From 84511d37eb0c8d771fd3ef07ab7c02eb232c92c5 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 12 Dec 2022 10:05:53 +0700 Subject: [PATCH 0001/1199] bump to 1.19.3 --- build.gradle.kts | 19 ++++++++++--------- gradle.properties | 5 +++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index cbf11166a..b05fb69f5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -192,21 +192,22 @@ dependencies { val configured_id: String by project val worldedit_fileid: String by project val more_overlays_version: String by project + val deps_mc_version: String by project - implementation(fg.deobf("top.theillusivec4.curios:curios-forge:${mc_version}-${curios_version}")) - compileOnly(fg.deobf("lain.mods.cos:CosmeticArmorReworked:${mc_version}-${cosmetic_armor_reworked_version}")) + compileOnly(fg.deobf("top.theillusivec4.curios:curios-forge:${deps_mc_version}-${curios_version}")) + compileOnly(fg.deobf("lain.mods.cos:CosmeticArmorReworked:${deps_mc_version}-${cosmetic_armor_reworked_version}")) - compileOnly(fg.deobf("mezz.jei:jei-${mc_version}-common-api:${jei_version}")) - compileOnly(fg.deobf("mezz.jei:jei-${mc_version}-forge-api:${jei_version}")) - runtimeOnly(fg.deobf("mezz.jei:jei-${mc_version}-forge:${jei_version}")) - // implementation("mcjty:theoneprobe:${mc_version}-${the_one_probe_version}:deobf") + compileOnly(fg.deobf("mezz.jei:jei-${deps_mc_version}-common-api:${jei_version}")) + compileOnly(fg.deobf("mezz.jei:jei-${deps_mc_version}-forge-api:${jei_version}")) + // runtimeOnly(fg.deobf("mezz.jei:jei-${deps_mc_version}-forge:${jei_version}")) + + // runtimeOnly(fg.deobf("curse.maven:jade-324717:${jade_id}")) + // runtimeOnly(fg.deobf("curse.maven:configured-457570:${configured_id}")) - runtimeOnly(fg.deobf("curse.maven:jade-324717:${jade_id}")) - runtimeOnly(fg.deobf("curse.maven:configured-457570:${configured_id}")) // runtimeOnly(fg.deobf("curse.maven:worldedit-225608:${worldedit_fileid}")) // runtimeOnly(fg.deobf("at.ridgo8.moreoverlays:MoreOverlays-updated:${more_overlays_version}")) - compileOnly(fg.deobf("mekanism:Mekanism:${mc_version}-${mekanism_version}:all")) + compileOnly(fg.deobf("mekanism:Mekanism:${deps_mc_version}-${mekanism_version}:all")) } } diff --git a/gradle.properties b/gradle.properties index 5890f6fe4..f87b48a72 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,9 +10,10 @@ mod_version=1.0 use_commit_hash_in_version=true -mc_version=1.19.2 +mc_version=1.19.3 +deps_mc_version=1.19.2 forge_gradle_version=5.1.27 -forge_version=43.1.43 +forge_version=44.0.11 mixingradle_version=0.7.32 mixin_version=0.8.5 From 889a312eec474439363cbd384a1ca744c2a791ac Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 22 Dec 2022 07:05:06 +0700 Subject: [PATCH 0002/1199] oh my god --- src/main/kotlin/ru/dbotthepony/mc/otm/core/EuclidMath.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/EuclidMath.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/EuclidMath.kt index cbdf67f10..8b08843ea 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/EuclidMath.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/EuclidMath.kt @@ -422,8 +422,8 @@ private fun ellipsoidShapeCacheKey(x: Int, y: Int, z: Int): Long { require(z > 0) { "Negative Z $z" } return (x.toLong() and 0xFFFFFL) or - ((y.toLong() ushr 20) and 0xFFFFFL) or - ((z.toLong() ushr 40) and 0xFFFFFL) + ((y.toLong() and 0xFFFFFL) shl 20) or + ((z.toLong() and 0xFFFFFL) shl 40) } private val blockShapeCache = Long2ObjectOpenHashMap>>() From 9be9e9756bf2234688633b7030a9698bea3bc529 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 23 Dec 2022 18:00:57 +0700 Subject: [PATCH 0003/1199] Bump version to 1.1 because 1.19.3 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index f87b48a72..68998d659 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ kotlin.stdlib.default.dependency=false org.gradle.vfs.watch=true mod_id=overdrive_that_matters -mod_version=1.0 +mod_version=1.1 use_commit_hash_in_version=true From 30929fc7e6ee91ef2d7f8203080adaebd3e83329 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 2 Jan 2023 13:04:20 +0700 Subject: [PATCH 0004/1199] Creative tabs updated --- .../mc/otm/OverdriveThatMatters.java | 15 +- .../otm/capability/MatteryPlayerCapability.kt | 11 +- .../mc/otm/item/EnergySwordItem.kt | 2 +- .../mc/otm/item/TritaniumArmorItem.kt | 2 +- .../mc/otm/item/weapon/AbstractWeaponItem.kt | 4 +- .../mc/otm/registry/CreativeTabs.kt | 161 ++++++++++++++++++ .../mc/otm/registry/MCreativeTabs.kt | 40 +++++ .../ru/dbotthepony/mc/otm/registry/MItems.kt | 140 ++++++++++----- .../dbotthepony/mc/otm/registry/MRegistry.kt | 87 +++++----- .../objects/ColoredDecorativeBlock.kt | 10 +- .../otm/registry/objects/DecorativeBlock.kt | 14 +- 11 files changed, 365 insertions(+), 121 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 61fb44f29..1e21f8c37 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -71,20 +71,6 @@ public final class OverdriveThatMatters { return new ResourceLocation(MOD_ID, path); } - public final CreativeModeTab CREATIVE_TAB = new CreativeModeTab("otm") { - @Override - public ItemStack makeIcon() { - return new ItemStack(MItems.INSTANCE.getBATTERY_CREATIVE(), 1); - } - }; - - public final CreativeModeTab CREATIVE_TAB_DECORATIVE = new CreativeModeTab("otm_decorative") { - @Override - public ItemStack makeIcon() { - return new ItemStack(MRegistry.INSTANCE.getVENT().getItem(), 1); - } - }; - private static void checkIfKotlinIsInstalled() { if (!KotlinVersion.CURRENT.isAtLeast(1, 6, 10)) { throw new UnsupportedClassVersionError("Installed kotlin version is " + KotlinVersion.CURRENT + ", when at least 1.6.10 is required."); @@ -132,6 +118,7 @@ public final class OverdriveThatMatters { modBus.addListener(EventPriority.NORMAL, TritaniumArmorModel::register); modBus.addListener(EventPriority.NORMAL, GravitationStabilizerModel::register); modBus.addListener(EventPriority.NORMAL, WidgetAtlasHolder::register); + modBus.addListener(EventPriority.NORMAL, MCreativeTabs.INSTANCE::populate); }); ClientConfig.INSTANCE.register(); diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index fd891abaa..7b6b7a843 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -825,21 +825,18 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial fun onPlayerCloneEvent(event: PlayerEvent.Clone) { val it = event.entity.matteryPlayer ?: return + var original = event.original.matteryPlayer - var resolver = event.original.getCapability(MatteryCapability.MATTERY_PLAYER) - - if (!resolver.isPresent || resolver.resolve().isEmpty) { + if (original == null) { event.original.reviveCaps() - resolver = event.original.getCapability(MatteryCapability.MATTERY_PLAYER) + original = event.original.matteryPlayer } - if (!resolver.isPresent || resolver.resolve().isEmpty) { + if (original == null) { event.original.invalidateCaps() return } - val original = resolver.resolve().get() - if (original.willBecomeAndroid && event.isWasDeath) { original.becomeAndroid() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt index 248b2cffd..d303d4852 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt @@ -59,7 +59,7 @@ fun getSweepingDamageRatioHook(ply: LivingEntity): Float? { return null } -class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)), Vanishable { +class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vanishable { val chargedAttributes: Multimap val dischargedAttributes: Multimap diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/TritaniumArmorItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/TritaniumArmorItem.kt index c26c0e48b..6c4c5e1bd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/TritaniumArmorItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/TritaniumArmorItem.kt @@ -68,7 +68,7 @@ private object TritaniumArmorRenderProperties : IClientItemExtensions { } } -class ItemTritaniumArmor(slot: EquipmentSlot) : ArmorItem(TritaniumArmorMaterial, slot, Properties().stacksTo(1).rarity(Rarity.RARE).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) { +class ItemTritaniumArmor(slot: EquipmentSlot) : ArmorItem(TritaniumArmorMaterial, slot, Properties().stacksTo(1).rarity(Rarity.RARE)) { override fun initializeClient(consumer: Consumer) { super.initializeClient(consumer) consumer.accept(TritaniumArmorRenderProperties) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt index 40c6a9f5d..1584f5682 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.item.weapon import com.mojang.blaze3d.systems.RenderSystem -import com.mojang.math.Vector3f import net.minecraft.client.Minecraft import net.minecraft.client.model.HumanoidModel import net.minecraft.client.renderer.block.model.ItemTransforms @@ -131,8 +130,7 @@ open class WeaponDataTable(val tag: CompoundTag) { } } -abstract class AbstractWeaponItem(val tables: KClass, rarity: Rarity = Rarity.UNCOMMON) : Item( - Properties().tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB).stacksTo(1).rarity(rarity)) { +abstract class AbstractWeaponItem(val tables: KClass, properties: Properties = Properties().stacksTo(1).rarity(Rarity.RARE)) : Item(properties) { fun makeDataTable(tag: CompoundTag) = tables.primaryConstructor!!.call(tag) /** diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt new file mode 100644 index 000000000..e8851322b --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt @@ -0,0 +1,161 @@ +package ru.dbotthepony.mc.otm.registry + +import net.minecraft.world.item.CreativeModeTab +import net.minecraft.world.item.DyeColor +import net.minecraft.world.item.Item + +private fun CreativeModeTab.Output.accept(values: Collection) { + for (item in values) { + accept(item) + } +} + +private fun CreativeModeTab.Output.base(values: Map) { + accept(values[null]!!) +} + +private val colorOrder = listOf( + null, + DyeColor.WHITE, + DyeColor.ORANGE, + DyeColor.MAGENTA, + DyeColor.LIGHT_BLUE, + DyeColor.YELLOW, + DyeColor.LIME, + DyeColor.PINK, + DyeColor.GRAY, + DyeColor.LIGHT_GRAY, + DyeColor.CYAN, + DyeColor.PURPLE, + DyeColor.BLUE, + DyeColor.BROWN, + DyeColor.GREEN, + DyeColor.RED, + DyeColor.BLACK, +) + +private fun CreativeModeTab.Output.colored(values: Map) { + accept(values[DyeColor.WHITE]!!) + accept(values[DyeColor.ORANGE]!!) + accept(values[DyeColor.MAGENTA]!!) + accept(values[DyeColor.LIGHT_BLUE]!!) + accept(values[DyeColor.YELLOW]!!) + accept(values[DyeColor.LIME]!!) + accept(values[DyeColor.PINK]!!) + accept(values[DyeColor.GRAY]!!) + accept(values[DyeColor.LIGHT_GRAY]!!) + accept(values[DyeColor.CYAN]!!) + accept(values[DyeColor.PURPLE]!!) + accept(values[DyeColor.BLUE]!!) + accept(values[DyeColor.BROWN]!!) + accept(values[DyeColor.GREEN]!!) + accept(values[DyeColor.RED]!!) + accept(values[DyeColor.BLACK]!!) +} + +private fun CreativeModeTab.Output.all(values: Map) { + base(values) + colored(values) +} + +internal fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { + with(consumer) { + accept(MItems.MACHINES) + + accept(MRegistry.CARGO_CRATES.item) + + base(MItems.TRITANIUM_DOOR) + base(MItems.TRITANIUM_TRAPDOOR) + + accept(MItems.MATTER_DUST) + + accept(MItems.TRITANIUM_ORE_CLUMP) + accept(MItems.TRITANIUM_DUST) + accept(MItems.TRITANIUM_INGOT) + accept(MItems.TRITANIUM_INGOT_BLOCK) + + accept(MItems.TRITANIUM_TOOLS) + accept(MItems.TRITANIUM_ARMOR) + + accept(MItems.ENERGY_SWORD) + accept(MItems.PLASMA_RIFLE) + + accept(MItems.BLACK_HOLE_SCANNER) + accept(MItems.GRAVITATION_FIELD_LIMITER) + accept(MItems.GRAVITATION_FIELD_SENSOR) + accept(MItems.PORTABLE_GRAVITATION_STABILIZER) + accept(MItems.BLACK_HOLE) + accept(MItems.GRAVITATIONAL_DISRUPTOR) + + accept(MItems.ALL_BATTERIES) + accept(MItems.MATTER_CAPACITORS) + + base(MItems.CARGO_CRATE_MINECARTS) + + accept(MItems.NUTRIENT_PASTE) + + // exo + accept(MItems.EXOPACK_PROBE) + accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_CREATIVE) + accept(MItems.ExopackUpgrades.CRAFTING_UPGRADE) + + accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_BIG) + accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_HUGE) + accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_WITHER) + accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_ENDER_DRAGON) + + accept(MItems.ExopackUpgrades.INVENTORY_UPGRADES) + // /exo + + accept(MItems.PILLS) + + accept(MItems.COMPONENTS) + } +} + +internal fun addDecorativeTabItems(consumer: CreativeModeTab.Output) { + with(consumer) { + accept(MItems.LABORATORY_LAMP) + accept(MItems.LABORATORY_LAMP_INVERTED) + accept(MItems.DANGER_STRIPE_BLOCK) + accept(MItems.METAL_BEAM) + + accept(MItems.TRITANIUM_STRIPED_BLOCK) + accept(MItems.TRITANIUM_STRIPED_STAIRS) + accept(MItems.TRITANIUM_STRIPED_SLAB) + accept(MItems.TRITANIUM_STRIPED_WALL) + accept(MItems.CARBON_FIBRE_BLOCK) + + colored(MItems.TRITANIUM_DOOR) + colored(MItems.TRITANIUM_TRAPDOOR) + + colored(MRegistry.CARGO_CRATES.items) + + colored(MItems.CARGO_CRATE_MINECARTS) + + all(MRegistry.DECORATIVE_CRATE.allItems) + + for (color in colorOrder) { + accept(MRegistry.TRITANIUM_BLOCK.allItems[color]!!) + accept(MRegistry.TRITANIUM_STAIRS.allItems[color]!!) + accept(MRegistry.TRITANIUM_SLAB.allItems[color]!!) + accept(MRegistry.TRITANIUM_WALL.allItems[color]!!) + } + + all(MRegistry.INDUSTRIAL_GLASS.allItems) + all(MRegistry.INDUSTRIAL_GLASS_PANE.allItems) + + colored(MRegistry.UNREFINED_FLOOR_TILES.items) + colored(MRegistry.FLOOR_TILES.items) + colored(MRegistry.FLOOR_TILES_STAIRS.items) + colored(MRegistry.FLOOR_TILES_SLAB.items) + + all(MRegistry.VENT.allItems) + all(MRegistry.VENT_ALTERNATIVE.allItems) + + accept(MRegistry.TRITANIUM_STRIPED_BLOCK.flatItems) + accept(MRegistry.TRITANIUM_STRIPED_STAIRS.flatItems) + accept(MRegistry.TRITANIUM_STRIPED_SLAB.flatItems) + accept(MRegistry.TRITANIUM_STRIPED_WALL.flatItems) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt new file mode 100644 index 000000000..aa7fe5cdd --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt @@ -0,0 +1,40 @@ +package ru.dbotthepony.mc.otm.registry + +import com.google.common.collect.Iterators +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap +import it.unimi.dsi.fastutil.objects.ReferenceLinkedOpenHashSet +import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet +import net.minecraft.resources.ResourceLocation +import net.minecraft.world.item.CreativeModeTab +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import net.minecraftforge.event.CreativeModeTabEvent +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.core.WriteOnce +import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.registry.MItems.BATTERY_CREATIVE + +object MCreativeTabs { + var MAIN by WriteOnce() + private set + var DECORATIVE by WriteOnce() + private set + + internal fun register(event: CreativeModeTabEvent.Register) { + MAIN = event.registerCreativeModeTab(ResourceLocation(OverdriveThatMatters.MOD_ID, "otm")) { + it.icon { ItemStack(BATTERY_CREATIVE, 1) } + + it.displayItems { features, consumer, flag -> + addMainCreativeTabItems(consumer) + } + } + + DECORATIVE = event.registerCreativeModeTab(ResourceLocation(OverdriveThatMatters.MOD_ID, "otm_decorative")) { + it.icon { ItemStack(MRegistry.VENT.item, 1) } + + it.displayItems { features, consumer, flag -> + addDecorativeTabItems(consumer) + } + } + } +} 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 6ecd83923..7f4862af9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -21,8 +21,7 @@ import ru.dbotthepony.mc.otm.item.* import ru.dbotthepony.mc.otm.item.weapon.PlasmaRifleItem object MItems { - private val DEFAULT_PROPERTIES = Item.Properties().stacksTo(64).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB) - private val DEFAULT_PROPERTIES_DECORATIVE = Item.Properties().stacksTo(64).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB_DECORATIVE) + private val DEFAULT_PROPERTIES = Item.Properties() private val registry: DeferredRegister = DeferredRegister.create(ForgeRegistries.ITEMS, OverdriveThatMatters.MOD_ID) internal fun register(bus: IEventBus) { @@ -92,7 +91,7 @@ object MItems { } val ENERGY_SERVO: Item by registry.register(MNames.ENERGY_SERVO) { - object : BlockItem(MBlocks.ENERGY_SERVO, DEFAULT_PROPERTIES){ + object : BlockItem(MBlocks.ENERGY_SERVO, DEFAULT_PROPERTIES) { override fun appendHoverText( p_40572_: ItemStack, p_40573_: Level?, @@ -134,7 +133,7 @@ object MItems { BlockTags.NEEDS_IRON_TOOL ) { Ingredient.of(TRITANIUM_INGOT) } - private val TOOLS_PROPRTIES = Item.Properties().tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB) + private val TOOLS_PROPRTIES = Item.Properties() val TRITANIUM_SWORD: Item by registry.register(MNames.TRITANIUM_SWORD) { SwordItem(TRITANIUM_COMPONENT, 4, -2.7f, TOOLS_PROPRTIES) } val TRITANIUM_SHOVEL: Item by registry.register(MNames.TRITANIUM_SHOVEL) { ShovelItem(TRITANIUM_COMPONENT, 1.5f, -2.4f, TOOLS_PROPRTIES) } @@ -193,6 +192,13 @@ object MItems { val PILL_OBLIVION: Item by registry.register(MNames.PILL_OBLIVION) { PillItem(PillType.OBLIVION) } val PILL_HEAL: Item by registry.register(MNames.PILL_HEAL) { HealPillItem() } + val PILLS = SupplierList( + ::PILL_ANDROID, + ::PILL_HUMANE, + ::PILL_OBLIVION, + ::PILL_HEAL, + ) + val BATTERY_CRUDE: Item by registry.register(MNames.BATTERY_CRUDE) { CrudeBatteryItem() } val BATTERY_BASIC: Item by registry.register(MNames.BATTERY_BASIC) { BatteryItem(ServerConfig.BATTERY_BASIC) } val BATTERY_NORMAL: Item by registry.register(MNames.BATTERY_NORMAL) { BatteryItem(ServerConfig.BATTERY_NORMAL) } @@ -206,11 +212,31 @@ object MItems { val ZPM_BATTERY: Item by registry.register(MNames.ZPM_BATTERY) { ZPMItem() } val BATTERIES = SupplierList( - { BATTERY_CRUDE }, - { BATTERY_BASIC }, - { BATTERY_NORMAL }, - { BATTERY_DENSE }, - { BATTERY_CAPACITOR }, + ::BATTERY_CRUDE, + ::BATTERY_BASIC, + ::BATTERY_NORMAL, + ::BATTERY_DENSE, + ::BATTERY_CAPACITOR, + ) + + val UNIQUE_BATTERIES = SupplierList( + ::QUANTUM_BATTERY, + ::QUANTUM_CAPACITOR, + ::QUANTUM_BATTERY_CREATIVE, + ::ZPM_BATTERY, + ) + + val ALL_BATTERIES = SupplierList( + ::BATTERY_CRUDE, + ::BATTERY_BASIC, + ::BATTERY_NORMAL, + ::BATTERY_DENSE, + ::BATTERY_CAPACITOR, + + ::QUANTUM_BATTERY, + ::QUANTUM_CAPACITOR, + ::QUANTUM_BATTERY_CREATIVE, + ::ZPM_BATTERY, ) val MATTER_CAPACITOR_BASIC: Item by registry.register(MNames.MATTER_CAPACITOR_BASIC) { MatterCapacitorItem(ServerConfig::MATTER_CAPACITOR_BASIC) } @@ -218,6 +244,13 @@ object MItems { val MATTER_CAPACITOR_DENSE: Item by registry.register(MNames.MATTER_CAPACITOR_DENSE) { MatterCapacitorItem(ServerConfig::MATTER_CAPACITOR_DENSE) } val MATTER_CAPACITOR_CREATIVE: Item by registry.register(MNames.MATTER_CAPACITOR_CREATIVE) { MatterCapacitorItem() } + val MATTER_CAPACITORS = SupplierList( + ::MATTER_CAPACITOR_BASIC, + ::MATTER_CAPACITOR_NORMAL, + ::MATTER_CAPACITOR_DENSE, + ::MATTER_CAPACITOR_CREATIVE, + ) + val PATTERN_DRIVE_NORMAL: Item by registry.register(MNames.PATTERN_DRIVE_NORMAL) { PatternStorageItem(ServerConfig::PATTERN_DRIVE_NORMAL) } val PATTERN_DRIVE_CREATIVE: Item by registry.register(MNames.PATTERN_DRIVE_CREATIVE) { PatternStorageItem() } val PATTERN_DRIVE_CREATIVE2: Item by registry.register(MNames.PATTERN_DRIVE_CREATIVE2) { CreativePatternItem() } @@ -225,16 +258,15 @@ object MItems { val PORTABLE_CONDENSATION_DRIVE: Item by registry.register(MNames.PORTABLE_CONDENSATION_DRIVE) { PortableCondensationDriveItem(4000) } val PORTABLE_DENSE_CONDENSATION_DRIVE: Item by registry.register(MNames.PORTABLE_DENSE_CONDENSATION_DRIVE) { PortableCondensationDriveItem(25000) } - val NUTRIENT_PASTE: Item by registry.register(MNames.NUTRIENT_PASTE) { Item(Item.Properties().stacksTo(64).food( - FoodProperties.Builder().meat().nutrition(8).saturationMod(0.9F).build()).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) } + val NUTRIENT_PASTE: Item by registry.register(MNames.NUTRIENT_PASTE) { Item(Item.Properties().stacksTo(64).food(FoodProperties.Builder().meat().nutrition(8).saturationMod(0.9F).build())) } - val LABORATORY_LAMP: Item by registry.register(MNames.LABORATORY_LAMP) { BlockItem(MBlocks.LABORATORY_LAMP, DEFAULT_PROPERTIES_DECORATIVE) } - val LABORATORY_LAMP_INVERTED: Item by registry.register(MNames.LABORATORY_LAMP_INVERTED) { BlockItem(MBlocks.LABORATORY_LAMP_INVERTED, DEFAULT_PROPERTIES_DECORATIVE) } - val DANGER_STRIPE_BLOCK: Item by registry.register(MNames.DANGER_STRIPE_BLOCK) { BlockItem(MBlocks.DANGER_STRIPE_BLOCK, DEFAULT_PROPERTIES_DECORATIVE) } - val METAL_BEAM: Item by registry.register(MNames.METAL_BEAM) { BlockItem(MBlocks.METAL_BEAM, DEFAULT_PROPERTIES_DECORATIVE) } + val LABORATORY_LAMP: Item by registry.register(MNames.LABORATORY_LAMP) { BlockItem(MBlocks.LABORATORY_LAMP, DEFAULT_PROPERTIES) } + val LABORATORY_LAMP_INVERTED: Item by registry.register(MNames.LABORATORY_LAMP_INVERTED) { BlockItem(MBlocks.LABORATORY_LAMP_INVERTED, DEFAULT_PROPERTIES) } + val DANGER_STRIPE_BLOCK: Item by registry.register(MNames.DANGER_STRIPE_BLOCK) { BlockItem(MBlocks.DANGER_STRIPE_BLOCK, DEFAULT_PROPERTIES) } + val METAL_BEAM: Item by registry.register(MNames.METAL_BEAM) { BlockItem(MBlocks.METAL_BEAM, DEFAULT_PROPERTIES) } - val TRITANIUM_DOOR = registry.allColored(MNames.TRITANIUM_DOOR) { color, _ -> DoubleHighBlockItem(MBlocks.TRITANIUM_DOOR[color]!!, if (color == null) DEFAULT_PROPERTIES else DEFAULT_PROPERTIES_DECORATIVE) } - val TRITANIUM_TRAPDOOR = registry.allColored(MNames.TRITANIUM_TRAPDOOR) { color, _ -> BlockItem(MBlocks.TRITANIUM_TRAPDOOR[color]!!, if (color == null) DEFAULT_PROPERTIES else DEFAULT_PROPERTIES_DECORATIVE) } + val TRITANIUM_DOOR = registry.allColored(MNames.TRITANIUM_DOOR) { color, _ -> DoubleHighBlockItem(MBlocks.TRITANIUM_DOOR[color]!!, DEFAULT_PROPERTIES) } + val TRITANIUM_TRAPDOOR = registry.allColored(MNames.TRITANIUM_TRAPDOOR) { color, _ -> BlockItem(MBlocks.TRITANIUM_TRAPDOOR[color]!!, DEFAULT_PROPERTIES) } init { MRegistry.TRITANIUM_PRESSURE_PLATE.registerItems(registry) @@ -273,24 +305,54 @@ object MItems { } } } + /** + * List of components for everything else + */ + val COMPONENTS = SupplierList( + ::MATTER_IO_PORT, + ::MATTER_TRANSFORM_MATRIX, + ::ENERGY_BUS, + ::ELECTRIC_PARTS, + ::MACHINE_FRAME, + ::TRITANIUM_PLATE, + ::IRON_PLATE, + ::GOLD_PLATE, + ::COPPER_WIRING, + ::GOLD_WIRING, + ::PORTABLE_CONDENSATION_DRIVE_CASING, + ::PORTABLE_DENSE_CONDENSATION_DRIVE_CASING, + ::CIRCUIT_PLATING, + ::BASIC_CONTROL_CIRCUIT, + ::ADVANCED_CONTROL_CIRCUIT, + ::MATTER_CAPACITOR_PARTS, + + ::QUANTUM_TRANSCEIVER, + ::ELECTROMAGNET, + ::MIRROR_COMPOUND, + ::MIRROR, + ) + + /** + * List of components for datagen code + */ val DATAGEN_COMPONENTS = SupplierList( - { ENERGY_BUS }, - { ELECTRIC_PARTS }, - { TRITANIUM_PLATE }, - { IRON_PLATE }, - { GOLD_PLATE }, - { COPPER_WIRING }, - { GOLD_WIRING }, - { CIRCUIT_PLATING }, - { BASIC_CONTROL_CIRCUIT }, - { ADVANCED_CONTROL_CIRCUIT }, - { MATTER_CAPACITOR_PARTS }, - { MATTER_IO_PORT }, - { MATTER_TRANSFORM_MATRIX }, - { QUANTUM_TRANSCEIVER }, - { ELECTROMAGNET }, - { MIRROR_COMPOUND }, - { MIRROR }, + ::ENERGY_BUS, + ::ELECTRIC_PARTS, + ::TRITANIUM_PLATE, + ::IRON_PLATE, + ::GOLD_PLATE, + ::COPPER_WIRING, + ::GOLD_WIRING, + ::CIRCUIT_PLATING, + ::BASIC_CONTROL_CIRCUIT, + ::ADVANCED_CONTROL_CIRCUIT, + ::MATTER_CAPACITOR_PARTS, + ::MATTER_IO_PORT, + ::MATTER_TRANSFORM_MATRIX, + ::QUANTUM_TRANSCEIVER, + ::ELECTROMAGNET, + ::MIRROR_COMPOUND, + ::MIRROR, ) val CARGO_CRATE_MINECARTS = registry.allColored(MNames.MINECART_CARGO_CRATE) { color, _ -> MinecartCargoCrateItem(color) } @@ -325,11 +387,11 @@ object MItems { MRegistry.TRITANIUM_WALL.registerItems(registry) } - val TRITANIUM_STRIPED_BLOCK: Item by registry.register(MNames.TRITANIUM_STRIPED_BLOCK) { BlockItem(MBlocks.TRITANIUM_STRIPED_BLOCK, DEFAULT_PROPERTIES_DECORATIVE) } - val TRITANIUM_STRIPED_STAIRS: Item by registry.register(MNames.TRITANIUM_STRIPED_STAIRS) { BlockItem(MBlocks.TRITANIUM_STRIPED_STAIRS, DEFAULT_PROPERTIES_DECORATIVE) } - val TRITANIUM_STRIPED_SLAB: Item by registry.register(MNames.TRITANIUM_STRIPED_SLAB) { BlockItem(MBlocks.TRITANIUM_STRIPED_SLAB, DEFAULT_PROPERTIES_DECORATIVE) } - val TRITANIUM_STRIPED_WALL: Item by registry.register(MNames.TRITANIUM_STRIPED_WALL) { BlockItem(MBlocks.TRITANIUM_STRIPED_WALL, DEFAULT_PROPERTIES_DECORATIVE) } - val CARBON_FIBRE_BLOCK: Item by registry.register(MNames.CARBON_FIBRE_BLOCK) { BlockItem(MBlocks.CARBON_FIBRE_BLOCK, DEFAULT_PROPERTIES_DECORATIVE) } + val TRITANIUM_STRIPED_BLOCK: Item by registry.register(MNames.TRITANIUM_STRIPED_BLOCK) { BlockItem(MBlocks.TRITANIUM_STRIPED_BLOCK, DEFAULT_PROPERTIES) } + val TRITANIUM_STRIPED_STAIRS: Item by registry.register(MNames.TRITANIUM_STRIPED_STAIRS) { BlockItem(MBlocks.TRITANIUM_STRIPED_STAIRS, DEFAULT_PROPERTIES) } + val TRITANIUM_STRIPED_SLAB: Item by registry.register(MNames.TRITANIUM_STRIPED_SLAB) { BlockItem(MBlocks.TRITANIUM_STRIPED_SLAB, DEFAULT_PROPERTIES) } + val TRITANIUM_STRIPED_WALL: Item by registry.register(MNames.TRITANIUM_STRIPED_WALL) { BlockItem(MBlocks.TRITANIUM_STRIPED_WALL, DEFAULT_PROPERTIES) } + val CARBON_FIBRE_BLOCK: Item by registry.register(MNames.CARBON_FIBRE_BLOCK) { BlockItem(MBlocks.CARBON_FIBRE_BLOCK, DEFAULT_PROPERTIES) } init { MRegistry.INDUSTRIAL_GLASS.registerItems(registry) 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 da076c070..a28adeca3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -57,113 +57,115 @@ object MRegistry { features.build(event) } - val CARGO_CRATES = DecorativeBlock(MNames.CARGO_CRATE, ::CargoCrateBlock, baseItemGroup = OverdriveThatMatters.INSTANCE.CREATIVE_TAB) + val CARGO_CRATES = DecorativeBlock(MNames.CARGO_CRATE, ::CargoCrateBlock) - val DECORATIVE_CRATE = DecorativeBlock.simple(MNames.DECORATIVE_CRATE, { + val DECORATIVE_CRATE = DecorativeBlock.simple(MNames.DECORATIVE_CRATE) { BlockBehaviour.Properties.of(Material.METAL, it?.materialColor ?: MaterialColor.SNOW) .sound(SoundType.METAL) .requiresCorrectToolForDrops() .explosionResistance(10f) .destroyTime(1f) - }) + } - val TRITANIUM_BLOCK = DecorativeBlock.simple(MNames.TRITANIUM_BLOCK, { + val TRITANIUM_BLOCK = DecorativeBlock.simple(MNames.TRITANIUM_BLOCK) { BlockBehaviour.Properties.of(Material.METAL, it?.materialColor ?: MaterialColor.COLOR_LIGHT_BLUE) .sound(SoundType.BASALT) .requiresCorrectToolForDrops() .explosionResistance(80f) .destroyTime(2.5f) - }) + } - val TRITANIUM_STAIRS = DecorativeBlock(MNames.TRITANIUM_STAIRS, { + val TRITANIUM_STAIRS = DecorativeBlock(MNames.TRITANIUM_STAIRS) { StairBlock( { TRITANIUM_BLOCK.allBlocks[it]!!.defaultBlockState() }, BlockBehaviour.Properties.copy(TRITANIUM_BLOCK.allBlocks[it]!!) ) - }) + } - val TRITANIUM_SLAB = DecorativeBlock(MNames.TRITANIUM_SLAB, { + val TRITANIUM_SLAB = DecorativeBlock(MNames.TRITANIUM_SLAB) { SlabBlock(BlockBehaviour.Properties.copy(TRITANIUM_BLOCK.allBlocks[it]!!)) - }) + } - val TRITANIUM_WALL = DecorativeBlock(MNames.TRITANIUM_WALL, { + val TRITANIUM_WALL = DecorativeBlock(MNames.TRITANIUM_WALL) { WallBlock(BlockBehaviour.Properties.copy(TRITANIUM_BLOCK.allBlocks[it]!!)) - }) + } val TRITANIUM_PRESSURE_PLATE = DecorativeBlock(MNames.TRITANIUM_PRESSURE_PLATE, ::TritaniumPressurePlate) - val VENT = DecorativeBlock.simple(MNames.VENT, { + val VENT = DecorativeBlock.simple(MNames.VENT) { BlockBehaviour.Properties.of(Material.METAL, it?.materialColor ?: MaterialColor.COLOR_LIGHT_BLUE) .sound(SoundType.BASALT) .requiresCorrectToolForDrops() .explosionResistance(20f) .destroyTime(1.5f) - }) + } - val VENT_ALTERNATIVE = DecorativeBlock.simple(MNames.VENT_ALTERNATIVE, { + val VENT_ALTERNATIVE = DecorativeBlock.simple(MNames.VENT_ALTERNATIVE) { BlockBehaviour.Properties.of(Material.METAL, it?.materialColor ?: MaterialColor.COLOR_LIGHT_BLUE) .sound(SoundType.BASALT) .requiresCorrectToolForDrops() .explosionResistance(20f) .destroyTime(1.5f) - }) + } - val FLOOR_TILES = ColoredDecorativeBlock.simple(MNames.FLOOR_TILES, { + val FLOOR_TILES = ColoredDecorativeBlock.simple(MNames.FLOOR_TILES) { BlockBehaviour.Properties.of(Material.STONE, it.materialColor) .sound(SoundType.STONE) .requiresCorrectToolForDrops() .strength(1.5f, 6f) - }) + } - val FLOOR_TILES_STAIRS = ColoredDecorativeBlock(MNames.FLOOR_TILES_STAIRS, { + val FLOOR_TILES_STAIRS = ColoredDecorativeBlock(MNames.FLOOR_TILES_STAIRS) { StairBlock( { FLOOR_TILES.blocks[it]!!.defaultBlockState() }, BlockBehaviour.Properties.copy(FLOOR_TILES.blocks[it]!!) ) - }) + } - val FLOOR_TILES_SLAB = ColoredDecorativeBlock(MNames.FLOOR_TILES_SLAB, { + val FLOOR_TILES_SLAB = ColoredDecorativeBlock(MNames.FLOOR_TILES_SLAB) { SlabBlock(BlockBehaviour.Properties.copy(FLOOR_TILES.blocks[it]!!)) - }) + } - val UNREFINED_FLOOR_TILES = ColoredDecorativeBlock.simple(MNames.UNREFINED_FLOOR_TILES, { + val UNREFINED_FLOOR_TILES = ColoredDecorativeBlock.simple(MNames.UNREFINED_FLOOR_TILES) { BlockBehaviour.Properties.of(Material.CLAY, it.materialColor) .sound(SoundType.GRAVEL) .strength(1f, 2f) - }) + } - val INDUSTRIAL_GLASS = DecorativeBlock(MNames.INDUSTRIAL_GLASS, { color -> - val properties = BlockBehaviour.Properties.of(Material.GLASS, if (color != null) color.materialColor else MaterialColor.NONE) - .destroyTime(1.5f) - .explosionResistance(40f) - .requiresCorrectToolForDrops() - .sound(SoundType.GLASS) - .noOcclusion() - .isValidSpawn { _: BlockState, _: BlockGetter, _: BlockPos, _: EntityType<*>? -> false } - .isRedstoneConductor { _: BlockState, _: BlockGetter, _: BlockPos -> false } - .isSuffocating { _: BlockState, _: BlockGetter, _: BlockPos -> false } - .isViewBlocking { _: BlockState, _: BlockGetter, _: BlockPos -> false } + val INDUSTRIAL_GLASS = DecorativeBlock(MNames.INDUSTRIAL_GLASS) { color -> + val properties = + BlockBehaviour.Properties.of(Material.GLASS, if (color != null) color.materialColor else MaterialColor.NONE) + .destroyTime(1.5f) + .explosionResistance(40f) + .requiresCorrectToolForDrops() + .sound(SoundType.GLASS) + .noOcclusion() + .isValidSpawn { _: BlockState, _: BlockGetter, _: BlockPos, _: EntityType<*>? -> false } + .isRedstoneConductor { _: BlockState, _: BlockGetter, _: BlockPos -> false } + .isSuffocating { _: BlockState, _: BlockGetter, _: BlockPos -> false } + .isViewBlocking { _: BlockState, _: BlockGetter, _: BlockPos -> false } if (color != null) { return@DecorativeBlock StainedGlassBlock(color, properties) } return@DecorativeBlock GlassBlock(properties) - }) + } - val INDUSTRIAL_GLASS_PANE = DecorativeBlock(MNames.INDUSTRIAL_GLASS_PANE, { color -> - val properties = BlockBehaviour.Properties.of(Material.GLASS, if (color != null) color.materialColor else MaterialColor.NONE) - .strength(1.25f, 5.0f) - .requiresCorrectToolForDrops() - .sound(SoundType.GLASS) - .noOcclusion() + val INDUSTRIAL_GLASS_PANE = DecorativeBlock(MNames.INDUSTRIAL_GLASS_PANE) { color -> + val properties = + BlockBehaviour.Properties.of(Material.GLASS, if (color != null) color.materialColor else MaterialColor.NONE) + .strength(1.25f, 5.0f) + .requiresCorrectToolForDrops() + .sound(SoundType.GLASS) + .noOcclusion() if (color != null) { return@DecorativeBlock StainedGlassPaneBlock(color, properties) } return@DecorativeBlock IronBarsBlock(properties) - }) + } val CRATE_RED = CrateProperties(MaterialColor.COLOR_RED, "crate_red") val CRATE_BLUE = CrateProperties(MaterialColor.COLOR_BLUE, "crate_blue") @@ -225,6 +227,7 @@ object MRegistry { bus.addListener(this::initializeClient) bus.addListener(this::initializeCommon) bus.addListener(MStats::registerVanilla) + bus.addListener(MCreativeTabs::register) MBlocks.register(bus) MBlockEntities.register(bus) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/ColoredDecorativeBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/ColoredDecorativeBlock.kt index 81416befa..07c3fd7a1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/ColoredDecorativeBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/ColoredDecorativeBlock.kt @@ -8,7 +8,6 @@ import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockBehaviour import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.RegistryObject -import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.core.SupplierMap import java.util.EnumMap @@ -19,7 +18,6 @@ import java.util.EnumMap open class ColoredDecorativeBlock( val baseName: String, private val provider: (DyeColor) -> Block, - itemGroup: CreativeModeTab = OverdriveThatMatters.INSTANCE.CREATIVE_TAB_DECORATIVE ) { var registeredItems = false private set @@ -111,7 +109,7 @@ open class ColoredDecorativeBlock( registeredBlocks = true } - private val properties = Item.Properties().tab(itemGroup).stacksTo(64) + private val properties = Item.Properties().stacksTo(64) open fun registerItems(registry: DeferredRegister) { check(itemMap.isEmpty()) { "( ͡° ͜ʖ ͡°) No. \\(• ε •)/ ( ͠° ل͜ ͡°) ( ͠° ͟ ͟ʖ ͡°) (ง ͠° ͟ل͜ ͡°)ง ( ͡°︺͡°) ('ω')" } @@ -138,10 +136,10 @@ open class ColoredDecorativeBlock( } companion object { - fun simple(baseName: String, provider: (DyeColor) -> BlockBehaviour.Properties, itemGroup: CreativeModeTab = OverdriveThatMatters.INSTANCE.CREATIVE_TAB_DECORATIVE): ColoredDecorativeBlock { - return ColoredDecorativeBlock(baseName, { + fun simple(baseName: String, provider: (DyeColor) -> BlockBehaviour.Properties): ColoredDecorativeBlock { + return ColoredDecorativeBlock(baseName) { Block(provider.invoke(it)) - }, itemGroup) + } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/DecorativeBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/DecorativeBlock.kt index 2ba5ac727..8aeafeabf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/DecorativeBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/DecorativeBlock.kt @@ -8,9 +8,9 @@ import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockBehaviour import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.RegistryObject -import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.core.SupplierMap import ru.dbotthepony.mc.otm.core.WriteOnce +import ru.dbotthepony.mc.otm.registry.MCreativeTabs /** * Base + Colored @@ -18,9 +18,7 @@ import ru.dbotthepony.mc.otm.core.WriteOnce class DecorativeBlock( baseName: String, private val provider: (DyeColor?) -> Block, - itemGroup: CreativeModeTab = OverdriveThatMatters.INSTANCE.CREATIVE_TAB_DECORATIVE, - val baseItemGroup: CreativeModeTab = OverdriveThatMatters.INSTANCE.CREATIVE_TAB_DECORATIVE, -) : ColoredDecorativeBlock(baseName, provider, itemGroup) { +) : ColoredDecorativeBlock(baseName, provider) { private var _block: RegistryObject by WriteOnce() private var _item: RegistryObject by WriteOnce() @@ -43,15 +41,15 @@ class DecorativeBlock( } override fun registerItems(registry: DeferredRegister) { - _item = registry.register(baseName) { BlockItem(_block.get(), Item.Properties().tab(baseItemGroup).stacksTo(64)) } + _item = registry.register(baseName) { BlockItem(_block.get(), Item.Properties().stacksTo(64)) } super.registerItems(registry) } companion object { - fun simple(baseName: String, provider: (DyeColor?) -> BlockBehaviour.Properties, itemGroup: CreativeModeTab = OverdriveThatMatters.INSTANCE.CREATIVE_TAB_DECORATIVE): DecorativeBlock { - return DecorativeBlock(baseName, { + fun simple(baseName: String, provider: (DyeColor?) -> BlockBehaviour.Properties): DecorativeBlock { + return DecorativeBlock(baseName) { Block(provider.invoke(it)) - }, itemGroup) + } } } } From 1bb643d91b8fbc12d9d07fe5c44b458c725fe614 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 7 Jan 2023 01:32:30 +0700 Subject: [PATCH 0005/1199] update euclid math extensions --- .../ru/dbotthepony/mc/otm/core/EuclidMath.kt | 94 ++++++----- .../ru/dbotthepony/mc/otm/core/MatrixExt.kt | 149 +++--------------- 2 files changed, 78 insertions(+), 165 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/EuclidMath.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/EuclidMath.kt index 8b08843ea..fd4feaff2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/EuclidMath.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/EuclidMath.kt @@ -1,15 +1,16 @@ package ru.dbotthepony.mc.otm.core -import com.mojang.math.Matrix3f -import com.mojang.math.Matrix4f -import com.mojang.math.Quaternion -import com.mojang.math.Vector3f -import it.unimi.dsi.fastutil.longs.Long2ObjectAVLTreeMap import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap import net.minecraft.core.BlockPos import net.minecraft.core.Direction import net.minecraft.core.Vec3i import net.minecraft.world.phys.Vec3 +import org.joml.AxisAngle4f +import org.joml.Matrix3f +import org.joml.Matrix4f +import org.joml.Quaternionf +import org.joml.Vector3f +import java.lang.Math.toDegrees import java.lang.ref.SoftReference import kotlin.math.* @@ -22,6 +23,12 @@ val VECTOR_DOWN = Vector(0.0, -1.0, 0.0) val VECTOR_RIGHT = Vector(0.0, 0.0, 1.0) val VECTOR_LEFT = Vector(0.0, 0.0, -1.0) +private const val DEGREES_TO_RADIANS = 0.017453292f + +fun toRadians(angle: Float): Float { + return angle * DEGREES_TO_RADIANS +} + fun Vector.asAngle(): Angle { val norm = normalize() return Angle(asin(norm.y), atan2(norm.x, norm.z)) @@ -33,39 +40,33 @@ fun Vector.asMutableAngle(): MutableAngle { } fun Vector3f.asAngle(): Angle { - val len = length() + val len = length().toDouble() val norm = Vector(x() / len, y() / len, z() / len) return Angle(asin(norm.y), atan2(norm.x, norm.z)) } fun Vector3f.asMutableAngle(): MutableAngle { - val len = length() + val len = length().toDouble() val norm = Vector(x() / len, y() / len, z() / len) return MutableAngle(asin(norm.y), atan2(norm.x, norm.z)) } +fun Vector3f.rotation(radians: Float): Quaternionf { + return Quaternionf(AxisAngle4f(radians, x, y, z)) +} + +fun Vector3f.rotationDegrees(degrees: Float): Quaternionf { + return rotation(toRadians(degrees)) +} + operator fun Vector3f.unaryMinus(): Vector3f { - setX(-x()) - setY(-y()) - setZ(-z()) + x = -x + y = -y + z = -z return this } -fun Vector3f.length() = sqrt(x().toDouble() * x() + y().toDouble() * y() + z().toDouble() * z()) - -operator fun Vector3f.times(v: Float): Vector3f { - setX(x() * v) - setY(y() * v) - setZ(z() * v) - return this -} - -operator fun Vector3f.div(v: Float): Vector3f { - setX(x() / v) - setY(y() / v) - setZ(z() / v) - return this -} +operator fun Vector3f.times(v: Float): Vector3f = mul(v) operator fun Vector3f.component1() = x() operator fun Vector3f.component2() = y() @@ -140,8 +141,14 @@ fun Vector.asVector3f(): Vector3f { return Vector3f(x.toFloat(), y.toFloat(), z.toFloat()) } -fun Quaternion(vec: Vector, rotation: Float, isDegrees: Boolean = false): Quaternion { - return Quaternion(vec.asVector3f(), rotation, isDegrees) +fun Quaternion(vec: Vector, rotation: Float, isDegrees: Boolean = false): Quaternionf { + // TODO: 1.19.3 + return Quaternionf(AxisAngle4f(if (isDegrees) toRadians(rotation) else rotation, vec.x.toFloat(), vec.y.toFloat(), vec.z.toFloat())) +} + +fun AxisAngle4f(vec: Vector, rotation: Float, isDegrees: Boolean = false): AxisAngle4f { + // TODO: 1.19.3 + return AxisAngle4f(if (isDegrees) toRadians(rotation) else rotation, vec.x.toFloat(), vec.y.toFloat(), vec.z.toFloat()) } fun Vector(x: Double): Vector { @@ -152,17 +159,24 @@ fun Vector(x: Double, y: Double): Vector { return Vector(x, y, 0.0) } -fun Vector.rotate(q: Quaternion): Vector { - val quaternion = Quaternion(q) - quaternion.mul(Quaternion(x.toFloat(), y.toFloat(), z.toFloat(), 0.0f)) - val quaternion1 = Quaternion(q) - quaternion1.conj() +fun Vector.rotate(q: Quaternionf): Vector { + // TODO: 1.19.3 + val quaternion = Quaternionf(q) + quaternion.mul(rotateAroundThis()) + val quaternion1 = Quaternionf(q) + quaternion1.conjugate() quaternion.mul(quaternion1) - return Vector(quaternion.i().toDouble(), quaternion.j().toDouble(), quaternion.k().toDouble()) + return Vector(quaternion.x.toDouble(), quaternion.y.toDouble(), quaternion.z.toDouble()) } -fun Vector.rotateAroundThis(rotation: Float, isDegrees: Boolean = false): Quaternion { - return Quaternion(this, rotation, isDegrees) +fun Vector.rotateAroundThis(rotation: Float, isDegrees: Boolean = false): Quaternionf { + // TODO: 1.19.3 + return Quaternionf(AxisAngle4f(if (isDegrees) toRadians(rotation) else rotation, x.toFloat(), y.toFloat(), z.toFloat())) +} + +fun Vector.rotateAroundThis(): Quaternionf { + // TODO: 1.19.3 + return Quaternionf(AxisAngle4f(0f, x.toFloat(), y.toFloat(), z.toFloat())) } fun Vector.asMatrix(): Matrix3f { @@ -197,7 +211,7 @@ interface IAngle { fun rotationX(): Matrix3f { if (roll == 0.0) { - return Matrix3f().also { it.identityFast() } + return Matrix3f().also { it.identity() } } return Matrix3f().also { @@ -214,7 +228,7 @@ interface IAngle { fun rotationZ(): Matrix3f { if (pitch == 0.0) { - return Matrix3f().also { it.identityFast() } + return Matrix3f().also { it.identity() } } return Matrix3f().also { @@ -231,7 +245,7 @@ interface IAngle { fun rotationY(): Matrix3f { if (yaw == 0.0) { - return Matrix3f().also { it.identityFast() } + return Matrix3f().also { it.identity() } } return Matrix3f().also { @@ -250,7 +264,7 @@ interface IAngle { fun rotationXYZ(): Matrix3f { if (pitch == 0.0 && yaw == 0.0 && roll == 0.0) - return Matrix3f().also { it.identityFast() } + return Matrix3f().also { it.identity() } return rotationY().also { it.mul(rotationZ()) @@ -260,7 +274,7 @@ interface IAngle { fun rotationXYZW(): Matrix4f { if (pitch == 0.0 && yaw == 0.0 && roll == 0.0) - return Matrix4f().also { it.identityFast() } + return Matrix4f().also { it.identity() } return rotationXYZ().toMatrix4f().also { it[3, 3] = 1f } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/MatrixExt.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/MatrixExt.kt index 3e8b1d6d3..770b60ec1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/MatrixExt.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/MatrixExt.kt @@ -3,13 +3,13 @@ package ru.dbotthepony.mc.otm.core -import com.mojang.math.Matrix3f -import com.mojang.math.Matrix4f -import com.mojang.math.Vector3f -import com.mojang.math.Vector4f +import org.joml.Matrix3f +import org.joml.Matrix4f +import org.joml.Vector3f +import org.joml.Vector4f fun Matrix4f.rotate(angle: IAngle): Matrix4f { - multiply(angle.rotationXYZW()) + mul(angle.rotationXYZW()) return this } @@ -20,164 +20,63 @@ fun Matrix4f.translate(vector: Vector) { fun Matrix4f.rotateAroundPoint(point: Vector, axis: Vector, rotation: Float, isDegrees: Boolean = false) { val p = point.asVector3f() translate(-p) - multiply(axis.rotateAroundThis(rotation, isDegrees)) + rotation(axis.rotateAroundThis(rotation, isDegrees)) // TODO: 1.19.3 translate(-p) } fun Matrix4f.rotateAroundPoint(point: Vector, axis: Vector3f, rotation: Float, isDegrees: Boolean = false) { val p = point.asVector3f() translate(-p) - multiply(if (isDegrees) axis.rotationDegrees(rotation) else axis.rotation(rotation)) + rotation(if (isDegrees) axis.rotationDegrees(rotation) else axis.rotation(rotation)) // TODO: 1.19.3 translate(-p) } fun Matrix4f.rotateAroundPoint(point: Vector, rotation: IAngle) { val p = point.asVector3f() translate(-p) - multiply(rotation.rotationXYZW()) + mul(rotation.rotationXYZW()) translate(-p) } fun Matrix4f.rotateAroundPoint(point: Vector3f, axis: Vector, rotation: Float, isDegrees: Boolean = false) { translate(-point) - multiply(axis.rotateAroundThis(rotation, isDegrees)) + rotation(axis.rotateAroundThis(rotation, isDegrees)) // TODO: 1.19.3 translate(-point) } fun Matrix4f.rotateAroundPoint(point: Vector3f, rotation: IAngle) { translate(-point) - multiply(rotation.rotationXYZW()) + mul(rotation.rotationXYZW()) translate(-point) } fun Matrix4f.rotateAroundPoint(point: Vector3f, axis: Vector3f, rotation: Float, isDegrees: Boolean = false) { translate(-point) - multiply(if (isDegrees) axis.rotationDegrees(rotation) else axis.rotation(rotation)) + rotation(if (isDegrees) axis.rotationDegrees(rotation) else axis.rotation(rotation)) // TODO: 1.19.3 translate(-point) } -operator fun Matrix4f.get(row: Int, column: Int): Float { - require(row in 0 .. 3) { "Invalid row: $row" } - require(column in 0 .. 3) { "Invalid column: $column" } - - return when (val index = row or (column shl 2)) { - 0 or (0 shl 2) -> m00 - 1 or (0 shl 2) -> m10 - 2 or (0 shl 2) -> m20 - 3 or (0 shl 2) -> m30 - 0 or (1 shl 2) -> m01 - 1 or (1 shl 2) -> m11 - 2 or (1 shl 2) -> m21 - 3 or (1 shl 2) -> m31 - 0 or (2 shl 2) -> m02 - 1 or (2 shl 2) -> m12 - 2 or (2 shl 2) -> m22 - 3 or (2 shl 2) -> m32 - 0 or (3 shl 2) -> m03 - 1 or (3 shl 2) -> m13 - 2 or (3 shl 2) -> m23 - 3 or (3 shl 2) -> m33 - else -> throw IllegalStateException("$index") - } -} - -operator fun Matrix4f.set(row: Int, column: Int, value: Float) { - require(row in 0 .. 3) { "Invalid row: $row" } - require(column in 0 .. 3) { "Invalid column: $column" } - - when (val index = row or (column shl 2)) { - 0 or (0 shl 2) -> m00 = value - 1 or (0 shl 2) -> m10 = value - 2 or (0 shl 2) -> m20 = value - 3 or (0 shl 2) -> m30 = value - 0 or (1 shl 2) -> m01 = value - 1 or (1 shl 2) -> m11 = value - 2 or (1 shl 2) -> m21 = value - 3 or (1 shl 2) -> m31 = value - 0 or (2 shl 2) -> m02 = value - 1 or (2 shl 2) -> m12 = value - 2 or (2 shl 2) -> m22 = value - 3 or (2 shl 2) -> m32 = value - 0 or (3 shl 2) -> m03 = value - 1 or (3 shl 2) -> m13 = value - 2 or (3 shl 2) -> m23 = value - 3 or (3 shl 2) -> m33 = value - else -> throw IllegalStateException("$index") - } -} - -operator fun Matrix3f.get(row: Int, column: Int): Float { - require(row in 0 .. 2) { "Invalid row: $row" } - require(column in 0 .. 2) { "Invalid column: $column" } - - return when (val index = row or (column shl 2)) { - 0 or (0 shl 2) -> m00 - 1 or (0 shl 2) -> m10 - 2 or (0 shl 2) -> m20 - 0 or (1 shl 2) -> m01 - 1 or (1 shl 2) -> m11 - 2 or (1 shl 2) -> m21 - 0 or (2 shl 2) -> m02 - 1 or (2 shl 2) -> m12 - 2 or (2 shl 2) -> m22 - else -> throw IllegalStateException("$index") - } -} - -@Suppress("EXTENSION_SHADOWED_BY_MEMBER") -operator fun Matrix3f.set(row: Int, column: Int, value: Float) { - require(row in 0 .. 2) { "Invalid row: $row" } - require(column in 0 .. 2) { "Invalid column: $column" } - - when (val index = row or (column shl 2)) { - 0 or (0 shl 2) -> m00 = value - 1 or (0 shl 2) -> m10 = value - 2 or (0 shl 2) -> m20 = value - 0 or (1 shl 2) -> m01 = value - 1 or (1 shl 2) -> m11 = value - 2 or (1 shl 2) -> m21 = value - 0 or (2 shl 2) -> m02 = value - 1 or (2 shl 2) -> m12 = value - 2 or (2 shl 2) -> m22 = value - else -> throw IllegalStateException("$index") - } -} - -fun Matrix4f.identity() = setIdentity() -fun Matrix3f.identity() = setIdentity() - -fun Matrix4f.identityFast() { - m00 = 1.0F - m11 = 1.0F - m22 = 1.0F - m33 = 1.0F -} - -fun Matrix3f.identityFast() { - m00 = 1.0F - m11 = 1.0F - m22 = 1.0F -} - fun Matrix3f.toMatrix4f(): Matrix4f { val result = Matrix4f() - result.m00 = this.m00 - result.m10 = this.m10 - result.m20 = this.m20 - result.m01 = this.m01 - result.m11 = this.m11 - result.m21 = this.m21 - result.m02 = this.m02 - result.m12 = this.m12 - result.m22 = this.m22 + result.zero() + + result.m00(this.m00) + result.m10(this.m10) + result.m20(this.m20) + result.m01(this.m01) + result.m11(this.m11) + result.m21(this.m21) + result.m02(this.m02) + result.m12(this.m12) + result.m22(this.m22) return result } var Matrix4f.translation: Vector3f get() { - return Vector3f(this[0, 3], this[1, 3], this[2, 3]) + return Vector3f(this[3, 0], this[3, 1], this[3, 2]) } set(value) { @@ -193,7 +92,7 @@ var Matrix4f.translation: Vector3f var Matrix4f.translation4: Vector4f get() { - return Vector4f(this[0, 3], this[1, 3], this[2, 3], this[3, 3]) + return Vector4f(this[3, 0], this[3, 1], this[3, 2], this[3, 3]) } set(value) { From bb52032364b685486389729f2435d4d137ccbe5f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 7 Jan 2023 13:28:06 +0700 Subject: [PATCH 0006/1199] More 1.19.3 porting --- .../android/feature/EnderTeleporterFeature.kt | 10 +++--- .../entity/blackhole/BlackHoleBlockEntity.kt | 2 +- .../otm/block/entity/blackhole/Explosions.kt | 6 ++-- .../mc/otm/client/render/AtlasSkinElement.kt | 2 +- .../dbotthepony/mc/otm/client/render/Ext.kt | 10 +++--- .../mc/otm/client/render/GlitchRenderer.kt | 19 ++--------- .../mc/otm/client/render/RenderHelper.kt | 10 +++--- .../mc/otm/client/render/ShockwaveRenderer.kt | 4 +-- .../mc/otm/client/render/WidgetAtlasHolder.kt | 5 ++- .../client/render/blockentity/BankRenderer.kt | 6 ++-- .../render/blockentity/BlackHoleRenderer.kt | 2 +- .../GravitationStabilizerRenderer.kt | 2 +- .../blockentity/MatterReplicatorRenderer.kt | 16 ++------- .../otm/client/screen/panels/Panel2Widget.kt | 5 +-- .../mc/otm/client/screen/panels/SlotPanel.kt | 2 +- .../ru/dbotthepony/mc/otm/core/EuclidMath.kt | 33 +++++++++++++++++++ .../mc/otm/core/UnOverengineering.kt | 4 +++ .../item/AbstractExoPackSlotUpgradeItem.kt | 2 +- .../ru/dbotthepony/mc/otm/item/BatteryItem.kt | 8 ++--- .../mc/otm/item/CreativePatternItem.kt | 2 +- .../mc/otm/item/ExoPackCraftingUpgradeItem.kt | 2 +- .../mc/otm/item/ExoPackProbeItem.kt | 2 +- .../mc/otm/item/GravitationalDisruptorItem.kt | 4 +-- .../mc/otm/item/MatterCapacitorItem.kt | 6 ++-- .../dbotthepony/mc/otm/item/MatterDustItem.kt | 2 +- .../mc/otm/item/MinecartCargoCrateItem.kt | 2 +- .../mc/otm/item/PatternStorageItem.kt | 8 ++--- .../ru/dbotthepony/mc/otm/item/PillItem.kt | 6 ++-- .../otm/item/PortableCondensationDriveItem.kt | 4 +-- .../item/PortableGravitationStabilizerItem.kt | 2 +- .../mc/otm/item/QuantumBatteryItem.kt | 6 ++-- .../mc/otm/item/SingleUseBatteryItem.kt | 8 ++--- .../mc/otm/item/weapon/AbstractWeaponItem.kt | 10 +++--- .../mc/otm/recipe/EnergyContainerRecipe.kt | 7 ++-- .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 5 +-- .../mc/otm/registry/MItemFunctionTypes.kt | 3 +- .../mc/otm/registry/MLootItemConditions.kt | 3 +- .../mc/otm/registry/MSoundEvents.kt | 3 +- .../ru/dbotthepony/mc/otm/registry/MStats.kt | 8 ++--- .../objects/StripedColoredDecorativeBlock.kt | 2 +- .../ru/dbotthepony/mc/otm/worldgen/OreGen.kt | 2 -- 41 files changed, 134 insertions(+), 111 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt index 55af601f2..d2805f377 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.android.feature import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack -import com.mojang.math.Vector3f import net.minecraft.ChatFormatting import net.minecraft.client.Camera import net.minecraft.client.renderer.LevelRenderer @@ -44,7 +43,10 @@ import ru.dbotthepony.mc.otm.core.component2 import ru.dbotthepony.mc.otm.core.component3 import ru.dbotthepony.mc.otm.core.formatPower import ru.dbotthepony.mc.otm.core.genericPositions +import ru.dbotthepony.mc.otm.core.holder import ru.dbotthepony.mc.otm.core.plus +import ru.dbotthepony.mc.otm.core.rotateXDegrees +import ru.dbotthepony.mc.otm.core.rotateYDegrees import ru.dbotthepony.mc.otm.core.shortestDistanceBetween import ru.dbotthepony.mc.otm.core.times import ru.dbotthepony.mc.otm.milliTime @@ -301,7 +303,7 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv val event = ForgeEventFactory.onEnderTeleport(ply, blockPos.x + 0.5, blockPos.y.toDouble(), blockPos.z + 0.5) if (event.isCanceled) { - (ply as ServerPlayer).connection.send(ClientboundSoundEntityPacket(SoundEvents.ITEM_BREAK, SoundSource.PLAYERS, ply, 0.3f, 0.5f, ply.level.random.nextLong())) + (ply as ServerPlayer).connection.send(ClientboundSoundEntityPacket(SoundEvents.ITEM_BREAK.holder, SoundSource.PLAYERS, ply, 0.3f, 0.5f, ply.level.random.nextLong())) return false } @@ -333,8 +335,8 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv poseStack.pushPose() poseStack.translate(x - vx, y - vy, z - vz) - poseStack.mulPose(Vector3f.YP.rotationDegrees(-camera.yRot)) - poseStack.mulPose(Vector3f.XP.rotationDegrees(camera.xRot)) + poseStack.rotateYDegrees(-camera.yRot) + poseStack.rotateXDegrees(camera.xRot) val size = 1f + sin(milliTime / 250.0).toFloat() * 0.2f val half = size / -2f 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 9cc7d00f4..b119619e4 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 @@ -151,7 +151,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Synchro blockPos.z + 0.5, gravitationStrength.toFloat() * 60, false, - Explosion.BlockInteraction.DESTROY + Level.ExplosionInteraction.BLOCK // TODO: 1.19.3 ) } } 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 128e2bd75..0777f6c46 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 @@ -118,7 +118,7 @@ class ExplosionSphere(val hive: ExplosionSphereHive, var pos: Vec3, var stepVelo val block = level.getBlockState(finalPos) if (!block.isAir && block.block !is BlockExplosionDebugger) { - val explosion = Explosion(level, null, null, null, pos.x, pos.y, pos.z, force.toFloat(),false, Explosion.BlockInteraction.BREAK) + val explosion = Explosion(level, null, null, null, pos.x, pos.y, pos.z, force.toFloat(), false, Explosion.BlockInteraction.DESTROY_WITH_DECAY) val explosionResistance = block.getExplosionResistance(level, blockPos, explosion) if (explosionResistance > force) { @@ -258,7 +258,7 @@ class ExplosionRay(val hive: ExplosionRayHive, var pos: Vec3, var stepVelocity: val block = level.getBlockState(blockPos) if (!block.isAir && block.block !is BlockExplosionDebugger) { - val explosion = Explosion(level, null, null, null, pos.x, pos.y, pos.z, force.toFloat(),false, Explosion.BlockInteraction.BREAK) + val explosion = Explosion(level, null, null, null, pos.x, pos.y, pos.z, force.toFloat(), false, Explosion.BlockInteraction.DESTROY_WITH_DECAY) val explosionResistance = block.getExplosionResistance(level, blockPos, explosion) if (explosionResistance > force) { @@ -535,7 +535,7 @@ private data class QueuedExplosion(val x: Double, val y: Double, val z: Double, z, radius, false, - Explosion.BlockInteraction.DESTROY + Level.ExplosionInteraction.BLOCK // TODO: 1.19.3 ) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AtlasSkinElement.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AtlasSkinElement.kt index be2bbc42b..c2380e795 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AtlasSkinElement.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AtlasSkinElement.kt @@ -66,7 +66,7 @@ class AtlasSkinElement( if ( _textureAtlasSprite == null || - _textureAtlasSprite.name.let { it.namespace == "minecraft" && it.path == "missingno" } || + _textureAtlasSprite.contents().name().let { it.namespace == "minecraft" && it.path == "missingno" } || changeset != WidgetAtlasHolder.INSTANCE.changeset ) { val get = WidgetAtlasHolder.INSTANCE.getSprite(location) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt index 5f25a168d..61efa2b17 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt @@ -3,13 +3,13 @@ package ru.dbotthepony.mc.otm.client.render import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.Tesselator import com.mojang.blaze3d.vertex.VertexConsumer -import com.mojang.math.Matrix4f -import com.mojang.math.Vector3f import net.minecraft.client.gui.Font import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.core.Vec3i import net.minecraft.network.chat.Component import net.minecraft.util.FormattedCharSequence +import org.joml.Matrix4f +import org.joml.Vector3f import ru.dbotthepony.mc.otm.core.* import kotlin.math.roundToInt @@ -21,12 +21,12 @@ fun VertexConsumer.color(color: RGBAColor): VertexConsumer = color(color.red, co fun PoseStack.translate(vector: Vector) = translate(vector.x, vector.y, vector.z) fun PoseStack.translate(vector: Vec3i) = translate(vector.x.toDouble(), vector.y.toDouble(), vector.z.toDouble()) -fun PoseStack.translate(vector: Vector3f) = last().pose().multiplyWithTranslation(vector.x(), vector.y(), vector.z()) +fun PoseStack.translate(vector: Vector3f) = translate(vector.x(), vector.y(), vector.z()) // TODO: 1.19.3 fun PoseStack.rotateAroundPoint(point: Vector, axis: Vector, rotation: Float, isDegrees: Boolean = false) { val last = last() last.pose().rotateAroundPoint(point, axis, rotation, isDegrees) - last.normal().mul(axis.rotateAroundThis(rotation, isDegrees)) + last.normal().rotate(axis.rotateAroundThis(rotation, isDegrees)) } fun PoseStack.rotateAroundPoint(point: Vector, rotation: IAngle) { @@ -38,7 +38,7 @@ fun PoseStack.rotateAroundPoint(point: Vector, rotation: IAngle) { fun PoseStack.rotateAroundPoint(point: Vector3f, axis: Vector, rotation: Float, isDegrees: Boolean = false) { val last = last() last.pose().rotateAroundPoint(point, axis, rotation, isDegrees) - last.normal().mul(axis.rotateAroundThis(rotation, isDegrees)) + last.normal().rotate(axis.rotateAroundThis(rotation, isDegrees)) } fun PoseStack.rotateAroundPoint(point: Vector3f, rotation: IAngle) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GlitchRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GlitchRenderer.kt index a85eec9da..6910fe611 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GlitchRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GlitchRenderer.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.client.render -import com.google.common.collect.ImmutableList import com.mojang.blaze3d.pipeline.MainTarget import com.mojang.blaze3d.platform.GlConst import com.mojang.blaze3d.platform.GlStateManager @@ -8,34 +7,20 @@ import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.BufferBuilder import com.mojang.blaze3d.vertex.BufferUploader import com.mojang.blaze3d.vertex.DefaultVertexFormat -import com.mojang.blaze3d.vertex.Tesselator -import com.mojang.blaze3d.vertex.VertexBuffer import com.mojang.blaze3d.vertex.VertexFormat -import com.mojang.math.Matrix4f -import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap -import it.unimi.dsi.fastutil.ints.Int2ObjectFunction import net.minecraft.client.Minecraft import net.minecraft.client.renderer.FogRenderer import net.minecraft.client.renderer.GameRenderer -import net.minecraft.core.Vec3i import net.minecraft.world.level.levelgen.XoroshiroRandomSource import net.minecraft.world.level.material.FogType -import org.lwjgl.opengl.GL14 -import ru.dbotthepony.mc.otm.ClientConfig +import org.joml.Matrix4f import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.core.RGBAColor -import ru.dbotthepony.mc.otm.core.component1 -import ru.dbotthepony.mc.otm.core.component2 -import ru.dbotthepony.mc.otm.core.component3 import ru.dbotthepony.mc.otm.core.linearInterpolation import ru.dbotthepony.mc.otm.milliTime import java.lang.ref.WeakReference -import java.util.stream.Collectors import kotlin.math.absoluteValue -import kotlin.math.ceil -import kotlin.math.pow @Suppress("SameParameterValue") object GlitchRenderer { @@ -215,7 +200,7 @@ object GlitchRenderer { val glitchBuffer = glitchBuffer val projection = RenderSystem.getProjectionMatrix() - RenderSystem.setProjectionMatrix(Matrix4f().also { it.setIdentity() }) + RenderSystem.setProjectionMatrix(Matrix4f()) RenderSystem.getModelViewStack().also { it.pushPose() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt index ffc77bb79..72d8c4dd8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt @@ -3,12 +3,12 @@ package ru.dbotthepony.mc.otm.client.render import com.mojang.blaze3d.platform.GlStateManager import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.* -import com.mojang.math.Matrix4f import net.minecraft.client.renderer.GameRenderer import net.minecraft.client.renderer.RenderStateShard import net.minecraft.client.renderer.RenderStateShard.LineStateShard import net.minecraft.client.renderer.RenderType import net.minecraft.client.renderer.texture.TextureAtlasSprite +import org.joml.Matrix4f import org.lwjgl.opengl.GL11.GL_ALWAYS import org.lwjgl.opengl.GL11.GL_LESS import ru.dbotthepony.mc.otm.client.minecraft @@ -22,7 +22,7 @@ import kotlin.math.pow import kotlin.math.roundToInt import kotlin.math.sin -private val identity = Matrix4f().also { it.setIdentity() } +private val identity = Matrix4f() var zLevel = 0f var drawColor = RGBAColor(255, 255, 255, 255) @@ -513,11 +513,11 @@ fun TextureAtlasSprite.render( stack: PoseStack, x: Float = 0f, y: Float = 0f, - width: Float = this.width.toFloat(), - height: Float = this.height.toFloat(), + width: Float, + height: Float, winding: UVWindingOrder = UVWindingOrder.NORMAL ) { - RenderSystem.setShaderTexture(0, atlas().location()) + RenderSystem.setShaderTexture(0, atlasLocation()) if (winding.isIdentity) { drawTexturedRect(stack.last().pose(), x, y, width, height, u0, v0, u1, v1) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ShockwaveRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ShockwaveRenderer.kt index a1b418fef..1ba1d357f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ShockwaveRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ShockwaveRenderer.kt @@ -4,7 +4,6 @@ import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.BufferUploader import com.mojang.blaze3d.vertex.DefaultVertexFormat import com.mojang.blaze3d.vertex.VertexFormat -import com.mojang.math.Vector3f import net.minecraft.client.renderer.GameRenderer import net.minecraftforge.client.event.RenderLevelStageEvent import org.lwjgl.opengl.GL11.GL_LESS @@ -14,6 +13,7 @@ import ru.dbotthepony.mc.otm.core.component1 import ru.dbotthepony.mc.otm.core.component2 import ru.dbotthepony.mc.otm.core.component3 import ru.dbotthepony.mc.otm.core.linearInterpolation +import ru.dbotthepony.mc.otm.core.rotateX import ru.dbotthepony.mc.otm.network.ShockwaveEffectPacket import ru.dbotthepony.mc.otm.secondTimeD import kotlin.math.PI @@ -52,7 +52,7 @@ object ShockwaveRenderer { event.poseStack.pushPose() val (x, y, z) = event.camera.position event.poseStack.translate(pos.x - x, pos.y - y + 0.1f, pos.z - z) // render slightly above landed position - event.poseStack.mulPose(Vector3f.XP.rotation(PI.toFloat() / 2f)) + event.poseStack.rotateX(PI.toFloat() / 2f) uploadArc(event.poseStack.last.pose, builder, x = 0f, y = 0f, innerRadius = (radius - 1f).coerceAtLeast(0f), outerRadius = radius, triangleFan = false) event.poseStack.popPose() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetAtlasHolder.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetAtlasHolder.kt index 30dd20860..9825bcc07 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetAtlasHolder.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetAtlasHolder.kt @@ -18,7 +18,7 @@ import kotlin.properties.Delegates var isWidgetAtlasAvailable: Boolean = false private set -class WidgetAtlasHolder private constructor(manager: TextureManager) : TextureAtlasHolder(manager, LOCATION, "gui") { +class WidgetAtlasHolder private constructor(manager: TextureManager) : TextureAtlasHolder(manager, LOCATION, INFO_LOCATION) { var changeset = 0 private set @@ -75,6 +75,9 @@ class WidgetAtlasHolder private constructor(manager: TextureManager) : TextureAt @JvmStatic val LOCATION = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/atlas/gui.png") + @JvmStatic + val INFO_LOCATION = ResourceLocation(OverdriveThatMatters.MOD_ID, "fuck/you/mojang") + @JvmStatic var INSTANCE: WidgetAtlasHolder by WriteOnce() private set diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt index 312172f87..038fe9ec9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.client.render.blockentity import com.mojang.blaze3d.vertex.PoseStack -import com.mojang.math.Vector3f import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.client.renderer.blockentity.BlockEntityRenderer import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider @@ -16,6 +15,7 @@ import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.core.rotateY import kotlin.math.PI abstract class BankRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer { @@ -42,7 +42,7 @@ abstract class BankRenderer(private val context: BlockEn val rotateFacing = facing == Direction.NORTH || facing == Direction.SOUTH if (rotateFacing) { - stack.mulPose(Vector3f.YP.rotation(PI.toFloat() / 2f)) + stack.rotateY(PI.toFloat() / 2f) } stack.scale(0.02f, 0.01f, 0.01f) @@ -64,7 +64,7 @@ abstract class BankRenderer(private val context: BlockEn height = heightMax * gaugeLevel(blockEntity) ) - stack.mulPose(Vector3f.YP.rotation(PI.toFloat())) + stack.rotateY(PI.toFloat()) stack.translate(-50.0, 0.0, -101.0) texture.uploadOntoPartialColor( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt index 40d9458ed..c6306278d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.client.render.blockentity import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.* -import com.mojang.math.Matrix4f import net.minecraft.client.Minecraft import net.minecraft.client.renderer.GameRenderer import net.minecraft.client.renderer.MultiBufferSource @@ -10,6 +9,7 @@ import net.minecraft.client.renderer.blockentity.BeaconRenderer import net.minecraft.client.renderer.blockentity.BlockEntityRenderer import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider import net.minecraft.world.phys.Vec3 +import org.joml.Matrix4f import org.lwjgl.opengl.GL30 import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.block.entity.GravitationStabilizerBlockEntity diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt index f5960e948..bd1389ce6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.client.render.blockentity import com.mojang.blaze3d.vertex.* -import com.mojang.math.Matrix4f import net.minecraft.client.Minecraft import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.client.renderer.RenderType @@ -11,6 +10,7 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRenderer import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider import net.minecraft.client.renderer.texture.OverlayTexture import net.minecraft.core.Direction +import org.joml.Matrix4f import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.block.BlackHoleBlock import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReplicatorRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReplicatorRenderer.kt index 42205bffa..3b1e7b8ce 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReplicatorRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReplicatorRenderer.kt @@ -1,37 +1,27 @@ package ru.dbotthepony.mc.otm.client.render.blockentity -import com.mojang.blaze3d.platform.GlStateManager import com.mojang.blaze3d.platform.GlStateManager.DestFactor import com.mojang.blaze3d.platform.GlStateManager.SourceFactor import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack -import com.mojang.math.Vector3f import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.client.renderer.block.model.ItemTransforms import net.minecraft.client.renderer.blockentity.BlockEntityRenderer import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider -import net.minecraft.client.server.IntegratedServer import net.minecraft.core.particles.DustParticleOptions import net.minecraft.world.level.levelgen.XoroshiroRandomSource -import org.lwjgl.opengl.GL14 -import org.lwjgl.opengl.GL14.GL_ADD -import org.lwjgl.opengl.GL14.GL_FUNC_ADD -import org.lwjgl.opengl.GL14.GL_MIN +import org.joml.Vector3f import org.lwjgl.opengl.GL14.glBlendColor -import ru.dbotthepony.mc.otm.NULLABLE_MINECRAFT_SERVER import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity -import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.render.lockBlendFunc -import ru.dbotthepony.mc.otm.client.render.popScissorRect -import ru.dbotthepony.mc.otm.client.render.pushScissorRect -import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel import ru.dbotthepony.mc.otm.core.component1 import ru.dbotthepony.mc.otm.core.component2 import ru.dbotthepony.mc.otm.core.component3 import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.normalizeAngleDeg +import ru.dbotthepony.mc.otm.core.rotateYDegrees import ru.dbotthepony.mc.otm.isPaused class MatterReplicatorRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer { @@ -78,7 +68,7 @@ class MatterReplicatorRenderer(private val context: BlockEntityRendererProvider. if (!isPaused) tile.renderRotation = normalizeAngleDeg(tile.renderRotation + diff / 10_000_000f) - pose.mulPose(Vector3f.YP.rotationDegrees(tile.renderRotation)) + pose.rotateYDegrees(tile.renderRotation) val model = context.itemRenderer.getModel( item, 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 235e271ed..5bf81201a 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 @@ -1,13 +1,14 @@ package ru.dbotthepony.mc.otm.client.screen.panels import com.mojang.blaze3d.vertex.PoseStack -import net.minecraft.client.gui.components.Widget +import net.minecraft.client.gui.components.Renderable import net.minecraft.client.gui.components.events.GuiEventListener import net.minecraft.client.gui.screens.Screen +// before 1.19.3 Renderable was Widget class Panel2Widget>( val panel: P -) : GuiEventListener, Widget { +) : GuiEventListener, Renderable { init { require(panel.parent == null) { "Widget wrapped panels can't have a parent ($panel has parent ${panel.parent})" } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SlotPanel.kt index 263da4a72..f2d037a88 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SlotPanel.kt @@ -104,7 +104,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.atlas().location()) + RenderSystem.setShaderTexture(0, texture.atlasLocation()) GuiComponent.blit(stack, 1, 1, 0, 16, 16, texture) } else { noItemIcon?.render(stack, width = width, height = height) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/EuclidMath.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/EuclidMath.kt index fd4feaff2..fc6a940dc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/EuclidMath.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/EuclidMath.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.core +import com.mojang.blaze3d.vertex.PoseStack import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap import net.minecraft.core.BlockPos import net.minecraft.core.Direction @@ -541,3 +542,35 @@ fun angleDifferenceDeg(angle1: Float, angle2: Float): Float { return 360f - diff } + +// 1.19.3 stuff +fun PoseStack.rotateY(rotation: Float): PoseStack { + mulPose(Quaternionf(AxisAngle4f(rotation, 0f, 1f, 0f))) + return this +} + +fun PoseStack.rotateX(rotation: Float): PoseStack { + mulPose(Quaternionf(AxisAngle4f(rotation, 1f, 0f, 0f))) + return this +} + +fun PoseStack.rotateZ(rotation: Float): PoseStack { + mulPose(Quaternionf(AxisAngle4f(rotation, 0f, 0f, 1f))) + return this +} + +fun PoseStack.rotateYDegrees(rotation: Float): PoseStack { + mulPose(Quaternionf(AxisAngle4f(toRadians(rotation), 0f, 1f, 0f))) + return this +} + +fun PoseStack.rotateXDegrees(rotation: Float): PoseStack { + mulPose(Quaternionf(AxisAngle4f(toRadians(rotation), 1f, 0f, 0f))) + return this +} + +fun PoseStack.rotateZDegrees(rotation: Float): PoseStack { + mulPose(Quaternionf(AxisAngle4f(toRadians(rotation), 0f, 0f, 1f))) + return this +} + diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt index 60f4e7329..a409cfa02 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt @@ -5,6 +5,7 @@ import net.minecraft.network.chat.MutableComponent import net.minecraft.network.chat.contents.LiteralContents import net.minecraft.network.chat.contents.TranslatableContents import net.minecraft.resources.ResourceLocation +import net.minecraft.sounds.SoundEvent import net.minecraft.world.item.Item import net.minecraft.world.level.block.Block import net.minecraftforge.registries.ForgeRegistries @@ -28,3 +29,6 @@ val Item.registryName get() = ForgeRegistries.ITEMS.getKeyNullable(this) val Block.registryName get() = ForgeRegistries.BLOCKS.getKeyNullable(this) fun FriendlyByteBuf.writeRegistryId(value: Item) = writeRegistryId(ForgeRegistries.ITEMS, value) + +// 1.19.3 lol +inline val SoundEvent.holder get() = ForgeRegistries.SOUND_EVENTS.getHolder(this).orElse(null) ?: throw NoSuchElementException("$this is missing from ${ForgeRegistries.SOUND_EVENTS}") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/AbstractExoPackSlotUpgradeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/AbstractExoPackSlotUpgradeItem.kt index dc568a513..f4e757762 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/AbstractExoPackSlotUpgradeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/AbstractExoPackSlotUpgradeItem.kt @@ -113,6 +113,6 @@ abstract class AbstractExoPackSlotUpgradeItem(properties: Properties = defaultPr override fun getUseAnimation(p_41452_: ItemStack): UseAnim = UseAnim.BOW companion object { - fun defaultProperties(rarity: Rarity = Rarity.UNCOMMON) = Properties().stacksTo(8).rarity(Rarity.UNCOMMON).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB).fireResistant() + fun defaultProperties(rarity: Rarity = Rarity.UNCOMMON): Properties = Properties().stacksTo(8).rarity(Rarity.UNCOMMON).fireResistant() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt index 02a5b8bb8..9aeea6fff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt @@ -71,7 +71,7 @@ open class BatteryItem : Item { receive: Decimal, extract: Decimal = receive, initialBatteryLevel: Decimal = Decimal.ZERO - ) : super(Properties().stacksTo(1).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) { + ) : super(Properties().stacksTo(1)) { isCreative = false this._capacity = { storage } this._receive = { receive } @@ -84,7 +84,7 @@ open class BatteryItem : Item { receive: () -> Decimal, extract: () -> Decimal = receive, initialBatteryLevel: () -> Decimal = { Decimal.ZERO } - ) : super(Properties().stacksTo(1).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) { + ) : super(Properties().stacksTo(1)) { isCreative = false this._capacity = storage this._receive = receive @@ -92,7 +92,7 @@ open class BatteryItem : Item { this._initialBatteryLevel = initialBatteryLevel } - constructor(values: BatteryBalanceValues) : super(Properties().stacksTo(1).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) { + constructor(values: BatteryBalanceValues) : super(Properties().stacksTo(1)) { isCreative = false this._capacity = values::capacity this._receive = values::receive @@ -100,7 +100,7 @@ open class BatteryItem : Item { this._initialBatteryLevel = values::initialBatteryLevel } - constructor() : super(Properties().stacksTo(1).rarity(Rarity.EPIC).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) { + constructor() : super(Properties().stacksTo(1).rarity(Rarity.EPIC)) { isCreative = true _capacity = { Decimal.LONG_MAX_VALUE } _receive = { Decimal.LONG_MAX_VALUE } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/CreativePatternItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/CreativePatternItem.kt index 2f2c04c0d..195e20896 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/CreativePatternItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/CreativePatternItem.kt @@ -26,7 +26,7 @@ import ru.dbotthepony.mc.otm.matter.MatterManager import java.util.* import java.util.stream.Stream -class CreativePatternItem : Item(Properties().rarity(Rarity.EPIC).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB).stacksTo(1)) { +class CreativePatternItem : Item(Properties().rarity(Rarity.EPIC).stacksTo(1)) { private object Patterns : IPatternStorage, ICapabilityProvider { private val resolver = LazyOptional.of { this } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ExoPackCraftingUpgradeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ExoPackCraftingUpgradeItem.kt index 55fd51e3f..cac3c7778 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ExoPackCraftingUpgradeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ExoPackCraftingUpgradeItem.kt @@ -15,7 +15,7 @@ import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.runIfClient -class ExoPackCraftingUpgradeItem : Item(Properties().tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB).stacksTo(1).rarity(Rarity.RARE)) { +class ExoPackCraftingUpgradeItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)) { override fun getUseDuration(p_41454_: ItemStack): Int { return 30 } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ExoPackProbeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ExoPackProbeItem.kt index ba8136365..ec4e4a962 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ExoPackProbeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ExoPackProbeItem.kt @@ -17,7 +17,7 @@ import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.registry.MRegistry import ru.dbotthepony.mc.otm.runIfClient -class ExoPackProbeItem : Item(Properties().tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB).stacksTo(1).rarity(Rarity.EPIC)) { +class ExoPackProbeItem : Item(Properties().stacksTo(1).rarity(Rarity.EPIC)) { override fun getUseDuration(p_41454_: ItemStack): Int { return 30 } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/GravitationalDisruptorItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/GravitationalDisruptorItem.kt index df6c8e937..4839d319f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/GravitationalDisruptorItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/GravitationalDisruptorItem.kt @@ -11,7 +11,7 @@ import net.minecraft.world.level.Level import ru.dbotthepony.mc.otm.core.TranslatableComponent class GravitationalDisruptorItem : - Item(Properties().tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB).stacksTo(1).rarity(Rarity.EPIC)) { + Item(Properties().stacksTo(1).rarity(Rarity.EPIC)) { override fun appendHoverText( p_41421_: ItemStack, p_41422_: Level?, @@ -51,4 +51,4 @@ class GravitationalDisruptorItem : ) ).withStyle(ChatFormatting.DARK_RED) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt index 612c6a831..9058ef64a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt @@ -94,17 +94,17 @@ class MatterCapacitorItem : Item { private val isCreative: Boolean - constructor(storage: Decimal) : super(Properties().stacksTo(1).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) { + constructor(storage: Decimal) : super(Properties().stacksTo(1)) { isCreative = false _capacity = { storage } } - constructor(storage: () -> Decimal) : super(Properties().stacksTo(1).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) { + constructor(storage: () -> Decimal) : super(Properties().stacksTo(1)) { isCreative = false _capacity = storage } - constructor() : super(Properties().stacksTo(1).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB).rarity(Rarity.EPIC)) { + constructor() : super(Properties().stacksTo(1).rarity(Rarity.EPIC)) { isCreative = true _capacity = { Decimal.LONG_MAX_VALUE } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt index 73bf251da..9d533f3c8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt @@ -15,7 +15,7 @@ import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.matter.IMatterValue import ru.dbotthepony.mc.otm.matter.MatterValue -class MatterDustItem : Item(Properties().tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB).stacksTo(64)), IMatterItem { +class MatterDustItem : Item(Properties().stacksTo(64)), IMatterItem { private fun matter(stack: ItemStack): Decimal { return stack.tag?.get("matter")?.let { return@let Decimal.deserializeNBT(it) } ?: return Decimal.ZERO } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MinecartCargoCrateItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MinecartCargoCrateItem.kt index f12f2f3e5..977ea270d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MinecartCargoCrateItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MinecartCargoCrateItem.kt @@ -21,7 +21,7 @@ import ru.dbotthepony.mc.otm.entity.MinecartCargoCrate import ru.dbotthepony.mc.otm.registry.MEntityTypes import kotlin.math.floor -class MinecartCargoCrateItem(val color: DyeColor?) : Item(Properties().stacksTo(16).tab(if (color == null) OverdriveThatMatters.INSTANCE.CREATIVE_TAB else OverdriveThatMatters.INSTANCE.CREATIVE_TAB_DECORATIVE)) { +class MinecartCargoCrateItem(val color: DyeColor?) : Item(Properties().stacksTo(16)) { init { DispenserBlock.registerBehavior(this, Companion) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PatternStorageItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PatternStorageItem.kt index d9f83835a..93ffbfb2f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PatternStorageItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PatternStorageItem.kt @@ -27,17 +27,17 @@ class PatternStorageItem : Item { val capacity get() = _capacity.invoke() var isCreative: Boolean - constructor(capacity: Int) : super(Properties().tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB).stacksTo(1)) { + constructor(capacity: Int) : super(Properties().stacksTo(1)) { _capacity = { capacity } isCreative = false } - constructor(capacity: () -> Int) : super(Properties().tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB).stacksTo(1)) { + constructor(capacity: () -> Int) : super(Properties().stacksTo(1)) { _capacity = capacity isCreative = false } - constructor() : super(Properties().rarity(Rarity.EPIC).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB).stacksTo(1)) { + constructor() : super(Properties().rarity(Rarity.EPIC).stacksTo(1)) { isCreative = true _capacity = { Int.MAX_VALUE } } @@ -184,4 +184,4 @@ class PatternStorageItem : Item { return PatternInsertInserted(pattern) } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PillItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PillItem.kt index ac7026454..9c50f7654 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PillItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PillItem.kt @@ -20,7 +20,7 @@ enum class PillType { BECOME_ANDROID, BECOME_HUMANE, OBLIVION } -class HealPillItem : Item(Properties().stacksTo(64).rarity(Rarity.UNCOMMON).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) { +class HealPillItem : Item(Properties().stacksTo(64).rarity(Rarity.UNCOMMON)) { override fun getUseDuration(p_41454_: ItemStack): Int { return 24 } @@ -65,7 +65,7 @@ class HealPillItem : Item(Properties().stacksTo(64).rarity(Rarity.UNCOMMON).tab( } class PillItem(val pillType: PillType) : - Item(Properties().stacksTo(64).rarity(Rarity.UNCOMMON).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) { + Item(Properties().stacksTo(64).rarity(Rarity.UNCOMMON)) { override fun getUseDuration(p_41454_: ItemStack): Int { return 32 @@ -168,4 +168,4 @@ class PillItem(val pillType: PillType) : } override fun getUseAnimation(p_41452_: ItemStack): UseAnim = UseAnim.EAT -} \ No newline at end of file +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableCondensationDriveItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableCondensationDriveItem.kt index ac493a33c..48d62cfd0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableCondensationDriveItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableCondensationDriveItem.kt @@ -29,7 +29,7 @@ import java.math.BigInteger import java.util.* class PortableCondensationDriveItem(capacity: Int) : - Item(Properties().stacksTo(1).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) { + Item(Properties().stacksTo(1)) { val capacity: BigInteger = capacity.toBigInteger() private inner class DriveCapability(private val stack: ItemStack) : ICapabilityProvider { @@ -154,4 +154,4 @@ class PortableCondensationDriveItem(capacity: Int) : } } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableGravitationStabilizerItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableGravitationStabilizerItem.kt index 16c39dc80..c09244d5e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableGravitationStabilizerItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableGravitationStabilizerItem.kt @@ -41,7 +41,7 @@ private object GravitationStabilizerArmorRenderProperties : IClientItemExtension } } -class ItemPortableGravitationStabilizer : ArmorItem(GravitationStabilizerArmorMaterial, EquipmentSlot.CHEST, Properties().stacksTo(1).rarity(Rarity.RARE).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) { +class ItemPortableGravitationStabilizer : ArmorItem(GravitationStabilizerArmorMaterial, EquipmentSlot.CHEST, Properties().stacksTo(1).rarity(Rarity.RARE)) { override fun initializeClient(consumer: Consumer) { super.initializeClient(consumer) consumer.accept(GravitationStabilizerArmorRenderProperties) 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 bc2fbf15d..fe7243c2f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt @@ -292,21 +292,21 @@ class QuantumBatteryItem : Item { Int2ObjectOpenHashMap() } - constructor(saveDataID: String) : super(Properties().stacksTo(1).rarity(Rarity.EPIC).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) { + constructor(saveDataID: String) : super(Properties().stacksTo(1).rarity(Rarity.EPIC)) { isCreative = true _capacity = { null } _throughput = { null } this.saveDataID = "otm_$saveDataID".intern() } - constructor(saveDataID: String, capacity: Decimal, io: Decimal) : super(Properties().stacksTo(1).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) { + constructor(saveDataID: String, capacity: Decimal, io: Decimal) : super(Properties().stacksTo(1)) { isCreative = false _capacity = { capacity } _throughput = { io } this.saveDataID = "otm_$saveDataID".intern() } - constructor(saveDataID: String, values: ConciseBalanceValues) : super(Properties().stacksTo(1).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) { + constructor(saveDataID: String, values: ConciseBalanceValues) : super(Properties().stacksTo(1)) { isCreative = false _capacity = values::capacity _throughput = values::throughput diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt index 37c0bb5f8..f888fd770 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt @@ -18,10 +18,10 @@ import ru.dbotthepony.mc.otm.core.* open class SingleUseBatteryItem( private val _capacity: () -> Decimal, private val _throughput: () -> Decimal? = { null }, - properties: Properties = Properties().stacksTo(1).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB) + properties: Properties = Properties().stacksTo(1) ) : Item(properties) { - constructor(values: ConciseBalanceValues, properties: Properties = Properties().stacksTo(1).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) : this(values::capacity, values::throughput, properties) - constructor(storage: Decimal, throughput: Decimal? = null, properties: Properties = Properties().stacksTo(1).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) : this({ storage }, { throughput }, properties) + constructor(values: ConciseBalanceValues, properties: Properties = Properties().stacksTo(1)) : this(values::capacity, values::throughput, properties) + constructor(storage: Decimal, throughput: Decimal? = null, properties: Properties = Properties().stacksTo(1)) : this({ storage }, { throughput }, properties) val capacity get() = _capacity.invoke() val throughput get() = _throughput.invoke() @@ -58,7 +58,7 @@ open class SingleUseBatteryItem( } } -class ZPMItem : SingleUseBatteryItem(ServerConfig.ZPM_BATTERY, Properties().stacksTo(1).rarity(Rarity.EPIC).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) { +class ZPMItem : SingleUseBatteryItem(ServerConfig.ZPM_BATTERY, Properties().stacksTo(1).rarity(Rarity.EPIC)) { override fun appendHoverText( itemStack: ItemStack, p_41422_: Level?, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt index 1584f5682..bf58e6e3c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt @@ -414,9 +414,9 @@ abstract class AbstractWeaponItem(val tables: KClass, pr yaw += (rotFire.yaw + (predictedData?.fireAnimDeviation?.yaw ?: 0.0)) * fireAnim * (1.0 - progress * 0.6) roll += (rotFire.roll + (predictedData?.fireAnimDeviation?.roll ?: 0.0)) * fireAnim * (1.0 - progress * 0.6) - pose.mulPose(Vector3f.ZP.rotation(roll.toFloat())) - pose.mulPose(Vector3f.YP.rotation(yaw.toFloat())) - pose.mulPose(Vector3f.XP.rotation(pitch.toFloat())) + pose.rotateZ(roll.toFloat()) + pose.rotateY(yaw.toFloat()) + pose.rotateX(pitch.toFloat()) itemInHandRenderer.renderItem( player, @@ -436,8 +436,8 @@ abstract class AbstractWeaponItem(val tables: KClass, pr RenderSystem.setShaderColor(1f, 1f, 1f, 1f) pose.translate(-0.85, 0.25, -0.25) - pose.mulPose(Vector3f.ZP.rotationDegrees(180f)) - pose.mulPose(Vector3f.YP.rotationDegrees(180f)) + pose.rotateZ(PI.toFloat()) + pose.rotateY(PI.toFloat()) pose.scale(0.01f, 0.01f, 0.01f) setDrawColor(holoHudBackground) 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 cf2ec4a80..53599a2e1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/EnergyContainerRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/EnergyContainerRecipe.kt @@ -6,6 +6,8 @@ import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation import net.minecraft.world.inventory.CraftingContainer import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.crafting.CookingBookCategory +import net.minecraft.world.item.crafting.CraftingBookCategory import net.minecraft.world.item.crafting.CraftingRecipe import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.item.crafting.RecipeSerializer @@ -21,12 +23,13 @@ import ru.dbotthepony.mc.otm.core.tagNotNull class EnergyContainerRecipe( p_44153_: ResourceLocation, p_44154_: String, + category: CraftingBookCategory, p_44155_: Int, p_44156_: Int, p_44157_: NonNullList, p_44158_: ItemStack, -) : ShapedRecipe(p_44153_, p_44154_, p_44155_, p_44156_, p_44157_, p_44158_) { - constructor(parent: ShapedRecipe) : this(parent.id, parent.group, parent.width, parent.height, parent.ingredients, parent.resultItem) +) : ShapedRecipe(p_44153_, p_44154_, category, p_44155_, p_44156_, p_44157_, p_44158_) { + constructor(parent: ShapedRecipe) : this(parent.id, parent.group, parent.category(), parent.width, parent.height, parent.ingredients, parent.resultItem) override fun assemble(container: CraftingContainer): ItemStack { val itemStack = super.assemble(container) 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 06625839d..60a750a26 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.registry import net.minecraft.ChatFormatting import net.minecraft.core.BlockPos import net.minecraft.network.chat.Component +import net.minecraft.sounds.SoundEvents import net.minecraft.util.valueproviders.UniformInt import net.minecraft.world.entity.Entity import net.minecraft.world.entity.monster.Zombie @@ -133,7 +134,7 @@ object MBlocks { val METAL_BEAM: Block by registry.register(MNames.METAL_BEAM) { Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.GRAY).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) } val TRITANIUM_DOOR = registry.allColored(MNames.TRITANIUM_DOOR) { color, _ -> - object : DoorBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops()) { + object : DoorBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), SoundEvents.IRON_DOOR_CLOSE, SoundEvents.IRON_DOOR_OPEN) { override fun appendHoverText( p_49816_: ItemStack, p_49817_: BlockGetter?, @@ -161,7 +162,7 @@ object MBlocks { } val TRITANIUM_TRAPDOOR = registry.allColored(MNames.TRITANIUM_TRAPDOOR) { color, _ -> - object : TrapDoorBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops()) { + object : TrapDoorBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), SoundEvents.IRON_DOOR_CLOSE, SoundEvents.IRON_DOOR_OPEN) { override fun appendHoverText( p_49816_: ItemStack, p_49817_: BlockGetter?, 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 ef7ac0a2b..c19180a93 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,7 @@ package ru.dbotthepony.mc.otm.registry import net.minecraft.core.Registry +import net.minecraft.core.registries.Registries import net.minecraft.world.level.storage.loot.functions.LootItemFunctionType import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.registries.DeferredRegister @@ -8,7 +9,7 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.data.loot.RandomizerFunction object MItemFunctionTypes { - private val registry = DeferredRegister.create(Registry.LOOT_FUNCTION_REGISTRY, OverdriveThatMatters.MOD_ID) + private val registry = DeferredRegister.create(Registries.LOOT_FUNCTION_TYPE, OverdriveThatMatters.MOD_ID) val RANDOMIZER: LootItemFunctionType by registry.register("randomizer") { LootItemFunctionType(RandomizerFunction.Companion) } 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 20fa79776..9149e0b10 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MLootItemConditions.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MLootItemConditions.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.registry import net.minecraft.core.Registry +import net.minecraft.core.registries.Registries import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.registries.DeferredRegister @@ -13,7 +14,7 @@ import ru.dbotthepony.mc.otm.data.condition.KilledByRealPlayerOrIndirectly import ru.dbotthepony.mc.otm.data.condition.ChanceCondition object MLootItemConditions { - private val registry = DeferredRegister.create(Registry.LOOT_ITEM_REGISTRY, OverdriveThatMatters.MOD_ID) + private val registry = DeferredRegister.create(Registries.LOOT_CONDITION_TYPE, OverdriveThatMatters.MOD_ID) val HAS_EXOPACK: LootItemConditionType by registry.register("has_exopack") { LootItemConditionType(HasExoPackCondition) } val CHANCE_WITH_PLAYTIME: LootItemConditionType by registry.register("chance_with_playtime") { LootItemConditionType(ChanceWithPlaytimeCondition) } 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 35ad59aa6..6a92474ae 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MSoundEvents.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MSoundEvents.kt @@ -13,7 +13,8 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters object MSoundEvents { private val registry: DeferredRegister = DeferredRegister.create(ForgeRegistries.SOUND_EVENTS, OverdriveThatMatters.MOD_ID) - private fun make(name: String) = registry.register(name) { SoundEvent(ResourceLocation(OverdriveThatMatters.MOD_ID, name)) } + // TODO: 1.19.3 + private fun make(name: String) = registry.register(name) { SoundEvent.createVariableRangeEvent(ResourceLocation(OverdriveThatMatters.MOD_ID, name)) } val RIFLE_SHOT: SoundEvent by make("item.rifle_shot") val PLASMA_WEAPON_OVERHEAT: SoundEvent by make("item.plasma_weapon_overheat") 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 dffa75140..efc37a888 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MStats.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MStats.kt @@ -1,9 +1,9 @@ package ru.dbotthepony.mc.otm.registry import net.minecraft.core.Registry +import net.minecraft.core.registries.BuiltInRegistries import net.minecraft.stats.StatFormatter import net.minecraft.stats.Stats -import net.minecraftforge.eventbus.api.SubscribeEvent import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent import ru.dbotthepony.mc.otm.registry.StatNames.DAMAGE_ABSORBED import ru.dbotthepony.mc.otm.registry.StatNames.HEALTH_REGENERATED @@ -12,9 +12,9 @@ import ru.dbotthepony.mc.otm.registry.StatNames.POWER_CONSUMED object MStats { fun registerVanilla(event: FMLCommonSetupEvent) { event.enqueueWork { - Registry.register(Registry.CUSTOM_STAT, DAMAGE_ABSORBED, DAMAGE_ABSORBED) - Registry.register(Registry.CUSTOM_STAT, HEALTH_REGENERATED, HEALTH_REGENERATED) - Registry.register(Registry.CUSTOM_STAT, POWER_CONSUMED, POWER_CONSUMED) + Registry.register(BuiltInRegistries.CUSTOM_STAT, DAMAGE_ABSORBED, DAMAGE_ABSORBED) + Registry.register(BuiltInRegistries.CUSTOM_STAT, HEALTH_REGENERATED, HEALTH_REGENERATED) + Registry.register(BuiltInRegistries.CUSTOM_STAT, POWER_CONSUMED, POWER_CONSUMED) Stats.CUSTOM[DAMAGE_ABSORBED, StatFormatter.DIVIDE_BY_TEN] Stats.CUSTOM[HEALTH_REGENERATED, StatFormatter.DIVIDE_BY_TEN] Stats.CUSTOM[POWER_CONSUMED, StatFormatter.DIVIDE_BY_TEN] diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/StripedColoredDecorativeBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/StripedColoredDecorativeBlock.kt index ba916e079..fe3516ddf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/StripedColoredDecorativeBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/StripedColoredDecorativeBlock.kt @@ -18,7 +18,7 @@ class StripedColoredDecorativeBlock( val basename: String, val blockFactory: (colorA: DyeColor, colorB: DyeColor) -> Block, val itemFactory: ((colorA: DyeColor, colorB: DyeColor, block: Block) -> Item) = { _, _, block -> - BlockItem(block, Item.Properties().tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB_DECORATIVE).stacksTo(64)) + BlockItem(block, Item.Properties().stacksTo(64)) } ) { private val mapBlocks = EnumMap>>(DyeColor::class.java) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/OreGen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/OreGen.kt index 37429e909..495aadf91 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/OreGen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/OreGen.kt @@ -1,8 +1,6 @@ package ru.dbotthepony.mc.otm.worldgen import net.minecraft.core.Holder -import net.minecraft.data.BuiltinRegistries.CONFIGURED_FEATURE -import net.minecraft.data.BuiltinRegistries.PLACED_FEATURE import net.minecraft.data.worldgen.features.OreFeatures import net.minecraft.world.level.levelgen.VerticalAnchor import net.minecraft.world.level.levelgen.feature.ConfiguredFeature From ee53b85aff6a268bcdc55ce4304f39f5e5193c81 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 7 Jan 2023 15:48:26 +0700 Subject: [PATCH 0007/1199] Update datagen class --- .../mc/otm/android/AndroidResearchDataProvider.kt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDataProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDataProvider.kt index 550c2a973..74ab0d7fa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDataProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDataProvider.kt @@ -4,15 +4,15 @@ import it.unimi.dsi.fastutil.objects.ObjectArraySet import net.minecraft.data.CachedOutput import net.minecraft.data.DataGenerator import net.minecraft.data.DataProvider +import net.minecraft.data.PackOutput import net.minecraft.resources.ResourceLocation import java.util.Collections import java.util.LinkedList +import java.util.concurrent.CompletableFuture import java.util.function.Consumer @Suppress("unused") -open class AndroidResearchDataProvider(protected val dataGenerator: DataGenerator) : DataProvider { - protected val pathProvider: DataGenerator.PathProvider = dataGenerator.createPathProvider(DataGenerator.Target.DATA_PACK, AndroidResearchManager.DIRECTORY) - +open class AndroidResearchDataProvider(protected val dataGenerator: DataGenerator, val modid: String) : DataProvider { protected val callbacks = LinkedList<(Consumer) -> Unit>() private val generated = LinkedList() @@ -35,15 +35,18 @@ open class AndroidResearchDataProvider(protected val dataGenerator: DataGenerato return this } - final override fun run(output: CachedOutput) { + final override fun run(output: CachedOutput): CompletableFuture<*> { AndroidResearchManager.fireRegistrationEvent() val set = ObjectArraySet() val added = LinkedList() + val futures = ArrayList>() + + val path = dataGenerator.packOutput.getOutputFolder(PackOutput.Target.DATA_PACK).resolve(modid).resolve(AndroidResearchManager.DIRECTORY) addEverything { if (set.add(it.id)) { - DataProvider.saveStable(output, it.toJson(), pathProvider.json(it.id)) + futures.add(DataProvider.saveStable(output, it.toJson(), path.resolve("${it.id}.json"))) AndroidResearchManager.put(it) added.add(it) } else { @@ -55,6 +58,8 @@ open class AndroidResearchDataProvider(protected val dataGenerator: DataGenerato value.validate() generated.add(value) } + + return CompletableFuture.allOf(*futures.toTypedArray()) } override fun getName(): String { From 7e6381ad745f6b0498c0dd7f40a60e73c14445c5 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 7 Jan 2023 15:48:41 +0700 Subject: [PATCH 0008/1199] idk what to do with oregen --- src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/OreGen.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/OreGen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/OreGen.kt index 495aadf91..dfc5c1c4d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/OreGen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/OreGen.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.worldgen import net.minecraft.core.Holder import net.minecraft.data.worldgen.features.OreFeatures +import net.minecraft.tags.BlockTags import net.minecraft.world.level.levelgen.VerticalAnchor import net.minecraft.world.level.levelgen.feature.ConfiguredFeature import net.minecraft.world.level.levelgen.feature.Feature @@ -10,15 +11,19 @@ import net.minecraft.world.level.levelgen.placement.CountPlacement import net.minecraft.world.level.levelgen.placement.HeightRangePlacement import net.minecraft.world.level.levelgen.placement.InSquarePlacement import net.minecraft.world.level.levelgen.placement.PlacedFeature +import net.minecraft.world.level.levelgen.structure.templatesystem.TagMatchTest import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.core.WriteOnce import ru.dbotthepony.mc.otm.registry.register @Suppress("UNNECESSARY_NOT_NULL_ASSERTION") object OreGen { + private val STONE_ORE_REPLACEABLES = TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES) + private val DEEPSLATE_ORE_REPLACEABLES = TagMatchTest(BlockTags.DEEPSLATE_ORE_REPLACEABLES) + val ORE_TRITANIUM_TARGET_LIST = listOf( - OreConfiguration.target(OreFeatures.STONE_ORE_REPLACEABLES, MBlocks.TRITANIUM_ORE.defaultBlockState())!!, - OreConfiguration.target(OreFeatures.DEEPSLATE_ORE_REPLACEABLES, MBlocks.DEEPSLATE_TRITANIUM_ORE.defaultBlockState())!!, + OreConfiguration.target(STONE_ORE_REPLACEABLES, MBlocks.TRITANIUM_ORE.defaultBlockState())!!, + OreConfiguration.target(DEEPSLATE_ORE_REPLACEABLES, MBlocks.DEEPSLATE_TRITANIUM_ORE.defaultBlockState())!!, ) var ORE_FEATURE_TRITANIUM_NORMAL by WriteOnce>>() From be2dcc6bae8c39b2970ff9439cc28a6d00c91158 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 7 Jan 2023 16:12:41 +0700 Subject: [PATCH 0009/1199] One more data provider --- .../mc/otm/matter/MatterDataProvider.kt | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) 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 e2a37e01d..df5927d60 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterDataProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterDataProvider.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.matter import net.minecraft.data.CachedOutput import net.minecraft.data.DataGenerator 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 @@ -11,13 +12,13 @@ import net.minecraftforge.data.event.GatherDataEvent import ru.dbotthepony.mc.otm.core.Decimal import ru.dbotthepony.mc.otm.core.registryName import java.util.Collections +import java.util.concurrent.CompletableFuture import java.util.function.Consumer @Suppress("FunctionName", "unused") -open class MatterDataProvider(protected val dataGenerator: DataGenerator, val namespace: String?) : DataProvider { +open class MatterDataProvider(protected val dataGenerator: DataGenerator, val modid: String) : DataProvider { constructor(event: GatherDataEvent) : this(event.generator, event.modContainer.namespace) - protected val pathProvider: DataGenerator.PathProvider = dataGenerator.createPathProvider(DataGenerator.Target.DATA_PACK, MatterManager.MATTER_DIRECTORY) protected val actions = LinkedHashMap() sealed class Configuration(val name: ResourceLocation) { @@ -911,14 +912,10 @@ open class MatterDataProvider(protected val dataGenerator: DataGenerator, val na } protected fun updateLocation(input: ResourceLocation, prefix: String): ResourceLocation { - if (namespace != null) { - if (input.namespace == namespace) { - return ResourceLocation(input.namespace, prefix + input.path) - } else { - return ResourceLocation(namespace, prefix + input.namespace + "/" + input.path) - } - } else { + if (input.namespace == modid) { return ResourceLocation(input.namespace, prefix + input.path) + } else { + return ResourceLocation(modid, prefix + input.namespace + "/" + input.path) } } @@ -1204,13 +1201,18 @@ open class MatterDataProvider(protected val dataGenerator: DataGenerator, val na protected val added = ArrayList() val addedView: List = Collections.unmodifiableList(added) - final override fun run(output: CachedOutput) { + final override fun run(output: CachedOutput): CompletableFuture<*> { addActions() + val promises = ArrayList>() + val path = dataGenerator.packOutput.getOutputFolder(PackOutput.Target.DATA_PACK).resolve(modid).resolve(MatterManager.MATTER_DIRECTORY) + for ((key, value) in actions) { - DataProvider.saveStable(output, value.toJson(), pathProvider.json(key)) + promises.add(DataProvider.saveStable(output, value.toJson(), path.resolve("$key.json"))) added.add(value) } + + return CompletableFuture.allOf(*promises.toTypedArray()) } override fun getName(): String { From adad99a6bf83c533b090f6ee50cd58f493729253 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 7 Jan 2023 16:15:00 +0700 Subject: [PATCH 0010/1199] Declare batteryLevel and matterLevel as vars instead of vals --- .../otm/capability/IMatteryEnergyStorage.kt | 16 ++++++- .../otm/capability/matter/IMatterHandler.kt | 16 ++++++- .../ru/dbotthepony/mc/otm/item/BatteryItem.kt | 14 ------ .../mc/otm/item/EnergySwordItem.kt | 10 ----- .../mc/otm/item/MatterCapacitorItem.kt | 14 ------ .../item/ProceduralExoPackSlotUpgradeItem.kt | 2 +- .../mc/otm/recipe/EnergyContainerRecipe.kt | 5 ++- .../mc/otm/registry/CreativeTabs.kt | 43 +++++++++++++++++-- 8 files changed, 73 insertions(+), 47 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/IMatteryEnergyStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/IMatteryEnergyStorage.kt index f4c241e34..a38abf9ce 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/IMatteryEnergyStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/IMatteryEnergyStorage.kt @@ -42,11 +42,25 @@ interface IMatteryEnergyStorage : IEnergyStorage { */ fun receiveEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal - val batteryLevel: Decimal + var batteryLevel: Decimal val maxBatteryLevel: Decimal val missingPower: Decimal get() = (maxBatteryLevel - batteryLevel).moreThanZero() + /** + * Empties power of this energy storage + */ + fun emptyBattery() { + batteryLevel = Decimal.ZERO + } + + /** + * Fully fills power in this energy storage + */ + fun fillBattery() { + batteryLevel = maxBatteryLevel + } + override fun receiveEnergy(maxReceive: Int, simulate: Boolean): Int { val received = receiveEnergyOuter(maxReceive, true).toInt() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterHandler.kt index a661ef67a..38f5dd893 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterHandler.kt @@ -8,9 +8,23 @@ import ru.dbotthepony.mc.otm.core.orNull import kotlin.math.roundToInt interface IMatterHandler { - val storedMatter: Decimal + var storedMatter: Decimal val maxStoredMatter: Decimal + /** + * Empties matter stored of this matter storage + */ + fun emptyMatter() { + storedMatter = Decimal.ZERO + } + + /** + * Fully fills matter stored in this matter storage + */ + fun fillMatter() { + storedMatter = maxStoredMatter + } + fun receiveMatterOuter(howMuch: Decimal, simulate: Boolean): Decimal fun receiveMatterInner(howMuch: Decimal, simulate: Boolean): Decimal fun extractMatterOuter(howMuch: Decimal, simulate: Boolean): Decimal diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt index 9aeea6fff..dbe491b6b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt @@ -145,20 +145,6 @@ open class BatteryItem : Item { } } - override fun fillItemCategory(p_41391_: CreativeModeTab, p_41392_: NonNullList) { - super.fillItemCategory(p_41391_, p_41392_) - - if (!isCreative && allowedIn(p_41391_)) { - p_41392_.add(ItemStack(this).also { - it.matteryEnergy?.let { - if (it is Power) { - it.maxPower() - } - } - }) - } - } - override fun initCapabilities(stack: ItemStack, nbt: CompoundTag?): ICapabilityProvider { return Power(stack) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt index d303d4852..2f7d19a66 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt @@ -193,16 +193,6 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani return EnergyConsumerItem(stack, MAX_ENERGY) } - override fun fillItemCategory(p_41391_: CreativeModeTab, p_41392_: NonNullList) { - super.fillItemCategory(p_41391_, p_41392_) - - if (allowedIn(p_41391_)) { - p_41392_.add(ItemStack(this).also { - it.matteryEnergy?.receiveEnergyInner(MAX_ENERGY, false) - }) - } - } - override fun getAttributeModifiers( slot: EquipmentSlot, itemStack: ItemStack diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt index 9058ef64a..bef7f1022 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt @@ -109,20 +109,6 @@ class MatterCapacitorItem : Item { _capacity = { Decimal.LONG_MAX_VALUE } } - override fun fillItemCategory(p_41391_: CreativeModeTab, p_41392_: NonNullList) { - super.fillItemCategory(p_41391_, p_41392_) - - if (!isCreative && allowedIn(p_41391_)) { - p_41392_.add(ItemStack(this).also { - it.getCapability(MatteryCapability.MATTER).ifPresentK { - if (it is Matter) { - it.storedMatter = it.maxStoredMatter - } - } - }) - } - } - override fun isBarVisible(p_150899_: ItemStack): Boolean { if (isCreative) return false diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralExoPackSlotUpgradeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralExoPackSlotUpgradeItem.kt index b7c645f20..9128da3b0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralExoPackSlotUpgradeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralExoPackSlotUpgradeItem.kt @@ -15,7 +15,7 @@ import ru.dbotthepony.mc.otm.data.loot.IRandomizableItem import java.util.* @Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") // .tab(null) is a legal statement because tab field itself is nullable -class ProceduralExoPackSlotUpgradeItem : AbstractExoPackSlotUpgradeItem(defaultProperties().tab(null)), +class ProceduralExoPackSlotUpgradeItem : AbstractExoPackSlotUpgradeItem(defaultProperties()), IRandomizableItem { override fun getRarity(itemStack: ItemStack): Rarity { return when (slotCount(itemStack)) { 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 53599a2e1..61d607024 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/EnergyContainerRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/EnergyContainerRecipe.kt @@ -17,6 +17,7 @@ import ru.dbotthepony.mc.otm.capability.ItemEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.container.iterator import ru.dbotthepony.mc.otm.container.stream +import ru.dbotthepony.mc.otm.core.filterNotNull import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.core.tagNotNull @@ -37,11 +38,11 @@ class EnergyContainerRecipe( val battery = container.stream() .filter { !it.isEmpty } .map { it.matteryEnergy } - .filter { it != null } + .filterNotNull() .findAny().orElse(null) if (battery != null) { - itemStack.tagNotNull[ItemEnergyStorageImpl.ENERGY_KEY] = battery.batteryLevel.serializeNBT() + itemStack.matteryEnergy?.batteryLevel = battery.batteryLevel } if (itemStack.isEnchantable) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt index e8851322b..59dae9636 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt @@ -3,6 +3,10 @@ package ru.dbotthepony.mc.otm.registry import net.minecraft.world.item.CreativeModeTab import net.minecraft.world.item.DyeColor import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.capability.matter.matter +import ru.dbotthepony.mc.otm.capability.matteryEnergy +import ru.dbotthepony.mc.otm.core.registryName private fun CreativeModeTab.Output.accept(values: Collection) { for (item in values) { @@ -58,6 +62,37 @@ private fun CreativeModeTab.Output.all(values: Map) { colored(values) } +private fun CreativeModeTab.Output.energized(value: Item) { + accept(value) + + val stack = ItemStack(value, 1) + val energy = stack.matteryEnergy ?: throw IllegalArgumentException("${value.registryName} does not implement mattery energy capability") + energy.fillBattery() + accept(stack) +} + +private fun CreativeModeTab.Output.energized(values: Iterable) { + for (value in values) { + energized(value) + } +} + +private fun CreativeModeTab.Output.mattery(value: Item) { + accept(value) + + val stack = ItemStack(value, 1) + val matter = stack.matter ?: throw IllegalArgumentException("${value.registryName} does not implement matter capability") + + matter.fillMatter() + accept(stack) +} + +private fun CreativeModeTab.Output.mattery(values: Iterable) { + for (value in values) { + mattery(value) + } +} + internal fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { with(consumer) { accept(MItems.MACHINES) @@ -77,8 +112,8 @@ internal fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { accept(MItems.TRITANIUM_TOOLS) accept(MItems.TRITANIUM_ARMOR) - accept(MItems.ENERGY_SWORD) - accept(MItems.PLASMA_RIFLE) + energized(MItems.ENERGY_SWORD) + energized(MItems.PLASMA_RIFLE) accept(MItems.BLACK_HOLE_SCANNER) accept(MItems.GRAVITATION_FIELD_LIMITER) @@ -87,8 +122,8 @@ internal fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { accept(MItems.BLACK_HOLE) accept(MItems.GRAVITATIONAL_DISRUPTOR) - accept(MItems.ALL_BATTERIES) - accept(MItems.MATTER_CAPACITORS) + energized(MItems.ALL_BATTERIES) + mattery(MItems.MATTER_CAPACITORS) base(MItems.CARGO_CRATE_MINECARTS) From c4396658715504c629941eccacb46da98dc6b731 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 7 Jan 2023 16:50:20 +0700 Subject: [PATCH 0011/1199] Update battery and matter implementations to reflect vars --- .../block/entity/BatteryBankBlockEntity.kt | 29 +++++++++------- .../block/entity/EnergyCounterBlockEntity.kt | 8 ++++- .../block/entity/EnergyServoBlockEntity.kt | 10 +++++- .../matter/MatterCapacitorBankBlockEntity.kt | 13 ++++++-- .../mc/otm/capability/EnergyStorageImpl.kt | 4 +-- .../ru/dbotthepony/mc/otm/capability/Ext.kt | 25 +++++++++++--- .../otm/capability/IMatteryEnergyStorage.kt | 17 ++++++++++ .../otm/capability/matter/IMatterHandler.kt | 17 ++++++++++ .../capability/matter/MatterHandlerImpl.kt | 1 - .../mc/otm/compat/mekanism/Power.kt | 11 ++++++- .../mc/otm/item/QuantumBatteryItem.kt | 33 ++++++++++++++++--- .../mc/otm/item/weapon/PlasmaWeaponItem.kt | 13 +++++++- 12 files changed, 151 insertions(+), 30 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BatteryBankBlockEntity.kt index 0247fdf29..dab1c48a2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BatteryBankBlockEntity.kt @@ -116,7 +116,7 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte return BatteryBankDistribution(distribution, summ) } - private fun distributeEnergy(isReceiving: Boolean, howMuch: Decimal, simulate: Boolean): Decimal { + private fun distributeEnergy(isReceiving: Boolean, howMuch: Decimal, simulate: Boolean, set: Boolean = false): Decimal { if (!howMuch.isPositive) return Decimal.ZERO @@ -171,21 +171,28 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte return distributeEnergy(isReceiving = true, howMuch, simulate) } - override val batteryLevel: Decimal get() { - var result = Decimal.ZERO + override val canSetBatteryLevel: Boolean + get() = false - for (i in 0 until container.containerSize) { - val stack = container.getItem(i) + override var batteryLevel: Decimal + get() { + var result = Decimal.ZERO - if (!stack.isEmpty) { - stack.energy?.let { - result += it.energyStoredMattery + for (i in 0 until container.containerSize) { + val stack = container.getItem(i) + + if (!stack.isEmpty) { + stack.energy?.let { + result += it.energyStoredMattery + } } } - } - return result - } + return result + } + set(value) { + throw UnsupportedOperationException("Can't set battery value for battery bank") + } override val maxBatteryLevel: Decimal get() { var result = Decimal.ZERO diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt index 5a4d9f90b..613ee4eb9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt @@ -190,7 +190,10 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat return Decimal.ZERO } - override val batteryLevel: Decimal + override val canSetBatteryLevel: Boolean + get() = false + + override var batteryLevel: Decimal get() { if (isInput) { if (outputCapability.isPresent) { @@ -216,6 +219,9 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat return Decimal.ZERO } + set(value) { + throw UnsupportedOperationException("Can't set energy on energy counter") + } override val maxBatteryLevel: Decimal get() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyServoBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyServoBlockEntity.kt index 6be52e29e..cdcff1a5b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyServoBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyServoBlockEntity.kt @@ -16,6 +16,7 @@ import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.capability.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.canSetBatteryMattery import ru.dbotthepony.mc.otm.capability.energy import ru.dbotthepony.mc.otm.capability.energyStoredMattery import ru.dbotthepony.mc.otm.capability.extractEnergy @@ -74,8 +75,15 @@ class EnergyServoBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte return container[SLOT_CHARGE].energy?.receiveEnergy(howMuch, simulate) ?: Decimal.ZERO } - override val batteryLevel: Decimal + override val canSetBatteryLevel: Boolean + get() = container[SLOT_CHARGE].energy?.canSetBatteryMattery ?: container[SLOT_DISCHARGE].energy?.canSetBatteryMattery ?: false + + override var batteryLevel: Decimal get() = container[SLOT_CHARGE].energy?.energyStoredMattery ?: container[SLOT_DISCHARGE].energy?.energyStoredMattery ?: Decimal.ZERO + set(value) { + val energy = container[SLOT_CHARGE].energy ?: container[SLOT_DISCHARGE].energy ?: throw UnsupportedOperationException("No item in slots") + energy.energyStoredMattery = value + } override val maxBatteryLevel: Decimal get() = container[SLOT_CHARGE].energy?.maxEnergyStoredMattery ?: container[SLOT_DISCHARGE].energy?.maxEnergyStoredMattery ?: Decimal.ZERO diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt index 73d01b49b..fe7bca537 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt @@ -24,6 +24,7 @@ import ru.dbotthepony.mc.otm.capability.matter.IMatterHandler import ru.dbotthepony.mc.otm.capability.matter.MatterDirection import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph @@ -39,24 +40,30 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) override val matterNode = Graph6Node(this) private val resolverNode = LazyOptional.of { this } - override val storedMatter: Decimal get() { + override val canSetMatterLevel: Boolean + get() = false + + override var storedMatter: Decimal get() { var summ = Decimal.ZERO for (stack in container) if (!stack.isEmpty) - stack.getCapability(MatteryCapability.MATTER).ifPresent { + stack.getCapability(MatteryCapability.MATTER).ifPresentK { summ += it.storedMatter } return summ } + set(value) { + throw UnsupportedOperationException() + } override val maxStoredMatter: Decimal get() { var summ = Decimal.ZERO for (stack in container) if (!stack.isEmpty) - stack.getCapability(MatteryCapability.MATTER).ifPresent { + stack.getCapability(MatteryCapability.MATTER).ifPresentK { summ += it.maxStoredMatter } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/EnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/EnergyStorageImpl.kt index 5e96e9c81..3bf4d780d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/EnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/EnergyStorageImpl.kt @@ -131,7 +131,7 @@ sealed class ItemEnergyStorageImpl( override var batteryLevel: Decimal get() = itemStack.tag?.map(ENERGY_KEY, Decimal::deserializeNBT) ?: initialBatteryLevel - protected set(value) { + set(value) { itemStack.tagNotNull[ENERGY_KEY] = value.serializeNBT() } @@ -301,7 +301,7 @@ sealed class BlockEnergyStorageImpl( } override var batteryLevel = Decimal.ZERO - protected set(value) { + set(value) { if (value != field) { field = value listener.invoke() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt index c49fad79e..a3e23da12 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt @@ -63,12 +63,29 @@ val IEnergyStorage.maxEnergyStoredMattery: Decimal get() { return Decimal.valueOf(maxEnergyStored) } -val IEnergyStorage.energyStoredMattery: Decimal get() { - if (this is IMatteryEnergyStorage) { - return batteryLevel +var IEnergyStorage.energyStoredMattery: Decimal + get() { + if (this is IMatteryEnergyStorage) { + return batteryLevel + } + + return Decimal.valueOf(energyStored) + } + set(value) { + if (this is IMatteryEnergyStorage) { + batteryLevel = value + return + } + + throw UnsupportedOperationException("Can't set stored energy on ${this::class.qualifiedName}") } - return Decimal.valueOf(energyStored) +val IEnergyStorage.canSetBatteryMattery: Boolean get() { + if (this is IMatteryEnergyStorage) { + return canSetBatteryLevel + } + + return false } val IEnergyStorage.chargeRatio: Float get() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/IMatteryEnergyStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/IMatteryEnergyStorage.kt index a38abf9ce..9903c83d9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/IMatteryEnergyStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/IMatteryEnergyStorage.kt @@ -42,6 +42,17 @@ interface IMatteryEnergyStorage : IEnergyStorage { */ fun receiveEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal + /** + * If this is false, then [batteryLevel] will throw [UnsupportedOperationException] when trying to set it + */ + val canSetBatteryLevel: Boolean get() = true + + /** + * Implementations are free to throw [UnsupportedOperationException] if setting battery level is not supported + * due to technical complications (in this case, [canSetBatteryLevel] MUST be false) + * + * @throws [UnsupportedOperationException] + */ var batteryLevel: Decimal val maxBatteryLevel: Decimal val missingPower: Decimal @@ -49,6 +60,9 @@ interface IMatteryEnergyStorage : IEnergyStorage { /** * Empties power of this energy storage + * + * @throws [UnsupportedOperationException] + * @see batteryLevel */ fun emptyBattery() { batteryLevel = Decimal.ZERO @@ -56,6 +70,9 @@ interface IMatteryEnergyStorage : IEnergyStorage { /** * Fully fills power in this energy storage + * + * @throws [UnsupportedOperationException] + * @see batteryLevel */ fun fillBattery() { batteryLevel = maxBatteryLevel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterHandler.kt index 38f5dd893..7863b2e9a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterHandler.kt @@ -8,11 +8,25 @@ import ru.dbotthepony.mc.otm.core.orNull import kotlin.math.roundToInt interface IMatterHandler { + /** + * If this is false, then [storedMatter] will throw [UnsupportedOperationException] when trying to set it + */ + val canSetMatterLevel: Boolean get() = true + + /** + * Implementations are free to throw [UnsupportedOperationException] if setting battery level is not supported + * due to technical complications (in this case, [canSetMatterLevel] MUST be false) + * + * @throws [UnsupportedOperationException] + */ var storedMatter: Decimal val maxStoredMatter: Decimal /** * Empties matter stored of this matter storage + * + * @throws [UnsupportedOperationException] + * @see storedMatter */ fun emptyMatter() { storedMatter = Decimal.ZERO @@ -20,6 +34,9 @@ interface IMatterHandler { /** * Fully fills matter stored in this matter storage + * + * @throws [UnsupportedOperationException] + * @see storedMatter */ fun fillMatter() { storedMatter = maxStoredMatter diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterHandlerImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterHandlerImpl.kt index b50bc0bb5..fb80c3b23 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterHandlerImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterHandlerImpl.kt @@ -42,7 +42,6 @@ open class MatterHandlerImpl @JvmOverloads constructor( get() = maxStoredMatterSupplier.invoke() override var storedMatter = Decimal.ZERO - protected set private var handler = LazyOptional.of { this } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt index e0d67b117..233ca45e9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt @@ -97,7 +97,10 @@ class Mekanism2MatteryEnergyWrapper(private val power: IStrictEnergyHandler, pri return receiveEnergyOuter(howMuch, simulate) } - override val batteryLevel: Decimal + override val canSetBatteryLevel: Boolean + get() = power.energyContainerCount == 1 + + override var batteryLevel: Decimal get() { var sum = Decimal.ZERO @@ -107,6 +110,12 @@ class Mekanism2MatteryEnergyWrapper(private val power: IStrictEnergyHandler, pri return sum * mekanism2MtJ } + set(value) { + if (power.energyContainerCount != 1) + throw UnsupportedOperationException("Can set power only when we have 1 energy container, ${power.energyContainerCount} present") + + power.setEnergy(0, (value * mtj2Mekanism).toFloatingLong()) + } override val maxBatteryLevel: Decimal get() { 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 fe7243c2f..d51b91b94 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.item import it.unimi.dsi.fastutil.ints.Int2ObjectAVLTreeMap +import it.unimi.dsi.fastutil.ints.Int2ObjectFunction import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import it.unimi.dsi.fastutil.ints.IntAVLTreeSet import it.unimi.dsi.fastutil.ints.IntOpenHashSet @@ -169,7 +170,7 @@ class QuantumBatteryItem : Item { return diff } - override val batteryLevel: Decimal + override var batteryLevel: Decimal get() { if (data.parent == null) { determineQuantumLink() @@ -181,6 +182,25 @@ class QuantumBatteryItem : Item { return data.energy } + set(value) { + if (data.parent == null) { + determineQuantumLink() + } + + if (isClientThread()) { + val energy1 = clientPowerMap[data.index] + + if (energy1 != null) { + energy1.energy = value + } else { + data.energy = value + } + + return + } + + data.energy = value + } val passed: Decimal get() { if (data.parent == null) { @@ -282,9 +302,9 @@ class QuantumBatteryItem : Item { } data class ClientData( - val energy: Decimal = Decimal.ZERO, - val passed: Decimal = Decimal.ZERO, - val received: Decimal = Decimal.ZERO, + var energy: Decimal = Decimal.ZERO, + var passed: Decimal = Decimal.ZERO, + var received: Decimal = Decimal.ZERO, ) val clientPowerMap: Int2ObjectOpenHashMap by lazy { @@ -447,7 +467,10 @@ class QuantumBatteryItem : Item { override fun play(context: Supplier) { context.packetHandled = true - type.clientPowerMap[channel] = ClientData(energy, passed, received) + val data = type.clientPowerMap.computeIfAbsent(channel, Int2ObjectFunction { ClientData() }) + data.energy = energy + data.passed = passed + data.received = received } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt index d16fe3a3f..a6c0824b3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt @@ -138,8 +138,19 @@ class PlasmaWeaponEnergy(val itemStack: ItemStack, private val innerCapacity: De return true } - override val batteryLevel: Decimal + override fun emptyBattery() { + innerBatteryLevel = Decimal.ZERO + } + + override fun fillBattery() { + innerBatteryLevel = innerCapacity + } + + override var batteryLevel: Decimal get() = (battery.energy?.energyStoredMattery ?: Decimal.ZERO) + innerBatteryLevel + set(value) { + innerBatteryLevel = value + } override val maxBatteryLevel: Decimal get() = (battery.energy?.maxEnergyStoredMattery ?: Decimal.ZERO) + innerCapacity From 68b68c42194da5091d800d688431eb5c1b92998f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 13 Jan 2023 15:30:39 +0700 Subject: [PATCH 0012/1199] Rename Skin Element to Mattery Sprite --- .../mc/otm/android/AndroidResearch.kt | 7 - .../mc/otm/android/AndroidResearchType.kt | 7 +- .../dbotthepony/mc/otm/client/MatteryGUI.kt | 4 +- ...kinElement.kt => AbstractMatterySprite.kt} | 46 +--- .../mc/otm/client/render/AtlasSkinElement.kt | 215 ------------------ .../otm/client/render/DynamicBufferSource.kt | 6 +- .../{SkinElement.kt => MatterySprite.kt} | 30 +-- .../mc/otm/client/render/ResearchIcons.kt | 48 ++-- .../mc/otm/client/render/SkinElementType.kt | 64 +++--- .../mc/otm/client/render/SkinGrid.kt | 6 +- .../render/StretchingRectangleElement.kt | 18 +- ...{SubSkinElement.kt => SubMatterySprite.kt} | 14 +- .../mc/otm/client/render/SubSkinGrid.kt | 6 +- .../mc/otm/client/render/WidgetAtlasHolder.kt | 99 -------- .../mc/otm/client/render/WidgetLocation.kt | 12 +- .../mc/otm/client/render/Widgets8.kt | 2 +- .../client/render/blockentity/BankRenderer.kt | 11 +- .../client/screen/panels/AbstractSlotPanel.kt | 2 +- .../mc/otm/client/screen/panels/FramePanel.kt | 4 +- .../client/screen/panels/HeightControls.kt | 10 +- .../screen/panels/ScrollBarConstants.kt | 24 +- .../mc/otm/client/screen/panels/SlotPanel.kt | 5 +- .../buttons/BooleanRectangleButtonPanel.kt | 6 +- .../screen/panels/buttons/CheckBoxPanel.kt | 18 +- .../buttons/EnumRectangleButtonPanel.kt | 14 +- .../LargeBooleanRectangleButtonPanel.kt | 6 +- .../buttons/LargeRectangleButtonPanel.kt | 4 +- .../panels/buttons/RectangleButtonPanel.kt | 10 +- .../SmallBooleanRectangleButtonPanel.kt | 4 +- .../buttons/SmallRectangleButtonPanel.kt | 4 +- .../mc/otm/compat/cos/CosmeticArmorCompat.kt | 18 +- .../mc/otm/compat/jei/SkinDrawable.kt | 4 +- 32 files changed, 171 insertions(+), 557 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/render/{AbstractSkinElement.kt => AbstractMatterySprite.kt} (89%) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AtlasSkinElement.kt rename src/main/kotlin/ru/dbotthepony/mc/otm/client/render/{SkinElement.kt => MatterySprite.kt} (60%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/render/{SubSkinElement.kt => SubMatterySprite.kt} (80%) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetAtlasHolder.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt index 0b1fc9484..20466b6a5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt @@ -9,27 +9,20 @@ import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.player.Player -import net.minecraft.world.item.ItemStack import net.minecraftforge.common.util.INBTSerializable import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.awareItemsStream -import ru.dbotthepony.mc.otm.capability.itemsStream -import ru.dbotthepony.mc.otm.client.render.SkinElement -import ru.dbotthepony.mc.otm.container.iterator import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.addAll import ru.dbotthepony.mc.otm.core.getCompoundList -import ru.dbotthepony.mc.otm.core.nonEmpty import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.milliTime -import ru.dbotthepony.mc.otm.nanoTime import ru.dbotthepony.mc.otm.network.FieldSynchronizer import ru.dbotthepony.mc.otm.registry.MRegistry import ru.dbotthepony.mc.otm.triggers.AndroidResearchTrigger -import java.io.DataInputStream import java.io.InputStream import kotlin.math.absoluteValue diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt index 7b5b67288..cc4cf4670 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt @@ -21,8 +21,7 @@ import net.minecraft.world.item.Items import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.level.ItemLike import net.minecraftforge.registries.ForgeRegistries -import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement -import ru.dbotthepony.mc.otm.client.render.SkinElement +import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.SkinElementType import ru.dbotthepony.mc.otm.core.ListSet import ru.dbotthepony.mc.otm.core.TranslatableComponent @@ -625,7 +624,7 @@ class AndroidResearchType( var description: MutableList? = null, var descriptionSuppliers: MutableList? = null, var itemIcon: Item? = null, - var skinIcon: AbstractSkinElement? = null, + var skinIcon: AbstractMatterySprite? = null, var iconText: Component? = null, ) { private val items = ArrayList>() @@ -639,7 +638,7 @@ class AndroidResearchType( return this } - fun withIcon(icon: AbstractSkinElement? = null): Builder { + fun withIcon(icon: AbstractMatterySprite? = null): Builder { this.skinIcon = icon this.itemIcon = null return this diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index bdca96c1e..830d1e3da 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -12,8 +12,6 @@ import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.player.Player import net.minecraftforge.client.event.RenderGuiEvent import net.minecraftforge.client.event.RenderGuiOverlayEvent -import net.minecraftforge.client.event.RenderLevelLastEvent -import net.minecraftforge.client.event.RenderLevelStageEvent import net.minecraftforge.client.event.ScreenEvent import net.minecraftforge.client.gui.overlay.ForgeGui import net.minecraftforge.client.gui.overlay.GuiOverlayManager @@ -30,7 +28,7 @@ import java.util.* import kotlin.math.ceil object MatteryGUI { - private val BARS = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "player_bars"), 80f, 36f) + private val BARS = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "player_bars"), 80f, 36f) val CHARGE = BARS.subElement(height = 9f) val CHARGE_BG = BARS.subElement(y = 9f, height = 9f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractSkinElement.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt similarity index 89% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractSkinElement.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt index 2805c30d2..af06604b7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractSkinElement.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt @@ -10,7 +10,7 @@ import ru.dbotthepony.mc.otm.core.RGBAColor import ru.dbotthepony.mc.otm.core.linearInterpolation import java.lang.ref.WeakReference -sealed class AbstractSkinElement { +sealed class AbstractMatterySprite { /** * Expected image width in pixels, used in calculations * and as default width argument in render methods @@ -28,14 +28,6 @@ sealed class AbstractSkinElement { abstract val u1: Float abstract val v1: Float - internal open fun addListener(listener: AbstractSkinElement) { - // no-op by default - } - - internal open fun parentChanges(parent: AbstractSkinElement) { - - } - fun partialU(offset: Float): Float { return u0 + (offset / width) * (u1 - u0) } @@ -313,40 +305,4 @@ sealed class AbstractSkinElement { fun toNetwork(buff: FriendlyByteBuf) { type.toActualNetwork(this, buff) } - - abstract class Mutable : AbstractSkinElement() { - private val listeners = ArrayList>(0) - - override fun addListener(listener: AbstractSkinElement) { - synchronized(listeners) { - val iterator = listeners.listIterator() - - for (ref in iterator) { - if (ref.get() == null) { - iterator.remove() - } else if (ref.get() === listener) { - return - } - } - - listeners.add(WeakReference(listener)) - } - } - - protected fun notifyListeners() { - synchronized(listeners) { - val iterator = listeners.listIterator() - - for (ref in iterator) { - val value = ref.get() - - if (value == null) { - iterator.remove() - } else { - value.parentChanges(this) - } - } - } - } - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AtlasSkinElement.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AtlasSkinElement.kt deleted file mode 100644 index c2380e795..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AtlasSkinElement.kt +++ /dev/null @@ -1,215 +0,0 @@ -package ru.dbotthepony.mc.otm.client.render - -import com.mojang.blaze3d.systems.RenderSystem -import com.mojang.blaze3d.vertex.DefaultVertexFormat -import com.mojang.blaze3d.vertex.VertexFormat -import net.minecraft.client.renderer.GameRenderer -import net.minecraft.client.renderer.RenderStateShard -import net.minecraft.client.renderer.RenderStateShard.TextureStateShard -import net.minecraft.client.renderer.RenderType -import net.minecraft.client.renderer.texture.TextureAtlasSprite -import net.minecraft.resources.ResourceLocation -import net.minecraft.util.Mth -import org.lwjgl.opengl.GL11.GL_ALWAYS -import ru.dbotthepony.mc.otm.isClient -import java.lang.ref.WeakReference -import java.util.stream.Stream - -class AtlasSkinElement( - val location: ResourceLocation, - override val width: Float, - override val height: Float, - val spriteWidth: Float = Mth.smallestEncompassingPowerOfTwo(width.toInt()).toFloat(), - val spriteHeight: Float = Mth.smallestEncompassingPowerOfTwo(height.toInt()).toFloat(), - override val winding: UVWindingOrder = UVWindingOrder.NORMAL, -) : AbstractSkinElement.Mutable() { - init { - synchronized(keys) { - if (keys.add(location)) { - if (isWidgetAtlasAvailable) { - queueRebuild() - } - } - } - - // optimistic: we should not create a lot of instances of this class - synchronized(atlasListeners) { - atlasListeners.add(WeakReference(this)) - val iterator = atlasListeners.listIterator() - - for (ref in iterator) { - val value = ref.get() - - if (value == null) { - iterator.remove() - } - } - } - - if (isWidgetAtlasAvailable) { - earlyBindingImpl() - } - } - - private fun earlyBindingImpl() { - if (WidgetAtlasHolder.INSTANCE.once) { - textureAtlasSpriteImpl - } - } - - private var changeset = -1 - private var _textureAtlasSprite: TextureAtlasSprite? = null - - private val textureAtlasSpriteImpl: TextureAtlasSprite get(): TextureAtlasSprite { - check(isClient) { "Invalid realm" } - val _textureAtlasSprite = _textureAtlasSprite - - if ( - _textureAtlasSprite == null || - _textureAtlasSprite.contents().name().let { it.namespace == "minecraft" && it.path == "missingno" } || - changeset != WidgetAtlasHolder.INSTANCE.changeset - ) { - val get = WidgetAtlasHolder.INSTANCE.getSprite(location) - this._textureAtlasSprite = get - changeset = WidgetAtlasHolder.INSTANCE.changeset - - u0 = get.u0 - v0 = get.v0 - u1 = get.u1 - (get.u1 - get.u0) * (1f - width / spriteWidth) - v1 = get.v1 - (get.v1 - get.v0) * (1f - height / spriteHeight) - - notifyListeners() - - return get - } - - return _textureAtlasSprite - } - - val textureAtlasSprite: TextureAtlasSprite get(): TextureAtlasSprite { - check(isWidgetAtlasAvailable) { "Atlas is not available; either we are not a client, or we are running datagen" } - return textureAtlasSpriteImpl - } - - override var u0 = 0f - private set - override var v0 = 0f - private set - override var u1 = 0f - private set - override var v1 = 0f - private set - - override val texture: ResourceLocation get() = WidgetAtlasHolder.LOCATION - - override fun equals(other: Any?): Boolean { - if (other is AtlasSkinElement) - return location == other.location - - return super.equals(other) - } - - override fun hashCode(): Int { - return WidgetAtlasHolder.INSTANCE.hashCode() xor location.hashCode() - } - - override fun toString(): String { - return "AtlasSkinElement[$location]" - } - - override val type: SkinElementType - get() = SkinElementType.ATLAS - - companion object { - private val keys = HashSet() - private val atlasListeners = ArrayList>() - val keysStream: Stream get() = keys.stream() - - fun notifyListeners() { - synchronized(atlasListeners) { - val iterator = atlasListeners.listIterator() - - for (ref in iterator) { - val value = ref.get() - - if (value == null) { - iterator.remove() - } else { - value.textureAtlasSpriteImpl - } - } - } - } - - private fun queueRebuild() { - WidgetAtlasHolder.INSTANCE.queueRebuild() - } - - val renderTypeNoDepth by lazy { - val builder = RenderType.CompositeState.builder() - - builder.setTextureState(TextureStateShard(WidgetAtlasHolder.LOCATION, false, false)) - builder.setShaderState(RenderStateShard.ShaderStateShard(GameRenderer::getPositionColorTexShader)) - builder.setDepthTestState(RenderStateShard.DepthTestStateShard("always", GL_ALWAYS)) - builder.setTransparencyState(RenderStateShard.TransparencyStateShard("normal_blend", { - RenderSystem.enableBlend() - RenderSystem.defaultBlendFunc() - }, { - RenderSystem.disableBlend() - })) - - @Suppress("INACCESSIBLE_TYPE") - RenderType.create("otm_gui_element_no_depth", - DefaultVertexFormat.POSITION_COLOR_TEX, - VertexFormat.Mode.QUADS, - 2048, - false, - false, - builder.createCompositeState(false)) as RenderType - } - - val renderTypeDepth by lazy { - val builder = RenderType.CompositeState.builder() - - builder.setTextureState(TextureStateShard(WidgetAtlasHolder.LOCATION, false, false)) - builder.setShaderState(RenderStateShard.ShaderStateShard(GameRenderer::getPositionColorTexShader)) - builder.setTransparencyState(RenderStateShard.TransparencyStateShard("normal_blend", { - RenderSystem.enableBlend() - RenderSystem.defaultBlendFunc() - }, { - RenderSystem.disableBlend() - })) - - @Suppress("INACCESSIBLE_TYPE") - RenderType.create("otm_gui_element_depth", - DefaultVertexFormat.POSITION_COLOR_TEX, - VertexFormat.Mode.QUADS, - 2048, - false, - false, - builder.createCompositeState(false)) as RenderType - } - - val renderTypeWorld by lazy { - val builder = RenderType.CompositeState.builder() - - builder.setTextureState(TextureStateShard(WidgetAtlasHolder.LOCATION, false, false)) - builder.setShaderState(RenderStateShard.ShaderStateShard(GameRenderer::getPositionColorTexShader)) - builder.setTransparencyState(RenderStateShard.TransparencyStateShard("normal_blend", { - RenderSystem.enableBlend() - RenderSystem.defaultBlendFunc() - }, { - RenderSystem.disableBlend() - })) - - @Suppress("INACCESSIBLE_TYPE") - RenderType.create("otm_gui_element_world", - DefaultVertexFormat.POSITION_COLOR_TEX, - VertexFormat.Mode.QUADS, - 8192, - false, - false, - builder.createCompositeState(false)) as RenderType - } - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt index 2e54a7fee..29c5c343d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt @@ -143,9 +143,9 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit next = State(RenderType.waterMask(), ImmutableList.of(next.type), true, false) it.add(next) - it.add(State(AtlasSkinElement.renderTypeDepth, ImmutableList.of(RenderType.waterMask()), true)) - it.add(State(AtlasSkinElement.renderTypeNoDepth, ImmutableList.of(RenderType.waterMask()), true)) - it.add(State(AtlasSkinElement.renderTypeWorld, ImmutableList.of(Sheets.signSheet()), true)) + it.add(State(AtlasMatterySprite.renderTypeDepth, ImmutableList.of(RenderType.waterMask()), true)) + it.add(State(AtlasMatterySprite.renderTypeNoDepth, ImmutableList.of(RenderType.waterMask()), true)) + it.add(State(AtlasMatterySprite.renderTypeWorld, ImmutableList.of(Sheets.signSheet()), true)) } private fun determineHeight(input: State, seen: MutableSet) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElement.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt similarity index 60% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElement.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt index b590d5b72..afd08f149 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElement.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt @@ -1,21 +1,6 @@ package ru.dbotthepony.mc.otm.client.render -import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonDeserializer -import com.google.gson.JsonElement -import com.google.gson.JsonObject -import com.google.gson.JsonPrimitive -import com.google.gson.JsonSerializationContext -import com.google.gson.JsonSerializer -import com.google.gson.JsonSyntaxException -import com.google.gson.TypeAdapter -import com.google.gson.internal.bind.TypeAdapters -import com.google.gson.stream.JsonReader -import com.google.gson.stream.JsonWriter -import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation -import ru.dbotthepony.mc.otm.core.set -import java.lang.reflect.Type fun ResourceLocation.element( x: Float, @@ -24,14 +9,14 @@ fun ResourceLocation.element( height: Float, textureWidth: Float = 256f, textureHeight: Float = 256f -) = SkinElement(this, x, y, width, height, textureWidth, textureHeight) +) = MatterySprite(this, x, y, width, height, textureWidth, textureHeight) fun ResourceLocation.pixel( x: Float, y: Float, textureWidth: Float = 256f, textureHeight: Float = 256f -) = SkinElement(this, x, y, 1f, 1f, textureWidth, textureHeight) +) = MatterySprite(this, x, y, 1f, 1f, textureWidth, textureHeight) fun ResourceLocation.hLine( x: Float, @@ -39,7 +24,7 @@ fun ResourceLocation.hLine( width: Float, textureWidth: Float = 256f, textureHeight: Float = 256f -) = SkinElement(this, x, y, width, 1f, textureWidth, textureHeight) +) = MatterySprite(this, x, y, width, 1f, textureWidth, textureHeight) fun ResourceLocation.vLine( x: Float, @@ -47,10 +32,10 @@ fun ResourceLocation.vLine( height: Float, textureWidth: Float = 256f, textureHeight: Float = 256f -) = SkinElement(this, x, y, 1f, height, textureWidth, textureHeight) +) = MatterySprite(this, x, y, 1f, height, textureWidth, textureHeight) @Suppress("unused") -data class SkinElement @JvmOverloads constructor( +data class MatterySprite @JvmOverloads constructor( override val texture: ResourceLocation, val x: Float, val y: Float, @@ -59,7 +44,7 @@ data class SkinElement @JvmOverloads constructor( val imageWidth: Float = 256f, val imageHeight: Float = 256f, override val winding: UVWindingOrder = UVWindingOrder.NORMAL, -) : AbstractSkinElement() { +) : AbstractMatterySprite() { init { require(x >= 0f) { "Invalid x $x" } require(y >= 0f) { "Invalid y $y" } @@ -67,6 +52,9 @@ data class SkinElement @JvmOverloads constructor( require(height > 0f) { "Invalid height $height" } require(imageWidth > 0f) { "Invalid image width $imageWidth" } require(imageHeight > 0f) { "Invalid image height $imageHeight" } + + require(width <= imageWidth) { "$width <= $imageWidth" } + require(height <= imageHeight) { "$height <= $imageHeight" } } override val u0 = this.x / imageWidth diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt index 02abfc9ee..c80ea1ee3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt @@ -4,37 +4,37 @@ import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.OverdriveThatMatters object ResearchIcons { - val ICON_TRANSFER: AbstractSkinElement - val ICON_ATTACK_BOOST: AbstractSkinElement - val ICON_PLASMA_SHIELD_BOOST: AbstractSkinElement - val ICON_CLOAK: AbstractSkinElement - val ICON_GRAVITATIONAL_STABILIZER: AbstractSkinElement - val ICON_AIR_BAGS: AbstractSkinElement - val ICON_JUMP_BOOST: AbstractSkinElement + val ICON_TRANSFER: AbstractMatterySprite + val ICON_ATTACK_BOOST: AbstractMatterySprite + val ICON_PLASMA_SHIELD_BOOST: AbstractMatterySprite + val ICON_CLOAK: AbstractMatterySprite + val ICON_GRAVITATIONAL_STABILIZER: AbstractMatterySprite + val ICON_AIR_BAGS: AbstractMatterySprite + val ICON_JUMP_BOOST: AbstractMatterySprite - val ICON_FEATHER_FALLING: AbstractSkinElement - val ICON_ITEM_MAGNET: AbstractSkinElement - val ICON_ARROW: AbstractSkinElement - val ICON_ARMOR: AbstractSkinElement - val ICON_NANOBOTS: AbstractSkinElement - val ICON_NIGHT_VISION: AbstractSkinElement - val ICON_OXYGEN_SUPPLY: AbstractSkinElement + val ICON_FEATHER_FALLING: AbstractMatterySprite + val ICON_ITEM_MAGNET: AbstractMatterySprite + val ICON_ARROW: AbstractMatterySprite + val ICON_ARMOR: AbstractMatterySprite + val ICON_NANOBOTS: AbstractMatterySprite + val ICON_NIGHT_VISION: AbstractMatterySprite + val ICON_OXYGEN_SUPPLY: AbstractMatterySprite - val ICON_PLASMA_SHIELD: AbstractSkinElement - val ICON_SHOCKWAVE: AbstractSkinElement - val ICON_LIMB_OVERCLOCKING: AbstractSkinElement - val ICON_STEP_ASSIST: AbstractSkinElement - val ICON_ENDER_TELEPORT: AbstractSkinElement - val ICON_WIRELESS_CHARGING: AbstractSkinElement - val ICON_UNKNOWN: AbstractSkinElement + val ICON_PLASMA_SHIELD: AbstractMatterySprite + val ICON_SHOCKWAVE: AbstractMatterySprite + val ICON_LIMB_OVERCLOCKING: AbstractMatterySprite + val ICON_STEP_ASSIST: AbstractMatterySprite + val ICON_ENDER_TELEPORT: AbstractMatterySprite + val ICON_WIRELESS_CHARGING: AbstractMatterySprite + val ICON_UNKNOWN: AbstractMatterySprite - val ICON_EXTENDED_REACH: AbstractSkinElement - val ICON_PHANTOM_ATTRACTOR: AbstractSkinElement + val ICON_EXTENDED_REACH: AbstractMatterySprite + val ICON_PHANTOM_ATTRACTOR: AbstractMatterySprite val KOT = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/block/ph_kitty.png").element(0f, 0f, 32f, 32f, 32f, 32f) init { - val grid = SubSkinGrid(AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "android_upgrades"), 126f, 126f), 18f, 18f, 7, 7) + val grid = SubSkinGrid(AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "android_upgrades"), 126f, 126f), 18f, 18f, 7, 7) ICON_TRANSFER = grid.next() ICON_ATTACK_BOOST = grid.next() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElementType.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElementType.kt index e8af0c1a5..6a729cf7c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElementType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElementType.kt @@ -9,8 +9,8 @@ import ru.dbotthepony.mc.otm.core.set enum class SkinElementType { SINGLE { - override fun toJson(value: AbstractSkinElement): JsonObject { - require(value is SkinElement) { "Invalid skin element provided, expected SkinElement, got ${value::class.qualifiedName}" } + override fun toJson(value: AbstractMatterySprite): JsonObject { + require(value is MatterySprite) { "Invalid skin element provided, expected SkinElement, got ${value::class.qualifiedName}" } return JsonObject().also { it["texture"] = JsonPrimitive(value.texture.toString()) @@ -24,8 +24,8 @@ enum class SkinElementType { } } - override fun toNetwork(value: AbstractSkinElement, buff: FriendlyByteBuf) { - require(value is SkinElement) { "Invalid skin element provided, expected SkinElement, got ${value::class.qualifiedName}" } + override fun toNetwork(value: AbstractMatterySprite, buff: FriendlyByteBuf) { + require(value is MatterySprite) { "Invalid skin element provided, expected SkinElement, got ${value::class.qualifiedName}" } buff.writeUtf(value.texture.toString()) buff.writeFloat(value.x) @@ -37,7 +37,7 @@ enum class SkinElementType { buff.writeEnum(value.winding) } - override fun fromNetwork(buff: FriendlyByteBuf): AbstractSkinElement { + override fun fromNetwork(buff: FriendlyByteBuf): AbstractMatterySprite { val texture = ResourceLocation(buff.readUtf()) val x = buff.readFloat() val y = buff.readFloat() @@ -47,10 +47,10 @@ enum class SkinElementType { val imageHeight = buff.readFloat() val winding = buff.readEnum(UVWindingOrder::class.java) - return SkinElement(texture, x, y, width, height, imageWidth, imageHeight, winding) + return MatterySprite(texture, x, y, width, height, imageWidth, imageHeight, winding) } - override fun fromJson(element: JsonObject): AbstractSkinElement { + override fun fromJson(element: JsonObject): AbstractMatterySprite { val texture = element["texture"]?.asString ?: throw JsonSyntaxException("Missing texture element") val x = element["x"]?.asFloat ?: throw JsonSyntaxException("Missing x element") val y = element["y"]?.asFloat ?: throw JsonSyntaxException("Missing y element") @@ -60,12 +60,12 @@ enum class SkinElementType { val imageHeight = element["imageHeight"]?.asFloat ?: throw JsonSyntaxException("Missing imageHeight element") val winding = element["winding"]?.asString ?: throw JsonSyntaxException("Missing winding element") - return SkinElement(ResourceLocation.tryParse(texture) ?: throw JsonSyntaxException("Invalid resource location: $texture"), x, y, width, height, imageWidth, imageHeight, UVWindingOrder.valueOf(winding)) + return MatterySprite(ResourceLocation.tryParse(texture) ?: throw JsonSyntaxException("Invalid resource location: $texture"), x, y, width, height, imageWidth, imageHeight, UVWindingOrder.valueOf(winding)) } }, ATLAS { - override fun toJson(value: AbstractSkinElement): JsonObject { - require(value is AtlasSkinElement) { "Invalid skin element provided, expected AtlasSkinElement, got ${value::class.qualifiedName}" } + override fun toJson(value: AbstractMatterySprite): JsonObject { + require(value is AtlasMatterySprite) { "Invalid skin element provided, expected AtlasSkinElement, got ${value::class.qualifiedName}" } return JsonObject().also { it["location"] = JsonPrimitive(value.location.toString()) @@ -74,33 +74,33 @@ enum class SkinElementType { } } - override fun toNetwork(value: AbstractSkinElement, buff: FriendlyByteBuf) { - require(value is AtlasSkinElement) { "Invalid skin element provided, expected AtlasSkinElement, got ${value::class.qualifiedName}" } + override fun toNetwork(value: AbstractMatterySprite, buff: FriendlyByteBuf) { + require(value is AtlasMatterySprite) { "Invalid skin element provided, expected AtlasSkinElement, got ${value::class.qualifiedName}" } buff.writeResourceLocation(value.location) buff.writeFloat(value.width) buff.writeFloat(value.height) } - override fun fromNetwork(buff: FriendlyByteBuf): AbstractSkinElement { + override fun fromNetwork(buff: FriendlyByteBuf): AbstractMatterySprite { val location = ResourceLocation(buff.readUtf()) val width = buff.readFloat() val height = buff.readFloat() - return AtlasSkinElement(location, width, height) + return AtlasMatterySprite(location, width, height) } - override fun fromJson(element: JsonObject): AbstractSkinElement { + override fun fromJson(element: JsonObject): AbstractMatterySprite { val location = element["location"]?.asString ?: throw JsonSyntaxException("Missing location element") val width = element["width"]?.asFloat ?: throw JsonSyntaxException("Missing width element") val height = element["height"]?.asFloat ?: throw JsonSyntaxException("Missing height element") - return AtlasSkinElement(ResourceLocation.tryParse(location) ?: throw JsonSyntaxException("Invalid resource location: $location"), width, height) + return AtlasMatterySprite(ResourceLocation.tryParse(location) ?: throw JsonSyntaxException("Invalid resource location: $location"), width, height) } }, SUBELEMENT { - override fun toJson(value: AbstractSkinElement): JsonObject { - require(value is SubSkinElement) { "Invalid skin element provided, expected SubSkinElement, got ${value::class.qualifiedName}" } + override fun toJson(value: AbstractMatterySprite): JsonObject { + require(value is SubMatterySprite) { "Invalid skin element provided, expected SubSkinElement, got ${value::class.qualifiedName}" } return JsonObject().also { it["parent"] = value.parent.toJson() @@ -111,8 +111,8 @@ enum class SkinElementType { } } - override fun toNetwork(value: AbstractSkinElement, buff: FriendlyByteBuf) { - require(value is SubSkinElement) { "Invalid skin element provided, expected SubSkinElement, got ${value::class.qualifiedName}" } + override fun toNetwork(value: AbstractMatterySprite, buff: FriendlyByteBuf) { + require(value is SubMatterySprite) { "Invalid skin element provided, expected SubSkinElement, got ${value::class.qualifiedName}" } value.parent.toNetwork(buff) buff.writeFloat(value.xOffset) @@ -121,50 +121,50 @@ enum class SkinElementType { buff.writeFloat(value.height) } - override fun fromNetwork(buff: FriendlyByteBuf): AbstractSkinElement { + override fun fromNetwork(buff: FriendlyByteBuf): AbstractMatterySprite { val parent = Companion.fromNetwork(buff) val xOffset = buff.readFloat() val yOffset = buff.readFloat() val subWidth = buff.readFloat() val subHeight = buff.readFloat() - return SubSkinElement(parent, xOffset, yOffset, subWidth, subHeight) + return SubMatterySprite(parent, xOffset, yOffset, subWidth, subHeight) } - override fun fromJson(element: JsonObject): AbstractSkinElement { + override fun fromJson(element: JsonObject): AbstractMatterySprite { val parent = element["parent"] as? JsonObject ?: throw JsonSyntaxException("Invalid parent") val xOffset = element["xOffset"].asFloat val yOffset = element["yOffset"].asFloat val subWidth = element["subWidth"].asFloat val subHeight = element["subHeight"].asFloat - return SubSkinElement(Companion.fromJson(parent), xOffset, yOffset, subWidth, subHeight) + return SubMatterySprite(Companion.fromJson(parent), xOffset, yOffset, subWidth, subHeight) } }; - protected abstract fun toJson(value: AbstractSkinElement): JsonObject - protected abstract fun toNetwork(value: AbstractSkinElement, buff: FriendlyByteBuf) - protected abstract fun fromNetwork(buff: FriendlyByteBuf): AbstractSkinElement - protected abstract fun fromJson(element: JsonObject): AbstractSkinElement + protected abstract fun toJson(value: AbstractMatterySprite): JsonObject + protected abstract fun toNetwork(value: AbstractMatterySprite, buff: FriendlyByteBuf) + protected abstract fun fromNetwork(buff: FriendlyByteBuf): AbstractMatterySprite + protected abstract fun fromJson(element: JsonObject): AbstractMatterySprite - fun toActualJson(value: AbstractSkinElement): JsonObject { + fun toActualJson(value: AbstractMatterySprite): JsonObject { return toJson(value).also { it["type"] = JsonPrimitive(name) } } - fun toActualNetwork(value: AbstractSkinElement, buff: FriendlyByteBuf) { + fun toActualNetwork(value: AbstractMatterySprite, buff: FriendlyByteBuf) { buff.writeEnum(this) toNetwork(value, buff) } companion object { - fun fromNetwork(buff: FriendlyByteBuf): AbstractSkinElement { + fun fromNetwork(buff: FriendlyByteBuf): AbstractMatterySprite { val type = buff.readEnum(SkinElementType::class.java) return type.fromNetwork(buff) } - fun fromJson(element: JsonObject): AbstractSkinElement { + fun fromJson(element: JsonObject): AbstractMatterySprite { val type = SkinElementType.valueOf(element["type"].asString) return type.fromJson(element) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinGrid.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinGrid.kt index ca4e96896..7861590dd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinGrid.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinGrid.kt @@ -35,8 +35,8 @@ data class SkinGrid( return this } - fun next(): SkinElement { - val element = SkinElement(texture, currentX, currentY, width, height, imageWidth, imageHeight) + fun next(): MatterySprite { + val element = MatterySprite(texture, currentX, currentY, width, height, imageWidth, imageHeight) skip() return element } @@ -54,5 +54,5 @@ data class SkinGrid( } operator fun get(column: Int, row: Int) = - SkinElement(texture, column * width, row * height, width, height, imageWidth, imageHeight) + MatterySprite(texture, column * width, row * height, width, height, imageWidth, imageHeight) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/StretchingRectangleElement.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/StretchingRectangleElement.kt index 8fe0010fb..4af924f63 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/StretchingRectangleElement.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/StretchingRectangleElement.kt @@ -5,15 +5,15 @@ import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty data class StretchingRectangleElement( - val topLeft: AbstractSkinElement, - val topRight: AbstractSkinElement, - val bottomLeft: AbstractSkinElement, - val bottomRight: AbstractSkinElement, - val left: AbstractSkinElement, - val right: AbstractSkinElement, - val top: AbstractSkinElement, - val bottom: AbstractSkinElement, - val middle: AbstractSkinElement, + val topLeft: AbstractMatterySprite, + val topRight: AbstractMatterySprite, + val bottomLeft: AbstractMatterySprite, + val bottomRight: AbstractMatterySprite, + val left: AbstractMatterySprite, + val right: AbstractMatterySprite, + val top: AbstractMatterySprite, + val bottom: AbstractMatterySprite, + val middle: AbstractMatterySprite, val padding: DockProperty = DockProperty.EMPTY ) { fun render( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubSkinElement.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubMatterySprite.kt similarity index 80% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubSkinElement.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubMatterySprite.kt index 61dc54c57..196317389 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubSkinElement.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubMatterySprite.kt @@ -2,14 +2,14 @@ package ru.dbotthepony.mc.otm.client.render import net.minecraft.resources.ResourceLocation -class SubSkinElement( - val parent: AbstractSkinElement, +class SubMatterySprite( + val parent: AbstractMatterySprite, val xOffset: Float = 0f, val yOffset: Float = 0f, override val width: Float = parent.width, override val height: Float = parent.height, private val overrideWinding: UVWindingOrder? = null -) : AbstractSkinElement.Mutable() { +) : AbstractMatterySprite.Mutable() { override var u0: Float = 0f private set override var v0: Float = 0f @@ -28,7 +28,7 @@ class SubSkinElement( notifyListeners() } - override fun parentChanges(parent: AbstractSkinElement) = calculateUVs() + override fun parentChanges(parent: AbstractMatterySprite) = calculateUVs() init { parent.addListener(this) @@ -53,12 +53,12 @@ class SubSkinElement( width: Float = this.width, height: Float = this.height, overrideWinding: UVWindingOrder? = this.overrideWinding - ) = SubSkinElement(parent, xOffset, yOffset, width, height, overrideWinding) + ) = SubMatterySprite(parent, xOffset, yOffset, width, height, overrideWinding) } -fun AbstractSkinElement.subElement( +fun AbstractMatterySprite.subElement( x: Float = 0f, y: Float = 0f, width: Float = this.width, height: Float = this.height, -) = SubSkinElement(this, x, y, width, height) +) = SubMatterySprite(this, x, y, width, height) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubSkinGrid.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubSkinGrid.kt index 65cabcfec..ea740df7d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubSkinGrid.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubSkinGrid.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.client.render @Suppress("unused") data class SubSkinGrid( - val parent: AbstractSkinElement, + val parent: AbstractMatterySprite, val width: Float, val height: Float, val columns: Int = 16, @@ -30,7 +30,7 @@ data class SubSkinGrid( return this } - fun next(): AbstractSkinElement { + fun next(): AbstractMatterySprite { val element = parent.subElement(currentX, currentY, width, height) skip() return element @@ -52,7 +52,7 @@ data class SubSkinGrid( parent.subElement(column * width, row * height, width, height) } -fun AbstractSkinElement.subGrid( +fun AbstractMatterySprite.subGrid( width: Float, height: Float, columns: Int = 16, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetAtlasHolder.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetAtlasHolder.kt deleted file mode 100644 index 9825bcc07..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetAtlasHolder.kt +++ /dev/null @@ -1,99 +0,0 @@ -package ru.dbotthepony.mc.otm.client.render - -import net.minecraft.client.renderer.texture.TextureAtlas -import net.minecraft.client.renderer.texture.TextureAtlasSprite -import net.minecraft.client.renderer.texture.TextureManager -import net.minecraft.client.resources.TextureAtlasHolder -import net.minecraft.resources.ResourceLocation -import net.minecraft.server.packs.resources.ResourceManager -import net.minecraft.util.profiling.ProfilerFiller -import net.minecraftforge.client.event.RegisterClientReloadListenersEvent -import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.isClientThread -import ru.dbotthepony.mc.otm.core.WriteOnce -import java.util.stream.Stream -import kotlin.properties.Delegates - -var isWidgetAtlasAvailable: Boolean = false - private set - -class WidgetAtlasHolder private constructor(manager: TextureManager) : TextureAtlasHolder(manager, LOCATION, INFO_LOCATION) { - var changeset = 0 - private set - - var once = false - private set - var demandsRebuild = false - private set - - private var resourceManager by Delegates.notNull() - private var profileManager by Delegates.notNull() - - override fun prepare(p_118891_: ResourceManager, p_118892_: ProfilerFiller): TextureAtlas.Preparations { - resourceManager = p_118891_ - profileManager = p_118892_ - changeset++ - return super.prepare(p_118891_, p_118892_) - } - - override fun apply(p_118894_: TextureAtlas.Preparations, p_118895_: ResourceManager, p_118896_: ProfilerFiller) { - once = true - resourceManager = p_118895_ - profileManager = p_118896_ - changeset++ - super.apply(p_118894_, p_118895_, p_118896_) - AtlasSkinElement.notifyListeners() - } - - fun rebuildIfRequired(): Boolean { - if (once && demandsRebuild && isClientThread()) { - apply(prepare(resourceManager, profileManager), resourceManager, profileManager) - } - - return demandsRebuild - } - - public override fun getSprite(p_118902_: ResourceLocation): TextureAtlasSprite { - if (!once) { - throw IllegalStateException("Trying to get sprite too early") - } - - return super.getSprite(p_118902_) - } - - fun queueRebuild() { - demandsRebuild = true - } - - override fun getResourcesToLoad(): Stream { - demandsRebuild = false - return AtlasSkinElement.keysStream - } - - companion object { - @JvmStatic - val LOCATION = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/atlas/gui.png") - - @JvmStatic - val INFO_LOCATION = ResourceLocation(OverdriveThatMatters.MOD_ID, "fuck/you/mojang") - - @JvmStatic - var INSTANCE: WidgetAtlasHolder by WriteOnce() - private set - - @JvmStatic - fun register(event: RegisterClientReloadListenersEvent) { - INSTANCE = WidgetAtlasHolder(minecraft.textureManager) - event.registerReloadListener(INSTANCE) - isWidgetAtlasAvailable = true - } - - @JvmStatic - fun renderGameHook() { - if (isWidgetAtlasAvailable) { - INSTANCE.rebuildIfRequired() - } - } - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt index 85b3a3bb3..813924b33 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt @@ -6,11 +6,11 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters object WidgetLocation { val WIDGETS_18 = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets_18.png") - val MISC = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/misc"), 64f, 64f) - val PATTERN_PANEL_TABS = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/pattern_panel_tabs"), 64f, 32f) + val MISC = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/misc"), 64f, 64f) + val PATTERN_PANEL_TABS = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/pattern_panel_tabs"), 64f, 32f) - val CHECKBOX = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/checkbox"), 32f, 64f) - val PROGRESS_ARROWS = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/progress_arrows"), 32f, 32f) - val HORIZONTAL_GAUGES = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/horizontal_gauges"), 128f, 64f) - val VERTICAL_GAUGES = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/vertical_gauges"), 128f, 48f) + val CHECKBOX = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/checkbox"), 32f, 64f) + val PROGRESS_ARROWS = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/progress_arrows"), 32f, 32f) + val HORIZONTAL_GAUGES = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/horizontal_gauges"), 128f, 64f) + val VERTICAL_GAUGES = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/vertical_gauges"), 128f, 48f) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt index 4b39a9136..0a631c678 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt @@ -4,7 +4,7 @@ import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.OverdriveThatMatters object Widgets8 { - val GRID = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets_8"), 64f, 32f).subGrid(8f, 8f, 64 / 8, 32 / 8) + val GRID = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets_8"), 64f, 32f).subGrid(8f, 8f, 64 / 8, 32 / 8) val BUTTON_IDLE = GRID[0, 0] val BUTTON_HOVERED = GRID[0, 1] diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt index 038fe9ec9..716a5c5ce 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt @@ -9,8 +9,7 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.BatteryBankBlockEntity import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterCapacitorBankBlockEntity -import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement -import ru.dbotthepony.mc.otm.client.render.AtlasSkinElement +import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel @@ -20,7 +19,7 @@ import kotlin.math.PI abstract class BankRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer { protected abstract fun gaugeLevel(entity: T): Float - protected abstract val texture: AbstractSkinElement + protected abstract val texture: AbstractMatterySprite override fun render( blockEntity: T, @@ -53,7 +52,7 @@ abstract class BankRenderer(private val context: BlockEn val width = 9f val heightMax = 39.36f - val buffer = DynamicBufferSource.WORLD.getBuffer(AtlasSkinElement.renderTypeWorld) + val buffer = DynamicBufferSource.WORLD.getBuffer(AtlasMatterySprite.renderTypeWorld) texture.uploadOntoPartialColor( stack, @@ -85,7 +84,7 @@ class BatteryBankRenderer(context: BlockEntityRendererProvider.Context) : BankRe return entity.gaugeLevel } - override val texture: AbstractSkinElement + override val texture: AbstractMatterySprite get() = PowerGaugePanel.GAUGE_FOREGROUND } @@ -94,7 +93,7 @@ class MatterBatteryBankRenderer(context: BlockEntityRendererProvider.Context) : return entity.gaugeLevel } - override val texture: AbstractSkinElement + override val texture: AbstractMatterySprite get() = MatterGaugePanel.GAUGE_FOREGROUND } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/AbstractSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/AbstractSlotPanel.kt index d7bcb2480..8c07d8624 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/AbstractSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/AbstractSlotPanel.kt @@ -19,7 +19,7 @@ abstract class AbstractSlotPanel> @JvmOverloads constru y: Float = 0f, width: Float = SIZE, height: Float = SIZE, - open val noItemIcon: SkinElement? = null + open val noItemIcon: MatterySprite? = null ) : EditablePanel(screen, parent, x, y, width, height), IItemStackPanel { protected open fun renderSlotBackground(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { SLOT_BACKGROUND.render(stack, width = width, height = height) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index 25f731094..fc9688dd9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -25,8 +25,8 @@ open class FramePanel( open inner class Tab( var onOpen: Runnable? = null, var onClose: Runnable? = null, - var activeIcon: AbstractSkinElement? = null, - var inactiveIcon: AbstractSkinElement? = null, + var activeIcon: AbstractMatterySprite? = null, + var inactiveIcon: AbstractMatterySprite? = null, ) : EditablePanel(this@FramePanel.screen, this@FramePanel, 0f, 0f, 28f, 28f) { var isActive = tabs.isEmpty() var initial = false diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/HeightControls.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/HeightControls.kt index 4ebe6a900..68013d638 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/HeightControls.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/HeightControls.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels import com.mojang.blaze3d.platform.InputConstants import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement +import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.Widgets import ru.dbotthepony.mc.otm.client.screen.panels.buttons.RectangleButtonPanel @@ -45,10 +45,10 @@ open class HeightControls( } open inner class Control(val isIncrease: Boolean) : RectangleButtonPanel(screen, this@HeightControls, width = BUTTON_WIDTH, height = BUTTON_HEIGHT) { - override val PRESSED: AbstractSkinElement = if (isIncrease) Widgets.ARROW_DOWN_BUTTON_PRESSED else Widgets.ARROW_UP_BUTTON_PRESSED - override val HOVERED: AbstractSkinElement = if (isIncrease) Widgets.ARROW_DOWN_BUTTON_HOVERED else Widgets.ARROW_UP_BUTTON_HOVERED - override val IDLE: AbstractSkinElement = if (isIncrease) Widgets.ARROW_DOWN_BUTTON_IDLE else Widgets.ARROW_UP_BUTTON_IDLE - override val DISABLED: AbstractSkinElement = if (isIncrease) Widgets.ARROW_DOWN_BUTTON_DISABLED else Widgets.ARROW_UP_BUTTON_DISABLED + override val PRESSED: AbstractMatterySprite = if (isIncrease) Widgets.ARROW_DOWN_BUTTON_PRESSED else Widgets.ARROW_UP_BUTTON_PRESSED + override val HOVERED: AbstractMatterySprite = if (isIncrease) Widgets.ARROW_DOWN_BUTTON_HOVERED else Widgets.ARROW_UP_BUTTON_HOVERED + override val IDLE: AbstractMatterySprite = if (isIncrease) Widgets.ARROW_DOWN_BUTTON_IDLE else Widgets.ARROW_UP_BUTTON_IDLE + override val DISABLED: AbstractMatterySprite = if (isIncrease) Widgets.ARROW_DOWN_BUTTON_DISABLED else Widgets.ARROW_UP_BUTTON_DISABLED init { dock = Dock.TOP diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ScrollBarConstants.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ScrollBarConstants.kt index ab67f2dca..46242cf9c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ScrollBarConstants.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ScrollBarConstants.kt @@ -2,34 +2,30 @@ package ru.dbotthepony.mc.otm.client.screen.panels import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement -import ru.dbotthepony.mc.otm.client.render.AtlasSkinElement -import ru.dbotthepony.mc.otm.client.render.WidgetLocation -import ru.dbotthepony.mc.otm.client.render.element import ru.dbotthepony.mc.otm.client.render.subElement object ScrollBarConstants { const val WIDTH = 14f const val SLIM_WIDTH = 8f - val BACKGROUND = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/background"), 14f, 8f) - val BACKGROUND_SLIM = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/background"), 8f, 8f) + val BACKGROUND = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/background"), 14f, 8f) + val BACKGROUND_SLIM = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/background"), 8f, 8f) val TOP = BACKGROUND.subElement(height = 2f) val BODY = BACKGROUND.subElement(y = 2f, height = 5f) val BOTTOM = BACKGROUND.subElement(y = 6f, height = 2f) - val BUTTON = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/idle"), 12f, 15f) - val BUTTON_HOVER = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/hovered"), 12f, 15f) - val BUTTON_PRESS = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/pressed"), 12f, 15f) - val BUTTON_DISABLED = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/disabled"), 12f, 15f) + val BUTTON = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/idle"), 12f, 15f) + val BUTTON_HOVER = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/hovered"), 12f, 15f) + val BUTTON_PRESS = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/pressed"), 12f, 15f) + val BUTTON_DISABLED = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/disabled"), 12f, 15f) val SLIM_TOP = BACKGROUND_SLIM.subElement(height = 2f) val SLIM_BODY = BACKGROUND_SLIM.subElement(y = 2f, height = 5f) val SLIM_BOTTOM = BACKGROUND_SLIM.subElement(y = 6f, height = 2f) - val SLIM_BUTTON = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/idle"), 6f, 15f) - val SLIM_BUTTON_HOVER = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/hovered"), 6f, 15f) - val SLIM_BUTTON_PRESS = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/pressed"), 6f, 15f) - val SLIM_BUTTON_DISABLED = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/disabled"), 6f, 15f) + val SLIM_BUTTON = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/idle"), 6f, 15f) + val SLIM_BUTTON_HOVER = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/hovered"), 6f, 15f) + val SLIM_BUTTON_PRESS = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/pressed"), 6f, 15f) + val SLIM_BUTTON_DISABLED = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/disabled"), 6f, 15f) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SlotPanel.kt index f2d037a88..f411c6a7d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SlotPanel.kt @@ -6,13 +6,12 @@ import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.ChatFormatting import net.minecraft.client.gui.GuiComponent -import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen import net.minecraft.client.renderer.GameRenderer import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.client.render.SkinElement +import ru.dbotthepony.mc.otm.client.render.MatterySprite import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.render.drawRect import ru.dbotthepony.mc.otm.client.render.setDrawColor @@ -28,7 +27,7 @@ open class SlotPanel, out T : Slot> @JvmOverloads const y: Float = 0f, width: Float = SIZE, height: Float = SIZE, - noItemIcon: SkinElement? = null + noItemIcon: MatterySprite? = null ) : AbstractSlotPanel(screen, parent, x, y, width, height, noItemIcon), ISlotPanel { override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { screen.returnSlot = slot diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/BooleanRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/BooleanRectangleButtonPanel.kt index 3fa9707d0..11da9ffe8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/BooleanRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/BooleanRectangleButtonPanel.kt @@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.buttons import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement +import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.value @@ -16,8 +16,8 @@ abstract class BooleanRectangleButtonPanel( width: Float, height: Float, val prop: GetterSetter, - val skinElementActive: AbstractSkinElement? = null, - val skinElementInactive: AbstractSkinElement? = null, + val skinElementActive: AbstractMatterySprite? = null, + val skinElementInactive: AbstractMatterySprite? = null, val onChange: ((newValue: Boolean) -> Unit)? = null, ) : RectangleButtonPanel(screen, parent, x, y, width, height, null) { override fun onClick(clickButton: Int) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxPanel.kt index 084ee8479..6db631948 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxPanel.kt @@ -4,7 +4,7 @@ import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.playGuiClickSound -import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement +import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.render.subGrid import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel @@ -81,14 +81,14 @@ open class CheckBoxPanel @JvmOverloads constructor( companion object { const val REGULAR_DIMENSIONS = 15f - val IDLE_UNCHECKED: AbstractSkinElement - val IDLE_CHECKED: AbstractSkinElement - val HOVERED_UNCHECKED: AbstractSkinElement - val HOVERED_CHECKED: AbstractSkinElement - val PRESSED_UNCHECKED: AbstractSkinElement - val PRESSED_CHECKED: AbstractSkinElement - val DISABLED_UNCHECKED: AbstractSkinElement - val DISABLED_CHECKED: AbstractSkinElement + val IDLE_UNCHECKED: AbstractMatterySprite + val IDLE_CHECKED: AbstractMatterySprite + val HOVERED_UNCHECKED: AbstractMatterySprite + val HOVERED_CHECKED: AbstractMatterySprite + val PRESSED_UNCHECKED: AbstractMatterySprite + val PRESSED_CHECKED: AbstractMatterySprite + val DISABLED_UNCHECKED: AbstractMatterySprite + val DISABLED_CHECKED: AbstractMatterySprite init { val grid = WidgetLocation.CHECKBOX.subGrid(REGULAR_DIMENSIONS, REGULAR_DIMENSIONS, 2, 4) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/EnumRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/EnumRectangleButtonPanel.kt index 3649a5e45..840cb3d85 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/EnumRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/EnumRectangleButtonPanel.kt @@ -5,7 +5,7 @@ import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.ChatFormatting import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component -import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement +import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.GetterSetter @@ -30,7 +30,7 @@ abstract class EnumRectangleButtonPanel>( ) : RectangleButtonPanel(screen, parent, x, y, width, height, null) { private var building = true - protected val enumMapping = EnumMap>(enum) + protected val enumMapping = EnumMap>(enum) protected val tooltipMapping = EnumMap(enum) fun addTooltip(value: T, component: Component): EnumRectangleButtonPanel { @@ -69,19 +69,19 @@ abstract class EnumRectangleButtonPanel>( return missing } - fun add(value: T, skinElement: AbstractSkinElement, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumRectangleButtonPanel { + fun add(value: T, skinElement: AbstractMatterySprite, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumRectangleButtonPanel { return add(value, skinElement to winding) } - fun add(value: T, skinElement: AbstractSkinElement, component: Component, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumRectangleButtonPanel { + fun add(value: T, skinElement: AbstractMatterySprite, component: Component, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumRectangleButtonPanel { return add(value, component, skinElement to winding) } - fun add(value: T, component: Component, skinElement: AbstractSkinElement, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumRectangleButtonPanel { + fun add(value: T, component: Component, skinElement: AbstractMatterySprite, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumRectangleButtonPanel { return add(value, component, skinElement to winding) } - fun add(value: T, pair: Pair): EnumRectangleButtonPanel { + fun add(value: T, pair: Pair): EnumRectangleButtonPanel { check(building) { "Not building" } check(enumMapping.put(value, pair) == null) { "Already has mapping for $value" } @@ -92,7 +92,7 @@ abstract class EnumRectangleButtonPanel>( return this } - fun add(value: T, component: Component, pair: Pair): EnumRectangleButtonPanel { + fun add(value: T, component: Component, pair: Pair): EnumRectangleButtonPanel { addTooltip(value, component) return add(value, pair) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/LargeBooleanRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/LargeBooleanRectangleButtonPanel.kt index 506bb2f8d..f541cab21 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/LargeBooleanRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/LargeBooleanRectangleButtonPanel.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.buttons import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement +import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.GetterSetter @@ -14,8 +14,8 @@ open class LargeBooleanRectangleButtonPanel( width: Float = SIZE, height: Float = SIZE, prop: GetterSetter, - skinElementActive: AbstractSkinElement? = null, - skinElementInactive: AbstractSkinElement? = null, + skinElementActive: AbstractMatterySprite? = null, + skinElementInactive: AbstractMatterySprite? = null, onChange: ((newValue: Boolean) -> Unit)? = null, ) : BooleanRectangleButtonPanel(screen, parent, x, y, width, height, prop, skinElementActive, skinElementInactive, onChange) { final override val IDLE = Widgets18.BUTTON_IDLE diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/LargeRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/LargeRectangleButtonPanel.kt index 4ebf8e9d9..f18cfc5ab 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/LargeRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/LargeRectangleButtonPanel.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.buttons import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement +import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel @@ -15,7 +15,7 @@ open class LargeRectangleButtonPanel( width: Float = SIZE, height: Float = SIZE, onPress: ((clickButton: Int) -> Unit)? = null, - val skinElement: AbstractSkinElement? = null, + val skinElement: AbstractMatterySprite? = null, val skinElementWinding: UVWindingOrder? = null, ) : RectangleButtonPanel(screen, parent, x, y, width, height, onPress) { final override val IDLE = Widgets18.BUTTON_IDLE diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/RectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/RectangleButtonPanel.kt index fe808675d..91f7bde54 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/RectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/RectangleButtonPanel.kt @@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.buttons import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.playGuiClickSound -import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement +import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel @Suppress("PropertyName") @@ -22,10 +22,10 @@ abstract class RectangleButtonPanel( onPress?.invoke(clickButton) } - abstract val PRESSED: AbstractSkinElement - abstract val HOVERED: AbstractSkinElement - abstract val IDLE: AbstractSkinElement - abstract val DISABLED: AbstractSkinElement + abstract val PRESSED: AbstractMatterySprite + abstract val HOVERED: AbstractMatterySprite + abstract val IDLE: AbstractMatterySprite + abstract val DISABLED: AbstractMatterySprite var isDisabled = false set(value) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/SmallBooleanRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/SmallBooleanRectangleButtonPanel.kt index 60babbc23..f255df62d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/SmallBooleanRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/SmallBooleanRectangleButtonPanel.kt @@ -13,8 +13,8 @@ open class SmallBooleanRectangleButtonPanel( width: Float = SIZE, height: Float = SIZE, prop: GetterSetter, - skinElementActive: AbstractSkinElement? = null, - skinElementInactive: AbstractSkinElement? = null, + skinElementActive: AbstractMatterySprite? = null, + skinElementInactive: AbstractMatterySprite? = null, onChange: ((newValue: Boolean) -> Unit)? = null, ) : BooleanRectangleButtonPanel(screen, parent, x, y, width, height, prop, skinElementActive, skinElementInactive, onChange) { final override val IDLE = Widgets8.BUTTON_IDLE diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/SmallRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/SmallRectangleButtonPanel.kt index 55db58e60..82a504e70 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/SmallRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/SmallRectangleButtonPanel.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.buttons import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.render.SkinElement +import ru.dbotthepony.mc.otm.client.render.MatterySprite import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.Widgets8 import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel @@ -15,7 +15,7 @@ open class SmallRectangleButtonPanel( width: Float = SIZE, height: Float = SIZE, onPress: ((clickButton: Int) -> Unit)? = null, - val skinElement: SkinElement? = null, + val skinElement: MatterySprite? = null, val skinElementWinding: UVWindingOrder? = null, ) : RectangleButtonPanel(screen, parent, x, y, width, height, onPress) { final override val IDLE = Widgets8.BUTTON_IDLE diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt index f3f98b207..ced32ebc1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt @@ -17,7 +17,7 @@ import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack import net.minecraftforge.fml.ModList import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.client.render.SkinElement +import ru.dbotthepony.mc.otm.client.render.MatterySprite import ru.dbotthepony.mc.otm.client.render.element import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.buttons.RectangleButtonPanel @@ -149,13 +149,13 @@ class CosmeticToggleButton( width: Float = 5f, height: Float = 5f ) : RectangleButtonPanel(screen, parent, x, y, width, height) { - override val PRESSED: SkinElement + override val PRESSED: MatterySprite get() = BUTTON_ACTIVE - override val HOVERED: SkinElement + override val HOVERED: MatterySprite get() = BUTTON_ACTIVE - override val IDLE: SkinElement + override val IDLE: MatterySprite get() = BUTTON_INACTIVE - override val DISABLED: SkinElement + override val DISABLED: MatterySprite get() = BUTTON_INACTIVE private val index = when (index) { @@ -198,13 +198,13 @@ class CosmeticToggleRenderButton( width: Float = 5f, height: Float = 5f ) : RectangleButtonPanel(screen, parent, x, y, width, height) { - override val PRESSED: SkinElement + override val PRESSED: MatterySprite get() = BUTTON_ACTIVE - override val HOVERED: SkinElement + override val HOVERED: MatterySprite get() = BUTTON_ACTIVE - override val IDLE: SkinElement + override val IDLE: MatterySprite get() = BUTTON_INACTIVE - override val DISABLED: SkinElement + override val DISABLED: MatterySprite get() = BUTTON_INACTIVE override fun onClick(clickButton: Int) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/SkinDrawable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/SkinDrawable.kt index 8a7eaf3fd..b6d66e1f8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/SkinDrawable.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/SkinDrawable.kt @@ -2,9 +2,9 @@ package ru.dbotthepony.mc.otm.compat.jei import com.mojang.blaze3d.vertex.PoseStack import mezz.jei.api.gui.drawable.IDrawable -import ru.dbotthepony.mc.otm.client.render.SkinElement +import ru.dbotthepony.mc.otm.client.render.MatterySprite -class SkinDrawable(val element: SkinElement) : IDrawable { +class SkinDrawable(val element: MatterySprite) : IDrawable { override fun getWidth(): Int { return element.width.toInt() } From 5693ca266e68bbe692949dd8f821108911ba8a33 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 13 Jan 2023 16:35:33 +0700 Subject: [PATCH 0013/1199] Mattery atlas, update all atlas assets --- .../dbotthepony/mc/otm/client/MatteryGUI.kt | 2 +- .../client/render/AbstractMatterySprite.kt | 87 ++++++++++++++++++ .../otm/client/render/DynamicBufferSource.kt | 9 +- .../mc/otm/client/render/MatteryAtlas.kt | 24 +++++ .../mc/otm/client/render/MatterySprite.kt | 21 +++-- .../mc/otm/client/render/ResearchIcons.kt | 2 +- .../mc/otm/client/render/SkinElementType.kt | 43 +-------- .../mc/otm/client/render/SkinGrid.kt | 8 +- .../mc/otm/client/render/SubMatterySprite.kt | 33 +------ .../mc/otm/client/render/WidgetLocation.kt | 12 +-- .../mc/otm/client/render/Widgets.kt | 8 +- .../mc/otm/client/render/Widgets18.kt | 18 ++-- .../mc/otm/client/render/Widgets8.kt | 2 +- .../client/render/blockentity/BankRenderer.kt | 2 +- .../screen/panels/ScrollBarConstants.kt | 24 +++-- .../screen/panels/buttons/CheckBoxPanel.kt | 2 +- .../textures/gui/android_upgrades.png | Bin 2792 -> 2551 bytes .../textures/gui/player_bars.png | Bin 348 -> 287 bytes .../textures/gui/widgets/checkbox.png | Bin 838 -> 817 bytes .../gui/widgets/horizontal_gauges.png | Bin 277 -> 326 bytes .../gui/widgets/pattern_panel_tabs.png | Bin 366 -> 481 bytes .../textures/gui/widgets/progress_arrows.png | Bin 275 -> 291 bytes .../textures/gui/widgets/scrollbar.png | Bin 0 -> 330 bytes .../gui/widgets/scrollbar/background.png | Bin 165 -> 0 bytes .../gui/widgets/scrollbar/disabled.png | Bin 367 -> 0 bytes .../gui/widgets/scrollbar/hovered.png | Bin 373 -> 0 bytes .../textures/gui/widgets/scrollbar/idle.png | Bin 371 -> 0 bytes .../gui/widgets/scrollbar/pressed.png | Bin 373 -> 0 bytes .../textures/gui/widgets/scrollbar_slim.png | Bin 0 -> 322 bytes .../gui/widgets/scrollbar_slim/background.png | Bin 357 -> 0 bytes .../gui/widgets/scrollbar_slim/disabled.png | Bin 398 -> 0 bytes .../gui/widgets/scrollbar_slim/hovered.png | Bin 404 -> 0 bytes .../gui/widgets/scrollbar_slim/idle.png | Bin 403 -> 0 bytes .../gui/widgets/scrollbar_slim/pressed.png | Bin 404 -> 0 bytes .../textures/gui/widgets/vertical_gauges.png | Bin 494 -> 887 bytes 35 files changed, 179 insertions(+), 118 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/background.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/disabled.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/hovered.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/idle.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/pressed.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/background.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/disabled.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/hovered.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/idle.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/pressed.png diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index 830d1e3da..a7f6ddbfc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -28,7 +28,7 @@ import java.util.* import kotlin.math.ceil object MatteryGUI { - private val BARS = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "player_bars"), 80f, 36f) + private val BARS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/player_bars.png"), 80f, 35f) val CHARGE = BARS.subElement(height = 9f) val CHARGE_BG = BARS.subElement(y = 9f, height = 9f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt index af06604b7..02435dc3e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt @@ -2,13 +2,20 @@ package ru.dbotthepony.mc.otm.client.render import com.google.gson.JsonObject import com.mojang.blaze3d.systems.RenderSystem +import com.mojang.blaze3d.vertex.DefaultVertexFormat import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.VertexConsumer +import com.mojang.blaze3d.vertex.VertexFormat +import net.minecraft.client.renderer.GameRenderer +import net.minecraft.client.renderer.RenderStateShard +import net.minecraft.client.renderer.RenderType import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation +import org.lwjgl.opengl.GL11.GL_ALWAYS import ru.dbotthepony.mc.otm.core.RGBAColor import ru.dbotthepony.mc.otm.core.linearInterpolation import java.lang.ref.WeakReference +import java.util.concurrent.ConcurrentHashMap sealed class AbstractMatterySprite { /** @@ -305,4 +312,84 @@ sealed class AbstractMatterySprite { fun toNetwork(buff: FriendlyByteBuf) { type.toActualNetwork(this, buff) } + + + val renderTypeNoDepth by lazy { + noDepthCache.computeIfAbsent(texture) { + val builder = RenderType.CompositeState.builder() + + builder.setTextureState(RenderStateShard.TextureStateShard(it, false, false)) + builder.setShaderState(RenderStateShard.ShaderStateShard(GameRenderer::getPositionColorTexShader)) + builder.setDepthTestState(RenderStateShard.DepthTestStateShard("always", GL_ALWAYS)) + builder.setTransparencyState(RenderStateShard.TransparencyStateShard("normal_blend", { + RenderSystem.enableBlend() + RenderSystem.defaultBlendFunc() + }, { + RenderSystem.disableBlend() + })) + + @Suppress("INACCESSIBLE_TYPE") + RenderType.create("otm_gui_element_no_depth", + DefaultVertexFormat.POSITION_COLOR_TEX, + VertexFormat.Mode.QUADS, + 2048, + false, + false, + builder.createCompositeState(false)) as RenderType + } + } + + val renderTypeDepth by lazy { + depthCache.computeIfAbsent(texture) { + val builder = RenderType.CompositeState.builder() + + builder.setTextureState(RenderStateShard.TextureStateShard(it, false, false)) + builder.setShaderState(RenderStateShard.ShaderStateShard(GameRenderer::getPositionColorTexShader)) + builder.setTransparencyState(RenderStateShard.TransparencyStateShard("normal_blend", { + RenderSystem.enableBlend() + RenderSystem.defaultBlendFunc() + }, { + RenderSystem.disableBlend() + })) + + @Suppress("INACCESSIBLE_TYPE") + RenderType.create("otm_gui_element_depth", + DefaultVertexFormat.POSITION_COLOR_TEX, + VertexFormat.Mode.QUADS, + 2048, + false, + false, + builder.createCompositeState(false)) as RenderType + } + } + + val renderTypeWorld by lazy { + worldCache.computeIfAbsent(texture) { + val builder = RenderType.CompositeState.builder() + + builder.setTextureState(RenderStateShard.TextureStateShard(it, false, false)) + builder.setShaderState(RenderStateShard.ShaderStateShard(GameRenderer::getPositionColorTexShader)) + builder.setTransparencyState(RenderStateShard.TransparencyStateShard("normal_blend", { + RenderSystem.enableBlend() + RenderSystem.defaultBlendFunc() + }, { + RenderSystem.disableBlend() + })) + + @Suppress("INACCESSIBLE_TYPE") + RenderType.create("otm_gui_element_world", + DefaultVertexFormat.POSITION_COLOR_TEX, + VertexFormat.Mode.QUADS, + 8192, + false, + false, + builder.createCompositeState(false)) as RenderType + } + } + + companion object { + private val noDepthCache = ConcurrentHashMap() + private val depthCache = ConcurrentHashMap() + private val worldCache = ConcurrentHashMap() + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt index 29c5c343d..0e0cfcf88 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt @@ -143,9 +143,12 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit next = State(RenderType.waterMask(), ImmutableList.of(next.type), true, false) it.add(next) - it.add(State(AtlasMatterySprite.renderTypeDepth, ImmutableList.of(RenderType.waterMask()), true)) - it.add(State(AtlasMatterySprite.renderTypeNoDepth, ImmutableList.of(RenderType.waterMask()), true)) - it.add(State(AtlasMatterySprite.renderTypeWorld, ImmutableList.of(Sheets.signSheet()), true)) + // TODO + // it.add(State(AtlasMatterySprite.renderTypeDepth, ImmutableList.of(RenderType.waterMask()), true)) + // TODO + // it.add(State(AtlasMatterySprite.renderTypeNoDepth, ImmutableList.of(RenderType.waterMask()), true)) + // TODO + // it.add(State(AtlasMatterySprite.renderTypeWorld, ImmutableList.of(Sheets.signSheet()), true)) } private fun determineHeight(input: State, seen: MutableSet) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt new file mode 100644 index 000000000..4a9304fa8 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt @@ -0,0 +1,24 @@ +package ru.dbotthepony.mc.otm.client.render + +import net.minecraft.resources.ResourceLocation + +data class MatteryAtlas( + val texture: ResourceLocation, + val width: Float, + val height: Float, + val winding: UVWindingOrder = UVWindingOrder.NORMAL, +) { + fun subElement( + x: Float = 0f, + y: Float = 0f, + width: Float = this.width, + height: Float = this.height, + winding: UVWindingOrder = this.winding, + ) = MatterySprite(texture, x = x, y = y, width = width, height = height, atlasHeight = this.height, atlasWidth = this.width, winding = winding) + + @Deprecated("Construct grid directly instead") + fun subGrid(rows: Int, columns: Int) = SkinGrid(texture, this.width / rows, this.height / columns, rows = rows, columns = columns) + + @Deprecated("Construct grid directly instead") + fun subGrid(width: Float, height: Float, rows: Int, columns: Int) = SkinGrid(texture, width, height, rows, columns) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt index afd08f149..352afb437 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt @@ -41,8 +41,8 @@ data class MatterySprite @JvmOverloads constructor( val y: Float, override val width: Float, override val height: Float, - val imageWidth: Float = 256f, - val imageHeight: Float = 256f, + val atlasWidth: Float = 256f, + val atlasHeight: Float = 256f, override val winding: UVWindingOrder = UVWindingOrder.NORMAL, ) : AbstractMatterySprite() { init { @@ -50,18 +50,19 @@ data class MatterySprite @JvmOverloads constructor( require(y >= 0f) { "Invalid y $y" } require(width > 0f) { "Invalid width $width" } require(height > 0f) { "Invalid height $height" } - require(imageWidth > 0f) { "Invalid image width $imageWidth" } - require(imageHeight > 0f) { "Invalid image height $imageHeight" } + require(atlasWidth > 0f) { "Invalid image width $atlasWidth" } + require(atlasHeight > 0f) { "Invalid image height $atlasHeight" } - require(width <= imageWidth) { "$width <= $imageWidth" } - require(height <= imageHeight) { "$height <= $imageHeight" } + require(width <= atlasWidth) { "$width <= $atlasWidth" } + require(height <= atlasHeight) { "$height <= $atlasHeight" } } - override val u0 = this.x / imageWidth - override val v0 = this.y / imageHeight - override val u1 = (this.x + width) / imageWidth - override val v1 = (this.y + height) / imageHeight + override val u0 = this.x / atlasWidth + override val v0 = this.y / atlasHeight + override val u1 = (this.x + width) / atlasWidth + override val v1 = (this.y + height) / atlasHeight override val type: SkinElementType get() = SkinElementType.SINGLE } + diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt index c80ea1ee3..8587d4197 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt @@ -34,7 +34,7 @@ object ResearchIcons { val KOT = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/block/ph_kitty.png").element(0f, 0f, 32f, 32f, 32f, 32f) init { - val grid = SubSkinGrid(AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "android_upgrades"), 126f, 126f), 18f, 18f, 7, 7) + val grid = SkinGrid(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/android_upgrades.png"), 18f, 18f, 7, 7) ICON_TRANSFER = grid.next() ICON_ATTACK_BOOST = grid.next() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElementType.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElementType.kt index 6a729cf7c..a672e32ab 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElementType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElementType.kt @@ -18,8 +18,8 @@ enum class SkinElementType { it["y"] = JsonPrimitive(value.y) it["width"] = JsonPrimitive(value.width) it["height"] = JsonPrimitive(value.height) - it["imageWidth"] = JsonPrimitive(value.imageWidth) - it["imageHeight"] = JsonPrimitive(value.imageHeight) + it["imageWidth"] = JsonPrimitive(value.atlasWidth) + it["imageHeight"] = JsonPrimitive(value.atlasHeight) it["winding"] = JsonPrimitive(value.winding.name) } } @@ -32,8 +32,8 @@ enum class SkinElementType { buff.writeFloat(value.y) buff.writeFloat(value.width) buff.writeFloat(value.height) - buff.writeFloat(value.imageWidth) - buff.writeFloat(value.imageHeight) + buff.writeFloat(value.atlasWidth) + buff.writeFloat(value.atlasHeight) buff.writeEnum(value.winding) } @@ -63,41 +63,6 @@ enum class SkinElementType { return MatterySprite(ResourceLocation.tryParse(texture) ?: throw JsonSyntaxException("Invalid resource location: $texture"), x, y, width, height, imageWidth, imageHeight, UVWindingOrder.valueOf(winding)) } }, - ATLAS { - override fun toJson(value: AbstractMatterySprite): JsonObject { - require(value is AtlasMatterySprite) { "Invalid skin element provided, expected AtlasSkinElement, got ${value::class.qualifiedName}" } - - return JsonObject().also { - it["location"] = JsonPrimitive(value.location.toString()) - it["width"] = JsonPrimitive(value.width) - it["height"] = JsonPrimitive(value.height) - } - } - - override fun toNetwork(value: AbstractMatterySprite, buff: FriendlyByteBuf) { - require(value is AtlasMatterySprite) { "Invalid skin element provided, expected AtlasSkinElement, got ${value::class.qualifiedName}" } - - buff.writeResourceLocation(value.location) - buff.writeFloat(value.width) - buff.writeFloat(value.height) - } - - override fun fromNetwork(buff: FriendlyByteBuf): AbstractMatterySprite { - val location = ResourceLocation(buff.readUtf()) - val width = buff.readFloat() - val height = buff.readFloat() - - return AtlasMatterySprite(location, width, height) - } - - override fun fromJson(element: JsonObject): AbstractMatterySprite { - val location = element["location"]?.asString ?: throw JsonSyntaxException("Missing location element") - val width = element["width"]?.asFloat ?: throw JsonSyntaxException("Missing width element") - val height = element["height"]?.asFloat ?: throw JsonSyntaxException("Missing height element") - - return AtlasMatterySprite(ResourceLocation.tryParse(location) ?: throw JsonSyntaxException("Invalid resource location: $location"), width, height) - } - }, SUBELEMENT { override fun toJson(value: AbstractMatterySprite): JsonObject { require(value is SubMatterySprite) { "Invalid skin element provided, expected SubSkinElement, got ${value::class.qualifiedName}" } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinGrid.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinGrid.kt index 7861590dd..f83cb71df 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinGrid.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinGrid.kt @@ -13,8 +13,8 @@ data class SkinGrid( var row = 0 var column = 0 - val imageWidth get() = width * columns - val imageHeight get() = height * rows + val atlasWidth get() = width * columns + val atlasHeight get() = height * rows val currentX: Float get() = column * width val currentY: Float get() = row * height @@ -36,7 +36,7 @@ data class SkinGrid( } fun next(): MatterySprite { - val element = MatterySprite(texture, currentX, currentY, width, height, imageWidth, imageHeight) + val element = MatterySprite(texture, currentX, currentY, width, height, atlasWidth, atlasHeight) skip() return element } @@ -54,5 +54,5 @@ data class SkinGrid( } operator fun get(column: Int, row: Int) = - MatterySprite(texture, column * width, row * height, width, height, imageWidth, imageHeight) + MatterySprite(texture, column * width, row * height, width, height, atlasWidth, atlasHeight) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubMatterySprite.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubMatterySprite.kt index 196317389..08b60e242 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubMatterySprite.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubMatterySprite.kt @@ -9,34 +9,11 @@ class SubMatterySprite( override val width: Float = parent.width, override val height: Float = parent.height, private val overrideWinding: UVWindingOrder? = null -) : AbstractMatterySprite.Mutable() { - override var u0: Float = 0f - private set - override var v0: Float = 0f - private set - override var u1: Float = 0f - private set - override var v1: Float = 0f - private set - - private fun calculateUVs() { - u0 = parent.u0 + (xOffset / parent.width) * (parent.u1 - parent.u0) - v0 = parent.v0 + (yOffset / parent.height) * (parent.v1 - parent.v0) - u1 = parent.u0 + ((xOffset + width) / parent.width) * (parent.u1 - parent.u0) - v1 = parent.v0 + ((yOffset + height) / parent.height) * (parent.v1 - parent.v0) - - notifyListeners() - } - - override fun parentChanges(parent: AbstractMatterySprite) = calculateUVs() - - init { - parent.addListener(this) - } - - init { - calculateUVs() - } +) : AbstractMatterySprite() { + override val u0 = parent.u0 + (xOffset / parent.width) * (parent.u1 - parent.u0) + override val v0 = parent.v0 + (yOffset / parent.height) * (parent.v1 - parent.v0) + override val u1 = parent.u0 + ((xOffset + width) / parent.width) * (parent.u1 - parent.u0) + override val v1 = parent.v0 + ((yOffset + height) / parent.height) * (parent.v1 - parent.v0) override val texture: ResourceLocation get() = parent.texture diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt index 813924b33..67431c658 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt @@ -6,11 +6,11 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters object WidgetLocation { val WIDGETS_18 = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets_18.png") - val MISC = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/misc"), 64f, 64f) - val PATTERN_PANEL_TABS = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/pattern_panel_tabs"), 64f, 32f) + val MISC = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/misc.png"), 64f, 64f) + val PATTERN_PANEL_TABS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/pattern_panel_tabs.png"), 64f, 32f) - val CHECKBOX = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/checkbox"), 32f, 64f) - val PROGRESS_ARROWS = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/progress_arrows"), 32f, 32f) - val HORIZONTAL_GAUGES = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/horizontal_gauges"), 128f, 64f) - val VERTICAL_GAUGES = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/vertical_gauges"), 128f, 48f) + val CHECKBOX = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/checkbox.png"), 32f, 64f) + val PROGRESS_ARROWS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/progress_arrows.png"), 22f, 31f) + val HORIZONTAL_GAUGES = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/horizontal_gauges.png"), 96f, 54f) + val VERTICAL_GAUGES = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/vertical_gauges.png"), 90f, 48f) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets.kt index 0921111a3..3a23df616 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets.kt @@ -8,8 +8,8 @@ object Widgets { val ARROW_UP_BUTTON_PRESSED = WidgetLocation.MISC.subElement(0f, 18f + 6f * 2f, 18f, 6f) val ARROW_UP_BUTTON_DISABLED = WidgetLocation.MISC.subElement(0f, 18f + 6f * 3f, 18f, 6f) - val ARROW_DOWN_BUTTON_IDLE = ARROW_UP_BUTTON_IDLE.copy(overrideWinding = UVWindingOrder.FLIP) - val ARROW_DOWN_BUTTON_HOVERED = ARROW_UP_BUTTON_HOVERED.copy(overrideWinding = UVWindingOrder.FLIP) - val ARROW_DOWN_BUTTON_PRESSED = ARROW_UP_BUTTON_PRESSED.copy(overrideWinding = UVWindingOrder.FLIP) - val ARROW_DOWN_BUTTON_DISABLED = ARROW_UP_BUTTON_DISABLED.copy(overrideWinding = UVWindingOrder.FLIP) + val ARROW_DOWN_BUTTON_IDLE = ARROW_UP_BUTTON_IDLE.copy(winding = UVWindingOrder.FLIP) + val ARROW_DOWN_BUTTON_HOVERED = ARROW_UP_BUTTON_HOVERED.copy(winding = UVWindingOrder.FLIP) + val ARROW_DOWN_BUTTON_PRESSED = ARROW_UP_BUTTON_PRESSED.copy(winding = UVWindingOrder.FLIP) + val ARROW_DOWN_BUTTON_DISABLED = ARROW_UP_BUTTON_DISABLED.copy(winding = UVWindingOrder.FLIP) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt index 34a812e8d..d49145350 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt @@ -5,15 +5,15 @@ private fun makeButton(grid: SkinGrid): StretchingRectangleElement { val y = grid.currentY return StretchingRectangleElement( - topLeft = WidgetLocation.WIDGETS_18.element(x, y, 2f, 2f, grid.imageWidth, grid.imageHeight), - topRight = WidgetLocation.WIDGETS_18.element(x + 16f, y, 2f, 2f, grid.imageWidth, grid.imageHeight), - bottomLeft = WidgetLocation.WIDGETS_18.element(x, y + 16f, 2f, 2f, grid.imageWidth, grid.imageHeight), - bottomRight = WidgetLocation.WIDGETS_18.element(x + 16f, y + 16f, 2f, 2f, grid.imageWidth, grid.imageHeight), - middle = WidgetLocation.WIDGETS_18.element(x + 2f, y + 2f, 14f, 14f, grid.imageWidth, grid.imageHeight), - top = WidgetLocation.WIDGETS_18.element(x + 2f, y, 14f, 2f, grid.imageWidth, grid.imageHeight), - left = WidgetLocation.WIDGETS_18.element(x, y + 2f, 2f, 14f, grid.imageWidth, grid.imageHeight), - right = WidgetLocation.WIDGETS_18.element(x + 16f, y + 2f, 2f, 14f, grid.imageWidth, grid.imageHeight), - bottom = WidgetLocation.WIDGETS_18.element(x + 2f, y + 16f, 14f, 2f, grid.imageWidth, grid.imageHeight), + topLeft = WidgetLocation.WIDGETS_18.element(x, y, 2f, 2f, grid.atlasWidth, grid.atlasHeight), + topRight = WidgetLocation.WIDGETS_18.element(x + 16f, y, 2f, 2f, grid.atlasWidth, grid.atlasHeight), + bottomLeft = WidgetLocation.WIDGETS_18.element(x, y + 16f, 2f, 2f, grid.atlasWidth, grid.atlasHeight), + bottomRight = WidgetLocation.WIDGETS_18.element(x + 16f, y + 16f, 2f, 2f, grid.atlasWidth, grid.atlasHeight), + middle = WidgetLocation.WIDGETS_18.element(x + 2f, y + 2f, 14f, 14f, grid.atlasWidth, grid.atlasHeight), + top = WidgetLocation.WIDGETS_18.element(x + 2f, y, 14f, 2f, grid.atlasWidth, grid.atlasHeight), + left = WidgetLocation.WIDGETS_18.element(x, y + 2f, 2f, 14f, grid.atlasWidth, grid.atlasHeight), + right = WidgetLocation.WIDGETS_18.element(x + 16f, y + 2f, 2f, 14f, grid.atlasWidth, grid.atlasHeight), + bottom = WidgetLocation.WIDGETS_18.element(x + 2f, y + 16f, 14f, 2f, grid.atlasWidth, grid.atlasHeight), ) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt index 0a631c678..bd18562ab 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt @@ -4,7 +4,7 @@ import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.OverdriveThatMatters object Widgets8 { - val GRID = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets_8"), 64f, 32f).subGrid(8f, 8f, 64 / 8, 32 / 8) + val GRID = SkinGrid(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets_8.png"), 8f, 8f, 64 / 8, 32 / 8) val BUTTON_IDLE = GRID[0, 0] val BUTTON_HOVERED = GRID[0, 1] diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt index 716a5c5ce..ef8f5da50 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt @@ -52,7 +52,7 @@ abstract class BankRenderer(private val context: BlockEn val width = 9f val heightMax = 39.36f - val buffer = DynamicBufferSource.WORLD.getBuffer(AtlasMatterySprite.renderTypeWorld) + val buffer = DynamicBufferSource.WORLD.getBuffer(texture.renderTypeWorld) texture.uploadOntoPartialColor( stack, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ScrollBarConstants.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ScrollBarConstants.kt index 46242cf9c..f30839f85 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ScrollBarConstants.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ScrollBarConstants.kt @@ -2,30 +2,34 @@ package ru.dbotthepony.mc.otm.client.screen.panels import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.client.render.MatteryAtlas import ru.dbotthepony.mc.otm.client.render.subElement object ScrollBarConstants { const val WIDTH = 14f const val SLIM_WIDTH = 8f - val BACKGROUND = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/background"), 14f, 8f) - val BACKGROUND_SLIM = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/background"), 8f, 8f) + val NORMAL_ATLAS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/scrollbar.png"), 62f, 15f) + val SLIM_ATLAS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/scrollbar_slim.png"), 32f, 15f) + + val BACKGROUND = NORMAL_ATLAS.subElement(width = 14f, height = 8f) + val BACKGROUND_SLIM = SLIM_ATLAS.subElement(width = 8f, height = 8f) val TOP = BACKGROUND.subElement(height = 2f) val BODY = BACKGROUND.subElement(y = 2f, height = 5f) val BOTTOM = BACKGROUND.subElement(y = 6f, height = 2f) - val BUTTON = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/idle"), 12f, 15f) - val BUTTON_HOVER = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/hovered"), 12f, 15f) - val BUTTON_PRESS = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/pressed"), 12f, 15f) - val BUTTON_DISABLED = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/disabled"), 12f, 15f) + val BUTTON = NORMAL_ATLAS.subElement(x = 15f, width = 12f) + val BUTTON_HOVER = NORMAL_ATLAS.subElement(x = 15f + 12f, width = 12f) + val BUTTON_PRESS = NORMAL_ATLAS.subElement(x = 15f + 12f * 2f, width = 12f) + val BUTTON_DISABLED = NORMAL_ATLAS.subElement(x = 15f + 12f * 3f, width = 12f) val SLIM_TOP = BACKGROUND_SLIM.subElement(height = 2f) val SLIM_BODY = BACKGROUND_SLIM.subElement(y = 2f, height = 5f) val SLIM_BOTTOM = BACKGROUND_SLIM.subElement(y = 6f, height = 2f) - val SLIM_BUTTON = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/idle"), 6f, 15f) - val SLIM_BUTTON_HOVER = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/hovered"), 6f, 15f) - val SLIM_BUTTON_PRESS = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/pressed"), 6f, 15f) - val SLIM_BUTTON_DISABLED = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/disabled"), 6f, 15f) + val SLIM_BUTTON = SLIM_ATLAS.subElement(x = 9f, width = 6f) + val SLIM_BUTTON_HOVER = SLIM_ATLAS.subElement(x = 9f + 6f, width = 6f) + val SLIM_BUTTON_PRESS = SLIM_ATLAS.subElement(x = 9f + 6f * 2f, width = 6f) + val SLIM_BUTTON_DISABLED = SLIM_ATLAS.subElement(x = 9f + 6f * 3f, width = 6f) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxPanel.kt index 6db631948..bbd0e6415 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxPanel.kt @@ -91,7 +91,7 @@ open class CheckBoxPanel @JvmOverloads constructor( val DISABLED_CHECKED: AbstractMatterySprite init { - val grid = WidgetLocation.CHECKBOX.subGrid(REGULAR_DIMENSIONS, REGULAR_DIMENSIONS, 2, 4) + val grid = WidgetLocation.CHECKBOX.subGrid(columns = 2, rows = 4) IDLE_UNCHECKED = grid.next() IDLE_CHECKED = grid.next() diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/android_upgrades.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/android_upgrades.png index 8deae1d89b471315e9704158fa0ce8b322d20c56..ce32f5677b5ad6833defe8b74a05a58aaad055b7 100644 GIT binary patch delta 2527 zcmb7G={MVn0@Y~;6{M>6N|?UsG8mJIVoG9(T8fr26xB$j6MsRRz*rIZG~8>QMFYjgdmor5ou!j{(*PSJLfK6?#Fx2xg0g2s(!ZHMF%AXZ3P(_ z86_u2yI;S0@_#8W`&AcD{FQZ2-vl_E=VWK|TReKbGB=!Mu6Q0N-k+bj3N<3zz~9k+ zzu)cwsXYQMEebn%Q3tccXcXaT^hKSmf+i1>SAeN6=71F+J)6_u?I4VfGqwuTwS{Y^ zrZ;e8zS}G8@3t_&Ne?q)Zx?pSXWcN)cqDMF32s5FOg07ie~TNHZdoFQKzNKg?A)L; zm;+t}tAOR}QGrPVwATsQDkJ>(=8 zec9_HEAO*nW>2UpzyUOeOjJx#bh(!G5S3L1=W>=L#=hyqZ@KD;VRzen9Y`S#B6K*k zO9KM}AxyH8?^fu!He97Rjpy_KX+hL#6iDi7R0y9uG--OHIqA0|R9ur=ii3UFoWX1a0|Pm6>#)e9 zR9JzwsKp1ka!X}0jZ7Km{*X)_>pr2|O)TA{Bm@-@EvN=V_HlE3qhLCH2*o zI?)@_%onv`1JOsE+p*d@va6j~ zHs*%R=1na>>1J$;L?UCWB{c3OBx7Vc3`8xuS(EWX&hQ!bQ&Cwdl%=w*RWj#p_=I;C zk)E#oVY3tv&m_P&U`cNX#ma1d^IcZO9=@al(Kl?F(q5W2i5@?b$%`Em7Q%N@_`q8h z)Bm)Q#v>}SnWTJ;YMk8*1ni0Wm?@`b6iXNaljHMj;AnBM}*gF zVDqC?LhEW$2k1pU2>NGtq;m3}7IjjPaq-KM>#9wocXCM_TzUM#Q3Lhpg&kX%7pQ7L zC;p%E&G^w->3@Pu!Hgk>ei1V8CxCDohK9LEDS5rc65SaqTT?zHK!!9&%0qI z)$4Ucc1i)3_F6WAP$x@A6!u>R8kZ-T84+BX>Vkq)4S6RG=No_tPe@(hQs!7^k4UtF z(nEZVX5D6HZnU7aa0y^J>N@S?mE3Ubc*?nv0ZkzNQ2f>GYYqEJLX;3csyDK?0w87&EaD0NG4=zy*X{n|pBQvTd zkxy5qHB63amiW*@;t~yq2(LlBjz6zGKtU3ajX{S|$$3KScF7tPzx41K<+&bsOg4I= z(gCO#Ol08F)n@?nuA}Yogra?(#HNiOKzyJSyksWq%O4ealPXpae|sWB>T8;vl%dhv zur1F^#$MhW;v5L}w-Bg)T)@P^^dQ*Gw0Q9kt33*HpN}v!*_H+f@AJ-@+gMBNeHZA? zXs*zj*SuM@n_pRMW*AeeajK^PB2bt3wnv-L5tzroh7I;fwi(@ZClI2i9LR;uPf}Gg zp#CyiTO@G7Q8sI0q47=lHtobv>fAEB)tB>Wj3ZGD_BJxHq~RA&Rf~>FZ7E8-m<<#X zRj#&vX@OkT1$FzZP{Ss;;qCVux6HKa_7(ZxMCYFOqP8R{P*5Ak-QIIYr0}UB>?h+v z;CDEJaYdE~ZnB{^B*H3z#H(*?5FGl;KWQt7696C+UCQ5Tv@3 zNf#ydvG+*e%9R7F^_?7t@!A|c(>v%^MgQd$L1A@QhmQ^HfuC`;{!OyFy})|d1&)2k zask>%?(?}cluXn~J}KysFC3h=ngqDM>rZ|wTvQ>WRJoQE2>w;~DwMInY9Tyof5>G+ z`{cjhZhxr3unt{H^^t@Xyxg<*&sz*c7Ovo~i?26Bf_w;jXsJ!!k$YYss3tq5i|Cw} zaD%=_u2#CrA6`S(Glj2L(XMfGh9^tX@40ZXQ%2@JT!LvRUF3PYf0F>%xsn5qneA9N z=#Ft&M8R+1l}&mQ1-~#uJ3>6kiXJDlc>iZ&6ilb|5fj?Z$%SUbkhI=D z$T!8P=9(J(X=c+4Iid867n|)6fJX8|?lPYo5pGHdl+o+I_;XhTZ#F3uCD`EVPGNuc zjm}5czK;`Ym`}fs=ml1Z!F4<>_Rmvk+F3}GvBRV=G8`{liC8-G=wS3qN0#tVqJKeE zu=kr;)A;hkpuaNt6&%3dfEcF#qG0s!=&=xt4puoCh<_X_5~ zB@0XxPlsQ|zG236eN%C3K4VuSq5MdUBrBxm}gqE_w<>sCl zXGu=QV?aj=8XIM8)>C_n%NIdeX@5XjxcG+lc-3UbmL$c1O0|GIPdjS7?nCN}iAZmK z@lDvk*0AMNP?vvKfk#>a>R@y(bYOddH9G9q%VoS*$Cl*|_A1Tn*ITUD+@_5$JpL&< zI5H^F6>MT4$$2=6K+Y_$EJ$P=P~VjXOB7(hfWo^3YP^wn;l)<3*yu&`&&N!<2PVpI zmJw2RFYGTOr-w&m>uhGu9$SxcAO|SDWUm8IfvIdN|EhOlMA=9A`>{?|r8ZH}mpStX zH#nk?*}@o^OJNk2u-t<>bG0AbnIScucHrArY_+e>b%+`Ji*2X{wOtK{uJNCXw;{mX zmZB^@shq^DlH`V3b`7!Is*{fLGrqh%MUSX6BhMvi(0Z7W-BwYr8sUvS(n$NXjv_|K z{3fh{I;mj=NjiX!zt3C%&Yaz)LX({EyN;)G>i!R${U2#*xb%w%oFgKt@ixe!ub)lE N>HI~zC$^Y7{{nIbDb@f0 literal 2792 zcmd5;`#Td18=hB44%1gT8`9U|MaZ$(rpV!~nB+8X8w(T3Vab>|6_Zt7ot)2kDU;11 zr8z{Bb2EmLIh(`GX%4f^=l#Ba;``x#?(4qp`?{VVp69u)=Ml`oR_2iMApig%V{d1D zeV^n0!9nr;+6wXR+9wgrb=ymTcfG3f`{Drl;GTVK3^MX+-p-T!GOec60xFZix)`d50qS4f)9C;JYZLy|kl5^kO2dm$Ie zne9u;Byz;I*5;ZBzibtDm^PBq<9bc5rbQl)i|5X-=n$97Gt~V5up+}0)U2)5tA-=c z)7{Yd@SBaWqpj0*{Y+l%#dy-kwk^T&U4Wf*Nk92}-j+&L-pp0C zAB+jHEI1QR9gL_^fZ#Q{GBf+TT9d`$^)!(AW>g;NDJnE*q865LO6iRXn;kxU_=-&0 zeB}lJlh4<7C#He?!*aQ1CvY(jsbpB)$zm5w2~(S_p5fW%(}Q{Nu~Yzh05_W2J3B5d z1W?5~(tF^~9+ZKi*)I`ptGL?Dp!t;^>O+o;6;9e;y&fei2kaC7!neu%+MTdw5cBE- zkosd?dZ|)yPoC5D)DHI&j&uy%Yn~cyThjk=quxnS9vz_G_bty@Ce%=m_H*mRjE)sl zyvl$eA?2b(Ft z$orw~Y#;_I4jj5QQAj+@+Tdn}*Sxb`!niTrb_Bay>X2@HE;~GQht&3d#dBoyOa`v` zy1Bf=qsSctkY>L3yjt5N&wkk1y$q)G8>&6&_{p_8A4^lCvWL zLAnyf4X>SLnTtgnP4ukD{LA)sSJfh@O#bK{|)T3wFWHuEf&p3Mmvg%cxPp9oybQXrO!^oy@+&QU%}qzz^+|Y#GAw*{#&Y z7rnAlrFti4!SWEfsWp$w_GTy@`hcbObh>qOJEhR~K^@phbQVVM(&81q>tFx!?F6(<#KGtr?7A3Riq3gy6>i!hE zVCASVGVEB*crC3@aWKQ9WN6Ca-Li{X9Ge?D642S%UXc!6lS`}-Cca;&mPkN^GTc*v z{nqb~suT2LSv{j~29NY@fXh0f7`z?D`>vk8^mOC~%-`Klx_o4nqQlYDqavRrCCWyY z?U0I2NbeXRL`OC$u}VhJii$R|$Yhg@>{$!m2xK-8qWxlAbZLqs@;*9}7>m6e5`Ycx zzm=6}we;o5_Z@fA;yn1R3nZX8pJFeI6i(loEYCxb^uHV8<%?W6u_R~p%086kD5?)v zevpbk#`O~0A2YfpEH4f8zs7kK`}*KL7;(swLkUUWR)J{ixw9;jZ>fh**8%a8WERuc z-1hUR=&QFNquCT}>!?xitjMI-`!QiT&#^`B%f)YYy(xSAaLqj(- zhod)`8GSNUvBPo#w*rNXPl^QeeIfASpBM8DA`mwii@iedaM!Jgrl)G?Z3}fJKx_f6 zwf0_TdKe z>cF*FakwFHV*!U79W>HC-5=}VR{mcySeI^sTpKrb)TncdDXiCNdQuN=wk zMvyt39Q7+m)Y93zaDzOeN!EJxdz5~}P!>*walf52(lRZ^r`0Dfykj6|ZUfBX8uAhn zfqF*fCk*r>B*5h*R}coNC3+3pB&N%fBBAf^!(|2-#m$xQF@_K#zV;Go#aRDtp{2c0 znB`P8Rts`k3~zu;H{=(BSU%{DHE@|}^&i2puD5%6D!`@;(-xahx-#OFO7B3&mPt8G zm3p>yj&g;Zz`^{z?7&yjSpL-k?e*+7rJI+v2h#R4#m{^G2o=E17}W$;YDkIS>N$(`z&f zF|i(1cxhD5G1Oxh>)2ISEF)d`iY!>u*j+aKy4qtg>`!glwkQ?XK!7qnZ5K)dEveCl zgcV+OEzx9@*xn*GYJ0DgKgZ516e;NME|jvK3JfSvny}`NEqn zJ*NCtJBEx-!UH}4CIrt$6+fyPHGXx@3d+F6ZQJd&30{aKD-=tKL|16#&{DLGi4qp( zsfmQ0l=P-;rI29VtBijO>Sa=pnQxPsqRXuF=Bt?| oNw4>`)7n%?5pi#JxQnsKyWjjO&eC@Gzf*wyWe4kbm%I}G11gt{&Hw-a diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/player_bars.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/player_bars.png index 4c867588e72db77b743a676a3ee8de66f049f0b6..9b2f9356737a3358d6535c530209d3251db056dc 100644 GIT binary patch delta 244 zcmcb^G@nVaGr-TCmrII^fq{Y7)59eQNCyD1G6x%wWM1BTXriKN{T5Fb$B+!?x7Q81 z4mk)oTO8v_+Ml?d zd`@#y@g134XT2PK(;QATOkh-Gc47;OJ^NexyQFV0)3)5-mYGwgOtPL}q>uuWzsDSU z{R8{4o$o(AuIzm3RU?1y{`1W1=I>zgY%M%1cFnq)_|Th0gYo+Ix8GM7zMFkd)G+w>J#E zjyj06U96mTtD`j`F}F-{+B?UB-gOTi>IHFWvT$#_SXQH-#@HrO^!I#Y!OXHBOvaZN ze4YOL-tlW^ON(#ryW}^`Q-iTZ*uerqIBdH6@VEH)oAxDl4sUwK(3bcka^oqBzT<&b z4CxI8OdRSEq8`Y6E}O9X(shSJXTRF{^8bDOdgt8v_sl+j|NJpc>;HFaW`vn7!VD_6 zWADtZ4Tx04UFukvT{MK^TR<#7IOUDNG?^v4vV05EZeMD2kvUF@jg&?#4tRy9v7y z8%x1fu<&TS3L9%}Eo=or@Bp#2vQo5>u>P|V5`+j24D<13-ecws1P^nj<%YV!vWre~ zG@;GR&S~Kn8i^1kL{vB3!o<`_ikjo|j(}Qk<0^~)ji&UHYeGO19yAM1QFu|ff2~+h zyek|tm-V#pnQ)gQ7ZiR_x>4p=#aW+&Dl_J!l0(8VVJ%z5MiraOjwReD+@7{<$q&wy zIjwkIv6Wjjf9|PX7+JEXr<5+UjZwy!U=j_3RaVGRBrdBhic3=V6E*y;zJF3&hPYNR z#W74C3*Gml{@{1FZl<@VoD@kw{j=x2cR+X>N?V@yb>w-aW2k$AOS|IFAHu+g=vx)7 z{Q#mHaDG+Mj2*bxgqFvG?&!W$Co`DIz}u;O(=0UKK;wM5x1W7Z?ja>zjbFpwK6GX! zd!fd=8>)Nz^NimgiEkTna)dh9-B|zt010qNS#tmY4#5Bb4#5Gqk!$S$00C7=L_t(o zNA1|rZG|1$@AfM@VS*D}?ZRukJ;7 znx@~Y8}0iZkG1!Hr}OUp4S3tOxLRa}TY-`Z&e3_E)7i5MSQ{k+Me2?PW1*;k^M^B0 zblLG4VW3DIH85GMRJccOu;16|^)8)vEyC-%rb~OvvczNUy`T4T-GVV98S&H1a4S$U z!8uymCKm-de1 zh{xJ{Kkwzb1!F`q;-{J6R-j~pbF}7V(kftWlnfN9I~I(Eq5{qz&P35=$7h6rB6ZZj zWU*4=9=XAOKiY<2@Pq&VMD5Wn7$cGqKg|rc0woiiqcty+Rsn0HWS~ghv0y9|6>$D= vCWr&00000NkvXXu0mjfeD!zR literal 838 zcmV-M1G)T(P)EX>4Tx04R}tkv&MmKpe$i(@LdOI@m$PAwzYtAS&W0RV;#q(pG5I!Q|2}Xws0R zxHt-~1qVMCs}3&Cx;nTDg5U>;qmz@Oie3JS*PxgfI+5Cns8h zQlOEPK_f{ip(ys}*i9hOVPKM5$^JL*X|Nax17Jm)F#ym3z&MWLZSOtq?gGFM8qaqL zIOpJ;Ya{S9SR@d`r)lB|53tta?yer8SioAF#8*||X|PBjhF>|l(*n7Onebu)8VRlI4PyIQ5~A!I&7Xm2LQt`h!;Z$xVx)IC>97IB=J=hcp5Ach~Za`?zBKI zVkW$pzy@W*4+1fy20WX<9>#zEDII{sI6+|_*F#Us?8)n6mvy-(t+D)2N|BoM=| z9NlSwT*ORxF@X)rh93lCNDX*4fjx`~FV-;|s&$;SV&C^o>Udce105XzFDeC@kW8KC QyZ`_I07*qoM6N<$g4?)m!2kdN diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/horizontal_gauges.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/horizontal_gauges.png index 83caab387ad6d3b2c44e19f6a07b3ef206b9b853..69916131808be41af77236c869c0c6135da9a2f8 100644 GIT binary patch literal 326 zcmeAS@N?(olHy`uVBq!ia0vp^2|#Sd!3HEP{O4Q(QjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`ISV`@iy0XB4uLSEsD@VqQ1G^=i(^Pd+}qn5c@G(gFkH-^=E=I&TjEf1 zm0;8gBgY#`8WW{eUQ9S2^iFhRaJ-=FeLu_Rru!`7-{mf^udpk+U3-gpO35+jjg@SLrb zR=DRl+!K^;U`$|ZkYq?>n8BFvkG4ifMN6gCHsLQoCO|{#S9F5he4R}c>anMpkS4! zi(^QJ^V=KVTn7v|Tmyd>{*TskS^h|+U**d^zvg+KnJZkUFPQPhH*LEKP&o)3;A{xI zr?@OsY;v)GWVOTGpP#kn#{{!OBpGfnY}m2G{A0g|I0J(^gWJzne!6PU=WY7dU}fjV jz>vcbAp=tQNA|%##%hJ4SCwgxz~*|o`njxgN@xNAGGkW| diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/pattern_panel_tabs.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/pattern_panel_tabs.png index 6988d0fc445d382e3172c8cdeb23b7e0a404031a..14b5b1ad1b2eeb57816cadb89be9aaee0017372d 100644 GIT binary patch delta 460 zcmV;-0W<#Y0^tK8iBL{Q4GJ0x0000DNk~Le0000y0000N2nGNE09ThRhmj#6e{e`y za{vGi!Tl|IZGx&*s+e@i=Y0I6lrR&h7Kp+q(C8jqcN|CiT`e|qe@Gwck!l00 z%Am5J73=M5A!ECSAtnX0oq>oHVn;@<55d}3t`XLThIM5tX3t^6OES~tC??Zo9pf4p z=_;_gYSAlZZ@yPlZ@!yQ#VnvuWR^tTlXy93QywyxTMZM>cvjmpUdf>)k?nv4;@QgI z!PouM`awSRNSl{h8y$UlB9vYlZ{l}{$!8wvY5E5O3{JWH42lQ<0000B|3Aa^Q@oBqE@y#9WHAE+-(e7DJf6QI1t@sm)5S5w!~5-ogM5b- zc$|0t`|qybm#eTvDEMgNtY_XrZ}tTB30pbcToR|aRk32T^^XFH!VX6Flvaz=JcVoy z%er(#^LJHUt`}v9R5DSX{p@UBKH~|sBOPsTUKn18b>n&QTjH0UkP$D(c7{!Q3^z3{ z#-x@pZkq0PgQLNXp@eoY%2Dm)?R6weqrXUE;+ zndcVfl=AEhU9g7VvN+baOqO9y$bY}Qpg9{o3*(r2E(mD7p3k5sc8j%Qov-;0yUDk< nnlbKsAUOXu{}09kmHQa&AM@UExhdWU^els?tDnm{r-UW|P9B6_ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/progress_arrows.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/progress_arrows.png index 97e06802276455560ed40e4d64134be8f3116acf..dc0c2a9a87fb045d498c4e65655241bfcab67b5b 100644 GIT binary patch delta 269 zcmbQtw3tb;Gr-TCmrII^fq{Y7)59eQNQ(inJO>+)e7xKC^F&33dd>om$YKTtzC$3) zD5~Mr0F>O}>EamT;l1^8pwJNk0oTB^tvUy^bQ(IwWa!%h;hwM^l5WOxm=+5zKe*!f-*?Oz-kLv^4Hoq+DxDwkt$uq|@Pdey>UkQA z4%&8UeCSXzwsH2IyDNFwyI(*fmIb~k_}mk2@igpA0auUP9Ja-B-yctws4QV}yArr1 zspnj~K#02D(i87wFGQ{WXMUXH_?Gq>)oa46u8;0s3{X)McXbcg;y(8`leOJcljsmx ROQ0thJYD@<);T3K0RX_rY0Cfr delta 253 zcmZ3?G?_`UGr-TCmrII^fq{Y7)59eQNGpIa2Q!d#S<-cEqM|}QPk>K|Yj=0||Ns9p zGBQBYcP7mTQYX&d-^dwRI96GIlAQa1~v$Xf3CQ->U@eR|`(FtyMoW sefphRQI&X>o7D{YjJC|5c}_^E?_SM$ljDV$C(tnrp00i_>zopr0P{RrEdT%j diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar.png new file mode 100644 index 0000000000000000000000000000000000000000..e15e25c3d023a24c1ec7319d4db4c6082421ba46 GIT binary patch literal 330 zcmeAS@N?(olHy`uVBq!ia0vp^c0kO}!3HGvJg@NqQjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`ISV`@iy0XB4ude`@%$AjK*9T-E{-7{-fu4&ay2^$uwLL~vFSH!iaVSg z@lx>3l~dI(c;6iHJO5DA$E|K-i@`ZB4$d>H)7o{vz2ASdaL?rBI;S%v*yfZRD?GA9 zn1yj!vG3)8dCx6g${e)p=-;HH=^M;-SU~#bu66DoQX@A^bPX(Fng3i;I`aPakWf)k z*T&v8xzW3l_w_h?#@VOOQuBHLv3*y~`|SJ4z458N+-p8ApP#vB-Rrs1U%tNYy>C$M zJt^h+gIV%r&Dl~V&DrmEA2fac)1!bl`;OG~$j8@qym{T59P;pi-L7?ub8i<|9Y6TB aL+&w$%AbutdLIM5%HZkh=d#Wzp$P!**o*T3 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/background.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/background.png deleted file mode 100644 index 187422eb75b26d4e73c6004e0baa414d42bba6d4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 165 zcmeAS@N?(olHy`uVBq!ia0vp^0zk~c!3HEhl+{lMQjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`ISV`@iy0XB4uLSEsD@VqP|(WL#W6%9IN8M9{Qr3eB@Rx`L=9ctRF;hg z*&0|p7*$nOd3qcel8hT&H5eANF*uf&f3GiMa4~0QX5jv5S9#GQKM80GgQu&X%Q~lo FCIFV$C$#_o diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/disabled.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/disabled.png deleted file mode 100644 index 767ab28675930ffe94326063ec69bba953a9606a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 367 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6SkfJR9T^xl_H+M9WCijSl0AZa z85pY67#JE_7#My5g&JNkFq9fFFuY1&V6d9Oz#v{QXIG#NP=YDR+uenMVO6iP5s=4O z;1OBOz`%DHgc*EaloaXxv=uk#I}GRZ9$ zba;5$B9@##9I3M+hQs07p(ecsJ~!V5i#VT4YA`W))pF}Q3Ridob*h%QMwFx^mZVxG z7o`Fz1|tI_BV9uST?6wFLjx;gBP(NbZ36=<1A~uAOlc?@a`RI%(<*UmXt3XP3#dT@ lZbM0CZfbE!Vr~JZ9#ad5CC_;uWdrpvc)I$ztaD0e0syw&VaEUf diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/hovered.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/hovered.png deleted file mode 100644 index 60457f250111541db0ec9907fe853a9ec84f1e8b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 373 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6SkfJR9T^xl_H+M9WCijSl0AZa z85pY67#JE_7#My5g&JNkFq9fFFuY1&V6d9Oz#v{QXIG#NP=YDR+uenMVO6iP5s=4O z;1OBOz`%DHgc*EaloaX$Ia$N7xf4-#4~ z=sXWbMQoIxm=BBwS(1nt8xO!;F)O;q5n`nd}bj?m+#jC9V-A zDTyViR>?)FK#IZ0z{p6~&_LI~JjBqz%Gk)t*j(Gdz{EaloaX$G+zi7$-^ads| zwzkJSGajfiPhw(gTbyy}nn#XU31f*t7SmOq7mi&Ln}Ax@DVc2VzT^$mtycptHiCL!G6~* opau=N4JDbmsl_FUxdoVdOf4XmJm-Cs4b;Qn>FVdQ&MBb@023EvMF0Q* diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/pressed.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar/pressed.png deleted file mode 100644 index d1b456e8a0063781e7abfb4375421dab739b8469..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 373 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6SkfJR9T^xl_H+M9WCijSl0AZa z85pY67#JE_7#My5g&JNkFq9fFFuY1&V6d9Oz#v{QXIG#NP=YDR+uenMVO6iP5s=4O z;1OBOz`%DHgc*EaloaX$Ia$N7xf4-#4~ z=_urfBXGB(#XFt9Q(_?X0$hN2-iKP5A*61Rp1 r`(3wy8Z_WGlw{_n7MCRE7GUZzwSZXiocB>SP!EHrtDnm{r-UW|bfsma diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim.png new file mode 100644 index 0000000000000000000000000000000000000000..f8539f3e60c7b11534649b726bdb9fee417fae63 GIT binary patch literal 322 zcmeAS@N?(olHy`uVBq!ia0vp^3P8-y!3HE-8_tRYDaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(eheoCO|{#S9F5he4R}c>anMpx|{+7sn6}@3&JO`C1fsTrbWjkh?qMh3Sqq z?T>6asYf06G+ICQJO5BK?UG-hiov)yJ{k?i@x2YlcDPxxM1#c$+fAs&9>y;UbHo1 zZKT&f)qpEvWiyv?PWRV&_x$HirUgywSpu$`>dlY1bN;hN!EPqWKa3aNhPTA=x5RNC zc~m!V%j;cFq)XoAbJ^H_0LfQRKfYp>mW6Ke}6CtxP8N;ckI7_ PUS#le^>bP0l+XkK`lf&| literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/background.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/background.png deleted file mode 100644 index b0a6eae96fc26e06e1117c7b964185c4674a6fdf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 357 zcmeAS@N?(olHy`uVBq!ia0vp^93TuL7#^lP35jgR3=A9lx&I`x0{IHb9znhg z3{`3j3=J&|48MRv4KElNN(~qoUL`OvSj}Ky5HFasE6@fg!Ib3f?!xfDz5mR9Adj=a zBeIx*f$tCqGm2_>H2?+KOFVsD*`IN7uuCh5+?u}(D5T=);uyklJ=r8Z0R%V_6FCw= z42{I32Bstlp1c1Q85l|uIi7EOz%v!7UbVzEq9i4;B-JXpC>2OC7#SED=^7g78kmO| z8dw<{TNxT_8yHv_7_2zuWrm_5H$NpatrAUxsRd9EL__!UBhEk#8gLs*GILXlOA>Pn i5PB>^49u;J%&m-#AbQRyD;NRwFnGH9xvX3o4}_% zqzpY>977~7CvW+6o`LGccrS z@m+7Re3%T>tXkq4QIe8al4_M)lnSI6j0}v7bPWx34a`Ff4XliftqhH|4GgRd3|5@- zGDFdjo1c=IR*74~&FP=IfEqO5Hk4%MrWThZ<`y9IScDjuTN#;K85=h diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/hovered.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/hovered.png deleted file mode 100644 index 98f996d4d5c5f4ff4a094c5bccbf89279d71fa1d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 404 zcmeAS@N?(olHy`uVBq!ia0vp^96&63o4}_% zq|7~C977~7C;$04pOMc(LQ*0^LgJj`PB$J9@BtC-l6{9lHyQvzgmMY5qG->HeMcD> zN*?o{4EU6M7iffPiEBhjN@7W>RdP`(kYX@0Ff!6LG|)9L4>2^bGB&m{G}bmSure@M zamvdKMMG|WN@iLmZVfl5f9e8i(16=el9`)YT#}eufY4(RVqk7%WNu|_1hM3dvH~b@ O7(8A5T-G@yGywq0m}Uw9 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/idle.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/idle.png deleted file mode 100644 index 603961851597f9b7129170f1b846d59f270ce68d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 403 zcmeAS@N?(olHy`uVBq!ia0vp^96&63o4}_% zq|7{B977~7Up>E(x50pi;h^xRFiF8{n`X3X&S4T-#WP{`{z}uitOwtIZD0o>zjC2hRbPdcy3=OP|jjarg zwG9lc3=CGB@-jowkei>9nO2Eg!_DcRx_}xq;5L+G=B5^xB<2<%^jL%#m|Gc{TNxWc UEIFgB016uhPgg&ebxsLQ01ne@%m4rY diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/pressed.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar_slim/pressed.png deleted file mode 100644 index 7b8b5dd0a0a3dc005eef6b0d9ce9f0059f918fbb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 404 zcmeAS@N?(olHy`uVBq!ia0vp^96&63o4}_% zq|7~C977~7C;$04pOMc(LQ*0^LZWNooj5iSPy^z&&pgi`t^$fmNbm^mYMa32R&qay zfnkQd0PC9D7Ir`*R7+eVN>UO_QmvAUQh^kMk%5tsuAzahfq96bft9hbm7%e=fq|8Q z!HQE}W+)nR^HVa@DsgMLIsH=?P=f~ChLX(O)Z&uF+yaCiix2~IDgTe~DWM4fX7pt_ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/vertical_gauges.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/vertical_gauges.png index 677f594224305e4809a7e27d13ed3ee6f2725ae8..c981a8143b9c6f55f1b285c4f086bfc1fa842623 100644 GIT binary patch literal 887 zcmeAS@N?(olHy`uVBq!ia0vp^Q9x|K!3HEJ9?!J{QjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`ISV`@iy0XB4uCLY*0oMf1_ovxPZ!6KinzCP99La&5OKX+FSy8}=!-j- z?JLoaUZZo6?1{?- z8crnce}DN?K41G`lbqdm=jFxK%5RgGU#@NZ zBe&xB>6-cC%k{hYAAEkc^QWDC9bfnN$}b!KeBYEXGnKJ^-s+OLl&S?5_wM{DtUGb} zeRgsA_MGf1JpBj$EQtIR@hx&)bwTZ3u*ic~KR(^A*~YMbae|!Yb>a8%=Z~v;T^IJB zFMD}r+x1XOkty$z4;r0T+8{nxbdI>~o@xX6aJQ+>(Tme6Siad-Eqrlf@oA>d&34nf zAHN7O{q|O4m&OMBj487#*I9Mxam7@BnPeOA^uo0jl5&mN{rd`P+Lyujj-eMX%h|p= zzlD93%q=O?!^$hPekIAeinErwE;l{>u2HLfo7>qB9Iv|l?pyANlMdy}?Va^d@QQfv zU(4wAy-?XVuAg<8Sr@0Q3oK&~vD{*s)#jd{KPz8SXZGuhax025z@CmbIrHr`$er~U zHD=tmO6oV`eB-+L!4`G*i)D>_fsWm44q|2ZpSwSMamMZg+uhSyK?18YX4UuiEjrB< zf6-*MWtSfJ8`pH!`K}KiZ-hB{gLv)!M_=+=14|+UVom<9H2^AF)tz?IW*y9d|1$fZ zy@z{QB-a7trLJecP3ruQZw-WmjAQJ@pVnV9_~9O~3bmPe-S!qU)Xz7%&vEy?zo^$( z-~a5MjO%RHb+%Uf+^=)SRF~BBuM__9?Zui08n^TcM13DuZ}ESiJuA)B{bFk4UZC*G zH#v6^#-#1NS^h%fmfDV6wN*y*bq~CLUbXrC1##E?KMmxkYsC83?7h3xn0Ni^A`OkZ z$D2~8xjxXF#d<#;9@?wEWo(7V#F2XCzyn6B&lvn+s}PpA>~UQ<3z%6LJYD@<);T3K F0RTa7pGp7# delta 474 zcmey)_KsPxGr-TCmrII^fq{Y7)59eQNH+kn0|zsZe9F=9J5f=gUNOKY#MRu~yt}*G z(9n>fL(KjE?&mLn3K$L?WH3KAAte>WZmto_1ybB4L4Lvi;ef%*pYan=n6tnmvY3H^ z?;r>>?wFYUmVtrM-qXb~B*XdbjE8xL6?j@Q@1*L!|9@cf>%*?XO{KHSrhfRYzb$Hh zz5WaZuK?+ae~~HPAarI?ayEz>!6S)EsT-6<(*!Wv6XR@0+kzomw zNW{mxjF!uoqRN>WJyXn;D0e_8do))@ z;OMf3=MBy=%zW1wYq>+%bNE*9)xVJ0AbVl%gjWqw8$L>H_;xcm!9aFH|G{(F2ihB| z^Q)L~TX$-Zh+av~nnQ*xqEr|K^YG2Gs+l3g?+CxI7p&6>M`yIcSO From ada06bda05af61a98495991065d8ee2768003083 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 13 Jan 2023 16:36:52 +0700 Subject: [PATCH 0014/1199] Rename skingrid to atlas/sprite grids --- .../otm/client/render/{SkinGrid.kt => GridAtlas.kt} | 10 +++++----- .../client/render/{SubSkinGrid.kt => GridSprite.kt} | 12 ++++++------ .../dbotthepony/mc/otm/client/render/MatteryAtlas.kt | 4 ++-- .../mc/otm/client/render/ResearchIcons.kt | 2 +- .../ru/dbotthepony/mc/otm/client/render/Widgets18.kt | 4 ++-- .../ru/dbotthepony/mc/otm/client/render/Widgets8.kt | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/render/{SkinGrid.kt => GridAtlas.kt} (86%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/render/{SubSkinGrid.kt => GridSprite.kt} (80%) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinGrid.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GridAtlas.kt similarity index 86% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinGrid.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GridAtlas.kt index f83cb71df..942fdc287 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinGrid.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GridAtlas.kt @@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.client.render import net.minecraft.resources.ResourceLocation @Suppress("unused") -data class SkinGrid( +data class GridAtlas( val texture: ResourceLocation, val width: Float, val height: Float, @@ -19,7 +19,7 @@ data class SkinGrid( val currentX: Float get() = column * width val currentY: Float get() = row * height - fun skip(): SkinGrid { + fun skip(): GridAtlas { column++ if (column >= columns) { @@ -29,7 +29,7 @@ data class SkinGrid( return this } - fun jump(): SkinGrid { + fun jump(): GridAtlas { row++ column = 0 return this @@ -41,13 +41,13 @@ data class SkinGrid( return element } - fun reset(): SkinGrid { + fun reset(): GridAtlas { row = 0 column = 0 return this } - fun seek(row: Int, column: Int): SkinGrid { + fun seek(row: Int, column: Int): GridAtlas { this.row = row this.column = column return this diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubSkinGrid.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GridSprite.kt similarity index 80% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubSkinGrid.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GridSprite.kt index ea740df7d..d4640546a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubSkinGrid.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GridSprite.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.mc.otm.client.render @Suppress("unused") -data class SubSkinGrid( +data class GridSprite( val parent: AbstractMatterySprite, val width: Float, val height: Float, @@ -14,7 +14,7 @@ data class SubSkinGrid( val currentX: Float get() = column * width val currentY: Float get() = row * height - fun skip(): SubSkinGrid { + fun skip(): GridSprite { column++ if (column >= columns) { @@ -24,7 +24,7 @@ data class SubSkinGrid( return this } - fun jump(): SubSkinGrid { + fun jump(): GridSprite { row++ column = 0 return this @@ -36,13 +36,13 @@ data class SubSkinGrid( return element } - fun reset(): SubSkinGrid { + fun reset(): GridSprite { row = 0 column = 0 return this } - fun seek(row: Int, column: Int): SubSkinGrid { + fun seek(row: Int, column: Int): GridSprite { this.row = row this.column = column return this @@ -57,4 +57,4 @@ fun AbstractMatterySprite.subGrid( height: Float, columns: Int = 16, rows: Int = 16, -) = SubSkinGrid(this, width, height, columns, rows) +) = GridSprite(this, width, height, columns, rows) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt index 4a9304fa8..601ba15bb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt @@ -17,8 +17,8 @@ data class MatteryAtlas( ) = MatterySprite(texture, x = x, y = y, width = width, height = height, atlasHeight = this.height, atlasWidth = this.width, winding = winding) @Deprecated("Construct grid directly instead") - fun subGrid(rows: Int, columns: Int) = SkinGrid(texture, this.width / rows, this.height / columns, rows = rows, columns = columns) + fun subGrid(rows: Int, columns: Int) = GridAtlas(texture, this.width / rows, this.height / columns, rows = rows, columns = columns) @Deprecated("Construct grid directly instead") - fun subGrid(width: Float, height: Float, rows: Int, columns: Int) = SkinGrid(texture, width, height, rows, columns) + fun subGrid(width: Float, height: Float, rows: Int, columns: Int) = GridAtlas(texture, width, height, rows, columns) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt index 8587d4197..f71d40de4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt @@ -34,7 +34,7 @@ object ResearchIcons { val KOT = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/block/ph_kitty.png").element(0f, 0f, 32f, 32f, 32f, 32f) init { - val grid = SkinGrid(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/android_upgrades.png"), 18f, 18f, 7, 7) + val grid = GridAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/android_upgrades.png"), 18f, 18f, 7, 7) ICON_TRANSFER = grid.next() ICON_ATTACK_BOOST = grid.next() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt index d49145350..741279d5d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt @@ -1,6 +1,6 @@ package ru.dbotthepony.mc.otm.client.render -private fun makeButton(grid: SkinGrid): StretchingRectangleElement { +private fun makeButton(grid: GridAtlas): StretchingRectangleElement { val x = grid.currentX val y = grid.currentY @@ -18,7 +18,7 @@ private fun makeButton(grid: SkinGrid): StretchingRectangleElement { } object Widgets18 { - val GRID = SkinGrid(WidgetLocation.WIDGETS_18, 18f, 18f) + val GRID = GridAtlas(WidgetLocation.WIDGETS_18, 18f, 18f) val BUTTON_IDLE_STRETCHABLE = makeButton(GRID) val BUTTON_IDLE = GRID.next() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt index bd18562ab..035e66671 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt @@ -4,7 +4,7 @@ import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.OverdriveThatMatters object Widgets8 { - val GRID = SkinGrid(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets_8.png"), 8f, 8f, 64 / 8, 32 / 8) + val GRID = GridAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets_8.png"), 8f, 8f, 64 / 8, 32 / 8) val BUTTON_IDLE = GRID[0, 0] val BUTTON_HOVERED = GRID[0, 1] From 630588677560dc40692f99f9cafcd634d9318521 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 13 Jan 2023 16:38:49 +0700 Subject: [PATCH 0015/1199] More renames of element to sprite --- .../mc/otm/android/AndroidResearchType.kt | 4 +-- .../android/feature/EnderTeleporterFeature.kt | 4 +-- .../dbotthepony/mc/otm/client/MatteryGUI.kt | 8 ++--- .../client/render/AbstractMatterySprite.kt | 3 +- .../mc/otm/client/render/MatteryAtlas.kt | 6 ++-- .../mc/otm/client/render/MatterySprite.kt | 6 ++-- .../mc/otm/client/render/ResearchIcons.kt | 2 +- .../{SkinElementType.kt => SpriteType.kt} | 8 ++--- .../render/StretchingRectangleElement.kt | 18 +++++----- .../mc/otm/client/render/SubMatterySprite.kt | 6 ++-- .../mc/otm/client/render/Widgets.kt | 10 +++--- .../mc/otm/client/render/Widgets18.kt | 18 +++++----- .../client/screen/ExoPackInventoryScreen.kt | 6 ++-- .../mc/otm/client/screen/MatterPanelScreen.kt | 9 +++-- .../client/screen/panels/AbstractSlotPanel.kt | 2 +- .../client/screen/panels/BackgroundPanel.kt | 22 +++++------- .../client/screen/panels/EffectListPanel.kt | 10 +++--- .../screen/panels/EntityRendererPanel.kt | 4 +-- .../mc/otm/client/screen/panels/FramePanel.kt | 24 ++++++------- .../screen/panels/ScrollBarConstants.kt | 34 +++++++++---------- .../screen/panels/buttons/CheckBoxPanel.kt | 3 +- .../widget/HorizontalPowerGaugePanel.kt | 10 +++--- .../client/screen/widget/MatterGaugePanel.kt | 6 ++-- .../client/screen/widget/PatternGaugePanel.kt | 7 ++-- .../client/screen/widget/PowerGaugePanel.kt | 8 ++--- .../screen/widget/ProgressGaugePanel.kt | 6 ++-- .../mc/otm/compat/cos/CosmeticArmorCompat.kt | 6 ++-- 27 files changed, 117 insertions(+), 133 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/render/{SkinElementType.kt => SpriteType.kt} (97%) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt index cc4cf4670..7d400ffb5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt @@ -22,7 +22,7 @@ import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.level.ItemLike import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite -import ru.dbotthepony.mc.otm.client.render.SkinElementType +import ru.dbotthepony.mc.otm.client.render.SpriteType import ru.dbotthepony.mc.otm.core.ListSet import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.isActuallyEmpty @@ -102,7 +102,7 @@ class AndroidResearchType( val resolvedSkinIcon by lazy { check(isClient) { "Invalid realm" } if (skinIcon != null) - SkinElementType.fromJson(skinIcon) + SpriteType.fromJson(skinIcon) else null } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt index d2805f377..453e38637 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt @@ -34,7 +34,7 @@ import ru.dbotthepony.mc.otm.capability.extractEnergyInnerExact import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.render.ResearchIcons -import ru.dbotthepony.mc.otm.client.render.element +import ru.dbotthepony.mc.otm.client.render.sprite import ru.dbotthepony.mc.otm.client.render.linesIgnoreZRenderType import ru.dbotthepony.mc.otm.core.Vector import ru.dbotthepony.mc.otm.core.asVector @@ -394,7 +394,7 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv private val SHAPE_CHECK_NOT_FENCE = Block.box(6.0, 17.0, 6.0, 10.0, 31.0, 10.0) private val SHAPE_CHECK_SUPPORT_PLAYER = Block.box(6.0, 0.0, 6.0, 10.0, 16.0, 10.0) - val SPRITE = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/item/black_hole.png").element(0f, 0f, 16f, 16f, 16f, 16f) + val SPRITE = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/item/black_hole.png").sprite(0f, 0f, 16f, 16f, 16f, 16f) val POWER_COST_DESCRIPTION = AndroidResearchManager.descriptionFunc( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index a7f6ddbfc..9e91f0ade 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -29,11 +29,11 @@ import kotlin.math.ceil object MatteryGUI { private val BARS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/player_bars.png"), 80f, 35f) - val CHARGE = BARS.subElement(height = 9f) - val CHARGE_BG = BARS.subElement(y = 9f, height = 9f) + val CHARGE = BARS.sprite(height = 9f) + val CHARGE_BG = BARS.sprite(y = 9f, height = 9f) - val CHARGE_HUNGER = BARS.subElement(y = 18f, height = 9f) - val CHARGE_HUNGER_BG = BARS.subElement(y = 27f, height = 9f) + val CHARGE_HUNGER = BARS.sprite(y = 18f, height = 9f) + val CHARGE_HUNGER_BG = BARS.sprite(y = 27f, height = 9f) private var originalBedButtonX = -1 private var originalBedButtonY = -1 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt index 02435dc3e..55cb45618 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt @@ -14,7 +14,6 @@ import net.minecraft.resources.ResourceLocation import org.lwjgl.opengl.GL11.GL_ALWAYS import ru.dbotthepony.mc.otm.core.RGBAColor import ru.dbotthepony.mc.otm.core.linearInterpolation -import java.lang.ref.WeakReference import java.util.concurrent.ConcurrentHashMap sealed class AbstractMatterySprite { @@ -43,7 +42,7 @@ sealed class AbstractMatterySprite { return v0 + (offset / height) * (v1 - v0) } - abstract val type: SkinElementType + abstract val type: SpriteType open val winding: UVWindingOrder get() = UVWindingOrder.NORMAL diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt index 601ba15bb..9052dcdae 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt @@ -8,7 +8,7 @@ data class MatteryAtlas( val height: Float, val winding: UVWindingOrder = UVWindingOrder.NORMAL, ) { - fun subElement( + fun sprite( x: Float = 0f, y: Float = 0f, width: Float = this.width, @@ -17,8 +17,8 @@ data class MatteryAtlas( ) = MatterySprite(texture, x = x, y = y, width = width, height = height, atlasHeight = this.height, atlasWidth = this.width, winding = winding) @Deprecated("Construct grid directly instead") - fun subGrid(rows: Int, columns: Int) = GridAtlas(texture, this.width / rows, this.height / columns, rows = rows, columns = columns) + fun grid(rows: Int, columns: Int) = GridAtlas(texture, this.width / rows, this.height / columns, rows = rows, columns = columns) @Deprecated("Construct grid directly instead") - fun subGrid(width: Float, height: Float, rows: Int, columns: Int) = GridAtlas(texture, width, height, rows, columns) + fun grid(width: Float, height: Float, rows: Int, columns: Int) = GridAtlas(texture, width, height, rows, columns) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt index 352afb437..980a6f166 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.client.render import net.minecraft.resources.ResourceLocation -fun ResourceLocation.element( +fun ResourceLocation.sprite( x: Float, y: Float, width: Float, @@ -62,7 +62,7 @@ data class MatterySprite @JvmOverloads constructor( override val u1 = (this.x + width) / atlasWidth override val v1 = (this.y + height) / atlasHeight - override val type: SkinElementType - get() = SkinElementType.SINGLE + override val type: SpriteType + get() = SpriteType.SINGLE } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt index f71d40de4..f043c2c74 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt @@ -31,7 +31,7 @@ object ResearchIcons { val ICON_EXTENDED_REACH: AbstractMatterySprite val ICON_PHANTOM_ATTRACTOR: AbstractMatterySprite - val KOT = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/block/ph_kitty.png").element(0f, 0f, 32f, 32f, 32f, 32f) + val KOT = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/block/ph_kitty.png").sprite(0f, 0f, 32f, 32f, 32f, 32f) init { val grid = GridAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/android_upgrades.png"), 18f, 18f, 7, 7) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElementType.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SpriteType.kt similarity index 97% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElementType.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SpriteType.kt index a672e32ab..677e6a132 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElementType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SpriteType.kt @@ -7,7 +7,7 @@ import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.core.set -enum class SkinElementType { +enum class SpriteType { SINGLE { override fun toJson(value: AbstractMatterySprite): JsonObject { require(value is MatterySprite) { "Invalid skin element provided, expected SkinElement, got ${value::class.qualifiedName}" } @@ -63,7 +63,7 @@ enum class SkinElementType { return MatterySprite(ResourceLocation.tryParse(texture) ?: throw JsonSyntaxException("Invalid resource location: $texture"), x, y, width, height, imageWidth, imageHeight, UVWindingOrder.valueOf(winding)) } }, - SUBELEMENT { + SUBSPRITE { override fun toJson(value: AbstractMatterySprite): JsonObject { require(value is SubMatterySprite) { "Invalid skin element provided, expected SubSkinElement, got ${value::class.qualifiedName}" } @@ -125,12 +125,12 @@ enum class SkinElementType { companion object { fun fromNetwork(buff: FriendlyByteBuf): AbstractMatterySprite { - val type = buff.readEnum(SkinElementType::class.java) + val type = buff.readEnum(SpriteType::class.java) return type.fromNetwork(buff) } fun fromJson(element: JsonObject): AbstractMatterySprite { - val type = SkinElementType.valueOf(element["type"].asString) + val type = SpriteType.valueOf(element["type"].asString) return type.fromJson(element) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/StretchingRectangleElement.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/StretchingRectangleElement.kt index 4af924f63..971011285 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/StretchingRectangleElement.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/StretchingRectangleElement.kt @@ -60,8 +60,8 @@ data class StretchingRectangleElement( val padding = sideThickness - innerThickness return StretchingRectangleElement( - topLeft = texture.element(x, y, cornerWidth, cornerHeight, imageWidth, imageHeight), - topRight = texture.element( + topLeft = texture.sprite(x, y, cornerWidth, cornerHeight, imageWidth, imageHeight), + topRight = texture.sprite( x + width - cornerWidth, y, cornerWidth, @@ -69,7 +69,7 @@ data class StretchingRectangleElement( imageWidth, imageHeight ), - bottomLeft = texture.element( + bottomLeft = texture.sprite( x, y + height - cornerHeight, cornerWidth, @@ -77,7 +77,7 @@ data class StretchingRectangleElement( imageWidth, imageHeight ), - bottomRight = texture.element( + bottomRight = texture.sprite( x + width - cornerWidth, y + height - cornerHeight, cornerWidth, @@ -86,7 +86,7 @@ data class StretchingRectangleElement( imageHeight ), - top = texture.element( + top = texture.sprite( x + cornerWidth, y, width - cornerWidth * 2f, @@ -94,7 +94,7 @@ data class StretchingRectangleElement( imageWidth, imageHeight ), - bottom = texture.element( + bottom = texture.sprite( x + cornerWidth, y + height - sideThickness, width - cornerWidth * 2f, @@ -102,8 +102,8 @@ data class StretchingRectangleElement( imageWidth, imageHeight ), - left = texture.element(x, y, sideThickness, height - cornerHeight * 2f, imageWidth, imageHeight), - right = texture.element( + left = texture.sprite(x, y, sideThickness, height - cornerHeight * 2f, imageWidth, imageHeight), + right = texture.sprite( x, y + width - sideThickness, sideThickness, @@ -112,7 +112,7 @@ data class StretchingRectangleElement( imageHeight ), - middle = texture.element( + middle = texture.sprite( x + innerThickness, y + innerThickness, width - innerThickness * 2f, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubMatterySprite.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubMatterySprite.kt index 08b60e242..4dbdf4087 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubMatterySprite.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubMatterySprite.kt @@ -18,8 +18,8 @@ class SubMatterySprite( override val texture: ResourceLocation get() = parent.texture - override val type: SkinElementType - get() = SkinElementType.SUBELEMENT + override val type: SpriteType + get() = SpriteType.SUBSPRITE override val winding: UVWindingOrder get() = overrideWinding ?: parent.winding @@ -33,7 +33,7 @@ class SubMatterySprite( ) = SubMatterySprite(parent, xOffset, yOffset, width, height, overrideWinding) } -fun AbstractMatterySprite.subElement( +fun AbstractMatterySprite.sprite( x: Float = 0f, y: Float = 0f, width: Float = this.width, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets.kt index 3a23df616..5248b2d71 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets.kt @@ -1,12 +1,12 @@ package ru.dbotthepony.mc.otm.client.render object Widgets { - val SLOT = WidgetLocation.MISC.subElement(0f, 0f, 18f, 18f) + val SLOT = WidgetLocation.MISC.sprite(0f, 0f, 18f, 18f) - val ARROW_UP_BUTTON_IDLE = WidgetLocation.MISC.subElement(0f, 18f, 18f, 6f) - val ARROW_UP_BUTTON_HOVERED = WidgetLocation.MISC.subElement(0f, 18f + 6f, 18f, 6f) - val ARROW_UP_BUTTON_PRESSED = WidgetLocation.MISC.subElement(0f, 18f + 6f * 2f, 18f, 6f) - val ARROW_UP_BUTTON_DISABLED = WidgetLocation.MISC.subElement(0f, 18f + 6f * 3f, 18f, 6f) + val ARROW_UP_BUTTON_IDLE = WidgetLocation.MISC.sprite(0f, 18f, 18f, 6f) + val ARROW_UP_BUTTON_HOVERED = WidgetLocation.MISC.sprite(0f, 18f + 6f, 18f, 6f) + val ARROW_UP_BUTTON_PRESSED = WidgetLocation.MISC.sprite(0f, 18f + 6f * 2f, 18f, 6f) + val ARROW_UP_BUTTON_DISABLED = WidgetLocation.MISC.sprite(0f, 18f + 6f * 3f, 18f, 6f) val ARROW_DOWN_BUTTON_IDLE = ARROW_UP_BUTTON_IDLE.copy(winding = UVWindingOrder.FLIP) val ARROW_DOWN_BUTTON_HOVERED = ARROW_UP_BUTTON_HOVERED.copy(winding = UVWindingOrder.FLIP) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt index 741279d5d..84cde28be 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt @@ -5,15 +5,15 @@ private fun makeButton(grid: GridAtlas): StretchingRectangleElement { val y = grid.currentY return StretchingRectangleElement( - topLeft = WidgetLocation.WIDGETS_18.element(x, y, 2f, 2f, grid.atlasWidth, grid.atlasHeight), - topRight = WidgetLocation.WIDGETS_18.element(x + 16f, y, 2f, 2f, grid.atlasWidth, grid.atlasHeight), - bottomLeft = WidgetLocation.WIDGETS_18.element(x, y + 16f, 2f, 2f, grid.atlasWidth, grid.atlasHeight), - bottomRight = WidgetLocation.WIDGETS_18.element(x + 16f, y + 16f, 2f, 2f, grid.atlasWidth, grid.atlasHeight), - middle = WidgetLocation.WIDGETS_18.element(x + 2f, y + 2f, 14f, 14f, grid.atlasWidth, grid.atlasHeight), - top = WidgetLocation.WIDGETS_18.element(x + 2f, y, 14f, 2f, grid.atlasWidth, grid.atlasHeight), - left = WidgetLocation.WIDGETS_18.element(x, y + 2f, 2f, 14f, grid.atlasWidth, grid.atlasHeight), - right = WidgetLocation.WIDGETS_18.element(x + 16f, y + 2f, 2f, 14f, grid.atlasWidth, grid.atlasHeight), - bottom = WidgetLocation.WIDGETS_18.element(x + 2f, y + 16f, 14f, 2f, grid.atlasWidth, grid.atlasHeight), + topLeft = WidgetLocation.WIDGETS_18.sprite(x, y, 2f, 2f, grid.atlasWidth, grid.atlasHeight), + topRight = WidgetLocation.WIDGETS_18.sprite(x + 16f, y, 2f, 2f, grid.atlasWidth, grid.atlasHeight), + bottomLeft = WidgetLocation.WIDGETS_18.sprite(x, y + 16f, 2f, 2f, grid.atlasWidth, grid.atlasHeight), + bottomRight = WidgetLocation.WIDGETS_18.sprite(x + 16f, y + 16f, 2f, 2f, grid.atlasWidth, grid.atlasHeight), + middle = WidgetLocation.WIDGETS_18.sprite(x + 2f, y + 2f, 14f, 14f, grid.atlasWidth, grid.atlasHeight), + top = WidgetLocation.WIDGETS_18.sprite(x + 2f, y, 14f, 2f, grid.atlasWidth, grid.atlasHeight), + left = WidgetLocation.WIDGETS_18.sprite(x, y + 2f, 2f, 14f, grid.atlasWidth, grid.atlasHeight), + right = WidgetLocation.WIDGETS_18.sprite(x + 16f, y + 2f, 2f, 14f, grid.atlasWidth, grid.atlasHeight), + bottom = WidgetLocation.WIDGETS_18.sprite(x + 2f, y + 16f, 14f, 2f, grid.atlasWidth, grid.atlasHeight), ) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt index 9489bb4b4..3f5456b3e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt @@ -6,7 +6,7 @@ import ru.dbotthepony.mc.otm.client.mousePos import ru.dbotthepony.mc.otm.client.moveMousePosScaled import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.client.render.element +import ru.dbotthepony.mc.otm.client.render.sprite import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.LargeRectangleButtonPanel import ru.dbotthepony.mc.otm.client.setMousePos @@ -206,8 +206,8 @@ class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen> @JvmOverloads constru val SLOT_HIGHLIGHT = RGBAColor(255, 255, 255, 100) val SLOT_HIGHLIGHT_DRAG = RGBAColor(200, 200, 200, 150) const val SIZE = 18f - val SLOT_BACKGROUND = WidgetLocation.MISC.subElement(0f, 0f, SIZE, SIZE) + val SLOT_BACKGROUND = WidgetLocation.MISC.sprite(0f, 0f, SIZE, SIZE) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/BackgroundPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/BackgroundPanel.kt index 34cbe3a26..4ab428291 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/BackgroundPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/BackgroundPanel.kt @@ -2,12 +2,8 @@ package ru.dbotthepony.mc.otm.client.screen.panels import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen -import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen import ru.dbotthepony.mc.otm.client.render.StretchingRectangleElement import ru.dbotthepony.mc.otm.client.render.WidgetLocation -import ru.dbotthepony.mc.otm.client.render.element -import ru.dbotthepony.mc.otm.client.render.subElement -import ru.dbotthepony.mc.otm.client.screen.MatteryScreen open class BackgroundPanel( screen: S, @@ -45,15 +41,15 @@ open class BackgroundPanel( ) = BackgroundPanel(screen, parent, x - 3f, y - 3f, width + 6f, height + 6f) val RECTANGLE = StretchingRectangleElement( - topLeft = WidgetLocation.MISC.subElement(18f, 24f, 3f, 3f), - topRight = WidgetLocation.MISC.subElement(27f, 24f, 3f, 3f), - bottomLeft = WidgetLocation.MISC.subElement(18f, 33f, 3f, 3f), - bottomRight = WidgetLocation.MISC.subElement(27f, 33f, 3f, 3f), - top = WidgetLocation.MISC.subElement(21f, 24f, 6f, 2f), - bottom = WidgetLocation.MISC.subElement(21f, 34f, 6f, 2f), - left = WidgetLocation.MISC.subElement(18f, 27f, 2f, 6f), - right = WidgetLocation.MISC.subElement(28f, 27f, 2f, 6f), - middle = WidgetLocation.MISC.subElement(30f, 12f, 6f, 6f), + topLeft = WidgetLocation.MISC.sprite(18f, 24f, 3f, 3f), + topRight = WidgetLocation.MISC.sprite(27f, 24f, 3f, 3f), + bottomLeft = WidgetLocation.MISC.sprite(18f, 33f, 3f, 3f), + bottomRight = WidgetLocation.MISC.sprite(27f, 33f, 3f, 3f), + top = WidgetLocation.MISC.sprite(21f, 24f, 6f, 2f), + bottom = WidgetLocation.MISC.sprite(21f, 34f, 6f, 2f), + left = WidgetLocation.MISC.sprite(18f, 27f, 2f, 6f), + right = WidgetLocation.MISC.sprite(28f, 27f, 2f, 6f), + middle = WidgetLocation.MISC.sprite(30f, 12f, 6f, 6f), padding = DockProperty(-1f, -1f, -1f, -1f) ) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt index 97924708c..e9292ea60 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt @@ -14,7 +14,7 @@ import ru.dbotthepony.mc.otm.client.render.TextAlign import ru.dbotthepony.mc.otm.client.render.determineTooltipPosition import ru.dbotthepony.mc.otm.client.render.drawAligned import ru.dbotthepony.mc.otm.client.render.drawScaledAligned -import ru.dbotthepony.mc.otm.client.render.element +import ru.dbotthepony.mc.otm.client.render.sprite import ru.dbotthepony.mc.otm.client.render.render import ru.dbotthepony.mc.otm.core.RGBAColor import ru.dbotthepony.mc.otm.core.TranslatableComponent @@ -266,9 +266,9 @@ open class EffectListPanel @JvmOverloads constructor( } companion object { - val BAR = AbstractContainerScreen.INVENTORY_LOCATION.element(0f, 166f, 120f, 32f) - val SQUARE = AbstractContainerScreen.INVENTORY_LOCATION.element(0f, 198f, 32f, 32f) - val SQUARE_THIN = AbstractContainerScreen.INVENTORY_LOCATION.element(141f, 166f, 24f, 24f) - val SQUARE_THIN_HIGHLIGHT = AbstractContainerScreen.INVENTORY_LOCATION.element(165f, 166f, 24f, 24f) + val BAR = AbstractContainerScreen.INVENTORY_LOCATION.sprite(0f, 166f, 120f, 32f) + val SQUARE = AbstractContainerScreen.INVENTORY_LOCATION.sprite(0f, 198f, 32f, 32f) + val SQUARE_THIN = AbstractContainerScreen.INVENTORY_LOCATION.sprite(141f, 166f, 24f, 24f) + val SQUARE_THIN_HIGHLIGHT = AbstractContainerScreen.INVENTORY_LOCATION.sprite(165f, 166f, 24f, 24f) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt index d38d25977..179c7d261 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt @@ -8,7 +8,7 @@ import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.player.Player import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.render.Widgets8 -import ru.dbotthepony.mc.otm.client.render.element +import ru.dbotthepony.mc.otm.client.render.sprite import ru.dbotthepony.mc.otm.client.screen.ExoPackInventoryScreen import ru.dbotthepony.mc.otm.client.screen.panels.buttons.SmallBooleanRectangleButtonPanel import ru.dbotthepony.mc.otm.compat.cos.CosmeticToggleRenderButton @@ -127,6 +127,6 @@ class EntityRendererPanel @JvmOverloads constructor( } companion object { - val ENTITY_RECTANGLE = AbstractContainerScreen.INVENTORY_LOCATION.element(25f, 7f, 51f, 72f) + val ENTITY_RECTANGLE = AbstractContainerScreen.INVENTORY_LOCATION.sprite(25f, 7f, 51f, 72f) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index fc9688dd9..1eb70ae8b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -232,21 +232,21 @@ open class FramePanel( const val PADDING_TOP = 14f val RECTANGLE = StretchingRectangleElement( - topLeft = WidgetLocation.MISC.subElement(x = 18f, y = 0f, width = 6f, height = 6f), - topRight = WidgetLocation.MISC.subElement(x = 24f, y = 0f, width = 6f, height = 6f), - left = WidgetLocation.MISC.subElement(x = 18f, y = 4f, width = 3f, height = 5f), - right = WidgetLocation.MISC.subElement(x = 25f, y = 3f, width = 5f, height = 5f), - top = WidgetLocation.MISC.subElement(x = 22f, y = 0f, width = 5f, height = 3f), - bottomLeft = WidgetLocation.MISC.subElement(x = 18f, y = 6f, width = 6f, height = 6f), - bottomRight = WidgetLocation.MISC.subElement(x = 24f, y = 6f, width = 6f, height = 6f), - bottom = WidgetLocation.MISC.subElement(x = 21f, y = 9f, width = 5f, height = 3f), - middle = WidgetLocation.MISC.subElement(x = 30f, y = 12f, width = 6f, height = 6f), + topLeft = WidgetLocation.MISC.sprite(x = 18f, y = 0f, width = 6f, height = 6f), + topRight = WidgetLocation.MISC.sprite(x = 24f, y = 0f, width = 6f, height = 6f), + left = WidgetLocation.MISC.sprite(x = 18f, y = 4f, width = 3f, height = 5f), + right = WidgetLocation.MISC.sprite(x = 25f, y = 3f, width = 5f, height = 5f), + top = WidgetLocation.MISC.sprite(x = 22f, y = 0f, width = 5f, height = 3f), + bottomLeft = WidgetLocation.MISC.sprite(x = 18f, y = 6f, width = 6f, height = 6f), + bottomRight = WidgetLocation.MISC.sprite(x = 24f, y = 6f, width = 6f, height = 6f), + bottom = WidgetLocation.MISC.sprite(x = 21f, y = 9f, width = 5f, height = 3f), + middle = WidgetLocation.MISC.sprite(x = 30f, y = 12f, width = 6f, height = 6f), padding = DockProperty(-3f, -3f, -3f, -3f) ) - val TAB_RIGHT_CONNECTION = WidgetLocation.MISC.subElement(x = 30f, y = 0f, width = 3f, height = 5f) - val TAB_LEFT_CONNECTION = WidgetLocation.MISC.subElement(x = 33f, y = 0f, width = 3f, height = 5f) - val TAB_BACKGROUND = WidgetLocation.MISC.subElement(x = 30f, y = 6f, width = 6f, height = 6f) + val TAB_RIGHT_CONNECTION = WidgetLocation.MISC.sprite(x = 30f, y = 0f, width = 3f, height = 5f) + val TAB_LEFT_CONNECTION = WidgetLocation.MISC.sprite(x = 33f, y = 0f, width = 3f, height = 5f) + val TAB_BACKGROUND = WidgetLocation.MISC.sprite(x = 30f, y = 6f, width = 6f, height = 6f) const val TAB_HEIGHT = 28f const val TAB_WIDTH = 28f diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ScrollBarConstants.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ScrollBarConstants.kt index f30839f85..e9473e0a6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ScrollBarConstants.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ScrollBarConstants.kt @@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.client.render.MatteryAtlas -import ru.dbotthepony.mc.otm.client.render.subElement +import ru.dbotthepony.mc.otm.client.render.sprite object ScrollBarConstants { const val WIDTH = 14f @@ -12,24 +12,24 @@ object ScrollBarConstants { val NORMAL_ATLAS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/scrollbar.png"), 62f, 15f) val SLIM_ATLAS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/scrollbar_slim.png"), 32f, 15f) - val BACKGROUND = NORMAL_ATLAS.subElement(width = 14f, height = 8f) - val BACKGROUND_SLIM = SLIM_ATLAS.subElement(width = 8f, height = 8f) + val BACKGROUND = NORMAL_ATLAS.sprite(width = 14f, height = 8f) + val BACKGROUND_SLIM = SLIM_ATLAS.sprite(width = 8f, height = 8f) - val TOP = BACKGROUND.subElement(height = 2f) - val BODY = BACKGROUND.subElement(y = 2f, height = 5f) - val BOTTOM = BACKGROUND.subElement(y = 6f, height = 2f) + val TOP = BACKGROUND.sprite(height = 2f) + val BODY = BACKGROUND.sprite(y = 2f, height = 5f) + val BOTTOM = BACKGROUND.sprite(y = 6f, height = 2f) - val BUTTON = NORMAL_ATLAS.subElement(x = 15f, width = 12f) - val BUTTON_HOVER = NORMAL_ATLAS.subElement(x = 15f + 12f, width = 12f) - val BUTTON_PRESS = NORMAL_ATLAS.subElement(x = 15f + 12f * 2f, width = 12f) - val BUTTON_DISABLED = NORMAL_ATLAS.subElement(x = 15f + 12f * 3f, width = 12f) + val BUTTON = NORMAL_ATLAS.sprite(x = 15f, width = 12f) + val BUTTON_HOVER = NORMAL_ATLAS.sprite(x = 15f + 12f, width = 12f) + val BUTTON_PRESS = NORMAL_ATLAS.sprite(x = 15f + 12f * 2f, width = 12f) + val BUTTON_DISABLED = NORMAL_ATLAS.sprite(x = 15f + 12f * 3f, width = 12f) - val SLIM_TOP = BACKGROUND_SLIM.subElement(height = 2f) - val SLIM_BODY = BACKGROUND_SLIM.subElement(y = 2f, height = 5f) - val SLIM_BOTTOM = BACKGROUND_SLIM.subElement(y = 6f, height = 2f) + val SLIM_TOP = BACKGROUND_SLIM.sprite(height = 2f) + val SLIM_BODY = BACKGROUND_SLIM.sprite(y = 2f, height = 5f) + val SLIM_BOTTOM = BACKGROUND_SLIM.sprite(y = 6f, height = 2f) - val SLIM_BUTTON = SLIM_ATLAS.subElement(x = 9f, width = 6f) - val SLIM_BUTTON_HOVER = SLIM_ATLAS.subElement(x = 9f + 6f, width = 6f) - val SLIM_BUTTON_PRESS = SLIM_ATLAS.subElement(x = 9f + 6f * 2f, width = 6f) - val SLIM_BUTTON_DISABLED = SLIM_ATLAS.subElement(x = 9f + 6f * 3f, width = 6f) + val SLIM_BUTTON = SLIM_ATLAS.sprite(x = 9f, width = 6f) + val SLIM_BUTTON_HOVER = SLIM_ATLAS.sprite(x = 9f + 6f, width = 6f) + val SLIM_BUTTON_PRESS = SLIM_ATLAS.sprite(x = 9f + 6f * 2f, width = 6f) + val SLIM_BUTTON_DISABLED = SLIM_ATLAS.sprite(x = 9f + 6f * 3f, width = 6f) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxPanel.kt index bbd0e6415..1e9e8b4af 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxPanel.kt @@ -6,7 +6,6 @@ import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.WidgetLocation -import ru.dbotthepony.mc.otm.client.render.subGrid import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel open class CheckBoxPanel @JvmOverloads constructor( @@ -91,7 +90,7 @@ open class CheckBoxPanel @JvmOverloads constructor( val DISABLED_CHECKED: AbstractMatterySprite init { - val grid = WidgetLocation.CHECKBOX.subGrid(columns = 2, rows = 4) + val grid = WidgetLocation.CHECKBOX.grid(columns = 2, rows = 4) IDLE_UNCHECKED = grid.next() IDLE_CHECKED = grid.next() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt index 2d27ff716..2cf60554e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt @@ -4,8 +4,6 @@ import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.WidgetLocation -import ru.dbotthepony.mc.otm.client.render.element -import ru.dbotthepony.mc.otm.client.render.subElement import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget @@ -45,11 +43,11 @@ open class HorizontalPowerGaugePanel( } companion object { - val GAUGE_BACKGROUND_TALL = WidgetLocation.HORIZONTAL_GAUGES.subElement(width = 96f, height = 18f) - val GAUGE_FOREGROUND_TALL = WidgetLocation.HORIZONTAL_GAUGES.subElement(y = 18f, width = 96f, height = 18f) + val GAUGE_BACKGROUND_TALL = WidgetLocation.HORIZONTAL_GAUGES.sprite(width = 96f, height = 18f) + val GAUGE_FOREGROUND_TALL = WidgetLocation.HORIZONTAL_GAUGES.sprite(y = 18f, width = 96f, height = 18f) - val GAUGE_BACKGROUND = WidgetLocation.HORIZONTAL_GAUGES.subElement(y = 36f, width = 96f, height = 9f) - val GAUGE_FOREGROUND = WidgetLocation.HORIZONTAL_GAUGES.subElement(y = 45f, width = 96f, height = 9f) + val GAUGE_BACKGROUND = WidgetLocation.HORIZONTAL_GAUGES.sprite(y = 36f, width = 96f, height = 9f) + val GAUGE_FOREGROUND = WidgetLocation.HORIZONTAL_GAUGES.sprite(y = 45f, width = 96f, height = 9f) } } 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 9c7980c41..18efc0375 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 @@ -10,8 +10,6 @@ import net.minecraft.client.renderer.GameRenderer import net.minecraft.network.chat.Component import org.lwjgl.opengl.GL11 import ru.dbotthepony.mc.otm.client.render.WidgetLocation -import ru.dbotthepony.mc.otm.client.render.element -import ru.dbotthepony.mc.otm.client.render.subElement import ru.dbotthepony.mc.otm.client.render.tesselator import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.TranslatableComponent @@ -118,7 +116,7 @@ open class MatterGaugePanel @JvmOverloads constructor( } companion object { - val GAUGE_BACKGROUND = WidgetLocation.VERTICAL_GAUGES.subElement(x = 18f, width = 9f) - val GAUGE_FOREGROUND = WidgetLocation.VERTICAL_GAUGES.subElement(x = 27f, width = 9f) + val GAUGE_BACKGROUND = WidgetLocation.VERTICAL_GAUGES.sprite(x = 18f, width = 9f) + val GAUGE_FOREGROUND = WidgetLocation.VERTICAL_GAUGES.sprite(x = 27f, width = 9f) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PatternGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PatternGaugePanel.kt index 3fe2eb7f6..69ceb56f2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PatternGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PatternGaugePanel.kt @@ -3,10 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.widget import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component -import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.WidgetLocation -import ru.dbotthepony.mc.otm.client.render.element -import ru.dbotthepony.mc.otm.client.render.subElement import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget @@ -48,7 +45,7 @@ open class PatternGaugePanel @JvmOverloads constructor( } companion object { - val GAUGE_BACKGROUND = WidgetLocation.VERTICAL_GAUGES.subElement(width = 9f) - val GAUGE_FOREGROUND = WidgetLocation.VERTICAL_GAUGES.subElement(x = 9f, width = 9f) + val GAUGE_BACKGROUND = WidgetLocation.VERTICAL_GAUGES.sprite(width = 9f) + val GAUGE_FOREGROUND = WidgetLocation.VERTICAL_GAUGES.sprite(x = 9f, width = 9f) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt index ec2bab3ab..5cf9f63a3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt @@ -61,11 +61,11 @@ open class PowerGaugePanel @JvmOverloads constructor( } companion object { - val GAUGE_BACKGROUND = WidgetLocation.VERTICAL_GAUGES.subElement(x = 36f, width = 9f) - val GAUGE_FOREGROUND = WidgetLocation.VERTICAL_GAUGES.subElement(x = 45f, width = 9f) + val GAUGE_BACKGROUND = WidgetLocation.VERTICAL_GAUGES.sprite(x = 36f, width = 9f) + val GAUGE_FOREGROUND = WidgetLocation.VERTICAL_GAUGES.sprite(x = 45f, width = 9f) - val GAUGE_BACKGROUND_WIDE = WidgetLocation.VERTICAL_GAUGES.subElement(x = 54f, width = 18f) - val GAUGE_FOREGROUND_WIDE = WidgetLocation.VERTICAL_GAUGES.subElement(x = 72f, width = 18f) + val GAUGE_BACKGROUND_WIDE = WidgetLocation.VERTICAL_GAUGES.sprite(x = 54f, width = 18f) + val GAUGE_FOREGROUND_WIDE = WidgetLocation.VERTICAL_GAUGES.sprite(x = 72f, width = 18f) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt index 5b157ea43..bd54da6eb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt @@ -7,8 +7,6 @@ import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.WidgetLocation -import ru.dbotthepony.mc.otm.client.render.element -import ru.dbotthepony.mc.otm.client.render.subElement import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget @@ -80,7 +78,7 @@ open class ProgressGaugePanel @JvmOverloads constructor( } companion object { - val GAUGE_BACKGROUND = WidgetLocation.PROGRESS_ARROWS.subElement(y = 0f, width = 22f, height = 15f) - val GAUGE_FOREGROUND = WidgetLocation.PROGRESS_ARROWS.subElement(y = 15f, width = 22f, height = 15f) + val GAUGE_BACKGROUND = WidgetLocation.PROGRESS_ARROWS.sprite(y = 0f, width = 22f, height = 15f) + val GAUGE_FOREGROUND = WidgetLocation.PROGRESS_ARROWS.sprite(y = 15f, width = 22f, height = 15f) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt index ced32ebc1..c7d053404 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt @@ -18,7 +18,7 @@ import net.minecraft.world.item.ItemStack import net.minecraftforge.fml.ModList import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.MatterySprite -import ru.dbotthepony.mc.otm.client.render.element +import ru.dbotthepony.mc.otm.client.render.sprite import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.buttons.RectangleButtonPanel import ru.dbotthepony.mc.otm.compat.cos.CosmeticToggleButton.Companion.BUTTON_ACTIVE @@ -185,8 +185,8 @@ class CosmeticToggleButton( } companion object { - val BUTTON_INACTIVE = GuiCosArmorInventory.TEXTURE.element(0f, 176f, 5f, 5f) - val BUTTON_ACTIVE = GuiCosArmorInventory.TEXTURE.element(5f, 176f, 5f, 5f) + val BUTTON_INACTIVE = GuiCosArmorInventory.TEXTURE.sprite(0f, 176f, 5f, 5f) + val BUTTON_ACTIVE = GuiCosArmorInventory.TEXTURE.sprite(5f, 176f, 5f, 5f) } } From 027b4bcc3d78647fccb7e92caef1707d4117909d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 13 Jan 2023 16:43:58 +0700 Subject: [PATCH 0016/1199] GridInSprite --- .../render/{GridSprite.kt => GridInSprite.kt} | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/render/{GridSprite.kt => GridInSprite.kt} (65%) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GridSprite.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GridInSprite.kt similarity index 65% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GridSprite.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GridInSprite.kt index d4640546a..ea03082e3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GridSprite.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GridInSprite.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.mc.otm.client.render @Suppress("unused") -data class GridSprite( +data class GridInSprite( val parent: AbstractMatterySprite, val width: Float, val height: Float, @@ -14,7 +14,7 @@ data class GridSprite( val currentX: Float get() = column * width val currentY: Float get() = row * height - fun skip(): GridSprite { + fun skip(): GridInSprite { column++ if (column >= columns) { @@ -24,37 +24,37 @@ data class GridSprite( return this } - fun jump(): GridSprite { + fun jump(): GridInSprite { row++ column = 0 return this } fun next(): AbstractMatterySprite { - val element = parent.subElement(currentX, currentY, width, height) + val element = parent.sprite(currentX, currentY, width, height) skip() return element } - fun reset(): GridSprite { + fun reset(): GridInSprite { row = 0 column = 0 return this } - fun seek(row: Int, column: Int): GridSprite { + fun seek(row: Int, column: Int): GridInSprite { this.row = row this.column = column return this } operator fun get(column: Int, row: Int) = - parent.subElement(column * width, row * height, width, height) + parent.sprite(column * width, row * height, width, height) } -fun AbstractMatterySprite.subGrid( +fun AbstractMatterySprite.grid( width: Float, height: Float, columns: Int = 16, rows: Int = 16, -) = GridSprite(this, width, height, columns, rows) +) = GridInSprite(this, width, height, columns, rows) From d403726d54c25fe23e57264926566700d6d40ec2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 13 Jan 2023 16:44:21 +0700 Subject: [PATCH 0017/1199] Update leaveBedButton SRG name --- src/main/resources/META-INF/accesstransformer.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 87431a1a8..4000db026 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -32,7 +32,7 @@ protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_9 public net.minecraft.world.item.BlockItem f_150696_ # BLOCK_ENTITY_TAG -public net.minecraft.client.gui.screens.InBedChatScreen f_242488_ # leaveBedButton +public net.minecraft.client.gui.screens.InBedChatScreen f_263129_ # leaveBedButton public net.minecraft.world.inventory.AbstractContainerMenu f_182405_ # stateId From 27c0f2274f46e87f2da45d4041625095e6136b58 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 13 Jan 2023 17:29:22 +0700 Subject: [PATCH 0018/1199] remove widget atlas from coremod injection --- src/main/resources/coremods/code_injector.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/main/resources/coremods/code_injector.js b/src/main/resources/coremods/code_injector.js index e474e4095..2a14deefa 100644 --- a/src/main/resources/coremods/code_injector.js +++ b/src/main/resources/coremods/code_injector.js @@ -899,14 +899,6 @@ function initializeCoreMod() { }, 'transformer': function(node) { - node.instructions.insert(new MethodInsnNode( - opcodesRemapped.invokestatic, - 'ru/dbotthepony/mc/otm/client/render/WidgetAtlasHolder', - 'renderGameHook', - '()V', - false - )) - // 288: invokevirtual #3558 // Method net/minecraft/client/renderer/PostChain.process:(F)V // 291: aload_0 // 292: getfield #2773 // Field minecraft:Lnet/minecraft/client/Minecraft; From b7a551cef4af0735a59a46652a4cb255695d7579 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 13 Jan 2023 17:31:10 +0700 Subject: [PATCH 0019/1199] Make it compile --- .../java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java | 4 +--- src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/OreGen.kt | 7 ++++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 1e21f8c37..fad7cc780 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -33,7 +33,6 @@ import ru.dbotthepony.mc.otm.client.model.ExosuitModel; import ru.dbotthepony.mc.otm.client.model.GravitationStabilizerModel; import ru.dbotthepony.mc.otm.client.model.TritaniumArmorModel; import ru.dbotthepony.mc.otm.client.render.ShockwaveRenderer; -import ru.dbotthepony.mc.otm.client.render.WidgetAtlasHolder; import ru.dbotthepony.mc.otm.compat.mekanism.QIOKt; import ru.dbotthepony.mc.otm.compat.mekanism.TooltipsKt; import ru.dbotthepony.mc.otm.core.Decimal; @@ -117,8 +116,7 @@ public final class OverdriveThatMatters { modBus.addListener(EventPriority.NORMAL, AndroidAbilityKeyMapping.INSTANCE::register); modBus.addListener(EventPriority.NORMAL, TritaniumArmorModel::register); modBus.addListener(EventPriority.NORMAL, GravitationStabilizerModel::register); - modBus.addListener(EventPriority.NORMAL, WidgetAtlasHolder::register); - modBus.addListener(EventPriority.NORMAL, MCreativeTabs.INSTANCE::populate); + modBus.addListener(EventPriority.NORMAL, MCreativeTabs.INSTANCE::register$overdrive_that_matters); }); ClientConfig.INSTANCE.register(); diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/OreGen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/OreGen.kt index dfc5c1c4d..aa96fb473 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/OreGen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/OreGen.kt @@ -1,6 +1,8 @@ package ru.dbotthepony.mc.otm.worldgen import net.minecraft.core.Holder +import net.minecraft.core.registries.BuiltInRegistries +import net.minecraft.core.registries.Registries import net.minecraft.data.worldgen.features.OreFeatures import net.minecraft.tags.BlockTags import net.minecraft.world.level.levelgen.VerticalAnchor @@ -31,6 +33,9 @@ object OreGen { var ORE_TRITANIUM_DEEP by WriteOnce>() fun register() { + // TODO: 1.19.3 + /*val registry = BuiltInRegistries.REGISTRY.get(Registries.CONFIGURED_FEATURE.location()) + ORE_FEATURE_TRITANIUM_NORMAL = CONFIGURED_FEATURE.register("ore_tritanium", ConfiguredFeature(Feature.ORE, OreConfiguration(ORE_TRITANIUM_TARGET_LIST, 9))) ORE_TRITANIUM_NORMAL = PLACED_FEATURE.register("ore_tritanium_normal", PlacedFeature( @@ -49,6 +54,6 @@ object OreGen { InSquarePlacement.spread(), HeightRangePlacement.uniform(VerticalAnchor.aboveBottom(8), VerticalAnchor.absolute(0)) ) - )) + ))*/ } } From afcbaf75aee75d7ba7d0ee851c8508e096eaa02d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 13 Jan 2023 17:39:47 +0700 Subject: [PATCH 0020/1199] =?UTF-8?q?=D1=87=D1=82=D0=BE=20=D0=B2=D1=8B=20?= =?UTF-8?q?=D0=BA=D1=83=D1=80=D0=B8=D0=BB=D0=B8=20mojang?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Revert "One more data provider" This reverts commit be2dcc6bae8c39b2970ff9439cc28a6d00c91158. Revert "Update datagen class" This reverts commit ee53b85aff6a268bcdc55ce4304f39f5e5193c81. --- .../ru/dbotthepony/mc/otm/datagen/DataGen.kt | 2 +- .../android/AndroidResearchDataProvider.kt | 15 ++++-------- .../mc/otm/matter/MatterDataProvider.kt | 24 +++++++++---------- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt index b58581093..fccf96442 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -406,7 +406,7 @@ object DataGen { val lootModifier = LootModifiers(event.generator) val languageProvider = MatteryLanguageProvider(event.generator) val matterData = MatterDataProvider(event) - val researchProvider = AndroidResearchDataProvider(event.generator).also { it.exec { addResearchData(it, languageProvider) } } + val researchProvider = AndroidResearchDataProvider(event.generator, MOD_ID).also { it.exec { addResearchData(it, languageProvider) } } this.blockModelProvider = blockModelProvider this.blockStateProvider = blockStateProvider diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDataProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDataProvider.kt index 74ab0d7fa..550c2a973 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDataProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDataProvider.kt @@ -4,15 +4,15 @@ import it.unimi.dsi.fastutil.objects.ObjectArraySet import net.minecraft.data.CachedOutput import net.minecraft.data.DataGenerator import net.minecraft.data.DataProvider -import net.minecraft.data.PackOutput import net.minecraft.resources.ResourceLocation import java.util.Collections import java.util.LinkedList -import java.util.concurrent.CompletableFuture import java.util.function.Consumer @Suppress("unused") -open class AndroidResearchDataProvider(protected val dataGenerator: DataGenerator, val modid: String) : DataProvider { +open class AndroidResearchDataProvider(protected val dataGenerator: DataGenerator) : DataProvider { + protected val pathProvider: DataGenerator.PathProvider = dataGenerator.createPathProvider(DataGenerator.Target.DATA_PACK, AndroidResearchManager.DIRECTORY) + protected val callbacks = LinkedList<(Consumer) -> Unit>() private val generated = LinkedList() @@ -35,18 +35,15 @@ open class AndroidResearchDataProvider(protected val dataGenerator: DataGenerato return this } - final override fun run(output: CachedOutput): CompletableFuture<*> { + final override fun run(output: CachedOutput) { AndroidResearchManager.fireRegistrationEvent() val set = ObjectArraySet() val added = LinkedList() - val futures = ArrayList>() - - val path = dataGenerator.packOutput.getOutputFolder(PackOutput.Target.DATA_PACK).resolve(modid).resolve(AndroidResearchManager.DIRECTORY) addEverything { if (set.add(it.id)) { - futures.add(DataProvider.saveStable(output, it.toJson(), path.resolve("${it.id}.json"))) + DataProvider.saveStable(output, it.toJson(), pathProvider.json(it.id)) AndroidResearchManager.put(it) added.add(it) } else { @@ -58,8 +55,6 @@ open class AndroidResearchDataProvider(protected val dataGenerator: DataGenerato value.validate() generated.add(value) } - - return CompletableFuture.allOf(*futures.toTypedArray()) } override fun getName(): String { 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 df5927d60..e2a37e01d 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 net.minecraft.data.CachedOutput import net.minecraft.data.DataGenerator 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 @@ -12,13 +11,13 @@ import net.minecraftforge.data.event.GatherDataEvent import ru.dbotthepony.mc.otm.core.Decimal import ru.dbotthepony.mc.otm.core.registryName import java.util.Collections -import java.util.concurrent.CompletableFuture import java.util.function.Consumer @Suppress("FunctionName", "unused") -open class MatterDataProvider(protected val dataGenerator: DataGenerator, val modid: String) : DataProvider { +open class MatterDataProvider(protected val dataGenerator: DataGenerator, val namespace: String?) : DataProvider { constructor(event: GatherDataEvent) : this(event.generator, event.modContainer.namespace) + protected val pathProvider: DataGenerator.PathProvider = dataGenerator.createPathProvider(DataGenerator.Target.DATA_PACK, MatterManager.MATTER_DIRECTORY) protected val actions = LinkedHashMap() sealed class Configuration(val name: ResourceLocation) { @@ -912,10 +911,14 @@ open class MatterDataProvider(protected val dataGenerator: DataGenerator, val mo } protected fun updateLocation(input: ResourceLocation, prefix: String): ResourceLocation { - if (input.namespace == modid) { - return ResourceLocation(input.namespace, prefix + input.path) + if (namespace != null) { + if (input.namespace == namespace) { + return ResourceLocation(input.namespace, prefix + input.path) + } else { + return ResourceLocation(namespace, prefix + input.namespace + "/" + input.path) + } } else { - return ResourceLocation(modid, prefix + input.namespace + "/" + input.path) + return ResourceLocation(input.namespace, prefix + input.path) } } @@ -1201,18 +1204,13 @@ open class MatterDataProvider(protected val dataGenerator: DataGenerator, val mo protected val added = ArrayList() val addedView: List = Collections.unmodifiableList(added) - final override fun run(output: CachedOutput): CompletableFuture<*> { + final override fun run(output: CachedOutput) { addActions() - val promises = ArrayList>() - val path = dataGenerator.packOutput.getOutputFolder(PackOutput.Target.DATA_PACK).resolve(modid).resolve(MatterManager.MATTER_DIRECTORY) - for ((key, value) in actions) { - promises.add(DataProvider.saveStable(output, value.toJson(), path.resolve("$key.json"))) + DataProvider.saveStable(output, value.toJson(), pathProvider.json(key)) added.add(value) } - - return CompletableFuture.allOf(*promises.toTypedArray()) } override fun getName(): String { From a8a01702ca9e44186a8c211987cfd53250278657 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 13 Jan 2023 17:52:32 +0700 Subject: [PATCH 0021/1199] re-re-re-redo datagen providers --- .../android/AndroidResearchDataProvider.kt | 26 +++++++++++--- .../ru/dbotthepony/mc/otm/core/WriteOnce.kt | 4 +-- .../mc/otm/matter/MatterDataProvider.kt | 34 ++++++++++++++----- 3 files changed, 50 insertions(+), 14 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDataProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDataProvider.kt index 550c2a973..ad2635fa8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDataProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDataProvider.kt @@ -4,14 +4,29 @@ import it.unimi.dsi.fastutil.objects.ObjectArraySet import net.minecraft.data.CachedOutput import net.minecraft.data.DataGenerator import net.minecraft.data.DataProvider +import net.minecraft.data.PackOutput import net.minecraft.resources.ResourceLocation +import net.minecraftforge.data.event.GatherDataEvent +import ru.dbotthepony.mc.otm.core.WriteOnce import java.util.Collections import java.util.LinkedList +import java.util.concurrent.CompletableFuture import java.util.function.Consumer @Suppress("unused") -open class AndroidResearchDataProvider(protected val dataGenerator: DataGenerator) : DataProvider { - protected val pathProvider: DataGenerator.PathProvider = dataGenerator.createPathProvider(DataGenerator.Target.DATA_PACK, AndroidResearchManager.DIRECTORY) +open class AndroidResearchDataProvider() : DataProvider { + var pathProvider: PackOutput.PathProvider by WriteOnce("You need to call bindPackOutput before registering this data provider") + private set + + constructor(output: PackOutput) : this() { + bindPackOutput(output) + } + + constructor(event: GatherDataEvent) : this(event.generator.packOutput) + + fun bindPackOutput(output: PackOutput) { + pathProvider = output.createPathProvider(PackOutput.Target.DATA_PACK, AndroidResearchManager.DIRECTORY) + } protected val callbacks = LinkedList<(Consumer) -> Unit>() @@ -35,15 +50,16 @@ open class AndroidResearchDataProvider(protected val dataGenerator: DataGenerato return this } - final override fun run(output: CachedOutput) { + final override fun run(output: CachedOutput): CompletableFuture<*> { AndroidResearchManager.fireRegistrationEvent() val set = ObjectArraySet() val added = LinkedList() + val futures = ArrayList>() addEverything { if (set.add(it.id)) { - DataProvider.saveStable(output, it.toJson(), pathProvider.json(it.id)) + futures.add(DataProvider.saveStable(output, it.toJson(), pathProvider.json(it.id))) AndroidResearchManager.put(it) added.add(it) } else { @@ -55,6 +71,8 @@ open class AndroidResearchDataProvider(protected val dataGenerator: DataGenerato value.validate() generated.add(value) } + + return CompletableFuture.allOf(*futures.toTypedArray()) } override fun getName(): String { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/WriteOnce.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/WriteOnce.kt index 2cd7c6c41..a4c8b047e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/WriteOnce.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/WriteOnce.kt @@ -3,11 +3,11 @@ package ru.dbotthepony.mc.otm.core import kotlin.properties.ReadWriteProperty import kotlin.reflect.KProperty -class WriteOnce : ReadWriteProperty { +class WriteOnce(private val customMessage: String? = null) : ReadWriteProperty { private var value: V? = null override fun getValue(thisRef: Any?, property: KProperty<*>): V { - return checkNotNull(value) { "Property ${property.name} is not initialized" } + return checkNotNull(value) { customMessage ?: "Property ${property.name} is not initialized" } } override fun setValue(thisRef: Any?, property: KProperty<*>, value: V) { 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 e2a37e01d..3dc8a157b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterDataProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterDataProvider.kt @@ -3,21 +3,35 @@ package ru.dbotthepony.mc.otm.matter import net.minecraft.data.CachedOutput import net.minecraft.data.DataGenerator 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 import net.minecraft.world.level.ItemLike import net.minecraftforge.data.event.GatherDataEvent +import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.WriteOnce import ru.dbotthepony.mc.otm.core.registryName import java.util.Collections +import java.util.concurrent.CompletableFuture import java.util.function.Consumer @Suppress("FunctionName", "unused") -open class MatterDataProvider(protected val dataGenerator: DataGenerator, val namespace: String?) : DataProvider { - constructor(event: GatherDataEvent) : this(event.generator, event.modContainer.namespace) +open class MatterDataProvider(val modid: String? = null) : DataProvider { + var pathProvider: PackOutput.PathProvider by WriteOnce("You need to call bindPackOutput before registering this data provider") + private set + + constructor(output: PackOutput, modid: String? = null) : this(modid) { + bindPackOutput(output) + } + + constructor(event: GatherDataEvent) : this(event.generator.packOutput, event.modContainer.namespace) + + fun bindPackOutput(output: PackOutput) { + pathProvider = output.createPathProvider(PackOutput.Target.DATA_PACK, AndroidResearchManager.DIRECTORY) + } - protected val pathProvider: DataGenerator.PathProvider = dataGenerator.createPathProvider(DataGenerator.Target.DATA_PACK, MatterManager.MATTER_DIRECTORY) protected val actions = LinkedHashMap() sealed class Configuration(val name: ResourceLocation) { @@ -911,11 +925,11 @@ open class MatterDataProvider(protected val dataGenerator: DataGenerator, val na } protected fun updateLocation(input: ResourceLocation, prefix: String): ResourceLocation { - if (namespace != null) { - if (input.namespace == namespace) { + if (modid != null) { + if (input.namespace == modid) { return ResourceLocation(input.namespace, prefix + input.path) } else { - return ResourceLocation(namespace, prefix + input.namespace + "/" + input.path) + return ResourceLocation(modid, prefix + input.namespace + "/" + input.path) } } else { return ResourceLocation(input.namespace, prefix + input.path) @@ -1204,13 +1218,17 @@ open class MatterDataProvider(protected val dataGenerator: DataGenerator, val na protected val added = ArrayList() val addedView: List = Collections.unmodifiableList(added) - final override fun run(output: CachedOutput) { + final override fun run(output: CachedOutput): CompletableFuture<*> { addActions() + val promises = ArrayList>() + for ((key, value) in actions) { - DataProvider.saveStable(output, value.toJson(), pathProvider.json(key)) + promises.add(DataProvider.saveStable(output, value.toJson(), pathProvider.json(key))) added.add(value) } + + return CompletableFuture.allOf(*promises.toTypedArray()) } override fun getName(): String { From 3c0f74bc03fadb2523c437b473df532533597d22 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 13 Jan 2023 18:47:16 +0700 Subject: [PATCH 0022/1199] Update datagen to match Mojang's inner schizo --- .../ru/dbotthepony/mc/otm/datagen/DataGen.kt | 2 +- .../advancements/AdvancementProvider.kt | 5 +- .../mc/otm/datagen/loot/LootTables.kt | 14 ++-- .../otm/datagen/models/MatteryModelBuilder.kt | 2 +- .../mc/otm/datagen/recipes/BlastingRecipes.kt | 7 +- .../datagen/recipes/CraftingTableRecipes.kt | 73 ++++++++++--------- .../otm/datagen/recipes/DecorativesRecipes.kt | 61 ++++++++-------- .../mc/otm/datagen/recipes/MatteryRecipe.kt | 5 +- .../datagen/recipes/MatteryRecipeProvider.kt | 4 +- .../mc/otm/datagen/recipes/OreRecipes.kt | 13 ++-- .../otm/datagen/recipes/ShapelessRecipes.kt | 7 +- .../mc/otm/datagen/tags/TagsProvider.kt | 35 +++++---- 12 files changed, 120 insertions(+), 108 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt index fccf96442..5aa004f90 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -406,7 +406,7 @@ object DataGen { val lootModifier = LootModifiers(event.generator) val languageProvider = MatteryLanguageProvider(event.generator) val matterData = MatterDataProvider(event) - val researchProvider = AndroidResearchDataProvider(event.generator, MOD_ID).also { it.exec { addResearchData(it, languageProvider) } } + val researchProvider = AndroidResearchDataProvider(event).also { it.exec { addResearchData(it, languageProvider) } } this.blockModelProvider = blockModelProvider this.blockStateProvider = blockStateProvider diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementProvider.kt index e2afbc95d..fb18e1e70 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementProvider.kt @@ -1,12 +1,13 @@ package ru.dbotthepony.mc.otm.datagen.advancements import net.minecraft.advancements.Advancement +import net.minecraft.core.HolderLookup import net.minecraftforge.common.data.ExistingFileHelper import net.minecraftforge.data.event.GatherDataEvent import java.util.LinkedList import java.util.function.Consumer -class AdvancementProvider(event: GatherDataEvent) : net.minecraft.data.advancements.AdvancementProvider(event.generator, event.existingFileHelper) { +class AdvancementProvider(event: GatherDataEvent) : net.minecraft.data.advancements.AdvancementProvider(event.generator.packOutput, event.lookupProvider, listOf(), event.existingFileHelper) { private val callbacks = LinkedList<(Consumer, ExistingFileHelper) -> Unit>() fun exec(callback: (Consumer, ExistingFileHelper) -> Unit) { @@ -19,7 +20,7 @@ class AdvancementProvider(event: GatherDataEvent) : net.minecraft.data.advanceme } } - override fun registerAdvancements(consumer: Consumer, fileHelper: ExistingFileHelper) { + override fun registerAdvancements(registries: HolderLookup.Provider, consumer: Consumer, fileHelper: ExistingFileHelper) { for (callback in callbacks) { callback.invoke(consumer, fileHelper) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt index 6aa71da6f..3cc1641bc 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt @@ -9,6 +9,7 @@ import it.unimi.dsi.fastutil.objects.Reference2ObjectFunction import net.minecraft.advancements.critereon.StatePropertiesPredicate import net.minecraft.data.DataGenerator import net.minecraft.data.loot.LootTableProvider +import net.minecraft.data.loot.LootTableSubProvider import net.minecraft.resources.ResourceLocation import net.minecraft.world.level.ItemLike import net.minecraft.world.level.block.Block @@ -32,11 +33,6 @@ import java.util.function.BiConsumer import java.util.function.Consumer import java.util.function.Supplier -private typealias LootTableSaver = BiConsumer -private typealias LootTableCallback = Consumer -private typealias LootTableCallbackProvider = Supplier -private typealias LootTuple = Pair - data class NbtCopy(val source: String, val destination: String, val strategy: CopyNbtFunction.MergeStrategy = CopyNbtFunction.MergeStrategy.REPLACE) fun TileNbtCopy(source: String, strategy: CopyNbtFunction.MergeStrategy = CopyNbtFunction.MergeStrategy.REPLACE): NbtCopy { @@ -65,7 +61,7 @@ private val poweredMatterWorker = arrayOf( TileNbtCopy(MatteryBlockEntity.MATTER_STORAGE_KEY), ) -class LootTables(generator: DataGenerator) : LootTableProvider(generator) { +class LootTables(generator: DataGenerator) : LootTableProvider(generator.packOutput, setOf() /* because we don't fucking validate you fuck */, listOf() /* because we attach everything after class is constructed duh */) { private val providersTable = Reference2ObjectArrayMap LootTable.Builder>>() fun builder(context: LootContextParamSet, id: ResourceLocation, provider: LootTable.Builder.() -> Unit) { @@ -80,10 +76,10 @@ class LootTables(generator: DataGenerator) : LootTableProvider(generator) { .put(id, provider) == null) { "Duplicate loot pool entry for $id" } } - override fun getTables(): List { + override fun getTables(): List { return providersTable.entries.stream().map { entry -> - Pair.of(LootTableCallbackProvider { - LootTableCallback { + SubProviderEntry({ + LootTableSubProvider { for ((id, callback) in entry.value) { it.accept(id, callback.invoke()) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelBuilder.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelBuilder.kt index 7f9d49323..65b3cd2c6 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelBuilder.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelBuilder.kt @@ -3,12 +3,12 @@ package ru.dbotthepony.mc.otm.datagen.models import com.google.gson.JsonArray import com.google.gson.JsonObject import com.google.gson.JsonPrimitive -import com.mojang.math.Vector3f import net.minecraft.client.renderer.block.model.BlockModel import net.minecraft.core.Direction import net.minecraft.resources.ResourceLocation import net.minecraftforge.client.model.generators.ModelBuilder import net.minecraftforge.common.data.ExistingFileHelper +import org.joml.Vector3f import ru.dbotthepony.mc.otm.container.set import ru.dbotthepony.mc.otm.core.set diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt index fea76cc46..971a5c3d7 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.datagen.recipes import net.minecraft.data.recipes.FinishedRecipe +import net.minecraft.data.recipes.RecipeCategory import net.minecraft.data.recipes.SimpleCookingRecipeBuilder import net.minecraft.world.item.crafting.Ingredient import ru.dbotthepony.mc.otm.datagen.modLocation @@ -9,8 +10,8 @@ import ru.dbotthepony.mc.otm.registry.MItems import java.util.function.Consumer fun addBlastingRecipes(consumer: Consumer) { - SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItems.MIRROR_COMPOUND), MItems.MIRROR, 0.1f, 100).unlockedBy(MItems.MIRROR_COMPOUND).save(consumer) + SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItems.MIRROR_COMPOUND), RecipeCategory.MISC, MItems.MIRROR, 0.1f, 100).unlockedBy(MItems.MIRROR_COMPOUND).save(consumer) - SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_PLATES), MItems.TRITANIUM_INGOT, 0f, 100).unlockedBy(MItemTags.TRITANIUM_PLATES).save(consumer, modLocation("tritanium_ingot_from_plates")) - SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_PLATES), MItems.TRITANIUM_INGOT, 0f, 50).unlockedBy(MItemTags.TRITANIUM_PLATES).save(consumer, modLocation("tritanium_ingot_from_plates_blasting")) + SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_PLATES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 100).unlockedBy(MItemTags.TRITANIUM_PLATES).save(consumer, modLocation("tritanium_ingot_from_plates")) + SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_PLATES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 50).unlockedBy(MItemTags.TRITANIUM_PLATES).save(consumer, modLocation("tritanium_ingot_from_plates_blasting")) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index 9527f614a..5ff8c0076 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.datagen.recipes import net.minecraft.data.recipes.FinishedRecipe +import net.minecraft.data.recipes.RecipeCategory import net.minecraft.data.recipes.ShapelessRecipeBuilder import net.minecraft.tags.ItemTags import net.minecraft.world.item.ItemStack @@ -16,36 +17,38 @@ import ru.dbotthepony.mc.otm.datagen.modLocation import java.util.function.Consumer fun addCraftingTableRecipes(consumer: Consumer) { - MatteryRecipe(MRegistry.CARGO_CRATES.item) + val machinesCategory = RecipeCategory.DECORATIONS + + MatteryRecipe(MRegistry.CARGO_CRATES.item, category = RecipeCategory.DECORATIONS) .row(MItemTags.TRITANIUM_PLATES, Tags.Items.CHESTS, MItemTags.TRITANIUM_PLATES) .unlockedBy(MItemTags.TRITANIUM_PLATES) .unlockedBy(Tags.Items.CHESTS) .build(consumer) for ((dye, crate) in MRegistry.CARGO_CRATES.blocks) { - ShapelessRecipeBuilder(crate, 1) + ShapelessRecipeBuilder(RecipeCategory.DECORATIONS, crate, 1) .requires(Ingredient.of(MRegistry.CARGO_CRATES.allItems.entries.stream().filter { it.key != dye }.map { ItemStack(it.value) })) .requires(dye.tag) .unlockedBy(MRegistry.CARGO_CRATES.allItems.entries.stream().filter { it.key != dye }.map { it.value }) .save(consumer, "${crate.registryName}_alt") } - ShapelessRecipeBuilder(MItems.TRITANIUM_INGOT_BLOCK, 1) + ShapelessRecipeBuilder(RecipeCategory.BUILDING_BLOCKS, MItems.TRITANIUM_INGOT_BLOCK, 1) .requires(Ingredient.of(MItemTags.TRITANIUM_INGOTS), 9) .unlockedBy(MItemTags.TRITANIUM_INGOTS) .save(consumer) - ShapelessRecipeBuilder(MItems.TRITANIUM_INGOT, 9) + ShapelessRecipeBuilder(RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 9) .requires(Ingredient.of(MItemTags.TRITANIUM_INGOTS_STORAGE)) .unlockedBy(MItemTags.TRITANIUM_INGOTS_STORAGE) .save(consumer, modLocation("tritanium_ingot_from_storage")) - ShapelessRecipeBuilder(MItems.ENERGY_COUNTER, 1) + ShapelessRecipeBuilder(machinesCategory, MItems.ENERGY_COUNTER, 1) .requires(MItems.ENERGY_COUNTER) .unlockedBy(MItems.ENERGY_COUNTER) .save(consumer, modLocation("energy_counter_reset")) - MatteryRecipe(MBlocks.PLATE_PRESS) + MatteryRecipe(MBlocks.PLATE_PRESS, category = machinesCategory) .row(MItems.ELECTRIC_PARTS, MItems.ENERGY_BUS, MItems.ELECTRIC_PARTS) .row(MItemTags.TRITANIUM_INGOTS, Items.BLAST_FURNACE, MItemTags.TRITANIUM_INGOTS) .row(MItemTags.PISTONS, MItemTags.TRITANIUM_INGOTS, MItemTags.PISTONS) @@ -53,14 +56,14 @@ fun addCraftingTableRecipes(consumer: Consumer) { .unlockedBy(MItems.ELECTRIC_PARTS) .build(consumer) - MatteryRecipe(MBlocks.PLATE_PRESS) + MatteryRecipe(MBlocks.PLATE_PRESS, category = machinesCategory) .rowB(MItems.MACHINE_FRAME) .rowAC(MItemTags.PISTONS, MItemTags.PISTONS) .unlockedBy(MItemTags.TRITANIUM_INGOTS) .unlockedBy(MItems.ELECTRIC_PARTS) .build(consumer, "advanced") - MatteryRecipe(MItems.PATTERN_DRIVE_NORMAL) + MatteryRecipe(MItems.PATTERN_DRIVE_NORMAL, category = machinesCategory) .rowAC(MItemTags.ADVANCED_CIRCUIT, MItemTags.ADVANCED_CIRCUIT) .row(MItemTags.ADVANCED_CIRCUIT, MItemTags.TRITANIUM_PLATES, MItemTags.ADVANCED_CIRCUIT) .rowAC(MItemTags.ADVANCED_CIRCUIT, MItemTags.ADVANCED_CIRCUIT) @@ -68,7 +71,7 @@ fun addCraftingTableRecipes(consumer: Consumer) { .build(consumer) // Машины - MatteryRecipe(MItems.MATTER_RECYCLER) + MatteryRecipe(MItems.MATTER_RECYCLER, category = machinesCategory) .row(MItems.MATTER_CAPACITOR_PARTS, Items.HOPPER, MItemTags.BASIC_CIRCUIT) .row(MItemTags.TRITANIUM_PLATES, MItems.MACHINE_FRAME, MItemTags.TRITANIUM_PLATES) .row(MItems.MATTER_CABLE, MItems.MATTER_IO_PORT, MItems.MATTER_CABLE) @@ -76,21 +79,21 @@ fun addCraftingTableRecipes(consumer: Consumer) { .build(consumer) // Блоки - MatteryRecipe(MItems.MATTER_CAPACITOR_BANK) + MatteryRecipe(MItems.MATTER_CAPACITOR_BANK, category = machinesCategory) .row(Tags.Items.GLASS, MItemTags.IRON_PLATES, Tags.Items.GLASS) .row(MItemTags.IRON_PLATES, MItems.MACHINE_FRAME, MItemTags.IRON_PLATES) .row(MItems.MATTER_CABLE, MItems.MATTER_IO_PORT, MItems.MATTER_CABLE) .unlockedBy(MItems.MATTER_CABLE) .build(consumer) - MatteryRecipe(MItems.BATTERY_BANK) + MatteryRecipe(MItems.BATTERY_BANK, category = machinesCategory) .row(Tags.Items.GLASS, MItemTags.IRON_PLATES, Tags.Items.GLASS) .row(MItemTags.IRON_PLATES, MItems.MACHINE_FRAME, MItemTags.IRON_PLATES) .row(MItems.ELECTRIC_PARTS, MItems.ENERGY_BUS, MItems.ELECTRIC_PARTS) .unlockedBy(MItems.ENERGY_BUS) .build(consumer) - MatteryRecipe(MItems.GRAVITATION_STABILIZER) + MatteryRecipe(MItems.GRAVITATION_STABILIZER, category = machinesCategory) .row(MItemTags.ADVANCED_CIRCUIT, MItems.GRAVITATION_FIELD_SENSOR, MItemTags.ADVANCED_CIRCUIT) .row(MItems.MATTER_TRANSFORM_MATRIX, MItems.MACHINE_FRAME, MItems.MATTER_TRANSFORM_MATRIX) .row(MItemTags.TRITANIUM_PLATES, MItems.GRAVITATION_FIELD_LIMITER, MItemTags.TRITANIUM_PLATES) @@ -98,7 +101,7 @@ fun addCraftingTableRecipes(consumer: Consumer) { .unlockedBy(MItems.GRAVITATION_FIELD_SENSOR) .build(consumer) - MatteryRecipe(MItems.PORTABLE_GRAVITATION_STABILIZER) + MatteryRecipe(MItems.PORTABLE_GRAVITATION_STABILIZER, category = RecipeCategory.COMBAT) .rowB(MItemTags.TRITANIUM_PLATES) .row(MItemTags.TRITANIUM_PLATES, MItems.GRAVITATION_FIELD_SENSOR, MItemTags.TRITANIUM_PLATES) .row(MItemTags.TRITANIUM_PLATES, MItems.GRAVITATION_FIELD_LIMITER, MItemTags.TRITANIUM_PLATES) @@ -106,53 +109,53 @@ fun addCraftingTableRecipes(consumer: Consumer) { .unlockedBy(MItems.GRAVITATION_FIELD_SENSOR) .build(consumer) - MatteryRecipe(MItems.GRAVITATION_FIELD_SENSOR) + MatteryRecipe(MItems.GRAVITATION_FIELD_SENSOR, category = RecipeCategory.MISC) .rowB(MItemTags.BASIC_CIRCUIT) .row(MItemTags.TRITANIUM_PLATES, MItems.ELECTROMAGNET, MItemTags.TRITANIUM_PLATES) .rowB(MItemTags.IRON_PLATES) .unlockedBy(MItems.ELECTROMAGNET) .build(consumer) - MatteryRecipe(MItems.GRAVITATION_FIELD_LIMITER) + MatteryRecipe(MItems.GRAVITATION_FIELD_LIMITER, category = RecipeCategory.MISC) .row(Tags.Items.ENDER_PEARLS, MItemTags.ADVANCED_CIRCUIT, Tags.Items.ENDER_PEARLS) .row(MItemTags.GOLD_WIRES, MItems.QUANTUM_TRANSCEIVER, MItemTags.GOLD_WIRES) .rowB(MItemTags.TRITANIUM_PLATES) .unlockedBy(MItems.QUANTUM_TRANSCEIVER) .build(consumer) - MatteryRecipe(MItems.BLACK_HOLE_SCANNER) + MatteryRecipe(MItems.BLACK_HOLE_SCANNER, category = RecipeCategory.TOOLS) .row(MItemTags.IRON_PLATES, Tags.Items.GLASS_PANES_COLORLESS, MItemTags.IRON_PLATES) .row(MItemTags.GOLD_WIRES, MItems.GRAVITATION_FIELD_SENSOR, MItemTags.ADVANCED_CIRCUIT) .rowAC(Tags.Items.DUSTS_GLOWSTONE, MItemTags.TRITANIUM_PLATES) .unlockedBy(MItems.GRAVITATION_FIELD_SENSOR) .build(consumer) - MatteryRecipe(MItems.PHANTOM_ATTRACTOR) + MatteryRecipe(MItems.PHANTOM_ATTRACTOR, category = machinesCategory) .row(Tags.Items.DUSTS_REDSTONE, Tags.Items.GLASS_COLORLESS, Tags.Items.DUSTS_REDSTONE) .row(MItemTags.TRITANIUM_PLATES, MItems.QUANTUM_TRANSCEIVER, MItemTags.TRITANIUM_PLATES) .row(MItemTags.TRITANIUM_PLATES, ItemTags.BEDS, MItemTags.TRITANIUM_PLATES) .unlockedBy(MItems.QUANTUM_TRANSCEIVER) .build(consumer) - MatteryRecipe(MItems.QUANTUM_TRANSCEIVER, 2) + MatteryRecipe(MItems.QUANTUM_TRANSCEIVER, 2, category = RecipeCategory.MISC) .rowAC(MItemTags.COPPER_WIRES, MItemTags.COPPER_WIRES) .row(MItemTags.GOLD_WIRES, Tags.Items.ENDER_PEARLS, MItemTags.GOLD_WIRES) .row(MItemTags.GOLD_WIRES, MItems.ELECTROMAGNET, MItemTags.GOLD_WIRES) .unlockedBy(Tags.Items.ENDER_PEARLS) .build(consumer) - MatteryRecipe(MItems.ELECTROMAGNET) + MatteryRecipe(MItems.ELECTROMAGNET, category = RecipeCategory.MISC) .row(MItemTags.COPPER_WIRES, Tags.Items.INGOTS_IRON, MItemTags.COPPER_WIRES) .unlockedBy(Tags.Items.ENDER_PEARLS) .build(consumer) - MatteryRecipe(MItems.ENERGY_SERVO) + MatteryRecipe(MItems.ENERGY_SERVO, category = RecipeCategory.MISC) .row(MItemTags.TRITANIUM_PLATES, MItems.MACHINE_FRAME, MItemTags.TRITANIUM_PLATES) .row(MItemTags.TRITANIUM_PLATES, MItems.ENERGY_BUS, MItemTags.TRITANIUM_PLATES) .unlockedBy(MItems.ENERGY_BUS) .build(consumer) - MatteryRecipe(MItems.MIRROR_COMPOUND, 3) + MatteryRecipe(MItems.MIRROR_COMPOUND, 3, category = RecipeCategory.MISC) .row(Tags.Items.GLASS_PANES_COLORLESS, Tags.Items.GLASS_PANES_COLORLESS, Tags.Items.GLASS_PANES_COLORLESS) .row(MItemTags.IRON_PLATES, MItemTags.IRON_PLATES, MItemTags.IRON_PLATES) .unlockedBy(MItemTags.IRON_PLATES) @@ -160,79 +163,79 @@ fun addCraftingTableRecipes(consumer: Consumer) { .build(consumer) // броня - MatteryRecipe(MItems.TRITANIUM_HELMET) + MatteryRecipe(MItems.TRITANIUM_HELMET, category = RecipeCategory.COMBAT) .row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) .row(MItemTags.TRITANIUM_PLATES, MItemTags.IRON_PLATES, MItemTags.TRITANIUM_PLATES) .unlockedBy(MItemTags.TRITANIUM_PLATES) .build(consumer) - MatteryRecipe(MItems.TRITANIUM_PANTS) + MatteryRecipe(MItems.TRITANIUM_PANTS, category = RecipeCategory.COMBAT) .row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) .row(MItemTags.TRITANIUM_PLATES, MItemTags.IRON_PLATES, MItemTags.TRITANIUM_PLATES) .rowAC(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) .unlockedBy(MItemTags.TRITANIUM_PLATES) .build(consumer) - MatteryRecipe(MItems.TRITANIUM_CHESTPLATE) + MatteryRecipe(MItems.TRITANIUM_CHESTPLATE, category = RecipeCategory.COMBAT) .row(MItemTags.TRITANIUM_PLATES, MItemTags.IRON_PLATES, MItemTags.TRITANIUM_PLATES) .row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) .row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) .unlockedBy(MItemTags.TRITANIUM_PLATES) .build(consumer) - MatteryRecipe(MItems.TRITANIUM_BOOTS) + MatteryRecipe(MItems.TRITANIUM_BOOTS, category = RecipeCategory.COMBAT) .rowAC(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) .row(MItemTags.TRITANIUM_PLATES, MItemTags.IRON_PLATES, MItemTags.TRITANIUM_PLATES) .unlockedBy(MItemTags.TRITANIUM_PLATES) .build(consumer) // простые батарейки - MatteryRecipe(MItems.BATTERY_CRUDE) + MatteryRecipe(MItems.BATTERY_CRUDE, category = RecipeCategory.MISC) .rowB(Tags.Items.DUSTS_REDSTONE) .rowB(Tags.Items.CROPS_POTATO) .rowB(Tags.Items.INGOTS_IRON) .build(consumer) - MatteryRecipe(MItems.BATTERY_BASIC) + MatteryRecipe(MItems.BATTERY_BASIC, category = RecipeCategory.MISC) .rowAC(Tags.Items.DUSTS_REDSTONE, Tags.Items.DUSTS_REDSTONE) .rowB(MItems.ELECTRIC_PARTS) .rowB(MItemTags.IRON_PLATES) .build(consumer) - MatteryRecipe(MItems.BATTERY_NORMAL) + MatteryRecipe(MItems.BATTERY_NORMAL, category = RecipeCategory.MISC) .rowB(MItems.ELECTRIC_PARTS) .row(MItemTags.COPPER_WIRES, MItemTags.IRON_PLATES, MItemTags.COPPER_WIRES) .row(Tags.Items.DUSTS_REDSTONE, Tags.Items.DUSTS_REDSTONE, Tags.Items.DUSTS_REDSTONE) .build(consumer) - MatteryRecipe(MItems.BATTERY_DENSE) + MatteryRecipe(MItems.BATTERY_DENSE, category = RecipeCategory.MISC) .row(Tags.Items.DUSTS_REDSTONE, MItems.ENERGY_BUS, Tags.Items.DUSTS_REDSTONE) .row(MItemTags.GOLD_WIRES, MItemTags.TRITANIUM_PLATES, MItemTags.GOLD_WIRES) .row(Tags.Items.DUSTS_REDSTONE, Tags.Items.DUSTS_REDSTONE, Tags.Items.DUSTS_REDSTONE) .build(consumer) - MatteryRecipe(MItems.BATTERY_CAPACITOR) + MatteryRecipe(MItems.BATTERY_CAPACITOR, category = RecipeCategory.MISC) .row(Tags.Items.DUSTS_REDSTONE, MItems.ENERGY_BUS, Tags.Items.DUSTS_REDSTONE) .row(MItemTags.GOLD_WIRES, MItemTags.TRITANIUM_PLATES, MItemTags.GOLD_WIRES) .row(MItemTags.GOLD_WIRES, Tags.Items.DUSTS_REDSTONE, MItemTags.GOLD_WIRES) .build(consumer) // накопители материи - MatteryRecipe(MItems.MATTER_CAPACITOR_DENSE) + MatteryRecipe(MItems.MATTER_CAPACITOR_DENSE, category = RecipeCategory.MISC) .row(MItems.MATTER_CAPACITOR_PARTS, Tags.Items.GLASS, MItems.MATTER_CAPACITOR_PARTS) .row(MItemTags.TRITANIUM_PLATES, Tags.Items.ENDER_PEARLS, MItemTags.TRITANIUM_PLATES) .rowAC(Tags.Items.GEMS_DIAMOND, Tags.Items.GEMS_DIAMOND) .build(consumer) // станция андроида - MatteryRecipe(MItems.ANDROID_STATION) + MatteryRecipe(MItems.ANDROID_STATION, category = machinesCategory) .row(MItems.ELECTRIC_PARTS, MItemTags.ADVANCED_CIRCUIT, MItems.ELECTRIC_PARTS) .row(MItemTags.TRITANIUM_PLATES, MItems.MACHINE_FRAME, MItemTags.TRITANIUM_PLATES) .row(MItemTags.TRITANIUM_PLATES, MItems.ELECTRIC_PARTS, MItemTags.TRITANIUM_PLATES) .build(consumer) // Энерго меч - MatteryRecipe(MItems.ENERGY_SWORD) + MatteryRecipe(MItems.ENERGY_SWORD, category = RecipeCategory.COMBAT) .rowBC(MItemTags.TRITANIUM_PLATES, MItemTags.GOLD_WIRES) .rowBC(MItemTags.TRITANIUM_PLATES, MItemTags.GOLD_WIRES) .row(MItems.BATTERY_CAPACITOR, MItems.TRITANIUM_SWORD, MItemTags.ADVANCED_CIRCUIT) @@ -240,14 +243,14 @@ fun addCraftingTableRecipes(consumer: Consumer) { .buildEnergetic(consumer) // лампа - MatteryRecipe(MItems.LABORATORY_LAMP) + MatteryRecipe(MItems.LABORATORY_LAMP, category = RecipeCategory.REDSTONE) .row(MItemTags.IRON_PLATES, MItemTags.HARDENED_GLASS_PANES_COLORLESS, MItemTags.IRON_PLATES) .row(MItems.MIRROR, Items.GLOWSTONE, MItems.MIRROR) .row(MItemTags.TRITANIUM_PLATES, Tags.Items.DUSTS_REDSTONE, MItemTags.TRITANIUM_PLATES) .build(consumer) // апгрейд на сетку крафта - MatteryRecipe(MItems.ExopackUpgrades.CRAFTING_UPGRADE) + MatteryRecipe(MItems.ExopackUpgrades.CRAFTING_UPGRADE, category = RecipeCategory.TOOLS) .row(MItemTags.ADVANCED_CIRCUIT, MItemTags.ADVANCED_CIRCUIT, MItemTags.ADVANCED_CIRCUIT) .row(MItemTags.CRAFTING_TABLES, MItems.QUANTUM_TRANSCEIVER, MItemTags.CRAFTING_TABLES) .row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt index d3f4b6067..2ae7fc69d 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt @@ -19,7 +19,7 @@ import ru.dbotthepony.mc.otm.registry.MRegistry import java.util.function.Consumer private fun stairs(base: ItemLike, result: ItemLike, consumer: Consumer) { - MatteryRecipe(result, 4) + MatteryRecipe(result, 4, category = RecipeCategory.BUILDING_BLOCKS) .rowA(base) .rowAB(base, base) .row(base, base, base) @@ -28,14 +28,14 @@ private fun stairs(base: ItemLike, result: ItemLike, consumer: Consumer) { - MatteryRecipe(result, 6) + MatteryRecipe(result, 6, category = RecipeCategory.BUILDING_BLOCKS) .row(base, base, base) .unlockedBy(base) .build(consumer) } private fun wall(base: ItemLike, result: ItemLike, consumer: Consumer) { - MatteryRecipe(result, 6) + MatteryRecipe(result, 6, category = RecipeCategory.BUILDING_BLOCKS) .row(base, base, base) .row(base, base, base) .unlockedBy(base) @@ -44,7 +44,7 @@ private fun wall(base: ItemLike, result: ItemLike, consumer: Consumer) { SingleItemRecipeBuilder - .stonecutting(Ingredient.of(base), result, amount) + .stonecutting(Ingredient.of(base), RecipeCategory.BUILDING_BLOCKS, result, amount) .unlockedBy(base) .save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "stonecutting/${result.asItem().registryName!!.path}_from_${base.asItem().registryName!!.path}")) } @@ -78,6 +78,7 @@ fun addDecorativesRecipes(provider: MatteryRecipeProvider, consumer: Consumer(3) private var index = 0 @@ -120,7 +121,7 @@ class MatteryRecipe(val result: ItemLike, val count: Int = 1) { throw NoSuchElementException("No recipe rows were defined") } - val builder = ShapedRecipeBuilder(result, count) + val builder = ShapedRecipeBuilder(category, result, count) val pairs = ArrayList>() val iterator = charlist.iterator() diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt index f985ee946..54d3e6ab0 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt @@ -63,7 +63,7 @@ fun T.unlockedBy(item: TagKey): T { return this } -class MatteryRecipeProvider(generatorIn: DataGenerator) : RecipeProvider(generatorIn) { +class MatteryRecipeProvider(generatorIn: DataGenerator) : RecipeProvider(generatorIn.packOutput) { private val callbacks = LinkedList() fun exec(callback: RecipeBuilderCallback): MatteryRecipeProvider { @@ -71,7 +71,7 @@ class MatteryRecipeProvider(generatorIn: DataGenerator) : RecipeProvider(generat return this } - override fun buildCraftingRecipes(callback: Consumer) { + override fun buildRecipes(callback: Consumer) { for (lambda in callbacks) { lambda(this, callback) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/OreRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/OreRecipes.kt index c9939a3da..f3a50e642 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/OreRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/OreRecipes.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.datagen.recipes import net.minecraft.data.recipes.FinishedRecipe +import net.minecraft.data.recipes.RecipeCategory import net.minecraft.data.recipes.SimpleCookingRecipeBuilder import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.crafting.Ingredient @@ -10,12 +11,12 @@ import ru.dbotthepony.mc.otm.registry.MItems import java.util.function.Consumer fun addOreSmeltingRecipes(consumer: Consumer) { - SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_ORES), MItems.TRITANIUM_INGOT, 1f, 100).unlockedBy(MItemTags.TRITANIUM_ORES).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "smelting/tritanium_ingot_from_ore_block")) - SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_ORES), MItems.TRITANIUM_INGOT, 1f, 200).unlockedBy(MItemTags.TRITANIUM_ORES).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "blasting/tritanium_ingot_from_ore_block")) + SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_ORES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 100).unlockedBy(MItemTags.TRITANIUM_ORES).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "smelting/tritanium_ingot_from_ore_block")) + SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_ORES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 200).unlockedBy(MItemTags.TRITANIUM_ORES).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "blasting/tritanium_ingot_from_ore_block")) - SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_ORE_CLUMPS), MItems.TRITANIUM_INGOT, 1f, 100).unlockedBy(MItemTags.TRITANIUM_ORE_CLUMPS).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "smelting/tritanium_ingot_from_raw_ore")) - SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_ORE_CLUMPS), MItems.TRITANIUM_INGOT, 1f, 200).unlockedBy(MItemTags.TRITANIUM_ORE_CLUMPS).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "blasting/tritanium_ingot_from_raw_ore")) + SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_ORE_CLUMPS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 100).unlockedBy(MItemTags.TRITANIUM_ORE_CLUMPS).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "smelting/tritanium_ingot_from_raw_ore")) + SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_ORE_CLUMPS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 200).unlockedBy(MItemTags.TRITANIUM_ORE_CLUMPS).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "blasting/tritanium_ingot_from_raw_ore")) - SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_DUSTS), MItems.TRITANIUM_INGOT, 0f, 100).unlockedBy(MItemTags.TRITANIUM_DUSTS).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "smelting/tritanium_ingot_from_dust")) - SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_DUSTS), MItems.TRITANIUM_INGOT, 0f, 200).unlockedBy(MItemTags.TRITANIUM_DUSTS).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "blasting/tritanium_ingot_from_dust")) + SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_DUSTS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 100).unlockedBy(MItemTags.TRITANIUM_DUSTS).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "smelting/tritanium_ingot_from_dust")) + SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_DUSTS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 200).unlockedBy(MItemTags.TRITANIUM_DUSTS).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "blasting/tritanium_ingot_from_dust")) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/ShapelessRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/ShapelessRecipes.kt index 72fb7f8b0..08f55b308 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/ShapelessRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/ShapelessRecipes.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.datagen.recipes import net.minecraft.data.recipes.FinishedRecipe +import net.minecraft.data.recipes.RecipeCategory import net.minecraft.data.recipes.ShapelessRecipeBuilder import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack @@ -15,21 +16,21 @@ import java.util.function.Consumer fun addShapelessRecipes(consumer: Consumer) { for (color in DyeColor.values()) { - ShapelessRecipeBuilder(MItems.CARGO_CRATE_MINECARTS[color]!!, 1) + ShapelessRecipeBuilder(RecipeCategory.TRANSPORTATION, MItems.CARGO_CRATE_MINECARTS[color]!!, 1) .requires(Items.MINECART) .requires(MRegistry.CARGO_CRATES.items[color]!!) .unlockedBy(Items.MINECART) .unlockedBy(MRegistry.CARGO_CRATES.items[color]!!) .save(consumer) - ShapelessRecipeBuilder(MItems.CARGO_CRATE_MINECARTS[color]!!, 1) + ShapelessRecipeBuilder(RecipeCategory.TRANSPORTATION, MItems.CARGO_CRATE_MINECARTS[color]!!, 1) .requires(Ingredient.of(MItems.CARGO_CRATE_MINECARTS.entries.stream().filter { it.key != color }.map { ItemStack(it.value) })) .requires(color.tag) .unlockedBy(MItems.CARGO_CRATE_MINECARTS.entries.stream().filter { it.key != color }.map { it.value }) .save(consumer, modLocation(MItems.CARGO_CRATE_MINECARTS[color]!!.registryName!!.path + "_alt")) } - ShapelessRecipeBuilder(MItems.CARGO_CRATE_MINECARTS[null]!!, 1) + ShapelessRecipeBuilder(RecipeCategory.TRANSPORTATION, MItems.CARGO_CRATE_MINECARTS[null]!!, 1) .requires(Items.MINECART) .requires(MRegistry.CARGO_CRATES.item) .unlockedBy(Items.MINECART) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt index 7df9e7f57..8e3ce80e7 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt @@ -1,7 +1,11 @@ package ru.dbotthepony.mc.otm.datagen.tags import it.unimi.dsi.fastutil.objects.ObjectArraySet +import net.minecraft.core.HolderLookup import net.minecraft.core.Registry +import net.minecraft.core.registries.BuiltInRegistries +import net.minecraft.core.registries.Registries +import net.minecraft.resources.ResourceKey import net.minecraft.resources.ResourceLocation import net.minecraft.tags.BlockTags import net.minecraft.tags.GameEventTags @@ -11,6 +15,7 @@ import net.minecraft.world.item.Tier import net.minecraft.world.item.Tiers import net.minecraft.world.level.block.Block import net.minecraftforge.data.event.GatherDataEvent +import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.datagen.DataGen import java.util.stream.Stream @@ -58,22 +63,24 @@ interface ForgeTagAppender : MTagAppender { class TagsProvider( private val event: GatherDataEvent ) { - inner class Delegate(registry: Registry) : MinecraftTagsProvider(event.generator, registry, DataGen.MOD_ID, event.existingFileHelper) { + inner class Delegate(registry: ResourceKey>) : MinecraftTagsProvider(event.generator.packOutput, registry, event.lookupProvider, DataGen.MOD_ID, event.existingFileHelper) { init { event.generator.addProvider(true, this) } private val tags = HashMap, ObjectArraySet>() - override fun addTags() { + override fun addTags(provider: HolderLookup.Provider) { if (tags.isEmpty()) { return } + val registry = (BuiltInRegistries.REGISTRY.get(registryKey.location()) ?: throw NoSuchElementException("No such registry $registryKey")) as Registry + for ((tag, values) in tags) { tag(tag).also { for (value in values) { - it.add(value) + it.add(ResourceKey.create(registryKey, registry.getKey(value) ?: throw NoSuchElementException("$value is missing from $registry"))) } } } @@ -83,7 +90,7 @@ class TagsProvider( return tags.computeIfAbsent(tag) { ObjectArraySet() } } - fun getSet(location: ResourceLocation) = getSet(TagKey.create(registry.key(), location)) + fun getSet(location: ResourceLocation) = getSet(TagKey.create(registryKey, location)) fun appender(tag: TagKey, message: ((T) -> Any) = { "$it is already in $tag" }): MTagAppender { val list = getSet(tag) @@ -118,7 +125,7 @@ class TagsProvider( return object : ForgeTagAppender { override fun add(key: String, value: T): MTagAppender { - val tag = TagKey.create(registry.key(), ResourceLocation("forge", "$path/$key")) + val tag = TagKey.create(registryKey, ResourceLocation("forge", "$path/$key")) if (!getSet(tag).add(value)) { throw IllegalStateException("$value is already in $tag") @@ -128,7 +135,7 @@ class TagsProvider( } override fun addSafe(key: String, value: T): Boolean { - val tag = TagKey.create(registry.key(), ResourceLocation("forge", "$path/$key")) + val tag = TagKey.create(registryKey, ResourceLocation("forge", "$path/$key")) return getSet(tag).add(value) } @@ -161,17 +168,17 @@ class TagsProvider( } fun appender(location: ResourceLocation): MTagAppender { - return appender(TagKey.create(registry.key(), location)) + return appender(TagKey.create(registryKey, location)) } fun appender(location: ResourceLocation, message: (T) -> Any): MTagAppender { - return appender(TagKey.create(registry.key(), location), message) + return appender(TagKey.create(registryKey, location), message) } } - val blocks = Delegate(Registry.BLOCK) - val items = Delegate(Registry.ITEM) - val mobEffects = Delegate(Registry.MOB_EFFECT) + val blocks = Delegate(Registries.BLOCK) + val items = Delegate(Registries.ITEM) + val mobEffects = Delegate(Registries.MOB_EFFECT) val androidImmuneEffects = mobEffects.appender(MatteryPlayerCapability.ANDROID_IMMUNE_EFFECTS) @@ -189,8 +196,8 @@ class TagsProvider( fun ore(key: String, block: Block): TagsProvider { val forgeKey = ResourceLocation("forge", "ores/$key") - val b = TagKey.create(Registry.BLOCK_REGISTRY, forgeKey) - val i = TagKey.create(Registry.ITEM_REGISTRY, forgeKey) + val b = TagKey.create(Registries.BLOCK, forgeKey) + val i = TagKey.create(Registries.ITEM, forgeKey) items.getSet(i).add(block.asItem()) itemOres.add(block.asItem()) @@ -230,7 +237,7 @@ class TagsProvider( val rawMaterials = items.forge("raw_materials") val wires = items.forge("wires") - val gameEvents = Delegate(Registry.GAME_EVENT) + val gameEvents = Delegate(Registries.GAME_EVENT) val vibrations = gameEvents.appender(GameEventTags.VIBRATIONS) fun requiresPickaxe(block: Block, tier: Tier? = null): TagsProvider { From 90dd782bcf851a29fe9b59ce77206ca8349e2b4f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 13 Jan 2023 18:56:17 +0700 Subject: [PATCH 0023/1199] Reference forge registries directly, when possible --- .../mc/otm/datagen/tags/TagsProvider.kt | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt index 8e3ce80e7..3f6c10c52 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt @@ -16,6 +16,7 @@ import net.minecraft.world.item.Tiers import net.minecraft.world.level.block.Block import net.minecraftforge.data.event.GatherDataEvent import net.minecraftforge.registries.ForgeRegistries +import net.minecraftforge.registries.IForgeRegistry import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.datagen.DataGen import java.util.stream.Stream @@ -60,10 +61,18 @@ interface ForgeTagAppender : MTagAppender { } } +private fun vanillaLookup(key: ResourceKey>): (T) -> ResourceLocation? { + val registry by lazy { (BuiltInRegistries.REGISTRY.get(key.location()) ?: throw NoSuchElementException("No such registry $key")) as Registry } + return { registry.getKey(it) } +} + class TagsProvider( private val event: GatherDataEvent ) { - inner class Delegate(registry: ResourceKey>) : MinecraftTagsProvider(event.generator.packOutput, registry, event.lookupProvider, DataGen.MOD_ID, event.existingFileHelper) { + inner class Delegate private constructor(key: ResourceKey>, val lookup: (T) -> ResourceLocation?) : MinecraftTagsProvider(event.generator.packOutput, key, event.lookupProvider, DataGen.MOD_ID, event.existingFileHelper) { + constructor(registry: IForgeRegistry) : this(registry.registryKey, registry::getKey) + constructor(key: ResourceKey>) : this(key, vanillaLookup(key)) + init { event.generator.addProvider(true, this) } @@ -75,12 +84,10 @@ class TagsProvider( return } - val registry = (BuiltInRegistries.REGISTRY.get(registryKey.location()) ?: throw NoSuchElementException("No such registry $registryKey")) as Registry - for ((tag, values) in tags) { tag(tag).also { for (value in values) { - it.add(ResourceKey.create(registryKey, registry.getKey(value) ?: throw NoSuchElementException("$value is missing from $registry"))) + it.add(ResourceKey.create(registryKey, lookup(value) ?: throw NoSuchElementException("$value is missing from $registryKey"))) } } } @@ -176,9 +183,9 @@ class TagsProvider( } } - val blocks = Delegate(Registries.BLOCK) - val items = Delegate(Registries.ITEM) - val mobEffects = Delegate(Registries.MOB_EFFECT) + val blocks = Delegate(ForgeRegistries.BLOCKS) + val items = Delegate(ForgeRegistries.ITEMS) + val mobEffects = Delegate(ForgeRegistries.MOB_EFFECTS) val androidImmuneEffects = mobEffects.appender(MatteryPlayerCapability.ANDROID_IMMUNE_EFFECTS) From a87f42c86636e6073b75802933fb0fb852049727 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 13 Jan 2023 18:59:53 +0700 Subject: [PATCH 0024/1199] Bump forge to 44.1.5 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 68998d659..7dbd04ac9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ use_commit_hash_in_version=true mc_version=1.19.3 deps_mc_version=1.19.2 forge_gradle_version=5.1.27 -forge_version=44.0.11 +forge_version=44.1.5 mixingradle_version=0.7.32 mixin_version=0.8.5 From 299ca05029e53f7f13e08172cbe0835fed8c2772 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 13 Jan 2023 19:13:03 +0700 Subject: [PATCH 0025/1199] Update datagen code to latest forge changes --- .../ru/dbotthepony/mc/otm/datagen/DataGen.kt | 16 +++++------ .../mc/otm/datagen/SoundDataProvider.kt | 2 +- .../advancements/AdvancementProvider.kt | 28 ------------------- .../mc/otm/datagen/blocks/Banks.kt | 2 +- .../blocks/MatteryBlockStateProvider.kt | 2 +- .../datagen/items/MatteryItemModelProvider.kt | 2 +- .../datagen/lang/MatteryLanguageProvider.kt | 2 +- .../mc/otm/datagen/loot/LootModifiers.kt | 2 +- .../otm/datagen/models/MatteryModelBuilder.kt | 2 +- .../datagen/models/MatteryModelProvider.kt | 2 +- 10 files changed, 16 insertions(+), 44 deletions(-) delete mode 100644 src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementProvider.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt index 5aa004f90..7b2f9a31a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -13,6 +13,7 @@ import net.minecraft.world.level.block.state.properties.DoorHingeSide import net.minecraft.world.level.block.state.properties.DoubleBlockHalf import net.minecraft.world.level.block.state.properties.Half import net.minecraftforge.client.model.generators.ModelFile +import net.minecraftforge.common.data.ForgeAdvancementProvider import net.minecraftforge.eventbus.api.SubscribeEvent import net.minecraftforge.fml.common.Mod import net.minecraftforge.data.event.GatherDataEvent @@ -29,7 +30,6 @@ import ru.dbotthepony.mc.otm.datagen.models.MatteryBlockModelProvider import ru.dbotthepony.mc.otm.datagen.recipes.MatteryRecipeProvider import ru.dbotthepony.mc.otm.registry.* import ru.dbotthepony.mc.otm.core.registryName -import ru.dbotthepony.mc.otm.datagen.advancements.AdvancementProvider import ru.dbotthepony.mc.otm.datagen.advancements.addAdvancements import ru.dbotthepony.mc.otm.datagen.advancements.addAndroidAdvancements import ru.dbotthepony.mc.otm.datagen.advancements.addMachineAdvancements @@ -419,7 +419,13 @@ object DataGen { this.matterData = matterData val tagsProvider = TagsProvider(event) - val advancementProvider = AdvancementProvider(event) + val advancementProvider = object : ForgeAdvancementProvider(event.generator.packOutput, event.lookupProvider, event.existingFileHelper, listOf( + AdvancementGenerator { registries, saver, existingFileHelper -> + addAdvancements(saver, existingFileHelper, languageProvider) + addAndroidAdvancements(saver, existingFileHelper, languageProvider) + addMachineAdvancements(saver, existingFileHelper, languageProvider) + } + )) {} addTags(tagsProvider) @@ -464,12 +470,6 @@ object DataGen { addOreSmeltingRecipes(consumer) } - advancementProvider.exec { it, files -> - addAdvancements(it, files, languageProvider) - addAndroidAdvancements(it, files, languageProvider) - addMachineAdvancements(it, files, languageProvider) - } - addPlatePressRecipes(recipeProvider) lootModifier.lambda { diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/SoundDataProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/SoundDataProvider.kt index 6e4c5ac76..eb5539c1a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/SoundDataProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/SoundDataProvider.kt @@ -11,7 +11,7 @@ fun SoundDefinition.subtitle(value: SoundEvent): SoundDefinition { return subtitle("otm.sound." + value.location.path) } -class SoundDataProvider(event: GatherDataEvent) : SoundDefinitionsProvider(event.generator, DataGen.MOD_ID, event.existingFileHelper) { +class SoundDataProvider(event: GatherDataEvent) : SoundDefinitionsProvider(event.generator.packOutput, DataGen.MOD_ID, event.existingFileHelper) { override fun registerSounds() { add(MSoundEvents.PLASMA_WEAPON_OVERHEAT, definition().subtitle("otm.sound.plasma_weapon_overheat") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementProvider.kt deleted file mode 100644 index fb18e1e70..000000000 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementProvider.kt +++ /dev/null @@ -1,28 +0,0 @@ -package ru.dbotthepony.mc.otm.datagen.advancements - -import net.minecraft.advancements.Advancement -import net.minecraft.core.HolderLookup -import net.minecraftforge.common.data.ExistingFileHelper -import net.minecraftforge.data.event.GatherDataEvent -import java.util.LinkedList -import java.util.function.Consumer - -class AdvancementProvider(event: GatherDataEvent) : net.minecraft.data.advancements.AdvancementProvider(event.generator.packOutput, event.lookupProvider, listOf(), event.existingFileHelper) { - private val callbacks = LinkedList<(Consumer, ExistingFileHelper) -> Unit>() - - fun exec(callback: (Consumer, ExistingFileHelper) -> Unit) { - callbacks.add(callback) - } - - fun exec(callback: (Consumer) -> Unit) { - callbacks.add { it, _ -> - callback.invoke(it) - } - } - - override fun registerAdvancements(registries: HolderLookup.Provider, consumer: Consumer, fileHelper: ExistingFileHelper) { - for (callback in callbacks) { - callback.invoke(consumer, fileHelper) - } - } -} diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt index 6fc3c2bb1..cdbe2bcca 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt @@ -17,7 +17,7 @@ private fun nothingOrNumber(input: Int): String { return (input - 1).toString() } -open class BatteryBankProvider(event: GatherDataEvent) : BlockStateProvider(event.generator, DataGen.MOD_ID, event.existingFileHelper) { +open class BatteryBankProvider(event: GatherDataEvent) : BlockStateProvider(event.generator.packOutput, DataGen.MOD_ID, event.existingFileHelper) { protected var block = "battery_bank" protected var batteryPath = "block/battery/battery" protected var registry: Block = MBlocks.BATTERY_BANK diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt index 441942236..ffd7cf4ed 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt @@ -41,7 +41,7 @@ private fun initialTransform(it: BlockState, modelPath: String, builder: Configu return modelPath } -class MatteryBlockStateProvider(event: GatherDataEvent) : BlockStateProvider(event.generator, DataGen.MOD_ID, event.existingFileHelper) { +class MatteryBlockStateProvider(event: GatherDataEvent) : BlockStateProvider(event.generator.packOutput, DataGen.MOD_ID, event.existingFileHelper) { private val callbacks = LinkedList<() -> Unit>() fun exec(lambda: () -> Unit): MatteryBlockStateProvider { diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt index 985082d3d..75e41c5d2 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt @@ -9,7 +9,7 @@ import ru.dbotthepony.mc.otm.datagen.DataGen import ru.dbotthepony.mc.otm.core.registryName import java.util.LinkedList -class MatteryItemModelProvider(event: GatherDataEvent) : ItemModelProvider(event.generator, DataGen.MOD_ID, event.existingFileHelper) { +class MatteryItemModelProvider(event: GatherDataEvent) : ItemModelProvider(event.generator.packOutput, DataGen.MOD_ID, event.existingFileHelper) { private val callbacks = LinkedList<() -> Unit>() fun exec(func: () -> Unit): MatteryItemModelProvider { diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/MatteryLanguageProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/MatteryLanguageProvider.kt index 2b84bf75b..9c16c52a6 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/MatteryLanguageProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/MatteryLanguageProvider.kt @@ -35,7 +35,7 @@ private fun researchString(key: AndroidResearchType): String { } class MatteryLanguageProvider(private val gen: DataGenerator) { - private inner class Slave(language: String) : LanguageProvider(gen, OverdriveThatMatters.MOD_ID, language) { + private inner class Slave(language: String) : LanguageProvider(gen.packOutput, OverdriveThatMatters.MOD_ID, language) { override fun addTranslations() {} } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootModifiers.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootModifiers.kt index cc119d648..af9dc0737 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootModifiers.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootModifiers.kt @@ -51,7 +51,7 @@ fun PlainLootAppender( vararg items: Pair ) = PlainLootAppender(conditions, Arrays.stream(items)) -class LootModifiers(generator: DataGenerator) : GlobalLootModifierProvider(generator, DataGen.MOD_ID) { +class LootModifiers(generator: DataGenerator) : GlobalLootModifierProvider(generator.packOutput, DataGen.MOD_ID) { private val lambdas = ArrayList<(LootModifiers) -> Unit>() fun lambda(lambda: (LootModifiers) -> Unit) { diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelBuilder.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelBuilder.kt index 65b3cd2c6..9c69f35ba 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelBuilder.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelBuilder.kt @@ -145,7 +145,7 @@ class MatteryModelBuilder(resourceLocation: ResourceLocation, existingFileHelper } (v["emissivity"] as? JsonPrimitive)?.asInt?.also { emissivity -> - emissivity(emissivity) + emissivity(emissivity, 0) } (v["ao"] as? JsonPrimitive)?.asBoolean?.also { ao -> diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelProvider.kt index dd0d3d415..b7d1dca22 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelProvider.kt @@ -14,7 +14,7 @@ import java.util.LinkedList private typealias Callback = (MatteryModelProvider) -> Unit -sealed class MatteryModelProvider(event: GatherDataEvent, folder: String) : ModelProvider(event.generator, DataGen.MOD_ID, folder, ::MatteryModelBuilder, event.existingFileHelper) { +sealed class MatteryModelProvider(event: GatherDataEvent, folder: String) : ModelProvider(event.generator.packOutput, DataGen.MOD_ID, folder, ::MatteryModelBuilder, event.existingFileHelper) { private fun extendWithFolder(rl: ResourceLocation): ResourceLocation { return if (rl.path.contains("/")) rl else ResourceLocation(rl.namespace, folder + "/" + rl.path) } From 8a68bc9bd80861f298162def15fae5d6dab50346 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 13 Jan 2023 19:20:14 +0700 Subject: [PATCH 0026/1199] Make it run --- .../kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt | 8 ++++++++ .../kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt | 1 - 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt index cdbe2bcca..f605784d9 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt @@ -40,6 +40,10 @@ open class BatteryBankProvider(event: GatherDataEvent) : BlockStateProvider(even } } } + + override fun getName(): String { + return "Battery Bank Model Provider" + } } class MatterBankProvider(event: GatherDataEvent) : BatteryBankProvider(event) { @@ -48,4 +52,8 @@ class MatterBankProvider(event: GatherDataEvent) : BatteryBankProvider(event) { batteryPath = "block/battery/matter_capacitor" registry = MBlocks.MATTER_CAPACITOR_BANK } + + override fun getName(): String { + return "Matter Bank Model Provider" + } } 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 a28adeca3..d7728cd27 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -227,7 +227,6 @@ object MRegistry { bus.addListener(this::initializeClient) bus.addListener(this::initializeCommon) bus.addListener(MStats::registerVanilla) - bus.addListener(MCreativeTabs::register) MBlocks.register(bus) MBlockEntities.register(bus) From 46509a59fb8159d336bc8a2e43f6e12e16dfc986 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 13 Jan 2023 19:28:11 +0700 Subject: [PATCH 0027/1199] Fix matter data provider writing to wrong folder --- .../ru/dbotthepony/mc/otm/matter/MatterDataProvider.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 3dc8a157b..dc1e34769 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterDataProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterDataProvider.kt @@ -29,7 +29,7 @@ open class MatterDataProvider(val modid: String? = null) : DataProvider { constructor(event: GatherDataEvent) : this(event.generator.packOutput, event.modContainer.namespace) fun bindPackOutput(output: PackOutput) { - pathProvider = output.createPathProvider(PackOutput.Target.DATA_PACK, AndroidResearchManager.DIRECTORY) + pathProvider = output.createPathProvider(PackOutput.Target.DATA_PACK, MatterManager.MATTER_DIRECTORY) } protected val actions = LinkedHashMap() @@ -1232,6 +1232,9 @@ open class MatterDataProvider(val modid: String? = null) : DataProvider { } override fun getName(): String { + if (modid != null) + return "Matter Data for mod $modid" + return "Matter Data" } } From 3d9bc21a6fa59782de90cc90f1a7e7255c48af18 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 13 Jan 2023 19:42:39 +0700 Subject: [PATCH 0028/1199] Don't add second itemstack if matter/energy value didn't change --- .../kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt index 59dae9636..131ca7ba9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt @@ -68,7 +68,9 @@ private fun CreativeModeTab.Output.energized(value: Item) { val stack = ItemStack(value, 1) val energy = stack.matteryEnergy ?: throw IllegalArgumentException("${value.registryName} does not implement mattery energy capability") energy.fillBattery() - accept(stack) + + if (ItemStack(value, 1).matteryEnergy!!.batteryLevel != energy.batteryLevel) + accept(stack) } private fun CreativeModeTab.Output.energized(values: Iterable) { @@ -84,7 +86,9 @@ private fun CreativeModeTab.Output.mattery(value: Item) { val matter = stack.matter ?: throw IllegalArgumentException("${value.registryName} does not implement matter capability") matter.fillMatter() - accept(stack) + + if (ItemStack(value, 1).matter!!.storedMatter != matter.storedMatter) + accept(stack) } private fun CreativeModeTab.Output.mattery(values: Iterable) { From 5d0b2c9f7e185849b08046bfed3fb4c20bda8d8b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 13 Jan 2023 21:54:52 +0700 Subject: [PATCH 0029/1199] Ore worldgen json datagen Used to place a configuredfeature, tele jigsaw, template or st'ructure at a given location. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ☎️ 🧩 😤 🛣️ 😵 💭 ✨ 🏗️ ⚙️ 🧩 🌎 ⏳ 🧮 🇯 🌞 ☎️ 🧩 😤 🛣️ 😵 💭 ✨ 🏗️ ⚙️ 🧩 🌎 ⏳ 🧮 🇯 🌞 ☎️ 🧩 😤 🛣️ 😵 💭 ✨ 🏗️ ⚙️ 🧩 🌎 ⏳ 🧮 🇯 🌞 ☎️ 🧩 😤 🛣️ 😵 💭 ✨ 🏗️ ⚙️ 🧩 🌎 ⏳ 🧮 🇯 🌞 When the dev team was programming telepathicgrunt, they realized that there was a potential to create something similar inside the tele, causing recursion until the jigsaw crashed. To fix this, they capped the injigsaw grunt available at 2^512 pathics, forcing anything telepathic to be less complex than telepathicgrunt and preventing crashes. Let’s dissect tele jigsaw grunt pathic telepathic st’ructure worldgenjson. Starting from the beginning, tele implies that the whole has remote control capabilities, such as telepathy or telekinesis. Next, jigsaw implies multiple pieces that can be slotted together and rearranged. A grunt is simply a particular sound generated by an animal, implying that it is capable of creating noise. Pathic, similar to pathos, implies that it can affect emotions in some way. Following this, we have the even more direct telepathic, implying it is capable of reading thoughts and emotions. St’ructure is more difficult because the part after the apostrophe must be abbreviated, meaning it is likely two words, “stereospecific technostructure”. This implies it is a synthetic construct with a specific arrangement, meaning it could be a program. With this context in mind, processorjigsaw makes sense: it’s capable of rearranging its components and editing its code. Finally, worldgenjson could mean that it has some ability to manipulate reality through JSON. With all this in mind, I present my theory. tele jigsaw grunt pathic telepathic st’ructure processorjigsaw worldgenjson is a sapient, self-editing AI with telepathic and ontokinetic abilities. Due to its synthetic nature, it is interested in studying the behavior of humans, and using its abilities, created and spread an inside joke within the MCDrama server, giving it its own name in an act of vanity. --- .../ru/dbotthepony/mc/otm/datagen/DataGen.kt | 2 + .../ru/dbotthepony/mc/otm/datagen/Ext.kt | 3 - .../ru/dbotthepony/mc/otm/datagen/OreGen.kt | 93 +++++++++++++++++++ .../mc/otm/OverdriveThatMatters.java | 3 - .../ru/dbotthepony/mc/otm/registry/Ext.kt | 8 +- .../ru/dbotthepony/mc/otm/worldgen/OreGen.kt | 59 ------------ 6 files changed, 99 insertions(+), 69 deletions(-) create mode 100644 src/data/kotlin/ru/dbotthepony/mc/otm/datagen/OreGen.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/OreGen.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt index 7b2f9a31a..f4b40cfb3 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -442,6 +442,8 @@ object DataGen { event.generator.addProvider(event.includeServer(), advancementProvider) event.generator.addProvider(event.includeServer(), matterData) + registerOreGen(event) + AddEnglishLanguage(languageProvider) for ((color, door) in MBlocks.TRITANIUM_DOOR) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/Ext.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/Ext.kt index 38dc866bb..4878ae37e 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/Ext.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/Ext.kt @@ -1,11 +1,8 @@ package ru.dbotthepony.mc.otm.datagen -import com.google.gson.JsonArray -import com.google.gson.JsonObject import net.minecraft.core.Direction import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.properties.Property -import kotlin.math.roundToInt fun Direction.toYRotBlockstate(): Int { return when (this) { diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/OreGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/OreGen.kt new file mode 100644 index 000000000..6eade58f3 --- /dev/null +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/OreGen.kt @@ -0,0 +1,93 @@ +package ru.dbotthepony.mc.otm.datagen + +import com.mojang.serialization.JsonOps +import net.minecraft.core.Holder +import net.minecraft.core.HolderOwner +import net.minecraft.core.registries.Registries +import net.minecraft.resources.RegistryOps +import net.minecraft.resources.ResourceKey +import net.minecraft.resources.ResourceLocation +import net.minecraft.server.packs.PackType +import net.minecraft.tags.BlockTags +import net.minecraft.world.level.levelgen.VerticalAnchor +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature +import net.minecraft.world.level.levelgen.feature.Feature +import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration +import net.minecraft.world.level.levelgen.placement.CountPlacement +import net.minecraft.world.level.levelgen.placement.HeightRangePlacement +import net.minecraft.world.level.levelgen.placement.InSquarePlacement +import net.minecraft.world.level.levelgen.placement.PlacedFeature +import net.minecraft.world.level.levelgen.structure.templatesystem.TagMatchTest +import net.minecraftforge.common.data.JsonCodecProvider +import net.minecraftforge.data.event.GatherDataEvent +import ru.dbotthepony.mc.otm.registry.MBlocks + +private object Owner : HolderOwner { + override fun canSerializeIn(p_255875_: HolderOwner): Boolean { + return true // because we can always reference things, even if they are not "registered" at this moment + } +} + +private data class Both(val key: Holder, val value: Holder) + +private fun createHolders(key: ResourceKey, value: T): Both { + val keyOnly = Holder.Reference.createStandAlone(Owner as HolderOwner, key) + val valueOnly = Holder.direct(value) + return Both(keyOnly, valueOnly) +} + +private fun remap(vararg input: Both): Map> { + val result = LinkedHashMap>() + + for (value in input) { + result[value.key.unwrapKey().get().location()] = value.value + } + + return result +} + +fun registerOreGen(event: GatherDataEvent) { + val stone = TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES) + val deepslate = TagMatchTest(BlockTags.DEEPSLATE_ORE_REPLACEABLES) + + val target by lazy { + listOf( + OreConfiguration.target(stone, MBlocks.TRITANIUM_ORE.defaultBlockState()), + OreConfiguration.target(deepslate, MBlocks.DEEPSLATE_TRITANIUM_ORE.defaultBlockState()), + ) + } + + val ops = RegistryOps.create(JsonOps.INSTANCE, event.lookupProvider.join()) + val tritanium = createHolders(ResourceKey.create(Registries.CONFIGURED_FEATURE, modLocation("ore_tritanium")), ConfiguredFeature(Feature.ORE, OreConfiguration(target, 9))) + val configuredFeatures = remap(tritanium) + + event.generator.addProvider(event.includeServer(), JsonCodecProvider( + event.generator.packOutput, event.existingFileHelper, DataGen.MOD_ID, ops, + PackType.SERVER_DATA, "worldgen/configured_feature", ConfiguredFeature.CODEC, configuredFeatures + )) + + val placedTritanium = createHolders(ResourceKey.create(Registries.PLACED_FEATURE, modLocation("normal_tritanium")), PlacedFeature( + tritanium.key, + listOf( + CountPlacement.of(8), + InSquarePlacement.spread(), + HeightRangePlacement.triangle(VerticalAnchor.absolute(0), VerticalAnchor.absolute(50)) + ) + )) + + val placedTritaniumDeep = createHolders(ResourceKey.create(Registries.PLACED_FEATURE, modLocation("deep_tritanium")), PlacedFeature( + tritanium.key, + listOf( + CountPlacement.of(10), + InSquarePlacement.spread(), + HeightRangePlacement.uniform(VerticalAnchor.aboveBottom(8), VerticalAnchor.absolute(0)) + ) + )) + + val placedFeatures = remap(placedTritanium, placedTritaniumDeep) + + event.generator.addProvider(event.includeServer(), JsonCodecProvider( + event.generator.packOutput, event.existingFileHelper, DataGen.MOD_ID, ops, + PackType.SERVER_DATA, "worldgen/placed_feature", PlacedFeature.CODEC, placedFeatures + )) +} diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index fad7cc780..46e9e034f 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -44,7 +44,6 @@ import ru.dbotthepony.mc.otm.matter.MatterManager; import ru.dbotthepony.mc.otm.network.*; import ru.dbotthepony.mc.otm.registry.*; import ru.dbotthepony.mc.otm.storage.*; -import ru.dbotthepony.mc.otm.worldgen.OreGen; import static net.minecraftforge.common.MinecraftForge.EVENT_BUS; @@ -181,8 +180,6 @@ public final class OverdriveThatMatters { if (ModList.get().isLoaded("mekanism")) { EVENT_BUS.addGenericListener(BlockEntity.class, EventPriority.NORMAL, QIOKt::attachCapabilities); } - - OreGen.INSTANCE.register(); } private void setupClient(final FMLClientSetupEvent event) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Ext.kt index 4d3ef11aa..fdbf81a00 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Ext.kt @@ -32,19 +32,19 @@ private fun DeferredRegister.doColored(prefix: String, factory: (color: D ) } -fun DeferredRegister.colored(prefix: String, factory: (color: DyeColor, name: String) -> T): Map { +internal fun DeferredRegister.colored(prefix: String, factory: (color: DyeColor, name: String) -> T): Map { return SupplierMap(doColored(prefix, factory)) } @Suppress("unchecked_cast") -fun DeferredRegister.allColored(prefix: String, factory: (color: DyeColor?, name: String) -> T): Map { +internal fun DeferredRegister.allColored(prefix: String, factory: (color: DyeColor?, name: String) -> T): Map { return SupplierMap(doColored(prefix, factory).also { (it as MutableCollection T>>).add((null as DyeColor?) to register(prefix) { factory.invoke(null, prefix) }::get) }) } -fun Registry.register(key: String, value: T): Holder { +internal fun Registry.register(key: String, value: T): Holder { return this.register(ResourceLocation(OverdriveThatMatters.MOD_ID, key), value) } -fun Registry.register(key: ResourceLocation, value: T): Holder { +internal fun Registry.register(key: ResourceLocation, value: T): Holder { return (this as WritableRegistry).register(ResourceKey.create(key(), key), value, Lifecycle.stable()) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/OreGen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/OreGen.kt deleted file mode 100644 index aa96fb473..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/worldgen/OreGen.kt +++ /dev/null @@ -1,59 +0,0 @@ -package ru.dbotthepony.mc.otm.worldgen - -import net.minecraft.core.Holder -import net.minecraft.core.registries.BuiltInRegistries -import net.minecraft.core.registries.Registries -import net.minecraft.data.worldgen.features.OreFeatures -import net.minecraft.tags.BlockTags -import net.minecraft.world.level.levelgen.VerticalAnchor -import net.minecraft.world.level.levelgen.feature.ConfiguredFeature -import net.minecraft.world.level.levelgen.feature.Feature -import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration -import net.minecraft.world.level.levelgen.placement.CountPlacement -import net.minecraft.world.level.levelgen.placement.HeightRangePlacement -import net.minecraft.world.level.levelgen.placement.InSquarePlacement -import net.minecraft.world.level.levelgen.placement.PlacedFeature -import net.minecraft.world.level.levelgen.structure.templatesystem.TagMatchTest -import ru.dbotthepony.mc.otm.registry.MBlocks -import ru.dbotthepony.mc.otm.core.WriteOnce -import ru.dbotthepony.mc.otm.registry.register - -@Suppress("UNNECESSARY_NOT_NULL_ASSERTION") -object OreGen { - private val STONE_ORE_REPLACEABLES = TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES) - private val DEEPSLATE_ORE_REPLACEABLES = TagMatchTest(BlockTags.DEEPSLATE_ORE_REPLACEABLES) - - val ORE_TRITANIUM_TARGET_LIST = listOf( - OreConfiguration.target(STONE_ORE_REPLACEABLES, MBlocks.TRITANIUM_ORE.defaultBlockState())!!, - OreConfiguration.target(DEEPSLATE_ORE_REPLACEABLES, MBlocks.DEEPSLATE_TRITANIUM_ORE.defaultBlockState())!!, - ) - - var ORE_FEATURE_TRITANIUM_NORMAL by WriteOnce>>() - var ORE_TRITANIUM_NORMAL by WriteOnce>() - var ORE_TRITANIUM_DEEP by WriteOnce>() - - fun register() { - // TODO: 1.19.3 - /*val registry = BuiltInRegistries.REGISTRY.get(Registries.CONFIGURED_FEATURE.location()) - - ORE_FEATURE_TRITANIUM_NORMAL = CONFIGURED_FEATURE.register("ore_tritanium", ConfiguredFeature(Feature.ORE, OreConfiguration(ORE_TRITANIUM_TARGET_LIST, 9))) - - ORE_TRITANIUM_NORMAL = PLACED_FEATURE.register("ore_tritanium_normal", PlacedFeature( - ORE_FEATURE_TRITANIUM_NORMAL, - listOf( - CountPlacement.of(8), - InSquarePlacement.spread(), - HeightRangePlacement.triangle(VerticalAnchor.absolute(0), VerticalAnchor.absolute(50)) - ) - )) - - ORE_TRITANIUM_DEEP = PLACED_FEATURE.register("ore_tritanium_deep", PlacedFeature( - ORE_FEATURE_TRITANIUM_NORMAL, - listOf( - CountPlacement.of(10), - InSquarePlacement.spread(), - HeightRangePlacement.uniform(VerticalAnchor.aboveBottom(8), VerticalAnchor.absolute(0)) - ) - ))*/ - } -} From 4c419aaf3501615da1c1dfb6154c41201bd12190 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 13 Jan 2023 22:08:42 +0700 Subject: [PATCH 0030/1199] Update tritanium ore biome modifier --- .../biome_modifier/overdrive_that_matters/tritanium_ore.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/data/overdrive_that_matters/forge/biome_modifier/overdrive_that_matters/tritanium_ore.json b/src/main/resources/data/overdrive_that_matters/forge/biome_modifier/overdrive_that_matters/tritanium_ore.json index f09c405e1..2624ac791 100644 --- a/src/main/resources/data/overdrive_that_matters/forge/biome_modifier/overdrive_that_matters/tritanium_ore.json +++ b/src/main/resources/data/overdrive_that_matters/forge/biome_modifier/overdrive_that_matters/tritanium_ore.json @@ -2,8 +2,8 @@ "type": "forge:add_features", "biomes": "#minecraft:is_overworld", "features": [ - "overdrive_that_matters:ore_tritanium_normal", - "overdrive_that_matters:ore_tritanium_deep" + "overdrive_that_matters:deep_tritanium", + "overdrive_that_matters:normal_tritanium" ], "step": "underground_ores" } From fe91b184a67e5f9095009deff82c719560c675cc Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 13 Jan 2023 22:33:57 +0700 Subject: [PATCH 0031/1199] Proper ore json datagen --- .../ru/dbotthepony/mc/otm/datagen/OreGen.kt | 83 +++++++------------ 1 file changed, 28 insertions(+), 55 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/OreGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/OreGen.kt index 6eade58f3..a52d3dbb6 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/OreGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/OreGen.kt @@ -1,13 +1,9 @@ package ru.dbotthepony.mc.otm.datagen -import com.mojang.serialization.JsonOps -import net.minecraft.core.Holder -import net.minecraft.core.HolderOwner +import net.minecraft.core.RegistrySetBuilder import net.minecraft.core.registries.Registries -import net.minecraft.resources.RegistryOps +import net.minecraft.data.worldgen.BootstapContext import net.minecraft.resources.ResourceKey -import net.minecraft.resources.ResourceLocation -import net.minecraft.server.packs.PackType import net.minecraft.tags.BlockTags import net.minecraft.world.level.levelgen.VerticalAnchor import net.minecraft.world.level.levelgen.feature.ConfiguredFeature @@ -18,56 +14,32 @@ import net.minecraft.world.level.levelgen.placement.HeightRangePlacement import net.minecraft.world.level.levelgen.placement.InSquarePlacement import net.minecraft.world.level.levelgen.placement.PlacedFeature import net.minecraft.world.level.levelgen.structure.templatesystem.TagMatchTest -import net.minecraftforge.common.data.JsonCodecProvider +import net.minecraftforge.common.data.DatapackBuiltinEntriesProvider import net.minecraftforge.data.event.GatherDataEvent import ru.dbotthepony.mc.otm.registry.MBlocks -private object Owner : HolderOwner { - override fun canSerializeIn(p_255875_: HolderOwner): Boolean { - return true // because we can always reference things, even if they are not "registered" at this moment - } -} +private val oreKey by lazy { ResourceKey.create(Registries.CONFIGURED_FEATURE, modLocation("tritanium_ore")) } -private data class Both(val key: Holder, val value: Holder) - -private fun createHolders(key: ResourceKey, value: T): Both { - val keyOnly = Holder.Reference.createStandAlone(Owner as HolderOwner, key) - val valueOnly = Holder.direct(value) - return Both(keyOnly, valueOnly) -} - -private fun remap(vararg input: Both): Map> { - val result = LinkedHashMap>() - - for (value in input) { - result[value.key.unwrapKey().get().location()] = value.value - } - - return result -} - -fun registerOreGen(event: GatherDataEvent) { +private fun configuredFeatures(context: BootstapContext>) { val stone = TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES) val deepslate = TagMatchTest(BlockTags.DEEPSLATE_ORE_REPLACEABLES) - val target by lazy { - listOf( - OreConfiguration.target(stone, MBlocks.TRITANIUM_ORE.defaultBlockState()), - OreConfiguration.target(deepslate, MBlocks.DEEPSLATE_TRITANIUM_ORE.defaultBlockState()), - ) - } + val target = listOf( + OreConfiguration.target(stone, MBlocks.TRITANIUM_ORE.defaultBlockState()), + OreConfiguration.target(deepslate, MBlocks.DEEPSLATE_TRITANIUM_ORE.defaultBlockState()), + ) - val ops = RegistryOps.create(JsonOps.INSTANCE, event.lookupProvider.join()) - val tritanium = createHolders(ResourceKey.create(Registries.CONFIGURED_FEATURE, modLocation("ore_tritanium")), ConfiguredFeature(Feature.ORE, OreConfiguration(target, 9))) - val configuredFeatures = remap(tritanium) + context.register(oreKey, ConfiguredFeature(Feature.ORE, OreConfiguration(target, 9))) +} - event.generator.addProvider(event.includeServer(), JsonCodecProvider( - event.generator.packOutput, event.existingFileHelper, DataGen.MOD_ID, ops, - PackType.SERVER_DATA, "worldgen/configured_feature", ConfiguredFeature.CODEC, configuredFeatures - )) +private fun placedFeatures(context: BootstapContext) { + fun location(name: String) = ResourceKey.create(Registries.PLACED_FEATURE, modLocation(name)) - val placedTritanium = createHolders(ResourceKey.create(Registries.PLACED_FEATURE, modLocation("normal_tritanium")), PlacedFeature( - tritanium.key, + val configured = context.lookup(Registries.CONFIGURED_FEATURE) + val ore = configured.getOrThrow(oreKey) + + context.register(location("normal_tritanium"), PlacedFeature( + ore, listOf( CountPlacement.of(8), InSquarePlacement.spread(), @@ -75,19 +47,20 @@ fun registerOreGen(event: GatherDataEvent) { ) )) - val placedTritaniumDeep = createHolders(ResourceKey.create(Registries.PLACED_FEATURE, modLocation("deep_tritanium")), PlacedFeature( - tritanium.key, + context.register(location("deep_tritanium"), PlacedFeature( + ore, listOf( CountPlacement.of(10), InSquarePlacement.spread(), HeightRangePlacement.uniform(VerticalAnchor.aboveBottom(8), VerticalAnchor.absolute(0)) ) )) - - val placedFeatures = remap(placedTritanium, placedTritaniumDeep) - - event.generator.addProvider(event.includeServer(), JsonCodecProvider( - event.generator.packOutput, event.existingFileHelper, DataGen.MOD_ID, ops, - PackType.SERVER_DATA, "worldgen/placed_feature", PlacedFeature.CODEC, placedFeatures - )) +} + +fun registerOreGen(event: GatherDataEvent) { + val set = RegistrySetBuilder() + .add(Registries.CONFIGURED_FEATURE, ::configuredFeatures) + .add(Registries.PLACED_FEATURE, ::placedFeatures) + + event.generator.addProvider(event.includeServer(), DatapackBuiltinEntriesProvider(event.generator.packOutput, event.lookupProvider, set, setOf(DataGen.MOD_ID))) } From 37e0f152a708cb1a615d56348c19ed4fc2829012 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 13 Jan 2023 23:37:16 +0700 Subject: [PATCH 0032/1199] Suppress warnings from mixin --- .../dbotthepony/mc/otm/mixin/MixinPatchProjectileFinder.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinPatchProjectileFinder.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinPatchProjectileFinder.java index c49676bdc..4dd8325cb 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinPatchProjectileFinder.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinPatchProjectileFinder.java @@ -16,7 +16,8 @@ public class MixinPatchProjectileFinder { value = "INVOKE", target = "net.minecraftforge.common.ForgeHooks.getProjectile(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/item/ItemStack;", ordinal = 2, - shift = At.Shift.BEFORE + shift = At.Shift.BEFORE, + remap = false ), cancellable = true) private void exosuitGetProjectileHook(ItemStack weaponItem, CallbackInfoReturnable hook) { From 0c01a7cdafb7adf9401cdf470c20cb804d8d9be9 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 13 Jan 2023 23:37:28 +0700 Subject: [PATCH 0033/1199] Update signature of renderLevel in coremod --- src/main/resources/coremods/code_injector.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/coremods/code_injector.js b/src/main/resources/coremods/code_injector.js index 2a14deefa..884576aad 100644 --- a/src/main/resources/coremods/code_injector.js +++ b/src/main/resources/coremods/code_injector.js @@ -938,7 +938,7 @@ function initializeCoreMod() { 'type': 'METHOD', 'class': 'net.minecraft.client.renderer.LevelRenderer', 'methodName': ASMAPI.mapMethod('m_109599_'), // renderLevel - 'methodDesc': '(Lcom/mojang/blaze3d/vertex/PoseStack;FJZLnet/minecraft/client/Camera;Lnet/minecraft/client/renderer/GameRenderer;Lnet/minecraft/client/renderer/LightTexture;Lcom/mojang/math/Matrix4f;)V' + 'methodDesc': '(Lcom/mojang/blaze3d/vertex/PoseStack;FJZLnet/minecraft/client/Camera;Lnet/minecraft/client/renderer/GameRenderer;Lnet/minecraft/client/renderer/LightTexture;Lorg/joml/Matrix4f;)V' }, 'transformer': function(node) { From 5149b7432dafa43130ea7b8ba6879f4c6e5d263d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 13 Jan 2023 23:55:50 +0700 Subject: [PATCH 0034/1199] update render stuff --- .../dbotthepony/mc/otm/client/render/Ext.kt | 4 +-- .../render/blockentity/BlackHoleRenderer.kt | 2 +- .../GravitationStabilizerRenderer.kt | 2 +- .../ru/dbotthepony/mc/otm/core/EuclidMath.kt | 35 ++++++++++--------- .../ru/dbotthepony/mc/otm/core/MatrixExt.kt | 16 ++++----- 5 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt index 61efa2b17..1baf4bc9a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt @@ -75,7 +75,7 @@ private fun Font.drawScaledDuckTyped(poseStack: PoseStack, text: Any, scale: Flo poseStack.translate(-translation) poseStack.scale(scale, scale, scale) val inv = 1f / scale - poseStack.translate(-translation * inv) + poseStack.translate(translation * inv) val size = drawDuckTyped(poseStack, text, x * inv, y * inv, color) poseStack.popPose() @@ -89,7 +89,7 @@ private fun Font.drawScaledDuckTyped(poseStack: PoseStack, buffer: MultiBufferSo poseStack.translate(-translation) poseStack.scale(scale, scale, scale) val inv = 1f / scale - poseStack.translate(-translation * inv) + poseStack.translate(translation * inv) val size = drawDuckTyped(poseStack, buffer, text, x * inv, y * inv, color, drawShadow, seeThrough, packedLightCoords, effectColor) poseStack.popPose() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt index c6306278d..12c565310 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt @@ -163,7 +163,7 @@ class BlackHoleRenderer(private val context: BlockEntityRendererProvider.Context poseStack.pushPose() poseStack.translate(0.5, 0.75, 0.5) - poseStack.translate(ang.forward() * tile.gravitationStrength * 0.6) + poseStack.translate(ang.forward() * tile.gravitationStrength.pow(0.5)) poseStack.rotateAroundPoint(poseStack.translation(), ang) val scale = (distance.coerceAtLeast(8.0) / 168.0).toFloat() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt index bd1389ce6..fc56109ee 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt @@ -148,7 +148,7 @@ class GravitationStabilizerRenderer(private val context: BlockEntityRendererProv font.drawAligned(poseStack, sorse, TranslatableComponent("otm.3d2d.gravitation_stabilizer.mass", bhTile.mass.formatMatter()), TextAlign.TOP_CENTER, 1f, -font.lineHeight.toFloat() / 2f + 1f, 0) font.drawAligned(poseStack, sorse, TranslatableComponent("otm.3d2d.gravitation_stabilizer.strength", "%.2f".format(bhTile.gravitationStrength)), TextAlign.TOP_CENTER, 1f, font.lineHeight.toFloat() / 2f + 1f, 0) - poseStack.translate(facing.opposite.normal * 0.02) + poseStack.translate(0.2f, 0f, -0.5f) font.drawAligned(poseStack, sorse, TranslatableComponent("otm.3d2d.gravitation_stabilizer.mass", bhTile.mass.formatMatter()), TextAlign.TOP_CENTER, 0f, -font.lineHeight.toFloat() / 2f, 0xFFFFFF) font.drawAligned(poseStack, sorse, TranslatableComponent("otm.3d2d.gravitation_stabilizer.strength", "%.2f".format(bhTile.gravitationStrength)), TextAlign.TOP_CENTER, 0f, font.lineHeight.toFloat() / 2f, 0xFFFFFF) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/EuclidMath.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/EuclidMath.kt index fc6a940dc..1c9d2d084 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/EuclidMath.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/EuclidMath.kt @@ -61,13 +61,10 @@ fun Vector3f.rotationDegrees(degrees: Float): Quaternionf { } operator fun Vector3f.unaryMinus(): Vector3f { - x = -x - y = -y - z = -z - return this + return Vector3f(-x, -y, -z) } -operator fun Vector3f.times(v: Float): Vector3f = mul(v) +operator fun Vector3f.times(v: Float): Vector3f = Vector3f(v).mul(v) operator fun Vector3f.component1() = x() operator fun Vector3f.component2() = y() @@ -131,9 +128,9 @@ fun Vector.rotateAroundAxis(axis: Vector, rotation: Double): Vector { fun Vector.rotate(angle: IAngle): Vector { val rotation = angle.rotationXYZ() - val newx = x * rotation[0, 0] + y * rotation[0, 1] + z * rotation[0, 2] - val newy = x * rotation[1, 0] + y * rotation[1, 1] + z * rotation[1, 2] - val newz = x * rotation[2, 0] + y * rotation[2, 1] + z * rotation[2, 2] + val newx = x * rotation[0, 0,] + y * rotation[1, 0] + z * rotation[2, 0] + val newy = x * rotation[0, 1,] + y * rotation[1, 1] + z * rotation[2, 1] + val newz = x * rotation[0, 2,] + y * rotation[1, 2] + z * rotation[2, 2] return Vector(newx, newy, newz) } @@ -220,9 +217,11 @@ interface IAngle { val c = cos(roll).toFloat() it[0, 0] = 1f + it[1, 1] = c - it[1, 2] = -s - it[2, 1] = s + it[2, 1] = -s + + it[1, 2] = s it[2, 2] = c } } @@ -237,9 +236,11 @@ interface IAngle { val c = cos(pitch).toFloat() it[0, 0] = c - it[0, 1] = -s - it[1, 0] = s + it[1, 0] = -s + + it[0, 1] = s it[1, 1] = c + it[2, 2] = 1f } } @@ -253,13 +254,13 @@ interface IAngle { val s = sin(yaw).toFloat() val c = cos(yaw).toFloat() - it[0, 0] = c - it[0, 2] = s + it[0, 0,] = c + it[2, 0,] = s - it[2, 0] = -s - it[2, 2] = c + it[0, 2,] = -s + it[2, 2,] = c - it[1, 1] = 1f + it[1, 1,] = 1f } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/MatrixExt.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/MatrixExt.kt index 770b60ec1..e6e1281fc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/MatrixExt.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/MatrixExt.kt @@ -21,39 +21,39 @@ fun Matrix4f.rotateAroundPoint(point: Vector, axis: Vector, rotation: Float, isD val p = point.asVector3f() translate(-p) rotation(axis.rotateAroundThis(rotation, isDegrees)) // TODO: 1.19.3 - translate(-p) + translate(p) } fun Matrix4f.rotateAroundPoint(point: Vector, axis: Vector3f, rotation: Float, isDegrees: Boolean = false) { val p = point.asVector3f() translate(-p) rotation(if (isDegrees) axis.rotationDegrees(rotation) else axis.rotation(rotation)) // TODO: 1.19.3 - translate(-p) + translate(p) } fun Matrix4f.rotateAroundPoint(point: Vector, rotation: IAngle) { val p = point.asVector3f() translate(-p) mul(rotation.rotationXYZW()) - translate(-p) + translate(p) } fun Matrix4f.rotateAroundPoint(point: Vector3f, axis: Vector, rotation: Float, isDegrees: Boolean = false) { translate(-point) rotation(axis.rotateAroundThis(rotation, isDegrees)) // TODO: 1.19.3 - translate(-point) + translate(point) } fun Matrix4f.rotateAroundPoint(point: Vector3f, rotation: IAngle) { translate(-point) mul(rotation.rotationXYZW()) - translate(-point) + translate(point) } fun Matrix4f.rotateAroundPoint(point: Vector3f, axis: Vector3f, rotation: Float, isDegrees: Boolean = false) { translate(-point) rotation(if (isDegrees) axis.rotationDegrees(rotation) else axis.rotation(rotation)) // TODO: 1.19.3 - translate(-point) + translate(point) } fun Matrix3f.toMatrix4f(): Matrix4f { @@ -76,7 +76,7 @@ fun Matrix3f.toMatrix4f(): Matrix4f { var Matrix4f.translation: Vector3f get() { - return Vector3f(this[3, 0], this[3, 1], this[3, 2]) + return Vector3f(this[0, 3], this[1, 3], this[2, 3]) } set(value) { @@ -92,7 +92,7 @@ var Matrix4f.translation: Vector3f var Matrix4f.translation4: Vector4f get() { - return Vector4f(this[3, 0], this[3, 1], this[3, 2], this[3, 3]) + return Vector4f(this[0, 3], this[1, 3], this[2, 3], this[3, 3]) } set(value) { From ce437d4e140fe61bbc29ddf62e5eb6dd7ac4f6d2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 14 Jan 2023 10:05:42 +0700 Subject: [PATCH 0035/1199] Remove Fraction class --- .../ru/dbotthepony/mc/otm/core/Decimal.kt | 12 - .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 55 +- .../ru/dbotthepony/mc/otm/core/Formatting.kt | 1 - .../ru/dbotthepony/mc/otm/core/Fraction.kt | 931 ------------------ .../dbotthepony/mc/otm/tests/FractionTests.kt | 345 ------- 5 files changed, 1 insertion(+), 1343 deletions(-) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/Fraction.kt delete mode 100644 src/test/kotlin/ru/dbotthepony/mc/otm/tests/FractionTests.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Decimal.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Decimal.kt index 68d8ab1d7..ddd2f602b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Decimal.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Decimal.kt @@ -729,18 +729,6 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 return toInt().toShort() } - fun toFraction(): Fraction { - if (isZero) { - return Fraction.ZERO - } - - if (weakEqualDoubles(decimal, 0.0)) { - return Fraction(whole) - } - - return Fraction(toBigDecmial()) - } - fun percentage(divisor: Decimal, zeroing: Boolean = true): Float { if ((isZero || divisor.isZero) && zeroing) return 0f if (isNaN || divisor.isNaN || divisor.isZero) return Float.NaN 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 5466189c0..dbb2e120e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -59,19 +59,6 @@ fun Number.dynPlus(other: Number): Number { is Int, is Byte, is Short -> this + other.toInt() is Long -> this + other.toLong() is Decimal -> this + other - is Fraction -> this + other.toImpreciseFraction() - else -> throw IllegalStateException("I don't know what to do with ${other::class.qualifiedName} (right hand operand)") - } - } - - is Fraction -> { - when (other) { - is Float -> this + other.toFloat() - is Double -> this + other.toDouble() - is Int, is Byte, is Short -> this + other.toInt() - is Long -> this + other.toLong() - is Decimal -> this + other.toFraction() - is Fraction -> this + other else -> throw IllegalStateException("I don't know what to do with ${other::class.qualifiedName} (right hand operand)") } } @@ -101,19 +88,6 @@ fun Number.dynMinus(other: Number): Number { is Int, is Byte, is Short -> this - other.toInt() is Long -> this - other.toLong() is Decimal -> this - other - is Fraction -> this - other.toImpreciseFraction() - else -> throw IllegalStateException("I don't know what to do with ${other::class.qualifiedName} (right hand operand)") - } - } - - is Fraction -> { - when (other) { - is Float -> this - other.toFloat() - is Double -> this - other.toDouble() - is Int, is Byte, is Short -> this - other.toInt() - is Long -> this - other.toLong() - is Decimal -> this - other.toFraction() - is Fraction -> this - other else -> throw IllegalStateException("I don't know what to do with ${other::class.qualifiedName} (right hand operand)") } } @@ -143,19 +117,6 @@ fun Number.dynTimes(other: Number): Number { is Int, is Byte, is Short -> this * other.toInt() is Long -> this * other.toLong() is Decimal -> this * other - is Fraction -> this * other.toImpreciseFraction() - else -> throw IllegalStateException("I don't know what to do with ${other::class.qualifiedName} (right hand operand)") - } - } - - is Fraction -> { - when (other) { - is Float -> this * other.toFloat() - is Double -> this * other.toDouble() - is Int, is Byte, is Short -> this * other.toInt() - is Long -> this * other.toLong() - is Decimal -> this * other.toFraction() - is Fraction -> this * other else -> throw IllegalStateException("I don't know what to do with ${other::class.qualifiedName} (right hand operand)") } } @@ -185,19 +146,6 @@ fun Number.dynDiv(other: Number): Number { is Int, is Byte, is Short -> this / other.toInt() is Long -> this / other.toLong() is Decimal -> this / other - is Fraction -> this / other.toImpreciseFraction() - else -> throw IllegalStateException("I don't know what to do with ${other::class.qualifiedName} (right hand operand)") - } - } - - is Fraction -> { - when (other) { - is Float -> this / other.toFloat() - is Double -> this / other.toDouble() - is Int, is Byte, is Short -> this / other.toInt() - is Long -> this / other.toLong() - is Decimal -> this / other.toFraction() - is Fraction -> this / other else -> throw IllegalStateException("I don't know what to do with ${other::class.qualifiedName} (right hand operand)") } } @@ -206,7 +154,7 @@ fun Number.dynDiv(other: Number): Number { } } -val Number.isFractional get() = this is Float || this is Double || this is Decimal || this is Fraction +val Number.isFractional get() = this is Float || this is Double || this is Decimal val Number.isWhole get() = !isFractional fun Number.toDecimal(): Decimal { @@ -218,7 +166,6 @@ fun Number.toDecimal(): Decimal { is Byte -> Decimal(this) is Short -> Decimal(this) is Long -> Decimal(this) - is Fraction -> this.toImpreciseFraction() else -> throw ClassCastException("Can not turn $this into ImpreciseFraction") } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Formatting.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Formatting.kt index 70dbdba68..e67b33a37 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Formatting.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Formatting.kt @@ -87,7 +87,6 @@ enum class SiPrefix( } val decimal = BigDecimal(string) - val fraction = Fraction(decimal) val impreciseFraction = Decimal(string) val integer = if (!fractional) BigInteger(string) else null diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Fraction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Fraction.kt deleted file mode 100644 index 4733891a5..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Fraction.kt +++ /dev/null @@ -1,931 +0,0 @@ -package ru.dbotthepony.mc.otm.core - -import net.minecraft.nbt.ByteArrayTag -import net.minecraft.nbt.StringTag -import net.minecraft.nbt.Tag -import net.minecraft.network.FriendlyByteBuf -import org.apache.logging.log4j.LogManager -import java.math.BigDecimal -import java.math.BigInteger -import java.math.MathContext -import java.math.RoundingMode - -private fun powScale(int: Int): BigInteger { - if (int <= 0) - return BigInteger.ONE - - var result = BigInteger.TEN - - for (i in 2 .. int) - result *= BigInteger.TEN - - return result -} - -private fun powUnscaled(unscaled: BigInteger, scale: Int): BigInteger { - if (scale >= 0) - return unscaled - - var result = unscaled - - for (i in 2 .. -scale) - result *= BigInteger.TEN - - return result -} - -val DEFAULT_MATH_CONTEXT = MathContext(64, RoundingMode.HALF_UP) - -@Suppress("NOTHING_TO_INLINE") -private inline fun invertCompare(int: Int): Int { - if (int == 0) - return 0 - - return if (int < 0) 1 else -1 -} - -private val BI_MINUS_ZERO = BigInteger("-0") -private val BI_MINUS_ONE = BigInteger("-1") -private val BI_DIV = BigInteger.valueOf(1_000_000_000) -private val BI_DIV2 = BigInteger.valueOf(10) -private val BI_MINUS_DIV = BigInteger.valueOf(-1_000_000_000) - -private fun isZero(value: BigInteger): Boolean { - return when (value.signum()) { - 0 -> true - 1 -> value == BigInteger.ZERO - -1 -> value == BI_MINUS_ZERO - else -> false - } -} - -private fun isOne(value: BigInteger): Boolean { - return when (value.signum()) { - 0 -> false - 1 -> value == BigInteger.ONE - -1 -> value == BI_MINUS_ONE - else -> false - } -} - -private fun compactTwoMod(value1: BigInteger, value2: BigInteger, compact: Boolean = true): Fraction { - val mod = value1.divideAndRemainder(value2) - - if (isZero(mod[1])) - return Fraction(mod[0], compact = compact) - - return Fraction(value1, value2, compact = compact) -} - -private fun positive(value: BigInteger): BigInteger { - return when (value.signum()) { - 0 -> value - 1 -> value - -1 -> -value - else -> throw InternalError() - } -} - -private val GCDs = arrayOf( - BigInteger.valueOf(2), BigInteger.valueOf(3), BigInteger.valueOf(5), BigInteger.valueOf(7), BigInteger.valueOf(11), BigInteger.valueOf(13), BigInteger.valueOf(17), BigInteger.valueOf(19), BigInteger.valueOf(23), BigInteger.valueOf(29), BigInteger.valueOf(31), BigInteger.valueOf(37), BigInteger.valueOf(41), BigInteger.valueOf(43), BigInteger.valueOf(47), BigInteger.valueOf(53), BigInteger.valueOf(59), BigInteger.valueOf(61), BigInteger.valueOf(67), BigInteger.valueOf(71), - BigInteger.valueOf(73), BigInteger.valueOf(79), BigInteger.valueOf(83), BigInteger.valueOf(89), BigInteger.valueOf(97), BigInteger.valueOf(101), BigInteger.valueOf(103), BigInteger.valueOf(107), BigInteger.valueOf(109), BigInteger.valueOf(113), BigInteger.valueOf(127), BigInteger.valueOf(131), BigInteger.valueOf(137), BigInteger.valueOf(139), BigInteger.valueOf(149), BigInteger.valueOf(151), BigInteger.valueOf(157), BigInteger.valueOf(163), BigInteger.valueOf(167), BigInteger.valueOf(173), - BigInteger.valueOf(179), BigInteger.valueOf(181), BigInteger.valueOf(191), BigInteger.valueOf(193), BigInteger.valueOf(197), BigInteger.valueOf(199), BigInteger.valueOf(211), BigInteger.valueOf(223), BigInteger.valueOf(227), BigInteger.valueOf(229), BigInteger.valueOf(233), BigInteger.valueOf(239), BigInteger.valueOf(241), BigInteger.valueOf(251), BigInteger.valueOf(257), BigInteger.valueOf(263), BigInteger.valueOf(269), BigInteger.valueOf(271), BigInteger.valueOf(277), BigInteger.valueOf(281), - BigInteger.valueOf(283), BigInteger.valueOf(293), BigInteger.valueOf(307), BigInteger.valueOf(311), BigInteger.valueOf(313), BigInteger.valueOf(317), BigInteger.valueOf(331), BigInteger.valueOf(337), BigInteger.valueOf(347), BigInteger.valueOf(349), BigInteger.valueOf(353), BigInteger.valueOf(359), BigInteger.valueOf(367), BigInteger.valueOf(373), BigInteger.valueOf(379), BigInteger.valueOf(383), BigInteger.valueOf(389), BigInteger.valueOf(397), BigInteger.valueOf(401), BigInteger.valueOf(409), - BigInteger.valueOf(419), BigInteger.valueOf(421), BigInteger.valueOf(431), BigInteger.valueOf(433), BigInteger.valueOf(439), BigInteger.valueOf(443), BigInteger.valueOf(449), BigInteger.valueOf(457), BigInteger.valueOf(461), BigInteger.valueOf(463), BigInteger.valueOf(467), BigInteger.valueOf(479), BigInteger.valueOf(487), BigInteger.valueOf(491), BigInteger.valueOf(499), BigInteger.valueOf(503), BigInteger.valueOf(509), BigInteger.valueOf(521), BigInteger.valueOf(523), BigInteger.valueOf(541), - BigInteger.valueOf(547), BigInteger.valueOf(557), BigInteger.valueOf(563), BigInteger.valueOf(569), BigInteger.valueOf(571), BigInteger.valueOf(577), BigInteger.valueOf(587), BigInteger.valueOf(593), BigInteger.valueOf(599), BigInteger.valueOf(601), BigInteger.valueOf(607), BigInteger.valueOf(613), BigInteger.valueOf(617), BigInteger.valueOf(619), BigInteger.valueOf(631), BigInteger.valueOf(641), BigInteger.valueOf(643), BigInteger.valueOf(647), BigInteger.valueOf(653), BigInteger.valueOf(659), - BigInteger.valueOf(661), BigInteger.valueOf(673), BigInteger.valueOf(677), BigInteger.valueOf(683), BigInteger.valueOf(691), BigInteger.valueOf(701), BigInteger.valueOf(709), BigInteger.valueOf(719), BigInteger.valueOf(727), BigInteger.valueOf(733), BigInteger.valueOf(739), BigInteger.valueOf(743), BigInteger.valueOf(751), BigInteger.valueOf(757), BigInteger.valueOf(761), BigInteger.valueOf(769), BigInteger.valueOf(773), BigInteger.valueOf(787), BigInteger.valueOf(797), BigInteger.valueOf(809), - BigInteger.valueOf(811), BigInteger.valueOf(821), BigInteger.valueOf(823), BigInteger.valueOf(827), BigInteger.valueOf(829), BigInteger.valueOf(839), BigInteger.valueOf(853), BigInteger.valueOf(857), BigInteger.valueOf(859), BigInteger.valueOf(863), BigInteger.valueOf(877), BigInteger.valueOf(881), BigInteger.valueOf(883), BigInteger.valueOf(887), BigInteger.valueOf(907), BigInteger.valueOf(911), BigInteger.valueOf(919), BigInteger.valueOf(929), BigInteger.valueOf(937), BigInteger.valueOf(941), - BigInteger.valueOf(947), BigInteger.valueOf(953), BigInteger.valueOf(967), BigInteger.valueOf(971), BigInteger.valueOf(977), BigInteger.valueOf(983), BigInteger.valueOf(991), BigInteger.valueOf(997), BigInteger.valueOf(1009), BigInteger.valueOf(1013), BigInteger.valueOf(1019), BigInteger.valueOf(1021), BigInteger.valueOf(1031), BigInteger.valueOf(1033), BigInteger.valueOf(1039), BigInteger.valueOf(1049), BigInteger.valueOf(1051), BigInteger.valueOf(1061), BigInteger.valueOf(1063), BigInteger.valueOf(1069), - BigInteger.valueOf(1087), BigInteger.valueOf(1091), BigInteger.valueOf(1093), BigInteger.valueOf(1097), BigInteger.valueOf(1103), BigInteger.valueOf(1109), BigInteger.valueOf(1117), BigInteger.valueOf(1123), BigInteger.valueOf(1129), BigInteger.valueOf(1151), BigInteger.valueOf(1153), BigInteger.valueOf(1163), BigInteger.valueOf(1171), BigInteger.valueOf(1181), BigInteger.valueOf(1187), BigInteger.valueOf(1193), BigInteger.valueOf(1201), BigInteger.valueOf(1213), BigInteger.valueOf(1217), BigInteger.valueOf(1223), - BigInteger.valueOf(1229), BigInteger.valueOf(1231), BigInteger.valueOf(1237), BigInteger.valueOf(1249), BigInteger.valueOf(1259), BigInteger.valueOf(1277), BigInteger.valueOf(1279), BigInteger.valueOf(1283), BigInteger.valueOf(1289), BigInteger.valueOf(1291), BigInteger.valueOf(1297), BigInteger.valueOf(1301), BigInteger.valueOf(1303), BigInteger.valueOf(1307), BigInteger.valueOf(1319), BigInteger.valueOf(1321), BigInteger.valueOf(1327), BigInteger.valueOf(1361), BigInteger.valueOf(1367), BigInteger.valueOf(1373), - BigInteger.valueOf(1381), BigInteger.valueOf(1399), BigInteger.valueOf(1409), BigInteger.valueOf(1423), BigInteger.valueOf(1427), BigInteger.valueOf(1429), BigInteger.valueOf(1433), BigInteger.valueOf(1439), BigInteger.valueOf(1447), BigInteger.valueOf(1451), BigInteger.valueOf(1453), BigInteger.valueOf(1459), BigInteger.valueOf(1471), BigInteger.valueOf(1481), BigInteger.valueOf(1483), BigInteger.valueOf(1487), BigInteger.valueOf(1489), BigInteger.valueOf(1493), BigInteger.valueOf(1499), BigInteger.valueOf(1511), - BigInteger.valueOf(1523), BigInteger.valueOf(1531), BigInteger.valueOf(1543), BigInteger.valueOf(1549), BigInteger.valueOf(1553), BigInteger.valueOf(1559), BigInteger.valueOf(1567), BigInteger.valueOf(1571), BigInteger.valueOf(1579), BigInteger.valueOf(1583), BigInteger.valueOf(1597), BigInteger.valueOf(1601), BigInteger.valueOf(1607), BigInteger.valueOf(1609), BigInteger.valueOf(1613), BigInteger.valueOf(1619), BigInteger.valueOf(1621), BigInteger.valueOf(1627), BigInteger.valueOf(1637), BigInteger.valueOf(1657), - BigInteger.valueOf(1663), BigInteger.valueOf(1667), BigInteger.valueOf(1669), BigInteger.valueOf(1693), BigInteger.valueOf(1697), BigInteger.valueOf(1699), BigInteger.valueOf(1709), BigInteger.valueOf(1721), BigInteger.valueOf(1723), BigInteger.valueOf(1733), BigInteger.valueOf(1741), BigInteger.valueOf(1747), BigInteger.valueOf(1753), BigInteger.valueOf(1759), BigInteger.valueOf(1777), BigInteger.valueOf(1783), BigInteger.valueOf(1787), BigInteger.valueOf(1789), BigInteger.valueOf(1801), BigInteger.valueOf(1811), - BigInteger.valueOf(1823), BigInteger.valueOf(1831), BigInteger.valueOf(1847), BigInteger.valueOf(1861), BigInteger.valueOf(1867), BigInteger.valueOf(1871), BigInteger.valueOf(1873), BigInteger.valueOf(1877), BigInteger.valueOf(1879), BigInteger.valueOf(1889), BigInteger.valueOf(1901), BigInteger.valueOf(1907), BigInteger.valueOf(1913), BigInteger.valueOf(1931), BigInteger.valueOf(1933), BigInteger.valueOf(1949), BigInteger.valueOf(1951), BigInteger.valueOf(1973), BigInteger.valueOf(1979), BigInteger.valueOf(1987), - BigInteger.valueOf(1993), BigInteger.valueOf(1997), BigInteger.valueOf(1999), BigInteger.valueOf(2003), BigInteger.valueOf(2011), BigInteger.valueOf(2017), BigInteger.valueOf(2027), BigInteger.valueOf(2029), BigInteger.valueOf(2039), BigInteger.valueOf(2053), BigInteger.valueOf(2063), BigInteger.valueOf(2069), BigInteger.valueOf(2081), BigInteger.valueOf(2083), BigInteger.valueOf(2087), BigInteger.valueOf(2089), BigInteger.valueOf(2099), BigInteger.valueOf(2111), BigInteger.valueOf(2113), BigInteger.valueOf(2129), - BigInteger.valueOf(2131), BigInteger.valueOf(2137), BigInteger.valueOf(2141), BigInteger.valueOf(2143), BigInteger.valueOf(2153), BigInteger.valueOf(2161), BigInteger.valueOf(2179), BigInteger.valueOf(2203), BigInteger.valueOf(2207), BigInteger.valueOf(2213), BigInteger.valueOf(2221), BigInteger.valueOf(2237), BigInteger.valueOf(2239), BigInteger.valueOf(2243), BigInteger.valueOf(2251), BigInteger.valueOf(2267), BigInteger.valueOf(2269), BigInteger.valueOf(2273), BigInteger.valueOf(2281), BigInteger.valueOf(2287), - BigInteger.valueOf(2293), BigInteger.valueOf(2297), BigInteger.valueOf(2309), BigInteger.valueOf(2311), BigInteger.valueOf(2333), BigInteger.valueOf(2339), BigInteger.valueOf(2341), BigInteger.valueOf(2347), BigInteger.valueOf(2351), BigInteger.valueOf(2357), BigInteger.valueOf(2371), BigInteger.valueOf(2377), BigInteger.valueOf(2381), BigInteger.valueOf(2383), BigInteger.valueOf(2389), BigInteger.valueOf(2393), BigInteger.valueOf(2399), BigInteger.valueOf(2411), BigInteger.valueOf(2417), BigInteger.valueOf(2423), - BigInteger.valueOf(2437), BigInteger.valueOf(2441), BigInteger.valueOf(2447), BigInteger.valueOf(2459), BigInteger.valueOf(2467), BigInteger.valueOf(2473), BigInteger.valueOf(2477), BigInteger.valueOf(2503), BigInteger.valueOf(2521), BigInteger.valueOf(2531), BigInteger.valueOf(2539), BigInteger.valueOf(2543), BigInteger.valueOf(2549), BigInteger.valueOf(2551), BigInteger.valueOf(2557), BigInteger.valueOf(2579), BigInteger.valueOf(2591), BigInteger.valueOf(2593), BigInteger.valueOf(2609), BigInteger.valueOf(2617), - BigInteger.valueOf(2621), BigInteger.valueOf(2633), BigInteger.valueOf(2647), BigInteger.valueOf(2657), BigInteger.valueOf(2659), BigInteger.valueOf(2663), BigInteger.valueOf(2671), BigInteger.valueOf(2677), BigInteger.valueOf(2683), BigInteger.valueOf(2687), BigInteger.valueOf(2689), BigInteger.valueOf(2693), BigInteger.valueOf(2699), BigInteger.valueOf(2707), BigInteger.valueOf(2711), BigInteger.valueOf(2713), BigInteger.valueOf(2719), BigInteger.valueOf(2729), BigInteger.valueOf(2731), BigInteger.valueOf(2741), - BigInteger.valueOf(2749), BigInteger.valueOf(2753), BigInteger.valueOf(2767), BigInteger.valueOf(2777), BigInteger.valueOf(2789), BigInteger.valueOf(2791), BigInteger.valueOf(2797), BigInteger.valueOf(2801), BigInteger.valueOf(2803), BigInteger.valueOf(2819), BigInteger.valueOf(2833), BigInteger.valueOf(2837), BigInteger.valueOf(2843), BigInteger.valueOf(2851), BigInteger.valueOf(2857), BigInteger.valueOf(2861), BigInteger.valueOf(2879), BigInteger.valueOf(2887), BigInteger.valueOf(2897), BigInteger.valueOf(2903), - BigInteger.valueOf(2909), BigInteger.valueOf(2917), BigInteger.valueOf(2927), BigInteger.valueOf(2939), BigInteger.valueOf(2953), BigInteger.valueOf(2957), BigInteger.valueOf(2963), BigInteger.valueOf(2969), BigInteger.valueOf(2971), BigInteger.valueOf(2999), BigInteger.valueOf(3001), BigInteger.valueOf(3011), BigInteger.valueOf(3019), BigInteger.valueOf(3023), BigInteger.valueOf(3037), BigInteger.valueOf(3041), BigInteger.valueOf(3049), BigInteger.valueOf(3061), BigInteger.valueOf(3067), BigInteger.valueOf(3079), - BigInteger.valueOf(3083), BigInteger.valueOf(3089), BigInteger.valueOf(3109), BigInteger.valueOf(3119), BigInteger.valueOf(3121), BigInteger.valueOf(3137), BigInteger.valueOf(3163), BigInteger.valueOf(3167), BigInteger.valueOf(3169), BigInteger.valueOf(3181), BigInteger.valueOf(3187), BigInteger.valueOf(3191), BigInteger.valueOf(3203), BigInteger.valueOf(3209), BigInteger.valueOf(3217), BigInteger.valueOf(3221), BigInteger.valueOf(3229), BigInteger.valueOf(3251), BigInteger.valueOf(3253), BigInteger.valueOf(3257), - BigInteger.valueOf(3259), BigInteger.valueOf(3271), BigInteger.valueOf(3299), BigInteger.valueOf(3301), BigInteger.valueOf(3307), BigInteger.valueOf(3313), BigInteger.valueOf(3319), BigInteger.valueOf(3323), BigInteger.valueOf(3329), BigInteger.valueOf(3331), BigInteger.valueOf(3343), BigInteger.valueOf(3347), BigInteger.valueOf(3359), BigInteger.valueOf(3361), BigInteger.valueOf(3371), BigInteger.valueOf(3373), BigInteger.valueOf(3389), BigInteger.valueOf(3391), BigInteger.valueOf(3407), BigInteger.valueOf(3413), - BigInteger.valueOf(3433), BigInteger.valueOf(3449), BigInteger.valueOf(3457), BigInteger.valueOf(3461), BigInteger.valueOf(3463), BigInteger.valueOf(3467), BigInteger.valueOf(3469), BigInteger.valueOf(3491), BigInteger.valueOf(3499), BigInteger.valueOf(3511), BigInteger.valueOf(3517), BigInteger.valueOf(3527), BigInteger.valueOf(3529), BigInteger.valueOf(3533), BigInteger.valueOf(3539), BigInteger.valueOf(3541), BigInteger.valueOf(3547), BigInteger.valueOf(3557), BigInteger.valueOf(3559), BigInteger.valueOf(3571), -) - -private val COMPACT_THRESHOLD = BigInteger("1000000000000000000000") - -@Suppress("NAME_SHADOWING") -private fun compactTwo(value1: BigInteger, value2: BigInteger, compact: Boolean = true): Fraction { - when (value1.signum()) { - 0 -> return Fraction(value1, value2, compact = compact) - 1 -> if (value1 < BI_DIV) return compactTwoMod(value1, value2, compact) - -1 -> if (value1 > BI_MINUS_DIV) return compactTwoMod(value1, value2, compact) - } - - when (value2.signum()) { - 0 -> return Fraction(value1, value2, compact = compact) - 1 -> if (value2 < BI_DIV) return compactTwoMod(value1, value2, compact) - -1 -> if (value2 > BI_MINUS_DIV) return compactTwoMod(value1, value2, compact) - } - - var value1 = value1 - var value2 = value2 - - while (true) { - val _a = value1.divideAndRemainder(BI_DIV) - val _b = value2.divideAndRemainder(BI_DIV) - - if (!isZero(_a[1]) || !isZero(_b[1])) - break - - value1 = _a[0] - value2 = _b[0] - } - - while (true) { - val _a = value1.divideAndRemainder(BI_DIV2) - val _b = value2.divideAndRemainder(BI_DIV2) - - if (!isZero(_a[1]) || !isZero(_b[1])) - break - - value1 = _a[0] - value2 = _b[0] - } - - val p1 = positive(value1) - val p2 = positive(value2) - - if (p1 > COMPACT_THRESHOLD || p2 > COMPACT_THRESHOLD) { - var hit = true - - while (hit) { - hit = false - - for (i in GCDs.size - 1 downTo 0) { - val div = GCDs[i] - - while (true) { - val _a = value1.divideAndRemainder(div) - val _b = value2.divideAndRemainder(div) - - if (!isZero(_a[1]) || !isZero(_b[1])) - break - - value1 = _a[0] - value2 = _b[0] - hit = true - } - } - } - } else if (p1 > GCDs[0] && p2 > GCDs[0]) { - var hit = true - - while (hit) { - hit = false - - for (i in 4 downTo 0) { - val div = GCDs[i] - - while (true) { - val _a = value1.divideAndRemainder(div) - val _b = value2.divideAndRemainder(div) - - if (!isZero(_a[1]) || !isZero(_b[1])) - break - - value1 = _a[0] - value2 = _b[0] - hit = true - } - } - } - } - - return compactTwoMod(value1, value2, compact) -} - -private fun unsignedInt(value: Byte): Int { - if (value < 0) { - return 256 + value - } - - return value.toInt() -} - -private data class MagnitudeCrunchResult(val value: BigInteger, val mag: Int) - -@Suppress("NAME_SHADOWING") -private fun magnitude(value: BigInteger): MagnitudeCrunchResult { - if (isZero(value)) - return MagnitudeCrunchResult(value, 0) - - var mag = 0 - var value = value - - while (true) { - val c = value.divideAndRemainder(BI_DIV2) - - if (!isZero(c[1])) - break - - value = c[0] - mag++ - } - - return MagnitudeCrunchResult(value, mag) -} - -@Suppress("unused") -class Fraction @JvmOverloads constructor( - val value: BigInteger, - val divisor: BigInteger = BigInteger.ONE, - val compact: Boolean = true -) : Number(), Comparable { - @JvmOverloads constructor(value: Long, compact: Boolean = true) : this(BigInteger.valueOf(value), compact = compact) - @JvmOverloads constructor(value: Int, compact: Boolean = true) : this(BigInteger.valueOf(value.toLong()), compact = compact) - @JvmOverloads constructor(value: Float, compact: Boolean = true) : this(BigDecimal(value.toString()), compact = compact) - @JvmOverloads constructor(value: Double, compact: Boolean = true) : this(BigDecimal(value.toString()), compact = compact) - @JvmOverloads constructor(value: String, compact: Boolean = true) : this(BigDecimal(value), compact = compact) - - @JvmOverloads constructor(value: Long, div: Long, compact: Boolean = true) : this(BigInteger.valueOf(value), BigInteger.valueOf(div), compact = compact) - @JvmOverloads constructor(value: Int, div: Int, compact: Boolean = true) : this(BigInteger.valueOf(value.toLong()), BigInteger.valueOf(div.toLong()), compact = compact) - @JvmOverloads constructor(value: Float, div: Float, compact: Boolean = true) : this(BigDecimal(value.toString()), BigDecimal(div.toString()), compact = compact) - @JvmOverloads constructor(value: Double, div: Double, compact: Boolean = true) : this(BigDecimal(value.toString()), BigDecimal(div.toString()), compact = compact) - @JvmOverloads constructor(value: String, div: String, compact: Boolean = true) : this(BigDecimal(value), BigDecimal(div), compact = compact) - - @JvmOverloads constructor(value: BigDecimal, compact: Boolean = true) : this(powUnscaled(value.unscaledValue(), value.scale()), powScale(value.scale()), compact = compact) - @JvmOverloads constructor(value: BigDecimal, div: BigDecimal, compact: Boolean = true) : this(powUnscaled(value.unscaledValue(), value.scale()).multiply(powScale(div.scale())), powScale(value.scale()).multiply(powUnscaled(div.unscaledValue(), div.scale())), compact = compact) - - override fun equals(other: Any?): Boolean { - if (other is Fraction) { - if (other.divisor == divisor) - return other.value == value - - val a = value * other.divisor - val b = other.value * divisor - - return a == b - } - - return false - } - - override fun hashCode(): Int { - return 31 * value.hashCode() + divisor.hashCode() - } - - fun compactAndCanonize(): Fraction { - if (value == BigInteger.ZERO || value == BigInteger.ONE || divisor == BigInteger.ONE) - return this - - val a = signnum() - val b = value.signum() - val c = divisor.signum() - - if (a != b && a != c) { - if (isZero(divisor)) - return Fraction(-value, -divisor) - - val mod = value.divideAndRemainder(divisor) - - if (isZero(mod[1])) - return Fraction(mod[0], compact = compact) - - return Fraction(-value, -divisor) - } - - if (isZero(divisor)) - return this - - return compactTwo(value, divisor, compact) - } - - fun isZero(): Boolean { - if (isNaN()) return false - return value == BigInteger.ZERO - } - - fun isOne(): Boolean { - if (isNaN()) return false - return value != BigInteger.ZERO && value == divisor - } - - fun compact(): Fraction { - if (isNaN()) return this - - if (value == BigInteger.ZERO || value == BigInteger.ONE || divisor == BigInteger.ONE) - return this - - if (divisor == BigInteger.ZERO || divisor == BI_MINUS_ZERO) - return this - - return compactTwo(value, divisor, compact) - } - - fun canonize(): Fraction { - if (isNaN()) return this - - if (value == BigInteger.ZERO || value == BigInteger.ONE || divisor == BigInteger.ONE || divisor == BigInteger.ZERO) - return this - - val a = signnum() - val b = value.signum() - val c = divisor.signum() - - if (a != b && a != c) - return Fraction(-value, -divisor) - - return this - } - - // Операторы - fun equalsCompact(other: Fraction?): Boolean { - if (other == null) - return false - - if (isNaN() || other.isNaN()) return false - - val a = compact() - val b = other.compact() - - return a.value == b.value && a.divisor == b.divisor - } - - override operator fun compareTo(other: Fraction): Int { - if (isNaN() || other.isNaN()) return 0 - - if (divisor == other.divisor) - return value.compareTo(other.value) - - val a = signnum() - val b = other.signnum() - - if (a == b && a == 0) - return 0 - - if (a < b) - return -1 - else if (a > b) - return 1 - - val cmp = (value * other.divisor).compareTo(other.value * divisor) - - if (a != value.signum() && a != divisor.signum()) { - if (b != other.value.signum() && b != other.divisor.signum()) { - return cmp - } - - return invertCompare(cmp) - } else if (b != other.value.signum() && b != other.divisor.signum()) { - return invertCompare(cmp) - } - - return cmp - } - - private fun plusCompact(other: Fraction): Fraction { - if (isNaN()) return this - - if (divisor == other.divisor) { - if (isOne(divisor)) - return Fraction(value + other.value, divisor) - - val new = value + other.value - - if (new.compareTo(BigInteger.ZERO) == 0) - return ZERO - - if (divisor == BigInteger.ZERO || divisor == BI_MINUS_ZERO) - return Fraction(new, divisor) - - return compactTwo(new, divisor) - } - - val new = value * other.divisor + other.value * divisor - val div = divisor * other.divisor - - if (div == BigInteger.ZERO || div == BI_MINUS_ZERO) - return Fraction(new, div) - - return compactTwo(new, div) - } - - operator fun plus(other: Fraction): Fraction { - if (isNaN()) return this - if (other.isNaN()) return other - - if (compact) - return plusCompact(other) - - if (divisor == other.divisor) { - return Fraction(value + other.value, divisor, compact = false) - } - - return Fraction(value * other.divisor + other.value * divisor, divisor * other.divisor, compact = false) - } - - private fun minusCompact(other: Fraction): Fraction { - if (divisor == other.divisor) { - if (isOne(divisor)) - return Fraction(value - other.value, divisor) - - val new = value - other.value - - if (new.compareTo(BigInteger.ZERO) == 0) - return ZERO - - if (divisor == BigInteger.ZERO || divisor == BI_MINUS_ZERO) - return Fraction(new, divisor) - - return compactTwo(new, divisor) - } - - val new = value * other.divisor - other.value * divisor - val div = divisor * other.divisor - - if (div == BigInteger.ZERO || div == BI_MINUS_ZERO) - return Fraction(new, div) - - return compactTwo(new, div) - } - - operator fun minus(other: Fraction): Fraction { - if (isNaN()) return this - if (other.isNaN()) return other - - if (compact) - return minusCompact(other) - - if (divisor == other.divisor) { - return Fraction(value - other.value, divisor, compact = false) - } - - return Fraction(value * other.divisor - other.value * divisor, divisor * other.divisor, compact = false) - } - - private fun timesCompact(other: Fraction): Fraction { - val new = value * other.value - - if (new.compareTo(BigInteger.ZERO) == 0) - return ZERO - - val div = divisor * other.divisor - - if (div == BigInteger.ZERO || div == BI_MINUS_ZERO) - return Fraction(new, div) - - return compactTwo(new, div) - } - - operator fun times(other: Fraction): Fraction { - if (isNaN()) return this - if (other.isNaN()) return other - if (other.isOne()) return this - - if (compact) - return timesCompact(other) - - return Fraction(value * other.value, divisor * other.divisor, compact = false) - } - - private fun divCompact(other: Fraction): Fraction { - val new = value * other.divisor - - if (new.compareTo(BigInteger.ZERO) == 0) - return ZERO - - val div = divisor * other.value - - if (div == BigInteger.ZERO || div == BI_MINUS_ZERO) - return Fraction(new, div) - - return compactTwo(new, div) - } - - operator fun div(other: Fraction): Fraction { - if (isNaN()) return this - if (other.isNaN()) return other - if (other.isOne()) return this - - if (compact) - return divCompact(other) - - return Fraction(value * other.divisor, divisor * other.value, compact = false) - } - - operator fun unaryMinus(): Fraction { - if (isNaN()) return this - return Fraction(-value, divisor) - } - - operator fun unaryPlus(): Fraction { - return this - } - - operator fun plus(other: Float): Fraction = plus(Fraction(other)) - operator fun minus(other: Float): Fraction = minus(Fraction(other)) - operator fun times(other: Float): Fraction = times(Fraction(other)) - operator fun div(other: Float): Fraction = div(Fraction(other)) - - operator fun plus(other: Double): Fraction = plus(Fraction(other)) - operator fun minus(other: Double): Fraction = minus(Fraction(other)) - operator fun times(other: Double): Fraction = times(Fraction(other)) - operator fun div(other: Double): Fraction = div(Fraction(other)) - - // может вызвать путаницу - /* - operator fun plus(other: BigDecimal): Fraction = plus(Fraction(other)) - operator fun minus(other: BigDecimal): Fraction = minus(Fraction(other)) - operator fun times(other: BigDecimal): Fraction = times(Fraction(other)) - operator fun div(other: BigDecimal): Fraction = div(Fraction(other)) - - operator fun plus(other: BigInteger): Fraction = plus(Fraction(other)) - operator fun minus(other: BigInteger): Fraction = minus(Fraction(other)) - operator fun times(other: BigInteger): Fraction = times(Fraction(other)) - operator fun div(other: BigInteger): Fraction = div(Fraction(other)) - */ - - operator fun plus(other: Int): Fraction = plus(Fraction(other)) - operator fun minus(other: Int): Fraction = minus(Fraction(other)) - operator fun times(other: Int): Fraction = times(Fraction(other)) - operator fun div(other: Int): Fraction = div(Fraction(other)) - - operator fun plus(other: Long): Fraction = plus(Fraction(other)) - operator fun minus(other: Long): Fraction = minus(Fraction(other)) - operator fun times(other: Long): Fraction = times(Fraction(other)) - operator fun div(other: Long): Fraction = div(Fraction(other)) - - /* - fun add(other: Float): Fraction = plus(Fraction(other)) - fun subtract(other: Float): Fraction = minus(Fraction(other)) - fun multiply(other: Float): Fraction = times(Fraction(other)) - fun divide(other: Float): Fraction = div(Fraction(other)) - - fun add(other: Double): Fraction = plus(Fraction(other)) - fun subtract(other: Double): Fraction = minus(Fraction(other)) - fun multiply(other: Double): Fraction = times(Fraction(other)) - fun divide(other: Double): Fraction = div(Fraction(other)) - - fun add(other: Int): Fraction = plus(Fraction(other)) - fun subtract(other: Int): Fraction = minus(Fraction(other)) - fun multiply(other: Int): Fraction = times(Fraction(other)) - fun divide(other: Int): Fraction = div(Fraction(other)) - - fun add(other: Long): Fraction = plus(Fraction(other)) - fun subtract(other: Long): Fraction = minus(Fraction(other)) - fun multiply(other: Long): Fraction = times(Fraction(other)) - fun divide(other: Long): Fraction = div(Fraction(other)) - - fun add(other: Fraction): Fraction = plus(other) - fun subtract(other: Fraction): Fraction = minus(other) - fun multiply(other: Fraction): Fraction = times(other) - fun divide(other: Fraction): Fraction = div(other) - */ - - operator fun rem(other: Fraction): Fraction { - if (isNaN()) return this - if (other.isNaN()) return other - return Fraction((this / other).wholePart()) - } - - // Преобразования - override fun toFloat(): Float { - if (isNaN()) return Float.NaN - return (value / divisor).toFloat() + ((value % divisor).toFloat() / divisor.toFloat()) - } - - override fun toDouble(): Double { - if (isNaN()) return Double.NaN - return (value / divisor).toDouble() + ((value % divisor).toDouble() / divisor.toDouble()) - } - - fun toImpreciseFraction(): Decimal { - if (isNaN()) - return Decimal.NaN - - val div = value.divideAndRemainder(divisor) - val a = divisor.toDouble() - val b = div[1].toDouble() - - if (b == 0.0 || !a.isFinite() || !b.isFinite()) { - return Decimal(div[0]) - } - - val div2 = a / b - - if (div2.isFinite() && !div2.isNaN()) { - return Decimal(div[0], div2) - } - - return Decimal(div[0]) - } - - fun toByteArray(): ByteArray { - if (isNaN()) { - return byteArrayOf(1, 0, 0, 0, 0, 1, 0, 0, 0, 0) - } - - val magValue = magnitude(value) - val magDiv = magnitude(divisor) - - val bytesA = magValue.value.toByteArray() - val bytesB = magDiv.value.toByteArray() - - return byteArrayOf( - (bytesA.size and 0xFF).toByte(), - (bytesA.size ushr 8).toByte(), - - (magValue.mag and 0xFF).toByte(), - (magValue.mag ushr 8).toByte(), - - *bytesA, - - (bytesB.size and 0xFF).toByte(), - (bytesB.size ushr 8).toByte(), - - (magDiv.mag and 0xFF).toByte(), - (magDiv.mag ushr 8).toByte(), - - *bytesB - ) - } - - override fun toInt(): Int { - if (isNaN()) throw ArithmeticException("Fraction is not a number") - return (value / divisor).toInt() - } - - override fun toLong(): Long { - if (isNaN()) throw ArithmeticException("Fraction is not a number") - return (value / divisor).toLong() - } - - override fun toByte(): Byte { - return toInt().toByte() - } - - override fun toChar(): Char { - return toInt().toChar() - } - - override fun toShort(): Short { - return toInt().toShort() - } - - @JvmOverloads - fun toBigDecimal(context: MathContext = DEFAULT_MATH_CONTEXT): BigDecimal { - if (isNaN()) throw ArithmeticException("Fraction is not a number") - return BigDecimal(value).divide(BigDecimal(divisor), context) - } - - // Утилиты - fun wholePart(): BigInteger { - if (isNaN()) throw ArithmeticException("Fraction is not a number") - return value / divisor - } - - fun fractionPart(): Fraction { - if (isNaN()) return this - return Fraction(value % divisor, divisor) - } - - fun modPart(): BigInteger { - if (isNaN()) throw ArithmeticException("Fraction is not a number") - return value % divisor - } - - override fun toString(): String { - if (isNaN()) return "NaN" - - return "$value/$divisor" - } - - fun formattedString(): String { - if (isNaN()) return "NaN" - return "${wholePart()} ${modPart()}/$divisor" - } - - @JvmOverloads - fun decimalString(nums: Int = 2, strict: Boolean = false): String { - if (isNaN()) return "NaN" - - val whole = wholePart() - val fraction = modPart() - - if (fraction == BigInteger.ZERO) { - if (!strict) - return whole.toString() - - return "${whole}.${"0".repeat(nums)}" - } - - var strdec = (fraction.toDouble() / divisor.toDouble()).toString() - - if (strdec.length == 1) { - strdec = "" - - if (strict) { - strdec = "0".repeat(nums) - } - } else { - strdec = strdec.substring(2) - - if (strict && strdec.length < nums) { - strdec += "0".repeat(nums - strdec.length) - } else if (strdec.length > nums) { - strdec = strdec.substring(0, nums) - } - } - - if (strdec == "") { - return whole.toString() - } - - return "${whole}.$strdec" - } - - fun signnum(): Int { - if (isNaN()) return 0 - - val a = value.signum() - val b = divisor.signum() - - if (a == b) { - if (a == 0) - return 0 - - return 1 - } - - return -1 - } - - fun serializeNBT(): ByteArrayTag { - return ByteArrayTag(toByteArray()) - } - - fun isNaN(): Boolean { - return divisor == BigInteger.ZERO - } - - fun write(buff: FriendlyByteBuf) { - buff.writeByteArray(toByteArray()) - } - - fun max(vararg others: Fraction): Fraction { - var max = this - - for (other in others) { - if (max < other) { - max = other - } - } - - return max - } - - fun min(vararg others: Fraction): Fraction { - var min = this - - for (other in others) { - if (min > other) { - min = other - } - } - - return min - } - - fun moreThanZero(): Fraction { - if (signnum() >= 0) - return this - - return ZERO - } - - fun lessOrZero(): Fraction { - if (signnum() <= 0) - return this - - return ZERO - } - - // Позволяет получить процент от деления данного на divisor с точностью до 5 цифр - fun percentage(divisor: Fraction, zeroing: Boolean = true): Float { - if (divisor.isZero() && zeroing) return 0f - if (isNaN() || divisor.isNaN()) return Float.NaN - - val mul = (this * TEN_THOUSAND) / divisor - if (mul.isNaN()) return Float.NaN - - return mul.wholePart().toFloat() / 10_000f - } - - companion object { - private val LOGGER = LogManager.getLogger() - - @JvmField - val ZERO = Fraction(BigInteger.ZERO) - - @JvmField - val NaN = Fraction(BigInteger.ZERO, BigInteger.ZERO) - - @JvmField - val ONE_HUNDRED = Fraction(BigInteger.valueOf(100)) - - @JvmField - val TEN_THOUSAND = Fraction(BigInteger.valueOf(10_000)) - - @JvmField - val HALF = Fraction(BigInteger.ONE, BigInteger.TWO) - - @JvmField - val THIRD = Fraction(BigInteger.ONE, BigInteger.valueOf(3)) - - @JvmField - val ONE = Fraction(BigInteger.ONE) - - @JvmField - val TWO = Fraction(BigInteger.TWO) - - @JvmField - val MINUS_ONE = Fraction(-1) - - @JvmField - val TEN = Fraction(BigInteger.TEN) - - @JvmField - val INT_MAX_VALUE = Fraction(Int.MAX_VALUE) - - @JvmField - val LONG_MAX_VALUE = Fraction(Long.MAX_VALUE) - - @JvmStatic - fun read(buff: FriendlyByteBuf): Fraction { - return fromByteArray(buff.readByteArray()) - } - - @JvmStatic - fun fromByteArray(bytes: ByteArray): Fraction { - try { - val rangeA = unsignedInt(bytes[0]) or (unsignedInt(bytes[1]) shl 8) - val magA = unsignedInt(bytes[2]) or (unsignedInt(bytes[3]) shl 8) - - val bytesA = bytes.copyOfRange(4, 4 + rangeA) - - val offsetB = 4 + rangeA - - val rangeB = unsignedInt(bytes[offsetB]) or (unsignedInt(bytes[offsetB + 1]) shl 8) - val magB = unsignedInt(bytes[offsetB + 2]) or (unsignedInt(bytes[offsetB + 3]) shl 8) - - val bytesB = bytes.copyOfRange(offsetB + 4, offsetB + 4 + rangeB) - - if (bytesB.isEmpty()) - return NaN - - return Fraction(if (bytesA.isNotEmpty()) (BigInteger(bytesA) * BigInteger("1" + "0".repeat(magA))) else BigInteger.ZERO, BigInteger(bytesB) * BigInteger("1" + "0".repeat(magB))) - } catch(err: Throwable) { - LOGGER.error("Unable to load Fraction from byte array", err) - return NaN - } - } - - @JvmStatic - fun deserializeNBT(bytesTag: ByteArrayTag): Fraction { - val bytes = bytesTag.asByteArray - return fromByteArray(bytes) - } - - // Преобразование строки в дробь с подавлением ошибок форматирования - @JvmStatic - fun fromString(str: String): Fraction { - try { - return Fraction(BigDecimal(str)) - } catch(err: Throwable) { - return ZERO - } - } - - @JvmStatic - fun deserializeNBT(tag: Tag?): Fraction { - if (tag == null) - return ZERO - - if (tag is ByteArrayTag) - return deserializeNBT(tag) - - if (tag is StringTag) - return try { - fromString(tag.asString) - } catch (anything: Throwable) { - ZERO - } - - return ZERO - } - } -} - diff --git a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FractionTests.kt b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FractionTests.kt deleted file mode 100644 index e51fa3924..000000000 --- a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FractionTests.kt +++ /dev/null @@ -1,345 +0,0 @@ -package ru.dbotthepony.mc.otm.tests - -import org.junit.jupiter.api.DisplayName -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertThrows -import ru.dbotthepony.mc.otm.core.Fraction -import ru.dbotthepony.mc.otm.core.Decimal -import java.math.BigDecimal -import java.math.BigInteger - -object FractionTests { - @Test - @DisplayName("Fraction declaration") - fun declaration() { - println("BigInteger 1/1 == ${Fraction(BigInteger.valueOf(1), BigInteger.valueOf(1))}") - println("BigDecimal 1 == ${Fraction(BigDecimal("1"))}") - - var one = BigDecimal("1.00") - - println("Unscaled ${one.unscaledValue()} with scale ${one.scale()} of $one") - println("BigDecimal $one == ${Fraction(one)}") - assert(Fraction(one).compareTo(Fraction.ONE) == 0) - - one = BigDecimal("1.0000") - - println("Unscaled ${one.unscaledValue()} with scale ${one.scale()} of $one") - println("BigDecimal $one == ${Fraction(one)}") - assert(Fraction(one).compareTo(Fraction.ONE) == 0) - - println("1/2 == ${Fraction(1, 2)}") - println("-1/2 == ${Fraction(-1, 2)}") - println("1/-2 == ${Fraction(1, -2)}") - println("-1/-2 == ${Fraction(-1, -2)}") - - println("canonical 1/2 == ${Fraction(1, 2).canonize()}") - println("canonical -1/2 == ${Fraction(-1, 2).canonize()}") - println("canonical 1/-2 == ${Fraction(1, -2).canonize()}") - println("canonical -1/-2 == ${Fraction(-1, -2).canonize()}") - } - - @Test - @DisplayName("Fraction NaN behavior") - fun nan() { - assert((Fraction.NaN + Fraction.ONE).isNaN()) - assert((Fraction.NaN - Fraction.ONE).isNaN()) - assert((Fraction.NaN / Fraction.ONE).isNaN()) - assert((Fraction.NaN * Fraction.ONE).isNaN()) - - assert((Fraction.ONE + Fraction.NaN).isNaN()) - assert((Fraction.ONE - Fraction.NaN).isNaN()) - assert((Fraction.ONE / Fraction.NaN).isNaN()) - assert((Fraction.ONE * Fraction.NaN).isNaN()) - - assert((Fraction.ONE / Fraction.ZERO).isNaN()) - assert((Fraction.ONE * Fraction(0, 0)).isNaN()) - assert((Fraction.ONE * Fraction(1, 0)).isNaN()) - - assert(Fraction.NaN.toFloat().isNaN()) - assert(Fraction.NaN.toDouble().isNaN()) - - assertThrows {Fraction.NaN.toInt()} - assertThrows {Fraction.NaN.toLong()} - assertThrows {Fraction.NaN.wholePart()} - - assert(Fraction.fromByteArray(Fraction.NaN.toByteArray()).isNaN()) - assert(Fraction.NaN.percentage(Fraction.ONE).isNaN()) - } - - @Test - @DisplayName("Fraction comparison") - fun equality() { - assert(Fraction(1).compareTo(Fraction.ONE) == 0) - assert(Fraction(1.0).compareTo(Fraction.ONE) == 0) - assert(Fraction(1.0F).compareTo(Fraction.ONE) == 0) - assert(Fraction(1, 1).compareTo(Fraction.ONE) == 0) - assert(Fraction(1.0, 1.0).compareTo(Fraction.ONE) == 0) - assert(Fraction(1.0F, 1.0F).compareTo(Fraction.ONE) == 0) - - assert(Fraction(1, 2).compareTo(Fraction.HALF) == 0) - assert(Fraction(1.0, 2.0).compareTo(Fraction.HALF) == 0) - assert(Fraction(1.0F, 2.0F).compareTo(Fraction.HALF) == 0) - - assert(Fraction(-1, -2).compareTo(Fraction.HALF) == 0) - assert(Fraction(-1.0, -2.0).compareTo(Fraction.HALF) == 0) - assert(Fraction(-1.0F, -2.0F).compareTo(Fraction.HALF) == 0) - - assert(Fraction(-1, 2).compareTo(Fraction.HALF) != 0) - assert(Fraction(-1.0, 2.0).compareTo(Fraction.HALF) != 0) - assert(Fraction(-1.0F, 2.0F).compareTo(Fraction.HALF) != 0) - - assert(Fraction(1, 2).compareTo(Fraction.ONE) != 0) - assert(Fraction(1.0, 2.0).compareTo(Fraction.ONE) != 0) - assert(Fraction(1.0F, 2.0F).compareTo(Fraction.ONE) != 0) - - assert(Fraction(2).compareTo(Fraction.TWO) == 0) - assert(Fraction(2.0).compareTo(Fraction.TWO) == 0) - assert(Fraction(2.0F).compareTo(Fraction.TWO) == 0) - assert(Fraction(2, 1).compareTo(Fraction.TWO) == 0) - assert(Fraction(2.0, 1.0).compareTo(Fraction.TWO) == 0) - assert(Fraction(2.0F, 1.0F).compareTo(Fraction.TWO) == 0) - - assert(Fraction(4, 3) > Fraction(5, 4)) - assert(Fraction(4, 4) < Fraction(5, 4)) - - assert(Fraction(-15, 2) < Fraction(2, 4)) - assert(Fraction(-1, 2) < Fraction(2, 4)) - assert(Fraction(-15, -2) > Fraction(2, 4)) - assert(Fraction(-15, -2) > Fraction(-2, -4)) - assert(Fraction(-15, 2) < Fraction(-2, -4)) - } - - @Test - @DisplayName("Fraction math") - fun math() { - assert((Fraction(1) / Fraction(1)) == Fraction(1)) - assert((Fraction(2) / Fraction(1)) == Fraction(2, 1)) - assert((Fraction(2) / Fraction(2)) == Fraction(1)) { Fraction(2) / Fraction(2) } - - assert((Fraction(4, 3) / Fraction(5, 4)) == (Fraction(4, 3) * Fraction(4, 5))) - assert((Fraction(4, 3) + Fraction(5, 4)) == Fraction(31, 12)) - } - - @Test - @DisplayName("Fraction compacting") - fun compacting() { - val frac = Fraction("2721280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "25600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") - - println("Compacting $frac => ${frac + Fraction.ZERO}") - } - - private val samples = arrayOf( - Fraction(9475, 4729), - Fraction(23535, 58723), - Fraction(-4852, 6859), - Fraction(-45623, -76849), - Fraction(38494, -76849), - Fraction(1043, -648), - ) - - private val samplesIM = arrayOf( - Decimal(9475.0 / 4729), - Decimal(23535.0 / 58723), - Decimal(-4852.0 / 6859), - Decimal(-45623.0 / -76849), - Decimal(38494.0 / -76849), - Decimal(1043.0 / -648), - ) - - private val samples2 = arrayOf( - (9475.0 / 4729), - (23535.0 / 58723), - (-4852.0 / 6859), - (-45623.0 / -76849), - (38494.0 / -76849), - (1043.0 / -648), - ) - - private val samples3 = arrayOf( - BigDecimal((9475.0 / 4729).toString()), - BigDecimal((23535.0 / 58723).toString()), - BigDecimal((-4852.0 / 6859).toString()), - BigDecimal((-45623.0 / -76849).toString()), - BigDecimal((38494.0 / -76849).toString()), - BigDecimal((1043.0 / -648).toString()), - ) - - @Test - @DisplayName("Fraction performance measurement") - fun performance() { - val rand = java.util.Random() - val blackHole = arrayOfNulls(100_000) - val blackHoleIM = arrayOfNulls(100_000) - val size = samples.size - var time = System.currentTimeMillis() - - for (i in 0 until 100_000) { - when (rand.nextInt(3)) { - 0 -> blackHole[i] = samples[rand.nextInt(size)] + samples[rand.nextInt(size)] - 1 -> blackHole[i] = samples[rand.nextInt(size)] - samples[rand.nextInt(size)] - 2 -> blackHole[i] = samples[rand.nextInt(size)] * samples[rand.nextInt(size)] - // 3 -> blackHole[i] = samples[rand.nextInt(size)] / samples[rand.nextInt(size)] - } - } - - println("Mean time for Fraction operation is ~${System.currentTimeMillis() - time} ms per 100,000 ops") - - time = System.currentTimeMillis() - - for (i in 0 until 100_000) { - when (rand.nextInt(3)) { - 0 -> blackHoleIM[i] = samplesIM[rand.nextInt(size)] + samplesIM[rand.nextInt(size)] - 1 -> blackHoleIM[i] = samplesIM[rand.nextInt(size)] - samplesIM[rand.nextInt(size)] - 2 -> blackHoleIM[i] = samplesIM[rand.nextInt(size)] * samplesIM[rand.nextInt(size)] - // 3 -> blackHole[i] = samples[rand.nextInt(size)] / samples[rand.nextInt(size)] - } - } - - println("Mean time for ImpreciseFraction operation is ~${System.currentTimeMillis() - time} ms per 100,000 ops") - - var sum = Fraction.ZERO - - // перемешаем чтоб оптимизатор не отбросил - for (i in 0 until size) { - sum += blackHole[i]!! - blackHole[i] = blackHole[rand.nextInt(size)] - } - - val blackHole2 = DoubleArray(100_000) - time = System.currentTimeMillis() - - for (i in 0 until 100_000) { - when (rand.nextInt(3)) { - 0 -> blackHole2[i] = samples2[rand.nextInt(size)] + samples2[rand.nextInt(size)] - 1 -> blackHole2[i] = samples2[rand.nextInt(size)] - samples2[rand.nextInt(size)] - 2 -> blackHole2[i] = samples2[rand.nextInt(size)] * samples2[rand.nextInt(size)] - // 3 -> blackHole2[i] = samples2[rand.nextInt(size)] / samples2[rand.nextInt(size)] - } - } - - println("Mean time for Double operation is ~${System.currentTimeMillis() - time} ms per 100,000 ops") - - val blackHole3 = arrayOfNulls(100_000) - time = System.currentTimeMillis() - - for (i in 0 until 100_000) { - when (rand.nextInt(3)) { - 0 -> blackHole3[i] = samples3[rand.nextInt(size)] + samples3[rand.nextInt(size)] - 1 -> blackHole3[i] = samples3[rand.nextInt(size)] - samples3[rand.nextInt(size)] - 2 -> blackHole3[i] = samples3[rand.nextInt(size)] * samples3[rand.nextInt(size)] - // 3 -> blackHole2[i] = samples2[rand.nextInt(size)] / samples2[rand.nextInt(size)] - } - } - - println("Mean time for BigDecimal operation is ~${System.currentTimeMillis() - time} ms per 100,000 ops") - - var sum2 = 0.0 - - // перемешаем чтоб оптимизатор не отбросил - for (i in 0 until size) { - sum2 += blackHole2[i] - blackHole2[i] = blackHole2[rand.nextInt(size)] - } - - var sum3 = 0.0 - - // перемешаем чтоб оптимизатор не отбросил - for (i in 0 until size) { - sum3 += blackHole2[i] - blackHole3[i] = blackHole3[rand.nextInt(size)] - } - - var sum4 = 0.0 - - // перемешаем чтоб оптимизатор не отбросил - for (i in 0 until size) { - sum4 += blackHoleIM[i]!!.toDouble() - blackHoleIM[i] = blackHoleIM[rand.nextInt(size)] - } - - println("$sum $sum2 $sum3") - } - - @Test - @DisplayName("Fraction serialization test") - fun serialization() { - var value = Fraction(1) - var serialized = value.serializeNBT() - - assert(value.compareTo(Fraction.deserializeNBT(serialized)) == 0) - - value = Fraction(4, 2) - serialized = value.serializeNBT() - - assert(value.compareTo(Fraction.deserializeNBT(serialized)) == 0) - - value = Fraction(-4, 2) - serialized = value.serializeNBT() - - assert(value.compareTo(Fraction.deserializeNBT(serialized)) == 0) - - value = Fraction(-4, -18) - serialized = value.serializeNBT() - - assert(value.compareTo(Fraction.deserializeNBT(serialized)) == 0) - - value = Fraction("3407203485237459085739045724837543569234750927348902374590872345", "-57777772398450982374590230984532984") - serialized = value.serializeNBT() - - assert(value.compareTo(Fraction.deserializeNBT(serialized)) == 0) - - value = Fraction("320", "100") - serialized = value.serializeNBT() - assert(value.compareTo(Fraction.deserializeNBT(serialized)) == 0) - - value = Fraction("324", "100") - serialized = value.serializeNBT() - assert(value.compareTo(Fraction.deserializeNBT(serialized)) == 0) - - value = Fraction("328", "100") - serialized = value.serializeNBT() - assert(value.compareTo(Fraction.deserializeNBT(serialized)) == 0) - - value = Fraction("332", "100") - serialized = value.serializeNBT() - assert(value.compareTo(Fraction.deserializeNBT(serialized)) == 0) - - value = Fraction("336", "100") - serialized = value.serializeNBT() - assert(value.compareTo(Fraction.deserializeNBT(serialized)) == 0) - } - - @Test - @DisplayName("Fraction inaccurate representation") - fun inaccurate() { - var value = 1.1 - var frac = Fraction(value) - - assert(frac.toDouble() == value) { "$value != $frac as (${frac.toDouble()})" } - - value = 1.45 - frac = Fraction(value) - - assert(frac.toDouble() == value) { "$value != $frac as (${frac.toDouble()})" } - - value = -1.0 - frac = Fraction(value) - - assert(frac.toDouble() == value) { "$value != $frac as (${frac.toDouble()})" } - - value = -254.66 - frac = Fraction(value) - - assert(frac.toDouble() == value) { "$value != $frac as (${frac.toDouble()})" } - - value = 94.949494 - frac = Fraction(value) - - assert(frac.toDouble() == value) { "$value != $frac as (${frac.toDouble()})" } - - value = 1.0 / 3 - frac = Fraction(value) - - assert(frac.toDouble() == value) { "$value != $frac as (${frac.toDouble()})" } - } -} From 0b316fe0fc6a5e0296face1f46fdd3021dd05a70 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 14 Jan 2023 10:12:15 +0700 Subject: [PATCH 0036/1199] toImpreciseFraction -> toDecimal --- .../mc/otm/compat/mekanism/Conversions.kt | 2 +- .../dbotthepony/mc/otm/compat/mekanism/Power.kt | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Conversions.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Conversions.kt index ac3a4166d..b760e0242 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Conversions.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Conversions.kt @@ -20,7 +20,7 @@ fun Decimal.toFloatingLong(): FloatingLong { return FloatingLong.create(whole.toLong(), (decimal * 10_000.0).toInt().toShort()) } -fun FloatingLong.toImpreciseFraction(): Decimal { +fun FloatingLong.toDecimal(): Decimal { // Overflow if (value < 0L) { return Decimal(LONG_OVERFLOW + BigInteger.valueOf(value), decimal / 10_000.0) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt index 233ca45e9..b6335ec86 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt @@ -51,7 +51,7 @@ private class DoubleLazy(onion: () -> Lazy) : Lazy { private val mekanism2MtJ by DoubleLazy lazy@{ try { val conf = MekanismConfig.general - return@lazy LazyCache(conf.forgeConversionRate::get) { Decimal.ONE / it.toImpreciseFraction() } + return@lazy LazyCache(conf.forgeConversionRate::get) { Decimal.ONE / it.toDecimal() } } catch(err: Throwable) { LOGGER.error("Unable to get Forge Energy to Mekanism Joules's conversion rate! Expect issues", err) } @@ -62,7 +62,7 @@ private val mekanism2MtJ by DoubleLazy lazy@{ private val mtj2Mekanism by DoubleLazy lazy@{ try { val conf = MekanismConfig.general - return@lazy LazyCache(conf.forgeConversionRate::get) { it.toImpreciseFraction() } + return@lazy LazyCache(conf.forgeConversionRate::get) { it.toDecimal() } } catch(err: Throwable) { LOGGER.error("Unable to get Mekanism Joules's to Forge Energy conversion rate! Expect issues", err) } @@ -77,7 +77,7 @@ class Mekanism2MatteryEnergyWrapper(private val power: IStrictEnergyHandler, pri false -> Action.EXECUTE } - return power.extractEnergy((howMuch * mtj2Mekanism).toFloatingLong(), action).toImpreciseFraction() * mekanism2MtJ + return power.extractEnergy((howMuch * mtj2Mekanism).toFloatingLong(), action).toDecimal() * mekanism2MtJ } override fun extractEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { @@ -90,7 +90,7 @@ class Mekanism2MatteryEnergyWrapper(private val power: IStrictEnergyHandler, pri false -> Action.EXECUTE } - return howMuch - power.insertEnergy((howMuch * mtj2Mekanism).toFloatingLong(), action).toImpreciseFraction() * mekanism2MtJ + return howMuch - power.insertEnergy((howMuch * mtj2Mekanism).toFloatingLong(), action).toDecimal() * mekanism2MtJ } override fun receiveEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { @@ -105,7 +105,7 @@ class Mekanism2MatteryEnergyWrapper(private val power: IStrictEnergyHandler, pri var sum = Decimal.ZERO for (i in 0 until power.energyContainerCount) { - sum += power.getEnergy(i).toImpreciseFraction() + sum += power.getEnergy(i).toDecimal() } return sum * mekanism2MtJ @@ -122,7 +122,7 @@ class Mekanism2MatteryEnergyWrapper(private val power: IStrictEnergyHandler, pri var sum = Decimal.ZERO for (i in 0 until power.energyContainerCount) { - sum += power.getMaxEnergy(i).toImpreciseFraction() + sum += power.getMaxEnergy(i).toDecimal() } return sum * mekanism2MtJ @@ -176,11 +176,11 @@ class Mattery2MekanismEnergyWrapper(private val power: IMatteryEnergyStorage) : override fun insertEnergy(container: Int, howMuch: FloatingLong, action: Action): FloatingLong { val copy = howMuch.copy() - return copy.minusEqual((power.receiveEnergyOuter(howMuch.toImpreciseFraction() * mekanism2MtJ, action.simulate()) * mtj2Mekanism).toFloatingLong()) + return copy.minusEqual((power.receiveEnergyOuter(howMuch.toDecimal() * mekanism2MtJ, action.simulate()) * mtj2Mekanism).toFloatingLong()) } override fun extractEnergy(container: Int, howMuch: FloatingLong, action: Action): FloatingLong { - return (power.extractEnergyOuter(howMuch.toImpreciseFraction() * mekanism2MtJ, action.simulate()) * mtj2Mekanism).toFloatingLong() + return (power.extractEnergyOuter(howMuch.toDecimal() * mekanism2MtJ, action.simulate()) * mtj2Mekanism).toFloatingLong() } } From fd7619b1440d3b6ab96a88d0f88472b8d300bdb9 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 14 Jan 2023 10:14:51 +0700 Subject: [PATCH 0037/1199] Remove EmptyMutableIterator --- .../mc/otm/core/EmptyMutableIterator.kt | 44 ------------------- 1 file changed, 44 deletions(-) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/EmptyMutableIterator.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/EmptyMutableIterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/EmptyMutableIterator.kt deleted file mode 100644 index b673ac9c3..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/EmptyMutableIterator.kt +++ /dev/null @@ -1,44 +0,0 @@ -package ru.dbotthepony.mc.otm.core - -object EmptyMutableIterator : MutableIterator<@UnsafeVariance Nothing>, MutableListIterator<@UnsafeVariance Nothing> { - override fun hasPrevious(): Boolean { - return false - } - - override fun nextIndex(): Int { - return 0 - } - - override fun previous(): Nothing { - throw NoSuchElementException() - } - - override fun previousIndex(): Int { - return -1 - } - - override fun add(element: Nothing) { - throw UnsupportedOperationException() - } - - override fun hasNext(): Boolean { - return false - } - - override fun next(): Nothing { - throw NoSuchElementException() - } - - override fun remove() { - throw NoSuchElementException() - } - - override fun set(element: Nothing) { - throw UnsupportedOperationException() - } - - @Suppress("unchecked_cast") - fun cast(): MutableListIterator { - return this as MutableListIterator - } -} From 5c5c68742b6ee8d645a110c8b9f0be87592c774a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 14 Jan 2023 10:50:36 +0700 Subject: [PATCH 0038/1199] Add docs to MatteryPlayerCapability --- .../otm/capability/MatteryPlayerCapability.kt | 185 ++++++++++++++++-- .../mc/otm/capability/UUIDIntModifiersMap.kt | 5 + 2 files changed, 172 insertions(+), 18 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 7b6b7a843..a4cba3302 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -79,15 +79,34 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial /** * For fields that need to be synchronized only to owning player + * + * Please mind if you really need to use this in your mod; + * don't forget to specify field names when you add them to synchronizer. + * + * Even if other side does not have your field defined, both sides will negotiate + * and figure out how to deal with this situation as long as you specify field name. */ val synchronizer = FieldSynchronizer() /** * For fields that need to be synchronized to everyone + * + * Please mind if you really need to use this in your mod; + * don't forget to specify field names when you add them to synchronizer. + * + * Even if other side does not have your field defined, both sides will negotiate + * and figure out how to deal with this situation as long as you specify field name. */ val publicSynchronizer = FieldSynchronizer() + /** + * Whenever player has Exopack + */ var hasExoPack by publicSynchronizer.bool(name = "hasExoPack") + + /** + * Whenever to render Exopack on player + */ var displayExoPack by publicSynchronizer.bool(true, name = "displayExoPack") private val exoPackSlotModifierMap: MutableMap by synchronizer.Map( @@ -100,6 +119,11 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial name = "exoPackSlotModifierMap" ) + /** + * Modifier map for Exopack slot counts + * + * If you want to properly extend Exopack suit capacity, add your value into this map + */ val exoPackSlotModifier = UUIDIntModifiersMap(observer = observer@{ if (ply !is ServerPlayer) return@observer @@ -111,6 +135,11 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } }, backingMap = this.exoPackSlotModifierMap) + /** + * Current slot count of Exopack + * + * For properly affecting this value please look at [exoPackSlotModifier] + */ var exoPackSlotCount by publicSynchronizer.int(setter = setter@{ value, access, _ -> require(value >= 0) { "Invalid slot count $value" } @@ -121,6 +150,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } }, name = "exoPackSlotCount") + /** + * Exopack container, which actually store items inside Exopack + */ var exoPackContainer: MatteryContainer = PlayerMatteryContainer(0) private set(value) { _exoPackMenu = null @@ -143,6 +175,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial field = value } + /** + * Whenever Exopack has 3x3 crafting grid upgrade installed + */ var isExoPackCraftingUpgraded by publicSynchronizer.bool(setter = setter@{ value, access, _ -> if (value != access.read()) { access.write(value) @@ -156,6 +191,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial field = value } + /** + * [ExoPackInventoryMenu] which player will see when pressing inventory key + */ val exoPackMenu: ExoPackInventoryMenu get() { if (_exoPackMenu == null) { @@ -166,6 +204,10 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } private var shouldSendIteration = false + + /** + * Android' iteration counter (death counter, updating only when Android) + */ var iteration = 0 private set @@ -186,15 +228,41 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial // getting them unburied will be a very work intense task private val trackingPlayers = Reference2ObjectOpenHashMap() + /** + * This returns if player is an Android or will become one on death/sleep/etc + */ val isEverAndroid: Boolean get() = isAndroid || willBecomeAndroid - var lastJumpTicks = 14 + internal var lastJumpTicks = 14 + /** + * In-game ticks this player exists (server play time, excluding time while "dead"), used by various things across the mod, such as + * "play time chance" loot condition + */ var ticksIExist = 0 private set + /** + * Whenever player should become an Android once transformation conditions are met (e.g. player dies or sleeps in bed) + */ var willBecomeAndroid by publicSynchronizer.bool(name = "willBecomeAndroid") + + /** + * Whenever player is an Android + * + * In OTM itself, Android players are generally treated as something in between alive and undead, such as: + * * They can't be healed using potions, can't receive regeneration buffs + * * But they can be harmed using harm potion + * * Can't be poisoned (with default datapack) + * * CAN be withered (with default datapack) + * * etc + * + * Android-immune (de)buffs are specified in `data/overdrive_that_matters/tags/mob_effect/android_immune_effects.json` + */ var isAndroid by publicSynchronizer.bool(name = "isAndroid") + /** + * [IMatteryEnergyStorage] instance, representing Android' battery charge + */ val androidEnergy = AndroidPowerSource(ply, synchronizer, ServerConfig.ANDROID_MAX_ENERGY, ServerConfig.ANDROID_MAX_ENERGY) fun invalidateNetworkState() { @@ -214,12 +282,29 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } } + /** + * Flags player to turn into Android + * + * This is used by Android Pill item in-game + * + * Does nothing if player is already an Android + */ fun becomeAndroidSoft() { if (isAndroid || willBecomeAndroid) return willBecomeAndroid = true (ply as? ServerPlayer)?.displayClientMessage(TranslatableComponent("otm.pill.message").withStyle(ChatFormatting.GRAY), false) } + /** + * Unconditionally and instantly turns player into Android + * + * This is different than setting [isAndroid] because it setup some variables, + * such as battery charge + * + * Does not kill the player + * + * Does nothing if player is already an Android + */ fun becomeAndroid() { if (isAndroid) return @@ -236,6 +321,11 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } } + /** + * [becomeAndroid] plus instantly kills the player + * + * Does nothing if player is already an Android + */ fun becomeAndroidAndKill() { if (isAndroid) return @@ -243,6 +333,25 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial ply.hurt(MRegistry.DAMAGE_BECOME_ANDROID, ply.maxHealth * 2) } + /** + * Unconditionally and instantly turns player into "human" + * + * This is different than setting [isAndroid] because it setup some variables, + * such as battery charge + * + * Does not kill the player + * + * Drops equipped battery BUT does NOT refund research, nor does remove features; + * Once player becomes Android again, they will retain all features and research. + * + * If you need to also remove research and features, look at [obliviate] + * + * However, this does reset [iteration] and death log + * + * Does nothing if player is not an Android + * + * Unsets [willBecomeAndroid] flag if it is true + */ fun becomeHumane() { if (willBecomeAndroid) willBecomeAndroid = false if (!isAndroid) return @@ -258,8 +367,19 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial if (ply is ServerPlayer) { BecomeHumaneTrigger.trigger(ply) } + + for (feature in featureMap.values) { + feature.removeModifiers() + } } + /** + * [becomeHumane] plus kills the player + * + * Does nothing if player is not an Android + * + * Unsets [willBecomeAndroid] flag if it is true + */ fun becomeHumaneAndKill() { if (willBecomeAndroid) willBecomeAndroid = false if (!isAndroid) return @@ -268,6 +388,11 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial ply.hurt(MRegistry.DAMAGE_BECOME_HUMANE, ply.maxHealth * 2) } + /** + * *Refunds* all research and removes all Android features + * + * Resets [iteration] and death log + */ fun obliviate(refund: Boolean = true) { for (instance in research.values) { if (instance.isResearched) { @@ -289,13 +414,16 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial deathLog.clear() } + /** + * Returns [AndroidResearch] state for specified [AndroidResearchType] + */ fun getResearch(type: AndroidResearchType): AndroidResearch { return research.computeIfAbsent(type) { return@computeIfAbsent AndroidResearch(type, this) } } - fun reloadResearch() { + internal fun reloadResearch() { val old = ArrayList(research.size) old.addAll(research.values) research.clear() @@ -309,6 +437,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } } + /** + * Android features stream, use this to get list of all Android features this player has + */ val features: Stream get() = featureMap.values.stream() private fun addFeature(feature: AndroidFeature): Boolean { @@ -331,6 +462,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial return true } + /** + * Adds or returns specified Android feature to this player + */ @Suppress("unchecked_cast") fun addFeature(feature: AndroidFeatureType): T { val get = featureMap[feature] @@ -340,7 +474,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial featureMap[feature] = factory - if (!ply.level.isClientSide) { + if (!ply.level.isClientSide && isAndroid) { queuedTicks.add(factory::applyModifiers) } @@ -356,14 +490,17 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial return factory } + /** + * Removes specified Android feature from this player + * + * @return whenever feature was found and removed + */ fun removeFeature(feature: AndroidFeatureType<*>): Boolean { val removed = featureMap.remove(feature) if (removed != null) { - if (!ply.level.isClientSide) { - queuedTicks.add { - removed.removeModifiers() - } + if (!ply.level.isClientSide && isAndroid) { + queuedTicks.add(removed::removeModifiers) } if (ply is ServerPlayer) { @@ -374,21 +511,32 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial return removed != null } + /** + * Whenever player has specified [feature] + */ fun hasFeature(feature: AndroidFeatureType<*>): Boolean { return featureMap.containsKey(feature) } + /** + * Whenever player has specified [feature] and its [AndroidFeature.level] is equal to or greater than [level] + */ fun hasFeatureLevel(feature: AndroidFeatureType<*>, level: Int): Boolean { val get = featureMap[feature] ?: return false return get.level >= level } + /** + * Raw get of Android feature of this player + * + * @return null if no such feature is present + */ @Suppress("unchecked_cast") fun getFeature(feature: AndroidFeatureType): T? { return featureMap[feature] as T? } - fun onHurt(event: LivingHurtEvent) { + internal fun onHurt(event: LivingHurtEvent) { if (isAndroid) { for (feature in featureMap.values) { feature.onHurt(event) @@ -400,16 +548,14 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } } - fun computeIfAbsent(feature: AndroidFeatureType): T { + internal fun computeIfAbsent(feature: AndroidFeatureType): T { return getFeature(feature) ?: addFeature(feature) } - fun getFeatureO(feature: AndroidFeatureType): Optional { - val get = getFeature(feature) - return if (get != null) Optional.of(get) else Optional.empty() - } - - fun ifFeature(feature: AndroidFeatureType, consumer: (T) -> Unit) { + /** + * Lambda style of [getFeature] + */ + inline fun ifFeature(feature: AndroidFeatureType, consumer: (T) -> Unit) { val get = getFeature(feature) if (get != null) { @@ -543,6 +689,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } } + /** + * Drops Android battery as in-world item + */ fun dropBattery() { if (androidEnergy.item.isEmpty) return ply.spawnAtLocation(androidEnergy.item) @@ -569,7 +718,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } } - fun tickClient() { + private fun tickClient() { queuedTicks.clear() if (!ply.isAlive) { @@ -585,7 +734,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial tickInventory() } - fun preTick() { + private fun preTick() { if (!ply.isAlive) return if (isAndroid) { @@ -596,7 +745,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } } - fun tick() { + private fun tick() { if (!ply.isAlive) return ticksIExist++ diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/UUIDIntModifiersMap.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/UUIDIntModifiersMap.kt index 8ddafb76a..772bd47f5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/UUIDIntModifiersMap.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/UUIDIntModifiersMap.kt @@ -7,6 +7,11 @@ import net.minecraftforge.common.util.INBTSerializable import ru.dbotthepony.mc.otm.core.contains import java.util.UUID +/** + * This class represents an `UUID -> Int` map, with each `Int` value being added to [value] property + * + * This is like Minecraft's Attribute map, except it operate only on whole numbers + */ class UUIDIntModifiersMap(private val observer: (Int) -> Unit, private val backingMap: MutableMap = HashMap()) : INBTSerializable { var value: Int = 0 private set From 16ea8295148f1371881e7e97f1586e4774d0a540 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 14 Jan 2023 10:54:57 +0700 Subject: [PATCH 0039/1199] Better package structure in capabilities --- .../mc/otm/capability/MatteryCapability.java | 1 + .../ru/dbotthepony/mc/otm/ServerConfig.kt | 2 +- .../android/feature/EnderTeleporterFeature.kt | 2 +- .../otm/android/feature/ItemMagnetFeature.kt | 8 +- .../otm/android/feature/JumpBoostFeature.kt | 4 +- .../android/feature/NanobotsArmorFeature.kt | 2 +- .../otm/android/feature/NightVisionFeature.kt | 2 +- .../otm/android/feature/ShockwaveFeature.kt | 2 +- .../mc/otm/block/AndroidStationBlock.kt | 5 +- .../mc/otm/block/ChemicalGeneratorBlock.kt | 4 +- .../mc/otm/block/PlatePressBlock.kt | 1 - .../block/entity/AndroidStationBlockEntity.kt | 2 +- .../block/entity/BatteryBankBlockEntity.kt | 1 + .../entity/ChemicalGeneratorBlockEntity.kt | 1 + .../block/entity/EnergyCounterBlockEntity.kt | 1 + .../block/entity/EnergyServoBlockEntity.kt | 2 +- .../block/entity/MatteryPoweredBlockEntity.kt | 3 + .../block/entity/MatteryWorkerBlockEntity.kt | 2 +- .../otm/block/entity/PlatePressBlockEntity.kt | 2 +- .../entity/matter/MatterBottlerBlockEntity.kt | 4 +- .../matter/MatterDecomposerBlockEntity.kt | 4 +- .../matter/MatterRecyclerBlockEntity.kt | 4 +- .../matter/MatterReplicatorBlockEntity.kt | 4 +- .../entity/matter/MatterScannerBlockEntity.kt | 4 +- .../entity/storage/DriveRackBlockEntity.kt | 2 +- .../entity/storage/DriveViewerBlockEntity.kt | 8 +- .../entity/storage/ItemMonitorBlockEntity.kt | 6 +- .../entity/storage/StorageBusBlockEntity.kt | 3 +- .../block/entity/storage/StorageInterfaces.kt | 3 + .../StoragePowerSupplierBlockEntity.kt | 4 +- .../mc/otm/block/storage/DriveRackBlock.kt | 2 +- .../mc/otm/block/storage/DriveViewerBlock.kt | 2 +- .../mc/otm/block/storage/ItemMonitorBlock.kt | 2 +- .../mc/otm/block/storage/StorageBusBlock.kt | 2 +- .../mc/otm/block/storage/StorageInterfaces.kt | 2 +- .../storage/StoragePowerSupplierBlock.kt | 2 +- .../ru/dbotthepony/mc/otm/capability/Ext.kt | 1 + .../{ => android}/AndroidPowerSource.kt | 5 +- .../{ => android}/MatteryPlayerCapability.kt | 5 +- .../BlockEnergyStorageImpl.kt} | 235 +----------------- .../capability/energy/IEnergyStorageImpl.kt | 102 ++++++++ .../{ => energy}/IMatteryEnergyStorage.kt | 2 +- .../energy/ItemEnergyStorageImpl.kt | 175 +++++++++++++ .../mc/otm/compat/mekanism/Power.kt | 5 +- .../graph/storage/BasicStorageGraphNode.kt | 4 +- .../otm/graph/storage/StorageNetworkGraph.kt | 4 +- .../ru/dbotthepony/mc/otm/item/BatteryItem.kt | 6 +- .../mc/otm/item/EnergySwordItem.kt | 13 +- .../mc/otm/item/QuantumBatteryItem.kt | 5 +- .../mc/otm/item/SingleUseBatteryItem.kt | 4 + .../mc/otm/item/weapon/PlasmaRifleItem.kt | 2 +- .../mc/otm/item/weapon/PlasmaWeaponItem.kt | 3 + .../mc/otm/menu/widget/LevelGaugeWidget.kt | 2 +- .../mc/otm/recipe/EnergyContainerRecipe.kt | 5 - .../mc/otm/storage/VirtualComponent.kt | 3 +- 55 files changed, 366 insertions(+), 320 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/capability/{ => android}/AndroidPowerSource.kt (95%) rename src/main/kotlin/ru/dbotthepony/mc/otm/capability/{ => android}/MatteryPlayerCapability.kt (99%) rename src/main/kotlin/ru/dbotthepony/mc/otm/capability/{EnergyStorageImpl.kt => energy/BlockEnergyStorageImpl.kt} (60%) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt rename src/main/kotlin/ru/dbotthepony/mc/otm/capability/{ => energy}/IMatteryEnergyStorage.kt (99%) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt diff --git a/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java b/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java index fbea8708e..dc0966b1f 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java +++ b/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java @@ -4,6 +4,7 @@ import mekanism.api.energy.IStrictEnergyHandler; import net.minecraftforge.common.capabilities.*; import org.jetbrains.annotations.NotNull; import ru.dbotthepony.mc.otm.capability.drive.IMatteryDrive; +import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage; import ru.dbotthepony.mc.otm.capability.matter.IMatterHandler; import ru.dbotthepony.mc.otm.capability.matter.IReplicationTaskProvider; import ru.dbotthepony.mc.otm.capability.matter.IPatternStorage; diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/ServerConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/ServerConfig.kt index 3bac5a3ce..38d82e1ab 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/ServerConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/ServerConfig.kt @@ -10,7 +10,7 @@ import ru.dbotthepony.mc.otm.block.entity.matter.MatterDecomposerBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterRecyclerBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterScannerBlockEntity -import ru.dbotthepony.mc.otm.capability.BlockEnergyStorageImpl +import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.core.Decimal import ru.dbotthepony.mc.otm.core.defineDecimal import ru.dbotthepony.mc.otm.item.EnergySwordItem diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt index 453e38637..ddfc81482 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt @@ -30,7 +30,7 @@ import ru.dbotthepony.mc.otm.ServerConfig import ru.dbotthepony.mc.otm.android.AndroidActiveFeature import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability -import ru.dbotthepony.mc.otm.capability.extractEnergyInnerExact +import ru.dbotthepony.mc.otm.capability.energy.extractEnergyInnerExact import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.render.ResearchIcons diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt index 55f579594..8607776d1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt @@ -5,25 +5,19 @@ import net.minecraft.ChatFormatting import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation -import net.minecraft.server.level.ServerLevel -import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.Entity import net.minecraft.world.entity.item.ItemEntity -import net.minecraftforge.event.ForgeEventFactory import net.minecraftforge.network.NetworkEvent import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.ServerConfig import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability -import ru.dbotthepony.mc.otm.capability.extractEnergyInner -import ru.dbotthepony.mc.otm.capability.extractEnergyInnerExact +import ru.dbotthepony.mc.otm.capability.energy.extractEnergyInnerExact import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.ResearchIcons -import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.Vector import ru.dbotthepony.mc.otm.core.formatPower -import ru.dbotthepony.mc.otm.core.formatSi import ru.dbotthepony.mc.otm.core.getEntitiesInEllipsoid import ru.dbotthepony.mc.otm.core.minus import ru.dbotthepony.mc.otm.core.plus diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt index 6490a1816..767e72d5f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt @@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.android.feature import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.ChatFormatting -import net.minecraft.nbt.CompoundTag import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer @@ -15,13 +14,12 @@ import ru.dbotthepony.mc.otm.ServerConfig import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability -import ru.dbotthepony.mc.otm.capability.extractEnergyInnerExact +import ru.dbotthepony.mc.otm.capability.energy.extractEnergyInnerExact import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.core.Vector import ru.dbotthepony.mc.otm.core.formatPower import ru.dbotthepony.mc.otm.core.plus -import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel import ru.dbotthepony.mc.otm.network.enqueueWork diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt index f1f9723d9..f6449b8b2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt @@ -8,7 +8,7 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.android.AndroidFeature import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability -import ru.dbotthepony.mc.otm.capability.extractEnergyInnerExact +import ru.dbotthepony.mc.otm.capability.energy.extractEnergyInnerExact import ru.dbotthepony.mc.otm.core.Decimal import ru.dbotthepony.mc.otm.registry.AndroidFeatures import ru.dbotthepony.mc.otm.registry.StatNames diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt index 4eeed3849..e41db1702 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt @@ -6,7 +6,7 @@ import net.minecraft.world.effect.MobEffects import ru.dbotthepony.mc.otm.ServerConfig import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability -import ru.dbotthepony.mc.otm.capability.extractEnergyInnerExact +import ru.dbotthepony.mc.otm.capability.energy.extractEnergyInnerExact import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.registry.AndroidFeatures diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt index 1a6d43de2..4b83bc39f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt @@ -17,7 +17,7 @@ import ru.dbotthepony.mc.otm.ServerConfig import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability -import ru.dbotthepony.mc.otm.capability.extractEnergyInnerExact +import ru.dbotthepony.mc.otm.capability.energy.extractEnergyInnerExact import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.core.Vector import ru.dbotthepony.mc.otm.core.formatPower diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/AndroidStationBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/AndroidStationBlock.kt index 2767cd147..d128ac6e1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/AndroidStationBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/AndroidStationBlock.kt @@ -21,10 +21,9 @@ import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.entity.AndroidStationBlockEntity import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity -import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.capability.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -89,4 +88,4 @@ class AndroidStationBlock : MatteryBlock(), EntityBlock { companion object { private val SHAPE = BlockShapes.ANDROID_STATION.computeShape() } -} \ No newline at end of file +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/ChemicalGeneratorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/ChemicalGeneratorBlock.kt index 294569aca..8adae472c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/ChemicalGeneratorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/ChemicalGeneratorBlock.kt @@ -22,8 +22,8 @@ import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.entity.ChemicalGeneratorBlockEntity import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState -import ru.dbotthepony.mc.otm.capability.GeneratorEnergyStorage -import ru.dbotthepony.mc.otm.capability.ItemEnergyStorageImpl +import ru.dbotthepony.mc.otm.capability.energy.GeneratorEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.ItemEnergyStorageImpl import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.map diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/PlatePressBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/PlatePressBlock.kt index 910a7581a..1e54ad9b9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/PlatePressBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/PlatePressBlock.kt @@ -19,7 +19,6 @@ import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.block.entity.PlatePressBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState -import ru.dbotthepony.mc.otm.capability.WorkerEnergyStorage import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/AndroidStationBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/AndroidStationBlockEntity.kt index ec79fb785..49db8e737 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/AndroidStationBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/AndroidStationBlockEntity.kt @@ -12,7 +12,7 @@ import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.phys.AABB import net.minecraftforge.common.ForgeConfigSpec import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.capability.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.core.Decimal import ru.dbotthepony.mc.otm.core.DecimalConfigValue import ru.dbotthepony.mc.otm.core.defineDecimal diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BatteryBankBlockEntity.kt index dab1c48a2..0a7aebe52 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BatteryBankBlockEntity.kt @@ -23,6 +23,7 @@ import ru.dbotthepony.mc.otm.block.BatteryBankBlock import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.capability.* +import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainerHooks diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ChemicalGeneratorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ChemicalGeneratorBlockEntity.kt index 612303fda..3a492a89c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ChemicalGeneratorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ChemicalGeneratorBlockEntity.kt @@ -22,6 +22,7 @@ import ru.dbotthepony.mc.otm.* import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.capability.* +import ru.dbotthepony.mc.otm.capability.energy.GeneratorEnergyStorage import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainerHooks import ru.dbotthepony.mc.otm.core.* diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt index 613ee4eb9..17d29a0dd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt @@ -19,6 +19,7 @@ import net.minecraftforge.energy.IEnergyStorage import ru.dbotthepony.mc.otm.* import ru.dbotthepony.mc.otm.block.EnergyCounterBlock import ru.dbotthepony.mc.otm.capability.* +import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.menu.EnergyCounterMenu diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyServoBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyServoBlockEntity.kt index cdcff1a5b..b0f07a5e1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyServoBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyServoBlockEntity.kt @@ -14,7 +14,7 @@ import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.block.IDroppableContainer -import ru.dbotthepony.mc.otm.capability.IMatteryEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.canSetBatteryMattery import ru.dbotthepony.mc.otm.capability.energy diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt index 4200a73ad..51745fd3e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt @@ -15,6 +15,9 @@ import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.capability.* +import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl +import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.ItemEnergyStorageImpl import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.core.Decimal import ru.dbotthepony.mc.otm.core.ifHas diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt index f37d6dc87..e9486f406 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt @@ -10,7 +10,7 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.block.Block -import ru.dbotthepony.mc.otm.capability.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.map diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/PlatePressBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/PlatePressBlockEntity.kt index d64a5e533..f7d36a62c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/PlatePressBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/PlatePressBlockEntity.kt @@ -16,7 +16,7 @@ import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.ServerConfig import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.capability.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainerHooks import ru.dbotthepony.mc.otm.core.Decimal diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index dbe384158..b4e8b6f1b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -22,9 +22,9 @@ import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState -import ru.dbotthepony.mc.otm.capability.BlockEnergyStorageImpl +import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.capability.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.IMatterHandler import ru.dbotthepony.mc.otm.capability.matter.MatterDirection import ru.dbotthepony.mc.otm.capability.matter.MatterHandlerImpl diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index e691f44ad..1cb743713 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -20,9 +20,9 @@ import net.minecraftforge.items.IItemHandler import ru.dbotthepony.mc.otm.ConciseBalanceValues import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity -import ru.dbotthepony.mc.otm.capability.BlockEnergyStorageImpl +import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.capability.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.IMatterHandler import ru.dbotthepony.mc.otm.capability.matter.MatterDirection import ru.dbotthepony.mc.otm.capability.matter.MatterHandlerImpl diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index dab3fded8..242635b4a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -20,9 +20,9 @@ import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.ConciseBalanceValues import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity -import ru.dbotthepony.mc.otm.capability.BlockEnergyStorageImpl +import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.capability.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.IMatterHandler import ru.dbotthepony.mc.otm.capability.matter.MatterDirection import ru.dbotthepony.mc.otm.capability.matter.MatterHandlerImpl diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index ca1961477..a74cc615a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -19,9 +19,9 @@ import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.ConciseBalanceValues import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity -import ru.dbotthepony.mc.otm.capability.BlockEnergyStorageImpl +import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.capability.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.* import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainerHandler diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt index b9bb50646..8f7ee8d45 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt @@ -19,9 +19,9 @@ import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.ConciseBalanceValues import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity -import ru.dbotthepony.mc.otm.capability.BlockEnergyStorageImpl +import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.capability.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.IPatternState import ru.dbotthepony.mc.otm.capability.matter.PatternState import ru.dbotthepony.mc.otm.container.MatteryContainer diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt index 4ab254faa..9751a6e5b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt @@ -17,7 +17,7 @@ import ru.dbotthepony.mc.otm.ServerConfig import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.capability.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.menu.DriveRackMenu import ru.dbotthepony.mc.otm.core.map diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt index 3f17d6fd1..0fd68dfbd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.block.entity.storage -import net.minecraft.MethodsReturnNonnullByDefault import net.minecraft.core.BlockPos import net.minecraft.nbt.CompoundTag import net.minecraft.network.chat.Component @@ -14,20 +13,17 @@ import net.minecraft.world.level.block.state.BlockState import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.ServerConfig import ru.dbotthepony.mc.otm.block.IDroppableContainer -import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.storage.DriveViewerBlock import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.capability.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.menu.DriveViewerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities -import ru.dbotthepony.mc.otm.container.set import ru.dbotthepony.mc.otm.core.map import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.registry.MBlocks -import javax.annotation.ParametersAreNonnullByDefault class DriveViewerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.DRIVE_VIEWER, p_155229_, p_155230_), IDroppableContainer { override fun setChanged() { @@ -94,4 +90,4 @@ class DriveViewerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte fun tick() { batteryChargeLoop() } -} \ No newline at end of file +} 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 62bd31287..571dbc5d0 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 @@ -5,7 +5,6 @@ import net.minecraft.core.BlockPos import net.minecraft.core.Direction import net.minecraft.core.NonNullList import net.minecraft.nbt.CompoundTag -import net.minecraft.nbt.StringTag import net.minecraft.network.FriendlyByteBuf import net.minecraft.network.chat.Component import net.minecraft.server.level.ServerLevel @@ -30,13 +29,12 @@ import ru.dbotthepony.mc.otm.ServerConfig import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.capability.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.get import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode import ru.dbotthepony.mc.otm.graph.storage.StorageNetworkGraph -import ru.dbotthepony.mc.otm.core.ifHas import ru.dbotthepony.mc.otm.menu.ItemMonitorMenu import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -523,4 +521,4 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : super.setRemoved() cell.destroy(level) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt index 711a617e4..c6825d7f7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt @@ -24,7 +24,7 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.AbstractStorageImportExport.Companion.FILTER_KEY import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.capability.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.graph.Graph6Node @@ -34,7 +34,6 @@ import ru.dbotthepony.mc.otm.graph.storage.StorageNetworkGraph import ru.dbotthepony.mc.otm.menu.StorageBusMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlocks -import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.storage.* import java.lang.ref.WeakReference import java.math.BigInteger diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt index 478eba4d8..7165519e9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt @@ -22,6 +22,9 @@ import ru.dbotthepony.mc.otm.block.CableBlock import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.capability.* +import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.extractStepInner +import ru.dbotthepony.mc.otm.capability.energy.extractStepInnerBi import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.graph.Graph6Node diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt index dbd3a52fe..4c5c08dd7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt @@ -17,8 +17,8 @@ import ru.dbotthepony.mc.otm.ServerConfig import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.capability.WorkerEnergyStorage -import ru.dbotthepony.mc.otm.capability.transferInner +import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.transferInner import ru.dbotthepony.mc.otm.core.Decimal import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode import ru.dbotthepony.mc.otm.graph.storage.StorageNetworkGraph diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt index 4ac908099..df085a37d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt @@ -17,7 +17,7 @@ import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.DriveRackBlockEntity -import ru.dbotthepony.mc.otm.capability.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt index 6d63d5528..1de05d726 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt @@ -22,7 +22,7 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.DriveViewerBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState -import ru.dbotthepony.mc.otm.capability.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt index 1fa5a506e..f53497785 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt @@ -17,7 +17,7 @@ import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorBlockEntity -import ru.dbotthepony.mc.otm.capability.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt index aa102c300..89726cb77 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt @@ -23,7 +23,7 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.StorageCableBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.StorageBusBlockEntity -import ru.dbotthepony.mc.otm.capability.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes import ru.dbotthepony.mc.otm.core.unaryMinus diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt index b4c9de21b..bda55fd7f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt @@ -24,7 +24,7 @@ import ru.dbotthepony.mc.otm.block.StorageCableBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.StorageExporterBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.StorageImporterBlockEntity -import ru.dbotthepony.mc.otm.capability.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes import ru.dbotthepony.mc.otm.core.unaryMinus diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt index 55e48e086..5d8a23712 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt @@ -17,7 +17,7 @@ import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.StoragePowerSupplierBlockEntity -import ru.dbotthepony.mc.otm.capability.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt index a3e23da12..6a9ab1ff5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt @@ -9,6 +9,7 @@ import net.minecraftforge.common.capabilities.ICapabilityProvider import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.energy.IEnergyStorage import net.minecraftforge.fml.ModList +import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.compat.cos.cosmeticArmorAwareStream import ru.dbotthepony.mc.otm.compat.cos.cosmeticArmorStream import ru.dbotthepony.mc.otm.compat.cos.isCosmeticArmorLoaded diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/AndroidPowerSource.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/android/AndroidPowerSource.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/mc/otm/capability/AndroidPowerSource.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/capability/android/AndroidPowerSource.kt index c850a32e6..6f7746dca 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/AndroidPowerSource.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/android/AndroidPowerSource.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.capability +package ru.dbotthepony.mc.otm.capability.android import net.minecraft.nbt.CompoundTag import net.minecraft.server.level.ServerPlayer @@ -6,6 +6,9 @@ import net.minecraft.world.entity.player.Player import net.minecraft.world.item.ItemStack import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.INBTSerializable +import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage +import ru.dbotthepony.mc.otm.capability.extractEnergy +import ru.dbotthepony.mc.otm.capability.receiveEnergy import ru.dbotthepony.mc.otm.core.Decimal import ru.dbotthepony.mc.otm.core.getDecimal import ru.dbotthepony.mc.otm.core.getItemStack diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/android/MatteryPlayerCapability.kt similarity index 99% rename from src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/capability/android/MatteryPlayerCapability.kt index a4cba3302..950be069f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/android/MatteryPlayerCapability.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.capability +package ru.dbotthepony.mc.otm.capability.android import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import net.minecraft.ChatFormatting @@ -44,6 +44,9 @@ import ru.dbotthepony.mc.otm.android.AndroidResearch import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidResearchType import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature +import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.UUIDIntModifiersMap +import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.stream diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/EnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt similarity index 60% rename from src/main/kotlin/ru/dbotthepony/mc/otm/capability/EnergyStorageImpl.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt index 3bf4d780d..0982a076b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/EnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt @@ -1,258 +1,27 @@ @file:Suppress("unused") -package ru.dbotthepony.mc.otm.capability +package ru.dbotthepony.mc.otm.capability.energy -import net.minecraft.ChatFormatting -import net.minecraft.core.Direction import net.minecraft.nbt.CompoundTag import net.minecraft.network.chat.Component import net.minecraft.world.item.BlockItem import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.BlockGetter -import net.minecraft.world.level.Level import net.minecraft.world.level.block.entity.BlockEntity import net.minecraftforge.common.ForgeConfigSpec -import net.minecraftforge.common.capabilities.Capability -import net.minecraftforge.common.capabilities.ForgeCapabilities -import net.minecraftforge.common.capabilities.ICapabilityProvider import net.minecraftforge.common.util.INBTSerializable import net.minecraftforge.common.util.LazyOptional -import net.minecraftforge.energy.IEnergyStorage import ru.dbotthepony.mc.otm.ConciseBalanceValues import ru.dbotthepony.mc.otm.VerboseBalanceValues import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity -import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper +import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.core.Decimal -import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.defineDecimal -import ru.dbotthepony.mc.otm.core.formatPower import ru.dbotthepony.mc.otm.core.map import ru.dbotthepony.mc.otm.core.mapIf import ru.dbotthepony.mc.otm.core.set -import ru.dbotthepony.mc.otm.core.tagNotNull - -sealed interface IEnergyStorageImpl { - val maxInput: Decimal? - val maxOutput: Decimal? - val direction: FlowDirection -} - -private fun batteryLevel(it: IEnergyStorage, tooltips: MutableList) { - tooltips.add(TranslatableComponent( - "otm.item.power.storage", - it.energyStored.formatPower(), - it.maxEnergyStored.formatPower() - ).withStyle(ChatFormatting.GRAY)) -} - -private fun batteryLevel(it: IMatteryEnergyStorage, tooltips: MutableList) { - tooltips.add(TranslatableComponent( - "otm.item.power.storage", - it.batteryLevel.formatPower(), - it.maxBatteryLevel.formatPower() - ).withStyle(ChatFormatting.GRAY)) - - if (it is IEnergyStorageImpl) { - when (it.direction) { - FlowDirection.INPUT -> { - if (it.maxInput != null) { - tooltips.add(TranslatableComponent("otm.item.power.throughput_mono", it.maxInput!!.formatPower()).withStyle(ChatFormatting.GRAY)) - } else { - tooltips.add(TranslatableComponent("otm.item.power.throughput_mono", TranslatableComponent("otm.item.power.infinity").withStyle(ChatFormatting.GRAY)).withStyle(ChatFormatting.GRAY)) - } - } - - FlowDirection.OUTPUT -> { - if (it.maxOutput != null) { - tooltips.add(TranslatableComponent("otm.item.power.throughput_mono", it.maxOutput!!.formatPower()).withStyle(ChatFormatting.GRAY)) - } else { - tooltips.add(TranslatableComponent("otm.item.power.throughput_mono", TranslatableComponent("otm.item.power.infinity").withStyle(ChatFormatting.GRAY)).withStyle(ChatFormatting.GRAY)) - } - } - - FlowDirection.BI_DIRECTIONAL -> { - val maxInput = it.maxInput - val maxOutput = it.maxOutput - - if (maxInput != null && maxOutput != null) { - tooltips.add(TranslatableComponent("otm.item.power.throughput", maxInput.formatPower(), maxOutput.formatPower()).withStyle(ChatFormatting.GRAY)) - } else if (maxInput != null) { - tooltips.add(TranslatableComponent("otm.item.power.throughput", - maxInput.formatPower(), - TranslatableComponent("otm.item.power.infinity").withStyle(ChatFormatting.GRAY) - ).withStyle(ChatFormatting.GRAY)) - } else if (maxOutput != null) { - tooltips.add(TranslatableComponent("otm.item.power.throughput", - TranslatableComponent("otm.item.power.infinity").withStyle(ChatFormatting.GRAY), - maxOutput.formatPower(), - ).withStyle(ChatFormatting.GRAY)) - } else { - tooltips.add(TranslatableComponent("otm.item.power.throughput", - TranslatableComponent("otm.item.power.infinity").withStyle(ChatFormatting.GRAY), - TranslatableComponent("otm.item.power.infinity").withStyle(ChatFormatting.GRAY), - ).withStyle(ChatFormatting.GRAY)) - } - } - } - } -} - -sealed class ItemEnergyStorageImpl( - final override val direction: FlowDirection, - protected val itemStack: ItemStack, - maxBatteryLevel: Decimal, - maxInput: Decimal?, - maxOutput: Decimal?, - val initialBatteryLevel: Decimal = Decimal.ZERO -) : IMatteryEnergyStorage, ICapabilityProvider, IEnergyStorageImpl { - final override var maxInput: Decimal? = maxInput - protected set - - final override var maxOutput: Decimal? = maxOutput - protected set - - private val resolver = LazyOptional.of { this } - private val resolverMekanism = if (isMekanismLoaded) LazyOptional.of { Mattery2MekanismEnergyWrapper(this) } else null - - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - if (cap == ForgeCapabilities.ENERGY || cap == MatteryCapability.ENERGY) { - return resolver.cast() - } else if (cap == MatteryCapability.MEKANISM_ENERGY) { - return resolverMekanism?.cast() ?: LazyOptional.empty() - } - - return LazyOptional.empty() - } - - override var maxBatteryLevel: Decimal = maxBatteryLevel - protected set - - override var batteryLevel: Decimal - get() = itemStack.tag?.map(ENERGY_KEY, Decimal::deserializeNBT) ?: initialBatteryLevel - set(value) { - itemStack.tagNotNull[ENERGY_KEY] = value.serializeNBT() - } - - override fun extractEnergyOuter(howMuch: Decimal, simulate: Boolean): Decimal { - if (direction == FlowDirection.INPUT) - return Decimal.ZERO - - return extractEnergyInner(howMuch, simulate) - } - - override fun receiveEnergyOuter(howMuch: Decimal, simulate: Boolean): Decimal { - if (direction == FlowDirection.OUTPUT) - return Decimal.ZERO - - return receiveEnergyInner(howMuch, simulate) - } - - override fun extractEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { - if (!howMuch.isPositive || itemStack.count != 1) - return Decimal.ZERO - - @Suppress("NAME_SHADOWING") - var howMuch = howMuch - val maxOutput = maxOutput - - if (maxOutput != null) { - howMuch = howMuch.coerceAtMost(maxOutput) - } - - val batteryLevel = batteryLevel - - if (!batteryLevel.isPositive) - return Decimal.ZERO - - val newLevel = (batteryLevel - howMuch).moreThanZero() - val diff = (batteryLevel - newLevel) - - if (!simulate && batteryLevel != newLevel) { - this.batteryLevel = newLevel - } - - return diff - } - - override fun receiveEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { - if (!howMuch.isPositive || itemStack.count != 1) - return Decimal.ZERO - - @Suppress("NAME_SHADOWING") - var howMuch = howMuch - val maxInput = maxInput - - if (maxInput != null) { - howMuch = howMuch.coerceAtMost(maxInput) - } - - val batteryLevel = batteryLevel - - if (batteryLevel >= maxBatteryLevel) - return Decimal.ZERO - - val newLevel = (batteryLevel + howMuch).coerceAtMost(maxBatteryLevel) - val diff = (newLevel - batteryLevel) - - if (!simulate && batteryLevel != newLevel) { - this.batteryLevel = newLevel - } - - return diff - } - - override fun canExtract(): Boolean { - return direction != FlowDirection.INPUT - } - - override fun canReceive(): Boolean { - return direction != FlowDirection.OUTPUT - } - - companion object { - const val ENERGY_KEY = "energy" - - fun appendHoverText(itemStack: ItemStack, level: Level?, tooltips: MutableList, flag: TooltipFlag) { - appendHoverText(itemStack, tooltips) - } - - fun appendHoverText(itemStack: ItemStack, tooltips: MutableList) { - val energy = itemStack.energy ?: return - - if (energy is IMatteryEnergyStorage) { - batteryLevel(energy, tooltips) - } else { - batteryLevel(energy, tooltips) - } - } - } -} - -open class EnergyConsumerItem( - stack: ItemStack, - maxBatteryLevel: Decimal, - maxInput: Decimal? = null, - maxOutput: Decimal? = maxInput, - initialBatteryLevel: Decimal = Decimal.ZERO -) : ItemEnergyStorageImpl(FlowDirection.INPUT, stack, maxBatteryLevel, maxInput, maxOutput, initialBatteryLevel) - -open class EnergyProducerItem( - stack: ItemStack, - maxBatteryLevel: Decimal, - maxInput: Decimal? = null, - maxOutput: Decimal? = maxInput, - initialBatteryLevel: Decimal = Decimal.ZERO -) : ItemEnergyStorageImpl(FlowDirection.OUTPUT, stack, maxBatteryLevel, maxInput, maxOutput, initialBatteryLevel) - -open class EnergyCapacitorItem( - stack: ItemStack, - maxBatteryLevel: Decimal, - maxInput: Decimal? = null, - maxOutput: Decimal? = maxInput, - initialBatteryLevel: Decimal = Decimal.ZERO -) : ItemEnergyStorageImpl(FlowDirection.BI_DIRECTIONAL, stack, maxBatteryLevel, maxInput, maxOutput, initialBatteryLevel) sealed class BlockEnergyStorageImpl( protected val listener: () -> Unit, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt new file mode 100644 index 000000000..677a3f66f --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt @@ -0,0 +1,102 @@ +package ru.dbotthepony.mc.otm.capability.energy + +import net.minecraft.ChatFormatting +import net.minecraft.network.chat.Component +import net.minecraftforge.energy.IEnergyStorage +import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.formatPower + +sealed interface IEnergyStorageImpl { + val maxInput: Decimal? + val maxOutput: Decimal? + val direction: FlowDirection +} + +internal fun batteryLevel(it: IEnergyStorage, tooltips: MutableList) { + tooltips.add( + TranslatableComponent( + "otm.item.power.storage", + it.energyStored.formatPower(), + it.maxEnergyStored.formatPower() + ).withStyle(ChatFormatting.GRAY)) +} + +internal fun batteryLevel(it: IMatteryEnergyStorage, tooltips: MutableList) { + tooltips.add( + TranslatableComponent( + "otm.item.power.storage", + it.batteryLevel.formatPower(), + it.maxBatteryLevel.formatPower() + ).withStyle(ChatFormatting.GRAY)) + + if (it is IEnergyStorageImpl) { + when (it.direction) { + FlowDirection.INPUT -> { + if (it.maxInput != null) { + tooltips.add( + TranslatableComponent("otm.item.power.throughput_mono", it.maxInput!!.formatPower()).withStyle( + ChatFormatting.GRAY + )) + } else { + tooltips.add( + TranslatableComponent( + "otm.item.power.throughput_mono", + TranslatableComponent("otm.item.power.infinity").withStyle(ChatFormatting.GRAY) + ).withStyle(ChatFormatting.GRAY)) + } + } + + FlowDirection.OUTPUT -> { + if (it.maxOutput != null) { + tooltips.add( + TranslatableComponent("otm.item.power.throughput_mono", it.maxOutput!!.formatPower()).withStyle( + ChatFormatting.GRAY + )) + } else { + tooltips.add( + TranslatableComponent( + "otm.item.power.throughput_mono", + TranslatableComponent("otm.item.power.infinity").withStyle(ChatFormatting.GRAY) + ).withStyle(ChatFormatting.GRAY)) + } + } + + FlowDirection.BI_DIRECTIONAL -> { + val maxInput = it.maxInput + val maxOutput = it.maxOutput + + if (maxInput != null && maxOutput != null) { + tooltips.add( + TranslatableComponent( + "otm.item.power.throughput", + maxInput.formatPower(), + maxOutput.formatPower() + ).withStyle(ChatFormatting.GRAY)) + } else if (maxInput != null) { + tooltips.add( + TranslatableComponent( + "otm.item.power.throughput", + maxInput.formatPower(), + TranslatableComponent("otm.item.power.infinity").withStyle(ChatFormatting.GRAY) + ).withStyle(ChatFormatting.GRAY)) + } else if (maxOutput != null) { + tooltips.add( + TranslatableComponent( + "otm.item.power.throughput", + TranslatableComponent("otm.item.power.infinity").withStyle(ChatFormatting.GRAY), + maxOutput.formatPower(), + ).withStyle(ChatFormatting.GRAY)) + } else { + tooltips.add( + TranslatableComponent( + "otm.item.power.throughput", + TranslatableComponent("otm.item.power.infinity").withStyle(ChatFormatting.GRAY), + TranslatableComponent("otm.item.power.infinity").withStyle(ChatFormatting.GRAY), + ).withStyle(ChatFormatting.GRAY)) + } + } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/IMatteryEnergyStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt similarity index 99% rename from src/main/kotlin/ru/dbotthepony/mc/otm/capability/IMatteryEnergyStorage.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt index 9903c83d9..a6eee5238 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/IMatteryEnergyStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.capability +package ru.dbotthepony.mc.otm.capability.energy import net.minecraftforge.energy.IEnergyStorage import ru.dbotthepony.mc.otm.core.Decimal diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt new file mode 100644 index 000000000..8e9690ba9 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt @@ -0,0 +1,175 @@ +package ru.dbotthepony.mc.otm.capability.energy + +import net.minecraft.core.Direction +import net.minecraft.network.chat.Component +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.TooltipFlag +import net.minecraft.world.level.Level +import net.minecraftforge.common.capabilities.Capability +import net.minecraftforge.common.capabilities.ForgeCapabilities +import net.minecraftforge.common.capabilities.ICapabilityProvider +import net.minecraftforge.common.util.LazyOptional +import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.energy +import ru.dbotthepony.mc.otm.capability.isMekanismLoaded +import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper +import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.map +import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.tagNotNull + +sealed class ItemEnergyStorageImpl( + final override val direction: FlowDirection, + protected val itemStack: ItemStack, + maxBatteryLevel: Decimal, + maxInput: Decimal?, + maxOutput: Decimal?, + val initialBatteryLevel: Decimal = Decimal.ZERO +) : IMatteryEnergyStorage, ICapabilityProvider, IEnergyStorageImpl { + final override var maxInput: Decimal? = maxInput + protected set + + final override var maxOutput: Decimal? = maxOutput + protected set + + private val resolver = LazyOptional.of { this } + private val resolverMekanism = if (isMekanismLoaded) LazyOptional.of { Mattery2MekanismEnergyWrapper(this) } else null + + override fun getCapability(cap: Capability, side: Direction?): LazyOptional { + if (cap == ForgeCapabilities.ENERGY || cap == MatteryCapability.ENERGY) { + return resolver.cast() + } else if (cap == MatteryCapability.MEKANISM_ENERGY) { + return resolverMekanism?.cast() ?: LazyOptional.empty() + } + + return LazyOptional.empty() + } + + override var maxBatteryLevel: Decimal = maxBatteryLevel + protected set + + override var batteryLevel: Decimal + get() = itemStack.tag?.map(ENERGY_KEY, Decimal.Companion::deserializeNBT) ?: initialBatteryLevel + set(value) { + itemStack.tagNotNull[ENERGY_KEY] = value.serializeNBT() + } + + override fun extractEnergyOuter(howMuch: Decimal, simulate: Boolean): Decimal { + if (direction == FlowDirection.INPUT) + return Decimal.ZERO + + return extractEnergyInner(howMuch, simulate) + } + + override fun receiveEnergyOuter(howMuch: Decimal, simulate: Boolean): Decimal { + if (direction == FlowDirection.OUTPUT) + return Decimal.ZERO + + return receiveEnergyInner(howMuch, simulate) + } + + override fun extractEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { + if (!howMuch.isPositive || itemStack.count != 1) + return Decimal.ZERO + + @Suppress("NAME_SHADOWING") + var howMuch = howMuch + val maxOutput = maxOutput + + if (maxOutput != null) { + howMuch = howMuch.coerceAtMost(maxOutput) + } + + val batteryLevel = batteryLevel + + if (!batteryLevel.isPositive) + return Decimal.ZERO + + val newLevel = (batteryLevel - howMuch).moreThanZero() + val diff = (batteryLevel - newLevel) + + if (!simulate && batteryLevel != newLevel) { + this.batteryLevel = newLevel + } + + return diff + } + + override fun receiveEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { + if (!howMuch.isPositive || itemStack.count != 1) + return Decimal.ZERO + + @Suppress("NAME_SHADOWING") + var howMuch = howMuch + val maxInput = maxInput + + if (maxInput != null) { + howMuch = howMuch.coerceAtMost(maxInput) + } + + val batteryLevel = batteryLevel + + if (batteryLevel >= maxBatteryLevel) + return Decimal.ZERO + + val newLevel = (batteryLevel + howMuch).coerceAtMost(maxBatteryLevel) + val diff = (newLevel - batteryLevel) + + if (!simulate && batteryLevel != newLevel) { + this.batteryLevel = newLevel + } + + return diff + } + + override fun canExtract(): Boolean { + return direction != FlowDirection.INPUT + } + + override fun canReceive(): Boolean { + return direction != FlowDirection.OUTPUT + } + + companion object { + const val ENERGY_KEY = "energy" + + fun appendHoverText(itemStack: ItemStack, level: Level?, tooltips: MutableList, flag: TooltipFlag) { + appendHoverText(itemStack, tooltips) + } + + fun appendHoverText(itemStack: ItemStack, tooltips: MutableList) { + val energy = itemStack.energy ?: return + + if (energy is IMatteryEnergyStorage) { + batteryLevel(energy, tooltips) + } else { + batteryLevel(energy, tooltips) + } + } + } +} + +open class EnergyConsumerItem( + stack: ItemStack, + maxBatteryLevel: Decimal, + maxInput: Decimal? = null, + maxOutput: Decimal? = maxInput, + initialBatteryLevel: Decimal = Decimal.ZERO +) : ItemEnergyStorageImpl(FlowDirection.INPUT, stack, maxBatteryLevel, maxInput, maxOutput, initialBatteryLevel) + +open class EnergyProducerItem( + stack: ItemStack, + maxBatteryLevel: Decimal, + maxInput: Decimal? = null, + maxOutput: Decimal? = maxInput, + initialBatteryLevel: Decimal = Decimal.ZERO +) : ItemEnergyStorageImpl(FlowDirection.OUTPUT, stack, maxBatteryLevel, maxInput, maxOutput, initialBatteryLevel) + +open class EnergyCapacitorItem( + stack: ItemStack, + maxBatteryLevel: Decimal, + maxInput: Decimal? = null, + maxOutput: Decimal? = maxInput, + initialBatteryLevel: Decimal = Decimal.ZERO +) : ItemEnergyStorageImpl(FlowDirection.BI_DIRECTIONAL, stack, maxBatteryLevel, maxInput, maxOutput, initialBatteryLevel) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt index b6335ec86..127c65672 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt @@ -10,7 +10,7 @@ import net.minecraftforge.common.capabilities.ICapabilityProvider import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.energy.IEnergyStorage import org.apache.logging.log4j.LogManager -import ru.dbotthepony.mc.otm.capability.IMatteryEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.isMekanismLoaded import ru.dbotthepony.mc.otm.core.Decimal @@ -70,7 +70,8 @@ private val mtj2Mekanism by DoubleLazy lazy@{ return@lazy lazyOf(Decimal.ONE) } -class Mekanism2MatteryEnergyWrapper(private val power: IStrictEnergyHandler, private val forgePower: IEnergyStorage? = null) : IMatteryEnergyStorage { +class Mekanism2MatteryEnergyWrapper(private val power: IStrictEnergyHandler, private val forgePower: IEnergyStorage? = null) : + IMatteryEnergyStorage { override fun extractEnergyOuter(howMuch: Decimal, simulate: Boolean): Decimal { val action = when (simulate) { true -> Action.SIMULATE diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/BasicStorageGraphNode.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/BasicStorageGraphNode.kt index d76c2d5e9..b0f52a83b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/BasicStorageGraphNode.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/BasicStorageGraphNode.kt @@ -1,12 +1,10 @@ package ru.dbotthepony.mc.otm.graph.storage -import it.unimi.dsi.fastutil.objects.ObjectArraySet import net.minecraft.world.level.Level import net.minecraftforge.common.util.LazyOptional -import ru.dbotthepony.mc.otm.capability.IMatteryEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.storage.IStorage -import ru.dbotthepony.mc.otm.storage.IStorageEventConsumer import ru.dbotthepony.mc.otm.storage.IStorageStack import ru.dbotthepony.mc.otm.storage.StorageStackType import java.util.* diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNetworkGraph.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNetworkGraph.kt index 5c4f94710..a86764829 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNetworkGraph.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNetworkGraph.kt @@ -6,7 +6,7 @@ import net.minecraft.server.level.ServerLevel import net.minecraft.world.level.Level import net.minecraft.world.level.block.entity.BlockEntity import ru.dbotthepony.mc.otm.addTickerPre -import ru.dbotthepony.mc.otm.capability.IMatteryEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.graph.Abstract6Graph import ru.dbotthepony.mc.otm.graph.Graph6Node @@ -92,4 +92,4 @@ class StorageNetworkGraph(private val level: Level) : Abstract6Graph Date: Sat, 14 Jan 2023 11:41:18 +0700 Subject: [PATCH 0040/1199] Documentation and some refactoring related to matter capability --- .../mc/otm/android/AndroidFeature.kt | 1 - .../entity/matter/MatterBottlerBlockEntity.kt | 12 ++-- .../matter/MatterCapacitorBankBlockEntity.kt | 7 +- .../matter/MatterDecomposerBlockEntity.kt | 4 +- .../matter/MatterRecyclerBlockEntity.kt | 4 +- .../matter/MatterReplicatorBlockEntity.kt | 3 +- .../mc/otm/capability/FlowDirection.kt | 31 +++++++- .../{android => }/MatteryPlayerCapability.kt | 6 +- .../{android => energy}/AndroidPowerSource.kt | 3 +- .../otm/capability/matter/IMatterHandler.kt | 70 +++++++++++++++++-- .../otm/capability/matter/MatterDirection.kt | 3 - .../capability/matter/MatterHandlerImpl.kt | 13 ++-- .../UUIDIntModifiersMap.kt | 4 +- .../mc/otm/graph/matter/MatterNetworkGraph.kt | 9 +-- .../mc/otm/item/MatterCapacitorItem.kt | 6 +- .../mc/otm/menu/MatterBottlerMenu.kt | 6 +- .../ru/dbotthepony/mc/otm/menu/Slots.kt | 7 +- 17 files changed, 133 insertions(+), 56 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/capability/{android => }/MatteryPlayerCapability.kt (99%) rename src/main/kotlin/ru/dbotthepony/mc/otm/capability/{android => energy}/AndroidPowerSource.kt (97%) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterDirection.kt rename src/main/kotlin/ru/dbotthepony/mc/otm/{capability => core}/UUIDIntModifiersMap.kt (94%) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeature.kt index 80decd149..663e21ba5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeature.kt @@ -7,7 +7,6 @@ import net.minecraftforge.event.entity.living.LivingHurtEvent import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.network.FieldSynchronizer -import java.io.DataInputStream import java.io.InputStream abstract class AndroidFeature(val type: AndroidFeatureType<*>, val android: MatteryPlayerCapability) : INBTSerializable { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index b4e8b6f1b..80b61db2c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -22,11 +22,11 @@ import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.IMatterHandler -import ru.dbotthepony.mc.otm.capability.matter.MatterDirection import ru.dbotthepony.mc.otm.capability.matter.MatterHandlerImpl import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainerHooks @@ -114,9 +114,9 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } }) - val matter: MatterHandlerImpl = object : MatterHandlerImpl(this::setChangedLight, MatterDirection.BIDIRECTIONAL, ::CAPACITY) { - override val direction: MatterDirection get() { - return if (this@MatterBottlerBlockEntity.isBottling) MatterDirection.RECEIVE else MatterDirection.EXTRACT + val matter: MatterHandlerImpl = object : MatterHandlerImpl(this::setChangedLight, FlowDirection.BI_DIRECTIONAL, ::CAPACITY) { + override val matterDirection: FlowDirection get() { + return if (this@MatterBottlerBlockEntity.isBottling) FlowDirection.INPUT else FlowDirection.OUTPUT } } @@ -233,7 +233,7 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : var capability: IMatterHandler? = null val align = if (isBottling) 0 else 3 var work_slot = -1 - val unexpectedDirection = if (isBottling) MatterDirection.EXTRACT else MatterDirection.RECEIVE + val unexpectedDirection = if (isBottling) FlowDirection.OUTPUT else FlowDirection.INPUT for (i in align until align + 3) { val itemStack = container.getItem(i) @@ -241,7 +241,7 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : if (!itemStack.isEmpty) { val cap = itemStack.getCapability(MatteryCapability.MATTER).orNull() ?: continue - if (cap.direction !== unexpectedDirection) { + if (cap.matterDirection != unexpectedDirection) { if (this.isBottling && cap.missingMatter > Decimal.ZERO || !this.isBottling && cap.storedMatter > Decimal.ZERO) { work_stack = itemStack capability = cap diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt index fe7bca537..e3eeb92c1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt @@ -19,9 +19,9 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.block.BatteryBankBlock import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity +import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.matter.IMatterHandler -import ru.dbotthepony.mc.otm.capability.matter.MatterDirection import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.core.Decimal import ru.dbotthepony.mc.otm.core.ifPresentK @@ -136,9 +136,8 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) return summ } - override val direction: MatterDirection get() { - return MatterDirection.BIDIRECTIONAL - } + override val matterDirection: FlowDirection + get() = FlowDirection.BI_DIRECTIONAL private var resolver = LazyOptional.of { this } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index 1cb743713..d622b51bc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -20,11 +20,11 @@ import net.minecraftforge.items.IItemHandler import ru.dbotthepony.mc.otm.ConciseBalanceValues import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity +import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.IMatterHandler -import ru.dbotthepony.mc.otm.capability.matter.MatterDirection import ru.dbotthepony.mc.otm.capability.matter.MatterHandlerImpl import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainerHooks @@ -128,7 +128,7 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) private var valid = true override val matterNode = Graph6Node(this) - val matter = MatterHandlerImpl(this::setChangedLight, MatterDirection.EXTRACT, ::CAPACITY) + val matter = MatterHandlerImpl(this::setChangedLight, FlowDirection.OUTPUT, ::CAPACITY) private var resolverMatter = LazyOptional.of { matter } private var resolverNode = LazyOptional.of { this } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index 242635b4a..a46221ec6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -20,11 +20,11 @@ import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.ConciseBalanceValues import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity +import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.IMatterHandler -import ru.dbotthepony.mc.otm.capability.matter.MatterDirection import ru.dbotthepony.mc.otm.capability.matter.MatterHandlerImpl import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainerHooks @@ -75,7 +75,7 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) val matter = MatterHandlerImpl( this::matterLevelUpdated, - MatterDirection.EXTRACT, + FlowDirection.OUTPUT, ::CAPACITY ) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index a74cc615a..1c990bb78 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -19,6 +19,7 @@ import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.ConciseBalanceValues import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity +import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage @@ -104,7 +105,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val matter = MatterHandlerImpl( this::matterLevelUpdated, - MatterDirection.RECEIVE, + FlowDirection.INPUT, ::MATTER_CAPACITY ) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt index 67dc1ffa9..d84501e38 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt @@ -1,5 +1,32 @@ package ru.dbotthepony.mc.otm.capability -enum class FlowDirection { - INPUT, OUTPUT, BI_DIRECTIONAL +import java.util.function.Predicate + +/** + * Represents possible flow direction, both for matter and for energy + */ +enum class FlowDirection(val input: Boolean, val output: Boolean) : Predicate { + /** + * Can only be inputted (consumer) + */ + INPUT(true, false), + + /** + * Can only be outputted/transmitted (producer) + */ + OUTPUT(false, true), + + /** + * Can both consume and produce (capacitor) + */ + BI_DIRECTIONAL(true, true), + + /** + * Why would you want to use this + */ + NONE(false, false); + + override fun test(t: FlowDirection): Boolean { + return t === this || (!input || t.input) && (!output || t.output) + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/android/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt similarity index 99% rename from src/main/kotlin/ru/dbotthepony/mc/otm/capability/android/MatteryPlayerCapability.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 950be069f..54d07417f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/android/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.capability.android +package ru.dbotthepony.mc.otm.capability import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import net.minecraft.ChatFormatting @@ -44,9 +44,7 @@ import ru.dbotthepony.mc.otm.android.AndroidResearch import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidResearchType import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature -import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.capability.UUIDIntModifiersMap -import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.capability.energy.AndroidPowerSource import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.stream diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/android/AndroidPowerSource.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt similarity index 97% rename from src/main/kotlin/ru/dbotthepony/mc/otm/capability/android/AndroidPowerSource.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt index 6f7746dca..c0f3be2a3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/android/AndroidPowerSource.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.capability.android +package ru.dbotthepony.mc.otm.capability.energy import net.minecraft.nbt.CompoundTag import net.minecraft.server.level.ServerPlayer @@ -6,7 +6,6 @@ import net.minecraft.world.entity.player.Player import net.minecraft.world.item.ItemStack import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.INBTSerializable -import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.extractEnergy import ru.dbotthepony.mc.otm.capability.receiveEnergy import ru.dbotthepony.mc.otm.core.Decimal diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterHandler.kt index 7863b2e9a..c0aec3e31 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterHandler.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.capability.matter import net.minecraftforge.common.capabilities.ICapabilityProvider import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.core.Decimal import ru.dbotthepony.mc.otm.core.RGBAColor import ru.dbotthepony.mc.otm.core.orNull @@ -14,12 +15,20 @@ interface IMatterHandler { val canSetMatterLevel: Boolean get() = true /** + * How much matter (estimated) is stored in this object. Why estimated? Because some objects can be bottomless. + * * Implementations are free to throw [UnsupportedOperationException] if setting battery level is not supported * due to technical complications (in this case, [canSetMatterLevel] MUST be false) * * @throws [UnsupportedOperationException] */ var storedMatter: Decimal + + /** + * How much matter (estimated) can this object hold. Why estimated? Because some objects can be bottomless. + * + * **DO NOT use this to determine "how much stuff is missing", use [missingMatter] instead!** + */ val maxStoredMatter: Decimal /** @@ -42,22 +51,71 @@ interface IMatterHandler { storedMatter = maxStoredMatter } + /** + * Make this object receive matter, from outside world. + * + * Call this if you don't own the object in question. + * + * @return matter accepted + */ fun receiveMatterOuter(howMuch: Decimal, simulate: Boolean): Decimal + + /** + * Make this object receive matter, from inside world. + * + * Call this if you DO own the object in question. + * + * Nothing stops you from calling this from outside world, however, this will most likely + * lead to bugs, use [receiveMatterOuter] in this case instead. Methods were separated (and inside interface) for ease of use. + * + * Don't try to hammer nails with a screwdriver. + * + * @return matter accepted + */ fun receiveMatterInner(howMuch: Decimal, simulate: Boolean): Decimal + + /** + * Make this object extract matter from itself, from outside world. + * + * Call this if you don't own the object in question. + * + * @return matter extracted + */ fun extractMatterOuter(howMuch: Decimal, simulate: Boolean): Decimal + + /** + * Make this object extract matter from itself, from inside world. + * + * Call this if you DO own the object in question. + * + * Nothing stops you from calling this from outside world, however, this will most likely + * lead to bugs, use [extractMatterOuter] in this case instead. Methods were separated (and inside interface) for ease of use. + * + * Don't try to hammer nails with a screwdriver. + * + * @return matter extracted + */ fun extractMatterInner(howMuch: Decimal, simulate: Boolean): Decimal - val direction: MatterDirection + /** + * How much matter (estimated) is missing in this object. Why estimated? Because some objects can be bottomless. + * + * Use this to determine whenever you need an estimate on how much matter this object can accept, **and do not implement [maxStoredMatter] - [storedMatter] logic by yourself**. + */ val missingMatter: Decimal get() = maxStoredMatter.minus(storedMatter).moreThanZero() - val allowsExtract: Boolean - get() = direction != MatterDirection.RECEIVE - - val allowsReceive: Boolean - get() = direction != MatterDirection.EXTRACT + /** + * Which direction does matter flows + */ + val matterDirection: FlowDirection } +inline val IMatterHandler.canExtractMatter: Boolean + get() = matterDirection.output +inline val IMatterHandler.canReceiveMatter: Boolean + get() = matterDirection.input + fun IMatterHandler.getBarWidth(): Int { return ((storedMatter / maxStoredMatter).toFloat().coerceAtLeast(0f).coerceAtMost(1f) * 13f).roundToInt() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterDirection.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterDirection.kt deleted file mode 100644 index e03c7bc4e..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterDirection.kt +++ /dev/null @@ -1,3 +0,0 @@ -package ru.dbotthepony.mc.otm.capability.matter - -enum class MatterDirection { RECEIVE, EXTRACT, BIDIRECTIONAL } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterHandlerImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterHandlerImpl.kt index fb80c3b23..7b9da92aa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterHandlerImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterHandlerImpl.kt @@ -5,19 +5,20 @@ import net.minecraftforge.common.util.INBTSerializable import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.ConciseBalanceValues import ru.dbotthepony.mc.otm.VerboseBalanceValues +import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.core.Decimal import ru.dbotthepony.mc.otm.core.set open class MatterHandlerImpl @JvmOverloads constructor( protected val listener: Runnable?, - override val direction: MatterDirection, + override val matterDirection: FlowDirection, protected val maxStoredMatterSupplier: () -> Decimal, protected val maxReceiveSupplier: () -> Decimal? = { null }, protected val maxExtractSupplier: () -> Decimal? = maxReceiveSupplier ) : IMatterHandler, INBTSerializable { constructor( listener: Runnable?, - direction: MatterDirection, + direction: FlowDirection, maxStoredMatter: Decimal, maxReceive: Decimal? = null, maxExtract: Decimal? = null, @@ -25,13 +26,13 @@ open class MatterHandlerImpl @JvmOverloads constructor( constructor( listener: Runnable?, - direction: MatterDirection, + direction: FlowDirection, values: ConciseBalanceValues ) : this(listener, direction, values::capacity, values::throughput, values::throughput) constructor( listener: Runnable?, - direction: MatterDirection, + direction: FlowDirection, values: VerboseBalanceValues ) : this(listener, direction, values::capacity, values::receive, values::extract) @@ -62,7 +63,7 @@ open class MatterHandlerImpl @JvmOverloads constructor( } override fun receiveMatterOuter(howMuch: Decimal, simulate: Boolean): Decimal { - if (direction === MatterDirection.EXTRACT) + if (!canReceiveMatter) return Decimal.ZERO return receiveMatterInner(howMuch, simulate) @@ -88,7 +89,7 @@ open class MatterHandlerImpl @JvmOverloads constructor( } override fun extractMatterOuter(howMuch: Decimal, simulate: Boolean): Decimal { - if (direction === MatterDirection.RECEIVE) + if (canExtractMatter) return Decimal.ZERO return extractMatterInner(howMuch, simulate) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/UUIDIntModifiersMap.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/UUIDIntModifiersMap.kt similarity index 94% rename from src/main/kotlin/ru/dbotthepony/mc/otm/capability/UUIDIntModifiersMap.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/UUIDIntModifiersMap.kt index 772bd47f5..1a566fe4d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/UUIDIntModifiersMap.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/UUIDIntModifiersMap.kt @@ -1,10 +1,8 @@ -package ru.dbotthepony.mc.otm.capability +package ru.dbotthepony.mc.otm.core import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.ListTag -import net.minecraft.nbt.Tag import net.minecraftforge.common.util.INBTSerializable -import ru.dbotthepony.mc.otm.core.contains import java.util.UUID /** diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNetworkGraph.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNetworkGraph.kt index d9251d542..4f0f59ef6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNetworkGraph.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNetworkGraph.kt @@ -4,6 +4,7 @@ import com.google.common.collect.Streams import net.minecraft.server.level.ServerLevel import net.minecraft.world.item.Item import net.minecraft.world.level.block.entity.BlockEntity +import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.matter.* import ru.dbotthepony.mc.otm.core.Decimal @@ -79,7 +80,7 @@ class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListe for (node in nodes) { val matter = node.value.getMatterHandler() - if (matter != null && matter.direction == MatterDirection.BIDIRECTIONAL) { + if (matter != null && matter.matterDirection == FlowDirection.BI_DIRECTIONAL) { level += matter.storedMatter } } @@ -93,7 +94,7 @@ class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListe for (node in nodes) { val matter = node.value.getMatterHandler() - if (matter != null && matter.direction == MatterDirection.BIDIRECTIONAL) { + if (matter != null && matter.matterDirection == FlowDirection.BI_DIRECTIONAL) { level += matter.maxStoredMatter } } @@ -136,7 +137,7 @@ class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListe for (node in nodes) { val matter = node.value.getMatterHandler() - if (matter != null && matter.direction == MatterDirection.BIDIRECTIONAL) { + if (matter != null && matter.matterDirection == FlowDirection.BI_DIRECTIONAL) { val value = matter.receiveMatterOuter(howMuch, simulate) howMuch -= value received += value @@ -160,7 +161,7 @@ class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListe for (node in nodes) { val matter = node.value.getMatterHandler() - if (matter != null && matter.direction != MatterDirection.EXTRACT) { + if (matter != null && matter.matterDirection != FlowDirection.OUTPUT) { val value = matter.receiveMatterOuter(howMuch, simulate) howMuch -= value received += value diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt index bef7f1022..0659177f7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt @@ -3,10 +3,8 @@ package ru.dbotthepony.mc.otm.item import net.minecraft.ChatFormatting import net.minecraft.MethodsReturnNonnullByDefault import net.minecraft.core.Direction -import net.minecraft.core.NonNullList import net.minecraft.nbt.CompoundTag import net.minecraft.network.chat.Component -import net.minecraft.world.item.CreativeModeTab import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Rarity @@ -15,7 +13,7 @@ import net.minecraft.world.level.Level import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ICapabilityProvider import net.minecraftforge.common.util.LazyOptional -import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.matter.* @@ -86,7 +84,7 @@ class MatterCapacitorItem : Item { return diff } - override val direction = MatterDirection.BIDIRECTIONAL + override val matterDirection = FlowDirection.BI_DIRECTIONAL } private val _capacity: () -> Decimal diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterBottlerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterBottlerMenu.kt index afca430f3..784cdde72 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterBottlerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterBottlerMenu.kt @@ -6,6 +6,8 @@ import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.core.ImmutableList import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.matter.canExtractMatter +import ru.dbotthepony.mc.otm.capability.matter.canReceiveMatter import ru.dbotthepony.mc.otm.menu.widget.BooleanPlayerInputWidget import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget @@ -45,9 +47,9 @@ class MatterBottlerMenu @JvmOverloads constructor( val cap = p_40231_.getCapability(MatteryCapability.MATTER).orNull() ?: return false if (workFlow.value) { - return index < 3 && cap.allowsReceive + return index < 3 && cap.canReceiveMatter } else { - return index >= 3 && cap.allowsExtract + return index >= 3 && cap.canExtractMatter } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt index c2e8374a9..2910de8d0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt @@ -4,9 +4,9 @@ import net.minecraft.world.Container import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy -import ru.dbotthepony.mc.otm.capability.matter.MatterDirection import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.runOnClient @@ -43,13 +43,12 @@ open class MatterContainerInputSlot @JvmOverloads constructor( index: Int, x: Int = 0, y: Int = 0, - val direction: MatterDirection = MatterDirection.BIDIRECTIONAL + val direction: FlowDirection = FlowDirection.BI_DIRECTIONAL ) : MatterySlot(container, index, x, y) { override fun mayPlace(itemStack: ItemStack): Boolean { val handler = itemStack.getCapability(MatteryCapability.MATTER).resolve() if (handler.isEmpty) return false - val direction = handler.get().direction - return super.mayPlace(itemStack) && (direction == MatterDirection.BIDIRECTIONAL || this.direction == direction) + return super.mayPlace(itemStack) && this.direction.test(handler.get().matterDirection) } } From e4dc6f60e71db6533e0484a3fdf3e9fb38552421 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 14 Jan 2023 11:57:32 +0700 Subject: [PATCH 0041/1199] Get rid of receive/extract matter separation --- .../entity/matter/MatterBottlerBlockEntity.kt | 10 ++--- .../matter/MatterCapacitorBankBlockEntity.kt | 16 ++----- .../matter/MatterReplicatorBlockEntity.kt | 2 +- .../otm/capability/matter/IMatterHandler.kt | 44 +++---------------- .../capability/matter/MatterHandlerImpl.kt | 8 ++-- .../mc/otm/graph/matter/MatterNetworkGraph.kt | 6 +-- .../mc/otm/item/MatterCapacitorItem.kt | 12 +---- 7 files changed, 26 insertions(+), 72 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index 80b61db2c..d2cb29fd7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -274,7 +274,7 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : ) if (extracted > Decimal.ZERO) { - val received = matter.receiveMatterOuter(extracted, false) + val received = matter.receiveMatter(extracted, false) graph.extractMatter(received, false) } } @@ -283,12 +283,12 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val energyExtracted = energy.extractEnergyInner(ENERGY_CONSUMPTION, true) if (!energyExtracted.isZero) { - val matter = capability.receiveMatterOuter(MATTER_EXCHANGE_RATE.coerceAtMost(matter.storedMatter) * energyExtracted / ENERGY_CONSUMPTION, true) + val matter = capability.receiveMatter(MATTER_EXCHANGE_RATE.coerceAtMost(matter.storedMatter) * energyExtracted / ENERGY_CONSUMPTION, true) if (!matter.isZero) { energy.extractEnergyInner(ENERGY_CONSUMPTION * matter / MATTER_EXCHANGE_RATE, false) - capability.receiveMatterOuter(matter, false) + capability.receiveMatter(matter, false) this.matter.extractMatterInner(matter, false) if (capability.missingMatter.isZero) { @@ -307,12 +307,12 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val energyExtracted = energy.extractEnergyInner(ENERGY_CONSUMPTION, true) if (!energyExtracted.isZero) { - val matter = capability.extractMatterOuter(MATTER_EXCHANGE_RATE.coerceAtMost(matter.missingMatter) * energyExtracted / ENERGY_CONSUMPTION, true) + val matter = capability.extractMatter(MATTER_EXCHANGE_RATE.coerceAtMost(matter.missingMatter) * energyExtracted / ENERGY_CONSUMPTION, true) if (!matter.isZero) { this.energy.extractEnergyInner(ENERGY_CONSUMPTION * matter / MATTER_EXCHANGE_RATE,false) - capability.extractMatterOuter(matter, false) + capability.extractMatter(matter, false) this.matter.receiveMatterInner(matter, false) if (capability.storedMatter.isZero) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt index e3eeb92c1..9d2994ce9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt @@ -70,11 +70,7 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) return summ } - override fun receiveMatterOuter(howMuch: Decimal, simulate: Boolean): Decimal { - return receiveMatterInner(howMuch, simulate) - } - - override fun receiveMatterInner(howMuch: Decimal, simulate: Boolean): Decimal { + override fun receiveMatter(howMuch: Decimal, simulate: Boolean): Decimal { if (!howMuch.isPositive) return Decimal.ZERO @@ -85,7 +81,7 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) for (stack in container) { if (!stack.isEmpty) { stack.getCapability(MatteryCapability.MATTER).ifPresent { - val diff = it.receiveMatterOuter(howMuch, simulate) + val diff = it.receiveMatter(howMuch, simulate) summ += diff howMuch -= diff } @@ -103,11 +99,7 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) return summ } - override fun extractMatterOuter(howMuch: Decimal, simulate: Boolean): Decimal { - return extractMatterInner(howMuch, simulate) - } - - override fun extractMatterInner(howMuch: Decimal, simulate: Boolean): Decimal { + override fun extractMatter(howMuch: Decimal, simulate: Boolean): Decimal { if (!howMuch.isPositive) return Decimal.ZERO @@ -118,7 +110,7 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) for (stack in container) { if (!stack.isEmpty) { stack.getCapability(MatteryCapability.MATTER).ifPresent { - val diff = it.extractMatterOuter(howMuch, simulate) + val diff = it.extractMatter(howMuch, simulate) summ += diff howMuch -= diff } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index 1c990bb78..ec26eec2c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -244,7 +244,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return Status.FAILURE_MATTER } - val received = matter.receiveMatterOuter(drain, false) + val received = matter.receiveMatter(drain, false) graph.extractMatter(received, false) // получили материю, проверяем возможность работы diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterHandler.kt index c0aec3e31..6dd5334b5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterHandler.kt @@ -20,6 +20,8 @@ interface IMatterHandler { * Implementations are free to throw [UnsupportedOperationException] if setting battery level is not supported * due to technical complications (in this case, [canSetMatterLevel] MUST be false) * + * If you need to fully fill matter value, DO call [fillMatter], or, in case if you want to fully drain, call [drainMatter] + * * @throws [UnsupportedOperationException] */ var storedMatter: Decimal @@ -37,7 +39,7 @@ interface IMatterHandler { * @throws [UnsupportedOperationException] * @see storedMatter */ - fun emptyMatter() { + fun drainMatter() { storedMatter = Decimal.ZERO } @@ -52,50 +54,18 @@ interface IMatterHandler { } /** - * Make this object receive matter, from outside world. - * - * Call this if you don't own the object in question. + * Fill matter into this object * * @return matter accepted */ - fun receiveMatterOuter(howMuch: Decimal, simulate: Boolean): Decimal + fun receiveMatter(howMuch: Decimal, simulate: Boolean): Decimal /** - * Make this object receive matter, from inside world. - * - * Call this if you DO own the object in question. - * - * Nothing stops you from calling this from outside world, however, this will most likely - * lead to bugs, use [receiveMatterOuter] in this case instead. Methods were separated (and inside interface) for ease of use. - * - * Don't try to hammer nails with a screwdriver. - * - * @return matter accepted - */ - fun receiveMatterInner(howMuch: Decimal, simulate: Boolean): Decimal - - /** - * Make this object extract matter from itself, from outside world. - * - * Call this if you don't own the object in question. + * Extract matter from this object * * @return matter extracted */ - fun extractMatterOuter(howMuch: Decimal, simulate: Boolean): Decimal - - /** - * Make this object extract matter from itself, from inside world. - * - * Call this if you DO own the object in question. - * - * Nothing stops you from calling this from outside world, however, this will most likely - * lead to bugs, use [extractMatterOuter] in this case instead. Methods were separated (and inside interface) for ease of use. - * - * Don't try to hammer nails with a screwdriver. - * - * @return matter extracted - */ - fun extractMatterInner(howMuch: Decimal, simulate: Boolean): Decimal + fun extractMatter(howMuch: Decimal, simulate: Boolean): Decimal /** * How much matter (estimated) is missing in this object. Why estimated? Because some objects can be bottomless. diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterHandlerImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterHandlerImpl.kt index 7b9da92aa..f3baa9b2f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterHandlerImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterHandlerImpl.kt @@ -62,14 +62,14 @@ open class MatterHandlerImpl @JvmOverloads constructor( return maxStoredMatter >= value && storedMatter + value <= maxStoredMatter } - override fun receiveMatterOuter(howMuch: Decimal, simulate: Boolean): Decimal { + override fun receiveMatter(howMuch: Decimal, simulate: Boolean): Decimal { if (!canReceiveMatter) return Decimal.ZERO return receiveMatterInner(howMuch, simulate) } - override fun receiveMatterInner(howMuch: Decimal, simulate: Boolean): Decimal { + fun receiveMatterInner(howMuch: Decimal, simulate: Boolean): Decimal { val new: Decimal if (maxReceive == null) { @@ -88,14 +88,14 @@ open class MatterHandlerImpl @JvmOverloads constructor( return diff } - override fun extractMatterOuter(howMuch: Decimal, simulate: Boolean): Decimal { + override fun extractMatter(howMuch: Decimal, simulate: Boolean): Decimal { if (canExtractMatter) return Decimal.ZERO return extractMatterInner(howMuch, simulate) } - override fun extractMatterInner(howMuch: Decimal, simulate: Boolean): Decimal { + fun extractMatterInner(howMuch: Decimal, simulate: Boolean): Decimal { val new: Decimal if (maxExtract == null) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNetworkGraph.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNetworkGraph.kt index 4f0f59ef6..163bfb788 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNetworkGraph.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNetworkGraph.kt @@ -114,7 +114,7 @@ class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListe val matter = node.value.getMatterHandler() if (matter != null) { - val value = matter.extractMatterOuter(howMuch, simulate) + val value = matter.extractMatter(howMuch, simulate) howMuch -= value extracted += value @@ -138,7 +138,7 @@ class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListe val matter = node.value.getMatterHandler() if (matter != null && matter.matterDirection == FlowDirection.BI_DIRECTIONAL) { - val value = matter.receiveMatterOuter(howMuch, simulate) + val value = matter.receiveMatter(howMuch, simulate) howMuch -= value received += value @@ -162,7 +162,7 @@ class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListe val matter = node.value.getMatterHandler() if (matter != null && matter.matterDirection != FlowDirection.OUTPUT) { - val value = matter.receiveMatterOuter(howMuch, simulate) + val value = matter.receiveMatter(howMuch, simulate) howMuch -= value received += value diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt index 0659177f7..a90a620df 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt @@ -52,11 +52,7 @@ class MatterCapacitorItem : Item { return if (isCreative) Decimal.LONG_MAX_VALUE else super.missingMatter } - override fun receiveMatterOuter(howMuch: Decimal, simulate: Boolean): Decimal { - return receiveMatterInner(howMuch, simulate) - } - - override fun receiveMatterInner(howMuch: Decimal, simulate: Boolean): Decimal { + override fun receiveMatter(howMuch: Decimal, simulate: Boolean): Decimal { if (isCreative) return howMuch val new = storedMatter.plus(howMuch.coerceAtMost(maxInput)).coerceAtMost(capacity) val diff = new.minus(storedMatter) @@ -68,11 +64,7 @@ class MatterCapacitorItem : Item { return diff } - override fun extractMatterOuter(howMuch: Decimal, simulate: Boolean): Decimal { - return extractMatterInner(howMuch, simulate) - } - - override fun extractMatterInner(howMuch: Decimal, simulate: Boolean): Decimal { + override fun extractMatter(howMuch: Decimal, simulate: Boolean): Decimal { if (isCreative) return howMuch val new = storedMatter.minus(howMuch.coerceAtMost(maxOutput)).moreThanZero() val diff = storedMatter.minus(new) From 75211f068ce18be43ecf1bb87e2db75a808c8463 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 14 Jan 2023 11:59:41 +0700 Subject: [PATCH 0042/1199] Rename IMatterHandler to IMatterStorage --- .../mc/otm/capability/MatteryCapability.java | 6 +++--- .../entity/matter/MatterBottlerBlockEntity.kt | 10 +++++----- .../matter/MatterCapacitorBankBlockEntity.kt | 6 +++--- .../entity/matter/MatterDecomposerBlockEntity.kt | 8 ++++---- .../entity/matter/MatterRecyclerBlockEntity.kt | 8 ++++---- .../entity/matter/MatterReplicatorBlockEntity.kt | 2 +- .../{IMatterHandler.kt => IMatterStorage.kt} | 15 +++++++++------ ...{MatterHandlerImpl.kt => MatterStorageImpl.kt} | 8 ++++---- .../mc/otm/graph/matter/IMatterGraphNode.kt | 2 +- .../mc/otm/item/MatterCapacitorItem.kt | 4 ++-- .../mc/otm/menu/widget/LevelGaugeWidget.kt | 4 ++-- 11 files changed, 38 insertions(+), 35 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/{IMatterHandler.kt => IMatterStorage.kt} (89%) rename src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/{MatterHandlerImpl.kt => MatterStorageImpl.kt} (94%) diff --git a/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java b/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java index dc0966b1f..958ece5b3 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java +++ b/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java @@ -5,7 +5,7 @@ import net.minecraftforge.common.capabilities.*; import org.jetbrains.annotations.NotNull; import ru.dbotthepony.mc.otm.capability.drive.IMatteryDrive; import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage; -import ru.dbotthepony.mc.otm.capability.matter.IMatterHandler; +import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage; import ru.dbotthepony.mc.otm.capability.matter.IReplicationTaskProvider; import ru.dbotthepony.mc.otm.capability.matter.IPatternStorage; import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode; @@ -26,7 +26,7 @@ public class MatteryCapability { @Nonnull @NotNull - public static final Capability MATTER = CapabilityManager.get(new CapabilityToken<>() {}); + public static final Capability MATTER = CapabilityManager.get(new CapabilityToken<>() {}); @Nonnull @NotNull @@ -63,7 +63,7 @@ public class MatteryCapability { public static void register(RegisterCapabilitiesEvent event) { event.register(IMatteryEnergyStorage.class); event.register(MatteryPlayerCapability.class); - event.register(IMatterHandler.class); + event.register(IMatterStorage.class); event.register(IMatterGraphNode.class); event.register(IPatternStorage.class); event.register(IReplicationTaskProvider.class); diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index d2cb29fd7..430890983 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -26,8 +26,8 @@ import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage -import ru.dbotthepony.mc.otm.capability.matter.IMatterHandler -import ru.dbotthepony.mc.otm.capability.matter.MatterHandlerImpl +import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage +import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainerHooks import ru.dbotthepony.mc.otm.graph.Graph6Node @@ -114,7 +114,7 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } }) - val matter: MatterHandlerImpl = object : MatterHandlerImpl(this::setChangedLight, FlowDirection.BI_DIRECTIONAL, ::CAPACITY) { + val matter: MatterStorageImpl = object : MatterStorageImpl(this::setChangedLight, FlowDirection.BI_DIRECTIONAL, ::CAPACITY) { override val matterDirection: FlowDirection get() { return if (this@MatterBottlerBlockEntity.isBottling) FlowDirection.INPUT else FlowDirection.OUTPUT } @@ -123,7 +123,7 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : private var initialCapacity: Decimal? = null private var lastWorkStack: ItemStack? = null - override fun getMatterHandler(): IMatterHandler { + override fun getMatterHandler(): IMatterStorage { return matter } @@ -230,7 +230,7 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } var work_stack: ItemStack? = null - var capability: IMatterHandler? = null + var capability: IMatterStorage? = null val align = if (isBottling) 0 else 3 var work_slot = -1 val unexpectedDirection = if (isBottling) FlowDirection.OUTPUT else FlowDirection.INPUT diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt index 9d2994ce9..0027a851f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt @@ -21,7 +21,7 @@ import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.capability.matter.IMatterHandler +import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.core.Decimal import ru.dbotthepony.mc.otm.core.ifPresentK @@ -33,7 +33,7 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.core.map import ru.dbotthepony.mc.otm.core.set -class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryBlockEntity(MBlockEntities.MATTER_CAPACITOR_BANK, p_155229_, p_155230_), IMatterGraphNode, IMatterHandler, IDroppableContainer { +class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryBlockEntity(MBlockEntities.MATTER_CAPACITOR_BANK, p_155229_, p_155230_), IMatterGraphNode, IMatterStorage, IDroppableContainer { var gaugeLevel by synchronizer.float() private set @@ -211,7 +211,7 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) MatterNetworkGraph.discoverFull(this, matterNode) } - override fun getMatterHandler(): IMatterHandler { + override fun getMatterHandler(): IMatterStorage { return this } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index d622b51bc..c0cd54136 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -24,8 +24,8 @@ import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage -import ru.dbotthepony.mc.otm.capability.matter.IMatterHandler -import ru.dbotthepony.mc.otm.capability.matter.MatterHandlerImpl +import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage +import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainerHooks import ru.dbotthepony.mc.otm.core.* @@ -128,7 +128,7 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) private var valid = true override val matterNode = Graph6Node(this) - val matter = MatterHandlerImpl(this::setChangedLight, FlowDirection.OUTPUT, ::CAPACITY) + val matter = MatterStorageImpl(this::setChangedLight, FlowDirection.OUTPUT, ::CAPACITY) private var resolverMatter = LazyOptional.of { matter } private var resolverNode = LazyOptional.of { this } @@ -242,7 +242,7 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) MatterNetworkGraph.discoverFull(this, matterNode) } - override fun getMatterHandler(): IMatterHandler { + override fun getMatterHandler(): IMatterStorage { return matter } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index a46221ec6..6d0f5bb13 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -24,8 +24,8 @@ import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage -import ru.dbotthepony.mc.otm.capability.matter.IMatterHandler -import ru.dbotthepony.mc.otm.capability.matter.MatterHandlerImpl +import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage +import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainerHooks import ru.dbotthepony.mc.otm.core.Decimal @@ -73,7 +73,7 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) } } - val matter = MatterHandlerImpl( + val matter = MatterStorageImpl( this::matterLevelUpdated, FlowDirection.OUTPUT, ::CAPACITY @@ -88,7 +88,7 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) private var valid = true override val energy = WorkerEnergyStorage(this::powerLevelUpdated, ENERGY_CONFIG) - override fun getMatterHandler(): IMatterHandler { + override fun getMatterHandler(): IMatterStorage { return matter } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index ec26eec2c..bd64d1820 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -103,7 +103,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : override val matterNode = Graph6Node(this) private val resolverNode = LazyOptional.of { this } - val matter = MatterHandlerImpl( + val matter = MatterStorageImpl( this::matterLevelUpdated, FlowDirection.INPUT, ::MATTER_CAPACITY diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterStorage.kt similarity index 89% rename from src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterHandler.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterStorage.kt index 6dd5334b5..ff4e0c345 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterStorage.kt @@ -8,7 +8,10 @@ import ru.dbotthepony.mc.otm.core.RGBAColor import ru.dbotthepony.mc.otm.core.orNull import kotlin.math.roundToInt -interface IMatterHandler { +/** + * Matter interface in Overdrive That Matters + */ +interface IMatterStorage { /** * If this is false, then [storedMatter] will throw [UnsupportedOperationException] when trying to set it */ @@ -81,17 +84,17 @@ interface IMatterHandler { val matterDirection: FlowDirection } -inline val IMatterHandler.canExtractMatter: Boolean +inline val IMatterStorage.canExtractMatter: Boolean get() = matterDirection.output -inline val IMatterHandler.canReceiveMatter: Boolean +inline val IMatterStorage.canReceiveMatter: Boolean get() = matterDirection.input -fun IMatterHandler.getBarWidth(): Int { +fun IMatterStorage.getBarWidth(): Int { return ((storedMatter / maxStoredMatter).toFloat().coerceAtLeast(0f).coerceAtMost(1f) * 13f).roundToInt() } -fun IMatterHandler.getBarColor(): Int { +fun IMatterStorage.getBarColor(): Int { return RGBAColor.LOW_MATTER.linearInterpolation((storedMatter / maxStoredMatter).toFloat(), RGBAColor.FULL_MATTER).toInt() } -val ICapabilityProvider.matter: IMatterHandler? get() = getCapability(MatteryCapability.MATTER).orNull() +val ICapabilityProvider.matter: IMatterStorage? get() = getCapability(MatteryCapability.MATTER).orNull() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterHandlerImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt similarity index 94% rename from src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterHandlerImpl.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt index f3baa9b2f..7bb3dcc36 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterHandlerImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt @@ -9,13 +9,13 @@ import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.core.Decimal import ru.dbotthepony.mc.otm.core.set -open class MatterHandlerImpl @JvmOverloads constructor( +open class MatterStorageImpl @JvmOverloads constructor( protected val listener: Runnable?, override val matterDirection: FlowDirection, protected val maxStoredMatterSupplier: () -> Decimal, protected val maxReceiveSupplier: () -> Decimal? = { null }, protected val maxExtractSupplier: () -> Decimal? = maxReceiveSupplier -) : IMatterHandler, INBTSerializable { +) : IMatterStorage, INBTSerializable { constructor( listener: Runnable?, direction: FlowDirection, @@ -44,7 +44,7 @@ open class MatterHandlerImpl @JvmOverloads constructor( override var storedMatter = Decimal.ZERO - private var handler = LazyOptional.of { this } + private var handler = LazyOptional.of { this } fun invalidate() { handler.invalidate() @@ -54,7 +54,7 @@ open class MatterHandlerImpl @JvmOverloads constructor( handler = LazyOptional.of { this } } - fun get(): LazyOptional { + fun get(): LazyOptional { return handler } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/IMatterGraphNode.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/IMatterGraphNode.kt index c1c995cfc..c64294c2c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/IMatterGraphNode.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/IMatterGraphNode.kt @@ -15,7 +15,7 @@ interface IMatterGraphListener { } interface IMatterGraphNode : IMatterGraphListener { - fun getMatterHandler(): IMatterHandler? = null + fun getMatterHandler(): IMatterStorage? = null fun getPatternHandler(): IPatternStorage? = null fun getTaskHandler(): IReplicationTaskProvider? = null diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt index a90a620df..4475dec6f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt @@ -26,8 +26,8 @@ import javax.annotation.ParametersAreNonnullByDefault @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault class MatterCapacitorItem : Item { - private inner class Matter(private val stack: ItemStack) : ICapabilityProvider, IMatterHandler { - private val resolver = LazyOptional.of { this } + private inner class Matter(private val stack: ItemStack) : ICapabilityProvider, IMatterStorage { + private val resolver = LazyOptional.of { this } override fun getCapability(cap: Capability, side: Direction?): LazyOptional { return if (cap === MatteryCapability.MATTER) resolver.cast() else LazyOptional.empty() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/LevelGaugeWidget.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/LevelGaugeWidget.kt index e2bbb79e3..7c8b51a89 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/LevelGaugeWidget.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/LevelGaugeWidget.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.mc.otm.menu.widget import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage -import ru.dbotthepony.mc.otm.capability.matter.IMatterHandler +import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage import ru.dbotthepony.mc.otm.capability.matter.IPatternStorage import ru.dbotthepony.mc.otm.core.Decimal import ru.dbotthepony.mc.otm.menu.MatteryMenu @@ -28,7 +28,7 @@ class LevelGaugeWidget(menu: MatteryMenu) : AbstractWidget(menu) { constructor( menu: MatteryMenu, - matter: IMatterHandler? + matter: IMatterStorage? ) : this(menu) { if (matter == null) return From 9073ae1b08d787c5d6cd3ca5d12a92fbfbbd5692 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 14 Jan 2023 13:02:25 +0700 Subject: [PATCH 0043/1199] Remove inner/outer variants from IMatteryEnergyStorage --- .../android/feature/EnderTeleporterFeature.kt | 6 +- .../otm/android/feature/ItemMagnetFeature.kt | 8 +- .../otm/android/feature/JumpBoostFeature.kt | 6 +- .../android/feature/NanobotsArmorFeature.kt | 8 +- .../feature/NanobotsRegenerationFeature.kt | 2 +- .../otm/android/feature/NightVisionFeature.kt | 8 +- .../otm/android/feature/ShockwaveFeature.kt | 8 +- .../block/entity/AndroidStationBlockEntity.kt | 2 +- .../block/entity/BatteryBankBlockEntity.kt | 8 +- .../block/entity/EnergyCounterBlockEntity.kt | 12 +- .../block/entity/EnergyServoBlockEntity.kt | 12 +- .../block/entity/MatteryPoweredBlockEntity.kt | 4 +- .../block/entity/storage/StorageInterfaces.kt | 2 - .../StoragePowerSupplierBlockEntity.kt | 3 +- .../ru/dbotthepony/mc/otm/capability/Ext.kt | 4 +- .../otm/capability/MatteryPlayerCapability.kt | 12 +- .../capability/energy/AndroidPowerSource.kt | 44 +--- .../energy/BlockEnergyStorageImpl.kt | 4 +- .../capability/energy/IEnergyStorageImpl.kt | 73 ++++++ .../energy/IMatteryEnergyStorage.kt | 224 +++++------------- .../energy/ItemEnergyStorageImpl.kt | 4 +- .../otm/capability/matter/IMatterStorage.kt | 10 +- .../mc/otm/compat/mekanism/Power.kt | 16 +- .../mc/otm/item/EnergySwordItem.kt | 14 +- .../mc/otm/item/QuantumBatteryItem.kt | 12 +- .../mc/otm/item/weapon/PlasmaRifleItem.kt | 4 +- .../mc/otm/item/weapon/PlasmaWeaponItem.kt | 12 +- .../mc/otm/storage/VirtualComponent.kt | 21 +- 28 files changed, 231 insertions(+), 312 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt index ddfc81482..546170a85 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt @@ -30,7 +30,7 @@ import ru.dbotthepony.mc.otm.ServerConfig import ru.dbotthepony.mc.otm.android.AndroidActiveFeature import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability -import ru.dbotthepony.mc.otm.capability.energy.extractEnergyInnerExact +import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.render.ResearchIcons @@ -64,7 +64,7 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv get() = ServerConfig.EnderTeleporter.COOLDOWN private fun canUse(): Boolean { - return !isOnCooldown && android.androidEnergy.extractEnergyInnerExact(ServerConfig.EnderTeleporter.ENERGY_COST, true).isPositive + return !isOnCooldown && android.androidEnergy.extractEnergyExact(ServerConfig.EnderTeleporter.ENERGY_COST, true) } private fun isValidGround(blockPos: BlockPos): Boolean { @@ -309,7 +309,7 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv putOnCooldown() lastTeleport = ply.server!!.tickCount - android.androidEnergy.extractEnergyInner(ServerConfig.EnderTeleporter.ENERGY_COST, false) + android.androidEnergy.extractEnergy(ServerConfig.EnderTeleporter.ENERGY_COST, false) ply.level.playSound(null, ply, SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 0.3f, 0.8f + ply.level.random.nextFloat() * 0.4f) ply.teleportTo(event.targetX, event.targetY, event.targetZ) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt index 8607776d1..af0d7921f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt @@ -13,7 +13,7 @@ import ru.dbotthepony.mc.otm.ServerConfig import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability -import ru.dbotthepony.mc.otm.capability.energy.extractEnergyInnerExact +import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.core.Vector @@ -73,7 +73,7 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable private val clientPredicate = Predicate { it is ItemEntity && (datatable[it] ?: SharedItemEntityData.EMPTY).let { !it.hasPickupDelay && (it.owner == null || it.owner != ply.uuid || it.lifespan - it.age <= 200) } } private fun doTick(server: Boolean) { - if (ply.isSpectator || server && !android.androidEnergy.extractEnergyInnerExact(ServerConfig.AndroidItemMagnet.POWER_DRAW, true).isPositive) { + if (ply.isSpectator || server && !android.androidEnergy.extractEnergyExact(ServerConfig.AndroidItemMagnet.POWER_DRAW, true)) { return } @@ -98,7 +98,7 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable if (data.position.distanceToSqr(ent.position) < 1.0) { data.ticksSinceActivity++ } else { - if (!android.androidEnergy.extractEnergyInnerExact(ServerConfig.AndroidItemMagnet.POWER_DRAW, false).isPositive) { + if (!android.androidEnergy.extractEnergyExact(ServerConfig.AndroidItemMagnet.POWER_DRAW, false)) { return } @@ -114,7 +114,7 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable override fun tickClient() { super.tickClient() - if (!ply.isSpectator && isActive && android.androidEnergy.extractEnergyInnerExact(ServerConfig.AndroidItemMagnet.POWER_DRAW, true).isPositive) { + if (!ply.isSpectator && isActive && android.androidEnergy.extractEnergyExact(ServerConfig.AndroidItemMagnet.POWER_DRAW, true)) { doTick(false) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt index 767e72d5f..b057ebfda 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt @@ -14,7 +14,7 @@ import ru.dbotthepony.mc.otm.ServerConfig import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability -import ru.dbotthepony.mc.otm.capability.energy.extractEnergyInnerExact +import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.core.Vector @@ -46,7 +46,7 @@ object TriggerJumpBoostPacket : MatteryPacket { val feature = mattery.getFeature(AndroidFeatures.JUMP_BOOST) as JumpBoostFeature? ?: return@enqueueWork - if (feature.isActive && feature.cooldown <= 4 && mattery.androidEnergy.extractEnergyInnerExact(ServerConfig.AndroidJumpBoost.ENERGY_COST, false).isPositive) { + if (feature.isActive && feature.cooldown <= 4 && mattery.androidEnergy.extractEnergyExact(ServerConfig.AndroidJumpBoost.ENERGY_COST, false)) { feature.putOnCooldown() context.sender?.let { @@ -90,7 +90,7 @@ class JumpBoostFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF val old = lastGround lastGround = ply.isOnGround - if (isActive && cooldown <= 0 && old != lastGround && !lastGround && isJumping && isShifting && ply.xRot <= ClientConfig.JUMP_BOOST_LOOK_ANGLE && android.androidEnergy.extractEnergyInnerExact(ServerConfig.AndroidJumpBoost.ENERGY_COST, true).isPositive) { + if (isActive && cooldown <= 0 && old != lastGround && !lastGround && isJumping && isShifting && ply.xRot <= ClientConfig.JUMP_BOOST_LOOK_ANGLE && android.androidEnergy.extractEnergyExact(ServerConfig.AndroidJumpBoost.ENERGY_COST, true)) { ply.deltaMovement += Vector(0.0, ServerConfig.AndroidJumpBoost.POWER * (level + 1) / 20.0, 0.0) putOnCooldown() MatteryPlayerNetworkChannel.sendToServer(TriggerJumpBoostPacket) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt index f6449b8b2..364b7912b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt @@ -8,7 +8,7 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.android.AndroidFeature import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability -import ru.dbotthepony.mc.otm.capability.energy.extractEnergyInnerExact +import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.core.Decimal import ru.dbotthepony.mc.otm.registry.AndroidFeatures import ru.dbotthepony.mc.otm.registry.StatNames @@ -28,12 +28,12 @@ class NanobotsArmorFeature(android: MatteryPlayerCapability) : AndroidFeature(An private var layers = 0 override fun tickServer() { - if (layers < strength + 1 && android.androidEnergy.extractEnergyInnerExact(ENERGY_PER_LAYER, true).isPositive) { + if (layers < strength + 1 && android.androidEnergy.extractEnergyExact(ENERGY_PER_LAYER, true)) { ticksPassed++ if (ticksPassed >= TICKS[speed]) { layers++ - android.androidEnergy.extractEnergyInner(ENERGY_PER_LAYER, false) + android.androidEnergy.extractEnergy(ENERGY_PER_LAYER, false) } } else { ticksPassed = 0 @@ -48,7 +48,7 @@ class NanobotsArmorFeature(android: MatteryPlayerCapability) : AndroidFeature(An if (absorbed > 0.1f) { val powerRequired = ENERGY_PER_HITPOINT * absorbed - val powerExtracted = android.androidEnergy.extractEnergyInner(powerRequired, false) + val powerExtracted = android.androidEnergy.extractEnergy(powerRequired, false) val realAbsorbed = (powerExtracted / ENERGY_PER_HITPOINT).toFloat() val ply = ply diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsRegenerationFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsRegenerationFeature.kt index e2e2b25c1..cfb8d3545 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsRegenerationFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsRegenerationFeature.kt @@ -24,7 +24,7 @@ class NanobotsRegenerationFeature(android: MatteryPlayerCapability) : AndroidFea if (ticksPassed > waitTime) { val missingHealth = (ply.maxHealth - ply.health).coerceAtMost(2f) val power = ServerConfig.NanobotsRegeneration.ENERGY_PER_HITPOINT * missingHealth - val extracted = android.androidEnergy.extractEnergyInner(power, false) + val extracted = android.androidEnergy.extractEnergy(power, false) if (extracted.isPositive) { healTicks = (healTicks + 1).coerceAtMost(level) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt index e41db1702..3f0e2d4f0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt @@ -6,7 +6,7 @@ import net.minecraft.world.effect.MobEffects import ru.dbotthepony.mc.otm.ServerConfig import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability -import ru.dbotthepony.mc.otm.capability.energy.extractEnergyInnerExact +import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.registry.AndroidFeatures @@ -18,12 +18,8 @@ class NightVisionFeature(android: MatteryPlayerCapability) : AndroidSwitchableFe if (isActive) { val effect = android.ply.activeEffectsMap[MobEffects.NIGHT_VISION] - if ((effect == null || effect.duration < 220) && (ply.isSpectator || android.androidEnergy.extractEnergyInnerExact(ServerConfig.NIGHT_VISION_POWER_DRAW, true).isPositive)) { + if ((effect == null || effect.duration < 220) && (ply.isSpectator || android.androidEnergy.extractEnergyExact(ServerConfig.NIGHT_VISION_POWER_DRAW, false))) { android.ply.addEffect(MobEffectInstance(MobEffects.NIGHT_VISION, 220, 0, false, false)) - - if (!ply.isSpectator) { - android.androidEnergy.extractEnergyInner(ServerConfig.NIGHT_VISION_POWER_DRAW, false) - } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt index 4b83bc39f..5e6431028 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt @@ -17,7 +17,7 @@ import ru.dbotthepony.mc.otm.ServerConfig import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability -import ru.dbotthepony.mc.otm.capability.energy.extractEnergyInnerExact +import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.core.Vector import ru.dbotthepony.mc.otm.core.formatPower @@ -83,7 +83,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF isActive && ply.isShiftKeyDown && !isOnCooldown && - android.androidEnergy.extractEnergyInnerExact(ServerConfig.Shockwave.ENERGY_COST, true).isPositive && + android.androidEnergy.extractEnergyExact(ServerConfig.Shockwave.ENERGY_COST, true) && ply.deltaMovement.y < -0.01 && creativeFlightTicks == 0 ) { @@ -94,7 +94,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF } fun shockwave() { - if (ply.isSpectator || isOnCooldown || !android.androidEnergy.extractEnergyInnerExact(ServerConfig.Shockwave.ENERGY_COST, false).isPositive) { + if (ply.isSpectator || isOnCooldown || !android.androidEnergy.extractEnergyExact(ServerConfig.Shockwave.ENERGY_COST, false)) { return } @@ -199,7 +199,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF !ply.isSpectator && isActive && !isOnCooldown && - android.androidEnergy.extractEnergyInnerExact(ServerConfig.Shockwave.ENERGY_COST, true).isPositive && + android.androidEnergy.extractEnergyExact(ServerConfig.Shockwave.ENERGY_COST, true) && creativeFlightTicks == 0 ) { val old = wasMidair diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/AndroidStationBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/AndroidStationBlockEntity.kt index 49db8e737..6f1474119 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/AndroidStationBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/AndroidStationBlockEntity.kt @@ -88,7 +88,7 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val extract = energy.extractEnergyInner(missing, true) if (extract > Decimal.ZERO) { - val received = it.androidEnergy.receiveEnergyOuter(extract, false) + val received = it.androidEnergy.receiveEnergy(extract, false) energy.extractEnergyInner(received, false) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BatteryBankBlockEntity.kt index 0a7aebe52..4d1439bec 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BatteryBankBlockEntity.kt @@ -78,7 +78,7 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte override fun canExtract() = mode != BankMode.RECEIVE override fun canReceive() = mode != BankMode.EXTRACT - override fun extractEnergyOuter(howMuch: Decimal, simulate: Boolean): Decimal { + override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { if (mode == BankMode.RECEIVE) return Decimal.ZERO @@ -157,18 +157,18 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte return summ } - override fun extractEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { + fun extractEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { return distributeEnergy(isReceiving = false, howMuch, simulate) } - override fun receiveEnergyOuter(howMuch: Decimal, simulate: Boolean): Decimal { + override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { if (mode == BankMode.EXTRACT) return Decimal.ZERO return receiveEnergyInner(howMuch, simulate) } - override fun receiveEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { + fun receiveEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { return distributeEnergy(isReceiving = true, howMuch, simulate) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt index 17d29a0dd..98f6e9488 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt @@ -127,11 +127,7 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat } private inner class EnergyCounterCap(val isInput: Boolean) : IMatteryEnergyStorage { - override fun extractEnergyOuter(howMuch: Decimal, simulate: Boolean): Decimal { - return extractEnergyInner(howMuch, simulate) - } - - override fun extractEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { + override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { if (isInput) return Decimal.ZERO @@ -159,11 +155,7 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat return Decimal.ZERO } - override fun receiveEnergyOuter(howMuch: Decimal, simulate: Boolean): Decimal { - return receiveEnergyInner(howMuch, simulate) - } - - override fun receiveEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { + override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { if (!isInput) return Decimal.ZERO diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyServoBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyServoBlockEntity.kt index b0f07a5e1..3c71756bf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyServoBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyServoBlockEntity.kt @@ -59,19 +59,11 @@ class EnergyServoBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte }) val energy = object : IMatteryEnergyStorage { - override fun extractEnergyOuter(howMuch: Decimal, simulate: Boolean): Decimal { - return extractEnergyInner(howMuch, simulate) - } - - override fun extractEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { + override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { return container[SLOT_DISCHARGE].energy?.extractEnergy(howMuch, simulate) ?: Decimal.ZERO } - override fun receiveEnergyOuter(howMuch: Decimal, simulate: Boolean): Decimal { - return receiveEnergyInner(howMuch, simulate) - } - - override fun receiveEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { + override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { return container[SLOT_CHARGE].energy?.receiveEnergy(howMuch, simulate) ?: Decimal.ZERO } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt index 51745fd3e..28745406e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt @@ -45,14 +45,14 @@ abstract class MatteryPoweredBlockEntity(p_155228_: BlockEntityType<*>, p_155229 return } - var demand = energy.receiveEnergyOuter(energy.missingPower, true) + var demand = energy.receiveEnergy(energy.missingPower, true) if (demand.isZero) return for (stack in batteryContainer) { if (!stack.isEmpty) { stack.getCapability(ForgeCapabilities.ENERGY).ifPresentK { if (it is IMatteryEnergyStorage) { - val diff = it.extractEnergyOuter(demand, false) + val diff = it.extractEnergy(demand, false) energy.receiveEnergyInner(diff, false) demand -= diff } else { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt index 7165519e9..a5627ce0d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt @@ -23,8 +23,6 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage -import ru.dbotthepony.mc.otm.capability.energy.extractStepInner -import ru.dbotthepony.mc.otm.capability.energy.extractStepInnerBi import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.graph.Graph6Node diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt index 4c5c08dd7..3b216607b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt @@ -18,7 +18,6 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage -import ru.dbotthepony.mc.otm.capability.energy.transferInner import ru.dbotthepony.mc.otm.core.Decimal import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode import ru.dbotthepony.mc.otm.graph.storage.StorageNetworkGraph @@ -92,7 +91,7 @@ class StoragePowerSupplierBlockEntity(blockPos: BlockPos, blockState: BlockState val available = energy.batteryLevel.coerceAtMost(ServerConfig.STORAGE_POWER_SUPPLIER.throughput) for (demanding in graph.powerDemandingNodes) { - val received = demanding.receiveEnergyOuter(available, true) + val received = demanding.receiveEnergy(available, true) if (received.isPositive) { demand += received diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt index 6a9ab1ff5..85558a9a4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt @@ -32,7 +32,7 @@ val ICapabilityProvider.matteryPlayer: MatteryPlayerCapability? get() = getCapab fun IEnergyStorage.receiveEnergy(amount: Decimal, simulate: Boolean): Decimal { if (this is IMatteryEnergyStorage) - return receiveEnergyOuter(amount, simulate) + return receiveEnergy(amount, simulate) if (!amount.isPositive) return Decimal.ZERO @@ -45,7 +45,7 @@ fun IEnergyStorage.receiveEnergy(amount: Decimal, simulate: Boolean): Decimal { fun IEnergyStorage.extractEnergy(amount: Decimal, simulate: Boolean): Decimal { if (this is IMatteryEnergyStorage) - return extractEnergyOuter(amount, simulate) + return extractEnergy(amount, simulate) if (!amount.isPositive) return Decimal.ZERO diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 54d07417f..79232b09a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -778,16 +778,16 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial if (!ply.isSpectator) { val stats = ply.foodData - while (stats.foodLevel < 18 && androidEnergy.extractEnergyInner(ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, true) >= ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT) { - androidEnergy.extractEnergyInner(ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false) + while (stats.foodLevel < 18 && androidEnergy.extractEnergy(ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, true) >= ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT) { + androidEnergy.extractEnergy(ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false) stats.foodLevel = stats.foodLevel + 1 } // "block" quick regeneration // also cause power to generate while in peaceful if (ServerConfig.REGENERATE_ENERGY) { - while (stats.foodLevel > 18 && androidEnergy.receiveEnergyInner(ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, true) >= ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT) { - androidEnergy.receiveEnergyInner(ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false) + while (stats.foodLevel > 18 && androidEnergy.receiveEnergy(ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, true) >= ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT) { + androidEnergy.receiveEnergy(ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false) stats.foodLevel = stats.foodLevel - 1 } } else if (ply.level.server?.worldData?.difficulty != Difficulty.PEACEFUL) { @@ -797,12 +797,12 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial val foodLevel = stats.foodLevel.toFloat() if (stats.saturationLevel < foodLevel) { - val extracted = androidEnergy.extractEnergyInner(ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * (foodLevel - stats.saturationLevel), false) + val extracted = androidEnergy.extractEnergy(ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * (foodLevel - stats.saturationLevel), false) stats.setSaturation(stats.saturationLevel + (extracted / ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT).toFloat()) } if (stats.exhaustionLevel > 0f) { - val extracted = androidEnergy.extractEnergyInner(ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * (stats.exhaustionLevel / 4f), false) + val extracted = androidEnergy.extractEnergy(ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * (stats.exhaustionLevel / 4f), false) stats.setExhaustion(stats.exhaustionLevel - (extracted / ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT).toFloat() * 4f) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt index c0f3be2a3..0f5a3fa24 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt @@ -51,47 +51,29 @@ class AndroidPowerSource( fun tick() { if (!item.isEmpty && battery < maxBattery) { item.getCapability(ForgeCapabilities.ENERGY).ifPresentK { - if (it is IMatteryEnergyStorage) { - battery += it.extractEnergyInner(maxBattery - battery, false) - } else { - battery += it.extractEnergy(maxBattery - battery, false) - } + battery += it.extractEnergy(maxBattery - battery, false) } } } - override fun receiveEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { - return receiveEnergyOuter(howMuch, simulate) - } - - override fun extractEnergyOuter(howMuch: Decimal, simulate: Boolean): Decimal { - return Decimal.ZERO - } - - override fun extractEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { + override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { @Suppress("name_shadowing") var howMuch = howMuch var drained = Decimal.ZERO if (!item.isEmpty) { item.getCapability(ForgeCapabilities.ENERGY).ifPresentK { - if (it is IMatteryEnergyStorage) { - val extracted = it.extractEnergyOuter(howMuch, simulate) - drained += extracted - howMuch -= extracted - } else { - val extracted = it.extractEnergy(howMuch, simulate) - drained += extracted - howMuch -= extracted - } - } + val extracted = it.extractEnergy(howMuch, simulate) + drained += extracted + howMuch -= extracted - if (howMuch.isZero) { - if (!simulate && ply is ServerPlayer) { - ply.awardStat(StatNames.POWER_CONSUMED, drained.toInt() * 10) - } + if (howMuch.isZero) { + if (!simulate && ply is ServerPlayer) { + ply.awardStat(StatNames.POWER_CONSUMED, drained.toInt() * 10) + } - return drained + return drained + } } } @@ -109,7 +91,7 @@ class AndroidPowerSource( return drained } - override fun receiveEnergyOuter(howMuch: Decimal, simulate: Boolean): Decimal { + override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { @Suppress("name_shadowing") var howMuch = howMuch var received = Decimal.ZERO @@ -117,7 +99,7 @@ class AndroidPowerSource( if (!item.isEmpty) { item.getCapability(ForgeCapabilities.ENERGY).ifPresentK { if (it is IMatteryEnergyStorage) { - val extracted = it.receiveEnergyOuter(howMuch, simulate) + val extracted = it.receiveEnergy(howMuch, simulate) received += extracted howMuch -= extracted } else { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt index 0982a076b..3f66c38b7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt @@ -77,14 +77,14 @@ sealed class BlockEnergyStorageImpl( } } - override fun extractEnergyOuter(howMuch: Decimal, simulate: Boolean): Decimal { + override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { if (direction == FlowDirection.INPUT) return Decimal.ZERO return extractEnergyInner(howMuch, simulate) } - override fun receiveEnergyOuter(howMuch: Decimal, simulate: Boolean): Decimal { + override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { if (direction == FlowDirection.OUTPUT) return Decimal.ZERO diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt index 677a3f66f..56f0063c6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt @@ -7,11 +7,82 @@ import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.core.Decimal import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.formatPower +import java.math.BigInteger sealed interface IEnergyStorageImpl { val maxInput: Decimal? val maxOutput: Decimal? val direction: FlowDirection + + fun extractEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal + fun receiveEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal + + fun extractStepInner(base: Decimal, multiplier: Int, simulate: Boolean): Int { + return (extractEnergyInner(base * multiplier, simulate) / base).toInt() + } + + fun extractStepInnerBi(base: Decimal, multiplier: Int, simulate: Boolean): BigInteger { + return (extractEnergyInner(base * multiplier, simulate) / base).whole + } + + fun extractStepInner(base: Decimal, multiplier: BigInteger, simulate: Boolean): Int { + return (extractEnergyInner(base * multiplier, simulate) / base).toInt() + } + + fun extractStepInnerBi(base: Decimal, multiplier: BigInteger, simulate: Boolean): BigInteger { + return (extractEnergyInner(base * multiplier, simulate) / base).whole + } + + fun transferInner(other: IMatteryEnergyStorage, amount: Decimal, simulate: Boolean): Decimal { + if (!amount.isPositive) + return Decimal.ZERO + + val extracted = extractEnergyInner(amount, true) + val received = other.receiveEnergy(extracted, simulate) + + if (!simulate) + extractEnergyInner(received, false) + + return received + } + + /** + * All or nothing + * + * @return energy accepted + */ + fun extractEnergyInnerExact(howMuch: Decimal, simulate: Boolean): Decimal { + val extracted = extractEnergyInner(howMuch, true) + + if (extracted != howMuch) { + return Decimal.ZERO + } + + if (!simulate) { + extractEnergyInner(howMuch, false) + } + + return extracted + } + + /** + * All or nothing + * + * @return energy accepted + */ + fun receiveEnergyInnerExact(howMuch: Decimal, simulate: Boolean): Decimal { + val extracted = receiveEnergyInner(howMuch, true) + + if (extracted != howMuch) { + return Decimal.ZERO + } + + if (!simulate) { + receiveEnergyInner(howMuch, false) + } + + return extracted + } } internal fun batteryLevel(it: IEnergyStorage, tooltips: MutableList) { @@ -97,6 +168,8 @@ internal fun batteryLevel(it: IMatteryEnergyStorage, tooltips: MutableList {} } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt index a6eee5238..be89b76b3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt @@ -6,41 +6,23 @@ import ru.dbotthepony.mc.otm.core.RGBAColor import java.math.BigInteger import kotlin.math.roundToInt -// IEnergyStorage for direct compat with Forge Energy +/** + * Energy interface in Overdrive That Matters, which is backward compatible with [IEnergyStorage] + */ interface IMatteryEnergyStorage : IEnergyStorage { /** * Energy extraction by external interacts * * @return energy extracted */ - fun extractEnergyOuter(howMuch: Decimal, simulate: Boolean): Decimal - - /** - * Energy extraction by internal processes - * - * Nothing stops you from calling this directly, not on yours capability, - * but you really should think before doing this on not own capability. - * - * @return energy extracted - */ - fun extractEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal + fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal /** * Energy insertion by external interacts * * @return energy accepted */ - fun receiveEnergyOuter(howMuch: Decimal, simulate: Boolean): Decimal - - /** - * Energy insertion by internal processes - * - * Nothing stops you from calling this directly, not on yours capability, - * but you really should think before doing this on not own capability. - * - * @return energy accepted - */ - fun receiveEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal + fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal /** * If this is false, then [batteryLevel] will throw [UnsupportedOperationException] when trying to set it @@ -48,13 +30,25 @@ interface IMatteryEnergyStorage : IEnergyStorage { val canSetBatteryLevel: Boolean get() = true /** + * How much energy (estimated) is stored in this energy storage. Why estimated? Because some objects can be bottomless. + * * Implementations are free to throw [UnsupportedOperationException] if setting battery level is not supported * due to technical complications (in this case, [canSetBatteryLevel] MUST be false) * * @throws [UnsupportedOperationException] */ var batteryLevel: Decimal + + /** + * How much energy (estimated) can this energy storage hold. Why estimated? Because some objects can be bottomless. + */ val maxBatteryLevel: Decimal + + /** + * How much energy (estimated) is missing in this energy storage. Why estimated? Because some objects can be bottomless. + * + * Use this to determine whenever you need an estimate on how much energy this storage can accept, **and do not implement [maxBatteryLevel] - [batteryLevel] logic by yourself**. + */ val missingPower: Decimal get() = (maxBatteryLevel - batteryLevel).moreThanZero() @@ -64,7 +58,7 @@ interface IMatteryEnergyStorage : IEnergyStorage { * @throws [UnsupportedOperationException] * @see batteryLevel */ - fun emptyBattery() { + fun drainBattery() { batteryLevel = Decimal.ZERO } @@ -78,24 +72,26 @@ interface IMatteryEnergyStorage : IEnergyStorage { batteryLevel = maxBatteryLevel } + // -------- Forge Energy stuff + override fun receiveEnergy(maxReceive: Int, simulate: Boolean): Int { - val received = receiveEnergyOuter(maxReceive, true).toInt() + val received = receiveEnergy(Decimal(maxReceive), true).toInt() // Receiving only a fraction if (received == 0) return 0 - return receiveEnergyOuter(Decimal(received), simulate).toInt() + return receiveEnergy(Decimal(received), simulate).toInt() } override fun extractEnergy(maxReceive: Int, simulate: Boolean): Int { - val extracted = extractEnergyOuter(maxReceive, true).toInt() + val extracted = extractEnergy(Decimal(maxReceive), true).toInt() // Extracting only a fraction if (extracted == 0) return 0 - return extractEnergyOuter(Decimal(extracted), simulate).toInt() + return extractEnergy(Decimal(extracted), simulate).toInt() } override fun getEnergyStored(): Int { @@ -107,172 +103,82 @@ interface IMatteryEnergyStorage : IEnergyStorage { } override fun canExtract(): Boolean { - return extractEnergyOuter(Decimal.ONE, true) > Decimal.ZERO + return extractEnergy(Decimal.ONE, true) > Decimal.ZERO } override fun canReceive(): Boolean { - return receiveEnergyOuter(Decimal.ONE, true) > Decimal.ZERO + return receiveEnergy(Decimal.ONE, true) > Decimal.ZERO } } -fun IMatteryEnergyStorage.receiveEnergyOuterExact(howMuch: Decimal, simulate: Boolean): Decimal { - val extracted = receiveEnergyOuter(howMuch, true) +fun IMatteryEnergyStorage.extractEnergyExact(howMuch: Decimal, simulate: Boolean): Boolean { + if (extractEnergy(howMuch, true) == howMuch) { + if (!simulate) { + return extractEnergy(howMuch, false) == howMuch + } - if (extracted != howMuch) { - return Decimal.ZERO + return true } - if (!simulate) { - receiveEnergyOuter(howMuch, false) + return false +} + +fun IMatteryEnergyStorage.receiveEnergyExact(howMuch: Decimal, simulate: Boolean): Boolean { + if (receiveEnergy(howMuch, true) == howMuch) { + if (!simulate) { + return receiveEnergy(howMuch, false) == howMuch + } + + return true } - return extracted -} -/** - * All or nothing - * - * @return energy extracted - */ -fun IMatteryEnergyStorage.extractEnergyOuterExact(howMuch: Decimal, simulate: Boolean): Decimal { - val extracted = extractEnergyOuter(howMuch, true) - - if (extracted != howMuch) { - return Decimal.ZERO - } - - if (!simulate) { - extractEnergyOuter(howMuch, false) - } - - return extracted + return false } -/** - * All or nothing - * - * @return energy accepted - */ -fun IMatteryEnergyStorage.receiveEnergyInnerExact(howMuch: Decimal, simulate: Boolean): Decimal { - val extracted = receiveEnergyInner(howMuch, true) +fun IMatteryEnergyStorage.extractEnergyExact(howMuch: Decimal, times: Int, simulate: Boolean): Int { + if (times == 0) + return 0 - if (extracted != howMuch) { - return Decimal.ZERO - } - - if (!simulate) { - receiveEnergyInner(howMuch, false) - } - - return extracted + require(times >= 0) { "times $times >= 0" } + require(howMuch >= Decimal.ZERO) { "howMuch $howMuch >= 0" } + return (extractEnergy(howMuch * times, simulate) / times).toInt() } -/** - * All or nothing - * - * @return energy extracted - */ -fun IMatteryEnergyStorage.extractEnergyInnerExact(howMuch: Decimal, simulate: Boolean): Decimal { - val extracted = extractEnergyInner(howMuch, true) - - if (extracted != howMuch) { - return Decimal.ZERO - } - - if (!simulate) { - extractEnergyInner(howMuch, false) - } - - return extracted +fun IMatteryEnergyStorage.extractEnergy(howMuch: Long, simulate: Boolean): Decimal { + return extractEnergy(Decimal(howMuch), simulate) } -fun IMatteryEnergyStorage.extractEnergyOuter(howMuch: Long, simulate: Boolean): Decimal { - return extractEnergyOuter(Decimal(howMuch), simulate) +fun IMatteryEnergyStorage.receiveEnergy(howMuch: Long, simulate: Boolean): Decimal { + return receiveEnergy(Decimal(howMuch), simulate) } -fun IMatteryEnergyStorage.extractEnergyOuter(howMuch: Int, simulate: Boolean): Decimal { - return extractEnergyOuter(Decimal(howMuch), simulate) -} - -fun IMatteryEnergyStorage.receiveEnergyOuter(howMuch: Long, simulate: Boolean): Decimal { - return receiveEnergyOuter(Decimal(howMuch), simulate) -} - -fun IMatteryEnergyStorage.receiveEnergyOuter(howMuch: Int, simulate: Boolean): Decimal { - return receiveEnergyOuter(Decimal(howMuch), simulate) -} - -fun IMatteryEnergyStorage.extractEnergyInner(howMuch: Long, simulate: Boolean): Decimal { - return extractEnergyInner(Decimal(howMuch), simulate) -} - -fun IMatteryEnergyStorage.extractEnergyInner(howMuch: Int, simulate: Boolean): Decimal { - return extractEnergyInner(Decimal(howMuch), simulate) -} - -fun IMatteryEnergyStorage.receiveEnergyInner(howMuch: Long, simulate: Boolean): Decimal { - return receiveEnergyInner(Decimal(howMuch), simulate) -} - -fun IMatteryEnergyStorage.receiveEnergyInner(howMuch: Int, simulate: Boolean): Decimal { - return receiveEnergyInner(Decimal(howMuch), simulate) -} - -fun IMatteryEnergyStorage.transferInner(other: IMatteryEnergyStorage, amount: Decimal, simulate: Boolean): Decimal { +fun IMatteryEnergyStorage.transfer(other: IMatteryEnergyStorage, amount: Decimal, simulate: Boolean): Decimal { if (!amount.isPositive) return Decimal.ZERO - val extracted = extractEnergyInner(amount, true) - val received = other.receiveEnergyOuter(extracted, simulate) + val extracted = extractEnergy(amount, true) + val received = other.receiveEnergy(extracted, simulate) if (!simulate) - extractEnergyInner(received, false) + extractEnergy(received, false) return received } -fun IMatteryEnergyStorage.transferOuter(other: IMatteryEnergyStorage, amount: Decimal, simulate: Boolean): Decimal { - if (!amount.isPositive) - return Decimal.ZERO - - val extracted = extractEnergyOuter(amount, true) - val received = other.receiveEnergyOuter(extracted, simulate) - - if (!simulate) - extractEnergyInner(received, false) - - return received -} - -fun IMatteryEnergyStorage.extractStepInner(base: Decimal, multiplier: Int, simulate: Boolean): Int { - return (extractEnergyInner(base * multiplier, simulate) / base).toInt() -} - -fun IMatteryEnergyStorage.extractStepOuter(base: Decimal, multiplier: Int, simulate: Boolean): Int { - return (extractEnergyOuter(base * multiplier, simulate) / base).toInt() -} - -fun IMatteryEnergyStorage.extractStepInnerBi(base: Decimal, multiplier: Int, simulate: Boolean): BigInteger { - return (extractEnergyInner(base * multiplier, simulate) / base).whole -} - -fun IMatteryEnergyStorage.extractStepOuterBi(base: Decimal, multiplier: Int, simulate: Boolean): BigInteger { - return (extractEnergyOuter(base * multiplier, simulate) / base).whole -} - -fun IMatteryEnergyStorage.extractStepInner(base: Decimal, multiplier: BigInteger, simulate: Boolean): Int { - return (extractEnergyInner(base * multiplier, simulate) / base).toInt() -} - fun IMatteryEnergyStorage.extractStepOuter(base: Decimal, multiplier: BigInteger, simulate: Boolean): Int { - return (extractEnergyOuter(base * multiplier, simulate) / base).toInt() + return (extractEnergy(base * multiplier, simulate) / base).toInt() } -fun IMatteryEnergyStorage.extractStepInnerBi(base: Decimal, multiplier: BigInteger, simulate: Boolean): BigInteger { - return (extractEnergyInner(base * multiplier, simulate) / base).whole +fun IMatteryEnergyStorage.extractStepOuter(base: Decimal, multiplier: Int, simulate: Boolean): Int { + return (extractEnergy(base * multiplier, simulate) / base).toInt() +} + +fun IMatteryEnergyStorage.extractStepOuterBi(base: Decimal, multiplier: Int, simulate: Boolean): BigInteger { + return (extractEnergy(base * multiplier, simulate) / base).whole } fun IMatteryEnergyStorage.extractStepOuterBi(base: Decimal, multiplier: BigInteger, simulate: Boolean): BigInteger { - return (extractEnergyOuter(base * multiplier, simulate) / base).whole + return (extractEnergy(base * multiplier, simulate) / base).whole } fun IMatteryEnergyStorage.getBarWidth(): Int { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt index 8e9690ba9..f9440b14b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt @@ -55,14 +55,14 @@ sealed class ItemEnergyStorageImpl( itemStack.tagNotNull[ENERGY_KEY] = value.serializeNBT() } - override fun extractEnergyOuter(howMuch: Decimal, simulate: Boolean): Decimal { + override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { if (direction == FlowDirection.INPUT) return Decimal.ZERO return extractEnergyInner(howMuch, simulate) } - override fun receiveEnergyOuter(howMuch: Decimal, simulate: Boolean): Decimal { + override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { if (direction == FlowDirection.OUTPUT) return Decimal.ZERO diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterStorage.kt index ff4e0c345..ab0af90b0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterStorage.kt @@ -18,7 +18,7 @@ interface IMatterStorage { val canSetMatterLevel: Boolean get() = true /** - * How much matter (estimated) is stored in this object. Why estimated? Because some objects can be bottomless. + * How much matter (estimated) is stored in this matter storage. Why estimated? Because some objects can be bottomless. * * Implementations are free to throw [UnsupportedOperationException] if setting battery level is not supported * due to technical complications (in this case, [canSetMatterLevel] MUST be false) @@ -30,7 +30,7 @@ interface IMatterStorage { var storedMatter: Decimal /** - * How much matter (estimated) can this object hold. Why estimated? Because some objects can be bottomless. + * How much matter (estimated) can this matter storage hold. Why estimated? Because some objects can be bottomless. * * **DO NOT use this to determine "how much stuff is missing", use [missingMatter] instead!** */ @@ -64,16 +64,16 @@ interface IMatterStorage { fun receiveMatter(howMuch: Decimal, simulate: Boolean): Decimal /** - * Extract matter from this object + * Extract matter from this matter storage * * @return matter extracted */ fun extractMatter(howMuch: Decimal, simulate: Boolean): Decimal /** - * How much matter (estimated) is missing in this object. Why estimated? Because some objects can be bottomless. + * How much matter (estimated) is missing in this matter storage. Why estimated? Because some objects can be bottomless. * - * Use this to determine whenever you need an estimate on how much matter this object can accept, **and do not implement [maxStoredMatter] - [storedMatter] logic by yourself**. + * Use this to determine whenever you need an estimate on how much matter this storage can accept, **and do not implement [maxStoredMatter] - [storedMatter] logic by yourself**. */ val missingMatter: Decimal get() = maxStoredMatter.minus(storedMatter).moreThanZero() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt index 127c65672..42dacc61d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt @@ -72,7 +72,7 @@ private val mtj2Mekanism by DoubleLazy lazy@{ class Mekanism2MatteryEnergyWrapper(private val power: IStrictEnergyHandler, private val forgePower: IEnergyStorage? = null) : IMatteryEnergyStorage { - override fun extractEnergyOuter(howMuch: Decimal, simulate: Boolean): Decimal { + override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { val action = when (simulate) { true -> Action.SIMULATE false -> Action.EXECUTE @@ -81,11 +81,7 @@ class Mekanism2MatteryEnergyWrapper(private val power: IStrictEnergyHandler, pri return power.extractEnergy((howMuch * mtj2Mekanism).toFloatingLong(), action).toDecimal() * mekanism2MtJ } - override fun extractEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { - return extractEnergyOuter(howMuch, simulate) - } - - override fun receiveEnergyOuter(howMuch: Decimal, simulate: Boolean): Decimal { + override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { val action = when (simulate) { true -> Action.SIMULATE false -> Action.EXECUTE @@ -94,10 +90,6 @@ class Mekanism2MatteryEnergyWrapper(private val power: IStrictEnergyHandler, pri return howMuch - power.insertEnergy((howMuch * mtj2Mekanism).toFloatingLong(), action).toDecimal() * mekanism2MtJ } - override fun receiveEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { - return receiveEnergyOuter(howMuch, simulate) - } - override val canSetBatteryLevel: Boolean get() = power.energyContainerCount == 1 @@ -177,11 +169,11 @@ class Mattery2MekanismEnergyWrapper(private val power: IMatteryEnergyStorage) : override fun insertEnergy(container: Int, howMuch: FloatingLong, action: Action): FloatingLong { val copy = howMuch.copy() - return copy.minusEqual((power.receiveEnergyOuter(howMuch.toDecimal() * mekanism2MtJ, action.simulate()) * mtj2Mekanism).toFloatingLong()) + return copy.minusEqual((power.receiveEnergy(howMuch.toDecimal() * mekanism2MtJ, action.simulate()) * mtj2Mekanism).toFloatingLong()) } override fun extractEnergy(container: Int, howMuch: FloatingLong, action: Action): FloatingLong { - return (power.extractEnergyOuter(howMuch.toDecimal() * mekanism2MtJ, action.simulate()) * mtj2Mekanism).toFloatingLong() + return (power.extractEnergy(howMuch.toDecimal() * mekanism2MtJ, action.simulate()) * mtj2Mekanism).toFloatingLong() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt index 6ac9775e5..eb07a3736 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt @@ -30,7 +30,7 @@ import net.minecraftforge.common.capabilities.ICapabilityProvider import ru.dbotthepony.mc.otm.capability.energy.EnergyConsumerItem import ru.dbotthepony.mc.otm.capability.energy.ItemEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.capability.energy.extractEnergyInnerExact +import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.capability.energy.getBarColor import ru.dbotthepony.mc.otm.capability.energy.getBarWidth import ru.dbotthepony.mc.otm.capability.matteryEnergy @@ -49,7 +49,7 @@ import ru.dbotthepony.mc.otm.core.WriteOnce * by coremod patch */ fun getSweepingDamageRatioHook(ply: LivingEntity): Float? { - if (ply.mainHandItem.item is EnergySwordItem && ply.mainHandItem.matteryEnergy?.extractEnergyInnerExact(EnergySwordItem.ENERGY_PER_SWING, true)?.isPositive == true) { + if (ply.mainHandItem.item is EnergySwordItem && ply.mainHandItem.matteryEnergy?.extractEnergyExact(EnergySwordItem.ENERGY_PER_SWING, true) == true) { return 1f } @@ -122,10 +122,10 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani } itemStack.getCapability(MatteryCapability.ENERGY).ifPresentK { - if (!it.extractEnergyInnerExact(ENERGY_PER_SWING, false).isZero) { + if (it.extractEnergyExact(ENERGY_PER_SWING, false)) { victim.matteryPlayer?.let { if (it.isAndroid) { - it.androidEnergy.extractEnergyInner(ENERGY_ZAP, false) + it.androidEnergy.extractEnergy(ENERGY_ZAP, false) victim.hurt(EMPDamageSource(attacker), 8f) } } @@ -175,11 +175,11 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani when (blockState.material) { Material.PLANT, Material.REPLACEABLE_PLANT, Material.VEGETABLE, Material.LEAVES -> - energy?.extractEnergyInnerExact(PLANT_POWER_COST, false) + energy?.extractEnergyExact(PLANT_POWER_COST, false) } if (blockState.`is`(Blocks.COBWEB)) { - energy?.extractEnergyInnerExact(COBWEB_POWER_COST, false) + energy?.extractEnergyExact(COBWEB_POWER_COST, false) } } @@ -208,7 +208,7 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani } override fun canPerformAction(stack: ItemStack, toolAction: ToolAction): Boolean { - if (stack.matteryEnergy?.extractEnergyInnerExact(ENERGY_PER_SWING, true)?.isPositive == true) { + if (stack.matteryEnergy?.extractEnergyExact(ENERGY_PER_SWING, true) == true) { return ToolActions.DEFAULT_SWORD_ACTIONS.contains(toolAction) } 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 45f3790cc..0edcffd73 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt @@ -90,11 +90,7 @@ class QuantumBatteryItem : Item { return LazyOptional.empty() } - override fun extractEnergyOuter(howMuch: Decimal, simulate: Boolean): Decimal { - return extractEnergyInner(howMuch, simulate) - } - - override fun extractEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { + override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { if (howMuch.isNegative) { return Decimal.ZERO } @@ -130,11 +126,7 @@ class QuantumBatteryItem : Item { return diff } - override fun receiveEnergyOuter(howMuch: Decimal, simulate: Boolean): Decimal { - return receiveEnergyInner(howMuch, simulate) - } - - override fun receiveEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { + override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { if (howMuch.isNegative) { return Decimal.ZERO } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaRifleItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaRifleItem.kt index 2773a1814..6ce5b81e0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaRifleItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaRifleItem.kt @@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.item.weapon import net.minecraft.sounds.SoundSource import net.minecraft.world.entity.player.Player import net.minecraft.world.item.ItemStack -import ru.dbotthepony.mc.otm.capability.energy.extractEnergyInnerExact +import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.Vector import ru.dbotthepony.mc.otm.entity.PlasmaProjectile @@ -56,7 +56,7 @@ class PlasmaRifleItem : PlasmaWeaponItem(PlasmaWeaponData } override fun canPrimaryFire(itemStack: ItemStack, player: Player, dt: PlasmaWeaponDataTable): Boolean { - return super.canPrimaryFire(itemStack, player, dt) && (player.abilities.instabuild || energyData(itemStack).extractEnergyInnerExact(ENERGY_PER_SHOT, true).isPositive) + return super.canPrimaryFire(itemStack, player, dt) && (player.abilities.instabuild || energyData(itemStack).extractEnergyExact(ENERGY_PER_SHOT, true)) } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt index d6ac137bb..765b62947 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt @@ -51,11 +51,11 @@ class PlasmaWeaponEnergy(val itemStack: ItemStack, private val innerCapacity: De battery = ItemStack.of(nbt["battery"] as CompoundTag) } - override fun extractEnergyOuter(howMuch: Decimal, simulate: Boolean): Decimal { + override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { return Decimal.ZERO } - override fun extractEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { + fun extractEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { if (!howMuch.isPositive) return Decimal.ZERO @@ -86,11 +86,7 @@ class PlasmaWeaponEnergy(val itemStack: ItemStack, private val innerCapacity: De return diff + totalExtracted } - override fun receiveEnergyOuter(howMuch: Decimal, simulate: Boolean): Decimal { - return receiveEnergyInner(howMuch, simulate) - } - - override fun receiveEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { + override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { if (!howMuch.isPositive) return Decimal.ZERO @@ -141,7 +137,7 @@ class PlasmaWeaponEnergy(val itemStack: ItemStack, private val innerCapacity: De return true } - override fun emptyBattery() { + override fun drainBattery() { innerBatteryLevel = Decimal.ZERO } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/VirtualComponent.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/VirtualComponent.kt index f30f7d283..2866da497 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/VirtualComponent.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/VirtualComponent.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.storage import it.unimi.dsi.fastutil.objects.ObjectArraySet import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.extractEnergy import ru.dbotthepony.mc.otm.core.isPositive import ru.dbotthepony.mc.otm.core.isZero import java.math.BigInteger @@ -285,7 +286,7 @@ open class PoweredComponent(open val parent: IStorageComponen override fun insertStack(stack: T, simulate: Boolean): T { val required = storageType.energyPerOperation * stack.count val energy = energyProvider.invoke() - val extracted = energy.extractEnergyInner(required, true) + val extracted = energy.extractEnergy(required, true) if (extracted.isZero) { return stack.copy() as T @@ -296,7 +297,7 @@ open class PoweredComponent(open val parent: IStorageComponen if (leftover.isEmpty) { if (!simulate) { - energy.extractEnergyInner(required, false) + energy.extractEnergy(required, false) } return leftover @@ -304,7 +305,7 @@ open class PoweredComponent(open val parent: IStorageComponen if (!simulate) { val requiredNew = storageType.energyPerOperation * (stack.count - leftover.count) - energy.extractEnergyInner(requiredNew, false) + energy.extractEnergy(requiredNew, false) } return leftover @@ -316,14 +317,14 @@ open class PoweredComponent(open val parent: IStorageComponen stack.count = (extracted / storageType.energyPerOperation).whole val diff = oldCount - stack.count val newRequired = storageType.energyPerOperation * stack.count - val newExtracted = energy.extractEnergyInner(newRequired, true) + val newExtracted = energy.extractEnergy(newRequired, true) if (newExtracted == newRequired) { val leftover = parent.insertStack(stack, simulate) if (leftover.isEmpty) { if (!simulate) { - energy.extractEnergyInner(newRequired, false) + energy.extractEnergy(newRequired, false) } leftover.count = diff @@ -332,7 +333,7 @@ open class PoweredComponent(open val parent: IStorageComponen if (!simulate) { val requiredNew = storageType.energyPerOperation * (stack.count - leftover.count) - energy.extractEnergyInner(requiredNew, false) + energy.extractEnergy(requiredNew, false) } leftover.count += diff @@ -347,7 +348,7 @@ open class PoweredComponent(open val parent: IStorageComponen override fun extractStack(id: UUID, amount: BigInteger, simulate: Boolean): T { val required = storageType.energyPerOperation * amount val energy = energyProvider.invoke() - val extracted = energy.extractEnergyInner(required, true) + val extracted = energy.extractEnergy(required, true) if (extracted.isZero) { return storageType.empty @@ -362,9 +363,9 @@ open class PoweredComponent(open val parent: IStorageComponen if (!simulate) { if (extractedStack.count == amount) { - energy.extractEnergyInner(required, false) + energy.extractEnergy(required, false) } else { - energy.extractEnergyInner(storageType.energyPerOperation * extractedStack.count, false) + energy.extractEnergy(storageType.energyPerOperation * extractedStack.count, false) } } @@ -380,7 +381,7 @@ open class PoweredComponent(open val parent: IStorageComponen } if (!simulate) { - energy.extractEnergyInner(storageType.energyPerOperation * extractedStack.count, false) + energy.extractEnergy(storageType.energyPerOperation * extractedStack.count, false) } return extractedStack From b9cb5db9ac080ad3bc5045bec5c29b2bc95f2f9e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 14 Jan 2023 14:22:15 +0700 Subject: [PATCH 0044/1199] Redo mattery energy storage --- .../block/entity/AndroidStationBlockEntity.kt | 12 +- .../block/entity/BatteryBankBlockEntity.kt | 34 +--- .../entity/ChemicalGeneratorBlockEntity.kt | 6 +- .../block/entity/EnergyCounterBlockEntity.kt | 19 +- .../block/entity/EnergyServoBlockEntity.kt | 7 + .../block/entity/MatteryPoweredBlockEntity.kt | 24 +-- .../block/entity/MatteryWorkerBlockEntity.kt | 4 +- .../entity/matter/MatterBottlerBlockEntity.kt | 12 +- .../matter/MatterCapacitorBankBlockEntity.kt | 2 +- .../entity/storage/StorageBusBlockEntity.kt | 8 +- .../block/entity/storage/StorageInterfaces.kt | 13 +- .../StoragePowerSupplierBlockEntity.kt | 5 +- .../ru/dbotthepony/mc/otm/capability/Ext.kt | 14 +- .../mc/otm/capability/FlowDirection.kt | 62 ++++++ .../capability/energy/AndroidPowerSource.kt | 4 + .../energy/BlockEnergyStorageImpl.kt | 26 +-- .../capability/energy/IEnergyStorageImpl.kt | 73 +------ .../energy/IMatteryEnergyStorage.kt | 191 +++++++++++++++--- .../energy/ItemEnergyStorageImpl.kt | 26 +-- .../otm/capability/matter/IMatterStorage.kt | 6 +- .../capability/matter/MatterStorageImpl.kt | 2 +- .../mc/otm/compat/mekanism/Power.kt | 19 +- .../mc/otm/graph/matter/MatterNetworkGraph.kt | 8 +- .../ru/dbotthepony/mc/otm/item/BatteryItem.kt | 8 +- .../mc/otm/item/MatterCapacitorItem.kt | 2 +- .../mc/otm/item/QuantumBatteryItem.kt | 11 +- .../mc/otm/item/weapon/PlasmaRifleItem.kt | 2 +- .../mc/otm/item/weapon/PlasmaWeaponItem.kt | 36 ++-- .../mc/otm/menu/AndroidStationMenu.kt | 4 +- .../ru/dbotthepony/mc/otm/menu/Slots.kt | 2 +- 30 files changed, 349 insertions(+), 293 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/AndroidStationBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/AndroidStationBlockEntity.kt index 6f1474119..5d0babbf2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/AndroidStationBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/AndroidStationBlockEntity.kt @@ -35,8 +35,8 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : get() = MBlocks.ANDROID_STATION.name override val energy = object : WorkerEnergyStorage(this@AndroidStationBlockEntity::setChangedLight, ::CAPACITY, ::MAX_IO, { null }) { - override fun extractEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { - return super.extractEnergyInner(howMuch, simulate).also { + override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { + return super.extractEnergy(howMuch, simulate).also { if (!simulate && this.batteryLevel.isZero) { if (blockState.getValue(WorkerState.SEMI_WORKER_STATE) != WorkerState.IDLE) { level?.setBlock(blockPos, blockState.setValue(WorkerState.SEMI_WORKER_STATE, WorkerState.IDLE), Block.UPDATE_CLIENTS) @@ -45,8 +45,8 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } - override fun receiveEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { - return super.receiveEnergyInner(howMuch, simulate).also { + override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { + return super.receiveEnergy(howMuch, simulate).also { if (!simulate && it.isPositive) { if (blockState.getValue(WorkerState.SEMI_WORKER_STATE) != WorkerState.WORKING) { level?.setBlock(blockPos, blockState.setValue(WorkerState.SEMI_WORKER_STATE, WorkerState.WORKING), Block.UPDATE_CLIENTS) @@ -85,11 +85,11 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val missing = it.androidEnergy.missingPower if (missing > Decimal.ZERO) { - val extract = energy.extractEnergyInner(missing, true) + val extract = energy.extractEnergy(missing, true) if (extract > Decimal.ZERO) { val received = it.androidEnergy.receiveEnergy(extract, false) - energy.extractEnergyInner(received, false) + energy.extractEnergy(received, false) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BatteryBankBlockEntity.kt index 4d1439bec..c3092159c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BatteryBankBlockEntity.kt @@ -72,17 +72,10 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte ) private data class BatteryBankDistribution(val distribution: Array, val maxThroughput: Decimal) - private enum class BankMode { RECEIVE, EXTRACT, BIDIRECTIONAL } - - private inner class BatteryBankEnergy(private val mode: BankMode) : IMatteryEnergyStorage { - override fun canExtract() = mode != BankMode.RECEIVE - override fun canReceive() = mode != BankMode.EXTRACT + private inner class BatteryBankEnergy(override val energyFlow: FlowDirection) : IMatteryEnergyStorage { override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { - if (mode == BankMode.RECEIVE) - return Decimal.ZERO - - return extractEnergyInner(howMuch, simulate) + return distributeEnergy(isReceiving = false, howMuch, simulate) } fun getDistribution(isReceiving: Boolean): BatteryBankDistribution { @@ -157,18 +150,7 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte return summ } - fun extractEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { - return distributeEnergy(isReceiving = false, howMuch, simulate) - } - override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { - if (mode == BankMode.EXTRACT) - return Decimal.ZERO - - return receiveEnergyInner(howMuch, simulate) - } - - fun receiveEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { return distributeEnergy(isReceiving = true, howMuch, simulate) } @@ -212,9 +194,9 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte } } - private val energyReceiver = BatteryBankEnergy(BankMode.RECEIVE) - private val energyExtractor = BatteryBankEnergy(BankMode.EXTRACT) - private val energy = BatteryBankEnergy(BankMode.BIDIRECTIONAL) + private val energyReceiver = BatteryBankEnergy(FlowDirection.INPUT) + private val energyExtractor = BatteryBankEnergy(FlowDirection.OUTPUT) + private val energy = BatteryBankEnergy(FlowDirection.BI_DIRECTIONAL) private var resolverEnergyReceiver = LazyOptional.of { energyReceiver } private var resolverEnergyExtractor = LazyOptional.of { energyExtractor } @@ -347,14 +329,14 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte val diff = it.receiveEnergy(maxThroughput, true) if (!diff.isZero) { - val newExtract = energy.extractEnergyInner(diff, true) + val newExtract = energy.extractEnergy(diff, true) val newReceive = it.receiveEnergy(newExtract, true) - val extracted = energy.extractEnergyInner(newReceive, false) + val extracted = energy.extractEnergy(newReceive, false) val received = it.receiveEnergy(extracted, false) if (received < extracted) { - energy.receiveEnergyInner(extracted - received, false) + energy.receiveEnergy(extracted - received, false) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ChemicalGeneratorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ChemicalGeneratorBlockEntity.kt index 3a492a89c..b46a5e0d9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ChemicalGeneratorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ChemicalGeneratorBlockEntity.kt @@ -165,18 +165,18 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryBl private var check = true private fun workWithPower(it: IEnergyStorage) { - val extracted = energy.extractEnergyInner(THROUGHPUT, true) + val extracted = energy.extractEnergy(THROUGHPUT, true) val received = it.receiveEnergy(extracted, false) if (!received.isZero) { - energy.extractEnergyInner(received, false) + energy.extractEnergy(received, false) } } fun tick() { if (workTicks > 0) { workTicks-- - energy.receiveEnergyInner(GENERATION_SPEED, false) + energy.receiveEnergy(GENERATION_SPEED, false) if (workTicks == 0) { workTicksTotal = 0 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt index 98f6e9488..07a1e3ce2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt @@ -126,11 +126,10 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat tickOnceServer(this::checkSurroundings) } - private inner class EnergyCounterCap(val isInput: Boolean) : IMatteryEnergyStorage { - override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { - if (isInput) - return Decimal.ZERO + private inner class EnergyCounterCap(isInput: Boolean) : IMatteryEnergyStorage { + override val energyFlow = FlowDirection.input(isInput) + override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { if (inputCapability.isPresent) { val it = inputCapability.resolve().get() @@ -156,9 +155,6 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat } override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { - if (!isInput) - return Decimal.ZERO - if (outputCapability.isPresent) { val it = outputCapability.resolve().get() @@ -188,7 +184,7 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat override var batteryLevel: Decimal get() { - if (isInput) { + if (energyFlow.input) { if (outputCapability.isPresent) { val it = outputCapability.resolve().get() @@ -218,7 +214,7 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat override val maxBatteryLevel: Decimal get() { - if (isInput) { + if (energyFlow.input) { if (outputCapability.isPresent) { val it = outputCapability.resolve().get() @@ -245,7 +241,7 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat override val missingPower: Decimal get() { - if (isInput) { + if (energyFlow.input) { if (outputCapability.isPresent) { val it = outputCapability.resolve().get() @@ -269,9 +265,6 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat return Decimal.ZERO } - - override fun canExtract() = !isInput - override fun canReceive() = isInput } private var resolverInput = LazyOptional.of { energyInput } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyServoBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyServoBlockEntity.kt index 3c71756bf..7fcebc2a6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyServoBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyServoBlockEntity.kt @@ -14,6 +14,7 @@ import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.block.IDroppableContainer +import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.canSetBatteryMattery @@ -59,6 +60,12 @@ class EnergyServoBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte }) val energy = object : IMatteryEnergyStorage { + override val energyFlow: FlowDirection get() { + val discharge = container[SLOT_DISCHARGE].energy + val charge = container[SLOT_CHARGE].energy + return FlowDirection.of(input = charge?.canReceive() ?: false, output = discharge?.canExtract() ?: false) + } + override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { return container[SLOT_DISCHARGE].energy?.extractEnergy(howMuch, simulate) ?: Decimal.ZERO } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt index 28745406e..bd1485eee 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt @@ -32,18 +32,8 @@ abstract class MatteryPoweredBlockEntity(p_155228_: BlockEntityType<*>, p_155229 val batteryContainer = MatteryContainer(this::setChangedLight, 1) protected fun batteryChargeLoop() { - var hit = false - - for (stack in batteryContainer) { - if (!stack.isEmpty) { - hit = true - break - } - } - - if (!hit) { + if (!batteryContainer.any { !it.isEmpty }) return - } var demand = energy.receiveEnergy(energy.missingPower, true) if (demand.isZero) return @@ -51,15 +41,9 @@ abstract class MatteryPoweredBlockEntity(p_155228_: BlockEntityType<*>, p_155229 for (stack in batteryContainer) { if (!stack.isEmpty) { stack.getCapability(ForgeCapabilities.ENERGY).ifPresentK { - if (it is IMatteryEnergyStorage) { - val diff = it.extractEnergy(demand, false) - energy.receiveEnergyInner(diff, false) - demand -= diff - } else { - val diff = it.extractEnergy(demand, false) - energy.receiveEnergyInner(diff, false) - demand -= diff - } + val diff = it.extractEnergy(demand, false) + energy.receiveEnergy(diff, false) + demand -= diff } if (demand <= Decimal.ZERO) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt index e9486f406..ed475cf53 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt @@ -303,7 +303,7 @@ abstract class MatteryWorkerBlockEntity( ticksAdvanced = availableTicks.coerceAtMost(ticksLeft) } else { requiredPower = currentJob.powerUsage * ticksLeft.coerceAtMost(availableTicks) - extractedPower = energy.extractEnergyInner(requiredPower, true) + extractedPower = energy.extractEnergy(requiredPower, true) ticksAdvanced = (extractedPower / requiredPower).toDouble().coerceAtMost(ticksLeft).coerceAtMost(availableTicks) } @@ -333,7 +333,7 @@ abstract class MatteryWorkerBlockEntity( extractedPower = status.newDrainedPower ?: extractedPower if (extractedPower != null) { - energy.extractEnergyInner(extractedPower, false) + energy.extractEnergy(extractedPower, false) } continue diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index 430890983..24e02c22f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -115,7 +115,7 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : }) val matter: MatterStorageImpl = object : MatterStorageImpl(this::setChangedLight, FlowDirection.BI_DIRECTIONAL, ::CAPACITY) { - override val matterDirection: FlowDirection get() { + override val matterFlow: FlowDirection get() { return if (this@MatterBottlerBlockEntity.isBottling) FlowDirection.INPUT else FlowDirection.OUTPUT } } @@ -241,7 +241,7 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : if (!itemStack.isEmpty) { val cap = itemStack.getCapability(MatteryCapability.MATTER).orNull() ?: continue - if (cap.matterDirection != unexpectedDirection) { + if (cap.matterFlow != unexpectedDirection) { if (this.isBottling && cap.missingMatter > Decimal.ZERO || !this.isBottling && cap.storedMatter > Decimal.ZERO) { work_stack = itemStack capability = cap @@ -280,13 +280,13 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } if (matter.storedMatter > Decimal.ZERO) { - val energyExtracted = energy.extractEnergyInner(ENERGY_CONSUMPTION, true) + val energyExtracted = energy.extractEnergy(ENERGY_CONSUMPTION, true) if (!energyExtracted.isZero) { val matter = capability.receiveMatter(MATTER_EXCHANGE_RATE.coerceAtMost(matter.storedMatter) * energyExtracted / ENERGY_CONSUMPTION, true) if (!matter.isZero) { - energy.extractEnergyInner(ENERGY_CONSUMPTION * matter / MATTER_EXCHANGE_RATE, false) + energy.extractEnergy(ENERGY_CONSUMPTION * matter / MATTER_EXCHANGE_RATE, false) capability.receiveMatter(matter, false) this.matter.extractMatterInner(matter, false) @@ -304,13 +304,13 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } } else { - val energyExtracted = energy.extractEnergyInner(ENERGY_CONSUMPTION, true) + val energyExtracted = energy.extractEnergy(ENERGY_CONSUMPTION, true) if (!energyExtracted.isZero) { val matter = capability.extractMatter(MATTER_EXCHANGE_RATE.coerceAtMost(matter.missingMatter) * energyExtracted / ENERGY_CONSUMPTION, true) if (!matter.isZero) { - this.energy.extractEnergyInner(ENERGY_CONSUMPTION * matter / MATTER_EXCHANGE_RATE,false) + this.energy.extractEnergy(ENERGY_CONSUMPTION * matter / MATTER_EXCHANGE_RATE,false) capability.extractMatter(matter, false) this.matter.receiveMatterInner(matter, false) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt index 0027a851f..7f1502cff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt @@ -128,7 +128,7 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) return summ } - override val matterDirection: FlowDirection + override val matterFlow: FlowDirection get() = FlowDirection.BI_DIRECTIONAL private var resolver = LazyOptional.of { this } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt index c6825d7f7..034c23628 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt @@ -484,7 +484,7 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter return stack val maxPossibleDemand = ITEM_STORAGE.energyPerOperation * stack.count - val maxExtractEnergy = energy.extractEnergyInner(maxPossibleDemand, true) + val maxExtractEnergy = energy.extractEnergy(maxPossibleDemand, true) var leftover: ItemStackWrapper = stack.copy() var additional: BigInteger = BigInteger.ZERO @@ -499,7 +499,7 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter leftover = ItemStackWrapper(parent.insertItem(slot, leftover.stack, simulate)) if (oldCount != leftover.count && !simulate) { - energy.extractEnergyInner(ITEM_STORAGE.energyPerOperation * (oldCount - leftover.count), false) + energy.extractEnergy(ITEM_STORAGE.energyPerOperation * (oldCount - leftover.count), false) if (scanned.size <= slot) { sizeScan() @@ -529,7 +529,7 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter return ItemStackWrapper.EMPTY val maxPossibleDemand = ITEM_STORAGE.energyPerOperation * amount - val maxExtractEnergy = energy.extractEnergyInner(maxPossibleDemand, true) + val maxExtractEnergy = energy.extractEnergy(maxPossibleDemand, true) @Suppress("NAME_SHADOWING") var amount = amount @@ -555,7 +555,7 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter totalExtracted += extracted.count if (extracted.count != 0 && !simulate) { - energy.extractEnergyInner(ITEM_STORAGE.energyPerOperation * extracted.count, false) + energy.extractEnergy(ITEM_STORAGE.energyPerOperation * extracted.count, false) } if (totalExtracted >= intAmount) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt index a5627ce0d..e9d20036c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt @@ -23,6 +23,7 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.graph.Graph6Node @@ -187,7 +188,7 @@ class StorageImporterBlockEntity(blockPos: BlockPos, blockState: BlockState) return stack val view = cell.storageGraph?.getVirtualComponent(ITEM_STORAGE) ?: return stack - val maxMove = energy.extractStepInnerBi(ITEM_STORAGE.energyPerOperation, stack.count, true) + val maxMove = energy.extractEnergyExact(ITEM_STORAGE.energyPerOperation, stack.count.toBigInteger(), true) if (maxMove == BigInteger.ZERO) return stack @@ -197,7 +198,7 @@ class StorageImporterBlockEntity(blockPos: BlockPos, blockState: BlockState) if (simulate) return leftover.stack - energy.extractStepInner(ITEM_STORAGE.energyPerOperation, maxMove - leftover.count, false) + energy.extractEnergyExact(ITEM_STORAGE.energyPerOperation, maxMove - leftover.count, false) return leftover.stack } @@ -229,7 +230,7 @@ class StorageImporterBlockEntity(blockPos: BlockPos, blockState: BlockState) lastSlot = 0 } - val maxMove = energy.extractStepInner(ITEM_STORAGE.energyPerOperation, MAX_MOVE_PER_OPERATION, true) + val maxMove = energy.extractEnergyExact(ITEM_STORAGE.energyPerOperation, MAX_MOVE_PER_OPERATION, true) var extracted = resolved.extractItem(lastSlot, maxMove, true) if (extracted.isEmpty || !filter.match(extracted)) { @@ -239,7 +240,7 @@ class StorageImporterBlockEntity(blockPos: BlockPos, blockState: BlockState) if (leftOver.count.toInt() != extracted.count) { extracted = resolved.extractItem(lastSlot, extracted.count - leftOver.count.toInt(), false) - energy.extractStepInner(ITEM_STORAGE.energyPerOperation, extracted.count, false) + energy.extractEnergyExact(ITEM_STORAGE.energyPerOperation, extracted.count, false) items.insertStack(ItemStackWrapper(extracted), false) } else { nextTick += INTERVAL * 4 @@ -353,7 +354,7 @@ class StorageExporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : continue } - var exportAmount = energy.extractStepInner(ITEM_STORAGE.energyPerOperation, exportAmountA, true) + var exportAmount = energy.extractEnergyExact(ITEM_STORAGE.energyPerOperation, exportAmountA, true).toIntSafe() if (exportAmount == 0) { break @@ -365,7 +366,7 @@ class StorageExporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : hit = true exportAmount = items.extractStack(stack.first, (exportAmount - leftover.count).toBigInteger(), false).count.toInt() resolved.insertItem(lastSlot, stack.second.stack.also { it.count = exportAmount }, false) - energy.extractStepInner(ITEM_STORAGE.energyPerOperation, exportAmount, false) + energy.extractEnergyExact(ITEM_STORAGE.energyPerOperation, exportAmount, false) break } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt index 3b216607b..cee292844 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt @@ -18,6 +18,7 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.transferChecked import ru.dbotthepony.mc.otm.core.Decimal import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode import ru.dbotthepony.mc.otm.graph.storage.StorageNetworkGraph @@ -103,13 +104,13 @@ class StoragePowerSupplierBlockEntity(blockPos: BlockPos, blockState: BlockState return } else if (demand < available) { for (demanding in graph.powerDemandingNodes) { - powerPassed += energy.transferInner(demanding, available, false) + powerPassed += energy.transferChecked(demanding, available, false) } } else { val forEach = available / i for (demanding in graph.powerDemandingNodes) { - powerPassed += energy.transferInner(demanding, forEach, false) + powerPassed += energy.transferChecked(demanding, forEach, false) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt index 85558a9a4..26871d5a0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt @@ -30,9 +30,12 @@ import java.util.stream.Stream val ICapabilityProvider.matteryPlayer: MatteryPlayerCapability? get() = getCapability(MatteryCapability.MATTERY_PLAYER).orNull() -fun IEnergyStorage.receiveEnergy(amount: Decimal, simulate: Boolean): Decimal { +/** + * Does a checked energy receive, calls [IMatteryEnergyStorage.receiveEnergyChecked] if possible + */ +internal fun IEnergyStorage.receiveEnergy(amount: Decimal, simulate: Boolean): Decimal { if (this is IMatteryEnergyStorage) - return receiveEnergy(amount, simulate) + return receiveEnergyChecked(amount, simulate) if (!amount.isPositive) return Decimal.ZERO @@ -43,9 +46,12 @@ fun IEnergyStorage.receiveEnergy(amount: Decimal, simulate: Boolean): Decimal { return Decimal.valueOf(receiveEnergy(amount.toInt(), simulate)) } -fun IEnergyStorage.extractEnergy(amount: Decimal, simulate: Boolean): Decimal { +/** + * Does a checked energy extraction, calls [IMatteryEnergyStorage.extractEnergyChecked] if possible + */ +internal fun IEnergyStorage.extractEnergy(amount: Decimal, simulate: Boolean): Decimal { if (this is IMatteryEnergyStorage) - return extractEnergy(amount, simulate) + return extractEnergyChecked(amount, simulate) if (!amount.isPositive) return Decimal.ZERO diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt index d84501e38..e13186bf6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt @@ -4,6 +4,21 @@ import java.util.function.Predicate /** * Represents possible flow direction, both for matter and for energy + * + * To dynamically get this enum by two booleans (by input and output states), use [FlowDirection.of] + * + * Also, this enum implements [Predicate], you can check incoming flow direction for "compatibility" with + * this flow direction, more precisely: + * [test] will return true and only true if [input] and [output] of incoming flow are assignable to this flow + * + * Example: + * * `INPUT.test(OUTPUT)` = `false` + * * `OUTPUT.test(INPUT)` = `false` + * * `INPUT.test(BI_DIRECTIONAL)` = `true` + * * `OUTPUT.test(BI_DIRECTIONAL)` = `true` + * * `BI_DIRECTIONAL.test(BI_DIRECTIONAL)` = `true` + * * `BI_DIRECTIONAL.test(OUTPUT)` = `false` + * * `BI_DIRECTIONAL.test(INPUT)` = `false` */ enum class FlowDirection(val input: Boolean, val output: Boolean) : Predicate { /** @@ -29,4 +44,51 @@ enum class FlowDirection(val input: Boolean, val output: Boolean) : Predicate { + override val energyFlow: FlowDirection + get() = FlowDirection.INPUT + private var battery by synchronizer.fraction(initialCharge, name = "android battery") private var maxBattery by synchronizer.fraction(maxCharge, name = "android max battery") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt index 3f66c38b7..0da6d774e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt @@ -25,7 +25,7 @@ import ru.dbotthepony.mc.otm.core.set sealed class BlockEnergyStorageImpl( protected val listener: () -> Unit, - final override val direction: FlowDirection, + final override val energyFlow: FlowDirection, private val maxBatteryLevelProvider: () -> Decimal, private val maxInputProvider: () -> Decimal?, private val maxOutputProvider: () -> Decimal?, @@ -78,20 +78,6 @@ sealed class BlockEnergyStorageImpl( } override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { - if (direction == FlowDirection.INPUT) - return Decimal.ZERO - - return extractEnergyInner(howMuch, simulate) - } - - override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { - if (direction == FlowDirection.OUTPUT) - return Decimal.ZERO - - return receiveEnergyInner(howMuch, simulate) - } - - override fun extractEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { if (!howMuch.isPositive) return Decimal.ZERO @@ -116,7 +102,7 @@ sealed class BlockEnergyStorageImpl( return diff } - override fun receiveEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { + override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { if (!howMuch.isPositive) return Decimal.ZERO @@ -141,14 +127,6 @@ sealed class BlockEnergyStorageImpl( return diff } - override fun canExtract(): Boolean { - return direction != FlowDirection.INPUT - } - - override fun canReceive(): Boolean { - return direction != FlowDirection.OUTPUT - } - override fun serializeNBT(): CompoundTag { val tag = CompoundTag() tag[ENERGY_STORED_KEY] = batteryLevel.serializeNBT() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt index 56f0063c6..5deb39c5f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt @@ -12,77 +12,6 @@ import java.math.BigInteger sealed interface IEnergyStorageImpl { val maxInput: Decimal? val maxOutput: Decimal? - val direction: FlowDirection - - fun extractEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal - fun receiveEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal - - fun extractStepInner(base: Decimal, multiplier: Int, simulate: Boolean): Int { - return (extractEnergyInner(base * multiplier, simulate) / base).toInt() - } - - fun extractStepInnerBi(base: Decimal, multiplier: Int, simulate: Boolean): BigInteger { - return (extractEnergyInner(base * multiplier, simulate) / base).whole - } - - fun extractStepInner(base: Decimal, multiplier: BigInteger, simulate: Boolean): Int { - return (extractEnergyInner(base * multiplier, simulate) / base).toInt() - } - - fun extractStepInnerBi(base: Decimal, multiplier: BigInteger, simulate: Boolean): BigInteger { - return (extractEnergyInner(base * multiplier, simulate) / base).whole - } - - fun transferInner(other: IMatteryEnergyStorage, amount: Decimal, simulate: Boolean): Decimal { - if (!amount.isPositive) - return Decimal.ZERO - - val extracted = extractEnergyInner(amount, true) - val received = other.receiveEnergy(extracted, simulate) - - if (!simulate) - extractEnergyInner(received, false) - - return received - } - - /** - * All or nothing - * - * @return energy accepted - */ - fun extractEnergyInnerExact(howMuch: Decimal, simulate: Boolean): Decimal { - val extracted = extractEnergyInner(howMuch, true) - - if (extracted != howMuch) { - return Decimal.ZERO - } - - if (!simulate) { - extractEnergyInner(howMuch, false) - } - - return extracted - } - - /** - * All or nothing - * - * @return energy accepted - */ - fun receiveEnergyInnerExact(howMuch: Decimal, simulate: Boolean): Decimal { - val extracted = receiveEnergyInner(howMuch, true) - - if (extracted != howMuch) { - return Decimal.ZERO - } - - if (!simulate) { - receiveEnergyInner(howMuch, false) - } - - return extracted - } } internal fun batteryLevel(it: IEnergyStorage, tooltips: MutableList) { @@ -103,7 +32,7 @@ internal fun batteryLevel(it: IMatteryEnergyStorage, tooltips: MutableList { if (it.maxInput != null) { tooltips.add( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt index be89b76b3..2e6986c6b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt @@ -1,29 +1,99 @@ package ru.dbotthepony.mc.otm.capability.energy import net.minecraftforge.energy.IEnergyStorage +import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.core.Decimal import ru.dbotthepony.mc.otm.core.RGBAColor import java.math.BigInteger import kotlin.math.roundToInt /** - * Energy interface in Overdrive That Matters, which is backward compatible with [IEnergyStorage] + * Energy interface in Overdrive That Matters, which also implements backward compatible methods to implement [IEnergyStorage] + * + * Details of this energy system are as follows: + * * [extractEnergy] and [receiveEnergy] are *unchecked*, which means, they will generally work regardless of energy storage type ([energyFlow]), be it tool, battery or generator. + * What this means is that, despite making no sense to use tool as a battery in machine, [extractEnergy] will work regardless. + * To avoid such cases, [extractEnergyChecked] and [receiveEnergyChecked] are provided + * * Instead of [canReceive] and [canExtract] of [IEnergyStorage], this interface employs [energyFlow] enum property, which is cleaner and easier to use, + * see [FlowDirection] for details + * * This interface allows to set energy stored *directly*. With great power comes great responsibility though, since, sometimes it is technically + * cumbersome or straight up impossible to set stored energy value, therefore, setter of [batteryLevel] is free to throw [UnsupportedOperationException]. + * To avoid try/catch block, check [canSetBatteryLevel] property first + * * Due to limitations of setting [batteryLevel] directly, two methods are also provided: [fillBattery] and [drainBattery]. If you ever + * need to only fill or drain this energy storage, call these two methods and do not use [batteryLevel] directly. + * * Lastly, there is [missingPower]. It returns whatever it has in name. What it makes better than writing your own "[maxBatteryLevel] - [batteryLevel]" logic is that + * implementations can use different and more precise logic to determine actually missing power. **Please use [missingPower] instead of writing your own logic to determine + * whenever storage is missing energy, it will make players not experience silly bugs and make you avoid headaches**. */ interface IMatteryEnergyStorage : IEnergyStorage { /** - * Energy extraction by external interacts + * Extracts up to [howMuch] energy from this storage + * + * In general, this method *does not* obey [energyFlow] and will allow to extract energy + * even if [energyFlow] and [canExtract] say otherwise, unlike [IEnergyStorage.extractEnergy], which, in general, + * obeys return value of [IEnergyStorage.canExtract]. + * + * Therefore, if you want/need to obey [energyFlow], use [extractEnergyChecked] + * + * General contracts: + * * Negative values are not allowed, failing to comply with this contract will result in undefined behavior (worst case) or exception (best case) + * * Returned value CAN NOT be bigger than requested [howMuch], implementations failing to obey this contract will cause undefined behavior in upstream code. + * Upstream code SHOULD NOT check for this contract. * * @return energy extracted */ fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal /** - * Energy insertion by external interacts + * Extracts up to [howMuch] energy from this storage, while obeying [energyFlow]. See [extractEnergy]. * - * @return energy accepted + * Interface implementations generally do not need to override this. + * + * @return energy extracted + */ + fun extractEnergyChecked(howMuch: Decimal, simulate: Boolean): Decimal { + require(!howMuch.isNegative) { "Negative amount of energy: $howMuch" } + + if (!energyFlow.output) + return Decimal.ZERO + + return extractEnergy(howMuch, simulate) + } + + /** + * Inserts up to [howMuch] energy into this storage + * + * In general, this method *does not* obey [energyFlow] and will allow to insert energy + * even if [energyFlow] and [canReceive] say otherwise, unlike [IEnergyStorage.receiveEnergy], which, in general, + * obeys return value of [IEnergyStorage.canReceive]. + * + * Therefore, if you want/need to obey [energyFlow], use [receiveEnergyChecked] + * + * General contracts: + * * Negative values are not allowed, failing to comply with this contract will result in undefined behavior (worst case) or exception (best case) + * * Returned value CAN NOT be bigger than requested [howMuch], implementations failing to obey this contract will cause undefined behavior in upstream code. + * Upstream code SHOULD NOT check for this contract. + * + * @return energy extracted */ fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal + /** + * Inserts up to [howMuch] energy into this storage, while obeying [energyFlow]. See [receiveEnergy]. + * + * Interface implementations generally do not need to override this. + * + * @return energy extracted + */ + fun receiveEnergyChecked(howMuch: Decimal, simulate: Boolean): Decimal { + require(!howMuch.isNegative) { "Negative amount of energy: $howMuch" } + + if (!energyFlow.output) + return Decimal.ZERO + + return extractEnergy(howMuch, simulate) + } + /** * If this is false, then [batteryLevel] will throw [UnsupportedOperationException] when trying to set it */ @@ -55,26 +125,47 @@ interface IMatteryEnergyStorage : IEnergyStorage { /** * Empties power of this energy storage * - * @throws [UnsupportedOperationException] * @see batteryLevel + * @return whenever operation was successful */ - fun drainBattery() { - batteryLevel = Decimal.ZERO + fun drainBattery(): Boolean { + try { + batteryLevel = Decimal.ZERO + } catch(err: UnsupportedOperationException) { + return false + } + + return true } /** * Fully fills power in this energy storage * - * @throws [UnsupportedOperationException] * @see batteryLevel + * @return whenever operation was successful */ - fun fillBattery() { - batteryLevel = maxBatteryLevel + fun fillBattery(): Boolean { + try { + batteryLevel = maxBatteryLevel + } catch(err: UnsupportedOperationException) { + return false + } + + return true } + /** + * Flow direction of energy possible for this energy storage, see [FlowDirection] + */ + val energyFlow: FlowDirection + // -------- Forge Energy stuff override fun receiveEnergy(maxReceive: Int, simulate: Boolean): Int { + // follow contract of IEnergyStorage + if (!energyFlow.input) + return 0 + val received = receiveEnergy(Decimal(maxReceive), true).toInt() // Receiving only a fraction @@ -85,6 +176,10 @@ interface IMatteryEnergyStorage : IEnergyStorage { } override fun extractEnergy(maxReceive: Int, simulate: Boolean): Int { + // follow contract of IEnergyStorage + if (energyFlow.output) + return 0 + val extracted = extractEnergy(Decimal(maxReceive), true).toInt() // Extracting only a fraction @@ -103,14 +198,19 @@ interface IMatteryEnergyStorage : IEnergyStorage { } override fun canExtract(): Boolean { - return extractEnergy(Decimal.ONE, true) > Decimal.ZERO + return energyFlow.output } override fun canReceive(): Boolean { - return receiveEnergy(Decimal.ONE, true) > Decimal.ZERO + return energyFlow.input } } +/** + * Performs *unchecked* extraction of energy + * + * @return whenever can (or we did) extract exactly [howMuch] energy from this storage + */ fun IMatteryEnergyStorage.extractEnergyExact(howMuch: Decimal, simulate: Boolean): Boolean { if (extractEnergy(howMuch, true) == howMuch) { if (!simulate) { @@ -123,6 +223,11 @@ fun IMatteryEnergyStorage.extractEnergyExact(howMuch: Decimal, simulate: Boolean return false } +/** + * Performs *unchecked* insertion of energy + * + * @return whenever can (or we did) receive exactly [howMuch] energy into this storage + */ fun IMatteryEnergyStorage.receiveEnergyExact(howMuch: Decimal, simulate: Boolean): Boolean { if (receiveEnergy(howMuch, true) == howMuch) { if (!simulate) { @@ -135,23 +240,56 @@ fun IMatteryEnergyStorage.receiveEnergyExact(howMuch: Decimal, simulate: Boolean return false } +/** + * Performs *unchecked* extraction of energy + * + * @return how much times can (or we did) extract exactly [howMuch] * [times] energy from this storage + */ fun IMatteryEnergyStorage.extractEnergyExact(howMuch: Decimal, times: Int, simulate: Boolean): Int { if (times == 0) return 0 require(times >= 0) { "times $times >= 0" } require(howMuch >= Decimal.ZERO) { "howMuch $howMuch >= 0" } - return (extractEnergy(howMuch * times, simulate) / times).toInt() + + @Suppress("name_shadowing") + val times = (extractEnergy(howMuch * times, true) / times).toInt() + + if (simulate) + return times + + return (extractEnergy(howMuch * times, false) / times).toInt() } +/** + * Performs *unchecked* extraction of energy + * + * @return how much times can (or we did) extract exactly [howMuch] * [times] energy from this storage + */ +fun IMatteryEnergyStorage.extractEnergyExact(howMuch: Decimal, multiplier: BigInteger, simulate: Boolean): BigInteger { + return (extractEnergy(howMuch * multiplier, simulate) / howMuch).whole +} + +/** + * @see [IMatteryEnergyStorage.extractEnergy] + */ fun IMatteryEnergyStorage.extractEnergy(howMuch: Long, simulate: Boolean): Decimal { return extractEnergy(Decimal(howMuch), simulate) } +/** + * @see [IMatteryEnergyStorage.receiveEnergy] + */ fun IMatteryEnergyStorage.receiveEnergy(howMuch: Long, simulate: Boolean): Decimal { return receiveEnergy(Decimal(howMuch), simulate) } +/** + * Performs *unchecked* energy transfer from this storage to [other] + * + * @see IMatteryEnergyStorage.extractEnergy + * @see IMatteryEnergyStorage.receiveEnergy + */ fun IMatteryEnergyStorage.transfer(other: IMatteryEnergyStorage, amount: Decimal, simulate: Boolean): Decimal { if (!amount.isPositive) return Decimal.ZERO @@ -160,25 +298,28 @@ fun IMatteryEnergyStorage.transfer(other: IMatteryEnergyStorage, amount: Decimal val received = other.receiveEnergy(extracted, simulate) if (!simulate) - extractEnergy(received, false) + return extractEnergy(received, false) return received } -fun IMatteryEnergyStorage.extractStepOuter(base: Decimal, multiplier: BigInteger, simulate: Boolean): Int { - return (extractEnergy(base * multiplier, simulate) / base).toInt() -} +/** + * Performs checked energy transfer from this storage to [other] + * + * @see IMatteryEnergyStorage.extractEnergy + * @see IMatteryEnergyStorage.receiveEnergy + */ +fun IMatteryEnergyStorage.transferChecked(other: IMatteryEnergyStorage, amount: Decimal, simulate: Boolean): Decimal { + if (!amount.isPositive) + return Decimal.ZERO -fun IMatteryEnergyStorage.extractStepOuter(base: Decimal, multiplier: Int, simulate: Boolean): Int { - return (extractEnergy(base * multiplier, simulate) / base).toInt() -} + val extracted = extractEnergy(amount, true) + val received = other.receiveEnergyChecked(extracted, simulate) -fun IMatteryEnergyStorage.extractStepOuterBi(base: Decimal, multiplier: Int, simulate: Boolean): BigInteger { - return (extractEnergy(base * multiplier, simulate) / base).whole -} + if (!simulate) + return extractEnergy(received, false) -fun IMatteryEnergyStorage.extractStepOuterBi(base: Decimal, multiplier: BigInteger, simulate: Boolean): BigInteger { - return (extractEnergy(base * multiplier, simulate) / base).whole + return received } fun IMatteryEnergyStorage.getBarWidth(): Int { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt index f9440b14b..8e9331612 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt @@ -20,7 +20,7 @@ import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.core.tagNotNull sealed class ItemEnergyStorageImpl( - final override val direction: FlowDirection, + final override val energyFlow: FlowDirection, protected val itemStack: ItemStack, maxBatteryLevel: Decimal, maxInput: Decimal?, @@ -56,20 +56,6 @@ sealed class ItemEnergyStorageImpl( } override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { - if (direction == FlowDirection.INPUT) - return Decimal.ZERO - - return extractEnergyInner(howMuch, simulate) - } - - override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { - if (direction == FlowDirection.OUTPUT) - return Decimal.ZERO - - return receiveEnergyInner(howMuch, simulate) - } - - override fun extractEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { if (!howMuch.isPositive || itemStack.count != 1) return Decimal.ZERO @@ -96,7 +82,7 @@ sealed class ItemEnergyStorageImpl( return diff } - override fun receiveEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { + override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { if (!howMuch.isPositive || itemStack.count != 1) return Decimal.ZERO @@ -123,14 +109,6 @@ sealed class ItemEnergyStorageImpl( return diff } - override fun canExtract(): Boolean { - return direction != FlowDirection.INPUT - } - - override fun canReceive(): Boolean { - return direction != FlowDirection.OUTPUT - } - companion object { const val ENERGY_KEY = "energy" diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterStorage.kt index ab0af90b0..dc70b2142 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterStorage.kt @@ -81,13 +81,13 @@ interface IMatterStorage { /** * Which direction does matter flows */ - val matterDirection: FlowDirection + val matterFlow: FlowDirection } inline val IMatterStorage.canExtractMatter: Boolean - get() = matterDirection.output + get() = matterFlow.output inline val IMatterStorage.canReceiveMatter: Boolean - get() = matterDirection.input + get() = matterFlow.input fun IMatterStorage.getBarWidth(): Int { return ((storedMatter / maxStoredMatter).toFloat().coerceAtLeast(0f).coerceAtMost(1f) * 13f).roundToInt() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt index 7bb3dcc36..420c03643 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt @@ -11,7 +11,7 @@ import ru.dbotthepony.mc.otm.core.set open class MatterStorageImpl @JvmOverloads constructor( protected val listener: Runnable?, - override val matterDirection: FlowDirection, + override val matterFlow: FlowDirection, protected val maxStoredMatterSupplier: () -> Decimal, protected val maxReceiveSupplier: () -> Decimal? = { null }, protected val maxExtractSupplier: () -> Decimal? = maxReceiveSupplier diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt index 42dacc61d..d2b6e4e66 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt @@ -10,6 +10,7 @@ import net.minecraftforge.common.capabilities.ICapabilityProvider import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.energy.IEnergyStorage import org.apache.logging.log4j.LogManager +import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.isMekanismLoaded @@ -70,8 +71,7 @@ private val mtj2Mekanism by DoubleLazy lazy@{ return@lazy lazyOf(Decimal.ONE) } -class Mekanism2MatteryEnergyWrapper(private val power: IStrictEnergyHandler, private val forgePower: IEnergyStorage? = null) : - IMatteryEnergyStorage { +class Mekanism2MatteryEnergyWrapper(private val power: IStrictEnergyHandler, private val forgePower: IEnergyStorage? = null) : IMatteryEnergyStorage { override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { val action = when (simulate) { true -> Action.SIMULATE @@ -121,19 +121,8 @@ class Mekanism2MatteryEnergyWrapper(private val power: IStrictEnergyHandler, pri return sum * mekanism2MtJ } - override fun canExtract(): Boolean { - if (forgePower != null) - return forgePower.canExtract() - - return super.canExtract() - } - - override fun canReceive(): Boolean { - if (forgePower != null) - return forgePower.canReceive() - - return super.canReceive() - } + override val energyFlow: FlowDirection + get() = FlowDirection.of(output = forgePower?.canExtract() ?: power.extractEnergy(FloatingLong.MAX_VALUE, Action.SIMULATE).greaterThan(FloatingLong.ZERO), input = forgePower?.canReceive() ?: power.insertEnergy(FloatingLong.MAX_VALUE, Action.SIMULATE).greaterThan(FloatingLong.ZERO)) } class Mattery2MekanismEnergyWrapper(private val power: IMatteryEnergyStorage) : IStrictEnergyHandler { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNetworkGraph.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNetworkGraph.kt index 163bfb788..4e7ca9b03 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNetworkGraph.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNetworkGraph.kt @@ -80,7 +80,7 @@ class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListe for (node in nodes) { val matter = node.value.getMatterHandler() - if (matter != null && matter.matterDirection == FlowDirection.BI_DIRECTIONAL) { + if (matter != null && matter.matterFlow == FlowDirection.BI_DIRECTIONAL) { level += matter.storedMatter } } @@ -94,7 +94,7 @@ class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListe for (node in nodes) { val matter = node.value.getMatterHandler() - if (matter != null && matter.matterDirection == FlowDirection.BI_DIRECTIONAL) { + if (matter != null && matter.matterFlow == FlowDirection.BI_DIRECTIONAL) { level += matter.maxStoredMatter } } @@ -137,7 +137,7 @@ class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListe for (node in nodes) { val matter = node.value.getMatterHandler() - if (matter != null && matter.matterDirection == FlowDirection.BI_DIRECTIONAL) { + if (matter != null && matter.matterFlow == FlowDirection.BI_DIRECTIONAL) { val value = matter.receiveMatter(howMuch, simulate) howMuch -= value received += value @@ -161,7 +161,7 @@ class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListe for (node in nodes) { val matter = node.value.getMatterHandler() - if (matter != null && matter.matterDirection != FlowDirection.OUTPUT) { + if (matter != null && matter.matterFlow != FlowDirection.OUTPUT) { val value = matter.receiveMatter(howMuch, simulate) howMuch -= value received += value diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt index d5d6617df..5ae18f6a0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt @@ -29,14 +29,14 @@ import kotlin.math.roundToInt open class BatteryItem : Item { private inner class Power(stack: ItemStack) : EnergyCapacitorItem(stack, this@BatteryItem.capacity, this@BatteryItem.receive, this@BatteryItem.extract, initialBatteryLevel = this@BatteryItem.initialBatteryLevel) { - override fun extractEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { + override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { if (isCreative) return howMuch - return super.extractEnergyInner(howMuch, simulate) + return super.extractEnergy(howMuch, simulate) } - override fun receiveEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { + override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { if (isCreative) return howMuch - return super.receiveEnergyInner(howMuch, simulate) + return super.receiveEnergy(howMuch, simulate) } override val missingPower: Decimal get() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt index 4475dec6f..4eda3a7e9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt @@ -76,7 +76,7 @@ class MatterCapacitorItem : Item { return diff } - override val matterDirection = FlowDirection.BI_DIRECTIONAL + override val matterFlow = FlowDirection.BI_DIRECTIONAL } private val _capacity: () -> Decimal 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 0edcffd73..2772269ce 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt @@ -78,6 +78,9 @@ class QuantumBatteryItem : Item { private val resolver = LazyOptional.of { this } private val resolverMekanism = if (isMekanismLoaded) LazyOptional.of { Mattery2MekanismEnergyWrapper(this) } else null + override val energyFlow: FlowDirection + get() = FlowDirection.BI_DIRECTIONAL + var data = Data() override fun getCapability(cap: Capability, side: Direction?): LazyOptional { @@ -225,14 +228,6 @@ class QuantumBatteryItem : Item { override val missingPower: Decimal get() = if (isCreative) Decimal.LONG_MAX_VALUE else super.missingPower - override fun canExtract(): Boolean { - return true - } - - override fun canReceive(): Boolean { - return true - } - private fun determineQuantumLink() { if (data.parent == null && isServerThread()) { val existing = stack.tag?.getInt("link_id") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaRifleItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaRifleItem.kt index 6ce5b81e0..4035fc729 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaRifleItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaRifleItem.kt @@ -50,7 +50,7 @@ class PlasmaRifleItem : PlasmaWeaponItem(PlasmaWeaponData ) if (!player.abilities.instabuild) - energyData(itemStack).extractEnergyInner(ENERGY_PER_SHOT, false) + energyData(itemStack).extractEnergy(ENERGY_PER_SHOT, false) return true } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt index 765b62947..2bd11a3ff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt @@ -24,11 +24,13 @@ import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.registry.MSoundEvents import kotlin.reflect.KClass -class PlasmaWeaponEnergy(val itemStack: ItemStack, private val innerCapacity: Decimal) : - IMatteryEnergyStorage, ICapabilityProvider, INBTSerializable { +class PlasmaWeaponEnergy(val itemStack: ItemStack, private val innerCapacity: Decimal) : IMatteryEnergyStorage, ICapabilityProvider, INBTSerializable { private val energyResolver = LazyOptional.of { this } private var innerBatteryLevel = Decimal.ZERO + override val energyFlow: FlowDirection + get() = FlowDirection.INPUT + var battery: ItemStack = ItemStack.EMPTY override fun getCapability(cap: Capability, side: Direction?): LazyOptional { @@ -52,10 +54,6 @@ class PlasmaWeaponEnergy(val itemStack: ItemStack, private val innerCapacity: De } override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { - return Decimal.ZERO - } - - fun extractEnergyInner(howMuch: Decimal, simulate: Boolean): Decimal { if (!howMuch.isPositive) return Decimal.ZERO @@ -129,20 +127,28 @@ class PlasmaWeaponEnergy(val itemStack: ItemStack, private val innerCapacity: De } } - override fun canExtract(): Boolean { - return false - } + override fun drainBattery(): Boolean { + innerBatteryLevel = Decimal.ZERO + + if (!battery.isEmpty) { + battery.getCapability(MatteryCapability.ENERGY).ifPresentK { + return it.drainBattery() + } + } - override fun canReceive(): Boolean { return true } - override fun drainBattery() { - innerBatteryLevel = Decimal.ZERO - } - - override fun fillBattery() { + override fun fillBattery(): Boolean { innerBatteryLevel = innerCapacity + + if (!battery.isEmpty) { + battery.getCapability(MatteryCapability.ENERGY).ifPresentK { + return it.fillBattery() + } + } + + return true } override var batteryLevel: Decimal diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/AndroidStationMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/AndroidStationMenu.kt index c1a8c141c..99e112c41 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/AndroidStationMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/AndroidStationMenu.kt @@ -56,7 +56,7 @@ class AndroidStationMenu @JvmOverloads constructor( if (p_18942_ != 0 || powerWidget.level < AndroidStationBlockEntity.ENERGY_PER_OPERATION || item.isEmpty) return ItemStack.EMPTY - (tile as AndroidStationBlockEntity).energy.extractEnergyInner(AndroidStationBlockEntity.ENERGY_PER_OPERATION, false) + (tile as AndroidStationBlockEntity).energy.extractEnergy(AndroidStationBlockEntity.ENERGY_PER_OPERATION, false) return removeItemNoUpdate(p_18942_) } @@ -73,7 +73,7 @@ class AndroidStationMenu @JvmOverloads constructor( if (p_18944_ != 0) return - (tile as AndroidStationBlockEntity).energy.extractEnergyInner(AndroidStationBlockEntity.ENERGY_PER_OPERATION, false) + (tile as AndroidStationBlockEntity).energy.extractEnergy(AndroidStationBlockEntity.ENERGY_PER_OPERATION, false) item = p_18945_ } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt index 2910de8d0..7eac16375 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt @@ -48,7 +48,7 @@ open class MatterContainerInputSlot @JvmOverloads constructor( override fun mayPlace(itemStack: ItemStack): Boolean { val handler = itemStack.getCapability(MatteryCapability.MATTER).resolve() if (handler.isEmpty) return false - return super.mayPlace(itemStack) && this.direction.test(handler.get().matterDirection) + return super.mayPlace(itemStack) && this.direction.test(handler.get().matterFlow) } } From 1365ac445a10c5d9459da25f19ad1766334fd14e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 14 Jan 2023 14:24:48 +0700 Subject: [PATCH 0045/1199] Small correction to checked energy extensions --- src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt index 26871d5a0..81b08130d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt @@ -38,6 +38,9 @@ internal fun IEnergyStorage.receiveEnergy(amount: Decimal, simulate: Boolean): D return receiveEnergyChecked(amount, simulate) if (!amount.isPositive) + throw IllegalArgumentException("Negative energy: $amount") + + if (!canReceive()) return Decimal.ZERO if (amount > Decimal.INT_MAX_VALUE) @@ -54,6 +57,9 @@ internal fun IEnergyStorage.extractEnergy(amount: Decimal, simulate: Boolean): D return extractEnergyChecked(amount, simulate) if (!amount.isPositive) + throw IllegalArgumentException("Negative energy: $amount") + + if (!canExtract()) return Decimal.ZERO if (amount > Decimal.INT_MAX_VALUE) From 87276e22ed34754f14703b06def0bab77527f052 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 14 Jan 2023 14:29:33 +0700 Subject: [PATCH 0046/1199] oops --- .../mc/otm/capability/energy/IMatteryEnergyStorage.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt index 2e6986c6b..e8241fd3a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt @@ -88,10 +88,10 @@ interface IMatteryEnergyStorage : IEnergyStorage { fun receiveEnergyChecked(howMuch: Decimal, simulate: Boolean): Decimal { require(!howMuch.isNegative) { "Negative amount of energy: $howMuch" } - if (!energyFlow.output) + if (!energyFlow.input) return Decimal.ZERO - return extractEnergy(howMuch, simulate) + return receiveEnergy(howMuch, simulate) } /** From 35921a3a4b7170fb64d9516cad51da9b0120efc8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 14 Jan 2023 14:32:39 +0700 Subject: [PATCH 0047/1199] Use canreceive/extract --- .../mc/otm/menu/ChemicalGeneratorMenu.kt | 15 ++++++++++----- .../ru/dbotthepony/mc/otm/menu/EnergyServoMenu.kt | 8 ++++---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ChemicalGeneratorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ChemicalGeneratorMenu.kt index 11dbdd27a..fb629b5fa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ChemicalGeneratorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ChemicalGeneratorMenu.kt @@ -6,6 +6,7 @@ import net.minecraft.world.item.ItemStack import net.minecraftforge.common.ForgeHooks import net.minecraftforge.common.capabilities.ForgeCapabilities import ru.dbotthepony.mc.otm.block.entity.ChemicalGeneratorBlockEntity +import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -16,20 +17,24 @@ class ChemicalGeneratorMenu @JvmOverloads constructor(id: Int, inv: Inventory, t val container = tile?.container ?: SimpleContainer(3) val fuelSlot = object : MatterySlot(container, ChemicalGeneratorBlockEntity.SLOT_INPUT) { - override fun mayPlace(p_40231_: ItemStack): Boolean { - return ForgeHooks.getBurnTime(p_40231_, null) > 0 + override fun mayPlace(itemStack: ItemStack): Boolean { + return ForgeHooks.getBurnTime(itemStack, null) > 0 } } val residueSlot = object : MatterySlot(container, ChemicalGeneratorBlockEntity.SLOT_RESIDUE) { - override fun mayPlace(p_40231_: ItemStack): Boolean { + override fun mayPlace(itemStack: ItemStack): Boolean { return false } } val batterySlot = object : MatterySlot(container, ChemicalGeneratorBlockEntity.SLOT_BATTERY) { - override fun mayPlace(p_40231_: ItemStack): Boolean { - return p_40231_.getCapability(ForgeCapabilities.ENERGY).isPresent + override fun mayPlace(itemStack: ItemStack): Boolean { + itemStack.getCapability(ForgeCapabilities.ENERGY).ifPresentK { + return it.canReceive() + } + + return false } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyServoMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyServoMenu.kt index eb8e679a8..858247fa8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyServoMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyServoMenu.kt @@ -24,14 +24,14 @@ class EnergyServoMenu @JvmOverloads constructor( val container = tile?.container ?: SimpleContainer(2) dischargeSlot = object : MatterySlot(container, EnergyServoBlockEntity.SLOT_DISCHARGE) { - override fun mayPlace(p_40231_: ItemStack): Boolean { - return super.mayPlace(p_40231_) && (p_40231_.energy?.let { it.extractEnergy(Int.MAX_VALUE, true) > 0 } ?: false) + override fun mayPlace(itemStack: ItemStack): Boolean { + return super.mayPlace(itemStack) && (itemStack.energy?.canExtract() ?: false) } } chargeSlot = object : MatterySlot(container, EnergyServoBlockEntity.SLOT_CHARGE) { - override fun mayPlace(p_40231_: ItemStack): Boolean { - return super.mayPlace(p_40231_) && (p_40231_.energy?.let { it.receiveEnergy(Int.MAX_VALUE, true) > 0 } ?: false) + override fun mayPlace(itemStack: ItemStack): Boolean { + return super.mayPlace(itemStack) && (itemStack.energy?.canReceive() ?: false) } } From c4692bdec4579eaba0e29d07fec86b6cee6f1e73 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 14 Jan 2023 15:02:56 +0700 Subject: [PATCH 0048/1199] Sort core package --- .../dbotthepony/mc/otm/datagen/MatterData.kt | 2 +- .../otm/datagen/models/MatteryModelBuilder.kt | 1 + .../recipes/PlatePressFinishedRecipe.kt | 1 + .../mc/otm/OverdriveThatMatters.java | 4 +- .../ru/dbotthepony/mc/otm/ServerConfig.kt | 4 +- .../ru/dbotthepony/mc/otm/SystemTime.kt | 2 +- .../mc/otm/android/AndroidFeature.kt | 2 +- .../mc/otm/android/AndroidResearch.kt | 4 +- .../mc/otm/android/AndroidResearchType.kt | 3 +- .../otm/android/AndroidSwitchableFeature.kt | 2 +- .../android/feature/EnderTeleporterFeature.kt | 22 +- .../otm/android/feature/ItemMagnetFeature.kt | 10 +- .../otm/android/feature/JumpBoostFeature.kt | 6 +- .../android/feature/NanobotsArmorFeature.kt | 4 +- .../feature/NanobotsRegenerationFeature.kt | 2 +- .../otm/android/feature/ShockwaveFeature.kt | 14 +- .../mc/otm/block/ChemicalGeneratorBlock.kt | 2 +- .../otm/block/GravitationStabilizerBlock.kt | 4 +- .../mc/otm/block/LaboratoryLamp.kt | 6 +- .../dbotthepony/mc/otm/block/MatteryBlock.kt | 6 +- .../mc/otm/block/PhantomAttractorBlock.kt | 5 +- .../block/entity/AndroidStationBlockEntity.kt | 6 +- .../block/entity/BatteryBankBlockEntity.kt | 6 +- .../otm/block/entity/CargoCrateBlockEntity.kt | 4 +- .../entity/ChemicalGeneratorBlockEntity.kt | 11 +- .../block/entity/EnergyCounterBlockEntity.kt | 7 + .../block/entity/EnergyServoBlockEntity.kt | 6 +- .../GravitationStabilizerBlockEntity.kt | 4 +- .../mc/otm/block/entity/MatteryBlockEntity.kt | 13 +- .../block/entity/MatteryPoweredBlockEntity.kt | 9 +- .../block/entity/MatteryWorkerBlockEntity.kt | 9 +- .../otm/block/entity/PlatePressBlockEntity.kt | 6 +- .../entity/blackhole/BlackHoleBlockEntity.kt | 11 +- .../blackhole/ExplosionDebuggerBlockEntity.kt | 4 +- .../otm/block/entity/blackhole/Explosions.kt | 10 +- .../entity/matter/MatterBottlerBlockEntity.kt | 5 + .../matter/MatterCapacitorBankBlockEntity.kt | 12 +- .../matter/MatterDecomposerBlockEntity.kt | 7 + .../matter/MatterRecyclerBlockEntity.kt | 13 +- .../matter/MatterReplicatorBlockEntity.kt | 7 + .../entity/matter/MatterScannerBlockEntity.kt | 8 +- .../matter/PatternStorageBlockEntity.kt | 6 +- .../entity/storage/DriveRackBlockEntity.kt | 4 +- .../entity/storage/DriveViewerBlockEntity.kt | 4 +- .../entity/storage/ItemMonitorBlockEntity.kt | 4 +- .../entity/storage/StorageBusBlockEntity.kt | 6 + .../block/entity/storage/StorageInterfaces.kt | 6 + .../StoragePowerSupplierBlockEntity.kt | 6 +- .../mc/otm/block/storage/StorageBusBlock.kt | 2 +- .../mc/otm/block/storage/StorageInterfaces.kt | 2 +- .../ru/dbotthepony/mc/otm/capability/Ext.kt | 9 +- .../otm/capability/MatteryPlayerCapability.kt | 9 + .../capability/drive/AbstractMatteryDrive.kt | 8 +- .../otm/capability/drive/ItemMatteryDrive.kt | 7 +- .../capability/energy/AndroidPowerSource.kt | 8 +- .../energy/BlockEnergyStorageImpl.kt | 10 +- .../capability/energy/IEnergyStorageImpl.kt | 5 +- .../energy/IMatteryEnergyStorage.kt | 4 +- .../energy/ItemEnergyStorageImpl.kt | 6 +- .../otm/capability/matter/IMatterStorage.kt | 4 +- .../otm/capability/matter/IPatternStorage.kt | 3 +- .../capability/matter/MatterStorageImpl.kt | 4 +- .../mc/otm/capability/matter/PatternState.kt | 2 + .../otm/capability/matter/ReplicationTask.kt | 2 +- .../mc/otm/client/AndroidAbilityKeyMapping.kt | 3 +- .../mc/otm/client/AndroidMenuKeyMapping.kt | 9 +- .../mc/otm/client/ClientEventHandler.kt | 2 +- .../dbotthepony/mc/otm/client/MatteryGUI.kt | 4 +- .../client/render/AbstractMatterySprite.kt | 4 +- .../dbotthepony/mc/otm/client/render/Ext.kt | 9 +- .../mc/otm/client/render/GlitchRenderer.kt | 2 +- .../mc/otm/client/render/RenderHelper.kt | 2 +- .../mc/otm/client/render/ShockwaveRenderer.kt | 12 +- .../mc/otm/client/render/SpriteType.kt | 1 + .../client/render/blockentity/BankRenderer.kt | 2 +- .../render/blockentity/BlackHoleRenderer.kt | 12 +- .../blockentity/EnergyCounterRenderer.kt | 9 +- .../GravitationStabilizerRenderer.kt | 12 +- .../blockentity/MatterReplicatorRenderer.kt | 10 +- .../render/entity/PlasmaProjectileRenderer.kt | 3 +- .../otm/client/screen/AndroidStationScreen.kt | 3 +- .../mc/otm/client/screen/DriveViewerScreen.kt | 2 +- .../otm/client/screen/EnergyCounterScreen.kt | 2 +- .../client/screen/ExoPackInventoryScreen.kt | 2 +- .../mc/otm/client/screen/ItemMonitorScreen.kt | 6 +- .../mc/otm/client/screen/MatterPanelScreen.kt | 2 +- .../mc/otm/client/screen/MatteryScreen.kt | 3 +- .../screen/StoragePowerSupplierScreen.kt | 2 +- .../client/screen/panels/AbstractSlotPanel.kt | 2 +- .../screen/panels/AnalogScrollBarPanel.kt | 2 +- .../client/screen/panels/EffectListPanel.kt | 6 +- .../mc/otm/client/screen/panels/Label.kt | 4 +- .../screen/panels/buttons/ButtonPanel.kt | 2 +- .../client/screen/widget/MatterGaugePanel.kt | 2 +- .../client/screen/widget/PowerGaugePanel.kt | 2 +- .../mc/otm/compat/cos/CosmeticArmorCompat.kt | 2 +- .../mc/otm/compat/curios/CuriosCompat.kt | 2 +- .../compat/jei/PlatePressRecipeCategory.kt | 2 +- .../mc/otm/compat/mekanism/Conversions.kt | 2 +- .../mc/otm/compat/mekanism/Power.kt | 2 +- .../dbotthepony/mc/otm/compat/mekanism/QIO.kt | 2 +- .../mc/otm/container/ContainerIterator.kt | 4 +- .../mc/otm/container/ContainerSpliterator.kt | 4 +- .../ru/dbotthepony/mc/otm/container/Ext.kt | 4 +- .../mc/otm/container/ItemFilter.kt | 5 +- .../otm/container/ItemHandlerSpliterator.kt | 4 +- .../mc/otm/container/MatteryContainer.kt | 4 +- .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 147 +------ .../ru/dbotthepony/mc/otm/core/LevelExt.kt | 2 + .../otm/core/{ => collect}/AwareItemStack.kt | 3 +- .../core/{ => collect}/CapabilityIterators.kt | 3 +- .../otm/core/{ => collect}/ConditionalSet.kt | 2 +- .../{ => collect}/ConditionalSupplierSet.kt | 2 +- .../core/{ => collect}/ItemStackIterators.kt | 2 +- .../mc/otm/core/{ => collect}/ListSet.kt | 4 +- .../core/{ => collect}/PredicateIterator.kt | 2 +- .../mc/otm/core/{ => collect}/ProxiedMap.kt | 2 +- .../mc/otm/core/{ => collect}/SlotIterator.kt | 2 +- .../mc/otm/core/{ => collect}/SupplierList.kt | 2 +- .../mc/otm/core/{ => collect}/SupplierMap.kt | 2 +- .../core/{ => collect}/UUIDIntModifiersMap.kt | 3 +- .../mc/otm/core/{ => math}/Decimal.kt | 6 +- .../mc/otm/core/{ => math}/EuclidMath.kt | 9 +- .../mc/otm/core/{ => math}/Math.kt | 2 +- .../mc/otm/core/{ => math}/MatrixExt.kt | 9 +- .../dbotthepony/mc/otm/core/math/NumberExt.kt | 147 +++++++ .../mc/otm/core/{ => math}/RGBAColor.kt | 2 +- .../core/{ => nbt}/CompoundTagDelegates.kt | 3 +- .../mc/otm/core/{ => nbt}/CompoundTagExt.kt | 2 +- .../mc/otm/core/{ => util}/DataStreams.kt | 4 +- .../mc/otm/core/{ => util}/FriendlyStreams.kt | 2 +- .../core/{Formatting.kt => util/SiPrefix.kt} | 13 +- .../dbotthepony/mc/otm/data/ItemStackCodec.kt | 1 + .../mc/otm/data/SerializedFunctionRegistry.kt | 10 +- .../mc/otm/data/condition/ChanceCondition.kt | 1 + .../condition/ChanceWithPlaytimeCondition.kt | 1 + .../condition/ItemInInventoryCondition.kt | 1 + .../mc/otm/data/loot/RandomizerFunction.kt | 1 + .../mc/otm/entity/PlasmaProjectile.kt | 1 - .../mc/otm/graph/Abstract6Graph.kt | 2 +- .../mc/otm/graph/matter/MatterNetworkGraph.kt | 2 +- .../ru/dbotthepony/mc/otm/item/BatteryItem.kt | 4 +- .../mc/otm/item/EnergySwordItem.kt | 6 +- .../mc/otm/item/MatterCapacitorItem.kt | 10 +- .../dbotthepony/mc/otm/item/MatterDustItem.kt | 5 +- .../mc/otm/item/PatternStorageItem.kt | 4 +- .../otm/item/PortableCondensationDriveItem.kt | 5 +- .../item/ProceduralExoPackSlotUpgradeItem.kt | 2 +- .../mc/otm/item/QuantumBatteryItem.kt | 11 +- .../mc/otm/item/SingleUseBatteryItem.kt | 1 + .../mc/otm/item/weapon/AbstractWeaponItem.kt | 23 +- .../mc/otm/item/weapon/PlasmaRifleItem.kt | 5 +- .../mc/otm/item/weapon/PlasmaWeaponItem.kt | 6 + .../mc/otm/item/weapon/VelocityCalculation.kt | 4 +- .../mc/otm/matter/AbstractRegistryAction.kt | 3 +- .../mc/otm/matter/BlacklistAction.kt | 1 + .../mc/otm/matter/BoundMatterFunction.kt | 3 +- .../mc/otm/matter/ComputeAction.kt | 3 +- .../dbotthepony/mc/otm/matter/DeleteAction.kt | 1 + .../dbotthepony/mc/otm/matter/IMatterValue.kt | 6 +- .../dbotthepony/mc/otm/matter/InsertAction.kt | 3 +- .../mc/otm/matter/MatterDataProvider.kt | 388 ++++++++++++------ .../mc/otm/matter/MatterFunction.kt | 6 +- .../mc/otm/matter/MatterManager.kt | 12 +- .../dbotthepony/mc/otm/matter/UpdateAction.kt | 3 +- .../mc/otm/menu/EnergyCounterMenu.kt | 2 +- .../mc/otm/menu/ItemMonitorMenu.kt | 2 +- .../mc/otm/menu/MatterCapacitorBankMenu.kt | 2 +- .../mc/otm/menu/MatterScannerMenu.kt | 2 +- .../mc/otm/menu/PatternStorageMenu.kt | 2 +- .../mc/otm/menu/widget/LevelGaugeWidget.kt | 8 +- .../mc/otm/network/FieldSynchronizer.kt | 19 + .../network/MatteryPlayerNetworkChannel.kt | 2 +- .../ru/dbotthepony/mc/otm/recipe/Helpers.kt | 1 + .../ru/dbotthepony/mc/otm/registry/Ext.kt | 2 +- .../ru/dbotthepony/mc/otm/registry/MItems.kt | 2 +- .../dbotthepony/mc/otm/registry/MRegistry.kt | 2 +- .../objects/ColoredDecorativeBlock.kt | 3 +- .../otm/registry/objects/DecorativeBlock.kt | 4 +- .../objects/StripedColoredDecorativeBlock.kt | 5 +- .../mc/otm/saveddata/SavedCountingMap.kt | 4 +- .../mc/otm/storage/ItemStackWrapper.kt | 2 + .../ru/dbotthepony/mc/otm/storage/Registry.kt | 2 +- .../mc/otm/storage/VirtualComponent.kt | 5 +- .../mc/otm/triggers/AndroidBatteryTrigger.kt | 1 + .../mc/otm/triggers/AndroidResearchTrigger.kt | 1 + .../mc/otm/triggers/NanobotsArmorTrigger.kt | 1 + .../otm/triggers/ShockwaveDamageMobTrigger.kt | 2 +- .../dbotthepony/mc/otm/tests/DecimalTests.kt | 2 +- .../mc/otm/tests/FormattingTests.kt | 6 +- .../mc/otm/tests/FriendlyStreams.kt | 14 +- .../ru/dbotthepony/mc/otm/tests/MathTests.kt | 4 +- 192 files changed, 940 insertions(+), 634 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/core/{ => collect}/AwareItemStack.kt (95%) rename src/main/kotlin/ru/dbotthepony/mc/otm/core/{ => collect}/CapabilityIterators.kt (95%) rename src/main/kotlin/ru/dbotthepony/mc/otm/core/{ => collect}/ConditionalSet.kt (96%) rename src/main/kotlin/ru/dbotthepony/mc/otm/core/{ => collect}/ConditionalSupplierSet.kt (96%) rename src/main/kotlin/ru/dbotthepony/mc/otm/core/{ => collect}/ItemStackIterators.kt (83%) rename src/main/kotlin/ru/dbotthepony/mc/otm/core/{ => collect}/ListSet.kt (96%) rename src/main/kotlin/ru/dbotthepony/mc/otm/core/{ => collect}/PredicateIterator.kt (97%) rename src/main/kotlin/ru/dbotthepony/mc/otm/core/{ => collect}/ProxiedMap.kt (99%) rename src/main/kotlin/ru/dbotthepony/mc/otm/core/{ => collect}/SlotIterator.kt (95%) rename src/main/kotlin/ru/dbotthepony/mc/otm/core/{ => collect}/SupplierList.kt (95%) rename src/main/kotlin/ru/dbotthepony/mc/otm/core/{ => collect}/SupplierMap.kt (95%) rename src/main/kotlin/ru/dbotthepony/mc/otm/core/{ => collect}/UUIDIntModifiersMap.kt (95%) rename src/main/kotlin/ru/dbotthepony/mc/otm/core/{ => math}/Decimal.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/core/{ => math}/EuclidMath.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/core/{ => math}/Math.kt (97%) rename src/main/kotlin/ru/dbotthepony/mc/otm/core/{ => math}/MatrixExt.kt (86%) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/math/NumberExt.kt rename src/main/kotlin/ru/dbotthepony/mc/otm/core/{ => math}/RGBAColor.kt (99%) rename src/main/kotlin/ru/dbotthepony/mc/otm/core/{ => nbt}/CompoundTagDelegates.kt (97%) rename src/main/kotlin/ru/dbotthepony/mc/otm/core/{ => nbt}/CompoundTagExt.kt (99%) rename src/main/kotlin/ru/dbotthepony/mc/otm/core/{ => util}/DataStreams.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/core/{ => util}/FriendlyStreams.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/core/{Formatting.kt => util/SiPrefix.kt} (95%) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt index f02e26d98..d441ceef3 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt @@ -4,7 +4,7 @@ import net.minecraft.tags.ItemTags import net.minecraft.world.item.Item import net.minecraft.world.item.Items import net.minecraftforge.common.Tags -import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.matter.MatterDataProvider import ru.dbotthepony.mc.otm.registry.MItemTags import ru.dbotthepony.mc.otm.registry.MItems diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelBuilder.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelBuilder.kt index 9c69f35ba..e1b04a422 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelBuilder.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelBuilder.kt @@ -10,6 +10,7 @@ import net.minecraftforge.client.model.generators.ModelBuilder import net.minecraftforge.common.data.ExistingFileHelper import org.joml.Vector3f import ru.dbotthepony.mc.otm.container.set +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set data class TextureSize(val width: Float, val height: Float) { diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressFinishedRecipe.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressFinishedRecipe.kt index 948b8ac53..996211d7f 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressFinishedRecipe.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressFinishedRecipe.kt @@ -8,6 +8,7 @@ import net.minecraft.world.item.crafting.RecipeSerializer import ru.dbotthepony.mc.otm.recipe.PlatePressRecipe import ru.dbotthepony.mc.otm.recipe.PlatePressRecipeFactory import ru.dbotthepony.mc.otm.container.set +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set class PlatePressFinishedRecipe(private val recipe: PlatePressRecipe) : FinishedRecipe { diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 46e9e034f..9fc842ee9 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -4,8 +4,6 @@ import kotlin.KotlinVersion; import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.eventbus.api.EventPriority; @@ -35,7 +33,7 @@ import ru.dbotthepony.mc.otm.client.model.TritaniumArmorModel; import ru.dbotthepony.mc.otm.client.render.ShockwaveRenderer; import ru.dbotthepony.mc.otm.compat.mekanism.QIOKt; import ru.dbotthepony.mc.otm.compat.mekanism.TooltipsKt; -import ru.dbotthepony.mc.otm.core.Decimal; +import ru.dbotthepony.mc.otm.core.math.Decimal; import ru.dbotthepony.mc.otm.item.ItemTritaniumArmor; import ru.dbotthepony.mc.otm.item.QuantumBatteryItem; import ru.dbotthepony.mc.otm.item.weapon.AbstractWeaponItem; diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/ServerConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/ServerConfig.kt index 38d82e1ab..b7be90abd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/ServerConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/ServerConfig.kt @@ -11,8 +11,8 @@ import ru.dbotthepony.mc.otm.block.entity.matter.MatterRecyclerBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterScannerBlockEntity import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl -import ru.dbotthepony.mc.otm.core.Decimal -import ru.dbotthepony.mc.otm.core.defineDecimal +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.item.EnergySwordItem import ru.dbotthepony.mc.otm.registry.MNames diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/SystemTime.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/SystemTime.kt index bd8a5b7ee..2f831c00b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/SystemTime.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/SystemTime.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.mc.otm import net.minecraft.util.TimeSource -import ru.dbotthepony.mc.otm.core.formatTickDuration +import ru.dbotthepony.mc.otm.core.util.formatTickDuration import java.util.function.LongSupplier /** diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeature.kt index 663e21ba5..51010446e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeature.kt @@ -5,7 +5,7 @@ import net.minecraft.nbt.CompoundTag import net.minecraftforge.common.util.INBTSerializable import net.minecraftforge.event.entity.living.LivingHurtEvent import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.network.FieldSynchronizer import java.io.InputStream diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt index 20466b6a5..03553c2d2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt @@ -16,9 +16,9 @@ import ru.dbotthepony.mc.otm.capability.awareItemsStream import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.addAll -import ru.dbotthepony.mc.otm.core.getCompoundList +import ru.dbotthepony.mc.otm.core.nbt.getCompoundList import ru.dbotthepony.mc.otm.core.registryName -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.milliTime import ru.dbotthepony.mc.otm.network.FieldSynchronizer import ru.dbotthepony.mc.otm.registry.MRegistry diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt index 7d400ffb5..3dd3c0c58 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt @@ -23,10 +23,11 @@ import net.minecraft.world.level.ItemLike import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.SpriteType -import ru.dbotthepony.mc.otm.core.ListSet +import ru.dbotthepony.mc.otm.core.collect.ListSet import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.isActuallyEmpty import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.core.toImmutableList import ru.dbotthepony.mc.otm.data.stream diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt index 10611e63c..2fa707c29 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt @@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.android import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.nbt.CompoundTag import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.nbt.set abstract class AndroidSwitchableFeature(type: AndroidFeatureType<*>, android: MatteryPlayerCapability) : AndroidFeature(type, android) { var isActive by synchronizer.bool(setter = setter@{ value, access, setByRemote -> diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt index 546170a85..c2d188d86 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt @@ -36,19 +36,19 @@ import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.client.render.sprite import ru.dbotthepony.mc.otm.client.render.linesIgnoreZRenderType -import ru.dbotthepony.mc.otm.core.Vector -import ru.dbotthepony.mc.otm.core.asVector -import ru.dbotthepony.mc.otm.core.component1 -import ru.dbotthepony.mc.otm.core.component2 -import ru.dbotthepony.mc.otm.core.component3 -import ru.dbotthepony.mc.otm.core.formatPower +import ru.dbotthepony.mc.otm.core.math.Vector +import ru.dbotthepony.mc.otm.core.math.asVector +import ru.dbotthepony.mc.otm.core.math.component1 +import ru.dbotthepony.mc.otm.core.math.component2 +import ru.dbotthepony.mc.otm.core.math.component3 +import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.core.genericPositions import ru.dbotthepony.mc.otm.core.holder -import ru.dbotthepony.mc.otm.core.plus -import ru.dbotthepony.mc.otm.core.rotateXDegrees -import ru.dbotthepony.mc.otm.core.rotateYDegrees -import ru.dbotthepony.mc.otm.core.shortestDistanceBetween -import ru.dbotthepony.mc.otm.core.times +import ru.dbotthepony.mc.otm.core.math.plus +import ru.dbotthepony.mc.otm.core.math.rotateXDegrees +import ru.dbotthepony.mc.otm.core.math.rotateYDegrees +import ru.dbotthepony.mc.otm.core.math.shortestDistanceBetween +import ru.dbotthepony.mc.otm.core.math.times import ru.dbotthepony.mc.otm.milliTime import ru.dbotthepony.mc.otm.registry.AndroidFeatures import ru.dbotthepony.mc.otm.registry.MNames diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt index af0d7921f..50ad23633 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt @@ -16,13 +16,13 @@ import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.ResearchIcons -import ru.dbotthepony.mc.otm.core.Vector -import ru.dbotthepony.mc.otm.core.formatPower +import ru.dbotthepony.mc.otm.core.math.Vector +import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.core.getEntitiesInEllipsoid -import ru.dbotthepony.mc.otm.core.minus -import ru.dbotthepony.mc.otm.core.plus +import ru.dbotthepony.mc.otm.core.math.minus +import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.core.position -import ru.dbotthepony.mc.otm.core.times +import ru.dbotthepony.mc.otm.core.math.times import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.WorldNetworkChannel import ru.dbotthepony.mc.otm.network.packetHandled diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt index b057ebfda..b45f18fbe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt @@ -17,9 +17,9 @@ import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.render.ResearchIcons -import ru.dbotthepony.mc.otm.core.Vector -import ru.dbotthepony.mc.otm.core.formatPower -import ru.dbotthepony.mc.otm.core.plus +import ru.dbotthepony.mc.otm.core.math.Vector +import ru.dbotthepony.mc.otm.core.util.formatPower +import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel import ru.dbotthepony.mc.otm.network.enqueueWork diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt index 364b7912b..4ecedb8c3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt @@ -9,10 +9,10 @@ import ru.dbotthepony.mc.otm.android.AndroidFeature import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact -import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.registry.AndroidFeatures import ru.dbotthepony.mc.otm.registry.StatNames -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.onceServer import ru.dbotthepony.mc.otm.triggers.NanobotsArmorTrigger import kotlin.math.roundToInt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsRegenerationFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsRegenerationFeature.kt index cfb8d3545..7af4d40aa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsRegenerationFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsRegenerationFeature.kt @@ -8,7 +8,7 @@ import ru.dbotthepony.mc.otm.android.AndroidFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.registry.AndroidFeatures import ru.dbotthepony.mc.otm.registry.StatNames -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.nbt.set import kotlin.math.roundToInt class NanobotsRegenerationFeature(android: MatteryPlayerCapability) : AndroidFeature(AndroidFeatures.NANOBOTS_REGENERATION, android) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt index 5e6431028..214c7f7ab 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt @@ -19,16 +19,16 @@ import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.client.render.ResearchIcons -import ru.dbotthepony.mc.otm.core.Vector -import ru.dbotthepony.mc.otm.core.formatPower -import ru.dbotthepony.mc.otm.core.getEllipsoidBlockPositions +import ru.dbotthepony.mc.otm.core.math.Vector +import ru.dbotthepony.mc.otm.core.util.formatPower +import ru.dbotthepony.mc.otm.core.math.getEllipsoidBlockPositions import ru.dbotthepony.mc.otm.core.getEntitiesInEllipsoid import ru.dbotthepony.mc.otm.core.getExplosionResistance -import ru.dbotthepony.mc.otm.core.minus -import ru.dbotthepony.mc.otm.core.plus +import ru.dbotthepony.mc.otm.core.math.minus +import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.core.position -import ru.dbotthepony.mc.otm.core.roundToIntVector -import ru.dbotthepony.mc.otm.core.times +import ru.dbotthepony.mc.otm.core.math.roundToIntVector +import ru.dbotthepony.mc.otm.core.math.times import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.network.MatteryPacket diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/ChemicalGeneratorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/ChemicalGeneratorBlock.kt index 8adae472c..b9cbe031f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/ChemicalGeneratorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/ChemicalGeneratorBlock.kt @@ -26,7 +26,7 @@ import ru.dbotthepony.mc.otm.capability.energy.GeneratorEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.ItemEnergyStorageImpl import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.core.map +import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.oncePre import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/GravitationStabilizerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/GravitationStabilizerBlock.kt index 09fa3929d..ca8d0ce25 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/GravitationStabilizerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/GravitationStabilizerBlock.kt @@ -25,8 +25,8 @@ import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.entity.GravitationStabilizerBlockEntity import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState -import ru.dbotthepony.mc.otm.core.plus -import ru.dbotthepony.mc.otm.core.times +import ru.dbotthepony.mc.otm.core.math.plus +import ru.dbotthepony.mc.otm.core.math.times import ru.dbotthepony.mc.otm.oncePre import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlocks diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/LaboratoryLamp.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/LaboratoryLamp.kt index 63e4ad9ee..a3ec37fbd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/LaboratoryLamp.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/LaboratoryLamp.kt @@ -23,9 +23,9 @@ import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.ServerConfig import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.get -import ru.dbotthepony.mc.otm.core.plus -import ru.dbotthepony.mc.otm.core.times -import ru.dbotthepony.mc.otm.core.unaryMinus +import ru.dbotthepony.mc.otm.core.math.plus +import ru.dbotthepony.mc.otm.core.math.times +import ru.dbotthepony.mc.otm.core.math.unaryMinus import ru.dbotthepony.mc.otm.once import ru.dbotthepony.mc.otm.registry.MBlocks diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt index 6d1a6700c..578fa6590 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt @@ -25,9 +25,9 @@ import net.minecraft.world.level.material.MaterialColor import net.minecraft.world.phys.BlockHitResult import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState -import ru.dbotthepony.mc.otm.core.component1 -import ru.dbotthepony.mc.otm.core.component2 -import ru.dbotthepony.mc.otm.core.component3 +import ru.dbotthepony.mc.otm.core.math.component1 +import ru.dbotthepony.mc.otm.core.math.component2 +import ru.dbotthepony.mc.otm.core.math.component3 import ru.dbotthepony.mc.otm.core.get interface IDroppableContainer { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/PhantomAttractorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/PhantomAttractorBlock.kt index a85210898..65ac7a89a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/PhantomAttractorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/PhantomAttractorBlock.kt @@ -12,7 +12,6 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.context.BlockPlaceContext import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level -import net.minecraft.world.level.LevelReader import net.minecraft.world.level.NaturalSpawner import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.Blocks @@ -27,8 +26,8 @@ import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import net.minecraftforge.common.ForgeHooks import ru.dbotthepony.mc.otm.core.get -import ru.dbotthepony.mc.otm.core.minus -import ru.dbotthepony.mc.otm.core.plus +import ru.dbotthepony.mc.otm.core.math.minus +import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.once import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.shapes.BlockShapes diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/AndroidStationBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/AndroidStationBlockEntity.kt index 5d0babbf2..d59942492 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/AndroidStationBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/AndroidStationBlockEntity.kt @@ -13,9 +13,9 @@ import net.minecraft.world.phys.AABB import net.minecraftforge.common.ForgeConfigSpec import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage -import ru.dbotthepony.mc.otm.core.Decimal -import ru.dbotthepony.mc.otm.core.DecimalConfigValue -import ru.dbotthepony.mc.otm.core.defineDecimal +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue +import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.menu.AndroidStationMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BatteryBankBlockEntity.kt index c3092159c..33924d262 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BatteryBankBlockEntity.kt @@ -28,6 +28,9 @@ import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainerHooks import ru.dbotthepony.mc.otm.core.* +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.unaryMinus +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.menu.BatteryBankMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -177,7 +180,8 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte throw UnsupportedOperationException("Can't set battery value for battery bank") } - override val maxBatteryLevel: Decimal get() { + override val maxBatteryLevel: Decimal + get() { var result = Decimal.ZERO for (i in 0 until container.containerSize) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/CargoCrateBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/CargoCrateBlockEntity.kt index 236c50821..97c58cbdd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/CargoCrateBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/CargoCrateBlockEntity.kt @@ -33,8 +33,8 @@ import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainerHooks import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.core.map -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.menu.CargoCrateMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MSoundEvents diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ChemicalGeneratorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ChemicalGeneratorBlockEntity.kt index b46a5e0d9..50915838f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ChemicalGeneratorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ChemicalGeneratorBlockEntity.kt @@ -30,6 +30,13 @@ import ru.dbotthepony.mc.otm.menu.ChemicalGeneratorMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.core.WriteOnce +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue +import ru.dbotthepony.mc.otm.core.math.defineDecimal +import ru.dbotthepony.mc.otm.core.math.plus +import ru.dbotthepony.mc.otm.core.math.unaryMinus +import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.nbt.set import java.lang.ref.WeakReference class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryBlockEntity(MBlockEntities.CHEMICAL_GENERATOR, pos, state), IDroppableContainer { @@ -77,8 +84,8 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryBl valid = true } - override fun setLevel(level: Level) { - super.setLevel(level) + override fun setLevel(p_155231_: Level) { + super.setLevel(p_155231_) tickOnceServer(this::checkSurroundings) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt index 07a1e3ce2..58bbf5a95 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt @@ -22,6 +22,13 @@ import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper import ru.dbotthepony.mc.otm.core.* +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.getDecimal +import ru.dbotthepony.mc.otm.core.math.unaryMinus +import ru.dbotthepony.mc.otm.core.nbt.getByteArrayList +import ru.dbotthepony.mc.otm.core.nbt.ifHas +import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.menu.EnergyCounterMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import java.lang.ref.WeakReference diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyServoBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyServoBlockEntity.kt index 7fcebc2a6..36060a13b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyServoBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyServoBlockEntity.kt @@ -25,9 +25,9 @@ import ru.dbotthepony.mc.otm.capability.maxEnergyStoredMattery import ru.dbotthepony.mc.otm.capability.receiveEnergy import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainerHooks -import ru.dbotthepony.mc.otm.core.Decimal -import ru.dbotthepony.mc.otm.core.map -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.menu.EnergyServoMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlocks diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/GravitationStabilizerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/GravitationStabilizerBlockEntity.kt index 9a14c3332..d2f25dee2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/GravitationStabilizerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/GravitationStabilizerBlockEntity.kt @@ -14,8 +14,8 @@ import ru.dbotthepony.mc.otm.block.BlockGravitationStabilizer import ru.dbotthepony.mc.otm.block.BlockGravitationStabilizerLens import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity -import ru.dbotthepony.mc.otm.core.plus -import ru.dbotthepony.mc.otm.core.times +import ru.dbotthepony.mc.otm.core.math.plus +import ru.dbotthepony.mc.otm.core.math.times import ru.dbotthepony.mc.otm.registry.MBlockEntities class GravitationStabilizerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryBlockEntity( 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 ba983af03..c2ed4d53b 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 @@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.block.entity import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.core.BlockPos import net.minecraft.world.level.block.state.BlockState -import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.MenuProvider import java.lang.Runnable import net.minecraft.server.level.ServerLevel @@ -23,16 +22,8 @@ import net.minecraft.world.level.Level import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity import net.minecraftforge.common.capabilities.Capability import ru.dbotthepony.mc.otm.core.TextComponent -import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.core.component1 -import ru.dbotthepony.mc.otm.core.component2 -import ru.dbotthepony.mc.otm.core.component3 -import ru.dbotthepony.mc.otm.core.ifHas -import ru.dbotthepony.mc.otm.core.position -import ru.dbotthepony.mc.otm.core.set -import ru.dbotthepony.mc.otm.network.BlockEntitySyncPacket -import ru.dbotthepony.mc.otm.network.FieldSynchronizer -import ru.dbotthepony.mc.otm.network.WorldNetworkChannel +import ru.dbotthepony.mc.otm.core.nbt.ifHas +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.oncePre abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: BlockPos, p_155230_: BlockState) : SynchronizedBlockEntity(p_155228_, p_155229_, p_155230_), MenuProvider { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt index bd1485eee..37396ca9b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt @@ -16,15 +16,14 @@ import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl -import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.ItemEnergyStorageImpl import ru.dbotthepony.mc.otm.container.MatteryContainer -import ru.dbotthepony.mc.otm.core.Decimal -import ru.dbotthepony.mc.otm.core.ifHas +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.nbt.ifHas import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.core.map -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.nbt.set abstract class MatteryPoweredBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: BlockPos, p_155230_: BlockState) : MatteryBlockEntity(p_155228_, p_155229_, p_155230_) { abstract val energy: BlockEnergyStorageImpl diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt index ed475cf53..9e3278d11 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt @@ -12,7 +12,14 @@ import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.block.Block import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.core.* -import ru.dbotthepony.mc.otm.core.map +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.getDecimal +import ru.dbotthepony.mc.otm.core.math.set +import ru.dbotthepony.mc.otm.core.math.weakEqualDoubles +import ru.dbotthepony.mc.otm.core.math.weakGreaterThan +import ru.dbotthepony.mc.otm.core.math.weakLessThan +import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.nbt.set private fun isReason(status: Any?, reason: Any) = status == null || status == reason diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/PlatePressBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/PlatePressBlockEntity.kt index f7d36a62c..144e2c029 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/PlatePressBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/PlatePressBlockEntity.kt @@ -19,12 +19,12 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainerHooks -import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.menu.PlatePressMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MRecipes -import ru.dbotthepony.mc.otm.core.map -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.nbt.set class PlatePressBlockEntity( p_155229_: BlockPos, 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 b119619e4..6d1b91ae8 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 @@ -10,7 +10,6 @@ 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 @@ -22,14 +21,14 @@ import ru.dbotthepony.mc.otm.block.BlackHoleBlock import ru.dbotthepony.mc.otm.block.entity.GravitationStabilizerBlockEntity import ru.dbotthepony.mc.otm.block.entity.SynchronizedBlockEntity import ru.dbotthepony.mc.otm.block.entity.blackhole.ExplosionQueue.Companion.queueForLevel -import ru.dbotthepony.mc.otm.core.Decimal -import ru.dbotthepony.mc.otm.core.plus +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRegistry -import ru.dbotthepony.mc.otm.core.getSphericalBlockPositions -import ru.dbotthepony.mc.otm.core.mapIf -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.math.getSphericalBlockPositions +import ru.dbotthepony.mc.otm.core.nbt.mapIf +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.triggers.BlackHoleTrigger import java.util.LinkedList diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/ExplosionDebuggerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/ExplosionDebuggerBlockEntity.kt index 0cdad6434..55d4378a4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/ExplosionDebuggerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/ExplosionDebuggerBlockEntity.kt @@ -7,8 +7,8 @@ import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.phys.Vec3 -import ru.dbotthepony.mc.otm.core.plus -import ru.dbotthepony.mc.otm.core.times +import ru.dbotthepony.mc.otm.core.math.plus +import ru.dbotthepony.mc.otm.core.math.times import ru.dbotthepony.mc.otm.registry.MBlockEntities class BlockEntityExplosionDebugger(p_155229_: BlockPos, p_155230_: BlockState) : BlockEntity(MBlockEntities.DEBUG_EXPLOSION_SMALL, p_155229_, p_155230_) { 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 0777f6c46..9de142daf 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 @@ -21,7 +21,15 @@ import net.minecraftforge.eventbus.api.SubscribeEvent import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.block.BlockExplosionDebugger import ru.dbotthepony.mc.otm.core.* -import ru.dbotthepony.mc.otm.core.Vector +import ru.dbotthepony.mc.otm.core.math.Vector +import ru.dbotthepony.mc.otm.core.math.component1 +import ru.dbotthepony.mc.otm.core.math.component2 +import ru.dbotthepony.mc.otm.core.math.component3 +import ru.dbotthepony.mc.otm.core.math.left +import ru.dbotthepony.mc.otm.core.math.plus +import ru.dbotthepony.mc.otm.core.math.rotateAroundAxis +import ru.dbotthepony.mc.otm.core.math.up +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.registry.MRegistry import java.util.* import kotlin.collections.ArrayList diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index 24e02c22f..b59157637 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -39,6 +39,11 @@ import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.core.WriteOnce +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue +import ru.dbotthepony.mc.otm.core.math.defineDecimal +import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.nbt.set class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.MATTER_BOTTLER, p_155229_, p_155230_), IMatterGraphNode, IDroppableContainer { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt index 7f1502cff..5d1389529 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt @@ -23,15 +23,15 @@ import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage import ru.dbotthepony.mc.otm.container.MatteryContainer -import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph import ru.dbotthepony.mc.otm.menu.MatterCapacitorBankMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities -import ru.dbotthepony.mc.otm.core.map -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.nbt.set class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryBlockEntity(MBlockEntities.MATTER_CAPACITOR_BANK, p_155229_, p_155230_), IMatterGraphNode, IMatterStorage, IDroppableContainer { var gaugeLevel by synchronizer.float() @@ -43,7 +43,8 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) override val canSetMatterLevel: Boolean get() = false - override var storedMatter: Decimal get() { + override var storedMatter: Decimal + get() { var summ = Decimal.ZERO for (stack in container) @@ -58,7 +59,8 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) throw UnsupportedOperationException() } - override val maxStoredMatter: Decimal get() { + override val maxStoredMatter: Decimal + get() { var summ = Decimal.ZERO for (stack in container) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index c0cd54136..0850b82c9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -39,6 +39,13 @@ import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.core.WriteOnce +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue +import ru.dbotthepony.mc.otm.core.math.defineDecimal +import ru.dbotthepony.mc.otm.core.math.getDecimal +import ru.dbotthepony.mc.otm.core.math.set +import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.matter.MatterManager fun moveMatterAsDustIntoContainer(_matterValue: Decimal, container: MatteryContainer, OUTPUT_DUST_MAIN: Int, OUTPUT_DUST_STACKING: Int): Decimal { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index 6d0f5bb13..5f9876c5d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -28,21 +28,22 @@ import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainerHooks -import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph import ru.dbotthepony.mc.otm.item.MatterDustItem -import ru.dbotthepony.mc.otm.core.map +import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.menu.MatterRecyclerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities -import ru.dbotthepony.mc.otm.core.DecimalConfigValue -import ru.dbotthepony.mc.otm.core.defineDecimal -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue +import ru.dbotthepony.mc.otm.core.math.defineDecimal +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.core.WriteOnce -import ru.dbotthepony.mc.otm.core.getDecimal +import ru.dbotthepony.mc.otm.core.math.getDecimal +import ru.dbotthepony.mc.otm.core.math.set class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryWorkerBlockEntity(MBlockEntities.MATTER_RECYCLER, blockPos, blockState, ::RecyclerJob), IMatterGraphNode, IDroppableContainer { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index bd64d1820..daf276288 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -35,6 +35,13 @@ import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.core.WriteOnce +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue +import ru.dbotthepony.mc.otm.core.math.defineDecimal +import ru.dbotthepony.mc.otm.core.math.getDecimal +import ru.dbotthepony.mc.otm.core.math.set +import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.matter.MatterManager class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt index 8f7ee8d45..103f04e5b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt @@ -26,10 +26,10 @@ import ru.dbotthepony.mc.otm.capability.matter.IPatternState import ru.dbotthepony.mc.otm.capability.matter.PatternState import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainerHooks -import ru.dbotthepony.mc.otm.core.Decimal -import ru.dbotthepony.mc.otm.core.DecimalConfigValue -import ru.dbotthepony.mc.otm.core.defineDecimal -import ru.dbotthepony.mc.otm.core.map +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue +import ru.dbotthepony.mc.otm.core.math.defineDecimal +import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt index 07a081342..e733387f1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt @@ -27,13 +27,13 @@ import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.capability.matter.* -import ru.dbotthepony.mc.otm.core.iterator +import ru.dbotthepony.mc.otm.core.collect.iterator import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph -import ru.dbotthepony.mc.otm.core.map +import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.registry.MBlockEntities -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.nbt.set import java.util.ArrayList import java.util.stream.Stream diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt index 9751a6e5b..f0fd113eb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt @@ -20,8 +20,8 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.menu.DriveRackMenu -import ru.dbotthepony.mc.otm.core.map -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.graph.storage.StorageNetworkGraph import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlocks diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt index 0fd68dfbd..6dc847021 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt @@ -21,8 +21,8 @@ import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.menu.DriveViewerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities -import ru.dbotthepony.mc.otm.core.map -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.registry.MBlocks class DriveViewerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.DRIVE_VIEWER, p_155229_, p_155230_), IDroppableContainer { 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 571dbc5d0..ef1653feb 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 @@ -39,8 +39,8 @@ import ru.dbotthepony.mc.otm.menu.ItemMonitorMenu import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.container.set -import ru.dbotthepony.mc.otm.core.getEnum -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.nbt.getEnum +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.storage.* import java.math.BigInteger diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt index 034c23628..f9c6d2cb8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt @@ -27,6 +27,12 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.core.* +import ru.dbotthepony.mc.otm.core.math.isPositive +import ru.dbotthepony.mc.otm.core.math.isZero +import ru.dbotthepony.mc.otm.core.math.plus +import ru.dbotthepony.mc.otm.core.math.unaryMinus +import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.GraphNodeListener import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt index e9d20036c..acf76caf0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt @@ -26,6 +26,12 @@ import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.core.* +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.plus +import ru.dbotthepony.mc.otm.core.math.toIntSafe +import ru.dbotthepony.mc.otm.core.math.unaryMinus +import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.GraphNodeListener import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt index cee292844..a9e2f61ab 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt @@ -19,14 +19,14 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.transferChecked -import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode import ru.dbotthepony.mc.otm.graph.storage.StorageNetworkGraph import ru.dbotthepony.mc.otm.menu.StoragePowerSupplierMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MNames -import ru.dbotthepony.mc.otm.core.getDecimal -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.math.getDecimal +import ru.dbotthepony.mc.otm.core.nbt.set class StoragePowerSupplierBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.STORAGE_POWER_SUPPLIER, blockPos, blockState) { override val defaultDisplayName: Component diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt index 89726cb77..d0f5d2867 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt @@ -26,7 +26,7 @@ import ru.dbotthepony.mc.otm.block.entity.storage.StorageBusBlockEntity import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes -import ru.dbotthepony.mc.otm.core.unaryMinus +import ru.dbotthepony.mc.otm.core.math.unaryMinus import ru.dbotthepony.mc.otm.oncePre class StorageBusBlock : RotatableMatteryBlock(), EntityBlock { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt index bda55fd7f..1ae920297 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt @@ -27,7 +27,7 @@ import ru.dbotthepony.mc.otm.block.entity.storage.StorageImporterBlockEntity import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes -import ru.dbotthepony.mc.otm.core.unaryMinus +import ru.dbotthepony.mc.otm.core.math.unaryMinus import ru.dbotthepony.mc.otm.oncePre class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt index 81b08130d..11ca15287 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt @@ -20,9 +20,9 @@ import ru.dbotthepony.mc.otm.compat.mekanism.getMekanismEnergySided import ru.dbotthepony.mc.otm.compat.mekanism.mekanismEnergy import ru.dbotthepony.mc.otm.container.awareStream import ru.dbotthepony.mc.otm.container.stream -import ru.dbotthepony.mc.otm.core.AwareItemStack -import ru.dbotthepony.mc.otm.core.ContainerItemStackEntry -import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.collect.AwareItemStack +import ru.dbotthepony.mc.otm.core.collect.ContainerItemStackEntry +import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.orNull import java.util.IdentityHashMap import java.util.LinkedList @@ -68,7 +68,8 @@ internal fun IEnergyStorage.extractEnergy(amount: Decimal, simulate: Boolean): D return Decimal.valueOf(extractEnergy(amount.toInt(), simulate)) } -val IEnergyStorage.maxEnergyStoredMattery: Decimal get() { +val IEnergyStorage.maxEnergyStoredMattery: Decimal + get() { if (this is IMatteryEnergyStorage) { return maxBatteryLevel } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 79232b09a..1e885e286 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -49,6 +49,15 @@ import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.stream import ru.dbotthepony.mc.otm.core.* +import ru.dbotthepony.mc.otm.core.collect.UUIDIntModifiersMap +import ru.dbotthepony.mc.otm.core.collect.nonEmpty +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.set +import ru.dbotthepony.mc.otm.core.nbt.getCompoundList +import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.core.util.IntValueCodec +import ru.dbotthepony.mc.otm.core.util.UUIDValueCodec import ru.dbotthepony.mc.otm.menu.ExoPackInventoryMenu import ru.dbotthepony.mc.otm.network.* import ru.dbotthepony.mc.otm.registry.AndroidFeatures diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/AbstractMatteryDrive.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/AbstractMatteryDrive.kt index 1fbda2ec0..60f568e8c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/AbstractMatteryDrive.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/AbstractMatteryDrive.kt @@ -7,8 +7,12 @@ import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.ListTag import net.minecraft.nbt.Tag import org.apache.logging.log4j.LogManager -import ru.dbotthepony.mc.otm.container.set import ru.dbotthepony.mc.otm.core.* +import ru.dbotthepony.mc.otm.core.math.BigInteger +import ru.dbotthepony.mc.otm.core.math.isPositive +import ru.dbotthepony.mc.otm.core.math.serializeNBT +import ru.dbotthepony.mc.otm.core.nbt.ifHas +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.storage.* import java.math.BigInteger import java.util.ArrayList @@ -214,4 +218,4 @@ abstract class AbstractMatteryDrive @JvmOverloads constructor companion object { private val LOGGER = LogManager.getLogger() } -} \ No newline at end of file +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/ItemMatteryDrive.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/ItemMatteryDrive.kt index 6cd728abb..4ff1b972b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/ItemMatteryDrive.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/ItemMatteryDrive.kt @@ -7,10 +7,9 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.core.BigInteger -import ru.dbotthepony.mc.otm.core.serializeNBT -import ru.dbotthepony.mc.otm.container.set -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.math.BigInteger +import ru.dbotthepony.mc.otm.core.math.serializeNBT +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.storage.IStorageTuple import ru.dbotthepony.mc.otm.storage.ItemStackWrapper import ru.dbotthepony.mc.otm.storage.StorageStackType diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt index 08b8b86bb..1559d828e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt @@ -9,11 +9,11 @@ import net.minecraftforge.common.util.INBTSerializable import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.extractEnergy import ru.dbotthepony.mc.otm.capability.receiveEnergy -import ru.dbotthepony.mc.otm.core.Decimal -import ru.dbotthepony.mc.otm.core.getDecimal -import ru.dbotthepony.mc.otm.core.getItemStack +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.getDecimal +import ru.dbotthepony.mc.otm.core.nbt.getItemStack import ru.dbotthepony.mc.otm.core.ifPresentK -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.network.FieldSynchronizer import ru.dbotthepony.mc.otm.registry.StatNames import ru.dbotthepony.mc.otm.triggers.AndroidBatteryTrigger diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt index 0da6d774e..e3d73b061 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt @@ -17,11 +17,11 @@ import ru.dbotthepony.mc.otm.ConciseBalanceValues import ru.dbotthepony.mc.otm.VerboseBalanceValues import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection -import ru.dbotthepony.mc.otm.core.Decimal -import ru.dbotthepony.mc.otm.core.defineDecimal -import ru.dbotthepony.mc.otm.core.map -import ru.dbotthepony.mc.otm.core.mapIf -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.defineDecimal +import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.nbt.mapIf +import ru.dbotthepony.mc.otm.core.nbt.set sealed class BlockEnergyStorageImpl( protected val listener: () -> Unit, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt index 5deb39c5f..edd032081 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt @@ -4,10 +4,9 @@ import net.minecraft.ChatFormatting import net.minecraft.network.chat.Component import net.minecraftforge.energy.IEnergyStorage import ru.dbotthepony.mc.otm.capability.FlowDirection -import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.core.formatPower -import java.math.BigInteger +import ru.dbotthepony.mc.otm.core.util.formatPower sealed interface IEnergyStorageImpl { val maxInput: Decimal? diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt index e8241fd3a..9f3853a0c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt @@ -2,8 +2,8 @@ package ru.dbotthepony.mc.otm.capability.energy import net.minecraftforge.energy.IEnergyStorage import ru.dbotthepony.mc.otm.capability.FlowDirection -import ru.dbotthepony.mc.otm.core.Decimal -import ru.dbotthepony.mc.otm.core.RGBAColor +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.RGBAColor import java.math.BigInteger import kotlin.math.roundToInt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt index 8e9331612..3a4708335 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt @@ -14,9 +14,9 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy import ru.dbotthepony.mc.otm.capability.isMekanismLoaded import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper -import ru.dbotthepony.mc.otm.core.Decimal -import ru.dbotthepony.mc.otm.core.map -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.tagNotNull sealed class ItemEnergyStorageImpl( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterStorage.kt index dc70b2142..c8544371f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterStorage.kt @@ -3,8 +3,8 @@ package ru.dbotthepony.mc.otm.capability.matter import net.minecraftforge.common.capabilities.ICapabilityProvider import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.FlowDirection -import ru.dbotthepony.mc.otm.core.Decimal -import ru.dbotthepony.mc.otm.core.RGBAColor +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.orNull import kotlin.math.roundToInt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IPatternStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IPatternStorage.kt index 4429e70e9..087d02a65 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IPatternStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IPatternStorage.kt @@ -1,10 +1,9 @@ package ru.dbotthepony.mc.otm.capability.matter -import net.minecraft.util.Mth import net.minecraft.world.item.Item import net.minecraftforge.common.capabilities.ICapabilityProvider import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.core.RGBAColor +import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.orNull import java.util.* import java.util.function.Predicate diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt index 420c03643..80482af86 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt @@ -6,8 +6,8 @@ import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.ConciseBalanceValues import ru.dbotthepony.mc.otm.VerboseBalanceValues import ru.dbotthepony.mc.otm.capability.FlowDirection -import ru.dbotthepony.mc.otm.core.Decimal -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.nbt.set open class MatterStorageImpl @JvmOverloads constructor( protected val listener: Runnable?, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/PatternState.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/PatternState.kt index c53bcc134..c1c17a410 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/PatternState.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/PatternState.kt @@ -9,6 +9,8 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.core.* +import ru.dbotthepony.mc.otm.core.nbt.contains +import ru.dbotthepony.mc.otm.core.nbt.set import java.util.* sealed interface IPatternState { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/ReplicationTask.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/ReplicationTask.kt index 0dd3991d9..b93b12d7f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/ReplicationTask.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/ReplicationTask.kt @@ -10,7 +10,7 @@ import net.minecraft.world.item.Items import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.core.readItemType import ru.dbotthepony.mc.otm.core.registryName -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.writeItemType import java.util.UUID diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt index d3ae061e9..cde8acdc9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.client import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.systems.RenderSystem -import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.KeyMapping import net.minecraftforge.client.event.RegisterKeyMappingsEvent import net.minecraftforge.client.event.RenderGuiEvent @@ -14,7 +13,7 @@ import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.render.drawRect import ru.dbotthepony.mc.otm.client.render.is3DContext -import ru.dbotthepony.mc.otm.core.RGBAColor +import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.network.ActivateAndroidFeaturePacket import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel import kotlin.math.roundToInt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt index 7476fed2b..4ab602abd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt @@ -16,7 +16,10 @@ import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.render.TextAlign import ru.dbotthepony.mc.otm.client.render.drawAligned import ru.dbotthepony.mc.otm.client.render.drawArc -import ru.dbotthepony.mc.otm.core.* +import ru.dbotthepony.mc.otm.core.math.RGBAColor +import ru.dbotthepony.mc.otm.core.math.angleDifference +import ru.dbotthepony.mc.otm.core.math.normalizeAngle +import ru.dbotthepony.mc.otm.core.util.formatTickDuration import ru.dbotthepony.mc.otm.milliTimeD import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel import ru.dbotthepony.mc.otm.network.SwitchAndroidFeaturePacket @@ -206,8 +209,8 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon event.poseStack, minecraft.window.guiScaledWidth / 2f, minecraft.window.guiScaledHeight / 2f, - linearInterpolation(lastSelectProgressGlobal, size, size * 1.2f), - linearInterpolation(lastSelectProgressGlobal, size * 0.3f, size * 0.4f), + ru.dbotthepony.mc.otm.core.math.linearInterpolation(lastSelectProgressGlobal, size, size * 1.2f), + ru.dbotthepony.mc.otm.core.math.linearInterpolation(lastSelectProgressGlobal, size * 0.3f, size * 0.4f), startDegree = lastSelectedDegree!!, endDegree = lastSelectedDegree!! + degreePerSlice diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt index bde02c326..5186062c4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt @@ -27,7 +27,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.Panel2Widget import ru.dbotthepony.mc.otm.compat.InventoryScrollPacket import ru.dbotthepony.mc.otm.compat.cos.isCosmeticArmorScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.core.integerDivisionUp +import ru.dbotthepony.mc.otm.core.math.integerDivisionUp import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.network.MenuNetworkChannel import ru.dbotthepony.mc.otm.registry.AndroidFeatures diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index 9e91f0ade..d94391adf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -21,8 +21,8 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.render.* -import ru.dbotthepony.mc.otm.core.RGBAColor -import ru.dbotthepony.mc.otm.core.formatPower +import ru.dbotthepony.mc.otm.core.math.RGBAColor +import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.core.ifPresentK import java.util.* import kotlin.math.ceil diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt index 55cb45618..953f95f17 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt @@ -12,8 +12,8 @@ import net.minecraft.client.renderer.RenderType import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation import org.lwjgl.opengl.GL11.GL_ALWAYS -import ru.dbotthepony.mc.otm.core.RGBAColor -import ru.dbotthepony.mc.otm.core.linearInterpolation +import ru.dbotthepony.mc.otm.core.math.RGBAColor +import ru.dbotthepony.mc.otm.core.math.linearInterpolation import java.util.concurrent.ConcurrentHashMap sealed class AbstractMatterySprite { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt index 1baf4bc9a..9edcc8c87 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt @@ -10,7 +10,14 @@ import net.minecraft.network.chat.Component import net.minecraft.util.FormattedCharSequence import org.joml.Matrix4f import org.joml.Vector3f -import ru.dbotthepony.mc.otm.core.* +import ru.dbotthepony.mc.otm.core.math.IAngle +import ru.dbotthepony.mc.otm.core.math.RGBAColor +import ru.dbotthepony.mc.otm.core.math.Vector +import ru.dbotthepony.mc.otm.core.math.rotateAroundPoint +import ru.dbotthepony.mc.otm.core.math.rotateAroundThis +import ru.dbotthepony.mc.otm.core.math.times +import ru.dbotthepony.mc.otm.core.math.translation +import ru.dbotthepony.mc.otm.core.math.unaryMinus import kotlin.math.roundToInt val tesselator: Tesselator get() = Tesselator.getInstance() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GlitchRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GlitchRenderer.kt index 6910fe611..f1a970036 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GlitchRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GlitchRenderer.kt @@ -17,7 +17,7 @@ import org.joml.Matrix4f import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.core.linearInterpolation +import ru.dbotthepony.mc.otm.core.math.linearInterpolation import ru.dbotthepony.mc.otm.milliTime import java.lang.ref.WeakReference import kotlin.math.absoluteValue diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt index 72d8c4dd8..f26184b61 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt @@ -12,7 +12,7 @@ import org.joml.Matrix4f import org.lwjgl.opengl.GL11.GL_ALWAYS import org.lwjgl.opengl.GL11.GL_LESS import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.core.RGBAColor +import ru.dbotthepony.mc.otm.core.math.RGBAColor import java.util.* import kotlin.collections.ArrayDeque import kotlin.math.PI diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ShockwaveRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ShockwaveRenderer.kt index 1ba1d357f..4d1a8b57c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ShockwaveRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ShockwaveRenderer.kt @@ -8,12 +8,12 @@ import net.minecraft.client.renderer.GameRenderer import net.minecraftforge.client.event.RenderLevelStageEvent import org.lwjgl.opengl.GL11.GL_LESS import ru.dbotthepony.mc.otm.ServerConfig -import ru.dbotthepony.mc.otm.core.Vector -import ru.dbotthepony.mc.otm.core.component1 -import ru.dbotthepony.mc.otm.core.component2 -import ru.dbotthepony.mc.otm.core.component3 -import ru.dbotthepony.mc.otm.core.linearInterpolation -import ru.dbotthepony.mc.otm.core.rotateX +import ru.dbotthepony.mc.otm.core.math.Vector +import ru.dbotthepony.mc.otm.core.math.component1 +import ru.dbotthepony.mc.otm.core.math.component2 +import ru.dbotthepony.mc.otm.core.math.component3 +import ru.dbotthepony.mc.otm.core.math.linearInterpolation +import ru.dbotthepony.mc.otm.core.math.rotateX import ru.dbotthepony.mc.otm.network.ShockwaveEffectPacket import ru.dbotthepony.mc.otm.secondTimeD import kotlin.math.PI diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SpriteType.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SpriteType.kt index 677e6a132..18149aa40 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SpriteType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SpriteType.kt @@ -5,6 +5,7 @@ import com.google.gson.JsonPrimitive import com.google.gson.JsonSyntaxException import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set enum class SpriteType { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt index ef8f5da50..72babc852 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt @@ -14,7 +14,7 @@ import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel import ru.dbotthepony.mc.otm.core.get -import ru.dbotthepony.mc.otm.core.rotateY +import ru.dbotthepony.mc.otm.core.math.rotateY import kotlin.math.PI abstract class BankRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt index 12c565310..ea28c7fb4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt @@ -17,7 +17,17 @@ import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.* -import ru.dbotthepony.mc.otm.core.* +import ru.dbotthepony.mc.otm.core.math.RGBAColor +import ru.dbotthepony.mc.otm.core.math.VECTOR_FORWARD +import ru.dbotthepony.mc.otm.core.math.VECTOR_RIGHT +import ru.dbotthepony.mc.otm.core.math.VECTOR_UP +import ru.dbotthepony.mc.otm.core.math.Vector +import ru.dbotthepony.mc.otm.core.math.asMutableAngle +import ru.dbotthepony.mc.otm.core.math.asVector +import ru.dbotthepony.mc.otm.core.math.minus +import ru.dbotthepony.mc.otm.core.math.rotateAroundAxis +import ru.dbotthepony.mc.otm.core.math.times +import ru.dbotthepony.mc.otm.core.util.formatMatter import ru.dbotthepony.mc.otm.registry.MItems import kotlin.math.PI import kotlin.math.pow diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/EnergyCounterRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/EnergyCounterRenderer.kt index 95d5fdd75..008242080 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/EnergyCounterRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/EnergyCounterRenderer.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.client.render.blockentity import com.mojang.blaze3d.vertex.PoseStack -import net.minecraft.client.Minecraft import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.client.renderer.blockentity.BlockEntityRenderer import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider @@ -11,10 +10,10 @@ import ru.dbotthepony.mc.otm.block.EnergyCounterBlock import ru.dbotthepony.mc.otm.block.entity.EnergyCounterBlockEntity import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.* -import ru.dbotthepony.mc.otm.core.RGBAColor -import ru.dbotthepony.mc.otm.core.asAngle -import ru.dbotthepony.mc.otm.core.formatPower -import ru.dbotthepony.mc.otm.core.times +import ru.dbotthepony.mc.otm.core.math.RGBAColor +import ru.dbotthepony.mc.otm.core.math.asAngle +import ru.dbotthepony.mc.otm.core.util.formatPower +import ru.dbotthepony.mc.otm.core.math.times import kotlin.math.PI class EnergyCounterRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt index fc56109ee..140842d68 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.client.render.blockentity import com.mojang.blaze3d.vertex.* -import net.minecraft.client.Minecraft import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.client.renderer.RenderType import net.minecraft.client.renderer.blockentity.BeaconRenderer @@ -20,6 +19,17 @@ import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.core.* +import ru.dbotthepony.mc.otm.core.math.RGBAColor +import ru.dbotthepony.mc.otm.core.math.VECTOR_DOWN +import ru.dbotthepony.mc.otm.core.math.VECTOR_FORWARD +import ru.dbotthepony.mc.otm.core.math.VECTOR_RIGHT +import ru.dbotthepony.mc.otm.core.math.VECTOR_UP +import ru.dbotthepony.mc.otm.core.math.Vector +import ru.dbotthepony.mc.otm.core.math.asAngle +import ru.dbotthepony.mc.otm.core.math.plus +import ru.dbotthepony.mc.otm.core.math.rotateAroundAxis +import ru.dbotthepony.mc.otm.core.math.times +import ru.dbotthepony.mc.otm.core.util.formatMatter import kotlin.math.PI @Suppress("PrivatePropertyName") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReplicatorRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReplicatorRenderer.kt index 3b1e7b8ce..73bc49d0d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReplicatorRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReplicatorRenderer.kt @@ -16,12 +16,12 @@ import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.render.lockBlendFunc -import ru.dbotthepony.mc.otm.core.component1 -import ru.dbotthepony.mc.otm.core.component2 -import ru.dbotthepony.mc.otm.core.component3 +import ru.dbotthepony.mc.otm.core.math.component1 +import ru.dbotthepony.mc.otm.core.math.component2 +import ru.dbotthepony.mc.otm.core.math.component3 import ru.dbotthepony.mc.otm.core.get -import ru.dbotthepony.mc.otm.core.normalizeAngleDeg -import ru.dbotthepony.mc.otm.core.rotateYDegrees +import ru.dbotthepony.mc.otm.core.math.normalizeAngleDeg +import ru.dbotthepony.mc.otm.core.math.rotateYDegrees import ru.dbotthepony.mc.otm.isPaused class MatterReplicatorRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/entity/PlasmaProjectileRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/entity/PlasmaProjectileRenderer.kt index 34c8917fd..b13fb7963 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/entity/PlasmaProjectileRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/entity/PlasmaProjectileRenderer.kt @@ -9,9 +9,8 @@ import ru.dbotthepony.mc.otm.client.render.TextAlign import ru.dbotthepony.mc.otm.client.render.drawAligned import ru.dbotthepony.mc.otm.client.render.rotateAroundPoint import ru.dbotthepony.mc.otm.client.render.translation -import ru.dbotthepony.mc.otm.core.Angle +import ru.dbotthepony.mc.otm.core.math.Angle import ru.dbotthepony.mc.otm.entity.PlasmaProjectile -import kotlin.math.PI class PlasmaProjectileRenderer(context: EntityRendererProvider.Context) : EntityRenderer(context) { override fun getTextureLocation(p_114482_: PlasmaProjectile): ResourceLocation { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt index 6ea310399..aafad7d12 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt @@ -28,12 +28,11 @@ import ru.dbotthepony.mc.otm.client.render.drawRect import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.ButtonPanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel -import ru.dbotthepony.mc.otm.core.RGBAColor +import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.menu.AndroidStationMenu import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel import ru.dbotthepony.mc.otm.network.AndroidResearchRequestPacket -import ru.dbotthepony.mc.otm.registry.MRegistry import java.util.* import kotlin.collections.ArrayList import kotlin.properties.Delegates diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/DriveViewerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/DriveViewerScreen.kt index 2eada543a..eeeffa51c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/DriveViewerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/DriveViewerScreen.kt @@ -8,7 +8,7 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.CheckBoxLabelInputPanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel -import ru.dbotthepony.mc.otm.core.integerDivisionDown +import ru.dbotthepony.mc.otm.core.math.integerDivisionDown import ru.dbotthepony.mc.otm.item.PortableCondensationDriveItem import ru.dbotthepony.mc.otm.menu.DriveViewerMenu import yalter.mousetweaks.api.MouseTweaksDisableWheelTweak diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/EnergyCounterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/EnergyCounterScreen.kt index 01fd8a4f7..913440b37 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/EnergyCounterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/EnergyCounterScreen.kt @@ -5,7 +5,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.ButtonPanel -import ru.dbotthepony.mc.otm.core.formatPower +import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.menu.EnergyCounterMenu class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt index 3f5456b3e..f69f02ebe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt @@ -11,7 +11,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.LargeRectangleButtonPanel import ru.dbotthepony.mc.otm.client.setMousePos import ru.dbotthepony.mc.otm.client.shouldOpenVanillaInventory -import ru.dbotthepony.mc.otm.core.integerDivisionDown +import ru.dbotthepony.mc.otm.core.math.integerDivisionDown import ru.dbotthepony.mc.otm.menu.ExoPackInventoryMenu import ru.dbotthepony.mc.otm.network.ExoSuitMenuOpen import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ItemMonitorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ItemMonitorScreen.kt index 9e8cdc170..4733cb7ab 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ItemMonitorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ItemMonitorScreen.kt @@ -17,9 +17,9 @@ import ru.dbotthepony.mc.otm.client.screen.panels.buttons.SmallEnumRectangleButt import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel import ru.dbotthepony.mc.otm.core.asGetterSetter -import ru.dbotthepony.mc.otm.core.integerDivisionDown -import ru.dbotthepony.mc.otm.core.formatReadableNumber -import ru.dbotthepony.mc.otm.core.formatSiComponent +import ru.dbotthepony.mc.otm.core.math.integerDivisionDown +import ru.dbotthepony.mc.otm.core.util.formatReadableNumber +import ru.dbotthepony.mc.otm.core.util.formatSiComponent import ru.dbotthepony.mc.otm.menu.ItemMonitorMenu import ru.dbotthepony.mc.otm.storage.ITEM_STORAGE import yalter.mousetweaks.api.MouseTweaksDisableWheelTweak diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterPanelScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterPanelScreen.kt index ff9f18e3e..15af82304 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterPanelScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterPanelScreen.kt @@ -11,7 +11,7 @@ import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.ButtonPanel import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.core.integerDivisionDown +import ru.dbotthepony.mc.otm.core.math.integerDivisionDown import ru.dbotthepony.mc.otm.menu.MatterPanelMenu import ru.dbotthepony.mc.otm.menu.ReplicationRequestPacket import ru.dbotthepony.mc.otm.network.MenuNetworkChannel 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 01a6a3f8c..c1ca6606b 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 @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.client.screen import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack -import it.unimi.dsi.fastutil.ints.Int2ObjectAVLTreeMap import it.unimi.dsi.fastutil.ints.Int2ObjectFunction import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import net.minecraft.ChatFormatting @@ -21,7 +20,7 @@ import ru.dbotthepony.mc.otm.ClientConfig import ru.dbotthepony.mc.otm.client.moveMousePosScaled import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.compat.cos.CosmeticToggleButton -import ru.dbotthepony.mc.otm.core.integerDivisionDown +import ru.dbotthepony.mc.otm.core.math.integerDivisionDown import ru.dbotthepony.mc.otm.menu.MatteryMenu import java.util.Collections diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StoragePowerSupplierScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StoragePowerSupplierScreen.kt index 34b515144..e3bc34cef 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StoragePowerSupplierScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StoragePowerSupplierScreen.kt @@ -5,7 +5,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.widget.HorizontalPowerGaugePanel -import ru.dbotthepony.mc.otm.core.formatPower +import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.menu.StoragePowerSupplierMenu diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/AbstractSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/AbstractSlotPanel.kt index 497656317..701e5c21e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/AbstractSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/AbstractSlotPanel.kt @@ -10,7 +10,7 @@ import org.lwjgl.opengl.GL11 import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.client.screen.MatteryScreen -import ru.dbotthepony.mc.otm.core.RGBAColor +import ru.dbotthepony.mc.otm.core.math.RGBAColor abstract class AbstractSlotPanel> @JvmOverloads constructor( screen: S, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/AnalogScrollBarPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/AnalogScrollBarPanel.kt index 226cbac40..38cb1b5f4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/AnalogScrollBarPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/AnalogScrollBarPanel.kt @@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.core.linearInterpolation +import ru.dbotthepony.mc.otm.core.math.linearInterpolation import ru.dbotthepony.mc.otm.milliTimeD import kotlin.math.roundToInt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt index e9292ea60..07ab355b8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt @@ -16,10 +16,10 @@ import ru.dbotthepony.mc.otm.client.render.drawAligned import ru.dbotthepony.mc.otm.client.render.drawScaledAligned import ru.dbotthepony.mc.otm.client.render.sprite import ru.dbotthepony.mc.otm.client.render.render -import ru.dbotthepony.mc.otm.core.RGBAColor +import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.core.formatTickDuration -import ru.dbotthepony.mc.otm.core.integerDivisionDown +import ru.dbotthepony.mc.otm.core.util.formatTickDuration +import ru.dbotthepony.mc.otm.core.math.integerDivisionDown import java.util.stream.Collectors open class EffectListPanel @JvmOverloads constructor( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt index bd701138d..9c506ab41 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt @@ -3,10 +3,8 @@ package ru.dbotthepony.mc.otm.client.screen.panels import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component -import ru.dbotthepony.mc.otm.client.render.clearDepth import ru.dbotthepony.mc.otm.core.TextComponent -import ru.dbotthepony.mc.otm.core.RGBAColor -import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.core.math.RGBAColor open class Label @JvmOverloads constructor( screen: S, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/ButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/ButtonPanel.kt index 1b4b32b51..f376d3cab 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/ButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/ButtonPanel.kt @@ -8,7 +8,7 @@ import ru.dbotthepony.mc.otm.client.render.TextAlign import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.render.drawAligned import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel -import ru.dbotthepony.mc.otm.core.RGBAColor +import ru.dbotthepony.mc.otm.core.math.RGBAColor open class ButtonPanel( screen: S, 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 18efc0375..a34012c68 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 @@ -13,7 +13,7 @@ import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.render.tesselator import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.core.formatMatterLevel +import ru.dbotthepony.mc.otm.core.util.formatMatterLevel import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.nanoTime import kotlin.math.absoluteValue diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt index 5cf9f63a3..194ef0004 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt @@ -6,7 +6,7 @@ import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel -import ru.dbotthepony.mc.otm.core.formatPowerLevel +import ru.dbotthepony.mc.otm.core.util.formatPowerLevel import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget open class PowerGaugePanel @JvmOverloads constructor( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt index c7d053404..b0f26e07c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt @@ -25,7 +25,7 @@ import ru.dbotthepony.mc.otm.compat.cos.CosmeticToggleButton.Companion.BUTTON_AC import ru.dbotthepony.mc.otm.compat.cos.CosmeticToggleButton.Companion.BUTTON_INACTIVE import ru.dbotthepony.mc.otm.container.awareStream import ru.dbotthepony.mc.otm.container.stream -import ru.dbotthepony.mc.otm.core.AwareItemStack +import ru.dbotthepony.mc.otm.core.collect.AwareItemStack import ru.dbotthepony.mc.otm.menu.MatterySlot import java.util.stream.Stream diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt index ddda5ccb1..3242a016c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt @@ -8,7 +8,7 @@ import net.minecraftforge.fml.ModList import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.container.awareStream import ru.dbotthepony.mc.otm.container.stream -import ru.dbotthepony.mc.otm.core.AwareItemStack +import ru.dbotthepony.mc.otm.core.collect.AwareItemStack import ru.dbotthepony.mc.otm.core.orNull import top.theillusivec4.curios.api.CuriosApi import top.theillusivec4.curios.common.inventory.CosmeticCurioSlot diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt index efd2869f0..6c2449140 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt @@ -18,7 +18,7 @@ import ru.dbotthepony.mc.otm.client.render.TextAlign import ru.dbotthepony.mc.otm.client.render.drawAligned import ru.dbotthepony.mc.otm.client.screen.panels.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel -import ru.dbotthepony.mc.otm.core.RGBAColor +import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.recipe.PlatePressRecipe diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Conversions.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Conversions.kt index b760e0242..fbf931c09 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Conversions.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Conversions.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.mc.otm.compat.mekanism import mekanism.api.math.FloatingLong -import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.math.Decimal import java.math.BigInteger private val LONG_OVERFLOW = BigInteger.valueOf(Long.MAX_VALUE) + BigInteger.valueOf(Long.MAX_VALUE) + BigInteger.TWO diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt index d2b6e4e66..fa7a627f6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt @@ -14,7 +14,7 @@ import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.isMekanismLoaded -import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.orNull import java.lang.ref.WeakReference import java.util.WeakHashMap diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/QIO.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/QIO.kt index 123bf5d3c..3c4b1ef04 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/QIO.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/QIO.kt @@ -20,7 +20,7 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.onceServer import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.isMekanismLoaded -import ru.dbotthepony.mc.otm.core.isPositive +import ru.dbotthepony.mc.otm.core.math.isPositive import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode import ru.dbotthepony.mc.otm.graph.storage.StorageNetworkGraph import ru.dbotthepony.mc.otm.storage.* diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerIterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerIterator.kt index 710757ef0..197633e58 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerIterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerIterator.kt @@ -3,8 +3,8 @@ package ru.dbotthepony.mc.otm.container import it.unimi.dsi.fastutil.objects.ObjectIterators import net.minecraft.world.Container import net.minecraft.world.item.ItemStack -import ru.dbotthepony.mc.otm.core.ContainerItemStackEntry -import ru.dbotthepony.mc.otm.core.AwareItemStack +import ru.dbotthepony.mc.otm.core.collect.ContainerItemStackEntry +import ru.dbotthepony.mc.otm.core.collect.AwareItemStack class ContainerIterator(private val container: Container, initialPosition: Int = 0) : ObjectIterators.AbstractIndexBasedListIterator(0, initialPosition), MutableListIterator { init { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerSpliterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerSpliterator.kt index 305792410..7087d6b7c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerSpliterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerSpliterator.kt @@ -4,8 +4,8 @@ import it.unimi.dsi.fastutil.objects.ObjectSpliterator import it.unimi.dsi.fastutil.objects.ObjectSpliterators import net.minecraft.world.Container import net.minecraft.world.item.ItemStack -import ru.dbotthepony.mc.otm.core.AwareItemStack -import ru.dbotthepony.mc.otm.core.ContainerItemStackEntry +import ru.dbotthepony.mc.otm.core.collect.AwareItemStack +import ru.dbotthepony.mc.otm.core.collect.ContainerItemStackEntry import java.util.stream.Stream import java.util.stream.StreamSupport diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt index bc2b1a738..6e45cb70b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt @@ -3,8 +3,8 @@ package ru.dbotthepony.mc.otm.container import net.minecraft.world.Container import net.minecraft.world.item.ItemStack import net.minecraftforge.common.capabilities.Capability -import ru.dbotthepony.mc.otm.core.iterator -import ru.dbotthepony.mc.otm.core.nonEmpty +import ru.dbotthepony.mc.otm.core.collect.iterator +import ru.dbotthepony.mc.otm.core.collect.nonEmpty operator fun Container.set(index: Int, value: ItemStack) = setItem(index, value) operator fun Container.get(index: Int): ItemStack = getItem(index) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemFilter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemFilter.kt index 25e41c726..8d55e42ba 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemFilter.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemFilter.kt @@ -11,11 +11,10 @@ import net.minecraftforge.common.util.INBTSerializable import net.minecraftforge.network.NetworkEvent import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.core.ifHas +import ru.dbotthepony.mc.otm.core.nbt.ifHas import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.network.MatteryPacket -import ru.dbotthepony.mc.otm.container.set -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.nbt.set import java.util.Arrays import java.util.LinkedList import java.util.function.Supplier diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemHandlerSpliterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemHandlerSpliterator.kt index 4482d0efc..25fc780fb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemHandlerSpliterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemHandlerSpliterator.kt @@ -4,8 +4,8 @@ import it.unimi.dsi.fastutil.objects.ObjectSpliterator import it.unimi.dsi.fastutil.objects.ObjectSpliterators import net.minecraft.world.item.ItemStack import net.minecraftforge.items.IItemHandler -import ru.dbotthepony.mc.otm.core.AwareItemStack -import ru.dbotthepony.mc.otm.core.ItemHandlerItemStackEntry +import ru.dbotthepony.mc.otm.core.collect.AwareItemStack +import ru.dbotthepony.mc.otm.core.collect.ItemHandlerItemStackEntry import java.util.* import java.util.stream.Stream import java.util.stream.StreamSupport diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt index 54ac9226f..97cdad1b9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt @@ -9,8 +9,8 @@ import net.minecraft.world.Container import kotlin.jvm.JvmOverloads import net.minecraft.world.entity.player.Player import net.minecraft.world.level.block.entity.BlockEntity -import ru.dbotthepony.mc.otm.core.ifHas -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.nbt.ifHas +import ru.dbotthepony.mc.otm.core.nbt.set import java.util.* @Suppress("UNUSED") 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 dbb2e120e..ace708971 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -8,9 +8,7 @@ import com.google.gson.JsonElement import com.google.gson.JsonObject import com.google.gson.JsonPrimitive import net.minecraft.core.BlockPos -import net.minecraft.nbt.ByteArrayTag import net.minecraft.nbt.CompoundTag -import net.minecraft.nbt.Tag import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.Entity @@ -28,8 +26,8 @@ import net.minecraftforge.items.IItemHandler import net.minecraftforge.registries.ForgeRegistries import net.minecraftforge.registries.ForgeRegistry import net.minecraftforge.registries.IForgeRegistry +import ru.dbotthepony.mc.otm.core.math.Vector import java.lang.ref.Reference -import java.lang.ref.WeakReference import java.math.BigInteger import java.util.Arrays import java.util.Spliterators @@ -38,149 +36,6 @@ import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.reflect.KProperty -/** - * Performs type check+cast and sums two numbers. - * - * Returns the same type as on input (adding Double to Float will not return Double, etc.) - */ -fun Number.dynPlus(other: Number): Number { - return when (this) { - is Float -> this + other.toFloat() - is Double -> this + other.toDouble() - is Int -> this + other.toInt() - is Long -> this + other.toLong() - is Short -> this + other.toShort() - is Byte -> this + other.toByte() - - is Decimal -> { - when (other) { - is Float -> this + other.toFloat() - is Double -> this + other.toDouble() - is Int, is Byte, is Short -> this + other.toInt() - is Long -> this + other.toLong() - is Decimal -> this + other - else -> throw IllegalStateException("I don't know what to do with ${other::class.qualifiedName} (right hand operand)") - } - } - - else -> throw IllegalStateException("I don't know what to do with ${this::class.qualifiedName} (left hand operand)") - } -} - -/** - * Performs type check+cast and subtracts two numbers. - * - * Returns the same type as on input (adding Double to Float will not return Double, etc.) - */ -fun Number.dynMinus(other: Number): Number { - return when (this) { - is Float -> this - other.toFloat() - is Double -> this - other.toDouble() - is Int -> this - other.toInt() - is Long -> this - other.toLong() - is Short -> this - other.toShort() - is Byte -> this - other.toByte() - - is Decimal -> { - when (other) { - is Float -> this - other.toFloat() - is Double -> this - other.toDouble() - is Int, is Byte, is Short -> this - other.toInt() - is Long -> this - other.toLong() - is Decimal -> this - other - else -> throw IllegalStateException("I don't know what to do with ${other::class.qualifiedName} (right hand operand)") - } - } - - else -> throw IllegalStateException("I don't know what to do with ${this::class.qualifiedName} (left hand operand)") - } -} - -/** - * Performs type check+cast and multiplies two numbers. - * - * Returns the same type as on input (adding Double to Float will not return Double, etc.) - */ -fun Number.dynTimes(other: Number): Number { - return when (this) { - is Float -> this * other.toFloat() - is Double -> this * other.toDouble() - is Int -> this * other.toInt() - is Long -> this * other.toLong() - is Short -> this * other.toShort() - is Byte -> this * other.toByte() - - is Decimal -> { - when (other) { - is Float -> this * other.toFloat() - is Double -> this * other.toDouble() - is Int, is Byte, is Short -> this * other.toInt() - is Long -> this * other.toLong() - is Decimal -> this * other - else -> throw IllegalStateException("I don't know what to do with ${other::class.qualifiedName} (right hand operand)") - } - } - - else -> throw IllegalStateException("I don't know what to do with ${this::class.qualifiedName} (left hand operand)") - } -} - -/** - * Performs type check+cast and divides two numbers. - * - * Returns the same type as on input (adding Double to Float will not return Double, etc.) - */ -fun Number.dynDiv(other: Number): Number { - return when (this) { - is Float -> this / other.toFloat() - is Double -> this / other.toDouble() - is Int -> this / other.toInt() - is Long -> this / other.toLong() - is Short -> this / other.toShort() - is Byte -> this / other.toByte() - - is Decimal -> { - when (other) { - is Float -> this / other.toFloat() - is Double -> this / other.toDouble() - is Int, is Byte, is Short -> this / other.toInt() - is Long -> this / other.toLong() - is Decimal -> this / other - else -> throw IllegalStateException("I don't know what to do with ${other::class.qualifiedName} (right hand operand)") - } - } - - else -> throw IllegalStateException("I don't know what to do with ${this::class.qualifiedName} (left hand operand)") - } -} - -val Number.isFractional get() = this is Float || this is Double || this is Decimal -val Number.isWhole get() = !isFractional - -fun Number.toDecimal(): Decimal { - return when (this) { - is Decimal -> this - is Float -> Decimal(this) - is Double -> Decimal(this) - is Int -> Decimal(this) - is Byte -> Decimal(this) - is Short -> Decimal(this) - is Long -> Decimal(this) - else -> throw ClassCastException("Can not turn $this into ImpreciseFraction") - } -} - -fun BigInteger(tag: Tag?): BigInteger { - if (tag !is ByteArrayTag) - return BigInteger.ZERO - - return BigInteger(tag.asByteArray) -} - -fun BigInteger.serializeNBT(): ByteArrayTag { - return ByteArrayTag(toByteArray()) -} - fun FriendlyByteBuf.writeBigInteger(value: BigInteger) { writeByteArray(value.toByteArray()) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/LevelExt.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/LevelExt.kt index 3342aefe9..38d70d4b8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/LevelExt.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/LevelExt.kt @@ -3,6 +3,8 @@ package ru.dbotthepony.mc.otm.core import net.minecraft.world.entity.Entity import net.minecraft.world.level.Level import net.minecraft.world.phys.AABB +import ru.dbotthepony.mc.otm.core.math.Vector +import ru.dbotthepony.mc.otm.core.math.minus import java.util.LinkedList import java.util.function.Predicate import kotlin.math.pow diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/AwareItemStack.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/AwareItemStack.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/mc/otm/core/AwareItemStack.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/AwareItemStack.kt index 3222c9e15..cc60cfe9d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/AwareItemStack.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/AwareItemStack.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.core +package ru.dbotthepony.mc.otm.core.collect import net.minecraft.world.Container import net.minecraft.world.entity.player.Inventory @@ -7,6 +7,7 @@ import net.minecraft.world.item.enchantment.EnchantmentHelper.hasBindingCurse import net.minecraftforge.items.IItemHandler import ru.dbotthepony.mc.otm.container.get import ru.dbotthepony.mc.otm.container.set +import ru.dbotthepony.mc.otm.core.get /** * Allows to see the contents of container and extract the item from it diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/CapabilityIterators.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/CapabilityIterators.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/mc/otm/core/CapabilityIterators.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/CapabilityIterators.kt index a04c6358b..eb4760384 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/CapabilityIterators.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/CapabilityIterators.kt @@ -1,9 +1,10 @@ -package ru.dbotthepony.mc.otm.core +package ru.dbotthepony.mc.otm.core.collect import net.minecraft.world.Container import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ICapabilityProvider import ru.dbotthepony.mc.otm.container.iterator +import ru.dbotthepony.mc.otm.core.ifPresentK open class CapabilityIterator

(protected open val parent: Iterator

, private val cap: Capability) : Iterator> { private var provider: P? = null diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/ConditionalSet.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ConditionalSet.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/mc/otm/core/ConditionalSet.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ConditionalSet.kt index 0b75642e9..04e3ff6e7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/ConditionalSet.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ConditionalSet.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.core +package ru.dbotthepony.mc.otm.core.collect class ConditionalSet : AbstractSet { // method without boxing diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/ConditionalSupplierSet.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ConditionalSupplierSet.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/mc/otm/core/ConditionalSupplierSet.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ConditionalSupplierSet.kt index f3454ceb0..9e55865fd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/ConditionalSupplierSet.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ConditionalSupplierSet.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.core +package ru.dbotthepony.mc.otm.core.collect class ConditionalSupplierSet : AbstractSet { // method without boxing diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/ItemStackIterators.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ItemStackIterators.kt similarity index 83% rename from src/main/kotlin/ru/dbotthepony/mc/otm/core/ItemStackIterators.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ItemStackIterators.kt index e64500e50..f3da0a85d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/ItemStackIterators.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ItemStackIterators.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.core +package ru.dbotthepony.mc.otm.core.collect import net.minecraft.world.item.ItemStack diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/ListSet.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ListSet.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/mc/otm/core/ListSet.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ListSet.kt index 449e5b585..fd8cdb104 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/ListSet.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ListSet.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.core +package ru.dbotthepony.mc.otm.core.collect import com.google.common.collect.ImmutableList import com.google.common.collect.ImmutableSet @@ -56,4 +56,4 @@ class ListSet(private val list: ImmutableList) : List, Set, RandomAc override fun subList(fromIndex: Int, toIndex: Int): List { return list.subList(fromIndex, toIndex) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/PredicateIterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/PredicateIterator.kt similarity index 97% rename from src/main/kotlin/ru/dbotthepony/mc/otm/core/PredicateIterator.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/PredicateIterator.kt index 92ba48e04..ff7c47461 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/PredicateIterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/PredicateIterator.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.core +package ru.dbotthepony.mc.otm.core.collect import java.util.function.Consumer import java.util.function.Predicate diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/ProxiedMap.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ProxiedMap.kt similarity index 99% rename from src/main/kotlin/ru/dbotthepony/mc/otm/core/ProxiedMap.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ProxiedMap.kt index 2c4840fd7..eae95106b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/ProxiedMap.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ProxiedMap.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.core +package ru.dbotthepony.mc.otm.core.collect abstract class ProxiedMap(protected val backingMap: MutableMap = HashMap()) : MutableMap { protected abstract fun onClear() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/SlotIterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/SlotIterator.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/mc/otm/core/SlotIterator.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/SlotIterator.kt index e8bcb616c..9db7a4561 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/SlotIterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/SlotIterator.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.core +package ru.dbotthepony.mc.otm.core.collect import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.inventory.Slot diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/SupplierList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/SupplierList.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/mc/otm/core/SupplierList.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/SupplierList.kt index aa47888fc..82c637fcf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/SupplierList.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/SupplierList.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.core +package ru.dbotthepony.mc.otm.core.collect import java.util.function.Supplier import java.util.stream.Stream diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/SupplierMap.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/SupplierMap.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/mc/otm/core/SupplierMap.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/SupplierMap.kt index 3b15b9c08..da61f08b2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/SupplierMap.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/SupplierMap.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.core +package ru.dbotthepony.mc.otm.core.collect import com.google.common.collect.ImmutableSet import java.util.stream.Stream diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/UUIDIntModifiersMap.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/UUIDIntModifiersMap.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/mc/otm/core/UUIDIntModifiersMap.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/UUIDIntModifiersMap.kt index 1a566fe4d..7f7a4174a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/UUIDIntModifiersMap.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/UUIDIntModifiersMap.kt @@ -1,8 +1,9 @@ -package ru.dbotthepony.mc.otm.core +package ru.dbotthepony.mc.otm.core.collect import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.ListTag import net.minecraftforge.common.util.INBTSerializable +import ru.dbotthepony.mc.otm.core.nbt.contains import java.util.UUID /** diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Decimal.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Decimal.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/core/Decimal.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Decimal.kt index ddd2f602b..cd3c96913 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Decimal.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Decimal.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.core +package ru.dbotthepony.mc.otm.core.math import net.minecraft.nbt.ByteArrayTag import net.minecraft.nbt.CompoundTag @@ -7,6 +7,10 @@ import net.minecraft.nbt.Tag import net.minecraft.network.FriendlyByteBuf import net.minecraftforge.common.ForgeConfigSpec import ru.dbotthepony.mc.otm.ObservedConfigValue +import ru.dbotthepony.mc.otm.core.util.readDouble +import ru.dbotthepony.mc.otm.core.util.readVarIntLE +import ru.dbotthepony.mc.otm.core.util.writeDouble +import ru.dbotthepony.mc.otm.core.util.writeVarIntLE import java.io.InputStream import java.io.OutputStream import java.math.BigDecimal diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/EuclidMath.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/EuclidMath.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/core/EuclidMath.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/math/EuclidMath.kt index 1c9d2d084..ce084ea57 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/EuclidMath.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/EuclidMath.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.core +package ru.dbotthepony.mc.otm.core.math import com.mojang.blaze3d.vertex.PoseStack import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap @@ -11,7 +11,6 @@ import org.joml.Matrix3f import org.joml.Matrix4f import org.joml.Quaternionf import org.joml.Vector3f -import java.lang.Math.toDegrees import java.lang.ref.SoftReference import kotlin.math.* @@ -282,7 +281,8 @@ interface IAngle { } } -data class Angle(override val pitch: Double = 0.0, override val yaw: Double = 0.0, override val roll: Double = 0.0) : IAngle { +data class Angle(override val pitch: Double = 0.0, override val yaw: Double = 0.0, override val roll: Double = 0.0) : + IAngle { companion object { const val PI_HALF = Math.PI / 2.0 @@ -300,7 +300,8 @@ data class Angle(override val pitch: Double = 0.0, override val yaw: Double = 0. } } -data class MutableAngle(override var pitch: Double = 0.0, override var yaw: Double = 0.0, override var roll: Double = 0.0) : IAngle { +data class MutableAngle(override var pitch: Double = 0.0, override var yaw: Double = 0.0, override var roll: Double = 0.0) : + IAngle { companion object { fun deg(pitch: Double, yaw: Double, roll: Double): MutableAngle { return MutableAngle(Math.toRadians(pitch), Math.toRadians(yaw), Math.toRadians(roll)) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Math.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Math.kt similarity index 97% rename from src/main/kotlin/ru/dbotthepony/mc/otm/core/Math.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Math.kt index a5955aa08..248380d83 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Math.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Math.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.core +package ru.dbotthepony.mc.otm.core.math import java.math.BigDecimal import java.math.BigInteger diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/MatrixExt.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/MatrixExt.kt similarity index 86% rename from src/main/kotlin/ru/dbotthepony/mc/otm/core/MatrixExt.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/math/MatrixExt.kt index e6e1281fc..f12e17d7d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/MatrixExt.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/MatrixExt.kt @@ -1,12 +1,19 @@ @file:Suppress("unused") -package ru.dbotthepony.mc.otm.core +package ru.dbotthepony.mc.otm.core.math import org.joml.Matrix3f import org.joml.Matrix4f import org.joml.Vector3f import org.joml.Vector4f +import ru.dbotthepony.mc.otm.core.math.IAngle +import ru.dbotthepony.mc.otm.core.math.Vector +import ru.dbotthepony.mc.otm.core.math.asVector3f +import ru.dbotthepony.mc.otm.core.math.rotateAroundThis +import ru.dbotthepony.mc.otm.core.math.rotation +import ru.dbotthepony.mc.otm.core.math.rotationDegrees +import ru.dbotthepony.mc.otm.core.math.unaryMinus fun Matrix4f.rotate(angle: IAngle): Matrix4f { mul(angle.rotationXYZW()) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/NumberExt.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/NumberExt.kt new file mode 100644 index 000000000..8c4c3dd64 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/NumberExt.kt @@ -0,0 +1,147 @@ +package ru.dbotthepony.mc.otm.core.math + +import net.minecraft.nbt.ByteArrayTag +import net.minecraft.nbt.Tag +import java.math.BigInteger + +/** + * Performs type check+cast and sums two numbers. + * + * Returns the same type as on input (adding Double to Float will not return Double, etc.) + */ +fun Number.dynPlus(other: Number): Number { + return when (this) { + is Float -> this + other.toFloat() + is Double -> this + other.toDouble() + is Int -> this + other.toInt() + is Long -> this + other.toLong() + is Short -> this + other.toShort() + is Byte -> this + other.toByte() + + is Decimal -> { + when (other) { + is Float -> this + other.toFloat() + is Double -> this + other.toDouble() + is Int, is Byte, is Short -> this + other.toInt() + is Long -> this + other.toLong() + is Decimal -> this + other + else -> throw IllegalStateException("I don't know what to do with ${other::class.qualifiedName} (right hand operand)") + } + } + + else -> throw IllegalStateException("I don't know what to do with ${this::class.qualifiedName} (left hand operand)") + } +} + +/** + * Performs type check+cast and subtracts two numbers. + * + * Returns the same type as on input (adding Double to Float will not return Double, etc.) + */ +fun Number.dynMinus(other: Number): Number { + return when (this) { + is Float -> this - other.toFloat() + is Double -> this - other.toDouble() + is Int -> this - other.toInt() + is Long -> this - other.toLong() + is Short -> this - other.toShort() + is Byte -> this - other.toByte() + + is Decimal -> { + when (other) { + is Float -> this - other.toFloat() + is Double -> this - other.toDouble() + is Int, is Byte, is Short -> this - other.toInt() + is Long -> this - other.toLong() + is Decimal -> this - other + else -> throw IllegalStateException("I don't know what to do with ${other::class.qualifiedName} (right hand operand)") + } + } + + else -> throw IllegalStateException("I don't know what to do with ${this::class.qualifiedName} (left hand operand)") + } +} + +/** + * Performs type check+cast and multiplies two numbers. + * + * Returns the same type as on input (adding Double to Float will not return Double, etc.) + */ +fun Number.dynTimes(other: Number): Number { + return when (this) { + is Float -> this * other.toFloat() + is Double -> this * other.toDouble() + is Int -> this * other.toInt() + is Long -> this * other.toLong() + is Short -> this * other.toShort() + is Byte -> this * other.toByte() + + is Decimal -> { + when (other) { + is Float -> this * other.toFloat() + is Double -> this * other.toDouble() + is Int, is Byte, is Short -> this * other.toInt() + is Long -> this * other.toLong() + is Decimal -> this * other + else -> throw IllegalStateException("I don't know what to do with ${other::class.qualifiedName} (right hand operand)") + } + } + + else -> throw IllegalStateException("I don't know what to do with ${this::class.qualifiedName} (left hand operand)") + } +} + +/** + * Performs type check+cast and divides two numbers. + * + * Returns the same type as on input (adding Double to Float will not return Double, etc.) + */ +fun Number.dynDiv(other: Number): Number { + return when (this) { + is Float -> this / other.toFloat() + is Double -> this / other.toDouble() + is Int -> this / other.toInt() + is Long -> this / other.toLong() + is Short -> this / other.toShort() + is Byte -> this / other.toByte() + + is Decimal -> { + when (other) { + is Float -> this / other.toFloat() + is Double -> this / other.toDouble() + is Int, is Byte, is Short -> this / other.toInt() + is Long -> this / other.toLong() + is Decimal -> this / other + else -> throw IllegalStateException("I don't know what to do with ${other::class.qualifiedName} (right hand operand)") + } + } + + else -> throw IllegalStateException("I don't know what to do with ${this::class.qualifiedName} (left hand operand)") + } +} + +val Number.isFractional get() = this is Float || this is Double || this is Decimal +val Number.isWhole get() = !isFractional +fun Number.toDecimal(): Decimal { + return when (this) { + is Decimal -> this + is Float -> Decimal(this) + is Double -> Decimal(this) + is Int -> Decimal(this) + is Byte -> Decimal(this) + is Short -> Decimal(this) + is Long -> Decimal(this) + else -> throw ClassCastException("Can not turn $this into ImpreciseFraction") + } +} + +fun BigInteger(tag: Tag?): BigInteger { + if (tag !is ByteArrayTag) + return BigInteger.ZERO + + return BigInteger(tag.asByteArray) +} + +fun BigInteger.serializeNBT(): ByteArrayTag { + return ByteArrayTag(toByteArray()) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/RGBAColor.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/RGBAColor.kt similarity index 99% rename from src/main/kotlin/ru/dbotthepony/mc/otm/core/RGBAColor.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/math/RGBAColor.kt index 44e049b2a..5aff0aa32 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/RGBAColor.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/RGBAColor.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.core +package ru.dbotthepony.mc.otm.core.math import com.mojang.blaze3d.systems.RenderSystem import net.minecraft.ChatFormatting diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/CompoundTagDelegates.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagDelegates.kt similarity index 97% rename from src/main/kotlin/ru/dbotthepony/mc/otm/core/CompoundTagDelegates.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagDelegates.kt index c3fc4a3df..7b6161557 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/CompoundTagDelegates.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagDelegates.kt @@ -1,7 +1,6 @@ -package ru.dbotthepony.mc.otm.core +package ru.dbotthepony.mc.otm.core.nbt import net.minecraft.nbt.CompoundTag -import net.minecraft.nbt.LongArrayTag import java.util.* import kotlin.properties.ReadWriteProperty import kotlin.reflect.KProperty diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/CompoundTagExt.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt similarity index 99% rename from src/main/kotlin/ru/dbotthepony/mc/otm/core/CompoundTagExt.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt index 2a93691b8..042eb8c63 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/CompoundTagExt.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.core +package ru.dbotthepony.mc.otm.core.nbt import net.minecraft.nbt.ByteArrayTag import net.minecraft.nbt.ByteTag diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/DataStreams.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/core/DataStreams.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt index 77d78a59d..095b0addd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/DataStreams.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt @@ -1,6 +1,8 @@ -package ru.dbotthepony.mc.otm.core +package ru.dbotthepony.mc.otm.core.util import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.core.math.readDecimal +import ru.dbotthepony.mc.otm.core.math.writeDecimal import java.io.DataInputStream import java.io.DataOutputStream import java.io.InputStream diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/FriendlyStreams.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/FriendlyStreams.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/core/FriendlyStreams.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/util/FriendlyStreams.kt index 53769f924..4beddf9d8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/FriendlyStreams.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/FriendlyStreams.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.core +package ru.dbotthepony.mc.otm.core.util import io.netty.handler.codec.EncoderException import net.minecraft.nbt.CompoundTag diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Formatting.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/SiPrefix.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/mc/otm/core/Formatting.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/util/SiPrefix.kt index e67b33a37..62e093cdf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Formatting.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/SiPrefix.kt @@ -1,7 +1,12 @@ -package ru.dbotthepony.mc.otm.core +package ru.dbotthepony.mc.otm.core.util import com.google.common.collect.ImmutableList import net.minecraft.network.chat.Component +import ru.dbotthepony.mc.otm.core.TextComponent +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.isNegative +import ru.dbotthepony.mc.otm.core.math.isZero import java.math.BigDecimal import java.math.BigInteger @@ -396,11 +401,13 @@ fun Int.formatPower(decimalPlaces: Int = 2) = formatSiComponent(POWER_NAME, deci fun Decimal.formatPower(decimalPlaces: Int = 2) = formatSiComponent(POWER_NAME, decimalPlaces) fun Decimal.formatMatter(decimalPlaces: Int = 2) = formatSiComponent(MATTER_NAME, decimalPlaces) -fun Decimal.formatMatterFull(decimalPlaces: Int = 2) = TranslatableComponent("otm.gui.matter.format", formatSiComponent(MATTER_NAME, decimalPlaces)) +fun Decimal.formatMatterFull(decimalPlaces: Int = 2) = TranslatableComponent("otm.gui.matter.format", formatSiComponent( + MATTER_NAME, decimalPlaces)) fun BigInteger.formatPower(decimalPlaces: Int = 2) = formatSiComponent(POWER_NAME, decimalPlaces) fun BigInteger.formatMatter(decimalPlaces: Int = 2) = formatSiComponent(MATTER_NAME, decimalPlaces) -fun BigInteger.formatMatterFull(decimalPlaces: Int = 2) = TranslatableComponent("otm.gui.matter.format", formatSiComponent(MATTER_NAME, decimalPlaces)) +fun BigInteger.formatMatterFull(decimalPlaces: Int = 2) = TranslatableComponent("otm.gui.matter.format", formatSiComponent( + MATTER_NAME, decimalPlaces)) fun formatPowerLevel(a: Decimal, b: Decimal, decimalPlaces: Int = 2) = TranslatableComponent("otm.gui.level", a.formatPower(decimalPlaces), b.formatPower(decimalPlaces)) fun formatMatterLevel(a: Decimal, b: Decimal, decimalPlaces: Int = 2) = TranslatableComponent("otm.gui.level", a.formatMatter(decimalPlaces), b.formatMatter(decimalPlaces)) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/ItemStackCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/ItemStackCodec.kt index a2a42a34d..da27c1d3f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/ItemStackCodec.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/ItemStackCodec.kt @@ -22,6 +22,7 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set import java.lang.reflect.Type diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/SerializedFunctionRegistry.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/SerializedFunctionRegistry.kt index 24f85d16e..548d43200 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/SerializedFunctionRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/SerializedFunctionRegistry.kt @@ -19,18 +19,18 @@ import it.unimi.dsi.fastutil.io.FastByteArrayInputStream import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation -import ru.dbotthepony.mc.otm.core.readType -import ru.dbotthepony.mc.otm.core.readVarIntLE +import ru.dbotthepony.mc.otm.core.util.readType +import ru.dbotthepony.mc.otm.core.util.readVarIntLE +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set -import ru.dbotthepony.mc.otm.core.writeType -import ru.dbotthepony.mc.otm.core.writeVarIntLE +import ru.dbotthepony.mc.otm.core.util.writeType +import ru.dbotthepony.mc.otm.core.util.writeVarIntLE import java.io.DataInputStream import java.io.DataOutputStream import java.lang.reflect.Type import java.util.Base64 import java.util.Collections import java.util.LinkedList -import java.util.function.Consumer class SerializedFunctionRegistry(val gson: Gson = Gson()) : JsonSerializer>, JsonDeserializer>, TypeAdapter>() { fun interface AnonymousFunction { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceCondition.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceCondition.kt index bb92e5431..74eb3c34b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceCondition.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceCondition.kt @@ -9,6 +9,7 @@ import net.minecraft.world.level.storage.loot.LootContext import net.minecraft.world.level.storage.loot.Serializer import net.minecraft.world.level.storage.loot.predicates.LootItemCondition import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.registry.MLootItemConditions diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceWithPlaytimeCondition.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceWithPlaytimeCondition.kt index bcfee2b3d..ba23eea7d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceWithPlaytimeCondition.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceWithPlaytimeCondition.kt @@ -10,6 +10,7 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParams import net.minecraft.world.level.storage.loot.predicates.LootItemCondition import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.data.get import ru.dbotthepony.mc.otm.registry.MLootItemConditions diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ItemInInventoryCondition.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ItemInInventoryCondition.kt index 39dc2ef2c..353f5a8c0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ItemInInventoryCondition.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ItemInInventoryCondition.kt @@ -16,6 +16,7 @@ import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.capability.itemsStream import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.data.get import ru.dbotthepony.mc.otm.registry.MLootItemConditions diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/RandomizerFunction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/RandomizerFunction.kt index b764464c2..822fdee36 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/RandomizerFunction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/RandomizerFunction.kt @@ -14,6 +14,7 @@ import net.minecraft.world.level.storage.loot.functions.LootItemFunction import net.minecraft.world.level.storage.loot.functions.LootItemFunctionType import net.minecraft.world.level.storage.loot.parameters.LootContextParams import org.apache.logging.log4j.LogManager +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.registry.MItemFunctionTypes diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/PlasmaProjectile.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/PlasmaProjectile.kt index 43096f523..966f0f13d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/PlasmaProjectile.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/PlasmaProjectile.kt @@ -12,7 +12,6 @@ import net.minecraft.world.phys.BlockHitResult import net.minecraft.world.phys.EntityHitResult import net.minecraft.world.phys.HitResult import net.minecraftforge.event.ForgeEventFactory -import ru.dbotthepony.mc.otm.core.Vector import ru.dbotthepony.mc.otm.registry.MEntityTypes import ru.dbotthepony.mc.otm.registry.PlasmaDamageSource diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Abstract6Graph.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Abstract6Graph.kt index 915eb16d9..8a136c671 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Abstract6Graph.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Abstract6Graph.kt @@ -6,7 +6,7 @@ import net.minecraft.core.SectionPos import net.minecraft.server.level.ServerLevel import net.minecraft.world.level.block.entity.BlockEntity import ru.dbotthepony.mc.otm.core.IConditionalTickable -import ru.dbotthepony.mc.otm.core.plus +import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.addTicker import java.util.* import kotlin.collections.ArrayList diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNetworkGraph.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNetworkGraph.kt index 4e7ca9b03..9cc19b1e8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNetworkGraph.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNetworkGraph.kt @@ -7,7 +7,7 @@ import net.minecraft.world.level.block.entity.BlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.matter.* -import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.graph.Abstract6Graph import ru.dbotthepony.mc.otm.graph.Graph6Node import java.util.* diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt index 5ae18f6a0..1c92144ac 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt @@ -23,6 +23,7 @@ import ru.dbotthepony.mc.otm.capability.energy.getBarColor import ru.dbotthepony.mc.otm.capability.energy.getBarWidth import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.* +import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.registry.MRegistry import ru.dbotthepony.mc.otm.runIfClient import kotlin.math.roundToInt @@ -39,7 +40,8 @@ open class BatteryItem : Item { return super.receiveEnergy(howMuch, simulate) } - override val missingPower: Decimal get() { + override val missingPower: Decimal + get() { return if (isCreative) Decimal.LONG_MAX_VALUE else super.missingPower } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt index eb07a3736..f9065728c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt @@ -35,10 +35,10 @@ import ru.dbotthepony.mc.otm.capability.energy.getBarColor import ru.dbotthepony.mc.otm.capability.energy.getBarWidth import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.capability.matteryPlayer -import ru.dbotthepony.mc.otm.core.Decimal -import ru.dbotthepony.mc.otm.core.DecimalConfigValue +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.core.defineDecimal +import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.registry.EMPDamageSource diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt index 4eda3a7e9..78a446aa8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt @@ -17,8 +17,8 @@ import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.matter.* -import ru.dbotthepony.mc.otm.core.Decimal -import ru.dbotthepony.mc.otm.core.formatMatter +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.util.formatMatter import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.tagNotNull import javax.annotation.ParametersAreNonnullByDefault @@ -44,11 +44,13 @@ class MatterCapacitorItem : Item { stack.tagNotNull.put("matter", value.serializeNBT()) } - override val maxStoredMatter: Decimal get() { + override val maxStoredMatter: Decimal + get() { return capacity } - override val missingMatter: Decimal get() { + override val missingMatter: Decimal + get() { return if (isCreative) Decimal.LONG_MAX_VALUE else super.missingMatter } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt index 9d533f3c8..90bcfd2cf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt @@ -6,12 +6,11 @@ import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.Level -import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.ServerConfig import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.matter.IMatterItem -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.matter.IMatterValue import ru.dbotthepony.mc.otm.matter.MatterValue diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PatternStorageItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PatternStorageItem.kt index 93ffbfb2f..f1812f5b9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PatternStorageItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PatternStorageItem.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.item -import ru.dbotthepony.mc.otm.OverdriveThatMatters import net.minecraft.world.item.ItemStack import net.minecraft.nbt.CompoundTag import net.minecraftforge.common.capabilities.ICapabilityProvider @@ -11,14 +10,13 @@ import net.minecraftforge.common.util.LazyOptional import net.minecraft.nbt.ListTag import net.minecraft.core.Direction import net.minecraft.network.chat.Component -import net.minecraft.util.Mth import net.minecraft.world.item.Item import net.minecraft.world.item.Rarity import net.minecraft.world.level.Level import net.minecraftforge.common.capabilities.Capability import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.capability.matter.* -import ru.dbotthepony.mc.otm.core.ifHas +import ru.dbotthepony.mc.otm.core.nbt.ifHas import java.util.* import java.util.stream.Stream diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableCondensationDriveItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableCondensationDriveItem.kt index 48d62cfd0..4aa4e152c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableCondensationDriveItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableCondensationDriveItem.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.item import ru.dbotthepony.mc.otm.capability.drive.DrivePool.isLegalAccess -import ru.dbotthepony.mc.otm.OverdriveThatMatters import net.minecraft.world.item.ItemStack import net.minecraftforge.common.capabilities.ICapabilityProvider import net.minecraftforge.common.util.LazyOptional @@ -18,13 +17,11 @@ import net.minecraft.world.item.Item import net.minecraft.world.level.Level import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.event.ForgeEventFactory -import net.minecraftforge.eventbus.api.SubscribeEvent import net.minecraftforge.event.entity.player.EntityItemPickupEvent -import net.minecraftforge.eventbus.api.EventPriority import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.capability.drive.DrivePool import ru.dbotthepony.mc.otm.container.ItemFilter -import ru.dbotthepony.mc.otm.core.ifHas +import ru.dbotthepony.mc.otm.core.nbt.ifHas import java.math.BigInteger import java.util.* diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralExoPackSlotUpgradeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralExoPackSlotUpgradeItem.kt index 9128da3b0..9864f1be7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralExoPackSlotUpgradeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralExoPackSlotUpgradeItem.kt @@ -9,7 +9,7 @@ import net.minecraft.world.item.Rarity import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.Level import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.tagNotNull import ru.dbotthepony.mc.otm.data.loot.IRandomizableItem import java.util.* 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 2772269ce..84373254a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt @@ -29,6 +29,11 @@ import ru.dbotthepony.mc.otm.capability.energy.getBarColor import ru.dbotthepony.mc.otm.capability.energy.getBarWidth import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper import ru.dbotthepony.mc.otm.core.* +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.readDecimal +import ru.dbotthepony.mc.otm.core.math.writeDecimal +import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.network.GenericNetworkChannel import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.packetHandled @@ -198,7 +203,8 @@ class QuantumBatteryItem : Item { data.energy = value } - val passed: Decimal get() { + val passed: Decimal + get() { if (data.parent == null) { determineQuantumLink() } @@ -210,7 +216,8 @@ class QuantumBatteryItem : Item { return data.passed } - val received: Decimal get() { + val received: Decimal + get() { if (data.parent == null) { determineQuantumLink() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt index cbe908c47..cce7ef7ee 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt @@ -18,6 +18,7 @@ import ru.dbotthepony.mc.otm.capability.energy.ItemEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.energy.getBarColor import ru.dbotthepony.mc.otm.capability.energy.getBarWidth import ru.dbotthepony.mc.otm.core.* +import ru.dbotthepony.mc.otm.core.math.Decimal open class SingleUseBatteryItem( private val _capacity: () -> Decimal, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt index bf58e6e3c..fcd607fc7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt @@ -26,7 +26,22 @@ import ru.dbotthepony.mc.otm.client.font import ru.dbotthepony.mc.otm.client.render.drawRect import ru.dbotthepony.mc.otm.client.render.setDrawColor import ru.dbotthepony.mc.otm.core.* -import ru.dbotthepony.mc.otm.core.Vector +import ru.dbotthepony.mc.otm.core.math.Angle +import ru.dbotthepony.mc.otm.core.math.RGBAColor +import ru.dbotthepony.mc.otm.core.math.Vector +import ru.dbotthepony.mc.otm.core.math.bezierCurve +import ru.dbotthepony.mc.otm.core.math.component1 +import ru.dbotthepony.mc.otm.core.math.component2 +import ru.dbotthepony.mc.otm.core.math.component3 +import ru.dbotthepony.mc.otm.core.math.linearInterpolation +import ru.dbotthepony.mc.otm.core.math.rotateX +import ru.dbotthepony.mc.otm.core.math.rotateY +import ru.dbotthepony.mc.otm.core.math.rotateZ +import ru.dbotthepony.mc.otm.core.nbt.EMPTY_UUID +import ru.dbotthepony.mc.otm.core.nbt.booleans +import ru.dbotthepony.mc.otm.core.nbt.ints +import ru.dbotthepony.mc.otm.core.nbt.uuids +import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.WeaponNetworkChannel import java.util.* @@ -284,7 +299,7 @@ abstract class AbstractWeaponItem(val tables: KClass, pr if (it.compatibleDataTable(predictedData)) (it as AbstractWeaponItem).dataTable = predictedData - val interp = linearInterpolation( + val interp = ru.dbotthepony.mc.otm.core.math.linearInterpolation( it.ironSightsProgress( player.mainHandItem, event.partialTick @@ -293,7 +308,9 @@ abstract class AbstractWeaponItem(val tables: KClass, pr val time = System.nanoTime() val diff = abs(lastFovTime - time) - lastFov = linearInterpolation(diff.coerceIn(0L, 10_000_000L).toDouble() / 10_000_000.0, lastFov, interp).coerceAtLeast(0.001) + lastFov = ru.dbotthepony.mc.otm.core.math.linearInterpolation( + diff.coerceIn(0L, 10_000_000L).toDouble() / 10_000_000.0, lastFov, interp + ).coerceAtLeast(0.001) lastFovTime = time event.fov /= lastFov diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaRifleItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaRifleItem.kt index 4035fc729..053b96d5e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaRifleItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaRifleItem.kt @@ -4,8 +4,9 @@ import net.minecraft.sounds.SoundSource import net.minecraft.world.entity.player.Player import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact -import ru.dbotthepony.mc.otm.core.* -import ru.dbotthepony.mc.otm.core.Vector +import ru.dbotthepony.mc.otm.core.math.Angle +import ru.dbotthepony.mc.otm.core.math.Vector +import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.entity.PlasmaProjectile import ru.dbotthepony.mc.otm.core.position import ru.dbotthepony.mc.otm.registry.MSoundEvents diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt index 2bd11a3ff..e33c8662d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt @@ -21,6 +21,12 @@ import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.getBarColor import ru.dbotthepony.mc.otm.capability.energy.getBarWidth import ru.dbotthepony.mc.otm.core.* +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.bezierCurve +import ru.dbotthepony.mc.otm.core.nbt.doubles +import ru.dbotthepony.mc.otm.core.nbt.ints +import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.registry.MSoundEvents import kotlin.reflect.KClass diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/VelocityCalculation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/VelocityCalculation.kt index c94c26837..a3d95a956 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/VelocityCalculation.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/VelocityCalculation.kt @@ -3,8 +3,8 @@ package ru.dbotthepony.mc.otm.item.weapon import net.minecraft.util.Mth import net.minecraft.world.entity.Entity import net.minecraft.world.phys.Vec3 -import ru.dbotthepony.mc.otm.core.plus -import ru.dbotthepony.mc.otm.core.times +import ru.dbotthepony.mc.otm.core.math.plus +import ru.dbotthepony.mc.otm.core.math.times import java.util.* import kotlin.math.PI import kotlin.math.cos 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 6b77baf72..7922d3331 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/AbstractRegistryAction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/AbstractRegistryAction.kt @@ -8,7 +8,8 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.tags.ItemTags import net.minecraft.tags.TagKey import net.minecraft.world.item.Item -import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set sealed class AbstractRegistryAction : Comparable { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/BlacklistAction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/BlacklistAction.kt index ae9a980ea..41ec5e35e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/BlacklistAction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/BlacklistAction.kt @@ -4,6 +4,7 @@ import com.google.gson.JsonObject import net.minecraft.resources.ResourceLocation import net.minecraft.tags.TagKey import net.minecraft.world.item.Item +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set class BlacklistAction : DeleteAction { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/BoundMatterFunction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/BoundMatterFunction.kt index f4a239e52..27e55bf04 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/BoundMatterFunction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/BoundMatterFunction.kt @@ -2,7 +2,8 @@ package ru.dbotthepony.mc.otm.matter import com.google.gson.JsonElement import com.google.gson.JsonObject -import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set class BoundMatterFunction(val function: MatterFunction, val value: T) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt index 9ffb62311..bdb723c09 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt @@ -10,8 +10,9 @@ import net.minecraft.tags.TagKey import net.minecraft.world.item.Item import net.minecraft.world.level.ItemLike import net.minecraftforge.registries.ForgeRegistries -import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.data.stream import java.util.stream.Stream diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/DeleteAction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/DeleteAction.kt index 58252bdd1..ad5b7b29a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/DeleteAction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/DeleteAction.kt @@ -4,6 +4,7 @@ import com.google.gson.JsonObject import net.minecraft.resources.ResourceLocation import net.minecraft.tags.TagKey import net.minecraft.world.item.Item +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set open class DeleteAction : AbstractRegistryAction { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/IMatterValue.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/IMatterValue.kt index 7fc49dd3b..6367157d2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/IMatterValue.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/IMatterValue.kt @@ -1,9 +1,9 @@ package ru.dbotthepony.mc.otm.matter import net.minecraft.network.FriendlyByteBuf -import ru.dbotthepony.mc.otm.core.Decimal -import ru.dbotthepony.mc.otm.core.readDecimal -import ru.dbotthepony.mc.otm.core.writeDecimal +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.readDecimal +import ru.dbotthepony.mc.otm.core.math.writeDecimal interface IMatterValue : Comparable { val matter: Decimal diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/InsertAction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/InsertAction.kt index b0f54b201..31f0ce082 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/InsertAction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/InsertAction.kt @@ -4,8 +4,9 @@ import com.google.gson.JsonObject import net.minecraft.resources.ResourceLocation import net.minecraft.tags.TagKey import net.minecraft.world.item.Item -import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.probablyParallelStream +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set class InsertAction : AbstractRegistryAction { 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 dc1e34769..42b89a276 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterDataProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterDataProvider.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.matter import net.minecraft.data.CachedOutput -import net.minecraft.data.DataGenerator import net.minecraft.data.DataProvider import net.minecraft.data.PackOutput import net.minecraft.resources.ResourceLocation @@ -9,8 +8,7 @@ import net.minecraft.tags.TagKey import net.minecraft.world.item.Item import net.minecraft.world.level.ItemLike import net.minecraftforge.data.event.GatherDataEvent -import ru.dbotthepony.mc.otm.android.AndroidResearchManager -import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.WriteOnce import ru.dbotthepony.mc.otm.core.registryName import java.util.Collections @@ -318,217 +316,281 @@ open class MatterDataProvider(val modid: String? = null) : DataProvider { } } - fun Scope( matterValue: Int, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity, configurator) + fun Scope( matterValue: Int, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity, configurator) fun Scope(item: ItemLike, matterValue: Int, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity, configurator) fun Scope(tag: TagKey, matterValue: Int, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity, configurator) - fun Scope( matterValue: Long, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity, configurator) + fun Scope( matterValue: Long, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity, configurator) fun Scope(item: ItemLike, matterValue: Long, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity, configurator) fun Scope(tag: TagKey, matterValue: Long, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity, configurator) - fun Scope( matterValue: Double, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity, configurator) + fun Scope( matterValue: Double, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity, configurator) fun Scope(item: ItemLike, matterValue: Double, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity, configurator) fun Scope(tag: TagKey, matterValue: Double, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity, configurator) - fun Scope( matterValue: Float, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity, configurator) + fun Scope( matterValue: Float, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity, configurator) fun Scope(item: ItemLike, matterValue: Float, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity, configurator) fun Scope(tag: TagKey, matterValue: Float, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity, configurator) - fun Scope( matterValue: Int, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun Scope( matterValue: Int, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(item: ItemLike, matterValue: Int, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(tag: TagKey, matterValue: Int, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun Scope( matterValue: Long, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun Scope( matterValue: Long, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(item: ItemLike, matterValue: Long, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(tag: TagKey, matterValue: Long, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun Scope( matterValue: Double, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun Scope( matterValue: Double, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(item: ItemLike, matterValue: Double, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(tag: TagKey, matterValue: Double, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun Scope( matterValue: Float, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun Scope( matterValue: Float, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(item: ItemLike, matterValue: Float, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(tag: TagKey, matterValue: Float, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun Scope( matterValue: Int, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun Scope( matterValue: Int, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(item: ItemLike, matterValue: Int, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(tag: TagKey, matterValue: Int, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun Scope( matterValue: Long, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun Scope( matterValue: Long, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(item: ItemLike, matterValue: Long, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(tag: TagKey, matterValue: Long, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun Scope( matterValue: Double, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun Scope( matterValue: Double, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(item: ItemLike, matterValue: Double, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(tag: TagKey, matterValue: Double, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun Scope( matterValue: Float, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun Scope( matterValue: Float, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(item: ItemLike, matterValue: Float, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(tag: TagKey, matterValue: Float, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun Scope( matterValue: Int, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun Scope( matterValue: Int, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(item: ItemLike, matterValue: Int, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(tag: TagKey, matterValue: Int, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun Scope( matterValue: Long, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun Scope( matterValue: Long, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(item: ItemLike, matterValue: Long, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(tag: TagKey, matterValue: Long, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun Scope( matterValue: Double, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun Scope( matterValue: Double, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(item: ItemLike, matterValue: Double, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(tag: TagKey, matterValue: Double, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun Scope( matterValue: Float, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun Scope( matterValue: Float, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(item: ItemLike, matterValue: Float, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(tag: TagKey, matterValue: Float, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) fun scope(matterValue: Decimal, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(matterValue, complexity, configurator) fun scope(item: ItemLike, matterValue: Decimal, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, matterValue, complexity, configurator) fun scope(tag: TagKey, matterValue: Decimal, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, matterValue, complexity, configurator) - fun scope( matterValue: Int, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity, configurator) + fun scope( matterValue: Int, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity, configurator) fun scope(item: ItemLike, matterValue: Int, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity, configurator) fun scope(tag: TagKey, matterValue: Int, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity, configurator) - fun scope( matterValue: Long, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity, configurator) + fun scope( matterValue: Long, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity, configurator) fun scope(item: ItemLike, matterValue: Long, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity, configurator) fun scope(tag: TagKey, matterValue: Long, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity, configurator) - fun scope( matterValue: Double, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity, configurator) + fun scope( matterValue: Double, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity, configurator) fun scope(item: ItemLike, matterValue: Double, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity, configurator) fun scope(tag: TagKey, matterValue: Double, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity, configurator) - fun scope( matterValue: Float, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity, configurator) + fun scope( matterValue: Float, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity, configurator) fun scope(item: ItemLike, matterValue: Float, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity, configurator) fun scope(tag: TagKey, matterValue: Float, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity, configurator) - fun scope( matterValue: Int, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun scope( matterValue: Int, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun scope(item: ItemLike, matterValue: Int, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun scope(tag: TagKey, matterValue: Int, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun scope( matterValue: Long, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun scope( matterValue: Long, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun scope(item: ItemLike, matterValue: Long, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun scope(tag: TagKey, matterValue: Long, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun scope( matterValue: Double, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun scope( matterValue: Double, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun scope(item: ItemLike, matterValue: Double, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun scope(tag: TagKey, matterValue: Double, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun scope( matterValue: Float, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun scope( matterValue: Float, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun scope(item: ItemLike, matterValue: Float, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun scope(tag: TagKey, matterValue: Float, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun scope( matterValue: Int, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun scope( matterValue: Int, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun scope(item: ItemLike, matterValue: Int, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun scope(tag: TagKey, matterValue: Int, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun scope( matterValue: Long, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun scope( matterValue: Long, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun scope(item: ItemLike, matterValue: Long, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun scope(tag: TagKey, matterValue: Long, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun scope( matterValue: Double, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun scope( matterValue: Double, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun scope(item: ItemLike, matterValue: Double, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun scope(tag: TagKey, matterValue: Double, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun scope( matterValue: Float, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun scope( matterValue: Float, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun scope(item: ItemLike, matterValue: Float, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun scope(tag: TagKey, matterValue: Float, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun scope( matterValue: Int, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun scope( matterValue: Int, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun scope(item: ItemLike, matterValue: Int, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun scope(tag: TagKey, matterValue: Int, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun scope( matterValue: Long, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun scope( matterValue: Long, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun scope(item: ItemLike, matterValue: Long, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun scope(tag: TagKey, matterValue: Long, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun scope( matterValue: Double, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun scope( matterValue: Double, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun scope(item: ItemLike, matterValue: Double, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun scope(tag: TagKey, matterValue: Double, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun scope( matterValue: Float, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun scope( matterValue: Float, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun scope(item: ItemLike, matterValue: Float, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun scope(tag: TagKey, matterValue: Float, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun Scope( matterValue: Int, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity, configurator) + fun Scope( matterValue: Int, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity, configurator) fun Scope(item: ItemLike, matterValue: Int, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity, configurator) fun Scope(tag: TagKey, matterValue: Int, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity, configurator) - fun Scope( matterValue: Long, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity, configurator) + fun Scope( matterValue: Long, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity, configurator) fun Scope(item: ItemLike, matterValue: Long, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity, configurator) fun Scope(tag: TagKey, matterValue: Long, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity, configurator) - fun Scope( matterValue: Double, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity, configurator) + fun Scope( matterValue: Double, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity, configurator) fun Scope(item: ItemLike, matterValue: Double, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity, configurator) fun Scope(tag: TagKey, matterValue: Double, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity, configurator) - fun Scope( matterValue: Float, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity, configurator) + fun Scope( matterValue: Float, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity, configurator) fun Scope(item: ItemLike, matterValue: Float, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity, configurator) fun Scope(tag: TagKey, matterValue: Float, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity, configurator) - fun Scope( matterValue: Int, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun Scope( matterValue: Int, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(item: ItemLike, matterValue: Int, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(tag: TagKey, matterValue: Int, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun Scope( matterValue: Long, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun Scope( matterValue: Long, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(item: ItemLike, matterValue: Long, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(tag: TagKey, matterValue: Long, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun Scope( matterValue: Double, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun Scope( matterValue: Double, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(item: ItemLike, matterValue: Double, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(tag: TagKey, matterValue: Double, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun Scope( matterValue: Float, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun Scope( matterValue: Float, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(item: ItemLike, matterValue: Float, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(tag: TagKey, matterValue: Float, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun Scope( matterValue: Int, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun Scope( matterValue: Int, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(item: ItemLike, matterValue: Int, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(tag: TagKey, matterValue: Int, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun Scope( matterValue: Long, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun Scope( matterValue: Long, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(item: ItemLike, matterValue: Long, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(tag: TagKey, matterValue: Long, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun Scope( matterValue: Double, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun Scope( matterValue: Double, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(item: ItemLike, matterValue: Double, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(tag: TagKey, matterValue: Double, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun Scope( matterValue: Float, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun Scope( matterValue: Float, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(item: ItemLike, matterValue: Float, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(tag: TagKey, matterValue: Float, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun Scope( matterValue: Int, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun Scope( matterValue: Int, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(item: ItemLike, matterValue: Int, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(tag: TagKey, matterValue: Int, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun Scope( matterValue: Long, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun Scope( matterValue: Long, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(item: ItemLike, matterValue: Long, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(tag: TagKey, matterValue: Long, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun Scope( matterValue: Double, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun Scope( matterValue: Double, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(item: ItemLike, matterValue: Double, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(tag: TagKey, matterValue: Double, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun Scope( matterValue: Float, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun Scope( matterValue: Float, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(item: ItemLike, matterValue: Float, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun Scope(tag: TagKey, matterValue: Float, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) fun scope(matterValue: Decimal, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(matterValue, complexity, configurator) fun scope(item: ItemLike, matterValue: Decimal, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(item, matterValue, complexity, configurator) fun scope(tag: TagKey, matterValue: Decimal, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(tag, matterValue, complexity, configurator) - fun scope( matterValue: Int, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity, configurator) + fun scope( matterValue: Int, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity, configurator) fun scope(item: ItemLike, matterValue: Int, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity, configurator) fun scope(tag: TagKey, matterValue: Int, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity, configurator) - fun scope( matterValue: Long, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity, configurator) + fun scope( matterValue: Long, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity, configurator) fun scope(item: ItemLike, matterValue: Long, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity, configurator) fun scope(tag: TagKey, matterValue: Long, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity, configurator) - fun scope( matterValue: Double, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity, configurator) + fun scope( matterValue: Double, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity, configurator) fun scope(item: ItemLike, matterValue: Double, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity, configurator) fun scope(tag: TagKey, matterValue: Double, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity, configurator) - fun scope( matterValue: Float, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity, configurator) + fun scope( matterValue: Float, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity, configurator) fun scope(item: ItemLike, matterValue: Float, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity, configurator) fun scope(tag: TagKey, matterValue: Float, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity, configurator) - fun scope( matterValue: Int, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun scope( matterValue: Int, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun scope(item: ItemLike, matterValue: Int, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun scope(tag: TagKey, matterValue: Int, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun scope( matterValue: Long, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun scope( matterValue: Long, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun scope(item: ItemLike, matterValue: Long, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun scope(tag: TagKey, matterValue: Long, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun scope( matterValue: Double, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun scope( matterValue: Double, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun scope(item: ItemLike, matterValue: Double, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun scope(tag: TagKey, matterValue: Double, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun scope( matterValue: Float, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun scope( matterValue: Float, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun scope(item: ItemLike, matterValue: Float, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun scope(tag: TagKey, matterValue: Float, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun scope( matterValue: Int, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun scope( matterValue: Int, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun scope(item: ItemLike, matterValue: Int, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun scope(tag: TagKey, matterValue: Int, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun scope( matterValue: Long, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun scope( matterValue: Long, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun scope(item: ItemLike, matterValue: Long, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun scope(tag: TagKey, matterValue: Long, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun scope( matterValue: Double, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun scope( matterValue: Double, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun scope(item: ItemLike, matterValue: Double, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun scope(tag: TagKey, matterValue: Double, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun scope( matterValue: Float, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun scope( matterValue: Float, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun scope(item: ItemLike, matterValue: Float, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun scope(tag: TagKey, matterValue: Float, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun scope( matterValue: Int, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun scope( matterValue: Int, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun scope(item: ItemLike, matterValue: Int, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun scope(tag: TagKey, matterValue: Int, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun scope( matterValue: Long, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun scope( matterValue: Long, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun scope(item: ItemLike, matterValue: Long, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun scope(tag: TagKey, matterValue: Long, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun scope( matterValue: Double, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun scope( matterValue: Double, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun scope(item: ItemLike, matterValue: Double, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun scope(tag: TagKey, matterValue: Double, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) - fun scope( matterValue: Float, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue), complexity.toDouble(), configurator) + fun scope( matterValue: Float, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue), complexity.toDouble(), configurator) fun scope(item: ItemLike, matterValue: Float, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue), complexity.toDouble(), configurator) fun scope(tag: TagKey, matterValue: Float, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue), complexity.toDouble(), configurator) @@ -561,110 +623,142 @@ open class MatterDataProvider(val modid: String? = null) : DataProvider { fun Scope(matterValue: Decimal, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(matterValue * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Decimal, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, matterValue * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Decimal, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, matterValue * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Int, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Int, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Int, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Int, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Long, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Long, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Long, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Long, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Double, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Double, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Double, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Double, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Float, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Float, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Float, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Float, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Int, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Int, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Int, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Int, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Long, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Long, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Long, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Long, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Double, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Double, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Double, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Double, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Float, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Float, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Float, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Float, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Int, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Int, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Int, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Int, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Long, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Long, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Long, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Long, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Double, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Double, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Double, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Double, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Float, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Float, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Float, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Float, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Int, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Int, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Int, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Int, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Long, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Long, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Long, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Long, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Double, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Double, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Double, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Double, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Float, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Float, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Float, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Float, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(matterValue: Decimal, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(matterValue * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Decimal, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, matterValue * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Decimal, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, matterValue * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Int, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Int, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Int, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Int, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Long, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Long, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Long, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Long, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Double, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Double, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Double, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Double, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Float, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Float, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Float, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Float, complexity: Double, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Int, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Int, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Int, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Int, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Long, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Long, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Long, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Long, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Double, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Double, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Double, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Double, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Float, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Float, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Float, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Float, complexity: Int, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Int, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Int, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Int, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Int, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Long, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Long, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Long, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Long, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Double, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Double, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Double, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Double, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Float, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Float, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Float, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Float, complexity: Float, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Int, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Int, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Int, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Int, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Long, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Long, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Long, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Long, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Double, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Double, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Double, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Double, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Float, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Float, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Float, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Float, complexity: Long, configurator: Scope.() -> Unit) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) @@ -672,110 +766,142 @@ open class MatterDataProvider(val modid: String? = null) : DataProvider { fun Scope(matterValue: Decimal, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(matterValue * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Decimal, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(item, matterValue * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Decimal, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(tag, matterValue * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Int, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Int, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Int, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Int, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Long, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Long, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Long, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Long, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Double, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Double, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Double, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Double, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Float, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Float, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Float, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Float, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Int, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Int, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Int, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Int, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Long, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Long, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Long, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Long, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Double, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Double, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Double, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Double, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Float, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Float, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Float, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Float, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Int, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Int, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Int, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Int, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Long, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Long, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Long, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Long, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Double, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Double, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Double, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Double, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Float, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Float, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Float, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Float, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Int, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Int, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Int, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Int, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Long, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Long, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Long, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Long, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Double, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Double, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Double, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Double, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun Scope( matterValue: Float, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun Scope( matterValue: Float, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(item: ItemLike, matterValue: Float, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun Scope(tag: TagKey, matterValue: Float, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(matterValue: Decimal, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(matterValue * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Decimal, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(item, matterValue * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Decimal, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(tag, matterValue * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Int, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Int, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Int, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Int, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Long, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Long, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Long, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Long, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Double, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Double, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Double, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Double, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Float, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Float, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Float, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Float, complexity: Double, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Int, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Int, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Int, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Int, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Long, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Long, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Long, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Long, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Double, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Double, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Double, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Double, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Float, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Float, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Float, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Float, complexity: Int, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Int, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Int, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Int, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Int, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Long, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Long, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Long, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Long, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Double, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Double, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Double, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Double, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Float, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Float, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Float, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Float, complexity: Float, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Int, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Int, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Int, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Int, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Long, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Long, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Long, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Long, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Double, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Double, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Double, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Double, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) - fun scope( matterValue: Float, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) + fun scope( matterValue: Float, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope( + Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(item: ItemLike, matterValue: Float, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(item, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) fun scope(tag: TagKey, matterValue: Float, complexity: Long, configurator: Consumer) = this@MatterDataProvider.Scope(tag, Decimal(matterValue) * this.matterValue, complexity * this.complexity, configurator) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterFunction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterFunction.kt index 37b2e7a9f..f4774ae06 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterFunction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterFunction.kt @@ -1,9 +1,9 @@ package ru.dbotthepony.mc.otm.matter import com.google.gson.JsonParseException -import ru.dbotthepony.mc.otm.core.Decimal -import ru.dbotthepony.mc.otm.core.integerDivisionDown -import ru.dbotthepony.mc.otm.core.integerDivisionUp +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.integerDivisionDown +import ru.dbotthepony.mc.otm.core.math.integerDivisionUp enum class MatterFunction { ADD { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index d9d2f187c..83d058abd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -62,17 +62,17 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.drive.IMatteryDrive import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.container.stream -import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.filterNotNull -import ru.dbotthepony.mc.otm.core.formatMatter -import ru.dbotthepony.mc.otm.core.formatMatterFull -import ru.dbotthepony.mc.otm.core.formatSiComponent -import ru.dbotthepony.mc.otm.core.formatTickDuration +import ru.dbotthepony.mc.otm.core.util.formatMatter +import ru.dbotthepony.mc.otm.core.util.formatMatterFull +import ru.dbotthepony.mc.otm.core.util.formatSiComponent +import ru.dbotthepony.mc.otm.core.util.formatTickDuration import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.isActuallyEmpty -import ru.dbotthepony.mc.otm.core.isZero +import ru.dbotthepony.mc.otm.core.math.isZero import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.core.readItemType import ru.dbotthepony.mc.otm.core.registryName diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/UpdateAction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/UpdateAction.kt index 5a255cf50..e1a0d0799 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/UpdateAction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/UpdateAction.kt @@ -8,7 +8,8 @@ import com.google.gson.JsonParseException import net.minecraft.resources.ResourceLocation import net.minecraft.tags.TagKey import net.minecraft.world.item.Item -import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.data.stream diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyCounterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyCounterMenu.kt index 827b45194..87af8898d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyCounterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyCounterMenu.kt @@ -7,7 +7,7 @@ import net.minecraft.world.inventory.Slot import net.minecraft.world.level.block.Block import ru.dbotthepony.mc.otm.block.EnergyCounterBlock import ru.dbotthepony.mc.otm.block.entity.EnergyCounterBlockEntity -import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.menu.widget.NumberPlayerInputWidget import ru.dbotthepony.mc.otm.menu.widget.OneWayPlayerInputWidget import ru.dbotthepony.mc.otm.registry.MMenus diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ItemMonitorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ItemMonitorMenu.kt index 63199e3da..925cec1ef 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ItemMonitorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ItemMonitorMenu.kt @@ -11,7 +11,7 @@ import net.minecraftforge.network.PacketDistributor import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorPlayerSettings import ru.dbotthepony.mc.otm.container.get -import ru.dbotthepony.mc.otm.core.nonEmpty +import ru.dbotthepony.mc.otm.core.collect.nonEmpty import ru.dbotthepony.mc.otm.menu.data.INetworkedItemViewProvider import ru.dbotthepony.mc.otm.menu.data.NetworkedItemView import ru.dbotthepony.mc.otm.network.MenuNetworkChannel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterCapacitorBankMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterCapacitorBankMenu.kt index 759e5a326..b03c8411b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterCapacitorBankMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterCapacitorBankMenu.kt @@ -4,7 +4,7 @@ import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.core.ImmutableList import ru.dbotthepony.mc.otm.block.entity.matter.MatterCapacitorBankBlockEntity -import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterScannerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterScannerMenu.kt index 5c1384149..81eb2fea8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterScannerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterScannerMenu.kt @@ -7,7 +7,7 @@ import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import net.minecraft.world.SimpleContainer import net.minecraft.world.item.ItemStack -import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.registry.MMenus diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/PatternStorageMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/PatternStorageMenu.kt index 7b4990b01..146e867e2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/PatternStorageMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/PatternStorageMenu.kt @@ -4,7 +4,7 @@ import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.core.ImmutableList import ru.dbotthepony.mc.otm.block.entity.matter.PatternStorageBlockEntity -import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/LevelGaugeWidget.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/LevelGaugeWidget.kt index 7c8b51a89..f2ab00129 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/LevelGaugeWidget.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/LevelGaugeWidget.kt @@ -3,13 +3,13 @@ package ru.dbotthepony.mc.otm.menu.widget import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage import ru.dbotthepony.mc.otm.capability.matter.IPatternStorage -import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.menu.MatteryMenu @Suppress("unused") class LevelGaugeWidget(menu: MatteryMenu) : AbstractWidget(menu) { var levelProvider = { Decimal.ONE } - var maxLevelProvider = {Decimal.ONE } + var maxLevelProvider = { Decimal.ONE } var level by menu.mSynchronizer.fraction() private set @@ -42,8 +42,8 @@ class LevelGaugeWidget(menu: MatteryMenu) : AbstractWidget(menu) { ) : this(menu) { if (patterns == null) return - this.levelProvider = {Decimal(patterns.storedPatterns)} - this.maxLevelProvider = {Decimal(patterns.patternCapacity)} + this.levelProvider = { Decimal(patterns.storedPatterns) } + this.maxLevelProvider = { Decimal(patterns.patternCapacity) } } constructor( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt index 9e9427b2a..1761b0832 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt @@ -11,6 +11,25 @@ import it.unimi.dsi.fastutil.objects.ReferenceArraySet import net.minecraft.world.item.ItemStack import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.core.* +import ru.dbotthepony.mc.otm.core.collect.ProxiedMap +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.util.BigDecimalValueCodec +import ru.dbotthepony.mc.otm.core.util.BooleanValueCodec +import ru.dbotthepony.mc.otm.core.util.ByteValueCodec +import ru.dbotthepony.mc.otm.core.util.DoubleValueCodec +import ru.dbotthepony.mc.otm.core.util.EnumValueCodec +import ru.dbotthepony.mc.otm.core.util.FloatValueCodec +import ru.dbotthepony.mc.otm.core.util.IStreamCodec +import ru.dbotthepony.mc.otm.core.util.ImpreciseFractionValueCodec +import ru.dbotthepony.mc.otm.core.util.IntValueCodec +import ru.dbotthepony.mc.otm.core.util.ItemStackValueCodec +import ru.dbotthepony.mc.otm.core.util.LongValueCodec +import ru.dbotthepony.mc.otm.core.util.ShortValueCodec +import ru.dbotthepony.mc.otm.core.util.UUIDValueCodec +import ru.dbotthepony.mc.otm.core.util.VarIntValueCodec +import ru.dbotthepony.mc.otm.core.util.VarLongValueCodec +import ru.dbotthepony.mc.otm.core.util.readVarIntLE +import ru.dbotthepony.mc.otm.core.util.writeVarIntLE import ru.dbotthepony.mc.otm.secondTime import java.io.DataInputStream import java.io.DataOutputStream diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt index 606d5745b..755bae55d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt @@ -26,7 +26,7 @@ import ru.dbotthepony.mc.otm.client.render.GlitchRenderer import ru.dbotthepony.mc.otm.client.render.ShockwaveRenderer import ru.dbotthepony.mc.otm.container.get import ru.dbotthepony.mc.otm.container.set -import ru.dbotthepony.mc.otm.core.Vector +import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.menu.AndroidStationMenu import ru.dbotthepony.mc.otm.menu.ExoPackInventoryMenu import ru.dbotthepony.mc.otm.registry.AndroidFeatures diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/Helpers.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/Helpers.kt index d0500fc95..dee95301c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/Helpers.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/Helpers.kt @@ -9,6 +9,7 @@ import net.minecraft.world.item.Items import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.container.set +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set fun stackFromJson(obj: JsonElement, field: String = ""): ItemStack { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Ext.kt index fdbf81a00..5072e9935 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Ext.kt @@ -9,7 +9,7 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.DyeColor import net.minecraftforge.registries.DeferredRegister import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.core.SupplierMap +import ru.dbotthepony.mc.otm.core.collect.SupplierMap private fun DeferredRegister.doColored(prefix: String, factory: (color: DyeColor, name: String) -> T): MutableCollection T>> { return mutableListOf( 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 7f4862af9..9d58d7dc9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -15,7 +15,7 @@ import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.ServerConfig -import ru.dbotthepony.mc.otm.core.SupplierList +import ru.dbotthepony.mc.otm.core.collect.SupplierList import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.item.* import ru.dbotthepony.mc.otm.item.weapon.PlasmaRifleItem 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 d7728cd27..ccac6679f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -27,7 +27,7 @@ import ru.dbotthepony.mc.otm.android.feature.ShockwaveFeature import ru.dbotthepony.mc.otm.block.CargoCrateBlock import ru.dbotthepony.mc.otm.block.TritaniumPressurePlate import ru.dbotthepony.mc.otm.capability.matteryEnergy -import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.item.EnergySwordItem import ru.dbotthepony.mc.otm.registry.objects.ColoredDecorativeBlock import ru.dbotthepony.mc.otm.registry.objects.CrateProperties diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/ColoredDecorativeBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/ColoredDecorativeBlock.kt index 07c3fd7a1..7b5e10a4d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/ColoredDecorativeBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/ColoredDecorativeBlock.kt @@ -1,14 +1,13 @@ package ru.dbotthepony.mc.otm.registry.objects import net.minecraft.world.item.BlockItem -import net.minecraft.world.item.CreativeModeTab import net.minecraft.world.item.DyeColor import net.minecraft.world.item.Item import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockBehaviour import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.RegistryObject -import ru.dbotthepony.mc.otm.core.SupplierMap +import ru.dbotthepony.mc.otm.core.collect.SupplierMap import java.util.EnumMap /** diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/DecorativeBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/DecorativeBlock.kt index 8aeafeabf..732085af2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/DecorativeBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/DecorativeBlock.kt @@ -1,16 +1,14 @@ package ru.dbotthepony.mc.otm.registry.objects import net.minecraft.world.item.BlockItem -import net.minecraft.world.item.CreativeModeTab import net.minecraft.world.item.DyeColor import net.minecraft.world.item.Item import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockBehaviour import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.RegistryObject -import ru.dbotthepony.mc.otm.core.SupplierMap +import ru.dbotthepony.mc.otm.core.collect.SupplierMap import ru.dbotthepony.mc.otm.core.WriteOnce -import ru.dbotthepony.mc.otm.registry.MCreativeTabs /** * Base + Colored diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/StripedColoredDecorativeBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/StripedColoredDecorativeBlock.kt index fe3516ddf..6e357144d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/StripedColoredDecorativeBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/StripedColoredDecorativeBlock.kt @@ -8,9 +8,8 @@ import net.minecraft.world.item.Item import net.minecraft.world.level.block.Block import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.RegistryObject -import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.core.SupplierList -import ru.dbotthepony.mc.otm.core.SupplierMap +import ru.dbotthepony.mc.otm.core.collect.SupplierList +import ru.dbotthepony.mc.otm.core.collect.SupplierMap import java.util.EnumMap @Suppress("PropertyName", "unused", "ReplaceGetOrSet", "ReplacePutWithAssignment") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/saveddata/SavedCountingMap.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/saveddata/SavedCountingMap.kt index a1ef2d947..6c696ea66 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/saveddata/SavedCountingMap.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/saveddata/SavedCountingMap.kt @@ -8,8 +8,8 @@ import net.minecraft.nbt.ListTag import net.minecraft.nbt.Tag import net.minecraft.world.level.saveddata.SavedData import org.apache.logging.log4j.LogManager -import ru.dbotthepony.mc.otm.core.ProxiedMap -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.collect.ProxiedMap +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.WriteOnce class SavedMapDelegate(val parent: SavedCountingMap>?, val index: Int, value: V) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/ItemStackWrapper.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/ItemStackWrapper.kt index 4ba6e3e5d..0c9402dd4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/ItemStackWrapper.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/ItemStackWrapper.kt @@ -4,6 +4,8 @@ import net.minecraft.network.FriendlyByteBuf import net.minecraft.world.item.ItemStack import org.jetbrains.annotations.ApiStatus import ru.dbotthepony.mc.otm.core.* +import ru.dbotthepony.mc.otm.core.math.isPositive +import ru.dbotthepony.mc.otm.core.math.toIntSafe import ru.dbotthepony.mc.otm.core.registryName import java.math.BigInteger diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/Registry.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/Registry.kt index 56ad6c23f..c8e6c54a0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/Registry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/Registry.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.mc.otm.storage import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.math.Decimal import java.util.IdentityHashMap open class StorageStackType( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/VirtualComponent.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/VirtualComponent.kt index 2866da497..a8dd38f74 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/VirtualComponent.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/VirtualComponent.kt @@ -2,9 +2,8 @@ package ru.dbotthepony.mc.otm.storage import it.unimi.dsi.fastutil.objects.ObjectArraySet import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage -import ru.dbotthepony.mc.otm.capability.energy.extractEnergy -import ru.dbotthepony.mc.otm.core.isPositive -import ru.dbotthepony.mc.otm.core.isZero +import ru.dbotthepony.mc.otm.core.math.isPositive +import ru.dbotthepony.mc.otm.core.math.isZero import java.math.BigInteger import java.util.* import java.util.stream.Stream diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidBatteryTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidBatteryTrigger.kt index 513d10a9f..86af33853 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidBatteryTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidBatteryTrigger.kt @@ -11,6 +11,7 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set object AndroidBatteryTrigger : SimpleCriterionTrigger() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidResearchTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidResearchTrigger.kt index 2eb8c4634..c2ef83ae8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidResearchTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidResearchTrigger.kt @@ -11,6 +11,7 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.android.AndroidResearchType +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set import java.util.function.Predicate diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NanobotsArmorTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NanobotsArmorTrigger.kt index fa026e177..a1d7253eb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NanobotsArmorTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NanobotsArmorTrigger.kt @@ -10,6 +10,7 @@ import net.minecraft.advancements.critereon.SimpleCriterionTrigger import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set object NanobotsArmorTrigger : SimpleCriterionTrigger() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ShockwaveDamageMobTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ShockwaveDamageMobTrigger.kt index a8fe3d1f1..e50e2a58c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ShockwaveDamageMobTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ShockwaveDamageMobTrigger.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.triggers import com.google.gson.JsonObject -import com.google.gson.JsonSyntaxException import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance import net.minecraft.advancements.critereon.DamagePredicate import net.minecraft.advancements.critereon.DamageSourcePredicate @@ -15,6 +14,7 @@ import net.minecraft.server.level.ServerPlayer import net.minecraft.world.damagesource.DamageSource import net.minecraft.world.entity.Entity import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set object ShockwaveDamageMobTrigger: SimpleCriterionTrigger() { diff --git a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/DecimalTests.kt b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/DecimalTests.kt index 52b31fcaf..801639431 100644 --- a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/DecimalTests.kt +++ b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/DecimalTests.kt @@ -5,7 +5,7 @@ import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test -import ru.dbotthepony.mc.otm.core.Decimal +import ru.dbotthepony.mc.otm.core.math.Decimal import java.io.ObjectInputStream import java.io.ObjectOutputStream diff --git a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FormattingTests.kt b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FormattingTests.kt index b278c12e9..e258d8012 100644 --- a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FormattingTests.kt +++ b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FormattingTests.kt @@ -3,9 +3,9 @@ package ru.dbotthepony.mc.otm.tests import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test -import ru.dbotthepony.mc.otm.core.Decimal -import ru.dbotthepony.mc.otm.core.formatReadableNumber -import ru.dbotthepony.mc.otm.core.formatSi +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.util.formatReadableNumber +import ru.dbotthepony.mc.otm.core.util.formatSi import java.math.BigInteger object FormattingTests { diff --git a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FriendlyStreams.kt b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FriendlyStreams.kt index 371cfb050..332832e17 100644 --- a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FriendlyStreams.kt +++ b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FriendlyStreams.kt @@ -5,12 +5,12 @@ import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test -import ru.dbotthepony.mc.otm.core.readInt -import ru.dbotthepony.mc.otm.core.readVarIntLE -import ru.dbotthepony.mc.otm.core.readVarLongLE -import ru.dbotthepony.mc.otm.core.writeInt -import ru.dbotthepony.mc.otm.core.writeVarIntLE -import ru.dbotthepony.mc.otm.core.writeVarLongLE +import ru.dbotthepony.mc.otm.core.util.readInt +import ru.dbotthepony.mc.otm.core.util.readVarIntLE +import ru.dbotthepony.mc.otm.core.util.readVarLongLE +import ru.dbotthepony.mc.otm.core.util.writeInt +import ru.dbotthepony.mc.otm.core.util.writeVarIntLE +import ru.dbotthepony.mc.otm.core.util.writeVarLongLE object FriendlyStreams { @Test @@ -118,4 +118,4 @@ object FriendlyStreams { assertEquals(-10023, input.readVarLongLE()) assertEquals(-100000, input.readVarLongLE()) } -} \ No newline at end of file +} diff --git a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/MathTests.kt b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/MathTests.kt index 4e96b646d..43b2b8a6e 100644 --- a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/MathTests.kt +++ b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/MathTests.kt @@ -3,8 +3,8 @@ package ru.dbotthepony.mc.otm.tests import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test -import ru.dbotthepony.mc.otm.core.integerDivisionDown -import ru.dbotthepony.mc.otm.core.integerDivisionUp +import ru.dbotthepony.mc.otm.core.math.integerDivisionDown +import ru.dbotthepony.mc.otm.core.math.integerDivisionUp object MathTests { @Test From aa07bdea3b091d8adf25934a0c9dd769e44e03a0 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 14 Jan 2023 17:30:28 +0700 Subject: [PATCH 0049/1199] Engine block --- src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt | 1 + src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt | 1 + src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt | 1 + src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt | 1 + 4 files changed, 4 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt index 131ca7ba9..ada0a79a8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt @@ -158,6 +158,7 @@ internal fun addDecorativeTabItems(consumer: CreativeModeTab.Output) { accept(MItems.LABORATORY_LAMP_INVERTED) accept(MItems.DANGER_STRIPE_BLOCK) accept(MItems.METAL_BEAM) + accept(MItems.ENGINE) accept(MItems.TRITANIUM_STRIPED_BLOCK) accept(MItems.TRITANIUM_STRIPED_STAIRS) 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 60a750a26..7cf8c879e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -132,6 +132,7 @@ object MBlocks { val LABORATORY_LAMP_LIGHT: Block by registry.register(MNames.LABORATORY_LAMP_LIGHT) { LaboratoryLampLight() } val DANGER_STRIPE_BLOCK: Block by registry.register(MNames.DANGER_STRIPE_BLOCK) { Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.GRAY).explosionResistance(6f).destroyTime(1.5f).requiresCorrectToolForDrops()) } val METAL_BEAM: Block by registry.register(MNames.METAL_BEAM) { Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.GRAY).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) } + val ENGINE: Block by registry.register(MNames.ENGINE) { Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.ORANGE).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) } val TRITANIUM_DOOR = registry.allColored(MNames.TRITANIUM_DOOR) { color, _ -> object : DoorBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), SoundEvents.IRON_DOOR_CLOSE, SoundEvents.IRON_DOOR_OPEN) { 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 9d58d7dc9..9f9536648 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -264,6 +264,7 @@ object MItems { val LABORATORY_LAMP_INVERTED: Item by registry.register(MNames.LABORATORY_LAMP_INVERTED) { BlockItem(MBlocks.LABORATORY_LAMP_INVERTED, DEFAULT_PROPERTIES) } val DANGER_STRIPE_BLOCK: Item by registry.register(MNames.DANGER_STRIPE_BLOCK) { BlockItem(MBlocks.DANGER_STRIPE_BLOCK, DEFAULT_PROPERTIES) } val METAL_BEAM: Item by registry.register(MNames.METAL_BEAM) { BlockItem(MBlocks.METAL_BEAM, DEFAULT_PROPERTIES) } + val ENGINE: Item by registry.register(MNames.ENGINE) { BlockItem(MBlocks.ENGINE, DEFAULT_PROPERTIES) } val TRITANIUM_DOOR = registry.allColored(MNames.TRITANIUM_DOOR) { color, _ -> DoubleHighBlockItem(MBlocks.TRITANIUM_DOOR[color]!!, DEFAULT_PROPERTIES) } val TRITANIUM_TRAPDOOR = registry.allColored(MNames.TRITANIUM_TRAPDOOR) { color, _ -> BlockItem(MBlocks.TRITANIUM_TRAPDOOR[color]!!, DEFAULT_PROPERTIES) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index 4a2ef2694..4218e4815 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -9,6 +9,7 @@ object MNames { const val LABORATORY_LAMP_LIGHT = "laboratory_lamp_light" const val DANGER_STRIPE_BLOCK = "danger_stripe_block" const val METAL_BEAM = "metal_beam" + const val ENGINE = "engine" // blocks const val ANDROID_STATION = "android_station" From ea6a237de8b01c756bec91d2fcc68a7a9e1c6b4a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 14 Jan 2023 17:34:48 +0700 Subject: [PATCH 0050/1199] Move tick, timer and writeonce to util --- .../ru/dbotthepony/mc/otm/datagen/DataGen.kt | 2 +- .../dbotthepony/mc/otm/GlobalEventHandler.kt | 8 +-- .../android/AndroidResearchDataProvider.kt | 3 +- .../block/entity/AndroidStationBlockEntity.kt | 2 +- .../entity/ChemicalGeneratorBlockEntity.kt | 2 +- .../entity/matter/MatterBottlerBlockEntity.kt | 2 +- .../matter/MatterDecomposerBlockEntity.kt | 3 +- .../matter/MatterRecyclerBlockEntity.kt | 2 +- .../matter/MatterReplicatorBlockEntity.kt | 3 +- .../entity/matter/MatterScannerBlockEntity.kt | 2 +- .../mc/otm/client/ClientTickHandler.kt | 9 ++-- .../dbotthepony/mc/otm/compat/mekanism/QIO.kt | 2 +- .../mc/otm/core/util/IConditionalTickable.kt | 36 ++++++++++++++ .../dbotthepony/mc/otm/core/util/ITickable.kt | 8 +++ .../mc/otm/core/{ => util}/TickList.kt | 49 ++++--------------- .../mc/otm/core/{ => util}/TimerQueue.kt | 2 +- .../mc/otm/core/{ => util}/WriteOnce.kt | 2 +- .../mc/otm/graph/Abstract6Graph.kt | 2 +- .../ru/dbotthepony/mc/otm/graph/Graph6Node.kt | 4 +- .../mc/otm/item/EnergySwordItem.kt | 2 +- .../mc/otm/matter/MatterDataProvider.kt | 2 +- .../mc/otm/registry/MCreativeTabs.kt | 8 +-- .../otm/registry/objects/DecorativeBlock.kt | 2 +- .../mc/otm/saveddata/SavedCountingMap.kt | 2 +- .../mc/otm/tests/TimerQueueTests.kt | 2 +- 25 files changed, 82 insertions(+), 79 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/util/IConditionalTickable.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ITickable.kt rename src/main/kotlin/ru/dbotthepony/mc/otm/core/{ => util}/TickList.kt (67%) rename src/main/kotlin/ru/dbotthepony/mc/otm/core/{ => util}/TimerQueue.kt (97%) rename src/main/kotlin/ru/dbotthepony/mc/otm/core/{ => util}/WriteOnce.kt (93%) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt index f4b40cfb3..f5c244a22 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -20,7 +20,7 @@ import net.minecraftforge.data.event.GatherDataEvent import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.android.AndroidResearchDataProvider import ru.dbotthepony.mc.otm.block.* -import ru.dbotthepony.mc.otm.core.WriteOnce +import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.datagen.blocks.BatteryBankProvider import ru.dbotthepony.mc.otm.datagen.blocks.MatterBankProvider import ru.dbotthepony.mc.otm.datagen.blocks.MatteryBlockStateProvider diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt index 2a0ca3784..08527452f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt @@ -16,10 +16,10 @@ import net.minecraftforge.event.server.ServerStoppingEvent import net.minecraftforge.fml.loading.FMLLoader import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.core.IConditionalTickable -import ru.dbotthepony.mc.otm.core.ITickable -import ru.dbotthepony.mc.otm.core.TickList -import ru.dbotthepony.mc.otm.core.TimerQueue +import ru.dbotthepony.mc.otm.core.util.IConditionalTickable +import ru.dbotthepony.mc.otm.core.util.ITickable +import ru.dbotthepony.mc.otm.core.util.TickList +import ru.dbotthepony.mc.otm.core.util.TimerQueue import java.util.* private val preServerTick = TickList() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDataProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDataProvider.kt index ad2635fa8..779263e7d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDataProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDataProvider.kt @@ -2,12 +2,11 @@ package ru.dbotthepony.mc.otm.android import it.unimi.dsi.fastutil.objects.ObjectArraySet import net.minecraft.data.CachedOutput -import net.minecraft.data.DataGenerator import net.minecraft.data.DataProvider import net.minecraft.data.PackOutput import net.minecraft.resources.ResourceLocation import net.minecraftforge.data.event.GatherDataEvent -import ru.dbotthepony.mc.otm.core.WriteOnce +import ru.dbotthepony.mc.otm.core.util.WriteOnce import java.util.Collections import java.util.LinkedList import java.util.concurrent.CompletableFuture diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/AndroidStationBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/AndroidStationBlockEntity.kt index d59942492..bf212b5ac 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/AndroidStationBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/AndroidStationBlockEntity.kt @@ -21,7 +21,7 @@ import ru.dbotthepony.mc.otm.menu.AndroidStationMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MNames -import ru.dbotthepony.mc.otm.core.WriteOnce +import ru.dbotthepony.mc.otm.core.util.WriteOnce @Suppress("ObjectPropertyName") class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ChemicalGeneratorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ChemicalGeneratorBlockEntity.kt index 50915838f..65397f358 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ChemicalGeneratorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ChemicalGeneratorBlockEntity.kt @@ -29,7 +29,7 @@ import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.menu.ChemicalGeneratorMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MNames -import ru.dbotthepony.mc.otm.core.WriteOnce +import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index b59157637..06526a072 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -38,7 +38,7 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MNames -import ru.dbotthepony.mc.otm.core.WriteOnce +import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index 0850b82c9..c05623c36 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -28,7 +28,6 @@ import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainerHooks -import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph @@ -38,7 +37,7 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MNames -import ru.dbotthepony.mc.otm.core.WriteOnce +import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index 5f9876c5d..12b1cfccd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -41,7 +41,7 @@ import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MNames -import ru.dbotthepony.mc.otm.core.WriteOnce +import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.core.math.getDecimal import ru.dbotthepony.mc.otm.core.math.set diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index daf276288..9895021eb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -31,10 +31,9 @@ import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph import ru.dbotthepony.mc.otm.menu.MatterReplicatorMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities -import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MNames -import ru.dbotthepony.mc.otm.core.WriteOnce +import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt index 103f04e5b..964f7e16a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt @@ -37,7 +37,7 @@ import ru.dbotthepony.mc.otm.menu.MatterScannerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MNames -import ru.dbotthepony.mc.otm.core.WriteOnce +import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.matter.MatterManager import java.util.* import kotlin.math.pow diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientTickHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientTickHandler.kt index 52b8581d2..7b04b4ebc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientTickHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientTickHandler.kt @@ -2,11 +2,10 @@ package ru.dbotthepony.mc.otm.client import net.minecraftforge.client.event.ClientPlayerNetworkEvent import net.minecraftforge.event.TickEvent -import org.apache.logging.log4j.LogManager -import ru.dbotthepony.mc.otm.core.IConditionalTickable -import ru.dbotthepony.mc.otm.core.ITickable -import ru.dbotthepony.mc.otm.core.TickList -import ru.dbotthepony.mc.otm.core.TimerQueue +import ru.dbotthepony.mc.otm.core.util.IConditionalTickable +import ru.dbotthepony.mc.otm.core.util.ITickable +import ru.dbotthepony.mc.otm.core.util.TickList +import ru.dbotthepony.mc.otm.core.util.TimerQueue import ru.dbotthepony.mc.otm.isClient private val preTickList = TickList() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/QIO.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/QIO.kt index 3c4b1ef04..5556f0819 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/QIO.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/QIO.kt @@ -15,7 +15,7 @@ import net.minecraftforge.common.capabilities.ICapabilityProvider import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.event.AttachCapabilitiesEvent import net.minecraftforge.eventbus.api.SubscribeEvent -import ru.dbotthepony.mc.otm.core.ITickable +import ru.dbotthepony.mc.otm.core.util.ITickable import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.onceServer import ru.dbotthepony.mc.otm.capability.MatteryCapability diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/IConditionalTickable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/IConditionalTickable.kt new file mode 100644 index 000000000..7a9491798 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/IConditionalTickable.kt @@ -0,0 +1,36 @@ +package ru.dbotthepony.mc.otm.core.util + +/** + * Represents tick callback with condition, once + */ +interface IConditionalTickable : ITickable { + /** + * Once this returns false, it should stay false. + * + * If it suddenly turns true after being false, result is undefined. + */ + val canTick: Boolean + + companion object { + fun wrap(ticker: () -> Boolean): IConditionalTickable { + return object : IConditionalTickable { + override var canTick: Boolean = true + private set + + override fun tick() { + canTick = !ticker.invoke() + } + } + } + + fun wrap(condition: () -> Boolean, ticker: () -> Unit): IConditionalTickable { + return object : IConditionalTickable { + override val canTick: Boolean get() = condition.invoke() + + override fun tick() { + ticker.invoke() + } + } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ITickable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ITickable.kt new file mode 100644 index 000000000..80c55d765 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ITickable.kt @@ -0,0 +1,8 @@ +package ru.dbotthepony.mc.otm.core.util + +/** + * Represents tick callback + */ +fun interface ITickable { + fun tick() +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/TickList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt similarity index 67% rename from src/main/kotlin/ru/dbotthepony/mc/otm/core/TickList.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt index 8b1d635f9..dcdb6134c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/TickList.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt @@ -1,7 +1,6 @@ -package ru.dbotthepony.mc.otm.core +package ru.dbotthepony.mc.otm.core.util import org.apache.logging.log4j.LogManager -import kotlin.ConcurrentModificationException class TickList { private val conditional = ArrayDeque() @@ -47,10 +46,16 @@ class TickList { } fun until(ticker: () -> Boolean) = add(IConditionalTickable.wrap(ticker)) - fun `while`(tickerCondition: () -> Boolean, ticker: () -> Unit) = add(IConditionalTickable.wrap(tickerCondition, ticker)) + fun `while`(tickerCondition: () -> Boolean, ticker: () -> Unit) = add( + IConditionalTickable.wrap( + tickerCondition, + ticker + ) + ) fun until(ticker: () -> Boolean, condition: Boolean, reason: String) = add(IConditionalTickable.wrap(ticker), condition, reason) - fun `while`(tickerCondition: () -> Boolean, ticker: () -> Unit, condition: Boolean, reason: String) = add(IConditionalTickable.wrap(tickerCondition, ticker), condition, reason) + fun `while`(tickerCondition: () -> Boolean, ticker: () -> Unit, condition: Boolean, reason: String) = add( + IConditionalTickable.wrap(tickerCondition, ticker), condition, reason) fun tick() { if (inTicker) { @@ -97,39 +102,3 @@ class TickList { private val LOGGER = LogManager.getLogger() } } - -fun interface ITickable { - fun tick() -} - -interface IConditionalTickable : ITickable { - /** - * Once this returns false, it should stay false. - * - * If it suddenly turns true after being false, result is undefined. - */ - val canTick: Boolean - - companion object { - fun wrap(ticker: () -> Boolean): IConditionalTickable { - return object : IConditionalTickable { - override var canTick: Boolean = true - private set - - override fun tick() { - canTick = !ticker.invoke() - } - } - } - - fun wrap(condition: () -> Boolean, ticker: () -> Unit): IConditionalTickable { - return object : IConditionalTickable { - override val canTick: Boolean get() = condition.invoke() - - override fun tick() { - ticker.invoke() - } - } - } - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/TimerQueue.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TimerQueue.kt similarity index 97% rename from src/main/kotlin/ru/dbotthepony/mc/otm/core/TimerQueue.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TimerQueue.kt index c4747cc94..2ecbc87eb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/TimerQueue.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TimerQueue.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.core +package ru.dbotthepony.mc.otm.core.util import org.apache.logging.log4j.LogManager diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/WriteOnce.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/WriteOnce.kt similarity index 93% rename from src/main/kotlin/ru/dbotthepony/mc/otm/core/WriteOnce.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/util/WriteOnce.kt index a4c8b047e..bda267313 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/WriteOnce.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/WriteOnce.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.core +package ru.dbotthepony.mc.otm.core.util import kotlin.properties.ReadWriteProperty import kotlin.reflect.KProperty diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Abstract6Graph.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Abstract6Graph.kt index 8a136c671..794e61d1c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Abstract6Graph.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Abstract6Graph.kt @@ -5,7 +5,7 @@ import net.minecraft.core.Direction import net.minecraft.core.SectionPos import net.minecraft.server.level.ServerLevel import net.minecraft.world.level.block.entity.BlockEntity -import ru.dbotthepony.mc.otm.core.IConditionalTickable +import ru.dbotthepony.mc.otm.core.util.IConditionalTickable import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.addTicker import java.util.* diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Graph6Node.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Graph6Node.kt index 73c2cfe99..c8b12be6b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Graph6Node.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Graph6Node.kt @@ -1,8 +1,8 @@ package ru.dbotthepony.mc.otm.graph import net.minecraft.core.Direction -import ru.dbotthepony.mc.otm.core.IConditionalTickable -import ru.dbotthepony.mc.otm.core.ITickable +import ru.dbotthepony.mc.otm.core.util.IConditionalTickable +import ru.dbotthepony.mc.otm.core.util.ITickable import ru.dbotthepony.mc.otm.SERVER_IS_LIVE interface GraphNodeListener { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt index f9065728c..ad59c3415 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt @@ -42,7 +42,7 @@ import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.registry.EMPDamageSource -import ru.dbotthepony.mc.otm.core.WriteOnce +import ru.dbotthepony.mc.otm.core.util.WriteOnce /** * This is called from [net.minecraft.world.item.enchantment.EnchantmentHelper.getSweepingDamageRatio] 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 42b89a276..13fc067dc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterDataProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterDataProvider.kt @@ -9,7 +9,7 @@ import net.minecraft.world.item.Item import net.minecraft.world.level.ItemLike import net.minecraftforge.data.event.GatherDataEvent import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.WriteOnce +import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.core.registryName import java.util.Collections import java.util.concurrent.CompletableFuture diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt index aa7fe5cdd..7a3176d4b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt @@ -1,17 +1,11 @@ package ru.dbotthepony.mc.otm.registry -import com.google.common.collect.Iterators -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap -import it.unimi.dsi.fastutil.objects.ReferenceLinkedOpenHashSet -import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.CreativeModeTab -import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraftforge.event.CreativeModeTabEvent import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.core.WriteOnce -import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.registry.MItems.BATTERY_CREATIVE object MCreativeTabs { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/DecorativeBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/DecorativeBlock.kt index 732085af2..d12237294 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/DecorativeBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/DecorativeBlock.kt @@ -8,7 +8,7 @@ import net.minecraft.world.level.block.state.BlockBehaviour import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.RegistryObject import ru.dbotthepony.mc.otm.core.collect.SupplierMap -import ru.dbotthepony.mc.otm.core.WriteOnce +import ru.dbotthepony.mc.otm.core.util.WriteOnce /** * Base + Colored diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/saveddata/SavedCountingMap.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/saveddata/SavedCountingMap.kt index 6c696ea66..42263a437 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/saveddata/SavedCountingMap.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/saveddata/SavedCountingMap.kt @@ -10,7 +10,7 @@ import net.minecraft.world.level.saveddata.SavedData import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.core.collect.ProxiedMap import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.core.WriteOnce +import ru.dbotthepony.mc.otm.core.util.WriteOnce class SavedMapDelegate(val parent: SavedCountingMap>?, val index: Int, value: V) { constructor(value: V) : this(null, -1, value) diff --git a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/TimerQueueTests.kt b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/TimerQueueTests.kt index 0a2d1edae..efd9f31be 100644 --- a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/TimerQueueTests.kt +++ b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/TimerQueueTests.kt @@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.tests import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test -import ru.dbotthepony.mc.otm.core.TimerQueue +import ru.dbotthepony.mc.otm.core.util.TimerQueue object TimerQueueTests { @Test From 03755ccaa4f1b5cc2f97f434d6d6116650702689 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Sat, 14 Jan 2023 17:18:38 +0600 Subject: [PATCH 0051/1199] engine model --- .../models/block/engine.json | 299 ++++++++++++++++++ .../textures/block/ship_engine.png | Bin 0 -> 918 bytes 2 files changed, 299 insertions(+) create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/engine.json create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/ship_engine.png diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/engine.json b/src/main/resources/assets/overdrive_that_matters/models/block/engine.json new file mode 100644 index 000000000..0d67aa334 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/engine.json @@ -0,0 +1,299 @@ +{ + "textures": { + "0": "overdrive_that_matters:block/ship_engine", + "particle": "overdrive_that_matters:block/ship_engine" + }, + "elements": [ + { + "name": "frame", + "from": [0, 0, 14], + "to": [16, 16, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [0, 0, 8, 4], "rotation": 180, "texture": "#0"}, + "east": {"uv": [0, 4, 8, 4.5], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 8, 4], "texture": "#0"}, + "west": {"uv": [0, 4, 8, 4.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [0, 4, 8, 4.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [0, 4, 8, 4.5], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [1, 1, 10], + "to": [15, 15, 14], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [0, 5.5, 7, 9], "rotation": 180, "texture": "#0"}, + "east": {"uv": [0, 4.5, 7, 5.5], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 7, 7], "texture": "#missing"}, + "west": {"uv": [0, 4.5, 7, 5.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [0, 4.5, 7, 5.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [0, 4.5, 7, 5.5], "texture": "#0"} + } + }, + { + "name": "funnycone", + "from": [4, 4, 7], + "to": [12, 12, 10], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [0, 0, 4, 4], "rotation": 180, "texture": "#missing"}, + "east": {"uv": [2, 1.75, 6, 3.25], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 4, 4], "texture": "#missing"}, + "west": {"uv": [2, 1.75, 6, 3.25], "rotation": 90, "texture": "#0"}, + "up": {"uv": [2, 1.75, 6, 3.25], "rotation": 180, "texture": "#0"}, + "down": {"uv": [2, 1.75, 6, 3.25], "texture": "#0"} + } + }, + { + "name": "funnycone", + "from": [3, 3, 4], + "to": [13, 13, 7], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [0, 0, 5, 5], "rotation": 180, "texture": "#missing"}, + "east": {"uv": [1.5, 2.25, 6.5, 3.75], "rotation": 270, "texture": "#0"}, + "south": {"uv": [1.5, 0.75, 6.5, 3.25], "texture": "#0"}, + "west": {"uv": [1.5, 2.25, 6.5, 3.75], "rotation": 90, "texture": "#0"}, + "up": {"uv": [1.5, 2.25, 6.5, 3.75], "rotation": 180, "texture": "#0"}, + "down": {"uv": [1.5, 2.25, 6.5, 3.75], "texture": "#0"} + } + }, + { + "name": "funnycone", + "from": [2, 2, 0], + "to": [14, 14, 4], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [0, 9, 6, 12], "rotation": 180, "texture": "#0"}, + "east": {"uv": [1, 2, 7, 4], "rotation": 270, "texture": "#0"}, + "south": {"uv": [1, 0.5, 7, 3.5], "texture": "#0"}, + "west": {"uv": [1, 2, 7, 4], "rotation": 90, "texture": "#0"}, + "up": {"uv": [1, 2, 7, 4], "rotation": 180, "texture": "#0"}, + "down": {"uv": [1, 2, 7, 4], "texture": "#0"} + } + }, + { + "name": "funnycone", + "from": [10, 7, 1], + "to": [13, 9, 10], + "rotation": {"angle": -22.5, "axis": "y", "origin": [12, 8, 9.5]}, + "faces": { + "north": {"uv": [12.5, 2.25, 13.5, 3], "rotation": 270, "texture": "#0"}, + "east": {"uv": [12.5, 0, 13.5, 2.25], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 1.5, 1], "texture": "#missing"}, + "west": {"uv": [0, 0, 1, 4.5], "rotation": 90, "texture": "#missing"}, + "up": {"uv": [13.5, 0, 15, 2.25], "rotation": 180, "texture": "#0"}, + "down": {"uv": [11, 0, 12.5, 2.25], "texture": "#0"} + } + }, + { + "name": "funnycone", + "from": [7, 10, 1], + "to": [9, 13, 10], + "rotation": {"angle": 22.5, "axis": "x", "origin": [8, 12, 9.5]}, + "faces": { + "north": {"uv": [12.5, 2.25, 13.5, 3], "rotation": 180, "texture": "#0"}, + "east": {"uv": [11, 0, 12.5, 2.25], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 1, 1.5], "texture": "#missing"}, + "west": {"uv": [13.5, 0, 15, 2.25], "rotation": 90, "texture": "#0"}, + "up": {"uv": [12.5, 0, 13.5, 2.25], "rotation": 180, "texture": "#0"}, + "down": {"uv": [0, 0, 1, 4.5], "texture": "#missing"} + } + }, + { + "name": "funnycone", + "from": [7, 3, 1], + "to": [9, 6, 10], + "rotation": {"angle": -22.5, "axis": "x", "origin": [8, 4, 9.5]}, + "faces": { + "north": {"uv": [12.5, 2.25, 13.5, 3], "rotation": 180, "texture": "#0"}, + "east": {"uv": [13.5, 0, 15, 2.25], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 1, 1.5], "texture": "#missing"}, + "west": {"uv": [11, 0, 12.5, 2.25], "rotation": 90, "texture": "#0"}, + "up": {"uv": [0, 0, 1, 4.5], "rotation": 180, "texture": "#missing"}, + "down": {"uv": [12.5, 0, 13.5, 2.25], "texture": "#0"} + } + }, + { + "name": "funnycone", + "from": [3, 7, 1], + "to": [6, 9, 10], + "rotation": {"angle": 22.5, "axis": "y", "origin": [4, 8, 9.5]}, + "faces": { + "north": {"uv": [12.5, 2.25, 13.5, 3], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 0, 1, 4.5], "rotation": 270, "texture": "#missing"}, + "south": {"uv": [0, 0, 1.5, 1], "texture": "#missing"}, + "west": {"uv": [12.5, 0, 13.5, 2.25], "rotation": 90, "texture": "#0"}, + "up": {"uv": [11, 0, 12.5, 2.25], "rotation": 180, "texture": "#0"}, + "down": {"uv": [13.5, 0, 15, 2.25], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [0, 14, 9], + "to": [2, 16, 14], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [8, 1.75, 9, 2.25], "texture": "#0"}, + "east": {"uv": [9, 0.5, 8, 1.75], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 1, 1], "texture": "#missing"}, + "west": {"uv": [9, 0.5, 8, 1.75], "rotation": 90, "texture": "#0"}, + "up": {"uv": [8, 0.5, 9, 1.75], "rotation": 180, "texture": "#0"}, + "down": {"uv": [8, 0.5, 9, 1.75], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [1, 14, 4], + "to": [2, 15, 9], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [9, 1.5, 9.5, 1.75], "rotation": 180, "texture": "#0"}, + "east": {"uv": [9, 0.25, 9.5, 1.5], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 0.5, 0.25], "texture": "#missing"}, + "west": {"uv": [9, 0.25, 9.5, 1.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [9, 0.25, 9.5, 1.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [9, 0.25, 9.5, 1.5], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [1, 1, 4], + "to": [2, 2, 9], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [9, 1.5, 9.5, 1.75], "rotation": 180, "texture": "#0"}, + "east": {"uv": [9, 0.25, 9.5, 1.5], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 0.5, 0.25], "texture": "#missing"}, + "west": {"uv": [9, 0.25, 9.5, 1.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [9, 0.25, 9.5, 1.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [9, 0.25, 9.5, 1.5], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [14, 1, 4], + "to": [15, 2, 9], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [9, 1.5, 9.5, 1.75], "rotation": 180, "texture": "#0"}, + "east": {"uv": [9, 0.25, 9.5, 1.5], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 0.5, 0.25], "texture": "#missing"}, + "west": {"uv": [9, 0.25, 9.5, 1.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [9, 0.25, 9.5, 1.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [9, 0.25, 9.5, 1.5], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [14, 14, 4], + "to": [15, 15, 9], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [9, 1.5, 9.5, 1.75], "rotation": 180, "texture": "#0"}, + "east": {"uv": [9, 0.25, 9.5, 1.5], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 0.5, 0.25], "texture": "#missing"}, + "west": {"uv": [9, 0.25, 9.5, 1.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [9, 0.25, 9.5, 1.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [9, 0.25, 9.5, 1.5], "texture": "#0"} + } + }, + { + "from": [14, 2, 7], + "to": [15, 14, 9], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [10.5, 0.25, 11, 3.25], "rotation": 180, "texture": "#0"}, + "east": {"uv": [9.5, 0.25, 10.5, 3.25], "texture": "#0"}, + "south": {"uv": [10.5, 0.25, 11, 3.25], "texture": "#0"}, + "west": {"uv": [9.5, 0.25, 10.5, 3.25], "rotation": 180, "texture": "#0"}, + "up": {"uv": [0, 0, 0.5, 1], "rotation": 180, "texture": "#missing"}, + "down": {"uv": [0, 0, 0.5, 1], "texture": "#missing"} + } + }, + { + "name": "frame", + "from": [1, 2, 7], + "to": [2, 14, 9], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [10.5, 0.25, 11, 3.25], "rotation": 180, "texture": "#0"}, + "east": {"uv": [9.5, 0.25, 10.5, 3.25], "texture": "#0"}, + "south": {"uv": [10.5, 0.25, 11, 3.25], "texture": "#0"}, + "west": {"uv": [9.5, 0.25, 10.5, 3.25], "rotation": 180, "texture": "#0"}, + "up": {"uv": [0, 0, 0.5, 1], "rotation": 180, "texture": "#missing"}, + "down": {"uv": [0, 0, 0.5, 1], "texture": "#missing"} + } + }, + { + "name": "frame", + "from": [2, 14, 7], + "to": [14, 15, 9], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [10.5, 0.25, 11, 3.25], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 0, 0.5, 1], "rotation": 270, "texture": "#missing"}, + "south": {"uv": [10.5, 0.25, 11, 3.25], "rotation": 90, "texture": "#0"}, + "west": {"uv": [0, 0, 0.5, 1], "rotation": 90, "texture": "#missing"}, + "up": {"uv": [9.5, 0.25, 10.5, 3.25], "rotation": 270, "texture": "#0"}, + "down": {"uv": [9.5, 0.25, 10.5, 3.25], "rotation": 90, "texture": "#0"} + } + }, + { + "from": [2, 1, 7], + "to": [14, 2, 9], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [10.5, 0.25, 11, 3.25], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 0, 0.5, 1], "rotation": 270, "texture": "#missing"}, + "south": {"uv": [10.5, 0.25, 11, 3.25], "rotation": 90, "texture": "#0"}, + "west": {"uv": [0, 0, 0.5, 1], "rotation": 90, "texture": "#missing"}, + "up": {"uv": [9.5, 0.25, 10.5, 3.25], "rotation": 270, "texture": "#0"}, + "down": {"uv": [9.5, 0.25, 10.5, 3.25], "rotation": 90, "texture": "#0"} + } + }, + { + "name": "frame", + "from": [14, 14, 9], + "to": [16, 16, 14], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [8, 1.75, 9, 2.25], "rotation": 270, "texture": "#0"}, + "east": {"uv": [8, 0.5, 9, 1.75], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 1, 1], "texture": "#missing"}, + "west": {"uv": [8, 0.5, 9, 1.75], "rotation": 90, "texture": "#0"}, + "up": {"uv": [9, 0.5, 8, 1.75], "rotation": 180, "texture": "#0"}, + "down": {"uv": [9, 0.5, 8, 1.75], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [14, 0, 9], + "to": [16, 2, 14], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [8, 1.75, 9, 2.25], "rotation": 180, "texture": "#0"}, + "east": {"uv": [9, 0.5, 8, 1.75], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 1, 1], "texture": "#missing"}, + "west": {"uv": [9, 0.5, 8, 1.75], "rotation": 90, "texture": "#0"}, + "up": {"uv": [8, 0.5, 9, 1.75], "rotation": 180, "texture": "#0"}, + "down": {"uv": [8, 0.5, 9, 1.75], "texture": "#0"} + } + }, + { + "from": [0, 0, 9], + "to": [2, 2, 14], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [8, 1.75, 9, 2.25], "rotation": 90, "texture": "#0"}, + "east": {"uv": [8, 0.5, 9, 1.75], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 1, 1], "texture": "#missing"}, + "west": {"uv": [8, 0.5, 9, 1.75], "rotation": 90, "texture": "#0"}, + "up": {"uv": [9, 0.5, 8, 1.75], "rotation": 180, "texture": "#0"}, + "down": {"uv": [9, 0.5, 8, 1.75], "texture": "#0"} + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/ship_engine.png b/src/main/resources/assets/overdrive_that_matters/textures/block/ship_engine.png new file mode 100644 index 0000000000000000000000000000000000000000..fd3cdf6e823632be3450239dee545593156f5929 GIT binary patch literal 918 zcmV;H18Mw;P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D11m{HK~!i%?U+Gp z6G0TmCo6$81mey1lv^Z(o=Q+JLcxRQl0%P)egpjwf`@(rCGqCPqs4%5t~o%iO=+nJ<=R;#s`PN!-ucx}*uI}0C_xlC3g=Vw4VCR^K!Q==GEr8CL_KikERVo$IUEu&c zb22z&r`!TL&bDUOCX)#XQ>)diBJuD?I*-E^gj{{nOi%#8#W^Fh0kG=(z8~mG2m(k7 z*90<=bk!0HAj#^ph60cko)j*`M}q-XwPZ9JY3(oOSSA@53aII{cnyccVCC(0dw~{#@OutAoequ5F(!2p+On3W7*p54I&~unGLU4#C|g?=ka}DC z0R_O7>=Fdqn8&ar%$beQ%P0zI@B6;9GaDX?NuKL20`N>02Ut)8n9wByu6C|?%Pk;< zSI3jHBU1p|^0Vtuc(%R0_`0)09lp`P2R*rM?Dolt`ts?;Q|iR<>c*V|ty;Nq5N&O2 zknooW?q3%afc&O%dT~KgJ3J)eK9F{Af4(^;B?1?l&y( zHr{M+Ppg-3%1x2*Gf^paNk0fOfV=v~Y!)fzeU23_9nmV$vJPBU4=4akj8`iT*x0^Q zNXNkJN8#N)I$C+x{JykVOX8B9j30iq9cQRu8hv zz^^Bll90>-IBRU4Lv+^}@8j++U9-1JB|Q`lY+#FLvVt;z8;*mB64>xfPR{3{aTPe-E2?*v*ktOLTR}TfbF+luU7r({sE1l1+b3`AlL#-8YL!;(MxJ? z-fNNoIEQWq7RAbI$p2(A#RSfOANzr0AOn%(ails2Oy}>^0}=+GyOJsZ(>cRBK6l-Q z)EUT%Q~{vMIf#eqJ+**!e8z7=9H|1}YG>eB29ml6@y`XDn8*y+NL7S5G@``B3<5gj sbM3JnapRvK#W^`SIXO8w|2s Date: Sat, 14 Jan 2023 19:18:16 +0700 Subject: [PATCH 0052/1199] BESubscribeList Fxies #227 --- .../entity/ChemicalGeneratorBlockEntity.kt | 55 ++------ .../mc/otm/core/collect/WeakHashSet.kt | 53 +++++++ .../mc/otm/core/util/BESubscribeList.kt | 130 ++++++++++++++++++ 3 files changed, 195 insertions(+), 43 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/WeakHashSet.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/util/BESubscribeList.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ChemicalGeneratorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ChemicalGeneratorBlockEntity.kt index 65397f358..d802eb763 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ChemicalGeneratorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ChemicalGeneratorBlockEntity.kt @@ -18,7 +18,6 @@ import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.energy.IEnergyStorage -import ru.dbotthepony.mc.otm.* import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.capability.* @@ -33,11 +32,9 @@ import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal -import ru.dbotthepony.mc.otm.core.math.plus -import ru.dbotthepony.mc.otm.core.math.unaryMinus import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set -import java.lang.ref.WeakReference +import ru.dbotthepony.mc.otm.core.util.BESubscribeList class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryBlockEntity(MBlockEntities.CHEMICAL_GENERATOR, pos, state), IDroppableContainer { override val defaultDisplayName: Component @@ -53,11 +50,13 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryBl get() = container val energy = GeneratorEnergyStorage(this::setChangedLight, CAPACITY, THROUGHPUT) - private val consumers = ArrayList>() + private val consumers = BESubscribeList(this, ForgeCapabilities.ENERGY) + + fun checkSurroundings() = consumers.update() override fun setChangedLight() { super.setChangedLight() - check = true + checkFuelSlot = true } override fun getCapability(cap: Capability, side: Direction?): LazyOptional { @@ -86,7 +85,7 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryBl override fun setLevel(p_155231_: Level) { super.setLevel(p_155231_) - tickOnceServer(this::checkSurroundings) + tickOnceServer(consumers::update) } override fun saveAdditional(nbt: CompoundTag) { @@ -107,36 +106,6 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryBl workTicksTotal = nbt.getInt(WORK_TICKS_TOTAL_KEY) } - fun checkSurroundings() { - if (!valid) - return - - val known = consumers.clone() as ArrayList<*> - consumers.clear() - val level = level ?: return - - for (direction in Direction.values()) { - // нельзя выталкивать энергию через перед - if (direction == blockState.getValue(RotatableMatteryBlock.FACING)) - continue - - val resolver = level.getBlockEntity(blockPos + direction)?.getEnergySided(-direction) - - resolver?.ifPresentK { - if (!known.contains(resolver)) { - val ref = WeakReference(this) - - resolver.addListener { - if (SERVER_IS_LIVE) - ref.get()?.checkSurroundings() - } - } - - consumers.add(resolver) - } - } - } - val itemHandler = container.handler(object : MatteryContainerHooks { override fun canInsert(slot: Int, stack: ItemStack): Boolean { if (slot == SLOT_INPUT) @@ -160,7 +129,7 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryBl super.setBlockState(p_155251_) if (valid) - tickOnceServer(this::checkSurroundings) + tickOnceServer(consumers::update) } var workTicks = 0 @@ -169,7 +138,7 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryBl var workTicksTotal = 0 private set - private var check = true + private var checkFuelSlot = true private fun workWithPower(it: IEnergyStorage) { val extracted = energy.extractEnergy(THROUGHPUT, true) @@ -187,7 +156,7 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryBl if (workTicks == 0) { workTicksTotal = 0 - check = true + checkFuelSlot = true } if (blockState.getValue(WorkerState.SEMI_WORKER_STATE) != WorkerState.WORKING) { @@ -197,7 +166,7 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryBl level?.setBlock(blockPos, blockState.setValue(WorkerState.SEMI_WORKER_STATE, WorkerState.IDLE), Block.UPDATE_CLIENTS) } - if (workTicks == 0 && !isBlockedByRedstone && check) { + if (workTicks == 0 && !isBlockedByRedstone && checkFuelSlot) { if (!container[SLOT_INPUT].isEmpty) { val ticks = ForgeHooks.getBurnTime(container[SLOT_INPUT], null) val residue = container[SLOT_INPUT].item.getCraftingRemainingItem(container[SLOT_INPUT].copy().also { it.count = 1 }) @@ -220,7 +189,7 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryBl } } - check = false + checkFuelSlot = false } if (energy.batteryLevel.isZero) return @@ -233,7 +202,7 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryBl } for (consumer in consumers) { - consumer.ifPresent(this::workWithPower) + workWithPower(consumer) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/WeakHashSet.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/WeakHashSet.kt new file mode 100644 index 000000000..b00538f52 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/WeakHashSet.kt @@ -0,0 +1,53 @@ +package ru.dbotthepony.mc.otm.core.collect + +import java.util.WeakHashMap + +/** + * Wrapper around [WeakHashMap] to behave like set + */ +class WeakHashSet : MutableSet { + private val backing = WeakHashMap() + + override fun add(element: E): Boolean { + return backing.put(element, Unit) == null + } + + override fun addAll(elements: Collection): Boolean { + return elements.count(::add) > 0 + } + + override fun clear() { + backing.clear() + } + + override fun iterator(): MutableIterator { + return backing.keys.iterator() + } + + override fun remove(element: E): Boolean { + return backing.remove(element) != null + } + + override fun removeAll(elements: Collection): Boolean { + return backing.keys.removeAll(elements) + } + + override fun retainAll(elements: Collection): Boolean { + return backing.keys.retainAll(elements) + } + + override val size: Int + get() = backing.size + + override fun contains(element: E): Boolean { + return backing.get(element) === Unit + } + + override fun containsAll(elements: Collection): Boolean { + return elements.all(::contains) + } + + override fun isEmpty(): Boolean { + return backing.isEmpty() + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/BESubscribeList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/BESubscribeList.kt new file mode 100644 index 000000000..6fa95f0e1 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/BESubscribeList.kt @@ -0,0 +1,130 @@ +package ru.dbotthepony.mc.otm.core.util + +import net.minecraft.core.Direction +import net.minecraft.core.SectionPos +import net.minecraft.world.level.block.entity.BlockEntity +import net.minecraftforge.common.capabilities.Capability +import net.minecraftforge.common.util.LazyOptional +import ru.dbotthepony.mc.otm.core.collect.WeakHashSet +import ru.dbotthepony.mc.otm.core.math.plus +import ru.dbotthepony.mc.otm.core.orNull +import ru.dbotthepony.mc.otm.onceServer +import java.lang.ref.WeakReference +import java.util.EnumMap +import java.util.function.Predicate + +open class BESubscribeList( + val block: BlockEntity, + val capability: Capability, +) : Predicate, Iterable { + private val knownCaps = WeakHashSet>() + private val trackedCaps = EnumMap>>(Direction::class.java) + + var valid = true + set(value) { + if (value != field) { + field = value + + if (value) { + update() + } + } + } + + fun invalidate() { + valid = false + } + + fun revive() { + valid = true + } + + // override + protected open fun subscribe(direction: Direction, capability: LazyOptional) {} + // override + protected open fun unsubscribe(direction: Direction, capability: LazyOptional?) {} + + override fun test(t: Direction): Boolean { + return true + } + + fun validate() { + val iterator = trackedCaps.iterator() + + for ((k, v) in iterator) { + if (v.get() == null) { + unsubscribe(k, null) + } + } + } + + override fun iterator(): Iterator { + return object : Iterator { + val iterator = trackedCaps.iterator() + var value: T? = null + + private fun find() { + while (iterator.hasNext() && value == null) { + val (k, v) = iterator.next() + value = v.get()?.orNull() + + if (value == null) { + iterator.remove() + unsubscribe(k, null) + } + } + } + + override fun hasNext(): Boolean { + find() + return value != null + } + + override fun next(): T { + find() + val value = value + this.value = null + return value ?: throw NoSuchElementException() + } + } + } + + fun update() { + if (!valid) + return + + val sorse = block.level?.chunkSource ?: return + var waitChunkLoad = false + + for (it in Direction.stream().filter(this)) { + val pos = block.blockPos + it + val getChunk = sorse.getChunkNow(SectionPos.blockToSectionCoord(pos.x), SectionPos.blockToSectionCoord(pos.z)) + + if (getChunk == null) { + waitChunkLoad = true + } else { + val cap = getChunk.getBlockEntity(pos)?.getCapability(capability) + val knownCap = trackedCaps[it]?.get() + + if (cap != null && cap.isPresent) { + if (knownCap !== cap) { + if (knownCaps.add(cap)) { + val ref = WeakReference(this) + cap.addListener { ref.get()?.update() } + } + + trackedCaps[it] = WeakReference(cap) + subscribe(it, cap) + } + } else { + trackedCaps.remove(it) + unsubscribe(it, knownCap) + } + } + } + + if (waitChunkLoad) { + onceServer(::update) + } + } +} From 3c73f809dc6431f3b507ce96a242e1a9bec759ad Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 14 Jan 2023 20:05:41 +0700 Subject: [PATCH 0053/1199] Misc updates to BESubscribeList --- .../mc/otm/core/util/BESubscribeList.kt | 55 +++++++++++++++---- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/BESubscribeList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/BESubscribeList.kt index 6fa95f0e1..8d33f4aed 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/BESubscribeList.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/BESubscribeList.kt @@ -52,7 +52,7 @@ open class BESubscribeList( val iterator = trackedCaps.iterator() for ((k, v) in iterator) { - if (v.get() == null) { + if (v.get() == null || !test(k)) { unsubscribe(k, null) } } @@ -68,7 +68,7 @@ open class BESubscribeList( val (k, v) = iterator.next() value = v.get()?.orNull() - if (value == null) { + if (value == null || !test(k)) { iterator.remove() unsubscribe(k, null) } @@ -89,42 +89,73 @@ open class BESubscribeList( } } - fun update() { + fun update(direction: Direction) { + return update(direction::equals) + } + + private var updateTick = 0 + + /** + * Updates subscription list, searching for new capabilities or "removing" outdated ones + * + * [predicate] predicate narrows sides-to-check list, not replaces list generated by this class' [test] + */ + @JvmOverloads + fun update(predicate: Predicate? = null) { if (!valid) return val sorse = block.level?.chunkSource ?: return var waitChunkLoad = false - for (it in Direction.stream().filter(this)) { - val pos = block.blockPos + it + updateTick++ + val updateTick = updateTick + var stream = Direction.stream().filter(this) + + if (predicate != null) { + stream = stream.filter(predicate) + } + + for (dir in stream) { + val pos = block.blockPos + dir val getChunk = sorse.getChunkNow(SectionPos.blockToSectionCoord(pos.x), SectionPos.blockToSectionCoord(pos.z)) if (getChunk == null) { waitChunkLoad = true } else { val cap = getChunk.getBlockEntity(pos)?.getCapability(capability) - val knownCap = trackedCaps[it]?.get() + val knownCap = trackedCaps[dir]?.get() if (cap != null && cap.isPresent) { if (knownCap !== cap) { if (knownCaps.add(cap)) { val ref = WeakReference(this) - cap.addListener { ref.get()?.update() } + + cap.addListener { + val self = ref.get() + + if (self != null) { + val current = self.trackedCaps[dir] + + if (current?.get() === it) { + self.update() + } + } + } } - trackedCaps[it] = WeakReference(cap) - subscribe(it, cap) + trackedCaps[dir] = WeakReference(cap) + subscribe(dir, cap) } } else { - trackedCaps.remove(it) - unsubscribe(it, knownCap) + trackedCaps.remove(dir) + unsubscribe(dir, knownCap) } } } if (waitChunkLoad) { - onceServer(::update) + onceServer { if (updateTick == this.updateTick) update(predicate) } } } } From 95a9aa72aa04a3684f44f465dea00525ade43159 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 14 Jan 2023 22:06:45 +0700 Subject: [PATCH 0054/1199] Move everything to BESubscribeList (and eliminate old, bugged code) --- .../mc/otm/block/BatteryBankBlock.kt | 5 +- .../block/entity/BatteryBankBlockEntity.kt | 35 +--- .../block/entity/EnergyCounterBlockEntity.kt | 86 +++----- .../mc/otm/block/entity/MatteryBlockEntity.kt | 23 --- .../block/entity/storage/StorageInterfaces.kt | 66 ++++--- .../mc/otm/core/util/BESubscribeList.kt | 186 +++++++++++++++--- 6 files changed, 244 insertions(+), 157 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/BatteryBankBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/BatteryBankBlock.kt index bb2a49852..7d6051719 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/BatteryBankBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/BatteryBankBlock.kt @@ -19,6 +19,7 @@ import net.minecraft.world.level.block.Block import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.once +import ru.dbotthepony.mc.otm.oncePre import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -77,7 +78,7 @@ class BatteryBankBlock : RotatableMatteryBlock(), EntityBlock { ) { super.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston) val blockEntity = level.getBlockEntity(pos) as? BatteryBankBlockEntity ?: return - level.once { blockEntity.checkSurroundings(level) } + level.oncePre { blockEntity.checkSurroundings() } } companion object { @@ -111,4 +112,4 @@ class BatteryBankBlock : RotatableMatteryBlock(), EntityBlock { ) } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BatteryBankBlockEntity.kt index 33924d262..da1a32af7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BatteryBankBlockEntity.kt @@ -31,6 +31,7 @@ import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.unaryMinus import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.core.util.BESubscribeList import ru.dbotthepony.mc.otm.menu.BatteryBankMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -263,7 +264,7 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte override fun setLevel(p_155231_: Level) { super.setLevel(p_155231_) - tickOnceServer(this::checkSurroundings) + checkSurroundings() } override fun getCapability(cap: Capability, side: Direction?): LazyOptional { @@ -294,41 +295,23 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte return super.getCapability(cap,side) } - private var consumingCapability = LazyOptional.empty() - - fun checkSurroundings(level: Level) { - if (isRemoved) return - - val tile = level.getBlockEntity(blockPos.offset(blockState.getValue(RotatableMatteryBlock.FACING).normal)) - - if (tile == null) { - consumingCapability = LazyOptional.empty() - return - } - - consumingCapability = getAndBind( - old = consumingCapability, - provider = tile, - capability = ForgeCapabilities.ENERGY, - side = -blockState.getValue(RotatableMatteryBlock.FACING) - ) { - @Suppress("name_shadowing") - val level = this.level - - if (level is ServerLevel && !SERVER_IS_LIVE) - checkSurroundings(level) + private val consumers = object : BESubscribeList(this@BatteryBankBlockEntity, ForgeCapabilities.ENERGY) { + override fun test(t: Direction): Boolean { + return -blockState.getValue(RotatableMatteryBlock.FACING) == t } } + fun checkSurroundings() = consumers.update((-blockState.getValue(RotatableMatteryBlock.FACING))::equals) + fun tick() { if (isBlockedByRedstone) return - consumingCapability.ifPresentK { + for (it in consumers) { val (_, maxThroughput) = energy.getDistribution(false) if (maxThroughput.isZero) - return@ifPresentK + continue val diff = it.receiveEnergy(maxThroughput, true) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt index 58bbf5a95..19cbaf27d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt @@ -29,6 +29,7 @@ import ru.dbotthepony.mc.otm.core.nbt.getByteArrayList import ru.dbotthepony.mc.otm.core.nbt.ifHas import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.core.util.BESubscribeList import ru.dbotthepony.mc.otm.menu.EnergyCounterMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import java.lang.ref.WeakReference @@ -125,8 +126,17 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat private val energyInput = EnergyCounterCap(true) private val energyOutput = EnergyCounterCap(false) - private var inputCapability: LazyOptional = LazyOptional.empty() - private var outputCapability: LazyOptional = LazyOptional.empty() + private val inputCapability = object : BESubscribeList(this@EnergyCounterBlockEntity, ForgeCapabilities.ENERGY) { + override fun test(t: Direction): Boolean { + return t == blockState.getValue(EnergyCounterBlock.INPUT_DIRECTION) + } + } + + private val outputCapability = object : BESubscribeList(this@EnergyCounterBlockEntity, ForgeCapabilities.ENERGY) { + override fun test(t: Direction): Boolean { + return t == -blockState.getValue(EnergyCounterBlock.INPUT_DIRECTION) + } + } override fun setLevel(p_155231_: Level) { super.setLevel(p_155231_) @@ -137,9 +147,9 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat override val energyFlow = FlowDirection.input(isInput) override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { - if (inputCapability.isPresent) { - val it = inputCapability.resolve().get() + val it = inputCapability.first + if (it != null) { val diff: Decimal val ioLimit = ioLimit @@ -162,9 +172,9 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat } override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { - if (outputCapability.isPresent) { - val it = outputCapability.resolve().get() + val it = outputCapability.first + if (it != null) { val diff: Decimal val ioLimit = ioLimit @@ -192,9 +202,9 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat override var batteryLevel: Decimal get() { if (energyFlow.input) { - if (outputCapability.isPresent) { - val it = outputCapability.resolve().get() + val it = outputCapability.first + if (it != null) { if (it is IMatteryEnergyStorage) { return it.batteryLevel } @@ -202,9 +212,9 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat return Decimal(it.energyStored) } } else { - if (inputCapability.isPresent) { - val it = inputCapability.resolve().get() + val it = inputCapability.first + if (it != null) { if (it is IMatteryEnergyStorage) { return it.batteryLevel } @@ -222,9 +232,9 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat override val maxBatteryLevel: Decimal get() { if (energyFlow.input) { - if (outputCapability.isPresent) { - val it = outputCapability.resolve().get() + val it = outputCapability.first + if (it != null) { if (it is IMatteryEnergyStorage) { return it.maxBatteryLevel } @@ -232,9 +242,9 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat return Decimal(it.maxEnergyStored) } } else { - if (inputCapability.isPresent) { - val it = inputCapability.resolve().get() + val it = inputCapability.first + if (it != null) { if (it is IMatteryEnergyStorage) { return it.maxBatteryLevel } @@ -249,9 +259,9 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat override val missingPower: Decimal get() { if (energyFlow.input) { - if (outputCapability.isPresent) { - val it = outputCapability.resolve().get() + val it = outputCapability.first + if (it != null) { if (it is IMatteryEnergyStorage) { return it.missingPower } @@ -259,9 +269,9 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat return Decimal((it.maxEnergyStored - it.energyStored).coerceAtLeast(0)) } } else { - if (inputCapability.isPresent) { - val it = inputCapability.resolve().get() + val it = inputCapability.first + if (it != null) { if (it is IMatteryEnergyStorage) { return it.missingPower } @@ -326,45 +336,9 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat } } - private fun getAndBind( - level: Level, - old: LazyOptional, - side: Direction - ): LazyOptional { - val ent = level.getBlockEntity(blockPos.offset(side.normal)) ?: return LazyOptional.empty() - val resolve = ent.getEnergySided(-side) - - if (resolve !== old) { - if (resolve.isPresent) { - val weak = WeakReference(this) - - resolve.addListener { - if (SERVER_IS_LIVE) - weak.get()?.checkSurroundings() - } - } - - return resolve - } - - return old - } - fun checkSurroundings() { - val level = level - if (isRemoved || level !is ServerLevel) return - - inputCapability = getAndBind( - level, - inputCapability, - blockState.getValue(EnergyCounterBlock.INPUT_DIRECTION) - ) - - outputCapability = getAndBind( - level, - outputCapability, - -blockState.getValue(EnergyCounterBlock.INPUT_DIRECTION) - ) + inputCapability.update((blockState.getValue(EnergyCounterBlock.INPUT_DIRECTION))::equals) + outputCapability.update((-blockState.getValue(EnergyCounterBlock.INPUT_DIRECTION))::equals) } override fun getCapability(cap: Capability, side: Direction?): LazyOptional { 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 c2ed4d53b..33f761487 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 @@ -98,29 +98,6 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc level.oncePre { if (!isRemoved) func.invoke(level) } } - protected fun getAndBind( - old: LazyOptional, - provider: ICapabilityProvider?, - capability: Capability, - side: Direction, - invalidate: Runnable - ): LazyOptional { - val get = provider?.getCapability(capability, side) ?: LazyOptional.empty() - - if (old !== get) { - if (get.isPresent) { - val ref = WeakReference(invalidate) - get.addListener { - ref.get()?.run() - } - } - - return get.cast() - } - - return get.cast() - } - override fun getDisplayName(): Component { return customDisplayName ?: defaultDisplayName } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt index acf76caf0..0e5f177a0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt @@ -27,11 +27,11 @@ import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.core.math.toIntSafe import ru.dbotthepony.mc.otm.core.math.unaryMinus import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.core.util.BESubscribeList import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.GraphNodeListener import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode @@ -81,12 +81,14 @@ abstract class AbstractStorageImportExport( override fun invalidateCaps() { super.invalidateCaps() cell.invalidate() + target.invalidate() valid = false } override fun reviveCaps() { super.reviveCaps() cell.revive() + target.revive() valid = true } @@ -101,21 +103,22 @@ abstract class AbstractStorageImportExport( if (p_155231_ is ServerLevel) { StorageNetworkGraph.discoverFull(this, cell.storageNode) + tickOnceServer(this::checkSurroundings) } - - tickOnceServer(this::checkSurroundings) } - protected var target: LazyOptional = LazyOptional.empty() protected abstract val targetCapability: Capability + protected val target by lazy { + object : BESubscribeList(this@AbstractStorageImportExport, targetCapability) { + override fun test(t: Direction): Boolean { + return t == -this@AbstractStorageImportExport.blockState.getValue(RotatableMatteryBlock.FACING_FULL) + } + } + } + fun checkSurroundings() { - target = getAndBind( - target, - level?.getBlockEntity(blockPos + blockState.getValue(RotatableMatteryBlock.FACING_FULL).normal), - targetCapability, - -blockState.getValue(RotatableMatteryBlock.FACING_FULL), - ) { tickOnceServer(this::checkSurroundings) } + target.update() } abstract val filter: ItemFilter @@ -226,18 +229,18 @@ class StorageImporterBlockEntity(blockPos: BlockPos, blockState: BlockState) nextTick-- - if (nextTick <= 0 && target.isPresent && enoughEnergy) { + val target = target.firstOrNull() + + if (nextTick <= 0 && target != null && enoughEnergy) { val graph = cell.storageGraph ?: return val items = graph.getVirtualComponent(ITEM_STORAGE) - val resolved = target.orThrow() - - if (lastSlot >= resolved.slots) { + if (lastSlot >= target.slots) { lastSlot = 0 } val maxMove = energy.extractEnergyExact(ITEM_STORAGE.energyPerOperation, MAX_MOVE_PER_OPERATION, true) - var extracted = resolved.extractItem(lastSlot, maxMove, true) + var extracted = target.extractItem(lastSlot, maxMove, true) if (extracted.isEmpty || !filter.match(extracted)) { lastSlot++ @@ -245,7 +248,7 @@ class StorageImporterBlockEntity(blockPos: BlockPos, blockState: BlockState) val leftOver = items.insertStack(ItemStackWrapper(extracted), true) if (leftOver.count.toInt() != extracted.count) { - extracted = resolved.extractItem(lastSlot, extracted.count - leftOver.count.toInt(), false) + extracted = target.extractItem(lastSlot, extracted.count - leftOver.count.toInt(), false) energy.extractEnergyExact(ITEM_STORAGE.energyPerOperation, extracted.count, false) items.insertStack(ItemStackWrapper(extracted), false) } else { @@ -335,43 +338,50 @@ class StorageExporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : nextTick-- - if (nextTick <= 0 && target.isPresent && enoughEnergy) { + val target = target.firstOrNull() + + if (nextTick <= 0 && target != null && enoughEnergy) { val graph = cell.storageGraph ?: return val items = graph.getVirtualComponent(ITEM_STORAGE) - val resolved = target.orThrow() - - if (lastSlot >= resolved.slots) { + if (lastSlot >= target.slots) { lastSlot = 0 } var hit = false for (stack in exportStacks) { - if (!resolved.isItemValid(lastSlot, stack.second.item)) { + if (!target.isItemValid(lastSlot, stack.second.item)) { continue } - val exportAmountA = items.extractStack(stack.first, stack.second.count.coerceAtMost( - MAX_MOVE_PER_OPERATION - ), true).count + val exportAmountA = items.extractStack( + stack.first, stack.second.count.coerceAtMost( + MAX_MOVE_PER_OPERATION + ), true + ).count if (exportAmountA == BigInteger.ZERO) { continue } - var exportAmount = energy.extractEnergyExact(ITEM_STORAGE.energyPerOperation, exportAmountA, true).toIntSafe() + var exportAmount = + energy.extractEnergyExact(ITEM_STORAGE.energyPerOperation, exportAmountA, true).toIntSafe() if (exportAmount == 0) { break } - val leftover = resolved.insertItem(lastSlot, stack.second.stack.also { it.count = exportAmount }, true) + val leftover = target.insertItem(lastSlot, stack.second.stack.also { it.count = exportAmount }, true) if (leftover.count != exportAmount) { hit = true - exportAmount = items.extractStack(stack.first, (exportAmount - leftover.count).toBigInteger(), false).count.toInt() - resolved.insertItem(lastSlot, stack.second.stack.also { it.count = exportAmount }, false) + exportAmount = items.extractStack( + stack.first, + (exportAmount - leftover.count).toBigInteger(), + false + ).count.toInt() + target.insertItem(lastSlot, stack.second.stack.also { it.count = exportAmount }, false) energy.extractEnergyExact(ITEM_STORAGE.energyPerOperation, exportAmount, false) break } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/BESubscribeList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/BESubscribeList.kt index 8d33f4aed..0d4fc1517 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/BESubscribeList.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/BESubscribeList.kt @@ -2,23 +2,84 @@ package ru.dbotthepony.mc.otm.core.util import net.minecraft.core.Direction import net.minecraft.core.SectionPos +import net.minecraft.server.level.ServerLevel import net.minecraft.world.level.block.entity.BlockEntity import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.util.LazyOptional +import ru.dbotthepony.mc.otm.SERVER_IS_LIVE import ru.dbotthepony.mc.otm.core.collect.WeakHashSet import ru.dbotthepony.mc.otm.core.math.plus +import ru.dbotthepony.mc.otm.core.math.unaryMinus import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.onceServer import java.lang.ref.WeakReference import java.util.EnumMap import java.util.function.Predicate +private inline val Direction.flag: Int get() = 1 shl (ordinal + 1) + +/** + * This class allows block entities to track [capability] per block side. + * + * Allowed sides are governed by [test] method, which is open for override. + * + * **IMPORTANT:** Once rules behind [test] are changed, you MUST call [validate] or [update] right away, or expect hard to debug bugs. + * If rule changes can't be tracked in practical way, then flip on [alwaysValidate], although it will come with performance + * penalty (this will cause [iterator] to invoke [validate] on each its invocation). + * + * Subclasses can also override [subscribe] and [unsubscribe] to more finely track changes in neighbours. + * + * **THIS CLASS IS COMPLETELY THREAD UNSAFE**, it is assumed you only ever invoke it on server thread, + * or, at very least, thread where [ServerLevel] resides. + */ open class BESubscribeList( val block: BlockEntity, val capability: Capability, + val alwaysValidate: Boolean = false ) : Predicate, Iterable { private val knownCaps = WeakHashSet>() private val trackedCaps = EnumMap>>(Direction::class.java) + private var updateQueued = false + private var firstKey: Direction? = null + private var lastDirectionSet = 0 + private var isWaitingOnChunk = false + + /** + * First valid capability, this is faster than invoking [iterator] and getting first value from it. + */ + val first: T? get() { + return firstLO.orNull() + } + + /** + * First valid capability as [LazyOptional], this is faster than invoking [iterator] and getting first value from it. + * + * If required, calls [update] + */ + val firstLO: LazyOptional get() { + if (updateQueued) { + update() + } else if (alwaysValidate) { + validate() + } + + for (i in 0 .. 2) { + if (firstKey == null) { + return LazyOptional.empty() + } + + val get = trackedCaps[firstKey]?.get() + + if (get == null || !get.isPresent) { + update() + continue + } + + return get + } + + return LazyOptional.empty() + } var valid = true set(value) { @@ -48,17 +109,13 @@ open class BESubscribeList( return true } - fun validate() { - val iterator = trackedCaps.iterator() - - for ((k, v) in iterator) { - if (v.get() == null || !test(k)) { - unsubscribe(k, null) - } - } - } - override fun iterator(): Iterator { + if (updateQueued) { + update() + } else if (alwaysValidate) { + validate() + } + return object : Iterator { val iterator = trackedCaps.iterator() var value: T? = null @@ -68,9 +125,13 @@ open class BESubscribeList( val (k, v) = iterator.next() value = v.get()?.orNull() - if (value == null || !test(k)) { + if (value == null) { iterator.remove() unsubscribe(k, null) + } else if (!test(k)) { + iterator.remove() + unsubscribe(k, null) + updateQueued = true } } } @@ -93,29 +154,99 @@ open class BESubscribeList( return update(direction::equals) } - private var updateTick = 0 + private fun calculateDirectionSet(): Int { + var set = 0 + + for (value in VALUES) + if (test(value)) + set = set or value.flag + + return set + } /** - * Updates subscription list, searching for new capabilities or "removing" outdated ones + * Checks for one of these conditions to be true: + * * If [test] was determined to be changed during last time [iterator] was invoked AND tracked capability was filtered out due to [test] returning false + * * Performs a fast bitflag intersection test, by calling [test] on all directions and seeking difference between built set and previous set checked during last [update] + * * Tracked capabilities are checked for validity (if references are still valid) * - * [predicate] predicate narrows sides-to-check list, not replaces list generated by this class' [test] + * Once *any* of conditions above end up true, [update] is called and nothing else down the list is checked further. + */ + fun validate() { + check(valid) { "Subscription list is marked as invalid" } + + if (updateQueued) { + update() + return + } + + val new = calculateDirectionSet() + + if (new != lastDirectionSet) { + val intersect = new and lastDirectionSet + val removed = lastDirectionSet and (intersect.inv()) + val added = new and (intersect.inv()) + + for (dir in VALUES) { + if (dir.flag and removed != 0) { + val value1 = trackedCaps.remove(dir) + val value = value1?.get() + + if (value1 != null) { + unsubscribe(dir, value) + } + } + } + + if (added != 0) { + update { it.flag and added != 0 } + } + + lastDirectionSet = new + return + } + + val iterator = trackedCaps.iterator() + var any = 0 + + for ((k, v) in iterator) { + if (v.get() == null) { + unsubscribe(k, null) + any = any or k.flag + } + } + + if (any != 0) { + update { it.flag and any != 0 } + } + } + + /** + * Updates subscription list, searching for new capabilities and "removing" outdated ones. + * + * [predicate] narrows sides-to-check list, not replaces the set generated by this class' [test] */ @JvmOverloads fun update(predicate: Predicate? = null) { - if (!valid) + if (!valid || block.isRemoved) return - val sorse = block.level?.chunkSource ?: return + val level = block.level as? ServerLevel ?: return // don't run on client + val sorse = level.chunkSource var waitChunkLoad = false - updateTick++ - val updateTick = updateTick - var stream = Direction.stream().filter(this) + var stream = Direction.stream() if (predicate != null) { stream = stream.filter(predicate) + } else { + updateQueued = false + lastDirectionSet = calculateDirectionSet() } + stream = stream.filter(this) + firstKey = null + for (dir in stream) { val pos = block.blockPos + dir val getChunk = sorse.getChunkNow(SectionPos.blockToSectionCoord(pos.x), SectionPos.blockToSectionCoord(pos.z)) @@ -123,7 +254,7 @@ open class BESubscribeList( if (getChunk == null) { waitChunkLoad = true } else { - val cap = getChunk.getBlockEntity(pos)?.getCapability(capability) + val cap = getChunk.getBlockEntity(pos)?.getCapability(capability, -dir) val knownCap = trackedCaps[dir]?.get() if (cap != null && cap.isPresent) { @@ -147,6 +278,10 @@ open class BESubscribeList( trackedCaps[dir] = WeakReference(cap) subscribe(dir, cap) } + + if (firstKey == null) { + firstKey = dir + } } else { trackedCaps.remove(dir) unsubscribe(dir, knownCap) @@ -154,8 +289,15 @@ open class BESubscribeList( } } - if (waitChunkLoad) { - onceServer { if (updateTick == this.updateTick) update(predicate) } + if (waitChunkLoad && SERVER_IS_LIVE) { + onceServer { if (isWaitingOnChunk) update() } + isWaitingOnChunk = true + } else if (predicate == null) { + isWaitingOnChunk = false } } + + companion object { + private val VALUES = Direction.values() + } } From f54322a94be83020db72809d122bdb4679358764 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 14 Jan 2023 22:14:15 +0700 Subject: [PATCH 0055/1199] otm_player -> player --- .../dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 1e885e286..8d1dcfef7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -943,8 +943,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial event.entity.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresentK { it.onHurt(event) } } - const val CAPABILITY_KEY = "otm_player" - val CAPABILITY_LOCATION = ResourceLocation(OverdriveThatMatters.MOD_ID, CAPABILITY_KEY) + val CAPABILITY_LOCATION = ResourceLocation(OverdriveThatMatters.MOD_ID, "player") fun onAttachCapabilityEvent(event: AttachCapabilitiesEvent) { val ent = event.`object` From 005ca656178b5cce96470597ad326620031a0cd8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 14 Jan 2023 22:14:37 +0700 Subject: [PATCH 0056/1199] Rename internal names of creative tabs --- .../kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt index 7a3176d4b..375e0e373 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt @@ -15,7 +15,7 @@ object MCreativeTabs { private set internal fun register(event: CreativeModeTabEvent.Register) { - MAIN = event.registerCreativeModeTab(ResourceLocation(OverdriveThatMatters.MOD_ID, "otm")) { + MAIN = event.registerCreativeModeTab(ResourceLocation(OverdriveThatMatters.MOD_ID, "main")) { it.icon { ItemStack(BATTERY_CREATIVE, 1) } it.displayItems { features, consumer, flag -> @@ -23,7 +23,7 @@ object MCreativeTabs { } } - DECORATIVE = event.registerCreativeModeTab(ResourceLocation(OverdriveThatMatters.MOD_ID, "otm_decorative")) { + DECORATIVE = event.registerCreativeModeTab(ResourceLocation(OverdriveThatMatters.MOD_ID, "decorative")) { it.icon { ItemStack(MRegistry.VENT.item, 1) } it.displayItems { features, consumer, flag -> From 7b22bd72c16f74eefe6e85318d9071449c24a399 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 14 Jan 2023 22:38:56 +0700 Subject: [PATCH 0057/1199] unoptimized --- src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShape.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShape.java b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShape.java index a414961ad..225b5afdc 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShape.java +++ b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShape.java @@ -95,7 +95,7 @@ public record BlockShape(SimpleCuboid ...shapes) { VoxelShape final_shape = shapes[0].getShape(); for (int i = 1; i < shapes.length; i++) - final_shape = Shapes.joinUnoptimized(final_shape, shapes[i].getShape(), BooleanOp.OR); + final_shape = Shapes.join(final_shape, shapes[i].getShape(), BooleanOp.OR); return final_shape; } From 8abf97f7f80254b790240987316c8246f9d8e4cc Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 14 Jan 2023 22:42:08 +0700 Subject: [PATCH 0058/1199] Actually add ship engine block --- .../mc/otm/datagen/DecorativeData.kt | 3 ++ .../mc/otm/shapes/BlockShapes.java | 20 +++++++++++++ .../dbotthepony/mc/otm/block/MatteryBlock.kt | 23 ++++++++++++++ .../mc/otm/block/decorative/EngineBlock.kt | 30 +++++++++++++++++++ .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 4 ++- 5 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt index 83e31826e..8a9319f1a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt @@ -262,4 +262,7 @@ fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelPr val textureRailing = ResourceLocation(DataGen.MOD_ID, "block/decorative/industrial_glass_frame") DataGen.pane(glass, textureSide, textureRailing) } + + blockStateProvider.block(MBlocks.ENGINE) + itemModelProvider.block(MItems.ENGINE) } diff --git a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java index 9417abf28..bb82d114a 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java +++ b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java @@ -569,4 +569,24 @@ public class BlockShapes { new SimpleCuboid(0.03125d, 0.125d, 0.65625d, 0.34375d, 0.625d, 0.96875d), new SimpleCuboid(0.65625d, 0.125d, 0.65625d, 0.96875d, 0.625d, 0.96875d) ); + + public static final BlockShape ENGINE = new BlockShape( + new SimpleCuboid(0d, 0d, 0.875d, 1d, 1d, 1d), + new SimpleCuboid(0.0625d, 0.0625d, 0.625d, 0.9375d, 0.9375d, 0.875d), + new SimpleCuboid(0.25d, 0.25d, 0.4375d, 0.75d, 0.75d, 0.625d), + new SimpleCuboid(0.1875d, 0.1875d, 0.25d, 0.8125d, 0.8125d, 0.4375d), + new SimpleCuboid(0.125d, 0.125d, 0d, 0.875d, 0.875d, 0.25d), + new SimpleCuboid(0d, 0.875d, 0.5625d, 0.125d, 1d, 0.875d), + new SimpleCuboid(0.0625d, 0.875d, 0.25d, 0.125d, 0.9375d, 0.5625d), + new SimpleCuboid(0.0625d, 0.0625d, 0.25d, 0.125d, 0.125d, 0.5625d), + new SimpleCuboid(0.875d, 0.0625d, 0.25d, 0.9375d, 0.125d, 0.5625d), + new SimpleCuboid(0.875d, 0.875d, 0.25d, 0.9375d, 0.9375d, 0.5625d), + new SimpleCuboid(0.875d, 0.125d, 0.4375d, 0.9375d, 0.875d, 0.5625d), + new SimpleCuboid(0.0625d, 0.125d, 0.4375d, 0.125d, 0.875d, 0.5625d), + new SimpleCuboid(0.125d, 0.875d, 0.4375d, 0.875d, 0.9375d, 0.5625d), + new SimpleCuboid(0.125d, 0.0625d, 0.4375d, 0.875d, 0.125d, 0.5625d), + new SimpleCuboid(0.875d, 0.875d, 0.5625d, 1d, 1d, 0.875d), + new SimpleCuboid(0.875d, 0d, 0.5625d, 1d, 0.125d, 0.875d), + new SimpleCuboid(0d, 0d, 0.5625d, 0.125d, 0.125d, 0.875d) + ); } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt index 578fa6590..7797409ba 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt @@ -238,6 +238,29 @@ abstract class RotatableMatteryBlock @JvmOverloads constructor(properties: Prope } companion object { + /** + * Allows to instance [RotatableMatteryBlock] directly + */ + fun make(properties: Properties, hasFreeRotation: Boolean = false, faceToPlayer: Boolean = true): RotatableMatteryBlock { + if (hasFreeRotation) { // can't have one class for two cases - superclass (both in OTM and in Minecraft) are leaking "this" + return object : RotatableMatteryBlock(properties) { + override val hasFreeRotation get() = true // this is accessed from superclass constructor + + override fun faceToPlayer(context: BlockPlaceContext): Boolean { + return faceToPlayer + } + } + } else { + return object : RotatableMatteryBlock(properties) { + override val hasFreeRotation get() = false // this is accessed from superclass constructor + + override fun faceToPlayer(context: BlockPlaceContext): Boolean { + return faceToPlayer + } + } + } + } + val FACING: EnumProperty = EnumProperty.create( "facing", Direction::class.java, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt new file mode 100644 index 000000000..d7a569582 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt @@ -0,0 +1,30 @@ +package ru.dbotthepony.mc.otm.block.decorative + +import net.minecraft.core.BlockPos +import net.minecraft.world.item.DyeColor +import net.minecraft.world.level.BlockGetter +import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.level.material.Material +import net.minecraft.world.phys.shapes.CollisionContext +import net.minecraft.world.phys.shapes.VoxelShape +import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.shapes.BlockShapes + +class EngineBlock : RotatableMatteryBlock(Properties.of(Material.METAL, DyeColor.ORANGE).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) { + override val hasFreeRotation: Boolean + get() = true + + private val shapes = getShapeForEachState { + BlockShapes.ENGINE.rotateInv(it[FACING_FULL]).computeShape() + } + + override fun getShape( + p_60555_: BlockState, + p_60556_: BlockGetter, + p_60557_: BlockPos, + p_60558_: CollisionContext + ): VoxelShape { + return shapes[p_60555_]!! + } +} 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 7cf8c879e..60f27f23d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -42,8 +42,10 @@ import ru.dbotthepony.mc.otm.block.LaboratoryLampLight import ru.dbotthepony.mc.otm.block.MatterCableBlock import ru.dbotthepony.mc.otm.block.PhantomAttractorBlock import ru.dbotthepony.mc.otm.block.PlatePressBlock +import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.StorageCableBlock import ru.dbotthepony.mc.otm.block.TritaniumPressurePlate +import ru.dbotthepony.mc.otm.block.decorative.EngineBlock import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock import ru.dbotthepony.mc.otm.block.matter.MatterCapacitorBankBlock import ru.dbotthepony.mc.otm.block.matter.MatterDecomposerBlock @@ -132,7 +134,7 @@ object MBlocks { val LABORATORY_LAMP_LIGHT: Block by registry.register(MNames.LABORATORY_LAMP_LIGHT) { LaboratoryLampLight() } val DANGER_STRIPE_BLOCK: Block by registry.register(MNames.DANGER_STRIPE_BLOCK) { Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.GRAY).explosionResistance(6f).destroyTime(1.5f).requiresCorrectToolForDrops()) } val METAL_BEAM: Block by registry.register(MNames.METAL_BEAM) { Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.GRAY).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) } - val ENGINE: Block by registry.register(MNames.ENGINE) { Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.ORANGE).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) } + val ENGINE: Block by registry.register(MNames.ENGINE) { EngineBlock() } val TRITANIUM_DOOR = registry.allColored(MNames.TRITANIUM_DOOR) { color, _ -> object : DoorBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), SoundEvents.IRON_DOOR_CLOSE, SoundEvents.IRON_DOOR_OPEN) { From 51c35d61425e95d9f4d5979a0eafa139fa928344 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 14 Jan 2023 22:51:17 +0700 Subject: [PATCH 0059/1199] Fix engine model not being parented to cube_all --- .../assets/overdrive_that_matters/models/block/engine.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/engine.json b/src/main/resources/assets/overdrive_that_matters/models/block/engine.json index 0d67aa334..d3bc265b0 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/engine.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/engine.json @@ -1,4 +1,5 @@ { + "parent": "minecraft:block/cube_all", "textures": { "0": "overdrive_that_matters:block/ship_engine", "particle": "overdrive_that_matters:block/ship_engine" From f89af0aefb74f6e15daae6c5ce51ec32e1e919c3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 14 Jan 2023 23:03:54 +0700 Subject: [PATCH 0060/1199] Add ship engine recipe, lang string and tag --- .../kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt | 2 ++ .../ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt | 2 ++ .../mc/otm/datagen/recipes/DecorativesRecipes.kt | 8 ++++++++ .../kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt | 2 ++ 4 files changed, 14 insertions(+) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 912815145..49fe1dc41 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -370,6 +370,8 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.DRIVE_VIEWER, "Drive Viewer") add(MBlocks.BLACK_HOLE, "Local Anomalous Singular Gravitation Field") + add(MBlocks.ENGINE, "Ship Engine") + add(MBlocks.TRITANIUM_INGOT_BLOCK, "Tritanium Plating Block") add(MBlocks.ENERGY_COUNTER, "Energy Counter") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index 1c838327f..cfa8ce748 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -58,6 +58,8 @@ fun addLootTables(lootTables: LootTables) { lootTables.dropsSelf(MBlocks.METAL_BEAM) { condition(ExplosionCondition.survivesExplosion()) } lootTables.dropsSelf(MBlocks.TRITANIUM_INGOT_BLOCK) { condition(ExplosionCondition.survivesExplosion()) } + lootTables.dropsSelf(MBlocks.ENGINE) { condition(ExplosionCondition.survivesExplosion()) } + for (door in MBlocks.TRITANIUM_TRAPDOOR.values) lootTables.dropsSelf(door) { condition(ExplosionCondition.survivesExplosion()) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt index 2ae7fc69d..b8712fe64 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt @@ -315,4 +315,12 @@ fun addDecorativesRecipes(provider: MatteryRecipeProvider, consumer: Consumer Date: Sun, 15 Jan 2023 20:01:55 +0700 Subject: [PATCH 0061/1199] Update battery bank physics model Fixes #224 --- src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java index bb82d114a..282e88463 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java +++ b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java @@ -23,11 +23,13 @@ public class BlockShapes { new SimpleCuboid(0.0625d, 0.0625d, 0.4375d, 0.9375d, 0.9375d, 0.5625d), new SimpleCuboid(0.125d, 0.03125d, 0.125d, 0.875d, 0.09375d, 0.875d), new SimpleCuboid(0.125d, 0.90625d, 0.125d, 0.875d, 0.96875d, 0.875d), - new SimpleCuboid(0.1875d, 0.1875d, 0d, 0.8125d, 0.8125d, 0.1875d), + new SimpleCuboid(0.3125d, 0.3125d, 0d, 0.6875d, 0.6875d, 0.1875d), new SimpleCuboid(0.0625d, 0.125d, 0.125d, 0.125d, 0.875d, 0.25d), new SimpleCuboid(0.0625d, 0.125d, 0.75d, 0.125d, 0.875d, 0.875d), new SimpleCuboid(0.875d, 0.125d, 0.75d, 0.9375d, 0.875d, 0.875d), new SimpleCuboid(0.875d, 0.125d, 0.125d, 0.9375d, 0.875d, 0.25d), + new SimpleCuboid(0.125d, 0.625d, 0.15625d, 0.875d, 0.75d, 0.21875d), + new SimpleCuboid(0.125d, 0.25d, 0.15625d, 0.875d, 0.375d, 0.21875d), new SimpleCuboid(0d, 0.125d, 0.375d, 0.125d, 0.875d, 0.625d), new SimpleCuboid(0.875d, 0.125d, 0.375d, 1d, 0.875d, 0.625d) ); From 2889d70648da027ff39134c8da866595c56c0be1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 15 Jan 2023 20:10:26 +0700 Subject: [PATCH 0062/1199] Move to formatting.kt --- .../mc/otm/core/util/Formatting.kt | 395 ++++++++++++++++++ .../dbotthepony/mc/otm/core/util/SiPrefix.kt | 368 ---------------- 2 files changed, 395 insertions(+), 368 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt new file mode 100644 index 000000000..a70ad48ac --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt @@ -0,0 +1,395 @@ +package ru.dbotthepony.mc.otm.core.util + +import net.minecraft.network.chat.Component +import ru.dbotthepony.mc.otm.core.TextComponent +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.isNegative +import ru.dbotthepony.mc.otm.core.math.isZero +import java.math.BigDecimal +import java.math.BigInteger + +fun BigInteger.formatReadableNumber(): String { + if (isZero) { + return "0" + } + + val strValue = toString() + + val absLength = strValue.length - (if (isNegative) 1 else 0) + val remainder = absLength % 3 + var groups = absLength / 3 + + if (remainder == 0) { + groups-- + } + + val buffer = CharArray((if (remainder == 0) 3 else remainder) + groups * 4 + if (isNegative) 1 else 0) + var c = 0 + var index = buffer.size - 1 + + for (i in strValue.length - 1 downTo (if (isNegative) 1 else 0)) { + c++ + + if (c == 4) { + buffer[index] = ' ' + index-- + c = 1 + } + + buffer[index] = strValue[i] + index-- + } + + if (isNegative) { + buffer[index] = '-' + } + + return String(buffer) +} + +fun BigDecimal.determineSiPrefix(): SiPrefix? { + if (isZero) { + return null + } + + var num = this + + if (isNegative) { + num = -this + } + + var prev: SiPrefix? = null + + if (num >= BigDecimal.ONE) { + for (value in SiPrefix.MULTIPLIES) { + if (value.decimal <= num) { + prev = value + } else { + break + } + } + } else { + for (value in SiPrefix.DECIMALS) { + if (value.decimal >= num) { + prev = value + } else { + break + } + } + } + + return prev +} + +fun BigDecimal.formatSiTranslatable(): Component { + if (isZero) { + return TextComponent("0.00") + } else if (this == BigDecimal.ONE) { + return TextComponent("1.00") + } + + return TextComponent("1.00") +} + +fun BigInteger.determineSiPrefix(): SiPrefix? { + if (isZero) { + return null + } + + var num = this + + if (isNegative) { + num = -this + } + + var prev: SiPrefix? = null + + if (num >= BigInteger.ONE) { + for (value in SiPrefix.MULTIPLIES) { + if (value.integer!! <= num) { + prev = value + } else { + break + } + } + } + + return prev +} + +fun BigInteger.formatSi(decimalPlaces: Int = 2): String { + require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } + val prefix = determineSiPrefix() ?: return toString() // + "." + "0".repeat(decimalPlaces) + val isNegative = isNegative + val arr = (if (isNegative) -this else this).divideAndRemainder(prefix.integer) + val divided = arr[0].toString() + val remainder = arr[1].toString() + + if (decimalPlaces == 0) { + if (isNegative) { + return "-" + divided + prefix.symbol + } else { + return divided + prefix.symbol + } + } + + @Suppress("NAME_SHADOWING") + val decimalPlaces = decimalPlaces.coerceAtMost(prefix.power) + + val add = (if (isNegative) 1 else 0) + + val buffer = CharArray(divided.length + 2 + decimalPlaces + add) + buffer[buffer.size - 1] = prefix.symbol + + if (isNegative) { + buffer[0] = '-' + } + + for (i in divided.indices) { + buffer[add + i] = divided[i] + } + + buffer[add + divided.length] = '.' + + for (i in 0 until decimalPlaces) { + buffer[add + i + divided.length + 1] = prefix.paddedIndex(remainder, i) + } + + return String(buffer) +} + +fun BigInteger.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2): Component { + require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } + val prefix = determineSiPrefix() ?: return if (suffix == "") TextComponent(toString(decimalPlaces)) else if (suffix is Component) TextComponent( + toString(decimalPlaces) + suffix.string + ) else TextComponent(toString(decimalPlaces) + suffix) + val isNegative = isNegative + val arr = (if (isNegative) -this else this).divideAndRemainder(prefix.integer) + val divided = arr[0].toString() + val remainder = arr[1].toString() + + if (decimalPlaces == 0) { + if (isNegative) { + return TranslatableComponent(prefix.formatLocaleKey, "-$divided", suffix) + } else { + return TranslatableComponent(prefix.formatLocaleKey, divided + prefix.symbol, suffix) + } + } + + @Suppress("NAME_SHADOWING") + val decimalPlaces = decimalPlaces.coerceAtMost(prefix.power) + + val add = (if (isNegative) 1 else 0) + + val buffer = CharArray(divided.length + 1 + decimalPlaces + add) + + if (isNegative) { + buffer[0] = '-' + } + + for (i in divided.indices) { + buffer[add + i] = divided[i] + } + + buffer[add + divided.length] = '.' + + for (i in 0 until decimalPlaces) { + buffer[add + i + divided.length + 1] = prefix.paddedIndex(remainder, i) + } + + return TranslatableComponent(prefix.formatLocaleKey, String(buffer), suffix) +} + +fun Decimal.determineSiPrefix(): SiPrefix? { + if (isZero) { + return null + } + + var num = this + + if (isNegative) { + num = -this + } + + var prev: SiPrefix? = null + + if (num >= Decimal.ONE) { + for (value in SiPrefix.MULTIPLIES) { + if (value.impreciseFraction <= num) { + prev = value + } else { + break + } + } + } else { + for (value in SiPrefix.DECIMALS_IMPRECISE) { + if (value.impreciseFraction >= num) { + prev = value + } else { + break + } + } + } + + return prev +} + +fun Int.determineSiPrefix(): SiPrefix? { + if (this == 0) { + return null + } + + var num = this + + if (this < 0) { + num = -this + } + + var prev: SiPrefix? = null + + if (num >= 1) { + for (value in SiPrefix.MULTIPLIES) { + if (value.int != null && value.int <= num) { + prev = value + } else { + break + } + } + } + + return prev +} + +fun Double.determineSiPrefix(): SiPrefix? { + if (this == 0.0) { + return null + } + + var num = this + + if (this < 0) { + num = -this + } + + var prev: SiPrefix? = null + + if (num >= 1) { + for (value in SiPrefix.MULTIPLIES) { + if (value.double <= num) { + prev = value + } else { + break + } + } + } + + return prev +} + +fun Decimal.formatSi(decimalPlaces: Int = 2): String { + require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } + val prefix = determineSiPrefix() ?: return toString(decimalPlaces) + return (this / prefix.impreciseFraction).toString(decimalPlaces) + prefix.symbol +} + +fun Int.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2): Component { + require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } + val prefix = determineSiPrefix() ?: return if (suffix == "") TextComponent(toString()) else if (suffix is Component) TextComponent( + toString() + " " + suffix.string + ) else TextComponent(toString() + " " + suffix) + return TranslatableComponent( + prefix.formatLocaleKey, + "%.${decimalPlaces}f".format(this.toFloat() / prefix.int!!.toFloat()), + suffix + ) +} + +fun Double.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2): Component { + require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } + val prefix = determineSiPrefix() ?: return if (suffix == "") TextComponent("%.${decimalPlaces}f".format(this)) else if (suffix is Component) TextComponent( + "%.${decimalPlaces}f".format(this) + " " + suffix.string + ) else TextComponent("%.${decimalPlaces}f".format(this) + " " + suffix) + return TranslatableComponent(prefix.formatLocaleKey, "%.${decimalPlaces}f".format(this / prefix.double), suffix) +} + +fun Decimal.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2): Component { + require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } + val prefix = determineSiPrefix() ?: return if (suffix == "") TextComponent(toString(decimalPlaces)) else if (suffix is Component) TextComponent( + toString(decimalPlaces) + " " + suffix.string + ) else TextComponent(toString(decimalPlaces) + " " + suffix) + return TranslatableComponent( + prefix.formatLocaleKey, + (this / prefix.impreciseFraction).toString(decimalPlaces), + suffix + ) +} + +val POWER_NAME = TranslatableComponent("otm.gui.power.name") +val MATTER_NAME = TranslatableComponent("otm.gui.matter.name") +fun Int.formatPower(decimalPlaces: Int = 2) = formatSiComponent(POWER_NAME, decimalPlaces) +fun Decimal.formatPower(decimalPlaces: Int = 2) = formatSiComponent(POWER_NAME, decimalPlaces) +fun Decimal.formatMatter(decimalPlaces: Int = 2) = formatSiComponent(MATTER_NAME, decimalPlaces) +fun Decimal.formatMatterFull(decimalPlaces: Int = 2) = TranslatableComponent( + "otm.gui.matter.format", formatSiComponent( + MATTER_NAME, decimalPlaces + ) +) + +fun BigInteger.formatPower(decimalPlaces: Int = 2) = formatSiComponent(POWER_NAME, decimalPlaces) +fun BigInteger.formatMatter(decimalPlaces: Int = 2) = formatSiComponent(MATTER_NAME, decimalPlaces) +fun BigInteger.formatMatterFull(decimalPlaces: Int = 2) = TranslatableComponent( + "otm.gui.matter.format", formatSiComponent( + MATTER_NAME, decimalPlaces + ) +) + +fun formatPowerLevel(a: Decimal, b: Decimal, decimalPlaces: Int = 2) = + TranslatableComponent("otm.gui.level", a.formatPower(decimalPlaces), b.formatPower(decimalPlaces)) +fun formatMatterLevel(a: Decimal, b: Decimal, decimalPlaces: Int = 2) = + TranslatableComponent("otm.gui.level", a.formatMatter(decimalPlaces), b.formatMatter(decimalPlaces)) +private fun padded(num: Int): String { + if (num in 0 .. 9) { + return "0$num" + } + + return num.toString() +} + +fun formatTickDuration(ticks: Int, longFormat: Boolean = false): String { + @Suppress("name_shadowing") + var leftTicks = ticks + + // val mTicks = leftTicks % 20 + leftTicks /= 20 + + val seconds = padded(leftTicks % 60) + leftTicks /= 60 + + if (longFormat) { + if (ticks <= 0) { + return "00:00:00" + } else if (ticks <= 20) { + return ".00000${padded(ticks)}" + } + + val minutes = padded(leftTicks % 60) + leftTicks /= 60 + val hours = padded(leftTicks) + return "$hours:$minutes:$seconds" + } else { + if (ticks <= 0) { + return "00:00" + } else if (ticks <= 20) { + return ".00${padded(ticks)}" + } + + val minutes = leftTicks + + if (minutes > 99) { + return "**:**" + } + + return "${padded(minutes)}:$seconds" + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/SiPrefix.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/SiPrefix.kt index 62e093cdf..b12ac983d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/SiPrefix.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/SiPrefix.kt @@ -1,54 +1,10 @@ package ru.dbotthepony.mc.otm.core.util import com.google.common.collect.ImmutableList -import net.minecraft.network.chat.Component -import ru.dbotthepony.mc.otm.core.TextComponent -import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.math.isNegative -import ru.dbotthepony.mc.otm.core.math.isZero import java.math.BigDecimal import java.math.BigInteger -fun BigInteger.formatReadableNumber(): String { - if (isZero) { - return "0" - } - - val strValue = toString() - - val absLength = strValue.length - (if (isNegative) 1 else 0) - val remainder = absLength % 3 - var groups = absLength / 3 - - if (remainder == 0) { - groups-- - } - - val buffer = CharArray((if (remainder == 0) 3 else remainder) + groups * 4 + if (isNegative) 1 else 0) - var c = 0 - var index = buffer.size - 1 - - for (i in strValue.length - 1 downTo (if (isNegative) 1 else 0)) { - c++ - - if (c == 4) { - buffer[index] = ' ' - index-- - c = 1 - } - - buffer[index] = strValue[i] - index-- - } - - if (isNegative) { - buffer[index] = '-' - } - - return String(buffer) -} - enum class SiPrefix( val power: Int, fractional: Boolean, @@ -133,327 +89,3 @@ enum class SiPrefix( } } -fun BigDecimal.determineSiPrefix(): SiPrefix? { - if (isZero) { - return null - } - - var num = this - - if (isNegative) { - num = -this - } - - var prev: SiPrefix? = null - - if (num >= BigDecimal.ONE) { - for (value in SiPrefix.MULTIPLIES) { - if (value.decimal <= num) { - prev = value - } else { - break - } - } - } else { - for (value in SiPrefix.DECIMALS) { - if (value.decimal >= num) { - prev = value - } else { - break - } - } - } - - return prev -} - -fun BigDecimal.formatSiTranslatable(): Component { - if (isZero) { - return TextComponent("0.00") - } else if (this == BigDecimal.ONE) { - return TextComponent("1.00") - } - - return TextComponent("1.00") -} - -fun BigInteger.determineSiPrefix(): SiPrefix? { - if (isZero) { - return null - } - - var num = this - - if (isNegative) { - num = -this - } - - var prev: SiPrefix? = null - - if (num >= BigInteger.ONE) { - for (value in SiPrefix.MULTIPLIES) { - if (value.integer!! <= num) { - prev = value - } else { - break - } - } - } - - return prev -} - -fun BigInteger.formatSi(decimalPlaces: Int = 2): String { - require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } - val prefix = determineSiPrefix() ?: return toString() // + "." + "0".repeat(decimalPlaces) - val isNegative = isNegative - val arr = (if (isNegative) -this else this).divideAndRemainder(prefix.integer) - val divided = arr[0].toString() - val remainder = arr[1].toString() - - if (decimalPlaces == 0) { - if (isNegative) { - return "-" + divided + prefix.symbol - } else { - return divided + prefix.symbol - } - } - - @Suppress("NAME_SHADOWING") - val decimalPlaces = decimalPlaces.coerceAtMost(prefix.power) - - val add = (if (isNegative) 1 else 0) - - val buffer = CharArray(divided.length + 2 + decimalPlaces + add) - buffer[buffer.size - 1] = prefix.symbol - - if (isNegative) { - buffer[0] = '-' - } - - for (i in divided.indices) { - buffer[add + i] = divided[i] - } - - buffer[add + divided.length] = '.' - - for (i in 0 until decimalPlaces) { - buffer[add + i + divided.length + 1] = prefix.paddedIndex(remainder, i) - } - - return String(buffer) -} - -fun BigInteger.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2): Component { - require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } - val prefix = determineSiPrefix() ?: return if (suffix == "") TextComponent(toString(decimalPlaces)) else if (suffix is Component) TextComponent(toString(decimalPlaces) + suffix.string) else TextComponent(toString(decimalPlaces) + suffix) - val isNegative = isNegative - val arr = (if (isNegative) -this else this).divideAndRemainder(prefix.integer) - val divided = arr[0].toString() - val remainder = arr[1].toString() - - if (decimalPlaces == 0) { - if (isNegative) { - return TranslatableComponent(prefix.formatLocaleKey, "-$divided", suffix) - } else { - return TranslatableComponent(prefix.formatLocaleKey, divided + prefix.symbol, suffix) - } - } - - @Suppress("NAME_SHADOWING") - val decimalPlaces = decimalPlaces.coerceAtMost(prefix.power) - - val add = (if (isNegative) 1 else 0) - - val buffer = CharArray(divided.length + 1 + decimalPlaces + add) - - if (isNegative) { - buffer[0] = '-' - } - - for (i in divided.indices) { - buffer[add + i] = divided[i] - } - - buffer[add + divided.length] = '.' - - for (i in 0 until decimalPlaces) { - buffer[add + i + divided.length + 1] = prefix.paddedIndex(remainder, i) - } - - return TranslatableComponent(prefix.formatLocaleKey, String(buffer), suffix) -} - -fun Decimal.determineSiPrefix(): SiPrefix? { - if (isZero) { - return null - } - - var num = this - - if (isNegative) { - num = -this - } - - var prev: SiPrefix? = null - - if (num >= Decimal.ONE) { - for (value in SiPrefix.MULTIPLIES) { - if (value.impreciseFraction <= num) { - prev = value - } else { - break - } - } - } else { - for (value in SiPrefix.DECIMALS_IMPRECISE) { - if (value.impreciseFraction >= num) { - prev = value - } else { - break - } - } - } - - return prev -} - -fun Int.determineSiPrefix(): SiPrefix? { - if (this == 0) { - return null - } - - var num = this - - if (this < 0) { - num = -this - } - - var prev: SiPrefix? = null - - if (num >= 1) { - for (value in SiPrefix.MULTIPLIES) { - if (value.int != null && value.int <= num) { - prev = value - } else { - break - } - } - } - - return prev -} - -fun Double.determineSiPrefix(): SiPrefix? { - if (this == 0.0) { - return null - } - - var num = this - - if (this < 0) { - num = -this - } - - var prev: SiPrefix? = null - - if (num >= 1) { - for (value in SiPrefix.MULTIPLIES) { - if (value.double <= num) { - prev = value - } else { - break - } - } - } - - return prev -} - -fun Decimal.formatSi(decimalPlaces: Int = 2): String { - require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } - val prefix = determineSiPrefix() ?: return toString(decimalPlaces) - return (this / prefix.impreciseFraction).toString(decimalPlaces) + prefix.symbol -} - -fun Int.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2): Component { - require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } - val prefix = determineSiPrefix() ?: return if (suffix == "") TextComponent(toString()) else if (suffix is Component) TextComponent(toString() + " " + suffix.string) else TextComponent(toString() + " " + suffix) - return TranslatableComponent(prefix.formatLocaleKey, "%.${decimalPlaces}f".format(this.toFloat() / prefix.int!!.toFloat()), suffix) -} - -fun Double.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2): Component { - require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } - val prefix = determineSiPrefix() ?: return if (suffix == "") TextComponent("%.${decimalPlaces}f".format(this)) else if (suffix is Component) TextComponent("%.${decimalPlaces}f".format(this) + " " + suffix.string) else TextComponent("%.${decimalPlaces}f".format(this) + " " + suffix) - return TranslatableComponent(prefix.formatLocaleKey, "%.${decimalPlaces}f".format(this / prefix.double), suffix) -} - -fun Decimal.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2): Component { - require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } - val prefix = determineSiPrefix() ?: return if (suffix == "") TextComponent(toString(decimalPlaces)) else if (suffix is Component) TextComponent(toString(decimalPlaces) + " " + suffix.string) else TextComponent(toString(decimalPlaces) + " " + suffix) - return TranslatableComponent(prefix.formatLocaleKey, (this / prefix.impreciseFraction).toString(decimalPlaces), suffix) -} - -val POWER_NAME = TranslatableComponent("otm.gui.power.name") -val MATTER_NAME = TranslatableComponent("otm.gui.matter.name") - -fun Int.formatPower(decimalPlaces: Int = 2) = formatSiComponent(POWER_NAME, decimalPlaces) - -fun Decimal.formatPower(decimalPlaces: Int = 2) = formatSiComponent(POWER_NAME, decimalPlaces) -fun Decimal.formatMatter(decimalPlaces: Int = 2) = formatSiComponent(MATTER_NAME, decimalPlaces) -fun Decimal.formatMatterFull(decimalPlaces: Int = 2) = TranslatableComponent("otm.gui.matter.format", formatSiComponent( - MATTER_NAME, decimalPlaces)) - -fun BigInteger.formatPower(decimalPlaces: Int = 2) = formatSiComponent(POWER_NAME, decimalPlaces) -fun BigInteger.formatMatter(decimalPlaces: Int = 2) = formatSiComponent(MATTER_NAME, decimalPlaces) -fun BigInteger.formatMatterFull(decimalPlaces: Int = 2) = TranslatableComponent("otm.gui.matter.format", formatSiComponent( - MATTER_NAME, decimalPlaces)) - -fun formatPowerLevel(a: Decimal, b: Decimal, decimalPlaces: Int = 2) = TranslatableComponent("otm.gui.level", a.formatPower(decimalPlaces), b.formatPower(decimalPlaces)) -fun formatMatterLevel(a: Decimal, b: Decimal, decimalPlaces: Int = 2) = TranslatableComponent("otm.gui.level", a.formatMatter(decimalPlaces), b.formatMatter(decimalPlaces)) - -private fun padded(num: Int): String { - if (num in 0 .. 9) { - return "0$num" - } - - return num.toString() -} - -fun formatTickDuration(ticks: Int, longFormat: Boolean = false): String { - @Suppress("name_shadowing") - var leftTicks = ticks - - // val mTicks = leftTicks % 20 - leftTicks /= 20 - - val seconds = padded(leftTicks % 60) - leftTicks /= 60 - - if (longFormat) { - if (ticks <= 0) { - return "00:00:00" - } else if (ticks <= 20) { - return ".00000${padded(ticks)}" - } - - val minutes = padded(leftTicks % 60) - leftTicks /= 60 - val hours = padded(leftTicks) - return "$hours:$minutes:$seconds" - } else { - if (ticks <= 0) { - return "00:00" - } else if (ticks <= 20) { - return ".00${padded(ticks)}" - } - - val minutes = leftTicks - - if (minutes > 99) { - return "**:**" - } - - return "${padded(minutes)}:$seconds" - } -} From e5d94792ae49444b42e6d8195cabeb0453444640 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 15 Jan 2023 22:44:32 +0700 Subject: [PATCH 0063/1199] Fix creative tabs have no names --- .../kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt index 375e0e373..4cfc8c9c3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt @@ -5,6 +5,7 @@ import net.minecraft.world.item.CreativeModeTab import net.minecraft.world.item.ItemStack import net.minecraftforge.event.CreativeModeTabEvent import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.registry.MItems.BATTERY_CREATIVE @@ -17,6 +18,7 @@ object MCreativeTabs { internal fun register(event: CreativeModeTabEvent.Register) { MAIN = event.registerCreativeModeTab(ResourceLocation(OverdriveThatMatters.MOD_ID, "main")) { it.icon { ItemStack(BATTERY_CREATIVE, 1) } + it.title(TranslatableComponent("itemGroup.otm")) it.displayItems { features, consumer, flag -> addMainCreativeTabItems(consumer) @@ -25,6 +27,7 @@ object MCreativeTabs { DECORATIVE = event.registerCreativeModeTab(ResourceLocation(OverdriveThatMatters.MOD_ID, "decorative")) { it.icon { ItemStack(MRegistry.VENT.item, 1) } + it.title(TranslatableComponent("itemGroup.otm_decorative")) it.displayItems { features, consumer, flag -> addDecorativeTabItems(consumer) From 26fe34d4009aa90ecd8220a397dffd93c96808fb Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 17 Jan 2023 12:43:39 +0700 Subject: [PATCH 0064/1199] final override fun iterator() --- .../kotlin/ru/dbotthepony/mc/otm/core/util/BESubscribeList.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/BESubscribeList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/BESubscribeList.kt index 0d4fc1517..18d010c75 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/BESubscribeList.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/BESubscribeList.kt @@ -109,7 +109,7 @@ open class BESubscribeList( return true } - override fun iterator(): Iterator { + final override fun iterator(): Iterator { if (updateQueued) { update() } else if (alwaysValidate) { From c3b738cd47ca9d188739eda76891d0d5bc286d82 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 19 Jan 2023 11:28:25 +0700 Subject: [PATCH 0065/1199] JEI, it just works:tm: --- build.gradle.kts | 11 ++++++----- gradle.properties | 4 +++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index b05fb69f5..cb75f7c34 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -193,13 +193,14 @@ dependencies { val worldedit_fileid: String by project val more_overlays_version: String by project val deps_mc_version: String by project + val jei_mc_version: String by project compileOnly(fg.deobf("top.theillusivec4.curios:curios-forge:${deps_mc_version}-${curios_version}")) compileOnly(fg.deobf("lain.mods.cos:CosmeticArmorReworked:${deps_mc_version}-${cosmetic_armor_reworked_version}")) - compileOnly(fg.deobf("mezz.jei:jei-${deps_mc_version}-common-api:${jei_version}")) - compileOnly(fg.deobf("mezz.jei:jei-${deps_mc_version}-forge-api:${jei_version}")) - // runtimeOnly(fg.deobf("mezz.jei:jei-${deps_mc_version}-forge:${jei_version}")) + compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-common-api:${jei_version}")) + compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge-api:${jei_version}")) + runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}")) // runtimeOnly(fg.deobf("curse.maven:jade-324717:${jade_id}")) // runtimeOnly(fg.deobf("curse.maven:configured-457570:${configured_id}")) @@ -350,8 +351,8 @@ repositories { } maven { - name = "Progwml6 maven" - url = uri("https://dvs1.progwml6.com/files/maven/") + name = "Jared's Maven" + url = uri("https://maven.blamejared.com/") content { includeGroup("mezz.jei") diff --git a/gradle.properties b/gradle.properties index 7dbd04ac9..72f45856a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,13 +11,15 @@ mod_version=1.1 use_commit_hash_in_version=true mc_version=1.19.3 +jei_mc_version=1.19.3 deps_mc_version=1.19.2 + forge_gradle_version=5.1.27 forge_version=44.1.5 mixingradle_version=0.7.32 mixin_version=0.8.5 -jei_version=11.3.0.262 +jei_version=12.0.2.2 jupiter_version=5.8.2 mekanism_version=10.3.5.homebaked curios_version=5.1.1.0 From ab9bb9c15fd34933e8142c3e1648abb6ce125cd8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 19 Jan 2023 11:55:45 +0700 Subject: [PATCH 0066/1199] oops --- src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt | 1 + 1 file changed, 1 insertion(+) 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 9f9536648..9aedf07d7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -232,6 +232,7 @@ object MItems { ::BATTERY_NORMAL, ::BATTERY_DENSE, ::BATTERY_CAPACITOR, + ::BATTERY_CREATIVE, ::QUANTUM_BATTERY, ::QUANTUM_CAPACITOR, From 3b9e61e1b4957b7512336143075c47c81fe2b52d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 19 Jan 2023 14:39:17 +0700 Subject: [PATCH 0067/1199] update build scripts --- build.gradle.kts | 2 -- settings.gradle.kts | 12 ------------ 2 files changed, 14 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index cb75f7c34..60fabaa42 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,9 +3,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import java.util.Date import java.text.SimpleDateFormat import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream -import kotlin.text.Regex import java.util.UUID -import org.spongepowered.asm.gradle.plugins.MixinExtension val mod_version: String by project val mc_version: String by project diff --git a/settings.gradle.kts b/settings.gradle.kts index 11d08643f..e72c25773 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,18 +1,6 @@ println("Running with Java ${System.getProperty("java.version")} on JVM: ${System.getProperty("java.vendor")} ${System.getProperty("java.vm.version")} (Architecture: ${System.getProperty("os.arch")})") -pluginManagement { - val kotlin_version: String by settings - val forge_gradle_version: String by settings - val mixingradle_version: String by settings - - plugins { - kotlin("jvm") version(kotlin_version) - id("net.minecraftforge.gradle") version(forge_gradle_version) - id("org.spongepowered.mixin") version(mixingradle_version) - } -} - buildscript { repositories { // These repositories are only for Gradle plugins, put any other repositories in the repository block further below From ae02fbd25d797e463b436e8f15d1908372f820bc Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 21 Jan 2023 15:28:59 +0700 Subject: [PATCH 0068/1199] Initial Russian locale --- .../ru/dbotthepony/mc/otm/datagen/DataGen.kt | 2 + .../mc/otm/datagen/lang/English.kt | 97 +-- .../datagen/lang/MatteryLanguageProvider.kt | 19 + .../mc/otm/datagen/lang/Russian.kt | 628 ++++++++++++++++++ .../mc/otm/item/ExoPackProbeItem.kt | 3 +- 5 files changed, 700 insertions(+), 49 deletions(-) create mode 100644 src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt index f5c244a22..f6fd731ef 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -36,6 +36,7 @@ import ru.dbotthepony.mc.otm.datagen.advancements.addMachineAdvancements import ru.dbotthepony.mc.otm.datagen.blocks.addBlockStates import ru.dbotthepony.mc.otm.datagen.blocks.addComplexBlockStates import ru.dbotthepony.mc.otm.datagen.items.addItemModels +import ru.dbotthepony.mc.otm.datagen.lang.AddRussianLanguage import ru.dbotthepony.mc.otm.datagen.lang.MatteryLanguageProvider import ru.dbotthepony.mc.otm.datagen.loot.* import ru.dbotthepony.mc.otm.datagen.loot.LootModifiers @@ -445,6 +446,7 @@ object DataGen { registerOreGen(event) AddEnglishLanguage(languageProvider) + AddRussianLanguage(languageProvider) for ((color, door) in MBlocks.TRITANIUM_DOOR) door(door, modLocation("block/decorative/tritanium_door_top${color?.name?.lowercase()?.let { "_$it" } ?: ""}"), modLocation("block/decorative/tritanium_door_bottom${color?.name?.lowercase()?.let { "_$it" } ?: ""}")) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 49fe1dc41..99a6e7856 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -3,23 +3,25 @@ package ru.dbotthepony.mc.otm.datagen.lang import ru.dbotthepony.mc.otm.registry.* private fun decoratives(provider: MatteryLanguageProvider) { - provider.englishColors.add(MRegistry.VENT, "%s Vent") - provider.englishColors.add(MRegistry.VENT_ALTERNATIVE, "%s Alternative Vent") + with(provider.englishColors) { + add(MRegistry.VENT, "%s Vent") + add(MRegistry.VENT_ALTERNATIVE, "%s Alternative Vent") - provider.englishColors.add(MRegistry.TRITANIUM_BLOCK, "%s Tritanium Block") - provider.englishColors.add(MRegistry.TRITANIUM_STAIRS, "%s Tritanium Stairs") - provider.englishColors.add(MRegistry.TRITANIUM_SLAB, "%s Tritanium Slab") - provider.englishColors.add(MRegistry.TRITANIUM_WALL, "%s Tritanium Wall") - provider.englishColors.add(MRegistry.FLOOR_TILES, "%s Floor Tiles") - provider.englishColors.add(MRegistry.FLOOR_TILES_STAIRS, "%s Floor Tiles Stairs") - provider.englishColors.add(MRegistry.FLOOR_TILES_SLAB, "%s Floor Tiles Slab") - provider.englishColors.add(MRegistry.UNREFINED_FLOOR_TILES, "Unrefined %s Floor Tiles") + add(MRegistry.TRITANIUM_BLOCK, "%s Tritanium Block") + add(MRegistry.TRITANIUM_STAIRS, "%s Tritanium Stairs") + add(MRegistry.TRITANIUM_SLAB, "%s Tritanium Slab") + add(MRegistry.TRITANIUM_WALL, "%s Tritanium Wall") + add(MRegistry.FLOOR_TILES, "%s Floor Tiles") + add(MRegistry.FLOOR_TILES_STAIRS, "%s Floor Tiles Stairs") + add(MRegistry.FLOOR_TILES_SLAB, "%s Floor Tiles Slab") + add(MRegistry.UNREFINED_FLOOR_TILES, "Unrefined %s Floor Tiles") - provider.englishColors.add(MRegistry.INDUSTRIAL_GLASS, "%s Stained Industrial Glass") - provider.englishColors.add(MRegistry.INDUSTRIAL_GLASS_PANE, "%s Stained Industrial Glass Pane") + add(MRegistry.INDUSTRIAL_GLASS, "%s Stained Industrial Glass") + add(MRegistry.INDUSTRIAL_GLASS_PANE, "%s Stained Industrial Glass Pane") - provider.englishColors.add(MRegistry.CARGO_CRATES, "%s Cargo Crate") - provider.englishColors.add(MRegistry.DECORATIVE_CRATE, "%s Container Block") + add(MRegistry.CARGO_CRATES, "%s Cargo Crate") + add(MRegistry.DECORATIVE_CRATE, "%s Container Block") + } with (provider.english) { for ((color, name) in provider.englishColors.dyeClassMapped) { @@ -46,10 +48,10 @@ private fun decoratives(provider: MatteryLanguageProvider) { add(MRegistry.TRITANIUM_PRESSURE_PLATE.block, "description1", "High blast resistance") } - provider.english.add(MItems.CARGO_CRATE_MINECARTS[null]!!, "Minecart with Cargo Crate") - provider.english.add(MEntityTypes.CARGO_CRATE_MINECARTS[null]!!, "Minecart with Cargo Crate") - with(provider.english) { + add(MItems.CARGO_CRATE_MINECARTS[null]!!, "Minecart with Cargo Crate") + add(MEntityTypes.CARGO_CRATE_MINECARTS[null]!!, "Minecart with Cargo Crate") + add(MRegistry.CARGO_CRATES.block, "Cargo Crate") add(MRegistry.TRITANIUM_BLOCK.block, "Tritanium Block") add(MRegistry.TRITANIUM_STAIRS.block, "Tritanium Stairs") @@ -133,7 +135,7 @@ private fun misc(provider: MatteryLanguageProvider) { gui("exopack.probe2", "There is fingerprint reader built into one of sides which gently glow when touched.") gui("exopack.probe3", "It seems this box will unlock once you strongly press fingerprint reader, and you feel what's inside will affect you without any way back!") - gui("exopack.already_activated", "You already have an Exopack on you!") + gui("exopack.already_activated", "You already have an Exopack!") gui("exopack_upgrades.no_exopack", "This piece of technology seems to be of no use to you.... Or does it?!") @@ -142,7 +144,7 @@ private fun misc(provider: MatteryLanguageProvider) { gui("exopack_upgrades.crafting_upgrade", "Using this will permanently grant 3x3 crafting grid in your Exopack inventory.") gui("crude_battery.replace_in_world", "Simplistic nature of this battery allows to replace your energy source in the field without using Android Station.") - gui("crude_battery.replace_in_world_warning", "This operation is very unstable and causes serious damage to your systems!") + gui("crude_battery.replace_in_world_warning", "This operation is very unstable and can cause extreme damage to your systems!") gui("power_supplier.active_nodes", "Currently demanding nodes: %s") @@ -151,14 +153,13 @@ private fun misc(provider: MatteryLanguageProvider) { misc("exopack_upgrades.slots_upgraded", "Your Exopack has permanently gained %s slots") misc("exopack_upgrades.crafting_upgraded", "Your Exopack has permanently gained 3x3 crafting grid") - misc("exopack.granted1", "As you keep pressing on the fingerprint reader, you are getting hurt in finger.") - misc("exopack.granted2", "After you raise your finger, fingerprint reader glows very bright.") - misc("exopack.granted3", "Then, the fingerprint reader fades, leaving faint trace not of your finger, but of your very soul.") - misc("exopack.granted4", "The device opens... And whatever was inside it shroud you, yet you feel nothing, as it wasn't even there.") - misc("exopack.granted5", "As whatever shrouded you takes final form, you feel it binds to your soul.") - misc("exopack.granted6", "INITIALIZATION SEQUENCE COMPLETE. WELCOME, USER %s") - misc("exopack.granted7", "You are now permanently equipped with four dimensional omni-present Exopack.") - misc("exopack.granted8", "As of now, this Exopack is not much, but it's built-in AI hints there are upgrade modules out there somewhere...") + misc("exopack.granted1", "As you keep pressing on the fingerprint reader, probe disappears.") + misc("exopack.granted2", "After a moment, you are getting pierced into back multiple times...") + misc("exopack.granted3", "As pain signals ease away, you find a new 'friend' on your back: the Exopack.") + misc("exopack.granted4", "This device provides access to personal pocket dimension in 4th space.") + misc("exopack.granted5", "Scavenge for or craft modules to upgrade your Exopack.") + misc("exopack.granted6", "The Exopack itself also exists in 4th dimension, it does not prevent wearing armor.") + misc("exopack.granted7", "However, despite existing in 4th dimension, items stored in it are still dropped upon unfortunate event.") misc("dumping_matter_registry", "Dumping matter registry to %s") misc("dumped_matter_registry", "Dumped matter registry to %s") @@ -222,8 +223,8 @@ private fun misc(provider: MatteryLanguageProvider) { misc("container.matter_panel.tasks", "Tasks") misc("container.matter_panel.patterns", "Patterns") - misc("item.power.infinite.storage", "Stored energy: Infinity / Infinity") - misc("item.power.infinite.throughput", "Max I/O Infinite / Infinite") + misc("item.power.infinite.storage", "Stored energy: ∞ / ∞") + misc("item.power.infinite.throughput", "Max I/O: ∞ / ∞") misc("item.power.passed", "Passed energy: %s") misc("item.power.received", "Received energy: %s") misc("item.power.average", "Average throughput: %s/t") @@ -231,9 +232,9 @@ private fun misc(provider: MatteryLanguageProvider) { misc("item.power.last_tick", "Last tick: %s") misc("item.power.storage", "Stored energy: %s / %s") - misc("item.power.throughput", "Max throughput: %s / %s") - misc("item.power.throughput_mono", "Max throughput: %s") - misc("item.power.infinity", "Infinity MtJ") + misc("item.power.throughput", "Max I/O: %s / %s") + misc("item.power.throughput_mono", "Max I/O: %s") + misc("item.power.infinity", "∞ MtJ") misc("item.worker.work_ticks_mono", "Work ticks: %s") misc("item.worker.work_ticks", "Work ticks: %s / %s") @@ -241,11 +242,11 @@ private fun misc(provider: MatteryLanguageProvider) { misc("item.block.stored_battery", "Battery: %s") misc("item.pattern.stored", "Stored patterns: %s / %s") - misc("item.pattern.infinite.stored", "Stored patterns %s") + misc("item.pattern.infinite.stored", "Stored patterns: %s") misc("item.pattern.line", "%s [%s%%]") misc("item.pattern.research", "Researched: %s%%") - misc("item.matter.infinite", "Stored matter: Infinity / Infinity") + misc("item.matter.infinite", "Stored matter: ∞ / ∞") misc("item.matter.normal", "Stored matter: %s / %s") misc("gui.matter_task.total", "Total: %s") @@ -264,8 +265,8 @@ private fun misc(provider: MatteryLanguageProvider) { misc("pill.heal", "Instantly restores 4 hearts upon ingestion, provides 2 min Absorption V and 8 seconds Regeneration III.") misc("pill.heal_android", "Does nothing to androids.") - misc("pill.message", "Nothing happened, but you feel exhausted?.. Maybe get rest.") - misc("pill.message_finish", "§kONE OF US ONE OF US ONE OF US ONE OF US ONE OF US") + misc("pill.message", "Nothing happened, but you feel... exhausted?.. Maybe get rest.") + misc("pill.message_finish", "§kONE OF US ONE OF US ONE OF US") misc("gui.power.percentage_level", "Energy level: %s%%") misc("gui.level", "%s / %s") @@ -347,11 +348,11 @@ private fun death(provider: MatteryLanguageProvider) { death("otm_become_humane.player", "%1\$s gained their humanity whilst %2\$s tried to reason with them") death("otm_event_horizon.player", "%1\$s tried to cross the event horizon whilst trying to escape %2\$s") death("otm_hawking_radiation.player", "%1\$s disintegrated whilst fighting %2\$s") - death("otm_emp.player", "%1\$s blew fuzes of %2\$s") - death("otm_emp.player.item", "%1\$s blew fuzes of %2\$s using %3\$s") + death("otm_emp.player", "%2\$s blew fuzes of %1\$s") + death("otm_emp.player.item", "%2\$s blew fuzes of %1\$s using %3\$s") - death(MRegistry.DAMAGE_EXOPACK_PROBE_ID, "%1 couldn't handle spinal surgery") - death("${MRegistry.DAMAGE_EXOPACK_PROBE_ID}.player", "%1 couldn't handle spinal surgery whilst fighting %2\$s") + death(MRegistry.DAMAGE_EXOPACK_PROBE_ID, "%1\$s couldn't handle spinal surgery") + death("${MRegistry.DAMAGE_EXOPACK_PROBE_ID}.player", "%1\$s couldn't handle spinal surgery whilst fighting %2\$s") } } @@ -388,7 +389,7 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.ENERGY_SERVO, "Energy Servo") add(MBlocks.ENERGY_SERVO, "desc", "Charges, Discharges or Exchanges energy of items") - add(MBlocks.CARBON_FIBRE_BLOCK, "Carbon fibre Block") + add(MBlocks.CARBON_FIBRE_BLOCK, "Carbon Fibre Block") add(MBlocks.TRITANIUM_STRIPED_BLOCK, "Tritanium Striped Block") add(MBlocks.TRITANIUM_STRIPED_STAIRS, "Tritanium Striped Stairs") @@ -404,8 +405,8 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.STORAGE_IMPORTER, "Storage Importer") add(MBlocks.STORAGE_EXPORTER, "Storage Exporter") - add(MBlocks.GRAVITATION_STABILIZER, "Gravitation Stabilizer") - add(MBlocks.GRAVITATION_STABILIZER_LENS, "Gravitation Stabilizer Lens") + add(MBlocks.GRAVITATION_STABILIZER, "Space-Time Equalizer") + add(MBlocks.GRAVITATION_STABILIZER_LENS, "Space-Time Equalizer Lens") add(MBlocks.GRAVITATION_STABILIZER, "desc", "Reduces gravitation effects of singularities") add(MBlocks.GRAVITATION_STABILIZER, "desc2", "Requires no power to operate") add(MBlocks.GRAVITATION_STABILIZER, "desc3", "Keep in mind the effect of multiple stabilizers produce exponentially increasing result") @@ -446,7 +447,7 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, "Indescribable Exopack Inventory Upgrade") add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, "description", "They normally generate in dungeons with appropriate NBT tag attached") - add(MItems.NUTRIENT_PASTE, "Nutrient paste") + add(MItems.NUTRIENT_PASTE, "Nutrient Paste") add(MItems.BLACK_HOLE_SCANNER, "Singularity Scanner") add(MItems.BLACK_HOLE_SCANNER, "desc", "Scans singularities for their properties") @@ -454,11 +455,11 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.GRAVITATION_FIELD_LIMITER, "Gravitation Field Limiter") add(MItems.GRAVITATION_FIELD_SENSOR, "Gravitation Field Sensor") - add(MItems.PORTABLE_GRAVITATION_STABILIZER, "Portable Gravitation Stabilizer") + add(MItems.PORTABLE_GRAVITATION_STABILIZER, "Portable Space-Time Equalizer") add(MItems.BATTERY_CRUDE, "Crude Battery") add(MItems.BATTERY_BASIC, "Basic Battery") - add(MItems.BATTERY_NORMAL, "Ordinary Battery") + add(MItems.BATTERY_NORMAL, "Battery") add(MItems.BATTERY_DENSE, "Dense Battery") add(MItems.BATTERY_CAPACITOR, "Capacitor Battery") add(MItems.BATTERY_CREATIVE, "Creative Battery") @@ -499,12 +500,12 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.ELECTROMAGNET, "Electromagnet") add(MItems.MIRROR_COMPOUND, "Mirror Compound") add(MItems.MIRROR, "Mirror") - add(MItems.MIRROR, "description", "You can clearly see your reflection in this thing") + add(MItems.MIRROR, "description", "I can clearly see my own reflection in this mirror") add(MItems.GRAVITATIONAL_DISRUPTOR, "Gravitational Disruptor") add(MItems.GRAVITATIONAL_DISRUPTOR, "description", "Once within close proximity of supermassive body, suppresses any gravity in it's radius") - add(MItems.GRAVITATIONAL_DISRUPTOR, "description2", "Allows collapse of black holes") + add(MItems.GRAVITATIONAL_DISRUPTOR, "description2", "Allows collapse of singularities") add(MItems.GRAVITATIONAL_DISRUPTOR, "description3", "Doesn't destroy any of mass singularity had acquired, which result in violent explosion of matter!") add(MItems.GRAVITATIONAL_DISRUPTOR, "description4", "The explosion %s be contained by %s. Do not even attempt to contain it.") add(MItems.GRAVITATIONAL_DISRUPTOR, "description4_clarification", "can not") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/MatteryLanguageProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/MatteryLanguageProvider.kt index 9c16c52a6..f4f28c71d 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/MatteryLanguageProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/MatteryLanguageProvider.kt @@ -382,6 +382,25 @@ class MatteryLanguageProvider(private val gen: DataGenerator) { "Black", ) + val russianColors = Colors("en_us", + "Белый", + "Оранжевый", + "Маджентовый", + "Светло Синий", + "Жёлтый", + "Лаймовый", + "Розовый", + "Серый", + "Светло Серый", + "Циановый", + "Пурпурный", + "Синий", + "Коричневый", + "Зелёный", + "Красный", + "Чёрный", + ) + val english by lazy { Builder("en_us") } val russian by lazy { Builder("ru_ru") } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt new file mode 100644 index 000000000..ea4b0e97c --- /dev/null +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -0,0 +1,628 @@ +package ru.dbotthepony.mc.otm.datagen.lang + +import ru.dbotthepony.mc.otm.registry.AndroidFeatures +import ru.dbotthepony.mc.otm.registry.MBlocks +import ru.dbotthepony.mc.otm.registry.MEntityTypes +import ru.dbotthepony.mc.otm.registry.MItems +import ru.dbotthepony.mc.otm.registry.MRegistry +import ru.dbotthepony.mc.otm.registry.MSoundEvents + +private const val HIGH_BLAST_RESISTANCE = "Высокая взрывоустойчивость" +private const val HIGH_BLAST_RESISTANCE_DOOR = "Взрывоустойчивая дверь с засовом красного камня..." +private const val FEELING_SAFE_NOW = "...ощущаете ли вы себя теперь в безопасности?" + +private fun decoratives(provider: MatteryLanguageProvider) { + with(provider.russianColors) { + add(MRegistry.VENT, "%s Вентиляция") + add(MRegistry.VENT_ALTERNATIVE, "%s Альтернативная Вентиляция") + + add(MRegistry.TRITANIUM_BLOCK, "%s Тритановый Блок") + add(MRegistry.TRITANIUM_STAIRS, "%s Тритановые Ступеньки") + add(MRegistry.TRITANIUM_SLAB, "%s Тритановая Плита") + add(MRegistry.TRITANIUM_WALL, "%s Тритановая Ограда") + add(MRegistry.FLOOR_TILES, "%s Керамическая Плитка") + add(MRegistry.FLOOR_TILES_STAIRS, "%s Ступеньки из Керамической Плитки") + add(MRegistry.FLOOR_TILES_SLAB, "%s Плита из Керамической Плитки") + add(MRegistry.UNREFINED_FLOOR_TILES, "Необработанная %s Кирамическая Плитка") + + add(MRegistry.INDUSTRIAL_GLASS, "%s Окрашенное Промышленное Стекло") + add(MRegistry.INDUSTRIAL_GLASS_PANE, "%s Окрашенная Промышленная Стеклянная Панель") + + add(MRegistry.CARGO_CRATES, "%s Грузовой Ящик") + add(MRegistry.DECORATIVE_CRATE, "%s Блок Контейнера") + } + + with (provider.english) { + for ((color, name) in provider.englishColors.dyeClassMapped) { + add(MItems.CARGO_CRATE_MINECARTS[color]!!, "Вагонетка с $name Грузовым Ящиком") + add(MEntityTypes.CARGO_CRATE_MINECARTS[color]!!, "Вагонетка с $name Грузовым Ящиком") + + add(MRegistry.TRITANIUM_PRESSURE_PLATE.getBlock(color), "$name Тритановая Нажимная пластина") + add(MRegistry.TRITANIUM_PRESSURE_PLATE.getBlock(color), "description0", "Активируется только при наступлении игрока на неё") + add(MRegistry.TRITANIUM_PRESSURE_PLATE.getBlock(color), "description1", HIGH_BLAST_RESISTANCE) + + add(MBlocks.TRITANIUM_DOOR[color]!!, "$name Тритановая Дверь") + add(MBlocks.TRITANIUM_DOOR[color]!!, "description0", HIGH_BLAST_RESISTANCE_DOOR) + add(MBlocks.TRITANIUM_DOOR[color]!!, "description1", FEELING_SAFE_NOW) + add(MBlocks.TRITANIUM_DOOR[color]!!, "description2", "Данный вариант выкрашен в $name") + + add(MBlocks.TRITANIUM_TRAPDOOR[color]!!, "$name Тритановый Люк") + add(MBlocks.TRITANIUM_TRAPDOOR[color]!!, "description0", HIGH_BLAST_RESISTANCE_DOOR) + add(MBlocks.TRITANIUM_TRAPDOOR[color]!!, "description1", FEELING_SAFE_NOW) + add(MBlocks.TRITANIUM_TRAPDOOR[color]!!, "description2", "Данный вариант выкрашен в $name") + } + + add(MRegistry.TRITANIUM_PRESSURE_PLATE.block, "Тритановая Нажимная пластина") + add(MRegistry.TRITANIUM_PRESSURE_PLATE.block, "description0", "Активируется только при наступлении игрока на неё") + add(MRegistry.TRITANIUM_PRESSURE_PLATE.block, "description1", HIGH_BLAST_RESISTANCE) + } + + with(provider.english) { + add(MItems.CARGO_CRATE_MINECARTS[null]!!, "Вагонетка с Грузовым Ящиком") + add(MEntityTypes.CARGO_CRATE_MINECARTS[null]!!, "Вагонетка с Грузовым Ящиком") + + add(MRegistry.CARGO_CRATES.block, "Грузовой Ящик") + add(MRegistry.TRITANIUM_BLOCK.block, "Тритановый Блок") + add(MRegistry.TRITANIUM_STAIRS.block, "Тритановые Ступеньки") + add(MRegistry.TRITANIUM_SLAB.block, "Тритановая Плита") + add(MRegistry.TRITANIUM_WALL.block, "Тритановая Ограда") + + add(MRegistry.INDUSTRIAL_GLASS.block, "Промышленное Стекло") + add(MRegistry.INDUSTRIAL_GLASS_PANE.block, "Панель Промышенного Стекла") + + add(MRegistry.DECORATIVE_CRATE.block, "Ржавый Грузовой Контейнер") + + add(MRegistry.VENT.block, "Вентиляция") + add(MRegistry.VENT_ALTERNATIVE.block, "Альтернаятивная Вентиляция") + + for ((block, colors) in MRegistry.TRITANIUM_STRIPED_BLOCK.blocksWithColor) { + val (base, stripe) = colors + + val baseName = provider.englishColors.dyeClassMapped[base]!! + val stripeName = provider.englishColors.dyeClassMapped[stripe]!! + + add(block, "$baseName-Окрашенный $stripeName-Ополосаченный Тритановый Блок") + } + + for ((block, colors) in MRegistry.TRITANIUM_STRIPED_STAIRS.blocksWithColor) { + val (base, stripe) = colors + + val baseName = provider.englishColors.dyeClassMapped[base]!! + val stripeName = provider.englishColors.dyeClassMapped[stripe]!! + + add(block, "$baseName-Окрашенные $stripeName-Ополосаченные Тритановые Ступеньки") + } + + for ((block, colors) in MRegistry.TRITANIUM_STRIPED_SLAB.blocksWithColor) { + val (base, stripe) = colors + + val baseName = provider.englishColors.dyeClassMapped[base]!! + val stripeName = provider.englishColors.dyeClassMapped[stripe]!! + + add(block, "$baseName-Окрашенная $stripeName-Ополосаченная Тритановая Плита") + } + + for ((block, colors) in MRegistry.TRITANIUM_STRIPED_WALL.blocksWithColor) { + val (base, stripe) = colors + + val baseName = provider.englishColors.dyeClassMapped[base]!! + val stripeName = provider.englishColors.dyeClassMapped[stripe]!! + + add(block, "$baseName-Окрашенная $stripeName-Ополосаченная Тритановая Ограда") + } + } +} + +private fun sounds(provider: MatteryLanguageProvider) { + with(provider.russian) { + sound("rifle_shot", "Выстрел плазменной винтовки") + sound("plasma_weapon_overheat", "Плазменное оружие перегрелось") + sound("player_become_android", "Игрок превратился в андроида") + + sound(MSoundEvents.CARGO_CRATE_OPEN, "Открыт грузовой ящик") + } +} + +private fun misc(provider: MatteryLanguageProvider) { + with(provider.english) { + gui("ticks", "Тиков") + + gui("power_cost_per_use", "Энергии на операцию: %s") + gui("power_cost_per_tick", "Энергии на тик: %s") + + gui("cancel", "Отмена") + gui("confirm", "Подтвердить") + + gui("recipe.ticks", "%s Тиков") + + gui("exopack", "Инвентарь Экзопака") + gui("exopack.go_back", "Открыть обычный инвентарь") + gui("exopack.go_in", "Открыть инвентарь экзопака") + gui("exopack.toggle_visibility", "Переключить отображение Экзопака") + + gui("exopack.probe1", "Данное маленькое устройство необычно на ощупь, а так же неприступно для любых попыток вскрыть.") + gui("exopack.probe2", "На одной из сторон данного устройства находится сканер отпечатка, который тускло загорается при касании.") + gui("exopack.probe3", "Вероятно, устройство откроется если достаточно сильно нажать на сканер отпечатка, и вы чувствуете, что последствия будут необратимы!") + + gui("exopack.already_activated", "У вас уже есть Экзопак!") + + gui("exopack_upgrades.no_exopack", "Данный пазл технологии кажется для вас бесполезным... Или..?!") + + gui("exopack_upgrades.already_activated", "Улучшение уже активно!") + gui("exopack_upgrades.slots_upgrade", "Активируя данное улучшение даст %s слотов в вашем Экзопаке.") + gui("exopack_upgrades.crafting_upgrade", "Активируя данное улучшение даст 3x3 сетку создания в вашем Экзопаке.") + + gui("crude_battery.replace_in_world", "Простота устройства данного аккумулятора позволяет вам заменить .") + gui("crude_battery.replace_in_world_warning", "Данная операция крайне рискованная и может нанести огромный урон вашим системам!") + + gui("power_supplier.active_nodes", "Узлы сети, требующие питания: %s") + + misc("battery.single_use", "Единоразовая батарейка, не может быть перезаряжена.") + + misc("exopack_upgrades.slots_upgraded", "Ваш Экзопак был расширен на %s слотов") + misc("exopack_upgrades.crafting_upgraded", "Ваш Экзопак получил 3x3 сетку создания") + + misc("exopack.granted1", "После некоторого времени нажатия на сканер отпечатка, маяк исчезает.") + misc("exopack.granted2", "Через мгновение, вашу спину пронзают множество раз...") + misc("exopack.granted3", "Как только боль утихает, вы обнаруживаете нового 'друга' на вашей спине: Экзопак.") + misc("exopack.granted4", "Данное устройство предоставляет вам доступ к карманному измерению в 4том измерении.") + misc("exopack.granted5", "Ищите или создавайте модули для улучшения Экзопака.") + misc("exopack.granted6", "Так же сам Экзопак существует в 4том измерении, что не мешает носить любую броню.") + misc("exopack.granted7", "Но не смотря на то, что Экзопак существует в 4том измерении, предметы из него всё равно высыпаются при смерти.") + + misc("dumping_matter_registry", "Выгружаю реестр материи в %s") + misc("dumped_matter_registry", "Выгрузил реестр материи в %s") + + misc("iteration", "Iteration %s") + misc("death_reason", "Decommissioned!") + + misc("item.blackhole_immunity", "Нейтрализует гравитационные эффекты сингулярностей") + + misc("suffix.merge", "%s %s") + + misc("suffix.kilo", "%s к%s") + misc("suffix.mega", "%s М%s") + misc("suffix.giga", "%s Г%s") + misc("suffix.tera", "%s Т%s") + misc("suffix.peta", "%s П%s") + misc("suffix.exa", "%s Э%s") + misc("suffix.zetta", "%s З%s") + misc("suffix.yotta", "%s И%s") + + misc("suffix.deci", "%s д%s") + misc("suffix.centi", "%s с%s") + misc("suffix.milli", "%s м%s") + misc("suffix.micro", "%s мк%s") + misc("suffix.nano", "%s н%s") + misc("suffix.pico", "%s п%s") + misc("suffix.femto", "%s ф%s") + misc("suffix.atto", "%s а%s") + misc("suffix.zepto", "%s з%s") + misc("suffix.yocto", "%s и%s") + + misc("suffix_raw.kilo", "к") + misc("suffix_raw.mega", "М") + misc("suffix_raw.giga", "Г") + misc("suffix_raw.tera", "Т") + misc("suffix_raw.peta", "П") + misc("suffix_raw.exa", "Э") + misc("suffix_raw.zetta", "З") + misc("suffix_raw.yotta", "И") + misc("suffix_raw.deci", "д") + misc("suffix_raw.centi", "с") + misc("suffix_raw.milli", "м") + misc("suffix_raw.micro", "мк") + misc("suffix_raw.nano", "н") + misc("suffix_raw.pico", "п") + misc("suffix_raw.femto", "ф") + misc("suffix_raw.atto", "а") + misc("suffix_raw.zepto", "з") + misc("suffix_raw.yocto", "и") + + misc("container.matter_panel.send", "Запросить") + misc("container.matter_panel.close", "Закрыть") + misc("container.matter_panel.cancel_task", "Отменить задание") + misc("container.matter_panel.cancel", "Отмена") + misc("container.matter_panel.label", "Запрос на репликацию") + misc("container.matter_panel.task", "Будущий запрос на репликацию") + + misc("container.matter_panel.tasks", "Задачи") + misc("container.matter_panel.patterns", "Шаблоны") + + misc("item.power.infinite.storage", "Хранимая энергия неиссякаема") + misc("item.power.infinite.throughput", "Максимальный ввод/вывод неограничен") + misc("item.power.passed", "Переданная энергия: %s") + misc("item.power.received", "Принятая энергия: %s") + misc("item.power.average", "Среднее: %s в тик") + misc("item.power.last_20_ticks", "Последняя секунда: %s") + misc("item.power.last_tick", "Последний тик: %s") + + misc("item.power.storage", "Хранимая энергия: %s / %s") + misc("item.power.throughput", "Максимальная пропускная способность: %s / %s") + misc("item.power.throughput_mono", "Максимальная пропускная способность: %s") + misc("item.power.infinity", "∞ МтДж") + + misc("item.worker.work_ticks_mono", "Рабочих тиков: %s") + misc("item.worker.work_ticks", "Рабочих тиков: %s / %s") + + misc("item.block.stored_battery", "Батарея: %s") + + misc("item.pattern.stored", "Хранимые шаблоны: %s / %s") + misc("item.pattern.infinite.stored", "Хранимые шаблоны: %s") + misc("item.pattern.research", "Исследовано: %s%%") + + misc("item.matter.infinite", "Хранимая материя неиссякаема") + misc("item.matter.normal", "Хранимая материя: %s / %s") + + misc("gui.matter_task.total", "Всего: %s") + misc("gui.matter_task.required", "Осталось исполнить: %s") + misc("gui.matter_task.in_progress", "В процессе: %s") + misc("gui.matter_task.finished", "Завершено: %s") + + misc("pill.warning", "ВНИМАНИЕ: Это МГНОВЕННО спишет вас при употреблении!") + misc("pill.android", "Примешь эту таблетку - войдешь в страну чудес, потеряв то, что удерживает тебя здесь.") + + misc("pill.humane", "Примешь эту таблетку - проснешься в своей постели и поверишь, что это был сон.") + + misc("pill.oblivion", "Предметы и Очки опыта, потраченные на исследования полностью возвращаются.") + misc("pill.message_oblivion", "Все возможности андроида были удалены, а потраченные на исследования предметы и опыт возвращены.") + + misc("pill.heal", "Мгновенно восполняет 4 сердца при употреблении, а так же даёт на 2 минуты Поглощение V и на 8 секунд Регенерацию III.") + misc("pill.heal_android", "Не действует на андроидов.") + + misc("pill.message", "Ничего не произошло, но вы чувствуете... себя уставшим?.. Возможно надо отдохнуть.") + misc("pill.message_finish", "§kОДИН ИЗ НАС ОДИН ИЗ НАС ОДИН ИЗ НАС ОДИН ИЗ НАС ОДИН ИЗ НАС") + + misc("gui.power.percentage_level", "Уровень энергии: %s%%") + misc("gui.level", "%s / %s") + misc("gui.power.name", "МтДж") + + misc("gui.power.burn_time", "Оставшееся время горения: %s тиков") + + misc("gui.progress_widget", "Прогресс: %s%%") + misc("gui.progress_widget_stuck", "Это устройство не может продолжить работу, проверьте конфигурацию") + + misc("gui.total_raw", "Всего:") + + misc("gui.matter.percentage_level", "Уровень материи: %s%%") + misc("gui.matter.format", "Материя: %s") + misc("gui.matter.format_and_complexity", "%s / Сложность: %s") + misc("gui.matter.format_and_complexity2", "%s (%s) / Сложность: %s (%s)") + misc("gui.matter.name", "МтЕд") + + misc("gui.filter.is_whitelist", "Белый список") + misc("gui.filter.match_nbt", "Сравнивать NBT") + misc("gui.filter.match_tag", "Сравнить Теги") + + misc("gui.android_research", "Дерево Исследований") + + misc("gui.pattern.percentage_level", "Уровень заполнения: %s%%") + misc("gui.pattern.format", "Хранимые шаблоны: %s / %s") + + misc("gui.redstone.ignored", "Режим красного камня: Игнорирование") + misc("gui.redstone.low", "Режим красного камня: Нет сигнала") + misc("gui.redstone.high", "Режим красного камня: Есть сигнал") + + misc("gui.redstone.ignored.description", "Сигнал красного камня не влияет на работу устройства") + misc("gui.redstone.low.description", "Устройство работает если нет сигнала красного камня") + misc("gui.redstone.high.description", "Устройство работает если есть сигнал красного камня") + + misc("3d2d.gravitation_stabilizer.mass", "Масса сингулярности: %s") + misc("3d2d.gravitation_stabilizer.strength", "Гравитационная сила: %s") + + misc("android_station.research.low_power", "Мало питания у Станции Андроидов! Исследования недоступны!") + misc("android_station.research.researched", "Исследовано!") + misc("android_station.research.can_be_researched", "Готово к исследованию!") + misc("android_station.research.can_not_be_researched", "Нельзя исследовать!") + misc("android_station.research.xp_cost", "Требуется %s уровней Опыта") + misc("android_station.research.item", "Требует %s %s шт.") + misc("android_station.research.missing_predecessors", "Сначала надо изучить %s") + + misc("android_station.research.confirm", "Подтвердите исследование %s") + misc("android_station.research.research_will_be_blocked", "Следующие исследования станут недоступны:") + + misc("android_station.low_power_0", "Недостаточно питания; Невозможно менять части андроида") + misc("android_station.low_power_1", "Слабое питание; Невозможно исследовать") + misc("android_station.power_ok", "Питание в норме") + + misc("filter.yes", "Да") + misc("filter.no", "Нет") + + misc("matter_bottler.switch_mode", "Переключить режим работы") + + misc("container.matter_panel.number_input", "Введите кол-во единиц репликации") + + misc("item.quantum_battery.creative", "Наполните этот аккумулятор чтоб выиграть Minecraft.") + misc("item.quantum_battery.creative2", "Встретимся после выгорания миллионов звёзд.") + misc("item.quantum_battery.creative_power", "Хранимая энергия: %s / ∞") + + misc("item.quantum_link_id", "ID Квантового соединения: %s") + misc("item.quantum_description", "Содержимое данного предмета связано с другими предметами посредством квантовой запутанности") + } +} + +private fun death(provider: MatteryLanguageProvider) { + with(provider.russian) { + death("otm_become_android", "%1\$s потерял свою человечность") + death("otm_become_humane", "%1\$s восстановил свою человечность") + death("otm_event_horizon", "%1\$s никогда не пересёк горизонт событий") + death("otm_hawking_radiation", "%1\$s открыл излучение Хокинга") + death("otm_emp", "Электроника %1\$s перегорела") + + death("otm_become_android.player", "%1\$s потерял свою человечность, когда %2\$s пытался образумить их") + death("otm_become_humane.player", "%1\$s восстановил свою человечность, когда %2\$s пытался образумить их") + death("otm_event_horizon.player", "%1\$s попытался пересечь горизонт событий, спасаясь от %2\$s") + death("otm_hawking_radiation.player", "%1\$s распался пока сражался с %2\$s") + death("otm_emp.player", "%2\$s выбил все предохранители %1\$s") + death("otm_emp.player.item", "%2\$s выбил все предохранители %1\$s используя %3\$s") + + death(MRegistry.DAMAGE_EXOPACK_PROBE_ID, "%1\$s не выдержал спинную хирургию") + death("${MRegistry.DAMAGE_EXOPACK_PROBE_ID}.player", "%1\$s не выдержал спинную хирургию пока сражался с %2\$s") + } +} + +private fun blocks(provider: MatteryLanguageProvider) { + with(provider.russian) { + add(MBlocks.ANDROID_STATION, "Станция Андроидов") + add(MBlocks.BATTERY_BANK, "Банк Аккумуляторов") + add(MBlocks.MATTER_DECOMPOSER, "Декомпозитор Материи") + add(MBlocks.MATTER_CAPACITOR_BANK, "Банк Накопителей Материи") + add(MBlocks.MATTER_CABLE, "Кабель Сети Материи") + add(MBlocks.PATTERN_STORAGE, "Хранилище Шаблонов") + add(MBlocks.MATTER_SCANNER, "Сканер Материи") + add(MBlocks.MATTER_PANEL, "Монитор Шаблонов") + add(MBlocks.MATTER_REPLICATOR, "Репликатор Материи") + add(MBlocks.MATTER_BOTTLER, "Бутилировщик Материи") + add(MBlocks.DRIVE_VIEWER, "Просмотрщик Дисков Конденсации") + add(MBlocks.BLACK_HOLE, "Локализированное Аномальное Сингулярное Гравитационное Поле") + + add(MBlocks.ENGINE, "Двигатель Корабля") + + add(MBlocks.TRITANIUM_INGOT_BLOCK, "Блок Слитков Тритана") + + add(MBlocks.ENERGY_COUNTER, "Счётчик Энергии") + add(MBlocks.ENERGY_COUNTER, "facing", "Сторона входа: %s") + add(MBlocks.ENERGY_COUNTER, "switch", "Сменить сторону входа") + add(MBlocks.ENERGY_COUNTER, "limit", "Лимит Ввода/Вывода. -1 для отключения лимитов") + + add(MBlocks.CHEMICAL_GENERATOR, "Химический Генератор") + add(MBlocks.DRIVE_RACK, "Стеллаж Дисков Конденсации") + add(MBlocks.ITEM_MONITOR, "Монитор Предметов") + add(MBlocks.PLATE_PRESS, "Пресс Пластин") + + add(MBlocks.MATTER_RECYCLER, "Перерабатыватель Материи") + add(MBlocks.ENERGY_SERVO, "Энергетическая Помпа") + add(MBlocks.ENERGY_SERVO, "desc", "Заряжает, Разряжает и Передаёт энергию между предметами") + + add(MBlocks.CARBON_FIBRE_BLOCK, "Блок Углеродных Трубок") + + add(MBlocks.TRITANIUM_STRIPED_BLOCK, "Тритановый Блок с Полоской") + add(MBlocks.TRITANIUM_STRIPED_STAIRS, "Тритановые Ступеньки с Полоской") + add(MBlocks.TRITANIUM_STRIPED_SLAB, "Тритановая Плита с Полоской") + add(MBlocks.TRITANIUM_STRIPED_WALL, "Тритановая Ограда с Полоской") + add(MBlocks.TRITANIUM_ORE, "Тритановая Руда") + add(MBlocks.DEEPSLATE_TRITANIUM_ORE, "Тританоносный Глубинный Сланец") + add(MBlocks.TRITANIUM_RAW_BLOCK, "Блок Рудного Тритана") + + add(MBlocks.STORAGE_CABLE, "Кабель Хранилища") + add(MBlocks.STORAGE_POWER_SUPPLIER, "Подстанция Сети Хранилища") + add(MBlocks.STORAGE_BUS, "Шина Хранилища") + add(MBlocks.STORAGE_IMPORTER, "Импортер Хранилища") + add(MBlocks.STORAGE_EXPORTER, "Экспортер Хранилища") + + add(MBlocks.GRAVITATION_STABILIZER, "Стабилизатор Пространства-Времени") + add(MBlocks.GRAVITATION_STABILIZER_LENS, "Линза Стабилизатора Пространства-Времени") + add(MBlocks.GRAVITATION_STABILIZER, "desc", "Уменьшает гравитационное влияние сингулярностей") + add(MBlocks.GRAVITATION_STABILIZER, "desc2", "Не требует энергии для работы") + add(MBlocks.GRAVITATION_STABILIZER, "desc3", "Имейте в ввиду, что несколько стабилизаторов создают экспоненциальный эффект") + add(MBlocks.GRAVITATION_STABILIZER, "desc4", "Слишком слабое гравитационное поле сингулярности приведёт к быстрому испарению последней") + + add(MBlocks.PHANTOM_ATTRACTOR, "Приманщик Фантомов") + add(MBlocks.PHANTOM_ATTRACTOR, "desc", "Приманивает фантомов в ночное время") + add(MBlocks.PHANTOM_ATTRACTOR, "desc2", "Не требует энергии для работы") + + add(MBlocks.LABORATORY_LAMP, "Лабораторная Лампа") + add(MBlocks.LABORATORY_LAMP, "description", "Освещает на несколько блоков в направлении своей лампы, с переключателем красного камня") + add(MBlocks.LABORATORY_LAMP_INVERTED, "Лабораторная Лампа (Инвентированный Сигнал)") + add(MBlocks.DANGER_STRIPE_BLOCK, "Полоски 'Опасность'") + add(MBlocks.METAL_BEAM, "Металлическая Опора") + + add(MBlocks.TRITANIUM_DOOR[null]!!, "Тритановая Дверь") + add(MBlocks.TRITANIUM_DOOR[null]!!, "description0", "Взрывоустойчивая дверь с засовом красного камня...") + add(MBlocks.TRITANIUM_DOOR[null]!!, "description1", FEELING_SAFE_NOW) + + add(MBlocks.TRITANIUM_TRAPDOOR[null]!!, "Тритановый Люк") + add(MBlocks.TRITANIUM_TRAPDOOR[null]!!, "description0", "Взрывоустойчивая дверь с засовом красного камня...") + add(MBlocks.TRITANIUM_TRAPDOOR[null]!!, "description1", FEELING_SAFE_NOW) + } +} + +private fun items(provider: MatteryLanguageProvider) { + with(provider.russian) { + add(MItems.EXOPACK_PROBE, "Маяк Экзопака") + add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_CREATIVE, "Творческое Обновление Инвентаря Экзопака") + add(MItems.ExopackUpgrades.CRAFTING_UPGRADE, "Обновление Сетки Крафта Экзопака") + + add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_WITHER, "Обновление Сверхмассивной Упаковки") + add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_WITHER, "description", "Использует те же принципы, которыми обладают Звёзды Незера") + + add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_ENDER_DRAGON, "Обновление Соединения Края Экзопака") + add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_ENDER_DRAGON, "description", "Позволяет хранить предметы в карманном измерении") + + add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, "Неописуемое Обновление Инвентаря Экзопака") + add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, "description", "В нормальных условиях, они появляются в сундуках") + + add(MItems.NUTRIENT_PASTE, "Питательная Паста") + + add(MItems.BLACK_HOLE_SCANNER, "Сканер Сингулярностей") + add(MItems.BLACK_HOLE_SCANNER, "desc", "Сканирует сингулярности и считывает их свойства") + add(MItems.BLACK_HOLE_SCANNER, "desc2", "Держите в любой их рук для считывания массы сингулярностей") + + add(MItems.GRAVITATION_FIELD_LIMITER, "Ограничитель Гравитационного Поля") + add(MItems.GRAVITATION_FIELD_SENSOR, "Сенсор Гравитационного Искажения") + add(MItems.PORTABLE_GRAVITATION_STABILIZER, "Портативный Стабилизатор Пространства-времени") + + add(MItems.BATTERY_CRUDE, "Самобытный Аккумулятор") + add(MItems.BATTERY_BASIC, "Простой Аккумулятор") + add(MItems.BATTERY_NORMAL, "Аккумулятор") + add(MItems.BATTERY_DENSE, "Плотный Аккумулятор") + add(MItems.BATTERY_CAPACITOR, "Аккумулятор-Накопитель") + add(MItems.BATTERY_CREATIVE, "Творческий Аккумулятор") + + add(MItems.QUANTUM_BATTERY, "Квантовый Аккумулятор") + add(MItems.QUANTUM_CAPACITOR, "Квантовый Аккумулятор-Накопитель") + add(MItems.QUANTUM_BATTERY_CREATIVE, "Творческий Квантовый Аккумулятор") + + add(MItems.TRITANIUM_SWORD, "Тритановый Меч") + add(MItems.TRITANIUM_PICKAXE, "Тритановая Кирка") + add(MItems.TRITANIUM_SHOVEL, "Тритановая Лопата") + add(MItems.TRITANIUM_AXE, "Тритановый Топор") + add(MItems.TRITANIUM_HOE, "Тритановая Мотыга") + + add(MItems.TRITANIUM_HELMET, "Тритановый Шлем") + add(MItems.TRITANIUM_CHESTPLATE, "Тритановый Нагрудник") + add(MItems.TRITANIUM_PANTS, "Тритановые Поножи") + add(MItems.TRITANIUM_BOOTS, "Тритановые Ботинки") + + add(MItems.TRITANIUM_DUST, "Тритановая Пыль") + add(MItems.TRITANIUM_INGOT, "Тритановый Слиток") + add(MItems.MATTER_IO_PORT, "Порт Ввода/Вывода Материи") + add(MItems.MATTER_TRANSFORM_MATRIX, "Матрица Преобразования Материи") + add(MItems.ENERGY_BUS, "Шина Питания") + add(MItems.ELECTRIC_PARTS, "Электрические Части") + add(MItems.MACHINE_FRAME, "Каркас Механизма") + add(MItems.TRITANIUM_PLATE, "Тритановая Пластина") + add(MItems.IRON_PLATE, "Железная Пластина") + add(MItems.GOLD_PLATE, "Золотая Пластина") + add(MItems.COPPER_WIRING, "Медная Проволока") + add(MItems.GOLD_WIRING, "Золотая Проволока") + add(MItems.PORTABLE_CONDENSATION_DRIVE_CASING, "Каркас Портативного Диска Конденсации") + add(MItems.PORTABLE_DENSE_CONDENSATION_DRIVE_CASING, "Каркас Плотного Портативного Диска Конденсации") + add(MItems.CIRCUIT_PLATING, "Плата Электроники") + add(MItems.BASIC_CONTROL_CIRCUIT, "Простая Схема Управления") + add(MItems.ADVANCED_CONTROL_CIRCUIT, "Продвинутая Схема Управления") + add(MItems.QUANTUM_TRANSCEIVER, "Квантовый Передатчик") + add(MItems.ELECTROMAGNET, "Электромагнит") + add(MItems.MIRROR_COMPOUND, "Набор Выплавки Стекла") + add(MItems.MIRROR, "Зеркало") + add(MItems.MIRROR, "description", "Я могу очень отчётливо видеть своё отражение в этом зеркале") + + add(MItems.GRAVITATIONAL_DISRUPTOR, "Антигравитационный Маяк") + + add(MItems.GRAVITATIONAL_DISRUPTOR, "description", "Будучи находясь около сверхмассивного тела, создаёт противоположное искажение пространства-времени") + add(MItems.GRAVITATIONAL_DISRUPTOR, "description2", "Позволяет уничтожать сингулярности") + add(MItems.GRAVITATIONAL_DISRUPTOR, "description3", "Никак не влияет на материю, которую накопила сингулярность, что вызывает неописуемо сильный взрыв материи!") + add(MItems.GRAVITATIONAL_DISRUPTOR, "description4", "Взрыв %s сдержан %s. Даже не пытайтесь его сдержать.") + add(MItems.GRAVITATIONAL_DISRUPTOR, "description4_clarification", "не может быть") + add(MItems.GRAVITATIONAL_DISRUPTOR, "description4_clarification2", "ничем") + + add(MItems.MATTER_DUST, "Пыль Материи") + add(MItems.MATTER_DUST, "desc", "Данный предмет является результатом неудачной попытки декомпозиции или репликации") + add(MItems.MATTER_DUST, "desc2", "Закиньте в Материальный Переработчик для переработки обратно в чистую материю!") + add(MItems.MATTER_DUST, "desc3", "Не нюхать, не кидать на других и не сыпать на пончики") + + add(MItems.PILL_ANDROID, "Таблетка Андроида") + add(MItems.PILL_HUMANE, "Таблетка Человечности") + add(MItems.PILL_OBLIVION, "Таблетка Сброса Андроида до Заводских Настроек") + add(MItems.PILL_HEAL, "Медицинская Таблетка") + + add(MItems.MATTER_CAPACITOR_PARTS, "Части Накопителя Материи") + add(MItems.MATTER_CAPACITOR_BASIC, "Простой Накопитель Материи") + add(MItems.MATTER_CAPACITOR_NORMAL, "Накопитель Материи") + add(MItems.MATTER_CAPACITOR_DENSE, "Плотный Накопитель Материи") + add(MItems.MATTER_CAPACITOR_CREATIVE, "Творческий Накопитель Материи") + + add(MItems.ENERGY_SWORD, "Высокочастотный Клинок") + add(MItems.ENERGY_SWORD, "desc", "Требует энергию для работы") + add(MItems.ENERGY_SWORD, "desc2", "Наносит дополнительный урон андроидам если имеет заряд") + add(MItems.ENERGY_SWORD, "desc3", "Всегда наносит полный урон по площади если имеет заряд") + add(MItems.ENERGY_SWORD, "desc4", "Зачарование 'Разящий клинок' не имеет никакого эффекта на данном оружии") + + add(MItems.PORTABLE_CONDENSATION_DRIVE, "Portable Condensation Drive") + add(MItems.PORTABLE_DENSE_CONDENSATION_DRIVE, "Portable Dense Condensation Drive") + add(MItems.PLASMA_RIFLE, "Плазменная Винтовка") + add(MItems.TRITANIUM_ORE_CLUMP, "Рудный Тритан") + add(MItems.PATTERN_DRIVE_NORMAL, "Диск Шаблонов") + add(MItems.PATTERN_DRIVE_CREATIVE, "Творческий Диск Шаблонов") + + add(MItems.PATTERN_DRIVE_CREATIVE2, "Вездесущий Диск Шаблонов") + add(MItems.PATTERN_DRIVE_CREATIVE2, "description1", "Предмет режима творчества") + add(MItems.PATTERN_DRIVE_CREATIVE2, "description2", "Содержит в себе шаблоны всех предметов, которые имеют значение материи") + + add(MItems.ZPM_BATTERY, "Модуль Нулевой Точки") + add(MItems.ZPM_BATTERY, "description", "Может быть найден у тех, кто путешествует между измерениями, если, конечно, они смогли достигнуть вселенной, где данные устройства были созиданы...") + } +} + +private fun stats(provider: MatteryLanguageProvider) { + with(provider.russian) { + stat("health_regenerated", "Здоровья Отрегенерировано Наноботами") + stat("damage_absorbed", "Урона Поглащено Наноботами") + stat("power_consumed", "МтДж Сожжено за Андроида") + } +} + +private fun research(provider: MatteryLanguageProvider) { + with(provider.russian) { + add("android_research.status.requires", "Требует %s для изучения") + add("android_research.status.blocks", "Блокирует %s") + add("android_research.status.blocked_by", "Блокируется %s") + add("android_research.status.requires_item", "Требует %s") + add("android_research.status.requires_item_multiple0", "Требует %s %s шт. (требуется ещё %s шт.)") + add("android_research.status.requires_item_multiple1", "Требует %s %s шт.") + + add("android_research.status.requires_item_any", "Требует любое из %s") + add("android_research.status.requires_item_multiple_any0", "Требует любое из %s %s шт. (требуется ещё %s шт.)") + add("android_research.status.requires_item_multiple_any1", "Требует любое из %s %s шт.") + } +} + +private fun androidFeatures(provider: MatteryLanguageProvider) { + with(provider.russian) { + add(AndroidFeatures.AIR_BAGS, "Воздушные Мешки") + add(AndroidFeatures.SHOCKWAVE, "Генератор Ударных Волн") + add(AndroidFeatures.NIGHT_VISION, "Ночное Зрение") + add(AndroidFeatures.NANOBOTS_ARMOR, "Броня из Наноботов") + add(AndroidFeatures.ITEM_MAGNET, "Магнит Предметов") + add(AndroidFeatures.STEP_ASSIST, "Помощник Подъёма") + add(AndroidFeatures.PHANTOM_ATTRACTOR, "Приманщик Фантомов") + add(AndroidFeatures.JUMP_BOOST, "Усилитель Прыжка") + add(AndroidFeatures.ENDER_TELEPORTER, "Телепортатор Края") + } +} + +private fun gui(provider: MatteryLanguageProvider) { + with(provider.russian) { + gui("item_monitor.refill_source.desc", "Контролирует источник предметов для заполнения сетки создания") + gui("item_monitor.refill_source.system", "Только система. Сетка создания будет заполняться только из системы предметов. Данный параметр соответствует поведению AE2 и Refined Storage") + gui("item_monitor.refill_source.inventory", "Только инвентарь. Сетка создания будет заполняться только из инвентаря игрока") + gui("item_monitor.refill_source.system_first", "Сначала система. Сетка создания сначала будет заполняться из системы предметов, а затем из инвентаря игрока") + gui("item_monitor.refill_source.inventory_first", "Сначала инвентарь. Сетка создания сначала будет заполняться из инвентаря игрока, а затем из системы предметов") + gui("item_monitor.refill_source.do_not", "Не заполнять автоматически") + + gui("item_monitor.result_target.desc", "Контролирует поведение сетки создания") + gui("item_monitor.result_target.all_system", "Всё в систему. И результат создания и остаток отправляется в систему предметов") + gui("item_monitor.result_target.mixed", "Смешанный. Результат создания кладётся в инвентарь игрока, остаток отправляется в систему предметов") + gui("item_monitor.result_target.all_inventory", "Всё в инвентарь. И результат создания и остаток кладётся в инвентарь игрока") + + gui("item_monitor.amount.desc", "Контролирует сколько предметов создавать при быстром крафте") + gui("item_monitor.amount.one", "Ровно один предмет") + gui("item_monitor.amount.stack", "Ровно одну стопку. Данный параметр соответствует поведению AE2 и Refined Storage") + gui("item_monitor.amount.full", "Стопку ингредиентов. Создание продолжается пока не будет достигнут лимит по стопке одного из ингредиентов. Если хотя бы один из ингредиентов не может быть стопкой, будет использован режим 'одна стопка результата'") + + gui("stored_amount", "Точное количество в хранилище: %s шт.") + } +} + +fun AddRussianLanguage(provider: MatteryLanguageProvider) { + decoratives(provider) + blocks(provider) + sounds(provider) + misc(provider) + items(provider) + gui(provider) + stats(provider) + research(provider) + death(provider) + androidFeatures(provider) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ExoPackProbeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ExoPackProbeItem.kt index ec4e4a962..12bfbaf5f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ExoPackProbeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ExoPackProbeItem.kt @@ -62,9 +62,10 @@ class ExoPackProbeItem : Item(Properties().stacksTo(1).rarity(Rarity.EPIC)) { mattery.hasExoPack = true player.displayClientMessage(TranslatableComponent("otm.exopack.granted1").withStyle(ChatFormatting.GRAY), false) + player.displayClientMessage(TranslatableComponent("otm.exopack.granted2").withStyle(ChatFormatting.GRAY), false) player.hurt(MRegistry.DAMAGE_EXOPACK_PROBE, 10f) - for (i in 2 .. 8) { + for (i in 3 .. 7) { onceServer((i - 1) * 100) { if (!player.hasDisconnected()) { if (i == 6) { From 610e10c9ad31ca2e74ebba14f79adcb6b2595fd6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 23 Jan 2023 14:44:24 +0700 Subject: [PATCH 0069/1199] Russian locale for main advancements --- .../datagen/advancements/AdvancementData.kt | 248 +++++++++++++----- .../datagen/lang/MatteryLanguageProvider.kt | 28 +- .../mc/otm/datagen/lang/Russian.kt | 34 +-- 3 files changed, 229 insertions(+), 81 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt index cfbbeefee..f47aeba45 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt @@ -19,14 +19,16 @@ import ru.dbotthepony.mc.otm.triggers.BlackHoleTrigger import java.util.function.Consumer fun addAdvancements(serializer: Consumer, existingFileHelper: ExistingFileHelper, lang: MatteryLanguageProvider) { - val translation = lang.english.Prepended("otm.advancements.regular") + val translation = lang.MultiBuilder("otm.advancements.regular") val root = AdvancementBuilder() .requirements(RequirementsStrategy.OR) .display( itemStack = ItemStack(MItems.TRITANIUM_INGOT), - title = TranslatableComponent(translation.add("root", "Overdrive That Matters")), - description = TranslatableComponent(translation.add("root.desc", "Its all about things that matter")), + title = translation.add("root", "Overdrive That Matters"), + description = translation.add("root.desc", "Its all about things that matter") { + russian("Мод про все штуки которые материальны") + }, showToast = false, announceChat = false, background = modLocation("textures/block/decorative/tritanium_block_gray.png") @@ -40,8 +42,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(root) .display( itemStack = ItemStack(MItems.BATTERY_CRUDE), - title = TranslatableComponent(translation.add("crude_battery", "Potato Power!")), - description = TranslatableComponent(translation.add("crude_battery.desc", "Put together a Crude Battery. Better hope for getter better power source soon")), + title = translation.add("crude_battery", "Potato Power!") { + russian("Сила Картофеля!") + }, + description = translation.add("crude_battery.desc", "Put together a Crude Battery. Better hope for getter better power source soon") { + russian("Создайте Простой Аккумулятор. Надо бы поторопиться с созданием более продвинутого аккумулятора") + }, ) .addCriterion("has_item", criterion(MItems.BATTERY_CRUDE)) .save(serializer, modLocation("regular/crude_battery"), existingFileHelper) @@ -50,8 +56,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(crude) .display( itemStack = ItemStack(MItems.BATTERY_NORMAL), - title = TranslatableComponent(translation.add("normal_battery", "Power Storage")), - description = TranslatableComponent(translation.add("normal_battery.desc", "Put together an Ordinary Battery")), + title = translation.add("normal_battery", "Power Storage") { + russian("Хранилище Энергии") + }, + description = translation.add("normal_battery.desc", "Put together a Battery") { + russian("Создайте Аккумулятор") + }, ) .addCriterion("has_item", criterion(MItems.BATTERY_NORMAL)) .save(serializer, modLocation("regular/normal_battery"), existingFileHelper) @@ -60,8 +70,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(normal) .display( itemStack = ItemStack(MItems.BATTERY_DENSE), - title = TranslatableComponent(translation.add("dense_battery", "Extra Space Battery")), - description = TranslatableComponent(translation.add("dense_battery.desc", "Put together a Dense Battery. Better not to expose it to fires!")), + title = translation.add("dense_battery", "Extra Space Battery") { + russian("Больше Места для Энергии") + }, + description = translation.add("dense_battery.desc", "Put together a Dense Battery. Better not to expose it to fires!") { + russian("Создайте Плотный Аккумулятор. Держите подальше от огня!") + }, ) .addCriterion("has_item", criterion(MItems.BATTERY_DENSE)) .save(serializer, modLocation("regular/dense_battery"), existingFileHelper) @@ -70,8 +84,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(normal) .display( itemStack = ItemStack(MItems.BATTERY_CAPACITOR), - title = TranslatableComponent(translation.add("capacitor_battery", "Supercapacitor")), - description = TranslatableComponent(translation.add("capacitor_battery.desc", "Put together a Capacitor Battery. Surely, you gonna need them somewhere...")), + title = translation.add("capacitor_battery", "Supercapacitor") { + russian("Сверхконденсатор") + }, + description = translation.add("capacitor_battery.desc", "Put together a Capacitor Battery. Surely, you gonna need them somewhere...") { + russian("Создайте Аккумулятор-Конденсатор. Очень вероятно, что вы найдете ему применение...") + }, ) .addCriterion("has_item", criterion(MItems.BATTERY_CAPACITOR)) .save(serializer, modLocation("regular/capacitor_battery"), existingFileHelper) @@ -80,8 +98,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(capacitor) .display( itemStack = ItemStack(MItems.ENERGY_SWORD), - title = TranslatableComponent(translation.add("energy_sword", "Self Sharpening Blade")), - description = TranslatableComponent(translation.add("energy_sword.desc", "Wield a High-Frequency Blade, a melee weapon intended to slice Creepers into creep-cakes. Rational folks won't attempt to slice their Android fellows...")), + title = translation.add("energy_sword", "Self Sharpening Blade") { + russian("Клинок с Самозаточкой") + }, + description = translation.add("energy_sword.desc", "Wield a High-Frequency Blade, a melee weapon intended to slice Creepers into creep-cakes") { + russian("Получите Высокочастотный Клинок, оружие ближнего боя предназначенное для нарезания Криперов на крипо-тортики") + }, frameType = FrameType.GOAL ) .addCriterion("has_item", criterion(MItems.ENERGY_SWORD)) @@ -91,8 +113,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(normal) .display( itemStack = ItemStack(MItems.QUANTUM_BATTERY), - title = TranslatableComponent(translation.add("quantum_battery", "Power, in Superposition")), - description = TranslatableComponent(translation.add("quantum_battery.desc", "Put together a Quantum Battery, powered by Ender technologies")), + title = translation.add("quantum_battery", "Power, in Superposition") { + russian("Энергия, в Суперпозиции") + }, + description = translation.add("quantum_battery.desc", "Put together a Quantum Battery, powered by Ender technologies") { + russian("Создайте Квантовый Аккумулятор, пропитаную технологиями Края") + }, frameType = FrameType.GOAL ) .rewards(AdvancementRewards.Builder.experience(50)) @@ -105,8 +131,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(root) .display( itemStack = ItemStack(MItems.ZPM_BATTERY), - title = TranslatableComponent(translation.add("zpm_battery", "Pocket Universe, as Power Source")), - description = TranslatableComponent(translation.add("zpm_battery.desc", "Find Zero Point Module, something from different universe of ours, created using technologies lost in time in all possible multiverses")), + title = translation.add("zpm_battery", "Pocket Universe, as Power Source") { + russian("Карманная Вселенная, как Источник Питания") + }, + description = translation.add("zpm_battery.desc", "Find Zero Point Module, something from different multiverse of ours, created using technologies lost in time in all possible multiverses") { + russian("Найдите Модуль Нулевой Точки, вещь из другой мультивселенной, созданная с использованием технологий, потерянных во времени во всех возможных мультивслеленных") + }, frameType = FrameType.CHALLENGE, hidden = true ) @@ -118,8 +148,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(root) .display( itemStack = ItemStack(MItems.BLACK_HOLE), - title = TranslatableComponent(translation.add("black_hole_pull", "Something Massive and Something Close")), - description = TranslatableComponent(translation.add("black_hole_pull.desc", "Experience Singularity's gravitational force, better not to get closer")), + title = translation.add("black_hole_pull", "Something Massive and Something Close") { + russian("Что то Массивное и Близкое") + }, + description = translation.add("black_hole_pull.desc", "Experience Singularity's gravitational force, better not to get closer") { + russian("Испытайте на себе гравитационную силу Сингулярности, лучше не подходить ближе") + }, hidden = true ) .addCriterion("pulled_by_black_hole", BlackHoleTrigger.Instance) @@ -129,8 +163,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(blackhole) .display( itemStack = ItemStack(MItems.BLACK_HOLE_SCANNER), - title = TranslatableComponent(translation.add("black_hole_scanner", "Determining the Mass")), - description = TranslatableComponent(translation.add("black_hole_scanner.desc", "Craft the Singularity Scanner, to determine mass of Singularity from safe distance")), + title = translation.add("black_hole_scanner", "Determining the Mass") { + russian("Определяем Массу") + }, + description = translation.add("black_hole_scanner.desc", "Craft the Singularity Scanner, to determine mass of... Singularities, from safe distance") { + russian("Создайте Сканер Сингулярностей, для определения массы... Сингулярностей на безопасном расстоянии") + }, ) .addCriterion("has_item", criterion(MItems.BLACK_HOLE_SCANNER)) .save(serializer, modLocation("regular/black_hole_scanner"), existingFileHelper) @@ -139,8 +177,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(blackhole) .display( itemStack = ItemStack(MItems.GRAVITATION_STABILIZER), - title = TranslatableComponent(translation.add("stabilizer", "Reducing the Impact")), - description = TranslatableComponent(translation.add("stabilizer.desc", "Put together a device that defy physical laws and also defy gravity of Singularities. Better hope it does not cause any side effects")), + title = translation.add("stabilizer", "Reducing the Impact") { + russian("Уменьшаем Воздействие") + }, + description = translation.add("stabilizer.desc", "Put together a device that defy physical laws and also defy gravity of Singularities. Better hope it does not cause any side effects") { + russian("Создайте устройство, которое смеётся перед законами физики, а так же смеётся перед силами гравитации Сингулярностей. Надо надеется, что это не принесёт никаких последствий") + }, ) .addCriterion("has_item", criterion(MItems.GRAVITATION_STABILIZER)) .save(serializer, modLocation("regular/stabilizer"), existingFileHelper) @@ -149,8 +191,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(blackhole) .display( itemStack = ItemStack(MItems.PORTABLE_GRAVITATION_STABILIZER), - title = TranslatableComponent(translation.add("portable_stabilizer", "Local Gravity Field")), - description = TranslatableComponent(translation.add("portable_stabilizer.desc", "Protect yourself from gravitational effect of Singularity using Portable Gravitation Stabilizer")), + title = translation.add("portable_stabilizer", "Local Gravity Field") { + russian("Локальное Поле Гравитации") + }, + description = translation.add("portable_stabilizer.desc", "Protect yourself from gravitational effect of Singularity using Portable Space-Time Equalizer") { + russian("Защитите себя от гравитационных эффектов Сингулярностей используя Портативный") + }, ) .addCriterion("has_item", criterion(MItems.PORTABLE_GRAVITATION_STABILIZER)) .save(serializer, modLocation("regular/portable_stabilizer"), existingFileHelper) @@ -160,8 +206,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .requirements(RequirementsStrategy.OR) .display( itemStack = ItemStack(MItems.TRITANIUM_ORE_CLUMP), - title = TranslatableComponent(translation.add("ore", "Blue Metal Discovery")), - description = TranslatableComponent(translation.add("ore.desc", "Mine some Tritanium")), + title = translation.add("ore", "Blue Metal Discovery") { + russian("Открытие Синего Металла") + }, + description = translation.add("ore.desc", "Mine some Tritanium") { + russian("Добудьте немного Тритана") + }, ) .addCriterion("has_tritanium_ore", criterion(MItemTags.TRITANIUM_ORES)) .addCriterion("has_tritanium_ore_clump", criterion(MItemTags.TRITANIUM_ORE_CLUMPS)) @@ -171,8 +221,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(ore) .display( itemStack = ItemStack(MItems.TRITANIUM_INGOT), - title = TranslatableComponent(translation.add("ingot", "Acquire Harder-ware")), - description = TranslatableComponent(translation.add("ingot.desc", "Smelt a Tritanium ingot")), + title = translation.add("ingot", "Acquire Harder-ware") { + russian("Куй сильнее...") + }, + description = translation.add("ingot.desc", "Smelt a Tritanium ingot") { + russian("Выплавьте Тритановый слиток") + }, ) .addCriterion("has_tritanium_ingot", criterion(MItemTags.TRITANIUM_INGOTS)) .save(serializer, modLocation("regular/ingot"), existingFileHelper) @@ -181,8 +235,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(ingot) .display( itemStack = ItemStack(MItems.TRITANIUM_PICKAXE), - title = TranslatableComponent(translation.add("pickaxe", "A Tool for Patient Miners")), - description = TranslatableComponent(translation.add("pickaxe.desc", "Craft a Tritanium Pickaxe")), + title = translation.add("pickaxe", "A Tool for Patient Miners") { + russian("Инструмент для Неспешных Шахтёров") + }, + description = translation.add("pickaxe.desc", "Craft a Tritanium Pickaxe") { + russian("Создайте Тритановую Кирку") + }, ) .addCriterion("has_tritanium_pickaxe", criterion(MItems.TRITANIUM_PICKAXE)) .save(serializer, modLocation("regular/pickaxe"), existingFileHelper) @@ -191,8 +249,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(ingot) .display( itemStack = ItemStack(MItems.TRITANIUM_HOE), - title = TranslatableComponent(translation.add("hoe", "A Tool for Farmers")), - description = TranslatableComponent(translation.add("hoe.desc", "Tritanium is a very good choice for making a sturdy Hoe")), + title = translation.add("hoe", "A Tool for Farmers") { + russian("Инструмент для Фермеров") + }, + description = translation.add("hoe.desc", "Tritanium is a very good choice for making a sturdy Hoe") { + russian("Тритан - очень хороший выбор для создания прочной Мотыги") + }, hidden = true ) .addCriterion("hoe", criterion(MItems.TRITANIUM_HOE)) @@ -202,8 +264,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(ingot) .display( itemStack = ItemStack(MItems.TRITANIUM_PLATE), - title = TranslatableComponent(translation.add("plate", "Hard Plating")), - description = TranslatableComponent(translation.add("plate.desc", "Roll down some Tritanium using a Plate Press")) + title = translation.add("plate", "Hard Plating") { + russian("Прочные Пластины") + }, + description = translation.add("plate.desc", "Roll down some Tritanium using a Plate Press") { + russian("Раскатайте немного Тритана используя Пресс Пластин") + } ) .addCriterion("has_item", criterion(MItemTags.TRITANIUM_PLATES)) .save(serializer, modLocation("regular/plate"), existingFileHelper) @@ -212,8 +278,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(plate) .display( itemStack = ItemStack(MItems.TRITANIUM_CHESTPLATE), - title = TranslatableComponent(translation.add("armor", "Composite Armor")), - description = TranslatableComponent(translation.add("armor.desc", "Bend some Tritanium plates into simple yet sturdy armor")) + title = translation.add("armor", "Composite Armor") { + russian("Композитная Броня") + }, + description = translation.add("armor.desc", "Bend some Tritanium Plates into simple yet sturdy armor") { + russian("Согните немного Тритановых Пластин в простую, но прочную, броню") + } ) .requirements(RequirementsStrategy.OR) .addCriterion("has_item0", criterion(MItems.TRITANIUM_HELMET)) @@ -226,8 +296,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(plate) .display( itemStack = ItemStack(MRegistry.INDUSTRIAL_GLASS.item), - title = TranslatableComponent(translation.add("industrial_glass", "Extra Hard Glass")), - description = TranslatableComponent(translation.add("industrial_glass.desc", "Manual says it should be bulletproof.")) + title = translation.add("industrial_glass", "Extra Hard Glass") { + russian("Дополнительно Прочное Стекло") + }, + description = translation.add("industrial_glass.desc", "Manual says it should be bulletproof.") { + russian("В инструкции указано что оно должно быть пуленепробиваемо.") + } ) .requirements(RequirementsStrategy.OR) .also { advancement -> @@ -239,8 +313,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(glass) .display( itemStack = ItemStack(MRegistry.INDUSTRIAL_GLASS.getItem(DyeColor.GREEN)), - title = TranslatableComponent(translation.add("industrial_glass2", "Glass-tacular Artist")), - description = TranslatableComponent(translation.add("industrial_glass2.desc", "Paint Industrial Glass all possible colors")), + title = translation.add("industrial_glass2", "Glass-Tacular Artist") { + russian("Стекло-Чаровательный Артист") + }, + description = translation.add("industrial_glass2.desc", "Paint Industrial Glass all possible colors") { + russian("Покрасьте Промышленное Стекло во все возможные цвета") + }, frameType = FrameType.GOAL ) .requirements(RequirementsStrategy.AND) @@ -253,8 +331,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(plate) .display( itemStack = ItemStack(MRegistry.CARGO_CRATES.item), - title = TranslatableComponent(translation.add("cargo_crate", "Sturdy Item Stash")), - description = TranslatableComponent(translation.add("cargo_crate.desc", "Cargo Crates, like Double Chest, but Single.")) + title = translation.add("cargo_crate", "Sturdy Item Stash") { + russian("Прочное Хранилище Предметов") + }, + description = translation.add("cargo_crate.desc", "Cargo Crates, like Double Chest, but Single") { + russian("Грузовые Ящики, будто Двойные Сундуки, но Одинарные.") + } ) .requirements(RequirementsStrategy.OR) .also { advancement -> @@ -266,8 +348,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(cargoCrate) .display( itemStack = ItemStack(MItems.CARGO_CRATE_MINECARTS[null]!!), - title = TranslatableComponent(translation.add("cargo_crate_minecart", "Crate On a Rail")), - description = TranslatableComponent(translation.add("cargo_crate_minecart.desc", "Drop a Cargo Crate onto Minecart and see how it goes")) + title = translation.add("cargo_crate_minecart", "Crate On a Rail") { + russian("Ящик на Рельсах") + }, + description = translation.add("cargo_crate_minecart.desc", "Drop a Cargo Crate onto Minecart and see how it goes") { + russian("Сбросьте Грузовой Ящик в Вагонетку и посмотрите что получится") + } ) .requirements(RequirementsStrategy.OR) .also { advancement -> @@ -279,8 +365,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(cargoCrateInMinecart) .display( itemStack = ItemStack(MItems.CARGO_CRATE_MINECARTS[DyeColor.GREEN]!!), - title = TranslatableComponent(translation.add("cargo_crate_minecart2", "A Motley Train")), - description = TranslatableComponent(translation.add("cargo_crate_minecart2.desc", "Have all color variants of Minecarts with Cargo Crates")), + title = translation.add("cargo_crate_minecart2", "A Motley Train") { + russian("Пёстрый Поезд") + }, + description = translation.add("cargo_crate_minecart2.desc", "Have all color variants of Minecarts with Cargo Crates") { + russian("Создайте все варианты покрасок Вагонеток с Грузовыми Ящиками") + }, frameType = FrameType.GOAL ) .requirements(RequirementsStrategy.AND) @@ -293,8 +383,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(cargoCrate) .display( itemStack = ItemStack(MRegistry.CARGO_CRATES.item), - title = TranslatableComponent(translation.add("cargo_crate2", "Colorful Warehouse")), - description = TranslatableComponent(translation.add("cargo_crate2.desc", "Craft all color variants of Cargo Crates")), + title = translation.add("cargo_crate2", "Colorful Warehouse") { + russian("Разноцветный Склад") + }, + description = translation.add("cargo_crate2.desc", "Craft all color variants of Cargo Crates") { + russian("Покрасьте Грузовые Ящики во все возможные цвета") + }, frameType = FrameType.GOAL ) .requirements(RequirementsStrategy.AND) @@ -307,8 +401,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(plate) .display( itemStack = ItemStack(MRegistry.TRITANIUM_BLOCK.item), - title = TranslatableComponent(translation.add("tritanium_block", "Cold, Impregnable Wall")), - description = TranslatableComponent(translation.add("tritanium_block.desc", "Coat stones in Tritanium Plates, a cheap yet incredibly sturdy material")) + title = translation.add("tritanium_block", "Cold, Impregnable Wall") { + russian("Холодная, Неприступная Стена") + }, + description = translation.add("tritanium_block.desc", "Coat stones in Tritanium, a cheap yet incredibly sturdy material") { + russian("Покройте булыжник в Тритане, дешёвый, но невероятно прочный материал") + } ) .requirements(RequirementsStrategy.OR) .also { advancement -> @@ -325,8 +423,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(tritaniumBlock) .display( itemStack = ItemStack(MItems.TRITANIUM_STRIPED_BLOCK), - title = TranslatableComponent(translation.add("striped_tritanium_block", "Old Fashion Color Touch")), - description = TranslatableComponent(translation.add("striped_tritanium_block.desc", "Pale Blue coat with Yellow stripe, I bet you know whose design is this")) + title = translation.add("striped_tritanium_block", "Old Fashion Color Touch") { + russian("Старомодная Цветовая Отделка") + }, + description = translation.add("striped_tritanium_block.desc", "Pale Blue coat with Yellow stripe, I bet you know whose design is this") { + russian("Бледно Синяя покраска с Жёлтой полоской, я готов поспорить вы знаете чей это дизайн") + } ) .requirements(RequirementsStrategy.OR) .addCriterion("has_item", criterion(MItems.TRITANIUM_STRIPED_BLOCK)) @@ -339,8 +441,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(tritaniumBlock) .display( itemStack = ItemStack(MRegistry.TRITANIUM_BLOCK.getItem(DyeColor.GREEN)), - title = TranslatableComponent(translation.add("tritanium_block2", "Colorful Fortress")), - description = TranslatableComponent(translation.add("tritanium_block2.desc", "Put some paint over Tritanium Block to make it look fabulous")) + title = translation.add("tritanium_block2", "Colorful Fortress") { + russian("Разноцветная Крепость") + }, + description = translation.add("tritanium_block2.desc", "Put some paint over Tritanium Block to make it look fabulous") { + russian("Покрасьте Тритановый Блок для придания ему сказочных оттенков") + } ) .requirements(RequirementsStrategy.OR) .also { advancement -> @@ -357,8 +463,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(colorTritaniumBlock) .display( itemStack = ItemStack(MRegistry.TRITANIUM_BLOCK.getItem(DyeColor.BLACK)), - title = TranslatableComponent(translation.add("tritanium_block3", "Paint Me A Castle")), - description = TranslatableComponent(translation.add("tritanium_block3.desc", "Craft all color variants of Tritanium Blocks")), + title = translation.add("tritanium_block3", "Paint Me A Castle") { + russian("Разукрась Мне Замок") + }, + description = translation.add("tritanium_block3.desc", "Craft all color variants of Tritanium Blocks") { + russian("Создайте все варианты покрасок Тритановых Блоков") + }, frameType = FrameType.GOAL ) .rewards(AdvancementRewards.Builder.loot(modLocation("tritanium_block3")).addExperience(100)) @@ -372,8 +482,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(colorfulTritaniumBlock) .display( itemStack = ItemStack(MRegistry.TRITANIUM_STRIPED_BLOCK.getItem(DyeColor.BLACK, DyeColor.WHITE)), - title = TranslatableComponent(translation.add("tritanium_block4", "All The Colors")), - description = TranslatableComponent(translation.add("tritanium_block4.desc", "Craft ALL color variants of Tritanium Blocks including striped ones")), + title = translation.add("tritanium_block4", "All The Colors") { + russian("Все Цвета Всё Сюда") + }, + description = translation.add("tritanium_block4.desc", "Craft ALL color variants of Tritanium Blocks including striped ones") { + russian("Создайте АБСОЛЮТНО ВСЕ варианты покрасок Тритановых Блоков, включая с полосками") + }, frameType = FrameType.CHALLENGE ) .rewards(AdvancementRewards.Builder.loot(modLocation("tritanium_block4")).addExperience(400)) @@ -389,8 +503,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(root) .display( itemStack = ItemStack(MItems.PILL_ANDROID), - title = TranslatableComponent(translation.add("pill", "Side Colored Mystery")), - description = TranslatableComponent(translation.add("pill.desc", "Find some of those mysterious pills. Consult with Cleric before trying to ingest them.")), + title = translation.add("pill", "Side Colored Mystery") { + russian("Мистика с Цветными Краями") + }, + description = translation.add("pill.desc", "Find some of those mysterious pills. Consult with Cleric before trying to ingest them.") { + russian("Найдите одну из этих ваших мистических пилюль. Проконсультируйтесь с Клериком перед употреблением.") + }, ) .requirements(RequirementsStrategy.OR) .addCriterion("pill1", criterion(MItems.PILL_ANDROID)) @@ -403,8 +521,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .parent(pill) .display( itemStack = ItemStack(MItems.PILL_HEAL), - title = TranslatableComponent(translation.add("all_pills", "Take Your Meds")), - description = TranslatableComponent(translation.add("all_pills.desc", "Find all possible pill types")), + title = translation.add("all_pills", "Take Your Meds") { + russian("Пей Таблетки") + }, + description = translation.add("all_pills.desc", "Find all possible pill types") { + russian("Найдите все возможные варианты пилюль") + }, frameType = FrameType.CHALLENGE, hidden = true ) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/MatteryLanguageProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/MatteryLanguageProvider.kt index f4f28c71d..673e1ee12 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/MatteryLanguageProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/MatteryLanguageProvider.kt @@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableList import com.google.common.collect.ImmutableMap import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap import net.minecraft.data.DataGenerator +import net.minecraft.network.chat.Component import net.minecraft.network.chat.MutableComponent import net.minecraft.network.chat.contents.TranslatableContents import net.minecraft.sounds.SoundEvent @@ -18,6 +19,7 @@ import net.minecraftforge.common.data.LanguageProvider import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.android.AndroidFeatureType import ru.dbotthepony.mc.otm.android.AndroidResearchType +import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.registry.objects.ColoredDecorativeBlock private fun researchString(key: AndroidResearchType): String { @@ -47,6 +49,30 @@ class MatteryLanguageProvider(private val gen: DataGenerator) { } } + inner class MultiBuilder(path: String) { + val path = "$path." + + constructor(vararg path: String) : this(path.joinToString(".")) + constructor(path: Collection) : this(path.joinToString(".")) + + inner class Path(path: String) { + val fullPath = this@MultiBuilder.path + path + fun english(value: String) = english.add(fullPath, value) + fun russian(value: String) = russian.add(fullPath, value) + } + + inline fun add(key: String, configurator: Path.() -> Unit): Component { + return TranslatableComponent(Path(key).also(configurator).fullPath) + } + + inline fun add(key: String, english: String, configurator: Path.() -> Unit = {}): Component { + return add(key) { + english(english) + configurator.invoke(this) + } + } + } + @Suppress("unused") inner class Builder(language: String) { val slave: LanguageProvider by lazy { slaves.computeIfAbsent(language, ::Slave) } @@ -382,7 +408,7 @@ class MatteryLanguageProvider(private val gen: DataGenerator) { "Black", ) - val russianColors = Colors("en_us", + val russianColors = Colors("ru_ru", "Белый", "Оранжевый", "Маджентовый", diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index ea4b0e97c..2d1ee7ae1 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -32,8 +32,8 @@ private fun decoratives(provider: MatteryLanguageProvider) { add(MRegistry.DECORATIVE_CRATE, "%s Блок Контейнера") } - with (provider.english) { - for ((color, name) in provider.englishColors.dyeClassMapped) { + with (provider.russian) { + for ((color, name) in provider.russianColors.dyeClassMapped) { add(MItems.CARGO_CRATE_MINECARTS[color]!!, "Вагонетка с $name Грузовым Ящиком") add(MEntityTypes.CARGO_CRATE_MINECARTS[color]!!, "Вагонетка с $name Грузовым Ящиком") @@ -57,7 +57,7 @@ private fun decoratives(provider: MatteryLanguageProvider) { add(MRegistry.TRITANIUM_PRESSURE_PLATE.block, "description1", HIGH_BLAST_RESISTANCE) } - with(provider.english) { + with(provider.russian) { add(MItems.CARGO_CRATE_MINECARTS[null]!!, "Вагонетка с Грузовым Ящиком") add(MEntityTypes.CARGO_CRATE_MINECARTS[null]!!, "Вагонетка с Грузовым Ящиком") @@ -78,8 +78,8 @@ private fun decoratives(provider: MatteryLanguageProvider) { for ((block, colors) in MRegistry.TRITANIUM_STRIPED_BLOCK.blocksWithColor) { val (base, stripe) = colors - val baseName = provider.englishColors.dyeClassMapped[base]!! - val stripeName = provider.englishColors.dyeClassMapped[stripe]!! + val baseName = provider.russianColors.dyeClassMapped[base]!! + val stripeName = provider.russianColors.dyeClassMapped[stripe]!! add(block, "$baseName-Окрашенный $stripeName-Ополосаченный Тритановый Блок") } @@ -87,8 +87,8 @@ private fun decoratives(provider: MatteryLanguageProvider) { for ((block, colors) in MRegistry.TRITANIUM_STRIPED_STAIRS.blocksWithColor) { val (base, stripe) = colors - val baseName = provider.englishColors.dyeClassMapped[base]!! - val stripeName = provider.englishColors.dyeClassMapped[stripe]!! + val baseName = provider.russianColors.dyeClassMapped[base]!! + val stripeName = provider.russianColors.dyeClassMapped[stripe]!! add(block, "$baseName-Окрашенные $stripeName-Ополосаченные Тритановые Ступеньки") } @@ -96,8 +96,8 @@ private fun decoratives(provider: MatteryLanguageProvider) { for ((block, colors) in MRegistry.TRITANIUM_STRIPED_SLAB.blocksWithColor) { val (base, stripe) = colors - val baseName = provider.englishColors.dyeClassMapped[base]!! - val stripeName = provider.englishColors.dyeClassMapped[stripe]!! + val baseName = provider.russianColors.dyeClassMapped[base]!! + val stripeName = provider.russianColors.dyeClassMapped[stripe]!! add(block, "$baseName-Окрашенная $stripeName-Ополосаченная Тритановая Плита") } @@ -105,8 +105,8 @@ private fun decoratives(provider: MatteryLanguageProvider) { for ((block, colors) in MRegistry.TRITANIUM_STRIPED_WALL.blocksWithColor) { val (base, stripe) = colors - val baseName = provider.englishColors.dyeClassMapped[base]!! - val stripeName = provider.englishColors.dyeClassMapped[stripe]!! + val baseName = provider.russianColors.dyeClassMapped[base]!! + val stripeName = provider.russianColors.dyeClassMapped[stripe]!! add(block, "$baseName-Окрашенная $stripeName-Ополосаченная Тритановая Ограда") } @@ -124,7 +124,7 @@ private fun sounds(provider: MatteryLanguageProvider) { } private fun misc(provider: MatteryLanguageProvider) { - with(provider.english) { + with(provider.russian) { gui("ticks", "Тиков") gui("power_cost_per_use", "Энергии на операцию: %s") @@ -466,7 +466,7 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.BATTERY_BASIC, "Простой Аккумулятор") add(MItems.BATTERY_NORMAL, "Аккумулятор") add(MItems.BATTERY_DENSE, "Плотный Аккумулятор") - add(MItems.BATTERY_CAPACITOR, "Аккумулятор-Накопитель") + add(MItems.BATTERY_CAPACITOR, "Аккумулятор-Конденсатор") add(MItems.BATTERY_CREATIVE, "Творческий Аккумулятор") add(MItems.QUANTUM_BATTERY, "Квантовый Аккумулятор") @@ -521,10 +521,10 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.MATTER_DUST, "desc2", "Закиньте в Материальный Переработчик для переработки обратно в чистую материю!") add(MItems.MATTER_DUST, "desc3", "Не нюхать, не кидать на других и не сыпать на пончики") - add(MItems.PILL_ANDROID, "Таблетка Андроида") - add(MItems.PILL_HUMANE, "Таблетка Человечности") - add(MItems.PILL_OBLIVION, "Таблетка Сброса Андроида до Заводских Настроек") - add(MItems.PILL_HEAL, "Медицинская Таблетка") + add(MItems.PILL_ANDROID, "Пилюля Андроида") + add(MItems.PILL_HUMANE, "Пилюля Человечности") + add(MItems.PILL_OBLIVION, "Пилюля Сброса Андроида до Заводских Настроек") + add(MItems.PILL_HEAL, "Медицинская Пилюля") add(MItems.MATTER_CAPACITOR_PARTS, "Части Накопителя Материи") add(MItems.MATTER_CAPACITOR_BASIC, "Простой Накопитель Материи") From 01caf1d85bb6a78e613ff14e1d46d6253c593b23 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 23 Jan 2023 14:59:35 +0700 Subject: [PATCH 0070/1199] Fix tritanium pressure plates being missing from creative menu --- src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt index ada0a79a8..ea4040cb5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt @@ -105,6 +105,7 @@ internal fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { base(MItems.TRITANIUM_DOOR) base(MItems.TRITANIUM_TRAPDOOR) + accept(MRegistry.TRITANIUM_PRESSURE_PLATE.item) accept(MItems.MATTER_DUST) @@ -168,6 +169,7 @@ internal fun addDecorativeTabItems(consumer: CreativeModeTab.Output) { colored(MItems.TRITANIUM_DOOR) colored(MItems.TRITANIUM_TRAPDOOR) + accept(MRegistry.TRITANIUM_PRESSURE_PLATE.items.values) colored(MRegistry.CARGO_CRATES.items) From 1d0ab8170a4f2a70009a68e2d69327591943f6d4 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 23 Jan 2023 15:00:28 +0700 Subject: [PATCH 0071/1199] =?UTF-8?q?Fix=20=D0=9F=20not=20being=20capital?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 2d1ee7ae1..a4ab753ea 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -37,7 +37,7 @@ private fun decoratives(provider: MatteryLanguageProvider) { add(MItems.CARGO_CRATE_MINECARTS[color]!!, "Вагонетка с $name Грузовым Ящиком") add(MEntityTypes.CARGO_CRATE_MINECARTS[color]!!, "Вагонетка с $name Грузовым Ящиком") - add(MRegistry.TRITANIUM_PRESSURE_PLATE.getBlock(color), "$name Тритановая Нажимная пластина") + add(MRegistry.TRITANIUM_PRESSURE_PLATE.getBlock(color), "$name Тритановая Нажимная Пластина") add(MRegistry.TRITANIUM_PRESSURE_PLATE.getBlock(color), "description0", "Активируется только при наступлении игрока на неё") add(MRegistry.TRITANIUM_PRESSURE_PLATE.getBlock(color), "description1", HIGH_BLAST_RESISTANCE) @@ -52,7 +52,7 @@ private fun decoratives(provider: MatteryLanguageProvider) { add(MBlocks.TRITANIUM_TRAPDOOR[color]!!, "description2", "Данный вариант выкрашен в $name") } - add(MRegistry.TRITANIUM_PRESSURE_PLATE.block, "Тритановая Нажимная пластина") + add(MRegistry.TRITANIUM_PRESSURE_PLATE.block, "Тритановая Нажимная Пластина") add(MRegistry.TRITANIUM_PRESSURE_PLATE.block, "description0", "Активируется только при наступлении игрока на неё") add(MRegistry.TRITANIUM_PRESSURE_PLATE.block, "description1", HIGH_BLAST_RESISTANCE) } From 7dd709938f30f2011fbae33d4de18a06041148ae Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 23 Jan 2023 17:52:06 +0700 Subject: [PATCH 0072/1199] More advancement russian locale, english locale adjustments --- .../advancements/AndroidAdvancementsData.kt | 178 +++++++++++++----- .../advancements/MachineAdvancementsData.kt | 83 ++++++-- .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 5 + 3 files changed, 201 insertions(+), 65 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt index 8103ac23a..c5250156c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt @@ -38,13 +38,17 @@ import ru.dbotthepony.mc.otm.triggers.ShockwaveTrigger import java.util.function.Consumer fun addAndroidAdvancements(serializer: Consumer, existingFileHelper: ExistingFileHelper, lang: MatteryLanguageProvider) { - val translation = lang.english.Prepended("otm.advancements.android") + val translation = lang.MultiBuilder("otm.advancements.android") val root = AdvancementBuilder() .display( itemStack = ItemStack(MItems.PILL_ANDROID), - title = TranslatableComponent(translation.add("root", "Androids and Humans")), - description = TranslatableComponent(translation.add("root.desc", "Can you make out who is cruel machine and who can love?")), + title = translation.add("root", "Androids and Humans") { + russian("Андроиды и Люди") + }, + description = translation.add("root.desc", "Can you make out who is cruel machine and who care about others?") { + russian("Сможете ли вы отличить бездушную машину от того, кому другие не безразличны?") + }, showToast = false, announceChat = false, background = modLocation("textures/block/decorative/metal_beam_top.png") @@ -56,8 +60,12 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .parent(root) .display( itemStack = ItemStack(MItems.ZPM_BATTERY), - title = TranslatableComponent(translation.add("zpm", "Fully Autonomous")), - description = TranslatableComponent(translation.add("zpm.desc", "Use Zero Point Module as internal battery power source. Only time is your enemy now")), + title = translation.add("zpm", "Fully Autonomous") { + russian("Полностью Автономный") + }, + description = translation.add("zpm.desc", "Use Zero Point Module as internal battery power source. Only time is your enemy now") { + russian("Используйте Модуль Нулевой Точки как внутренний источник питания. Теперь только время будет вашим злейшим врагом") + }, hidden = true, frameType = FrameType.CHALLENGE ) @@ -68,8 +76,12 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .parent(root) .display( itemStack = ItemStack(MItems.QUANTUM_BATTERY), - title = TranslatableComponent(translation.add("quantum_battery", "Wireless Charged")), - description = TranslatableComponent(translation.add("quantum_battery.desc", "Use Quantum Battery as internal battery power source, might as well have Fission Reactor charge other side of the link")), + title = translation.add("quantum_battery", "Wireless Charged") { + russian("Беспроводная Зарядка") + }, + description = translation.add("quantum_battery.desc", "Use Quantum Battery as internal battery power source, might as well have Fission Reactor charge other side of the link") { + russian("Используйте Квантовый Аккумулятор как внутренний источник питания, можно даже подключить другой конец к Реактору Распада") + }, hidden = true, frameType = FrameType.GOAL ) @@ -82,8 +94,12 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .parent(root) .display( itemStack = ItemStack(MItems.PILL_ANDROID), - title = TranslatableComponent(translation.add("normal", "Last Sweet Dreams")), - description = TranslatableComponent(translation.add("normal.desc", "Become an Android in your dreams, a soulless machine... Or is it?")), + title = translation.add("normal", "Last Sweet Dreams") { + russian("Последние Сновидения") + }, + description = translation.add("normal.desc", "Become an Android in your dreams, a soulless machine... Or is it?") { + russian("Превратитесь в Андроида во сне, в бездушную машину... Или нет?") + }, hidden = true, ) .addCriterion("became_android", BecomeAndroidSleepTrigger.Instance) @@ -93,8 +109,12 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .parent(root) .display( itemStack = ItemStack(MItems.PILL_ANDROID), - title = TranslatableComponent(translation.add("death", "The Old Way")), - description = TranslatableComponent(translation.add("death.desc", "Become an Android in event of death, veteran's favorite")), + title = translation.add("death", "The Old Way") { + russian("Изготовленный по Старинке") + }, + description = translation.add("death.desc", "In event of death, become an Android; Veteran's favorite") { + russian("Будучи умерев, станьте Андроидом; Ветераны оценят") + }, hidden = true, ) .addCriterion("became_android", BecomeAndroidDeathTrigger.Instance) @@ -104,8 +124,12 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .parent(root) .display( itemStack = ItemStack(MItems.PILL_HUMANE), - title = TranslatableComponent(translation.add("unandroid", "Feel Humane Again")), - description = TranslatableComponent(translation.add("unandroid.desc", "Become fleshy after being a machine, yet something is still missing that you had before...")), + title = translation.add("unandroid", "Feel Humane Again") { + russian("Вкусить Человечность Вновь") + }, + description = translation.add("unandroid.desc", "Become fleshy after being a machine, yet something is still missing that you had before...") { + russian("Вновь обретите плоть после своей жизни как набор гаек и болтов, но вот чего-то всё равно не хватает, что было при вас с самого начала...") + }, hidden = true, frameType = FrameType.GOAL ) @@ -116,8 +140,12 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .parent(root) .display( itemStack = ItemStack(Items.PHANTOM_MEMBRANE), - title = TranslatableComponent(translation.add("phantom_spawn_denied", "Insomnia Immune")), - description = TranslatableComponent(translation.add("phantom_spawn_denied.desc", "Have Phantoms not come after you because you are not someone who needs to sleep")), + title = translation.add("phantom_spawn_denied", "Insomnia Immune") { + russian("Пере-Бессоница") + }, + description = translation.add("phantom_spawn_denied.desc", "Have Phantoms not come after you because you are not someone who needs to sleep") { + russian("Не привлеките внимание Фантомов, так как вы не тот, кому надо спать") + }, hidden = true ) .addCriterion("phantom_spawn_denied", PhantomSpawnDeniedTrigger.Instance) @@ -127,8 +155,12 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .parent(phantoms) .display( itemStack = ItemStack(MItems.PHANTOM_ATTRACTOR), - title = TranslatableComponent(translation.add("phantom_attractor", "Eversleeping Decoy")), - description = TranslatableComponent(translation.add("phantom_attractor.desc", "Put together a Phantom Attractor, to be able to fight Phantoms as Android again")), + title = translation.add("phantom_attractor", "Eversleeping Decoy") { + russian("Вечноспящий Декой") + }, + description = translation.add("phantom_attractor.desc", "Put together a Phantom Attractor, to be able to fight Phantoms as Android again") { + russian("Создайте Приманщик Фантомов, для привлечения Фантомов вновь, будучи Андроидом") + }, ) .addCriterion("has_item", criterion(MItems.PHANTOM_ATTRACTOR)) .save(serializer, modLocation("regular/phantom_attractor"), existingFileHelper) @@ -137,8 +169,12 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .parent(attractor) .display( itemStack = ItemStack(MItems.PHANTOM_ATTRACTOR), - title = TranslatableComponent(translation.add("phantom_attractor_research", "Deception of Phantoms")), - description = TranslatableComponent(translation.add("phantom_attractor_research.desc", "Research into how to attract Phantoms the same way as the ones who need to sleep")), + title = translation.add("phantom_attractor_research", "Deception of Phantoms") { + russian("Обман Фантомов") + }, + description = translation.add("phantom_attractor_research.desc", "Research into how to attract Phantoms the same way as the ones who need to sleep") { + russian("Исследуйте привлечение Фантомов, чтоб привлекать их так же, как те, кому нужно спать") + }, ) .addCriterion("researched", AndroidResearchTrigger.Instance(modLocation(MNames.PHANTOM_ATTRACTOR))) .save(serializer, modLocation("regular/phantom_attractor_research"), existingFileHelper) @@ -147,8 +183,12 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .parent(root) .display( itemStack = ItemStack(MItems.ANDROID_STATION), - title = TranslatableComponent(translation.add("research_anything", "New Trick")), - description = TranslatableComponent(translation.add("research_anything.desc", "Research anything as Android")), + title = translation.add("research_anything", "New Trick") { + russian("Новый Фокус") + }, + description = translation.add("research_anything.desc", "Research anything as Android") { + russian("Исследуйте что либо за Андроида") + }, ) .addCriterion("research_anything", AndroidResearchTrigger.Instance(null)) .save(serializer, modLocation("android/research_anything"), existingFileHelper) @@ -157,8 +197,12 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .parent(researchAnything) .display( itemStack = ItemStack(Items.WATER_BUCKET), - title = TranslatableComponent(translation.add("air_bags", "Patching Up Wooden Vessel")), - description = TranslatableComponent(translation.add("air_bags.desc", "Research Air Bags as Android, to float in water")), + title = translation.add("air_bags", "Patching Up Wooden Vessel") { + russian("В Бочку - Затычку") + }, + description = translation.add("air_bags.desc", "Research Air Bags as Android, to float in water") { + russian("Исследуйте Воздушные Мешки, дабы быть вновь поплавком в воде") + }, ) .addCriterion("air_bags", AndroidResearchTrigger.Instance(modLocation(MNames.AIR_BAGS))) .save(serializer, modLocation("android/research_air_bags"), existingFileHelper) @@ -167,8 +211,12 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .parent(researchAnything) .display( itemStack = ItemStack(Items.ENDER_EYE), - title = TranslatableComponent(translation.add("night_vision", "Second Pair of Eyes")), - description = TranslatableComponent(translation.add("night_vision.desc", "Research Night Vision as Android, to see in the dark")), + title = translation.add("night_vision", "Second Pair of Eyes") { + russian("Вторая Пара Глаз") + }, + description = translation.add("night_vision.desc", "Research Night Vision as Android, to see in the dark") { + russian("Исследуйте Ночное Зрение за Андроида, дабы видеть во тьме") + }, ) .addCriterion("night_vision", AndroidResearchTrigger.Instance(modLocation(MNames.NIGHT_VISION))) .save(serializer, modLocation("android/research_night_vision"), existingFileHelper) @@ -177,8 +225,12 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .parent(researchAnything) .display( itemStack = ItemStack(MItems.MATTER_TRANSFORM_MATRIX), - title = TranslatableComponent(translation.add("nanobots", "Nanomachines, Son!")), - description = TranslatableComponent(translation.add("nanobots.desc", "Research Nanobots as Android, to unlock potent research that come after it")), + title = translation.add("nanobots", "Nanomachines, Son!") { + russian("Наномашины, Дитя!") + }, + description = translation.add("nanobots.desc", "Research Nanobots as Android, to unlock potent research that come after it") { + russian("Исследуйте Наномашины за Андроида, для разблокировки очень больших возможностей") + }, hidden = true ) .addCriterion("nanobots", AndroidResearchTrigger.Instance(modLocation(MNames.NANOBOTS))) @@ -188,8 +240,12 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .parent(nanobots) .display( itemStack = ItemStack(Items.SHIELD), - title = TranslatableComponent(translation.add("nanobots_armor_deflect", "Like a Concrete Wall")), - description = TranslatableComponent(translation.add("nanobots_armor_deflect.desc", "Have Nanobots absorb more than 5 hears of damage while you are left still functioning")), + title = translation.add("nanobots_armor_deflect", "Like a Concrete Wall") { + russian("Как за Каменной Стеной") + }, + description = translation.add("nanobots_armor_deflect.desc", "Have Nanobots absorb more than 5 hears of damage while you are left still functioning") { + russian("Дайте Наноботам поглотить 5 сердец урона, не отключившись насовсем") + }, hidden = true, frameType = FrameType.GOAL ) @@ -200,8 +256,12 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .parent(shielding) .display( itemStack = ItemStack(Items.SHIELD), - title = TranslatableComponent(translation.add("nanobots_armor_deflect2", "Unstoppable Force vs Immovable Object")), - description = TranslatableComponent(translation.add("nanobots_armor_deflect2.desc", "Have Nanobots absorb more than 10 hears of damage while you are left still functioning")), + title = translation.add("nanobots_armor_deflect2", "Unstoppable Force vs Immovable Object") { + russian("Неостановимая Сила против Недвижимого Объекта") + }, + description = translation.add("nanobots_armor_deflect2.desc", "Have Nanobots absorb more than 10 hears of damage while you are left still functioning") { + russian("Дайте Наноботам поглотить 10 сердец урона, не отключившись насовсем") + }, hidden = true, frameType = FrameType.CHALLENGE ) @@ -212,8 +272,12 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .parent(researchAnything) .display( itemStack = ItemStack(Items.FEATHER), - title = TranslatableComponent(translation.add("fall_dampeners_save", "Lucky Landing")), - description = TranslatableComponent(translation.add("fall_dampeners_save.desc", "Survive fall that would have otherwise be fatal without Fall Dampeners research")), + title = translation.add("fall_dampeners_save", "Lucky Landing") { + russian("Удачное Приземление") + }, + description = translation.add("fall_dampeners_save.desc", "Survive fall that would have otherwise be fatal without Fall Dampeners research") { + russian("Выживите после падения, которое было бы фатальным без исследования Смягчителей Падения") + }, frameType = FrameType.GOAL ) .addCriterion("saved", FallDampenersSaveTrigger.Instance) @@ -223,8 +287,12 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .parent(researchAnything) .display( itemStack = ItemStack(Items.SKELETON_SKULL), - title = TranslatableComponent(translation.add("ender_teleport_fall_death", "Navigation Error")), - description = TranslatableComponent(translation.add("ender_teleport_fall_death.desc", "Fall to your death moments after Teleporting")), + title = translation.add("ender_teleport_fall_death", "Navigation Error") { + russian("Ошибка Навигации") + }, + description = translation.add("ender_teleport_fall_death.desc", "Fall to your demise moments after Teleporting as Android") { + russian("Разбейтесь насмерть через мгновения после телепортации за Андроида") + }, frameType = FrameType.GOAL, hidden = true ) @@ -235,8 +303,12 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .parent(nanobots) .display( itemStack = ItemStack(Items.GOLDEN_APPLE), - title = TranslatableComponent(translation.add("regen", "Field Repair Done Easy")), - description = TranslatableComponent(translation.add("regen.desc", "Research Nanobots Regeneration as Android")), + title = translation.add("regen", "Field Repair Done Easy") { + russian("Починка на Ходу - Легко") + }, + description = translation.add("regen.desc", "Research Nanobots Regeneration as Android") { + russian("Исследуйте Регенерацию Наноботов за Андроида") + }, ) .addCriterion("regen0", AndroidResearchTrigger.Instance(modLocation(MNames.NANOBOTS_REGENERATION_1))) .save(serializer, modLocation("android/regen"), existingFileHelper) @@ -245,8 +317,12 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .parent(regen) .display( itemStack = ItemStack(Items.ENCHANTED_GOLDEN_APPLE), - title = TranslatableComponent(translation.add("regen_all", "Field Repair Done Effortless")), - description = TranslatableComponent(translation.add("regen_all.desc", "Max out Nanobots Regeneration research")), + title = translation.add("regen_all", "Field Repair Done Effortless") { + russian("Починка на Ходу - Без Усилий") + }, + description = translation.add("regen_all.desc", "Max out Nanobots Regeneration research") { + russian("Полностью исследуйте Регенерацию Наноботов за Андроида") + }, frameType = FrameType.GOAL, ) .addCriterion("regen0", AndroidResearchTrigger.Instance(modLocation(MNames.NANOBOTS_REGENERATION_1))) @@ -259,8 +335,12 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .parent(researchAnything) .display( itemStack = ItemStack(MItems.ANDROID_STATION), - title = TranslatableComponent(translation.add("research_all", "Mecha-agnomination")), - description = TranslatableComponent(translation.add("research_all.desc", "Research everything (that don't block any other research)")), + title = translation.add("research_all", "Mecha-Agnomination") { + russian("Меха-Зумие") + }, + description = translation.add("research_all.desc", "Research everything as Android (that don't block or get blocked by any other research)") { + russian("Исследуйте все технологии за Андроида (которые не блокируют и не блокируются другими технологиями)") + }, frameType = FrameType.CHALLENGE ) .rewards(AdvancementRewards.Builder.experience(400).addLootTable(modLocation("research_all_android"))) @@ -277,8 +357,12 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .parent(researchAnything) .display( itemStack = ItemStack(Items.PISTON), - title = TranslatableComponent(translation.add("shockwave", "Supersonic Landing")), - description = TranslatableComponent(translation.add("shockwave.desc", "Perform a Shockwave upon landing")), + title = translation.add("shockwave", "Supersonic Landing") { + russian("Сверхзвуковое Приземление") + }, + description = translation.add("shockwave.desc", "Make a Shockwave upon landing") { + russian("Вызовите Ударную Волну при приземлении") + }, ) .addCriterion("shockwave", ShockwaveTrigger.Instance) .save(serializer, modLocation("android/shockwave"), existingFileHelper) @@ -287,8 +371,12 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .parent(shockwave) .display( itemStack = ItemStack(Items.WARDEN_SPAWN_EGG), - title = TranslatableComponent(translation.add("shockwave_warden", "Music To Their Ears")), - description = TranslatableComponent(translation.add("shockwave_warden.desc", "Hurt Warden using Shockwave ability")), + title = translation.add("shockwave_warden", "Music to their Ears") { + russian("Музыка для их Ушей") + }, + description = translation.add("shockwave_warden.desc", "Hurt Warden using Shockwave ability") { + russian("Нанесите Хранителю урон используя Ударную Волну") + }, frameType = FrameType.GOAL ) .addCriterion("shockwave_warden", ShockwaveDamageMobTrigger.Instance(EntityPredicate.Builder.entity().of(EntityType.WARDEN).build().wrap())) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt index 6cb958c8b..2dcb1d3be 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt @@ -2,10 +2,12 @@ package ru.dbotthepony.mc.otm.datagen.advancements import net.minecraft.advancements.Advancement import net.minecraft.advancements.RequirementsStrategy +import net.minecraft.network.chat.contents.TranslatableContents import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraftforge.common.data.ExistingFileHelper import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.key import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.datagen.lang.MatteryLanguageProvider import ru.dbotthepony.mc.otm.datagen.modLocation @@ -13,17 +15,28 @@ import ru.dbotthepony.mc.otm.registry.MItemTags import ru.dbotthepony.mc.otm.registry.MItems import java.util.function.Consumer -private data class CraftEntry(val item: Item, val englishName: String, val englishSuffix: String? = null) +private data class CraftEntry( + val item: Item, + val englishName: String, + val englishSuffix: String? = null, + + val russianName: String? = null, + val russianSuffix: String? = null, +) fun addMachineAdvancements(serializer: Consumer, existingFileHelper: ExistingFileHelper, lang: MatteryLanguageProvider) { - val translation = lang.english.Prepended("otm.advancements.machine") + val translation = lang.MultiBuilder("otm.advancements.machine") val root = AdvancementBuilder() .requirements(RequirementsStrategy.OR) .display( itemStack = ItemStack(MItems.CHEMICAL_GENERATOR), - title = TranslatableComponent(translation.add("root", "Tritanium Empowered Machinery")), - description = TranslatableComponent(translation.add("root.desc", "Do not drop in anything if you want the latter preserved intact")), + title = translation.add("root", "Tritanium Empowered Machinery") { + russian("Тританово Запитанные Механизмы") + }, + description = translation.add("root.desc", "Do not drop in anything if you want the latter preserved intact") { + russian("Не роняйте ничего внутрь если хотите чтоб последнее осталось таким, какое оно есть") + }, showToast = false, announceChat = false, background = modLocation("textures/block/decorative/floor_tiles_gray.png") @@ -37,8 +50,12 @@ fun addMachineAdvancements(serializer: Consumer, existingFileHelper .parent(root) .display( itemStack = ItemStack(MItems.CHEMICAL_GENERATOR), - title = TranslatableComponent(translation.add("chemical_generator", "Burning the Organics")), - description = TranslatableComponent(translation.add("chemical_generator.desc", "Craft a Chemical Generator, better to put it outside")), + title = translation.add("chemical_generator", "Burning the Organics") { + russian("Сжигание Органики") + }, + description = translation.add("chemical_generator.desc", "Craft a Chemical Generator, better to put it outside") { + russian("Создайте Химический Генератор. Лучше установить его снаружи") + }, ) .addCriterion("has_machine", criterion(MItems.CHEMICAL_GENERATOR)) .save(serializer, modLocation("machines/chemical_generator"), existingFileHelper) @@ -47,24 +64,38 @@ fun addMachineAdvancements(serializer: Consumer, existingFileHelper .parent(chem) .display( itemStack = ItemStack(MItems.PLATE_PRESS), - title = TranslatableComponent(translation.add("plate_press", "Bending the Material")), - description = TranslatableComponent(translation.add("plate_press.desc", "Craft a Plate Press, avoid having limbs inside during operation")), + title = translation.add("plate_press", "Bending the Material") { + russian("Раскатка Металла") + }, + description = translation.add("plate_press.desc", "Craft a Plate Press, avoid having limbs inside at all times") { + russian("Создайте Пресс Пластин, не суйте свои или чужие конечности внутрь") + }, ) .addCriterion("has_machine", criterion(MItems.PLATE_PRESS)) .save(serializer, modLocation("machines/plate_press"), existingFileHelper) val entries = listOf( - CraftEntry(MItems.MATTER_SCANNER, "Scanning Things that Matter"), - CraftEntry(MItems.PATTERN_STORAGE, "Digital Knowledge Library"), - CraftEntry(MItems.MATTER_DECOMPOSER, "Decaying the Atoms", "Keep your limbs outside of the working chamber at all times"), - CraftEntry(MItems.MATTER_PANEL, "Indexing the Library"), - CraftEntry(MItems.MATTER_REPLICATOR, "Local Bakery", "Now let's bake some perfect bread"), - CraftEntry(MItems.MATTER_BOTTLER, "Transfusing Pure Matter", "For those who loved to play with water in their childhood"), - CraftEntry(MItems.MATTER_RECYCLER, "Refine and Redefine", "This is what waste recycling should look like"), - CraftEntry(MItems.MATTER_CAPACITOR_BANK, "Modular Matter Tank"), + CraftEntry(MItems.MATTER_SCANNER, "Scanning Things that Matter", + russianName = "Сканируем Вещи которые Материальны"), + CraftEntry(MItems.PATTERN_STORAGE, "Digital Knowledge Library", + russianName = "Цифровая Библиотека Знаний"), + CraftEntry(MItems.MATTER_DECOMPOSER, "Decaying the Atoms", "Keep your limbs outside of the working chamber at all times", + russianName = "Разлагаем Атомы", russianSuffix = "Во всех ситуациях держите свои конечности вне рабочей камеры"), + CraftEntry(MItems.MATTER_PANEL, "Indexing the Library", + russianName = "Индексируем Библиотеку"), + CraftEntry(MItems.MATTER_REPLICATOR, "Local Bakery", "Now let's bake some perfect bread", + russianName = "Местная Выпечка", russianSuffix = "А теперь давайте выпечем немного идеального хлеба"), + CraftEntry(MItems.MATTER_BOTTLER, "Transfusing Pure Matter", "For those who loved to play with water in their childhood", + russianName = "Переливаем Чистую Материю", russianSuffix = "Для тех, кто любил играться в воде в детстве"), + CraftEntry(MItems.MATTER_RECYCLER, "Refine and Redefine", "This is what waste recycling should look like", + russianName = "Переработка и Перегонка", russianSuffix = "Вот он, пик переработки отходов"), + CraftEntry(MItems.MATTER_CAPACITOR_BANK, "Modular Matter Tank", + russianName = "Модульный Бак Материи"), - CraftEntry(MItems.ENERGY_COUNTER, "Visualize Power Burn"), - CraftEntry(MItems.BATTERY_BANK, "Batteries Not Included", "By all means avoid the urge to hammer incompatible batteries into the power bus."), + CraftEntry(MItems.ENERGY_COUNTER, "Visualize Power Burn", + russianName = "Визуализация Сжигания Энергии"), + CraftEntry(MItems.BATTERY_BANK, "Batteries Not Included", "By all means avoid the urge to hammer incompatible batteries into the power bus.", + russianName = "Батарейки в Комплект не Входят", russianSuffix = "Пожалуйста, воздержитесь от вбивания кувалдой несовместимых батарей в энергетическую шину."), ) val built = mutableMapOf() @@ -72,12 +103,24 @@ fun addMachineAdvancements(serializer: Consumer, existingFileHelper for (entry in entries) { val path = entry.item.registryName!!.path + val translated = translation.add("$path.desc", "Craft a %s%s") { + russian("Создайте %s%s") + } + + val translatedSuffix = translation.add("$path.suffix", if (entry.englishSuffix != null) ". " + entry.englishSuffix else "") { + russian(if (entry.russianSuffix != null) ". " + entry.russianSuffix else "") + } + built[entry.item] = AdvancementBuilder() .parent(press) .display( itemStack = ItemStack(entry.item), - title = TranslatableComponent(translation.add(path, entry.englishName)), - description = TranslatableComponent(translation.add("$path.desc", "Craft a %s%s"), entry.item.description, if (entry.englishSuffix != null) ". " + entry.englishSuffix else ""), + title = translation.add(path, entry.englishName) { + if (entry.russianName != null) { + russian(entry.russianName) + } + }, + description = TranslatableComponent(translated.contents.key, entry.item.description, translatedSuffix), ) .addCriterion("has_machine", criterion(entry.item)) .save(serializer, modLocation("machines/$path"), existingFileHelper) 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 ace708971..68b54d5f7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -10,6 +10,8 @@ import com.google.gson.JsonPrimitive import net.minecraft.core.BlockPos import net.minecraft.nbt.CompoundTag import net.minecraft.network.FriendlyByteBuf +import net.minecraft.network.chat.ComponentContents +import net.minecraft.network.chat.contents.TranslatableContents import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.Entity import net.minecraft.world.item.Item @@ -248,3 +250,6 @@ inline fun MutableList>.forValidRefs(fn: (T) -> Unit) { } } } + +val ComponentContents.key: String + get() = (this as? TranslatableContents ?: throw ClassCastException("$this is not a TranslatableContents"))?.key From b7a7a5e5d856c0eea9dab9896f3476b72c1f12c3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 23 Jan 2023 18:41:16 +0700 Subject: [PATCH 0073/1199] Android Research locale --- .../mc/otm/datagen/ResearchData.kt | 195 +++++++++++++----- .../advancements/AndroidAdvancementsData.kt | 6 +- .../datagen/lang/MatteryLanguageProvider.kt | 31 +++ .../mc/otm/datagen/lang/Russian.kt | 2 +- 4 files changed, 181 insertions(+), 53 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt index 0623cfc76..b800419d7 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt @@ -394,74 +394,171 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang serializer.accept(JUMP_BOOST_1) serializer.accept(JUMP_BOOST_2) - with(lang.english) { - misc("fall_dampeners.description", "Reduces fall damage by %s%%") + with(lang) { + misc("fall_dampeners.description", "Reduces fall damage by %s%%") { + russian("Уменьшает урон от падения на %s%%") + } - add(limbList[0], "Limb Overclocking %s") - add(limbList[0], "description", "Boosts unit's mobility by %s%% and attack speed by %s%%") + add(limbList[0], "Limb Overclocking %s") { + russian("Разгон Конечностей %s") + } - add(AIR_BAGS, "Air Bags") - add(NANOBOTS, "Nanobots") - add(AIR_BAGS, "description", "Allows unit to swim in water") - add(NANOBOTS, "description", "Various useful nanobots for doing various tasks") + add(limbList[0], "description", "Boosts mobility by %s%% and attack speed by %s%%") { + russian("Увеличивает мобильность на %s%% и скорость атак на %s%%") + } - add(regenList[0], "Regeneration %s") - add(regenList[0], "description", "Nanobots get ability to repair unit's internal systems on the move") - add(regenList[0], "description_improve", "Improves regeneration speed") + add(AIR_BAGS, "Air Bags") { + russian("Воздушные Мешки") + } + add(NANOBOTS, "Nanobots") { + russian("Наноботы") + } + add(AIR_BAGS, "description", "Allows to swim in water") { + russian("Позволяет плавать в воде") + } + add(NANOBOTS, "description", "Various useful nanobots for doing various tasks") { + russian("Различные наноботы для различных задач") + } - add(NANOBOTS_ARMOR, "Nanobots Armor") - add(NANOBOTS_ARMOR, "description", "Allows nanobots to align themselves in cell shape, reducing incoming damage by a %% by absorbing impacts") + add(regenList[0], "Regeneration %s") { + russian("Регенерация %s") + } + add(regenList[0], "description", "Nanobots get ability to repair internal Android' systems on the move") { + russian("Наноботы получают возможность чинить внутренние системы Андроида на ходу") + } + add(regenList[0], "description_improve", "Improves health regeneration speed") { + russian("Улучшает скорость регенерации здоровья") + } - add(armorSpeedList[0], "Nanobots Armor Build Speed %s") - add(armorSpeedList[0], "description", "Reduces time required for nanobots to form protection layer") + add(NANOBOTS_ARMOR, "Nanobots Armor") { + russian("Броня из Наноботов") + } + add(NANOBOTS_ARMOR, "description", "Allows nanobots to align themselves in cell shape, reducing incoming damage by a %% by absorbing impacts") { + russian("Позволяет наноботам выстраиваться в клеточную структуру, уменьшая внешний урон на определённый проект путём поглощения ударов") + } - add(armorStrengthList[0], "Nanobots Armor Strength %s") - add(armorStrengthList[0], "description", "Increases impact absorption strength of nanobots") + add(armorSpeedList[0], "Nanobots Armor Build Speed %s") { + russian("Скорость Построения Слоя Брони Наноботов %s") + } + add(armorSpeedList[0], "description", "Reduces time required for nanobots to form protection layer") { + russian("Уменьшает время необходимое наноботам для формирования защитного слоя") + } - add(EXTENDED_REACH, "Extended Reach") - add(EXTENDED_REACH, "description", "Increases block interaction distance") + add(armorStrengthList[0], "Nanobots Armor Strength %s") { + russian("Сила Слоя Брони Наноботов %s") + } + add(armorStrengthList[0], "description", "Increases impact absorption strength of nanobots") { + russian("Увеличивает поглощающею силу брони наноботов") + } - add(IMPROVED_LIMBS, "Improved Limbs") - add(IMPROVED_LIMBS, "description", "Allows limbs to be upgraded") + add(EXTENDED_REACH, "Extended Reach") { + russian("Удлинённые Манипуляторы") + } + add(EXTENDED_REACH, "description", "Increases block interaction distance") { + russian("Увеличивает радиус взаимодействия с блоками") + } - add(STEP_ASSIST, "Step Assist") - add(STEP_ASSIST, "description", "Allows unit to step up whole blocks") + add(IMPROVED_LIMBS, "Improved Limbs") { + russian("Улучшенные Конечности") + } + add(IMPROVED_LIMBS, "description", "Allows limbs to be upgraded") { + russian("Позволяет улучшать конечности") + } - add(ITEM_MAGNET, "Item Magnet") - add(ITEM_MAGNET, "description0", "Pulls nearby items to unit while active") - add(ITEM_MAGNET, "description1", "Drains energy for each item stack it pulls") + add(STEP_ASSIST, "Step Assist") { + russian("Помощь Подъёма") + } + add(STEP_ASSIST, "description", "Allows unit to step up whole blocks") { + russian("Позволяет переступать полные блоки") + } - add(FALL_DAMPENERS_1, "Fall Dampeners") - add(FALL_DAMPENERS_1, "description", "Installs basic equipment in unit's limbs to negate some fall damage") + add(ITEM_MAGNET, "Item Magnet") { + russian("Предметный Магнит") + } + add(ITEM_MAGNET, "description0", "Pulls nearby items while active") { + russian("Притягивает ближайшие предметы пока активен") + } + add(ITEM_MAGNET, "description1", "Drains energy for each item stack it pulls") { + russian("Потребляет энергию за каждую стопку которую притягивает магнит") + } - add(FALL_DAMPENERS_2, "Fall Dampeners 2") - add(FALL_DAMPENERS_2, "description", "Installs micro displacing and dampening equipment in unit's limbs to negate great deal of fall damage") + add(FALL_DAMPENERS_1, "Fall Dampeners") { + russian("Поглотители Инерции") + } + add(FALL_DAMPENERS_1, "description", "Installs basic equipment in limbs to negate some fall damage") { + russian("Обустраивает конечности примитивными деталями для небольшого смягчения падения") + } - add(FALL_DAMPENERS_3, "Fall Dampeners 3") - add(FALL_DAMPENERS_3, "description0", "Installs autonomous calculation matrices and hardening to crucial parts") - add(FALL_DAMPENERS_3, "description1", "of unit's limbs to land on to negate most of fall damage") + add(FALL_DAMPENERS_2, "Fall Dampeners 2") { + russian("Поглотители Инерции 2") + } + add(FALL_DAMPENERS_2, "description", "Installs micro displacing and dampening equipment in limbs to negate great deal of fall damage") { + russian("Оборудует конечности микро смещающимися и смягчающим оборудованием, которое поглощает значительный урон от падения") + } - add(SHOCKWAVE, "Shockwave Pulsator") - add(SHOCKWAVE, "description0", "Releases a shockwave around unit, damaging everything in small radius, as unit quickly land on ground") - add(SHOCKWAVE, "description1", "It does not, however, help with ground impact damage!") + add(FALL_DAMPENERS_3, "Fall Dampeners 3") { + russian("Поглотители Инерции 3") + } + add(FALL_DAMPENERS_3, "description0", "Installs autonomous fall damage avoidance calculation matrices and hardening to crucial parts") { + russian("Устанавливает автономные матрицы калькуляции избегания урона от падения, а так же усиливает защиту важных деталей") + } + add(FALL_DAMPENERS_3, "description1", "of limbs to land on to negate most of fall damage") { + russian("от урона от падения для почти полного поглощения урона от падения") + } - add(PHANTOM_ATTRACTOR, "Builtin Phantom Attractor") - add(PHANTOM_ATTRACTOR, "description", "Allows unit to attract phantoms while active under same conditions as non-androids") + add(SHOCKWAVE, "Shockwave Pulsator") { + russian("Генератор Ударных Волн") + } + add(SHOCKWAVE, "description0", "Releases a shockwave, damaging everything in small radius, as you quickly land on ground") { + russian("Вызывает ударную волну при стремительном падении на землю, нанося урон всему, что вас окружает") + } + add(SHOCKWAVE, "description1", "It does not, however, help with ground impact damage!") { + russian("Используйте с осторожностью, так как данная технология сама по себе не поглащает урон от падения!") + } - add(JUMP_BOOST_1, "Jump Boost") - add(JUMP_BOOST_1, "description0", "Allows unit to perform higher jump") - add(JUMP_BOOST_1, "description1", "Can be activated by crouching and jumping at the same time") + add(PHANTOM_ATTRACTOR, "Builtin Phantom Attractor") { + russian("Встроенный Приманщик Фантомов") + } + add(PHANTOM_ATTRACTOR, "description", "Allows to attract phantoms while active under same conditions as non-Androids") { + russian("Позволяет привлекать фантомов под теми же условиями, как и не Андроиды") + } - add(JUMP_BOOST_2, "Jump Boost 2") - add(JUMP_BOOST_2, "description", "Allows unit to perform extra higher jump") + add(JUMP_BOOST_1, "Jump Boost") { + russian("Усилитель Прыжка") + } + add(JUMP_BOOST_1, "description0", "Allows to perform higher jump") { + russian("Позволяет совершить высокий прыжок") + } + add(JUMP_BOOST_1, "description1", "Can be activated by crouching and jumping at the same time") { + russian("Для прыжка удерживайте кнопку приседания и нажмите кнопку прыжка") + } - add(ENDER_TELEPORTER, "Ender Teleporter") - add(ENDER_TELEPORTER, "description", "Allows unit to perform instant, short distance teleports without damage to internal systems") + add(JUMP_BOOST_2, "Jump Boost 2") { + russian("Усилитель Прыжка 2") + } + add(JUMP_BOOST_2, "description", "Allows to perform extra higher jump") { + russian("Позволяет совершить ещё более высокий прыжок") + } - add(NIGHT_VISION, "Night Vision") - add(NIGHT_VISION, "description", "Allows unit to clearly see in the dark") + add(ENDER_TELEPORTER, "Ender Teleporter") { + russian("Телепортатор Края") + } + add(ENDER_TELEPORTER, "description", "Allows to perform instant, short distance teleports without damage to internal systems") { + russian("Позволяет совершать мгновенную телепортацию на короткую дистанцию без нанесения урона внутренним системам") + } - add(attackBoostList[0], "Attack Boost %s") - add(attackBoostList[0], "description", "Increases total melee attack strength by %s%%") + add(NIGHT_VISION, "Night Vision") { + russian("Ночное Зрение") + } + add(NIGHT_VISION, "description", "Allows to clearly see in the dark") { + russian("Позволяет видеть в темноте") + } + + add(attackBoostList[0], "Attack Boost %s") { + russian("Усиление Атаки %s") + } + add(attackBoostList[0], "description", "Increases total melee attack strength by %s%%") { + russian("Увеличивает урон в ближнем бою на %s%%") + } } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt index c5250156c..9d53300a1 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt @@ -215,7 +215,7 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper russian("Вторая Пара Глаз") }, description = translation.add("night_vision.desc", "Research Night Vision as Android, to see in the dark") { - russian("Исследуйте Ночное Зрение за Андроида, дабы видеть во тьме") + russian("Исследуйте Ночное Зрение за Андроида, дабы видеть во темноте") }, ) .addCriterion("night_vision", AndroidResearchTrigger.Instance(modLocation(MNames.NIGHT_VISION))) @@ -275,8 +275,8 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper title = translation.add("fall_dampeners_save", "Lucky Landing") { russian("Удачное Приземление") }, - description = translation.add("fall_dampeners_save.desc", "Survive fall that would have otherwise be fatal without Fall Dampeners research") { - russian("Выживите после падения, которое было бы фатальным без исследования Смягчителей Падения") + description = translation.add("fall_dampeners_save.desc", "Survive fall that would have otherwise be fatal without Fall Dampeners") { + russian("Выживите после падения, которое было бы фатальным без Поглотителей Инерции") }, frameType = FrameType.GOAL ) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/MatteryLanguageProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/MatteryLanguageProvider.kt index 673e1ee12..bd7aa1ec9 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/MatteryLanguageProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/MatteryLanguageProvider.kt @@ -18,6 +18,7 @@ import net.minecraft.world.level.block.Block import net.minecraftforge.common.data.LanguageProvider import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.android.AndroidFeatureType +import ru.dbotthepony.mc.otm.android.AndroidResearch import ru.dbotthepony.mc.otm.android.AndroidResearchType import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.registry.objects.ColoredDecorativeBlock @@ -430,5 +431,35 @@ class MatteryLanguageProvider(private val gen: DataGenerator) { val english by lazy { Builder("en_us") } val russian by lazy { Builder("ru_ru") } + inner class Single(val key: String) { + fun english(value: String) = english.add(key, value) + fun russian(value: String) = russian.add(key, value) + } + + inline fun add(key: String, configurator: Single.() -> Unit) = Single(key).also(configurator) + fun add(key: AndroidResearchType, configurator: Single.() -> Unit) = Single(researchString(key)).also(configurator) + + inline fun add(key: String, english: String, configurator: Single.() -> Unit = {}) = add(key) { english(english); configurator.invoke(this) } + fun add(key: AndroidResearchType, english: String, configurator: Single.() -> Unit = {}) = add(key) { english(english); configurator.invoke(this) } + fun add(key: AndroidResearchType, suffix: String, english: String, configurator: Single.() -> Unit = {}) = add(researchString(key) + ".$suffix") { english(english); configurator.invoke(this) } + + inline fun death(key: String, configurator: Single.() -> Unit) = Single("death.attack.$key").also(configurator) + inline fun death(key: String, english: String, configurator: Single.() -> Unit = {}) = death(key) { english(english); configurator.invoke(this) } + + inline fun research(key: String, configurator: Single.() -> Unit) = Single("android_research.overdrive_that_matters.$key").also(configurator) + inline fun research(key: String, english: String, configurator: Single.() -> Unit = {}) = research(key) { english(english); configurator.invoke(this) } + inline fun research(key: String, suffix: String, english: String, configurator: Single.() -> Unit = {}) = research("$key.$suffix") { english(english); configurator.invoke(this) } + + inline fun misc(key: String, configurator: Single.() -> Unit) = Single("otm.$key").also(configurator) + inline fun misc(key: String, english: String, configurator: Single.() -> Unit = {}) = misc(key) { english(english); configurator.invoke(this) } + + inline fun gui(key: String, configurator: Single.() -> Unit) = Single("otm.gui.$key").also(configurator) + inline fun gui(key: String, english: String, configurator: Single.() -> Unit = {}) = gui(key) { english(english); configurator.invoke(this) } + + inline fun sound(key: String, configurator: Single.() -> Unit) = Single("otm.sound.$key").also(configurator) + inline fun sound(key: String, english: String, configurator: Single.() -> Unit = {}) = sound(key) { english(english); configurator.invoke(this) } + inline fun sound(key: SoundEvent, configurator: Single.() -> Unit) = Single("otm.sound.${key.location.path}").also(configurator) + inline fun sound(key: SoundEvent, english: String, configurator: Single.() -> Unit = {}) = sound(key) { english(english); configurator.invoke(this) } + fun getProvider(language: String): LanguageProvider = slaves.computeIfAbsent(language, ::Slave) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index a4ab753ea..bec55be61 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -583,7 +583,7 @@ private fun androidFeatures(provider: MatteryLanguageProvider) { add(AndroidFeatures.SHOCKWAVE, "Генератор Ударных Волн") add(AndroidFeatures.NIGHT_VISION, "Ночное Зрение") add(AndroidFeatures.NANOBOTS_ARMOR, "Броня из Наноботов") - add(AndroidFeatures.ITEM_MAGNET, "Магнит Предметов") + add(AndroidFeatures.ITEM_MAGNET, "Предметный Магнит") add(AndroidFeatures.STEP_ASSIST, "Помощник Подъёма") add(AndroidFeatures.PHANTOM_ATTRACTOR, "Приманщик Фантомов") add(AndroidFeatures.JUMP_BOOST, "Усилитель Прыжка") From b82a0271085b74cbf4abd25bb2f8f335bed9601b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 23 Jan 2023 20:53:09 +0700 Subject: [PATCH 0074/1199] even lesser chance for android pills in dungeons Fixes #160 --- .../dbotthepony/mc/otm/datagen/loot/LootModifiersData.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootModifiersData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootModifiersData.kt index 4d9d3b332..61e301237 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootModifiersData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootModifiersData.kt @@ -71,14 +71,14 @@ fun addLootModifiers(it: LootModifiers) { it.add("dungeon_pill", PlainLootAppender( arrayOf(LootTableIdCondition(BuiltInLootTables.SIMPLE_DUNGEON)), - ItemStack(MItems.PILL_ANDROID, 1) to 0.4, + ItemStack(MItems.PILL_ANDROID, 1) to 0.1, ItemStack(MItems.PILL_HEAL, 2) to 0.5, ItemStack(MItems.PILL_HEAL, 1) to 0.75, )) it.add("mineshaft_pill", PlainLootAppender( arrayOf(LootTableIdCondition(BuiltInLootTables.ABANDONED_MINESHAFT)), - ItemStack(MItems.PILL_ANDROID, 1) to 0.075, + ItemStack(MItems.PILL_ANDROID, 1) to 0.04, ItemStack(MItems.PILL_HEAL, 2) to 0.1, ItemStack(MItems.PILL_HEAL, 1) to 0.4, )) @@ -92,7 +92,7 @@ fun addLootModifiers(it: LootModifiers) { it.add("desert_pyramid_pill", PlainLootAppender( arrayOf(LootTableIdCondition(BuiltInLootTables.DESERT_PYRAMID)), - ItemStack(MItems.PILL_ANDROID, 1) to 0.05, + ItemStack(MItems.PILL_ANDROID, 1) to 0.15, ItemStack(MItems.PILL_HEAL, 1) to 0.3, )) @@ -103,7 +103,7 @@ fun addLootModifiers(it: LootModifiers) { it.add("end_city_modifications", PlainLootAppender( arrayOf(LootTableIdCondition(BuiltInLootTables.END_CITY_TREASURE)), - ItemStack(MItems.PILL_ANDROID, 1) to 0.1, + ItemStack(MItems.PILL_ANDROID, 1) to 0.15, ItemStack(MItems.PILL_HUMANE, 1) to 0.3, ItemStack(MItems.PILL_OBLIVION, 1) to 0.5, ItemStack(MItems.ZPM_BATTERY, 1) to 0.005, From b2bababac2f76c6a2fb67b2ffb5cbdaee3e1b4c1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 23 Jan 2023 21:17:15 +0700 Subject: [PATCH 0075/1199] Make tritanium armor require leather armor --- .../mc/otm/datagen/recipes/CraftingTableRecipes.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index 5ff8c0076..a2eac90db 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -165,27 +165,27 @@ fun addCraftingTableRecipes(consumer: Consumer) { // броня MatteryRecipe(MItems.TRITANIUM_HELMET, category = RecipeCategory.COMBAT) .row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) - .row(MItemTags.TRITANIUM_PLATES, MItemTags.IRON_PLATES, MItemTags.TRITANIUM_PLATES) + .row(MItemTags.TRITANIUM_PLATES, Items.LEATHER_HELMET, MItemTags.TRITANIUM_PLATES) .unlockedBy(MItemTags.TRITANIUM_PLATES) .build(consumer) MatteryRecipe(MItems.TRITANIUM_PANTS, category = RecipeCategory.COMBAT) .row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) - .row(MItemTags.TRITANIUM_PLATES, MItemTags.IRON_PLATES, MItemTags.TRITANIUM_PLATES) + .row(MItemTags.TRITANIUM_PLATES, Items.LEATHER_LEGGINGS, MItemTags.TRITANIUM_PLATES) .rowAC(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) .unlockedBy(MItemTags.TRITANIUM_PLATES) .build(consumer) MatteryRecipe(MItems.TRITANIUM_CHESTPLATE, category = RecipeCategory.COMBAT) - .row(MItemTags.TRITANIUM_PLATES, MItemTags.IRON_PLATES, MItemTags.TRITANIUM_PLATES) + .row(MItemTags.TRITANIUM_PLATES, Items.LEATHER_CHESTPLATE, MItemTags.TRITANIUM_PLATES) .row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) .row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) .unlockedBy(MItemTags.TRITANIUM_PLATES) .build(consumer) MatteryRecipe(MItems.TRITANIUM_BOOTS, category = RecipeCategory.COMBAT) - .rowAC(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) - .row(MItemTags.TRITANIUM_PLATES, MItemTags.IRON_PLATES, MItemTags.TRITANIUM_PLATES) + .row(MItemTags.TRITANIUM_PLATES, Items.LEATHER_BOOTS, MItemTags.TRITANIUM_PLATES) + .row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) .unlockedBy(MItemTags.TRITANIUM_PLATES) .build(consumer) From 740ae89ab25c8f7a1424f10e3cbffac55df59c7a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 23 Jan 2023 22:02:03 +0700 Subject: [PATCH 0076/1199] Add tritanium armor to freeze immune tag --- src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt | 7 +++++++ src/main/resources/overdrive_that_matters.mixins.json | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index beb1320ba..78fbc2d3c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -7,6 +7,7 @@ import net.minecraft.world.item.BlockItem import net.minecraft.world.item.Items import net.minecraft.world.item.Tiers import net.minecraft.world.level.block.Blocks +import ru.dbotthepony.mc.otm.datagen.recipes.addCraftingTableRecipes import ru.dbotthepony.mc.otm.registry.MBlockTags import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MItemTags @@ -35,6 +36,12 @@ fun addTags(tagsProvider: TagsProvider) { tagsProvider.wires.add("copper", MItems.COPPER_WIRING) tagsProvider.wires.add("gold", MItems.GOLD_WIRING) + tagsProvider.items.appender(ItemTags.FREEZE_IMMUNE_WEARABLES) + .add(MItems.TRITANIUM_BOOTS) + .add(MItems.TRITANIUM_PANTS) + .add(MItems.TRITANIUM_CHESTPLATE) + .add(MItems.TRITANIUM_HELMET) + tagsProvider.requiresPickaxe( MBlocks.MATTER_CABLE, MBlocks.STORAGE_CABLE diff --git a/src/main/resources/overdrive_that_matters.mixins.json b/src/main/resources/overdrive_that_matters.mixins.json index dcbc2ffc0..07c4b2a7f 100644 --- a/src/main/resources/overdrive_that_matters.mixins.json +++ b/src/main/resources/overdrive_that_matters.mixins.json @@ -1,3 +1,4 @@ + { "required": true, "package": "ru.dbotthepony.mc.otm.mixin", @@ -7,4 +8,4 @@ "mixins": [ "MixinPatchProjectileFinder" ] -} \ No newline at end of file +} From 47f95975e5d62ffbe48f8f80a4ce14df158f285e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 23 Jan 2023 22:07:34 +0700 Subject: [PATCH 0077/1199] Actually make tritanium armor require full set to stop freezing instead --- .../dbotthepony/mc/otm/datagen/tags/Tags.kt | 6 ---- .../mc/otm/mixin/MixinLivingEntity.java | 30 +++++++++++++++++++ .../overdrive_that_matters.mixins.json | 3 +- 3 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 src/main/java/ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index 78fbc2d3c..c31990cbe 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -36,12 +36,6 @@ fun addTags(tagsProvider: TagsProvider) { tagsProvider.wires.add("copper", MItems.COPPER_WIRING) tagsProvider.wires.add("gold", MItems.GOLD_WIRING) - tagsProvider.items.appender(ItemTags.FREEZE_IMMUNE_WEARABLES) - .add(MItems.TRITANIUM_BOOTS) - .add(MItems.TRITANIUM_PANTS) - .add(MItems.TRITANIUM_CHESTPLATE) - .add(MItems.TRITANIUM_HELMET) - tagsProvider.requiresPickaxe( MBlocks.MATTER_CABLE, MBlocks.STORAGE_CABLE diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java new file mode 100644 index 000000000..8f4aae057 --- /dev/null +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java @@ -0,0 +1,30 @@ +package ru.dbotthepony.mc.otm.mixin; + +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.LivingEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import ru.dbotthepony.mc.otm.registry.MItems; + +@Mixin(LivingEntity.class) +public class MixinLivingEntity { + @Inject( + method = "canFreeze()Z", + at = @At("HEAD"), + cancellable = true) + public void canFreeze(CallbackInfoReturnable hook) { + if (((Object) this) instanceof LivingEntity entity) { + boolean flag = + entity.getItemBySlot(EquipmentSlot.HEAD).is(MItems.INSTANCE.getTRITANIUM_HELMET()) && + entity.getItemBySlot(EquipmentSlot.CHEST).is(MItems.INSTANCE.getTRITANIUM_CHESTPLATE()) && + entity.getItemBySlot(EquipmentSlot.LEGS).is(MItems.INSTANCE.getTRITANIUM_PANTS()) && + entity.getItemBySlot(EquipmentSlot.FEET).is(MItems.INSTANCE.getTRITANIUM_BOOTS()) + ; + + if (flag) + hook.setReturnValue(false); + } + } +} diff --git a/src/main/resources/overdrive_that_matters.mixins.json b/src/main/resources/overdrive_that_matters.mixins.json index 07c4b2a7f..7559f932a 100644 --- a/src/main/resources/overdrive_that_matters.mixins.json +++ b/src/main/resources/overdrive_that_matters.mixins.json @@ -6,6 +6,7 @@ "minVersion": "0.8", "refmap": "overdrive_that_matters.refmap.json", "mixins": [ - "MixinPatchProjectileFinder" + "MixinPatchProjectileFinder", + "MixinLivingEntity" ] } From 95189b7eaf1ab7d658ece9c0b36d4c4679ec187d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 23 Jan 2023 22:18:48 +0700 Subject: [PATCH 0078/1199] Opening a cargo crate now updates its physical model --- .../mc/otm/shapes/BlockShapes.java | 10 +++++++++ .../mc/otm/block/CargoCrateBlock.kt | 21 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java index 282e88463..c260aba9c 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java +++ b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java @@ -591,4 +591,14 @@ public class BlockShapes { new SimpleCuboid(0.875d, 0d, 0.5625d, 1d, 0.125d, 0.875d), new SimpleCuboid(0d, 0d, 0.5625d, 0.125d, 0.125d, 0.875d) ); + + public static final BlockShape CARGO_CRATE_OPEN = new BlockShape( + new SimpleCuboid(0d, 0d, 0d, 1d, 0.8125d, 1d), + new SimpleCuboid(0.125d, 0.8125d, 0.125d, 0.875d, 0.9375d, 0.875d), + new SimpleCuboid(0d, 0.9375d, 0d, 1d, 1.125d, 1d), + new SimpleCuboid(0d, 0.8125d, 0.4375d, 0d, 0.9375d, 0.5625d), + new SimpleCuboid(1d, 0.8125d, 0.4375d, 1d, 0.9375d, 0.5625d), + new SimpleCuboid(0.4375d, 0.8125d, 1d, 0.5625d, 0.9375d, 1d), + new SimpleCuboid(0.4375d, 0.8125d, 0d, 0.5625d, 0.9375d, 0d) + ); } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/CargoCrateBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/CargoCrateBlock.kt index 7f2364c4b..d204f3bc5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/CargoCrateBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/CargoCrateBlock.kt @@ -1,10 +1,12 @@ package ru.dbotthepony.mc.otm.block +import com.google.common.collect.ImmutableMap import net.minecraft.core.BlockPos import net.minecraft.world.Containers import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.DyeColor import net.minecraft.world.item.context.BlockPlaceContext +import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.EntityBlock @@ -14,7 +16,12 @@ import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.level.block.state.properties.BooleanProperty import net.minecraft.world.level.material.Material import net.minecraft.world.level.material.MaterialColor +import net.minecraft.world.phys.shapes.CollisionContext +import net.minecraft.world.phys.shapes.Shapes +import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.entity.CargoCrateBlockEntity +import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.shapes.BlockShapes class CargoCrateBlock(val color: DyeColor?) : RotatableMatteryBlock( Properties.of(Material.STONE, color?.materialColor ?: MaterialColor.COLOR_BLUE).requiresCorrectToolForDrops().strength(1.5f, 30.0f) @@ -43,8 +50,22 @@ class CargoCrateBlock(val color: DyeColor?) : RotatableMatteryBlock( return AbstractContainerMenu.getRedstoneSignalFromContainer(tile.container) } + override fun getShape( + p_60555_: BlockState, + p_60556_: BlockGetter, + p_60557_: BlockPos, + p_60558_: CollisionContext + ): VoxelShape { + if (p_60555_[IS_OPEN]) { + return CARGO_CRATE_OPEN + } else { + return Shapes.block() + } + } + companion object { @JvmField val IS_OPEN: BooleanProperty = BooleanProperty.create("open") + val CARGO_CRATE_OPEN: VoxelShape = BlockShapes.CARGO_CRATE_OPEN.computeShape() } } From ab135ace62d9f9b2e6664db28711ea8da0ab2c6e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 23 Jan 2023 22:20:04 +0700 Subject: [PATCH 0079/1199] Move laboratory lamp to decorative package --- .../mc/otm/block/{ => decorative}/LaboratoryLamp.kt | 6 ++++-- src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt | 6 ++---- 2 files changed, 6 insertions(+), 6 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/block/{ => decorative}/LaboratoryLamp.kt (97%) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/LaboratoryLamp.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt similarity index 97% rename from src/main/kotlin/ru/dbotthepony/mc/otm/block/LaboratoryLamp.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt index a3ec37fbd..bd83db1d6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/LaboratoryLamp.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.block +package ru.dbotthepony.mc.otm.block.decorative import net.minecraft.ChatFormatting import net.minecraft.core.BlockPos @@ -21,6 +21,7 @@ import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.Shapes import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.ServerConfig +import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.plus @@ -183,7 +184,8 @@ class LaboratoryLamp(val invertRedstone: Boolean) : Block(Properties.of(Material if (shouldBeLit) { if (targetState.isAir && targetState.block != MBlocks.LABORATORY_LAMP_LIGHT) { - level.setBlockAndUpdate(target, MBlocks.LABORATORY_LAMP_LIGHT.defaultBlockState().setValue(RotatableMatteryBlock.FACING_FULL, -facing)) + level.setBlockAndUpdate(target, MBlocks.LABORATORY_LAMP_LIGHT.defaultBlockState().setValue( + RotatableMatteryBlock.FACING_FULL, -facing)) } } else { if (targetState.block == MBlocks.LABORATORY_LAMP_LIGHT) { 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 60f27f23d..f495dc588 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -37,14 +37,12 @@ import ru.dbotthepony.mc.otm.block.BlockSphereDebugger import ru.dbotthepony.mc.otm.block.ChemicalGeneratorBlock import ru.dbotthepony.mc.otm.block.EnergyCounterBlock import ru.dbotthepony.mc.otm.block.EnergyServoBlock -import ru.dbotthepony.mc.otm.block.LaboratoryLamp -import ru.dbotthepony.mc.otm.block.LaboratoryLampLight +import ru.dbotthepony.mc.otm.block.decorative.LaboratoryLamp +import ru.dbotthepony.mc.otm.block.decorative.LaboratoryLampLight import ru.dbotthepony.mc.otm.block.MatterCableBlock import ru.dbotthepony.mc.otm.block.PhantomAttractorBlock import ru.dbotthepony.mc.otm.block.PlatePressBlock -import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.StorageCableBlock -import ru.dbotthepony.mc.otm.block.TritaniumPressurePlate import ru.dbotthepony.mc.otm.block.decorative.EngineBlock import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock import ru.dbotthepony.mc.otm.block.matter.MatterCapacitorBankBlock From f9b5a673e295cfb52e6c8aafc6465c0ca1121c15 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 23 Jan 2023 22:27:03 +0700 Subject: [PATCH 0080/1199] More block packages sorting --- .../dbotthepony/mc/otm/datagen/blocks/Banks.kt | 2 +- .../mc/otm/datagen/blocks/BlockStates.kt | 2 +- .../otm/datagen/blocks/ComplexBlockStates.kt | 5 ++--- .../mc/otm/datagen/loot/LootTablesData.kt | 4 ++-- .../ru/dbotthepony/mc/otm/ServerConfig.kt | 4 ++-- .../block/{ => decorative}/CargoCrateBlock.kt | 7 +++---- .../{ => decorative}/TritaniumPressurePlate.kt | 2 +- .../entity/blackhole/BlackHoleBlockEntity.kt | 5 +++-- .../{ => decorative}/CargoCrateBlockEntity.kt | 5 +++-- .../matter/MatterCapacitorBankBlockEntity.kt | 2 +- .../{ => tech}/AndroidStationBlockEntity.kt | 13 ++++++++++--- .../{ => tech}/BatteryBankBlockEntity.kt | 7 +++---- .../{ => tech}/ChemicalGeneratorBlockEntity.kt | 4 +++- .../{ => tech}/EnergyCounterBlockEntity.kt | 8 +++----- .../{ => tech}/EnergyServoBlockEntity.kt | 3 ++- .../GravitationStabilizerBlockEntity.kt | 8 +++++--- .../entity/{ => tech}/PlatePressBlockEntity.kt | 7 +++++-- .../block/matter/MatterCapacitorBankBlock.kt | 8 +------- .../block/{ => tech}/AndroidStationBlock.kt | 5 +++-- .../otm/block/{ => tech}/BatteryBankBlock.kt | 6 +++--- .../block/{ => tech}/ChemicalGeneratorBlock.kt | 5 +++-- .../otm/block/{ => tech}/EnergyCounterBlock.kt | 6 +++--- .../otm/block/{ => tech}/EnergyServoBlock.kt | 5 +++-- .../{ => tech}/GravitationStabilizerBlock.kt | 5 +++-- .../block/{ => tech}/PhantomAttractorBlock.kt | 3 ++- .../mc/otm/block/{ => tech}/PlatePressBlock.kt | 5 +++-- .../client/render/blockentity/BankRenderer.kt | 2 +- .../render/blockentity/BlackHoleRenderer.kt | 2 +- .../blockentity/EnergyCounterRenderer.kt | 4 ++-- .../GravitationStabilizerRenderer.kt | 2 +- .../otm/client/screen/AndroidStationScreen.kt | 2 +- .../mc/otm/entity/MinecartCargoCrate.kt | 4 ++-- .../mc/otm/menu/AndroidStationMenu.kt | 5 +---- .../dbotthepony/mc/otm/menu/BatteryBankMenu.kt | 4 +--- .../dbotthepony/mc/otm/menu/CargoCrateMenu.kt | 2 +- .../mc/otm/menu/ChemicalGeneratorMenu.kt | 2 +- .../mc/otm/menu/EnergyCounterMenu.kt | 4 ++-- .../dbotthepony/mc/otm/menu/EnergyServoMenu.kt | 2 +- .../mc/otm/menu/MinecartCargoCrateMenu.kt | 2 +- .../dbotthepony/mc/otm/menu/PlatePressMenu.kt | 3 +-- .../mc/otm/recipe/PlatePressRecipe.kt | 4 +--- .../mc/otm/registry/MBlockEntities.kt | 7 +++++++ .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 18 +++++++++--------- .../dbotthepony/mc/otm/registry/MRegistry.kt | 4 ++-- 44 files changed, 110 insertions(+), 99 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/block/{ => decorative}/CargoCrateBlock.kt (93%) rename src/main/kotlin/ru/dbotthepony/mc/otm/block/{ => decorative}/TritaniumPressurePlate.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/{ => decorative}/CargoCrateBlockEntity.kt (96%) rename src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/{ => tech}/AndroidStationBlockEntity.kt (90%) rename src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/{ => tech}/BatteryBankBlockEntity.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/{ => tech}/ChemicalGeneratorBlockEntity.kt (97%) rename src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/{ => tech}/EnergyCounterBlockEntity.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/{ => tech}/EnergyServoBlockEntity.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/{ => tech}/GravitationStabilizerBlockEntity.kt (90%) rename src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/{ => tech}/PlatePressBlockEntity.kt (94%) rename src/main/kotlin/ru/dbotthepony/mc/otm/block/{ => tech}/AndroidStationBlock.kt (94%) rename src/main/kotlin/ru/dbotthepony/mc/otm/block/{ => tech}/BatteryBankBlock.kt (95%) rename src/main/kotlin/ru/dbotthepony/mc/otm/block/{ => tech}/ChemicalGeneratorBlock.kt (95%) rename src/main/kotlin/ru/dbotthepony/mc/otm/block/{ => tech}/EnergyCounterBlock.kt (96%) rename src/main/kotlin/ru/dbotthepony/mc/otm/block/{ => tech}/EnergyServoBlock.kt (92%) rename src/main/kotlin/ru/dbotthepony/mc/otm/block/{ => tech}/GravitationStabilizerBlock.kt (97%) rename src/main/kotlin/ru/dbotthepony/mc/otm/block/{ => tech}/PhantomAttractorBlock.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/block/{ => tech}/PlatePressBlock.kt (94%) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt index f605784d9..b17567cde 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt @@ -4,7 +4,7 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.world.level.block.Block import net.minecraftforge.client.model.generators.BlockStateProvider import net.minecraftforge.data.event.GatherDataEvent -import ru.dbotthepony.mc.otm.block.BatteryBankBlock +import ru.dbotthepony.mc.otm.block.tech.BatteryBankBlock import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.datagen.DataGen import ru.dbotthepony.mc.otm.datagen.toYRotBlockstate diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt index e4db7d8c1..2d821f4cd 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt @@ -6,7 +6,7 @@ import net.minecraft.world.level.block.state.properties.DoubleBlockHalf import net.minecraftforge.client.model.generators.ConfiguredModel import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.block.CableBlock -import ru.dbotthepony.mc.otm.block.CargoCrateBlock +import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt index be4fc41e2..352e4cf28 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt @@ -2,12 +2,11 @@ package ru.dbotthepony.mc.otm.datagen.blocks import net.minecraft.core.Direction import net.minecraft.resources.ResourceLocation -import ru.dbotthepony.mc.otm.block.EnergyCounterBlock +import ru.dbotthepony.mc.otm.block.tech.EnergyCounterBlock import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.matter.PatternStorageBlock import ru.dbotthepony.mc.otm.block.storage.DriveViewerBlock -import ru.dbotthepony.mc.otm.datagen.DataGen import ru.dbotthepony.mc.otm.datagen.DataGen.MOD_ID import ru.dbotthepony.mc.otm.datagen.toYRotBlockstate import ru.dbotthepony.mc.otm.registry.MBlocks @@ -94,4 +93,4 @@ fun addComplexBlockStates(provider: MatteryBlockStateProvider) { part().modelFile(mdl).rotationX(90).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, dir).condition(EnergyCounterBlock.IF_DIRECTION, Direction.DOWN) } } -} \ No newline at end of file +} diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index cfa8ce748..dd4a30389 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -6,8 +6,8 @@ import net.minecraft.world.level.block.state.properties.DoubleBlockHalf import net.minecraft.world.level.storage.loot.entries.LootItem import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets import net.minecraft.world.level.storage.loot.predicates.ExplosionCondition -import ru.dbotthepony.mc.otm.block.entity.ChemicalGeneratorBlockEntity -import ru.dbotthepony.mc.otm.block.entity.EnergyCounterBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.ChemicalGeneratorBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.EnergyCounterBlockEntity import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity.Companion.ENERGY_KEY import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity.Companion.MATTER_STORAGE_KEY import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity.Companion.REDSTONE_SETTING_KEY diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/ServerConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/ServerConfig.kt index b7be90abd..2e1d74972 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/ServerConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/ServerConfig.kt @@ -3,8 +3,8 @@ package ru.dbotthepony.mc.otm import net.minecraftforge.common.ForgeConfigSpec import net.minecraftforge.fml.ModLoadingContext import net.minecraftforge.fml.config.ModConfig -import ru.dbotthepony.mc.otm.block.entity.AndroidStationBlockEntity -import ru.dbotthepony.mc.otm.block.entity.ChemicalGeneratorBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.ChemicalGeneratorBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterDecomposerBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterRecyclerBlockEntity diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/CargoCrateBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/CargoCrateBlock.kt similarity index 93% rename from src/main/kotlin/ru/dbotthepony/mc/otm/block/CargoCrateBlock.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/CargoCrateBlock.kt index d204f3bc5..19fcb775e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/CargoCrateBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/CargoCrateBlock.kt @@ -1,8 +1,6 @@ -package ru.dbotthepony.mc.otm.block +package ru.dbotthepony.mc.otm.block.decorative -import com.google.common.collect.ImmutableMap import net.minecraft.core.BlockPos -import net.minecraft.world.Containers import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.DyeColor import net.minecraft.world.item.context.BlockPlaceContext @@ -19,7 +17,8 @@ import net.minecraft.world.level.material.MaterialColor import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.Shapes import net.minecraft.world.phys.shapes.VoxelShape -import ru.dbotthepony.mc.otm.block.entity.CargoCrateBlockEntity +import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.entity.decorative.CargoCrateBlockEntity import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.shapes.BlockShapes diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/TritaniumPressurePlate.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/block/TritaniumPressurePlate.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt index abc9fd9ac..5d4b53a36 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/TritaniumPressurePlate.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.block +package ru.dbotthepony.mc.otm.block.decorative import net.minecraft.ChatFormatting import net.minecraft.core.BlockPos 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 6d1b91ae8..3c3782657 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 @@ -18,7 +18,7 @@ import net.minecraft.world.level.levelgen.structure.BoundingBox import net.minecraft.world.phys.AABB import net.minecraft.world.phys.Vec3 import ru.dbotthepony.mc.otm.block.BlackHoleBlock -import ru.dbotthepony.mc.otm.block.entity.GravitationStabilizerBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.GravitationStabilizerBlockEntity import ru.dbotthepony.mc.otm.block.entity.SynchronizedBlockEntity import ru.dbotthepony.mc.otm.block.entity.blackhole.ExplosionQueue.Companion.queueForLevel import ru.dbotthepony.mc.otm.core.math.Decimal @@ -73,7 +73,8 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Synchro }) override fun getRenderBoundingBox(): AABB { - return AABB(blockPos.offset(-GravitationStabilizerBlockEntity.RANGE, -GravitationStabilizerBlockEntity.RANGE, -GravitationStabilizerBlockEntity.RANGE), blockPos.offset(GravitationStabilizerBlockEntity.RANGE, GravitationStabilizerBlockEntity.RANGE, GravitationStabilizerBlockEntity.RANGE)) + return AABB(blockPos.offset(-GravitationStabilizerBlockEntity.RANGE, -GravitationStabilizerBlockEntity.RANGE, -GravitationStabilizerBlockEntity.RANGE), blockPos.offset( + GravitationStabilizerBlockEntity.RANGE, GravitationStabilizerBlockEntity.RANGE, GravitationStabilizerBlockEntity.RANGE)) } var gravitationStrength = 1.0 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/CargoCrateBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/CargoCrateBlockEntity.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt index 97c58cbdd..b6b9af778 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/CargoCrateBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.block.entity +package ru.dbotthepony.mc.otm.block.entity.decorative import net.minecraft.advancements.CriteriaTriggers import net.minecraft.core.BlockPos @@ -28,8 +28,9 @@ import net.minecraft.world.phys.Vec3 import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.LazyOptional -import ru.dbotthepony.mc.otm.block.CargoCrateBlock +import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock import ru.dbotthepony.mc.otm.block.IDroppableContainer +import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainerHooks import ru.dbotthepony.mc.otm.core.TranslatableComponent diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt index 5d1389529..b20dce44f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt @@ -16,7 +16,7 @@ import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.block.BatteryBankBlock +import ru.dbotthepony.mc.otm.block.tech.BatteryBankBlock import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/AndroidStationBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt similarity index 90% rename from src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/AndroidStationBlockEntity.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt index bf212b5ac..433a754a6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/AndroidStationBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.block.entity +package ru.dbotthepony.mc.otm.block.entity.tech import net.minecraft.core.BlockPos import net.minecraft.network.chat.Component @@ -11,6 +11,8 @@ import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.phys.AABB import net.minecraftforge.common.ForgeConfigSpec +import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity +import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.core.math.Decimal @@ -34,7 +36,9 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : override val defaultDisplayName: Component get() = MBlocks.ANDROID_STATION.name - override val energy = object : WorkerEnergyStorage(this@AndroidStationBlockEntity::setChangedLight, ::CAPACITY, ::MAX_IO, { null }) { + override val energy = object : WorkerEnergyStorage(this@AndroidStationBlockEntity::setChangedLight, + AndroidStationBlockEntity.Companion::CAPACITY, + AndroidStationBlockEntity.Companion::MAX_IO, { null }) { override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { return super.extractEnergy(howMuch, simulate).also { if (!simulate && this.batteryLevel.isZero) { @@ -49,7 +53,10 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return super.receiveEnergy(howMuch, simulate).also { if (!simulate && it.isPositive) { if (blockState.getValue(WorkerState.SEMI_WORKER_STATE) != WorkerState.WORKING) { - level?.setBlock(blockPos, blockState.setValue(WorkerState.SEMI_WORKER_STATE, WorkerState.WORKING), Block.UPDATE_CLIENTS) + level?.setBlock(blockPos, blockState.setValue( + WorkerState.SEMI_WORKER_STATE, + WorkerState.WORKING + ), Block.UPDATE_CLIENTS) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BatteryBankBlockEntity.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index da1a32af7..56f62e2ab 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -1,10 +1,9 @@ -package ru.dbotthepony.mc.otm.block.entity +package ru.dbotthepony.mc.otm.block.entity.tech import net.minecraft.core.BlockPos import net.minecraft.core.Direction import net.minecraft.nbt.CompoundTag import net.minecraft.network.chat.Component -import net.minecraft.server.level.ServerLevel import net.minecraft.world.Container import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player @@ -18,10 +17,10 @@ import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.energy.IEnergyStorage import org.apache.logging.log4j.LogManager -import ru.dbotthepony.mc.otm.* -import ru.dbotthepony.mc.otm.block.BatteryBankBlock +import ru.dbotthepony.mc.otm.block.tech.BatteryBankBlock import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ChemicalGeneratorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/ChemicalGeneratorBlockEntity.kt similarity index 97% rename from src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ChemicalGeneratorBlockEntity.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/ChemicalGeneratorBlockEntity.kt index d802eb763..31cb59c84 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ChemicalGeneratorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/ChemicalGeneratorBlockEntity.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.block.entity +package ru.dbotthepony.mc.otm.block.entity.tech import net.minecraft.core.BlockPos import net.minecraft.core.Direction @@ -20,6 +20,8 @@ import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.energy.IEnergyStorage import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity +import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.GeneratorEnergyStorage import ru.dbotthepony.mc.otm.container.MatteryContainer diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt index 19cbaf27d..63849e236 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyCounterBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.block.entity +package ru.dbotthepony.mc.otm.block.entity.tech import net.minecraft.core.BlockPos import net.minecraft.core.Direction @@ -6,7 +6,6 @@ import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.IntTag import net.minecraft.nbt.ListTag import net.minecraft.network.chat.Component -import net.minecraft.server.level.ServerLevel import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu @@ -16,8 +15,8 @@ import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.energy.IEnergyStorage -import ru.dbotthepony.mc.otm.* -import ru.dbotthepony.mc.otm.block.EnergyCounterBlock +import ru.dbotthepony.mc.otm.block.tech.EnergyCounterBlock +import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper @@ -32,7 +31,6 @@ import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.BESubscribeList import ru.dbotthepony.mc.otm.menu.EnergyCounterMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities -import java.lang.ref.WeakReference import java.util.* class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryBlockEntity(MBlockEntities.ENERGY_COUNTER, p_155229_, p_155230_) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyServoBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyServoBlockEntity.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt index 36060a13b..ba0c52a5d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/EnergyServoBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.block.entity +package ru.dbotthepony.mc.otm.block.entity.tech import net.minecraft.core.BlockPos import net.minecraft.core.Direction @@ -14,6 +14,7 @@ import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.block.IDroppableContainer +import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.MatteryCapability diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/GravitationStabilizerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/GravitationStabilizerBlockEntity.kt similarity index 90% rename from src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/GravitationStabilizerBlockEntity.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/GravitationStabilizerBlockEntity.kt index d2f25dee2..7fb8defd9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/GravitationStabilizerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/GravitationStabilizerBlockEntity.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.block.entity +package ru.dbotthepony.mc.otm.block.entity.tech import net.minecraft.core.BlockPos import net.minecraft.core.SectionPos @@ -10,10 +10,12 @@ import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.phys.AABB import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.block.BlockGravitationStabilizer -import ru.dbotthepony.mc.otm.block.BlockGravitationStabilizerLens +import ru.dbotthepony.mc.otm.block.tech.BlockGravitationStabilizerLens import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity +import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity +import ru.dbotthepony.mc.otm.block.tech.BlockGravitationStabilizer import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.core.math.times import ru.dbotthepony.mc.otm.registry.MBlockEntities diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/PlatePressBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PlatePressBlockEntity.kt similarity index 94% rename from src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/PlatePressBlockEntity.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PlatePressBlockEntity.kt index 144e2c029..42513baaf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/PlatePressBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PlatePressBlockEntity.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.block.entity +package ru.dbotthepony.mc.otm.block.entity.tech import net.minecraft.core.BlockPos import net.minecraft.core.Direction @@ -15,6 +15,7 @@ import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.ServerConfig import ru.dbotthepony.mc.otm.block.IDroppableContainer +import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.container.MatteryContainer @@ -29,7 +30,9 @@ import ru.dbotthepony.mc.otm.core.nbt.set class PlatePressBlockEntity( p_155229_: BlockPos, p_155230_: BlockState -) : MatteryWorkerBlockEntity(MBlockEntities.PLATE_PRESS, p_155229_, p_155230_, ::ItemJob), IDroppableContainer { +) : MatteryWorkerBlockEntity(MBlockEntities.PLATE_PRESS, p_155229_, p_155230_, + ::ItemJob +), IDroppableContainer { val container = MatteryContainer(this::setChangedLight, 2) override val energy = WorkerEnergyStorage(this::setChangedLight, ServerConfig.PLATE_PRESS) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt index 7ceaff35d..853fa5849 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt @@ -4,22 +4,16 @@ import net.minecraft.core.BlockPos import net.minecraft.core.Direction import net.minecraft.world.item.context.BlockPlaceContext import net.minecraft.world.level.BlockGetter -import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.EntityBlock import net.minecraft.world.level.block.entity.BlockEntity -import net.minecraft.world.level.block.entity.BlockEntityTicker -import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape -import ru.dbotthepony.mc.otm.block.BatteryBankBlock +import ru.dbotthepony.mc.otm.block.tech.BatteryBankBlock import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock -import ru.dbotthepony.mc.otm.block.entity.SynchronizedBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterCapacitorBankBlockEntity -import ru.dbotthepony.mc.otm.block.blockServerTicker -import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes class MatterCapacitorBankBlock : RotatableMatteryBlock(), EntityBlock { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/AndroidStationBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidStationBlock.kt similarity index 94% rename from src/main/kotlin/ru/dbotthepony/mc/otm/block/AndroidStationBlock.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidStationBlock.kt index d128ac6e1..722b13328 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/AndroidStationBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidStationBlock.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.block +package ru.dbotthepony.mc.otm.block.tech import net.minecraft.core.BlockPos import net.minecraft.network.chat.Component @@ -19,7 +19,8 @@ import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.phys.BlockHitResult import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape -import ru.dbotthepony.mc.otm.block.entity.AndroidStationBlockEntity +import ru.dbotthepony.mc.otm.block.MatteryBlock +import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.capability.MatteryCapability diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/BatteryBankBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/mc/otm/block/BatteryBankBlock.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt index 7d6051719..7e2fb9fa5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/BatteryBankBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.block +package ru.dbotthepony.mc.otm.block.tech import net.minecraft.MethodsReturnNonnullByDefault import javax.annotation.ParametersAreNonnullByDefault @@ -12,13 +12,13 @@ import net.minecraft.world.level.block.entity.BlockEntityTicker import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.core.BlockPos import net.minecraft.core.Direction -import ru.dbotthepony.mc.otm.block.entity.BatteryBankBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.BatteryBankBlockEntity import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape -import ru.dbotthepony.mc.otm.once +import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.oncePre import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/ChemicalGeneratorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/mc/otm/block/ChemicalGeneratorBlock.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt index b9cbe031f..f46063df1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/ChemicalGeneratorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.block +package ru.dbotthepony.mc.otm.block.tech import net.minecraft.ChatFormatting import net.minecraft.core.BlockPos @@ -19,7 +19,8 @@ import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape -import ru.dbotthepony.mc.otm.block.entity.ChemicalGeneratorBlockEntity +import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.entity.tech.ChemicalGeneratorBlockEntity import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.capability.energy.GeneratorEnergyStorage diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/EnergyCounterBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyCounterBlock.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/mc/otm/block/EnergyCounterBlock.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyCounterBlock.kt index 0a560257a..1cebd30df 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/EnergyCounterBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyCounterBlock.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.block +package ru.dbotthepony.mc.otm.block.tech import net.minecraft.core.BlockPos import net.minecraft.core.Direction @@ -16,9 +16,9 @@ import net.minecraft.world.level.block.state.properties.EnumProperty import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.SERVER_IS_LIVE -import ru.dbotthepony.mc.otm.block.entity.EnergyCounterBlockEntity +import ru.dbotthepony.mc.otm.block.MatteryBlock +import ru.dbotthepony.mc.otm.block.entity.tech.EnergyCounterBlockEntity import ru.dbotthepony.mc.otm.once -import ru.dbotthepony.mc.otm.onceServer import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/EnergyServoBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt similarity index 92% rename from src/main/kotlin/ru/dbotthepony/mc/otm/block/EnergyServoBlock.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt index d81a6e62c..3fc8b7c37 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/EnergyServoBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.block +package ru.dbotthepony.mc.otm.block.tech import net.minecraft.core.BlockPos import net.minecraft.core.Direction @@ -13,7 +13,8 @@ import net.minecraft.world.level.material.Material import net.minecraft.world.level.material.MaterialColor import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape -import ru.dbotthepony.mc.otm.block.entity.EnergyServoBlockEntity +import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.entity.tech.EnergyServoBlockEntity import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/GravitationStabilizerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt similarity index 97% rename from src/main/kotlin/ru/dbotthepony/mc/otm/block/GravitationStabilizerBlock.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt index ca8d0ce25..146af6a17 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/GravitationStabilizerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.block +package ru.dbotthepony.mc.otm.block.tech import net.minecraft.core.BlockPos import net.minecraft.core.Direction @@ -22,7 +22,8 @@ import net.minecraft.world.level.material.MaterialColor import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape -import ru.dbotthepony.mc.otm.block.entity.GravitationStabilizerBlockEntity +import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.entity.tech.GravitationStabilizerBlockEntity import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.core.math.plus diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/PhantomAttractorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/block/PhantomAttractorBlock.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt index 65ac7a89a..deada4a16 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/PhantomAttractorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.block +package ru.dbotthepony.mc.otm.block.tech import net.minecraft.core.BlockPos import net.minecraft.server.level.ServerLevel @@ -25,6 +25,7 @@ import net.minecraft.world.phys.AABB import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import net.minecraftforge.common.ForgeHooks +import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.minus import ru.dbotthepony.mc.otm.core.math.plus diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/PlatePressBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt similarity index 94% rename from src/main/kotlin/ru/dbotthepony/mc/otm/block/PlatePressBlock.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt index 1e54ad9b9..ef0b6e008 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/PlatePressBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.block +package ru.dbotthepony.mc.otm.block.tech import net.minecraft.core.BlockPos import net.minecraft.core.Direction @@ -16,8 +16,9 @@ import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape +import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity -import ru.dbotthepony.mc.otm.block.entity.PlatePressBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt index 72babc852..08a96b8bb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt @@ -6,7 +6,7 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRenderer import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider import net.minecraft.core.Direction import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock -import ru.dbotthepony.mc.otm.block.entity.BatteryBankBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.BatteryBankBlockEntity import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterCapacitorBankBlockEntity import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt index ea28c7fb4..b88da50cc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt @@ -12,7 +12,7 @@ import net.minecraft.world.phys.Vec3 import org.joml.Matrix4f import org.lwjgl.opengl.GL30 import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.block.entity.GravitationStabilizerBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.GravitationStabilizerBlockEntity import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/EnergyCounterRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/EnergyCounterRenderer.kt index 008242080..fccd11b5c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/EnergyCounterRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/EnergyCounterRenderer.kt @@ -6,8 +6,8 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRenderer import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider import net.minecraft.core.Direction import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.block.EnergyCounterBlock -import ru.dbotthepony.mc.otm.block.entity.EnergyCounterBlockEntity +import ru.dbotthepony.mc.otm.block.tech.EnergyCounterBlock +import ru.dbotthepony.mc.otm.block.entity.tech.EnergyCounterBlockEntity import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.core.math.RGBAColor diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt index 140842d68..c0f0819c9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt @@ -13,7 +13,7 @@ import org.joml.Matrix4f import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.block.BlackHoleBlock import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock -import ru.dbotthepony.mc.otm.block.entity.GravitationStabilizerBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.GravitationStabilizerBlockEntity import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.client.minecraft diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt index aafad7d12..0f62c7a4d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt @@ -16,7 +16,7 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.android.AndroidResearch import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidResearchType -import ru.dbotthepony.mc.otm.block.entity.AndroidStationBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.client.minecraft diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/MinecartCargoCrate.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/MinecartCargoCrate.kt index 3f6ded63c..6f205d8f8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/MinecartCargoCrate.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/MinecartCargoCrate.kt @@ -15,8 +15,8 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.gameevent.GameEvent -import ru.dbotthepony.mc.otm.block.CargoCrateBlock -import ru.dbotthepony.mc.otm.block.entity.CargoCrateBlockEntity +import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock +import ru.dbotthepony.mc.otm.block.entity.decorative.CargoCrateBlockEntity import ru.dbotthepony.mc.otm.core.position import ru.dbotthepony.mc.otm.menu.MinecartCargoCrateMenu import ru.dbotthepony.mc.otm.registry.MItems diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/AndroidStationMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/AndroidStationMenu.kt index 99e112c41..1c61ad696 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/AndroidStationMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/AndroidStationMenu.kt @@ -9,13 +9,10 @@ import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack import net.minecraftforge.common.capabilities.ForgeCapabilities -import ru.dbotthepony.mc.otm.block.entity.AndroidStationBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability -import ru.dbotthepony.mc.otm.capability.energy -import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.registry.MMenus -import java.util.* import kotlin.reflect.KMutableProperty0 class AndroidStationMenu @JvmOverloads constructor( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/BatteryBankMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/BatteryBankMenu.kt index 9cd7da508..8bb3fa687 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/BatteryBankMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/BatteryBankMenu.kt @@ -1,12 +1,10 @@ package ru.dbotthepony.mc.otm.menu -import com.google.common.collect.ImmutableList import net.minecraft.world.Container import kotlin.jvm.JvmOverloads import net.minecraft.world.entity.player.Inventory -import ru.dbotthepony.mc.otm.block.entity.BatteryBankBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.BatteryBankBlockEntity import net.minecraft.world.SimpleContainer -import net.minecraft.world.inventory.Slot import ru.dbotthepony.mc.otm.core.ImmutableList import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.capability.MatteryCapability diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/CargoCrateMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/CargoCrateMenu.kt index 65352ffdd..b3681244f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/CargoCrateMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/CargoCrateMenu.kt @@ -4,7 +4,7 @@ import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import ru.dbotthepony.mc.otm.core.ImmutableList -import ru.dbotthepony.mc.otm.block.entity.CargoCrateBlockEntity +import ru.dbotthepony.mc.otm.block.entity.decorative.CargoCrateBlockEntity import ru.dbotthepony.mc.otm.registry.MMenus class CargoCrateMenu @JvmOverloads constructor( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ChemicalGeneratorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ChemicalGeneratorMenu.kt index fb629b5fa..f01b5a004 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ChemicalGeneratorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ChemicalGeneratorMenu.kt @@ -5,7 +5,7 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack import net.minecraftforge.common.ForgeHooks import net.minecraftforge.common.capabilities.ForgeCapabilities -import ru.dbotthepony.mc.otm.block.entity.ChemicalGeneratorBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.ChemicalGeneratorBlockEntity import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyCounterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyCounterMenu.kt index 87af8898d..f480dbbd2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyCounterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyCounterMenu.kt @@ -5,8 +5,8 @@ import kotlin.jvm.JvmOverloads import net.minecraft.world.entity.player.Inventory import net.minecraft.world.inventory.Slot import net.minecraft.world.level.block.Block -import ru.dbotthepony.mc.otm.block.EnergyCounterBlock -import ru.dbotthepony.mc.otm.block.entity.EnergyCounterBlockEntity +import ru.dbotthepony.mc.otm.block.tech.EnergyCounterBlock +import ru.dbotthepony.mc.otm.block.entity.tech.EnergyCounterBlockEntity import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.menu.widget.NumberPlayerInputWidget import ru.dbotthepony.mc.otm.menu.widget.OneWayPlayerInputWidget diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyServoMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyServoMenu.kt index 858247fa8..a96ca4071 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyServoMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyServoMenu.kt @@ -5,7 +5,7 @@ import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack -import ru.dbotthepony.mc.otm.block.entity.EnergyServoBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.EnergyServoBlockEntity import ru.dbotthepony.mc.otm.capability.energy import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MinecartCargoCrateMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MinecartCargoCrateMenu.kt index e5d07b566..e6564d7d0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MinecartCargoCrateMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MinecartCargoCrateMenu.kt @@ -5,7 +5,7 @@ import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import ru.dbotthepony.mc.otm.core.ImmutableList -import ru.dbotthepony.mc.otm.block.entity.CargoCrateBlockEntity +import ru.dbotthepony.mc.otm.block.entity.decorative.CargoCrateBlockEntity import ru.dbotthepony.mc.otm.entity.MinecartCargoCrate import ru.dbotthepony.mc.otm.registry.MMenus diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/PlatePressMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/PlatePressMenu.kt index a4fc2680b..ecf50b2bb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/PlatePressMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/PlatePressMenu.kt @@ -3,8 +3,7 @@ package ru.dbotthepony.mc.otm.menu import com.google.common.collect.ImmutableList import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory -import net.minecraft.world.inventory.Slot -import ru.dbotthepony.mc.otm.block.entity.PlatePressBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt index 784ca124b..29f1431c4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt @@ -7,16 +7,14 @@ import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation import net.minecraft.world.Container import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.Items import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.item.crafting.Recipe import net.minecraft.world.item.crafting.RecipeSerializer import net.minecraft.world.item.crafting.RecipeType import net.minecraft.world.level.Level -import net.minecraftforge.common.ForgeHooks import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.block.entity.PlatePressBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity import ru.dbotthepony.mc.otm.container.get import ru.dbotthepony.mc.otm.core.isActuallyEmpty import ru.dbotthepony.mc.otm.registry.MRecipes 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 047198565..4617a7940 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt @@ -8,11 +8,18 @@ import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.block.entity.* +import ru.dbotthepony.mc.otm.block.entity.tech.* import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity import ru.dbotthepony.mc.otm.block.entity.blackhole.BlockEntityExplosionDebugger import ru.dbotthepony.mc.otm.block.entity.blackhole.BlockEntitySphereDebugger +import ru.dbotthepony.mc.otm.block.entity.decorative.CargoCrateBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.* import ru.dbotthepony.mc.otm.block.entity.storage.* +import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.BatteryBankBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.EnergyServoBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.GravitationStabilizerBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity import ru.dbotthepony.mc.otm.client.render.blockentity.BatteryBankRenderer import ru.dbotthepony.mc.otm.client.render.blockentity.BlackHoleRenderer import ru.dbotthepony.mc.otm.client.render.blockentity.EnergyCounterRenderer 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 f495dc588..69472a02e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -27,21 +27,21 @@ 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.block.AndroidStationBlock -import ru.dbotthepony.mc.otm.block.BatteryBankBlock +import ru.dbotthepony.mc.otm.block.tech.AndroidStationBlock +import ru.dbotthepony.mc.otm.block.tech.BatteryBankBlock import ru.dbotthepony.mc.otm.block.BlackHoleBlock import ru.dbotthepony.mc.otm.block.BlockExplosionDebugger -import ru.dbotthepony.mc.otm.block.BlockGravitationStabilizer -import ru.dbotthepony.mc.otm.block.BlockGravitationStabilizerLens +import ru.dbotthepony.mc.otm.block.tech.BlockGravitationStabilizer +import ru.dbotthepony.mc.otm.block.tech.BlockGravitationStabilizerLens import ru.dbotthepony.mc.otm.block.BlockSphereDebugger -import ru.dbotthepony.mc.otm.block.ChemicalGeneratorBlock -import ru.dbotthepony.mc.otm.block.EnergyCounterBlock -import ru.dbotthepony.mc.otm.block.EnergyServoBlock +import ru.dbotthepony.mc.otm.block.tech.ChemicalGeneratorBlock +import ru.dbotthepony.mc.otm.block.tech.EnergyCounterBlock +import ru.dbotthepony.mc.otm.block.tech.EnergyServoBlock import ru.dbotthepony.mc.otm.block.decorative.LaboratoryLamp import ru.dbotthepony.mc.otm.block.decorative.LaboratoryLampLight import ru.dbotthepony.mc.otm.block.MatterCableBlock -import ru.dbotthepony.mc.otm.block.PhantomAttractorBlock -import ru.dbotthepony.mc.otm.block.PlatePressBlock +import ru.dbotthepony.mc.otm.block.tech.PhantomAttractorBlock +import ru.dbotthepony.mc.otm.block.tech.PlatePressBlock import ru.dbotthepony.mc.otm.block.StorageCableBlock import ru.dbotthepony.mc.otm.block.decorative.EngineBlock import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock 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 ccac6679f..e7bfac5fb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -24,8 +24,8 @@ import ru.dbotthepony.mc.otm.android.feature.ItemMagnetFeature import ru.dbotthepony.mc.otm.android.feature.JumpBoostFeature import ru.dbotthepony.mc.otm.android.feature.NanobotsArmorFeature import ru.dbotthepony.mc.otm.android.feature.ShockwaveFeature -import ru.dbotthepony.mc.otm.block.CargoCrateBlock -import ru.dbotthepony.mc.otm.block.TritaniumPressurePlate +import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock +import ru.dbotthepony.mc.otm.block.decorative.TritaniumPressurePlate import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.item.EnergySwordItem From 48bda405cdc1991db7efac036d4ee3c4f2a28bad Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 23 Jan 2023 23:37:03 +0700 Subject: [PATCH 0081/1199] Holo sign test --- .../mc/otm/datagen/lang/English.kt | 1 + .../mc/otm/datagen/lang/Russian.kt | 1 + .../mc/otm/datagen/loot/LootTablesData.kt | 3 ++ .../datagen/recipes/CraftingTableRecipes.kt | 5 +++ .../dbotthepony/mc/otm/datagen/tags/Tags.kt | 1 + .../mc/otm/block/decorative/HoloSignBlock.kt | 17 ++++++++ .../entity/decorative/HoloSignBlockEntity.kt | 41 +++++++++++++++++++ .../render/blockentity/HoloSignRenderer.kt | 36 ++++++++++++++++ .../mc/otm/core/util/DataStreams.kt | 15 +++++++ .../dbotthepony/mc/otm/menu/HoloSignMenu.kt | 15 +++++++ .../mc/otm/network/FieldSynchronizer.kt | 10 +++++ .../mc/otm/registry/CreativeTabs.kt | 1 + .../mc/otm/registry/MBlockEntities.kt | 5 +++ .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 2 + .../ru/dbotthepony/mc/otm/registry/MItems.kt | 1 + .../ru/dbotthepony/mc/otm/registry/MMenus.kt | 1 + .../ru/dbotthepony/mc/otm/registry/MNames.kt | 1 + 17 files changed, 156 insertions(+) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/HoloSignRenderer.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/HoloSignMenu.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 99a6e7856..6729cade1 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -372,6 +372,7 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.BLACK_HOLE, "Local Anomalous Singular Gravitation Field") add(MBlocks.ENGINE, "Ship Engine") + add(MBlocks.HOLO_SIGN, "Holo Sign") add(MBlocks.TRITANIUM_INGOT_BLOCK, "Tritanium Plating Block") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index bec55be61..8658d3e89 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -377,6 +377,7 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.BLACK_HOLE, "Локализированное Аномальное Сингулярное Гравитационное Поле") add(MBlocks.ENGINE, "Двигатель Корабля") + add(MBlocks.HOLO_SIGN, "Голографическая Табличка") add(MBlocks.TRITANIUM_INGOT_BLOCK, "Блок Слитков Тритана") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index dd4a30389..3b0d5f6f3 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -12,6 +12,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity.Companion.ENERGY_KE import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity.Companion.MATTER_STORAGE_KEY import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity.Companion.REDSTONE_SETTING_KEY import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity.Companion.REDSTONE_SIGNAL_KEY +import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.AbstractStorageImportExport.Companion.FILTER_KEY import ru.dbotthepony.mc.otm.block.entity.storage.StoragePowerSupplierBlockEntity @@ -145,6 +146,8 @@ fun addLootTables(lootTables: LootTables) { REDSTONE_SETTING_KEY, ) + lootTables.tile(MBlocks.HOLO_SIGN, HoloSignBlockEntity.TEXT_KEY) + lootTables.dropsSelf(MBlocks.STORAGE_CABLE) lootTables.poweredTile(MBlocks.ANDROID_STATION) lootTables.basicTile(MBlocks.BATTERY_BANK) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index a2eac90db..2cda8c5f5 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -48,6 +48,11 @@ fun addCraftingTableRecipes(consumer: Consumer) { .unlockedBy(MItems.ENERGY_COUNTER) .save(consumer, modLocation("energy_counter_reset")) + ShapelessRecipeBuilder(machinesCategory, MItems.HOLO_SIGN, 1) + .requires(MItems.HOLO_SIGN) + .unlockedBy(MItems.HOLO_SIGN) + .save(consumer, modLocation("holo_sign_reset")) + MatteryRecipe(MBlocks.PLATE_PRESS, category = machinesCategory) .row(MItems.ELECTRIC_PARTS, MItems.ENERGY_BUS, MItems.ELECTRIC_PARTS) .row(MItemTags.TRITANIUM_INGOTS, Items.BLAST_FURNACE, MItemTags.TRITANIUM_INGOTS) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index c31990cbe..e726c1a6e 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -144,6 +144,7 @@ fun addTags(tagsProvider: TagsProvider) { MBlocks.TRITANIUM_INGOT_BLOCK, MBlocks.ENGINE, + MBlocks.HOLO_SIGN, ), Tiers.IRON) tagsProvider.requiresPickaxe(MBlocks.TRITANIUM_ORE, Tiers.IRON) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt new file mode 100644 index 000000000..f49adacbd --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt @@ -0,0 +1,17 @@ +package ru.dbotthepony.mc.otm.block.decorative + +import net.minecraft.core.BlockPos +import net.minecraft.world.level.block.EntityBlock +import net.minecraft.world.level.block.entity.BlockEntity +import net.minecraft.world.level.block.state.BlockState +import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity + +class HoloSignBlock : RotatableMatteryBlock(), EntityBlock { + override val hasFreeRotation: Boolean + get() = true + + override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { + return HoloSignBlockEntity(p_153215_, p_153216_) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt new file mode 100644 index 000000000..ba6eec801 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt @@ -0,0 +1,41 @@ +package ru.dbotthepony.mc.otm.block.entity.decorative + +import net.minecraft.core.BlockPos +import net.minecraft.nbt.CompoundTag +import net.minecraft.network.chat.Component +import net.minecraft.world.MenuProvider +import net.minecraft.world.entity.player.Inventory +import net.minecraft.world.entity.player.Player +import net.minecraft.world.inventory.AbstractContainerMenu +import net.minecraft.world.level.block.state.BlockState +import ru.dbotthepony.mc.otm.block.entity.SynchronizedBlockEntity +import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.menu.HoloSignMenu +import ru.dbotthepony.mc.otm.registry.MBlockEntities +import ru.dbotthepony.mc.otm.registry.MBlocks + +class HoloSignBlockEntity(blockPos: BlockPos, blockState: BlockState) : SynchronizedBlockEntity(MBlockEntities.HOLO_SIGN, blockPos, blockState), MenuProvider { + var text by synchronizer.string("АМОГУС", name = "text") + + override fun createMenu(p_39954_: Int, p_39955_: Inventory, p_39956_: Player): AbstractContainerMenu { + return HoloSignMenu(p_39954_, p_39955_, this) + } + + override fun getDisplayName(): Component { + return MBlocks.HOLO_SIGN.name + } + + override fun saveAdditional(p_187471_: CompoundTag) { + super.saveAdditional(p_187471_) + p_187471_[TEXT_KEY] = text + } + + override fun load(p_155245_: CompoundTag) { + super.load(p_155245_) + text = p_155245_.getString(TEXT_KEY) + } + + companion object { + const val TEXT_KEY = "SignText" + } +} 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 new file mode 100644 index 000000000..a06a15d92 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/HoloSignRenderer.kt @@ -0,0 +1,36 @@ +package ru.dbotthepony.mc.otm.client.render.blockentity + +import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.renderer.MultiBufferSource +import net.minecraft.client.renderer.blockentity.BlockEntityRenderer +import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider +import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity +import ru.dbotthepony.mc.otm.client.font +import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource +import ru.dbotthepony.mc.otm.client.render.TextAlign +import ru.dbotthepony.mc.otm.client.render.drawAligned +import ru.dbotthepony.mc.otm.core.math.RGBAColor +import ru.dbotthepony.mc.otm.core.math.rotateX +import ru.dbotthepony.mc.otm.core.math.rotateY + +class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer { + override fun render( + tile: HoloSignBlockEntity, + partialTick: Float, + poseStack: PoseStack, + badSorse: MultiBufferSource, + p_112311_: Int, + p_112312_: Int + ) { + poseStack.pushPose() + poseStack.translate(0.5f, 0.5f, -0.1f) + poseStack.rotateX(Math.PI.toFloat()) + poseStack.rotateY(Math.PI.toFloat()) + poseStack.scale(0.01f, 0.01f, 0.01f) + + val sorse = DynamicBufferSource.WORLD + + font.drawAligned(poseStack = poseStack, buffer = sorse, text = tile.text, align = TextAlign.CENTER_CENTER, x = 0f, y = 0f, color = RGBAColor.BLUE.toInt()) + poseStack.popPose() + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt index 095b0addd..a41e5a94e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt @@ -73,6 +73,7 @@ val BigDecimalValueCodec = StreamCodec(DataInputStream::readBigDecimal, DataOutp val UUIDValueCodec = StreamCodec({ s -> UUID(s.readLong(), s.readLong()) }, { s, v -> s.writeLong(v.mostSignificantBits); s.writeLong(v.leastSignificantBits) }) val VarIntValueCodec = StreamCodec(DataInputStream::readVarIntLE, DataOutputStream::writeVarIntLE) val VarLongValueCodec = StreamCodec(DataInputStream::readVarLongLE, DataOutputStream::writeVarLongLE) +val BinaryStringCodec = StreamCodec(DataInputStream::readBinaryString, DataOutputStream::writeBinaryString) class EnumValueCodec>(private val clazz: Class) : IStreamCodec { private val values = clazz.enumConstants @@ -248,6 +249,19 @@ fun OutputStream.writeVarLongLE(value: Long) { } } +fun InputStream.readBinaryString(): String { + val size = readVarIntLE() + val bytes = ByteArray(size) + read(bytes) + return bytes.decodeToString() +} + +fun OutputStream.writeBinaryString(input: String) { + val bytes = input.encodeToByteArray() + writeVarIntLE(bytes.size) + write(bytes) +} + private data class IndexedStreamCodec( val condition: Predicate, val id: Int, @@ -282,6 +296,7 @@ private val codecs: List> = com.google.common.collect.Immu it.add(IndexedStreamCodec(codecID++, ImpreciseFractionValueCodec)) it.add(IndexedStreamCodec(codecID++, BigDecimalValueCodec)) it.add(IndexedStreamCodec(codecID++, UUIDValueCodec)) + it.add(IndexedStreamCodec(codecID++, BinaryStringCodec)) it.build() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/HoloSignMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/HoloSignMenu.kt new file mode 100644 index 000000000..b031f4b1d --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/HoloSignMenu.kt @@ -0,0 +1,15 @@ +package ru.dbotthepony.mc.otm.menu + +import net.minecraft.world.entity.player.Inventory +import net.minecraft.world.inventory.Slot +import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity +import ru.dbotthepony.mc.otm.registry.MMenus + +class HoloSignMenu @JvmOverloads constructor( + containerId: Int, + inventory: Inventory, + tile: HoloSignBlockEntity? = null +) : MatteryMenu(MMenus.HOLO_SIGN, containerId, inventory, tile) { + override val storageSlots: Collection + get() = listOf() +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt index 1761b0832..9ac6c20c1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt @@ -14,6 +14,7 @@ import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.collect.ProxiedMap import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.util.BigDecimalValueCodec +import ru.dbotthepony.mc.otm.core.util.BinaryStringCodec import ru.dbotthepony.mc.otm.core.util.BooleanValueCodec import ru.dbotthepony.mc.otm.core.util.ByteValueCodec import ru.dbotthepony.mc.otm.core.util.DoubleValueCodec @@ -289,6 +290,15 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return Field(value, VarIntValueCodec, getter, setter, name = name) } + fun string( + value: String = "", + getter: FieldGetter? = null, + setter: FieldSetter? = null, + name: String = nextFieldName(), + ): Field { + return Field(value, BinaryStringCodec, getter, setter, name = name) + } + fun fixedInt( value: Int = 0, getter: FieldGetter? = null, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt index ea4040cb5..4e43c9d01 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt @@ -102,6 +102,7 @@ internal fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { accept(MItems.MACHINES) accept(MRegistry.CARGO_CRATES.item) + accept(MItems.HOLO_SIGN) base(MItems.TRITANIUM_DOOR) base(MItems.TRITANIUM_TRAPDOOR) 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 4617a7940..3f80fa3c3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt @@ -13,6 +13,7 @@ import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity import ru.dbotthepony.mc.otm.block.entity.blackhole.BlockEntityExplosionDebugger import ru.dbotthepony.mc.otm.block.entity.blackhole.BlockEntitySphereDebugger import ru.dbotthepony.mc.otm.block.entity.decorative.CargoCrateBlockEntity +import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.* import ru.dbotthepony.mc.otm.block.entity.storage.* import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity @@ -24,6 +25,7 @@ import ru.dbotthepony.mc.otm.client.render.blockentity.BatteryBankRenderer import ru.dbotthepony.mc.otm.client.render.blockentity.BlackHoleRenderer import ru.dbotthepony.mc.otm.client.render.blockentity.EnergyCounterRenderer import ru.dbotthepony.mc.otm.client.render.blockentity.GravitationStabilizerRenderer +import ru.dbotthepony.mc.otm.client.render.blockentity.HoloSignRenderer import ru.dbotthepony.mc.otm.client.render.blockentity.MatterBatteryBankRenderer import ru.dbotthepony.mc.otm.client.render.blockentity.MatterReplicatorRenderer @@ -62,6 +64,8 @@ object MBlockEntities { val STORAGE_EXPORTER: BlockEntityType<*> by registry.register(MNames.STORAGE_EXPORTER) { BlockEntityType.Builder.of(::StorageExporterBlockEntity, MBlocks.STORAGE_EXPORTER).build(null) } val STORAGE_POWER_SUPPLIER: BlockEntityType<*> by registry.register(MNames.STORAGE_POWER_SUPPLIER) { BlockEntityType.Builder.of(::StoragePowerSupplierBlockEntity, MBlocks.STORAGE_POWER_SUPPLIER).build(null) } + val HOLO_SIGN: BlockEntityType by registry.register(MNames.HOLO_SIGN) { BlockEntityType.Builder.of(::HoloSignBlockEntity, MBlocks.HOLO_SIGN).build(null) } + val DEBUG_EXPLOSION_SMALL: BlockEntityType<*> by registry.register(MNames.DEBUG_EXPLOSION_SMALL) { BlockEntityType.Builder.of(::BlockEntityExplosionDebugger, MBlocks.DEBUG_EXPLOSION_SMALL).build(null) } val DEBUG_SPHERE_POINTS: BlockEntityType<*> by registry.register(MNames.DEBUG_SPHERE_POINTS) { BlockEntityType.Builder.of(::BlockEntitySphereDebugger, MBlocks.DEBUG_SPHERE_POINTS).build(null) } @@ -79,6 +83,7 @@ object MBlockEntities { BlockEntityRenderers.register(BATTERY_BANK as BlockEntityType, ::BatteryBankRenderer) BlockEntityRenderers.register(MATTER_CAPACITOR_BANK as BlockEntityType, ::MatterBatteryBankRenderer) BlockEntityRenderers.register(MATTER_REPLICATOR as BlockEntityType, ::MatterReplicatorRenderer) + BlockEntityRenderers.register(HOLO_SIGN, ::HoloSignRenderer) } } } 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 69472a02e..610485890 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -44,6 +44,7 @@ import ru.dbotthepony.mc.otm.block.tech.PhantomAttractorBlock import ru.dbotthepony.mc.otm.block.tech.PlatePressBlock import ru.dbotthepony.mc.otm.block.StorageCableBlock import ru.dbotthepony.mc.otm.block.decorative.EngineBlock +import ru.dbotthepony.mc.otm.block.decorative.HoloSignBlock import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock import ru.dbotthepony.mc.otm.block.matter.MatterCapacitorBankBlock import ru.dbotthepony.mc.otm.block.matter.MatterDecomposerBlock @@ -133,6 +134,7 @@ object MBlocks { val DANGER_STRIPE_BLOCK: Block by registry.register(MNames.DANGER_STRIPE_BLOCK) { Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.GRAY).explosionResistance(6f).destroyTime(1.5f).requiresCorrectToolForDrops()) } val METAL_BEAM: Block by registry.register(MNames.METAL_BEAM) { Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.GRAY).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) } val ENGINE: Block by registry.register(MNames.ENGINE) { EngineBlock() } + val HOLO_SIGN: Block by registry.register(MNames.HOLO_SIGN) { HoloSignBlock() } val TRITANIUM_DOOR = registry.allColored(MNames.TRITANIUM_DOOR) { color, _ -> object : DoorBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), SoundEvents.IRON_DOOR_CLOSE, SoundEvents.IRON_DOOR_OPEN) { 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 9aedf07d7..9d123f2bb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -266,6 +266,7 @@ object MItems { val DANGER_STRIPE_BLOCK: Item by registry.register(MNames.DANGER_STRIPE_BLOCK) { BlockItem(MBlocks.DANGER_STRIPE_BLOCK, DEFAULT_PROPERTIES) } val METAL_BEAM: Item by registry.register(MNames.METAL_BEAM) { BlockItem(MBlocks.METAL_BEAM, DEFAULT_PROPERTIES) } val ENGINE: Item by registry.register(MNames.ENGINE) { BlockItem(MBlocks.ENGINE, DEFAULT_PROPERTIES) } + val HOLO_SIGN: Item by registry.register(MNames.HOLO_SIGN) { BlockItem(MBlocks.HOLO_SIGN, DEFAULT_PROPERTIES) } val TRITANIUM_DOOR = registry.allColored(MNames.TRITANIUM_DOOR) { color, _ -> DoubleHighBlockItem(MBlocks.TRITANIUM_DOOR[color]!!, DEFAULT_PROPERTIES) } val TRITANIUM_TRAPDOOR = registry.allColored(MNames.TRITANIUM_TRAPDOOR) { color, _ -> BlockItem(MBlocks.TRITANIUM_TRAPDOOR[color]!!, DEFAULT_PROPERTIES) } 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 ec03ab814..6df9e3c7c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt @@ -33,6 +33,7 @@ object MMenus { val PLATE_PRESS: MenuType<*> by registry.register(MNames.PLATE_PRESS) { MenuType(::PlatePressMenu) } val MATTER_RECYCLER: MenuType<*> by registry.register(MNames.MATTER_RECYCLER) { MenuType(::MatterRecyclerMenu) } val ENERGY_SERVO: MenuType<*> by registry.register(MNames.ENERGY_SERVO) { MenuType(::EnergyServoMenu) } + val HOLO_SIGN: MenuType<*> by registry.register(MNames.HOLO_SIGN) { MenuType(::HoloSignMenu) } val STORAGE_BUS: MenuType<*> by registry.register(MNames.STORAGE_BUS) { MenuType(::StorageBusMenu) } val STORAGE_EXPORTER: MenuType<*> by registry.register(MNames.STORAGE_EXPORTER) { MenuType(::StorageExporterMenu) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index 4218e4815..228b39c0e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -10,6 +10,7 @@ object MNames { const val DANGER_STRIPE_BLOCK = "danger_stripe_block" const val METAL_BEAM = "metal_beam" const val ENGINE = "engine" + const val HOLO_SIGN = "holo_sign" // blocks const val ANDROID_STATION = "android_station" From 7dffa61bae19b8b5edc7c1758b9bd2b35cff5f63 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 24 Jan 2023 12:09:37 +0700 Subject: [PATCH 0082/1199] rotateWithBlockFacing --- .../render/blockentity/HoloSignRenderer.kt | 11 +-- .../mc/otm/core/math/EuclidMath.kt | 84 +++++++++++++++++++ 2 files changed, 90 insertions(+), 5 deletions(-) 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 a06a15d92..8af4ac339 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 @@ -4,14 +4,16 @@ import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.client.renderer.blockentity.BlockEntityRenderer import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider +import net.minecraft.core.Direction +import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity import ru.dbotthepony.mc.otm.client.font import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.render.TextAlign import ru.dbotthepony.mc.otm.client.render.drawAligned +import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.RGBAColor -import ru.dbotthepony.mc.otm.core.math.rotateX -import ru.dbotthepony.mc.otm.core.math.rotateY +import ru.dbotthepony.mc.otm.core.math.rotateWithBlockFacing class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer { override fun render( @@ -23,9 +25,8 @@ class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context) p_112312_: Int ) { poseStack.pushPose() - poseStack.translate(0.5f, 0.5f, -0.1f) - poseStack.rotateX(Math.PI.toFloat()) - poseStack.rotateY(Math.PI.toFloat()) + poseStack.rotateWithBlockFacing(tile.blockState[RotatableMatteryBlock.FACING_FULL], clarifyingAxis = Direction.SOUTH) + poseStack.translate(0.0f, 0.0f, -0.1f) poseStack.scale(0.01f, 0.01f, 0.01f) val sorse = DynamicBufferSource.WORLD diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/EuclidMath.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/EuclidMath.kt index ce084ea57..2d9c2d4e2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/EuclidMath.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/EuclidMath.kt @@ -561,6 +561,90 @@ fun PoseStack.rotateZ(rotation: Float): PoseStack { return this } +const val PIf = 3.1415927f + +/** + * aligns 0,0 with top left point of block corner when looking directly at it, + * and swaps Y to +Y when going down and -Y when going up + */ +fun PoseStack.rotateWithBlockFacing(rotation: Direction, clarifyingAxis: Direction? = null): PoseStack { + when (rotation) { + Direction.NORTH -> { + rotateX(PIf) + rotateY(PIf) + translate(-1f, -1f, 0f) + } + + Direction.EAST -> { + rotateX(PIf) + rotateY(PIf / -2f) + translate(-1f, -1f, -1f) + } + + Direction.WEST -> { + rotateX(PIf) + rotateY(PIf / 2f) + translate(0f, -1f, 0f) + } + + Direction.UP -> { + rotateX(PIf / 2f) + translate(0f, 0f, -1f) + + if (clarifyingAxis != null) { + when (clarifyingAxis) { + Direction.NORTH -> {} + Direction.SOUTH -> { + rotateZ(PIf) + translate(-1f, -1f, 0f) + } + Direction.WEST -> { + rotateZ(PIf / -2f) + translate(-1f, 0f, 0f) + } + Direction.EAST -> { + rotateZ(PIf / 2f) + translate(0f, -1f, 0f) + } + else -> {} + } + } + } + + Direction.DOWN -> { + rotateY(PIf) + rotateX(PIf / -2f) + translate(-1f, 0f, 0f) + + if (clarifyingAxis != null) { + when (clarifyingAxis) { + Direction.NORTH -> {} + Direction.SOUTH -> { + rotateZ(PIf) + translate(-1f, -1f, 0f) + } + Direction.WEST -> { + rotateZ(PIf / 2f) + translate(0f, -1f, 0f) + } + Direction.EAST -> { + rotateZ(PIf / -2f) + translate(-1f, 0f, 0f) + } + else -> {} + } + } + } + + Direction.SOUTH -> { + rotateX(PIf) + translate(0f, -1f, -1f) + } + } + + return this +} + fun PoseStack.rotateYDegrees(rotation: Float): PoseStack { mulPose(Quaternionf(AxisAngle4f(toRadians(rotation), 0f, 1f, 0f))) return this From 8ba2ef8b9500fe29c6b567d28cdd672627097e7d Mon Sep 17 00:00:00 2001 From: GearShocky Date: Tue, 24 Jan 2023 12:43:05 +0600 Subject: [PATCH 0083/1199] matter-bottled --- .../textures/block/matter_bottler.png | Bin 536 -> 735 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/matter_bottler.png b/src/main/resources/assets/overdrive_that_matters/textures/block/matter_bottler.png index e440f0e488f9e9ad68b8d2927c11daf66d783c4b..a3e712419f86a609a4749e58bb4bc665be8c5b90 100644 GIT binary patch delta 682 zcmV;b0#*H(1m6XaL4Q9`OjJcRH8m?MD;5?OR8&;k+uQ&D|Nqzk|KLerU|@fLe^F6U zwEzJB0044wa%OpiZGw+S|GPKFkX>(jCMG5T006bX@$mov02OpnPE-H?|NsC0|NsC0 z|NsC0|NsC0|Nj6h*?sB&000SaNLh0L01m$Z01m$aI0aKA0Dk}i2uVaiR7gvum5Fl0 zAPht~YzK0Xw$A^5Yj-69#`Ywg=__N9K#MFx>XaAo-Ur1;@8Q(Wqr-#UG|j>^an*8J z7RDwv5x^jmHHjmlZF8WE|;7)0@#dx;A;qWMr+nyU|A?|WmAEgK@S<_ z&NJ8w&<|ROq<_?{E^xcwZaF1{p9{##vuw0b3ajN-;C@fw@xa2EQdH1W(#eqXFezP` z#Er+q45~nx=jZboqc%w*!l9H=pnb-g0e5?ffKjj~_BRWtZ5c5^(*hL0i$~4CfPjq@ z*u{nbD^(!7{D@!Q_=_%$0%@~5plzjv@;sL)0xVP#fqx_deUp;XW=FLvl7R|rGvF&= zQo~A#kxMNA57;$>!j%xf_v8WP*X6+dOw&&X_P}6cC2G)5Cg4#I`gKX5W~fC^-By$K zK>){(14V}KZB%e4;KSMoux)(}lcEjmU%`b{YJ!(p15KHIC(v#RVToxAygQ!-I#=LU z?r$K6^?&aIaub|eTe$FF0e=v1xUt$Su7TeZfGxM22w;sii)--L0J@(t@HtzvxCVa7 zt`x9^ieGKEp=Xc>)f|mK3iOQ3v12FTjsjXiG|0zn-p-*0=5OGnS);%)jl)4Qe`65P ze_;cd8IQ908}L~JX99Ye6kaCtH&%(}6X~Us8YAqlv-ul%MV(`JsKM*?3ykSTLC9ov QrvLx|07*qoM6N<$f)Lj~y#N3J delta 481 zcmcc5I)i0`W4%FuPl&6jsi~NlSVBU=?c2Bi1Hlc3{|`Lt>+1sp1Gh3T{AXauZR&Ub zzuWxSgxLHl1_p*nnOj|flt4+4Uoc2L5@2|s94iTw<1FxqEM{Qf+YiEw7OcT43=E8+ zo-U3d9^QMWb`~90;Bk>nWUrUc{qw*6wrEuM;k=JqX6`d!jyk-E;}Op>z6-WJjy}1& z1&+CJSY=oFO@5hSGGWDuOx4|j_f{q@U^}1Q^Kzr~3O+yWn_Jl~FJarf?Y+^8x9f~G zcthB0n^R+_X*50EZx#{GIP2g7=Htt(%Iw%1SFxORV9(mn`*>Tf(zQ$Tm>RFJ)z|g7 zv+bHKDdW&|jv?aB6v@mU{W_xu4IzeUvm9j#!sO@wcyL6jIjNl0(3@NR%#nEtqOZ0& z9^?Ht&CxFGvFIV~<{gW=424ZIcxP#Sf5hF)UOl1B{&+2OTl=i8u#b7nYu7J!yslu( z?5DjWH$m0za~|^@OS5&wUyjeY$Ikmdy&=l{W=-OO<$UWE7Cg9PazZjNW5aURD|7#d zHn^;sxn)JmuIAH6+1|*nP}0>}_^yQa)@q--FQr7-r?p*~d+Wg_HreJ$!EC?(vF4WO V?TR@qr3(yr22WQ%mvv4FO#nyY)&l?l From 472cb057a5f6d8d764acac5a7106063c3ec2d7e1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 25 Jan 2023 14:21:44 +0700 Subject: [PATCH 0084/1199] Text input panel test --- .../entity/decorative/HoloSignBlockEntity.kt | 2 +- .../ru/dbotthepony/mc/otm/client/Ext.kt | 8 + .../render/blockentity/HoloSignRenderer.kt | 14 +- .../mc/otm/client/screen/HoloSignScreen.kt | 21 + .../otm/client/screen/panels/EditablePanel.kt | 2 +- .../mc/otm/client/screen/panels/GridPanel.kt | 5 +- .../client/screen/panels/TextInputPanel.kt | 787 ++++++++++++++++++ .../mc/otm/core/math/EuclidMath.kt | 2 + .../dbotthepony/mc/otm/menu/HoloSignMenu.kt | 9 + .../ru/dbotthepony/mc/otm/registry/MMenus.kt | 3 +- 10 files changed, 844 insertions(+), 9 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/HoloSignScreen.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt index ba6eec801..984f2bfbd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt @@ -15,7 +15,7 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlocks class HoloSignBlockEntity(blockPos: BlockPos, blockState: BlockState) : SynchronizedBlockEntity(MBlockEntities.HOLO_SIGN, blockPos, blockState), MenuProvider { - var text by synchronizer.string("АМОГУС", name = "text") + var text by synchronizer.string("АМОГУС\nБОНУС\nИИСУС\nПЛЮС", name = "text") override fun createMenu(p_39954_: Int, p_39955_: Inventory, p_39956_: Player): AbstractContainerMenu { return HoloSignMenu(p_39954_, p_39955_, this) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/Ext.kt index 8c0eb85e6..819893727 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/Ext.kt @@ -1,5 +1,7 @@ package ru.dbotthepony.mc.otm.client +import com.mojang.blaze3d.platform.InputConstants +import com.mojang.blaze3d.platform.Window import net.minecraft.client.Minecraft import net.minecraft.client.gui.Font import net.minecraft.client.resources.sounds.SimpleSoundInstance @@ -13,6 +15,12 @@ import java.nio.DoubleBuffer inline val minecraft: Minecraft get() = Minecraft.getInstance() inline val font: Font get() = minecraft.font +fun Window.isKeyDown(key: Int) = InputConstants.isKeyDown(window, key) + +val Window.isShiftDown get() = isKeyDown(InputConstants.KEY_LSHIFT) || isKeyDown(InputConstants.KEY_RSHIFT) +val Window.isCtrlDown get() = isKeyDown(InputConstants.KEY_RCONTROL) || isKeyDown(InputConstants.KEY_LCONTROL) + + fun playGuiClickSound() { minecraft.soundManager.play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0f)) } 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 8af4ac339..59ede0d1a 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 @@ -25,13 +25,21 @@ class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context) p_112312_: Int ) { poseStack.pushPose() - poseStack.rotateWithBlockFacing(tile.blockState[RotatableMatteryBlock.FACING_FULL], clarifyingAxis = Direction.SOUTH) - poseStack.translate(0.0f, 0.0f, -0.1f) + poseStack.rotateWithBlockFacing(tile.blockState[RotatableMatteryBlock.FACING_FULL]) + poseStack.translate(0.5f, 0.5f, -0.05f) poseStack.scale(0.01f, 0.01f, 0.01f) val sorse = DynamicBufferSource.WORLD - font.drawAligned(poseStack = poseStack, buffer = sorse, text = tile.text, align = TextAlign.CENTER_CENTER, x = 0f, y = 0f, color = RGBAColor.BLUE.toInt()) + val lines = tile.text.split('\n') + val totalHeight = lines.size * font.lineHeight + (lines.size - 1) * 2f + var y = -totalHeight / 2f + + for (line in lines) { + font.drawAligned(poseStack = poseStack, buffer = sorse, text = line, align = TextAlign.TOP_CENTER, x = 0f, y = y, color = RGBAColor.BLUE.toInt()) + y += font.lineHeight + 2f + } + poseStack.popPose() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/HoloSignScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/HoloSignScreen.kt new file mode 100644 index 000000000..2329df6cd --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/HoloSignScreen.kt @@ -0,0 +1,21 @@ +package ru.dbotthepony.mc.otm.client.screen + +import net.minecraft.network.chat.Component +import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.panels.Dock +import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.TextInputPanel +import ru.dbotthepony.mc.otm.menu.HoloSignMenu + +class HoloSignScreen(menu: HoloSignMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, title) { + override fun makeMainFrame(): FramePanel> { + val frame = FramePanel(this, null, 0f, 0f, 200f, 200f, getTitle()) + + val textbox = TextInputPanel(this, frame) + textbox.dock = Dock.FILL + textbox.text = "МОГУС\nБОНУС\n\nСУС" + textbox.multiLine = true + + return frame + } +} 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 9b5f3fac1..f039f7a4d 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 @@ -1251,7 +1251,7 @@ open class EditablePanel @JvmOverloads constructor( return list } - operator fun get(index: Int): EditablePanel<*>? { + fun getChildren(index: Int): EditablePanel<*>? { if (index < 0 || index >= childrenInternal.size) return null return childrenInternal[index] } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/GridPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/GridPanel.kt index 301fc1189..62a4865c4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/GridPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/GridPanel.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.client.screen.panels import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.screen.MatteryScreen open class GridPanel @JvmOverloads constructor( screen: S, @@ -23,7 +22,7 @@ open class GridPanel @JvmOverloads constructor( var column = 0 while (column < columns) { - val child = get(index) ?: break + val child = getChildren(index) ?: break if (child.visible && child.dock === Dock.NONE) { lineY = lineY.coerceAtLeast(child.height + child.dockMargin.top + child.dockMargin.bottom) @@ -41,7 +40,7 @@ open class GridPanel @JvmOverloads constructor( currentX = 0f lineY = 0f - get(index) ?: break + getChildren(index) ?: break } super.performLayout() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt new file mode 100644 index 000000000..86f3ce71c --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt @@ -0,0 +1,787 @@ +package ru.dbotthepony.mc.otm.client.screen.panels + +import com.mojang.blaze3d.platform.InputConstants +import com.mojang.blaze3d.vertex.PoseStack +import it.unimi.dsi.fastutil.chars.CharOpenHashSet +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap +import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.isCtrlDown +import ru.dbotthepony.mc.otm.client.isKeyDown +import ru.dbotthepony.mc.otm.client.isShiftDown +import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource +import ru.dbotthepony.mc.otm.client.render.TextAlign +import ru.dbotthepony.mc.otm.client.render.drawAligned +import ru.dbotthepony.mc.otm.core.math.RGBAColor +import ru.dbotthepony.mc.otm.milliTime + +open class TextInputPanel( + screen: S, + parent: EditablePanel<*>?, + x: Float = 0f, + y: Float = 0f, + width: Float = 10f, + height: Float = 10f, +) : EditablePanel(screen, parent, x, y, width, height) { + data class TextSelection(val start: Int, val end: Int) { + init { + require(start <= end) { "$start <= $end" } + require(start >= 0) { "$start >= 0" } + } + } + + private inner class Snapshot { + private val lines = ArrayList(this@TextInputPanel.lines) // ultra fast copy + private val cursorLine = this@TextInputPanel.cursorLine + private val cursorCharacter = this@TextInputPanel.cursorCharacter + + fun apply() { + this@TextInputPanel.lines.clear() + this@TextInputPanel.lines.addAll(lines) + this@TextInputPanel.cursorCharacter = cursorCharacter + this@TextInputPanel.cursorLine = cursorLine + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as TextInputPanel<*>.Snapshot + + if (lines != other.lines) return false + if (cursorLine != other.cursorLine) return false + if (cursorCharacter != other.cursorCharacter) return false + + return true + } + + override fun hashCode(): Int { + var result = lines.hashCode() + result = 31 * result + cursorLine + result = 31 * result + cursorCharacter + return result + } + } + + protected var ignoreUpdates = false + var debug = true + var multiLine = false + var cursorLine = 0 + var cursorCharacter = 0 + var textColor = RGBAColor.WHITE + var cursorColor = RGBAColor.BLACK + + private var textCache: String? = null + private val lines = ArrayList() + private val selections = Int2ObjectOpenHashMap() + private val undo = ArrayDeque() + private val redo = ArrayDeque() + + private var snapshotTimer: Long? = null + + override fun tick() { + super.tick() + + if (snapshotTimer != null && snapshotTimer!! <= milliTime) { + pushbackSnapshot() + snapshotTimer = null + redo.clear() + } + } + + private fun pushbackSnapshot() { + val snapshot = Snapshot() + + if (undo.isEmpty() || undo.last() != snapshot) + undo.addLast(snapshot) + } + + private fun recordHistory(hard: Boolean = false) { + if (hard) { + pushbackSnapshot() + snapshotTimer = null + } else if (snapshotTimer == null) { + snapshotTimer = milliTime + 800L + } else if (snapshotTimer!! <= milliTime) { + pushbackSnapshot() + snapshotTimer = null + } + + redo.clear() + } + + // it gets really dirty + // idk man :( + private fun undo() { + if (undo.isEmpty()) + return + + if (snapshotTimer != null || redo.isEmpty()) { + pushbackSnapshot() + snapshotTimer = null + } + + val current = Snapshot() + + while (undo.isNotEmpty()) { + val removed = undo.removeLast() + redo.addFirst(removed) + + if (removed != current) { + removed.apply() + break + } + } + } + + // it gets really dirty + // idk man :( + private fun redo() { + if (redo.isEmpty()) + return + + val current = Snapshot() + + snapshotTimer = null + + while (redo.isNotEmpty()) { + val removed = redo.removeFirst() + undo.addLast(removed) + + if (current != removed) { + removed.apply() + break + } + } + } + + operator fun get(index: Int): String? { + return lines.getOrNull(index) + } + + operator fun set(index: Int, value: String) { + if (index < 0) { + throw IndexOutOfBoundsException("negative index $index") + } + + lines.ensureCapacity(index) + + while (lines.size <= index) { + lines.add("") + } + + lines[index] = value + } + + fun insertLine(index: Int, value: String = "") { + lines.ensureCapacity(index) + + while (lines.size < index) { + lines.add("") + } + + val upperLines = selections.int2ObjectEntrySet().filter { it.intKey >= index } + + for (entry in upperLines) { + selections.remove(entry.intKey) + } + + for (entry in upperLines) { + selections.put(entry.intKey + 1, entry.value) + } + + lines.add(index, value) + } + + fun removeLine(index: Int): Boolean { + if (index < 0 || index >= lines.size) { + return false + } + + if (cursorLine == index) { + if (index != 0) + cursorLine-- + + cursorCharacter = lines.getOrNull(cursorLine)?.length ?: 0 + } + + lines.removeAt(index) + selections.remove(index) + val upperLines = selections.int2ObjectEntrySet().filter { it.intKey > index } + + for (entry in upperLines) { + selections.remove(entry.intKey) + } + + for (entry in upperLines) { + selections.put(entry.intKey - 1, entry.value) + } + + return true + } + + fun moveCursors(line: Int, character: Int, moveBy: Int) { + @Suppress("name_shadowing") + val moveBy = if (character + moveBy < 0) -character else moveBy + + if (cursorLine == line && cursorCharacter >= character) { + cursorCharacter = (cursorCharacter + moveBy).coerceIn(0, this[cursorLine]?.length ?: Int.MAX_VALUE) + } + + val selection = selections[line] + + if (selection != null) { + val (start, end) = selection + + if (character < start) { + selections[line] = TextSelection(start + moveBy, end + moveBy) + } else if (character > end && character + moveBy < end) { + if (character + moveBy < start) { + // selections.remove(line) + selections[line] = TextSelection(0, 0) + } else { + selections[line] = TextSelection(start, character + moveBy) + } + } else if (character in start .. end) { + if (moveBy > 0 || character + moveBy <= start) { + selections[line] = TextSelection(start, end + moveBy) + } else { + selections[line] = TextSelection(character + moveBy, end + moveBy) + } + } + } + } + + fun wipeSelection() { + val inversed = ArrayList(selections.int2ObjectEntrySet()) + inversed.sortByDescending { it.intKey } + + for ((lineNumber, selection) in inversed) { + if (selection.start != selection.end) { + if (selection.start == 0 && selection.end == this[lineNumber]!!.length) { + + } + } + } + + selections.clear() + } + + protected open fun textChanged(oldText: String, newText: String) {} + + var text: String + get() { + var textCache = textCache + + if (textCache == null) { + textCache = lines.joinToString("\n") + this.textCache = textCache + } + + return textCache + } + set(value) { + if ((textCache ?: lines.joinToString("\n")) == value) + return + + snapshotTimer = null + selections.clear() + lines.clear() + redo.clear() + undo.clear() + cursorLine = 0 + cursorCharacter = 0 + lines.addAll(value.split(NEWLINES)) + } + + fun advanceCursorLeft() { + val line = this[cursorLine] + + if (line != null && cursorCharacter > line.length) { + cursorCharacter = line.length - 1 + } + + if (cursorCharacter > 0) { + cursorCharacter-- + } else if (cursorLine > 0) { + cursorLine-- + cursorCharacter = 0 + + @Suppress("name_shadowing") + val line = this[cursorLine] + + if (line != null) { + cursorCharacter = line.length + } + } + } + + fun advanceCursorRight() { + cursorCharacter++ + + val line = this[cursorLine] + + if (line != null && cursorCharacter > line.length) { + if (lines.size <= cursorLine + 1) { + cursorCharacter = line.length + } else { + cursorLine++ + cursorCharacter = 0 + } + } else if (line == null) { + cursorCharacter = 0 + } + } + + override fun keyPressedInternal(key: Int, scancode: Int, mods: Int): Boolean { + if (key == InputConstants.KEY_ESCAPE) { + killFocus() + return true + } + + if (key == InputConstants.KEY_RETURN) { + if (multiLine) { + if (!minecraft.window.isShiftDown && !minecraft.window.isCtrlDown) + wipeSelection() + + val line = this[cursorLine] + + if (line != null && !minecraft.window.isShiftDown) { + if (cursorCharacter <= 0) { + recordHistory(true) + insertLine(cursorLine, "") + + if (!minecraft.window.isCtrlDown) { + cursorLine++ + cursorCharacter = 0 + } + } else if (cursorCharacter >= line.length) { + recordHistory(true) + insertLine(cursorLine + 1, "") + + if (!minecraft.window.isCtrlDown) { + cursorLine++ + cursorCharacter = 0 + } + } else { + val before = line.substring(0, cursorCharacter) + val after = line.substring(cursorCharacter) + + recordHistory(true) + this[cursorLine] = before + insertLine(cursorLine + 1, after) + + if (!minecraft.window.isCtrlDown) { + cursorLine++ + cursorCharacter = 0 + } + } + } else { + recordHistory(true) + insertLine(cursorLine + 1) + cursorLine++ + cursorCharacter = 0 + } + + return true + } else { + killFocus() + return true + } + } + + if (key == InputConstants.KEY_TAB) { + if (multiLine) { + val lines = if (selections.isNotEmpty()) selections.keys else listOf(cursorLine) + + + if (minecraft.window.isKeyDown(InputConstants.KEY_RSHIFT) || minecraft.window.isKeyDown(InputConstants.KEY_LSHIFT)) { + var hit = false + + for (lineNumber in lines) { + val line = this[lineNumber]!! + + if (line[0] == '\t') { + if (!hit) { + hit = true + recordHistory(true) + } + + this[lineNumber] = line.substring(1) + moveCursors(lineNumber, 1, -1) + } + } + } else { + if (lines.isNotEmpty()) + recordHistory(true) + + for (lineNumber in lines) { + this[lineNumber] = "\t" + this[lineNumber]!! + moveCursors(lineNumber, 0, 1) + } + } + + return true + } + + killFocus() + return true + } + + if (key == InputConstants.KEY_LEFT) { + if (minecraft.window.isCtrlDown) { + val line = this[cursorLine] + + if (line == null || cursorCharacter <= 0) { + advanceCursorLeft() + } else { + if (cursorCharacter >= line.length) + cursorCharacter = line.length - 1 + + cursorCharacter = greedyAdvanceLeft(line, cursorCharacter) + } + } else { + advanceCursorLeft() + } + + return true + } else if (key == InputConstants.KEY_RIGHT) { + if (minecraft.window.isCtrlDown) { + val line = this[cursorLine] + + if (line == null || cursorCharacter + 1 >= line.length) { + advanceCursorRight() + } else { + if (cursorCharacter < 0) + cursorCharacter = 0 + + cursorCharacter = greedyAdvanceRight(line, cursorCharacter) + } + } else { + advanceCursorRight() + } + + return true + } else if (key == InputConstants.KEY_UP) { + if (cursorLine > 0) { + cursorLine-- + } + + return true + } else if (key == InputConstants.KEY_DOWN) { + if (cursorLine < lines.size - 1) { + cursorLine++ + } + + return true + } + + if (key == InputConstants.KEY_BACKSPACE) { + if (cursorLine <= 0 && cursorCharacter <= 0) { + return true + } else if (cursorCharacter <= 0) { + val line = this[cursorLine] + + if (line == null) { + cursorCharacter = this[--cursorLine]?.length ?: 0 + } else { + removeLine(cursorLine) + val newLine = this[cursorLine] + + if (newLine == null) { + this[cursorLine] = line + } else { + this[cursorLine] = newLine + line + } + + recordHistory() + } + } else { + val line = this[cursorLine] + + if (line != null) { + var cursorCharacter = cursorCharacter + + if (cursorCharacter >= line.length) + cursorCharacter = line.length - 1 + + val newLine = line.substring(0, cursorCharacter - 1) + line.substring(cursorCharacter) + moveCursors(cursorLine, cursorCharacter, -1) + this[cursorLine] = newLine + recordHistory() + } + } + + return true + } + + if (key == InputConstants.KEY_DELETE) { + if (cursorLine !in 0 until lines.size) { + cursorLine = lines.size - 1 + return true + } + + if (minecraft.window.isShiftDown) { + pushbackSnapshot() + removeLine(cursorLine) + + if (cursorLine >= lines.size) + cursorLine = lines.size + + cursorCharacter = 0 + recordHistory(true) + return true + } + + val line = this[cursorLine]!! + + if (cursorCharacter >= line.length) { + if (cursorLine + 1 == lines.size) { + return true + } + + if (snapshotTimer == null) + pushbackSnapshot() + + val bottomLine = this[cursorLine + 1]!! + cursorCharacter = line.length + this[cursorLine] = line + bottomLine + removeLine(cursorLine + 1) + + recordHistory() + } else { + if (snapshotTimer == null) + pushbackSnapshot() + + val cursorCharacter = cursorCharacter + moveCursors(cursorLine, cursorCharacter, -1) + this[cursorLine] = line.substring(0, cursorCharacter) + line.substring(cursorCharacter + 1) + + if (cursorCharacter != 0) + this.cursorCharacter++ + + recordHistory() + } + + return true + } + + if (key == InputConstants.KEY_Z && minecraft.window.isCtrlDown) { + undo() + } else if (key == InputConstants.KEY_Y && minecraft.window.isCtrlDown) { + redo() + } + + return true + } + + override fun charTypedInternal(codepoint: Char, mods: Int): Boolean { + var line = this[cursorLine] + + if (line == null) { + set(cursorLine, "") + line = "" + cursorCharacter = 0 + } + + if (cursorCharacter >= line.length) + line += codepoint + else + line = line.substring(0, cursorCharacter) + codepoint + line.substring(cursorCharacter) + + if (snapshotTimer == null) + pushbackSnapshot() + + set(cursorLine, line) + moveCursors(cursorLine, cursorCharacter, 1) + recordHistory() + + return true + } + + override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + var y = 0f + + for (line in lines) { + font.drawAligned( + poseStack = stack, + buffer = BUFFER, + text = line, + align = TextAlign.TOP_LEFT, + x = 0f, + y = y, + color = textColor + ) + + y += font.lineHeight + 2f + } + + if (isFocused && milliTime % 1000L > 200L) { + val activeLine = this[cursorLine] + + if (activeLine == null || cursorCharacter >= activeLine.length) { + font.drawAligned( + poseStack = stack, + buffer = BUFFER, + text = "_", + align = TextAlign.TOP_LEFT, + x = if (activeLine == null) 0f else font.width(activeLine).toFloat(), + y = cursorLine * (font.lineHeight + 2f), + color = cursorColor + ) + } else { + font.drawAligned( + poseStack = stack, + buffer = BUFFER, + text = "|", + align = TextAlign.TOP_LEFT, + x = font.width(activeLine.substring(0, cursorCharacter)).toFloat() - 1f, + y = cursorLine * (font.lineHeight + 2f), + color = cursorColor + ) + } + } + + if (debug) { + font.drawAligned( + poseStack = stack, + buffer = BUFFER, + text = cursorLine.toString(), + align = TextAlign.TOP_RIGHT, + x = width, + y = 0f, + color = cursorColor + ) + + font.drawAligned( + poseStack = stack, + buffer = BUFFER, + text = cursorCharacter.toString(), + align = TextAlign.TOP_RIGHT, + x = width, + y = font.lineHeight + 2f, + color = cursorColor + ) + + font.drawAligned( + poseStack = stack, + buffer = BUFFER, + text = lines.size.toString(), + align = TextAlign.TOP_RIGHT, + x = width, + y = font.lineHeight * 2 + 4f, + color = cursorColor + ) + } + + BUFFER.endBatch() + } + + override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { + requestFocus() + return true + } + + private enum class CharType { + SPACES { + override fun contains(input: Char): Boolean { + return _SPACES.contains(input) + } + + override fun canJumpInto(category: CharType): Boolean { + return true + } + }, + CONTROL { + override fun contains(input: Char): Boolean { + return _CONTROL.contains(input) + } + + override fun canJumpInto(category: CharType): Boolean { + return category == CONTROL + } + }, + OTHER { + override fun contains(input: Char): Boolean { + return !_SPACES.contains(input) && !_CONTROL.contains(input) + } + + override fun canJumpInto(category: CharType): Boolean { + return category == OTHER + } + }; + + abstract fun contains(input: Char): Boolean + abstract fun canJumpInto(category: CharType): Boolean + + companion object { + private val values = values() + + operator fun get(input: Char): CharType { + for (value in values) { + if (value.contains(input)) { + return value + } + } + + throw NoSuchElementException("for $input") + } + } + } + + companion object { + val NEWLINES = Regex("\n\r?") + private val BUFFER = DynamicBufferSource() + + private val _SPACES = CharOpenHashSet().also { + for (char in " \t\n\r\u0000") + it.add(char) + } + + private val _CONTROL = CharOpenHashSet().also { + for (char in "!@\"'#$%^&?*()~`[]/\\;:|<>.,") + it.add(char) + } + + private fun greedyAdvanceLeft(input: String, position: Int): Int { + if (position <= 1) + return 0 + + @Suppress("name_shadowing") + var position = position + var type = CharType[input[--position]] + + while (position > 0) { + val newType = CharType[input[position]] + + if (type.canJumpInto(newType)) { + position-- + type = newType + } else { + return position + 1 + } + } + + return position + } + + private fun greedyAdvanceRight(input: String, position: Int): Int { + @Suppress("name_shadowing") + var position = position + var type = CharType[input[position]] + + while (position < input.length) { + val newType = CharType[input[position]] + + if (type.canJumpInto(newType)) { + position++ + type = newType + } else { + return position + } + } + + return position + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/EuclidMath.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/EuclidMath.kt index 2d9c2d4e2..5dd4654a1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/EuclidMath.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/EuclidMath.kt @@ -566,6 +566,8 @@ const val PIf = 3.1415927f /** * aligns 0,0 with top left point of block corner when looking directly at it, * and swaps Y to +Y when going down and -Y when going up + * + * allows to draw 2D interface in 3D space */ fun PoseStack.rotateWithBlockFacing(rotation: Direction, clarifyingAxis: Direction? = null): PoseStack { when (rotation) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/HoloSignMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/HoloSignMenu.kt index b031f4b1d..8ad731f18 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/HoloSignMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/HoloSignMenu.kt @@ -10,6 +10,15 @@ class HoloSignMenu @JvmOverloads constructor( inventory: Inventory, tile: HoloSignBlockEntity? = null ) : MatteryMenu(MMenus.HOLO_SIGN, containerId, inventory, tile) { + var text by mSynchronizer.string(name = "text") + override val storageSlots: Collection get() = listOf() + + override fun broadcastChanges() { + super.broadcastChanges() + + if (tile is HoloSignBlockEntity) + text = tile.text + } } 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 6df9e3c7c..ae03a7a64 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt @@ -33,7 +33,7 @@ object MMenus { val PLATE_PRESS: MenuType<*> by registry.register(MNames.PLATE_PRESS) { MenuType(::PlatePressMenu) } val MATTER_RECYCLER: MenuType<*> by registry.register(MNames.MATTER_RECYCLER) { MenuType(::MatterRecyclerMenu) } val ENERGY_SERVO: MenuType<*> by registry.register(MNames.ENERGY_SERVO) { MenuType(::EnergyServoMenu) } - val HOLO_SIGN: MenuType<*> by registry.register(MNames.HOLO_SIGN) { MenuType(::HoloSignMenu) } + val HOLO_SIGN: MenuType by registry.register(MNames.HOLO_SIGN) { MenuType(::HoloSignMenu) } val STORAGE_BUS: MenuType<*> by registry.register(MNames.STORAGE_BUS) { MenuType(::StorageBusMenu) } val STORAGE_EXPORTER: MenuType<*> by registry.register(MNames.STORAGE_EXPORTER) { MenuType(::StorageExporterMenu) } @@ -71,6 +71,7 @@ object MMenus { MenuScreens.register(STORAGE_IMPORTER as MenuType, ::StorageImporterScreen) MenuScreens.register(STORAGE_POWER_SUPPLIER as MenuType, ::StoragePowerSupplierScreen) MenuScreens.register(ENERGY_SERVO as MenuType, ::EnergyServoScreen) + MenuScreens.register(HOLO_SIGN, ::HoloSignScreen) } } } From 409c5bb44372ace67f1e53b68c073bec4f375f13 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 25 Jan 2023 18:47:35 +0700 Subject: [PATCH 0085/1199] Use parchment --- build.gradle.kts | 4 +++- gradle.properties | 1 + settings.gradle.kts | 9 +++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 60fabaa42..4a1022857 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,6 +7,7 @@ import java.util.UUID val mod_version: String by project val mc_version: String by project +val parchment_version: String by project val forge_version: String by project val mod_id: String by project val handle_deps: String by project @@ -19,6 +20,7 @@ plugins { `maven-publish` id("net.minecraftforge.gradle") id("org.spongepowered.mixin") + id("org.parchmentmc.librarian.forgegradle") } configurations { @@ -216,7 +218,7 @@ configurations { } minecraft { - mappings("official", mc_version) + mappings("parchment", parchment_version) accessTransformer(file("src/main/resources/META-INF/accesstransformer.cfg")) runs { diff --git a/gradle.properties b/gradle.properties index 72f45856a..f8b7672a6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,6 +11,7 @@ mod_version=1.1 use_commit_hash_in_version=true mc_version=1.19.3 +parchment_version=2022.12.18-1.19.3 jei_mc_version=1.19.3 deps_mc_version=1.19.2 diff --git a/settings.gradle.kts b/settings.gradle.kts index e72c25773..d51bd0be5 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -17,6 +17,13 @@ buildscript { } } + maven(url = "https://maven.parchmentmc.org") { + content { + includeGroup("org.parchmentmc") + includeGroup("org.parchmentmc.feather") + } + } + mavenCentral() } @@ -28,5 +35,7 @@ buildscript { classpath(group = "net.minecraftforge.gradle", name = "ForgeGradle", version = forge_gradle_version) classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}") classpath("org.spongepowered:mixingradle:${mixingradle_version}") + + classpath(group = "org.parchmentmc", name = "librarian", version = "1.+") } } From b62ac72bc5245f95e324f35cbed098213edd5415 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 25 Jan 2023 21:03:22 +0700 Subject: [PATCH 0086/1199] Text input selection test --- .../client/screen/panels/TextInputPanel.kt | 318 ++++++++++++++---- 1 file changed, 257 insertions(+), 61 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt index 86f3ce71c..0b4cb9411 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt @@ -1,10 +1,16 @@ package ru.dbotthepony.mc.otm.client.screen.panels +import com.mojang.blaze3d.platform.GlStateManager import com.mojang.blaze3d.platform.InputConstants +import com.mojang.blaze3d.systems.RenderSystem +import com.mojang.blaze3d.vertex.DefaultVertexFormat import com.mojang.blaze3d.vertex.PoseStack +import com.mojang.blaze3d.vertex.VertexFormat import it.unimi.dsi.fastutil.chars.CharOpenHashSet -import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap +import it.unimi.dsi.fastutil.ints.Int2ObjectAVLTreeMap +import it.unimi.dsi.fastutil.ints.Int2ObjectMap import net.minecraft.client.gui.screens.Screen +import net.minecraft.client.renderer.GameRenderer import ru.dbotthepony.mc.otm.client.isCtrlDown import ru.dbotthepony.mc.otm.client.isKeyDown import ru.dbotthepony.mc.otm.client.isShiftDown @@ -12,6 +18,8 @@ import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.render.TextAlign import ru.dbotthepony.mc.otm.client.render.drawAligned +import ru.dbotthepony.mc.otm.client.render.tesselator +import ru.dbotthepony.mc.otm.core.addAll import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.milliTime @@ -23,10 +31,39 @@ open class TextInputPanel( width: Float = 10f, height: Float = 10f, ) : EditablePanel(screen, parent, x, y, width, height) { - data class TextSelection(val start: Int, val end: Int) { - init { - require(start <= end) { "$start <= $end" } - require(start >= 0) { "$start >= 0" } + private data class TextSelection(val start: Int, val end: Int) { + val isInversed get() = start > end + val isNotEmpty get() = start != end + + val actualStart get() = if (isInversed) this.end else this.start + val actualEnd get() = if (isInversed) this.start else this.end + + fun sub(line: String): Pair { + val before = line.substring(0, actualStart.coerceIn(0, line.length)) + val selected = line.substring(actualStart.coerceIn(0, line.length), actualEnd.coerceAtMost(line.length)) + + return before to selected + } + + fun coversEntireString(value: String?): Boolean { + if (value == null) + return false + + return value.length <= actualEnd && actualStart <= 0 + } + + fun coversEntireLine(value: String?): Boolean { + if (value == null) + return true + + return value.length < actualEnd && actualStart <= 0 + } + + fun coversNewline(value: String?): Boolean { + if (value == null) + return actualEnd == Int.MAX_VALUE + + return value.length < actualEnd } } @@ -34,10 +71,13 @@ open class TextInputPanel( private val lines = ArrayList(this@TextInputPanel.lines) // ultra fast copy private val cursorLine = this@TextInputPanel.cursorLine private val cursorCharacter = this@TextInputPanel.cursorCharacter + private val selections = Int2ObjectAVLTreeMap(this@TextInputPanel.selections) fun apply() { this@TextInputPanel.lines.clear() this@TextInputPanel.lines.addAll(lines) + this@TextInputPanel.selections.clear() + this@TextInputPanel.selections.putAll(selections) this@TextInputPanel.cursorCharacter = cursorCharacter this@TextInputPanel.cursorLine = cursorLine } @@ -51,6 +91,7 @@ open class TextInputPanel( if (lines != other.lines) return false if (cursorLine != other.cursorLine) return false if (cursorCharacter != other.cursorCharacter) return false + if (selections != other.selections) return false return true } @@ -73,7 +114,7 @@ open class TextInputPanel( private var textCache: String? = null private val lines = ArrayList() - private val selections = Int2ObjectOpenHashMap() + private val selections = Int2ObjectAVLTreeMap() private val undo = ArrayDeque() private val redo = ArrayDeque() @@ -96,6 +137,11 @@ open class TextInputPanel( undo.addLast(snapshot) } + private fun pushbackSnapshotIfNoTimer() { + if (snapshotTimer == null) + pushbackSnapshot() + } + private fun recordHistory(hard: Boolean = false) { if (hard) { pushbackSnapshot() @@ -173,6 +219,19 @@ open class TextInputPanel( lines[index] = value } + private fun selectionIndex(index: Int) = object : Int2ObjectMap.Entry { + override fun setValue(newValue: TextSelection): TextSelection? { + return selections.put(index, newValue) + } + + override fun getIntKey(): Int { + return index + } + + override val value: TextSelection + get() = selections[index] ?: throw NoSuchElementException() + } + fun insertLine(index: Int, value: String = "") { lines.ensureCapacity(index) @@ -180,7 +239,8 @@ open class TextInputPanel( lines.add("") } - val upperLines = selections.int2ObjectEntrySet().filter { it.intKey >= index } + val upperLines = ArrayList>() + upperLines.addAll(selections.int2ObjectEntrySet().iterator(selectionIndex(index))) for (entry in upperLines) { selections.remove(entry.intKey) @@ -207,7 +267,9 @@ open class TextInputPanel( lines.removeAt(index) selections.remove(index) - val upperLines = selections.int2ObjectEntrySet().filter { it.intKey > index } + + val upperLines = ArrayList>() + upperLines.addAll(selections.int2ObjectEntrySet().iterator(selectionIndex(index))) for (entry in upperLines) { selections.remove(entry.intKey) @@ -220,7 +282,7 @@ open class TextInputPanel( return true } - fun moveCursors(line: Int, character: Int, moveBy: Int) { + protected fun moveCursors(line: Int, character: Int, moveBy: Int) { @Suppress("name_shadowing") val moveBy = if (character + moveBy < 0) -character else moveBy @@ -252,9 +314,24 @@ open class TextInputPanel( } } - fun wipeSelection() { + protected fun wipeSelection() { + if (selections.isEmpty()) + return + + pushbackSnapshotIfNoTimer() + val inversed = ArrayList(selections.int2ObjectEntrySet()) - inversed.sortByDescending { it.intKey } + + var downTo = inversed.size.ushr(1) + if (inversed.size and 1 == 1) downTo++ + + for (i in inversed.size - 1 downTo downTo) { + val i2 = inversed.size - i + val a = inversed[i] + val b = inversed[i2] + inversed[i] = b + inversed[i2] = a + } for ((lineNumber, selection) in inversed) { if (selection.start != selection.end) { @@ -264,7 +341,7 @@ open class TextInputPanel( } } - selections.clear() + // selections.clear() } protected open fun textChanged(oldText: String, newText: String) {} @@ -294,18 +371,38 @@ open class TextInputPanel( lines.addAll(value.split(NEWLINES)) } - fun advanceCursorLeft() { + data class CursorAdvanceResult( + val oldLine: Int, + val newLine: Int, + val oldCharacter: Int, + val newCharacter: Int, + val couldHaveChangedLine: Boolean + ) { + val linesChanged get() = oldLine != newLine + val charsChanged get() = linesChanged || oldCharacter != newCharacter + val advancedChars get() = newCharacter - oldCharacter + } + + fun advanceCursorLeft(greedy: Boolean = false): CursorAdvanceResult { + val oldLine = cursorLine + val oldChar = cursorCharacter val line = this[cursorLine] + var couldHaveChangedLine = false if (line != null && cursorCharacter > line.length) { cursorCharacter = line.length - 1 } if (cursorCharacter > 0) { - cursorCharacter-- + if (greedy && line != null) { + cursorCharacter = greedyAdvanceLeft(line, cursorCharacter) + } else { + cursorCharacter-- + } } else if (cursorLine > 0) { cursorLine-- cursorCharacter = 0 + couldHaveChangedLine = true @Suppress("name_shadowing") val line = this[cursorLine] @@ -313,15 +410,29 @@ open class TextInputPanel( if (line != null) { cursorCharacter = line.length } + } else { + couldHaveChangedLine = true } + + return CursorAdvanceResult(oldLine, cursorLine, oldChar, cursorCharacter, couldHaveChangedLine = couldHaveChangedLine) } - fun advanceCursorRight() { - cursorCharacter++ + fun advanceCursorRight(greedy: Boolean = false): CursorAdvanceResult { + val oldLine = cursorLine + val oldChar = cursorCharacter + var couldHaveChangedLine = false val line = this[cursorLine] + if (greedy && line != null && cursorCharacter + 1 < line.length) { + cursorCharacter = greedyAdvanceRight(line, cursorCharacter) + } else { + cursorCharacter++ + } + if (line != null && cursorCharacter > line.length) { + couldHaveChangedLine = true + if (lines.size <= cursorLine + 1) { cursorCharacter = line.length } else { @@ -331,6 +442,8 @@ open class TextInputPanel( } else if (line == null) { cursorCharacter = 0 } + + return CursorAdvanceResult(oldLine, cursorLine, oldChar, cursorCharacter, couldHaveChangedLine = couldHaveChangedLine) } override fun keyPressedInternal(key: Int, scancode: Int, mods: Int): Boolean { @@ -394,7 +507,6 @@ open class TextInputPanel( if (multiLine) { val lines = if (selections.isNotEmpty()) selections.keys else listOf(cursorLine) - if (minecraft.window.isKeyDown(InputConstants.KEY_RSHIFT) || minecraft.window.isKeyDown(InputConstants.KEY_LSHIFT)) { var hit = false @@ -429,36 +541,54 @@ open class TextInputPanel( } if (key == InputConstants.KEY_LEFT) { - if (minecraft.window.isCtrlDown) { - val line = this[cursorLine] - - if (line == null || cursorCharacter <= 0) { - advanceCursorLeft() - } else { - if (cursorCharacter >= line.length) - cursorCharacter = line.length - 1 - - cursorCharacter = greedyAdvanceLeft(line, cursorCharacter) - } + if (!minecraft.window.isShiftDown) { + advanceCursorLeft(minecraft.window.isCtrlDown) + selections.clear() } else { - advanceCursorLeft() + if (this[cursorLine] == null) + return true + + val existing = selections[cursorLine] + val result = advanceCursorLeft(minecraft.window.isCtrlDown) + + if (!result.linesChanged) + selections[result.oldLine] = TextSelection( + existing?.start ?: result.oldCharacter, + result.newCharacter) + else { + this[result.newLine]?.let { + val existingNewline = selections[result.newLine] + + if (existingNewline == null) { + selections[result.newLine] = TextSelection( + Int.MAX_VALUE, + it.length) + } else { + if (!existingNewline.isInversed) { + selections[result.newLine] = TextSelection( + existingNewline.start, + it.length) + } + } + } + } } return true } else if (key == InputConstants.KEY_RIGHT) { - if (minecraft.window.isCtrlDown) { - val line = this[cursorLine] - - if (line == null || cursorCharacter + 1 >= line.length) { - advanceCursorRight() - } else { - if (cursorCharacter < 0) - cursorCharacter = 0 - - cursorCharacter = greedyAdvanceRight(line, cursorCharacter) - } + if (!minecraft.window.isShiftDown) { + advanceCursorRight(minecraft.window.isCtrlDown) + selections.clear() } else { - advanceCursorRight() + if (this[cursorLine] == null) + return true + + val existing = selections[cursorLine] + val result = advanceCursorRight(minecraft.window.isCtrlDown) + + selections[result.oldLine] = TextSelection( + existing?.start ?: result.oldCharacter, + if (result.couldHaveChangedLine) Int.MAX_VALUE else result.newCharacter) } return true @@ -467,23 +597,30 @@ open class TextInputPanel( cursorLine-- } + selections.clear() + return true } else if (key == InputConstants.KEY_DOWN) { if (cursorLine < lines.size - 1) { cursorLine++ } + selections.clear() + return true } if (key == InputConstants.KEY_BACKSPACE) { + wipeSelection() + + val line = this[cursorLine] + if (cursorLine <= 0 && cursorCharacter <= 0) { return true - } else if (cursorCharacter <= 0) { - val line = this[cursorLine] - + } else if (cursorCharacter <= 0 || line?.length == 0) { if (line == null) { cursorCharacter = this[--cursorLine]?.length ?: 0 + recordHistory() } else { removeLine(cursorLine) val newLine = this[cursorLine] @@ -497,17 +634,23 @@ open class TextInputPanel( recordHistory() } } else { - val line = this[cursorLine] - if (line != null) { - var cursorCharacter = cursorCharacter + pushbackSnapshotIfNoTimer() - if (cursorCharacter >= line.length) - cursorCharacter = line.length - 1 - - val newLine = line.substring(0, cursorCharacter - 1) + line.substring(cursorCharacter) - moveCursors(cursorLine, cursorCharacter, -1) - this[cursorLine] = newLine + // remove from very end + if (cursorCharacter >= line.length) { + val newLine = line.substring(0, line.length - 1) + moveCursors(cursorLine, cursorCharacter, -1) + this[cursorLine] = newLine + recordHistory() + } else { + val newLine = line.substring(0, cursorCharacter - 1) + line.substring(cursorCharacter) + moveCursors(cursorLine, cursorCharacter, -1) + this[cursorLine] = newLine + recordHistory() + } + } else if (cursorLine > 0) { + cursorLine-- recordHistory() } } @@ -516,6 +659,8 @@ open class TextInputPanel( } if (key == InputConstants.KEY_DELETE) { + wipeSelection() + if (cursorLine !in 0 until lines.size) { cursorLine = lines.size - 1 return true @@ -540,8 +685,7 @@ open class TextInputPanel( return true } - if (snapshotTimer == null) - pushbackSnapshot() + pushbackSnapshotIfNoTimer() val bottomLine = this[cursorLine + 1]!! cursorCharacter = line.length @@ -550,8 +694,7 @@ open class TextInputPanel( recordHistory() } else { - if (snapshotTimer == null) - pushbackSnapshot() + pushbackSnapshotIfNoTimer() val cursorCharacter = cursorCharacter moveCursors(cursorLine, cursorCharacter, -1) @@ -572,10 +715,19 @@ open class TextInputPanel( redo() } + if (key == InputConstants.KEY_A && minecraft.window.isCtrlDown) { + selections.clear() + + for ((i, line) in lines.withIndex()) { + selections[i] = TextSelection(0, Int.MAX_VALUE) + } + } + return true } override fun charTypedInternal(codepoint: Char, mods: Int): Boolean { + wipeSelection() var line = this[cursorLine] if (line == null) { @@ -589,8 +741,7 @@ open class TextInputPanel( else line = line.substring(0, cursorCharacter) + codepoint + line.substring(cursorCharacter) - if (snapshotTimer == null) - pushbackSnapshot() + pushbackSnapshotIfNoTimer() set(cursorLine, line) moveCursors(cursorLine, cursorCharacter, 1) @@ -602,7 +753,9 @@ open class TextInputPanel( override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { var y = 0f - for (line in lines) { + for ((i, line) in lines.withIndex()) { + val selection = selections[i] + font.drawAligned( poseStack = stack, buffer = BUFFER, @@ -613,6 +766,42 @@ open class TextInputPanel( color = textColor ) + if (selection != null && (selection.isNotEmpty || selection.coversEntireLine(line))) { + val (before, selected) = selection.sub(line) + + var x = 0f + + if (before.isNotEmpty()) { + x = font.width(before).toFloat() + } + + val width = if (selection.coversNewline(line)) this.width - x else font.width(selected).toFloat() + + RenderSystem.setShader(GameRenderer::getPositionShader) + RenderSystem.setShaderColor(0.0f, 0.0f, 1.0f, 1.0f) + RenderSystem.disableTexture() + RenderSystem.enableColorLogicOp() + RenderSystem.logicOp(GlStateManager.LogicOp.OR_REVERSE) + RenderSystem.disableDepthTest() + RenderSystem.defaultBlendFunc() + + val builder = tesselator.builder + + builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION) + + builder.vertex(stack.last().pose(), x, y + font.lineHeight + 2f, 0f).endVertex() + builder.vertex(stack.last().pose(), x + width, y + font.lineHeight + 2f, 0f).endVertex() + builder.vertex(stack.last().pose(), x + width, y, 0f).endVertex() + builder.vertex(stack.last().pose(), x, y, 0f).endVertex() + + tesselator.end() + + RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f) + RenderSystem.disableColorLogicOp() + RenderSystem.enableTexture() + RenderSystem.enableDepthTest() + } + y += font.lineHeight + 2f } @@ -678,6 +867,7 @@ open class TextInputPanel( } override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { + selections.clear() requestFocus() return true } @@ -745,7 +935,7 @@ open class TextInputPanel( private fun greedyAdvanceLeft(input: String, position: Int): Int { if (position <= 1) - return 0 + return -1 @Suppress("name_shadowing") var position = position @@ -768,6 +958,12 @@ open class TextInputPanel( private fun greedyAdvanceRight(input: String, position: Int): Int { @Suppress("name_shadowing") var position = position + + if (position < 0) + position = 0 + else if (position >= input.length) + return position + 1 + var type = CharType[input[position]] while (position < input.length) { From 7299238fc90d844cb5db96a722780a194d263401 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 25 Jan 2023 21:03:49 +0700 Subject: [PATCH 0087/1199] Tabs don't render properly loal --- .../client/screen/panels/TextInputPanel.kt | 37 ------------------- 1 file changed, 37 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt index 0b4cb9411..d44f5e468 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt @@ -503,43 +503,6 @@ open class TextInputPanel( } } - if (key == InputConstants.KEY_TAB) { - if (multiLine) { - val lines = if (selections.isNotEmpty()) selections.keys else listOf(cursorLine) - - if (minecraft.window.isKeyDown(InputConstants.KEY_RSHIFT) || minecraft.window.isKeyDown(InputConstants.KEY_LSHIFT)) { - var hit = false - - for (lineNumber in lines) { - val line = this[lineNumber]!! - - if (line[0] == '\t') { - if (!hit) { - hit = true - recordHistory(true) - } - - this[lineNumber] = line.substring(1) - moveCursors(lineNumber, 1, -1) - } - } - } else { - if (lines.isNotEmpty()) - recordHistory(true) - - for (lineNumber in lines) { - this[lineNumber] = "\t" + this[lineNumber]!! - moveCursors(lineNumber, 0, 1) - } - } - - return true - } - - killFocus() - return true - } - if (key == InputConstants.KEY_LEFT) { if (!minecraft.window.isShiftDown) { advanceCursorLeft(minecraft.window.isCtrlDown) From dac83d7e6330fb4e124161e7fbbf59a92ce18303 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 25 Jan 2023 23:25:44 +0700 Subject: [PATCH 0088/1199] Selecting text while going up and down the lines --- .../client/screen/panels/TextInputPanel.kt | 146 +++++++++++++----- 1 file changed, 108 insertions(+), 38 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt index d44f5e468..668abe3ba 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt @@ -446,6 +446,50 @@ open class TextInputPanel( return CursorAdvanceResult(oldLine, cursorLine, oldChar, cursorCharacter, couldHaveChangedLine = couldHaveChangedLine) } + private fun simulateSelectLeft(greedy: Boolean) { + val thisLine = this[cursorLine] ?: return + + val existing = selections[cursorLine] + val result = advanceCursorLeft(greedy) + + if (!result.linesChanged) + selections[result.oldLine] = TextSelection( + existing?.start ?: result.oldCharacter, + result.newCharacter) + else { + this[result.newLine]?.let { + val existingNewline = selections[result.newLine] + + if (existingNewline == null) { + selections[result.newLine] = TextSelection( + Int.MAX_VALUE, + it.length) + } else { + if (!existingNewline.isInversed) { + selections[result.newLine] = TextSelection( + existingNewline.start, + result.newCharacter) + } + } + } + + if (existing != null && existing.actualStart == 0 && thisLine.isEmpty() && !existing.isInversed) { + selections.remove(result.oldLine) + } + } + } + + private fun simulateSelectRight(greedy: Boolean) { + this[cursorLine] ?: return + + val existing = selections[cursorLine] + val result = advanceCursorRight(greedy) + + selections[result.oldLine] = TextSelection( + existing?.start ?: result.oldCharacter, + if (result.couldHaveChangedLine) Int.MAX_VALUE else result.newCharacter) + } + override fun keyPressedInternal(key: Int, scancode: Int, mods: Int): Boolean { if (key == InputConstants.KEY_ESCAPE) { killFocus() @@ -511,30 +555,7 @@ open class TextInputPanel( if (this[cursorLine] == null) return true - val existing = selections[cursorLine] - val result = advanceCursorLeft(minecraft.window.isCtrlDown) - - if (!result.linesChanged) - selections[result.oldLine] = TextSelection( - existing?.start ?: result.oldCharacter, - result.newCharacter) - else { - this[result.newLine]?.let { - val existingNewline = selections[result.newLine] - - if (existingNewline == null) { - selections[result.newLine] = TextSelection( - Int.MAX_VALUE, - it.length) - } else { - if (!existingNewline.isInversed) { - selections[result.newLine] = TextSelection( - existingNewline.start, - it.length) - } - } - } - } + simulateSelectLeft(minecraft.window.isCtrlDown) } return true @@ -546,29 +567,78 @@ open class TextInputPanel( if (this[cursorLine] == null) return true - val existing = selections[cursorLine] - val result = advanceCursorRight(minecraft.window.isCtrlDown) - - selections[result.oldLine] = TextSelection( - existing?.start ?: result.oldCharacter, - if (result.couldHaveChangedLine) Int.MAX_VALUE else result.newCharacter) + simulateSelectRight(minecraft.window.isCtrlDown) } return true } else if (key == InputConstants.KEY_UP) { - if (cursorLine > 0) { - cursorLine-- - } + if (minecraft.window.isShiftDown) { + if (cursorLine > 0) { + val cursorCharacter = cursorCharacter + val cursorLine = cursorLine - selections.clear() + while (this.cursorCharacter >= 0 && this.cursorLine == cursorLine) { + simulateSelectLeft(false) + } + + val line = this[this.cursorLine]!! + + if (cursorCharacter < line.length) { + this.cursorCharacter = line.length + + while (this.cursorCharacter > cursorCharacter) { + simulateSelectLeft(false) + } + } + + this.cursorCharacter = cursorCharacter + } + } else { + if (cursorLine > 0) { + cursorLine-- + } + + selections.clear() + } return true } else if (key == InputConstants.KEY_DOWN) { - if (cursorLine < lines.size - 1) { - cursorLine++ - } + if (minecraft.window.isShiftDown) { + if (cursorLine < lines.size - 1) { + val cursorCharacter = cursorCharacter + val cursorLine = cursorLine - selections.clear() + while (this.cursorCharacter >= cursorCharacter && this.cursorLine == cursorLine) { + simulateSelectRight(true) + } + + val line = this[this.cursorLine]!! + + if (cursorCharacter < line.length) { + this.cursorCharacter = 0 + + while (this.cursorCharacter < cursorCharacter) { + simulateSelectRight(false) + } + } else { + val store = this.cursorLine + + for (i in 0 .. line.length) { + simulateSelectRight(false) + } + + this.cursorLine = store + } + + this.cursorCharacter = cursorCharacter + } + } else { + if (cursorLine < lines.size - 1) { + cursorLine++ + } + + selections.clear() + } return true } From 16e371ec019fd20b25516b47d36edfc86016f53f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 26 Jan 2023 00:17:15 +0700 Subject: [PATCH 0089/1199] selection wiping --- .../client/screen/panels/TextInputPanel.kt | 91 ++++++++++++------- 1 file changed, 59 insertions(+), 32 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt index 668abe3ba..d50effbf4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt @@ -34,6 +34,7 @@ open class TextInputPanel( private data class TextSelection(val start: Int, val end: Int) { val isInversed get() = start > end val isNotEmpty get() = start != end + val isValid get() = start != end val actualStart get() = if (isInversed) this.end else this.start val actualEnd get() = if (isInversed) this.start else this.end @@ -67,6 +68,14 @@ open class TextInputPanel( } } + private fun putSelection(index: Int, selection: TextSelection) { + if (selection.isValid) { + selections[index] = selection + } else { + selections.remove(index) + } + } + private inner class Snapshot { private val lines = ArrayList(this@TextInputPanel.lines) // ultra fast copy private val cursorLine = this@TextInputPanel.cursorLine @@ -296,19 +305,19 @@ open class TextInputPanel( val (start, end) = selection if (character < start) { - selections[line] = TextSelection(start + moveBy, end + moveBy) + putSelection(line, TextSelection(start + moveBy, end + moveBy)) } else if (character > end && character + moveBy < end) { if (character + moveBy < start) { // selections.remove(line) selections[line] = TextSelection(0, 0) } else { - selections[line] = TextSelection(start, character + moveBy) + putSelection(line, TextSelection(start, character + moveBy)) } } else if (character in start .. end) { if (moveBy > 0 || character + moveBy <= start) { - selections[line] = TextSelection(start, end + moveBy) + putSelection(line, TextSelection(start, end + moveBy)) } else { - selections[line] = TextSelection(character + moveBy, end + moveBy) + putSelection(line, TextSelection(character + moveBy, end + moveBy)) } } } @@ -319,29 +328,41 @@ open class TextInputPanel( return pushbackSnapshotIfNoTimer() + val set = selections.int2ObjectEntrySet() - val inversed = ArrayList(selections.int2ObjectEntrySet()) + while (set.isNotEmpty()) { + val (lineNumber, selection) = set.last() + selections.remove(lineNumber) + val line = this[lineNumber] ?: continue + if (!selection.isValid) continue // ??? - var downTo = inversed.size.ushr(1) - if (inversed.size and 1 == 1) downTo++ - - for (i in inversed.size - 1 downTo downTo) { - val i2 = inversed.size - i - val a = inversed[i] - val b = inversed[i2] - inversed[i] = b - inversed[i2] = a - } - - for ((lineNumber, selection) in inversed) { - if (selection.start != selection.end) { - if (selection.start == 0 && selection.end == this[lineNumber]!!.length) { + if (selection.coversEntireLine(line)) { + removeLine(lineNumber) + } else if (selection.coversEntireString(line)) { + this[lineNumber] = "" + } else if (selection.coversNewline(line)) { + val before = line.substring(0, selection.actualStart.coerceIn(0, line.length)) + val next = this[lineNumber + 1] + if (next == null) { + this[lineNumber] = before + } else { + this[lineNumber] = before + next + removeLine(lineNumber + 1) } + } else { + val before = line.substring(0, selection.actualStart.coerceIn(0, line.length)) + val after = line.substring(selection.actualEnd.coerceIn(0, line.length)) + this[lineNumber] = before + after + } + + if (lineNumber < cursorLine) { + cursorLine = lineNumber + cursorCharacter = selection.actualStart + } else if (lineNumber == cursorLine && cursorCharacter > selection.actualStart) { + cursorCharacter = selection.actualStart } } - - // selections.clear() } protected open fun textChanged(oldText: String, newText: String) {} @@ -453,22 +474,22 @@ open class TextInputPanel( val result = advanceCursorLeft(greedy) if (!result.linesChanged) - selections[result.oldLine] = TextSelection( + putSelection(result.oldLine, TextSelection( existing?.start ?: result.oldCharacter, - result.newCharacter) + result.newCharacter)) else { this[result.newLine]?.let { val existingNewline = selections[result.newLine] if (existingNewline == null) { - selections[result.newLine] = TextSelection( + putSelection(result.newLine, TextSelection( Int.MAX_VALUE, - it.length) + it.length)) } else { if (!existingNewline.isInversed) { - selections[result.newLine] = TextSelection( + putSelection(result.newLine, TextSelection( existingNewline.start, - result.newCharacter) + result.newCharacter)) } } } @@ -485,9 +506,9 @@ open class TextInputPanel( val existing = selections[cursorLine] val result = advanceCursorRight(greedy) - selections[result.oldLine] = TextSelection( + putSelection(result.oldLine, TextSelection( existing?.start ?: result.oldCharacter, - if (result.couldHaveChangedLine) Int.MAX_VALUE else result.newCharacter) + if (result.couldHaveChangedLine) Int.MAX_VALUE else result.newCharacter)) } override fun keyPressedInternal(key: Int, scancode: Int, mods: Int): Boolean { @@ -644,7 +665,10 @@ open class TextInputPanel( } if (key == InputConstants.KEY_BACKSPACE) { - wipeSelection() + if (selections.isNotEmpty()) { + wipeSelection() + return true + } val line = this[cursorLine] @@ -692,7 +716,10 @@ open class TextInputPanel( } if (key == InputConstants.KEY_DELETE) { - wipeSelection() + if (selections.isNotEmpty()) { + wipeSelection() + return true + } if (cursorLine !in 0 until lines.size) { cursorLine = lines.size - 1 @@ -799,7 +826,7 @@ open class TextInputPanel( color = textColor ) - if (selection != null && (selection.isNotEmpty || selection.coversEntireLine(line))) { + if (selection != null && selection.isValid && (selection.isNotEmpty || selection.coversEntireLine(line))) { val (before, selected) = selection.sub(line) var x = 0f From b6d5cc402426ca1df55817681b069b4974d507a8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 26 Jan 2023 15:21:34 +0700 Subject: [PATCH 0090/1199] Moving text cursor using mice --- .../client/screen/panels/TextInputPanel.kt | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt index d50effbf4..66ee71717 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt @@ -6,11 +6,15 @@ import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.DefaultVertexFormat import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.VertexFormat +import it.unimi.dsi.fastutil.chars.Char2IntAVLTreeMap +import it.unimi.dsi.fastutil.chars.Char2IntFunction +import it.unimi.dsi.fastutil.chars.Char2IntOpenHashMap import it.unimi.dsi.fastutil.chars.CharOpenHashSet import it.unimi.dsi.fastutil.ints.Int2ObjectAVLTreeMap import it.unimi.dsi.fastutil.ints.Int2ObjectMap import net.minecraft.client.gui.screens.Screen import net.minecraft.client.renderer.GameRenderer +import org.joml.Vector2i import ru.dbotthepony.mc.otm.client.isCtrlDown import ru.dbotthepony.mc.otm.client.isKeyDown import ru.dbotthepony.mc.otm.client.isShiftDown @@ -929,9 +933,69 @@ open class TextInputPanel( override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { selections.clear() requestFocus() + + val (lx, ly) = screenToLocal(x, y) + val pos = localToText(lx, ly) + cursorLine = pos.y + cursorCharacter = pos.x + return true } + fun localToText(x: Float, y: Float): Vector2i { + if (lines.isEmpty()) + return Vector2i(0, 0) + + val line = (y / (font.lineHeight + 2f)).toInt().coerceIn(0, lines.size - 1) + val sLine = this[line] ?: return Vector2i(0, line) + + if (x <= 0f) + return Vector2i(0, line) + else if (x >= font.width(sLine)) + return Vector2i(sLine.length, line) + + // binary search attempt + // simply: sucks + /*@Suppress("name_shadowing") + var x = x + var start = 0 + var end = sLine.length - 1 + + while (start < end - 1) { + val split = (end - start) / 2 + val before = font.width(sLine.substring(start, start + split)) + + if (x < before) { + end = start + split + } else if (x > before) { + x -= before + start += split + } else { + break + } + } + + return Vector2i(start, line)*/ + + val cache = Char2IntOpenHashMap() + var accumulatedWidth = 0f + + for ((i, char) in sLine.withIndex()) { + val width = cache.computeIfAbsent(char, Char2IntFunction { font.width(it.toString()) }) + + if (x in accumulatedWidth .. accumulatedWidth + width) { + if (x - accumulatedWidth < width / 2) + return Vector2i(i, line) + else + return Vector2i(i + 1, line) + } else { + accumulatedWidth += width + } + } + + return Vector2i(sLine.length, line) + } + private enum class CharType { SPACES { override fun contains(input: Char): Boolean { From 518b7e67fea0bfe6ed22f3adc18884a3dfaaafc6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 26 Jan 2023 16:06:20 +0700 Subject: [PATCH 0091/1199] Selecting text with mouse --- .../client/screen/panels/TextInputPanel.kt | 157 ++++++++++++------ 1 file changed, 105 insertions(+), 52 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt index 66ee71717..d78276a78 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt @@ -515,6 +515,64 @@ open class TextInputPanel( if (result.couldHaveChangedLine) Int.MAX_VALUE else result.newCharacter)) } + private fun simulateSelectionUp(): Boolean { + if (cursorLine <= 0) + return false + + val cursorCharacter = cursorCharacter + val cursorLine = cursorLine + + while (this.cursorCharacter >= 0 && this.cursorLine == cursorLine) { + simulateSelectLeft(false) + } + + val line = this[this.cursorLine]!! + + if (cursorCharacter < line.length) { + this.cursorCharacter = line.length + + while (this.cursorCharacter > cursorCharacter) { + simulateSelectLeft(false) + } + } + + this.cursorCharacter = cursorCharacter + return true + } + + private fun simulateSelectionDown(): Boolean { + if (cursorLine >= lines.size - 1) + return false + + val cursorCharacter = cursorCharacter + val cursorLine = cursorLine + + while (this.cursorCharacter >= cursorCharacter && this.cursorLine == cursorLine) { + simulateSelectRight(true) + } + + val line = this[this.cursorLine]!! + + if (cursorCharacter < line.length) { + this.cursorCharacter = 0 + + while (this.cursorCharacter < cursorCharacter) { + simulateSelectRight(false) + } + } else { + val store = this.cursorLine + + for (i in 0 .. line.length) { + simulateSelectRight(false) + } + + this.cursorLine = store + } + + this.cursorCharacter = cursorCharacter + return true + } + override fun keyPressedInternal(key: Int, scancode: Int, mods: Int): Boolean { if (key == InputConstants.KEY_ESCAPE) { killFocus() @@ -598,26 +656,7 @@ open class TextInputPanel( return true } else if (key == InputConstants.KEY_UP) { if (minecraft.window.isShiftDown) { - if (cursorLine > 0) { - val cursorCharacter = cursorCharacter - val cursorLine = cursorLine - - while (this.cursorCharacter >= 0 && this.cursorLine == cursorLine) { - simulateSelectLeft(false) - } - - val line = this[this.cursorLine]!! - - if (cursorCharacter < line.length) { - this.cursorCharacter = line.length - - while (this.cursorCharacter > cursorCharacter) { - simulateSelectLeft(false) - } - } - - this.cursorCharacter = cursorCharacter - } + simulateSelectionUp() } else { if (cursorLine > 0) { cursorLine-- @@ -629,34 +668,7 @@ open class TextInputPanel( return true } else if (key == InputConstants.KEY_DOWN) { if (minecraft.window.isShiftDown) { - if (cursorLine < lines.size - 1) { - val cursorCharacter = cursorCharacter - val cursorLine = cursorLine - - while (this.cursorCharacter >= cursorCharacter && this.cursorLine == cursorLine) { - simulateSelectRight(true) - } - - val line = this[this.cursorLine]!! - - if (cursorCharacter < line.length) { - this.cursorCharacter = 0 - - while (this.cursorCharacter < cursorCharacter) { - simulateSelectRight(false) - } - } else { - val store = this.cursorLine - - for (i in 0 .. line.length) { - simulateSelectRight(false) - } - - this.cursorLine = store - } - - this.cursorCharacter = cursorCharacter - } + simulateSelectionDown() } else { if (cursorLine < lines.size - 1) { cursorLine++ @@ -930,14 +942,21 @@ open class TextInputPanel( BUFFER.endBatch() } + var isSelecting = false + protected set + override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { selections.clear() requestFocus() - val (lx, ly) = screenToLocal(x, y) - val pos = localToText(lx, ly) - cursorLine = pos.y - cursorCharacter = pos.x + if (button == InputConstants.MOUSE_BUTTON_LEFT) { + val (lx, ly) = screenToLocal(x, y) + val pos = localToText(lx, ly) + cursorLine = pos.y + cursorCharacter = pos.x + + isSelecting = true + } return true } @@ -996,6 +1015,40 @@ open class TextInputPanel( return Vector2i(sLine.length, line) } + override fun mouseReleasedInner(x: Double, y: Double, button: Int): Boolean { + if (button == InputConstants.MOUSE_BUTTON_LEFT) + isSelecting = false + + return true + } + + override fun mouseDraggedInner(x: Double, y: Double, button: Int, xDelta: Double, yDelta: Double): Boolean { + if (button != InputConstants.MOUSE_BUTTON_LEFT || !isSelecting) + return true + + val (lx, ly) = screenToLocal(x, y) + val pos = localToText(lx, ly) + val cursorLine = pos.y + val cursorCharacter = pos.x + + while (cursorLine > this.cursorLine && simulateSelectionDown()) {} + while (cursorLine < this.cursorLine && simulateSelectionUp()) {} + + var lastCursorCharacter = this.cursorCharacter + 1 + + while (cursorCharacter < this.cursorCharacter && lastCursorCharacter != this.cursorCharacter) { + lastCursorCharacter = this.cursorCharacter + simulateSelectLeft(false) + } + + while (cursorCharacter > this.cursorCharacter && lastCursorCharacter != this.cursorCharacter) { + lastCursorCharacter = this.cursorCharacter + simulateSelectRight(false) + } + + return true + } + private enum class CharType { SPACES { override fun contains(input: Char): Boolean { From 9c762d50fa2fe950ec2b0f3fa14fa830285742ba Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 26 Jan 2023 17:21:53 +0700 Subject: [PATCH 0092/1199] try to fix some selection bugs --- .../client/screen/panels/TextInputPanel.kt | 150 +++++++++--------- 1 file changed, 76 insertions(+), 74 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt index d78276a78..51be6d77a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt @@ -6,7 +6,6 @@ import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.DefaultVertexFormat import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.VertexFormat -import it.unimi.dsi.fastutil.chars.Char2IntAVLTreeMap import it.unimi.dsi.fastutil.chars.Char2IntFunction import it.unimi.dsi.fastutil.chars.Char2IntOpenHashMap import it.unimi.dsi.fastutil.chars.CharOpenHashSet @@ -16,7 +15,6 @@ import net.minecraft.client.gui.screens.Screen import net.minecraft.client.renderer.GameRenderer import org.joml.Vector2i import ru.dbotthepony.mc.otm.client.isCtrlDown -import ru.dbotthepony.mc.otm.client.isKeyDown import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource @@ -35,40 +33,35 @@ open class TextInputPanel( width: Float = 10f, height: Float = 10f, ) : EditablePanel(screen, parent, x, y, width, height) { - private data class TextSelection(val start: Int, val end: Int) { - val isInversed get() = start > end - val isNotEmpty get() = start != end - val isValid get() = start != end + private data class TextSelection(val cursor: Int, val shift: Int) { + val isLeft get() = shift < 0 + val isRight get() = shift > 0 - val actualStart get() = if (isInversed) this.end else this.start - val actualEnd get() = if (isInversed) this.start else this.end + fun move(value: Int, lineLength: Int): TextSelection { + return TextSelection(cursor, (shift + value).coerceIn(-cursor, lineLength - cursor + 1)) + } + + val isValid get() = shift != 0 + val start get() = if (isRight) cursor else cursor + shift + val end get() = if (isRight) cursor + shift else cursor fun sub(line: String): Pair { - val before = line.substring(0, actualStart.coerceIn(0, line.length)) - val selected = line.substring(actualStart.coerceIn(0, line.length), actualEnd.coerceAtMost(line.length)) + val before = line.substring(0, start.coerceIn(0, line.length)) + val selected = line.substring(start.coerceIn(0, line.length), end.coerceAtMost(line.length)) return before to selected } - fun coversEntireString(value: String?): Boolean { - if (value == null) - return false - - return value.length <= actualEnd && actualStart <= 0 + fun coversEntireString(value: String): Boolean { + return start <= 0 && value.length <= end } - fun coversEntireLine(value: String?): Boolean { - if (value == null) - return true - - return value.length < actualEnd && actualStart <= 0 + fun coversEntireLine(value: String): Boolean { + return start <= 0 && value.length < end } - fun coversNewline(value: String?): Boolean { - if (value == null) - return actualEnd == Int.MAX_VALUE - - return value.length < actualEnd + fun coversNewline(value: String): Boolean { + return value.length < end } } @@ -306,7 +299,8 @@ open class TextInputPanel( val selection = selections[line] if (selection != null) { - val (start, end) = selection + val start = selection.start + val end = selection.end if (character < start) { putSelection(line, TextSelection(start + moveBy, end + moveBy)) @@ -345,7 +339,7 @@ open class TextInputPanel( } else if (selection.coversEntireString(line)) { this[lineNumber] = "" } else if (selection.coversNewline(line)) { - val before = line.substring(0, selection.actualStart.coerceIn(0, line.length)) + val before = line.substring(0, selection.start.coerceIn(0, line.length)) val next = this[lineNumber + 1] if (next == null) { @@ -355,22 +349,20 @@ open class TextInputPanel( removeLine(lineNumber + 1) } } else { - val before = line.substring(0, selection.actualStart.coerceIn(0, line.length)) - val after = line.substring(selection.actualEnd.coerceIn(0, line.length)) + val before = line.substring(0, selection.start.coerceIn(0, line.length)) + val after = line.substring(selection.end.coerceIn(0, line.length)) this[lineNumber] = before + after } if (lineNumber < cursorLine) { cursorLine = lineNumber - cursorCharacter = selection.actualStart - } else if (lineNumber == cursorLine && cursorCharacter > selection.actualStart) { - cursorCharacter = selection.actualStart + cursorCharacter = selection.start + } else if (lineNumber == cursorLine && cursorCharacter > selection.start) { + cursorCharacter = selection.start } } } - protected open fun textChanged(oldText: String, newText: String) {} - var text: String get() { var textCache = textCache @@ -410,14 +402,17 @@ open class TextInputPanel( fun advanceCursorLeft(greedy: Boolean = false): CursorAdvanceResult { val oldLine = cursorLine - val oldChar = cursorCharacter val line = this[cursorLine] var couldHaveChangedLine = false if (line != null && cursorCharacter > line.length) { - cursorCharacter = line.length - 1 + cursorCharacter = line.length + } else if (cursorCharacter < 0) { + cursorCharacter = 0 } + val oldChar = cursorCharacter + if (cursorCharacter > 0) { if (greedy && line != null) { cursorCharacter = greedyAdvanceLeft(line, cursorCharacter) @@ -444,11 +439,18 @@ open class TextInputPanel( fun advanceCursorRight(greedy: Boolean = false): CursorAdvanceResult { val oldLine = cursorLine - val oldChar = cursorCharacter var couldHaveChangedLine = false val line = this[cursorLine] + if (line != null && cursorCharacter > line.length) { + cursorCharacter = line.length + } else if (cursorCharacter < 0) { + cursorCharacter = 0 + } + + val oldChar = cursorCharacter + if (greedy && line != null && cursorCharacter + 1 < line.length) { cursorCharacter = greedyAdvanceRight(line, cursorCharacter) } else { @@ -472,47 +474,39 @@ open class TextInputPanel( } private fun simulateSelectLeft(greedy: Boolean) { - val thisLine = this[cursorLine] ?: return - - val existing = selections[cursorLine] + val line = this[cursorLine] ?: return + val existing = selections[cursorLine] ?: TextSelection(cursorCharacter, 0) val result = advanceCursorLeft(greedy) - if (!result.linesChanged) - putSelection(result.oldLine, TextSelection( - existing?.start ?: result.oldCharacter, - result.newCharacter)) - else { - this[result.newLine]?.let { - val existingNewline = selections[result.newLine] + if (result.couldHaveChangedLine) { + putSelection(result.oldLine, existing.move(-line.length, line.length)) + } else { + putSelection(result.oldLine, existing.move(result.newCharacter - result.oldCharacter, line.length)) + } - if (existingNewline == null) { - putSelection(result.newLine, TextSelection( - Int.MAX_VALUE, - it.length)) - } else { - if (!existingNewline.isInversed) { - putSelection(result.newLine, TextSelection( - existingNewline.start, - result.newCharacter)) - } - } - } + if (result.linesChanged) { + val existingNew = selections[result.newLine] + val lineNew = this[result.newLine] ?: return - if (existing != null && existing.actualStart == 0 && thisLine.isEmpty() && !existing.isInversed) { - selections.remove(result.oldLine) + if (existingNew == null) { + putSelection(result.newLine, TextSelection(result.newCharacter + 1, -1)) + } else { + putSelection(result.newLine, existingNew.move(-1, lineNew.length)) } } } private fun simulateSelectRight(greedy: Boolean) { - this[cursorLine] ?: return - - val existing = selections[cursorLine] + val line = this[cursorLine] ?: return + val existing = selections[cursorLine] ?: TextSelection(cursorCharacter, 0) val result = advanceCursorRight(greedy) - putSelection(result.oldLine, TextSelection( - existing?.start ?: result.oldCharacter, - if (result.couldHaveChangedLine) Int.MAX_VALUE else result.newCharacter)) + if (result.couldHaveChangedLine) { + if (result.oldLine != lines.size - 1) + putSelection(result.oldLine, existing.move(line.length.coerceAtLeast(1), line.length)) + } else { + putSelection(result.oldLine, existing.move(result.newCharacter - result.oldCharacter, line.length)) + } } private fun simulateSelectionUp(): Boolean { @@ -560,13 +554,21 @@ open class TextInputPanel( simulateSelectRight(false) } } else { - val store = this.cursorLine + if (line.isEmpty()) { + val existing = selections[this.cursorLine] - for (i in 0 .. line.length) { - simulateSelectRight(false) + if (existing != null && existing.isLeft) { + selections.remove(this.cursorLine) + } + } else { + val store = this.cursorLine + + for (i in 0 .. line.length) { + simulateSelectRight(false) + } + + this.cursorLine = store } - - this.cursorLine = store } this.cursorCharacter = cursorCharacter @@ -842,7 +844,7 @@ open class TextInputPanel( color = textColor ) - if (selection != null && selection.isValid && (selection.isNotEmpty || selection.coversEntireLine(line))) { + if (selection != null && selection.isValid) { val (before, selected) = selection.sub(line) var x = 0f @@ -851,7 +853,7 @@ open class TextInputPanel( x = font.width(before).toFloat() } - val width = if (selection.coversNewline(line)) this.width - x else font.width(selected).toFloat() + val width = if (selection.coversNewline(line) && i != lines.size - 1) this.width - x else font.width(selected).toFloat() RenderSystem.setShader(GameRenderer::getPositionShader) RenderSystem.setShaderColor(0.0f, 0.0f, 1.0f, 1.0f) From 60acb8a2dde907779326a836457eb96d8a94bac1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 26 Jan 2023 18:55:21 +0700 Subject: [PATCH 0093/1199] ctrl c ctrl v Works:tm: selection doesn't Works:tm: --- .../client/render/AbstractMatterySprite.kt | 1 - .../mc/otm/client/render/MatteryAtlas.kt | 6 + .../mc/otm/client/render/RenderHelper.kt | 42 +++--- .../mc/otm/client/screen/HoloSignScreen.kt | 2 +- .../client/screen/panels/TextInputPanel.kt | 130 +++++++++++++++--- 5 files changed, 140 insertions(+), 41 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt index 953f95f17..d8389b1bf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt @@ -312,7 +312,6 @@ sealed class AbstractMatterySprite { type.toActualNetwork(this, buff) } - val renderTypeNoDepth by lazy { noDepthCache.computeIfAbsent(texture) { val builder = RenderType.CompositeState.builder() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt index 9052dcdae..0cb929362 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt @@ -2,6 +2,12 @@ package ru.dbotthepony.mc.otm.client.render import net.minecraft.resources.ResourceLocation +fun ResourceLocation.atlas( + width: Float, + height: Float, + winding: UVWindingOrder = UVWindingOrder.NORMAL, +) = MatteryAtlas(this, width, height, winding) + data class MatteryAtlas( val texture: ResourceLocation, val width: Float, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt index f26184b61..38327e737 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt @@ -311,7 +311,8 @@ fun drawRect( x: Float, y: Float, width: Float, - height: Float + height: Float, + color: RGBAColor = drawColor ) { RenderSystem.disableTexture() RenderSystem.enableBlend() @@ -326,10 +327,10 @@ fun drawRect( builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR) - builder.vertex(matrix, x, y + height, zLevel).color(drawColor).endVertex() - builder.vertex(matrix, x + width, y + height, zLevel).color(drawColor).endVertex() - builder.vertex(matrix, x + width, y, zLevel).color(drawColor).endVertex() - builder.vertex(matrix, x, y, zLevel).color(drawColor).endVertex() + builder.vertex(matrix, x, y + height, zLevel).color(color).endVertex() + builder.vertex(matrix, x + width, y + height, zLevel).color(color).endVertex() + builder.vertex(matrix, x + width, y, zLevel).color(color).endVertex() + builder.vertex(matrix, x, y, zLevel).color(color).endVertex() tess.end() RenderSystem.enableTexture() @@ -340,15 +341,17 @@ fun drawRect( x: Float, y: Float, width: Float, - height: Float -) = drawRect(pose.last().pose(), x, y, width, height) + height: Float, + color: RGBAColor = drawColor +) = drawRect(pose.last().pose(), x, y, width, height, color = color) fun drawRect( x: Float, y: Float, width: Float, - height: Float -) = drawRect(identity, x, y, width, height) + height: Float, + color: RGBAColor = drawColor +) = drawRect(identity, x, y, width, height, color = color) fun drawLine( matrix: Matrix4f, @@ -356,7 +359,8 @@ fun drawLine( startY: Float, endX: Float, endY: Float, - width: Float + width: Float, + color: RGBAColor = drawColor ) { RenderSystem.disableTexture() RenderSystem.enableBlend() @@ -390,22 +394,22 @@ fun drawLine( builder.vertex(matrix, startX - y0 * sin, startY + y0 * cos, - zLevel).color(drawColor).endVertex() + zLevel).color(color).endVertex() builder.vertex(matrix, startX - y1 * sin, startY + y1 * cos, - zLevel).color(drawColor).endVertex() + zLevel).color(color).endVertex() builder.vertex(matrix, startX + x2 * cos - y2 * sin, startY + x2 * sin + y2 * cos, - zLevel).color(drawColor).endVertex() + zLevel).color(color).endVertex() builder.vertex(matrix, startX + x3 * cos - y3 * sin, startY + x3 * sin + y3 * cos, - zLevel).color(drawColor).endVertex() + zLevel).color(color).endVertex() tess.end() RenderSystem.enableTexture() @@ -417,16 +421,18 @@ fun drawLine( startY: Float, endX: Float, endY: Float, - width: Float -) = drawLine(pose.last().pose(), startX, startY, endX, endY, width) + width: Float, + color: RGBAColor = drawColor +) = drawLine(pose.last().pose(), startX, startY, endX, endY, width, color = color) fun drawLine( startX: Float, startY: Float, endX: Float, endY: Float, - width: Float -) = drawLine(identity, startX, startY, endX, endY, width) + width: Float, + color: RGBAColor = drawColor +) = drawLine(identity, startX, startY, endX, endY, width, color = color) data class ScissorRect(val x: Int, val y: Int, val width: Int, val height: Int) { fun withinBounds(x: Int, y: Int): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/HoloSignScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/HoloSignScreen.kt index 2329df6cd..2b42df530 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/HoloSignScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/HoloSignScreen.kt @@ -13,8 +13,8 @@ class HoloSignScreen(menu: HoloSignMenu, inventory: Inventory, title: Component) val textbox = TextInputPanel(this, frame) textbox.dock = Dock.FILL - textbox.text = "МОГУС\nБОНУС\n\nСУС" textbox.multiLine = true + textbox.text = "МОГУС\nБОНУС\n\nСУС" return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt index 51be6d77a..381ed1efb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt @@ -17,9 +17,11 @@ import org.joml.Vector2i import ru.dbotthepony.mc.otm.client.isCtrlDown import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.render.TextAlign import ru.dbotthepony.mc.otm.client.render.drawAligned +import ru.dbotthepony.mc.otm.client.render.drawRect import ru.dbotthepony.mc.otm.client.render.tesselator import ru.dbotthepony.mc.otm.core.addAll import ru.dbotthepony.mc.otm.core.math.RGBAColor @@ -110,13 +112,13 @@ open class TextInputPanel( } } - protected var ignoreUpdates = false - var debug = true + var debugDraw = false var multiLine = false var cursorLine = 0 var cursorCharacter = 0 var textColor = RGBAColor.WHITE - var cursorColor = RGBAColor.BLACK + var cursorColor = RGBAColor.GREEN + var backgroundColor = RGBAColor.BLACK private var textCache: String? = null private val lines = ArrayList() @@ -363,19 +365,23 @@ open class TextInputPanel( } } + private fun textCache(): String { + var textCache = textCache + + if (textCache == null) { + textCache = lines.joinToString("\n") + this.textCache = textCache + } + + return textCache + } + var text: String get() { - var textCache = textCache - - if (textCache == null) { - textCache = lines.joinToString("\n") - this.textCache = textCache - } - - return textCache + return textCache() } set(value) { - if ((textCache ?: lines.joinToString("\n")) == value) + if (textCache() == value) return snapshotTimer = null @@ -385,7 +391,12 @@ open class TextInputPanel( undo.clear() cursorLine = 0 cursorCharacter = 0 - lines.addAll(value.split(NEWLINES)) + + if (multiLine) { + lines.addAll(value.split(NEWLINES)) + } else { + lines.add(value.replace(NEWLINES, "")) + } } data class CursorAdvanceResult( @@ -789,16 +800,91 @@ open class TextInputPanel( if (key == InputConstants.KEY_Z && minecraft.window.isCtrlDown) { undo() + return true } else if (key == InputConstants.KEY_Y && minecraft.window.isCtrlDown) { redo() + return true } if (key == InputConstants.KEY_A && minecraft.window.isCtrlDown) { selections.clear() for ((i, line) in lines.withIndex()) { - selections[i] = TextSelection(0, Int.MAX_VALUE) + selections[i] = TextSelection(0, line.length + 1) } + + return true + } + + if (key == InputConstants.KEY_V && minecraft.window.isCtrlDown) { + wipeSelection() + pushbackSnapshot() + + if (multiLine) { + val insert = minecraft.keyboardHandler.clipboard.replace("\t", " ").split(NEWLINES) + + val line = this[cursorLine] + + if (line == null) { + insertLine(cursorLine, insert[0]) + } else if (line.isEmpty()) { + this[cursorLine] = insert[0] + } else { + this[cursorLine] = line.substring(0, cursorCharacter.coerceAtMost(line.length - 1)) + insert[0] + line.substring(cursorCharacter.coerceAtMost(line.length)) + } + + for (i in 1 until insert.size - 1) { + insertLine(++cursorLine, insert[i]) + } + + if (insert.size >= 3) { + val line2 = this[++cursorLine] + + if (line2 == null) { + insertLine(cursorLine, insert.last()) + } else { + this[cursorLine] = insert.last() + line2 + } + } + } else { + val insert = minecraft.keyboardHandler.clipboard.replace("\t", " ").replace(NEWLINES, "") + val line = this[cursorLine] + + if (line == null) { + insertLine(cursorLine, insert) + } else if (line.isEmpty()) { + this[cursorLine] = insert + } else { + this[cursorLine] = line.substring(0, cursorCharacter.coerceAtMost(line.length - 1)) + insert + line.substring(cursorCharacter.coerceAtMost(line.length)) + } + } + + pushbackSnapshot() + return true + } + + if (key == InputConstants.KEY_C && minecraft.window.isCtrlDown) { + if (selections.isEmpty()) { + return true + } + + val build = ArrayList(selections.size) + + for ((lineNumber, selection) in selections.int2ObjectEntrySet()) { + val line = this[lineNumber] ?: continue + + if (selection.coversEntireLine(line)) { + build.add(line + "\n") + } else { + val (_, value) = selection.sub(line) + build.add(if (selection.coversNewline(line)) value + "\n" else value) + } + } + + minecraft.keyboardHandler.clipboard = build.joinToString("") + playGuiClickSound() + + return true } return true @@ -829,6 +915,8 @@ open class TextInputPanel( } override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + drawRect(stack, 0f, 0f, width, height, backgroundColor) + var y = 0f for ((i, line) in lines.withIndex()) { @@ -856,10 +944,10 @@ open class TextInputPanel( val width = if (selection.coversNewline(line) && i != lines.size - 1) this.width - x else font.width(selected).toFloat() RenderSystem.setShader(GameRenderer::getPositionShader) - RenderSystem.setShaderColor(0.0f, 0.0f, 1.0f, 1.0f) + RenderSystem.setShaderColor(cursorColor.red, cursorColor.green, cursorColor.blue, 0.4f) RenderSystem.disableTexture() - RenderSystem.enableColorLogicOp() - RenderSystem.logicOp(GlStateManager.LogicOp.OR_REVERSE) + //RenderSystem.enableColorLogicOp() + //RenderSystem.logicOp(GlStateManager.LogicOp.NOR) RenderSystem.disableDepthTest() RenderSystem.defaultBlendFunc() @@ -875,7 +963,7 @@ open class TextInputPanel( tesselator.end() RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f) - RenderSystem.disableColorLogicOp() + //RenderSystem.disableColorLogicOp() RenderSystem.enableTexture() RenderSystem.enableDepthTest() } @@ -883,7 +971,7 @@ open class TextInputPanel( y += font.lineHeight + 2f } - if (isFocused && milliTime % 1000L > 200L) { + if (isFocused && milliTime % 1000L > 500L) { val activeLine = this[cursorLine] if (activeLine == null || cursorCharacter >= activeLine.length) { @@ -909,7 +997,7 @@ open class TextInputPanel( } } - if (debug) { + if (debugDraw) { font.drawAligned( poseStack = stack, buffer = BUFFER, @@ -1099,7 +1187,7 @@ open class TextInputPanel( } companion object { - val NEWLINES = Regex("\n\r?") + val NEWLINES = Regex("\r?\n") private val BUFFER = DynamicBufferSource() private val _SPACES = CharOpenHashSet().also { From c7e086e9ae6812fed51141e57848656c07e57f6c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 26 Jan 2023 19:01:25 +0700 Subject: [PATCH 0094/1199] Home and End hotkeys --- .../client/screen/panels/TextInputPanel.kt | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt index 381ed1efb..02d4ea70f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt @@ -887,6 +887,38 @@ open class TextInputPanel( return true } + if (key == InputConstants.KEY_HOME) { + if (minecraft.window.isShiftDown && cursorCharacter != 0) { + val thisLine = cursorLine + + while (cursorCharacter > 0 && thisLine == cursorLine) { + simulateSelectLeft(false) + } + } else { + if (!minecraft.window.isShiftDown) selections.clear() + cursorCharacter = 0 + } + + return true + } + + if (key == InputConstants.KEY_END) { + if (minecraft.window.isShiftDown) { + val line = this[cursorLine] ?: return true + if (cursorCharacter >= line.length) return true + val thisLine = cursorLine + + while (cursorCharacter < line.length && thisLine == cursorLine) { + simulateSelectRight(false) + } + } else { + if (!minecraft.window.isShiftDown) selections.clear() + cursorCharacter = this[cursorLine]?.length ?: 0 + } + + return true + } + return true } From f279bcd3d64535740a5db7595d9c9b68c02a4ec6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 26 Jan 2023 20:05:14 +0700 Subject: [PATCH 0095/1199] Holo sign block is now barely functional --- .../mc/otm/client/screen/HoloSignScreen.kt | 26 +++++- .../client/screen/panels/TextInputPanel.kt | 86 ++++++++++++++++--- .../dbotthepony/mc/otm/menu/HoloSignMenu.kt | 6 ++ .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 51 +++++++++++ .../mc/otm/network/MenuNetworkChannel.kt | 3 +- 5 files changed, 154 insertions(+), 18 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/HoloSignScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/HoloSignScreen.kt index 2b42df530..b2742e0f3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/HoloSignScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/HoloSignScreen.kt @@ -6,15 +6,33 @@ import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.TextInputPanel import ru.dbotthepony.mc.otm.menu.HoloSignMenu +import ru.dbotthepony.mc.otm.milliTime class HoloSignScreen(menu: HoloSignMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, title) { override fun makeMainFrame(): FramePanel> { val frame = FramePanel(this, null, 0f, 0f, 200f, 200f, getTitle()) - val textbox = TextInputPanel(this, frame) - textbox.dock = Dock.FILL - textbox.multiLine = true - textbox.text = "МОГУС\nБОНУС\n\nСУС" + object : TextInputPanel(this@HoloSignScreen, frame) { + init { + dock = Dock.FILL + multiLine = true + } + + private var lastChanges = 0L + + override fun onTextChanged(old: String, new: String) { + lastChanges = milliTime + 1000L + menu.textInput.input(new) + } + + override fun tick() { + super.tick() + + if (milliTime >= lastChanges) { + text = menu.text + } + } + } return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt index 02d4ea70f..66d879741 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt @@ -80,14 +80,24 @@ open class TextInputPanel( private val cursorLine = this@TextInputPanel.cursorLine private val cursorCharacter = this@TextInputPanel.cursorCharacter private val selections = Int2ObjectAVLTreeMap(this@TextInputPanel.selections) + private val multiLine = this@TextInputPanel.multiLine fun apply() { this@TextInputPanel.lines.clear() - this@TextInputPanel.lines.addAll(lines) + + if (this@TextInputPanel.multiLine) + this@TextInputPanel.lines.addAll(lines) + else + this@TextInputPanel.lines.add(lines.joinToString("")) + + this@TextInputPanel.selections.clear() - this@TextInputPanel.selections.putAll(selections) + if (this@TextInputPanel.multiLine && multiLine) + this@TextInputPanel.selections.putAll(selections) + this@TextInputPanel.cursorCharacter = cursorCharacter this@TextInputPanel.cursorLine = cursorLine + triggerChangeCallback() } override fun equals(other: Any?): Boolean { @@ -114,18 +124,41 @@ open class TextInputPanel( var debugDraw = false var multiLine = false + set(value) { + if (field == value) return + + if (!value && lines.size > 1) { + val merge = lines.joinToString("") + lines.clear() + lines.add(merge) + triggerChangeCallback() + } + + field = value + } + var cursorLine = 0 var cursorCharacter = 0 var textColor = RGBAColor.WHITE var cursorColor = RGBAColor.GREEN var backgroundColor = RGBAColor.BLACK + private var oldText = ArrayList() private var textCache: String? = null private val lines = ArrayList() private val selections = Int2ObjectAVLTreeMap() private val undo = ArrayDeque() private val redo = ArrayDeque() + private fun triggerChangeCallback() { + if (oldText != lines) { + textCache = null + val old = oldText.joinToString("\n") + oldText = ArrayList(lines) + onTextChanged(old, textCache()) + } + } + private var snapshotTimer: Long? = null override fun tick() { @@ -214,9 +247,11 @@ open class TextInputPanel( } operator fun set(index: Int, value: String) { - if (index < 0) { + if (index < 0) throw IndexOutOfBoundsException("negative index $index") - } + + if (!multiLine && index != 0) + throw IllegalStateException("Not accepting newlines") lines.ensureCapacity(index) @@ -241,6 +276,9 @@ open class TextInputPanel( } fun insertLine(index: Int, value: String = "") { + if (!multiLine && lines.isNotEmpty()) + throw IllegalStateException("Not accepting newlines") + lines.ensureCapacity(index) while (lines.size < index) { @@ -262,9 +300,8 @@ open class TextInputPanel( } fun removeLine(index: Int): Boolean { - if (index < 0 || index >= lines.size) { + if (index < 0 || index >= lines.size) return false - } if (cursorLine == index) { if (index != 0) @@ -363,6 +400,8 @@ open class TextInputPanel( cursorCharacter = selection.start } } + + triggerChangeCallback() } private fun textCache(): String { @@ -391,6 +430,7 @@ open class TextInputPanel( undo.clear() cursorLine = 0 cursorCharacter = 0 + textCache = null if (multiLine) { lines.addAll(value.split(NEWLINES)) @@ -636,9 +676,12 @@ open class TextInputPanel( cursorCharacter = 0 } + triggerChangeCallback() + return true } else { killFocus() + triggerChangeCallback() return true } } @@ -718,6 +761,7 @@ open class TextInputPanel( } recordHistory() + triggerChangeCallback() } } else { if (line != null) { @@ -728,13 +772,14 @@ open class TextInputPanel( val newLine = line.substring(0, line.length - 1) moveCursors(cursorLine, cursorCharacter, -1) this[cursorLine] = newLine - recordHistory() } else { val newLine = line.substring(0, cursorCharacter - 1) + line.substring(cursorCharacter) moveCursors(cursorLine, cursorCharacter, -1) this[cursorLine] = newLine - recordHistory() } + + recordHistory() + triggerChangeCallback() } else if (cursorLine > 0) { cursorLine-- recordHistory() @@ -751,7 +796,7 @@ open class TextInputPanel( } if (cursorLine !in 0 until lines.size) { - cursorLine = lines.size - 1 + cursorLine = (lines.size - 1).coerceAtLeast(0) return true } @@ -764,6 +809,7 @@ open class TextInputPanel( cursorCharacter = 0 recordHistory(true) + triggerChangeCallback() return true } @@ -780,8 +826,6 @@ open class TextInputPanel( cursorCharacter = line.length this[cursorLine] = line + bottomLine removeLine(cursorLine + 1) - - recordHistory() } else { pushbackSnapshotIfNoTimer() @@ -791,10 +835,10 @@ open class TextInputPanel( if (cursorCharacter != 0) this.cursorCharacter++ - - recordHistory() } + recordHistory() + triggerChangeCallback() return true } @@ -860,6 +904,7 @@ open class TextInputPanel( } pushbackSnapshot() + triggerChangeCallback() return true } @@ -924,6 +969,10 @@ open class TextInputPanel( override fun charTypedInternal(codepoint: Char, mods: Int): Boolean { wipeSelection() + + if (!multiLine) + cursorLine = 0 + var line = this[cursorLine] if (line == null) { @@ -942,6 +991,7 @@ open class TextInputPanel( set(cursorLine, line) moveCursors(cursorLine, cursorCharacter, 1) recordHistory() + triggerChangeCallback() return true } @@ -1171,6 +1221,16 @@ open class TextInputPanel( return true } + protected open fun onTextChanged(old: String, new: String) { + changeCallback?.invoke(old, new) + } + + protected var changeCallback: ((old: String, new: String) -> Unit)? = null + + fun onTextChange(callback: (old: String, new: String) -> Unit) { + changeCallback = callback + } + private enum class CharType { SPACES { override fun contains(input: Char): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/HoloSignMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/HoloSignMenu.kt index 8ad731f18..0d6dba642 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/HoloSignMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/HoloSignMenu.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.menu import net.minecraft.world.entity.player.Inventory import net.minecraft.world.inventory.Slot import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity +import ru.dbotthepony.mc.otm.core.util.BinaryStringCodec import ru.dbotthepony.mc.otm.registry.MMenus class HoloSignMenu @JvmOverloads constructor( @@ -12,6 +13,11 @@ class HoloSignMenu @JvmOverloads constructor( ) : MatteryMenu(MMenus.HOLO_SIGN, containerId, inventory, tile) { var text by mSynchronizer.string(name = "text") + val textInput = PlayerInput(BinaryStringCodec) { + if (tile is HoloSignBlockEntity) + tile.text = it + } + override val storageSlots: Collection get() = listOf() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 8c77b7a51..1d68ed134 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -2,7 +2,10 @@ package ru.dbotthepony.mc.otm.menu import com.google.common.collect.ImmutableList import com.mojang.datafixers.util.Pair +import it.unimi.dsi.fastutil.io.FastByteArrayInputStream +import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap +import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import net.minecraft.world.Container @@ -12,17 +15,26 @@ import net.minecraft.world.inventory.* import net.minecraft.world.item.ItemStack import net.minecraft.world.item.enchantment.EnchantmentHelper.hasBindingCurse import net.minecraft.world.level.block.entity.BlockEntity +import net.minecraftforge.network.NetworkEvent import net.minecraftforge.network.PacketDistributor import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.compat.cos.cosmeticArmorSlots import ru.dbotthepony.mc.otm.compat.curios.isCurioSlot import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot +import ru.dbotthepony.mc.otm.core.util.IStreamCodec import ru.dbotthepony.mc.otm.menu.widget.AbstractWidget import ru.dbotthepony.mc.otm.network.FieldSynchronizer +import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.MenuFieldPacket import ru.dbotthepony.mc.otm.network.MenuNetworkChannel +import ru.dbotthepony.mc.otm.network.packetHandled +import ru.dbotthepony.mc.otm.network.sender +import java.io.DataInputStream +import java.io.DataOutputStream import java.util.* +import java.util.function.Supplier +import kotlin.collections.ArrayList abstract class MatteryMenu @JvmOverloads protected constructor( menuType: MenuType<*>?, @@ -43,6 +55,45 @@ abstract class MatteryMenu @JvmOverloads protected constructor( private val _playerExoSuitSlots = ArrayList() private val _playerCombinedInventorySlots = ArrayList() + private val playerInputs = ArrayList>() + + class PlayerInputPacket(val containerId: Int, val inputId: Int, val payload: ByteArray) : MatteryPacket { + constructor(buff: FriendlyByteBuf) : this(buff.readVarInt(), buff.readVarInt(), ByteArray(buff.readableBytes()).also { buff.readBytes(it) }) + + override fun write(buff: FriendlyByteBuf) { + buff.writeVarInt(containerId) + buff.writeVarInt(inputId) + buff.writeBytes(payload) + } + + override fun play(context: Supplier) { + context.packetHandled = true + val menu = context.sender?.containerMenu as? MatteryMenu ?: return + if (menu.containerId != containerId) return + val input = menu.playerInputs.getOrNull(inputId) ?: return + if (!input.allowSpectators && context.sender!!.isSpectator) return + input.invoke(input.codec.read(DataInputStream(FastByteArrayInputStream(payload)))) + } + } + + inner class PlayerInput(val codec: IStreamCodec, val allowSpectators: Boolean = false, val handler: (V) -> Unit) { + val id = playerInputs.size + + init { + playerInputs.add(this) + } + + fun input(value: V) { + val stream = FastByteArrayOutputStream() + codec.write(DataOutputStream(stream), value) + MenuNetworkChannel.sendToServer(PlayerInputPacket(containerId, id, stream.array.copyOfRange(0, stream.length))) + } + + internal fun invoke(value: Any?) { + handler.invoke(value as V) + } + } + /** * inventory + exosuit + hotbar (in this order) */ diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt index d09bb9034..b22cae9f8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt @@ -65,7 +65,7 @@ class SetCarriedPacket(val item: ItemStack) : MatteryPacket { } object MenuNetworkChannel : MatteryNetworkChannel( - version = "1", + version = "2", name = "menu" ) { fun register() { @@ -86,6 +86,7 @@ object MenuNetworkChannel : MatteryNetworkChannel( add(NumberPlayerInputPacket::class.java, NumberPlayerInputPacket.Companion::read, NetworkDirection.PLAY_TO_SERVER) add(OneWayPlayerInputPacket::class.java, OneWayPlayerInputPacket.Companion::read, NetworkDirection.PLAY_TO_SERVER) add(BooleanPlayerInputPacket::class.java, BooleanPlayerInputPacket.Companion::read, NetworkDirection.PLAY_TO_SERVER) + add(MatteryMenu.PlayerInputPacket::class.java, MatteryMenu::PlayerInputPacket, NetworkDirection.PLAY_TO_SERVER) // menu specific From 22ec96345b2532e52246f4a8e236637c8addd808 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 26 Jan 2023 20:07:39 +0700 Subject: [PATCH 0096/1199] Set more meaningful default dimensions --- .../mc/otm/client/screen/panels/TextInputPanel.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt index 66d879741..7d2620312 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.client.screen.panels -import com.mojang.blaze3d.platform.GlStateManager import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.DefaultVertexFormat @@ -32,8 +31,8 @@ open class TextInputPanel( parent: EditablePanel<*>?, x: Float = 0f, y: Float = 0f, - width: Float = 10f, - height: Float = 10f, + width: Float = 60f, + height: Float = 11f, ) : EditablePanel(screen, parent, x, y, width, height) { private data class TextSelection(val cursor: Int, val shift: Int) { val isLeft get() = shift < 0 From fc1623b478df89bdaad96f6914e00cef28873d20 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 26 Jan 2023 20:14:14 +0700 Subject: [PATCH 0097/1199] a --- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 1d68ed134..ea481dc3f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -28,6 +28,7 @@ import ru.dbotthepony.mc.otm.network.FieldSynchronizer import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.MenuFieldPacket import ru.dbotthepony.mc.otm.network.MenuNetworkChannel +import ru.dbotthepony.mc.otm.network.enqueueWork import ru.dbotthepony.mc.otm.network.packetHandled import ru.dbotthepony.mc.otm.network.sender import java.io.DataInputStream @@ -68,11 +69,14 @@ abstract class MatteryMenu @JvmOverloads protected constructor( override fun play(context: Supplier) { context.packetHandled = true - val menu = context.sender?.containerMenu as? MatteryMenu ?: return - if (menu.containerId != containerId) return - val input = menu.playerInputs.getOrNull(inputId) ?: return - if (!input.allowSpectators && context.sender!!.isSpectator) return - input.invoke(input.codec.read(DataInputStream(FastByteArrayInputStream(payload)))) + + context.enqueueWork { + val menu = context.sender?.containerMenu as? MatteryMenu ?: return@enqueueWork + if (menu.containerId != containerId) return@enqueueWork + val input = menu.playerInputs.getOrNull(inputId) ?: return@enqueueWork + if (!input.allowSpectators && context.sender!!.isSpectator) return@enqueueWork + input.invoke(input.codec.read(DataInputStream(FastByteArrayInputStream(payload)))) + } } } From 34d14ec9c6735b1b0ae5657a5388953f312c9eb2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 26 Jan 2023 21:08:53 +0700 Subject: [PATCH 0098/1199] Migrate player menu inputs to PlayerInput --- .../otm/client/screen/EnergyCounterScreen.kt | 4 +- ...putPanel.kt => NetworkNumberInputPanel.kt} | 43 ++++++-- .../panels/buttons/CheckBoxInputPanel.kt | 6 +- .../panels/buttons/CheckBoxLabelInputPanel.kt | 4 +- .../mc/otm/menu/DriveViewerMenu.kt | 34 +++--- .../mc/otm/menu/EnergyCounterMenu.kt | 42 +++----- .../mc/otm/menu/MatterBottlerMenu.kt | 13 +-- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 28 ++++- .../dbotthepony/mc/otm/menu/StorageBusMenu.kt | 8 +- .../mc/otm/menu/StorageExporterMenu.kt | 8 +- .../mc/otm/menu/StorageImporterMenu.kt | 8 +- .../menu/widget/BooleanPlayerInputWidget.kt | 101 ------------------ .../otm/menu/widget/NetworkedBooleanInput.kt | 60 +++++++++++ .../menu/widget/NumberPlayerInputWidget.kt | 92 ---------------- .../menu/widget/OneWayPlayerInputWidget.kt | 53 --------- .../mc/otm/network/MenuNetworkChannel.kt | 14 +-- 16 files changed, 181 insertions(+), 337 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{NumberInputPanel.kt => NetworkNumberInputPanel.kt} (51%) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/BooleanPlayerInputWidget.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/NetworkedBooleanInput.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/NumberPlayerInputWidget.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/OneWayPlayerInputWidget.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/EnergyCounterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/EnergyCounterScreen.kt index 913440b37..46955192e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/EnergyCounterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/EnergyCounterScreen.kt @@ -82,7 +82,7 @@ class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title: val button = ButtonPanel(this, frame, 0f, 0f, 0f, 20f, TranslatableComponent("block.overdrive_that_matters.energy_counter.switch")) button.dock = Dock.TOP button.setDockMargin(4f, 0f, 4f, 0f) - button.bind { menu.switchDirection.userInput(minecraft?.player) } + button.bind { menu.switchDirection.input(null) } } val infoPanels = frame.fetchChildren() @@ -91,7 +91,7 @@ class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title: label.dock = Dock.TOP label.setDockMargin(4f, 0f, 0f, 0f) - val inputPanel = NumberInputPanel(this, frame, menu.maxIO) + val inputPanel = NetworkNumberInputPanel(this, frame, widget = menu.maxIOInput, networkValue = menu::maxIO) inputPanel.dock = Dock.TOP inputPanel.setDockMargin(4f, 0f, 4f, 0f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/NumberInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/NetworkNumberInputPanel.kt similarity index 51% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/NumberInputPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/NetworkNumberInputPanel.kt index 79883527b..ded232d00 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/NumberInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/NetworkNumberInputPanel.kt @@ -4,25 +4,50 @@ import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.TextComponent -import ru.dbotthepony.mc.otm.client.screen.MatteryScreen -import ru.dbotthepony.mc.otm.menu.widget.NumberPlayerInputWidget +import ru.dbotthepony.mc.otm.menu.MatteryMenu import java.math.BigDecimal +import java.util.function.BooleanSupplier -open class NumberInputPanel @JvmOverloads constructor( +open class NetworkNumberInputPanel @JvmOverloads constructor( screen: S, parent: EditablePanel<*>?, - val inputWidget: NumberPlayerInputWidget, + val networkValue: () -> BigDecimal, + val callback: (BigDecimal) -> Unit, + val isAvailable: BooleanSupplier = BooleanSupplier { true }, x: Float = 0f, y: Float = 0f, width: Float = 0f, height: Float = 20f, defaultText: Component = TextComponent("") ) : EditBoxPanel(screen, parent, x, y, width, height, defaultText) { + constructor( + screen: S, + parent: EditablePanel<*>?, + widget: MatteryMenu.PlayerInput, + networkValue: () -> BigDecimal, + x: Float = 0f, + y: Float = 0f, + width: Float = 0f, + height: Float = 20f, + defaultText: Component = TextComponent("") + ) : this( + screen = screen, + parent = parent, + callback = widget::input, + isAvailable = { widget.allowSpectators || minecraft.player?.isSpectator != true }, + networkValue = networkValue, + x = x, + y = y, + width = width, + height = height, + defaultText = defaultText, + ) + protected var nextUpdateFromServer = 0L protected var inputStr = "" override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { - if (inputWidget.ignoreSpectators && minecraft.player?.isSpectator == true) { + if (!isAvailable.asBoolean) { return true } @@ -33,7 +58,7 @@ open class NumberInputPanel @JvmOverloads constructor( super.tick() if (isFocused) { - if (inputWidget.ignoreSpectators && minecraft.player?.isSpectator == true) { + if (!isAvailable.asBoolean) { killFocus() return } @@ -42,14 +67,14 @@ open class NumberInputPanel @JvmOverloads constructor( } if (nextUpdateFromServer < System.currentTimeMillis()) { - getOrCreateWidget().value = inputWidget.value.toPlainString() + getOrCreateWidget().value = networkValue.invoke().toPlainString() inputStr = getOrCreateWidget().value - } else if (!inputWidget.ignoreSpectators || minecraft.player?.isSpectator != true) { + } else if (isAvailable.asBoolean) { if (inputStr != getOrCreateWidget().value) { inputStr = getOrCreateWidget().value try { - inputWidget.userInput(BigDecimal(inputStr), minecraft.player) + callback.invoke(BigDecimal(inputStr)) } catch (_: Throwable) { } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxInputPanel.kt index a5bfd55fa..3c2210d1f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxInputPanel.kt @@ -3,12 +3,12 @@ package ru.dbotthepony.mc.otm.client.screen.panels.buttons import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel -import ru.dbotthepony.mc.otm.menu.widget.BooleanPlayerInputWidget +import ru.dbotthepony.mc.otm.menu.widget.NetworkedBooleanInput open class CheckBoxInputPanel @JvmOverloads constructor( screen: S, parent: EditablePanel<*>?, - val widget: BooleanPlayerInputWidget, + val widget: NetworkedBooleanInput, x: Float = 0f, y: Float = 0f, width: Float = REGULAR_DIMENSIONS + 120f, @@ -19,7 +19,7 @@ open class CheckBoxInputPanel @JvmOverloads constructor( set(value) {} override var isDisabled: Boolean - get() = !widget.ignoreSpectators || minecraft.player?.isSpectator == true + get() = widget.input.allowSpectators || minecraft.player?.isSpectator == true set(value) {} override fun onClick() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxLabelInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxLabelInputPanel.kt index d42d56c43..106c63ea8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxLabelInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxLabelInputPanel.kt @@ -4,12 +4,12 @@ import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.Label -import ru.dbotthepony.mc.otm.menu.widget.BooleanPlayerInputWidget +import ru.dbotthepony.mc.otm.menu.widget.NetworkedBooleanInput open class CheckBoxLabelInputPanel @JvmOverloads constructor( screen: S, parent: EditablePanel<*>?, - widget: BooleanPlayerInputWidget, + widget: NetworkedBooleanInput, text: Component, x: Float = 0f, y: Float = 0f, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/DriveViewerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/DriveViewerMenu.kt index 81ee77c47..8c1487933 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/DriveViewerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/DriveViewerMenu.kt @@ -15,7 +15,7 @@ import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.item.PortableCondensationDriveItem import ru.dbotthepony.mc.otm.menu.data.INetworkedItemViewProvider import ru.dbotthepony.mc.otm.menu.data.NetworkedItemView -import ru.dbotthepony.mc.otm.menu.widget.BooleanPlayerInputWidget +import ru.dbotthepony.mc.otm.menu.widget.NetworkedBooleanInput import ru.dbotthepony.mc.otm.registry.MMenus import ru.dbotthepony.mc.otm.storage.ITEM_STORAGE import ru.dbotthepony.mc.otm.storage.ItemStackWrapper @@ -68,15 +68,15 @@ class DriveViewerMenu @JvmOverloads constructor( val driveFilterSlots = addFilterSlots(driveFilter) - val isWhitelist = BooleanPlayerInputWidget(this) - val matchTag = BooleanPlayerInputWidget(this) - val matchNBT = BooleanPlayerInputWidget(this) + val isWhitelist = NetworkedBooleanInput(this) + val matchTag = NetworkedBooleanInput(this) + val matchNBT = NetworkedBooleanInput(this) init { if (tile == null) { - isWhitelist.asClient() - matchTag.asClient() - matchNBT.asClient() + isWhitelist.isClient = true + matchTag.isClient = true + matchNBT.isClient = true } } @@ -109,24 +109,24 @@ class DriveViewerMenu @JvmOverloads constructor( driveFilter.copyFrom(filter) driveFilter.isLocked = false - isWhitelist.withProperty(driveFilter::isWhitelist) - matchTag.withProperty(driveFilter::matchTag) - matchNBT.withProperty(driveFilter::matchNBT) + isWhitelist.with(driveFilter::isWhitelist) + matchTag.with(driveFilter::matchTag) + matchNBT.with(driveFilter::matchNBT) } else { driveFilter.clear() driveFilter.isLocked = true - isWhitelist.withoutAnything() - matchTag.withoutAnything() - matchNBT.withoutAnything() + isWhitelist.clear() + matchTag.clear() + matchNBT.clear() } } else { driveFilter.clear() driveFilter.isLocked = true - isWhitelist.withoutAnything() - matchTag.withoutAnything() - matchNBT.withoutAnything() + isWhitelist.clear() + matchTag.clear() + matchNBT.clear() } } @@ -170,4 +170,4 @@ class DriveViewerMenu @JvmOverloads constructor( slot.setChanged() return copy } -} \ No newline at end of file +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyCounterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyCounterMenu.kt index f480dbbd2..106203c19 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyCounterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyCounterMenu.kt @@ -8,8 +8,6 @@ import net.minecraft.world.level.block.Block import ru.dbotthepony.mc.otm.block.tech.EnergyCounterBlock import ru.dbotthepony.mc.otm.block.entity.tech.EnergyCounterBlockEntity import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.menu.widget.NumberPlayerInputWidget -import ru.dbotthepony.mc.otm.menu.widget.OneWayPlayerInputWidget import ru.dbotthepony.mc.otm.registry.MMenus import java.math.BigDecimal @@ -22,36 +20,28 @@ class EnergyCounterMenu @JvmOverloads constructor( var average by mSynchronizer.fraction() var last20Ticks by mSynchronizer.fraction() var lastTick by mSynchronizer.fraction() + var maxIO by mSynchronizer.bigDecimal() + + val switchDirection = oneWayInput { + if (tile is EnergyCounterBlockEntity) + tile.level?.setBlock(tile.blockPos, tile.blockState.setValue(EnergyCounterBlock.INPUT_DIRECTION, tile.blockState.getValue(EnergyCounterBlock.INPUT_DIRECTION).opposite), Block.UPDATE_ALL) + } - val switchDirection: OneWayPlayerInputWidget var inputDirection by mSynchronizer.enum(Direction::class.java) - val maxIO = NumberPlayerInputWidget(this) - - // TODO: Graph and proper networking for it - private var ticksPassed = 0 - - init { - if (tile == null) { - switchDirection = OneWayPlayerInputWidget(this) - maxIO.asClient() - } else { - switchDirection = OneWayPlayerInputWidget(this) { - tile.level?.setBlock(tile.blockPos, tile.blockState.setValue(EnergyCounterBlock.INPUT_DIRECTION, tile.blockState.getValue(EnergyCounterBlock.INPUT_DIRECTION).opposite), Block.UPDATE_ALL) - } - - maxIO.withSupplier { - return@withSupplier if (tile.ioLimit == null) MINUS_ONE else tile.ioLimit!!.toBigDecmial() - }.withConsumer { - if (it.signum() < 0) { - tile.ioLimit = null - } else { - tile.ioLimit = Decimal(it) - } + val maxIOInput = bigDecimalInput { + if (tile is EnergyCounterBlockEntity) { + if (it.signum() < 0) { + tile.ioLimit = null + } else { + tile.ioLimit = Decimal(it) } } } + // TODO: Graph and proper networking for it + private var ticksPassed = 0 + override fun broadcastChanges() { if (tile is EnergyCounterBlockEntity) { passed = tile.passed @@ -64,6 +54,8 @@ class EnergyCounterMenu @JvmOverloads constructor( ticksPassed = (ticksPassed + 1) % 20 inputDirection = tile.blockState.getValue(EnergyCounterBlock.INPUT_DIRECTION) + + maxIO = tile.ioLimit?.toBigDecmial() ?: -BigDecimal.ONE } super.broadcastChanges() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterBottlerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterBottlerMenu.kt index 784cdde72..ab79c71da 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterBottlerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterBottlerMenu.kt @@ -8,7 +8,7 @@ import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.matter.canExtractMatter import ru.dbotthepony.mc.otm.capability.matter.canReceiveMatter -import ru.dbotthepony.mc.otm.menu.widget.BooleanPlayerInputWidget +import ru.dbotthepony.mc.otm.menu.widget.NetworkedBooleanInput import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.core.orNull @@ -21,7 +21,7 @@ class MatterBottlerMenu @JvmOverloads constructor( ) : MatteryPoweredMenu( MMenus.MATTER_BOTTLER, p_38852_, inventory, tile ) { - val workFlow: BooleanPlayerInputWidget + val workFlow: NetworkedBooleanInput val progressWidget: ProgressGaugeWidget val matterWidget: LevelGaugeWidget @@ -34,11 +34,11 @@ class MatterBottlerMenu @JvmOverloads constructor( if (tile == null) { progressWidget = ProgressGaugeWidget(this) matterWidget = LevelGaugeWidget(this) - workFlow = BooleanPlayerInputWidget(this).asClient() + workFlow = NetworkedBooleanInput(this).asClient() } else { progressWidget = ProgressGaugeWidget(this) { tile.getWorkProgress() } matterWidget = LevelGaugeWidget(this, tile.matter) - workFlow = BooleanPlayerInputWidget(this, tile::isBottling) + workFlow = NetworkedBooleanInput(this, tile::isBottling) } storageSlots = ImmutableList(6) { index -> @@ -58,9 +58,4 @@ class MatterBottlerMenu @JvmOverloads constructor( storageSlots.forEach(this::addSlot) addInventorySlots() } - - override fun broadcastChanges() { - super.broadcastChanges() - workFlow.value = (tile as MatterBottlerBlockEntity).isBottling - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index ea481dc3f..d5b09478f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -22,7 +22,10 @@ import ru.dbotthepony.mc.otm.compat.cos.cosmeticArmorSlots import ru.dbotthepony.mc.otm.compat.curios.isCurioSlot import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot +import ru.dbotthepony.mc.otm.core.util.BigDecimalValueCodec +import ru.dbotthepony.mc.otm.core.util.BooleanValueCodec import ru.dbotthepony.mc.otm.core.util.IStreamCodec +import ru.dbotthepony.mc.otm.core.util.NullValueCodec import ru.dbotthepony.mc.otm.menu.widget.AbstractWidget import ru.dbotthepony.mc.otm.network.FieldSynchronizer import ru.dbotthepony.mc.otm.network.MatteryPacket @@ -33,6 +36,7 @@ import ru.dbotthepony.mc.otm.network.packetHandled import ru.dbotthepony.mc.otm.network.sender import java.io.DataInputStream import java.io.DataOutputStream +import java.math.BigDecimal import java.util.* import java.util.function.Supplier import kotlin.collections.ArrayList @@ -43,6 +47,9 @@ abstract class MatteryMenu @JvmOverloads protected constructor( val inventory: Inventory, val tile: BlockEntity? = null ) : AbstractContainerMenu(menuType, containerId) { + /** + * Server->Client field synchronizer + */ val mSynchronizer = FieldSynchronizer() val ply: Player get() = inventory.player @@ -80,8 +87,12 @@ abstract class MatteryMenu @JvmOverloads protected constructor( } } - inner class PlayerInput(val codec: IStreamCodec, val allowSpectators: Boolean = false, val handler: (V) -> Unit) { + /** + * Client->Server handler + */ + inner class PlayerInput(val codec: IStreamCodec, allowSpectators: Boolean = false, val handler: (V) -> Unit) { val id = playerInputs.size + var allowSpectators by mSynchronizer.bool(allowSpectators) init { playerInputs.add(this) @@ -93,11 +104,26 @@ abstract class MatteryMenu @JvmOverloads protected constructor( MenuNetworkChannel.sendToServer(PlayerInputPacket(containerId, id, stream.array.copyOfRange(0, stream.length))) } + fun checkedInput(value: V, player: Player?) { + if (allowSpectators || player?.isSpectator == false) { + return input(value) + } + } + internal fun invoke(value: Any?) { handler.invoke(value as V) } } + fun oneWayInput(allowSpectators: Boolean = false, handler: () -> Unit): PlayerInput { + return PlayerInput(NullValueCodec, allowSpectators) { + handler.invoke() + } + } + + fun bigDecimalInput(allowSpectators: Boolean = false, handler: (BigDecimal) -> Unit) = PlayerInput(BigDecimalValueCodec, allowSpectators, handler) + fun booleanInput(allowSpectators: Boolean = false, handler: (Boolean) -> Unit) = PlayerInput(BooleanValueCodec, allowSpectators, handler) + /** * inventory + exosuit + hotbar (in this order) */ diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageBusMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageBusMenu.kt index f7dfd875b..6f13278d0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageBusMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageBusMenu.kt @@ -4,7 +4,7 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.inventory.Slot import ru.dbotthepony.mc.otm.block.entity.storage.StorageBusBlockEntity import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot -import ru.dbotthepony.mc.otm.menu.widget.BooleanPlayerInputWidget +import ru.dbotthepony.mc.otm.menu.widget.NetworkedBooleanInput import ru.dbotthepony.mc.otm.registry.MMenus class StorageBusMenu @JvmOverloads constructor( @@ -15,15 +15,15 @@ class StorageBusMenu @JvmOverloads constructor( MMenus.STORAGE_BUS, p_38852_, inventory, tile ) { val busFilterSlots: List - val busFilterState: BooleanPlayerInputWidget + val busFilterState: NetworkedBooleanInput init { if (tile != null) { busFilterSlots = addFilterSlots(tile.filter) - busFilterState = BooleanPlayerInputWidget(this, tile.filter::isWhitelist) + busFilterState = NetworkedBooleanInput(this, tile.filter::isWhitelist) } else { busFilterSlots = addFilterSlots(StorageBusBlockEntity.MAX_FILTERS) - busFilterState = BooleanPlayerInputWidget(this).asClient() + busFilterState = NetworkedBooleanInput(this).asClient() } addInventorySlots() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageExporterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageExporterMenu.kt index 777118f53..d16a7c3c7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageExporterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageExporterMenu.kt @@ -4,7 +4,7 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.inventory.Slot import ru.dbotthepony.mc.otm.block.entity.storage.StorageExporterBlockEntity import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot -import ru.dbotthepony.mc.otm.menu.widget.BooleanPlayerInputWidget +import ru.dbotthepony.mc.otm.menu.widget.NetworkedBooleanInput import ru.dbotthepony.mc.otm.registry.MMenus class StorageExporterMenu @JvmOverloads constructor( @@ -15,15 +15,15 @@ class StorageExporterMenu @JvmOverloads constructor( MMenus.STORAGE_EXPORTER, p_38852_, inventory, tile ) { val busFilterSlots: List - val busFilterState: BooleanPlayerInputWidget + val busFilterState: NetworkedBooleanInput init { if (tile != null) { busFilterSlots = addFilterSlots(tile.filter) - busFilterState = BooleanPlayerInputWidget(this, tile.filter::isWhitelist) + busFilterState = NetworkedBooleanInput(this, tile.filter::isWhitelist) } else { busFilterSlots = addFilterSlots(StorageExporterBlockEntity.MAX_FILTERS) - busFilterState = BooleanPlayerInputWidget(this).asClient() + busFilterState = NetworkedBooleanInput(this).asClient() } addInventorySlots() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageImporterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageImporterMenu.kt index 554153aef..3ccd5fa1e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageImporterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageImporterMenu.kt @@ -4,7 +4,7 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.inventory.Slot import ru.dbotthepony.mc.otm.block.entity.storage.StorageImporterBlockEntity import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot -import ru.dbotthepony.mc.otm.menu.widget.BooleanPlayerInputWidget +import ru.dbotthepony.mc.otm.menu.widget.NetworkedBooleanInput import ru.dbotthepony.mc.otm.registry.MMenus class StorageImporterMenu @JvmOverloads constructor( @@ -15,15 +15,15 @@ class StorageImporterMenu @JvmOverloads constructor( MMenus.STORAGE_IMPORTER, p_38852_, inventory, tile ) { val busFilterSlots: List - val busFilterState: BooleanPlayerInputWidget + val busFilterState: NetworkedBooleanInput init { if (tile != null) { busFilterSlots = addFilterSlots(tile.filter) - busFilterState = BooleanPlayerInputWidget(this, tile.filter::isWhitelist) + busFilterState = NetworkedBooleanInput(this, tile.filter::isWhitelist) } else { busFilterSlots = addFilterSlots(StorageImporterBlockEntity.MAX_FILTERS) - busFilterState = BooleanPlayerInputWidget(this).asClient() + busFilterState = NetworkedBooleanInput(this).asClient() } addInventorySlots() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/BooleanPlayerInputWidget.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/BooleanPlayerInputWidget.kt deleted file mode 100644 index da5988ed8..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/BooleanPlayerInputWidget.kt +++ /dev/null @@ -1,101 +0,0 @@ -package ru.dbotthepony.mc.otm.menu.widget - -import net.minecraft.network.FriendlyByteBuf -import net.minecraft.world.entity.player.Player -import net.minecraftforge.network.NetworkEvent -import ru.dbotthepony.mc.otm.menu.MatteryMenu -import ru.dbotthepony.mc.otm.network.MatteryPacket -import ru.dbotthepony.mc.otm.network.MenuNetworkChannel -import ru.dbotthepony.mc.otm.network.sender -import java.util.function.Supplier -import kotlin.reflect.KMutableProperty0 - -class BooleanPlayerInputPacket(val id: Int, val value: Boolean) : MatteryPacket { - override fun play(context: Supplier) { - context.get().packetHandled = true - - context.get().enqueueWork { - ((context.get().sender?.containerMenu as? MatteryMenu)?.getWidget(id) as? BooleanPlayerInputWidget)?.userInput(value, context.sender!!) - } - } - - override fun write(buff: FriendlyByteBuf) { - buff.writeInt(id) - buff.writeBoolean(value) - } - - companion object { - fun read(buff: FriendlyByteBuf): BooleanPlayerInputPacket { - return BooleanPlayerInputPacket(buff.readInt(), buff.readBoolean()) - } - } -} - -class BooleanPlayerInputWidget(menu: MatteryMenu) : AbstractWidget(menu) { - var value by menu.mSynchronizer.bool() - var ignoreSpectators by menu.mSynchronizer.bool(true) - - constructor(menu: MatteryMenu, state: KMutableProperty0) : this(menu) { - withClicker { state.set(it) } - withSupplier { state.get() } - } - - var supplier: (() -> Boolean)? = null - var clicker: ((Boolean) -> Unit)? = null - - fun withSupplier(func: () -> Boolean): BooleanPlayerInputWidget { - supplier = func - return this - } - - fun withClicker(func: (Boolean) -> Unit): BooleanPlayerInputWidget { - clicker = func - return this - } - - fun withProperty(state: KMutableProperty0): BooleanPlayerInputWidget { - withClicker { state.set(it) } - withSupplier { state.get() } - return this - } - - fun withoutAnything(): BooleanPlayerInputWidget { - supplier = null - clicker = null - return this - } - - fun asClient(): BooleanPlayerInputWidget { - supplier = null - clicker = { - MenuNetworkChannel.sendToServer(BooleanPlayerInputPacket(slotID, it)) - } - - return this - } - - fun userInput(newValue: Boolean, ply: Player? = null) { - if (ply?.isSpectator == true && ignoreSpectators) { - return - } - - val clicker = clicker - - if (clicker != null) { - clicker.invoke(newValue) - updateServer() - } - } - - fun switchValue(ply: Player? = null) { - userInput(!value, ply) - } - - override fun updateServer() { - val supplier = supplier - - if (supplier != null) { - value = supplier.invoke() - } - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/NetworkedBooleanInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/NetworkedBooleanInput.kt new file mode 100644 index 000000000..52d705aa0 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/NetworkedBooleanInput.kt @@ -0,0 +1,60 @@ +package ru.dbotthepony.mc.otm.menu.widget + +import net.minecraft.world.entity.player.Player +import ru.dbotthepony.mc.otm.menu.MatteryMenu +import kotlin.reflect.KMutableProperty0 + +class NetworkedBooleanInput(menu: MatteryMenu) { + val input = menu.booleanInput { consumer?.invoke(it) } + val value by menu.mSynchronizer.bool(getter = { supplier?.invoke() ?: false }) + + constructor(menu: MatteryMenu, state: KMutableProperty0) : this(menu) { + with(state) + } + + var isClient = false + + fun asClient(): NetworkedBooleanInput { + isClient = true + supplier = null + consumer = null + return this + } + + var supplier: (() -> Boolean)? = null + var consumer: ((Boolean) -> Unit)? = null + + fun withSupplier(func: () -> Boolean): NetworkedBooleanInput { + supplier = func + return this + } + + fun withConsumer(func: (Boolean) -> Unit): NetworkedBooleanInput { + consumer = func + return this + } + + fun with(state: KMutableProperty0): NetworkedBooleanInput { + withConsumer { state.set(it) } + withSupplier { state.get() } + return this + } + + fun clear(): NetworkedBooleanInput { + supplier = null + consumer = null + return this + } + + fun userInput(newValue: Boolean, ply: Player? = null) { + if (isClient) { + input.checkedInput(newValue, ply) + } else { + consumer?.invoke(newValue) + } + } + + fun switchValue(ply: Player? = null) { + userInput(!value, ply) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/NumberPlayerInputWidget.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/NumberPlayerInputWidget.kt deleted file mode 100644 index 7489a7e97..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/NumberPlayerInputWidget.kt +++ /dev/null @@ -1,92 +0,0 @@ -package ru.dbotthepony.mc.otm.menu.widget - -import net.minecraft.network.FriendlyByteBuf -import net.minecraft.world.entity.player.Player -import net.minecraftforge.network.NetworkEvent -import ru.dbotthepony.mc.otm.menu.MatteryMenu -import ru.dbotthepony.mc.otm.network.* -import java.math.BigDecimal -import java.util.function.Supplier - -class NumberPlayerInputPacket(val id: Int, val value: BigDecimal) : MatteryPacket { - override fun play(context: Supplier) { - context.get().packetHandled = true - - context.get().enqueueWork { - ((context.get().sender?.containerMenu as? MatteryMenu)?.getWidget(id) as? NumberPlayerInputWidget)?.userInput(value, context.sender!!) - } - } - - override fun write(buff: FriendlyByteBuf) { - buff.writeInt(id) - buff.writeDecimal(value) - } - - companion object { - fun read(buff: FriendlyByteBuf): NumberPlayerInputPacket { - return NumberPlayerInputPacket(buff.readInt(), buff.readDecimal()) - } - } -} - -class NumberPlayerInputWidget(menu: MatteryMenu) : AbstractWidget(menu) { - var value by menu.mSynchronizer.bigDecimal() - var ignoreSpectators by menu.mSynchronizer.bool(true) - - var supplier: (() -> BigDecimal)? = null - var consumer: ((BigDecimal) -> Unit)? = null - var minValue: BigDecimal? = null - var maxValue: BigDecimal? = null - - fun withSupplier(func: () -> BigDecimal): NumberPlayerInputWidget { - supplier = func - return this - } - - fun withConsumer(func: (BigDecimal) -> Unit): NumberPlayerInputWidget { - consumer = func - return this - } - - fun asClient(): NumberPlayerInputWidget { - supplier = null - - consumer = { - MenuNetworkChannel.sendToServer(NumberPlayerInputPacket(slotID, it)) - } - - return this - } - - fun userInput(newValue: BigDecimal, ply: Player? = null) { - if (ply?.isSpectator == true && ignoreSpectators) { - return - } - - val consumer = consumer - - if (consumer != null) { - @Suppress("name_shadowing") - var newValue = newValue - - if (minValue != null) { - newValue = newValue.max(minValue!!) - } - - if (maxValue != null) { - newValue = newValue.min(maxValue!!) - } - - consumer.invoke(newValue) - updateServer() - } - } - - override fun updateServer() { - val supplier = supplier - - if (supplier != null) { - value = supplier.invoke() - } - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/OneWayPlayerInputWidget.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/OneWayPlayerInputWidget.kt deleted file mode 100644 index 203eae69c..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/OneWayPlayerInputWidget.kt +++ /dev/null @@ -1,53 +0,0 @@ -package ru.dbotthepony.mc.otm.menu.widget - -import net.minecraft.network.FriendlyByteBuf -import net.minecraft.world.entity.player.Player -import net.minecraftforge.network.NetworkEvent -import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.menu.MatteryMenu -import ru.dbotthepony.mc.otm.network.MatteryPacket -import ru.dbotthepony.mc.otm.network.MenuNetworkChannel -import ru.dbotthepony.mc.otm.network.sender -import ru.dbotthepony.mc.otm.runIfClient -import java.util.function.Supplier - -class OneWayPlayerInputPacket(val id: Int) : MatteryPacket { - override fun play(context: Supplier) { - context.get().packetHandled = true - - context.get().enqueueWork { - ((context.get().sender?.containerMenu as? MatteryMenu)?.getWidget(id) as? OneWayPlayerInputWidget)?.userInput(context.sender!!) - } - } - - override fun write(buff: FriendlyByteBuf) { - buff.writeInt(id) - } - - companion object { - fun read(buff: FriendlyByteBuf): OneWayPlayerInputPacket { - return OneWayPlayerInputPacket(buff.readInt()) - } - } -} - -class OneWayPlayerInputWidget(menu: MatteryMenu, clicker: (() -> Unit)? = null) : AbstractWidget(menu) { - val clicker: () -> Unit - var ignoreSpectators by menu.mSynchronizer.bool(true) - - init { - if (clicker != null) { - this.clicker = clicker - } else { - this.clicker = { MenuNetworkChannel.sendToServer(OneWayPlayerInputPacket(slotID)) } - } - } - - fun userInput(ply: Player? = null) { - if (ply?.isSpectator != true || !ignoreSpectators) { - clicker.invoke() - } - } - - override fun updateServer() {} -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt index b22cae9f8..e6fa318e0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt @@ -19,9 +19,6 @@ import ru.dbotthepony.mc.otm.menu.data.ItemViewInteractPacket import ru.dbotthepony.mc.otm.menu.data.StackAddPacket import ru.dbotthepony.mc.otm.menu.data.StackChangePacket import ru.dbotthepony.mc.otm.menu.data.StackRemovePacket -import ru.dbotthepony.mc.otm.menu.widget.BooleanPlayerInputPacket -import ru.dbotthepony.mc.otm.menu.widget.NumberPlayerInputPacket -import ru.dbotthepony.mc.otm.menu.widget.OneWayPlayerInputPacket import java.io.ByteArrayInputStream import java.util.function.Supplier @@ -79,17 +76,12 @@ object MenuNetworkChannel : MatteryNetworkChannel( add(StackChangePacket::class.java, StackChangePacket.Companion::read, NetworkDirection.PLAY_TO_CLIENT) add(StackRemovePacket::class.java, StackRemovePacket.Companion::read, NetworkDirection.PLAY_TO_CLIENT) - // container data + // Menu data + // Server->Client add(MenuFieldPacket::class.java, MenuFieldPacket.Companion::read, NetworkDirection.PLAY_TO_CLIENT) - - // Player input in menus - add(NumberPlayerInputPacket::class.java, NumberPlayerInputPacket.Companion::read, NetworkDirection.PLAY_TO_SERVER) - add(OneWayPlayerInputPacket::class.java, OneWayPlayerInputPacket.Companion::read, NetworkDirection.PLAY_TO_SERVER) - add(BooleanPlayerInputPacket::class.java, BooleanPlayerInputPacket.Companion::read, NetworkDirection.PLAY_TO_SERVER) + // Client->Server add(MatteryMenu.PlayerInputPacket::class.java, MatteryMenu::PlayerInputPacket, NetworkDirection.PLAY_TO_SERVER) - // menu specific - // Item monitor add(ItemMonitorPlayerSettings::class.java, ItemMonitorPlayerSettings.Companion::read) From 0ea4d25755b2f1b46215b7a7ec761ff2542f6700 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 26 Jan 2023 21:11:52 +0700 Subject: [PATCH 0099/1199] Technically NetworkedBooleanInput is no longer widget --- .../mc/otm/client/screen/panels/buttons/CheckBoxInputPanel.kt | 2 +- .../otm/client/screen/panels/buttons/CheckBoxLabelInputPanel.kt | 2 +- src/main/kotlin/ru/dbotthepony/mc/otm/menu/DriveViewerMenu.kt | 2 +- src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterBottlerMenu.kt | 2 +- src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageBusMenu.kt | 2 +- .../kotlin/ru/dbotthepony/mc/otm/menu/StorageExporterMenu.kt | 2 +- .../kotlin/ru/dbotthepony/mc/otm/menu/StorageImporterMenu.kt | 2 +- .../mc/otm/menu/{widget => input}/NetworkedBooleanInput.kt | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/{widget => input}/NetworkedBooleanInput.kt (96%) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxInputPanel.kt index 3c2210d1f..7e705b038 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxInputPanel.kt @@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.buttons import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel -import ru.dbotthepony.mc.otm.menu.widget.NetworkedBooleanInput +import ru.dbotthepony.mc.otm.menu.input.NetworkedBooleanInput open class CheckBoxInputPanel @JvmOverloads constructor( screen: S, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxLabelInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxLabelInputPanel.kt index 106c63ea8..1cdb14217 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxLabelInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxLabelInputPanel.kt @@ -4,7 +4,7 @@ import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.Label -import ru.dbotthepony.mc.otm.menu.widget.NetworkedBooleanInput +import ru.dbotthepony.mc.otm.menu.input.NetworkedBooleanInput open class CheckBoxLabelInputPanel @JvmOverloads constructor( screen: S, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/DriveViewerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/DriveViewerMenu.kt index 8c1487933..56c538b55 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/DriveViewerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/DriveViewerMenu.kt @@ -15,7 +15,7 @@ import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.item.PortableCondensationDriveItem import ru.dbotthepony.mc.otm.menu.data.INetworkedItemViewProvider import ru.dbotthepony.mc.otm.menu.data.NetworkedItemView -import ru.dbotthepony.mc.otm.menu.widget.NetworkedBooleanInput +import ru.dbotthepony.mc.otm.menu.input.NetworkedBooleanInput import ru.dbotthepony.mc.otm.registry.MMenus import ru.dbotthepony.mc.otm.storage.ITEM_STORAGE import ru.dbotthepony.mc.otm.storage.ItemStackWrapper diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterBottlerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterBottlerMenu.kt index ab79c71da..4dd49a0fa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterBottlerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterBottlerMenu.kt @@ -8,7 +8,7 @@ import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.matter.canExtractMatter import ru.dbotthepony.mc.otm.capability.matter.canReceiveMatter -import ru.dbotthepony.mc.otm.menu.widget.NetworkedBooleanInput +import ru.dbotthepony.mc.otm.menu.input.NetworkedBooleanInput import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.core.orNull diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageBusMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageBusMenu.kt index 6f13278d0..56d8a394a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageBusMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageBusMenu.kt @@ -4,7 +4,7 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.inventory.Slot import ru.dbotthepony.mc.otm.block.entity.storage.StorageBusBlockEntity import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot -import ru.dbotthepony.mc.otm.menu.widget.NetworkedBooleanInput +import ru.dbotthepony.mc.otm.menu.input.NetworkedBooleanInput import ru.dbotthepony.mc.otm.registry.MMenus class StorageBusMenu @JvmOverloads constructor( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageExporterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageExporterMenu.kt index d16a7c3c7..6902e798e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageExporterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageExporterMenu.kt @@ -4,7 +4,7 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.inventory.Slot import ru.dbotthepony.mc.otm.block.entity.storage.StorageExporterBlockEntity import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot -import ru.dbotthepony.mc.otm.menu.widget.NetworkedBooleanInput +import ru.dbotthepony.mc.otm.menu.input.NetworkedBooleanInput import ru.dbotthepony.mc.otm.registry.MMenus class StorageExporterMenu @JvmOverloads constructor( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageImporterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageImporterMenu.kt index 3ccd5fa1e..b821aaaa6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageImporterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageImporterMenu.kt @@ -4,7 +4,7 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.inventory.Slot import ru.dbotthepony.mc.otm.block.entity.storage.StorageImporterBlockEntity import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot -import ru.dbotthepony.mc.otm.menu.widget.NetworkedBooleanInput +import ru.dbotthepony.mc.otm.menu.input.NetworkedBooleanInput import ru.dbotthepony.mc.otm.registry.MMenus class StorageImporterMenu @JvmOverloads constructor( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/NetworkedBooleanInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/NetworkedBooleanInput.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/NetworkedBooleanInput.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/NetworkedBooleanInput.kt index 52d705aa0..7d41df71f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/NetworkedBooleanInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/NetworkedBooleanInput.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.menu.widget +package ru.dbotthepony.mc.otm.menu.input import net.minecraft.world.entity.player.Player import ru.dbotthepony.mc.otm.menu.MatteryMenu From 1842074d9e5ff72e8c9a07e8cf597c03f16e4855 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 26 Jan 2023 21:15:01 +0700 Subject: [PATCH 0100/1199] AbstractNetworkedInput --- .../mc/otm/menu/MatterBottlerMenu.kt | 3 +- .../otm/menu/input/AbstractNetworkedInput.kt | 53 +++++++++++++++++++ .../otm/menu/input/NetworkedBooleanInput.kt | 48 ++--------------- 3 files changed, 58 insertions(+), 46 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterBottlerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterBottlerMenu.kt index 4dd49a0fa..4f19a8041 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterBottlerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterBottlerMenu.kt @@ -34,7 +34,8 @@ class MatterBottlerMenu @JvmOverloads constructor( if (tile == null) { progressWidget = ProgressGaugeWidget(this) matterWidget = LevelGaugeWidget(this) - workFlow = NetworkedBooleanInput(this).asClient() + workFlow = NetworkedBooleanInput(this) + workFlow.asClient() } else { progressWidget = ProgressGaugeWidget(this) { tile.getWorkProgress() } matterWidget = LevelGaugeWidget(this, tile.matter) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt new file mode 100644 index 000000000..567fbaf7c --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt @@ -0,0 +1,53 @@ +package ru.dbotthepony.mc.otm.menu.input + +import net.minecraft.world.entity.player.Player +import ru.dbotthepony.mc.otm.menu.MatteryMenu +import kotlin.reflect.KMutableProperty0 + +abstract class AbstractNetworkedInput { + abstract val input: MatteryMenu.PlayerInput + abstract val value: V + + var isClient = false + + fun asClient(): AbstractNetworkedInput { + isClient = true + supplier = null + consumer = null + return this + } + + var supplier: (() -> V)? = null + var consumer: ((V) -> Unit)? = null + + fun withSupplier(func: () -> V): AbstractNetworkedInput { + supplier = func + return this + } + + fun withConsumer(func: (V) -> Unit): AbstractNetworkedInput { + consumer = func + return this + } + + fun with(state: KMutableProperty0): AbstractNetworkedInput { + withConsumer { state.set(it) } + withSupplier { state.get() } + return this + } + + fun clear(): AbstractNetworkedInput { + supplier = null + consumer = null + return this + } + + fun userInput(newValue: V, ply: Player? = null) { + if (isClient) { + input.checkedInput(newValue, ply) + } else { + consumer?.invoke(newValue) + } + } + +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/NetworkedBooleanInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/NetworkedBooleanInput.kt index 7d41df71f..63fb35eb9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/NetworkedBooleanInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/NetworkedBooleanInput.kt @@ -4,56 +4,14 @@ import net.minecraft.world.entity.player.Player import ru.dbotthepony.mc.otm.menu.MatteryMenu import kotlin.reflect.KMutableProperty0 -class NetworkedBooleanInput(menu: MatteryMenu) { - val input = menu.booleanInput { consumer?.invoke(it) } - val value by menu.mSynchronizer.bool(getter = { supplier?.invoke() ?: false }) +class NetworkedBooleanInput(menu: MatteryMenu) : AbstractNetworkedInput() { + override val input = menu.booleanInput { consumer?.invoke(it) } + override val value by menu.mSynchronizer.bool(getter = { supplier?.invoke() ?: false }) constructor(menu: MatteryMenu, state: KMutableProperty0) : this(menu) { with(state) } - var isClient = false - - fun asClient(): NetworkedBooleanInput { - isClient = true - supplier = null - consumer = null - return this - } - - var supplier: (() -> Boolean)? = null - var consumer: ((Boolean) -> Unit)? = null - - fun withSupplier(func: () -> Boolean): NetworkedBooleanInput { - supplier = func - return this - } - - fun withConsumer(func: (Boolean) -> Unit): NetworkedBooleanInput { - consumer = func - return this - } - - fun with(state: KMutableProperty0): NetworkedBooleanInput { - withConsumer { state.set(it) } - withSupplier { state.get() } - return this - } - - fun clear(): NetworkedBooleanInput { - supplier = null - consumer = null - return this - } - - fun userInput(newValue: Boolean, ply: Player? = null) { - if (isClient) { - input.checkedInput(newValue, ply) - } else { - consumer?.invoke(newValue) - } - } - fun switchValue(ply: Player? = null) { userInput(!value, ply) } From 117e59e0284d2e853d016242af6390e91c996935 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 26 Jan 2023 21:46:02 +0700 Subject: [PATCH 0101/1199] NetworkedStringInput --- .../mc/otm/client/screen/HoloSignScreen.kt | 25 ++--------- .../client/screen/panels/TextInputPanel.kt | 17 +++++-- .../panels/buttons/CheckBoxInputPanel.kt | 2 +- .../panels/input/NetworkedStringInputPanel.kt | 45 +++++++++++++++++++ .../dbotthepony/mc/otm/menu/HoloSignMenu.kt | 15 +------ .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 2 + .../dbotthepony/mc/otm/menu/StorageBusMenu.kt | 3 +- .../mc/otm/menu/StorageExporterMenu.kt | 3 +- .../mc/otm/menu/StorageImporterMenu.kt | 3 +- .../otm/menu/input/AbstractNetworkedInput.kt | 12 ++++- .../otm/menu/input/NetworkedBooleanInput.kt | 2 +- .../mc/otm/menu/input/NetworkedStringInput.kt | 13 ++++++ .../mc/otm/network/FieldSynchronizer.kt | 3 ++ 13 files changed, 101 insertions(+), 44 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/NetworkedStringInput.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/HoloSignScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/HoloSignScreen.kt index b2742e0f3..bedffd2d8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/HoloSignScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/HoloSignScreen.kt @@ -5,6 +5,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.TextInputPanel +import ru.dbotthepony.mc.otm.client.screen.panels.input.NetworkedStringInputPanel import ru.dbotthepony.mc.otm.menu.HoloSignMenu import ru.dbotthepony.mc.otm.milliTime @@ -12,27 +13,9 @@ class HoloSignScreen(menu: HoloSignMenu, inventory: Inventory, title: Component) override fun makeMainFrame(): FramePanel> { val frame = FramePanel(this, null, 0f, 0f, 200f, 200f, getTitle()) - object : TextInputPanel(this@HoloSignScreen, frame) { - init { - dock = Dock.FILL - multiLine = true - } - - private var lastChanges = 0L - - override fun onTextChanged(old: String, new: String) { - lastChanges = milliTime + 1000L - menu.textInput.input(new) - } - - override fun tick() { - super.tick() - - if (milliTime >= lastChanges) { - text = menu.text - } - } - } + val input = NetworkedStringInputPanel(this, frame, backend = menu.text) + input.dock = Dock.FILL + input.multiLine = true return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt index 7d2620312..286b6c9cd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt @@ -138,9 +138,10 @@ open class TextInputPanel( var cursorLine = 0 var cursorCharacter = 0 - var textColor = RGBAColor.WHITE - var cursorColor = RGBAColor.GREEN - var backgroundColor = RGBAColor.BLACK + open var textColor = RGBAColor.WHITE + open var cursorColor = RGBAColor.GREEN + open var backgroundColor = RGBAColor.BLACK + open var isActive = true private var oldText = ArrayList() private var textCache: String? = null @@ -626,7 +627,7 @@ open class TextInputPanel( } override fun keyPressedInternal(key: Int, scancode: Int, mods: Int): Boolean { - if (key == InputConstants.KEY_ESCAPE) { + if (key == InputConstants.KEY_ESCAPE || !isActive) { killFocus() return true } @@ -967,6 +968,11 @@ open class TextInputPanel( } override fun charTypedInternal(codepoint: Char, mods: Int): Boolean { + if (!isActive) { + killFocus() + return true + } + wipeSelection() if (!multiLine) @@ -1117,6 +1123,9 @@ open class TextInputPanel( protected set override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { + if (!isActive) + return true + selections.clear() requestFocus() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxInputPanel.kt index 7e705b038..016d91545 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxInputPanel.kt @@ -23,6 +23,6 @@ open class CheckBoxInputPanel @JvmOverloads constructor( set(value) {} override fun onClick() { - widget.userInput(!checked, minecraft.player) + widget.input(!checked, minecraft.player) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt new file mode 100644 index 000000000..b21bd5682 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt @@ -0,0 +1,45 @@ +package ru.dbotthepony.mc.otm.client.screen.panels.input + +import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.client.screen.panels.TextInputPanel +import ru.dbotthepony.mc.otm.menu.input.AbstractNetworkedInput +import ru.dbotthepony.mc.otm.menu.input.NetworkedStringInput +import ru.dbotthepony.mc.otm.milliTime + +open class NetworkedStringInputPanel( + screen: S, + parent: EditablePanel<*>?, + val backend: AbstractNetworkedInput, + x: Float = 0f, + y: Float = 0f, + width: Float = 60f, + height: Float = 11f, +) : TextInputPanel(screen, parent, x, y, width, height) { + override var isActive: Boolean + get() = backend.checkClient() + set(value) {} + + override fun onFocusChanged(new: Boolean, old: Boolean) { + super.onFocusChanged(new, old) + + if (new && !backend.checkClient()) { + killFocus() + } + } + + private var lastChanges = 0L + + override fun onTextChanged(old: String, new: String) { + lastChanges = milliTime + 1000L + backend.clientInput(new) + } + + override fun tick() { + super.tick() + + if (milliTime >= lastChanges) { + text = backend.value + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/HoloSignMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/HoloSignMenu.kt index 0d6dba642..babf9e1d0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/HoloSignMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/HoloSignMenu.kt @@ -4,6 +4,7 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.inventory.Slot import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity import ru.dbotthepony.mc.otm.core.util.BinaryStringCodec +import ru.dbotthepony.mc.otm.menu.input.NetworkedStringInput import ru.dbotthepony.mc.otm.registry.MMenus class HoloSignMenu @JvmOverloads constructor( @@ -11,20 +12,8 @@ class HoloSignMenu @JvmOverloads constructor( inventory: Inventory, tile: HoloSignBlockEntity? = null ) : MatteryMenu(MMenus.HOLO_SIGN, containerId, inventory, tile) { - var text by mSynchronizer.string(name = "text") - - val textInput = PlayerInput(BinaryStringCodec) { - if (tile is HoloSignBlockEntity) - tile.text = it - } + val text = if (tile != null) NetworkedStringInput(this, tile::text) else NetworkedStringInput(this).asClient() override val storageSlots: Collection get() = listOf() - - override fun broadcastChanges() { - super.broadcastChanges() - - if (tile is HoloSignBlockEntity) - text = tile.text - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index d5b09478f..fb1734cec 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -23,6 +23,7 @@ import ru.dbotthepony.mc.otm.compat.curios.isCurioSlot import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot import ru.dbotthepony.mc.otm.core.util.BigDecimalValueCodec +import ru.dbotthepony.mc.otm.core.util.BinaryStringCodec import ru.dbotthepony.mc.otm.core.util.BooleanValueCodec import ru.dbotthepony.mc.otm.core.util.IStreamCodec import ru.dbotthepony.mc.otm.core.util.NullValueCodec @@ -123,6 +124,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( fun bigDecimalInput(allowSpectators: Boolean = false, handler: (BigDecimal) -> Unit) = PlayerInput(BigDecimalValueCodec, allowSpectators, handler) fun booleanInput(allowSpectators: Boolean = false, handler: (Boolean) -> Unit) = PlayerInput(BooleanValueCodec, allowSpectators, handler) + fun stringInput(allowSpectators: Boolean = false, handler: (String) -> Unit) = PlayerInput(BinaryStringCodec, allowSpectators, handler) /** * inventory + exosuit + hotbar (in this order) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageBusMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageBusMenu.kt index 56d8a394a..1ba27a8b0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageBusMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageBusMenu.kt @@ -23,7 +23,8 @@ class StorageBusMenu @JvmOverloads constructor( busFilterState = NetworkedBooleanInput(this, tile.filter::isWhitelist) } else { busFilterSlots = addFilterSlots(StorageBusBlockEntity.MAX_FILTERS) - busFilterState = NetworkedBooleanInput(this).asClient() + busFilterState = NetworkedBooleanInput(this) + busFilterState.asClient() } addInventorySlots() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageExporterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageExporterMenu.kt index 6902e798e..adb914d72 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageExporterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageExporterMenu.kt @@ -23,7 +23,8 @@ class StorageExporterMenu @JvmOverloads constructor( busFilterState = NetworkedBooleanInput(this, tile.filter::isWhitelist) } else { busFilterSlots = addFilterSlots(StorageExporterBlockEntity.MAX_FILTERS) - busFilterState = NetworkedBooleanInput(this).asClient() + busFilterState = NetworkedBooleanInput(this) + busFilterState.asClient() } addInventorySlots() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageImporterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageImporterMenu.kt index b821aaaa6..28372779a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageImporterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageImporterMenu.kt @@ -23,7 +23,8 @@ class StorageImporterMenu @JvmOverloads constructor( busFilterState = NetworkedBooleanInput(this, tile.filter::isWhitelist) } else { busFilterSlots = addFilterSlots(StorageImporterBlockEntity.MAX_FILTERS) - busFilterState = NetworkedBooleanInput(this).asClient() + busFilterState = NetworkedBooleanInput(this) + busFilterState.asClient() } addInventorySlots() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt index 567fbaf7c..f37129057 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.menu.input import net.minecraft.world.entity.player.Player +import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.menu.MatteryMenu import kotlin.reflect.KMutableProperty0 @@ -42,7 +43,7 @@ abstract class AbstractNetworkedInput { return this } - fun userInput(newValue: V, ply: Player? = null) { + fun input(newValue: V, ply: Player? = null) { if (isClient) { input.checkedInput(newValue, ply) } else { @@ -50,4 +51,13 @@ abstract class AbstractNetworkedInput { } } + fun clientInput(newValue: V) { + if (isClient) { + input.checkedInput(newValue, minecraft.player) + } + } + + fun checkClient(): Boolean { + return input.allowSpectators || minecraft.player?.isSpectator == false + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/NetworkedBooleanInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/NetworkedBooleanInput.kt index 63fb35eb9..676636e0b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/NetworkedBooleanInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/NetworkedBooleanInput.kt @@ -13,6 +13,6 @@ class NetworkedBooleanInput(menu: MatteryMenu) : AbstractNetworkedInput } fun switchValue(ply: Player? = null) { - userInput(!value, ply) + input(!value, ply) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/NetworkedStringInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/NetworkedStringInput.kt new file mode 100644 index 000000000..de365c103 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/NetworkedStringInput.kt @@ -0,0 +1,13 @@ +package ru.dbotthepony.mc.otm.menu.input + +import ru.dbotthepony.mc.otm.menu.MatteryMenu +import kotlin.reflect.KMutableProperty0 + +class NetworkedStringInput(menu: MatteryMenu) : AbstractNetworkedInput() { + override val input = menu.stringInput { consumer?.invoke(it.replace('\u0000', ' ')) } + override val value by menu.mSynchronizer.string(getter = { supplier?.invoke() ?: "" }) + + constructor(menu: MatteryMenu, state: KMutableProperty0) : this(menu) { + with(state) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt index 9ac6c20c1..258c199af 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt @@ -171,6 +171,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa fun fraction(getter: () -> Decimal, name: String = nextFieldName()) = ComputedField(getter, ImpreciseFractionValueCodec, name) fun bigDecimal(getter: () -> BigDecimal, name: String = nextFieldName()) = ComputedField(getter, BigDecimalValueCodec, name) fun item(getter: () -> ItemStack, name: String = nextFieldName()) = ComputedField(getter, ItemStackValueCodec, name) + fun string(getter: () -> String, name: String = nextFieldName()) = ComputedField(getter, BinaryStringCodec, name) fun byte(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, ByteValueCodec, name) fun bool(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, BooleanValueCodec, name) @@ -185,6 +186,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa fun fraction(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, ImpreciseFractionValueCodec, name) fun bigDecimal(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, BigDecimalValueCodec, name) fun item(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, ItemStackValueCodec, name) + fun string(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, BinaryStringCodec, name) fun byte(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, ByteValueCodec, name) fun bool(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, BooleanValueCodec, name) @@ -199,6 +201,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa fun fraction(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, ImpreciseFractionValueCodec, name) fun bigDecimal(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, BigDecimalValueCodec, name) fun item(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, ItemStackValueCodec, name) + fun string(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, BinaryStringCodec, name) fun > enum(type: Class, getter: () -> T, name: String = nextFieldName()) = ComputedField(getter, EnumValueCodec(type), name) inline fun > enum(noinline getter: () -> T, name: String = nextFieldName()) = ComputedField(getter, EnumValueCodec(T::class.java), name) From b1c978a3b0b02cbcb2fffdaa0cb3bf30d3f2531d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 26 Jan 2023 21:47:29 +0700 Subject: [PATCH 0102/1199] Fix editing holo sign does not mark chunk dirty --- .../mc/otm/block/entity/decorative/HoloSignBlockEntity.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt index 984f2bfbd..760b447f4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt @@ -15,7 +15,10 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlocks class HoloSignBlockEntity(blockPos: BlockPos, blockState: BlockState) : SynchronizedBlockEntity(MBlockEntities.HOLO_SIGN, blockPos, blockState), MenuProvider { - var text by synchronizer.string("АМОГУС\nБОНУС\nИИСУС\nПЛЮС", name = "text") + var text by synchronizer.string("", name = "text", setter = { value, access, remote -> + setChanged() + access.write(value) + }) override fun createMenu(p_39954_: Int, p_39955_: Inventory, p_39956_: Player): AbstractContainerMenu { return HoloSignMenu(p_39954_, p_39955_, this) From feb1f8d9d6efec8cf7d08ec14f65cd10162568f0 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 26 Jan 2023 21:47:44 +0700 Subject: [PATCH 0103/1199] Rename field -> access in FieldSetter --- .../kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt index 258c199af..f2972666d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt @@ -59,7 +59,7 @@ fun interface FieldGetter { } fun interface FieldSetter { - fun invoke(value: V, field: FieldAccess, setByRemote: Boolean) + fun invoke(value: V, access: FieldAccess, setByRemote: Boolean) } sealed interface IField : ReadOnlyProperty, Supplier, () -> V { From bbe4e0ccad130605156a00a0170c70955f2aede7 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 26 Jan 2023 21:50:50 +0700 Subject: [PATCH 0104/1199] Get rid of client/server fields in networked inputs because they don't make sense anyway --- .../otm/client/screen/MatterBottlerScreen.kt | 2 +- .../panels/buttons/CheckBoxInputPanel.kt | 2 +- .../panels/input/NetworkedStringInputPanel.kt | 7 ++--- .../mc/otm/menu/DriveViewerMenu.kt | 8 ----- .../dbotthepony/mc/otm/menu/HoloSignMenu.kt | 2 +- .../mc/otm/menu/MatterBottlerMenu.kt | 1 - .../dbotthepony/mc/otm/menu/StorageBusMenu.kt | 1 - .../mc/otm/menu/StorageExporterMenu.kt | 1 - .../mc/otm/menu/StorageImporterMenu.kt | 1 - .../otm/menu/input/AbstractNetworkedInput.kt | 29 ++++--------------- .../otm/menu/input/NetworkedBooleanInput.kt | 4 +-- 11 files changed, 14 insertions(+), 44 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterBottlerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterBottlerScreen.kt index 89ea2cff7..60aa8c4c1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterBottlerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterBottlerScreen.kt @@ -35,7 +35,7 @@ class MatterBottlerScreen(menu: MatterBottlerMenu, inventory: Inventory, title: if (minecraft?.player?.isSpectator != true) { val mode = ButtonPanel(this, frame, 46f, 69f, 100f, 20f, TranslatableComponent("otm.matter_bottler.switch_mode")) - mode.bind { menu.workFlow.switchValue(minecraft?.player) } + mode.bind { menu.workFlow.switchValue() } } return frame diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxInputPanel.kt index 016d91545..7213bf4ff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxInputPanel.kt @@ -23,6 +23,6 @@ open class CheckBoxInputPanel @JvmOverloads constructor( set(value) {} override fun onClick() { - widget.input(!checked, minecraft.player) + widget.input(!checked) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt index b21bd5682..3a88b7b05 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt @@ -4,7 +4,6 @@ import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.TextInputPanel import ru.dbotthepony.mc.otm.menu.input.AbstractNetworkedInput -import ru.dbotthepony.mc.otm.menu.input.NetworkedStringInput import ru.dbotthepony.mc.otm.milliTime open class NetworkedStringInputPanel( @@ -17,13 +16,13 @@ open class NetworkedStringInputPanel( height: Float = 11f, ) : TextInputPanel(screen, parent, x, y, width, height) { override var isActive: Boolean - get() = backend.checkClient() + get() = backend.check() set(value) {} override fun onFocusChanged(new: Boolean, old: Boolean) { super.onFocusChanged(new, old) - if (new && !backend.checkClient()) { + if (new && !backend.check()) { killFocus() } } @@ -32,7 +31,7 @@ open class NetworkedStringInputPanel( override fun onTextChanged(old: String, new: String) { lastChanges = milliTime + 1000L - backend.clientInput(new) + backend.input(new) } override fun tick() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/DriveViewerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/DriveViewerMenu.kt index 56c538b55..cd32121ae 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/DriveViewerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/DriveViewerMenu.kt @@ -72,14 +72,6 @@ class DriveViewerMenu @JvmOverloads constructor( val matchTag = NetworkedBooleanInput(this) val matchNBT = NetworkedBooleanInput(this) - init { - if (tile == null) { - isWhitelist.isClient = true - matchTag.isClient = true - matchNBT.isClient = true - } - } - override fun broadcastChanges() { super.broadcastChanges() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/HoloSignMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/HoloSignMenu.kt index babf9e1d0..07e36ac5e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/HoloSignMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/HoloSignMenu.kt @@ -12,7 +12,7 @@ class HoloSignMenu @JvmOverloads constructor( inventory: Inventory, tile: HoloSignBlockEntity? = null ) : MatteryMenu(MMenus.HOLO_SIGN, containerId, inventory, tile) { - val text = if (tile != null) NetworkedStringInput(this, tile::text) else NetworkedStringInput(this).asClient() + val text = if (tile != null) NetworkedStringInput(this, tile::text) else NetworkedStringInput(this) override val storageSlots: Collection get() = listOf() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterBottlerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterBottlerMenu.kt index 4f19a8041..3f73cd46a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterBottlerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterBottlerMenu.kt @@ -35,7 +35,6 @@ class MatterBottlerMenu @JvmOverloads constructor( progressWidget = ProgressGaugeWidget(this) matterWidget = LevelGaugeWidget(this) workFlow = NetworkedBooleanInput(this) - workFlow.asClient() } else { progressWidget = ProgressGaugeWidget(this) { tile.getWorkProgress() } matterWidget = LevelGaugeWidget(this, tile.matter) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageBusMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageBusMenu.kt index 1ba27a8b0..052ef14c7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageBusMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageBusMenu.kt @@ -24,7 +24,6 @@ class StorageBusMenu @JvmOverloads constructor( } else { busFilterSlots = addFilterSlots(StorageBusBlockEntity.MAX_FILTERS) busFilterState = NetworkedBooleanInput(this) - busFilterState.asClient() } addInventorySlots() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageExporterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageExporterMenu.kt index adb914d72..eff1d2179 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageExporterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageExporterMenu.kt @@ -24,7 +24,6 @@ class StorageExporterMenu @JvmOverloads constructor( } else { busFilterSlots = addFilterSlots(StorageExporterBlockEntity.MAX_FILTERS) busFilterState = NetworkedBooleanInput(this) - busFilterState.asClient() } addInventorySlots() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageImporterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageImporterMenu.kt index 28372779a..bcce606d3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageImporterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageImporterMenu.kt @@ -24,7 +24,6 @@ class StorageImporterMenu @JvmOverloads constructor( } else { busFilterSlots = addFilterSlots(StorageImporterBlockEntity.MAX_FILTERS) busFilterState = NetworkedBooleanInput(this) - busFilterState.asClient() } addInventorySlots() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt index f37129057..eb15c3794 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.menu.input -import net.minecraft.world.entity.player.Player import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.menu.MatteryMenu import kotlin.reflect.KMutableProperty0 @@ -9,15 +8,6 @@ abstract class AbstractNetworkedInput { abstract val input: MatteryMenu.PlayerInput abstract val value: V - var isClient = false - - fun asClient(): AbstractNetworkedInput { - isClient = true - supplier = null - consumer = null - return this - } - var supplier: (() -> V)? = null var consumer: ((V) -> Unit)? = null @@ -43,21 +33,14 @@ abstract class AbstractNetworkedInput { return this } - fun input(newValue: V, ply: Player? = null) { - if (isClient) { - input.checkedInput(newValue, ply) - } else { - consumer?.invoke(newValue) - } + /** + * shortcut to checked input of [input] + */ + fun input(newValue: V) { + input.checkedInput(newValue, minecraft.player) } - fun clientInput(newValue: V) { - if (isClient) { - input.checkedInput(newValue, minecraft.player) - } - } - - fun checkClient(): Boolean { + fun check(): Boolean { return input.allowSpectators || minecraft.player?.isSpectator == false } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/NetworkedBooleanInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/NetworkedBooleanInput.kt index 676636e0b..57a26fa77 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/NetworkedBooleanInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/NetworkedBooleanInput.kt @@ -12,7 +12,7 @@ class NetworkedBooleanInput(menu: MatteryMenu) : AbstractNetworkedInput with(state) } - fun switchValue(ply: Player? = null) { - input(!value, ply) + fun switchValue() { + input(!value) } } From 14b2d673d1659c7928c097f049c1bc3ee0e15b01 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 26 Jan 2023 21:51:47 +0700 Subject: [PATCH 0105/1199] docs --- .../ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt index eb15c3794..3892885b1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt @@ -40,6 +40,9 @@ abstract class AbstractNetworkedInput { input.checkedInput(newValue, minecraft.player) } + /** + * checks if local (client) player can modify this input + */ fun check(): Boolean { return input.allowSpectators || minecraft.player?.isSpectator == false } From ff21380939aabaa9782f4165803becfd6ea46771 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 26 Jan 2023 21:54:58 +0700 Subject: [PATCH 0106/1199] Move menus to subpackages --- .../decorative/CargoCrateBlockEntity.kt | 2 +- .../entity/decorative/HoloSignBlockEntity.kt | 2 +- .../matter/MatterCapacitorBankBlockEntity.kt | 2 +- .../matter/MatterDecomposerBlockEntity.kt | 2 +- .../entity/matter/MatterPanelBlockEntity.kt | 2 +- .../matter/MatterRecyclerBlockEntity.kt | 2 +- .../entity/matter/MatterScannerBlockEntity.kt | 2 +- .../matter/PatternStorageBlockEntity.kt | 2 +- .../entity/storage/DriveRackBlockEntity.kt | 2 +- .../entity/storage/StorageBusBlockEntity.kt | 2 +- .../block/entity/storage/StorageInterfaces.kt | 4 ++-- .../StoragePowerSupplierBlockEntity.kt | 2 +- .../entity/tech/AndroidStationBlockEntity.kt | 2 +- .../entity/tech/BatteryBankBlockEntity.kt | 2 +- .../tech/ChemicalGeneratorBlockEntity.kt | 2 +- .../entity/tech/EnergyCounterBlockEntity.kt | 2 +- .../entity/tech/EnergyServoBlockEntity.kt | 2 +- .../entity/tech/PlatePressBlockEntity.kt | 2 +- .../otm/client/screen/AndroidStationScreen.kt | 2 +- .../mc/otm/client/screen/BatteryBankScreen.kt | 4 +--- .../mc/otm/client/screen/CargoCrateScreen.kt | 4 ++-- .../client/screen/ChemicalGeneratorScreen.kt | 2 +- .../mc/otm/client/screen/DriveRackScreen.kt | 3 +-- .../otm/client/screen/EnergyCounterScreen.kt | 2 +- .../mc/otm/client/screen/EnergyServoScreen.kt | 2 +- .../mc/otm/client/screen/HoloSignScreen.kt | 4 +--- .../screen/MatterCapacitorBankScreen.kt | 3 +-- .../client/screen/MatterDecomposerScreen.kt | 2 +- .../mc/otm/client/screen/MatterPanelScreen.kt | 2 +- .../otm/client/screen/MatterRecyclerScreen.kt | 2 +- .../otm/client/screen/MatterScannerScreen.kt | 2 +- .../otm/client/screen/PatternStorageScreen.kt | 3 +-- .../mc/otm/client/screen/PlatePressScreen.kt | 3 +-- .../mc/otm/client/screen/StorageBusScreen.kt | 2 +- .../client/screen/StorageExporterScreen.kt | 2 +- .../client/screen/StorageImporterScreen.kt | 2 +- .../screen/StoragePowerSupplierScreen.kt | 2 +- .../mc/otm/entity/MinecartCargoCrate.kt | 2 +- .../menu/{ => decorative}/CargoCrateMenu.kt | 4 +++- .../otm/menu/{ => decorative}/HoloSignMenu.kt | 4 ++-- .../MinecartCargoCrateMenu.kt | 4 +++- .../menu/{ => matter}/MatterBottlerMenu.kt | 4 +++- .../{ => matter}/MatterCapacitorBankMenu.kt | 4 +++- .../menu/{ => matter}/MatterDecomposerMenu.kt | 5 ++++- .../otm/menu/{ => matter}/MatterPanelMenu.kt | 4 ++-- .../menu/{ => matter}/MatterRecyclerMenu.kt | 4 +++- .../menu/{ => matter}/MatterReplicatorMenu.kt | 7 ++++--- .../menu/{ => matter}/MatterScannerMenu.kt | 4 +++- .../menu/{ => matter}/PatternStorageMenu.kt | 4 +++- .../otm/menu/{ => storage}/DriveRackMenu.kt | 7 +++++-- .../otm/menu/{ => storage}/DriveViewerMenu.kt | 4 +++- .../otm/menu/{ => storage}/ItemMonitorMenu.kt | 4 +++- .../otm/menu/{ => storage}/StorageBusMenu.kt | 3 ++- .../menu/{ => storage}/StorageExporterMenu.kt | 3 ++- .../menu/{ => storage}/StorageImporterMenu.kt | 3 ++- .../{ => storage}/StoragePowerSupplierMenu.kt | 3 ++- .../otm/menu/{ => tech}/AndroidStationMenu.kt | 4 +++- .../mc/otm/menu/{ => tech}/BatteryBankMenu.kt | 5 ++++- .../menu/{ => tech}/ChemicalGeneratorMenu.kt | 4 +++- .../otm/menu/{ => tech}/EnergyCounterMenu.kt | 3 ++- .../mc/otm/menu/{ => tech}/EnergyServoMenu.kt | 4 +++- .../mc/otm/menu/{ => tech}/PlatePressMenu.kt | 5 ++++- .../network/MatteryPlayerNetworkChannel.kt | 2 +- .../mc/otm/network/MenuNetworkChannel.kt | 6 +++--- .../ru/dbotthepony/mc/otm/registry/MMenus.kt | 21 ++++++++++++++++++- 65 files changed, 135 insertions(+), 82 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/{ => decorative}/CargoCrateMenu.kt (88%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/{ => decorative}/HoloSignMenu.kt (87%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/{ => decorative}/MinecartCargoCrateMenu.kt (90%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/{ => matter}/MatterBottlerMenu.kt (93%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/{ => matter}/MatterCapacitorBankMenu.kt (89%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/{ => matter}/MatterDecomposerMenu.kt (90%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/{ => matter}/MatterPanelMenu.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/{ => matter}/MatterRecyclerMenu.kt (90%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/{ => matter}/MatterReplicatorMenu.kt (89%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/{ => matter}/MatterScannerMenu.kt (91%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/{ => matter}/PatternStorageMenu.kt (90%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/{ => storage}/DriveRackMenu.kt (78%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/{ => storage}/DriveViewerMenu.kt (97%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/{ => storage}/ItemMonitorMenu.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/{ => storage}/StorageBusMenu.kt (91%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/{ => storage}/StorageExporterMenu.kt (91%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/{ => storage}/StorageImporterMenu.kt (91%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/{ => storage}/StoragePowerSupplierMenu.kt (90%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/{ => tech}/AndroidStationMenu.kt (96%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/{ => tech}/BatteryBankMenu.kt (86%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/{ => tech}/ChemicalGeneratorMenu.kt (93%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/{ => tech}/EnergyCounterMenu.kt (95%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/{ => tech}/EnergyServoMenu.kt (91%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/{ => tech}/PlatePressMenu.kt (84%) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt index b6b9af778..aa762442c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt @@ -36,7 +36,7 @@ import ru.dbotthepony.mc.otm.container.MatteryContainerHooks import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.menu.CargoCrateMenu +import ru.dbotthepony.mc.otm.menu.decorative.CargoCrateMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MSoundEvents diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt index 760b447f4..7d2283702 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt @@ -10,7 +10,7 @@ import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.level.block.state.BlockState import ru.dbotthepony.mc.otm.block.entity.SynchronizedBlockEntity import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.menu.HoloSignMenu +import ru.dbotthepony.mc.otm.menu.decorative.HoloSignMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlocks diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt index b20dce44f..a12a8c866 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt @@ -28,7 +28,7 @@ import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph -import ru.dbotthepony.mc.otm.menu.MatterCapacitorBankMenu +import ru.dbotthepony.mc.otm.menu.matter.MatterCapacitorBankMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index c05623c36..2b6c5a25c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -32,7 +32,7 @@ import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph import ru.dbotthepony.mc.otm.item.MatterDustItem -import ru.dbotthepony.mc.otm.menu.MatterDecomposerMenu +import ru.dbotthepony.mc.otm.menu.matter.MatterDecomposerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MItems diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt index 26494ce9d..2fe317f8d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt @@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.block.entity.matter import net.minecraft.core.BlockPos import net.minecraft.core.Direction import net.minecraft.world.level.block.state.BlockState -import ru.dbotthepony.mc.otm.menu.MatterPanelMenu +import ru.dbotthepony.mc.otm.menu.matter.MatterPanelMenu import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index 12b1cfccd..66bbb4c06 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -34,7 +34,7 @@ import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph import ru.dbotthepony.mc.otm.item.MatterDustItem import ru.dbotthepony.mc.otm.core.nbt.map -import ru.dbotthepony.mc.otm.menu.MatterRecyclerMenu +import ru.dbotthepony.mc.otm.menu.matter.MatterRecyclerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt index 964f7e16a..be8ab1bb4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt @@ -33,7 +33,7 @@ import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph -import ru.dbotthepony.mc.otm.menu.MatterScannerMenu +import ru.dbotthepony.mc.otm.menu.matter.MatterScannerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MNames diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt index e733387f1..759d29f70 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt @@ -13,7 +13,7 @@ import net.minecraftforge.common.util.LazyOptional import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu -import ru.dbotthepony.mc.otm.menu.PatternStorageMenu +import ru.dbotthepony.mc.otm.menu.matter.PatternStorageMenu import net.minecraft.MethodsReturnNonnullByDefault import net.minecraft.core.Direction import net.minecraft.network.chat.Component diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt index f0fd113eb..8984c1174 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt @@ -19,7 +19,7 @@ import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.container.MatteryContainer -import ru.dbotthepony.mc.otm.menu.DriveRackMenu +import ru.dbotthepony.mc.otm.menu.storage.DriveRackMenu import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.graph.storage.StorageNetworkGraph diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt index f9c6d2cb8..d85cdd401 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt @@ -37,7 +37,7 @@ import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.GraphNodeListener import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode import ru.dbotthepony.mc.otm.graph.storage.StorageNetworkGraph -import ru.dbotthepony.mc.otm.menu.StorageBusMenu +import ru.dbotthepony.mc.otm.menu.storage.StorageBusMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.storage.* diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt index 0e5f177a0..80c059349 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt @@ -36,8 +36,8 @@ import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.GraphNodeListener import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode import ru.dbotthepony.mc.otm.graph.storage.StorageNetworkGraph -import ru.dbotthepony.mc.otm.menu.StorageExporterMenu -import ru.dbotthepony.mc.otm.menu.StorageImporterMenu +import ru.dbotthepony.mc.otm.menu.storage.StorageExporterMenu +import ru.dbotthepony.mc.otm.menu.storage.StorageImporterMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.storage.* diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt index a9e2f61ab..d9cc36200 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt @@ -22,7 +22,7 @@ import ru.dbotthepony.mc.otm.capability.energy.transferChecked import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode import ru.dbotthepony.mc.otm.graph.storage.StorageNetworkGraph -import ru.dbotthepony.mc.otm.menu.StoragePowerSupplierMenu +import ru.dbotthepony.mc.otm.menu.storage.StoragePowerSupplierMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.core.math.getDecimal diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt index 433a754a6..1779b1100 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt @@ -19,7 +19,7 @@ import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.core.ifPresentK -import ru.dbotthepony.mc.otm.menu.AndroidStationMenu +import ru.dbotthepony.mc.otm.menu.tech.AndroidStationMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MNames diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index 56f62e2ab..5e6b4ab70 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -31,7 +31,7 @@ import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.unaryMinus import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.BESubscribeList -import ru.dbotthepony.mc.otm.menu.BatteryBankMenu +import ru.dbotthepony.mc.otm.menu.tech.BatteryBankMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryBlockEntity(MBlockEntities.BATTERY_BANK, p_155229_, p_155230_), IDroppableContainer { 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 31cb59c84..fdb3b94f7 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 @@ -27,7 +27,7 @@ import ru.dbotthepony.mc.otm.capability.energy.GeneratorEnergyStorage import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainerHooks import ru.dbotthepony.mc.otm.core.* -import ru.dbotthepony.mc.otm.menu.ChemicalGeneratorMenu +import ru.dbotthepony.mc.otm.menu.tech.ChemicalGeneratorMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.core.util.WriteOnce diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt index 63849e236..c7dbf226e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt @@ -29,7 +29,7 @@ import ru.dbotthepony.mc.otm.core.nbt.ifHas import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.BESubscribeList -import ru.dbotthepony.mc.otm.menu.EnergyCounterMenu +import ru.dbotthepony.mc.otm.menu.tech.EnergyCounterMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import java.util.* diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt index ba0c52a5d..d7c4b9655 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt @@ -29,7 +29,7 @@ import ru.dbotthepony.mc.otm.container.MatteryContainerHooks import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.menu.EnergyServoMenu +import ru.dbotthepony.mc.otm.menu.tech.EnergyServoMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlocks 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 42513baaf..9b6804ed4 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 @@ -21,7 +21,7 @@ import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainerHooks import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.menu.PlatePressMenu +import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MRecipes import ru.dbotthepony.mc.otm.core.nbt.map diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt index 0f62c7a4d..fddf2072f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt @@ -30,7 +30,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.buttons.ButtonPanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.ifPresentK -import ru.dbotthepony.mc.otm.menu.AndroidStationMenu +import ru.dbotthepony.mc.otm.menu.tech.AndroidStationMenu import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel import ru.dbotthepony.mc.otm.network.AndroidResearchRequestPacket import java.util.* diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/BatteryBankScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/BatteryBankScreen.kt index 8cb61abca..130c7aae1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/BatteryBankScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/BatteryBankScreen.kt @@ -1,12 +1,10 @@ package ru.dbotthepony.mc.otm.client.screen import net.minecraft.network.chat.Component -import ru.dbotthepony.mc.otm.menu.BatteryBankMenu +import ru.dbotthepony.mc.otm.menu.tech.BatteryBankMenu import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.panels.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel -import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel -import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel class BatteryBankScreen(menu: BatteryBankMenu, p_97742_: Inventory, p_97743_: Component) : diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/CargoCrateScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/CargoCrateScreen.kt index f941a1f48..d9f37fa14 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/CargoCrateScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/CargoCrateScreen.kt @@ -5,8 +5,8 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.GridPanel import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel -import ru.dbotthepony.mc.otm.menu.CargoCrateMenu -import ru.dbotthepony.mc.otm.menu.MinecartCargoCrateMenu +import ru.dbotthepony.mc.otm.menu.decorative.CargoCrateMenu +import ru.dbotthepony.mc.otm.menu.decorative.MinecartCargoCrateMenu class CargoCrateScreen(menu: CargoCrateMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { override fun makeMainFrame(): FramePanel> { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ChemicalGeneratorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ChemicalGeneratorScreen.kt index 3558493f9..303647e70 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ChemicalGeneratorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ChemicalGeneratorScreen.kt @@ -6,7 +6,7 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel -import ru.dbotthepony.mc.otm.menu.ChemicalGeneratorMenu +import ru.dbotthepony.mc.otm.menu.tech.ChemicalGeneratorMenu class ChemicalGeneratorScreen(menu: ChemicalGeneratorMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { override fun makeMainFrame(): FramePanel> { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/DriveRackScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/DriveRackScreen.kt index 225590967..eb4459045 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/DriveRackScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/DriveRackScreen.kt @@ -1,12 +1,11 @@ package ru.dbotthepony.mc.otm.client.screen import net.minecraft.network.chat.Component -import ru.dbotthepony.mc.otm.menu.DriveRackMenu +import ru.dbotthepony.mc.otm.menu.storage.DriveRackMenu import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.panels.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel -import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel class DriveRackScreen(menu: DriveRackMenu, inventory: Inventory, title: Component) : diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/EnergyCounterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/EnergyCounterScreen.kt index 46955192e..15b5cd9d6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/EnergyCounterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/EnergyCounterScreen.kt @@ -6,7 +6,7 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.ButtonPanel import ru.dbotthepony.mc.otm.core.util.formatPower -import ru.dbotthepony.mc.otm.menu.EnergyCounterMenu +import ru.dbotthepony.mc.otm.menu.tech.EnergyCounterMenu class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { override fun makeMainFrame(): FramePanel> { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/EnergyServoScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/EnergyServoScreen.kt index 16cbe0c0c..1f7e61d93 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/EnergyServoScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/EnergyServoScreen.kt @@ -11,7 +11,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.widget.HorizontalPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalPowerGaugePanel -import ru.dbotthepony.mc.otm.menu.EnergyServoMenu +import ru.dbotthepony.mc.otm.menu.tech.EnergyServoMenu class EnergyServoScreen(menu: EnergyServoMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { override fun makeMainFrame(): FramePanel> { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/HoloSignScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/HoloSignScreen.kt index bedffd2d8..07580cefa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/HoloSignScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/HoloSignScreen.kt @@ -4,10 +4,8 @@ import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel -import ru.dbotthepony.mc.otm.client.screen.panels.TextInputPanel import ru.dbotthepony.mc.otm.client.screen.panels.input.NetworkedStringInputPanel -import ru.dbotthepony.mc.otm.menu.HoloSignMenu -import ru.dbotthepony.mc.otm.milliTime +import ru.dbotthepony.mc.otm.menu.decorative.HoloSignMenu class HoloSignScreen(menu: HoloSignMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, title) { override fun makeMainFrame(): FramePanel> { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterCapacitorBankScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterCapacitorBankScreen.kt index a104919dc..67189909f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterCapacitorBankScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterCapacitorBankScreen.kt @@ -1,11 +1,10 @@ package ru.dbotthepony.mc.otm.client.screen import net.minecraft.network.chat.Component -import ru.dbotthepony.mc.otm.menu.MatterCapacitorBankMenu +import ru.dbotthepony.mc.otm.menu.matter.MatterCapacitorBankMenu import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.MatterCapacitorSlotPanel -import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel class MatterCapacitorBankScreen(p_97741_: MatterCapacitorBankMenu, p_97742_: Inventory, p_97743_: Component) : diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterDecomposerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterDecomposerScreen.kt index a95600d33..7a49939cb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterDecomposerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterDecomposerScreen.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen import net.minecraft.network.chat.Component -import ru.dbotthepony.mc.otm.menu.MatterDecomposerMenu +import ru.dbotthepony.mc.otm.menu.matter.MatterDecomposerMenu import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.panels.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterPanelScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterPanelScreen.kt index 15af82304..f2d82cedf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterPanelScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterPanelScreen.kt @@ -12,7 +12,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.ButtonPanel import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.integerDivisionDown -import ru.dbotthepony.mc.otm.menu.MatterPanelMenu +import ru.dbotthepony.mc.otm.menu.matter.MatterPanelMenu import ru.dbotthepony.mc.otm.menu.ReplicationRequestPacket import ru.dbotthepony.mc.otm.network.MenuNetworkChannel import yalter.mousetweaks.api.MouseTweaksDisableWheelTweak diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterRecyclerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterRecyclerScreen.kt index a6e9b0a2d..f9f99af63 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterRecyclerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterRecyclerScreen.kt @@ -8,7 +8,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel -import ru.dbotthepony.mc.otm.menu.MatterRecyclerMenu +import ru.dbotthepony.mc.otm.menu.matter.MatterRecyclerMenu class MatterRecyclerScreen(menu: MatterRecyclerMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { override fun makeMainFrame(): FramePanel> { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterScannerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterScannerScreen.kt index 9e3c414ed..baf34c53a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterScannerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterScannerScreen.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen import net.minecraft.network.chat.Component -import ru.dbotthepony.mc.otm.menu.MatterScannerMenu +import ru.dbotthepony.mc.otm.menu.matter.MatterScannerMenu import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.panels.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/PatternStorageScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/PatternStorageScreen.kt index 9ef311ae5..57278f817 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/PatternStorageScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/PatternStorageScreen.kt @@ -1,11 +1,10 @@ package ru.dbotthepony.mc.otm.client.screen import net.minecraft.network.chat.Component -import ru.dbotthepony.mc.otm.menu.PatternStorageMenu +import ru.dbotthepony.mc.otm.menu.matter.PatternStorageMenu import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.PatternSlotPanel -import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.PatternGaugePanel class PatternStorageScreen(p_97741_: PatternStorageMenu, p_97742_: Inventory, p_97743_: Component) : diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/PlatePressScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/PlatePressScreen.kt index 24cbe87d0..d5bfd55aa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/PlatePressScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/PlatePressScreen.kt @@ -5,10 +5,9 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.panels.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel -import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel -import ru.dbotthepony.mc.otm.menu.PlatePressMenu +import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu class PlatePressScreen(menu: PlatePressMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageBusScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageBusScreen.kt index e2546153b..1587e2a56 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageBusScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageBusScreen.kt @@ -7,7 +7,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.CheckBoxLabelInputPanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel -import ru.dbotthepony.mc.otm.menu.StorageBusMenu +import ru.dbotthepony.mc.otm.menu.storage.StorageBusMenu class StorageBusScreen(menu: StorageBusMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageExporterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageExporterScreen.kt index ff6276da6..2046ef281 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageExporterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageExporterScreen.kt @@ -7,7 +7,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.CheckBoxLabelInputPanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel -import ru.dbotthepony.mc.otm.menu.StorageExporterMenu +import ru.dbotthepony.mc.otm.menu.storage.StorageExporterMenu class StorageExporterScreen(menu: StorageExporterMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageImporterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageImporterScreen.kt index 5da4971ac..99f7cee3e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageImporterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageImporterScreen.kt @@ -7,7 +7,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.CheckBoxLabelInputPanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel -import ru.dbotthepony.mc.otm.menu.StorageImporterMenu +import ru.dbotthepony.mc.otm.menu.storage.StorageImporterMenu class StorageImporterScreen(menu: StorageImporterMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StoragePowerSupplierScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StoragePowerSupplierScreen.kt index e3bc34cef..b63cf5435 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StoragePowerSupplierScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StoragePowerSupplierScreen.kt @@ -7,7 +7,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.widget.HorizontalPowerGaugePanel import ru.dbotthepony.mc.otm.core.util.formatPower -import ru.dbotthepony.mc.otm.menu.StoragePowerSupplierMenu +import ru.dbotthepony.mc.otm.menu.storage.StoragePowerSupplierMenu class StoragePowerSupplierScreen(menu: StoragePowerSupplierMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/MinecartCargoCrate.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/MinecartCargoCrate.kt index 6f205d8f8..d1a2e24f5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/MinecartCargoCrate.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/MinecartCargoCrate.kt @@ -18,7 +18,7 @@ import net.minecraft.world.level.gameevent.GameEvent import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock import ru.dbotthepony.mc.otm.block.entity.decorative.CargoCrateBlockEntity import ru.dbotthepony.mc.otm.core.position -import ru.dbotthepony.mc.otm.menu.MinecartCargoCrateMenu +import ru.dbotthepony.mc.otm.menu.decorative.MinecartCargoCrateMenu import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRegistry import ru.dbotthepony.mc.otm.registry.MSoundEvents diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/CargoCrateMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt similarity index 88% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/CargoCrateMenu.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt index b3681244f..824ecf6e0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/CargoCrateMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt @@ -1,10 +1,12 @@ -package ru.dbotthepony.mc.otm.menu +package ru.dbotthepony.mc.otm.menu.decorative import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import ru.dbotthepony.mc.otm.core.ImmutableList import ru.dbotthepony.mc.otm.block.entity.decorative.CargoCrateBlockEntity +import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.registry.MMenus class CargoCrateMenu @JvmOverloads constructor( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/HoloSignMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt similarity index 87% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/HoloSignMenu.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt index 07e36ac5e..871f21e60 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/HoloSignMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt @@ -1,9 +1,9 @@ -package ru.dbotthepony.mc.otm.menu +package ru.dbotthepony.mc.otm.menu.decorative import net.minecraft.world.entity.player.Inventory import net.minecraft.world.inventory.Slot import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity -import ru.dbotthepony.mc.otm.core.util.BinaryStringCodec +import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.input.NetworkedStringInput import ru.dbotthepony.mc.otm.registry.MMenus diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MinecartCargoCrateMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt similarity index 90% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/MinecartCargoCrateMenu.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt index e6564d7d0..8959e986f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MinecartCargoCrateMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.menu +package ru.dbotthepony.mc.otm.menu.decorative import net.minecraft.world.Container import net.minecraft.world.SimpleContainer @@ -7,6 +7,8 @@ import net.minecraft.world.entity.player.Player import ru.dbotthepony.mc.otm.core.ImmutableList import ru.dbotthepony.mc.otm.block.entity.decorative.CargoCrateBlockEntity import ru.dbotthepony.mc.otm.entity.MinecartCargoCrate +import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.registry.MMenus class MinecartCargoCrateMenu @JvmOverloads constructor( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterBottlerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt similarity index 93% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterBottlerMenu.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt index 3f73cd46a..bfcc044d2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterBottlerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.menu +package ru.dbotthepony.mc.otm.menu.matter import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory @@ -12,6 +12,8 @@ import ru.dbotthepony.mc.otm.menu.input.NetworkedBooleanInput import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.core.orNull +import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu +import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.registry.MMenus class MatterBottlerMenu @JvmOverloads constructor( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterCapacitorBankMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterCapacitorBankMenu.kt similarity index 89% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterCapacitorBankMenu.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterCapacitorBankMenu.kt index b03c8411b..c96ac0f08 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterCapacitorBankMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterCapacitorBankMenu.kt @@ -1,10 +1,12 @@ -package ru.dbotthepony.mc.otm.menu +package ru.dbotthepony.mc.otm.menu.matter import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.core.ImmutableList import ru.dbotthepony.mc.otm.block.entity.matter.MatterCapacitorBankBlockEntity import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.menu.MatterContainerInputSlot +import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterDecomposerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt similarity index 90% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterDecomposerMenu.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt index 9156eb5bb..6d6b58960 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterDecomposerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.menu +package ru.dbotthepony.mc.otm.menu.matter import com.google.common.collect.ImmutableList import kotlin.jvm.JvmOverloads @@ -12,6 +12,9 @@ import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.matter.MatterManager +import ru.dbotthepony.mc.otm.menu.MachineOutputSlot +import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu +import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.registry.MMenus class MatterDecomposerMenu @JvmOverloads constructor( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterPanelMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterPanelMenu.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt index 04f6ae207..250d8d8df 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterPanelMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.menu +package ru.dbotthepony.mc.otm.menu.matter import net.minecraft.network.FriendlyByteBuf import net.minecraft.server.level.ServerPlayer @@ -8,12 +8,12 @@ import net.minecraft.world.inventory.Slot import net.minecraftforge.network.NetworkEvent import net.minecraftforge.network.PacketDistributor import org.apache.logging.log4j.LogManager -import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.block.entity.matter.MatterPanelBlockEntity import ru.dbotthepony.mc.otm.capability.matter.* import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphListener import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph +import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.network.* import ru.dbotthepony.mc.otm.registry.MMenus import java.util.* diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterRecyclerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt similarity index 90% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterRecyclerMenu.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt index fc9a02bb1..1c6e4b6b0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterRecyclerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.menu +package ru.dbotthepony.mc.otm.menu.matter import com.google.common.collect.ImmutableList import net.minecraft.world.SimpleContainer @@ -7,6 +7,8 @@ import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.block.entity.matter.MatterRecyclerBlockEntity import ru.dbotthepony.mc.otm.item.MatterDustItem +import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu +import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterReplicatorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt similarity index 89% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterReplicatorMenu.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt index 39e16d5d3..a5fbfa75d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterReplicatorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.menu +package ru.dbotthepony.mc.otm.menu.matter import kotlin.jvm.JvmOverloads import net.minecraft.world.entity.player.Inventory @@ -6,8 +6,9 @@ import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import net.minecraft.world.SimpleContainer -import net.minecraft.world.inventory.Slot import ru.dbotthepony.mc.otm.core.ImmutableList +import ru.dbotthepony.mc.otm.menu.MachineOutputSlot +import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.registry.MMenus class MatterReplicatorMenu @JvmOverloads constructor( @@ -40,4 +41,4 @@ class MatterReplicatorMenu @JvmOverloads constructor( addInventorySlots() } -} \ No newline at end of file +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterScannerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt similarity index 91% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterScannerMenu.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt index 81eb2fea8..8357aeb71 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatterScannerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.menu +package ru.dbotthepony.mc.otm.menu.matter import kotlin.jvm.JvmOverloads import net.minecraft.world.entity.player.Inventory @@ -9,6 +9,8 @@ import net.minecraft.world.SimpleContainer import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.matter.MatterManager +import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu +import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.registry.MMenus class MatterScannerMenu @JvmOverloads constructor( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/PatternStorageMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt similarity index 90% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/PatternStorageMenu.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt index 146e867e2..4257dd380 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/PatternStorageMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt @@ -1,10 +1,12 @@ -package ru.dbotthepony.mc.otm.menu +package ru.dbotthepony.mc.otm.menu.matter import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.core.ImmutableList import ru.dbotthepony.mc.otm.block.entity.matter.PatternStorageBlockEntity import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.menu.PatternSlot import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/DriveRackMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveRackMenu.kt similarity index 78% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/DriveRackMenu.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveRackMenu.kt index 7b31075c2..fd0bad009 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/DriveRackMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveRackMenu.kt @@ -1,9 +1,12 @@ -package ru.dbotthepony.mc.otm.menu +package ru.dbotthepony.mc.otm.menu.storage import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.core.ImmutableList import ru.dbotthepony.mc.otm.block.entity.storage.DriveRackBlockEntity +import ru.dbotthepony.mc.otm.menu.DriveSlot +import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu +import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.registry.MMenus class DriveRackMenu @JvmOverloads constructor( @@ -24,4 +27,4 @@ class DriveRackMenu @JvmOverloads constructor( addInventorySlots() } -} \ No newline at end of file +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/DriveViewerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt similarity index 97% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/DriveViewerMenu.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt index cd32121ae..f30c08c7b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/DriveViewerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.menu +package ru.dbotthepony.mc.otm.menu.storage import com.google.common.collect.ImmutableList import net.minecraft.world.SimpleContainer @@ -13,6 +13,8 @@ import ru.dbotthepony.mc.otm.capability.drive.IMatteryDrive import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.item.PortableCondensationDriveItem +import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu +import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.data.INetworkedItemViewProvider import ru.dbotthepony.mc.otm.menu.data.NetworkedItemView import ru.dbotthepony.mc.otm.menu.input.NetworkedBooleanInput diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ItemMonitorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/ItemMonitorMenu.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt index 925cec1ef..6fb8bbddb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ItemMonitorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.menu +package ru.dbotthepony.mc.otm.menu.storage import net.minecraft.server.level.ServerPlayer import net.minecraft.world.Container @@ -12,6 +12,8 @@ import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorPlayerSettings import ru.dbotthepony.mc.otm.container.get import ru.dbotthepony.mc.otm.core.collect.nonEmpty +import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu +import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.data.INetworkedItemViewProvider import ru.dbotthepony.mc.otm.menu.data.NetworkedItemView import ru.dbotthepony.mc.otm.network.MenuNetworkChannel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageBusMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageBusMenu.kt similarity index 91% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageBusMenu.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageBusMenu.kt index 052ef14c7..8cfa1a5f3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageBusMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageBusMenu.kt @@ -1,9 +1,10 @@ -package ru.dbotthepony.mc.otm.menu +package ru.dbotthepony.mc.otm.menu.storage import net.minecraft.world.entity.player.Inventory import net.minecraft.world.inventory.Slot import ru.dbotthepony.mc.otm.block.entity.storage.StorageBusBlockEntity import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot +import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.input.NetworkedBooleanInput import ru.dbotthepony.mc.otm.registry.MMenus diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageExporterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageExporterMenu.kt similarity index 91% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageExporterMenu.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageExporterMenu.kt index eff1d2179..840ee3fd4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageExporterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageExporterMenu.kt @@ -1,9 +1,10 @@ -package ru.dbotthepony.mc.otm.menu +package ru.dbotthepony.mc.otm.menu.storage import net.minecraft.world.entity.player.Inventory import net.minecraft.world.inventory.Slot import ru.dbotthepony.mc.otm.block.entity.storage.StorageExporterBlockEntity import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot +import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.input.NetworkedBooleanInput import ru.dbotthepony.mc.otm.registry.MMenus diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageImporterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageImporterMenu.kt similarity index 91% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageImporterMenu.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageImporterMenu.kt index bcce606d3..bc41f66ac 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StorageImporterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageImporterMenu.kt @@ -1,9 +1,10 @@ -package ru.dbotthepony.mc.otm.menu +package ru.dbotthepony.mc.otm.menu.storage import net.minecraft.world.entity.player.Inventory import net.minecraft.world.inventory.Slot import ru.dbotthepony.mc.otm.block.entity.storage.StorageImporterBlockEntity import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot +import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.input.NetworkedBooleanInput import ru.dbotthepony.mc.otm.registry.MMenus diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StoragePowerSupplierMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StoragePowerSupplierMenu.kt similarity index 90% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/StoragePowerSupplierMenu.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StoragePowerSupplierMenu.kt index 0e7483177..a4be8757b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/StoragePowerSupplierMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StoragePowerSupplierMenu.kt @@ -1,8 +1,9 @@ -package ru.dbotthepony.mc.otm.menu +package ru.dbotthepony.mc.otm.menu.storage import net.minecraft.world.entity.player.Inventory import net.minecraft.world.inventory.Slot import ru.dbotthepony.mc.otm.block.entity.storage.StoragePowerSupplierBlockEntity +import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.registry.MMenus class StoragePowerSupplierMenu @JvmOverloads constructor( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/AndroidStationMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/AndroidStationMenu.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt index 1c61ad696..aafee79a1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/AndroidStationMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.menu +package ru.dbotthepony.mc.otm.menu.tech import com.google.common.collect.ImmutableList import net.minecraft.server.level.ServerPlayer @@ -12,6 +12,8 @@ import net.minecraftforge.common.capabilities.ForgeCapabilities import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu +import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.registry.MMenus import kotlin.reflect.KMutableProperty0 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/BatteryBankMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt similarity index 86% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/BatteryBankMenu.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt index 8bb3fa687..e470ad129 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/BatteryBankMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.menu +package ru.dbotthepony.mc.otm.menu.tech import net.minecraft.world.Container import kotlin.jvm.JvmOverloads @@ -9,6 +9,9 @@ import ru.dbotthepony.mc.otm.core.ImmutableList import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.core.orNull +import ru.dbotthepony.mc.otm.menu.BatterySlot +import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.registry.MMenus class BatteryBankMenu @JvmOverloads constructor( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ChemicalGeneratorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt similarity index 93% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/ChemicalGeneratorMenu.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt index f01b5a004..4950063cd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ChemicalGeneratorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.menu +package ru.dbotthepony.mc.otm.menu.tech import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory @@ -7,6 +7,8 @@ import net.minecraftforge.common.ForgeHooks import net.minecraftforge.common.capabilities.ForgeCapabilities import ru.dbotthepony.mc.otm.block.entity.tech.ChemicalGeneratorBlockEntity import ru.dbotthepony.mc.otm.core.ifPresentK +import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyCounterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyCounterMenu.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyCounterMenu.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyCounterMenu.kt index 106203c19..01aac2e7d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyCounterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyCounterMenu.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.menu +package ru.dbotthepony.mc.otm.menu.tech import net.minecraft.core.Direction import kotlin.jvm.JvmOverloads @@ -8,6 +8,7 @@ import net.minecraft.world.level.block.Block import ru.dbotthepony.mc.otm.block.tech.EnergyCounterBlock import ru.dbotthepony.mc.otm.block.entity.tech.EnergyCounterBlockEntity import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.registry.MMenus import java.math.BigDecimal diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyServoMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt similarity index 91% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyServoMenu.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt index a96ca4071..c452c4a83 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/EnergyServoMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.menu +package ru.dbotthepony.mc.otm.menu.tech import com.google.common.collect.ImmutableList import net.minecraft.world.SimpleContainer @@ -7,6 +7,8 @@ import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.block.entity.tech.EnergyServoBlockEntity import ru.dbotthepony.mc.otm.capability.energy +import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/PlatePressMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt similarity index 84% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/PlatePressMenu.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt index ecf50b2bb..ff88899f7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/PlatePressMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt @@ -1,9 +1,12 @@ -package ru.dbotthepony.mc.otm.menu +package ru.dbotthepony.mc.otm.menu.tech import com.google.common.collect.ImmutableList import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity +import ru.dbotthepony.mc.otm.menu.MachineOutputSlot +import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu +import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt index 755bae55d..0abf41fb7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt @@ -27,7 +27,7 @@ import ru.dbotthepony.mc.otm.client.render.ShockwaveRenderer import ru.dbotthepony.mc.otm.container.get import ru.dbotthepony.mc.otm.container.set import ru.dbotthepony.mc.otm.core.math.Vector -import ru.dbotthepony.mc.otm.menu.AndroidStationMenu +import ru.dbotthepony.mc.otm.menu.tech.AndroidStationMenu import ru.dbotthepony.mc.otm.menu.ExoPackInventoryMenu import ru.dbotthepony.mc.otm.registry.AndroidFeatures import ru.dbotthepony.mc.otm.registry.MRegistry diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt index e6fa318e0..c8fb6826b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt @@ -9,11 +9,11 @@ import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorPlayerSettings import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.compat.InventoryScrollPacket import ru.dbotthepony.mc.otm.container.ItemFilterSlotPacket -import ru.dbotthepony.mc.otm.menu.CancelTaskPacket +import ru.dbotthepony.mc.otm.menu.matter.CancelTaskPacket import ru.dbotthepony.mc.otm.menu.MatteryMenu -import ru.dbotthepony.mc.otm.menu.PatternsChangePacket +import ru.dbotthepony.mc.otm.menu.matter.PatternsChangePacket import ru.dbotthepony.mc.otm.menu.ReplicationRequestPacket -import ru.dbotthepony.mc.otm.menu.TasksChangePacket +import ru.dbotthepony.mc.otm.menu.matter.TasksChangePacket import ru.dbotthepony.mc.otm.menu.data.ClearItemViewPacket import ru.dbotthepony.mc.otm.menu.data.ItemViewInteractPacket import ru.dbotthepony.mc.otm.menu.data.StackAddPacket 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 ae03a7a64..52dc1f3ec 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt @@ -4,12 +4,31 @@ import net.minecraft.client.gui.screens.MenuScreens import net.minecraft.world.inventory.MenuType import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.client.screen.* import ru.dbotthepony.mc.otm.menu.* +import ru.dbotthepony.mc.otm.menu.decorative.CargoCrateMenu +import ru.dbotthepony.mc.otm.menu.decorative.HoloSignMenu +import ru.dbotthepony.mc.otm.menu.decorative.MinecartCargoCrateMenu +import ru.dbotthepony.mc.otm.menu.matter.MatterCapacitorBankMenu +import ru.dbotthepony.mc.otm.menu.matter.MatterDecomposerMenu +import ru.dbotthepony.mc.otm.menu.matter.MatterPanelMenu +import ru.dbotthepony.mc.otm.menu.matter.MatterRecyclerMenu +import ru.dbotthepony.mc.otm.menu.matter.MatterScannerMenu +import ru.dbotthepony.mc.otm.menu.matter.PatternStorageMenu +import ru.dbotthepony.mc.otm.menu.storage.DriveRackMenu +import ru.dbotthepony.mc.otm.menu.storage.StorageBusMenu +import ru.dbotthepony.mc.otm.menu.storage.StorageExporterMenu +import ru.dbotthepony.mc.otm.menu.storage.StorageImporterMenu +import ru.dbotthepony.mc.otm.menu.storage.StoragePowerSupplierMenu +import ru.dbotthepony.mc.otm.menu.tech.AndroidStationMenu +import ru.dbotthepony.mc.otm.menu.tech.BatteryBankMenu +import ru.dbotthepony.mc.otm.menu.tech.ChemicalGeneratorMenu +import ru.dbotthepony.mc.otm.menu.tech.EnergyCounterMenu +import ru.dbotthepony.mc.otm.menu.tech.EnergyServoMenu +import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu object MMenus { private val registry = DeferredRegister.create(ForgeRegistries.MENU_TYPES, OverdriveThatMatters.MOD_ID) From 68736860d9d8a708cd61b7ec10493dcea0c4c36c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 26 Jan 2023 21:57:22 +0700 Subject: [PATCH 0107/1199] Move screens to subpackages --- .../screen/decorative/CargoCrateScreen.kt | 21 +++++++++++++++++++ .../screen/{ => decorative}/HoloSignScreen.kt | 3 ++- .../MinecartCargoCrateScreen.kt} | 16 ++------------ .../{ => matter}/MatterBottlerScreen.kt | 3 ++- .../{ => matter}/MatterCapacitorBankScreen.kt | 3 ++- .../{ => matter}/MatterDecomposerScreen.kt | 3 ++- .../screen/{ => matter}/MatterPanelScreen.kt | 3 ++- .../{ => matter}/MatterRecyclerScreen.kt | 3 ++- .../{ => matter}/MatterReplicatorScreen.kt | 5 +++-- .../{ => matter}/MatterScannerScreen.kt | 3 ++- .../{ => matter}/PatternStorageScreen.kt | 3 ++- .../screen/{ => storage}/DriveRackScreen.kt | 3 ++- .../screen/{ => storage}/DriveViewerScreen.kt | 3 ++- .../screen/{ => storage}/ItemMonitorScreen.kt | 9 ++++---- .../screen/{ => storage}/StorageBusScreen.kt | 3 ++- .../{ => storage}/StorageExporterScreen.kt | 3 ++- .../{ => storage}/StorageImporterScreen.kt | 3 ++- .../StoragePowerSupplierScreen.kt | 3 ++- .../screen/{ => tech}/AndroidStationScreen.kt | 3 ++- .../screen/{ => tech}/BatteryBankScreen.kt | 3 ++- .../{ => tech}/ChemicalGeneratorScreen.kt | 3 ++- .../screen/{ => tech}/EnergyCounterScreen.kt | 3 ++- .../screen/{ => tech}/EnergyServoScreen.kt | 3 ++- .../screen/{ => tech}/PlatePressScreen.kt | 3 ++- .../ru/dbotthepony/mc/otm/registry/MMenus.kt | 14 +++++++++++++ 25 files changed, 85 insertions(+), 40 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/{ => decorative}/HoloSignScreen.kt (87%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/{CargoCrateScreen.kt => decorative/MinecartCargoCrateScreen.kt} (59%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/{ => matter}/MatterBottlerScreen.kt (94%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/{ => matter}/MatterCapacitorBankScreen.kt (90%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/{ => matter}/MatterDecomposerScreen.kt (92%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/{ => matter}/MatterPanelScreen.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/{ => matter}/MatterRecyclerScreen.kt (92%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/{ => matter}/MatterReplicatorScreen.kt (92%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/{ => matter}/MatterScannerScreen.kt (92%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/{ => matter}/PatternStorageScreen.kt (90%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/{ => storage}/DriveRackScreen.kt (91%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/{ => storage}/DriveViewerScreen.kt (97%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/{ => storage}/ItemMonitorScreen.kt (96%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/{ => storage}/StorageBusScreen.kt (91%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/{ => storage}/StorageExporterScreen.kt (91%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/{ => storage}/StorageImporterScreen.kt (91%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/{ => storage}/StoragePowerSupplierScreen.kt (94%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/{ => tech}/AndroidStationScreen.kt (99%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/{ => tech}/BatteryBankScreen.kt (89%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/{ => tech}/ChemicalGeneratorScreen.kt (92%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/{ => tech}/EnergyCounterScreen.kt (96%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/{ => tech}/EnergyServoScreen.kt (95%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/{ => tech}/PlatePressScreen.kt (91%) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt new file mode 100644 index 000000000..2286a99bb --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt @@ -0,0 +1,21 @@ +package ru.dbotthepony.mc.otm.client.screen.decorative + +import net.minecraft.network.chat.Component +import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.GridPanel +import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel +import ru.dbotthepony.mc.otm.menu.decorative.CargoCrateMenu + +class CargoCrateScreen(menu: CargoCrateMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { + override fun makeMainFrame(): FramePanel> { + val frame = FramePanel(this, null, 0f, 0f, INVENTORY_FRAME_WIDTH, 22f + 4f + 6f * 18f, getTitle()) + val grid = GridPanel(this, frame, 8f, 18f, 9f * 18f, 6f * 18f, 9, 6) + + for (slot in menu.storageSlots) + SlotPanel(this, grid, slot) + + return frame + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/HoloSignScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt similarity index 87% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/HoloSignScreen.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt index 07580cefa..756c0e578 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/HoloSignScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt @@ -1,7 +1,8 @@ -package ru.dbotthepony.mc.otm.client.screen +package ru.dbotthepony.mc.otm.client.screen.decorative import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.input.NetworkedStringInputPanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/CargoCrateScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/MinecartCargoCrateScreen.kt similarity index 59% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/CargoCrateScreen.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/MinecartCargoCrateScreen.kt index d9f37fa14..2f976e024 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/CargoCrateScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/MinecartCargoCrateScreen.kt @@ -1,25 +1,13 @@ -package ru.dbotthepony.mc.otm.client.screen +package ru.dbotthepony.mc.otm.client.screen.decorative import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.GridPanel import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel -import ru.dbotthepony.mc.otm.menu.decorative.CargoCrateMenu import ru.dbotthepony.mc.otm.menu.decorative.MinecartCargoCrateMenu -class CargoCrateScreen(menu: CargoCrateMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { - override fun makeMainFrame(): FramePanel> { - val frame = FramePanel(this, null, 0f, 0f, INVENTORY_FRAME_WIDTH, 22f + 4f + 6f * 18f, getTitle()) - val grid = GridPanel(this, frame, 8f, 18f, 9f * 18f, 6f * 18f, 9, 6) - - for (slot in menu.storageSlots) - SlotPanel(this, grid, slot) - - return frame - } -} - class MinecartCargoCrateScreen(menu: MinecartCargoCrateMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { override fun makeMainFrame(): FramePanel> { val frame = FramePanel(this, null, 0f, 0f, INVENTORY_FRAME_WIDTH, 22f + 4f + 6f * 18f, getTitle()) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterBottlerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt similarity index 94% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterBottlerScreen.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt index 60aa8c4c1..428bfabd9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterBottlerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt @@ -1,7 +1,8 @@ -package ru.dbotthepony.mc.otm.client.screen +package ru.dbotthepony.mc.otm.client.screen.matter import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.ButtonPanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterCapacitorBankScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterCapacitorBankScreen.kt similarity index 90% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterCapacitorBankScreen.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterCapacitorBankScreen.kt index 67189909f..e821cd4f7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterCapacitorBankScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterCapacitorBankScreen.kt @@ -1,8 +1,9 @@ -package ru.dbotthepony.mc.otm.client.screen +package ru.dbotthepony.mc.otm.client.screen.matter import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.menu.matter.MatterCapacitorBankMenu import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.MatterCapacitorSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterDecomposerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt similarity index 92% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterDecomposerScreen.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt index 7a49939cb..48629e96d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterDecomposerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt @@ -1,8 +1,9 @@ -package ru.dbotthepony.mc.otm.client.screen +package ru.dbotthepony.mc.otm.client.screen.matter import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.menu.matter.MatterDecomposerMenu import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterPanelScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterPanelScreen.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterPanelScreen.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterPanelScreen.kt index f2d82cedf..afc862cea 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterPanelScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterPanelScreen.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.client.screen +package ru.dbotthepony.mc.otm.client.screen.matter import net.minecraft.ChatFormatting import net.minecraft.client.gui.components.EditBox @@ -8,6 +8,7 @@ import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.capability.matter.IPatternState import ru.dbotthepony.mc.otm.capability.matter.IReplicationTask import ru.dbotthepony.mc.otm.client.render.WidgetLocation +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.ButtonPanel import ru.dbotthepony.mc.otm.core.TranslatableComponent diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterRecyclerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt similarity index 92% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterRecyclerScreen.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt index f9f99af63..c40b5e302 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterRecyclerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt @@ -1,7 +1,8 @@ -package ru.dbotthepony.mc.otm.client.screen +package ru.dbotthepony.mc.otm.client.screen.matter import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterReplicatorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt similarity index 92% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterReplicatorScreen.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt index 134348d2c..6d89cb02b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterReplicatorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt @@ -1,8 +1,9 @@ -package ru.dbotthepony.mc.otm.client.screen +package ru.dbotthepony.mc.otm.client.screen.matter import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.menu.MatterReplicatorMenu import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel @@ -30,4 +31,4 @@ class MatterReplicatorScreen(p_97741_: MatterReplicatorMenu, p_97742_: Inventory return frame } -} \ No newline at end of file +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterScannerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterScannerScreen.kt similarity index 92% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterScannerScreen.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterScannerScreen.kt index baf34c53a..71cfa1be2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatterScannerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterScannerScreen.kt @@ -1,8 +1,9 @@ -package ru.dbotthepony.mc.otm.client.screen +package ru.dbotthepony.mc.otm.client.screen.matter import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.menu.matter.MatterScannerMenu import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/PatternStorageScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/PatternStorageScreen.kt similarity index 90% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/PatternStorageScreen.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/PatternStorageScreen.kt index 57278f817..8ed07f6c4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/PatternStorageScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/PatternStorageScreen.kt @@ -1,8 +1,9 @@ -package ru.dbotthepony.mc.otm.client.screen +package ru.dbotthepony.mc.otm.client.screen.matter import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.menu.matter.PatternStorageMenu import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.PatternSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.PatternGaugePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/DriveRackScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/DriveRackScreen.kt similarity index 91% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/DriveRackScreen.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/DriveRackScreen.kt index eb4459045..b2f2f49eb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/DriveRackScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/DriveRackScreen.kt @@ -1,8 +1,9 @@ -package ru.dbotthepony.mc.otm.client.screen +package ru.dbotthepony.mc.otm.client.screen.storage import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.menu.storage.DriveRackMenu import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/DriveViewerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/DriveViewerScreen.kt similarity index 97% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/DriveViewerScreen.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/DriveViewerScreen.kt index eeeffa51c..f54264cb6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/DriveViewerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/DriveViewerScreen.kt @@ -1,9 +1,10 @@ -package ru.dbotthepony.mc.otm.client.screen +package ru.dbotthepony.mc.otm.client.screen.storage import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.CheckBoxLabelInputPanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ItemMonitorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/ItemMonitorScreen.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ItemMonitorScreen.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/ItemMonitorScreen.kt index 4733cb7ab..d9cf6b17d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ItemMonitorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/ItemMonitorScreen.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.client.screen +package ru.dbotthepony.mc.otm.client.screen.storage import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack @@ -12,6 +12,7 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorPlayerSettings import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.Widgets8 +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.SmallEnumRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel @@ -44,9 +45,9 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp frame.width = 178f + frame.dockPadding.left + frame.dockPadding.right val viewScrollBar = DiscreteScrollBarPanel(this, topPanel, - { integerDivisionDown(menu.networkedItemView.itemCount, ITEM_GRID_WIDTH) }, - { _, _, _ -> }, - 28f + ITEM_GRID_WIDTH * 18f + 2f, 16f, ITEM_GRID_HEIGHT * 18f) + { integerDivisionDown(menu.networkedItemView.itemCount, ITEM_GRID_WIDTH) }, + { _, _, _ -> }, + 28f + ITEM_GRID_WIDTH * 18f + 2f, 16f, ITEM_GRID_HEIGHT * 18f) viewScrollBar.dock = Dock.RIGHT viewScrollBar.setDockMargin(left = 2f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageBusScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt similarity index 91% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageBusScreen.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt index 1587e2a56..febb0e26a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageBusScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt @@ -1,7 +1,8 @@ -package ru.dbotthepony.mc.otm.client.screen +package ru.dbotthepony.mc.otm.client.screen.storage import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.CheckBoxLabelInputPanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageExporterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt similarity index 91% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageExporterScreen.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt index 2046ef281..61a60e96e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageExporterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt @@ -1,7 +1,8 @@ -package ru.dbotthepony.mc.otm.client.screen +package ru.dbotthepony.mc.otm.client.screen.storage import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.CheckBoxLabelInputPanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageImporterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt similarity index 91% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageImporterScreen.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt index 99f7cee3e..a3ac11dd7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageImporterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt @@ -1,7 +1,8 @@ -package ru.dbotthepony.mc.otm.client.screen +package ru.dbotthepony.mc.otm.client.screen.storage import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.CheckBoxLabelInputPanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StoragePowerSupplierScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt similarity index 94% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StoragePowerSupplierScreen.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt index b63cf5435..a8c413979 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StoragePowerSupplierScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt @@ -1,7 +1,8 @@ -package ru.dbotthepony.mc.otm.client.screen +package ru.dbotthepony.mc.otm.client.screen.storage import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.widget.HorizontalPowerGaugePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/AndroidStationScreen.kt similarity index 99% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/AndroidStationScreen.kt index fddf2072f..06c8e3409 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/AndroidStationScreen.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.client.screen +package ru.dbotthepony.mc.otm.client.screen.tech import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.systems.RenderSystem @@ -25,6 +25,7 @@ import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.render.drawColor import ru.dbotthepony.mc.otm.client.render.drawLine import ru.dbotthepony.mc.otm.client.render.drawRect +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.ButtonPanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/BatteryBankScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BatteryBankScreen.kt similarity index 89% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/BatteryBankScreen.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BatteryBankScreen.kt index 130c7aae1..593aee7a6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/BatteryBankScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BatteryBankScreen.kt @@ -1,8 +1,9 @@ -package ru.dbotthepony.mc.otm.client.screen +package ru.dbotthepony.mc.otm.client.screen.tech import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.menu.tech.BatteryBankMenu import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ChemicalGeneratorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt similarity index 92% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ChemicalGeneratorScreen.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt index 303647e70..b9d1f34bb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ChemicalGeneratorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt @@ -1,7 +1,8 @@ -package ru.dbotthepony.mc.otm.client.screen +package ru.dbotthepony.mc.otm.client.screen.tech import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/EnergyCounterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/EnergyCounterScreen.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt index 15b5cd9d6..c198e87a4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/EnergyCounterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt @@ -1,7 +1,8 @@ -package ru.dbotthepony.mc.otm.client.screen +package ru.dbotthepony.mc.otm.client.screen.tech import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.ButtonPanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/EnergyServoScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/EnergyServoScreen.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt index 1f7e61d93..942f04b8a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/EnergyServoScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt @@ -1,8 +1,9 @@ -package ru.dbotthepony.mc.otm.client.screen +package ru.dbotthepony.mc.otm.client.screen.tech import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.Dock diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/PlatePressScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt similarity index 91% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/PlatePressScreen.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt index d5bfd55aa..472267c09 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/PlatePressScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt @@ -1,7 +1,8 @@ -package ru.dbotthepony.mc.otm.client.screen +package ru.dbotthepony.mc.otm.client.screen.tech import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel 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 52dc1f3ec..c12f84f30 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt @@ -8,6 +8,20 @@ import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.client.screen.* +import ru.dbotthepony.mc.otm.client.screen.decorative.CargoCrateScreen +import ru.dbotthepony.mc.otm.client.screen.decorative.MinecartCargoCrateScreen +import ru.dbotthepony.mc.otm.client.screen.matter.MatterBottlerScreen +import ru.dbotthepony.mc.otm.client.screen.matter.MatterCapacitorBankScreen +import ru.dbotthepony.mc.otm.client.screen.matter.MatterDecomposerScreen +import ru.dbotthepony.mc.otm.client.screen.matter.MatterRecyclerScreen +import ru.dbotthepony.mc.otm.client.screen.storage.DriveRackScreen +import ru.dbotthepony.mc.otm.client.screen.storage.StorageBusScreen +import ru.dbotthepony.mc.otm.client.screen.storage.StorageExporterScreen +import ru.dbotthepony.mc.otm.client.screen.storage.StorageImporterScreen +import ru.dbotthepony.mc.otm.client.screen.storage.StoragePowerSupplierScreen +import ru.dbotthepony.mc.otm.client.screen.tech.EnergyCounterScreen +import ru.dbotthepony.mc.otm.client.screen.tech.EnergyServoScreen +import ru.dbotthepony.mc.otm.client.screen.tech.PlatePressScreen import ru.dbotthepony.mc.otm.menu.* import ru.dbotthepony.mc.otm.menu.decorative.CargoCrateMenu import ru.dbotthepony.mc.otm.menu.decorative.HoloSignMenu From bf756191a5e3565978b8e972fc64036992057683 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 26 Jan 2023 22:01:30 +0700 Subject: [PATCH 0108/1199] Move panels to subpackages --- .../mc/otm/client/screen/ExoPackInventoryScreen.kt | 5 +++-- .../ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt | 3 +++ .../mc/otm/client/screen/decorative/CargoCrateScreen.kt | 2 +- .../client/screen/decorative/MinecartCargoCrateScreen.kt | 2 +- .../mc/otm/client/screen/matter/MatterBottlerScreen.kt | 2 ++ .../otm/client/screen/matter/MatterCapacitorBankScreen.kt | 2 +- .../mc/otm/client/screen/matter/MatterDecomposerScreen.kt | 2 +- .../mc/otm/client/screen/matter/MatterPanelScreen.kt | 2 ++ .../mc/otm/client/screen/matter/MatterRecyclerScreen.kt | 2 +- .../mc/otm/client/screen/matter/MatterReplicatorScreen.kt | 2 +- .../mc/otm/client/screen/matter/MatterScannerScreen.kt | 2 +- .../mc/otm/client/screen/matter/PatternStorageScreen.kt | 2 +- .../mc/otm/client/screen/panels/EditablePanel.kt | 1 + .../otm/client/screen/panels/ScrollbarBackgroundPanel.kt | 3 +++ .../otm/client/screen/panels/{ => input}/EditBoxPanel.kt | 6 ++++-- .../screen/panels/{ => input}/NetworkNumberInputPanel.kt | 3 ++- .../otm/client/screen/panels/{ => input}/QueryUserPanel.kt | 6 +++++- .../otm/client/screen/panels/{ => input}/TextInputPanel.kt | 3 ++- .../client/screen/panels/{ => slot}/AbstractSlotPanel.kt | 4 +++- .../otm/client/screen/panels/{ => slot}/FilterSlotPanel.kt | 4 ++-- .../client/screen/panels/{ => slot}/FoldableSlotPanel.kt | 7 +++++-- .../mc/otm/client/screen/panels/{ => slot}/SlotPanel.kt | 4 +++- .../screen/panels/{ => util}/AnalogScrollBarPanel.kt | 3 ++- .../otm/client/screen/panels/{ => util}/BackgroundPanel.kt | 4 +++- .../screen/panels/{ => util}/DiscreteScrollBarPanel.kt | 3 ++- .../screen/panels/{ => util}/DraggableCanvasPanel.kt | 5 +++-- .../mc/otm/client/screen/panels/{ => util}/GridPanel.kt | 4 +++- .../otm/client/screen/panels/{ => util}/HeightControls.kt | 4 +++- .../client/screen/panels/{ => util}/ScrollBarConstants.kt | 2 +- .../mc/otm/client/screen/storage/DriveRackScreen.kt | 2 +- .../mc/otm/client/screen/storage/DriveViewerScreen.kt | 3 +++ .../mc/otm/client/screen/storage/ItemMonitorScreen.kt | 3 +++ .../mc/otm/client/screen/storage/StorageBusScreen.kt | 2 ++ .../mc/otm/client/screen/storage/StorageExporterScreen.kt | 2 ++ .../mc/otm/client/screen/storage/StorageImporterScreen.kt | 2 ++ .../client/screen/storage/StoragePowerSupplierScreen.kt | 1 + .../mc/otm/client/screen/tech/AndroidStationScreen.kt | 3 +++ .../mc/otm/client/screen/tech/BatteryBankScreen.kt | 2 +- .../mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt | 1 + .../mc/otm/client/screen/tech/EnergyCounterScreen.kt | 1 + .../mc/otm/client/screen/tech/EnergyServoScreen.kt | 2 +- .../mc/otm/client/screen/tech/PlatePressScreen.kt | 2 +- 42 files changed, 87 insertions(+), 33 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{ => input}/EditBoxPanel.kt (87%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{ => input}/NetworkNumberInputPanel.kt (94%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{ => input}/QueryUserPanel.kt (86%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{ => input}/TextInputPanel.kt (99%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{ => slot}/AbstractSlotPanel.kt (95%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{ => slot}/FilterSlotPanel.kt (89%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{ => slot}/FoldableSlotPanel.kt (89%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{ => slot}/SlotPanel.kt (96%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{ => util}/AnalogScrollBarPanel.kt (97%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{ => util}/BackgroundPanel.kt (90%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{ => util}/DiscreteScrollBarPanel.kt (97%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{ => util}/DraggableCanvasPanel.kt (87%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{ => util}/GridPanel.kt (85%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{ => util}/HeightControls.kt (93%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{ => util}/ScrollBarConstants.kt (96%) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt index f69f02ebe..e5bfc79cf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt @@ -9,6 +9,7 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.render.sprite import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.LargeRectangleButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.BackgroundPanel import ru.dbotthepony.mc.otm.client.setMousePos import ru.dbotthepony.mc.otm.client.shouldOpenVanillaInventory import ru.dbotthepony.mc.otm.core.math.integerDivisionDown @@ -177,8 +178,8 @@ class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen( screen: S, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditBoxPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/EditBoxPanel.kt similarity index 87% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditBoxPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/EditBoxPanel.kt index 41678aacd..050256363 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditBoxPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/EditBoxPanel.kt @@ -1,8 +1,10 @@ -package ru.dbotthepony.mc.otm.client.screen.panels +package ru.dbotthepony.mc.otm.client.screen.panels.input import net.minecraft.client.gui.components.EditBox import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.client.screen.panels.Widget2Panel import ru.dbotthepony.mc.otm.core.TextComponent open class EditBoxPanel( @@ -52,4 +54,4 @@ open class EditBoxPanel( requestFocus() return true } -} \ No newline at end of file +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/NetworkNumberInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkNumberInputPanel.kt similarity index 94% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/NetworkNumberInputPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkNumberInputPanel.kt index ded232d00..4e9c1cbf6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/NetworkNumberInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkNumberInputPanel.kt @@ -1,8 +1,9 @@ -package ru.dbotthepony.mc.otm.client.screen.panels +package ru.dbotthepony.mc.otm.client.screen.panels.input import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.menu.MatteryMenu import java.math.BigDecimal diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/QueryUserPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/QueryUserPanel.kt similarity index 86% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/QueryUserPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/QueryUserPanel.kt index 6b6a9fcc0..d36109441 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/QueryUserPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/QueryUserPanel.kt @@ -1,8 +1,12 @@ -package ru.dbotthepony.mc.otm.client.screen.panels +package ru.dbotthepony.mc.otm.client.screen.panels.input import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.Dock +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.Label import ru.dbotthepony.mc.otm.client.screen.panels.buttons.ButtonPanel import ru.dbotthepony.mc.otm.core.TranslatableComponent diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt similarity index 99% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt index 286b6c9cd..64d52ae70 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.client.screen.panels +package ru.dbotthepony.mc.otm.client.screen.panels.input import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.systems.RenderSystem @@ -22,6 +22,7 @@ import ru.dbotthepony.mc.otm.client.render.TextAlign import ru.dbotthepony.mc.otm.client.render.drawAligned import ru.dbotthepony.mc.otm.client.render.drawRect import ru.dbotthepony.mc.otm.client.render.tesselator +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.addAll import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.milliTime diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/AbstractSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/AbstractSlotPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt index 701e5c21e..8bb20e1cd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/AbstractSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.client.screen.panels +package ru.dbotthepony.mc.otm.client.screen.panels.slot import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack @@ -10,6 +10,8 @@ import org.lwjgl.opengl.GL11 import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.client.screen.panels.IItemStackPanel import ru.dbotthepony.mc.otm.core.math.RGBAColor abstract class AbstractSlotPanel> @JvmOverloads constructor( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FilterSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/FilterSlotPanel.kt similarity index 89% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FilterSlotPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/FilterSlotPanel.kt index ede980d40..5cb0b7ef5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FilterSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/FilterSlotPanel.kt @@ -1,8 +1,8 @@ -package ru.dbotthepony.mc.otm.client.screen.panels +package ru.dbotthepony.mc.otm.client.screen.panels.slot -import net.minecraft.client.gui.screens.Screen import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot import ru.dbotthepony.mc.otm.container.ItemFilterSlotPacket import ru.dbotthepony.mc.otm.network.MenuNetworkChannel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FoldableSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/FoldableSlotPanel.kt similarity index 89% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FoldableSlotPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/FoldableSlotPanel.kt index d0b3a2a82..7adfe743b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FoldableSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/FoldableSlotPanel.kt @@ -1,9 +1,12 @@ -package ru.dbotthepony.mc.otm.client.screen.panels +package ru.dbotthepony.mc.otm.client.screen.panels.slot import net.minecraft.world.inventory.Slot import ru.dbotthepony.mc.otm.SystemTime import ru.dbotthepony.mc.otm.client.screen.MatteryScreen -import ru.dbotthepony.mc.otm.nanoTime +import ru.dbotthepony.mc.otm.client.screen.panels.util.BackgroundPanel +import ru.dbotthepony.mc.otm.client.screen.panels.Dock +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.client.screen.panels.ISlotPanel open class FoldableSlotPanel, out T : Slot> @JvmOverloads constructor( screen: S, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/SlotPanel.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SlotPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/SlotPanel.kt index f411c6a7d..05b1efef6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/SlotPanel.kt @@ -1,6 +1,6 @@ @file:Suppress("FunctionName") -package ru.dbotthepony.mc.otm.client.screen.panels +package ru.dbotthepony.mc.otm.client.screen.panels.slot import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack @@ -16,6 +16,8 @@ import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.render.drawRect import ru.dbotthepony.mc.otm.client.render.setDrawColor import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.client.screen.panels.ISlotPanel import javax.annotation.Nonnull import kotlin.math.roundToInt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/AnalogScrollBarPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/AnalogScrollBarPanel.kt similarity index 97% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/AnalogScrollBarPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/AnalogScrollBarPanel.kt index 38cb1b5f4..dff0e3f95 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/AnalogScrollBarPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/AnalogScrollBarPanel.kt @@ -1,8 +1,9 @@ -package ru.dbotthepony.mc.otm.client.screen.panels +package ru.dbotthepony.mc.otm.client.screen.panels.util import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.math.linearInterpolation import ru.dbotthepony.mc.otm.milliTimeD import kotlin.math.roundToInt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/BackgroundPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/BackgroundPanel.kt similarity index 90% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/BackgroundPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/BackgroundPanel.kt index 4ab428291..9c95e6a1b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/BackgroundPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/BackgroundPanel.kt @@ -1,9 +1,11 @@ -package ru.dbotthepony.mc.otm.client.screen.panels +package ru.dbotthepony.mc.otm.client.screen.panels.util import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.render.StretchingRectangleElement import ru.dbotthepony.mc.otm.client.render.WidgetLocation +import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel open class BackgroundPanel( screen: S, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DiscreteScrollBarPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/DiscreteScrollBarPanel.kt similarity index 97% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DiscreteScrollBarPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/DiscreteScrollBarPanel.kt index a2abea412..6bd79d6d2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DiscreteScrollBarPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/DiscreteScrollBarPanel.kt @@ -1,8 +1,9 @@ -package ru.dbotthepony.mc.otm.client.screen.panels +package ru.dbotthepony.mc.otm.client.screen.panels.util import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import kotlin.math.roundToInt open class DiscreteScrollBarPanel( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DraggableCanvasPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/DraggableCanvasPanel.kt similarity index 87% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DraggableCanvasPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/DraggableCanvasPanel.kt index ca49b34a5..ec27abccf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DraggableCanvasPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/DraggableCanvasPanel.kt @@ -1,6 +1,7 @@ -package ru.dbotthepony.mc.otm.client.screen.panels +package ru.dbotthepony.mc.otm.client.screen.panels.util import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel open class DraggableCanvasPanel @JvmOverloads constructor( screen: S, @@ -40,4 +41,4 @@ open class DraggableCanvasPanel @JvmOverloads constructor( init { scissor = true } -} \ No newline at end of file +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/GridPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/GridPanel.kt similarity index 85% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/GridPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/GridPanel.kt index 62a4865c4..62c17e32d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/GridPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/GridPanel.kt @@ -1,6 +1,8 @@ -package ru.dbotthepony.mc.otm.client.screen.panels +package ru.dbotthepony.mc.otm.client.screen.panels.util import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.screen.panels.Dock +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel open class GridPanel @JvmOverloads constructor( screen: S, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/HeightControls.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/HeightControls.kt similarity index 93% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/HeightControls.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/HeightControls.kt index 68013d638..294a4d69a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/HeightControls.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/HeightControls.kt @@ -1,9 +1,11 @@ -package ru.dbotthepony.mc.otm.client.screen.panels +package ru.dbotthepony.mc.otm.client.screen.panels.util import com.mojang.blaze3d.platform.InputConstants import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.Widgets +import ru.dbotthepony.mc.otm.client.screen.panels.Dock +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.buttons.RectangleButtonPanel open class HeightControls( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ScrollBarConstants.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/ScrollBarConstants.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ScrollBarConstants.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/ScrollBarConstants.kt index e9473e0a6..546346c56 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ScrollBarConstants.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/ScrollBarConstants.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.client.screen.panels +package ru.dbotthepony.mc.otm.client.screen.panels.util import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.OverdriveThatMatters diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/DriveRackScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/DriveRackScreen.kt index b2f2f49eb..78b77d536 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/DriveRackScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/DriveRackScreen.kt @@ -4,7 +4,7 @@ import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.menu.storage.DriveRackMenu import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen -import ru.dbotthepony.mc.otm.client.screen.panels.BatterySlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel 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 f54264cb6..886d14206 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 @@ -8,6 +8,9 @@ import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.CheckBoxLabelInputPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.FilterSlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel import ru.dbotthepony.mc.otm.core.math.integerDivisionDown import ru.dbotthepony.mc.otm.item.PortableCondensationDriveItem 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 d9cf6b17d..9e9d2e718 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 @@ -15,6 +15,9 @@ import ru.dbotthepony.mc.otm.client.render.Widgets8 import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.SmallEnumRectangleButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.BackgroundPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel import ru.dbotthepony.mc.otm.core.asGetterSetter diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt index febb0e26a..8c916c248 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt @@ -6,6 +6,8 @@ import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.CheckBoxLabelInputPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.FilterSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel import ru.dbotthepony.mc.otm.menu.storage.StorageBusMenu diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt index 61a60e96e..2be138184 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt @@ -6,6 +6,8 @@ import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.CheckBoxLabelInputPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.FilterSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel import ru.dbotthepony.mc.otm.menu.storage.StorageExporterMenu diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt index a3ac11dd7..54021703a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt @@ -6,6 +6,8 @@ import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.CheckBoxLabelInputPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.FilterSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel import ru.dbotthepony.mc.otm.menu.storage.StorageImporterMenu diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt index a8c413979..86b616aa1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt @@ -5,6 +5,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* +import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.HorizontalPowerGaugePanel import ru.dbotthepony.mc.otm.core.util.formatPower 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 06c8e3409..0ef836012 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 @@ -28,6 +28,9 @@ import ru.dbotthepony.mc.otm.client.render.drawRect import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.ButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.EquipmentBatterySlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.DraggableCanvasPanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.ifPresentK diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BatteryBankScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BatteryBankScreen.kt index 593aee7a6..9308536ac 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BatteryBankScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BatteryBankScreen.kt @@ -4,7 +4,7 @@ import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.menu.tech.BatteryBankMenu import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen -import ru.dbotthepony.mc.otm.client.screen.panels.BatterySlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt index b9d1f34bb..f024bb793 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt @@ -5,6 +5,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* +import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel import ru.dbotthepony.mc.otm.menu.tech.ChemicalGeneratorMenu diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt index c198e87a4..4385ac4a3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt @@ -6,6 +6,7 @@ import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.buttons.ButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.input.NetworkNumberInputPanel import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.menu.tech.EnergyCounterMenu diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt index 942f04b8a..eb2cebd56 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt @@ -5,7 +5,7 @@ import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.AbstractSlotPanel -import ru.dbotthepony.mc.otm.client.screen.panels.BatterySlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt index 472267c09..5931ef5a5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt @@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.tech import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen -import ru.dbotthepony.mc.otm.client.screen.panels.BatterySlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel From 806a45f6bbcd93e60eedcc43875e3e83d758def9 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 26 Jan 2023 22:02:37 +0700 Subject: [PATCH 0109/1199] Rename buttons -> button --- .../kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt | 2 +- .../dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt | 2 +- .../mc/otm/client/screen/matter/MatterBottlerScreen.kt | 2 +- .../mc/otm/client/screen/matter/MatterPanelScreen.kt | 2 +- .../mc/otm/client/screen/panels/EntityRendererPanel.kt | 2 +- .../panels/{buttons => button}/BooleanRectangleButtonPanel.kt | 2 +- .../otm/client/screen/panels/{buttons => button}/ButtonPanel.kt | 2 +- .../screen/panels/{buttons => button}/CheckBoxInputPanel.kt | 2 +- .../panels/{buttons => button}/CheckBoxLabelInputPanel.kt | 2 +- .../screen/panels/{buttons => button}/CheckBoxLabelPanel.kt | 2 +- .../client/screen/panels/{buttons => button}/CheckBoxPanel.kt | 2 +- .../panels/{buttons => button}/EnumRectangleButtonPanel.kt | 2 +- .../{buttons => button}/LargeBooleanRectangleButtonPanel.kt | 2 +- .../panels/{buttons => button}/LargeEnumRectangleButtonPanel.kt | 2 +- .../panels/{buttons => button}/LargeRectangleButtonPanel.kt | 2 +- .../screen/panels/{buttons => button}/RectangleButtonPanel.kt | 2 +- .../{buttons => button}/SmallBooleanRectangleButtonPanel.kt | 2 +- .../panels/{buttons => button}/SmallEnumRectangleButtonPanel.kt | 2 +- .../panels/{buttons => button}/SmallRectangleButtonPanel.kt | 2 +- .../mc/otm/client/screen/panels/input/QueryUserPanel.kt | 2 +- .../mc/otm/client/screen/panels/util/HeightControls.kt | 2 +- .../mc/otm/client/screen/storage/DriveViewerScreen.kt | 2 +- .../mc/otm/client/screen/storage/ItemMonitorScreen.kt | 2 +- .../mc/otm/client/screen/storage/StorageBusScreen.kt | 2 +- .../mc/otm/client/screen/storage/StorageExporterScreen.kt | 2 +- .../mc/otm/client/screen/storage/StorageImporterScreen.kt | 2 +- .../mc/otm/client/screen/tech/AndroidStationScreen.kt | 2 +- .../mc/otm/client/screen/tech/EnergyCounterScreen.kt | 2 +- .../ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt | 2 +- 29 files changed, 29 insertions(+), 29 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{buttons => button}/BooleanRectangleButtonPanel.kt (95%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{buttons => button}/ButtonPanel.kt (97%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{buttons => button}/CheckBoxInputPanel.kt (93%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{buttons => button}/CheckBoxLabelInputPanel.kt (93%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{buttons => button}/CheckBoxLabelPanel.kt (92%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{buttons => button}/CheckBoxPanel.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{buttons => button}/EnumRectangleButtonPanel.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{buttons => button}/LargeBooleanRectangleButtonPanel.kt (94%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{buttons => button}/LargeEnumRectangleButtonPanel.kt (93%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{buttons => button}/LargeRectangleButtonPanel.kt (95%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{buttons => button}/RectangleButtonPanel.kt (96%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{buttons => button}/SmallBooleanRectangleButtonPanel.kt (94%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{buttons => button}/SmallEnumRectangleButtonPanel.kt (93%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{buttons => button}/SmallRectangleButtonPanel.kt (95%) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt index 5186062c4..27fd39610 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt @@ -22,7 +22,7 @@ import ru.dbotthepony.mc.otm.client.screen.ExoPackInventoryScreen import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.DiscreteScrollBarPanel -import ru.dbotthepony.mc.otm.client.screen.panels.buttons.LargeRectangleButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.Panel2Widget import ru.dbotthepony.mc.otm.compat.InventoryScrollPacket import ru.dbotthepony.mc.otm.compat.cos.isCosmeticArmorScreen diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt index e5bfc79cf..0655840d3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt @@ -8,7 +8,7 @@ import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.render.sprite import ru.dbotthepony.mc.otm.client.screen.panels.* -import ru.dbotthepony.mc.otm.client.screen.panels.buttons.LargeRectangleButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.BackgroundPanel import ru.dbotthepony.mc.otm.client.setMousePos import ru.dbotthepony.mc.otm.client.shouldOpenVanillaInventory diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt index 59550b455..15823cc00 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt @@ -5,7 +5,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* -import ru.dbotthepony.mc.otm.client.screen.panels.buttons.ButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.ButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.MatterCapacitorSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel 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 9b8515635..d8ffe7126 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 @@ -10,7 +10,7 @@ import ru.dbotthepony.mc.otm.capability.matter.IReplicationTask import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.* -import ru.dbotthepony.mc.otm.client.screen.panels.buttons.ButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.ButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.input.EditBoxPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.ScrollBarConstants import ru.dbotthepony.mc.otm.core.TranslatableComponent diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt index 179c7d261..b6f3160f6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt @@ -10,7 +10,7 @@ import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.render.Widgets8 import ru.dbotthepony.mc.otm.client.render.sprite import ru.dbotthepony.mc.otm.client.screen.ExoPackInventoryScreen -import ru.dbotthepony.mc.otm.client.screen.panels.buttons.SmallBooleanRectangleButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.SmallBooleanRectangleButtonPanel import ru.dbotthepony.mc.otm.compat.cos.CosmeticToggleRenderButton import ru.dbotthepony.mc.otm.compat.cos.isCosmeticArmorLoaded import ru.dbotthepony.mc.otm.core.TranslatableComponent diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/BooleanRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/BooleanRectangleButtonPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt index 11da9ffe8..74f75efa9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/BooleanRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.client.screen.panels.buttons +package ru.dbotthepony.mc.otm.client.screen.panels.button import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.vertex.PoseStack diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/ButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt similarity index 97% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/ButtonPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt index f376d3cab..d3aea862f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/ButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.client.screen.panels.buttons +package ru.dbotthepony.mc.otm.client.screen.panels.button import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxInputPanel.kt similarity index 93% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxInputPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxInputPanel.kt index 7213bf4ff..ff36cd941 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxInputPanel.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.client.screen.panels.buttons +package ru.dbotthepony.mc.otm.client.screen.panels.button import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.minecraft diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxLabelInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelInputPanel.kt similarity index 93% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxLabelInputPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelInputPanel.kt index 1cdb14217..578354830 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxLabelInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelInputPanel.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.client.screen.panels.buttons +package ru.dbotthepony.mc.otm.client.screen.panels.button import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxLabelPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelPanel.kt similarity index 92% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxLabelPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelPanel.kt index 4d24b4ac8..301ecb901 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxLabelPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelPanel.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.client.screen.panels.buttons +package ru.dbotthepony.mc.otm.client.screen.panels.button import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt index 1e9e8b4af..822e76a16 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.client.screen.panels.buttons +package ru.dbotthepony.mc.otm.client.screen.panels.button import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.vertex.PoseStack diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/EnumRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/EnumRectangleButtonPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt index 840cb3d85..88ebba99e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/EnumRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.client.screen.panels.buttons +package ru.dbotthepony.mc.otm.client.screen.panels.button import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.vertex.PoseStack diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/LargeBooleanRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeBooleanRectangleButtonPanel.kt similarity index 94% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/LargeBooleanRectangleButtonPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeBooleanRectangleButtonPanel.kt index f541cab21..0c70d2968 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/LargeBooleanRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeBooleanRectangleButtonPanel.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.client.screen.panels.buttons +package ru.dbotthepony.mc.otm.client.screen.panels.button import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/LargeEnumRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeEnumRectangleButtonPanel.kt similarity index 93% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/LargeEnumRectangleButtonPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeEnumRectangleButtonPanel.kt index c39145854..2eae319de 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/LargeEnumRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeEnumRectangleButtonPanel.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.client.screen.panels.buttons +package ru.dbotthepony.mc.otm.client.screen.panels.button import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.render.Widgets18 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/LargeRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/LargeRectangleButtonPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt index f18cfc5ab..ab8f0f553 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/LargeRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.client.screen.panels.buttons +package ru.dbotthepony.mc.otm.client.screen.panels.button import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/RectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/RectangleButtonPanel.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/RectangleButtonPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/RectangleButtonPanel.kt index 91f7bde54..ed7340ead 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/RectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/RectangleButtonPanel.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.client.screen.panels.buttons +package ru.dbotthepony.mc.otm.client.screen.panels.button import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/SmallBooleanRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallBooleanRectangleButtonPanel.kt similarity index 94% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/SmallBooleanRectangleButtonPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallBooleanRectangleButtonPanel.kt index f255df62d..3b64db74c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/SmallBooleanRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallBooleanRectangleButtonPanel.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.client.screen.panels.buttons +package ru.dbotthepony.mc.otm.client.screen.panels.button import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.render.* diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/SmallEnumRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallEnumRectangleButtonPanel.kt similarity index 93% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/SmallEnumRectangleButtonPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallEnumRectangleButtonPanel.kt index 7563207a1..c432c73a2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/SmallEnumRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallEnumRectangleButtonPanel.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.client.screen.panels.buttons +package ru.dbotthepony.mc.otm.client.screen.panels.button import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.render.Widgets8 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/SmallRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallRectangleButtonPanel.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/SmallRectangleButtonPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallRectangleButtonPanel.kt index 82a504e70..42d9addca 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/SmallRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallRectangleButtonPanel.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.client.screen.panels.buttons +package ru.dbotthepony.mc.otm.client.screen.panels.button import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/QueryUserPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/QueryUserPanel.kt index d36109441..8e71cecbd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/QueryUserPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/QueryUserPanel.kt @@ -7,7 +7,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.Label -import ru.dbotthepony.mc.otm.client.screen.panels.buttons.ButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.ButtonPanel import ru.dbotthepony.mc.otm.core.TranslatableComponent open class QueryUserPanel( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/HeightControls.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/HeightControls.kt index 294a4d69a..53de032e0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/HeightControls.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/HeightControls.kt @@ -6,7 +6,7 @@ import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.Widgets import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel -import ru.dbotthepony.mc.otm.client.screen.panels.buttons.RectangleButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.RectangleButtonPanel open class HeightControls( screen: S, 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 886d14206..1684bf94c 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 @@ -7,7 +7,7 @@ import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* -import ru.dbotthepony.mc.otm.client.screen.panels.buttons.CheckBoxLabelInputPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.CheckBoxLabelInputPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.FilterSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel 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 9e9d2e718..2bcf78b1b 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 @@ -14,7 +14,7 @@ import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.Widgets8 import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.* -import ru.dbotthepony.mc.otm.client.screen.panels.buttons.SmallEnumRectangleButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.SmallEnumRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.BackgroundPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt index 8c916c248..7d0f3e5f0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt @@ -5,7 +5,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* -import ru.dbotthepony.mc.otm.client.screen.panels.buttons.CheckBoxLabelInputPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.CheckBoxLabelInputPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.FilterSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt index 2be138184..02bd2b59f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt @@ -5,7 +5,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* -import ru.dbotthepony.mc.otm.client.screen.panels.buttons.CheckBoxLabelInputPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.CheckBoxLabelInputPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.FilterSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt index 54021703a..12f1b2155 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt @@ -5,7 +5,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* -import ru.dbotthepony.mc.otm.client.screen.panels.buttons.CheckBoxLabelInputPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.CheckBoxLabelInputPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.FilterSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel 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 0ef836012..4bac6dfe9 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 @@ -27,7 +27,7 @@ import ru.dbotthepony.mc.otm.client.render.drawLine import ru.dbotthepony.mc.otm.client.render.drawRect import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.* -import ru.dbotthepony.mc.otm.client.screen.panels.buttons.ButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.ButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.EquipmentBatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.DraggableCanvasPanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt index 4385ac4a3..a33529277 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt @@ -5,7 +5,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* -import ru.dbotthepony.mc.otm.client.screen.panels.buttons.ButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.ButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.input.NetworkNumberInputPanel import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.menu.tech.EnergyCounterMenu diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt index b0f26e07c..54399f9ed 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt @@ -20,7 +20,7 @@ import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.MatterySprite import ru.dbotthepony.mc.otm.client.render.sprite import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel -import ru.dbotthepony.mc.otm.client.screen.panels.buttons.RectangleButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.RectangleButtonPanel import ru.dbotthepony.mc.otm.compat.cos.CosmeticToggleButton.Companion.BUTTON_ACTIVE import ru.dbotthepony.mc.otm.compat.cos.CosmeticToggleButton.Companion.BUTTON_INACTIVE import ru.dbotthepony.mc.otm.container.awareStream From a14c069c502f495997bfa96f91831242d2969b3a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 26 Jan 2023 22:14:56 +0700 Subject: [PATCH 0110/1199] Fix imports --- .../entity/matter/MatterBottlerBlockEntity.kt | 2 +- .../entity/matter/MatterReplicatorBlockEntity.kt | 2 +- .../entity/storage/DriveViewerBlockEntity.kt | 4 ++-- .../entity/storage/ItemMonitorBlockEntity.kt | 2 +- .../mc/otm/client/ClientEventHandler.kt | 4 ++-- .../otm/client/screen/ExoPackInventoryScreen.kt | 3 +++ .../mc/otm/client/screen/MatteryScreen.kt | 3 +++ .../client/screen/decorative/CargoCrateScreen.kt | 2 +- .../decorative/MinecartCargoCrateScreen.kt | 2 +- .../client/screen/matter/MatterBottlerScreen.kt | 4 ++-- .../screen/matter/MatterDecomposerScreen.kt | 2 +- .../client/screen/matter/MatterPanelScreen.kt | 4 +++- .../client/screen/matter/MatterRecyclerScreen.kt | 2 +- .../screen/matter/MatterReplicatorScreen.kt | 4 ++-- .../client/screen/matter/MatterScannerScreen.kt | 2 +- .../otm/client/screen/panels/EffectListPanel.kt | 1 + .../screen/panels/ScrollbarBackgroundPanel.kt | 1 + .../panels/input/NetworkedStringInputPanel.kt | 1 - .../screen/panels/util/AnalogScrollBarPanel.kt | 1 + .../otm/client/screen/storage/DriveRackScreen.kt | 4 ++-- .../client/screen/storage/DriveViewerScreen.kt | 7 +++++-- .../client/screen/storage/ItemMonitorScreen.kt | 12 +++++++++--- .../screen/storage/StoragePowerSupplierScreen.kt | 3 ++- .../client/screen/tech/AndroidStationScreen.kt | 1 + .../screen/tech/ChemicalGeneratorScreen.kt | 3 ++- .../otm/client/screen/tech/EnergyServoScreen.kt | 2 +- .../otm/client/screen/tech/PlatePressScreen.kt | 2 +- .../otm/compat/jei/PlatePressRecipeCategory.kt | 2 +- .../mc/otm/network/MenuNetworkChannel.kt | 2 +- .../ru/dbotthepony/mc/otm/registry/MMenus.kt | 16 ++++++++++++++-- 30 files changed, 67 insertions(+), 33 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index 06526a072..273c8bda7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -33,7 +33,7 @@ import ru.dbotthepony.mc.otm.container.MatteryContainerHooks import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph -import ru.dbotthepony.mc.otm.menu.MatterBottlerMenu +import ru.dbotthepony.mc.otm.menu.matter.MatterBottlerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.registry.MBlocks diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index 9895021eb..1304e51ec 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -29,7 +29,7 @@ import ru.dbotthepony.mc.otm.container.MatteryContainerHandler import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph -import ru.dbotthepony.mc.otm.menu.MatterReplicatorMenu +import ru.dbotthepony.mc.otm.menu.matter.MatterReplicatorMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MNames diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt index 6dc847021..bb869d7ca 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt @@ -19,10 +19,10 @@ import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.container.MatteryContainer -import ru.dbotthepony.mc.otm.menu.DriveViewerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.menu.storage.DriveViewerMenu import ru.dbotthepony.mc.otm.registry.MBlocks class DriveViewerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.DRIVE_VIEWER, p_155229_, p_155230_), IDroppableContainer { @@ -73,7 +73,7 @@ class DriveViewerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte override val defaultDisplayName: Component get() = MBlocks.DRIVE_VIEWER.name - override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu? { + override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { return DriveViewerMenu(containerID, inventory, this) } 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 ef1653feb..31cf89889 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 @@ -35,12 +35,12 @@ import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.get import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode import ru.dbotthepony.mc.otm.graph.storage.StorageNetworkGraph -import ru.dbotthepony.mc.otm.menu.ItemMonitorMenu import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.container.set import ru.dbotthepony.mc.otm.core.nbt.getEnum import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.menu.storage.ItemMonitorMenu import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.storage.* import java.math.BigInteger diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt index 27fd39610..0e2ef890d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt @@ -20,8 +20,8 @@ import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.ExoPackInventoryScreen import ru.dbotthepony.mc.otm.client.screen.MatteryScreen -import ru.dbotthepony.mc.otm.client.screen.panels.AbstractSlotPanel -import ru.dbotthepony.mc.otm.client.screen.panels.DiscreteScrollBarPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.Panel2Widget import ru.dbotthepony.mc.otm.compat.InventoryScrollPacket diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt index 0655840d3..d7d107bf2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt @@ -9,7 +9,10 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.render.sprite import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeRectangleButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.BackgroundPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel import ru.dbotthepony.mc.otm.client.setMousePos import ru.dbotthepony.mc.otm.client.shouldOpenVanillaInventory import ru.dbotthepony.mc.otm.core.math.integerDivisionDown 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 c5b69166b..976303274 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 @@ -19,7 +19,10 @@ import org.lwjgl.opengl.GL13 import ru.dbotthepony.mc.otm.ClientConfig import ru.dbotthepony.mc.otm.client.moveMousePosScaled import ru.dbotthepony.mc.otm.client.screen.panels.* +import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.FoldableSlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.HeightControls import ru.dbotthepony.mc.otm.client.screen.panels.util.ScrollBarConstants import ru.dbotthepony.mc.otm.compat.cos.CosmeticToggleButton diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt index 08991c62d..a4f7c0206 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt @@ -5,7 +5,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel -import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.menu.decorative.CargoCrateMenu class CargoCrateScreen(menu: CargoCrateMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/MinecartCargoCrateScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/MinecartCargoCrateScreen.kt index 979434f25..5e938ac69 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/MinecartCargoCrateScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/MinecartCargoCrateScreen.kt @@ -5,7 +5,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel -import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.menu.decorative.MinecartCargoCrateMenu class MinecartCargoCrateScreen(menu: MinecartCargoCrateMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt index 15823cc00..dd91e10f2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt @@ -11,14 +11,14 @@ import ru.dbotthepony.mc.otm.client.screen.panels.slot.MatterCapacitorSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel -import ru.dbotthepony.mc.otm.menu.MatterBottlerMenu +import ru.dbotthepony.mc.otm.menu.matter.MatterBottlerMenu class MatterBottlerScreen(menu: MatterBottlerMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { private var progress: ProgressGaugePanel? = null - override fun makeMainFrame(): FramePanel> { + override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! val p = PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt index e1661f4dd..aa2143b70 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt @@ -6,7 +6,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel -import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel 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 d8ffe7126..dda087779 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 @@ -12,11 +12,13 @@ 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 import ru.dbotthepony.mc.otm.client.screen.panels.input.EditBoxPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.ScrollBarConstants import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.integerDivisionDown import ru.dbotthepony.mc.otm.menu.matter.MatterPanelMenu -import ru.dbotthepony.mc.otm.menu.ReplicationRequestPacket +import ru.dbotthepony.mc.otm.menu.matter.ReplicationRequestPacket import ru.dbotthepony.mc.otm.network.MenuNetworkChannel import yalter.mousetweaks.api.MouseTweaksDisableWheelTweak diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt index 8df59e2b4..ba839582a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt @@ -5,7 +5,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel -import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt index 5fcc370b4..2305a1bfb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt @@ -1,15 +1,15 @@ package ru.dbotthepony.mc.otm.client.screen.matter import net.minecraft.network.chat.Component -import ru.dbotthepony.mc.otm.menu.MatterReplicatorMenu import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel -import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel +import ru.dbotthepony.mc.otm.menu.matter.MatterReplicatorMenu class MatterReplicatorScreen(p_97741_: MatterReplicatorMenu, p_97742_: Inventory, p_97743_: Component) : MatteryScreen(p_97741_, p_97742_, p_97743_) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterScannerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterScannerScreen.kt index d26be7ecf..d08d3336f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterScannerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterScannerScreen.kt @@ -6,7 +6,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel -import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.PatternGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt index 07ab355b8..cc9b47ef5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt @@ -16,6 +16,7 @@ import ru.dbotthepony.mc.otm.client.render.drawAligned import ru.dbotthepony.mc.otm.client.render.drawScaledAligned import ru.dbotthepony.mc.otm.client.render.sprite import ru.dbotthepony.mc.otm.client.render.render +import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.util.formatTickDuration diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ScrollbarBackgroundPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ScrollbarBackgroundPanel.kt index eb9e79563..9584cc0a0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ScrollbarBackgroundPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ScrollbarBackgroundPanel.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.AnalogScrollBarPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.BackgroundPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.ScrollBarConstants diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt index 3a88b7b05..5c548a493 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.client.screen.panels.input import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel -import ru.dbotthepony.mc.otm.client.screen.panels.TextInputPanel import ru.dbotthepony.mc.otm.menu.input.AbstractNetworkedInput import ru.dbotthepony.mc.otm.milliTime diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/AnalogScrollBarPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/AnalogScrollBarPanel.kt index dff0e3f95..549d7841d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/AnalogScrollBarPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/AnalogScrollBarPanel.kt @@ -4,6 +4,7 @@ import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.core.math.linearInterpolation import ru.dbotthepony.mc.otm.milliTimeD import kotlin.math.roundToInt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/DriveRackScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/DriveRackScreen.kt index 78b77d536..237e9c72e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/DriveRackScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/DriveRackScreen.kt @@ -6,13 +6,13 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel -import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel class DriveRackScreen(menu: DriveRackMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { - override fun makeMainFrame(): FramePanel> { + override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! WidePowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) 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 1684bf94c..ca4ec029c 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 @@ -8,20 +8,23 @@ import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.button.CheckBoxLabelInputPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.FilterSlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel import ru.dbotthepony.mc.otm.core.math.integerDivisionDown import ru.dbotthepony.mc.otm.item.PortableCondensationDriveItem -import ru.dbotthepony.mc.otm.menu.DriveViewerMenu +import ru.dbotthepony.mc.otm.menu.storage.DriveViewerMenu import yalter.mousetweaks.api.MouseTweaksDisableWheelTweak @MouseTweaksDisableWheelTweak class DriveViewerScreen(menu: DriveViewerMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { - override fun makeMainFrame(): FramePanel> { + override fun makeMainFrame(): FramePanel> { val frame = FramePanel(this, null, 0f, 0f, FRAME_WIDTH, FRAME_HEIGHT, getTitle()) val views = ArrayList>() 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 2bcf78b1b..e1b67b61a 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 @@ -13,10 +13,16 @@ import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorPlayerSettings import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.Widgets8 import ru.dbotthepony.mc.otm.client.screen.MatteryScreen -import ru.dbotthepony.mc.otm.client.screen.panels.* +import ru.dbotthepony.mc.otm.client.screen.panels.Dock +import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.button.SmallEnumRectangleButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.BackgroundPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel @@ -24,7 +30,7 @@ import ru.dbotthepony.mc.otm.core.asGetterSetter import ru.dbotthepony.mc.otm.core.math.integerDivisionDown import ru.dbotthepony.mc.otm.core.util.formatReadableNumber import ru.dbotthepony.mc.otm.core.util.formatSiComponent -import ru.dbotthepony.mc.otm.menu.ItemMonitorMenu +import ru.dbotthepony.mc.otm.menu.storage.ItemMonitorMenu import ru.dbotthepony.mc.otm.storage.ITEM_STORAGE import yalter.mousetweaks.api.MouseTweaksDisableWheelTweak @@ -32,7 +38,7 @@ import yalter.mousetweaks.api.MouseTweaksDisableWheelTweak class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { - override fun makeMainFrame(): FramePanel> { + override fun makeMainFrame(): FramePanel> { val frame = FramePanel(this@ItemMonitorScreen, null, 0f, 0f, 1f, 1f, getTitle()) val topPanel = EditablePanel(this, frame) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt index 86b616aa1..294f9fcbb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt @@ -5,6 +5,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* +import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.HorizontalPowerGaugePanel import ru.dbotthepony.mc.otm.core.util.formatPower @@ -13,7 +14,7 @@ import ru.dbotthepony.mc.otm.menu.storage.StoragePowerSupplierMenu class StoragePowerSupplierScreen(menu: StoragePowerSupplierMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { - override fun makeMainFrame(): FramePanel> { + override fun makeMainFrame(): FramePanel> { val frame = FramePanel(this, width = 200f, height = 60f, title) HorizontalPowerGaugePanel(this, frame, menu.powerWidget).also { 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 4bac6dfe9..62069e936 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 @@ -28,6 +28,7 @@ import ru.dbotthepony.mc.otm.client.render.drawRect 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 +import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.EquipmentBatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.DraggableCanvasPanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt index f024bb793..e61fdb4be 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt @@ -3,9 +3,10 @@ package ru.dbotthepony.mc.otm.client.screen.tech import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel import ru.dbotthepony.mc.otm.menu.tech.ChemicalGeneratorMenu diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt index eb2cebd56..c49970006 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt @@ -4,7 +4,7 @@ import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen -import ru.dbotthepony.mc.otm.client.screen.panels.AbstractSlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt index 5931ef5a5..e4e6f1f1c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt @@ -5,7 +5,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel -import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt index 6c2449140..408930ca5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt @@ -16,7 +16,7 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.TextAlign import ru.dbotthepony.mc.otm.client.render.drawAligned -import ru.dbotthepony.mc.otm.client.screen.panels.AbstractSlotPanel +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.math.RGBAColor import ru.dbotthepony.mc.otm.core.TranslatableComponent diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt index c8fb6826b..f5d70c0af 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt @@ -12,7 +12,7 @@ import ru.dbotthepony.mc.otm.container.ItemFilterSlotPacket import ru.dbotthepony.mc.otm.menu.matter.CancelTaskPacket import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.matter.PatternsChangePacket -import ru.dbotthepony.mc.otm.menu.ReplicationRequestPacket +import ru.dbotthepony.mc.otm.menu.matter.ReplicationRequestPacket import ru.dbotthepony.mc.otm.menu.matter.TasksChangePacket import ru.dbotthepony.mc.otm.menu.data.ClearItemViewPacket import ru.dbotthepony.mc.otm.menu.data.ItemViewInteractPacket 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 c12f84f30..dd08c720e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt @@ -7,32 +7,44 @@ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.client.screen.* import ru.dbotthepony.mc.otm.client.screen.decorative.CargoCrateScreen +import ru.dbotthepony.mc.otm.client.screen.decorative.HoloSignScreen import ru.dbotthepony.mc.otm.client.screen.decorative.MinecartCargoCrateScreen import ru.dbotthepony.mc.otm.client.screen.matter.MatterBottlerScreen import ru.dbotthepony.mc.otm.client.screen.matter.MatterCapacitorBankScreen import ru.dbotthepony.mc.otm.client.screen.matter.MatterDecomposerScreen +import ru.dbotthepony.mc.otm.client.screen.matter.MatterPanelScreen import ru.dbotthepony.mc.otm.client.screen.matter.MatterRecyclerScreen +import ru.dbotthepony.mc.otm.client.screen.matter.MatterReplicatorScreen +import ru.dbotthepony.mc.otm.client.screen.matter.MatterScannerScreen +import ru.dbotthepony.mc.otm.client.screen.matter.PatternStorageScreen import ru.dbotthepony.mc.otm.client.screen.storage.DriveRackScreen +import ru.dbotthepony.mc.otm.client.screen.storage.DriveViewerScreen +import ru.dbotthepony.mc.otm.client.screen.storage.ItemMonitorScreen import ru.dbotthepony.mc.otm.client.screen.storage.StorageBusScreen import ru.dbotthepony.mc.otm.client.screen.storage.StorageExporterScreen import ru.dbotthepony.mc.otm.client.screen.storage.StorageImporterScreen import ru.dbotthepony.mc.otm.client.screen.storage.StoragePowerSupplierScreen +import ru.dbotthepony.mc.otm.client.screen.tech.AndroidStationScreen +import ru.dbotthepony.mc.otm.client.screen.tech.BatteryBankScreen +import ru.dbotthepony.mc.otm.client.screen.tech.ChemicalGeneratorScreen import ru.dbotthepony.mc.otm.client.screen.tech.EnergyCounterScreen import ru.dbotthepony.mc.otm.client.screen.tech.EnergyServoScreen import ru.dbotthepony.mc.otm.client.screen.tech.PlatePressScreen -import ru.dbotthepony.mc.otm.menu.* import ru.dbotthepony.mc.otm.menu.decorative.CargoCrateMenu import ru.dbotthepony.mc.otm.menu.decorative.HoloSignMenu import ru.dbotthepony.mc.otm.menu.decorative.MinecartCargoCrateMenu +import ru.dbotthepony.mc.otm.menu.matter.MatterBottlerMenu import ru.dbotthepony.mc.otm.menu.matter.MatterCapacitorBankMenu import ru.dbotthepony.mc.otm.menu.matter.MatterDecomposerMenu import ru.dbotthepony.mc.otm.menu.matter.MatterPanelMenu import ru.dbotthepony.mc.otm.menu.matter.MatterRecyclerMenu +import ru.dbotthepony.mc.otm.menu.matter.MatterReplicatorMenu import ru.dbotthepony.mc.otm.menu.matter.MatterScannerMenu import ru.dbotthepony.mc.otm.menu.matter.PatternStorageMenu import ru.dbotthepony.mc.otm.menu.storage.DriveRackMenu +import ru.dbotthepony.mc.otm.menu.storage.DriveViewerMenu +import ru.dbotthepony.mc.otm.menu.storage.ItemMonitorMenu import ru.dbotthepony.mc.otm.menu.storage.StorageBusMenu import ru.dbotthepony.mc.otm.menu.storage.StorageExporterMenu import ru.dbotthepony.mc.otm.menu.storage.StorageImporterMenu From 2a8d08c357b0f3a5ac32a71338eb5581032bff99 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Fri, 27 Jan 2023 05:15:15 +0600 Subject: [PATCH 0111/1199] holo-sign model is in but for some reason lights rendering is odd --- .../mc/otm/datagen/blocks/BlockStates.kt | 1 + .../mc/otm/datagen/items/ItemModels.kt | 2 + .../models/block/holo_sign.json | 191 ++++++++++++++++++ .../textures/block/holo_sign.png | Bin 0 -> 418 bytes 4 files changed, 194 insertions(+) create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/holo_sign.json create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/holo_sign.png diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt index 2d821f4cd..6869638f6 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt @@ -32,6 +32,7 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { provider.block(MBlocks.CHEMICAL_GENERATOR) provider.block(MBlocks.MATTER_SCANNER) provider.block(MBlocks.ITEM_MONITOR) + provider.block(MBlocks.HOLO_SIGN) provider.exec { with(provider.getMultipartBuilder(MBlocks.PHANTOM_ATTRACTOR)) { diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index 3b8e3a921..241e68d50 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -29,6 +29,8 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.block(MItems.TRITANIUM_INGOT_BLOCK) provider.block(MItems.ITEM_MONITOR) provider.block(MItems.PHANTOM_ATTRACTOR) + provider.block(MItems.HOLO_SIGN) + MRegistry.VENT.allItems.values.forEach(provider::block) MRegistry.VENT_ALTERNATIVE.allItems.values.forEach(provider::block) diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/holo_sign.json b/src/main/resources/assets/overdrive_that_matters/models/block/holo_sign.json new file mode 100644 index 000000000..050affd54 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/holo_sign.json @@ -0,0 +1,191 @@ +{ + "parent": "block/cube_all", + "render_type": "translucent", + "textures": { + "0": "overdrive_that_matters:block/holo_sign", + "particle": "overdrive_that_matters:block/holo_sign" + }, + "elements": [ + { + "name": "body", + "from": [0, 0, 14], + "to": [16, 16, 16], + "faces": { + "north": {"uv": [0, 0, 8, 8], "texture": "#0"}, + "east": {"uv": [0, 11.5, 8, 12.5], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 8, 8], "texture": "#0"}, + "west": {"uv": [0, 11.5, 8, 12.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [0, 11.5, 8, 12.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [0, 11.5, 8, 12.5], "texture": "#0"} + } + }, + { + "name": "body", + "from": [1, 1, 13], + "to": [15, 15, 14], + "faces": { + "north": {"uv": [0, 0, 7, 7], "texture": "#missing"}, + "east": {"uv": [0, 11, 7, 11.5], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 0, 7, 7], "texture": "#missing"}, + "west": {"uv": [0, 11, 7, 11.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [0, 11, 7, 11.5], "texture": "#0"}, + "down": {"uv": [0, 11, 7, 11.5], "texture": "#0"} + } + }, + { + "name": "body", + "from": [0, 0, 10], + "to": [16, 16, 13], + "faces": { + "north": {"uv": [8, 0, 16, 8], "texture": "#0"}, + "east": {"uv": [0, 9.5, 8, 11], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 0, 8, 8], "texture": "#0"}, + "west": {"uv": [0, 9.5, 8, 11], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 8, 8, 9.5], "texture": "#0"}, + "down": {"uv": [0, 8, 8, 9.5], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "body", + "from": [14, 5, 9], + "to": [16, 11, 10], + "faces": { + "north": {"uv": [0.5, 12.5, 1.5, 15.5], "texture": "#0"}, + "east": {"uv": [0, 12.5, 0.5, 15.5], "texture": "#0"}, + "south": {"uv": [0, 0, 1, 3], "texture": "#missing"}, + "west": {"uv": [1.5, 12.5, 2, 15.5], "texture": "#0"}, + "up": {"uv": [1.5, 16, 0.5, 15.5], "texture": "#0"}, + "down": {"uv": [1.5, 15.5, 0.5, 16], "texture": "#0"} + } + }, + { + "name": "body", + "from": [0, 5, 9], + "to": [2, 11, 10], + "faces": { + "north": {"uv": [1.5, 12.5, 0.5, 15.5], "texture": "#0"}, + "east": {"uv": [1.5, 12.5, 2, 15.5], "texture": "#0"}, + "south": {"uv": [0, 0, 1, 3], "texture": "#missing"}, + "west": {"uv": [0, 12.5, 0.5, 15.5], "texture": "#0"}, + "up": {"uv": [0.5, 15.5, 1.5, 16], "texture": "#0"}, + "down": {"uv": [0.5, 15.5, 1.5, 16], "texture": "#0"} + } + }, + { + "name": "light", + "from": [1, 14, 10], + "to": [2, 15, 10], + "faces": { + "north": {"uv": [2, 12.5, 2.5, 13], "texture": "#0", "emissivity": 15}, + "east": {"uv": [0, 0, 0, 0.5], "texture": "#0", "emissivity": 15}, + "south": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"}, + "west": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, + "up": {"uv": [0, 0, 0.5, 0], "texture": "#missing"}, + "down": {"uv": [0, 0, 0.5, 0], "texture": "#missing"} + } + }, + { + "name": "light", + "from": [1, 1, 10], + "to": [2, 2, 10], + "faces": { + "north": {"uv": [2, 12.5, 2.5, 13], "texture": "#0", "emissivity": 15}, + "east": {"uv": [0, 0, 0, 0.5], "texture": "#0", "emissivity": 15}, + "south": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"}, + "west": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, + "up": {"uv": [0, 0, 0.5, 0], "texture": "#missing"}, + "down": {"uv": [0, 0, 0.5, 0], "texture": "#missing"} + } + }, + { + "name": "light", + "from": [14, 1, 10], + "to": [15, 2, 10], + "faces": { + "north": {"uv": [2, 12.5, 2.5, 13], "texture": "#0", "emissivity": 15}, + "east": {"uv": [0, 0, 0, 0.5], "texture": "#0", "emissivity": 15}, + "south": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"}, + "west": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, + "up": {"uv": [0, 0, 0.5, 0], "texture": "#missing"}, + "down": {"uv": [0, 0, 0.5, 0], "texture": "#missing"} + } + }, + { + "name": "light", + "from": [14, 14, 10], + "to": [15, 15, 10], + "faces": { + "north": {"uv": [2, 12.5, 2.5, 13], "texture": "#0", "emissivity": 15}, + "east": {"uv": [0, 0, 0, 0.5], "texture": "#0", "emissivity": 15}, + "south": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"}, + "west": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, + "up": {"uv": [0, 0, 0.5, 0], "texture": "#missing"}, + "down": {"uv": [0, 0, 0.5, 0], "texture": "#missing"} + } + }, + { + "name": "light", + "from": [14, 6, 9], + "to": [14, 10, 10], + "faces": { + "north": {"uv": [0, 0, 0, 2], "texture": "#missing"}, + "east": {"uv": [0, 0, 0.5, 2], "texture": "#missing"}, + "south": {"uv": [0, 0, 0, 2], "texture": "#missing"}, + "west": {"uv": [2, 13, 2.5, 15], "texture": "#0", "emissivity": 15}, + "up": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, + "down": {"uv": [0, 0, 0, 0.5], "texture": "#missing"} + } + }, + { + "name": "light", + "from": [2, 6, 9], + "to": [2, 10, 10], + "faces": { + "north": {"uv": [0, 0, 0, 2], "texture": "#missing"}, + "east": {"uv": [2, 13, 2.5, 15], "texture": "#0", "emissivity": 15}, + "south": {"uv": [0, 0, 0, 2], "texture": "#missing"}, + "west": {"uv": [2, 13, 2.5, 15], "texture": "#0", "emissivity": 15}, + "up": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, + "down": {"uv": [0, 0, 0, 0.5], "texture": "#missing"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "rotation": [90, 0, 0], + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 225, 0], + "translation": [2, -1.25, 0], + "scale": [0.625, 0.625, 0.625] + }, + "head": { + "translation": [0, 0, -10], + "scale": [0.94, 0.94, 0.94] + }, + "fixed": { + "translation": [0, 0, -2.75], + "scale": [0.5, 0.5, 0.5] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/holo_sign.png b/src/main/resources/assets/overdrive_that_matters/textures/block/holo_sign.png new file mode 100644 index 0000000000000000000000000000000000000000..1100a2d1bbb7608b6c5d8195f46b14d808dfcdd9 GIT binary patch literal 418 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyjKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCijS1AIbU6A}_aLPFHk)U>s=O-)V3#Kh|B>)YGg|3C2je*>t9AzSVDHz37b z666>B9}XD2{24z1g*gj6B8wRq_zr_GV60Za4DfZlg2E_qLM;GNzw!A8^BrO(Cafwz#vnH|cp)s@>Gmabr1ti7T@ zrQ}VEclQ;hg_9g~&*V>ElKuN^!MwW91{$+@UL{_6-gA1>hP*dc`CHe{7P}_@TCC1G zDok zQp0AC*xS~ Date: Fri, 27 Jan 2023 11:03:32 +0700 Subject: [PATCH 0112/1199] Directly declare generic type --- .../ru/dbotthepony/mc/otm/registry/Ext.kt | 6 ++ .../mc/otm/registry/MBlockEntities.kt | 71 +++++++++---------- .../mc/otm/registry/RegistryEntryExt.kt | 8 --- 3 files changed, 40 insertions(+), 45 deletions(-) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/registry/RegistryEntryExt.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Ext.kt index 5072e9935..38286bbda 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Ext.kt @@ -8,8 +8,14 @@ import net.minecraft.resources.ResourceKey import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.DyeColor import net.minecraftforge.registries.DeferredRegister +import net.minecraftforge.registries.RegistryObject import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.core.collect.SupplierMap +import kotlin.reflect.KProperty + +operator fun RegistryObject.getValue(thisRef: Any, property: KProperty<*>): T { + return get() +} private fun DeferredRegister.doColored(prefix: String, factory: (color: DyeColor, name: String) -> T): MutableCollection T>> { return mutableListOf( 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 3f80fa3c3..7e87582b3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt @@ -33,41 +33,38 @@ import ru.dbotthepony.mc.otm.client.render.blockentity.MatterReplicatorRenderer object MBlockEntities { private val registry = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, OverdriveThatMatters.MOD_ID) - val ANDROID_STATION: BlockEntityType<*> by registry.register(MNames.ANDROID_STATION) { BlockEntityType.Builder.of(::AndroidStationBlockEntity, MBlocks.ANDROID_STATION).build(null) } - val BATTERY_BANK: BlockEntityType<*> by registry.register(MNames.BATTERY_BANK) { BlockEntityType.Builder.of(::BatteryBankBlockEntity, MBlocks.BATTERY_BANK).build(null) } - val MATTER_DECOMPOSER: BlockEntityType<*> by registry.register(MNames.MATTER_DECOMPOSER) { BlockEntityType.Builder.of(::MatterDecomposerBlockEntity, MBlocks.MATTER_DECOMPOSER).build(null) } - val MATTER_CAPACITOR_BANK: BlockEntityType<*> by registry.register(MNames.MATTER_CAPACITOR_BANK) { BlockEntityType.Builder.of(::MatterCapacitorBankBlockEntity, MBlocks.MATTER_CAPACITOR_BANK).build(null) } - val MATTER_CABLE: BlockEntityType<*> by registry.register(MNames.MATTER_CABLE) { BlockEntityType.Builder.of(::MatterCableBlockEntity, MBlocks.MATTER_CABLE).build(null) } - val STORAGE_CABLE: BlockEntityType<*> by registry.register(MNames.STORAGE_CABLE) { BlockEntityType.Builder.of(::StorageCableBlockEntity, MBlocks.STORAGE_CABLE).build(null) } - val PATTERN_STORAGE: BlockEntityType<*> by registry.register(MNames.PATTERN_STORAGE) { BlockEntityType.Builder.of(::PatternStorageBlockEntity, MBlocks.PATTERN_STORAGE).build(null) } - val MATTER_SCANNER: BlockEntityType<*> by registry.register(MNames.MATTER_SCANNER) { BlockEntityType.Builder.of(::MatterScannerBlockEntity, MBlocks.MATTER_SCANNER).build(null) } - val MATTER_PANEL: BlockEntityType<*> by registry.register(MNames.MATTER_PANEL) { BlockEntityType.Builder.of(::MatterPanelBlockEntity, MBlocks.MATTER_PANEL).build(null) } - val MATTER_REPLICATOR: BlockEntityType<*> by registry.register(MNames.MATTER_REPLICATOR) { BlockEntityType.Builder.of(::MatterReplicatorBlockEntity, MBlocks.MATTER_REPLICATOR).build(null) } - val MATTER_BOTTLER: BlockEntityType<*> by registry.register(MNames.MATTER_BOTTLER) { BlockEntityType.Builder.of(::MatterBottlerBlockEntity, MBlocks.MATTER_BOTTLER).build(null) } - val DRIVE_VIEWER: BlockEntityType<*> by registry.register(MNames.DRIVE_VIEWER) { BlockEntityType.Builder.of(::DriveViewerBlockEntity, MBlocks.DRIVE_VIEWER).build(null) } - val BLACK_HOLE: BlockEntityType<*> by registry.register(MNames.BLACK_HOLE) { BlockEntityType.Builder.of(::BlackHoleBlockEntity, MBlocks.BLACK_HOLE).build(null) } - val CARGO_CRATE: BlockEntityType<*> by registry.register(MNames.CARGO_CRATE) { BlockEntityType.Builder.of( - ::CargoCrateBlockEntity, - *MRegistry.CARGO_CRATES.blocks.values.toTypedArray() - ).build(null) } - val DRIVE_RACK: BlockEntityType<*> by registry.register(MNames.DRIVE_RACK) { BlockEntityType.Builder.of(::DriveRackBlockEntity, MBlocks.DRIVE_RACK).build(null) } - val ITEM_MONITOR: BlockEntityType<*> by registry.register(MNames.ITEM_MONITOR) { BlockEntityType.Builder.of(::ItemMonitorBlockEntity, MBlocks.ITEM_MONITOR).build(null) } - val ENERGY_COUNTER: BlockEntityType<*> by registry.register(MNames.ENERGY_COUNTER) { BlockEntityType.Builder.of(::EnergyCounterBlockEntity, MBlocks.ENERGY_COUNTER).build(null) } - val CHEMICAL_GENERATOR: BlockEntityType<*> by registry.register(MNames.CHEMICAL_GENERATOR) { BlockEntityType.Builder.of(::ChemicalGeneratorBlockEntity, MBlocks.CHEMICAL_GENERATOR).build(null) } - val PLATE_PRESS: BlockEntityType<*> by registry.register(MNames.PLATE_PRESS) { BlockEntityType.Builder.of(::PlatePressBlockEntity, MBlocks.PLATE_PRESS).build(null) } - val GRAVITATION_STABILIZER: BlockEntityType<*> by registry.register(MNames.GRAVITATION_STABILIZER) { BlockEntityType.Builder.of(::GravitationStabilizerBlockEntity, MBlocks.GRAVITATION_STABILIZER).build(null) } - val MATTER_RECYCLER: BlockEntityType<*> by registry.register(MNames.MATTER_RECYCLER) { BlockEntityType.Builder.of(::MatterRecyclerBlockEntity, MBlocks.MATTER_RECYCLER).build(null) } - val ENERGY_SERVO: BlockEntityType<*> by registry.register(MNames.ENERGY_SERVO) { BlockEntityType.Builder.of(::EnergyServoBlockEntity, MBlocks.ENERGY_SERVO).build(null) } + val ANDROID_STATION: BlockEntityType by registry.register(MNames.ANDROID_STATION) { BlockEntityType.Builder.of(::AndroidStationBlockEntity, MBlocks.ANDROID_STATION).build(null) } + val BATTERY_BANK: BlockEntityType by registry.register(MNames.BATTERY_BANK) { BlockEntityType.Builder.of(::BatteryBankBlockEntity, MBlocks.BATTERY_BANK).build(null) } + val MATTER_DECOMPOSER: BlockEntityType by registry.register(MNames.MATTER_DECOMPOSER) { BlockEntityType.Builder.of(::MatterDecomposerBlockEntity, MBlocks.MATTER_DECOMPOSER).build(null) } + val MATTER_CAPACITOR_BANK: BlockEntityType by registry.register(MNames.MATTER_CAPACITOR_BANK) { BlockEntityType.Builder.of(::MatterCapacitorBankBlockEntity, MBlocks.MATTER_CAPACITOR_BANK).build(null) } + val MATTER_CABLE: BlockEntityType by registry.register(MNames.MATTER_CABLE) { BlockEntityType.Builder.of(::MatterCableBlockEntity, MBlocks.MATTER_CABLE).build(null) } + val STORAGE_CABLE: BlockEntityType by registry.register(MNames.STORAGE_CABLE) { BlockEntityType.Builder.of(::StorageCableBlockEntity, MBlocks.STORAGE_CABLE).build(null) } + val PATTERN_STORAGE: BlockEntityType by registry.register(MNames.PATTERN_STORAGE) { BlockEntityType.Builder.of(::PatternStorageBlockEntity, MBlocks.PATTERN_STORAGE).build(null) } + val MATTER_SCANNER: BlockEntityType by registry.register(MNames.MATTER_SCANNER) { BlockEntityType.Builder.of(::MatterScannerBlockEntity, MBlocks.MATTER_SCANNER).build(null) } + val MATTER_PANEL: BlockEntityType by registry.register(MNames.MATTER_PANEL) { BlockEntityType.Builder.of(::MatterPanelBlockEntity, MBlocks.MATTER_PANEL).build(null) } + val MATTER_REPLICATOR: BlockEntityType by registry.register(MNames.MATTER_REPLICATOR) { BlockEntityType.Builder.of(::MatterReplicatorBlockEntity, MBlocks.MATTER_REPLICATOR).build(null) } + val MATTER_BOTTLER: BlockEntityType by registry.register(MNames.MATTER_BOTTLER) { BlockEntityType.Builder.of(::MatterBottlerBlockEntity, MBlocks.MATTER_BOTTLER).build(null) } + val DRIVE_VIEWER: BlockEntityType by registry.register(MNames.DRIVE_VIEWER) { BlockEntityType.Builder.of(::DriveViewerBlockEntity, MBlocks.DRIVE_VIEWER).build(null) } + val BLACK_HOLE: BlockEntityType by registry.register(MNames.BLACK_HOLE) { BlockEntityType.Builder.of(::BlackHoleBlockEntity, MBlocks.BLACK_HOLE).build(null) } + val CARGO_CRATE: BlockEntityType by registry.register(MNames.CARGO_CRATE) { BlockEntityType.Builder.of(::CargoCrateBlockEntity, *MRegistry.CARGO_CRATES.blocks.values.toTypedArray()).build(null) } + val DRIVE_RACK: BlockEntityType by registry.register(MNames.DRIVE_RACK) { BlockEntityType.Builder.of(::DriveRackBlockEntity, MBlocks.DRIVE_RACK).build(null) } + val ITEM_MONITOR: BlockEntityType by registry.register(MNames.ITEM_MONITOR) { BlockEntityType.Builder.of(::ItemMonitorBlockEntity, MBlocks.ITEM_MONITOR).build(null) } + val ENERGY_COUNTER: BlockEntityType by registry.register(MNames.ENERGY_COUNTER) { BlockEntityType.Builder.of(::EnergyCounterBlockEntity, MBlocks.ENERGY_COUNTER).build(null) } + val CHEMICAL_GENERATOR: BlockEntityType by registry.register(MNames.CHEMICAL_GENERATOR) { BlockEntityType.Builder.of(::ChemicalGeneratorBlockEntity, MBlocks.CHEMICAL_GENERATOR).build(null) } + val PLATE_PRESS: BlockEntityType by registry.register(MNames.PLATE_PRESS) { BlockEntityType.Builder.of(::PlatePressBlockEntity, MBlocks.PLATE_PRESS).build(null) } + val GRAVITATION_STABILIZER: BlockEntityType by registry.register(MNames.GRAVITATION_STABILIZER) { BlockEntityType.Builder.of(::GravitationStabilizerBlockEntity, MBlocks.GRAVITATION_STABILIZER).build(null) } + val MATTER_RECYCLER: BlockEntityType by registry.register(MNames.MATTER_RECYCLER) { BlockEntityType.Builder.of(::MatterRecyclerBlockEntity, MBlocks.MATTER_RECYCLER).build(null) } + val ENERGY_SERVO: BlockEntityType by registry.register(MNames.ENERGY_SERVO) { BlockEntityType.Builder.of(::EnergyServoBlockEntity, MBlocks.ENERGY_SERVO).build(null) } - val STORAGE_BUS: BlockEntityType<*> by registry.register(MNames.STORAGE_BUS) { BlockEntityType.Builder.of(::StorageBusBlockEntity, MBlocks.STORAGE_BUS).build(null) } - val STORAGE_IMPORTER: BlockEntityType<*> by registry.register(MNames.STORAGE_IMPORTER) { BlockEntityType.Builder.of(::StorageImporterBlockEntity, MBlocks.STORAGE_IMPORTER).build(null) } - val STORAGE_EXPORTER: BlockEntityType<*> by registry.register(MNames.STORAGE_EXPORTER) { BlockEntityType.Builder.of(::StorageExporterBlockEntity, MBlocks.STORAGE_EXPORTER).build(null) } - val STORAGE_POWER_SUPPLIER: BlockEntityType<*> by registry.register(MNames.STORAGE_POWER_SUPPLIER) { BlockEntityType.Builder.of(::StoragePowerSupplierBlockEntity, MBlocks.STORAGE_POWER_SUPPLIER).build(null) } + val STORAGE_BUS: BlockEntityType by registry.register(MNames.STORAGE_BUS) { BlockEntityType.Builder.of(::StorageBusBlockEntity, MBlocks.STORAGE_BUS).build(null) } + val STORAGE_IMPORTER: BlockEntityType by registry.register(MNames.STORAGE_IMPORTER) { BlockEntityType.Builder.of(::StorageImporterBlockEntity, MBlocks.STORAGE_IMPORTER).build(null) } + val STORAGE_EXPORTER: BlockEntityType by registry.register(MNames.STORAGE_EXPORTER) { BlockEntityType.Builder.of(::StorageExporterBlockEntity, MBlocks.STORAGE_EXPORTER).build(null) } + val STORAGE_POWER_SUPPLIER: BlockEntityType by registry.register(MNames.STORAGE_POWER_SUPPLIER) { BlockEntityType.Builder.of(::StoragePowerSupplierBlockEntity, MBlocks.STORAGE_POWER_SUPPLIER).build(null) } val HOLO_SIGN: BlockEntityType by registry.register(MNames.HOLO_SIGN) { BlockEntityType.Builder.of(::HoloSignBlockEntity, MBlocks.HOLO_SIGN).build(null) } - val DEBUG_EXPLOSION_SMALL: BlockEntityType<*> by registry.register(MNames.DEBUG_EXPLOSION_SMALL) { BlockEntityType.Builder.of(::BlockEntityExplosionDebugger, MBlocks.DEBUG_EXPLOSION_SMALL).build(null) } - val DEBUG_SPHERE_POINTS: BlockEntityType<*> by registry.register(MNames.DEBUG_SPHERE_POINTS) { BlockEntityType.Builder.of(::BlockEntitySphereDebugger, MBlocks.DEBUG_SPHERE_POINTS).build(null) } + val DEBUG_EXPLOSION_SMALL: BlockEntityType by registry.register(MNames.DEBUG_EXPLOSION_SMALL) { BlockEntityType.Builder.of(::BlockEntityExplosionDebugger, MBlocks.DEBUG_EXPLOSION_SMALL).build(null) } + val DEBUG_SPHERE_POINTS: BlockEntityType by registry.register(MNames.DEBUG_SPHERE_POINTS) { BlockEntityType.Builder.of(::BlockEntitySphereDebugger, MBlocks.DEBUG_SPHERE_POINTS).build(null) } internal fun register(bus: IEventBus) { registry.register(bus) @@ -77,12 +74,12 @@ object MBlockEntities { @Suppress("unchecked_cast") private fun registerClient(event: FMLClientSetupEvent) { event.enqueueWork { - BlockEntityRenderers.register(BLACK_HOLE as BlockEntityType, ::BlackHoleRenderer) - BlockEntityRenderers.register(GRAVITATION_STABILIZER as BlockEntityType, ::GravitationStabilizerRenderer) - BlockEntityRenderers.register(ENERGY_COUNTER as BlockEntityType, ::EnergyCounterRenderer) - BlockEntityRenderers.register(BATTERY_BANK as BlockEntityType, ::BatteryBankRenderer) - BlockEntityRenderers.register(MATTER_CAPACITOR_BANK as BlockEntityType, ::MatterBatteryBankRenderer) - BlockEntityRenderers.register(MATTER_REPLICATOR as BlockEntityType, ::MatterReplicatorRenderer) + BlockEntityRenderers.register(BLACK_HOLE, ::BlackHoleRenderer) + BlockEntityRenderers.register(GRAVITATION_STABILIZER, ::GravitationStabilizerRenderer) + BlockEntityRenderers.register(ENERGY_COUNTER, ::EnergyCounterRenderer) + BlockEntityRenderers.register(BATTERY_BANK, ::BatteryBankRenderer) + BlockEntityRenderers.register(MATTER_CAPACITOR_BANK, ::MatterBatteryBankRenderer) + BlockEntityRenderers.register(MATTER_REPLICATOR, ::MatterReplicatorRenderer) BlockEntityRenderers.register(HOLO_SIGN, ::HoloSignRenderer) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/RegistryEntryExt.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/RegistryEntryExt.kt deleted file mode 100644 index 85b9e3f8a..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/RegistryEntryExt.kt +++ /dev/null @@ -1,8 +0,0 @@ -package ru.dbotthepony.mc.otm.registry - -import net.minecraftforge.registries.RegistryObject -import kotlin.reflect.KProperty - -operator fun RegistryObject.getValue(thisRef: Any, property: KProperty<*>): T { - return get() -} From f76fe4add611acd47ecfed985c9b7dd700db9d34 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 27 Jan 2023 11:39:02 +0700 Subject: [PATCH 0113/1199] acceptsCharacter, support text padding in text input --- .../screen/panels/input/TextInputPanel.kt | 80 ++++++++++--------- .../dbotthepony/mc/otm/core/math/RGBAColor.kt | 53 ++++++------ 2 files changed, 72 insertions(+), 61 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt index 64d52ae70..25923bc19 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt @@ -22,6 +22,7 @@ import ru.dbotthepony.mc.otm.client.render.TextAlign import ru.dbotthepony.mc.otm.client.render.drawAligned import ru.dbotthepony.mc.otm.client.render.drawRect import ru.dbotthepony.mc.otm.client.render.tesselator +import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.addAll import ru.dbotthepony.mc.otm.core.math.RGBAColor @@ -144,6 +145,11 @@ open class TextInputPanel( open var backgroundColor = RGBAColor.BLACK open var isActive = true + init { + scissor = true + dockPadding = DockProperty(2f, 2f, 2f, 2f) + } + private var oldText = ArrayList() private var textCache: String? = null private val lines = ArrayList() @@ -968,12 +974,21 @@ open class TextInputPanel( return true } + open fun acceptsCharacter(codepoint: Char, mods: Int = 0): Boolean { + return true + } + override fun charTypedInternal(codepoint: Char, mods: Int): Boolean { if (!isActive) { killFocus() return true } + if (!acceptsCharacter(codepoint, mods)) { + playGuiClickSound() + return true + } + wipeSelection() if (!multiLine) @@ -1003,9 +1018,10 @@ open class TextInputPanel( } override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - drawRect(stack, 0f, 0f, width, height, backgroundColor) + if (!backgroundColor.isFullyTransparent) + drawRect(stack, 0f, 0f, width, height, backgroundColor) - var y = 0f + var y = dockPadding.top for ((i, line) in lines.withIndex()) { val selection = selections[i] @@ -1015,7 +1031,7 @@ open class TextInputPanel( buffer = BUFFER, text = line, align = TextAlign.TOP_LEFT, - x = 0f, + x = dockPadding.left, y = y, color = textColor ) @@ -1023,10 +1039,10 @@ open class TextInputPanel( if (selection != null && selection.isValid) { val (before, selected) = selection.sub(line) - var x = 0f + var x = dockPadding.left if (before.isNotEmpty()) { - x = font.width(before).toFloat() + x += font.width(before).toFloat() } val width = if (selection.coversNewline(line) && i != lines.size - 1) this.width - x else font.width(selected).toFloat() @@ -1057,6 +1073,9 @@ open class TextInputPanel( } y += font.lineHeight + 2f + + if (y > height - dockPadding.bottom) + break } if (isFocused && milliTime % 1000L > 500L) { @@ -1068,8 +1087,8 @@ open class TextInputPanel( buffer = BUFFER, text = "_", align = TextAlign.TOP_LEFT, - x = if (activeLine == null) 0f else font.width(activeLine).toFloat(), - y = cursorLine * (font.lineHeight + 2f), + x = dockPadding.left + (if (activeLine == null) 0f else font.width(activeLine).toFloat()), + y = dockPadding.top + cursorLine * (font.lineHeight + 2f), color = cursorColor ) } else { @@ -1078,8 +1097,8 @@ open class TextInputPanel( buffer = BUFFER, text = "|", align = TextAlign.TOP_LEFT, - x = font.width(activeLine.substring(0, cursorCharacter)).toFloat() - 1f, - y = cursorLine * (font.lineHeight + 2f), + x = dockPadding.left + font.width(activeLine.substring(0, cursorCharacter)).toFloat() - 1f, + y = dockPadding.top + cursorLine * (font.lineHeight + 2f), color = cursorColor ) } @@ -1092,7 +1111,7 @@ open class TextInputPanel( text = cursorLine.toString(), align = TextAlign.TOP_RIGHT, x = width, - y = 0f, + y = dockPadding.top, color = cursorColor ) @@ -1101,8 +1120,8 @@ open class TextInputPanel( buffer = BUFFER, text = cursorCharacter.toString(), align = TextAlign.TOP_RIGHT, - x = width, - y = font.lineHeight + 2f, + x = width - dockPadding.right, + y = dockPadding.top + font.lineHeight + 2f, color = cursorColor ) @@ -1111,8 +1130,8 @@ open class TextInputPanel( buffer = BUFFER, text = lines.size.toString(), align = TextAlign.TOP_RIGHT, - x = width, - y = font.lineHeight * 2 + 4f, + x = width - dockPadding.right, + y = dockPadding.top + font.lineHeight * 2 + 4f, color = cursorColor ) } @@ -1142,10 +1161,20 @@ open class TextInputPanel( return true } + @Suppress("name_shadowing") fun localToText(x: Float, y: Float): Vector2i { if (lines.isEmpty()) return Vector2i(0, 0) + var x = x - dockPadding.left + var y = y - dockPadding.top + + if (y > height - dockPadding.bottom) + y = height - dockPadding.bottom + + if (x > width - dockPadding.right) + x = width - dockPadding.right + val line = (y / (font.lineHeight + 2f)).toInt().coerceIn(0, lines.size - 1) val sLine = this[line] ?: return Vector2i(0, line) @@ -1154,29 +1183,6 @@ open class TextInputPanel( else if (x >= font.width(sLine)) return Vector2i(sLine.length, line) - // binary search attempt - // simply: sucks - /*@Suppress("name_shadowing") - var x = x - var start = 0 - var end = sLine.length - 1 - - while (start < end - 1) { - val split = (end - start) / 2 - val before = font.width(sLine.substring(start, start + split)) - - if (x < before) { - end = start + split - } else if (x > before) { - x -= before - start += split - } else { - break - } - } - - return Vector2i(start, line)*/ - val cache = Char2IntOpenHashMap() var accumulatedWidth = 0f diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/RGBAColor.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/RGBAColor.kt index 5aff0aa32..26a611b6b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/RGBAColor.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/RGBAColor.kt @@ -76,33 +76,38 @@ data class RGBAColor(val red: Float, val green: Float, val blue: Float, val alph ) } + val isFullyTransparent get() = alpha <= 0f + companion object { - val BLACK = RGBAColor(0f, 0f, 0f, 1f) - val WHITE = RGBAColor(1f, 1f, 1f, 1f) - val RED = RGBAColor(1f, 0f, 0f) - val GREEN = RGBAColor(0f, 1f, 0f, 1f) - val LIGHT_GREEN = RGBAColor(136, 255, 124) - val SLATE_GRAY = RGBAColor(64, 64, 64) - val GRAY = RGBAColor(0x2C2C2CFFL) + @JvmField val TRANSPARENT_BLACK = RGBAColor(0f, 0f, 0f, 0f) + @JvmField val TRANSPARENT_WHITE = RGBAColor(1f, 1f, 1f, 0f) - val DARK_BLUE = rgb(ChatFormatting.DARK_BLUE.color!!) - val DARK_GREEN = rgb(ChatFormatting.DARK_GREEN.color!!) - val DARK_AQUA = rgb(ChatFormatting.DARK_AQUA.color!!) - val DARK_RED = rgb(ChatFormatting.DARK_RED.color!!) - val DARK_PURPLE = rgb(ChatFormatting.DARK_PURPLE.color!!) - val GOLD = rgb(ChatFormatting.GOLD.color!!) - val DARK_GRAY = rgb(ChatFormatting.DARK_GRAY.color!!) - val BLUE = rgb(ChatFormatting.BLUE.color!!) - val AQUA = rgb(ChatFormatting.AQUA.color!!) - val LIGHT_PURPLE = rgb(ChatFormatting.LIGHT_PURPLE.color!!) - val YELLOW = rgb(ChatFormatting.YELLOW.color!!) + @JvmField val BLACK = RGBAColor(0f, 0f, 0f, 1f) + @JvmField val WHITE = RGBAColor(1f, 1f, 1f, 1f) + @JvmField val RED = RGBAColor(1f, 0f, 0f) + @JvmField val GREEN = RGBAColor(0f, 1f, 0f, 1f) + @JvmField val LIGHT_GREEN = RGBAColor(136, 255, 124) + @JvmField val SLATE_GRAY = RGBAColor(64, 64, 64) + @JvmField val GRAY = RGBAColor(0x2C2C2CFFL) - val LOW_POWER = RGBAColor(173, 41, 41) - val FULL_POWER = RGBAColor(255, 242, 40) - val LOW_MATTER = RGBAColor(0, 24, 148) - val FULL_MATTER = RGBAColor(72, 90, 255) - val LOW_PATTERNS = RGBAColor(44, 104, 57) - val FULL_PATTERNS = RGBAColor(65, 255, 87) + @JvmField val DARK_BLUE = rgb(ChatFormatting.DARK_BLUE.color!!) + @JvmField val DARK_GREEN = rgb(ChatFormatting.DARK_GREEN.color!!) + @JvmField val DARK_AQUA = rgb(ChatFormatting.DARK_AQUA.color!!) + @JvmField val DARK_RED = rgb(ChatFormatting.DARK_RED.color!!) + @JvmField val DARK_PURPLE = rgb(ChatFormatting.DARK_PURPLE.color!!) + @JvmField val GOLD = rgb(ChatFormatting.GOLD.color!!) + @JvmField val DARK_GRAY = rgb(ChatFormatting.DARK_GRAY.color!!) + @JvmField val BLUE = rgb(ChatFormatting.BLUE.color!!) + @JvmField val AQUA = rgb(ChatFormatting.AQUA.color!!) + @JvmField val LIGHT_PURPLE = rgb(ChatFormatting.LIGHT_PURPLE.color!!) + @JvmField val YELLOW = rgb(ChatFormatting.YELLOW.color!!) + + @JvmField val LOW_POWER = RGBAColor(173, 41, 41) + @JvmField val FULL_POWER = RGBAColor(255, 242, 40) + @JvmField val LOW_MATTER = RGBAColor(0, 24, 148) + @JvmField val FULL_MATTER = RGBAColor(72, 90, 255) + @JvmField val LOW_PATTERNS = RGBAColor(44, 104, 57) + @JvmField val FULL_PATTERNS = RGBAColor(65, 255, 87) fun inv(color: Int): RGBAColor { val r = (color and -0x1000000 ushr 24) / 255f From cbd40d03ee515b8627a4943b81d160cf441ba4a8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 27 Jan 2023 11:45:52 +0700 Subject: [PATCH 0114/1199] Allow to move selection cursor while mouse is outside of panel bounds --- .../mc/otm/client/screen/panels/input/TextInputPanel.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt index 25923bc19..6a1d94d43 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt @@ -1156,6 +1156,7 @@ open class TextInputPanel( cursorCharacter = pos.x isSelecting = true + grabMouseInput = true } return true @@ -1203,8 +1204,12 @@ open class TextInputPanel( } override fun mouseReleasedInner(x: Double, y: Double, button: Int): Boolean { - if (button == InputConstants.MOUSE_BUTTON_LEFT) - isSelecting = false + if (button == InputConstants.MOUSE_BUTTON_LEFT) { + if (isSelecting) { + grabMouseInput = false + isSelecting = false + } + } return true } From 6ea1edd358a159c652623c61586b497bef53d6e8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 27 Jan 2023 11:46:15 +0700 Subject: [PATCH 0115/1199] Kill mouse grab when killing focus --- .../ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt | 2 ++ 1 file changed, 2 insertions(+) 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 789d77c3b..b7f42f508 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 @@ -1125,6 +1125,8 @@ open class EditablePanel @JvmOverloads constructor( killFocusInternal() findAbsoluteRoot().updateFocus() } + + grabMouseInput = false } fun findHierarchicalFocus(): EditablePanel<*>? { From 74ade468074170fabc7ccd5127619103d39e6854 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 27 Jan 2023 11:48:22 +0700 Subject: [PATCH 0116/1199] More proper mouse grab killing in killfocus --- .../mc/otm/client/screen/panels/EditablePanel.kt | 14 ++++++++++++-- .../client/screen/panels/input/TextInputPanel.kt | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) 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 b7f42f508..be3c62cde 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 @@ -1118,15 +1118,25 @@ open class EditablePanel @JvmOverloads constructor( if (isFocused) { isFocused = false } + + grabMouseInput = false + } + + private fun killGrabMouseInput() { + for (child in childrenInternal) { + child.killGrabMouseInput() + } + + grabMouseInput = false } fun killFocus() { if (isEverFocused()) { killFocusInternal() findAbsoluteRoot().updateFocus() + } else if (isGrabbingMouseInput()) { + killGrabMouseInput() } - - grabMouseInput = false } fun findHierarchicalFocus(): EditablePanel<*>? { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt index 6a1d94d43..e656c59ab 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt @@ -1156,7 +1156,7 @@ open class TextInputPanel( cursorCharacter = pos.x isSelecting = true - grabMouseInput = true + tryToGrabMouseInput() } return true From 87b86b5d9fec5e9aa436b27429a5768f7e439acd Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 27 Jan 2023 11:50:45 +0700 Subject: [PATCH 0117/1199] Declare setter of autoKillFocus as public --- .../ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt | 2 -- 1 file changed, 2 deletions(-) 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 be3c62cde..1aecb526d 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 @@ -575,8 +575,6 @@ open class EditablePanel @JvmOverloads constructor( } var autoKillFocus = false - protected set - private var focusedAsParent = false val font: Font get() = if (screen is MatteryScreen<*>) screen.font else minecraft.font From b7887b49460cebc52e4082c864f637482f446d50 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 27 Jan 2023 11:51:03 +0700 Subject: [PATCH 0118/1199] Unfocus text input panel when clicking outside its bounds --- .../mc/otm/client/screen/panels/input/TextInputPanel.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt index e656c59ab..be557e04e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt @@ -148,6 +148,7 @@ open class TextInputPanel( init { scissor = true dockPadding = DockProperty(2f, 2f, 2f, 2f) + autoKillFocus = true } private var oldText = ArrayList() From c47082e3f369f5415d07755e9918dd68ed8c71f8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 27 Jan 2023 12:12:44 +0700 Subject: [PATCH 0119/1199] Clear selection only when clicked while already focused --- .../client/screen/panels/input/TextInputPanel.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt index be557e04e..02ae27b59 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt @@ -1147,14 +1147,18 @@ open class TextInputPanel( if (!isActive) return true - selections.clear() + if (isEverFocused()) + selections.clear() + requestFocus() if (button == InputConstants.MOUSE_BUTTON_LEFT) { - val (lx, ly) = screenToLocal(x, y) - val pos = localToText(lx, ly) - cursorLine = pos.y - cursorCharacter = pos.x + if (selections.isEmpty()) { + val (lx, ly) = screenToLocal(x, y) + val pos = localToText(lx, ly) + cursorLine = pos.y + cursorCharacter = pos.x + } isSelecting = true tryToGrabMouseInput() From 864d8b8df2e892c2f8fc2333d45a173e1fa401d8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 27 Jan 2023 12:29:57 +0700 Subject: [PATCH 0120/1199] Return proper "input handled" booleans when possible --- .../mc/otm/client/screen/MatteryScreen.kt | 13 ++++---- .../otm/client/screen/panels/EditablePanel.kt | 32 ++++++++++++++----- 2 files changed, 31 insertions(+), 14 deletions(-) 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 976303274..8679606a7 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 @@ -318,10 +318,11 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit override fun mouseClicked(x: Double, y: Double, button: Int): Boolean { var click = false + var focusKilled = false for (panel in panels) { if (click || !panel.mouseClickedChecked(x, y, button)) { - panel.killFocusForEverythingExceptInner() + focusKilled = panel.killFocusForEverythingExceptInner() || focusKilled } else { if (returnSlot != null) { super.mouseClicked(x, y, button) @@ -332,7 +333,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } } - return true + return click || focusKilled } private var lastDragSlot: Slot? = null @@ -350,7 +351,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } } - return true + return false } override fun mouseReleased(p_97812_: Double, p_97813_: Double, p_97814_: Int): Boolean { @@ -388,7 +389,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } } - return true + return false } override fun keyReleased(p_94715_: Int, p_94716_: Int, p_94717_: Int): Boolean { @@ -398,7 +399,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } } - return true + return false } override fun charTyped(p_94683_: Char, p_94684_: Int): Boolean { @@ -408,7 +409,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } } - return true + return false } override fun keyPressed(key: Int, scancode: Int, mods: Int): Boolean { 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 1aecb526d..864394e24 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 @@ -1108,16 +1108,24 @@ open class EditablePanel @JvmOverloads constructor( } } - private fun killFocusInternal() { + private fun killFocusInternal(): Boolean { + var status = false + for (child in childrenInternal) { - child.killFocusInternal() + status = child.killFocusInternal() || status } if (isFocused) { isFocused = false + status = true } - grabMouseInput = false + if (grabMouseInput) { + grabMouseInput = false + status = true + } + + return status } private fun killGrabMouseInput() { @@ -1128,13 +1136,17 @@ open class EditablePanel @JvmOverloads constructor( grabMouseInput = false } - fun killFocus() { + fun killFocus(): Boolean { if (isEverFocused()) { - killFocusInternal() + val status = killFocusInternal() findAbsoluteRoot().updateFocus() + return status } else if (isGrabbingMouseInput()) { killGrabMouseInput() + return true } + + return false } fun findHierarchicalFocus(): EditablePanel<*>? { @@ -1310,14 +1322,18 @@ open class EditablePanel @JvmOverloads constructor( } } - fun killFocusForEverythingExceptInner() { + fun killFocusForEverythingExceptInner(): Boolean { + var focusKilled = false + for (child in childrenInternal) { - child.killFocusForEverythingExceptInner() + focusKilled = child.killFocusForEverythingExceptInner() || focusKilled } if (autoKillFocus) { - killFocus() + focusKilled = killFocus() || focusKilled } + + return focusKilled } final override fun mouseClicked(x: Double, y: Double, button: Int): Boolean { From fd84c40c1ef7f41256845f74be93749155d807b7 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 27 Jan 2023 20:16:40 +0700 Subject: [PATCH 0121/1199] Rename cursorCharacter to cursorRow --- .../screen/panels/input/TextInputPanel.kt | 174 +++++++++--------- 1 file changed, 87 insertions(+), 87 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt index 02ae27b59..99f9c457a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt @@ -79,7 +79,7 @@ open class TextInputPanel( private inner class Snapshot { private val lines = ArrayList(this@TextInputPanel.lines) // ultra fast copy private val cursorLine = this@TextInputPanel.cursorLine - private val cursorCharacter = this@TextInputPanel.cursorCharacter + private val cursorCharacter = this@TextInputPanel.cursorRow private val selections = Int2ObjectAVLTreeMap(this@TextInputPanel.selections) private val multiLine = this@TextInputPanel.multiLine @@ -96,7 +96,7 @@ open class TextInputPanel( if (this@TextInputPanel.multiLine && multiLine) this@TextInputPanel.selections.putAll(selections) - this@TextInputPanel.cursorCharacter = cursorCharacter + this@TextInputPanel.cursorRow = cursorCharacter this@TextInputPanel.cursorLine = cursorLine triggerChangeCallback() } @@ -139,7 +139,7 @@ open class TextInputPanel( } var cursorLine = 0 - var cursorCharacter = 0 + var cursorRow = 0 open var textColor = RGBAColor.WHITE open var cursorColor = RGBAColor.GREEN open var backgroundColor = RGBAColor.BLACK @@ -315,7 +315,7 @@ open class TextInputPanel( if (index != 0) cursorLine-- - cursorCharacter = lines.getOrNull(cursorLine)?.length ?: 0 + cursorRow = lines.getOrNull(cursorLine)?.length ?: 0 } lines.removeAt(index) @@ -339,8 +339,8 @@ open class TextInputPanel( @Suppress("name_shadowing") val moveBy = if (character + moveBy < 0) -character else moveBy - if (cursorLine == line && cursorCharacter >= character) { - cursorCharacter = (cursorCharacter + moveBy).coerceIn(0, this[cursorLine]?.length ?: Int.MAX_VALUE) + if (cursorLine == line && cursorRow >= character) { + cursorRow = (cursorRow + moveBy).coerceIn(0, this[cursorLine]?.length ?: Int.MAX_VALUE) } val selection = selections[line] @@ -403,9 +403,9 @@ open class TextInputPanel( if (lineNumber < cursorLine) { cursorLine = lineNumber - cursorCharacter = selection.start - } else if (lineNumber == cursorLine && cursorCharacter > selection.start) { - cursorCharacter = selection.start + cursorRow = selection.start + } else if (lineNumber == cursorLine && cursorRow > selection.start) { + cursorRow = selection.start } } @@ -437,7 +437,7 @@ open class TextInputPanel( redo.clear() undo.clear() cursorLine = 0 - cursorCharacter = 0 + cursorRow = 0 textCache = null if (multiLine) { @@ -464,36 +464,36 @@ open class TextInputPanel( val line = this[cursorLine] var couldHaveChangedLine = false - if (line != null && cursorCharacter > line.length) { - cursorCharacter = line.length - } else if (cursorCharacter < 0) { - cursorCharacter = 0 + if (line != null && cursorRow > line.length) { + cursorRow = line.length + } else if (cursorRow < 0) { + cursorRow = 0 } - val oldChar = cursorCharacter + val oldChar = cursorRow - if (cursorCharacter > 0) { + if (cursorRow > 0) { if (greedy && line != null) { - cursorCharacter = greedyAdvanceLeft(line, cursorCharacter) + cursorRow = greedyAdvanceLeft(line, cursorRow) } else { - cursorCharacter-- + cursorRow-- } } else if (cursorLine > 0) { cursorLine-- - cursorCharacter = 0 + cursorRow = 0 couldHaveChangedLine = true @Suppress("name_shadowing") val line = this[cursorLine] if (line != null) { - cursorCharacter = line.length + cursorRow = line.length } } else { couldHaveChangedLine = true } - return CursorAdvanceResult(oldLine, cursorLine, oldChar, cursorCharacter, couldHaveChangedLine = couldHaveChangedLine) + return CursorAdvanceResult(oldLine, cursorLine, oldChar, cursorRow, couldHaveChangedLine = couldHaveChangedLine) } fun advanceCursorRight(greedy: Boolean = false): CursorAdvanceResult { @@ -502,39 +502,39 @@ open class TextInputPanel( val line = this[cursorLine] - if (line != null && cursorCharacter > line.length) { - cursorCharacter = line.length - } else if (cursorCharacter < 0) { - cursorCharacter = 0 + if (line != null && cursorRow > line.length) { + cursorRow = line.length + } else if (cursorRow < 0) { + cursorRow = 0 } - val oldChar = cursorCharacter + val oldChar = cursorRow - if (greedy && line != null && cursorCharacter + 1 < line.length) { - cursorCharacter = greedyAdvanceRight(line, cursorCharacter) + if (greedy && line != null && cursorRow + 1 < line.length) { + cursorRow = greedyAdvanceRight(line, cursorRow) } else { - cursorCharacter++ + cursorRow++ } - if (line != null && cursorCharacter > line.length) { + if (line != null && cursorRow > line.length) { couldHaveChangedLine = true if (lines.size <= cursorLine + 1) { - cursorCharacter = line.length + cursorRow = line.length } else { cursorLine++ - cursorCharacter = 0 + cursorRow = 0 } } else if (line == null) { - cursorCharacter = 0 + cursorRow = 0 } - return CursorAdvanceResult(oldLine, cursorLine, oldChar, cursorCharacter, couldHaveChangedLine = couldHaveChangedLine) + return CursorAdvanceResult(oldLine, cursorLine, oldChar, cursorRow, couldHaveChangedLine = couldHaveChangedLine) } private fun simulateSelectLeft(greedy: Boolean) { val line = this[cursorLine] ?: return - val existing = selections[cursorLine] ?: TextSelection(cursorCharacter, 0) + val existing = selections[cursorLine] ?: TextSelection(cursorRow, 0) val result = advanceCursorLeft(greedy) if (result.couldHaveChangedLine) { @@ -557,7 +557,7 @@ open class TextInputPanel( private fun simulateSelectRight(greedy: Boolean) { val line = this[cursorLine] ?: return - val existing = selections[cursorLine] ?: TextSelection(cursorCharacter, 0) + val existing = selections[cursorLine] ?: TextSelection(cursorRow, 0) val result = advanceCursorRight(greedy) if (result.couldHaveChangedLine) { @@ -572,24 +572,24 @@ open class TextInputPanel( if (cursorLine <= 0) return false - val cursorCharacter = cursorCharacter + val cursorCharacter = cursorRow val cursorLine = cursorLine - while (this.cursorCharacter >= 0 && this.cursorLine == cursorLine) { + while (this.cursorRow >= 0 && this.cursorLine == cursorLine) { simulateSelectLeft(false) } val line = this[this.cursorLine]!! if (cursorCharacter < line.length) { - this.cursorCharacter = line.length + this.cursorRow = line.length - while (this.cursorCharacter > cursorCharacter) { + while (this.cursorRow > cursorCharacter) { simulateSelectLeft(false) } } - this.cursorCharacter = cursorCharacter + this.cursorRow = cursorCharacter return true } @@ -597,19 +597,19 @@ open class TextInputPanel( if (cursorLine >= lines.size - 1) return false - val cursorCharacter = cursorCharacter + val cursorCharacter = cursorRow val cursorLine = cursorLine - while (this.cursorCharacter >= cursorCharacter && this.cursorLine == cursorLine) { + while (this.cursorRow >= cursorCharacter && this.cursorLine == cursorLine) { simulateSelectRight(true) } val line = this[this.cursorLine]!! if (cursorCharacter < line.length) { - this.cursorCharacter = 0 + this.cursorRow = 0 - while (this.cursorCharacter < cursorCharacter) { + while (this.cursorRow < cursorCharacter) { simulateSelectRight(false) } } else { @@ -630,7 +630,7 @@ open class TextInputPanel( } } - this.cursorCharacter = cursorCharacter + this.cursorRow = cursorCharacter return true } @@ -648,25 +648,25 @@ open class TextInputPanel( val line = this[cursorLine] if (line != null && !minecraft.window.isShiftDown) { - if (cursorCharacter <= 0) { + if (cursorRow <= 0) { recordHistory(true) insertLine(cursorLine, "") if (!minecraft.window.isCtrlDown) { cursorLine++ - cursorCharacter = 0 + cursorRow = 0 } - } else if (cursorCharacter >= line.length) { + } else if (cursorRow >= line.length) { recordHistory(true) insertLine(cursorLine + 1, "") if (!minecraft.window.isCtrlDown) { cursorLine++ - cursorCharacter = 0 + cursorRow = 0 } } else { - val before = line.substring(0, cursorCharacter) - val after = line.substring(cursorCharacter) + val before = line.substring(0, cursorRow) + val after = line.substring(cursorRow) recordHistory(true) this[cursorLine] = before @@ -674,14 +674,14 @@ open class TextInputPanel( if (!minecraft.window.isCtrlDown) { cursorLine++ - cursorCharacter = 0 + cursorRow = 0 } } } else { recordHistory(true) insertLine(cursorLine + 1) cursorLine++ - cursorCharacter = 0 + cursorRow = 0 } triggerChangeCallback() @@ -752,11 +752,11 @@ open class TextInputPanel( val line = this[cursorLine] - if (cursorLine <= 0 && cursorCharacter <= 0) { + if (cursorLine <= 0 && cursorRow <= 0) { return true - } else if (cursorCharacter <= 0 || line?.length == 0) { + } else if (cursorRow <= 0 || line?.length == 0) { if (line == null) { - cursorCharacter = this[--cursorLine]?.length ?: 0 + cursorRow = this[--cursorLine]?.length ?: 0 recordHistory() } else { removeLine(cursorLine) @@ -776,13 +776,13 @@ open class TextInputPanel( pushbackSnapshotIfNoTimer() // remove from very end - if (cursorCharacter >= line.length) { + if (cursorRow >= line.length) { val newLine = line.substring(0, line.length - 1) - moveCursors(cursorLine, cursorCharacter, -1) + moveCursors(cursorLine, cursorRow, -1) this[cursorLine] = newLine } else { - val newLine = line.substring(0, cursorCharacter - 1) + line.substring(cursorCharacter) - moveCursors(cursorLine, cursorCharacter, -1) + val newLine = line.substring(0, cursorRow - 1) + line.substring(cursorRow) + moveCursors(cursorLine, cursorRow, -1) this[cursorLine] = newLine } @@ -815,7 +815,7 @@ open class TextInputPanel( if (cursorLine >= lines.size) cursorLine = lines.size - cursorCharacter = 0 + cursorRow = 0 recordHistory(true) triggerChangeCallback() return true @@ -823,7 +823,7 @@ open class TextInputPanel( val line = this[cursorLine]!! - if (cursorCharacter >= line.length) { + if (cursorRow >= line.length) { if (cursorLine + 1 == lines.size) { return true } @@ -831,18 +831,18 @@ open class TextInputPanel( pushbackSnapshotIfNoTimer() val bottomLine = this[cursorLine + 1]!! - cursorCharacter = line.length + cursorRow = line.length this[cursorLine] = line + bottomLine removeLine(cursorLine + 1) } else { pushbackSnapshotIfNoTimer() - val cursorCharacter = cursorCharacter + val cursorCharacter = cursorRow moveCursors(cursorLine, cursorCharacter, -1) this[cursorLine] = line.substring(0, cursorCharacter) + line.substring(cursorCharacter + 1) if (cursorCharacter != 0) - this.cursorCharacter++ + this.cursorRow++ } recordHistory() @@ -882,7 +882,7 @@ open class TextInputPanel( } else if (line.isEmpty()) { this[cursorLine] = insert[0] } else { - this[cursorLine] = line.substring(0, cursorCharacter.coerceAtMost(line.length - 1)) + insert[0] + line.substring(cursorCharacter.coerceAtMost(line.length)) + this[cursorLine] = line.substring(0, cursorRow.coerceAtMost(line.length - 1)) + insert[0] + line.substring(cursorRow.coerceAtMost(line.length)) } for (i in 1 until insert.size - 1) { @@ -907,7 +907,7 @@ open class TextInputPanel( } else if (line.isEmpty()) { this[cursorLine] = insert } else { - this[cursorLine] = line.substring(0, cursorCharacter.coerceAtMost(line.length - 1)) + insert + line.substring(cursorCharacter.coerceAtMost(line.length)) + this[cursorLine] = line.substring(0, cursorRow.coerceAtMost(line.length - 1)) + insert + line.substring(cursorRow.coerceAtMost(line.length)) } } @@ -941,15 +941,15 @@ open class TextInputPanel( } if (key == InputConstants.KEY_HOME) { - if (minecraft.window.isShiftDown && cursorCharacter != 0) { + if (minecraft.window.isShiftDown && cursorRow != 0) { val thisLine = cursorLine - while (cursorCharacter > 0 && thisLine == cursorLine) { + while (cursorRow > 0 && thisLine == cursorLine) { simulateSelectLeft(false) } } else { if (!minecraft.window.isShiftDown) selections.clear() - cursorCharacter = 0 + cursorRow = 0 } return true @@ -958,15 +958,15 @@ open class TextInputPanel( if (key == InputConstants.KEY_END) { if (minecraft.window.isShiftDown) { val line = this[cursorLine] ?: return true - if (cursorCharacter >= line.length) return true + if (cursorRow >= line.length) return true val thisLine = cursorLine - while (cursorCharacter < line.length && thisLine == cursorLine) { + while (cursorRow < line.length && thisLine == cursorLine) { simulateSelectRight(false) } } else { if (!minecraft.window.isShiftDown) selections.clear() - cursorCharacter = this[cursorLine]?.length ?: 0 + cursorRow = this[cursorLine]?.length ?: 0 } return true @@ -1000,18 +1000,18 @@ open class TextInputPanel( if (line == null) { set(cursorLine, "") line = "" - cursorCharacter = 0 + cursorRow = 0 } - if (cursorCharacter >= line.length) + if (cursorRow >= line.length) line += codepoint else - line = line.substring(0, cursorCharacter) + codepoint + line.substring(cursorCharacter) + line = line.substring(0, cursorRow) + codepoint + line.substring(cursorRow) pushbackSnapshotIfNoTimer() set(cursorLine, line) - moveCursors(cursorLine, cursorCharacter, 1) + moveCursors(cursorLine, cursorRow, 1) recordHistory() triggerChangeCallback() @@ -1082,7 +1082,7 @@ open class TextInputPanel( if (isFocused && milliTime % 1000L > 500L) { val activeLine = this[cursorLine] - if (activeLine == null || cursorCharacter >= activeLine.length) { + if (activeLine == null || cursorRow >= activeLine.length) { font.drawAligned( poseStack = stack, buffer = BUFFER, @@ -1098,7 +1098,7 @@ open class TextInputPanel( buffer = BUFFER, text = "|", align = TextAlign.TOP_LEFT, - x = dockPadding.left + font.width(activeLine.substring(0, cursorCharacter)).toFloat() - 1f, + x = dockPadding.left + font.width(activeLine.substring(0, cursorRow)).toFloat() - 1f, y = dockPadding.top + cursorLine * (font.lineHeight + 2f), color = cursorColor ) @@ -1119,7 +1119,7 @@ open class TextInputPanel( font.drawAligned( poseStack = stack, buffer = BUFFER, - text = cursorCharacter.toString(), + text = cursorRow.toString(), align = TextAlign.TOP_RIGHT, x = width - dockPadding.right, y = dockPadding.top + font.lineHeight + 2f, @@ -1157,7 +1157,7 @@ open class TextInputPanel( val (lx, ly) = screenToLocal(x, y) val pos = localToText(lx, ly) cursorLine = pos.y - cursorCharacter = pos.x + cursorRow = pos.x } isSelecting = true @@ -1231,15 +1231,15 @@ open class TextInputPanel( while (cursorLine > this.cursorLine && simulateSelectionDown()) {} while (cursorLine < this.cursorLine && simulateSelectionUp()) {} - var lastCursorCharacter = this.cursorCharacter + 1 + var lastCursorCharacter = this.cursorRow + 1 - while (cursorCharacter < this.cursorCharacter && lastCursorCharacter != this.cursorCharacter) { - lastCursorCharacter = this.cursorCharacter + while (cursorCharacter < this.cursorRow && lastCursorCharacter != this.cursorRow) { + lastCursorCharacter = this.cursorRow simulateSelectLeft(false) } - while (cursorCharacter > this.cursorCharacter && lastCursorCharacter != this.cursorCharacter) { - lastCursorCharacter = this.cursorCharacter + while (cursorCharacter > this.cursorRow && lastCursorCharacter != this.cursorRow) { + lastCursorCharacter = this.cursorRow simulateSelectRight(false) } From 64a54add95c500520c9be6c51d21d5aa27d5a0da Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 28 Jan 2023 17:26:04 +0700 Subject: [PATCH 0122/1199] Line and row scrolling --- .../screen/panels/input/TextInputPanel.kt | 88 ++++++++++++++++--- 1 file changed, 75 insertions(+), 13 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt index 99f9c457a..2fd29f08e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt @@ -27,6 +27,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.addAll import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.milliTime +import kotlin.math.roundToInt open class TextInputPanel( screen: S, @@ -158,6 +159,18 @@ open class TextInputPanel( private val undo = ArrayDeque() private val redo = ArrayDeque() + /** + * scroll in rows (up-down) + */ + private var scrollLines = 0 + + /** + * scroll in pixels (left-right) + */ + private var scrollPixels = 0f + + var rowSpacing = 2f + private fun triggerChangeCallback() { if (oldText != lines) { textCache = null @@ -1018,13 +1031,59 @@ open class TextInputPanel( return true } + private val characterWidthCache = Char2IntOpenHashMap() + + private fun width(char: Char): Int { + return characterWidthCache.computeIfAbsent(char, Char2IntFunction { font.width(it.toString()) }) + } + + private fun width(text: String, beginning: Int = 0, end: Int = text.length - 1): Int { + var accumulate = 0 + + for (i in beginning.coerceAtLeast(0) .. end.coerceAtMost(text.length - 1)) { + accumulate += width(text[i]) + } + + return accumulate + } + override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { if (!backgroundColor.isFullyTransparent) drawRect(stack, 0f, 0f, width, height, backgroundColor) + if (multiLine) { + val heightInLines = ((height - dockPadding.top - dockPadding.bottom) / (font.lineHeight + rowSpacing)).toInt() + + if (heightInLines > 0) { + if (cursorLine < scrollLines) { + scrollLines = (cursorLine - 1).coerceAtLeast(0) + } else if (heightInLines + scrollLines < cursorLine) { + scrollLines = (cursorLine - heightInLines).coerceIn(0, lines.size - 2) + } + } + } else { + scrollLines = 0 + } + + val selectedLine = this[cursorLine] + + if (selectedLine != null) { + val w = width(selectedLine, end = cursorRow) - scrollPixels + + if (w < 0f) { + scrollPixels = (scrollPixels - 30f).coerceAtLeast(0f) + } else if (w >= width - dockPadding.right) { + scrollPixels += 30f + } + } + + stack.pushPose() + stack.translate(-scrollPixels, 0f, 0f) + var y = dockPadding.top - for ((i, line) in lines.withIndex()) { + for (i in scrollLines until lines.size) { + val line = lines[i] val selection = selections[i] font.drawAligned( @@ -1046,7 +1105,7 @@ open class TextInputPanel( x += font.width(before).toFloat() } - val width = if (selection.coversNewline(line) && i != lines.size - 1) this.width - x else font.width(selected).toFloat() + val width = if (selection.coversNewline(line) && i != lines.size - 1) this.width - x + scrollPixels else font.width(selected).toFloat() RenderSystem.setShader(GameRenderer::getPositionShader) RenderSystem.setShaderColor(cursorColor.red, cursorColor.green, cursorColor.blue, 0.4f) @@ -1060,8 +1119,8 @@ open class TextInputPanel( builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION) - builder.vertex(stack.last().pose(), x, y + font.lineHeight + 2f, 0f).endVertex() - builder.vertex(stack.last().pose(), x + width, y + font.lineHeight + 2f, 0f).endVertex() + builder.vertex(stack.last().pose(), x, y + font.lineHeight + rowSpacing, 0f).endVertex() + builder.vertex(stack.last().pose(), x + width, y + font.lineHeight + rowSpacing, 0f).endVertex() builder.vertex(stack.last().pose(), x + width, y, 0f).endVertex() builder.vertex(stack.last().pose(), x, y, 0f).endVertex() @@ -1073,7 +1132,7 @@ open class TextInputPanel( RenderSystem.enableDepthTest() } - y += font.lineHeight + 2f + y += font.lineHeight + rowSpacing if (y > height - dockPadding.bottom) break @@ -1089,7 +1148,7 @@ open class TextInputPanel( text = "_", align = TextAlign.TOP_LEFT, x = dockPadding.left + (if (activeLine == null) 0f else font.width(activeLine).toFloat()), - y = dockPadding.top + cursorLine * (font.lineHeight + 2f), + y = dockPadding.top + (cursorLine - scrollLines) * (font.lineHeight + rowSpacing), color = cursorColor ) } else { @@ -1099,12 +1158,14 @@ open class TextInputPanel( text = "|", align = TextAlign.TOP_LEFT, x = dockPadding.left + font.width(activeLine.substring(0, cursorRow)).toFloat() - 1f, - y = dockPadding.top + cursorLine * (font.lineHeight + 2f), + y = dockPadding.top + (cursorLine - scrollLines) * (font.lineHeight + rowSpacing), color = cursorColor ) } } + stack.popPose() + if (debugDraw) { font.drawAligned( poseStack = stack, @@ -1122,7 +1183,7 @@ open class TextInputPanel( text = cursorRow.toString(), align = TextAlign.TOP_RIGHT, x = width - dockPadding.right, - y = dockPadding.top + font.lineHeight + 2f, + y = dockPadding.top + font.lineHeight + rowSpacing, color = cursorColor ) @@ -1132,7 +1193,7 @@ open class TextInputPanel( text = lines.size.toString(), align = TextAlign.TOP_RIGHT, x = width - dockPadding.right, - y = dockPadding.top + font.lineHeight * 2 + 4f, + y = dockPadding.top + font.lineHeight * 2f + rowSpacing * 2f, color = cursorColor ) } @@ -1181,19 +1242,20 @@ open class TextInputPanel( if (x > width - dockPadding.right) x = width - dockPadding.right - val line = (y / (font.lineHeight + 2f)).toInt().coerceIn(0, lines.size - 1) + x += scrollPixels + + val line = (scrollLines + (y / (font.lineHeight + rowSpacing)).toInt()).coerceIn(0, lines.size - 1) val sLine = this[line] ?: return Vector2i(0, line) if (x <= 0f) return Vector2i(0, line) - else if (x >= font.width(sLine)) + else if (x >= width(sLine)) return Vector2i(sLine.length, line) - val cache = Char2IntOpenHashMap() var accumulatedWidth = 0f for ((i, char) in sLine.withIndex()) { - val width = cache.computeIfAbsent(char, Char2IntFunction { font.width(it.toString()) }) + val width = width(char) if (x in accumulatedWidth .. accumulatedWidth + width) { if (x - accumulatedWidth < width / 2) From 8de86dd08767501ed70272ce8bb90cde3fb5fb6a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 28 Jan 2023 17:50:18 +0700 Subject: [PATCH 0123/1199] Limit text input in holo sign --- .../entity/decorative/HoloSignBlockEntity.kt | 2 ++ .../mc/otm/menu/decorative/HoloSignMenu.kt | 23 ++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt index 7d2283702..f79bc621c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt @@ -40,5 +40,7 @@ class HoloSignBlockEntity(blockPos: BlockPos, blockState: BlockState) : Synchron companion object { const val TEXT_KEY = "SignText" + const val DEFAULT_MAX_NEWLINES = 8 + const val DEFAULT_MAX_LINE_LENGTH = 15 } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt index 871f21e60..ef06105ad 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.menu.decorative import net.minecraft.world.entity.player.Inventory import net.minecraft.world.inventory.Slot import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity +import ru.dbotthepony.mc.otm.client.screen.panels.input.TextInputPanel import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.input.NetworkedStringInput import ru.dbotthepony.mc.otm.registry.MMenus @@ -12,8 +13,28 @@ class HoloSignMenu @JvmOverloads constructor( inventory: Inventory, tile: HoloSignBlockEntity? = null ) : MatteryMenu(MMenus.HOLO_SIGN, containerId, inventory, tile) { - val text = if (tile != null) NetworkedStringInput(this, tile::text) else NetworkedStringInput(this) + val text = if (tile != null) + NetworkedStringInput(this).withConsumer { + val lines = it.split(NEWLINES) + val result = ArrayList(lines.size.coerceAtMost(HoloSignBlockEntity.DEFAULT_MAX_NEWLINES)) + + for (i in 0 until lines.size.coerceAtMost(HoloSignBlockEntity.DEFAULT_MAX_NEWLINES)) { + if (lines[i].length > HoloSignBlockEntity.DEFAULT_MAX_LINE_LENGTH) { + result.add(lines[i].substring(0, HoloSignBlockEntity.DEFAULT_MAX_LINE_LENGTH)) + } else { + result.add(lines[i]) + } + } + + tile.text = result.joinToString("\n") + }.withSupplier(tile::text) + else + NetworkedStringInput(this) override val storageSlots: Collection get() = listOf() + + companion object { + private val NEWLINES = Regex("\r?\n") + } } From fd9b74cebe54c85614348f0a082f4fb059399578 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 28 Jan 2023 18:18:46 +0700 Subject: [PATCH 0124/1199] Get rid of matterymodelbuilder (because it is useless) --- .../mc/otm/datagen/DecorativeData.kt | 7 +- .../mc/otm/datagen/models/BlockModels.kt | 25 --- .../otm/datagen/models/MatteryModelBuilder.kt | 164 ------------------ .../datagen/models/MatteryModelProvider.kt | 37 +--- 4 files changed, 7 insertions(+), 226 deletions(-) delete mode 100644 src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelBuilder.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt index 8a9319f1a..d574dc669 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt @@ -1,11 +1,11 @@ package ru.dbotthepony.mc.otm.datagen import net.minecraft.resources.ResourceLocation -import net.minecraft.world.level.block.PressurePlateBlock import net.minecraft.world.level.block.SlabBlock import net.minecraft.world.level.block.StairBlock import net.minecraft.world.level.block.WallBlock import net.minecraft.world.level.block.state.properties.BlockStateProperties +import net.minecraftforge.client.model.generators.BlockModelBuilder import net.minecraftforge.client.model.generators.ConfiguredModel import net.minecraftforge.client.model.generators.ModelFile import ru.dbotthepony.mc.otm.OverdriveThatMatters @@ -15,7 +15,6 @@ import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.datagen.blocks.MatteryBlockStateProvider import ru.dbotthepony.mc.otm.datagen.items.MatteryItemModelProvider import ru.dbotthepony.mc.otm.datagen.models.MatteryBlockModelProvider -import ru.dbotthepony.mc.otm.datagen.models.MatteryModelBuilder import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MNames @@ -181,8 +180,8 @@ fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelPr DataGen.decorativeCubeAll(MBlocks.DANGER_STRIPE_BLOCK) DataGen.decorativeColumn(MBlocks.METAL_BEAM, "metal_beam_side", "metal_beam_top") - var labLampOn: MatteryModelBuilder? = null - var labLampOff: MatteryModelBuilder? = null + var labLampOn: BlockModelBuilder? = null + var labLampOff: BlockModelBuilder? = null blockModelProvider.exec { val top = ResourceLocation(DataGen.MOD_ID, "block/decorative/metal_beam_top") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/BlockModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/BlockModels.kt index af8524102..52418774b 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/BlockModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/BlockModels.kt @@ -9,30 +9,5 @@ fun addBlockModels(provider: MatteryBlockModelProvider) { resourceCubeAll(MBlocks.TRITANIUM_RAW_BLOCK) resourceCubeAll(MBlocks.DEEPSLATE_TRITANIUM_ORE) resourceCubeAll(MBlocks.TRITANIUM_INGOT_BLOCK) - - exec { - copy("block/battery/battery1", "block/battery/battery0").also { it.offset(-4f, 0f, 0f) } - copy("block/battery/battery2", "block/battery/battery0").also { it.offset(-8f, 0f, 0f) } - - copy("block/battery/battery3", "block/battery/battery0").also { it.offset(0f, 6f, 0f) } - copy("block/battery/battery4", "block/battery/battery0").also { it.offset(-4f, 6f, 0f) } - copy("block/battery/battery5", "block/battery/battery0").also { it.offset(-8f, 6f, 0f) } - - copy("block/battery/battery7", "block/battery/battery6").also { it.offset(4f, 0f, 0f) } - copy("block/battery/battery8", "block/battery/battery6").also { it.offset(8f, 0f, 0f) } - - copy("block/battery/battery9", "block/battery/battery6").also { it.offset(0f, 6f, 0f) } - copy("block/battery/battery10", "block/battery/battery6").also { it.offset(4f, 6f, 0f) } - copy("block/battery/battery11", "block/battery/battery6").also { it.offset(8f, 6f, 0f) } - - for (i in 0 .. 11) { - withExistingParent("block/battery/matter_capacitor$i", ResourceLocation(ru.dbotthepony.mc.otm.datagen.DataGen.MOD_ID, "block/battery/battery$i")) - .texture("1", "block/matterybank_core") - } - - for (i in 1 .. 7) { - copy("block/pattern/model$i", "block/pattern/model0").also { it.offset(-2f * i, 0f, 0f) } - } - } } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelBuilder.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelBuilder.kt deleted file mode 100644 index e1b04a422..000000000 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelBuilder.kt +++ /dev/null @@ -1,164 +0,0 @@ -package ru.dbotthepony.mc.otm.datagen.models - -import com.google.gson.JsonArray -import com.google.gson.JsonObject -import com.google.gson.JsonPrimitive -import net.minecraft.client.renderer.block.model.BlockModel -import net.minecraft.core.Direction -import net.minecraft.resources.ResourceLocation -import net.minecraftforge.client.model.generators.ModelBuilder -import net.minecraftforge.common.data.ExistingFileHelper -import org.joml.Vector3f -import ru.dbotthepony.mc.otm.container.set -import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.core.set - -data class TextureSize(val width: Float, val height: Float) { - constructor(arr: JsonArray) : this(arr[0].asFloat, arr[1].asFloat) - - init { - require(width > 0f) { "Invalid width $width" } - require(height > 0f) { "Invalid width $height" } - } -} - -class MatteryModelBuilder(resourceLocation: ResourceLocation, existingFileHelper: ExistingFileHelper) : ModelBuilder(resourceLocation, existingFileHelper) { - var textureSize: TextureSize? = null - - fun fromJson(input: JsonObject) { - input["parent"]?.let { - parent(ExistingModelFile(ResourceLocation(it.asString), existingFileHelper)) - } - - input["ambientocclusion"]?.let { - ambientOcclusion = it.asBoolean - } - - input["gui_light"]?.let { - guiLight = BlockModel.GuiLight.valueOf(it.asString) - } - - (input["texture_size"] as? JsonArray)?.let { - textureSize = TextureSize(it) - } - - (input["textures"] as? JsonObject)?.let { - for ((k, v) in it.entrySet()) { - texture(k, v.asString) - } - } - - (input["elements"] as? JsonArray)?.let { - var i = -1 - - for (value in it) { - i++ - check(value is JsonObject) { "Encountered invalid element at $i" } - element().fromJson(value) - } - } - } - - override fun toJson(): JsonObject { - return super.toJson().also { - val textureSize = textureSize - - if (textureSize != null) { - it["texture_size"] = JsonArray().also { - it.add(textureSize.width) - it.add(textureSize.height) - } - } - } - } - - override fun element(): MatteryModelElement { - check(customLoader == null) { "Can not use custom loaders and elements at the same time" } - return MatteryModelElement().also(elements::add) - } - - override fun element(index: Int): MatteryModelElement { - return super.element(index) as MatteryModelElement - } - - fun offset(x: Float, y: Float, z: Float) { - for (element in elements) { - (element as MatteryModelElement).offset(x, y, z) - } - } - - fun offset(value: Vector3f) { - for (element in elements) { - (element as MatteryModelElement).offset(value) - } - } - - inner class MatteryModelElement : ElementBuilder() { - private var from: Vector3f = Vector3f() - private var to: Vector3f = Vector3f(16f, 16f, 16f) - - fun from(value: Vector3f) = from(value.x(), value.y(), value.z()) - fun to(value: Vector3f) = to(value.x(), value.y(), value.z()) - - override fun from(x: Float, y: Float, z: Float): MatteryModelElement { - from = Vector3f(x, y, z) - super.from(x, y, z) - return this - } - - override fun to(x: Float, y: Float, z: Float): MatteryModelElement { - to = Vector3f(x, y, z) - super.to(x, y, z) - return this - } - - fun offset(x: Float, y: Float, z: Float): MatteryModelElement { - from(x + from.x(), y + from.y(), z + from.z()) - return to(x + to.x(), y + to.y(), z + to.z()) - } - - fun offset(value: Vector3f) = offset(value.x(), value.y(), value.z()) - - fun fromJson(input: JsonObject) { - val from = input["from"] as JsonArray - val to = input["to"] as JsonArray - - from(from[0].asFloat, from[1].asFloat, from[2].asFloat) - to(to[0].asFloat, to[1].asFloat, to[2].asFloat) - - (input["faces"] as? JsonObject)?.let { - for ((k, v) in it.entrySet()) { - with(face(Direction.valueOf(k.uppercase()))) { - check(v is JsonObject) { "Element has invalid face at $k" } - - (v["uv"] as? JsonArray)?.also { uv -> - check(uv.size() == 4) { "Element at $k has invalid number of uvs ${uv.size()}" } - uvs(uv[0].asFloat, uv[1].asFloat, uv[2].asFloat, uv[3].asFloat) - } - - (v["rotation"] as? JsonPrimitive)?.also { rotation -> - when (rotation.asInt) { - 90 -> rotation(FaceRotation.CLOCKWISE_90) - -90, 270 -> rotation(FaceRotation.COUNTERCLOCKWISE_90) - 180, -180 -> rotation(FaceRotation.UPSIDE_DOWN) - else -> rotation(FaceRotation.ZERO) - } - } - - (v["emissivity"] as? JsonPrimitive)?.asInt?.also { emissivity -> - emissivity(emissivity, 0) - } - - (v["ao"] as? JsonPrimitive)?.asBoolean?.also { ao -> - ao(ao) - } - - (v["texture"] as? JsonPrimitive)?.also { - texture(it.asString) - } - } - } - } - } - } -} diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelProvider.kt index b7d1dca22..cec8563c5 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelProvider.kt @@ -6,44 +6,17 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.server.packs.PackType import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.DoorBlock +import net.minecraftforge.client.model.generators.BlockModelProvider import net.minecraftforge.client.model.generators.ModelProvider import net.minecraftforge.data.event.GatherDataEvent import ru.dbotthepony.mc.otm.datagen.DataGen import ru.dbotthepony.mc.otm.core.registryName import java.util.LinkedList -private typealias Callback = (MatteryModelProvider) -> Unit +class MatteryBlockModelProvider(event: GatherDataEvent) : BlockModelProvider(event.generator.packOutput, DataGen.MOD_ID, event.existingFileHelper) { + private val callbacks = LinkedList<(MatteryBlockModelProvider) -> Unit>() -sealed class MatteryModelProvider(event: GatherDataEvent, folder: String) : ModelProvider(event.generator.packOutput, DataGen.MOD_ID, folder, ::MatteryModelBuilder, event.existingFileHelper) { - private fun extendWithFolder(rl: ResourceLocation): ResourceLocation { - return if (rl.path.contains("/")) rl else ResourceLocation(rl.namespace, folder + "/" + rl.path) - } - - fun copy(destination: String, source: String): MatteryModelBuilder { - val destinationLocation = extendWithFolder(if (destination.contains(":")) ResourceLocation(destination) else ResourceLocation(modid, destination)) - val sourceLocation = extendWithFolder(if (source.contains(":")) ResourceLocation("models/$source.json") else ResourceLocation(modid, "models/$source.json")) - - check(!generatedModels.containsKey(destinationLocation)) { "Model provider already contains model $destinationLocation" } - existingFileHelper.trackGenerated(destinationLocation, MODEL) - - return factory.apply(destinationLocation).also { - generatedModels[destinationLocation] = it - val resource = existingFileHelper.getResource(sourceLocation, PackType.CLIENT_RESOURCES) - val stream = resource.open() - val reader = stream.reader() - - try { - it.fromJson(JsonParser.parseReader(reader) as JsonObject) - } finally { - reader.close() - stream.close() - } - } - } - - private val callbacks = LinkedList() - - fun exec(callback: Callback) { + fun exec(callback: (MatteryBlockModelProvider) -> Unit) { callbacks.add(callback) } @@ -52,9 +25,7 @@ sealed class MatteryModelProvider(event: GatherDataEvent, folder: String) : Mode callback(this) } } -} -class MatteryBlockModelProvider(event: GatherDataEvent) : MatteryModelProvider(event, BLOCK_FOLDER) { override fun getName(): String { return "Block Models: $modid" } From ad2ab7e10adf3bde107f1c8b05551933a63b6db1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 28 Jan 2023 18:24:05 +0700 Subject: [PATCH 0125/1199] Add battery models which are no longer datagened --- .../models/block/battery/battery0.json | 2 +- .../models/block/battery/battery1.json | 153 ++++++++++++++++++ .../models/block/battery/battery10.json | 153 ++++++++++++++++++ .../models/block/battery/battery11.json | 153 ++++++++++++++++++ .../models/block/battery/battery2.json | 153 ++++++++++++++++++ .../models/block/battery/battery3.json | 153 ++++++++++++++++++ .../models/block/battery/battery4.json | 153 ++++++++++++++++++ .../models/block/battery/battery5.json | 153 ++++++++++++++++++ .../models/block/battery/battery6.json | 2 +- .../models/block/battery/battery7.json | 153 ++++++++++++++++++ .../models/block/battery/battery8.json | 153 ++++++++++++++++++ .../models/block/battery/battery9.json | 153 ++++++++++++++++++ .../block/battery/matter_capacitor0.json | 6 + .../block/battery/matter_capacitor1.json | 6 + .../block/battery/matter_capacitor10.json | 6 + .../block/battery/matter_capacitor11.json | 6 + .../block/battery/matter_capacitor2.json | 6 + .../block/battery/matter_capacitor3.json | 6 + .../block/battery/matter_capacitor4.json | 6 + .../block/battery/matter_capacitor5.json | 6 + .../block/battery/matter_capacitor6.json | 6 + .../block/battery/matter_capacitor7.json | 6 + .../block/battery/matter_capacitor8.json | 6 + .../block/battery/matter_capacitor9.json | 6 + .../models/block/pattern/model1.json | 80 +++++++++ .../models/block/pattern/model2.json | 80 +++++++++ .../models/block/pattern/model3.json | 80 +++++++++ .../models/block/pattern/model4.json | 80 +++++++++ .../models/block/pattern/model5.json | 80 +++++++++ .../models/block/pattern/model6.json | 80 +++++++++ .../models/block/pattern/model7.json | 80 +++++++++ 31 files changed, 2164 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/battery/battery1.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/battery/battery10.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/battery/battery11.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/battery/battery2.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/battery/battery3.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/battery/battery4.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/battery/battery5.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/battery/battery7.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/battery/battery8.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/battery/battery9.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor0.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor1.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor10.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor11.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor2.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor3.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor4.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor5.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor6.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor7.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor8.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor9.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/pattern/model1.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/pattern/model2.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/pattern/model3.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/pattern/model4.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/pattern/model5.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/pattern/model6.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/pattern/model7.json diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery0.json b/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery0.json index 194766728..c605a9108 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery0.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery0.json @@ -23,7 +23,7 @@ "from": [11, 2, 1], "to": [13, 7, 1], "faces": { - "north": {"uv": [1.5, 3, 2.5, 8], "texture": "#1", "emissivity": 15}, + "north": {"uv": [1.5, 3, 2.5, 8], "texture": "#1", "forge_data": {"block_light": 15}}, "east": {"uv": [0, 0, 0, 5], "texture": "#missing"}, "south": {"uv": [0, 0, 1, 5], "texture": "#missing"}, "west": {"uv": [0, 0, 0, 5], "texture": "#missing"}, diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery1.json b/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery1.json new file mode 100644 index 000000000..cf73f222b --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery1.json @@ -0,0 +1,153 @@ +{ + "elements": [ + { + "faces": { + "down": { + "rotation": 270, + "texture": "#1", + "uv": [ + 8.0, + 7.0, + 11.0, + 9.0 + ] + }, + "east": { + "rotation": 180, + "texture": "#1", + "uv": [ + 8.0, + 7.0, + 11.0, + 2.0 + ] + }, + "north": { + "texture": "#1", + "uv": [ + 12.0, + 2.0, + 13.0, + 7.0 + ] + }, + "south": { + "texture": "#1", + "uv": [ + 11.0, + 2.0, + 12.0, + 7.0 + ] + }, + "up": { + "rotation": 90, + "texture": "#1", + "uv": [ + 8.0, + 0.0, + 11.0, + 2.0 + ] + }, + "west": { + "texture": "#1", + "uv": [ + 8.0, + 2.0, + 11.0, + 7.0 + ] + } + }, + "from": [ + 7, + 2, + 1 + ], + "to": [ + 9, + 7, + 7 + ] + }, + { + "faces": { + "down": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 0.0 + ] + }, + "east": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 0.0, + 5.0 + ] + }, + "north": { + "forge_data": { + "block_light": 15 + }, + "texture": "#1", + "uv": [ + 1.5, + 3.0, + 2.5, + 8.0 + ] + }, + "south": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 5.0 + ] + }, + "up": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 0.0 + ] + }, + "west": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 0.0, + 5.0 + ] + } + }, + "from": [ + 7, + 2, + 1 + ], + "to": [ + 9, + 7, + 1 + ] + } + ], + "texture_size": [ + 32.0, + 16.0 + ], + "textures": { + "1": "overdrive_that_matters:block/batterybank_core" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery10.json b/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery10.json new file mode 100644 index 000000000..61036c0e1 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery10.json @@ -0,0 +1,153 @@ +{ + "elements": [ + { + "faces": { + "down": { + "rotation": 90, + "texture": "#1", + "uv": [ + 8.0, + 7.0, + 11.0, + 9.0 + ] + }, + "east": { + "texture": "#1", + "uv": [ + 8.0, + 2.0, + 11.0, + 7.0 + ] + }, + "north": { + "texture": "#1", + "uv": [ + 11.0, + 2.0, + 12.0, + 7.0 + ] + }, + "south": { + "texture": "#1", + "uv": [ + 12.0, + 2.0, + 13.0, + 7.0 + ] + }, + "up": { + "rotation": 270, + "texture": "#1", + "uv": [ + 8.0, + 0.0, + 11.0, + 2.0 + ] + }, + "west": { + "rotation": 180, + "texture": "#1", + "uv": [ + 8.0, + 7.0, + 11.0, + 2.0 + ] + } + }, + "from": [ + 7, + 8, + 9 + ], + "to": [ + 9, + 13, + 15 + ] + }, + { + "faces": { + "down": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 0.0 + ] + }, + "east": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 0.0, + 5.0 + ] + }, + "north": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 5.0 + ] + }, + "south": { + "forge_data": { + "block_light": 15 + }, + "texture": "#1", + "uv": [ + 2.0, + 3.0, + 3.0, + 8.0 + ] + }, + "up": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 0.0 + ] + }, + "west": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 0.0, + 5.0 + ] + } + }, + "from": [ + 7, + 8, + 15 + ], + "to": [ + 9, + 13, + 15 + ] + } + ], + "texture_size": [ + 32.0, + 16.0 + ], + "textures": { + "1": "overdrive_that_matters:block/batterybank_core" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery11.json b/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery11.json new file mode 100644 index 000000000..8ef46e816 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery11.json @@ -0,0 +1,153 @@ +{ + "elements": [ + { + "faces": { + "down": { + "rotation": 90, + "texture": "#1", + "uv": [ + 8.0, + 7.0, + 11.0, + 9.0 + ] + }, + "east": { + "texture": "#1", + "uv": [ + 8.0, + 2.0, + 11.0, + 7.0 + ] + }, + "north": { + "texture": "#1", + "uv": [ + 11.0, + 2.0, + 12.0, + 7.0 + ] + }, + "south": { + "texture": "#1", + "uv": [ + 12.0, + 2.0, + 13.0, + 7.0 + ] + }, + "up": { + "rotation": 270, + "texture": "#1", + "uv": [ + 8.0, + 0.0, + 11.0, + 2.0 + ] + }, + "west": { + "rotation": 180, + "texture": "#1", + "uv": [ + 8.0, + 7.0, + 11.0, + 2.0 + ] + } + }, + "from": [ + 11, + 8, + 9 + ], + "to": [ + 13, + 13, + 15 + ] + }, + { + "faces": { + "down": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 0.0 + ] + }, + "east": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 0.0, + 5.0 + ] + }, + "north": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 5.0 + ] + }, + "south": { + "forge_data": { + "block_light": 15 + }, + "texture": "#1", + "uv": [ + 2.0, + 3.0, + 3.0, + 8.0 + ] + }, + "up": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 0.0 + ] + }, + "west": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 0.0, + 5.0 + ] + } + }, + "from": [ + 11, + 8, + 15 + ], + "to": [ + 13, + 13, + 15 + ] + } + ], + "texture_size": [ + 32.0, + 16.0 + ], + "textures": { + "1": "overdrive_that_matters:block/batterybank_core" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery2.json b/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery2.json new file mode 100644 index 000000000..bd0876bd3 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery2.json @@ -0,0 +1,153 @@ +{ + "elements": [ + { + "faces": { + "down": { + "rotation": 270, + "texture": "#1", + "uv": [ + 8.0, + 7.0, + 11.0, + 9.0 + ] + }, + "east": { + "rotation": 180, + "texture": "#1", + "uv": [ + 8.0, + 7.0, + 11.0, + 2.0 + ] + }, + "north": { + "texture": "#1", + "uv": [ + 12.0, + 2.0, + 13.0, + 7.0 + ] + }, + "south": { + "texture": "#1", + "uv": [ + 11.0, + 2.0, + 12.0, + 7.0 + ] + }, + "up": { + "rotation": 90, + "texture": "#1", + "uv": [ + 8.0, + 0.0, + 11.0, + 2.0 + ] + }, + "west": { + "texture": "#1", + "uv": [ + 8.0, + 2.0, + 11.0, + 7.0 + ] + } + }, + "from": [ + 3, + 2, + 1 + ], + "to": [ + 5, + 7, + 7 + ] + }, + { + "faces": { + "down": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 0.0 + ] + }, + "east": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 0.0, + 5.0 + ] + }, + "north": { + "forge_data": { + "block_light": 15 + }, + "texture": "#1", + "uv": [ + 1.5, + 3.0, + 2.5, + 8.0 + ] + }, + "south": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 5.0 + ] + }, + "up": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 0.0 + ] + }, + "west": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 0.0, + 5.0 + ] + } + }, + "from": [ + 3, + 2, + 1 + ], + "to": [ + 5, + 7, + 1 + ] + } + ], + "texture_size": [ + 32.0, + 16.0 + ], + "textures": { + "1": "overdrive_that_matters:block/batterybank_core" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery3.json b/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery3.json new file mode 100644 index 000000000..e194b47fa --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery3.json @@ -0,0 +1,153 @@ +{ + "elements": [ + { + "faces": { + "down": { + "rotation": 270, + "texture": "#1", + "uv": [ + 8.0, + 7.0, + 11.0, + 9.0 + ] + }, + "east": { + "rotation": 180, + "texture": "#1", + "uv": [ + 8.0, + 7.0, + 11.0, + 2.0 + ] + }, + "north": { + "texture": "#1", + "uv": [ + 12.0, + 2.0, + 13.0, + 7.0 + ] + }, + "south": { + "texture": "#1", + "uv": [ + 11.0, + 2.0, + 12.0, + 7.0 + ] + }, + "up": { + "rotation": 90, + "texture": "#1", + "uv": [ + 8.0, + 0.0, + 11.0, + 2.0 + ] + }, + "west": { + "texture": "#1", + "uv": [ + 8.0, + 2.0, + 11.0, + 7.0 + ] + } + }, + "from": [ + 11, + 8, + 1 + ], + "to": [ + 13, + 13, + 7 + ] + }, + { + "faces": { + "down": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 0.0 + ] + }, + "east": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 0.0, + 5.0 + ] + }, + "north": { + "forge_data": { + "block_light": 15 + }, + "texture": "#1", + "uv": [ + 1.5, + 3.0, + 2.5, + 8.0 + ] + }, + "south": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 5.0 + ] + }, + "up": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 0.0 + ] + }, + "west": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 0.0, + 5.0 + ] + } + }, + "from": [ + 11, + 8, + 1 + ], + "to": [ + 13, + 13, + 1 + ] + } + ], + "texture_size": [ + 32.0, + 16.0 + ], + "textures": { + "1": "overdrive_that_matters:block/batterybank_core" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery4.json b/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery4.json new file mode 100644 index 000000000..6e2a355e3 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery4.json @@ -0,0 +1,153 @@ +{ + "elements": [ + { + "faces": { + "down": { + "rotation": 270, + "texture": "#1", + "uv": [ + 8.0, + 7.0, + 11.0, + 9.0 + ] + }, + "east": { + "rotation": 180, + "texture": "#1", + "uv": [ + 8.0, + 7.0, + 11.0, + 2.0 + ] + }, + "north": { + "texture": "#1", + "uv": [ + 12.0, + 2.0, + 13.0, + 7.0 + ] + }, + "south": { + "texture": "#1", + "uv": [ + 11.0, + 2.0, + 12.0, + 7.0 + ] + }, + "up": { + "rotation": 90, + "texture": "#1", + "uv": [ + 8.0, + 0.0, + 11.0, + 2.0 + ] + }, + "west": { + "texture": "#1", + "uv": [ + 8.0, + 2.0, + 11.0, + 7.0 + ] + } + }, + "from": [ + 7, + 8, + 1 + ], + "to": [ + 9, + 13, + 7 + ] + }, + { + "faces": { + "down": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 0.0 + ] + }, + "east": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 0.0, + 5.0 + ] + }, + "north": { + "forge_data": { + "block_light": 15 + }, + "texture": "#1", + "uv": [ + 1.5, + 3.0, + 2.5, + 8.0 + ] + }, + "south": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 5.0 + ] + }, + "up": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 0.0 + ] + }, + "west": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 0.0, + 5.0 + ] + } + }, + "from": [ + 7, + 8, + 1 + ], + "to": [ + 9, + 13, + 1 + ] + } + ], + "texture_size": [ + 32.0, + 16.0 + ], + "textures": { + "1": "overdrive_that_matters:block/batterybank_core" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery5.json b/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery5.json new file mode 100644 index 000000000..55c80c12c --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery5.json @@ -0,0 +1,153 @@ +{ + "elements": [ + { + "faces": { + "down": { + "rotation": 270, + "texture": "#1", + "uv": [ + 8.0, + 7.0, + 11.0, + 9.0 + ] + }, + "east": { + "rotation": 180, + "texture": "#1", + "uv": [ + 8.0, + 7.0, + 11.0, + 2.0 + ] + }, + "north": { + "texture": "#1", + "uv": [ + 12.0, + 2.0, + 13.0, + 7.0 + ] + }, + "south": { + "texture": "#1", + "uv": [ + 11.0, + 2.0, + 12.0, + 7.0 + ] + }, + "up": { + "rotation": 90, + "texture": "#1", + "uv": [ + 8.0, + 0.0, + 11.0, + 2.0 + ] + }, + "west": { + "texture": "#1", + "uv": [ + 8.0, + 2.0, + 11.0, + 7.0 + ] + } + }, + "from": [ + 3, + 8, + 1 + ], + "to": [ + 5, + 13, + 7 + ] + }, + { + "faces": { + "down": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 0.0 + ] + }, + "east": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 0.0, + 5.0 + ] + }, + "north": { + "forge_data": { + "block_light": 15 + }, + "texture": "#1", + "uv": [ + 1.5, + 3.0, + 2.5, + 8.0 + ] + }, + "south": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 5.0 + ] + }, + "up": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 0.0 + ] + }, + "west": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 0.0, + 5.0 + ] + } + }, + "from": [ + 3, + 8, + 1 + ], + "to": [ + 5, + 13, + 1 + ] + } + ], + "texture_size": [ + 32.0, + 16.0 + ], + "textures": { + "1": "overdrive_that_matters:block/batterybank_core" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery6.json b/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery6.json index ca6135657..dbadc1c35 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery6.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery6.json @@ -26,7 +26,7 @@ "faces": { "north": {"uv": [0, 0, 1, 5], "texture": "#missing"}, "east": {"uv": [0, 0, 0, 5], "texture": "#missing"}, - "south": {"uv": [2, 3, 3, 8], "texture": "#1", "emissivity": 15}, + "south": {"uv": [2, 3, 3, 8], "texture": "#1", "forge_data": {"block_light": 15}}, "west": {"uv": [0, 0, 0, 5], "texture": "#missing"}, "up": {"uv": [0, 0, 1, 0], "texture": "#missing"}, "down": {"uv": [0, 0, 1, 0], "texture": "#missing"} diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery7.json b/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery7.json new file mode 100644 index 000000000..f39d18793 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery7.json @@ -0,0 +1,153 @@ +{ + "elements": [ + { + "faces": { + "down": { + "rotation": 90, + "texture": "#1", + "uv": [ + 8.0, + 7.0, + 11.0, + 9.0 + ] + }, + "east": { + "texture": "#1", + "uv": [ + 8.0, + 2.0, + 11.0, + 7.0 + ] + }, + "north": { + "texture": "#1", + "uv": [ + 11.0, + 2.0, + 12.0, + 7.0 + ] + }, + "south": { + "texture": "#1", + "uv": [ + 12.0, + 2.0, + 13.0, + 7.0 + ] + }, + "up": { + "rotation": 270, + "texture": "#1", + "uv": [ + 8.0, + 0.0, + 11.0, + 2.0 + ] + }, + "west": { + "rotation": 180, + "texture": "#1", + "uv": [ + 8.0, + 7.0, + 11.0, + 2.0 + ] + } + }, + "from": [ + 7, + 2, + 9 + ], + "to": [ + 9, + 7, + 15 + ] + }, + { + "faces": { + "down": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 0.0 + ] + }, + "east": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 0.0, + 5.0 + ] + }, + "north": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 5.0 + ] + }, + "south": { + "forge_data": { + "block_light": 15 + }, + "texture": "#1", + "uv": [ + 2.0, + 3.0, + 3.0, + 8.0 + ] + }, + "up": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 0.0 + ] + }, + "west": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 0.0, + 5.0 + ] + } + }, + "from": [ + 7, + 2, + 15 + ], + "to": [ + 9, + 7, + 15 + ] + } + ], + "texture_size": [ + 32.0, + 16.0 + ], + "textures": { + "1": "overdrive_that_matters:block/batterybank_core" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery8.json b/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery8.json new file mode 100644 index 000000000..44587c83e --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery8.json @@ -0,0 +1,153 @@ +{ + "elements": [ + { + "faces": { + "down": { + "rotation": 90, + "texture": "#1", + "uv": [ + 8.0, + 7.0, + 11.0, + 9.0 + ] + }, + "east": { + "texture": "#1", + "uv": [ + 8.0, + 2.0, + 11.0, + 7.0 + ] + }, + "north": { + "texture": "#1", + "uv": [ + 11.0, + 2.0, + 12.0, + 7.0 + ] + }, + "south": { + "texture": "#1", + "uv": [ + 12.0, + 2.0, + 13.0, + 7.0 + ] + }, + "up": { + "rotation": 270, + "texture": "#1", + "uv": [ + 8.0, + 0.0, + 11.0, + 2.0 + ] + }, + "west": { + "rotation": 180, + "texture": "#1", + "uv": [ + 8.0, + 7.0, + 11.0, + 2.0 + ] + } + }, + "from": [ + 11, + 2, + 9 + ], + "to": [ + 13, + 7, + 15 + ] + }, + { + "faces": { + "down": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 0.0 + ] + }, + "east": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 0.0, + 5.0 + ] + }, + "north": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 5.0 + ] + }, + "south": { + "forge_data": { + "block_light": 15 + }, + "texture": "#1", + "uv": [ + 2.0, + 3.0, + 3.0, + 8.0 + ] + }, + "up": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 0.0 + ] + }, + "west": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 0.0, + 5.0 + ] + } + }, + "from": [ + 11, + 2, + 15 + ], + "to": [ + 13, + 7, + 15 + ] + } + ], + "texture_size": [ + 32.0, + 16.0 + ], + "textures": { + "1": "overdrive_that_matters:block/batterybank_core" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery9.json b/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery9.json new file mode 100644 index 000000000..6749cd43a --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/battery/battery9.json @@ -0,0 +1,153 @@ +{ + "elements": [ + { + "faces": { + "down": { + "rotation": 90, + "texture": "#1", + "uv": [ + 8.0, + 7.0, + 11.0, + 9.0 + ] + }, + "east": { + "texture": "#1", + "uv": [ + 8.0, + 2.0, + 11.0, + 7.0 + ] + }, + "north": { + "texture": "#1", + "uv": [ + 11.0, + 2.0, + 12.0, + 7.0 + ] + }, + "south": { + "texture": "#1", + "uv": [ + 12.0, + 2.0, + 13.0, + 7.0 + ] + }, + "up": { + "rotation": 270, + "texture": "#1", + "uv": [ + 8.0, + 0.0, + 11.0, + 2.0 + ] + }, + "west": { + "rotation": 180, + "texture": "#1", + "uv": [ + 8.0, + 7.0, + 11.0, + 2.0 + ] + } + }, + "from": [ + 3, + 8, + 9 + ], + "to": [ + 5, + 13, + 15 + ] + }, + { + "faces": { + "down": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 0.0 + ] + }, + "east": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 0.0, + 5.0 + ] + }, + "north": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 5.0 + ] + }, + "south": { + "forge_data": { + "block_light": 15 + }, + "texture": "#1", + "uv": [ + 2.0, + 3.0, + 3.0, + 8.0 + ] + }, + "up": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 1.0, + 0.0 + ] + }, + "west": { + "texture": "#missing", + "uv": [ + 0.0, + 0.0, + 0.0, + 5.0 + ] + } + }, + "from": [ + 3, + 8, + 15 + ], + "to": [ + 5, + 13, + 15 + ] + } + ], + "texture_size": [ + 32.0, + 16.0 + ], + "textures": { + "1": "overdrive_that_matters:block/batterybank_core" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor0.json b/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor0.json new file mode 100644 index 000000000..623fc86f9 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor0.json @@ -0,0 +1,6 @@ +{ + "parent": "overdrive_that_matters:block/battery/battery0", + "textures": { + "1": "overdrive_that_matters:block/matterybank_core" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor1.json b/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor1.json new file mode 100644 index 000000000..ba7a0f00b --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor1.json @@ -0,0 +1,6 @@ +{ + "parent": "overdrive_that_matters:block/battery/battery1", + "textures": { + "1": "overdrive_that_matters:block/matterybank_core" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor10.json b/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor10.json new file mode 100644 index 000000000..e2d1aebbd --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor10.json @@ -0,0 +1,6 @@ +{ + "parent": "overdrive_that_matters:block/battery/battery10", + "textures": { + "1": "overdrive_that_matters:block/matterybank_core" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor11.json b/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor11.json new file mode 100644 index 000000000..3f585c50a --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor11.json @@ -0,0 +1,6 @@ +{ + "parent": "overdrive_that_matters:block/battery/battery11", + "textures": { + "1": "overdrive_that_matters:block/matterybank_core" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor2.json b/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor2.json new file mode 100644 index 000000000..aa5a377a4 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor2.json @@ -0,0 +1,6 @@ +{ + "parent": "overdrive_that_matters:block/battery/battery2", + "textures": { + "1": "overdrive_that_matters:block/matterybank_core" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor3.json b/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor3.json new file mode 100644 index 000000000..d56db1fe8 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor3.json @@ -0,0 +1,6 @@ +{ + "parent": "overdrive_that_matters:block/battery/battery3", + "textures": { + "1": "overdrive_that_matters:block/matterybank_core" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor4.json b/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor4.json new file mode 100644 index 000000000..102188f76 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor4.json @@ -0,0 +1,6 @@ +{ + "parent": "overdrive_that_matters:block/battery/battery4", + "textures": { + "1": "overdrive_that_matters:block/matterybank_core" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor5.json b/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor5.json new file mode 100644 index 000000000..ffcfb8898 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor5.json @@ -0,0 +1,6 @@ +{ + "parent": "overdrive_that_matters:block/battery/battery5", + "textures": { + "1": "overdrive_that_matters:block/matterybank_core" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor6.json b/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor6.json new file mode 100644 index 000000000..9e50b467a --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor6.json @@ -0,0 +1,6 @@ +{ + "parent": "overdrive_that_matters:block/battery/battery6", + "textures": { + "1": "overdrive_that_matters:block/matterybank_core" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor7.json b/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor7.json new file mode 100644 index 000000000..176468b41 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor7.json @@ -0,0 +1,6 @@ +{ + "parent": "overdrive_that_matters:block/battery/battery7", + "textures": { + "1": "overdrive_that_matters:block/matterybank_core" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor8.json b/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor8.json new file mode 100644 index 000000000..58e866b6b --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor8.json @@ -0,0 +1,6 @@ +{ + "parent": "overdrive_that_matters:block/battery/battery8", + "textures": { + "1": "overdrive_that_matters:block/matterybank_core" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor9.json b/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor9.json new file mode 100644 index 000000000..6819e719f --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/battery/matter_capacitor9.json @@ -0,0 +1,6 @@ +{ + "parent": "overdrive_that_matters:block/battery/battery9", + "textures": { + "1": "overdrive_that_matters:block/matterybank_core" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/pattern/model1.json b/src/main/resources/assets/overdrive_that_matters/models/block/pattern/model1.json new file mode 100644 index 000000000..bb1a26d99 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/pattern/model1.json @@ -0,0 +1,80 @@ +{ + "elements": [ + { + "faces": { + "down": { + "texture": "#texture", + "uv": [ + 1.0, + 14.0, + 15.0, + 15.0 + ] + }, + "east": { + "texture": "#texture", + "uv": [ + 15.0, + 1.0, + 1.0, + 15.0 + ] + }, + "north": { + "texture": "#texture", + "uv": [ + 1.0, + 1.0, + 2.0, + 15.0 + ] + }, + "south": { + "texture": "#texture", + "uv": [ + 14.0, + 1.0, + 15.0, + 15.0 + ] + }, + "up": { + "rotation": 90, + "texture": "#texture", + "uv": [ + 1.0, + 1.0, + 15.0, + 2.0 + ] + }, + "west": { + "texture": "#texture", + "uv": [ + 1.0, + 1.0, + 15.0, + 15.0 + ] + } + }, + "from": [ + 13, + 2, + 2 + ], + "to": [ + 13.3, + 14, + 14 + ] + } + ], + "texture_size": [ + 32.0, + 32.0 + ], + "textures": { + "texture": "overdrive_that_matters:item/pattern_drive_tier0" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/pattern/model2.json b/src/main/resources/assets/overdrive_that_matters/models/block/pattern/model2.json new file mode 100644 index 000000000..4be6cdcce --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/pattern/model2.json @@ -0,0 +1,80 @@ +{ + "elements": [ + { + "faces": { + "down": { + "texture": "#texture", + "uv": [ + 1.0, + 14.0, + 15.0, + 15.0 + ] + }, + "east": { + "texture": "#texture", + "uv": [ + 15.0, + 1.0, + 1.0, + 15.0 + ] + }, + "north": { + "texture": "#texture", + "uv": [ + 1.0, + 1.0, + 2.0, + 15.0 + ] + }, + "south": { + "texture": "#texture", + "uv": [ + 14.0, + 1.0, + 15.0, + 15.0 + ] + }, + "up": { + "rotation": 90, + "texture": "#texture", + "uv": [ + 1.0, + 1.0, + 15.0, + 2.0 + ] + }, + "west": { + "texture": "#texture", + "uv": [ + 1.0, + 1.0, + 15.0, + 15.0 + ] + } + }, + "from": [ + 11, + 2, + 2 + ], + "to": [ + 11.3, + 14, + 14 + ] + } + ], + "texture_size": [ + 32.0, + 32.0 + ], + "textures": { + "texture": "overdrive_that_matters:item/pattern_drive_tier0" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/pattern/model3.json b/src/main/resources/assets/overdrive_that_matters/models/block/pattern/model3.json new file mode 100644 index 000000000..3b85bbf4a --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/pattern/model3.json @@ -0,0 +1,80 @@ +{ + "elements": [ + { + "faces": { + "down": { + "texture": "#texture", + "uv": [ + 1.0, + 14.0, + 15.0, + 15.0 + ] + }, + "east": { + "texture": "#texture", + "uv": [ + 15.0, + 1.0, + 1.0, + 15.0 + ] + }, + "north": { + "texture": "#texture", + "uv": [ + 1.0, + 1.0, + 2.0, + 15.0 + ] + }, + "south": { + "texture": "#texture", + "uv": [ + 14.0, + 1.0, + 15.0, + 15.0 + ] + }, + "up": { + "rotation": 90, + "texture": "#texture", + "uv": [ + 1.0, + 1.0, + 15.0, + 2.0 + ] + }, + "west": { + "texture": "#texture", + "uv": [ + 1.0, + 1.0, + 15.0, + 15.0 + ] + } + }, + "from": [ + 9, + 2, + 2 + ], + "to": [ + 9.3, + 14, + 14 + ] + } + ], + "texture_size": [ + 32.0, + 32.0 + ], + "textures": { + "texture": "overdrive_that_matters:item/pattern_drive_tier0" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/pattern/model4.json b/src/main/resources/assets/overdrive_that_matters/models/block/pattern/model4.json new file mode 100644 index 000000000..eb86425dd --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/pattern/model4.json @@ -0,0 +1,80 @@ +{ + "elements": [ + { + "faces": { + "down": { + "texture": "#texture", + "uv": [ + 1.0, + 14.0, + 15.0, + 15.0 + ] + }, + "east": { + "texture": "#texture", + "uv": [ + 15.0, + 1.0, + 1.0, + 15.0 + ] + }, + "north": { + "texture": "#texture", + "uv": [ + 1.0, + 1.0, + 2.0, + 15.0 + ] + }, + "south": { + "texture": "#texture", + "uv": [ + 14.0, + 1.0, + 15.0, + 15.0 + ] + }, + "up": { + "rotation": 90, + "texture": "#texture", + "uv": [ + 1.0, + 1.0, + 15.0, + 2.0 + ] + }, + "west": { + "texture": "#texture", + "uv": [ + 1.0, + 1.0, + 15.0, + 15.0 + ] + } + }, + "from": [ + 7, + 2, + 2 + ], + "to": [ + 7.3, + 14, + 14 + ] + } + ], + "texture_size": [ + 32.0, + 32.0 + ], + "textures": { + "texture": "overdrive_that_matters:item/pattern_drive_tier0" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/pattern/model5.json b/src/main/resources/assets/overdrive_that_matters/models/block/pattern/model5.json new file mode 100644 index 000000000..585684cc6 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/pattern/model5.json @@ -0,0 +1,80 @@ +{ + "elements": [ + { + "faces": { + "down": { + "texture": "#texture", + "uv": [ + 1.0, + 14.0, + 15.0, + 15.0 + ] + }, + "east": { + "texture": "#texture", + "uv": [ + 15.0, + 1.0, + 1.0, + 15.0 + ] + }, + "north": { + "texture": "#texture", + "uv": [ + 1.0, + 1.0, + 2.0, + 15.0 + ] + }, + "south": { + "texture": "#texture", + "uv": [ + 14.0, + 1.0, + 15.0, + 15.0 + ] + }, + "up": { + "rotation": 90, + "texture": "#texture", + "uv": [ + 1.0, + 1.0, + 15.0, + 2.0 + ] + }, + "west": { + "texture": "#texture", + "uv": [ + 1.0, + 1.0, + 15.0, + 15.0 + ] + } + }, + "from": [ + 5, + 2, + 2 + ], + "to": [ + 5.3, + 14, + 14 + ] + } + ], + "texture_size": [ + 32.0, + 32.0 + ], + "textures": { + "texture": "overdrive_that_matters:item/pattern_drive_tier0" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/pattern/model6.json b/src/main/resources/assets/overdrive_that_matters/models/block/pattern/model6.json new file mode 100644 index 000000000..4f5a1ee88 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/pattern/model6.json @@ -0,0 +1,80 @@ +{ + "elements": [ + { + "faces": { + "down": { + "texture": "#texture", + "uv": [ + 1.0, + 14.0, + 15.0, + 15.0 + ] + }, + "east": { + "texture": "#texture", + "uv": [ + 15.0, + 1.0, + 1.0, + 15.0 + ] + }, + "north": { + "texture": "#texture", + "uv": [ + 1.0, + 1.0, + 2.0, + 15.0 + ] + }, + "south": { + "texture": "#texture", + "uv": [ + 14.0, + 1.0, + 15.0, + 15.0 + ] + }, + "up": { + "rotation": 90, + "texture": "#texture", + "uv": [ + 1.0, + 1.0, + 15.0, + 2.0 + ] + }, + "west": { + "texture": "#texture", + "uv": [ + 1.0, + 1.0, + 15.0, + 15.0 + ] + } + }, + "from": [ + 3, + 2, + 2 + ], + "to": [ + 3.3000002, + 14, + 14 + ] + } + ], + "texture_size": [ + 32.0, + 32.0 + ], + "textures": { + "texture": "overdrive_that_matters:item/pattern_drive_tier0" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/pattern/model7.json b/src/main/resources/assets/overdrive_that_matters/models/block/pattern/model7.json new file mode 100644 index 000000000..fea7a32c6 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/pattern/model7.json @@ -0,0 +1,80 @@ +{ + "elements": [ + { + "faces": { + "down": { + "texture": "#texture", + "uv": [ + 1.0, + 14.0, + 15.0, + 15.0 + ] + }, + "east": { + "texture": "#texture", + "uv": [ + 15.0, + 1.0, + 1.0, + 15.0 + ] + }, + "north": { + "texture": "#texture", + "uv": [ + 1.0, + 1.0, + 2.0, + 15.0 + ] + }, + "south": { + "texture": "#texture", + "uv": [ + 14.0, + 1.0, + 15.0, + 15.0 + ] + }, + "up": { + "rotation": 90, + "texture": "#texture", + "uv": [ + 1.0, + 1.0, + 15.0, + 2.0 + ] + }, + "west": { + "texture": "#texture", + "uv": [ + 1.0, + 1.0, + 15.0, + 15.0 + ] + } + }, + "from": [ + 1, + 2, + 2 + ], + "to": [ + 1.3000002, + 14, + 14 + ] + } + ], + "texture_size": [ + 32.0, + 32.0 + ], + "textures": { + "texture": "overdrive_that_matters:item/pattern_drive_tier0" + } +} \ No newline at end of file From 903cb30c8eb210d0d0552beb7fb90cffc9ed5d67 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 28 Jan 2023 18:29:07 +0700 Subject: [PATCH 0126/1199] Exiark - Let There Be Light (feat. Chi-Chi) --- .../models/block/holo_sign.json | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/holo_sign.json b/src/main/resources/assets/overdrive_that_matters/models/block/holo_sign.json index 050affd54..8af9b0feb 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/holo_sign.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/holo_sign.json @@ -76,8 +76,8 @@ "from": [1, 14, 10], "to": [2, 15, 10], "faces": { - "north": {"uv": [2, 12.5, 2.5, 13], "texture": "#0", "emissivity": 15}, - "east": {"uv": [0, 0, 0, 0.5], "texture": "#0", "emissivity": 15}, + "north": {"uv": [2, 12.5, 2.5, 13], "texture": "#0", "forge_data": {"block_light": 15}}, + "east": {"uv": [0, 0, 0, 0.5], "texture": "#0", "forge_data": {"block_light": 15}}, "south": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"}, "west": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, "up": {"uv": [0, 0, 0.5, 0], "texture": "#missing"}, @@ -89,8 +89,8 @@ "from": [1, 1, 10], "to": [2, 2, 10], "faces": { - "north": {"uv": [2, 12.5, 2.5, 13], "texture": "#0", "emissivity": 15}, - "east": {"uv": [0, 0, 0, 0.5], "texture": "#0", "emissivity": 15}, + "north": {"uv": [2, 12.5, 2.5, 13], "texture": "#0", "forge_data": {"block_light": 15}}, + "east": {"uv": [0, 0, 0, 0.5], "texture": "#0", "forge_data": {"block_light": 15}}, "south": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"}, "west": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, "up": {"uv": [0, 0, 0.5, 0], "texture": "#missing"}, @@ -102,8 +102,8 @@ "from": [14, 1, 10], "to": [15, 2, 10], "faces": { - "north": {"uv": [2, 12.5, 2.5, 13], "texture": "#0", "emissivity": 15}, - "east": {"uv": [0, 0, 0, 0.5], "texture": "#0", "emissivity": 15}, + "north": {"uv": [2, 12.5, 2.5, 13], "texture": "#0", "forge_data": {"block_light": 15}}, + "east": {"uv": [0, 0, 0, 0.5], "texture": "#0", "forge_data": {"block_light": 15}}, "south": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"}, "west": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, "up": {"uv": [0, 0, 0.5, 0], "texture": "#missing"}, @@ -115,8 +115,8 @@ "from": [14, 14, 10], "to": [15, 15, 10], "faces": { - "north": {"uv": [2, 12.5, 2.5, 13], "texture": "#0", "emissivity": 15}, - "east": {"uv": [0, 0, 0, 0.5], "texture": "#0", "emissivity": 15}, + "north": {"uv": [2, 12.5, 2.5, 13], "texture": "#0", "forge_data": {"block_light": 15}}, + "east": {"uv": [0, 0, 0, 0.5], "texture": "#0", "forge_data": {"block_light": 15}}, "south": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"}, "west": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, "up": {"uv": [0, 0, 0.5, 0], "texture": "#missing"}, @@ -131,7 +131,7 @@ "north": {"uv": [0, 0, 0, 2], "texture": "#missing"}, "east": {"uv": [0, 0, 0.5, 2], "texture": "#missing"}, "south": {"uv": [0, 0, 0, 2], "texture": "#missing"}, - "west": {"uv": [2, 13, 2.5, 15], "texture": "#0", "emissivity": 15}, + "west": {"uv": [2, 13, 2.5, 15], "texture": "#0", "forge_data": {"block_light": 15}}, "up": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, "down": {"uv": [0, 0, 0, 0.5], "texture": "#missing"} } @@ -142,9 +142,9 @@ "to": [2, 10, 10], "faces": { "north": {"uv": [0, 0, 0, 2], "texture": "#missing"}, - "east": {"uv": [2, 13, 2.5, 15], "texture": "#0", "emissivity": 15}, + "east": {"uv": [2, 13, 2.5, 15], "texture": "#0", "forge_data": {"block_light": 15}}, "south": {"uv": [0, 0, 0, 2], "texture": "#missing"}, - "west": {"uv": [2, 13, 2.5, 15], "texture": "#0", "emissivity": 15}, + "west": {"uv": [2, 13, 2.5, 15], "texture": "#0", "forge_data": {"block_light": 15}}, "up": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, "down": {"uv": [0, 0, 0, 0.5], "texture": "#missing"} } From cb433871be04f117b5b08705c49f727a96464f8b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 28 Jan 2023 18:48:53 +0700 Subject: [PATCH 0127/1199] Holo sign shape --- .../dbotthepony/mc/otm/shapes/BlockShapes.java | 14 ++++++++++++++ .../mc/otm/block/decorative/HoloSignBlock.kt | 18 ++++++++++++++++++ .../render/blockentity/HoloSignRenderer.kt | 2 +- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java index c260aba9c..6809d213d 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java +++ b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java @@ -601,4 +601,18 @@ public class BlockShapes { new SimpleCuboid(0.4375d, 0.8125d, 1d, 0.5625d, 0.9375d, 1d), new SimpleCuboid(0.4375d, 0.8125d, 0d, 0.5625d, 0.9375d, 0d) ); + + public static final BlockShape HOLO_SIGN = new BlockShape( + new SimpleCuboid(0d, 0d, 0.875d, 1d, 1d, 1d), + new SimpleCuboid(0.0625d, 0.0625d, 0.8125d, 0.9375d, 0.9375d, 0.875d), + new SimpleCuboid(0d, 0d, 0.625d, 1d, 1d, 0.8125d), + new SimpleCuboid(0.875d, 0.3125d, 0.5625d, 1d, 0.6875d, 0.625d), + new SimpleCuboid(0d, 0.3125d, 0.5625d, 0.125d, 0.6875d, 0.625d), + new SimpleCuboid(0.0625d, 0.875d, 0.625d, 0.125d, 0.9375d, 0.625d), + new SimpleCuboid(0.0625d, 0.0625d, 0.625d, 0.125d, 0.125d, 0.625d), + new SimpleCuboid(0.875d, 0.0625d, 0.625d, 0.9375d, 0.125d, 0.625d), + new SimpleCuboid(0.875d, 0.875d, 0.625d, 0.9375d, 0.9375d, 0.625d), + new SimpleCuboid(0.875d, 0.375d, 0.5625d, 0.875d, 0.625d, 0.625d), + new SimpleCuboid(0.125d, 0.375d, 0.5625d, 0.125d, 0.625d, 0.625d) + ); } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt index f49adacbd..608461e44 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt @@ -1,11 +1,16 @@ package ru.dbotthepony.mc.otm.block.decorative import net.minecraft.core.BlockPos +import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.block.EntityBlock import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.phys.shapes.CollisionContext +import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity +import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.shapes.BlockShapes class HoloSignBlock : RotatableMatteryBlock(), EntityBlock { override val hasFreeRotation: Boolean @@ -14,4 +19,17 @@ class HoloSignBlock : RotatableMatteryBlock(), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return HoloSignBlockEntity(p_153215_, p_153216_) } + + private val shapes = getShapeForEachState { + BlockShapes.HOLO_SIGN.rotateInv(it[FACING_FULL]).computeShape() + } + + override fun getShape( + pState: BlockState, + pLevel: BlockGetter, + pPos: BlockPos, + pContext: CollisionContext + ): VoxelShape { + return shapes[pState]!! + } } 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 59ede0d1a..7a99d84e6 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 @@ -26,7 +26,7 @@ class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context) ) { poseStack.pushPose() poseStack.rotateWithBlockFacing(tile.blockState[RotatableMatteryBlock.FACING_FULL]) - poseStack.translate(0.5f, 0.5f, -0.05f) + poseStack.translate(0.5f, 0.5f, 0.6f) poseStack.scale(0.01f, 0.01f, 0.01f) val sorse = DynamicBufferSource.WORLD From 6c4d8d492b08bb51ab11244f148a66415861a60e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 28 Jan 2023 23:48:01 +0700 Subject: [PATCH 0128/1199] Make IMutableField implement GetterSetter --- .../kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt index f2972666d..99282374e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt @@ -89,7 +89,7 @@ sealed interface IField : ReadOnlyProperty, Supplier, () -> V { } } -sealed interface IMutableField : IField, ReadWriteProperty, Consumer { +sealed interface IMutableField : IField, ReadWriteProperty, GetterSetter { override var value: V override fun setValue(thisRef: Any, property: KProperty<*>, value: V) { From fdad25cb17a76b8d4589c7ea0fa84bdb6cf11171 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 28 Jan 2023 23:57:08 +0700 Subject: [PATCH 0129/1199] AbstractNetworkedInput.with accepts GetterSetter --- .../mc/otm/menu/input/AbstractNetworkedInput.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt index 3892885b1..377828510 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.menu.input import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.menu.MatteryMenu import kotlin.reflect.KMutableProperty0 @@ -27,6 +28,12 @@ abstract class AbstractNetworkedInput { return this } + fun with(state: GetterSetter): AbstractNetworkedInput { + withConsumer(state::accept) + withSupplier(state::get) + return this + } + fun clear(): AbstractNetworkedInput { supplier = null consumer = null From 4c78e4e6c61b326f1e1b669c577c66c12bcf8974 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 29 Jan 2023 00:02:41 +0700 Subject: [PATCH 0130/1199] Trick JVM into not validating hierarchy tree --- .../otm/menu/input/AbstractNetworkedInput.kt | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt index 377828510..6ad53fa17 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt @@ -1,14 +1,26 @@ package ru.dbotthepony.mc.otm.menu.input +import net.minecraft.world.entity.player.Player import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.menu.MatteryMenu import kotlin.reflect.KMutableProperty0 -abstract class AbstractNetworkedInput { +/** + * Getting and setting values should ONLY be done clientside + */ +abstract class AbstractNetworkedInput : GetterSetter { abstract val input: MatteryMenu.PlayerInput abstract val value: V + override fun get(): V { + return value + } + + override fun accept(t: V) { + input.checkedInput(t, minecraft.player as Player?) + } + var supplier: (() -> V)? = null var consumer: ((V) -> Unit)? = null @@ -44,13 +56,13 @@ abstract class AbstractNetworkedInput { * shortcut to checked input of [input] */ fun input(newValue: V) { - input.checkedInput(newValue, minecraft.player) + input.checkedInput(newValue, minecraft.player as Player?) } /** * checks if local (client) player can modify this input */ fun check(): Boolean { - return input.allowSpectators || minecraft.player?.isSpectator == false + return input.allowSpectators || (minecraft.player as Player?)?.isSpectator == false } } From d49ec98d71d5894ff3d8a3906feca9c192e2910e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 29 Jan 2023 00:12:32 +0700 Subject: [PATCH 0131/1199] Implement ReadWriteProperty in GetterSetter --- .../ru/dbotthepony/mc/otm/core/GetterSetter.kt | 17 ++++++++--------- .../mc/otm/network/FieldSynchronizer.kt | 18 +++++++----------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt index 10de8c854..9c7953444 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.core import java.util.function.Consumer import java.util.function.Supplier +import kotlin.properties.ReadWriteProperty import kotlin.reflect.KMutableProperty0 import kotlin.reflect.KProperty @@ -9,17 +10,15 @@ inline var GetterSetter.value: V get() = get() set(value) { accept(value) } -@Suppress("nothing_to_inline") -inline operator fun GetterSetter.getValue(thisRef: Any, property: KProperty<*>): V { - return get() -} +interface GetterSetter : Supplier, Consumer, ReadWriteProperty { + override fun setValue(thisRef: Any?, property: KProperty<*>, value: V) { + accept(value) + } -@Suppress("nothing_to_inline") -inline operator fun GetterSetter.setValue(thisRef: Any, property: KProperty<*>, value: V) { - accept(value) -} + override fun getValue(thisRef: Any?, property: KProperty<*>): V { + return get() + } -interface GetterSetter : Supplier, Consumer { companion object { fun of(getter: Supplier, setter: Consumer): GetterSetter { return object : GetterSetter { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt index 99282374e..d8ab2bca4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt @@ -62,7 +62,7 @@ fun interface FieldSetter { fun invoke(value: V, access: FieldAccess, setByRemote: Boolean) } -sealed interface IField : ReadOnlyProperty, Supplier, () -> V { +sealed interface IField : ReadOnlyProperty, Supplier, () -> V { fun observe(): Boolean fun markDirty() fun markDirty(endpoint: FieldSynchronizer.Endpoint) @@ -76,7 +76,7 @@ sealed interface IField : ReadOnlyProperty, Supplier, () -> V { fun read(stream: DataInputStream) - override fun getValue(thisRef: Any, property: KProperty<*>): V { + override fun getValue(thisRef: Any?, property: KProperty<*>): V { return this.value } @@ -89,20 +89,16 @@ sealed interface IField : ReadOnlyProperty, Supplier, () -> V { } } -sealed interface IMutableField : IField, ReadWriteProperty, GetterSetter { - override var value: V - - override fun setValue(thisRef: Any, property: KProperty<*>, value: V) { - this.value = value +sealed interface IMutableField : IField, GetterSetter { + override fun getValue(thisRef: Any?, property: KProperty<*>): V { + return this.value } + override var value: V + override fun accept(t: V) { value = t } - - override fun getValue(thisRef: Any, property: KProperty<*>): V { - return super.getValue(thisRef, property) - } } data class MapChangeset( From e505bce76dee8d37d4cae52c82332aef558c27b2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 29 Jan 2023 14:23:17 +0700 Subject: [PATCH 0132/1199] Give player input classes better names --- .../screen/panels/button/CheckBoxInputPanel.kt | 4 ++-- .../screen/panels/button/CheckBoxLabelInputPanel.kt | 4 ++-- .../screen/panels/input/NetworkedStringInputPanel.kt | 4 ++-- .../mc/otm/menu/decorative/HoloSignMenu.kt | 7 +++---- ...edInput.kt => AbstractPlayerInputWithFeedback.kt} | 12 ++++++------ ...edBooleanInput.kt => BooleanInputWithFeedback.kt} | 8 ++++++-- ...rkedStringInput.kt => StringInputWithFeedback.kt} | 7 ++++++- .../mc/otm/menu/matter/MatterBottlerMenu.kt | 8 ++++---- .../mc/otm/menu/storage/DriveViewerMenu.kt | 8 ++++---- .../mc/otm/menu/storage/StorageBusMenu.kt | 8 ++++---- .../mc/otm/menu/storage/StorageExporterMenu.kt | 8 ++++---- .../mc/otm/menu/storage/StorageImporterMenu.kt | 8 ++++---- 12 files changed, 47 insertions(+), 39 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/{AbstractNetworkedInput.kt => AbstractPlayerInputWithFeedback.kt} (74%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/{NetworkedBooleanInput.kt => BooleanInputWithFeedback.kt} (64%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/{NetworkedStringInput.kt => StringInputWithFeedback.kt} (63%) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxInputPanel.kt index ff36cd941..60a8acc37 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxInputPanel.kt @@ -3,12 +3,12 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel -import ru.dbotthepony.mc.otm.menu.input.NetworkedBooleanInput +import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback open class CheckBoxInputPanel @JvmOverloads constructor( screen: S, parent: EditablePanel<*>?, - val widget: NetworkedBooleanInput, + val widget: BooleanInputWithFeedback, x: Float = 0f, y: Float = 0f, width: Float = REGULAR_DIMENSIONS + 120f, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelInputPanel.kt index 578354830..1fc7b8709 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelInputPanel.kt @@ -4,12 +4,12 @@ import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.Label -import ru.dbotthepony.mc.otm.menu.input.NetworkedBooleanInput +import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback open class CheckBoxLabelInputPanel @JvmOverloads constructor( screen: S, parent: EditablePanel<*>?, - widget: NetworkedBooleanInput, + widget: BooleanInputWithFeedback, text: Component, x: Float = 0f, y: Float = 0f, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt index 5c548a493..960f69ae2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt @@ -2,13 +2,13 @@ package ru.dbotthepony.mc.otm.client.screen.panels.input import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel -import ru.dbotthepony.mc.otm.menu.input.AbstractNetworkedInput +import ru.dbotthepony.mc.otm.menu.input.AbstractPlayerInputWithFeedback import ru.dbotthepony.mc.otm.milliTime open class NetworkedStringInputPanel( screen: S, parent: EditablePanel<*>?, - val backend: AbstractNetworkedInput, + val backend: AbstractPlayerInputWithFeedback, x: Float = 0f, y: Float = 0f, width: Float = 60f, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt index ef06105ad..b09a3e120 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt @@ -3,9 +3,8 @@ package ru.dbotthepony.mc.otm.menu.decorative import net.minecraft.world.entity.player.Inventory import net.minecraft.world.inventory.Slot import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity -import ru.dbotthepony.mc.otm.client.screen.panels.input.TextInputPanel import ru.dbotthepony.mc.otm.menu.MatteryMenu -import ru.dbotthepony.mc.otm.menu.input.NetworkedStringInput +import ru.dbotthepony.mc.otm.menu.input.StringInputWithFeedback import ru.dbotthepony.mc.otm.registry.MMenus class HoloSignMenu @JvmOverloads constructor( @@ -14,7 +13,7 @@ class HoloSignMenu @JvmOverloads constructor( tile: HoloSignBlockEntity? = null ) : MatteryMenu(MMenus.HOLO_SIGN, containerId, inventory, tile) { val text = if (tile != null) - NetworkedStringInput(this).withConsumer { + StringInputWithFeedback(this).withConsumer { val lines = it.split(NEWLINES) val result = ArrayList(lines.size.coerceAtMost(HoloSignBlockEntity.DEFAULT_MAX_NEWLINES)) @@ -29,7 +28,7 @@ class HoloSignMenu @JvmOverloads constructor( tile.text = result.joinToString("\n") }.withSupplier(tile::text) else - NetworkedStringInput(this) + StringInputWithFeedback(this) override val storageSlots: Collection get() = listOf() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt similarity index 74% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt index 6ad53fa17..bf3704012 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractNetworkedInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt @@ -9,7 +9,7 @@ import kotlin.reflect.KMutableProperty0 /** * Getting and setting values should ONLY be done clientside */ -abstract class AbstractNetworkedInput : GetterSetter { +abstract class AbstractPlayerInputWithFeedback : GetterSetter { abstract val input: MatteryMenu.PlayerInput abstract val value: V @@ -24,29 +24,29 @@ abstract class AbstractNetworkedInput : GetterSetter { var supplier: (() -> V)? = null var consumer: ((V) -> Unit)? = null - fun withSupplier(func: () -> V): AbstractNetworkedInput { + fun withSupplier(func: () -> V): AbstractPlayerInputWithFeedback { supplier = func return this } - fun withConsumer(func: (V) -> Unit): AbstractNetworkedInput { + fun withConsumer(func: (V) -> Unit): AbstractPlayerInputWithFeedback { consumer = func return this } - fun with(state: KMutableProperty0): AbstractNetworkedInput { + fun with(state: KMutableProperty0): AbstractPlayerInputWithFeedback { withConsumer { state.set(it) } withSupplier { state.get() } return this } - fun with(state: GetterSetter): AbstractNetworkedInput { + fun with(state: GetterSetter): AbstractPlayerInputWithFeedback { withConsumer(state::accept) withSupplier(state::get) return this } - fun clear(): AbstractNetworkedInput { + fun clear(): AbstractPlayerInputWithFeedback { supplier = null consumer = null return this diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/NetworkedBooleanInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/BooleanInputWithFeedback.kt similarity index 64% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/NetworkedBooleanInput.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/BooleanInputWithFeedback.kt index 57a26fa77..65bf20706 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/NetworkedBooleanInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/BooleanInputWithFeedback.kt @@ -1,10 +1,10 @@ package ru.dbotthepony.mc.otm.menu.input -import net.minecraft.world.entity.player.Player +import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.menu.MatteryMenu import kotlin.reflect.KMutableProperty0 -class NetworkedBooleanInput(menu: MatteryMenu) : AbstractNetworkedInput() { +class BooleanInputWithFeedback(menu: MatteryMenu) : AbstractPlayerInputWithFeedback() { override val input = menu.booleanInput { consumer?.invoke(it) } override val value by menu.mSynchronizer.bool(getter = { supplier?.invoke() ?: false }) @@ -12,6 +12,10 @@ class NetworkedBooleanInput(menu: MatteryMenu) : AbstractNetworkedInput with(state) } + constructor(menu: MatteryMenu, state: GetterSetter) : this(menu) { + with(state) + } + fun switchValue() { input(!value) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/NetworkedStringInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/StringInputWithFeedback.kt similarity index 63% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/NetworkedStringInput.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/StringInputWithFeedback.kt index de365c103..891ba3021 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/NetworkedStringInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/StringInputWithFeedback.kt @@ -1,13 +1,18 @@ package ru.dbotthepony.mc.otm.menu.input +import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.menu.MatteryMenu import kotlin.reflect.KMutableProperty0 -class NetworkedStringInput(menu: MatteryMenu) : AbstractNetworkedInput() { +class StringInputWithFeedback(menu: MatteryMenu) : AbstractPlayerInputWithFeedback() { override val input = menu.stringInput { consumer?.invoke(it.replace('\u0000', ' ')) } override val value by menu.mSynchronizer.string(getter = { supplier?.invoke() ?: "" }) constructor(menu: MatteryMenu, state: KMutableProperty0) : this(menu) { with(state) } + + constructor(menu: MatteryMenu, state: GetterSetter) : this(menu) { + with(state) + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt index bfcc044d2..f1b061dfb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt @@ -8,7 +8,7 @@ import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.matter.canExtractMatter import ru.dbotthepony.mc.otm.capability.matter.canReceiveMatter -import ru.dbotthepony.mc.otm.menu.input.NetworkedBooleanInput +import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.core.orNull @@ -23,7 +23,7 @@ class MatterBottlerMenu @JvmOverloads constructor( ) : MatteryPoweredMenu( MMenus.MATTER_BOTTLER, p_38852_, inventory, tile ) { - val workFlow: NetworkedBooleanInput + val workFlow: BooleanInputWithFeedback val progressWidget: ProgressGaugeWidget val matterWidget: LevelGaugeWidget @@ -36,11 +36,11 @@ class MatterBottlerMenu @JvmOverloads constructor( if (tile == null) { progressWidget = ProgressGaugeWidget(this) matterWidget = LevelGaugeWidget(this) - workFlow = NetworkedBooleanInput(this) + workFlow = BooleanInputWithFeedback(this) } else { progressWidget = ProgressGaugeWidget(this) { tile.getWorkProgress() } matterWidget = LevelGaugeWidget(this, tile.matter) - workFlow = NetworkedBooleanInput(this, tile::isBottling) + workFlow = BooleanInputWithFeedback(this, tile::isBottling) } storageSlots = ImmutableList(6) { index -> diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt index f30c08c7b..cc0502f73 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt @@ -17,7 +17,7 @@ import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.data.INetworkedItemViewProvider import ru.dbotthepony.mc.otm.menu.data.NetworkedItemView -import ru.dbotthepony.mc.otm.menu.input.NetworkedBooleanInput +import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback import ru.dbotthepony.mc.otm.registry.MMenus import ru.dbotthepony.mc.otm.storage.ITEM_STORAGE import ru.dbotthepony.mc.otm.storage.ItemStackWrapper @@ -70,9 +70,9 @@ class DriveViewerMenu @JvmOverloads constructor( val driveFilterSlots = addFilterSlots(driveFilter) - val isWhitelist = NetworkedBooleanInput(this) - val matchTag = NetworkedBooleanInput(this) - val matchNBT = NetworkedBooleanInput(this) + val isWhitelist = BooleanInputWithFeedback(this) + val matchTag = BooleanInputWithFeedback(this) + val matchNBT = BooleanInputWithFeedback(this) override fun broadcastChanges() { super.broadcastChanges() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageBusMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageBusMenu.kt index 8cfa1a5f3..e29d7526e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageBusMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageBusMenu.kt @@ -5,7 +5,7 @@ import net.minecraft.world.inventory.Slot import ru.dbotthepony.mc.otm.block.entity.storage.StorageBusBlockEntity import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu -import ru.dbotthepony.mc.otm.menu.input.NetworkedBooleanInput +import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback import ru.dbotthepony.mc.otm.registry.MMenus class StorageBusMenu @JvmOverloads constructor( @@ -16,15 +16,15 @@ class StorageBusMenu @JvmOverloads constructor( MMenus.STORAGE_BUS, p_38852_, inventory, tile ) { val busFilterSlots: List - val busFilterState: NetworkedBooleanInput + val busFilterState: BooleanInputWithFeedback init { if (tile != null) { busFilterSlots = addFilterSlots(tile.filter) - busFilterState = NetworkedBooleanInput(this, tile.filter::isWhitelist) + busFilterState = BooleanInputWithFeedback(this, tile.filter::isWhitelist) } else { busFilterSlots = addFilterSlots(StorageBusBlockEntity.MAX_FILTERS) - busFilterState = NetworkedBooleanInput(this) + busFilterState = BooleanInputWithFeedback(this) } addInventorySlots() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageExporterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageExporterMenu.kt index 840ee3fd4..391633a96 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageExporterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageExporterMenu.kt @@ -5,7 +5,7 @@ import net.minecraft.world.inventory.Slot import ru.dbotthepony.mc.otm.block.entity.storage.StorageExporterBlockEntity import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu -import ru.dbotthepony.mc.otm.menu.input.NetworkedBooleanInput +import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback import ru.dbotthepony.mc.otm.registry.MMenus class StorageExporterMenu @JvmOverloads constructor( @@ -16,15 +16,15 @@ class StorageExporterMenu @JvmOverloads constructor( MMenus.STORAGE_EXPORTER, p_38852_, inventory, tile ) { val busFilterSlots: List - val busFilterState: NetworkedBooleanInput + val busFilterState: BooleanInputWithFeedback init { if (tile != null) { busFilterSlots = addFilterSlots(tile.filter) - busFilterState = NetworkedBooleanInput(this, tile.filter::isWhitelist) + busFilterState = BooleanInputWithFeedback(this, tile.filter::isWhitelist) } else { busFilterSlots = addFilterSlots(StorageExporterBlockEntity.MAX_FILTERS) - busFilterState = NetworkedBooleanInput(this) + busFilterState = BooleanInputWithFeedback(this) } addInventorySlots() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageImporterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageImporterMenu.kt index bc41f66ac..e568a0a8f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageImporterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageImporterMenu.kt @@ -5,7 +5,7 @@ import net.minecraft.world.inventory.Slot import ru.dbotthepony.mc.otm.block.entity.storage.StorageImporterBlockEntity import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu -import ru.dbotthepony.mc.otm.menu.input.NetworkedBooleanInput +import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback import ru.dbotthepony.mc.otm.registry.MMenus class StorageImporterMenu @JvmOverloads constructor( @@ -16,15 +16,15 @@ class StorageImporterMenu @JvmOverloads constructor( MMenus.STORAGE_IMPORTER, p_38852_, inventory, tile ) { val busFilterSlots: List - val busFilterState: NetworkedBooleanInput + val busFilterState: BooleanInputWithFeedback init { if (tile != null) { busFilterSlots = addFilterSlots(tile.filter) - busFilterState = NetworkedBooleanInput(this, tile.filter::isWhitelist) + busFilterState = BooleanInputWithFeedback(this, tile.filter::isWhitelist) } else { busFilterSlots = addFilterSlots(StorageImporterBlockEntity.MAX_FILTERS) - busFilterState = NetworkedBooleanInput(this) + busFilterState = BooleanInputWithFeedback(this) } addInventorySlots() From 19d8eca2e5ddff1284b50777cbc7f7e5147f2965 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 29 Jan 2023 20:02:40 +0700 Subject: [PATCH 0133/1199] Holo sign lock, more streamlined player input API --- .../entity/decorative/HoloSignBlockEntity.kt | 27 ++++++++++++- .../screen/decorative/HoloSignScreen.kt | 5 +++ .../panels/button/CheckBoxInputPanel.kt | 9 +++-- .../panels/button/CheckBoxLabelInputPanel.kt | 13 ++----- .../panels/input/NetworkedStringInputPanel.kt | 7 ++-- .../dbotthepony/mc/otm/core/GetterSetter.kt | 8 ++++ .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 21 +++++++++- .../mc/otm/menu/decorative/HoloSignMenu.kt | 29 +++++--------- .../input/AbstractPlayerInputWithFeedback.kt | 38 ++++++++++--------- .../menu/input/BooleanInputWithFeedback.kt | 2 +- .../mc/otm/network/FieldSynchronizer.kt | 4 ++ 11 files changed, 106 insertions(+), 57 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt index f79bc621c..07417c75c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt @@ -20,6 +20,8 @@ class HoloSignBlockEntity(blockPos: BlockPos, blockState: BlockState) : Synchron access.write(value) }) + var locked = false + override fun createMenu(p_39954_: Int, p_39955_: Inventory, p_39956_: Player): AbstractContainerMenu { return HoloSignMenu(p_39954_, p_39955_, this) } @@ -35,12 +37,35 @@ class HoloSignBlockEntity(blockPos: BlockPos, blockState: BlockState) : Synchron override fun load(p_155245_: CompoundTag) { super.load(p_155245_) - text = p_155245_.getString(TEXT_KEY) + locked = p_155245_.getBoolean(LOCKED_KEY) + + if (locked) { + text = p_155245_.getString(TEXT_KEY) + } else { + text = truncate(p_155245_.getString(TEXT_KEY)) + } } companion object { const val TEXT_KEY = "SignText" + const val LOCKED_KEY = "Locked" const val DEFAULT_MAX_NEWLINES = 8 const val DEFAULT_MAX_LINE_LENGTH = 15 + private val NEWLINES = Regex("\r?\n") + + fun truncate(input: String): String { + val lines = input.split(NEWLINES) + val result = ArrayList(lines.size.coerceAtMost(DEFAULT_MAX_NEWLINES)) + + for (i in 0 until lines.size.coerceAtMost(DEFAULT_MAX_NEWLINES)) { + if (lines[i].length > DEFAULT_MAX_LINE_LENGTH) { + result.add(lines[i].substring(0, DEFAULT_MAX_LINE_LENGTH)) + } else { + result.add(lines[i]) + } + } + + return result.joinToString("\n") + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt index 756c0e578..f182df1d4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt @@ -5,7 +5,9 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.CheckBoxLabelInputPanel import ru.dbotthepony.mc.otm.client.screen.panels.input.NetworkedStringInputPanel +import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.menu.decorative.HoloSignMenu class HoloSignScreen(menu: HoloSignMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, title) { @@ -16,6 +18,9 @@ class HoloSignScreen(menu: HoloSignMenu, inventory: Inventory, title: Component) input.dock = Dock.FILL input.multiLine = true + val lock = CheckBoxLabelInputPanel(this, frame, menu.locked, TranslatableComponent("otm.gui.lock_holo_screen")) + lock.dock = Dock.BOTTOM + return frame } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxInputPanel.kt index 60a8acc37..bc96b8d98 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxInputPanel.kt @@ -3,12 +3,13 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel -import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback +import ru.dbotthepony.mc.otm.core.value +import ru.dbotthepony.mc.otm.menu.input.IPlayerInputWithFeedback open class CheckBoxInputPanel @JvmOverloads constructor( screen: S, parent: EditablePanel<*>?, - val widget: BooleanInputWithFeedback, + val widget: IPlayerInputWithFeedback, x: Float = 0f, y: Float = 0f, width: Float = REGULAR_DIMENSIONS + 120f, @@ -19,10 +20,10 @@ open class CheckBoxInputPanel @JvmOverloads constructor( set(value) {} override var isDisabled: Boolean - get() = widget.input.allowSpectators || minecraft.player?.isSpectator == true + get() = !widget.test(minecraft.player) set(value) {} override fun onClick() { - widget.input(!checked) + widget.accept(!checked) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelInputPanel.kt index 1fc7b8709..3b4a5e241 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelInputPanel.kt @@ -5,11 +5,12 @@ import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.Label import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.IPlayerInputWithFeedback open class CheckBoxLabelInputPanel @JvmOverloads constructor( screen: S, parent: EditablePanel<*>?, - widget: BooleanInputWithFeedback, + widget: IPlayerInputWithFeedback, text: Component, x: Float = 0f, y: Float = 0f, @@ -17,14 +18,6 @@ open class CheckBoxLabelInputPanel @JvmOverloads constructor( height: Float = CheckBoxPanel.REGULAR_DIMENSIONS ) : EditablePanel(screen, parent, x, y, width, height) { val widget get() = checkbox.widget - val checkbox = CheckBoxInputPanel( - screen, - this, - widget, - 0f, - 0f, - CheckBoxPanel.REGULAR_DIMENSIONS, - CheckBoxPanel.REGULAR_DIMENSIONS - ) + val checkbox = CheckBoxInputPanel(screen = screen, parent = this, widget = widget, x = 0f, y = 0f, width = CheckBoxPanel.REGULAR_DIMENSIONS, height = CheckBoxPanel.REGULAR_DIMENSIONS) val label = Label(screen, this, CheckBoxPanel.REGULAR_DIMENSIONS + 4f, 4f, text = text) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt index 960f69ae2..799d6fd52 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.input import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.menu.input.AbstractPlayerInputWithFeedback import ru.dbotthepony.mc.otm.milliTime @@ -15,13 +16,13 @@ open class NetworkedStringInputPanel( height: Float = 11f, ) : TextInputPanel(screen, parent, x, y, width, height) { override var isActive: Boolean - get() = backend.check() + get() = backend.test(minecraft.player) set(value) {} override fun onFocusChanged(new: Boolean, old: Boolean) { super.onFocusChanged(new, old) - if (new && !backend.check()) { + if (new && !backend.test(minecraft.player)) { killFocus() } } @@ -30,7 +31,7 @@ open class NetworkedStringInputPanel( override fun onTextChanged(old: String, new: String) { lastChanges = milliTime + 1000L - backend.input(new) + backend.accept(new) } override fun tick() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt index 9c7953444..022140131 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt @@ -19,6 +19,14 @@ interface GetterSetter : Supplier, Consumer, ReadWriteProperty return get() } + operator fun invoke(): V { + return get() + } + + operator fun invoke(value: V) { + accept(value) + } + companion object { fun of(getter: Supplier, setter: Consumer): GetterSetter { return object : GetterSetter { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index fb1734cec..87912e150 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -39,6 +39,7 @@ import java.io.DataInputStream import java.io.DataOutputStream import java.math.BigDecimal import java.util.* +import java.util.function.Predicate import java.util.function.Supplier import kotlin.collections.ArrayList @@ -82,7 +83,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( val menu = context.sender?.containerMenu as? MatteryMenu ?: return@enqueueWork if (menu.containerId != containerId) return@enqueueWork val input = menu.playerInputs.getOrNull(inputId) ?: return@enqueueWork - if (!input.allowSpectators && context.sender!!.isSpectator) return@enqueueWork + if (!input.test(context.sender)) return@enqueueWork input.invoke(input.codec.read(DataInputStream(FastByteArrayInputStream(payload)))) } } @@ -91,7 +92,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( /** * Client->Server handler */ - inner class PlayerInput(val codec: IStreamCodec, allowSpectators: Boolean = false, val handler: (V) -> Unit) { + inner class PlayerInput(val codec: IStreamCodec, allowSpectators: Boolean = false, val handler: (V) -> Unit) : Predicate { val id = playerInputs.size var allowSpectators by mSynchronizer.bool(allowSpectators) @@ -99,6 +100,22 @@ abstract class MatteryMenu @JvmOverloads protected constructor( playerInputs.add(this) } + private val filters = ArrayList>() + + init { + filters.add { allowSpectators || !it.isSpectator } + } + + fun filter(predicate: Predicate): PlayerInput { + filters.add(predicate) + return this + } + + override fun test(player: Player?): Boolean { + if (player == null) return false + return filters.all { it.test(player) } + } + fun input(value: V) { val stream = FastByteArrayOutputStream() codec.write(DataOutputStream(stream), value) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt index b09a3e120..1a2c9203b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt @@ -4,6 +4,7 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.inventory.Slot import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.StringInputWithFeedback import ru.dbotthepony.mc.otm.registry.MMenus @@ -12,28 +13,18 @@ class HoloSignMenu @JvmOverloads constructor( inventory: Inventory, tile: HoloSignBlockEntity? = null ) : MatteryMenu(MMenus.HOLO_SIGN, containerId, inventory, tile) { - val text = if (tile != null) - StringInputWithFeedback(this).withConsumer { - val lines = it.split(NEWLINES) - val result = ArrayList(lines.size.coerceAtMost(HoloSignBlockEntity.DEFAULT_MAX_NEWLINES)) + val text = StringInputWithFeedback(this) + val locked = BooleanInputWithFeedback(this) - for (i in 0 until lines.size.coerceAtMost(HoloSignBlockEntity.DEFAULT_MAX_NEWLINES)) { - if (lines[i].length > HoloSignBlockEntity.DEFAULT_MAX_LINE_LENGTH) { - result.add(lines[i].substring(0, HoloSignBlockEntity.DEFAULT_MAX_LINE_LENGTH)) - } else { - result.add(lines[i]) - } - } + init { + locked.filter { it.isCreative } - tile.text = result.joinToString("\n") - }.withSupplier(tile::text) - else - StringInputWithFeedback(this) + if (tile != null) { + text.withConsumer { if (tile.locked) tile.text = it else tile.text = HoloSignBlockEntity.truncate(it) }.withSupplier(tile::text) + locked.with(tile::locked) + } + } override val storageSlots: Collection get() = listOf() - - companion object { - private val NEWLINES = Regex("\r?\n") - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt index bf3704012..22695363c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt @@ -4,12 +4,17 @@ import net.minecraft.world.entity.player.Player import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.menu.MatteryMenu +import java.util.function.Consumer +import java.util.function.Predicate +import java.util.function.Supplier import kotlin.reflect.KMutableProperty0 +interface IPlayerInputWithFeedback : GetterSetter, Predicate + /** * Getting and setting values should ONLY be done clientside */ -abstract class AbstractPlayerInputWithFeedback : GetterSetter { +abstract class AbstractPlayerInputWithFeedback : IPlayerInputWithFeedback { abstract val input: MatteryMenu.PlayerInput abstract val value: V @@ -21,6 +26,9 @@ abstract class AbstractPlayerInputWithFeedback : GetterSetter { input.checkedInput(t, minecraft.player as Player?) } + override fun test(player: Player?) = input.test(player) + fun filter(filter: Predicate) = input.filter(filter) + var supplier: (() -> V)? = null var consumer: ((V) -> Unit)? = null @@ -29,11 +37,21 @@ abstract class AbstractPlayerInputWithFeedback : GetterSetter { return this } + fun withSupplier(func: Supplier): AbstractPlayerInputWithFeedback { + supplier = func::get + return this + } + fun withConsumer(func: (V) -> Unit): AbstractPlayerInputWithFeedback { consumer = func return this } + fun withConsumer(func: Consumer): AbstractPlayerInputWithFeedback { + consumer = func::accept + return this + } + fun with(state: KMutableProperty0): AbstractPlayerInputWithFeedback { withConsumer { state.set(it) } withSupplier { state.get() } @@ -41,8 +59,8 @@ abstract class AbstractPlayerInputWithFeedback : GetterSetter { } fun with(state: GetterSetter): AbstractPlayerInputWithFeedback { - withConsumer(state::accept) - withSupplier(state::get) + withConsumer(state) + withSupplier(state) return this } @@ -51,18 +69,4 @@ abstract class AbstractPlayerInputWithFeedback : GetterSetter { consumer = null return this } - - /** - * shortcut to checked input of [input] - */ - fun input(newValue: V) { - input.checkedInput(newValue, minecraft.player as Player?) - } - - /** - * checks if local (client) player can modify this input - */ - fun check(): Boolean { - return input.allowSpectators || (minecraft.player as Player?)?.isSpectator == false - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/BooleanInputWithFeedback.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/BooleanInputWithFeedback.kt index 65bf20706..7d2346604 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/BooleanInputWithFeedback.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/BooleanInputWithFeedback.kt @@ -17,6 +17,6 @@ class BooleanInputWithFeedback(menu: MatteryMenu) : AbstractPlayerInputWithFeedb } fun switchValue() { - input(!value) + accept(!value) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt index d8ab2bca4..e20ba3937 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt @@ -99,6 +99,10 @@ sealed interface IMutableField : IField, GetterSetter { override fun accept(t: V) { value = t } + + override fun invoke(): V { + return this.value + } } data class MapChangeset( From ece5b2a936c7293e862c92aeb07e6f66bacd2954 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 29 Jan 2023 20:23:37 +0700 Subject: [PATCH 0134/1199] Better check box label --- .../screen/decorative/HoloSignScreen.kt | 2 ++ .../button/AbstractCheckBoxLabelPanel.kt | 29 +++++++++++++++++++ .../panels/button/CheckBoxLabelInputPanel.kt | 8 +++-- .../panels/button/CheckBoxLabelPanel.kt | 8 ++--- 4 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractCheckBoxLabelPanel.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt index f182df1d4..f13c8649d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt @@ -4,6 +4,7 @@ import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.Dock +import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.button.CheckBoxLabelInputPanel import ru.dbotthepony.mc.otm.client.screen.panels.input.NetworkedStringInputPanel @@ -20,6 +21,7 @@ class HoloSignScreen(menu: HoloSignMenu, inventory: Inventory, title: Component) val lock = CheckBoxLabelInputPanel(this, frame, menu.locked, TranslatableComponent("otm.gui.lock_holo_screen")) lock.dock = Dock.BOTTOM + lock.dockMargin = DockProperty(2f, 2f, 2f, 2f) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractCheckBoxLabelPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractCheckBoxLabelPanel.kt new file mode 100644 index 000000000..3e6384b24 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractCheckBoxLabelPanel.kt @@ -0,0 +1,29 @@ +package ru.dbotthepony.mc.otm.client.screen.panels.button + +import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.client.screen.panels.Label +import kotlin.math.roundToInt + +abstract class AbstractCheckBoxLabelPanel @JvmOverloads constructor( + screen: S, + parent: EditablePanel<*>?, + x: Float = 0f, + y: Float = 0f, + width: Float = CheckBoxPanel.REGULAR_DIMENSIONS + 120f, + height: Float = CheckBoxPanel.REGULAR_DIMENSIONS +) : EditablePanel(screen, parent, x, y, width, height) { + abstract val checkbox: CheckBoxPanel + abstract val label: Label + + override fun performLayout() { + super.performLayout() + + checkbox.x = dockPadding.left + checkbox.y = dockPadding.top + (height / 2f - checkbox.height / 2f).roundToInt().toFloat() + + label.x = checkbox.x + checkbox.width + 4f + label.y = ((height - dockPadding.top - dockPadding.bottom) / 2f - font.lineHeight / 2f).roundToInt().toFloat() + label.width = width - checkbox.width - dockPadding.right + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelInputPanel.kt index 3b4a5e241..905bfff6a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelInputPanel.kt @@ -2,10 +2,12 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component +import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.Label import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.IPlayerInputWithFeedback +import kotlin.math.roundToInt open class CheckBoxLabelInputPanel @JvmOverloads constructor( screen: S, @@ -16,8 +18,8 @@ open class CheckBoxLabelInputPanel @JvmOverloads constructor( y: Float = 0f, width: Float = CheckBoxPanel.REGULAR_DIMENSIONS + 120f, height: Float = CheckBoxPanel.REGULAR_DIMENSIONS -) : EditablePanel(screen, parent, x, y, width, height) { +) : AbstractCheckBoxLabelPanel(screen, parent, x, y, width, height) { val widget get() = checkbox.widget - val checkbox = CheckBoxInputPanel(screen = screen, parent = this, widget = widget, x = 0f, y = 0f, width = CheckBoxPanel.REGULAR_DIMENSIONS, height = CheckBoxPanel.REGULAR_DIMENSIONS) - val label = Label(screen, this, CheckBoxPanel.REGULAR_DIMENSIONS + 4f, 4f, text = text) + override val checkbox = CheckBoxInputPanel(screen = screen, parent = this, widget = widget, x = 0f, y = 0f, width = CheckBoxPanel.REGULAR_DIMENSIONS, height = CheckBoxPanel.REGULAR_DIMENSIONS) + override val label = Label(screen, this, CheckBoxPanel.REGULAR_DIMENSIONS + 4f, 4f, text = text) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelPanel.kt index 301ecb901..e9dd03780 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelPanel.kt @@ -4,6 +4,7 @@ import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.Label +import kotlin.math.roundToInt open class CheckBoxLabelPanel @JvmOverloads constructor( screen: S, @@ -13,8 +14,7 @@ open class CheckBoxLabelPanel @JvmOverloads constructor( y: Float = 0f, width: Float = CheckBoxPanel.REGULAR_DIMENSIONS + 120f, height: Float = CheckBoxPanel.REGULAR_DIMENSIONS -) : EditablePanel(screen, parent, x, y, width, height) { - val checkbox = - CheckBoxPanel(screen, this, 0f, 0f, CheckBoxPanel.REGULAR_DIMENSIONS, CheckBoxPanel.REGULAR_DIMENSIONS) - val label = Label(screen, this, CheckBoxPanel.REGULAR_DIMENSIONS + 4f, 4f, text = text) +) : AbstractCheckBoxLabelPanel(screen, parent, x, y, width, height) { + override val checkbox = CheckBoxPanel(screen, this, 0f, 0f, CheckBoxPanel.REGULAR_DIMENSIONS, CheckBoxPanel.REGULAR_DIMENSIONS) + override val label = Label(screen, this, CheckBoxPanel.REGULAR_DIMENSIONS + 4f, 4f, text = text) } From 074090f40404dac47498988f06db47265da9abb6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 29 Jan 2023 20:26:51 +0700 Subject: [PATCH 0135/1199] fix checkbox texture --- .../ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt | 2 +- .../mc/otm/client/screen/panels/button/CheckBoxPanel.kt | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt index 67431c658..a2b160c72 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt @@ -9,7 +9,7 @@ object WidgetLocation { val MISC = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/misc.png"), 64f, 64f) val PATTERN_PANEL_TABS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/pattern_panel_tabs.png"), 64f, 32f) - val CHECKBOX = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/checkbox.png"), 32f, 64f) + val CHECKBOX = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/checkbox.png"), 30f, 60f) val PROGRESS_ARROWS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/progress_arrows.png"), 22f, 31f) val HORIZONTAL_GAUGES = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/horizontal_gauges.png"), 96f, 54f) val VERTICAL_GAUGES = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/vertical_gauges.png"), 90f, 48f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt index 822e76a16..611c17599 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt @@ -92,14 +92,14 @@ open class CheckBoxPanel @JvmOverloads constructor( init { val grid = WidgetLocation.CHECKBOX.grid(columns = 2, rows = 4) - IDLE_UNCHECKED = grid.next() IDLE_CHECKED = grid.next() - HOVERED_UNCHECKED = grid.next() + IDLE_UNCHECKED = grid.next() HOVERED_CHECKED = grid.next() - PRESSED_UNCHECKED = grid.next() + HOVERED_UNCHECKED = grid.next() PRESSED_CHECKED = grid.next() - DISABLED_UNCHECKED = grid.next() + PRESSED_UNCHECKED = grid.next() DISABLED_CHECKED = grid.next() + DISABLED_UNCHECKED = grid.next() } } } From 46f0b1bf59917cc601f7f7a24afe79e393bfbdc6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 29 Jan 2023 20:31:35 +0700 Subject: [PATCH 0136/1199] Fix scroll bar constants --- .../screen/panels/util/ScrollBarConstants.kt | 16 ++++++++-------- .../textures/gui/widgets/scrollbar.png | Bin 330 -> 701 bytes .../textures/gui/widgets/scrollbar_slim.png | Bin 322 -> 682 bytes 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/ScrollBarConstants.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/ScrollBarConstants.kt index 546346c56..397500379 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/ScrollBarConstants.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/ScrollBarConstants.kt @@ -19,17 +19,17 @@ object ScrollBarConstants { val BODY = BACKGROUND.sprite(y = 2f, height = 5f) val BOTTOM = BACKGROUND.sprite(y = 6f, height = 2f) - val BUTTON = NORMAL_ATLAS.sprite(x = 15f, width = 12f) - val BUTTON_HOVER = NORMAL_ATLAS.sprite(x = 15f + 12f, width = 12f) - val BUTTON_PRESS = NORMAL_ATLAS.sprite(x = 15f + 12f * 2f, width = 12f) - val BUTTON_DISABLED = NORMAL_ATLAS.sprite(x = 15f + 12f * 3f, width = 12f) + val BUTTON = NORMAL_ATLAS.sprite(x = 14f, width = 12f) + val BUTTON_HOVER = NORMAL_ATLAS.sprite(x = 14f + 12f, width = 12f) + val BUTTON_PRESS = NORMAL_ATLAS.sprite(x = 14f + 12f * 2f, width = 12f) + val BUTTON_DISABLED = NORMAL_ATLAS.sprite(x = 14f + 12f * 3f, width = 12f) val SLIM_TOP = BACKGROUND_SLIM.sprite(height = 2f) val SLIM_BODY = BACKGROUND_SLIM.sprite(y = 2f, height = 5f) val SLIM_BOTTOM = BACKGROUND_SLIM.sprite(y = 6f, height = 2f) - val SLIM_BUTTON = SLIM_ATLAS.sprite(x = 9f, width = 6f) - val SLIM_BUTTON_HOVER = SLIM_ATLAS.sprite(x = 9f + 6f, width = 6f) - val SLIM_BUTTON_PRESS = SLIM_ATLAS.sprite(x = 9f + 6f * 2f, width = 6f) - val SLIM_BUTTON_DISABLED = SLIM_ATLAS.sprite(x = 9f + 6f * 3f, width = 6f) + val SLIM_BUTTON = SLIM_ATLAS.sprite(x = 8f, width = 6f) + val SLIM_BUTTON_HOVER = SLIM_ATLAS.sprite(x = 8f + 6f, width = 6f) + val SLIM_BUTTON_PRESS = SLIM_ATLAS.sprite(x = 8f + 6f * 2f, width = 6f) + val SLIM_BUTTON_DISABLED = SLIM_ATLAS.sprite(x = 8f + 6f * 3f, width = 6f) } diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/scrollbar.png index e15e25c3d023a24c1ec7319d4db4c6082421ba46..b8ac70a148105f9847e8011a78d1fae46a4988a8 100644 GIT binary patch delta 657 zcmV;C0&e}v0=)&0BYy#fX+uL$Nkc;*aB^>EX>4Tx04R}tkv&MmP!xqvQ$>*$2Rn#V z$WWauii$W&6^me@v=v%)FnQ@8G-*guTpR`0f`dPcRRAnrR#3^C4DgA>b4)iZ;tk@NO-tvzPaI+;Ng+Nb9y92I#E)E;U4G+SbXee- zAtRHTCk_#d#SWG`n3W8bc$zq(s2b%9S(g>gTb$KOjkWH{Ul_=1D`~FN3L}msB#?v% z88wtqfrTjT8h4eX0?0+92^3pMao|HcqDgk=iL77Y0d8kxP@}V8a(w} z00006VoOIv0RI600RN!9r<0LB7=H(JNliru=K&oJ9WHa^)#v~K0J%v-K~zY`?U%6) z!yphvKT;OL4Fw%Du!bwc2JW!Ovgo)uJOwEtH!iFrB$AcfZ+Qh@Pp8u8RuLR|2T@YA0D#t-#bOiDt9Vbg zZM%H8)^_nkbjhE~a{2D!=Z}7x=UQy##kd&%7vrs~>1T|`7*&k1xp1wu%8bj5i*Ye7 r#&2d^y<0e?RFC6>lX;$Rb)7u{%B6rjC?T_)00000NkvXXu0mjf6Dcbz delta 304 zcmV-00nh%u1Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi z!vFvd!vV){sAK>D0N+VOK~zXf?a?s`gFp}k&y2Yn;ov^HuA^<+a5~4q^@twh2qgTm_>JQL0000EX>4Tx04R}tkv&MmP!xqvQ$>*$2Rn#V z$WWauii$W&6^me@v=v%)FnQ@8G-*guTpR`0f`dPcRRAnrR#3^C4DgA>b4)iZ;tk@NO-tvzPaI+;Ng+Nb9y92I#E)E;U4G+SbXee- zAtRHTCk_#d#SWG`n3W8bc$zq(s2b%9S(g>gTb$KOjkWH{Ul_=1D`~FN3L}msB#?v% z88wtqfrTjT8h4eX0?0+92^3pMao|HcqDgk=iL77Y0d8kxP@}V8a(w} z00006VoOIv0RI600RN!9r<0LB7=H(JNliru=K&oJ9xS%U=LY})0H#SqK~y-)?Uk_& z!yphvKam%*8wxsR@ETO$4d{TePVRhjcnYUN3W*(KDN3Y>U%uvZPn=FjDK{Ks97j0k zUU-ZV#u!|Q)_RwBxo9uBe4gimuj>i`SeB*W!!Q55Z{TRvzGh&WCh;!q4>SXRZ$O+ChY+@Wd>-Sy|Hw7G Y15-w%kroW$p8x;=07*qoM6N<$f`1Db%>V!Z delta 296 zcmV+@0oVSj1;PT5BYyw^b5ch_0Itp)=>Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi z!vFvd!vV){sAK>D0M|)GK~zXf?Ug|egdhw>(U@=^-I(Y#xP~k71}tU8LA-%G<4(`v zDQ416Q6wwP>wbO8zBK)E0J`rU{o%Ebiy| z`2wJVuLMxnH7=i6+|TnUaJvE-`~lGISA<>$>C{bnb5oJU#FzaJvF~ um&d58DmX1;(;?6pvkxB^r4)HCjJ*LS!MCvD?g#n+0000 Date: Sun, 29 Jan 2023 21:01:12 +0700 Subject: [PATCH 0137/1199] Holo screen locale, api docs --- .../dbotthepony/mc/otm/datagen/lang/English.kt | 3 +++ .../dbotthepony/mc/otm/datagen/lang/Russian.kt | 3 +++ .../client/screen/decorative/HoloSignScreen.kt | 1 + .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 17 +++++++---------- .../mc/otm/menu/decorative/HoloSignMenu.kt | 1 + .../input/AbstractPlayerInputWithFeedback.kt | 9 ++++++++- 6 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 6729cade1..6dc802e52 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -116,6 +116,9 @@ private fun sounds(provider: MatteryLanguageProvider) { private fun misc(provider: MatteryLanguageProvider) { with(provider.english) { + gui("lock_holo_screen", "Lock contents") + gui("lock_holo_screen.tip", "Locking and unlocking contents is only possible in creative.\nWhen locked, text boundaries are removed.") + gui("ticks", "Ticks") gui("power_cost_per_use", "Power cost per use: %s") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 8658d3e89..46b3441a3 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -125,6 +125,9 @@ private fun sounds(provider: MatteryLanguageProvider) { private fun misc(provider: MatteryLanguageProvider) { with(provider.russian) { + gui("lock_holo_screen", "Заблокировать содержимое") + gui("lock_holo_screen.tip", "Блокировка и разблокировка содержимого возможна только в режиме творчества.\nКогда заблокировано, границы ввода текста отключены.") + gui("ticks", "Тиков") gui("power_cost_per_use", "Энергии на операцию: %s") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt index f13c8649d..676642d71 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt @@ -22,6 +22,7 @@ class HoloSignScreen(menu: HoloSignMenu, inventory: Inventory, title: Component) val lock = CheckBoxLabelInputPanel(this, frame, menu.locked, TranslatableComponent("otm.gui.lock_holo_screen")) lock.dock = Dock.BOTTOM lock.dockMargin = DockProperty(2f, 2f, 2f, 2f) + lock.tooltip = TranslatableComponent("otm.gui.lock_holo_screen.tip") return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 87912e150..a04aaf714 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -18,6 +18,7 @@ import net.minecraft.world.level.block.entity.BlockEntity import net.minecraftforge.network.NetworkEvent import net.minecraftforge.network.PacketDistributor import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.compat.cos.cosmeticArmorSlots import ru.dbotthepony.mc.otm.compat.curios.isCurioSlot import ru.dbotthepony.mc.otm.container.ItemFilter @@ -50,7 +51,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( val tile: BlockEntity? = null ) : AbstractContainerMenu(menuType, containerId) { /** - * Server->Client field synchronizer + * Server->Client synchronizer */ val mSynchronizer = FieldSynchronizer() val ply: Player get() = inventory.player @@ -90,7 +91,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( } /** - * Client->Server handler + * Client->Server input */ inner class PlayerInput(val codec: IStreamCodec, allowSpectators: Boolean = false, val handler: (V) -> Unit) : Predicate { val id = playerInputs.size @@ -117,14 +118,10 @@ abstract class MatteryMenu @JvmOverloads protected constructor( } fun input(value: V) { - val stream = FastByteArrayOutputStream() - codec.write(DataOutputStream(stream), value) - MenuNetworkChannel.sendToServer(PlayerInputPacket(containerId, id, stream.array.copyOfRange(0, stream.length))) - } - - fun checkedInput(value: V, player: Player?) { - if (allowSpectators || player?.isSpectator == false) { - return input(value) + if (test(minecraft.player as Player?)) { + val stream = FastByteArrayOutputStream() + codec.write(DataOutputStream(stream), value) + MenuNetworkChannel.sendToServer(PlayerInputPacket(containerId, id, stream.array.copyOfRange(0, stream.length))) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt index 1a2c9203b..402406f00 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt @@ -17,6 +17,7 @@ class HoloSignMenu @JvmOverloads constructor( val locked = BooleanInputWithFeedback(this) init { + text.filter { it.isCreative || !locked.value } locked.filter { it.isCreative } if (tile != null) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt index 22695363c..077e9a9ff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt @@ -9,9 +9,16 @@ import java.util.function.Predicate import java.util.function.Supplier import kotlin.reflect.KMutableProperty0 +/** + * Represents Server to Client synchronization and Client to Server input + * + * Getting and setting values should ONLY be done clientside + */ interface IPlayerInputWithFeedback : GetterSetter, Predicate /** + * Represents Server to Client synchronization and Client to Server input + * * Getting and setting values should ONLY be done clientside */ abstract class AbstractPlayerInputWithFeedback : IPlayerInputWithFeedback { @@ -23,7 +30,7 @@ abstract class AbstractPlayerInputWithFeedback : IPlayerInputWithFeedback } override fun accept(t: V) { - input.checkedInput(t, minecraft.player as Player?) + input.input(t) } override fun test(player: Player?) = input.test(player) From fb1117907addc2e97a5fed73e2e13e68a1f5bc8d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 29 Jan 2023 21:07:18 +0700 Subject: [PATCH 0138/1199] Matter panel now requires tritanium plates --- .../overdrive_that_matters/recipes/machines/matter_panel.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/data/overdrive_that_matters/recipes/machines/matter_panel.json b/src/main/resources/data/overdrive_that_matters/recipes/machines/matter_panel.json index abe33da3b..167cba500 100644 --- a/src/main/resources/data/overdrive_that_matters/recipes/machines/matter_panel.json +++ b/src/main/resources/data/overdrive_that_matters/recipes/machines/matter_panel.json @@ -10,7 +10,7 @@ "key": { "P": {"tag": "forge:glass_panes"}, "G": {"tag": "forge:dusts/glowstone"}, - "T": {"tag": "forge:plates/iron"}, + "T": {"tag": "forge:plates/tritanium"}, "C": {"tag": "forge:circuits/advanced"}, "E": {"item": "overdrive_that_matters:electric_parts"}, "-": {"item": "overdrive_that_matters:matter_cable"} From 1d8c636de4d62019d0cd5c61c24d1e07b69607d0 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 29 Jan 2023 21:14:05 +0700 Subject: [PATCH 0139/1199] Holo sign crafting recipe --- .../mc/otm/datagen/recipes/CraftingTableRecipes.kt | 7 ------- .../mc/otm/datagen/recipes/DecorativesRecipes.kt | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index 2cda8c5f5..230497240 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -247,13 +247,6 @@ fun addCraftingTableRecipes(consumer: Consumer) { .unlockedBy(MItems.BATTERY_CAPACITOR) .buildEnergetic(consumer) - // лампа - MatteryRecipe(MItems.LABORATORY_LAMP, category = RecipeCategory.REDSTONE) - .row(MItemTags.IRON_PLATES, MItemTags.HARDENED_GLASS_PANES_COLORLESS, MItemTags.IRON_PLATES) - .row(MItems.MIRROR, Items.GLOWSTONE, MItems.MIRROR) - .row(MItemTags.TRITANIUM_PLATES, Tags.Items.DUSTS_REDSTONE, MItemTags.TRITANIUM_PLATES) - .build(consumer) - // апгрейд на сетку крафта MatteryRecipe(MItems.ExopackUpgrades.CRAFTING_UPGRADE, category = RecipeCategory.TOOLS) .row(MItemTags.ADVANCED_CIRCUIT, MItemTags.ADVANCED_CIRCUIT, MItemTags.ADVANCED_CIRCUIT) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt index b8712fe64..8f69951c6 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt @@ -323,4 +323,18 @@ fun addDecorativesRecipes(provider: MatteryRecipeProvider, consumer: Consumer Date: Sun, 29 Jan 2023 21:50:14 +0700 Subject: [PATCH 0140/1199] IRedstoneControl, redstone control for holo signs --- .../mc/otm/datagen/loot/LootTables.kt | 7 +- .../mc/otm/datagen/loot/LootTablesData.kt | 12 +-- .../dbotthepony/mc/otm/block/MatteryBlock.kt | 5 +- .../mc/otm/block/decorative/HoloSignBlock.kt | 2 + .../mc/otm/block/entity/MatteryBlockEntity.kt | 58 ++--------- .../block/entity/MatteryWorkerBlockEntity.kt | 2 +- .../mc/otm/block/entity/RedstoneControl.kt | 97 +++++++++++++++++++ .../mc/otm/block/entity/RedstoneSetting.kt | 24 ++++- .../entity/decorative/HoloSignBlockEntity.kt | 26 +++-- .../entity/matter/MatterBottlerBlockEntity.kt | 2 +- .../entity/tech/AndroidStationBlockEntity.kt | 2 +- .../entity/tech/BatteryBankBlockEntity.kt | 2 +- .../tech/ChemicalGeneratorBlockEntity.kt | 2 +- .../render/blockentity/HoloSignRenderer.kt | 3 + .../mc/otm/core/nbt/CompoundTagExt.kt | 7 +- 15 files changed, 165 insertions(+), 86 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt index 3cc1641bc..bc9d7b1a0 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt @@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.datagen.loot -import com.mojang.datafixers.util.Pair import it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap import it.unimi.dsi.fastutil.objects.Reference2ObjectFunction import net.minecraft.advancements.critereon.StatePropertiesPredicate @@ -29,9 +28,6 @@ import net.minecraft.world.level.storage.loot.providers.nbt.ContextNbtProvider import net.minecraft.world.level.storage.loot.providers.number.ConstantValue import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity -import java.util.function.BiConsumer -import java.util.function.Consumer -import java.util.function.Supplier data class NbtCopy(val source: String, val destination: String, val strategy: CopyNbtFunction.MergeStrategy = CopyNbtFunction.MergeStrategy.REPLACE) @@ -40,8 +36,7 @@ fun TileNbtCopy(source: String, strategy: CopyNbtFunction.MergeStrategy = CopyNb } private val basicTags = arrayOf( - TileNbtCopy(MatteryBlockEntity.REDSTONE_SIGNAL_KEY), - TileNbtCopy(MatteryBlockEntity.REDSTONE_SETTING_KEY), + TileNbtCopy(MatteryBlockEntity.REDSTONE_CONTROL_KEY), ) private val poweredTags = arrayOf( diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index 3b0d5f6f3..fc3ecc2ff 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -10,8 +10,7 @@ import ru.dbotthepony.mc.otm.block.entity.tech.ChemicalGeneratorBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.EnergyCounterBlockEntity import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity.Companion.ENERGY_KEY import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity.Companion.MATTER_STORAGE_KEY -import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity.Companion.REDSTONE_SETTING_KEY -import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity.Companion.REDSTONE_SIGNAL_KEY +import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity.Companion.REDSTONE_CONTROL_KEY import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.AbstractStorageImportExport.Companion.FILTER_KEY @@ -139,11 +138,10 @@ fun addLootTables(lootTables: LootTables) { EnergyCounterBlockEntity.POWER_HISTORY_KEY, EnergyCounterBlockEntity.POWER_HISTORY_POINTER_KEY) lootTables.tile(MBlocks.CHEMICAL_GENERATOR, - ChemicalGeneratorBlockEntity.WORK_TICKS_KEY, - ChemicalGeneratorBlockEntity.WORK_TICKS_TOTAL_KEY, - ENERGY_KEY, - REDSTONE_SIGNAL_KEY, - REDSTONE_SETTING_KEY, + ChemicalGeneratorBlockEntity.WORK_TICKS_KEY, + ChemicalGeneratorBlockEntity.WORK_TICKS_TOTAL_KEY, + ENERGY_KEY, + REDSTONE_CONTROL_KEY, ) lootTables.tile(MBlocks.HOLO_SIGN, HoloSignBlockEntity.TEXT_KEY) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt index 7797409ba..b8e854b1d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt @@ -23,6 +23,7 @@ import net.minecraft.world.level.block.state.properties.EnumProperty import net.minecraft.world.level.material.Material import net.minecraft.world.level.material.MaterialColor import net.minecraft.world.phys.BlockHitResult +import ru.dbotthepony.mc.otm.block.entity.IRedstoneControlProvider import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.core.math.component1 @@ -158,8 +159,8 @@ abstract class MatteryBlock @JvmOverloads constructor( if (this is EntityBlock && !level.isClientSide) { val tile = level.getBlockEntity(pos) - if (tile is MatteryBlockEntity) - tile.redstoneSignal = level.getBestNeighborSignal(pos) + if (tile is IRedstoneControlProvider) + tile.redstoneControl.redstoneSignal = level.getBestNeighborSignal(pos) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt index 608461e44..b47d15211 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt @@ -2,6 +2,8 @@ package ru.dbotthepony.mc.otm.block.decorative import net.minecraft.core.BlockPos import net.minecraft.world.level.BlockGetter +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.EntityBlock import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.state.BlockState 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 33f761487..b2a0bf3c3 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 @@ -7,11 +7,7 @@ import net.minecraft.world.MenuProvider import java.lang.Runnable import net.minecraft.server.level.ServerLevel import net.minecraft.client.multiplayer.ClientLevel -import net.minecraft.core.Direction import net.minecraft.core.SectionPos -import net.minecraftforge.common.util.LazyOptional -import net.minecraftforge.common.capabilities.ICapabilityProvider -import java.lang.ref.WeakReference import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu @@ -20,51 +16,18 @@ import net.minecraft.nbt.StringTag import net.minecraft.network.chat.Component import net.minecraft.world.level.Level import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity -import net.minecraftforge.common.capabilities.Capability import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.nbt.ifHas import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.oncePre -abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: BlockPos, p_155230_: BlockState) : SynchronizedBlockEntity(p_155228_, p_155229_, p_155230_), MenuProvider { +abstract class MatteryBlockEntity( + p_155228_: BlockEntityType<*>, + p_155229_: BlockPos, + p_155230_: BlockState +) : SynchronizedBlockEntity(p_155228_, p_155229_, p_155230_), MenuProvider, IRedstoneControlProvider { var customDisplayName: Component? = null - var redstoneSignal = 0 - set(level) { - val old = isBlockedByRedstone - field = level - val state = isBlockedByRedstone - - if (old != state) { - redstoneStatusUpdated(state, old) - } - } - - var redstoneSetting: RedstoneSetting = RedstoneSetting.LOW - set(setting) { - val old = isBlockedByRedstone - field = setting - val state = isBlockedByRedstone - if (old != state) { - redstoneStatusUpdated(state, old) - } - } - - val isBlockedByRedstone: Boolean - get() { - when (redstoneSetting) { - RedstoneSetting.LOW -> { - return redstoneSignal > 0 - } - - RedstoneSetting.HIGH -> { - return redstoneSignal <= 0 - } - - RedstoneSetting.IGNORED -> { - return false - } - } - } + override val redstoneControl: IRedstoneControl = RedstoneControl(::redstoneStatusUpdated) protected open val defaultDisplayName: Component get() = level?.getBlockState(blockPos)?.block?.name ?: TextComponent("null at $blockPos") @@ -111,8 +74,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc if (customDisplayName != null) nbt.putString("Name", Component.Serializer.toJson(customDisplayName)) - nbt[REDSTONE_SETTING_KEY] = redstoneSetting.ordinal.toByte() - nbt[REDSTONE_SIGNAL_KEY] = redstoneSignal.toByte() + nbt[REDSTONE_CONTROL_KEY] = redstoneControl.serializeNBT() } override fun load(nbt: CompoundTag) { @@ -122,8 +84,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc customDisplayName = Component.Serializer.fromJson(it.asString) } - redstoneSetting = RedstoneSetting[nbt.getByte(REDSTONE_SETTING_KEY).toInt()] - redstoneSignal = nbt.getByte(REDSTONE_SIGNAL_KEY).toInt() + redstoneControl.deserializeNBT(nbt[REDSTONE_CONTROL_KEY] as? CompoundTag) } // Just to mark chunk unsaved @@ -137,8 +98,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } companion object { - const val REDSTONE_SETTING_KEY = "redstoneSetting" - const val REDSTONE_SIGNAL_KEY = "redstoneSignal" + const val REDSTONE_CONTROL_KEY = "redstoneControl" const val INVENTORY_KEY = "container" const val MATTER_STORAGE_KEY = "matterStorage" const val ENERGY_KEY = "energyStorage" diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt index 9e3278d11..c829fd509 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt @@ -261,7 +261,7 @@ abstract class MatteryWorkerBlockEntity( var availableTicks = 1.0 while (!isIdling && weakGreaterThan(availableTicks, 0.0) && throttleTicks <= 0) { - if (isBlockedByRedstone) { + if (redstoneControl.isBlockedByRedstone) { isIdling = true break } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt new file mode 100644 index 000000000..92a5401aa --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt @@ -0,0 +1,97 @@ +package ru.dbotthepony.mc.otm.block.entity + +import net.minecraft.nbt.CompoundTag +import net.minecraftforge.common.util.INBTSerializable +import ru.dbotthepony.mc.otm.core.nbt.getEnum +import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.network.FieldSynchronizer + +interface IRedstoneControlProvider { + val redstoneControl: IRedstoneControl +} + +interface IRedstoneControl : INBTSerializable { + var redstoneSetting: RedstoneSetting + var redstoneSignal: Int + + val isBlockedByRedstone: Boolean get() = !redstoneSetting.test(redstoneSignal) + + override fun serializeNBT(): CompoundTag { + return CompoundTag().also { + it[SETTING_KEY] = redstoneSetting.toString() + it[SIGNAL_KEY] = redstoneSignal + } + } + + override fun deserializeNBT(nbt: CompoundTag?) { + if (nbt == null) { + redstoneSetting = RedstoneSetting.LOW + redstoneSignal = 0 + return + } + + redstoneSetting = nbt.getEnum(SETTING_KEY) + redstoneSignal = nbt.getInt(SIGNAL_KEY) + } + + companion object { + const val SETTING_KEY = "RedstoneSetting" + const val SIGNAL_KEY = "RedstoneSignal" + } +} + +class RedstoneControl(private val valueChanges: (new: Boolean, old: Boolean) -> Unit) : IRedstoneControl { + override var redstoneSetting: RedstoneSetting = RedstoneSetting.LOW + set(level) { + val old = isBlockedByRedstone + field = level + val state = isBlockedByRedstone + + if (old != state) { + valueChanges.invoke(state, old) + } + } + + override var redstoneSignal: Int = 0 + set(setting) { + val old = isBlockedByRedstone + field = setting + val state = isBlockedByRedstone + if (old != state) { + valueChanges.invoke(state, old) + } + } +} + +class SynchronizedRedstoneControl( + synchronizer: FieldSynchronizer, + private val valueChanges: (new: Boolean, old: Boolean) -> Unit +) : IRedstoneControl { + override var redstoneSetting: RedstoneSetting by synchronizer.enum(RedstoneSetting.LOW, setter = { value, access, setByRemote -> + if (setByRemote) { + access.write(value) + } else { + val old = isBlockedByRedstone + access.write(value) + val state = isBlockedByRedstone + + if (old != state) { + valueChanges.invoke(state, old) + } + } + }) + + override var redstoneSignal: Int by synchronizer.int(0, setter = { value, access, setByRemote -> + if (setByRemote) { + access.write(value) + } else { + val old = isBlockedByRedstone + access.write(value) + val state = isBlockedByRedstone + + if (old != state) { + valueChanges.invoke(state, old) + } + } + }) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneSetting.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneSetting.kt index 43a75fdf8..14569fe14 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneSetting.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneSetting.kt @@ -2,11 +2,25 @@ package ru.dbotthepony.mc.otm.block.entity import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.core.TranslatableComponent +import java.util.function.IntPredicate +import java.util.function.Predicate -enum class RedstoneSetting(val label: Component, val description: Component) { - IGNORED(TranslatableComponent("otm.gui.redstone.ignored"), TranslatableComponent("otm.gui.redstone.ignored.description")), - LOW(TranslatableComponent("otm.gui.redstone.low"), TranslatableComponent("otm.gui.redstone.low.description")), - HIGH(TranslatableComponent("otm.gui.redstone.high"), TranslatableComponent("otm.gui.redstone.high.description")); +enum class RedstoneSetting(val label: Component, val description: Component): IntPredicate { + IGNORED(TranslatableComponent("otm.gui.redstone.ignored"), TranslatableComponent("otm.gui.redstone.ignored.description")) { + override fun test(t: Int): Boolean { + return true + } + }, + LOW(TranslatableComponent("otm.gui.redstone.low"), TranslatableComponent("otm.gui.redstone.low.description")) { + override fun test(t: Int): Boolean { + return t <= 0 + } + }, + HIGH(TranslatableComponent("otm.gui.redstone.high"), TranslatableComponent("otm.gui.redstone.high.description")) { + override fun test(t: Int): Boolean { + return t > 0 + } + }; operator fun next(): RedstoneSetting { return values[(ordinal + 1) % values.size] @@ -22,4 +36,4 @@ enum class RedstoneSetting(val label: Component, val description: Component) { return values[index] } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt index 07417c75c..f5b3abfbc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt @@ -8,13 +8,17 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.level.block.state.BlockState +import ru.dbotthepony.mc.otm.block.entity.IRedstoneControlProvider import ru.dbotthepony.mc.otm.block.entity.SynchronizedBlockEntity +import ru.dbotthepony.mc.otm.block.entity.SynchronizedRedstoneControl import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.menu.decorative.HoloSignMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlocks -class HoloSignBlockEntity(blockPos: BlockPos, blockState: BlockState) : SynchronizedBlockEntity(MBlockEntities.HOLO_SIGN, blockPos, blockState), MenuProvider { +class HoloSignBlockEntity(blockPos: BlockPos, blockState: BlockState) : SynchronizedBlockEntity(MBlockEntities.HOLO_SIGN, blockPos, blockState), MenuProvider, IRedstoneControlProvider { + override val redstoneControl = SynchronizedRedstoneControl(synchronizer) { _, _ -> } + var text by synchronizer.string("", name = "text", setter = { value, access, remote -> setChanged() access.write(value) @@ -30,25 +34,29 @@ class HoloSignBlockEntity(blockPos: BlockPos, blockState: BlockState) : Synchron return MBlocks.HOLO_SIGN.name } - override fun saveAdditional(p_187471_: CompoundTag) { - super.saveAdditional(p_187471_) - p_187471_[TEXT_KEY] = text + override fun saveAdditional(nbt: CompoundTag) { + super.saveAdditional(nbt) + nbt[TEXT_KEY] = text + nbt[REDSTONE_CONTROL_KEY] = redstoneControl.serializeNBT() } - override fun load(p_155245_: CompoundTag) { - super.load(p_155245_) - locked = p_155245_.getBoolean(LOCKED_KEY) + override fun load(nbt: CompoundTag) { + super.load(nbt) + locked = nbt.getBoolean(LOCKED_KEY) if (locked) { - text = p_155245_.getString(TEXT_KEY) + text = nbt.getString(TEXT_KEY) } else { - text = truncate(p_155245_.getString(TEXT_KEY)) + text = truncate(nbt.getString(TEXT_KEY)) } + + redstoneControl.deserializeNBT(nbt[REDSTONE_CONTROL_KEY] as? CompoundTag) } companion object { const val TEXT_KEY = "SignText" const val LOCKED_KEY = "Locked" + const val REDSTONE_CONTROL_KEY = "RedstoneControl" const val DEFAULT_MAX_NEWLINES = 8 const val DEFAULT_MAX_LINE_LENGTH = 15 private val NEWLINES = Regex("\r?\n") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index 273c8bda7..32109a4a2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -222,7 +222,7 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : fun tick() { batteryChargeLoop() - if (isBlockedByRedstone) { + if (redstoneControl.isBlockedByRedstone) { if (blockState.getValue(WorkerState.SEMI_WORKER_STATE) !== WorkerState.IDLE) { level?.setBlock( blockPos, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt index 1779b1100..6cf739ced 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt @@ -78,7 +78,7 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : batteryChargeLoop() - if (isBlockedByRedstone) return + if (redstoneControl.isBlockedByRedstone) return val level = level ?: return val x = blockPos.x.toDouble() val y = blockPos.y.toDouble() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index 5e6b4ab70..8020ecfa6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -303,7 +303,7 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte fun checkSurroundings() = consumers.update((-blockState.getValue(RotatableMatteryBlock.FACING))::equals) fun tick() { - if (isBlockedByRedstone) + if (redstoneControl.isBlockedByRedstone) return for (it in consumers) { 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 fdb3b94f7..40c368eb6 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 @@ -168,7 +168,7 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryBl level?.setBlock(blockPos, blockState.setValue(WorkerState.SEMI_WORKER_STATE, WorkerState.IDLE), Block.UPDATE_CLIENTS) } - if (workTicks == 0 && !isBlockedByRedstone && checkFuelSlot) { + if (workTicks == 0 && !redstoneControl.isBlockedByRedstone && checkFuelSlot) { if (!container[SLOT_INPUT].isEmpty) { val ticks = ForgeHooks.getBurnTime(container[SLOT_INPUT], null) val residue = container[SLOT_INPUT].item.getCraftingRemainingItem(container[SLOT_INPUT].copy().also { it.count = 1 }) 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 7a99d84e6..5499eeb0d 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 @@ -24,6 +24,9 @@ class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context) p_112311_: Int, p_112312_: Int ) { + if (tile.redstoneControl.isBlockedByRedstone) + return + poseStack.pushPose() poseStack.rotateWithBlockFacing(tile.blockState[RotatableMatteryBlock.FACING_FULL]) poseStack.translate(0.5f, 0.5f, 0.6f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt index 042eb8c63..4073e87f5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt @@ -62,14 +62,15 @@ inline fun CompoundTag.mapIf(key: String, consumer: (T) -> return null } -inline fun > CompoundTag.getEnum(key: String): R { +inline fun > CompoundTag.getEnum(key: String, ifNothing: () -> R = { R::class.java.enumConstants[0] }): R { val tag = get(key) if (tag is StringTag) { - return R::class.java.enumConstants.first { it.name == tag.asString } + val str = tag.asString + return R::class.java.enumConstants.first { it.name == str } } - return R::class.java.enumConstants[0] + return ifNothing.invoke() } fun CompoundTag.getItemStack(key: String): ItemStack = map(key, ItemStack::of) ?: ItemStack.EMPTY From 1bedd960da2b58109cf1f9b76cf527113838f6d5 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 29 Jan 2023 21:51:24 +0700 Subject: [PATCH 0141/1199] =?UTF-8?q?=E2=9A=99=20SHOCKY=20=E2=80=94=20?= =?UTF-8?q?=D0=A1=D0=B5=D0=B3=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=2021:49=20?= =?UTF-8?q?=D0=A1=D0=AB=D0=A0=3F=20=D0=B0=20=D0=B8=20=D1=82=D0=B5=D0=BA?= =?UTF-8?q?=D1=81=D1=82=20=D1=81=D0=B8=D0=BD=D0=B8=D0=BC=20=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=B0=D0=BD=D0=B5=D1=82=D1=81=D1=8F=20=D0=B8=D0=BB=D0=B8?= =?UTF-8?q?=20=D0=B1=D1=83=D0=B4=D0=B5=D1=82=20=D0=B6=D1=91=D0=BB=D1=82?= =?UTF-8?q?=D1=8B=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/client/render/blockentity/HoloSignRenderer.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 5499eeb0d..a79e423fd 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 @@ -39,7 +39,7 @@ class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context) var y = -totalHeight / 2f for (line in lines) { - font.drawAligned(poseStack = poseStack, buffer = sorse, text = line, align = TextAlign.TOP_CENTER, x = 0f, y = y, color = RGBAColor.BLUE.toInt()) + font.drawAligned(poseStack = poseStack, buffer = sorse, text = line, align = TextAlign.TOP_CENTER, x = 0f, y = y, color = RGBAColor.YELLOW.toInt()) y += font.lineHeight + 2f } From f742d6d81923b394517c557e72e656eec871cf1e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 29 Jan 2023 21:54:59 +0700 Subject: [PATCH 0142/1199] Declare redstone control as abstract class, not interface to further enforce composition usage of this class --- .../mc/otm/block/entity/MatteryBlockEntity.kt | 2 +- .../mc/otm/block/entity/RedstoneControl.kt | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) 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 b2a0bf3c3..8b187d490 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 @@ -27,7 +27,7 @@ abstract class MatteryBlockEntity( p_155230_: BlockState ) : SynchronizedBlockEntity(p_155228_, p_155229_, p_155230_), MenuProvider, IRedstoneControlProvider { var customDisplayName: Component? = null - override val redstoneControl: IRedstoneControl = RedstoneControl(::redstoneStatusUpdated) + override val redstoneControl: AbstractRedstoneControl = RedstoneControl(::redstoneStatusUpdated) protected open val defaultDisplayName: Component get() = level?.getBlockState(blockPos)?.block?.name ?: TextComponent("null at $blockPos") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt index 92a5401aa..8f6e80e88 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt @@ -7,12 +7,12 @@ import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.network.FieldSynchronizer interface IRedstoneControlProvider { - val redstoneControl: IRedstoneControl + val redstoneControl: AbstractRedstoneControl } -interface IRedstoneControl : INBTSerializable { - var redstoneSetting: RedstoneSetting - var redstoneSignal: Int +abstract class AbstractRedstoneControl : INBTSerializable { + abstract var redstoneSetting: RedstoneSetting + abstract var redstoneSignal: Int val isBlockedByRedstone: Boolean get() = !redstoneSetting.test(redstoneSignal) @@ -40,7 +40,7 @@ interface IRedstoneControl : INBTSerializable { } } -class RedstoneControl(private val valueChanges: (new: Boolean, old: Boolean) -> Unit) : IRedstoneControl { +class RedstoneControl(private val valueChanges: (new: Boolean, old: Boolean) -> Unit) : AbstractRedstoneControl() { override var redstoneSetting: RedstoneSetting = RedstoneSetting.LOW set(level) { val old = isBlockedByRedstone @@ -66,7 +66,7 @@ class RedstoneControl(private val valueChanges: (new: Boolean, old: Boolean) -> class SynchronizedRedstoneControl( synchronizer: FieldSynchronizer, private val valueChanges: (new: Boolean, old: Boolean) -> Unit -) : IRedstoneControl { +) : AbstractRedstoneControl() { override var redstoneSetting: RedstoneSetting by synchronizer.enum(RedstoneSetting.LOW, setter = { value, access, setByRemote -> if (setByRemote) { access.write(value) From 4b9fc97b7cd2f825372b6fdc764ceb46d7a7bca2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 29 Jan 2023 22:19:51 +0700 Subject: [PATCH 0143/1199] Mark field creation methods as jvm overloads --- .../mc/otm/network/FieldSynchronizer.kt | 108 ++++++++++-------- 1 file changed, 63 insertions(+), 45 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt index e20ba3937..3d2187b5d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt @@ -158,60 +158,61 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa hasChanges = false } - fun byte(getter: () -> Byte, name: String = nextFieldName()) = ComputedField(getter, ByteValueCodec, name) - fun bool(getter: () -> Boolean, name: String = nextFieldName()) = ComputedField(getter, BooleanValueCodec, name) - fun short(getter: () -> Short, name: String = nextFieldName()) = ComputedField(getter, ShortValueCodec, name) - fun long(getter: () -> Long, name: String = nextFieldName()) = ComputedField(getter, VarLongValueCodec, name) - fun fixedLong(getter: () -> Long, name: String = nextFieldName()) = ComputedField(getter, LongValueCodec, name) - fun float(getter: () -> Float, name: String = nextFieldName()) = ComputedField(getter, FloatValueCodec, name) - fun double(getter: () -> Double, name: String = nextFieldName()) = ComputedField(getter, DoubleValueCodec, name) - fun uuid(getter: () -> UUID, name: String = nextFieldName()) = ComputedField(getter, UUIDValueCodec, name) - fun int(getter: () -> Int, name: String = nextFieldName()) = ComputedField(getter, VarIntValueCodec, name) - fun fixedInt(getter: () -> Int, name: String = nextFieldName()) = ComputedField(getter, IntValueCodec, name) - fun fraction(getter: () -> Decimal, name: String = nextFieldName()) = ComputedField(getter, ImpreciseFractionValueCodec, name) - fun bigDecimal(getter: () -> BigDecimal, name: String = nextFieldName()) = ComputedField(getter, BigDecimalValueCodec, name) - fun item(getter: () -> ItemStack, name: String = nextFieldName()) = ComputedField(getter, ItemStackValueCodec, name) - fun string(getter: () -> String, name: String = nextFieldName()) = ComputedField(getter, BinaryStringCodec, name) + @JvmOverloads fun byte(getter: () -> Byte, name: String = nextFieldName()) = ComputedField(getter, ByteValueCodec, name) + @JvmOverloads fun bool(getter: () -> Boolean, name: String = nextFieldName()) = ComputedField(getter, BooleanValueCodec, name) + @JvmOverloads fun short(getter: () -> Short, name: String = nextFieldName()) = ComputedField(getter, ShortValueCodec, name) + @JvmOverloads fun long(getter: () -> Long, name: String = nextFieldName()) = ComputedField(getter, VarLongValueCodec, name) + @JvmOverloads fun fixedLong(getter: () -> Long, name: String = nextFieldName()) = ComputedField(getter, LongValueCodec, name) + @JvmOverloads fun float(getter: () -> Float, name: String = nextFieldName()) = ComputedField(getter, FloatValueCodec, name) + @JvmOverloads fun double(getter: () -> Double, name: String = nextFieldName()) = ComputedField(getter, DoubleValueCodec, name) + @JvmOverloads fun uuid(getter: () -> UUID, name: String = nextFieldName()) = ComputedField(getter, UUIDValueCodec, name) + @JvmOverloads fun int(getter: () -> Int, name: String = nextFieldName()) = ComputedField(getter, VarIntValueCodec, name) + @JvmOverloads fun fixedInt(getter: () -> Int, name: String = nextFieldName()) = ComputedField(getter, IntValueCodec, name) + @JvmOverloads fun fraction(getter: () -> Decimal, name: String = nextFieldName()) = ComputedField(getter, ImpreciseFractionValueCodec, name) + @JvmOverloads fun bigDecimal(getter: () -> BigDecimal, name: String = nextFieldName()) = ComputedField(getter, BigDecimalValueCodec, name) + @JvmOverloads fun item(getter: () -> ItemStack, name: String = nextFieldName()) = ComputedField(getter, ItemStackValueCodec, name) + @JvmOverloads fun string(getter: () -> String, name: String = nextFieldName()) = ComputedField(getter, BinaryStringCodec, name) - fun byte(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, ByteValueCodec, name) - fun bool(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, BooleanValueCodec, name) - fun short(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, ShortValueCodec, name) - fun long(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, VarLongValueCodec, name) - fun fixedLong(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, LongValueCodec, name) - fun float(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, FloatValueCodec, name) - fun double(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, DoubleValueCodec, name) - fun uuid(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, UUIDValueCodec, name) - fun int(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, VarIntValueCodec, name) - fun fixedInt(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, IntValueCodec, name) - fun fraction(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, ImpreciseFractionValueCodec, name) - fun bigDecimal(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, BigDecimalValueCodec, name) - fun item(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, ItemStackValueCodec, name) - fun string(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, BinaryStringCodec, name) + @JvmOverloads fun byte(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, ByteValueCodec, name) + @JvmOverloads fun bool(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, BooleanValueCodec, name) + @JvmOverloads fun short(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, ShortValueCodec, name) + @JvmOverloads fun long(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, VarLongValueCodec, name) + @JvmOverloads fun fixedLong(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, LongValueCodec, name) + @JvmOverloads fun float(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, FloatValueCodec, name) + @JvmOverloads fun double(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, DoubleValueCodec, name) + @JvmOverloads fun uuid(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, UUIDValueCodec, name) + @JvmOverloads fun int(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, VarIntValueCodec, name) + @JvmOverloads fun fixedInt(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, IntValueCodec, name) + @JvmOverloads fun fraction(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, ImpreciseFractionValueCodec, name) + @JvmOverloads fun bigDecimal(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, BigDecimalValueCodec, name) + @JvmOverloads fun item(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, ItemStackValueCodec, name) + @JvmOverloads fun string(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, BinaryStringCodec, name) - fun byte(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, ByteValueCodec, name) - fun bool(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, BooleanValueCodec, name) - fun short(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, ShortValueCodec, name) - fun long(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, VarLongValueCodec, name) - fun fixedLong(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, LongValueCodec, name) - fun float(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, FloatValueCodec, name) - fun double(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, DoubleValueCodec, name) - fun uuid(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, UUIDValueCodec, name) - fun int(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, VarIntValueCodec, name) - fun fixedInt(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, IntValueCodec, name) - fun fraction(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, ImpreciseFractionValueCodec, name) - fun bigDecimal(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, BigDecimalValueCodec, name) - fun item(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, ItemStackValueCodec, name) - fun string(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, BinaryStringCodec, name) + @JvmOverloads fun byte(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, ByteValueCodec, name) + @JvmOverloads fun bool(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, BooleanValueCodec, name) + @JvmOverloads fun short(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, ShortValueCodec, name) + @JvmOverloads fun long(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, VarLongValueCodec, name) + @JvmOverloads fun fixedLong(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, LongValueCodec, name) + @JvmOverloads fun float(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, FloatValueCodec, name) + @JvmOverloads fun double(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, DoubleValueCodec, name) + @JvmOverloads fun uuid(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, UUIDValueCodec, name) + @JvmOverloads fun int(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, VarIntValueCodec, name) + @JvmOverloads fun fixedInt(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, IntValueCodec, name) + @JvmOverloads fun fraction(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, ImpreciseFractionValueCodec, name) + @JvmOverloads fun bigDecimal(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, BigDecimalValueCodec, name) + @JvmOverloads fun item(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, ItemStackValueCodec, name) + @JvmOverloads fun string(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, BinaryStringCodec, name) - fun > enum(type: Class, getter: () -> T, name: String = nextFieldName()) = ComputedField(getter, EnumValueCodec(type), name) + @JvmOverloads fun > enum(type: Class, getter: () -> T, name: String = nextFieldName()) = ComputedField(getter, EnumValueCodec(type), name) inline fun > enum(noinline getter: () -> T, name: String = nextFieldName()) = ComputedField(getter, EnumValueCodec(T::class.java), name) - fun > enum(type: Class, getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, EnumValueCodec(type), name) + @JvmOverloads fun > enum(type: Class, getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, EnumValueCodec(type), name) inline fun > enum(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, EnumValueCodec(T::class.java), name) - fun > enum(type: Class, getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, EnumValueCodec(type), name) + @JvmOverloads fun > enum(type: Class, getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, EnumValueCodec(type), name) inline fun > enum(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, EnumValueCodec(T::class.java), name) + @JvmOverloads fun byte( value: Byte = 0, getter: FieldGetter? = null, @@ -221,6 +222,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return Field(value, ByteValueCodec, getter, setter, name = name) } + @JvmOverloads fun bool( value: Boolean = false, getter: FieldGetter? = null, @@ -230,6 +232,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return Field(value, BooleanValueCodec, getter, setter, name = name) } + @JvmOverloads fun short( value: Short = 0, getter: FieldGetter? = null, @@ -239,6 +242,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return Field(value, ShortValueCodec, getter, setter, name = name) } + @JvmOverloads fun long( value: Long = 0L, getter: FieldGetter? = null, @@ -248,6 +252,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return Field(value, VarLongValueCodec, getter, setter, name = name) } + @JvmOverloads fun fixedLong( value: Long = 0L, getter: FieldGetter? = null, @@ -257,6 +262,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return Field(value, LongValueCodec, getter, setter, name = name) } + @JvmOverloads fun float( value: Float = 0f, getter: FieldGetter? = null, @@ -266,6 +272,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return Field(value, FloatValueCodec, getter, setter, name = name) } + @JvmOverloads fun double( value: Double = 0.0, getter: FieldGetter? = null, @@ -275,6 +282,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return Field(value, DoubleValueCodec, getter, setter, name = name) } + @JvmOverloads fun uuid( value: UUID = UUID(0L, 0L), getter: FieldGetter? = null, @@ -284,6 +292,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return Field(value, UUIDValueCodec, getter, setter, name = name) } + @JvmOverloads fun int( value: Int = 0, getter: FieldGetter? = null, @@ -293,6 +302,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return Field(value, VarIntValueCodec, getter, setter, name = name) } + @JvmOverloads fun string( value: String = "", getter: FieldGetter? = null, @@ -302,6 +312,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return Field(value, BinaryStringCodec, getter, setter, name = name) } + @JvmOverloads fun fixedInt( value: Int = 0, getter: FieldGetter? = null, @@ -311,6 +322,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return Field(value, IntValueCodec, getter, setter, name = name) } + @JvmOverloads fun fraction( value: Decimal = Decimal.ZERO, getter: FieldGetter? = null, @@ -320,6 +332,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return Field(value, ImpreciseFractionValueCodec, getter, setter, name = name) } + @JvmOverloads fun bigDecimal( value: BigDecimal = BigDecimal.ZERO, getter: FieldGetter? = null, @@ -329,6 +342,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return Field(value, BigDecimalValueCodec, getter, setter, name = name) } + @JvmOverloads fun > enum( type: Class, value: T = type.enumConstants[0], @@ -339,6 +353,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return Field(value, EnumValueCodec(type), getter, setter, name = name) } + @JvmOverloads fun > enum( value: T, getter: FieldGetter? = null, @@ -348,6 +363,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return Field(value, EnumValueCodec(value::class.java), getter, setter, name = name) } + @JvmOverloads fun item( value: ItemStack = ItemStack.EMPTY, getter: FieldGetter? = null, @@ -358,6 +374,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return Field(value, ItemStackValueCodec, getter, setter, isObserver = observe, name = name) } + @JvmOverloads fun item( delegate: KMutableProperty0, name: String = nextFieldName(), @@ -365,6 +382,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return ObservedField(delegate, ItemStackValueCodec, name = name) } + @JvmOverloads fun map( keyCodec: IStreamCodec, valueCodec: IStreamCodec, From b817e9f290715864f930be7718650261a743c2d6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 29 Jan 2023 22:24:30 +0700 Subject: [PATCH 0144/1199] Allow to pass nulls as field name to use private next field name --- .../mc/otm/block/entity/RedstoneControl.kt | 3 +- .../mc/otm/network/FieldSynchronizer.kt | 168 +++++++++--------- 2 files changed, 86 insertions(+), 85 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt index 8f6e80e88..2fbd9561a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt @@ -65,7 +65,8 @@ class RedstoneControl(private val valueChanges: (new: Boolean, old: Boolean) -> class SynchronizedRedstoneControl( synchronizer: FieldSynchronizer, - private val valueChanges: (new: Boolean, old: Boolean) -> Unit + private val valueChanges: (new: Boolean, old: Boolean) -> Unit, + fieldNamePrefix: String? = null ) : AbstractRedstoneControl() { override var redstoneSetting: RedstoneSetting by synchronizer.enum(RedstoneSetting.LOW, setter = { value, access, setByRemote -> if (setByRemote) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt index 3d2187b5d..f969f2148 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt @@ -158,68 +158,68 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa hasChanges = false } - @JvmOverloads fun byte(getter: () -> Byte, name: String = nextFieldName()) = ComputedField(getter, ByteValueCodec, name) - @JvmOverloads fun bool(getter: () -> Boolean, name: String = nextFieldName()) = ComputedField(getter, BooleanValueCodec, name) - @JvmOverloads fun short(getter: () -> Short, name: String = nextFieldName()) = ComputedField(getter, ShortValueCodec, name) - @JvmOverloads fun long(getter: () -> Long, name: String = nextFieldName()) = ComputedField(getter, VarLongValueCodec, name) - @JvmOverloads fun fixedLong(getter: () -> Long, name: String = nextFieldName()) = ComputedField(getter, LongValueCodec, name) - @JvmOverloads fun float(getter: () -> Float, name: String = nextFieldName()) = ComputedField(getter, FloatValueCodec, name) - @JvmOverloads fun double(getter: () -> Double, name: String = nextFieldName()) = ComputedField(getter, DoubleValueCodec, name) - @JvmOverloads fun uuid(getter: () -> UUID, name: String = nextFieldName()) = ComputedField(getter, UUIDValueCodec, name) - @JvmOverloads fun int(getter: () -> Int, name: String = nextFieldName()) = ComputedField(getter, VarIntValueCodec, name) - @JvmOverloads fun fixedInt(getter: () -> Int, name: String = nextFieldName()) = ComputedField(getter, IntValueCodec, name) - @JvmOverloads fun fraction(getter: () -> Decimal, name: String = nextFieldName()) = ComputedField(getter, ImpreciseFractionValueCodec, name) - @JvmOverloads fun bigDecimal(getter: () -> BigDecimal, name: String = nextFieldName()) = ComputedField(getter, BigDecimalValueCodec, name) - @JvmOverloads fun item(getter: () -> ItemStack, name: String = nextFieldName()) = ComputedField(getter, ItemStackValueCodec, name) - @JvmOverloads fun string(getter: () -> String, name: String = nextFieldName()) = ComputedField(getter, BinaryStringCodec, name) + @JvmOverloads fun byte(getter: () -> Byte, name: String? = nextFieldName()) = ComputedField(getter, ByteValueCodec, name ?: nextFieldName()) + @JvmOverloads fun bool(getter: () -> Boolean, name: String? = nextFieldName()) = ComputedField(getter, BooleanValueCodec, name ?: nextFieldName()) + @JvmOverloads fun short(getter: () -> Short, name: String? = nextFieldName()) = ComputedField(getter, ShortValueCodec, name ?: nextFieldName()) + @JvmOverloads fun long(getter: () -> Long, name: String? = nextFieldName()) = ComputedField(getter, VarLongValueCodec, name ?: nextFieldName()) + @JvmOverloads fun fixedLong(getter: () -> Long, name: String? = nextFieldName()) = ComputedField(getter, LongValueCodec, name ?: nextFieldName()) + @JvmOverloads fun float(getter: () -> Float, name: String? = nextFieldName()) = ComputedField(getter, FloatValueCodec, name ?: nextFieldName()) + @JvmOverloads fun double(getter: () -> Double, name: String? = nextFieldName()) = ComputedField(getter, DoubleValueCodec, name ?: nextFieldName()) + @JvmOverloads fun uuid(getter: () -> UUID, name: String? = nextFieldName()) = ComputedField(getter, UUIDValueCodec, name ?: nextFieldName()) + @JvmOverloads fun int(getter: () -> Int, name: String? = nextFieldName()) = ComputedField(getter, VarIntValueCodec, name ?: nextFieldName()) + @JvmOverloads fun fixedInt(getter: () -> Int, name: String? = nextFieldName()) = ComputedField(getter, IntValueCodec, name ?: nextFieldName()) + @JvmOverloads fun fraction(getter: () -> Decimal, name: String? = nextFieldName()) = ComputedField(getter, ImpreciseFractionValueCodec, name ?: nextFieldName()) + @JvmOverloads fun bigDecimal(getter: () -> BigDecimal, name: String? = nextFieldName()) = ComputedField(getter, BigDecimalValueCodec, name ?: nextFieldName()) + @JvmOverloads fun item(getter: () -> ItemStack, name: String? = nextFieldName()) = ComputedField(getter, ItemStackValueCodec, name ?: nextFieldName()) + @JvmOverloads fun string(getter: () -> String, name: String? = nextFieldName()) = ComputedField(getter, BinaryStringCodec, name ?: nextFieldName()) - @JvmOverloads fun byte(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, ByteValueCodec, name) - @JvmOverloads fun bool(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, BooleanValueCodec, name) - @JvmOverloads fun short(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, ShortValueCodec, name) - @JvmOverloads fun long(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, VarLongValueCodec, name) - @JvmOverloads fun fixedLong(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, LongValueCodec, name) - @JvmOverloads fun float(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, FloatValueCodec, name) - @JvmOverloads fun double(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, DoubleValueCodec, name) - @JvmOverloads fun uuid(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, UUIDValueCodec, name) - @JvmOverloads fun int(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, VarIntValueCodec, name) - @JvmOverloads fun fixedInt(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, IntValueCodec, name) - @JvmOverloads fun fraction(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, ImpreciseFractionValueCodec, name) - @JvmOverloads fun bigDecimal(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, BigDecimalValueCodec, name) - @JvmOverloads fun item(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, ItemStackValueCodec, name) - @JvmOverloads fun string(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, BinaryStringCodec, name) + @JvmOverloads fun byte(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, ByteValueCodec, name ?: nextFieldName()) + @JvmOverloads fun bool(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, BooleanValueCodec, name ?: nextFieldName()) + @JvmOverloads fun short(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, ShortValueCodec, name ?: nextFieldName()) + @JvmOverloads fun long(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, VarLongValueCodec, name ?: nextFieldName()) + @JvmOverloads fun fixedLong(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, LongValueCodec, name ?: nextFieldName()) + @JvmOverloads fun float(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, FloatValueCodec, name ?: nextFieldName()) + @JvmOverloads fun double(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, DoubleValueCodec, name ?: nextFieldName()) + @JvmOverloads fun uuid(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, UUIDValueCodec, name ?: nextFieldName()) + @JvmOverloads fun int(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, VarIntValueCodec, name ?: nextFieldName()) + @JvmOverloads fun fixedInt(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, IntValueCodec, name ?: nextFieldName()) + @JvmOverloads fun fraction(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, ImpreciseFractionValueCodec, name ?: nextFieldName()) + @JvmOverloads fun bigDecimal(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, BigDecimalValueCodec, name ?: nextFieldName()) + @JvmOverloads fun item(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, ItemStackValueCodec, name ?: nextFieldName()) + @JvmOverloads fun string(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, BinaryStringCodec, name ?: nextFieldName()) - @JvmOverloads fun byte(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, ByteValueCodec, name) - @JvmOverloads fun bool(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, BooleanValueCodec, name) - @JvmOverloads fun short(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, ShortValueCodec, name) - @JvmOverloads fun long(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, VarLongValueCodec, name) - @JvmOverloads fun fixedLong(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, LongValueCodec, name) - @JvmOverloads fun float(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, FloatValueCodec, name) - @JvmOverloads fun double(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, DoubleValueCodec, name) - @JvmOverloads fun uuid(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, UUIDValueCodec, name) - @JvmOverloads fun int(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, VarIntValueCodec, name) - @JvmOverloads fun fixedInt(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, IntValueCodec, name) - @JvmOverloads fun fraction(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, ImpreciseFractionValueCodec, name) - @JvmOverloads fun bigDecimal(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, BigDecimalValueCodec, name) - @JvmOverloads fun item(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, ItemStackValueCodec, name) - @JvmOverloads fun string(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, BinaryStringCodec, name) + @JvmOverloads fun byte(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, ByteValueCodec, name ?: nextFieldName()) + @JvmOverloads fun bool(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, BooleanValueCodec, name ?: nextFieldName()) + @JvmOverloads fun short(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, ShortValueCodec, name ?: nextFieldName()) + @JvmOverloads fun long(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, VarLongValueCodec, name ?: nextFieldName()) + @JvmOverloads fun fixedLong(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, LongValueCodec, name ?: nextFieldName()) + @JvmOverloads fun float(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, FloatValueCodec, name ?: nextFieldName()) + @JvmOverloads fun double(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, DoubleValueCodec, name ?: nextFieldName()) + @JvmOverloads fun uuid(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, UUIDValueCodec, name ?: nextFieldName()) + @JvmOverloads fun int(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, VarIntValueCodec, name ?: nextFieldName()) + @JvmOverloads fun fixedInt(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, IntValueCodec, name ?: nextFieldName()) + @JvmOverloads fun fraction(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, ImpreciseFractionValueCodec, name ?: nextFieldName()) + @JvmOverloads fun bigDecimal(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, BigDecimalValueCodec, name ?: nextFieldName()) + @JvmOverloads fun item(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, ItemStackValueCodec, name ?: nextFieldName()) + @JvmOverloads fun string(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, BinaryStringCodec, name ?: nextFieldName()) - @JvmOverloads fun > enum(type: Class, getter: () -> T, name: String = nextFieldName()) = ComputedField(getter, EnumValueCodec(type), name) - inline fun > enum(noinline getter: () -> T, name: String = nextFieldName()) = ComputedField(getter, EnumValueCodec(T::class.java), name) + @JvmOverloads fun > enum(type: Class, getter: () -> T, name: String? = nextFieldName()) = ComputedField(getter, EnumValueCodec(type), name ?: nextFieldName()) + inline fun > enum(noinline getter: () -> T, name: String? = nextFieldName()) = ComputedField(getter, EnumValueCodec(T::class.java), name ?: nextFieldName()) - @JvmOverloads fun > enum(type: Class, getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, EnumValueCodec(type), name) - inline fun > enum(getter: KProperty0, name: String = nextFieldName()) = ComputedField(getter, EnumValueCodec(T::class.java), name) + @JvmOverloads fun > enum(type: Class, getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, EnumValueCodec(type), name ?: nextFieldName()) + inline fun > enum(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, EnumValueCodec(T::class.java), name ?: nextFieldName()) - @JvmOverloads fun > enum(type: Class, getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, EnumValueCodec(type), name) - inline fun > enum(getter: Supplier, name: String = nextFieldName()) = ComputedField(getter::get, EnumValueCodec(T::class.java), name) + @JvmOverloads fun > enum(type: Class, getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, EnumValueCodec(type), name ?: nextFieldName()) + inline fun > enum(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, EnumValueCodec(T::class.java), name ?: nextFieldName()) @JvmOverloads fun byte( value: Byte = 0, getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String = nextFieldName(), + name: String? = nextFieldName(), ): Field { - return Field(value, ByteValueCodec, getter, setter, name = name) + return Field(value, ByteValueCodec, getter, setter, name = name ?: nextFieldName()) } @JvmOverloads @@ -227,9 +227,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: Boolean = false, getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String = nextFieldName(), + name: String? = nextFieldName(), ): Field { - return Field(value, BooleanValueCodec, getter, setter, name = name) + return Field(value, BooleanValueCodec, getter, setter, name = name ?: nextFieldName()) } @JvmOverloads @@ -237,9 +237,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: Short = 0, getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String = nextFieldName(), + name: String? = nextFieldName(), ): Field { - return Field(value, ShortValueCodec, getter, setter, name = name) + return Field(value, ShortValueCodec, getter, setter, name = name ?: nextFieldName()) } @JvmOverloads @@ -247,9 +247,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: Long = 0L, getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String = nextFieldName(), + name: String? = nextFieldName(), ): Field { - return Field(value, VarLongValueCodec, getter, setter, name = name) + return Field(value, VarLongValueCodec, getter, setter, name = name ?: nextFieldName()) } @JvmOverloads @@ -257,9 +257,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: Long = 0L, getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String = nextFieldName(), + name: String? = nextFieldName(), ): Field { - return Field(value, LongValueCodec, getter, setter, name = name) + return Field(value, LongValueCodec, getter, setter, name = name ?: nextFieldName()) } @JvmOverloads @@ -267,9 +267,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: Float = 0f, getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String = nextFieldName(), + name: String? = nextFieldName(), ): Field { - return Field(value, FloatValueCodec, getter, setter, name = name) + return Field(value, FloatValueCodec, getter, setter, name = name ?: nextFieldName()) } @JvmOverloads @@ -277,9 +277,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: Double = 0.0, getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String = nextFieldName(), + name: String? = nextFieldName(), ): Field { - return Field(value, DoubleValueCodec, getter, setter, name = name) + return Field(value, DoubleValueCodec, getter, setter, name = name ?: nextFieldName()) } @JvmOverloads @@ -287,9 +287,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: UUID = UUID(0L, 0L), getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String = nextFieldName(), + name: String? = nextFieldName(), ): Field { - return Field(value, UUIDValueCodec, getter, setter, name = name) + return Field(value, UUIDValueCodec, getter, setter, name = name ?: nextFieldName()) } @JvmOverloads @@ -297,9 +297,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: Int = 0, getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String = nextFieldName(), + name: String? = nextFieldName(), ): Field { - return Field(value, VarIntValueCodec, getter, setter, name = name) + return Field(value, VarIntValueCodec, getter, setter, name = name ?: nextFieldName()) } @JvmOverloads @@ -307,9 +307,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: String = "", getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String = nextFieldName(), + name: String? = nextFieldName(), ): Field { - return Field(value, BinaryStringCodec, getter, setter, name = name) + return Field(value, BinaryStringCodec, getter, setter, name = name ?: nextFieldName()) } @JvmOverloads @@ -317,9 +317,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: Int = 0, getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String = nextFieldName(), + name: String? = nextFieldName(), ): Field { - return Field(value, IntValueCodec, getter, setter, name = name) + return Field(value, IntValueCodec, getter, setter, name = name ?: nextFieldName()) } @JvmOverloads @@ -327,9 +327,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: Decimal = Decimal.ZERO, getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String = nextFieldName(), + name: String? = nextFieldName(), ): Field { - return Field(value, ImpreciseFractionValueCodec, getter, setter, name = name) + return Field(value, ImpreciseFractionValueCodec, getter, setter, name = name ?: nextFieldName()) } @JvmOverloads @@ -337,9 +337,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: BigDecimal = BigDecimal.ZERO, getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String = nextFieldName(), + name: String? = nextFieldName(), ): Field { - return Field(value, BigDecimalValueCodec, getter, setter, name = name) + return Field(value, BigDecimalValueCodec, getter, setter, name = name ?: nextFieldName()) } @JvmOverloads @@ -348,9 +348,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: T = type.enumConstants[0], getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String = nextFieldName(), + name: String? = nextFieldName(), ): Field { - return Field(value, EnumValueCodec(type), getter, setter, name = name) + return Field(value, EnumValueCodec(type), getter, setter, name = name ?: nextFieldName()) } @JvmOverloads @@ -358,9 +358,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: T, getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String = nextFieldName(), + name: String? = nextFieldName(), ): Field { - return Field(value, EnumValueCodec(value::class.java), getter, setter, name = name) + return Field(value, EnumValueCodec(value::class.java), getter, setter, name = name ?: nextFieldName()) } @JvmOverloads @@ -369,17 +369,17 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa getter: FieldGetter? = null, setter: FieldSetter? = null, observe: Boolean = true, - name: String = nextFieldName(), + name: String? = nextFieldName(), ): Field { - return Field(value, ItemStackValueCodec, getter, setter, isObserver = observe, name = name) + return Field(value, ItemStackValueCodec, getter, setter, isObserver = observe, name = name ?: nextFieldName()) } @JvmOverloads fun item( delegate: KMutableProperty0, - name: String = nextFieldName(), + name: String? = nextFieldName(), ): ObservedField { - return ObservedField(delegate, ItemStackValueCodec, name = name) + return ObservedField(delegate, ItemStackValueCodec, name = name ?: nextFieldName()) } @JvmOverloads @@ -389,7 +389,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa callback: ((changes: Collection>) -> Unit)? = null, backingMap: MutableMap = HashMap(), observingBackingMap: MutableMap? = null, - name: String = nextFieldName(), + name: String? = nextFieldName(), ): Map { return Map( keyCodec = keyCodec, @@ -397,7 +397,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa callback = callback, backingMap = backingMap, observingBackingMap = observingBackingMap, - name = name, + name = name ?: nextFieldName(), ) } From 44c0422387ce0fa28c3d9cc858d8b5e5c5c5059f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 29 Jan 2023 22:25:28 +0700 Subject: [PATCH 0145/1199] Allow to specify field name prefix in SynchronizedRedstoneControl --- .../ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt index 2fbd9561a..bc4adde43 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt @@ -65,9 +65,11 @@ class RedstoneControl(private val valueChanges: (new: Boolean, old: Boolean) -> class SynchronizedRedstoneControl( synchronizer: FieldSynchronizer, + fieldNamePrefix: String?, private val valueChanges: (new: Boolean, old: Boolean) -> Unit, - fieldNamePrefix: String? = null ) : AbstractRedstoneControl() { + constructor(synchronizer: FieldSynchronizer, valueChanges: (new: Boolean, old: Boolean) -> Unit) : this(synchronizer, null, valueChanges) + override var redstoneSetting: RedstoneSetting by synchronizer.enum(RedstoneSetting.LOW, setter = { value, access, setByRemote -> if (setByRemote) { access.write(value) @@ -80,7 +82,7 @@ class SynchronizedRedstoneControl( valueChanges.invoke(state, old) } } - }) + }, name = if (fieldNamePrefix != null) "${fieldNamePrefix}_redstoneSetting" else null) override var redstoneSignal: Int by synchronizer.int(0, setter = { value, access, setByRemote -> if (setByRemote) { @@ -94,5 +96,5 @@ class SynchronizedRedstoneControl( valueChanges.invoke(state, old) } } - }) + }, name = if (fieldNamePrefix != null) "${fieldNamePrefix}_redstoneSignal" else null) } From b2998ccaa5ea92831baaa62f10139933aa3d5aba Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 29 Jan 2023 22:31:50 +0700 Subject: [PATCH 0146/1199] EnumValueCodec writeByIndices --- .../mc/otm/block/entity/RedstoneControl.kt | 2 +- .../dbotthepony/mc/otm/core/util/DataStreams.kt | 17 ++++++++++------- .../mc/otm/network/FieldSynchronizer.kt | 6 ++++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt index bc4adde43..1f0423382 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt @@ -82,7 +82,7 @@ class SynchronizedRedstoneControl( valueChanges.invoke(state, old) } } - }, name = if (fieldNamePrefix != null) "${fieldNamePrefix}_redstoneSetting" else null) + }, name = if (fieldNamePrefix != null) "${fieldNamePrefix}_redstoneSetting" else null, writeByIndices = true) override var redstoneSignal: Int by synchronizer.int(0, setter = { value, access, setByRemote -> if (setByRemote) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt index a41e5a94e..0e5b6303e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt @@ -75,21 +75,24 @@ val VarIntValueCodec = StreamCodec(DataInputStream::readVarIntLE, DataOutputStre val VarLongValueCodec = StreamCodec(DataInputStream::readVarLongLE, DataOutputStream::writeVarLongLE) val BinaryStringCodec = StreamCodec(DataInputStream::readBinaryString, DataOutputStream::writeBinaryString) -class EnumValueCodec>(private val clazz: Class) : IStreamCodec { +class EnumValueCodec>(clazz: Class, val writeByIndices: Boolean = false) : IStreamCodec { private val values = clazz.enumConstants override fun read(stream: DataInputStream): V { - val id = stream.readVarIntLE() - - if (id >= values.size) { - throw IndexOutOfBoundsException("Unable to read enum $clazz, no such enum at index $id") + if (writeByIndices) { + val id = stream.readVarIntLE() + return values.getOrNull(id) ?: throw NoSuchElementException("No such enum with index $id") } - return values[id] + val id = stream.readBinaryString() + return values.firstOrNull { id == it.name } ?: throw NoSuchElementException("No such enum $id") } override fun write(stream: DataOutputStream, value: V) { - stream.writeVarIntLE(value.ordinal) + if (writeByIndices) + stream.writeVarIntLE(value.ordinal) + else + stream.writeBinaryString(value.name) } override fun copy(value: V): V { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt index f969f2148..d3b1b5cd7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt @@ -348,9 +348,10 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: T = type.enumConstants[0], getter: FieldGetter? = null, setter: FieldSetter? = null, + writeByIndices: Boolean = false, name: String? = nextFieldName(), ): Field { - return Field(value, EnumValueCodec(type), getter, setter, name = name ?: nextFieldName()) + return Field(value, EnumValueCodec(type, writeByIndices = writeByIndices), getter, setter, name = name ?: nextFieldName()) } @JvmOverloads @@ -358,9 +359,10 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: T, getter: FieldGetter? = null, setter: FieldSetter? = null, + writeByIndices: Boolean = false, name: String? = nextFieldName(), ): Field { - return Field(value, EnumValueCodec(value::class.java), getter, setter, name = name ?: nextFieldName()) + return Field(value, EnumValueCodec(value::class.java, writeByIndices = writeByIndices), getter, setter, name = name ?: nextFieldName()) } @JvmOverloads From 4c7f68e66d9c7e340b02b1dabfde4792bb800809 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 29 Jan 2023 22:35:29 +0700 Subject: [PATCH 0147/1199] Specify redstone control field names if using secondary constructor --- .../ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt index 1f0423382..68a45e1df 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt @@ -68,7 +68,7 @@ class SynchronizedRedstoneControl( fieldNamePrefix: String?, private val valueChanges: (new: Boolean, old: Boolean) -> Unit, ) : AbstractRedstoneControl() { - constructor(synchronizer: FieldSynchronizer, valueChanges: (new: Boolean, old: Boolean) -> Unit) : this(synchronizer, null, valueChanges) + constructor(synchronizer: FieldSynchronizer, valueChanges: (new: Boolean, old: Boolean) -> Unit) : this(synchronizer, "", valueChanges) override var redstoneSetting: RedstoneSetting by synchronizer.enum(RedstoneSetting.LOW, setter = { value, access, setByRemote -> if (setByRemote) { From e6018bd9d7ebfdcdd0e94cb38ed6885282f872e8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 29 Jan 2023 22:38:55 +0700 Subject: [PATCH 0148/1199] Always call a callback when one of fields change --- .../mc/otm/block/entity/MatteryBlockEntity.kt | 7 +++++- .../mc/otm/block/entity/RedstoneControl.kt | 23 +++++++------------ .../entity/decorative/HoloSignBlockEntity.kt | 2 +- 3 files changed, 15 insertions(+), 17 deletions(-) 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 8b187d490..31fe08a0a 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 @@ -27,7 +27,12 @@ abstract class MatteryBlockEntity( p_155230_: BlockState ) : SynchronizedBlockEntity(p_155228_, p_155229_, p_155230_), MenuProvider, IRedstoneControlProvider { var customDisplayName: Component? = null - override val redstoneControl: AbstractRedstoneControl = RedstoneControl(::redstoneStatusUpdated) + override val redstoneControl: AbstractRedstoneControl = RedstoneControl { new, old -> + if (new != old) + redstoneStatusUpdated(new, old) + else + setChangedLight() + } protected open val defaultDisplayName: Component get() = level?.getBlockState(blockPos)?.block?.name ?: TextComponent("null at $blockPos") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt index 68a45e1df..5e112c7ae 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt @@ -43,23 +43,20 @@ abstract class AbstractRedstoneControl : INBTSerializable { class RedstoneControl(private val valueChanges: (new: Boolean, old: Boolean) -> Unit) : AbstractRedstoneControl() { override var redstoneSetting: RedstoneSetting = RedstoneSetting.LOW set(level) { + if (level == field) return val old = isBlockedByRedstone field = level val state = isBlockedByRedstone - - if (old != state) { - valueChanges.invoke(state, old) - } + valueChanges.invoke(state, old) } override var redstoneSignal: Int = 0 set(setting) { + if (setting == field) return val old = isBlockedByRedstone field = setting val state = isBlockedByRedstone - if (old != state) { - valueChanges.invoke(state, old) - } + valueChanges.invoke(state, old) } } @@ -71,30 +68,26 @@ class SynchronizedRedstoneControl( constructor(synchronizer: FieldSynchronizer, valueChanges: (new: Boolean, old: Boolean) -> Unit) : this(synchronizer, "", valueChanges) override var redstoneSetting: RedstoneSetting by synchronizer.enum(RedstoneSetting.LOW, setter = { value, access, setByRemote -> + if (access.read() == value) return@enum if (setByRemote) { access.write(value) } else { val old = isBlockedByRedstone access.write(value) val state = isBlockedByRedstone - - if (old != state) { - valueChanges.invoke(state, old) - } + valueChanges.invoke(state, old) } }, name = if (fieldNamePrefix != null) "${fieldNamePrefix}_redstoneSetting" else null, writeByIndices = true) override var redstoneSignal: Int by synchronizer.int(0, setter = { value, access, setByRemote -> + if (access.read() == value) return@int if (setByRemote) { access.write(value) } else { val old = isBlockedByRedstone access.write(value) val state = isBlockedByRedstone - - if (old != state) { - valueChanges.invoke(state, old) - } + valueChanges.invoke(state, old) } }, name = if (fieldNamePrefix != null) "${fieldNamePrefix}_redstoneSignal" else null) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt index f5b3abfbc..9429d3251 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt @@ -17,7 +17,7 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlocks class HoloSignBlockEntity(blockPos: BlockPos, blockState: BlockState) : SynchronizedBlockEntity(MBlockEntities.HOLO_SIGN, blockPos, blockState), MenuProvider, IRedstoneControlProvider { - override val redstoneControl = SynchronizedRedstoneControl(synchronizer) { _, _ -> } + override val redstoneControl = SynchronizedRedstoneControl(synchronizer) { _, _ -> setChanged() } var text by synchronizer.string("", name = "text", setter = { value, access, remote -> setChanged() From c6cdc6c3a295b404441e54e0f65cd67bb120ef9c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 29 Jan 2023 23:02:15 +0700 Subject: [PATCH 0149/1199] Stop eating exceptions --- .../dbotthepony/mc/otm/network/WorldNetworkChannel.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt index 6eac71721..f9d56b474 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt @@ -5,6 +5,7 @@ import net.minecraft.core.BlockPos import net.minecraft.network.FriendlyByteBuf import net.minecraftforge.network.NetworkDirection import net.minecraftforge.network.NetworkEvent +import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.android.feature.ItemEntityDataPacket import ru.dbotthepony.mc.otm.block.entity.SynchronizedBlockEntity import ru.dbotthepony.mc.otm.client.minecraft @@ -22,7 +23,13 @@ class BlockEntitySyncPacket(val position: BlockPos, val buffer: ByteArray, val v context.enqueueWork { val level = minecraft.player?.level ?: return@enqueueWork val blockEntity = level.getBlockEntity(position) as? SynchronizedBlockEntity ?: return@enqueueWork - blockEntity.synchronizer.applyNetworkPayload(FastByteArrayInputStream(buffer, 0, validBytes)) + + try { + blockEntity.synchronizer.applyNetworkPayload(FastByteArrayInputStream(buffer, 0, validBytes)) + } catch(err: Throwable) { + LOGGER.error("Exception while reading synchronized BlockEntity data!\nPosition: $position\nBlock: ${level.getBlockState(position)}\nBlock entity: $blockEntity", err) + throw err + } } } @@ -34,6 +41,8 @@ class BlockEntitySyncPacket(val position: BlockPos, val buffer: ByteArray, val v buff.readBytes(array) return BlockEntitySyncPacket(position, array, size) } + + private val LOGGER = LogManager.getLogger() } } From 45ec6d14283308bb3c3436a324993978ca6fc56c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 29 Jan 2023 23:02:37 +0700 Subject: [PATCH 0150/1199] Add null check in EnumValueCodec --- src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt index 0e5b6303e..516a47e4d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt @@ -76,7 +76,7 @@ val VarLongValueCodec = StreamCodec(DataInputStream::readVarLongLE, DataOutputSt val BinaryStringCodec = StreamCodec(DataInputStream::readBinaryString, DataOutputStream::writeBinaryString) class EnumValueCodec>(clazz: Class, val writeByIndices: Boolean = false) : IStreamCodec { - private val values = clazz.enumConstants + private val values = clazz.enumConstants ?: throw ClassCastException("$clazz does not have enum constants. Not an enum?") override fun read(stream: DataInputStream): V { if (writeByIndices) { From a99dab51b4cacc7294961a3a46313c03af2db61e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 29 Jan 2023 23:19:40 +0700 Subject: [PATCH 0151/1199] fix enums --- .../mc/otm/core/util/DataStreams.kt | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt index 516a47e4d..83ca6a005 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt @@ -76,7 +76,7 @@ val VarLongValueCodec = StreamCodec(DataInputStream::readVarLongLE, DataOutputSt val BinaryStringCodec = StreamCodec(DataInputStream::readBinaryString, DataOutputStream::writeBinaryString) class EnumValueCodec>(clazz: Class, val writeByIndices: Boolean = false) : IStreamCodec { - private val values = clazz.enumConstants ?: throw ClassCastException("$clazz does not have enum constants. Not an enum?") + private val values = search(clazz) ?: throw ClassCastException("$clazz does not have enum constants. Not an enum?") override fun read(stream: DataInputStream): V { if (writeByIndices) { @@ -102,6 +102,23 @@ class EnumValueCodec>(clazz: Class, val writeByIndices: Boole override fun compare(a: V, b: V): Boolean { return a === b } + + companion object { + /** + * FIXME: enums with abstract methods which get compiled to subclasses, whose DO NOT expose "parent's" enum constants array + * + * is there an already existing solution? + */ + fun > search(clazz: Class): Array? { + var search: Class<*> = clazz + + while (search.enumConstants == null && search.superclass != null) { + search = search.superclass + } + + return search.enumConstants as? Array + } + } } fun OutputStream.writeInt(value: Int) { From e2791add3bdb295ba82e89370b77b6999ac77f9e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 30 Jan 2023 11:10:14 +0700 Subject: [PATCH 0152/1199] Add BlockRotationFreedom and BlockRotation without changing any logic --- .../mc/otm/datagen/DecorativeData.kt | 9 +- .../mc/otm/datagen/blocks/Banks.kt | 11 +- .../mc/otm/datagen/blocks/BlockStates.kt | 67 ++++----- .../otm/datagen/blocks/ComplexBlockStates.kt | 21 +-- .../blocks/MatteryBlockStateProvider.kt | 11 +- .../ru/dbotthepony/mc/otm/block/Cables.kt | 22 ++- .../mc/otm/block/IDroppableContainer.kt | 21 +++ .../dbotthepony/mc/otm/block/MatteryBlock.kt | 100 +------------ .../mc/otm/block/RotatableMatteryBlock.kt | 51 +++++++ .../mc/otm/block/decorative/EngineBlock.kt | 8 +- .../mc/otm/block/decorative/HoloSignBlock.kt | 10 +- .../mc/otm/block/decorative/LaboratoryLamp.kt | 23 +-- .../dbotthepony/mc/otm/block/entity/Cables.kt | 8 +- .../entity/storage/StorageBusBlockEntity.kt | 12 +- .../block/entity/storage/StorageInterfaces.kt | 12 +- .../entity/tech/BatteryBankBlockEntity.kt | 10 +- .../tech/ChemicalGeneratorBlockEntity.kt | 3 +- .../tech/GravitationStabilizerBlockEntity.kt | 3 +- .../mc/otm/block/matter/MatterBottlerBlock.kt | 3 +- .../block/matter/MatterCapacitorBankBlock.kt | 3 +- .../otm/block/matter/MatterDecomposerBlock.kt | 5 +- .../mc/otm/block/matter/MatterPanelBlock.kt | 14 +- .../otm/block/matter/MatterRecyclerBlock.kt | 3 +- .../otm/block/matter/MatterReplicatorBlock.kt | 5 +- .../mc/otm/block/matter/MatterScannerBlock.kt | 5 +- .../otm/block/matter/PatternStorageBlock.kt | 5 +- .../mc/otm/block/storage/DriveRackBlock.kt | 3 +- .../mc/otm/block/storage/DriveViewerBlock.kt | 3 +- .../mc/otm/block/storage/ItemMonitorBlock.kt | 3 +- .../mc/otm/block/storage/StorageBusBlock.kt | 11 +- .../mc/otm/block/storage/StorageInterfaces.kt | 19 ++- .../storage/StoragePowerSupplierBlock.kt | 3 +- .../mc/otm/block/tech/BatteryBankBlock.kt | 3 +- .../otm/block/tech/ChemicalGeneratorBlock.kt | 3 +- .../mc/otm/block/tech/EnergyServoBlock.kt | 3 +- .../block/tech/GravitationStabilizerBlock.kt | 28 ++-- .../otm/block/tech/PhantomAttractorBlock.kt | 3 +- .../mc/otm/block/tech/PlatePressBlock.kt | 3 +- .../client/render/blockentity/BankRenderer.kt | 3 +- .../GravitationStabilizerRenderer.kt | 5 +- .../render/blockentity/HoloSignRenderer.kt | 3 +- .../mc/otm/core/math/BlockRotation.kt | 137 ++++++++++++++++++ .../mc/otm/core/math/BlockRotationFreedom.kt | 50 +++++++ 43 files changed, 480 insertions(+), 248 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/IDroppableContainer.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/RotatableMatteryBlock.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotationFreedom.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt index d574dc669..fe4d252be 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt @@ -11,6 +11,7 @@ import net.minecraftforge.client.model.generators.ModelFile import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.datagen.blocks.MatteryBlockStateProvider import ru.dbotthepony.mc.otm.datagen.items.MatteryItemModelProvider @@ -216,16 +217,16 @@ fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelPr blockStateProvider.getVariantBuilder(MBlocks.LABORATORY_LAMP).forAllStates { return@forAllStates ConfiguredModel.builder() .modelFile(if (it[BlockStateProperties.LIT]) labLampOn!! else labLampOff!!) - .rotationX(it[RotatableMatteryBlock.FACING_FULL].toXRotBlockstate()) - .rotationY(it[RotatableMatteryBlock.FACING_FULL].toYRotBlockstate()) + .rotationX(it[BlockRotationFreedom.TWO.property].primary.toXRotBlockstate()) + .rotationY(it[BlockRotationFreedom.TWO.property].primary.toYRotBlockstate()) .build() } blockStateProvider.getVariantBuilder(MBlocks.LABORATORY_LAMP_INVERTED).forAllStates { return@forAllStates ConfiguredModel.builder() .modelFile(if (it[BlockStateProperties.LIT]) labLampOn!! else labLampOff!!) - .rotationX(it[RotatableMatteryBlock.FACING_FULL].toXRotBlockstate()) - .rotationY(it[RotatableMatteryBlock.FACING_FULL].toYRotBlockstate()) + .rotationX(it[BlockRotationFreedom.TWO.property].primary.toXRotBlockstate()) + .rotationY(it[BlockRotationFreedom.TWO.property].primary.toYRotBlockstate()) .build() } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt index b17567cde..8fe6a9ede 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt @@ -6,6 +6,7 @@ import net.minecraftforge.client.model.generators.BlockStateProvider import net.minecraftforge.data.event.GatherDataEvent import ru.dbotthepony.mc.otm.block.tech.BatteryBankBlock import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.datagen.DataGen import ru.dbotthepony.mc.otm.datagen.toYRotBlockstate import ru.dbotthepony.mc.otm.registry.MBlocks @@ -26,15 +27,15 @@ open class BatteryBankProvider(event: GatherDataEvent) : BlockStateProvider(even with(getMultipartBuilder(registry)) { val battery_bank = models().getExistingFile(ResourceLocation("overdrive_that_matters:block/$block")) - RotatableMatteryBlock.FACING.possibleValues.forEach { - part().modelFile(battery_bank).rotationY(it.toYRotBlockstate()).addModel().condition( - RotatableMatteryBlock.FACING, it) + BlockRotationFreedom.ONE.possibleValues.forEach { + part().modelFile(battery_bank).rotationY(it.primary.toYRotBlockstate()).addModel().condition( + BlockRotationFreedom.ONE.property, it) for (i in 0 .. 11) { part().modelFile( models().getExistingFile(ResourceLocation("overdrive_that_matters:$batteryPath$i")) - ).rotationY(it.toYRotBlockstate()).addModel() - .condition(RotatableMatteryBlock.FACING, it) + ).rotationY(it.primary.toYRotBlockstate()).addModel() + .condition(BlockRotationFreedom.ONE.property, it) .condition(BatteryBankBlock.BATTERY_SLOTS_PROPS[i], true) } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt index 6869638f6..e83b8671b 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt @@ -10,6 +10,7 @@ import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock +import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.datagen.modLocation import ru.dbotthepony.mc.otm.datagen.toXRotBlockstate @@ -36,41 +37,41 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { provider.exec { with(provider.getMultipartBuilder(MBlocks.PHANTOM_ATTRACTOR)) { - for (dir in RotatableMatteryBlock.FACING.possibleValues) { + for (dir in BlockRotationFreedom.ONE.possibleValues) { part().modelFile(provider.models().getExistingFile(modLocation("block/${MNames.PHANTOM_ATTRACTOR}"))) - .rotationY(dir.toYRotBlockstate()) + .rotationY(dir.primary.toYRotBlockstate()) .addModel() .condition(BlockStateProperties.DOUBLE_BLOCK_HALF, DoubleBlockHalf.LOWER) - .condition(RotatableMatteryBlock.FACING, dir) + .condition(BlockRotationFreedom.ONE.property, dir) .end() } } with(provider.getMultipartBuilder(MBlocks.MATTER_BOTTLER)) { - for (dir in RotatableMatteryBlock.FACING.possibleValues) { + for (dir in BlockRotationFreedom.ONE.possibleValues) { for (enum in WorkerState.SEMI_WORKER_STATE.possibleValues) { part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_bottler_${enum.name.lowercase()}"))) - .rotationY(dir.toYRotBlockstate()) + .rotationY(dir.primary.toYRotBlockstate()) .addModel() - .condition(RotatableMatteryBlock.FACING, dir) + .condition(BlockRotationFreedom.ONE.property, dir) .condition(WorkerState.WORKER_STATE, enum) .end() } } - for (dir in RotatableMatteryBlock.FACING.possibleValues) { + for (dir in BlockRotationFreedom.ONE.possibleValues) { for (enum in MatterBottlerBlock.SLOT_PROPERTIES) { part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_bottler_${enum.name}_open"))) - .rotationY(dir.toYRotBlockstate()) + .rotationY(dir.primary.toYRotBlockstate()) .addModel() - .condition(RotatableMatteryBlock.FACING, dir) + .condition(BlockRotationFreedom.ONE.property, dir) .condition(enum, false) .end() part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_bottler_${enum.name}_closed"))) - .rotationY(dir.toYRotBlockstate()) + .rotationY(dir.primary.toYRotBlockstate()) .addModel() - .condition(RotatableMatteryBlock.FACING, dir) + .condition(BlockRotationFreedom.ONE.property, dir) .condition(enum, true) .end() } @@ -98,26 +99,26 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { OverdriveThatMatters.MOD_ID, "${crate.registryName!!.path}_${if (it.getValue( CargoCrateBlock.IS_OPEN)) "open" else "closed"}") )) - .rotationY(it.getValue(RotatableMatteryBlock.FACING).toYRotBlockstate()) + .rotationY(it.getValue(BlockRotationFreedom.ONE.property).primary.toYRotBlockstate()) .buildLast() ) } } with(provider.getMultipartBuilder(MBlocks.STORAGE_BUS)) { - for (dir in net.minecraft.core.Direction.values()) { + for (dir in BlockRotationFreedom.TWO.possibleValues) { part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_bus"))) - .rotationX(dir.toXRotBlockstate()) - .rotationY(dir.toYRotBlockstate()) + .rotationX(dir.primary.toXRotBlockstate()) + .rotationY(dir.primary.toYRotBlockstate()) .addModel() - .condition(RotatableMatteryBlock.FACING_FULL, dir) + .condition(BlockRotationFreedom.TWO.property, dir) .end() part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_connection"))) - .rotationX(dir.toXRotBlockstateInv()) - .rotationY(dir.toYRotBlockstateInv()) + .rotationX(dir.primary.toXRotBlockstateInv()) + .rotationY(dir.primary.toYRotBlockstateInv()) .addModel() - .condition(CableBlock.MAPPING_CONNECTION_PROP[dir.ordinal], true) + .condition(CableBlock.MAPPING_CONNECTION_PROP[dir.primary]!!, true) .end() } @@ -126,19 +127,19 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { } with(provider.getMultipartBuilder(MBlocks.STORAGE_IMPORTER)) { - for (dir in net.minecraft.core.Direction.values()) { + for (dir in BlockRotationFreedom.TWO.possibleValues) { part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_importer"))) - .rotationX(dir.toXRotBlockstate()) - .rotationY(dir.toYRotBlockstate()) + .rotationX(dir.primary.toXRotBlockstate()) + .rotationY(dir.primary.toYRotBlockstate()) .addModel() - .condition(RotatableMatteryBlock.FACING_FULL, dir) + .condition(BlockRotationFreedom.TWO.property, dir) .end() part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_connection"))) - .rotationX(dir.toXRotBlockstateInv()) - .rotationY(dir.toYRotBlockstateInv()) + .rotationX(dir.primary.toXRotBlockstateInv()) + .rotationY(dir.primary.toYRotBlockstateInv()) .addModel() - .condition(CableBlock.MAPPING_CONNECTION_PROP[dir.ordinal], true) + .condition(CableBlock.MAPPING_CONNECTION_PROP[dir.primary]!!, true) .end() } @@ -147,19 +148,19 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { } with(provider.getMultipartBuilder(MBlocks.STORAGE_EXPORTER)) { - for (dir in net.minecraft.core.Direction.values()) { + for (dir in BlockRotationFreedom.TWO.possibleValues) { part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_exporter"))) - .rotationX(dir.toXRotBlockstate()) - .rotationY(dir.toYRotBlockstate()) + .rotationX(dir.primary.toXRotBlockstate()) + .rotationY(dir.primary.toYRotBlockstate()) .addModel() - .condition(RotatableMatteryBlock.FACING_FULL, dir) + .condition(BlockRotationFreedom.TWO.property, dir) .end() part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_connection"))) - .rotationX(dir.toXRotBlockstateInv()) - .rotationY(dir.toYRotBlockstateInv()) + .rotationX(dir.primary.toXRotBlockstateInv()) + .rotationY(dir.primary.toYRotBlockstateInv()) .addModel() - .condition(CableBlock.MAPPING_CONNECTION_PROP[dir.ordinal], true) + .condition(CableBlock.MAPPING_CONNECTION_PROP[dir.primary]!!, true) .end() } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt index 352e4cf28..4deeb9760 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt @@ -7,45 +7,46 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.matter.PatternStorageBlock import ru.dbotthepony.mc.otm.block.storage.DriveViewerBlock +import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.datagen.DataGen.MOD_ID import ru.dbotthepony.mc.otm.datagen.toYRotBlockstate import ru.dbotthepony.mc.otm.registry.MBlocks fun addComplexBlockStates(provider: MatteryBlockStateProvider) { with(provider.getMultipartBuilder(MBlocks.DRIVE_VIEWER)) { - for (facing in RotatableMatteryBlock.FACING.possibleValues) { + for (facing in BlockRotationFreedom.ONE.possibleValues) { part() .modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/drive_viewer_drive_part"))) - .rotationY(facing.toYRotBlockstate()) + .rotationY(facing.primary.toYRotBlockstate()) .addModel() - .condition(RotatableMatteryBlock.FACING, facing) + .condition(BlockRotationFreedom.ONE.property, facing) .condition(DriveViewerBlock.DRIVE_PRESENT, true) for (workState in WorkerState.SEMI_WORKER_STATE.possibleValues) { part() .modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/drive_viewer_${workState.name.lowercase()}"))) - .rotationY(facing.toYRotBlockstate()) + .rotationY(facing.primary.toYRotBlockstate()) .addModel() .condition(WorkerState.SEMI_WORKER_STATE, workState) - .condition(RotatableMatteryBlock.FACING, facing) + .condition(BlockRotationFreedom.ONE.property, facing) } } } with(provider.getMultipartBuilder(MBlocks.PATTERN_STORAGE)) { - for (facing in RotatableMatteryBlock.FACING.possibleValues) { + for (facing in BlockRotationFreedom.ONE.possibleValues) { part() .modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/pattern_storage"))) - .rotationY(facing.toYRotBlockstate()) + .rotationY(facing.primary.toYRotBlockstate()) .addModel() - .condition(RotatableMatteryBlock.FACING, facing) + .condition(BlockRotationFreedom.ONE.property, facing) for (i in 0 .. 7) { part() .modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/pattern/model$i"))) - .rotationY(facing.toYRotBlockstate()) + .rotationY(facing.primary.toYRotBlockstate()) .addModel() - .condition(RotatableMatteryBlock.FACING, facing) + .condition(BlockRotationFreedom.ONE.property, facing) .condition(PatternStorageBlock.PATTERN_STORAGE_DISKS_PROPS[i], true) } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt index ffd7cf4ed..e41abe868 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt @@ -8,6 +8,7 @@ import net.minecraftforge.client.model.generators.ConfiguredModel import net.minecraftforge.data.event.GatherDataEvent import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.datagen.DataGen import ru.dbotthepony.mc.otm.datagen.getValueNullable import ru.dbotthepony.mc.otm.datagen.toXRotBlockstate @@ -21,13 +22,13 @@ private val EMPTY: BlockStateTransform = { _, _, _ -> null } private fun initialTransform(it: BlockState, modelPath: String, builder: ConfiguredModel.Builder<*>): String { @Suppress("NAME_SHADOWING") var modelPath = modelPath - it.getValueNullable(RotatableMatteryBlock.FACING)?.let { - builder.rotationY(it.toYRotBlockstate()) + it.getValueNullable(BlockRotationFreedom.ONE.property)?.let { + builder.rotationY(it.primary.toYRotBlockstate()) } - it.getValueNullable(RotatableMatteryBlock.FACING_FULL)?.let { - builder.rotationY(it.toYRotBlockstate()) - builder.rotationX(it.toXRotBlockstate()) + it.getValueNullable(BlockRotationFreedom.TWO.property)?.let { + builder.rotationY(it.primary.toYRotBlockstate()) + builder.rotationX(it.primary.toXRotBlockstate()) } it.getValueNullable(WorkerState.WORKER_STATE)?.let { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt index d48726a54..ad9f67f30 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt @@ -4,6 +4,7 @@ package ru.dbotthepony.mc.otm.block import net.minecraft.core.BlockPos +import net.minecraft.core.Direction import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.EntityBlock @@ -19,6 +20,9 @@ import net.minecraft.world.phys.shapes.Shapes import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.entity.MatterCableBlockEntity import ru.dbotthepony.mc.otm.block.entity.StorageCableBlockEntity +import ru.dbotthepony.mc.otm.core.math.BlockRotation +import java.util.Collections +import java.util.EnumMap abstract class CableBlock(properties: Properties) : Block(properties) { init { @@ -52,14 +56,16 @@ abstract class CableBlock(properties: Properties) : Block(properties) { val CONNECTION_UP: BooleanProperty = BooleanProperty.create("connect_up") val CONNECTION_DOWN: BooleanProperty = BooleanProperty.create("connect_down") - val MAPPING_CONNECTION_PROP = listOf( - CONNECTION_DOWN, - CONNECTION_UP, - CONNECTION_NORTH, - CONNECTION_SOUTH, - CONNECTION_WEST, - CONNECTION_EAST - ) + val MAPPING_CONNECTION_PROP: Map = EnumMap(Direction::class.java) + .let { + it[Direction.DOWN] = CONNECTION_DOWN + it[Direction.UP] = CONNECTION_UP + it[Direction.NORTH] = CONNECTION_NORTH + it[Direction.SOUTH] = CONNECTION_SOUTH + it[Direction.WEST] = CONNECTION_WEST + it[Direction.EAST] = CONNECTION_EAST + Collections.unmodifiableMap(it) + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/IDroppableContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/IDroppableContainer.kt new file mode 100644 index 000000000..e542b303f --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/IDroppableContainer.kt @@ -0,0 +1,21 @@ +package ru.dbotthepony.mc.otm.block + +import net.minecraft.core.BlockPos +import net.minecraft.world.Container +import net.minecraft.world.entity.player.Player +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.state.BlockState + +interface IDroppableContainer { + val droppableContainer: Container + + fun beforeDroppingItems( + oldBlockState: BlockState, + level: Level, + blockPos: BlockPos, + newBlockState: BlockState, + movedByPiston: Boolean + ) {} + + fun beforeDestroyedByPlayer(level: Level, blockPos: BlockPos, blockState: BlockState, player: Player) {} +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt index b8e854b1d..892393764 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt @@ -4,7 +4,6 @@ import net.minecraft.core.BlockPos import net.minecraft.core.Direction import net.minecraft.core.particles.DustParticleOptions import net.minecraft.util.RandomSource -import net.minecraft.world.Container import net.minecraft.world.Containers import net.minecraft.world.InteractionHand import net.minecraft.world.InteractionResult @@ -12,38 +11,20 @@ import net.minecraft.world.MenuProvider import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.player.Player import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.context.BlockPlaceContext import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.EntityBlock -import net.minecraft.world.level.block.Rotation import net.minecraft.world.level.block.state.BlockState -import net.minecraft.world.level.block.state.StateDefinition -import net.minecraft.world.level.block.state.properties.EnumProperty import net.minecraft.world.level.material.Material import net.minecraft.world.level.material.MaterialColor import net.minecraft.world.phys.BlockHitResult import ru.dbotthepony.mc.otm.block.entity.IRedstoneControlProvider import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.math.component1 import ru.dbotthepony.mc.otm.core.math.component2 import ru.dbotthepony.mc.otm.core.math.component3 -import ru.dbotthepony.mc.otm.core.get - -interface IDroppableContainer { - val droppableContainer: Container - - fun beforeDroppingItems( - oldBlockState: BlockState, - level: Level, - blockPos: BlockPos, - newBlockState: BlockState, - movedByPiston: Boolean - ) {} - - fun beforeDestroyedByPlayer(level: Level, blockPos: BlockPos, blockState: BlockState, player: Player) {} -} abstract class MatteryBlock @JvmOverloads constructor( properties: Properties = DEFAULT_PROPERTIES @@ -94,7 +75,9 @@ abstract class MatteryBlock @JvmOverloads constructor( val state = blockState.getOptionalValue(WorkerState.WORKER_STATE).or { blockState.getOptionalValue(WorkerState.SEMI_WORKER_STATE) } if (state.isPresent && state.get() == WorkerState.WORKING) { - val state2 = blockState.getOptionalValue(RotatableMatteryBlock.FACING).or { blockState.getOptionalValue(RotatableMatteryBlock.FACING_FULL) } + val state2 = blockState.getOptionalValue(BlockRotationFreedom.ONE.property) + .or { blockState.getOptionalValue(BlockRotationFreedom.TWO.property) } + .or { blockState.getOptionalValue(BlockRotationFreedom.THREE.property) } if (state2.isPresent) { val direction = state2.get() @@ -109,7 +92,7 @@ abstract class MatteryBlock @JvmOverloads constructor( yd += ny * 0.5 zd += nz * 0.5 - when (direction) { + when (direction.primary) { Direction.DOWN, Direction.UP -> { xd += random.nextDouble() - 0.5 zd += random.nextDouble() - 0.5 @@ -201,76 +184,3 @@ abstract class MatteryBlock @JvmOverloads constructor( } } -abstract class RotatableMatteryBlock @JvmOverloads constructor(properties: Properties = DEFAULT_PROPERTIES) : MatteryBlock(properties) { - init { - @Suppress("LeakingThis") - registerDefaultState(getStateDefinition().any().setValue(facingProperty, Direction.SOUTH)) - } - - override fun createBlockStateDefinition(builder: StateDefinition.Builder) { - builder.add(facingProperty) - } - - override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { - if (hasFreeRotation) { - return defaultBlockState().setValue( - FACING_FULL, - if (faceToPlayer(context)) context.nearestLookingDirection.opposite else context.nearestLookingDirection - ) - } else { - return defaultBlockState().setValue( - FACING, - if (faceToPlayer(context)) context.horizontalDirection.opposite else context.horizontalDirection - ) - } - } - - @Suppress("OVERRIDE_DEPRECATION") - override fun rotate(blockState: BlockState, rotation: Rotation): BlockState { - @Suppress("DEPRECATION") - return super.rotate(blockState, rotation).setValue(facingProperty, rotation.rotate(blockState[facingProperty])) - } - - val facingProperty get() = if (hasFreeRotation) FACING_FULL else FACING - open val hasFreeRotation get() = false - - open fun faceToPlayer(context: BlockPlaceContext): Boolean { - return true - } - - companion object { - /** - * Allows to instance [RotatableMatteryBlock] directly - */ - fun make(properties: Properties, hasFreeRotation: Boolean = false, faceToPlayer: Boolean = true): RotatableMatteryBlock { - if (hasFreeRotation) { // can't have one class for two cases - superclass (both in OTM and in Minecraft) are leaking "this" - return object : RotatableMatteryBlock(properties) { - override val hasFreeRotation get() = true // this is accessed from superclass constructor - - override fun faceToPlayer(context: BlockPlaceContext): Boolean { - return faceToPlayer - } - } - } else { - return object : RotatableMatteryBlock(properties) { - override val hasFreeRotation get() = false // this is accessed from superclass constructor - - override fun faceToPlayer(context: BlockPlaceContext): Boolean { - return faceToPlayer - } - } - } - } - - val FACING: EnumProperty = EnumProperty.create( - "facing", - Direction::class.java, - Direction.SOUTH, - Direction.WEST, - Direction.NORTH, - Direction.EAST - ) - - val FACING_FULL: EnumProperty = EnumProperty.create("facing", Direction::class.java) - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/RotatableMatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/RotatableMatteryBlock.kt new file mode 100644 index 000000000..248123fbf --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/RotatableMatteryBlock.kt @@ -0,0 +1,51 @@ +package ru.dbotthepony.mc.otm.block + +import net.minecraft.world.item.context.BlockPlaceContext +import net.minecraft.world.level.block.Block +import net.minecraft.world.level.block.Rotation +import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.level.block.state.StateDefinition +import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.core.math.BlockRotation +import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom + +abstract class RotatableMatteryBlock @JvmOverloads constructor(properties: Properties = DEFAULT_PROPERTIES) : MatteryBlock(properties) { + init { + @Suppress("LeakingThis") + registerDefaultState(getStateDefinition().any().setValue(rotationProperty, BlockRotation.SOUTH)) + } + + override fun createBlockStateDefinition(builder: StateDefinition.Builder) { + builder.add(rotationProperty) + } + + override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { + if (rotationFreedom() == BlockRotationFreedom.ONE) { + return defaultBlockState().setValue( + rotationProperty, + BlockRotation.of(if (faceToPlayer(context)) context.horizontalDirection.opposite else context.horizontalDirection) + ) + } else { + return defaultBlockState().setValue( + rotationProperty, + BlockRotation.of(if (faceToPlayer(context)) context.nearestLookingDirection.opposite else context.nearestLookingDirection) + ) + } + } + + @Suppress("OVERRIDE_DEPRECATION") + override fun rotate(blockState: BlockState, rotation: Rotation): BlockState { + @Suppress("DEPRECATION") + return super.rotate(blockState, rotation).setValue(rotationProperty, blockState[rotationProperty].rotate(rotation)) + } + + val rotationProperty get() = rotationFreedom().property + + open fun rotationFreedom(): BlockRotationFreedom { + return BlockRotationFreedom.ONE + } + + open fun faceToPlayer(context: BlockPlaceContext): Boolean { + return true + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt index d7a569582..c3103284c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt @@ -9,14 +9,16 @@ import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.shapes.BlockShapes class EngineBlock : RotatableMatteryBlock(Properties.of(Material.METAL, DyeColor.ORANGE).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) { - override val hasFreeRotation: Boolean - get() = true + override fun rotationFreedom(): BlockRotationFreedom { + return BlockRotationFreedom.TWO + } private val shapes = getShapeForEachState { - BlockShapes.ENGINE.rotateInv(it[FACING_FULL]).computeShape() + BlockShapes.ENGINE.rotateInv(it[rotationProperty].primary).computeShape() } override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt index b47d15211..80c0b51db 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt @@ -2,8 +2,6 @@ package ru.dbotthepony.mc.otm.block.decorative import net.minecraft.core.BlockPos import net.minecraft.world.level.BlockGetter -import net.minecraft.world.level.Level -import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.EntityBlock import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.state.BlockState @@ -12,18 +10,20 @@ import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.shapes.BlockShapes class HoloSignBlock : RotatableMatteryBlock(), EntityBlock { - override val hasFreeRotation: Boolean - get() = true + override fun rotationFreedom(): BlockRotationFreedom { + return BlockRotationFreedom.TWO + } override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return HoloSignBlockEntity(p_153215_, p_153216_) } private val shapes = getShapeForEachState { - BlockShapes.HOLO_SIGN.rotateInv(it[FACING_FULL]).computeShape() + BlockShapes.HOLO_SIGN.rotateInv(it[rotationProperty].primary).computeShape() } override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt index bd83db1d6..42afb0f0d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt @@ -21,19 +21,20 @@ import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.Shapes import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.ServerConfig -import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom +import ru.dbotthepony.mc.otm.core.math.blockRotation import ru.dbotthepony.mc.otm.core.math.plus -import ru.dbotthepony.mc.otm.core.math.times -import ru.dbotthepony.mc.otm.core.math.unaryMinus import ru.dbotthepony.mc.otm.once import ru.dbotthepony.mc.otm.registry.MBlocks +private val FACING_FULL = BlockRotationFreedom.TWO.property + class LaboratoryLampLight : Block(Properties.of(Material.AIR).strength(-1.0F, 3600000.8F).noLootTable().noOcclusion().lightLevel { 15 }) { override fun createBlockStateDefinition(builder: StateDefinition.Builder) { super.createBlockStateDefinition(builder) - builder.add(RotatableMatteryBlock.FACING_FULL) + builder.add(FACING_FULL) } override fun hasDynamicShape(): Boolean { @@ -53,7 +54,7 @@ class LaboratoryLampLight : Block(Properties.of(Material.AIR).strength(-1.0F, 36 @Suppress("OVERRIDE_DEPRECATION") override fun rotate(blockState: BlockState, rotation: Rotation): BlockState { @Suppress("DEPRECATION") - return super.rotate(blockState, rotation).setValue(RotatableMatteryBlock.FACING_FULL, rotation.rotate(blockState[RotatableMatteryBlock.FACING_FULL])) + return super.rotate(blockState, rotation).setValue(FACING_FULL, blockState[FACING_FULL].rotate(rotation)) } @Suppress("OVERRIDE_DEPRECATION") @@ -80,7 +81,7 @@ class LaboratoryLampLight : Block(Properties.of(Material.AIR).strength(-1.0F, 36 if (level.getBlockState(pos) != state) return@once - val facing = state[RotatableMatteryBlock.FACING_FULL] + val facing = state[FACING_FULL] var hit = false @@ -111,14 +112,14 @@ class LaboratoryLamp(val invertRedstone: Boolean) : Block(Properties.of(Material override fun createBlockStateDefinition(builder: StateDefinition.Builder) { super.createBlockStateDefinition(builder) - builder.add(RotatableMatteryBlock.FACING_FULL) + builder.add(FACING_FULL) builder.add(BlockStateProperties.LIT) } override fun getStateForPlacement(context: BlockPlaceContext): BlockState { return super.getStateForPlacement(context)!! .setValue(BlockStateProperties.LIT, !invertRedstone) - .setValue(RotatableMatteryBlock.FACING_FULL, -context.nearestLookingDirection) + .setValue(FACING_FULL, -context.nearestLookingDirection.blockRotation) } override fun appendHoverText( @@ -147,7 +148,7 @@ class LaboratoryLamp(val invertRedstone: Boolean) : Block(Properties.of(Material @Suppress("OVERRIDE_DEPRECATION") override fun rotate(blockState: BlockState, rotation: Rotation): BlockState { @Suppress("DEPRECATION") - return super.rotate(blockState, rotation).setValue(RotatableMatteryBlock.FACING_FULL, rotation.rotate(blockState[RotatableMatteryBlock.FACING_FULL])) + return super.rotate(blockState, rotation).setValue(FACING_FULL, blockState[FACING_FULL].rotate(rotation)) } fun doTick( @@ -172,7 +173,7 @@ class LaboratoryLamp(val invertRedstone: Boolean) : Block(Properties.of(Material level.setBlockAndUpdate(pos, state.setValue(BlockStateProperties.LIT, shouldBeLit)) } - val facing = state[RotatableMatteryBlock.FACING_FULL] + val facing = state[FACING_FULL] for (i in 1 .. ServerConfig.LABORATORY_LAMP_LIGHT_LENGTH) { val target = pos + facing * i @@ -185,7 +186,7 @@ class LaboratoryLamp(val invertRedstone: Boolean) : Block(Properties.of(Material if (shouldBeLit) { if (targetState.isAir && targetState.block != MBlocks.LABORATORY_LAMP_LIGHT) { level.setBlockAndUpdate(target, MBlocks.LABORATORY_LAMP_LIGHT.defaultBlockState().setValue( - RotatableMatteryBlock.FACING_FULL, -facing)) + FACING_FULL, -facing)) } } else { if (targetState.block == MBlocks.LABORATORY_LAMP_LIGHT) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Cables.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Cables.kt index f086c6229..7b091594c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Cables.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Cables.kt @@ -54,14 +54,14 @@ class MatterCableBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } override fun onNeighbour(node: Graph6Node<*>, direction: Direction) { - val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction.ordinal], true) + val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, true) if (newState !== blockState && SERVER_IS_LIVE) level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) } override fun onUnNeighbour(node: Graph6Node<*>, direction: Direction) { - val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction.ordinal], false) + val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, false) if (newState !== blockState && SERVER_IS_LIVE) level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) @@ -110,14 +110,14 @@ class StorageCableBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } override fun onNeighbour(node: Graph6Node<*>, direction: Direction) { - val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction.ordinal], true) + val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, true) if (newState !== blockState && SERVER_IS_LIVE) level!!.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) } override fun onUnNeighbour(node: Graph6Node<*>, direction: Direction) { - val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction.ordinal], false) + val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, false) if (newState !== blockState && SERVER_IS_LIVE) level!!.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt index d85cdd401..4ac58d7b3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt @@ -27,6 +27,8 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.core.* +import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom +import ru.dbotthepony.mc.otm.core.math.getCapability import ru.dbotthepony.mc.otm.core.math.isPositive import ru.dbotthepony.mc.otm.core.math.isZero import ru.dbotthepony.mc.otm.core.math.plus @@ -79,14 +81,14 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter val cell: BasicStorageGraphNode = object : BasicStorageGraphNode(energy), GraphNodeListener { override fun onNeighbour(node: Graph6Node<*>, direction: Direction) { - val newState = this@StorageBusBlockEntity.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction.ordinal], true) + val newState = this@StorageBusBlockEntity.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, true) if (newState !== this@StorageBusBlockEntity.blockState && SERVER_IS_LIVE) level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) } override fun onUnNeighbour(node: Graph6Node<*>, direction: Direction) { - val newState = this@StorageBusBlockEntity.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction.ordinal], false) + val newState = this@StorageBusBlockEntity.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, false) if (newState !== this@StorageBusBlockEntity.blockState && SERVER_IS_LIVE) level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) @@ -111,7 +113,7 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter private var valid = true override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - return if (valid && cap === MatteryCapability.STORAGE_NODE && side != blockState.getValue(RotatableMatteryBlock.FACING_FULL)) { + return if (valid && cap === MatteryCapability.STORAGE_NODE && side != blockState.getValue(BlockRotationFreedom.TWO.property).primary) { cell.get().cast() } else super.getCapability(cap, side) } @@ -157,8 +159,8 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter if (isRemoved) return - val front = blockPos + blockState.getValue(RotatableMatteryBlock.FACING_FULL) - val storage = level?.getBlockEntity(front)?.getCapability(ForgeCapabilities.ITEM_HANDLER, -blockState.getValue(RotatableMatteryBlock.FACING_FULL))?.let { if (it.isPresent) it else null } + val front = blockPos + blockState.getValue(BlockRotationFreedom.TWO.property) + val storage = level?.getBlockEntity(front)?.getCapability(ForgeCapabilities.ITEM_HANDLER, -blockState.getValue(BlockRotationFreedom.TWO.property))?.let { if (it.isPresent) it else null } if (neighbour != storage) { neighbour = storage diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt index 80c059349..c06fda606 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt @@ -26,7 +26,9 @@ import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.core.* +import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.rotationTwo import ru.dbotthepony.mc.otm.core.math.toIntSafe import ru.dbotthepony.mc.otm.core.math.unaryMinus import ru.dbotthepony.mc.otm.core.nbt.map @@ -56,14 +58,14 @@ abstract class AbstractStorageImportExport( val cell: BasicStorageGraphNode = object : BasicStorageGraphNode(energy), GraphNodeListener { override fun onNeighbour(node: Graph6Node<*>, direction: Direction) { - val newState = this@AbstractStorageImportExport.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction.ordinal], true) + val newState = this@AbstractStorageImportExport.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, true) if (newState !== this@AbstractStorageImportExport.blockState && SERVER_IS_LIVE) level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) } override fun onUnNeighbour(node: Graph6Node<*>, direction: Direction) { - val newState = this@AbstractStorageImportExport.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction.ordinal], false) + val newState = this@AbstractStorageImportExport.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, false) if (newState !== this@AbstractStorageImportExport.blockState && SERVER_IS_LIVE) level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) @@ -73,7 +75,7 @@ abstract class AbstractStorageImportExport( private var valid = true override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - return if (valid && cap === MatteryCapability.STORAGE_NODE && side != blockState.getValue(RotatableMatteryBlock.FACING_FULL)) { + return if (valid && cap === MatteryCapability.STORAGE_NODE && side != blockState.getValue(BlockRotationFreedom.TWO.property).primary) { cell.get().cast() } else super.getCapability(cap, side) } @@ -112,7 +114,7 @@ abstract class AbstractStorageImportExport( protected val target by lazy { object : BESubscribeList(this@AbstractStorageImportExport, targetCapability) { override fun test(t: Direction): Boolean { - return t == -this@AbstractStorageImportExport.blockState.getValue(RotatableMatteryBlock.FACING_FULL) + return t == -this@AbstractStorageImportExport.blockState.getValue(BlockRotationFreedom.TWO.property).primary } } } @@ -177,7 +179,7 @@ class StorageImporterBlockEntity(blockPos: BlockPos, blockState: BlockState) } override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - if (valid && cap == ForgeCapabilities.ITEM_HANDLER && side == blockState.getValue(RotatableMatteryBlock.FACING_FULL)) { + if (valid && cap == ForgeCapabilities.ITEM_HANDLER && side == blockState.rotationTwo.primary) { return resolverItemHandler.cast() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index 8020ecfa6..a04973c44 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -28,6 +28,8 @@ import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainerHooks import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.facingOne +import ru.dbotthepony.mc.otm.core.math.rotationOne import ru.dbotthepony.mc.otm.core.math.unaryMinus import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.BESubscribeList @@ -271,7 +273,7 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte if (cap == MatteryCapability.ENERGY || cap == ForgeCapabilities.ENERGY) { if (side == null) return resolverEnergy.cast() - if (side == blockState.getValue(RotatableMatteryBlock.FACING)) + if (side == blockState.facingOne) return resolverEnergyExtractor.cast() else return resolverEnergyReceiver.cast() @@ -280,7 +282,7 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte if (cap == MatteryCapability.MEKANISM_ENERGY) { if (side == null) return mekanismResolverEnergy.cast() - if (side == blockState.getValue(RotatableMatteryBlock.FACING)) + if (side == blockState.facingOne) return mekanismResolverEnergyExtractor.cast() else return mekanismResolverEnergyReceiver.cast() @@ -296,11 +298,11 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte private val consumers = object : BESubscribeList(this@BatteryBankBlockEntity, ForgeCapabilities.ENERGY) { override fun test(t: Direction): Boolean { - return -blockState.getValue(RotatableMatteryBlock.FACING) == t + return -blockState.facingOne == t } } - fun checkSurroundings() = consumers.update((-blockState.getValue(RotatableMatteryBlock.FACING))::equals) + fun checkSurroundings() = consumers.update((-blockState.facingOne)::equals) fun tick() { if (redstoneControl.isBlockedByRedstone) 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 40c368eb6..73e6e6cc1 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 @@ -34,6 +34,7 @@ import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal +import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.BESubscribeList @@ -62,7 +63,7 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryBl } override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - if (valid && (cap == MatteryCapability.ENERGY || cap == ForgeCapabilities.ENERGY) && side !== blockState.getValue(RotatableMatteryBlock.FACING)) + if (valid && (cap == MatteryCapability.ENERGY || cap == ForgeCapabilities.ENERGY) && side !== blockState.facingOne) return energy.resolver.cast() if (valid && cap == ForgeCapabilities.ITEM_HANDLER) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/GravitationStabilizerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/GravitationStabilizerBlockEntity.kt index 7fb8defd9..0ae35a55c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/GravitationStabilizerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/GravitationStabilizerBlockEntity.kt @@ -16,6 +16,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity import ru.dbotthepony.mc.otm.block.tech.BlockGravitationStabilizer +import ru.dbotthepony.mc.otm.core.math.facingTwo import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.core.math.times import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -32,7 +33,7 @@ class GravitationStabilizerBlockEntity(p_155229_: BlockPos, p_155230_: BlockStat fun tick(level: Level) { var findBlackHole: BlackHoleBlockEntity? = null - val dir = blockState.getValue(RotatableMatteryBlock.FACING_FULL).normal + val dir = blockState.facingTwo.normal for (i in 2 .. RANGE) { val pos = blockPos + dir * i diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt index d81a21840..dcf6e2cd6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt @@ -18,6 +18,7 @@ import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity +import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -56,7 +57,7 @@ class MatterBottlerBlock : RotatableMatteryBlock(), EntityBlock { p_60557_: BlockPos, p_60558_: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.getValue(FACING).ordinal] + return SHAPES[p_60555_.facingOne.ordinal] } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt index 853fa5849..323b3f199 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt @@ -14,6 +14,7 @@ import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.tech.BatteryBankBlock import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.matter.MatterCapacitorBankBlockEntity +import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.shapes.BlockShapes class MatterCapacitorBankBlock : RotatableMatteryBlock(), EntityBlock { @@ -41,7 +42,7 @@ class MatterCapacitorBankBlock : RotatableMatteryBlock(), EntityBlock { p_60557_: BlockPos, p_60558_: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.getValue(FACING).ordinal] + return SHAPES[p_60555_.facingOne.ordinal] } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt index faf3065c4..3adfc867f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt @@ -18,6 +18,7 @@ import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -50,7 +51,7 @@ class MatterDecomposerBlock : RotatableMatteryBlock(), EntityBlock { p_60557_: BlockPos, p_60558_: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.getValue(FACING).ordinal] + return SHAPES[p_60555_.facingOne.ordinal] } companion object { @@ -65,4 +66,4 @@ class MatterDecomposerBlock : RotatableMatteryBlock(), EntityBlock { BlockShapes.MATTER_DECOMPOSER.rotate(Direction.EAST).computeShape() ) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterPanelBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterPanelBlock.kt index d23b5bcd5..4a8076269 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterPanelBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterPanelBlock.kt @@ -17,6 +17,9 @@ import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.properties.EnumProperty import ru.dbotthepony.mc.otm.block.MatteryBlock import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.core.math.BlockRotation +import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom +import ru.dbotthepony.mc.otm.core.math.rotationTwo class MatterPanelBlock : RotatableMatteryBlock(), EntityBlock { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { @@ -26,10 +29,10 @@ class MatterPanelBlock : RotatableMatteryBlock(), EntityBlock { private val shapes: ImmutableMap init { - registerDefaultState(getStateDefinition().any().setValue(FACING_FULL, Direction.SOUTH)) + registerDefaultState(getStateDefinition().any().setValue(BlockRotationFreedom.TWO.property, BlockRotation.SOUTH)) shapes = getShapeForEachState { - when (it.getValue(FACING_FULL)) { + when (it.rotationTwo.primary) { Direction.NORTH -> Shapes.box( 0.0, 0.0, @@ -91,10 +94,11 @@ class MatterPanelBlock : RotatableMatteryBlock(), EntityBlock { return shapes[p_60555_]!! } - override val hasFreeRotation: Boolean - get() = true + override fun rotationFreedom(): BlockRotationFreedom { + return BlockRotationFreedom.TWO + } override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { - return defaultBlockState().setValue(FACING_FULL, context.clickedFace) + return defaultBlockState().setValue(BlockRotationFreedom.TWO.property, BlockRotation.of(context.clickedFace)) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt index d8c99395a..34d471188 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt @@ -16,6 +16,7 @@ import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.matter.MatterRecyclerBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -46,7 +47,7 @@ class MatterRecyclerBlock : RotatableMatteryBlock(), EntityBlock { p_60557_: BlockPos, p_60558_: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.getValue(FACING).ordinal] + return SHAPES[p_60555_.facingOne.ordinal] } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt index 1d15fbbc6..c90943d5d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt @@ -16,6 +16,7 @@ import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -46,7 +47,7 @@ class MatterReplicatorBlock : RotatableMatteryBlock(), EntityBlock { p_60557_: BlockPos, p_60558_: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.getValue(FACING).ordinal] + return SHAPES[p_60555_.facingOne.ordinal] } companion object { @@ -65,4 +66,4 @@ class MatterReplicatorBlock : RotatableMatteryBlock(), EntityBlock { ) } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt index 51b3a72c3..a7efee532 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt @@ -16,6 +16,7 @@ import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.matter.MatterScannerBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -46,7 +47,7 @@ class MatterScannerBlock : RotatableMatteryBlock(), EntityBlock { p_60557_: BlockPos, p_60558_: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.getValue(FACING).ordinal] + return SHAPES[p_60555_.facingOne.ordinal] } companion object { @@ -65,4 +66,4 @@ class MatterScannerBlock : RotatableMatteryBlock(), EntityBlock { ) } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt index 5bdcb39ea..30813617f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt @@ -16,6 +16,7 @@ import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.matter.PatternStorageBlockEntity +import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.shapes.BlockShapes class PatternStorageBlock : RotatableMatteryBlock(), EntityBlock { @@ -62,7 +63,7 @@ class PatternStorageBlock : RotatableMatteryBlock(), EntityBlock { p_60557_: BlockPos, p_60558_: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.getValue(FACING).ordinal] + return SHAPES[p_60555_.facingOne.ordinal] } companion object { @@ -92,4 +93,4 @@ class PatternStorageBlock : RotatableMatteryBlock(), EntityBlock { ) } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt index df085a37d..f88f67b5e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt @@ -18,6 +18,7 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.DriveRackBlockEntity import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -54,7 +55,7 @@ class DriveRackBlock : RotatableMatteryBlock(), EntityBlock { p_60557_: BlockPos, p_60558_: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.getValue(FACING).ordinal] + return SHAPES[p_60555_.facingOne.ordinal] } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt index 1de05d726..45fe6a2bd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt @@ -23,6 +23,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.DriveViewerBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -69,7 +70,7 @@ class DriveViewerBlock : RotatableMatteryBlock(), EntityBlock { p_60557_: BlockPos, p_60558_: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.getValue(FACING).ordinal] + return SHAPES[p_60555_.facingOne.ordinal] } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt index f53497785..95dfe2786 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt @@ -18,6 +18,7 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorBlockEntity import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -54,7 +55,7 @@ class ItemMonitorBlock : RotatableMatteryBlock(), EntityBlock { p_60557_: BlockPos, p_60558_: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.getValue(FACING).ordinal] + return SHAPES[p_60555_.facingOne.ordinal] } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt index d0f5d2867..544f5d006 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt @@ -24,13 +24,18 @@ import ru.dbotthepony.mc.otm.block.StorageCableBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.StorageBusBlockEntity import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.core.math.BlockRotation +import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom +import ru.dbotthepony.mc.otm.core.math.facingTwo import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes import ru.dbotthepony.mc.otm.core.math.unaryMinus import ru.dbotthepony.mc.otm.oncePre class StorageBusBlock : RotatableMatteryBlock(), EntityBlock { - override val hasFreeRotation: Boolean get() = true + override fun rotationFreedom(): BlockRotationFreedom { + return BlockRotationFreedom.TWO + } init { registerDefaultState(defaultBlockState() @@ -47,7 +52,7 @@ class StorageBusBlock : RotatableMatteryBlock(), EntityBlock { } override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { - return super.getStateForPlacement(context)?.setValue(FACING_FULL, -context.clickedFace) + return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.TWO.property, BlockRotation.of(-context.clickedFace)) } override fun appendHoverText( @@ -93,7 +98,7 @@ class StorageBusBlock : RotatableMatteryBlock(), EntityBlock { finalShape = Shapes.joinUnoptimized(finalShape, shapes[i], BooleanOp.OR) } - finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_BUS.rotateInv(it.getValue(FACING_FULL)).computeShape(), BooleanOp.OR) + finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_BUS.rotateInv(it.facingTwo).computeShape(), BooleanOp.OR) return@getShapeForEachState finalShape } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt index 1ae920297..0b8fb51f3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt @@ -25,13 +25,18 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.StorageExporterBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.StorageImporterBlockEntity import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.core.math.BlockRotation +import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom +import ru.dbotthepony.mc.otm.core.math.facingTwo import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes import ru.dbotthepony.mc.otm.core.math.unaryMinus import ru.dbotthepony.mc.otm.oncePre class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock { - override val hasFreeRotation: Boolean get() = true + override fun rotationFreedom(): BlockRotationFreedom { + return BlockRotationFreedom.TWO + } override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return StorageImporterBlockEntity(p_153215_, p_153216_) @@ -72,7 +77,7 @@ class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock { } override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { - return super.getStateForPlacement(context)?.setValue(FACING_FULL, -context.clickedFace) + return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.TWO.property, BlockRotation.of(-context.clickedFace)) } override fun appendHoverText( @@ -94,7 +99,7 @@ class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock { finalShape = Shapes.joinUnoptimized(finalShape, shapes[i], BooleanOp.OR) } - finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_IMPORTER.rotateInv(it.getValue(FACING_FULL)).computeShape(), BooleanOp.OR) + finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_IMPORTER.rotateInv(it.facingTwo).computeShape(), BooleanOp.OR) return@getShapeForEachState finalShape } @@ -133,7 +138,9 @@ class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock { } class StorageExporterBlock : RotatableMatteryBlock(), EntityBlock { - override val hasFreeRotation: Boolean get() = true + override fun rotationFreedom(): BlockRotationFreedom { + return BlockRotationFreedom.TWO + } override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return StorageExporterBlockEntity(p_153215_, p_153216_) @@ -185,7 +192,7 @@ class StorageExporterBlock : RotatableMatteryBlock(), EntityBlock { } override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { - return super.getStateForPlacement(context)?.setValue(FACING_FULL, -context.clickedFace) + return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.TWO.property, BlockRotation.of(-context.clickedFace)) } private val shapes = getShapeForEachState { @@ -196,7 +203,7 @@ class StorageExporterBlock : RotatableMatteryBlock(), EntityBlock { finalShape = Shapes.joinUnoptimized(finalShape, shapes[i], BooleanOp.OR) } - finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_EXPORTER.rotateInv(it.getValue(FACING_FULL)).computeShape(), BooleanOp.OR) + finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_EXPORTER.rotateInv(it.facingTwo).computeShape(), BooleanOp.OR) return@getShapeForEachState finalShape } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt index 5d8a23712..e4d59f655 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt @@ -18,6 +18,7 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.StoragePowerSupplierBlockEntity import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -54,7 +55,7 @@ class StoragePowerSupplierBlock : RotatableMatteryBlock(), EntityBlock { p_60557_: BlockPos, p_60558_: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.getValue(FACING).ordinal] + return SHAPES[p_60555_.facingOne.ordinal] } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt index 7e2fb9fa5..79496afe2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt @@ -19,6 +19,7 @@ import net.minecraft.world.level.block.Block import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.oncePre import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -61,7 +62,7 @@ class BatteryBankBlock : RotatableMatteryBlock(), EntityBlock { p_60557_: BlockPos, p_60558_: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.getValue(FACING).ordinal] + return SHAPES[p_60555_.facingOne.ordinal] } override fun faceToPlayer(context: BlockPlaceContext): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt index f46063df1..473d0c605 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt @@ -27,6 +27,7 @@ import ru.dbotthepony.mc.otm.capability.energy.GeneratorEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.ItemEnergyStorageImpl import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.oncePre import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -100,7 +101,7 @@ class ChemicalGeneratorBlock : RotatableMatteryBlock(), EntityBlock { p_60557_: BlockPos, p_60558_: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.getValue(FACING).ordinal] + return SHAPES[p_60555_.facingOne.ordinal] } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt index 3fc8b7c37..ecb5e7ecc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt @@ -15,6 +15,7 @@ import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.tech.EnergyServoBlockEntity +import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -41,7 +42,7 @@ class EnergyServoBlock : RotatableMatteryBlock(Properties.of(Material.METAL, Mat p_60557_: BlockPos, p_60558_: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.getValue(FACING).ordinal] + return SHAPES[p_60555_.facingOne.ordinal] } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt index 146af6a17..f7a82cbd6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt @@ -26,6 +26,8 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.tech.GravitationStabilizerBlockEntity import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom +import ru.dbotthepony.mc.otm.core.math.facingTwo import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.core.math.times import ru.dbotthepony.mc.otm.oncePre @@ -52,7 +54,9 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock { return BlockEntityTicker { level, _, _, tile -> if (tile is GravitationStabilizerBlockEntity) tile.tick(level) } } - override val hasFreeRotation: Boolean get() = true + override fun rotationFreedom(): BlockRotationFreedom { + return BlockRotationFreedom.TWO + } override fun createBlockStateDefinition(builder: StateDefinition.Builder) { super.createBlockStateDefinition(builder) @@ -64,7 +68,7 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock { val blockPos = context.clickedPos val level = context.level - for (face in FACING_FULL.possibleValues) { + for (face in BlockRotationFreedom.TWO.possibleValues) { val dir = face.normal for (i in 1 ..GravitationStabilizerBlockEntity.RANGE) { @@ -74,14 +78,14 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock { if (!getState.isAir) { if (chunk.getBlockEntity(pos) is BlackHoleBlockEntity) { - state = state.setValue(FACING_FULL, face) + state = state.setValue(BlockRotationFreedom.TWO.property, face) break } } } } - val bbPos = blockPos + state.getValue(FACING_FULL).normal + val bbPos = blockPos + state.getValue(BlockRotationFreedom.TWO.property).normal if (!context.level.isInWorldBounds(bbPos)) return null if (!level.getBlockState(bbPos).canBeReplaced(context)) return null @@ -99,9 +103,9 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock { super.setPlacedBy(level, blockPos, blockState, entity, itemStack) if (!level.isClientSide) { - val bbPos = blockPos + blockState.getValue(FACING_FULL).normal + val bbPos = blockPos + blockState.getValue(BlockRotationFreedom.TWO.property).normal val newState = MBlocks.GRAVITATION_STABILIZER_LENS.defaultBlockState() - .setValue(FACING_FULL, blockState.getValue(FACING_FULL)) + .setValue(BlockRotationFreedom.TWO.property, blockState.getValue(BlockRotationFreedom.TWO.property)) level.setBlock(bbPos, newState, UPDATE_ALL) } @@ -137,7 +141,7 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock { p_60557_: BlockPos, p_60558_: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.getValue(FACING_FULL).ordinal] + return SHAPES[p_60555_.facingTwo.ordinal] } companion object { @@ -155,13 +159,15 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock { } fun getBoundingBlockPos(blockState: BlockState, blockPos: BlockPos): BlockPos { - return blockPos + blockState.getValue(FACING_FULL).normal + return blockPos + blockState.getValue(BlockRotationFreedom.TWO.property).normal } } } class BlockGravitationStabilizerLens : RotatableMatteryBlock(props) { - override val hasFreeRotation: Boolean get() = true + override fun rotationFreedom(): BlockRotationFreedom { + return BlockRotationFreedom.TWO + } override fun createBlockStateDefinition(builder: StateDefinition.Builder) { super.createBlockStateDefinition(builder) @@ -198,7 +204,7 @@ class BlockGravitationStabilizerLens : RotatableMatteryBlock(props) { p_60557_: BlockPos, p_60558_: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.getValue(FACING_FULL).ordinal] + return SHAPES[p_60555_.facingTwo.ordinal] } companion object { @@ -207,7 +213,7 @@ class BlockGravitationStabilizerLens : RotatableMatteryBlock(props) { } fun getBoundingBlockPos(blockState: BlockState, blockPos: BlockPos): BlockPos { - return blockPos + blockState.getValue(FACING_FULL).opposite.normal + return blockPos + blockState.getValue(BlockRotationFreedom.TWO.property).opposite.normal } private val SHAPES = arrayOf( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt index deada4a16..b50ce41d4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt @@ -27,6 +27,7 @@ import net.minecraft.world.phys.shapes.VoxelShape import net.minecraftforge.common.ForgeHooks import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.core.math.minus import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.once @@ -92,7 +93,7 @@ class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of(Material.METAL DoubleBlockHalf.LOWER -> BlockShapes.PHANTOM_ATTRACTOR_BOTTOM } - shape.rotate(it[FACING]!!).computeShape() + shape.rotate(it.facingOne).computeShape() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt index ef0b6e008..4c788677a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt @@ -20,6 +20,7 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -60,7 +61,7 @@ class PlatePressBlock(properties: Properties = DEFAULT_PROPERTIES) : RotatableMa p_60557_: BlockPos, p_60558_: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.getValue(FACING).ordinal] + return SHAPES[p_60555_.facingOne.ordinal] } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt index 08a96b8bb..2d67ee17a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt @@ -14,6 +14,7 @@ import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.core.math.rotateY import kotlin.math.PI @@ -37,7 +38,7 @@ abstract class BankRenderer(private val context: BlockEn stack.pushPose() - val facing = blockEntity.blockState[RotatableMatteryBlock.FACING] + val facing = blockEntity.blockState.facingOne val rotateFacing = facing == Direction.NORTH || facing == Direction.SOUTH if (rotateFacing) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt index c0f0819c9..5e240253b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt @@ -26,6 +26,7 @@ import ru.dbotthepony.mc.otm.core.math.VECTOR_RIGHT import ru.dbotthepony.mc.otm.core.math.VECTOR_UP import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.math.asAngle +import ru.dbotthepony.mc.otm.core.math.facingTwo import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.core.math.rotateAroundAxis import ru.dbotthepony.mc.otm.core.math.times @@ -47,7 +48,7 @@ class GravitationStabilizerRenderer(private val context: BlockEntityRendererProv var len = 64.0 var lenI = 64 - val normal = tile.blockState.getValue(RotatableMatteryBlock.FACING_FULL).normal + val normal = tile.blockState.facingTwo.normal val level = tile.level var bhTile: BlackHoleBlockEntity? = null @@ -68,7 +69,7 @@ class GravitationStabilizerRenderer(private val context: BlockEntityRendererProv poseStack.pushPose() poseStack.translate(0.5, 0.5, 0.5) - val facing: Direction = tile.blockState.getValue(RotatableMatteryBlock.FACING_FULL) + val facing = tile.blockState.facingTwo val rotateZ: Double val rotateY: Double 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 a79e423fd..1c89e54de 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 @@ -13,6 +13,7 @@ import ru.dbotthepony.mc.otm.client.render.TextAlign import ru.dbotthepony.mc.otm.client.render.drawAligned import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.RGBAColor +import ru.dbotthepony.mc.otm.core.math.facingTwo import ru.dbotthepony.mc.otm.core.math.rotateWithBlockFacing class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer { @@ -28,7 +29,7 @@ class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context) return poseStack.pushPose() - poseStack.rotateWithBlockFacing(tile.blockState[RotatableMatteryBlock.FACING_FULL]) + poseStack.rotateWithBlockFacing(tile.blockState.facingTwo) poseStack.translate(0.5f, 0.5f, 0.6f) poseStack.scale(0.01f, 0.01f, 0.01f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt new file mode 100644 index 000000000..b67604aa2 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt @@ -0,0 +1,137 @@ +package ru.dbotthepony.mc.otm.core.math + +import net.minecraft.core.BlockPos +import net.minecraft.core.Direction +import net.minecraft.core.Vec3i +import net.minecraft.util.StringRepresentable +import net.minecraft.world.level.block.Rotation +import net.minecraftforge.common.capabilities.Capability +import net.minecraftforge.common.capabilities.ICapabilityProvider +import net.minecraftforge.common.util.LazyOptional + +internal inline val Direction.blockRotation + get() = BlockRotation.of(this) + +fun ICapabilityProvider.getCapability(capability: Capability, side: BlockRotation?): LazyOptional { + return getCapability(capability, side?.primary) +} + +operator fun Vec3i.plus(other: BlockRotation): Vec3i { + return this + other.normal +} + +operator fun BlockPos.plus(other: BlockRotation): BlockPos { + return this + other.normal +} + +enum class BlockRotation(val primary: Direction, val secondary: Direction?) : StringRepresentable { + DOWN(Direction.DOWN, null), + UP(Direction.UP, null), + NORTH(Direction.NORTH, null), + SOUTH(Direction.SOUTH, null), + WEST(Direction.WEST, null), + EAST(Direction.EAST, null), + + DOWN_NORTH(Direction.DOWN, Direction.NORTH), + DOWN_SOUTH(Direction.DOWN, Direction.SOUTH), + DOWN_WEST(Direction.DOWN, Direction.WEST), + DOWN_EAST(Direction.DOWN, Direction.EAST), + + UP_NORTH(Direction.UP, Direction.NORTH), + UP_SOUTH(Direction.UP, Direction.SOUTH), + UP_WEST(Direction.UP, Direction.WEST), + UP_EAST(Direction.UP, Direction.EAST); + + val lowercaseName = name.lowercase() + + override fun getSerializedName(): String { + return lowercaseName + } + + fun rotate(by: Rotation): BlockRotation { + return of(by.rotate(primary), secondary) + } + + operator fun times(other: Int): Vec3i { + return normal * other + } + + operator fun plus(other: Vec3i): Vec3i { + return normal + other + } + + operator fun plus(other: Direction): Vec3i { + return normal + other + } + + operator fun plus(other: BlockRotation): Vec3i { + return normal + other.normal + } + + operator fun unaryMinus() = opposite + + // more performant + val opposite by lazy { of(primary.opposite, secondary?.opposite) } + val normal: Vec3i get() = primary.normal + + companion object { + @JvmStatic + fun of(direction: Direction): BlockRotation { + return when (direction) { + Direction.DOWN -> DOWN + Direction.UP -> UP + Direction.NORTH -> NORTH + Direction.SOUTH -> SOUTH + Direction.WEST -> WEST + Direction.EAST -> EAST + } + } + + @JvmStatic + fun of(primary: Direction, secondary: Direction?): BlockRotation { + return when (primary) { + Direction.NORTH -> { + require(secondary == null) { "Impossible direction: $primary - $secondary" } + NORTH + } + + Direction.SOUTH -> { + require(secondary == null) { "Impossible direction: $primary - $secondary" } + SOUTH + } + + Direction.WEST -> { + require(secondary == null) { "Impossible direction: $primary - $secondary" } + WEST + } + + Direction.EAST -> { + require(secondary == null) { "Impossible direction: $primary - $secondary" } + EAST + } + + Direction.UP -> { + when (secondary) { + null -> UP + Direction.NORTH -> UP_NORTH + Direction.SOUTH -> UP_SOUTH + Direction.WEST -> UP_WEST + Direction.EAST -> UP_EAST + else -> throw IllegalArgumentException("Impossible direction: $primary - $secondary") + } + } + + Direction.DOWN -> { + when (secondary) { + null -> DOWN + Direction.NORTH -> DOWN_NORTH + Direction.SOUTH -> DOWN_SOUTH + Direction.WEST -> DOWN_WEST + Direction.EAST -> DOWN_EAST + else -> throw IllegalArgumentException("Impossible direction: $primary - $secondary") + } + } + } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotationFreedom.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotationFreedom.kt new file mode 100644 index 000000000..fc0dd01fb --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotationFreedom.kt @@ -0,0 +1,50 @@ +package ru.dbotthepony.mc.otm.core.math + +import net.minecraft.core.Direction +import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.level.block.state.properties.EnumProperty +import ru.dbotthepony.mc.otm.core.get + +internal inline val BlockState.rotationOne: BlockRotation get() = this[BlockRotationFreedom.ONE.property] +internal inline val BlockState.rotationTwo: BlockRotation get() = this[BlockRotationFreedom.TWO.property] +internal inline val BlockState.rotationThree: BlockRotation get() = this[BlockRotationFreedom.THREE.property] + +internal inline val BlockState.facingOne: Direction get() = this[BlockRotationFreedom.ONE.property].primary +internal inline val BlockState.facingTwo: Direction get() = this[BlockRotationFreedom.TWO.property].primary +internal inline val BlockState.facingThree: Direction get() = this[BlockRotationFreedom.THREE.property].primary + +enum class BlockRotationFreedom(vararg values: BlockRotation) { + ONE( + BlockRotation.NORTH, + BlockRotation.SOUTH, + BlockRotation.WEST, + BlockRotation.EAST, + ), + TWO( + BlockRotation.DOWN, + BlockRotation.UP, + BlockRotation.NORTH, + BlockRotation.SOUTH, + BlockRotation.WEST, + BlockRotation.EAST, + ), + THREE( + BlockRotation.DOWN, + BlockRotation.UP, + BlockRotation.NORTH, + BlockRotation.SOUTH, + BlockRotation.WEST, + BlockRotation.EAST, + BlockRotation.DOWN_NORTH, + BlockRotation.DOWN_SOUTH, + BlockRotation.DOWN_WEST, + BlockRotation.DOWN_EAST, + BlockRotation.UP_NORTH, + BlockRotation.UP_SOUTH, + BlockRotation.UP_WEST, + BlockRotation.UP_EAST, + ); + + val possibleValues: Collection get() = property.possibleValues + val property: EnumProperty = EnumProperty.create("facing", BlockRotation::class.java, *values) +} From 192144cc2708df04a7456d28a50ec338fcf54e09 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 30 Jan 2023 14:08:01 +0700 Subject: [PATCH 0153/1199] Implement some logic for three rotation freedom of blocks, make holo sign have three rotation freedoms --- .../blocks/MatteryBlockStateProvider.kt | 5 +++ .../mc/otm/block/RotatableMatteryBlock.kt | 27 ++++++++++--- .../mc/otm/block/decorative/HoloSignBlock.kt | 2 +- .../render/blockentity/HoloSignRenderer.kt | 3 +- .../mc/otm/core/math/BlockRotation.kt | 39 ++++++++++++++++--- .../mc/otm/core/math/BlockRotationFreedom.kt | 2 - .../mc/otm/core/math/EuclidMath.kt | 4 ++ 7 files changed, 66 insertions(+), 16 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt index e41abe868..ed3aba803 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt @@ -31,6 +31,11 @@ private fun initialTransform(it: BlockState, modelPath: String, builder: Configu builder.rotationX(it.primary.toXRotBlockstate()) } + it.getValueNullable(BlockRotationFreedom.THREE.property)?.let { + builder.rotationY(it.primary.toYRotBlockstate() + (it.secondary?.toYRotBlockstate() ?: 0)) + builder.rotationX(it.primary.toXRotBlockstate()) + } + it.getValueNullable(WorkerState.WORKER_STATE)?.let { modelPath += "_" + it.name.lowercase() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/RotatableMatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/RotatableMatteryBlock.kt index 248123fbf..fa7689090 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/RotatableMatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/RotatableMatteryBlock.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.block +import net.minecraft.core.Direction import net.minecraft.world.item.context.BlockPlaceContext import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.Rotation @@ -20,16 +21,30 @@ abstract class RotatableMatteryBlock @JvmOverloads constructor(properties: Prope } override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { - if (rotationFreedom() == BlockRotationFreedom.ONE) { - return defaultBlockState().setValue( - rotationProperty, + return when (val freedom = rotationFreedom()) { + BlockRotationFreedom.ONE -> defaultBlockState().setValue( + freedom.property, BlockRotation.of(if (faceToPlayer(context)) context.horizontalDirection.opposite else context.horizontalDirection) ) - } else { - return defaultBlockState().setValue( - rotationProperty, + + BlockRotationFreedom.TWO -> defaultBlockState().setValue( + freedom.property, BlockRotation.of(if (faceToPlayer(context)) context.nearestLookingDirection.opposite else context.nearestLookingDirection) ) + + BlockRotationFreedom.THREE -> { + val primary = if (faceToPlayer(context)) context.nearestLookingDirection.opposite else context.nearestLookingDirection + var secondary = if (faceToPlayer(context)) context.horizontalDirection else context.horizontalDirection.opposite + + if (primary == Direction.DOWN) { + secondary = secondary.opposite + } + + defaultBlockState().setValue( + freedom.property, + BlockRotation.ofSafe(primary, secondary) + ) + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt index 80c0b51db..92f861ff4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt @@ -15,7 +15,7 @@ import ru.dbotthepony.mc.otm.shapes.BlockShapes class HoloSignBlock : RotatableMatteryBlock(), EntityBlock { override fun rotationFreedom(): BlockRotationFreedom { - return BlockRotationFreedom.TWO + return BlockRotationFreedom.THREE } override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { 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 1c89e54de..5a5ed2bc9 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 @@ -15,6 +15,7 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.facingTwo import ru.dbotthepony.mc.otm.core.math.rotateWithBlockFacing +import ru.dbotthepony.mc.otm.core.math.rotationThree class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer { override fun render( @@ -29,7 +30,7 @@ class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context) return poseStack.pushPose() - poseStack.rotateWithBlockFacing(tile.blockState.facingTwo) + poseStack.rotateWithBlockFacing(tile.blockState.rotationThree) poseStack.translate(0.5f, 0.5f, 0.6f) poseStack.scale(0.01f, 0.01f, 0.01f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt index b67604aa2..b77eec949 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt @@ -24,20 +24,21 @@ operator fun BlockPos.plus(other: BlockRotation): BlockPos { return this + other.normal } +/** + * [secondary] clarifies about block's top facing direction, NOT bottom + */ enum class BlockRotation(val primary: Direction, val secondary: Direction?) : StringRepresentable { - DOWN(Direction.DOWN, null), - UP(Direction.UP, null), + DOWN(Direction.DOWN, Direction.NORTH), + UP(Direction.UP, Direction.NORTH), NORTH(Direction.NORTH, null), SOUTH(Direction.SOUTH, null), WEST(Direction.WEST, null), EAST(Direction.EAST, null), - DOWN_NORTH(Direction.DOWN, Direction.NORTH), DOWN_SOUTH(Direction.DOWN, Direction.SOUTH), DOWN_WEST(Direction.DOWN, Direction.WEST), DOWN_EAST(Direction.DOWN, Direction.EAST), - UP_NORTH(Direction.UP, Direction.NORTH), UP_SOUTH(Direction.UP, Direction.SOUTH), UP_WEST(Direction.UP, Direction.WEST), UP_EAST(Direction.UP, Direction.EAST); @@ -113,7 +114,6 @@ enum class BlockRotation(val primary: Direction, val secondary: Direction?) : St Direction.UP -> { when (secondary) { null -> UP - Direction.NORTH -> UP_NORTH Direction.SOUTH -> UP_SOUTH Direction.WEST -> UP_WEST Direction.EAST -> UP_EAST @@ -124,7 +124,6 @@ enum class BlockRotation(val primary: Direction, val secondary: Direction?) : St Direction.DOWN -> { when (secondary) { null -> DOWN - Direction.NORTH -> DOWN_NORTH Direction.SOUTH -> DOWN_SOUTH Direction.WEST -> DOWN_WEST Direction.EAST -> DOWN_EAST @@ -133,5 +132,33 @@ enum class BlockRotation(val primary: Direction, val secondary: Direction?) : St } } } + + @JvmStatic + fun ofSafe(primary: Direction, secondary: Direction?): BlockRotation { + return when (primary) { + Direction.NORTH -> NORTH + Direction.SOUTH -> SOUTH + Direction.WEST -> WEST + Direction.EAST -> EAST + + Direction.UP -> { + when (secondary) { + Direction.SOUTH -> UP_SOUTH + Direction.WEST -> UP_WEST + Direction.EAST -> UP_EAST + else -> UP + } + } + + Direction.DOWN -> { + when (secondary) { + Direction.SOUTH -> DOWN_SOUTH + Direction.WEST -> DOWN_WEST + Direction.EAST -> DOWN_EAST + else -> DOWN + } + } + } + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotationFreedom.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotationFreedom.kt index fc0dd01fb..2f131ba8e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotationFreedom.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotationFreedom.kt @@ -35,11 +35,9 @@ enum class BlockRotationFreedom(vararg values: BlockRotation) { BlockRotation.SOUTH, BlockRotation.WEST, BlockRotation.EAST, - BlockRotation.DOWN_NORTH, BlockRotation.DOWN_SOUTH, BlockRotation.DOWN_WEST, BlockRotation.DOWN_EAST, - BlockRotation.UP_NORTH, BlockRotation.UP_SOUTH, BlockRotation.UP_WEST, BlockRotation.UP_EAST, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/EuclidMath.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/EuclidMath.kt index 5dd4654a1..3b8c60b5f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/EuclidMath.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/EuclidMath.kt @@ -647,6 +647,10 @@ fun PoseStack.rotateWithBlockFacing(rotation: Direction, clarifyingAxis: Directi return this } +fun PoseStack.rotateWithBlockFacing(rotation: BlockRotation): PoseStack { + return rotateWithBlockFacing(rotation = rotation.primary, clarifyingAxis = rotation.secondary) +} + fun PoseStack.rotateYDegrees(rotation: Float): PoseStack { mulPose(Quaternionf(AxisAngle4f(toRadians(rotation), 0f, 1f, 0f))) return this From 25630a7924ae19b018e430083d4ab250a08c5ad7 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 30 Jan 2023 15:36:25 +0700 Subject: [PATCH 0154/1199] Actual block rotation enum impl, with left/right and front/back --- .../mc/otm/datagen/DecorativeData.kt | 9 +- .../ru/dbotthepony/mc/otm/datagen/Ext.kt | 7 +- .../mc/otm/datagen/blocks/Banks.kt | 5 +- .../mc/otm/datagen/blocks/BlockStates.kt | 41 +++-- .../otm/datagen/blocks/ComplexBlockStates.kt | 9 +- .../blocks/MatteryBlockStateProvider.kt | 11 +- .../dbotthepony/mc/otm/block/MatteryBlock.kt | 2 +- .../mc/otm/block/RotatableMatteryBlock.kt | 8 +- .../mc/otm/block/decorative/EngineBlock.kt | 2 +- .../mc/otm/block/decorative/HoloSignBlock.kt | 2 +- .../entity/storage/StorageBusBlockEntity.kt | 4 +- .../block/entity/storage/StorageInterfaces.kt | 7 +- .../mc/otm/block/matter/MatterPanelBlock.kt | 6 +- .../block/tech/GravitationStabilizerBlock.kt | 2 +- .../mc/otm/core/math/BlockRotation.kt | 141 ++++++++---------- .../mc/otm/core/math/BlockRotationFreedom.kt | 56 ++++++- .../mc/otm/core/math/EuclidMath.kt | 2 +- 17 files changed, 170 insertions(+), 144 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt index fe4d252be..30a5aee55 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt @@ -9,7 +9,6 @@ import net.minecraftforge.client.model.generators.BlockModelBuilder import net.minecraftforge.client.model.generators.ConfiguredModel import net.minecraftforge.client.model.generators.ModelFile import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.registryName @@ -217,16 +216,16 @@ fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelPr blockStateProvider.getVariantBuilder(MBlocks.LABORATORY_LAMP).forAllStates { return@forAllStates ConfiguredModel.builder() .modelFile(if (it[BlockStateProperties.LIT]) labLampOn!! else labLampOff!!) - .rotationX(it[BlockRotationFreedom.TWO.property].primary.toXRotBlockstate()) - .rotationY(it[BlockRotationFreedom.TWO.property].primary.toYRotBlockstate()) + .rotationX(it[BlockRotationFreedom.TWO.property].front.toXRotBlockstate()) + .rotationY(it[BlockRotationFreedom.TWO.property].front.toYRotBlockstate()) .build() } blockStateProvider.getVariantBuilder(MBlocks.LABORATORY_LAMP_INVERTED).forAllStates { return@forAllStates ConfiguredModel.builder() .modelFile(if (it[BlockStateProperties.LIT]) labLampOn!! else labLampOff!!) - .rotationX(it[BlockRotationFreedom.TWO.property].primary.toXRotBlockstate()) - .rotationY(it[BlockRotationFreedom.TWO.property].primary.toYRotBlockstate()) + .rotationX(it[BlockRotationFreedom.TWO.property].front.toXRotBlockstate()) + .rotationY(it[BlockRotationFreedom.TWO.property].front.toYRotBlockstate()) .build() } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/Ext.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/Ext.kt index 4878ae37e..d4f102c3f 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/Ext.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/Ext.kt @@ -6,9 +6,7 @@ import net.minecraft.world.level.block.state.properties.Property fun Direction.toYRotBlockstate(): Int { return when (this) { - Direction.DOWN -> 0 - Direction.UP -> 0 - Direction.NORTH -> 0 + Direction.DOWN, Direction.UP, Direction.NORTH -> 0 Direction.SOUTH -> 180 Direction.WEST -> -90 Direction.EAST -> 90 @@ -17,8 +15,7 @@ fun Direction.toYRotBlockstate(): Int { fun Direction.toYRotBlockstateInv(): Int { return when (this) { - Direction.DOWN -> 0 - Direction.UP -> 0 + Direction.DOWN, Direction.UP -> 0 Direction.NORTH -> 180 Direction.SOUTH -> 0 Direction.WEST -> 90 diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt index 8fe6a9ede..5e145d39b 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt @@ -5,7 +5,6 @@ import net.minecraft.world.level.block.Block import net.minecraftforge.client.model.generators.BlockStateProvider import net.minecraftforge.data.event.GatherDataEvent import ru.dbotthepony.mc.otm.block.tech.BatteryBankBlock -import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.datagen.DataGen import ru.dbotthepony.mc.otm.datagen.toYRotBlockstate @@ -28,13 +27,13 @@ open class BatteryBankProvider(event: GatherDataEvent) : BlockStateProvider(even val battery_bank = models().getExistingFile(ResourceLocation("overdrive_that_matters:block/$block")) BlockRotationFreedom.ONE.possibleValues.forEach { - part().modelFile(battery_bank).rotationY(it.primary.toYRotBlockstate()).addModel().condition( + part().modelFile(battery_bank).rotationY(it.front.toYRotBlockstate()).addModel().condition( BlockRotationFreedom.ONE.property, it) for (i in 0 .. 11) { part().modelFile( models().getExistingFile(ResourceLocation("overdrive_that_matters:$batteryPath$i")) - ).rotationY(it.primary.toYRotBlockstate()).addModel() + ).rotationY(it.front.toYRotBlockstate()).addModel() .condition(BlockRotationFreedom.ONE.property, it) .condition(BatteryBankBlock.BATTERY_SLOTS_PROPS[i], true) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt index e83b8671b..10ce4ef91 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt @@ -7,7 +7,6 @@ import net.minecraftforge.client.model.generators.ConfiguredModel import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.block.CableBlock import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock -import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom @@ -39,7 +38,7 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { with(provider.getMultipartBuilder(MBlocks.PHANTOM_ATTRACTOR)) { for (dir in BlockRotationFreedom.ONE.possibleValues) { part().modelFile(provider.models().getExistingFile(modLocation("block/${MNames.PHANTOM_ATTRACTOR}"))) - .rotationY(dir.primary.toYRotBlockstate()) + .rotationY(dir.front.toYRotBlockstate()) .addModel() .condition(BlockStateProperties.DOUBLE_BLOCK_HALF, DoubleBlockHalf.LOWER) .condition(BlockRotationFreedom.ONE.property, dir) @@ -51,7 +50,7 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { for (dir in BlockRotationFreedom.ONE.possibleValues) { for (enum in WorkerState.SEMI_WORKER_STATE.possibleValues) { part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_bottler_${enum.name.lowercase()}"))) - .rotationY(dir.primary.toYRotBlockstate()) + .rotationY(dir.front.toYRotBlockstate()) .addModel() .condition(BlockRotationFreedom.ONE.property, dir) .condition(WorkerState.WORKER_STATE, enum) @@ -62,14 +61,14 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { for (dir in BlockRotationFreedom.ONE.possibleValues) { for (enum in MatterBottlerBlock.SLOT_PROPERTIES) { part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_bottler_${enum.name}_open"))) - .rotationY(dir.primary.toYRotBlockstate()) + .rotationY(dir.front.toYRotBlockstate()) .addModel() .condition(BlockRotationFreedom.ONE.property, dir) .condition(enum, false) .end() part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_bottler_${enum.name}_closed"))) - .rotationY(dir.primary.toYRotBlockstate()) + .rotationY(dir.front.toYRotBlockstate()) .addModel() .condition(BlockRotationFreedom.ONE.property, dir) .condition(enum, true) @@ -99,7 +98,7 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { OverdriveThatMatters.MOD_ID, "${crate.registryName!!.path}_${if (it.getValue( CargoCrateBlock.IS_OPEN)) "open" else "closed"}") )) - .rotationY(it.getValue(BlockRotationFreedom.ONE.property).primary.toYRotBlockstate()) + .rotationY(it.getValue(BlockRotationFreedom.ONE.property).front.toYRotBlockstate()) .buildLast() ) } @@ -108,17 +107,17 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { with(provider.getMultipartBuilder(MBlocks.STORAGE_BUS)) { for (dir in BlockRotationFreedom.TWO.possibleValues) { part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_bus"))) - .rotationX(dir.primary.toXRotBlockstate()) - .rotationY(dir.primary.toYRotBlockstate()) + .rotationX(dir.front.toXRotBlockstate()) + .rotationY(dir.front.toYRotBlockstate()) .addModel() .condition(BlockRotationFreedom.TWO.property, dir) .end() part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_connection"))) - .rotationX(dir.primary.toXRotBlockstateInv()) - .rotationY(dir.primary.toYRotBlockstateInv()) + .rotationX(dir.front.toXRotBlockstateInv()) + .rotationY(dir.front.toYRotBlockstateInv()) .addModel() - .condition(CableBlock.MAPPING_CONNECTION_PROP[dir.primary]!!, true) + .condition(CableBlock.MAPPING_CONNECTION_PROP[dir.front]!!, true) .end() } @@ -129,17 +128,17 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { with(provider.getMultipartBuilder(MBlocks.STORAGE_IMPORTER)) { for (dir in BlockRotationFreedom.TWO.possibleValues) { part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_importer"))) - .rotationX(dir.primary.toXRotBlockstate()) - .rotationY(dir.primary.toYRotBlockstate()) + .rotationX(dir.front.toXRotBlockstate()) + .rotationY(dir.front.toYRotBlockstate()) .addModel() .condition(BlockRotationFreedom.TWO.property, dir) .end() part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_connection"))) - .rotationX(dir.primary.toXRotBlockstateInv()) - .rotationY(dir.primary.toYRotBlockstateInv()) + .rotationX(dir.front.toXRotBlockstateInv()) + .rotationY(dir.front.toYRotBlockstateInv()) .addModel() - .condition(CableBlock.MAPPING_CONNECTION_PROP[dir.primary]!!, true) + .condition(CableBlock.MAPPING_CONNECTION_PROP[dir.front]!!, true) .end() } @@ -150,17 +149,17 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { with(provider.getMultipartBuilder(MBlocks.STORAGE_EXPORTER)) { for (dir in BlockRotationFreedom.TWO.possibleValues) { part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_exporter"))) - .rotationX(dir.primary.toXRotBlockstate()) - .rotationY(dir.primary.toYRotBlockstate()) + .rotationX(dir.front.toXRotBlockstate()) + .rotationY(dir.front.toYRotBlockstate()) .addModel() .condition(BlockRotationFreedom.TWO.property, dir) .end() part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_connection"))) - .rotationX(dir.primary.toXRotBlockstateInv()) - .rotationY(dir.primary.toYRotBlockstateInv()) + .rotationX(dir.front.toXRotBlockstateInv()) + .rotationY(dir.front.toYRotBlockstateInv()) .addModel() - .condition(CableBlock.MAPPING_CONNECTION_PROP[dir.primary]!!, true) + .condition(CableBlock.MAPPING_CONNECTION_PROP[dir.front]!!, true) .end() } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt index 4deeb9760..714934982 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt @@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.datagen.blocks import net.minecraft.core.Direction import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.block.tech.EnergyCounterBlock -import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.matter.PatternStorageBlock import ru.dbotthepony.mc.otm.block.storage.DriveViewerBlock @@ -17,7 +16,7 @@ fun addComplexBlockStates(provider: MatteryBlockStateProvider) { for (facing in BlockRotationFreedom.ONE.possibleValues) { part() .modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/drive_viewer_drive_part"))) - .rotationY(facing.primary.toYRotBlockstate()) + .rotationY(facing.front.toYRotBlockstate()) .addModel() .condition(BlockRotationFreedom.ONE.property, facing) .condition(DriveViewerBlock.DRIVE_PRESENT, true) @@ -25,7 +24,7 @@ fun addComplexBlockStates(provider: MatteryBlockStateProvider) { for (workState in WorkerState.SEMI_WORKER_STATE.possibleValues) { part() .modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/drive_viewer_${workState.name.lowercase()}"))) - .rotationY(facing.primary.toYRotBlockstate()) + .rotationY(facing.front.toYRotBlockstate()) .addModel() .condition(WorkerState.SEMI_WORKER_STATE, workState) .condition(BlockRotationFreedom.ONE.property, facing) @@ -37,14 +36,14 @@ fun addComplexBlockStates(provider: MatteryBlockStateProvider) { for (facing in BlockRotationFreedom.ONE.possibleValues) { part() .modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/pattern_storage"))) - .rotationY(facing.primary.toYRotBlockstate()) + .rotationY(facing.front.toYRotBlockstate()) .addModel() .condition(BlockRotationFreedom.ONE.property, facing) for (i in 0 .. 7) { part() .modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/pattern/model$i"))) - .rotationY(facing.primary.toYRotBlockstate()) + .rotationY(facing.front.toYRotBlockstate()) .addModel() .condition(BlockRotationFreedom.ONE.property, facing) .condition(PatternStorageBlock.PATTERN_STORAGE_DISKS_PROPS[i], true) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt index ed3aba803..01a084807 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt @@ -6,7 +6,6 @@ import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.client.model.generators.BlockStateProvider import net.minecraftforge.client.model.generators.ConfiguredModel import net.minecraftforge.data.event.GatherDataEvent -import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.datagen.DataGen @@ -23,17 +22,17 @@ private fun initialTransform(it: BlockState, modelPath: String, builder: Configu @Suppress("NAME_SHADOWING") var modelPath = modelPath it.getValueNullable(BlockRotationFreedom.ONE.property)?.let { - builder.rotationY(it.primary.toYRotBlockstate()) + builder.rotationY(it.front.toYRotBlockstate()) } it.getValueNullable(BlockRotationFreedom.TWO.property)?.let { - builder.rotationY(it.primary.toYRotBlockstate()) - builder.rotationX(it.primary.toXRotBlockstate()) + builder.rotationY(it.front.toYRotBlockstate()) + builder.rotationX(it.front.toXRotBlockstate()) } it.getValueNullable(BlockRotationFreedom.THREE.property)?.let { - builder.rotationY(it.primary.toYRotBlockstate() + (it.secondary?.toYRotBlockstate() ?: 0)) - builder.rotationX(it.primary.toXRotBlockstate()) + builder.rotationY(it.front.toYRotBlockstate() + it.top.toYRotBlockstate()) + builder.rotationX(it.front.toXRotBlockstate()) } it.getValueNullable(WorkerState.WORKER_STATE)?.let { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt index 892393764..0fa3772af 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt @@ -92,7 +92,7 @@ abstract class MatteryBlock @JvmOverloads constructor( yd += ny * 0.5 zd += nz * 0.5 - when (direction.primary) { + when (direction.front) { Direction.DOWN, Direction.UP -> { xd += random.nextDouble() - 0.5 zd += random.nextDouble() - 0.5 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/RotatableMatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/RotatableMatteryBlock.kt index fa7689090..401853578 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/RotatableMatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/RotatableMatteryBlock.kt @@ -24,12 +24,12 @@ abstract class RotatableMatteryBlock @JvmOverloads constructor(properties: Prope return when (val freedom = rotationFreedom()) { BlockRotationFreedom.ONE -> defaultBlockState().setValue( freedom.property, - BlockRotation.of(if (faceToPlayer(context)) context.horizontalDirection.opposite else context.horizontalDirection) + freedom.of(if (faceToPlayer(context)) context.horizontalDirection.opposite else context.horizontalDirection) ) BlockRotationFreedom.TWO -> defaultBlockState().setValue( freedom.property, - BlockRotation.of(if (faceToPlayer(context)) context.nearestLookingDirection.opposite else context.nearestLookingDirection) + freedom.of(if (faceToPlayer(context)) context.nearestLookingDirection.opposite else context.nearestLookingDirection) ) BlockRotationFreedom.THREE -> { @@ -42,9 +42,11 @@ abstract class RotatableMatteryBlock @JvmOverloads constructor(properties: Prope defaultBlockState().setValue( freedom.property, - BlockRotation.ofSafe(primary, secondary) + freedom.of(primary, secondary) ) } + + BlockRotationFreedom.FOUR -> TODO("Can't rotate with four rotation freedom yet") } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt index c3103284c..43b24a62e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt @@ -18,7 +18,7 @@ class EngineBlock : RotatableMatteryBlock(Properties.of(Material.METAL, DyeColor } private val shapes = getShapeForEachState { - BlockShapes.ENGINE.rotateInv(it[rotationProperty].primary).computeShape() + BlockShapes.ENGINE.rotateInv(it[rotationProperty].front).computeShape() } override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt index 92f861ff4..124c10eb1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt @@ -23,7 +23,7 @@ class HoloSignBlock : RotatableMatteryBlock(), EntityBlock { } private val shapes = getShapeForEachState { - BlockShapes.HOLO_SIGN.rotateInv(it[rotationProperty].primary).computeShape() + BlockShapes.HOLO_SIGN.rotateInv(it[rotationProperty].front).computeShape() } override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt index 4ac58d7b3..b03a534fc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt @@ -20,7 +20,6 @@ import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.items.IItemHandler import ru.dbotthepony.mc.otm.* import ru.dbotthepony.mc.otm.block.CableBlock -import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.AbstractStorageImportExport.Companion.FILTER_KEY import ru.dbotthepony.mc.otm.capability.MatteryCapability @@ -32,7 +31,6 @@ import ru.dbotthepony.mc.otm.core.math.getCapability import ru.dbotthepony.mc.otm.core.math.isPositive import ru.dbotthepony.mc.otm.core.math.isZero import ru.dbotthepony.mc.otm.core.math.plus -import ru.dbotthepony.mc.otm.core.math.unaryMinus import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.graph.Graph6Node @@ -113,7 +111,7 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter private var valid = true override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - return if (valid && cap === MatteryCapability.STORAGE_NODE && side != blockState.getValue(BlockRotationFreedom.TWO.property).primary) { + return if (valid && cap === MatteryCapability.STORAGE_NODE && side != blockState.getValue(BlockRotationFreedom.TWO.property).front) { cell.get().cast() } else super.getCapability(cap, side) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt index c06fda606..3b1762b84 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt @@ -19,7 +19,6 @@ import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.items.IItemHandler import ru.dbotthepony.mc.otm.* import ru.dbotthepony.mc.otm.block.CableBlock -import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage @@ -75,7 +74,7 @@ abstract class AbstractStorageImportExport( private var valid = true override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - return if (valid && cap === MatteryCapability.STORAGE_NODE && side != blockState.getValue(BlockRotationFreedom.TWO.property).primary) { + return if (valid && cap === MatteryCapability.STORAGE_NODE && side != blockState.getValue(BlockRotationFreedom.TWO.property).front) { cell.get().cast() } else super.getCapability(cap, side) } @@ -114,7 +113,7 @@ abstract class AbstractStorageImportExport( protected val target by lazy { object : BESubscribeList(this@AbstractStorageImportExport, targetCapability) { override fun test(t: Direction): Boolean { - return t == -this@AbstractStorageImportExport.blockState.getValue(BlockRotationFreedom.TWO.property).primary + return t == -this@AbstractStorageImportExport.blockState.getValue(BlockRotationFreedom.TWO.property).front } } } @@ -179,7 +178,7 @@ class StorageImporterBlockEntity(blockPos: BlockPos, blockState: BlockState) } override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - if (valid && cap == ForgeCapabilities.ITEM_HANDLER && side == blockState.rotationTwo.primary) { + if (valid && cap == ForgeCapabilities.ITEM_HANDLER && side == blockState.rotationTwo.front) { return resolverItemHandler.cast() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterPanelBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterPanelBlock.kt index 4a8076269..0b593d258 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterPanelBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterPanelBlock.kt @@ -11,11 +11,7 @@ import net.minecraft.world.phys.shapes.VoxelShape import net.minecraft.world.phys.shapes.Shapes import net.minecraft.world.level.BlockGetter import net.minecraft.world.phys.shapes.CollisionContext -import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.item.context.BlockPlaceContext -import net.minecraft.world.level.block.Block -import net.minecraft.world.level.block.state.properties.EnumProperty -import ru.dbotthepony.mc.otm.block.MatteryBlock import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom @@ -32,7 +28,7 @@ class MatterPanelBlock : RotatableMatteryBlock(), EntityBlock { registerDefaultState(getStateDefinition().any().setValue(BlockRotationFreedom.TWO.property, BlockRotation.SOUTH)) shapes = getShapeForEachState { - when (it.rotationTwo.primary) { + when (it.rotationTwo.front) { Direction.NORTH -> Shapes.box( 0.0, 0.0, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt index f7a82cbd6..b178aba8b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt @@ -213,7 +213,7 @@ class BlockGravitationStabilizerLens : RotatableMatteryBlock(props) { } fun getBoundingBlockPos(blockState: BlockState, blockPos: BlockPos): BlockPos { - return blockPos + blockState.getValue(BlockRotationFreedom.TWO.property).opposite.normal + return blockPos + blockState.getValue(BlockRotationFreedom.TWO.property).front.opposite.normal } private val SHAPES = arrayOf( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt index b77eec949..c484b2441 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt @@ -8,12 +8,13 @@ import net.minecraft.world.level.block.Rotation import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ICapabilityProvider import net.minecraftforge.common.util.LazyOptional +import java.util.EnumMap internal inline val Direction.blockRotation get() = BlockRotation.of(this) fun ICapabilityProvider.getCapability(capability: Capability, side: BlockRotation?): LazyOptional { - return getCapability(capability, side?.primary) + return getCapability(capability, side?.front) } operator fun Vec3i.plus(other: BlockRotation): Vec3i { @@ -25,15 +26,18 @@ operator fun BlockPos.plus(other: BlockRotation): BlockPos { } /** - * [secondary] clarifies about block's top facing direction, NOT bottom + * [top] clarifies about block's top facing direction, NOT bottom */ -enum class BlockRotation(val primary: Direction, val secondary: Direction?) : StringRepresentable { +enum class BlockRotation( + val front: Direction, + val top: Direction, +) : StringRepresentable { DOWN(Direction.DOWN, Direction.NORTH), UP(Direction.UP, Direction.NORTH), - NORTH(Direction.NORTH, null), - SOUTH(Direction.SOUTH, null), - WEST(Direction.WEST, null), - EAST(Direction.EAST, null), + NORTH(Direction.NORTH, Direction.UP), + SOUTH(Direction.SOUTH, Direction.UP), + WEST(Direction.WEST, Direction.UP), + EAST(Direction.EAST, Direction.UP), DOWN_SOUTH(Direction.DOWN, Direction.SOUTH), DOWN_WEST(Direction.DOWN, Direction.WEST), @@ -41,7 +45,43 @@ enum class BlockRotation(val primary: Direction, val secondary: Direction?) : St UP_SOUTH(Direction.UP, Direction.SOUTH), UP_WEST(Direction.UP, Direction.WEST), - UP_EAST(Direction.UP, Direction.EAST); + UP_EAST(Direction.UP, Direction.EAST), + + /** + * This rotation is impossible to achieve using blockstates because blockstate def can't rotate models in XY plane (z axis) + */ + NORTH_DOWN(Direction.NORTH, Direction.DOWN), + + /** + * This rotation is impossible to achieve using blockstates because blockstate def can't rotate models in XY plane (z axis) + */ + SOUTH_DOWN(Direction.SOUTH, Direction.DOWN), + + /** + * This rotation is impossible to achieve using blockstates because blockstate def can't rotate models in XY plane (z axis) + */ + WEST_DOWN(Direction.WEST, Direction.DOWN), + + /** + * This rotation is impossible to achieve using blockstates because blockstate def can't rotate models in XY plane (z axis) + */ + EAST_DOWN(Direction.EAST, Direction.DOWN), + ; + + val right: Direction + + init { + val crossproduct = front.normal.cross(top.normal) + right = Direction.values().first { it.normal == crossproduct } + } + + val left: Direction = right.opposite + val bottom: Direction = top.opposite + val back: Direction = front.opposite + + operator fun component1() = front + operator fun component2() = top + operator fun component3() = left val lowercaseName = name.lowercase() @@ -50,7 +90,7 @@ enum class BlockRotation(val primary: Direction, val secondary: Direction?) : St } fun rotate(by: Rotation): BlockRotation { - return of(by.rotate(primary), secondary) + return of(by.rotate(front), top) } operator fun times(other: Int): Vec3i { @@ -72,8 +112,8 @@ enum class BlockRotation(val primary: Direction, val secondary: Direction?) : St operator fun unaryMinus() = opposite // more performant - val opposite by lazy { of(primary.opposite, secondary?.opposite) } - val normal: Vec3i get() = primary.normal + val opposite by lazy { of(front.opposite, top.opposite) } + val normal: Vec3i get() = front.normal companion object { @JvmStatic @@ -88,77 +128,26 @@ enum class BlockRotation(val primary: Direction, val secondary: Direction?) : St } } - @JvmStatic - fun of(primary: Direction, secondary: Direction?): BlockRotation { - return when (primary) { - Direction.NORTH -> { - require(secondary == null) { "Impossible direction: $primary - $secondary" } - NORTH - } + private val mapped = EnumMap>(Direction::class.java) - Direction.SOUTH -> { - require(secondary == null) { "Impossible direction: $primary - $secondary" } - SOUTH - } - - Direction.WEST -> { - require(secondary == null) { "Impossible direction: $primary - $secondary" } - WEST - } - - Direction.EAST -> { - require(secondary == null) { "Impossible direction: $primary - $secondary" } - EAST - } - - Direction.UP -> { - when (secondary) { - null -> UP - Direction.SOUTH -> UP_SOUTH - Direction.WEST -> UP_WEST - Direction.EAST -> UP_EAST - else -> throw IllegalArgumentException("Impossible direction: $primary - $secondary") - } - } - - Direction.DOWN -> { - when (secondary) { - null -> DOWN - Direction.SOUTH -> DOWN_SOUTH - Direction.WEST -> DOWN_WEST - Direction.EAST -> DOWN_EAST - else -> throw IllegalArgumentException("Impossible direction: $primary - $secondary") - } - } + init { + for (value in values()) { + val (front, top) = value + mapped.computeIfAbsent(front) { EnumMap(Direction::class.java) }.put(top, value) } } @JvmStatic - fun ofSafe(primary: Direction, secondary: Direction?): BlockRotation { - return when (primary) { - Direction.NORTH -> NORTH - Direction.SOUTH -> SOUTH - Direction.WEST -> WEST - Direction.EAST -> EAST + fun of(front: Direction, top: Direction?): BlockRotation { + val f = mapped[front]!! + return f[top ?: (if (front == Direction.DOWN || front == Direction.UP) Direction.NORTH else Direction.UP)] ?: throw IllegalArgumentException("Impossible block rotation: $front - $top") + } - Direction.UP -> { - when (secondary) { - Direction.SOUTH -> UP_SOUTH - Direction.WEST -> UP_WEST - Direction.EAST -> UP_EAST - else -> UP - } - } - - Direction.DOWN -> { - when (secondary) { - Direction.SOUTH -> DOWN_SOUTH - Direction.WEST -> DOWN_WEST - Direction.EAST -> DOWN_EAST - else -> DOWN - } - } - } + @JvmStatic + fun ofSafe(front: Direction, top: Direction?): BlockRotation { + val f = mapped[front]!! + val computeTop = if (front == Direction.DOWN || front == Direction.UP) Direction.NORTH else Direction.UP + return f[top ?: computeTop] ?: f[computeTop] ?: f.values.first() } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotationFreedom.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotationFreedom.kt index 2f131ba8e..cb479a34d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotationFreedom.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotationFreedom.kt @@ -4,14 +4,15 @@ import net.minecraft.core.Direction import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.properties.EnumProperty import ru.dbotthepony.mc.otm.core.get +import java.util.EnumMap internal inline val BlockState.rotationOne: BlockRotation get() = this[BlockRotationFreedom.ONE.property] internal inline val BlockState.rotationTwo: BlockRotation get() = this[BlockRotationFreedom.TWO.property] internal inline val BlockState.rotationThree: BlockRotation get() = this[BlockRotationFreedom.THREE.property] -internal inline val BlockState.facingOne: Direction get() = this[BlockRotationFreedom.ONE.property].primary -internal inline val BlockState.facingTwo: Direction get() = this[BlockRotationFreedom.TWO.property].primary -internal inline val BlockState.facingThree: Direction get() = this[BlockRotationFreedom.THREE.property].primary +internal inline val BlockState.facingOne: Direction get() = this[BlockRotationFreedom.ONE.property].front +internal inline val BlockState.facingTwo: Direction get() = this[BlockRotationFreedom.TWO.property].front +internal inline val BlockState.facingThree: Direction get() = this[BlockRotationFreedom.THREE.property].front enum class BlockRotationFreedom(vararg values: BlockRotation) { ONE( @@ -41,8 +42,57 @@ enum class BlockRotationFreedom(vararg values: BlockRotation) { BlockRotation.UP_SOUTH, BlockRotation.UP_WEST, BlockRotation.UP_EAST, + ), + + /** + * These rotations are impossible to achieve using blockstates because blockstate def can't rotate models in XY plane (z axis) + */ + FOUR( + BlockRotation.DOWN, + BlockRotation.UP, + BlockRotation.NORTH, + BlockRotation.SOUTH, + BlockRotation.WEST, + BlockRotation.EAST, + BlockRotation.DOWN_SOUTH, + BlockRotation.DOWN_WEST, + BlockRotation.DOWN_EAST, + BlockRotation.UP_SOUTH, + BlockRotation.UP_WEST, + BlockRotation.UP_EAST, + BlockRotation.NORTH_DOWN, + BlockRotation.SOUTH_DOWN, + BlockRotation.WEST_DOWN, + BlockRotation.EAST_DOWN, ); val possibleValues: Collection get() = property.possibleValues val property: EnumProperty = EnumProperty.create("facing", BlockRotation::class.java, *values) + + private val oneDirection = EnumMap(Direction::class.java) + private val twoDirection = EnumMap>(Direction::class.java) + + init { + for (direction in Direction.values()) { + oneDirection[direction] = possibleValues.firstOrNull { it.front == direction } + ?: possibleValues.first() + + val second = EnumMap(Direction::class.java) + twoDirection[direction] = second + + for (direction2 in Direction.values()) { + second[direction2] = possibleValues.firstOrNull { it.front == direction && it.top == direction2 } + ?: possibleValues.firstOrNull { it.front == direction } + ?: possibleValues.first() + } + } + } + + fun of(front: Direction): BlockRotation { + return oneDirection[front]!! + } + + fun of(front: Direction, top: Direction = Direction.UP): BlockRotation { + return twoDirection[front]!![top]!! + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/EuclidMath.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/EuclidMath.kt index 3b8c60b5f..86045f6f4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/EuclidMath.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/EuclidMath.kt @@ -648,7 +648,7 @@ fun PoseStack.rotateWithBlockFacing(rotation: Direction, clarifyingAxis: Directi } fun PoseStack.rotateWithBlockFacing(rotation: BlockRotation): PoseStack { - return rotateWithBlockFacing(rotation = rotation.primary, clarifyingAxis = rotation.secondary) + return rotateWithBlockFacing(rotation = rotation.front, clarifyingAxis = rotation.top) } fun PoseStack.rotateYDegrees(rotation: Float): PoseStack { From 643ca8385131f9f7ba942066009e057076600c1d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 30 Jan 2023 15:52:59 +0700 Subject: [PATCH 0155/1199] BlockShape.rotateFromNorth and rotateFromSouth --- .../dbotthepony/mc/otm/shapes/BlockShape.java | 23 +++++++++++++++++-- .../mc/otm/block/decorative/EngineBlock.kt | 2 +- .../mc/otm/block/decorative/HoloSignBlock.kt | 2 +- .../mc/otm/block/matter/MatterBottlerBlock.kt | 6 ++--- .../block/matter/MatterCapacitorBankBlock.kt | 6 ++--- .../otm/block/matter/MatterDecomposerBlock.kt | 6 ++--- .../otm/block/matter/MatterRecyclerBlock.kt | 6 ++--- .../otm/block/matter/MatterReplicatorBlock.kt | 6 ++--- .../mc/otm/block/matter/MatterScannerBlock.kt | 6 ++--- .../otm/block/matter/PatternStorageBlock.kt | 6 ++--- .../mc/otm/block/storage/DriveRackBlock.kt | 6 ++--- .../mc/otm/block/storage/DriveViewerBlock.kt | 6 ++--- .../mc/otm/block/storage/ItemMonitorBlock.kt | 6 ++--- .../mc/otm/block/storage/StorageBusBlock.kt | 2 +- .../mc/otm/block/storage/StorageInterfaces.kt | 4 ++-- .../storage/StoragePowerSupplierBlock.kt | 6 ++--- .../mc/otm/block/tech/BatteryBankBlock.kt | 6 ++--- .../otm/block/tech/ChemicalGeneratorBlock.kt | 6 ++--- .../mc/otm/block/tech/EnergyCounterBlock.kt | 2 +- .../mc/otm/block/tech/EnergyServoBlock.kt | 12 +++++----- .../block/tech/GravitationStabilizerBlock.kt | 12 +++++----- .../otm/block/tech/PhantomAttractorBlock.kt | 2 +- .../mc/otm/block/tech/PlatePressBlock.kt | 6 ++--- 23 files changed, 82 insertions(+), 63 deletions(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShape.java b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShape.java index 225b5afdc..daadec952 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShape.java +++ b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShape.java @@ -5,6 +5,7 @@ import net.minecraft.core.Direction; import net.minecraft.world.phys.shapes.BooleanOp; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; +import ru.dbotthepony.mc.otm.core.math.BlockRotation; import javax.annotation.ParametersAreNonnullByDefault; @@ -47,7 +48,7 @@ public record BlockShape(SimpleCuboid ...shapes) { return new BlockShape(list); } - public BlockShape rotate(Direction dir) { + public BlockShape rotateFromSouth(Direction dir) { if (dir == Direction.SOUTH) return this; @@ -69,7 +70,7 @@ public record BlockShape(SimpleCuboid ...shapes) { return this; } - public BlockShape rotateInv(Direction dir) { + public BlockShape rotateFromNorth(Direction dir) { if (dir == Direction.SOUTH) return rotateAroundY(Math.PI); @@ -91,6 +92,24 @@ public record BlockShape(SimpleCuboid ...shapes) { return this; } + public BlockShape rotateFromNorth(BlockRotation dir) { + var result = rotateFromNorth(dir.getFront()); + + if (dir.getTop() != Direction.DOWN && dir.getTop() != Direction.UP) + result = result.rotateFromNorth(dir.getTop()); + + return result; + } + + public BlockShape rotateFromSouth(BlockRotation dir) { + var result = rotateFromSouth(dir.getFront()); + + if (dir.getTop() != Direction.DOWN && dir.getTop() != Direction.UP) + result = result.rotateFromSouth(dir.getTop()); + + return result; + } + public VoxelShape computeShape() { VoxelShape final_shape = shapes[0].getShape(); diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt index 43b24a62e..9590835f8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt @@ -18,7 +18,7 @@ class EngineBlock : RotatableMatteryBlock(Properties.of(Material.METAL, DyeColor } private val shapes = getShapeForEachState { - BlockShapes.ENGINE.rotateInv(it[rotationProperty].front).computeShape() + BlockShapes.ENGINE.rotateFromNorth(it[rotationProperty].front).computeShape() } override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt index 124c10eb1..c5c275f34 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt @@ -23,7 +23,7 @@ class HoloSignBlock : RotatableMatteryBlock(), EntityBlock { } private val shapes = getShapeForEachState { - BlockShapes.HOLO_SIGN.rotateInv(it[rotationProperty].front).computeShape() + BlockShapes.HOLO_SIGN.rotateFromNorth(it[rotationProperty]).computeShape() } override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt index dcf6e2cd6..9fbe19b32 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt @@ -76,9 +76,9 @@ class MatterBottlerBlock : RotatableMatteryBlock(), EntityBlock { def, def, def, - BlockShapes.MATTER_BOTTLER.rotate(Direction.NORTH).computeShape(), - BlockShapes.MATTER_BOTTLER.rotate(Direction.WEST).computeShape(), - BlockShapes.MATTER_BOTTLER.rotate(Direction.EAST).computeShape() + BlockShapes.MATTER_BOTTLER.rotateFromSouth(Direction.NORTH).computeShape(), + BlockShapes.MATTER_BOTTLER.rotateFromSouth(Direction.WEST).computeShape(), + BlockShapes.MATTER_BOTTLER.rotateFromSouth(Direction.EAST).computeShape() ) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt index 323b3f199..354c80bf3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt @@ -55,9 +55,9 @@ class MatterCapacitorBankBlock : RotatableMatteryBlock(), EntityBlock { def, def, def, - BlockShapes.MATTER_CAPACITOR_BANK.rotate(Direction.NORTH).computeShape(), - BlockShapes.MATTER_CAPACITOR_BANK.rotate(Direction.WEST).computeShape(), - BlockShapes.MATTER_CAPACITOR_BANK.rotate(Direction.EAST).computeShape() + BlockShapes.MATTER_CAPACITOR_BANK.rotateFromSouth(Direction.NORTH).computeShape(), + BlockShapes.MATTER_CAPACITOR_BANK.rotateFromSouth(Direction.WEST).computeShape(), + BlockShapes.MATTER_CAPACITOR_BANK.rotateFromSouth(Direction.EAST).computeShape() ) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt index 3adfc867f..d9f7f955d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt @@ -61,9 +61,9 @@ class MatterDecomposerBlock : RotatableMatteryBlock(), EntityBlock { def, def, def, - BlockShapes.MATTER_DECOMPOSER.rotate(Direction.NORTH).computeShape(), - BlockShapes.MATTER_DECOMPOSER.rotate(Direction.WEST).computeShape(), - BlockShapes.MATTER_DECOMPOSER.rotate(Direction.EAST).computeShape() + BlockShapes.MATTER_DECOMPOSER.rotateFromSouth(Direction.NORTH).computeShape(), + BlockShapes.MATTER_DECOMPOSER.rotateFromSouth(Direction.WEST).computeShape(), + BlockShapes.MATTER_DECOMPOSER.rotateFromSouth(Direction.EAST).computeShape() ) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt index 34d471188..e1e4d406a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt @@ -60,9 +60,9 @@ class MatterRecyclerBlock : RotatableMatteryBlock(), EntityBlock { def, def, def, - BlockShapes.MATTER_RECYCLER.rotate(Direction.NORTH).computeShape(), - BlockShapes.MATTER_RECYCLER.rotate(Direction.WEST).computeShape(), - BlockShapes.MATTER_RECYCLER.rotate(Direction.EAST).computeShape() + BlockShapes.MATTER_RECYCLER.rotateFromSouth(Direction.NORTH).computeShape(), + BlockShapes.MATTER_RECYCLER.rotateFromSouth(Direction.WEST).computeShape(), + BlockShapes.MATTER_RECYCLER.rotateFromSouth(Direction.EAST).computeShape() ) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt index c90943d5d..9219a2cec 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt @@ -60,9 +60,9 @@ class MatterReplicatorBlock : RotatableMatteryBlock(), EntityBlock { def, def, def, - BlockShapes.MATTER_REPLICATOR.rotate(Direction.NORTH).computeShape(), - BlockShapes.MATTER_REPLICATOR.rotate(Direction.WEST).computeShape(), - BlockShapes.MATTER_REPLICATOR.rotate(Direction.EAST).computeShape() + BlockShapes.MATTER_REPLICATOR.rotateFromSouth(Direction.NORTH).computeShape(), + BlockShapes.MATTER_REPLICATOR.rotateFromSouth(Direction.WEST).computeShape(), + BlockShapes.MATTER_REPLICATOR.rotateFromSouth(Direction.EAST).computeShape() ) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt index a7efee532..352d218ba 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt @@ -60,9 +60,9 @@ class MatterScannerBlock : RotatableMatteryBlock(), EntityBlock { def, def, def, - BlockShapes.MATTER_SCANNER.rotate(Direction.NORTH).computeShape(), - BlockShapes.MATTER_SCANNER.rotate(Direction.WEST).computeShape(), - BlockShapes.MATTER_SCANNER.rotate(Direction.EAST).computeShape() + BlockShapes.MATTER_SCANNER.rotateFromSouth(Direction.NORTH).computeShape(), + BlockShapes.MATTER_SCANNER.rotateFromSouth(Direction.WEST).computeShape(), + BlockShapes.MATTER_SCANNER.rotateFromSouth(Direction.EAST).computeShape() ) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt index 30813617f..cb2a17a62 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt @@ -87,9 +87,9 @@ class PatternStorageBlock : RotatableMatteryBlock(), EntityBlock { def, def, def, - BlockShapes.PATTERN_STORAGE.rotate(Direction.NORTH).computeShape(), - BlockShapes.PATTERN_STORAGE.rotate(Direction.WEST).computeShape(), - BlockShapes.PATTERN_STORAGE.rotate(Direction.EAST).computeShape() + BlockShapes.PATTERN_STORAGE.rotateFromSouth(Direction.NORTH).computeShape(), + BlockShapes.PATTERN_STORAGE.rotateFromSouth(Direction.WEST).computeShape(), + BlockShapes.PATTERN_STORAGE.rotateFromSouth(Direction.EAST).computeShape() ) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt index f88f67b5e..0b5f87892 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt @@ -65,9 +65,9 @@ class DriveRackBlock : RotatableMatteryBlock(), EntityBlock { def, def, def, - BlockShapes.DRIVE_RACK.rotate(Direction.NORTH).computeShape(), - BlockShapes.DRIVE_RACK.rotate(Direction.WEST).computeShape(), - BlockShapes.DRIVE_RACK.rotate(Direction.EAST).computeShape() + BlockShapes.DRIVE_RACK.rotateFromSouth(Direction.NORTH).computeShape(), + BlockShapes.DRIVE_RACK.rotateFromSouth(Direction.WEST).computeShape(), + BlockShapes.DRIVE_RACK.rotateFromSouth(Direction.EAST).computeShape() ) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt index 45fe6a2bd..4e1c2007b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt @@ -84,9 +84,9 @@ class DriveViewerBlock : RotatableMatteryBlock(), EntityBlock { def, def, def, - BlockShapes.DRIVE_VIEWER.rotate(Direction.NORTH).computeShape(), - BlockShapes.DRIVE_VIEWER.rotate(Direction.WEST).computeShape(), - BlockShapes.DRIVE_VIEWER.rotate(Direction.EAST).computeShape() + BlockShapes.DRIVE_VIEWER.rotateFromSouth(Direction.NORTH).computeShape(), + BlockShapes.DRIVE_VIEWER.rotateFromSouth(Direction.WEST).computeShape(), + BlockShapes.DRIVE_VIEWER.rotateFromSouth(Direction.EAST).computeShape() ) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt index 95dfe2786..5a8566257 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt @@ -65,9 +65,9 @@ class ItemMonitorBlock : RotatableMatteryBlock(), EntityBlock { def, def, def, - BlockShapes.ITEM_MONITOR.rotate(Direction.NORTH).computeShape(), - BlockShapes.ITEM_MONITOR.rotate(Direction.WEST).computeShape(), - BlockShapes.ITEM_MONITOR.rotate(Direction.EAST).computeShape() + BlockShapes.ITEM_MONITOR.rotateFromSouth(Direction.NORTH).computeShape(), + BlockShapes.ITEM_MONITOR.rotateFromSouth(Direction.WEST).computeShape(), + BlockShapes.ITEM_MONITOR.rotateFromSouth(Direction.EAST).computeShape() ) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt index 544f5d006..d5f054f7f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt @@ -98,7 +98,7 @@ class StorageBusBlock : RotatableMatteryBlock(), EntityBlock { finalShape = Shapes.joinUnoptimized(finalShape, shapes[i], BooleanOp.OR) } - finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_BUS.rotateInv(it.facingTwo).computeShape(), BooleanOp.OR) + finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_BUS.rotateFromNorth(it.facingTwo).computeShape(), BooleanOp.OR) return@getShapeForEachState finalShape } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt index 0b8fb51f3..9d333a0db 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt @@ -99,7 +99,7 @@ class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock { finalShape = Shapes.joinUnoptimized(finalShape, shapes[i], BooleanOp.OR) } - finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_IMPORTER.rotateInv(it.facingTwo).computeShape(), BooleanOp.OR) + finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_IMPORTER.rotateFromNorth(it.facingTwo).computeShape(), BooleanOp.OR) return@getShapeForEachState finalShape } @@ -203,7 +203,7 @@ class StorageExporterBlock : RotatableMatteryBlock(), EntityBlock { finalShape = Shapes.joinUnoptimized(finalShape, shapes[i], BooleanOp.OR) } - finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_EXPORTER.rotateInv(it.facingTwo).computeShape(), BooleanOp.OR) + finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_EXPORTER.rotateFromNorth(it.facingTwo).computeShape(), BooleanOp.OR) return@getShapeForEachState finalShape } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt index e4d59f655..2aad23266 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt @@ -68,9 +68,9 @@ class StoragePowerSupplierBlock : RotatableMatteryBlock(), EntityBlock { def, def, def, - BlockShapes.STORAGE_POWER_SUPPLIER.rotate(Direction.NORTH).computeShape(), - BlockShapes.STORAGE_POWER_SUPPLIER.rotate(Direction.WEST).computeShape(), - BlockShapes.STORAGE_POWER_SUPPLIER.rotate(Direction.EAST).computeShape() + BlockShapes.STORAGE_POWER_SUPPLIER.rotateFromSouth(Direction.NORTH).computeShape(), + BlockShapes.STORAGE_POWER_SUPPLIER.rotateFromSouth(Direction.WEST).computeShape(), + BlockShapes.STORAGE_POWER_SUPPLIER.rotateFromSouth(Direction.EAST).computeShape() ) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt index 79496afe2..03c2186ef 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt @@ -107,9 +107,9 @@ class BatteryBankBlock : RotatableMatteryBlock(), EntityBlock { def, def, def, - BlockShapes.BATTERY_BANK.rotate(Direction.NORTH).computeShape(), - BlockShapes.BATTERY_BANK.rotate(Direction.WEST).computeShape(), - BlockShapes.BATTERY_BANK.rotate(Direction.EAST).computeShape() + BlockShapes.BATTERY_BANK.rotateFromSouth(Direction.NORTH).computeShape(), + BlockShapes.BATTERY_BANK.rotateFromSouth(Direction.WEST).computeShape(), + BlockShapes.BATTERY_BANK.rotateFromSouth(Direction.EAST).computeShape() ) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt index 473d0c605..c80a29b8a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt @@ -111,9 +111,9 @@ class ChemicalGeneratorBlock : RotatableMatteryBlock(), EntityBlock { def, def, def, - BlockShapes.CHEMICAL_GENERATOR.rotate(Direction.NORTH).computeShape(), - BlockShapes.CHEMICAL_GENERATOR.rotate(Direction.WEST).computeShape(), - BlockShapes.CHEMICAL_GENERATOR.rotate(Direction.EAST).computeShape() + BlockShapes.CHEMICAL_GENERATOR.rotateFromSouth(Direction.NORTH).computeShape(), + BlockShapes.CHEMICAL_GENERATOR.rotateFromSouth(Direction.WEST).computeShape(), + BlockShapes.CHEMICAL_GENERATOR.rotateFromSouth(Direction.EAST).computeShape() ) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyCounterBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyCounterBlock.kt index 1cebd30df..cb617b551 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyCounterBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyCounterBlock.kt @@ -97,7 +97,7 @@ class EnergyCounterBlock : MatteryBlock(), EntityBlock { } if (input === Direction.UP || input === Direction.DOWN) { - shape = shape.rotateInv(iface) + shape = shape.rotateFromNorth(iface) } else if (input === Direction.EAST || input === Direction.WEST) { when (iface) { Direction.DOWN -> shape = shape.rotateAroundX(Math.PI / 2) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt index ecb5e7ecc..fbce75b0d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt @@ -52,12 +52,12 @@ class EnergyServoBlock : RotatableMatteryBlock(Properties.of(Material.METAL, Mat val def = BlockShapes.ENERGY_SERVO.computeShape() SHAPES = arrayOf( - def, - def, - def, - BlockShapes.ENERGY_SERVO.rotate(Direction.NORTH).computeShape(), - BlockShapes.ENERGY_SERVO.rotate(Direction.WEST).computeShape(), - BlockShapes.ENERGY_SERVO.rotate(Direction.EAST).computeShape() + def, + def, + def, + BlockShapes.ENERGY_SERVO.rotateFromSouth(Direction.NORTH).computeShape(), + BlockShapes.ENERGY_SERVO.rotateFromSouth(Direction.WEST).computeShape(), + BlockShapes.ENERGY_SERVO.rotateFromSouth(Direction.EAST).computeShape() ) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt index b178aba8b..1bfd53e17 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt @@ -149,9 +149,9 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock { BlockShapes.GRAVITATION_STABILIZER.rotateAroundX(PI / 2).computeShape(), BlockShapes.GRAVITATION_STABILIZER.rotateAroundX(-PI / 2).computeShape(), BlockShapes.GRAVITATION_STABILIZER.computeShape(), - BlockShapes.GRAVITATION_STABILIZER.rotate(Direction.NORTH).computeShape(), - BlockShapes.GRAVITATION_STABILIZER.rotate(Direction.WEST).computeShape(), - BlockShapes.GRAVITATION_STABILIZER.rotate(Direction.EAST).computeShape() + BlockShapes.GRAVITATION_STABILIZER.rotateFromSouth(Direction.NORTH).computeShape(), + BlockShapes.GRAVITATION_STABILIZER.rotateFromSouth(Direction.WEST).computeShape(), + BlockShapes.GRAVITATION_STABILIZER.rotateFromSouth(Direction.EAST).computeShape() ) fun getBoundingBlock(level: Level, blockState: BlockState, blockPos: BlockPos): BlockState { @@ -220,9 +220,9 @@ class BlockGravitationStabilizerLens : RotatableMatteryBlock(props) { BlockShapes.GRAVITATION_STABILIZER_LENS.rotateAroundX(PI / 2).computeShape(), BlockShapes.GRAVITATION_STABILIZER_LENS.rotateAroundX(-PI / 2).computeShape(), BlockShapes.GRAVITATION_STABILIZER_LENS.computeShape(), - BlockShapes.GRAVITATION_STABILIZER_LENS.rotate(Direction.NORTH).computeShape(), - BlockShapes.GRAVITATION_STABILIZER_LENS.rotate(Direction.WEST).computeShape(), - BlockShapes.GRAVITATION_STABILIZER_LENS.rotate(Direction.EAST).computeShape() + BlockShapes.GRAVITATION_STABILIZER_LENS.rotateFromSouth(Direction.NORTH).computeShape(), + BlockShapes.GRAVITATION_STABILIZER_LENS.rotateFromSouth(Direction.WEST).computeShape(), + BlockShapes.GRAVITATION_STABILIZER_LENS.rotateFromSouth(Direction.EAST).computeShape() ) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt index b50ce41d4..5dfbb2667 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt @@ -93,7 +93,7 @@ class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of(Material.METAL DoubleBlockHalf.LOWER -> BlockShapes.PHANTOM_ATTRACTOR_BOTTOM } - shape.rotate(it.facingOne).computeShape() + shape.rotateFromSouth(it.facingOne).computeShape() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt index 4c788677a..8ae695002 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt @@ -74,9 +74,9 @@ class PlatePressBlock(properties: Properties = DEFAULT_PROPERTIES) : RotatableMa def, def, def, - BlockShapes.PLATE_PRESS_IDLE.rotate(Direction.NORTH).computeShape(), - BlockShapes.PLATE_PRESS_IDLE.rotate(Direction.WEST).computeShape(), - BlockShapes.PLATE_PRESS_IDLE.rotate(Direction.EAST).computeShape() + BlockShapes.PLATE_PRESS_IDLE.rotateFromSouth(Direction.NORTH).computeShape(), + BlockShapes.PLATE_PRESS_IDLE.rotateFromSouth(Direction.WEST).computeShape(), + BlockShapes.PLATE_PRESS_IDLE.rotateFromSouth(Direction.EAST).computeShape() ) } } From ba90c60cd209900d79c47d157d940d437409f87f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 30 Jan 2023 16:05:26 +0700 Subject: [PATCH 0156/1199] Use getShapeForEachState --- .../mc/otm/block/decorative/EngineBlock.kt | 2 +- .../mc/otm/block/matter/MatterBottlerBlock.kt | 29 +++++---------- .../block/matter/MatterCapacitorBankBlock.kt | 34 ++++++------------ .../otm/block/matter/MatterDecomposerBlock.kt | 27 +++++--------- .../otm/block/matter/MatterRecyclerBlock.kt | 31 +++++----------- .../otm/block/matter/MatterReplicatorBlock.kt | 31 +++++----------- .../mc/otm/block/matter/MatterScannerBlock.kt | 31 +++++----------- .../otm/block/matter/PatternStorageBlock.kt | 29 +++++---------- .../mc/otm/block/storage/DriveRackBlock.kt | 27 +++++--------- .../mc/otm/block/storage/DriveViewerBlock.kt | 28 +++++---------- .../mc/otm/block/storage/ItemMonitorBlock.kt | 27 +++++--------- .../mc/otm/block/storage/StorageBusBlock.kt | 6 ++-- .../mc/otm/block/storage/StorageInterfaces.kt | 9 ++--- .../storage/StoragePowerSupplierBlock.kt | 31 +++++----------- .../mc/otm/block/tech/BatteryBankBlock.kt | 36 +++++++------------ .../otm/block/tech/ChemicalGeneratorBlock.kt | 27 +++++--------- .../mc/otm/block/tech/EnergyServoBlock.kt | 31 +++++----------- .../otm/block/tech/PhantomAttractorBlock.kt | 15 ++++---- .../mc/otm/block/tech/PlatePressBlock.kt | 31 +++++----------- 19 files changed, 156 insertions(+), 326 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt index 9590835f8..4cb0533ff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt @@ -18,7 +18,7 @@ class EngineBlock : RotatableMatteryBlock(Properties.of(Material.METAL, DyeColor } private val shapes = getShapeForEachState { - BlockShapes.ENGINE.rotateFromNorth(it[rotationProperty].front).computeShape() + BlockShapes.ENGINE.rotateFromNorth(it[rotationProperty]).computeShape() } override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt index 9fbe19b32..9ff19bded 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt @@ -18,6 +18,7 @@ import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity +import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -51,35 +52,23 @@ class MatterBottlerBlock : RotatableMatteryBlock(), EntityBlock { .setValue(SLOT_PROPERTIES[2], false) } + private val shapes = getShapeForEachState { BlockShapes.MATTER_BOTTLER.rotateFromSouth(it[rotationProperty]).computeShape() } + + @Suppress("override_deprecation") override fun getShape( - p_60555_: BlockState, - p_60556_: BlockGetter, - p_60557_: BlockPos, - p_60558_: CollisionContext + state: BlockState, + blockGetter: BlockGetter, + pos: BlockPos, + context: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.facingOne.ordinal] + return shapes[state]!! } companion object { - private val SHAPES: List - val SLOT_PROPERTIES = arrayOf( BooleanProperty.create("bottle_0"), BooleanProperty.create("bottle_1"), BooleanProperty.create("bottle_2") ) - - init { - val def = BlockShapes.MATTER_BOTTLER.computeShape() - - SHAPES = listOf( - def, - def, - def, - BlockShapes.MATTER_BOTTLER.rotateFromSouth(Direction.NORTH).computeShape(), - BlockShapes.MATTER_BOTTLER.rotateFromSouth(Direction.WEST).computeShape(), - BlockShapes.MATTER_BOTTLER.rotateFromSouth(Direction.EAST).computeShape() - ) - } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt index 354c80bf3..5744a0a02 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt @@ -14,7 +14,7 @@ import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.tech.BatteryBankBlock import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.matter.MatterCapacitorBankBlockEntity -import ru.dbotthepony.mc.otm.core.math.facingOne +import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.shapes.BlockShapes class MatterCapacitorBankBlock : RotatableMatteryBlock(), EntityBlock { @@ -32,33 +32,19 @@ class MatterCapacitorBankBlock : RotatableMatteryBlock(), EntityBlock { } override fun createBlockStateDefinition(builder: StateDefinition.Builder) { - builder.add(*BatteryBankBlock.BATTERY_SLOTS_PROPS) + BatteryBankBlock.BATTERY_SLOTS_PROPS.forEach(builder::add) super.createBlockStateDefinition(builder) } + private val shapes = getShapeForEachState { BlockShapes.MATTER_CAPACITOR_BANK.rotateFromSouth(it[rotationProperty]).computeShape() } + + @Suppress("override_deprecation") override fun getShape( - p_60555_: BlockState, - p_60556_: BlockGetter, - p_60557_: BlockPos, - p_60558_: CollisionContext + state: BlockState, + blockGetter: BlockGetter, + pos: BlockPos, + context: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.facingOne.ordinal] - } - - companion object { - private val SHAPES: List - - init { - val def = BlockShapes.MATTER_CAPACITOR_BANK.computeShape() - - SHAPES = listOf( - def, - def, - def, - BlockShapes.MATTER_CAPACITOR_BANK.rotateFromSouth(Direction.NORTH).computeShape(), - BlockShapes.MATTER_CAPACITOR_BANK.rotateFromSouth(Direction.WEST).computeShape(), - BlockShapes.MATTER_CAPACITOR_BANK.rotateFromSouth(Direction.EAST).computeShape() - ) - } + return shapes[state]!! } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt index d9f7f955d..6cc72cd37 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt @@ -18,6 +18,7 @@ import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -45,25 +46,15 @@ class MatterDecomposerBlock : RotatableMatteryBlock(), EntityBlock { builder.add(WorkerState.WORKER_STATE) } + private val shapes = getShapeForEachState { BlockShapes.MATTER_DECOMPOSER.rotateFromSouth(it[rotationProperty]).computeShape() } + + @Suppress("override_deprecation") override fun getShape( - p_60555_: BlockState, - p_60556_: BlockGetter, - p_60557_: BlockPos, - p_60558_: CollisionContext + state: BlockState, + blockGetter: BlockGetter, + pos: BlockPos, + context: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.facingOne.ordinal] - } - - companion object { - private val def = BlockShapes.MATTER_DECOMPOSER.computeShape() - - private val SHAPES: List = listOf( - def, - def, - def, - BlockShapes.MATTER_DECOMPOSER.rotateFromSouth(Direction.NORTH).computeShape(), - BlockShapes.MATTER_DECOMPOSER.rotateFromSouth(Direction.WEST).computeShape(), - BlockShapes.MATTER_DECOMPOSER.rotateFromSouth(Direction.EAST).computeShape() - ) + return shapes[state]!! } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt index e1e4d406a..ff528be42 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt @@ -16,6 +16,7 @@ import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.matter.MatterRecyclerBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -41,29 +42,15 @@ class MatterRecyclerBlock : RotatableMatteryBlock(), EntityBlock { return BlockEntityTicker { _, _, _, tile -> if (tile is MatterRecyclerBlockEntity) tile.tick() } } + private val shapes = getShapeForEachState { BlockShapes.MATTER_RECYCLER.rotateFromSouth(it[rotationProperty]).computeShape() } + + @Suppress("override_deprecation") override fun getShape( - p_60555_: BlockState, - p_60556_: BlockGetter, - p_60557_: BlockPos, - p_60558_: CollisionContext + state: BlockState, + blockGetter: BlockGetter, + pos: BlockPos, + context: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.facingOne.ordinal] - } - - companion object { - private val SHAPES: Array - - init { - val def = BlockShapes.MATTER_RECYCLER.computeShape() - - SHAPES = arrayOf( - def, - def, - def, - BlockShapes.MATTER_RECYCLER.rotateFromSouth(Direction.NORTH).computeShape(), - BlockShapes.MATTER_RECYCLER.rotateFromSouth(Direction.WEST).computeShape(), - BlockShapes.MATTER_RECYCLER.rotateFromSouth(Direction.EAST).computeShape() - ) - } + return shapes[state]!! } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt index 9219a2cec..cdbc0338f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt @@ -16,6 +16,7 @@ import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -41,29 +42,15 @@ class MatterReplicatorBlock : RotatableMatteryBlock(), EntityBlock { builder.add(WorkerState.WORKER_STATE) } + private val shapes = getShapeForEachState { BlockShapes.MATTER_REPLICATOR.rotateFromSouth(it[rotationProperty]).computeShape() } + + @Suppress("override_deprecation") override fun getShape( - p_60555_: BlockState, - p_60556_: BlockGetter, - p_60557_: BlockPos, - p_60558_: CollisionContext + state: BlockState, + blockGetter: BlockGetter, + pos: BlockPos, + context: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.facingOne.ordinal] - } - - companion object { - private val SHAPES: Array - - init { - val def = BlockShapes.MATTER_REPLICATOR.computeShape() - - SHAPES = arrayOf( - def, - def, - def, - BlockShapes.MATTER_REPLICATOR.rotateFromSouth(Direction.NORTH).computeShape(), - BlockShapes.MATTER_REPLICATOR.rotateFromSouth(Direction.WEST).computeShape(), - BlockShapes.MATTER_REPLICATOR.rotateFromSouth(Direction.EAST).computeShape() - ) - } + return shapes[state]!! } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt index 352d218ba..8122e0499 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt @@ -16,6 +16,7 @@ import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.matter.MatterScannerBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -41,29 +42,15 @@ class MatterScannerBlock : RotatableMatteryBlock(), EntityBlock { builder.add(WorkerState.WORKER_STATE) } + private val shapes = getShapeForEachState { BlockShapes.MATTER_SCANNER.rotateFromSouth(it[rotationProperty]).computeShape() } + + @Suppress("override_deprecation") override fun getShape( - p_60555_: BlockState, - p_60556_: BlockGetter, - p_60557_: BlockPos, - p_60558_: CollisionContext + state: BlockState, + blockGetter: BlockGetter, + pos: BlockPos, + context: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.facingOne.ordinal] - } - - companion object { - private val SHAPES: Array - - init { - val def = BlockShapes.MATTER_SCANNER.computeShape() - - SHAPES = arrayOf( - def, - def, - def, - BlockShapes.MATTER_SCANNER.rotateFromSouth(Direction.NORTH).computeShape(), - BlockShapes.MATTER_SCANNER.rotateFromSouth(Direction.WEST).computeShape(), - BlockShapes.MATTER_SCANNER.rotateFromSouth(Direction.EAST).computeShape() - ) - } + return shapes[state]!! } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt index cb2a17a62..838e134b2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt @@ -16,6 +16,7 @@ import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.matter.PatternStorageBlockEntity +import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -57,13 +58,16 @@ class PatternStorageBlock : RotatableMatteryBlock(), EntityBlock { super.onRemove(oldBlockState, level, blockPos, newBlockState, movedByPiston) } + private val shapes = getShapeForEachState { BlockShapes.PATTERN_STORAGE.rotateFromSouth(it[rotationProperty]).computeShape() } + + @Suppress("override_deprecation") override fun getShape( - p_60555_: BlockState, - p_60556_: BlockGetter, - p_60557_: BlockPos, - p_60558_: CollisionContext + state: BlockState, + blockGetter: BlockGetter, + pos: BlockPos, + context: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.facingOne.ordinal] + return shapes[state]!! } companion object { @@ -77,20 +81,5 @@ class PatternStorageBlock : RotatableMatteryBlock(), EntityBlock { BooleanProperty.create("disk_6") as BooleanProperty, BooleanProperty.create("disk_7") as BooleanProperty ) - - private val SHAPES: List - - init { - val def = BlockShapes.PATTERN_STORAGE.computeShape() - - SHAPES = listOf( - def, - def, - def, - BlockShapes.PATTERN_STORAGE.rotateFromSouth(Direction.NORTH).computeShape(), - BlockShapes.PATTERN_STORAGE.rotateFromSouth(Direction.WEST).computeShape(), - BlockShapes.PATTERN_STORAGE.rotateFromSouth(Direction.EAST).computeShape() - ) - } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt index 0b5f87892..8025cc3e0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt @@ -18,6 +18,7 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.DriveRackBlockEntity import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -49,25 +50,15 @@ class DriveRackBlock : RotatableMatteryBlock(), EntityBlock { MatteryPoweredBlockEntity.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) } + private val shapes = getShapeForEachState { BlockShapes.DRIVE_RACK.rotateFromSouth(it[rotationProperty]).computeShape() } + + @Suppress("override_deprecation") override fun getShape( - p_60555_: BlockState, - p_60556_: BlockGetter, - p_60557_: BlockPos, - p_60558_: CollisionContext + state: BlockState, + blockGetter: BlockGetter, + pos: BlockPos, + context: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.facingOne.ordinal] - } - - companion object { - private val def = BlockShapes.DRIVE_RACK.computeShape() - - private val SHAPES: List = listOf( - def, - def, - def, - BlockShapes.DRIVE_RACK.rotateFromSouth(Direction.NORTH).computeShape(), - BlockShapes.DRIVE_RACK.rotateFromSouth(Direction.WEST).computeShape(), - BlockShapes.DRIVE_RACK.rotateFromSouth(Direction.EAST).computeShape() - ) + return shapes[state]!! } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt index 4e1c2007b..e42de611d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt @@ -23,6 +23,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.DriveViewerBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -64,30 +65,19 @@ class DriveViewerBlock : RotatableMatteryBlock(), EntityBlock { return super.getStateForPlacement(context)!!.setValue(DRIVE_PRESENT, false) } + private val shapes = getShapeForEachState { BlockShapes.DRIVE_VIEWER.rotateFromSouth(it[rotationProperty]).computeShape() } + + @Suppress("override_deprecation") override fun getShape( - p_60555_: BlockState, - p_60556_: BlockGetter, - p_60557_: BlockPos, - p_60558_: CollisionContext + state: BlockState, + blockGetter: BlockGetter, + pos: BlockPos, + context: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.facingOne.ordinal] + return shapes[state]!! } companion object { val DRIVE_PRESENT: BooleanProperty = BooleanProperty.create("drive") - private val SHAPES: Array - - init { - val def = BlockShapes.DRIVE_VIEWER.computeShape() - - SHAPES = arrayOf( - def, - def, - def, - BlockShapes.DRIVE_VIEWER.rotateFromSouth(Direction.NORTH).computeShape(), - BlockShapes.DRIVE_VIEWER.rotateFromSouth(Direction.WEST).computeShape(), - BlockShapes.DRIVE_VIEWER.rotateFromSouth(Direction.EAST).computeShape() - ) - } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt index 5a8566257..a89ed8983 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt @@ -18,6 +18,7 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorBlockEntity import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -49,25 +50,15 @@ class ItemMonitorBlock : RotatableMatteryBlock(), EntityBlock { MatteryPoweredBlockEntity.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) } + private val shapes = getShapeForEachState { BlockShapes.ITEM_MONITOR.rotateFromSouth(it[rotationProperty]).computeShape() } + + @Suppress("override_deprecation") override fun getShape( - p_60555_: BlockState, - p_60556_: BlockGetter, - p_60557_: BlockPos, - p_60558_: CollisionContext + state: BlockState, + blockGetter: BlockGetter, + pos: BlockPos, + context: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.facingOne.ordinal] - } - - companion object { - private val def = BlockShapes.ITEM_MONITOR.computeShape() - - private val SHAPES: List = listOf( - def, - def, - def, - BlockShapes.ITEM_MONITOR.rotateFromSouth(Direction.NORTH).computeShape(), - BlockShapes.ITEM_MONITOR.rotateFromSouth(Direction.WEST).computeShape(), - BlockShapes.ITEM_MONITOR.rotateFromSouth(Direction.EAST).computeShape() - ) + return shapes[state]!! } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt index d5f054f7f..21ea4a630 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt @@ -24,9 +24,11 @@ import ru.dbotthepony.mc.otm.block.StorageCableBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.StorageBusBlockEntity import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.math.facingTwo +import ru.dbotthepony.mc.otm.core.math.rotationTwo import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes import ru.dbotthepony.mc.otm.core.math.unaryMinus @@ -98,7 +100,7 @@ class StorageBusBlock : RotatableMatteryBlock(), EntityBlock { finalShape = Shapes.joinUnoptimized(finalShape, shapes[i], BooleanOp.OR) } - finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_BUS.rotateFromNorth(it.facingTwo).computeShape(), BooleanOp.OR) + finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_BUS.rotateFromNorth(it[rotationProperty]).computeShape(), BooleanOp.OR) return@getShapeForEachState finalShape } @@ -110,7 +112,7 @@ class StorageBusBlock : RotatableMatteryBlock(), EntityBlock { p_60557_: BlockPos, p_60558_: CollisionContext ): VoxelShape { - return shapes[p_60555_] ?: BlockShapes.STORAGE_BUS.computeShape() + return shapes[p_60555_]!! } @Suppress("OVERRIDE_DEPRECATION") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt index 9d333a0db..b3c1bd366 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt @@ -25,6 +25,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.StorageExporterBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.StorageImporterBlockEntity import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.math.facingTwo @@ -99,7 +100,7 @@ class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock { finalShape = Shapes.joinUnoptimized(finalShape, shapes[i], BooleanOp.OR) } - finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_IMPORTER.rotateFromNorth(it.facingTwo).computeShape(), BooleanOp.OR) + finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_IMPORTER.rotateFromNorth(it[rotationProperty]).computeShape(), BooleanOp.OR) return@getShapeForEachState finalShape } @@ -111,7 +112,7 @@ class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock { p_60557_: BlockPos, p_60558_: CollisionContext ): VoxelShape { - return shapes[p_60555_] ?: BlockShapes.STORAGE_BUS.computeShape() + return shapes[p_60555_]!! } @Suppress("OVERRIDE_DEPRECATION") @@ -203,7 +204,7 @@ class StorageExporterBlock : RotatableMatteryBlock(), EntityBlock { finalShape = Shapes.joinUnoptimized(finalShape, shapes[i], BooleanOp.OR) } - finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_EXPORTER.rotateFromNorth(it.facingTwo).computeShape(), BooleanOp.OR) + finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_EXPORTER.rotateFromNorth(it[rotationProperty]).computeShape(), BooleanOp.OR) return@getShapeForEachState finalShape } @@ -215,7 +216,7 @@ class StorageExporterBlock : RotatableMatteryBlock(), EntityBlock { p_60557_: BlockPos, p_60558_: CollisionContext ): VoxelShape { - return shapes[p_60555_] ?: BlockShapes.STORAGE_BUS.computeShape() + return shapes[p_60555_]!! } @Suppress("OVERRIDE_DEPRECATION") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt index 2aad23266..d3b4810d8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt @@ -18,6 +18,7 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.StoragePowerSupplierBlockEntity import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -49,29 +50,15 @@ class StoragePowerSupplierBlock : RotatableMatteryBlock(), EntityBlock { MatteryPoweredBlockEntity.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) } + private val shapes = getShapeForEachState { BlockShapes.STORAGE_POWER_SUPPLIER.rotateFromSouth(it[rotationProperty]).computeShape() } + + @Suppress("override_deprecation") override fun getShape( - p_60555_: BlockState, - p_60556_: BlockGetter, - p_60557_: BlockPos, - p_60558_: CollisionContext + state: BlockState, + blockGetter: BlockGetter, + pos: BlockPos, + context: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.facingOne.ordinal] - } - - companion object { - private val SHAPES: Array - - init { - val def = BlockShapes.STORAGE_POWER_SUPPLIER.computeShape() - - SHAPES = arrayOf( - def, - def, - def, - BlockShapes.STORAGE_POWER_SUPPLIER.rotateFromSouth(Direction.NORTH).computeShape(), - BlockShapes.STORAGE_POWER_SUPPLIER.rotateFromSouth(Direction.WEST).computeShape(), - BlockShapes.STORAGE_POWER_SUPPLIER.rotateFromSouth(Direction.EAST).computeShape() - ) - } + return shapes[state]!! } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt index 03c2186ef..b0d6f9df3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.block.tech +import com.google.common.collect.ImmutableList import net.minecraft.MethodsReturnNonnullByDefault import javax.annotation.ParametersAreNonnullByDefault import net.minecraft.world.level.block.EntityBlock @@ -11,7 +12,6 @@ import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.entity.BlockEntityTicker import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.core.BlockPos -import net.minecraft.core.Direction import ru.dbotthepony.mc.otm.block.entity.tech.BatteryBankBlockEntity import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level @@ -19,7 +19,7 @@ import net.minecraft.world.level.block.Block import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock -import ru.dbotthepony.mc.otm.core.math.facingOne +import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.oncePre import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -48,7 +48,7 @@ class BatteryBankBlock : RotatableMatteryBlock(), EntityBlock { } override fun createBlockStateDefinition(builder: StateDefinition.Builder) { - builder.add(*BATTERY_SLOTS_PROPS) + BATTERY_SLOTS_PROPS.forEach(builder::add) super.createBlockStateDefinition(builder) } @@ -56,13 +56,16 @@ class BatteryBankBlock : RotatableMatteryBlock(), EntityBlock { return BatteryBankBlockEntity(blockPos, blockState) } + private val shapes = getShapeForEachState { BlockShapes.BATTERY_BANK.rotateFromSouth(it[rotationProperty]).computeShape() } + + @Suppress("override_deprecation") override fun getShape( - p_60555_: BlockState, - p_60556_: BlockGetter, - p_60557_: BlockPos, - p_60558_: CollisionContext + state: BlockState, + blockGetter: BlockGetter, + pos: BlockPos, + context: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.facingOne.ordinal] + return shapes[state]!! } override fun faceToPlayer(context: BlockPlaceContext): Boolean { @@ -83,7 +86,7 @@ class BatteryBankBlock : RotatableMatteryBlock(), EntityBlock { } companion object { - val BATTERY_SLOTS_PROPS = arrayOf( + val BATTERY_SLOTS_PROPS: ImmutableList = ImmutableList.of( BooleanProperty.create("battery_0") as BooleanProperty, BooleanProperty.create("battery_1") as BooleanProperty, BooleanProperty.create("battery_2") as BooleanProperty, @@ -97,20 +100,5 @@ class BatteryBankBlock : RotatableMatteryBlock(), EntityBlock { BooleanProperty.create("battery_10") as BooleanProperty, BooleanProperty.create("battery_11") as BooleanProperty, ) - - private val SHAPES: List - - init { - val def = BlockShapes.BATTERY_BANK.computeShape() - - SHAPES = java.util.List.of( - def, - def, - def, - BlockShapes.BATTERY_BANK.rotateFromSouth(Direction.NORTH).computeShape(), - BlockShapes.BATTERY_BANK.rotateFromSouth(Direction.WEST).computeShape(), - BlockShapes.BATTERY_BANK.rotateFromSouth(Direction.EAST).computeShape() - ) - } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt index c80a29b8a..53c02ebcc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt @@ -27,6 +27,7 @@ import ru.dbotthepony.mc.otm.capability.energy.GeneratorEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.ItemEnergyStorageImpl import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.oncePre @@ -95,25 +96,15 @@ class ChemicalGeneratorBlock : RotatableMatteryBlock(), EntityBlock { } } + private val shapes = getShapeForEachState { BlockShapes.CHEMICAL_GENERATOR.rotateFromSouth(it[rotationProperty]).computeShape() } + + @Suppress("override_deprecation") override fun getShape( - p_60555_: BlockState, - p_60556_: BlockGetter, - p_60557_: BlockPos, - p_60558_: CollisionContext + state: BlockState, + blockGetter: BlockGetter, + pos: BlockPos, + context: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.facingOne.ordinal] - } - - companion object { - private val def = BlockShapes.CHEMICAL_GENERATOR.computeShape() - - private val SHAPES: List = listOf( - def, - def, - def, - BlockShapes.CHEMICAL_GENERATOR.rotateFromSouth(Direction.NORTH).computeShape(), - BlockShapes.CHEMICAL_GENERATOR.rotateFromSouth(Direction.WEST).computeShape(), - BlockShapes.CHEMICAL_GENERATOR.rotateFromSouth(Direction.EAST).computeShape() - ) + return shapes[state]!! } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt index fbce75b0d..4287fb226 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt @@ -15,6 +15,7 @@ import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.tech.EnergyServoBlockEntity +import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -36,29 +37,15 @@ class EnergyServoBlock : RotatableMatteryBlock(Properties.of(Material.METAL, Mat return null } + private val shapes = getShapeForEachState { BlockShapes.ENERGY_SERVO.rotateFromSouth(it[rotationProperty]).computeShape() } + + @Suppress("override_deprecation") override fun getShape( - p_60555_: BlockState, - p_60556_: BlockGetter, - p_60557_: BlockPos, - p_60558_: CollisionContext + state: BlockState, + blockGetter: BlockGetter, + pos: BlockPos, + context: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.facingOne.ordinal] - } - - companion object { - private val SHAPES: Array - - init { - val def = BlockShapes.ENERGY_SERVO.computeShape() - - SHAPES = arrayOf( - def, - def, - def, - BlockShapes.ENERGY_SERVO.rotateFromSouth(Direction.NORTH).computeShape(), - BlockShapes.ENERGY_SERVO.rotateFromSouth(Direction.WEST).computeShape(), - BlockShapes.ENERGY_SERVO.rotateFromSouth(Direction.EAST).computeShape() - ) - } + return shapes[state]!! } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt index 5dfbb2667..37ea605c0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt @@ -30,6 +30,7 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.core.math.minus import ru.dbotthepony.mc.otm.core.math.plus +import ru.dbotthepony.mc.otm.core.math.rotationOne import ru.dbotthepony.mc.otm.once import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -86,15 +87,13 @@ class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of(Material.METAL } } - private val shapes by lazy { - getShapeForEachState { - val shape = when (it[BlockStateProperties.DOUBLE_BLOCK_HALF]!!) { - DoubleBlockHalf.UPPER -> BlockShapes.PHANTOM_ATTRACTOR_TOP.moveY(-1.0) - DoubleBlockHalf.LOWER -> BlockShapes.PHANTOM_ATTRACTOR_BOTTOM - } - - shape.rotateFromSouth(it.facingOne).computeShape() + private val shapes = getShapeForEachState { + val shape = when (it[BlockStateProperties.DOUBLE_BLOCK_HALF]!!) { + DoubleBlockHalf.UPPER -> BlockShapes.PHANTOM_ATTRACTOR_TOP.moveY(-1.0) + DoubleBlockHalf.LOWER -> BlockShapes.PHANTOM_ATTRACTOR_BOTTOM } + + shape.rotateFromSouth(it[rotationProperty]).computeShape() } override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt index 8ae695002..ab7427e98 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt @@ -20,6 +20,7 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -55,29 +56,15 @@ class PlatePressBlock(properties: Properties = DEFAULT_PROPERTIES) : RotatableMa MatteryWorkerBlockEntity.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) } + private val shapes = getShapeForEachState { BlockShapes.PLATE_PRESS_IDLE.rotateFromSouth(it[rotationProperty]).computeShape() } + + @Suppress("override_deprecation") override fun getShape( - p_60555_: BlockState, - p_60556_: BlockGetter, - p_60557_: BlockPos, - p_60558_: CollisionContext + state: BlockState, + blockGetter: BlockGetter, + pos: BlockPos, + context: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.facingOne.ordinal] - } - - companion object { - private val SHAPES: Array - - init { - val def = BlockShapes.PLATE_PRESS_IDLE.computeShape() - - SHAPES = arrayOf( - def, - def, - def, - BlockShapes.PLATE_PRESS_IDLE.rotateFromSouth(Direction.NORTH).computeShape(), - BlockShapes.PLATE_PRESS_IDLE.rotateFromSouth(Direction.WEST).computeShape(), - BlockShapes.PLATE_PRESS_IDLE.rotateFromSouth(Direction.EAST).computeShape() - ) - } + return shapes[state]!! } } From 81c773b228ad1857892e80c697144ef53526705b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 30 Jan 2023 16:25:15 +0700 Subject: [PATCH 0157/1199] More efficient getShapeForEachState --- .../dbotthepony/mc/otm/block/MatteryBlock.kt | 30 +++++++++++++++++++ .../mc/otm/block/matter/MatterBottlerBlock.kt | 3 +- .../block/matter/MatterCapacitorBankBlock.kt | 3 +- .../otm/block/matter/MatterDecomposerBlock.kt | 3 +- .../otm/block/matter/MatterRecyclerBlock.kt | 3 +- .../otm/block/matter/MatterReplicatorBlock.kt | 3 +- .../mc/otm/block/matter/MatterScannerBlock.kt | 3 +- .../otm/block/matter/PatternStorageBlock.kt | 3 +- .../mc/otm/block/storage/DriveRackBlock.kt | 3 +- .../mc/otm/block/storage/DriveViewerBlock.kt | 3 +- .../mc/otm/block/storage/ItemMonitorBlock.kt | 3 +- .../storage/StoragePowerSupplierBlock.kt | 3 +- .../mc/otm/block/tech/BatteryBankBlock.kt | 3 +- .../otm/block/tech/ChemicalGeneratorBlock.kt | 3 +- .../mc/otm/block/tech/EnergyServoBlock.kt | 3 +- .../otm/block/tech/PhantomAttractorBlock.kt | 3 +- .../mc/otm/block/tech/PlatePressBlock.kt | 3 +- 17 files changed, 62 insertions(+), 16 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt index 0fa3772af..a6843199c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt @@ -1,5 +1,8 @@ package ru.dbotthepony.mc.otm.block +import com.google.common.collect.ImmutableMap +import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap +import it.unimi.dsi.fastutil.objects.Object2ObjectFunction import net.minecraft.core.BlockPos import net.minecraft.core.Direction import net.minecraft.core.particles.DustParticleOptions @@ -15,17 +18,44 @@ import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.EntityBlock import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.level.block.state.properties.Property import net.minecraft.world.level.material.Material import net.minecraft.world.level.material.MaterialColor import net.minecraft.world.phys.BlockHitResult +import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.entity.IRedstoneControlProvider import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.math.component1 import ru.dbotthepony.mc.otm.core.math.component2 import ru.dbotthepony.mc.otm.core.math.component3 +fun Block.getShapeForEachState(properties: List>, fn: (BlockState) -> VoxelShape): Map { + val builder = ImmutableMap.Builder() + + if (properties.isEmpty()) { + val shape = fn(stateDefinition.possibleStates.first()) + + for (state in stateDefinition.possibleStates) { + builder.put(state, shape) + } + } else { + val cache = Object2ObjectArrayMap, VoxelShape>() + + for (state in stateDefinition.possibleStates) { + builder.put(state, cache.computeIfAbsent(properties.map { state[it] }, Object2ObjectFunction { fn(state) })) + } + } + + return builder.build() +} + +fun Block.getShapeForEachState(property: Property<*>, fn: (BlockState) -> VoxelShape): Map { + return getShapeForEachState(listOf(property), fn) +} + abstract class MatteryBlock @JvmOverloads constructor( properties: Properties = DEFAULT_PROPERTIES ) : Block(properties) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt index 9ff19bded..c4c189ff7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt @@ -18,6 +18,7 @@ import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity +import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -52,7 +53,7 @@ class MatterBottlerBlock : RotatableMatteryBlock(), EntityBlock { .setValue(SLOT_PROPERTIES[2], false) } - private val shapes = getShapeForEachState { BlockShapes.MATTER_BOTTLER.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.MATTER_BOTTLER.rotateFromSouth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt index 5744a0a02..62439912a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt @@ -14,6 +14,7 @@ import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.tech.BatteryBankBlock import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.matter.MatterCapacitorBankBlockEntity +import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -36,7 +37,7 @@ class MatterCapacitorBankBlock : RotatableMatteryBlock(), EntityBlock { super.createBlockStateDefinition(builder) } - private val shapes = getShapeForEachState { BlockShapes.MATTER_CAPACITOR_BANK.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.MATTER_CAPACITOR_BANK.rotateFromSouth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt index 6cc72cd37..02194b695 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt @@ -18,6 +18,7 @@ import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -46,7 +47,7 @@ class MatterDecomposerBlock : RotatableMatteryBlock(), EntityBlock { builder.add(WorkerState.WORKER_STATE) } - private val shapes = getShapeForEachState { BlockShapes.MATTER_DECOMPOSER.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.MATTER_DECOMPOSER.rotateFromSouth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt index ff528be42..b74db3c47 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt @@ -16,6 +16,7 @@ import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.matter.MatterRecyclerBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -42,7 +43,7 @@ class MatterRecyclerBlock : RotatableMatteryBlock(), EntityBlock { return BlockEntityTicker { _, _, _, tile -> if (tile is MatterRecyclerBlockEntity) tile.tick() } } - private val shapes = getShapeForEachState { BlockShapes.MATTER_RECYCLER.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.MATTER_RECYCLER.rotateFromSouth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt index cdbc0338f..2bdd286e8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt @@ -16,6 +16,7 @@ import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -42,7 +43,7 @@ class MatterReplicatorBlock : RotatableMatteryBlock(), EntityBlock { builder.add(WorkerState.WORKER_STATE) } - private val shapes = getShapeForEachState { BlockShapes.MATTER_REPLICATOR.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.MATTER_REPLICATOR.rotateFromSouth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt index 8122e0499..b810622e6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt @@ -16,6 +16,7 @@ import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.matter.MatterScannerBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -42,7 +43,7 @@ class MatterScannerBlock : RotatableMatteryBlock(), EntityBlock { builder.add(WorkerState.WORKER_STATE) } - private val shapes = getShapeForEachState { BlockShapes.MATTER_SCANNER.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.MATTER_SCANNER.rotateFromSouth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt index 838e134b2..7764393b5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt @@ -16,6 +16,7 @@ import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.matter.PatternStorageBlockEntity +import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -58,7 +59,7 @@ class PatternStorageBlock : RotatableMatteryBlock(), EntityBlock { super.onRemove(oldBlockState, level, blockPos, newBlockState, movedByPiston) } - private val shapes = getShapeForEachState { BlockShapes.PATTERN_STORAGE.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.PATTERN_STORAGE.rotateFromSouth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt index 8025cc3e0..6d7897ee7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt @@ -17,6 +17,7 @@ import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.DriveRackBlockEntity +import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.facingOne @@ -50,7 +51,7 @@ class DriveRackBlock : RotatableMatteryBlock(), EntityBlock { MatteryPoweredBlockEntity.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) } - private val shapes = getShapeForEachState { BlockShapes.DRIVE_RACK.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.DRIVE_RACK.rotateFromSouth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt index e42de611d..a0294517c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt @@ -22,6 +22,7 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.DriveViewerBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.facingOne @@ -65,7 +66,7 @@ class DriveViewerBlock : RotatableMatteryBlock(), EntityBlock { return super.getStateForPlacement(context)!!.setValue(DRIVE_PRESENT, false) } - private val shapes = getShapeForEachState { BlockShapes.DRIVE_VIEWER.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.DRIVE_VIEWER.rotateFromSouth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt index a89ed8983..9821eae26 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt @@ -17,6 +17,7 @@ import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorBlockEntity +import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.facingOne @@ -50,7 +51,7 @@ class ItemMonitorBlock : RotatableMatteryBlock(), EntityBlock { MatteryPoweredBlockEntity.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) } - private val shapes = getShapeForEachState { BlockShapes.ITEM_MONITOR.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.ITEM_MONITOR.rotateFromSouth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt index d3b4810d8..ff739647c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt @@ -17,6 +17,7 @@ import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.StoragePowerSupplierBlockEntity +import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.facingOne @@ -50,7 +51,7 @@ class StoragePowerSupplierBlock : RotatableMatteryBlock(), EntityBlock { MatteryPoweredBlockEntity.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) } - private val shapes = getShapeForEachState { BlockShapes.STORAGE_POWER_SUPPLIER.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.STORAGE_POWER_SUPPLIER.rotateFromSouth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt index b0d6f9df3..5c6fb49e6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt @@ -19,6 +19,7 @@ import net.minecraft.world.level.block.Block import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.oncePre import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -56,7 +57,7 @@ class BatteryBankBlock : RotatableMatteryBlock(), EntityBlock { return BatteryBankBlockEntity(blockPos, blockState) } - private val shapes = getShapeForEachState { BlockShapes.BATTERY_BANK.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.BATTERY_BANK.rotateFromSouth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt index 53c02ebcc..bdd1f6137 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt @@ -23,6 +23,7 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.tech.ChemicalGeneratorBlockEntity import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.capability.energy.GeneratorEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.ItemEnergyStorageImpl import ru.dbotthepony.mc.otm.container.MatteryContainer @@ -96,7 +97,7 @@ class ChemicalGeneratorBlock : RotatableMatteryBlock(), EntityBlock { } } - private val shapes = getShapeForEachState { BlockShapes.CHEMICAL_GENERATOR.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.CHEMICAL_GENERATOR.rotateFromSouth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt index 4287fb226..a525a00ba 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt @@ -15,6 +15,7 @@ import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.tech.EnergyServoBlockEntity +import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -37,7 +38,7 @@ class EnergyServoBlock : RotatableMatteryBlock(Properties.of(Material.METAL, Mat return null } - private val shapes = getShapeForEachState { BlockShapes.ENERGY_SERVO.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.ENERGY_SERVO.rotateFromSouth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt index 37ea605c0..d0081b8ab 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt @@ -26,6 +26,7 @@ import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import net.minecraftforge.common.ForgeHooks import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.core.math.minus @@ -87,7 +88,7 @@ class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of(Material.METAL } } - private val shapes = getShapeForEachState { + private val shapes = getShapeForEachState(rotationProperty) { val shape = when (it[BlockStateProperties.DOUBLE_BLOCK_HALF]!!) { DoubleBlockHalf.UPPER -> BlockShapes.PHANTOM_ATTRACTOR_TOP.moveY(-1.0) DoubleBlockHalf.LOWER -> BlockShapes.PHANTOM_ATTRACTOR_BOTTOM diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt index ab7427e98..f752d0df0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt @@ -20,6 +20,7 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -56,7 +57,7 @@ class PlatePressBlock(properties: Properties = DEFAULT_PROPERTIES) : RotatableMa MatteryWorkerBlockEntity.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) } - private val shapes = getShapeForEachState { BlockShapes.PLATE_PRESS_IDLE.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.PLATE_PRESS_IDLE.rotateFromSouth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( From 52a2e845fa3dafc45dabb63befd61ca003a07713 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 30 Jan 2023 18:38:25 +0700 Subject: [PATCH 0158/1199] Get rid of blockstate explosion caused by battery banks except now they have unbaked models --- .../ru/dbotthepony/mc/otm/datagen/DataGen.kt | 5 +- .../mc/otm/datagen/DecorativeData.kt | 10 ++- .../ru/dbotthepony/mc/otm/datagen/Ext.kt | 54 ------------- .../mc/otm/datagen/blocks/Banks.kt | 25 +++--- .../mc/otm/datagen/blocks/BlockStates.kt | 42 +++++----- .../otm/datagen/blocks/ComplexBlockStates.kt | 14 ++-- .../blocks/MatteryBlockStateProvider.kt | 16 ++-- .../mc/otm/OverdriveThatMatters.java | 7 +- .../matter/MatterCapacitorBankBlockEntity.kt | 26 ++----- .../entity/tech/BatteryBankBlockEntity.kt | 19 ++--- .../block/matter/MatterCapacitorBankBlock.kt | 16 +--- .../mc/otm/block/tech/BatteryBankBlock.kt | 35 +-------- .../client/render/blockentity/BankRenderer.kt | 78 ++++++++++++++++++- .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 10 ++- .../mc/otm/core/math/EuclidMath.kt | 77 ++++++++++++++++++ .../mc/otm/registry/MCreativeTabs.kt | 2 +- 16 files changed, 239 insertions(+), 197 deletions(-) delete mode 100644 src/data/kotlin/ru/dbotthepony/mc/otm/datagen/Ext.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt index f6fd731ef..e02056fcb 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -20,6 +20,7 @@ import net.minecraftforge.data.event.GatherDataEvent import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.android.AndroidResearchDataProvider import ru.dbotthepony.mc.otm.block.* +import ru.dbotthepony.mc.otm.core.math.yRotationBlockstateNorth import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.datagen.blocks.BatteryBankProvider import ru.dbotthepony.mc.otm.datagen.blocks.MatterBankProvider @@ -272,7 +273,7 @@ object DataGen { } } ).rotationY( - facing.toYRotBlockstate() - 90 + + facing.yRotationBlockstateNorth() - 90 + (if (open) when (hinge) { DoorHingeSide.LEFT -> 90 DoorHingeSide.RIGHT -> -90 @@ -322,7 +323,7 @@ object DataGen { Half.BOTTOM -> trapdoorBottom } ).rotationY( - facing.toYRotBlockstate() + facing.yRotationBlockstateNorth() ).addModel() .condition(TrapDoorBlock.FACING, facing) .condition(TrapDoorBlock.OPEN, open) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt index 30a5aee55..d1e531f91 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt @@ -11,6 +11,8 @@ import net.minecraftforge.client.model.generators.ModelFile import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom +import ru.dbotthepony.mc.otm.core.math.xRotationBlockstateNorth +import ru.dbotthepony.mc.otm.core.math.yRotationBlockstateNorth import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.datagen.blocks.MatteryBlockStateProvider import ru.dbotthepony.mc.otm.datagen.items.MatteryItemModelProvider @@ -216,16 +218,16 @@ fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelPr blockStateProvider.getVariantBuilder(MBlocks.LABORATORY_LAMP).forAllStates { return@forAllStates ConfiguredModel.builder() .modelFile(if (it[BlockStateProperties.LIT]) labLampOn!! else labLampOff!!) - .rotationX(it[BlockRotationFreedom.TWO.property].front.toXRotBlockstate()) - .rotationY(it[BlockRotationFreedom.TWO.property].front.toYRotBlockstate()) + .rotationX(it[BlockRotationFreedom.TWO.property].front.xRotationBlockstateNorth()) + .rotationY(it[BlockRotationFreedom.TWO.property].front.yRotationBlockstateNorth()) .build() } blockStateProvider.getVariantBuilder(MBlocks.LABORATORY_LAMP_INVERTED).forAllStates { return@forAllStates ConfiguredModel.builder() .modelFile(if (it[BlockStateProperties.LIT]) labLampOn!! else labLampOff!!) - .rotationX(it[BlockRotationFreedom.TWO.property].front.toXRotBlockstate()) - .rotationY(it[BlockRotationFreedom.TWO.property].front.toYRotBlockstate()) + .rotationX(it[BlockRotationFreedom.TWO.property].front.xRotationBlockstateNorth()) + .rotationY(it[BlockRotationFreedom.TWO.property].front.yRotationBlockstateNorth()) .build() } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/Ext.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/Ext.kt deleted file mode 100644 index d4f102c3f..000000000 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/Ext.kt +++ /dev/null @@ -1,54 +0,0 @@ -package ru.dbotthepony.mc.otm.datagen - -import net.minecraft.core.Direction -import net.minecraft.world.level.block.state.BlockState -import net.minecraft.world.level.block.state.properties.Property - -fun Direction.toYRotBlockstate(): Int { - return when (this) { - Direction.DOWN, Direction.UP, Direction.NORTH -> 0 - Direction.SOUTH -> 180 - Direction.WEST -> -90 - Direction.EAST -> 90 - } -} - -fun Direction.toYRotBlockstateInv(): Int { - return when (this) { - Direction.DOWN, Direction.UP -> 0 - Direction.NORTH -> 180 - Direction.SOUTH -> 0 - Direction.WEST -> 90 - Direction.EAST -> -90 - } -} - -fun Direction.toXRotBlockstate(): Int { - return when (this) { - Direction.DOWN -> 90 - Direction.UP -> -90 - Direction.NORTH -> 0 - Direction.SOUTH -> 0 - Direction.WEST -> 0 - Direction.EAST -> 0 - } -} - -fun Direction.toXRotBlockstateInv(): Int { - return when (this) { - Direction.DOWN -> -90 - Direction.UP -> 90 - Direction.NORTH -> 0 - Direction.SOUTH -> 0 - Direction.WEST -> 0 - Direction.EAST -> 0 - } -} - -fun > BlockState.getValueNullable(prop: Property): T? { - if (hasProperty(prop)) { - return getValue(prop) - } - - return null -} diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt index 5e145d39b..20884bc5d 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt @@ -3,11 +3,12 @@ package ru.dbotthepony.mc.otm.datagen.blocks import net.minecraft.resources.ResourceLocation import net.minecraft.world.level.block.Block import net.minecraftforge.client.model.generators.BlockStateProvider +import net.minecraftforge.client.model.generators.ConfiguredModel import net.minecraftforge.data.event.GatherDataEvent -import ru.dbotthepony.mc.otm.block.tech.BatteryBankBlock +import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom +import ru.dbotthepony.mc.otm.core.math.yRotationBlockstateNorth import ru.dbotthepony.mc.otm.datagen.DataGen -import ru.dbotthepony.mc.otm.datagen.toYRotBlockstate import ru.dbotthepony.mc.otm.registry.MBlocks private fun nothingOrNumber(input: Int): String { @@ -23,20 +24,12 @@ open class BatteryBankProvider(event: GatherDataEvent) : BlockStateProvider(even protected var registry: Block = MBlocks.BATTERY_BANK override fun registerStatesAndModels() { - with(getMultipartBuilder(registry)) { - val battery_bank = models().getExistingFile(ResourceLocation("overdrive_that_matters:block/$block")) - - BlockRotationFreedom.ONE.possibleValues.forEach { - part().modelFile(battery_bank).rotationY(it.front.toYRotBlockstate()).addModel().condition( - BlockRotationFreedom.ONE.property, it) - - for (i in 0 .. 11) { - part().modelFile( - models().getExistingFile(ResourceLocation("overdrive_that_matters:$batteryPath$i")) - ).rotationY(it.front.toYRotBlockstate()).addModel() - .condition(BlockRotationFreedom.ONE.property, it) - .condition(BatteryBankBlock.BATTERY_SLOTS_PROPS[i], true) - } + with(getVariantBuilder(registry)) { + forAllStates { + ConfiguredModel.builder() + .modelFile(models().getExistingFile(ResourceLocation("overdrive_that_matters:block/$block"))) + .rotationY(it[BlockRotationFreedom.ONE.property].front.yRotationBlockstateNorth()) + .build() } } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt index 10ce4ef91..1d7daaded 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt @@ -10,12 +10,12 @@ import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom +import ru.dbotthepony.mc.otm.core.math.xRotationBlockstateNorth +import ru.dbotthepony.mc.otm.core.math.xRotationBlockstateSouth +import ru.dbotthepony.mc.otm.core.math.yRotationBlockstateNorth +import ru.dbotthepony.mc.otm.core.math.yRotationBlockstateSouth import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.datagen.modLocation -import ru.dbotthepony.mc.otm.datagen.toXRotBlockstate -import ru.dbotthepony.mc.otm.datagen.toXRotBlockstateInv -import ru.dbotthepony.mc.otm.datagen.toYRotBlockstate -import ru.dbotthepony.mc.otm.datagen.toYRotBlockstateInv import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.registry.MRegistry @@ -38,7 +38,7 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { with(provider.getMultipartBuilder(MBlocks.PHANTOM_ATTRACTOR)) { for (dir in BlockRotationFreedom.ONE.possibleValues) { part().modelFile(provider.models().getExistingFile(modLocation("block/${MNames.PHANTOM_ATTRACTOR}"))) - .rotationY(dir.front.toYRotBlockstate()) + .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() .condition(BlockStateProperties.DOUBLE_BLOCK_HALF, DoubleBlockHalf.LOWER) .condition(BlockRotationFreedom.ONE.property, dir) @@ -50,7 +50,7 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { for (dir in BlockRotationFreedom.ONE.possibleValues) { for (enum in WorkerState.SEMI_WORKER_STATE.possibleValues) { part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_bottler_${enum.name.lowercase()}"))) - .rotationY(dir.front.toYRotBlockstate()) + .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() .condition(BlockRotationFreedom.ONE.property, dir) .condition(WorkerState.WORKER_STATE, enum) @@ -61,14 +61,14 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { for (dir in BlockRotationFreedom.ONE.possibleValues) { for (enum in MatterBottlerBlock.SLOT_PROPERTIES) { part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_bottler_${enum.name}_open"))) - .rotationY(dir.front.toYRotBlockstate()) + .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() .condition(BlockRotationFreedom.ONE.property, dir) .condition(enum, false) .end() part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_bottler_${enum.name}_closed"))) - .rotationY(dir.front.toYRotBlockstate()) + .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() .condition(BlockRotationFreedom.ONE.property, dir) .condition(enum, true) @@ -98,7 +98,7 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { OverdriveThatMatters.MOD_ID, "${crate.registryName!!.path}_${if (it.getValue( CargoCrateBlock.IS_OPEN)) "open" else "closed"}") )) - .rotationY(it.getValue(BlockRotationFreedom.ONE.property).front.toYRotBlockstate()) + .rotationY(it.getValue(BlockRotationFreedom.ONE.property).front.yRotationBlockstateNorth()) .buildLast() ) } @@ -107,15 +107,15 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { with(provider.getMultipartBuilder(MBlocks.STORAGE_BUS)) { for (dir in BlockRotationFreedom.TWO.possibleValues) { part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_bus"))) - .rotationX(dir.front.toXRotBlockstate()) - .rotationY(dir.front.toYRotBlockstate()) + .rotationX(dir.front.xRotationBlockstateNorth()) + .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() .condition(BlockRotationFreedom.TWO.property, dir) .end() part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_connection"))) - .rotationX(dir.front.toXRotBlockstateInv()) - .rotationY(dir.front.toYRotBlockstateInv()) + .rotationX(dir.front.xRotationBlockstateSouth()) + .rotationY(dir.front.yRotationBlockstateSouth()) .addModel() .condition(CableBlock.MAPPING_CONNECTION_PROP[dir.front]!!, true) .end() @@ -128,15 +128,15 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { with(provider.getMultipartBuilder(MBlocks.STORAGE_IMPORTER)) { for (dir in BlockRotationFreedom.TWO.possibleValues) { part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_importer"))) - .rotationX(dir.front.toXRotBlockstate()) - .rotationY(dir.front.toYRotBlockstate()) + .rotationX(dir.front.xRotationBlockstateNorth()) + .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() .condition(BlockRotationFreedom.TWO.property, dir) .end() part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_connection"))) - .rotationX(dir.front.toXRotBlockstateInv()) - .rotationY(dir.front.toYRotBlockstateInv()) + .rotationX(dir.front.xRotationBlockstateSouth()) + .rotationY(dir.front.yRotationBlockstateSouth()) .addModel() .condition(CableBlock.MAPPING_CONNECTION_PROP[dir.front]!!, true) .end() @@ -149,15 +149,15 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { with(provider.getMultipartBuilder(MBlocks.STORAGE_EXPORTER)) { for (dir in BlockRotationFreedom.TWO.possibleValues) { part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_exporter"))) - .rotationX(dir.front.toXRotBlockstate()) - .rotationY(dir.front.toYRotBlockstate()) + .rotationX(dir.front.xRotationBlockstateNorth()) + .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() .condition(BlockRotationFreedom.TWO.property, dir) .end() part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_connection"))) - .rotationX(dir.front.toXRotBlockstateInv()) - .rotationY(dir.front.toYRotBlockstateInv()) + .rotationX(dir.front.xRotationBlockstateSouth()) + .rotationY(dir.front.yRotationBlockstateSouth()) .addModel() .condition(CableBlock.MAPPING_CONNECTION_PROP[dir.front]!!, true) .end() diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt index 714934982..16711d918 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt @@ -7,8 +7,8 @@ import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.matter.PatternStorageBlock import ru.dbotthepony.mc.otm.block.storage.DriveViewerBlock import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom +import ru.dbotthepony.mc.otm.core.math.yRotationBlockstateNorth import ru.dbotthepony.mc.otm.datagen.DataGen.MOD_ID -import ru.dbotthepony.mc.otm.datagen.toYRotBlockstate import ru.dbotthepony.mc.otm.registry.MBlocks fun addComplexBlockStates(provider: MatteryBlockStateProvider) { @@ -16,7 +16,7 @@ fun addComplexBlockStates(provider: MatteryBlockStateProvider) { for (facing in BlockRotationFreedom.ONE.possibleValues) { part() .modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/drive_viewer_drive_part"))) - .rotationY(facing.front.toYRotBlockstate()) + .rotationY(facing.front.yRotationBlockstateNorth()) .addModel() .condition(BlockRotationFreedom.ONE.property, facing) .condition(DriveViewerBlock.DRIVE_PRESENT, true) @@ -24,7 +24,7 @@ fun addComplexBlockStates(provider: MatteryBlockStateProvider) { for (workState in WorkerState.SEMI_WORKER_STATE.possibleValues) { part() .modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/drive_viewer_${workState.name.lowercase()}"))) - .rotationY(facing.front.toYRotBlockstate()) + .rotationY(facing.front.yRotationBlockstateNorth()) .addModel() .condition(WorkerState.SEMI_WORKER_STATE, workState) .condition(BlockRotationFreedom.ONE.property, facing) @@ -36,14 +36,14 @@ fun addComplexBlockStates(provider: MatteryBlockStateProvider) { for (facing in BlockRotationFreedom.ONE.possibleValues) { part() .modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/pattern_storage"))) - .rotationY(facing.front.toYRotBlockstate()) + .rotationY(facing.front.yRotationBlockstateNorth()) .addModel() .condition(BlockRotationFreedom.ONE.property, facing) for (i in 0 .. 7) { part() .modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/pattern/model$i"))) - .rotationY(facing.front.toYRotBlockstate()) + .rotationY(facing.front.yRotationBlockstateNorth()) .addModel() .condition(BlockRotationFreedom.ONE.property, facing) .condition(PatternStorageBlock.PATTERN_STORAGE_DISKS_PROPS[i], true) @@ -69,8 +69,8 @@ fun addComplexBlockStates(provider: MatteryBlockStateProvider) { val southWest = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_south_west")) for (dir in arrayOf(Direction.EAST, Direction.WEST, Direction.SOUTH, Direction.NORTH)) { - part().modelFile(down).rotationY(dir.toYRotBlockstate()).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.UP).condition(EnergyCounterBlock.IF_DIRECTION, dir) - part().modelFile(up).rotationY(dir.toYRotBlockstate()).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.DOWN).condition(EnergyCounterBlock.IF_DIRECTION, dir) + part().modelFile(down).rotationY(dir.yRotationBlockstateNorth()).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.UP).condition(EnergyCounterBlock.IF_DIRECTION, dir) + part().modelFile(up).rotationY(dir.yRotationBlockstateNorth()).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.DOWN).condition(EnergyCounterBlock.IF_DIRECTION, dir) } // низкий поклон за полностью рабочий поворот вокруг оси Z diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt index 01a084807..90babe7c9 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt @@ -7,11 +7,11 @@ import net.minecraftforge.client.model.generators.BlockStateProvider import net.minecraftforge.client.model.generators.ConfiguredModel import net.minecraftforge.data.event.GatherDataEvent import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.core.getValueNullable import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom +import ru.dbotthepony.mc.otm.core.math.xRotationBlockstateNorth +import ru.dbotthepony.mc.otm.core.math.yRotationBlockstateNorth import ru.dbotthepony.mc.otm.datagen.DataGen -import ru.dbotthepony.mc.otm.datagen.getValueNullable -import ru.dbotthepony.mc.otm.datagen.toXRotBlockstate -import ru.dbotthepony.mc.otm.datagen.toYRotBlockstate import ru.dbotthepony.mc.otm.core.registryName import java.util.LinkedList @@ -22,17 +22,17 @@ private fun initialTransform(it: BlockState, modelPath: String, builder: Configu @Suppress("NAME_SHADOWING") var modelPath = modelPath it.getValueNullable(BlockRotationFreedom.ONE.property)?.let { - builder.rotationY(it.front.toYRotBlockstate()) + builder.rotationY(it.front.yRotationBlockstateNorth()) } it.getValueNullable(BlockRotationFreedom.TWO.property)?.let { - builder.rotationY(it.front.toYRotBlockstate()) - builder.rotationX(it.front.toXRotBlockstate()) + builder.rotationY(it.front.yRotationBlockstateNorth()) + builder.rotationX(it.front.xRotationBlockstateNorth()) } it.getValueNullable(BlockRotationFreedom.THREE.property)?.let { - builder.rotationY(it.front.toYRotBlockstate() + it.top.toYRotBlockstate()) - builder.rotationX(it.front.toXRotBlockstate()) + builder.rotationY(it.front.yRotationBlockstateNorth() + it.top.yRotationBlockstateNorth()) + builder.rotationX(it.front.xRotationBlockstateNorth()) } it.getValueNullable(WorkerState.WORKER_STATE)?.let { diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 9fc842ee9..0d7fab0ca 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -31,6 +31,8 @@ import ru.dbotthepony.mc.otm.client.model.ExosuitModel; import ru.dbotthepony.mc.otm.client.model.GravitationStabilizerModel; import ru.dbotthepony.mc.otm.client.model.TritaniumArmorModel; import ru.dbotthepony.mc.otm.client.render.ShockwaveRenderer; +import ru.dbotthepony.mc.otm.client.render.blockentity.BatteryBankRenderer; +import ru.dbotthepony.mc.otm.client.render.blockentity.MatterBatteryBankRenderer; import ru.dbotthepony.mc.otm.compat.mekanism.QIOKt; import ru.dbotthepony.mc.otm.compat.mekanism.TooltipsKt; import ru.dbotthepony.mc.otm.core.math.Decimal; @@ -113,7 +115,10 @@ public final class OverdriveThatMatters { modBus.addListener(EventPriority.NORMAL, AndroidAbilityKeyMapping.INSTANCE::register); modBus.addListener(EventPriority.NORMAL, TritaniumArmorModel::register); modBus.addListener(EventPriority.NORMAL, GravitationStabilizerModel::register); - modBus.addListener(EventPriority.NORMAL, MCreativeTabs.INSTANCE::register$overdrive_that_matters); + modBus.addListener(EventPriority.NORMAL, MCreativeTabs.INSTANCE::register); + + modBus.addListener(EventPriority.NORMAL, BatteryBankRenderer.Companion::onRegisterAdditionalModels); + modBus.addListener(EventPriority.NORMAL, MatterBatteryBankRenderer.Companion::onRegisterAdditionalModels); }); ClientConfig.INSTANCE.register(); diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt index a12a8c866..a8e9e404b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt @@ -19,10 +19,12 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.block.tech.BatteryBankBlock import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.BatteryBankBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage import ru.dbotthepony.mc.otm.container.MatteryContainer +import ru.dbotthepony.mc.otm.core.ImmutableList import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.graph.Graph6Node @@ -135,30 +137,18 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) private var resolver = LazyOptional.of { this } - val container = object : MatteryContainer(this::setChangedLight, 6 * 2) { + val container = object : MatteryContainer(this::setChangedLight, BatteryBankBlockEntity.CAPACITY) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { super.setChanged(slot, new, old) - val level = level - - if (level != null) { - var state = blockState - - for (i in BatteryBankBlock.BATTERY_SLOTS_PROPS.indices) { - state = state.setValue( - BatteryBankBlock.BATTERY_SLOTS_PROPS[i], - getItem(i).getCapability(MatteryCapability.MATTER).isPresent - ) - } - - if (state !== blockState) { - level.setBlock(blockPos, state, Block.UPDATE_CLIENTS) - } - } - + capacitorStatus[slot].value = new.getCapability(MatteryCapability.MATTER).isPresent gaugeLevel = (storedMatter / maxStoredMatter).toFloat() } } + val capacitorStatus = ImmutableList(BatteryBankBlockEntity.CAPACITY) { + synchronizer.bool(false, name = "capacitor$it") + } + override val droppableContainer: Container get() = container override val defaultDisplayName: Component diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index a04973c44..a4dec5cfe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -44,24 +44,15 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte val container: MatteryContainer = object : MatteryContainer(this::setChanged, CAPACITY) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { super.setChanged(slot, new, old) - - val level = level - if (level != null) { - var state = blockState - - for (i in BatteryBankBlock.BATTERY_SLOTS_PROPS.indices) { - state = state.setValue(BatteryBankBlock.BATTERY_SLOTS_PROPS[i], getItem(i).getCapability(ForgeCapabilities.ENERGY).isPresent) - } - - if (state !== blockState) { - level.setBlock(blockPos, state, Block.UPDATE_CLIENTS) - } - } - + batteryStatus[slot].value = new.getCapability(ForgeCapabilities.ENERGY).isPresent gaugeLevel = (energy.batteryLevel / energy.maxBatteryLevel).toFloat() } } + val batteryStatus = ImmutableList(CAPACITY) { + synchronizer.bool(false, name = "battery$it") + } + override val droppableContainer: Container get() = container private val itemHandler = container.handler( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt index 62439912a..99ff2d94a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt @@ -23,21 +23,7 @@ class MatterCapacitorBankBlock : RotatableMatteryBlock(), EntityBlock { return MatterCapacitorBankBlockEntity(blockPos, blockState) } - override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { - var state = super.getStateForPlacement(context) ?: return null - - for (prop in BatteryBankBlock.BATTERY_SLOTS_PROPS) - state = state.setValue(prop, false) - - return state - } - - override fun createBlockStateDefinition(builder: StateDefinition.Builder) { - BatteryBankBlock.BATTERY_SLOTS_PROPS.forEach(builder::add) - super.createBlockStateDefinition(builder) - } - - private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.MATTER_CAPACITOR_BANK.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.MATTER_CAPACITOR_BANK.rotateFromNorth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt index 5c6fb49e6..f84edddf7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt @@ -28,15 +28,6 @@ import ru.dbotthepony.mc.otm.shapes.BlockShapes @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault class BatteryBankBlock : RotatableMatteryBlock(), EntityBlock { - override fun getStateForPlacement(context: BlockPlaceContext): BlockState { - var state = super.getStateForPlacement(context)!! - - for (prop in BATTERY_SLOTS_PROPS) - state = state.setValue(prop, false) - - return state - } - override fun getTicker( level: Level, p_153213_: BlockState, @@ -48,16 +39,11 @@ class BatteryBankBlock : RotatableMatteryBlock(), EntityBlock { return BlockEntityTicker { _, _, _, tile -> if (tile is BatteryBankBlockEntity) tile.tick() } } - override fun createBlockStateDefinition(builder: StateDefinition.Builder) { - BATTERY_SLOTS_PROPS.forEach(builder::add) - super.createBlockStateDefinition(builder) - } - - override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity? { + override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return BatteryBankBlockEntity(blockPos, blockState) } - private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.BATTERY_BANK.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.BATTERY_BANK.rotateFromNorth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( @@ -85,21 +71,4 @@ class BatteryBankBlock : RotatableMatteryBlock(), EntityBlock { val blockEntity = level.getBlockEntity(pos) as? BatteryBankBlockEntity ?: return level.oncePre { blockEntity.checkSurroundings() } } - - companion object { - val BATTERY_SLOTS_PROPS: ImmutableList = ImmutableList.of( - BooleanProperty.create("battery_0") as BooleanProperty, - BooleanProperty.create("battery_1") as BooleanProperty, - BooleanProperty.create("battery_2") as BooleanProperty, - BooleanProperty.create("battery_3") as BooleanProperty, - BooleanProperty.create("battery_4") as BooleanProperty, - BooleanProperty.create("battery_5") as BooleanProperty, - BooleanProperty.create("battery_6") as BooleanProperty, - BooleanProperty.create("battery_7") as BooleanProperty, - BooleanProperty.create("battery_8") as BooleanProperty, - BooleanProperty.create("battery_9") as BooleanProperty, - BooleanProperty.create("battery_10") as BooleanProperty, - BooleanProperty.create("battery_11") as BooleanProperty, - ) - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt index 2d67ee17a..5d62e3ff0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt @@ -2,25 +2,43 @@ package ru.dbotthepony.mc.otm.client.render.blockentity import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.renderer.MultiBufferSource +import net.minecraft.client.renderer.RenderType import net.minecraft.client.renderer.blockentity.BlockEntityRenderer import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider +import net.minecraft.client.resources.model.BakedModel import net.minecraft.core.Direction -import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock -import ru.dbotthepony.mc.otm.block.entity.tech.BatteryBankBlockEntity +import net.minecraft.resources.ResourceLocation +import net.minecraft.world.level.levelgen.XoroshiroRandomSource +import net.minecraftforge.client.event.ModelEvent +import org.joml.AxisAngle4f +import org.joml.Quaternionf +import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterCapacitorBankBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.BatteryBankBlockEntity +import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel +import ru.dbotthepony.mc.otm.core.ImmutableList import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom +import ru.dbotthepony.mc.otm.core.math.PIf import ru.dbotthepony.mc.otm.core.math.facingOne +import ru.dbotthepony.mc.otm.core.math.rotate import ru.dbotthepony.mc.otm.core.math.rotateY +import ru.dbotthepony.mc.otm.nanoTime +import java.util.function.Supplier import kotlin.math.PI abstract class BankRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer { protected abstract fun gaugeLevel(entity: T): Float protected abstract val texture: AbstractMatterySprite + protected abstract val models: List + protected abstract fun status(entity: T): List> + + private val random = XoroshiroRandomSource(nanoTime) override fun render( blockEntity: T, @@ -30,6 +48,26 @@ abstract class BankRenderer(private val context: BlockEn p_112311_: Int, p_112312_: Int ) { + val status = status(blockEntity) + + stack.pushPose() + stack.translate(0.5f, 0.5f, 0.5f) + stack.rotate(blockEntity.blockState[BlockRotationFreedom.ONE.property].front) + stack.translate(-0.5f, -0.5f, -0.5f) + + for ((i, model) in models.withIndex()) { + if (!status[i].get()) { + continue + } + + val buffer = DynamicBufferSource.WORLD.getBuffer(RenderType.solid()) + + for (quad in model.getQuads(null, null, random)) + buffer.putBulkData(stack.last(), quad, 1f, 1f, 1f, p_112311_, p_112312_) + } + + stack.popPose() + val plainLevel = gaugeLevel(blockEntity) if (plainLevel <= 0f) { @@ -81,20 +119,56 @@ abstract class BankRenderer(private val context: BlockEn } class BatteryBankRenderer(context: BlockEntityRendererProvider.Context) : BankRenderer(context) { + override val models: List by lazy { + ImmutableList(12) { + minecraft.modelManager.modelBakery.bakedTopLevelModels[ResourceLocation(OverdriveThatMatters.MOD_ID, "block/battery/battery$it")]!! + } + } + + override fun status(entity: BatteryBankBlockEntity): List> { + return entity.batteryStatus + } + override fun gaugeLevel(entity: BatteryBankBlockEntity): Float { return entity.gaugeLevel } override val texture: AbstractMatterySprite get() = PowerGaugePanel.GAUGE_FOREGROUND + + companion object { + fun onRegisterAdditionalModels(event: ModelEvent.RegisterAdditional) { + for (i in 0 .. 11) { + event.register(ResourceLocation(OverdriveThatMatters.MOD_ID, "block/battery/battery$i")) + } + } + } } class MatterBatteryBankRenderer(context: BlockEntityRendererProvider.Context) : BankRenderer(context) { + override val models: List by lazy { + ImmutableList(12) { + minecraft.modelManager.modelBakery.bakedTopLevelModels[ResourceLocation(OverdriveThatMatters.MOD_ID, "block/battery/matter_capacitor$it")]!! + } + } + + override fun status(entity: MatterCapacitorBankBlockEntity): List> { + return entity.capacitorStatus + } + override fun gaugeLevel(entity: MatterCapacitorBankBlockEntity): Float { return entity.gaugeLevel } override val texture: AbstractMatterySprite get() = MatterGaugePanel.GAUGE_FOREGROUND + + companion object { + fun onRegisterAdditionalModels(event: ModelEvent.RegisterAdditional) { + for (i in 0 .. 11) { + event.register(ResourceLocation(OverdriveThatMatters.MOD_ID, "block/battery/matter_capacitor$i")) + } + } + } } 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 68b54d5f7..f744436af 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -112,7 +112,7 @@ fun > T.prev(values: Array): T { return values[next] } -inline fun ImmutableList(size: Int, initializer: (index: Int) -> T): ImmutableList { +inline fun ImmutableList(size: Int, initializer: (index: Int) -> T): ImmutableList { require(size >= 0) { "Invalid list size $size" } return when (size) { @@ -253,3 +253,11 @@ inline fun MutableList>.forValidRefs(fn: (T) -> Unit) { val ComponentContents.key: String get() = (this as? TranslatableContents ?: throw ClassCastException("$this is not a TranslatableContents"))?.key + +fun > BlockState.getValueNullable(prop: Property): T? { + if (hasProperty(prop)) { + return getValue(prop) + } + + return null +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/EuclidMath.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/EuclidMath.kt index 86045f6f4..440d4a6f1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/EuclidMath.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/EuclidMath.kt @@ -561,6 +561,15 @@ fun PoseStack.rotateZ(rotation: Float): PoseStack { return this } +fun PoseStack.rotate(rotation: Direction): PoseStack { + return rotateY(rotation.yRotationNorth()).rotateX(rotation.xRotationNorth()) +} + +fun PoseStack.rotateSouth(rotation: Direction): PoseStack { + return rotateY(rotation.yRotationSouth()).rotateX(rotation.xRotationSouth()) +} +// /1.19.3 stuff + const val PIf = 3.1415927f /** @@ -666,3 +675,71 @@ fun PoseStack.rotateZDegrees(rotation: Float): PoseStack { return this } +fun Direction.yRotationBlockstateNorth(): Int { + return when (this) { + Direction.DOWN, Direction.UP, Direction.NORTH -> 0 + Direction.SOUTH -> 180 + Direction.WEST -> -90 + Direction.EAST -> 90 + } +} + +fun Direction.yRotationBlockstateSouth(): Int { + return when (this) { + Direction.DOWN, Direction.UP, Direction.SOUTH -> 0 + Direction.NORTH -> 180 + Direction.WEST -> 90 + Direction.EAST -> -90 + } +} + +fun Direction.xRotationBlockstateNorth(): Int { + return when (this) { + Direction.DOWN -> 90 + Direction.UP -> -90 + else -> 0 + } +} + +fun Direction.xRotationBlockstateSouth(): Int { + return when (this) { + Direction.DOWN -> -90 + Direction.UP -> 90 + else -> 0 + } +} + +fun Direction.yRotationNorth(): Float { + return when (this) { + Direction.DOWN, Direction.UP, Direction.NORTH -> 0f + Direction.SOUTH -> PIf + Direction.WEST -> -PIf / 2f + Direction.EAST -> PIf / 2f + } +} + +fun Direction.yRotationSouth(): Float { + return when (this) { + Direction.DOWN, Direction.UP, Direction.SOUTH -> 0f + Direction.NORTH -> PIf + Direction.WEST -> PIf / 2f + Direction.EAST -> -PIf / 2f + } +} + +fun Direction.xRotationNorth(): Float { + return when (this) { + Direction.DOWN -> PIf / 2f + Direction.UP -> -PIf / 2f + else -> 0f + } +} + +fun Direction.xRotationSouth(): Float { + return when (this) { + Direction.DOWN -> -PIf / 2f + Direction.UP -> PIf / 2f + else -> 0f + } +} + diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt index 4cfc8c9c3..415c331dc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt @@ -15,7 +15,7 @@ object MCreativeTabs { var DECORATIVE by WriteOnce() private set - internal fun register(event: CreativeModeTabEvent.Register) { + fun register(event: CreativeModeTabEvent.Register) { MAIN = event.registerCreativeModeTab(ResourceLocation(OverdriveThatMatters.MOD_ID, "main")) { it.icon { ItemStack(BATTERY_CREATIVE, 1) } it.title(TranslatableComponent("itemGroup.otm")) From 862eba0234a7be804da42433d3b56721684dea14 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 30 Jan 2023 21:35:11 +0700 Subject: [PATCH 0159/1199] Get button classes in line --- .../screen/matter/MatterBottlerScreen.kt | 3 +- .../client/screen/matter/MatterPanelScreen.kt | 14 ++-- .../panels/button/AbstractButtonPanel.kt | 68 +++++++++++++++++ .../button/BooleanRectangleButtonPanel.kt | 10 +-- .../screen/panels/button/ButtonPanel.kt | 73 ++++--------------- .../panels/button/CheckBoxInputPanel.kt | 8 +- .../screen/panels/button/CheckBoxPanel.kt | 58 +++++++-------- .../panels/button/RectangleButtonPanel.kt | 58 +++------------ .../screen/panels/input/QueryUserPanel.kt | 22 ++---- .../screen/tech/AndroidStationScreen.kt | 4 +- .../client/screen/tech/EnergyCounterScreen.kt | 3 +- .../input/AbstractPlayerInputWithFeedback.kt | 20 ++++- 12 files changed, 164 insertions(+), 177 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractButtonPanel.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt index dd91e10f2..5cf75261b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt @@ -37,8 +37,7 @@ class MatterBottlerScreen(menu: MatterBottlerMenu, inventory: Inventory, title: progress = ProgressGaugePanel(this, frame, menu.progressWidget, 90f, PROGRESS_ARROW_TOP) if (minecraft?.player?.isSpectator != true) { - val mode = ButtonPanel(this, frame, 46f, 69f, 100f, 20f, TranslatableComponent("otm.matter_bottler.switch_mode")) - mode.bind { menu.workFlow.switchValue() } + ButtonPanel(this, frame, 46f, 69f, 100f, 20f, TranslatableComponent("otm.matter_bottler.switch_mode"), onPress = menu.workFlow::switchValue) } return frame 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 dda087779..87585c6c3 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 @@ -157,7 +157,7 @@ class MatterPanelScreen( } if (minecraft?.player?.isSpectator != true) { - ButtonPanel(this@MatterPanelScreen, frame, width = 80f, label = TranslatableComponent("otm.container.matter_panel.cancel_task"), onPress = { + ButtonPanel(this@MatterPanelScreen, frame, width = 80f, label = TranslatableComponent("otm.container.matter_panel.cancel_task"), onPress = Runnable { menu.requestTaskCancel(task.id) frame.remove() }).also { @@ -259,32 +259,32 @@ class MatterPanelScreen( } } - ButtonPanel(this, rowTop, width = 40f, label = TranslatableComponent("otm.container.matter_panel.increase_by", 8), onPress = { input.increase(8) }).also { + ButtonPanel(this, rowTop, width = 40f, label = TranslatableComponent("otm.container.matter_panel.increase_by", 8), onPress = Runnable { input.increase(8) }).also { it.dock = Dock.RIGHT it.dockLeft = 2f } - ButtonPanel(this, rowTop, width = 40f, label = TranslatableComponent("otm.container.matter_panel.increase_by", 64), onPress = { input.increase(64) }).also { + ButtonPanel(this, rowTop, width = 40f, label = TranslatableComponent("otm.container.matter_panel.increase_by", 64), onPress = Runnable { input.increase(64) }).also { it.dock = Dock.RIGHT it.dockLeft = 2f } - ButtonPanel(this, rowTop, width = 40f, label = TranslatableComponent("otm.container.matter_panel.increase_by", 256), onPress = { input.increase(256) }).also { + ButtonPanel(this, rowTop, width = 40f, label = TranslatableComponent("otm.container.matter_panel.increase_by", 256), onPress = Runnable { input.increase(256) }).also { it.dock = Dock.RIGHT it.dockLeft = 2f } - ButtonPanel(this, rowBottom, width = 40f, label = TranslatableComponent("otm.container.matter_panel.decrease_by", 8), onPress = { input.increase(-8) }).also { + ButtonPanel(this, rowBottom, width = 40f, label = TranslatableComponent("otm.container.matter_panel.decrease_by", 8), onPress = Runnable { input.increase(-8) }).also { it.dock = Dock.RIGHT it.dockLeft = 2f } - ButtonPanel(this, rowBottom, width = 40f, label = TranslatableComponent("otm.container.matter_panel.decrease_by", 64), onPress = { input.increase(-64) }).also { + ButtonPanel(this, rowBottom, width = 40f, label = TranslatableComponent("otm.container.matter_panel.decrease_by", 64), onPress = Runnable { input.increase(-64) }).also { it.dock = Dock.RIGHT it.dockLeft = 2f } - ButtonPanel(this, rowBottom, width = 40f, label = TranslatableComponent("otm.container.matter_panel.decrease_by", 256), onPress = { input.increase(-256) }).also { + ButtonPanel(this, rowBottom, width = 40f, label = TranslatableComponent("otm.container.matter_panel.decrease_by", 256), onPress = Runnable { input.increase(-256) }).also { it.dock = Dock.RIGHT it.dockLeft = 2f } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractButtonPanel.kt new file mode 100644 index 000000000..15f224659 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractButtonPanel.kt @@ -0,0 +1,68 @@ +package ru.dbotthepony.mc.otm.client.screen.panels.button + +import com.mojang.blaze3d.platform.InputConstants +import net.minecraft.client.gui.screens.Screen +import net.minecraft.network.chat.Component +import ru.dbotthepony.mc.otm.client.playGuiClickSound +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import java.util.function.IntConsumer +import java.util.function.IntPredicate + +abstract class AbstractButtonPanel( + screen: S, + parent: EditablePanel<*>?, + x: Float = 0f, + y: Float = 0f, + width: Float = 10f, + height: Float = 10f, +) : EditablePanel(screen, parent, x, y, width, height), IntPredicate { + var isPressed = false + protected set + + open var isDisabled = false + set(value) { + if (field != value) { + if (!value) { + isPressed = false + grabMouseInput = false + } + + field = value + } + } + + override fun test(value: Int): Boolean { + return value == InputConstants.MOUSE_BUTTON_LEFT + } + + protected abstract fun onClick(mouseButton: Int) + + override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { + if (isDisabled || isPressed || !test(button)) { + return true + } + + if (!tryToGrabMouseInput()) { + return true + } + + isPressed = true + playGuiClickSound() + return true + } + + override fun mouseReleasedInner(x: Double, y: Double, button: Int): Boolean { + if (!isPressed || !test(button)) { + return true + } + + grabMouseInput = false + isPressed = false + + if (isHovered) { + onClick(button) + } + + return true + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt index 74f75efa9..5d2563433 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt @@ -20,12 +20,10 @@ abstract class BooleanRectangleButtonPanel( val skinElementInactive: AbstractMatterySprite? = null, val onChange: ((newValue: Boolean) -> Unit)? = null, ) : RectangleButtonPanel(screen, parent, x, y, width, height, null) { - override fun onClick(clickButton: Int) { - if (clickButton == InputConstants.MOUSE_BUTTON_LEFT) { - val newValue = !prop.value - prop.value = newValue - onChange?.invoke(newValue) - } + override fun onClick(mouseButton: Int) { + val newValue = !prop.value + prop.value = newValue + onChange?.invoke(newValue) } override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt index d3aea862f..ac07c680c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt @@ -9,6 +9,7 @@ import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.render.drawAligned import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.math.RGBAColor +import java.util.function.IntConsumer open class ButtonPanel( screen: S, @@ -17,9 +18,10 @@ open class ButtonPanel( y: Float = 0f, width: Float = 40f, height: Float = HEIGHT, - var label: Component -) : EditablePanel(screen, parent, x, y, width, height) { - constructor(screen: S, parent: EditablePanel<*>?, label: Component) : this(screen, parent, x = 0f, label = label) + var label: Component, + var onPress: IntConsumer? = null +) : AbstractButtonPanel(screen, parent, x, y, width, height) { + constructor(screen: S, parent: EditablePanel<*>?, label: Component, onPress: IntConsumer? = null) : this(screen, parent, x = 0f, label = label, onPress = onPress) constructor( screen: S, @@ -30,75 +32,28 @@ open class ButtonPanel( height: Float = HEIGHT, label: Component, onPress: Runnable - ) : this(screen, parent, x, y, width, height, label) { - this.callback = onPress - } - - protected var callback: Runnable? = null - protected var pressed = false - - protected open fun onClick(button: Int) { - callback?.run() - } - - override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { - if (isDisabled || pressed) { - return true - } - - if (!tryToGrabMouseInput()) { - return true - } - - pressed = true - playGuiClickSound() - return true - } - - override fun mouseReleasedInner(x: Double, y: Double, button: Int): Boolean { - if (!pressed) { - return true - } - - grabMouseInput = false - pressed = false - - if (isHovered) { - onClick(button) - } - - return true - } - - fun bind(runnable: Runnable) { - callback = runnable - } + ) : this(screen, parent, x, y, width, height, label, onPress = IntConsumer { onPress.run() }) var textColor = RGBAColor.WHITE - var isDisabled = false - set(value) { - if (field != value) { - if (!value) { - pressed = false - grabMouseInput = false - } + override fun onClick(mouseButton: Int) { + onPress?.accept(mouseButton) + } - field = value - } - } - - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + protected fun renderStretchableBackground(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { if (isDisabled) { Widgets18.BUTTON_DISABLED_STRETCHABLE.render(stack, width = width, height = height) - } else if (pressed) { + } else if (isPressed) { Widgets18.BUTTON_PRESSED_STRETCHABLE.render(stack, width = width, height = height) } else if (isHovered) { Widgets18.BUTTON_HOVERED_STRETCHABLE.render(stack, width = width, height = height) } else { Widgets18.BUTTON_IDLE_STRETCHABLE.render(stack, width = width, height = height) } + } + override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + renderStretchableBackground(stack, mouseX, mouseY, partialTick) font.drawAligned(stack, label, TextAlign.CENTER_CENTER, width / 2f, height / 2f, textColor.toInt()) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxInputPanel.kt index bc96b8d98..ff562de31 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxInputPanel.kt @@ -1,8 +1,10 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import net.minecraft.client.gui.screens.Screen +import net.minecraft.world.entity.player.Player import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.value import ru.dbotthepony.mc.otm.menu.input.IPlayerInputWithFeedback @@ -15,7 +17,7 @@ open class CheckBoxInputPanel @JvmOverloads constructor( width: Float = REGULAR_DIMENSIONS + 120f, height: Float = REGULAR_DIMENSIONS ) : CheckBoxPanel(screen, parent, x, y, width, height) { - override var checked: Boolean + override var isChecked: Boolean get() = widget.value set(value) {} @@ -23,7 +25,7 @@ open class CheckBoxInputPanel @JvmOverloads constructor( get() = !widget.test(minecraft.player) set(value) {} - override fun onClick() { - widget.accept(!checked) + override fun onClick(mouseButton: Int) { + widget.accept(!isChecked) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt index 611c17599..a0281a043 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt @@ -2,11 +2,13 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.vertex.PoseStack +import it.unimi.dsi.fastutil.booleans.BooleanConsumer import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.core.TextComponent open class CheckBoxPanel @JvmOverloads constructor( screen: S, @@ -14,34 +16,42 @@ open class CheckBoxPanel @JvmOverloads constructor( x: Float = 0f, y: Float = 0f, width: Float = REGULAR_DIMENSIONS, - height: Float = REGULAR_DIMENSIONS -) : EditablePanel(screen, parent, x, y, width, height) { - open var checked = false - open var isDisabled = false - protected var isPressed = false + height: Float = REGULAR_DIMENSIONS, + var onPress: BooleanConsumer? = null +) : AbstractButtonPanel(screen, parent, x, y, width, height) { + open var isChecked = false - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + open val IDLE_UNCHECKED: AbstractMatterySprite = Companion.IDLE_UNCHECKED + open val IDLE_CHECKED: AbstractMatterySprite = Companion.IDLE_CHECKED + open val HOVERED_UNCHECKED: AbstractMatterySprite = Companion.HOVERED_UNCHECKED + open val HOVERED_CHECKED: AbstractMatterySprite = Companion.HOVERED_CHECKED + open val PRESSED_UNCHECKED: AbstractMatterySprite = Companion.PRESSED_UNCHECKED + open val PRESSED_CHECKED: AbstractMatterySprite = Companion.PRESSED_CHECKED + open val DISABLED_UNCHECKED: AbstractMatterySprite = Companion.DISABLED_UNCHECKED + open val DISABLED_CHECKED: AbstractMatterySprite = Companion.DISABLED_CHECKED + + protected fun renderCheckboxBackground(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { if (isDisabled) { - if (checked) { + if (isChecked) { DISABLED_CHECKED.render(stack, width = width, height = height) } else { DISABLED_UNCHECKED.render(stack, width = width, height = height) } } else { if (isPressed) { - if (checked) { + if (isChecked) { PRESSED_CHECKED.render(stack, width = width, height = height) } else { PRESSED_UNCHECKED.render(stack, width = width, height = height) } } else if (isHovered) { - if (checked) { + if (isChecked) { HOVERED_CHECKED.render(stack, width = width, height = height) } else { HOVERED_UNCHECKED.render(stack, width = width, height = height) } } else { - if (checked) { + if (isChecked) { IDLE_CHECKED.render(stack, width = width, height = height) } else { IDLE_UNCHECKED.render(stack, width = width, height = height) @@ -50,31 +60,13 @@ open class CheckBoxPanel @JvmOverloads constructor( } } - protected open fun onClick() { - checked = !checked + override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + renderCheckboxBackground(stack, mouseX, mouseY, partialTick) } - override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { - if (!isDisabled && button == InputConstants.MOUSE_BUTTON_LEFT) { - grabMouseInput = true - isPressed = true - playGuiClickSound() - } - - return true - } - - override fun mouseReleasedInner(x: Double, y: Double, button: Int): Boolean { - if (isPressed && button == InputConstants.MOUSE_BUTTON_LEFT) { - if (isHovered) { - onClick() - } - - isPressed = false - grabMouseInput = false - } - - return true + override fun onClick(mouseButton: Int) { + isChecked = !isChecked + onPress?.accept(isChecked) } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/RectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/RectangleButtonPanel.kt index ed7340ead..6a72b0dc7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/RectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/RectangleButtonPanel.kt @@ -5,6 +5,8 @@ import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.core.TextComponent +import java.util.function.IntConsumer @Suppress("PropertyName") abstract class RectangleButtonPanel( @@ -14,35 +16,21 @@ abstract class RectangleButtonPanel( y: Float = 0f, width: Float, height: Float, - val onPress: ((clickButton: Int) -> Unit)? = null, -) : EditablePanel(screen, parent, x, y, width, height) { - protected var pressed = false - - protected open fun onClick(clickButton: Int) { - onPress?.invoke(clickButton) - } - + var onPress: IntConsumer? = null, +) : AbstractButtonPanel(screen, parent, x, y, width, height) { abstract val PRESSED: AbstractMatterySprite abstract val HOVERED: AbstractMatterySprite abstract val IDLE: AbstractMatterySprite abstract val DISABLED: AbstractMatterySprite - var isDisabled = false - set(value) { - if (field != value) { - if (!value) { - pressed = false - grabMouseInput = false - } + override fun onClick(mouseButton: Int) { + onPress?.accept(mouseButton) + } - field = value - } - } - - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + protected fun renderSquareButton(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { if (isDisabled) { DISABLED.render(stack, 0f, 0f, width, height) - } else if (pressed) { + } else if (isPressed) { PRESSED.render(stack, 0f, 0f, width, height) } else if (isHovered) { HOVERED.render(stack, 0f, 0f, width, height) @@ -51,31 +39,7 @@ abstract class RectangleButtonPanel( } } - override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { - if (!isDisabled) { - if (!pressed) { - playGuiClickSound() - } - - if (tryToGrabMouseInput()) { - pressed = true - } - } - - return true - } - - override fun mouseReleasedInner(x: Double, y: Double, button: Int): Boolean { - if (!isDisabled && pressed) { - pressed = false - - if (isHovered) { - onClick(button) - } - } - - grabMouseInput = false - - return true + override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + renderSquareButton(stack, mouseX, mouseY, partialTick) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/QueryUserPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/QueryUserPanel.kt index 8e71cecbd..78e634dec 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/QueryUserPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/QueryUserPanel.kt @@ -44,22 +44,16 @@ open class QueryUserPanel( this.height = height + bottom.height + PADDING + PADDING_TOP + 4f - ButtonPanel(screen, bottom, width = font.width(TranslatableComponent("otm.gui.cancel")) + 12f, label = TranslatableComponent("otm.gui.cancel")).also { - it.bind { - onCancel?.run() - this.remove() - } - - it.dock = Dock.RIGHT - } + ButtonPanel(screen, bottom, width = font.width(TranslatableComponent("otm.gui.cancel")) + 12f, label = TranslatableComponent("otm.gui.cancel"), onPress = Runnable { + onCancel?.run() + this.remove() + }).dock = Dock.RIGHT if (onConfirm != null) { - ButtonPanel(screen, bottom, width = font.width(TranslatableComponent("otm.gui.confirm")) + 12f, label = TranslatableComponent("otm.gui.confirm")).also { - it.bind { - onConfirm.run() - this.remove() - } - + ButtonPanel(screen, bottom, width = font.width(TranslatableComponent("otm.gui.confirm")) + 12f, label = TranslatableComponent("otm.gui.confirm"), onPress = Runnable { + onConfirm.run() + this.remove() + }).also { it.dock = Dock.RIGHT it.dockRight = 2f } 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 62069e936..734aa863b 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 @@ -643,12 +643,10 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I researchCanvas.parent = research val bottom = EditablePanel(this, research, 0f, 0f, 0f, 20f) - val close = ButtonPanel(this, bottom, 0f, 0f, 90f, 20f, TranslatableComponent("otm.container.matter_panel.close")) + val close = ButtonPanel(this, bottom, 0f, 0f, 90f, 20f, TranslatableComponent("otm.container.matter_panel.close"), onPress = Runnable { research!!.remove() }) bottom.dock = Dock.BOTTOM - close.dock = Dock.RIGHT - close.bind { research!!.remove() } bottom.setDockMargin(0f, 0f, 4f, 4f) researchCanvas.setDockMargin(4f, 4f, 4f, 4f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt index a33529277..47a510171 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt @@ -81,10 +81,9 @@ class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title: label.setDockMargin(4f, 0f, 0f, 0f) if (!menu.ply.isSpectator) { - val button = ButtonPanel(this, frame, 0f, 0f, 0f, 20f, TranslatableComponent("block.overdrive_that_matters.energy_counter.switch")) + val button = ButtonPanel(this, frame, 0f, 0f, 0f, 20f, TranslatableComponent("block.overdrive_that_matters.energy_counter.switch"), onPress = Runnable { menu.switchDirection.input(null) }) button.dock = Dock.TOP button.setDockMargin(4f, 0f, 4f, 0f) - button.bind { menu.switchDirection.input(null) } } val infoPanels = frame.fetchChildren() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt index 077e9a9ff..ae053bb60 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt @@ -14,7 +14,25 @@ import kotlin.reflect.KMutableProperty0 * * Getting and setting values should ONLY be done clientside */ -interface IPlayerInputWithFeedback : GetterSetter, Predicate +interface IPlayerInputWithFeedback : GetterSetter, Predicate { + companion object { + fun of(getterSetter: GetterSetter): IPlayerInputWithFeedback { + return object : IPlayerInputWithFeedback, GetterSetter by getterSetter { + override fun test(t: Player?): Boolean { + return true + } + } + } + + fun validPlayer(getterSetter: GetterSetter): IPlayerInputWithFeedback { + return object : IPlayerInputWithFeedback, GetterSetter by getterSetter { + override fun test(t: Player?): Boolean { + return t != null + } + } + } + } +} /** * Represents Server to Client synchronization and Client to Server input From 7d5b63f38e2dda2b58daea928b9bb2a6f293636f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 30 Jan 2023 23:19:58 +0700 Subject: [PATCH 0160/1199] Redstone control button, sanitize EnumRectangleButtonPanel, EnumInputWithFeedback --- .../mc/otm/client/render/MatteryAtlas.kt | 3 - .../mc/otm/client/render/WidgetLocation.kt | 1 + .../mc/otm/client/render/Widgets18.kt | 6 + .../mc/otm/client/screen/MatteryScreen.kt | 35 +++++ .../screen/decorative/HoloSignScreen.kt | 3 + .../client/screen/panels/button/Buttons.kt | 59 ++++++++ .../panels/button/EnumRectangleButtonPanel.kt | 128 +++++++----------- .../button/LargeEnumRectangleButtonPanel.kt | 3 +- .../button/SmallEnumRectangleButtonPanel.kt | 3 +- .../screen/panels/slot/AbstractSlotPanel.kt | 35 +---- .../screen/storage/ItemMonitorScreen.kt | 43 +++--- .../dbotthepony/mc/otm/core/GetterSetter.kt | 25 +++- .../mc/otm/core/util/DataStreams.kt | 11 +- .../mc/otm/menu/decorative/HoloSignMenu.kt | 5 + .../input/AbstractPlayerInputWithFeedback.kt | 8 ++ .../otm/menu/input/EnumInputWithFeedback.kt | 22 +++ .../textures/gui/widgets/redstone.png | Bin 0 -> 736 bytes .../textures/gui/widgets/redstone.xcf | Bin 0 -> 2211 bytes 18 files changed, 242 insertions(+), 148 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/Buttons.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/redstone.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/redstone.xcf diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt index 0cb929362..f0b8feab9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt @@ -22,9 +22,6 @@ data class MatteryAtlas( winding: UVWindingOrder = this.winding, ) = MatterySprite(texture, x = x, y = y, width = width, height = height, atlasHeight = this.height, atlasWidth = this.width, winding = winding) - @Deprecated("Construct grid directly instead") fun grid(rows: Int, columns: Int) = GridAtlas(texture, this.width / rows, this.height / columns, rows = rows, columns = columns) - - @Deprecated("Construct grid directly instead") fun grid(width: Float, height: Float, rows: Int, columns: Int) = GridAtlas(texture, width, height, rows, columns) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt index a2b160c72..c8fcecade 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt @@ -13,4 +13,5 @@ object WidgetLocation { val PROGRESS_ARROWS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/progress_arrows.png"), 22f, 31f) val HORIZONTAL_GAUGES = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/horizontal_gauges.png"), 96f, 54f) val VERTICAL_GAUGES = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/vertical_gauges.png"), 90f, 48f) + val REDSTONE_CONTROLS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/redstone.png"), 54f, 18f) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt index 84cde28be..1acecb411 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt @@ -46,4 +46,10 @@ object Widgets18 { val BUTTON_DISABLED_STRETCHABLE = makeButton(GRID) val BUTTON_DISABLED = GRID.next() val COOLDOWN = GRID.next() + + private val redstoneGrid = WidgetLocation.REDSTONE_CONTROLS.grid(rows = 1, columns = 3) + + val REDSTONE_IGNORED = redstoneGrid.next() + val REDSTONE_LOW = redstoneGrid.next() + val REDSTONE_HIGH = redstoneGrid.next() } 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 8679606a7..394c95677 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 @@ -11,6 +11,7 @@ import net.minecraft.client.renderer.entity.ItemRenderer import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import net.minecraft.world.inventory.Slot +import net.minecraft.world.item.ItemStack import net.minecraftforge.client.event.ContainerScreenEvent.Render.Background import net.minecraftforge.client.event.ContainerScreenEvent.Render.Foreground import net.minecraftforge.common.MinecraftForge @@ -62,6 +63,40 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit val quickCraftingType get() = quickCraftingType val isQuickCrafting get() = isQuickCrafting + fun renderItemStack(absoluteX: Float, absoluteY: Float, itemstack: ItemStack, countOverride: String? = null) { + if (!itemstack.isEmpty) { + RenderSystem.enableDepthTest() + + val systemPoseStack = RenderSystem.getModelViewStack() + + systemPoseStack.pushPose() + systemPoseStack.translate(absoluteX + 1f, absoluteY + 1f, 0f) + RenderSystem.applyModelViewMatrix() + RenderSystem.depthFunc(GL11.GL_LESS) + + // Thanks Mojang + // Very cool + // (for int x, int y, which are then cast into doubles anyway) + itemRenderer.blitOffset = 1f // Z pos + + itemRenderer.renderAndDecorateItem( + requireNotNull(ru.dbotthepony.mc.otm.client.minecraft.player) { "yo, dude, what the fuck" }, + itemstack, + 0, + 0, + (absoluteX + absoluteY * 1000f).toInt() + ) + + RenderSystem.depthFunc(GL11.GL_ALWAYS) + itemRenderer.renderGuiItemDecorations(font, itemstack, 0, 0, countOverride) + itemRenderer.blitOffset = 0f + + // too big accumulations can lead to Z near clipping issues + systemPoseStack.popPose() + RenderSystem.applyModelViewMatrix() + } + } + init { for (slot in menu.slots) { slot.x = Int.MAX_VALUE diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt index 676642d71..213dba6a2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt @@ -7,6 +7,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.button.CheckBoxLabelInputPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.input.NetworkedStringInputPanel import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.menu.decorative.HoloSignMenu @@ -24,6 +25,8 @@ class HoloSignScreen(menu: HoloSignMenu, inventory: Inventory, title: Component) lock.dockMargin = DockProperty(2f, 2f, 2f, 2f) lock.tooltip = TranslatableComponent("otm.gui.lock_holo_screen.tip") + makeDeviceControls(this, frame, redstone = menu.redstone) + return frame } } 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 new file mode 100644 index 000000000..b3dba870b --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/Buttons.kt @@ -0,0 +1,59 @@ +package ru.dbotthepony.mc.otm.client.screen.panels.button + +import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.Items +import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting +import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.client.render.Widgets18 +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.menu.input.IPlayerInputWithFeedback + +fun > makeRedstoneSettingButton( + screen: S, + parent: EditablePanel<*>?, + x: Float = 0f, + y: Float = 0f, + control: IPlayerInputWithFeedback +): LargeEnumRectangleButtonPanel { + return object : LargeEnumRectangleButtonPanel( + screen, parent, x = x, y = y, + defaultValue = RedstoneSetting.LOW, enum = RedstoneSetting::class.java, + prop = control, + ) { + override var isDisabled: Boolean + get() = !control.test(minecraft.player) + set(value) {} + + init { + add(RedstoneSetting.IGNORED, tooltip = RedstoneSetting.IGNORED.description, skinElement = Widgets18.REDSTONE_IGNORED) + add(RedstoneSetting.LOW, tooltip = RedstoneSetting.LOW.description, skinElement = Widgets18.REDSTONE_LOW) + add(RedstoneSetting.HIGH, tooltip = RedstoneSetting.HIGH.description, skinElement = Widgets18.REDSTONE_HIGH) + } + } +} + +fun > makeDeviceControls( + screen: S, + parent: FramePanel, + redstone: IPlayerInputWithFeedback? = null +): EditablePanel { + val panel = object : EditablePanel(screen, parent, width = LargeEnumRectangleButtonPanel.SIZE, height = 0f) { + override fun tick() { + super.tick() + x = parent.width + 3f + y = 0f + } + } + + var y = 0f + + if (redstone != null) { + y += makeRedstoneSettingButton(screen, panel, y = y, control = redstone).height + 2f + } + + panel.height = (y - 2f).coerceAtLeast(0f) + return panel +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt index 88ebba99e..e6e8e65f2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt @@ -12,6 +12,7 @@ import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.next import ru.dbotthepony.mc.otm.core.prev +import ru.dbotthepony.mc.otm.core.util.EnumValueCodec import ru.dbotthepony.mc.otm.core.value import java.util.* import kotlin.collections.ArrayList @@ -23,31 +24,25 @@ abstract class EnumRectangleButtonPanel>( y: Float = 0f, width: Float, height: Float, - val enum: Class, + enum: Class, val prop: GetterSetter, val defaultValue: T, - val onChange: ((newValue: T) -> Unit)? = null, ) : RectangleButtonPanel(screen, parent, x, y, width, height, null) { - private var building = true + val enum = EnumValueCodec.searchClass(enum) + private var isBuilding = true - protected val enumMapping = EnumMap>(enum) - protected val tooltipMapping = EnumMap(enum) + data class Entry>( + val key: T, + val skinElement: AbstractMatterySprite?, + val winding: UVWindingOrder = UVWindingOrder.NORMAL, + val tooltip: Component? = null + ) - fun addTooltip(value: T, component: Component): EnumRectangleButtonPanel { - check(tooltipMapping.put(value, component) == null) { "Already has mapping for $value" } - return this - } - - var mainTooltip: Component? = null - set(value) { - if (field != null) { - throw UnsupportedOperationException("Write once only") - } - - field = value - } + protected val enumMapping = EnumMap>(enum) fun isFullyDefined(): Boolean { + if (!isBuilding) return true + for (value in enum.enumConstants) { if (enumMapping[value] == null) { return false @@ -69,77 +64,54 @@ abstract class EnumRectangleButtonPanel>( return missing } - fun add(value: T, skinElement: AbstractMatterySprite, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumRectangleButtonPanel { - return add(value, skinElement to winding) + fun add(key: T, skinElement: AbstractMatterySprite? = null, tooltip: Component? = null, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumRectangleButtonPanel { + return add(Entry(key = key, skinElement = skinElement, winding = winding, tooltip = tooltip)) } - fun add(value: T, skinElement: AbstractMatterySprite, component: Component, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumRectangleButtonPanel { - return add(value, component, skinElement to winding) - } - - fun add(value: T, component: Component, skinElement: AbstractMatterySprite, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumRectangleButtonPanel { - return add(value, component, skinElement to winding) - } - - fun add(value: T, pair: Pair): EnumRectangleButtonPanel { - check(building) { "Not building" } - check(enumMapping.put(value, pair) == null) { "Already has mapping for $value" } - - if (enumMapping.size == enum.enumConstants.size) { - finish() - } - + fun add(entry: Entry): EnumRectangleButtonPanel { + check(isBuilding) { "Not building" } + check(enumMapping.put(entry.key, entry) == null) { "Already has mapping for ${entry.key}" } + if (enumMapping.size == enum.enumConstants.size) finish() return this } - fun add(value: T, component: Component, pair: Pair): EnumRectangleButtonPanel { - addTooltip(value, component) - return add(value, pair) - } - fun finish(): EnumRectangleButtonPanel { - check(building) { "Not building" } - check(isFullyDefined()) { - "Not all enums having their mapping defined, missing are: ${missingValues.joinToString(", ")}" - } - - building = false + check(isBuilding) { "Not building" } + check(isFullyDefined()) { "Not all enums having their mapping defined, missing are: ${missingValues.joinToString(", ")}" } + isBuilding = false return this } override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - check(!building) { "Still building this button!" } + check(!isBuilding) { "Still building this button!" } super.innerRender(stack, mouseX, mouseY, partialTick) - val pair = checkNotNull(enumMapping[prop.get()]) { "HOW" } - pair.first.render(stack, 0f, 0f, width, height, pair.second) + val entry = checkNotNull(enumMapping[prop.get()]) { "HOW" } + entry.skinElement?.render(stack, 0f, 0f, width, height, entry.winding) } override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { - check(!building) { "Still building this button!" } + check(!isBuilding) { "Still building this button!" } return super.mouseClickedInner(x, y, button) } override fun mouseReleasedInner(x: Double, y: Double, button: Int): Boolean { - check(!building) { "Still building this button!" } + check(!isBuilding) { "Still building this button!" } return super.mouseReleasedInner(x, y, button) } - override fun onClick(clickButton: Int) { - when (clickButton) { - InputConstants.MOUSE_BUTTON_LEFT -> { - prop.value = prop.value.next(enum.enumConstants) - onChange?.invoke(prop.get()) - } - - InputConstants.MOUSE_BUTTON_RIGHT -> { - prop.value = prop.value.prev(enum.enumConstants) - onChange?.invoke(prop.get()) - } + override fun test(value: Int): Boolean { + return value == InputConstants.MOUSE_BUTTON_LEFT || + value == InputConstants.MOUSE_BUTTON_RIGHT || + value == InputConstants.MOUSE_BUTTON_MIDDLE + } + override fun onClick(mouseButton: Int) { + when (mouseButton) { + InputConstants.MOUSE_BUTTON_LEFT -> prop.value = prop.value.next(enum.enumConstants) + InputConstants.MOUSE_BUTTON_RIGHT -> prop.value = prop.value.prev(enum.enumConstants) InputConstants.MOUSE_BUTTON_MIDDLE -> { - if (prop.get() != defaultValue) { + if (prop.value != defaultValue) { prop.value = defaultValue - onChange?.invoke(prop.get()) } } } @@ -150,33 +122,27 @@ abstract class EnumRectangleButtonPanel>( return super.innerRenderTooltips(stack, mouseX, mouseY, partialTick) } - if (mainTooltip == null && tooltipMapping.size == 0) { + if (tooltip == null && tooltipList == null && enumMapping.values.none { it.tooltip != null }) { return super.innerRenderTooltips(stack, mouseX, mouseY, partialTick) } val listing = ArrayList() - if (mainTooltip != null) { - listing.add(mainTooltip!!) + if (tooltipList != null) { + listing.addAll(tooltipList!!) + listing.add(SPACE) + } else if (tooltip != null) { + listing.add(tooltip!!) listing.add(SPACE) } - for ((key, value) in tooltipMapping) { - if (key == prop.get()) { - listing.add(value.copy().withStyle(ChatFormatting.WHITE)) - } else { - listing.add(value.copy().withStyle(ChatFormatting.GRAY)) + for (entry in enumMapping.values) { + if (entry.tooltip != null) { + listing.add(entry.tooltip.copy().withStyle(if (entry.key == prop.get()) ChatFormatting.WHITE else ChatFormatting.GRAY)) } } - screen.renderComponentTooltip( - stack, - listing, - mouseX.toInt(), - mouseY.toInt(), - font - ) - + screen.renderComponentTooltip(stack, listing, mouseX.toInt(), mouseY.toInt(), font) return true } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeEnumRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeEnumRectangleButtonPanel.kt index 2eae319de..2e0925ad0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeEnumRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeEnumRectangleButtonPanel.kt @@ -15,8 +15,7 @@ open class LargeEnumRectangleButtonPanel>( enum: Class, prop: GetterSetter, defaultValue: T, - onChange: ((newValue: T) -> Unit)? = null, -) : EnumRectangleButtonPanel(screen, parent, x, y, width, height, enum, prop, defaultValue, onChange) { +) : EnumRectangleButtonPanel(screen, parent, x, y, width, height, enum, prop, defaultValue) { final override val IDLE = Widgets18.BUTTON_IDLE final override val HOVERED = Widgets18.BUTTON_HOVERED final override val PRESSED = Widgets18.BUTTON_PRESSED diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallEnumRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallEnumRectangleButtonPanel.kt index c432c73a2..29444e7db 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallEnumRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallEnumRectangleButtonPanel.kt @@ -15,8 +15,7 @@ open class SmallEnumRectangleButtonPanel>( enum: Class, prop: GetterSetter, defaultValue: T, - onChange: ((newValue: T) -> Unit)? = null, -) : EnumRectangleButtonPanel(screen, parent, x, y, width, height, enum, prop, defaultValue, onChange) { +) : EnumRectangleButtonPanel(screen, parent, x, y, width, height, enum, prop, defaultValue) { final override val IDLE = Widgets8.BUTTON_IDLE final override val HOVERED = Widgets8.BUTTON_HOVERED final override val PRESSED = Widgets8.BUTTON_PRESSED diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt index 8bb20e1cd..37422cba5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt @@ -6,8 +6,6 @@ import net.minecraft.client.renderer.GameRenderer import net.minecraft.network.chat.Component import net.minecraft.world.item.ItemStack import net.minecraftforge.client.extensions.common.IClientItemExtensions -import org.lwjgl.opengl.GL11 -import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel @@ -27,40 +25,11 @@ abstract class AbstractSlotPanel> @JvmOverloads constru SLOT_BACKGROUND.render(stack, width = width, height = height) } - protected open fun renderRegular(stack: PoseStack, itemstack: ItemStack, count_override: String? = null) { + protected open fun renderRegular(stack: PoseStack, itemstack: ItemStack, countOverride: String? = null) { RenderSystem.setShader(GameRenderer::getPositionTexShader) if (!itemstack.isEmpty) { - RenderSystem.enableDepthTest() - - val systemPoseStack = RenderSystem.getModelViewStack() - - systemPoseStack.pushPose() - systemPoseStack.translate((absoluteX + 1f).toDouble(), (absoluteY + 1f).toDouble(), 0.0) - RenderSystem.applyModelViewMatrix() - RenderSystem.depthFunc(GL11.GL_LESS) - - // Thanks Mojang - // Very cool - // (for int x, int y, which are then cast into doubles anyway) - screen.itemRenderer.blitOffset = 1f // Z pos - - screen.itemRenderer.renderAndDecorateItem( - requireNotNull(minecraft.player) { "yo, dude, what the fuck" }, - itemstack, - 0, - 0, - (absoluteX + absoluteY * 1000f).toInt() - ) - - RenderSystem.depthFunc(GL11.GL_ALWAYS) - screen.itemRenderer.renderGuiItemDecorations(screen.font, itemstack, 0, 0, count_override) - screen.itemRenderer.blitOffset = 0f - - // too big accumulations can lead to Z near clipping issues - systemPoseStack.popPose() - RenderSystem.applyModelViewMatrix() - + screen.renderItemStack(absoluteX, absoluteY, itemstack, countOverride) clearDepth(stack) } 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 e1b67b61a..902b1e211 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 @@ -139,16 +139,15 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp val refillPriority = SmallEnumRectangleButtonPanel(this, arrowLine, enum = ItemMonitorPlayerSettings.IngredientPriority::class.java, - prop = menu.settings::ingredientPriority.asGetterSetter(), - defaultValue = ItemMonitorPlayerSettings.IngredientPriority.SYSTEM, - onChange = { menu.sendSettingsToServer() }) + prop = menu.settings::ingredientPriority.asGetterSetter(watch = { _, _ -> menu.sendSettingsToServer() }), + defaultValue = ItemMonitorPlayerSettings.IngredientPriority.SYSTEM) - refillPriority.mainTooltip = TranslatableComponent("otm.gui.item_monitor.refill_source.desc") - refillPriority.add(ItemMonitorPlayerSettings.IngredientPriority.SYSTEM, ItemMonitorPlayerSettings.IngredientPriority.SYSTEM.component, Widgets8.WHITE_ARROW_DOWN, UVWindingOrder.FLIP) - refillPriority.add(ItemMonitorPlayerSettings.IngredientPriority.INVENTORY, ItemMonitorPlayerSettings.IngredientPriority.INVENTORY.component, Widgets8.WHITE_ARROW_DOWN) - refillPriority.add(ItemMonitorPlayerSettings.IngredientPriority.INVENTORY_FIRST, ItemMonitorPlayerSettings.IngredientPriority.INVENTORY_FIRST.component, Widgets8.ARROW_SIDEWAYS, UVWindingOrder.FLIP) - refillPriority.add(ItemMonitorPlayerSettings.IngredientPriority.SYSTEM_FIRST, ItemMonitorPlayerSettings.IngredientPriority.SYSTEM_FIRST.component, Widgets8.ARROW_SIDEWAYS) - refillPriority.add(ItemMonitorPlayerSettings.IngredientPriority.DO_NOT, ItemMonitorPlayerSettings.IngredientPriority.DO_NOT.component, Widgets8.MINUS) + refillPriority.tooltip = TranslatableComponent("otm.gui.item_monitor.refill_source.desc") + refillPriority.add(ItemMonitorPlayerSettings.IngredientPriority.SYSTEM, tooltip = ItemMonitorPlayerSettings.IngredientPriority.SYSTEM.component, skinElement = Widgets8.WHITE_ARROW_DOWN, winding = UVWindingOrder.FLIP) + refillPriority.add(ItemMonitorPlayerSettings.IngredientPriority.INVENTORY, tooltip = ItemMonitorPlayerSettings.IngredientPriority.INVENTORY.component, skinElement = Widgets8.WHITE_ARROW_DOWN) + refillPriority.add(ItemMonitorPlayerSettings.IngredientPriority.INVENTORY_FIRST, tooltip = ItemMonitorPlayerSettings.IngredientPriority.INVENTORY_FIRST.component, skinElement = Widgets8.ARROW_SIDEWAYS, winding = UVWindingOrder.FLIP) + refillPriority.add(ItemMonitorPlayerSettings.IngredientPriority.SYSTEM_FIRST, tooltip = ItemMonitorPlayerSettings.IngredientPriority.SYSTEM_FIRST.component, skinElement = Widgets8.ARROW_SIDEWAYS) + refillPriority.add(ItemMonitorPlayerSettings.IngredientPriority.DO_NOT, tooltip = ItemMonitorPlayerSettings.IngredientPriority.DO_NOT.component, skinElement = Widgets8.MINUS) refillPriority.dock = Dock.LEFT @@ -161,25 +160,23 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp val resultTarget = SmallEnumRectangleButtonPanel(this, resultAndButtons, y = 38f, enum = ItemMonitorPlayerSettings.ResultTarget::class.java, - prop = menu.settings::resultTarget.asGetterSetter(), - defaultValue = ItemMonitorPlayerSettings.ResultTarget.MIXED, - onChange = { menu.sendSettingsToServer() }) + prop = menu.settings::resultTarget.asGetterSetter(watch = { _, _ -> menu.sendSettingsToServer() }), + defaultValue = ItemMonitorPlayerSettings.ResultTarget.MIXED) - resultTarget.mainTooltip = TranslatableComponent("otm.gui.item_monitor.result_target.desc") - resultTarget.add(ItemMonitorPlayerSettings.ResultTarget.MIXED, ItemMonitorPlayerSettings.ResultTarget.MIXED.component, Widgets8.ARROW_SIDEWAYS) - resultTarget.add(ItemMonitorPlayerSettings.ResultTarget.ALL_INVENTORY, ItemMonitorPlayerSettings.ResultTarget.ALL_INVENTORY.component, Widgets8.ARROW_PAINTED_UP, UVWindingOrder.FLIP) - resultTarget.add(ItemMonitorPlayerSettings.ResultTarget.ALL_SYSTEM, ItemMonitorPlayerSettings.ResultTarget.ALL_SYSTEM.component, Widgets8.ARROW_PAINTED_UP) + resultTarget.tooltip = TranslatableComponent("otm.gui.item_monitor.result_target.desc") + resultTarget.add(ItemMonitorPlayerSettings.ResultTarget.MIXED, tooltip = ItemMonitorPlayerSettings.ResultTarget.MIXED.component, skinElement = Widgets8.ARROW_SIDEWAYS) + resultTarget.add(ItemMonitorPlayerSettings.ResultTarget.ALL_INVENTORY, tooltip = ItemMonitorPlayerSettings.ResultTarget.ALL_INVENTORY.component, skinElement = Widgets8.ARROW_PAINTED_UP, winding = UVWindingOrder.FLIP) + resultTarget.add(ItemMonitorPlayerSettings.ResultTarget.ALL_SYSTEM, tooltip = ItemMonitorPlayerSettings.ResultTarget.ALL_SYSTEM.component, skinElement = Widgets8.ARROW_PAINTED_UP) val craftingAmount = SmallEnumRectangleButtonPanel(this, resultAndButtons, x = 10f, y = 38f, enum = ItemMonitorPlayerSettings.Amount::class.java, - prop = menu.settings::craftingAmount.asGetterSetter(), - defaultValue = ItemMonitorPlayerSettings.Amount.STACK, - onChange = { menu.sendSettingsToServer() }) + prop = menu.settings::craftingAmount.asGetterSetter(watch = { _, _ -> menu.sendSettingsToServer() }), + defaultValue = ItemMonitorPlayerSettings.Amount.STACK) - craftingAmount.mainTooltip = TranslatableComponent("otm.gui.item_monitor.amount.desc") - craftingAmount.add(ItemMonitorPlayerSettings.Amount.ONE, ItemMonitorPlayerSettings.Amount.ONE.component, Widgets8.ONE) - craftingAmount.add(ItemMonitorPlayerSettings.Amount.STACK, ItemMonitorPlayerSettings.Amount.STACK.component, Widgets8.S) - craftingAmount.add(ItemMonitorPlayerSettings.Amount.FULL, ItemMonitorPlayerSettings.Amount.FULL.component, Widgets8.F) + craftingAmount.tooltip = TranslatableComponent("otm.gui.item_monitor.amount.desc") + craftingAmount.add(ItemMonitorPlayerSettings.Amount.ONE, tooltip = ItemMonitorPlayerSettings.Amount.ONE.component, skinElement = Widgets8.ONE) + craftingAmount.add(ItemMonitorPlayerSettings.Amount.STACK, tooltip = ItemMonitorPlayerSettings.Amount.STACK.component, skinElement = Widgets8.S) + craftingAmount.add(ItemMonitorPlayerSettings.Amount.FULL, tooltip = ItemMonitorPlayerSettings.Amount.FULL.component, skinElement = Widgets8.F) val craftingHistory = GridPanel(this, bottomPanel, width = 3 * 18f, height = 3 * 18f, columns = 3, rows = 3) craftingHistory.dock = Dock.LEFT diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt index 022140131..db519b33e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt @@ -66,5 +66,28 @@ interface GetterSetter : Supplier, Consumer, ReadWriteProperty } } -fun KMutableProperty0.asGetterSetter() = GetterSetter.of(this) +fun KMutableProperty0.asGetterSetter(watch: ((old: V, new: V) -> Unit)? = null): GetterSetter { + return GetterSetter.of(this).let { + if (watch != null) { + it.watch(watch) + } else { + it + } + } +} + +fun GetterSetter.watch(watch: (old: V, new: V) -> Unit): GetterSetter { + return object : GetterSetter { + override fun get(): V { + return this@watch.get() + } + + override fun accept(t: V) { + val old = get() + this@watch.accept(t) + watch.invoke(old, t) + } + } +} + fun KMutableProperty0.asGetterOnly() = GetterSetter.of(Supplier { this.get() }, Consumer { /* do nothing */ }) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt index 83ca6a005..95c4308d3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt @@ -76,7 +76,8 @@ val VarLongValueCodec = StreamCodec(DataInputStream::readVarLongLE, DataOutputSt val BinaryStringCodec = StreamCodec(DataInputStream::readBinaryString, DataOutputStream::writeBinaryString) class EnumValueCodec>(clazz: Class, val writeByIndices: Boolean = false) : IStreamCodec { - private val values = search(clazz) ?: throw ClassCastException("$clazz does not have enum constants. Not an enum?") + val clazz = searchClass(clazz) + private val values = searchClass(clazz).enumConstants!! override fun read(stream: DataInputStream): V { if (writeByIndices) { @@ -109,14 +110,18 @@ class EnumValueCodec>(clazz: Class, val writeByIndices: Boole * * is there an already existing solution? */ - fun > search(clazz: Class): Array? { + fun > searchClass(clazz: Class): Class { var search: Class<*> = clazz while (search.enumConstants == null && search.superclass != null) { search = search.superclass } - return search.enumConstants as? Array + if (search.enumConstants == null) { + throw ClassCastException("$clazz does not represent an enum or enum subclass") + } + + return search as Class } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt index 402406f00..a9495dfa8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt @@ -2,9 +2,11 @@ package ru.dbotthepony.mc.otm.menu.decorative import net.minecraft.world.entity.player.Inventory import net.minecraft.world.inventory.Slot +import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.StringInputWithFeedback import ru.dbotthepony.mc.otm.registry.MMenus @@ -15,14 +17,17 @@ class HoloSignMenu @JvmOverloads constructor( ) : MatteryMenu(MMenus.HOLO_SIGN, containerId, inventory, tile) { val text = StringInputWithFeedback(this) val locked = BooleanInputWithFeedback(this) + val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java) init { text.filter { it.isCreative || !locked.value } + redstone.filter { it.isCreative || !locked.value } locked.filter { it.isCreative } if (tile != null) { text.withConsumer { if (tile.locked) tile.text = it else tile.text = HoloSignBlockEntity.truncate(it) }.withSupplier(tile::text) locked.with(tile::locked) + redstone.with(tile.redstoneControl::redstoneSetting) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt index ae053bb60..8a4893d75 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt @@ -24,6 +24,10 @@ interface IPlayerInputWithFeedback : GetterSetter, Predicate { } } + fun of(getterSetter: GetterSetter, filter: Predicate): IPlayerInputWithFeedback { + return object : IPlayerInputWithFeedback, GetterSetter by getterSetter, Predicate by filter {} + } + fun validPlayer(getterSetter: GetterSetter): IPlayerInputWithFeedback { return object : IPlayerInputWithFeedback, GetterSetter by getterSetter { override fun test(t: Player?): Boolean { @@ -34,6 +38,10 @@ interface IPlayerInputWithFeedback : GetterSetter, Predicate { } } +fun GetterSetter.wrapAsPlayerInput(filter: Predicate = Predicate { it != null }): IPlayerInputWithFeedback { + return IPlayerInputWithFeedback.of(this, filter) +} + /** * Represents Server to Client synchronization and Client to Server input * diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt new file mode 100644 index 000000000..f03279bd4 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt @@ -0,0 +1,22 @@ +package ru.dbotthepony.mc.otm.menu.input + +import ru.dbotthepony.mc.otm.core.GetterSetter +import ru.dbotthepony.mc.otm.core.util.EnumValueCodec +import ru.dbotthepony.mc.otm.menu.MatteryMenu +import kotlin.reflect.KMutableProperty0 + +class EnumInputWithFeedback>(menu: MatteryMenu, clazz: Class) : AbstractPlayerInputWithFeedback() { + val codec = EnumValueCodec(clazz) + private val default = codec.clazz.enumConstants!![0] + + override val input = menu.PlayerInput(codec, false) { consumer?.invoke(it) } + override val value by menu.mSynchronizer.ComputedField(getter = { supplier?.invoke() ?: default }, codec) + + constructor(menu: MatteryMenu, clazz: Class, state: KMutableProperty0) : this(menu, clazz) { + with(state) + } + + constructor(menu: MatteryMenu, clazz: Class, state: GetterSetter) : this(menu, clazz) { + with(state) + } +} diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/redstone.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/redstone.png new file mode 100644 index 0000000000000000000000000000000000000000..bf86e17f084afd79ccdec439e3b7f132dd8b60ac GIT binary patch literal 736 zcmV<60w4W}P)EX>4Tx04R}tkv&MmP!xqvQ$>+V2Rn#}WQa}{L`58>ibb$c+6t{Yn7s54nlvOS zE{=k0!NH%!s)LKOt`4q(Aov5~>f)s6A|>9J6k5c1;qgAsyXWxUeSpxYFwN?k05sh; zQ}LLX&8><(uLxiSVMvfWLS5n{2}!Ab|SlBp3-6HBV5Q@)V( zSmnIMS*z4o>z@3Dp}fA5<~prm#Ib|~k`SSwhB7L!5v5%x#X^eCV?O>N*PkSpLas6x zITlcb2HEw4|H1FsT7{`eFDVoQx?ddUV-)Dw1)6oo`95}><_Qpd2CnqBzuEw1KS{5* zHR%WlZvz+CZB5w&E_Z;zCqp)6R|?V+3I*W(jJ_!c4BP^JYu?;i=Qw=;GBm5@8{ps& z7%Nity3f0NJLmRqPiuZZxTA8z1ijBF00006VoOIv0RI600RN!9r;`8x010qNS#tmY zE+YT{E+YYWr9XB6000McNliru=K&rMGbR22e#`&>02y>eSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{006j2L_t(Y$75g^1w#uk!WjSm|0mA?M#e$uF{a@fW1}9U z1eoVG{5Q{S_&;o8jGmsu>#=nqA^)+lhl1zeMcUfn;Q#pKVTC8Ug5b4lQPf~Fr%Or~ z!(fLqJ5l(Z$Bz>>NH!RoISg1lM#yZe=1{91tFW^A-*N01 zBP=Nfty#lJPCbU6{7z18V5D18q-6z->@j+HiteQ%y*xGAq#A8`jDk@>HUI$rfJ6$Y S$Bh{P0000bQhA2niMr6lfPg$%e?QA{B{H2?_9)O`154r8udQfZJVGd_jc5 zKaeG#!Pl^@G@LW`G%iF{rEV&&b!P6|du}|QGcyUJ_|QG-^xQA?M#F%;1a8xTeFJU* zriq3@2iUSWU~>ns_dp_GcL4!x0{1hYmG^+(KqbV>YMoIW2g51GhWgpPanPOyT{nrQ zefQ1Vckh|Gsi;xh4ue`aj=GxtV|y|^9t7@WG>E!8&UP>Cj0U5zyREv~I6P>(b@eoM zkUm(GZn)}U`e<_4?nJ}TZPYP3J~PS&wa>$7>PEv(KbWv$)ay-xsjK)oKXuQNIp>_2 z^K?-7koLvbX}`fm{oAf1KyZbM{V42{z%{3p0IstHs`PhfXrTqbIE%`ekIs0U^B?7W zzL4T|q zin#z&fy~9?AEwGxrEfe0V0zw4hruXuLu_y+u99#R;4;E-ljKZ%%nkGcWWtHznjAvn ztBzARN19EE)@nMk&=gW6#iq5)T13h!Lk=ZQB}7duTd0Xq6Qjl}#+IM8h@b`;awv8x zCdM--4)#gtq?a>o8A zwTt|qm6cwt{L^pG)GmEmlS8Pau6*X!9#gS26Km-tB^=p{99H3*p5;4U38G!($gbm` zdvLqaqKgfC;XHweFSG-f15wdr6d|#d{ak2826^X5- j+n0#@xJG%W3eVOOof9`s@DCvc&Q`%F12~syXy5n)`ObX} literal 0 HcmV?d00001 From 9e995a88aeb2ec6ca25e0d128b035c2a3655c4a6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 30 Jan 2023 23:25:18 +0700 Subject: [PATCH 0161/1199] =?UTF-8?q?=E2=9A=99=20SHOCKY=20=E2=80=94=20?= =?UTF-8?q?=D0=A1=D0=B5=D0=B3=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=2022:45=20?= =?UTF-8?q?=D1=8F=20=D0=B4=D1=83=D0=BC=D0=B0=D0=BB=20=D1=82=D0=B5=D0=BA?= =?UTF-8?q?=D1=81=D1=82=20=D0=B1=D1=83=D0=B4=D0=B5=D1=82=20=D0=BD=D0=B5?= =?UTF-8?q?=D0=BC=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=B4=D0=B0=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/client/render/blockentity/HoloSignRenderer.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 5a5ed2bc9..80c8aa5c2 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 @@ -31,7 +31,7 @@ class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context) poseStack.pushPose() poseStack.rotateWithBlockFacing(tile.blockState.rotationThree) - poseStack.translate(0.5f, 0.5f, 0.6f) + poseStack.translate(0.5f, 0.5f, 0.5f) poseStack.scale(0.01f, 0.01f, 0.01f) val sorse = DynamicBufferSource.WORLD From 0ad7618ad7d20e8d81801ad305e8f2f30d388206 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 30 Jan 2023 23:48:56 +0700 Subject: [PATCH 0162/1199] Redstone controls in menus, fix a lot of machines ignoring their redstone control --- .../otm/block/entity/storage/StorageBusBlockEntity.kt | 4 ++-- .../mc/otm/block/entity/storage/StorageInterfaces.kt | 8 +++++++- .../entity/storage/StoragePowerSupplierBlockEntity.kt | 3 +++ .../otm/block/entity/tech/EnergyCounterBlockEntity.kt | 6 ++++++ .../otm/block/entity/tech/EnergyServoBlockEntity.kt | 3 +++ .../otm/client/screen/matter/MatterBottlerScreen.kt | 3 +++ .../client/screen/matter/MatterDecomposerScreen.kt | 3 +++ .../otm/client/screen/matter/MatterRecyclerScreen.kt | 3 +++ .../client/screen/matter/MatterReplicatorScreen.kt | 3 +++ .../otm/client/screen/matter/MatterScannerScreen.kt | 3 +++ .../mc/otm/client/screen/panels/button/Buttons.kt | 2 +- .../mc/otm/client/screen/storage/StorageBusScreen.kt | 3 +++ .../client/screen/storage/StorageExporterScreen.kt | 3 +++ .../client/screen/storage/StorageImporterScreen.kt | 3 +++ .../screen/storage/StoragePowerSupplierScreen.kt | 3 +++ .../mc/otm/client/screen/tech/AndroidStationScreen.kt | 3 +++ .../otm/client/screen/tech/ChemicalGeneratorScreen.kt | 5 ++++- .../mc/otm/client/screen/tech/EnergyCounterScreen.kt | 3 +++ .../mc/otm/client/screen/tech/EnergyServoScreen.kt | 3 +++ .../mc/otm/client/screen/tech/PlatePressScreen.kt | 5 ++++- .../ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt | 4 ++++ .../mc/otm/menu/tech/ChemicalGeneratorMenu.kt | 11 +++++++++++ .../dbotthepony/mc/otm/menu/tech/EnergyCounterMenu.kt | 10 ++++++++++ .../dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt | 10 ++++++++++ 24 files changed, 101 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt index b03a534fc..c37b24102 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt @@ -486,7 +486,7 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter } override fun insertStack(stack: ItemStackWrapper, simulate: Boolean): ItemStackWrapper { - if (energy.batteryLevel.isZero || !filter.match(stack.item)) + if (redstoneControl.isBlockedByRedstone || energy.batteryLevel.isZero || !filter.match(stack.item)) return stack val maxPossibleDemand = ITEM_STORAGE.energyPerOperation * stack.count @@ -531,7 +531,7 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter } override fun extractStack(id: UUID, amount: BigInteger, simulate: Boolean): ItemStackWrapper { - if (!amount.isPositive) + if (redstoneControl.isBlockedByRedstone || !amount.isPositive) return ItemStackWrapper.EMPTY val maxPossibleDemand = ITEM_STORAGE.energyPerOperation * amount diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt index 3b1762b84..19c4b3342 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt @@ -194,7 +194,7 @@ class StorageImporterBlockEntity(blockPos: BlockPos, blockState: BlockState) } override fun insertItem(slot: Int, stack: ItemStack, simulate: Boolean): ItemStack { - if (!filter.match(stack)) + if (redstoneControl.isBlockedByRedstone || !filter.match(stack)) return stack val view = cell.storageGraph?.getVirtualComponent(ITEM_STORAGE) ?: return stack @@ -225,6 +225,9 @@ class StorageImporterBlockEntity(blockPos: BlockPos, blockState: BlockState) } fun tick() { + if (redstoneControl.isBlockedByRedstone) + return + batteryChargeLoop() cell.tickEnergyDemanding() @@ -334,6 +337,9 @@ class StorageExporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : } fun tick() { + if (redstoneControl.isBlockedByRedstone) + return + batteryChargeLoop() cell.tickEnergyDemanding() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt index d9cc36200..16c54f5e6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt @@ -76,6 +76,9 @@ class StoragePowerSupplierBlockEntity(blockPos: BlockPos, blockState: BlockState } fun tick() { + if (redstoneControl.isBlockedByRedstone) + return + batteryChargeLoop() if (energy.batteryLevel.isZero) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt index c7dbf226e..982838158 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt @@ -145,6 +145,9 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat override val energyFlow = FlowDirection.input(isInput) override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { + if (redstoneControl.isBlockedByRedstone) + return Decimal.ZERO + val it = inputCapability.first if (it != null) { @@ -170,6 +173,9 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat } override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { + if (redstoneControl.isBlockedByRedstone) + return Decimal.ZERO + val it = outputCapability.first if (it != null) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt index d7c4b9655..85d942161 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt @@ -133,6 +133,9 @@ class EnergyServoBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte } fun tick() { + if (redstoneControl.isBlockedByRedstone) + return + val charge = container[SLOT_CHARGE] val discharge = container[SLOT_DISCHARGE] diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt index 5cf75261b..713119729 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt @@ -6,6 +6,7 @@ import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.button.ButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.MatterCapacitorSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel @@ -40,6 +41,8 @@ class MatterBottlerScreen(menu: MatterBottlerMenu, inventory: Inventory, title: ButtonPanel(this, frame, 46f, 69f, 100f, 20f, TranslatableComponent("otm.matter_bottler.switch_mode"), onPress = menu.workFlow::switchValue) } + makeDeviceControls(this, frame, redstone = menu.redstone) + return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt index aa2143b70..ab2c64c78 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt @@ -6,6 +6,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel @@ -27,6 +28,8 @@ class MatterDecomposerScreen(p_97741_: MatterDecomposerMenu, p_97742_: Inventory SlotPanel(this, frame, menu.outputMain, 74f, PROGRESS_SLOT_TOP) SlotPanel(this, frame, menu.outputStacking, 56f, PROGRESS_SLOT_TOP) + makeDeviceControls(this, frame, redstone = menu.redstone) + return frame } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt index ba839582a..beb48e502 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt @@ -5,6 +5,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel @@ -23,6 +24,8 @@ class MatterRecyclerScreen(menu: MatterRecyclerMenu, inventory: Inventory, title ProgressGaugePanel(this, frame, menu.progress, 63f, PROGRESS_ARROW_TOP).flop = true SlotPanel(this, frame, menu.input, 93f, PROGRESS_SLOT_TOP) + makeDeviceControls(this, frame, redstone = menu.redstone) + return frame } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt index 2305a1bfb..022b961ae 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt @@ -5,6 +5,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel @@ -29,6 +30,8 @@ class MatterReplicatorScreen(p_97741_: MatterReplicatorMenu, p_97742_: Inventory SlotPanel(this, frame, menu.storageSlots[3], 80f, PROGRESS_SLOT_TOP + 22f) SlotPanel(this, frame, menu.storageSlots[4], 80f + 18f, PROGRESS_SLOT_TOP + 22f) + makeDeviceControls(this, frame, redstone = menu.redstone) + return frame } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterScannerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterScannerScreen.kt index d08d3336f..524284ccc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterScannerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterScannerScreen.kt @@ -6,6 +6,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.PatternGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel @@ -24,6 +25,8 @@ class MatterScannerScreen(p_97741_: MatterScannerMenu, p_97742_: Inventory, p_97 ProgressGaugePanel(this, frame, menu.progress, 63f, PROGRESS_ARROW_TOP).flop = true SlotPanel(this, frame, menu.input, 93f, PROGRESS_SLOT_TOP) + makeDeviceControls(this, frame, redstone = menu.redstone) + return frame } } 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 b3dba870b..e5f01598c 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 @@ -40,7 +40,7 @@ fun > makeDeviceControls( parent: FramePanel, redstone: IPlayerInputWithFeedback? = null ): EditablePanel { - val panel = object : EditablePanel(screen, parent, width = LargeEnumRectangleButtonPanel.SIZE, height = 0f) { + val panel = object : EditablePanel(screen, parent, width = LargeEnumRectangleButtonPanel.SIZE, height = 0f, x = parent.width + 3f) { override fun tick() { super.tick() x = parent.width + 3f diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt index 7d0f3e5f0..8d759e8c3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt @@ -6,6 +6,7 @@ import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.button.CheckBoxLabelInputPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.FilterSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel @@ -28,6 +29,8 @@ class StorageBusScreen(menu: StorageBusMenu, inventory: Inventory, title: Compon CheckBoxLabelInputPanel(this, frame, menu.busFilterState, TranslatableComponent("otm.gui.filter.is_whitelist"), 59f, 78f, width = 170f) + makeDeviceControls(this, frame, redstone = menu.redstone) + return frame } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt index 02bd2b59f..720e7f8c6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt @@ -6,6 +6,7 @@ import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.button.CheckBoxLabelInputPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.FilterSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel @@ -28,6 +29,8 @@ class StorageExporterScreen(menu: StorageExporterMenu, inventory: Inventory, tit CheckBoxLabelInputPanel(this, frame, menu.busFilterState, TranslatableComponent("otm.gui.filter.is_whitelist"), 59f, 78f, width = 170f) + makeDeviceControls(this, frame, redstone = menu.redstone) + return frame } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt index 12f1b2155..27c850202 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt @@ -6,6 +6,7 @@ import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.button.CheckBoxLabelInputPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.FilterSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel @@ -28,6 +29,8 @@ class StorageImporterScreen(menu: StorageImporterMenu, inventory: Inventory, tit CheckBoxLabelInputPanel(this, frame, menu.busFilterState, TranslatableComponent("otm.gui.filter.is_whitelist"), 59f, 78f, width = 170f) + makeDeviceControls(this, frame, redstone = menu.redstone) + return frame } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt index 294f9fcbb..d50b6a97c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt @@ -5,6 +5,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.HorizontalPowerGaugePanel @@ -66,6 +67,8 @@ class StoragePowerSupplierScreen(menu: StoragePowerSupplierMenu, inventory: Inve } } + makeDeviceControls(this, frame, redstone = menu.redstone) + return frame } } 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 734aa863b..7e621b80b 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 @@ -28,6 +28,7 @@ import ru.dbotthepony.mc.otm.client.render.drawRect 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 +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.EquipmentBatterySlotPanel @@ -730,6 +731,8 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I this.playerStrip = playerStrip + makeDeviceControls(this, frame, redstone = menu.redstone) + return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt index e61fdb4be..b0394c745 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt @@ -4,6 +4,7 @@ import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel @@ -12,7 +13,7 @@ import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel import ru.dbotthepony.mc.otm.menu.tech.ChemicalGeneratorMenu class ChemicalGeneratorScreen(menu: ChemicalGeneratorMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { - override fun makeMainFrame(): FramePanel> { + override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! WidePowerGaugePanel(this, frame, menu.energy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) @@ -33,6 +34,8 @@ class ChemicalGeneratorScreen(menu: ChemicalGeneratorMenu, inventory: Inventory, SlotPanel(this, frame, menu.residueSlot, 56f, PROGRESS_SLOT_TOP) SlotPanel(this, frame, menu.fuelSlot, 104f, PROGRESS_SLOT_TOP) + makeDeviceControls(this, frame, redstone = menu.redstone) + return frame } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt index 47a510171..6fb3052db 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt @@ -6,6 +6,7 @@ import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.button.ButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.input.NetworkNumberInputPanel import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.menu.tech.EnergyCounterMenu @@ -106,6 +107,8 @@ class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title: limitsTab.onClose!!.run() + makeDeviceControls(this, frame, redstone = menu.redstone) + return frame } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt index c49970006..a33f5d9e6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt @@ -9,6 +9,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.widget.HorizontalPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalPowerGaugePanel @@ -61,6 +62,8 @@ class EnergyServoScreen(menu: EnergyServoMenu, inventory: Inventory, title: Comp it.dockRight } + makeDeviceControls(this, frame, redstone = menu.redstone) + return frame } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt index e4e6f1f1c..cd70a1ef1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt @@ -5,6 +5,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel @@ -12,7 +13,7 @@ import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu class PlatePressScreen(menu: PlatePressMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { - override fun makeMainFrame(): FramePanel> { + override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! WidePowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) @@ -22,6 +23,8 @@ class PlatePressScreen(menu: PlatePressMenu, inventory: Inventory, title: Compon ProgressGaugePanel(this, frame, menu.progressGauge, 78f, PROGRESS_ARROW_TOP) SlotPanel(this, frame, menu.outputSlot, 104f, PROGRESS_SLOT_TOP) + makeDeviceControls(this, frame, redstone = menu.redstone) + return frame } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt index 2f2f226a6..f8cfc8287 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt @@ -5,6 +5,8 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import net.minecraft.world.SimpleContainer +import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting +import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback abstract class MatteryPoweredMenu protected constructor( menuType: MenuType<*>, @@ -14,6 +16,7 @@ abstract class MatteryPoweredMenu protected constructor( ) : MatteryMenu(menuType, containerID, inventory, tile) { val powerWidget: LevelGaugeWidget val batterySlot: BatterySlot + val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java) init { if (tile == null) { @@ -22,6 +25,7 @@ abstract class MatteryPoweredMenu protected constructor( } else { powerWidget = LevelGaugeWidget(this, tile.energy) batterySlot = BatterySlot(tile.batteryContainer, 0) + redstone.with(tile.redstoneControl::redstoneSetting) } addSlot(batterySlot) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt index 4950063cd..765217587 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt @@ -5,10 +5,12 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack import net.minecraftforge.common.ForgeHooks import net.minecraftforge.common.capabilities.ForgeCapabilities +import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.block.entity.tech.ChemicalGeneratorBlockEntity import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -16,6 +18,14 @@ import ru.dbotthepony.mc.otm.registry.MMenus class ChemicalGeneratorMenu @JvmOverloads constructor(id: Int, inv: Inventory, tile: ChemicalGeneratorBlockEntity? = null) : MatteryMenu(MMenus.CHEMICAL_GENERATOR, id, inv, tile) { + val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java) + + init { + if (tile != null) { + redstone.with(tile.redstoneControl::redstoneSetting) + } + } + val container = tile?.container ?: SimpleContainer(3) val fuelSlot = object : MatterySlot(container, ChemicalGeneratorBlockEntity.SLOT_INPUT) { @@ -44,6 +54,7 @@ class ChemicalGeneratorMenu @JvmOverloads constructor(id: Int, inv: Inventory, t val energy = LevelGaugeWidget(this, tile?.energy) var burnTime by mSynchronizer.int() + override val storageSlots = listOf( addSlot(fuelSlot), addSlot(batterySlot), diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyCounterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyCounterMenu.kt index 01aac2e7d..1242fe4db 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyCounterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyCounterMenu.kt @@ -5,10 +5,12 @@ import kotlin.jvm.JvmOverloads import net.minecraft.world.entity.player.Inventory import net.minecraft.world.inventory.Slot import net.minecraft.world.level.block.Block +import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.block.tech.EnergyCounterBlock import ru.dbotthepony.mc.otm.block.entity.tech.EnergyCounterBlockEntity import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.registry.MMenus import java.math.BigDecimal @@ -28,6 +30,14 @@ class EnergyCounterMenu @JvmOverloads constructor( tile.level?.setBlock(tile.blockPos, tile.blockState.setValue(EnergyCounterBlock.INPUT_DIRECTION, tile.blockState.getValue(EnergyCounterBlock.INPUT_DIRECTION).opposite), Block.UPDATE_ALL) } + val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java) + + init { + if (tile != null) { + redstone.with(tile.redstoneControl::redstoneSetting) + } + } + var inputDirection by mSynchronizer.enum(Direction::class.java) val maxIOInput = bigDecimalInput { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt index c452c4a83..cba9da535 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt @@ -5,10 +5,12 @@ import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.block.entity.tech.EnergyServoBlockEntity import ru.dbotthepony.mc.otm.capability.energy import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -22,6 +24,14 @@ class EnergyServoMenu @JvmOverloads constructor( val powerGauge = LevelGaugeWidget(this, tile?.energy) + val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java) + + init { + if (tile != null) { + redstone.with(tile.redstoneControl::redstoneSetting) + } + } + init { val container = tile?.container ?: SimpleContainer(2) From 12779ddc62783f2529e3a1febda331f19b73b569 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 30 Jan 2023 23:52:19 +0700 Subject: [PATCH 0163/1199] Add redstone control to battery bank menu --- .../mc/otm/client/screen/tech/BatteryBankScreen.kt | 5 ++++- .../ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BatteryBankScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BatteryBankScreen.kt index 9308536ac..bdc576dd3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BatteryBankScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BatteryBankScreen.kt @@ -6,12 +6,13 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel class BatteryBankScreen(menu: BatteryBankMenu, p_97742_: Inventory, p_97743_: Component) : MatteryScreen(menu, p_97742_, p_97743_) { - override fun makeMainFrame(): FramePanel> { + override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! WidePowerGaugePanel(this, frame, menu.powerLevel, LEFT_MARGIN, GAUGE_TOP_WITHOUT_SLOT) @@ -22,6 +23,8 @@ class BatteryBankScreen(menu: BatteryBankMenu, p_97742_: Inventory, p_97743_: Co for (i in 6 .. 11) BatterySlotPanel(this, frame, menu.storageSlots[i], 44f + 18 * (i - 6), 32f + 18f) + makeDeviceControls(this, frame, redstone = menu.redstone) + return frame } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt index e470ad129..69ba6fe18 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt @@ -5,6 +5,7 @@ import kotlin.jvm.JvmOverloads import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.block.entity.tech.BatteryBankBlockEntity import net.minecraft.world.SimpleContainer +import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.core.ImmutableList import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.capability.MatteryCapability @@ -12,6 +13,7 @@ import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.menu.BatterySlot import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.registry.MMenus class BatteryBankMenu @JvmOverloads constructor( @@ -21,8 +23,13 @@ class BatteryBankMenu @JvmOverloads constructor( ) : MatteryMenu(MMenus.BATTERY_BANK, p_38852_, inventory, tile) { val powerLevel: LevelGaugeWidget override val storageSlots: List + val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java) init { + if (tile != null) { + redstone.with(tile.redstoneControl::redstoneSetting) + } + val container: Container = tile?.container ?: SimpleContainer(BatteryBankBlockEntity.CAPACITY) powerLevel = LevelGaugeWidget(this, tile?.getCapability(MatteryCapability.ENERGY)?.orNull()) From 6b97e050c6f3b9985246ded01d8a2aad6b2ad8da Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 30 Jan 2023 23:57:45 +0700 Subject: [PATCH 0164/1199] fix phantom attractor physics model --- .../ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt index d0081b8ab..f6adab820 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt @@ -88,7 +88,7 @@ class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of(Material.METAL } } - private val shapes = getShapeForEachState(rotationProperty) { + private val shapes = getShapeForEachState(listOf(rotationProperty, BlockStateProperties.DOUBLE_BLOCK_HALF)) { val shape = when (it[BlockStateProperties.DOUBLE_BLOCK_HALF]!!) { DoubleBlockHalf.UPPER -> BlockShapes.PHANTOM_ATTRACTOR_TOP.moveY(-1.0) DoubleBlockHalf.LOWER -> BlockShapes.PHANTOM_ATTRACTOR_BOTTOM From ae75a05e649203ce147f25966133b8e8f09db903 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Mon, 30 Jan 2023 23:03:04 +0600 Subject: [PATCH 0165/1199] Fix funny z-fighting on holo signs --- .../models/block/holo_sign.json | 99 +++++++++--------- .../textures/block/holo_sign.png | Bin 418 -> 424 bytes 2 files changed, 50 insertions(+), 49 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/holo_sign.json b/src/main/resources/assets/overdrive_that_matters/models/block/holo_sign.json index 8af9b0feb..fb314ebd6 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/holo_sign.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/holo_sign.json @@ -1,6 +1,7 @@ { + "credit": "Made with Blockbench", "parent": "block/cube_all", - "render_type": "translucent", + "render_type": "translucent", "textures": { "0": "overdrive_that_matters:block/holo_sign", "particle": "overdrive_that_matters:block/holo_sign" @@ -73,80 +74,80 @@ }, { "name": "light", - "from": [1, 14, 10], - "to": [2, 15, 10], + "from": [14, 14, 9.99], + "to": [15, 15, 9.99], "faces": { - "north": {"uv": [2, 12.5, 2.5, 13], "texture": "#0", "forge_data": {"block_light": 15}}, - "east": {"uv": [0, 0, 0, 0.5], "texture": "#0", "forge_data": {"block_light": 15}}, - "south": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"}, - "west": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, - "up": {"uv": [0, 0, 0.5, 0], "texture": "#missing"}, - "down": {"uv": [0, 0, 0.5, 0], "texture": "#missing"} + "north": {"uv": [8.5, 8.5, 9, 9], "texture": "#0", "forge_data": {"block_light": 15}}, + "east": {"uv": [0, 0, 0, 16], "texture": "#missing"}, + "south": {"uv": [0, 0, 16, 16], "texture": "#missing"}, + "west": {"uv": [0, 0, 0, 16], "texture": "#missing"}, + "up": {"uv": [0, 0, 16, 0], "texture": "#missing"}, + "down": {"uv": [0, 0, 16, 0], "texture": "#missing"} } }, { "name": "light", - "from": [1, 1, 10], - "to": [2, 2, 10], + "from": [1, 14, 9.99], + "to": [2, 15, 9.99], "faces": { - "north": {"uv": [2, 12.5, 2.5, 13], "texture": "#0", "forge_data": {"block_light": 15}}, - "east": {"uv": [0, 0, 0, 0.5], "texture": "#0", "forge_data": {"block_light": 15}}, - "south": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"}, - "west": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, - "up": {"uv": [0, 0, 0.5, 0], "texture": "#missing"}, - "down": {"uv": [0, 0, 0.5, 0], "texture": "#missing"} + "north": {"uv": [15, 8.5, 15.5, 9], "texture": "#0", "forge_data": {"block_light": 15}}, + "east": {"uv": [0, 0, 0, 16], "texture": "#missing"}, + "south": {"uv": [0, 0, 16, 16], "texture": "#missing"}, + "west": {"uv": [0, 0, 0, 16], "texture": "#missing"}, + "up": {"uv": [0, 0, 16, 0], "texture": "#missing"}, + "down": {"uv": [0, 0, 16, 0], "texture": "#missing"} } }, { "name": "light", - "from": [14, 1, 10], - "to": [15, 2, 10], + "from": [1, 1, 9.99], + "to": [2, 2, 9.99], "faces": { - "north": {"uv": [2, 12.5, 2.5, 13], "texture": "#0", "forge_data": {"block_light": 15}}, - "east": {"uv": [0, 0, 0, 0.5], "texture": "#0", "forge_data": {"block_light": 15}}, - "south": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"}, - "west": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, - "up": {"uv": [0, 0, 0.5, 0], "texture": "#missing"}, - "down": {"uv": [0, 0, 0.5, 0], "texture": "#missing"} + "north": {"uv": [15, 15, 15.5, 15.5], "texture": "#0", "forge_data": {"block_light": 15}}, + "east": {"uv": [0, 0, 0, 16], "texture": "#missing"}, + "south": {"uv": [0, 0, 16, 16], "texture": "#missing"}, + "west": {"uv": [0, 0, 0, 16], "texture": "#missing"}, + "up": {"uv": [0, 0, 16, 0], "texture": "#missing"}, + "down": {"uv": [0, 0, 16, 0], "texture": "#missing"} } }, { "name": "light", - "from": [14, 14, 10], - "to": [15, 15, 10], + "from": [14, 1, 9.99], + "to": [15, 2, 9.99], "faces": { - "north": {"uv": [2, 12.5, 2.5, 13], "texture": "#0", "forge_data": {"block_light": 15}}, - "east": {"uv": [0, 0, 0, 0.5], "texture": "#0", "forge_data": {"block_light": 15}}, - "south": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"}, - "west": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, - "up": {"uv": [0, 0, 0.5, 0], "texture": "#missing"}, - "down": {"uv": [0, 0, 0.5, 0], "texture": "#missing"} + "north": {"uv": [8.5, 15, 9, 15.5], "texture": "#0", "forge_data": {"block_light": 15}}, + "east": {"uv": [0, 0, 0, 16], "texture": "#missing"}, + "south": {"uv": [0, 0, 16, 16], "texture": "#missing"}, + "west": {"uv": [0, 0, 0, 16], "texture": "#missing"}, + "up": {"uv": [0, 0, 16, 0], "texture": "#missing"}, + "down": {"uv": [0, 0, 16, 0], "texture": "#missing"} } }, { "name": "light", - "from": [14, 6, 9], - "to": [14, 10, 10], + "from": [2.01, 6, 9], + "to": [2.01, 10, 10], "faces": { - "north": {"uv": [0, 0, 0, 2], "texture": "#missing"}, - "east": {"uv": [0, 0, 0.5, 2], "texture": "#missing"}, - "south": {"uv": [0, 0, 0, 2], "texture": "#missing"}, - "west": {"uv": [2, 13, 2.5, 15], "texture": "#0", "forge_data": {"block_light": 15}}, - "up": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, - "down": {"uv": [0, 0, 0, 0.5], "texture": "#missing"} + "north": {"uv": [0, 0, 0, 4], "texture": "#missing"}, + "east": {"uv": [1.5, 13, 2, 15], "texture": "#0", "forge_data": {"block_light": 15}}, + "south": {"uv": [0, 0, 0, 4], "texture": "#missing"}, + "west": {"uv": [0, 0, 1, 4], "texture": "#missing"}, + "up": {"uv": [0, 0, 0, 1], "texture": "#missing"}, + "down": {"uv": [0, 0, 0, 1], "texture": "#missing"} } }, { "name": "light", - "from": [2, 6, 9], - "to": [2, 10, 10], + "from": [13.99, 6, 9], + "to": [13.99, 10, 10], "faces": { - "north": {"uv": [0, 0, 0, 2], "texture": "#missing"}, - "east": {"uv": [2, 13, 2.5, 15], "texture": "#0", "forge_data": {"block_light": 15}}, - "south": {"uv": [0, 0, 0, 2], "texture": "#missing"}, - "west": {"uv": [2, 13, 2.5, 15], "texture": "#0", "forge_data": {"block_light": 15}}, - "up": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, - "down": {"uv": [0, 0, 0, 0.5], "texture": "#missing"} + "north": {"uv": [0, 0, 0, 4], "texture": "#missing"}, + "east": {"uv": [0, 0, 1, 4], "texture": "#missing"}, + "south": {"uv": [0, 0, 0, 4], "texture": "#missing"}, + "west": {"uv": [1.5, 13, 2, 15], "texture": "#0", "forge_data": {"block_light": 15}}, + "up": {"uv": [0, 0, 0, 1], "texture": "#missing"}, + "down": {"uv": [0, 0, 0, 1], "texture": "#missing"} } } ], diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/holo_sign.png b/src/main/resources/assets/overdrive_that_matters/textures/block/holo_sign.png index 1100a2d1bbb7608b6c5d8195f46b14d808dfcdd9..8e3d643a89386d032f9f4d0346dc4ad1d521e269 100644 GIT binary patch delta 318 zcmV-E0m1&F1E>R#RTlr?Nfs6se}8|6hll^z000001@_!Sk!vDi&7W@&xOwdHLR~e-kK!!s?Nc<^Xc#e27U|R&x z8Gb{$j`D27bFDEbX?Po%QdG#rH4VijC#$uEeq?$ zuH#h4x~XCPzHZ@nLZvT20v`;^jwjMfcpRmB$qVik{%PS4a`Zrp1@A2|K%XNgXD z0P{&iK~y+Tol*%BgD?o>h_TK8AKYDnPSjL8-5CkT0udsj=Ecn^%oMgN^x`m~!Y&7> zHcu7sreg33^FkCu`T!3C&ILe3;mJ@!#f#tsgPBl`?x@mBkw6WXgpfQbLqv{5GT=)R z7|ggMU3+=9;dQ8g2BRyea3pl>giDLm0-=&XEzED1q-*=laGrkiFesZ0>S5I9jLWjH zZtOa5wXK^L)*tH@emhj!2}t0BVcGsf(!V204!BnMrA0i*-s7JZ7+}nilk_FM15jZc z%=D7^my|O?t#y5+F@s25+dGXJP+@Ji6&?vcv;gA<(r)7yt$hHYr4^*(<&eDq0000< KMNUMnLSTZHOO2!e From 9f58bb87367b940d706e6756b542a6eec55274a9 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 31 Jan 2023 00:15:50 +0700 Subject: [PATCH 0166/1199] Fix using wrong rotation in physical models --- .../ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt | 4 +--- .../ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt | 4 +--- .../ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt | 2 +- .../dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt | 2 +- .../ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt | 2 +- .../dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt | 2 +- .../ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt | 2 +- .../ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt | 2 +- .../ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt | 2 +- .../ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt | 2 +- .../ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt | 2 +- .../mc/otm/block/storage/StoragePowerSupplierBlock.kt | 2 +- .../dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt | 2 +- .../ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt | 2 +- .../ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt | 2 +- .../ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt | 2 +- 16 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt index 4cb0533ff..79e7deaf1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt @@ -17,9 +17,7 @@ class EngineBlock : RotatableMatteryBlock(Properties.of(Material.METAL, DyeColor return BlockRotationFreedom.TWO } - private val shapes = getShapeForEachState { - BlockShapes.ENGINE.rotateFromNorth(it[rotationProperty]).computeShape() - } + private val shapes = getShapeForEachState { BlockShapes.ENGINE.rotateFromNorth(it[rotationProperty]).computeShape() } override fun getShape( p_60555_: BlockState, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt index c5c275f34..abd308ba9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt @@ -22,9 +22,7 @@ class HoloSignBlock : RotatableMatteryBlock(), EntityBlock { return HoloSignBlockEntity(p_153215_, p_153216_) } - private val shapes = getShapeForEachState { - BlockShapes.HOLO_SIGN.rotateFromNorth(it[rotationProperty]).computeShape() - } + private val shapes = getShapeForEachState { BlockShapes.HOLO_SIGN.rotateFromNorth(it[rotationProperty]).computeShape() } override fun getShape( pState: BlockState, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt index c4c189ff7..6cad2f412 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt @@ -53,7 +53,7 @@ class MatterBottlerBlock : RotatableMatteryBlock(), EntityBlock { .setValue(SLOT_PROPERTIES[2], false) } - private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.MATTER_BOTTLER.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.MATTER_BOTTLER.rotateFromNorth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt index 02194b695..0d7a7a886 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt @@ -47,7 +47,7 @@ class MatterDecomposerBlock : RotatableMatteryBlock(), EntityBlock { builder.add(WorkerState.WORKER_STATE) } - private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.MATTER_DECOMPOSER.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.MATTER_DECOMPOSER.rotateFromNorth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt index b74db3c47..673522d9a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt @@ -43,7 +43,7 @@ class MatterRecyclerBlock : RotatableMatteryBlock(), EntityBlock { return BlockEntityTicker { _, _, _, tile -> if (tile is MatterRecyclerBlockEntity) tile.tick() } } - private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.MATTER_RECYCLER.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.MATTER_RECYCLER.rotateFromNorth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt index 2bdd286e8..b190c8e4d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt @@ -43,7 +43,7 @@ class MatterReplicatorBlock : RotatableMatteryBlock(), EntityBlock { builder.add(WorkerState.WORKER_STATE) } - private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.MATTER_REPLICATOR.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.MATTER_REPLICATOR.rotateFromNorth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt index b810622e6..370c77b05 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt @@ -43,7 +43,7 @@ class MatterScannerBlock : RotatableMatteryBlock(), EntityBlock { builder.add(WorkerState.WORKER_STATE) } - private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.MATTER_SCANNER.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.MATTER_SCANNER.rotateFromNorth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt index 7764393b5..2a62149c4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt @@ -59,7 +59,7 @@ class PatternStorageBlock : RotatableMatteryBlock(), EntityBlock { super.onRemove(oldBlockState, level, blockPos, newBlockState, movedByPiston) } - private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.PATTERN_STORAGE.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.PATTERN_STORAGE.rotateFromNorth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt index 6d7897ee7..cd032b99a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt @@ -51,7 +51,7 @@ class DriveRackBlock : RotatableMatteryBlock(), EntityBlock { MatteryPoweredBlockEntity.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) } - private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.DRIVE_RACK.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.DRIVE_RACK.rotateFromNorth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt index a0294517c..d0569066c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt @@ -66,7 +66,7 @@ class DriveViewerBlock : RotatableMatteryBlock(), EntityBlock { return super.getStateForPlacement(context)!!.setValue(DRIVE_PRESENT, false) } - private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.DRIVE_VIEWER.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.DRIVE_VIEWER.rotateFromNorth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt index 9821eae26..d008bcdfe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt @@ -51,7 +51,7 @@ class ItemMonitorBlock : RotatableMatteryBlock(), EntityBlock { MatteryPoweredBlockEntity.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) } - private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.ITEM_MONITOR.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.ITEM_MONITOR.rotateFromNorth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt index ff739647c..48e84f67b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt @@ -51,7 +51,7 @@ class StoragePowerSupplierBlock : RotatableMatteryBlock(), EntityBlock { MatteryPoweredBlockEntity.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) } - private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.STORAGE_POWER_SUPPLIER.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.STORAGE_POWER_SUPPLIER.rotateFromNorth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt index bdd1f6137..c6a2a7517 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt @@ -97,7 +97,7 @@ class ChemicalGeneratorBlock : RotatableMatteryBlock(), EntityBlock { } } - private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.CHEMICAL_GENERATOR.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.CHEMICAL_GENERATOR.rotateFromNorth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt index a525a00ba..f6aa71efe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt @@ -38,7 +38,7 @@ class EnergyServoBlock : RotatableMatteryBlock(Properties.of(Material.METAL, Mat return null } - private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.ENERGY_SERVO.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.ENERGY_SERVO.rotateFromNorth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt index f6adab820..694654e12 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt @@ -94,7 +94,7 @@ class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of(Material.METAL DoubleBlockHalf.LOWER -> BlockShapes.PHANTOM_ATTRACTOR_BOTTOM } - shape.rotateFromSouth(it[rotationProperty]).computeShape() + shape.rotateFromNorth(it[rotationProperty]).computeShape() } override fun getShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt index f752d0df0..341adcadb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt @@ -57,7 +57,7 @@ class PlatePressBlock(properties: Properties = DEFAULT_PROPERTIES) : RotatableMa MatteryWorkerBlockEntity.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) } - private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.PLATE_PRESS_IDLE.rotateFromSouth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.PLATE_PRESS_IDLE.rotateFromNorth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( From e35a3aaf801083ec99987c9b4bbb61ef56b836d5 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 31 Jan 2023 00:21:57 +0700 Subject: [PATCH 0167/1199] daym --- .../mc/otm/block/entity/tech/BatteryBankBlockEntity.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index a4dec5cfe..f348fdd9b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -289,11 +289,11 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte private val consumers = object : BESubscribeList(this@BatteryBankBlockEntity, ForgeCapabilities.ENERGY) { override fun test(t: Direction): Boolean { - return -blockState.facingOne == t + return blockState.facingOne == t } } - fun checkSurroundings() = consumers.update((-blockState.facingOne)::equals) + fun checkSurroundings() = consumers.update(blockState.facingOne::equals) fun tick() { if (redstoneControl.isBlockedByRedstone) From 2b9920c8ac84af64f786340ba1b7c50eb11b5397 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 31 Jan 2023 00:23:24 +0700 Subject: [PATCH 0168/1199] make energy servo be fully controlled by redstone --- .../mc/otm/block/entity/tech/EnergyServoBlockEntity.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt index 85d942161..aa6fcbdd5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt @@ -68,10 +68,16 @@ class EnergyServoBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte } override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { + if (redstoneControl.isBlockedByRedstone) + return Decimal.ZERO + return container[SLOT_DISCHARGE].energy?.extractEnergy(howMuch, simulate) ?: Decimal.ZERO } override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { + if (redstoneControl.isBlockedByRedstone) + return Decimal.ZERO + return container[SLOT_CHARGE].energy?.receiveEnergy(howMuch, simulate) ?: Decimal.ZERO } From 5ee05f3a6b4c87de4f723b1765e6dcf7a7eac6c8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 31 Jan 2023 00:26:05 +0700 Subject: [PATCH 0169/1199] Return zero instead of throwing exception --- .../mc/otm/capability/energy/IMatteryEnergyStorage.kt | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt index 9f3853a0c..799f0a8ab 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt @@ -52,9 +52,7 @@ interface IMatteryEnergyStorage : IEnergyStorage { * @return energy extracted */ fun extractEnergyChecked(howMuch: Decimal, simulate: Boolean): Decimal { - require(!howMuch.isNegative) { "Negative amount of energy: $howMuch" } - - if (!energyFlow.output) + if (howMuch.isNegative || !energyFlow.output) return Decimal.ZERO return extractEnergy(howMuch, simulate) @@ -86,9 +84,7 @@ interface IMatteryEnergyStorage : IEnergyStorage { * @return energy extracted */ fun receiveEnergyChecked(howMuch: Decimal, simulate: Boolean): Decimal { - require(!howMuch.isNegative) { "Negative amount of energy: $howMuch" } - - if (!energyFlow.input) + if (howMuch.isNegative || !energyFlow.input) return Decimal.ZERO return receiveEnergy(howMuch, simulate) From c5c2a3a3cbab541c3873b1a52a431c89668bde72 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 31 Jan 2023 00:27:04 +0700 Subject: [PATCH 0170/1199] Update docs --- .../mc/otm/capability/energy/IMatteryEnergyStorage.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt index 799f0a8ab..e83f907a4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt @@ -36,7 +36,7 @@ interface IMatteryEnergyStorage : IEnergyStorage { * Therefore, if you want/need to obey [energyFlow], use [extractEnergyChecked] * * General contracts: - * * Negative values are not allowed, failing to comply with this contract will result in undefined behavior (worst case) or exception (best case) + * * Negative values are not allowed, failing to comply with this contract will result in undefined behavior in worst case or nothing in best case * * Returned value CAN NOT be bigger than requested [howMuch], implementations failing to obey this contract will cause undefined behavior in upstream code. * Upstream code SHOULD NOT check for this contract. * @@ -68,7 +68,7 @@ interface IMatteryEnergyStorage : IEnergyStorage { * Therefore, if you want/need to obey [energyFlow], use [receiveEnergyChecked] * * General contracts: - * * Negative values are not allowed, failing to comply with this contract will result in undefined behavior (worst case) or exception (best case) + * * Negative values are not allowed, failing to comply with this contract will result in undefined behavior in worst case or nothing in best case * * Returned value CAN NOT be bigger than requested [howMuch], implementations failing to obey this contract will cause undefined behavior in upstream code. * Upstream code SHOULD NOT check for this contract. * From 99e1f94fb51373e04f63a6966434671f35e3dd9d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 31 Jan 2023 00:30:59 +0700 Subject: [PATCH 0171/1199] docs --- .../kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt | 6 +++++- .../ru/dbotthepony/mc/otm/core/math/BlockRotationFreedom.kt | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt index c484b2441..cefba788a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt @@ -26,7 +26,11 @@ operator fun BlockPos.plus(other: BlockRotation): BlockPos { } /** - * [top] clarifies about block's top facing direction, NOT bottom + * Represents unique block orientation in space, by providing [front] and [top] directions + * + * Allows to get relative faces through [left], [right], [bottom] and [back] + * + * @see BlockRotationFreedom */ enum class BlockRotation( val front: Direction, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotationFreedom.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotationFreedom.kt index cb479a34d..efe3ef08a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotationFreedom.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotationFreedom.kt @@ -14,6 +14,9 @@ internal inline val BlockState.facingOne: Direction get() = this[BlockRotationFr internal inline val BlockState.facingTwo: Direction get() = this[BlockRotationFreedom.TWO.property].front internal inline val BlockState.facingThree: Direction get() = this[BlockRotationFreedom.THREE.property].front +/** + * Controls the rotational freedom of block in space, employing [property] and [of] to get valid value from set of possible values + */ enum class BlockRotationFreedom(vararg values: BlockRotation) { ONE( BlockRotation.NORTH, From ab99eb799481de38e66b24759287ff50507b2ad7 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 31 Jan 2023 00:40:27 +0700 Subject: [PATCH 0172/1199] Fix broken holo sign not retaining redstone control settings --- .../kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index fc3ecc2ff..8bb1a3831 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -144,7 +144,7 @@ fun addLootTables(lootTables: LootTables) { REDSTONE_CONTROL_KEY, ) - lootTables.tile(MBlocks.HOLO_SIGN, HoloSignBlockEntity.TEXT_KEY) + lootTables.tile(MBlocks.HOLO_SIGN, HoloSignBlockEntity.TEXT_KEY, HoloSignBlockEntity.REDSTONE_CONTROL_KEY) lootTables.dropsSelf(MBlocks.STORAGE_CABLE) lootTables.poweredTile(MBlocks.ANDROID_STATION) From b5510448677be6fbaa00ee09941d768f69c9f0f9 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 31 Jan 2023 11:36:57 +0700 Subject: [PATCH 0173/1199] Fix pattern_panel_tabs dimensions were wrong in code --- .../ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt index c8fcecade..8a10a2134 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt @@ -7,7 +7,7 @@ object WidgetLocation { val WIDGETS_18 = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets_18.png") val MISC = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/misc.png"), 64f, 64f) - val PATTERN_PANEL_TABS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/pattern_panel_tabs.png"), 64f, 32f) + val PATTERN_PANEL_TABS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/pattern_panel_tabs.png"), 60f, 23f) val CHECKBOX = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/checkbox.png"), 30f, 60f) val PROGRESS_ARROWS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/progress_arrows.png"), 22f, 31f) From 6390857959dcb716035e536d6cf61414c74fc596 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 31 Jan 2023 13:45:08 +0700 Subject: [PATCH 0174/1199] Split widgets_18 to several files --- .../mc/otm/client/render/WidgetLocation.kt | 5 +- .../mc/otm/client/render/Widgets18.kt | 71 +++++++++--------- .../textures/gui/widgets/large_button.png | Bin 0 -> 663 bytes .../textures/gui/widgets/large_button.xcf | Bin 0 -> 3043 bytes .../textures/gui/widgets/misc18.png | Bin 0 -> 815 bytes .../textures/gui/widgets/misc18.xcf | Bin 0 -> 3113 bytes .../textures/gui/widgets/slot_backgrounds.png | Bin 0 -> 995 bytes .../textures/gui/widgets/slot_backgrounds.xcf | Bin 0 -> 3973 bytes .../textures/gui/widgets/storage_controls.png | Bin 0 -> 711 bytes .../textures/gui/widgets/storage_controls.xcf | Bin 0 -> 3189 bytes .../textures/gui/widgets_18.png | Bin 1868 -> 0 bytes .../textures/gui/widgets_18.xcf | Bin 13980 -> 0 bytes 12 files changed, 41 insertions(+), 35 deletions(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/large_button.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/large_button.xcf create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/misc18.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/misc18.xcf create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/slot_backgrounds.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/slot_backgrounds.xcf create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/storage_controls.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/storage_controls.xcf delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets_18.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets_18.xcf diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt index 8a10a2134..44502c2a7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt @@ -4,7 +4,10 @@ import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.OverdriveThatMatters object WidgetLocation { - val WIDGETS_18 = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets_18.png") + val LARGE_BUTTON = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/large_button.png"), 72f, 18f) + val STORAGE_CONTROLS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/storage_controls.png"), 90f, 18f) + val MISC_18 = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/misc_18.png"), 72f, 72f) + val SLOT_BACKGROUNDS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/slot_backgrounds.png"), 72f, 72f) val MISC = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/misc.png"), 64f, 64f) val PATTERN_PANEL_TABS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/pattern_panel_tabs.png"), 60f, 23f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt index 1acecb411..540fe2035 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt @@ -5,47 +5,50 @@ private fun makeButton(grid: GridAtlas): StretchingRectangleElement { val y = grid.currentY return StretchingRectangleElement( - topLeft = WidgetLocation.WIDGETS_18.sprite(x, y, 2f, 2f, grid.atlasWidth, grid.atlasHeight), - topRight = WidgetLocation.WIDGETS_18.sprite(x + 16f, y, 2f, 2f, grid.atlasWidth, grid.atlasHeight), - bottomLeft = WidgetLocation.WIDGETS_18.sprite(x, y + 16f, 2f, 2f, grid.atlasWidth, grid.atlasHeight), - bottomRight = WidgetLocation.WIDGETS_18.sprite(x + 16f, y + 16f, 2f, 2f, grid.atlasWidth, grid.atlasHeight), - middle = WidgetLocation.WIDGETS_18.sprite(x + 2f, y + 2f, 14f, 14f, grid.atlasWidth, grid.atlasHeight), - top = WidgetLocation.WIDGETS_18.sprite(x + 2f, y, 14f, 2f, grid.atlasWidth, grid.atlasHeight), - left = WidgetLocation.WIDGETS_18.sprite(x, y + 2f, 2f, 14f, grid.atlasWidth, grid.atlasHeight), - right = WidgetLocation.WIDGETS_18.sprite(x + 16f, y + 2f, 2f, 14f, grid.atlasWidth, grid.atlasHeight), - bottom = WidgetLocation.WIDGETS_18.sprite(x + 2f, y + 16f, 14f, 2f, grid.atlasWidth, grid.atlasHeight), + topLeft = grid.texture.sprite(x, y, 2f, 2f, grid.atlasWidth, grid.atlasHeight), + topRight = grid.texture.sprite(x + 16f, y, 2f, 2f, grid.atlasWidth, grid.atlasHeight), + bottomLeft = grid.texture.sprite(x, y + 16f, 2f, 2f, grid.atlasWidth, grid.atlasHeight), + bottomRight = grid.texture.sprite(x + 16f, y + 16f, 2f, 2f, grid.atlasWidth, grid.atlasHeight), + middle = grid.texture.sprite(x + 2f, y + 2f, 14f, 14f, grid.atlasWidth, grid.atlasHeight), + top = grid.texture.sprite(x + 2f, y, 14f, 2f, grid.atlasWidth, grid.atlasHeight), + left = grid.texture.sprite(x, y + 2f, 2f, 14f, grid.atlasWidth, grid.atlasHeight), + right = grid.texture.sprite(x + 16f, y + 2f, 2f, 14f, grid.atlasWidth, grid.atlasHeight), + bottom = grid.texture.sprite(x + 2f, y + 16f, 14f, 2f, grid.atlasWidth, grid.atlasHeight), ) } object Widgets18 { - val GRID = GridAtlas(WidgetLocation.WIDGETS_18, 18f, 18f) + private val buttonGrids = WidgetLocation.LARGE_BUTTON.grid(rows = 1, columns = 4) - val BUTTON_IDLE_STRETCHABLE = makeButton(GRID) - val BUTTON_IDLE = GRID.next() - val BUTTON_HOVERED_STRETCHABLE = makeButton(GRID) - val BUTTON_HOVERED = GRID.next() - val BUTTON_PRESSED_STRETCHABLE = makeButton(GRID) - val BUTTON_PRESSED = GRID.next() - val ARROW_DOWN = GRID.next() - val AZ = GRID.next() - val COUNT = GRID.next() - val COLON = GRID.next() - val C = GRID.next() - val CROSS = GRID.next() - val FORWARD_SLASH = GRID.next() - val BATTERY_SLOT_BACKGROUND = GRID.next() - val PATTERN_SLOT_BACKGROUND = GRID.next() - val EQUIPMENT_BATTERY_SLOT_BACKGROUND = GRID.next() - val MATTER_CAPACITOR_SLOT_BACKGROUND = GRID.next() - val RETURN_ARROW_LEFT = GRID.next() + val BUTTON_IDLE_STRETCHABLE = makeButton(buttonGrids) + val BUTTON_IDLE = buttonGrids.next() + val BUTTON_HOVERED_STRETCHABLE = makeButton(buttonGrids) + val BUTTON_HOVERED = buttonGrids.next() + val BUTTON_PRESSED_STRETCHABLE = makeButton(buttonGrids) + val BUTTON_PRESSED = buttonGrids.next() + val BUTTON_DISABLED_STRETCHABLE = makeButton(buttonGrids) + val BUTTON_DISABLED = buttonGrids.next() - init { - GRID.jump() - } + private val storageGrid = WidgetLocation.STORAGE_CONTROLS.grid(rows = 1, columns = 5) + val ARROW_DOWN = storageGrid.next() + val AZ = storageGrid.next() + val COUNT = storageGrid.next() + val COLON = storageGrid.next() + val C = storageGrid.next() - val BUTTON_DISABLED_STRETCHABLE = makeButton(GRID) - val BUTTON_DISABLED = GRID.next() - val COOLDOWN = GRID.next() + private val miscGrid = WidgetLocation.MISC_18.grid(4, 4) + + val COOLDOWN = miscGrid.next() + val CROSS = miscGrid.next() + val FORWARD_SLASH = miscGrid.next() + val RETURN_ARROW_LEFT = miscGrid.next() + + private val slotBgGrid = WidgetLocation.SLOT_BACKGROUNDS.grid(4, 4) + + val BATTERY_SLOT_BACKGROUND = slotBgGrid.next() + val EQUIPMENT_BATTERY_SLOT_BACKGROUND = slotBgGrid.next() + val PATTERN_SLOT_BACKGROUND = slotBgGrid.next() + val MATTER_CAPACITOR_SLOT_BACKGROUND = slotBgGrid.next() private val redstoneGrid = WidgetLocation.REDSTONE_CONTROLS.grid(rows = 1, columns = 3) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/large_button.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/large_button.png new file mode 100644 index 0000000000000000000000000000000000000000..dbacdc975fd42f0b8d7c7cdb928d12c6dedffd5b GIT binary patch literal 663 zcmV;I0%-k-P)EX>4Tx04R}tkv&MmP!xqvQ$>+V2Rn#}WQa}{L`58>ibb$c+6t{Yn7s54nlvOS zE{=k0!NH%!s)LKOt`4q(Aov5~>f)s6A|>9J6k5c1;qgAsyXWxUeSpxYFwN?k05sh; zQ}LLX&8><(uLxiSVMvfWLS5n{2}!Ab|SlBp3-6HBV5Q@)V( zSmnIMS*z4o>z@3Dp}fA5<~prm#Ib|~k`SSwhB7L!5v5%x#X^eCV?O>N*PkSpLas6x zITlcb2HEw4|H1FsT7{`eFDVoQx?ddUV-)Dw1)6oo`95}><_Qpd2CnqBzuEw1KS{5* zHR%WlZvz+CZB5w&E_Z;zCqp)6R|?V+3I*W(jJ_!c4BP^JYu?;i=Qw=;GBm5@8{ps& z7%Nity3f0NJLmRqPiuZZxTA8z1ijBF00006VoOIv0RI600RN!9r;`8x010qNS#tmY z3ljhU3ljkVnw%H_000McNliru=K&uCDJ+8+v^M|%0F+5YK~z}7?U=C*#2^eszfbJJ z6o>^t%#2_G#1u?Iid2boDIDvr`LA>HgdUYG05%NR+eBkV&e_D{03gQrN;1YUc~ol+ z03aeJpVfPRfdIgJuac~_E^{eG<*Bt^<`9C)Gv_q*d_W#yAO>O}24WxvVju=$ xAi_Wl#6Z8tecQ^l+_!Qq_pSV29sv(#j~w0JD^D^xh9dv~002ovPDHLkV1mKP8_WOz literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/large_button.xcf b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/large_button.xcf new file mode 100644 index 0000000000000000000000000000000000000000..c8ec6176243d42a6e9b8df345f6460bd0f4b6594 GIT binary patch literal 3043 zcmds2O=}ZD7@mzyV^_o4_2VQmeiRZUm_2Af5JC3f*@K?be5?y;QnFFnlWDIW^duta zFYvGwTS~$7>T&k!&+weEKJV-fPRiOtAQ18{&pgk(@8q3i^6akXZ*B9PMw`E_Iu1iT z2W%3EPry207#OYs7oUA(jDWZXtN^RPja1XR>%cGIiig$}f2;1bDqi1jBE_iwy%Y>~ zJ1rjcI)1ZkmfBvU*Xi|nNm8ZnZPs~JUQQY1&5W|cF{nC(u@(n;k_ z*B@}d+j!jy=o7tmJ7^8KT(9XwPA{hKtcCF^nXJ(7K&*aEcd;-0iZm!UQ0EI-O=<- zO`DqLn!cpz%bG4~+JdJ29sv{ufcB>T8>t4dd!%Co_^zgPn;@+sx33gf9ToLOby#SAxQ#fM|&x^tolT3gI^mv^&wbcX+qpX{`8j#EQ%Btke&*i^Nq+$8 zGjx&sNgkq@)t{;Nk|t;~QVM*=pM~EUHKYoER34Ub;ZL{te(cVTCTMNB(w|GZS%yC! z{MVnS(NK({J$iP^_k1W0Bl!YcB$q0K%<9q$szJhLQ=6Z0sX5H3A!UA6d7D`^gT=Mt W%W;jdIne~It(uK{XjwNSm;MC^Q|e0q literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/misc18.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/misc18.png new file mode 100644 index 0000000000000000000000000000000000000000..9a54260fbf9ee9815e6e266c7c3e632276a8b038 GIT binary patch literal 815 zcmV+~1JL}5P)EX>4Tx04R}tkv&MmP!xqvQ$>+V2Rn#}WQa}{L`58>ibb$c+6t{Yn7s54nlvOS zE{=k0!NH%!s)LKOt`4q(Aov5~>f)s6A|>9J6k5c1;qgAsyXWxUeSpxYFwN?k05sh; zQ}LLX&8><(uLxiSVMvfWLS5n{2}!Ab|SlBp3-6HBV5Q@)V( zSmnIMS*z4o>z@3Dp}fA5<~prm#Ib|~k`SSwhB7L!5v5%x#X^eCV?O>N*PkSpLas6x zITlcb2HEw4|H1FsT7{`eFDVoQx?ddUV-)Dw1)6oo`95}><_Qpd2CnqBzuEw1KS{5* zHR%WlZvz+CZB5w&E_Z;zCqp)6R|?V+3I*W(jJ_!c4BP^JYu?;i=Qw=;GBm5@8{ps& z7%Nity3f0NJLmRqPiuZZxTA8z1ijBF00006VoOIv0RI600RN!9r;`8x010qNS#tmY z3ljhU3ljkVnw%H_000McNliru=K&uCI}p@^xMKhS0W3*GK~#9!?byi@gCGz^Q6K;R z&z+46D`|$NA<@)5RW2ML_>>{a%#IZ#9sj7Ttjtc?a{YVwVw*97tXGb%*+&=P2{z|b$#Vp_jkP@ zM#Gs2H2dbbZ}M9?tAx=zUTt@+VbL316;i9LcfNE&uufRV)Ki(b!4=(2l3HcG^JSnL zg$L?gR)w^Bnz!g%)9YfH0r%TWfL=hlY^iW`dRjS zkr`*jtdy%t7@pm`y<6@BC z7B-eP6vRk^kdxMO_UCAX@p)!(L8WTPln-Mmbf$;u&AqWWbvOpfVmU4Ex3j72vwJ~iinwx4jYwg8o z1}?$)X0^MtGTW5h&TKR@TBx?#jm~UmQC5wrEw-npwxN4#!gWG54yznkbnYCEaP zT5>)4&SmvU{ZRXACw?c#n3V&#cpA7#es2{m78szPod!}4C2l$VhQkXEmkuvFyyWn* z!-v2*-v~hAhveKG|4z!GOgyV0;J4{dxh(*`izEKBV{icojtlWWB-*q#M*pVuSA?gF zfG2!C0Qf*2$N~Y712RAeFsC2_T@o2x21?+C)XzBcn9qLf&v7^&$Mw>ADtNq$G2;;4 zx<7cDpDH;Rpjn#_oq|@M)poq9w$-lMi{Hj?zvyLq=n%^pUQBTMUB_VnrVF6WC+w%Sv{jra=tG&!gcrj-;LMQo>bp(manNEzx-L+4tyR;zuO^` zbhmBsiDl5XQTvh(rS)9!o#CeV3wZ#Xg j_V{05G;Kl~%`1(~`2`{3GHodWD4I literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/slot_backgrounds.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/slot_backgrounds.png new file mode 100644 index 0000000000000000000000000000000000000000..33348815c94a6593e190e4067a75b03fa76988e3 GIT binary patch literal 995 zcmV<9104K`P)EX>4Tx04R}tkv&MmP!xqvQ$>+V2Rn#}WQa}{L`58>ibb$c+6t{Yn7s54nlvOS zE{=k0!NH%!s)LKOt`4q(Aov5~>f)s6A|>9J6k5c1;qgAsyXWxUeSpxYFwN?k05sh; zQ}LLX&8><(uLxiSVMvfWLS5n{2}!Ab|SlBp3-6HBV5Q@)V( zSmnIMS*z4o>z@3Dp}fA5<~prm#Ib|~k`SSwhB7L!5v5%x#X^eCV?O>N*PkSpLas6x zITlcb2HEw4|H1FsT7{`eFDVoQx?ddUV-)Dw1)6oo`95}><_Qpd2CnqBzuEw1KS{5* zHR%WlZvz+CZB5w&E_Z;zCqp)6R|?V+3I*W(jJ_!c4BP^JYu?;i=Qw=;GBm5@8{ps& z7%Nity3f0NJLmRqPiuZZxTA8z1ijBF00006VoOIv0RI600RN!9r;`8x010qNS#tmY z3ljhU3ljkVnw%H_000McNliru=K&uED;j+emqGvl0pLkQK~#9!?bkg{!!Q)U@ucd| zg@G|sKZZ1&a*bR9u`x5ScjgLgh)a0j5}isJN|`!VRTs7}ImE7$*iK3-`2VCRY0_Bs zlb@dx1USDe%kuJBzkkX4m)fytIQ9zO_VXj`vL8ib(P-k=q0L(9P-pE7$GPiZP4Ber z&(RD@lh~?(#oN0vmE`?4?fA^3x?t+TZwz!Ps7iqDZg0ZttFOuz?;jqE>-l^hJUzcC zofkrc(P)xyH|ub_Svz$o%d%VuVH`+0oBjlJxl(@1d#%#B6c9a_J^jzS!ypi^i+pz& z1p3jmu(~Y5`m?Iwn1Zlau9V}Hdal#H?wLMF-*%d2k-Sc4)1%q+Z>m^b3d!H6o;^na z+VA(qYm=tuT}fxtV%;&VKc^0qQs!+dPdQCYW!|TqG>MfIl_gtNF&Ut`DppnIoBC5u z_cV!>aa~M`)m1Q4V7lHATBTUs!s#+AeA=lh^X1^k^pf|=d!)L6wHa4WumAD|{p`8} zb#2F{%$v%3Qx&u6PnyKVQMm@$Zlr8>sd6^xXP0(tJ~g7@IF~6{wFb2vSKnn;xO};H zvgNn<%rK>!@Au!Y?Sq=q{mbO%kKzKYPQhJD#T*$E!r}-~XnkL(o(!|Q9&{jJD%^oH#6@&`+YOp?mS53qm3>3 z-pcAK;nHPe{5jeyXtf$1*U{cYTVUaBtFg#q9Y3z~;|AKyJI{!?;kt?DqczcPm6)f! ziuNnowKf7+?mSp;Z!Wj@I`^O=wtv0U-G98jDZ9JdoqM-um$up)yW6{aa>;hfd+odH za>d@Ow_(0}hIv)mo6V29$@)fTr!7}kAU&RtN@4loPG?_sb~f&Bc6r9`)>e0OU)u2% zT)@e}9CPKWeN+hkhebbgr|9SJR|YwF4S*ZxypTQ54znM!pR-@GEc^idu=QUd;Mn|fG->Bf(3YHZ-SHbfY99HmE zVD`6$#{T#_vu|F1vBc>hX#zA!a$j8;n54B?d@wLW~d<~!J&jh35SwM!lCS^ zQ=kOn5<5-@kni39Wt|c5wZErY~a44-q1&0a_@l_QZs(v~JN-!?5<1~C1$~rV~Xy#~uPiUItnLZcZ6llQXLd-6jNAm`28l+fkD!j39>0CwG zqteS-w;%a3RXA5LUl*-#&ZTk%pH>8Z1>DLC5573V237E#(=VdJ>s;Yzb;<>`L{30M zLBc~>)-|I#_3%Wo236}RYf#b?6ETpB+ArtzVHUbkOoITMCw%J+loId(pP)mzNFaLb zhb1GL)Gu);7O@G05wsB^MW091igE%PMie2^2$2FIQap8}gR1qEHQJiT6EP6l2$5Pt zAJ0fPifIsF^CCowB?oLmq!D?A87PQ)?1w#?2$7aJjBKPav@s$@pU2dSa{?O16eH3Y zkpdx7Jaw#ts`ZpL+M34`F%a4qky=9^&saB#X%JxZVnm812WF?od8{~rYg(G<%B*r>hHq7}(l!dq{l;SJu_t)uW#_U*~Xpzs0C zup^viIL}U=%Iq6^f*nGAlzoo_?vUqQCT?^5d|i~=C2xyGaOl445c+>`yY;~tHmF*k zIsHxgOXF`C-{k8${V|fX4#0blhFXZ0u2}-7jb|SHnFz61Y{H$ z%oAdg2tQ$KVtG5Kd&Meqyn*1r^Fea>A0KyC^z;x88W;gWkk%d<-Jll;l7B4S!oR-% zOaVvQP)msvB+6H&jVGLfl zn1vLeXey+jIEB%XY{fDKjQIByUZbHQgD+xcM+gN3&6RTdsF@mZGbSj`b;QSq`c%>t zEEHlPUThv)M-R?$Hz3vwANtszpkwel*R~@9pY=B`|DNFJc+owf?iMKeuv?Mct0?!4 z@aY*gsKT$De$AfuwMo|Jj@2N2ADndJ1j*0iJX0P2BSw@rIOfNUH)0l4U&G(~5NxSU zQZ{##bpA2qC5E0ySmr4c*YVXz_#e^LNcfl5KT5qe$+z6`$@#~Sm*{mK+n8j`I!896 i;D5w5qu^gz|0rv&c6aJd&y&fKyhhP{um-D}HToOld^g1a literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/storage_controls.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/storage_controls.png new file mode 100644 index 0000000000000000000000000000000000000000..9346529e2d65a83ff9af3015c31308c15028e4ed GIT binary patch literal 711 zcmV;&0yzDNP)EX>4Tx04R}tkv&MmP!xqvQ$>+V2Rn#}WQa}{L`58>ibb$c+6t{Yn7s54nlvOS zE{=k0!NH%!s)LKOt`4q(Aov5~>f)s6A|>9J6k5c1;qgAsyXWxUeSpxYFwN?k05sh; zQ}LLX&8><(uLxiSVMvfWLS5n{2}!Ab|SlBp3-6HBV5Q@)V( zSmnIMS*z4o>z@3Dp}fA5<~prm#Ib|~k`SSwhB7L!5v5%x#X^eCV?O>N*PkSpLas6x zITlcb2HEw4|H1FsT7{`eFDVoQx?ddUV-)Dw1)6oo`95}><_Qpd2CnqBzuEw1KS{5* zHR%WlZvz+CZB5w&E_Z;zCqp)6R|?V+3I*W(jJ_!c4BP^JYu?;i=Qw=;GBm5@8{ps& z7%Nity3f0NJLmRqPiuZZxTA8z1ijBF00006VoOIv0RI600RN!9r;`8x010qNS#tmY z3ljhU3ljkVnw%H_000McNliru=K&uCI}Nvm)Vcrw0K`c|K~z}7?U&sSfFKBkv-wy& zKJQgmZpZ1polzVdjmQH#p%V!vbFt%6lS8Q;aS`qyVitEP?g& z%3L{)(l)xjUTbN}SDLJuqKW%M_NOZ%-y7}TtUL;aC$l3GY3d$*WX_0Ctunk@$K9-> z2KCM%q9iX*Hhi}0u#E8Tsb@@<@6^U`2-<3uY4o4E?#+99bXgUx@e|Gm*7I`f!)hTT tCTnwAUB_QYQ4Ki`EKYxL1P1_sY3z@Uy-Oc@?(F~o002ovPDHLkV1kVaI*9-P literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/storage_controls.xcf b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/storage_controls.xcf new file mode 100644 index 0000000000000000000000000000000000000000..2e3d11ece63bb479b22eae7e67d46b6a2ed8e80f GIT binary patch literal 3189 zcmd5;&ubGw6rLpABu!dd>yML#)mCVQKq6T1Py|oCSnwoxsNJSX475o}sOnkJ zJa`a9Ja`k4LLpR}A}r!@a?^jMv>m^1cSokO)e=1HOTT$<-kW)y_vY=}tyCA6?3H5K zewZ&51n4d>L;>^)I1R*N7^pl8OvN!wa2Vw<#NiB(zWG830>pJaKpHq7$nYgFbOJMaAp<1o*K zmTKA@i0|a4Y|de0cKhO7b)LZ z!{}$8dV1~!D3dM$TE1Y&8AG-WIcvy$hTLz+1CV*sQvfLi@PE+%T?r#0N?%v2xa<{XFaTD#w zD?Yhpch>R6v4$?xf~gJDcJyjemqWKTna~b=o(=2&K}}|_8*6ofp~~LY`pMv(!1sd* zeuKoldSyYzP>?>-;CsSFQKExc_+&}Ar=Xe?k#yv}xcCw?!4DIJ7F1?TAv6yNP3^&k PKZJ(wn1n)TYEt|HFMOI3 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets_18.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets_18.png deleted file mode 100644 index 765c4d40e2056b95e7c0c547fff52df4fd6a37bf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1868 zcmeHH`&ZJ568{1MW{O&?8EYlBdwsQL?fPglP<#N&iVtwh7aqAG001Kb-a8loKvtii4+8+;v&&-kPQs1%@(Lt)d0EjJ7vka*V*$YSI_vr=ywt-| zMh$5S4zpaevbL!F_KbO_vWJ+bNjxD#|KAPLI<-iAIhP?_nnPA5CQdE zhCJ+75c+-mwy449Oc%N@V#dcZMmr#!bbf8zpkBrKqU*UnGGZ!awWBBBD%~m9^cp|i zz3HZ}{C$eCF;#8te)~f!1{bK{8!lgc$RxTRnKYW@f9F5bPO^;gA)wGU2VG~gALd6C zM`le$&`-bSqYjq|Y!Ie7T$iGen`TCZX(euTLgd@s`-{zb!v#u4p|e^+wRjxwU?+ZQ zi8b`UdKhGSTx45mxZ5<$IhgoGJVw=xncdhseM3P3AC`md15qckmN6S+_5AXZy1gS0f72zdUexQ;kQm&LVA5QH=o^^^m+JAx+^e;I9>PoqA@L(5Iobq2JhfP9KJQ@?k+iOXb0{F!;S zu9226znEQ)!=nCil6Yh7s5)03XNtAO!hEh*^ApW;WYz$D>4gclMIu2CJf51O>7zKM zrKO%rqZ1RwZ{FATEZ=p|vAVUqtnG>FW@g>1g_OqOMDw>vENvp#mSYk?A{8LhGBULE zj~b0jZCP7eoAG)VOItM1`|@Rh_f4m(5+1I9#jd}mtg%d>D_o7&=rrNbaU1r#xVABK z6z5J@{T5E)H2M{!+CPmft=SyvT)GF74_^wSw|5@l@d!um#cW^Fy>}1@%J%KF&8Wki zC@%&kE2OOhUskp8a3LGHrq~^w_V(G;mYG9czmu_zcfuM5eTK90bgM=Mj+M?7r5*b? zg|t@IOiF1Q`&Z6Nqf%WXT#V`JN+?g|%Eily16Xy#(VX?c;>45lD+|RRA(Pq{#_La$ zj+H)-yU0k5s#>*)MGH6GB^>21UgMaD1QkLOR&TECv%6nNWgg6vfol>r7SG$r(mNc3 zv&`#>_NWhA+cQ@h#9hCVet2{%R}5qAHS7D4OL9);kqwnV4y%06KWQB5gv){%G33tl zt#H5ny^F~7CW`0N1}d72ZL_a9wplO*p$#USjN^X6hV|wr@9$YuH8K(1h}u2KJ!snV zT}DC1H&?R4*O){#RimsNU!J)^!)XfetFzYTf>id>%>^8q72=p6#p*4bAyvxg|d z)A}te!)}C6;-As@v?@+u3Oe@ErTz_F5hmdP(wU55?ab=3t0Q4twCOIwy+-sWf`x*H z_>#MdM(O&g%u|m{5_6a5M{0&R%shj*Cw{`Z%=t%A^o`-~yK9xbjpL`mZ*z{2Il5jW9EhtZer1n>8zn~w-*u8``pK<)%bH%o+Cua zOAe6@xn{sHm;=LZlmo7Fu%G-5@kl z`YU73{0}eb*`NG`lI4c<@LRe*Twdj?l@)6;3H{Xtt;S~NgUW1~7Y)BxaO_CtZ>`SY7l)0H1L@VR^P&zJ?}vC|2t4Q%B(o-4#RGhqk1+L?rT(WI<{&aB+@Wk z+C}i81n9tw?P=Bxq>0Dn+hxru9$>gdto|#_mARNVQxQ&qpr1o`r3@pUwSbXR2AoK# quWffOjVz+0UOS&K#a!nDZvak$a&fXEI|yT9{w*<`)h> zH+zCLjvqO4Vs^<>EU}GYO6tA)+AvK2z_3g3dqq7Y!$VsNqAL_l<$dz)0SX@V&KH z!%JRxAzTJ>nPpAiMG839QAor*@o$|(inT^0o%MSS4j}vp{O(28SuAx*9R+lh?%4yLn z4~RQi+T$4MP8EA(KVS;c!Xe-`vdkc6IB`)fK``mmIfJ+6GocxuPl;01GTuC6;z2i1omA#OH3Heu+T3&~Vp-TgZ42=s}_!;kJAT^ed%pU`3QG zs&WCaz+zQmX&(apdf-E#AE+M$`Vib<^(s0Xu}ysj3IMx=s73!ZvL1<^2y>2B75u?JrpRKB#(} zs*V^JbyxJdbpfpA3fF;t#sgw;v5pj4n~ZX=kpkUrsfdEq?u4mV0ox5yx*9UzIc`D; zgKfEx0hzE1(@4@?ryS;_n-&#=XWV@_?qqVH=Fn5XdQSA_>H=6TCvxa%4m|~io+1r$ zK{Cp{MoOUA&59@pY7RYBj0)0RkkZwV0nf>yr)aWD7J8Z!j%EW(=GG~P5@ilOHFzec zdYT6{kDdb7^P)Fj7r<(Hkw;JS=qWJt6lstTl2Pt8QUb+pRzyKi^XRE!RFLL_l&*#h zcupQYMUz#s(9^tdG#gklzfL)nDD&v4!83W)Qwgf_GU%y`Qz0?#!B zp4}ku+;#+BZHW1}fo-N0ovRIjA2$SE-5~JeHUgWz$NHdl@Vb8Kfb~n~*ItHSI*D@` zA3-hy;$h=Y>Qsiu3=rSNp{?sqW*-^V>eO9*-_$o?=aop_x+J6DJO9>(2hvV+9l$5M z{{}+;L?Vcb|1@$zkc2C9L@jXL-XNxYQYnRtoX<)wJZ9jQN3-X&sIhA#S8U&6KEaIRuYG@R~!gd5=TzLEf#$a z!52kvaas-5buA15gtU(#_#8sxxT&&c2qbx}s`o7(Ezv%j{;R3sk(CO9? zJ)NSNyZ@?M(}|rCvo+lPSsNZm!-JMSrB1T3R^zW*%IIioG(Kx{(ue$p$w?pbeI*~tPNlc!$?cmwe=yj{n@x7ZR!xn{6DP~6>?JcRqResyE&;3`hv zyz<7BH>XKN-qP|$wg)kW*e8;505?j!XBzn8j># z7CB1@cDN#18L7cEd9%(Q+K+hVmpcJLZ9M-xD&pk< zA3-kh?TR5-!pJVY?A^n z7?Y@_;0&9y?bF8Z!CTi=PrZY>gm+MQ>B_s0@ci1V-n|D|xSJN_Np=XK(*?0#Ip|h| z|E56*?4%f{=c_La4BzsQ_05M1LQIQfxlg3ay(Z#l){=kfrj&SEKg(t`=oe`m7u6yB zx|FBcY1`wimY84TY`MfNbGuIGUv!Dt&qx?K70K91F-tu1`!+m~M%2w7dDGa4>!M{< z+pY4=E2MW?XcZ3jn|IylE*mW~&A!^famB}Pu-mpXb=Kd?&RORFMG1P?*=E@P^CsSy zC!+-W|Img9(*B11)6VJ1@iJe0%kuZ8VlCc(GR(7=1h6mE@?7#e`I!64~jbdOUI+W&16@$-06!BFlIpxTG}>-)pVCjK_nM zI7O_ecPQt(@ny-wMhQAqL>g5jeB+Zy#?G8k#QUS$k>#QI{hqCJ$eihTzKcdaIN+N* zqlGbOp^iO(>!J)zgm2>R6fX~gbVzh%L+aqkLufQ&Xi!CdQb={QSNJhpbj9R4X!zT^ zE(}c`;#AqWqekwAM)Jkn6(|=z4#d|Z;XC>T9ZPo8mN&u Date: Tue, 31 Jan 2023 15:56:46 +0700 Subject: [PATCH 0175/1199] Fix widgets --- .../ru/dbotthepony/mc/otm/client/MatteryGUI.kt | 2 +- .../mc/otm/client/render/MatteryAtlas.kt | 2 +- .../mc/otm/client/render/MatterySprite.kt | 4 ++-- .../mc/otm/client/render/WidgetLocation.kt | 2 +- .../mc/otm/client/render/Widgets8.kt | 2 +- .../textures/gui/player_bars.png | Bin 287 -> 290 bytes 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index d94391adf..4d0eabd97 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -28,7 +28,7 @@ import java.util.* import kotlin.math.ceil object MatteryGUI { - private val BARS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/player_bars.png"), 80f, 35f) + private val BARS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/player_bars.png"), 80f, 36f) val CHARGE = BARS.sprite(height = 9f) val CHARGE_BG = BARS.sprite(y = 9f, height = 9f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt index f0b8feab9..c6f0ab4db 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt @@ -22,6 +22,6 @@ data class MatteryAtlas( winding: UVWindingOrder = this.winding, ) = MatterySprite(texture, x = x, y = y, width = width, height = height, atlasHeight = this.height, atlasWidth = this.width, winding = winding) - fun grid(rows: Int, columns: Int) = GridAtlas(texture, this.width / rows, this.height / columns, rows = rows, columns = columns) + fun grid(rows: Int, columns: Int) = GridAtlas(texture, this.width / columns, this.height / rows, rows = rows, columns = columns) fun grid(width: Float, height: Float, rows: Int, columns: Int) = GridAtlas(texture, width, height, rows, columns) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt index 980a6f166..741654d4a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt @@ -53,8 +53,8 @@ data class MatterySprite @JvmOverloads constructor( require(atlasWidth > 0f) { "Invalid image width $atlasWidth" } require(atlasHeight > 0f) { "Invalid image height $atlasHeight" } - require(width <= atlasWidth) { "$width <= $atlasWidth" } - require(height <= atlasHeight) { "$height <= $atlasHeight" } + require(x + width <= atlasWidth) { "${x + width} <= $atlasWidth" } + require(y + height <= atlasHeight) { "${y + height} <= $atlasHeight" } } override val u0 = this.x / atlasWidth diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt index 44502c2a7..6caaabfee 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt @@ -6,7 +6,7 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters object WidgetLocation { val LARGE_BUTTON = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/large_button.png"), 72f, 18f) val STORAGE_CONTROLS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/storage_controls.png"), 90f, 18f) - val MISC_18 = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/misc_18.png"), 72f, 72f) + val MISC_18 = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/misc18.png"), 72f, 72f) val SLOT_BACKGROUNDS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/slot_backgrounds.png"), 72f, 72f) val MISC = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/misc.png"), 64f, 64f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt index 035e66671..3a8f5ba75 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt @@ -4,7 +4,7 @@ import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.OverdriveThatMatters object Widgets8 { - val GRID = GridAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets_8.png"), 8f, 8f, 64 / 8, 32 / 8) + val GRID = GridAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets_8.png"), 8f, 8f, columns = 64 / 8, rows = 32 / 8) val BUTTON_IDLE = GRID[0, 0] val BUTTON_HOVERED = GRID[0, 1] diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/player_bars.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/player_bars.png index 9b2f9356737a3358d6535c530209d3251db056dc..dd0ef990b9d74087e9227312fdb572d697a895f2 100644 GIT binary patch delta 123 zcmbQww1{bfIF||s8v_G_+@ifz6BSJvw@(Z=WzyL^u}|Lcch53S#@pNe&N1=wI%z$@ zNFl}HM8gC|MP{dWjjOVMFh9Oi{`2FWBSri8pTGaS<+b$tiTC8x(A0Sx;a>MU|C!gq S1CN20FnGH9xvX$opqG1A~BD2#y=FsaO*pKae|LJjM=hGVbbN8QTUN?U?@t&NrtcRokOy$H5@fe}J UjvzB7b)XFlp00i_>zopr0F6j3WB>pF From 2d519356fad15c6f43d75599789ad2fbef1a415b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 3 Feb 2023 15:15:40 +0700 Subject: [PATCH 0176/1199] get rid of useless stuff in formatting --- .../dbotthepony/mc/otm/core/math/Decimal.kt | 9 + .../mc/otm/core/util/Formatting.kt | 258 ++++-------------- .../dbotthepony/mc/otm/core/util/SiPrefix.kt | 3 + .../mc/otm/tests/FormattingTests.kt | 69 ----- 4 files changed, 59 insertions(+), 280 deletions(-) delete mode 100644 src/test/kotlin/ru/dbotthepony/mc/otm/tests/FormattingTests.kt 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 cd3c96913..59683671a 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 @@ -537,6 +537,15 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 return Decimal(-whole, -decimal) } + val absoluteValue: Decimal + get() { + if (isNegative) { + return -this + } else { + return this + } + } + override fun equals(other: Any?): Boolean { if (isNaN) return false diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt index a70ad48ac..ad2dad48b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt @@ -8,6 +8,16 @@ import ru.dbotthepony.mc.otm.core.math.isNegative import ru.dbotthepony.mc.otm.core.math.isZero import java.math.BigDecimal import java.math.BigInteger +import kotlin.math.absoluteValue + +private fun concat(numbers: String, suffix: Any): Component { + if (suffix == "") + return TextComponent(numbers) + else if (suffix is Component) + return TextComponent(numbers + " " + suffix.string) + else + return TextComponent("$numbers $suffix") +} fun BigInteger.formatReadableNumber(): String { if (isZero) { @@ -49,121 +59,25 @@ fun BigInteger.formatReadableNumber(): String { } fun BigDecimal.determineSiPrefix(): SiPrefix? { - if (isZero) { - return null - } - - var num = this - - if (isNegative) { - num = -this - } - - var prev: SiPrefix? = null + if (isZero) return null + val num = this.abs() if (num >= BigDecimal.ONE) { - for (value in SiPrefix.MULTIPLIES) { - if (value.decimal <= num) { - prev = value - } else { - break - } - } + return SiPrefix.MULTIPLIES.lastOrNull { it.decimal <= num } } else { - for (value in SiPrefix.DECIMALS) { - if (value.decimal >= num) { - prev = value - } else { - break - } - } + return SiPrefix.DECIMALS.lastOrNull { it.decimal >= num } } - - return prev -} - -fun BigDecimal.formatSiTranslatable(): Component { - if (isZero) { - return TextComponent("0.00") - } else if (this == BigDecimal.ONE) { - return TextComponent("1.00") - } - - return TextComponent("1.00") } fun BigInteger.determineSiPrefix(): SiPrefix? { - if (isZero) { - return null - } - - var num = this - - if (isNegative) { - num = -this - } - - var prev: SiPrefix? = null - - if (num >= BigInteger.ONE) { - for (value in SiPrefix.MULTIPLIES) { - if (value.integer!! <= num) { - prev = value - } else { - break - } - } - } - - return prev -} - -fun BigInteger.formatSi(decimalPlaces: Int = 2): String { - require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } - val prefix = determineSiPrefix() ?: return toString() // + "." + "0".repeat(decimalPlaces) - val isNegative = isNegative - val arr = (if (isNegative) -this else this).divideAndRemainder(prefix.integer) - val divided = arr[0].toString() - val remainder = arr[1].toString() - - if (decimalPlaces == 0) { - if (isNegative) { - return "-" + divided + prefix.symbol - } else { - return divided + prefix.symbol - } - } - - @Suppress("NAME_SHADOWING") - val decimalPlaces = decimalPlaces.coerceAtMost(prefix.power) - - val add = (if (isNegative) 1 else 0) - - val buffer = CharArray(divided.length + 2 + decimalPlaces + add) - buffer[buffer.size - 1] = prefix.symbol - - if (isNegative) { - buffer[0] = '-' - } - - for (i in divided.indices) { - buffer[add + i] = divided[i] - } - - buffer[add + divided.length] = '.' - - for (i in 0 until decimalPlaces) { - buffer[add + i + divided.length + 1] = prefix.paddedIndex(remainder, i) - } - - return String(buffer) + if (isZero) return null + val num = this.abs() + return SiPrefix.MULTIPLIES.lastOrNull { it.integer!! <= num } } fun BigInteger.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2): Component { require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } - val prefix = determineSiPrefix() ?: return if (suffix == "") TextComponent(toString(decimalPlaces)) else if (suffix is Component) TextComponent( - toString(decimalPlaces) + suffix.string - ) else TextComponent(toString(decimalPlaces) + suffix) + val prefix = determineSiPrefix() ?: return concat(toString(decimalPlaces), suffix) val isNegative = isNegative val arr = (if (isNegative) -this else this).divideAndRemainder(prefix.integer) val divided = arr[0].toString() @@ -171,7 +85,7 @@ fun BigInteger.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2): Comp if (decimalPlaces == 0) { if (isNegative) { - return TranslatableComponent(prefix.formatLocaleKey, "-$divided", suffix) + return TranslatableComponent(prefix.formatLocaleKey, "-$divided${prefix.symbol}", suffix) } else { return TranslatableComponent(prefix.formatLocaleKey, divided + prefix.symbol, suffix) } @@ -179,9 +93,7 @@ fun BigInteger.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2): Comp @Suppress("NAME_SHADOWING") val decimalPlaces = decimalPlaces.coerceAtMost(prefix.power) - val add = (if (isNegative) 1 else 0) - val buffer = CharArray(divided.length + 1 + decimalPlaces + add) if (isNegative) { @@ -206,33 +118,13 @@ fun Decimal.determineSiPrefix(): SiPrefix? { return null } - var num = this - - if (isNegative) { - num = -this - } - - var prev: SiPrefix? = null + val num = this.absoluteValue if (num >= Decimal.ONE) { - for (value in SiPrefix.MULTIPLIES) { - if (value.impreciseFraction <= num) { - prev = value - } else { - break - } - } + return SiPrefix.MULTIPLIES.lastOrNull { it.impreciseFraction <= num } } else { - for (value in SiPrefix.DECIMALS_IMPRECISE) { - if (value.impreciseFraction >= num) { - prev = value - } else { - break - } - } + return SiPrefix.DECIMALS.lastOrNull { it.impreciseFraction >= num } } - - return prev } fun Int.determineSiPrefix(): SiPrefix? { @@ -240,51 +132,20 @@ fun Int.determineSiPrefix(): SiPrefix? { return null } - var num = this - - if (this < 0) { - num = -this - } - - var prev: SiPrefix? = null - - if (num >= 1) { - for (value in SiPrefix.MULTIPLIES) { - if (value.int != null && value.int <= num) { - prev = value - } else { - break - } - } - } - - return prev + val num = this.absoluteValue + if (num <= 1) return null + return SiPrefix.MULTIPLIES.lastOrNull { it.int != null && it.int <= num } } fun Double.determineSiPrefix(): SiPrefix? { - if (this == 0.0) { - return null + if (this == 0.0) return null + val num = this.absoluteValue + + if (num >= 1.0) { + return SiPrefix.MULTIPLIES.lastOrNull { it.double <= num } + } else { + return SiPrefix.DECIMALS.lastOrNull { it.double >= num } } - - var num = this - - if (this < 0) { - num = -this - } - - var prev: SiPrefix? = null - - if (num >= 1) { - for (value in SiPrefix.MULTIPLIES) { - if (value.double <= num) { - prev = value - } else { - break - } - } - } - - return prev } fun Decimal.formatSi(decimalPlaces: Int = 2): String { @@ -295,59 +156,34 @@ fun Decimal.formatSi(decimalPlaces: Int = 2): String { fun Int.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2): Component { require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } - val prefix = determineSiPrefix() ?: return if (suffix == "") TextComponent(toString()) else if (suffix is Component) TextComponent( - toString() + " " + suffix.string - ) else TextComponent(toString() + " " + suffix) - return TranslatableComponent( - prefix.formatLocaleKey, - "%.${decimalPlaces}f".format(this.toFloat() / prefix.int!!.toFloat()), - suffix - ) + val prefix = determineSiPrefix() ?: return concat(toString(), suffix) + return TranslatableComponent(prefix.formatLocaleKey, "%.${decimalPlaces}f".format(this.toFloat() / prefix.int!!.toFloat()), suffix) } fun Double.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2): Component { require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } - val prefix = determineSiPrefix() ?: return if (suffix == "") TextComponent("%.${decimalPlaces}f".format(this)) else if (suffix is Component) TextComponent( - "%.${decimalPlaces}f".format(this) + " " + suffix.string - ) else TextComponent("%.${decimalPlaces}f".format(this) + " " + suffix) + val prefix = determineSiPrefix() ?: return concat("%.${decimalPlaces}f".format(this), suffix) return TranslatableComponent(prefix.formatLocaleKey, "%.${decimalPlaces}f".format(this / prefix.double), suffix) } fun Decimal.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2): Component { require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } - val prefix = determineSiPrefix() ?: return if (suffix == "") TextComponent(toString(decimalPlaces)) else if (suffix is Component) TextComponent( - toString(decimalPlaces) + " " + suffix.string - ) else TextComponent(toString(decimalPlaces) + " " + suffix) - return TranslatableComponent( - prefix.formatLocaleKey, - (this / prefix.impreciseFraction).toString(decimalPlaces), - suffix - ) + val prefix = determineSiPrefix() ?: return concat(toString(decimalPlaces), suffix) + return TranslatableComponent(prefix.formatLocaleKey, (this / prefix.impreciseFraction).toString(decimalPlaces), suffix) } -val POWER_NAME = TranslatableComponent("otm.gui.power.name") -val MATTER_NAME = TranslatableComponent("otm.gui.matter.name") -fun Int.formatPower(decimalPlaces: Int = 2) = formatSiComponent(POWER_NAME, decimalPlaces) -fun Decimal.formatPower(decimalPlaces: Int = 2) = formatSiComponent(POWER_NAME, decimalPlaces) -fun Decimal.formatMatter(decimalPlaces: Int = 2) = formatSiComponent(MATTER_NAME, decimalPlaces) -fun Decimal.formatMatterFull(decimalPlaces: Int = 2) = TranslatableComponent( - "otm.gui.matter.format", formatSiComponent( - MATTER_NAME, decimalPlaces - ) -) +fun Int.formatPower(decimalPlaces: Int = 2) = formatSiComponent(TranslatableComponent("otm.gui.power.name"), decimalPlaces) +fun Decimal.formatPower(decimalPlaces: Int = 2) = formatSiComponent(TranslatableComponent("otm.gui.power.name"), decimalPlaces) +fun Decimal.formatMatter(decimalPlaces: Int = 2) = formatSiComponent(TranslatableComponent("otm.gui.matter.name"), decimalPlaces) +fun Decimal.formatMatterFull(decimalPlaces: Int = 2) = TranslatableComponent("otm.gui.matter.format", formatSiComponent(TranslatableComponent("otm.gui.matter.name"), decimalPlaces)) -fun BigInteger.formatPower(decimalPlaces: Int = 2) = formatSiComponent(POWER_NAME, decimalPlaces) -fun BigInteger.formatMatter(decimalPlaces: Int = 2) = formatSiComponent(MATTER_NAME, decimalPlaces) -fun BigInteger.formatMatterFull(decimalPlaces: Int = 2) = TranslatableComponent( - "otm.gui.matter.format", formatSiComponent( - MATTER_NAME, decimalPlaces - ) -) +fun BigInteger.formatPower(decimalPlaces: Int = 2) = formatSiComponent(TranslatableComponent("otm.gui.power.name"), decimalPlaces) +fun BigInteger.formatMatter(decimalPlaces: Int = 2) = formatSiComponent(TranslatableComponent("otm.gui.matter.name"), decimalPlaces) +fun BigInteger.formatMatterFull(decimalPlaces: Int = 2) = TranslatableComponent("otm.gui.matter.format", formatSiComponent(TranslatableComponent("otm.gui.matter.name"), decimalPlaces)) + +fun formatPowerLevel(a: Decimal, b: Decimal, decimalPlaces: Int = 2) = TranslatableComponent("otm.gui.level", a.formatPower(decimalPlaces), b.formatPower(decimalPlaces)) +fun formatMatterLevel(a: Decimal, b: Decimal, decimalPlaces: Int = 2) = TranslatableComponent("otm.gui.level", a.formatMatter(decimalPlaces), b.formatMatter(decimalPlaces)) -fun formatPowerLevel(a: Decimal, b: Decimal, decimalPlaces: Int = 2) = - TranslatableComponent("otm.gui.level", a.formatPower(decimalPlaces), b.formatPower(decimalPlaces)) -fun formatMatterLevel(a: Decimal, b: Decimal, decimalPlaces: Int = 2) = - TranslatableComponent("otm.gui.level", a.formatMatter(decimalPlaces), b.formatMatter(decimalPlaces)) private fun padded(num: Int): String { if (num in 0 .. 9) { return "0$num" diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/SiPrefix.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/SiPrefix.kt index b12ac983d..7c227a279 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/SiPrefix.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/SiPrefix.kt @@ -56,6 +56,7 @@ enum class SiPrefix( val double = string.toDouble() companion object { + @JvmField val MULTIPLIES: List = ImmutableList.builder() .add(KILO) .add(MEGA) @@ -67,6 +68,7 @@ enum class SiPrefix( .add(YOTTA) .build() + @JvmField val DECIMALS: List = ImmutableList.builder() //.add(DECI) //.add(CENTI) @@ -80,6 +82,7 @@ enum class SiPrefix( .add(YOCTO) .build() + @JvmField val DECIMALS_IMPRECISE: List = ImmutableList.builder() //.add(DECI) //.add(CENTI) diff --git a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FormattingTests.kt b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FormattingTests.kt deleted file mode 100644 index e258d8012..000000000 --- a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FormattingTests.kt +++ /dev/null @@ -1,69 +0,0 @@ -package ru.dbotthepony.mc.otm.tests - -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.DisplayName -import org.junit.jupiter.api.Test -import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.util.formatReadableNumber -import ru.dbotthepony.mc.otm.core.util.formatSi -import java.math.BigInteger - -object FormattingTests { - @Test - @DisplayName("BigInteger formatting as readable number") - fun biginteger() { - assertEquals("0", BigInteger("0").formatReadableNumber()) - assertEquals("45", BigInteger("45").formatReadableNumber()) - assertEquals("-45", BigInteger("-45").formatReadableNumber()) - assertEquals("0", BigInteger("-0").formatReadableNumber()) - - assertEquals("100", BigInteger("100").formatReadableNumber()) - assertEquals("-100", BigInteger("-100").formatReadableNumber()) - assertEquals("999", BigInteger("999").formatReadableNumber()) - assertEquals("1 999", BigInteger("1999").formatReadableNumber()) - assertEquals("8 992", BigInteger("8992").formatReadableNumber()) - assertEquals("-8 992", BigInteger("-8992").formatReadableNumber()) - assertEquals("100 200", BigInteger("100200").formatReadableNumber()) - assertEquals("-100 200", BigInteger("-100200").formatReadableNumber()) - - assertEquals("-1 100 200", BigInteger("-1100200").formatReadableNumber()) - assertEquals("1 100 200", BigInteger("1100200").formatReadableNumber()) - assertEquals("2 730 250 200", BigInteger("2730250200").formatReadableNumber()) - assertEquals("1 222 730 250 200", BigInteger("1222730250200").formatReadableNumber()) - } - - @Test - @DisplayName("BigInteger formatting as si number") - fun bigintegerSi() { - assertEquals("0", BigInteger("0").formatSi()) - assertEquals("420", BigInteger("420").formatSi()) - assertEquals("-420", BigInteger("-420").formatSi()) - assertEquals("555", BigInteger("555").formatSi()) - assertEquals("55", BigInteger("55").formatSi()) - assertEquals("1.20k", BigInteger("1205").formatSi()) - assertEquals("-1.20k", BigInteger("-1205").formatSi()) - assertEquals("1.21k", BigInteger("1215").formatSi()) - assertEquals("4.50M", BigInteger("4501204").formatSi()) - assertEquals("4.00M", BigInteger("4000111").formatSi()) - assertEquals("4.0011M", BigInteger("4001111").formatSi(4)) - assertEquals("-4.0011M", BigInteger("-4001111").formatSi(4)) - } - - @Test - @DisplayName("ImpreciseFraction formatting as si number") - fun impreciseFractionSi() { - assertEquals("0.00", Decimal("0").formatSi(2)) - assertEquals("14.62", Decimal("14.62").formatSi(2)) - assertEquals("1.00k", Decimal("1000").formatSi(2)) - assertEquals("1.00k", Decimal("1000.1").formatSi(2)) - assertEquals("1.00k", Decimal("1004.2").formatSi(2)) - assertEquals("1.01k", Decimal("1014.5").formatSi(2)) - assertEquals("1.014k", Decimal("1014.5").formatSi(3)) - assertEquals("1.01k", Decimal("1014.256").formatSi(2)) - assertEquals("12.73k", Decimal("12734.256").formatSi(2)) - assertEquals("127.34k", Decimal("127342.256").formatSi(2)) - assertEquals("1.27M", Decimal("1273421.256").formatSi(2)) - assertEquals("1.273M", Decimal("1273421.256").formatSi(3)) - assertEquals("1.2734M", Decimal("1273421.256").formatSi(4)) - } -} From e28867e9136d10e2a1c0bdfb0274de89aa954d6b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 5 Feb 2023 17:52:54 +0700 Subject: [PATCH 0177/1199] Formatting without SI prefix while holding shift --- .../capability/energy/IEnergyStorageImpl.kt | 21 +++--- .../ru/dbotthepony/mc/otm/client/Ext.kt | 21 ++++++ .../render/blockentity/BlackHoleRenderer.kt | 3 +- .../GravitationStabilizerRenderer.kt | 5 +- .../client/screen/tech/EnergyCounterScreen.kt | 11 +-- .../client/screen/widget/MatterGaugePanel.kt | 3 +- .../client/screen/widget/PowerGaugePanel.kt | 3 +- .../mc/otm/core/util/Formatting.kt | 70 ++++++++++++++----- .../mc/otm/item/MatterCapacitorItem.kt | 5 +- .../mc/otm/matter/MatterManager.kt | 5 +- 10 files changed, 105 insertions(+), 42 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt index edd032081..a290fcb05 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt @@ -4,6 +4,7 @@ import net.minecraft.ChatFormatting import net.minecraft.network.chat.Component import net.minecraftforge.energy.IEnergyStorage import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.util.formatPower @@ -17,8 +18,8 @@ internal fun batteryLevel(it: IEnergyStorage, tooltips: MutableList) tooltips.add( TranslatableComponent( "otm.item.power.storage", - it.energyStored.formatPower(), - it.maxEnergyStored.formatPower() + it.energyStored.formatPower(formatAsReadable = ShiftPressedCond), + it.maxEnergyStored.formatPower(formatAsReadable = ShiftPressedCond) ).withStyle(ChatFormatting.GRAY)) } @@ -26,8 +27,8 @@ internal fun batteryLevel(it: IMatteryEnergyStorage, tooltips: MutableList { if (it.maxInput != null) { tooltips.add( - TranslatableComponent("otm.item.power.throughput_mono", it.maxInput!!.formatPower()).withStyle( + TranslatableComponent("otm.item.power.throughput_mono", it.maxInput!!.formatPower(formatAsReadable = ShiftPressedCond)).withStyle( ChatFormatting.GRAY )) } else { @@ -50,7 +51,7 @@ internal fun batteryLevel(it: IMatteryEnergyStorage, tooltips: MutableList { if (it.maxOutput != null) { tooltips.add( - TranslatableComponent("otm.item.power.throughput_mono", it.maxOutput!!.formatPower()).withStyle( + TranslatableComponent("otm.item.power.throughput_mono", it.maxOutput!!.formatPower(formatAsReadable = ShiftPressedCond)).withStyle( ChatFormatting.GRAY )) } else { @@ -70,14 +71,14 @@ internal fun batteryLevel(it: IMatteryEnergyStorage, tooltips: MutableList(menu, inventory, title) { - override fun makeMainFrame(): FramePanel> { + override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! var label: Label = object : Label(this@EnergyCounterScreen, frame) { @@ -20,7 +21,7 @@ class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title: super.tick() text = TranslatableComponent( "otm.item.power.passed", - menu.passed.formatPower() + menu.passed.formatPower(formatAsReadable = ShiftPressedCond) ) } } @@ -33,7 +34,7 @@ class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title: super.tick() text = TranslatableComponent( "otm.item.power.average", - menu.average.formatPower() + menu.average.formatPower(formatAsReadable = ShiftPressedCond) ) } } @@ -46,7 +47,7 @@ class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title: super.tick() text = TranslatableComponent( "otm.item.power.last_20_ticks", - menu.last20Ticks.formatPower() + menu.last20Ticks.formatPower(formatAsReadable = ShiftPressedCond) ) } } @@ -59,7 +60,7 @@ class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title: super.tick() text = TranslatableComponent( "otm.item.power.last_tick", - menu.lastTick.formatPower() + menu.lastTick.formatPower(formatAsReadable = ShiftPressedCond) ) } } 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 a34012c68..2e8eed2b5 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 @@ -9,6 +9,7 @@ import net.minecraft.client.gui.screens.Screen import net.minecraft.client.renderer.GameRenderer import net.minecraft.network.chat.Component import org.lwjgl.opengl.GL11 +import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.render.tesselator import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel @@ -44,7 +45,7 @@ open class MatterGaugePanel @JvmOverloads constructor( "otm.gui.matter.percentage_level", String.format("%.2f", widget.percentage() * 100.0) ), - formatMatterLevel(widget.level(), widget.maxLevel()) + formatMatterLevel(widget.level(), widget.maxLevel(), formatAsReadable = ShiftPressedCond) ) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt index 194ef0004..1f248a14c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.widget import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component +import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel @@ -25,7 +26,7 @@ open class PowerGaugePanel @JvmOverloads constructor( protected open fun makeTooltip(): MutableList { return mutableListOf( TranslatableComponent("otm.gui.power.percentage_level", String.format("%.2f", widget.percentage() * 100.0)), - formatPowerLevel(widget.level(), widget.maxLevel()) + formatPowerLevel(widget.level(), widget.maxLevel(), formatAsReadable = ShiftPressedCond) ) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt index ad2dad48b..ac8d94713 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.core.util +import it.unimi.dsi.fastutil.chars.CharArrayList import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent @@ -8,7 +9,9 @@ import ru.dbotthepony.mc.otm.core.math.isNegative import ru.dbotthepony.mc.otm.core.math.isZero import java.math.BigDecimal import java.math.BigInteger +import java.util.function.BooleanSupplier import kotlin.math.absoluteValue +import kotlin.math.roundToInt private fun concat(numbers: String, suffix: Any): Component { if (suffix == "") @@ -75,7 +78,7 @@ fun BigInteger.determineSiPrefix(): SiPrefix? { return SiPrefix.MULTIPLIES.lastOrNull { it.integer!! <= num } } -fun BigInteger.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2): Component { +fun BigInteger.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never): Component { require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } val prefix = determineSiPrefix() ?: return concat(toString(decimalPlaces), suffix) val isNegative = isNegative @@ -148,41 +151,74 @@ fun Double.determineSiPrefix(): SiPrefix? { } } -fun Decimal.formatSi(decimalPlaces: Int = 2): String { - require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } - val prefix = determineSiPrefix() ?: return toString(decimalPlaces) - return (this / prefix.impreciseFraction).toString(decimalPlaces) + prefix.symbol +private val never = BooleanSupplier { false } + +private fun reformat(numbers: String): String { + if (numbers.length <= 4) + return numbers + + val result = CharArrayList((numbers.length * 1.6).roundToInt()) + + var dot = numbers.lastIndexOf('.') + + if (dot != -1) { + for (i in numbers.length - 1 downTo dot) { + result.add(numbers[i]) + } + + dot-- + } else { + dot = numbers.length - 1 + } + + var c = 0 + + for (i in dot downTo 0) { + if (++c == 4) { + c = 1 + result.add(' ') + } + + result.add(numbers[i]) + } + + return String(CharArray(result.size) { + result.getChar(result.size - it - 1) + }) } -fun Int.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2): Component { +fun Int.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never): Component { require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } + if (formatAsReadable.asBoolean) return concat(reformat(toString()), suffix) val prefix = determineSiPrefix() ?: return concat(toString(), suffix) return TranslatableComponent(prefix.formatLocaleKey, "%.${decimalPlaces}f".format(this.toFloat() / prefix.int!!.toFloat()), suffix) } -fun Double.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2): Component { +fun Double.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never): Component { require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } + if (formatAsReadable.asBoolean) return concat(reformat("%.${decimalPlaces}f".format(this)), suffix) val prefix = determineSiPrefix() ?: return concat("%.${decimalPlaces}f".format(this), suffix) return TranslatableComponent(prefix.formatLocaleKey, "%.${decimalPlaces}f".format(this / prefix.double), suffix) } -fun Decimal.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2): Component { +fun Decimal.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never): Component { require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } + if (formatAsReadable.asBoolean) return concat(reformat(toString(decimalPlaces)), suffix) val prefix = determineSiPrefix() ?: return concat(toString(decimalPlaces), suffix) return TranslatableComponent(prefix.formatLocaleKey, (this / prefix.impreciseFraction).toString(decimalPlaces), suffix) } -fun Int.formatPower(decimalPlaces: Int = 2) = formatSiComponent(TranslatableComponent("otm.gui.power.name"), decimalPlaces) -fun Decimal.formatPower(decimalPlaces: Int = 2) = formatSiComponent(TranslatableComponent("otm.gui.power.name"), decimalPlaces) -fun Decimal.formatMatter(decimalPlaces: Int = 2) = formatSiComponent(TranslatableComponent("otm.gui.matter.name"), decimalPlaces) -fun Decimal.formatMatterFull(decimalPlaces: Int = 2) = TranslatableComponent("otm.gui.matter.format", formatSiComponent(TranslatableComponent("otm.gui.matter.name"), decimalPlaces)) +fun Int.formatPower(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.power.name"), decimalPlaces, formatAsReadable = formatAsReadable) +fun Decimal.formatPower(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.power.name"), decimalPlaces, formatAsReadable = formatAsReadable) +fun Decimal.formatMatter(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.matter.name"), decimalPlaces, formatAsReadable = formatAsReadable) +fun Decimal.formatMatterFull(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = TranslatableComponent("otm.gui.matter.format", formatSiComponent(TranslatableComponent("otm.gui.matter.name"), decimalPlaces, formatAsReadable = formatAsReadable)) -fun BigInteger.formatPower(decimalPlaces: Int = 2) = formatSiComponent(TranslatableComponent("otm.gui.power.name"), decimalPlaces) -fun BigInteger.formatMatter(decimalPlaces: Int = 2) = formatSiComponent(TranslatableComponent("otm.gui.matter.name"), decimalPlaces) -fun BigInteger.formatMatterFull(decimalPlaces: Int = 2) = TranslatableComponent("otm.gui.matter.format", formatSiComponent(TranslatableComponent("otm.gui.matter.name"), decimalPlaces)) +fun BigInteger.formatPower(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.power.name"), decimalPlaces, formatAsReadable = formatAsReadable) +fun BigInteger.formatMatter(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.matter.name"), decimalPlaces, formatAsReadable = formatAsReadable) +fun BigInteger.formatMatterFull(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = TranslatableComponent("otm.gui.matter.format", formatSiComponent(TranslatableComponent("otm.gui.matter.name"), decimalPlaces, formatAsReadable = formatAsReadable)) -fun formatPowerLevel(a: Decimal, b: Decimal, decimalPlaces: Int = 2) = TranslatableComponent("otm.gui.level", a.formatPower(decimalPlaces), b.formatPower(decimalPlaces)) -fun formatMatterLevel(a: Decimal, b: Decimal, decimalPlaces: Int = 2) = TranslatableComponent("otm.gui.level", a.formatMatter(decimalPlaces), b.formatMatter(decimalPlaces)) +fun formatPowerLevel(a: Decimal, b: Decimal, decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = TranslatableComponent("otm.gui.level", a.formatPower(decimalPlaces, formatAsReadable = formatAsReadable), b.formatPower(decimalPlaces, formatAsReadable = formatAsReadable)) +fun formatMatterLevel(a: Decimal, b: Decimal, decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = TranslatableComponent("otm.gui.level", a.formatMatter(decimalPlaces, formatAsReadable = formatAsReadable), b.formatMatter(decimalPlaces, formatAsReadable = formatAsReadable)) private fun padded(num: Int): String { if (num in 0 .. 9) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt index 78a446aa8..b58b41715 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt @@ -17,6 +17,7 @@ import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.matter.* +import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.util.formatMatter import ru.dbotthepony.mc.otm.core.ifPresentK @@ -136,8 +137,8 @@ class MatterCapacitorItem : Item { p_41423_.add( TranslatableComponent( "otm.item.matter.normal", - it.storedMatter.formatMatter(), - capacity.formatMatter() + it.storedMatter.formatMatter(formatAsReadable = ShiftPressedCond), + capacity.formatMatter(formatAsReadable = ShiftPressedCond) ).withStyle(ChatFormatting.GRAY) ) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 83d058abd..15851efe9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -60,6 +60,7 @@ import ru.dbotthepony.mc.otm.SERVER_IS_LIVE import ru.dbotthepony.mc.otm.SystemTime import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.drive.IMatteryDrive +import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.container.stream import ru.dbotthepony.mc.otm.core.math.Decimal @@ -1085,9 +1086,7 @@ object MatterManager { } fun tooltipEvent(event: ItemTooltipEvent) { - val window = minecraft.window.window - - if (InputConstants.isKeyDown(window, GLFW.GLFW_KEY_LEFT_SHIFT) || InputConstants.isKeyDown(window, GLFW.GLFW_KEY_RIGHT_SHIFT)) { + if (minecraft.window.isShiftDown) { val matter = get(event.itemStack, accountForStackSize = false) if (matter.hasMatterValue) { From a9fee2b527af20bf83fbb7a2e55349f5b8f48a79 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 5 Feb 2023 17:53:12 +0700 Subject: [PATCH 0178/1199] how --- src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 46b3441a3..2093b565c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -507,7 +507,7 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.ADVANCED_CONTROL_CIRCUIT, "Продвинутая Схема Управления") add(MItems.QUANTUM_TRANSCEIVER, "Квантовый Передатчик") add(MItems.ELECTROMAGNET, "Электромагнит") - add(MItems.MIRROR_COMPOUND, "Набор Выплавки Стекла") + add(MItems.MIRROR_COMPOUND, "Набор Выплавки Зеркала") add(MItems.MIRROR, "Зеркало") add(MItems.MIRROR, "description", "Я могу очень отчётливо видеть своё отражение в этом зеркале") From fea86d74ef2e576d6a1d1033fa4145aa57b86483 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 5 Feb 2023 17:56:35 +0700 Subject: [PATCH 0179/1199] Cycle between full and si-prefixed matter values --- .../ru/dbotthepony/mc/otm/matter/MatterManager.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 15851efe9..8d2f02ae8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -79,6 +79,7 @@ import ru.dbotthepony.mc.otm.core.readItemType import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.core.stream import ru.dbotthepony.mc.otm.core.writeItemType +import ru.dbotthepony.mc.otm.milliTime import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.RegistryNetworkChannel import ru.dbotthepony.mc.otm.registry.RegistryDelegate @@ -86,6 +87,7 @@ import ru.dbotthepony.mc.otm.storage.ItemStackWrapper import java.io.File import java.math.BigInteger import java.util.* +import java.util.function.BooleanSupplier import java.util.function.Supplier import java.util.stream.Stream import kotlin.ConcurrentModificationException @@ -1085,6 +1087,8 @@ object MatterManager { return getResearchAdvance(this@MatterManager.get(stack.asItem()).complexity) } + private val formatMatterAsReadable = BooleanSupplier { minecraft.window.isShiftDown && milliTime % 2_000L > 1_000L } + fun tooltipEvent(event: ItemTooltipEvent) { if (minecraft.window.isShiftDown) { val matter = get(event.itemStack, accountForStackSize = false) @@ -1096,20 +1100,20 @@ object MatterManager { if (matter.matter != matterSized.matter || matter.complexity != matterSized.complexity) { event.toolTip.add( TranslatableComponent("otm.gui.matter.format_and_complexity2", - matter.matter.formatMatterFull(), - matterSized.matter.formatMatter(), + matter.matter.formatMatterFull(formatAsReadable = formatMatterAsReadable), + matterSized.matter.formatMatter(formatAsReadable = formatMatterAsReadable), if (matter.complexity > 1000.0) formatTickDuration(matter.complexity.roundToInt(), true) else matter.complexity.formatSiComponent(TranslatableComponent("otm.gui.ticks")), if (matterSized.complexity > 1000.0) formatTickDuration(matterSized.complexity.roundToInt(), true) else matterSized.complexity.formatSiComponent(TranslatableComponent("otm.gui.ticks")), ).withStyle(ChatFormatting.AQUA)) } else { event.toolTip.add( TranslatableComponent("otm.gui.matter.format_and_complexity", - matter.matter.formatMatterFull(), + matter.matter.formatMatterFull(formatAsReadable = formatMatterAsReadable), if (matter.complexity > 1000.0) formatTickDuration(matter.complexity.roundToInt(), true) else matter.complexity.formatSiComponent(TranslatableComponent("otm.gui.ticks")), ).withStyle(ChatFormatting.AQUA)) } } else { - event.toolTip.add(matter.matter.formatMatterFull().withStyle(ChatFormatting.AQUA)) + event.toolTip.add(matter.matter.formatMatterFull(formatAsReadable = formatMatterAsReadable).withStyle(ChatFormatting.AQUA)) } } From fb8d882af02dad10e4c4b12994c0d1013e385fa2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 5 Feb 2023 17:58:33 +0700 Subject: [PATCH 0180/1199] ALWAYS_DISPLAY_MATTER_VALUE client setting --- src/main/kotlin/ru/dbotthepony/mc/otm/ClientConfig.kt | 9 ++++++--- .../kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt | 5 +++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/ClientConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/ClientConfig.kt index 5f1638064..be0e59dfd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/ClientConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/ClientConfig.kt @@ -10,17 +10,20 @@ object ClientConfig { private val spec: ForgeConfigSpec private var registered = false + var ALWAYS_DISPLAY_MATTER_VALUE: Boolean by specBuilder + .define("ALWAYS_DISPLAY_MATTER_VALUE", false) + var EXOPACK_INVENTORY_ROWS: Int by specBuilder .comment("Amount of inventory rows to show when wearing Exosuit") - .defineInRange("exosuitInventoryRows", 3, 3, 6) + .defineInRange("EXOPACK_INVENTORY_ROWS", 3, 3, 6) var JUMP_BOOST_LOOK_ANGLE: Double by specBuilder .comment("If looking below this angle (actually, looking 'above' as you see in game, but not as you expect it, check with debug screen), Crouch + Jump will trigger jump boost android ability") - .defineInRange("jumpBoostTriggerAngle", 30.0, -180.0, 180.0) + .defineInRange("JUMP_BOOST_LOOK_ANGLE", 30.0, -180.0, 180.0) var EXOPACK_FREE_SCROLL: Boolean by specBuilder .comment("Allow to scroll Exopack inventory in non OTM inventories when hovering just over inventory slots, not only scrollbar") - .define("exopackFreeScroll", true) + .define("EXOPACK_FREE_SCROLL", true) init { spec = specBuilder.build() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 8d2f02ae8..d39549e2a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -53,6 +53,7 @@ import net.minecraftforge.registries.ForgeRegistries import net.minecraftforge.server.command.EnumArgument import org.apache.logging.log4j.LogManager import org.lwjgl.glfw.GLFW +import ru.dbotthepony.mc.otm.ClientConfig import ru.dbotthepony.mc.otm.MINECRAFT_SERVER import ru.dbotthepony.mc.otm.NULLABLE_MINECRAFT_SERVER import ru.dbotthepony.mc.otm.OverdriveThatMatters @@ -1087,10 +1088,10 @@ object MatterManager { return getResearchAdvance(this@MatterManager.get(stack.asItem()).complexity) } - private val formatMatterAsReadable = BooleanSupplier { minecraft.window.isShiftDown && milliTime % 2_000L > 1_000L } + private val formatMatterAsReadable = BooleanSupplier { if (ClientConfig.ALWAYS_DISPLAY_MATTER_VALUE) minecraft.window.isShiftDown else minecraft.window.isShiftDown && milliTime % 2_000L > 1_000L } fun tooltipEvent(event: ItemTooltipEvent) { - if (minecraft.window.isShiftDown) { + if (ClientConfig.ALWAYS_DISPLAY_MATTER_VALUE || minecraft.window.isShiftDown) { val matter = get(event.itemStack, accountForStackSize = false) if (matter.hasMatterValue) { From 7b6cce48b9e0ab8ae72729cb4a2f6a24e4e6da2d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 5 Feb 2023 18:03:06 +0700 Subject: [PATCH 0181/1199] some config key renames to match code --- .../ru/dbotthepony/mc/otm/ServerConfig.kt | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/ServerConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/ServerConfig.kt index 2e1d74972..e096700d2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/ServerConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/ServerConfig.kt @@ -79,7 +79,7 @@ object ServerConfig { return obj } - val LABORATORY_LAMP_LIGHT_LENGTH: Int by specBuilder.comment("In blocks").defineInRange("laboratoryLampLightLength", 6, 1, 128) + val LABORATORY_LAMP_LIGHT_LENGTH: Int by specBuilder.comment("In blocks").defineInRange("LABORATORY_LAMP_LIGHT_LENGTH", 6, 1, 128) init { specBuilder.comment("Energy batteries balance values").push("energyBatteries") @@ -126,7 +126,7 @@ object ServerConfig { val PLATE_PRESS = BlockEnergyStorageImpl.makeConfigEntry(specBuilder, MNames.PLATE_PRESS) val STORAGE_POWER_SUPPLIER = BlockEnergyStorageImpl.makeConfigEntry(specBuilder, MNames.STORAGE_POWER_SUPPLIER, capacity = Decimal(100_000), throughput = Decimal(320)) - val STORAGE_INTERFACES = BlockEnergyStorageImpl.makeConfigEntry(specBuilder, "storage_interfaces", capacity = Decimal(10_000)) + val STORAGE_INTERFACES = BlockEnergyStorageImpl.makeConfigEntry(specBuilder, "STORAGE_INTERFACES", capacity = Decimal(10_000)) val ITEM_MONITOR = BlockEnergyStorageImpl.makeConfigEntry(specBuilder, MNames.ITEM_MONITOR) val DRIVE_VIEWER = BlockEnergyStorageImpl.makeConfigEntry(specBuilder, MNames.DRIVE_VIEWER) val DRIVE_RACK = BlockEnergyStorageImpl.makeConfigEntry(specBuilder, MNames.DRIVE_RACK, capacity = Decimal(80_000)) @@ -142,7 +142,7 @@ object ServerConfig { .comment("This setting controls whenever to regenerate small amount of energy while eating as Android") .comment("And also whenever to regenerate energy while in peaceful") .comment("If this is disabled, any (technically) excess hunger will be nullified, unless playing on peaceful difficulty.") - .define("regenerateEnergy", true) + .define("REGENERATE_ENERGY", true) object NanobotsRegeneration { val COOLDOWN: List by specBuilder @@ -153,15 +153,15 @@ object ServerConfig { .comment("") .comment("Wording in pseudocode:") .comment("if (ticksSinceTakingDamage >= cooldownConfigOption[healTicks /* or config's biggest index, whichever is smaller */]) {") - .comment(" healTicks = min(healTicks + 1, this.level /* ability level */)") + .comment(" healTicks = min(healTicks + 1, level /* ability level */)") .comment(" ticksSinceTakingDamage = 0") .comment(" this.ply.heal(...)") .comment("}") - .defineList("cooldown", { mutableListOf(80, 60, 40, 20) }) { it is Int } + .defineList("COOLDOWN", { mutableListOf(80, 60, 40, 20) }) { it is Int } val ENERGY_PER_HITPOINT by specBuilder .comment("Energy required to regenerate 1 health point (half a heart)") - .defineDecimal("energyPerHitpoint", Decimal(800)) + .defineDecimal("ENERGY_PER_HITPOINT", Decimal(800)) } val ANDROID_ENERGY_PER_HUNGER_POINT by specBuilder.defineDecimal("energyPerHunger", Decimal(2000), Decimal.ZERO) @@ -171,13 +171,13 @@ object ServerConfig { object EnderTeleporter { init { - specBuilder.comment("Ender Teleporter ability").push("ender_teleporter") + specBuilder.comment("Ender Teleporter ability").push("EnderTeleporter") } - val ENERGY_COST by specBuilder.defineDecimal("energyCost", Decimal(4096), Decimal.ZERO) - val COOLDOWN: Int by specBuilder.comment("In ticks").defineInRange("cooldown", 40, 0, Int.MAX_VALUE) - val MAX_PHASE_DISTANCE: Int by specBuilder.comment("Determines how much blocks can we 'phase' through to teleport on solid surface").defineInRange("maxPhaseDistance", 6, 0, Int.MAX_VALUE) - val MAX_DISTANCE: Double by specBuilder.comment("In blocks, euclidean distance").defineInRange("maxDistance", 12.0, 2.0, Int.MAX_VALUE.toDouble()) + val ENERGY_COST by specBuilder.defineDecimal("ENERGY_COST", Decimal(4096), Decimal.ZERO) + val COOLDOWN: Int by specBuilder.comment("In ticks").defineInRange("COOLDOWN", 40, 0, Int.MAX_VALUE) + val MAX_PHASE_DISTANCE: Int by specBuilder.comment("Determines how much blocks can we 'phase' through to teleport on solid surface").defineInRange("MAX_PHASE_DISTANCE", 6, 0, Int.MAX_VALUE) + val MAX_DISTANCE: Double by specBuilder.comment("In blocks, euclidean distance").defineInRange("MAX_DISTANCE", 12.0, 2.0, Int.MAX_VALUE.toDouble()) init { specBuilder.pop() @@ -186,13 +186,13 @@ object ServerConfig { object AndroidJumpBoost { init { - specBuilder.comment("Jump boost ability").push("jump_boost") + specBuilder.comment("Jump boost ability").push("AndroidJumpBoost") } - val ENERGY_COST by specBuilder.defineDecimal("energyCost", Decimal(1024), Decimal.ZERO) - val POWER: Double by specBuilder.comment("The jump height on jump boost, as (level + 1) of feature, in meters per second").defineInRange("power", 6.0, 0.0, Double.MAX_VALUE) - val BASE_COOLDOWN: Int by specBuilder.comment("In ticks").defineInRange("baseCooldown", 40, 0, Int.MAX_VALUE) - val COOLDOWN_REDUCTION: Int by specBuilder.comment("In ticks, per level of feature").defineInRange("cooldownReduction", 20, 0, Int.MAX_VALUE) + val ENERGY_COST by specBuilder.defineDecimal("ENERGY_COST", Decimal(1024), Decimal.ZERO) + val POWER: Double by specBuilder.comment("The jump height on jump boost, as (level + 1) of feature, in meters per second").defineInRange("POWER", 6.0, 0.0, Double.MAX_VALUE) + val BASE_COOLDOWN: Int by specBuilder.comment("In ticks").defineInRange("BASE_COOLDOWN", 40, 0, Int.MAX_VALUE) + val COOLDOWN_REDUCTION: Int by specBuilder.comment("In ticks, per level of feature").defineInRange("COOLDOWN_REDUCTION", 20, 0, Int.MAX_VALUE) init { specBuilder.pop() @@ -201,12 +201,12 @@ object ServerConfig { object AndroidItemMagnet { init { - specBuilder.comment("Item magnet ability").push("item_magnet") + specBuilder.comment("Item magnet ability").push("AndroidItemMagnet") } - val POWER_DRAW by specBuilder.comment("Per tick per stack").defineDecimal("powerDraw", Decimal(8), Decimal.ZERO) - val RADIUS_HORIZONTAL: Double by specBuilder.defineInRange("radiusHorizontal", 6.0, 0.0, Double.MAX_VALUE / 4.0) - val RADIUS_VERTICAL: Double by specBuilder.defineInRange("radiusVertical", 3.0, 0.0, Double.MAX_VALUE / 4.0) + val POWER_DRAW by specBuilder.comment("Per tick per stack").defineDecimal("POWER_DRAW", Decimal(8), Decimal.ZERO) + val RADIUS_HORIZONTAL: Double by specBuilder.defineInRange("RADIUS_HORIZONTAL", 6.0, 0.0, Double.MAX_VALUE / 4.0) + val RADIUS_VERTICAL: Double by specBuilder.defineInRange("RADIUS_VERTICAL", 3.0, 0.0, Double.MAX_VALUE / 4.0) init { specBuilder.pop() @@ -215,22 +215,22 @@ object ServerConfig { object Shockwave { init { - specBuilder.comment("Shockwave ability").push("shockwave") + specBuilder.comment("Shockwave ability").push("Shockwave") } - val TERMINAL_VELOCITY: Double by specBuilder.comment("In meters per second vertically").defineInRange("terminalVelocity", 5.6, 0.0) - val ACCELERATION: Double by specBuilder.comment("In meters per second vertically").defineInRange("acceleration", 4.0, 0.0) - val COOLDOWN: Int by specBuilder.comment("In ticks").defineInRange("cooldown", 30, 1) - val RADIUS_HORIZONTAL: Double by specBuilder.comment("In meters").defineInRange("radiusHorizontal", 4.0, 0.0) - val RADIUS_VERTICAL: Double by specBuilder.comment("In meters").defineInRange("radiusVertical", 1.0, 0.0) + val TERMINAL_VELOCITY: Double by specBuilder.comment("In meters per second vertically").defineInRange("TERMINAL_VELOCITY", 5.6, 0.0) + val ACCELERATION: Double by specBuilder.comment("In meters per second vertically").defineInRange("ACCELERATION", 4.0, 0.0) + val COOLDOWN: Int by specBuilder.comment("In ticks").defineInRange("COOLDOWN", 30, 1) + val RADIUS_HORIZONTAL: Double by specBuilder.comment("In meters").defineInRange("RADIUS_HORIZONTAL", 4.0, 0.0) + val RADIUS_VERTICAL: Double by specBuilder.comment("In meters").defineInRange("RADIUS_VERTICAL", 1.0, 0.0) - val RADIUS_HORIZONTAL_WARDEN: Double by specBuilder.comment("In meters, when searching for Warden").defineInRange("radiusHorizontalWarden", 16.0, 0.0) - val RADIUS_VERTICAL_WARDEN: Double by specBuilder.comment("In meters, when searching for Warden").defineInRange("radiusVerticalWarden", 6.0, 0.0) + val RADIUS_HORIZONTAL_WARDEN: Double by specBuilder.comment("In meters, when searching for Warden").defineInRange("RADIUS_HORIZONTAL_WARDEN", 16.0, 0.0) + val RADIUS_VERTICAL_WARDEN: Double by specBuilder.comment("In meters, when searching for Warden").defineInRange("RADIUS_VERTICAL_WARDEN", 6.0, 0.0) - val BREAK_BLOCKS: Boolean by specBuilder.comment("Break blocks without any blast resistance").define("breakBlocks", true) - val DAMAGE: Double by specBuilder.comment("Max potential damage done by shockwave").defineInRange("damage", 12.0, 0.0, Float.MAX_VALUE.toDouble()) - val WARDEN_DAMAGE_MULT: Double by specBuilder.defineInRange("wardenDamageMultiplier", 4.0, 0.0, Float.MAX_VALUE.toDouble()) - val ENERGY_COST by specBuilder.defineDecimal("energyCost", Decimal(2048), Decimal.ZERO) + val BREAK_BLOCKS: Boolean by specBuilder.comment("Break blocks without any blast resistance").define("BREAK_BLOCKS", true) + val DAMAGE: Double by specBuilder.comment("Max potential damage done by shockwave").defineInRange("DAMAGE", 12.0, 0.0, Float.MAX_VALUE.toDouble()) + val WARDEN_DAMAGE_MULT: Double by specBuilder.defineInRange("WARDEN_DAMAGE_MULT", 4.0, 0.0, Float.MAX_VALUE.toDouble()) + val ENERGY_COST by specBuilder.defineDecimal("ENERGY_COST", Decimal(2048), Decimal.ZERO) init { specBuilder.pop() @@ -250,7 +250,7 @@ object ServerConfig { specBuilder.comment("Tweaking of exosuits").push("exosuitPlayer") } - val INFINITE_EXOSUIT_UPGRADES: Boolean by specBuilder.comment("Allows to apply the same upgrade over and over again.", "Obviously completely breaks balance.").define("infinite_upgrades", false) + val INFINITE_EXOSUIT_UPGRADES: Boolean by specBuilder.comment("Allows to apply the same upgrade over and over again.", "Obviously completely breaks balance.").define("INFINITE_EXOSUIT_UPGRADES", false) init { specBuilder.pop() From e238ceceaf7b1de6a4714b730ae5da026a7efcef Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 8 Feb 2023 23:15:11 +0700 Subject: [PATCH 0182/1199] Plate press recipes experience points Fixes #139 --- .../datagen/recipes/MatteryRecipeProvider.kt | 7 +- .../recipes/PlatePressFinishedRecipe.kt | 13 +- .../otm/datagen/recipes/PlatePressRecipes.kt | 20 +-- .../dbotthepony/mc/otm/GlobalEventHandler.kt | 13 ++ .../block/entity/MatteryWorkerBlockEntity.kt | 14 +- .../entity/tech/PlatePressBlockEntity.kt | 25 ++- .../mc/otm/block/tech/EnergyCounterBlock.kt | 2 +- .../compat/jei/PlatePressRecipeCategory.kt | 6 + .../mc/otm/core/UnOverengineering.kt | 39 +++++ .../mc/otm/core/util/FriendlyStreams.kt | 145 ++++++++++++++++++ .../ru/dbotthepony/mc/otm/menu/Slots.kt | 12 +- .../mc/otm/menu/tech/PlatePressMenu.kt | 3 +- .../mc/otm/recipe/PlatePressRecipe.kt | 15 +- 13 files changed, 286 insertions(+), 28 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt index 54d3e6ab0..9472720e7 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt @@ -10,6 +10,8 @@ import net.minecraft.data.recipes.RecipeBuilder import net.minecraft.data.recipes.RecipeProvider import net.minecraft.resources.ResourceLocation import net.minecraft.tags.TagKey +import net.minecraft.util.valueproviders.ConstantFloat +import net.minecraft.util.valueproviders.FloatProvider import net.minecraft.world.item.Item import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.level.ItemLike @@ -77,14 +79,15 @@ class MatteryRecipeProvider(generatorIn: DataGenerator) : RecipeProvider(generat } } - fun plate(id: String, count: Int = 1, workTicks: Int = 200) { + fun plate(id: String, count: Int = 1, workTicks: Int = 200, experience: FloatProvider = ConstantFloat.ZERO) { exec { _, consumer -> consumer.accept(PlatePressShallowFinishedRecipe( ResourceLocation(DataGen.MOD_ID, "plates/$id"), ResourceLocation("forge", "ingots/$id"), ResourceLocation("forge", "plates/$id"), count, - workTicks + workTicks, + experience = experience )) } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressFinishedRecipe.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressFinishedRecipe.kt index 996211d7f..4fac241ba 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressFinishedRecipe.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressFinishedRecipe.kt @@ -2,14 +2,18 @@ package ru.dbotthepony.mc.otm.datagen.recipes import com.google.gson.JsonObject import com.google.gson.JsonPrimitive +import com.mojang.serialization.JsonOps import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.resources.ResourceLocation +import net.minecraft.util.valueproviders.ConstantFloat +import net.minecraft.util.valueproviders.FloatProvider +import net.minecraft.util.valueproviders.UniformFloat import net.minecraft.world.item.crafting.RecipeSerializer import ru.dbotthepony.mc.otm.recipe.PlatePressRecipe import ru.dbotthepony.mc.otm.recipe.PlatePressRecipeFactory -import ru.dbotthepony.mc.otm.container.set -import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.toJsonStrict +import ru.dbotthepony.mc.otm.data.getOrNull class PlatePressFinishedRecipe(private val recipe: PlatePressRecipe) : FinishedRecipe { override fun serializeRecipeData(it: JsonObject) { @@ -21,6 +25,7 @@ class PlatePressFinishedRecipe(private val recipe: PlatePressRecipe) : FinishedR } it["work_time"] = JsonPrimitive(recipe.workTime) + it["experience"] = FloatProvider.CODEC.toJsonStrict(recipe.experience) } override fun getId(): ResourceLocation { @@ -45,7 +50,8 @@ class PlatePressShallowFinishedRecipe( private val input: ResourceLocation, private val output: ResourceLocation, private val count: Int = 1, - private val workTime: Int = 200 + private val workTime: Int = 200, + private val experience: FloatProvider = ConstantFloat.ZERO, ) : FinishedRecipe { override fun serializeRecipeData(it: JsonObject) { it["input"] = JsonObject().also { @@ -60,6 +66,7 @@ class PlatePressShallowFinishedRecipe( } it["work_time"] = JsonPrimitive(workTime) + it["experience"] = FloatProvider.CODEC.toJsonStrict(experience) } override fun getId(): ResourceLocation { diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressRecipes.kt index 2131d5383..40dc88454 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressRecipes.kt @@ -1,19 +1,21 @@ package ru.dbotthepony.mc.otm.datagen.recipes +import net.minecraft.util.valueproviders.ConstantFloat + fun addPlatePressRecipes(provider: MatteryRecipeProvider) { - val baselineMetals = arrayOf("iron", "silver", "bronze", "lead", "constantan", "brass") - val softMetals = arrayOf("gold", "aluminum", "aluminium", "copper", "electrum", "zinc") - val hardMetals = arrayOf("tritanium", "steel", "tungsten", "uranium") + val baselineMetals = arrayOf("iron" to 0.2f, "silver" to 0.3f, "bronze" to 0.3f, "lead" to 0.3f, "constantan" to 0.4f, "brass" to 0.3f) + val softMetals = arrayOf("gold" to 0.4f, "aluminum" to 0.3f, "aluminium" to 0.3f, "copper" to 0.2f, "electrum" to 0.4f, "zinc" to 0.3f) + val hardMetals = arrayOf("tritanium" to 0.5f, "steel" to 0.5f, "tungsten" to 0.55f, "uranium" to 0.5f) - for (thing in baselineMetals) { - provider.plate(thing) + for ((thing, exp) in baselineMetals) { + provider.plate(thing, experience = ConstantFloat.of(exp), workTicks = 160) } - for (thing in softMetals) { - provider.plate(thing, workTicks = 140) + for ((thing, exp) in softMetals) { + provider.plate(thing, workTicks = 120, experience = ConstantFloat.of(exp)) } - for (thing in hardMetals) { - provider.plate(thing, workTicks = 300) + for ((thing, exp) in hardMetals) { + provider.plate(thing, workTicks = 240, experience = ConstantFloat.of(exp)) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt index 08527452f..1d5d80e8f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt @@ -5,6 +5,7 @@ package ru.dbotthepony.mc.otm import net.minecraft.client.server.IntegratedServer import net.minecraft.server.MinecraftServer +import net.minecraft.server.level.ServerLevel import net.minecraft.world.level.Level import net.minecraftforge.api.distmarker.Dist import net.minecraftforge.event.TickEvent @@ -195,6 +196,8 @@ fun tickWhileServer(condition: () -> Boolean, ticker: () -> Unit) { } fun Level.once(ticker: ITickable) { + if (this.isClientSide) return + if (!SERVER_IS_LIVE) { LOGGER.error("Refusing to add ticker $ticker while server is dying", IllegalStateException("Server is stopping")) return @@ -204,6 +207,8 @@ fun Level.once(ticker: ITickable) { } fun Level.oncePre(ticker: ITickable) { + if (this.isClientSide) return + if (!SERVER_IS_LIVE) { LOGGER.error("Refusing to add ticker $ticker while server is dying", IllegalStateException("Server is stopping")) return @@ -213,6 +218,8 @@ fun Level.oncePre(ticker: ITickable) { } fun Level.addTicker(ticker: IConditionalTickable) { + if (this.isClientSide) return + if (!SERVER_IS_LIVE) { LOGGER.error("Refusing to add ticker $ticker while server is dying", IllegalStateException("Server is stopping")) return @@ -222,6 +229,8 @@ fun Level.addTicker(ticker: IConditionalTickable) { } fun Level.addTickerPre(ticker: IConditionalTickable) { + if (this.isClientSide) return + if (!SERVER_IS_LIVE) { LOGGER.error("Refusing to add ticker $ticker while server is dying", IllegalStateException("Server is stopping")) return @@ -231,18 +240,22 @@ fun Level.addTickerPre(ticker: IConditionalTickable) { } fun Level.until(ticker: () -> Boolean) { + if (this.isClientSide) return addTicker(IConditionalTickable.wrap(ticker)) } fun Level.untilPre(ticker: () -> Boolean) { + if (this.isClientSide) return addTickerPre(IConditionalTickable.wrap(ticker)) } fun Level.`while`(condition: () -> Boolean, ticker: () -> Unit) { + if (this.isClientSide) return addTicker(IConditionalTickable.wrap(condition, ticker)) } fun Level.whilePre(condition: () -> Boolean, ticker: () -> Unit) { + if (this.isClientSide) return addTickerPre(IConditionalTickable.wrap(condition, ticker)) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt index c829fd509..6084266ac 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt @@ -32,29 +32,34 @@ abstract class MatteryWorkerBlockEntity( open class Job { open val ticks: Double open val powerUsage: Decimal + open val experience: Float constructor( ticks: Double, - powerUsage: Decimal = Decimal.ZERO + powerUsage: Decimal = Decimal.ZERO, + experience: Float = 0f, ) { this.ticks = ticks this.powerUsage = powerUsage + this.experience = experience } constructor( tag: CompoundTag - ) : this(tag.getDouble(TICKS_KEY), tag.getDecimal(POWER_KEY)) + ) : this(tag.getDouble(TICKS_KEY), tag.getDecimal(POWER_KEY), tag.getFloat(EXPERIENCE_KEY)) open fun serializeNBT(): CompoundTag { return CompoundTag().also { it[TICKS_KEY] = ticks it[POWER_KEY] = powerUsage + it[EXPERIENCE_KEY] = experience } } companion object { const val TICKS_KEY = "ticks" const val POWER_KEY = "power" + const val EXPERIENCE_KEY = "power" } } @@ -65,8 +70,9 @@ abstract class MatteryWorkerBlockEntity( constructor( itemStack: ItemStack, ticks: Double, - power: Decimal = Decimal.ZERO - ) : super(ticks, power) { + power: Decimal = Decimal.ZERO, + experience: Float = 0f, + ) : super(ticks, power, experience) { this.itemStack = itemStack } 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 9b6804ed4..aeb8085a4 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 @@ -4,7 +4,10 @@ import net.minecraft.core.BlockPos import net.minecraft.core.Direction import net.minecraft.nbt.CompoundTag import net.minecraft.network.chat.Component +import net.minecraft.server.level.ServerLevel +import net.minecraft.server.level.ServerPlayer import net.minecraft.world.Container +import net.minecraft.world.entity.ExperienceOrb import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu @@ -26,16 +29,27 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MRecipes import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.once +import ru.dbotthepony.mc.otm.onceServer class PlatePressBlockEntity( p_155229_: BlockPos, p_155230_: BlockState -) : MatteryWorkerBlockEntity(MBlockEntities.PLATE_PRESS, p_155229_, p_155230_, - ::ItemJob -), IDroppableContainer { +) : MatteryWorkerBlockEntity(MBlockEntities.PLATE_PRESS, p_155229_, p_155230_, ::ItemJob), IDroppableContainer { val container = MatteryContainer(this::setChangedLight, 2) override val energy = WorkerEnergyStorage(this::setChangedLight, ServerConfig.PLATE_PRESS) + var experience = 0.0 + + fun popExperience(player: ServerPlayer) { + val whole = experience.toInt() + + if (whole > 0) { + experience -= whole + ExperienceOrb.award(player.level as ServerLevel, player.position(), whole) + } + } + override val droppableContainer: Container get() = container val itemHandler = container.handler(object : MatteryContainerHooks { @@ -68,11 +82,13 @@ class PlatePressBlockEntity( override fun saveAdditional(nbt: CompoundTag) { super.saveAdditional(nbt) nbt[INVENTORY_KEY] = container.serializeNBT() + nbt["experience"] = experience } override fun load(nbt: CompoundTag) { super.load(nbt) nbt.map(INVENTORY_KEY, container::deserializeNBT) + experience = nbt.getDouble("experience") } override val defaultDisplayName: Component @@ -89,6 +105,7 @@ class PlatePressBlockEntity( if (!container.fullyAddItem(job.itemStack, start = SLOT_OUTPUT, end = SLOT_OUTPUT)) return Status.FAILURE_ITEM + experience = (experience + job.experience).coerceAtMost(100.0) return Status.SUCCESS } @@ -99,7 +116,7 @@ class PlatePressBlockEntity( val recipe = level?.recipeManager?.getRecipeFor(MRecipes.PLATE_PRESS, container, level!!)?.orElse(null) ?: return null to IdleReason.ITEM container[SLOT_INPUT].shrink(1) - return ItemJob(recipe.resultItem, recipe.workTime.toDouble(), BASELINE_CONSUMPTION) to null + return ItemJob(recipe.resultItem, recipe.workTime.toDouble(), BASELINE_CONSUMPTION, experience = recipe.experience.sample(level!!.random)) to null } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyCounterBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyCounterBlock.kt index cb617b551..e393d52f5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyCounterBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyCounterBlock.kt @@ -73,7 +73,7 @@ class EnergyCounterBlock : MatteryBlock(), EntityBlock { ) { super.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston) - if (!level.isClientSide && SERVER_IS_LIVE) { + if (SERVER_IS_LIVE) { level.once { (level.getBlockEntity(pos) as? EnergyCounterBlockEntity)?.checkSurroundings() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt index 408930ca5..61e9cb38c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt @@ -71,6 +71,12 @@ object PlatePressRecipeCategory : IRecipeCategory, IDrawable { mouseY: Double ) { minecraft.font.drawAligned(stack, TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), TextAlign.TOP_CENTER, 40f, 30f, RGBAColor.BLACK) + + val average = recipe.experience.toString() + + if (average != "0.0") { + minecraft.font.drawAligned(stack, TranslatableComponent("gui.jei.category.smelting.experience", average), TextAlign.TOP_CENTER, 40f, 1f, RGBAColor.BLACK) + } } override fun getWidth(): Int { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt index a409cfa02..c0fbd76df 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt @@ -1,5 +1,11 @@ package ru.dbotthepony.mc.otm.core +import com.google.gson.JsonElement +import com.google.gson.JsonSyntaxException +import com.mojang.serialization.Codec +import com.mojang.serialization.JsonOps +import net.minecraft.nbt.NbtOps +import net.minecraft.nbt.Tag import net.minecraft.network.FriendlyByteBuf import net.minecraft.network.chat.MutableComponent import net.minecraft.network.chat.contents.LiteralContents @@ -11,6 +17,39 @@ import net.minecraft.world.level.block.Block import net.minecraftforge.registries.ForgeRegistries import net.minecraftforge.registries.IForgeRegistry +// because doing it inline is ugly +fun Codec.fromJson(value: JsonElement): V? { + return decode(JsonOps.INSTANCE, value).get().map({ left -> left.first }, { null }) +} + +fun Codec.fromJsonStrict(value: JsonElement): V { + return decode(JsonOps.INSTANCE, value).get().map({ left -> left.first }, { throw JsonSyntaxException("Error decoding element: ${it.message()}") }) +} + +fun Codec.toJson(value: V): JsonElement? { + return encode(value, JsonOps.INSTANCE, JsonOps.INSTANCE.empty()).get().map({ it }, { null }) +} + +fun Codec.toJsonStrict(value: V): JsonElement { + return encode(value, JsonOps.INSTANCE, JsonOps.INSTANCE.empty()).get().map({ it }, { throw RuntimeException("Error encoding element: ${it.message()}") }) +} + +fun Codec.fromNbt(value: Tag): V? { + return decode(NbtOps.INSTANCE, value).get().map({ left -> left.first }, { null }) +} + +fun Codec.fromNbtStrict(value: Tag): V { + return decode(NbtOps.INSTANCE, value).get().map({ left -> left.first }, { throw RuntimeException("Error decoding element: ${it.message()}") }) +} + +fun Codec.toNbt(value: V): Tag? { + return encode(value, NbtOps.INSTANCE, NbtOps.INSTANCE.empty()).get().map({ it }, { null }) +} + +fun Codec.toNbtStrict(value: V): Tag { + return encode(value, NbtOps.INSTANCE, NbtOps.INSTANCE.empty()).get().map({ it }, { throw RuntimeException("Error encoding element: ${it.message()}") }) +} + // 1.19 being 1.19 fun TranslatableComponent(key: String, vararg values: Any): MutableComponent = MutableComponent.create(TranslatableContents(key, *values)) fun TextComponent(value: String): MutableComponent = MutableComponent.create(LiteralContents(value)) 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 4beddf9d8..01a6dc749 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 @@ -1,9 +1,19 @@ package ru.dbotthepony.mc.otm.core.util +import com.google.gson.JsonArray +import com.google.gson.JsonElement +import com.google.gson.JsonNull +import com.google.gson.JsonObject +import com.google.gson.JsonParseException +import com.google.gson.JsonPrimitive +import com.google.gson.JsonSyntaxException +import io.netty.buffer.ByteBufInputStream +import io.netty.buffer.ByteBufOutputStream import io.netty.handler.codec.EncoderException import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.NbtAccounter import net.minecraft.nbt.NbtIo +import net.minecraft.network.FriendlyByteBuf import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraftforge.registries.ForgeRegistries @@ -11,6 +21,7 @@ import net.minecraftforge.registries.ForgeRegistry import java.io.* import java.math.BigDecimal import java.math.BigInteger +import kotlin.math.absoluteValue // But seriously, Mojang, why would you need to derive from ByteBuf directly, when you can implement // your own InputStream and OutputStream, since ByteBuf is meant to be operated on most time like a stream anyway? @@ -88,3 +99,137 @@ fun InputStream.readBigDecimal(): BigDecimal { return BigDecimal(BigInteger(bytes), scale) } +private const val TYPE_NULL = 0x01 +private const val TYPE_DOUBLE = 0x02 +private const val TYPE_BOOLEAN = 0x03 +private const val TYPE_INT = 0x04 +private const val TYPE_STRING = 0x05 +private const val TYPE_ARRAY = 0x06 +private const val TYPE_OBJECT = 0x07 + +private fun fixSignedInt(read: Long): Long { + val sign = read and 0x1L + @Suppress("name_shadowing") + val read = read ushr 1 + + if (sign == 1L) { + return -read - 1L + } else { + return read + } +} + +/** + * Writes binary json to stream in Starbound Object Notation format + * + * just copy pasted this code from my another project because i was lazy + */ +fun OutputStream.writeJson(element: JsonElement) { + if (element is JsonObject) { + write(TYPE_OBJECT) + writeVarIntLE(element.size()) + + for ((k, v) in element.entrySet()) { + writeBinaryString(k) + writeJson(v) + } + } else if (element is JsonArray) { + write(TYPE_ARRAY) + writeVarIntLE(element.size()) + + for (v in element) { + writeJson(v) + } + } else if (element is JsonPrimitive) { + if (element.isNumber) { + val num = element.asNumber + + if (num is Int || num is Long) { + write(TYPE_INT) + var int = num.toLong() + + if (int < 0) { + int = int.absoluteValue.shl(1).or(1) + } else { + int.shl(1) + } + + writeVarLongLE(int) + } else if (num is Float || num is Double) { + write(TYPE_DOUBLE) + writeDouble(num.toDouble()) + } else { + throw IllegalArgumentException("Unknown number type: ${num::class.qualifiedName}") + } + } else if (element.isString) { + write(TYPE_STRING) + writeBinaryString(element.asString) + } else if (element.isBoolean) { + write(TYPE_BOOLEAN) + write(if (element.asBoolean) 1 else 0) + } else { + write(TYPE_NULL) + } + } else { + throw IllegalArgumentException("Unknown element type: ${element::class.qualifiedName}") + } +} + +/** + * Reads binary json from stream in Starbound Object Notation format + * + * just copy pasted this code from my another project because i was lazy + */ +fun InputStream.readJson(): JsonElement { + return when (val id = read()) { + TYPE_NULL -> JsonNull.INSTANCE + TYPE_DOUBLE -> JsonPrimitive(readDouble()) + TYPE_BOOLEAN -> JsonPrimitive(read() > 1) + TYPE_INT -> JsonPrimitive(fixSignedInt(readVarLongLE())) + TYPE_STRING -> JsonPrimitive(readBinaryString()) + TYPE_ARRAY -> { + val values = readVarIntLE() + + if (values == 0) return JsonArray() + if (values < 0) throw JsonSyntaxException("Tried to read json array with $values elements in it") + + val build = JsonArray(values) + for (i in 0 until values) build.add(readJson()) + return build + } + TYPE_OBJECT -> { + val values = readVarIntLE() + if (values == 0) return JsonObject() + if (values < 0) throw JsonSyntaxException("Tried to read json object with $values elements in it") + + val build = JsonObject() + + for (i in 0 until values) { + val key: String + + try { + key = readBinaryString() + } catch(err: Throwable) { + throw JsonSyntaxException("Reading json object at $i", err) + } + + try { + build.add(key, readJson()) + } catch(err: Throwable) { + throw JsonSyntaxException("Reading json object at $i with name $key", err) + } + } + + return build + } + else -> throw JsonParseException("Unknown element type $id") + } +} + +fun FriendlyByteBuf.readJson(): JsonElement { + return ByteBufInputStream(this).readJson() +} + +fun FriendlyByteBuf.writeJson(value: JsonElement) { + ByteBufOutputStream(this).writeJson(value) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt index 7eac16375..3b545428b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt @@ -26,10 +26,20 @@ open class MatterySlot @JvmOverloads constructor(container: Container, index: In } } -open class MachineOutputSlot @JvmOverloads constructor(container: Container, index: Int, x: Int = 0, y: Int = 0) : MatterySlot(container, index, x, y) { +open class MachineOutputSlot @JvmOverloads constructor(container: Container, index: Int, x: Int = 0, y: Int = 0, val onTake: () -> Unit = {}) : MatterySlot(container, index, x, y) { override fun mayPlace(itemStack: ItemStack): Boolean { return false } + + override fun onTake(pPlayer: Player, pStack: ItemStack) { + super.onTake(pPlayer, pStack) + this.onTake.invoke() + } + + override fun onQuickCraft(pStack: ItemStack, pAmount: Int) { + super.onQuickCraft(pStack, pAmount) + this.onTake.invoke() + } } open class BatterySlot @JvmOverloads constructor(container: Container, index: Int, x: Int = 0, y: Int = 0) : MatterySlot(container, index, x, y) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt index ff88899f7..cd4f123cc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.menu.tech import com.google.common.collect.ImmutableList +import net.minecraft.server.level.ServerPlayer import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity @@ -18,7 +19,7 @@ class PlatePressMenu @JvmOverloads constructor( val container = tile?.container ?: SimpleContainer(2) val inputSlot = MatterySlot(container, PlatePressBlockEntity.SLOT_INPUT) - val outputSlot = MachineOutputSlot(container, PlatePressBlockEntity.SLOT_OUTPUT) + val outputSlot = MachineOutputSlot(container, PlatePressBlockEntity.SLOT_OUTPUT) { tile?.popExperience(ply as ServerPlayer) } override val storageSlots: List = ImmutableList.of(inputSlot, outputSlot) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt index 29f1431c4..70d2a8f6e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt @@ -5,6 +5,8 @@ import com.google.gson.JsonPrimitive import net.minecraft.core.NonNullList import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation +import net.minecraft.util.valueproviders.ConstantFloat +import net.minecraft.util.valueproviders.FloatProvider import net.minecraft.world.Container import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Ingredient @@ -16,16 +18,21 @@ import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity import ru.dbotthepony.mc.otm.container.get +import ru.dbotthepony.mc.otm.core.fromJsonStrict import ru.dbotthepony.mc.otm.core.isActuallyEmpty import ru.dbotthepony.mc.otm.registry.MRecipes import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.core.toJsonStrict +import ru.dbotthepony.mc.otm.core.util.readJson +import ru.dbotthepony.mc.otm.core.util.writeJson class PlatePressRecipe( private val id: ResourceLocation, val input: Ingredient, val output: Ingredient, val count: Int, - val workTime: Int = 200 + val workTime: Int = 200, + val experience: FloatProvider = ConstantFloat.ZERO ) : Recipe { override fun matches(container: Container, p_44003_: Level): Boolean { if (output.isActuallyEmpty || input.isActuallyEmpty) @@ -103,11 +110,12 @@ object PlatePressRecipeFactory : RecipeSerializer { val count = ((obj["result"] as JsonObject)["count"] as? JsonPrimitive)?.let { return@let try {it.asInt} catch(err: Throwable) {throw IllegalStateException("Invalid result.count")} } ?: 1 - return PlatePressRecipe(loc, input, result, count, workTime) + val experience = obj["experience"]?.let { FloatProvider.CODEC.fromJsonStrict(it) } ?: ConstantFloat.ZERO + return PlatePressRecipe(loc, input, result, count, workTime, experience) } override fun fromNetwork(loc: ResourceLocation, buff: FriendlyByteBuf): PlatePressRecipe { - return PlatePressRecipe(loc, Ingredient.fromNetwork(buff), Ingredient.fromNetwork(buff), buff.readInt(), buff.readInt()) + return PlatePressRecipe(loc, Ingredient.fromNetwork(buff), Ingredient.fromNetwork(buff), buff.readInt(), buff.readInt(), FloatProvider.CODEC.fromJsonStrict(buff.readJson())) } override fun toNetwork(buff: FriendlyByteBuf, recipe: PlatePressRecipe) { @@ -115,5 +123,6 @@ object PlatePressRecipeFactory : RecipeSerializer { recipe.output.toNetwork(buff) buff.writeInt(recipe.count) buff.writeInt(recipe.workTime) + buff.writeJson(FloatProvider.CODEC.toJsonStrict(recipe.experience)) } } From 89609b45f69a78852eeb2a3e8c6dbc9ee1138a48 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 8 Feb 2023 23:24:47 +0700 Subject: [PATCH 0183/1199] Make axe instantly break leaves --- .../ru/dbotthepony/mc/otm/item/MatteryAxeItem.kt | 16 ++++++++++++++++ .../ru/dbotthepony/mc/otm/registry/MItems.kt | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/item/MatteryAxeItem.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatteryAxeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatteryAxeItem.kt new file mode 100644 index 000000000..b55940d8a --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatteryAxeItem.kt @@ -0,0 +1,16 @@ +package ru.dbotthepony.mc.otm.item + +import net.minecraft.world.item.AxeItem +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.Tier +import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.level.material.Material + +class MatteryAxeItem(pTier: Tier, pAttackDamageModifier: Float, pAttackSpeedModifier: Float, pProperties: Properties) : AxeItem(pTier, pAttackDamageModifier, pAttackSpeedModifier, pProperties) { + override fun getDestroySpeed(pStack: ItemStack, pState: BlockState): Float { + if (pState.material == Material.LEAVES) + return 64f + + return super.getDestroySpeed(pStack, pState) + } +} 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 9d123f2bb..56885842b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -137,7 +137,7 @@ object MItems { val TRITANIUM_SWORD: Item by registry.register(MNames.TRITANIUM_SWORD) { SwordItem(TRITANIUM_COMPONENT, 4, -2.7f, TOOLS_PROPRTIES) } val TRITANIUM_SHOVEL: Item by registry.register(MNames.TRITANIUM_SHOVEL) { ShovelItem(TRITANIUM_COMPONENT, 1.5f, -2.4f, TOOLS_PROPRTIES) } - val TRITANIUM_AXE: Item by registry.register(MNames.TRITANIUM_AXE) { AxeItem(TRITANIUM_COMPONENT, 8.5f, -3.4f, TOOLS_PROPRTIES) } + val TRITANIUM_AXE: Item by registry.register(MNames.TRITANIUM_AXE) { MatteryAxeItem(TRITANIUM_COMPONENT, 8.5f, -3.4f, TOOLS_PROPRTIES) } val TRITANIUM_PICKAXE: Item by registry.register(MNames.TRITANIUM_PICKAXE) { PickaxeItem(TRITANIUM_COMPONENT, 2, -2.8f, TOOLS_PROPRTIES) } val TRITANIUM_HOE: Item by registry.register(MNames.TRITANIUM_HOE) { HoeItem(TRITANIUM_COMPONENT, 0, -3.4f, TOOLS_PROPRTIES) } From d56cf36fb98282754d8adb2b1c7dae1f2fbd2e99 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 8 Feb 2023 23:26:21 +0700 Subject: [PATCH 0184/1199] AXES_BREAK_LEAVES_INSTANTLY config option --- src/main/kotlin/ru/dbotthepony/mc/otm/ServerConfig.kt | 5 +++++ src/main/kotlin/ru/dbotthepony/mc/otm/item/MatteryAxeItem.kt | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/ServerConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/ServerConfig.kt index e096700d2..44c4018cc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/ServerConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/ServerConfig.kt @@ -237,6 +237,10 @@ object ServerConfig { } } + object Tools { + val AXES_BREAK_LEAVES_INSTANTLY: Boolean by specBuilder.define("AXES_BREAK_LEAVES_INSTANTLY", true) + } + init { // access instances so spec is built NanobotsRegeneration @@ -244,6 +248,7 @@ object ServerConfig { AndroidJumpBoost AndroidItemMagnet Shockwave + Tools specBuilder.pop() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatteryAxeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatteryAxeItem.kt index b55940d8a..a2de91551 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatteryAxeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatteryAxeItem.kt @@ -5,10 +5,11 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Tier import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.material.Material +import ru.dbotthepony.mc.otm.ServerConfig class MatteryAxeItem(pTier: Tier, pAttackDamageModifier: Float, pAttackSpeedModifier: Float, pProperties: Properties) : AxeItem(pTier, pAttackDamageModifier, pAttackSpeedModifier, pProperties) { override fun getDestroySpeed(pStack: ItemStack, pState: BlockState): Float { - if (pState.material == Material.LEAVES) + if (pState.material == Material.LEAVES && ServerConfig.Tools.AXES_BREAK_LEAVES_INSTANTLY) return 64f return super.getDestroySpeed(pStack, pState) From c1d244dda6bd3686b41d8f33c439c0958333c0ea Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 8 Feb 2023 23:32:54 +0700 Subject: [PATCH 0185/1199] Make sure player is still watching for chunk when networking --- .../mc/otm/block/entity/SynchronizedBlockEntity.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/SynchronizedBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/SynchronizedBlockEntity.kt index 88315d951..920821fb4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/SynchronizedBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/SynchronizedBlockEntity.kt @@ -335,8 +335,8 @@ abstract class SynchronizedBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: players.add(event.player) it.changeset++ - onceServer(20) { - if (!event.player.hasDisconnected()) { + onceServer(10) { + if (!event.player.hasDisconnected() && event.player in players) { blocks.forValidRefs { it.synchronizeToPlayers(false) } From d7af3774de3448008a8c341c6e6dcd2a02b8f554 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 9 Feb 2023 14:13:20 +0700 Subject: [PATCH 0186/1199] move configs to config subpackage --- .../mc/otm/OverdriveThatMatters.java | 2 + .../dbotthepony/mc/otm/ObservedConfigList.kt | 1 + .../android/feature/EnderTeleporterFeature.kt | 2 +- .../android/feature/FallDampenersFeature.kt | 2 +- .../otm/android/feature/ItemMagnetFeature.kt | 2 +- .../otm/android/feature/JumpBoostFeature.kt | 4 +- .../feature/NanobotsRegenerationFeature.kt | 2 +- .../otm/android/feature/NightVisionFeature.kt | 2 +- .../otm/android/feature/ShockwaveFeature.kt | 2 +- .../mc/otm/block/decorative/LaboratoryLamp.kt | 2 +- .../entity/matter/MatterBottlerBlockEntity.kt | 2 +- .../matter/MatterDecomposerBlockEntity.kt | 2 +- .../matter/MatterRecyclerBlockEntity.kt | 2 +- .../matter/MatterReplicatorBlockEntity.kt | 2 +- .../entity/matter/MatterScannerBlockEntity.kt | 2 +- .../entity/storage/DriveRackBlockEntity.kt | 2 +- .../entity/storage/DriveViewerBlockEntity.kt | 2 +- .../entity/storage/ItemMonitorBlockEntity.kt | 2 +- .../entity/storage/StorageBusBlockEntity.kt | 1 + .../block/entity/storage/StorageInterfaces.kt | 2 + .../StoragePowerSupplierBlockEntity.kt | 2 +- .../entity/tech/PlatePressBlockEntity.kt | 2 +- .../otm/capability/MatteryPlayerCapability.kt | 1 + .../energy/BlockEnergyStorageImpl.kt | 40 ++++++++++++------- .../capability/matter/MatterStorageImpl.kt | 4 +- .../mc/otm/client/ClientEventHandler.kt | 2 +- .../mc/otm/client/render/ShockwaveRenderer.kt | 2 +- .../mc/otm/client/screen/MatteryScreen.kt | 2 +- .../mc/otm/config/BatteryBalanceValues.kt | 7 ++++ .../mc/otm/{ => config}/ClientConfig.kt | 2 +- .../mc/otm/config/ConciseBalanceValues.kt | 8 ++++ .../mc/otm/{ => config}/ConfigExt.kt | 2 +- .../otm/{ => config}/ObservedConfigValue.kt | 2 +- .../mc/otm/{ => config}/ServerConfig.kt | 17 +------- .../mc/otm/config/VerboseBalanceValues.kt | 9 +++++ .../dbotthepony/mc/otm/core/math/Decimal.kt | 2 +- .../item/AbstractExoPackSlotUpgradeItem.kt | 2 +- .../ru/dbotthepony/mc/otm/item/BatteryItem.kt | 4 +- .../dbotthepony/mc/otm/item/MatterDustItem.kt | 2 +- .../dbotthepony/mc/otm/item/MatteryAxeItem.kt | 2 +- .../mc/otm/item/QuantumBatteryItem.kt | 1 + .../mc/otm/item/SingleUseBatteryItem.kt | 4 +- .../mc/otm/matter/MatterManager.kt | 4 +- .../ru/dbotthepony/mc/otm/registry/MItems.kt | 2 +- 44 files changed, 96 insertions(+), 69 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/config/BatteryBalanceValues.kt rename src/main/kotlin/ru/dbotthepony/mc/otm/{ => config}/ClientConfig.kt (97%) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/config/ConciseBalanceValues.kt rename src/main/kotlin/ru/dbotthepony/mc/otm/{ => config}/ConfigExt.kt (94%) rename src/main/kotlin/ru/dbotthepony/mc/otm/{ => config}/ObservedConfigValue.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/{ => config}/ServerConfig.kt (97%) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/config/VerboseBalanceValues.kt diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 0d7fab0ca..8a5ff8191 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -35,6 +35,8 @@ import ru.dbotthepony.mc.otm.client.render.blockentity.BatteryBankRenderer; import ru.dbotthepony.mc.otm.client.render.blockentity.MatterBatteryBankRenderer; import ru.dbotthepony.mc.otm.compat.mekanism.QIOKt; import ru.dbotthepony.mc.otm.compat.mekanism.TooltipsKt; +import ru.dbotthepony.mc.otm.config.ClientConfig; +import ru.dbotthepony.mc.otm.config.ServerConfig; import ru.dbotthepony.mc.otm.core.math.Decimal; import ru.dbotthepony.mc.otm.item.ItemTritaniumArmor; import ru.dbotthepony.mc.otm.item.QuantumBatteryItem; diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/ObservedConfigList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/ObservedConfigList.kt index 0c2c192d0..7a9493536 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/ObservedConfigList.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/ObservedConfigList.kt @@ -4,6 +4,7 @@ import it.unimi.dsi.fastutil.ints.IntArrayList import net.minecraft.resources.ResourceLocation import net.minecraftforge.common.ForgeConfigSpec import net.minecraftforge.registries.IForgeRegistry +import ru.dbotthepony.mc.otm.config.getValue import java.util.LinkedList abstract class ObservedConfigList(val parent: ForgeConfigSpec.ConfigValue>, private val allowNulls: Boolean = false) : AbstractMutableList(), RandomAccess { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt index c2d188d86..3a2a0341d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt @@ -26,7 +26,7 @@ import net.minecraftforge.event.ForgeEventFactory import net.minecraftforge.event.entity.living.LivingDeathEvent import ru.dbotthepony.mc.otm.NULLABLE_MINECRAFT_SERVER import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.ServerConfig +import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.android.AndroidActiveFeature import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt index c942434be..c4f3d6506 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt @@ -5,10 +5,10 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import net.minecraftforge.event.entity.living.LivingHurtEvent import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.ServerConfig import ru.dbotthepony.mc.otm.android.AndroidFeature import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability +import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.registry.AndroidFeatures diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt index 50ad23633..06272adeb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt @@ -9,7 +9,7 @@ import net.minecraft.world.entity.Entity import net.minecraft.world.entity.item.ItemEntity import net.minecraftforge.network.NetworkEvent import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.ServerConfig +import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt index b45f18fbe..46368a359 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt @@ -8,9 +8,9 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import net.minecraft.sounds.SoundSource import net.minecraftforge.network.NetworkEvent -import ru.dbotthepony.mc.otm.ClientConfig +import ru.dbotthepony.mc.otm.config.ClientConfig import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.ServerConfig +import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsRegenerationFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsRegenerationFeature.kt index 7af4d40aa..907a7997f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsRegenerationFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsRegenerationFeature.kt @@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.android.feature import net.minecraft.nbt.CompoundTag import net.minecraft.server.level.ServerPlayer import net.minecraftforge.event.entity.living.LivingHurtEvent -import ru.dbotthepony.mc.otm.ServerConfig +import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.android.AndroidFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.registry.AndroidFeatures diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt index 3f0e2d4f0..24914ebdc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt @@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.android.feature import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.world.effect.MobEffectInstance import net.minecraft.world.effect.MobEffects -import ru.dbotthepony.mc.otm.ServerConfig +import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt index 214c7f7ab..932235b7a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt @@ -13,7 +13,7 @@ import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.monster.warden.Warden import net.minecraftforge.network.NetworkEvent import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.ServerConfig +import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt index 42afb0f0d..17ace9ebe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt @@ -20,7 +20,7 @@ import net.minecraft.world.level.material.Material import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.Shapes import net.minecraft.world.phys.shapes.VoxelShape -import ru.dbotthepony.mc.otm.ServerConfig +import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index 32109a4a2..bfd1ebad7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -17,7 +17,7 @@ import net.minecraftforge.common.ForgeConfigSpec import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.LazyOptional -import ru.dbotthepony.mc.otm.ConciseBalanceValues +import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index 2b6c5a25c..ddb55e1da 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -17,7 +17,7 @@ import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.items.IItemHandler -import ru.dbotthepony.mc.otm.ConciseBalanceValues +import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index 66bbb4c06..92530b835 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -17,7 +17,7 @@ import net.minecraftforge.common.ForgeConfigSpec.ConfigValue import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.LazyOptional -import ru.dbotthepony.mc.otm.ConciseBalanceValues +import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index 1304e51ec..fd2f060a3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -16,7 +16,7 @@ import net.minecraftforge.common.ForgeConfigSpec import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.LazyOptional -import ru.dbotthepony.mc.otm.ConciseBalanceValues +import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt index be8ab1bb4..f61f3d1d0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt @@ -16,7 +16,7 @@ import net.minecraftforge.common.ForgeConfigSpec import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.LazyOptional -import ru.dbotthepony.mc.otm.ConciseBalanceValues +import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt index 8984c1174..c303195c4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt @@ -13,7 +13,7 @@ import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.util.LazyOptional -import ru.dbotthepony.mc.otm.ServerConfig +import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode import ru.dbotthepony.mc.otm.capability.MatteryCapability diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt index bb869d7ca..695a76878 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt @@ -11,7 +11,7 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.ServerConfig +import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.storage.DriveViewerBlock 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 31cf89889..acb7bf6ee 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 @@ -25,7 +25,7 @@ import net.minecraftforge.common.util.INBTSerializable import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.network.NetworkEvent import org.apache.logging.log4j.LogManager -import ru.dbotthepony.mc.otm.ServerConfig +import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryCapability diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt index c37b24102..eb18f3b4e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt @@ -24,6 +24,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.AbstractStorageImportExport.Companion.FILTER_KEY import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt index 19c4b3342..072a8f8d2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt @@ -23,6 +23,8 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact +import ru.dbotthepony.mc.otm.config.ConciseBalanceValues +import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt index 16c54f5e6..634290bd5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt @@ -13,7 +13,7 @@ import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.ServerConfig +import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryCapability 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 aeb8085a4..1cea0a3e6 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 @@ -16,7 +16,7 @@ import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.LazyOptional -import ru.dbotthepony.mc.otm.ServerConfig +import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.core.TranslatableComponent diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 8d1dcfef7..1e0545cdd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -46,6 +46,7 @@ import ru.dbotthepony.mc.otm.android.AndroidResearchType import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.energy.AndroidPowerSource import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.stream import ru.dbotthepony.mc.otm.core.* diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt index e3d73b061..0ec7c4e1f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt @@ -13,8 +13,8 @@ import net.minecraft.world.level.block.entity.BlockEntity import net.minecraftforge.common.ForgeConfigSpec import net.minecraftforge.common.util.INBTSerializable import net.minecraftforge.common.util.LazyOptional -import ru.dbotthepony.mc.otm.ConciseBalanceValues -import ru.dbotthepony.mc.otm.VerboseBalanceValues +import ru.dbotthepony.mc.otm.config.ConciseBalanceValues +import ru.dbotthepony.mc.otm.config.VerboseBalanceValues import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.core.math.Decimal @@ -196,19 +196,23 @@ open class WorkerEnergyStorage( constructor( listener: () -> Unit, - values: ConciseBalanceValues) : this(listener, values::capacity, values::throughput, values::throughput) + values: ConciseBalanceValues + ) : this(listener, values::capacity, values::throughput, values::throughput) constructor( listener: BlockEntity, - values: ConciseBalanceValues) : this(listener::setChanged, values::capacity, values::throughput, values::throughput) + values: ConciseBalanceValues + ) : this(listener::setChanged, values::capacity, values::throughput, values::throughput) constructor( listener: () -> Unit, - values: VerboseBalanceValues) : this(listener, values::capacity, values::receive, values::extract) + values: VerboseBalanceValues + ) : this(listener, values::capacity, values::receive, values::extract) constructor( listener: BlockEntity, - values: VerboseBalanceValues) : this(listener::setChanged, values::capacity, values::receive, values::extract) + values: VerboseBalanceValues + ) : this(listener::setChanged, values::capacity, values::receive, values::extract) constructor( listener: BlockEntity, @@ -244,19 +248,23 @@ open class GeneratorEnergyStorage( constructor( listener: () -> Unit, - values: ConciseBalanceValues) : this(listener, values::capacity, values::throughput, values::throughput) + values: ConciseBalanceValues + ) : this(listener, values::capacity, values::throughput, values::throughput) constructor( listener: BlockEntity, - values: ConciseBalanceValues) : this(listener::setChanged, values::capacity, values::throughput, values::throughput) + values: ConciseBalanceValues + ) : this(listener::setChanged, values::capacity, values::throughput, values::throughput) constructor( listener: () -> Unit, - values: VerboseBalanceValues) : this(listener, values::capacity, values::receive, values::extract) + values: VerboseBalanceValues + ) : this(listener, values::capacity, values::receive, values::extract) constructor( listener: BlockEntity, - values: VerboseBalanceValues) : this(listener::setChanged, values::capacity, values::receive, values::extract) + values: VerboseBalanceValues + ) : this(listener::setChanged, values::capacity, values::receive, values::extract) constructor( listener: BlockEntity, @@ -292,19 +300,23 @@ open class CapacitorEnergyStorage( constructor( listener: () -> Unit, - values: ConciseBalanceValues) : this(listener, values::capacity, values::throughput, values::throughput) + values: ConciseBalanceValues + ) : this(listener, values::capacity, values::throughput, values::throughput) constructor( listener: BlockEntity, - values: ConciseBalanceValues) : this(listener::setChanged, values::capacity, values::throughput, values::throughput) + values: ConciseBalanceValues + ) : this(listener::setChanged, values::capacity, values::throughput, values::throughput) constructor( listener: () -> Unit, - values: VerboseBalanceValues) : this(listener, values::capacity, values::receive, values::extract) + values: VerboseBalanceValues + ) : this(listener, values::capacity, values::receive, values::extract) constructor( listener: BlockEntity, - values: VerboseBalanceValues) : this(listener::setChanged, values::capacity, values::receive, values::extract) + values: VerboseBalanceValues + ) : this(listener::setChanged, values::capacity, values::receive, values::extract) constructor( listener: BlockEntity, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt index 80482af86..eaa9de819 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt @@ -3,8 +3,8 @@ package ru.dbotthepony.mc.otm.capability.matter import net.minecraft.nbt.CompoundTag import net.minecraftforge.common.util.INBTSerializable import net.minecraftforge.common.util.LazyOptional -import ru.dbotthepony.mc.otm.ConciseBalanceValues -import ru.dbotthepony.mc.otm.VerboseBalanceValues +import ru.dbotthepony.mc.otm.config.ConciseBalanceValues +import ru.dbotthepony.mc.otm.config.VerboseBalanceValues import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.nbt.set diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt index 0e2ef890d..17138d59a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt @@ -12,7 +12,7 @@ import net.minecraftforge.client.event.MovementInputUpdateEvent import net.minecraftforge.client.event.ScreenEvent import net.minecraftforge.client.event.ScreenEvent.MouseDragged import net.minecraftforge.client.event.ScreenEvent.MouseScrolled -import ru.dbotthepony.mc.otm.ClientConfig +import ru.dbotthepony.mc.otm.config.ClientConfig import ru.dbotthepony.mc.otm.android.feature.JumpBoostFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ShockwaveRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ShockwaveRenderer.kt index 4d1a8b57c..b3b842c97 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ShockwaveRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ShockwaveRenderer.kt @@ -7,7 +7,7 @@ import com.mojang.blaze3d.vertex.VertexFormat import net.minecraft.client.renderer.GameRenderer import net.minecraftforge.client.event.RenderLevelStageEvent import org.lwjgl.opengl.GL11.GL_LESS -import ru.dbotthepony.mc.otm.ServerConfig +import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.math.component1 import ru.dbotthepony.mc.otm.core.math.component2 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 394c95677..41dee7093 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 @@ -17,7 +17,7 @@ import net.minecraftforge.client.event.ContainerScreenEvent.Render.Foreground import net.minecraftforge.common.MinecraftForge import org.lwjgl.opengl.GL11 import org.lwjgl.opengl.GL13 -import ru.dbotthepony.mc.otm.ClientConfig +import ru.dbotthepony.mc.otm.config.ClientConfig import ru.dbotthepony.mc.otm.client.moveMousePosScaled import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/BatteryBalanceValues.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/BatteryBalanceValues.kt new file mode 100644 index 000000000..5cb55730a --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/BatteryBalanceValues.kt @@ -0,0 +1,7 @@ +package ru.dbotthepony.mc.otm.config + +import ru.dbotthepony.mc.otm.core.math.Decimal + +interface BatteryBalanceValues : VerboseBalanceValues { + val initialBatteryLevel: Decimal +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/ClientConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ClientConfig.kt similarity index 97% rename from src/main/kotlin/ru/dbotthepony/mc/otm/ClientConfig.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/config/ClientConfig.kt index be0e59dfd..4327156de 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/ClientConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ClientConfig.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm +package ru.dbotthepony.mc.otm.config import net.minecraftforge.common.ForgeConfigSpec import net.minecraftforge.fml.ModLoadingContext diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ConciseBalanceValues.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ConciseBalanceValues.kt new file mode 100644 index 000000000..06b3e90bd --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ConciseBalanceValues.kt @@ -0,0 +1,8 @@ +package ru.dbotthepony.mc.otm.config + +import ru.dbotthepony.mc.otm.core.math.Decimal + +interface ConciseBalanceValues { + val capacity: Decimal + val throughput: Decimal +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/ConfigExt.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ConfigExt.kt similarity index 94% rename from src/main/kotlin/ru/dbotthepony/mc/otm/ConfigExt.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/config/ConfigExt.kt index aedd29ba9..9febd526a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/ConfigExt.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ConfigExt.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm +package ru.dbotthepony.mc.otm.config import net.minecraftforge.common.ForgeConfigSpec import kotlin.reflect.KProperty diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/ObservedConfigValue.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ObservedConfigValue.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/ObservedConfigValue.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/config/ObservedConfigValue.kt index 4aa7953a8..6f8caa5e4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/ObservedConfigValue.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ObservedConfigValue.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm +package ru.dbotthepony.mc.otm.config import net.minecraftforge.common.ForgeConfigSpec.ConfigValue import org.apache.logging.log4j.LogManager diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/ServerConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt similarity index 97% rename from src/main/kotlin/ru/dbotthepony/mc/otm/ServerConfig.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt index 44c4018cc..e55be2c01 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/ServerConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm +package ru.dbotthepony.mc.otm.config import net.minecraftforge.common.ForgeConfigSpec import net.minecraftforge.fml.ModLoadingContext @@ -16,21 +16,6 @@ import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.item.EnergySwordItem import ru.dbotthepony.mc.otm.registry.MNames -interface VerboseBalanceValues { - val capacity: Decimal - val receive: Decimal - val extract: Decimal -} - -interface BatteryBalanceValues : VerboseBalanceValues { - val initialBatteryLevel: Decimal -} - -interface ConciseBalanceValues { - val capacity: Decimal - val throughput: Decimal -} - object ServerConfig { private val specBuilder = ForgeConfigSpec.Builder() @Suppress("JoinDeclarationAndAssignment") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/VerboseBalanceValues.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/VerboseBalanceValues.kt new file mode 100644 index 000000000..9b50f3bc2 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/VerboseBalanceValues.kt @@ -0,0 +1,9 @@ +package ru.dbotthepony.mc.otm.config + +import ru.dbotthepony.mc.otm.core.math.Decimal + +interface VerboseBalanceValues { + val capacity: Decimal + val receive: Decimal + val extract: Decimal +} 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 59683671a..768cdd6ce 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 @@ -6,7 +6,7 @@ import net.minecraft.nbt.StringTag import net.minecraft.nbt.Tag import net.minecraft.network.FriendlyByteBuf import net.minecraftforge.common.ForgeConfigSpec -import ru.dbotthepony.mc.otm.ObservedConfigValue +import ru.dbotthepony.mc.otm.config.ObservedConfigValue import ru.dbotthepony.mc.otm.core.util.readDouble import ru.dbotthepony.mc.otm.core.util.readVarIntLE import ru.dbotthepony.mc.otm.core.util.writeDouble diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/AbstractExoPackSlotUpgradeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/AbstractExoPackSlotUpgradeItem.kt index f4e757762..37f7b0d12 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/AbstractExoPackSlotUpgradeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/AbstractExoPackSlotUpgradeItem.kt @@ -15,7 +15,7 @@ import net.minecraft.world.item.TooltipFlag import net.minecraft.world.item.UseAnim import net.minecraft.world.level.Level import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.ServerConfig +import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.TranslatableComponent diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt index 1c92144ac..74f2eee84 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt @@ -14,8 +14,8 @@ import net.minecraft.world.item.* import net.minecraft.world.level.Level import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.capabilities.ICapabilityProvider -import ru.dbotthepony.mc.otm.BatteryBalanceValues -import ru.dbotthepony.mc.otm.ServerConfig +import ru.dbotthepony.mc.otm.config.BatteryBalanceValues +import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.EnergyCapacitorItem import ru.dbotthepony.mc.otm.capability.energy.ItemEnergyStorageImpl diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt index 90bcfd2cf..5c63d5b51 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt @@ -6,7 +6,7 @@ import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.Level -import ru.dbotthepony.mc.otm.ServerConfig +import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.matter.IMatterItem diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatteryAxeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatteryAxeItem.kt index a2de91551..631941d18 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatteryAxeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatteryAxeItem.kt @@ -5,7 +5,7 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Tier import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.material.Material -import ru.dbotthepony.mc.otm.ServerConfig +import ru.dbotthepony.mc.otm.config.ServerConfig class MatteryAxeItem(pTier: Tier, pAttackDamageModifier: Float, pAttackSpeedModifier: Float, pProperties: Properties) : AxeItem(pTier, pAttackDamageModifier, pAttackSpeedModifier, pProperties) { override fun getDestroySpeed(pStack: ItemStack, pState: BlockState): Float { 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 84373254a..50e9b1cc9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt @@ -28,6 +28,7 @@ import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.getBarColor import ru.dbotthepony.mc.otm.capability.energy.getBarWidth import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper +import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.readDecimal diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt index cce7ef7ee..a8b2fd133 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt @@ -9,9 +9,9 @@ import net.minecraft.world.item.Rarity import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.Level import net.minecraftforge.common.capabilities.ICapabilityProvider -import ru.dbotthepony.mc.otm.ConciseBalanceValues +import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.ServerConfig +import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.EnergyProducerItem import ru.dbotthepony.mc.otm.capability.energy.ItemEnergyStorageImpl diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index d39549e2a..b207035f8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -8,7 +8,6 @@ import com.google.gson.JsonElement import com.google.gson.JsonObject import com.google.gson.JsonParseException import com.google.gson.JsonSyntaxException -import com.mojang.blaze3d.platform.InputConstants import com.mojang.brigadier.arguments.StringArgumentType import com.mojang.brigadier.context.CommandContext import it.unimi.dsi.fastutil.objects.Object2BooleanFunction @@ -52,8 +51,7 @@ import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.ForgeRegistries import net.minecraftforge.server.command.EnumArgument import org.apache.logging.log4j.LogManager -import org.lwjgl.glfw.GLFW -import ru.dbotthepony.mc.otm.ClientConfig +import ru.dbotthepony.mc.otm.config.ClientConfig import ru.dbotthepony.mc.otm.MINECRAFT_SERVER import ru.dbotthepony.mc.otm.NULLABLE_MINECRAFT_SERVER import ru.dbotthepony.mc.otm.OverdriveThatMatters 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 56885842b..b4b410362 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -14,7 +14,7 @@ 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.ServerConfig +import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.core.collect.SupplierList import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.item.* From f0fadcc852d05b7d473e1210a2da2964c141f0d6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 9 Feb 2023 21:37:54 +0700 Subject: [PATCH 0187/1199] Split server config, energy sword discharge variance --- .../mc/otm/OverdriveThatMatters.java | 8 + .../android/feature/EnderTeleporterFeature.kt | 28 +- .../android/feature/FallDampenersFeature.kt | 6 +- .../otm/android/feature/ItemMagnetFeature.kt | 12 +- .../otm/android/feature/JumpBoostFeature.kt | 12 +- .../feature/NanobotsRegenerationFeature.kt | 8 +- .../otm/android/feature/NightVisionFeature.kt | 3 +- .../otm/android/feature/ShockwaveFeature.kt | 28 +- .../entity/storage/DriveRackBlockEntity.kt | 3 +- .../entity/storage/DriveViewerBlockEntity.kt | 3 +- .../entity/storage/ItemMonitorBlockEntity.kt | 3 +- .../entity/storage/StorageBusBlockEntity.kt | 3 +- .../block/entity/storage/StorageInterfaces.kt | 3 +- .../StoragePowerSupplierBlockEntity.kt | 5 +- .../entity/tech/PlatePressBlockEntity.kt | 3 +- .../otm/capability/MatteryPlayerCapability.kt | 29 +-- .../mc/otm/client/render/ShockwaveRenderer.kt | 3 +- .../mc/otm/config/AbstractConfig.kt | 20 ++ .../mc/otm/config/AndroidConfig.kt | 108 ++++++++ .../dbotthepony/mc/otm/config/ItemsConfig.kt | 92 +++++++ .../mc/otm/config/MachinesConfig.kt | 32 +++ .../dbotthepony/mc/otm/config/ServerConfig.kt | 244 +----------------- .../dbotthepony/mc/otm/config/ToolsConfig.kt | 11 + .../dbotthepony/mc/otm/core/math/Decimal.kt | 15 ++ .../ru/dbotthepony/mc/otm/item/BatteryItem.kt | 3 +- .../mc/otm/item/EnergySwordItem.kt | 32 ++- .../dbotthepony/mc/otm/item/MatterDustItem.kt | 7 +- .../dbotthepony/mc/otm/item/MatteryAxeItem.kt | 4 +- .../mc/otm/item/SingleUseBatteryItem.kt | 3 +- .../ru/dbotthepony/mc/otm/registry/MItems.kt | 21 +- 30 files changed, 414 insertions(+), 338 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/config/ToolsConfig.kt diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 8a5ff8191..e14fd89a5 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -35,8 +35,12 @@ import ru.dbotthepony.mc.otm.client.render.blockentity.BatteryBankRenderer; import ru.dbotthepony.mc.otm.client.render.blockentity.MatterBatteryBankRenderer; import ru.dbotthepony.mc.otm.compat.mekanism.QIOKt; import ru.dbotthepony.mc.otm.compat.mekanism.TooltipsKt; +import ru.dbotthepony.mc.otm.config.AndroidConfig; import ru.dbotthepony.mc.otm.config.ClientConfig; +import ru.dbotthepony.mc.otm.config.ItemsConfig; +import ru.dbotthepony.mc.otm.config.MachinesConfig; import ru.dbotthepony.mc.otm.config.ServerConfig; +import ru.dbotthepony.mc.otm.config.ToolsConfig; import ru.dbotthepony.mc.otm.core.math.Decimal; import ru.dbotthepony.mc.otm.item.ItemTritaniumArmor; import ru.dbotthepony.mc.otm.item.QuantumBatteryItem; @@ -125,6 +129,10 @@ public final class OverdriveThatMatters { ClientConfig.INSTANCE.register(); ServerConfig.INSTANCE.register(); + AndroidConfig.INSTANCE.register(); + ItemsConfig.INSTANCE.register(); + MachinesConfig.INSTANCE.register(); + ToolsConfig.INSTANCE.register(); } private void setup(final FMLCommonSetupEvent event) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt index 3a2a0341d..a03bc1074 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt @@ -26,7 +26,6 @@ import net.minecraftforge.event.ForgeEventFactory import net.minecraftforge.event.entity.living.LivingDeathEvent import ru.dbotthepony.mc.otm.NULLABLE_MINECRAFT_SERVER import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.android.AndroidActiveFeature import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability @@ -36,6 +35,7 @@ import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.client.render.sprite import ru.dbotthepony.mc.otm.client.render.linesIgnoreZRenderType +import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.math.asVector import ru.dbotthepony.mc.otm.core.math.component1 @@ -61,10 +61,10 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv private set override val maxCooldown: Int - get() = ServerConfig.EnderTeleporter.COOLDOWN + get() = AndroidConfig.EnderTeleporter.COOLDOWN private fun canUse(): Boolean { - return !isOnCooldown && android.androidEnergy.extractEnergyExact(ServerConfig.EnderTeleporter.ENERGY_COST, true) + return !isOnCooldown && android.androidEnergy.extractEnergyExact(AndroidConfig.EnderTeleporter.ENERGY_COST, true) } private fun isValidGround(blockPos: BlockPos): Boolean { @@ -113,14 +113,14 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv } private fun tryToPhaseThroughWall(blockPos: BlockPos, normal: Vec3i): TraceResult? { - val phasedBlocks = ArrayList(ServerConfig.EnderTeleporter.MAX_PHASE_DISTANCE) + val phasedBlocks = ArrayList(AndroidConfig.EnderTeleporter.MAX_PHASE_DISTANCE) phasedBlocks.add(blockPos) - for (extend in 1 .. ServerConfig.EnderTeleporter.MAX_PHASE_DISTANCE) { + for (extend in 1 .. AndroidConfig.EnderTeleporter.MAX_PHASE_DISTANCE) { val pos = blockPos + normal * extend if (isAirGap(pos)) { - for (y in 0 .. ServerConfig.EnderTeleporter.MAX_PHASE_DISTANCE - extend) { + for (y in 0 .. AndroidConfig.EnderTeleporter.MAX_PHASE_DISTANCE - extend) { val newPos = BlockPos(pos.x, pos.y - y, pos.z) if (isValidPosition(newPos)) { @@ -143,7 +143,7 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv val result = ply.level.clip(ClipContext( headPosition, - headPosition + aimVector * (ServerConfig.EnderTeleporter.MAX_DISTANCE * 2.0), + headPosition + aimVector * (AndroidConfig.EnderTeleporter.MAX_DISTANCE * 2.0), ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, ply @@ -159,7 +159,7 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv !ply.isShiftKeyDown && result.direction == Direction.UP && isValidPosition(result.blockPos.above()) && - shortestDistanceBetween(testPositions, result.blockPos.above().asVector()) <= ServerConfig.EnderTeleporter.MAX_DISTANCE + shortestDistanceBetween(testPositions, result.blockPos.above().asVector()) <= AndroidConfig.EnderTeleporter.MAX_DISTANCE ) { return TraceResult(result.blockPos.above()) } @@ -217,14 +217,14 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv if (!isAirGap(pos)) { phasedBlocks++ - if (phasedBlocks >= ServerConfig.EnderTeleporter.MAX_PHASE_DISTANCE) { + if (phasedBlocks >= AndroidConfig.EnderTeleporter.MAX_PHASE_DISTANCE) { break } phasedBlocksList.add(pos) } - if (shortestDistanceBetween(testPositions, pos.asVector()) > ServerConfig.EnderTeleporter.MAX_DISTANCE) { + if (shortestDistanceBetween(testPositions, pos.asVector()) > AndroidConfig.EnderTeleporter.MAX_DISTANCE) { break } @@ -271,14 +271,14 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv if (!isAirGap(pos)) { phasedBlocks++ - if (phasedBlocks >= ServerConfig.EnderTeleporter.MAX_PHASE_DISTANCE) { + if (phasedBlocks >= AndroidConfig.EnderTeleporter.MAX_PHASE_DISTANCE) { break } phasedBlocksList.add(pos) } - if (shortestDistanceBetween(testPositions, pos.asVector()) > ServerConfig.EnderTeleporter.MAX_DISTANCE) { + if (shortestDistanceBetween(testPositions, pos.asVector()) > AndroidConfig.EnderTeleporter.MAX_DISTANCE) { break } @@ -309,7 +309,7 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv putOnCooldown() lastTeleport = ply.server!!.tickCount - android.androidEnergy.extractEnergy(ServerConfig.EnderTeleporter.ENERGY_COST, false) + android.androidEnergy.extractEnergy(AndroidConfig.EnderTeleporter.ENERGY_COST, false) ply.level.playSound(null, ply, SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 0.3f, 0.8f + ply.level.random.nextFloat() * 0.4f) ply.teleportTo(event.targetX, event.targetY, event.targetZ) @@ -400,7 +400,7 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv AndroidResearchManager.descriptionFunc( ResourceLocation(OverdriveThatMatters.MOD_ID, MNames.ENDER_TELEPORTER), "otm.gui.power_cost_per_use", - { ServerConfig.EnderTeleporter.ENERGY_COST.formatPower().copy().withStyle(ChatFormatting.YELLOW) }) + { AndroidConfig.EnderTeleporter.ENERGY_COST.formatPower().copy().withStyle(ChatFormatting.YELLOW) }) fun onEntityDeath(event: LivingDeathEvent) { val android = event.entity.matteryPlayer ?: return diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt index c4f3d6506..96e3180c2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt @@ -8,7 +8,7 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.android.AndroidFeature import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability -import ru.dbotthepony.mc.otm.config.ServerConfig +import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.registry.AndroidFeatures @@ -18,7 +18,7 @@ import ru.dbotthepony.mc.otm.triggers.FallDampenersSaveTrigger class FallDampenersFeature(capability: MatteryPlayerCapability) : AndroidFeature(AndroidFeatures.FALL_DAMPENERS, capability) { override fun onHurt(event: LivingHurtEvent) { if (event.source.isFall) { - val reduction = (ServerConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL * (level + 1)).toFloat() + val reduction = (AndroidConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL * (level + 1)).toFloat() val old = event.amount @@ -37,7 +37,7 @@ class FallDampenersFeature(capability: MatteryPlayerCapability) : AndroidFeature companion object { val DESCRIPTION = AndroidResearchManager.descriptionFuncs.register(ResourceLocation(OverdriveThatMatters.MOD_ID, MNames.FALL_DAMPENERS)) { level: Int -> - TranslatableComponent("otm.fall_dampeners.description", TextComponent("%.1f".format((ServerConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL * level).toFloat().coerceAtLeast(0f).coerceAtMost(1f) * 100f)).withStyle(ChatFormatting.YELLOW)) + TranslatableComponent("otm.fall_dampeners.description", TextComponent("%.1f".format((AndroidConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL * level).toFloat().coerceAtLeast(0f).coerceAtMost(1f) * 100f)).withStyle(ChatFormatting.YELLOW)) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt index 06272adeb..6542e1513 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt @@ -9,7 +9,7 @@ import net.minecraft.world.entity.Entity import net.minecraft.world.entity.item.ItemEntity import net.minecraftforge.network.NetworkEvent import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.config.ServerConfig +import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability @@ -73,13 +73,13 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable private val clientPredicate = Predicate { it is ItemEntity && (datatable[it] ?: SharedItemEntityData.EMPTY).let { !it.hasPickupDelay && (it.owner == null || it.owner != ply.uuid || it.lifespan - it.age <= 200) } } private fun doTick(server: Boolean) { - if (ply.isSpectator || server && !android.androidEnergy.extractEnergyExact(ServerConfig.AndroidItemMagnet.POWER_DRAW, true)) { + if (ply.isSpectator || server && !android.androidEnergy.extractEnergyExact(AndroidConfig.Magnet.POWER_DRAW, true)) { return } val entities = ply.level.getEntitiesInEllipsoid( ply.position, - Vector(ServerConfig.AndroidItemMagnet.RADIUS_HORIZONTAL, ServerConfig.AndroidItemMagnet.RADIUS_VERTICAL, ServerConfig.AndroidItemMagnet.RADIUS_HORIZONTAL), + Vector(AndroidConfig.Magnet.RADIUS_HORIZONTAL, AndroidConfig.Magnet.RADIUS_VERTICAL, AndroidConfig.Magnet.RADIUS_HORIZONTAL), if (server) Predicate { it is ItemEntity } else clientPredicate ) @@ -98,7 +98,7 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable if (data.position.distanceToSqr(ent.position) < 1.0) { data.ticksSinceActivity++ } else { - if (!android.androidEnergy.extractEnergyExact(ServerConfig.AndroidItemMagnet.POWER_DRAW, false)) { + if (!android.androidEnergy.extractEnergyExact(AndroidConfig.Magnet.POWER_DRAW, false)) { return } @@ -114,7 +114,7 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable override fun tickClient() { super.tickClient() - if (!ply.isSpectator && isActive && android.androidEnergy.extractEnergyExact(ServerConfig.AndroidItemMagnet.POWER_DRAW, true)) { + if (!ply.isSpectator && isActive && android.androidEnergy.extractEnergyExact(AndroidConfig.Magnet.POWER_DRAW, true)) { doTick(false) } } @@ -136,6 +136,6 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable AndroidResearchManager.descriptionFunc(ResourceLocation( OverdriveThatMatters.MOD_ID, MNames.ITEM_MAGNET), "otm.gui.power_cost_per_tick", - { ServerConfig.AndroidItemMagnet.POWER_DRAW.formatPower().copy().withStyle(ChatFormatting.YELLOW) }) + { AndroidConfig.Magnet.POWER_DRAW.formatPower().copy().withStyle(ChatFormatting.YELLOW) }) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt index 46368a359..29db42b6d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt @@ -10,7 +10,7 @@ import net.minecraft.sounds.SoundSource import net.minecraftforge.network.NetworkEvent import ru.dbotthepony.mc.otm.config.ClientConfig import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.config.ServerConfig +import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability @@ -46,7 +46,7 @@ object TriggerJumpBoostPacket : MatteryPacket { val feature = mattery.getFeature(AndroidFeatures.JUMP_BOOST) as JumpBoostFeature? ?: return@enqueueWork - if (feature.isActive && feature.cooldown <= 4 && mattery.androidEnergy.extractEnergyExact(ServerConfig.AndroidJumpBoost.ENERGY_COST, false)) { + if (feature.isActive && feature.cooldown <= 4 && mattery.androidEnergy.extractEnergyExact(AndroidConfig.JumpBoost.ENERGY_COST, false)) { feature.putOnCooldown() context.sender?.let { @@ -68,7 +68,7 @@ class JumpBoostFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF private var tickCooldownClient = false override val maxCooldown: Int - get() = (ServerConfig.AndroidJumpBoost.BASE_COOLDOWN - ServerConfig.AndroidJumpBoost.COOLDOWN_REDUCTION * level).coerceAtLeast(0) + get() = (AndroidConfig.JumpBoost.BASE_COOLDOWN - AndroidConfig.JumpBoost.COOLDOWN_REDUCTION * level).coerceAtLeast(0) override var cooldown by synchronizer.int(setter = setter@{ value, access, setByRemote -> access.write(value) @@ -90,8 +90,8 @@ class JumpBoostFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF val old = lastGround lastGround = ply.isOnGround - if (isActive && cooldown <= 0 && old != lastGround && !lastGround && isJumping && isShifting && ply.xRot <= ClientConfig.JUMP_BOOST_LOOK_ANGLE && android.androidEnergy.extractEnergyExact(ServerConfig.AndroidJumpBoost.ENERGY_COST, true)) { - ply.deltaMovement += Vector(0.0, ServerConfig.AndroidJumpBoost.POWER * (level + 1) / 20.0, 0.0) + if (isActive && cooldown <= 0 && old != lastGround && !lastGround && isJumping && isShifting && ply.xRot <= ClientConfig.JUMP_BOOST_LOOK_ANGLE && android.androidEnergy.extractEnergyExact(AndroidConfig.JumpBoost.ENERGY_COST, true)) { + ply.deltaMovement += Vector(0.0, AndroidConfig.JumpBoost.POWER * (level + 1) / 20.0, 0.0) putOnCooldown() MatteryPlayerNetworkChannel.sendToServer(TriggerJumpBoostPacket) @@ -130,6 +130,6 @@ class JumpBoostFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF AndroidResearchManager.descriptionFunc( ResourceLocation(OverdriveThatMatters.MOD_ID, MNames.JUMP_BOOST), "otm.gui.power_cost_per_use", - { ServerConfig.AndroidJumpBoost.ENERGY_COST.formatPower().copy().withStyle(ChatFormatting.YELLOW) }) + { AndroidConfig.JumpBoost.ENERGY_COST.formatPower().copy().withStyle(ChatFormatting.YELLOW) }) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsRegenerationFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsRegenerationFeature.kt index 907a7997f..539fd57c4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsRegenerationFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsRegenerationFeature.kt @@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.android.feature import net.minecraft.nbt.CompoundTag import net.minecraft.server.level.ServerPlayer import net.minecraftforge.event.entity.living.LivingHurtEvent -import ru.dbotthepony.mc.otm.config.ServerConfig +import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.android.AndroidFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.registry.AndroidFeatures @@ -19,16 +19,16 @@ class NanobotsRegenerationFeature(android: MatteryPlayerCapability) : AndroidFea if (ply.health > 0f && ply.health < ply.maxHealth) { ticksPassed++ - val waitTime = ServerConfig.NanobotsRegeneration.COOLDOWN.getOrElse(healTicks) { ServerConfig.NanobotsRegeneration.COOLDOWN.last() } + val waitTime = AndroidConfig.NanobotsRegeneration.COOLDOWN.getOrElse(healTicks) { AndroidConfig.NanobotsRegeneration.COOLDOWN.last() } if (ticksPassed > waitTime) { val missingHealth = (ply.maxHealth - ply.health).coerceAtMost(2f) - val power = ServerConfig.NanobotsRegeneration.ENERGY_PER_HITPOINT * missingHealth + val power = AndroidConfig.NanobotsRegeneration.ENERGY_PER_HITPOINT * missingHealth val extracted = android.androidEnergy.extractEnergy(power, false) if (extracted.isPositive) { healTicks = (healTicks + 1).coerceAtMost(level) - val healed = (extracted / ServerConfig.NanobotsRegeneration.ENERGY_PER_HITPOINT).toFloat() + val healed = (extracted / AndroidConfig.NanobotsRegeneration.ENERGY_PER_HITPOINT).toFloat() ply.heal(healed) (ply as ServerPlayer?)?.awardStat(StatNames.HEALTH_REGENERATED, (healed * 10f).roundToInt()) ticksPassed = 0 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt index 24914ebdc..d5d9a2d89 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt @@ -8,6 +8,7 @@ import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.client.render.ResearchIcons +import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.registry.AndroidFeatures class NightVisionFeature(android: MatteryPlayerCapability) : AndroidSwitchableFeature(AndroidFeatures.NIGHT_VISION, android) { @@ -18,7 +19,7 @@ class NightVisionFeature(android: MatteryPlayerCapability) : AndroidSwitchableFe if (isActive) { val effect = android.ply.activeEffectsMap[MobEffects.NIGHT_VISION] - if ((effect == null || effect.duration < 220) && (ply.isSpectator || android.androidEnergy.extractEnergyExact(ServerConfig.NIGHT_VISION_POWER_DRAW, false))) { + if ((effect == null || effect.duration < 220) && (ply.isSpectator || android.androidEnergy.extractEnergyExact(AndroidConfig.NIGHT_VISION_POWER_DRAW, false))) { android.ply.addEffect(MobEffectInstance(MobEffects.NIGHT_VISION, 220, 0, false, false)) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt index 932235b7a..7ac93da7c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt @@ -13,7 +13,7 @@ import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.monster.warden.Warden import net.minecraftforge.network.NetworkEvent import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.config.ServerConfig +import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability @@ -68,7 +68,7 @@ object TriggerShockwavePacket : MatteryPacket { class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableFeature(AndroidFeatures.SHOCKWAVE, capability) { override val maxCooldown: Int - get() = ServerConfig.Shockwave.COOLDOWN + get() = AndroidConfig.Shockwave.COOLDOWN private var wasMidair = false private var highestSpeed = 0.0 @@ -83,18 +83,18 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF isActive && ply.isShiftKeyDown && !isOnCooldown && - android.androidEnergy.extractEnergyExact(ServerConfig.Shockwave.ENERGY_COST, true) && + android.androidEnergy.extractEnergyExact(AndroidConfig.Shockwave.ENERGY_COST, true) && ply.deltaMovement.y < -0.01 && creativeFlightTicks == 0 ) { - ply.deltaMovement += Vector(0.0, -ServerConfig.Shockwave.ACCELERATION / 20.0, 0.0) + ply.deltaMovement += Vector(0.0, -AndroidConfig.Shockwave.ACCELERATION / 20.0, 0.0) } ticker(true) } fun shockwave() { - if (ply.isSpectator || isOnCooldown || !android.androidEnergy.extractEnergyExact(ServerConfig.Shockwave.ENERGY_COST, false)) { + if (ply.isSpectator || isOnCooldown || !android.androidEnergy.extractEnergyExact(AndroidConfig.Shockwave.ENERGY_COST, false)) { return } @@ -117,14 +117,14 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF // TODO: raycasting val entities = ply.level.getEntitiesInEllipsoid( ply.position, - Vector(ServerConfig.Shockwave.RADIUS_HORIZONTAL, ServerConfig.Shockwave.RADIUS_VERTICAL, ServerConfig.Shockwave.RADIUS_HORIZONTAL), + Vector(AndroidConfig.Shockwave.RADIUS_HORIZONTAL, AndroidConfig.Shockwave.RADIUS_VERTICAL, AndroidConfig.Shockwave.RADIUS_HORIZONTAL), except = ply, ) { (it !is LivingEntity || !it.isSpectator && it.isAlive) } val wardens = ply.level.getEntitiesInEllipsoid( Warden::class.java, ply.position, - Vector(ServerConfig.Shockwave.RADIUS_HORIZONTAL_WARDEN, ServerConfig.Shockwave.RADIUS_VERTICAL_WARDEN, ServerConfig.Shockwave.RADIUS_HORIZONTAL_WARDEN), + Vector(AndroidConfig.Shockwave.RADIUS_HORIZONTAL_WARDEN, AndroidConfig.Shockwave.RADIUS_VERTICAL_WARDEN, AndroidConfig.Shockwave.RADIUS_HORIZONTAL_WARDEN), ) { true } val seen = ReferenceArraySet() @@ -134,7 +134,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF val multiplier = (1.0 - distanceMultiplier).pow(0.5) val source = ShockwaveDamageSource(ply) - val damage = multiplier.toFloat() * ServerConfig.Shockwave.DAMAGE.toFloat() * ServerConfig.Shockwave.WARDEN_DAMAGE_MULT.toFloat() + val damage = multiplier.toFloat() * AndroidConfig.Shockwave.DAMAGE.toFloat() * AndroidConfig.Shockwave.WARDEN_DAMAGE_MULT.toFloat() entity.hurt(source, damage) entity.deltaMovement += (entity.position - ply.position).normalize() * (multiplier * 3.0) @@ -150,7 +150,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF // don't hurt items, arrows, etc etc if (entity is LivingEntity) { val source = ShockwaveDamageSource(ply) - val damage = multiplier.toFloat() * ServerConfig.Shockwave.DAMAGE.toFloat() + val damage = multiplier.toFloat() * AndroidConfig.Shockwave.DAMAGE.toFloat() entity.hurt(source, damage) entity.deltaMovement += (entity.position - ply.position).normalize() * (multiplier * 3.0) @@ -163,10 +163,10 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF } } - if (ServerConfig.Shockwave.BREAK_BLOCKS) { + if (AndroidConfig.Shockwave.BREAK_BLOCKS) { val rounded = ply.position.roundToIntVector() - for (blockPos in getEllipsoidBlockPositions(ServerConfig.Shockwave.RADIUS_HORIZONTAL.roundToInt(), ServerConfig.Shockwave.RADIUS_VERTICAL.roundToInt(), ServerConfig.Shockwave.RADIUS_HORIZONTAL.roundToInt())) { + for (blockPos in getEllipsoidBlockPositions(AndroidConfig.Shockwave.RADIUS_HORIZONTAL.roundToInt(), AndroidConfig.Shockwave.RADIUS_VERTICAL.roundToInt(), AndroidConfig.Shockwave.RADIUS_HORIZONTAL.roundToInt())) { val newBlockPos = blockPos + rounded val blockState = ply.level.getBlockState(newBlockPos) @@ -199,7 +199,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF !ply.isSpectator && isActive && !isOnCooldown && - android.androidEnergy.extractEnergyExact(ServerConfig.Shockwave.ENERGY_COST, true) && + android.androidEnergy.extractEnergyExact(AndroidConfig.Shockwave.ENERGY_COST, true) && creativeFlightTicks == 0 ) { val old = wasMidair @@ -209,7 +209,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF highestSpeed = (-ply.deltaMovement.y).coerceAtLeast(highestSpeed) } - if (old != wasMidair && !wasMidair && ServerConfig.Shockwave.TERMINAL_VELOCITY <= (highestSpeed * 20.0) && ply.isShiftKeyDown) { + if (old != wasMidair && !wasMidair && AndroidConfig.Shockwave.TERMINAL_VELOCITY <= (highestSpeed * 20.0) && ply.isShiftKeyDown) { if (isClient) { // I HATE SELF-UPDATING PLAYERS // I HATE SELF-UPDATING PLAYERS @@ -253,6 +253,6 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF AndroidResearchManager.descriptionFunc( ResourceLocation(OverdriveThatMatters.MOD_ID, MNames.SHOCKWAVE), "otm.gui.power_cost_per_use", - { ServerConfig.Shockwave.ENERGY_COST.formatPower().copy().withStyle(ChatFormatting.YELLOW) }) + { AndroidConfig.Shockwave.ENERGY_COST.formatPower().copy().withStyle(ChatFormatting.YELLOW) }) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt index c303195c4..776b4fa85 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt @@ -18,6 +18,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.menu.storage.DriveRackMenu import ru.dbotthepony.mc.otm.core.nbt.map @@ -29,7 +30,7 @@ import ru.dbotthepony.mc.otm.storage.* class DriveRackBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.DRIVE_RACK, p_155229_, p_155230_) { - override val energy = WorkerEnergyStorage(this, ServerConfig.DRIVE_RACK) + override val energy = WorkerEnergyStorage(this, MachinesConfig.DRIVE_RACK) val container: MatteryContainer = object : MatteryContainer(this::setChanged, 4) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt index 695a76878..bce874ea6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt @@ -18,6 +18,7 @@ import ru.dbotthepony.mc.otm.block.storage.DriveViewerBlock import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.core.nbt.map @@ -44,7 +45,7 @@ class DriveViewerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte } } - override val energy = WorkerEnergyStorage(this, ServerConfig.DRIVE_VIEWER) + override val energy = WorkerEnergyStorage(this, MachinesConfig.DRIVE_VIEWER) val container: MatteryContainer = object : MatteryContainer(this::setChanged, 1) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { 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 acb7bf6ee..4853bb18e 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 @@ -31,6 +31,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.get import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode @@ -182,7 +183,7 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.ITEM_MONITOR, p_155229_, p_155230_), IStorageEventConsumer { - override val energy = WorkerEnergyStorage(this, ServerConfig.ITEM_MONITOR) + override val energy = WorkerEnergyStorage(this, MachinesConfig.ITEM_MONITOR) var poweredView: PoweredVirtualComponent? = null private set diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt index eb18f3b4e..39ec6b9a2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt @@ -24,6 +24,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.AbstractStorageImportExport.Companion.FILTER_KEY import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.core.* @@ -76,7 +77,7 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter return StorageBusMenu(containerID, inventory, this) } - override val energy = WorkerEnergyStorage(this::setChangedLight, ServerConfig.STORAGE_INTERFACES) + override val energy = WorkerEnergyStorage(this::setChangedLight, MachinesConfig.STORAGE_INTERFACES) val cell: BasicStorageGraphNode = object : BasicStorageGraphNode(energy), GraphNodeListener { override fun onNeighbour(node: Graph6Node<*>, direction: Direction) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt index 072a8f8d2..83a84d696 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt @@ -24,6 +24,7 @@ import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.config.ConciseBalanceValues +import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.core.* @@ -53,7 +54,7 @@ abstract class AbstractStorageImportExport( blockType: BlockEntityType<*>, blockPos: BlockPos, blockState: BlockState, - energyValues: ConciseBalanceValues = ServerConfig.STORAGE_INTERFACES + energyValues: ConciseBalanceValues = MachinesConfig.STORAGE_INTERFACES ) : MatteryPoweredBlockEntity(blockType, blockPos, blockState) { final override val energy = WorkerEnergyStorage(this::setChangedLight, energyValues) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt index 634290bd5..138e11d23 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt @@ -19,6 +19,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.transferChecked +import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode import ru.dbotthepony.mc.otm.graph.storage.StorageNetworkGraph @@ -92,7 +93,7 @@ class StoragePowerSupplierBlockEntity(blockPos: BlockPos, blockState: BlockState var demand = Decimal.ZERO var i = 0 - val available = energy.batteryLevel.coerceAtMost(ServerConfig.STORAGE_POWER_SUPPLIER.throughput) + val available = energy.batteryLevel.coerceAtMost(MachinesConfig.STORAGE_POWER_SUPPLIER.throughput) for (demanding in graph.powerDemandingNodes) { val received = demanding.receiveEnergy(available, true) @@ -118,7 +119,7 @@ class StoragePowerSupplierBlockEntity(blockPos: BlockPos, blockState: BlockState } } - override val energy = WorkerEnergyStorage(this, ServerConfig.STORAGE_POWER_SUPPLIER) + override val energy = WorkerEnergyStorage(this, MachinesConfig.STORAGE_POWER_SUPPLIER) override fun saveAdditional(nbt: CompoundTag) { super.saveAdditional(nbt) 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 1cea0a3e6..dea715cfd 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 @@ -21,6 +21,7 @@ import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainerHooks import ru.dbotthepony.mc.otm.core.math.Decimal @@ -37,7 +38,7 @@ class PlatePressBlockEntity( p_155230_: BlockState ) : MatteryWorkerBlockEntity(MBlockEntities.PLATE_PRESS, p_155229_, p_155230_, ::ItemJob), IDroppableContainer { val container = MatteryContainer(this::setChangedLight, 2) - override val energy = WorkerEnergyStorage(this::setChangedLight, ServerConfig.PLATE_PRESS) + override val energy = WorkerEnergyStorage(this::setChangedLight, MachinesConfig.PLATE_PRESS) var experience = 0.0 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 1e0545cdd..c71ac169e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -46,14 +46,13 @@ import ru.dbotthepony.mc.otm.android.AndroidResearchType import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.energy.AndroidPowerSource import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.config.ServerConfig +import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.stream import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.collect.UUIDIntModifiersMap import ru.dbotthepony.mc.otm.core.collect.nonEmpty import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.math.set import ru.dbotthepony.mc.otm.core.nbt.getCompoundList import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set @@ -274,7 +273,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial /** * [IMatteryEnergyStorage] instance, representing Android' battery charge */ - val androidEnergy = AndroidPowerSource(ply, synchronizer, ServerConfig.ANDROID_MAX_ENERGY, ServerConfig.ANDROID_MAX_ENERGY) + val androidEnergy = AndroidPowerSource(ply, synchronizer, AndroidConfig.ANDROID_MAX_ENERGY, AndroidConfig.ANDROID_MAX_ENERGY) fun invalidateNetworkState() { synchronizer.invalidate() @@ -324,8 +323,8 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial shouldPlaySound = false iteration = 0 deathLog.clear() - androidEnergy.batteryLevel = ServerConfig.ANDROID_MAX_ENERGY - androidEnergy.maxBatteryLevel = ServerConfig.ANDROID_MAX_ENERGY + androidEnergy.batteryLevel = AndroidConfig.ANDROID_MAX_ENERGY + androidEnergy.maxBatteryLevel = AndroidConfig.ANDROID_MAX_ENERGY if (ply is ServerPlayer) { BecomeAndroidTrigger.trigger(ply) @@ -372,7 +371,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial iteration = 0 deathLog.clear() androidEnergy.batteryLevel = Decimal.ZERO - androidEnergy.maxBatteryLevel = ServerConfig.ANDROID_MAX_ENERGY + androidEnergy.maxBatteryLevel = AndroidConfig.ANDROID_MAX_ENERGY dropBattery() if (ply is ServerPlayer) { @@ -788,16 +787,16 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial if (!ply.isSpectator) { val stats = ply.foodData - while (stats.foodLevel < 18 && androidEnergy.extractEnergy(ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, true) >= ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT) { - androidEnergy.extractEnergy(ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false) + while (stats.foodLevel < 18 && androidEnergy.extractEnergy(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT, true) >= AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT) { + androidEnergy.extractEnergy(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false) stats.foodLevel = stats.foodLevel + 1 } // "block" quick regeneration // also cause power to generate while in peaceful - if (ServerConfig.REGENERATE_ENERGY) { - while (stats.foodLevel > 18 && androidEnergy.receiveEnergy(ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, true) >= ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT) { - androidEnergy.receiveEnergy(ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false) + if (AndroidConfig.REGENERATE_ENERGY) { + while (stats.foodLevel > 18 && androidEnergy.receiveEnergy(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT, true) >= AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT) { + androidEnergy.receiveEnergy(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false) stats.foodLevel = stats.foodLevel - 1 } } else if (ply.level.server?.worldData?.difficulty != Difficulty.PEACEFUL) { @@ -807,13 +806,13 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial val foodLevel = stats.foodLevel.toFloat() if (stats.saturationLevel < foodLevel) { - val extracted = androidEnergy.extractEnergy(ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * (foodLevel - stats.saturationLevel), false) - stats.setSaturation(stats.saturationLevel + (extracted / ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT).toFloat()) + val extracted = androidEnergy.extractEnergy(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT * (foodLevel - stats.saturationLevel), false) + stats.setSaturation(stats.saturationLevel + (extracted / AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT).toFloat()) } if (stats.exhaustionLevel > 0f) { - val extracted = androidEnergy.extractEnergy(ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT * (stats.exhaustionLevel / 4f), false) - stats.setExhaustion(stats.exhaustionLevel - (extracted / ServerConfig.ANDROID_ENERGY_PER_HUNGER_POINT).toFloat() * 4f) + val extracted = androidEnergy.extractEnergy(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT * (stats.exhaustionLevel / 4f), false) + stats.setExhaustion(stats.exhaustionLevel - (extracted / AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT).toFloat() * 4f) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ShockwaveRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ShockwaveRenderer.kt index b3b842c97..c408b8245 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ShockwaveRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ShockwaveRenderer.kt @@ -7,6 +7,7 @@ import com.mojang.blaze3d.vertex.VertexFormat import net.minecraft.client.renderer.GameRenderer import net.minecraftforge.client.event.RenderLevelStageEvent import org.lwjgl.opengl.GL11.GL_LESS +import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.math.component1 @@ -82,6 +83,6 @@ object ShockwaveRenderer { } fun handle(packet: ShockwaveEffectPacket) { - State(packet.pos, ServerConfig.Shockwave.RADIUS_HORIZONTAL.toFloat()) + State(packet.pos, AndroidConfig.Shockwave.RADIUS_HORIZONTAL.toFloat()) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt new file mode 100644 index 000000000..399ffca68 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt @@ -0,0 +1,20 @@ +package ru.dbotthepony.mc.otm.config + +import net.minecraftforge.common.ForgeConfigSpec +import net.minecraftforge.fml.ModLoadingContext +import net.minecraftforge.fml.config.ModConfig +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.core.util.WriteOnce + +abstract class AbstractConfig(private val configName: String, private val type: ModConfig.Type = ModConfig.Type.SERVER) { + private var spec: ForgeConfigSpec by WriteOnce() + protected val builder = ForgeConfigSpec.Builder() + private var registered = false + + fun register() { + check(!registered) { "Already registered config" } + registered = true + spec = builder.build() + ModLoadingContext.get().registerConfig(type, spec, "${OverdriveThatMatters.MOD_ID}-$configName.toml") + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt new file mode 100644 index 000000000..693a1392b --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt @@ -0,0 +1,108 @@ +package ru.dbotthepony.mc.otm.config + +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.defineDecimal + +object AndroidConfig : AbstractConfig("androids") { + val REGENERATE_ENERGY: Boolean by builder + .comment("If (technically) hunger is above threshold, it turns into energy") + .comment("This setting controls whenever to regenerate small amount of energy while eating as Android") + .comment("And also whenever to regenerate energy while in peaceful") + .comment("If this is disabled, any (technically) excess hunger will be nullified, unless playing on peaceful difficulty.") + .define("REGENERATE_ENERGY", true) + + + object NanobotsRegeneration { + val COOLDOWN: List by builder + .comment("In ticks, time between heal ticks") + .comment("One heal tick restores 1 heart (2 health points) at most") + .comment("If not getting hurt in specified period of ticks, heal tick takes place, tick timer resets to zero and THIS array' index advances by 1") + .comment("Index inside this array can not exceed of one of ability's") + .comment("") + .comment("Wording in pseudocode:") + .comment("if (ticksSinceTakingDamage >= cooldownConfigOption[healTicks /* or config's biggest index, whichever is smaller */]) {") + .comment(" healTicks = min(healTicks + 1, level /* ability level */)") + .comment(" ticksSinceTakingDamage = 0") + .comment(" this.ply.heal(...)") + .comment("}") + .defineList("COOLDOWN", { mutableListOf(80, 60, 40, 20) }) { it is Int } + + val ENERGY_PER_HITPOINT by builder + .comment("Energy required to regenerate 1 health point (half a heart)") + .defineDecimal("ENERGY_PER_HITPOINT", Decimal(800)) + } + + val ANDROID_ENERGY_PER_HUNGER_POINT by builder.defineDecimal("energyPerHunger", Decimal(2000), Decimal.ZERO) + val ANDROID_MAX_ENERGY by builder.comment("Internal battery of every android has this much storage").defineDecimal("capacity", Decimal(80_000), Decimal.ZERO) + val NIGHT_VISION_POWER_DRAW by builder.defineDecimal("nightVisionPowerDraw", Decimal(8), Decimal.ZERO) + val FALL_DAMAGE_REDUCTION_PER_LEVEL: Double by builder.comment("In percent. Level of feature is multiplied by this").defineInRange("fallDamageReductionPerDampenerLevel", 0.25, 0.01, 1.0) + + object EnderTeleporter { + init { + builder.comment("Ender Teleporter ability").push("EnderTeleporter") + } + + val ENERGY_COST by builder.defineDecimal("ENERGY_COST", Decimal(4096), Decimal.ZERO) + val COOLDOWN: Int by builder.comment("In ticks").defineInRange("COOLDOWN", 40, 0, Int.MAX_VALUE) + val MAX_PHASE_DISTANCE: Int by builder.comment("Determines how much blocks can we 'phase' through to teleport on solid surface").defineInRange("MAX_PHASE_DISTANCE", 6, 0, Int.MAX_VALUE) + val MAX_DISTANCE: Double by builder.comment("In blocks, euclidean distance").defineInRange("MAX_DISTANCE", 12.0, 2.0, Int.MAX_VALUE.toDouble()) + + init { + builder.pop() + } + } + + object JumpBoost { + init { + builder.comment("Jump boost ability").push("JumpBoost") + } + + val ENERGY_COST by builder.defineDecimal("ENERGY_COST", Decimal(1024), Decimal.ZERO) + val POWER: Double by builder.comment("The jump height on jump boost, as (level + 1) of feature, in meters per second").defineInRange("POWER", 6.0, 0.0, Double.MAX_VALUE) + val BASE_COOLDOWN: Int by builder.comment("In ticks").defineInRange("BASE_COOLDOWN", 40, 0, Int.MAX_VALUE) + val COOLDOWN_REDUCTION: Int by builder.comment("In ticks, per level of feature").defineInRange("COOLDOWN_REDUCTION", 20, 0, Int.MAX_VALUE) + + init { + builder.pop() + } + } + + object Magnet { + init { + builder.comment("Item magnet ability").push("Magnet") + } + + val POWER_DRAW by builder.comment("Per tick per stack").defineDecimal("POWER_DRAW", Decimal(8), Decimal.ZERO) + val RADIUS_HORIZONTAL: Double by builder.defineInRange("RADIUS_HORIZONTAL", 6.0, 0.0, Double.MAX_VALUE / 4.0) + val RADIUS_VERTICAL: Double by builder.defineInRange("RADIUS_VERTICAL", 3.0, 0.0, Double.MAX_VALUE / 4.0) + + init { + builder.pop() + } + } + + object Shockwave { + init { + builder.comment("Shockwave ability").push("Shockwave") + } + + val TERMINAL_VELOCITY: Double by builder.comment("In meters per second vertically").defineInRange("TERMINAL_VELOCITY", 5.6, 0.0) + val ACCELERATION: Double by builder.comment("In meters per second vertically").defineInRange("ACCELERATION", 4.0, 0.0) + val COOLDOWN: Int by builder.comment("In ticks").defineInRange("COOLDOWN", 30, 1) + val RADIUS_HORIZONTAL: Double by builder.comment("In meters").defineInRange("RADIUS_HORIZONTAL", 4.0, 0.0) + val RADIUS_VERTICAL: Double by builder.comment("In meters").defineInRange("RADIUS_VERTICAL", 1.0, 0.0) + + val RADIUS_HORIZONTAL_WARDEN: Double by builder.comment("In meters, when searching for Warden").defineInRange("RADIUS_HORIZONTAL_WARDEN", 16.0, 0.0) + val RADIUS_VERTICAL_WARDEN: Double by builder.comment("In meters, when searching for Warden").defineInRange("RADIUS_VERTICAL_WARDEN", 6.0, 0.0) + + val BREAK_BLOCKS: Boolean by builder.comment("Break blocks without any blast resistance").define("BREAK_BLOCKS", true) + val DAMAGE: Double by builder.comment("Max potential damage done by shockwave").defineInRange("DAMAGE", 12.0, 0.0, Float.MAX_VALUE.toDouble()) + val WARDEN_DAMAGE_MULT: Double by builder.defineInRange("WARDEN_DAMAGE_MULT", 4.0, 0.0, Float.MAX_VALUE.toDouble()) + val ENERGY_COST by builder.defineDecimal("ENERGY_COST", Decimal(2048), Decimal.ZERO) + + init { + builder.pop() + } + } + +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt new file mode 100644 index 000000000..f60c18772 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt @@ -0,0 +1,92 @@ +package ru.dbotthepony.mc.otm.config + +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.defineDecimal +import ru.dbotthepony.mc.otm.registry.MNames + +object ItemsConfig : AbstractConfig("items") { + private fun verboseValues(name: String, storage: Decimal, receive: Decimal, extract: Decimal = receive): VerboseBalanceValues { + builder.push(name) + + val obj = object : VerboseBalanceValues { + override val capacity: Decimal by builder.defineDecimal("capacity", storage, minimum = Decimal.ONE) + override val receive: Decimal by builder.defineDecimal("receive", receive, minimum = Decimal.ONE) + override val extract: Decimal by builder.defineDecimal("extract", extract, minimum = Decimal.ONE) + } + + builder.pop() + + return obj + } + + private fun batteryValues(name: String, storage: Decimal, receive: Decimal, extract: Decimal = receive, initialBatteryLevel: Decimal = Decimal.ZERO): BatteryBalanceValues { + builder.push(name) + + val obj = object : BatteryBalanceValues { + override val capacity: Decimal by builder.defineDecimal("capacity", storage, minimum = Decimal.ONE) + override val receive: Decimal by builder.defineDecimal("receive", receive, minimum = Decimal.ONE) + override val extract: Decimal by builder.defineDecimal("extract", extract, minimum = Decimal.ONE) + override val initialBatteryLevel: Decimal by builder.defineDecimal("initialBatteryLevel", initialBatteryLevel, minimum = Decimal.ZERO) + } + + builder.pop() + + return obj + } + + private fun conciseValues(name: String, storage: Decimal, throughput: Decimal): ConciseBalanceValues { + builder.push(name) + + val obj = object : ConciseBalanceValues { + override val capacity: Decimal by builder.defineDecimal("capacity", storage, minimum = Decimal.ONE) + override val throughput: Decimal by builder.defineDecimal("throughput", throughput, minimum = Decimal.ONE) + } + + builder.pop() + + return obj + } + + init { + builder.push("EnergyBatteries") + } + + object Batteries { + val BATTERY_CRUDE = batteryValues(MNames.BATTERY_CRUDE, Decimal(100_000), Decimal(160), Decimal(40), Decimal(80_000)) + val BATTERY_BASIC = batteryValues(MNames.BATTERY_BASIC, Decimal(400_000), Decimal(600)) + val BATTERY_NORMAL = batteryValues(MNames.BATTERY_NORMAL, Decimal(2_000_000), Decimal(1_000)) + val BATTERY_DENSE = batteryValues(MNames.BATTERY_DENSE, Decimal(10_000_000), Decimal(2_000)) + val BATTERY_CAPACITOR = batteryValues(MNames.BATTERY_CAPACITOR, Decimal(500_000), Decimal(50_000)) + + val QUANTUM_BATTERY = conciseValues(MNames.QUANTUM_BATTERY, Decimal(40_000_000), Decimal(10_000)) + val QUANTUM_CAPACITOR = conciseValues(MNames.QUANTUM_CAPACITOR, Decimal(1_000_000), Decimal(200_000)) + + val ZPM_BATTERY = conciseValues(MNames.ZPM_BATTERY, Decimal(200_000_000_000_000L), Decimal(200_000_000L)) + } + + init { + Batteries + builder.pop() + } + + val MATTER_DUST_CAPACITY by builder.comment("Maximal matter value one matter dust item can have").defineDecimal("matterDustCapacity", Decimal(2_000), minimum = Decimal.ONE_TENTH) + + init { + builder.push("MatterCapacitors") + } + + object Capacitors { + val MATTER_CAPACITOR_BASIC by builder.defineDecimal(MNames.MATTER_CAPACITOR_BASIC, Decimal(2_000), minimum = Decimal.ONE_TENTH) + val MATTER_CAPACITOR_NORMAL by builder.defineDecimal(MNames.MATTER_CAPACITOR_NORMAL, Decimal(40_000), minimum = Decimal.ONE_TENTH) + val MATTER_CAPACITOR_DENSE by builder.defineDecimal(MNames.MATTER_CAPACITOR_DENSE, Decimal(400_000), minimum = Decimal.ONE_TENTH) + } + + init { + Capacitors + builder.pop() + } + + object PatternDrives { + val NORMAL: Int by builder.defineInRange(MNames.PATTERN_DRIVE_NORMAL, 4, 1, Int.MAX_VALUE) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt new file mode 100644 index 000000000..9e8ef569f --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt @@ -0,0 +1,32 @@ +package ru.dbotthepony.mc.otm.config + +import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity +import ru.dbotthepony.mc.otm.block.entity.matter.MatterDecomposerBlockEntity +import ru.dbotthepony.mc.otm.block.entity.matter.MatterRecyclerBlockEntity +import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity +import ru.dbotthepony.mc.otm.block.entity.matter.MatterScannerBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.ChemicalGeneratorBlockEntity +import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.registry.MNames + +object MachinesConfig : AbstractConfig("machines") { + init { + AndroidStationBlockEntity.registerConfig(builder) + ChemicalGeneratorBlockEntity.registerConfig(builder) + MatterRecyclerBlockEntity.registerConfig(builder) + MatterBottlerBlockEntity.registerConfig(builder) + MatterReplicatorBlockEntity.registerConfig(builder) + MatterScannerBlockEntity.registerConfig(builder) + MatterDecomposerBlockEntity.registerConfig(builder) + } + + + val PLATE_PRESS = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.PLATE_PRESS) + val STORAGE_POWER_SUPPLIER = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.STORAGE_POWER_SUPPLIER, capacity = Decimal(100_000), throughput = Decimal(320)) + val STORAGE_INTERFACES = BlockEnergyStorageImpl.makeConfigEntry(builder, "STORAGE_INTERFACES", capacity = Decimal(10_000)) + val ITEM_MONITOR = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.ITEM_MONITOR) + val DRIVE_VIEWER = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.DRIVE_VIEWER) + val DRIVE_RACK = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.DRIVE_RACK, capacity = Decimal(80_000)) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt index e55be2c01..c1f3e2783 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt @@ -16,245 +16,7 @@ import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.item.EnergySwordItem import ru.dbotthepony.mc.otm.registry.MNames -object ServerConfig { - private val specBuilder = ForgeConfigSpec.Builder() - @Suppress("JoinDeclarationAndAssignment") - private val spec: ForgeConfigSpec - private var registered = false - - private fun verboseValues(name: String, storage: Decimal, receive: Decimal, extract: Decimal = receive): VerboseBalanceValues { - specBuilder.push(name) - - val obj = object : VerboseBalanceValues { - override val capacity: Decimal by specBuilder.defineDecimal("capacity", storage, minimum = Decimal.ONE) - override val receive: Decimal by specBuilder.defineDecimal("receive", receive, minimum = Decimal.ONE) - override val extract: Decimal by specBuilder.defineDecimal("extract", extract, minimum = Decimal.ONE) - } - - specBuilder.pop() - - return obj - } - - private fun batteryValues(name: String, storage: Decimal, receive: Decimal, extract: Decimal = receive, initialBatteryLevel: Decimal = Decimal.ZERO): BatteryBalanceValues { - specBuilder.push(name) - - val obj = object : BatteryBalanceValues { - override val capacity: Decimal by specBuilder.defineDecimal("capacity", storage, minimum = Decimal.ONE) - override val receive: Decimal by specBuilder.defineDecimal("receive", receive, minimum = Decimal.ONE) - override val extract: Decimal by specBuilder.defineDecimal("extract", extract, minimum = Decimal.ONE) - override val initialBatteryLevel: Decimal by specBuilder.defineDecimal("initialBatteryLevel", initialBatteryLevel, minimum = Decimal.ZERO) - } - - specBuilder.pop() - - return obj - } - - private fun conciseValues(name: String, storage: Decimal, throughput: Decimal): ConciseBalanceValues { - specBuilder.push(name) - - val obj = object : ConciseBalanceValues { - override val capacity: Decimal by specBuilder.defineDecimal("capacity", storage, minimum = Decimal.ONE) - override val throughput: Decimal by specBuilder.defineDecimal("throughput", throughput, minimum = Decimal.ONE) - } - - specBuilder.pop() - - return obj - } - - val LABORATORY_LAMP_LIGHT_LENGTH: Int by specBuilder.comment("In blocks").defineInRange("LABORATORY_LAMP_LIGHT_LENGTH", 6, 1, 128) - - init { - specBuilder.comment("Energy batteries balance values").push("energyBatteries") - } - - val BATTERY_CRUDE = batteryValues(MNames.BATTERY_CRUDE, Decimal(100_000), Decimal(160), Decimal(40), Decimal(80_000)) - val BATTERY_BASIC = batteryValues(MNames.BATTERY_BASIC, Decimal(400_000), Decimal(600)) - val BATTERY_NORMAL = batteryValues(MNames.BATTERY_NORMAL, Decimal(2_000_000), Decimal(1_000)) - val BATTERY_DENSE = batteryValues(MNames.BATTERY_DENSE, Decimal(10_000_000), Decimal(2_000)) - val BATTERY_CAPACITOR = batteryValues(MNames.BATTERY_CAPACITOR, Decimal(500_000), Decimal(50_000)) - - val QUANTUM_BATTERY = conciseValues(MNames.QUANTUM_BATTERY, Decimal(40_000_000), Decimal(10_000)) - val QUANTUM_CAPACITOR = conciseValues(MNames.QUANTUM_CAPACITOR, Decimal(1_000_000), Decimal(200_000)) - - val ZPM_BATTERY = conciseValues(MNames.ZPM_BATTERY, Decimal(200_000_000_000_000L), Decimal(200_000_000L)) - - init { - specBuilder.pop() - - specBuilder.comment("Matter capacitors and pattern drives balance values").push("matterCapacitorsAndDrives") - } - - val MATTER_CAPACITOR_BASIC by specBuilder.defineDecimal(MNames.MATTER_CAPACITOR_BASIC, Decimal(2_000), minimum = Decimal.ONE_TENTH) - val MATTER_CAPACITOR_NORMAL by specBuilder.defineDecimal(MNames.MATTER_CAPACITOR_NORMAL, Decimal(40_000), minimum = Decimal.ONE_TENTH) - val MATTER_CAPACITOR_DENSE by specBuilder.defineDecimal(MNames.MATTER_CAPACITOR_DENSE, Decimal(400_000), minimum = Decimal.ONE_TENTH) - - val MATTER_DUST_CAPACITY by specBuilder.comment("Maximal matter value one matter dust item can have").defineDecimal("matterDustCapacity", Decimal(2_000), minimum = Decimal.ONE_TENTH) - - val PATTERN_DRIVE_NORMAL: Int by specBuilder.defineInRange(MNames.PATTERN_DRIVE_NORMAL, 4, 1, Int.MAX_VALUE) - - init { - specBuilder.pop() - - specBuilder.comment("Balance values of machinery").push("machines") - - AndroidStationBlockEntity.registerConfig(specBuilder) - ChemicalGeneratorBlockEntity.registerConfig(specBuilder) - MatterRecyclerBlockEntity.registerConfig(specBuilder) - MatterBottlerBlockEntity.registerConfig(specBuilder) - MatterReplicatorBlockEntity.registerConfig(specBuilder) - MatterScannerBlockEntity.registerConfig(specBuilder) - MatterDecomposerBlockEntity.registerConfig(specBuilder) - } - - val PLATE_PRESS = BlockEnergyStorageImpl.makeConfigEntry(specBuilder, MNames.PLATE_PRESS) - val STORAGE_POWER_SUPPLIER = BlockEnergyStorageImpl.makeConfigEntry(specBuilder, MNames.STORAGE_POWER_SUPPLIER, capacity = Decimal(100_000), throughput = Decimal(320)) - val STORAGE_INTERFACES = BlockEnergyStorageImpl.makeConfigEntry(specBuilder, "STORAGE_INTERFACES", capacity = Decimal(10_000)) - val ITEM_MONITOR = BlockEnergyStorageImpl.makeConfigEntry(specBuilder, MNames.ITEM_MONITOR) - val DRIVE_VIEWER = BlockEnergyStorageImpl.makeConfigEntry(specBuilder, MNames.DRIVE_VIEWER) - val DRIVE_RACK = BlockEnergyStorageImpl.makeConfigEntry(specBuilder, MNames.DRIVE_RACK, capacity = Decimal(80_000)) - - init { - specBuilder.pop() - - specBuilder.comment("Tweaking of android players").push("androidPlayer") - } - - val REGENERATE_ENERGY: Boolean by specBuilder - .comment("If (technically) hunger is above threshold, it turns into energy") - .comment("This setting controls whenever to regenerate small amount of energy while eating as Android") - .comment("And also whenever to regenerate energy while in peaceful") - .comment("If this is disabled, any (technically) excess hunger will be nullified, unless playing on peaceful difficulty.") - .define("REGENERATE_ENERGY", true) - - object NanobotsRegeneration { - val COOLDOWN: List by specBuilder - .comment("In ticks, time between heal ticks") - .comment("One heal tick restores 1 heart (2 health points) at most") - .comment("If not getting hurt in specified period of ticks, heal tick takes place, tick timer resets to zero and THIS array' index advances by 1") - .comment("Index inside this array can not exceed of one of ability's") - .comment("") - .comment("Wording in pseudocode:") - .comment("if (ticksSinceTakingDamage >= cooldownConfigOption[healTicks /* or config's biggest index, whichever is smaller */]) {") - .comment(" healTicks = min(healTicks + 1, level /* ability level */)") - .comment(" ticksSinceTakingDamage = 0") - .comment(" this.ply.heal(...)") - .comment("}") - .defineList("COOLDOWN", { mutableListOf(80, 60, 40, 20) }) { it is Int } - - val ENERGY_PER_HITPOINT by specBuilder - .comment("Energy required to regenerate 1 health point (half a heart)") - .defineDecimal("ENERGY_PER_HITPOINT", Decimal(800)) - } - - val ANDROID_ENERGY_PER_HUNGER_POINT by specBuilder.defineDecimal("energyPerHunger", Decimal(2000), Decimal.ZERO) - val ANDROID_MAX_ENERGY by specBuilder.comment("Internal battery of every android has this much storage").defineDecimal("capacity", Decimal(80_000), Decimal.ZERO) - val NIGHT_VISION_POWER_DRAW by specBuilder.defineDecimal("nightVisionPowerDraw", Decimal(8), Decimal.ZERO) - val FALL_DAMAGE_REDUCTION_PER_LEVEL: Double by specBuilder.comment("In percent. Level of feature is multiplied by this").defineInRange("fallDamageReductionPerDampenerLevel", 0.25, 0.01, 1.0) - - object EnderTeleporter { - init { - specBuilder.comment("Ender Teleporter ability").push("EnderTeleporter") - } - - val ENERGY_COST by specBuilder.defineDecimal("ENERGY_COST", Decimal(4096), Decimal.ZERO) - val COOLDOWN: Int by specBuilder.comment("In ticks").defineInRange("COOLDOWN", 40, 0, Int.MAX_VALUE) - val MAX_PHASE_DISTANCE: Int by specBuilder.comment("Determines how much blocks can we 'phase' through to teleport on solid surface").defineInRange("MAX_PHASE_DISTANCE", 6, 0, Int.MAX_VALUE) - val MAX_DISTANCE: Double by specBuilder.comment("In blocks, euclidean distance").defineInRange("MAX_DISTANCE", 12.0, 2.0, Int.MAX_VALUE.toDouble()) - - init { - specBuilder.pop() - } - } - - object AndroidJumpBoost { - init { - specBuilder.comment("Jump boost ability").push("AndroidJumpBoost") - } - - val ENERGY_COST by specBuilder.defineDecimal("ENERGY_COST", Decimal(1024), Decimal.ZERO) - val POWER: Double by specBuilder.comment("The jump height on jump boost, as (level + 1) of feature, in meters per second").defineInRange("POWER", 6.0, 0.0, Double.MAX_VALUE) - val BASE_COOLDOWN: Int by specBuilder.comment("In ticks").defineInRange("BASE_COOLDOWN", 40, 0, Int.MAX_VALUE) - val COOLDOWN_REDUCTION: Int by specBuilder.comment("In ticks, per level of feature").defineInRange("COOLDOWN_REDUCTION", 20, 0, Int.MAX_VALUE) - - init { - specBuilder.pop() - } - } - - object AndroidItemMagnet { - init { - specBuilder.comment("Item magnet ability").push("AndroidItemMagnet") - } - - val POWER_DRAW by specBuilder.comment("Per tick per stack").defineDecimal("POWER_DRAW", Decimal(8), Decimal.ZERO) - val RADIUS_HORIZONTAL: Double by specBuilder.defineInRange("RADIUS_HORIZONTAL", 6.0, 0.0, Double.MAX_VALUE / 4.0) - val RADIUS_VERTICAL: Double by specBuilder.defineInRange("RADIUS_VERTICAL", 3.0, 0.0, Double.MAX_VALUE / 4.0) - - init { - specBuilder.pop() - } - } - - object Shockwave { - init { - specBuilder.comment("Shockwave ability").push("Shockwave") - } - - val TERMINAL_VELOCITY: Double by specBuilder.comment("In meters per second vertically").defineInRange("TERMINAL_VELOCITY", 5.6, 0.0) - val ACCELERATION: Double by specBuilder.comment("In meters per second vertically").defineInRange("ACCELERATION", 4.0, 0.0) - val COOLDOWN: Int by specBuilder.comment("In ticks").defineInRange("COOLDOWN", 30, 1) - val RADIUS_HORIZONTAL: Double by specBuilder.comment("In meters").defineInRange("RADIUS_HORIZONTAL", 4.0, 0.0) - val RADIUS_VERTICAL: Double by specBuilder.comment("In meters").defineInRange("RADIUS_VERTICAL", 1.0, 0.0) - - val RADIUS_HORIZONTAL_WARDEN: Double by specBuilder.comment("In meters, when searching for Warden").defineInRange("RADIUS_HORIZONTAL_WARDEN", 16.0, 0.0) - val RADIUS_VERTICAL_WARDEN: Double by specBuilder.comment("In meters, when searching for Warden").defineInRange("RADIUS_VERTICAL_WARDEN", 6.0, 0.0) - - val BREAK_BLOCKS: Boolean by specBuilder.comment("Break blocks without any blast resistance").define("BREAK_BLOCKS", true) - val DAMAGE: Double by specBuilder.comment("Max potential damage done by shockwave").defineInRange("DAMAGE", 12.0, 0.0, Float.MAX_VALUE.toDouble()) - val WARDEN_DAMAGE_MULT: Double by specBuilder.defineInRange("WARDEN_DAMAGE_MULT", 4.0, 0.0, Float.MAX_VALUE.toDouble()) - val ENERGY_COST by specBuilder.defineDecimal("ENERGY_COST", Decimal(2048), Decimal.ZERO) - - init { - specBuilder.pop() - } - } - - object Tools { - val AXES_BREAK_LEAVES_INSTANTLY: Boolean by specBuilder.define("AXES_BREAK_LEAVES_INSTANTLY", true) - } - - init { - // access instances so spec is built - NanobotsRegeneration - EnderTeleporter - AndroidJumpBoost - AndroidItemMagnet - Shockwave - Tools - - specBuilder.pop() - - specBuilder.comment("Tweaking of exosuits").push("exosuitPlayer") - } - - val INFINITE_EXOSUIT_UPGRADES: Boolean by specBuilder.comment("Allows to apply the same upgrade over and over again.", "Obviously completely breaks balance.").define("INFINITE_EXOSUIT_UPGRADES", false) - - init { - specBuilder.pop() - - EnergySwordItem.registerConfig(specBuilder) - } - - init { - spec = specBuilder.build() - } - - fun register() { - check(!registered) { "Already registered config" } - registered = true - ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, spec) - } +object ServerConfig : AbstractConfig("misc") { + val LABORATORY_LAMP_LIGHT_LENGTH: Int by builder.comment("In blocks").defineInRange("LABORATORY_LAMP_LIGHT_LENGTH", 6, 1, 128) + val INFINITE_EXOSUIT_UPGRADES: Boolean by builder.comment("Allows to apply the same upgrade over and over again.", "Obviously completely breaks balance.").define("INFINITE_EXOSUIT_UPGRADES", false) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ToolsConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ToolsConfig.kt new file mode 100644 index 000000000..400405afb --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ToolsConfig.kt @@ -0,0 +1,11 @@ +package ru.dbotthepony.mc.otm.config + +import ru.dbotthepony.mc.otm.item.EnergySwordItem + +object ToolsConfig : AbstractConfig("tools") { + val AXES_BREAK_LEAVES_INSTANTLY: Boolean by builder.define("AXES_BREAK_LEAVES_INSTANTLY", true) + + init { + EnergySwordItem.registerConfig(builder) + } +} 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 768cdd6ce..40f72c805 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 @@ -5,6 +5,7 @@ import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.StringTag import net.minecraft.nbt.Tag import net.minecraft.network.FriendlyByteBuf +import net.minecraft.util.RandomSource import net.minecraftforge.common.ForgeConfigSpec import ru.dbotthepony.mc.otm.config.ObservedConfigValue import ru.dbotthepony.mc.otm.core.util.readDouble @@ -937,3 +938,17 @@ fun ForgeConfigSpec.Builder.defineDecimal(path: List, defaultValue: Deci comment("Default: $defaultValue") return DecimalConfigValue(define(path, defaultValue.toString()), minimum, maximum) } + +fun RandomSource.nextDecimal(min: Decimal, max: Decimal, round: Boolean = false): Decimal { + val value = nextDouble() + + if (round) { + return Decimal((min + (max - min) * value).whole) + } else { + return min + (max - min) * value + } +} + +fun RandomSource.nextVariance(value: Decimal, round: Boolean = false): Decimal { + return nextDecimal(-value / 2, value / 2, round) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt index 74f2eee84..c2cbe345a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt @@ -22,6 +22,7 @@ import ru.dbotthepony.mc.otm.capability.energy.ItemEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.energy.getBarColor import ru.dbotthepony.mc.otm.capability.energy.getBarWidth import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.config.ItemsConfig import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.registry.MRegistry @@ -159,7 +160,7 @@ open class BatteryItem : Item { } } -class CrudeBatteryItem : BatteryItem(ServerConfig.BATTERY_CRUDE) { +class CrudeBatteryItem : BatteryItem(ItemsConfig.Batteries.BATTERY_CRUDE) { override fun appendHoverText( stack: ItemStack, p_41422_: Level?, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt index ad59c3415..263d542e2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt @@ -40,6 +40,7 @@ import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.core.ifPresentK +import ru.dbotthepony.mc.otm.core.math.nextVariance import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.registry.EMPDamageSource import ru.dbotthepony.mc.otm.core.util.WriteOnce @@ -123,9 +124,10 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani itemStack.getCapability(MatteryCapability.ENERGY).ifPresentK { if (it.extractEnergyExact(ENERGY_PER_SWING, false)) { + it.extractEnergy(attacker.level.random.nextVariance(ENERGY_PER_SWING_VARIANCE), false) victim.matteryPlayer?.let { - if (it.isAndroid) { - it.androidEnergy.extractEnergy(ENERGY_ZAP, false) + if (it.isAndroid && it.androidEnergy.extractEnergyExact(ENERGY_ZAP, false)) { + it.androidEnergy.extractEnergy(attacker.level.random.nextVariance(ENERGY_ZAP_VARIANCE), false) victim.hurt(EMPDamageSource(attacker), 8f) } } @@ -168,18 +170,20 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani p_41417_: Level, blockState: BlockState, p_41419_: BlockPos, - p_41420_: LivingEntity + user: LivingEntity ): Boolean { - if (blockState.getDestroySpeed(p_41417_, p_41419_) != 0f && (p_41420_ !is Player || !p_41420_.isCreative)) { + if (blockState.getDestroySpeed(p_41417_, p_41419_) != 0f && (user !is Player || !user.isCreative)) { val energy = itemStack.matteryEnergy when (blockState.material) { Material.PLANT, Material.REPLACEABLE_PLANT, Material.VEGETABLE, Material.LEAVES -> - energy?.extractEnergyExact(PLANT_POWER_COST, false) + if (energy?.extractEnergyExact(PLANT_POWER_COST, false) == true) + energy.extractEnergyExact(user.level.random.nextVariance(PLANT_POWER_COST_VARIANCE), false) } if (blockState.`is`(Blocks.COBWEB)) { - energy?.extractEnergyExact(COBWEB_POWER_COST, false) + if (energy?.extractEnergyExact(COBWEB_POWER_COST, false) == true) + energy.extractEnergyExact(user.level.random.nextVariance(COBWEB_POWER_COST_VARIANCE), false) } } @@ -218,24 +222,36 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani companion object { val MAX_ENERGY get() = _MAX_ENERGY.get() val ENERGY_ZAP get() = _ENERGY_ZAP.get() + val ENERGY_ZAP_VARIANCE get() = _ENERGY_ZAP_VARIANCE.get() val ENERGY_PER_SWING get() = _ENERGY_PER_SWING.get() + val ENERGY_PER_SWING_VARIANCE get() = _ENERGY_PER_SWING_VARIANCE.get() val COBWEB_POWER_COST get() = _COBWEB_POWER_COST.get() + val COBWEB_POWER_COST_VARIANCE get() = _COBWEB_POWER_COST_VARIANCE.get() val PLANT_POWER_COST get() = _PLANT_POWER_COST.get() + val PLANT_POWER_COST_VARIANCE get() = _PLANT_POWER_COST_VARIANCE.get() private var _MAX_ENERGY: DecimalConfigValue by WriteOnce() private var _ENERGY_ZAP: DecimalConfigValue by WriteOnce() + private var _ENERGY_ZAP_VARIANCE: DecimalConfigValue by WriteOnce() private var _ENERGY_PER_SWING: DecimalConfigValue by WriteOnce() + private var _ENERGY_PER_SWING_VARIANCE: DecimalConfigValue by WriteOnce() private var _COBWEB_POWER_COST: DecimalConfigValue by WriteOnce() + private var _COBWEB_POWER_COST_VARIANCE: DecimalConfigValue by WriteOnce() private var _PLANT_POWER_COST: DecimalConfigValue by WriteOnce() + private var _PLANT_POWER_COST_VARIANCE: DecimalConfigValue by WriteOnce() fun registerConfig(builder: ForgeConfigSpec.Builder) { - builder.comment("Energy sword values").push("energy_sword") + builder.comment("Energy sword values").push("EnergySword") _MAX_ENERGY = builder.defineDecimal("MAX_ENERGY", Decimal(500_000), Decimal.ZERO) - _ENERGY_ZAP = builder.defineDecimal("ENERGY_ZAP", Decimal(4_000), Decimal.ZERO) + _ENERGY_ZAP = builder.comment("Extra energy required when hitting androids").defineDecimal("ENERGY_ZAP", Decimal(4_000), Decimal.ZERO) + _ENERGY_ZAP_VARIANCE = builder.comment("Random deviation from ENERGY_ZAP").defineDecimal("ENERGY_ZAP_VARIANCE", Decimal(800), Decimal.ZERO) _ENERGY_PER_SWING = builder.defineDecimal("ENERGY_PER_SWING", Decimal(2_000), Decimal.ZERO) + _ENERGY_PER_SWING_VARIANCE = builder.comment("Random deviation from ENERGY_PER_SWING").defineDecimal("ENERGY_PER_SWING_VARIANCE", Decimal(500), Decimal.ZERO) _COBWEB_POWER_COST = builder.defineDecimal("COBWEB_POWER_COST", Decimal(2_500), Decimal.ZERO) + _COBWEB_POWER_COST_VARIANCE = builder.comment("Random deviation from COBWEB_POWER_COST").defineDecimal("COBWEB_POWER_COST_VARIANCE", Decimal(500), Decimal.ZERO) _PLANT_POWER_COST = builder.defineDecimal("PLANT_POWER_COST", Decimal(500), Decimal.ZERO) + _PLANT_POWER_COST_VARIANCE = builder.comment("Random deviation from PLANT_POWER_COST").defineDecimal("PLANT_POWER_COST_VARIANCE", Decimal(100), Decimal.ZERO) builder.pop() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt index 5c63d5b51..da8f40f3e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt @@ -6,6 +6,7 @@ import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.Level +import ru.dbotthepony.mc.otm.config.ItemsConfig import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.Decimal @@ -56,10 +57,10 @@ class MatterDustItem : Item(Properties().stacksTo(64)), IMatterItem { val matterThis = matter(stack) - if (matterThis >= ServerConfig.MATTER_DUST_CAPACITY) + if (matterThis >= ItemsConfig.MATTER_DUST_CAPACITY) return Decimal.ZERO - val newMatter = (matterThis + matter).coerceAtMost(ServerConfig.MATTER_DUST_CAPACITY) + val newMatter = (matterThis + matter).coerceAtMost(ItemsConfig.MATTER_DUST_CAPACITY) val diff = newMatter - matterThis if (!simulate) @@ -69,7 +70,7 @@ class MatterDustItem : Item(Properties().stacksTo(64)), IMatterItem { } fun isFull(stack: ItemStack): Boolean { - return matter(stack) >= ServerConfig.MATTER_DUST_CAPACITY + return matter(stack) >= ItemsConfig.MATTER_DUST_CAPACITY } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatteryAxeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatteryAxeItem.kt index 631941d18..2de16d329 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatteryAxeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatteryAxeItem.kt @@ -5,11 +5,11 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Tier import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.material.Material -import ru.dbotthepony.mc.otm.config.ServerConfig +import ru.dbotthepony.mc.otm.config.ToolsConfig class MatteryAxeItem(pTier: Tier, pAttackDamageModifier: Float, pAttackSpeedModifier: Float, pProperties: Properties) : AxeItem(pTier, pAttackDamageModifier, pAttackSpeedModifier, pProperties) { override fun getDestroySpeed(pStack: ItemStack, pState: BlockState): Float { - if (pState.material == Material.LEAVES && ServerConfig.Tools.AXES_BREAK_LEAVES_INSTANTLY) + if (pState.material == Material.LEAVES && ToolsConfig.AXES_BREAK_LEAVES_INSTANTLY) return 64f return super.getDestroySpeed(pStack, pState) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt index a8b2fd133..222194986 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt @@ -17,6 +17,7 @@ import ru.dbotthepony.mc.otm.capability.energy.EnergyProducerItem import ru.dbotthepony.mc.otm.capability.energy.ItemEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.energy.getBarColor import ru.dbotthepony.mc.otm.capability.energy.getBarWidth +import ru.dbotthepony.mc.otm.config.ItemsConfig import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.math.Decimal @@ -63,7 +64,7 @@ open class SingleUseBatteryItem( } } -class ZPMItem : SingleUseBatteryItem(ServerConfig.ZPM_BATTERY, Properties().stacksTo(1).rarity(Rarity.EPIC)) { +class ZPMItem : SingleUseBatteryItem(ItemsConfig.Batteries.ZPM_BATTERY, Properties().stacksTo(1).rarity(Rarity.EPIC)) { override fun appendHoverText( itemStack: ItemStack, p_41422_: Level?, 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 b4b410362..163fad55e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -14,6 +14,7 @@ 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.config.ItemsConfig import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.core.collect.SupplierList import ru.dbotthepony.mc.otm.core.TranslatableComponent @@ -200,14 +201,14 @@ object MItems { ) val BATTERY_CRUDE: Item by registry.register(MNames.BATTERY_CRUDE) { CrudeBatteryItem() } - val BATTERY_BASIC: Item by registry.register(MNames.BATTERY_BASIC) { BatteryItem(ServerConfig.BATTERY_BASIC) } - val BATTERY_NORMAL: Item by registry.register(MNames.BATTERY_NORMAL) { BatteryItem(ServerConfig.BATTERY_NORMAL) } - val BATTERY_DENSE: Item by registry.register(MNames.BATTERY_DENSE) { BatteryItem(ServerConfig.BATTERY_DENSE) } - val BATTERY_CAPACITOR: Item by registry.register(MNames.BATTERY_CAPACITOR) { BatteryItem(ServerConfig.BATTERY_CAPACITOR) } + val BATTERY_BASIC: Item by registry.register(MNames.BATTERY_BASIC) { BatteryItem(ItemsConfig.Batteries.BATTERY_BASIC) } + val BATTERY_NORMAL: Item by registry.register(MNames.BATTERY_NORMAL) { BatteryItem(ItemsConfig.Batteries.BATTERY_NORMAL) } + val BATTERY_DENSE: Item by registry.register(MNames.BATTERY_DENSE) { BatteryItem(ItemsConfig.Batteries.BATTERY_DENSE) } + val BATTERY_CAPACITOR: Item by registry.register(MNames.BATTERY_CAPACITOR) { BatteryItem(ItemsConfig.Batteries.BATTERY_CAPACITOR) } val BATTERY_CREATIVE: Item by registry.register(MNames.BATTERY_CREATIVE) { BatteryItem() } - val QUANTUM_BATTERY: Item by registry.register(MNames.QUANTUM_BATTERY) { QuantumBatteryItem(MNames.QUANTUM_BATTERY, ServerConfig.QUANTUM_BATTERY) } - val QUANTUM_CAPACITOR: Item by registry.register(MNames.QUANTUM_CAPACITOR) { QuantumBatteryItem(MNames.QUANTUM_CAPACITOR, ServerConfig.QUANTUM_CAPACITOR) } + val QUANTUM_BATTERY: Item by registry.register(MNames.QUANTUM_BATTERY) { QuantumBatteryItem(MNames.QUANTUM_BATTERY, ItemsConfig.Batteries.QUANTUM_BATTERY) } + val QUANTUM_CAPACITOR: Item by registry.register(MNames.QUANTUM_CAPACITOR) { QuantumBatteryItem(MNames.QUANTUM_CAPACITOR, ItemsConfig.Batteries.QUANTUM_CAPACITOR) } val QUANTUM_BATTERY_CREATIVE: Item by registry.register(MNames.QUANTUM_BATTERY_CREATIVE) { QuantumBatteryItem(MNames.QUANTUM_BATTERY_CREATIVE) } val ZPM_BATTERY: Item by registry.register(MNames.ZPM_BATTERY) { ZPMItem() } @@ -240,9 +241,9 @@ object MItems { ::ZPM_BATTERY, ) - val MATTER_CAPACITOR_BASIC: Item by registry.register(MNames.MATTER_CAPACITOR_BASIC) { MatterCapacitorItem(ServerConfig::MATTER_CAPACITOR_BASIC) } - val MATTER_CAPACITOR_NORMAL: Item by registry.register(MNames.MATTER_CAPACITOR_NORMAL) { MatterCapacitorItem(ServerConfig::MATTER_CAPACITOR_NORMAL) } - val MATTER_CAPACITOR_DENSE: Item by registry.register(MNames.MATTER_CAPACITOR_DENSE) { MatterCapacitorItem(ServerConfig::MATTER_CAPACITOR_DENSE) } + val MATTER_CAPACITOR_BASIC: Item by registry.register(MNames.MATTER_CAPACITOR_BASIC) { MatterCapacitorItem(ItemsConfig.Capacitors::MATTER_CAPACITOR_BASIC) } + val MATTER_CAPACITOR_NORMAL: Item by registry.register(MNames.MATTER_CAPACITOR_NORMAL) { MatterCapacitorItem(ItemsConfig.Capacitors::MATTER_CAPACITOR_NORMAL) } + val MATTER_CAPACITOR_DENSE: Item by registry.register(MNames.MATTER_CAPACITOR_DENSE) { MatterCapacitorItem(ItemsConfig.Capacitors::MATTER_CAPACITOR_DENSE) } val MATTER_CAPACITOR_CREATIVE: Item by registry.register(MNames.MATTER_CAPACITOR_CREATIVE) { MatterCapacitorItem() } val MATTER_CAPACITORS = SupplierList( @@ -252,7 +253,7 @@ object MItems { ::MATTER_CAPACITOR_CREATIVE, ) - val PATTERN_DRIVE_NORMAL: Item by registry.register(MNames.PATTERN_DRIVE_NORMAL) { PatternStorageItem(ServerConfig::PATTERN_DRIVE_NORMAL) } + val PATTERN_DRIVE_NORMAL: Item by registry.register(MNames.PATTERN_DRIVE_NORMAL) { PatternStorageItem(ItemsConfig.PatternDrives::NORMAL) } val PATTERN_DRIVE_CREATIVE: Item by registry.register(MNames.PATTERN_DRIVE_CREATIVE) { PatternStorageItem() } val PATTERN_DRIVE_CREATIVE2: Item by registry.register(MNames.PATTERN_DRIVE_CREATIVE2) { CreativePatternItem() } From 685450da0ca9d5d6bdd4d1370de6b43d06fef6e9 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 9 Feb 2023 21:39:03 +0700 Subject: [PATCH 0188/1199] Rename keys --- .../dbotthepony/mc/otm/config/ItemsConfig.kt | 18 +++++++++--------- .../ru/dbotthepony/mc/otm/item/BatteryItem.kt | 3 +-- .../mc/otm/item/SingleUseBatteryItem.kt | 3 +-- .../ru/dbotthepony/mc/otm/registry/MItems.kt | 15 +++++++-------- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt index f60c18772..6fe596eaf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt @@ -52,16 +52,16 @@ object ItemsConfig : AbstractConfig("items") { } object Batteries { - val BATTERY_CRUDE = batteryValues(MNames.BATTERY_CRUDE, Decimal(100_000), Decimal(160), Decimal(40), Decimal(80_000)) - val BATTERY_BASIC = batteryValues(MNames.BATTERY_BASIC, Decimal(400_000), Decimal(600)) - val BATTERY_NORMAL = batteryValues(MNames.BATTERY_NORMAL, Decimal(2_000_000), Decimal(1_000)) - val BATTERY_DENSE = batteryValues(MNames.BATTERY_DENSE, Decimal(10_000_000), Decimal(2_000)) - val BATTERY_CAPACITOR = batteryValues(MNames.BATTERY_CAPACITOR, Decimal(500_000), Decimal(50_000)) + val CRUDE = batteryValues(MNames.BATTERY_CRUDE, Decimal(100_000), Decimal(160), Decimal(40), Decimal(80_000)) + val BASIC = batteryValues(MNames.BATTERY_BASIC, Decimal(400_000), Decimal(600)) + val NORMAL = batteryValues(MNames.BATTERY_NORMAL, Decimal(2_000_000), Decimal(1_000)) + val DENSE = batteryValues(MNames.BATTERY_DENSE, Decimal(10_000_000), Decimal(2_000)) + val CAPACITOR = batteryValues(MNames.BATTERY_CAPACITOR, Decimal(500_000), Decimal(50_000)) val QUANTUM_BATTERY = conciseValues(MNames.QUANTUM_BATTERY, Decimal(40_000_000), Decimal(10_000)) val QUANTUM_CAPACITOR = conciseValues(MNames.QUANTUM_CAPACITOR, Decimal(1_000_000), Decimal(200_000)) - val ZPM_BATTERY = conciseValues(MNames.ZPM_BATTERY, Decimal(200_000_000_000_000L), Decimal(200_000_000L)) + val ZPM = conciseValues(MNames.ZPM_BATTERY, Decimal(200_000_000_000_000L), Decimal(200_000_000L)) } init { @@ -76,9 +76,9 @@ object ItemsConfig : AbstractConfig("items") { } object Capacitors { - val MATTER_CAPACITOR_BASIC by builder.defineDecimal(MNames.MATTER_CAPACITOR_BASIC, Decimal(2_000), minimum = Decimal.ONE_TENTH) - val MATTER_CAPACITOR_NORMAL by builder.defineDecimal(MNames.MATTER_CAPACITOR_NORMAL, Decimal(40_000), minimum = Decimal.ONE_TENTH) - val MATTER_CAPACITOR_DENSE by builder.defineDecimal(MNames.MATTER_CAPACITOR_DENSE, Decimal(400_000), minimum = Decimal.ONE_TENTH) + val BASIC by builder.defineDecimal(MNames.MATTER_CAPACITOR_BASIC, Decimal(2_000), minimum = Decimal.ONE_TENTH) + val NORMAL by builder.defineDecimal(MNames.MATTER_CAPACITOR_NORMAL, Decimal(40_000), minimum = Decimal.ONE_TENTH) + val DENSE by builder.defineDecimal(MNames.MATTER_CAPACITOR_DENSE, Decimal(400_000), minimum = Decimal.ONE_TENTH) } init { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt index c2cbe345a..19710415f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt @@ -15,7 +15,6 @@ import net.minecraft.world.level.Level import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.capabilities.ICapabilityProvider import ru.dbotthepony.mc.otm.config.BatteryBalanceValues -import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.EnergyCapacitorItem import ru.dbotthepony.mc.otm.capability.energy.ItemEnergyStorageImpl @@ -160,7 +159,7 @@ open class BatteryItem : Item { } } -class CrudeBatteryItem : BatteryItem(ItemsConfig.Batteries.BATTERY_CRUDE) { +class CrudeBatteryItem : BatteryItem(ItemsConfig.Batteries.CRUDE) { override fun appendHoverText( stack: ItemStack, p_41422_: Level?, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt index 222194986..336e24038 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt @@ -11,7 +11,6 @@ import net.minecraft.world.level.Level import net.minecraftforge.common.capabilities.ICapabilityProvider import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.EnergyProducerItem import ru.dbotthepony.mc.otm.capability.energy.ItemEnergyStorageImpl @@ -64,7 +63,7 @@ open class SingleUseBatteryItem( } } -class ZPMItem : SingleUseBatteryItem(ItemsConfig.Batteries.ZPM_BATTERY, Properties().stacksTo(1).rarity(Rarity.EPIC)) { +class ZPMItem : SingleUseBatteryItem(ItemsConfig.Batteries.ZPM, Properties().stacksTo(1).rarity(Rarity.EPIC)) { override fun appendHoverText( itemStack: ItemStack, p_41422_: Level?, 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 163fad55e..ae570b824 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -15,7 +15,6 @@ import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.config.ItemsConfig -import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.core.collect.SupplierList import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.item.* @@ -201,10 +200,10 @@ object MItems { ) val BATTERY_CRUDE: Item by registry.register(MNames.BATTERY_CRUDE) { CrudeBatteryItem() } - val BATTERY_BASIC: Item by registry.register(MNames.BATTERY_BASIC) { BatteryItem(ItemsConfig.Batteries.BATTERY_BASIC) } - val BATTERY_NORMAL: Item by registry.register(MNames.BATTERY_NORMAL) { BatteryItem(ItemsConfig.Batteries.BATTERY_NORMAL) } - val BATTERY_DENSE: Item by registry.register(MNames.BATTERY_DENSE) { BatteryItem(ItemsConfig.Batteries.BATTERY_DENSE) } - val BATTERY_CAPACITOR: Item by registry.register(MNames.BATTERY_CAPACITOR) { BatteryItem(ItemsConfig.Batteries.BATTERY_CAPACITOR) } + val BATTERY_BASIC: Item by registry.register(MNames.BATTERY_BASIC) { BatteryItem(ItemsConfig.Batteries.BASIC) } + val BATTERY_NORMAL: Item by registry.register(MNames.BATTERY_NORMAL) { BatteryItem(ItemsConfig.Batteries.NORMAL) } + val BATTERY_DENSE: Item by registry.register(MNames.BATTERY_DENSE) { BatteryItem(ItemsConfig.Batteries.DENSE) } + val BATTERY_CAPACITOR: Item by registry.register(MNames.BATTERY_CAPACITOR) { BatteryItem(ItemsConfig.Batteries.CAPACITOR) } val BATTERY_CREATIVE: Item by registry.register(MNames.BATTERY_CREATIVE) { BatteryItem() } val QUANTUM_BATTERY: Item by registry.register(MNames.QUANTUM_BATTERY) { QuantumBatteryItem(MNames.QUANTUM_BATTERY, ItemsConfig.Batteries.QUANTUM_BATTERY) } @@ -241,9 +240,9 @@ object MItems { ::ZPM_BATTERY, ) - val MATTER_CAPACITOR_BASIC: Item by registry.register(MNames.MATTER_CAPACITOR_BASIC) { MatterCapacitorItem(ItemsConfig.Capacitors::MATTER_CAPACITOR_BASIC) } - val MATTER_CAPACITOR_NORMAL: Item by registry.register(MNames.MATTER_CAPACITOR_NORMAL) { MatterCapacitorItem(ItemsConfig.Capacitors::MATTER_CAPACITOR_NORMAL) } - val MATTER_CAPACITOR_DENSE: Item by registry.register(MNames.MATTER_CAPACITOR_DENSE) { MatterCapacitorItem(ItemsConfig.Capacitors::MATTER_CAPACITOR_DENSE) } + val MATTER_CAPACITOR_BASIC: Item by registry.register(MNames.MATTER_CAPACITOR_BASIC) { MatterCapacitorItem(ItemsConfig.Capacitors::BASIC) } + val MATTER_CAPACITOR_NORMAL: Item by registry.register(MNames.MATTER_CAPACITOR_NORMAL) { MatterCapacitorItem(ItemsConfig.Capacitors::NORMAL) } + val MATTER_CAPACITOR_DENSE: Item by registry.register(MNames.MATTER_CAPACITOR_DENSE) { MatterCapacitorItem(ItemsConfig.Capacitors::DENSE) } val MATTER_CAPACITOR_CREATIVE: Item by registry.register(MNames.MATTER_CAPACITOR_CREATIVE) { MatterCapacitorItem() } val MATTER_CAPACITORS = SupplierList( From 4ca63a0650327e7d7df1167964805bfe9b351063 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 10 Feb 2023 16:51:22 +0700 Subject: [PATCH 0189/1199] Actually, this should be enough --- .../mc/otm/compat/ExtendedInventoryHandler.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/ExtendedInventoryHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/ExtendedInventoryHandler.kt index 2e1a2afdc..d27d2759c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/ExtendedInventoryHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/ExtendedInventoryHandler.kt @@ -186,6 +186,18 @@ private class FakeSlot : MatterySlot(SimpleContainer(1), 0, 0, 0) { override fun allowModification(p_150652_: Player): Boolean { return false } + + override fun isActive(): Boolean { + return false + } + + override fun getMaxStackSize(pStack: ItemStack): Int { + return 0 + } + + override fun getMaxStackSize(): Int { + return 0 + } } class InventoryScrollPacket(val scroll: Int) : MatteryPacket { From abe53a417fa5bacc7ea5b4c36d630c1a967267c3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 10 Feb 2023 19:00:47 +0700 Subject: [PATCH 0190/1199] Enable koremods, bump Kotlin to 1.8.0 --- build.gradle.kts | 28 +++++++++++++++------------- gradle.properties | 5 ++++- settings.gradle.kts | 24 ++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 4a1022857..c759d0761 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -21,6 +21,8 @@ plugins { id("net.minecraftforge.gradle") id("org.spongepowered.mixin") id("org.parchmentmc.librarian.forgegradle") + id("wtf.gofancy.fancygradle") + id("wtf.gofancy.koremods.gradle") } configurations { @@ -148,6 +150,7 @@ dependencies { val kotlin_coroutines_version: String by project val kotlin_serialization_version: String by project val mixin_version: String by project + val koremods_modlauncher_version: String by project minecraft("net.minecraftforge:forge:$mc_version-$forge_version") testImplementation("org.junit.jupiter:junit-jupiter:${jupiter_version}") @@ -161,28 +164,16 @@ dependencies { (this as ExternalModuleDependency).exclude(group = "org.jetbrains", module = "annotations") } as Closure - // Add everything to the classpath correctly klibrary(create("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version", excludeKGroup)) klibrary(create("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version", excludeKGroup)) klibrary(create("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version", excludeKGroup)) klibrary(create("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$kotlin_coroutines_version", excludeKGroup)) klibrary(create("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlin_serialization_version", excludeKGroup)) - // Real mod deobf dependency examples - these get remapped to your current mappings - // compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency - // runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency - // implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency - - // Examples using mod jars from ./libs + koremods(group = "wtf.gofancy.koremods", name = "koremods-modlauncher", version = koremods_modlauncher_version) compileOnly("yalter.mousetweaks:MouseTweaks:2.23:api") - annotationProcessor("org.spongepowered:mixin:${mixin_version}:processor") - // compile against the JEI API but do not include it at runtime - //compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") - // at runtime, use the full JEI jar - //runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") - if (handleDeps) { val jei_version: String by project val mekanism_version: String by project @@ -331,6 +322,17 @@ repositories { } } + maven(url = "https://maven.gofancy.wtf/releases") { + name = "Garden of Fancy" + + content { + includeGroup("wtf.gofancy.koremods") + includeGroup("wtf.gofancy.fancygradle") + includeGroup("wtf.gofancy.koremods.gradle") + includeGroup("codes.som") + } + } + maven { name = "Kotlin for Forge" url = uri("https://thedarkcolour.github.io/KotlinForForge/") diff --git a/gradle.properties b/gradle.properties index f8b7672a6..f237a0a31 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,6 +10,9 @@ mod_version=1.1 use_commit_hash_in_version=true +koremods_modlauncher_version=0.5.7 +koremods_script_version=0.5.0 + mc_version=1.19.3 parchment_version=2022.12.18-1.19.3 jei_mc_version=1.19.3 @@ -31,7 +34,7 @@ worldedit_fileid=3922622 more_overlays_version=1.21.3-mc1.19 kotlin_for_forge_version=3.1.0 -kotlin_version=1.6.10 +kotlin_version=1.8.0 kotlin_coroutines_version=1.6.0 kotlin_serialization_version=1.3.2 diff --git a/settings.gradle.kts b/settings.gradle.kts index d51bd0be5..022ac9e13 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -5,6 +5,8 @@ buildscript { repositories { // These repositories are only for Gradle plugins, put any other repositories in the repository block further below maven(url = "https://maven.minecraftforge.net") { + name = "Minecraft Forge" + content { includeGroup("net.minecraftforge.gradle") includeGroup("net.minecraftforge") @@ -12,18 +14,33 @@ buildscript { } maven(url = "https://repo.spongepowered.org/repository/maven-public/") { + name = "Spongepowered" + content { includeGroup("org.spongepowered") } } maven(url = "https://maven.parchmentmc.org") { + name = "Parchment mappings" + content { includeGroup("org.parchmentmc") includeGroup("org.parchmentmc.feather") } } + maven(url = "https://maven.gofancy.wtf/releases") { + name = "Garden of Fancy" + + content { + includeGroup("wtf.gofancy.koremods") + includeGroup("wtf.gofancy.fancygradle") + includeGroup("wtf.gofancy.koremods.gradle") + includeGroup("codes.som") + } + } + mavenCentral() } @@ -31,11 +48,18 @@ buildscript { val kotlin_version: String by settings val forge_gradle_version: String by settings val mixingradle_version: String by settings + val koremods_modlauncher_version: String by settings + val koremods_script_version: String by settings classpath(group = "net.minecraftforge.gradle", name = "ForgeGradle", version = forge_gradle_version) classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}") classpath("org.spongepowered:mixingradle:${mixingradle_version}") classpath(group = "org.parchmentmc", name = "librarian", version = "1.+") + + classpath(group = "wtf.gofancy.koremods", name = "koremods-gradle", version = "0.1.23") + classpath(group = "wtf.gofancy.fancygradle", name = "wtf.gofancy.fancygradle.gradle.plugin", version = "1.1.2-3") + classpath(group = "wtf.gofancy.koremods", name = "koremods-modlauncher", version = koremods_modlauncher_version) + classpath(group = "wtf.gofancy.koremods", name = "koremods-script", version = koremods_script_version) } } From 536c959f4726eb183e586995b0ad0f6212890c97 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 10 Feb 2023 19:04:29 +0700 Subject: [PATCH 0191/1199] Update code to reflect newer kotlin version --- README.md | 11 ++++++----- .../ru/dbotthepony/mc/otm/OverdriveThatMatters.java | 4 ++-- src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c153ece08..c702f104a 100644 --- a/README.md +++ b/README.md @@ -5,19 +5,20 @@ Minecraft mod with science fiction style, about matter, and energy, combined. ### Required mods -* [Kotlin for Forge](https://www.curseforge.com/minecraft/mc-mods/kotlin-for-forge) or have Kotlin standard library in classpath +* [Kotlin for Forge](https://www.curseforge.com/minecraft/mc-mods/kotlin-for-forge) or have Kotlin standard library in classpath (at least 1.8.0 is required) +* [Koremods](https://beta.curseforge.com/minecraft/mc-mods/koremods) ### Recommended mods * [Ferrite Core](https://www.curseforge.com/minecraft/mc-mods/ferritecore), reduces memory usage * In case of Overdrive That Matters, ***greatly*** reduces JVM heap bloat caused by model data being duplicated -### Supported mods +### Mods with special compatibility code -* [Mekanism](https://www.curseforge.com/minecraft/mc-mods/Mekanism) (full duplex Mekanism Joules support, QIO) -* [Curios](https://www.curseforge.com/minecraft/mc-mods/curios) (GUI support, technical inventory access) -* [Cosmetic Armor Reworked](https://www.curseforge.com/minecraft/mc-mods/cosmetic-armor-reworked) (GUI support, technical inventory access) * [JEI](https://www.curseforge.com/minecraft/mc-mods/jei) +* [Mekanism](https://www.curseforge.com/minecraft/mc-mods/Mekanism) +* [Curios](https://www.curseforge.com/minecraft/mc-mods/curios) +* [Cosmetic Armor Reworked](https://www.curseforge.com/minecraft/mc-mods/cosmetic-armor-reworked) ---- diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index e14fd89a5..dc2768d39 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -76,8 +76,8 @@ public final class OverdriveThatMatters { } private static void checkIfKotlinIsInstalled() { - if (!KotlinVersion.CURRENT.isAtLeast(1, 6, 10)) { - throw new UnsupportedClassVersionError("Installed kotlin version is " + KotlinVersion.CURRENT + ", when at least 1.6.10 is required."); + if (!KotlinVersion.CURRENT.isAtLeast(1, 8, 0)) { + throw new UnsupportedClassVersionError("Installed kotlin version is " + KotlinVersion.CURRENT + ", when at least 1.8.0 is required."); } } 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 f744436af..6a5fae9fe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -252,7 +252,7 @@ inline fun MutableList>.forValidRefs(fn: (T) -> Unit) { } val ComponentContents.key: String - get() = (this as? TranslatableContents ?: throw ClassCastException("$this is not a TranslatableContents"))?.key + get() = (this as? TranslatableContents ?: throw ClassCastException("$this is not a TranslatableContents")).key fun > BlockState.getValueNullable(prop: Property): T? { if (hasProperty(prop)) { From 1b1d58eb83be968d25106ff3d332818ca38c25d5 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 10 Feb 2023 20:09:35 +0700 Subject: [PATCH 0192/1199] This is not required --- build.gradle.kts | 1 - settings.gradle.kts | 1 - 2 files changed, 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index c759d0761..09b76bff3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -21,7 +21,6 @@ plugins { id("net.minecraftforge.gradle") id("org.spongepowered.mixin") id("org.parchmentmc.librarian.forgegradle") - id("wtf.gofancy.fancygradle") id("wtf.gofancy.koremods.gradle") } diff --git a/settings.gradle.kts b/settings.gradle.kts index 022ac9e13..b42315a03 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -58,7 +58,6 @@ buildscript { classpath(group = "org.parchmentmc", name = "librarian", version = "1.+") classpath(group = "wtf.gofancy.koremods", name = "koremods-gradle", version = "0.1.23") - classpath(group = "wtf.gofancy.fancygradle", name = "wtf.gofancy.fancygradle.gradle.plugin", version = "1.1.2-3") classpath(group = "wtf.gofancy.koremods", name = "koremods-modlauncher", version = koremods_modlauncher_version) classpath(group = "wtf.gofancy.koremods", name = "koremods-script", version = koremods_script_version) } From 1adf633fbd41029fccc4fdad14dc54b60dd125ca Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 10 Feb 2023 20:18:23 +0700 Subject: [PATCH 0193/1199] I guess no koremods for me --- build.gradle.kts | 13 ------------- settings.gradle.kts | 15 --------------- 2 files changed, 28 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 09b76bff3..f96881ddf 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -21,7 +21,6 @@ plugins { id("net.minecraftforge.gradle") id("org.spongepowered.mixin") id("org.parchmentmc.librarian.forgegradle") - id("wtf.gofancy.koremods.gradle") } configurations { @@ -169,7 +168,6 @@ dependencies { klibrary(create("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$kotlin_coroutines_version", excludeKGroup)) klibrary(create("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlin_serialization_version", excludeKGroup)) - koremods(group = "wtf.gofancy.koremods", name = "koremods-modlauncher", version = koremods_modlauncher_version) compileOnly("yalter.mousetweaks:MouseTweaks:2.23:api") annotationProcessor("org.spongepowered:mixin:${mixin_version}:processor") @@ -321,17 +319,6 @@ repositories { } } - maven(url = "https://maven.gofancy.wtf/releases") { - name = "Garden of Fancy" - - content { - includeGroup("wtf.gofancy.koremods") - includeGroup("wtf.gofancy.fancygradle") - includeGroup("wtf.gofancy.koremods.gradle") - includeGroup("codes.som") - } - } - maven { name = "Kotlin for Forge" url = uri("https://thedarkcolour.github.io/KotlinForForge/") diff --git a/settings.gradle.kts b/settings.gradle.kts index b42315a03..c424d90e3 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -30,17 +30,6 @@ buildscript { } } - maven(url = "https://maven.gofancy.wtf/releases") { - name = "Garden of Fancy" - - content { - includeGroup("wtf.gofancy.koremods") - includeGroup("wtf.gofancy.fancygradle") - includeGroup("wtf.gofancy.koremods.gradle") - includeGroup("codes.som") - } - } - mavenCentral() } @@ -56,9 +45,5 @@ buildscript { classpath("org.spongepowered:mixingradle:${mixingradle_version}") classpath(group = "org.parchmentmc", name = "librarian", version = "1.+") - - classpath(group = "wtf.gofancy.koremods", name = "koremods-gradle", version = "0.1.23") - classpath(group = "wtf.gofancy.koremods", name = "koremods-modlauncher", version = koremods_modlauncher_version) - classpath(group = "wtf.gofancy.koremods", name = "koremods-script", version = koremods_script_version) } } From 3a829813413e74837043ad35d97ae74463e14a1a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 10 Feb 2023 20:43:12 +0700 Subject: [PATCH 0194/1199] =?UTF-8?q?=E2=9A=99=20SHOCKY=20=E2=80=94=20?= =?UTF-8?q?=D0=A1=D0=B5=D0=B3=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=2020:42=20?= =?UTF-8?q?=D1=87=D1=82=D0=BE=20=D0=BD=D0=B5=20=D1=82=D0=B0=D0=BA.=20...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/block/pattern_storage_pattern.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/pattern_storage_pattern.json b/src/main/resources/assets/overdrive_that_matters/models/block/pattern_storage_pattern.json index 52099239b..5a7ad6e22 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/pattern_storage_pattern.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/pattern_storage_pattern.json @@ -16,5 +16,5 @@ "down": {"uv": [1, 14, 15, 15], "texture": "#texture"} } } - ], + ] } \ No newline at end of file From faa64a47c3815d7ab3df7963f8ecdbc78dc58250 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 10 Feb 2023 21:23:45 +0700 Subject: [PATCH 0195/1199] Proper phantoms spawn hook --- .../mc/otm/OverdriveThatMatters.java | 1 - .../otm/capability/MatteryPlayerCapability.kt | 13 +++++++++ src/main/resources/coremods/code_injector.js | 27 +++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index dc2768d39..6e92cacc6 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -154,7 +154,6 @@ public final class OverdriveThatMatters { EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayerCapability.Companion::onPlayerChangeDimensionEvent); EVENT_BUS.addListener(EventPriority.LOWEST, MatteryPlayerCapability.Companion::onPlayerDeath); EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayerCapability.Companion::onPlayerCloneEvent); - EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayerCapability.Companion::canEntitySpawn); EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayerCapability.Companion::onStartTracking); EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayerCapability.Companion::onStopTracking); diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index c71ac169e..c73cc4d96 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -1015,6 +1015,19 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial private val LOGGER = LogManager.getLogger() + /** + * hooked into PhantomSpawner through coremod script + */ + @JvmStatic + fun phantomSpawnHook(player: Player): Boolean { + if (player.matteryPlayer?.isAndroid == true) { + val feature = player.matteryPlayer?.getFeature(AndroidFeatures.PHANTOM_ATTRACTOR) as AndroidSwitchableFeature? + return feature?.isActive == true + } + + return true + } + fun canEntitySpawn(event: LivingSpawnEvent.CheckSpawn) { if (event.spawnReason == MobSpawnType.NATURAL && event.entity is Phantom) { for (ply in event.entity.level.players()) { diff --git a/src/main/resources/coremods/code_injector.js b/src/main/resources/coremods/code_injector.js index 884576aad..f733d2489 100644 --- a/src/main/resources/coremods/code_injector.js +++ b/src/main/resources/coremods/code_injector.js @@ -616,6 +616,33 @@ function backtrack(instructions, from, opcode, skipAmount) { function initializeCoreMod() { return { + 'PhantomSpawner block spawns as android': method('net.minecraft.world.level.levelgen.PhantomSpawner.m_7995_(Lnet/minecraft/server/level/ServerLevel;ZZ)I', function(node) { + var isSpectator = ASMAPI.mapMethod('m_5833_') + + for (var i = 0; i < node.instructions.size(); i++) { + var instr = node.instructions.get(i) + + if (instr.getOpcode() == opcodesRemapped.invokevirtual && instr.name == isSpectator) { + var aload = backtrack(node.instructions, i, opcodesRemapped.aload) + + putInstructions(node, instr, [ + new VarInsnNode(opcodesRemapped.aload, aload["var"]), + new MethodInsnNode( + opcodesRemapped.invokestatic, + 'ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability', + 'phantomSpawnHook', + '(Lnet/minecraft/world/entity/player/Player;)Z' + ), + new InsnNode(opcodesRemapped.iand) + ]) + + return node + } + } + + return node + }), + 'Inventory#dropAll': injectAtTail( 'net.minecraft.world.entity.player.Inventory.m_36071_()V', [ From 685ac399b6c5394b2feff94ecd6b23ed8a1a0583 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 10 Feb 2023 21:23:59 +0700 Subject: [PATCH 0196/1199] fix items config --- src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt index 6fe596eaf..1cac81e2b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt @@ -89,4 +89,8 @@ object ItemsConfig : AbstractConfig("items") { object PatternDrives { val NORMAL: Int by builder.defineInRange(MNames.PATTERN_DRIVE_NORMAL, 4, 1, Int.MAX_VALUE) } + + init { + PatternDrives + } } From a7266ec01e7b162e859b994d4ea0fee8a50667b8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 10 Feb 2023 21:27:28 +0700 Subject: [PATCH 0197/1199] Add missing pattern drives to creative menu --- src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt index 4e43c9d01..bedd47f92 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt @@ -130,6 +130,9 @@ internal fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { energized(MItems.ALL_BATTERIES) mattery(MItems.MATTER_CAPACITORS) + accept(MItems.PATTERN_DRIVE_NORMAL) + accept(MItems.PATTERN_DRIVE_CREATIVE) + accept(MItems.PATTERN_DRIVE_CREATIVE2) base(MItems.CARGO_CRATE_MINECARTS) From 513ef21926eba86beb38d8fb7a25463a1b477b81 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 14 Feb 2023 22:49:57 +0700 Subject: [PATCH 0198/1199] Idiot proof network read methods --- .../dbotthepony/mc/otm/core/math/Decimal.kt | 8 +- .../mc/otm/core/util/DataStreams.kt | 73 ++++++++++++------- .../mc/otm/core/util/FriendlyStreams.kt | 49 ++++++++----- .../mc/otm/data/SerializedFunctionRegistry.kt | 11 ++- .../mc/otm/network/FieldSynchronizer.kt | 17 +++-- 5 files changed, 100 insertions(+), 58 deletions(-) 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 40f72c805..39f471d84 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 @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.core.math import net.minecraft.nbt.ByteArrayTag import net.minecraft.nbt.CompoundTag +import net.minecraft.nbt.NbtAccounter import net.minecraft.nbt.StringTag import net.minecraft.nbt.Tag import net.minecraft.network.FriendlyByteBuf @@ -859,8 +860,11 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 fun FriendlyByteBuf.readDecimal() = Decimal.read(this) fun FriendlyByteBuf.writeDecimal(value: Decimal) = value.write(this) -fun InputStream.readDecimal(): Decimal { - val bytes = ByteArray(readVarIntLE()) +fun InputStream.readDecimal(sizeLimit: NbtAccounter = NbtAccounter(512L)): Decimal { + val size = readVarIntLE(sizeLimit) + require(size >= 0) { "Negative payload size: $size" } + sizeLimit.accountBytes(size.toLong() + 8L) + val bytes = ByteArray(size) read(bytes) return Decimal(BigInteger(bytes), readDouble()) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt index 95c4308d3..b4ea5972d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt @@ -1,9 +1,12 @@ package ru.dbotthepony.mc.otm.core.util +import net.minecraft.nbt.NbtAccounter import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.core.math.readDecimal import ru.dbotthepony.mc.otm.core.math.writeDecimal +import java.io.DataInput import java.io.DataInputStream +import java.io.DataOutput import java.io.DataOutputStream import java.io.InputStream import java.io.OutputStream @@ -18,7 +21,7 @@ import kotlin.math.absoluteValue * Also provides [copy] and [compare] methods */ interface IStreamCodec { - fun read(stream: DataInputStream): V + fun read(stream: DataInputStream, sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 KiB */)): V fun write(stream: DataOutputStream, value: V) /** @@ -37,13 +40,21 @@ interface IStreamCodec { } class StreamCodec( - private val reader: (stream: DataInputStream) -> V, + private val reader: (stream: DataInputStream, sizeLimit: NbtAccounter) -> V, private val writer: (stream: DataOutputStream, value: V) -> Unit, private val copier: ((value: V) -> V) = { it }, private val comparator: ((a: V, b: V) -> Boolean) = { a, b -> a == b } ) : IStreamCodec { - override fun read(stream: DataInputStream): V { - return reader.invoke(stream) + constructor( + reader: (stream: DataInputStream) -> V, + payloadSize: Long, + writer: (stream: DataOutputStream, value: V) -> Unit, + copier: ((value: V) -> V) = { it }, + comparator: ((a: V, b: V) -> Boolean) = { a, b -> a == b } + ) : this({ stream, sizeLimit -> sizeLimit.accountBytes(payloadSize); reader.invoke(stream) }, writer, copier, comparator) + + override fun read(stream: DataInputStream, sizeLimit: NbtAccounter): V { + return reader.invoke(stream, sizeLimit) } override fun write(stream: DataOutputStream, value: V) { @@ -59,18 +70,18 @@ class StreamCodec( } } -val NullValueCodec = StreamCodec({ null }, { _, _ -> }) -val BooleanValueCodec = StreamCodec(DataInputStream::readBoolean, DataOutputStream::writeBoolean) -val ByteValueCodec = StreamCodec(DataInputStream::readByte, { s, v -> s.writeByte(v.toInt()) }) -val ShortValueCodec = StreamCodec(DataInputStream::readShort, { s, v -> s.writeShort(v.toInt()) }) -val IntValueCodec = StreamCodec(DataInputStream::readInt, DataOutputStream::writeInt) -val LongValueCodec = StreamCodec(DataInputStream::readLong, DataOutputStream::writeLong) -val FloatValueCodec = StreamCodec(DataInputStream::readFloat, DataOutputStream::writeFloat) -val DoubleValueCodec = StreamCodec(DataInputStream::readDouble, DataOutputStream::writeDouble) +val NullValueCodec = StreamCodec({ _, _ -> null }, { _, _ -> }) +val BooleanValueCodec = StreamCodec(DataInputStream::readBoolean, 1L, DataOutputStream::writeBoolean) +val ByteValueCodec = StreamCodec(DataInputStream::readByte, 1L, { s, v -> s.writeByte(v.toInt()) }) +val ShortValueCodec = StreamCodec(DataInputStream::readShort, 2L, { s, v -> s.writeShort(v.toInt()) }) +val IntValueCodec = StreamCodec(DataInputStream::readInt, 4L, DataOutputStream::writeInt) +val LongValueCodec = StreamCodec(DataInputStream::readLong, 8L, DataOutputStream::writeLong) +val FloatValueCodec = StreamCodec(DataInputStream::readFloat, 4L, DataOutputStream::writeFloat) +val DoubleValueCodec = StreamCodec(DataInputStream::readDouble, 8L, DataOutputStream::writeDouble) val ItemStackValueCodec = StreamCodec(DataInputStream::readItem, DataOutputStream::writeItem, ItemStack::copy) { a, b -> a.equals(b, true) } val ImpreciseFractionValueCodec = StreamCodec(DataInputStream::readDecimal, DataOutputStream::writeDecimal) val BigDecimalValueCodec = StreamCodec(DataInputStream::readBigDecimal, DataOutputStream::writeBigDecimal) -val UUIDValueCodec = StreamCodec({ s -> UUID(s.readLong(), s.readLong()) }, { s, v -> s.writeLong(v.mostSignificantBits); s.writeLong(v.leastSignificantBits) }) +val UUIDValueCodec = StreamCodec({ s, a -> a.accountBytes(8L); UUID(s.readLong(), s.readLong()) }, { s, v -> s.writeLong(v.mostSignificantBits); s.writeLong(v.leastSignificantBits) }) val VarIntValueCodec = StreamCodec(DataInputStream::readVarIntLE, DataOutputStream::writeVarIntLE) val VarLongValueCodec = StreamCodec(DataInputStream::readVarLongLE, DataOutputStream::writeVarLongLE) val BinaryStringCodec = StreamCodec(DataInputStream::readBinaryString, DataOutputStream::writeBinaryString) @@ -79,13 +90,13 @@ class EnumValueCodec>(clazz: Class, val writeByIndices: Boole val clazz = searchClass(clazz) private val values = searchClass(clazz).enumConstants!! - override fun read(stream: DataInputStream): V { + override fun read(stream: DataInputStream, sizeLimit: NbtAccounter): V { if (writeByIndices) { - val id = stream.readVarIntLE() + val id = stream.readVarIntLE(sizeLimit) return values.getOrNull(id) ?: throw NoSuchElementException("No such enum with index $id") } - val id = stream.readBinaryString() + val id = stream.readBinaryString(sizeLimit) return values.firstOrNull { id == it.name } ?: throw NoSuchElementException("No such enum $id") } @@ -127,7 +138,7 @@ class EnumValueCodec>(clazz: Class, val writeByIndices: Boole } fun OutputStream.writeInt(value: Int) { - if (this is DataOutputStream) { + if (this is DataOutput) { writeInt(value) return } @@ -139,7 +150,7 @@ fun OutputStream.writeInt(value: Int) { } fun InputStream.readInt(): Int { - if (this is DataInputStream) { + if (this is DataInput) { return readInt() } @@ -147,7 +158,7 @@ fun InputStream.readInt(): Int { } fun OutputStream.writeLong(value: Long) { - if (this is DataOutputStream) { + if (this is DataOutput) { writeLong(value) return } @@ -162,7 +173,7 @@ fun OutputStream.writeLong(value: Long) { } fun InputStream.readLong(): Long { - if (this is DataInputStream) { + if (this is DataInput) { return readLong() } @@ -180,7 +191,8 @@ fun InputStream.readFloat() = Float.fromBits(readInt()) fun OutputStream.writeDouble(value: Double) = writeLong(value.toBits()) fun InputStream.readDouble() = Double.fromBits(readLong()) -fun InputStream.readVarIntLE(): Int { +fun InputStream.readVarIntLE(sizeLimit: NbtAccounter? = null): Int { + sizeLimit?.accountBytes(1L) val readFirst = read() if (readFirst < 0) { @@ -198,6 +210,7 @@ fun InputStream.readVarIntLE(): Int { while (nextBit != 0) { result = result or (read shl i) + sizeLimit?.accountBytes(1L) read = read() if (read < 0) { @@ -227,7 +240,9 @@ fun OutputStream.writeVarIntLE(value: Int) { } } -fun InputStream.readVarLongLE(): Long { +fun InputStream.readVarLongLE(sizeLimit: NbtAccounter? = null): Long { + sizeLimit?.accountBytes(1L) + val readFirst = read() if (readFirst < 0) { @@ -245,6 +260,7 @@ fun InputStream.readVarLongLE(): Long { while (nextBit != 0) { result = result or (read shl i).toLong() + sizeLimit?.accountBytes(1L) read = read() if (read < 0) { @@ -274,8 +290,10 @@ fun OutputStream.writeVarLongLE(value: Long) { } } -fun InputStream.readBinaryString(): String { +fun InputStream.readBinaryString(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 KiB */)): String { val size = readVarIntLE() + require(size >= 0) { "Negative payload size: $size" } + sizeLimit.accountBytes(size.toLong()) val bytes = ByteArray(size) read(bytes) return bytes.decodeToString() @@ -292,8 +310,8 @@ private data class IndexedStreamCodec( val id: Int, val codec: StreamCodec ) { - fun read(stream: DataInputStream): T { - return codec.read(stream) + fun read(stream: DataInputStream, sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 KiB */)): T { + return codec.read(stream, sizeLimit) } fun write(stream: DataOutputStream, value: Any?) { @@ -346,12 +364,13 @@ fun DataOutputStream.writeType(value: Any?) { /** * Read arbitrary data from this stream, in exploit-free way */ -fun DataInputStream.readType(): Any? { +fun DataInputStream.readType(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 KiB */)): Any? { + sizeLimit.accountBytes(1L) val id = read() if (id >= codecs.size) { throw IndexOutOfBoundsException("No codec for network type $id") } - return codecs[id].read(this) + return codecs[id].read(this, sizeLimit) } 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 01a6dc749..cb67e89bd 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 @@ -18,6 +18,7 @@ import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraftforge.registries.ForgeRegistries import net.minecraftforge.registries.ForgeRegistry +import org.apache.commons.lang3.mutable.MutableInt import java.io.* import java.math.BigDecimal import java.math.BigInteger @@ -36,7 +37,7 @@ fun OutputStream.writeNbt(value: CompoundTag) { } } -fun InputStream.readNbt(accounter: NbtAccounter = NbtAccounter.UNLIMITED): CompoundTag { +fun InputStream.readNbt(accounter: NbtAccounter = NbtAccounter(1L shl 18 /* 256 KiB */)): CompoundTag { return try { NbtIo.read(if (this is DataInputStream) this else DataInputStream(this), accounter) } catch (ioexception: IOException) { @@ -68,17 +69,19 @@ fun OutputStream.writeItem(itemStack: ItemStack, limitedTag: Boolean = true) { } } -fun InputStream.readItem(): ItemStack { +fun InputStream.readItem(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 KiB */)): ItemStack { + sizeLimit.accountBytes(1L) + if (read() == 0) { return ItemStack.EMPTY } - + sizeLimit.accountBytes(9L) val item = (ForgeRegistries.ITEMS as ForgeRegistry).getValue(readInt()) val itemStack = ItemStack(item, readInt()) if (read() != 0) { - itemStack.readShareTag(readNbt()) + itemStack.readShareTag(readNbt(sizeLimit)) } return itemStack @@ -91,9 +94,11 @@ fun OutputStream.writeBigDecimal(value: BigDecimal) { write(bytes) } -fun InputStream.readBigDecimal(): BigDecimal { +fun InputStream.readBigDecimal(sizeLimit: NbtAccounter = NbtAccounter(512L)): BigDecimal { val scale = readInt() - val size = readVarIntLE() + val size = readVarIntLE(sizeLimit) + require(size >= 0) { "Negative payload size: $size" } + sizeLimit.accountBytes(size.toLong() + 4L) val bytes = ByteArray(size) read(bytes) return BigDecimal(BigInteger(bytes), scale) @@ -180,25 +185,33 @@ fun OutputStream.writeJson(element: JsonElement) { * * just copy pasted this code from my another project because i was lazy */ -fun InputStream.readJson(): JsonElement { +fun InputStream.readJson(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 KiB */)): JsonElement { + sizeLimit.accountBytes(1L) + return when (val id = read()) { TYPE_NULL -> JsonNull.INSTANCE - TYPE_DOUBLE -> JsonPrimitive(readDouble()) - TYPE_BOOLEAN -> JsonPrimitive(read() > 1) - TYPE_INT -> JsonPrimitive(fixSignedInt(readVarLongLE())) - TYPE_STRING -> JsonPrimitive(readBinaryString()) + TYPE_DOUBLE -> { + sizeLimit.accountBytes(8L) + JsonPrimitive(readDouble()) + } + TYPE_BOOLEAN -> { + sizeLimit.accountBytes(1L) + JsonPrimitive(read() > 1) + } + TYPE_INT -> JsonPrimitive(fixSignedInt(readVarLongLE(sizeLimit))) + TYPE_STRING -> JsonPrimitive(readBinaryString(sizeLimit)) TYPE_ARRAY -> { - val values = readVarIntLE() + val values = readVarIntLE(sizeLimit) if (values == 0) return JsonArray() if (values < 0) throw JsonSyntaxException("Tried to read json array with $values elements in it") val build = JsonArray(values) - for (i in 0 until values) build.add(readJson()) + for (i in 0 until values) build.add(readJson(sizeLimit)) return build } TYPE_OBJECT -> { - val values = readVarIntLE() + val values = readVarIntLE(sizeLimit) if (values == 0) return JsonObject() if (values < 0) throw JsonSyntaxException("Tried to read json object with $values elements in it") @@ -208,13 +221,13 @@ fun InputStream.readJson(): JsonElement { val key: String try { - key = readBinaryString() + key = readBinaryString(sizeLimit) } catch(err: Throwable) { throw JsonSyntaxException("Reading json object at $i", err) } try { - build.add(key, readJson()) + build.add(key, readJson(sizeLimit)) } catch(err: Throwable) { throw JsonSyntaxException("Reading json object at $i with name $key", err) } @@ -226,8 +239,8 @@ fun InputStream.readJson(): JsonElement { } } -fun FriendlyByteBuf.readJson(): JsonElement { - return ByteBufInputStream(this).readJson() +fun FriendlyByteBuf.readJson(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18)): JsonElement { + return ByteBufInputStream(this).readJson(sizeLimit) } fun FriendlyByteBuf.writeJson(value: JsonElement) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/SerializedFunctionRegistry.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/SerializedFunctionRegistry.kt index 548d43200..0a916f07b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/SerializedFunctionRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/SerializedFunctionRegistry.kt @@ -17,6 +17,7 @@ import io.netty.buffer.ByteBufInputStream import io.netty.buffer.ByteBufOutputStream import it.unimi.dsi.fastutil.io.FastByteArrayInputStream import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream +import net.minecraft.nbt.NbtAccounter import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.core.util.readType @@ -175,9 +176,10 @@ class SerializedFunctionRegistry(val gson: Gson = Gson()) : JsonSerializer val stream = DataInputStream(ByteBufInputStream(buff)) val arguments = LinkedList() + val sizeLimit = NbtAccounter(1L shl 18 /* 256 KiB */) - for (i in 0 until stream.readVarIntLE()) { - arguments.add(stream.readType()) + for (i in 0 until stream.readVarIntLE(sizeLimit)) { + arguments.add(stream.readType(sizeLimit)) } return map[id]?.bind(arguments) @@ -192,9 +194,10 @@ class SerializedFunctionRegistry(val gson: Gson = Gson()) : JsonSerializer val argumentString = value["arguments"]?.asString ?: return null val stream = DataInputStream(FastByteArrayInputStream(Base64.getDecoder().decode(argumentString))) val arguments = LinkedList() + val sizeLimit = NbtAccounter(1L shl 18 /* 256 KiB */) - for (i in 0 until stream.readVarIntLE()) { - arguments.add(stream.readType()) + for (i in 0 until stream.readVarIntLE(sizeLimit)) { + arguments.add(stream.readType(sizeLimit)) } return map[ResourceLocation(id)]?.bind(arguments) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt index d3b1b5cd7..af8e37281 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt @@ -8,6 +8,7 @@ import it.unimi.dsi.fastutil.objects.ObjectArraySet import it.unimi.dsi.fastutil.objects.Reference2ObjectFunction import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.ReferenceArraySet +import net.minecraft.nbt.NbtAccounter import net.minecraft.world.item.ItemStack import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.core.* @@ -1111,15 +1112,15 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa private val missingFields = ObjectArraySet() private val missingFieldsMap = Int2ObjectArrayMap() - fun applyNetworkPayload(stream: InputStream): Int { + fun applyNetworkPayload(stream: InputStream, sizeLimit: NbtAccounter = NbtAccounter(1L shl 21 /* 2 MiB */)): Int { if (stream.read() > 0) { idToField.clear() missingFieldsMap.clear() - var fieldId = stream.readVarIntLE() + var fieldId = stream.readVarIntLE(sizeLimit) while (fieldId != 0) { - val size = stream.readVarIntLE() + val size = stream.readVarIntLE(sizeLimit) val nameBytes = ByteArray(size) stream.read(nameBytes) val name = String(nameBytes, Charsets.UTF_8) @@ -1137,27 +1138,29 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa findField.id = fieldId } - fieldId = stream.readVarIntLE() + fieldId = stream.readVarIntLE(sizeLimit) } } - var fieldId = stream.readVarIntLE() + var fieldId = stream.readVarIntLE(sizeLimit) var i = 0 while (fieldId != 0) { val field = idToField[fieldId] - val payloadSize = stream.readVarIntLE() + val payloadSize = stream.readVarIntLE(sizeLimit) if (field == null) { LOGGER.error("Unable to read field $fieldId (${missingFieldsMap[fieldId]}) because we don't know anything about it! Skipping $payloadSize bytes", IllegalStateException("Unknown field $fieldId")) + sizeLimit.accountBytes(payloadSize.toLong()) stream.skipNBytes(payloadSize.toLong()) continue } + sizeLimit.accountBytes(payloadSize.toLong()) val bytes = ByteArray(payloadSize) stream.read(bytes) field.read(DataInputStream(FastByteArrayInputStream(bytes)), payloadSize) - fieldId = stream.readVarIntLE() + fieldId = stream.readVarIntLE(sizeLimit) i++ } From b254a705d7e565bd4b628e67a258c9738af5755e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 15 Feb 2023 14:23:57 +0700 Subject: [PATCH 0199/1199] applyNetworkPayload -> read --- .../ru/dbotthepony/mc/otm/android/AndroidFeature.kt | 2 +- .../ru/dbotthepony/mc/otm/android/AndroidResearch.kt | 2 +- .../dbotthepony/mc/otm/network/FieldSynchronizer.kt | 4 +--- .../mc/otm/network/MatteryPlayerNetworkChannel.kt | 4 ++-- .../dbotthepony/mc/otm/network/MenuNetworkChannel.kt | 2 +- .../mc/otm/network/WorldNetworkChannel.kt | 2 +- .../mc/otm/tests/FieldSynchronizerTests.kt | 12 ++++++------ 7 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeature.kt index 51010446e..736a3da2c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeature.kt @@ -40,7 +40,7 @@ abstract class AndroidFeature(val type: AndroidFeatureType<*>, val android: Matt } open fun applyNetworkPayload(stream: InputStream) { - synchronizer.applyNetworkPayload(stream) + synchronizer.read(stream) } override fun serializeNBT(): CompoundTag { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt index 03553c2d2..154d7dba9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt @@ -196,7 +196,7 @@ class AndroidResearch(val type: AndroidResearchType, val capability: MatteryPlay } fun applyNetworkPayload(stream: InputStream) { - synchronizer.applyNetworkPayload(stream) + synchronizer.read(stream) } val canResearch: Boolean get() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt index af8e37281..d9e3f8068 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt @@ -39,13 +39,11 @@ import java.io.InputStream import java.lang.ref.WeakReference import java.math.BigDecimal import java.util.* -import java.util.function.Consumer import java.util.function.Supplier import kotlin.ConcurrentModificationException import kotlin.collections.ArrayList import kotlin.collections.HashMap import kotlin.properties.ReadOnlyProperty -import kotlin.properties.ReadWriteProperty import kotlin.reflect.KMutableProperty0 import kotlin.reflect.KProperty import kotlin.reflect.KProperty0 @@ -1112,7 +1110,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa private val missingFields = ObjectArraySet() private val missingFieldsMap = Int2ObjectArrayMap() - fun applyNetworkPayload(stream: InputStream, sizeLimit: NbtAccounter = NbtAccounter(1L shl 21 /* 2 MiB */)): Int { + fun read(stream: InputStream, sizeLimit: NbtAccounter = NbtAccounter(1L shl 21 /* 2 MiB */)): Int { if (stream.read() > 0) { idToField.clear() missingFieldsMap.clear() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt index 0abf41fb7..1d66bc2fa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt @@ -60,9 +60,9 @@ class MatteryPlayerFieldPacket(val bytes: ByteArray, val length: Int, val isPubl } if (isPublic) { - player.publicSynchronizer.applyNetworkPayload(ByteArrayInputStream(bytes, 0, length)) + player.publicSynchronizer.read(ByteArrayInputStream(bytes, 0, length)) } else { - player.synchronizer.applyNetworkPayload(ByteArrayInputStream(bytes, 0, length)) + player.synchronizer.read(ByteArrayInputStream(bytes, 0, length)) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt index f5d70c0af..0c5fd3cb4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt @@ -32,7 +32,7 @@ class MenuFieldPacket(val bytes: ByteArray, val length: Int) : MatteryPacket { override fun play(context: Supplier) { context.packetHandled = true context.get().enqueueWork { - (minecraft.player?.containerMenu as? MatteryMenu)?.mSynchronizer?.applyNetworkPayload(ByteArrayInputStream(bytes, 0, length)) + (minecraft.player?.containerMenu as? MatteryMenu)?.mSynchronizer?.read(ByteArrayInputStream(bytes, 0, length)) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt index f9d56b474..9e8cfc865 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt @@ -25,7 +25,7 @@ class BlockEntitySyncPacket(val position: BlockPos, val buffer: ByteArray, val v val blockEntity = level.getBlockEntity(position) as? SynchronizedBlockEntity ?: return@enqueueWork try { - blockEntity.synchronizer.applyNetworkPayload(FastByteArrayInputStream(buffer, 0, validBytes)) + blockEntity.synchronizer.read(FastByteArrayInputStream(buffer, 0, validBytes)) } catch(err: Throwable) { LOGGER.error("Exception while reading synchronized BlockEntity data!\nPosition: $position\nBlock: ${level.getBlockState(position)}\nBlock entity: $blockEntity", err) throw err diff --git a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FieldSynchronizerTests.kt b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FieldSynchronizerTests.kt index 1d70b17a4..550469f3f 100644 --- a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FieldSynchronizerTests.kt +++ b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FieldSynchronizerTests.kt @@ -31,7 +31,7 @@ object FieldSynchronizerTests { intA2.value = 348488 intA3.value = -4 - b.applyNetworkPayload(a.collectNetworkPayload()!!.let { ByteArrayInputStream(it.array, 0, it.length) }) + b.read(a.collectNetworkPayload()!!.let { ByteArrayInputStream(it.array, 0, it.length) }) assertEquals(boolA.value, boolB.value) assertEquals(intA.value, intB.value) @@ -62,7 +62,7 @@ object FieldSynchronizerTests { //intA2.setValue(348488) intA3.value = -4 - b.applyNetworkPayload(a.collectNetworkPayload()!!.let { ByteArrayInputStream(it.array, 0, it.length) }) + b.read(a.collectNetworkPayload()!!.let { ByteArrayInputStream(it.array, 0, it.length) }) assertEquals(boolA.value, boolB.value) assertEquals(intA.value, intB.value) @@ -95,8 +95,8 @@ object FieldSynchronizerTests { f4.value = 80L - b.applyNetworkPayload(bEndpoint.collectNetworkPayload()!!.let { ByteArrayInputStream(it.array, 0, it.length) }) - c.applyNetworkPayload(cEndpoint.collectNetworkPayload()!!.let { ByteArrayInputStream(it.array, 0, it.length) }) + b.read(bEndpoint.collectNetworkPayload()!!.let { ByteArrayInputStream(it.array, 0, it.length) }) + c.read(cEndpoint.collectNetworkPayload()!!.let { ByteArrayInputStream(it.array, 0, it.length) }) for ((i, field) in bFields.withIndex()) { assertEquals(aFields[i].value, field.value) @@ -125,7 +125,7 @@ object FieldSynchronizerTests { fieldsa[i].value = i } - b.applyNetworkPayload(a.collectNetworkPayload()!!.let { ByteArrayInputStream(it.array, 0, it.length) }) + b.read(a.collectNetworkPayload()!!.let { ByteArrayInputStream(it.array, 0, it.length) }) for (i in 0 .. 900) { assertEquals(fieldsa[i].value, fieldsb[i].value) @@ -153,7 +153,7 @@ object FieldSynchronizerTests { fieldsa[i].value = i } - b.applyNetworkPayload(a.collectNetworkPayload()!!.let { ByteArrayInputStream(it.array, 0, it.length) }) + b.read(a.collectNetworkPayload()!!.let { ByteArrayInputStream(it.array, 0, it.length) }) for (i in 0 .. 900) { assertEquals(fieldsa[i].value, fieldsb[i].value) From 370aca1e6a2327cfbe387da3487609e6d58b9df6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 15 Feb 2023 17:31:59 +0700 Subject: [PATCH 0200/1199] Cobblestone generator device --- .../mc/otm/datagen/lang/English.kt | 9 +- .../mc/otm/datagen/lang/Russian.kt | 9 +- .../mc/otm/datagen/loot/LootTablesData.kt | 2 + .../datagen/recipes/CraftingTableRecipes.kt | 7 ++ .../dbotthepony/mc/otm/datagen/tags/Tags.kt | 1 + .../block/entity/MatteryPoweredBlockEntity.kt | 25 +++--- .../block/entity/MatteryWorkerBlockEntity.kt | 6 +- .../block/entity/tech/CobblerBlockEntity.kt | 82 +++++++++++++++++++ .../mc/otm/block/tech/CobblerBlock.kt | 29 +++++++ .../otm/client/screen/tech/CobblerScreen.kt | 27 ++++++ .../otm/menu/input/EnumInputWithFeedback.kt | 4 + .../mc/otm/menu/tech/CobblerMenu.kt | 34 ++++++++ .../mc/otm/registry/MBlockEntities.kt | 1 + .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 2 + .../ru/dbotthepony/mc/otm/registry/MItems.kt | 36 ++++---- .../ru/dbotthepony/mc/otm/registry/MMenus.kt | 4 + .../ru/dbotthepony/mc/otm/registry/MNames.kt | 1 + 17 files changed, 237 insertions(+), 42 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/CobblerBlock.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/CobblerScreen.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 6dc802e52..cdf677bb2 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -116,6 +116,8 @@ private fun sounds(provider: MatteryLanguageProvider) { private fun misc(provider: MatteryLanguageProvider) { with(provider.english) { + misc("needs_no_power", "Requires no power to operate") + gui("lock_holo_screen", "Lock contents") gui("lock_holo_screen.tip", "Locking and unlocking contents is only possible in creative.\nWhen locked, text boundaries are removed.") @@ -373,6 +375,7 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.MATTER_BOTTLER, "Matter Bottler") add(MBlocks.DRIVE_VIEWER, "Drive Viewer") add(MBlocks.BLACK_HOLE, "Local Anomalous Singular Gravitation Field") + add(MBlocks.COBBLESTONE_GENERATOR, "Cobblestone Generator") add(MBlocks.ENGINE, "Ship Engine") add(MBlocks.HOLO_SIGN, "Holo Sign") @@ -412,13 +415,11 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.GRAVITATION_STABILIZER, "Space-Time Equalizer") add(MBlocks.GRAVITATION_STABILIZER_LENS, "Space-Time Equalizer Lens") add(MBlocks.GRAVITATION_STABILIZER, "desc", "Reduces gravitation effects of singularities") - add(MBlocks.GRAVITATION_STABILIZER, "desc2", "Requires no power to operate") - add(MBlocks.GRAVITATION_STABILIZER, "desc3", "Keep in mind the effect of multiple stabilizers produce exponentially increasing result") - add(MBlocks.GRAVITATION_STABILIZER, "desc4", "Too weak gravitation field will cause singularity to melt and evaporate away very fast") + add(MBlocks.GRAVITATION_STABILIZER, "desc2", "Keep in mind the effect of multiple stabilizers produce exponentially increasing result") + add(MBlocks.GRAVITATION_STABILIZER, "desc3", "Too weak gravitation field will cause singularity to melt and evaporate away very fast") add(MBlocks.PHANTOM_ATTRACTOR, "Phantom Attractor") add(MBlocks.PHANTOM_ATTRACTOR, "desc", "Attracts Phantoms when it is night time") - add(MBlocks.PHANTOM_ATTRACTOR, "desc2", "Requires no power to operate") add(MBlocks.LABORATORY_LAMP, "Laboratory Lamp") add(MBlocks.LABORATORY_LAMP, "description", "Provides directional light with redstone switch") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 2093b565c..f333f0d35 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -125,6 +125,8 @@ private fun sounds(provider: MatteryLanguageProvider) { private fun misc(provider: MatteryLanguageProvider) { with(provider.russian) { + misc("needs_no_power", "Не требует энергии для работы") + gui("lock_holo_screen", "Заблокировать содержимое") gui("lock_holo_screen.tip", "Блокировка и разблокировка содержимого возможна только в режиме творчества.\nКогда заблокировано, границы ввода текста отключены.") @@ -378,6 +380,7 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.MATTER_BOTTLER, "Бутилировщик Материи") add(MBlocks.DRIVE_VIEWER, "Просмотрщик Дисков Конденсации") add(MBlocks.BLACK_HOLE, "Локализированное Аномальное Сингулярное Гравитационное Поле") + add(MBlocks.COBBLESTONE_GENERATOR, "Генератор Булыжника") add(MBlocks.ENGINE, "Двигатель Корабля") add(MBlocks.HOLO_SIGN, "Голографическая Табличка") @@ -417,13 +420,11 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.GRAVITATION_STABILIZER, "Стабилизатор Пространства-Времени") add(MBlocks.GRAVITATION_STABILIZER_LENS, "Линза Стабилизатора Пространства-Времени") add(MBlocks.GRAVITATION_STABILIZER, "desc", "Уменьшает гравитационное влияние сингулярностей") - add(MBlocks.GRAVITATION_STABILIZER, "desc2", "Не требует энергии для работы") - add(MBlocks.GRAVITATION_STABILIZER, "desc3", "Имейте в ввиду, что несколько стабилизаторов создают экспоненциальный эффект") - add(MBlocks.GRAVITATION_STABILIZER, "desc4", "Слишком слабое гравитационное поле сингулярности приведёт к быстрому испарению последней") + add(MBlocks.GRAVITATION_STABILIZER, "desc2", "Имейте в ввиду, что несколько стабилизаторов создают экспоненциальный эффект") + add(MBlocks.GRAVITATION_STABILIZER, "desc3", "Слишком слабое гравитационное поле сингулярности приведёт к быстрому испарению последней") add(MBlocks.PHANTOM_ATTRACTOR, "Приманщик Фантомов") add(MBlocks.PHANTOM_ATTRACTOR, "desc", "Приманивает фантомов в ночное время") - add(MBlocks.PHANTOM_ATTRACTOR, "desc2", "Не требует энергии для работы") add(MBlocks.LABORATORY_LAMP, "Лабораторная Лампа") add(MBlocks.LABORATORY_LAMP, "description", "Освещает на несколько блоков в направлении своей лампы, с переключателем красного камня") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index 8bb1a3831..a6321136b 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -58,6 +58,8 @@ fun addLootTables(lootTables: LootTables) { lootTables.dropsSelf(MBlocks.METAL_BEAM) { condition(ExplosionCondition.survivesExplosion()) } lootTables.dropsSelf(MBlocks.TRITANIUM_INGOT_BLOCK) { condition(ExplosionCondition.survivesExplosion()) } + lootTables.tile(MBlocks.COBBLESTONE_GENERATOR) + lootTables.dropsSelf(MBlocks.ENGINE) { condition(ExplosionCondition.survivesExplosion()) } for (door in MBlocks.TRITANIUM_TRAPDOOR.values) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index 230497240..19d69f99a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -253,4 +253,11 @@ fun addCraftingTableRecipes(consumer: Consumer) { .row(MItemTags.CRAFTING_TABLES, MItems.QUANTUM_TRANSCEIVER, MItemTags.CRAFTING_TABLES) .row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) .build(consumer) + + // генератор коблы + MatteryRecipe(MItems.COBBLESTONE_GENERATOR, category = machinesCategory) + .row(MItemTags.HARDENED_GLASS_COLORLESS, MItems.TRITANIUM_PICKAXE, MItemTags.HARDENED_GLASS_COLORLESS) + .row(Items.LAVA_BUCKET, Items.HOPPER, Items.WATER_BUCKET) + .rowB(Tags.Items.CHESTS) + .build(consumer) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index e726c1a6e..ad9a713a6 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -145,6 +145,7 @@ fun addTags(tagsProvider: TagsProvider) { MBlocks.ENGINE, MBlocks.HOLO_SIGN, + MBlocks.COBBLESTONE_GENERATOR, ), Tiers.IRON) tagsProvider.requiresPickaxe(MBlocks.TRITANIUM_ORE, Tiers.IRON) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt index 37396ca9b..791544ebd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt @@ -26,22 +26,22 @@ import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set abstract class MatteryPoweredBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: BlockPos, p_155230_: BlockState) : MatteryBlockEntity(p_155228_, p_155229_, p_155230_) { - abstract val energy: BlockEnergyStorageImpl + abstract val energy: BlockEnergyStorageImpl? private var valid = true val batteryContainer = MatteryContainer(this::setChangedLight, 1) protected fun batteryChargeLoop() { - if (!batteryContainer.any { !it.isEmpty }) + if (energy == null || !batteryContainer.any { !it.isEmpty }) return - var demand = energy.receiveEnergy(energy.missingPower, true) + var demand = energy!!.receiveEnergy(energy!!.missingPower, true) if (demand.isZero) return for (stack in batteryContainer) { if (!stack.isEmpty) { stack.getCapability(ForgeCapabilities.ENERGY).ifPresentK { val diff = it.extractEnergy(demand, false) - energy.receiveEnergy(diff, false) + energy!!.receiveEnergy(diff, false) demand -= diff } @@ -53,31 +53,36 @@ abstract class MatteryPoweredBlockEntity(p_155228_: BlockEntityType<*>, p_155229 override fun invalidateCaps() { super.invalidateCaps() - energy.invalidate() + energy?.invalidate() valid = false } override fun reviveCaps() { super.reviveCaps() - energy.revive() + energy?.revive() valid = true } override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - if (valid && (cap == MatteryCapability.ENERGY || cap == ForgeCapabilities.ENERGY)) - return energy.resolver.cast() + if (valid && (cap === MatteryCapability.ENERGY || cap === ForgeCapabilities.ENERGY) && energy != null) + return energy!!.resolver.cast() return super.getCapability(cap, side) } public override fun saveAdditional(nbt: CompoundTag) { super.saveAdditional(nbt) - nbt[ENERGY_KEY] = energy.serializeNBT() + + if (energy != null) + nbt[ENERGY_KEY] = energy!!.serializeNBT() + nbt[BATTERY_KEY] = batteryContainer.serializeNBT() } override fun load(nbt: CompoundTag) { - nbt.ifHas(ENERGY_KEY, CompoundTag::class.java, energy::deserializeNBT) + if (energy != null) + nbt.ifHas(ENERGY_KEY, CompoundTag::class.java, energy!!::deserializeNBT) + batteryContainer.deserializeNBT(nbt[BATTERY_KEY]) super.load(nbt) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt index 6084266ac..7eef81a74 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt @@ -288,7 +288,7 @@ abstract class MatteryWorkerBlockEntity( currentJob = job } - if (!currentJob.powerUsage.isZero && energy.batteryLevel.isZero) { + if (!currentJob.powerUsage.isZero && (energy == null || energy!!.batteryLevel.isZero)) { idleReason = IdleReason.POWER isIdling = true idleTicksAnim++ @@ -316,7 +316,7 @@ abstract class MatteryWorkerBlockEntity( ticksAdvanced = availableTicks.coerceAtMost(ticksLeft) } else { requiredPower = currentJob.powerUsage * ticksLeft.coerceAtMost(availableTicks) - extractedPower = energy.extractEnergy(requiredPower, true) + extractedPower = energy!!.extractEnergy(requiredPower, true) ticksAdvanced = (extractedPower / requiredPower).toDouble().coerceAtMost(ticksLeft).coerceAtMost(availableTicks) } @@ -346,7 +346,7 @@ abstract class MatteryWorkerBlockEntity( extractedPower = status.newDrainedPower ?: extractedPower if (extractedPower != null) { - energy.extractEnergy(extractedPower, false) + energy!!.extractEnergy(extractedPower, false) } continue diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt new file mode 100644 index 000000000..07a2c7b29 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt @@ -0,0 +1,82 @@ +package ru.dbotthepony.mc.otm.block.entity.tech + +import net.minecraft.core.BlockPos +import net.minecraft.core.Direction +import net.minecraft.nbt.CompoundTag +import net.minecraft.network.chat.Component +import net.minecraft.world.Container +import net.minecraft.world.entity.player.Inventory +import net.minecraft.world.entity.player.Player +import net.minecraft.world.inventory.AbstractContainerMenu +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.Items +import net.minecraft.world.level.block.state.BlockState +import net.minecraftforge.common.capabilities.Capability +import net.minecraftforge.common.capabilities.ForgeCapabilities +import net.minecraftforge.common.util.LazyOptional +import ru.dbotthepony.mc.otm.block.IDroppableContainer +import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity +import ru.dbotthepony.mc.otm.container.MatteryContainer +import ru.dbotthepony.mc.otm.container.MatteryContainerHooks +import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.menu.tech.CobblerMenu +import ru.dbotthepony.mc.otm.registry.MBlockEntities + +class CobblerBlockEntity(blockPos: BlockPos, blockState: BlockState) + : MatteryWorkerBlockEntity(MBlockEntities.COBBLESTONE_GENERATOR, blockPos, blockState, ::ItemJob), IDroppableContainer { + override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { + return CobblerMenu(containerID, inventory, this) + } + + override val energy = null + override val droppableContainer = MatteryContainer(this::itemContainerUpdated, CONTAINER_SIZE) + val handler = droppableContainer.handler(object : MatteryContainerHooks { + override fun canInsert(slot: Int, stack: ItemStack): Boolean { + return false + } + }) + + override fun getCapability(cap: Capability, side: Direction?): LazyOptional { + if (cap === ForgeCapabilities.ITEM_HANDLER) + return handler.get().cast() + + return super.getCapability(cap, side) + } + + override fun invalidateCaps() { + super.invalidateCaps() + handler.invalidate() + } + + override fun reviveCaps() { + super.reviveCaps() + handler.revive() + } + + override fun saveAdditional(nbt: CompoundTag) { + super.saveAdditional(nbt) + nbt[INVENTORY_KEY] = droppableContainer.serializeNBT() + } + + override fun load(nbt: CompoundTag) { + super.load(nbt) + nbt.map(INVENTORY_KEY, droppableContainer::deserializeNBT) + } + + override fun onJobFinish(job: ItemJob): Status { + if (!droppableContainer.fullyAddItem(job.itemStack)) { + return Status.FAILURE_ITEM + } + + return Status.SUCCESS + } + + override fun computeNextJob(): Pair { + return ItemJob(ItemStack(Items.COBBLESTONE), 40.0) to null + } + + companion object { + const val CONTAINER_SIZE = 16 + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/CobblerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/CobblerBlock.kt new file mode 100644 index 000000000..c92f427ae --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/CobblerBlock.kt @@ -0,0 +1,29 @@ +package ru.dbotthepony.mc.otm.block.tech + +import net.minecraft.core.BlockPos +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.EntityBlock +import net.minecraft.world.level.block.entity.BlockEntity +import net.minecraft.world.level.block.entity.BlockEntityTicker +import net.minecraft.world.level.block.entity.BlockEntityType +import net.minecraft.world.level.block.state.BlockState +import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.entity.tech.CobblerBlockEntity + +class CobblerBlock : RotatableMatteryBlock(), EntityBlock { + override fun newBlockEntity(pPos: BlockPos, pState: BlockState): BlockEntity { + return CobblerBlockEntity(pPos, pState) + } + + override fun getTicker( + pLevel: Level, + pState: BlockState, + pBlockEntityType: BlockEntityType + ): BlockEntityTicker? { + if (!pLevel.isClientSide) { + return BlockEntityTicker { _, _, _, pBlockEntity -> if (pBlockEntity is CobblerBlockEntity) pBlockEntity.basicTicker() } + } + + return null + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/CobblerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/CobblerScreen.kt new file mode 100644 index 000000000..42b304b03 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/CobblerScreen.kt @@ -0,0 +1,27 @@ +package ru.dbotthepony.mc.otm.client.screen.tech + +import net.minecraft.network.chat.Component +import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls +import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel +import ru.dbotthepony.mc.otm.menu.tech.CobblerMenu + +class CobblerScreen(menu: CobblerMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { + override fun makeMainFrame(): FramePanel> { + val frame = super.makeMainFrame()!! + + ProgressGaugePanel(this, frame, menu.progress, 30f, 42f) + + for (row in 0 .. 3) + for (column in 0 .. 3) + SlotPanel(this, frame, menu.storageSlots[row * 4 + column], 80f + column * AbstractSlotPanel.SIZE, 17f + row * AbstractSlotPanel.SIZE) + + makeDeviceControls(this, frame, redstone = menu.redstone) + + return frame + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt index f03279bd4..fe9dfabfd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt @@ -5,6 +5,10 @@ import ru.dbotthepony.mc.otm.core.util.EnumValueCodec import ru.dbotthepony.mc.otm.menu.MatteryMenu import kotlin.reflect.KMutableProperty0 +inline fun > EnumInputWithFeedback(menu: MatteryMenu) = EnumInputWithFeedback(menu, E::class.java) +inline fun > EnumInputWithFeedback(menu: MatteryMenu, state: KMutableProperty0) = EnumInputWithFeedback(menu, E::class.java, state) +inline fun > EnumInputWithFeedback(menu: MatteryMenu, state: GetterSetter) = EnumInputWithFeedback(menu, E::class.java, state) + class EnumInputWithFeedback>(menu: MatteryMenu, clazz: Class) : AbstractPlayerInputWithFeedback() { val codec = EnumValueCodec(clazz) private val default = codec.clazz.enumConstants!![0] diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt new file mode 100644 index 000000000..0ee1adb62 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt @@ -0,0 +1,34 @@ +package ru.dbotthepony.mc.otm.menu.tech + +import net.minecraft.world.SimpleContainer +import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting +import ru.dbotthepony.mc.otm.block.entity.tech.CobblerBlockEntity +import ru.dbotthepony.mc.otm.core.ImmutableList +import ru.dbotthepony.mc.otm.menu.MachineOutputSlot +import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback +import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget +import ru.dbotthepony.mc.otm.registry.MMenus + +class CobblerMenu @JvmOverloads constructor( + p_38852_: Int, + inventory: Inventory, + tile: CobblerBlockEntity? = null +) : MatteryMenu(MMenus.COBBLESTONE_GENERATOR, p_38852_, inventory, tile) { + override val storageSlots = (tile?.droppableContainer ?: SimpleContainer(CobblerBlockEntity.CONTAINER_SIZE)).let { c -> ImmutableList(c.containerSize) { addSlot(MachineOutputSlot(c, it)) } } + val redstone = EnumInputWithFeedback(this) + + val progress: ProgressGaugeWidget + + init { + if (tile == null) + progress = ProgressGaugeWidget(this) + else { + progress = ProgressGaugeWidget(this, tile::workProgress, tile::isUnableToProcess) + redstone.with(tile.redstoneControl::redstoneSetting) + } + + addInventorySlots() + } +} 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 7e87582b3..b0e1e28c5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt @@ -55,6 +55,7 @@ object MBlockEntities { val GRAVITATION_STABILIZER: BlockEntityType by registry.register(MNames.GRAVITATION_STABILIZER) { BlockEntityType.Builder.of(::GravitationStabilizerBlockEntity, MBlocks.GRAVITATION_STABILIZER).build(null) } val MATTER_RECYCLER: BlockEntityType by registry.register(MNames.MATTER_RECYCLER) { BlockEntityType.Builder.of(::MatterRecyclerBlockEntity, MBlocks.MATTER_RECYCLER).build(null) } val ENERGY_SERVO: BlockEntityType by registry.register(MNames.ENERGY_SERVO) { BlockEntityType.Builder.of(::EnergyServoBlockEntity, MBlocks.ENERGY_SERVO).build(null) } + val COBBLESTONE_GENERATOR: BlockEntityType by registry.register(MNames.COBBLESTONE_GENERATOR) { BlockEntityType.Builder.of(::CobblerBlockEntity, MBlocks.COBBLESTONE_GENERATOR).build(null) } val STORAGE_BUS: BlockEntityType by registry.register(MNames.STORAGE_BUS) { BlockEntityType.Builder.of(::StorageBusBlockEntity, MBlocks.STORAGE_BUS).build(null) } val STORAGE_IMPORTER: BlockEntityType by registry.register(MNames.STORAGE_IMPORTER) { BlockEntityType.Builder.of(::StorageImporterBlockEntity, MBlocks.STORAGE_IMPORTER).build(null) } 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 610485890..fb2eb2935 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -60,6 +60,7 @@ import ru.dbotthepony.mc.otm.block.storage.StorageBusBlock import ru.dbotthepony.mc.otm.block.storage.StorageExporterBlock import ru.dbotthepony.mc.otm.block.storage.StorageImporterBlock import ru.dbotthepony.mc.otm.block.storage.StoragePowerSupplierBlock +import ru.dbotthepony.mc.otm.block.tech.CobblerBlock import ru.dbotthepony.mc.otm.core.TranslatableComponent object MBlocks { @@ -84,6 +85,7 @@ object MBlocks { val PLATE_PRESS: Block by registry.register(MNames.PLATE_PRESS) { PlatePressBlock() } val MATTER_RECYCLER: Block by registry.register(MNames.MATTER_RECYCLER) { MatterRecyclerBlock() } val ENERGY_SERVO: Block by registry.register(MNames.ENERGY_SERVO) { EnergyServoBlock() } + val COBBLESTONE_GENERATOR: Block by registry.register(MNames.COBBLESTONE_GENERATOR) { CobblerBlock() } val STORAGE_BUS: Block by registry.register(MNames.STORAGE_BUS) { StorageBusBlock() } val STORAGE_IMPORTER: Block by registry.register(MNames.STORAGE_IMPORTER) { StorageImporterBlock() } 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 ae570b824..a4f1959a3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -58,46 +58,31 @@ object MItems { val GRAVITATION_STABILIZER: Item by registry.register(MNames.GRAVITATION_STABILIZER) { object : BlockItem(MBlocks.GRAVITATION_STABILIZER, DEFAULT_PROPERTIES) { - override fun appendHoverText( - p_40572_: ItemStack, - p_40573_: Level?, - p_40574_: MutableList, - p_40575_: TooltipFlag - ) { + override fun appendHoverText(p_40572_: ItemStack, p_40573_: Level?, p_40574_: MutableList, p_40575_: TooltipFlag) { super.appendHoverText(p_40572_, p_40573_, p_40574_, p_40575_) p_40574_.add(TranslatableComponent("${MBlocks.GRAVITATION_STABILIZER.descriptionId}.desc").withStyle(ChatFormatting.GRAY)) + p_40574_.add(TranslatableComponent("otm.needs_no_power").withStyle(ChatFormatting.DARK_GRAY)) p_40574_.add(TranslatableComponent("${MBlocks.GRAVITATION_STABILIZER.descriptionId}.desc2").withStyle(ChatFormatting.DARK_GRAY)) p_40574_.add(TranslatableComponent("${MBlocks.GRAVITATION_STABILIZER.descriptionId}.desc3").withStyle(ChatFormatting.DARK_GRAY)) - p_40574_.add(TranslatableComponent("${MBlocks.GRAVITATION_STABILIZER.descriptionId}.desc4").withStyle(ChatFormatting.DARK_GRAY)) } } } val PHANTOM_ATTRACTOR: Item by registry.register(MNames.PHANTOM_ATTRACTOR) { object : DoubleHighBlockItem(MBlocks.PHANTOM_ATTRACTOR, DEFAULT_PROPERTIES) { - override fun appendHoverText( - p_40572_: ItemStack, - p_40573_: Level?, - p_40574_: MutableList, - p_40575_: TooltipFlag - ) { + override fun appendHoverText(p_40572_: ItemStack, p_40573_: Level?, p_40574_: MutableList, p_40575_: TooltipFlag) { super.appendHoverText(p_40572_, p_40573_, p_40574_, p_40575_) p_40574_.add(TranslatableComponent("${MBlocks.PHANTOM_ATTRACTOR.descriptionId}.desc").withStyle(ChatFormatting.GRAY)) - p_40574_.add(TranslatableComponent("${MBlocks.PHANTOM_ATTRACTOR.descriptionId}.desc2").withStyle(ChatFormatting.DARK_GRAY)) + p_40574_.add(TranslatableComponent("otm.needs_no_power").withStyle(ChatFormatting.DARK_GRAY)) } } } val ENERGY_SERVO: Item by registry.register(MNames.ENERGY_SERVO) { object : BlockItem(MBlocks.ENERGY_SERVO, DEFAULT_PROPERTIES) { - override fun appendHoverText( - p_40572_: ItemStack, - p_40573_: Level?, - p_40574_: MutableList, - p_40575_: TooltipFlag - ) { + override fun appendHoverText(p_40572_: ItemStack, p_40573_: Level?, p_40574_: MutableList, p_40575_: TooltipFlag) { super.appendHoverText(p_40572_, p_40573_, p_40574_, p_40575_) p_40574_.add(TranslatableComponent("${MBlocks.ENERGY_SERVO.descriptionId}.desc").withStyle(ChatFormatting.GRAY)) @@ -105,13 +90,22 @@ object MItems { } } + val COBBLESTONE_GENERATOR: Item by registry.register(MNames.COBBLESTONE_GENERATOR) { + object : BlockItem(MBlocks.COBBLESTONE_GENERATOR, DEFAULT_PROPERTIES) { + override fun appendHoverText(p_40572_: ItemStack, p_40573_: Level?, p_40574_: MutableList, p_40575_: TooltipFlag) { + super.appendHoverText(p_40572_, p_40573_, p_40574_, p_40575_) + p_40574_.add(TranslatableComponent("otm.needs_no_power").withStyle(ChatFormatting.GRAY)) + } + } + } + val MACHINES = SupplierList( ::ANDROID_STATION, ::BATTERY_BANK, ::MATTER_DECOMPOSER, ::MATTER_CAPACITOR_BANK, ::MATTER_CABLE, ::PATTERN_STORAGE, ::MATTER_SCANNER, ::MATTER_PANEL, ::MATTER_REPLICATOR, ::MATTER_BOTTLER, ::ENERGY_COUNTER, ::CHEMICAL_GENERATOR, ::PLATE_PRESS, ::MATTER_RECYCLER, ::STORAGE_BUS, ::STORAGE_IMPORTER, ::STORAGE_EXPORTER, ::DRIVE_VIEWER, ::DRIVE_RACK, ::ITEM_MONITOR, ::STORAGE_CABLE, ::STORAGE_POWER_SUPPLIER, ::ENERGY_SERVO, ::PHANTOM_ATTRACTOR, - ::GRAVITATION_STABILIZER, + ::GRAVITATION_STABILIZER, ::COBBLESTONE_GENERATOR ) val DEBUG_EXPLOSION_SMALL: Item by registry.register(MNames.DEBUG_EXPLOSION_SMALL) { BlockItem(MBlocks.DEBUG_EXPLOSION_SMALL, Item.Properties().stacksTo(64)) } 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 dd08c720e..ca87fe476 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt @@ -28,6 +28,7 @@ import ru.dbotthepony.mc.otm.client.screen.storage.StoragePowerSupplierScreen import ru.dbotthepony.mc.otm.client.screen.tech.AndroidStationScreen import ru.dbotthepony.mc.otm.client.screen.tech.BatteryBankScreen import ru.dbotthepony.mc.otm.client.screen.tech.ChemicalGeneratorScreen +import ru.dbotthepony.mc.otm.client.screen.tech.CobblerScreen import ru.dbotthepony.mc.otm.client.screen.tech.EnergyCounterScreen import ru.dbotthepony.mc.otm.client.screen.tech.EnergyServoScreen import ru.dbotthepony.mc.otm.client.screen.tech.PlatePressScreen @@ -52,6 +53,7 @@ import ru.dbotthepony.mc.otm.menu.storage.StoragePowerSupplierMenu import ru.dbotthepony.mc.otm.menu.tech.AndroidStationMenu import ru.dbotthepony.mc.otm.menu.tech.BatteryBankMenu import ru.dbotthepony.mc.otm.menu.tech.ChemicalGeneratorMenu +import ru.dbotthepony.mc.otm.menu.tech.CobblerMenu import ru.dbotthepony.mc.otm.menu.tech.EnergyCounterMenu import ru.dbotthepony.mc.otm.menu.tech.EnergyServoMenu import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu @@ -79,6 +81,7 @@ object MMenus { val MATTER_RECYCLER: MenuType<*> by registry.register(MNames.MATTER_RECYCLER) { MenuType(::MatterRecyclerMenu) } val ENERGY_SERVO: MenuType<*> by registry.register(MNames.ENERGY_SERVO) { MenuType(::EnergyServoMenu) } val HOLO_SIGN: MenuType by registry.register(MNames.HOLO_SIGN) { MenuType(::HoloSignMenu) } + val COBBLESTONE_GENERATOR: MenuType by registry.register(MNames.COBBLESTONE_GENERATOR) { MenuType(::CobblerMenu) } val STORAGE_BUS: MenuType<*> by registry.register(MNames.STORAGE_BUS) { MenuType(::StorageBusMenu) } val STORAGE_EXPORTER: MenuType<*> by registry.register(MNames.STORAGE_EXPORTER) { MenuType(::StorageExporterMenu) } @@ -117,6 +120,7 @@ object MMenus { MenuScreens.register(STORAGE_POWER_SUPPLIER as MenuType, ::StoragePowerSupplierScreen) MenuScreens.register(ENERGY_SERVO as MenuType, ::EnergyServoScreen) MenuScreens.register(HOLO_SIGN, ::HoloSignScreen) + MenuScreens.register(COBBLESTONE_GENERATOR, ::CobblerScreen) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index 228b39c0e..79b463c2a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -31,6 +31,7 @@ object MNames { const val PLATE_PRESS = "plate_press" const val MATTER_RECYCLER = "matter_recycler" const val ENERGY_SERVO = "energy_servo" + const val COBBLESTONE_GENERATOR = "cobblestone_generator" const val STORAGE_CABLE = "storage_cable" // нужен рецепт const val STORAGE_POWER_SUPPLIER = "storage_power_supplier" // нужен рецепт From 0ee5673ea983dc9b026b0b866dea471eb3899465 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 16 Feb 2023 13:12:29 +0700 Subject: [PATCH 0201/1199] A lot of refactoring related to block entities, capability helpers and save helpers --- .../mc/otm/datagen/loot/LootTables.kt | 10 +- .../mc/otm/datagen/loot/LootTablesData.kt | 6 +- .../mc/otm/OverdriveThatMatters.java | 14 +- .../mc/otm/capability/MatteryCapability.java | 5 +- .../dbotthepony/mc/otm/block/MatteryBlock.kt | 8 +- .../mc/otm/block/entity/MatteryBlockEntity.kt | 790 ++++++++++++++++-- .../block/entity/MatteryDeviceBlockEntity.kt | 64 ++ .../block/entity/MatteryPoweredBlockEntity.kt | 2 +- .../mc/otm/block/entity/RedstoneControl.kt | 2 +- .../block/entity/SynchronizedBlockEntity.kt | 380 --------- .../entity/blackhole/BlackHoleBlockEntity.kt | 4 +- .../decorative/CargoCrateBlockEntity.kt | 4 +- .../entity/decorative/HoloSignBlockEntity.kt | 6 +- .../matter/MatterCapacitorBankBlockEntity.kt | 6 +- .../entity/matter/MatterPanelBlockEntity.kt | 4 +- .../matter/PatternStorageBlockEntity.kt | 4 +- .../entity/tech/BatteryBankBlockEntity.kt | 9 +- .../tech/ChemicalGeneratorBlockEntity.kt | 5 +- .../block/entity/tech/CobblerBlockEntity.kt | 40 +- .../entity/tech/EnergyCounterBlockEntity.kt | 4 +- .../entity/tech/EnergyServoBlockEntity.kt | 4 +- .../tech/GravitationStabilizerBlockEntity.kt | 5 +- .../otm/block/tech/ChemicalGeneratorBlock.kt | 5 +- .../energy/BlockEnergyStorageImpl.kt | 3 +- .../client/render/blockentity/BankRenderer.kt | 7 +- .../mc/otm/container/MatteryContainer.kt | 7 +- .../mc/otm/core/math/BlockRotation.kt | 36 + .../mc/otm/core/nbt/CompoundTagExt.kt | 21 + .../mc/otm/network/WorldNetworkChannel.kt | 4 +- 29 files changed, 923 insertions(+), 536 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/SynchronizedBlockEntity.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt index bc9d7b1a0..a57b06bd1 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt @@ -26,7 +26,7 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition import net.minecraft.world.level.storage.loot.providers.nbt.ContextNbtProvider import net.minecraft.world.level.storage.loot.providers.number.ConstantValue -import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity +import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity data class NbtCopy(val source: String, val destination: String, val strategy: CopyNbtFunction.MergeStrategy = CopyNbtFunction.MergeStrategy.REPLACE) @@ -36,13 +36,13 @@ fun TileNbtCopy(source: String, strategy: CopyNbtFunction.MergeStrategy = CopyNb } private val basicTags = arrayOf( - TileNbtCopy(MatteryBlockEntity.REDSTONE_CONTROL_KEY), + TileNbtCopy(MatteryDeviceBlockEntity.REDSTONE_CONTROL_KEY), ) private val poweredTags = arrayOf( *basicTags, - TileNbtCopy(MatteryBlockEntity.ENERGY_KEY), - TileNbtCopy(MatteryBlockEntity.BATTERY_KEY), + TileNbtCopy(MatteryDeviceBlockEntity.ENERGY_KEY), + TileNbtCopy(MatteryDeviceBlockEntity.BATTERY_KEY), ) private val workerTags = arrayOf( @@ -53,7 +53,7 @@ private val workerTags = arrayOf( private val poweredMatterWorker = arrayOf( *workerTags, - TileNbtCopy(MatteryBlockEntity.MATTER_STORAGE_KEY), + TileNbtCopy(MatteryDeviceBlockEntity.MATTER_STORAGE_KEY), ) class LootTables(generator: DataGenerator) : LootTableProvider(generator.packOutput, setOf() /* because we don't fucking validate you fuck */, listOf() /* because we attach everything after class is constructed duh */) { diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index a6321136b..5b5548bb8 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -8,9 +8,9 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets import net.minecraft.world.level.storage.loot.predicates.ExplosionCondition import ru.dbotthepony.mc.otm.block.entity.tech.ChemicalGeneratorBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.EnergyCounterBlockEntity -import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity.Companion.ENERGY_KEY -import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity.Companion.MATTER_STORAGE_KEY -import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity.Companion.REDSTONE_CONTROL_KEY +import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity.Companion.ENERGY_KEY +import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity.Companion.MATTER_STORAGE_KEY +import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity.Companion.REDSTONE_CONTROL_KEY import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.AbstractStorageImportExport.Companion.FILTER_KEY diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 6e92cacc6..e4d26df10 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -17,7 +17,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import ru.dbotthepony.mc.otm.android.AndroidResearchManager; import ru.dbotthepony.mc.otm.android.feature.EnderTeleporterFeature; -import ru.dbotthepony.mc.otm.block.entity.SynchronizedBlockEntity; +import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity; import ru.dbotthepony.mc.otm.block.entity.blackhole.ExplosionQueue; import ru.dbotthepony.mc.otm.capability.MatteryCapability; import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability; @@ -170,12 +170,12 @@ public final class OverdriveThatMatters { EVENT_BUS.addListener(EventPriority.NORMAL, MatterManager.INSTANCE::onDataPackSync); EVENT_BUS.addListener(EventPriority.NORMAL, MatterManager.INSTANCE::addCommands); - EVENT_BUS.addListener(EventPriority.NORMAL, SynchronizedBlockEntity.Companion::onServerStopping); - EVENT_BUS.addListener(EventPriority.NORMAL, SynchronizedBlockEntity.Companion::onLevelUnload); - EVENT_BUS.addListener(EventPriority.NORMAL, SynchronizedBlockEntity.Companion::onWatch); - EVENT_BUS.addListener(EventPriority.NORMAL, SynchronizedBlockEntity.Companion::onForget); - EVENT_BUS.addListener(EventPriority.NORMAL, SynchronizedBlockEntity.Companion::playerDisconnected); - EVENT_BUS.addListener(EventPriority.LOWEST, SynchronizedBlockEntity.Companion::postLevelTick); + EVENT_BUS.addListener(EventPriority.NORMAL, MatteryBlockEntity.Companion::onServerStopping); + EVENT_BUS.addListener(EventPriority.NORMAL, MatteryBlockEntity.Companion::onLevelUnload); + EVENT_BUS.addListener(EventPriority.NORMAL, MatteryBlockEntity.Companion::onWatch); + EVENT_BUS.addListener(EventPriority.NORMAL, MatteryBlockEntity.Companion::onForget); + EVENT_BUS.addListener(EventPriority.NORMAL, MatteryBlockEntity.Companion::playerDisconnected); + EVENT_BUS.addListener(EventPriority.LOWEST, MatteryBlockEntity.Companion::postLevelTick); EVENT_BUS.addListener(EventPriority.NORMAL, EnderTeleporterFeature.Companion::onEntityDeath); EVENT_BUS.addListener(EventPriority.HIGH, ItemTritaniumArmor.Companion::onHurt); diff --git a/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java b/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java index 958ece5b3..4b182e74a 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java +++ b/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java @@ -1,7 +1,10 @@ package ru.dbotthepony.mc.otm.capability; import mekanism.api.energy.IStrictEnergyHandler; -import net.minecraftforge.common.capabilities.*; +import net.minecraftforge.common.capabilities.CapabilityManager; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.CapabilityToken; +import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent; import org.jetbrains.annotations.NotNull; import ru.dbotthepony.mc.otm.capability.drive.IMatteryDrive; import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage; diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt index a6843199c..1c271cb0b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt @@ -23,8 +23,8 @@ import net.minecraft.world.level.material.Material import net.minecraft.world.level.material.MaterialColor import net.minecraft.world.phys.BlockHitResult import net.minecraft.world.phys.shapes.VoxelShape -import ru.dbotthepony.mc.otm.block.entity.IRedstoneControlProvider -import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity +import ru.dbotthepony.mc.otm.block.entity.IRedstoneControlled +import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom @@ -69,7 +69,7 @@ abstract class MatteryBlock @JvmOverloads constructor( if (this is EntityBlock && itemStack.hasCustomHoverName() && !level.isClientSide) { val tile = level.getBlockEntity(blockPos) - if (tile is MatteryBlockEntity) + if (tile is MatteryDeviceBlockEntity) tile.customDisplayName = itemStack.displayName } @@ -172,7 +172,7 @@ abstract class MatteryBlock @JvmOverloads constructor( if (this is EntityBlock && !level.isClientSide) { val tile = level.getBlockEntity(pos) - if (tile is IRedstoneControlProvider) + if (tile is IRedstoneControlled) tile.redstoneControl.redstoneSignal = level.getBestNeighborSignal(pos) } } 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 31fe08a0a..10e7117ba 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 @@ -1,43 +1,404 @@ package ru.dbotthepony.mc.otm.block.entity -import net.minecraft.world.level.block.entity.BlockEntityType -import net.minecraft.core.BlockPos -import net.minecraft.world.level.block.state.BlockState -import net.minecraft.world.MenuProvider -import java.lang.Runnable -import net.minecraft.server.level.ServerLevel +import it.unimi.dsi.fastutil.longs.Long2ObjectFunction +import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap +import it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap +import it.unimi.dsi.fastutil.objects.ReferenceArraySet import net.minecraft.client.multiplayer.ClientLevel +import net.minecraft.core.BlockPos +import net.minecraft.core.Direction import net.minecraft.core.SectionPos -import net.minecraft.world.entity.player.Inventory -import net.minecraft.world.entity.player.Player -import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.nbt.CompoundTag -import net.minecraft.nbt.StringTag -import net.minecraft.network.chat.Component +import net.minecraft.nbt.Tag +import net.minecraft.server.level.ServerLevel +import net.minecraft.server.level.ServerPlayer +import net.minecraft.world.level.ChunkPos import net.minecraft.world.level.Level +import net.minecraft.world.level.block.entity.BlockEntity +import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity -import ru.dbotthepony.mc.otm.core.TextComponent -import ru.dbotthepony.mc.otm.core.nbt.ifHas +import net.minecraft.world.level.block.state.BlockState +import net.minecraftforge.common.capabilities.Capability +import net.minecraftforge.common.capabilities.ForgeCapabilities +import net.minecraftforge.common.util.INBTSerializable +import net.minecraftforge.common.util.LazyOptional +import net.minecraftforge.event.TickEvent +import net.minecraftforge.event.TickEvent.LevelTickEvent +import net.minecraftforge.event.entity.player.PlayerEvent +import net.minecraftforge.event.level.ChunkWatchEvent +import net.minecraftforge.event.level.LevelEvent +import net.minecraftforge.event.server.ServerStoppingEvent +import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage +import ru.dbotthepony.mc.otm.core.forValidRefs +import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.core.math.BlockRotation +import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.network.BlockEntitySyncPacket +import ru.dbotthepony.mc.otm.network.FieldSynchronizer +import ru.dbotthepony.mc.otm.network.WorldNetworkChannel import ru.dbotthepony.mc.otm.oncePre +import ru.dbotthepony.mc.otm.onceServer +import java.lang.ref.WeakReference +import java.util.WeakHashMap +import kotlin.properties.ReadWriteProperty +import kotlin.reflect.KMutableProperty0 +import kotlin.reflect.KProperty +import kotlin.reflect.KProperty0 -abstract class MatteryBlockEntity( - p_155228_: BlockEntityType<*>, - p_155229_: BlockPos, - p_155230_: BlockState -) : SynchronizedBlockEntity(p_155228_, p_155229_, p_155230_), MenuProvider, IRedstoneControlProvider { - var customDisplayName: Component? = null - override val redstoneControl: AbstractRedstoneControl = RedstoneControl { new, old -> - if (new != old) - redstoneStatusUpdated(new, old) - else - setChangedLight() +/** + * Absolute barebone block entity class in Overdrive that Matters, providing bare minimum functionality + */ +abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: BlockPos, p_155230_: BlockState) : BlockEntity(p_155228_, p_155229_, p_155230_) { + private var isSynchronizing = false + + /** + * "shortcut" for getting [BlockRotation] + * + * if block has no rotation, returns [BlockRotation.NORTH] + */ + open val blockRotation: BlockRotation get() { + return blockState[(blockState.block as? RotatableMatteryBlock ?: return BlockRotation.NORTH).rotationProperty] } - protected open val defaultDisplayName: Component - get() = level?.getBlockState(blockPos)?.block?.name ?: TextComponent("null at $blockPos") + // Capabilities - abstract override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu? + private val caps = Reference2ObjectArrayMap, CapInstance<*, *>>() + + fun getCapInstance(index: Capability): CapInstance? { + return caps[index] as CapInstance? + } + + protected fun energy(capability: T): StaticCap { + return StaticCap(MatteryCapability.ENERGY, "energy", capability).alias(ForgeCapabilities.ENERGY) + } + + abstract inner class CapInstance>(type: Capability, val name: String) : INBTSerializable { + private val types = ReferenceArraySet>() + protected var valid = true + abstract val capability: T + + protected var optional by object : ReadWriteProperty> { + private var value: LazyOptional? = null + + override fun getValue(thisRef: Any?, property: KProperty<*>): LazyOptional { + if (value == null) + value = if (valid) LazyOptional.of { capability } else LazyOptional.empty() + + return value!! + } + + override fun setValue(thisRef: Any?, property: KProperty<*>, value: LazyOptional) { + this.value = value + } + } + + init { + check(!caps.values.any { it.name == name }) { "Already has capability with name $name!" } + check(!caps.containsKey(type)) { "Already has capability with type $type!" } + caps[type] = this + types.add(type) + } + + fun alias(type: Capability): S { + if (type !in types) { + check(!caps.containsKey(type)) { "Already has capability with type $type!" } + caps[type] = this + types.add(type) + } + + return this as S + } + + override fun toString(): String { + return "${this@MatteryBlockEntity} at $blockPos CapInstance[name = $name, capability = $capability]" + } + + override fun serializeNBT(): CompoundTag { + return CompoundTag().also { + var sides = 0 + + for (i in 0 .. 5) + if (exposedSides[i].first) + sides = sides.or(1 shl (i + 1)) + + it["sides"] = sides.toShort() + + if (capability is INBTSerializable<*>) + it["capability"] = (capability as INBTSerializable).serializeNBT() + } + } + + override fun deserializeNBT(nbt: CompoundTag) { + var sides = 0 + + if (nbt.contains("sides")) { + sides = nbt.getInt("sides") + } + + for (i in 0 .. 5) { + val isExposed = sides and (1 shl (1 + i)) == 1 + + if (isExposed && valid) { + exposedSides[i] = true to LazyOptional.of { capability } + } else { + exposedSides[i] = isExposed to LazyOptional.empty() + } + } + + val tag = nbt["capability"] + + if (tag != null && capability is INBTSerializable<*>) { + // will throw classcastexception if serialized type is wrong + (capability as INBTSerializable).deserializeNBT(tag) + } + } + + protected val exposedSides = Array>>(6) { true to LazyOptional.of { capability } } + + fun exposeAt(side: RelativeSide): S { + if (!exposedSides[side.ordinal].first) { + if (valid) { + setChanged() + exposedSides[side.ordinal] = true to LazyOptional.of { capability } + } else { + exposedSides[side.ordinal] = true to LazyOptional.empty() + } + } + + return this as S + } + + fun closeAt(side: RelativeSide): S { + if (exposedSides[side.ordinal].first) { + exposedSides[side.ordinal].second.invalidate() + exposedSides[side.ordinal] = false to LazyOptional.empty() + } + + return this as S + } + + fun closeAll(): S { + for (side in RelativeSide.values()) + closeAt(side) + + return this as S + } + + fun exposeAll(): S { + for (side in RelativeSide.values()) + exposeAt(side) + + return this as S + } + + fun exposeFront() = exposeAt(RelativeSide.FRONT) + fun exposeBack() = exposeAt(RelativeSide.BACK) + fun exposeLeft() = exposeAt(RelativeSide.LEFT) + fun exposeRight() = exposeAt(RelativeSide.RIGHT) + fun exposeTop() = exposeAt(RelativeSide.TOP) + fun exposeBottom() = exposeAt(RelativeSide.BOTTOM) + + fun closeFront() = closeAt(RelativeSide.FRONT) + fun closeBack() = closeAt(RelativeSide.BACK) + fun closeLeft() = closeAt(RelativeSide.LEFT) + fun closeRight() = closeAt(RelativeSide.RIGHT) + fun closeTop() = closeAt(RelativeSide.TOP) + fun closeBottom() = closeAt(RelativeSide.BOTTOM) + + fun isExposedAt(side: RelativeSide): Boolean { + return exposedSides[side.ordinal].first + } + + fun isExposedAt(side: Direction): Boolean { + return isExposedAt(blockRotation.dir2Side(side)) + } + + fun get(side: Direction? = null): LazyOptional { + if (!valid) { + return LazyOptional.empty() + } + + if (side == null) { + return optional + } else { + return exposedSides[blockRotation.dir2Side(side).ordinal].second + } + } + + fun invalidate() { + if (valid) { + for ((_, v) in exposedSides) + v.invalidate() + + optional.invalidate() + valid = false + } + } + + fun revive() { + if (!valid) { + for ((i, pair) in exposedSides.withIndex()) + if (pair.first) + exposedSides[i] = true to LazyOptional.of { capability } + + optional = LazyOptional.of { capability } + valid = true + } + } + } + + inner class StaticCap(type: Capability, name: String, override val capability: T) : CapInstance>(type, name) + + inner class DynamicCap(type: Capability, name: String, capability: T) : CapInstance>(type, name) { + override var capability: T = capability + private set(value) { + field = value + + if (valid) { + val old = ArrayList>(7) + old.add(optional) + val new = LazyOptional.of { value } + optional = new + + for ((i, pair) in exposedSides.withIndex()) { + if (pair.first) { + old.add(pair.second) + exposedSides[i] = true to LazyOptional.of { value } + } + } + + old.forEach(LazyOptional::invalidate) + } + } + } + + // /Capabilities + + override fun getCapability(cap: Capability, side: Direction?): LazyOptional { + return caps[cap]?.get(side)?.cast() ?: super.getCapability(cap, side) + } + + override fun invalidateCaps() { + super.invalidateCaps() + + for (cap in caps.values) + cap.invalidate() + } + + override fun reviveCaps() { + super.reviveCaps() + + for (cap in caps.values) + cap.revive() + } + + private data class Savetable0(val type: Class, val property: KProperty0, val name: String, val serialize: (V) -> T, val deserialize: (V, T) -> Unit) + private data class Savetable1(val type: Class, val property: KMutableProperty0, val name: String, val serialize: (V) -> T, val deserialize: (T) -> V) + + private val savetables0 = ArrayList>() + private val savetables1 = ArrayList>() + + /** + * Save and load object state + */ + protected fun savetable(type: Class, property: KProperty0, name: String = property.name, serialize: (V) -> T, deserialize: (V, T?) -> Unit) { + check(!savetables0.any { it.name == name }) { "Already has save field with name $name" } + check(!savetables1.any { it.name == name }) { "Already has save field with name $name" } + savetables0.add(Savetable0(type, property, name, serialize, deserialize)) + } + + /** + * Save and load value + */ + protected fun savetable(type: Class, property: KMutableProperty0, name: String = property.name, serialize: (V) -> T, deserialize: (T?) -> V) { + check(!savetables0.any { it.name == name }) { "Already has save field with name $name" } + check(!savetables1.any { it.name == name }) { "Already has save field with name $name" } + savetables1.add(Savetable1(type, property, name, serialize, deserialize)) + } + + /** + * Save and load object state + */ + protected fun > savetable(type: Class, property: KProperty0, name: String = property.name) { + savetable(type, property, name, { it.serializeNBT()!! }, { self, it -> self.deserializeNBT(it) }) + } + + /** + * Save and load object state + */ + protected inline fun > savetable(property: KProperty0, name: String = property.name) { + savetable(T::class.java, property, name) + } + + /** + * Save and load object state + */ + protected inline fun savetable(property: KProperty0, name: String = property.name, noinline serialize: (V) -> T, noinline deserialize: (V, T?) -> Unit) { + savetable(T::class.java, property, name, serialize, deserialize) + } + + /** + * Save and load value + */ + protected inline fun savetable(property: KMutableProperty0, name: String = property.name, noinline serialize: (V) -> T, noinline deserialize: (T?) -> V) { + savetable(T::class.java, property, name, serialize, deserialize) + } + + override fun saveAdditional(nbt: CompoundTag) { + super.saveAdditional(nbt) + + if (caps.isNotEmpty()) { + nbt["Capabilities"] = CompoundTag().also { + for (cap in caps.values) { + it[cap.name] = cap.serializeNBT() + } + } + } + + for (data in savetables0) { + nbt[data.name] = (data.serialize as (Any) -> Tag).invoke(data.property.get()) + } + + for (data in savetables1) { + nbt[data.name] = (data.serialize as (Any) -> Tag).invoke(data.property.get()) + } + } + + override fun load(nbt: CompoundTag) { + super.load(nbt) + + if (nbt.contains("Capabilities")) { + @Suppress("name_shadowing") + val nbt = nbt.getCompound("Capabilities") + + for (cap in caps.values) { + if (nbt.contains(cap.name)) { + cap.deserializeNBT(nbt.getCompound(cap.name)) + } + } + } + + for (data in savetables0) { + val value = nbt[data.name] + + if (value != null && data.type.isAssignableFrom(value.javaClass)) { + (data.deserialize as (Any, Tag) -> Unit).invoke(data.property.get(), value) + } else if (value != null) { + throw ClassCastException("Expected ") + } + } + + for (data in savetables1) { + val value = nbt[data.name] + + if (value != null && data.type.isAssignableFrom(value.javaClass)) { + (data.property as KMutableProperty0).set((data.deserialize as (Tag) -> Any).invoke(value)) + } + } + } protected fun tickOnce(func: Runnable) { level?.oncePre { if (!isRemoved) func.run() } @@ -66,32 +427,6 @@ abstract class MatteryBlockEntity( level.oncePre { if (!isRemoved) func.invoke(level) } } - override fun getDisplayName(): Component { - return customDisplayName ?: defaultDisplayName - } - - protected open fun redstoneStatusUpdated(newBlocked: Boolean, oldBlocked: Boolean) {} - - override fun saveAdditional(nbt: CompoundTag) { - super.saveAdditional(nbt) - - val customDisplayName = customDisplayName - if (customDisplayName != null) - nbt.putString("Name", Component.Serializer.toJson(customDisplayName)) - - nbt[REDSTONE_CONTROL_KEY] = redstoneControl.serializeNBT() - } - - override fun load(nbt: CompoundTag) { - super.load(nbt) - - nbt.ifHas("Name", StringTag::class.java) { - customDisplayName = Component.Serializer.fromJson(it.asString) - } - - redstoneControl.deserializeNBT(nbt[REDSTONE_CONTROL_KEY] as? CompoundTag) - } - // Just to mark chunk unsaved open fun setChangedLight() { val level = level @@ -102,6 +437,255 @@ abstract class MatteryBlockEntity( } } + val synchronizer = FieldSynchronizer { + if (isSynchronizing) + return@FieldSynchronizer + + if (!isRemoved && level?.isClientSide == false && (_subCache == null || (_subCache ?: throw ConcurrentModificationException()).players.isNotEmpty())) { + onceServer { + synchronizeToPlayers(true) + } + } else { + markSynchronizerClean() + } + } + + private fun markSynchronizerClean() { + synchronizer.markClean() + } + + init { + synchronizer.defaultEndpoint.markUnused() + } + + override fun setLevel(p_155231_: Level) { + super.setLevel(p_155231_) + unsubscribe() + _subCache = null + + if (!p_155231_.isClientSide) { + subscribe() + } + } + + override fun setRemoved() { + super.setRemoved() + unsubscribe() + } + + override fun clearRemoved() { + super.clearRemoved() + + if (level?.isClientSide == false) { + subscribe() + } + } + + private var _subCache: ChunkSubscribers? = null + + private fun unsubscribe() { + val subCache = _subCache ?: return + + if (subCache.unsubscribe(this)) { + val level = subCache.level.get() + + if (level != null) { + playerMap.get(level)?.remove(subCache.chunkPos) + } + } + + lastSubscriptionChangeset = -1 + } + + private fun subscribe(): ChunkSubscribers { + val level = level + check(level is ServerLevel) { "Invalid realm" } + unsubscribe() + + val subs = playerMap + .computeIfAbsent(level) { Long2ObjectOpenHashMap() } + .computeIfAbsent(ChunkPos(blockPos).toLong(), Long2ObjectFunction { ChunkSubscribers(level = WeakReference(level), chunkPos = ChunkPos(blockPos).toLong()) }) + + subs.subscribe(this) + _subCache = subs + return subs + } + + private val subscription get() = _subCache ?: subscribe() + private var lastSubscriptionChangeset = -1 + + fun synchronizeToPlayers() { + synchronizeToPlayers(false) + } + + protected fun synchronizeToPlayers(calledBySynchronizer: Boolean) { + isSynchronizing = true + + try { + if (synchronizer.isEmpty || isRemoved) { + if (calledBySynchronizer) synchronizer.markClean() + return + } + + check(level is ServerLevel) { "Invalid realm or Level is null" } + + synchronizer.observe() + + val subscription = subscription + + if (subscription.players.isEmpty() || lastSubscriptionChangeset == subscription.changeset && !synchronizer.hasChanges) { + if (calledBySynchronizer) synchronizer.markClean() + return + } + + lastSubscriptionChangeset = subscription.changeset + + for (player in subscription.players) { + val payload = synchronizer.computeEndpointFor(player).collectNetworkPayload() + + if (payload != null) { + WorldNetworkChannel.send(player, BlockEntitySyncPacket(blockPos, payload.array, payload.length)) + } + } + + synchronizer.markClean() + } finally { + isSynchronizing = false + } + } + + private data class ChunkSubscribers( + val blockEntities: ArrayList> = ArrayList(0), + val players: ArrayList = ArrayList(1), + val observingBlockEntities: ArrayList> = ArrayList(0), + val level: WeakReference, + val chunkPos: Long, + var changeset: Int = 0 + ) { + fun cleanUpBlocks() { + val listIterator = blockEntities.listIterator() + + for (block in listIterator) { + if (block.get() == null) { + listIterator.remove() + } + } + } + + val hasObservers: Boolean get() { + val listIterator = blockEntities.listIterator() + + for (value in listIterator) { + val ref = value.get() + + if (ref == null) { + listIterator.remove() + } else if (ref.synchronizer.hasObservers) { + return true + } + } + + return false + } + + fun subscribe(blockEntity: MatteryBlockEntity) { + val iterator = blockEntities.listIterator() + + for (value in iterator) { + val ref = value.get() + + if (ref === blockEntity) { + return + } else if (ref == null) { + iterator.remove() + } + } + + val bref = WeakReference(blockEntity) + blockEntities.add(bref) + changeset++ + + onceServer { + blockEntity.synchronizeToPlayers() + } + + if (blockEntity.synchronizer.hasObservers) { + observingBlockEntities.add(bref) + val listing = tickingMap.computeIfAbsent(level.get() ?: throw NullPointerException("Level got GCd!")) { ArrayList(1) } + val tickerIterator = listing.listIterator() + + for (value in tickerIterator) { + val ref = value.get() + + if (ref === this) { + return + } else if (ref == null) { + tickerIterator.remove() + } + } + + listing.add(WeakReference(this)) + } + } + + fun unsubscribe(blockEntity: MatteryBlockEntity): Boolean { + val listIterator = blockEntities.listIterator() + + for (value in listIterator) { + if (value.get() === blockEntity) { + listIterator.remove() + changeset++ + break + } + } + + if (blockEntity.synchronizer.hasObservers) { + val tickerIterator = observingBlockEntities.listIterator() + + for (value in tickerIterator) { + val ref = value.get() + + if (ref === blockEntity) { + tickerIterator.remove() + break + } else if (ref == null) { + tickerIterator.remove() + } + } + } + + if (players.isNotEmpty()) { + return false + } + + cleanUpBlocks() + return blockEntities.isEmpty() + } + + val isEmpty: Boolean get() { + if (players.isNotEmpty()) { + return false + } + + cleanUpBlocks() + return blockEntities.isEmpty() + } + } + + /** + * Why track player-tracked chunks? + * + * because minecraft itself doesn't track them, well, + * in "section partitioning" way. + * + * just look at [net.minecraft.server.level.PlayerMap] + * + * the [net.minecraft.server.level.PlayerMap.getPlayers] straight ignores chunk position + * and just fetches all players + * + * even if they did not ignore that argument, you still have to fetch player *list* though + * [net.minecraft.server.level.ChunkMap.getPlayers], which is not something we want + */ companion object { const val REDSTONE_CONTROL_KEY = "redstoneControl" const val INVENTORY_KEY = "container" @@ -110,5 +694,105 @@ abstract class MatteryBlockEntity( const val BATTERY_KEY = "batteryInventory" const val LOOT_TABLE_KEY = RandomizableContainerBlockEntity.LOOT_TABLE_TAG const val LOOT_TABLE_SEED_KEY = RandomizableContainerBlockEntity.LOOT_TABLE_SEED_TAG + + private val playerMap = WeakHashMap>() + private val tickingMap = WeakHashMap>>() + + fun onLevelUnload(event: LevelEvent.Unload) { + val level = event.level as? ServerLevel ?: return + playerMap.remove(level) + tickingMap.remove(level) + } + + fun onServerStopping(event: ServerStoppingEvent) { + playerMap.clear() + tickingMap.clear() + } + + fun postLevelTick(event: LevelTickEvent) { + if (event.phase == TickEvent.Phase.END) { + val level = event.level as? ServerLevel ?: return + val listing = tickingMap[level] ?: return + val listIterator = listing.listIterator() + var hitAnyObservers = false + + for (value in listIterator) { + val ref = value.get() + + if (ref == null) { + listIterator.remove() + } else if (ref.players.isNotEmpty()) { + var hitObservers = false + + ref.observingBlockEntities.forValidRefs { + hitObservers = true + hitAnyObservers = true + it.synchronizeToPlayers() + } + + if (!hitObservers) { + listIterator.remove() + } + } + } + + if (!hitAnyObservers) { + tickingMap.remove(level) + } + } + } + + fun onWatch(event: ChunkWatchEvent.Watch) { + playerMap + .computeIfAbsent(event.level) { Long2ObjectOpenHashMap() } + .computeIfAbsent(event.pos.toLong(), Long2ObjectFunction { ChunkSubscribers(level = WeakReference(event.level), chunkPos = event.pos.toLong()) }) + .let { + val (blocks, players) = it + + if (event.player !in players) { + players.add(event.player) + it.changeset++ + + onceServer(10) { + if (!event.player.hasDisconnected() && event.player in players) { + blocks.forValidRefs { + it.synchronizeToPlayers(false) + } + } + } + } + } + } + + fun onForget(event: ChunkWatchEvent.UnWatch) { + val subs = playerMap.get(event.level)?.get(event.pos.toLong()) ?: return + + if (subs.players.remove(event.player)) { + if (subs.isEmpty) { + playerMap.get(event.level)?.remove(event.pos.toLong()) + } else { + subs.changeset++ + subs.blockEntities.forValidRefs { + it.synchronizer.removeEndpointFor(event.player) + } + } + } + } + + fun playerDisconnected(event: PlayerEvent.PlayerLoggedOutEvent) { + for (tree in playerMap.values) { + val iterator = tree.iterator() + + for (entry in iterator) { + if (entry.value.players.remove(event.entity)) { + entry.value.changeset++ + + if (entry.value.isEmpty) { + iterator.remove() + } + } + } + } + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt new file mode 100644 index 000000000..b2e43f7db --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -0,0 +1,64 @@ +package ru.dbotthepony.mc.otm.block.entity + +import net.minecraft.world.level.block.entity.BlockEntityType +import net.minecraft.core.BlockPos +import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.MenuProvider +import java.lang.Runnable +import net.minecraft.server.level.ServerLevel +import net.minecraft.client.multiplayer.ClientLevel +import net.minecraft.core.SectionPos +import net.minecraft.world.entity.player.Inventory +import net.minecraft.world.entity.player.Player +import net.minecraft.world.inventory.AbstractContainerMenu +import net.minecraft.nbt.CompoundTag +import net.minecraft.network.chat.Component +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity +import ru.dbotthepony.mc.otm.core.TextComponent +import ru.dbotthepony.mc.otm.core.nbt.getJson +import ru.dbotthepony.mc.otm.core.nbt.putJson +import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.oncePre + +/** + * Device block entity base, implementing [MenuProvider] and [IRedstoneControlled], and also tracks custom display name + */ +abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blockPos: BlockPos, blockState: BlockState) + : MatteryBlockEntity(blockEntityType, blockPos, blockState), MenuProvider, IRedstoneControlled { + var customDisplayName: Component? = null + + override val redstoneControl: AbstractRedstoneControl = RedstoneControl { new, old -> + setChangedLight() + + if (new != old) + redstoneStatusUpdated(new, old) + } + + protected open val defaultDisplayName: Component + get() = level?.getBlockState(blockPos)?.block?.name ?: TextComponent("null at $blockPos") + + abstract override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu? + + override fun getDisplayName(): Component { + return customDisplayName ?: defaultDisplayName + } + + protected open fun redstoneStatusUpdated(newBlocked: Boolean, oldBlocked: Boolean) {} + + override fun saveAdditional(nbt: CompoundTag) { + super.saveAdditional(nbt) + + if (customDisplayName != null) + nbt.putJson("Name", Component.Serializer.toJsonTree(customDisplayName!!)) + + nbt[REDSTONE_CONTROL_KEY] = redstoneControl.serializeNBT() + } + + override fun load(nbt: CompoundTag) { + super.load(nbt) + + customDisplayName = nbt.getJson("Name")?.let(Component.Serializer::fromJson) + redstoneControl.deserializeNBT(nbt[REDSTONE_CONTROL_KEY] as? CompoundTag) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt index 791544ebd..89d265c9c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt @@ -25,7 +25,7 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set -abstract class MatteryPoweredBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: BlockPos, p_155230_: BlockState) : MatteryBlockEntity(p_155228_, p_155229_, p_155230_) { +abstract class MatteryPoweredBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(p_155228_, p_155229_, p_155230_) { abstract val energy: BlockEnergyStorageImpl? private var valid = true val batteryContainer = MatteryContainer(this::setChangedLight, 1) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt index 5e112c7ae..a022d1918 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt @@ -6,7 +6,7 @@ import ru.dbotthepony.mc.otm.core.nbt.getEnum import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.network.FieldSynchronizer -interface IRedstoneControlProvider { +interface IRedstoneControlled { val redstoneControl: AbstractRedstoneControl } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/SynchronizedBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/SynchronizedBlockEntity.kt deleted file mode 100644 index 920821fb4..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/SynchronizedBlockEntity.kt +++ /dev/null @@ -1,380 +0,0 @@ -package ru.dbotthepony.mc.otm.block.entity - -import it.unimi.dsi.fastutil.longs.Long2ObjectFunction -import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap -import net.minecraft.core.BlockPos -import net.minecraft.server.level.ServerLevel -import net.minecraft.server.level.ServerPlayer -import net.minecraft.world.level.ChunkPos -import net.minecraft.world.level.Level -import net.minecraft.world.level.block.entity.BlockEntity -import net.minecraft.world.level.block.entity.BlockEntityType -import net.minecraft.world.level.block.state.BlockState -import net.minecraftforge.event.TickEvent -import net.minecraftforge.event.TickEvent.LevelTickEvent -import net.minecraftforge.event.entity.player.PlayerEvent -import net.minecraftforge.event.level.ChunkWatchEvent -import net.minecraftforge.event.level.LevelEvent -import net.minecraftforge.event.server.ServerStoppingEvent -import ru.dbotthepony.mc.otm.core.forValidRefs -import ru.dbotthepony.mc.otm.network.BlockEntitySyncPacket -import ru.dbotthepony.mc.otm.network.FieldSynchronizer -import ru.dbotthepony.mc.otm.network.WorldNetworkChannel -import ru.dbotthepony.mc.otm.onceServer -import java.lang.ref.WeakReference -import java.util.WeakHashMap - -abstract class SynchronizedBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: BlockPos, p_155230_: BlockState) : BlockEntity(p_155228_, p_155229_, p_155230_) { - private var isSynchronizing = false - - val synchronizer = FieldSynchronizer { - if (isSynchronizing) - return@FieldSynchronizer - - if (!isRemoved && level?.isClientSide == false && (_subCache == null || (_subCache ?: throw ConcurrentModificationException()).players.isNotEmpty())) { - onceServer { - synchronizeToPlayers(true) - } - } else { - markSynchronizerClean() - } - } - - private fun markSynchronizerClean() { - synchronizer.markClean() - } - - init { - synchronizer.defaultEndpoint.markUnused() - } - - override fun setLevel(p_155231_: Level) { - super.setLevel(p_155231_) - unsubscribe() - _subCache = null - - if (!p_155231_.isClientSide) { - subscribe() - } - } - - override fun setRemoved() { - super.setRemoved() - unsubscribe() - } - - override fun clearRemoved() { - super.clearRemoved() - - if (level?.isClientSide == false) { - subscribe() - } - } - - private var _subCache: ChunkSubscribers? = null - - private fun unsubscribe() { - val subCache = _subCache ?: return - - if (subCache.unsubscribe(this)) { - val level = subCache.level.get() - - if (level != null) { - playerMap.get(level)?.remove(subCache.chunkPos) - } - } - - lastSubscriptionChangeset = -1 - } - - private fun subscribe(): ChunkSubscribers { - val level = level - check(level is ServerLevel) { "Invalid realm" } - unsubscribe() - - val subs = playerMap - .computeIfAbsent(level) { Long2ObjectOpenHashMap() } - .computeIfAbsent(ChunkPos(blockPos).toLong(), Long2ObjectFunction { ChunkSubscribers(level = WeakReference(level), chunkPos = ChunkPos(blockPos).toLong()) }) - - subs.subscribe(this) - _subCache = subs - return subs - } - - private val subscription get() = _subCache ?: subscribe() - private var lastSubscriptionChangeset = -1 - - fun synchronizeToPlayers() { - synchronizeToPlayers(false) - } - - protected fun synchronizeToPlayers(calledBySynchronizer: Boolean) { - isSynchronizing = true - - try { - if (synchronizer.isEmpty || isRemoved) { - if (calledBySynchronizer) synchronizer.markClean() - return - } - - check(level is ServerLevel) { "Invalid realm or Level is null" } - - synchronizer.observe() - - val subscription = subscription - - if (subscription.players.isEmpty() || lastSubscriptionChangeset == subscription.changeset && !synchronizer.hasChanges) { - if (calledBySynchronizer) synchronizer.markClean() - return - } - - lastSubscriptionChangeset = subscription.changeset - - for (player in subscription.players) { - val payload = synchronizer.computeEndpointFor(player).collectNetworkPayload() - - if (payload != null) { - WorldNetworkChannel.send(player, BlockEntitySyncPacket(blockPos, payload.array, payload.length)) - } - } - - synchronizer.markClean() - } finally { - isSynchronizing = false - } - } - - private data class ChunkSubscribers( - val blockEntities: ArrayList> = ArrayList(0), - val players: ArrayList = ArrayList(1), - val observingBlockEntities: ArrayList> = ArrayList(0), - val level: WeakReference, - val chunkPos: Long, - var changeset: Int = 0 - ) { - fun cleanUpBlocks() { - val listIterator = blockEntities.listIterator() - - for (block in listIterator) { - if (block.get() == null) { - listIterator.remove() - } - } - } - - val hasObservers: Boolean get() { - val listIterator = blockEntities.listIterator() - - for (value in listIterator) { - val ref = value.get() - - if (ref == null) { - listIterator.remove() - } else if (ref.synchronizer.hasObservers) { - return true - } - } - - return false - } - - fun subscribe(blockEntity: SynchronizedBlockEntity) { - val iterator = blockEntities.listIterator() - - for (value in iterator) { - val ref = value.get() - - if (ref === blockEntity) { - return - } else if (ref == null) { - iterator.remove() - } - } - - val bref = WeakReference(blockEntity) - blockEntities.add(bref) - changeset++ - - onceServer { - blockEntity.synchronizeToPlayers() - } - - if (blockEntity.synchronizer.hasObservers) { - observingBlockEntities.add(bref) - val listing = tickingMap.computeIfAbsent(level.get() ?: throw NullPointerException("Level got GCd!")) { ArrayList(1) } - val tickerIterator = listing.listIterator() - - for (value in tickerIterator) { - val ref = value.get() - - if (ref === this) { - return - } else if (ref == null) { - tickerIterator.remove() - } - } - - listing.add(WeakReference(this)) - } - } - - fun unsubscribe(blockEntity: SynchronizedBlockEntity): Boolean { - val listIterator = blockEntities.listIterator() - - for (value in listIterator) { - if (value.get() === blockEntity) { - listIterator.remove() - changeset++ - break - } - } - - if (blockEntity.synchronizer.hasObservers) { - val tickerIterator = observingBlockEntities.listIterator() - - for (value in tickerIterator) { - val ref = value.get() - - if (ref === blockEntity) { - tickerIterator.remove() - break - } else if (ref == null) { - tickerIterator.remove() - } - } - } - - if (players.isNotEmpty()) { - return false - } - - cleanUpBlocks() - return blockEntities.isEmpty() - } - - val isEmpty: Boolean get() { - if (players.isNotEmpty()) { - return false - } - - cleanUpBlocks() - return blockEntities.isEmpty() - } - } - - /** - * Why track player-tracked chunks? - * - * because minecraft itself doesn't track them, well, - * in "section partitioning" way. - * - * just look at [net.minecraft.server.level.PlayerMap] - * - * the [net.minecraft.server.level.PlayerMap.getPlayers] straight ignores chunk position - * and just fetches all players - * - * even if they did not ignore that argument, you still have to fetch player *list* though - * [net.minecraft.server.level.ChunkMap.getPlayers], which is not something we want - */ - companion object { - private val playerMap = WeakHashMap>() - private val tickingMap = WeakHashMap>>() - - fun onLevelUnload(event: LevelEvent.Unload) { - val level = event.level as? ServerLevel ?: return - playerMap.remove(level) - tickingMap.remove(level) - } - - fun onServerStopping(event: ServerStoppingEvent) { - playerMap.clear() - tickingMap.clear() - } - - fun postLevelTick(event: LevelTickEvent) { - if (event.phase == TickEvent.Phase.END) { - val level = event.level as? ServerLevel ?: return - val listing = tickingMap[level] ?: return - val listIterator = listing.listIterator() - var hitAnyObservers = false - - for (value in listIterator) { - val ref = value.get() - - if (ref == null) { - listIterator.remove() - } else if (ref.players.isNotEmpty()) { - var hitObservers = false - - ref.observingBlockEntities.forValidRefs { - hitObservers = true - hitAnyObservers = true - it.synchronizeToPlayers() - } - - if (!hitObservers) { - listIterator.remove() - } - } - } - - if (!hitAnyObservers) { - tickingMap.remove(level) - } - } - } - - fun onWatch(event: ChunkWatchEvent.Watch) { - playerMap - .computeIfAbsent(event.level) { Long2ObjectOpenHashMap() } - .computeIfAbsent(event.pos.toLong(), Long2ObjectFunction { ChunkSubscribers(level = WeakReference(event.level), chunkPos = event.pos.toLong()) }) - .let { - val (blocks, players) = it - - if (event.player !in players) { - players.add(event.player) - it.changeset++ - - onceServer(10) { - if (!event.player.hasDisconnected() && event.player in players) { - blocks.forValidRefs { - it.synchronizeToPlayers(false) - } - } - } - } - } - } - - fun onForget(event: ChunkWatchEvent.UnWatch) { - val subs = playerMap.get(event.level)?.get(event.pos.toLong()) ?: return - - if (subs.players.remove(event.player)) { - if (subs.isEmpty) { - playerMap.get(event.level)?.remove(event.pos.toLong()) - } else { - subs.changeset++ - subs.blockEntities.forValidRefs { - it.synchronizer.removeEndpointFor(event.player) - } - } - } - } - - fun playerDisconnected(event: PlayerEvent.PlayerLoggedOutEvent) { - for (tree in playerMap.values) { - val iterator = tree.iterator() - - for (entry in iterator) { - if (entry.value.players.remove(event.entity)) { - entry.value.changeset++ - - if (entry.value.isEmpty) { - iterator.remove() - } - } - } - } - } - } -} 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 3c3782657..eb7e64e18 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 @@ -19,7 +19,7 @@ import net.minecraft.world.phys.AABB import net.minecraft.world.phys.Vec3 import ru.dbotthepony.mc.otm.block.BlackHoleBlock import ru.dbotthepony.mc.otm.block.entity.tech.GravitationStabilizerBlockEntity -import ru.dbotthepony.mc.otm.block.entity.SynchronizedBlockEntity +import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.block.entity.blackhole.ExplosionQueue.Companion.queueForLevel import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.plus @@ -36,7 +36,7 @@ import kotlin.math.pow import kotlin.math.roundToInt import kotlin.math.sqrt -class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : SynchronizedBlockEntity(MBlockEntities.BLACK_HOLE, p_155229_, p_155230_) { +class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryBlockEntity(MBlockEntities.BLACK_HOLE, p_155229_, p_155230_) { var mass by synchronizer.fraction(BASELINE_MASS, setter = setter@{ mass, field, setByRemote -> if (mass <= Decimal.ZERO) { collapse() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt index aa762442c..b345ac238 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt @@ -30,7 +30,7 @@ import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock import ru.dbotthepony.mc.otm.block.IDroppableContainer -import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity +import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainerHooks import ru.dbotthepony.mc.otm.core.TranslatableComponent @@ -43,7 +43,7 @@ import ru.dbotthepony.mc.otm.registry.MSoundEvents class CargoCrateBlockEntity( p_155229_: BlockPos, p_155230_: BlockState -) : MatteryBlockEntity(MBlockEntities.CARGO_CRATE, p_155229_, p_155230_), IDroppableContainer { +) : MatteryDeviceBlockEntity(MBlockEntities.CARGO_CRATE, p_155229_, p_155230_), IDroppableContainer { val container = MatteryContainer(this::setChanged, CAPACITY) private var interactingPlayers = 0 val handler = container.handler(object : MatteryContainerHooks { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt index 9429d3251..a4b1b36ff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt @@ -8,15 +8,15 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.level.block.state.BlockState -import ru.dbotthepony.mc.otm.block.entity.IRedstoneControlProvider -import ru.dbotthepony.mc.otm.block.entity.SynchronizedBlockEntity +import ru.dbotthepony.mc.otm.block.entity.IRedstoneControlled +import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.block.entity.SynchronizedRedstoneControl import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.menu.decorative.HoloSignMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlocks -class HoloSignBlockEntity(blockPos: BlockPos, blockState: BlockState) : SynchronizedBlockEntity(MBlockEntities.HOLO_SIGN, blockPos, blockState), MenuProvider, IRedstoneControlProvider { +class HoloSignBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryBlockEntity(MBlockEntities.HOLO_SIGN, blockPos, blockState), MenuProvider, IRedstoneControlled { override val redstoneControl = SynchronizedRedstoneControl(synchronizer) { _, _ -> setChanged() } var text by synchronizer.string("", name = "text", setter = { value, access, remote -> diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt index a8e9e404b..61496ebed 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt @@ -11,14 +11,12 @@ import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level -import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.block.tech.BatteryBankBlock import ru.dbotthepony.mc.otm.block.IDroppableContainer -import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity +import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.BatteryBankBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability @@ -35,7 +33,7 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set -class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryBlockEntity(MBlockEntities.MATTER_CAPACITOR_BANK, p_155229_, p_155230_), IMatterGraphNode, IMatterStorage, IDroppableContainer { +class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.MATTER_CAPACITOR_BANK, p_155229_, p_155230_), IMatterGraphNode, IMatterStorage, IDroppableContainer { var gaugeLevel by synchronizer.float() private set diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt index 2fe317f8d..28c09daeb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt @@ -19,7 +19,7 @@ import net.minecraft.server.level.ServerLevel import net.minecraft.world.level.Level import net.minecraftforge.common.capabilities.Capability import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity +import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.matter.* import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode @@ -29,7 +29,7 @@ import java.util.ArrayList import java.util.stream.Stream class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : - MatteryBlockEntity(MBlockEntities.MATTER_PANEL, p_155229_, p_155230_), IMatterGraphNode, IReplicationTaskProvider { + MatteryDeviceBlockEntity(MBlockEntities.MATTER_PANEL, p_155229_, p_155230_), IMatterGraphNode, IReplicationTaskProvider { private val listeners = ArrayList() override val matterNode = Graph6Node(this) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt index 759d29f70..378c5ac21 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt @@ -24,7 +24,7 @@ import net.minecraft.world.level.block.Block import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities import ru.dbotthepony.mc.otm.block.IDroppableContainer -import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity +import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.capability.matter.* import ru.dbotthepony.mc.otm.core.collect.iterator @@ -40,7 +40,7 @@ import java.util.stream.Stream @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : - MatteryBlockEntity(MBlockEntities.PATTERN_STORAGE, p_155229_, p_155230_), IMatterGraphNode, IPatternStorage, IDroppableContainer { + MatteryDeviceBlockEntity(MBlockEntities.PATTERN_STORAGE, p_155229_, p_155230_), IMatterGraphNode, IPatternStorage, IDroppableContainer { override val matterNode = Graph6Node(this) private val resolverPatterns = LazyOptional.of { this } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index f348fdd9b..a92b3eb3a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -10,17 +10,14 @@ import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level -import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.energy.IEnergyStorage import org.apache.logging.log4j.LogManager -import ru.dbotthepony.mc.otm.block.tech.BatteryBankBlock import ru.dbotthepony.mc.otm.block.IDroppableContainer -import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock -import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity +import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper @@ -29,14 +26,12 @@ import ru.dbotthepony.mc.otm.container.MatteryContainerHooks import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.facingOne -import ru.dbotthepony.mc.otm.core.math.rotationOne -import ru.dbotthepony.mc.otm.core.math.unaryMinus import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.BESubscribeList import ru.dbotthepony.mc.otm.menu.tech.BatteryBankMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities -class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryBlockEntity(MBlockEntities.BATTERY_BANK, p_155229_, p_155230_), IDroppableContainer { +class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.BATTERY_BANK, p_155229_, p_155230_), IDroppableContainer { var gaugeLevel by synchronizer.float() private set 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 73e6e6cc1..e78090317 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 @@ -19,8 +19,7 @@ import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.energy.IEnergyStorage import ru.dbotthepony.mc.otm.block.IDroppableContainer -import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock -import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity +import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.GeneratorEnergyStorage @@ -39,7 +38,7 @@ import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.BESubscribeList -class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryBlockEntity(MBlockEntities.CHEMICAL_GENERATOR, pos, state), IDroppableContainer { +class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.CHEMICAL_GENERATOR, pos, state), IDroppableContainer { override val defaultDisplayName: Component get() = MACHINE_NAME diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt index 07a2c7b29..56947d59a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt @@ -1,25 +1,17 @@ package ru.dbotthepony.mc.otm.block.entity.tech import net.minecraft.core.BlockPos -import net.minecraft.core.Direction -import net.minecraft.nbt.CompoundTag -import net.minecraft.network.chat.Component -import net.minecraft.world.Container import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.level.block.state.BlockState -import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities -import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainerHooks -import ru.dbotthepony.mc.otm.core.nbt.map -import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.menu.tech.CobblerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -31,37 +23,15 @@ class CobblerBlockEntity(blockPos: BlockPos, blockState: BlockState) override val energy = null override val droppableContainer = MatteryContainer(this::itemContainerUpdated, CONTAINER_SIZE) - val handler = droppableContainer.handler(object : MatteryContainerHooks { + + val handler = StaticCap(ForgeCapabilities.ITEM_HANDLER, INVENTORY_KEY, droppableContainer.handler(object : MatteryContainerHooks { override fun canInsert(slot: Int, stack: ItemStack): Boolean { return false } - }) + })) - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - if (cap === ForgeCapabilities.ITEM_HANDLER) - return handler.get().cast() - - return super.getCapability(cap, side) - } - - override fun invalidateCaps() { - super.invalidateCaps() - handler.invalidate() - } - - override fun reviveCaps() { - super.reviveCaps() - handler.revive() - } - - override fun saveAdditional(nbt: CompoundTag) { - super.saveAdditional(nbt) - nbt[INVENTORY_KEY] = droppableContainer.serializeNBT() - } - - override fun load(nbt: CompoundTag) { - super.load(nbt) - nbt.map(INVENTORY_KEY, droppableContainer::deserializeNBT) + init { + savetable(::droppableContainer, INVENTORY_KEY) } override fun onJobFinish(job: ItemJob): Status { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt index 982838158..e31e5aa5c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt @@ -16,7 +16,7 @@ import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.energy.IEnergyStorage import ru.dbotthepony.mc.otm.block.tech.EnergyCounterBlock -import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity +import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper @@ -33,7 +33,7 @@ import ru.dbotthepony.mc.otm.menu.tech.EnergyCounterMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import java.util.* -class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryBlockEntity(MBlockEntities.ENERGY_COUNTER, p_155229_, p_155230_) { +class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.ENERGY_COUNTER, p_155229_, p_155230_) { var passed by synchronizer.fraction() private val history = Array(10 * 20) { Decimal.ZERO } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt index aa6fcbdd5..17403b223 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt @@ -14,7 +14,7 @@ import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.block.IDroppableContainer -import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity +import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.MatteryCapability @@ -33,7 +33,7 @@ import ru.dbotthepony.mc.otm.menu.tech.EnergyServoMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlocks -class EnergyServoBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryBlockEntity(MBlockEntities.ENERGY_SERVO, blockPos, blockState), IDroppableContainer { +class EnergyServoBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.ENERGY_SERVO, blockPos, blockState), IDroppableContainer { override val defaultDisplayName: Component get() = MBlocks.ENERGY_SERVO.name diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/GravitationStabilizerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/GravitationStabilizerBlockEntity.kt index 0ae35a55c..06eb3b533 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/GravitationStabilizerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/GravitationStabilizerBlockEntity.kt @@ -11,8 +11,7 @@ import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.phys.AABB import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.block.tech.BlockGravitationStabilizerLens -import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock -import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity +import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity import ru.dbotthepony.mc.otm.block.tech.BlockGravitationStabilizer @@ -21,7 +20,7 @@ import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.core.math.times import ru.dbotthepony.mc.otm.registry.MBlockEntities -class GravitationStabilizerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryBlockEntity( +class GravitationStabilizerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity( MBlockEntities.GRAVITATION_STABILIZER, p_155229_, p_155230_) { override val defaultDisplayName: Component diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt index c6a2a7517..4728e76e2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.block.tech import net.minecraft.ChatFormatting import net.minecraft.core.BlockPos -import net.minecraft.core.Direction import net.minecraft.nbt.CompoundTag import net.minecraft.network.chat.Component import net.minecraft.world.item.BlockItem @@ -20,8 +19,9 @@ import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock -import ru.dbotthepony.mc.otm.block.entity.tech.ChemicalGeneratorBlockEntity import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.ChemicalGeneratorBlockEntity +import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.capability.energy.GeneratorEnergyStorage @@ -29,7 +29,6 @@ import ru.dbotthepony.mc.otm.capability.energy.ItemEnergyStorageImpl import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.get -import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.oncePre import ru.dbotthepony.mc.otm.registry.MBlockEntities diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt index 0ec7c4e1f..627c997bf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt @@ -13,9 +13,10 @@ import net.minecraft.world.level.block.entity.BlockEntity import net.minecraftforge.common.ForgeConfigSpec import net.minecraftforge.common.util.INBTSerializable import net.minecraftforge.common.util.LazyOptional +import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.config.VerboseBalanceValues -import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity +import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.defineDecimal diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt index 5d62e3ff0..ae1c202e6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt @@ -10,10 +10,8 @@ import net.minecraft.core.Direction import net.minecraft.resources.ResourceLocation import net.minecraft.world.level.levelgen.XoroshiroRandomSource import net.minecraftforge.client.event.ModelEvent -import org.joml.AxisAngle4f -import org.joml.Quaternionf import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity +import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterCapacitorBankBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.BatteryBankBlockEntity import ru.dbotthepony.mc.otm.client.minecraft @@ -24,7 +22,6 @@ import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel import ru.dbotthepony.mc.otm.core.ImmutableList import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom -import ru.dbotthepony.mc.otm.core.math.PIf import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.core.math.rotate import ru.dbotthepony.mc.otm.core.math.rotateY @@ -32,7 +29,7 @@ import ru.dbotthepony.mc.otm.nanoTime import java.util.function.Supplier import kotlin.math.PI -abstract class BankRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer { +abstract class BankRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer { protected abstract fun gaugeLevel(entity: T): Float protected abstract val texture: AbstractMatterySprite protected abstract val models: List diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt index 97cdad1b9..c91c77904 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt @@ -9,12 +9,13 @@ import net.minecraft.world.Container import kotlin.jvm.JvmOverloads import net.minecraft.world.entity.player.Player import net.minecraft.world.level.block.entity.BlockEntity +import net.minecraftforge.common.util.INBTSerializable import ru.dbotthepony.mc.otm.core.nbt.ifHas import ru.dbotthepony.mc.otm.core.nbt.set import java.util.* @Suppress("UNUSED") -open class MatteryContainer(val watcher: Runnable, private val size: Int) : Container, Iterable { +open class MatteryContainer(val watcher: Runnable, private val size: Int) : Container, Iterable, INBTSerializable { constructor(watcher: BlockEntity, size: Int) : this(watcher::setChanged, size) constructor(size: Int) : this({}, size) @@ -107,7 +108,7 @@ open class MatteryContainer(val watcher: Runnable, private val size: Int) : Cont setChanged() } - fun deserializeNBT(tag: Tag?) { + override fun deserializeNBT(tag: Tag?) { when (tag) { is CompoundTag -> deserializeNBT(tag) is ListTag -> deserializeNBT(tag) @@ -122,7 +123,7 @@ open class MatteryContainer(val watcher: Runnable, private val size: Int) : Cont if (ignoreChangeNotifications == 0) watcher.run() } - fun serializeNBT(): ListTag { + override fun serializeNBT(): ListTag { return ListTag().also { for ((i, item) in slots.withIndex()) { if (!item.isEmpty) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt index cefba788a..496ce6645 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.core.math +import com.google.common.collect.ImmutableMap import net.minecraft.core.BlockPos import net.minecraft.core.Direction import net.minecraft.core.Vec3i @@ -8,6 +9,7 @@ import net.minecraft.world.level.block.Rotation import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ICapabilityProvider import net.minecraftforge.common.util.LazyOptional +import java.util.Collections import java.util.EnumMap internal inline val Direction.blockRotation @@ -25,6 +27,10 @@ operator fun BlockPos.plus(other: BlockRotation): BlockPos { return this + other.normal } +enum class RelativeSide { + FRONT, BACK, LEFT, RIGHT, TOP, BOTTOM +} + /** * Represents unique block orientation in space, by providing [front] and [top] directions * @@ -83,6 +89,36 @@ enum class BlockRotation( val bottom: Direction = top.opposite val back: Direction = front.opposite + private val _dir2Side = EnumMap(Direction::class.java) + private val _side2Dir = EnumMap(RelativeSide::class.java) + + val dir2Side: Map = Collections.unmodifiableMap(_dir2Side) + val side2Dir: Map = Collections.unmodifiableMap(_side2Dir) + + init { + _side2Dir[RelativeSide.FRONT] = front + _side2Dir[RelativeSide.BACK] = back + _side2Dir[RelativeSide.LEFT] = left + _side2Dir[RelativeSide.RIGHT] = right + _side2Dir[RelativeSide.TOP] = top + _side2Dir[RelativeSide.BOTTOM] = bottom + + _dir2Side[front] = RelativeSide.FRONT + _dir2Side[back] = RelativeSide.BACK + _dir2Side[left] = RelativeSide.LEFT + _dir2Side[right] = RelativeSide.RIGHT + _dir2Side[top] = RelativeSide.TOP + _dir2Side[bottom] = RelativeSide.BOTTOM + } + + fun dir2Side(direction: Direction): RelativeSide { + return _dir2Side[direction]!! + } + + fun side2Dir(side: RelativeSide): Direction { + return _side2Dir[side]!! + } + operator fun component1() = front operator fun component2() = top operator fun component3() = left diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt index 4073e87f5..ae8e344da 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt @@ -1,5 +1,8 @@ package ru.dbotthepony.mc.otm.core.nbt +import com.google.gson.JsonElement +import it.unimi.dsi.fastutil.io.FastByteArrayInputStream +import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream import net.minecraft.nbt.ByteArrayTag import net.minecraft.nbt.ByteTag import net.minecraft.nbt.CompoundTag @@ -10,11 +13,14 @@ import net.minecraft.nbt.IntTag import net.minecraft.nbt.ListTag import net.minecraft.nbt.LongArrayTag import net.minecraft.nbt.LongTag +import net.minecraft.nbt.NbtAccounter import net.minecraft.nbt.NbtUtils import net.minecraft.nbt.ShortTag import net.minecraft.nbt.StringTag import net.minecraft.nbt.Tag import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.core.util.readJson +import ru.dbotthepony.mc.otm.core.util.writeJson import java.util.UUID operator fun CompoundTag.set(index: String, value: Tag) = put(index, value) @@ -132,3 +138,18 @@ fun CompoundTag.getUUIDSafe(key: String): UUID? { val value = this[key] as? IntArrayTag ?: return null return NbtUtils.loadUUID(value) } + +fun CompoundTag.putJson(key: String, json: JsonElement) { + val bytes = FastByteArrayOutputStream() + bytes.writeJson(json) + putByteArray(key, bytes.array.copyOfRange(0, bytes.length)) +} + +fun CompoundTag.getJson(key: String, sizeLimit: NbtAccounter = NbtAccounter.UNLIMITED): JsonElement? { + val bytes = getByteArray(key) + + if (bytes.isEmpty()) + return null + + return FastByteArrayInputStream(bytes).readJson(sizeLimit) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt index 9e8cfc865..b135c3f94 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt @@ -7,7 +7,7 @@ import net.minecraftforge.network.NetworkDirection import net.minecraftforge.network.NetworkEvent import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.android.feature.ItemEntityDataPacket -import ru.dbotthepony.mc.otm.block.entity.SynchronizedBlockEntity +import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.client.minecraft import java.util.function.Supplier @@ -22,7 +22,7 @@ class BlockEntitySyncPacket(val position: BlockPos, val buffer: ByteArray, val v context.enqueueWork { val level = minecraft.player?.level ?: return@enqueueWork - val blockEntity = level.getBlockEntity(position) as? SynchronizedBlockEntity ?: return@enqueueWork + val blockEntity = level.getBlockEntity(position) as? MatteryBlockEntity ?: return@enqueueWork try { blockEntity.synchronizer.read(FastByteArrayInputStream(buffer, 0, validBytes)) From 4fc05e1f3af99530b58a54668fe9cd64b7356fc6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 16 Feb 2023 21:53:20 +0700 Subject: [PATCH 0202/1199] Make everything revolve around block sides rather than anything else *spontaneous combustion* --- .../mc/otm/datagen/loot/LootTables.kt | 9 +- .../mc/otm/datagen/loot/LootTablesData.kt | 6 +- .../mc/otm/block/entity/MatteryBlockEntity.kt | 524 +++++++++++------- .../block/entity/MatteryPoweredBlockEntity.kt | 50 +- .../block/entity/MatteryWorkerBlockEntity.kt | 9 +- .../decorative/CargoCrateBlockEntity.kt | 22 +- .../entity/matter/MatterBottlerBlockEntity.kt | 70 +-- .../matter/MatterCapacitorBankBlockEntity.kt | 69 +-- .../matter/MatterDecomposerBlockEntity.kt | 78 +-- .../entity/matter/MatterPanelBlockEntity.kt | 24 +- .../matter/MatterRecyclerBlockEntity.kt | 54 +- .../matter/MatterReplicatorBlockEntity.kt | 62 +-- .../entity/matter/MatterScannerBlockEntity.kt | 51 +- .../matter/PatternStorageBlockEntity.kt | 64 +-- .../entity/storage/DriveRackBlockEntity.kt | 34 +- .../entity/storage/DriveViewerBlockEntity.kt | 24 +- .../entity/storage/ItemMonitorBlockEntity.kt | 30 +- .../entity/storage/StorageBusBlockEntity.kt | 48 +- .../block/entity/storage/StorageInterfaces.kt | 58 +- .../StoragePowerSupplierBlockEntity.kt | 49 +- .../entity/tech/AndroidStationBlockEntity.kt | 18 +- .../entity/tech/BatteryBankBlockEntity.kt | 97 +--- .../tech/ChemicalGeneratorBlockEntity.kt | 67 ++- .../block/entity/tech/CobblerBlockEntity.kt | 6 +- .../entity/tech/EnergyCounterBlockEntity.kt | 2 +- .../entity/tech/EnergyServoBlockEntity.kt | 41 +- .../entity/tech/PlatePressBlockEntity.kt | 40 +- .../otm/block/matter/PatternStorageBlock.kt | 4 +- .../ru/dbotthepony/mc/otm/capability/Ext.kt | 2 +- .../energy/BlockEnergyStorageImpl.kt | 5 +- .../capability/matter/MatterStorageImpl.kt | 5 +- .../mc/otm/container/ItemFilter.kt | 2 +- .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 16 + .../mc/otm/menu/MatteryPoweredMenu.kt | 5 +- .../mc/otm/menu/matter/PatternStorageMenu.kt | 2 +- 35 files changed, 625 insertions(+), 1022 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt index a57b06bd1..2deda7074 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt @@ -26,6 +26,7 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition import net.minecraft.world.level.storage.loot.providers.nbt.ContextNbtProvider import net.minecraft.world.level.storage.loot.providers.number.ConstantValue +import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity @@ -36,13 +37,13 @@ fun TileNbtCopy(source: String, strategy: CopyNbtFunction.MergeStrategy = CopyNb } private val basicTags = arrayOf( - TileNbtCopy(MatteryDeviceBlockEntity.REDSTONE_CONTROL_KEY), + TileNbtCopy(MatteryBlockEntity.REDSTONE_CONTROL_KEY), ) private val poweredTags = arrayOf( *basicTags, - TileNbtCopy(MatteryDeviceBlockEntity.ENERGY_KEY), - TileNbtCopy(MatteryDeviceBlockEntity.BATTERY_KEY), + TileNbtCopy(MatteryBlockEntity.ENERGY_KEY), + TileNbtCopy(MatteryBlockEntity.BATTERY_KEY), ) private val workerTags = arrayOf( @@ -53,7 +54,7 @@ private val workerTags = arrayOf( private val poweredMatterWorker = arrayOf( *workerTags, - TileNbtCopy(MatteryDeviceBlockEntity.MATTER_STORAGE_KEY), + TileNbtCopy(MatteryBlockEntity.MATTER_STORAGE_KEY), ) class LootTables(generator: DataGenerator) : LootTableProvider(generator.packOutput, setOf() /* because we don't fucking validate you fuck */, listOf() /* because we attach everything after class is constructed duh */) { diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index 5b5548bb8..a6321136b 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -8,9 +8,9 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets import net.minecraft.world.level.storage.loot.predicates.ExplosionCondition import ru.dbotthepony.mc.otm.block.entity.tech.ChemicalGeneratorBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.EnergyCounterBlockEntity -import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity.Companion.ENERGY_KEY -import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity.Companion.MATTER_STORAGE_KEY -import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity.Companion.REDSTONE_CONTROL_KEY +import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity.Companion.ENERGY_KEY +import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity.Companion.MATTER_STORAGE_KEY +import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity.Companion.REDSTONE_CONTROL_KEY import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.AbstractStorageImportExport.Companion.FILTER_KEY 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 10e7117ba..a47e974c3 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 @@ -1,15 +1,21 @@ package ru.dbotthepony.mc.otm.block.entity +import com.google.common.collect.ImmutableSet import it.unimi.dsi.fastutil.longs.Long2ObjectFunction import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap +import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap import it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap -import it.unimi.dsi.fastutil.objects.ReferenceArraySet import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.core.BlockPos import net.minecraft.core.Direction import net.minecraft.core.SectionPos +import net.minecraft.nbt.ByteTag import net.minecraft.nbt.CompoundTag +import net.minecraft.nbt.DoubleTag +import net.minecraft.nbt.FloatTag +import net.minecraft.nbt.StringTag import net.minecraft.nbt.Tag +import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerPlayer import net.minecraft.world.level.ChunkPos @@ -28,20 +34,28 @@ import net.minecraftforge.event.entity.player.PlayerEvent import net.minecraftforge.event.level.ChunkWatchEvent import net.minecraftforge.event.level.LevelEvent import net.minecraftforge.event.server.ServerStoppingEvent +import net.minecraftforge.items.IItemHandler import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage +import ru.dbotthepony.mc.otm.capability.isMekanismLoaded +import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper import ru.dbotthepony.mc.otm.core.forValidRefs +import ru.dbotthepony.mc.otm.core.forValidRefsBreak import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.core.util.EnumValueCodec import ru.dbotthepony.mc.otm.network.BlockEntitySyncPacket import ru.dbotthepony.mc.otm.network.FieldSynchronizer import ru.dbotthepony.mc.otm.network.WorldNetworkChannel import ru.dbotthepony.mc.otm.oncePre import ru.dbotthepony.mc.otm.onceServer import java.lang.ref.WeakReference +import java.util.Collections +import java.util.EnumMap import java.util.WeakHashMap import kotlin.properties.ReadWriteProperty import kotlin.reflect.KMutableProperty0 @@ -63,236 +77,341 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc return blockState[(blockState.block as? RotatableMatteryBlock ?: return BlockRotation.NORTH).rotationProperty] } - // Capabilities + private val _sides = EnumMap(RelativeSide::class.java) + val sides: Map = Collections.unmodifiableMap(_sides) - private val caps = Reference2ObjectArrayMap, CapInstance<*, *>>() + private data class SidelessCap(val cap: T, var optional: LazyOptional) + private val sidelessCaps = Reference2ObjectArrayMap, SidelessCap<*>>() - fun getCapInstance(index: Capability): CapInstance? { - return caps[index] as CapInstance? + /** + * exposes capability when no side is specified + */ + protected fun exposeSideless(capability: Capability, value: T) { + check(!sidelessCaps.containsKey(capability)) { "Already has globally exposed $capability!" } + sidelessCaps[capability] = SidelessCap(value, LazyOptional.of { value }) + setChanged() } - protected fun energy(capability: T): StaticCap { - return StaticCap(MatteryCapability.ENERGY, "energy", capability).alias(ForgeCapabilities.ENERGY) - } - - abstract inner class CapInstance>(type: Capability, val name: String) : INBTSerializable { - private val types = ReferenceArraySet>() - protected var valid = true - abstract val capability: T - - protected var optional by object : ReadWriteProperty> { - private var value: LazyOptional? = null - - override fun getValue(thisRef: Any?, property: KProperty<*>): LazyOptional { - if (value == null) - value = if (valid) LazyOptional.of { capability } else LazyOptional.empty() - - return value!! - } - - override fun setValue(thisRef: Any?, property: KProperty<*>, value: LazyOptional) { - this.value = value + protected fun exposeAllSidesExcept(side: RelativeSide, capability: Capability, value: T) { + for ((k, v) in _sides) { + if (k != side) { + v.Cap(capability, value) } } + } + protected fun isSidelessExposed(capability: Capability<*>): Boolean { + return sidelessCaps.containsKey(capability) + } + + protected fun removeSideless(capability: Capability<*>): Boolean { + if (sidelessCaps.remove(capability) != null) { + setChanged() + return true + } + + return false + } + + /** + * Exposes capability unconditionally, on all sides and sideless + */ + protected fun exposeGlobally(capability: Capability, value: T) { + exposeSideless(capability, value) + + for (side in _sides.values) + side.Cap(capability, value) + } + + protected fun exposeEnergyGlobally(value: IMatteryEnergyStorage) { + exposeGlobally(ForgeCapabilities.ENERGY, value) + exposeGlobally(MatteryCapability.ENERGY, value) + + if (isMekanismLoaded) { + exposeGlobally(MatteryCapability.MEKANISM_ENERGY, Mattery2MekanismEnergyWrapper(value)) + } + } + + protected fun exposeEnergy(side: RelativeSide, value: IMatteryEnergyStorage) { + _sides[side]!!.Cap(ForgeCapabilities.ENERGY, value) + _sides[side]!!.Cap(MatteryCapability.ENERGY, value) + + if (isMekanismLoaded) { + _sides[side]!!.Cap(MatteryCapability.MEKANISM_ENERGY, Mattery2MekanismEnergyWrapper(value)) + } + } + + protected fun exposeEnergySideless( value: IMatteryEnergyStorage) { + exposeSideless(ForgeCapabilities.ENERGY, value) + exposeSideless(MatteryCapability.ENERGY, value) + + if (isMekanismLoaded) { + exposeSideless(MatteryCapability.MEKANISM_ENERGY, Mattery2MekanismEnergyWrapper(value)) + } + } + + protected fun exposeItemsGlobally(value: IItemHandler) { + exposeGlobally(ForgeCapabilities.ITEM_HANDLER, value) + } + + enum class SideMode(val filter: FlowDirection, val automation: FlowDirection) { + DISABLED (FlowDirection.NONE, FlowDirection.NONE), + NONE (FlowDirection.BI_DIRECTIONAL, FlowDirection.NONE), + INPUT (FlowDirection.INPUT, FlowDirection.NONE), + OUTPUT (FlowDirection.OUTPUT, FlowDirection.NONE), + + PULL (FlowDirection.INPUT, FlowDirection.INPUT), + PUSH (FlowDirection.OUTPUT, FlowDirection.OUTPUT), + PULL_ONLY (FlowDirection.BI_DIRECTIONAL, FlowDirection.INPUT), + PUSH_ONLY (FlowDirection.BI_DIRECTIONAL, FlowDirection.OUTPUT), + PULL_PUSH (FlowDirection.BI_DIRECTIONAL, FlowDirection.BI_DIRECTIONAL); + + val isOpen = filter != FlowDirection.NONE + + companion object { + @JvmField + val BI_SET: ImmutableSet = ImmutableSet.of(NONE, INPUT, OUTPUT, PULL, PUSH, PULL_ONLY, PUSH_ONLY, PULL_PUSH, DISABLED) + + @JvmField + val INPUT_SET: ImmutableSet = ImmutableSet.of(INPUT, PULL, DISABLED) + + @JvmField + val OUTPUT_SET: ImmutableSet = ImmutableSet.of(OUTPUT, PUSH, DISABLED) + + @JvmField + val CODEC = EnumValueCodec(SideMode::class.java) + } + } + + fun interface SideModeListener { + fun sideModeChanges(config: Side.ModeState, new: SideMode, old: SideMode) + } + + inner class Side(val side: RelativeSide) : INBTSerializable { init { - check(!caps.values.any { it.name == name }) { "Already has capability with name $name!" } - check(!caps.containsKey(type)) { "Already has capability with type $type!" } - caps[type] = this - types.add(type) + check(!_sides.containsKey(side)) { "dafuq are you trying to do" } + _sides[side] = this } - fun alias(type: Capability): S { - if (type !in types) { - check(!caps.containsKey(type)) { "Already has capability with type $type!" } - caps[type] = this - types.add(type) - } + private val caps = Reference2ObjectArrayMap, Cap<*>>() + private val modeStates = Object2ObjectArrayMap() + private val data = Object2ObjectArrayMap>() - return this as S + val isEmpty get() = caps.isEmpty() && modeStates.isEmpty() + + operator fun get(capability: Capability): Cap? { + return caps[capability] as Cap? } - override fun toString(): String { - return "${this@MatteryBlockEntity} at $blockPos CapInstance[name = $name, capability = $capability]" + operator fun get(index: String): ModeState? { + return modeStates[index] + } + + fun addData(index: ResourceLocation, data: INBTSerializable<*>) { + this.data[index] = data as INBTSerializable + } + + fun getData(index: ResourceLocation): INBTSerializable<*>? { + return data[index] + } + + fun invalidate() { + for (cap in caps.values) + cap.invalidate() + } + + fun revive() { + for (cap in caps.values) + cap.revive() } override fun serializeNBT(): CompoundTag { return CompoundTag().also { - var sides = 0 + val modelist = CompoundTag() - for (i in 0 .. 5) - if (exposedSides[i].first) - sides = sides.or(1 shl (i + 1)) + for (cap in modeStates.values) { + modelist[cap.name] = cap.serializeNBT() + } - it["sides"] = sides.toShort() - - if (capability is INBTSerializable<*>) - it["capability"] = (capability as INBTSerializable).serializeNBT() + it["Modes"] = modelist } } override fun deserializeNBT(nbt: CompoundTag) { - var sides = 0 + if (nbt.contains("Modes")) { + val caplist = nbt.getCompound("Modes") - if (nbt.contains("sides")) { - sides = nbt.getInt("sides") - } - - for (i in 0 .. 5) { - val isExposed = sides and (1 shl (1 + i)) == 1 - - if (isExposed && valid) { - exposedSides[i] = true to LazyOptional.of { capability } - } else { - exposedSides[i] = isExposed to LazyOptional.empty() + for (state in modeStates.values) { + if (state.name in caplist) { + state.deserializeNBT(caplist.getString(state.name)) + } } } - - val tag = nbt["capability"] - - if (tag != null && capability is INBTSerializable<*>) { - // will throw classcastexception if serialized type is wrong - (capability as INBTSerializable).deserializeNBT(tag) - } } - protected val exposedSides = Array>>(6) { true to LazyOptional.of { capability } } + inner class ModeState(val name: String, val possibleValues: ImmutableSet = SideMode.BI_SET) : INBTSerializable { + init { + check(!modeStates.containsKey(name)) { "Already has config with name $name on side $side" } + modeStates[name] = this + } - fun exposeAt(side: RelativeSide): S { - if (!exposedSides[side.ordinal].first) { - if (valid) { - setChanged() - exposedSides[side.ordinal] = true to LazyOptional.of { capability } - } else { - exposedSides[side.ordinal] = true to LazyOptional.empty() + val side get() = this@Side.side + + var mode by synchronizer.Field(possibleValues.first(), SideMode.CODEC, setter = { value, access, setByRemote -> + require(value in possibleValues) { "Value $value is not allowed (allowed values: $possibleValues)" } + val old = access.read() + + if (value != old) { + access.write(value) + + listeners.forValidRefs { + it.sideModeChanges(this, value, old) + } } - } + }, name = "SideConfig/$side/$name") - return this as S - } + fun isAllowed(value: SideMode): Boolean = value in possibleValues - fun closeAt(side: RelativeSide): S { - if (exposedSides[side.ordinal].first) { - exposedSides[side.ordinal].second.invalidate() - exposedSides[side.ordinal] = false to LazyOptional.empty() - } + private val listeners = ArrayList>() - return this as S - } + fun addListener(listener: SideModeListener) { + var hit = false - fun closeAll(): S { - for (side in RelativeSide.values()) - closeAt(side) - - return this as S - } - - fun exposeAll(): S { - for (side in RelativeSide.values()) - exposeAt(side) - - return this as S - } - - fun exposeFront() = exposeAt(RelativeSide.FRONT) - fun exposeBack() = exposeAt(RelativeSide.BACK) - fun exposeLeft() = exposeAt(RelativeSide.LEFT) - fun exposeRight() = exposeAt(RelativeSide.RIGHT) - fun exposeTop() = exposeAt(RelativeSide.TOP) - fun exposeBottom() = exposeAt(RelativeSide.BOTTOM) - - fun closeFront() = closeAt(RelativeSide.FRONT) - fun closeBack() = closeAt(RelativeSide.BACK) - fun closeLeft() = closeAt(RelativeSide.LEFT) - fun closeRight() = closeAt(RelativeSide.RIGHT) - fun closeTop() = closeAt(RelativeSide.TOP) - fun closeBottom() = closeAt(RelativeSide.BOTTOM) - - fun isExposedAt(side: RelativeSide): Boolean { - return exposedSides[side.ordinal].first - } - - fun isExposedAt(side: Direction): Boolean { - return isExposedAt(blockRotation.dir2Side(side)) - } - - fun get(side: Direction? = null): LazyOptional { - if (!valid) { - return LazyOptional.empty() - } - - if (side == null) { - return optional - } else { - return exposedSides[blockRotation.dir2Side(side).ordinal].second - } - } - - fun invalidate() { - if (valid) { - for ((_, v) in exposedSides) - v.invalidate() - - optional.invalidate() - valid = false - } - } - - fun revive() { - if (!valid) { - for ((i, pair) in exposedSides.withIndex()) - if (pair.first) - exposedSides[i] = true to LazyOptional.of { capability } - - optional = LazyOptional.of { capability } - valid = true - } - } - } - - inner class StaticCap(type: Capability, name: String, override val capability: T) : CapInstance>(type, name) - - inner class DynamicCap(type: Capability, name: String, capability: T) : CapInstance>(type, name) { - override var capability: T = capability - private set(value) { - field = value - - if (valid) { - val old = ArrayList>(7) - old.add(optional) - val new = LazyOptional.of { value } - optional = new - - for ((i, pair) in exposedSides.withIndex()) { - if (pair.first) { - old.add(pair.second) - exposedSides[i] = true to LazyOptional.of { value } - } + listeners.forValidRefsBreak { + if (it === listener) { + hit = true + return@forValidRefsBreak true } - old.forEach(LazyOptional::invalidate) + return@forValidRefsBreak false + } + + if (!hit) { + listeners.add(WeakReference(listener)) } } + + override fun serializeNBT(): StringTag { + return StringTag.valueOf(mode.name) + } + + override fun deserializeNBT(nbt: StringTag) { + mode = SideMode.valueOf(nbt.asString) + } + + fun deserializeNBT(nbt: String) { + mode = SideMode.valueOf(nbt) + } + } + + inner class Cap(val type: Capability, val capability: T) { + init { + check(!caps.containsKey(type)) { "Already has capability $type on side $side" } + caps[type] = this + } + + private var isExposed = true + private var isValid = true + private var isRemoved = false + + var optional: LazyOptional by object : ReadWriteProperty> { + private var value: LazyOptional? = null + + override fun getValue(thisRef: Any?, property: KProperty<*>): LazyOptional { + if (value == null) { + value = LazyOptional.of { capability } + } + + return value!! + } + + override fun setValue(thisRef: Any?, property: KProperty<*>, value: LazyOptional) { + this.value = value + } + } + private set + + fun remove() { + if (!isRemoved) { + isRemoved = true + val removed = caps.remove(type) + check(removed == this) { "$removed != $this" } + optional.invalidate() + } + } + + fun close() { + if (!isRemoved && isExposed) { + isExposed = false + optional.invalidate() + setChanged() + } + } + + fun expose() { + if (!isRemoved && !isExposed) { + isExposed = true + + if (isValid) { + optional = LazyOptional.of { capability } + setChanged() + } + } + } + + fun invalidate() { + if (!isRemoved && isValid) { + isValid = false + optional.invalidate() + setChanged() + } + } + + fun revive() { + if (!isRemoved && !isValid) { + isValid = true + + if (isExposed) { + optional = LazyOptional.of { capability } + setChanged() + } + } + } + } } - // /Capabilities + val front = Side(RelativeSide.FRONT) + val back = Side(RelativeSide.BACK) + val left = Side(RelativeSide.LEFT) + val right = Side(RelativeSide.RIGHT) + val top = Side(RelativeSide.TOP) + val bottom = Side(RelativeSide.BOTTOM) - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - return caps[cap]?.get(side)?.cast() ?: super.getCapability(cap, side) + override fun getCapability(cap: Capability, side: Direction?): LazyOptional { + if (side != null) { + val get = _sides[blockRotation.dir2Side(side)]!![cap] + + if (get != null) + return get.optional + + return super.getCapability(cap, side) + } + + return sidelessCaps[cap]?.optional?.cast() ?: super.getCapability(cap, side) } override fun invalidateCaps() { super.invalidateCaps() - for (cap in caps.values) - cap.invalidate() + for (side in sides.values) + side.invalidate() } override fun reviveCaps() { super.reviveCaps() - for (cap in caps.values) - cap.revive() + for (side in sides.values) + side.revive() } private data class Savetable0(val type: Class, val property: KProperty0, val name: String, val serialize: (V) -> T, val deserialize: (V, T) -> Unit) @@ -304,7 +423,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc /** * Save and load object state */ - protected fun savetable(type: Class, property: KProperty0, name: String = property.name, serialize: (V) -> T, deserialize: (V, T?) -> Unit) { + protected fun savetable(type: Class, property: KProperty0, name: String = property.name, serialize: (V) -> T, deserialize: (V, T) -> Unit) { check(!savetables0.any { it.name == name }) { "Already has save field with name $name" } check(!savetables1.any { it.name == name }) { "Already has save field with name $name" } savetables0.add(Savetable0(type, property, name, serialize, deserialize)) @@ -313,7 +432,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc /** * Save and load value */ - protected fun savetable(type: Class, property: KMutableProperty0, name: String = property.name, serialize: (V) -> T, deserialize: (T?) -> V) { + protected fun savetable(type: Class, property: KMutableProperty0, name: String = property.name, serialize: (V) -> T, deserialize: (T) -> V) { check(!savetables0.any { it.name == name }) { "Already has save field with name $name" } check(!savetables1.any { it.name == name }) { "Already has save field with name $name" } savetables1.add(Savetable1(type, property, name, serialize, deserialize)) @@ -336,24 +455,38 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc /** * Save and load object state */ - protected inline fun savetable(property: KProperty0, name: String = property.name, noinline serialize: (V) -> T, noinline deserialize: (V, T?) -> Unit) { + protected inline fun savetable(property: KProperty0, name: String = property.name, noinline serialize: (V) -> T, noinline deserialize: (V, T) -> Unit) { savetable(T::class.java, property, name, serialize, deserialize) } /** * Save and load value */ - protected inline fun savetable(property: KMutableProperty0, name: String = property.name, noinline serialize: (V) -> T, noinline deserialize: (T?) -> V) { + protected inline fun savetable(property: KMutableProperty0, name: String = property.name, noinline serialize: (V) -> T, noinline deserialize: (T) -> V) { savetable(T::class.java, property, name, serialize, deserialize) } + protected fun savetableFloat(property: KMutableProperty0, name: String = property.name) { + savetable(FloatTag::class.java, property, name, { FloatTag.valueOf(it) }, { tag -> tag.asFloat }) + } + + protected fun savetableDouble(property: KMutableProperty0, name: String = property.name) { + savetable(DoubleTag::class.java, property, name, { DoubleTag.valueOf(it) }, { tag -> tag.asDouble }) + } + + protected fun savetableBoolean(property: KMutableProperty0, name: String = property.name) { + savetable(ByteTag::class.java, property, name, { if (it) ByteTag.ONE else ByteTag.ZERO }, { tag -> tag.asInt > 0 }) + } + override fun saveAdditional(nbt: CompoundTag) { super.saveAdditional(nbt) - if (caps.isNotEmpty()) { - nbt["Capabilities"] = CompoundTag().also { - for (cap in caps.values) { - it[cap.name] = cap.serializeNBT() + if (_sides.values.any { !it.isEmpty }) { + nbt["Sides"] = CompoundTag().also { + for (side in _sides.values) { + if (!side.isEmpty) { + it[side.side.name] = side.serializeNBT() + } } } } @@ -370,13 +503,12 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc override fun load(nbt: CompoundTag) { super.load(nbt) - if (nbt.contains("Capabilities")) { - @Suppress("name_shadowing") - val nbt = nbt.getCompound("Capabilities") + if (nbt.contains("Sides")) { + val tag = nbt.getCompound("Sides") - for (cap in caps.values) { - if (nbt.contains(cap.name)) { - cap.deserializeNBT(nbt.getCompound(cap.name)) + for (side in _sides.values) { + if (side.side.name in tag) { + side.deserializeNBT(tag.getCompound(side.side.name)) } } } @@ -387,7 +519,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc if (value != null && data.type.isAssignableFrom(value.javaClass)) { (data.deserialize as (Any, Tag) -> Unit).invoke(data.property.get(), value) } else if (value != null) { - throw ClassCastException("Expected ") + throw ClassCastException("Expected ${data.type.canonicalName}, got ${value.javaClass.canonicalName}") } } @@ -396,6 +528,8 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc if (value != null && data.type.isAssignableFrom(value.javaClass)) { (data.property as KMutableProperty0).set((data.deserialize as (Tag) -> Any).invoke(value)) + } else if (value != null) { + throw ClassCastException("Expected ${data.type.canonicalName}, got ${value.javaClass.canonicalName}") } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt index 89d265c9c..ed857c2dd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt @@ -9,6 +9,7 @@ import net.minecraft.world.item.BlockItem import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.BlockGetter +import net.minecraft.world.level.Level import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.capabilities.Capability @@ -26,22 +27,25 @@ import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set abstract class MatteryPoweredBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(p_155228_, p_155229_, p_155230_) { - abstract val energy: BlockEnergyStorageImpl? - private var valid = true - val batteryContainer = MatteryContainer(this::setChangedLight, 1) + val batteryContainer = MatteryContainer(::setChangedLight, 1) + + init { + savetable(::batteryContainer, BATTERY_KEY) + } protected fun batteryChargeLoop() { + val energy = matteryEnergy if (energy == null || !batteryContainer.any { !it.isEmpty }) return - var demand = energy!!.receiveEnergy(energy!!.missingPower, true) + var demand = energy.receiveEnergy(energy.missingPower, true) if (demand.isZero) return for (stack in batteryContainer) { if (!stack.isEmpty) { stack.getCapability(ForgeCapabilities.ENERGY).ifPresentK { val diff = it.extractEnergy(demand, false) - energy!!.receiveEnergy(diff, false) + energy.receiveEnergy(diff, false) demand -= diff } @@ -51,42 +55,6 @@ abstract class MatteryPoweredBlockEntity(p_155228_: BlockEntityType<*>, p_155229 } } - override fun invalidateCaps() { - super.invalidateCaps() - energy?.invalidate() - valid = false - } - - override fun reviveCaps() { - super.reviveCaps() - energy?.revive() - valid = true - } - - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - if (valid && (cap === MatteryCapability.ENERGY || cap === ForgeCapabilities.ENERGY) && energy != null) - return energy!!.resolver.cast() - - return super.getCapability(cap, side) - } - - public override fun saveAdditional(nbt: CompoundTag) { - super.saveAdditional(nbt) - - if (energy != null) - nbt[ENERGY_KEY] = energy!!.serializeNBT() - - nbt[BATTERY_KEY] = batteryContainer.serializeNBT() - } - - override fun load(nbt: CompoundTag) { - if (energy != null) - nbt.ifHas(ENERGY_KEY, CompoundTag::class.java, energy!!::deserializeNBT) - - batteryContainer.deserializeNBT(nbt[BATTERY_KEY]) - super.load(nbt) - } - companion object { fun appendHoverText(itemStack: ItemStack, blockGetter: BlockGetter?, tooltips: MutableList, flag: TooltipFlag) { val tag = itemStack.tag?.get(BlockItem.BLOCK_ENTITY_TAG) as? CompoundTag ?: return diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt index 7eef81a74..882bb93af 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt @@ -11,6 +11,7 @@ import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.block.Block import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.getDecimal @@ -254,10 +255,7 @@ abstract class MatteryWorkerBlockEntity( errorTicksAnim = 0 idleTicksAnim++ - if (idleTicksAnim > 20 && blockState.hasProperty(WorkerState.WORKER_STATE) && blockState.getValue( - WorkerState.WORKER_STATE - ) != WorkerState.IDLE - ) { + if (idleTicksAnim > 20 && blockState.hasProperty(WorkerState.WORKER_STATE) && blockState.getValue(WorkerState.WORKER_STATE) != WorkerState.IDLE) { level?.setBlock(blockPos, blockState.setValue(WorkerState.WORKER_STATE, WorkerState.IDLE), Block.UPDATE_CLIENTS) } @@ -265,6 +263,7 @@ abstract class MatteryWorkerBlockEntity( } var availableTicks = 1.0 + val energy = matteryEnergy while (!isIdling && weakGreaterThan(availableTicks, 0.0) && throttleTicks <= 0) { if (redstoneControl.isBlockedByRedstone) { @@ -288,7 +287,7 @@ abstract class MatteryWorkerBlockEntity( currentJob = job } - if (!currentJob.powerUsage.isZero && (energy == null || energy!!.batteryLevel.isZero)) { + if (!currentJob.powerUsage.isZero && (energy == null || energy.batteryLevel.isZero)) { idleReason = IdleReason.POWER isIdling = true idleTicksAnim++ diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt index b345ac238..75eed3621 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt @@ -95,35 +95,19 @@ class CargoCrateBlockEntity( } } - override fun invalidateCaps() { - super.invalidateCaps() - handler.invalidate() - } - - override fun reviveCaps() { - super.reviveCaps() - handler.revive() - } - - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - if (cap == ForgeCapabilities.ITEM_HANDLER) - return handler.get().cast() - - return super.getCapability(cap, side) + init { + exposeItemsGlobally(handler) + savetable(::container, INVENTORY_KEY) } override fun saveAdditional(nbt: CompoundTag) { super.saveAdditional(nbt) - nbt[INVENTORY_KEY] = container.serializeNBT() - lootTable?.let { nbt[LOOT_TABLE_KEY] = it.toString() } lootTableSeed?.let { nbt[LOOT_TABLE_SEED_KEY] = it } } override fun load(nbt: CompoundTag) { super.load(nbt) - container.deserializeNBT(nbt[INVENTORY_KEY]) - lootTable = nbt.map(LOOT_TABLE_KEY) { it: StringTag -> ResourceLocation.tryParse(it.asString) } lootTableSeed = (nbt[LOOT_TABLE_SEED_KEY] as LongTag?)?.asLong } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index bfd1ebad7..f115b3692 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -49,8 +49,7 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.MATTER_BOTTLER, p_155229_, p_155230_), IMatterGraphNode, IDroppableContainer { override val matterNode = Graph6Node(this) - private val resolverNode = LazyOptional.of { this } - override val energy = WorkerEnergyStorage(this, ENERGY_VALUES) + val energy = WorkerEnergyStorage(this, ENERGY_VALUES) var isBottling: Boolean = true set(value) { @@ -98,8 +97,7 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } - override val droppableContainer: Container - get() = container + override val droppableContainer by ::container val itemHandler = container.handler(object : MatteryContainerHooks { override fun canInsert(slot: Int, stack: ItemStack): Boolean { @@ -125,6 +123,19 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } + init { + exposeGlobally(MatteryCapability.MATTER, matter) + exposeGlobally(MatteryCapability.MATTER_NODE, this) + exposeItemsGlobally(itemHandler) + + savetableBoolean(::isBottling) + savetable(::energy, ENERGY_KEY) + savetable(::matter, MATTER_STORAGE_KEY) + savetable(::container, INVENTORY_KEY) + + exposeEnergyGlobally(energy) + } + private var initialCapacity: Decimal? = null private var lastWorkStack: ItemStack? = null @@ -139,61 +150,10 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatterNetworkGraph.discoverFull(this, matterNode) } - private var valid = true - - override fun invalidateCaps() { - super.invalidateCaps() - valid = false - itemHandler.invalidate() - matter.invalidate() - } - - override fun reviveCaps() { - super.reviveCaps() - valid = true - itemHandler.revive() - matter.revive() - } - - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - if (valid) { - if (cap == MatteryCapability.MATTER) { - return matter.get().cast() - } - - if (cap == ForgeCapabilities.ITEM_HANDLER) { - return itemHandler.get().cast() - } - - if (cap == MatteryCapability.MATTER_NODE) { - return resolverNode.cast() - } - } - - return super.getCapability(cap, side) - } - - override val defaultDisplayName: Component - get() = MBlocks.MATTER_BOTTLER.name - override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { return MatterBottlerMenu(containerID, inventory, this) } - override fun saveAdditional(nbt: CompoundTag) { - super.saveAdditional(nbt) - nbt[INVENTORY_KEY] = container.serializeNBT() - nbt[IS_BOTTLING_KEY] = isBottling - nbt[MATTER_STORAGE_KEY] = matter.serializeNBT() - } - - override fun load(nbt: CompoundTag) { - super.load(nbt) - isBottling = nbt.getBoolean(IS_BOTTLING_KEY) - nbt.map(MATTER_STORAGE_KEY, matter::deserializeNBT) - nbt.map(INVENTORY_KEY, container::deserializeNBT) - } - fun getWorkProgress(): Float { val lastWorkStack = lastWorkStack ?: return 0f val initialCapacity = initialCapacity ?: return 0f diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt index 61496ebed..a195923ad 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt @@ -38,26 +38,25 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) private set override val matterNode = Graph6Node(this) - private val resolverNode = LazyOptional.of { this } override val canSetMatterLevel: Boolean get() = false override var storedMatter: Decimal get() { - var summ = Decimal.ZERO + var summ = Decimal.ZERO - for (stack in container) - if (!stack.isEmpty) - stack.getCapability(MatteryCapability.MATTER).ifPresentK { - summ += it.storedMatter - } + for (stack in container) + if (!stack.isEmpty) + stack.getCapability(MatteryCapability.MATTER).ifPresentK { + summ += it.storedMatter + } - return summ - } - set(value) { - throw UnsupportedOperationException() - } + return summ + } + set(value) { + throw UnsupportedOperationException() + } override val maxStoredMatter: Decimal get() { @@ -133,8 +132,6 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) override val matterFlow: FlowDirection get() = FlowDirection.BI_DIRECTIONAL - private var resolver = LazyOptional.of { this } - val container = object : MatteryContainer(this::setChangedLight, BatteryBankBlockEntity.CAPACITY) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { super.setChanged(slot, new, old) @@ -147,48 +144,18 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) synchronizer.bool(false, name = "capacitor$it") } - override val droppableContainer: Container - get() = container - override val defaultDisplayName: Component - get() = MACHINE_NAME + override val droppableContainer by ::container - override fun saveAdditional(nbt: CompoundTag) { - super.saveAdditional(nbt) - nbt[INVENTORY_KEY] = container.serializeNBT() - } - - override fun load(nbt: CompoundTag) { - super.load(nbt) - nbt.map(INVENTORY_KEY, container::deserializeNBT) + init { + savetable(::container, INVENTORY_KEY) + exposeGlobally(MatteryCapability.MATTER, this) + exposeGlobally(MatteryCapability.MATTER_NODE, this) } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { return MatterCapacitorBankMenu(containerID, inventory, this) } - private var valid = true - - override fun invalidateCaps() { - super.invalidateCaps() - valid = false - resolver.invalidate() - } - - override fun reviveCaps() { - super.reviveCaps() - valid = true - resolver = LazyOptional.of { this } - } - - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - if (valid) { - if (cap === MatteryCapability.MATTER) return resolver.cast() - if (cap === MatteryCapability.MATTER_NODE) return resolverNode.cast() - } - - return super.getCapability(cap, side) - } - override fun setRemoved() { super.setRemoved() matterNode.destroy(::MatterNetworkGraph) @@ -204,8 +171,4 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) override fun getMatterHandler(): IMatterStorage { return this } - - companion object { - private val MACHINE_NAME = TranslatableComponent("block.overdrive_that_matters.matter_capacitor_bank") - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index ddb55e1da..e46abbf57 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -130,74 +130,46 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) } } - override val energy = WorkerEnergyStorage(this, ENERGY_VALUES) - private var valid = true + val energy = WorkerEnergyStorage(this, ENERGY_VALUES) + + init { + exposeEnergyGlobally(energy) + savetable(::energy, ENERGY_KEY) + } + override val matterNode = Graph6Node(this) - val matter = MatterStorageImpl(this::setChangedLight, FlowDirection.OUTPUT, ::CAPACITY) + val matter = MatterStorageImpl(::setChangedLight, FlowDirection.OUTPUT, ::CAPACITY) - private var resolverMatter = LazyOptional.of { matter } - private var resolverNode = LazyOptional.of { this } + init { + exposeGlobally(MatteryCapability.MATTER, matter) + exposeGlobally(MatteryCapability.MATTER_NODE, this) + savetable(::matter, MATTER_STORAGE_KEY) + } // вход, выход val container = MatteryContainer(this::setChangedLight, 3) + override val droppableContainer by ::container - override val droppableContainer: Container - get() = container + val itemHandler = container.handler(object : MatteryContainerHooks { + override fun canInsert(slot: Int, stack: ItemStack): Boolean { + return slot == INPUT_SLOT && MatterManager.canDecompose(stack) + } - private val itemHandler = LazyOptional.of { - container.handler(object : MatteryContainerHooks { - override fun canInsert(slot: Int, stack: ItemStack): Boolean { - return slot == INPUT_SLOT && MatterManager.canDecompose(stack) - } + override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { + return slot != INPUT_SLOT + } + }) - override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { - return slot != INPUT_SLOT - } - }) + init { + exposeItemsGlobally(itemHandler) + savetable(::container, INVENTORY_KEY) } - override val defaultDisplayName: Component - get() = MBlocks.MATTER_DECOMPOSER.name - override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { return MatterDecomposerMenu(containerID, inventory, this) } - override fun saveAdditional(nbt: CompoundTag) { - super.saveAdditional(nbt) - nbt[INVENTORY_KEY] = container.serializeNBT() - nbt[MATTER_STORAGE_KEY] = matter.serializeNBT() - } - - override fun load(nbt: CompoundTag) { - super.load(nbt) - nbt.map(INVENTORY_KEY, container::deserializeNBT) - nbt.map(MATTER_STORAGE_KEY, matter::deserializeNBT) - } - - override fun reviveCaps() { - valid = true - super.reviveCaps() - resolverMatter = LazyOptional.of { matter } - } - - override fun invalidateCaps() { - valid = false - super.invalidateCaps() - resolverMatter.invalidate() - } - - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - if (valid) { - if (cap == MatteryCapability.MATTER) return resolverMatter.cast() - if (cap == MatteryCapability.MATTER_NODE) return resolverNode.cast() - if (cap == ForgeCapabilities.ITEM_HANDLER) return itemHandler.cast() - } - - return super.getCapability(cap, side) - } - override fun onJobFinish(job: DecomposerJob): Status { if (job.toDust) { job.matterValue = moveMatterAsDustIntoContainer(job.matterValue, container, OUTPUT_DUST_MAIN, OUTPUT_DUST_STACKING) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt index 28c09daeb..0c248d17c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt @@ -49,27 +49,9 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return MatterPanelMenu(containerID, inventory, this) } - private var valid = true - - override fun invalidateCaps() { - super.invalidateCaps() - valid = false - resolver.invalidate() - } - - override fun reviveCaps() { - super.reviveCaps() - valid = true - resolver = LazyOptional.of { this } - } - - private var resolver = LazyOptional.of { this } - - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - if (valid && (cap === MatteryCapability.MATTER_NODE || cap === MatteryCapability.TASK)) - return resolver.cast() - - return super.getCapability(cap, side) + init { + exposeGlobally(MatteryCapability.MATTER_NODE, this) + exposeGlobally(MatteryCapability.TASK, this) } override fun setLevel(p_155231_: Level) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index 92530b835..d35c5f407 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -82,12 +82,9 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) val container = MatteryContainer(this::itemContainerUpdated, 1) - override val droppableContainer: Container - get() = container + override val droppableContainer by ::container override val matterNode = Graph6Node(this) - private var resolverNode = LazyOptional.of { this } - private var valid = true - override val energy = WorkerEnergyStorage(this::powerLevelUpdated, ENERGY_CONFIG) + val energy = WorkerEnergyStorage(this::powerLevelUpdated, ENERGY_CONFIG) override fun getMatterHandler(): IMatterStorage { return matter @@ -103,18 +100,14 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) } }) - override fun invalidateCaps() { - super.invalidateCaps() - matter.invalidate() - itemHandler.invalidate() - resolverNode.invalidate() - } - - override fun reviveCaps() { - super.reviveCaps() - matter.revive() - itemHandler.revive() - resolverNode = LazyOptional.of { this } + init { + exposeItemsGlobally(itemHandler) + exposeEnergyGlobally(energy) + exposeGlobally(MatteryCapability.MATTER, matter) + exposeGlobally(MatteryCapability.MATTER_NODE, this) + savetable(::energy, ENERGY_KEY) + savetable(::container, INVENTORY_KEY) + savetable(::matter, MATTER_STORAGE_KEY) } override fun setRemoved() { @@ -129,33 +122,6 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) MatterNetworkGraph.discoverFull(this, matterNode) } - override fun saveAdditional(nbt: CompoundTag) { - super.saveAdditional(nbt) - nbt[MATTER_STORAGE_KEY] = matter.serializeNBT() - nbt[INVENTORY_KEY] = container.serializeNBT() - } - - override fun load(nbt: CompoundTag) { - super.load(nbt) - nbt.map(MATTER_STORAGE_KEY, matter::deserializeNBT) - nbt.map(INVENTORY_KEY, container::deserializeNBT) - } - - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - if (!valid) - return super.getCapability(cap, side) - - return when (cap) { - ForgeCapabilities.ITEM_HANDLER -> itemHandler.get().cast() - MatteryCapability.MATTER -> matter.get().cast() - MatteryCapability.MATTER_NODE -> resolverNode.cast() - else -> super.getCapability(cap, side) - } - } - - override val defaultDisplayName: Component - get() = MBlocks.MATTER_RECYCLER.name - override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { return MatterRecyclerMenu(containerID, inventory, this) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index fd2f060a3..79c421027 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -105,24 +105,23 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } - override val energy = WorkerEnergyStorage(this::powerLevelUpdated, ENERGY_VALUES) + val energy = WorkerEnergyStorage(this::powerLevelUpdated, ENERGY_VALUES) override val matterNode = Graph6Node(this) - private val resolverNode = LazyOptional.of { this } - - val matter = MatterStorageImpl( - this::matterLevelUpdated, - FlowDirection.INPUT, - ::MATTER_CAPACITY - ) - + val matter = MatterStorageImpl(this::matterLevelUpdated, FlowDirection.INPUT, ::MATTER_CAPACITY) val container = MatteryContainer(this::itemContainerUpdated, 5) - private val itemHandler = container.handler(MatteryContainerHandler.OnlyOut) + val itemHandler = container.handler(MatteryContainerHandler.OnlyOut) + override val droppableContainer by ::container - override val defaultDisplayName: Component - get() = MBlocks.MATTER_REPLICATOR.name + init { + exposeEnergyGlobally(energy) + exposeItemsGlobally(itemHandler) + exposeGlobally(MatteryCapability.MATTER, matter) + exposeGlobally(MatteryCapability.MATTER_NODE, this) - override val droppableContainer: Container - get() = container + savetable(::energy, ENERGY_KEY) + savetable(::matter, MATTER_STORAGE_KEY) + savetable(::container, INVENTORY_KEY) + } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { return MatterReplicatorMenu(containerID, inventory, this) @@ -270,41 +269,6 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return Status.SUCCESS } - override fun saveAdditional(nbt: CompoundTag) { - super.saveAdditional(nbt) - nbt[INVENTORY_KEY] = container.serializeNBT() - nbt[MATTER_STORAGE_KEY] = matter.serializeNBT() - } - - override fun load(nbt: CompoundTag) { - super.load(nbt) - nbt.map(INVENTORY_KEY, container::deserializeNBT) - nbt.map(MATTER_STORAGE_KEY, matter::deserializeNBT) - } - - private var valid = true - - override fun invalidateCaps() { - super.invalidateCaps() - valid = false - itemHandler.invalidate() - } - - override fun reviveCaps() { - super.reviveCaps() - valid = true - itemHandler.revive() - } - - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - if (valid) { - if (cap == MatteryCapability.MATTER_NODE) return resolverNode.cast() - if (cap == ForgeCapabilities.ITEM_HANDLER) return itemHandler.get().cast() - } - - return super.getCapability(cap, side) - } - companion object { private val BASE_CONSUMPTION get() = _BASE_CONSUMPTION.get() private val DRAIN_MULT get() = _DRAIN_MULT.get() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt index f61f3d1d0..60d86ebfb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt @@ -46,9 +46,8 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryWorkerBlockEntity(MBlockEntities.MATTER_SCANNER, p_155229_, p_155230_, ::ItemJob), IMatterGraphNode, IDroppableContainer { val container = MatteryContainer(this::itemContainerUpdated, 1) - override val energy = WorkerEnergyStorage(this::powerLevelUpdated, ENERGY_VALUES) - - private val itemHandler = container.handler(object : MatteryContainerHooks { + val energy = WorkerEnergyStorage(this::powerLevelUpdated, ENERGY_VALUES) + val itemHandler = container.handler(object : MatteryContainerHooks { override fun canInsert(slot: Int, stack: ItemStack): Boolean { return MatterManager.canDecompose(stack) } @@ -58,8 +57,16 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } }) - override val droppableContainer: Container - get() = container + override val droppableContainer by ::container + + init { + exposeItemsGlobally(itemHandler) + exposeEnergyGlobally(energy) + exposeGlobally(MatteryCapability.MATTER_NODE, this) + + savetable(::container, INVENTORY_KEY) + savetable(::energy, ENERGY_KEY) + } // IMatterGraphNode override fun onPatternAdded(state: IPatternState) { @@ -81,56 +88,22 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } // /IMatterGraphNode - private var valid = true override val matterNode: Graph6Node = Graph6Node(this) - private var resolverNode = LazyOptional.of { this } - - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - if (valid) { - if (cap == ForgeCapabilities.ITEM_HANDLER) return itemHandler.get().cast() - if (cap == MatteryCapability.MATTER_NODE) return resolverNode.cast() - } - - return super.getCapability(cap, side) - } override fun invalidateCaps() { super.invalidateCaps() - valid = false - itemHandler.invalidate() - resolverNode.invalidate() matterNode.destroy(::MatterNetworkGraph) } - override fun reviveCaps() { - super.reviveCaps() - valid = true - itemHandler.revive() - resolverNode = LazyOptional.of { this } - } - override fun setRemoved() { super.setRemoved() matterNode.destroy(::MatterNetworkGraph) } - override val defaultDisplayName: Component - get() = MBlocks.MATTER_SCANNER.name - override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { return MatterScannerMenu(containerID, inventory, this) } - override fun saveAdditional(nbt: CompoundTag) { - super.saveAdditional(nbt) - nbt.put(INVENTORY_KEY, container.serializeNBT()) - } - - override fun load(nbt: CompoundTag) { - super.load(nbt) - nbt.map(INVENTORY_KEY, container::deserializeNBT) - } - override fun onJobFinish(job: ItemJob): Status { val grid = matterNode.graph as MatterNetworkGraph? ?: return Status.FAILURE_WAIT diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt index 378c5ac21..93c3ff577 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt @@ -16,7 +16,6 @@ import net.minecraft.world.inventory.AbstractContainerMenu import ru.dbotthepony.mc.otm.menu.matter.PatternStorageMenu import net.minecraft.MethodsReturnNonnullByDefault import net.minecraft.core.Direction -import net.minecraft.network.chat.Component import net.minecraft.server.level.ServerLevel import net.minecraft.world.Container import net.minecraft.world.level.Level @@ -25,7 +24,6 @@ import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity -import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.capability.matter.* import ru.dbotthepony.mc.otm.core.collect.iterator import ru.dbotthepony.mc.otm.graph.Graph6Node @@ -43,10 +41,8 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.PATTERN_STORAGE, p_155229_, p_155230_), IMatterGraphNode, IPatternStorage, IDroppableContainer { override val matterNode = Graph6Node(this) - private val resolverPatterns = LazyOptional.of { this } - private val resolverNode = LazyOptional.of { this } - val patternContainer: MatteryContainer = object : MatteryContainer(this::setChanged, 8) { + val container: MatteryContainer = object : MatteryContainer(this::setChanged, 8) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { val grid = matterNode.graph as MatterNetworkGraph? @@ -82,7 +78,7 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : for (i in 0..7) { state = state.setValue( PatternStorageBlock.PATTERN_STORAGE_DISKS_PROPS[i], - this.patternContainer.getItem(i).getCapability(MatteryCapability.PATTERN).isPresent + this.container.getItem(i).getCapability(MatteryCapability.PATTERN).isPresent ) } @@ -91,21 +87,8 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } - private val resolverItem = - patternContainer.handler { slot: Int, stack: ItemStack -> stack.getCapability(MatteryCapability.PATTERN).isPresent } - - override fun saveAdditional(nbt: CompoundTag) { - super.saveAdditional(nbt) - nbt[INVENTORY_KEY] = patternContainer.serializeNBT() - } - - override fun load(nbt: CompoundTag) { - super.load(nbt) - nbt.map(INVENTORY_KEY, patternContainer::deserializeNBT) - } - - override val droppableContainer: Container - get() = patternContainer + private val itemHandler = container.handler { slot: Int, stack: ItemStack -> stack.getCapability(MatteryCapability.PATTERN).isPresent } + override val droppableContainer by ::container override fun setLevel(p_155231_: Level) { super.setLevel(p_155231_) @@ -118,34 +101,19 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return this } - private var valid = true - override fun invalidateCaps() { super.invalidateCaps() - valid = false - resolverItem.invalidate() matterNode.destroy(::MatterNetworkGraph) } - override fun reviveCaps() { - super.reviveCaps() - valid = true - resolverItem.revive() + init { + exposeGlobally(MatteryCapability.PATTERN, this) + exposeGlobally(MatteryCapability.MATTER_NODE, this) + exposeItemsGlobally(itemHandler) + + savetable(::container, INVENTORY_KEY) } - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - if (valid) { - if (cap == MatteryCapability.PATTERN) return resolverPatterns.cast() - if (cap == MatteryCapability.MATTER_NODE) return resolverNode.cast() - if (cap == ForgeCapabilities.ITEM_HANDLER) return resolverItem.get().cast() - } - - return super.getCapability(cap, side) - } - - override val defaultDisplayName: Component - get() = MACHINE_NAME - override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { return PatternStorageMenu(containerID, inventory, this) } @@ -153,7 +121,7 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : override val patterns: Stream get() { val streams = ArrayList>() - for (provider in this.patternContainer.iterator(MatteryCapability.PATTERN)) { + for (provider in this.container.iterator(MatteryCapability.PATTERN)) { streams.add(provider.second.patterns) } @@ -163,7 +131,7 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : override val patternCapacity: Int get() { var stored = 0L - for ((_, pattern) in this.patternContainer.iterator(MatteryCapability.PATTERN)) + for ((_, pattern) in this.container.iterator(MatteryCapability.PATTERN)) stored += pattern.patternCapacity.toLong() return if (stored > Int.MAX_VALUE) Int.MAX_VALUE else stored.toInt() @@ -172,7 +140,7 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : override val storedPatterns: Int get() { var stored = 0L - for ((_, pattern) in this.patternContainer.iterator(MatteryCapability.PATTERN)) + for ((_, pattern) in this.container.iterator(MatteryCapability.PATTERN)) stored += pattern.storedPatterns.toLong() return if (stored > Int.MAX_VALUE) Int.MAX_VALUE else stored.toInt() @@ -184,7 +152,7 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } override fun insertPattern(pattern: IPatternState, onlyUpdate: Boolean, simulate: Boolean): PatternInsertStatus { - for (pair in this.patternContainer.iterator(MatteryCapability.PATTERN)) { + for (pair in this.container.iterator(MatteryCapability.PATTERN)) { val status = pair.second.insertPattern(pattern, onlyUpdate, simulate) if (!status.isFailed) { @@ -208,8 +176,4 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return PatternInsertFailure } - - companion object { - private val MACHINE_NAME = TranslatableComponent("block.overdrive_that_matters.pattern_storage") - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt index 776b4fa85..f56a58c2c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt @@ -30,7 +30,7 @@ import ru.dbotthepony.mc.otm.storage.* class DriveRackBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.DRIVE_RACK, p_155229_, p_155230_) { - override val energy = WorkerEnergyStorage(this, MachinesConfig.DRIVE_RACK) + val energy = WorkerEnergyStorage(this, MachinesConfig.DRIVE_RACK) val container: MatteryContainer = object : MatteryContainer(this::setChanged, 4) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { @@ -52,14 +52,11 @@ class DriveRackBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val cell = BasicStorageGraphNode(energy) - override fun load(nbt: CompoundTag) { - super.load(nbt) - nbt.map(INVENTORY_KEY, container::deserializeNBT) - } - - override fun saveAdditional(nbt: CompoundTag) { - super.saveAdditional(nbt) - nbt[INVENTORY_KEY] = container.serializeNBT() + init { + savetable(::energy, ENERGY_KEY) + savetable(::container, INVENTORY_KEY) + exposeEnergyGlobally(energy) + exposeGlobally(MatteryCapability.STORAGE_NODE, cell) } override fun setLevel(p_155231_: Level) { @@ -74,29 +71,10 @@ class DriveRackBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : cell.tickEnergyDemanding() } - override val defaultDisplayName: Component - get() = MBlocks.DRIVE_RACK.name - override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { return DriveRackMenu(containerID, inventory, this) } - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - return if (cap === MatteryCapability.STORAGE_NODE) { - cell.get().cast() - } else super.getCapability(cap, side) - } - - override fun invalidateCaps() { - super.invalidateCaps() - cell.invalidate() - } - - override fun reviveCaps() { - super.reviveCaps() - cell.revive() - } - override fun setRemoved() { super.setRemoved() cell.destroy(level) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt index bce874ea6..f9b176dd5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt @@ -45,7 +45,7 @@ class DriveViewerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte } } - override val energy = WorkerEnergyStorage(this, MachinesConfig.DRIVE_VIEWER) + val energy = WorkerEnergyStorage(this, MachinesConfig.DRIVE_VIEWER) val container: MatteryContainer = object : MatteryContainer(this::setChanged, 1) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { @@ -69,25 +69,19 @@ class DriveViewerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte } } - override val droppableContainer: Container - get() = container - override val defaultDisplayName: Component - get() = MBlocks.DRIVE_VIEWER.name + override val droppableContainer by ::container + + init { + savetable(::energy, ENERGY_KEY) + savetable(::container, INVENTORY_KEY) + + exposeEnergyGlobally(energy) + } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { return DriveViewerMenu(containerID, inventory, this) } - override fun saveAdditional(nbt: CompoundTag) { - super.saveAdditional(nbt) - nbt[INVENTORY_KEY] = container.serializeNBT() - } - - override fun load(nbt: CompoundTag) { - super.load(nbt) - nbt.map(INVENTORY_KEY, container::deserializeNBT) - } - fun tick() { batteryChargeLoop() } 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 4853bb18e..46df0363d 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 @@ -183,7 +183,12 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.ITEM_MONITOR, p_155229_, p_155230_), IStorageEventConsumer { - override val energy = WorkerEnergyStorage(this, MachinesConfig.ITEM_MONITOR) + val energy = WorkerEnergyStorage(this, MachinesConfig.ITEM_MONITOR) + + init { + exposeEnergyGlobally(energy) + savetable(::energy, ENERGY_KEY) + } var poweredView: PoweredVirtualComponent? = null private set @@ -201,6 +206,10 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } + init { + exposeGlobally(MatteryCapability.STORAGE_NODE, cell) + } + private val settings = HashMap() private val craftingAmount = Object2ObjectArrayMap() private val lastCraftingRecipe = Object2ObjectArrayMap() @@ -488,9 +497,6 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : lastCraftingRecipe.clear() } - override val defaultDisplayName: Component - get() = MBlocks.ITEM_MONITOR.name - override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { return ItemMonitorMenu(containerID, inventory, this) } @@ -502,22 +508,6 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : StorageNetworkGraph.discoverFull(this, cell.storageNode) } - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - return if (cap === MatteryCapability.STORAGE_NODE) { - cell.get().cast() - } else super.getCapability(cap, side) - } - - override fun invalidateCaps() { - super.invalidateCaps() - cell.invalidate() - } - - override fun reviveCaps() { - super.reviveCaps() - cell.revive() - } - override fun setRemoved() { super.setRemoved() cell.destroy(level) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt index 39ec6b9a2..12ed70922 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt @@ -29,6 +29,7 @@ import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom +import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.core.math.getCapability import ru.dbotthepony.mc.otm.core.math.isPositive import ru.dbotthepony.mc.otm.core.math.isZero @@ -77,7 +78,12 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter return StorageBusMenu(containerID, inventory, this) } - override val energy = WorkerEnergyStorage(this::setChangedLight, MachinesConfig.STORAGE_INTERFACES) + val energy = WorkerEnergyStorage(this::setChangedLight, MachinesConfig.STORAGE_INTERFACES) + + init { + exposeEnergyGlobally(energy) + savetable(::energy, ENERGY_KEY) + } val cell: BasicStorageGraphNode = object : BasicStorageGraphNode(energy), GraphNodeListener { override fun onNeighbour(node: Graph6Node<*>, direction: Direction) { @@ -95,11 +101,20 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter } } + init { + exposeSideless(MatteryCapability.STORAGE_NODE, cell) + exposeAllSidesExcept(RelativeSide.FRONT, MatteryCapability.STORAGE_NODE, cell) + } + val filter = ItemFilter(MAX_FILTERS) { _, _, _ -> component?.scan() setChangedLight() } + init { + savetable(::filter, FILTER_KEY) + } + override fun setLevel(p_155231_: Level) { super.setLevel(p_155231_) @@ -110,26 +125,6 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter tickOnceServer(this::checkSurroundings) } - private var valid = true - - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - return if (valid && cap === MatteryCapability.STORAGE_NODE && side != blockState.getValue(BlockRotationFreedom.TWO.property).front) { - cell.get().cast() - } else super.getCapability(cap, side) - } - - override fun invalidateCaps() { - super.invalidateCaps() - cell.invalidate() - valid = false - } - - override fun reviveCaps() { - super.reviveCaps() - cell.revive() - valid = true - } - private var neighbour: LazyOptional? = null private var component: ItemHandlerComponent? = null @@ -142,17 +137,6 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter override fun setRemoved() { super.setRemoved() cell.destroy(level) - valid = false - } - - override fun saveAdditional(nbt: CompoundTag) { - super.saveAdditional(nbt) - nbt[FILTER_KEY] = filter.serializeNBT() - } - - override fun load(nbt: CompoundTag) { - super.load(nbt) - nbt.map(FILTER_KEY, filter::deserializeNBT) } fun checkSurroundings() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt index 83a84d696..20ca390ac 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt @@ -30,6 +30,7 @@ import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.core.math.rotationTwo import ru.dbotthepony.mc.otm.core.math.toIntSafe import ru.dbotthepony.mc.otm.core.math.unaryMinus @@ -56,7 +57,12 @@ abstract class AbstractStorageImportExport( blockState: BlockState, energyValues: ConciseBalanceValues = MachinesConfig.STORAGE_INTERFACES ) : MatteryPoweredBlockEntity(blockType, blockPos, blockState) { - final override val energy = WorkerEnergyStorage(this::setChangedLight, energyValues) + val energy = WorkerEnergyStorage(::setChangedLight, energyValues) + + init { + exposeEnergyGlobally(energy) + savetable(::energy, ENERGY_KEY) + } val cell: BasicStorageGraphNode = object : BasicStorageGraphNode(energy), GraphNodeListener { override fun onNeighbour(node: Graph6Node<*>, direction: Direction) { @@ -74,32 +80,24 @@ abstract class AbstractStorageImportExport( } } - private var valid = true - - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - return if (valid && cap === MatteryCapability.STORAGE_NODE && side != blockState.getValue(BlockRotationFreedom.TWO.property).front) { - cell.get().cast() - } else super.getCapability(cap, side) + init { + exposeSideless(MatteryCapability.STORAGE_NODE, cell) + exposeAllSidesExcept(RelativeSide.FRONT, MatteryCapability.STORAGE_NODE, cell) } override fun invalidateCaps() { super.invalidateCaps() - cell.invalidate() target.invalidate() - valid = false } override fun reviveCaps() { super.reviveCaps() - cell.revive() target.revive() - valid = true } override fun setRemoved() { super.setRemoved() cell.destroy(level) - valid = false } override fun setLevel(p_155231_: Level) { @@ -127,14 +125,8 @@ abstract class AbstractStorageImportExport( abstract val filter: ItemFilter - override fun saveAdditional(nbt: CompoundTag) { - super.saveAdditional(nbt) - nbt[FILTER_KEY] = filter.serializeNBT() - } - - override fun load(nbt: CompoundTag) { - super.load(nbt) - nbt.map(FILTER_KEY, filter::deserializeNBT) + init { + savetable(::filter, FILTER_KEY) } companion object { @@ -146,9 +138,6 @@ abstract class AbstractStorageImportExport( class StorageImporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : AbstractStorageImportExport(MBlockEntities.STORAGE_IMPORTER, blockPos, blockState), IItemHandler { - override val defaultDisplayName: Component - get() = MACHINE_NAME - override val filter = ItemFilter(MAX_FILTERS) { _, _, _ -> setChangedLight() } @@ -165,27 +154,8 @@ class StorageImporterBlockEntity(blockPos: BlockPos, blockState: BlockState) override val targetCapability: Capability get() = ForgeCapabilities.ITEM_HANDLER - private var valid = true - private var resolverItemHandler = LazyOptional.of { this } - - override fun invalidateCaps() { - super.invalidateCaps() - resolverItemHandler.invalidate() - valid = false - } - - override fun reviveCaps() { - super.reviveCaps() - resolverItemHandler = LazyOptional.of { this } - valid = true - } - - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - if (valid && cap == ForgeCapabilities.ITEM_HANDLER && side == blockState.rotationTwo.front) { - return resolverItemHandler.cast() - } - - return super.getCapability(cap, side) + init { + front.Cap(ForgeCapabilities.ITEM_HANDLER, this) } override fun getSlots(): Int { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt index 138e11d23..21263331f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt @@ -30,18 +30,27 @@ import ru.dbotthepony.mc.otm.core.math.getDecimal import ru.dbotthepony.mc.otm.core.nbt.set class StoragePowerSupplierBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.STORAGE_POWER_SUPPLIER, blockPos, blockState) { - override val defaultDisplayName: Component - get() = MACHINE_NAME - override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { return StoragePowerSupplierMenu(containerID, inventory, this) } val cell = BasicStorageGraphNode() + val energy = WorkerEnergyStorage(this, MachinesConfig.STORAGE_POWER_SUPPLIER) + + init { + savetable(::energy, ENERGY_KEY) + + exposeEnergyGlobally(energy) + exposeGlobally(MatteryCapability.STORAGE_NODE, cell) + } var powerPassed = Decimal.ZERO private set + init { + savetable(::powerPassed, POWER_PASSED_KEY, Decimal::serializeNBT, Decimal.Companion::deserializeNBT) + } + override fun setLevel(p_155231_: Level) { super.setLevel(p_155231_) @@ -50,30 +59,9 @@ class StoragePowerSupplierBlockEntity(blockPos: BlockPos, blockState: BlockState } } - private var valid = true - - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - return if (valid && cap === MatteryCapability.STORAGE_NODE) { - cell.get().cast() - } else super.getCapability(cap, side) - } - - override fun invalidateCaps() { - super.invalidateCaps() - cell.invalidate() - valid = false - } - - override fun reviveCaps() { - super.reviveCaps() - cell.revive() - valid = true - } - override fun setRemoved() { super.setRemoved() cell.destroy(level) - valid = false } fun tick() { @@ -119,20 +107,7 @@ class StoragePowerSupplierBlockEntity(blockPos: BlockPos, blockState: BlockState } } - override val energy = WorkerEnergyStorage(this, MachinesConfig.STORAGE_POWER_SUPPLIER) - - override fun saveAdditional(nbt: CompoundTag) { - super.saveAdditional(nbt) - nbt[POWER_PASSED_KEY] = powerPassed.serializeNBT() - } - - override fun load(nbt: CompoundTag) { - super.load(nbt) - powerPassed = nbt.getDecimal(POWER_PASSED_KEY) - } - companion object { - private val MACHINE_NAME = TranslatableComponent("block.${OverdriveThatMatters.MOD_ID}.${MNames.STORAGE_POWER_SUPPLIER}") const val POWER_PASSED_KEY = "powerPassed" } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt index 6cf739ced..a51524825 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.block.entity.tech import net.minecraft.core.BlockPos -import net.minecraft.network.chat.Component import net.minecraft.server.level.ServerPlayer import net.minecraft.world.MenuProvider import net.minecraft.world.entity.player.Inventory @@ -21,7 +20,6 @@ import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.menu.tech.AndroidStationMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities -import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.core.util.WriteOnce @@ -33,10 +31,7 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return AndroidStationMenu(containerID, inventory, this) } - override val defaultDisplayName: Component - get() = MBlocks.ANDROID_STATION.name - - override val energy = object : WorkerEnergyStorage(this@AndroidStationBlockEntity::setChangedLight, + val energy = object : WorkerEnergyStorage(this@AndroidStationBlockEntity::setChangedLight, AndroidStationBlockEntity.Companion::CAPACITY, AndroidStationBlockEntity.Companion::MAX_IO, { null }) { override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { @@ -63,11 +58,16 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } - private var tickedOnve = false + init { + exposeEnergyGlobally(energy) + savetable(::energy, ENERGY_KEY) + } + + private var tickedOnce = false fun tick() { - if (!tickedOnve) { - tickedOnve = true + if (!tickedOnce) { + tickedOnce = true if (energy.batteryLevel.isPositive && blockState.getValue(WorkerState.SEMI_WORKER_STATE) != WorkerState.WORKING) { level?.setBlock(blockPos, blockState.setValue(WorkerState.SEMI_WORKER_STATE, WorkerState.WORKING), Block.UPDATE_CLIENTS) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index a92b3eb3a..57c3ff7b2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -25,6 +25,7 @@ import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainerHooks import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.BESubscribeList @@ -48,8 +49,7 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte synchronizer.bool(false, name = "battery$it") } - override val droppableContainer: Container - get() = container + override val droppableContainer by ::container private val itemHandler = container.handler( object : MatteryContainerHooks { override fun canInsert(slot: Int, stack: ItemStack): Boolean { @@ -62,6 +62,11 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte } ) + init { + exposeItemsGlobally(itemHandler) + savetable(::container, INVENTORY_KEY) + } + private data class BatteryBankDistribution(val distribution: Array, val maxThroughput: Decimal) private inner class BatteryBankEnergy(override val energyFlow: FlowDirection) : IMatteryEnergyStorage { @@ -190,62 +195,18 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte private val energyExtractor = BatteryBankEnergy(FlowDirection.OUTPUT) private val energy = BatteryBankEnergy(FlowDirection.BI_DIRECTIONAL) - private var resolverEnergyReceiver = LazyOptional.of { energyReceiver } - private var resolverEnergyExtractor = LazyOptional.of { energyExtractor } - private var resolverEnergy = LazyOptional.of { energy } - - private var mekanismResolverEnergyReceiver = if (isMekanismLoaded) LazyOptional.of { Mattery2MekanismEnergyWrapper(energyReceiver) } else LazyOptional.empty() - private var mekanismResolverEnergyExtractor = if (isMekanismLoaded) LazyOptional.of { Mattery2MekanismEnergyWrapper(energyExtractor) } else LazyOptional.empty() - private var mekanismResolverEnergy = if (isMekanismLoaded) LazyOptional.of { Mattery2MekanismEnergyWrapper(energy) } else LazyOptional.empty() - - private var resolverItemHandler = LazyOptional.of { itemHandler } - - private var valid = true - - override fun saveAdditional(nbt: CompoundTag) { - super.saveAdditional(nbt) - nbt[INVENTORY_KEY] = container.serializeNBT() - } - - override fun load(nbt: CompoundTag) { - container.deserializeNBT(nbt[INVENTORY_KEY]) - super.load(nbt) - } - - override val defaultDisplayName: Component - get() = MACHINE_NAME - override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { return BatteryBankMenu(containerID, inventory, this) } - override fun invalidateCaps() { - super.invalidateCaps() - valid = false - resolverEnergyReceiver.invalidate() - resolverEnergyExtractor.invalidate() - resolverEnergy.invalidate() - resolverItemHandler.invalidate() + init { + exposeEnergySideless(energy) + exposeEnergy(RelativeSide.FRONT, energyExtractor) - if (isMekanismLoaded) { - mekanismResolverEnergyReceiver.invalidate() - mekanismResolverEnergyExtractor.invalidate() - mekanismResolverEnergy.invalidate() - } - } - - override fun reviveCaps() { - super.reviveCaps() - valid = true - resolverEnergyReceiver = LazyOptional.of { energyReceiver } - resolverEnergyExtractor = LazyOptional.of { energyExtractor } - resolverEnergy = LazyOptional.of { energy } - resolverItemHandler = LazyOptional.of { itemHandler } - - if (isMekanismLoaded) { - mekanismResolverEnergyReceiver = LazyOptional.of { Mattery2MekanismEnergyWrapper(energyReceiver) } - mekanismResolverEnergyExtractor = LazyOptional.of { Mattery2MekanismEnergyWrapper(energyExtractor) } - mekanismResolverEnergy = LazyOptional.of { Mattery2MekanismEnergyWrapper(energy) } + for (side in RelativeSide.values()) { + if (side != RelativeSide.FRONT) { + exposeEnergy(side, energyReceiver) + } } } @@ -254,34 +215,6 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte checkSurroundings() } - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - if (valid) { - if (cap == MatteryCapability.ENERGY || cap == ForgeCapabilities.ENERGY) { - if (side == null) return resolverEnergy.cast() - - if (side == blockState.facingOne) - return resolverEnergyExtractor.cast() - else - return resolverEnergyReceiver.cast() - } - - if (cap == MatteryCapability.MEKANISM_ENERGY) { - if (side == null) return mekanismResolverEnergy.cast() - - if (side == blockState.facingOne) - return mekanismResolverEnergyExtractor.cast() - else - return mekanismResolverEnergyReceiver.cast() - } - - if (cap == ForgeCapabilities.ITEM_HANDLER) { - return resolverItemHandler.cast() - } - } - - return super.getCapability(cap,side) - } - private val consumers = object : BESubscribeList(this@BatteryBankBlockEntity, ForgeCapabilities.ENERGY) { override fun test(t: Direction): Boolean { return blockState.facingOne == t @@ -317,8 +250,6 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte } companion object { - private val MACHINE_NAME = TranslatableComponent("block.overdrive_that_matters.battery_bank") const val CAPACITY = 6 * 2 - private val LOGGER = LogManager.getLogger() } } 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 e78090317..01807af67 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 @@ -23,6 +23,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.GeneratorEnergyStorage +import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainerHooks import ru.dbotthepony.mc.otm.core.* @@ -39,19 +40,45 @@ import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.BESubscribeList class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.CHEMICAL_GENERATOR, pos, state), IDroppableContainer { - override val defaultDisplayName: Component - get() = MACHINE_NAME - override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { return ChemicalGeneratorMenu(containerID, inventory, this) } private var valid = true val container = MatteryContainer(this::setChangedLight, SLOTS) - override val droppableContainer: Container - get() = container + override val droppableContainer by ::container val energy = GeneratorEnergyStorage(this::setChangedLight, CAPACITY, THROUGHPUT) + val itemHandler = container.handler(object : MatteryContainerHooks { + override fun canInsert(slot: Int, stack: ItemStack): Boolean { + if (slot == SLOT_INPUT) + return ForgeHooks.getBurnTime(stack, null) > 0 + + if (slot == SLOT_RESIDUE) + return false + + return stack.getCapability(ForgeCapabilities.ENERGY).isPresent + } + + override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { + if (slot == SLOT_RESIDUE) return true + + return slot == SLOT_BATTERY && + (!stack.getCapability(ForgeCapabilities.ENERGY).isPresent || stack.getCapability(ForgeCapabilities.ENERGY).resolve().get().receiveEnergy(Int.MAX_VALUE, true) <= 0) + } + }) + + init { + savetable(::energy, ENERGY_KEY) + exposeGlobally(ForgeCapabilities.ITEM_HANDLER, itemHandler) + exposeGlobally(ForgeCapabilities.ENERGY, energy) + exposeGlobally(MatteryCapability.ENERGY, energy) + + if (isMekanismLoaded) { + exposeGlobally(MatteryCapability.MEKANISM_ENERGY, Mattery2MekanismEnergyWrapper(energy)) + } + } + private val consumers = BESubscribeList(this, ForgeCapabilities.ENERGY) fun checkSurroundings() = consumers.update() @@ -61,16 +88,6 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe checkFuelSlot = true } - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - if (valid && (cap == MatteryCapability.ENERGY || cap == ForgeCapabilities.ENERGY) && side !== blockState.facingOne) - return energy.resolver.cast() - - if (valid && cap == ForgeCapabilities.ITEM_HANDLER) - return itemHandler.get().cast() - - return super.getCapability(cap, side) - } - override fun invalidateCaps() { super.invalidateCaps() itemHandler.invalidate() @@ -108,25 +125,6 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe workTicksTotal = nbt.getInt(WORK_TICKS_TOTAL_KEY) } - val itemHandler = container.handler(object : MatteryContainerHooks { - override fun canInsert(slot: Int, stack: ItemStack): Boolean { - if (slot == SLOT_INPUT) - return ForgeHooks.getBurnTime(stack, null) > 0 - - if (slot == SLOT_RESIDUE) - return false - - return stack.getCapability(ForgeCapabilities.ENERGY).isPresent - } - - override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { - if (slot == SLOT_RESIDUE) return true - - return slot == SLOT_BATTERY && - (!stack.getCapability(ForgeCapabilities.ENERGY).isPresent || stack.getCapability(ForgeCapabilities.ENERGY).resolve().get().receiveEnergy(Int.MAX_VALUE, true) <= 0) - } - }) - override fun setBlockState(p_155251_: BlockState) { super.setBlockState(p_155251_) @@ -212,7 +210,6 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe private val THROUGHPUT get() = _THROUGHPUT.get() private val GENERATION_SPEED get() = _GENERATION_SPEED.get() private val CAPACITY get() = _CAPACITY.get() - private val MACHINE_NAME = TranslatableComponent("block.overdrive_that_matters.chemical_generator") private var _THROUGHPUT: DecimalConfigValue by WriteOnce() private var _GENERATION_SPEED: DecimalConfigValue by WriteOnce() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt index 56947d59a..b6fcbafc8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt @@ -21,16 +21,16 @@ class CobblerBlockEntity(blockPos: BlockPos, blockState: BlockState) return CobblerMenu(containerID, inventory, this) } - override val energy = null override val droppableContainer = MatteryContainer(this::itemContainerUpdated, CONTAINER_SIZE) - val handler = StaticCap(ForgeCapabilities.ITEM_HANDLER, INVENTORY_KEY, droppableContainer.handler(object : MatteryContainerHooks { + val handler = droppableContainer.handler(object : MatteryContainerHooks { override fun canInsert(slot: Int, stack: ItemStack): Boolean { return false } - })) + }) init { + exposeItemsGlobally(handler) savetable(::droppableContainer, INVENTORY_KEY) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt index e31e5aa5c..9919aebeb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt @@ -345,7 +345,7 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat outputCapability.update((-blockState.getValue(EnergyCounterBlock.INPUT_DIRECTION))::equals) } - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { + override fun getCapability(cap: Capability, side: Direction?): LazyOptional { if (side == null || isRemoved) return super.getCapability(cap, side) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt index 17403b223..80f3be069 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt @@ -95,49 +95,16 @@ class EnergyServoBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte get() = container[SLOT_CHARGE].energy?.maxEnergyStoredMattery ?: container[SLOT_DISCHARGE].energy?.maxEnergyStoredMattery ?: Decimal.ZERO } - private var resolverEnergy = LazyOptional.of { energy } - private var valid = true - - override fun invalidateCaps() { - super.invalidateCaps() - valid = false - resolverEnergy.invalidate() - itemHandler.invalidate() - } - - override fun reviveCaps() { - super.reviveCaps() - valid = true - resolverEnergy = LazyOptional.of { energy } - itemHandler.revive() + init { + exposeEnergyGlobally(energy) + exposeItemsGlobally(itemHandler) + savetable(::container, INVENTORY_KEY) } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { return EnergyServoMenu(containerID, inventory, this) } - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - if (valid) { - when (cap) { - MatteryCapability.ENERGY, ForgeCapabilities.ENERGY -> return resolverEnergy.cast() - ForgeCapabilities.ITEM_HANDLER -> return itemHandler.get().cast() - } - } - - return super.getCapability(cap, side) - } - - override fun saveAdditional(nbt: CompoundTag) { - super.saveAdditional(nbt) - - nbt[INVENTORY_KEY] = container.serializeNBT() - } - - override fun load(nbt: CompoundTag) { - super.load(nbt) - nbt.map(INVENTORY_KEY, container::deserializeNBT) - } - fun tick() { if (redstoneControl.isBlockedByRedstone) return 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 dea715cfd..370753f29 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 @@ -38,7 +38,7 @@ class PlatePressBlockEntity( p_155230_: BlockState ) : MatteryWorkerBlockEntity(MBlockEntities.PLATE_PRESS, p_155229_, p_155230_, ::ItemJob), IDroppableContainer { val container = MatteryContainer(this::setChangedLight, 2) - override val energy = WorkerEnergyStorage(this::setChangedLight, MachinesConfig.PLATE_PRESS) + val energy = WorkerEnergyStorage(this::setChangedLight, MachinesConfig.PLATE_PRESS) var experience = 0.0 @@ -51,8 +51,7 @@ class PlatePressBlockEntity( } } - override val droppableContainer: Container - get() = container + override val droppableContainer by ::container val itemHandler = container.handler(object : MatteryContainerHooks { override fun canInsert(slot: Int, stack: ItemStack): Boolean { return slot != SLOT_OUTPUT @@ -63,38 +62,12 @@ class PlatePressBlockEntity( } }) - override fun invalidateCaps() { - super.invalidateCaps() - itemHandler.invalidate() + init { + savetable(::energy, ENERGY_KEY) + savetable(::container, INVENTORY_KEY) + savetableDouble(::experience) } - override fun reviveCaps() { - super.reviveCaps() - itemHandler.revive() - } - - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - if (cap == ForgeCapabilities.ITEM_HANDLER) - return itemHandler.get().cast() - - return super.getCapability(cap, side) - } - - override fun saveAdditional(nbt: CompoundTag) { - super.saveAdditional(nbt) - nbt[INVENTORY_KEY] = container.serializeNBT() - nbt["experience"] = experience - } - - override fun load(nbt: CompoundTag) { - super.load(nbt) - nbt.map(INVENTORY_KEY, container::deserializeNBT) - experience = nbt.getDouble("experience") - } - - override val defaultDisplayName: Component - get() = MACHINE_NAME - override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { return PlatePressMenu(containerID, inventory, this) } @@ -122,7 +95,6 @@ class PlatePressBlockEntity( companion object { private val BASELINE_CONSUMPTION = Decimal(15) - private val MACHINE_NAME = TranslatableComponent("block.overdrive_that_matters.plate_press") const val SLOT_INPUT = 0 const val SLOT_OUTPUT = 1 } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt index 2a62149c4..fc2a84286 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.block.matter import net.minecraft.core.BlockPos -import net.minecraft.core.Direction import net.minecraft.world.Containers import net.minecraft.world.item.context.BlockPlaceContext import net.minecraft.world.level.BlockGetter @@ -18,7 +17,6 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.matter.PatternStorageBlockEntity import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get -import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.shapes.BlockShapes class PatternStorageBlock : RotatableMatteryBlock(), EntityBlock { @@ -51,7 +49,7 @@ class PatternStorageBlock : RotatableMatteryBlock(), EntityBlock { val blockentity = level.getBlockEntity(blockPos) if (blockentity is PatternStorageBlockEntity) { - Containers.dropContents(level, blockPos, blockentity.patternContainer) + Containers.dropContents(level, blockPos, blockentity.container) level.updateNeighbourForOutputSignal(blockPos, this) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt index 11ca15287..49063638d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt @@ -134,7 +134,7 @@ val ICapabilityProvider.energy: IEnergyStorage? get() { } /** - * Shortcut for getting [IMatteryEnergyStorage], including wrappers for it + * Shortcut for getting sideless [IMatteryEnergyStorage], including wrappers for it */ val ICapabilityProvider.matteryEnergy: IMatteryEnergyStorage? get() { val mattery = getCapability(MatteryCapability.ENERGY) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt index 627c997bf..9afcbe58d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt @@ -30,7 +30,7 @@ sealed class BlockEnergyStorageImpl( private val maxBatteryLevelProvider: () -> Decimal, private val maxInputProvider: () -> Decimal?, private val maxOutputProvider: () -> Decimal?, -) : IMatteryEnergyStorage, INBTSerializable, IEnergyStorageImpl { +) : IMatteryEnergyStorage, INBTSerializable, IEnergyStorageImpl { constructor( listener: () -> Unit, direction: FlowDirection, @@ -139,7 +139,8 @@ sealed class BlockEnergyStorageImpl( return tag } - override fun deserializeNBT(nbt: CompoundTag) { + override fun deserializeNBT(nbt: CompoundTag?) { + if (nbt == null) return batteryLevel = nbt.map(ENERGY_STORED_KEY, Decimal.Companion::deserializeNBT) ?: Decimal.ZERO maxBatteryLevelStorage = nbt.mapIf(ENERGY_STORED_MAX_KEY, Decimal.Companion::deserializeNBT) maxInputStorage = nbt.mapIf(MAX_INPUT_KEY, Decimal.Companion::deserializeNBT) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt index eaa9de819..ee47b32fe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt @@ -15,7 +15,7 @@ open class MatterStorageImpl @JvmOverloads constructor( protected val maxStoredMatterSupplier: () -> Decimal, protected val maxReceiveSupplier: () -> Decimal? = { null }, protected val maxExtractSupplier: () -> Decimal? = maxReceiveSupplier -) : IMatterStorage, INBTSerializable { +) : IMatterStorage, INBTSerializable { constructor( listener: Runnable?, direction: FlowDirection, @@ -123,7 +123,8 @@ open class MatterStorageImpl @JvmOverloads constructor( } } - override fun deserializeNBT(tag: CompoundTag) { + override fun deserializeNBT(tag: CompoundTag?) { + if (tag == null) return storedMatter = Decimal.deserializeNBT(tag["stored"]) //maxStoredMatter = ImpreciseFraction.deserializeNBT(tag["max_storage"]) //maxReceive = if (tag.contains("max_receive")) ImpreciseFraction.deserializeNBT(tag["max_receive"]) else null diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemFilter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemFilter.kt index 8d55e42ba..5e6e69ac2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemFilter.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemFilter.kt @@ -101,7 +101,7 @@ fun interface ItemFilterFullCallback { class ItemFilter( val size: Int, private val modified: ItemFilterFullCallback? = null -) : INBTSerializable { +) : INBTSerializable { constructor(size: Int, modified: ItemFilterCallback?) : this(size, modified?.let { 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 6a5fae9fe..a7eed1b49 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -251,6 +251,22 @@ inline fun MutableList>.forValidRefs(fn: (T) -> Unit) { } } +inline fun MutableList>.forValidRefsBreak(fn: (T) -> Boolean) { + val iterator = listIterator() + + for (value in iterator) { + val get = value.get() + + if (get == null) { + iterator.remove() + } else { + if (fn.invoke(get)) { + break + } + } + } +} + val ComponentContents.key: String get() = (this as? TranslatableContents ?: throw ClassCastException("$this is not a TranslatableContents")).key diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt index f8cfc8287..9ac648a32 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt @@ -6,6 +6,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import net.minecraft.world.SimpleContainer import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting +import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback abstract class MatteryPoweredMenu protected constructor( @@ -14,16 +15,14 @@ abstract class MatteryPoweredMenu protected constructor( inventory: Inventory, tile: MatteryPoweredBlockEntity? = null ) : MatteryMenu(menuType, containerID, inventory, tile) { - val powerWidget: LevelGaugeWidget + val powerWidget = LevelGaugeWidget(this, tile?.matteryEnergy) val batterySlot: BatterySlot val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java) init { if (tile == null) { - powerWidget = LevelGaugeWidget(this) batterySlot = BatterySlot(SimpleContainer(1), 0) } else { - powerWidget = LevelGaugeWidget(this, tile.energy) batterySlot = BatterySlot(tile.batteryContainer, 0) redstone.with(tile.redstoneControl::redstoneSetting) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt index 4257dd380..530349417 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt @@ -35,7 +35,7 @@ class PatternStorageMenu @JvmOverloads constructor( }) } - val patterns = tile?.patternContainer ?: SimpleContainer(2 * 4) + val patterns = tile?.container ?: SimpleContainer(2 * 4) storageSlots = ImmutableList(2 * 4) { PatternSlot(patterns, it) From 882d60ebc6fee108edc657be597cc1a7bf3de25b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 17 Feb 2023 07:57:16 +0700 Subject: [PATCH 0203/1199] Fix android config not being built fully --- .../ru/dbotthepony/mc/otm/config/AndroidConfig.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt index 693a1392b..3a6981e53 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt @@ -13,6 +13,10 @@ object AndroidConfig : AbstractConfig("androids") { object NanobotsRegeneration { + init { + builder.push("NanobotsRegeneration") + } + val COOLDOWN: List by builder .comment("In ticks, time between heal ticks") .comment("One heal tick restores 1 heart (2 health points) at most") @@ -30,6 +34,10 @@ object AndroidConfig : AbstractConfig("androids") { val ENERGY_PER_HITPOINT by builder .comment("Energy required to regenerate 1 health point (half a heart)") .defineDecimal("ENERGY_PER_HITPOINT", Decimal(800)) + + init { + builder.pop() + } } val ANDROID_ENERGY_PER_HUNGER_POINT by builder.defineDecimal("energyPerHunger", Decimal(2000), Decimal.ZERO) @@ -105,4 +113,11 @@ object AndroidConfig : AbstractConfig("androids") { } } + init { + NanobotsRegeneration + EnderTeleporter + JumpBoost + Magnet + Shockwave + } } From 49caf1c0b26162ed4a1a84609a8f448a226a7198 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 17 Feb 2023 13:24:56 +0700 Subject: [PATCH 0204/1199] Shrink cobblestone generator container size to 9 --- .../mc/otm/block/entity/tech/CobblerBlockEntity.kt | 2 +- .../dbotthepony/mc/otm/client/screen/tech/CobblerScreen.kt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt index b6fcbafc8..aaceb272d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt @@ -47,6 +47,6 @@ class CobblerBlockEntity(blockPos: BlockPos, blockState: BlockState) } companion object { - const val CONTAINER_SIZE = 16 + const val CONTAINER_SIZE = 9 } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/CobblerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/CobblerScreen.kt index 42b304b03..ae546eff5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/CobblerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/CobblerScreen.kt @@ -16,9 +16,9 @@ class CobblerScreen(menu: CobblerMenu, inventory: Inventory, title: Component) : ProgressGaugePanel(this, frame, menu.progress, 30f, 42f) - for (row in 0 .. 3) - for (column in 0 .. 3) - SlotPanel(this, frame, menu.storageSlots[row * 4 + column], 80f + column * AbstractSlotPanel.SIZE, 17f + row * AbstractSlotPanel.SIZE) + for (row in 0 .. 2) + for (column in 0 .. 2) + SlotPanel(this, frame, menu.storageSlots[row * 3 + column], 80f + column * AbstractSlotPanel.SIZE, 26f + row * AbstractSlotPanel.SIZE) makeDeviceControls(this, frame, redstone = menu.redstone) From d66b96c791867d22fdb7eef0df30f99a8203b891 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 17 Feb 2023 14:46:12 +0700 Subject: [PATCH 0205/1199] Make children panels override tickInner --- .../client/screen/matter/MatterPanelScreen.kt | 8 ++++---- .../otm/client/screen/panels/EditablePanel.kt | 11 +++++++--- .../client/screen/panels/EffectListPanel.kt | 8 ++++---- .../otm/client/screen/panels/Widget2Panel.kt | 4 ++-- .../client/screen/panels/button/Buttons.kt | 4 ++-- .../screen/panels/input/EditBoxPanel.kt | 4 ++-- .../panels/input/NetworkNumberInputPanel.kt | 4 ++-- .../panels/input/NetworkedStringInputPanel.kt | 4 ++-- .../screen/panels/input/TextInputPanel.kt | 4 ++-- .../screen/panels/slot/FoldableSlotPanel.kt | 8 ++++---- .../storage/StoragePowerSupplierScreen.kt | 8 ++++---- .../screen/tech/AndroidStationScreen.kt | 4 ++-- .../client/screen/tech/EnergyCounterScreen.kt | 20 +++++++++---------- .../screen/widget/ProgressGaugePanel.kt | 4 ++-- 14 files changed, 50 insertions(+), 45 deletions(-) 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 87585c6c3..75c0a72fe 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 @@ -142,8 +142,8 @@ class MatterPanelScreen( return menu.tasks.firstOrNull { it.id == task.id }?.let { it.stack((it.required + it.inProgress).coerceAtLeast(1)) } ?: task.stack((task.required + task.inProgress).coerceAtLeast(1)) } - override fun tick() { - super.tick() + override fun tickInner() { + super.tickInner() if (!menu.tasks.any { it.id == task.id }) { frame.remove() @@ -208,8 +208,8 @@ class MatterPanelScreen( } } - override fun tick() { - super.tick() + override fun tickInner() { + super.tickInner() if (!menu.patterns.any { it.id == pattern.id }) { frame.remove() 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 864394e24..b4c168828 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 @@ -1598,10 +1598,15 @@ open class EditablePanel @JvmOverloads constructor( return x >= pos.x && x <= pos.x + width && y >= pos.y && y + height <= pos.y } - protected var tick = 0 + var tickCount = 0 + private set - open fun tick() { - tick++ + protected open fun tickInner() {} + + fun tick() { + tickCount++ + + tickInner() for (child in Array(visibleChildrenInternal.size) { visibleChildrenInternal[it] }) { child.tick() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt index cc9b47ef5..5aec68c76 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt @@ -100,8 +100,8 @@ open class EffectListPanel @JvmOverloads constructor( return true } - override fun tick() { - super.tick() + override fun tickInner() { + super.tickInner() if (!isStillValid) { effectButtons.remove(effectType) @@ -163,14 +163,14 @@ open class EffectListPanel @JvmOverloads constructor( canvas.yOffset = newScroll * -26f } - override fun tick() { + override fun tickInner() { for (effect in entity.activeEffects) { effectButtons.computeIfAbsent(effect.effect, Object2ObjectFunction { EffectSquare(effect) }) } - super.tick() + super.tickInner() } val canvas = object : EditablePanel(screen, this@EffectListPanel, 0f, 0f, width, height) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Widget2Panel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Widget2Panel.kt index 6b5b6fd1e..c20095400 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Widget2Panel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Widget2Panel.kt @@ -26,8 +26,8 @@ abstract class Widget2Panel( val isWidgetDisabled: Boolean get() = disableTicks > 0 - override fun tick() { - super.tick() + override fun tickInner() { + super.tickInner() if (disableTicks > 0) { disableTicks-- 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 e5f01598c..c9ab1997f 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 @@ -41,8 +41,8 @@ fun > makeDeviceControls( redstone: IPlayerInputWithFeedback? = null ): EditablePanel { val panel = object : EditablePanel(screen, parent, width = LargeEnumRectangleButtonPanel.SIZE, height = 0f, x = parent.width + 3f) { - override fun tick() { - super.tick() + override fun tickInner() { + super.tickInner() x = parent.width + 3f y = 0f } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/EditBoxPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/EditBoxPanel.kt index 050256363..2bdebef73 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/EditBoxPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/EditBoxPanel.kt @@ -36,8 +36,8 @@ open class EditBoxPanel( new_widget.value = old_widget.value } - override fun tick() { - super.tick() + override fun tickInner() { + super.tickInner() widget?.tick() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkNumberInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkNumberInputPanel.kt index 4e9c1cbf6..b92c12a83 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkNumberInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkNumberInputPanel.kt @@ -55,8 +55,8 @@ open class NetworkNumberInputPanel @JvmOverloads constructor( return super.mouseClickedInner(x, y, button) } - override fun tick() { - super.tick() + override fun tickInner() { + super.tickInner() if (isFocused) { if (!isAvailable.asBoolean) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt index 799d6fd52..4026ccdaa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt @@ -34,8 +34,8 @@ open class NetworkedStringInputPanel( backend.accept(new) } - override fun tick() { - super.tick() + override fun tickInner() { + super.tickInner() if (milliTime >= lastChanges) { text = backend.value diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt index 2fd29f08e..f9c850265 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt @@ -182,8 +182,8 @@ open class TextInputPanel( private var snapshotTimer: Long? = null - override fun tick() { - super.tick() + override fun tickInner() { + super.tickInner() if (snapshotTimer != null && snapshotTimer!! <= milliTime) { pushbackSnapshot() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/FoldableSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/FoldableSlotPanel.kt index 7adfe743b..a74d550bb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/FoldableSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/FoldableSlotPanel.kt @@ -64,8 +64,8 @@ open class FoldableSlotPanel, out T : Slot> @JvmOverloa remove() } - override fun tick() { - super.tick() + override fun tickInner() { + super.tickInner() x = this@FoldableSlotPanel.absoluteX - dockPadding.left y = this@FoldableSlotPanel.absoluteY - dockPadding.top @@ -92,8 +92,8 @@ open class FoldableSlotPanel, out T : Slot> @JvmOverloa hoverPanel?.remove() } - override fun tick() { - super.tick() + override fun tickInner() { + super.tickInner() val hoveringSince = hoveringSince diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt index d50b6a97c..5eda45a80 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt @@ -42,8 +42,8 @@ class StoragePowerSupplierScreen(menu: StoragePowerSupplierMenu, inventory: Inve dock = Dock.TOP } - override fun tick() { - super.tick() + override fun tickInner() { + super.tickInner() text = TranslatableComponent( "otm.item.power.passed", @@ -57,8 +57,8 @@ class StoragePowerSupplierScreen(menu: StoragePowerSupplierMenu, inventory: Inve dock = Dock.TOP } - override fun tick() { - super.tick() + override fun tickInner() { + super.tickInner() text = TranslatableComponent( "otm.gui.power_supplier.active_nodes", 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 7e621b80b..1d3fbfa6e 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 @@ -551,8 +551,8 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I return super.mouseClickedInner(x, y, button) } - override fun tick() { - super.tick() + override fun tickInner() { + super.tickInner() if (isPreview && !layoutInvalidated) { if (firstTick) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt index e500f4ce8..ee5cb47e1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt @@ -17,8 +17,8 @@ class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title: val frame = super.makeMainFrame()!! var label: Label = object : Label(this@EnergyCounterScreen, frame) { - override fun tick() { - super.tick() + override fun tickInner() { + super.tickInner() text = TranslatableComponent( "otm.item.power.passed", menu.passed.formatPower(formatAsReadable = ShiftPressedCond) @@ -30,8 +30,8 @@ class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title: label.setDockMargin(4f, 0f, 0f, 0f) label = object : Label(this@EnergyCounterScreen, frame) { - override fun tick() { - super.tick() + override fun tickInner() { + super.tickInner() text = TranslatableComponent( "otm.item.power.average", menu.average.formatPower(formatAsReadable = ShiftPressedCond) @@ -43,8 +43,8 @@ class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title: label.setDockMargin(4f, 0f, 0f, 0f) label = object : Label(this@EnergyCounterScreen, frame) { - override fun tick() { - super.tick() + override fun tickInner() { + super.tickInner() text = TranslatableComponent( "otm.item.power.last_20_ticks", menu.last20Ticks.formatPower(formatAsReadable = ShiftPressedCond) @@ -56,8 +56,8 @@ class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title: label.setDockMargin(4f, 0f, 0f, 0f) label = object : Label(this@EnergyCounterScreen, frame) { - override fun tick() { - super.tick() + override fun tickInner() { + super.tickInner() text = TranslatableComponent( "otm.item.power.last_tick", menu.lastTick.formatPower(formatAsReadable = ShiftPressedCond) @@ -69,8 +69,8 @@ class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title: label.setDockMargin(4f, 0f, 0f, 0f) label = object : Label(this@EnergyCounterScreen, frame) { - override fun tick() { - super.tick() + override fun tickInner() { + super.tickInner() text = TranslatableComponent( "block.overdrive_that_matters.energy_counter.facing", diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt index bd54da6eb..530506aa3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt @@ -49,7 +49,7 @@ open class ProgressGaugePanel @JvmOverloads constructor( } override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - if (widget.isStuck() && tick % 40 <= 20) { + if (widget.isStuck() && tickCount % 40 <= 20) { RenderSystem.setShaderColor(0.75f, 0.4f, 0.4f, 1f) } @@ -63,7 +63,7 @@ open class ProgressGaugePanel @JvmOverloads constructor( GAUGE_FOREGROUND.renderPartial(stack, height = height, width = width) } - if (widget.isStuck() && tick % 40 <= 20) { + if (widget.isStuck() && tickCount % 40 <= 20) { RenderSystem.setShaderColor(1f, 1f, 1f, 1f) } } From e9b753667ae2ef47183daf86941b4e9ff14f7cbb Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 17 Feb 2023 14:58:10 +0700 Subject: [PATCH 0206/1199] Rename item handler impl, remove unused code --- .../decorative/CargoCrateBlockEntity.kt | 8 +- .../entity/matter/MatterBottlerBlockEntity.kt | 14 +- .../matter/MatterDecomposerBlockEntity.kt | 13 +- .../matter/MatterRecyclerBlockEntity.kt | 13 +- .../matter/MatterReplicatorBlockEntity.kt | 12 +- .../entity/matter/MatterScannerBlockEntity.kt | 13 +- .../entity/tech/BatteryBankBlockEntity.kt | 12 +- .../tech/ChemicalGeneratorBlockEntity.kt | 43 +----- .../block/entity/tech/CobblerBlockEntity.kt | 5 +- .../entity/tech/EnergyServoBlockEntity.kt | 12 +- .../entity/tech/PlatePressBlockEntity.kt | 17 +-- .../mc/otm/container/ContainerHandler.kt | 81 +++++++++++ .../mc/otm/container/HandlerFilter.kt | 38 +++++ .../mc/otm/container/MatteryContainer.kt | 18 +-- .../otm/container/MatteryContainerHandler.kt | 130 ------------------ 15 files changed, 155 insertions(+), 274 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHandler.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainerHandler.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt index 75eed3621..df2748903 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.block.entity.decorative import net.minecraft.advancements.CriteriaTriggers import net.minecraft.core.BlockPos -import net.minecraft.core.Direction import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.LongTag import net.minecraft.nbt.StringTag @@ -25,14 +24,11 @@ import net.minecraft.world.level.storage.loot.LootContext import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets import net.minecraft.world.level.storage.loot.parameters.LootContextParams import net.minecraft.world.phys.Vec3 -import net.minecraftforge.common.capabilities.Capability -import net.minecraftforge.common.capabilities.ForgeCapabilities -import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.container.MatteryContainer -import ru.dbotthepony.mc.otm.container.MatteryContainerHooks +import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set @@ -46,7 +42,7 @@ class CargoCrateBlockEntity( ) : MatteryDeviceBlockEntity(MBlockEntities.CARGO_CRATE, p_155229_, p_155230_), IDroppableContainer { val container = MatteryContainer(this::setChanged, CAPACITY) private var interactingPlayers = 0 - val handler = container.handler(object : MatteryContainerHooks { + val handler = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { return lootTable == null } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index f115b3692..0113e1a2a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -1,11 +1,7 @@ package ru.dbotthepony.mc.otm.block.entity.matter import net.minecraft.core.BlockPos -import net.minecraft.core.Direction -import net.minecraft.nbt.CompoundTag -import net.minecraft.network.chat.Component import net.minecraft.server.level.ServerLevel -import net.minecraft.world.Container import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu @@ -14,9 +10,6 @@ import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeConfigSpec -import net.minecraftforge.common.capabilities.Capability -import net.minecraftforge.common.capabilities.ForgeCapabilities -import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock @@ -29,21 +22,18 @@ import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl import ru.dbotthepony.mc.otm.container.MatteryContainer -import ru.dbotthepony.mc.otm.container.MatteryContainerHooks +import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph import ru.dbotthepony.mc.otm.menu.matter.MatterBottlerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.core.* -import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal -import ru.dbotthepony.mc.otm.core.nbt.map -import ru.dbotthepony.mc.otm.core.nbt.set class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.MATTER_BOTTLER, p_155229_, p_155230_), IMatterGraphNode, IDroppableContainer { @@ -99,7 +89,7 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : override val droppableContainer by ::container - val itemHandler = container.handler(object : MatteryContainerHooks { + val itemHandler = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { if (isBottling) { return slot < 3 && stack.getCapability(MatteryCapability.MATTER).isPresent diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index e46abbf57..a2a73b6e2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -1,11 +1,8 @@ package ru.dbotthepony.mc.otm.block.entity.matter import net.minecraft.core.BlockPos -import net.minecraft.core.Direction import net.minecraft.nbt.CompoundTag -import net.minecraft.network.chat.Component import net.minecraft.server.level.ServerLevel -import net.minecraft.world.Container import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu @@ -13,10 +10,6 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeConfigSpec -import net.minecraftforge.common.capabilities.Capability -import net.minecraftforge.common.capabilities.ForgeCapabilities -import net.minecraftforge.common.util.LazyOptional -import net.minecraftforge.items.IItemHandler import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity @@ -27,14 +20,13 @@ import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl import ru.dbotthepony.mc.otm.container.MatteryContainer -import ru.dbotthepony.mc.otm.container.MatteryContainerHooks +import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph import ru.dbotthepony.mc.otm.item.MatterDustItem import ru.dbotthepony.mc.otm.menu.matter.MatterDecomposerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities -import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.core.util.WriteOnce @@ -43,7 +35,6 @@ import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.core.math.getDecimal import ru.dbotthepony.mc.otm.core.math.set -import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.matter.MatterManager @@ -151,7 +142,7 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) val container = MatteryContainer(this::setChangedLight, 3) override val droppableContainer by ::container - val itemHandler = container.handler(object : MatteryContainerHooks { + val itemHandler = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { return slot == INPUT_SLOT && MatterManager.canDecompose(stack) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index d35c5f407..f9ae8769a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -1,11 +1,8 @@ package ru.dbotthepony.mc.otm.block.entity.matter import net.minecraft.core.BlockPos -import net.minecraft.core.Direction import net.minecraft.nbt.CompoundTag -import net.minecraft.network.chat.Component import net.minecraft.server.level.ServerLevel -import net.minecraft.world.Container import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu @@ -14,9 +11,6 @@ import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeConfigSpec import net.minecraftforge.common.ForgeConfigSpec.ConfigValue -import net.minecraftforge.common.capabilities.Capability -import net.minecraftforge.common.capabilities.ForgeCapabilities -import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity @@ -27,19 +21,16 @@ import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl import ru.dbotthepony.mc.otm.container.MatteryContainer -import ru.dbotthepony.mc.otm.container.MatteryContainerHooks +import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph import ru.dbotthepony.mc.otm.item.MatterDustItem -import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.menu.matter.MatterRecyclerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal -import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.core.math.getDecimal @@ -90,7 +81,7 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) return matter } - private val itemHandler = container.handler(object : MatteryContainerHooks { + private val itemHandler = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { return stack.item is MatterDustItem } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index 79c421027..ffc1434c5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -1,11 +1,8 @@ package ru.dbotthepony.mc.otm.block.entity.matter import net.minecraft.core.BlockPos -import net.minecraft.core.Direction import net.minecraft.nbt.CompoundTag -import net.minecraft.network.chat.Component import net.minecraft.server.level.ServerLevel -import net.minecraft.world.Container import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu @@ -13,9 +10,6 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeConfigSpec -import net.minecraftforge.common.capabilities.Capability -import net.minecraftforge.common.capabilities.ForgeCapabilities -import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity @@ -25,13 +19,13 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.* import ru.dbotthepony.mc.otm.container.MatteryContainer -import ru.dbotthepony.mc.otm.container.MatteryContainerHandler +import ru.dbotthepony.mc.otm.container.ContainerHandler +import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph import ru.dbotthepony.mc.otm.menu.matter.MatterReplicatorMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities -import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.core.math.Decimal @@ -109,7 +103,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : override val matterNode = Graph6Node(this) val matter = MatterStorageImpl(this::matterLevelUpdated, FlowDirection.INPUT, ::MATTER_CAPACITY) val container = MatteryContainer(this::itemContainerUpdated, 5) - val itemHandler = container.handler(MatteryContainerHandler.OnlyOut) + val itemHandler = container.handler(HandlerFilter.OnlyOut) override val droppableContainer by ::container init { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt index 60d86ebfb..2ee0658d3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt @@ -1,11 +1,7 @@ package ru.dbotthepony.mc.otm.block.entity.matter import net.minecraft.core.BlockPos -import net.minecraft.core.Direction -import net.minecraft.nbt.CompoundTag -import net.minecraft.network.chat.Component import net.minecraft.server.level.ServerLevel -import net.minecraft.world.Container import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu @@ -13,9 +9,6 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeConfigSpec -import net.minecraftforge.common.capabilities.Capability -import net.minecraftforge.common.capabilities.ForgeCapabilities -import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity @@ -25,17 +18,15 @@ import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.IPatternState import ru.dbotthepony.mc.otm.capability.matter.PatternState import ru.dbotthepony.mc.otm.container.MatteryContainer -import ru.dbotthepony.mc.otm.container.MatteryContainerHooks +import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal -import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph import ru.dbotthepony.mc.otm.menu.matter.MatterScannerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities -import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.matter.MatterManager @@ -47,7 +38,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val container = MatteryContainer(this::itemContainerUpdated, 1) val energy = WorkerEnergyStorage(this::powerLevelUpdated, ENERGY_VALUES) - val itemHandler = container.handler(object : MatteryContainerHooks { + val itemHandler = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { return MatterManager.canDecompose(stack) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index 57c3ff7b2..3a40b75aa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -2,32 +2,24 @@ package ru.dbotthepony.mc.otm.block.entity.tech import net.minecraft.core.BlockPos import net.minecraft.core.Direction -import net.minecraft.nbt.CompoundTag -import net.minecraft.network.chat.Component -import net.minecraft.world.Container import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState -import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities -import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.energy.IEnergyStorage -import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage -import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper import ru.dbotthepony.mc.otm.container.MatteryContainer -import ru.dbotthepony.mc.otm.container.MatteryContainerHooks +import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.core.math.facingOne -import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.BESubscribeList import ru.dbotthepony.mc.otm.menu.tech.BatteryBankMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -51,7 +43,7 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte override val droppableContainer by ::container private val itemHandler = container.handler( - object : MatteryContainerHooks { + object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { return stack.getCapability(ForgeCapabilities.ENERGY).isPresent } 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 01807af67..88343b292 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 @@ -1,10 +1,7 @@ package ru.dbotthepony.mc.otm.block.entity.tech import net.minecraft.core.BlockPos -import net.minecraft.core.Direction import net.minecraft.nbt.CompoundTag -import net.minecraft.network.chat.Component -import net.minecraft.world.Container import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu @@ -14,9 +11,7 @@ import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeConfigSpec import net.minecraftforge.common.ForgeHooks -import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities -import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.energy.IEnergyStorage import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity @@ -25,7 +20,7 @@ import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.GeneratorEnergyStorage import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper import ru.dbotthepony.mc.otm.container.MatteryContainer -import ru.dbotthepony.mc.otm.container.MatteryContainerHooks +import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.menu.tech.ChemicalGeneratorMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -34,7 +29,6 @@ import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal -import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.BESubscribeList @@ -44,12 +38,11 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe return ChemicalGeneratorMenu(containerID, inventory, this) } - private var valid = true val container = MatteryContainer(this::setChangedLight, SLOTS) override val droppableContainer by ::container val energy = GeneratorEnergyStorage(this::setChangedLight, CAPACITY, THROUGHPUT) - val itemHandler = container.handler(object : MatteryContainerHooks { + val itemHandler = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { if (slot == SLOT_INPUT) return ForgeHooks.getBurnTime(stack, null) > 0 @@ -70,13 +63,9 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe init { savetable(::energy, ENERGY_KEY) - exposeGlobally(ForgeCapabilities.ITEM_HANDLER, itemHandler) - exposeGlobally(ForgeCapabilities.ENERGY, energy) - exposeGlobally(MatteryCapability.ENERGY, energy) - - if (isMekanismLoaded) { - exposeGlobally(MatteryCapability.MEKANISM_ENERGY, Mattery2MekanismEnergyWrapper(energy)) - } + savetable(::container, INVENTORY_KEY) + exposeEnergyGlobally(energy) + exposeItemsGlobally(itemHandler) } private val consumers = BESubscribeList(this, ForgeCapabilities.ENERGY) @@ -88,20 +77,6 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe checkFuelSlot = true } - override fun invalidateCaps() { - super.invalidateCaps() - itemHandler.invalidate() - energy.invalidate() - valid = false - } - - override fun reviveCaps() { - super.reviveCaps() - itemHandler.revive() - energy.revive() - valid = true - } - override fun setLevel(p_155231_: Level) { super.setLevel(p_155231_) tickOnceServer(consumers::update) @@ -110,8 +85,6 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe override fun saveAdditional(nbt: CompoundTag) { super.saveAdditional(nbt) - nbt[ENERGY_KEY] = energy.serializeNBT() - nbt[INVENTORY_KEY] = container.serializeNBT() nbt[WORK_TICKS_KEY] = workTicks nbt[WORK_TICKS_TOTAL_KEY] = workTicksTotal } @@ -119,17 +92,13 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe override fun load(nbt: CompoundTag) { super.load(nbt) - nbt.map(ENERGY_KEY, energy::deserializeNBT) - container.deserializeNBT(nbt[INVENTORY_KEY]) workTicks = nbt.getInt(WORK_TICKS_KEY) workTicksTotal = nbt.getInt(WORK_TICKS_TOTAL_KEY) } override fun setBlockState(p_155251_: BlockState) { super.setBlockState(p_155251_) - - if (valid) - tickOnceServer(consumers::update) + tickOnceServer(consumers::update) } var workTicks = 0 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt index aaceb272d..52de77096 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt @@ -7,11 +7,10 @@ import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.level.block.state.BlockState -import net.minecraftforge.common.capabilities.ForgeCapabilities import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.container.MatteryContainer -import ru.dbotthepony.mc.otm.container.MatteryContainerHooks +import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.menu.tech.CobblerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -23,7 +22,7 @@ class CobblerBlockEntity(blockPos: BlockPos, blockState: BlockState) override val droppableContainer = MatteryContainer(this::itemContainerUpdated, CONTAINER_SIZE) - val handler = droppableContainer.handler(object : MatteryContainerHooks { + val handler = droppableContainer.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { return false } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt index 80f3be069..0656a01dc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt @@ -1,8 +1,6 @@ package ru.dbotthepony.mc.otm.block.entity.tech import net.minecraft.core.BlockPos -import net.minecraft.core.Direction -import net.minecraft.nbt.CompoundTag import net.minecraft.network.chat.Component import net.minecraft.world.Container import net.minecraft.world.entity.player.Inventory @@ -10,14 +8,10 @@ import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.level.block.state.BlockState -import net.minecraftforge.common.capabilities.Capability -import net.minecraftforge.common.capabilities.ForgeCapabilities -import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage -import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.canSetBatteryMattery import ru.dbotthepony.mc.otm.capability.energy import ru.dbotthepony.mc.otm.capability.energyStoredMattery @@ -25,10 +19,8 @@ import ru.dbotthepony.mc.otm.capability.extractEnergy import ru.dbotthepony.mc.otm.capability.maxEnergyStoredMattery import ru.dbotthepony.mc.otm.capability.receiveEnergy import ru.dbotthepony.mc.otm.container.MatteryContainer -import ru.dbotthepony.mc.otm.container.MatteryContainerHooks +import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.nbt.map -import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.menu.tech.EnergyServoMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlocks @@ -42,7 +34,7 @@ class EnergyServoBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte override val droppableContainer: Container get() = container - val itemHandler = container.handler(object : MatteryContainerHooks { + val itemHandler = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { return when (slot) { SLOT_DISCHARGE -> stack.isEmpty || stack.energy?.let { it.extractEnergy(Int.MAX_VALUE, true) > 0 } ?: false 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 370753f29..05d7939ea 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 @@ -1,37 +1,24 @@ package ru.dbotthepony.mc.otm.block.entity.tech import net.minecraft.core.BlockPos -import net.minecraft.core.Direction -import net.minecraft.nbt.CompoundTag -import net.minecraft.network.chat.Component import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerPlayer -import net.minecraft.world.Container import net.minecraft.world.entity.ExperienceOrb import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.level.block.state.BlockState -import net.minecraftforge.common.capabilities.Capability -import net.minecraftforge.common.capabilities.ForgeCapabilities -import net.minecraftforge.common.util.LazyOptional -import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity -import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.MatteryContainer -import ru.dbotthepony.mc.otm.container.MatteryContainerHooks +import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MRecipes -import ru.dbotthepony.mc.otm.core.nbt.map -import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.once -import ru.dbotthepony.mc.otm.onceServer class PlatePressBlockEntity( p_155229_: BlockPos, @@ -52,7 +39,7 @@ class PlatePressBlockEntity( } override val droppableContainer by ::container - val itemHandler = container.handler(object : MatteryContainerHooks { + val itemHandler = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { return slot != SLOT_OUTPUT } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHandler.kt new file mode 100644 index 000000000..cbba0cd31 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHandler.kt @@ -0,0 +1,81 @@ +package ru.dbotthepony.mc.otm.container + +import net.minecraft.world.item.ItemStack +import net.minecraftforge.common.util.LazyOptional +import net.minecraftforge.items.IItemHandler + +class ContainerHandler @JvmOverloads internal constructor( + private val container: MatteryContainer, + private val filter: HandlerFilter = HandlerFilter.Both, +) : IItemHandler { + override fun getSlots() = container.containerSize + override fun getStackInSlot(slot: Int) = container[slot] + + override fun insertItem(slot: Int, stack: ItemStack, simulate: Boolean): ItemStack { + if (!filter.canInsert(slot, stack)) + return stack + + filter.preInsert(slot, stack, simulate) + val localStack = container[slot] + + if (localStack.isEmpty) { + if (!simulate) { + val copy = stack.copy() + container.setChanged(slot, copy, ItemStack.EMPTY) + container.setItem(slot, copy) + } + + return ItemStack.EMPTY + } else if (localStack.isStackable && localStack.maxStackSize > localStack.count && ItemStack.isSameItemSameTags(localStack, stack)) { + val newCount = localStack.maxStackSize.coerceAtMost(localStack.count + stack.count) + val diff = newCount - localStack.count + + if (diff != 0) { + if (!simulate) { + val old = localStack.copy() + localStack.grow(diff) + container.setChanged(slot, localStack, old) + } + + val copy = stack.copy() + copy.shrink(diff) + return copy + } + } + + return stack + } + + override fun extractItem(slot: Int, amount: Int, simulate: Boolean): ItemStack { + if (amount == 0) + return ItemStack.EMPTY + + require(amount >= 0) { "Can not extract negative amount of items" } + + filter.preExtract(slot, amount, simulate) + + val localStack = container.getItem(slot) + if (localStack.isEmpty) return ItemStack.EMPTY + if (!filter.canExtract(slot, amount, localStack)) return ItemStack.EMPTY + + val minimal = amount.coerceAtMost(localStack.count) + val copy = localStack.copy() + copy.count = minimal + + if (!simulate) { + val old = localStack.copy() + localStack.shrink(minimal) + container.setChanged(slot, localStack, old) + } + + return copy + } + + override fun getSlotLimit(slot: Int): Int { + return container.maxStackSize + } + + override fun isItemValid(slot: Int, stack: ItemStack): Boolean { + return filter.canInsert(slot, stack) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt new file mode 100644 index 000000000..a0843131a --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt @@ -0,0 +1,38 @@ +package ru.dbotthepony.mc.otm.container + +import net.minecraft.world.item.ItemStack + +interface HandlerFilter { + fun canInsert(slot: Int, stack: ItemStack): Boolean { + return true + } + + fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { + return true + } + + fun preInsert(slot: Int, stack: ItemStack, simulate: Boolean) {} + fun preExtract(slot: Int, amount: Int, simulate: Boolean) {} + + object OnlyIn : HandlerFilter { + override fun canInsert(slot: Int, stack: ItemStack): Boolean { + return true + } + + override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { + return false + } + } + + object OnlyOut : HandlerFilter { + override fun canInsert(slot: Int, stack: ItemStack): Boolean { + return false + } + + override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { + return true + } + } + + object Both : HandlerFilter +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt index c91c77904..5ed8462ec 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt @@ -148,28 +148,28 @@ open class MatteryContainer(val watcher: Runnable, private val size: Int) : Cont fun handler( insert_validator: (slot: Int, stack: ItemStack) -> Boolean, extract_validator: (slot: Int, amount: Int, stack: ItemStack) -> Boolean - ): MatteryContainerHandler { - return MatteryContainerHandler(this, object : MatteryContainerHooks { + ): ContainerHandler { + return ContainerHandler(this, object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack) = insert_validator(slot, stack) override fun canExtract(slot: Int, amount: Int, stack: ItemStack) = extract_validator(slot, amount, stack) }) } fun handler( - filter: MatteryContainerHooks - ): MatteryContainerHandler { - return MatteryContainerHandler(this, filter) + filter: HandlerFilter + ): ContainerHandler { + return ContainerHandler(this, filter) } - fun handler(insert_validator: (Int, ItemStack) -> Boolean): MatteryContainerHandler { - return MatteryContainerHandler(this, object : MatteryContainerHooks { + fun handler(insert_validator: (Int, ItemStack) -> Boolean): ContainerHandler { + return ContainerHandler(this, object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack) = insert_validator(slot, stack) override fun canExtract(slot: Int, amount: Int, stack: ItemStack) = false }) } - fun handler(): MatteryContainerHandler { - return MatteryContainerHandler(this) + fun handler(): ContainerHandler { + return ContainerHandler(this) } open fun getMaxStackSize(slot: Int) = maxStackSize diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainerHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainerHandler.kt deleted file mode 100644 index f37e9a581..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainerHandler.kt +++ /dev/null @@ -1,130 +0,0 @@ -package ru.dbotthepony.mc.otm.container - -import net.minecraft.world.item.ItemStack -import net.minecraftforge.common.util.LazyOptional -import net.minecraftforge.items.IItemHandler - -interface MatteryContainerHooks { - fun canInsert(slot: Int, stack: ItemStack): Boolean { - return true - } - - fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { - return true - } - - fun preInsert(slot: Int, stack: ItemStack, simulate: Boolean) {} - fun preExtract(slot: Int, amount: Int, simulate: Boolean) {} -} - -class MatteryContainerHandler @JvmOverloads internal constructor( - private val container: MatteryContainer, - private val hooks: MatteryContainerHooks = Both, -) : IItemHandler { - object OnlyIn : MatteryContainerHooks { - override fun canInsert(slot: Int, stack: ItemStack): Boolean { - return true - } - - override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { - return false - } - } - - object OnlyOut : MatteryContainerHooks { - override fun canInsert(slot: Int, stack: ItemStack): Boolean { - return false - } - - override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { - return true - } - } - - object Both : MatteryContainerHooks - - private var handler = LazyOptional.of { this } - - fun get(): LazyOptional { - return handler - } - - fun invalidate() { - handler.invalidate() - } - - fun revive() { - handler = LazyOptional.of { this } - } - - override fun getSlots() = container.containerSize - override fun getStackInSlot(slot: Int) = container[slot] - - override fun insertItem(slot: Int, stack: ItemStack, simulate: Boolean): ItemStack { - if (!hooks.canInsert(slot, stack)) - return stack - - hooks.preInsert(slot, stack, simulate) - val localStack = container[slot] - - if (localStack.isEmpty) { - if (!simulate) { - val copy = stack.copy() - container.setChanged(slot, copy, ItemStack.EMPTY) - container.setItem(slot, copy) - } - - return ItemStack.EMPTY - } else if (localStack.isStackable && localStack.maxStackSize > localStack.count && ItemStack.isSameItemSameTags(localStack, stack)) { - val newCount = Math.min(localStack.maxStackSize, localStack.count + stack.count) - val diff = newCount - localStack.count - - if (diff != 0) { - if (!simulate) { - val copy = localStack.copy() - localStack.grow(diff) - container.setChanged(slot, localStack, copy) - } - - val copy = stack.copy() - copy.shrink(diff) - return copy - } - } - - return stack - } - - override fun extractItem(slot: Int, amount: Int, simulate: Boolean): ItemStack { - if (amount == 0) - return ItemStack.EMPTY - - require(amount >= 0) { "Can not extract negative amount of items" } - - hooks.preExtract(slot, amount, simulate) - - val localStack = container.getItem(slot) - if (localStack.isEmpty) return ItemStack.EMPTY - if (!hooks.canExtract(slot, amount, localStack)) return ItemStack.EMPTY - - val minimal = Math.min(amount, localStack.count) - val copy = localStack.copy() - copy.count = minimal - - if (!simulate) { - val copy = localStack.copy() - localStack.shrink(minimal) - container.setChanged(slot, localStack, copy) - } - - return copy - } - - override fun getSlotLimit(slot: Int): Int { - return container.maxStackSize - } - - override fun isItemValid(slot: Int, stack: ItemStack): Boolean { - return hooks.canInsert(slot, stack) - } -} From 0c06d6edb87bf2cbef6318feba59b4993477ef20 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Feb 2023 00:18:09 +0700 Subject: [PATCH 0207/1199] Move savetables logic to utility class --- .../mc/otm/block/entity/MatteryBlockEntity.kt | 91 +------ .../entity/matter/MatterBottlerBlockEntity.kt | 2 +- .../StoragePowerSupplierBlockEntity.kt | 2 +- .../entity/tech/PlatePressBlockEntity.kt | 2 +- .../mc/otm/core/util/Savetables.kt | 252 ++++++++++++++++++ 5 files changed, 260 insertions(+), 89 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt 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 a47e974c3..40bf618b5 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 @@ -48,6 +48,7 @@ import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.EnumValueCodec +import ru.dbotthepony.mc.otm.core.util.Savetables import ru.dbotthepony.mc.otm.network.BlockEntitySyncPacket import ru.dbotthepony.mc.otm.network.FieldSynchronizer import ru.dbotthepony.mc.otm.network.WorldNetworkChannel @@ -414,68 +415,10 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc side.revive() } - private data class Savetable0(val type: Class, val property: KProperty0, val name: String, val serialize: (V) -> T, val deserialize: (V, T) -> Unit) - private data class Savetable1(val type: Class, val property: KMutableProperty0, val name: String, val serialize: (V) -> T, val deserialize: (T) -> V) + protected val savetables = Savetables() - private val savetables0 = ArrayList>() - private val savetables1 = ArrayList>() - - /** - * Save and load object state - */ - protected fun savetable(type: Class, property: KProperty0, name: String = property.name, serialize: (V) -> T, deserialize: (V, T) -> Unit) { - check(!savetables0.any { it.name == name }) { "Already has save field with name $name" } - check(!savetables1.any { it.name == name }) { "Already has save field with name $name" } - savetables0.add(Savetable0(type, property, name, serialize, deserialize)) - } - - /** - * Save and load value - */ - protected fun savetable(type: Class, property: KMutableProperty0, name: String = property.name, serialize: (V) -> T, deserialize: (T) -> V) { - check(!savetables0.any { it.name == name }) { "Already has save field with name $name" } - check(!savetables1.any { it.name == name }) { "Already has save field with name $name" } - savetables1.add(Savetable1(type, property, name, serialize, deserialize)) - } - - /** - * Save and load object state - */ - protected fun > savetable(type: Class, property: KProperty0, name: String = property.name) { - savetable(type, property, name, { it.serializeNBT()!! }, { self, it -> self.deserializeNBT(it) }) - } - - /** - * Save and load object state - */ protected inline fun > savetable(property: KProperty0, name: String = property.name) { - savetable(T::class.java, property, name) - } - - /** - * Save and load object state - */ - protected inline fun savetable(property: KProperty0, name: String = property.name, noinline serialize: (V) -> T, noinline deserialize: (V, T) -> Unit) { - savetable(T::class.java, property, name, serialize, deserialize) - } - - /** - * Save and load value - */ - protected inline fun savetable(property: KMutableProperty0, name: String = property.name, noinline serialize: (V) -> T, noinline deserialize: (T) -> V) { - savetable(T::class.java, property, name, serialize, deserialize) - } - - protected fun savetableFloat(property: KMutableProperty0, name: String = property.name) { - savetable(FloatTag::class.java, property, name, { FloatTag.valueOf(it) }, { tag -> tag.asFloat }) - } - - protected fun savetableDouble(property: KMutableProperty0, name: String = property.name) { - savetable(DoubleTag::class.java, property, name, { DoubleTag.valueOf(it) }, { tag -> tag.asDouble }) - } - - protected fun savetableBoolean(property: KMutableProperty0, name: String = property.name) { - savetable(ByteTag::class.java, property, name, { if (it) ByteTag.ONE else ByteTag.ZERO }, { tag -> tag.asInt > 0 }) + savetables.Stateful(property, name, T::class.java) } override fun saveAdditional(nbt: CompoundTag) { @@ -491,13 +434,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } } - for (data in savetables0) { - nbt[data.name] = (data.serialize as (Any) -> Tag).invoke(data.property.get()) - } - - for (data in savetables1) { - nbt[data.name] = (data.serialize as (Any) -> Tag).invoke(data.property.get()) - } + savetables.serializeNBT(nbt) } override fun load(nbt: CompoundTag) { @@ -513,25 +450,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } } - for (data in savetables0) { - val value = nbt[data.name] - - if (value != null && data.type.isAssignableFrom(value.javaClass)) { - (data.deserialize as (Any, Tag) -> Unit).invoke(data.property.get(), value) - } else if (value != null) { - throw ClassCastException("Expected ${data.type.canonicalName}, got ${value.javaClass.canonicalName}") - } - } - - for (data in savetables1) { - val value = nbt[data.name] - - if (value != null && data.type.isAssignableFrom(value.javaClass)) { - (data.property as KMutableProperty0).set((data.deserialize as (Tag) -> Any).invoke(value)) - } else if (value != null) { - throw ClassCastException("Expected ${data.type.canonicalName}, got ${value.javaClass.canonicalName}") - } - } + savetables.deserializeNBT(nbt) } protected fun tickOnce(func: Runnable) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index 0113e1a2a..7c73c414a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -118,7 +118,7 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : exposeGlobally(MatteryCapability.MATTER_NODE, this) exposeItemsGlobally(itemHandler) - savetableBoolean(::isBottling) + savetables.bool(::isBottling) savetable(::energy, ENERGY_KEY) savetable(::matter, MATTER_STORAGE_KEY) savetable(::container, INVENTORY_KEY) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt index 21263331f..3e7f09dcd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt @@ -48,7 +48,7 @@ class StoragePowerSupplierBlockEntity(blockPos: BlockPos, blockState: BlockState private set init { - savetable(::powerPassed, POWER_PASSED_KEY, Decimal::serializeNBT, Decimal.Companion::deserializeNBT) + savetables.decimal(::powerPassed, POWER_PASSED_KEY) } override fun setLevel(p_155231_: Level) { 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 05d7939ea..551f1adc9 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 @@ -52,7 +52,7 @@ class PlatePressBlockEntity( init { savetable(::energy, ENERGY_KEY) savetable(::container, INVENTORY_KEY) - savetableDouble(::experience) + savetables.double(::experience) } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt new file mode 100644 index 000000000..ea41fab76 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt @@ -0,0 +1,252 @@ +package ru.dbotthepony.mc.otm.core.util + +import net.minecraft.nbt.ByteTag +import net.minecraft.nbt.CompoundTag +import net.minecraft.nbt.DoubleTag +import net.minecraft.nbt.FloatTag +import net.minecraft.nbt.IntTag +import net.minecraft.nbt.NumericTag +import net.minecraft.nbt.Tag +import net.minecraftforge.common.util.INBTSerializable +import ru.dbotthepony.mc.otm.core.GetterSetter +import ru.dbotthepony.mc.otm.core.asGetterSetter +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.nbt.set +import java.util.function.Supplier +import kotlin.reflect.KMutableProperty0 +import kotlin.reflect.KProperty0 + +/** + * Utility class to manage list of composited properties in other classes to be (de)serialized in NBT tags + */ +class Savetables : INBTSerializable { + private val entries = ArrayList>() + + interface Entry : INBTSerializable { + val name: String + val type: Class + fun validate() + } + + inline fun , reified T : Tag> stateful(getter: Supplier, name: String): Stateful { + return Stateful(getter, name, T::class.java) + .withSerializer { it.serializeNBT() } + .withDeserializer { v, t -> v.deserializeNBT(t) } + } + + inline fun , reified T : Tag> stateful(getter: KProperty0, name: String = getter.name): Stateful { + return Stateful(getter, name, T::class.java) + .withSerializer { it.serializeNBT() } + .withDeserializer { v, t -> v.deserializeNBT(t) } + } + + fun decimal(prop: GetterSetter, name: String, default: Decimal = Decimal.ZERO): Stateless { + return Stateless(prop, name, Tag::class.java) + .withDeserializer { Decimal.deserializeNBT(it) } + .withSerializer { it.serializeNBT() } + .withDefault { default } + } + + fun decimalNullable(prop: GetterSetter, name: String, default: Decimal = Decimal.ZERO): Stateless { + return Stateless(prop, name, Tag::class.java) + .withDeserializer { Decimal.deserializeNBT(it) } + .withSerializer { it?.serializeNBT() } + .withDefault { default } + } + + fun decimal(prop: KMutableProperty0, name: String = prop.name, default: Decimal = Decimal.ZERO): Stateless { + return Stateless(prop, name, Tag::class.java) + .withDeserializer { Decimal.deserializeNBT(it) } + .withSerializer { it.serializeNBT() } + .withDefault { default } + } + + fun decimalNullable(prop: KMutableProperty0, name: String = prop.name, default: Decimal = Decimal.ZERO): Stateless { + return Stateless(prop, name, Tag::class.java) + .withDeserializer { Decimal.deserializeNBT(it) } + .withSerializer { it?.serializeNBT() } + .withDefault { default } + } + + fun float(prop: GetterSetter, name: String): Stateless { + return Stateless(prop, name, NumericTag::class.java) + .withSerializer { FloatTag.valueOf(it) } + .withDeserializer { it.asFloat } + } + + fun float(prop: KMutableProperty0, name: String = prop.name): Stateless { + return Stateless(prop, name, NumericTag::class.java) + .withSerializer { FloatTag.valueOf(it) } + .withDeserializer { it.asFloat } + } + + fun double(prop: GetterSetter, name: String): Stateless { + return Stateless(prop, name, NumericTag::class.java) + .withSerializer { DoubleTag.valueOf(it) } + .withDeserializer { it.asDouble } + } + + fun double(prop: KMutableProperty0, name: String = prop.name): Stateless { + return Stateless(prop, name, NumericTag::class.java) + .withSerializer { DoubleTag.valueOf(it) } + .withDeserializer { it.asDouble } + } + + fun int(prop: GetterSetter, name: String): Stateless { + return Stateless(prop, name, NumericTag::class.java) + .withSerializer { IntTag.valueOf(it) } + .withDeserializer { it.asInt } + } + + fun int(prop: KMutableProperty0, name: String = prop.name): Stateless { + return Stateless(prop, name, NumericTag::class.java) + .withSerializer { IntTag.valueOf(it) } + .withDeserializer { it.asInt } + } + + fun bool(prop: GetterSetter, name: String): Stateless { + return Stateless(prop, name, NumericTag::class.java) + .withSerializer { ByteTag.valueOf(it) } + .withDeserializer { it.asByte > 0 } + } + + fun bool(prop: KMutableProperty0, name: String = prop.name): Stateless { + return Stateless(prop, name, NumericTag::class.java) + .withSerializer { ByteTag.valueOf(it) } + .withDeserializer { it.asByte > 0 } + } + + override fun serializeNBT(): CompoundTag { + return CompoundTag().also(::serializeNBT) + } + + private var validated = false + + fun validate() { + if (validated) return + + for (entry in entries) + entry.validate() + + validated = true + } + + override fun deserializeNBT(nbt: CompoundTag) { + validate() + + for (entry in entries) { + val value = nbt[entry.name] + + if (value != null && entry.type.isAssignableFrom(value.javaClass)) { + (entry as INBTSerializable).deserializeNBT(value) + } else { + entry.deserializeNBT(null) + } + } + } + + fun serializeNBT(nbt: CompoundTag) { + validate() + + for (entry in entries) { + val value = entry.serializeNBT() + + if (value != null) + nbt[entry.name] = value + } + } + + inner class Stateful(private val prop: Supplier, override val name: String, override val type: Class) : Entry { + constructor(field: KProperty0, name: String = field.name, type: Class) : this(field::get, name, type) + + init { + check(!entries.any { it.name == name }) { "Already has entry with name $name!" } + entries.add(this) + validated = false + } + + private var serializer: ((V) -> T?)? = null + private var deserializer: ((V, T) -> Unit)? = null + private var resetter: ((V) -> Unit)? = null + + fun withSerializer(serializer: (V) -> T?): Stateful { + this.serializer = serializer + return this + } + + fun withDeserializer(deserializer: (V, T) -> Unit): Stateful { + this.deserializer = deserializer + return this + } + + fun withResetter(resetter: (V) -> Unit): Stateful { + this.resetter = resetter + return this + } + + override fun serializeNBT(): T? { + return checkNotNull(serializer) { "No serializer specified for $name" }.invoke(prop.get()) + } + + override fun deserializeNBT(nbt: T?) { + if (nbt == null) { + resetter?.invoke(prop.get()) + } else { + checkNotNull(deserializer) { "No deserializer specified for $name" }.invoke(prop.get(), nbt) + } + } + + override fun validate() { + checkNotNull(serializer) { "No serializer specified for $name" } + checkNotNull(deserializer) { "No deserializer specified for $name" } + } + } + + inner class Stateless(private val prop: GetterSetter, override val name: String, override val type: Class) : Entry { + constructor(field: KMutableProperty0, name: String = field.name, type: Class) : this(field.asGetterSetter(), name, type) + + init { + check(!entries.any { it.name == name }) { "Already has entry with name $name!" } + entries.add(this) + validated = false + } + + private var serializer: ((V) -> T?)? = null + private var deserializer: ((T) -> V)? = null + private var default: (() -> V)? = null + + override fun validate() { + checkNotNull(serializer) { "No serializer specified for $name" } + checkNotNull(deserializer) { "No deserializer specified for $name" } + } + + fun withSerializer(serializer: (V) -> T?): Stateless { + this.serializer = serializer + return this + } + + fun withDeserializer(deserializer: (T) -> V): Stateless { + this.deserializer = deserializer + return this + } + + fun withDefault(default: () -> V): Stateless { + this.default = default + return this + } + + override fun serializeNBT(): T? { + return checkNotNull(serializer) { "No serializer specified for $name" }.invoke(prop.get()) + } + + override fun deserializeNBT(nbt: T?) { + if (nbt == null) { + if (default != null) { + prop.accept(default!!.invoke()) + } + } else { + prop.accept(checkNotNull(deserializer) { "No deserializer specified for $name" }.invoke(nbt)) + } + } + } +} From aab9e09e30667ac495eab359ecc971f4608ac7d1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Feb 2023 00:31:49 +0700 Subject: [PATCH 0208/1199] damn --- .../mc/otm/block/entity/MatteryBlockEntity.kt | 2 +- .../dbotthepony/mc/otm/core/util/Savetables.kt | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) 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 40bf618b5..1da14f61f 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 @@ -418,7 +418,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc protected val savetables = Savetables() protected inline fun > savetable(property: KProperty0, name: String = property.name) { - savetables.Stateful(property, name, T::class.java) + savetables.stateful(property, name, T::class.java) } override fun saveAdditional(nbt: CompoundTag) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt index ea41fab76..44c2ddc36 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt @@ -28,14 +28,22 @@ class Savetables : INBTSerializable { fun validate() } - inline fun , reified T : Tag> stateful(getter: Supplier, name: String): Stateful { - return Stateful(getter, name, T::class.java) + inline fun , reified T : Tag> stateful(getter: Supplier, name: String): Stateful { + return stateful(getter, name, T::class.java) + } + + inline fun , reified T : Tag> stateful(getter: KProperty0, name: String = getter.name): Stateful { + return stateful(getter, name, T::class.java) + } + + fun , T : Tag> stateful(getter: Supplier, name: String, type: Class): Stateful { + return Stateful(getter, name, type) .withSerializer { it.serializeNBT() } .withDeserializer { v, t -> v.deserializeNBT(t) } } - inline fun , reified T : Tag> stateful(getter: KProperty0, name: String = getter.name): Stateful { - return Stateful(getter, name, T::class.java) + fun , T : Tag> stateful(getter: KProperty0, name: String = getter.name, type: Class): Stateful { + return Stateful(getter, name, type) .withSerializer { it.serializeNBT() } .withDeserializer { v, t -> v.deserializeNBT(t) } } From d8648d7088377f07c428878d0be64f229f8c3322 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Feb 2023 09:59:09 +0700 Subject: [PATCH 0209/1199] Capability subscriptions embedded into MatteryBlockEntity.Side --- .../dbotthepony/mc/otm/block/MatteryBlock.kt | 7 + .../mc/otm/block/entity/MatteryBlockEntity.kt | 159 ++++++++- .../entity/blackhole/BlackHoleBlockEntity.kt | 4 +- .../entity/matter/MatterBottlerBlockEntity.kt | 6 +- .../matter/MatterCapacitorBankBlockEntity.kt | 15 +- .../matter/MatterDecomposerBlockEntity.kt | 6 +- .../entity/matter/MatterPanelBlockEntity.kt | 9 +- .../matter/MatterRecyclerBlockEntity.kt | 6 +- .../matter/MatterReplicatorBlockEntity.kt | 7 +- .../entity/matter/MatterScannerBlockEntity.kt | 6 +- .../matter/PatternStorageBlockEntity.kt | 14 +- .../entity/storage/DriveRackBlockEntity.kt | 15 +- .../entity/storage/ItemMonitorBlockEntity.kt | 11 +- .../entity/storage/StorageBusBlockEntity.kt | 11 +- .../block/entity/storage/StorageInterfaces.kt | 56 +--- .../StoragePowerSupplierBlockEntity.kt | 17 +- .../entity/tech/BatteryBankBlockEntity.kt | 35 +- .../tech/ChemicalGeneratorBlockEntity.kt | 39 +-- .../entity/tech/EnergyCounterBlockEntity.kt | 127 ++------ .../mc/otm/block/storage/StorageInterfaces.kt | 44 --- .../mc/otm/block/tech/BatteryBankBlock.kt | 13 - .../otm/block/tech/ChemicalGeneratorBlock.kt | 21 -- .../mc/otm/block/tech/EnergyCounterBlock.kt | 17 - .../dbotthepony/mc/otm/core/GetterSetter.kt | 8 + .../mc/otm/core/util/BESubscribeList.kt | 303 ------------------ 25 files changed, 262 insertions(+), 694 deletions(-) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/util/BESubscribeList.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt index 1c271cb0b..c86a94288 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt @@ -23,7 +23,9 @@ import net.minecraft.world.level.material.Material import net.minecraft.world.level.material.MaterialColor import net.minecraft.world.phys.BlockHitResult import net.minecraft.world.phys.shapes.VoxelShape +import ru.dbotthepony.mc.otm.SERVER_IS_LIVE import ru.dbotthepony.mc.otm.block.entity.IRedstoneControlled +import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.core.get @@ -97,6 +99,7 @@ abstract class MatteryBlock @JvmOverloads constructor( if (this is EntityBlock && level.isClientSide) return InteractionResult.SUCCESS + @Suppress("DEPRECATION") return super.use(blockState, level, blockPos, ply, hand, blockHitResult) } @@ -167,6 +170,7 @@ abstract class MatteryBlock @JvmOverloads constructor( neighbourPos: BlockPos, movedByPiston: Boolean ) { + @Suppress("DEPRECATION") super.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston) if (this is EntityBlock && !level.isClientSide) { @@ -174,6 +178,9 @@ abstract class MatteryBlock @JvmOverloads constructor( if (tile is IRedstoneControlled) tile.redstoneControl.redstoneSignal = level.getBestNeighborSignal(pos) + + if (tile is MatteryBlockEntity && SERVER_IS_LIVE) + tile.neighborChanged(neighbour, neighbourPos, movedByPiston) } } 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 1da14f61f..b29a1a17e 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 @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.block.entity import com.google.common.collect.ImmutableSet +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import it.unimi.dsi.fastutil.longs.Long2ObjectFunction import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap @@ -9,10 +10,8 @@ import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.core.BlockPos import net.minecraft.core.Direction import net.minecraft.core.SectionPos -import net.minecraft.nbt.ByteTag +import net.minecraft.core.Vec3i import net.minecraft.nbt.CompoundTag -import net.minecraft.nbt.DoubleTag -import net.minecraft.nbt.FloatTag import net.minecraft.nbt.StringTag import net.minecraft.nbt.Tag import net.minecraft.resources.ResourceLocation @@ -20,6 +19,7 @@ import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerPlayer import net.minecraft.world.level.ChunkPos import net.minecraft.world.level.Level +import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity @@ -41,25 +41,30 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.isMekanismLoaded import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper +import ru.dbotthepony.mc.otm.core.collect.SupplierList +import ru.dbotthepony.mc.otm.core.collect.WeakHashSet import ru.dbotthepony.mc.otm.core.forValidRefs import ru.dbotthepony.mc.otm.core.forValidRefsBreak import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.RelativeSide +import ru.dbotthepony.mc.otm.core.math.minus +import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.EnumValueCodec import ru.dbotthepony.mc.otm.core.util.Savetables import ru.dbotthepony.mc.otm.network.BlockEntitySyncPacket import ru.dbotthepony.mc.otm.network.FieldSynchronizer import ru.dbotthepony.mc.otm.network.WorldNetworkChannel +import ru.dbotthepony.mc.otm.once import ru.dbotthepony.mc.otm.oncePre import ru.dbotthepony.mc.otm.onceServer import java.lang.ref.WeakReference import java.util.Collections import java.util.EnumMap import java.util.WeakHashMap +import java.util.function.Supplier import kotlin.properties.ReadWriteProperty -import kotlin.reflect.KMutableProperty0 import kotlin.reflect.KProperty import kotlin.reflect.KProperty0 @@ -155,6 +160,11 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc exposeGlobally(ForgeCapabilities.ITEM_HANDLER, value) } + @Suppress("SuspiciousCallableReferenceInLambda") + protected fun trackGlobally(capability: Capability): List> { + return SupplierList(_sides.values.map { it.track(capability)::get }) + } + enum class SideMode(val filter: FlowDirection, val automation: FlowDirection) { DISABLED (FlowDirection.NONE, FlowDirection.NONE), NONE (FlowDirection.BI_DIRECTIONAL, FlowDirection.NONE), @@ -197,6 +207,81 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc private val caps = Reference2ObjectArrayMap, Cap<*>>() private val modeStates = Object2ObjectArrayMap() private val data = Object2ObjectArrayMap>() + private val subscriptions = Reference2ObjectArrayMap, SubRef<*>>() + private val knownLOs = WeakHashSet>() + + private inner class SubRef(var value: LazyOptional) : Supplier> { + override fun get(): LazyOptional { + return value + } + + fun unset() { + value = LazyOptional.empty() + } + } + + fun track(capability: Capability): Supplier> { + var subref = subscriptions[capability] as Supplier>? + + if (subref == null) { + subref = SubRef(LazyOptional.empty()) as SubRef + subscriptions[capability] = subref + level?.once { updateTracked(capability) } + } + + return subref + } + + fun updateTracked() { + for (key in subscriptions.keys) { + // Concurrent Modification safety: + // we do not add nor remove keys from map, we only update values + updateTracked(key) + } + } + + private fun updateTracked(capability: Capability<*>) { + if (isRemoved) return + val dir = blockRotation.side2Dir(side) + + val chunk = level + ?.chunkSource + ?.getChunkNow(SectionPos.blockToSectionCoord(blockPos.x), SectionPos.blockToSectionCoord(blockPos.z)) + + if (chunk == null) { + subscriptions[capability]!!.unset() + level?.once { updateTracked(capability) } + return + } + + val entity = chunk.getBlockEntity(blockPos + dir.normal) + + if (entity == null) { + subscriptions[capability]!!.unset() + return + } + + val new = entity.getCapability(capability, dir.opposite) + + if (!new.isPresent) { + subscriptions[capability]!!.unset() + return + } + + val subref = subscriptions[capability] as SubRef + + if (subref.value !== new) { + if (knownLOs.add(new)) { + val ref = WeakReference(this) + + new.addListener { + ref.get()?.updateTracked(capability) + } + } + + subref.value = new as LazyOptional + } + } val isEmpty get() = caps.isEmpty() && modeStates.isEmpty() @@ -453,6 +538,30 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc savetables.deserializeNBT(nbt) } + @Suppress("OVERRIDE_DEPRECATION") + override fun setBlockState(pBlockState: BlockState) { + val old = blockRotation + @Suppress("DEPRECATION") + super.setBlockState(pBlockState) + val new = blockRotation + + if (old != new) { + for (side in _sides.values) { + side.updateTracked() + side.invalidate() + } + } + + for (side in _sides.values) { + side.revive() + } + } + + fun neighborChanged(neighbour: Block, neighbourPos: BlockPos, movedByPiston: Boolean) { + val dir = vec2Dir[vecKey(neighbourPos - blockPos)] ?: return + _sides[blockRotation.dir2Side(dir)]!!.updateTracked() + } + protected fun tickOnce(func: Runnable) { level?.oncePre { if (!isRemoved) func.run() } } @@ -511,13 +620,31 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc synchronizer.defaultEndpoint.markUnused() } - override fun setLevel(p_155231_: Level) { - super.setLevel(p_155231_) + override fun setLevel(level: Level) { + val old = this.level + super.setLevel(level) unsubscribe() _subCache = null - if (!p_155231_.isClientSide) { + if (!level.isClientSide) { subscribe() + + if (old != null) { + for (side in _sides.values) { + side.updateTracked() + side.invalidate() + } + + for (side in _sides.values) { + side.revive() + } + } else { + level.once { + for (side in _sides.values) { + side.updateTracked() + } + } + } } } @@ -751,6 +878,24 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc private val playerMap = WeakHashMap>() private val tickingMap = WeakHashMap>>() + private val vec2Dir = Int2ObjectOpenHashMap() + + private fun vecKey(value: Vec3i): Int { + if (value.x !in -1 .. 1) return -1 + if (value.y !in -1 .. 1) return -1 + if (value.z !in -1 .. 1) return -1 + val x = if (value.x < 0) 2 else value.x + val y = if (value.y < 0) 2 else value.y + val z = if (value.z < 0) 2 else value.z + return x or (y shl 4) or (z shl 8) + } + + init { + for (dir in Direction.values()) { + vec2Dir[vecKey(dir.normal)] = dir + } + } + fun onLevelUnload(event: LevelEvent.Unload) { val level = event.level as? ServerLevel ?: return playerMap.remove(level) 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 eb7e64e18..9d1477b0e 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 @@ -85,8 +85,8 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery private var sleepTicks = 4 - override fun setLevel(p_155231_: Level) { - super.setLevel(p_155231_) + override fun setLevel(level: Level) { + super.setLevel(level) sleepTicks = 4 } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index 7c73c414a..036077d4f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -133,10 +133,10 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return matter } - override fun setLevel(p_155231_: Level) { - super.setLevel(p_155231_) + override fun setLevel(level: Level) { + super.setLevel(level) - if (p_155231_ is ServerLevel) + if (level is ServerLevel) MatterNetworkGraph.discoverFull(this, matterNode) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt index a195923ad..b21812692 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt @@ -1,20 +1,13 @@ package ru.dbotthepony.mc.otm.block.entity.matter import net.minecraft.core.BlockPos -import net.minecraft.core.Direction -import net.minecraft.nbt.CompoundTag -import net.minecraft.network.chat.Component import net.minecraft.server.level.ServerLevel -import net.minecraft.world.Container import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState -import net.minecraftforge.common.capabilities.Capability -import net.minecraftforge.common.util.LazyOptional -import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.BatteryBankBlockEntity @@ -30,8 +23,6 @@ import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph import ru.dbotthepony.mc.otm.menu.matter.MatterCapacitorBankMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities -import ru.dbotthepony.mc.otm.core.nbt.map -import ru.dbotthepony.mc.otm.core.nbt.set class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.MATTER_CAPACITOR_BANK, p_155229_, p_155230_), IMatterGraphNode, IMatterStorage, IDroppableContainer { var gaugeLevel by synchronizer.float() @@ -161,10 +152,10 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) matterNode.destroy(::MatterNetworkGraph) } - override fun setLevel(p_155231_: Level) { - super.setLevel(p_155231_) + override fun setLevel(level: Level) { + super.setLevel(level) - if (p_155231_ is ServerLevel) + if (level is ServerLevel) MatterNetworkGraph.discoverFull(this, matterNode) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index a2a73b6e2..3fd64d919 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -204,10 +204,10 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) matterNode.destroy(::MatterNetworkGraph) } - override fun setLevel(p_155231_: Level) { - super.setLevel(p_155231_) + override fun setLevel(level: Level) { + super.setLevel(level) - if (p_155231_ is ServerLevel) + if (level is ServerLevel) MatterNetworkGraph.discoverFull(this, matterNode) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt index 0c248d17c..86e34f8c2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt @@ -1,13 +1,11 @@ package ru.dbotthepony.mc.otm.block.entity.matter import net.minecraft.core.BlockPos -import net.minecraft.core.Direction import net.minecraft.world.level.block.state.BlockState import ru.dbotthepony.mc.otm.menu.matter.MatterPanelMenu import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu -import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.capability.MatteryCapability import java.util.HashMap import java.util.UUID @@ -17,7 +15,6 @@ import net.minecraft.nbt.Tag import net.minecraft.network.chat.Component import net.minecraft.server.level.ServerLevel import net.minecraft.world.level.Level -import net.minecraftforge.common.capabilities.Capability import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.matter.* @@ -54,10 +51,10 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : exposeGlobally(MatteryCapability.TASK, this) } - override fun setLevel(p_155231_: Level) { - super.setLevel(p_155231_) + override fun setLevel(level: Level) { + super.setLevel(level) - if (p_155231_ is ServerLevel) + if (level is ServerLevel) MatterNetworkGraph.discoverFull(this, matterNode) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index f9ae8769a..0426dee94 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -106,10 +106,10 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) matterNode.destroy(::MatterNetworkGraph) } - override fun setLevel(p_155231_: Level) { - super.setLevel(p_155231_) + override fun setLevel(level: Level) { + super.setLevel(level) - if (p_155231_ is ServerLevel) + if (level is ServerLevel) MatterNetworkGraph.discoverFull(this, matterNode) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index ffc1434c5..ecc75250f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -19,7 +19,6 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.* import ru.dbotthepony.mc.otm.container.MatteryContainer -import ru.dbotthepony.mc.otm.container.ContainerHandler import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode @@ -164,10 +163,10 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : matterNode.destroy(::MatterNetworkGraph) } - override fun setLevel(p_155231_: Level) { - super.setLevel(p_155231_) + override fun setLevel(level: Level) { + super.setLevel(level) - if (p_155231_ is ServerLevel) + if (level is ServerLevel) MatterNetworkGraph.discoverFull(this, matterNode) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt index 2ee0658d3..907d8d2e4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt @@ -169,10 +169,10 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return null to IdleReason.ITEM } - override fun setLevel(p_155231_: Level) { - super.setLevel(p_155231_) + override fun setLevel(level: Level) { + super.setLevel(level) - if (p_155231_ is ServerLevel) { + if (level is ServerLevel) { MatterNetworkGraph.discoverFull(this, matterNode) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt index 93c3ff577..0e372ba60 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt @@ -8,20 +8,14 @@ import ru.dbotthepony.mc.otm.container.MatteryContainer import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.block.matter.PatternStorageBlock -import net.minecraft.nbt.CompoundTag -import net.minecraftforge.common.util.LazyOptional import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import ru.dbotthepony.mc.otm.menu.matter.PatternStorageMenu import net.minecraft.MethodsReturnNonnullByDefault -import net.minecraft.core.Direction import net.minecraft.server.level.ServerLevel -import net.minecraft.world.Container import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block -import net.minecraftforge.common.capabilities.Capability -import net.minecraftforge.common.capabilities.ForgeCapabilities import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.matter.* @@ -29,9 +23,7 @@ import ru.dbotthepony.mc.otm.core.collect.iterator import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph -import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.registry.MBlockEntities -import ru.dbotthepony.mc.otm.core.nbt.set import java.util.ArrayList import java.util.stream.Stream @@ -90,10 +82,10 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : private val itemHandler = container.handler { slot: Int, stack: ItemStack -> stack.getCapability(MatteryCapability.PATTERN).isPresent } override val droppableContainer by ::container - override fun setLevel(p_155231_: Level) { - super.setLevel(p_155231_) + override fun setLevel(level: Level) { + super.setLevel(level) - if (p_155231_ is ServerLevel) + if (level is ServerLevel) MatterNetworkGraph.discoverFull(this, matterNode) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt index f56a58c2c..e36f1b0fc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt @@ -1,9 +1,6 @@ package ru.dbotthepony.mc.otm.block.entity.storage import net.minecraft.core.BlockPos -import net.minecraft.core.Direction -import net.minecraft.nbt.CompoundTag -import net.minecraft.network.chat.Component import net.minecraft.server.level.ServerLevel import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player @@ -11,9 +8,6 @@ import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState -import net.minecraftforge.common.capabilities.Capability -import net.minecraftforge.common.util.LazyOptional -import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode import ru.dbotthepony.mc.otm.capability.MatteryCapability @@ -21,11 +15,8 @@ import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.menu.storage.DriveRackMenu -import ru.dbotthepony.mc.otm.core.nbt.map -import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.graph.storage.StorageNetworkGraph import ru.dbotthepony.mc.otm.registry.MBlockEntities -import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.storage.* class DriveRackBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : @@ -59,10 +50,10 @@ class DriveRackBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : exposeGlobally(MatteryCapability.STORAGE_NODE, cell) } - override fun setLevel(p_155231_: Level) { - super.setLevel(p_155231_) + override fun setLevel(level: Level) { + super.setLevel(level) - if (p_155231_ is ServerLevel) + if (level is ServerLevel) StorageNetworkGraph.discoverFull(this, cell.storageNode) } 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 46df0363d..03a5be273 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 @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.block.entity.storage import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap import net.minecraft.core.BlockPos -import net.minecraft.core.Direction import net.minecraft.core.NonNullList import net.minecraft.nbt.CompoundTag import net.minecraft.network.FriendlyByteBuf @@ -20,12 +19,9 @@ import net.minecraft.world.item.crafting.RecipeType import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeHooks -import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.util.INBTSerializable -import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.network.NetworkEvent import org.apache.logging.log4j.LogManager -import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryCapability @@ -42,7 +38,6 @@ import ru.dbotthepony.mc.otm.container.set import ru.dbotthepony.mc.otm.core.nbt.getEnum import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.menu.storage.ItemMonitorMenu -import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.storage.* import java.math.BigInteger import java.util.* @@ -501,10 +496,10 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return ItemMonitorMenu(containerID, inventory, this) } - override fun setLevel(p_155231_: Level) { - super.setLevel(p_155231_) + override fun setLevel(level: Level) { + super.setLevel(level) - if (p_155231_ is ServerLevel) + if (level is ServerLevel) StorageNetworkGraph.discoverFull(this, cell.storageNode) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt index 12ed70922..de9319380 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt @@ -4,7 +4,6 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectAVLTreeMap import it.unimi.dsi.fastutil.ints.IntAVLTreeSet import net.minecraft.core.BlockPos import net.minecraft.core.Direction -import net.minecraft.nbt.CompoundTag import net.minecraft.network.chat.Component import net.minecraft.server.level.ServerLevel import net.minecraft.world.entity.player.Inventory @@ -14,7 +13,6 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState -import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.items.IItemHandler @@ -25,7 +23,6 @@ import ru.dbotthepony.mc.otm.block.entity.storage.AbstractStorageImportExport.Co import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.config.MachinesConfig -import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom @@ -34,8 +31,6 @@ import ru.dbotthepony.mc.otm.core.math.getCapability import ru.dbotthepony.mc.otm.core.math.isPositive import ru.dbotthepony.mc.otm.core.math.isZero import ru.dbotthepony.mc.otm.core.math.plus -import ru.dbotthepony.mc.otm.core.nbt.map -import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.GraphNodeListener import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode @@ -115,10 +110,10 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter savetable(::filter, FILTER_KEY) } - override fun setLevel(p_155231_: Level) { - super.setLevel(p_155231_) + override fun setLevel(level: Level) { + super.setLevel(level) - if (p_155231_ is ServerLevel) { + if (level is ServerLevel) { StorageNetworkGraph.discoverFull(this, cell.storageNode) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt index 20ca390ac..f4ac6cedc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.block.entity.storage import net.minecraft.core.BlockPos import net.minecraft.core.Direction -import net.minecraft.nbt.CompoundTag import net.minecraft.network.chat.Component import net.minecraft.server.level.ServerLevel import net.minecraft.world.entity.player.Inventory @@ -15,28 +14,22 @@ import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities -import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.items.IItemHandler -import ru.dbotthepony.mc.otm.* +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.SERVER_IS_LIVE import ru.dbotthepony.mc.otm.block.CableBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity -import ru.dbotthepony.mc.otm.capability.* +import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.config.MachinesConfig -import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.container.ItemFilter -import ru.dbotthepony.mc.otm.core.* -import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom +import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.RelativeSide -import ru.dbotthepony.mc.otm.core.math.rotationTwo import ru.dbotthepony.mc.otm.core.math.toIntSafe -import ru.dbotthepony.mc.otm.core.math.unaryMinus -import ru.dbotthepony.mc.otm.core.nbt.map -import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.core.util.BESubscribeList +import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.GraphNodeListener import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode @@ -45,11 +38,15 @@ import ru.dbotthepony.mc.otm.menu.storage.StorageExporterMenu import ru.dbotthepony.mc.otm.menu.storage.StorageImporterMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MNames -import ru.dbotthepony.mc.otm.storage.* +import ru.dbotthepony.mc.otm.storage.IStorageEventConsumer +import ru.dbotthepony.mc.otm.storage.IStorageProvider +import ru.dbotthepony.mc.otm.storage.ITEM_STORAGE +import ru.dbotthepony.mc.otm.storage.ItemStackWrapper +import ru.dbotthepony.mc.otm.storage.StorageStackType +import ru.dbotthepony.mc.otm.storage.addStack import java.math.BigInteger import java.util.* import java.util.stream.Stream -import kotlin.collections.HashSet abstract class AbstractStorageImportExport( blockType: BlockEntityType<*>, @@ -85,42 +82,23 @@ abstract class AbstractStorageImportExport( exposeAllSidesExcept(RelativeSide.FRONT, MatteryCapability.STORAGE_NODE, cell) } - override fun invalidateCaps() { - super.invalidateCaps() - target.invalidate() - } - - override fun reviveCaps() { - super.reviveCaps() - target.revive() - } - override fun setRemoved() { super.setRemoved() cell.destroy(level) } - override fun setLevel(p_155231_: Level) { - super.setLevel(p_155231_) + override fun setLevel(level: Level) { + super.setLevel(level) - if (p_155231_ is ServerLevel) { + if (level is ServerLevel) { StorageNetworkGraph.discoverFull(this, cell.storageNode) - tickOnceServer(this::checkSurroundings) } } protected abstract val targetCapability: Capability protected val target by lazy { - object : BESubscribeList(this@AbstractStorageImportExport, targetCapability) { - override fun test(t: Direction): Boolean { - return t == -this@AbstractStorageImportExport.blockState.getValue(BlockRotationFreedom.TWO.property).front - } - } - } - - fun checkSurroundings() { - target.update() + front.track(targetCapability) } abstract val filter: ItemFilter @@ -206,7 +184,7 @@ class StorageImporterBlockEntity(blockPos: BlockPos, blockState: BlockState) nextTick-- - val target = target.firstOrNull() + val target = target.get().orNull() if (nextTick <= 0 && target != null && enoughEnergy) { val graph = cell.storageGraph ?: return @@ -318,7 +296,7 @@ class StorageExporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : nextTick-- - val target = target.firstOrNull() + val target = target.get().orNull() if (nextTick <= 0 && target != null && enoughEnergy) { val graph = cell.storageGraph ?: return diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt index 3e7f09dcd..458e8a257 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt @@ -1,20 +1,12 @@ package ru.dbotthepony.mc.otm.block.entity.storage import net.minecraft.core.BlockPos -import net.minecraft.core.Direction -import net.minecraft.nbt.CompoundTag -import net.minecraft.network.chat.Component import net.minecraft.server.level.ServerLevel import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState -import net.minecraftforge.common.capabilities.Capability -import net.minecraftforge.common.util.LazyOptional -import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.config.ServerConfig -import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage @@ -25,9 +17,6 @@ import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode import ru.dbotthepony.mc.otm.graph.storage.StorageNetworkGraph import ru.dbotthepony.mc.otm.menu.storage.StoragePowerSupplierMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities -import ru.dbotthepony.mc.otm.registry.MNames -import ru.dbotthepony.mc.otm.core.math.getDecimal -import ru.dbotthepony.mc.otm.core.nbt.set class StoragePowerSupplierBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.STORAGE_POWER_SUPPLIER, blockPos, blockState) { override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { @@ -51,10 +40,10 @@ class StoragePowerSupplierBlockEntity(blockPos: BlockPos, blockState: BlockState savetables.decimal(::powerPassed, POWER_PASSED_KEY) } - override fun setLevel(p_155231_: Level) { - super.setLevel(p_155231_) + override fun setLevel(level: Level) { + super.setLevel(level) - if (p_155231_ is ServerLevel) { + if (level is ServerLevel) { StorageNetworkGraph.discoverFull(this, cell.storageNode) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index 3a40b75aa..24863d985 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -1,26 +1,28 @@ package ru.dbotthepony.mc.otm.block.entity.tech import net.minecraft.core.BlockPos -import net.minecraft.core.Direction import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack -import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.capabilities.ForgeCapabilities -import net.minecraftforge.energy.IEnergyStorage import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity -import ru.dbotthepony.mc.otm.capability.* +import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.capability.energy import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage -import ru.dbotthepony.mc.otm.container.MatteryContainer +import ru.dbotthepony.mc.otm.capability.energyStoredMattery +import ru.dbotthepony.mc.otm.capability.extractEnergy +import ru.dbotthepony.mc.otm.capability.maxEnergyStoredMattery +import ru.dbotthepony.mc.otm.capability.receiveEnergy import ru.dbotthepony.mc.otm.container.HandlerFilter -import ru.dbotthepony.mc.otm.core.* +import ru.dbotthepony.mc.otm.container.MatteryContainer +import ru.dbotthepony.mc.otm.core.ImmutableList +import ru.dbotthepony.mc.otm.core.getValue +import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.RelativeSide -import ru.dbotthepony.mc.otm.core.math.facingOne -import ru.dbotthepony.mc.otm.core.util.BESubscribeList import ru.dbotthepony.mc.otm.menu.tech.BatteryBankMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -202,28 +204,17 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte } } - override fun setLevel(p_155231_: Level) { - super.setLevel(p_155231_) - checkSurroundings() - } - - private val consumers = object : BESubscribeList(this@BatteryBankBlockEntity, ForgeCapabilities.ENERGY) { - override fun test(t: Direction): Boolean { - return blockState.facingOne == t - } - } - - fun checkSurroundings() = consumers.update(blockState.facingOne::equals) + private val consumers by front.track(ForgeCapabilities.ENERGY) fun tick() { if (redstoneControl.isBlockedByRedstone) return - for (it in consumers) { + consumers.ifPresentK { val (_, maxThroughput) = energy.getDistribution(false) if (maxThroughput.isZero) - continue + return@ifPresentK val diff = it.receiveEnergy(maxThroughput, true) 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 88343b292..8f131b122 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 @@ -1,12 +1,10 @@ package ru.dbotthepony.mc.otm.block.entity.tech import net.minecraft.core.BlockPos -import net.minecraft.nbt.CompoundTag import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack -import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeConfigSpec @@ -18,7 +16,6 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.GeneratorEnergyStorage -import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.core.* @@ -29,9 +26,6 @@ import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal -import ru.dbotthepony.mc.otm.core.nbt.map -import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.core.util.BESubscribeList class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.CHEMICAL_GENERATOR, pos, state), IDroppableContainer { override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { @@ -66,41 +60,18 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe savetable(::container, INVENTORY_KEY) exposeEnergyGlobally(energy) exposeItemsGlobally(itemHandler) + + savetables.int(::workTicks, WORK_TICKS_KEY) + savetables.int(::workTicksTotal, WORK_TICKS_TOTAL_KEY) } - private val consumers = BESubscribeList(this, ForgeCapabilities.ENERGY) - - fun checkSurroundings() = consumers.update() + private val consumers = trackGlobally(ForgeCapabilities.ENERGY) override fun setChangedLight() { super.setChangedLight() checkFuelSlot = true } - override fun setLevel(p_155231_: Level) { - super.setLevel(p_155231_) - tickOnceServer(consumers::update) - } - - override fun saveAdditional(nbt: CompoundTag) { - super.saveAdditional(nbt) - - nbt[WORK_TICKS_KEY] = workTicks - nbt[WORK_TICKS_TOTAL_KEY] = workTicksTotal - } - - override fun load(nbt: CompoundTag) { - super.load(nbt) - - workTicks = nbt.getInt(WORK_TICKS_KEY) - workTicksTotal = nbt.getInt(WORK_TICKS_TOTAL_KEY) - } - - override fun setBlockState(p_155251_: BlockState) { - super.setBlockState(p_155251_) - tickOnceServer(consumers::update) - } - var workTicks = 0 private set @@ -171,7 +142,7 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe } for (consumer in consumers) { - workWithPower(consumer) + consumer.ifPresentK(::workWithPower) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt index 9919aebeb..32c0b6782 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.block.entity.tech import net.minecraft.core.BlockPos -import net.minecraft.core.Direction import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.IntTag import net.minecraft.nbt.ListTag @@ -9,26 +8,21 @@ import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu -import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState -import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities -import net.minecraftforge.common.util.LazyOptional -import net.minecraftforge.energy.IEnergyStorage import ru.dbotthepony.mc.otm.block.tech.EnergyCounterBlock import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper import ru.dbotthepony.mc.otm.core.* +import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.getDecimal -import ru.dbotthepony.mc.otm.core.math.unaryMinus import ru.dbotthepony.mc.otm.core.nbt.getByteArrayList import ru.dbotthepony.mc.otm.core.nbt.ifHas import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.core.util.BESubscribeList import ru.dbotthepony.mc.otm.menu.tech.EnergyCounterMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import java.util.* @@ -36,6 +30,10 @@ import java.util.* class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.ENERGY_COUNTER, p_155229_, p_155230_) { var passed by synchronizer.fraction() + override val blockRotation: BlockRotation get() { + return BlockRotation.of(blockState[EnergyCounterBlock.INPUT_DIRECTION]) + } + private val history = Array(10 * 20) { Decimal.ZERO } internal var historyTick = 0 @@ -124,22 +122,8 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat private val energyInput = EnergyCounterCap(true) private val energyOutput = EnergyCounterCap(false) - private val inputCapability = object : BESubscribeList(this@EnergyCounterBlockEntity, ForgeCapabilities.ENERGY) { - override fun test(t: Direction): Boolean { - return t == blockState.getValue(EnergyCounterBlock.INPUT_DIRECTION) - } - } - - private val outputCapability = object : BESubscribeList(this@EnergyCounterBlockEntity, ForgeCapabilities.ENERGY) { - override fun test(t: Direction): Boolean { - return t == -blockState.getValue(EnergyCounterBlock.INPUT_DIRECTION) - } - } - - override fun setLevel(p_155231_: Level) { - super.setLevel(p_155231_) - tickOnceServer(this::checkSurroundings) - } + private val inputCapability by front.track(ForgeCapabilities.ENERGY) + private val outputCapability by back.track(ForgeCapabilities.ENERGY) private inner class EnergyCounterCap(isInput: Boolean) : IMatteryEnergyStorage { override val energyFlow = FlowDirection.input(isInput) @@ -148,7 +132,7 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat if (redstoneControl.isBlockedByRedstone) return Decimal.ZERO - val it = inputCapability.first + val it = inputCapability.orNull() if (it != null) { val diff: Decimal @@ -176,7 +160,7 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat if (redstoneControl.isBlockedByRedstone) return Decimal.ZERO - val it = outputCapability.first + val it = outputCapability.orNull() if (it != null) { val diff: Decimal @@ -206,7 +190,7 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat override var batteryLevel: Decimal get() { if (energyFlow.input) { - val it = outputCapability.first + val it = outputCapability.orNull() if (it != null) { if (it is IMatteryEnergyStorage) { @@ -216,7 +200,7 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat return Decimal(it.energyStored) } } else { - val it = inputCapability.first + val it = inputCapability.orNull() if (it != null) { if (it is IMatteryEnergyStorage) { @@ -236,7 +220,7 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat override val maxBatteryLevel: Decimal get() { if (energyFlow.input) { - val it = outputCapability.first + val it = outputCapability.orNull() if (it != null) { if (it is IMatteryEnergyStorage) { @@ -246,7 +230,7 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat return Decimal(it.maxEnergyStored) } } else { - val it = inputCapability.first + val it = inputCapability.orNull() if (it != null) { if (it is IMatteryEnergyStorage) { @@ -263,7 +247,7 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat override val missingPower: Decimal get() { if (energyFlow.input) { - val it = outputCapability.first + val it = outputCapability.orNull() if (it != null) { if (it is IMatteryEnergyStorage) { @@ -273,7 +257,7 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat return Decimal((it.maxEnergyStored - it.energyStored).coerceAtLeast(0)) } } else { - val it = inputCapability.first + val it = inputCapability.orNull() if (it != null) { if (it is IMatteryEnergyStorage) { @@ -288,86 +272,19 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat } } - private var resolverInput = LazyOptional.of { energyInput } - private var resolverOutput = LazyOptional.of { energyOutput } + init { + front.Cap(ForgeCapabilities.ENERGY, energyInput) + front.Cap(MatteryCapability.ENERGY, energyInput) - private var resolverInputMekanism = if (isMekanismLoaded) LazyOptional.of { Mattery2MekanismEnergyWrapper(energyInput) } else null - private var resolverOutputMekanism = if (isMekanismLoaded) LazyOptional.of { Mattery2MekanismEnergyWrapper(energyOutput) } else null - - private var valid = true - - override fun invalidateCaps() { - super.invalidateCaps() - valid = false - resolverInput.invalidate() - resolverInputMekanism?.invalidate() - resolverOutput.invalidate() - resolverOutputMekanism?.invalidate() - } - - override fun reviveCaps() { - super.reviveCaps() - valid = true - resolverInput = LazyOptional.of { energyInput } - resolverOutput = LazyOptional.of { energyOutput } + back.Cap(ForgeCapabilities.ENERGY, energyOutput) + back.Cap(MatteryCapability.ENERGY, energyOutput) if (isMekanismLoaded) { - resolverInputMekanism = LazyOptional.of { Mattery2MekanismEnergyWrapper(energyInput) } - resolverOutputMekanism = LazyOptional.of { Mattery2MekanismEnergyWrapper(energyOutput) } + front.Cap(MatteryCapability.MEKANISM_ENERGY, Mattery2MekanismEnergyWrapper(energyInput)) + back.Cap(MatteryCapability.MEKANISM_ENERGY, Mattery2MekanismEnergyWrapper(energyOutput)) } } - @Suppress("deprecation", "OVERRIDE_DEPRECATION") - override fun setBlockState(new: BlockState) { - val old = blockState - super.setBlockState(new) - - if (new !== old && new.getValue(EnergyCounterBlock.INPUT_DIRECTION) != old.getValue(EnergyCounterBlock.INPUT_DIRECTION)) { - resolverInput.invalidate() - resolverInputMekanism?.invalidate() - resolverOutput.invalidate() - resolverOutputMekanism?.invalidate() - - resolverInput = LazyOptional.of { energyInput } - resolverOutput = LazyOptional.of { energyOutput } - - if (isMekanismLoaded) { - resolverInputMekanism = LazyOptional.of { Mattery2MekanismEnergyWrapper(energyInput) } - resolverOutputMekanism = LazyOptional.of { Mattery2MekanismEnergyWrapper(energyOutput) } - } - - checkSurroundings() - } - } - - fun checkSurroundings() { - inputCapability.update((blockState.getValue(EnergyCounterBlock.INPUT_DIRECTION))::equals) - outputCapability.update((-blockState.getValue(EnergyCounterBlock.INPUT_DIRECTION))::equals) - } - - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - if (side == null || isRemoved) - return super.getCapability(cap, side) - - if (valid) { - if (side == blockState.getValue(EnergyCounterBlock.INPUT_DIRECTION)) { - if (cap == MatteryCapability.ENERGY || cap == ForgeCapabilities.ENERGY) { - return resolverInput.cast() - } else if (cap == MatteryCapability.MEKANISM_ENERGY) { - return resolverInputMekanism!!.cast() - } - } else if (side == blockState.getValue(EnergyCounterBlock.INPUT_DIRECTION).opposite) { - if (cap == MatteryCapability.ENERGY || cap == ForgeCapabilities.ENERGY) { - return resolverOutput.cast() - } else if (cap == MatteryCapability.MEKANISM_ENERGY) { - return resolverOutputMekanism!!.cast() - } - } - } - - return super.getCapability(cap, side) - } - fun tick() { lastTick = history[historyTick] historyTick = (historyTick + 1) % history.size diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt index b3c1bd366..6f7a3e0f2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt @@ -114,28 +114,6 @@ class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock { ): VoxelShape { return shapes[p_60555_]!! } - - @Suppress("OVERRIDE_DEPRECATION") - override fun neighborChanged( - state: BlockState, - level: Level, - pos: BlockPos, - neighbour: Block, - neighbourPos: BlockPos, - movedByPiston: Boolean - ) { - super.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston) - - if (!level.isClientSide) { - val tile = level.getBlockEntity(pos) - - if (tile is StorageImporterBlockEntity) { - level.oncePre { - tile.checkSurroundings() - } - } - } - } } class StorageExporterBlock : RotatableMatteryBlock(), EntityBlock { @@ -218,26 +196,4 @@ class StorageExporterBlock : RotatableMatteryBlock(), EntityBlock { ): VoxelShape { return shapes[p_60555_]!! } - - @Suppress("OVERRIDE_DEPRECATION") - override fun neighborChanged( - state: BlockState, - level: Level, - pos: BlockPos, - neighbour: Block, - neighbourPos: BlockPos, - movedByPiston: Boolean - ) { - super.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston) - - if (!level.isClientSide) { - val tile = level.getBlockEntity(pos) - - if (tile is StorageExporterBlockEntity) { - level.oncePre { - tile.checkSurroundings() - } - } - } - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt index f84edddf7..75a288228 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt @@ -58,17 +58,4 @@ class BatteryBankBlock : RotatableMatteryBlock(), EntityBlock { override fun faceToPlayer(context: BlockPlaceContext): Boolean { return false } - - override fun neighborChanged( - state: BlockState, - level: Level, - pos: BlockPos, - neighbour: Block, - neighbourPos: BlockPos, - movedByPiston: Boolean - ) { - super.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston) - val blockEntity = level.getBlockEntity(pos) as? BatteryBankBlockEntity ?: return - level.oncePre { blockEntity.checkSurroundings() } - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt index 4728e76e2..cc57e14d7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt @@ -75,27 +75,6 @@ class ChemicalGeneratorBlock : RotatableMatteryBlock(), EntityBlock { } } - override fun neighborChanged( - state: BlockState, - level: Level, - pos: BlockPos, - neighbour: Block, - neighbourPos: BlockPos, - movedByPiston: Boolean - ) { - super.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston) - - if (!level.isClientSide) { - val tile = level.getBlockEntity(pos) - - if (tile is ChemicalGeneratorBlockEntity) { - level.oncePre { - tile.checkSurroundings() - } - } - } - } - private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.CHEMICAL_GENERATOR.rotateFromNorth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyCounterBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyCounterBlock.kt index e393d52f5..b6c4a565a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyCounterBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyCounterBlock.kt @@ -63,23 +63,6 @@ class EnergyCounterBlock : MatteryBlock(), EntityBlock { p_49915_.add(INPUT_DIRECTION, IF_DIRECTION) } - override fun neighborChanged( - state: BlockState, - level: Level, - pos: BlockPos, - neighbour: Block, - neighbourPos: BlockPos, - movedByPiston: Boolean - ) { - super.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston) - - if (SERVER_IS_LIVE) { - level.once { - (level.getBlockEntity(pos) as? EnergyCounterBlockEntity)?.checkSurroundings() - } - } - } - private val SHAPES = HashMap() init { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt index db519b33e..b64cbd207 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt @@ -66,6 +66,14 @@ interface GetterSetter : Supplier, Consumer, ReadWriteProperty } } +operator fun Supplier.getValue(thisRef: Any?, property: KProperty<*>): T { + return get() +} + +operator fun Consumer.setValue(thisRef: Any?, property: KProperty<*>, value: T) { + accept(value) +} + fun KMutableProperty0.asGetterSetter(watch: ((old: V, new: V) -> Unit)? = null): GetterSetter { return GetterSetter.of(this).let { if (watch != null) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/BESubscribeList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/BESubscribeList.kt deleted file mode 100644 index 18d010c75..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/BESubscribeList.kt +++ /dev/null @@ -1,303 +0,0 @@ -package ru.dbotthepony.mc.otm.core.util - -import net.minecraft.core.Direction -import net.minecraft.core.SectionPos -import net.minecraft.server.level.ServerLevel -import net.minecraft.world.level.block.entity.BlockEntity -import net.minecraftforge.common.capabilities.Capability -import net.minecraftforge.common.util.LazyOptional -import ru.dbotthepony.mc.otm.SERVER_IS_LIVE -import ru.dbotthepony.mc.otm.core.collect.WeakHashSet -import ru.dbotthepony.mc.otm.core.math.plus -import ru.dbotthepony.mc.otm.core.math.unaryMinus -import ru.dbotthepony.mc.otm.core.orNull -import ru.dbotthepony.mc.otm.onceServer -import java.lang.ref.WeakReference -import java.util.EnumMap -import java.util.function.Predicate - -private inline val Direction.flag: Int get() = 1 shl (ordinal + 1) - -/** - * This class allows block entities to track [capability] per block side. - * - * Allowed sides are governed by [test] method, which is open for override. - * - * **IMPORTANT:** Once rules behind [test] are changed, you MUST call [validate] or [update] right away, or expect hard to debug bugs. - * If rule changes can't be tracked in practical way, then flip on [alwaysValidate], although it will come with performance - * penalty (this will cause [iterator] to invoke [validate] on each its invocation). - * - * Subclasses can also override [subscribe] and [unsubscribe] to more finely track changes in neighbours. - * - * **THIS CLASS IS COMPLETELY THREAD UNSAFE**, it is assumed you only ever invoke it on server thread, - * or, at very least, thread where [ServerLevel] resides. - */ -open class BESubscribeList( - val block: BlockEntity, - val capability: Capability, - val alwaysValidate: Boolean = false -) : Predicate, Iterable { - private val knownCaps = WeakHashSet>() - private val trackedCaps = EnumMap>>(Direction::class.java) - private var updateQueued = false - private var firstKey: Direction? = null - private var lastDirectionSet = 0 - private var isWaitingOnChunk = false - - /** - * First valid capability, this is faster than invoking [iterator] and getting first value from it. - */ - val first: T? get() { - return firstLO.orNull() - } - - /** - * First valid capability as [LazyOptional], this is faster than invoking [iterator] and getting first value from it. - * - * If required, calls [update] - */ - val firstLO: LazyOptional get() { - if (updateQueued) { - update() - } else if (alwaysValidate) { - validate() - } - - for (i in 0 .. 2) { - if (firstKey == null) { - return LazyOptional.empty() - } - - val get = trackedCaps[firstKey]?.get() - - if (get == null || !get.isPresent) { - update() - continue - } - - return get - } - - return LazyOptional.empty() - } - - var valid = true - set(value) { - if (value != field) { - field = value - - if (value) { - update() - } - } - } - - fun invalidate() { - valid = false - } - - fun revive() { - valid = true - } - - // override - protected open fun subscribe(direction: Direction, capability: LazyOptional) {} - // override - protected open fun unsubscribe(direction: Direction, capability: LazyOptional?) {} - - override fun test(t: Direction): Boolean { - return true - } - - final override fun iterator(): Iterator { - if (updateQueued) { - update() - } else if (alwaysValidate) { - validate() - } - - return object : Iterator { - val iterator = trackedCaps.iterator() - var value: T? = null - - private fun find() { - while (iterator.hasNext() && value == null) { - val (k, v) = iterator.next() - value = v.get()?.orNull() - - if (value == null) { - iterator.remove() - unsubscribe(k, null) - } else if (!test(k)) { - iterator.remove() - unsubscribe(k, null) - updateQueued = true - } - } - } - - override fun hasNext(): Boolean { - find() - return value != null - } - - override fun next(): T { - find() - val value = value - this.value = null - return value ?: throw NoSuchElementException() - } - } - } - - fun update(direction: Direction) { - return update(direction::equals) - } - - private fun calculateDirectionSet(): Int { - var set = 0 - - for (value in VALUES) - if (test(value)) - set = set or value.flag - - return set - } - - /** - * Checks for one of these conditions to be true: - * * If [test] was determined to be changed during last time [iterator] was invoked AND tracked capability was filtered out due to [test] returning false - * * Performs a fast bitflag intersection test, by calling [test] on all directions and seeking difference between built set and previous set checked during last [update] - * * Tracked capabilities are checked for validity (if references are still valid) - * - * Once *any* of conditions above end up true, [update] is called and nothing else down the list is checked further. - */ - fun validate() { - check(valid) { "Subscription list is marked as invalid" } - - if (updateQueued) { - update() - return - } - - val new = calculateDirectionSet() - - if (new != lastDirectionSet) { - val intersect = new and lastDirectionSet - val removed = lastDirectionSet and (intersect.inv()) - val added = new and (intersect.inv()) - - for (dir in VALUES) { - if (dir.flag and removed != 0) { - val value1 = trackedCaps.remove(dir) - val value = value1?.get() - - if (value1 != null) { - unsubscribe(dir, value) - } - } - } - - if (added != 0) { - update { it.flag and added != 0 } - } - - lastDirectionSet = new - return - } - - val iterator = trackedCaps.iterator() - var any = 0 - - for ((k, v) in iterator) { - if (v.get() == null) { - unsubscribe(k, null) - any = any or k.flag - } - } - - if (any != 0) { - update { it.flag and any != 0 } - } - } - - /** - * Updates subscription list, searching for new capabilities and "removing" outdated ones. - * - * [predicate] narrows sides-to-check list, not replaces the set generated by this class' [test] - */ - @JvmOverloads - fun update(predicate: Predicate? = null) { - if (!valid || block.isRemoved) - return - - val level = block.level as? ServerLevel ?: return // don't run on client - val sorse = level.chunkSource - var waitChunkLoad = false - - var stream = Direction.stream() - - if (predicate != null) { - stream = stream.filter(predicate) - } else { - updateQueued = false - lastDirectionSet = calculateDirectionSet() - } - - stream = stream.filter(this) - firstKey = null - - for (dir in stream) { - val pos = block.blockPos + dir - val getChunk = sorse.getChunkNow(SectionPos.blockToSectionCoord(pos.x), SectionPos.blockToSectionCoord(pos.z)) - - if (getChunk == null) { - waitChunkLoad = true - } else { - val cap = getChunk.getBlockEntity(pos)?.getCapability(capability, -dir) - val knownCap = trackedCaps[dir]?.get() - - if (cap != null && cap.isPresent) { - if (knownCap !== cap) { - if (knownCaps.add(cap)) { - val ref = WeakReference(this) - - cap.addListener { - val self = ref.get() - - if (self != null) { - val current = self.trackedCaps[dir] - - if (current?.get() === it) { - self.update() - } - } - } - } - - trackedCaps[dir] = WeakReference(cap) - subscribe(dir, cap) - } - - if (firstKey == null) { - firstKey = dir - } - } else { - trackedCaps.remove(dir) - unsubscribe(dir, knownCap) - } - } - } - - if (waitChunkLoad && SERVER_IS_LIVE) { - onceServer { if (isWaitingOnChunk) update() } - isWaitingOnChunk = true - } else if (predicate == null) { - isWaitingOnChunk = false - } - } - - companion object { - private val VALUES = Direction.values() - } -} From 5f5af4ed0642a5d67074f9a8740d9be1d39e7f56 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Feb 2023 10:23:05 +0700 Subject: [PATCH 0210/1199] get rid of rigid ModeState dependency --- .../mc/otm/block/entity/MatteryBlockEntity.kt | 29 ++++++------------- 1 file changed, 9 insertions(+), 20 deletions(-) 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 b29a1a17e..ec3dc18d8 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 @@ -205,7 +205,6 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } private val caps = Reference2ObjectArrayMap, Cap<*>>() - private val modeStates = Object2ObjectArrayMap() private val data = Object2ObjectArrayMap>() private val subscriptions = Reference2ObjectArrayMap, SubRef<*>>() private val knownLOs = WeakHashSet>() @@ -283,17 +282,14 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } } - val isEmpty get() = caps.isEmpty() && modeStates.isEmpty() + val isEmpty get() = caps.isEmpty() && data.isEmpty() operator fun get(capability: Capability): Cap? { return caps[capability] as Cap? } - operator fun get(index: String): ModeState? { - return modeStates[index] - } - fun addData(index: ResourceLocation, data: INBTSerializable<*>) { + require(!this.data.containsKey(index)) { "Already has data with ID $index on $side!" } this.data[index] = data as INBTSerializable } @@ -313,32 +309,25 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc override fun serializeNBT(): CompoundTag { return CompoundTag().also { - val modelist = CompoundTag() - - for (cap in modeStates.values) { - modelist[cap.name] = cap.serializeNBT() + for ((k, v) in data) { + it[k.toString()] = v.serializeNBT() } - - it["Modes"] = modelist } } override fun deserializeNBT(nbt: CompoundTag) { - if (nbt.contains("Modes")) { - val caplist = nbt.getCompound("Modes") + for ((k, v) in data) { + val tag = nbt[k.toString()] - for (state in modeStates.values) { - if (state.name in caplist) { - state.deserializeNBT(caplist.getString(state.name)) - } + if (tag != null) { + v.deserializeNBT(tag) } } } inner class ModeState(val name: String, val possibleValues: ImmutableSet = SideMode.BI_SET) : INBTSerializable { init { - check(!modeStates.containsKey(name)) { "Already has config with name $name on side $side" } - modeStates[name] = this + addData(ResourceLocation(name), this) } val side get() = this@Side.side From 993790fbb5770ba97e8f8504e943cd00819581f0 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Feb 2023 22:29:48 +0700 Subject: [PATCH 0211/1199] Enable Jade and configured again --- build.gradle.kts | 4 ++-- gradle.properties | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index f96881ddf..1179aeca3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -190,8 +190,8 @@ dependencies { compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge-api:${jei_version}")) runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}")) - // runtimeOnly(fg.deobf("curse.maven:jade-324717:${jade_id}")) - // runtimeOnly(fg.deobf("curse.maven:configured-457570:${configured_id}")) + runtimeOnly(fg.deobf("curse.maven:jade-324717:${jade_id}")) + runtimeOnly(fg.deobf("curse.maven:configured-457570:${configured_id}")) // runtimeOnly(fg.deobf("curse.maven:worldedit-225608:${worldedit_fileid}")) // runtimeOnly(fg.deobf("at.ridgo8.moreoverlays:MoreOverlays-updated:${more_overlays_version}")) diff --git a/gradle.properties b/gradle.properties index f237a0a31..c42c45b38 100644 --- a/gradle.properties +++ b/gradle.properties @@ -28,8 +28,8 @@ jupiter_version=5.8.2 mekanism_version=10.3.5.homebaked curios_version=5.1.1.0 cosmetic_armor_reworked_version=v1 -jade_id=4010505 -configured_id=4011355 +jade_id=4330163 +configured_id=4166861 worldedit_fileid=3922622 more_overlays_version=1.21.3-mc1.19 From a54d2f940f71afb23b70b429b493bcc232d8a6e4 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 19 Feb 2023 01:06:09 +0700 Subject: [PATCH 0212/1199] A lot of stuff related to configurable devices sides --- .../mc/otm/datagen/lang/English.kt | 18 ++ .../mc/otm/datagen/lang/Russian.kt | 18 ++ .../mc/otm/block/entity/MatteryBlockEntity.kt | 216 ++++------------ .../block/entity/MatteryDeviceBlockEntity.kt | 240 ++++++++++++++++++ .../block/entity/MatteryPoweredBlockEntity.kt | 4 +- .../block/entity/MatteryWorkerBlockEntity.kt | 9 +- .../entity/blackhole/BlackHoleBlockEntity.kt | 3 +- .../entity/matter/MatterBottlerBlockEntity.kt | 4 +- .../matter/MatterDecomposerBlockEntity.kt | 5 +- .../matter/MatterRecyclerBlockEntity.kt | 4 +- .../entity/storage/DriveRackBlockEntity.kt | 4 +- .../entity/storage/DriveViewerBlockEntity.kt | 4 - .../entity/storage/ItemMonitorBlockEntity.kt | 5 +- .../entity/storage/StorageBusBlockEntity.kt | 4 +- .../block/entity/storage/StorageInterfaces.kt | 10 +- .../StoragePowerSupplierBlockEntity.kt | 6 +- .../entity/tech/AndroidStationBlockEntity.kt | 6 +- .../entity/tech/BatteryBankBlockEntity.kt | 4 +- .../tech/ChemicalGeneratorBlockEntity.kt | 4 +- .../block/entity/tech/CobblerBlockEntity.kt | 5 +- .../entity/tech/EnergyCounterBlockEntity.kt | 4 +- .../entity/tech/EnergyServoBlockEntity.kt | 4 +- .../otm/block/matter/MatterReplicatorBlock.kt | 2 +- .../mc/otm/block/matter/MatterScannerBlock.kt | 2 +- .../mc/otm/block/tech/CobblerBlock.kt | 2 +- .../mc/otm/block/tech/PlatePressBlock.kt | 2 +- .../mc/otm/capability/CombinedItemHandler.kt | 80 ++++++ .../mc/otm/capability/EmptyItemHandler.kt | 30 +++ .../mc/otm/capability/FlowDirection.kt | 4 + .../dbotthepony/mc/otm/capability/Helpers.kt | 43 ++++ .../otm/capability/UnmodifiableItemHandler.kt | 14 + .../energy/IMatteryEnergyStorage.kt | 8 +- .../mc/otm/client/render/WidgetLocation.kt | 1 + .../mc/otm/client/render/Widgets18.kt | 13 + .../otm/client/screen/panels/EditablePanel.kt | 4 +- .../button/BooleanRectangleButtonPanel.kt | 13 +- .../client/screen/panels/button/Buttons.kt | 136 +++++++++- .../panels/button/EnumRectangleButtonPanel.kt | 95 ++++--- .../LargeBooleanRectangleButtonPanel.kt | 2 + .../button/LargeEnumRectangleButtonPanel.kt | 2 + .../otm/client/screen/tech/CobblerScreen.kt | 2 +- .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 7 + .../mc/otm/core/collect/ConditionalSet.kt | 6 + .../mc/otm/core/util/Savetables.kt | 23 ++ .../dbotthepony/mc/otm/core/util/TickList.kt | 17 ++ .../otm/menu/input/ItemHandlerPlayerInput.kt | 66 +++++ .../mc/otm/menu/tech/CobblerMenu.kt | 3 + .../textures/gui/widgets/side_controls.png | Bin 0 -> 1140 bytes .../textures/gui/widgets/side_controls.xcf | Bin 0 -> 6919 bytes .../textures/gui/widgets_8.xcf | Bin 6564 -> 6564 bytes 50 files changed, 901 insertions(+), 257 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/capability/CombinedItemHandler.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/capability/EmptyItemHandler.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/capability/Helpers.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/capability/UnmodifiableItemHandler.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.xcf diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index cdf677bb2..328d94b0f 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -611,6 +611,24 @@ private fun gui(provider: MatteryLanguageProvider) { gui("item_monitor.amount.full", "Stack of ingredients. Craft until reaching stack size of one of ingredients. If at least one of inputs is not stackable then 'one stack' mode is used instead") gui("stored_amount", "Exact amount stored: %s") + + gui("sides.item_config", "Item Configuration") + + gui("sides.top", "Top") + gui("sides.bottom", "Bottom") + gui("sides.front", "Front") + gui("sides.back", "Back") + gui("sides.left", "Left") + gui("sides.right", "Right") + + gui("side_mode.disabled", "Disabled") + gui("side_mode.input", "Input only") + gui("side_mode.output", "Output only") + gui("side_mode.input_output", "Input/Output") + gui("side_mode.battery", "Battery") + + gui("side_mode.pull", "Pull") + gui("side_mode.push", "Push") } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index f333f0d35..84a5e547d 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -616,6 +616,24 @@ private fun gui(provider: MatteryLanguageProvider) { gui("item_monitor.amount.full", "Стопку ингредиентов. Создание продолжается пока не будет достигнут лимит по стопке одного из ингредиентов. Если хотя бы один из ингредиентов не может быть стопкой, будет использован режим 'одна стопка результата'") gui("stored_amount", "Точное количество в хранилище: %s шт.") + + gui("sides.item_config", "Настройка Предметов") + + gui("sides.top", "Верхняя сторона") + gui("sides.bottom", "Нижняя сторона") + gui("sides.front", "Передняя сторона") + gui("sides.back", "Задняя сторона") + gui("sides.left", "Левая сторона") + gui("sides.right", "Правая сторона") + + gui("side_mode.disabled", "Отключено") + gui("side_mode.input", "Только вход") + gui("side_mode.output", "Только выход") + gui("side_mode.input_output", "Вход/Выход") + gui("side_mode.battery", "Батарея") + + gui("side_mode.pull", "Автоматическое вытягивание") + gui("side_mode.push", "Автоматическое выталкивание") } } 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 ec3dc18d8..d2f74287d 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 @@ -4,7 +4,6 @@ import com.google.common.collect.ImmutableSet import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import it.unimi.dsi.fastutil.longs.Long2ObjectFunction import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap -import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap import it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.core.BlockPos @@ -12,11 +11,10 @@ import net.minecraft.core.Direction import net.minecraft.core.SectionPos import net.minecraft.core.Vec3i import net.minecraft.nbt.CompoundTag -import net.minecraft.nbt.StringTag import net.minecraft.nbt.Tag -import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerPlayer +import net.minecraft.world.item.ItemStack import net.minecraft.world.level.ChunkPos import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block @@ -35,24 +33,30 @@ import net.minecraftforge.event.level.ChunkWatchEvent import net.minecraftforge.event.level.LevelEvent import net.minecraftforge.event.server.ServerStoppingEvent import net.minecraftforge.items.IItemHandler +import ru.dbotthepony.mc.otm.SERVER_IS_LIVE import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock -import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.capability.CombinedItemHandler +import ru.dbotthepony.mc.otm.capability.EmptyItemHandler import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.UnmodifiableItemHandler import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.isMekanismLoaded +import ru.dbotthepony.mc.otm.capability.moveBetweenSlots import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper import ru.dbotthepony.mc.otm.core.collect.SupplierList import ru.dbotthepony.mc.otm.core.collect.WeakHashSet import ru.dbotthepony.mc.otm.core.forValidRefs -import ru.dbotthepony.mc.otm.core.forValidRefsBreak import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.core.getValue +import ru.dbotthepony.mc.otm.core.ifPresentK +import ru.dbotthepony.mc.otm.core.immutableMap import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.core.math.minus import ru.dbotthepony.mc.otm.core.math.plus -import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.core.util.EnumValueCodec +import ru.dbotthepony.mc.otm.core.util.ITickable import ru.dbotthepony.mc.otm.core.util.Savetables +import ru.dbotthepony.mc.otm.core.util.TickList import ru.dbotthepony.mc.otm.network.BlockEntitySyncPacket import ru.dbotthepony.mc.otm.network.FieldSynchronizer import ru.dbotthepony.mc.otm.network.WorldNetworkChannel @@ -88,6 +92,12 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc private data class SidelessCap(val cap: T, var optional: LazyOptional) private val sidelessCaps = Reference2ObjectArrayMap, SidelessCap<*>>() + protected val tickList = TickList() + protected val savetables = Savetables() + + open fun tick() { + tickList.tick() + } /** * exposes capability when no side is specified @@ -138,16 +148,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } } - protected fun exposeEnergy(side: RelativeSide, value: IMatteryEnergyStorage) { - _sides[side]!!.Cap(ForgeCapabilities.ENERGY, value) - _sides[side]!!.Cap(MatteryCapability.ENERGY, value) - - if (isMekanismLoaded) { - _sides[side]!!.Cap(MatteryCapability.MEKANISM_ENERGY, Mattery2MekanismEnergyWrapper(value)) - } - } - - protected fun exposeEnergySideless( value: IMatteryEnergyStorage) { + protected fun exposeEnergySideless(value: IMatteryEnergyStorage) { exposeSideless(ForgeCapabilities.ENERGY, value) exposeSideless(MatteryCapability.ENERGY, value) @@ -156,6 +157,17 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } } + protected fun exposeEnergy(side: RelativeSide, value: IMatteryEnergyStorage) { + val thisSide = _sides[side]!! + + thisSide.Cap(ForgeCapabilities.ENERGY, value) + thisSide.Cap(MatteryCapability.ENERGY, value) + + if (isMekanismLoaded) { + thisSide.Cap(MatteryCapability.MEKANISM_ENERGY, Mattery2MekanismEnergyWrapper(value)) + } + } + protected fun exposeItemsGlobally(value: IItemHandler) { exposeGlobally(ForgeCapabilities.ITEM_HANDLER, value) } @@ -165,47 +177,13 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc return SupplierList(_sides.values.map { it.track(capability)::get }) } - enum class SideMode(val filter: FlowDirection, val automation: FlowDirection) { - DISABLED (FlowDirection.NONE, FlowDirection.NONE), - NONE (FlowDirection.BI_DIRECTIONAL, FlowDirection.NONE), - INPUT (FlowDirection.INPUT, FlowDirection.NONE), - OUTPUT (FlowDirection.OUTPUT, FlowDirection.NONE), - - PULL (FlowDirection.INPUT, FlowDirection.INPUT), - PUSH (FlowDirection.OUTPUT, FlowDirection.OUTPUT), - PULL_ONLY (FlowDirection.BI_DIRECTIONAL, FlowDirection.INPUT), - PUSH_ONLY (FlowDirection.BI_DIRECTIONAL, FlowDirection.OUTPUT), - PULL_PUSH (FlowDirection.BI_DIRECTIONAL, FlowDirection.BI_DIRECTIONAL); - - val isOpen = filter != FlowDirection.NONE - - companion object { - @JvmField - val BI_SET: ImmutableSet = ImmutableSet.of(NONE, INPUT, OUTPUT, PULL, PUSH, PULL_ONLY, PUSH_ONLY, PULL_PUSH, DISABLED) - - @JvmField - val INPUT_SET: ImmutableSet = ImmutableSet.of(INPUT, PULL, DISABLED) - - @JvmField - val OUTPUT_SET: ImmutableSet = ImmutableSet.of(OUTPUT, PUSH, DISABLED) - - @JvmField - val CODEC = EnumValueCodec(SideMode::class.java) - } - } - - fun interface SideModeListener { - fun sideModeChanges(config: Side.ModeState, new: SideMode, old: SideMode) - } - - inner class Side(val side: RelativeSide) : INBTSerializable { + inner class Side(val side: RelativeSide) { init { check(!_sides.containsKey(side)) { "dafuq are you trying to do" } _sides[side] = this } private val caps = Reference2ObjectArrayMap, Cap<*>>() - private val data = Object2ObjectArrayMap>() private val subscriptions = Reference2ObjectArrayMap, SubRef<*>>() private val knownLOs = WeakHashSet>() @@ -240,7 +218,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } private fun updateTracked(capability: Capability<*>) { - if (isRemoved) return + if (isRemoved || !SERVER_IS_LIVE) return val dir = blockRotation.side2Dir(side) val chunk = level @@ -282,21 +260,10 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } } - val isEmpty get() = caps.isEmpty() && data.isEmpty() - operator fun get(capability: Capability): Cap? { return caps[capability] as Cap? } - fun addData(index: ResourceLocation, data: INBTSerializable<*>) { - require(!this.data.containsKey(index)) { "Already has data with ID $index on $side!" } - this.data[index] = data as INBTSerializable - } - - fun getData(index: ResourceLocation): INBTSerializable<*>? { - return data[index] - } - fun invalidate() { for (cap in caps.values) cap.invalidate() @@ -307,87 +274,18 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc cap.revive() } - override fun serializeNBT(): CompoundTag { - return CompoundTag().also { - for ((k, v) in data) { - it[k.toString()] = v.serializeNBT() - } - } - } - - override fun deserializeNBT(nbt: CompoundTag) { - for ((k, v) in data) { - val tag = nbt[k.toString()] - - if (tag != null) { - v.deserializeNBT(tag) - } - } - } - - inner class ModeState(val name: String, val possibleValues: ImmutableSet = SideMode.BI_SET) : INBTSerializable { - init { - addData(ResourceLocation(name), this) - } - - val side get() = this@Side.side - - var mode by synchronizer.Field(possibleValues.first(), SideMode.CODEC, setter = { value, access, setByRemote -> - require(value in possibleValues) { "Value $value is not allowed (allowed values: $possibleValues)" } - val old = access.read() - - if (value != old) { - access.write(value) - - listeners.forValidRefs { - it.sideModeChanges(this, value, old) - } - } - }, name = "SideConfig/$side/$name") - - fun isAllowed(value: SideMode): Boolean = value in possibleValues - - private val listeners = ArrayList>() - - fun addListener(listener: SideModeListener) { - var hit = false - - listeners.forValidRefsBreak { - if (it === listener) { - hit = true - return@forValidRefsBreak true - } - - return@forValidRefsBreak false - } - - if (!hit) { - listeners.add(WeakReference(listener)) - } - } - - override fun serializeNBT(): StringTag { - return StringTag.valueOf(mode.name) - } - - override fun deserializeNBT(nbt: StringTag) { - mode = SideMode.valueOf(nbt.asString) - } - - fun deserializeNBT(nbt: String) { - mode = SideMode.valueOf(nbt) - } - } - inner class Cap(val type: Capability, val capability: T) { init { check(!caps.containsKey(type)) { "Already has capability $type on side $side" } caps[type] = this } - private var isExposed = true - private var isValid = true - private var isRemoved = false + var isExposed = true + private set + var isValid = true + private set + var isRemoved = false + private set var optional: LazyOptional by object : ReadWriteProperty> { private var value: LazyOptional? = null @@ -419,7 +317,9 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc if (!isRemoved && isExposed) { isExposed = false optional.invalidate() - setChanged() + + if (SERVER_IS_LIVE) + level?.once { setChanged() } } } @@ -429,7 +329,9 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc if (isValid) { optional = LazyOptional.of { capability } - setChanged() + + if (SERVER_IS_LIVE) + level?.once { setChanged() } } } } @@ -438,7 +340,9 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc if (!isRemoved && isValid) { isValid = false optional.invalidate() - setChanged() + + if (SERVER_IS_LIVE) + level?.once { setChanged() } } } @@ -448,7 +352,9 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc if (isExposed) { optional = LazyOptional.of { capability } - setChanged() + + if (SERVER_IS_LIVE) + level?.once { setChanged() } } } } @@ -489,41 +395,17 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc side.revive() } - protected val savetables = Savetables() - protected inline fun > savetable(property: KProperty0, name: String = property.name) { savetables.stateful(property, name, T::class.java) } override fun saveAdditional(nbt: CompoundTag) { super.saveAdditional(nbt) - - if (_sides.values.any { !it.isEmpty }) { - nbt["Sides"] = CompoundTag().also { - for (side in _sides.values) { - if (!side.isEmpty) { - it[side.side.name] = side.serializeNBT() - } - } - } - } - savetables.serializeNBT(nbt) } override fun load(nbt: CompoundTag) { super.load(nbt) - - if (nbt.contains("Sides")) { - val tag = nbt.getCompound("Sides") - - for (side in _sides.values) { - if (side.side.name in tag) { - side.deserializeNBT(tag.getCompound(side.side.name)) - } - } - } - savetables.deserializeNBT(nbt) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index b2e43f7db..9366184be 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.block.entity +import com.google.common.collect.ImmutableSet import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.core.BlockPos import net.minecraft.world.level.block.state.BlockState @@ -13,12 +14,24 @@ import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.nbt.CompoundTag import net.minecraft.network.chat.Component +import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity +import net.minecraftforge.common.capabilities.ForgeCapabilities +import net.minecraftforge.items.IItemHandler +import ru.dbotthepony.mc.otm.capability.CombinedItemHandler +import ru.dbotthepony.mc.otm.capability.EmptyItemHandler +import ru.dbotthepony.mc.otm.capability.UnmodifiableItemHandler +import ru.dbotthepony.mc.otm.capability.moveBetweenSlots import ru.dbotthepony.mc.otm.core.TextComponent +import ru.dbotthepony.mc.otm.core.getValue +import ru.dbotthepony.mc.otm.core.ifPresentK +import ru.dbotthepony.mc.otm.core.immutableMap +import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.core.nbt.getJson import ru.dbotthepony.mc.otm.core.nbt.putJson import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.core.util.ITickable import ru.dbotthepony.mc.otm.oncePre /** @@ -61,4 +74,231 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo customDisplayName = nbt.getJson("Name")?.let(Component.Serializer::fromJson) redstoneControl.deserializeNBT(nbt[REDSTONE_CONTROL_KEY] as? CompoundTag) } + + + enum class ItemHandlerView(val translationKey: String) { + DISABLED("otm.gui.side_mode.disabled"), + INPUT("otm.gui.side_mode.input"), + OUTPUT("otm.gui.side_mode.output"), + INPUT_OUTPUT("otm.gui.side_mode.input_output"), + BATTERY("otm.gui.side_mode.battery"); + } + + inner class GlobalItemHandler( + input: IItemHandler? = null, + output: IItemHandler? = null, + battery: IItemHandler? = null, + val frontDefault: ItemHandlerView = determineDefaultMode(input, output), + val backDefault: ItemHandlerView = determineDefaultMode(input, output), + val leftDefault: ItemHandlerView = determineDefaultMode(input, output), + val rightDefault: ItemHandlerView = determineDefaultMode(input, output), + val topDefault: ItemHandlerView = determineDefaultMode(input, output), + val bottomDefault: ItemHandlerView = determineDefaultMode(input, output), + ) { + val sideless: IItemHandler + + init { + val caps = ArrayList() + + if (input != null) caps.add(input) + if (output != null) caps.add(output) + if (battery != null) caps.add(battery) + + sideless = UnmodifiableItemHandler(CombinedItemHandler(caps)) + exposeSideless(ForgeCapabilities.ITEM_HANDLER, sideless) + } + + val front = ConfigurableItemHandler(RelativeSide.FRONT, input, output, battery).also { it.mode = frontDefault } + val back = ConfigurableItemHandler(RelativeSide.BACK, input, output, battery).also { it.mode = backDefault } + val left = ConfigurableItemHandler(RelativeSide.LEFT, input, output, battery).also { it.mode = leftDefault } + val right = ConfigurableItemHandler(RelativeSide.RIGHT, input, output, battery).also { it.mode = rightDefault } + val top = ConfigurableItemHandler(RelativeSide.TOP, input, output, battery).also { it.mode = topDefault } + val bottom = ConfigurableItemHandler(RelativeSide.BOTTOM, input, output, battery).also { it.mode = bottomDefault } + + val sides = immutableMap { + put(RelativeSide.FRONT, this@GlobalItemHandler.front) + put(RelativeSide.BACK, this@GlobalItemHandler.back) + put(RelativeSide.LEFT, this@GlobalItemHandler.left) + put(RelativeSide.RIGHT, this@GlobalItemHandler.right) + put(RelativeSide.TOP, this@GlobalItemHandler.top) + put(RelativeSide.BOTTOM, this@GlobalItemHandler.bottom) + } + + val defaults = immutableMap { + put(RelativeSide.FRONT, frontDefault) + put(RelativeSide.BACK, backDefault) + put(RelativeSide.LEFT, leftDefault) + put(RelativeSide.RIGHT, rightDefault) + put(RelativeSide.TOP, topDefault) + put(RelativeSide.BOTTOM, bottomDefault) + } + } + + inner class ConfigurableItemHandler( + side: RelativeSide, + val input: IItemHandler? = null, + val output: IItemHandler? = null, + val battery: IItemHandler? = null, + ) : IItemHandler, ITickable { + private var currentHandler: IItemHandler = EmptyItemHandler + val capController = sides[side]!!.Cap(ForgeCapabilities.ITEM_HANDLER, this) + private val neighbour by sides[side]!!.track(ForgeCapabilities.ITEM_HANDLER) + + val possibleViews: ImmutableSet + val inputOutput: IItemHandler? + + init { + tickList.always(this) + + val builder = ImmutableSet.Builder() + + builder.add(ItemHandlerView.DISABLED) + + if (input != null) builder.add(ItemHandlerView.INPUT) + if (output != null) builder.add(ItemHandlerView.OUTPUT) + if (input != null && output != null) builder.add(ItemHandlerView.INPUT_OUTPUT) + if (battery != null) builder.add(ItemHandlerView.BATTERY) + + possibleViews = builder.build() + + capController.close() + + if (input != null && output != null) { + inputOutput = CombinedItemHandler(input, output) + } else { + inputOutput = null + } + } + + var mode by synchronizer.enum(ItemHandlerView.DISABLED, setter = { value, access, setByRemote -> + require(value in possibleViews) { "View type $value is not allowed (allowed views: $possibleViews)" } + + if (access.read() != value) { + access.write(value) + + if (value == ItemHandlerView.DISABLED) { + capController.close() + } else { + capController.close() + capController.expose() + } + + when (value) { + ItemHandlerView.DISABLED -> currentHandler = EmptyItemHandler + ItemHandlerView.INPUT -> currentHandler = input!! + ItemHandlerView.OUTPUT -> currentHandler = output!! + ItemHandlerView.INPUT_OUTPUT -> currentHandler = inputOutput!! + ItemHandlerView.BATTERY -> currentHandler = battery!! + } + } + }) + + var automatePull = false + set(value) { + if (field != value) { + field = value + + if (value) { + innerSlotPull = 0 + outerSlotPull = 0 + } + } + } + + var automatePush = false + set(value) { + if (field != value) { + field = value + + if (value) { + innerSlotPush = 0 + outerSlotPush = 0 + } + } + } + + init { + savetables.bool(::automatePull, "itemhandler_${side}_automatePull") + savetables.bool(::automatePush, "itemhandler_${side}_automatePush") + savetables.enum(::mode, "itemhandler_${side}_mode", ItemHandlerView::valueOf) + } + + private var innerSlotPull = 0 + private var outerSlotPull = 0 + + private var innerSlotPush = 0 + private var outerSlotPush = 0 + + override fun tick() { + if (mode == ItemHandlerView.DISABLED || currentHandler.slots == 0 || redstoneControl.isBlockedByRedstone) + return + + neighbour.ifPresentK { + if (it.slots == 0) + return + + if (automatePull) { + if (innerSlotPull !in 0 until currentHandler.slots) + innerSlotPull = 0 + + if (outerSlotPull !in 0 until it.slots) + outerSlotPull = 0 + + val (outerSlotPull, innerSlotPull) = moveBetweenSlots(it, outerSlotPull, currentHandler, innerSlotPull) + this.innerSlotPull = innerSlotPull + this.outerSlotPull = outerSlotPull + } + + if (automatePush) { + if (innerSlotPush !in 0 until currentHandler.slots) + innerSlotPush = 0 + + if (outerSlotPush !in 0 until it.slots) + outerSlotPush = 0 + + val (innerSlotPush, outerSlotPush) = moveBetweenSlots(currentHandler, innerSlotPush, it, outerSlotPush) + this.innerSlotPush = innerSlotPush + this.outerSlotPush = outerSlotPush + } + } + } + + override fun getSlots(): Int { + return currentHandler.slots + } + + override fun getStackInSlot(slot: Int): ItemStack { + return currentHandler.getStackInSlot(slot) + } + + override fun insertItem(slot: Int, stack: ItemStack, simulate: Boolean): ItemStack { + return currentHandler.insertItem(slot, stack, simulate) + } + + override fun extractItem(slot: Int, amount: Int, simulate: Boolean): ItemStack { + return currentHandler.extractItem(slot, amount, simulate) + } + + override fun getSlotLimit(slot: Int): Int { + return currentHandler.getSlotLimit(slot) + } + + override fun isItemValid(slot: Int, stack: ItemStack): Boolean { + return currentHandler.isItemValid(slot, stack) + } + } + + companion object { + + private fun determineDefaultMode(input: IItemHandler?, output: IItemHandler?): ItemHandlerView { + if (input == null && output == null) + return ItemHandlerView.DISABLED + else if (input != null && output != null) + return ItemHandlerView.INPUT_OUTPUT + else if (output != null) + return ItemHandlerView.OUTPUT + else + return ItemHandlerView.INPUT + } + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt index ed857c2dd..fde001d37 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt @@ -33,7 +33,9 @@ abstract class MatteryPoweredBlockEntity(p_155228_: BlockEntityType<*>, p_155229 savetable(::batteryContainer, BATTERY_KEY) } - protected fun batteryChargeLoop() { + override fun tick() { + super.tick() + val energy = matteryEnergy if (energy == null || !batteryContainer.any { !it.isEmpty }) return diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt index 882bb93af..bb7e717c7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt @@ -233,7 +233,9 @@ abstract class MatteryWorkerBlockEntity( isIdling = newBlocked } - protected fun workerLoop() { + override fun tick() { + super.tick() + if (errorTicksAnim > 20 && blockState.hasProperty(WorkerState.WORKER_STATE) && blockState.getValue(WorkerState.WORKER_STATE) != WorkerState.ERROR) { level?.setBlock(blockPos, blockState.setValue(WorkerState.WORKER_STATE, WorkerState.ERROR), Block.UPDATE_CLIENTS) } @@ -379,11 +381,6 @@ abstract class MatteryWorkerBlockEntity( } } - fun basicTicker() { - batteryChargeLoop() - workerLoop() - } - companion object { const val WORK_TICKS_KEY = "workTicks" const val JOB_KEY = "job" 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 9d1477b0e..52df29f0b 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 @@ -215,7 +215,8 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery } } - fun tick() { + override fun tick() { + super.tick() sleepTicks-- if (sleepTicks > 0) return val level = level as? ServerLevel ?: return diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index 036077d4f..fc1fe4522 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -169,8 +169,8 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : matterNode.destroy(::MatterNetworkGraph) } - fun tick() { - batteryChargeLoop() + override fun tick() { + super.tick() if (redstoneControl.isBlockedByRedstone) { if (blockState.getValue(WorkerState.SEMI_WORKER_STATE) !== WorkerState.IDLE) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index 3fd64d919..90fdf93c6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -215,9 +215,8 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) return matter } - fun tick() { - batteryChargeLoop() - workerLoop() + override fun tick() { + super.tick() val grid = matterNode.graph as MatterNetworkGraph? ?: return diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index 0426dee94..1811434d7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -154,8 +154,8 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) return Status.SUCCESS } - fun tick() { - basicTicker() + override fun tick() { + super.tick() val graph = matterNode.graph as MatterNetworkGraph? ?: return val received = graph.receiveMatter(matter.storedMatter, false) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt index e36f1b0fc..7a7856fa3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt @@ -57,8 +57,8 @@ class DriveRackBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : StorageNetworkGraph.discoverFull(this, cell.storageNode) } - fun tick() { - batteryChargeLoop() + override fun tick() { + super.tick() cell.tickEnergyDemanding() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt index f9b176dd5..44c6c3eb1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt @@ -81,8 +81,4 @@ class DriveViewerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { return DriveViewerMenu(containerID, inventory, this) } - - fun tick() { - batteryChargeLoop() - } } 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 03a5be273..224c4df97 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 @@ -481,8 +481,9 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return settings.computeIfAbsent(ply.uuid) { ItemMonitorPlayerSettings() } } - fun tick() { - batteryChargeLoop() + override fun tick() { + super.tick() + cell.tickEnergyDemanding() if (craftingAmount.size != 0) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt index de9319380..f2258b9f6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt @@ -123,8 +123,8 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter private var neighbour: LazyOptional? = null private var component: ItemHandlerComponent? = null - fun tick() { - batteryChargeLoop() + override fun tick() { + super.tick() component?.scan() cell.tickEnergyDemanding() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt index f4ac6cedc..f38b98c93 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt @@ -175,11 +175,12 @@ class StorageImporterBlockEntity(blockPos: BlockPos, blockState: BlockState) return filter.match(stack) } - fun tick() { + override fun tick() { + super.tick() + if (redstoneControl.isBlockedByRedstone) return - batteryChargeLoop() cell.tickEnergyDemanding() nextTick-- @@ -287,11 +288,12 @@ class StorageExporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : return relevantTuples.stream().map { it to view[it] } } - fun tick() { + override fun tick() { + super.tick() + if (redstoneControl.isBlockedByRedstone) return - batteryChargeLoop() cell.tickEnergyDemanding() nextTick-- diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt index 458e8a257..fa0dbb017 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt @@ -53,12 +53,12 @@ class StoragePowerSupplierBlockEntity(blockPos: BlockPos, blockState: BlockState cell.destroy(level) } - fun tick() { + override fun tick() { + super.tick() + if (redstoneControl.isBlockedByRedstone) return - batteryChargeLoop() - if (energy.batteryLevel.isZero) return diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt index a51524825..378b917a9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt @@ -65,7 +65,9 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : private var tickedOnce = false - fun tick() { + override fun tick() { + super.tick() + if (!tickedOnce) { tickedOnce = true @@ -76,8 +78,6 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } - batteryChargeLoop() - if (redstoneControl.isBlockedByRedstone) return val level = level ?: return val x = blockPos.x.toDouble() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index 24863d985..6ae004b60 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -206,7 +206,9 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte private val consumers by front.track(ForgeCapabilities.ENERGY) - fun tick() { + override fun tick() { + super.tick() + if (redstoneControl.isBlockedByRedstone) return 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 8f131b122..9cdd3c35c 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 @@ -89,7 +89,9 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe } } - fun tick() { + override fun tick() { + super.tick() + if (workTicks > 0) { workTicks-- energy.receiveEnergy(GENERATION_SPEED, false) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt index 52de77096..499daad92 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt @@ -22,14 +22,15 @@ class CobblerBlockEntity(blockPos: BlockPos, blockState: BlockState) override val droppableContainer = MatteryContainer(this::itemContainerUpdated, CONTAINER_SIZE) - val handler = droppableContainer.handler(object : HandlerFilter { + val itemHandler = droppableContainer.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { return false } }) + val itemConfig = GlobalItemHandler(output = itemHandler) + init { - exposeItemsGlobally(handler) savetable(::droppableContainer, INVENTORY_KEY) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt index 32c0b6782..82fcf0fee 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt @@ -285,7 +285,9 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat } } - fun tick() { + override fun tick() { + super.tick() + lastTick = history[historyTick] historyTick = (historyTick + 1) % history.size history[historyTick] = Decimal.ZERO diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt index 0656a01dc..7cd689f7a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt @@ -97,7 +97,9 @@ class EnergyServoBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte return EnergyServoMenu(containerID, inventory, this) } - fun tick() { + override fun tick() { + super.tick() + if (redstoneControl.isBlockedByRedstone) return diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt index b190c8e4d..a483c570a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt @@ -35,7 +35,7 @@ class MatterReplicatorBlock : RotatableMatteryBlock(), EntityBlock { if (p_153212_.isClientSide || p_153214_ !== MBlockEntities.MATTER_REPLICATOR) return null - return BlockEntityTicker { _, _, _, tile -> if (tile is MatterReplicatorBlockEntity) tile.basicTicker() } + return BlockEntityTicker { _, _, _, tile -> if (tile is MatterReplicatorBlockEntity) tile.tick() } } override fun createBlockStateDefinition(builder: StateDefinition.Builder) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt index 370c77b05..7a80592c2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt @@ -35,7 +35,7 @@ class MatterScannerBlock : RotatableMatteryBlock(), EntityBlock { if (p_153212_.isClientSide || p_153214_ !== MBlockEntities.MATTER_SCANNER) return null - return BlockEntityTicker { _, _, _, tile -> if (tile is MatterScannerBlockEntity) tile.basicTicker() } + return BlockEntityTicker { _, _, _, tile -> if (tile is MatterScannerBlockEntity) tile.tick() } } override fun createBlockStateDefinition(builder: StateDefinition.Builder) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/CobblerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/CobblerBlock.kt index c92f427ae..0271d346c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/CobblerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/CobblerBlock.kt @@ -21,7 +21,7 @@ class CobblerBlock : RotatableMatteryBlock(), EntityBlock { pBlockEntityType: BlockEntityType ): BlockEntityTicker? { if (!pLevel.isClientSide) { - return BlockEntityTicker { _, _, _, pBlockEntity -> if (pBlockEntity is CobblerBlockEntity) pBlockEntity.basicTicker() } + return BlockEntityTicker { _, _, _, pBlockEntity -> if (pBlockEntity is CobblerBlockEntity) pBlockEntity.tick() } } return null diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt index 341adcadb..c9fc9e6ce 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt @@ -39,7 +39,7 @@ class PlatePressBlock(properties: Properties = DEFAULT_PROPERTIES) : RotatableMa if (p_153212_.isClientSide || p_153214_ !== MBlockEntities.PLATE_PRESS) return null - return BlockEntityTicker { _, _, _, tile -> if (tile is PlatePressBlockEntity) tile.basicTicker() } + return BlockEntityTicker { _, _, _, tile -> if (tile is PlatePressBlockEntity) tile.tick() } } override fun createBlockStateDefinition(builder: StateDefinition.Builder) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/CombinedItemHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/CombinedItemHandler.kt new file mode 100644 index 000000000..b43fc9121 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/CombinedItemHandler.kt @@ -0,0 +1,80 @@ +package ru.dbotthepony.mc.otm.capability + +import com.google.common.collect.ImmutableList +import net.minecraft.world.item.ItemStack +import net.minecraftforge.items.IItemHandler +import java.util.stream.Stream + +class CombinedItemHandler(val handlers: ImmutableList) : IItemHandler { + constructor(handlers: Stream) : this(handlers.collect(ImmutableList.toImmutableList())) + constructor(handlers: Collection) : this(ImmutableList.copyOf(handlers)) + constructor(vararg handlers: IItemHandler) : this(ImmutableList.copyOf(handlers)) + + private val lastSizes = IntArray(this.handlers.size) + private var totalSize = 0 + private val mappings = ArrayList() + private data class Mapping(val handler: IItemHandler, val slot: Int) + + private fun check() { + for ((i, handler) in handlers.withIndex()) { + var oldSize = lastSizes[i] + + if (oldSize != handler.slots) { + totalSize += handler.slots - lastSizes[i] + var edge = 0 + + for (i2 in 0 .. i) { + edge += lastSizes[i2] + } + + edge-- + + while (oldSize > handler.slots) { + mappings.removeAt(edge--) + oldSize-- + } + + while (oldSize < handler.slots) { + mappings.add(++edge, Mapping(handler, oldSize++)) + } + + lastSizes[i] = handler.slots + } + } + } + + override fun getSlots(): Int { + check() + return totalSize + } + + override fun getStackInSlot(slot: Int): ItemStack { + check() + val mapping = mappings.getOrNull(slot) ?: return ItemStack.EMPTY + return mapping.handler.getStackInSlot(mapping.slot) + } + + override fun insertItem(slot: Int, stack: ItemStack, simulate: Boolean): ItemStack { + check() + val mapping = mappings.getOrNull(slot) ?: return stack + return mapping.handler.insertItem(mapping.slot, stack, simulate) + } + + override fun extractItem(slot: Int, amount: Int, simulate: Boolean): ItemStack { + check() + val mapping = mappings.getOrNull(slot) ?: return ItemStack.EMPTY + return mapping.handler.extractItem(mapping.slot, amount, simulate) + } + + override fun getSlotLimit(slot: Int): Int { + check() + val mapping = mappings.getOrNull(slot) ?: return 0 + return mapping.handler.getSlotLimit(mapping.slot) + } + + override fun isItemValid(slot: Int, stack: ItemStack): Boolean { + check() + val mapping = mappings.getOrNull(slot) ?: return false + return mapping.handler.isItemValid(mapping.slot, stack) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/EmptyItemHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/EmptyItemHandler.kt new file mode 100644 index 000000000..0cf000529 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/EmptyItemHandler.kt @@ -0,0 +1,30 @@ +package ru.dbotthepony.mc.otm.capability + +import net.minecraft.world.item.ItemStack +import net.minecraftforge.items.IItemHandler + +object EmptyItemHandler : IItemHandler { + override fun getSlots(): Int { + return 0 + } + + override fun getStackInSlot(slot: Int): ItemStack { + return ItemStack.EMPTY + } + + override fun insertItem(slot: Int, stack: ItemStack, simulate: Boolean): ItemStack { + return stack + } + + override fun extractItem(slot: Int, amount: Int, simulate: Boolean): ItemStack { + return ItemStack.EMPTY + } + + override fun getSlotLimit(slot: Int): Int { + return 0 + } + + override fun isItemValid(slot: Int, stack: ItemStack): Boolean { + return false + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt index e13186bf6..d49194b2d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt @@ -45,6 +45,10 @@ enum class FlowDirection(val input: Boolean, val output: Boolean) : Predicate { + val getItem = source.extractItem(sourceSlot, Int.MAX_VALUE, true) + + if (getItem.isEmpty) { + return sourceSlot + 1 to destinationSlot + } else { + val leftover = destination.insertItem(destinationSlot, getItem, true) + + if (leftover.count == getItem.count) { + return sourceSlot to destinationSlot + 1 + } else { + val getItem2 = source.extractItem(sourceSlot, getItem.count - leftover.count, true) + + if (getItem2.isEmpty) { + return sourceSlot + 1 to destinationSlot + } else { + val leftover2 = destination.insertItem(destinationSlot, getItem2, true) + + if (leftover2.isEmpty) { + source.extractItem(sourceSlot, getItem2.count, false) + destination.insertItem(destinationSlot, getItem2, false) + + if (getItem2.count == getItem.count) { + return sourceSlot + 1 to destinationSlot + } else { + return sourceSlot to destinationSlot + } + } + } + } + } + + return sourceSlot to destinationSlot +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/UnmodifiableItemHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/UnmodifiableItemHandler.kt new file mode 100644 index 000000000..3546158a6 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/UnmodifiableItemHandler.kt @@ -0,0 +1,14 @@ +package ru.dbotthepony.mc.otm.capability + +import net.minecraft.world.item.ItemStack +import net.minecraftforge.items.IItemHandler + +class UnmodifiableItemHandler(private val parent: IItemHandler) : IItemHandler by parent { + override fun extractItem(slot: Int, amount: Int, simulate: Boolean): ItemStack { + return ItemStack.EMPTY + } + + override fun isItemValid(slot: Int, stack: ItemStack): Boolean { + return false + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt index e83f907a4..3a4087f97 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt @@ -162,13 +162,13 @@ interface IMatteryEnergyStorage : IEnergyStorage { if (!energyFlow.input) return 0 - val received = receiveEnergy(Decimal(maxReceive), true).toInt() + val received = receiveEnergyChecked(Decimal(maxReceive), true).toInt() // Receiving only a fraction if (received == 0) return 0 - return receiveEnergy(Decimal(received), simulate).toInt() + return receiveEnergyChecked(Decimal(received), simulate).toInt() } override fun extractEnergy(maxReceive: Int, simulate: Boolean): Int { @@ -176,13 +176,13 @@ interface IMatteryEnergyStorage : IEnergyStorage { if (energyFlow.output) return 0 - val extracted = extractEnergy(Decimal(maxReceive), true).toInt() + val extracted = extractEnergyChecked(Decimal(maxReceive), true).toInt() // Extracting only a fraction if (extracted == 0) return 0 - return extractEnergy(Decimal(extracted), simulate).toInt() + return extractEnergyChecked(Decimal(extracted), simulate).toInt() } override fun getEnergyStored(): Int { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt index 6caaabfee..0b4725b34 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt @@ -17,4 +17,5 @@ object WidgetLocation { val HORIZONTAL_GAUGES = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/horizontal_gauges.png"), 96f, 54f) val VERTICAL_GAUGES = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/vertical_gauges.png"), 90f, 48f) val REDSTONE_CONTROLS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/redstone.png"), 54f, 18f) + val SIDE_CONTROLS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/side_controls.png"), 72f, 72f) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt index 540fe2035..3bc229a6c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt @@ -55,4 +55,17 @@ object Widgets18 { val REDSTONE_IGNORED = redstoneGrid.next() val REDSTONE_LOW = redstoneGrid.next() val REDSTONE_HIGH = redstoneGrid.next() + + private val controlsGrid = WidgetLocation.SIDE_CONTROLS.grid(rows = 4, columns = 4) + + val PULL = controlsGrid.next() + val PUSH = controlsGrid.next() + val PULL_DISABLED = controlsGrid.next() + val PUSH_DISABLED = controlsGrid.next() + val DISABLED = controlsGrid.next() + val INPUT_ONLY = controlsGrid.next() + val OUTPUT_ONLY = controlsGrid.next() + val INPUT_OUTPUT = controlsGrid.next() + val BATTERY_ONLY = controlsGrid.next() + val ITEMS_CONFIGURATION = controlsGrid.next() } 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 b4c168828..23b8853fb 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 @@ -569,12 +569,12 @@ open class EditablePanel @JvmOverloads constructor( val old = field field = value - onFocusChanged(old, value) + onFocusChanged(value, old) findAbsoluteRoot().updateFocus() } } - var autoKillFocus = false + var autoKillFocus = true private var focusedAsParent = false val font: Font get() = if (screen is MatteryScreen<*>) screen.font else minecraft.font diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt index 5d2563433..8d568d90c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt @@ -1,12 +1,13 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button -import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.value +import ru.dbotthepony.mc.otm.menu.input.IPlayerInputWithFeedback abstract class BooleanRectangleButtonPanel( screen: S, @@ -26,6 +27,16 @@ abstract class BooleanRectangleButtonPanel( onChange?.invoke(newValue) } + override var isDisabled: Boolean + get() { + if (prop is IPlayerInputWithFeedback) { + return !prop.test(minecraft.player) + } else { + return super.isDisabled + } + } + set(value) { super.isDisabled = value } + override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { super.innerRender(stack, mouseX, mouseY, partialTick) 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 c9ab1997f..8b1e4d6fc 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 @@ -1,17 +1,21 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button -import com.mojang.blaze3d.vertex.PoseStack -import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.Items +import com.mojang.blaze3d.platform.InputConstants +import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.core.TextComponent +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.menu.input.IPlayerInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput +import java.util.function.Predicate -fun > makeRedstoneSettingButton( +private fun > makeRedstoneSettingButton( screen: S, parent: EditablePanel<*>?, x: Float = 0f, @@ -35,10 +39,115 @@ fun > makeRedstoneSettingButton( } } +private fun > makeItemModeButton(screen: S, parent: FramePanel, input: ItemHandlerPlayerInput.Piece): LargeEnumRectangleButtonPanel { + val button = LargeEnumRectangleButtonPanel(screen, parent, enum = MatteryDeviceBlockEntity.ItemHandlerView::class.java, prop = input.input, defaultValue = input.default) + + val values = listOf( + MatteryDeviceBlockEntity.ItemHandlerView.DISABLED to Widgets18.DISABLED, + MatteryDeviceBlockEntity.ItemHandlerView.INPUT to Widgets18.INPUT_ONLY, + MatteryDeviceBlockEntity.ItemHandlerView.OUTPUT to Widgets18.OUTPUT_ONLY, + MatteryDeviceBlockEntity.ItemHandlerView.INPUT_OUTPUT to Widgets18.INPUT_OUTPUT, + MatteryDeviceBlockEntity.ItemHandlerView.BATTERY to Widgets18.BATTERY_ONLY, + ) + + for ((k, v) in values) { + button.add(k, skinElement = v, tooltip = TranslatableComponent(k.translationKey)) + } + + button.finish() + button.predicate = Predicate { input.isAllowed(it) } + + return button +} + +private fun > makeItemHandlerControlPanel( + screen: S, + inputs: ItemHandlerPlayerInput +): FramePanel { + val frame = object : FramePanel(screen, 78f, 80f, TranslatableComponent("otm.gui.sides.item_config")) { + override fun tickInner() { + super.tickInner() + + if (!isEverFocused()) { + remove() + } + } + } + + val front = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.FRONT]!!) + val back = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.BACK]!!) + val left = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.LEFT]!!) + val right = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.RIGHT]!!) + val top = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.TOP]!!) + val bottom = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.BOTTOM]!!) + + if (inputs.pull.test(minecraft.player)) { + val pull = LargeBooleanRectangleButtonPanel( + screen, + frame, + skinElementActive = Widgets18.PULL, + skinElementInactive = Widgets18.PULL_DISABLED, + prop = inputs.pull, + ) + + pull.tooltip = TranslatableComponent("otm.gui.side_mode.pull") + + pull.x = 30f - 20f + pull.y = 14f + } + + if (inputs.push.test(minecraft.player)) { + val push = LargeBooleanRectangleButtonPanel( + screen, + frame, + skinElementActive = Widgets18.PUSH, + skinElementInactive = Widgets18.PUSH_DISABLED, + prop = inputs.push, + ) + + push.tooltip = TranslatableComponent("otm.gui.side_mode.push") + + push.x = 30f + 20f + push.y = 14f + } + + top.tooltip = TranslatableComponent("otm.gui.sides.top") + bottom.tooltip = TranslatableComponent("otm.gui.sides.bottom") + back.tooltip = TranslatableComponent("otm.gui.sides.back") + front.tooltip = TranslatableComponent("otm.gui.sides.front") + left.tooltip = TranslatableComponent("otm.gui.sides.left") + right.tooltip = TranslatableComponent("otm.gui.sides.right") + + top.x = 30f + top.y = 14f + + right.x = 30f - 20f + right.y = 14f + 20f + + left.x = 30f + 20f + left.y = 14f + 20f + + front.x = 30f + front.y = 14f + 20f + + bottom.x = 30f + bottom.y = 14f + 42f + + back.x = 30f - 20f + back.y = 14f + 42f + + screen.addPanel(frame) + + frame.requestFocus() + + return frame +} + fun > makeDeviceControls( screen: S, parent: FramePanel, - redstone: IPlayerInputWithFeedback? = null + redstone: IPlayerInputWithFeedback? = null, + itemConfig: ItemHandlerPlayerInput? = null ): EditablePanel { val panel = object : EditablePanel(screen, parent, width = LargeEnumRectangleButtonPanel.SIZE, height = 0f, x = parent.width + 3f) { override fun tickInner() { @@ -54,6 +163,23 @@ fun > makeDeviceControls( y += makeRedstoneSettingButton(screen, panel, y = y, control = redstone).height + 2f } + if (itemConfig != null) { + y += object : LargeRectangleButtonPanel(screen, panel, y = y, skinElement = Widgets18.ITEMS_CONFIGURATION) { + init { + tooltip = TranslatableComponent("otm.gui.sides.item_config") + } + + override fun onClick(mouseButton: Int) { + if (mouseButton == InputConstants.MOUSE_BUTTON_LEFT) { + val frame = makeItemHandlerControlPanel(screen, itemConfig) + + frame.x = absoluteX + width / 2f - frame.width / 2f + frame.y = absoluteY + height + 8f + } + } + }.height + 2f + } + panel.height = (y - 2f).coerceAtLeast(0f) return panel } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt index e6e8e65f2..b699f1bfb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt @@ -5,6 +5,7 @@ import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.ChatFormatting import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component +import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel @@ -14,7 +15,9 @@ import ru.dbotthepony.mc.otm.core.next import ru.dbotthepony.mc.otm.core.prev import ru.dbotthepony.mc.otm.core.util.EnumValueCodec import ru.dbotthepony.mc.otm.core.value +import ru.dbotthepony.mc.otm.menu.input.IPlayerInputWithFeedback import java.util.* +import java.util.function.Predicate import kotlin.collections.ArrayList abstract class EnumRectangleButtonPanel>( @@ -29,7 +32,19 @@ abstract class EnumRectangleButtonPanel>( val defaultValue: T, ) : RectangleButtonPanel(screen, parent, x, y, width, height, null) { val enum = EnumValueCodec.searchClass(enum) + private val constants: Array = enum.enumConstants private var isBuilding = true + var predicate: Predicate = Predicate { true } + + override var isDisabled: Boolean + get() { + if (prop is IPlayerInputWithFeedback) { + return !prop.test(minecraft.player) + } else { + return super.isDisabled + } + } + set(value) { super.isDisabled = value } data class Entry>( val key: T, @@ -40,30 +55,6 @@ abstract class EnumRectangleButtonPanel>( protected val enumMapping = EnumMap>(enum) - fun isFullyDefined(): Boolean { - if (!isBuilding) return true - - for (value in enum.enumConstants) { - if (enumMapping[value] == null) { - return false - } - } - - return true - } - - val missingValues: List get() { - val missing = ArrayList() - - for (value in enum.enumConstants) { - if (enumMapping[value] == null) { - missing.add(value) - } - } - - return missing - } - fun add(key: T, skinElement: AbstractMatterySprite? = null, tooltip: Component? = null, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumRectangleButtonPanel { return add(Entry(key = key, skinElement = skinElement, winding = winding, tooltip = tooltip)) } @@ -76,8 +67,9 @@ abstract class EnumRectangleButtonPanel>( } fun finish(): EnumRectangleButtonPanel { - check(isBuilding) { "Not building" } - check(isFullyDefined()) { "Not all enums having their mapping defined, missing are: ${missingValues.joinToString(", ")}" } + if (!isBuilding) return this + check(enumMapping.isNotEmpty()) { "No enums were defined, like, at all." } + check(enumMapping.containsKey(defaultValue)) { "Default value $defaultValue is missing from mapping" } isBuilding = false return this } @@ -85,7 +77,7 @@ abstract class EnumRectangleButtonPanel>( override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { check(!isBuilding) { "Still building this button!" } super.innerRender(stack, mouseX, mouseY, partialTick) - val entry = checkNotNull(enumMapping[prop.get()]) { "HOW" } + val entry = enumMapping[prop.get()] ?: return entry.skinElement?.render(stack, 0f, 0f, width, height, entry.winding) } @@ -106,9 +98,48 @@ abstract class EnumRectangleButtonPanel>( } override fun onClick(mouseButton: Int) { + check(!isBuilding) { "Still building this button!" } + if (enumMapping.size == 1) return + when (mouseButton) { - InputConstants.MOUSE_BUTTON_LEFT -> prop.value = prop.value.next(enum.enumConstants) - InputConstants.MOUSE_BUTTON_RIGHT -> prop.value = prop.value.prev(enum.enumConstants) + InputConstants.MOUSE_BUTTON_LEFT -> { + var i = constants.size + var ordinal = prop.value.ordinal + + while (i >= 0) { + i-- + ordinal++ + + if (ordinal >= constants.size) { + ordinal = 0 + } + + if (enumMapping.containsKey(constants[ordinal]) && predicate.test(constants[ordinal])) { + prop.value = constants[ordinal] + break + } + } + } + + InputConstants.MOUSE_BUTTON_RIGHT -> { + var i = constants.size + var ordinal = prop.value.ordinal + + while (i >= 0) { + i-- + ordinal-- + + if (ordinal < 0) { + ordinal = constants.size - 1 + } + + if (enumMapping.containsKey(constants[ordinal]) && predicate.test(constants[ordinal])) { + prop.value = constants[ordinal] + break + } + } + } + InputConstants.MOUSE_BUTTON_MIDDLE -> { if (prop.value != defaultValue) { prop.value = defaultValue @@ -122,7 +153,7 @@ abstract class EnumRectangleButtonPanel>( return super.innerRenderTooltips(stack, mouseX, mouseY, partialTick) } - if (tooltip == null && tooltipList == null && enumMapping.values.none { it.tooltip != null }) { + if (tooltip == null && tooltipList == null && enumMapping.entries.none { predicate.test(it.key) && it.value.tooltip != null }) { return super.innerRenderTooltips(stack, mouseX, mouseY, partialTick) } @@ -136,8 +167,8 @@ abstract class EnumRectangleButtonPanel>( listing.add(SPACE) } - for (entry in enumMapping.values) { - if (entry.tooltip != null) { + for ((k, entry) in enumMapping) { + if (entry.tooltip != null && predicate.test(k)) { listing.add(entry.tooltip.copy().withStyle(if (entry.key == prop.get()) ChatFormatting.WHITE else ChatFormatting.GRAY)) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeBooleanRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeBooleanRectangleButtonPanel.kt index 0c70d2968..531f520cc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeBooleanRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeBooleanRectangleButtonPanel.kt @@ -1,10 +1,12 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.GetterSetter +import ru.dbotthepony.mc.otm.menu.input.IPlayerInputWithFeedback open class LargeBooleanRectangleButtonPanel( screen: S, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeEnumRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeEnumRectangleButtonPanel.kt index 2e0925ad0..d4bff231b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeEnumRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeEnumRectangleButtonPanel.kt @@ -1,9 +1,11 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.GetterSetter +import ru.dbotthepony.mc.otm.menu.input.IPlayerInputWithFeedback open class LargeEnumRectangleButtonPanel>( screen: S, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/CobblerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/CobblerScreen.kt index ae546eff5..d50eb7f5a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/CobblerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/CobblerScreen.kt @@ -20,7 +20,7 @@ class CobblerScreen(menu: CobblerMenu, inventory: Inventory, title: Component) : for (column in 0 .. 2) SlotPanel(this, frame, menu.storageSlots[row * 3 + column], 80f + column * AbstractSlotPanel.SIZE, 26f + row * AbstractSlotPanel.SIZE) - makeDeviceControls(this, frame, redstone = menu.redstone) + makeDeviceControls(this, frame, redstone = menu.redstone, itemConfig = menu.itemConfig) return frame } 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 a7eed1b49..fc6e51c1b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -4,6 +4,7 @@ package ru.dbotthepony.mc.otm.core import com.google.common.collect.ImmutableList +import com.google.common.collect.ImmutableMap import com.google.gson.JsonElement import com.google.gson.JsonObject import com.google.gson.JsonPrimitive @@ -128,6 +129,12 @@ inline fun ImmutableList(size: Int, initializer: (index: Int) -> T): I } } +inline fun immutableMap(initializer: ImmutableMap.Builder.() -> Unit): ImmutableMap { + val builder = ImmutableMap.Builder() + initializer.invoke(builder) + return builder.build() +} + fun IForgeRegistry.getID(value: T): Int { return (this as ForgeRegistry).getID(value) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ConditionalSet.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ConditionalSet.kt index 04e3ff6e7..781f9ef47 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ConditionalSet.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ConditionalSet.kt @@ -1,5 +1,7 @@ package ru.dbotthepony.mc.otm.core.collect +import java.util.stream.Stream + class ConditionalSet : AbstractSet { // method without boxing fun interface Condition { @@ -16,6 +18,10 @@ class ConditionalSet : AbstractSet { this.getters = Array(getters.size) { getters[it] } } + constructor(getters: Stream>) : super() { + this.getters = getters.toArray { arrayOfNulls>(it) } + } + override val size: Int get() { var i = 0 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt index 44c2ddc36..81a89bdcd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt @@ -6,6 +6,7 @@ import net.minecraft.nbt.DoubleTag import net.minecraft.nbt.FloatTag import net.minecraft.nbt.IntTag import net.minecraft.nbt.NumericTag +import net.minecraft.nbt.StringTag import net.minecraft.nbt.Tag import net.minecraftforge.common.util.INBTSerializable import ru.dbotthepony.mc.otm.core.GetterSetter @@ -32,6 +33,10 @@ class Savetables : INBTSerializable { return stateful(getter, name, T::class.java) } + inline fun , reified T : Tag> stateful(getter: V, name: String): Stateful { + return stateful(getter, name, T::class.java) + } + inline fun , reified T : Tag> stateful(getter: KProperty0, name: String = getter.name): Stateful { return stateful(getter, name, T::class.java) } @@ -42,6 +47,12 @@ class Savetables : INBTSerializable { .withDeserializer { v, t -> v.deserializeNBT(t) } } + fun , T : Tag> stateful(getter: V, name: String, type: Class): Stateful { + return Stateful({ getter }, name, type) + .withSerializer { it.serializeNBT() } + .withDeserializer { v, t -> v.deserializeNBT(t) } + } + fun , T : Tag> stateful(getter: KProperty0, name: String = getter.name, type: Class): Stateful { return Stateful(getter, name, type) .withSerializer { it.serializeNBT() } @@ -124,6 +135,18 @@ class Savetables : INBTSerializable { .withDeserializer { it.asByte > 0 } } + fun > enum(prop: GetterSetter, name: String, map: (String) -> E): Stateless { + return Stateless(prop, name, StringTag::class.java) + .withSerializer { StringTag.valueOf(it.name) } + .withDeserializer { map.invoke(it.asString) } + } + + fun > enum(prop: KMutableProperty0, name: String = prop.name, map: (String) -> E): Stateless { + return Stateless(prop, name, StringTag::class.java) + .withSerializer { StringTag.valueOf(it.name) } + .withDeserializer { map.invoke(it.asString) } + } + override fun serializeNBT(): CompoundTag { return CompoundTag().also(::serializeNBT) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt index dcdb6134c..f244f5381 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt @@ -5,6 +5,8 @@ import org.apache.logging.log4j.LogManager class TickList { private val conditional = ArrayDeque() private val once = ArrayDeque() + private val always = ArrayList() + private val alwaysValveTime = ArrayList() private val conditionalValveTime = ArrayList() private val onceValveTime = ArrayList() @@ -27,6 +29,14 @@ class TickList { } } + fun always(ticker: ITickable) { + if (inTicker) { + alwaysValveTime.add(ticker) + } else { + always.add(ticker) + } + } + fun add(ticker: IConditionalTickable, condition: Boolean, reason: String) { if (!condition) { LOGGER.error("Refusing to add tickable $ticker because we $reason", IllegalStateException(reason)) @@ -79,6 +89,13 @@ class TickList { once.clear() + for (ticker in always) { + ticker.tick() + } + + always.addAll(alwaysValveTime) + alwaysValveTime.clear() + for (ticker in conditionalValveTime) { conditional.addFirst(ticker) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt new file mode 100644 index 000000000..2c96cea3a --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt @@ -0,0 +1,66 @@ +package ru.dbotthepony.mc.otm.menu.input + +import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity +import ru.dbotthepony.mc.otm.core.immutableMap +import ru.dbotthepony.mc.otm.core.math.RelativeSide +import ru.dbotthepony.mc.otm.menu.MatteryMenu + +class ItemHandlerPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = true, val allowPush: Boolean = true) { + inner class Piece(val side: RelativeSide) { + var isPresent by menu.mSynchronizer.bool() + private set + + private val allowedFlags = MatteryDeviceBlockEntity.ItemHandlerView.values().map { menu.mSynchronizer.bool() to it } + + fun isAllowed(value: MatteryDeviceBlockEntity.ItemHandlerView) = allowedFlags[value.ordinal].first.value + + val pull = BooleanInputWithFeedback(menu) + val push = BooleanInputWithFeedback(menu) + val input = EnumInputWithFeedback(menu) + + var default by menu.mSynchronizer.enum(MatteryDeviceBlockEntity.ItemHandlerView.DISABLED) + + init { + pull.filter { allowPull } + push.filter { allowPush } + } + + fun configure(config: MatteryDeviceBlockEntity.ConfigurableItemHandler) { + isPresent = true + + for ((f, v) in allowedFlags) { + f.value = v in config.possibleViews + } + + pull.with(config::automatePull) + push.with(config::automatePush) + input.withSupplier { config.mode }.withConsumer { if (it in config.possibleViews) config.mode = it } + } + } + + val pieces = immutableMap { for (side in RelativeSide.values()) put(side, Piece(side)) } + + // TODO + val pull = BooleanInputWithFeedback(menu) + + // TODO + val push = BooleanInputWithFeedback(menu) + + init { + pull.filter { allowPull } + push.filter { allowPush } + } + + fun configure(config: MatteryDeviceBlockEntity.GlobalItemHandler) { + for ((side, v) in config.sides) { + pieces[side]!!.configure(v) + pieces[side]!!.default = config.defaults[side]!! + } + + pull.withSupplier { pieces.values.all { it.pull.value } } + push.withSupplier { pieces.values.all { it.push.value } } + + pull.withConsumer { v -> pieces.values.forEach { it.pull.input.input(v) } } + push.withConsumer { v -> pieces.values.forEach { it.push.input.input(v) } } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt index 0ee1adb62..bb14c3f44 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt @@ -8,6 +8,7 @@ import ru.dbotthepony.mc.otm.core.ImmutableList import ru.dbotthepony.mc.otm.menu.MachineOutputSlot import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -18,6 +19,7 @@ class CobblerMenu @JvmOverloads constructor( ) : MatteryMenu(MMenus.COBBLESTONE_GENERATOR, p_38852_, inventory, tile) { override val storageSlots = (tile?.droppableContainer ?: SimpleContainer(CobblerBlockEntity.CONTAINER_SIZE)).let { c -> ImmutableList(c.containerSize) { addSlot(MachineOutputSlot(c, it)) } } val redstone = EnumInputWithFeedback(this) + val itemConfig = ItemHandlerPlayerInput(this, false, false) val progress: ProgressGaugeWidget @@ -27,6 +29,7 @@ class CobblerMenu @JvmOverloads constructor( else { progress = ProgressGaugeWidget(this, tile::workProgress, tile::isUnableToProcess) redstone.with(tile.redstoneControl::redstoneSetting) + itemConfig.configure(tile.itemConfig) } addInventorySlots() diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.png new file mode 100644 index 0000000000000000000000000000000000000000..4e8c82af21ad5c8ef2ea86deab904017db6e1706 GIT binary patch literal 1140 zcmV-)1dIELP)EX>4Tx04R}tkv&MmKpe$iQ>9WW9qb_DkfAzR5ET(8sbUcS}bq^n3?_xa5``n+SUn!Uj@QK88OgAjz4dUrd zOXs{#9ARZiAwDM_Gw6cEk6f2se&bwnSm2ovBb%Nlju4BbE|$BPl?|16ia4sM8s!T) zmle)ioYiWbweQJa7%FHh8LrbDMgmJnA_WmL>ZqU!3o%+XQcR?2Kknfla{MWB$>gel zkz)ZhsE`~#_#gc4)+|m=xJjWn(EDQBA0t3u7icwX`}^3oTPJ}38Mx9q{#p~5`6Rv3 z(V|B{cpJF5?r8EJaJd5vKIxJnIg+2IP%HxPXY@^ZVBi)AuDQLn_i_3FWT~s=8{ps& z7%fruy2rcwx_kTgOuN4ycTsYwv&K?z00006VoOIv00000008+zyMF)x010qNS#tmY z4#NNd4#NS*Z>VGd000McNliru=K>NDI{;=AYmoo|0&z)1K~#9!?V3GH12GuKpM-u0 z7YD(i(4|8c!J(Ur6nZ!beuLV@sW^*Mm+ChVoTP%dxC<^Fx)dA)2N%CZTzsi%F8Aav zx!3;>N{_oXKKb2~Jjq!i0D^LKqv+^HHMakf@fr2~%Ea5Wqu!>S%2)DR$}tJaLk<7{fGTp@@w18Czh9`T z$0O4Q^Ky8o>MmzPkgJ?HNp+D!L?m2;Io{d%J-&T^r>oWf#}{dXc^>wJ4>`W$aeCaL z%V`3!cTK+&>%(d9@lkM7TF;EMLrjk+?GST~N7~ZUB!`nZoFF(uh$DqFggEiUwIh>) zGGz{@b9IpW^P9<5d?gNTThiwo85oeS4%w#h^LeENN!Q_%G_)F#K|avu zpeTxz>3rGeApAzrC4-iWi|@PnMD%;C^LK6Z!T&@3e!r5-0c4O%2H7TH?)s>1NPR{8 zBSL@2Ud)1RL8xyvYP%O}@_q{d000000000000000C<9-7hP+@g# zX}z+(kuMlFwXwFike@ccnTvEUMs&~Q%}=^-H0ldW<=R?)W*V(^NDGvy&04vcFV~i? zuQbGCeRZ|5(#)IjA=wuX50-llHRlUoNqpk-)Mq|V@B4iC1)q<+>GM-JeSZ2UpO63M z^NHVmeopdrw8?4+Nv;OU&6R3HMhrlbZ4Eso@=Nb>Wkn#d%jk3nZAUkAwMJbK(>gHv7r|GJfzsCm$@n#gu~{mXkH-P7<5t^xtysKxSN6P6xix+@I$HkNUruQIl23 z(PSgU#pc_kFNzM2kM=hZuad*EhF?YEKlO6_(h(f(6)lvPWjmZH^qy_Bd+ zZyjG<%5-#yr%DO*gt}kqn4f4vYM^vk=69LjO?wV}-)#@PFY_bsx$U+m6MD+3uBdLb zTCck@zpLu_YB%HQ5Kp-Ybmn(G^AnBvT{FMO{9by?f$w|mfp=tnVz8B zMAw&Pku4%*M`X*j`eyU3_01+sI{Rr`TncWs*CRlVl~5b}GNjlf1lwZphloB*gTGjN z0SJ$>Ek;zVlr>vKwu!FBO6h76dy@V%B=RU@62X`(@`$nNQb7^LC5lTFmnZ;INEc&n zx`?Ms6qhJ)hjB3g>W?7`K4R0ZiQ*B(BZ@~9U?oHp&qVQv;t>VzFfInn{4qqqM{L?N zQ8ZCBQ8ZBu=n}|cBLXE^!yWV(0P_2Zz<9A~U69n+JPMdn{Rtzfta6*Z!bsj)LT%`; zkYXP{fKldLL?5P%c{i3m08k~tRgzvM=~b4_5Qzpx20{i-$3mz`gd!1&L?{x$5D|co zfscXGvG6%AfsmP|Lm;QY5Y0__&Q2yy!hghm)mHXl}EFA zkb@~Hs1Rd6fk19hTCX4o&Ky4o|Fr&UCAfX~V9Z3g^w>UzP2{Z)%ehO6cS-RsDc&W; zyQFxR6n7=FFxz--~HeTC!ZR6FIj2EX-yogs3uOePWyi6&((b4Jphw}l+lY0T91Ofm60FxgMkdvwcPyq{)4;lgkCzG%X76Jo5 QlP?3wlOqm{vy2276*y55iU0rr delta 53 zcmV-50LuTQGo&++h5>Amhw}l!lY0T9lOqm{ld=L(0Rxf`8Uh0!lduaG0s}XbHv`F& L9s-oJj06}J4g(Qr From 3f8cf5abe6c48b335f9f192bfe8d7cfa65b06993 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 19 Feb 2023 01:08:56 +0700 Subject: [PATCH 0213/1199] Move slash in texture 1 pixel up --- .../textures/gui/widgets/side_controls.png | Bin 1140 -> 1146 bytes .../textures/gui/widgets/side_controls.xcf | Bin 6919 -> 6919 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.png index 4e8c82af21ad5c8ef2ea86deab904017db6e1706..64b4f0f003bc85d4c9d0d4463626bc6b0bb67bbb 100644 GIT binary patch delta 675 zcmV;U0$ly{2>J-H^sW^*Mm+ChtI7tO@aWA-Z=pr}>4qf~f=Tfy^FPHa{yChA150r*W zdVTN7d;i)H0T7gviK3HMyP=HF5iSnhF+c* zH&0)}BttJRWRTuw8isX`idhf+D}Oi>xnx4zl&+V*Kive0XCs3+4bMvsx8b4W#C9>8 zfIQ`J1ca1h9fN;NB8re>6A@ZY;vl^)q)0g?A$iCF006L!T(pumk*~d8;x&hlbCp*- z9MZ%iv&gYYs)C#iL9Ur|@cb;QEQg3lxCC>$yZd{5|M^KoM7MAMf4)c?%RGi3a1Nk;)$zA z+JcJ9oH|JouCtY|v@b*V;nZVnxXXa7H?AzRPq106uCo?NpwnQ6cKd zB8OcMX9MbM`Co=@M2LC-03g^j?}Nc$kZQ0SkH@9_pR3_}KW{df?YIm-L>p5FyL{UUUMAPYXs{~2c?vvEDYLP)c z(8r)Cij=9m>|+p~QFO_m#r%48H(!W;k9GdeoiF)c)a`b+ayftua>*du0L)zN{_oX zKKb2~Jjq!i0D^LKqv+^HHMakf@fr2~%Ea5Wqu!>S%2kJzEKr4E=mw zTt0jXlMMZQA(M2KX&Kf%DrP3CjpxE&8ACw7S0 z1mr1)BOs(4>l}Y%5>bR4n~2bI5+~_(Aw|kD3CTka004k0a@z5;iQK!(+2Z$ zc&O?wXG4&yoH$8!kwZizT!T5@+4()beSfE`)&IvAX@hwl_Jj{PzTS?^p~s!z}=*2HSXs$!gK)wCfd)0XlqoeI%T7CE+d zB;+`>le7T^0D#bCJ}cw#IMqBho6So3f3BAAm22JD_;tti_7m%iqmKhG8Id;Q3K8@? z?1?V>tLJ~-9<5d?gNTThiwo85oeS4%w#h^LeENN!Q_%G_)F#K|avupeTxz z>3rGeApAzrC4-iWi|@PnMD%;C^LK6Z!T&@3e!r5-0c4O%2H7TH?)s>1NPR{8BSL@2 zUd)1RL8xyvYP%O}@_q{d000000000000000C<7H=e298I7TLa900000NkvXXu0mjf DBGWy7 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.xcf b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.xcf index a44512a59bf824667b346690604fb565a7f7689e..4be0c0acb8f8d16e645a517b35d7ba3c5aae1f0d 100644 GIT binary patch delta 162 zcmZoSYd4#a!DziPQ$?^Ogj1@qZ7!&`5%?`eRxK&BWIf5+wyei0_dxljoX#+_hs!Hb(O R3K}v_4&|A$xlg!~9RL|2A8`Nx From 5db3d665f0821e636ad4ed81c226035d20263f4a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 19 Feb 2023 11:25:24 +0700 Subject: [PATCH 0214/1199] Get things a little cleanup after recent commits --- .../mc/otm/block/IDroppableContainer.kt | 21 -- .../dbotthepony/mc/otm/block/MatteryBlock.kt | 9 +- .../mc/otm/block/entity/MatteryBlockEntity.kt | 13 + .../block/entity/MatteryDeviceBlockEntity.kt | 287 +++++++++--------- .../block/entity/MatteryPoweredBlockEntity.kt | 2 +- .../decorative/CargoCrateBlockEntity.kt | 17 +- .../entity/matter/MatterBottlerBlockEntity.kt | 7 +- .../matter/MatterCapacitorBankBlockEntity.kt | 7 +- .../matter/MatterDecomposerBlockEntity.kt | 6 +- .../matter/MatterRecyclerBlockEntity.kt | 6 +- .../matter/MatterReplicatorBlockEntity.kt | 6 +- .../entity/matter/MatterScannerBlockEntity.kt | 7 +- .../matter/PatternStorageBlockEntity.kt | 6 +- .../entity/storage/DriveRackBlockEntity.kt | 2 +- .../entity/storage/DriveViewerBlockEntity.kt | 14 +- .../entity/storage/StorageBusBlockEntity.kt | 3 - .../block/entity/storage/StorageInterfaces.kt | 4 +- .../entity/tech/BatteryBankBlockEntity.kt | 8 +- .../tech/ChemicalGeneratorBlockEntity.kt | 6 +- .../block/entity/tech/CobblerBlockEntity.kt | 13 +- .../entity/tech/EnergyServoBlockEntity.kt | 8 +- .../tech/GravitationStabilizerBlockEntity.kt | 9 +- .../entity/tech/PlatePressBlockEntity.kt | 6 +- .../client/screen/panels/button/Buttons.kt | 15 +- .../otm/menu/input/ItemHandlerPlayerInput.kt | 17 +- .../mc/otm/menu/tech/CobblerMenu.kt | 2 +- 26 files changed, 211 insertions(+), 290 deletions(-) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/IDroppableContainer.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/IDroppableContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/IDroppableContainer.kt deleted file mode 100644 index e542b303f..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/IDroppableContainer.kt +++ /dev/null @@ -1,21 +0,0 @@ -package ru.dbotthepony.mc.otm.block - -import net.minecraft.core.BlockPos -import net.minecraft.world.Container -import net.minecraft.world.entity.player.Player -import net.minecraft.world.level.Level -import net.minecraft.world.level.block.state.BlockState - -interface IDroppableContainer { - val droppableContainer: Container - - fun beforeDroppingItems( - oldBlockState: BlockState, - level: Level, - blockPos: BlockPos, - newBlockState: BlockState, - movedByPiston: Boolean - ) {} - - fun beforeDestroyedByPlayer(level: Level, blockPos: BlockPos, blockState: BlockState, player: Player) {} -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt index c86a94288..143fc75aa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt @@ -195,9 +195,12 @@ abstract class MatteryBlock @JvmOverloads constructor( if (!oldBlockState.`is`(newBlockState.block)) { val blockentity = level.getBlockEntity(blockPos) - if (blockentity is IDroppableContainer) { + if (blockentity is MatteryBlockEntity) { blockentity.beforeDroppingItems(oldBlockState, level, blockPos, newBlockState, movedByPiston) - Containers.dropContents(level, blockPos, blockentity.droppableContainer) + + for (container in blockentity.droppableContainers) + Containers.dropContents(level, blockPos, container) + level.updateNeighbourForOutputSignal(blockPos, this) } } @@ -211,7 +214,7 @@ abstract class MatteryBlock @JvmOverloads constructor( val blockentity = level.getBlockEntity(blockPos) - if (blockentity is IDroppableContainer) { + if (blockentity is MatteryBlockEntity) { blockentity.beforeDestroyedByPlayer(level, blockPos, blockState, player) } } 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 d2f74287d..58f61a93d 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 @@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableSet import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import it.unimi.dsi.fastutil.longs.Long2ObjectFunction import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap +import it.unimi.dsi.fastutil.objects.ObjectArraySet import it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.core.BlockPos @@ -14,6 +15,8 @@ import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.Tag import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerPlayer +import net.minecraft.world.Container +import net.minecraft.world.entity.player.Player import net.minecraft.world.item.ItemStack import net.minecraft.world.level.ChunkPos import net.minecraft.world.level.Level @@ -87,6 +90,16 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc return blockState[(blockState.block as? RotatableMatteryBlock ?: return BlockRotation.NORTH).rotationProperty] } + private val _droppableContainers = ObjectArraySet() + val droppableContainers: Set = Collections.unmodifiableSet(_droppableContainers) + + protected fun addDroppableContainer(container: Container) { + _droppableContainers.add(container) + } + + open fun beforeDroppingItems(oldBlockState: BlockState, level: Level, blockPos: BlockPos, newBlockState: BlockState, movedByPiston: Boolean) {} + open fun beforeDestroyedByPlayer(level: Level, blockPos: BlockPos, blockState: BlockState, player: Player) {} + private val _sides = EnumMap(RelativeSide::class.java) val sides: Map = Collections.unmodifiableMap(_sides) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index 9366184be..08d71f8fc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -5,18 +5,12 @@ import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.core.BlockPos import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.MenuProvider -import java.lang.Runnable -import net.minecraft.server.level.ServerLevel -import net.minecraft.client.multiplayer.ClientLevel -import net.minecraft.core.SectionPos import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.nbt.CompoundTag import net.minecraft.network.chat.Component import net.minecraft.world.item.ItemStack -import net.minecraft.world.level.Level -import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.items.IItemHandler import ru.dbotthepony.mc.otm.capability.CombinedItemHandler @@ -32,7 +26,6 @@ import ru.dbotthepony.mc.otm.core.nbt.getJson import ru.dbotthepony.mc.otm.core.nbt.putJson import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.ITickable -import ru.dbotthepony.mc.otm.oncePre /** * Device block entity base, implementing [MenuProvider] and [IRedstoneControlled], and also tracks custom display name @@ -75,8 +68,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo redstoneControl.deserializeNBT(nbt[REDSTONE_CONTROL_KEY] as? CompoundTag) } - - enum class ItemHandlerView(val translationKey: String) { + enum class ItemHandlerMode(val translationKey: String) { DISABLED("otm.gui.side_mode.disabled"), INPUT("otm.gui.side_mode.input"), OUTPUT("otm.gui.side_mode.output"), @@ -84,16 +76,16 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo BATTERY("otm.gui.side_mode.battery"); } - inner class GlobalItemHandler( + inner class ConfigurableItemHandler( input: IItemHandler? = null, output: IItemHandler? = null, battery: IItemHandler? = null, - val frontDefault: ItemHandlerView = determineDefaultMode(input, output), - val backDefault: ItemHandlerView = determineDefaultMode(input, output), - val leftDefault: ItemHandlerView = determineDefaultMode(input, output), - val rightDefault: ItemHandlerView = determineDefaultMode(input, output), - val topDefault: ItemHandlerView = determineDefaultMode(input, output), - val bottomDefault: ItemHandlerView = determineDefaultMode(input, output), + val frontDefault: ItemHandlerMode = determineDefaultMode(input, output), + val backDefault: ItemHandlerMode = determineDefaultMode(input, output), + val leftDefault: ItemHandlerMode = determineDefaultMode(input, output), + val rightDefault: ItemHandlerMode = determineDefaultMode(input, output), + val topDefault: ItemHandlerMode = determineDefaultMode(input, output), + val bottomDefault: ItemHandlerMode = determineDefaultMode(input, output), ) { val sideless: IItemHandler @@ -108,20 +100,20 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo exposeSideless(ForgeCapabilities.ITEM_HANDLER, sideless) } - val front = ConfigurableItemHandler(RelativeSide.FRONT, input, output, battery).also { it.mode = frontDefault } - val back = ConfigurableItemHandler(RelativeSide.BACK, input, output, battery).also { it.mode = backDefault } - val left = ConfigurableItemHandler(RelativeSide.LEFT, input, output, battery).also { it.mode = leftDefault } - val right = ConfigurableItemHandler(RelativeSide.RIGHT, input, output, battery).also { it.mode = rightDefault } - val top = ConfigurableItemHandler(RelativeSide.TOP, input, output, battery).also { it.mode = topDefault } - val bottom = ConfigurableItemHandler(RelativeSide.BOTTOM, input, output, battery).also { it.mode = bottomDefault } + val front = Piece(RelativeSide.FRONT, input, output, battery).also { it.mode = frontDefault } + val back = Piece(RelativeSide.BACK, input, output, battery).also { it.mode = backDefault } + val left = Piece(RelativeSide.LEFT, input, output, battery).also { it.mode = leftDefault } + val right = Piece(RelativeSide.RIGHT, input, output, battery).also { it.mode = rightDefault } + val top = Piece(RelativeSide.TOP, input, output, battery).also { it.mode = topDefault } + val bottom = Piece(RelativeSide.BOTTOM, input, output, battery).also { it.mode = bottomDefault } val sides = immutableMap { - put(RelativeSide.FRONT, this@GlobalItemHandler.front) - put(RelativeSide.BACK, this@GlobalItemHandler.back) - put(RelativeSide.LEFT, this@GlobalItemHandler.left) - put(RelativeSide.RIGHT, this@GlobalItemHandler.right) - put(RelativeSide.TOP, this@GlobalItemHandler.top) - put(RelativeSide.BOTTOM, this@GlobalItemHandler.bottom) + put(RelativeSide.FRONT, front) + put(RelativeSide.BACK, back) + put(RelativeSide.LEFT, left) + put(RelativeSide.RIGHT, right) + put(RelativeSide.TOP, top) + put(RelativeSide.BOTTOM, bottom) } val defaults = immutableMap { @@ -132,173 +124,172 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo put(RelativeSide.TOP, topDefault) put(RelativeSide.BOTTOM, bottomDefault) } - } - inner class ConfigurableItemHandler( - side: RelativeSide, - val input: IItemHandler? = null, - val output: IItemHandler? = null, - val battery: IItemHandler? = null, - ) : IItemHandler, ITickable { - private var currentHandler: IItemHandler = EmptyItemHandler - val capController = sides[side]!!.Cap(ForgeCapabilities.ITEM_HANDLER, this) - private val neighbour by sides[side]!!.track(ForgeCapabilities.ITEM_HANDLER) + inner class Piece( + side: RelativeSide, + val input: IItemHandler? = null, + val output: IItemHandler? = null, + val battery: IItemHandler? = null, + ) : IItemHandler, ITickable { + private var currentHandler: IItemHandler = EmptyItemHandler + val capController = this@MatteryDeviceBlockEntity.sides[side]!!.Cap(ForgeCapabilities.ITEM_HANDLER, this) + private val neighbour by this@MatteryDeviceBlockEntity.sides[side]!!.track(ForgeCapabilities.ITEM_HANDLER) - val possibleViews: ImmutableSet - val inputOutput: IItemHandler? + val possibleViews: ImmutableSet + val inputOutput: IItemHandler? - init { - tickList.always(this) + init { + tickList.always(this) - val builder = ImmutableSet.Builder() + val builder = ImmutableSet.Builder() - builder.add(ItemHandlerView.DISABLED) + builder.add(ItemHandlerMode.DISABLED) - if (input != null) builder.add(ItemHandlerView.INPUT) - if (output != null) builder.add(ItemHandlerView.OUTPUT) - if (input != null && output != null) builder.add(ItemHandlerView.INPUT_OUTPUT) - if (battery != null) builder.add(ItemHandlerView.BATTERY) + if (input != null) builder.add(ItemHandlerMode.INPUT) + if (output != null) builder.add(ItemHandlerMode.OUTPUT) + if (input != null && output != null) builder.add(ItemHandlerMode.INPUT_OUTPUT) + if (battery != null) builder.add(ItemHandlerMode.BATTERY) - possibleViews = builder.build() + possibleViews = builder.build() - capController.close() + capController.close() - if (input != null && output != null) { - inputOutput = CombinedItemHandler(input, output) - } else { - inputOutput = null - } - } - - var mode by synchronizer.enum(ItemHandlerView.DISABLED, setter = { value, access, setByRemote -> - require(value in possibleViews) { "View type $value is not allowed (allowed views: $possibleViews)" } - - if (access.read() != value) { - access.write(value) - - if (value == ItemHandlerView.DISABLED) { - capController.close() + if (input != null && output != null) { + inputOutput = CombinedItemHandler(input, output) } else { - capController.close() - capController.expose() - } - - when (value) { - ItemHandlerView.DISABLED -> currentHandler = EmptyItemHandler - ItemHandlerView.INPUT -> currentHandler = input!! - ItemHandlerView.OUTPUT -> currentHandler = output!! - ItemHandlerView.INPUT_OUTPUT -> currentHandler = inputOutput!! - ItemHandlerView.BATTERY -> currentHandler = battery!! + inputOutput = null } } - }) - var automatePull = false - set(value) { - if (field != value) { - field = value + var mode by synchronizer.enum(ItemHandlerMode.DISABLED, setter = { value, access, setByRemote -> + require(value in possibleViews) { "View type $value is not allowed (allowed views: $possibleViews)" } - if (value) { - innerSlotPull = 0 - outerSlotPull = 0 + if (access.read() != value) { + access.write(value) + + if (value == ItemHandlerMode.DISABLED) { + capController.close() + } else { + capController.close() + capController.expose() + } + + when (value) { + ItemHandlerMode.DISABLED -> currentHandler = EmptyItemHandler + ItemHandlerMode.INPUT -> currentHandler = input!! + ItemHandlerMode.OUTPUT -> currentHandler = output!! + ItemHandlerMode.INPUT_OUTPUT -> currentHandler = inputOutput!! + ItemHandlerMode.BATTERY -> currentHandler = battery!! } } - } + }) - var automatePush = false - set(value) { - if (field != value) { - field = value + var automatePull = false + set(value) { + if (field != value) { + field = value - if (value) { - innerSlotPush = 0 - outerSlotPush = 0 + if (value) { + innerSlotPull = 0 + outerSlotPull = 0 + } } } + + var automatePush = false + set(value) { + if (field != value) { + field = value + + if (value) { + innerSlotPush = 0 + outerSlotPush = 0 + } + } + } + + init { + savetables.bool(::automatePull, "itemhandler_${side}_automatePull") + savetables.bool(::automatePush, "itemhandler_${side}_automatePush") + savetables.enum(::mode, "itemhandler_${side}_mode", ItemHandlerMode::valueOf) } - init { - savetables.bool(::automatePull, "itemhandler_${side}_automatePull") - savetables.bool(::automatePush, "itemhandler_${side}_automatePush") - savetables.enum(::mode, "itemhandler_${side}_mode", ItemHandlerView::valueOf) - } + private var innerSlotPull = 0 + private var outerSlotPull = 0 - private var innerSlotPull = 0 - private var outerSlotPull = 0 + private var innerSlotPush = 0 + private var outerSlotPush = 0 - private var innerSlotPush = 0 - private var outerSlotPush = 0 - - override fun tick() { - if (mode == ItemHandlerView.DISABLED || currentHandler.slots == 0 || redstoneControl.isBlockedByRedstone) - return - - neighbour.ifPresentK { - if (it.slots == 0) + override fun tick() { + if (mode == ItemHandlerMode.DISABLED || currentHandler.slots == 0 || redstoneControl.isBlockedByRedstone) return - if (automatePull) { - if (innerSlotPull !in 0 until currentHandler.slots) - innerSlotPull = 0 + neighbour.ifPresentK { + if (it.slots == 0) + return - if (outerSlotPull !in 0 until it.slots) - outerSlotPull = 0 + if (automatePull) { + if (innerSlotPull !in 0 until currentHandler.slots) + innerSlotPull = 0 - val (outerSlotPull, innerSlotPull) = moveBetweenSlots(it, outerSlotPull, currentHandler, innerSlotPull) - this.innerSlotPull = innerSlotPull - this.outerSlotPull = outerSlotPull - } + if (outerSlotPull !in 0 until it.slots) + outerSlotPull = 0 - if (automatePush) { - if (innerSlotPush !in 0 until currentHandler.slots) - innerSlotPush = 0 + val (outerSlotPull, innerSlotPull) = moveBetweenSlots(it, outerSlotPull, currentHandler, innerSlotPull) + this.innerSlotPull = innerSlotPull + this.outerSlotPull = outerSlotPull + } - if (outerSlotPush !in 0 until it.slots) - outerSlotPush = 0 + if (automatePush) { + if (innerSlotPush !in 0 until currentHandler.slots) + innerSlotPush = 0 - val (innerSlotPush, outerSlotPush) = moveBetweenSlots(currentHandler, innerSlotPush, it, outerSlotPush) - this.innerSlotPush = innerSlotPush - this.outerSlotPush = outerSlotPush + if (outerSlotPush !in 0 until it.slots) + outerSlotPush = 0 + + val (innerSlotPush, outerSlotPush) = moveBetweenSlots(currentHandler, innerSlotPush, it, outerSlotPush) + this.innerSlotPush = innerSlotPush + this.outerSlotPush = outerSlotPush + } } } - } - override fun getSlots(): Int { - return currentHandler.slots - } + override fun getSlots(): Int { + return currentHandler.slots + } - override fun getStackInSlot(slot: Int): ItemStack { - return currentHandler.getStackInSlot(slot) - } + override fun getStackInSlot(slot: Int): ItemStack { + return currentHandler.getStackInSlot(slot) + } - override fun insertItem(slot: Int, stack: ItemStack, simulate: Boolean): ItemStack { - return currentHandler.insertItem(slot, stack, simulate) - } + override fun insertItem(slot: Int, stack: ItemStack, simulate: Boolean): ItemStack { + return currentHandler.insertItem(slot, stack, simulate) + } - override fun extractItem(slot: Int, amount: Int, simulate: Boolean): ItemStack { - return currentHandler.extractItem(slot, amount, simulate) - } + override fun extractItem(slot: Int, amount: Int, simulate: Boolean): ItemStack { + return currentHandler.extractItem(slot, amount, simulate) + } - override fun getSlotLimit(slot: Int): Int { - return currentHandler.getSlotLimit(slot) - } + override fun getSlotLimit(slot: Int): Int { + return currentHandler.getSlotLimit(slot) + } - override fun isItemValid(slot: Int, stack: ItemStack): Boolean { - return currentHandler.isItemValid(slot, stack) + override fun isItemValid(slot: Int, stack: ItemStack): Boolean { + return currentHandler.isItemValid(slot, stack) + } } } companion object { - - private fun determineDefaultMode(input: IItemHandler?, output: IItemHandler?): ItemHandlerView { + private fun determineDefaultMode(input: IItemHandler?, output: IItemHandler?): ItemHandlerMode { if (input == null && output == null) - return ItemHandlerView.DISABLED + return ItemHandlerMode.DISABLED else if (input != null && output != null) - return ItemHandlerView.INPUT_OUTPUT + return ItemHandlerMode.INPUT_OUTPUT else if (output != null) - return ItemHandlerView.OUTPUT + return ItemHandlerMode.OUTPUT else - return ItemHandlerView.INPUT + return ItemHandlerMode.INPUT } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt index fde001d37..ff5f138ae 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt @@ -27,7 +27,7 @@ import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set abstract class MatteryPoweredBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(p_155228_, p_155229_, p_155230_) { - val batteryContainer = MatteryContainer(::setChangedLight, 1) + val batteryContainer = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) init { savetable(::batteryContainer, BATTERY_KEY) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt index df2748903..e1bf6e0e6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt @@ -25,7 +25,6 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets import net.minecraft.world.level.storage.loot.parameters.LootContextParams import net.minecraft.world.phys.Vec3 import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock -import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.HandlerFilter @@ -39,8 +38,9 @@ import ru.dbotthepony.mc.otm.registry.MSoundEvents class CargoCrateBlockEntity( p_155229_: BlockPos, p_155230_: BlockState -) : MatteryDeviceBlockEntity(MBlockEntities.CARGO_CRATE, p_155229_, p_155230_), IDroppableContainer { - val container = MatteryContainer(this::setChanged, CAPACITY) +) : MatteryDeviceBlockEntity(MBlockEntities.CARGO_CRATE, p_155229_, p_155230_) { + val container = MatteryContainer(this::setChanged, CAPACITY).also(::addDroppableContainer) + private var interactingPlayers = 0 val handler = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { @@ -52,13 +52,7 @@ class CargoCrateBlockEntity( } }) - override fun beforeDroppingItems( - oldBlockState: BlockState, - level: Level, - blockPos: BlockPos, - newBlockState: BlockState, - movedByPiston: Boolean - ) { + override fun beforeDroppingItems(oldBlockState: BlockState, level: Level, blockPos: BlockPos, newBlockState: BlockState, movedByPiston: Boolean) { unpackLootTable() } @@ -69,9 +63,6 @@ class CargoCrateBlockEntity( var lootTable: ResourceLocation? = null var lootTableSeed: Long? = null - override val droppableContainer: Container - get() = container - fun onPlayerOpen() { val level = level diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index fc1fe4522..a92b0ed2c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -11,7 +11,6 @@ import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeConfigSpec import ru.dbotthepony.mc.otm.config.ConciseBalanceValues -import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState @@ -36,7 +35,7 @@ import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : - MatteryPoweredBlockEntity(MBlockEntities.MATTER_BOTTLER, p_155229_, p_155230_), IMatterGraphNode, IDroppableContainer { + MatteryPoweredBlockEntity(MBlockEntities.MATTER_BOTTLER, p_155229_, p_155230_), IMatterGraphNode { override val matterNode = Graph6Node(this) val energy = WorkerEnergyStorage(this, ENERGY_VALUES) @@ -85,9 +84,7 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : super.setChanged(slot, new, old) updateBlockState() } - } - - override val droppableContainer by ::container + }.also(::addDroppableContainer) val itemHandler = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt index b21812692..75750314b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt @@ -8,7 +8,6 @@ import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState -import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.BatteryBankBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection @@ -24,7 +23,7 @@ import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph import ru.dbotthepony.mc.otm.menu.matter.MatterCapacitorBankMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities -class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.MATTER_CAPACITOR_BANK, p_155229_, p_155230_), IMatterGraphNode, IMatterStorage, IDroppableContainer { +class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.MATTER_CAPACITOR_BANK, p_155229_, p_155230_), IMatterGraphNode, IMatterStorage { var gaugeLevel by synchronizer.float() private set @@ -129,14 +128,12 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) capacitorStatus[slot].value = new.getCapability(MatteryCapability.MATTER).isPresent gaugeLevel = (storedMatter / maxStoredMatter).toFloat() } - } + }.also(::addDroppableContainer) val capacitorStatus = ImmutableList(BatteryBankBlockEntity.CAPACITY) { synchronizer.bool(false, name = "capacitor$it") } - override val droppableContainer by ::container - init { savetable(::container, INVENTORY_KEY) exposeGlobally(MatteryCapability.MATTER, this) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index 90fdf93c6..f166e6842 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -11,7 +11,6 @@ import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeConfigSpec import ru.dbotthepony.mc.otm.config.ConciseBalanceValues -import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl @@ -92,7 +91,7 @@ fun moveMatterAsDustIntoContainer(_matterValue: Decimal, container: MatteryConta } class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) - : MatteryWorkerBlockEntity(MBlockEntities.MATTER_DECOMPOSER, pos, state, ::DecomposerJob), IMatterGraphNode, IDroppableContainer { + : MatteryWorkerBlockEntity(MBlockEntities.MATTER_DECOMPOSER, pos, state, ::DecomposerJob), IMatterGraphNode { class DecomposerJob : Job { val toDust: Boolean @@ -139,8 +138,7 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) } // вход, выход - val container = MatteryContainer(this::setChangedLight, 3) - override val droppableContainer by ::container + val container = MatteryContainer(this::setChangedLight, 3).also(::addDroppableContainer) val itemHandler = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index 1811434d7..db1279f35 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -12,7 +12,6 @@ import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeConfigSpec import net.minecraftforge.common.ForgeConfigSpec.ConfigValue import ru.dbotthepony.mc.otm.config.ConciseBalanceValues -import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl @@ -37,7 +36,7 @@ import ru.dbotthepony.mc.otm.core.math.getDecimal import ru.dbotthepony.mc.otm.core.math.set class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) - : MatteryWorkerBlockEntity(MBlockEntities.MATTER_RECYCLER, blockPos, blockState, ::RecyclerJob), IMatterGraphNode, IDroppableContainer { + : MatteryWorkerBlockEntity(MBlockEntities.MATTER_RECYCLER, blockPos, blockState, ::RecyclerJob), IMatterGraphNode { class RecyclerJob : Job { var totalMatter: Decimal @@ -71,9 +70,8 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) ::CAPACITY ) - val container = MatteryContainer(this::itemContainerUpdated, 1) + val container = MatteryContainer(this::itemContainerUpdated, 1).also(::addDroppableContainer) - override val droppableContainer by ::container override val matterNode = Graph6Node(this) val energy = WorkerEnergyStorage(this::powerLevelUpdated, ENERGY_CONFIG) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index ecc75250f..af96a49f5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -11,7 +11,6 @@ import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeConfigSpec import ru.dbotthepony.mc.otm.config.ConciseBalanceValues -import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl @@ -43,7 +42,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } catch(err: NoSuchElementException) { null } - }), IMatterGraphNode, IDroppableContainer { + }), IMatterGraphNode { class ReplicatorJob : ItemJob { val matterPerTick: Decimal @@ -101,9 +100,8 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val energy = WorkerEnergyStorage(this::powerLevelUpdated, ENERGY_VALUES) override val matterNode = Graph6Node(this) val matter = MatterStorageImpl(this::matterLevelUpdated, FlowDirection.INPUT, ::MATTER_CAPACITY) - val container = MatteryContainer(this::itemContainerUpdated, 5) + val container = MatteryContainer(this::itemContainerUpdated, 5).also(::addDroppableContainer) val itemHandler = container.handler(HandlerFilter.OnlyOut) - override val droppableContainer by ::container init { exposeEnergyGlobally(energy) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt index 907d8d2e4..2d31a57fb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt @@ -10,7 +10,6 @@ import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeConfigSpec import ru.dbotthepony.mc.otm.config.ConciseBalanceValues -import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.MatteryCapability @@ -34,9 +33,9 @@ import java.util.* import kotlin.math.pow class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : - MatteryWorkerBlockEntity(MBlockEntities.MATTER_SCANNER, p_155229_, p_155230_, ::ItemJob), IMatterGraphNode, IDroppableContainer { + MatteryWorkerBlockEntity(MBlockEntities.MATTER_SCANNER, p_155229_, p_155230_, ::ItemJob), IMatterGraphNode { - val container = MatteryContainer(this::itemContainerUpdated, 1) + val container = MatteryContainer(this::itemContainerUpdated, 1).also(::addDroppableContainer) val energy = WorkerEnergyStorage(this::powerLevelUpdated, ENERGY_VALUES) val itemHandler = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { @@ -48,8 +47,6 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } }) - override val droppableContainer by ::container - init { exposeItemsGlobally(itemHandler) exposeEnergyGlobally(energy) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt index 0e372ba60..fd6cbf42a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt @@ -16,7 +16,6 @@ import net.minecraft.MethodsReturnNonnullByDefault import net.minecraft.server.level.ServerLevel import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block -import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.matter.* import ru.dbotthepony.mc.otm.core.collect.iterator @@ -30,7 +29,7 @@ import java.util.stream.Stream @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : - MatteryDeviceBlockEntity(MBlockEntities.PATTERN_STORAGE, p_155229_, p_155230_), IMatterGraphNode, IPatternStorage, IDroppableContainer { + MatteryDeviceBlockEntity(MBlockEntities.PATTERN_STORAGE, p_155229_, p_155230_), IMatterGraphNode, IPatternStorage { override val matterNode = Graph6Node(this) @@ -60,7 +59,7 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : override fun getMaxStackSize(): Int { return 1 } - } + }.also(::addDroppableContainer) private fun updateBlockstate() { val level = level ?: return @@ -80,7 +79,6 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } private val itemHandler = container.handler { slot: Int, stack: ItemStack -> stack.getCapability(MatteryCapability.PATTERN).isPresent } - override val droppableContainer by ::container override fun setLevel(level: Level) { super.setLevel(level) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt index 7a7856fa3..caba91cdf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt @@ -39,7 +39,7 @@ class DriveRackBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : }.add(it) } } - } + }.also(::addDroppableContainer) val cell = BasicStorageGraphNode(energy) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt index 44c6c3eb1..9e8f3b45c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt @@ -1,9 +1,6 @@ package ru.dbotthepony.mc.otm.block.entity.storage import net.minecraft.core.BlockPos -import net.minecraft.nbt.CompoundTag -import net.minecraft.network.chat.Component -import net.minecraft.world.Container import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu @@ -11,8 +8,6 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.config.ServerConfig -import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.storage.DriveViewerBlock import ru.dbotthepony.mc.otm.block.entity.WorkerState @@ -21,12 +16,9 @@ import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.registry.MBlockEntities -import ru.dbotthepony.mc.otm.core.nbt.map -import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.menu.storage.DriveViewerMenu -import ru.dbotthepony.mc.otm.registry.MBlocks -class DriveViewerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.DRIVE_VIEWER, p_155229_, p_155230_), IDroppableContainer { +class DriveViewerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.DRIVE_VIEWER, p_155229_, p_155230_) { override fun setChanged() { super.setChanged() @@ -67,9 +59,7 @@ class DriveViewerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte } } } - } - - override val droppableContainer by ::container + }.also(::addDroppableContainer) init { savetable(::energy, ENERGY_KEY) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt index f2258b9f6..af2a6edbe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt @@ -66,9 +66,6 @@ private fun Long.clamp(): Int { } class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.STORAGE_BUS, blockPos, blockState) { - override val defaultDisplayName: Component - get() = MBlocks.STORAGE_BUS.name - override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { return StorageBusMenu(containerID, inventory, this) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt index f38b98c93..fe8120e81 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt @@ -113,9 +113,7 @@ abstract class AbstractStorageImportExport( } } -class StorageImporterBlockEntity(blockPos: BlockPos, blockState: BlockState) - : AbstractStorageImportExport(MBlockEntities.STORAGE_IMPORTER, blockPos, blockState), - IItemHandler { +class StorageImporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : AbstractStorageImportExport(MBlockEntities.STORAGE_IMPORTER, blockPos, blockState), IItemHandler { override val filter = ItemFilter(MAX_FILTERS) { _, _, _ -> setChangedLight() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index 6ae004b60..893e98528 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -7,7 +7,6 @@ import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.capabilities.ForgeCapabilities -import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.energy @@ -26,24 +25,23 @@ import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.menu.tech.BatteryBankMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities -class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.BATTERY_BANK, p_155229_, p_155230_), IDroppableContainer { +class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.BATTERY_BANK, p_155229_, p_155230_) { var gaugeLevel by synchronizer.float() private set // 6 на 2 - val container: MatteryContainer = object : MatteryContainer(this::setChanged, CAPACITY) { + val container: MatteryContainer = object : MatteryContainer(::setChanged, CAPACITY) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { super.setChanged(slot, new, old) batteryStatus[slot].value = new.getCapability(ForgeCapabilities.ENERGY).isPresent gaugeLevel = (energy.batteryLevel / energy.maxBatteryLevel).toFloat() } - } + }.also(::addDroppableContainer) val batteryStatus = ImmutableList(CAPACITY) { synchronizer.bool(false, name = "battery$it") } - override val droppableContainer by ::container private val itemHandler = container.handler( object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { 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 9cdd3c35c..ec0ed5821 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 @@ -11,7 +11,6 @@ import net.minecraftforge.common.ForgeConfigSpec import net.minecraftforge.common.ForgeHooks import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.energy.IEnergyStorage -import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.capability.* @@ -27,13 +26,12 @@ import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal -class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.CHEMICAL_GENERATOR, pos, state), IDroppableContainer { +class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.CHEMICAL_GENERATOR, pos, state) { override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { return ChemicalGeneratorMenu(containerID, inventory, this) } - val container = MatteryContainer(this::setChangedLight, SLOTS) - override val droppableContainer by ::container + val container = MatteryContainer(this::setChangedLight, SLOTS).also(::addDroppableContainer) val energy = GeneratorEnergyStorage(this::setChangedLight, CAPACITY, THROUGHPUT) val itemHandler = container.handler(object : HandlerFilter { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt index 499daad92..b163f84c3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt @@ -7,7 +7,6 @@ import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.level.block.state.BlockState -import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.HandlerFilter @@ -15,27 +14,27 @@ import ru.dbotthepony.mc.otm.menu.tech.CobblerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities class CobblerBlockEntity(blockPos: BlockPos, blockState: BlockState) - : MatteryWorkerBlockEntity(MBlockEntities.COBBLESTONE_GENERATOR, blockPos, blockState, ::ItemJob), IDroppableContainer { + : MatteryWorkerBlockEntity(MBlockEntities.COBBLESTONE_GENERATOR, blockPos, blockState, ::ItemJob) { override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { return CobblerMenu(containerID, inventory, this) } - override val droppableContainer = MatteryContainer(this::itemContainerUpdated, CONTAINER_SIZE) + val container = MatteryContainer(this::itemContainerUpdated, CONTAINER_SIZE).also(::addDroppableContainer) - val itemHandler = droppableContainer.handler(object : HandlerFilter { + val itemHandler = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { return false } }) - val itemConfig = GlobalItemHandler(output = itemHandler) + val itemConfig = ConfigurableItemHandler(output = itemHandler) init { - savetable(::droppableContainer, INVENTORY_KEY) + savetable(::container, INVENTORY_KEY) } override fun onJobFinish(job: ItemJob): Status { - if (!droppableContainer.fullyAddItem(job.itemStack)) { + if (!container.fullyAddItem(job.itemStack)) { return Status.FAILURE_ITEM } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt index 7cd689f7a..8936ba1d9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt @@ -8,7 +8,6 @@ import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.level.block.state.BlockState -import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage @@ -25,14 +24,11 @@ import ru.dbotthepony.mc.otm.menu.tech.EnergyServoMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlocks -class EnergyServoBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.ENERGY_SERVO, blockPos, blockState), IDroppableContainer { +class EnergyServoBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.ENERGY_SERVO, blockPos, blockState) { override val defaultDisplayName: Component get() = MBlocks.ENERGY_SERVO.name - val container = MatteryContainer(this::setChangedLight, 2) - - override val droppableContainer: Container - get() = container + val container = MatteryContainer(this::setChangedLight, 2).also(::addDroppableContainer) val itemHandler = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/GravitationStabilizerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/GravitationStabilizerBlockEntity.kt index 06eb3b533..bd2c70c3d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/GravitationStabilizerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/GravitationStabilizerBlockEntity.kt @@ -20,12 +20,7 @@ import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.core.math.times import ru.dbotthepony.mc.otm.registry.MBlockEntities -class GravitationStabilizerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity( - MBlockEntities.GRAVITATION_STABILIZER, p_155229_, p_155230_) { - - override val defaultDisplayName: Component - get() = MACHINE_NAME - +class GravitationStabilizerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.GRAVITATION_STABILIZER, p_155229_, p_155230_) { override fun createMenu(containerID: Int, inventory: Inventory, ply: Player) = null private var blackHole: BlackHoleBlockEntity? = null @@ -81,8 +76,6 @@ class GravitationStabilizerBlockEntity(p_155229_: BlockPos, p_155230_: BlockStat } companion object { - private val minBBox = BlockPos(1, 1, 1) const val RANGE = 64 - private val MACHINE_NAME = TranslatableComponent("block.overdrive_that_matters.gravitation_stabilizer") } } 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 551f1adc9..653db7be9 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 @@ -9,7 +9,6 @@ import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.level.block.state.BlockState -import ru.dbotthepony.mc.otm.block.IDroppableContainer import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.config.MachinesConfig @@ -23,8 +22,8 @@ import ru.dbotthepony.mc.otm.registry.MRecipes class PlatePressBlockEntity( p_155229_: BlockPos, p_155230_: BlockState -) : MatteryWorkerBlockEntity(MBlockEntities.PLATE_PRESS, p_155229_, p_155230_, ::ItemJob), IDroppableContainer { - val container = MatteryContainer(this::setChangedLight, 2) +) : MatteryWorkerBlockEntity(MBlockEntities.PLATE_PRESS, p_155229_, p_155230_, ::ItemJob) { + val container = MatteryContainer(this::setChangedLight, 2).also(::addDroppableContainer) val energy = WorkerEnergyStorage(this::setChangedLight, MachinesConfig.PLATE_PRESS) var experience = 0.0 @@ -38,7 +37,6 @@ class PlatePressBlockEntity( } } - override val droppableContainer by ::container val itemHandler = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { return slot != SLOT_OUTPUT 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 8b1e4d6fc..80614aa6c 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 @@ -8,7 +8,6 @@ import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel -import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.menu.input.IPlayerInputWithFeedback @@ -39,15 +38,15 @@ private fun > makeRedstoneSettingButton( } } -private fun > makeItemModeButton(screen: S, parent: FramePanel, input: ItemHandlerPlayerInput.Piece): LargeEnumRectangleButtonPanel { - val button = LargeEnumRectangleButtonPanel(screen, parent, enum = MatteryDeviceBlockEntity.ItemHandlerView::class.java, prop = input.input, defaultValue = input.default) +private fun > makeItemModeButton(screen: S, parent: FramePanel, input: ItemHandlerPlayerInput.Piece): LargeEnumRectangleButtonPanel { + val button = LargeEnumRectangleButtonPanel(screen, parent, enum = MatteryDeviceBlockEntity.ItemHandlerMode::class.java, prop = input.input, defaultValue = input.default) val values = listOf( - MatteryDeviceBlockEntity.ItemHandlerView.DISABLED to Widgets18.DISABLED, - MatteryDeviceBlockEntity.ItemHandlerView.INPUT to Widgets18.INPUT_ONLY, - MatteryDeviceBlockEntity.ItemHandlerView.OUTPUT to Widgets18.OUTPUT_ONLY, - MatteryDeviceBlockEntity.ItemHandlerView.INPUT_OUTPUT to Widgets18.INPUT_OUTPUT, - MatteryDeviceBlockEntity.ItemHandlerView.BATTERY to Widgets18.BATTERY_ONLY, + MatteryDeviceBlockEntity.ItemHandlerMode.DISABLED to Widgets18.DISABLED, + MatteryDeviceBlockEntity.ItemHandlerMode.INPUT to Widgets18.INPUT_ONLY, + MatteryDeviceBlockEntity.ItemHandlerMode.OUTPUT to Widgets18.OUTPUT_ONLY, + MatteryDeviceBlockEntity.ItemHandlerMode.INPUT_OUTPUT to Widgets18.INPUT_OUTPUT, + MatteryDeviceBlockEntity.ItemHandlerMode.BATTERY to Widgets18.BATTERY_ONLY, ) for ((k, v) in values) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt index 2c96cea3a..dcf8aa1de 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt @@ -7,27 +7,22 @@ import ru.dbotthepony.mc.otm.menu.MatteryMenu class ItemHandlerPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = true, val allowPush: Boolean = true) { inner class Piece(val side: RelativeSide) { - var isPresent by menu.mSynchronizer.bool() - private set + private val allowedFlags = MatteryDeviceBlockEntity.ItemHandlerMode.values().map { menu.mSynchronizer.bool() to it } - private val allowedFlags = MatteryDeviceBlockEntity.ItemHandlerView.values().map { menu.mSynchronizer.bool() to it } - - fun isAllowed(value: MatteryDeviceBlockEntity.ItemHandlerView) = allowedFlags[value.ordinal].first.value + fun isAllowed(value: MatteryDeviceBlockEntity.ItemHandlerMode) = allowedFlags[value.ordinal].first.value val pull = BooleanInputWithFeedback(menu) val push = BooleanInputWithFeedback(menu) - val input = EnumInputWithFeedback(menu) + val input = EnumInputWithFeedback(menu) - var default by menu.mSynchronizer.enum(MatteryDeviceBlockEntity.ItemHandlerView.DISABLED) + var default by menu.mSynchronizer.enum(MatteryDeviceBlockEntity.ItemHandlerMode.DISABLED) init { pull.filter { allowPull } push.filter { allowPush } } - fun configure(config: MatteryDeviceBlockEntity.ConfigurableItemHandler) { - isPresent = true - + fun configure(config: MatteryDeviceBlockEntity.ConfigurableItemHandler.Piece) { for ((f, v) in allowedFlags) { f.value = v in config.possibleViews } @@ -51,7 +46,7 @@ class ItemHandlerPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = tru push.filter { allowPush } } - fun configure(config: MatteryDeviceBlockEntity.GlobalItemHandler) { + fun configure(config: MatteryDeviceBlockEntity.ConfigurableItemHandler) { for ((side, v) in config.sides) { pieces[side]!!.configure(v) pieces[side]!!.default = config.defaults[side]!! diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt index bb14c3f44..8519d30f3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt @@ -17,7 +17,7 @@ class CobblerMenu @JvmOverloads constructor( inventory: Inventory, tile: CobblerBlockEntity? = null ) : MatteryMenu(MMenus.COBBLESTONE_GENERATOR, p_38852_, inventory, tile) { - override val storageSlots = (tile?.droppableContainer ?: SimpleContainer(CobblerBlockEntity.CONTAINER_SIZE)).let { c -> ImmutableList(c.containerSize) { addSlot(MachineOutputSlot(c, it)) } } + override val storageSlots = (tile?.container ?: SimpleContainer(CobblerBlockEntity.CONTAINER_SIZE)).let { c -> ImmutableList(c.containerSize) { addSlot(MachineOutputSlot(c, it)) } } val redstone = EnumInputWithFeedback(this) val itemConfig = ItemHandlerPlayerInput(this, false, false) From 32da00423edf38a5c633e9848a6f9ec61e983b3c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 19 Feb 2023 12:07:03 +0700 Subject: [PATCH 0215/1199] More ConfigurableItemHandler tests --- .../block/entity/MatteryDeviceBlockEntity.kt | 45 +++++++++----- .../block/entity/MatteryPoweredBlockEntity.kt | 2 + .../tech/ChemicalGeneratorBlockEntity.kt | 61 ++++++++----------- .../otm/block/tech/ChemicalGeneratorBlock.kt | 10 --- .../screen/tech/ChemicalGeneratorScreen.kt | 2 +- .../mc/otm/container/HandlerFilter.kt | 32 ++++++++++ .../otm/menu/input/ItemHandlerPlayerInput.kt | 3 + .../mc/otm/menu/tech/ChemicalGeneratorMenu.kt | 12 ++-- 8 files changed, 101 insertions(+), 66 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index 08d71f8fc..595d313b2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -80,12 +80,12 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo input: IItemHandler? = null, output: IItemHandler? = null, battery: IItemHandler? = null, - val frontDefault: ItemHandlerMode = determineDefaultMode(input, output), - val backDefault: ItemHandlerMode = determineDefaultMode(input, output), - val leftDefault: ItemHandlerMode = determineDefaultMode(input, output), - val rightDefault: ItemHandlerMode = determineDefaultMode(input, output), - val topDefault: ItemHandlerMode = determineDefaultMode(input, output), - val bottomDefault: ItemHandlerMode = determineDefaultMode(input, output), + val frontDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.FRONT), + val backDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.BACK), + val leftDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.LEFT), + val rightDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.RIGHT), + val topDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.TOP), + val bottomDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.BOTTOM), ) { val sideless: IItemHandler @@ -281,15 +281,32 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo } companion object { - private fun determineDefaultMode(input: IItemHandler?, output: IItemHandler?): ItemHandlerMode { - if (input == null && output == null) + private fun determineDefaultMode(input: IItemHandler?, output: IItemHandler?, battery: IItemHandler?, side: RelativeSide): ItemHandlerMode { + if (side == RelativeSide.BACK && battery != null) { + return ItemHandlerMode.BATTERY + } + + if (input == null && output == null) { return ItemHandlerMode.DISABLED - else if (input != null && output != null) - return ItemHandlerMode.INPUT_OUTPUT - else if (output != null) - return ItemHandlerMode.OUTPUT - else - return ItemHandlerMode.INPUT + } else if (input != null && output != null) { + return when (side) { + RelativeSide.FRONT, RelativeSide.BACK -> ItemHandlerMode.DISABLED + RelativeSide.RIGHT, RelativeSide.TOP -> ItemHandlerMode.INPUT + RelativeSide.LEFT, RelativeSide.BOTTOM -> ItemHandlerMode.OUTPUT + } + } else if (output != null) { + if (side == RelativeSide.TOP) { + return ItemHandlerMode.DISABLED + } else { + return ItemHandlerMode.OUTPUT + } + } else { + if (side == RelativeSide.BOTTOM) { + return ItemHandlerMode.DISABLED + } else { + return ItemHandlerMode.INPUT + } + } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt index ff5f138ae..05de98e43 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt @@ -18,6 +18,7 @@ import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.energy.ItemEnergyStorageImpl +import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.nbt.ifHas @@ -28,6 +29,7 @@ import ru.dbotthepony.mc.otm.core.nbt.set abstract class MatteryPoweredBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(p_155228_, p_155229_, p_155230_) { val batteryContainer = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) + val batteryItemHandler = batteryContainer.handler(HandlerFilter.Dischargeable) init { savetable(::batteryContainer, BATTERY_KEY) 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 ec0ed5821..327c1bedb 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 @@ -31,33 +31,29 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe return ChemicalGeneratorMenu(containerID, inventory, this) } - val container = MatteryContainer(this::setChangedLight, SLOTS).also(::addDroppableContainer) - val energy = GeneratorEnergyStorage(this::setChangedLight, CAPACITY, THROUGHPUT) + val batteryContainer = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) + val residueContainer = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) + val fuelContainer = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) - val itemHandler = container.handler(object : HandlerFilter { - override fun canInsert(slot: Int, stack: ItemStack): Boolean { - if (slot == SLOT_INPUT) - return ForgeHooks.getBurnTime(stack, null) > 0 + val batteryItemHandler = batteryContainer.handler(HandlerFilter.Chargeable) + val residueItemHandler = batteryContainer.handler(HandlerFilter.OnlyOut) + val fuelItemHandler = batteryContainer.handler(HandlerFilter.ChemicalFuel) - if (slot == SLOT_RESIDUE) - return false + val energy = GeneratorEnergyStorage(::setChangedLight, CAPACITY, THROUGHPUT) - return stack.getCapability(ForgeCapabilities.ENERGY).isPresent - } - - override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { - if (slot == SLOT_RESIDUE) return true - - return slot == SLOT_BATTERY && - (!stack.getCapability(ForgeCapabilities.ENERGY).isPresent || stack.getCapability(ForgeCapabilities.ENERGY).resolve().get().receiveEnergy(Int.MAX_VALUE, true) <= 0) - } - }) + val itemConfig = ConfigurableItemHandler( + input = fuelItemHandler, + output = residueItemHandler, + battery = batteryItemHandler, + backDefault = ItemHandlerMode.BATTERY) init { savetable(::energy, ENERGY_KEY) - savetable(::container, INVENTORY_KEY) + savetable(::batteryContainer) + savetable(::residueContainer) + savetable(::fuelContainer) + exposeEnergyGlobally(energy) - exposeItemsGlobally(itemHandler) savetables.int(::workTicks, WORK_TICKS_KEY) savetables.int(::workTicksTotal, WORK_TICKS_TOTAL_KEY) @@ -107,25 +103,25 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe } if (workTicks == 0 && !redstoneControl.isBlockedByRedstone && checkFuelSlot) { - if (!container[SLOT_INPUT].isEmpty) { - val ticks = ForgeHooks.getBurnTime(container[SLOT_INPUT], null) - val residue = container[SLOT_INPUT].item.getCraftingRemainingItem(container[SLOT_INPUT].copy().also { it.count = 1 }) - val canPutResidue = residue.isEmpty || container[SLOT_RESIDUE].isEmpty || ItemStack.isSameItemSameTags(container[SLOT_RESIDUE], residue) && container[SLOT_RESIDUE].count < container[2].maxStackSize + if (!fuelContainer[0].isEmpty) { + val ticks = ForgeHooks.getBurnTime(fuelContainer[0], null) + val residue = fuelContainer[0].item.getCraftingRemainingItem(fuelContainer[0].copy().also { it.count = 1 }) + val canPutResidue = residue.isEmpty || residueContainer[0].isEmpty || ItemStack.isSameItemSameTags(residueContainer[0], residue) && residueContainer[0].count < residueContainer[0].maxStackSize if (canPutResidue && ticks >= 4 && (energy.batteryLevel < Decimal.ONE || GENERATION_SPEED * (ticks / 4) + energy.batteryLevel <= energy.maxBatteryLevel)) { workTicksTotal = ticks / 4 workTicks = ticks / 4 - container[SLOT_INPUT].shrink(1) + fuelContainer[0].shrink(1) if (!residue.isEmpty) { - if (container[SLOT_RESIDUE].isEmpty) { - container[SLOT_RESIDUE] = residue + if (residueContainer[0].isEmpty) { + residueContainer[0] = residue } else { - container[SLOT_RESIDUE].count++ + residueContainer[0].count++ } } - container.setChanged(SLOT_INPUT) + fuelContainer.setChanged(0) } } @@ -134,7 +130,7 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe if (energy.batteryLevel.isZero) return - val item = container[SLOT_BATTERY] + val item = batteryContainer[0] if (!item.isEmpty) { item.energy?.let(this::workWithPower) @@ -155,11 +151,6 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe private var _GENERATION_SPEED: DecimalConfigValue by WriteOnce() private var _CAPACITY: DecimalConfigValue by WriteOnce() - const val SLOT_INPUT = 0 - const val SLOT_BATTERY = 1 - const val SLOT_RESIDUE = 2 - const val SLOTS = 3 - fun registerConfig(builder: ForgeConfigSpec.Builder) { builder.push(MNames.CHEMICAL_GENERATOR) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt index cc57e14d7..3dd554dbb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt @@ -63,16 +63,6 @@ class ChemicalGeneratorBlock : RotatableMatteryBlock(), EntityBlock { ) { super.appendHoverText(itemStack, p_49817_, tooltips, p_49819_) GeneratorEnergyStorage.appendHoverText(itemStack, p_49817_, tooltips, p_49819_) - - val tag = itemStack.tag?.get(BlockItem.BLOCK_ENTITY_TAG) as? CompoundTag ?: return - val container = MatteryContainer(ChemicalGeneratorBlockEntity.SLOTS) - tag.map(MatteryBlockEntity.INVENTORY_KEY, container::deserializeNBT) - - if (!container[ChemicalGeneratorBlockEntity.SLOT_BATTERY].isEmpty) { - tooltips.add(TranslatableComponent("otm.item.block.stored_battery", container[ChemicalGeneratorBlockEntity.SLOT_BATTERY].displayName).withStyle(ChatFormatting.GRAY)) - - ItemEnergyStorageImpl.appendHoverText(container[ChemicalGeneratorBlockEntity.SLOT_BATTERY], tooltips) - } } private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.CHEMICAL_GENERATOR.rotateFromNorth(it[rotationProperty]).computeShape() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt index b0394c745..1d12426f1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt @@ -34,7 +34,7 @@ class ChemicalGeneratorScreen(menu: ChemicalGeneratorMenu, inventory: Inventory, SlotPanel(this, frame, menu.residueSlot, 56f, PROGRESS_SLOT_TOP) SlotPanel(this, frame, menu.fuelSlot, 104f, PROGRESS_SLOT_TOP) - makeDeviceControls(this, frame, redstone = menu.redstone) + makeDeviceControls(this, frame, redstone = menu.redstone, itemConfig = menu.itemConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt index a0843131a..2089f618e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt @@ -1,6 +1,8 @@ package ru.dbotthepony.mc.otm.container import net.minecraft.world.item.ItemStack +import net.minecraftforge.common.ForgeHooks +import net.minecraftforge.common.capabilities.ForgeCapabilities interface HandlerFilter { fun canInsert(slot: Int, stack: ItemStack): Boolean { @@ -35,4 +37,34 @@ interface HandlerFilter { } object Both : HandlerFilter + + object Dischargeable : HandlerFilter { + override fun canInsert(slot: Int, stack: ItemStack): Boolean { + return stack.getCapability(ForgeCapabilities.ENERGY).map { it.canExtract() && it.extractEnergy(Int.MAX_VALUE, true) > 0 }.orElse(false) + } + + override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { + return stack.getCapability(ForgeCapabilities.ENERGY).map { !it.canExtract() || it.extractEnergy(Int.MAX_VALUE, true) <= 0 }.orElse(true) + } + } + + object Chargeable : HandlerFilter { + override fun canInsert(slot: Int, stack: ItemStack): Boolean { + return stack.getCapability(ForgeCapabilities.ENERGY).map { it.canReceive() && it.receiveEnergy(Int.MAX_VALUE, true) > 0 }.orElse(false) + } + + override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { + return stack.getCapability(ForgeCapabilities.ENERGY).map { !it.canReceive() || it.receiveEnergy(Int.MAX_VALUE, true) <= 0 }.orElse(true) + } + } + + object ChemicalFuel : HandlerFilter { + override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { + return ForgeHooks.getBurnTime(stack, null) <= 0 + } + + override fun canInsert(slot: Int, stack: ItemStack): Boolean { + return ForgeHooks.getBurnTime(stack, null) > 0 + } + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt index dcf8aa1de..cc5853ab8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt @@ -5,6 +5,9 @@ import ru.dbotthepony.mc.otm.core.immutableMap import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.menu.MatteryMenu +/** + * [allowPull] and [allowPush] controls whenever player is allowed to change these options + */ class ItemHandlerPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = true, val allowPush: Boolean = true) { inner class Piece(val side: RelativeSide) { private val allowedFlags = MatteryDeviceBlockEntity.ItemHandlerMode.values().map { menu.mSynchronizer.bool() to it } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt index 765217587..18ea8fc55 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt @@ -11,6 +11,7 @@ import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -19,28 +20,28 @@ class ChemicalGeneratorMenu @JvmOverloads constructor(id: Int, inv: Inventory, t : MatteryMenu(MMenus.CHEMICAL_GENERATOR, id, inv, tile) { val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java) + val itemConfig = ItemHandlerPlayerInput(this, allowPull = false, allowPush = true) init { if (tile != null) { redstone.with(tile.redstoneControl::redstoneSetting) + itemConfig.configure(tile.itemConfig) } } - val container = tile?.container ?: SimpleContainer(3) - - val fuelSlot = object : MatterySlot(container, ChemicalGeneratorBlockEntity.SLOT_INPUT) { + val fuelSlot = object : MatterySlot(tile?.fuelContainer ?: SimpleContainer(1), 0) { override fun mayPlace(itemStack: ItemStack): Boolean { return ForgeHooks.getBurnTime(itemStack, null) > 0 } } - val residueSlot = object : MatterySlot(container, ChemicalGeneratorBlockEntity.SLOT_RESIDUE) { + val residueSlot = object : MatterySlot(tile?.residueContainer ?: SimpleContainer(1), 0) { override fun mayPlace(itemStack: ItemStack): Boolean { return false } } - val batterySlot = object : MatterySlot(container, ChemicalGeneratorBlockEntity.SLOT_BATTERY) { + val batterySlot = object : MatterySlot(tile?.batteryContainer ?: SimpleContainer(1), 0) { override fun mayPlace(itemStack: ItemStack): Boolean { itemStack.getCapability(ForgeCapabilities.ENERGY).ifPresentK { return it.canReceive() @@ -54,7 +55,6 @@ class ChemicalGeneratorMenu @JvmOverloads constructor(id: Int, inv: Inventory, t val energy = LevelGaugeWidget(this, tile?.energy) var burnTime by mSynchronizer.int() - override val storageSlots = listOf( addSlot(fuelSlot), addSlot(batterySlot), From 36354842aca620154a01ef63aec47175f4e90f4b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 19 Feb 2023 12:19:32 +0700 Subject: [PATCH 0216/1199] Add integrated dynamics to test env --- build.gradle.kts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index 1179aeca3..336a93f88 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -197,6 +197,11 @@ dependencies { // runtimeOnly(fg.deobf("at.ridgo8.moreoverlays:MoreOverlays-updated:${more_overlays_version}")) compileOnly(fg.deobf("mekanism:Mekanism:${deps_mc_version}-${mekanism_version}:all")) + + runtimeOnly(fg.deobf("curse.maven:cyclops-core-232758:4392602")) + runtimeOnly(fg.deobf("curse.maven:integrated-dynamics-236307:4391535")) + runtimeOnly(fg.deobf("curse.maven:integrated-crafting-287357:4391487")) + runtimeOnly(fg.deobf("curse.maven:integrated-terminals-295910:4400924")) } } From dd316bf16eebfda0b57c68600172c743ece4a870 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 19 Feb 2023 12:22:47 +0700 Subject: [PATCH 0217/1199] Add common capabilities to test env --- build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle.kts b/build.gradle.kts index 336a93f88..d10e28251 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -202,6 +202,7 @@ dependencies { runtimeOnly(fg.deobf("curse.maven:integrated-dynamics-236307:4391535")) runtimeOnly(fg.deobf("curse.maven:integrated-crafting-287357:4391487")) runtimeOnly(fg.deobf("curse.maven:integrated-terminals-295910:4400924")) + runtimeOnly(fg.deobf("curse.maven:common-capabilities-247007:4391468")) } } From 14c0ff1476245bc7e206fb35fa894bb8bb4659db Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 19 Feb 2023 12:26:06 +0700 Subject: [PATCH 0218/1199] =?UTF-8?q?=D0=B8=D0=BC=D0=B5=D0=B9=D1=82=D0=B5?= =?UTF-8?q?=20=D0=B2=20=D0=B2=D0=B2=D0=B8=D0=B4=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 84a5e547d..4595ff051 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -420,7 +420,7 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.GRAVITATION_STABILIZER, "Стабилизатор Пространства-Времени") add(MBlocks.GRAVITATION_STABILIZER_LENS, "Линза Стабилизатора Пространства-Времени") add(MBlocks.GRAVITATION_STABILIZER, "desc", "Уменьшает гравитационное влияние сингулярностей") - add(MBlocks.GRAVITATION_STABILIZER, "desc2", "Имейте в ввиду, что несколько стабилизаторов создают экспоненциальный эффект") + add(MBlocks.GRAVITATION_STABILIZER, "desc2", "Имейте ввиду, что несколько стабилизаторов создают экспоненциальный эффект") add(MBlocks.GRAVITATION_STABILIZER, "desc3", "Слишком слабое гравитационное поле сингулярности приведёт к быстрому испарению последней") add(MBlocks.PHANTOM_ATTRACTOR, "Приманщик Фантомов") From 3a108c3b1345ce262db1ec55808a64bfdb453f2c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 19 Feb 2023 12:41:39 +0700 Subject: [PATCH 0219/1199] fix using clientside method serverside --- .../dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt index cc5853ab8..ea5b9eae9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt @@ -58,7 +58,7 @@ class ItemHandlerPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = tru pull.withSupplier { pieces.values.all { it.pull.value } } push.withSupplier { pieces.values.all { it.push.value } } - pull.withConsumer { v -> pieces.values.forEach { it.pull.input.input(v) } } - push.withConsumer { v -> pieces.values.forEach { it.push.input.input(v) } } + pull.withConsumer { v -> pieces.values.forEach { it.pull.input.invoke(v) } } + push.withConsumer { v -> pieces.values.forEach { it.push.input.invoke(v) } } } } From 0a240fc37f121e360a01dd6bf9c5e0f9feb4bc97 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 19 Feb 2023 12:43:28 +0700 Subject: [PATCH 0220/1199] god damn it --- .../mc/otm/block/entity/tech/ChemicalGeneratorBlockEntity.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 327c1bedb..9caad79cb 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 @@ -36,8 +36,8 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe val fuelContainer = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) val batteryItemHandler = batteryContainer.handler(HandlerFilter.Chargeable) - val residueItemHandler = batteryContainer.handler(HandlerFilter.OnlyOut) - val fuelItemHandler = batteryContainer.handler(HandlerFilter.ChemicalFuel) + val residueItemHandler = residueContainer.handler(HandlerFilter.OnlyOut) + val fuelItemHandler = fuelContainer.handler(HandlerFilter.ChemicalFuel) val energy = GeneratorEnergyStorage(::setChangedLight, CAPACITY, THROUGHPUT) From 435c939f28d9b3bdc88a5159e91adc698e6fc9fb Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 19 Feb 2023 12:54:37 +0700 Subject: [PATCH 0221/1199] Add integrated tunnels --- build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle.kts b/build.gradle.kts index d10e28251..fff609b59 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -203,6 +203,7 @@ dependencies { runtimeOnly(fg.deobf("curse.maven:integrated-crafting-287357:4391487")) runtimeOnly(fg.deobf("curse.maven:integrated-terminals-295910:4400924")) runtimeOnly(fg.deobf("curse.maven:common-capabilities-247007:4391468")) + runtimeOnly(fg.deobf("curse.maven:integrated-tunnels-251389:4344632")) } } From 9959f72db35131187279a142c1294cc535a38923 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 19 Feb 2023 13:26:53 +0700 Subject: [PATCH 0222/1199] Fix invalid condition in imatteryenergystorage extractenergy --- .../mc/otm/capability/energy/IMatteryEnergyStorage.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt index 3a4087f97..70efbdc09 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt @@ -173,7 +173,7 @@ interface IMatteryEnergyStorage : IEnergyStorage { override fun extractEnergy(maxReceive: Int, simulate: Boolean): Int { // follow contract of IEnergyStorage - if (energyFlow.output) + if (!energyFlow.output) return 0 val extracted = extractEnergyChecked(Decimal(maxReceive), true).toInt() From 3b53d65b29c2807834373712e801eec98f13dc2d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 21 Feb 2023 09:13:31 +0700 Subject: [PATCH 0223/1199] Configurable energy handler working --- .../mc/otm/datagen/lang/English.kt | 1 + .../mc/otm/datagen/lang/Russian.kt | 1 + .../mc/otm/block/entity/MatteryBlockEntity.kt | 17 +- .../block/entity/MatteryDeviceBlockEntity.kt | 171 +++++++++++++++-- .../tech/ChemicalGeneratorBlockEntity.kt | 27 +-- .../mc/otm/capability/FlowDirection.kt | 60 +++++- .../dbotthepony/mc/otm/capability/Helpers.kt | 26 +++ .../mc/otm/client/render/Widgets18.kt | 1 + .../client/screen/panels/button/Buttons.kt | 176 +++++++++++++----- .../screen/tech/ChemicalGeneratorScreen.kt | 2 +- .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 14 ++ .../mc/otm/menu/input/EnergyPlayerInput.kt | 62 ++++++ .../otm/menu/input/ItemHandlerPlayerInput.kt | 2 +- .../mc/otm/menu/tech/ChemicalGeneratorMenu.kt | 3 + .../textures/gui/widgets/side_controls.png | Bin 1146 -> 1189 bytes .../textures/gui/widgets/side_controls.xcf | Bin 6919 -> 7474 bytes 16 files changed, 464 insertions(+), 99 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyPlayerInput.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 328d94b0f..3aab1fb17 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -613,6 +613,7 @@ private fun gui(provider: MatteryLanguageProvider) { gui("stored_amount", "Exact amount stored: %s") gui("sides.item_config", "Item Configuration") + gui("sides.energy_config", "Energy Configuration") gui("sides.top", "Top") gui("sides.bottom", "Bottom") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 4595ff051..d8446ebce 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -618,6 +618,7 @@ private fun gui(provider: MatteryLanguageProvider) { gui("stored_amount", "Точное количество в хранилище: %s шт.") gui("sides.item_config", "Настройка Предметов") + gui("sides.energy_config", "Настройка Энергии") gui("sides.top", "Верхняя сторона") gui("sides.bottom", "Нижняя сторона") 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 58f61a93d..20294fce6 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 @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.block.entity +import com.google.common.collect.ImmutableList import com.google.common.collect.ImmutableSet import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import it.unimi.dsi.fastutil.longs.Long2ObjectFunction @@ -52,7 +53,9 @@ import ru.dbotthepony.mc.otm.core.forValidRefs import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.getValue import ru.dbotthepony.mc.otm.core.ifPresentK +import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.immutableMap +import ru.dbotthepony.mc.otm.core.immutableSet import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.core.math.minus @@ -170,14 +173,16 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } } - protected fun exposeEnergy(side: RelativeSide, value: IMatteryEnergyStorage) { - val thisSide = _sides[side]!! + protected fun exposeEnergy(side: RelativeSide, value: IMatteryEnergyStorage): ImmutableList> { + return immutableList { + val thisSide = _sides[side]!! - thisSide.Cap(ForgeCapabilities.ENERGY, value) - thisSide.Cap(MatteryCapability.ENERGY, value) + accept(thisSide.Cap(ForgeCapabilities.ENERGY, value)) + accept(thisSide.Cap(MatteryCapability.ENERGY, value)) - if (isMekanismLoaded) { - thisSide.Cap(MatteryCapability.MEKANISM_ENERGY, Mattery2MekanismEnergyWrapper(value)) + if (isMekanismLoaded) { + accept(thisSide.Cap(MatteryCapability.MEKANISM_ENERGY, Mattery2MekanismEnergyWrapper(value))) + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index 595d313b2..2159a4ab0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -15,12 +15,16 @@ import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.items.IItemHandler import ru.dbotthepony.mc.otm.capability.CombinedItemHandler import ru.dbotthepony.mc.otm.capability.EmptyItemHandler +import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.UnmodifiableItemHandler +import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.moveBetweenSlots +import ru.dbotthepony.mc.otm.capability.moveEnergy import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.getValue import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.immutableMap +import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.core.nbt.getJson import ru.dbotthepony.mc.otm.core.nbt.putJson @@ -68,6 +72,135 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo redstoneControl.deserializeNBT(nbt[REDSTONE_CONTROL_KEY] as? CompoundTag) } + inner class ConfigurableEnergy( + val capability: T, + + val possibleModes: FlowDirection = capability.energyFlow, + + val frontDefault: FlowDirection = possibleModes, + val backDefault: FlowDirection = possibleModes, + val leftDefault: FlowDirection = possibleModes, + val rightDefault: FlowDirection = possibleModes, + val topDefault: FlowDirection = possibleModes, + val bottomDefault: FlowDirection = possibleModes, + ) { + init { + exposeEnergySideless(capability) + } + + val front = Piece(RelativeSide.FRONT).also { it.energyFlow = frontDefault } + val back = Piece(RelativeSide.BACK).also { it.energyFlow = backDefault } + val left = Piece(RelativeSide.LEFT).also { it.energyFlow = leftDefault } + val right = Piece(RelativeSide.RIGHT).also { it.energyFlow = rightDefault } + val top = Piece(RelativeSide.TOP).also { it.energyFlow = topDefault } + val bottom = Piece(RelativeSide.BOTTOM).also { it.energyFlow = bottomDefault } + + val pieces = immutableMap { + put(RelativeSide.FRONT, front) + put(RelativeSide.BACK, back) + put(RelativeSide.LEFT, left) + put(RelativeSide.RIGHT, right) + put(RelativeSide.TOP, top) + put(RelativeSide.BOTTOM, bottom) + } + + val defaults = immutableMap { + put(RelativeSide.FRONT, frontDefault) + put(RelativeSide.BACK, backDefault) + put(RelativeSide.LEFT, leftDefault) + put(RelativeSide.RIGHT, rightDefault) + put(RelativeSide.TOP, topDefault) + put(RelativeSide.BOTTOM, bottomDefault) + } + + inner class Piece(val side: RelativeSide) : IMatteryEnergyStorage, ITickable { + private val capControllers = exposeEnergy(side, this@Piece) + private val neighbour by sides[side]!!.track(ForgeCapabilities.ENERGY) + + override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { + return capability.extractEnergy(howMuch, simulate) + } + + override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { + return capability.receiveEnergy(howMuch, simulate) + } + + override fun extractEnergyChecked(howMuch: Decimal, simulate: Boolean): Decimal { + if (energyFlow.output) + return capability.extractEnergyChecked(howMuch, simulate) + + return Decimal.ZERO + } + + override fun receiveEnergyChecked(howMuch: Decimal, simulate: Boolean): Decimal { + if (energyFlow.input) + return capability.receiveEnergyChecked(howMuch, simulate) + + return Decimal.ZERO + } + + override var batteryLevel: Decimal by capability::batteryLevel + override val maxBatteryLevel: Decimal by capability::maxBatteryLevel + override val missingPower: Decimal by capability::missingPower + + override val canSetBatteryLevel: Boolean by capability::canSetBatteryLevel + + override fun drainBattery(): Boolean { + return capability.drainBattery() + } + + override fun fillBattery(): Boolean { + return capability.fillBattery() + } + + override fun tick() { + if (energyFlow == FlowDirection.NONE || !automatePull && !automatePush) + return + + neighbour.ifPresentK { + if (energyFlow.input && automatePull) { + moveEnergy(source = it, destination = capability, simulate = false) + } + + if (energyFlow.output && automatePush) { + moveEnergy(source = capability, destination = it, simulate = false) + } + } + } + + init { + tickList.always(this) + } + + override var energyFlow by synchronizer.enum(possibleModes, setter = { value, access, setByRemote -> + require(possibleModes.isSupertype(value)) { "Energy mode $value is not allowed (allowed modes: ${possibleModes.family})" } + + if (access.read() != value) { + access.write(value) + + if (value == FlowDirection.NONE) { + for (controller in capControllers) + controller.close() + } else { + for (controller in capControllers) { + controller.close() + controller.expose() + } + } + } + }) + + var automatePull by synchronizer.bool() + var automatePush by synchronizer.bool() + + init { + savetables.enum(::energyFlow, "energy_${side}_flow", FlowDirection::valueOf) + savetables.bool(::automatePull, "energy_${side}_pull") + savetables.bool(::automatePush, "energy_${side}_push") + } + } + } + enum class ItemHandlerMode(val translationKey: String) { DISABLED("otm.gui.side_mode.disabled"), INPUT("otm.gui.side_mode.input"), @@ -107,7 +240,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo val top = Piece(RelativeSide.TOP, input, output, battery).also { it.mode = topDefault } val bottom = Piece(RelativeSide.BOTTOM, input, output, battery).also { it.mode = bottomDefault } - val sides = immutableMap { + val pieces = immutableMap { put(RelativeSide.FRONT, front) put(RelativeSide.BACK, back) put(RelativeSide.LEFT, left) @@ -126,14 +259,14 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo } inner class Piece( - side: RelativeSide, + val side: RelativeSide, val input: IItemHandler? = null, val output: IItemHandler? = null, val battery: IItemHandler? = null, ) : IItemHandler, ITickable { private var currentHandler: IItemHandler = EmptyItemHandler - val capController = this@MatteryDeviceBlockEntity.sides[side]!!.Cap(ForgeCapabilities.ITEM_HANDLER, this) - private val neighbour by this@MatteryDeviceBlockEntity.sides[side]!!.track(ForgeCapabilities.ITEM_HANDLER) + private val capController = sides[side]!!.Cap(ForgeCapabilities.ITEM_HANDLER, this) + private val neighbour by sides[side]!!.track(ForgeCapabilities.ITEM_HANDLER) val possibleViews: ImmutableSet val inputOutput: IItemHandler? @@ -184,29 +317,27 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo } }) - var automatePull = false - set(value) { - if (field != value) { - field = value + var automatePull by synchronizer.bool(setter = { value, access, _ -> + if (access.read() != value) { + access.write(value) - if (value) { - innerSlotPull = 0 - outerSlotPull = 0 - } + if (value) { + innerSlotPush = 0 + outerSlotPush = 0 } } + }) - var automatePush = false - set(value) { - if (field != value) { - field = value + var automatePush by synchronizer.bool(setter = { value, access, _ -> + if (access.read() != value) { + access.write(value) - if (value) { - innerSlotPush = 0 - outerSlotPush = 0 - } + if (value) { + innerSlotPush = 0 + outerSlotPush = 0 } } + }) init { savetables.bool(::automatePull, "itemhandler_${side}_automatePull") 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 9caad79cb..e1f8696a2 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 @@ -47,20 +47,21 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe battery = batteryItemHandler, backDefault = ItemHandlerMode.BATTERY) + val energyConfig = ConfigurableEnergy(energy) + init { + for (piece in energyConfig.pieces.values) + piece.automatePush = true + savetable(::energy, ENERGY_KEY) savetable(::batteryContainer) savetable(::residueContainer) savetable(::fuelContainer) - exposeEnergyGlobally(energy) - savetables.int(::workTicks, WORK_TICKS_KEY) savetables.int(::workTicksTotal, WORK_TICKS_TOTAL_KEY) } - private val consumers = trackGlobally(ForgeCapabilities.ENERGY) - override fun setChangedLight() { super.setChangedLight() checkFuelSlot = true @@ -74,15 +75,6 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe private var checkFuelSlot = true - private fun workWithPower(it: IEnergyStorage) { - val extracted = energy.extractEnergy(THROUGHPUT, true) - val received = it.receiveEnergy(extracted, false) - - if (!received.isZero) { - energy.extractEnergy(received, false) - } - } - override fun tick() { super.tick() @@ -133,12 +125,9 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe val item = batteryContainer[0] if (!item.isEmpty) { - item.energy?.let(this::workWithPower) - if (energy.batteryLevel.isZero) return - } - - for (consumer in consumers) { - consumer.ifPresentK(::workWithPower) + item.energy?.also { + moveEnergy(energy, it, THROUGHPUT, simulate = false) + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt index d49194b2d..b26b06f06 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.capability +import com.google.common.collect.ImmutableSet import java.util.function.Predicate /** @@ -20,35 +21,84 @@ import java.util.function.Predicate * * `BI_DIRECTIONAL.test(OUTPUT)` = `false` * * `BI_DIRECTIONAL.test(INPUT)` = `false` */ -enum class FlowDirection(val input: Boolean, val output: Boolean) : Predicate { +enum class FlowDirection(val input: Boolean, val output: Boolean, val translationKey: String) : Predicate { /** * Can only be inputted (consumer) */ - INPUT(true, false), + INPUT(true, false, "otm.gui.side_mode.input"), /** * Can only be outputted/transmitted (producer) */ - OUTPUT(false, true), + OUTPUT(false, true, "otm.gui.side_mode.output"), /** * Can both consume and produce (capacitor) */ - BI_DIRECTIONAL(true, true), + BI_DIRECTIONAL(true, true, "otm.gui.side_mode.input_output"), /** * Why would you want to use this */ - NONE(false, false); + NONE(false, false, "otm.gui.side_mode.disabled"); + /** + * All values that pass [isSupertype] + */ + val family: ImmutableSet by lazy { + ImmutableSet.Builder().also { + when (this) { + INPUT -> it.add(INPUT) + OUTPUT -> it.add(OUTPUT) + BI_DIRECTIONAL -> { + it.add(INPUT) + it.add(OUTPUT) + it.add(BI_DIRECTIONAL) + } + else -> {} + } + + it.add(NONE) + }.build() + } + + /** + * Subtype test (returns true if we can assign [t] to this, e.g. we can assign [BI_DIRECTIONAL] to [INPUT]) + */ override fun test(t: FlowDirection): Boolean { return t === this || (!input || t.input) && (!output || t.output) } + /** + * Subtype test (returns true if we can assign [value] to this, e.g. we can assign [BI_DIRECTIONAL] to [INPUT]) + */ + fun isSubtype(value: FlowDirection) = test(value) + + /** + * Supertype test (e.g. [INPUT] is supertype to [BI_DIRECTIONAL], so if this is [BI_DIRECTIONAL] then calling [isSupertype] with [INPUT] will return `true`) + */ + fun isSupertype(value: FlowDirection): Boolean { + return value === this || value in family + } + fun intersect(other: FlowDirection): FlowDirection { return of(other.input && input, other.output && output) } + fun withInput(flag: Boolean): FlowDirection { + if (flag == input) + return this + + return of(flag, output) + } + + fun withOutput(flag: Boolean): FlowDirection { + if (flag == output) + return this + + return of(input, flag) + } + companion object { @JvmStatic fun of(input: Boolean, output: Boolean): FlowDirection { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Helpers.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Helpers.kt index cc8cb0e75..dafd77dfc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Helpers.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Helpers.kt @@ -1,6 +1,8 @@ package ru.dbotthepony.mc.otm.capability +import net.minecraftforge.energy.IEnergyStorage import net.minecraftforge.items.IItemHandler +import ru.dbotthepony.mc.otm.core.math.Decimal /** * Attempts to safely exchange/move item between slots of two handlers @@ -41,3 +43,27 @@ fun moveBetweenSlots(source: IItemHandler, sourceSlot: Int, destination: IItemHa return sourceSlot to destinationSlot } + +@Suppress("name_shadowing") +fun moveEnergy(source: IEnergyStorage, destination: IEnergyStorage, amount: Decimal = Decimal.LONG_MAX_VALUE, simulate: Boolean): Decimal { + val extracted = source.extractEnergy(amount, true) + + if (extracted.isPositive) { + val received = destination.receiveEnergy(extracted, true) + + if (received.isPositive) { + val extracted = source.extractEnergy(received, true) + + if (extracted.isPositive) { + if (simulate) { + return extracted + } + + val received = destination.receiveEnergy(extracted, false) + return source.extractEnergy(received, false) + } + } + } + + return Decimal.ZERO +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt index 3bc229a6c..1b0a14618 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt @@ -68,4 +68,5 @@ object Widgets18 { val INPUT_OUTPUT = controlsGrid.next() val BATTERY_ONLY = controlsGrid.next() val ITEMS_CONFIGURATION = controlsGrid.next() + val ENERGY_CONFIGURATION = controlsGrid.next() } 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 80614aa6c..0902b3524 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 @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import com.mojang.blaze3d.platform.InputConstants import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting +import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.MatteryScreen @@ -10,6 +11,8 @@ import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.RelativeSide +import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput import ru.dbotthepony.mc.otm.menu.input.IPlayerInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import java.util.function.Predicate @@ -59,57 +62,33 @@ private fun > makeItemModeButton(screen: S, parent: FramePa return button } -private fun > makeItemHandlerControlPanel( - screen: S, - inputs: ItemHandlerPlayerInput -): FramePanel { - val frame = object : FramePanel(screen, 78f, 80f, TranslatableComponent("otm.gui.sides.item_config")) { - override fun tickInner() { - super.tickInner() +private fun > makeEnergyModeButton(screen: S, parent: FramePanel, input: EnergyPlayerInput.Piece): LargeEnumRectangleButtonPanel { + val button = LargeEnumRectangleButtonPanel(screen, parent, enum = FlowDirection::class.java, prop = input.input, defaultValue = input.default) - if (!isEverFocused()) { - remove() - } - } + val values = listOf( + FlowDirection.NONE to Widgets18.DISABLED, + FlowDirection.INPUT to Widgets18.INPUT_ONLY, + FlowDirection.OUTPUT to Widgets18.OUTPUT_ONLY, + FlowDirection.BI_DIRECTIONAL to Widgets18.INPUT_OUTPUT, + ) + + for ((k, v) in values) { + button.add(k, skinElement = v, tooltip = TranslatableComponent(k.translationKey)) } - val front = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.FRONT]!!) - val back = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.BACK]!!) - val left = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.LEFT]!!) - val right = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.RIGHT]!!) - val top = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.TOP]!!) - val bottom = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.BOTTOM]!!) + button.finish() - if (inputs.pull.test(minecraft.player)) { - val pull = LargeBooleanRectangleButtonPanel( - screen, - frame, - skinElementActive = Widgets18.PULL, - skinElementInactive = Widgets18.PULL_DISABLED, - prop = inputs.pull, - ) - - pull.tooltip = TranslatableComponent("otm.gui.side_mode.pull") - - pull.x = 30f - 20f - pull.y = 14f - } - - if (inputs.push.test(minecraft.player)) { - val push = LargeBooleanRectangleButtonPanel( - screen, - frame, - skinElementActive = Widgets18.PUSH, - skinElementInactive = Widgets18.PUSH_DISABLED, - prop = inputs.push, - ) - - push.tooltip = TranslatableComponent("otm.gui.side_mode.push") - - push.x = 30f + 20f - push.y = 14f - } + return button +} +private fun moveButtons( + front: EditablePanel<*>, + back: EditablePanel<*>, + left: EditablePanel<*>, + right: EditablePanel<*>, + top: EditablePanel<*>, + bottom: EditablePanel<*>, +) { top.tooltip = TranslatableComponent("otm.gui.sides.top") bottom.tooltip = TranslatableComponent("otm.gui.sides.bottom") back.tooltip = TranslatableComponent("otm.gui.sides.back") @@ -134,9 +113,94 @@ private fun > makeItemHandlerControlPanel( back.x = 30f - 20f back.y = 14f + 42f +} +@Suppress("name_shadowing") +private fun pullPush(frame: FramePanel<*>, pull: BooleanInputWithFeedback, push: BooleanInputWithFeedback) { + if (pull.test(minecraft.player)) { + val pull = LargeBooleanRectangleButtonPanel( + frame.screen, + frame, + skinElementActive = Widgets18.PULL, + skinElementInactive = Widgets18.PULL_DISABLED, + prop = pull, + ) + + pull.tooltip = TranslatableComponent("otm.gui.side_mode.pull") + + pull.x = 30f - 20f + pull.y = 14f + } + + if (push.test(minecraft.player)) { + val push = LargeBooleanRectangleButtonPanel( + frame.screen, + frame, + skinElementActive = Widgets18.PUSH, + skinElementInactive = Widgets18.PUSH_DISABLED, + prop = push, + ) + + push.tooltip = TranslatableComponent("otm.gui.side_mode.push") + + push.x = 30f + 20f + push.y = 14f + } +} + +private fun > makeItemHandlerControlPanel( + screen: S, + inputs: ItemHandlerPlayerInput +): FramePanel { + val frame = object : FramePanel(screen, 78f, 80f, TranslatableComponent("otm.gui.sides.item_config")) { + override fun tickInner() { + super.tickInner() + + if (!isEverFocused()) { + remove() + } + } + } + + val front = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.FRONT]!!) + val back = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.BACK]!!) + val left = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.LEFT]!!) + val right = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.RIGHT]!!) + val top = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.TOP]!!) + val bottom = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.BOTTOM]!!) + + pullPush(frame, inputs.pull, inputs.push) + moveButtons(front, back, left, right, top, bottom) screen.addPanel(frame) + frame.requestFocus() + return frame +} + +private fun > makeEnergyConfigPanel( + screen: S, + inputs: EnergyPlayerInput +): FramePanel { + val frame = object : FramePanel(screen, 78f, 80f, TranslatableComponent("otm.gui.sides.energy_config")) { + override fun tickInner() { + super.tickInner() + + if (!isEverFocused()) { + remove() + } + } + } + + val front = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.FRONT]!!).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } + val back = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.BACK]!!).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } + val left = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.LEFT]!!).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } + val right = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.RIGHT]!!).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } + val top = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.TOP]!!).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } + val bottom = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.BOTTOM]!!).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } + + pullPush(frame, inputs.pull, inputs.push) + moveButtons(front, back, left, right, top, bottom) + screen.addPanel(frame) frame.requestFocus() return frame @@ -146,7 +210,8 @@ fun > makeDeviceControls( screen: S, parent: FramePanel, redstone: IPlayerInputWithFeedback? = null, - itemConfig: ItemHandlerPlayerInput? = null + itemConfig: ItemHandlerPlayerInput? = null, + energyConfig: EnergyPlayerInput? = null, ): EditablePanel { val panel = object : EditablePanel(screen, parent, width = LargeEnumRectangleButtonPanel.SIZE, height = 0f, x = parent.width + 3f) { override fun tickInner() { @@ -179,6 +244,23 @@ fun > makeDeviceControls( }.height + 2f } + if (energyConfig != null) { + y += object : LargeRectangleButtonPanel(screen, panel, y = y, skinElement = Widgets18.ENERGY_CONFIGURATION) { + init { + tooltip = TranslatableComponent("otm.gui.sides.energy_config") + } + + override fun onClick(mouseButton: Int) { + if (mouseButton == InputConstants.MOUSE_BUTTON_LEFT) { + val frame = makeEnergyConfigPanel(screen, energyConfig) + + frame.x = absoluteX + width / 2f - frame.width / 2f + frame.y = absoluteY + height + 8f + } + } + }.height + 2f + } + panel.height = (y - 2f).coerceAtLeast(0f) return panel } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt index 1d12426f1..64de1b85b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt @@ -34,7 +34,7 @@ class ChemicalGeneratorScreen(menu: ChemicalGeneratorMenu, inventory: Inventory, SlotPanel(this, frame, menu.residueSlot, 56f, PROGRESS_SLOT_TOP) SlotPanel(this, frame, menu.fuelSlot, 104f, PROGRESS_SLOT_TOP) - makeDeviceControls(this, frame, redstone = menu.redstone, itemConfig = menu.itemConfig) + makeDeviceControls(this, frame, redstone = menu.redstone, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig) return frame } 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 fc6e51c1b..4ca99c91e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -5,6 +5,7 @@ package ru.dbotthepony.mc.otm.core import com.google.common.collect.ImmutableList import com.google.common.collect.ImmutableMap +import com.google.common.collect.ImmutableSet import com.google.gson.JsonElement import com.google.gson.JsonObject import com.google.gson.JsonPrimitive @@ -35,6 +36,7 @@ import java.math.BigInteger import java.util.Arrays import java.util.Spliterators import java.util.UUID +import java.util.function.Consumer import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.reflect.KProperty @@ -135,6 +137,18 @@ inline fun immutableMap(initializer: ImmutableMap.Builder immutableSet(initializer: Consumer.() -> Unit): ImmutableSet { + val builder = ImmutableSet.Builder() + initializer.invoke(builder::add) + return builder.build() +} + +inline fun immutableList(initializer: Consumer.() -> Unit): ImmutableList { + val builder = ImmutableList.Builder() + initializer.invoke(builder::add) + return builder.build() +} + fun IForgeRegistry.getID(value: T): Int { return (this as ForgeRegistry).getID(value) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyPlayerInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyPlayerInput.kt new file mode 100644 index 000000000..c74ebac05 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyPlayerInput.kt @@ -0,0 +1,62 @@ +package ru.dbotthepony.mc.otm.menu.input + +import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity +import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.core.immutableMap +import ru.dbotthepony.mc.otm.core.math.RelativeSide +import ru.dbotthepony.mc.otm.menu.MatteryMenu + +/** + * [allowPull] and [allowPush] controls whenever player is allowed to change these options + */ +class EnergyPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = true, val allowPush: Boolean = true) { + var possibleModes by menu.mSynchronizer.enum(FlowDirection::class.java) + private set + + inner class Piece(val side: RelativeSide) { + val pull = BooleanInputWithFeedback(menu) + val push = BooleanInputWithFeedback(menu) + val input = EnumInputWithFeedback(menu) + + var default by menu.mSynchronizer.enum(FlowDirection.NONE) + + init { + pull.filter { allowPull } + push.filter { allowPush } + } + + fun configure(config: MatteryDeviceBlockEntity.ConfigurableEnergy<*>.Piece, parent: MatteryDeviceBlockEntity.ConfigurableEnergy<*>) { + pull.with(config::automatePull) + push.with(config::automatePush) + input.withSupplier { config.energyFlow }.withConsumer { if (parent.possibleModes.isSupertype(it)) config.energyFlow = it } + } + } + + val pieces = immutableMap { for (side in RelativeSide.values()) put(side, Piece(side)) } + + // TODO + val pull = BooleanInputWithFeedback(menu) + + // TODO + val push = BooleanInputWithFeedback(menu) + + init { + pull.filter { allowPull } + push.filter { allowPush } + } + + fun configure(config: MatteryDeviceBlockEntity.ConfigurableEnergy<*>) { + possibleModes = config.possibleModes + + for ((side, v) in config.pieces) { + pieces[side]!!.configure(v, config) + pieces[side]!!.default = config.defaults[side]!! + } + + pull.withSupplier { pieces.values.all { it.pull.value } } + push.withSupplier { pieces.values.all { it.push.value } } + + pull.withConsumer { v -> pieces.values.forEach { it.pull.input.invoke(v) } } + push.withConsumer { v -> pieces.values.forEach { it.push.input.invoke(v) } } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt index ea5b9eae9..2706e5798 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt @@ -50,7 +50,7 @@ class ItemHandlerPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = tru } fun configure(config: MatteryDeviceBlockEntity.ConfigurableItemHandler) { - for ((side, v) in config.sides) { + for ((side, v) in config.pieces) { pieces[side]!!.configure(v) pieces[side]!!.default = config.defaults[side]!! } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt index 18ea8fc55..71f02822a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt @@ -10,6 +10,7 @@ import ru.dbotthepony.mc.otm.block.entity.tech.ChemicalGeneratorBlockEntity import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget @@ -21,11 +22,13 @@ class ChemicalGeneratorMenu @JvmOverloads constructor(id: Int, inv: Inventory, t val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java) val itemConfig = ItemHandlerPlayerInput(this, allowPull = false, allowPush = true) + val energyConfig = EnergyPlayerInput(this, allowPull = false, allowPush = true) init { if (tile != null) { redstone.with(tile.redstoneControl::redstoneSetting) itemConfig.configure(tile.itemConfig) + energyConfig.configure(tile.energyConfig) } } diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.png index 64b4f0f003bc85d4c9d0d4463626bc6b0bb67bbb..fafdeacc035cbc3616295c0db9084f558c7e0107 100644 GIT binary patch delta 719 zcmV;=0x(L_t(|+U=UXN@GD3$IlFTh%{RWTL@_^ z(kyI|&PD=WtOVb{O=A_T#mXl72EtZL7D5{PfK3V;!9uXG*|!)Qb>n1a?wNb%BRBW| z1MzY{CTD*4%$%7JA^@UtbgSs-R<*YOl5vlE|EtCGRZl%%^=f~&vpXEC-Ql=)JL6$j zjfY(oLJ)-^os+clKGNqhNkYp0#k|a~h$tlSt!gfvOkds3aXTCAr(}@+(_p?V~ zlA)hZ#pUduFv-x*XPKm%OvkY9QI_@4m-By4M3PLfm3005)9f-zJZl-m>3AwR+>XbR zV;y2H0V(Bh1jK)o&S6Q+6Fmmf_yXQ$9yifSq>4A@CoL4XXo?y_sa_r5nVri{raM6FpI;! z2q7nQJnXMKOmftDfM{ht1f$WY(quQ8OhlE>@qNyhPUw|u3aY+@T7o{f z`F6*8@brImKS)OSc6Rmt*x9otXmQvVd+bNgldm08%Q0pU5z)i)Lhbd>h3_?2W)ww1 zL`2i+v@vpwo7J-6Q#Q1=C3Bn^6au{?MNt^5PT3r!U$@;KOB{Zq=#xPY%ZvB7b4T=f ztn>fc=_~((27`eJk%_5?T_ZCn<($;vPQcvt(Y8lT*iv5+e~8fkw^0szFXmbh>RXLi zd$C-lo>k^^?6*Q~Y5@QM0000000000004ld@CH{8u^ad!NkRYs002ovPDHLkV1l-p BT95z$ delta 676 zcmV;V0$cs13Hk`I;{ksX5(p|wg?TOj00MVOL_t(|+U=S@OT$1Ihu=H;A-XsS4nmg> zT?B`2E~Q{_68r|*#i=-pQaYZl|oR(0!QGVN5JrBNa3 z$s&hc4`&1FYx!S>ZA6HA001D^H1C7KV32CC8;{4O{GY4gd*xa+HlFUd+j(Jq@O*jX zB_q;iTp@pgX2%`TW`Fdm7HbFN6K0F~wQ6^+gzGt5W<*g$L`2i+bgKkO*Y16qkpvC-pbvIv#evftj&Yds$U)1e(w{kgv406dJ+W^d6A5{&h zuZVv{=Ylmn$4=oKYL7o{91_Fv$JA~Y9Q`3Gc> zl2VS8T_*=6B@wy3E9T8SlfcfESkf%NbeFg)*_l!bD1JAT_Q-*;wbH#~RYvcXjMH3|^Kww^G!tF_5;c%RSZp3ybO1Mm{LiucY8$@iadmRE5(k|+IXdV= z7bpLMf-VYz94LheizTg zD+AFsuZn&9s^}pGAwY0$Ah@#-JmGKX0fa*XQPDz_VN(tm)ISVJ*MeNct@x3_+>e1+ WT8NjimFgSGpMf;9kglqo`R9MjIA5Ru From 504033b65e5021b9df463b73cbda713d866ef654 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 21 Feb 2023 16:10:58 +0700 Subject: [PATCH 0224/1199] not so good attempt at improving clarity of configuration menu --- .../mc/otm/client/render/WidgetLocation.kt | 2 +- .../mc/otm/client/render/Widgets18.kt | 59 ++++++++++++++++-- .../client/screen/panels/button/Buttons.kt | 52 ++++++--------- .../textures/gui/widgets/side_controls.png | Bin 1189 -> 2020 bytes .../textures/gui/widgets/side_controls.xcf | Bin 7474 -> 36864 bytes 5 files changed, 74 insertions(+), 39 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt index 0b4725b34..5b13d0273 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt @@ -17,5 +17,5 @@ object WidgetLocation { val HORIZONTAL_GAUGES = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/horizontal_gauges.png"), 96f, 54f) val VERTICAL_GAUGES = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/vertical_gauges.png"), 90f, 48f) val REDSTONE_CONTROLS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/redstone.png"), 54f, 18f) - val SIDE_CONTROLS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/side_controls.png"), 72f, 72f) + val SIDE_CONTROLS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/side_controls.png"), 144f, 72f) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt index 1b0a14618..603a47cb6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt @@ -1,5 +1,10 @@ package ru.dbotthepony.mc.otm.client.render +import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity +import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.core.immutableMap +import ru.dbotthepony.mc.otm.core.math.RelativeSide + private fun makeButton(grid: GridAtlas): StretchingRectangleElement { val x = grid.currentX val y = grid.currentY @@ -56,17 +61,61 @@ object Widgets18 { val REDSTONE_LOW = redstoneGrid.next() val REDSTONE_HIGH = redstoneGrid.next() - private val controlsGrid = WidgetLocation.SIDE_CONTROLS.grid(rows = 4, columns = 4) + private val controlsGrid = WidgetLocation.SIDE_CONTROLS.grid(rows = 4, columns = 8) val PULL = controlsGrid.next() val PUSH = controlsGrid.next() val PULL_DISABLED = controlsGrid.next() val PUSH_DISABLED = controlsGrid.next() - val DISABLED = controlsGrid.next() - val INPUT_ONLY = controlsGrid.next() - val OUTPUT_ONLY = controlsGrid.next() - val INPUT_OUTPUT = controlsGrid.next() + + private fun controls() = immutableMap { + put(FlowDirection.NONE, controlsGrid.next()) + put(FlowDirection.INPUT, controlsGrid.next()) + put(FlowDirection.OUTPUT, controlsGrid.next()) + put(FlowDirection.BI_DIRECTIONAL, controlsGrid.next()) + } + + private fun controls2(input: Map) = immutableMap { + put(MatteryDeviceBlockEntity.ItemHandlerMode.DISABLED, input[FlowDirection.NONE]!!) + put(MatteryDeviceBlockEntity.ItemHandlerMode.INPUT, input[FlowDirection.INPUT]!!) + put(MatteryDeviceBlockEntity.ItemHandlerMode.OUTPUT, input[FlowDirection.OUTPUT]!!) + put(MatteryDeviceBlockEntity.ItemHandlerMode.INPUT_OUTPUT, input[FlowDirection.BI_DIRECTIONAL]!!) + put(MatteryDeviceBlockEntity.ItemHandlerMode.BATTERY, BATTERY_ONLY) + } + + val LEFT_CONTROLS = controls() + val RIGHT_CONTROLS = controls() + val TOP_CONTROLS = controls() + val BOTTOM_CONTROLS = controls() + val FRONT_CONTROLS = controls() + val BACK_CONTROLS = controls() + + val CONTROLS = immutableMap { + put(RelativeSide.BOTTOM, BOTTOM_CONTROLS) + put(RelativeSide.TOP, TOP_CONTROLS) + put(RelativeSide.LEFT, LEFT_CONTROLS) + put(RelativeSide.RIGHT, RIGHT_CONTROLS) + put(RelativeSide.FRONT, FRONT_CONTROLS) + put(RelativeSide.BACK, BACK_CONTROLS) + } + val BATTERY_ONLY = controlsGrid.next() val ITEMS_CONFIGURATION = controlsGrid.next() val ENERGY_CONFIGURATION = controlsGrid.next() + + val LEFT_CONTROLS_ITEMS = controls2(LEFT_CONTROLS) + val RIGHT_CONTROLS_ITEMS = controls2(RIGHT_CONTROLS) + val TOP_CONTROLS_ITEMS = controls2(TOP_CONTROLS) + val BOTTOM_CONTROLS_ITEMS = controls2(BOTTOM_CONTROLS) + val FRONT_CONTROLS_ITEMS = controls2(FRONT_CONTROLS) + val BACK_CONTROLS_ITEMS = controls2(BACK_CONTROLS) + + val ITEMS_CONTROLS = immutableMap { + put(RelativeSide.BOTTOM, BOTTOM_CONTROLS_ITEMS) + put(RelativeSide.TOP, TOP_CONTROLS_ITEMS) + put(RelativeSide.LEFT, LEFT_CONTROLS_ITEMS) + put(RelativeSide.RIGHT, RIGHT_CONTROLS_ITEMS) + put(RelativeSide.FRONT, FRONT_CONTROLS_ITEMS) + put(RelativeSide.BACK, BACK_CONTROLS_ITEMS) + } } 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 0902b3524..72ef6acce 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 @@ -5,6 +5,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel @@ -41,19 +42,11 @@ private fun > makeRedstoneSettingButton( } } -private fun > makeItemModeButton(screen: S, parent: FramePanel, input: ItemHandlerPlayerInput.Piece): LargeEnumRectangleButtonPanel { +private fun > makeItemModeButton(screen: S, parent: FramePanel, input: ItemHandlerPlayerInput.Piece, side: RelativeSide): LargeEnumRectangleButtonPanel { val button = LargeEnumRectangleButtonPanel(screen, parent, enum = MatteryDeviceBlockEntity.ItemHandlerMode::class.java, prop = input.input, defaultValue = input.default) - val values = listOf( - MatteryDeviceBlockEntity.ItemHandlerMode.DISABLED to Widgets18.DISABLED, - MatteryDeviceBlockEntity.ItemHandlerMode.INPUT to Widgets18.INPUT_ONLY, - MatteryDeviceBlockEntity.ItemHandlerMode.OUTPUT to Widgets18.OUTPUT_ONLY, - MatteryDeviceBlockEntity.ItemHandlerMode.INPUT_OUTPUT to Widgets18.INPUT_OUTPUT, - MatteryDeviceBlockEntity.ItemHandlerMode.BATTERY to Widgets18.BATTERY_ONLY, - ) - - for ((k, v) in values) { - button.add(k, skinElement = v, tooltip = TranslatableComponent(k.translationKey)) + for (v in MatteryDeviceBlockEntity.ItemHandlerMode.values()) { + button.add(v, skinElement = Widgets18.ITEMS_CONTROLS[side]!![v]!!, tooltip = TranslatableComponent(v.translationKey)) } button.finish() @@ -62,18 +55,11 @@ private fun > makeItemModeButton(screen: S, parent: FramePa return button } -private fun > makeEnergyModeButton(screen: S, parent: FramePanel, input: EnergyPlayerInput.Piece): LargeEnumRectangleButtonPanel { +private fun > makeEnergyModeButton(screen: S, parent: FramePanel, input: EnergyPlayerInput.Piece, side: RelativeSide): LargeEnumRectangleButtonPanel { val button = LargeEnumRectangleButtonPanel(screen, parent, enum = FlowDirection::class.java, prop = input.input, defaultValue = input.default) - val values = listOf( - FlowDirection.NONE to Widgets18.DISABLED, - FlowDirection.INPUT to Widgets18.INPUT_ONLY, - FlowDirection.OUTPUT to Widgets18.OUTPUT_ONLY, - FlowDirection.BI_DIRECTIONAL to Widgets18.INPUT_OUTPUT, - ) - - for ((k, v) in values) { - button.add(k, skinElement = v, tooltip = TranslatableComponent(k.translationKey)) + for (v in FlowDirection.values()) { + button.add(v, skinElement = Widgets18.CONTROLS[side]!![v]!!, tooltip = TranslatableComponent(v.translationKey)) } button.finish() @@ -162,12 +148,12 @@ private fun > makeItemHandlerControlPanel( } } - val front = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.FRONT]!!) - val back = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.BACK]!!) - val left = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.LEFT]!!) - val right = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.RIGHT]!!) - val top = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.TOP]!!) - val bottom = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.BOTTOM]!!) + val front = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.FRONT]!!, RelativeSide.FRONT) + val back = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.BACK]!!, RelativeSide.BACK) + val left = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.LEFT]!!, RelativeSide.LEFT) + val right = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.RIGHT]!!, RelativeSide.RIGHT) + val top = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.TOP]!!, RelativeSide.TOP) + val bottom = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.BOTTOM]!!, RelativeSide.BOTTOM) pullPush(frame, inputs.pull, inputs.push) moveButtons(front, back, left, right, top, bottom) @@ -191,12 +177,12 @@ private fun > makeEnergyConfigPanel( } } - val front = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.FRONT]!!).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } - val back = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.BACK]!!).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } - val left = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.LEFT]!!).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } - val right = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.RIGHT]!!).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } - val top = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.TOP]!!).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } - val bottom = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.BOTTOM]!!).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } + val front = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.FRONT]!!, RelativeSide.FRONT).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } + val back = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.BACK]!!, RelativeSide.BACK).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } + val left = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.LEFT]!!, RelativeSide.LEFT).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } + val right = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.RIGHT]!!, RelativeSide.RIGHT).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } + val top = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.TOP]!!, RelativeSide.TOP).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } + val bottom = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.BOTTOM]!!, RelativeSide.BOTTOM).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } pullPush(frame, inputs.pull, inputs.push) moveButtons(front, back, left, right, top, bottom) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.png index fafdeacc035cbc3616295c0db9084f558c7e0107..30dfc45a74927934ac1da9d45c7a56a12abc9060 100644 GIT binary patch delta 2010 zcmV<02POEW3FHqUiBL{Q4GJ0x0000DNk~Le0001x0000;2nGNE02wQM`jH_be?=+| zRuFN>P@OFJg*ZwTi(sL&6nNgNw7S4z7YA_yOYT;-u&z zCH^ldw21NGxF7HCJ?`ECLZiY|vuhksHOolFV`4V9Dh6I5U;sgcFd;EhPox(!@El+F z@bUF7%Co%B{W*G-yvYEcNIb`Mf5Rf)AfDN@bk6(4VOEk9;&b9LgDyz?$aUG}H_ki6e@tQNECMS>e3JS*_Gq>z@3Dp}e+|<~q$`#Ib|~ zk`N)IhB7L!5T#Wk#YBqsV;=q?$DbsZOs+B*ITlcb3d!+<|H1EW&BD~Af14DF0o^aQ z{V@Urc7bNyw!e>UyLkfmpMfi_?XNa~*-z5zZ7p&H^lbwd*KJMS11@)f!6#iZBuDbo z6bc34{fxdT2lU?pJ!@`nt$mz602%6P`35*R1V)RLz3%buU}tato@w>>19x|Fsqk^L z761SM24YJ`L;!98ZUAmKe*)Mh00009a7bBm000id000id0mpBsWB>pF2XskIMF-~s z6$t|)TnTJx000HyNkl3E5UpPJM>ug{xWH%=2TBeUC{wZsv^YAre;_N_ zNGLXrlt}&u21kbkW)tNCCkmXbxxk=6$^DDD;JjAv+;rEg>Ym>Df2aqG7R_vJP4}DX zs;_p5al3G)B9b)CysTfxYWt||325)sk$diy%H zlXW@&?sAYPw?C6okwKNe^C#}>d|qu{lBH$2+N)yAe+O!(?vFOV;rt05E0RPH z2}tBYCLg)e5j#laK}dx7(`3hmmMjk1B~80zanLSlT=FcfwsI{iU0a?)c3dp)$wi(N z0wE;QRAf>D`4cKhnCp|@mFlV0DlA42Z8@KU7(uk6!K`6 zFr?ZV+Y&ZGf0wFVM4ni*DIIyFrFzPww_zt&d7iz@9}|!UX|DD{7upnU*fAIk27|$1 z7$r8z9g{Vnu-uD^wzAG4$Cg&~T&p_3@)L(2I0c2cg( zzm}Bi;_QeCQK-!!9iLEC%W(~w>q6{^e>%uxRNTcT`g*-~T#qca5xDW~ za{k?M*Bi6r`@>yt?7Dn^P&-piL-&x26=Mq*S%TP&Sm60bxAR~{CJUI%A-V?~kv%6}v zub6VBf9U7O$0#8<#T{Bran%!AO>v4ltsNr|Lm;cRu&5fkxzMDa+gm{+A-88#${*Lp zn%);RofKR(ijpZ51vkE-c0$p8^EtGP=lqG;nY2+&3{gcV*~-xPqw%rnyG#2ssYje# zYx>Yg)HFUR*Xa9`;+yY77yL083NnDe}^gV(#9=CY?sTQ5_Y1!u+St+p8=Rl z>DL8?9^&U{6^V!<4%x=frHJdALJ#qCY>LDQ;%L)0zUBdvQsKJhSX=%`$;0&!yMDc> zo#+DsQXb>xe^E%TDiw`|8m>~&Sg7HetId(R8JokOQg$ZN!LbIbjgN>xMjk9-){M{K zf1gxuiaVS<((xJmlj==0W#mCHHS(0LwzLY#W;@RxT~dl2y+2cK*~+DS>xzOd)s87P zx8Y(5b6sgy2dccQEA6Cq>Sa8qphNwU+R2p@4(UntkRmac@~sOBI<1|Y)o3okRu@Ej zup%*+@~vwMI@C^X#paMmWH1;E27|#cf9f(mR5pjI5-y?aQ&+hZ&d$zM8-7<;S5EUi z($7gTjqNSGo6V{w68Va|_-{s3Q9IH-isfpr(oTM=orBv4)x_VQ?7O~@G?_r5-D0UO z2(crb^pwfZWrv99f3zgJ zKiPM0;Gw-xN39%@rv!Pn2*f?358cN1KeK7@_2F565`24jU%lDCaMEM3$g)^0h=}Os z=B78~AyOz3tverIp17rJD3K?aM04axNr-dgAUSfYHvQ37Rg1-wO*1$4;N{?>#&`RQVo?ETxt;R*@J} z+@X`k-PtIKn(b_>@^U=9v-EP-=bR|2NHoPAo*<+9Lqkibr_yRmqJl$ymjNlOk>9Oo z+n@WBeRpvCP0v_Ra1`}lP8vpFQDQvd(} delta 1172 zcmV;F1Z(@`52XnqiBL{Q4GJ0x0000DNk~Le0000;0000;2nGNE09Ea?N0A{Se^M$P z>>%Qhp*mR*6%i+?Vi7EqwnD28CYOFelZGV4#ZhoAIQX$xb#QUk)xlK|1V2DrU7QqM zq{ROvg%&X$9QWhhy~o`W`R4dUrdOXs{#9ARZiAwDM_Gw6cEk6f2se&bwn zSm2ovBb%Nlju4BbE|$BPl?|16ia4sM8s!T)mle)ioYiWbweQJa7%FHh8LrbDMgmJn zA_WmL>ZqU!3o%+XQcR?2Kknfla{MWB$>gelkz)ZhsE`~#_#gc4)+|m=f4E7ZIMDlI z+aDu9U>9gLZ2SAzwp%BF{~5T_I{sP{nE52V(b1wuKzJLtxbA539&ot>3_j_SAvuzt zrcf*b?`QN)d0^lc2(G!kwfAxQ0A#7FpF2XskIMF-~s z6bm6XEna=80007_Nkl~;*um&%gHIpCBk-1=8%&^5@)_K-P4H`(D$=PVUnSrPsQczpD@YL&u5vW zn@q>B?opQY(3kUne@;Y_Ot6)7{ruDHGDMapJMHBV9q+GN(z&(_>JzPswY6HYsu-tQwQY#Ws-?V6r((2IM-ICk&IUBp@_!Sy z5i!~U0Dx#^e?A1G(Wug7H9jF&jGNW6;ZruW zwk30%859D&BSlddt4`S*q+hq)A4?p5qv(@C56g@9YPWMo^m(lF|Jvy*|APjDfe4X_ zsfS%7GbrVp)ZtFR-1X76P1sUj5r2r#|F=;NdoSi%5b9fvSbMQtrJhyhbL_W5ZE67k m00000000000001hrtk(=53w8gBS}I40000roY-ZvR69`i46cLgV!s7OWiGV_bojAt9vtB$7 z#NuUX67$kvLRC?zqOFA74@GL_6ea@k-m29Wbz6;TOQkBJ{ZOQ~q959-RZ;A{{r#VF z&b?=5?l|imV_UkJ?A;kdCvcyd-l-b*3#U=_dPK8ftz>lPIx|xxl0b7-@#>?4(>X1?C|{rB`WL>=iA3m9631GK6>Qv{Wna{KXB;2qeqS& zo0~Ul*Rewf_RrmHf4grW`anVS?m7EY^uz6?{r4SSJT$laW_%}leBQI`p~b_;=MFF4 z_uhkTVqi?g@>x3gb3?d%u*v$J3F z5@)~kEzW+~51oDe)y{6*^C%>ea9`%e$&r6`^^tJ zd*NYczwM~A-~J6}|H_{^`&a+c+3)e?-aqC15B{>Vk38w@#WiQY-?zK{A?JVS@0|T% z8&sI-Pn`ePHaYvzdz^jpQD=YRADsOuPp8NK-T6=X`kl}JibG|@E1S=r>VC8P)Y*@9 zzuf)m*(a1@0#n7Lm}}*J{m1x)H8BcTHg!jCJuk-ux5ypb8lvEyi`+AjTipq1W+V4z z+^X*g=2lD{qjW0&72b`N?36p@!M-kXhpBTHVbN3RMxH6 zaTc>FsV>eWwZ-XVVsXmM)M7oE!mqI0%vieW;;x@c&Rt0_Hx z7RyQHi{+$*KX%s^OW&yx7Hs0bSo#je(#7s6pSRd{^}K>f@H0_k3RN+s6lz4a!d$rG zicD|%;{3(}VLZj@lLz)6KYsAo2@UHw@w%kgD7=1!I+Q|LFR!Y?)g*Y&$a|*P zyR>vh^`A+W$eW&-SxqCmex{0_`p>M|pM2DR#_C_C{?)0ICG54;<%tife%$9)mzPhf z!jnnxhUWO#9`Dl9s_I`&mWWMPXHKS(U0j4gM)J%uSH zb>hmc2`a#tt;%XtU!uHnOVv+MT4;u1Qj3`+hI%N+?3QfBmRBk*7guU~+xrzaVRclK zaytz!E1M8v>x4~HpG=k3l?a>c2~#hp=(qCo+d^+ynZ~7F^V`~ztgR#pIM+^ESZV7j zLXRaz(k3KrCJXeXLodxh(k3KrmKPvtv(srp&W;QuZBiM*rDmy9B5T@&q#a1wfuv+8 zk+Do%8C&jp2a2 z$E7KGzv3pW4hYyugUiY$gxES^)6^$ZrFA93CVRrv%PIP;{QNc{>B2NF^_t%%Bwa`p zaITXyvC<|aZ4QvML0`=DlC;qvOQj*xL()b@(gq}L^pLcXk+cCx8xctxo}|8_h@`|A zNwb)Yq|}>IPD!>%+K5O>Sg8R?Ws9WP8A)-M8%9#OL{hUoNvUrdQ>AqoNwctwq~z}* zDZTC`X`_#%C(%;q33_)ag`j38k_vLSjNq=Ii#r1?Q)(fshHQ7HoYdLgD6Eba)*OO_w6HJvQXr{;S zx}fbuZW!XMsauQ`X)0T0Ie8*^144&12%9p(t%jJWwV8)xOa-m43gT zsYhBFrn}$j{&Dxox$6u(kn%r?sbKVs)0(LDaFjJM-X>GjHf_Jd6BK5@4sP@7phbr` zJllRgWOyZ_+ASt^1b2l|)smzotjv;DZ`b@HHi^%rEVInX#Wt$7*4B#RJ;oj?tfiHL zfon~RN%*a5JtT}-LcA)NXr-)+o5;I8p$Uj|NeY_KtiU!B;S%{}mVkPv=7s(wK9{o0 zvLF{tXs&f6fxXB0PlYulS*g4^EiUAjCRi9vAYK(rG*i|Qn$Yx3fD?Ta;7e-)d}>W- z_$D-b6HF*s6G%Z58mC+!(! zVw@#^^lYDtJb@~HVr<`25J%AVeIb05iBZXBMFpOh4mjC2A2ty_L#pXZFb68x1gOAU zQjaG4Sbr1YGo+fn1nll>gV%j+Op0DE@2~AA!r7bP>S25>7+yxtIPtf5a1{Rjp7kjE zxhiwv=;QCJgvEv@#Nof{H6bwOZ%J@TY}<{Pgm&UT=Uj2{Wmy0u$t5-=9_2>SGZ~z- zwb=WzECf_<65KZhiJdjY^E`U2YszzGLD&Rj@cHiNx_>Zt-D|}Ov7RJdX`H5u+BeE{ z`5P6GKUcphclS@1tNj}uOA$?%tM3bWb|>k|W;VVox9c`6$t$}PaxRc_ft>3$xJQAQXous4*i#Uu)X`OvyXJY*8Td~&z${4_bJ{+eXD?Tw5a}n;+($?qwef$ z4oCh#9j{1SbFv_gplg0Ngul{oCBZpDl1#f6aD+IW#XpNJ+(}wBU=48F=^i_c=rmcGMG>d1WLVR3P3>c#F?9sWZ$-T zqfd=90IDWSuifZ7(r=P?2mpF5QP~qnU=850&yzY6yC#A=eUwc?XKvfQ*055`yTNpytS_G+; z;3mMLsleFQ!vLX>)@EbM3Q+2-B|@Y+kd~<^z!1_32Sq!tbRexwWQ95fNbo15?Lb=6 zmcY{-1S;qg(q`}{B<-9B+ma1wRSE!SPlW>7D%xfnE<-zT(y$Wcq#dY3G^Ca46%t4b zQv!P8anT9&#G+N1WQ^j;EbNB@>U3(_8X_CgW(eqDxIo}ZZCc2$jj9El4<_6z&O+ zX6VI>KsBhz%(mn_uWhQtrv~fAwm?kbq34OC2?L-fn2-UY(8Jo5Wt>~C0m%)ETo`VRf9bNdzj_D#>ts-`$nZ^S_r?Y8U#ve z7`NBBsZ;J)YDT&OHdJLVEi_(Z(Q8OensUQZ)8`6sXw{%mQUjCr8d8#`oZcvrF8N;s zlhz$fsw6@8_e;iDX>cF)UD)Wd`CWA|f99LHyI=R8e^WsmLG$;9@Oi)fxb1NThH%RO z!v=fQT6Gv?(pEdjZwrl5^0u(WBI)o>{W>>F8(3)7k~3TF?V$Trc-UpvZJhyh*E_z} z)d@{7G3)lCG=WXB$pqF0z2m9Fb(3tDC5)XwR!ZKkHCYB6-s$$z`jy^@1h?cg!QQ61 zUxkO=b=@ie)z=H0X4V7)F12t~49e6pQ-euq0<26EkeX<~15R;-XWdYW&DJb@%$8Z_Ts5Jyn+p%A{YS)sj+n-amLmjmu4c{~|5F^^`L z1k)o;0PT4k_Xn3ic=!G|=KD?X>FyBT&(v@ODU~{F3M`*9`g3s!h)_|($K&ZTZm8&}fWp@Ut2=x5osqw94cNWE zAdaBjb_P>%&!eI_DmuV9T1m%A(2mME-_VHX&n?TjyI;`W^7(=|f^PY82zP?ky(nc< zW9lxNB;qxoqSB;uG&G>1Azr9xB`MYt+$%~-4JtC?DWIa#PIELgprRpOs3@ftY6F+L z)JwMN2UyQ3vtIzC|7!OuXCD=%$Ms0)DC@mGb_j@Q;3jY1DghRrKo+mi-l|tgJhy$% z+4dXK;JNi47rrO^)nmZFJ^j_OBY{N9glN{;-9t2LX^DvW!-RlshJ0L26 zQL#EPRRS!mkzO!lI3mhX5Cb8BEL!K2wgHjAN2+v%n(Q=ATq6*P9TH8|j>1>~6b_ya zi`DVc;y8hv?XFI*;9|y6AtQXA5RL#M>c(^K?V5* zKdZ%hm&7=c-fa0jHhgYDL>y9m(Ky*DD?d(#w)TvZ9j5Z*1S08}Z@wpN*3Tn&WXAs6HDfkVXT4Db<{eQ)V+xfRI%HNZC4)mfJccTf(nH zvdkfX;oOc7%L?QbP#bJUiL%Oe0#;SW^{EXiGY$)B6qg#HoVPEJt6KTR`6|}F;y9f@ z?QKISlkuUxx}8()x78QuO}RBYkvnKR@LOpFRrTBUm59C>DXv;$BSae9_gM|YfN&LR zt%az>0bQZfCDa2Y1OifJ{@;Ko~h;K%v>1tR)Wgl5+s1Cg(tyV;Ujb zI(1#T@Il`#hZmO~I)3lbhmK>-U3ZI??XY31xix&O)Nbh=qv$(}zE9rzh5w2CeH*sd z$NEo*Bl+tQ3htSQ7g*}~WztGzF=a$b36l|3q-~0gOTpCeX)n&@7XP)DU*omoAqBLJ{zge@+z zwT#dRTQnqUsnDm`sH<*bTa7U3Y>hA}>?*cK*mMsPG)T)J8L4=vI2a}-f>a99N0Um@ zM(O9p1%WZNUzi>`jTAdhyH`!2QKr#R@<-3@w?&>n5x-Tq{T&5y1l|7r5I!%h-%TR3 z88_4H88_48b^1Z^7h`MMl+m4~8FO~R=8P*ve4_U(Hebx9KGRUC&-76p2~hmS*qR|_ zbUL}A-DX_4!@4O@O_f3O4-%}7r(4GEz4PKGL;wWuw+$v}r`f{CqYwY;yu_q@i@g||`fN)?eYWwT zKEJ&wH?2M?+^Ub2!RkXPxB7UgLp>IIF}AOd(yYFqo?AI%FbyIgd_b=nHy~WhIm%4P zgt_DLyY@QUe*0#^T@Mz-5p>rhA^dqDJO{!DI7iFsIH?jEv{5+cSQvF@-~GwR-^V$3 z|9(LnL3d|hIx-Yh!DOhQJ;_jg?Tr+4uf7$Bgt0X1vAqNp#AZ;Nm!Ov4Bn%6>Ni+de zlAx#nl4$PLx8kV9(yYh!@=QRH0TEt)TK=CxZI@q}4hXW;A#_&qdu zqi0AC(a|CB`&)k_V)jsvCO^+xpK|uwvM(y|hct@UO%FW#KIH7g!Met_L*RFyAB*OO z1Jf{ifn&vLK5@eVv0*k~d*Inl7u!q|{5%Z428~c1&k-=*TDwv+{Y$SN(2KIy3hITn z7fwrKpKFpvJAY|yE>`rCF2`0vHa!ooGDZjC83mIHT%KThS_VrRe5_c>BaROf8>9)g zho9}hvPmj|o5MhC`mZ{kBapnccA;k4tAK5{xpFTT)C+BvoQ}&VnWV-xsKmvJUebga zCE4`c0V>rbhIj|wK4cKD4TpPWGJpg3j8@Q6$xt!)qGz;%E~_=bgV3q)zj(9?q3me1 z3hSqT3-0y^pbJ}-unm<_{m{m}Kq<_7>4EuZv<6-=^o*7;q%c~BDfNsNw9H0J+iNHl zkJdnEveB}ojnmlleE2z-7fTGD84qcM6+Td?=tzzbSkCfq8BU$X+Id zmkPlaZ5WlFml46QIL4&sB}VWwHk=9{Aa_9C0wB+cf(srIF9PfxAWu%_=kVj=MS#5n z9f0LV-2*E3G)|3_($)bx#N zKnK*J{JG~7xjVyFz1DNj>4G?d?#WJJ2|~%?_8cqE;B!74w3q35qKk70ixIA`RUV$t zaDTLWU$N=w5y+lnzkVJ5F97Ebr>GnV|YK6Qn(6aQ+y~g8;}6OoMR)JtoZzkOPOhFt$@7Wf@ zp9kb~Kz@L8Bu~akBOjG>9tflE>;v)5NPV1h;I&cO5J%8~w}$Wl$Rk5o>>a4+Whn5O zy`Cg|{h+*nd?^xw-jFZ`O1iSW1T`Fn5Wy>wpaN1PL4i2z*;S0)br zq6>fUj*tL5q``U6PpZSe6XKVXPuum#SNIDqUaT*f?XD2Mt>w<&@(NdqwlUlg9PU4! z1sKtX8u`7)__HvySTO03YpY5pM9B3dWeYaJ)>%jSh1+WqaTGn3Vne)LutB`}v2}BZ z-TV>CB+T9b&;t9cgqqb7CN>v!#9>TmwLZ?blIm6uyV(PqJ@|PJqVol@UF?C~)(rth z6Ye*LCU!FgGy%ibog3ug(%v#L*& z(sbb~gh{D4Lmf+LNDyVB?hjriOiFDF8kW+KZBiOSPAGlMuN2m8s|ve8LT)D}Y^8!~ zpk<^F;M}dW0pOI>)-z7(lujIvvZB1jdX)XV@4cBb-*);{~$_~`qgClEmJLuz>972G#YUJM0$)l&-LQ_o$GTQ+I&@ zx4N<=m(t$@Ln9h#*Q65c(=SgWkNgO8$!L@zJw@nGM58QkFO5va_B1l6 zriiF+D(q^O5RR%%3}3!*;}jg&8@kth(;2;|4p$o7U%&#)g-;n$s`!cb!TM1E%| z*|3)NU^37LTqnn7R5q}`u5N`UwiS(SXakDsPooT?Mw~gY^M0WPS7eBgcCy8&kXoIm zFB{^*sAoIgxaXqD^&a!#KO|ld8@f^{4f7$T9YCTcUMRaTa2)$W9U;P3>ZCNxhm;q@ zhAgFFKKlQRaJbQ2rvUr0p$i^*n~lFhmrM0k*kptTbVAN`#F$Y22V79iq~+QBDe|y(=Yoalr~MI3OIsnm1{4#_L6Hax%QH4FS+)TYpAhYJIJ+zTsz3MgIqhv zwS!zkjpbt3nE%I9a&aCZ-w%`9xF^_lV^8R-bm5w~L46%3CQt+QY?KN7%Hj%1l3)K} zaAAke`!tV>2;m8F_#e;CKQf$8L*l0yn5P+-ry=pvkoajxI@H*}oFdmLa-AaADRP}6 z*C}!hHI@qnrow;PsWr(3C^g0Z*U11R6D5?;V_yO$KqMSFGPWXNryrh;a>I@=yw3jg ze?|T<;+`8An*0fIgq*rQ1UHk?JR>mF%p_CulSzGkI;qX`|B~iWN9S)#$Tf88QySu7 z3NcYfT+|R76~sqrujLvlX2^vonnEPi5luBjR0UC0I&quCPtTMmW#%UbcvhW%j$GrP zBUca|rL;&S9IPE7FwmX}p2*}sX+j*%CvFUR7|wl=b*O>N x`ylf^$h;3S?}Ny$=*J*N{Cf8}pl?`7!l)+s*q!-Tw{|6hJH)j9< delta 1126 zcmaJ`k9AfF<6`WR9!Iru(q@a;*$zRQ7lD6MWht5rb3%i zRARX*B0ebofCVFdAk_z77mR)K2b9vP`0*l$g?Q#}f}qufJ7?z1nX`B9o!JNS@!s9z z6Y2A9)2Gg~O?4%c8or@YsQDd)g%AQm2+^|C-y?>WWw#%ObuE7SanPpaN>c___(0$@J6BfZ zrLiGs{Bkqt`gJnTrs%|sDXTVERjn&krniUPm@?SKHxG_-eS)WH zGqWSE?!@=|*PSRk8;`4;Ie)0OOqo?GC8hdbN+U)X6<06Npf3w|RRe`Z-@5kEp*eHE znJ%{jsGg`2`#sJqy*XZ$_pmS@di$EzPxt3~L_gKd{~nXWL)3V+iVN{{GG!TMv4_?I z*Tj0HYSL-FEbngh8vN+AdLbx&8aK7+dlr@Xv)fQH2UP+phb}F|<9{_1D&|Tm7plqn z`og`!tHSHT^LM$nf#D;)eWM2kx=H9aDRnVL^I21d3!HBFlS)@?qo0}P{95*_kdY8? zL^`>*k->b;;#(o34a`ROFdH4oTi4zT8Ea=Y*2`?{XukCZv`ssiZ5mW;b< Date: Tue, 21 Feb 2023 16:13:34 +0700 Subject: [PATCH 0225/1199] Fix push/pull of energy working while disabled by redstone --- .../dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index 2159a4ab0..96f264442 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -154,7 +154,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo } override fun tick() { - if (energyFlow == FlowDirection.NONE || !automatePull && !automatePush) + if (energyFlow == FlowDirection.NONE || !automatePull && !automatePush || redstoneControl.isBlockedByRedstone) return neighbour.ifPresentK { From 2db9e45291f062e03518ca2333721dfe5ef90c98 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 23 Feb 2023 01:58:42 +0700 Subject: [PATCH 0226/1199] Fix plate press being broken --- .../entity/tech/PlatePressBlockEntity.kt | 29 +++++++++---------- .../client/screen/tech/PlatePressScreen.kt | 2 +- .../mc/otm/menu/input/EnergyPlayerInput.kt | 2 +- .../otm/menu/input/ItemHandlerPlayerInput.kt | 2 +- .../mc/otm/menu/tech/PlatePressMenu.kt | 16 +++++++--- .../mc/otm/recipe/PlatePressRecipe.kt | 2 +- 6 files changed, 29 insertions(+), 24 deletions(-) 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 653db7be9..9d93cff3f 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 @@ -23,8 +23,9 @@ class PlatePressBlockEntity( p_155229_: BlockPos, p_155230_: BlockState ) : MatteryWorkerBlockEntity(MBlockEntities.PLATE_PRESS, p_155229_, p_155230_, ::ItemJob) { - val container = MatteryContainer(this::setChangedLight, 2).also(::addDroppableContainer) val energy = WorkerEnergyStorage(this::setChangedLight, MachinesConfig.PLATE_PRESS) + val inputContainer = MatteryContainer(this::itemContainerUpdated, 1).also(::addDroppableContainer) + val outputContainer = MatteryContainer(this::itemContainerUpdated, 1).also(::addDroppableContainer) var experience = 0.0 @@ -37,19 +38,16 @@ class PlatePressBlockEntity( } } - val itemHandler = container.handler(object : HandlerFilter { - override fun canInsert(slot: Int, stack: ItemStack): Boolean { - return slot != SLOT_OUTPUT - } - - override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { - return slot != SLOT_INPUT - } - }) + val energyConfig = ConfigurableEnergy(energy) + val itemConfig = ConfigurableItemHandler( + input = inputContainer.handler(HandlerFilter.OnlyIn), + output = outputContainer.handler(HandlerFilter.OnlyOut), + ) init { savetable(::energy, ENERGY_KEY) - savetable(::container, INVENTORY_KEY) + savetable(::inputContainer) + savetable(::outputContainer) savetables.double(::experience) } @@ -61,7 +59,7 @@ class PlatePressBlockEntity( if (job.itemStack.isEmpty) return Status.SUCCESS - if (!container.fullyAddItem(job.itemStack, start = SLOT_OUTPUT, end = SLOT_OUTPUT)) + if (!outputContainer.fullyAddItem(job.itemStack)) return Status.FAILURE_ITEM experience = (experience + job.experience).coerceAtMost(100.0) @@ -73,14 +71,13 @@ class PlatePressBlockEntity( return null to IdleReason.POWER } - val recipe = level?.recipeManager?.getRecipeFor(MRecipes.PLATE_PRESS, container, level!!)?.orElse(null) ?: return null to IdleReason.ITEM - container[SLOT_INPUT].shrink(1) + val recipe = level?.recipeManager?.getRecipeFor(MRecipes.PLATE_PRESS, inputContainer, level!!)?.orElse(null) ?: return null to IdleReason.ITEM + inputContainer[0].shrink(1) + inputContainer.setChanged(0) return ItemJob(recipe.resultItem, recipe.workTime.toDouble(), BASELINE_CONSUMPTION, experience = recipe.experience.sample(level!!.random)) to null } companion object { private val BASELINE_CONSUMPTION = Decimal(15) - const val SLOT_INPUT = 0 - const val SLOT_OUTPUT = 1 } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt index cd70a1ef1..9f9c1382b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt @@ -23,7 +23,7 @@ class PlatePressScreen(menu: PlatePressMenu, inventory: Inventory, title: Compon ProgressGaugePanel(this, frame, menu.progressGauge, 78f, PROGRESS_ARROW_TOP) SlotPanel(this, frame, menu.outputSlot, 104f, PROGRESS_SLOT_TOP) - makeDeviceControls(this, frame, redstone = menu.redstone) + makeDeviceControls(this, frame, redstone = menu.redstone, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyPlayerInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyPlayerInput.kt index c74ebac05..2a75d9421 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyPlayerInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyPlayerInput.kt @@ -9,7 +9,7 @@ import ru.dbotthepony.mc.otm.menu.MatteryMenu /** * [allowPull] and [allowPush] controls whenever player is allowed to change these options */ -class EnergyPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = true, val allowPush: Boolean = true) { +class EnergyPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = false, val allowPush: Boolean = false) { var possibleModes by menu.mSynchronizer.enum(FlowDirection::class.java) private set diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt index 2706e5798..f28c3fc29 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt @@ -8,7 +8,7 @@ import ru.dbotthepony.mc.otm.menu.MatteryMenu /** * [allowPull] and [allowPush] controls whenever player is allowed to change these options */ -class ItemHandlerPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = true, val allowPush: Boolean = true) { +class ItemHandlerPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = false, val allowPush: Boolean = false) { inner class Piece(val side: RelativeSide) { private val allowedFlags = MatteryDeviceBlockEntity.ItemHandlerMode.values().map { menu.mSynchronizer.bool() to it } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt index cd4f123cc..dbae50e25 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt @@ -8,6 +8,8 @@ import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity import ru.dbotthepony.mc.otm.menu.MachineOutputSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput +import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -16,18 +18,24 @@ class PlatePressMenu @JvmOverloads constructor( inventory: Inventory, tile: PlatePressBlockEntity? = null ) : MatteryPoweredMenu(MMenus.PLATE_PRESS, containerID, inventory, tile) { - val container = tile?.container ?: SimpleContainer(2) - - val inputSlot = MatterySlot(container, PlatePressBlockEntity.SLOT_INPUT) - val outputSlot = MachineOutputSlot(container, PlatePressBlockEntity.SLOT_OUTPUT) { tile?.popExperience(ply as ServerPlayer) } + val inputSlot = MatterySlot(tile?.inputContainer ?: SimpleContainer(1), 0) + val outputSlot = MachineOutputSlot(tile?.outputContainer ?: SimpleContainer(1), 0) { tile?.popExperience(ply as ServerPlayer) } override val storageSlots: List = ImmutableList.of(inputSlot, outputSlot) val progressGauge = if (tile != null) ProgressGaugeWidget(this, tile::workProgress, tile::isUnableToProcess) else ProgressGaugeWidget(this) + val itemConfig = ItemHandlerPlayerInput(this, allowPush = true) + val energyConfig = EnergyPlayerInput(this, allowPull = true) + init { addSlot(inputSlot) addSlot(outputSlot) addInventorySlots() + + if (tile != null) { + itemConfig.configure(tile.itemConfig) + energyConfig.configure(tile.energyConfig) + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt index 70d2a8f6e..013e9d8a8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt @@ -38,7 +38,7 @@ class PlatePressRecipe( if (output.isActuallyEmpty || input.isActuallyEmpty) return false - return input.test(container[PlatePressBlockEntity.SLOT_INPUT]) + return input.test(container[0]) } private val outputStack: ItemStack by lazy { From 5b12be2ac44f541ef47286310493af4fb01cd5e2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 23 Feb 2023 02:10:57 +0700 Subject: [PATCH 0227/1199] deduplicate stuff --- .../block/entity/MatteryDeviceBlockEntity.kt | 64 +++++++++---------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index 96f264442..be38c2d74 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -210,9 +210,9 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo } inner class ConfigurableItemHandler( - input: IItemHandler? = null, - output: IItemHandler? = null, - battery: IItemHandler? = null, + val input: IItemHandler? = null, + val output: IItemHandler? = null, + val battery: IItemHandler? = null, val frontDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.FRONT), val backDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.BACK), val leftDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.LEFT), @@ -233,12 +233,12 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo exposeSideless(ForgeCapabilities.ITEM_HANDLER, sideless) } - val front = Piece(RelativeSide.FRONT, input, output, battery).also { it.mode = frontDefault } - val back = Piece(RelativeSide.BACK, input, output, battery).also { it.mode = backDefault } - val left = Piece(RelativeSide.LEFT, input, output, battery).also { it.mode = leftDefault } - val right = Piece(RelativeSide.RIGHT, input, output, battery).also { it.mode = rightDefault } - val top = Piece(RelativeSide.TOP, input, output, battery).also { it.mode = topDefault } - val bottom = Piece(RelativeSide.BOTTOM, input, output, battery).also { it.mode = bottomDefault } + val front = Piece(RelativeSide.FRONT).also { it.mode = frontDefault } + val back = Piece(RelativeSide.BACK).also { it.mode = backDefault } + val left = Piece(RelativeSide.LEFT).also { it.mode = leftDefault } + val right = Piece(RelativeSide.RIGHT).also { it.mode = rightDefault } + val top = Piece(RelativeSide.TOP).also { it.mode = topDefault } + val bottom = Piece(RelativeSide.BOTTOM).also { it.mode = bottomDefault } val pieces = immutableMap { put(RelativeSide.FRONT, front) @@ -258,40 +258,38 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo put(RelativeSide.BOTTOM, bottomDefault) } + val possibleViews: ImmutableSet + val inputOutput: IItemHandler? + + init { + val builder = ImmutableSet.Builder() + + builder.add(ItemHandlerMode.DISABLED) + + if (input != null) builder.add(ItemHandlerMode.INPUT) + if (output != null) builder.add(ItemHandlerMode.OUTPUT) + if (input != null && output != null) builder.add(ItemHandlerMode.INPUT_OUTPUT) + if (battery != null) builder.add(ItemHandlerMode.BATTERY) + + possibleViews = builder.build() + + if (input != null && output != null) { + inputOutput = CombinedItemHandler(input, output) + } else { + inputOutput = null + } + } + inner class Piece( val side: RelativeSide, - val input: IItemHandler? = null, - val output: IItemHandler? = null, - val battery: IItemHandler? = null, ) : IItemHandler, ITickable { private var currentHandler: IItemHandler = EmptyItemHandler private val capController = sides[side]!!.Cap(ForgeCapabilities.ITEM_HANDLER, this) private val neighbour by sides[side]!!.track(ForgeCapabilities.ITEM_HANDLER) - val possibleViews: ImmutableSet - val inputOutput: IItemHandler? - init { tickList.always(this) - - val builder = ImmutableSet.Builder() - - builder.add(ItemHandlerMode.DISABLED) - - if (input != null) builder.add(ItemHandlerMode.INPUT) - if (output != null) builder.add(ItemHandlerMode.OUTPUT) - if (input != null && output != null) builder.add(ItemHandlerMode.INPUT_OUTPUT) - if (battery != null) builder.add(ItemHandlerMode.BATTERY) - - possibleViews = builder.build() - capController.close() - - if (input != null && output != null) { - inputOutput = CombinedItemHandler(input, output) - } else { - inputOutput = null - } } var mode by synchronizer.enum(ItemHandlerMode.DISABLED, setter = { value, access, setByRemote -> From a9b28a66ca3b68eab754668396cb87f8d11be63c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 23 Feb 2023 15:11:45 +0700 Subject: [PATCH 0228/1199] Create separate loot item function for saving tile nbt data --- .../mc/otm/datagen/loot/LootTables.kt | 88 +------------------ .../mc/otm/datagen/loot/LootTablesData.kt | 58 +++++------- .../dbotthepony/mc/otm/block/MatteryBlock.kt | 2 +- .../block/entity/MatteryDeviceBlockEntity.kt | 41 ++++----- .../mc/otm/data/loot/CopyTileNbtFunction.kt | 77 ++++++++++++++++ .../otm/menu/input/ItemHandlerPlayerInput.kt | 17 ++-- .../mc/otm/registry/MItemFunctionTypes.kt | 2 + 7 files changed, 135 insertions(+), 150 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt index 2deda7074..a69526acc 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt @@ -24,11 +24,11 @@ import net.minecraft.world.level.storage.loot.functions.SetItemCountFunction import net.minecraft.world.level.storage.loot.parameters.LootContextParamSet import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition -import net.minecraft.world.level.storage.loot.providers.nbt.ContextNbtProvider import net.minecraft.world.level.storage.loot.providers.number.ConstantValue import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity -import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity +import ru.dbotthepony.mc.otm.core.stream +import ru.dbotthepony.mc.otm.data.loot.CopyTileNbtFunction data class NbtCopy(val source: String, val destination: String, val strategy: CopyNbtFunction.MergeStrategy = CopyNbtFunction.MergeStrategy.REPLACE) @@ -155,91 +155,11 @@ class LootTables(generator: DataGenerator) : LootTableProvider(generator.packOut } } - fun tile(block: Block, f: (CopyNbtFunction.Builder) -> Unit = {}) { + fun tile(block: Block, vararg filterTags: String) { singleLootPool(LootContextParamSets.BLOCK, block.lootTable) { add(LootItem.lootTableItem(block).also { - it.apply(CopyNbtFunction.copyData(ContextNbtProvider.BLOCK_ENTITY).also { - it.copy("Name", "BlockEntityTag.Name") - f(it) - }) + it.apply(CopyTileNbtFunction(filterTags.stream())) }) } } - - fun tile(block: Block, vararg tags: NbtCopy) { - tile(block) { - for ((source, destination, strategy) in tags) { - it.copy(source, destination, strategy) - } - } - } - - fun basicTile(block: Block, vararg tags: NbtCopy) { - tile(block) { - for ((source, destination, strategy) in tags) { - it.copy(source, destination, strategy) - } - - for ((source, destination, strategy) in basicTags) { - it.copy(source, destination, strategy) - } - } - } - - fun poweredTile(block: Block, vararg tags: NbtCopy) { - tile(block) { - for ((source, destination, strategy) in tags) { - it.copy(source, destination, strategy) - } - - for ((source, destination, strategy) in poweredTags) { - it.copy(source, destination, strategy) - } - } - } - - fun workerTile(block: Block, vararg tags: NbtCopy) { - tile(block) { - for ((source, destination, strategy) in tags) { - it.copy(source, destination, strategy) - } - - for ((source, destination, strategy) in workerTags) { - it.copy(source, destination, strategy) - } - } - } - - fun matterWorkerTile(block: Block, vararg tags: NbtCopy) { - tile(block) { - for ((source, destination, strategy) in tags) { - it.copy(source, destination, strategy) - } - - for ((source, destination, strategy) in poweredMatterWorker) { - it.copy(source, destination, strategy) - } - } - } - - fun tile(block: Block, vararg tags: String) { - tile(block, *tags.map { NbtCopy(it, "BlockEntityTag.$it", CopyNbtFunction.MergeStrategy.REPLACE) }.toTypedArray()) - } - - // fix overload resolution by adding extra required argument - fun basicTile(block: Block, f: String, vararg tags: String) { - basicTile(block, *tags.map { TileNbtCopy(it) }.toMutableList().also { it.add(TileNbtCopy(f)) }.toTypedArray()) - } - - fun poweredTile(block: Block, f: String, vararg tags: String) { - poweredTile(block, *tags.map { TileNbtCopy(it) }.toMutableList().also { it.add(TileNbtCopy(f)) }.toTypedArray()) - } - - fun workerTile(block: Block, f: String, vararg tags: String) { - workerTile(block, *tags.map { TileNbtCopy(it) }.toMutableList().also { it.add(TileNbtCopy(f)) }.toTypedArray()) - } - - fun matterWorkerTile(block: Block, f: String, vararg tags: String) { - matterWorkerTile(block, *tags.map { TileNbtCopy(it) }.toMutableList().also { it.add(TileNbtCopy(f)) }.toTypedArray()) - } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index a6321136b..f6427365e 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -58,8 +58,6 @@ fun addLootTables(lootTables: LootTables) { lootTables.dropsSelf(MBlocks.METAL_BEAM) { condition(ExplosionCondition.survivesExplosion()) } lootTables.dropsSelf(MBlocks.TRITANIUM_INGOT_BLOCK) { condition(ExplosionCondition.survivesExplosion()) } - lootTables.tile(MBlocks.COBBLESTONE_GENERATOR) - lootTables.dropsSelf(MBlocks.ENGINE) { condition(ExplosionCondition.survivesExplosion()) } for (door in MBlocks.TRITANIUM_TRAPDOOR.values) @@ -133,41 +131,31 @@ fun addLootTables(lootTables: LootTables) { lootPool { item(Items.BLACK_DYE) { setCount(64) } } } + lootTables.tile(MBlocks.COBBLESTONE_GENERATOR) + lootTables.tile(MBlocks.ENERGY_SERVO) + lootTables.tile(MBlocks.ENERGY_COUNTER) + lootTables.tile(MBlocks.CHEMICAL_GENERATOR) + lootTables.tile(MBlocks.HOLO_SIGN) + lootTables.tile(MBlocks.STORAGE_CABLE) + lootTables.tile(MBlocks.ANDROID_STATION) + lootTables.tile(MBlocks.BATTERY_BANK) + lootTables.tile(MBlocks.DRIVE_VIEWER) - lootTables.tile(MBlocks.ENERGY_COUNTER, - EnergyCounterBlockEntity.IO_LIMIT_KEY, EnergyCounterBlockEntity.PASSED_ENERGY_KEY, - EnergyCounterBlockEntity.POWER_HISTORY_KEY, EnergyCounterBlockEntity.POWER_HISTORY_POINTER_KEY) + lootTables.tile(MBlocks.STORAGE_BUS) + lootTables.tile(MBlocks.STORAGE_IMPORTER) + lootTables.tile(MBlocks.STORAGE_EXPORTER) + lootTables.tile(MBlocks.STORAGE_POWER_SUPPLIER) + lootTables.tile(MBlocks.DRIVE_RACK) - lootTables.tile(MBlocks.CHEMICAL_GENERATOR, - ChemicalGeneratorBlockEntity.WORK_TICKS_KEY, - ChemicalGeneratorBlockEntity.WORK_TICKS_TOTAL_KEY, - ENERGY_KEY, - REDSTONE_CONTROL_KEY, - ) + lootTables.tile(MBlocks.MATTER_DECOMPOSER) + lootTables.tile(MBlocks.MATTER_REPLICATOR) + lootTables.tile(MBlocks.MATTER_RECYCLER) + lootTables.tile(MBlocks.MATTER_SCANNER) + lootTables.tile(MBlocks.PLATE_PRESS) - lootTables.tile(MBlocks.HOLO_SIGN, HoloSignBlockEntity.TEXT_KEY, HoloSignBlockEntity.REDSTONE_CONTROL_KEY) - - lootTables.dropsSelf(MBlocks.STORAGE_CABLE) - lootTables.poweredTile(MBlocks.ANDROID_STATION) - lootTables.basicTile(MBlocks.BATTERY_BANK) - lootTables.poweredTile(MBlocks.DRIVE_VIEWER) - - lootTables.poweredTile(MBlocks.STORAGE_BUS, TileNbtCopy(FILTER_KEY)) - lootTables.poweredTile(MBlocks.STORAGE_IMPORTER, TileNbtCopy(FILTER_KEY)) - lootTables.poweredTile(MBlocks.STORAGE_EXPORTER, TileNbtCopy(FILTER_KEY)) - lootTables.poweredTile(MBlocks.STORAGE_POWER_SUPPLIER, TileNbtCopy(StoragePowerSupplierBlockEntity.POWER_PASSED_KEY)) - lootTables.poweredTile(MBlocks.DRIVE_RACK) - - lootTables.matterWorkerTile(MBlocks.MATTER_DECOMPOSER) - lootTables.matterWorkerTile(MBlocks.MATTER_REPLICATOR) - lootTables.matterWorkerTile(MBlocks.MATTER_RECYCLER) - lootTables.workerTile(MBlocks.MATTER_SCANNER) - lootTables.workerTile(MBlocks.PLATE_PRESS) - - lootTables.basicTile(MBlocks.MATTER_PANEL, TileNbtCopy("tasks")) - lootTables.basicTile(MBlocks.PATTERN_STORAGE) - lootTables.basicTile(MBlocks.MATTER_CAPACITOR_BANK) - lootTables.poweredTile(MBlocks.MATTER_BOTTLER, - TileNbtCopy(MATTER_STORAGE_KEY), TileNbtCopy(MatterBottlerBlockEntity.IS_BOTTLING_KEY)) + lootTables.tile(MBlocks.MATTER_PANEL) + lootTables.tile(MBlocks.PATTERN_STORAGE) + lootTables.tile(MBlocks.MATTER_CAPACITOR_BANK) + lootTables.tile(MBlocks.MATTER_BOTTLER) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt index 143fc75aa..f0da2a116 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt @@ -192,7 +192,7 @@ abstract class MatteryBlock @JvmOverloads constructor( newBlockState: BlockState, movedByPiston: Boolean ) { - if (!oldBlockState.`is`(newBlockState.block)) { + if (!oldBlockState.`is`(newBlockState.block) && !level.isClientSide) { val blockentity = level.getBlockEntity(blockPos) if (blockentity is MatteryBlockEntity) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index be38c2d74..9eef5abfc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -221,8 +221,27 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo val bottomDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.BOTTOM), ) { val sideless: IItemHandler + val possibleViews: ImmutableSet + val inputOutput: IItemHandler? init { + val builder = ImmutableSet.Builder() + + builder.add(ItemHandlerMode.DISABLED) + + if (input != null) builder.add(ItemHandlerMode.INPUT) + if (output != null) builder.add(ItemHandlerMode.OUTPUT) + if (input != null && output != null) builder.add(ItemHandlerMode.INPUT_OUTPUT) + if (battery != null) builder.add(ItemHandlerMode.BATTERY) + + possibleViews = builder.build() + + if (input != null && output != null) { + inputOutput = CombinedItemHandler(input, output) + } else { + inputOutput = null + } + val caps = ArrayList() if (input != null) caps.add(input) @@ -258,28 +277,6 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo put(RelativeSide.BOTTOM, bottomDefault) } - val possibleViews: ImmutableSet - val inputOutput: IItemHandler? - - init { - val builder = ImmutableSet.Builder() - - builder.add(ItemHandlerMode.DISABLED) - - if (input != null) builder.add(ItemHandlerMode.INPUT) - if (output != null) builder.add(ItemHandlerMode.OUTPUT) - if (input != null && output != null) builder.add(ItemHandlerMode.INPUT_OUTPUT) - if (battery != null) builder.add(ItemHandlerMode.BATTERY) - - possibleViews = builder.build() - - if (input != null && output != null) { - inputOutput = CombinedItemHandler(input, output) - } else { - inputOutput = null - } - } - inner class Piece( val side: RelativeSide, ) : IItemHandler, ITickable { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt new file mode 100644 index 000000000..c1958d418 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt @@ -0,0 +1,77 @@ +package ru.dbotthepony.mc.otm.data.loot + +import com.google.common.collect.ImmutableList +import com.google.gson.JsonArray +import com.google.gson.JsonDeserializationContext +import com.google.gson.JsonObject +import com.google.gson.JsonPrimitive +import com.google.gson.JsonSerializationContext +import net.minecraft.nbt.CompoundTag +import net.minecraft.world.item.ItemStack +import net.minecraft.world.level.storage.loot.LootContext +import net.minecraft.world.level.storage.loot.Serializer +import net.minecraft.world.level.storage.loot.functions.LootItemFunction +import net.minecraft.world.level.storage.loot.functions.LootItemFunctionType +import net.minecraft.world.level.storage.loot.parameters.LootContextParams +import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.stream +import ru.dbotthepony.mc.otm.core.tagNotNull +import ru.dbotthepony.mc.otm.data.stream +import ru.dbotthepony.mc.otm.registry.MItemFunctionTypes +import java.util.stream.Stream + +class CopyTileNbtFunction(filter: Stream = Stream.empty()) : LootItemFunction, LootItemFunction.Builder { + constructor(filter: Collection) : this(filter.stream()) + constructor(vararg filter: String) : this(filter.stream()) + + val filter: ImmutableList = /*immutableList { + filter.forEach(this) + }*/ filter.collect(ImmutableList.toImmutableList()) + + override fun apply(t: ItemStack, u: LootContext): ItemStack { + val blockEntity = u.getParamOrNull(LootContextParams.BLOCK_ENTITY) ?: return t + val result = t.tagNotNull["BlockEntityTag"] as? CompoundTag + + val data = blockEntity.saveWithoutMetadata() + + for (k in filter) { + data.remove(k) + } + + if (result == null) { + t.tagNotNull["BlockEntityTag"] = data + } else { + for (k in data.allKeys) { + result[k] = data[k]!! + } + } + + return t + } + + override fun getType(): LootItemFunctionType { + return MItemFunctionTypes.COPY_TILE_NBT + } + + override fun build(): LootItemFunction { + return this + } + + companion object : Serializer { + override fun serialize( + pJson: JsonObject, + pValue: CopyTileNbtFunction, + pSerializationContext: JsonSerializationContext + ) { + pJson["filter"] = JsonArray().also { for (v in pValue.filter) it.add(v) } + } + + override fun deserialize( + pJson: JsonObject, + pSerializationContext: JsonDeserializationContext + ): CopyTileNbtFunction { + return CopyTileNbtFunction((pJson["filter"] as? JsonArray)?.stream()?.filter { it is JsonPrimitive }?.map { it.asString!! } ?: Stream.empty()) + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt index f28c3fc29..c565c407e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt @@ -9,10 +9,11 @@ import ru.dbotthepony.mc.otm.menu.MatteryMenu * [allowPull] and [allowPush] controls whenever player is allowed to change these options */ class ItemHandlerPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = false, val allowPush: Boolean = false) { - inner class Piece(val side: RelativeSide) { - private val allowedFlags = MatteryDeviceBlockEntity.ItemHandlerMode.values().map { menu.mSynchronizer.bool() to it } + private val allowedFlags = MatteryDeviceBlockEntity.ItemHandlerMode.values().map { menu.mSynchronizer.bool() to it } + fun isAllowed(value: MatteryDeviceBlockEntity.ItemHandlerMode) = allowedFlags[value.ordinal].first.value - fun isAllowed(value: MatteryDeviceBlockEntity.ItemHandlerMode) = allowedFlags[value.ordinal].first.value + inner class Piece(val side: RelativeSide) { + fun isAllowed(value: MatteryDeviceBlockEntity.ItemHandlerMode) = this@ItemHandlerPlayerInput.isAllowed(value) val pull = BooleanInputWithFeedback(menu) val push = BooleanInputWithFeedback(menu) @@ -26,13 +27,9 @@ class ItemHandlerPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = fal } fun configure(config: MatteryDeviceBlockEntity.ConfigurableItemHandler.Piece) { - for ((f, v) in allowedFlags) { - f.value = v in config.possibleViews - } - pull.with(config::automatePull) push.with(config::automatePush) - input.withSupplier { config.mode }.withConsumer { if (it in config.possibleViews) config.mode = it } + input.withSupplier { config.mode }.withConsumer { if (isAllowed(it)) config.mode = it } } } @@ -50,6 +47,10 @@ class ItemHandlerPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = fal } fun configure(config: MatteryDeviceBlockEntity.ConfigurableItemHandler) { + for ((f, v) in allowedFlags) { + f.value = v in config.possibleViews + } + for ((side, v) in config.pieces) { pieces[side]!!.configure(v) pieces[side]!!.default = config.defaults[side]!! 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 c19180a93..2e5645ad5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItemFunctionTypes.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItemFunctionTypes.kt @@ -6,12 +6,14 @@ import net.minecraft.world.level.storage.loot.functions.LootItemFunctionType import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.registries.DeferredRegister import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.data.loot.CopyTileNbtFunction import ru.dbotthepony.mc.otm.data.loot.RandomizerFunction object MItemFunctionTypes { private val registry = DeferredRegister.create(Registries.LOOT_FUNCTION_TYPE, OverdriveThatMatters.MOD_ID) val RANDOMIZER: LootItemFunctionType by registry.register("randomizer") { LootItemFunctionType(RandomizerFunction.Companion) } + val COPY_TILE_NBT: LootItemFunctionType by registry.register("copy_tile_nbt") { LootItemFunctionType(CopyTileNbtFunction.Companion) } internal fun register(bus: IEventBus) { registry.register(bus) From 689d9cd5c13ad954846873ac4d6b801a2f0a6864 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 23 Feb 2023 15:38:43 +0700 Subject: [PATCH 0229/1199] Some fixes for holo signs save/load, fix for redstone control --- .../mc/otm/datagen/loot/LootTablesData.kt | 2 +- .../block/entity/MatteryDeviceBlockEntity.kt | 23 ++++++++--- .../mc/otm/block/entity/RedstoneControl.kt | 2 +- .../entity/decorative/HoloSignBlockEntity.kt | 38 ++++++++++--------- .../render/blockentity/HoloSignRenderer.kt | 6 +-- .../mc/otm/core/util/Savetables.kt | 12 ++++++ .../mc/otm/menu/decorative/HoloSignMenu.kt | 4 +- 7 files changed, 54 insertions(+), 33 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index f6427365e..37790e3f2 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -136,7 +136,7 @@ fun addLootTables(lootTables: LootTables) { lootTables.tile(MBlocks.ENERGY_SERVO) lootTables.tile(MBlocks.ENERGY_COUNTER) lootTables.tile(MBlocks.CHEMICAL_GENERATOR) - lootTables.tile(MBlocks.HOLO_SIGN) + lootTables.tile(MBlocks.HOLO_SIGN, "isLocked") lootTables.tile(MBlocks.STORAGE_CABLE) lootTables.tile(MBlocks.ANDROID_STATION) lootTables.tile(MBlocks.BATTERY_BANK) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index 9eef5abfc..7c6e8bb9c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -11,6 +11,7 @@ import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.nbt.CompoundTag import net.minecraft.network.chat.Component import net.minecraft.world.item.ItemStack +import net.minecraft.world.level.Level import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.items.IItemHandler import ru.dbotthepony.mc.otm.capability.CombinedItemHandler @@ -30,6 +31,7 @@ import ru.dbotthepony.mc.otm.core.nbt.getJson import ru.dbotthepony.mc.otm.core.nbt.putJson import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.ITickable +import ru.dbotthepony.mc.otm.once /** * Device block entity base, implementing [MenuProvider] and [IRedstoneControlled], and also tracks custom display name @@ -38,13 +40,17 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo : MatteryBlockEntity(blockEntityType, blockPos, blockState), MenuProvider, IRedstoneControlled { var customDisplayName: Component? = null - override val redstoneControl: AbstractRedstoneControl = RedstoneControl { new, old -> + override val redstoneControl = RedstoneControl { new, old -> setChangedLight() if (new != old) redstoneStatusUpdated(new, old) } + init { + savetables.stateful(::redstoneControl, REDSTONE_CONTROL_KEY) + } + protected open val defaultDisplayName: Component get() = level?.getBlockState(blockPos)?.block?.name ?: TextComponent("null at $blockPos") @@ -58,18 +64,23 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo override fun saveAdditional(nbt: CompoundTag) { super.saveAdditional(nbt) - if (customDisplayName != null) nbt.putJson("Name", Component.Serializer.toJsonTree(customDisplayName!!)) - - nbt[REDSTONE_CONTROL_KEY] = redstoneControl.serializeNBT() } override fun load(nbt: CompoundTag) { super.load(nbt) - customDisplayName = nbt.getJson("Name")?.let(Component.Serializer::fromJson) - redstoneControl.deserializeNBT(nbt[REDSTONE_CONTROL_KEY] as? CompoundTag) + } + + override fun setLevel(level: Level) { + super.setLevel(level) + + level.once { + if (!isRemoved && this.level == level) { + redstoneControl.redstoneSignal = level.getBestNeighborSignal(blockPos) + } + } } inner class ConfigurableEnergy( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt index a022d1918..e6d4c3180 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt @@ -10,7 +10,7 @@ interface IRedstoneControlled { val redstoneControl: AbstractRedstoneControl } -abstract class AbstractRedstoneControl : INBTSerializable { +abstract class AbstractRedstoneControl : INBTSerializable { abstract var redstoneSetting: RedstoneSetting abstract var redstoneSignal: Int diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt index a4b1b36ff..dd121d04a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt @@ -7,24 +7,31 @@ import net.minecraft.world.MenuProvider import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu +import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState import ru.dbotthepony.mc.otm.block.entity.IRedstoneControlled import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.block.entity.SynchronizedRedstoneControl -import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.menu.decorative.HoloSignMenu +import ru.dbotthepony.mc.otm.once import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlocks class HoloSignBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryBlockEntity(MBlockEntities.HOLO_SIGN, blockPos, blockState), MenuProvider, IRedstoneControlled { override val redstoneControl = SynchronizedRedstoneControl(synchronizer) { _, _ -> setChanged() } - var text by synchronizer.string("", name = "text", setter = { value, access, remote -> + var signText by synchronizer.string("", name = "text", setter = { value, access, remote -> setChanged() access.write(value) }) - var locked = false + var isLocked = false + + init { + savetables.string(::signText) + savetables.bool(::isLocked) + savetables.stateful(::redstoneControl) + } override fun createMenu(p_39954_: Int, p_39955_: Inventory, p_39956_: Player): AbstractContainerMenu { return HoloSignMenu(p_39954_, p_39955_, this) @@ -34,29 +41,24 @@ class HoloSignBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryB return MBlocks.HOLO_SIGN.name } - override fun saveAdditional(nbt: CompoundTag) { - super.saveAdditional(nbt) - nbt[TEXT_KEY] = text - nbt[REDSTONE_CONTROL_KEY] = redstoneControl.serializeNBT() + override fun setLevel(level: Level) { + super.setLevel(level) + + level.once { + if (!isRemoved && this.level == level) { + redstoneControl.redstoneSignal = level.getBestNeighborSignal(blockPos) + } + } } override fun load(nbt: CompoundTag) { super.load(nbt) - locked = nbt.getBoolean(LOCKED_KEY) - if (locked) { - text = nbt.getString(TEXT_KEY) - } else { - text = truncate(nbt.getString(TEXT_KEY)) - } - - redstoneControl.deserializeNBT(nbt[REDSTONE_CONTROL_KEY] as? CompoundTag) + if (!isLocked) + signText = truncate(signText) } companion object { - const val TEXT_KEY = "SignText" - const val LOCKED_KEY = "Locked" - const val REDSTONE_CONTROL_KEY = "RedstoneControl" const val DEFAULT_MAX_NEWLINES = 8 const val DEFAULT_MAX_LINE_LENGTH = 15 private val NEWLINES = Regex("\r?\n") 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 80c8aa5c2..a482b3641 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 @@ -4,16 +4,12 @@ import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.client.renderer.blockentity.BlockEntityRenderer import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider -import net.minecraft.core.Direction -import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity import ru.dbotthepony.mc.otm.client.font import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.render.TextAlign import ru.dbotthepony.mc.otm.client.render.drawAligned -import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.RGBAColor -import ru.dbotthepony.mc.otm.core.math.facingTwo import ru.dbotthepony.mc.otm.core.math.rotateWithBlockFacing import ru.dbotthepony.mc.otm.core.math.rotationThree @@ -36,7 +32,7 @@ class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context) val sorse = DynamicBufferSource.WORLD - val lines = tile.text.split('\n') + val lines = tile.signText.split('\n') val totalHeight = lines.size * font.lineHeight + (lines.size - 1) * 2f var y = -totalHeight / 2f diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt index 81a89bdcd..51630470b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt @@ -135,6 +135,18 @@ class Savetables : INBTSerializable { .withDeserializer { it.asByte > 0 } } + fun string(prop: GetterSetter, name: String): Stateless { + return Stateless(prop, name, StringTag::class.java) + .withSerializer { StringTag.valueOf(it) } + .withDeserializer { it.asString } + } + + fun string(prop: KMutableProperty0, name: String = prop.name): Stateless { + return Stateless(prop, name, StringTag::class.java) + .withSerializer { StringTag.valueOf(it) } + .withDeserializer { it.asString } + } + fun > enum(prop: GetterSetter, name: String, map: (String) -> E): Stateless { return Stateless(prop, name, StringTag::class.java) .withSerializer { StringTag.valueOf(it.name) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt index a9495dfa8..205f3e5f7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt @@ -25,8 +25,8 @@ class HoloSignMenu @JvmOverloads constructor( locked.filter { it.isCreative } if (tile != null) { - text.withConsumer { if (tile.locked) tile.text = it else tile.text = HoloSignBlockEntity.truncate(it) }.withSupplier(tile::text) - locked.with(tile::locked) + text.withConsumer { if (tile.isLocked) tile.signText = it else tile.signText = HoloSignBlockEntity.truncate(it) }.withSupplier(tile::signText) + locked.with(tile::isLocked) redstone.with(tile.redstoneControl::redstoneSetting) } } From 53563e9982ee3bf4b0ee4b4ee6e2efa14a323e28 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 23 Feb 2023 19:01:20 +0700 Subject: [PATCH 0230/1199] Try to narrow down the issue with missing field id mappings --- .../kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt index d9e3f8068..eb573c63f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt @@ -1140,6 +1140,10 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } } + if (idToField.isEmpty()) { + throw IllegalStateException("Can't read anything, field ID mapping is empty!") + } + var fieldId = stream.readVarIntLE(sizeLimit) var i = 0 From 10e71d2ab8fda08461589e6890e4a5b0112405c3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 23 Feb 2023 20:40:06 +0700 Subject: [PATCH 0231/1199] sure buddy --- .../ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt index 3242a016c..41f0ef33e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt @@ -28,9 +28,9 @@ private fun Player.getCuriosSlotsImpl(): Collection> { val sortedIdentifiers = ArrayList(handler.curios.keys.size) sortedIdentifiers.addAll(handler.curios.keys) - if (handler.curios !is LinkedHashMap) { - sortedIdentifiers.sort() - } + //if (handler.curios !is LinkedHashMap) { + // sortedIdentifiers.sort() + //} for (identifier in sortedIdentifiers) { val curio = handler.curios[identifier]!! From a36e47c6295b61f7a06ddb08030f702467c06b98 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 24 Feb 2023 14:31:26 +0700 Subject: [PATCH 0232/1199] For the love of god --- .../mc/otm/network/WorldNetworkChannel.kt | 66 ++++++++++++++++--- 1 file changed, 56 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt index b135c3f94..30a9e1273 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt @@ -1,14 +1,20 @@ package ru.dbotthepony.mc.otm.network import it.unimi.dsi.fastutil.io.FastByteArrayInputStream +import it.unimi.dsi.fastutil.objects.Object2ObjectFunction +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap import net.minecraft.core.BlockPos import net.minecraft.network.FriendlyByteBuf +import net.minecraft.world.level.Level import net.minecraftforge.network.NetworkDirection import net.minecraftforge.network.NetworkEvent import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.android.feature.ItemEntityDataPacket import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.client.onceClient +import java.lang.ref.SoftReference +import java.util.WeakHashMap import java.util.function.Supplier class BlockEntitySyncPacket(val position: BlockPos, val buffer: ByteArray, val validBytes: Int) : MatteryPacket { @@ -17,23 +23,63 @@ class BlockEntitySyncPacket(val position: BlockPos, val buffer: ByteArray, val v buff.writeBytes(buffer, 0, validBytes) } + private fun execute() { + val level = minecraft.player?.level + + if (level == null) { + LOGGER.error("Received BlockEntitySyncPacket before we are in valid level.") + + onceClient { + execute() + } + + return + } + + val blockEntity = level.getBlockEntity(position) + + if (blockEntity == null) { + LOGGER.warn("Putting BlockEntitySyncPacket received for $position into backlog because there is literally no block entity there!") + LOGGER.warn("This is CERTAINLY a bug in one of optimizing mods you have or server has installed!") + LOGGER.warn("This can cause memory leak.") + + backlog.computeIfAbsent(level) { Object2ObjectOpenHashMap() } + .computeIfAbsent(position, Object2ObjectFunction { ArrayList() }) + .add(this) + + return + } else if (blockEntity !is MatteryBlockEntity) { + LOGGER.warn("Dropping BlockEntitySyncPacket received for $position, because there is $blockEntity which is not MatteryBlockEntity!") + backlog[level]?.remove(position) + return + } + + val packets = backlog[level]?.remove(position) + + try { + if (packets != null) { + for (packet in packets) { + blockEntity.synchronizer.read(FastByteArrayInputStream(packet.buffer, 0, packet.validBytes)) + } + } + + blockEntity.synchronizer.read(FastByteArrayInputStream(buffer, 0, validBytes)) + } catch(err: Throwable) { + LOGGER.error("Exception while reading synchronized BlockEntity data!\nPosition: $position\nBlock: ${level.getBlockState(position)}\nBlock entity: $blockEntity", err) + } + } + override fun play(context: Supplier) { context.packetHandled = true context.enqueueWork { - val level = minecraft.player?.level ?: return@enqueueWork - val blockEntity = level.getBlockEntity(position) as? MatteryBlockEntity ?: return@enqueueWork - - try { - blockEntity.synchronizer.read(FastByteArrayInputStream(buffer, 0, validBytes)) - } catch(err: Throwable) { - LOGGER.error("Exception while reading synchronized BlockEntity data!\nPosition: $position\nBlock: ${level.getBlockState(position)}\nBlock entity: $blockEntity", err) - throw err - } + execute() } } companion object { + private val backlog = WeakHashMap>>() + fun read(buff: FriendlyByteBuf): BlockEntitySyncPacket { val position = buff.readBlockPos() val size = buff.readableBytes() @@ -47,7 +93,7 @@ class BlockEntitySyncPacket(val position: BlockPos, val buffer: ByteArray, val v } object WorldNetworkChannel : MatteryNetworkChannel( - version = "2", + version = "3", name = "world" ) { fun register() { From 59689011a158bc62418466798499d90103e2e4f0 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Feb 2023 17:59:24 +0700 Subject: [PATCH 0233/1199] Fix soft deadlock in storage interfaces --- .../block/entity/storage/StorageInterfaces.kt | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt index fe8120e81..ec4d9b8b9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt @@ -36,6 +36,7 @@ import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode import ru.dbotthepony.mc.otm.graph.storage.StorageNetworkGraph import ru.dbotthepony.mc.otm.menu.storage.StorageExporterMenu import ru.dbotthepony.mc.otm.menu.storage.StorageImporterMenu +import ru.dbotthepony.mc.otm.once import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.storage.IStorageEventConsumer @@ -63,17 +64,25 @@ abstract class AbstractStorageImportExport( val cell: BasicStorageGraphNode = object : BasicStorageGraphNode(energy), GraphNodeListener { override fun onNeighbour(node: Graph6Node<*>, direction: Direction) { - val newState = this@AbstractStorageImportExport.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, true) + level?.once { + if (!isRemoved) { + val newState = this@AbstractStorageImportExport.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, true) - if (newState !== this@AbstractStorageImportExport.blockState && SERVER_IS_LIVE) - level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + if (newState !== this@AbstractStorageImportExport.blockState && SERVER_IS_LIVE) + level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + } + } } override fun onUnNeighbour(node: Graph6Node<*>, direction: Direction) { - val newState = this@AbstractStorageImportExport.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, false) + level?.once { + if (!isRemoved) { + val newState = this@AbstractStorageImportExport.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, false) - if (newState !== this@AbstractStorageImportExport.blockState && SERVER_IS_LIVE) - level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + if (newState !== this@AbstractStorageImportExport.blockState && SERVER_IS_LIVE) + level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + } + } } } From c555b2f318b6d72a3cb92adb72c994f3704d0a46 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Feb 2023 17:59:52 +0700 Subject: [PATCH 0234/1199] More savetables types, make savetables compatible to be nested --- .../mc/otm/core/util/Savetables.kt | 60 ++++++++++++++++--- 1 file changed, 52 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt index 51630470b..000799c2c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt @@ -5,13 +5,16 @@ import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.DoubleTag import net.minecraft.nbt.FloatTag import net.minecraft.nbt.IntTag +import net.minecraft.nbt.ListTag import net.minecraft.nbt.NumericTag import net.minecraft.nbt.StringTag import net.minecraft.nbt.Tag +import net.minecraft.resources.ResourceLocation import net.minecraftforge.common.util.INBTSerializable import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.asGetterSetter import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.nbt.set import java.util.function.Supplier import kotlin.reflect.KMutableProperty0 @@ -20,7 +23,7 @@ import kotlin.reflect.KProperty0 /** * Utility class to manage list of composited properties in other classes to be (de)serialized in NBT tags */ -class Savetables : INBTSerializable { +class Savetables : INBTSerializable { private val entries = ArrayList>() interface Entry : INBTSerializable { @@ -159,6 +162,41 @@ class Savetables : INBTSerializable { .withDeserializer { map.invoke(it.asString) } } + fun vector(prop: GetterSetter, name: String, default: Vector = Vector.ZERO): Stateless { + return Stateless(prop, name, ListTag::class.java) + .withSerializer { ListTag().also { l -> + l.add(DoubleTag.valueOf(it.x)) + l.add(DoubleTag.valueOf(it.y)) + l.add(DoubleTag.valueOf(it.z)) + } } + .withDeserializer { + if (it.size < 3) { + default + } else { + val x = it[0] as? NumericTag ?: return@withDeserializer default + val y = it[1] as? NumericTag ?: return@withDeserializer default + val z = it[2] as? NumericTag ?: return@withDeserializer default + Vector(x.asDouble, y.asDouble, z.asDouble) + } + } + } + + fun vector(prop: KMutableProperty0, name: String = prop.name, default: Vector = Vector.ZERO): Stateless { + return vector(prop.asGetterSetter(), name, default) + } + + fun location(prop: GetterSetter, name: String): Stateless { + return Stateless(prop, name, StringTag::class.java) + .withSerializer { StringTag.valueOf(it.toString()) } + .withDeserializer { ResourceLocation(it.asString) } + } + + fun location(prop: KMutableProperty0, name: String = prop.name): Stateless { + return Stateless(prop, name, StringTag::class.java) + .withSerializer { StringTag.valueOf(it.toString()) } + .withDeserializer { ResourceLocation(it.asString) } + } + override fun serializeNBT(): CompoundTag { return CompoundTag().also(::serializeNBT) } @@ -174,17 +212,23 @@ class Savetables : INBTSerializable { validated = true } - override fun deserializeNBT(nbt: CompoundTag) { + override fun deserializeNBT(nbt: CompoundTag?) { validate() - for (entry in entries) { - val value = nbt[entry.name] - - if (value != null && entry.type.isAssignableFrom(value.javaClass)) { - (entry as INBTSerializable).deserializeNBT(value) - } else { + if (nbt == null) { + for (entry in entries) { entry.deserializeNBT(null) } + } else { + for (entry in entries) { + val value = nbt[entry.name] + + if (value != null && entry.type.isAssignableFrom(value.javaClass)) { + (entry as INBTSerializable).deserializeNBT(value) + } else { + entry.deserializeNBT(null) + } + } } } From 9924711f31f71f6a1a5756890b9fbfe6f4c499cb Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Feb 2023 18:00:16 +0700 Subject: [PATCH 0235/1199] Make UUIDIntModifiersMap compatible with savetables --- .../dbotthepony/mc/otm/core/collect/UUIDIntModifiersMap.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/UUIDIntModifiersMap.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/UUIDIntModifiersMap.kt index 7f7a4174a..9895d02c8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/UUIDIntModifiersMap.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/UUIDIntModifiersMap.kt @@ -11,7 +11,7 @@ import java.util.UUID * * This is like Minecraft's Attribute map, except it operate only on whole numbers */ -class UUIDIntModifiersMap(private val observer: (Int) -> Unit, private val backingMap: MutableMap = HashMap()) : INBTSerializable { +class UUIDIntModifiersMap(private val observer: (Int) -> Unit, private val backingMap: MutableMap = HashMap()) : INBTSerializable { var value: Int = 0 private set @@ -78,8 +78,9 @@ class UUIDIntModifiersMap(private val observer: (Int) -> Unit, private val backi } } - override fun deserializeNBT(nbt: ListTag) { + override fun deserializeNBT(nbt: ListTag?) { backingMap.clear() + nbt ?: return val old = this.value this.value = 0 From 5b4c68b2017e7675256bf260b182c66288fc641a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Feb 2023 18:11:54 +0700 Subject: [PATCH 0236/1199] More achievements! Travel underwater without Air Bags, fixes #209 Kill Elder Guardian without Air Bags, fixes #210 Kill the Wither as Android, fixes #206 --- .../advancements/AndroidAdvancementsData.kt | 76 ++++++- .../mc/otm/OverdriveThatMatters.java | 3 + .../otm/capability/MatteryPlayerCapability.kt | 78 +++++-- .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 8 + .../dbotthepony/mc/otm/registry/MRegistry.kt | 4 + .../otm/triggers/AndroidTravelUnderwater.kt | 40 ++++ .../mc/otm/triggers/KillAsAndroidTrigger.kt | 201 ++++++++++++++++++ 7 files changed, 389 insertions(+), 21 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidTravelUnderwater.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/triggers/KillAsAndroidTrigger.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt index 9d53300a1..cc035e41f 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt @@ -20,17 +20,20 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.datagen.DataGen import ru.dbotthepony.mc.otm.datagen.lang.MatteryLanguageProvider import ru.dbotthepony.mc.otm.datagen.modLocation +import ru.dbotthepony.mc.otm.registry.AndroidFeatures import ru.dbotthepony.mc.otm.registry.MItemTags import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.triggers.AndroidBatteryTrigger import ru.dbotthepony.mc.otm.triggers.AndroidResearchTrigger +import ru.dbotthepony.mc.otm.triggers.AndroidTravelUnderwater import ru.dbotthepony.mc.otm.triggers.BecomeAndroidDeathTrigger import ru.dbotthepony.mc.otm.triggers.BecomeAndroidSleepTrigger import ru.dbotthepony.mc.otm.triggers.BecomeAndroidTrigger import ru.dbotthepony.mc.otm.triggers.BecomeHumaneTrigger import ru.dbotthepony.mc.otm.triggers.EnderTeleporterFallDeathTrigger import ru.dbotthepony.mc.otm.triggers.FallDampenersSaveTrigger +import ru.dbotthepony.mc.otm.triggers.KillAsAndroidTrigger import ru.dbotthepony.mc.otm.triggers.NanobotsArmorTrigger import ru.dbotthepony.mc.otm.triggers.PhantomSpawnDeniedTrigger import ru.dbotthepony.mc.otm.triggers.ShockwaveDamageMobTrigger @@ -46,8 +49,8 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper title = translation.add("root", "Androids and Humans") { russian("Андроиды и Люди") }, - description = translation.add("root.desc", "Can you make out who is cruel machine and who care about others?") { - russian("Сможете ли вы отличить бездушную машину от того, кому другие не безразличны?") + description = translation.add("root.desc", "Can you make out who is cruel machine and who shows empathy?") { + russian("Сможете ли вы отличить бездушную машину от того, кто показывает сочувствие?") }, showToast = false, announceChat = false, @@ -381,4 +384,73 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper ) .addCriterion("shockwave_warden", ShockwaveDamageMobTrigger.Instance(EntityPredicate.Builder.entity().of(EntityType.WARDEN).build().wrap())) .save(serializer, modLocation("android/shockwave_warden"), existingFileHelper) + + AdvancementBuilder() + .parent(root) + .display( + itemStack = ItemStack(Items.WITHER_SKELETON_SKULL), + title = translation.add("wither", "Not Quite Alive, Not Quite Undead") { + russian("Ни Живой, Ни Мёртвый") + }, + description = translation.add("wither.desc", "Defeat The Wither as Android. The Wither was surely confused over kind of thing you are") { + russian("Победите Иссушителя будучи Андроидом. Наверняка Иссушитель был ошеломлён таким раскладом дел") + }, + frameType = FrameType.GOAL, + hidden = true + ) + .addCriterion("kill_wither", KillAsAndroidTrigger.Instance( + predicate = EntityPredicate.Builder.entity().of(EntityType.WITHER).build().wrap(), + )) + .save(serializer, modLocation("android/wither"), existingFileHelper) + + val underwater = AdvancementBuilder() + .parent(root) + .display( + itemStack = ItemStack(Items.TURTLE_SPAWN_EGG), + title = translation.add("travel_underwater", "Underwater Walk") { + russian("Подводная Прогулка") + }, + description = translation.add("travel_underwater.desc", "Travel at least 200 meters underwater as Android without Air Bags research. This reminds us of someone...") { + russian("Преодолейте как минимум 200 метров под водой будучи Андроидом без исследования Воздушных Мешков. Кого-то это нам напоминает...") + }, + frameType = FrameType.GOAL, + hidden = true + ) + .addCriterion("travel", AndroidTravelUnderwater.Instance(200.0)) + .save(serializer, modLocation("android/underwater"), existingFileHelper) + + AdvancementBuilder() + .parent(underwater) + .display( + itemStack = ItemStack(Items.TURTLE_SPAWN_EGG), + title = translation.add("travel_underwater2", "Underwater Travel") { + russian("Подводная Прогулка") + }, + description = translation.add("travel_underwater2.desc", "Travel at least 1046 meters underwater as Android without Air Bags research, like someone else did so") { + russian("Преодолейте как минимум 1046 метров под водой будучи Андроидом без исследования Воздушных Мешков, прям как тот, кто так однажды так и сделал") + }, + frameType = FrameType.CHALLENGE, + hidden = true + ) + .addCriterion("travel", AndroidTravelUnderwater.Instance(1046.0)) + .save(serializer, modLocation("android/underwater2"), existingFileHelper) + + AdvancementBuilder() + .parent(root) + .display( + itemStack = ItemStack(Items.PRISMARINE_CRYSTALS), + title = translation.add("elder_guardian", "Drowned, but Still Determined") { + russian("Затонувший, но Всё Ещё Целеустремлённый") + }, + description = translation.add("elder_guardian.desc", "Slay Elder Guardian as Android without Air Bags researched") { + russian("Победите Древнего Стража будучи Андроидом без исследования Воздушных Мешков") + }, + frameType = FrameType.CHALLENGE, + hidden = true + ) + .addCriterion("kill_elder_guardian", KillAsAndroidTrigger.Instance( + predicate = EntityPredicate.Builder.entity().of(EntityType.ELDER_GUARDIAN).build().wrap(), + featurePredicate = KillAsAndroidTrigger.Not(KillAsAndroidTrigger.Has(AndroidFeatures.AIR_BAGS.registryName!!)) + )) + .save(serializer, modLocation("android/elder_guardian"), existingFileHelper) } diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index e4d26df10..46bf4ab8b 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -50,6 +50,7 @@ import ru.dbotthepony.mc.otm.matter.MatterManager; import ru.dbotthepony.mc.otm.network.*; import ru.dbotthepony.mc.otm.registry.*; import ru.dbotthepony.mc.otm.storage.*; +import ru.dbotthepony.mc.otm.triggers.KillAsAndroidTrigger; import static net.minecraftforge.common.MinecraftForge.EVENT_BUS; @@ -177,6 +178,8 @@ public final class OverdriveThatMatters { EVENT_BUS.addListener(EventPriority.NORMAL, MatteryBlockEntity.Companion::playerDisconnected); EVENT_BUS.addListener(EventPriority.LOWEST, MatteryBlockEntity.Companion::postLevelTick); + EVENT_BUS.addListener(EventPriority.LOWEST, KillAsAndroidTrigger.INSTANCE::onKill); + EVENT_BUS.addListener(EventPriority.NORMAL, EnderTeleporterFeature.Companion::onEntityDeath); EVENT_BUS.addListener(EventPriority.HIGH, ItemTritaniumArmor.Companion::onHurt); diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index c73cc4d96..506e347a9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -21,6 +21,7 @@ import net.minecraft.world.entity.player.Player import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ProjectileWeaponItem import net.minecraft.world.item.enchantment.EnchantmentHelper.hasVanishingCurse +import net.minecraft.world.phys.Vec3 import net.minecraftforge.common.ForgeHooks import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ICapabilityProvider @@ -53,16 +54,19 @@ import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.collect.UUIDIntModifiersMap import ru.dbotthepony.mc.otm.core.collect.nonEmpty import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.minus import ru.dbotthepony.mc.otm.core.nbt.getCompoundList import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.IntValueCodec +import ru.dbotthepony.mc.otm.core.util.Savetables import ru.dbotthepony.mc.otm.core.util.UUIDValueCodec import ru.dbotthepony.mc.otm.menu.ExoPackInventoryMenu import ru.dbotthepony.mc.otm.network.* import ru.dbotthepony.mc.otm.registry.AndroidFeatures import ru.dbotthepony.mc.otm.registry.MRegistry import ru.dbotthepony.mc.otm.triggers.AndroidResearchTrigger +import ru.dbotthepony.mc.otm.triggers.AndroidTravelUnderwater import ru.dbotthepony.mc.otm.triggers.BecomeAndroidDeathTrigger import ru.dbotthepony.mc.otm.triggers.BecomeAndroidSleepTrigger import ru.dbotthepony.mc.otm.triggers.BecomeAndroidTrigger @@ -98,6 +102,11 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial */ val synchronizer = FieldSynchronizer() + /** + * For data to be stored and loaded from NBT automatically + */ + val savetables = Savetables() + /** * For fields that need to be synchronized to everyone * @@ -251,6 +260,19 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial var ticksIExist = 0 private set + private var lastOutsideLiquid = Vec3(0.0, 0.0, 0.0) + private var wasInLiquid = false + private var lastDimension = ResourceLocation("overworld") + + init { + savetables.int(::ticksIExist) + savetables.int(::iteration) + savetables.bool(::shouldSendIteration) + savetables.bool(::wasInLiquid) + savetables.vector(::lastOutsideLiquid) + savetables.location(::lastDimension) + } + /** * Whenever player should become an Android once transformation conditions are met (e.g. player dies or sleeps in bed) */ @@ -326,6 +348,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial androidEnergy.batteryLevel = AndroidConfig.ANDROID_MAX_ENERGY androidEnergy.maxBatteryLevel = AndroidConfig.ANDROID_MAX_ENERGY + lastOutsideLiquid = ply.position() + wasInLiquid = false + if (ply is ServerPlayer) { BecomeAndroidTrigger.trigger(ply) } @@ -374,6 +399,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial androidEnergy.maxBatteryLevel = AndroidConfig.ANDROID_MAX_ENERGY dropBattery() + lastOutsideLiquid = ply.position() + wasInLiquid = false + if (ply is ServerPlayer) { BecomeHumaneTrigger.trigger(ply) } @@ -574,14 +602,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } override fun serializeNBT(): CompoundTag { - val tag = CompoundTag() - - tag["ticksIExist"] = ticksIExist + val tag = savetables.serializeNBT() // iteration - tag["iteration"] = iteration - tag["shouldSendIteration"] = shouldSendIteration - tag["deathLog"] = ListTag().also { for ((ticks, component) in deathLog) { it.add(CompoundTag().also { @@ -626,12 +649,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } override fun deserializeNBT(tag: CompoundTag) { - ticksIExist = tag.getInt("ticksIExist") + savetables.deserializeNBT(tag) // iterations - iteration = tag.getInt("iteration") - shouldSendIteration = tag.getBoolean("shouldSendIteration") - deathLog.clear() for (value in tag.getCompoundList("deathLog")) { @@ -773,18 +793,38 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } if (isAndroid) { - if (!ply.isSpectator && ply.airSupply < ply.maxAirSupply) - ply.airSupply = ply.maxAirSupply - - // TODO: Maybe passive drain? - // extractEnergyInner(BigDecimal.valueOf(new Random().nextDouble()), false); - if (!ply.isSpectator && ply.isSwimming && !hasFeature(AndroidFeatures.AIR_BAGS)) { - ply.isSwimming = false - } - androidEnergy.tick() if (!ply.isSpectator) { + if (ply.airSupply < ply.maxAirSupply) + ply.airSupply = ply.maxAirSupply + + if (ply.isSwimming && !hasFeature(AndroidFeatures.AIR_BAGS)) + ply.isSwimming = false + + if (ply is ServerPlayer) { + if (ply.level.dimension().location() != lastDimension) { + lastDimension = ply.level.dimension().location() + wasInLiquid = false + lastOutsideLiquid = ply.position + } + + if (ply.isUnderWater) { + if (!wasInLiquid) { + wasInLiquid = true + lastOutsideLiquid = ply.position + } + } else { + if (wasInLiquid) { + wasInLiquid = false + val distance = (lastOutsideLiquid - ply.position).length() + AndroidTravelUnderwater.trigger(ply, distance) + } + + lastOutsideLiquid = ply.position + } + } + val stats = ply.foodData while (stats.foodLevel < 18 && androidEnergy.extractEnergy(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT, true) >= AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT) { 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 4ca99c91e..05c455fe9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -298,3 +298,11 @@ fun > BlockState.getValueNullable(prop: Property): T? { return null } + +fun Stream.asIterable(): Iterable { + return object : Iterable { + override fun iterator(): Iterator { + return this@asIterable.iterator() + } + } +} 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 e7bfac5fb..ae466a53c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -34,7 +34,9 @@ import ru.dbotthepony.mc.otm.registry.objects.CrateProperties import ru.dbotthepony.mc.otm.registry.objects.DecorativeBlock import ru.dbotthepony.mc.otm.registry.objects.StripedColoredDecorativeBlock import ru.dbotthepony.mc.otm.triggers.AndroidBatteryTrigger +import ru.dbotthepony.mc.otm.triggers.KillAsAndroidTrigger import ru.dbotthepony.mc.otm.triggers.AndroidResearchTrigger +import ru.dbotthepony.mc.otm.triggers.AndroidTravelUnderwater import ru.dbotthepony.mc.otm.triggers.BecomeAndroidDeathTrigger import ru.dbotthepony.mc.otm.triggers.BecomeAndroidSleepTrigger import ru.dbotthepony.mc.otm.triggers.BecomeAndroidTrigger @@ -265,6 +267,8 @@ object MRegistry { CriteriaTriggers.register(NanobotsArmorTrigger) CriteriaTriggers.register(FallDampenersSaveTrigger) CriteriaTriggers.register(EnderTeleporterFallDeathTrigger) + CriteriaTriggers.register(KillAsAndroidTrigger) + CriteriaTriggers.register(AndroidTravelUnderwater) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidTravelUnderwater.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidTravelUnderwater.kt new file mode 100644 index 000000000..4224aed90 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidTravelUnderwater.kt @@ -0,0 +1,40 @@ +package ru.dbotthepony.mc.otm.triggers + +import com.google.gson.JsonObject +import com.google.gson.JsonParseException +import com.google.gson.JsonPrimitive +import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance +import net.minecraft.advancements.critereon.DeserializationContext +import net.minecraft.advancements.critereon.EntityPredicate +import net.minecraft.advancements.critereon.SerializationContext +import net.minecraft.advancements.critereon.SimpleCriterionTrigger +import net.minecraft.resources.ResourceLocation +import net.minecraft.server.level.ServerPlayer +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.core.set + +object AndroidTravelUnderwater : SimpleCriterionTrigger() { + val ID = ResourceLocation(OverdriveThatMatters.MOD_ID, "android_walk_underwater") + + override fun getId(): ResourceLocation { + return ID + } + + override fun createInstance(pJson: JsonObject, pPlayer: EntityPredicate.Composite, pContext: DeserializationContext): Instance { + return Instance((pJson["distance_to_travel"] as? JsonPrimitive)?.asDouble ?: throw JsonParseException("Invalid 'distance_to_travel' value")) + } + + fun trigger(player: ServerPlayer, travelled: Double) { + trigger(player) { + it.distanceToTravel <= travelled + } + } + + class Instance(val distanceToTravel: Double) : AbstractCriterionTriggerInstance(ID, EntityPredicate.Composite.ANY) { + override fun serializeToJson(pConditions: SerializationContext): JsonObject { + return super.serializeToJson(pConditions).also { + it["distance_to_travel"] = JsonPrimitive(distanceToTravel) + } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/KillAsAndroidTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/KillAsAndroidTrigger.kt new file mode 100644 index 000000000..2d783b159 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/KillAsAndroidTrigger.kt @@ -0,0 +1,201 @@ +package ru.dbotthepony.mc.otm.triggers + +import com.google.common.collect.ImmutableList +import com.google.gson.JsonArray +import com.google.gson.JsonObject +import com.google.gson.JsonSyntaxException +import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance +import net.minecraft.advancements.critereon.DeserializationContext +import net.minecraft.advancements.critereon.EntityPredicate +import net.minecraft.advancements.critereon.SerializationContext +import net.minecraft.advancements.critereon.SimpleCriterionTrigger +import net.minecraft.resources.ResourceLocation +import net.minecraft.server.level.ServerPlayer +import net.minecraft.world.entity.monster.ElderGuardian +import net.minecraftforge.event.entity.living.LivingDeathEvent +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability +import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.core.asIterable +import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.stream +import ru.dbotthepony.mc.otm.registry.MRegistry +import java.util.function.Predicate + +object KillAsAndroidTrigger : SimpleCriterionTrigger() { + val ID = ResourceLocation(OverdriveThatMatters.MOD_ID, "kill_as_android") + + override fun getId(): ResourceLocation { + return ID + } + + override fun createInstance(pJson: JsonObject, pPlayer: EntityPredicate.Composite, pContext: DeserializationContext): Instance { + return Instance( + predicate = EntityPredicate.Composite.fromJson(pJson, "predicate", pContext), + playerPredicate = pPlayer, + featurePredicate = (pJson["feature_predicate"] as? JsonObject)?.let(PredicateType::from) ?: throw JsonSyntaxException("Invalid 'feature_predicate': ${pJson["feature_predicate"]}") + ) + } + + enum class PredicateType(val factory: (JsonObject) -> FeaturePredicate) { + ALWAYS({ Always }), + HAS(::Has), + NOT(::Not), + AND(::And), + OR(::OrPredicate); + + companion object { + fun from(json: JsonObject): FeaturePredicate { + return when (val type = json["type"]?.asString?.lowercase()) { + null -> throw JsonSyntaxException("Missing feature predicate 'type'") + "has" -> HAS.factory(json) + "and" -> AND.factory(json) + "not" -> NOT.factory(json) + "or" -> OR.factory(json) + "always" -> ALWAYS.factory(json) + else -> throw JsonSyntaxException("Unknown feature predicate $type") + } + } + } + } + + abstract class FeaturePredicate : Predicate { + abstract val type: PredicateType + + open fun toJson(): JsonObject { + return JsonObject().also { + it["type"] = type.name.lowercase() + } + } + } + + object Always : FeaturePredicate() { + override val type: PredicateType + get() = PredicateType.ALWAYS + + override fun test(t: MatteryPlayerCapability): Boolean { + return true + } + } + + class Has : FeaturePredicate { + private val resolved by lazy { MRegistry.ANDROID_FEATURES.getValue(name) } + val name: ResourceLocation + + constructor(name: ResourceLocation) { + this.name = name + } + + constructor(value: JsonObject) { + this.name = ResourceLocation.tryParse(value["name"]?.asString ?: throw JsonSyntaxException("Invalid android feature name: ${value["name"]}")) ?: throw JsonSyntaxException("Invalid android feature name ${value["name"]}") + } + + override val type: PredicateType + get() = PredicateType.HAS + + override fun test(t: MatteryPlayerCapability): Boolean { + return t.hasFeature(resolved ?: return false) + } + + override fun toJson(): JsonObject { + return super.toJson().also { + it["name"] = name.toString() + } + } + } + + class Not(val parent: FeaturePredicate) : FeaturePredicate() { + constructor(input: JsonObject) : this(PredicateType.from(input["parent"] as? JsonObject ?: throw JsonSyntaxException("Invalid parent"))) + + override val type: PredicateType + get() = PredicateType.NOT + + override fun test(t: MatteryPlayerCapability): Boolean { + return !parent.test(t) + } + + override fun toJson(): JsonObject { + return super.toJson().also { + it["parent"] = parent.toJson() + } + } + } + + class And(children: Iterable) : FeaturePredicate() { + constructor(input: JsonObject) : this((input["children"] as? JsonArray)?.stream()?.map { PredicateType.from(it as? JsonObject ?: throw JsonSyntaxException("Invalid element in children list: $it")) }?.asIterable() ?: throw JsonSyntaxException("Invalid children list")) + + val children: ImmutableList = ImmutableList.copyOf(children) + + override val type: PredicateType + get() = PredicateType.AND + + override fun test(t: MatteryPlayerCapability): Boolean { + return children.all { it.test(t) } + } + + override fun toJson(): JsonObject { + return super.toJson().also { + it["children"] = JsonArray().also { + for (child in children) { + it.add(child.toJson()) + } + } + } + } + } + + class OrPredicate(children: Iterable) : FeaturePredicate() { + constructor(input: JsonObject) : this((input["children"] as? JsonArray)?.stream()?.map { PredicateType.from(it as? JsonObject ?: throw JsonSyntaxException("Invalid element in children list: $it")) }?.asIterable() ?: throw JsonSyntaxException("Invalid children list")) + + val children: ImmutableList = ImmutableList.copyOf(children) + + override val type: PredicateType + get() = PredicateType.OR + + override fun test(t: MatteryPlayerCapability): Boolean { + return children.any { it.test(t) } + } + + override fun toJson(): JsonObject { + return super.toJson().also { + it["children"] = JsonArray().also { + for (child in children) { + it.add(child.toJson()) + } + } + } + } + } + + class Instance( + val predicate: EntityPredicate.Composite = EntityPredicate.Composite.ANY, + val featurePredicate: FeaturePredicate = Always, + playerPredicate: EntityPredicate.Composite = EntityPredicate.Composite.ANY, + ) : AbstractCriterionTriggerInstance(ID, playerPredicate) { + override fun serializeToJson(pConditions: SerializationContext): JsonObject { + return super.serializeToJson(pConditions).also { + it["predicate"] = predicate.toJson(pConditions) + it["feature_predicate"] = featurePredicate.toJson() + } + } + } + + fun onKill(event: LivingDeathEvent) { + if (event.entity is ElderGuardian) { + val killer = event.entity.combatTracker.killer + + if (killer is ServerPlayer) { + val data = killer.matteryPlayer ?: return + + if (data.isAndroid) { + val context = EntityPredicate.createContext(killer, event.entity) + + trigger(killer) { + it.predicate.matches(context) && + it.featurePredicate.test(data) + } + } + } + } + } +} From f4db9b1e22f8ab53322d74e44c25780b607332b1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Feb 2023 18:24:53 +0700 Subject: [PATCH 0237/1199] Ignore creative players --- .../ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 506e347a9..10fb5fb41 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -809,7 +809,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial lastOutsideLiquid = ply.position } - if (ply.isUnderWater) { + if (ply.isUnderWater && !ply.isCreative) { if (!wasInLiquid) { wasInLiquid = true lastOutsideLiquid = ply.position From c8cdc2daf2a9962613071791bfe4d28eb90e190e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Feb 2023 18:28:19 +0700 Subject: [PATCH 0238/1199] Bump curios and cos --- build.gradle.kts | 8 ++++---- gradle.properties | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index fff609b59..18a4cca4a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -174,17 +174,17 @@ dependencies { if (handleDeps) { val jei_version: String by project val mekanism_version: String by project - val curios_version: String by project - val cosmetic_armor_reworked_version: String by project + val cosmetic_armor_reworked_id: String by project val jade_id: String by project val configured_id: String by project val worldedit_fileid: String by project val more_overlays_version: String by project val deps_mc_version: String by project val jei_mc_version: String by project + val curios_file_id: String by project - compileOnly(fg.deobf("top.theillusivec4.curios:curios-forge:${deps_mc_version}-${curios_version}")) - compileOnly(fg.deobf("lain.mods.cos:CosmeticArmorReworked:${deps_mc_version}-${cosmetic_armor_reworked_version}")) + implementation(fg.deobf("curse.maven:curios-309927:$curios_file_id")) + implementation(fg.deobf("curse.maven:cosmetic-armor-reworked-237307:$cosmetic_armor_reworked_id")) compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-common-api:${jei_version}")) compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge-api:${jei_version}")) diff --git a/gradle.properties b/gradle.properties index c42c45b38..955a80ded 100644 --- a/gradle.properties +++ b/gradle.properties @@ -26,8 +26,8 @@ mixin_version=0.8.5 jei_version=12.0.2.2 jupiter_version=5.8.2 mekanism_version=10.3.5.homebaked -curios_version=5.1.1.0 -cosmetic_armor_reworked_version=v1 +curios_file_id=4325469 +cosmetic_armor_reworked_id=4145717 jade_id=4330163 configured_id=4166861 worldedit_fileid=3922622 From eb39675b1522bfd5853d8cd7f8d3ae1ab43b3f7c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Feb 2023 18:29:55 +0700 Subject: [PATCH 0239/1199] Typo --- .../dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt index f47aeba45..dea99aca7 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt @@ -26,7 +26,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MItems.TRITANIUM_INGOT), title = translation.add("root", "Overdrive That Matters"), - description = translation.add("root.desc", "Its all about things that matter") { + description = translation.add("root.desc", "It's all about things that matter") { russian("Мод про все штуки которые материальны") }, showToast = false, From f5840c4ca1a73ce05864a221310fe49830aa3822 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Feb 2023 18:37:44 +0700 Subject: [PATCH 0240/1199] --- .../entity/tech/AndroidStationBlockEntity.kt | 16 +++------------- .../otm/capability/energy/AndroidPowerSource.kt | 12 +++--------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt index 378b917a9..96d029eac 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt @@ -14,6 +14,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.moveEnergy import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal @@ -86,19 +87,8 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : for (ent in level.getEntitiesOfClass(ServerPlayer::class.java, AABB(x, y, z, x + 1.0, y + 2.0, z + 1.0))) { ent.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresentK { - if (!it.isAndroid) - return@ifPresentK - - val missing = it.androidEnergy.missingPower - - if (missing > Decimal.ZERO) { - val extract = energy.extractEnergy(missing, true) - - if (extract > Decimal.ZERO) { - val received = it.androidEnergy.receiveEnergy(extract, false) - energy.extractEnergy(received, false) - } - } + if (it.isAndroid) + moveEnergy(energy, it.androidEnergy, amount = energy.batteryLevel, simulate = false) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt index 1559d828e..1f1bc6445 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt @@ -102,15 +102,9 @@ class AndroidPowerSource( if (!item.isEmpty) { item.getCapability(ForgeCapabilities.ENERGY).ifPresentK { - if (it is IMatteryEnergyStorage) { - val extracted = it.receiveEnergy(howMuch, simulate) - received += extracted - howMuch -= extracted - } else { - val extracted = it.receiveEnergy(howMuch, simulate) - received += extracted - howMuch -= extracted - } + val extracted = it.receiveEnergy(howMuch, simulate) + received += extracted + howMuch -= extracted } if (howMuch.isZero) { From 7c4ad1049ec2a867f6b11e18cc4b9596c4426437 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Feb 2023 20:05:31 +0700 Subject: [PATCH 0241/1199] sheeesh --- src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt index 49063638d..833203473 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt @@ -37,7 +37,7 @@ internal fun IEnergyStorage.receiveEnergy(amount: Decimal, simulate: Boolean): D if (this is IMatteryEnergyStorage) return receiveEnergyChecked(amount, simulate) - if (!amount.isPositive) + if (amount.isNegative) throw IllegalArgumentException("Negative energy: $amount") if (!canReceive()) @@ -56,7 +56,7 @@ internal fun IEnergyStorage.extractEnergy(amount: Decimal, simulate: Boolean): D if (this is IMatteryEnergyStorage) return extractEnergyChecked(amount, simulate) - if (!amount.isPositive) + if (amount.isNegative) throw IllegalArgumentException("Negative energy: $amount") if (!canExtract()) From 3f25afd9d9db1349e57a1f9a86e513331f250920 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Feb 2023 20:25:26 +0700 Subject: [PATCH 0242/1199] Tritanium anvil, bars, shears, shield, nuggets --- .../mc/otm/datagen/items/ItemModels.kt | 2 +- .../mc/otm/datagen/lang/English.kt | 8 ++ .../mc/otm/datagen/lang/Russian.kt | 8 ++ .../mc/otm/datagen/loot/LootTablesData.kt | 4 + .../mc/otm/datagen/recipes/BlastingRecipes.kt | 17 +++ .../datagen/recipes/CraftingTableRecipes.kt | 23 ++++ .../otm/datagen/recipes/DecorativesRecipes.kt | 11 ++ .../dbotthepony/mc/otm/datagen/tags/Tags.kt | 10 +- .../mc/otm/mixin/MixinAnvilBlock.java | 33 +++++ .../mc/otm/registry/CreativeTabs.kt | 7 +- .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 27 ++++ .../ru/dbotthepony/mc/otm/registry/MItems.kt | 122 +++++++++++------- .../ru/dbotthepony/mc/otm/registry/MNames.kt | 5 + .../ru/dbotthepony/mc/otm/registry/Tags.kt | 2 + .../overdrive_that_matters.mixins.json | 3 +- 15 files changed, 230 insertions(+), 52 deletions(-) create mode 100644 src/main/java/ru/dbotthepony/mc/otm/mixin/MixinAnvilBlock.java diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index 241e68d50..bf6cff3f1 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -78,7 +78,7 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.generated(MItems.EXOPACK_PROBE) - provider.handheld(MItems.TRITANIUM_TOOLS) + //provider.handheld(MItems.TRITANIUM_TOOLS) provider.generated(MItems.TRITANIUM_ARMOR) provider.generatedTiered(MItems.BATTERIES, "battery_tier") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 3aab1fb17..72e387605 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -434,6 +434,11 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.TRITANIUM_TRAPDOOR[null]!!, "Tritanium Trapdoor") add(MBlocks.TRITANIUM_TRAPDOOR[null]!!, "description0", "High blast resistance door with redstone latch...") add(MBlocks.TRITANIUM_TRAPDOOR[null]!!, "description1", "...feeling safe now?") + + add(MBlocks.TRITANIUM_BARS, "Tritanium Bars") + + for (block in MBlocks.TRITANIUM_ANVIL) + add(block, "Tritanium Anvil") } } @@ -478,6 +483,8 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.TRITANIUM_SHOVEL, "Tritanium Shovel") add(MItems.TRITANIUM_AXE, "Tritanium Axe") add(MItems.TRITANIUM_HOE, "Tritanium Hoe") + add(MItems.TRITANIUM_SHEARS, "Tritanium Shears") + add(MItems.TRITANIUM_SHIELD, "Tritanium Shield") add(MItems.TRITANIUM_HELMET, "Tritanium Helmet") add(MItems.TRITANIUM_CHESTPLATE, "Tritanium Chestplate") @@ -486,6 +493,7 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.TRITANIUM_DUST, "Tritanium Dust") add(MItems.TRITANIUM_INGOT, "Tritanium Ingot") + add(MItems.TRITANIUM_NUGGET, "Tritanium Nugget") add(MItems.MATTER_IO_PORT, "Matter IO Port") add(MItems.MATTER_TRANSFORM_MATRIX, "Matter Transformation Matrix") add(MItems.ENERGY_BUS, "Energy Bus") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index d8446ebce..710f310f9 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -439,6 +439,11 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.TRITANIUM_TRAPDOOR[null]!!, "Тритановый Люк") add(MBlocks.TRITANIUM_TRAPDOOR[null]!!, "description0", "Взрывоустойчивая дверь с засовом красного камня...") add(MBlocks.TRITANIUM_TRAPDOOR[null]!!, "description1", FEELING_SAFE_NOW) + + add(MBlocks.TRITANIUM_BARS, "Тритановая решётка") + + for (block in MBlocks.TRITANIUM_ANVIL) + add(block, "Тритановая Наковальня") } } @@ -483,6 +488,8 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.TRITANIUM_SHOVEL, "Тритановая Лопата") add(MItems.TRITANIUM_AXE, "Тритановый Топор") add(MItems.TRITANIUM_HOE, "Тритановая Мотыга") + add(MItems.TRITANIUM_SHEARS, "Тритановые ножницы") + add(MItems.TRITANIUM_SHIELD, "Тритановый щит") add(MItems.TRITANIUM_HELMET, "Тритановый Шлем") add(MItems.TRITANIUM_CHESTPLATE, "Тритановый Нагрудник") @@ -491,6 +498,7 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.TRITANIUM_DUST, "Тритановая Пыль") add(MItems.TRITANIUM_INGOT, "Тритановый Слиток") + add(MItems.TRITANIUM_NUGGET, "Тритановый самородок") add(MItems.MATTER_IO_PORT, "Порт Ввода/Вывода Материи") add(MItems.MATTER_TRANSFORM_MATRIX, "Матрица Преобразования Материи") add(MItems.ENERGY_BUS, "Шина Питания") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index 37790e3f2..e86310f86 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -57,9 +57,13 @@ fun addLootTables(lootTables: LootTables) { lootTables.dropsSelf(MBlocks.DANGER_STRIPE_BLOCK) { condition(ExplosionCondition.survivesExplosion()) } lootTables.dropsSelf(MBlocks.METAL_BEAM) { condition(ExplosionCondition.survivesExplosion()) } lootTables.dropsSelf(MBlocks.TRITANIUM_INGOT_BLOCK) { condition(ExplosionCondition.survivesExplosion()) } + lootTables.dropsSelf(MBlocks.TRITANIUM_BARS) { condition(ExplosionCondition.survivesExplosion()) } lootTables.dropsSelf(MBlocks.ENGINE) { condition(ExplosionCondition.survivesExplosion()) } + for (block in MBlocks.TRITANIUM_ANVIL) + lootTables.dropsSelf(block) { condition(ExplosionCondition.survivesExplosion()) } + for (door in MBlocks.TRITANIUM_TRAPDOOR.values) lootTables.dropsSelf(door) { condition(ExplosionCondition.survivesExplosion()) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt index 971a5c3d7..1ffe1f3d2 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt @@ -4,6 +4,7 @@ import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.data.recipes.RecipeCategory import net.minecraft.data.recipes.SimpleCookingRecipeBuilder import net.minecraft.world.item.crafting.Ingredient +import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.datagen.modLocation import ru.dbotthepony.mc.otm.registry.MItemTags import ru.dbotthepony.mc.otm.registry.MItems @@ -14,4 +15,20 @@ fun addBlastingRecipes(consumer: Consumer) { SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_PLATES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 100).unlockedBy(MItemTags.TRITANIUM_PLATES).save(consumer, modLocation("tritanium_ingot_from_plates")) SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_PLATES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 50).unlockedBy(MItemTags.TRITANIUM_PLATES).save(consumer, modLocation("tritanium_ingot_from_plates_blasting")) + + for (tool in MItems.TRITANIUM_TOOLS) { + SimpleCookingRecipeBuilder.smelting( + Ingredient.of(tool), + RecipeCategory.MISC, + MItems.TRITANIUM_NUGGET, + 0f, 200 + ).unlockedBy(MItems.TRITANIUM_NUGGET).save(consumer, modLocation("cooking/nugget_from_${tool.registryName!!.path}")) + + SimpleCookingRecipeBuilder.blasting( + Ingredient.of(tool), + RecipeCategory.MISC, + MItems.TRITANIUM_NUGGET, + 0f, 100 + ).unlockedBy(MItems.TRITANIUM_NUGGET).save(consumer, modLocation("blasting/nugget_from_${tool.registryName!!.path}")) + } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index 19d69f99a..477a9faeb 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -260,4 +260,27 @@ fun addCraftingTableRecipes(consumer: Consumer) { .row(Items.LAVA_BUCKET, Items.HOPPER, Items.WATER_BUCKET) .rowB(Tags.Items.CHESTS) .build(consumer) + + MatteryRecipe(MItems.TRITANIUM_SHEARS, category = RecipeCategory.TOOLS) + .rowB(MItemTags.TRITANIUM_INGOTS) + .rowA(MItemTags.TRITANIUM_INGOTS) + .build(consumer) + + MatteryRecipe(MItems.TRITANIUM_SHIELD, category = RecipeCategory.COMBAT) + .row(MItemTags.TRITANIUM_INGOTS, Items.SHIELD, MItemTags.TRITANIUM_INGOTS) + .row(MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS) + .rowB(MItemTags.TRITANIUM_INGOTS) + .build(consumer) + + ShapelessRecipeBuilder(RecipeCategory.MISC, MItems.TRITANIUM_NUGGET, 9) + .requires(MItemTags.TRITANIUM_INGOTS) + .unlockedBy(MItemTags.TRITANIUM_INGOTS) + .unlockedBy(MItemTags.TRITANIUM_NUGGETS) + .save(consumer) + + ShapelessRecipeBuilder(RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 9) + .requires(Ingredient.of(MItemTags.TRITANIUM_NUGGETS), 9) + .unlockedBy(MItemTags.TRITANIUM_INGOTS) + .unlockedBy(MItemTags.TRITANIUM_NUGGETS) + .save(consumer, modLocation("ingot_from_nuggets")) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt index 8f69951c6..555385af4 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt @@ -337,4 +337,15 @@ fun addDecorativesRecipes(provider: MatteryRecipeProvider, consumer: Consumer info) { + var list = MBlocks.INSTANCE.getTRITANIUM_ANVIL(); + + for (int i = 0; i < list.size(); i++) { + if (pState.is(list.get(i))) { + if (i == list.size()) { + info.setReturnValue(null); + } else { + info.setReturnValue(list.get(i + 1).defaultBlockState().setValue(AnvilBlock.FACING, pState.getValue(AnvilBlock.FACING))); + } + + return; + } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt index bedd47f92..07546d9c5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt @@ -107,8 +107,9 @@ internal fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { base(MItems.TRITANIUM_DOOR) base(MItems.TRITANIUM_TRAPDOOR) accept(MRegistry.TRITANIUM_PRESSURE_PLATE.item) + accept(MItems.TRITANIUM_ANVIL[0]) - accept(MItems.MATTER_DUST) + // accept(MItems.MATTER_DUST) accept(MItems.TRITANIUM_ORE_CLUMP) accept(MItems.TRITANIUM_DUST) @@ -170,11 +171,15 @@ internal fun addDecorativeTabItems(consumer: CreativeModeTab.Output) { accept(MItems.TRITANIUM_STRIPED_SLAB) accept(MItems.TRITANIUM_STRIPED_WALL) accept(MItems.CARBON_FIBRE_BLOCK) + accept(MItems.TRITANIUM_BARS) colored(MItems.TRITANIUM_DOOR) colored(MItems.TRITANIUM_TRAPDOOR) accept(MRegistry.TRITANIUM_PRESSURE_PLATE.items.values) + for (i in 0 until MItems.TRITANIUM_ANVIL.size) + accept(MItems.TRITANIUM_ANVIL[i]) + colored(MRegistry.CARGO_CRATES.items) colored(MItems.CARGO_CRATE_MINECARTS) 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 fb2eb2935..6aeae5d1a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -11,9 +11,11 @@ import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.BlockGetter +import net.minecraft.world.level.block.AnvilBlock import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.DoorBlock import net.minecraft.world.level.block.DropExperienceBlock +import net.minecraft.world.level.block.IronBarsBlock import net.minecraft.world.level.block.SlabBlock import net.minecraft.world.level.block.SoundType import net.minecraft.world.level.block.StairBlock @@ -62,6 +64,8 @@ import ru.dbotthepony.mc.otm.block.storage.StorageImporterBlock import ru.dbotthepony.mc.otm.block.storage.StoragePowerSupplierBlock import ru.dbotthepony.mc.otm.block.tech.CobblerBlock import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.collect.SupplierList +import java.util.function.Supplier object MBlocks { private val registry = DeferredRegister.create(ForgeRegistries.BLOCKS, OverdriveThatMatters.MOD_ID) @@ -117,6 +121,10 @@ object MBlocks { Block(BlockBehaviour.Properties.of(Material.METAL, MaterialColor.COLOR_BLUE).explosionResistance(400f).destroyTime(3f).requiresCorrectToolForDrops()) } + val TRITANIUM_BARS: IronBarsBlock by registry.register(MNames.TRITANIUM_BARS) { + IronBarsBlock(BlockBehaviour.Properties.of(Material.METAL, MaterialColor.COLOR_BLUE).explosionResistance(45f).destroyTime(2.5f).requiresCorrectToolForDrops()) + } + val DEEPSLATE_TRITANIUM_ORE: Block by registry.register(MNames.DEEPSLATE_TRITANIUM_ORE) { DropExperienceBlock( BlockBehaviour.Properties.of(Material.STONE) .strength(4.75f, 6.5f) @@ -138,6 +146,25 @@ object MBlocks { val ENGINE: Block by registry.register(MNames.ENGINE) { EngineBlock() } val HOLO_SIGN: Block by registry.register(MNames.HOLO_SIGN) { HoloSignBlock() } + const val TRITANIUM_ANVIL_VARIANTS = 7 + + val TRITANIUM_ANVIL: List + + init { + val anvils = ArrayList<() -> Block>() + + for (i in 0 until TRITANIUM_ANVIL_VARIANTS) { + val props = BlockBehaviour.Properties.of(Material.METAL, DyeColor.LIGHT_BLUE) + .destroyTime(2.5f - i * 0.15f) + .explosionResistance(1200f - i * 80f) + .requiresCorrectToolForDrops() + + anvils.add(registry.register(MNames.TRITANIUM_ANVIL + i) { AnvilBlock(props) }::get) + } + + TRITANIUM_ANVIL = SupplierList(anvils) + } + val TRITANIUM_DOOR = registry.allColored(MNames.TRITANIUM_DOOR) { color, _ -> object : DoorBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), SoundEvents.IRON_DOOR_CLOSE, SoundEvents.IRON_DOOR_OPEN) { override fun appendHoverText( 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 a4f1959a3..f566f338b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.registry import net.minecraft.ChatFormatting import net.minecraft.network.chat.Component +import net.minecraft.resources.ResourceLocation import net.minecraft.tags.BlockTags import net.minecraft.world.entity.EquipmentSlot import net.minecraft.world.food.FoodProperties @@ -10,6 +11,7 @@ import net.minecraft.world.item.* import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.level.Level import net.minecraftforge.common.ForgeTier +import net.minecraftforge.common.TierSortingRegistry import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.ForgeRegistries @@ -28,35 +30,35 @@ object MItems { registry.register(bus) } - val ANDROID_STATION: Item by registry.register(MNames.ANDROID_STATION) { BlockItem(MBlocks.ANDROID_STATION, DEFAULT_PROPERTIES) } - val BATTERY_BANK: Item by registry.register(MNames.BATTERY_BANK) { BlockItem(MBlocks.BATTERY_BANK, DEFAULT_PROPERTIES) } - val MATTER_DECOMPOSER: Item by registry.register(MNames.MATTER_DECOMPOSER) { BlockItem(MBlocks.MATTER_DECOMPOSER, DEFAULT_PROPERTIES) } - val MATTER_CAPACITOR_BANK: Item by registry.register(MNames.MATTER_CAPACITOR_BANK) { BlockItem(MBlocks.MATTER_CAPACITOR_BANK, DEFAULT_PROPERTIES) } - val MATTER_CABLE: Item by registry.register(MNames.MATTER_CABLE) { BlockItem(MBlocks.MATTER_CABLE, DEFAULT_PROPERTIES) } - val PATTERN_STORAGE: Item by registry.register(MNames.PATTERN_STORAGE) { BlockItem(MBlocks.PATTERN_STORAGE, DEFAULT_PROPERTIES) } - val MATTER_SCANNER: Item by registry.register(MNames.MATTER_SCANNER) { BlockItem(MBlocks.MATTER_SCANNER, DEFAULT_PROPERTIES) } - val MATTER_PANEL: Item by registry.register(MNames.MATTER_PANEL) { BlockItem(MBlocks.MATTER_PANEL, DEFAULT_PROPERTIES) } - val MATTER_REPLICATOR: Item by registry.register(MNames.MATTER_REPLICATOR) { BlockItem(MBlocks.MATTER_REPLICATOR, DEFAULT_PROPERTIES) } - val MATTER_BOTTLER: Item by registry.register(MNames.MATTER_BOTTLER) { BlockItem(MBlocks.MATTER_BOTTLER, DEFAULT_PROPERTIES) } + val ANDROID_STATION: BlockItem by registry.register(MNames.ANDROID_STATION) { BlockItem(MBlocks.ANDROID_STATION, DEFAULT_PROPERTIES) } + val BATTERY_BANK: BlockItem by registry.register(MNames.BATTERY_BANK) { BlockItem(MBlocks.BATTERY_BANK, DEFAULT_PROPERTIES) } + val MATTER_DECOMPOSER: BlockItem by registry.register(MNames.MATTER_DECOMPOSER) { BlockItem(MBlocks.MATTER_DECOMPOSER, DEFAULT_PROPERTIES) } + val MATTER_CAPACITOR_BANK: BlockItem by registry.register(MNames.MATTER_CAPACITOR_BANK) { BlockItem(MBlocks.MATTER_CAPACITOR_BANK, DEFAULT_PROPERTIES) } + val MATTER_CABLE: BlockItem by registry.register(MNames.MATTER_CABLE) { BlockItem(MBlocks.MATTER_CABLE, DEFAULT_PROPERTIES) } + val PATTERN_STORAGE: BlockItem by registry.register(MNames.PATTERN_STORAGE) { BlockItem(MBlocks.PATTERN_STORAGE, DEFAULT_PROPERTIES) } + val MATTER_SCANNER: BlockItem by registry.register(MNames.MATTER_SCANNER) { BlockItem(MBlocks.MATTER_SCANNER, DEFAULT_PROPERTIES) } + val MATTER_PANEL: BlockItem by registry.register(MNames.MATTER_PANEL) { BlockItem(MBlocks.MATTER_PANEL, DEFAULT_PROPERTIES) } + val MATTER_REPLICATOR: BlockItem by registry.register(MNames.MATTER_REPLICATOR) { BlockItem(MBlocks.MATTER_REPLICATOR, DEFAULT_PROPERTIES) } + val MATTER_BOTTLER: BlockItem by registry.register(MNames.MATTER_BOTTLER) { BlockItem(MBlocks.MATTER_BOTTLER, DEFAULT_PROPERTIES) } - val TRITANIUM_ORE: Item by registry.register(MNames.TRITANIUM_ORE) { BlockItem(MBlocks.TRITANIUM_ORE, DEFAULT_PROPERTIES) } - val DEEPSLATE_TRITANIUM_ORE: Item by registry.register(MNames.DEEPSLATE_TRITANIUM_ORE) { BlockItem(MBlocks.DEEPSLATE_TRITANIUM_ORE, DEFAULT_PROPERTIES) } - val TRITANIUM_RAW_BLOCK: Item by registry.register(MNames.TRITANIUM_RAW_BLOCK) { BlockItem(MBlocks.TRITANIUM_RAW_BLOCK, DEFAULT_PROPERTIES) } - val ENERGY_COUNTER: Item by registry.register(MNames.ENERGY_COUNTER) { BlockItem(MBlocks.ENERGY_COUNTER, DEFAULT_PROPERTIES) } - val CHEMICAL_GENERATOR: Item by registry.register(MNames.CHEMICAL_GENERATOR) { BlockItem(MBlocks.CHEMICAL_GENERATOR, DEFAULT_PROPERTIES) } - val PLATE_PRESS: Item by registry.register(MNames.PLATE_PRESS) { BlockItem(MBlocks.PLATE_PRESS, DEFAULT_PROPERTIES) } - val MATTER_RECYCLER: Item by registry.register(MNames.MATTER_RECYCLER) { BlockItem(MBlocks.MATTER_RECYCLER, DEFAULT_PROPERTIES) } + val TRITANIUM_ORE: BlockItem by registry.register(MNames.TRITANIUM_ORE) { BlockItem(MBlocks.TRITANIUM_ORE, DEFAULT_PROPERTIES) } + val DEEPSLATE_TRITANIUM_ORE: BlockItem by registry.register(MNames.DEEPSLATE_TRITANIUM_ORE) { BlockItem(MBlocks.DEEPSLATE_TRITANIUM_ORE, DEFAULT_PROPERTIES) } + val TRITANIUM_RAW_BLOCK: BlockItem by registry.register(MNames.TRITANIUM_RAW_BLOCK) { BlockItem(MBlocks.TRITANIUM_RAW_BLOCK, DEFAULT_PROPERTIES) } + val ENERGY_COUNTER: BlockItem by registry.register(MNames.ENERGY_COUNTER) { BlockItem(MBlocks.ENERGY_COUNTER, DEFAULT_PROPERTIES) } + val CHEMICAL_GENERATOR: BlockItem by registry.register(MNames.CHEMICAL_GENERATOR) { BlockItem(MBlocks.CHEMICAL_GENERATOR, DEFAULT_PROPERTIES) } + val PLATE_PRESS: BlockItem by registry.register(MNames.PLATE_PRESS) { BlockItem(MBlocks.PLATE_PRESS, DEFAULT_PROPERTIES) } + val MATTER_RECYCLER: BlockItem by registry.register(MNames.MATTER_RECYCLER) { BlockItem(MBlocks.MATTER_RECYCLER, DEFAULT_PROPERTIES) } - val STORAGE_BUS: Item by registry.register(MNames.STORAGE_BUS) { BlockItem(MBlocks.STORAGE_BUS, DEFAULT_PROPERTIES) } - val STORAGE_IMPORTER: Item by registry.register(MNames.STORAGE_IMPORTER) { BlockItem(MBlocks.STORAGE_IMPORTER, DEFAULT_PROPERTIES) } - val STORAGE_EXPORTER: Item by registry.register(MNames.STORAGE_EXPORTER) { BlockItem(MBlocks.STORAGE_EXPORTER, DEFAULT_PROPERTIES) } - val DRIVE_VIEWER: Item by registry.register(MNames.DRIVE_VIEWER) { BlockItem(MBlocks.DRIVE_VIEWER, DEFAULT_PROPERTIES) } - val DRIVE_RACK: Item by registry.register(MNames.DRIVE_RACK) { BlockItem(MBlocks.DRIVE_RACK, DEFAULT_PROPERTIES) } - val ITEM_MONITOR: Item by registry.register(MNames.ITEM_MONITOR) { BlockItem(MBlocks.ITEM_MONITOR, DEFAULT_PROPERTIES) } - val STORAGE_CABLE: Item by registry.register(MNames.STORAGE_CABLE) { BlockItem(MBlocks.STORAGE_CABLE, DEFAULT_PROPERTIES) } - val STORAGE_POWER_SUPPLIER: Item by registry.register(MNames.STORAGE_POWER_SUPPLIER) { BlockItem(MBlocks.STORAGE_POWER_SUPPLIER, DEFAULT_PROPERTIES) } + val STORAGE_BUS: BlockItem by registry.register(MNames.STORAGE_BUS) { BlockItem(MBlocks.STORAGE_BUS, DEFAULT_PROPERTIES) } + val STORAGE_IMPORTER: BlockItem by registry.register(MNames.STORAGE_IMPORTER) { BlockItem(MBlocks.STORAGE_IMPORTER, DEFAULT_PROPERTIES) } + val STORAGE_EXPORTER: BlockItem by registry.register(MNames.STORAGE_EXPORTER) { BlockItem(MBlocks.STORAGE_EXPORTER, DEFAULT_PROPERTIES) } + val DRIVE_VIEWER: BlockItem by registry.register(MNames.DRIVE_VIEWER) { BlockItem(MBlocks.DRIVE_VIEWER, DEFAULT_PROPERTIES) } + val DRIVE_RACK: BlockItem by registry.register(MNames.DRIVE_RACK) { BlockItem(MBlocks.DRIVE_RACK, DEFAULT_PROPERTIES) } + val ITEM_MONITOR: BlockItem by registry.register(MNames.ITEM_MONITOR) { BlockItem(MBlocks.ITEM_MONITOR, DEFAULT_PROPERTIES) } + val STORAGE_CABLE: BlockItem by registry.register(MNames.STORAGE_CABLE) { BlockItem(MBlocks.STORAGE_CABLE, DEFAULT_PROPERTIES) } + val STORAGE_POWER_SUPPLIER: BlockItem by registry.register(MNames.STORAGE_POWER_SUPPLIER) { BlockItem(MBlocks.STORAGE_POWER_SUPPLIER, DEFAULT_PROPERTIES) } - val GRAVITATION_STABILIZER: Item by registry.register(MNames.GRAVITATION_STABILIZER) { + val GRAVITATION_STABILIZER: BlockItem by registry.register(MNames.GRAVITATION_STABILIZER) { object : BlockItem(MBlocks.GRAVITATION_STABILIZER, DEFAULT_PROPERTIES) { override fun appendHoverText(p_40572_: ItemStack, p_40573_: Level?, p_40574_: MutableList, p_40575_: TooltipFlag) { super.appendHoverText(p_40572_, p_40573_, p_40574_, p_40575_) @@ -69,7 +71,7 @@ object MItems { } } - val PHANTOM_ATTRACTOR: Item by registry.register(MNames.PHANTOM_ATTRACTOR) { + val PHANTOM_ATTRACTOR: DoubleHighBlockItem by registry.register(MNames.PHANTOM_ATTRACTOR) { object : DoubleHighBlockItem(MBlocks.PHANTOM_ATTRACTOR, DEFAULT_PROPERTIES) { override fun appendHoverText(p_40572_: ItemStack, p_40573_: Level?, p_40574_: MutableList, p_40575_: TooltipFlag) { super.appendHoverText(p_40572_, p_40573_, p_40574_, p_40575_) @@ -80,7 +82,7 @@ object MItems { } } - val ENERGY_SERVO: Item by registry.register(MNames.ENERGY_SERVO) { + val ENERGY_SERVO: BlockItem by registry.register(MNames.ENERGY_SERVO) { object : BlockItem(MBlocks.ENERGY_SERVO, DEFAULT_PROPERTIES) { override fun appendHoverText(p_40572_: ItemStack, p_40573_: Level?, p_40574_: MutableList, p_40575_: TooltipFlag) { super.appendHoverText(p_40572_, p_40573_, p_40574_, p_40575_) @@ -90,7 +92,7 @@ object MItems { } } - val COBBLESTONE_GENERATOR: Item by registry.register(MNames.COBBLESTONE_GENERATOR) { + val COBBLESTONE_GENERATOR: BlockItem by registry.register(MNames.COBBLESTONE_GENERATOR) { object : BlockItem(MBlocks.COBBLESTONE_GENERATOR, DEFAULT_PROPERTIES) { override fun appendHoverText(p_40572_: ItemStack, p_40573_: Level?, p_40574_: MutableList, p_40575_: TooltipFlag) { super.appendHoverText(p_40572_, p_40573_, p_40574_, p_40575_) @@ -111,12 +113,26 @@ object MItems { val DEBUG_EXPLOSION_SMALL: Item by registry.register(MNames.DEBUG_EXPLOSION_SMALL) { BlockItem(MBlocks.DEBUG_EXPLOSION_SMALL, Item.Properties().stacksTo(64)) } val DEBUG_SPHERE_POINTS: Item by registry.register(MNames.DEBUG_SPHERE_POINTS) { BlockItem(MBlocks.DEBUG_SPHERE_POINTS, Item.Properties().stacksTo(64)) } + val TRITANIUM_ANVIL: List + + init { + val props = ArrayList<() -> BlockItem>() + + for (i in MBlocks.TRITANIUM_ANVIL.indices) { + props.add(registry.register(MNames.TRITANIUM_ANVIL + i) { BlockItem(MBlocks.TRITANIUM_ANVIL[i], DEFAULT_PROPERTIES) }::get) + } + + TRITANIUM_ANVIL = SupplierList(props) + } + val MATTER_DUST: Item by registry.register(MNames.MATTER_DUST) { MatterDustItem() } val TRITANIUM_ORE_CLUMP: Item by registry.register(MNames.TRITANIUM_ORE_CLUMP) { Item(DEFAULT_PROPERTIES) } val TRITANIUM_DUST: Item by registry.register(MNames.TRITANIUM_DUST) { Item(DEFAULT_PROPERTIES) } + val TRITANIUM_NUGGET: Item by registry.register(MNames.TRITANIUM_NUGGET) { Item(DEFAULT_PROPERTIES) } val TRITANIUM_INGOT: Item by registry.register(MNames.TRITANIUM_INGOT) { Item(DEFAULT_PROPERTIES) } - val TRITANIUM_INGOT_BLOCK: Item by registry.register(MNames.TRITANIUM_INGOT_BLOCK) { BlockItem(MBlocks.TRITANIUM_INGOT_BLOCK, DEFAULT_PROPERTIES) } + val TRITANIUM_INGOT_BLOCK: BlockItem by registry.register(MNames.TRITANIUM_INGOT_BLOCK) { BlockItem(MBlocks.TRITANIUM_INGOT_BLOCK, DEFAULT_PROPERTIES) } + val TRITANIUM_BARS: BlockItem by registry.register(MNames.TRITANIUM_BARS) { BlockItem(MBlocks.TRITANIUM_BARS, DEFAULT_PROPERTIES) } val TRITANIUM_COMPONENT: ForgeTier = ForgeTier( Tiers.IRON.level, @@ -127,32 +143,42 @@ object MItems { BlockTags.NEEDS_IRON_TOOL ) { Ingredient.of(TRITANIUM_INGOT) } + val TRITANIUM_COMPONENT_NAME = ResourceLocation(OverdriveThatMatters.MOD_ID, "tritanium") + + init { + TierSortingRegistry.registerTier(TRITANIUM_COMPONENT, TRITANIUM_COMPONENT_NAME, listOf(Tiers.IRON), listOf(Tiers.DIAMOND)) + } + private val TOOLS_PROPRTIES = Item.Properties() - val TRITANIUM_SWORD: Item by registry.register(MNames.TRITANIUM_SWORD) { SwordItem(TRITANIUM_COMPONENT, 4, -2.7f, TOOLS_PROPRTIES) } - val TRITANIUM_SHOVEL: Item by registry.register(MNames.TRITANIUM_SHOVEL) { ShovelItem(TRITANIUM_COMPONENT, 1.5f, -2.4f, TOOLS_PROPRTIES) } - val TRITANIUM_AXE: Item by registry.register(MNames.TRITANIUM_AXE) { MatteryAxeItem(TRITANIUM_COMPONENT, 8.5f, -3.4f, TOOLS_PROPRTIES) } - val TRITANIUM_PICKAXE: Item by registry.register(MNames.TRITANIUM_PICKAXE) { PickaxeItem(TRITANIUM_COMPONENT, 2, -2.8f, TOOLS_PROPRTIES) } - val TRITANIUM_HOE: Item by registry.register(MNames.TRITANIUM_HOE) { HoeItem(TRITANIUM_COMPONENT, 0, -3.4f, TOOLS_PROPRTIES) } + val TRITANIUM_SWORD: SwordItem by registry.register(MNames.TRITANIUM_SWORD) { SwordItem(TRITANIUM_COMPONENT, 4, -2.7f, TOOLS_PROPRTIES) } + val TRITANIUM_SHOVEL: ShovelItem by registry.register(MNames.TRITANIUM_SHOVEL) { ShovelItem(TRITANIUM_COMPONENT, 1.5f, -2.4f, TOOLS_PROPRTIES) } + val TRITANIUM_AXE: MatteryAxeItem by registry.register(MNames.TRITANIUM_AXE) { MatteryAxeItem(TRITANIUM_COMPONENT, 8.5f, -3.4f, TOOLS_PROPRTIES) } + val TRITANIUM_PICKAXE: PickaxeItem by registry.register(MNames.TRITANIUM_PICKAXE) { PickaxeItem(TRITANIUM_COMPONENT, 2, -2.8f, TOOLS_PROPRTIES) } + val TRITANIUM_HOE: HoeItem by registry.register(MNames.TRITANIUM_HOE) { HoeItem(TRITANIUM_COMPONENT, 0, -3.4f, TOOLS_PROPRTIES) } + val TRITANIUM_SHEARS: ShearsItem by registry.register(MNames.TRITANIUM_SHEARS) { ShearsItem(Item.Properties().durability(3072)) } + val TRITANIUM_SHIELD: ShieldItem by registry.register(MNames.TRITANIUM_SHIELD) { ShieldItem(Item.Properties().durability(2048)) } val TRITANIUM_TOOLS = SupplierList( - { TRITANIUM_SWORD }, - { TRITANIUM_SHOVEL }, - { TRITANIUM_AXE }, - { TRITANIUM_PICKAXE }, - { TRITANIUM_HOE } + ::TRITANIUM_SWORD, + ::TRITANIUM_SHOVEL, + ::TRITANIUM_AXE, + ::TRITANIUM_PICKAXE, + ::TRITANIUM_HOE, + ::TRITANIUM_SHEARS, + ::TRITANIUM_SHIELD, ) - val TRITANIUM_HELMET: Item by registry.register(MNames.TRITANIUM_HELMET) { ItemTritaniumArmor(EquipmentSlot.HEAD) } - val TRITANIUM_CHESTPLATE: Item by registry.register(MNames.TRITANIUM_CHESTPLATE) { ItemTritaniumArmor(EquipmentSlot.CHEST) } - val TRITANIUM_PANTS: Item by registry.register(MNames.TRITANIUM_PANTS) { ItemTritaniumArmor(EquipmentSlot.LEGS) } - val TRITANIUM_BOOTS: Item by registry.register(MNames.TRITANIUM_BOOTS) { ItemTritaniumArmor(EquipmentSlot.FEET) } + val TRITANIUM_HELMET: ItemTritaniumArmor by registry.register(MNames.TRITANIUM_HELMET) { ItemTritaniumArmor(EquipmentSlot.HEAD) } + val TRITANIUM_CHESTPLATE: ItemTritaniumArmor by registry.register(MNames.TRITANIUM_CHESTPLATE) { ItemTritaniumArmor(EquipmentSlot.CHEST) } + val TRITANIUM_PANTS: ItemTritaniumArmor by registry.register(MNames.TRITANIUM_PANTS) { ItemTritaniumArmor(EquipmentSlot.LEGS) } + val TRITANIUM_BOOTS: ItemTritaniumArmor by registry.register(MNames.TRITANIUM_BOOTS) { ItemTritaniumArmor(EquipmentSlot.FEET) } val TRITANIUM_ARMOR = SupplierList( - { TRITANIUM_HELMET }, - { TRITANIUM_CHESTPLATE }, - { TRITANIUM_PANTS }, - { TRITANIUM_BOOTS } + ::TRITANIUM_HELMET, + ::TRITANIUM_CHESTPLATE, + ::TRITANIUM_PANTS, + ::TRITANIUM_BOOTS ) val ENERGY_SWORD: Item by registry.register(MNames.ENERGY_SWORD) { EnergySwordItem() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index 79b463c2a..e5becbf8b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -32,6 +32,7 @@ object MNames { const val MATTER_RECYCLER = "matter_recycler" const val ENERGY_SERVO = "energy_servo" const val COBBLESTONE_GENERATOR = "cobblestone_generator" + const val TRITANIUM_ANVIL = "tritanium_anvil" const val STORAGE_CABLE = "storage_cable" // нужен рецепт const val STORAGE_POWER_SUPPLIER = "storage_power_supplier" // нужен рецепт @@ -130,6 +131,8 @@ object MNames { const val TRITANIUM_PICKAXE = "tritanium_pickaxe" const val TRITANIUM_SHOVEL = "tritanium_shovel" const val TRITANIUM_HOE = "tritanium_hoe" + const val TRITANIUM_SHEARS = "tritanium_shears" + const val TRITANIUM_SHIELD = "tritanium_shield" const val ENERGY_SWORD = "energy_sword" @@ -137,8 +140,10 @@ object MNames { // items: crafting components const val TRITANIUM_DUST = "tritanium_dust" + const val TRITANIUM_NUGGET = "tritanium_nugget" const val TRITANIUM_INGOT = "tritanium_ingot" const val TRITANIUM_INGOT_BLOCK = "tritanium_ingot_block" + const val TRITANIUM_BARS = "tritanium_bars" const val MATTER_IO_PORT = "matter_io_port" const val MATTER_TRANSFORM_MATRIX = "matter_transform_matrix" diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt index 9bb794004..42fc27a72 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt @@ -13,6 +13,8 @@ object MItemTags { val TRITANIUM_ORES: TagKey = ItemTags.create(ResourceLocation("forge", "ores/tritanium")) val TRITANIUM_ORE_CLUMPS: TagKey = ItemTags.create(ResourceLocation("forge", "raw_materials/tritanium")) val TRITANIUM_INGOTS: TagKey = ItemTags.create(ResourceLocation("forge", "ingots/tritanium")) + val TRITANIUM_NUGGETS: TagKey = ItemTags.create(ResourceLocation("forge", "nuggets/tritanium")) + val NUGGETS: TagKey = ItemTags.create(ResourceLocation("forge", "nuggets")) val TRITANIUM_INGOTS_STORAGE: TagKey = ItemTags.create(ResourceLocation("forge", "storage_blocks/tritanium")) val TRITANIUM_PLATES: TagKey = ItemTags.create(ResourceLocation("forge", "plates/tritanium")) val TRITANIUM_DUSTS: TagKey = ItemTags.create(ResourceLocation("forge", "dusts/tritanium")) diff --git a/src/main/resources/overdrive_that_matters.mixins.json b/src/main/resources/overdrive_that_matters.mixins.json index 7559f932a..1ff29e66e 100644 --- a/src/main/resources/overdrive_that_matters.mixins.json +++ b/src/main/resources/overdrive_that_matters.mixins.json @@ -7,6 +7,7 @@ "refmap": "overdrive_that_matters.refmap.json", "mixins": [ "MixinPatchProjectileFinder", - "MixinLivingEntity" + "MixinLivingEntity", + "MixinAnvilBlock" ] } From 11fd2cb7bb52c55bce2a45fc1989664123804b80 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Feb 2023 20:33:59 +0700 Subject: [PATCH 0243/1199] =?UTF-8?q?YuRaNnNzZZ=20=E2=80=94=20=D0=A1=D0=B5?= =?UTF-8?q?=D0=B3=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=2020:25=20=D0=A2=D1=80?= =?UTF-8?q?=D0=B8=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D1=8B=D0=B5=20=D0=9F=D1=80?= =?UTF-8?q?=D1=83=D1=82=D1=8C=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/datagen/lang/Russian.kt | 346 +++++++++--------- 1 file changed, 173 insertions(+), 173 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 710f310f9..27778a6d3 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -16,64 +16,64 @@ private fun decoratives(provider: MatteryLanguageProvider) { add(MRegistry.VENT, "%s Вентиляция") add(MRegistry.VENT_ALTERNATIVE, "%s Альтернативная Вентиляция") - add(MRegistry.TRITANIUM_BLOCK, "%s Тритановый Блок") - add(MRegistry.TRITANIUM_STAIRS, "%s Тритановые Ступеньки") - add(MRegistry.TRITANIUM_SLAB, "%s Тритановая Плита") - add(MRegistry.TRITANIUM_WALL, "%s Тритановая Ограда") - add(MRegistry.FLOOR_TILES, "%s Керамическая Плитка") - add(MRegistry.FLOOR_TILES_STAIRS, "%s Ступеньки из Керамической Плитки") - add(MRegistry.FLOOR_TILES_SLAB, "%s Плита из Керамической Плитки") - add(MRegistry.UNREFINED_FLOOR_TILES, "Необработанная %s Кирамическая Плитка") + add(MRegistry.TRITANIUM_BLOCK, "%s тритановый блок") + add(MRegistry.TRITANIUM_STAIRS, "%s Тритановые ступеньки") + add(MRegistry.TRITANIUM_SLAB, "%s Тритановая плита") + add(MRegistry.TRITANIUM_WALL, "%s тритановая ограда") + add(MRegistry.FLOOR_TILES, "%s керамическая плитка") + add(MRegistry.FLOOR_TILES_STAIRS, "%s ступеньки из керамической плитки") + add(MRegistry.FLOOR_TILES_SLAB, "%s плита из керамической плитки") + add(MRegistry.UNREFINED_FLOOR_TILES, "Необработанная %s кирамическая Плитка") - add(MRegistry.INDUSTRIAL_GLASS, "%s Окрашенное Промышленное Стекло") - add(MRegistry.INDUSTRIAL_GLASS_PANE, "%s Окрашенная Промышленная Стеклянная Панель") + add(MRegistry.INDUSTRIAL_GLASS, "%s окрашенное промышленное стекло") + add(MRegistry.INDUSTRIAL_GLASS_PANE, "%s окрашенная промышленная стеклянная панель") - add(MRegistry.CARGO_CRATES, "%s Грузовой Ящик") - add(MRegistry.DECORATIVE_CRATE, "%s Блок Контейнера") + add(MRegistry.CARGO_CRATES, "%s грузовой ящик") + add(MRegistry.DECORATIVE_CRATE, "%s блок контейнера") } with (provider.russian) { for ((color, name) in provider.russianColors.dyeClassMapped) { - add(MItems.CARGO_CRATE_MINECARTS[color]!!, "Вагонетка с $name Грузовым Ящиком") - add(MEntityTypes.CARGO_CRATE_MINECARTS[color]!!, "Вагонетка с $name Грузовым Ящиком") + add(MItems.CARGO_CRATE_MINECARTS[color]!!, "Вагонетка с $name грузовым ящиком") + add(MEntityTypes.CARGO_CRATE_MINECARTS[color]!!, "Вагонетка с $name грузовым ящиком") - add(MRegistry.TRITANIUM_PRESSURE_PLATE.getBlock(color), "$name Тритановая Нажимная Пластина") + add(MRegistry.TRITANIUM_PRESSURE_PLATE.getBlock(color), "$name тритановая нажимная пластина") add(MRegistry.TRITANIUM_PRESSURE_PLATE.getBlock(color), "description0", "Активируется только при наступлении игрока на неё") add(MRegistry.TRITANIUM_PRESSURE_PLATE.getBlock(color), "description1", HIGH_BLAST_RESISTANCE) - add(MBlocks.TRITANIUM_DOOR[color]!!, "$name Тритановая Дверь") + add(MBlocks.TRITANIUM_DOOR[color]!!, "$name тритановая дверь") add(MBlocks.TRITANIUM_DOOR[color]!!, "description0", HIGH_BLAST_RESISTANCE_DOOR) add(MBlocks.TRITANIUM_DOOR[color]!!, "description1", FEELING_SAFE_NOW) add(MBlocks.TRITANIUM_DOOR[color]!!, "description2", "Данный вариант выкрашен в $name") - add(MBlocks.TRITANIUM_TRAPDOOR[color]!!, "$name Тритановый Люк") + add(MBlocks.TRITANIUM_TRAPDOOR[color]!!, "$name тритановый люк") add(MBlocks.TRITANIUM_TRAPDOOR[color]!!, "description0", HIGH_BLAST_RESISTANCE_DOOR) add(MBlocks.TRITANIUM_TRAPDOOR[color]!!, "description1", FEELING_SAFE_NOW) add(MBlocks.TRITANIUM_TRAPDOOR[color]!!, "description2", "Данный вариант выкрашен в $name") } - add(MRegistry.TRITANIUM_PRESSURE_PLATE.block, "Тритановая Нажимная Пластина") + add(MRegistry.TRITANIUM_PRESSURE_PLATE.block, "Тритановая нажимная пластина") add(MRegistry.TRITANIUM_PRESSURE_PLATE.block, "description0", "Активируется только при наступлении игрока на неё") add(MRegistry.TRITANIUM_PRESSURE_PLATE.block, "description1", HIGH_BLAST_RESISTANCE) } with(provider.russian) { - add(MItems.CARGO_CRATE_MINECARTS[null]!!, "Вагонетка с Грузовым Ящиком") - add(MEntityTypes.CARGO_CRATE_MINECARTS[null]!!, "Вагонетка с Грузовым Ящиком") + add(MItems.CARGO_CRATE_MINECARTS[null]!!, "Вагонетка с грузовым ящиком") + add(MEntityTypes.CARGO_CRATE_MINECARTS[null]!!, "Вагонетка с грузовым ящиком") - add(MRegistry.CARGO_CRATES.block, "Грузовой Ящик") - add(MRegistry.TRITANIUM_BLOCK.block, "Тритановый Блок") - add(MRegistry.TRITANIUM_STAIRS.block, "Тритановые Ступеньки") - add(MRegistry.TRITANIUM_SLAB.block, "Тритановая Плита") - add(MRegistry.TRITANIUM_WALL.block, "Тритановая Ограда") + add(MRegistry.CARGO_CRATES.block, "Грузовой ящик") + add(MRegistry.TRITANIUM_BLOCK.block, "Тритановый блок") + add(MRegistry.TRITANIUM_STAIRS.block, "Тритановые ступеньки") + add(MRegistry.TRITANIUM_SLAB.block, "Тритановая плита") + add(MRegistry.TRITANIUM_WALL.block, "Тритановая ограда") - add(MRegistry.INDUSTRIAL_GLASS.block, "Промышленное Стекло") - add(MRegistry.INDUSTRIAL_GLASS_PANE.block, "Панель Промышенного Стекла") + add(MRegistry.INDUSTRIAL_GLASS.block, "Промышленное стекло") + add(MRegistry.INDUSTRIAL_GLASS_PANE.block, "Панель промышенного стекла") - add(MRegistry.DECORATIVE_CRATE.block, "Ржавый Грузовой Контейнер") + add(MRegistry.DECORATIVE_CRATE.block, "Ржавый грузовой контейнер") add(MRegistry.VENT.block, "Вентиляция") - add(MRegistry.VENT_ALTERNATIVE.block, "Альтернаятивная Вентиляция") + add(MRegistry.VENT_ALTERNATIVE.block, "Альтернаятивная вентиляция") for ((block, colors) in MRegistry.TRITANIUM_STRIPED_BLOCK.blocksWithColor) { val (base, stripe) = colors @@ -81,7 +81,7 @@ private fun decoratives(provider: MatteryLanguageProvider) { val baseName = provider.russianColors.dyeClassMapped[base]!! val stripeName = provider.russianColors.dyeClassMapped[stripe]!! - add(block, "$baseName-Окрашенный $stripeName-Ополосаченный Тритановый Блок") + add(block, "$baseName-окрашенный $stripeName-ополосаченный тритановый блок") } for ((block, colors) in MRegistry.TRITANIUM_STRIPED_STAIRS.blocksWithColor) { @@ -90,7 +90,7 @@ private fun decoratives(provider: MatteryLanguageProvider) { val baseName = provider.russianColors.dyeClassMapped[base]!! val stripeName = provider.russianColors.dyeClassMapped[stripe]!! - add(block, "$baseName-Окрашенные $stripeName-Ополосаченные Тритановые Ступеньки") + add(block, "$baseName-окрашенные $stripeName-ополосаченные тритановые ступеньки") } for ((block, colors) in MRegistry.TRITANIUM_STRIPED_SLAB.blocksWithColor) { @@ -99,7 +99,7 @@ private fun decoratives(provider: MatteryLanguageProvider) { val baseName = provider.russianColors.dyeClassMapped[base]!! val stripeName = provider.russianColors.dyeClassMapped[stripe]!! - add(block, "$baseName-Окрашенная $stripeName-Ополосаченная Тритановая Плита") + add(block, "$baseName-окрашенная $stripeName-ополосаченная тритановая Плита") } for ((block, colors) in MRegistry.TRITANIUM_STRIPED_WALL.blocksWithColor) { @@ -108,7 +108,7 @@ private fun decoratives(provider: MatteryLanguageProvider) { val baseName = provider.russianColors.dyeClassMapped[base]!! val stripeName = provider.russianColors.dyeClassMapped[stripe]!! - add(block, "$baseName-Окрашенная $stripeName-Ополосаченная Тритановая Ограда") + add(block, "$baseName-окрашенная $stripeName-ополосаченная тритановая ограда") } } } @@ -154,8 +154,8 @@ private fun misc(provider: MatteryLanguageProvider) { gui("exopack_upgrades.no_exopack", "Данный пазл технологии кажется для вас бесполезным... Или..?!") gui("exopack_upgrades.already_activated", "Улучшение уже активно!") - gui("exopack_upgrades.slots_upgrade", "Активируя данное улучшение даст %s слотов в вашем Экзопаке.") - gui("exopack_upgrades.crafting_upgrade", "Активируя данное улучшение даст 3x3 сетку создания в вашем Экзопаке.") + gui("exopack_upgrades.slots_upgrade", "Активируя данное улучшение даст %s слотов в вашем экзопаке.") + gui("exopack_upgrades.crafting_upgrade", "Активируя данное улучшение даст 3x3 сетку создания в вашем экзопаке.") gui("crude_battery.replace_in_world", "Простота устройства данного аккумулятора позволяет вам заменить .") gui("crude_battery.replace_in_world_warning", "Данная операция крайне рискованная и может нанести огромный урон вашим системам!") @@ -173,7 +173,7 @@ private fun misc(provider: MatteryLanguageProvider) { misc("exopack.granted4", "Данное устройство предоставляет вам доступ к карманному измерению в 4том измерении.") misc("exopack.granted5", "Ищите или создавайте модули для улучшения Экзопака.") misc("exopack.granted6", "Так же сам Экзопак существует в 4том измерении, что не мешает носить любую броню.") - misc("exopack.granted7", "Но не смотря на то, что Экзопак существует в 4том измерении, предметы из него всё равно высыпаются при смерти.") + misc("exopack.granted7", "Но не смотря на то, что экзопак существует в 4том измерении, предметы из него всё равно высыпаются при смерти.") misc("dumping_matter_registry", "Выгружаю реестр материи в %s") misc("dumped_matter_registry", "Выгрузил реестр материи в %s") @@ -272,7 +272,7 @@ private fun misc(provider: MatteryLanguageProvider) { misc("pill.oblivion", "Предметы и Очки опыта, потраченные на исследования полностью возвращаются.") misc("pill.message_oblivion", "Все возможности андроида были удалены, а потраченные на исследования предметы и опыт возвращены.") - misc("pill.heal", "Мгновенно восполняет 4 сердца при употреблении, а так же даёт на 2 минуты Поглощение V и на 8 секунд Регенерацию III.") + misc("pill.heal", "Мгновенно восполняет 4 сердца при употреблении, а так же даёт на 2 минуты поглощение V и на 8 секунд регенерацию III.") misc("pill.heal_android", "Не действует на андроидов.") misc("pill.message", "Ничего не произошло, но вы чувствуете... себя уставшим?.. Возможно надо отдохнуть.") @@ -315,7 +315,7 @@ private fun misc(provider: MatteryLanguageProvider) { misc("3d2d.gravitation_stabilizer.mass", "Масса сингулярности: %s") misc("3d2d.gravitation_stabilizer.strength", "Гравитационная сила: %s") - misc("android_station.research.low_power", "Мало питания у Станции Андроидов! Исследования недоступны!") + misc("android_station.research.low_power", "Мало питания у станции андроидов! Исследования недоступны!") misc("android_station.research.researched", "Исследовано!") misc("android_station.research.can_be_researched", "Готово к исследованию!") misc("android_station.research.can_not_be_researched", "Нельзя исследовать!") @@ -368,159 +368,159 @@ private fun death(provider: MatteryLanguageProvider) { private fun blocks(provider: MatteryLanguageProvider) { with(provider.russian) { - add(MBlocks.ANDROID_STATION, "Станция Андроидов") - add(MBlocks.BATTERY_BANK, "Банк Аккумуляторов") - add(MBlocks.MATTER_DECOMPOSER, "Декомпозитор Материи") - add(MBlocks.MATTER_CAPACITOR_BANK, "Банк Накопителей Материи") - add(MBlocks.MATTER_CABLE, "Кабель Сети Материи") - add(MBlocks.PATTERN_STORAGE, "Хранилище Шаблонов") - add(MBlocks.MATTER_SCANNER, "Сканер Материи") - add(MBlocks.MATTER_PANEL, "Монитор Шаблонов") - add(MBlocks.MATTER_REPLICATOR, "Репликатор Материи") - add(MBlocks.MATTER_BOTTLER, "Бутилировщик Материи") - add(MBlocks.DRIVE_VIEWER, "Просмотрщик Дисков Конденсации") - add(MBlocks.BLACK_HOLE, "Локализированное Аномальное Сингулярное Гравитационное Поле") - add(MBlocks.COBBLESTONE_GENERATOR, "Генератор Булыжника") + add(MBlocks.ANDROID_STATION, "Станция андроидов") + add(MBlocks.BATTERY_BANK, "Банк аккумуляторов") + add(MBlocks.MATTER_DECOMPOSER, "Декомпозитор материи") + add(MBlocks.MATTER_CAPACITOR_BANK, "Банк накопителей материи") + add(MBlocks.MATTER_CABLE, "Кабель сети материи") + add(MBlocks.PATTERN_STORAGE, "Хранилище шаблонов") + add(MBlocks.MATTER_SCANNER, "Сканер материи") + add(MBlocks.MATTER_PANEL, "Монитор шаблонов") + add(MBlocks.MATTER_REPLICATOR, "Репликатор материи") + add(MBlocks.MATTER_BOTTLER, "Бутилировщик материи") + add(MBlocks.DRIVE_VIEWER, "Просмотрщик дисков конденсации") + add(MBlocks.BLACK_HOLE, "Локализированное аномальное сингулярное гравитационное поле") + add(MBlocks.COBBLESTONE_GENERATOR, "Генератор булыжника") - add(MBlocks.ENGINE, "Двигатель Корабля") - add(MBlocks.HOLO_SIGN, "Голографическая Табличка") + add(MBlocks.ENGINE, "Двигатель корабля") + add(MBlocks.HOLO_SIGN, "Голографическая табличка") - add(MBlocks.TRITANIUM_INGOT_BLOCK, "Блок Слитков Тритана") + add(MBlocks.TRITANIUM_INGOT_BLOCK, "Блок слитков тритана") - add(MBlocks.ENERGY_COUNTER, "Счётчик Энергии") - add(MBlocks.ENERGY_COUNTER, "facing", "Сторона входа: %s") - add(MBlocks.ENERGY_COUNTER, "switch", "Сменить сторону входа") - add(MBlocks.ENERGY_COUNTER, "limit", "Лимит Ввода/Вывода. -1 для отключения лимитов") + add(MBlocks.ENERGY_COUNTER, "Счётчик энергии") + add(MBlocks.ENERGY_COUNTER, "Facing", "сторона входа: %s") + add(MBlocks.ENERGY_COUNTER, "Switch", "сменить сторону входа") + add(MBlocks.ENERGY_COUNTER, "Limit", "лимит ввода/вывода. -1 для отключения лимитов") - add(MBlocks.CHEMICAL_GENERATOR, "Химический Генератор") - add(MBlocks.DRIVE_RACK, "Стеллаж Дисков Конденсации") - add(MBlocks.ITEM_MONITOR, "Монитор Предметов") - add(MBlocks.PLATE_PRESS, "Пресс Пластин") + add(MBlocks.CHEMICAL_GENERATOR, "Химический генератор") + add(MBlocks.DRIVE_RACK, "Стеллаж дисков конденсации") + add(MBlocks.ITEM_MONITOR, "Монитор предметов") + add(MBlocks.PLATE_PRESS, "Пресс пластин") - add(MBlocks.MATTER_RECYCLER, "Перерабатыватель Материи") - add(MBlocks.ENERGY_SERVO, "Энергетическая Помпа") - add(MBlocks.ENERGY_SERVO, "desc", "Заряжает, Разряжает и Передаёт энергию между предметами") + add(MBlocks.MATTER_RECYCLER, "Перерабатыватель материи") + add(MBlocks.ENERGY_SERVO, "Энергетическая помпа") + add(MBlocks.ENERGY_SERVO, "Desc", "заряжает, разряжает и передаёт энергию между предметами") - add(MBlocks.CARBON_FIBRE_BLOCK, "Блок Углеродных Трубок") + add(MBlocks.CARBON_FIBRE_BLOCK, "Блок углеродных трубок") - add(MBlocks.TRITANIUM_STRIPED_BLOCK, "Тритановый Блок с Полоской") - add(MBlocks.TRITANIUM_STRIPED_STAIRS, "Тритановые Ступеньки с Полоской") - add(MBlocks.TRITANIUM_STRIPED_SLAB, "Тритановая Плита с Полоской") - add(MBlocks.TRITANIUM_STRIPED_WALL, "Тритановая Ограда с Полоской") - add(MBlocks.TRITANIUM_ORE, "Тритановая Руда") - add(MBlocks.DEEPSLATE_TRITANIUM_ORE, "Тританоносный Глубинный Сланец") - add(MBlocks.TRITANIUM_RAW_BLOCK, "Блок Рудного Тритана") + add(MBlocks.TRITANIUM_STRIPED_BLOCK, "Тритановый блок с полоской") + add(MBlocks.TRITANIUM_STRIPED_STAIRS, "Тритановые ступеньки с полоской") + add(MBlocks.TRITANIUM_STRIPED_SLAB, "Тритановая плита с полоской") + add(MBlocks.TRITANIUM_STRIPED_WALL, "Тритановая ограда с полоской") + add(MBlocks.TRITANIUM_ORE, "Тритановая руда") + add(MBlocks.DEEPSLATE_TRITANIUM_ORE, "Тританоносный глубинный сланец") + add(MBlocks.TRITANIUM_RAW_BLOCK, "Блок рудного тритана") - add(MBlocks.STORAGE_CABLE, "Кабель Хранилища") - add(MBlocks.STORAGE_POWER_SUPPLIER, "Подстанция Сети Хранилища") - add(MBlocks.STORAGE_BUS, "Шина Хранилища") - add(MBlocks.STORAGE_IMPORTER, "Импортер Хранилища") - add(MBlocks.STORAGE_EXPORTER, "Экспортер Хранилища") + add(MBlocks.STORAGE_CABLE, "Кабель хранилища") + add(MBlocks.STORAGE_POWER_SUPPLIER, "Подстанция сети хранилища") + add(MBlocks.STORAGE_BUS, "Шина хранилища") + add(MBlocks.STORAGE_IMPORTER, "Импортер хранилища") + add(MBlocks.STORAGE_EXPORTER, "Экспортер хранилища") - add(MBlocks.GRAVITATION_STABILIZER, "Стабилизатор Пространства-Времени") - add(MBlocks.GRAVITATION_STABILIZER_LENS, "Линза Стабилизатора Пространства-Времени") - add(MBlocks.GRAVITATION_STABILIZER, "desc", "Уменьшает гравитационное влияние сингулярностей") - add(MBlocks.GRAVITATION_STABILIZER, "desc2", "Имейте ввиду, что несколько стабилизаторов создают экспоненциальный эффект") - add(MBlocks.GRAVITATION_STABILIZER, "desc3", "Слишком слабое гравитационное поле сингулярности приведёт к быстрому испарению последней") + add(MBlocks.GRAVITATION_STABILIZER, "Стабилизатор пространства-времени") + add(MBlocks.GRAVITATION_STABILIZER_LENS, "Линза стабилизатора пространства-времени") + add(MBlocks.GRAVITATION_STABILIZER, "Desc", "уменьшает гравитационное влияние сингулярностей") + add(MBlocks.GRAVITATION_STABILIZER, "Desc2", "имейте ввиду, что несколько стабилизаторов создают экспоненциальный эффект") + add(MBlocks.GRAVITATION_STABILIZER, "Desc3", "слишком слабое гравитационное поле сингулярности приведёт к быстрому испарению последней") - add(MBlocks.PHANTOM_ATTRACTOR, "Приманщик Фантомов") - add(MBlocks.PHANTOM_ATTRACTOR, "desc", "Приманивает фантомов в ночное время") + add(MBlocks.PHANTOM_ATTRACTOR, "Приманщик фантомов") + add(MBlocks.PHANTOM_ATTRACTOR, "Desc", "приманивает фантомов в ночное время") - add(MBlocks.LABORATORY_LAMP, "Лабораторная Лампа") - add(MBlocks.LABORATORY_LAMP, "description", "Освещает на несколько блоков в направлении своей лампы, с переключателем красного камня") - add(MBlocks.LABORATORY_LAMP_INVERTED, "Лабораторная Лампа (Инвентированный Сигнал)") - add(MBlocks.DANGER_STRIPE_BLOCK, "Полоски 'Опасность'") - add(MBlocks.METAL_BEAM, "Металлическая Опора") + add(MBlocks.LABORATORY_LAMP, "Лабораторная лампа") + add(MBlocks.LABORATORY_LAMP, "Description", "освещает на несколько блоков в направлении своей лампы, с переключателем красного камня") + add(MBlocks.LABORATORY_LAMP_INVERTED, "Лабораторная лампа (инвентированный сигнал)") + add(MBlocks.DANGER_STRIPE_BLOCK, "Полоски 'опасность'") + add(MBlocks.METAL_BEAM, "Металлическая опора") - add(MBlocks.TRITANIUM_DOOR[null]!!, "Тритановая Дверь") + add(MBlocks.TRITANIUM_DOOR[null]!!, "Тритановая дверь") add(MBlocks.TRITANIUM_DOOR[null]!!, "description0", "Взрывоустойчивая дверь с засовом красного камня...") add(MBlocks.TRITANIUM_DOOR[null]!!, "description1", FEELING_SAFE_NOW) - add(MBlocks.TRITANIUM_TRAPDOOR[null]!!, "Тритановый Люк") + add(MBlocks.TRITANIUM_TRAPDOOR[null]!!, "Тритановый люк") add(MBlocks.TRITANIUM_TRAPDOOR[null]!!, "description0", "Взрывоустойчивая дверь с засовом красного камня...") add(MBlocks.TRITANIUM_TRAPDOOR[null]!!, "description1", FEELING_SAFE_NOW) add(MBlocks.TRITANIUM_BARS, "Тритановая решётка") for (block in MBlocks.TRITANIUM_ANVIL) - add(block, "Тритановая Наковальня") + add(block, "Тритановая наковальня") } } private fun items(provider: MatteryLanguageProvider) { with(provider.russian) { - add(MItems.EXOPACK_PROBE, "Маяк Экзопака") - add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_CREATIVE, "Творческое Обновление Инвентаря Экзопака") - add(MItems.ExopackUpgrades.CRAFTING_UPGRADE, "Обновление Сетки Крафта Экзопака") + add(MItems.EXOPACK_PROBE, "Маяк экзопака") + add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_CREATIVE, "Творческое обновление инвентаря экзопака") + add(MItems.ExopackUpgrades.CRAFTING_UPGRADE, "Обновление сетки крафта экзопака") - add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_WITHER, "Обновление Сверхмассивной Упаковки") - add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_WITHER, "description", "Использует те же принципы, которыми обладают Звёзды Незера") + add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_WITHER, "Обновление сверхмассивной упаковки") + add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_WITHER, "description", "Использует те же принципы, которыми обладают звёзды незера") - add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_ENDER_DRAGON, "Обновление Соединения Края Экзопака") + add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_ENDER_DRAGON, "Обновление соединения края экзопака") add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_ENDER_DRAGON, "description", "Позволяет хранить предметы в карманном измерении") - add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, "Неописуемое Обновление Инвентаря Экзопака") + add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, "Неописуемое обновление инвентаря экзопака") add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, "description", "В нормальных условиях, они появляются в сундуках") - add(MItems.NUTRIENT_PASTE, "Питательная Паста") + add(MItems.NUTRIENT_PASTE, "Питательная паста") - add(MItems.BLACK_HOLE_SCANNER, "Сканер Сингулярностей") + add(MItems.BLACK_HOLE_SCANNER, "Сканер сингулярностей") add(MItems.BLACK_HOLE_SCANNER, "desc", "Сканирует сингулярности и считывает их свойства") add(MItems.BLACK_HOLE_SCANNER, "desc2", "Держите в любой их рук для считывания массы сингулярностей") - add(MItems.GRAVITATION_FIELD_LIMITER, "Ограничитель Гравитационного Поля") - add(MItems.GRAVITATION_FIELD_SENSOR, "Сенсор Гравитационного Искажения") - add(MItems.PORTABLE_GRAVITATION_STABILIZER, "Портативный Стабилизатор Пространства-времени") + add(MItems.GRAVITATION_FIELD_LIMITER, "Ограничитель гравитационного поля") + add(MItems.GRAVITATION_FIELD_SENSOR, "Сенсор гравитационного искажения") + add(MItems.PORTABLE_GRAVITATION_STABILIZER, "Портативный стабилизатор пространства-времени") - add(MItems.BATTERY_CRUDE, "Самобытный Аккумулятор") - add(MItems.BATTERY_BASIC, "Простой Аккумулятор") + add(MItems.BATTERY_CRUDE, "Самобытный аккумулятор") + add(MItems.BATTERY_BASIC, "Простой аккумулятор") add(MItems.BATTERY_NORMAL, "Аккумулятор") - add(MItems.BATTERY_DENSE, "Плотный Аккумулятор") - add(MItems.BATTERY_CAPACITOR, "Аккумулятор-Конденсатор") - add(MItems.BATTERY_CREATIVE, "Творческий Аккумулятор") + add(MItems.BATTERY_DENSE, "Плотный аккумулятор") + add(MItems.BATTERY_CAPACITOR, "Аккумулятор-конденсатор") + add(MItems.BATTERY_CREATIVE, "Творческий аккумулятор") - add(MItems.QUANTUM_BATTERY, "Квантовый Аккумулятор") - add(MItems.QUANTUM_CAPACITOR, "Квантовый Аккумулятор-Накопитель") - add(MItems.QUANTUM_BATTERY_CREATIVE, "Творческий Квантовый Аккумулятор") + add(MItems.QUANTUM_BATTERY, "Квантовый аккумулятор") + add(MItems.QUANTUM_CAPACITOR, "Квантовый аккумулятор-накопитель") + add(MItems.QUANTUM_BATTERY_CREATIVE, "Творческий квантовый аккумулятор") - add(MItems.TRITANIUM_SWORD, "Тритановый Меч") - add(MItems.TRITANIUM_PICKAXE, "Тритановая Кирка") - add(MItems.TRITANIUM_SHOVEL, "Тритановая Лопата") - add(MItems.TRITANIUM_AXE, "Тритановый Топор") - add(MItems.TRITANIUM_HOE, "Тритановая Мотыга") + add(MItems.TRITANIUM_SWORD, "Тритановый меч") + add(MItems.TRITANIUM_PICKAXE, "Тритановая кирка") + add(MItems.TRITANIUM_SHOVEL, "Тритановая лопата") + add(MItems.TRITANIUM_AXE, "Тритановый топор") + add(MItems.TRITANIUM_HOE, "Тритановая мотыга") add(MItems.TRITANIUM_SHEARS, "Тритановые ножницы") add(MItems.TRITANIUM_SHIELD, "Тритановый щит") - add(MItems.TRITANIUM_HELMET, "Тритановый Шлем") - add(MItems.TRITANIUM_CHESTPLATE, "Тритановый Нагрудник") - add(MItems.TRITANIUM_PANTS, "Тритановые Поножи") - add(MItems.TRITANIUM_BOOTS, "Тритановые Ботинки") + add(MItems.TRITANIUM_HELMET, "Тритановый шлем") + add(MItems.TRITANIUM_CHESTPLATE, "Тритановый нагрудник") + add(MItems.TRITANIUM_PANTS, "Тритановые поножи") + add(MItems.TRITANIUM_BOOTS, "Тритановые ботинки") - add(MItems.TRITANIUM_DUST, "Тритановая Пыль") - add(MItems.TRITANIUM_INGOT, "Тритановый Слиток") + add(MItems.TRITANIUM_DUST, "Тритановая пыль") + add(MItems.TRITANIUM_INGOT, "Тритановый слиток") add(MItems.TRITANIUM_NUGGET, "Тритановый самородок") - add(MItems.MATTER_IO_PORT, "Порт Ввода/Вывода Материи") - add(MItems.MATTER_TRANSFORM_MATRIX, "Матрица Преобразования Материи") - add(MItems.ENERGY_BUS, "Шина Питания") - add(MItems.ELECTRIC_PARTS, "Электрические Части") - add(MItems.MACHINE_FRAME, "Каркас Механизма") - add(MItems.TRITANIUM_PLATE, "Тритановая Пластина") - add(MItems.IRON_PLATE, "Железная Пластина") - add(MItems.GOLD_PLATE, "Золотая Пластина") - add(MItems.COPPER_WIRING, "Медная Проволока") - add(MItems.GOLD_WIRING, "Золотая Проволока") - add(MItems.PORTABLE_CONDENSATION_DRIVE_CASING, "Каркас Портативного Диска Конденсации") - add(MItems.PORTABLE_DENSE_CONDENSATION_DRIVE_CASING, "Каркас Плотного Портативного Диска Конденсации") - add(MItems.CIRCUIT_PLATING, "Плата Электроники") - add(MItems.BASIC_CONTROL_CIRCUIT, "Простая Схема Управления") - add(MItems.ADVANCED_CONTROL_CIRCUIT, "Продвинутая Схема Управления") - add(MItems.QUANTUM_TRANSCEIVER, "Квантовый Передатчик") + add(MItems.MATTER_IO_PORT, "Порт ввода/вывода материи") + add(MItems.MATTER_TRANSFORM_MATRIX, "Матрица преобразования материи") + add(MItems.ENERGY_BUS, "Шина питания") + add(MItems.ELECTRIC_PARTS, "электрические части") + add(MItems.MACHINE_FRAME, "Каркас механизма") + add(MItems.TRITANIUM_PLATE, "тритановая пластина") + add(MItems.IRON_PLATE, "Железная пластина") + add(MItems.GOLD_PLATE, "Золотая пластина") + add(MItems.COPPER_WIRING, "медная проволока") + add(MItems.GOLD_WIRING, "Золотая проволока") + add(MItems.PORTABLE_CONDENSATION_DRIVE_CASING, "Каркас портативного диска конденсации") + add(MItems.PORTABLE_DENSE_CONDENSATION_DRIVE_CASING, "Каркас плотного портативного диска конденсации") + add(MItems.CIRCUIT_PLATING, "Плата электроники") + add(MItems.BASIC_CONTROL_CIRCUIT, "Простая схема управления") + add(MItems.ADVANCED_CONTROL_CIRCUIT, "Продвинутая схема управления") + add(MItems.QUANTUM_TRANSCEIVER, "Квантовый передатчик") add(MItems.ELECTROMAGNET, "Электромагнит") - add(MItems.MIRROR_COMPOUND, "Набор Выплавки Зеркала") + add(MItems.MIRROR_COMPOUND, "Набор выплавки зеркала") add(MItems.MIRROR, "Зеркало") add(MItems.MIRROR, "description", "Я могу очень отчётливо видеть своё отражение в этом зеркале") - add(MItems.GRAVITATIONAL_DISRUPTOR, "Антигравитационный Маяк") + add(MItems.GRAVITATIONAL_DISRUPTOR, "Антигравитационный маяк") add(MItems.GRAVITATIONAL_DISRUPTOR, "description", "Будучи находясь около сверхмассивного тела, создаёт противоположное искажение пространства-времени") add(MItems.GRAVITATIONAL_DISRUPTOR, "description2", "Позволяет уничтожать сингулярности") @@ -529,23 +529,23 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.GRAVITATIONAL_DISRUPTOR, "description4_clarification", "не может быть") add(MItems.GRAVITATIONAL_DISRUPTOR, "description4_clarification2", "ничем") - add(MItems.MATTER_DUST, "Пыль Материи") + add(MItems.MATTER_DUST, "Пыль материи") add(MItems.MATTER_DUST, "desc", "Данный предмет является результатом неудачной попытки декомпозиции или репликации") add(MItems.MATTER_DUST, "desc2", "Закиньте в Материальный Переработчик для переработки обратно в чистую материю!") add(MItems.MATTER_DUST, "desc3", "Не нюхать, не кидать на других и не сыпать на пончики") - add(MItems.PILL_ANDROID, "Пилюля Андроида") - add(MItems.PILL_HUMANE, "Пилюля Человечности") - add(MItems.PILL_OBLIVION, "Пилюля Сброса Андроида до Заводских Настроек") - add(MItems.PILL_HEAL, "Медицинская Пилюля") + add(MItems.PILL_ANDROID, "Пилюля андроида") + add(MItems.PILL_HUMANE, "Пилюля человечности") + add(MItems.PILL_OBLIVION, "Пилюля сброса андроида до заводских настроек") + add(MItems.PILL_HEAL, "Медицинская пилюля") - add(MItems.MATTER_CAPACITOR_PARTS, "Части Накопителя Материи") - add(MItems.MATTER_CAPACITOR_BASIC, "Простой Накопитель Материи") - add(MItems.MATTER_CAPACITOR_NORMAL, "Накопитель Материи") - add(MItems.MATTER_CAPACITOR_DENSE, "Плотный Накопитель Материи") - add(MItems.MATTER_CAPACITOR_CREATIVE, "Творческий Накопитель Материи") + add(MItems.MATTER_CAPACITOR_PARTS, "Части накопителя материи") + add(MItems.MATTER_CAPACITOR_BASIC, "Простой накопитель материи") + add(MItems.MATTER_CAPACITOR_NORMAL, "Накопитель материи") + add(MItems.MATTER_CAPACITOR_DENSE, "Плотный накопитель материи") + add(MItems.MATTER_CAPACITOR_CREATIVE, "Творческий накопитель материи") - add(MItems.ENERGY_SWORD, "Высокочастотный Клинок") + add(MItems.ENERGY_SWORD, "Высокочастотный клинок") add(MItems.ENERGY_SWORD, "desc", "Требует энергию для работы") add(MItems.ENERGY_SWORD, "desc2", "Наносит дополнительный урон андроидам если имеет заряд") add(MItems.ENERGY_SWORD, "desc3", "Всегда наносит полный урон по площади если имеет заряд") @@ -553,25 +553,25 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.PORTABLE_CONDENSATION_DRIVE, "Portable Condensation Drive") add(MItems.PORTABLE_DENSE_CONDENSATION_DRIVE, "Portable Dense Condensation Drive") - add(MItems.PLASMA_RIFLE, "Плазменная Винтовка") - add(MItems.TRITANIUM_ORE_CLUMP, "Рудный Тритан") - add(MItems.PATTERN_DRIVE_NORMAL, "Диск Шаблонов") - add(MItems.PATTERN_DRIVE_CREATIVE, "Творческий Диск Шаблонов") + add(MItems.PLASMA_RIFLE, "Плазменная винтовка") + add(MItems.TRITANIUM_ORE_CLUMP, "Рудный тритан") + add(MItems.PATTERN_DRIVE_NORMAL, "Диск шаблонов") + add(MItems.PATTERN_DRIVE_CREATIVE, "Творческий диск шаблонов") - add(MItems.PATTERN_DRIVE_CREATIVE2, "Вездесущий Диск Шаблонов") + add(MItems.PATTERN_DRIVE_CREATIVE2, "Вездесущий диск шаблонов") add(MItems.PATTERN_DRIVE_CREATIVE2, "description1", "Предмет режима творчества") add(MItems.PATTERN_DRIVE_CREATIVE2, "description2", "Содержит в себе шаблоны всех предметов, которые имеют значение материи") - add(MItems.ZPM_BATTERY, "Модуль Нулевой Точки") + add(MItems.ZPM_BATTERY, "Модуль нулевой точки") add(MItems.ZPM_BATTERY, "description", "Может быть найден у тех, кто путешествует между измерениями, если, конечно, они смогли достигнуть вселенной, где данные устройства были созиданы...") } } private fun stats(provider: MatteryLanguageProvider) { with(provider.russian) { - stat("health_regenerated", "Здоровья Отрегенерировано Наноботами") - stat("damage_absorbed", "Урона Поглащено Наноботами") - stat("power_consumed", "МтДж Сожжено за Андроида") + stat("health_regenerated", "Здоровья отрегенерировано наноботами") + stat("damage_absorbed", "Урона поглащено наноботами") + stat("power_consumed", "МтДж сожжено за андроида") } } @@ -592,15 +592,15 @@ private fun research(provider: MatteryLanguageProvider) { private fun androidFeatures(provider: MatteryLanguageProvider) { with(provider.russian) { - add(AndroidFeatures.AIR_BAGS, "Воздушные Мешки") - add(AndroidFeatures.SHOCKWAVE, "Генератор Ударных Волн") - add(AndroidFeatures.NIGHT_VISION, "Ночное Зрение") - add(AndroidFeatures.NANOBOTS_ARMOR, "Броня из Наноботов") - add(AndroidFeatures.ITEM_MAGNET, "Предметный Магнит") - add(AndroidFeatures.STEP_ASSIST, "Помощник Подъёма") - add(AndroidFeatures.PHANTOM_ATTRACTOR, "Приманщик Фантомов") - add(AndroidFeatures.JUMP_BOOST, "Усилитель Прыжка") - add(AndroidFeatures.ENDER_TELEPORTER, "Телепортатор Края") + add(AndroidFeatures.AIR_BAGS, "Воздушные мешки") + add(AndroidFeatures.SHOCKWAVE, "Генератор ударных волн") + add(AndroidFeatures.NIGHT_VISION, "Ночное зрение") + add(AndroidFeatures.NANOBOTS_ARMOR, "Броня из наноботов") + add(AndroidFeatures.ITEM_MAGNET, "Предметный магнит") + add(AndroidFeatures.STEP_ASSIST, "Помощник подъёма") + add(AndroidFeatures.PHANTOM_ATTRACTOR, "Приманщик фантомов") + add(AndroidFeatures.JUMP_BOOST, "Усилитель прыжка") + add(AndroidFeatures.ENDER_TELEPORTER, "Телепортатор края") } } @@ -625,8 +625,8 @@ private fun gui(provider: MatteryLanguageProvider) { gui("stored_amount", "Точное количество в хранилище: %s шт.") - gui("sides.item_config", "Настройка Предметов") - gui("sides.energy_config", "Настройка Энергии") + gui("sides.item_config", "Настройка предметов") + gui("sides.energy_config", "Настройка энергии") gui("sides.top", "Верхняя сторона") gui("sides.bottom", "Нижняя сторона") From eda537f4606db7cc924674bac7626b1066d44c1e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Feb 2023 20:42:45 +0700 Subject: [PATCH 0244/1199] =?UTF-8?q?YuRaNnNzZZ=20=E2=80=94=2019.02.2023?= =?UTF-8?q?=2012:24=20=D0=B8=20=D0=BF=D0=BE=D1=87=D0=B5=D0=BC=D1=83=20?= =?UTF-8?q?=D0=B2=D1=81=D0=B5=20=D1=81=D0=BB=D0=BE=D0=B2=D0=B0=20=D0=B2=20?= =?UTF-8?q?=D0=BD=D0=B0=D0=B7=D0=B2=D0=B0=D0=BD=D0=B8=D0=B8=20=D1=81=20?= =?UTF-8?q?=D0=B1=D0=BE=D0=BB=D1=8C=D1=88=D0=BE=D0=B9=20=D0=B1=D1=83=D0=BA?= =?UTF-8?q?=D0=B2=D1=8B=20=D0=B8=D0=BD=D0=B3=D0=BB=D0=B8=D1=88=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=B4=D0=BE=D1=85=D1=83=D1=8F=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datagen/advancements/AdvancementData.kt | 106 +++++++++--------- .../advancements/AndroidAdvancementsData.kt | 98 ++++++++-------- .../advancements/MachineAdvancementsData.kt | 30 ++--- 3 files changed, 117 insertions(+), 117 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt index dea99aca7..ae0a8461d 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt @@ -43,7 +43,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MItems.BATTERY_CRUDE), title = translation.add("crude_battery", "Potato Power!") { - russian("Сила Картофеля!") + russian("Сила картофеля!") }, description = translation.add("crude_battery.desc", "Put together a Crude Battery. Better hope for getter better power source soon") { russian("Создайте Простой Аккумулятор. Надо бы поторопиться с созданием более продвинутого аккумулятора") @@ -57,10 +57,10 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MItems.BATTERY_NORMAL), title = translation.add("normal_battery", "Power Storage") { - russian("Хранилище Энергии") + russian("Хранилище энергии") }, description = translation.add("normal_battery.desc", "Put together a Battery") { - russian("Создайте Аккумулятор") + russian("Создайте аккумулятор") }, ) .addCriterion("has_item", criterion(MItems.BATTERY_NORMAL)) @@ -71,10 +71,10 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MItems.BATTERY_DENSE), title = translation.add("dense_battery", "Extra Space Battery") { - russian("Больше Места для Энергии") + russian("Больше места для энергии") }, description = translation.add("dense_battery.desc", "Put together a Dense Battery. Better not to expose it to fires!") { - russian("Создайте Плотный Аккумулятор. Держите подальше от огня!") + russian("Создайте плотный аккумулятор. Держите подальше от огня!") }, ) .addCriterion("has_item", criterion(MItems.BATTERY_DENSE)) @@ -88,7 +88,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist russian("Сверхконденсатор") }, description = translation.add("capacitor_battery.desc", "Put together a Capacitor Battery. Surely, you gonna need them somewhere...") { - russian("Создайте Аккумулятор-Конденсатор. Очень вероятно, что вы найдете ему применение...") + russian("Создайте аккумулятор-конденсатор. Очень вероятно, что вы найдете ему применение...") }, ) .addCriterion("has_item", criterion(MItems.BATTERY_CAPACITOR)) @@ -99,10 +99,10 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MItems.ENERGY_SWORD), title = translation.add("energy_sword", "Self Sharpening Blade") { - russian("Клинок с Самозаточкой") + russian("Клинок с самозаточкой") }, description = translation.add("energy_sword.desc", "Wield a High-Frequency Blade, a melee weapon intended to slice Creepers into creep-cakes") { - russian("Получите Высокочастотный Клинок, оружие ближнего боя предназначенное для нарезания Криперов на крипо-тортики") + russian("Получите высокочастотный клинок, оружие ближнего боя предназначенное для нарезания Криперов на крипо-тортики") }, frameType = FrameType.GOAL ) @@ -114,10 +114,10 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MItems.QUANTUM_BATTERY), title = translation.add("quantum_battery", "Power, in Superposition") { - russian("Энергия, в Суперпозиции") + russian("Энергия, в суперпозиции") }, description = translation.add("quantum_battery.desc", "Put together a Quantum Battery, powered by Ender technologies") { - russian("Создайте Квантовый Аккумулятор, пропитаную технологиями Края") + russian("Создайте квантовый аккумулятор, пропитанную технологиями Края") }, frameType = FrameType.GOAL ) @@ -132,10 +132,10 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MItems.ZPM_BATTERY), title = translation.add("zpm_battery", "Pocket Universe, as Power Source") { - russian("Карманная Вселенная, как Источник Питания") + russian("Карманная вселенная, как источник питания") }, description = translation.add("zpm_battery.desc", "Find Zero Point Module, something from different multiverse of ours, created using technologies lost in time in all possible multiverses") { - russian("Найдите Модуль Нулевой Точки, вещь из другой мультивселенной, созданная с использованием технологий, потерянных во времени во всех возможных мультивслеленных") + russian("Найдите модуль нулевой точки, вещь из другой мультивселенной, созданная с использованием технологий, потерянных во времени во всех возможных мультивслеленных") }, frameType = FrameType.CHALLENGE, hidden = true @@ -149,10 +149,10 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MItems.BLACK_HOLE), title = translation.add("black_hole_pull", "Something Massive and Something Close") { - russian("Что то Массивное и Близкое") + russian("Что то массивное и близкое") }, description = translation.add("black_hole_pull.desc", "Experience Singularity's gravitational force, better not to get closer") { - russian("Испытайте на себе гравитационную силу Сингулярности, лучше не подходить ближе") + russian("Испытайте на себе гравитационную силу сингулярности, лучше не подходить ближе") }, hidden = true ) @@ -164,10 +164,10 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MItems.BLACK_HOLE_SCANNER), title = translation.add("black_hole_scanner", "Determining the Mass") { - russian("Определяем Массу") + russian("Определяем массу") }, description = translation.add("black_hole_scanner.desc", "Craft the Singularity Scanner, to determine mass of... Singularities, from safe distance") { - russian("Создайте Сканер Сингулярностей, для определения массы... Сингулярностей на безопасном расстоянии") + russian("Создайте сканер сингулярностей, для определения массы... Сингулярностей на безопасном расстоянии") }, ) .addCriterion("has_item", criterion(MItems.BLACK_HOLE_SCANNER)) @@ -178,10 +178,10 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MItems.GRAVITATION_STABILIZER), title = translation.add("stabilizer", "Reducing the Impact") { - russian("Уменьшаем Воздействие") + russian("Уменьшаем воздействие") }, description = translation.add("stabilizer.desc", "Put together a device that defy physical laws and also defy gravity of Singularities. Better hope it does not cause any side effects") { - russian("Создайте устройство, которое смеётся перед законами физики, а так же смеётся перед силами гравитации Сингулярностей. Надо надеется, что это не принесёт никаких последствий") + russian("Создайте устройство, которое смеётся перед законами физики, а так же смеётся перед силами гравитации сингулярностей. Надо надеется, что это не принесёт никаких последствий") }, ) .addCriterion("has_item", criterion(MItems.GRAVITATION_STABILIZER)) @@ -192,7 +192,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MItems.PORTABLE_GRAVITATION_STABILIZER), title = translation.add("portable_stabilizer", "Local Gravity Field") { - russian("Локальное Поле Гравитации") + russian("Локальное поле гравитации") }, description = translation.add("portable_stabilizer.desc", "Protect yourself from gravitational effect of Singularity using Portable Space-Time Equalizer") { russian("Защитите себя от гравитационных эффектов Сингулярностей используя Портативный") @@ -207,10 +207,10 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MItems.TRITANIUM_ORE_CLUMP), title = translation.add("ore", "Blue Metal Discovery") { - russian("Открытие Синего Металла") + russian("Открытие синего металла") }, description = translation.add("ore.desc", "Mine some Tritanium") { - russian("Добудьте немного Тритана") + russian("Добудьте немного тритана") }, ) .addCriterion("has_tritanium_ore", criterion(MItemTags.TRITANIUM_ORES)) @@ -225,7 +225,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist russian("Куй сильнее...") }, description = translation.add("ingot.desc", "Smelt a Tritanium ingot") { - russian("Выплавьте Тритановый слиток") + russian("Выплавьте тритановый слиток") }, ) .addCriterion("has_tritanium_ingot", criterion(MItemTags.TRITANIUM_INGOTS)) @@ -236,10 +236,10 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MItems.TRITANIUM_PICKAXE), title = translation.add("pickaxe", "A Tool for Patient Miners") { - russian("Инструмент для Неспешных Шахтёров") + russian("Инструмент для неспешных шахтёров") }, description = translation.add("pickaxe.desc", "Craft a Tritanium Pickaxe") { - russian("Создайте Тритановую Кирку") + russian("Создайте тритановую кирку") }, ) .addCriterion("has_tritanium_pickaxe", criterion(MItems.TRITANIUM_PICKAXE)) @@ -250,7 +250,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MItems.TRITANIUM_HOE), title = translation.add("hoe", "A Tool for Farmers") { - russian("Инструмент для Фермеров") + russian("Инструмент для фермеров") }, description = translation.add("hoe.desc", "Tritanium is a very good choice for making a sturdy Hoe") { russian("Тритан - очень хороший выбор для создания прочной Мотыги") @@ -265,10 +265,10 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MItems.TRITANIUM_PLATE), title = translation.add("plate", "Hard Plating") { - russian("Прочные Пластины") + russian("Прочные пластины") }, description = translation.add("plate.desc", "Roll down some Tritanium using a Plate Press") { - russian("Раскатайте немного Тритана используя Пресс Пластин") + russian("Раскатайте немного тритана используя пресс пластин") } ) .addCriterion("has_item", criterion(MItemTags.TRITANIUM_PLATES)) @@ -279,10 +279,10 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MItems.TRITANIUM_CHESTPLATE), title = translation.add("armor", "Composite Armor") { - russian("Композитная Броня") + russian("Композитная броня") }, description = translation.add("armor.desc", "Bend some Tritanium Plates into simple yet sturdy armor") { - russian("Согните немного Тритановых Пластин в простую, но прочную, броню") + russian("Согните немного тритановых пластин в простую, но прочную, броню") } ) .requirements(RequirementsStrategy.OR) @@ -297,7 +297,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MRegistry.INDUSTRIAL_GLASS.item), title = translation.add("industrial_glass", "Extra Hard Glass") { - russian("Дополнительно Прочное Стекло") + russian("Дополнительно прочное стекло") }, description = translation.add("industrial_glass.desc", "Manual says it should be bulletproof.") { russian("В инструкции указано что оно должно быть пуленепробиваемо.") @@ -314,10 +314,10 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MRegistry.INDUSTRIAL_GLASS.getItem(DyeColor.GREEN)), title = translation.add("industrial_glass2", "Glass-Tacular Artist") { - russian("Стекло-Чаровательный Артист") + russian("Стекло-чаровательный артист") }, description = translation.add("industrial_glass2.desc", "Paint Industrial Glass all possible colors") { - russian("Покрасьте Промышленное Стекло во все возможные цвета") + russian("Покрасьте промышленное стекло во все возможные цвета") }, frameType = FrameType.GOAL ) @@ -332,10 +332,10 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MRegistry.CARGO_CRATES.item), title = translation.add("cargo_crate", "Sturdy Item Stash") { - russian("Прочное Хранилище Предметов") + russian("Прочное хранилище предметов") }, description = translation.add("cargo_crate.desc", "Cargo Crates, like Double Chest, but Single") { - russian("Грузовые Ящики, будто Двойные Сундуки, но Одинарные.") + russian("Грузовые ящики, будто двойные сундуки, но одинарные.") } ) .requirements(RequirementsStrategy.OR) @@ -349,10 +349,10 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MItems.CARGO_CRATE_MINECARTS[null]!!), title = translation.add("cargo_crate_minecart", "Crate On a Rail") { - russian("Ящик на Рельсах") + russian("Ящик на рельсах") }, description = translation.add("cargo_crate_minecart.desc", "Drop a Cargo Crate onto Minecart and see how it goes") { - russian("Сбросьте Грузовой Ящик в Вагонетку и посмотрите что получится") + russian("Сбросьте грузовой ящик в вагонетку и посмотрите, что получится") } ) .requirements(RequirementsStrategy.OR) @@ -366,10 +366,10 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MItems.CARGO_CRATE_MINECARTS[DyeColor.GREEN]!!), title = translation.add("cargo_crate_minecart2", "A Motley Train") { - russian("Пёстрый Поезд") + russian("Пёстрый поезд") }, description = translation.add("cargo_crate_minecart2.desc", "Have all color variants of Minecarts with Cargo Crates") { - russian("Создайте все варианты покрасок Вагонеток с Грузовыми Ящиками") + russian("Создайте все варианты покрасок вагонеток с грузовыми Ящиками") }, frameType = FrameType.GOAL ) @@ -384,10 +384,10 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MRegistry.CARGO_CRATES.item), title = translation.add("cargo_crate2", "Colorful Warehouse") { - russian("Разноцветный Склад") + russian("Разноцветный склад") }, description = translation.add("cargo_crate2.desc", "Craft all color variants of Cargo Crates") { - russian("Покрасьте Грузовые Ящики во все возможные цвета") + russian("Покрасьте грузовые ящики во все возможные цвета") }, frameType = FrameType.GOAL ) @@ -402,10 +402,10 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MRegistry.TRITANIUM_BLOCK.item), title = translation.add("tritanium_block", "Cold, Impregnable Wall") { - russian("Холодная, Неприступная Стена") + russian("Холодная, неприступная стена") }, description = translation.add("tritanium_block.desc", "Coat stones in Tritanium, a cheap yet incredibly sturdy material") { - russian("Покройте булыжник в Тритане, дешёвый, но невероятно прочный материал") + russian("Покройте булыжник в тритане, дешёвый, но невероятно прочный материал") } ) .requirements(RequirementsStrategy.OR) @@ -424,10 +424,10 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MItems.TRITANIUM_STRIPED_BLOCK), title = translation.add("striped_tritanium_block", "Old Fashion Color Touch") { - russian("Старомодная Цветовая Отделка") + russian("Старомодная цветовая отделка") }, description = translation.add("striped_tritanium_block.desc", "Pale Blue coat with Yellow stripe, I bet you know whose design is this") { - russian("Бледно Синяя покраска с Жёлтой полоской, я готов поспорить вы знаете чей это дизайн") + russian("Бледно синяя покраска с жёлтой полоской, я готов поспорить вы знаете чей это дизайн") } ) .requirements(RequirementsStrategy.OR) @@ -442,10 +442,10 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MRegistry.TRITANIUM_BLOCK.getItem(DyeColor.GREEN)), title = translation.add("tritanium_block2", "Colorful Fortress") { - russian("Разноцветная Крепость") + russian("Разноцветная крепость") }, description = translation.add("tritanium_block2.desc", "Put some paint over Tritanium Block to make it look fabulous") { - russian("Покрасьте Тритановый Блок для придания ему сказочных оттенков") + russian("Покрасьте тритановый блок для придания ему сказочных оттенков") } ) .requirements(RequirementsStrategy.OR) @@ -464,10 +464,10 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MRegistry.TRITANIUM_BLOCK.getItem(DyeColor.BLACK)), title = translation.add("tritanium_block3", "Paint Me A Castle") { - russian("Разукрась Мне Замок") + russian("Разукрась мне замок") }, description = translation.add("tritanium_block3.desc", "Craft all color variants of Tritanium Blocks") { - russian("Создайте все варианты покрасок Тритановых Блоков") + russian("Создайте все варианты покрасок тритановых Блоков") }, frameType = FrameType.GOAL ) @@ -483,10 +483,10 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MRegistry.TRITANIUM_STRIPED_BLOCK.getItem(DyeColor.BLACK, DyeColor.WHITE)), title = translation.add("tritanium_block4", "All The Colors") { - russian("Все Цвета Всё Сюда") + russian("Все цвета всё сюда") }, description = translation.add("tritanium_block4.desc", "Craft ALL color variants of Tritanium Blocks including striped ones") { - russian("Создайте АБСОЛЮТНО ВСЕ варианты покрасок Тритановых Блоков, включая с полосками") + russian("Создайте АБСОЛЮТНО ВСЕ варианты покрасок тритановых блоков, включая с полосками") }, frameType = FrameType.CHALLENGE ) @@ -504,10 +504,10 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MItems.PILL_ANDROID), title = translation.add("pill", "Side Colored Mystery") { - russian("Мистика с Цветными Краями") + russian("Мистика с цветными краями") }, description = translation.add("pill.desc", "Find some of those mysterious pills. Consult with Cleric before trying to ingest them.") { - russian("Найдите одну из этих ваших мистических пилюль. Проконсультируйтесь с Клериком перед употреблением.") + russian("Найдите одну из этих ваших мистических пилюль. Проконсультируйтесь с клериком перед употреблением.") }, ) .requirements(RequirementsStrategy.OR) @@ -522,7 +522,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .display( itemStack = ItemStack(MItems.PILL_HEAL), title = translation.add("all_pills", "Take Your Meds") { - russian("Пей Таблетки") + russian("Пей таблетки") }, description = translation.add("all_pills.desc", "Find all possible pill types") { russian("Найдите все возможные варианты пилюль") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt index cc035e41f..2fedfdf91 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt @@ -47,7 +47,7 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(MItems.PILL_ANDROID), title = translation.add("root", "Androids and Humans") { - russian("Андроиды и Люди") + russian("Андроиды и люди") }, description = translation.add("root.desc", "Can you make out who is cruel machine and who shows empathy?") { russian("Сможете ли вы отличить бездушную машину от того, кто показывает сочувствие?") @@ -64,10 +64,10 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(MItems.ZPM_BATTERY), title = translation.add("zpm", "Fully Autonomous") { - russian("Полностью Автономный") + russian("Полностью автономный") }, - description = translation.add("zpm.desc", "Use Zero Point Module as internal battery power source. Only time is your enemy now") { - russian("Используйте Модуль Нулевой Точки как внутренний источник питания. Теперь только время будет вашим злейшим врагом") + description = translation.add("zpm.desc", "Use Zero Point Module as internal battery power source. Only eternity is your enemy now") { + russian("Используйте модуль нулевой точки как внутренний источник питания. Теперь только вечность будет вашим злейшим врагом") }, hidden = true, frameType = FrameType.CHALLENGE @@ -80,7 +80,7 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(MItems.QUANTUM_BATTERY), title = translation.add("quantum_battery", "Wireless Charged") { - russian("Беспроводная Зарядка") + russian("Беспроводная зарядка") }, description = translation.add("quantum_battery.desc", "Use Quantum Battery as internal battery power source, might as well have Fission Reactor charge other side of the link") { russian("Используйте Квантовый Аккумулятор как внутренний источник питания, можно даже подключить другой конец к Реактору Распада") @@ -98,10 +98,10 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(MItems.PILL_ANDROID), title = translation.add("normal", "Last Sweet Dreams") { - russian("Последние Сновидения") + russian("Последние сновидения") }, description = translation.add("normal.desc", "Become an Android in your dreams, a soulless machine... Or is it?") { - russian("Превратитесь в Андроида во сне, в бездушную машину... Или нет?") + russian("Превратитесь в андроида во сне, в бездушную машину... Или нет?") }, hidden = true, ) @@ -113,10 +113,10 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(MItems.PILL_ANDROID), title = translation.add("death", "The Old Way") { - russian("Изготовленный по Старинке") + russian("Изготовленный по старинке") }, description = translation.add("death.desc", "In event of death, become an Android; Veteran's favorite") { - russian("Будучи умерев, станьте Андроидом; Ветераны оценят") + russian("Будучи умерев, станьте андроидом; Ветераны оценят") }, hidden = true, ) @@ -128,7 +128,7 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(MItems.PILL_HUMANE), title = translation.add("unandroid", "Feel Humane Again") { - russian("Вкусить Человечность Вновь") + russian("Вкусить человечность вновь") }, description = translation.add("unandroid.desc", "Become fleshy after being a machine, yet something is still missing that you had before...") { russian("Вновь обретите плоть после своей жизни как набор гаек и болтов, но вот чего-то всё равно не хватает, что было при вас с самого начала...") @@ -144,7 +144,7 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(Items.PHANTOM_MEMBRANE), title = translation.add("phantom_spawn_denied", "Insomnia Immune") { - russian("Пере-Бессоница") + russian("Пере-бессоница") }, description = translation.add("phantom_spawn_denied.desc", "Have Phantoms not come after you because you are not someone who needs to sleep") { russian("Не привлеките внимание Фантомов, так как вы не тот, кому надо спать") @@ -159,10 +159,10 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(MItems.PHANTOM_ATTRACTOR), title = translation.add("phantom_attractor", "Eversleeping Decoy") { - russian("Вечноспящий Декой") + russian("Вечноспящий декой") }, description = translation.add("phantom_attractor.desc", "Put together a Phantom Attractor, to be able to fight Phantoms as Android again") { - russian("Создайте Приманщик Фантомов, для привлечения Фантомов вновь, будучи Андроидом") + russian("Создайте приманщик фантомов, для привлечения фантомов вновь, будучи андроидом") }, ) .addCriterion("has_item", criterion(MItems.PHANTOM_ATTRACTOR)) @@ -173,10 +173,10 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(MItems.PHANTOM_ATTRACTOR), title = translation.add("phantom_attractor_research", "Deception of Phantoms") { - russian("Обман Фантомов") + russian("Обман фантомов") }, description = translation.add("phantom_attractor_research.desc", "Research into how to attract Phantoms the same way as the ones who need to sleep") { - russian("Исследуйте привлечение Фантомов, чтоб привлекать их так же, как те, кому нужно спать") + russian("Исследуйте привлечение фантомов, чтоб привлекать их так же, как те, кому нужно спать") }, ) .addCriterion("researched", AndroidResearchTrigger.Instance(modLocation(MNames.PHANTOM_ATTRACTOR))) @@ -187,10 +187,10 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(MItems.ANDROID_STATION), title = translation.add("research_anything", "New Trick") { - russian("Новый Фокус") + russian("Новый фокус") }, description = translation.add("research_anything.desc", "Research anything as Android") { - russian("Исследуйте что либо за Андроида") + russian("Исследуйте что либо за андроида") }, ) .addCriterion("research_anything", AndroidResearchTrigger.Instance(null)) @@ -201,10 +201,10 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(Items.WATER_BUCKET), title = translation.add("air_bags", "Patching Up Wooden Vessel") { - russian("В Бочку - Затычку") + russian("В бочку - затычку") }, description = translation.add("air_bags.desc", "Research Air Bags as Android, to float in water") { - russian("Исследуйте Воздушные Мешки, дабы быть вновь поплавком в воде") + russian("Исследуйте воздушные мешки, дабы быть вновь поплавком в воде") }, ) .addCriterion("air_bags", AndroidResearchTrigger.Instance(modLocation(MNames.AIR_BAGS))) @@ -215,10 +215,10 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(Items.ENDER_EYE), title = translation.add("night_vision", "Second Pair of Eyes") { - russian("Вторая Пара Глаз") + russian("Вторая пара глаз") }, description = translation.add("night_vision.desc", "Research Night Vision as Android, to see in the dark") { - russian("Исследуйте Ночное Зрение за Андроида, дабы видеть во темноте") + russian("Исследуйте ночное зрение за андроида, дабы видеть во темноте") }, ) .addCriterion("night_vision", AndroidResearchTrigger.Instance(modLocation(MNames.NIGHT_VISION))) @@ -229,10 +229,10 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(MItems.MATTER_TRANSFORM_MATRIX), title = translation.add("nanobots", "Nanomachines, Son!") { - russian("Наномашины, Дитя!") + russian("Наномашины, дитя!") }, description = translation.add("nanobots.desc", "Research Nanobots as Android, to unlock potent research that come after it") { - russian("Исследуйте Наномашины за Андроида, для разблокировки очень больших возможностей") + russian("Исследуйте наномашины за андроида, для разблокировки очень больших возможностей") }, hidden = true ) @@ -244,10 +244,10 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(Items.SHIELD), title = translation.add("nanobots_armor_deflect", "Like a Concrete Wall") { - russian("Как за Каменной Стеной") + russian("Как за каменной стеной") }, description = translation.add("nanobots_armor_deflect.desc", "Have Nanobots absorb more than 5 hears of damage while you are left still functioning") { - russian("Дайте Наноботам поглотить 5 сердец урона, не отключившись насовсем") + russian("Дайте наноботам поглотить 5 сердец урона, не отключившись насовсем") }, hidden = true, frameType = FrameType.GOAL @@ -260,10 +260,10 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(Items.SHIELD), title = translation.add("nanobots_armor_deflect2", "Unstoppable Force vs Immovable Object") { - russian("Неостановимая Сила против Недвижимого Объекта") + russian("Неостановимая сила против недвижимого объекта") }, description = translation.add("nanobots_armor_deflect2.desc", "Have Nanobots absorb more than 10 hears of damage while you are left still functioning") { - russian("Дайте Наноботам поглотить 10 сердец урона, не отключившись насовсем") + russian("Дайте наноботам поглотить 10 сердец урона, не отключившись насовсем") }, hidden = true, frameType = FrameType.CHALLENGE @@ -276,10 +276,10 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(Items.FEATHER), title = translation.add("fall_dampeners_save", "Lucky Landing") { - russian("Удачное Приземление") + russian("Удачное приземление") }, description = translation.add("fall_dampeners_save.desc", "Survive fall that would have otherwise be fatal without Fall Dampeners") { - russian("Выживите после падения, которое было бы фатальным без Поглотителей Инерции") + russian("Выживите после падения, которое было бы фатальным без поглотителей инерции") }, frameType = FrameType.GOAL ) @@ -291,10 +291,10 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(Items.SKELETON_SKULL), title = translation.add("ender_teleport_fall_death", "Navigation Error") { - russian("Ошибка Навигации") + russian("Ошибка навигации") }, description = translation.add("ender_teleport_fall_death.desc", "Fall to your demise moments after Teleporting as Android") { - russian("Разбейтесь насмерть через мгновения после телепортации за Андроида") + russian("Разбейтесь насмерть через мгновения после телепортации за андроида") }, frameType = FrameType.GOAL, hidden = true @@ -307,10 +307,10 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(Items.GOLDEN_APPLE), title = translation.add("regen", "Field Repair Done Easy") { - russian("Починка на Ходу - Легко") + russian("Починка на ходу - легко") }, description = translation.add("regen.desc", "Research Nanobots Regeneration as Android") { - russian("Исследуйте Регенерацию Наноботов за Андроида") + russian("Исследуйте регенерацию наноботов за андроида") }, ) .addCriterion("regen0", AndroidResearchTrigger.Instance(modLocation(MNames.NANOBOTS_REGENERATION_1))) @@ -321,10 +321,10 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(Items.ENCHANTED_GOLDEN_APPLE), title = translation.add("regen_all", "Field Repair Done Effortless") { - russian("Починка на Ходу - Без Усилий") + russian("Починка на ходу - без усилий") }, description = translation.add("regen_all.desc", "Max out Nanobots Regeneration research") { - russian("Полностью исследуйте Регенерацию Наноботов за Андроида") + russian("Полностью исследуйте регенерацию наноботов за андроида") }, frameType = FrameType.GOAL, ) @@ -339,10 +339,10 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(MItems.ANDROID_STATION), title = translation.add("research_all", "Mecha-Agnomination") { - russian("Меха-Зумие") + russian("Меха-зумие") }, description = translation.add("research_all.desc", "Research everything as Android (that don't block or get blocked by any other research)") { - russian("Исследуйте все технологии за Андроида (которые не блокируют и не блокируются другими технологиями)") + russian("Исследуйте все технологии за андроида (которые не блокируют и не блокируются другими технологиями)") }, frameType = FrameType.CHALLENGE ) @@ -361,10 +361,10 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(Items.PISTON), title = translation.add("shockwave", "Supersonic Landing") { - russian("Сверхзвуковое Приземление") + russian("Сверхзвуковое приземление") }, description = translation.add("shockwave.desc", "Make a Shockwave upon landing") { - russian("Вызовите Ударную Волну при приземлении") + russian("Вызовите ударную волну при приземлении") }, ) .addCriterion("shockwave", ShockwaveTrigger.Instance) @@ -375,10 +375,10 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(Items.WARDEN_SPAWN_EGG), title = translation.add("shockwave_warden", "Music to their Ears") { - russian("Музыка для их Ушей") + russian("Музыка для их ушей") }, description = translation.add("shockwave_warden.desc", "Hurt Warden using Shockwave ability") { - russian("Нанесите Хранителю урон используя Ударную Волну") + russian("Нанесите хранителю урон используя ударную волну") }, frameType = FrameType.GOAL ) @@ -390,10 +390,10 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(Items.WITHER_SKELETON_SKULL), title = translation.add("wither", "Not Quite Alive, Not Quite Undead") { - russian("Ни Живой, Ни Мёртвый") + russian("Ни живой, ни мёртвый") }, description = translation.add("wither.desc", "Defeat The Wither as Android. The Wither was surely confused over kind of thing you are") { - russian("Победите Иссушителя будучи Андроидом. Наверняка Иссушитель был ошеломлён таким раскладом дел") + russian("Победите Иссушителя будучи андроидом. Наверняка Иссушитель был ошеломлён таким раскладом дел") }, frameType = FrameType.GOAL, hidden = true @@ -408,10 +408,10 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(Items.TURTLE_SPAWN_EGG), title = translation.add("travel_underwater", "Underwater Walk") { - russian("Подводная Прогулка") + russian("Подводная прогулка") }, description = translation.add("travel_underwater.desc", "Travel at least 200 meters underwater as Android without Air Bags research. This reminds us of someone...") { - russian("Преодолейте как минимум 200 метров под водой будучи Андроидом без исследования Воздушных Мешков. Кого-то это нам напоминает...") + russian("Преодолейте как минимум 200 метров под водой будучи андроидом без исследования воздушных мешков. Кого-то это нам напоминает...") }, frameType = FrameType.GOAL, hidden = true @@ -424,10 +424,10 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(Items.TURTLE_SPAWN_EGG), title = translation.add("travel_underwater2", "Underwater Travel") { - russian("Подводная Прогулка") + russian("Подводная прогулка") }, description = translation.add("travel_underwater2.desc", "Travel at least 1046 meters underwater as Android without Air Bags research, like someone else did so") { - russian("Преодолейте как минимум 1046 метров под водой будучи Андроидом без исследования Воздушных Мешков, прям как тот, кто так однажды так и сделал") + russian("Преодолейте как минимум 1046 метров под водой будучи андроидом без исследования воздушных мешков, прям как тот, кто так однажды так и сделал") }, frameType = FrameType.CHALLENGE, hidden = true @@ -440,10 +440,10 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(Items.PRISMARINE_CRYSTALS), title = translation.add("elder_guardian", "Drowned, but Still Determined") { - russian("Затонувший, но Всё Ещё Целеустремлённый") + russian("Затонувший, но всё ещё целеустремлённый") }, description = translation.add("elder_guardian.desc", "Slay Elder Guardian as Android without Air Bags researched") { - russian("Победите Древнего Стража будучи Андроидом без исследования Воздушных Мешков") + russian("Победите Древнего стража будучи андроидом без исследования воздушных мешков") }, frameType = FrameType.CHALLENGE, hidden = true diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt index 2dcb1d3be..b50ef7bb0 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt @@ -32,7 +32,7 @@ fun addMachineAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(MItems.CHEMICAL_GENERATOR), title = translation.add("root", "Tritanium Empowered Machinery") { - russian("Тританово Запитанные Механизмы") + russian("Тританово запитанные механизмы") }, description = translation.add("root.desc", "Do not drop in anything if you want the latter preserved intact") { russian("Не роняйте ничего внутрь если хотите чтоб последнее осталось таким, какое оно есть") @@ -51,10 +51,10 @@ fun addMachineAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(MItems.CHEMICAL_GENERATOR), title = translation.add("chemical_generator", "Burning the Organics") { - russian("Сжигание Органики") + russian("Сжигание органики") }, description = translation.add("chemical_generator.desc", "Craft a Chemical Generator, better to put it outside") { - russian("Создайте Химический Генератор. Лучше установить его снаружи") + russian("Создайте химический генератор. Лучше установить его снаружи") }, ) .addCriterion("has_machine", criterion(MItems.CHEMICAL_GENERATOR)) @@ -65,10 +65,10 @@ fun addMachineAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(MItems.PLATE_PRESS), title = translation.add("plate_press", "Bending the Material") { - russian("Раскатка Металла") + russian("Раскатка металла") }, description = translation.add("plate_press.desc", "Craft a Plate Press, avoid having limbs inside at all times") { - russian("Создайте Пресс Пластин, не суйте свои или чужие конечности внутрь") + russian("Создайте пресс пластин, не суйте свои или чужие конечности внутрь") }, ) .addCriterion("has_machine", criterion(MItems.PLATE_PRESS)) @@ -76,26 +76,26 @@ fun addMachineAdvancements(serializer: Consumer, existingFileHelper val entries = listOf( CraftEntry(MItems.MATTER_SCANNER, "Scanning Things that Matter", - russianName = "Сканируем Вещи которые Материальны"), + russianName = "Сканируем вещи которые материальны"), CraftEntry(MItems.PATTERN_STORAGE, "Digital Knowledge Library", - russianName = "Цифровая Библиотека Знаний"), + russianName = "Цифровая библиотека знаний"), CraftEntry(MItems.MATTER_DECOMPOSER, "Decaying the Atoms", "Keep your limbs outside of the working chamber at all times", - russianName = "Разлагаем Атомы", russianSuffix = "Во всех ситуациях держите свои конечности вне рабочей камеры"), + russianName = "Разлагаем атомы", russianSuffix = "Во всех ситуациях держите свои конечности вне рабочей камеры"), CraftEntry(MItems.MATTER_PANEL, "Indexing the Library", - russianName = "Индексируем Библиотеку"), + russianName = "Индексируем библиотеку"), CraftEntry(MItems.MATTER_REPLICATOR, "Local Bakery", "Now let's bake some perfect bread", - russianName = "Местная Выпечка", russianSuffix = "А теперь давайте выпечем немного идеального хлеба"), + russianName = "Местная выпечка", russianSuffix = "А теперь давайте выпечем немного идеального хлеба"), CraftEntry(MItems.MATTER_BOTTLER, "Transfusing Pure Matter", "For those who loved to play with water in their childhood", - russianName = "Переливаем Чистую Материю", russianSuffix = "Для тех, кто любил играться в воде в детстве"), + russianName = "Переливаем чистую материю", russianSuffix = "Для тех, кто любил играться в воде в детстве"), CraftEntry(MItems.MATTER_RECYCLER, "Refine and Redefine", "This is what waste recycling should look like", - russianName = "Переработка и Перегонка", russianSuffix = "Вот он, пик переработки отходов"), + russianName = "Переработка и перегонка", russianSuffix = "Вот он, пик переработки отходов"), CraftEntry(MItems.MATTER_CAPACITOR_BANK, "Modular Matter Tank", - russianName = "Модульный Бак Материи"), + russianName = "Модульный бак материи"), CraftEntry(MItems.ENERGY_COUNTER, "Visualize Power Burn", - russianName = "Визуализация Сжигания Энергии"), + russianName = "Визуализация сжигания энергии"), CraftEntry(MItems.BATTERY_BANK, "Batteries Not Included", "By all means avoid the urge to hammer incompatible batteries into the power bus.", - russianName = "Батарейки в Комплект не Входят", russianSuffix = "Пожалуйста, воздержитесь от вбивания кувалдой несовместимых батарей в энергетическую шину."), + russianName = "Батарейки в комплект не входят", russianSuffix = "Пожалуйста, воздержитесь от вбивания кувалдой несовместимых батарей в энергетическую шину."), ) val built = mutableMapOf() From 69077d97d28ec31bc2d29918d46c8f4ad73613b1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Feb 2023 20:45:26 +0700 Subject: [PATCH 0245/1199] More correct wording --- .../dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt index ae0a8461d..482b73656 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt @@ -525,7 +525,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist russian("Пей таблетки") }, description = translation.add("all_pills.desc", "Find all possible pill types") { - russian("Найдите все возможные варианты пилюль") + russian("Найдите всевозможные варианты пилюль") }, frameType = FrameType.CHALLENGE, hidden = true From 13840d3dcce3da847b724ffaa2c0ee9a14e2f30d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Feb 2023 21:14:51 +0700 Subject: [PATCH 0246/1199] forgot count --- .../ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt index 555385af4..32f1f15c6 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt @@ -338,7 +338,7 @@ fun addDecorativesRecipes(provider: MatteryRecipeProvider, consumer: Consumer Date: Sat, 25 Feb 2023 21:38:10 +0700 Subject: [PATCH 0247/1199] kot --- .../mc/otm/datagen/items/ItemModels.kt | 3 ++- .../textures/item/component/tritanium_nugget.png | Bin 0 -> 2437 bytes .../textures/item/tritanium_shears.png | Bin 0 -> 2437 bytes .../textures/item/tritanium_shield.png | Bin 0 -> 2437 bytes 4 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/component/tritanium_nugget.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_shears.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_shield.png diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index bf6cff3f1..76f7b8c00 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -74,11 +74,12 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.component(MItems.TRITANIUM_DUST) provider.component(MItems.TRITANIUM_INGOT) + provider.component(MItems.TRITANIUM_NUGGET) provider.resource(MItems.TRITANIUM_ORE_CLUMP) provider.generated(MItems.EXOPACK_PROBE) - //provider.handheld(MItems.TRITANIUM_TOOLS) + provider.handheld(MItems.TRITANIUM_TOOLS) provider.generated(MItems.TRITANIUM_ARMOR) provider.generatedTiered(MItems.BATTERIES, "battery_tier") diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/component/tritanium_nugget.png b/src/main/resources/assets/overdrive_that_matters/textures/item/component/tritanium_nugget.png new file mode 100644 index 0000000000000000000000000000000000000000..d36635b4d3d72a5dd2644f4bd55341d6da866d5b GIT binary patch literal 2437 zcmV;033~R4P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGizyJUazyWI3i3tDz2^vX6K~zXfC00vs zB-ItZ&w5u^_1o=s`!Sv|69|G4pg@8KG$8_{NP$K2WB3W#Wt~+vStU{yStQB^wh=-M z5Qc#Za?}}@2Yz%Upb|=-M)42x#xW6JKs6zYd`g%BkkQV~@VUGD8nrn9+annhN)EiW(2EG_GrV4IL;%VOge-yd}} zwG3gfM_+$F8MoJqSy@Dz&1SMQ$;)DXd3CXlV4X2m*L9xfTI;%0jFO%qkM?#rso;&@ zaP_B99&}1txdV{{Q12<@|Q^k6nph&VO-yL_tHqK;OD!6<$JynX}QA)ve z{Kie3Qs3hDUc9@yoKs5tRtsAyrE5(o8mBM@BST?Twv<+sO=GpoAcxSKM>Bn&lC_erC;cPZ1gx0$84G&PlV@rMa_I{q1Cl}|sCWdKH zgjrXDQ&)De+fcU0*AhM08RNhJ657s%p7GJ_uHSJiD}fmjbxMp?CY}C!X6r zzqo*#|NPe{i**7#di~zz^#aI%MNKvcX$QgS+1czGnG>pJwrK(%%dv|hkD`>(8UWQb z18$3D#0_J5a{A@h|6#X|?#yPhaL_Ug>)G^d9Y>?_7{C`rAq3JuaEda;MO~w?|$=+WBb4WDE;N{|45T`vs`Qq z22q-TKsVqc6Sbh^rRNSgQ?Bdlx=P}>-y0%-Ntz)aHSUrOuD~bYX-J`USr&Ok89RA) z+V2mer2OG@9_MP6Wz+z}3axU+2y8V`C=F1mWPR^wukY}_Z#ky0ZLwG^OvBW)rh+P6 zX^mK#XiBX(Qe(NLuG!(8BV;nlvX4Lh1bjDz>~#lmyn!24Rk=18Xb3_*+t?e1MxCpC zWis9C`mPNUQqDB5D^fS6!I3P>@CC#JWNBHLoG{<_vHHzdU-_QdYdN9glz^!yuU9GR zF3sZg^}>?+&i=sl`FuVbj|K-j+oH&1oj4K>Da$krA@RX}R8?Koy3|Mts??H+6e$pM9!x)eb_(b#31_Obem}Xi)-E8ohSwjn`hN^JJ?(^aAhU7hkkOKlJ_W?Ll5D z$8;15x~hf-SBt;uM( zf3S1+_U_4dPx^z7!C9Fld*kt_-w{;Dn^M)939~>MH*5h)X;_0!H}J!gr%y*)!|k@eGu$2wyOw1FY2PuC0+VY}6oJe4wnmeF&l0jG z8EV?GP2|j$@^EJ&DdBIu`dpQ4%5<%C9(aDQ9TZg!v5Z$s!Z=cVYj^A2Uq0|WGs|NX z-ST1%l--t_W(BgDmo(25RJX{IEYE;yryW{Ub6vJW4{`8=frK-b$#kU*0m~!{mxtW-vDO}Q*2gi%dotbpBDLioql_IIlWq4EtZ^==^w7O|Q88^LF@8ID1qdRv8-9ayC zyJ$zGoQy{=-+M7hV~AR&Rd2MtxLo9E5rn;(K=-Azd%fZA)zzZi^7p#I!4`nwd6cAS z8U$_A^!R%Zei62O!?HD_Uf92N=jgRpUfJE7kUV>E|BZJaybXL&{~#;k@I2@7SKm06 z`|ab$I|qkxlAs&tJYz&nM*V)<4m`^g%yYpWYTK@5+x(q3f9CprcWV%KL7Yy|>h$~F z@v!&uPhXI%MwY?=jQ4~vQK!h{_s37sBlq|APk(rFc(`3>o4}?A{a~^+2t0v`0TodT z1=_T(q@eu4&+joPiPG><8YU`ILD$O?O)*)=j_qK{5CZ=edBQ0lPbL%`w=KtDtIG@c zJ|47pCnKhE%ano>$7+hfuo~lp5oTKgWx@`gS&4lmzL8sk@IRjOOHm6BxT4q@kjB3@iKZXGhfneCd zc#y;y3e8ZN21LL8@Et_g1k-@iyoYtjA=)LX%WQdu1;&Xuf*KO!NofV%TBg%93v6Z* z4U-8e3=?OYMO}l&P%bKMX}C;PSjTWCkm{RkH;svabHMUuDDp5;+F{V^5KB;i2@R`@ zyi6)xz!eN1*wf?>)^8r1!W2Sivk2vHOx&zvFl(l0+;FplF-!)G;tRSardmH7gkFeR ztBL~Y!BKo*9o{tiDTO(-bfgW_YzFDh(03zjVSoWUun>6D)!-O~><4V*mu8Px#1ZP1_K>z@;j|==^1poj532;bRa{vGizyJUazyWI3i3tDz2^vX6K~zXfC00vs zB-ItZ&w5u^_1o=s`!Sv|69|G4pg@8KG$8_{NP$K2WB3W#Wt~+vStU{yStQB^wh=-M z5Qc#Za?}}@2Yz%Upb|=-M)42x#xW6JKs6zYd`g%BkkQV~@VUGD8nrn9+annhN)EiW(2EG_GrV4IL;%VOge-yd}} zwG3gfM_+$F8MoJqSy@Dz&1SMQ$;)DXd3CXlV4X2m*L9xfTI;%0jFO%qkM?#rso;&@ zaP_B99&}1txdV{{Q12<@|Q^k6nph&VO-yL_tHqK;OD!6<$JynX}QA)ve z{Kie3Qs3hDUc9@yoKs5tRtsAyrE5(o8mBM@BST?Twv<+sO=GpoAcxSKM>Bn&lC_erC;cPZ1gx0$84G&PlV@rMa_I{q1Cl}|sCWdKH zgjrXDQ&)De+fcU0*AhM08RNhJ657s%p7GJ_uHSJiD}fmjbxMp?CY}C!X6r zzqo*#|NPe{i**7#di~zz^#aI%MNKvcX$QgS+1czGnG>pJwrK(%%dv|hkD`>(8UWQb z18$3D#0_J5a{A@h|6#X|?#yPhaL_Ug>)G^d9Y>?_7{C`rAq3JuaEda;MO~w?|$=+WBb4WDE;N{|45T`vs`Qq z22q-TKsVqc6Sbh^rRNSgQ?Bdlx=P}>-y0%-Ntz)aHSUrOuD~bYX-J`USr&Ok89RA) z+V2mer2OG@9_MP6Wz+z}3axU+2y8V`C=F1mWPR^wukY}_Z#ky0ZLwG^OvBW)rh+P6 zX^mK#XiBX(Qe(NLuG!(8BV;nlvX4Lh1bjDz>~#lmyn!24Rk=18Xb3_*+t?e1MxCpC zWis9C`mPNUQqDB5D^fS6!I3P>@CC#JWNBHLoG{<_vHHzdU-_QdYdN9glz^!yuU9GR zF3sZg^}>?+&i=sl`FuVbj|K-j+oH&1oj4K>Da$krA@RX}R8?Koy3|Mts??H+6e$pM9!x)eb_(b#31_Obem}Xi)-E8ohSwjn`hN^JJ?(^aAhU7hkkOKlJ_W?Ll5D z$8;15x~hf-SBt;uM( zf3S1+_U_4dPx^z7!C9Fld*kt_-w{;Dn^M)939~>MH*5h)X;_0!H}J!gr%y*)!|k@eGu$2wyOw1FY2PuC0+VY}6oJe4wnmeF&l0jG z8EV?GP2|j$@^EJ&DdBIu`dpQ4%5<%C9(aDQ9TZg!v5Z$s!Z=cVYj^A2Uq0|WGs|NX z-ST1%l--t_W(BgDmo(25RJX{IEYE;yryW{Ub6vJW4{`8=frK-b$#kU*0m~!{mxtW-vDO}Q*2gi%dotbpBDLioql_IIlWq4EtZ^==^w7O|Q88^LF@8ID1qdRv8-9ayC zyJ$zGoQy{=-+M7hV~AR&Rd2MtxLo9E5rn;(K=-Azd%fZA)zzZi^7p#I!4`nwd6cAS z8U$_A^!R%Zei62O!?HD_Uf92N=jgRpUfJE7kUV>E|BZJaybXL&{~#;k@I2@7SKm06 z`|ab$I|qkxlAs&tJYz&nM*V)<4m`^g%yYpWYTK@5+x(q3f9CprcWV%KL7Yy|>h$~F z@v!&uPhXI%MwY?=jQ4~vQK!h{_s37sBlq|APk(rFc(`3>o4}?A{a~^+2t0v`0TodT z1=_T(q@eu4&+joPiPG><8YU`ILD$O?O)*)=j_qK{5CZ=edBQ0lPbL%`w=KtDtIG@c zJ|47pCnKhE%ano>$7+hfuo~lp5oTKgWx@`gS&4lmzL8sk@IRjOOHm6BxT4q@kjB3@iKZXGhfneCd zc#y;y3e8ZN21LL8@Et_g1k-@iyoYtjA=)LX%WQdu1;&Xuf*KO!NofV%TBg%93v6Z* z4U-8e3=?OYMO}l&P%bKMX}C;PSjTWCkm{RkH;svabHMUuDDp5;+F{V^5KB;i2@R`@ zyi6)xz!eN1*wf?>)^8r1!W2Sivk2vHOx&zvFl(l0+;FplF-!)G;tRSardmH7gkFeR ztBL~Y!BKo*9o{tiDTO(-bfgW_YzFDh(03zjVSoWUun>6D)!-O~><4V*mu8Px#1ZP1_K>z@;j|==^1poj532;bRa{vGizyJUazyWI3i3tDz2^vX6K~zXfC00vs zB-ItZ&w5u^_1o=s`!Sv|69|G4pg@8KG$8_{NP$K2WB3W#Wt~+vStU{yStQB^wh=-M z5Qc#Za?}}@2Yz%Upb|=-M)42x#xW6JKs6zYd`g%BkkQV~@VUGD8nrn9+annhN)EiW(2EG_GrV4IL;%VOge-yd}} zwG3gfM_+$F8MoJqSy@Dz&1SMQ$;)DXd3CXlV4X2m*L9xfTI;%0jFO%qkM?#rso;&@ zaP_B99&}1txdV{{Q12<@|Q^k6nph&VO-yL_tHqK;OD!6<$JynX}QA)ve z{Kie3Qs3hDUc9@yoKs5tRtsAyrE5(o8mBM@BST?Twv<+sO=GpoAcxSKM>Bn&lC_erC;cPZ1gx0$84G&PlV@rMa_I{q1Cl}|sCWdKH zgjrXDQ&)De+fcU0*AhM08RNhJ657s%p7GJ_uHSJiD}fmjbxMp?CY}C!X6r zzqo*#|NPe{i**7#di~zz^#aI%MNKvcX$QgS+1czGnG>pJwrK(%%dv|hkD`>(8UWQb z18$3D#0_J5a{A@h|6#X|?#yPhaL_Ug>)G^d9Y>?_7{C`rAq3JuaEda;MO~w?|$=+WBb4WDE;N{|45T`vs`Qq z22q-TKsVqc6Sbh^rRNSgQ?Bdlx=P}>-y0%-Ntz)aHSUrOuD~bYX-J`USr&Ok89RA) z+V2mer2OG@9_MP6Wz+z}3axU+2y8V`C=F1mWPR^wukY}_Z#ky0ZLwG^OvBW)rh+P6 zX^mK#XiBX(Qe(NLuG!(8BV;nlvX4Lh1bjDz>~#lmyn!24Rk=18Xb3_*+t?e1MxCpC zWis9C`mPNUQqDB5D^fS6!I3P>@CC#JWNBHLoG{<_vHHzdU-_QdYdN9glz^!yuU9GR zF3sZg^}>?+&i=sl`FuVbj|K-j+oH&1oj4K>Da$krA@RX}R8?Koy3|Mts??H+6e$pM9!x)eb_(b#31_Obem}Xi)-E8ohSwjn`hN^JJ?(^aAhU7hkkOKlJ_W?Ll5D z$8;15x~hf-SBt;uM( zf3S1+_U_4dPx^z7!C9Fld*kt_-w{;Dn^M)939~>MH*5h)X;_0!H}J!gr%y*)!|k@eGu$2wyOw1FY2PuC0+VY}6oJe4wnmeF&l0jG z8EV?GP2|j$@^EJ&DdBIu`dpQ4%5<%C9(aDQ9TZg!v5Z$s!Z=cVYj^A2Uq0|WGs|NX z-ST1%l--t_W(BgDmo(25RJX{IEYE;yryW{Ub6vJW4{`8=frK-b$#kU*0m~!{mxtW-vDO}Q*2gi%dotbpBDLioql_IIlWq4EtZ^==^w7O|Q88^LF@8ID1qdRv8-9ayC zyJ$zGoQy{=-+M7hV~AR&Rd2MtxLo9E5rn;(K=-Azd%fZA)zzZi^7p#I!4`nwd6cAS z8U$_A^!R%Zei62O!?HD_Uf92N=jgRpUfJE7kUV>E|BZJaybXL&{~#;k@I2@7SKm06 z`|ab$I|qkxlAs&tJYz&nM*V)<4m`^g%yYpWYTK@5+x(q3f9CprcWV%KL7Yy|>h$~F z@v!&uPhXI%MwY?=jQ4~vQK!h{_s37sBlq|APk(rFc(`3>o4}?A{a~^+2t0v`0TodT z1=_T(q@eu4&+joPiPG><8YU`ILD$O?O)*)=j_qK{5CZ=edBQ0lPbL%`w=KtDtIG@c zJ|47pCnKhE%ano>$7+hfuo~lp5oTKgWx@`gS&4lmzL8sk@IRjOOHm6BxT4q@kjB3@iKZXGhfneCd zc#y;y3e8ZN21LL8@Et_g1k-@iyoYtjA=)LX%WQdu1;&Xuf*KO!NofV%TBg%93v6Z* z4U-8e3=?OYMO}l&P%bKMX}C;PSjTWCkm{RkH;svabHMUuDDp5;+F{V^5KB;i2@R`@ zyi6)xz!eN1*wf?>)^8r1!W2Sivk2vHOx&zvFl(l0+;FplF-!)G;tRSardmH7gkFeR ztBL~Y!BKo*9o{tiDTO(-bfgW_YzFDh(03zjVSoWUun>6D)!-O~><4V*mu8 Date: Sat, 25 Feb 2023 22:00:40 +0700 Subject: [PATCH 0248/1199] Energy servo item and energy configurations --- .../entity/tech/EnergyServoBlockEntity.kt | 63 ++++++------------- .../client/screen/tech/EnergyServoScreen.kt | 2 +- .../mc/otm/container/HandlerFilter.kt | 22 +++++++ .../mc/otm/menu/tech/EnergyServoMenu.kt | 34 +++++----- 4 files changed, 60 insertions(+), 61 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt index 8936ba1d9..a179552fd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt @@ -1,8 +1,6 @@ package ru.dbotthepony.mc.otm.block.entity.tech import net.minecraft.core.BlockPos -import net.minecraft.network.chat.Component -import net.minecraft.world.Container import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu @@ -22,36 +20,15 @@ import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.menu.tech.EnergyServoMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities -import ru.dbotthepony.mc.otm.registry.MBlocks class EnergyServoBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.ENERGY_SERVO, blockPos, blockState) { - override val defaultDisplayName: Component - get() = MBlocks.ENERGY_SERVO.name - - val container = MatteryContainer(this::setChangedLight, 2).also(::addDroppableContainer) - - val itemHandler = container.handler(object : HandlerFilter { - override fun canInsert(slot: Int, stack: ItemStack): Boolean { - return when (slot) { - SLOT_DISCHARGE -> stack.isEmpty || stack.energy?.let { it.extractEnergy(Int.MAX_VALUE, true) > 0 } ?: false - SLOT_CHARGE -> stack.isEmpty || stack.energy?.let { it.receiveEnergy(Int.MAX_VALUE, true) > 0 } ?: false - else -> false - } - } - - override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { - return when (slot) { - SLOT_DISCHARGE -> stack.isEmpty || stack.energy?.let { it.extractEnergy(Int.MAX_VALUE, true) <= 0 } ?: false - SLOT_CHARGE -> stack.isEmpty || stack.energy?.let { it.receiveEnergy(Int.MAX_VALUE, true) <= 0 } ?: false - else -> false - } - } - }) + val discharge = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) + val charge = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) val energy = object : IMatteryEnergyStorage { override val energyFlow: FlowDirection get() { - val discharge = container[SLOT_DISCHARGE].energy - val charge = container[SLOT_CHARGE].energy + val discharge = discharge[0].energy + val charge = charge[0].energy return FlowDirection.of(input = charge?.canReceive() ?: false, output = discharge?.canExtract() ?: false) } @@ -59,34 +36,39 @@ class EnergyServoBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte if (redstoneControl.isBlockedByRedstone) return Decimal.ZERO - return container[SLOT_DISCHARGE].energy?.extractEnergy(howMuch, simulate) ?: Decimal.ZERO + return discharge[0].energy?.extractEnergy(howMuch, simulate) ?: Decimal.ZERO } override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { if (redstoneControl.isBlockedByRedstone) return Decimal.ZERO - return container[SLOT_CHARGE].energy?.receiveEnergy(howMuch, simulate) ?: Decimal.ZERO + return charge[0].energy?.receiveEnergy(howMuch, simulate) ?: Decimal.ZERO } override val canSetBatteryLevel: Boolean - get() = container[SLOT_CHARGE].energy?.canSetBatteryMattery ?: container[SLOT_DISCHARGE].energy?.canSetBatteryMattery ?: false + get() = charge[0].energy?.canSetBatteryMattery ?: discharge[0].energy?.canSetBatteryMattery ?: false override var batteryLevel: Decimal - get() = container[SLOT_CHARGE].energy?.energyStoredMattery ?: container[SLOT_DISCHARGE].energy?.energyStoredMattery ?: Decimal.ZERO + get() = charge[0].energy?.energyStoredMattery ?: discharge[0].energy?.energyStoredMattery ?: Decimal.ZERO set(value) { - val energy = container[SLOT_CHARGE].energy ?: container[SLOT_DISCHARGE].energy ?: throw UnsupportedOperationException("No item in slots") + val energy = charge[0].energy ?: discharge[0].energy ?: throw UnsupportedOperationException("No item in slots") energy.energyStoredMattery = value } override val maxBatteryLevel: Decimal - get() = container[SLOT_CHARGE].energy?.maxEnergyStoredMattery ?: container[SLOT_DISCHARGE].energy?.maxEnergyStoredMattery ?: Decimal.ZERO + get() = charge[0].energy?.maxEnergyStoredMattery ?: discharge[0].energy?.maxEnergyStoredMattery ?: Decimal.ZERO } + val energyConfig = ConfigurableEnergy(energy, possibleModes = FlowDirection.BI_DIRECTIONAL) + val itemConfig = ConfigurableItemHandler( + input = charge.handler(HandlerFilter.OnlyIn.and(HandlerFilter.Chargeable)), + output = discharge.handler(HandlerFilter.OnlyOut.and(HandlerFilter.Dischargeable)) + ) + init { - exposeEnergyGlobally(energy) - exposeItemsGlobally(itemHandler) - savetable(::container, INVENTORY_KEY) + savetables.stateful(::charge) + savetables.stateful(::discharge) } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { @@ -99,8 +81,8 @@ class EnergyServoBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte if (redstoneControl.isBlockedByRedstone) return - val charge = container[SLOT_CHARGE] - val discharge = container[SLOT_DISCHARGE] + val charge = charge[0] + val discharge = discharge[0] if (!charge.isEmpty && !discharge.isEmpty) { val chargeEnergy = charge.energy ?: return @@ -121,9 +103,4 @@ class EnergyServoBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte } } } - - companion object { - const val SLOT_DISCHARGE = 0 - const val SLOT_CHARGE = 1 - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt index a33f5d9e6..159c496cb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt @@ -62,7 +62,7 @@ class EnergyServoScreen(menu: EnergyServoMenu, inventory: Inventory, title: Comp it.dockRight } - makeDeviceControls(this, frame, redstone = menu.redstone) + makeDeviceControls(this, frame, redstone = menu.redstone, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt index 2089f618e..3dd2450ba 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt @@ -16,6 +16,28 @@ interface HandlerFilter { fun preInsert(slot: Int, stack: ItemStack, simulate: Boolean) {} fun preExtract(slot: Int, amount: Int, simulate: Boolean) {} + fun and(other: HandlerFilter): HandlerFilter { + return object : HandlerFilter { + override fun canInsert(slot: Int, stack: ItemStack): Boolean { + return this@HandlerFilter.canInsert(slot, stack) && other.canInsert(slot, stack) + } + + override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { + return this@HandlerFilter.canExtract(slot, amount, stack) && other.canExtract(slot, amount, stack) + } + + override fun preInsert(slot: Int, stack: ItemStack, simulate: Boolean) { + this@HandlerFilter.preInsert(slot, stack, simulate) + other.preInsert(slot, stack, simulate) + } + + override fun preExtract(slot: Int, amount: Int, simulate: Boolean) { + this@HandlerFilter.preExtract(slot, amount, simulate) + other.preExtract(slot, amount, simulate) + } + } + } + object OnlyIn : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { return true diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt index cba9da535..04b0e8892 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt @@ -10,7 +10,9 @@ import ru.dbotthepony.mc.otm.block.entity.tech.EnergyServoBlockEntity import ru.dbotthepony.mc.otm.capability.energy import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -19,34 +21,32 @@ class EnergyServoMenu @JvmOverloads constructor( inventory: Inventory, tile: EnergyServoBlockEntity? = null ) : MatteryMenu(MMenus.ENERGY_SERVO, p_38852_, inventory, tile) { - val dischargeSlot: MatterySlot - val chargeSlot: MatterySlot + val dischargeSlot = object : MatterySlot(tile?.discharge ?: SimpleContainer(1), 0) { + override fun mayPlace(itemStack: ItemStack): Boolean { + return super.mayPlace(itemStack) && (itemStack.energy?.canExtract() ?: false) + } + } + + val chargeSlot = object : MatterySlot(tile?.charge ?: SimpleContainer(1), 0) { + override fun mayPlace(itemStack: ItemStack): Boolean { + return super.mayPlace(itemStack) && (itemStack.energy?.canReceive() ?: false) + } + } val powerGauge = LevelGaugeWidget(this, tile?.energy) - + val itemConfig = ItemHandlerPlayerInput(this) + val energyConfig = EnergyPlayerInput(this, true, true) val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java) init { if (tile != null) { redstone.with(tile.redstoneControl::redstoneSetting) + itemConfig.configure(tile.itemConfig) + energyConfig.configure(tile.energyConfig) } } init { - val container = tile?.container ?: SimpleContainer(2) - - dischargeSlot = object : MatterySlot(container, EnergyServoBlockEntity.SLOT_DISCHARGE) { - override fun mayPlace(itemStack: ItemStack): Boolean { - return super.mayPlace(itemStack) && (itemStack.energy?.canExtract() ?: false) - } - } - - chargeSlot = object : MatterySlot(container, EnergyServoBlockEntity.SLOT_CHARGE) { - override fun mayPlace(itemStack: ItemStack): Boolean { - return super.mayPlace(itemStack) && (itemStack.energy?.canReceive() ?: false) - } - } - addSlot(dischargeSlot) addSlot(chargeSlot) addInventorySlots() From de69829cbcbaa52db1a3c8d498cfdca3c5c6ec92 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Feb 2023 22:06:34 +0700 Subject: [PATCH 0249/1199] Oh my god --- .../ru/dbotthepony/mc/otm/block/MatteryBlock.kt | 15 ++++++++++----- .../mc/otm/block/entity/MatteryBlockEntity.kt | 5 +++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt index f0da2a116..dd0cb5212 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt @@ -33,6 +33,7 @@ import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.math.component1 import ru.dbotthepony.mc.otm.core.math.component2 import ru.dbotthepony.mc.otm.core.math.component3 +import ru.dbotthepony.mc.otm.once fun Block.getShapeForEachState(properties: List>, fn: (BlockState) -> VoxelShape): Map { val builder = ImmutableMap.Builder() @@ -174,13 +175,17 @@ abstract class MatteryBlock @JvmOverloads constructor( super.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston) if (this is EntityBlock && !level.isClientSide) { - val tile = level.getBlockEntity(pos) + val tile = level.getBlockEntity(pos) ?: return - if (tile is IRedstoneControlled) - tile.redstoneControl.redstoneSignal = level.getBestNeighborSignal(pos) + level.once { + if (!tile.isRemoved) { + if (tile is IRedstoneControlled) + tile.redstoneControl.redstoneSignal = level.getBestNeighborSignal(pos) - if (tile is MatteryBlockEntity && SERVER_IS_LIVE) - tile.neighborChanged(neighbour, neighbourPos, movedByPiston) + if (tile is MatteryBlockEntity && SERVER_IS_LIVE) + tile.neighborChanged(neighbour, neighbourPos, movedByPiston) + } + } } } 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 20294fce6..cc484d733 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 @@ -238,10 +238,11 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc private fun updateTracked(capability: Capability<*>) { if (isRemoved || !SERVER_IS_LIVE) return val dir = blockRotation.side2Dir(side) + val targetPos = blockPos + dir.normal val chunk = level ?.chunkSource - ?.getChunkNow(SectionPos.blockToSectionCoord(blockPos.x), SectionPos.blockToSectionCoord(blockPos.z)) + ?.getChunkNow(SectionPos.blockToSectionCoord(targetPos.x), SectionPos.blockToSectionCoord(targetPos.z)) if (chunk == null) { subscriptions[capability]!!.unset() @@ -249,7 +250,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc return } - val entity = chunk.getBlockEntity(blockPos + dir.normal) + val entity = chunk.getBlockEntity(targetPos) if (entity == null) { subscriptions[capability]!!.unset() From 5adbcdb7b17d582781f90fd3be422e117d0e5149 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Feb 2023 22:08:15 +0700 Subject: [PATCH 0250/1199] eeey --- src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt index 833203473..65fe3ae74 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt @@ -43,7 +43,7 @@ internal fun IEnergyStorage.receiveEnergy(amount: Decimal, simulate: Boolean): D if (!canReceive()) return Decimal.ZERO - if (amount > Decimal.INT_MAX_VALUE) + if (amount >= Decimal.INT_MAX_VALUE) return Decimal.valueOf(receiveEnergy(Int.MAX_VALUE, simulate)) return Decimal.valueOf(receiveEnergy(amount.toInt(), simulate)) @@ -62,7 +62,7 @@ internal fun IEnergyStorage.extractEnergy(amount: Decimal, simulate: Boolean): D if (!canExtract()) return Decimal.ZERO - if (amount > Decimal.INT_MAX_VALUE) + if (amount >= Decimal.INT_MAX_VALUE) return Decimal.valueOf(extractEnergy(Int.MAX_VALUE, simulate)) return Decimal.valueOf(extractEnergy(amount.toInt(), simulate)) From 2ab3ccdf0251e099c338bcff554a72c4420fbf69 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Feb 2023 22:13:17 +0700 Subject: [PATCH 0251/1199] Add ignoreFlowRestrictions to moveEnergy --- .../otm/block/entity/tech/AndroidStationBlockEntity.kt | 2 +- .../kotlin/ru/dbotthepony/mc/otm/capability/Helpers.kt | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt index 96d029eac..212084307 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt @@ -88,7 +88,7 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : for (ent in level.getEntitiesOfClass(ServerPlayer::class.java, AABB(x, y, z, x + 1.0, y + 2.0, z + 1.0))) { ent.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresentK { if (it.isAndroid) - moveEnergy(energy, it.androidEnergy, amount = energy.batteryLevel, simulate = false) + moveEnergy(energy, it.androidEnergy, amount = energy.batteryLevel, simulate = false, ignoreFlowRestrictions = true) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Helpers.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Helpers.kt index dafd77dfc..1d48ca885 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Helpers.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Helpers.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.capability import net.minecraftforge.energy.IEnergyStorage import net.minecraftforge.items.IItemHandler +import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.core.math.Decimal /** @@ -45,14 +46,14 @@ fun moveBetweenSlots(source: IItemHandler, sourceSlot: Int, destination: IItemHa } @Suppress("name_shadowing") -fun moveEnergy(source: IEnergyStorage, destination: IEnergyStorage, amount: Decimal = Decimal.LONG_MAX_VALUE, simulate: Boolean): Decimal { - val extracted = source.extractEnergy(amount, true) +fun moveEnergy(source: IEnergyStorage, destination: IEnergyStorage, amount: Decimal = Decimal.LONG_MAX_VALUE, simulate: Boolean, ignoreFlowRestrictions: Boolean = false): Decimal { + val extracted = if (ignoreFlowRestrictions && source is IMatteryEnergyStorage) source.extractEnergy(amount, true) else source.extractEnergy(amount, true) if (extracted.isPositive) { val received = destination.receiveEnergy(extracted, true) if (received.isPositive) { - val extracted = source.extractEnergy(received, true) + val extracted = if (ignoreFlowRestrictions && source is IMatteryEnergyStorage) source.extractEnergy(received, true) else source.extractEnergy(received, true) if (extracted.isPositive) { if (simulate) { @@ -60,7 +61,7 @@ fun moveEnergy(source: IEnergyStorage, destination: IEnergyStorage, amount: Deci } val received = destination.receiveEnergy(extracted, false) - return source.extractEnergy(received, false) + return if (ignoreFlowRestrictions && source is IMatteryEnergyStorage) source.extractEnergy(received, false) else source.extractEnergy(received, false) } } } From 3530c60e15ac51321057aea80cf104e3233dbee0 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sat, 25 Feb 2023 20:23:15 +0300 Subject: [PATCH 0252/1199] tags for armors/tools + forge tag appender fix --- .../ru/dbotthepony/mc/otm/datagen/tags/Tags.kt | 14 ++++++++++++++ .../mc/otm/datagen/tags/TagsProvider.kt | 12 ++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index 639958f6b..a2d6469f3 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -88,6 +88,20 @@ fun addTags(tagsProvider: TagsProvider) { tagsProvider.items.appender(MItemTags.TRITANIUM_NUGGETS).add(MItems.TRITANIUM_NUGGET) tagsProvider.items.appender(MItemTags.NUGGETS).add(MItems.TRITANIUM_NUGGET) + tagsProvider.items.forge("armors") + .add("helmets", MItems.TRITANIUM_HELMET) + .add("chestplates", MItems.TRITANIUM_CHESTPLATE) + .add("leggings", MItems.TRITANIUM_PANTS) + .add("boots", MItems.TRITANIUM_BOOTS) + tagsProvider.items.forge("tools") + .add("swords", MItems.TRITANIUM_SWORD) + .add("axes", MItems.TRITANIUM_AXE) + .add("pickaxes", MItems.TRITANIUM_PICKAXE) + .add("shovels", MItems.TRITANIUM_SHOVEL) + .add("hoes", MItems.TRITANIUM_HOE) + .add("shields", MItems.TRITANIUM_SHIELD) + tagsProvider.items.forge("shears").add(MItems.TRITANIUM_SHEARS) + tagsProvider.blocks.appender(BlockTags.STAIRS) .add(MRegistry.FLOOR_TILES_STAIRS.blocks.values) .add(MRegistry.TRITANIUM_STAIRS.allBlocks.values) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt index 3f6c10c52..bc575e784 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt @@ -43,16 +43,16 @@ interface MTagAppender { } interface ForgeTagAppender : MTagAppender { - fun add(key: String, value: T): MTagAppender + fun add(key: String, value: T): ForgeTagAppender fun addSafe(key: String, value: T): Boolean - fun add(key: String, vararg values: T): MTagAppender + fun add(key: String, vararg values: T): ForgeTagAppender fun addSafe(key: String, vararg values: T): Boolean { var any = false for (value in values) any = addSafe(key, value) return any } - fun add(key: String, values: Collection): MTagAppender + fun add(key: String, values: Collection): ForgeTagAppender fun addSafe(key: String, values: Collection): Boolean { var any = false @@ -131,7 +131,7 @@ class TagsProvider( val parent by lazy { appender(ResourceLocation("forge", path)) } return object : ForgeTagAppender { - override fun add(key: String, value: T): MTagAppender { + override fun add(key: String, value: T): ForgeTagAppender { val tag = TagKey.create(registryKey, ResourceLocation("forge", "$path/$key")) if (!getSet(tag).add(value)) { @@ -146,12 +146,12 @@ class TagsProvider( return getSet(tag).add(value) } - override fun add(key: String, vararg values: T): MTagAppender { + override fun add(key: String, vararg values: T): ForgeTagAppender { for (value in values) add(key, value) return this } - override fun add(key: String, values: Collection): MTagAppender { + override fun add(key: String, values: Collection): ForgeTagAppender { for (value in values) add(key, value) return this } From 813e7cda26dcac76cc299f423c5a35376004b5c0 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 26 Feb 2023 16:30:11 +0700 Subject: [PATCH 0253/1199] typo --- .../kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 27778a6d3..83c468494 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -502,12 +502,12 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.MATTER_IO_PORT, "Порт ввода/вывода материи") add(MItems.MATTER_TRANSFORM_MATRIX, "Матрица преобразования материи") add(MItems.ENERGY_BUS, "Шина питания") - add(MItems.ELECTRIC_PARTS, "электрические части") + add(MItems.ELECTRIC_PARTS, "Электрические части") add(MItems.MACHINE_FRAME, "Каркас механизма") - add(MItems.TRITANIUM_PLATE, "тритановая пластина") + add(MItems.TRITANIUM_PLATE, "Тритановая пластина") add(MItems.IRON_PLATE, "Железная пластина") add(MItems.GOLD_PLATE, "Золотая пластина") - add(MItems.COPPER_WIRING, "медная проволока") + add(MItems.COPPER_WIRING, "Медная проволока") add(MItems.GOLD_WIRING, "Золотая проволока") add(MItems.PORTABLE_CONDENSATION_DRIVE_CASING, "Каркас портативного диска конденсации") add(MItems.PORTABLE_DENSE_CONDENSATION_DRIVE_CASING, "Каркас плотного портативного диска конденсации") From a85124224f6ee05dad2e058869a381a70a48630c Mon Sep 17 00:00:00 2001 From: GearShocky Date: Mon, 27 Feb 2023 04:55:52 +0600 Subject: [PATCH 0254/1199] Tritanium shears, no idea where do i put a shield model since it makes a duplicate --- .../textures/item/tritanium_shears.png | Bin 2437 -> 259 bytes .../textures/item/tritanium_shield.png | Bin 2437 -> 486 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_shears.png b/src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_shears.png index d36635b4d3d72a5dd2644f4bd55341d6da866d5b..da7fb1fea2eda508cdd13d5586492b32c484e21a 100644 GIT binary patch delta 237 zcmZn_Ze~*K4DfU3<&xrJU|`_&^l%9R(gGmN!3-odboqlPDk{`V2l#}zHqKg++tfdI z_Ze+%?SOy)IXO8~Q&Srcf1o<29Y<#XDbA80zu^B+z!2FVGl!$7z02a0V8cprgEGert&?>_&R&@3 zytb9U*5RGBU0!w_>+&ZeCled`L?%z(-5t!ZL^HZ6^~j?o9a}ffTN7IB_Gr4Zi;ePJ WHnZ+9r`bS@7(8A5T-G@yGywp!D^OGb delta 2432 zcmV-`34iv30)-PHiBL{Q4GJ0x0000DNk~Le0000W0000W2m$~A0Q?y3qmdyXe+h6% zS#tmY4!{5a4!{9w)`zZJjkY>wb;}+i^bu_gMVX#MEe?A$v*Na(MM4QcKvNOrc zVt#pbv5sJ!F;>@gp66QYx>Ssko*|F+b~vfvjo)&zJV}yR)rwHAdF9Y#e=9J0gTAr@ zH)yX@#d@8fNU|s29e2Vu&SY6CxO_G}Rf^zIO2Kvf#!Z}3-{SXPyt}%bQ%d|+3tK9s zYfUNTRB)S1-?d!FF7bjJhzy=F&-0SJ==AzOJUbZwv<+sO=GpoAcxSKM>Bn&l zC_erC;cPZ1gx0$84G&PlV@rMa_I{q1Cl}|sCWdKHgjrXDQ&}Uie3t^a!=ZQk=qH}rKEJqtoB#aRCyR9gJbL}!<@Ex{ zfJIF<2x$kw>Dk%r8krNSX0~YpAIq_eB9Ee!(Ha2NH3M#oWyB3*dUE>Z*Z*O+j_%B6 zvvANd4C~qSY#m3VfAJW=7eyfi(m-&EGQ~w*sA>^s8Q2OBYrvyxN|wuYr9e?&ML97l zt*TO`X?%SAG)gvUq4@89^NwTtzyK)y+8Bo;<(=%B7aGmAs;pFk_@iEC*WyFp>51W&NQzpQa7f- zku1yb1;hhne`#5moG{<_vHHzdU-_QdYdN9glz^!yuU9GRF3sZg^}>?+&i=sl`FuVb zj|K-j+oH&1oj4K>Da$krA@RX}R8?Koy3|Mts??H+6e$pM9!x)eb_(b#31_ zObem}Xi)-E8ohSwjn`hN^JJ?(^aAhU7hkkOKlJ_Wf9*kDD#vsb3c9M0cHoKX!A+7= z+>27-AH08m`u(>p*B*r7{A&K>*=a`PaS4+Y;QhaN7>)l^I@H{iiV-(%;Vh)tumYZe;vYD4O z&lFU*$dWA2fNG~5T2ymgwnGnb@PmPbGnUEHe=IjmHl1C>Inh)>04}c9wJL}G&Rh52 z0A~zSY*uT_u)LO^7WsUgetUX3y;@x@mYkC;-!NtxASWk-w&y`wYvrLi_`WL*PHG+m zodObJImgqJ>GkHv`3AL3h1lKQ&$BA4;L#9DZrjf6eE#V8`+tA&==^w7O|Q88^LF@8ID1qdRv8-9ayCyJ$zGoQy{=-+M7h zV~AR&Rd2MtxLo9E5rn;(K=-Azd%fZA)zzZi^7p#I!4`nwd6cAS8U$_A^!R%Zei62O z!?HD_Uf92N=jgRpUfJE7kUV>E|BZJaf4mKRQU4$-;_y7@@mJqCmiz7F$2$jyagv}L z=saUYO-B8G+YUU-6wGtM9%|dJW!wCnH-F~(es^mSc0rs@(CYO2-SM#Z@=srotVWi? z0F3v9Fj1$-XrgF=a zf)mGTioviN>BSaT@2FXY^$@OX}UAr?J5J|b= zI9?F=t+Ys2i%Y1I;FuB!+%<5$f8&5gMHca2|LS$LJzAG|2R(sl&-e2p2d}O!&Uus> zS&8Y0Gk%VRC5|ifooK|KPnh8|jb& zuQ?YCs?K;6ML??;29F+o<|tUNQeDg!S6&FQ^5Zl%g+O!W=#I3qOzz?=f1}dyOxpvq zi?XT-N#g|Vn!oq^J7h6TonID#4y4khW)cmP2`LN{ zXPZS`gT_!UDs5@FOjTINa3+xIn`}3YiGXv!@@6RVFjCrK(CZLOP=E;ytBbr$DqX-8 z3?JCjERLtq#Zz*gBeK9-QM_SqM|~*Vt`MGYhYlYnwpxa zsi}>Je{NHMY<^WjLIO~cUu^n3Q&S+r%y)@Bkm4>0@(cbC2Mk{RjGutQoCO|{#S9F5 zhe4R}c>anM1_nlRPZ!6K2=}+sZcl4g;Bghyz5MXM{SNh$jIlbIJHIUCf5XnHe6y{- zCp5MsueggZU51xm;@+XF&jX}Vk}ld>>{aLUJX69U_k=_7hi}$52{)D*5xXX^Dn^u? zcW-PFyQ|Ekb1g(P;d8=au@Ym8B@-oCH42_&RMFDZ|FPhtpy8f*ry$dGFb=`YmZvHVkQ0IjP9|yhYpY!j3iPgmfA= zu-Ge}$X~O4zF?`$e)cEb4UY4@_OX0%P0(ky{uCoToy(%EXk|nF%anbc|9O)5enm8? z3QT(-tbP0l+XkKMcJ=w delta 2432 zcmV-`34iwH1BDYIiBL{Q4GJ0x0000DNk~Le0000W0000W2m$~A0Q?y3qmdyXe+h6% zS#tmY4!{5a4!{9w)`zZJjkY>wb;}+i^bu_gMVX#MEe?A$v*Na(MM4QcKvNOrc zVt#pbv5sJ!F;>@gp66QYx>Ssko*|F+b~vfvjo)&zJV}yR)rwHAdF9Y#e=9J0gTAr@ zH)yX@#d@8fNU|s29e2Vu&SY6CxO_G}Rf^zIO2Kvf#!Z}3-{SXPyt}%bQ%d|+3tK9s zYfUNTRB)S1-?d!FF7bjJhzy=F&-0SJ==AzOJUbZwv<+sO=GpoAcxSKM>Bn&l zC_erC;cPZ1gx0$84G&PlV@rMa_I{q1Cl}|sCWdKHgjrXDQ&}Uie3t^a!=ZQk=qH}rKEJqtoB#aRCyR9gJbL}!<@Ex{ zfJIF<2x$kw>Dk%r8krNSX0~YpAIq_eB9Ee!(Ha2NH3M#oWyB3*dUE>Z*Z*O+j_%B6 zvvANd4C~qSY#m3VfAJW=7eyfi(m-&EGQ~w*sA>^s8Q2OBYrvyxN|wuYr9e?&ML97l zt*TO`X?%SAG)gvUq4@89^NwTtzyK)y+8Bo;<(=%B7aGmAs;pFk_@iEC*WyFp>51W&NQzpQa7f- zku1yb1;hhne`#5moG{<_vHHzdU-_QdYdN9glz^!yuU9GRF3sZg^}>?+&i=sl`FuVb zj|K-j+oH&1oj4K>Da$krA@RX}R8?Koy3|Mts??H+6e$pM9!x)eb_(b#31_ zObem}Xi)-E8ohSwjn`hN^JJ?(^aAhU7hkkOKlJ_Wf9*kDD#vsb3c9M0cHoKX!A+7= z+>27-AH08m`u(>p*B*r7{A&K>*=a`PaS4+Y;QhaN7>)l^I@H{iiV-(%;Vh)tumYZe;vYD4O z&lFU*$dWA2fNG~5T2ymgwnGnb@PmPbGnUEHe=IjmHl1C>Inh)>04}c9wJL}G&Rh52 z0A~zSY*uT_u)LO^7WsUgetUX3y;@x@mYkC;-!NtxASWk-w&y`wYvrLi_`WL*PHG+m zodObJImgqJ>GkHv`3AL3h1lKQ&$BA4;L#9DZrjf6eE#V8`+tA&==^w7O|Q88^LF@8ID1qdRv8-9ayCyJ$zGoQy{=-+M7h zV~AR&Rd2MtxLo9E5rn;(K=-Azd%fZA)zzZi^7p#I!4`nwd6cAS8U$_A^!R%Zei62O z!?HD_Uf92N=jgRpUfJE7kUV>E|BZJaf4mKRQU4$-;_y7@@mJqCmiz7F$2$jyagv}L z=saUYO-B8G+YUU-6wGtM9%|dJW!wCnH-F~(es^mSc0rs@(CYO2-SM#Z@=srotVWi? z0F3v9Fj1$-XrgF=a zf)mGTioviN>BSaT@2FXY^$@OX}UAr?J5J|b= zI9?F=t+Ys2i%Y1I;FuB!+%<5$f8&5gMHca2|LS$LJzAG|2R(sl&-e2p2d}O!&Uus> zS&8Y0Gk%VRC5|ifooK|KPnh8|jb& zuQ?YCs?K;6ML??;29F+o<|tUNQeDg!S6&FQ^5Zl%g+O!W=#I3qOzz?=f1}dyOxpvq zi?XT-N#g|Vn!oq^J7h6TonID#4y4khW)cmP2`LN{ zXPZS`gT_!UDs5@FOjTINa3+xIn`}3YiGXv!@@6RVFjCrK(CZLOP=E;ytBbr$DqX-8 z3?JCj Date: Mon, 27 Feb 2023 10:49:27 +0300 Subject: [PATCH 0255/1199] do not generate shield model + shield blocking predicate --- .../ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt | 2 +- .../kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index 76f7b8c00..ad6eeb407 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -79,7 +79,7 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.generated(MItems.EXOPACK_PROBE) - provider.handheld(MItems.TRITANIUM_TOOLS) + provider.handheld(MItems.TRITANIUM_TOOLS.filter { it != MItems.TRITANIUM_SHIELD }) provider.generated(MItems.TRITANIUM_ARMOR) provider.generatedTiered(MItems.BATTERIES, "battery_tier") 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 ae466a53c..82e118108 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -273,6 +273,13 @@ object MRegistry { } private fun initializeClient(event: FMLClientSetupEvent) { + ItemProperties.register(MItems.TRITANIUM_SHIELD, ResourceLocation(OverdriveThatMatters.MOD_ID, "blocking")) { stack, level, entity, _ -> + if (entity?.isUsingItem == true && entity.useItem == stack) { + 1f + } else { + 0f + } + } ItemProperties.register(MItems.ENERGY_SWORD, ResourceLocation(OverdriveThatMatters.MOD_ID, "is_powered")) { stack, _, _, _ -> if ((stack.matteryEnergy?.batteryLevel ?: Decimal.ZERO) >= EnergySwordItem.ENERGY_PER_SWING) { 1f From de68575848e330b778e68d587ed4ba0486619e9c Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Mon, 27 Feb 2023 20:06:03 +0300 Subject: [PATCH 0256/1199] Every KILL has it's ULTRA - Jhon Ultrakill --- .../mc/otm/datagen/SoundDataProvider.kt | 5 +++ .../mixin/MixinAbstractHurtingProjectile.java | 36 ++++++++++++++++++ .../mc/otm/registry/MSoundEvents.kt | 1 + .../sounds/android/punch_projectile.ogg | Bin 0 -> 47601 bytes .../overdrive_that_matters.mixins.json | 3 +- 5 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 src/main/java/ru/dbotthepony/mc/otm/mixin/MixinAbstractHurtingProjectile.java create mode 100644 src/main/resources/assets/overdrive_that_matters/sounds/android/punch_projectile.ogg diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/SoundDataProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/SoundDataProvider.kt index eb5539c1a..79e01991e 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/SoundDataProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/SoundDataProvider.kt @@ -34,6 +34,11 @@ class SoundDataProvider(event: GatherDataEvent) : SoundDefinitionsProvider(event add(MSoundEvents.ANDROID_SHOCKWAVE, definition().subtitle("otm.sound.android.shockwave") .with(SoundDefinition.Sound.sound(modLocation("android/shockwave"), SoundDefinition.SoundType.SOUND))) + + add(MSoundEvents.ANDROID_PROJ_PARRY, + definition().subtitle("otm.sound.android.projectile_parry") + .with(SoundDefinition.Sound.sound(modLocation("android/punch_projectile"), SoundDefinition.SoundType.SOUND)) + ) } private inline fun add(value: SoundEvent, block: SoundDefinition.() -> Unit) { diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinAbstractHurtingProjectile.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinAbstractHurtingProjectile.java new file mode 100644 index 000000000..aa61faf9a --- /dev/null +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinAbstractHurtingProjectile.java @@ -0,0 +1,36 @@ +package ru.dbotthepony.mc.otm.mixin; + +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.projectile.AbstractHurtingProjectile; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import ru.dbotthepony.mc.otm.capability.MatteryCapability; +import ru.dbotthepony.mc.otm.registry.MSoundEvents; + +@Mixin(AbstractHurtingProjectile.class) +public class MixinAbstractHurtingProjectile { + @Inject( + method = "hurt(Lnet/minecraft/world/damagesource/DamageSource;F)Z", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/projectile/AbstractHurtingProjectile;markHurt()V", + ordinal = 0 + ) + ) + public void onProjectileHit(DamageSource pSource, float pAmount, CallbackInfoReturnable cir) { + Entity entity = pSource.getEntity(); + if (entity == null) return; + + entity.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresent(cap -> { + AbstractHurtingProjectile proj = (AbstractHurtingProjectile)(Object)this; + + if (cap.isAndroid() && proj.getOwner() != entity) { + entity.level.playSound(entity, proj.blockPosition(), MSoundEvents.INSTANCE.getANDROID_PROJ_PARRY(), SoundSource.PLAYERS, 1.0f, 0.95f + entity.level.random.nextFloat() * 0.1f); + } + }); + } +} 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 6a92474ae..d1c3d73b7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MSoundEvents.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MSoundEvents.kt @@ -23,6 +23,7 @@ object MSoundEvents { val ANDROID_JUMP_BOOST: SoundEvent by make("android.jump_boost") val ANDROID_SHOCKWAVE: SoundEvent by make("android.shockwave") + val ANDROID_PROJ_PARRY: SoundEvent by make("android.projectile_parry") internal fun register(bus: IEventBus) { registry.register(bus) diff --git a/src/main/resources/assets/overdrive_that_matters/sounds/android/punch_projectile.ogg b/src/main/resources/assets/overdrive_that_matters/sounds/android/punch_projectile.ogg new file mode 100644 index 0000000000000000000000000000000000000000..fd1d63941c4deb5bf7272c0968dd53fb77eb1ef7 GIT binary patch literal 47601 zcmb@tbzD@>`!~FZiXZ|?Hz)`wAWL^Cozg5I(y??mD&5^B!h&>nigb5}fUwftEPEgD z^ZEY1&;2~F`~K%Sui-E=*EQG7T-WVf@b(`F#FB@4_rDfJ;kM;}uG^Lcfp9Z=9PvoU2> zurr~uFwO#md6U!otPEPDQU|WawyMW@SPpX60mNXKiI^WaYqc+Y8ErzcyZr zzEwj3JpyXLvQ!*g z#cqfX0^J9FqDK$UT9+~(St&TiA))TvNFUtjRVuQGglPV#Mq=Nqc8f8jll;jK%k(4(I-L}y9m z7@HTHrBs_1R9p6yGxn8Z-l>340F~S8t66f+|0@}5#vA?Lldx&`E08eY%Pw28E?XKg zC7LcfMzlK*cY}bK3M(;o*s)94vv=9^14+W+T~Dm+z_Bd$zd^VSI|w8UChM>z>jAu> z#588dp>8iQWiK}cxZ>6$|L5!T9bSNmP^THkn}2%57O8jVmQR3LqRdBcG5_`iC#MgwT8Ih?%yy$%n^1;wV&Rn@8dwf7G!@;;;v{@_^# zS_I9eKh1vgZQcJ4A7LPFdecOmXpEz$Z z!2pUGIRF%gRjsGn7xPF$VO5im*RWV6X$II|Mgc*kGK>^?NPI^U|3tf9hFpLZ{~fq} znxUuUBmb3#4#?g=qXp6kE0Z#tfU1hBx|5}5g5z9`pU$-7(v;`YRG2QI|NjoG|1bvx zkjD3pld<}t;I333c~SJg0sfacws>7pWIa(dGUYUKql^QG>85%Y z3VuZF8wh?#?K3R$h}JKb^$~Skq*6N(Q0$@djTMz5j*V23gn>YxKxn|<&!eIWP|z5x#JqdW&3rFsS{RPBG$3Gw(-;m)q0?sLNlWGVL@Lq4 zV2aY_3@{>PX(lHeB@7rKFk`5~(~@TD3l`2YRw=K+zI)TpffC)mu)syC7;7&4w z0Uj8hfjL9xI3$#*n#`b(!})IJ1i+}O00C1c;F7yhF##=Pi#kZ8?@R%mPeQ_qsz{Wj zfeD(+<^fx2e^nKcJ<#H|k18U-R2LDH3D|yHQ9x9!zO0I--O?Z`3}AD9NZpyr_K2Z_ z$hVUUM&yIT(2;15^BhKGk0sg(qPfq&^$j`s< zK1lQ)h{!iqzn=$A1;oHNQYn-NPUfqm6pW)342GxrC`wDmDanG@Z|ltSl%&C(cXfG2 zp|^E7faNM+>reH;5oKVgngrT90KLIr)4V`ipi98t5WpUw2ZK%OZ{6w9!p0#X)V@m6 zQnavm{SYva1N34cA>eowCFwjsFQlwfNg7!9CV{%nWT0OlV4-E55M}9GcL8+}C~y!$ z!vc;h;=@wnabnY^ZGLE9?;wi@cnVV=6YQUAkHh*X${te`joJO;3~Dhel;%wf%fmCfxg}&Rg>UmAbHGqH%Amu zE5K!uhtvkQCnI0r28@&FcAPAkn0O@R&p?vEsSFdCKN`TUJ8VfyG2Ei!7Adz-yAA$7 zMJOtwfW zQ|;ve_fOOVQaUU4&cShNB(PMUXSaw37ARU6fPALv zejWyfIAAJFPS1cM0Mf!TVC915RS_73kprt)FjFUq{SM$7U_Jmofkki{P?=1A%W$g# zOjH|a1_%bK;I|F|az%Byw^k;#?e_$3tyHb2x&v-Vz_!){iW&Oz`X((e+P-%qTwxn9sUYLyZ=kzJA6y*JAtAo0}N<^b{BMNUq$JE z1<$1EVX^<3g5C1+AC+gfz*6G<3zNTRlE0?z5T_)K{#WnruoC<1c94Ht006wz%ls=) zlD@<3t*Kjk0C=hY6#yOGb$%yM5`9Gb9{~(70F3Id0O;u7+^rQ5X!tIkPvZ#mbBWa{ zKEJ>qe)*SQ%fR;cudX@GzwKWD>&!ov{vE~t|Hc2$E~nrKNAhYMd$z;L!gOY6h;4JXOBu-lyOLl+&W7MpvffbpYO5J($Ym81O}l=K1xcj zfE5&24=1rirJ1S-v_i_(AyBl;Y+wbw1z2&DPoy-oXpP9Alm|X5LeEe&tslxU1#!p9 zs{{;GooYh|cmjbH9z026KfrM|F9TRkh8A<6W!U57z^2W^IN+)7IK1cMkg&RS3Ws44 zIE90B5wHsm3ZPMY?AKLkKnFPBi$2)AkCw~}0ANG+1kTcZtiS-0hkx9vh}056hj`A& ze6e`XDKJ6ZVKyLPZIS>lc(cgo35= zI^w0_!1*2Y1q4EU%8L64Px$j^Oc1xQWaK>%#$!zKpJKwo%+y(}Uu|T$>C!ksAd$d+ zoS?uCDsUzV{i__*PaO~ZJwV;V(~=FfpO{g#hdXr8L?4Obe9<5iMnUK1UiPP3-1j9- z{i>|8dE3wJ=jva87iK`uza=HD{@FhVp+6<2W&rbuNWBM^W8k6!odb)Y+NVHM<8^Lc zenDZ;cjA)Lvhs>bD*t(=@afa1J6&Pm{^`@-rv}1AcU7Rzu1B-R9lK<|g;;Iv2iz z)t{N`x%Fq4P6vupRYB~IT}|n6bEIZ86FL&G#_Z!?y)BZMqkp0f!E_NO%n#+T@tlbz zj**QI67+K$!tIb2n8!jmA~Pgs!hM4z$cNJ)ZF4bS;#igv*$^D$3okFhW4`jmre?&v zE;4J_{-U9Bt>j{-fReE!*Y9B2{y1Zgf85ccnUB=cJf+8xuR(h#@5UuLxH#^V6G8db zNZC$%lH9KU$-6l>8Hc{I^?|FVs-rmMHB_(j-tl3)C5(yr035%a3it6+78m3sgHt(} zJ7UTjAoQ}1F7?KbHT8HkypSH=1w-4jH~f1AtjPM2b(Z%cV)d}rs7)9Tl z1^M!({`Gup(Zy%Yr~RCKX|1G8=gMyxlP-cYtjJ}jVQ3Lq|KY8+h|nf>f&%v!$oRpjjb_1 zxz?)i&imPL0e#JT?kQU~HQ;kT@75h`MW-1hA4g$!9BNFBBK3g_Y`oc3_J)^ro@^4^ zuca`hjjukVvuJ_8*qXVi+1_h(=jU?CT0z92|9$${jHZE%>!ql!o?R;qb7l#X`TKQD4ja6DrUw zM6T!KM>9~Ux8KEX%FnCaTFJB0^h3Szn2TQv8y4L3#2k|>hi&kprYo-_s~mYDtg6x* zFX{K^O4zP$Ikr3${geR-Gkfx99gSw?TnX#~&02ClT=}gKN6k*VyhDx(Y>qV$^R0{o zIBv*q+LYPqNmNANAJ>7^k<=Xf&;=tIM_01l1~f8{jm`)IaeqCxoeyxI*<3`CC$HSe z+_LM3{yOcY??y`_L&xk_*OkXvUe2cx&S+=K%R%-feMb|YYfcL+$LoHZ#k2Z>`^G#K ztaSF(yi&i-)KdnS5G7 znC!1D(=YKx_bNrl z7<0pISpZvhB2Ym6r&py`WLgM(BWEz8!A(&x3Y~m#%!7Gg&yrFN-FeHd|3FAi&}-yT z=fjbShWv^74axzq{x8z1GN1TRSD8yU>+y|t5r!mA(~ZR!RujXX7-Z=o1J@^Ln;J_z zx>Asp4s6|Z6E+U6srhr#UvJK)eZpXAy52Jx7A$LaU~AkaYeU2lQ@N^z)J2I&=lq!o zIuBGeHRb1CHx)w_ zP{DMzrZZ0O)o)NO*izSY!`u^ZkNI{nJGb57vx)!P*MFu-1UoB!*e4znaXJM7XEG8y znqe1BN?2cLv|Z6!Y%BCLHQ4h=>R!^7TR`8K(xrsc6 z5Lf2J99zyxb2nKi4u)2vkmgJOI(_b*hM=FBGYjVw*p?UUiVT0;329j;vZJ;Ydys`!RIm$bmR!{JXPfk2&vRWKNDyNbdoHBFO~3+$5y3 z+KE1N|G79}tU@*N>lQT(%#kr06?H}M4bhZ?-_gVT0OXG2<<3u*4i zL$3ALPtTB(W*L66dnEIe)w@2h-$IZ9-H-5y6w~a&Hm^6kokLeC>~mdpjTQ2nDiRz& zmtaNT6Y>ARPdC4CgrgE!e}J`nA%u{fIXgd$)+hRehirP80pm=eb)%h<0uzN>nY# z^uWM;=0b{91Jq=YH3i`$ZJzFR;0)31tBLqM6cgtYedH9Qic6;I9FekHvC_0zgor(= zs6Z)wA5!5YLK-UIMY6Hl9tD{T+-TvwBmqxyxciPhPhe6($ki zQfR7aE$7pzyRM4Nk!Z-5P0ZgFR1^E4IWgZU`)p`pWzl9FY_PHyitOppWxQDuFL%eg zcnEQZlaG1kW(Ytc9a3LO82>(T`f};9y>|7K?O}4YR)Q9tJYOa0r(i8N8g!#EGt+?$cSD3YvtCp|l5)!hTaWFC_P=TZ7lp$JLxS3RqtoV#J;spA$8f|(WV zl^XqE9ldg}O+6gxi6TcAc#{^L%)`Tod+mDEeb%_=EN}4V&?fO7h<}Xesex>Y4E49& z&9}`9%voK|p&NzOXa&RxK0_boUda3i3Q6&KHsLe3;Md`4#~L1+vN4XKUqk{YPi@hz zoecJCY~fpa+Au^`-jdM_%@BJbHNWQ?yLR*pBs>(>Qo~qk9gZQ)i1Wgwt;*UT@-f<+ zE`mI)*%Ol9_n9hHzt4j-ev;IO0>>})a2T!QNQ}M^VrrkZ3aEBdZwROgP3_;Tw?8@RUxn2-!>U0m;>rjZku8G z{y;KylNK97*BWqsQ)6z{!5&8cR8U3jnP-Dn3DMxxjQ5o~X~nATMsEL{PWs-IJTHl) z3uQyk>dV#pA*&e;AY}9IV(4qdmjSCvCVjc5iH~&kv<~XX^bUPA-ki}6E%EfGyg%BI zYTY$b!y2r~ZHJxu2fnxmx_O%gPg~#7cu-96<2wJ9R=ZH(i5q;6@2A2lK88d_ROxosSc% z6K(1pT=suTW#Q+2u)mN%aBMxO0dI@vva}uAiU8j?d=gMdRNgwSeI@+W`LvP)0mOf)?=H1D^Vm) zL~qhwN}w5uw<=?{!%V|GkNg;GP7(eg(a{?7fZStHB%|R2jr59j!px``%C^(F(MC-T zr`3(O^tIY9tIs$hZO_i)>=qU@ncngH`g{~13gxQNAq%tCj4M65uxK%Xnw(oD{@mV# zzP%i2K=d$JdC6jxViKr6(o?4dK9V$4@sLoQ6ditE=O1BpMZgtF`tIG7g7i^r&X!1Z z@KGfFTO=DjOC&lZ+y$IYKe(T-s99fJJUWT65g3bGysqG#>~-u2yZIH7)U(xk=KQgB zm#_)x$zgRlBLwUF)2sn~vncMiw8m{igtpLNAGDlXvCVoqU0+?1US%#;Oane5($dV; zZAG@2#g3KdQ$QM_DXd7&)=*}gvUJ9rxoy*~O^q8XLAFq68fUkGpwNsI>X@KNQK6Gx zB+|TcN2ANGqXWP1GDcD8%F!eE9U_ZrLA&8pkai->arNbvX03(prg@DFvjjHB+5Lep z)-9|r+IwKM5*??k5~7sq+bvIAg8DR@>~{b!@}hvyk|&P%ZaD1sMXZ|Koj6U-iG?_M zWEVHdDlz5AlQ!V0RsO8{XZK@CPA+vQf*Q!7=id@fG?#`Q2D}&lY@Ti?%pK(-`cpW6 zCwF&s=w}qIm^aKEyI*BSGYSn|a+*e^IY8_vep5fms!?EIO!;-{;R2=bsM)QV|D(I| zEJJHNZU5uqI#OL#tcy1}QyqnZ&tee;@2dzn$K8EY|H)V$DPlHUMwi2K@Zp#N`kOywez*6A(_jT-RwkhlK!mScWS(@f?O$ zg?x(M)NYI~TT71;^5-gALxZ91q(N_VRUHXKnn+%ASe+^JY(*+Uv+tN;DJm z`Z#+jS`99f&{8leV)!V09s6pSy#b+S$zQ4^^2A(`nr%?femXY!ss1~q0Gk})Y*CeH zm6xtxZ^oow;XIBEYVqLU9BgNh3JfZEn%m~HOcU%0PC8g@B7tZN*3rJ9HmQ!ARQ_V@ z^14U?Us~HCn!xf!K7P$~YMeH5+o`iniZ!^GzWRr{KudE2%#Gs`<%B+ieQ;LtQkCM~ zZ>6L20Be8R=UK7INAvVGYgguVYe5D#FIe|+T}!6V5Bdj0W5W1kVW;XRGnq4&^9TZ( zlYKO7XAgMi!U&0AV*RBdvgS#M#mnPbhXpd`KwJH-TxIwsWOn1dr>*m<*r&V{?!AY> z{9(HJIq~6NyyxPUSBK6j<7ByG8dKPmD=)!y%PS$&4c-UpT)S~g<-w>1dw&pD6L6-3 zbtGp!Ybm|J^ll0qP9y&I*;8`Fk4G54xju+SE>rDnoVnoEH=@Mz_VE|5j4sB1&Xab* zE+;x^V%>mR-mM3{&_!Oru@q%FK(@hPpVIImvHxO;uSPgA0hLk1CF z(=ei~#^|-czPC=fPtj7#2-W7oX;mwShj_xukbvyPZof9A^r?(H#onb>?N~G>yxF8- zugOR70O8KIbYXTqaAS6!CmDVicEBq%KQ?UkVpr%(is$c`I+^BJ|4m($bv~};xnW1R zuIE~Z!*_diHOC&$gr&Dlo*DbUE3P(G+_2OywW95s2$AXA4`(-a^y#%_((_?h#E~C^ zDiYSi2vheyO)eC>dntrBb1w}Nt9ieUXu@C8h#v~<2`+mRSEa_|OwYJLSj~e>5Aj!L zTzrwa4NX6{s(m@?>seFemUcbI*L%IAO2%40BR6;dO2pr5PM5)>;40m5-%_(;wxkwq zwPM{d&N}L0@@twK)-D>4$xNKap4mv71(L@|FgqbsV|P@i%Kcrnqlbu2nul z|InrA?!BQ4_IhPjqytTtD)f7G zhen}jw1r2qslV#wgQwF!!M*vr{>AT}r|O`B{yr6IW&WS1Lbty%nP57|p)|HIH!(3Y zcXqS2cd~PH@o)uxT7qe2=4OXPHY1TbvYU+e7%hE-WixM@I{l8E=o><;QpXP7yDv(2 z@#xoUl?ab^{@Rmp?@HNj*JdxvKJ(=7@~F;ssD>GzNY)oc%uQ-lN4_}E z56^d8Sc$aW{*8U#9ieEwt2!W4d>=$J%Wm9jbkr72R8PK{W@PM#zg1t(w|oIM$PMYb zE=?WGn`@_M>_X(?B^vBRXv>{(w^g0md5~FFa*Wwt z8BeC>(HW+|PUF?IauKTBVKAbAjVqYKeUSD#QOwh9Nz9E>#2*F0D-USPZaidbi7TP& zNVjUuxoTmDH|BshxhIclYq0nrfUN$LtGD+OlHyrLwJcSI-IDNTQNPjYC-0I@w<;>y z*=#>2u_Jx~eK)^G$|Q|08d0%!)6)^I8U*sdB1h*F7OfsYAvkii!6RI#Ik*Yxf&0K~ zayi9c1n>DSpuNr<<6-T$f zfvgP#C#TqM+4}~e)@NxW$)16kFEF_>=G$dqys`?Y<}b$DHneUo+Abb*4$Tf$C%>}_ zkZ;B+zuNx3uS2he;pucGc&&fp)^*)9_XGrDoV?#IwleFITD+20P@**#HPWCrS1l(Y zaI}=dUxC~@HuXwZ;^UHMbK!3=G;u!^aOq->Iq2=(Fo-h-y#8g!^vG#ZIkki zyRO$q+jF4?PgU6}_vs;>RPzLKUGEJWL7~v4CG}c{#j~<1ulLj=ep!VoeB^25#EJ;sSmqrR=e#dBSAKWmbfXHS)nPPA` zG36=gdh|!WDV;djfft-Dk%!)>kTuVD%V*RTeh*ogIy`Bl_}*0PlyDj-7?zv)dp(cRuY)cmGO4hu-f&TWC_a1U%&N7s*KD?Q_VQ>VMV5?EX zg9#m-gpRO4XQRf8XVoE76@AQ_GgcHn=GC?7S##nKLGKnZ!@=+yCuvZp_= zNzF%0v#hrbSE4_YI3BNwPaI$^jWFaVcwVZz9a0PpBKUZ$` zdtwl}ts5d_Gxil5)1r8OReUY#=1Dlhv~LP>UxX2Ml3sKql*bc1qO@Kdn46t=ux{|= zvDN_*3P|=IQ~VB9eUXaYpA^*CCFX5>t47V^3b+wDAG`svH`$b&5Rq~*;lwlU)vuoL z#+E1fZ1r&#VRT)dALDA|R8&Lmn>1u)3xU(3=YD1h{~x)I3V~2XjyHNT{!orebvd5=YcwDb{~}%ovC9|Vbr71@PHP|3V;17&){ljr)O@stg7{O^f{Zw1x9^1<6#Ehj&XI7>Uh()E;L@EftquD znaS?l!D3ygN}fGaZbrSCaE@(D-06q=b=bnTEhk3}bB9is2=xS7m36$yFg(;4YVDt0 zlVGL9t*_LQYqT3hN__7hHtaUW(R98MCgh<$X4!81r_ppNFu$ zCNH|@lCz(NEn$pwd}KXGqGg9u{nokqh)S1oS3%ujj433_b8j)b{~Y8dia6%jO3HbuD?bO%c{`u6&7R)wpe%Ex% zT0XVtRofg0`+kpZ<_w`rXbz>T8*kckz8CFE$_IQIw0}7ilc1>qCa*2yDrcSFjpsG= z(9U+?=8F%QdK}?wi|}xX*L^-|;?@;k{Mb?J!@P4!K@o$j78`F@TUdg18aQ;`0oy<2 zvh5mCB7-;+ypk)ZR@lQ9oG;%I^3u(=h1G3a?ksL0T&*oh_j;@av1Y5Iv8NWXtQI}Y zJu3!Qd0;=6nvF_YV0+25) z6^pq(AFbx%W;61QE<3yAHl3pxYx!IX4i}D!GtTB)hlRDYI%pWTkxP<(1mTu>57ZhizYCl2{*SZm|C2K zY6T_NzEq8QTi;`%Ig~>dnFkx9=5DJWV+LRG*YEY0#!6n;I-?tWEmt71>^Ji7c)@(~ zgM3wegGZSuw(Sw);MXg~j(jFLaSC2~i~;;Hb5c}?^RTyM`@O+BKc)Lvp!$`&Ltdi?^ad$Z zDDC`vt)cD-+A^P)6>a3T5ODxE`FjMb{+2_S#_nlF0qSm!Y2LGrwcI~8i%*`F^(YI3 zZA`Xh^_U!lw@|(=XeR$MWvS&>8`v09vcs2sx`nf8_2o>>E_WN+qBMCg&?T*d-fjtez|zka5;INO|!Ugj;O z<8oC*E%M3_{Qiw9@xr<5bh~du5x-*c&yeh8D}mIMc~<(S`cNF1AJ)ne!~UZpE6Z^Q zlgsOH_Reg|X(1;v4+PHT9P(hz+ERrb4AMR&WA{@`efZ__Y_-&Gh$mD*$7y|C6XBX& zuPM=TA##7(fxcKJ*Dd_(XVLkm{yy zPYj&dFAQ*1c)vxI^}x3VU!|Q4bhI%;77KNciqnZ?Xe}SgdGS9S*k}oT&6df(TK54- zdT8`gyz;!4&=oizK&{Luvdc)_ZzMx4oC2WxaXcv8gL6BJ%_b*R^;Qq}aM@>R^wFUt z*2#1GX>J8p2iu%O-_Elu3%8cH5(B79zVN;D$g@OvHl!!el}THAMEsU|QA(}aCKJ$T z*K!r4)SL!cU_vrw6z0;@z;;Dw6uAr=&fUSQ@~0(!N9Ys}ePWo`^-x$HCB#D5n62xo z8d*S>^!y}fFFl1rA42i3(LnS(0}>JfVx1lr0-cpNRw1IYM_?_1K^&$5Ky{bthzo+uCULks$IUm&=NU{3^nY zVvJ8***Sx)O4qABxCg8gX28FMkU6{fnUXByT$6OAr6n;yAfuITPVbQN!TZv~WeoG@ zTSqnZpm14QZ3Oku4uZkllSwl)(aGMe%fzbZC(osG$ijT#_SqP7xbhV4+vO!^}&9rQG`kX%Z6D%-Nq~J4EF-b-&$uTA%tmGh1VHfD-|4& zM6R3Ix3&y>8~#CdM|mrw%uRIV!QD6Lj9)OtZy0zQ4#Vh}>u8QvH6r$IxJH=K(fO_T zzmcG;(gtEJS+Bea5?aYVCt7#1zfum%(-QN0myFdNx~BKM>HLG_H`3LIox#0b^_b}r z=xeS6`(0&qjr9-(Y2kb=!x}m2tsVET;U3;~CH}#ZKD^}yS|Q`kXRlVCEmW@@m`~<6 z4*y>K)~xsQ1vpWj?KwnEv2=KZA8KNlZY@8%`1&#fZSdr*#*&U$sfPc$8nK8N7wu{DSjoIdcp3ck*0yl~eO zI=NJ;df6vmg0LC#(y=lTnCgNi?k=g@d*UUqDjB9hJ^SD0p1m(be#3QW*SqPTsyXGF zFycMt#wY&pM>#Eki@aNIncni<{11pmZ)rwXl@ArDn^- zZ|iPe7DaMU;dEq7ZzUG>hoeSc{jpuQ`WDFe*bGjF(6xtMy%1Iqyw<-gGE)wk_ib3E zc$`xyjMG@&XmM6Ll}T?ew}~<$K#?uYgSoC-D!`bqpiu z8XSwx-#-8;&eaXcB`qeby2xC%NM{@-Nc4Qh%MOksi+g9<%(uM|?K(hsGh_H6Ph_>~ zj79hUmW@n3<<@G;*V@iQCF_o*RG&2v*LnN;cVuzH0tU9kO7Ru=L}hx!IsN&lZRB1T)I)<846~f}<1d#CEsl z@4T-vYqRQ4b71ILdPuS4FnUks@j3wo5R=Gb_V(YnUkYWX_(~}fv_SH9uOI!Enro@P zE=YDhKWm$teTzvcxgDQbsQmn0&S-qF*~C$N60xt>*ihn=&=Pork@QQx>aH8`z7d0` z6rpC4KpD0zf~g;mbXCleygEmh!{D0_HBN9|6FL6LOD~AI(fnz^B~8_jI_}LmJp2Ki zkbX}cXMXlp6a>mY4`x2e{Lh0K;421@WX0PkA|&!75~+YhN+OX0NF*x~X<%rmr)R7O zpiz$Z5i0e4(OyF&Du`+gW0zT`Sc)R&+`S0+$;0eXsg4lvO2=U3n->ExuBsyZ5p&>e z3n85&SF=zg&vtB;K{q_eG1TGX*0Z+Kyz=q6Fpa2lgKw6Eqr3sJmG_xgP2$V1#{#^r z-P0wBmhCTo{V5V~Jy$@5mkh>RD$7hBjq(oCIZc$Q3`98<&UN%OGhBei5)H8YNlnFD zI))=Fb+Gmh-@$8E)CzKS1B;>?&J@|&qMP-e|ocl7BD)QyVDs^3T3r){%E^-B@ zN6+}5Qhx`50`||k**jMojdGbHiZ2?>$MP)l1ZoaBpEF+=zmS_Fd8$AX&y1wi77}mA z&ctn^5F*G~g}fRrxbO9$K#GG3g%TQ1C7>5V*hyMbb6)$1xXJA4kuD!$5YKaY_+^0% zXJ;Az3E$(&nQXSs9o$j4kZXJGi8lq50kKL;Fs6gblrBDjLrvFCw6O@OkG8@XQEPlr zDd3vX7xkD3BhKwH^HpgrTajx(U;=&&^^2+yC*tN_)b7NCTCNaDq8H!gQ0fI?=bdmp zM0rT>bunXbXmxqROUO_4}XD?O`JE|-!+3gk&XJd4I<8aw^RK6Q?K8NaPMoJktQI9Xl>-vpl zT+NX6W?mZ2JPFa3^U6N^cA-PLqc|~dQew29hpX^1IZ-?&S7UD0w~>Uc;R*bKpVNMn z$NnK>ew;0IW@vHw3nM1mmOW~pG&;Q>jwv^j0>@*J3l```^LkrQ6eA2L>(?WC5$`K* zj>x)^wEidOLp1}I_pk?4uGlTp_Zs9SA2gvs2?9wKZjNbdHsItM z5QBCTlY~jYoo9J3SmF1h)Nrz0i_f%_3VQZ;1c_S$P@TuthY_gem#vlkuNw|GvMV3( zp!ri;a0Ps>{qU-YD51uw*Om262($gJl^iraU@I-FlCcEWy(Hl}EH{X2wkT#>?w`P+X-%(kA78>9AV$W-Sh2V#4j`kx+-BZ_q8`5#+ zHSy zSW}JhGG+Klfy&1!eG|oR;dlYhF`5NSw#$bGk$=t_YJyDa>O)5%%L{yNj*n}+CJ^ro z+$CIT!h?K}LeSCTepinuHHd59JFfM--PT1WJn_2tR}#zmi+WIY+CMDa?#)BR)o*fD zR3CDg_sM?niJQ$9V|M+nlq9iqee!F3$TAS!yX!l2T9X1n+1C;vZ8>63ucjU1-^`s) zZ}ZOm7EGxgU8Vkb&+wq$x$aN8pQwFA4JlzJu(M8;tK5kO53M`=7Qfsqf00Ufv@gkV zj1AgP=hBn@*fI1Dp`^ty6|3)Yso6prl{_MESwSEkoYqR8v3g@;!<`~Ik_~x6(e}28 zLC-^g+m`WJ+nx+c-lntibwQl7c&HCYVqtCVWB~4JbX0(kSgg&;*Ly90G$P#F31jR_ z?{m(KCMs3LQmlWecesqK1qjYRKa5^ojMSJs#+seQ)2#RU>xi!OZX{Ilqbo?2bcyHA7o>rjM*8 zNgxp7-n5H|BOdcg+ib!)kCzefW?UKxHQ7!3L6;HBhlOh#VQbSRn^39{X@TT(LRPh# z&VwBeLtN0Vjz;NKfI5g+lcabt6YM@L(FlXsPK6$ig#TBu@k~9_I%=pJ$ z^60&`WgayVE`>mLiwg&jIfehbEs6Wy-xRAJ7rOi!GXv=;ccX+O7u^WB-V?rE*gTXE z>08&LNYUPWih={8y8Xs|QR+HXTcXsTF^PW7OSgrQ+OfP6W#F6qg|*t^9=8$)dD!K& zSj7!ze!MBU*^`n1)q1w_NS+%M5I^tM@c5fJi%^vgG!6;zJgE}zdHNips=4g%TVHwh z{hsa;nkjdVdsE~oB`LEX)hs^^<;g$xc!A4d?X&Mrvi@+@?tD4-N5r}ibJm)vYs1^G zwtCb3e3Xe!UAw&(H=0WmJ=$RQ;j_1R4235-b3yotgt{t05hjHd?>bc;%Yo8p0wp1h zFu!`+CkIf(u-`N^-xI7%F&+oLh(RX#5e-*2vCW3y?pS3tEQ;t3mf*TAE!K2mID*bg z&%7ZE16yp)NhIyUz8d7rl^1t%p3p9BEljrpw-F7ip4NO5k;jges zYxWimRT7B_Qe`}G;tp*lAL!&-ZIi*DiO0ap8Y+p8ZJG;Wbr#rogB_yPUKX|bvG7_w zhG1%LEt~Gpq=CosrvOJ?Q_3-c0h`#>S<{=QpUYNCDyP%Bm#7Ny^4gl@zgIZL4d3sr zRweB{QTUE$;4Uqso5p25`kU@F)Z_@?c)n*+hwspEhuLnwYOy=^erlrtzLErg&X{?@ z1A<^_GFE9L>yO&uR3B^0MeN`+97YEv0-R>eyVBPFJ`5A(j0CO%jH|_B+wh^Kiz|AE zrM6lA%RgPK%kt?9hNVXbN`)eqt5LrLX9+do8|-^hIs;+vFJdEh`8N@<-=x0LvN1*a zKndtkF52w_xdGICq65C-N@uu+$aY1d^8ETvb|wIvtXi2YvyY3CBr+!}u>!DSz$CgF z&sHZLq|Q-6=dL3;<{n}B;k-|4nuT!G|Y9_y4mswz7gK4LbF&3KR=+f6f}ZCN?< zL&*{O6OF#PKqHXFTt)*2}NZRl2ct8a(2&Og|9&VRl6;VQh>%s4JTI5F=) z{pPLHr?nEr8g%N2_8#PL9!`-#=% z04MzBnfW8u_45uTrSpm>7Gd6Y9=4U|OT=r64=)1tSJcOtZr(Q%p56=)Bp1@t6zjjv zI&Xw);iSfJviFqE^c$hcH9iIow*xTiIaTHx0+CDt3ZW;J8M@0*cR z7JJD31D~mhQukp?0`0rK?v^LKc3t#^sc@*9&1`9OL4L5~0|9cJf!8HCA7!39EXFQ? z**IQUU1}EOB=($Sif^)~S5&Xmj^<|&)X9{K74u@%B`kF~EqR`H73Q{#cVv=R+A3=% z4XJ)f{xOer#!J3)`ORKfYfxTc?a@*?{c4-Ah#M}0p|^sYf%=w6_SVt^9f3AEjwCjJ z+WZGfi-kFYjsyA_gVomu+o~t8=WR*~RHrmH2&z7Vrtz}aPzG7z#H<`-W8>wGjl1?W zfVc8FX+a>TKkgrnBOfZ2N6HA>8>Y^l-JZ)8Hla#hCtUFbmcWm-U;eq zb;eU4^i|eZCp0Jf&Hf6DC(-FZ~^vGR!;28m-Q0e zFH}@nJ~3aE@j&w?l3xxszNILn#mzJFr$>(409&JroE)vSNH?ZXnT%-ImqB0?q6!sV4Zo?dgJTBE`! zq?*o1zwt7!>YAu-#+=!y=J*0bOH!XZyaVF7=-US#9O^4IV|CiQ%5+6$H(C~z6VAa| zOAxC?`CKPvRVzuKay=BP$S+>bFg&5%W(rk(z@0HVZJSDrM@jEz6~Xs<_}f;$@g8$c z=4R^h%MSC(8h5l{*XxSM;|`&}85<+r*ZcAU9jYfTblwc)Ncv)cK62#)FVx;2d}$08 z9#7Zi@4i|1W6PH{Q_(SJC?odjC`h-K7?xoXynB{>2e3f$aCFs*IHwbf+03P@`ik!SWVE`m35S~!V zBL57zxWaMBGOAfl5vPp8zT#b|l&IU7>trBpzCSla%gg2nCc<=0mL!fVC#d>#f^{Tf zPm|Xk@C99`9X-WeEuGhsOXk|T4_9`V2LxijN7>tp9gEAd*I_aTjjq$!1(6@g0RW$LIt{e-v@Ya6QsLif+ROKG1fQG`)FoqVSz-- zBash~NP@eBg+vlE-m~uXqa76q$QC_8zCX1O7zxNI*l=bJ!G7Jcn?uU*%4tQzjVMe^ zQS0@N!g?8)O+{&6Ydgo?PNwY3LH%pbrC-{lNSYHj%VI>=$Q6EOrl{h@q3Z{pK28N> zh%`M`&^IsV+%z#O=76PNRf&?awOSke~Hp`Aw~uMyVb%p|fhI=PcUa8#BfP zn19ZXpFTlp5>1Fx@vL{#HY3ee;o~Ggj;b`9ggMtT}m4T!$`mOPRk6`i|3^^u8NLrYvkS)PMX7bl{a!QxS_1a!7F@3F zz;Ujt_jCo1);th5!w>}@W;FDkPuA^5`~%?D$&z(VF^AGZXIo-y_{ZS^HZ`$|C)!`w zKx7z0+cKye+u@?W;p1SF;@t^Vtd=s&-GQG__)zC31`FVNP-sRJ9Vh1ZYGxEtO-AGj3HsY zUcFxJrzo3`yP6Be#>LaPVRX~o@DGyMOW_J%p|(9jK>$Cj00ICU{tn=#p9Z2sv}|C2 zIV*J#u~Xjp-Q`v9b^ZGMgYCn!){z-qRKuIaqYLAU@xvhNB22idO_NW3Z(>*7*gl7E z_;axX2HRpqqFGRD(?U=-{MDEDAY)2@wpogY*)*L`)2+W`W7@8&>~b!Y&w_!g$}d?Do%{x^Zc4 zm!i7e*z9pgC0eyK0SEKlR<*zPx6|+y9`8@~eY}kiR`oV6mf--J&R#vQ07MW103_n> zP`?I7o>}{$p7+~&?@E^!0hVqwy`{OEpX^-m@1Yv*NCLeEzwen3L$!R~;@gamRqB$E z>v4*of8MJb{ChHUzQQoHUvK}wpma^?ykLGj6$kk#pJlfYO)jFD5^BeDI>wUZt z=5x}fV{PYj?A<&(Y+{p`ZYAomj-0q7p^F~|6T7m=lKtpt-^sC?y(FdQ{h^UYbWdt% zq}kdN<7|%eoD&XAghhduQ1{^oPKg1)@c;y$08U8~G%c6nVfRs}0ZimZ{=)1+?3K1_ zlz92Gj$q4qKJoA!JPV6$mc)STn~8S*V62}u&HP*wM{`-5#fj#n)K&T6g&ZWtM@Ut6 z|9wBcYVUUM_e^Xuy^#yO1}%T#(<4*XvufODDt@;rD&F;1UsL6Wx4J2WfWy+Z-&Phr z0;?b&R{yU5fhxE;>cX;I`+u5QF!*trb}iN!XF2G~GF$yQ+PgH|i@G%`M#GfbI>SA# z-B|TtPSxfuyHz#!-Y0qIQIC3jANb)Rv`;a8KCYNu$g!v{8d*-!pc1VYKkhOTKt+f_ zN~X9mIGHFSh`T!N>jDlD%O`6MT^D$BHoG^mhY(36E8`-4QV2ecQ3nr$vvisqK@mkr z0zf#&`Os-xY*yq3&bh{~Htg0y%9f;(h$JzxiW7&@HsW;`Q3^&hpR8zprMqr+OT8cW zc)kR<0FrZ#dGcpE1Qq}S0N!}}*h*YxpMuyW6k_t{AC_uZyHiNng9!HLl!-ho^)lp%JYy6X&&>a@vC&6L-r?asi(+#YjYZd?zuNq@?yrg@bJjU zaHqU(8*6fENMDPlSv0NvIIs0?7G8}knO5T7+hI5wN#HdQBLH;;gcHC-5;P5S-^bqE zGd?j!jaB*zU91836$_lXzWep8R8fol@=9FG166C~v)PNztXcJ<(y%{V%0szbTB+iR z#OuiqUTA^yc%@GF;aoBOKYf@^4(;%w|7RTT3@gx%u(;{^?)ELNH+eRzg8@~_T)&VN z-?%2M{8!EHda;`o`>cz68*dPp3F0`?Mcs;3#+GxpAYpUK(dOFnh8>m@4xP{1I1T+} z6a0KZXPgxO4~MV&Cvhw5N3N=-pl|0R2>BJd2E1#hEy)090Tf9?SX=-|`Hn*p5JdY( z*9B&wwM>CY2{#RuR*HCzRUgVCi?g~HJ8q&LBOj*`Dln!=apM5~)lHMU_XjWrl}^$c z0%5U!+DdX!%7dk8hHH_tv`h<+2qqtj#<0jq+nZrRt~TiFFt-b&IB8g{Od=hCTi453h8?JSbgn>#h1nG#;edwYQlxb zR;XW}i0LkjB=${~J=X0xX={RH{O>f*&^cO8U~EaAmqe>oQjKl%%v3^V4D!%7SEoBD z>oD99ZZy1`sH`_R5r264U`At;USCvdNYlpRdT6qI>!E!S!~y^iyk6yivRL5Z2m{7~ zaQss$cCQVds&ydo_2ug2{v=3MB?+ap5==)AY_=NT}q9P&ypk_fjjWDDb zOiw3t00B_X>*YQ^2fJLU6Vb5n;w3So7_+6c!>{w9@Nt6zf-Sy$9%pyT?CLlV8u)T) zlS|~xN19pFe`Q3B^mntx_QGNS>ReSNCmjD0&{`a~s4CC3d)1vmlM4WiN-Cqbb#*8z|5g_ti z+F8hCtr#cw?f0~IB+QMZ!>!Gh*CysiUF@B_93_o@%nEJW~;VDy} z964J1am41-%+}eOZZpJh{dmY>Yq3)dRWjzT_E0I(@t=L?IalK7$YnT$S&d_Y)6v%1 zZbm|%m>f0BfLd zer|2+@sB7lEdD{sDD>nYX4O@H|bR zkUX$VFc2&d6k{-_Xn=r^;s}^xzyJV90uTT|*J4`RZL+P=Wt~m!rJPsz+;n-Fw;@rI z4P)mM1p{aYHpjl~HwS~m)gA;*YyQMEG3KYmx|}{?x0u4p%Z8Xc1oowm=YyC=r0&!D zKOx0Yat&WI4Vb|*Yz7s<70HD9I5EOSh}g+wK*az600000{`a~q5@edTV68Yr<+J#t zM~X?q7>f?oXkx;6Qy62Mg@@Nq2a`*wER8Mo$2-r3EggHk=>GEZkDDjSc3PoiOM@;4 zvok2oBd+WklR-8sY+HvmIj8==tnN%@4cNZQ6CF|QBIAmnLY(lu&;F4|TNl}E-l6qlC}P6}Sl-t+Z*Lq~7pDGIxq8u;;D7KW zRkeRpyZwDIW9Ur-^1P^^jGQx6d7Z3uA45wW*RvFUyo@xjrNWjIJ1{oAWAPhP)n zNRX@<{;tn4y2xPR)49e#BhxY*nTYOar@VT2o;@-+nqye*&Ld4T(MbIK(ky=M?e+D6 z%eR&!h$a%>rJ9d293AkiiZgeG_mf_ap>lYj>hKh%EbDGq8 z;Fi7_zw`R$iK(|@Y$t^k;`<2loo-&Oc;%yOj_%z_`FO3|Sua^?=fsUMc`Cw5^2`2n z${j&{wnv4%xy;`Q@fGiJ(br8@Vc+?xt&y9Dc6aOJPr?C4`=!8=H3w=RKW=*-6FumWYX`XU^_;K&BB%#yE$wnWRbR)}@k-`Y z4kjns`yBqXqaW&fDq-hKWsAXae+mJYOh-b1NB)ylK*070D4-Q02tq$eQHxh*alwe7 znx3G9P}^{KqGilFzpGkwq#rA4V#Pj3XJP$+0}wuXkV!NkKY8I;?&J{>>U7DbH5^?g z%Q5zOCKo0D$@^Yu9L`x9T!WAf3@_zvQqoMeV12(G20vy8vt^RI`1Q}cgu8-2_P_yv z08eLUQvd*fhX4Qo0001{?Qt*$00014zjR<4|NjpE{|Ep74gdcL|Nj90{}2EFVqaQZ zUR=HhyDtz#+KKdC(a4yTPtW5u+mOuDx;ZbYZAYzh(7bQkY#d9<&)bZ!Fi$7SWS{l0 zS*!};7slK=U3i6tanW1T&maWBH`_^;D-wF~vBB>vOOs4hM;i^xTsV<>Rxd9^)-;MFI9;DRKm000{S z0Kzx2Mc)&dC}MPPvTXRh4ARZ48rr;c8_)@Nd2Kwp=3D%X@4PTO@!E4k<~# zv^Nsw@~}+KUNqj{W2&xZU;fS@RQ}fxJI~7k!PxFB*6NxuFMNZB?tJY^u{XKDuQT7u z6Z%cFl>MfR6%VsdcI$fIG4}Lp#b)J`W;50Or7F+)=Vp*+!-FOK87_Dz5CCY40000< z6h(NXt=j98q+q$PGP3@3UniQT`Rqf+F=w7zh?u>ndoh@gvB89kg^nyBp1*2N(4KEj z;=H?GB$r+6pUVH_>?dD49LiQQL_$%A)qqRi{bn&2J7);4SonFY(_?~hg2q_$*6pF{U?aC4D1xwbKe z=|Gw*!rjx2wQXXRy!~Y7RP?!K7o8YRXCyIaX#`2;^ceSx9qcRnP~qR~@_tX^ zFgKPr>fbh7++EZ79*)^sg4R05L3&#;?=B}0VgR6YP&P?e7y{v+#PJY4yMA(`Fy z@kG9`6dPCn*T$6R^nSan{KjIE*Ch4@DHQ5M&mTDbh3#Gl)4gDRMIUj?D_*@f7sMEF z#HIic5JX)+XqbTAu3`u=b^;*)0D#uPRACv(jk+K85C5BypUx3xPLdJI34X2P)H!)f zCd^pz%X5{}uD29UkSw3}!5F~Rc(jSI{!PFLlrCV{I8oO#4jl3|H3iE(csR4<}r}P^!*5GW+sb*7+s3{%Q=aD+jY1)q_H-3~QZ<)=>r|?&H zR>_tQ=C-;zis`{`Iz1&btjW)@hZZEPp^xot=5%W0^nf{4t{AyKJPLLno=)^sS!3Yg z^)vpF{a|$CRyR6HnrkZ$II-ny< zHn2<6vC_lk^yDn3A!}lHuxt9uJKd)JuuKDC5X2C^2x0*RfcxtJmL>@UMj)o1KC#ZA zk9lA-X5UhgLJ75?I&dl(#R>1Z_OOVm)UZQ8*5=ENX)51&jw$V1#@li7`a^^=YQkGu z7e244Wd^yqu??&fZjdNAiG0GDw2Ld?sb|F>9e2>a4d$troBB%))^R#2UCqCGt&4i? zI)rL*_chht>{&i6>Uygqz=9qYb+cglgK;hH^JS_GN!H6?N@)%>8{6fgeaFyiDs;xp z!iv1)o>giI4xFsN8h4Lkm0$^lmI6lfh zOc6-=QI!Ff_7hURl-ace4c5RyfImvfY;9qY7#h4Z52un$V-zZ+xAZo4)Vb;Y@5UGfB!|QN9P1l?M}esplvZ!bdy@rb@|## zEj`}wBb%F(nZ7EmAqF>xKW?%<9XuZQOH4F_y@>7U_=M?XD%V1X{pngAg&;-%lok;2k`Yt{0PY0< z1V@XVcqfYnF_b6b|Nnhm+9zPcH){Vsag3y^T99$SM}xMKHPv^OifM6?q;gL)*e>=&)-1Gc+e*&2{r05fmf^Nc`8@!M_KBSacpmW?;{gS*dO?6q874rfJrD{N zF z{{t_-hzE?OU^a78-Aj862`0@2*j-n;Z~5Naw35`#9sG66<5T;st@&RsHbe>^H2?qr z0{{RD-qyN~2FN=QJNmFG@O|j#PHJL=R*%+{J@gzFHKSFB{k&(sYb+;5yO+0`x>e7* zGuLo`s}HPAsLj7(%DNdq{5*_k(h%*DQ#0zRb)&T&^vho9RS69{`D&3G+xyhvA!1sM zapH>)&b&P5;Tiz=5>jSvL!r!CiLxXjmy8-?=f+X@vLD86YMs{hO3UaCMi1TLYO0^A zPfpxn5`&RB^@6X`LcQ56$07-00RZ6QD*?jh2m=}juOB?yZ>4+TUMjuX$tUinbg}1h z`aQ>DX?AxekCAs;^?|G1H}zjA&+Yd3J_NOq=4z01{67^+Q`{gG?)k$?lQc`w9wuH3 z)7e0Dxjmu1mFK|a6fupR|D0U*MbCM9dj4k|^ui`X_3@kZY{eHmDtalByG?^ zG%cAY!KrK=eWax0-{+*){ik0gFMkOCk<-5MlIKg{&|Stn<5z_TgLNkkf5@ud{B`60 zOO(i#Q4_AwxpOpf;jn1{M8OfQI|mhz2>=94{~-ea0N{>9C940;*;o}a0bodFQ3_XA zFck;(ftd2{bWA4Xnw=r$Rgl8~5Y1vH5J0RWx`yG;_I z_R(}?GJ<1yN#~Bl;qr*k_hT{`U$=(SQS;+7S{~yt^>Xc#cTPHMdhGCHS91_0YCkrX z*SpP*mz`@ShbLVc)~#Q-P-HXE_G26)nGM7;?TJUtrVoPlIP3?flcAE(JR-UnGq$!i zUAJXEZRXdux&uon2nw3D_Ik>Eaz)4-cDDuxO=w&?c7NJBftk>D zn>5#shki*|Dxf zLv`PbRk$|O$zE|PAUEpeY}US?rslo!{CdjnpN;JMPj!Yd;_=?FB;^#(%5QwOw=MEj zg<8(j{da0VvSN|jI+9v5PI2#Q_a{yF^IOv$9@m}p18MiG;^mCaLv2(KcT-y(#c`&& z$s*jN1B-F7@0-G@J3=Ci%qpn%7(PJ2aFhuE1k=z=9pE7u-Yz1Brwc?h0Y?qNG_LE> zG?3o2LW9LVciPz)M+Gq?eoL_&NrTx4BZGF`-5BeZEQe1WMa|kTo04>EJ}f^eo#8Cm z+@?-8TBWo0GR}@tX%EvWf`IiAsYpT7UzTN5!)c7=gi}EiZ5YfU^KL zbvss5!U4>{!9M`NFh$`A^G(UT)zw>FeD3;BUw3EeyJY{E)x9@2ZZ2uJuUoqRu5&i$ z((~E=G9JcJf`=Padx_@8l z%hi|r@6M9Lck#6A`T52>4u75w<||h|O#Qf0IL3YP*AFQ*6?ToI?d!%c6wJ>mG`elr z>PX`9oKWWAXfl0bI~`d+-FcJE*@!ppm-;?NU!#{t0)ze)gWe$cZs!L}a%aetS!7)V5wf}oL+C=}-XEA*2nni5DBBRxq zjyv4T;BL07<{b_5jK<*l{czsR+RGa=Z(UKH@e4Y>5bo(#K6b$!x97Y)^S+_iI_$#k z=|~pu!B_=~_vwD=qm+F|OKUAXD{G10zS>_;W$xog;O?wq4<*7PRh{NlD!blVTe zeV#v)}Azw>@}oSUNg@5k;rJ5PhnY=0eVd?RhP_V5(B<0k5DuSA9)h0LLw8k>wdA0G)0 zT{4+-T|NI)nGo{+)1BjGcH|cNp)x2bw4s>2*2bQ6@*Pm%s@eRT>>1n?@E`LCWdvpW zOkc0kKXp0Pur~l}RG75Pu8}#CZgC$>IoO-gq@A9@4)&=VHt; z)Rbzcb6Htix_y=6U`VrjxVN>;^PF?yoz>2Nmid=h_p?Q52Wtm`gEN;=Ht_EJZTPfE~9<_ z`qgo#)TH0P^fvI!<={pyD*LX)27g=doz3ZC7_dG5#*pJ{Zo*{?8@~OvJve!c%><8bESWNRe`ss34$VkGDeX(f^wS8VQym!!^dD{@)eE7s!Xq&6$ zt$+3{QaoU6@E;GiZU}m#Le#I;qyQYnqH^G3KOi&* zxMX#m=Es_Z#+tzz@*u5qANTeDj>3~UQ1FKh4XUyFp8eVoUn%&jszR^QG4g=s1f z70qHP3h>ql5nRm{qZ1cCkgok@9=Z0lxHp%(W@YE*-Sw}EADWjoyX5Da>+bW3_g*p- zXYoV)^3~$FdIP%44s8{i+@_T(UU5&Q!~C%M_fp@eSCWdNjGwoLZ@*krz)S33W^d!7 zF7n|Ne9b2APra1ixRj0kzpY*EHm&S=eTnsoxA(5My*!l7r+mG5Cwr(f(RqzcaZuK{ zWWzcvpArr^X;?6Y`#Ka-;Rdk_Rqd5eqTlJs0!u3-1|td2sAHvn;FZ4h7-an$E;P-m zF%d`mLL~j@gR>s?_NKi)Z`q$x{fhqK$8q+vW4gV4=5@mB@>cR-{U?0?M){ref3jo) zi!JpaO`rRQho;GVkFeJeGb#{#j9{?GQV_@im`D%4m?NCEmqdu-!C zB;X69-`Qn4%xQ0?jp^pT>*3+k*}CMPypBJNbT*$nhdv8eS?6P3%#M$`u0CD&yV~8G zxG!HH7pL}~YI)@5w%ELOJ#o?4`%Xf~X!rai)U5tXN|rfzN`Lh&*4=yz5A(i!qbXd@@R0h^48VLA;WK4O63@J^WQgls{O1jk?6O*Je=0Jq51rN zT_o)j95t_&O?`N0X^Yxc+typ8XL`sz_f6C1cC%h-8k-W+_;Ut{O3W9a?{8_=k1-%5 zHmImM2(Il>FBh2MeMnE*I@9*>H+0aw$1R|vd(=j zG>_$)t3j7n$x_P+HJ%TRP)l-Rt(gsrs$?<2+ne^kJ&G#zv-L-Yq(MQ&*WiF@m>2J1e z=XKdDyR!vBa?d_)5atr63F_D?<54?t_#4mnS}7Pi7Zw0MNBh2~J`je2f55%{Wnq|- zZEQ)3=EC;++aqX`+>BmqtaavKC87x}-<`J88kyItTE~O9KaM3_d^$Q4Iyzu!(uU5% z>^5^t?FO=B`2CR7KF5TZ7bkrhGHPq6UYq0XdGI(4MITAtmG!Jle0O_j9LtjWWV5sx zyDZao=d5vDmE<-b^Kj&qxv~^((v|wa^`o^z*UNgC8k3gkAs7k9_Kee1?ZYv@4nKEV z=Z^gZG#=<_>S)$uJ8o+vev@u| z^{Drcoo(GNe(uX&G)b=_A6vCgWd=L!LVo@UQZ_K--iq{_?|LWiB^N^NW_&!~;V z6X3aZHh@VE{*TaqclaRUPE;?^!&1kj&X2{O`zJr99nCP)U$KKLL`84P5LoYaprsO~ zvzniEkIu}b9sfP*lrBQ`kGcA0_f$SSe&VNr@}`j_=KY*<>8(Igt5ur~-%YOIKOJ|k z@~a}adRynU`HN?T;+v$#1Xk#!_{-?zAE&5ISgz({^8~lx|1^%m7|T}12~xJ0`Pk(e zk?wlXP{rhO)6wSmTzLhaMtd){LulY907f6jD=rOfVN)X)&0$<~IZrVM#+g~|Bp67d z9+545ErlQFwgg#z76+mI!(j5sv9W1=+-ZK*%18a6X$AfC+GLK$@lbuI_2t2-o(@fq z$mJJ$x)`I|I*_y5ao8O-*qXzq9nIzXvBzfl(9Ct*U4vy~+Al_qLfx+hX8H`V|7vn$ z?r=EBN#4qh={mV*S_41b9Q4I`bSyNRmSs$*hnbGPw_x*SxY?FyHes9Qevok2y3LpQ z>fWwf^D)hj`-343?x={Aw6jw^_QBkFd4;>7AI$!dOV85QsANzs?7c@Hf}@VFWtJ$H zBlo|N$Z_8#D8TA&`(^p>VtIM|n66#Q%RaGEZOb)}vdYco{atX&TSKmP9q%CJ!(AGE zozdAoaW*JVOf{+@@11qD+^auF*V&2Q^te;O^6~Wx_3k`ga$Gh)DDI#0MWLl`HDp=( zslGnqkH+kGqeixE^nNjq+`01g8S5E!IY(I?r4w;%zr1Ur)VR1Qnu)zjM#j{Q0b*U^ zoaQJg_UY-j<}y_FjjsENiKo|D|qa# zeRIn--1xd(`c(IyT+CI2Y5PX;XfprPeqA8V4xxBYQyh+xe4Xlj_qd^+@<)vWt!cwq z`mc`A(!TC?d?2QVd9hBDefP`ae00Xixm;vQ{UM7QelG{_)Zu>Mkm0r8YM$(DOGF^= z2+Ve3))bk_ThSZP_4%^YT z%}PI~Q-id*R`%P_H=1g@U(CLB3_TH3?5DSyw~u$a>+~ovhPLZ0F9mUZoV)cLZSHlW z_UvlXTV`lBR8O+BEVoVleaGIKT-Re~q$Y39p(fjeTRNO1)U=21eN1}&)SHw2aLZLQ zHRseTO~->IH^HZ6`{>GP@W+$n&9b?W)*zJ)9X-~BJSG*J$$l^=PfQ!Tq?Ojg({*Rt_FyjYP>QvlMHR94K>WGBAC1peN9G9w~dR|rfJvSHYnyY(AS;F+B zwX3qV2F04#y3cc~NoKFv-Y||`H`-~hYOoij7C4NmE2c(KAE+OW&jk`SXM2grZ>6)_ z-}D;F!OQdb84KOWLG@{;xw>T)*1B(3r#ejL9Ho0=Xl|x^Gu(+X(V{^?OIv#_@;3ZF z72%!7ELJ0awRONqXuHl|EN!ituuA!8y0;zC&3WSuyHX#{N3PmoGba3f+ZdqA%yfLx zcO7H^M_0bD43B7@@wOOPm??K~t8#{mk z-bK6Zy&N?#6<-*Ayfn$uT4a>1=~t=AGTgKogSb9DK_7IFSGKRxX0X|1N!`+5>srFf zZS7(WY989uJeaWpAU^-0@WNp0KRso}%oxDP_>i<;6r=8onr zOLIDEPQum1bI)3zFA}a9IX@mRCC-rrU2W$c-3Mo;B2 z&e75g8aWJ3JoU6f9Xn?DA)KRSsb4t3u?~Gw(+QId7K7;9>m*BFHrKmXmcpI)tgW8| z#qM-E^KCq}oxXkVG_+NtA!&y0?$oC8^iSjQT5H$syMB6uL%H<72FXB7rMu%&a^$;S z>vc08^BT^H=KO1d{OH$_UxHpP*Q2x&s$oaIs|67o4fScSHdD6CL>z_gZ9k>UuWSbI z?k{iKkGmOHP5dSw()0q&g-Q=$x2YScaD$N~Wy4!i{%TpOScGWa_(g_p$+h2CzI9H< z?9Ju4Ja;YbxlXFi_^7JeO-4d{luaeSMYr?&f5{el<=hT@e+KI^?=O9`SUTL3Is7D6 zL5HyG*}M1F7n|r!H(Y37YZN)JIGn%;2j2hBb^KRm<*^m2hY7RnSs|1I9lsMch z#zxKsb*)%6_bwrxZUG18-EcXN`Pnvb)GMr|i)@6&{r`nZ`^6LcMHstM&Y=cZB4e_CLfpR98k>zn z!d)jNsA0W3GIO+k#^DfH`V;a6~v&k8R8C@v42~1n7w#){T^$ez@8xo&} zd6iST>+hNE?v|S>zH&vsM7loot)D?3JHH+?hXT!|rPvo#r>sf#gXv5Ma* z{oaQ^d~hA}h3fyehkd_xm@1cMws^z)@k}{h_1#l)-+yNQRdBRgc)iQ5&O3LxkAu^k zJghl+|G>r9qBtLY0G4EpOnw*N-+9b+Trv3damHnPNh?s2f+*5=XRTe|5S7Uo*ep(7 zKC^s@U|+PaJH4j(_Kb!q+7Ua^$7NO0lAm#O z+lvVnr$`RoRHnnu#cu{1uc_5nPD?=U3GWkcJvY(qc9y=~hg&~?Lv7szJo7Y#jNFGe zpXo@Y{}1h{<~kzjS)Uo+v_^|tN`s3_M`<4Uy<2aYBg8GGR`z;QWrRT?1#+}nyWN2uTnqJs*bonNri=l} zhN5+N#3{3Jw%5Kn>!$*S%9JBpK?5BIfq(!Z3S%*M2b0&m(^7Jnx3HwhfHC4@5UMp$`6)B7KX z?Cf7Em6;q1o~T1vd^vWLZLC3wK7#SYv88VN?EQ05r_>Am<3^)lCCfO>7yPnb+fn;Y zuj`EG%fMufKe;@0#CXv;%gU>vm?ScpJj;B9J7hyW!?*Ahjm_ZEn~irZBJt10zkQ)m z!=sZCb8|3tgyK|{L>_8|3?q&$@?m$Vu=34PDfM#PiJRS002P500000005@# zaWDt~0004R2f`Qs|2Y5uE&u-?|Nj>M{|^8E3jh57{{vn|`?)Q}1xzJ)53LpV*)6Y@S+L3HGE!FfxXjSI!JKBh%BN>${&$J{=$J?dh}(Bh(xn za_h@zq(^h1c2n0*6P_z1dT->RiKQPdEeEr6cVx_LG%-;>pYCLvIt;ev7Q@4I)zrMt zhoi*fXlt%2a~iACk1wyUz2AR+rs?`(`(9epoo3y7*i>*9qcQJH8LNKUHB304ImE#f znw5!TN83vwnGknT&Rh8KZfGYj+t0d3hi#Wf_apB`H^spg@fK8!Qz}WMcNW;_L>N!T zr4svpN%er+&$VN{G9b(gjTDD@5MwK0oi&);W-E=~@{Y8QG=+dTpl?uz7_aH)lTPVJ zqT>FXx8~Al-@H6g;uz*p1~$#v$vfw z796|3nJhPK?{dzC+X5Aua2y++kad2RRbGls+}~cCzI{EMpNR|AtbN6`%cTk) z;4V`bcDZ?9@$oL%Uv)Ul=Dl-{vUt|~T1VWR$q23~%UuQ(U#myxBq@wbRcu2vUJ0Qh z99&m7iiwNcl7Ss=3sZlN);XBk7OSQJv}-K@o<{q9KbjP1$QTmAU02UC5@VX8iBpCz zze-$cFOA{J%74mHW%6_7>A3x7uLBKawXHH1YfTCK6G!ICoz)RZL-%Dd!JJ&Nna55> z7u~0HJzAuuUmsoFp(fK~i}V48KK#oy?1$9aI>_WMIXby(>@S;7HhI{>SEW|Z)<~td zOm%%Bqm7-RKln7eF-NzHTaKT`(u$J-6Vt=2bEDyTa^QpOO(+hV5u*wD)aP6IALV^N z|E6BrZ8e8kdQ_UGu~4N;cf(R%Xj!U0>IwHVK)}Gd`Pmh_c4O;qH)_OaWRF)F%TcFN zHym$1lE0UiD_&c(lg?A$rS-LqK<;2od{J!vG5>?}8}g_<=RWs_0@2lb zB6Kb{{%MEb8W=Bs&{buf@1^PKHErrx_?Y zj>?kd8UHC;ZRz74Kl{Gv@9;Z%9qr`n;hNtPzI;o%v_0r;JWw$$mk(gY(nh%2Lm9wTXWE8g@JlPMz{Br;2`#YZSyn>tsa(tP5-v^1fpAyNU}M%(;-G@C{W7}Xe^&ADYeLWPGX^|$5(c1dVlbd;Q=!|A*^o1O7*r{H6nt2v=(nwmWAXYeePB+sA zcHDnU8FaU_By&4jwuPSIJ;t2I^ZDsWXBrDf^nT?do2eucAQ{HB!nv^Tm13hzG<-^z z)9USj(N<}s{4}D>r=8q1oZlv|;=bj79LIz@W)T^CH1zY=Ud|;XT}p~l>o2B;V{Y%} zW7;k12z7P;qft$#`aot?y*rkVq~0BTFAwR(b>tcQ4AD^&ZG1B^C#uM zWli3JDY&2;s>J+s;HmG0h|bACt!bCs;gu9ZIj znM)@9EJlb1Ddsx5GCp}IS$;OjV7YbhM|zH2viHP(;z{(!jV1U2?SzzEb(@kQ*T-dr z%^&Q0E(SUI3{GCCg5!q|%?E-(&gdRxlXCu>Gr|-;=2vYx8l?#&o^;r6F1Exa@qM_Nqrj>~zR*B0OO z*A6>A)uFfcv$AMtAB|mkf9DOgp39olC(2~3Os_rm+OaK7wzE`TDdTZ;GvtkV`nW~j z&M;?}C1t*>_KltInSJhm-kY;+M9T3xkPLU>NkvLIaP zvWB%jpeM@KNq%6hy+Q8Xqa|8J{$vO-ZI8db+cx51|J-6-wgm>3So@ei1uOL3!J)KR zPW=nD+~s2;sl8RIxmoP|t`I%jh_c%|5m~l2na#6D96JQg>LdxAEIY@>g(K1YRGfM3 z!lrN~eLIa-^D?_lM|AHune{+2Y%SFr{bS4c%E?64jNSNJgd*N7dKQqSZF;_QyX^lKW;O|?S+Py0 z-IL~Vk9x3_=PJN?XHLeCLB~ zlt0p3!}q6ym3;El>qaPKiZL!Qg6#t}3S#FSO+@HqN-S(lr?c^Gi2@c2o^|^^)^-Rn z1hkYQxE-=h108GoC}$Ip(JKS-IB=T{ap6Cg22iK zEB-DTn$5XKPjJFly-=Sq`KLXdt_fq7)5|zal$hp+UH7-!hZV0Jd^O1{U5)CW`4nsO z`={id>eHQl!*h>>Y0PKiIre%y6)JW?9A>@egP+OxstbtXgSAt6MZVBT(c7dc)sfcd z-P{U&4$&uuQv#!S~t-#DpJi9A_+V0UlZ?XJ5g#yoRmYN>f?my&D z6y;>Y^X4f{$N*^osw)2tMg35-W4gT*@4GG{QGRYf*cud%V{b z?X}jom!S@2lsop3@HX~)Go{$2`Ec8I6P6I{QL;CIdC06)#bv2?ieIE%abG5z6q;@T1}@! zIkt;*gSmu8wH!75xM3}g6Kz7$nx~OKbGCyIKHc;oed+Z6eX|P`Grv%so5)=p;!Qi= z(alcF&X8~u;B#f~%MgDt^X!$T(DCfx`?3sB`dpR}jZ*rvtQn5{#X`0X)HjIF?7q;O zqlVS#baF|q_Llw2)jUX1tf~DR&XejfY=q3v+CmF! zqc6!>yUcTG**qVZ2T}Oz@Ud*fd^rwY51sx0hWh_8l~dySJss0Zy$`K6$70O44%2@#IddpD@_$x%pq=KL zIlyxdhk~07|+Z)X=-<#+^J1IZX0=K)Mzk_Tl?dYxTxCsyHC6iZ%DT`eOjKz zi>+psE9;`Y4^L6GoZ=Np?(9j5YBT#vEa&9m+rBqjz86;PP;&IjIb&(0!BjJEy4u08 zvzcT9ZH2Ae58Ym%Df_0D)p_;xe;-zQ^!l>w|IW$lkc@sMv-ARL3&ZBSit7JjHokVj zey4s=@9ustF>9sAtLOdqX%b#VvlwB@=zoLwW*eN2EERr!E^nVB1l=@Y?afl&*&tqW zL%IA_vlilKX0BjSRB99H^;~s0(Rn*A7_na4m-WBexhv3u_%&~{7&6#AXgp~YxDu3< z0M|P4FWifdoO|8J-P<)ZauW$sopuTP+skk8>Vb%lnI(hxWKr>CY)c6uWK9ISWkeJs zZ(i0&MkI4Hl^lxBmz(6q4oS-aX;2@M0lTlth!qGt57 zTd~zH5^scJoECr4!}z>KYKsl#Wbhl@?>dFdq%_nhJ)av#P(-vLt62}}k=FjKi;trs z_~Y5%*W~>U_vnK5e2$O0-5f(((ZKV6SJ$rbEc(AW==oSiv@v?yQj4S|z;qYqh%(Dv z&?jXI2Mz2ha;%b&0a$GzHXJO%hy<}dXQBwoDDf^_zybiiMEf|WHg^Uz7~N<2iKZoL z%xTh%RR8v1%-R;JwC)(Es;#{hOqcpJi8Lqw)J6Nks!v?Q!(lko+NAX}{VjhgA7#}h zT zHV#yrV_&`hVDtv>o&>syWC-tX^?o5vJBY|q;A7u^x~-{_nryFH`5Ajr({ugu$_wX) zD3($*!$do+OJX9B@wZ2?mjPhe;!kO}|tV!rzxR)jE?YxxYZYA*Xm ztvTlbbUZd}7Sp~6;^hS;Gw~19=J&)X>!VzlKhpVU51w6D81EKYFg zAVJiXpFFg9mp2{zso%|r-Nbs(@Tz~L1G}~5{kgVOHi2#&CkM5Q)9$&+hj1-hnaezU zkAAitkZvflL^bZssXgwu#hiWw5QIdl{QNK;C;N$&p2HT?n`c)yJcXsiLtGCBmMAYGo9f~NFRj5MvW0x`n08eLUQvd)!=l}o!0001{?Qt*( z0002#f(Jbl|M~y#|Mvg#|NjI3>HqEj!T;aBMcaJu4Ui`oFgk}1S*@~~?YOX23gOS6 zjyU4(G~0|c`RWW!_WtgM@ow1DqcJQ`meSL$jx(E}<{YNi`+c?riweLR#ZX}nHLpc< z8U+$~+Iq9uU-=}zC)T6f<<|OcnuAV0S{1Ec zMoN6fR$iR7)mNmMtoPfJY9>E9JC4?p&}=X9u+V+)GMscaXh=?adrG!>W%eb(E zCAKLcq-#wx6&501Mf-Ih%LaNX7%+UiWC3cJR?ZiR;a}ehn}dKDjO;XL*o^qNxb@1o zYb2RwE3k;g%?Dr*hu$5YN8g7{sWKpKT0J*4`m`AOmQkDM9iDTK-sVMKZ_Vtzta4h7aREO1|NL)iXDQA8Razcq zsm#GOKk2_6GPmN((fH=E52+;@2?! z1gp3q{=ILJiK$z>_h1JJ_k-j}bisN~OHm_#2`#hWBsWI#R_UJ$$BpjEjYm5$_ zPp(+Hc9L#N8=5ioW&GPCJFc@c_1Wex+XBu;L>t#VoHyug^v>T-_&5gaJ}DpxQf3YU z4fsYc)Ppo=_V3mG7TiqaS71X;?I|x>-!u4ie}2yGHGAX4tV*Jq7D7e^CSfzx$Euk?ZaE<5*n8)eouB}ntn zA>*(j!qB%`$2pRF1*-m)E$8J6SI@S&^74;0gBcI?GfH!0G^EG-kxu%#ZasFlWBv8x z&F4ZaJgoh2V6D6SCyoBqAIz=o^4pqO&!fK$+t{Q%k1mu)8Yu6KU~mMEO)kulW&3eERG*i$Js8?!8qRtFKK;7w-QtQx1;Z4 zt?6TXTE0M?=(hD4f1#KD-Xj?Kxm)?;Vx<5L1?W4DiC(gLdF-mK9wS5Fy>(78 z_w%2-@5uS}=hfw6;V<6(H$GXKr*8<_^(iKe-O_#i6Grudvs30_;}L(<7J74 zNi zH9)>#0Jq0GDcM4;DH$nW)WWjH#NbU@WF$S6Gn|^HS{I@4-0BV2`^9|y=6tX?VH2Gq zdH?H5Z~rVSNV-K`DlrDN-EP+Vxv*f~z~QB>+4J4l4&((l%E7v<9#1Dn13BYemcG*X zamLhUzVAwNUjH6s<Ku4Zkbh!15#jc4^sxMBOm=YIlEY;xuPSs2+EyFq@WX1@p1%`4;%0-KeB&{4 z@Jo>rE328H&I_Z9*ktu{6B{LY0(oDamD-k*N;oFQi)*}g@^4BWivQgfyUfH&*jGQ? z@ApC1EQWRy#Aoln)AkL@ceN46{DNX^W0xOUixlLjC-_<|^QM`e6iY1g$I&z{~ zvwVnG+e3#dDt>->CzJLvxOEyD$}Gyn5}K>ER@_xO^D42+2ljRFTA@p;-N|@hB2FbA z>*dGLqGj}IBhX9;P+i;Sm9mKVI z6;*!oQ=#w9J}AK3J~`n){?i2+UbE}ifT%Ni>kpb-9j0idazC`;zdH@0@WTN}o zDruNuESOldu&$UAx-K0{>0C$Wq})sG3Kdb}`jxo}x|>BPYMHV0s;V>;k50PYmJ{VN zcmHU`LEH9>scLPm?RoUdB?ri57KqNSAHuK$TE6zmuU0au1(fCBd2lErLO)94-(xz} zNAtg=g3%Vb2BF4@Glv|Onj?C){;^c9v_E=*j3 zMRsB`TBCMrvYT)FdY{ZkuCZT7!P@)w%ORyXn>qeLy{|5S#q;RZq3ei`yC)yCSuT6} zmzI%xe4aXdaiQe(*wv4+u|dR1q7DLDRF-{Q+`)xArvAr4F9wg88$P?&C7N`l zqI$i!5B(6~cxm3Dnl2Ohze(HdGw<_95bkFte}C);5plIy_EYkD^^v?L@J^-r(QLde z%Jtr#5aRHadOwV-73A0YJ*9Ve%@O;)`S#ZHiLsq`i2n&3(C!Zi55A;2m%34%FpuQ4 zZACa)|I@Q0(8vRnquX7#m^J9Gk-YKCKH{RnMYtQnD*nh>m5ReKP?d#dVckUSl49MA z5wr6f3ZMc2enk7)wi3t$14dt8o{(6~bJjnPgjbn4KM6} znh~`9KKs1(zW=J#4zm*qX3c#rW-Z$Mdptt&CmW=4&B1p!qr>gPn;!n0IKN!wr#6dF z_eN2q%`qNvwFA zO&)ztva*hl5)^TCE;~hk2s~(noWEcYkf61!Egi>AcEH-=toesS9EWMWd{7$WQy8=3 z#Pq??ET3puD!<^L=`_*uSBRz^e#n(0aWn9f5MX}Z`scPr8NQ(#IxmD7{=Xl*^UD8< z5=mhg*!|bpJ9-}ugG03W8~h@xgjj)?SUPSx2_y!jP92k8ZlQh%5K?aeL>lHSo?~YUJs(Il?_D)4US0 z(LWDhAu0ehOwUHGLARi0r1=_x=ym=peInwhe1z-K~X)u*Q@V8)3&@M%EH04<-6Y}7)-b#iYmfw&e_DT+JZRB30s5ICX**W4npBhyH<`Z$BW$f#6fPc&0_a3 zkP8fV-)a}^#W};Gmc6-I7#RAytyO1`H_Hd*m02mxZ1Y2TTPqoQin4ZE*&zKTEsX>A z$#E@xHErk~6-#N^>7H`qkgu$?-Zl2}c&DxGt@ZlB{ldA}`Z#sj@E+(32JPF&L;5F74x30C^LVK7fYMuDIX+OebLmNqTR+o`j zzl_@!uT)u^4~E{Fv-S6AA^YG{DaBdurDF!nBK}m^l}vm(On$qG>oR9~7bOs5y2zI3 zrFVHu9InqSvoRVjGp84h*f|FcySU!r*Sa{b=9TyJ=bQyPTM4ftm*o`{ak&? z8|RVT$sKhXc+lE>&?f=$KK0S-lBwRe^E{iAE!FeT`Hz`we}k5}PCNN~Hdi(B;c2FMh z%8O3FM0;<0fB_9gcP(=^oCs2+bYsiz#f~@OiWR+;vlT}{o1y5b z%_(jVroI)`{<`#J>>KSN)tWv_Hs?DzVm7-2Gc|=e|1_m+T&k2lUK8 z3RUA5N+GuTEgGzg#8>G*qTKRSHQ%A!R`%>A@_pEO!LG@qJ(iuX?!K$W5RE;!&Xu9+ zfa}LOe0ZHA^~pBDGHF-lLA_L}hhC7upZfQqTLyxvK!)MEiAXEs!S|FuFZzNKM;N`$_Fr zxlUfWOb3RCX$x!eH|g-^rT`uA(Bpfl58Rfym4_Z)>7w0h1{a3;raNt0RLs;#iH8o* za$3`!I0{2D%#GL9GKptpjY@{L#+(8{#r-!JlrYi5C*zhrN*C}s7dz8)dop@G59wi` zm}u?8GaI&#byYc-+~iUt+b%zNlf0{8Fp&!2j?gE^PL6cL_1j_lf&FiuNm_!DLrL=f zzjE|l=T+yVv>deG#l&%cgn!4P+8T2QvZYhfUFS*i)mPfm6AalDJo)=B-b4e#V%_LX zl+xS1`MW==lt;^DCbH^w(nYR7<~9$+5BEICH9bJLt8CLL>q@fo4tO0HdFj0!jC~So zi8MT7f2=K;=^N!!5-xHyAbRDO!0@A7dgfaUQ}v;{w&dUafkITOc{YD;Z{VuJe=t&Q zF69U9K6FynckvnwEXgwQSLrLSUe_1oeJt(ljE1HRJliNVETyF%Wb;s)5395L93^&g zV^`meiZ9oqoqRy3l$_^SqX!zTf@pjCvA z0?cW@dAWGVFT0WtcQ1TH0eSV6^3_g}RNKVCZZOE&_URe&U$K?0R?7MW|IcS8bKc6N8|7C3x%eOLzvip;mlmge?G0^KYk6@tXWPVm! zMQ=+4KH7dp#?GwlsO)rI64|Kk9IG#TV{eVzMG_bhhp%_$N6aj`zT9IUqS=3w z&=&hqzqDsnJ?gBS$eZPNM+XF6Y=<{CuZ?N=)gv#97Qt+QjtB{_Nq%rspsH-BFP5qQ zGiIBje%O4z+}h?_%+G1)%RD!!iH0Z01y`L*rw9K@)ocXJH&Z4sk~ty9U`B+OVWgRe z7t73lyQ|KO9D8RKdTu;|6q2O9i*dF85G=>m!wS$*wf(Iv!~0#*NvG&_E$nD6cUKgN z>jFMRdtG{f0S!jCQU@@kQR_&?(iY9w-e086fO({mIlms2w#!;n<7PrL(f)H=RN|O& z?0{nL-L-lgt%*;$3O|PFwKGB;@+Fz~#3k5B!?rEs>|a)*r|o6s>rNVcgpUQ6 z<2~Q_A9dQs{wGFf9Yr2-PuFAmdUkT4|DLpuv74-fS$g=vx868DcpmTmt+I3O!}WjL zHuPa`yHsBqmucx&qtq9u+mcdAMno<3xU3o8UK=@f8sE-G5ynUA*4 zK+J-p%8XDs4tO=o6L#NFmbb8358#a&Pl%rjbRuozZl%J&o|2#De=0|H)PET&Bm32N zUhm+0`!iqLec5Tx>u>zmt-te=H{Rio1NBL9?XEUCUs1L5#1N0hP(n1jL^2-G`1BRw ze@{LFDfwV-r#O;7X^I zNd`VU`PZ4Jzcs@1)VKcTbDvbW06s)}UwQ%12D6OeO<4gNkYnbdH+B8G{HSaw)jWXP z`!tHO-UbYBM>VJR=BpbVxV1IhXsZ>)rjp`nc7^p+Hhy)-bD6m&%xW^h1JnCpo;+gua z)?NNkvN!Ngg+_+51StAqBl?=BhiA4tajesIT{w14IVw0e092e12OILNKs zJX9c!_#sX33e}Kf26=r_G1~`(=Pf4E=Bvei^N9(+WDJ`nCvRb{#Pnxhgzd+Ve~g}k z>!Td`3gtk% zMZ<$fg*IAi%q{jG)yT{Oo<#e;wFbx+j3kWq#S1$gAWNczH}3Oy?K|Ga)pA1>t+vvJ zC~Z8%pi7sl7R*FmTVk1Xp`{k!PfF5xi4YVK5vulPacUrU^Frp zJ||)U6@38-jtBE?Do`!YW4jLfQZjdEQtZ0e{*MtNv43YW|DTSJ;i9-Sx%$5LM73GO zl2JjvBou}p#$#EwIpyOW_dbcKSweX=F~f4zN&(xG{(hd_l_@bY$vM*XALjiCxO`cy zdemxYJ8Ag}W1a8_RlG1jaKqlEvjbPyp*w7{CEDh!M;tt1cvHMoD-VERp;n&;N0rmI z#wg|Vyc0)aOuu80!8?_xlgVky|JK&__Z;l}9mJfByt2z!yKSrmi!DBx@kESIKORPl z=Zw_mo|@6Sljl#)*joFMl5(WaFq@lGy#yPL7|N_H@IF2Vqc^O`7<004eO`?|Ig$PET$Lf3fLeWWxZIb%vY z`Z?2nnFd-t81%;sv;FCt^?j&4!L2=~L+u# z<4RQJVzdX|I*#Pz{}dd?<=$FW-96pfw?9{$-x^){_UDurw!_Bp7-eKmFfdMtDfgX16US9J7}W&d#hK4Q)Lx@@q0w@Ur0#@vrS!rJGUB zX|6dvrAkO`xQjQTOq)I&yR06MJ*$yH9tOr;3;!#Pd*)*qPpR6Ol?``&+<2`KwOskS z>3u-+nwE%~xP#y5n=jSkj_8N$jT_|2nvqMH=b$aHQ^{SsxAESIeFLS!k1n;-XMnUu1@#hRzK2PVJ8JKe1UcWTxc+A6p zY(?JE#C(_MtTkR%{jZiiOr*V>Z+M>1nD61AavNy0!+`A80VT z&eanl)jCY1uGT=qmfB9-v^2WwRP8*vb{2FO*2d5FT{CZH-`@677&hi3|AIUQMd;9I z*Xm01-q8@P+lD9g60?$`)8~}+1c{q9BAZUi?X6h0Xb~@dhXpd-Qa;vp%@I}$a;jcW z#h6VAV81btS#bhD3$9eZL0eauyz%wGO9TXgP|VSfwvq7_x0-jdEj z3yYu5s=dG*HNWr8{QWrnk>68DbHV&*Opvgw8MLQCA*G`|)8gL|Jn zULnOR$0f+IFHTB+IIe7S+7?UIdVN{#> z8JSFSoPDLn$HOhj52~*f{pQvE5J^S|Dq4Pc(g+>r8#9;$OVum~xoCUm_WYB_l-nDg z-s+U77eBc@UIzkqA@OytNhThvc)SOIjtn^HF(K_p=&r@alED`8u=EnYU>F%}TmoyPH!2w+foBeh_$H zWNe3?@@5uc{h4>5YJ253MD(}TmS`(3C_F1nOr>%sxm>PhAnpzU>(JN@A3AtDSA`nBi%ZQWDw9%ZrpLPanSr znAHpxOsTx@tAW(Jh6pFbJztDx4d=DFz~@Z^&|=$Dfv`WQ{KXG+&p$&kZHJ+abo1vt zj8S1J@%9#WR<2<=ub)N79+0T)a&G>-Uz?=*WXsL5-N>Jf8_7D6T3RbBvoBlz`-SIN zZgL4Ox3!Gpk~ULsQd?-A$I@IH$POA&!s$xPV025GY}C&N^)D{`8tDYV@ZqT2`EcU9 zd%EF>v7g178pI$F~ACrgS2kNq#cSiXWrd++bd3VyN4l(|m9NGC0H%M+p86px$hj11| zMF*fB~eb*W2w_?uwXx@_6Hcn_ZvtpRVX;fyCbsfFM2=9SZ^;UOr$6V^_Rk^lP1bxr4=gF?+V3j_jx)uHWz5?sH;PB#|!l$Ci(dJK016a{pS*UXY)sq2gKeiNS~0Vvob*@JX>-$r@$g3SF7#8ul$K^Oy1pD zd~))*-v^QX34H$2NtW(iHblOLD~xv!?BQUK>Q>Y7)D8|bh~=C|XD$`YoWa9wd(4D0 z7D}XQZVbqUk6F9fU`3Cfol05lp`o%bqg$A2v@2-?#@FvMJBSvo5+7;}G~QhxVdumi&X1xaW3<#(dPvp3N4pUk zQEd7e_QzXQ$IXxUPWm}7e`=G$ec|mc0RBUJoh^WFFkrYwUPwaLP!m;Gg|-Hg|3hkLudHZ*=qe*6A`{Y(m5U%Yq-x7Q+@=6f0JI ztF|d0wMK_Y?kJJ@{)gmQ)maldS@TNE#L}zE{H#W&h zKlp<>M#mrmHoPc3AA^16k7{PE5%T0hhxemswkCb32wi()V7Vckarrt`wYU9H&d$Ys zvxTZ8hwB9y_seF-f=KfLzo5tA>DqEOi>^q$s~yQVv|UW--EKcG%5)8d8oDuQ^ZELt zH;sO~4);9_t=%H?z?WB?KthfQ_llPy5}pg0IvwzaUyj2)(-Y7e_CiI<)a9mu^vo~! zou8V^%%kz>|1@&Oj*DnL^y?1cy@8Qay0u$LwfYF@>tV&FfZQ^E0g+m$xx8B1?z-DU zYNd7WMaNwDchUV`F_sMBwn=4UW0*|=G#TD_vSW4{>`T&8$RO}t?lIbqtr3<0@`goB z2U0i~7sVCnbWRv6t$b8-82}!1``Gq?c!CC84lg9mlq5!sZ+X3W@*ea}G;hKZ-4RL- z)7VjOZGD`jobuta-id{qb~}!#m9vbRkGekiS29q`PFnlWO_Q%$f4rf3XZK#&<38U| zjsbNJWz@Qzq}po@&`^i{;@-t;)#KY6i?v+ci*QaxW>CrQZ^uVD5<6&aI=lWXsr8aD z=|o22{HAaM*!|sf31wyFqnXT;m}t36v(Y%-a=j@#x+F>*vHizT+y{qjXGiw=+{Bal zDBP_{U!`k*KN1c^y!CmD+jd^~>%Oz{sjb<2uL=ivzRgmLnU>{~eCs)kHOp5?_pMJi z=8w?TFz45C?f=3=ZC9ESeZpqeiBtJ)ZEf*1SC9MHfoO4RapUGn?f1Jpx6(P(a;M#+ z^HV3Y+NjdPK)T*rmYKZ2UhkKGPufGV8Tu&D%D%emv_rmQ>XCh-br#<$&&tt2yD>R{ zkk@y95%^w?d$0cHL}n?MKHe~dHmli4gwnO z{TQm#)~pQnk$bcg5-WT}&$TbxmKRf5ZF%`H{xh*0@{_WAxW?b8^DhSJ(M=)8q#AQc zzvgeua-hk^B2yrTeaizyx%WAL&t((C__;*;gXtjKN>k@2n2bx$kh?rG?M(842hxfq`YLX%jZ#`$s#v}1 z|ARmQzgtGVHRZ~cRTN({z568MSEmV8+1TluqGIeq*RL6kxvMQuY3pv}`-FLL?LjaYYSA1pwYddmgO=I$*%C{oDw}O$*U!d8s>i z(Q0)XGRmIhmQ~$NPP>^0@7ErBZ9T?Dk8R)yy{NQeA9GK0%RzcZwF8Q~q@AF>t^(Gm zWVk}&=n<6cYGZRd|K4PPtn{&CI=zugGvoZHJyZ_wwF4FxUCQrAhJ+96PmcTbCuiO0 zZVCG+JM_9OPcb90s50u^*V=>Sl-_T=UHV|}eumd?pV9WGbH21#PWR{YxwBoSnj_mO zxE-rcWz40D6m(5~rPeO>WD3W0!r9ujg;^(`N~9btcP+ug(!pG&|C4+$>Y)W6T^nF0 z;GH~Ql!=Z$H}a7Yk9w=cWOvkltgb=VQ6M8QqhTJL1TW``TgHdhLQy_bW$)CkK1xPj zV|>(oGN#k5=>I(1ZnhYlBM(=q^>@F;aC6(VuRQtWnl`#_X~)l4`YjyuQ~OE0yZoJl z=~roIHzw5G&LeGN>)-hCZimjvD<%7FRTae8BTKV!!|^jVQ8xgu%Z*`UKKYv(NAWw8 zt|lpOl?j*}_MRpkyq^h+#DOJG`LImAbrTXc>d>yqdOLJMin2;i{3~PonmCSH-CyS@Bel@CC>fF zkq-T9H}0}t!~0JZ;U>zear`^4c4M7nsg8!`W;Aites6wyCo{MZtK;!{ajd>(-pECN ztUvQ`H_ECrr;@${x*)vCnJYKXpzn)6?K!xeH@o}$H+S|Q@7*u{>-IJE+3$oEh6H{o z3{&6e5-~2CA18H$BY#opf(Igj%br+alax!0SvXUYNTxAS1OWbnd!K!SaDxIYrcW&u zRNr{^a-3+i+D>Y%H`|wFs;*M~(#B`1Mp?AlrEMlDe4h1JRohh+t~y=#v&$^M1%kxY z%k=JSq=X&5uiILhANen=wwBfoTU!^orDXjm-a@4HH3u5r-Fr>k`x7^!v9;OhcWYC8 z_xI@1`9S1tQ$~<5IUAMx^Y1!T5-Em5n$hGIhb%;6Bqqk#yMO7g$T8`9cPhiHB=C}O zrEe6c@+MC>G+OklK^{H^lzCjO5XxiXFzkt{SqrmGjTCd}JFS1`tLTS#R{d8f_DywE zq7tFe3A?)&F23X=zWSK&fJRnDT6V^<8!Q!DdIgUH0D3^ zKNa@otKMv}a#-vSdgm|lvp?{+{o<};H<3xv)Ooo?RA&wgc&cj>81rfT8|LFb7u`LJ zFW<*ENI7Mdf>m#(Q(nKm901mG9A!&{c0U9>e({-><$SkqQtcl39=`}~KF-ObZ)eHV zS06F%kN)?@n_JUIxY2fK{jj%yF2maxj?&nCa7S*N1Fl%MQ{T>^&nepgo>P15?G6ek L;0yo&00000%_tA1 literal 0 HcmV?d00001 diff --git a/src/main/resources/overdrive_that_matters.mixins.json b/src/main/resources/overdrive_that_matters.mixins.json index 1ff29e66e..c0527a2d9 100644 --- a/src/main/resources/overdrive_that_matters.mixins.json +++ b/src/main/resources/overdrive_that_matters.mixins.json @@ -8,6 +8,7 @@ "mixins": [ "MixinPatchProjectileFinder", "MixinLivingEntity", - "MixinAnvilBlock" + "MixinAnvilBlock", + "MixinAbstractHurtingProjectile" ] } From bd9ec5f4a39ac44a3109d3215bb348270a0ecb7f Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Mon, 27 Feb 2023 21:31:56 +0300 Subject: [PATCH 0257/1199] =?UTF-8?q?=D0=B2=D1=8B=20=D0=BD=D0=B5=20=D1=82?= =?UTF-8?q?=D1=83=D0=B4=D0=B0=20=D1=88=D1=83=D1=82=D0=B8=D1=82=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/datagen/advancements/AndroidAdvancementsData.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt index 2fedfdf91..b560066f9 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt @@ -228,8 +228,8 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .parent(researchAnything) .display( itemStack = ItemStack(MItems.MATTER_TRANSFORM_MATRIX), - title = translation.add("nanobots", "Nanomachines, Son!") { - russian("Наномашины, дитя!") + title = translation.add("nanobots", "Nanomachines, son.") { + russian("Наномашины, сынок.") }, description = translation.add("nanobots.desc", "Research Nanobots as Android, to unlock potent research that come after it") { russian("Исследуйте наномашины за андроида, для разблокировки очень больших возможностей") From b142faaac359afc74e965e8f05fd71e707f414d7 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 28 Feb 2023 08:35:42 +0700 Subject: [PATCH 0258/1199] build number in jar name --- build.gradle.kts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 18a4cca4a..84e10ceca 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -29,7 +29,7 @@ configurations { get("implementation").extendsFrom(get("library"), get("klibrary")) } -data class GitInfo(val version: String, val count: String, val tag: String) { +data class GitInfo(val version: String, val count: String, val tag: String, val buildNumber: String) { // val tagIsVersion: Boolean get() = tag != "" && tag.matches(Regex("v[0-9]+\\.[0-9]\\.[0-9]")) val publishVersion: String get() { @@ -40,16 +40,18 @@ data class GitInfo(val version: String, val count: String, val tag: String) { } val jarName: String get() { + val buildNumber = if (buildNumber != "") "-$buildNumber" else "" + if (tag != "") - return "$mod_version-$version" + return "$mod_version-$version$buildNumber" // if (count != "") // return "$mod_version-SNAPSHOT-${version}_$count" if (version != "") { - return "$mod_version-SNAPSHOT-$version" + return "$mod_version-SNAPSHOT-$version$buildNumber" } else { - return "$mod_version-SNAPSHOT" + return "$mod_version-SNAPSHOT$buildNumber" } } @@ -65,7 +67,7 @@ data class GitInfo(val version: String, val count: String, val tag: String) { } } -val gitVersion = getCommitVersion() ?: GitInfo("", "", "") +val gitVersion = getCommitVersion() ?: GitInfo("", "", "", "") version = gitVersion.modVersion group = "ru.dbotthepony" @@ -102,7 +104,7 @@ fun getCommitVersion(): GitInfo? { val tag = tagStream.array.copyOfRange(0, tagStream.length).toString(Charsets.UTF_8).trim() val count = countStream.array.copyOfRange(0, countStream.length).toString(Charsets.UTF_8).trim() - return GitInfo(version, count, tag) + return GitInfo(version, count, tag, System.getenv("BUILD_NUMBER") ?: "") } catch(err: Throwable) { println("Error getting git version") println(err) From 8319b7c26de80fa541008e68acc1178b8f0ea98d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 28 Feb 2023 17:27:39 +0700 Subject: [PATCH 0259/1199] =?UTF-8?q?YuRaNnNzZZ=20=E2=80=94=20=D0=A1=D0=B5?= =?UTF-8?q?=D0=B3=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=2015:51=20=D0=BE=D0=BD?= =?UTF-8?q?=20=D0=BF=D1=80=D0=B8=20=D1=80=D0=B5=D0=BF=D0=BB=D0=B8=D0=BA?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D0=B8=20=D0=B1=D0=B5=D1=80=D1=91=D1=82=20?= =?UTF-8?q?=D0=BA=D0=B0=D0=BA=D0=BE=D0=B5-=D1=82=D0=BE=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BB=D0=B8=D1=87=D0=B5=D1=81=D1=82=D0=B2=D0=BE=20=D0=B8=20?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D0=B0=D0=B2=D0=BB=D1=8F=D0=B5=D1=82=20=D0=BF?= =?UTF-8?q?=D0=BE=D1=81=D0=BB=D0=B5=20=D1=80=D0=B5=D0=BF=D0=BB=D0=B8=D0=BA?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../otm/block/entity/matter/MatterReplicatorBlockEntity.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index af96a49f5..1b356d032 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -210,7 +210,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } override fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: ReplicatorJob): Status { - val drainPerTick = currentJob!!.matterPerTick * ticksAdvanced + val drainPerTick = job.matterPerTick * ticksAdvanced val graph = matterNode.graph as MatterNetworkGraph? ?: return Status.FAILURE_WAIT_FAST if (matter.extractMatterInner(drainPerTick, true) < drainPerTick) { @@ -233,7 +233,9 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } else { // в тик требуется меньше материи, чем её может хранить репликатор // примем из сети недостающее количество бака материи, или 200 тиков репликации, что меньше - val drain = graph.extractMatter(matter.missingMatter.coerceAtMost(drainPerTick * DRAIN_MULT), true) + val drain = graph.extractMatter(matter.missingMatter + .coerceAtMost(drainPerTick * DRAIN_MULT) + .coerceAtMost(job.matterPerTick * (job.ticks - workTicks - ticksAdvanced)), true) if (drain.isZero) { // в сети нет материи From 7364f7d2d81099183eeee606a224d977a1e2542c Mon Sep 17 00:00:00 2001 From: GearShocky Date: Thu, 2 Mar 2023 05:41:13 +0600 Subject: [PATCH 0260/1199] Tritanium shield, exosuit upgrade modules texture update --- .../models/item/tritanium_shield.json | 147 ++++++++++++++++++ .../item/tritanium_shield_blocking.json | 139 +++++++++++++++++ .../textures/block/tritanium_anvil.png | Bin 0 -> 500 bytes .../textures/block/tritanium_anvil_top.png | Bin 0 -> 461 bytes .../item/exosuit_crafting_upgrade.png | Bin 243 -> 273 bytes .../item/exosuit_inventory_upgrade.png | Bin 245 -> 279 bytes .../exosuit_inventory_upgrade_creative.png | Bin 236 -> 290 bytes 7 files changed, 286 insertions(+) create mode 100644 src/main/resources/assets/overdrive_that_matters/models/item/tritanium_shield.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/item/tritanium_shield_blocking.json create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/tritanium_anvil.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/tritanium_anvil_top.png diff --git a/src/main/resources/assets/overdrive_that_matters/models/item/tritanium_shield.json b/src/main/resources/assets/overdrive_that_matters/models/item/tritanium_shield.json new file mode 100644 index 000000000..2a49c326d --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/item/tritanium_shield.json @@ -0,0 +1,147 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [64, 64], + "textures": { + "0": "overdrive_that_matters:item/tritanium_shield", + "particle": "overdrive_that_matters:item/tritanium_shield" + }, + "elements": [ + { + "from": [5, 7, 5], + "to": [11, 9, 11], + "faces": { + "north": {"uv": [8, 1.5, 8.5, 3], "rotation": 90, "texture": "#0"}, + "east": {"uv": [8, 0, 8.5, 1.5], "rotation": 90, "texture": "#0"}, + "south": {"uv": [10, 1.5, 10.5, 3], "rotation": 90, "texture": "#0"}, + "west": {"uv": [8.5, 0, 9, 1.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [10, 3, 8.5, 1.5], "texture": "#0"}, + "down": {"uv": [8, 1.5, 6.5, 3], "texture": "#0"} + } + }, + { + "from": [11, 2, -3], + "to": [12, 14, 19], + "faces": { + "north": {"uv": [0.25, 0.25, 3.25, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0.25, 0.25, 3.25, 5.75], "rotation": 90, "texture": "#0"}, + "south": {"uv": [3.25, 0, 6.25, 0.25], "rotation": 90, "texture": "#0"}, + "west": {"uv": [3.5, 0.25, 6.5, 5.75], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0.25, 5.75, 0, 0.25], "rotation": 180, "texture": "#0"}, + "down": {"uv": [3.5, 0.25, 3.25, 5.75], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [11.6, 12, -4], + "to": [12.6, 13, 20], + "faces": { + "north": {"uv": [0, 9.5, 0.25, 9.75], "texture": "#0"}, + "east": {"uv": [0, 9.75, 0.25, 15.75], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 15.75, 0.25, 16], "texture": "#0"}, + "west": {"uv": [0, 9.75, 0.25, 15.75], "rotation": 90, "texture": "#0"}, + "up": {"uv": [0, 9.75, 0.25, 15.75], "texture": "#0"}, + "down": {"uv": [0, 9.75, 0.25, 15.75], "texture": "#0"} + } + }, + { + "from": [11.6, 3, -4], + "to": [12.6, 4, 20], + "faces": { + "north": {"uv": [0, 9.5, 0.25, 9.75], "texture": "#0"}, + "east": {"uv": [0, 9.75, 0.25, 15.75], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 15.75, 0.25, 16], "texture": "#0"}, + "west": {"uv": [0, 9.75, 0.25, 15.75], "rotation": 90, "texture": "#0"}, + "up": {"uv": [0, 9.75, 0.25, 15.75], "texture": "#0"}, + "down": {"uv": [0, 9.75, 0.25, 15.75], "texture": "#0"} + } + }, + { + "from": [11.6, 4, -1.1], + "to": [12.6, 12, -0.1], + "faces": { + "north": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "west": {"uv": [0, 0, 0.25, 2], "texture": "#missing"}, + "up": {"uv": [0, 0, 0.25, 0.25], "texture": "#missing"}, + "down": {"uv": [0, 0, 0.25, 0.25], "texture": "#missing"} + } + }, + { + "from": [11.6, 4, -3.1], + "to": [12.6, 12, -2.1], + "faces": { + "north": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "west": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "up": {"uv": [0, 0, 0.25, 0.25], "texture": "#missing"}, + "down": {"uv": [0, 0, 0.25, 0.25], "texture": "#missing"} + } + }, + { + "from": [11.6, 4, 16.1], + "to": [12.6, 12, 17.1], + "faces": { + "north": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "west": {"uv": [0, 0, 0.25, 2], "texture": "#missing"}, + "up": {"uv": [0, 0, 0.25, 0.25], "texture": "#missing"}, + "down": {"uv": [0, 0, 0.25, 0.25], "texture": "#missing"} + } + }, + { + "from": [11.6, 4, 18.1], + "to": [12.6, 12, 19.1], + "faces": { + "north": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "west": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "up": {"uv": [0, 0, 0.25, 0.25], "texture": "#missing"}, + "down": {"uv": [0, 0, 0.25, 0.25], "texture": "#missing"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [90, 0, 0], + "translation": [0, -2, 4] + }, + "thirdperson_lefthand": { + "rotation": [90, 0, 180], + "translation": [0, -2, 4] + }, + "firstperson_righthand": { + "rotation": [90, -5, -90], + "translation": [-1.75, -7, 4] + }, + "firstperson_lefthand": { + "rotation": [90, -5, 90], + "translation": [-1.75, -7, 4] + }, + "ground": { + "rotation": [90, 0, 0], + "translation": [0, 3, 0], + "scale": [0.5, 0.5, 0.5] + }, + "gui": { + "rotation": [91, -9, 115], + "translation": [1, -0.25, 0], + "scale": [0.65, 0.65, 0.65] + }, + "fixed": { + "rotation": [90, 0, -90], + "translation": [0, 0, 0.5], + "scale": [0.5, 0.5, 0.5] + } + }, + "overrides": [ + { + "predicate": { + "blocking": 1 + }, + "model": "overdrive_that_matters:item/tritanium_shield_blocking" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/item/tritanium_shield_blocking.json b/src/main/resources/assets/overdrive_that_matters/models/item/tritanium_shield_blocking.json new file mode 100644 index 000000000..ee8421417 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/item/tritanium_shield_blocking.json @@ -0,0 +1,139 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [64, 64], + "textures": { + "0": "overdrive_that_matters:item/tritanium_shield", + "particle": "overdrive_that_matters:item/tritanium_shield" + }, + "elements": [ + { + "from": [5, 7, 5], + "to": [11, 9, 11], + "faces": { + "north": {"uv": [8, 1.5, 8.5, 3], "rotation": 90, "texture": "#0"}, + "east": {"uv": [8, 0, 8.5, 1.5], "rotation": 90, "texture": "#0"}, + "south": {"uv": [10, 1.5, 10.5, 3], "rotation": 90, "texture": "#0"}, + "west": {"uv": [8.5, 0, 9, 1.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [10, 3, 8.5, 1.5], "texture": "#0"}, + "down": {"uv": [8, 1.5, 6.5, 3], "texture": "#0"} + } + }, + { + "from": [11, 2, -3], + "to": [12, 14, 19], + "faces": { + "north": {"uv": [0.25, 0.25, 3.25, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0.25, 0.25, 3.25, 5.75], "rotation": 90, "texture": "#0"}, + "south": {"uv": [3.25, 0, 6.25, 0.25], "rotation": 90, "texture": "#0"}, + "west": {"uv": [3.5, 0.25, 6.5, 5.75], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0.25, 5.75, 0, 0.25], "rotation": 180, "texture": "#0"}, + "down": {"uv": [3.5, 0.25, 3.25, 5.75], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [11.6, 12, -4], + "to": [12.6, 13, 20], + "faces": { + "north": {"uv": [0, 9.5, 0.25, 9.75], "texture": "#0"}, + "east": {"uv": [0, 9.75, 0.25, 15.75], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 15.75, 0.25, 16], "texture": "#0"}, + "west": {"uv": [0, 9.75, 0.25, 15.75], "rotation": 90, "texture": "#0"}, + "up": {"uv": [0, 9.75, 0.25, 15.75], "texture": "#0"}, + "down": {"uv": [0, 9.75, 0.25, 15.75], "texture": "#0"} + } + }, + { + "from": [11.6, 4, 18.1], + "to": [12.6, 12, 19.1], + "faces": { + "north": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "west": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "up": {"uv": [0, 0, 0.25, 0.25], "texture": "#missing"}, + "down": {"uv": [0, 0, 0.25, 0.25], "texture": "#missing"} + } + }, + { + "from": [11.6, 3, -4], + "to": [12.6, 4, 20], + "faces": { + "north": {"uv": [0, 9.5, 0.25, 9.75], "texture": "#0"}, + "east": {"uv": [0, 9.75, 0.25, 15.75], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 15.75, 0.25, 16], "texture": "#0"}, + "west": {"uv": [0, 9.75, 0.25, 15.75], "rotation": 90, "texture": "#0"}, + "up": {"uv": [0, 9.75, 0.25, 15.75], "texture": "#0"}, + "down": {"uv": [0, 9.75, 0.25, 15.75], "texture": "#0"} + } + }, + { + "from": [11.6, 4, 16.1], + "to": [12.6, 12, 17.1], + "faces": { + "north": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "west": {"uv": [0, 0, 0.25, 2], "texture": "#missing"}, + "up": {"uv": [0, 0, 0.25, 0.25], "texture": "#missing"}, + "down": {"uv": [0, 0, 0.25, 0.25], "texture": "#missing"} + } + }, + { + "from": [11.6, 4, -1.1], + "to": [12.6, 12, -0.1], + "faces": { + "north": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "west": {"uv": [0, 0, 0.25, 2], "texture": "#missing"}, + "up": {"uv": [0, 0, 0.25, 0.25], "texture": "#missing"}, + "down": {"uv": [0, 0, 0.25, 0.25], "texture": "#missing"} + } + }, + { + "from": [11.6, 4, -3.1], + "to": [12.6, 12, -2.1], + "faces": { + "north": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "west": {"uv": [0.25, 10, 2.25, 10.25], "rotation": 90, "texture": "#0"}, + "up": {"uv": [0, 0, 0.25, 0.25], "texture": "#missing"}, + "down": {"uv": [0, 0, 0.25, 0.25], "texture": "#missing"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [90, 39, -40], + "translation": [1, -2, 0] + }, + "thirdperson_lefthand": { + "rotation": [90, 0, 180], + "translation": [0, -2, 4] + }, + "firstperson_righthand": { + "rotation": [90, -5, -90], + "translation": [-1.75, -7, 4] + }, + "firstperson_lefthand": { + "rotation": [90, -5, 90], + "translation": [-1.75, -7, 4] + }, + "ground": { + "rotation": [90, 0, 0], + "translation": [0, 3, 0], + "scale": [0.5, 0.5, 0.5] + }, + "gui": { + "rotation": [91, -9, 115], + "translation": [1, -0.25, 0], + "scale": [0.65, 0.65, 0.65] + }, + "fixed": { + "rotation": [90, 0, -90], + "translation": [0, 0, 0.5], + "scale": [0.5, 0.5, 0.5] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/tritanium_anvil.png b/src/main/resources/assets/overdrive_that_matters/textures/block/tritanium_anvil.png new file mode 100644 index 0000000000000000000000000000000000000000..3d489f5fa1e0560ff213168fbf19a4eadcf7414b GIT binary patch literal 500 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyjKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCilI0(?STO-)ThLP8P}64cbxV)LtVoBGT9XE)AT5t5QCCnx6~60NPRomSZb zR9@>h5vZGiuO!GX_&+jWa6NG61W<;vz$3C4sNgUNGak=hkpgsprKgKyh=u>!NwUrF|YtjOWlfJ#$8-M*d|Bo1+Z!_#KGObuuQQPaeK%lkD*u!3Er`Qg{N!i8PIm*rSARpcgKP!HJEIVbO7wZr`B6HeED zzp&uJUFT`X7rEJR+z?K!Nb2|easA!g4Gor!hI2A^wzI0t2>sEYzK@^VgX4eU#^m;! z|79I#{JH;7DgA$WMf;ck9u`7mEgY5M_phxtyKmRTPEx4PsxmNfjo@$KWR te-AZw$$URxengASHII?g{>{6;+<~v;ygy{!=LQBJgQu&X%Q~loCIB>X#FPL4 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/exosuit_crafting_upgrade.png b/src/main/resources/assets/overdrive_that_matters/textures/item/exosuit_crafting_upgrade.png index 14e1e9fe3f3388cedeecc511846bd31d50791a99..ab31babfcfb3ef91c8486ceb9a67ad44cf1a620b 100644 GIT binary patch delta 216 zcmey&IFV_BW4&B}Pl#(^VBm@sD{kJrdC&I0n3z~oQ?y!pa(=^qpKhVQJ>m2A?U%PgaSRx)_H`njxg HN@xNA1>94e delta 165 zcmbQp^qFyjqos6!Pl#(^V4#?oSbcr{J=_0>O&=5#6!`pSFf}!0U|?W*y88u?;w%aB z3;quU48i^tLKEvG5`8>f978mMOS>KU4k&Q2xTZe+udm0;eM`;n+o6<ug23uxud}BVa{DX9X;!XBAow_I8YgAkvHx?#-V_@%OF$(_4^a^Mj NgQu&X%Q~loCIIG2L!STu diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/exosuit_inventory_upgrade.png b/src/main/resources/assets/overdrive_that_matters/textures/item/exosuit_inventory_upgrade.png index 193a436a51169329bbf4d667e38189e4c9329b56..4d127ba2c6491e8628f4ba2b36390b382ba1777b 100644 GIT binary patch delta 201 zcmey$IGt&NqoZPgPl#(^VBm@sD{kJrdD!&9J=_0cVq#5AO{S)%YHDge{~3VbU~KC< zAjMr0$`ba4#P2#!4$DAb_9!4j~*<-bl`PxcwDh<)AUAos`njxgN@xNAm3ma# delta 188 zcmbQv^p$afW4&B}Pl#(^V4#?oSbcqcK|#S`(+Br#|NH!B2n!1{H8o{mU}*AHYy(nU zB|(0{|6zb((;1!fKvB*DkH}&M2EP3u%xJ+HtO6AD@^oz;VRkmDd0N z8@d(VTFg7MQab3P_@hmW6t}hJCnoEgw*A$UN=YnJVaPj}evg?e^`dk_plkgaSXOP%{jmUOEQ6=3pUXO@geCx_mPmsD diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/exosuit_inventory_upgrade_creative.png b/src/main/resources/assets/overdrive_that_matters/textures/item/exosuit_inventory_upgrade_creative.png index 81826e77f3802ac1341d073359d930084d370cde..e81bd8a990ac6cbf65175981a93a71d7838b9c28 100644 GIT binary patch delta 233 zcmaFExQJFSdvWgFuM>8tC#9u4jo-V$?re;UbMYrfXWp-V&pCHVi3zjuDdq({ zlT2V-aksoxDnXESM{W}5{Rh5kf{nTi6TW^;k|GI+ZBxvX}>h delta 179 zcmZ3)^oDVQW4%OxPl)S=RN)d0mcL))Z%r3IZ2I7y?SG&D3_!4dR~;je;wTC73;quQ z4ELJ%Mgqk+3p^r=85sEXgD|57Yp@DX(9_e!F+?MHZl5FH0R;}0g*Tr5w|}R^();q{ z&bJ0?UGg2L``RkZ{oepCH*QDbP0l+XkKiyla| From d91865417858db99781182b64db9622c3a026b00 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 2 Mar 2023 14:15:58 +0700 Subject: [PATCH 0261/1199] damn it --- src/main/java/ru/dbotthepony/mc/otm/mixin/MixinAnvilBlock.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinAnvilBlock.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinAnvilBlock.java index 799482713..6569a8cd6 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinAnvilBlock.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinAnvilBlock.java @@ -20,7 +20,7 @@ public class MixinAnvilBlock { for (int i = 0; i < list.size(); i++) { if (pState.is(list.get(i))) { - if (i == list.size()) { + if (i == list.size() - 1) { info.setReturnValue(null); } else { info.setReturnValue(list.get(i + 1).defaultBlockState().setValue(AnvilBlock.FACING, pState.getValue(AnvilBlock.FACING))); From 04f8da559bcdcbd761ea96cac80e1f5400056c78 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 2 Mar 2023 15:53:20 +0700 Subject: [PATCH 0262/1199] Add missing languagestrings to russian locale --- src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 83c468494..e1390b173 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -178,8 +178,8 @@ private fun misc(provider: MatteryLanguageProvider) { misc("dumping_matter_registry", "Выгружаю реестр материи в %s") misc("dumped_matter_registry", "Выгрузил реестр материи в %s") - misc("iteration", "Iteration %s") - misc("death_reason", "Decommissioned!") + misc("iteration", "Итерация %s") + misc("death_reason", "Списан!") misc("item.blackhole_immunity", "Нейтрализует гравитационные эффекты сингулярностей") From 0b74f5be272f57a65d277add3a7e6e9ee55c0764 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 2 Mar 2023 17:11:26 +0700 Subject: [PATCH 0263/1199] =?UTF-8?q?=D0=B3=D0=B8=D1=80=D1=88=D0=BE=D0=BA?= =?UTF-8?q?=D1=83=20=D0=BD=D1=83=D0=B6=D0=BD=D1=8B=20blockstate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/dbotthepony/mc/otm/datagen/DecorativeData.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt index d1e531f91..b135513aa 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.datagen import net.minecraft.resources.ResourceLocation +import net.minecraft.world.level.block.AnvilBlock import net.minecraft.world.level.block.SlabBlock import net.minecraft.world.level.block.StairBlock import net.minecraft.world.level.block.WallBlock @@ -38,6 +39,17 @@ fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelPr DataGen.decoratives(MRegistry.TRITANIUM_BLOCK) + for (anvil in MBlocks.TRITANIUM_ANVIL) { + blockStateProvider.exec { + blockStateProvider.getVariantBuilder(anvil).forAllStates { + ConfiguredModel.builder() + .modelFile(blockStateProvider.models().getExistingFile(modLocation("blocks/${anvil.registryName!!.path}"))) + .rotationY(it[AnvilBlock.FACING].yRotationBlockstateNorth()) + .build() + } + } + } + for ((color, block) in MRegistry.TRITANIUM_STAIRS.allBlocks) { DataGen.decorativeStairs(block as StairBlock, MRegistry.TRITANIUM_BLOCK.allBlocks[color]!!.registryName!!.path, MRegistry.TRITANIUM_BLOCK.allBlocks[color]!!.registryName!!.path) } From 193489021b2b467130086caef17bb8848e386f19 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Thu, 2 Mar 2023 17:51:54 +0600 Subject: [PATCH 0264/1199] Tritanium anvil model --- .../mc/otm/datagen/DecorativeData.kt | 2 +- .../mc/otm/datagen/items/ItemModels.kt | 6 + .../models/block/tritanium_anvil0.json | 197 +++++++++++++++++ .../models/block/tritanium_anvil1.json | 198 ++++++++++++++++++ .../models/block/tritanium_anvil2.json | 198 ++++++++++++++++++ .../models/block/tritanium_anvil3.json | 198 ++++++++++++++++++ .../models/block/tritanium_anvil4.json | 198 ++++++++++++++++++ .../models/block/tritanium_anvil5.json | 198 ++++++++++++++++++ .../models/block/tritanium_anvil6.json | 198 ++++++++++++++++++ .../textures/block/tritanium_anvil.png | Bin 500 -> 555 bytes .../textures/block/tritanium_anvil_top.png | Bin 461 -> 466 bytes 11 files changed, 1392 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil0.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil1.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil2.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil3.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil4.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil5.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil6.json diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt index b135513aa..0a40478ab 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt @@ -43,7 +43,7 @@ fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelPr blockStateProvider.exec { blockStateProvider.getVariantBuilder(anvil).forAllStates { ConfiguredModel.builder() - .modelFile(blockStateProvider.models().getExistingFile(modLocation("blocks/${anvil.registryName!!.path}"))) + .modelFile(blockStateProvider.models().getExistingFile(modLocation("block/${anvil.registryName!!.path}"))) .rotationY(it[AnvilBlock.FACING].yRotationBlockstateNorth()) .build() } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index ad6eeb407..ead8fb642 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -5,6 +5,7 @@ import net.minecraft.world.item.DyeColor import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.datagen.DataGen import ru.dbotthepony.mc.otm.datagen.modLocation +import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRegistry @@ -103,6 +104,7 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.block(MItems.TRITANIUM_TRAPDOOR[null]!!, "tritanium_trapdoor_bottom") + for (color in DyeColor.values()) provider.block(MItems.TRITANIUM_TRAPDOOR[color]!!, "tritanium_trapdoor_${color.name.lowercase()}_bottom") @@ -125,6 +127,10 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.block(MItems.STORAGE_IMPORTER) provider.block(MItems.STORAGE_EXPORTER) + for (item in MItems.TRITANIUM_ANVIL) { + provider.block(item) + } + for ((color, item) in MItems.CARGO_CRATE_MINECARTS) { provider.generated(item) } diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil0.json b/src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil0.json new file mode 100644 index 000000000..5e50a41ca --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil0.json @@ -0,0 +1,197 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [32, 32], + "textures": { + "3": "overdrive_that_matters:block/tritanium_anvil", + "particle": "overdrive_that_matters:block/tritanium_anvil" + }, + "elements": [ + { + "name": "Anvil base", + "from": [2, 0, 2], + "to": [14, 4, 14], + "faces": { + "north": {"uv": [0, 8, 6, 10], "texture": "#3"}, + "east": {"uv": [0, 10, 6, 8], "rotation": 180, "texture": "#3"}, + "south": {"uv": [0, 8, 6, 10], "texture": "#3"}, + "west": {"uv": [0, 8, 6, 10], "texture": "#3"}, + "up": {"uv": [1, 1, 7, 7], "rotation": 180, "texture": "#3"}, + "down": {"uv": [0, 10, 6, 16], "rotation": 180, "texture": "#3", "cullface": "down"} + } + }, + { + "name": "Wider section beneath top portion", + "from": [6, 5, 4], + "to": [10, 10, 12], + "faces": { + "north": {"uv": [3, 3, 5, 5.5], "texture": "#3"}, + "east": {"uv": [5, 2, 2.5, 6], "rotation": 270, "texture": "#3"}, + "south": {"uv": [3, 3, 5, 5.5], "texture": "#3"}, + "west": {"uv": [2.5, 2, 5, 6], "rotation": 90, "texture": "#3"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Lower narrow portion", + "from": [4, 4, 3], + "to": [12, 5, 13], + "faces": { + "north": {"uv": [2, 5.5, 6, 6], "texture": "#3"}, + "east": {"uv": [2.5, 1.5, 2, 6.5], "rotation": 270, "texture": "#3"}, + "south": {"uv": [2, 5.5, 6, 6], "texture": "#3"}, + "west": {"uv": [2, 1.5, 2.5, 6.5], "rotation": 90, "texture": "#3"}, + "up": {"uv": [2, 1.5, 6, 6.5], "rotation": 180, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Anvil top", + "from": [3, 10, 0], + "to": [13, 16, 16], + "faces": { + "north": {"uv": [11, 8, 16, 11], "texture": "#3"}, + "east": {"uv": [8, 0, 5, 8], "rotation": 270, "texture": "#3"}, + "south": {"uv": [11, 8, 16, 11], "rotation": 180, "texture": "#3"}, + "west": {"uv": [5, 0, 8, 8], "rotation": 90, "texture": "#3"}, + "up": {"uv": [11, 0, 16, 8], "rotation": 180, "texture": "#3"}, + "down": {"uv": [6, 11, 14, 16], "rotation": 90, "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [13, 10, 2], + "to": [14, 15, 4], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [13, 10, 12], + "to": [14, 15, 14], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 10, 12], + "to": [3, 15, 14], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 10, 2], + "to": [3, 15, 4], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 8, 12], + "to": [14, 10, 14], + "faces": { + "north": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "east": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "south": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "west": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "down": {"uv": [9, 3, 10, 9], "rotation": 90, "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 8, 2], + "to": [14, 10, 4], + "faces": { + "north": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "east": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "south": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "west": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "down": {"uv": [9, 3, 10, 9], "rotation": 90, "texture": "#3"} + } + }, + { + "name": "Lower narrow portion support", + "from": [5, 5, 6], + "to": [6, 8, 10], + "faces": { + "north": {"uv": [12, 1, 12.5, 2.5], "texture": "#3"}, + "east": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "south": {"uv": [14.5, 1, 15, 2.5], "texture": "#3"}, + "west": {"uv": [12.5, 1, 14.5, 2.5], "texture": "#3"}, + "up": {"uv": [12.5, 0.5, 14.5, 1], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Lower narrow portion support", + "from": [10, 5, 6], + "to": [11, 8, 10], + "faces": { + "north": {"uv": [12, 1, 12.5, 2.5], "texture": "#3"}, + "east": {"uv": [12.5, 1, 14.5, 2.5], "texture": "#3"}, + "south": {"uv": [14.5, 1, 15, 2.5], "texture": "#3"}, + "west": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "up": {"uv": [12.5, 0.5, 14.5, 1], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 225, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "scale": [0.5, 0.5, 0.5] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil1.json b/src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil1.json new file mode 100644 index 000000000..848b50a1a --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil1.json @@ -0,0 +1,198 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [32, 32], + "textures": { + "2": "overdrive_that_matters:block/tritanium_anvil_top", + "3": "overdrive_that_matters:block/tritanium_anvil", + "particle": "overdrive_that_matters:block/tritanium_anvil" + }, + "elements": [ + { + "name": "Anvil base", + "from": [2, 0, 2], + "to": [14, 4, 14], + "faces": { + "north": {"uv": [0, 8, 6, 10], "texture": "#3"}, + "east": {"uv": [0, 10, 6, 8], "rotation": 180, "texture": "#3"}, + "south": {"uv": [0, 8, 6, 10], "texture": "#3"}, + "west": {"uv": [0, 8, 6, 10], "texture": "#3"}, + "up": {"uv": [1, 1, 7, 7], "rotation": 180, "texture": "#3"}, + "down": {"uv": [0, 10, 6, 16], "rotation": 180, "texture": "#3", "cullface": "down"} + } + }, + { + "name": "Wider section beneath top portion", + "from": [6, 5, 4], + "to": [10, 10, 12], + "faces": { + "north": {"uv": [3, 3, 5, 5.5], "texture": "#3"}, + "east": {"uv": [5, 2, 2.5, 6], "rotation": 270, "texture": "#3"}, + "south": {"uv": [3, 3, 5, 5.5], "texture": "#3"}, + "west": {"uv": [2.5, 2, 5, 6], "rotation": 90, "texture": "#3"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Lower narrow portion", + "from": [4, 4, 3], + "to": [12, 5, 13], + "faces": { + "north": {"uv": [2, 5.5, 6, 6], "texture": "#3"}, + "east": {"uv": [2.5, 1.5, 2, 6.5], "rotation": 270, "texture": "#3"}, + "south": {"uv": [2, 5.5, 6, 6], "texture": "#3"}, + "west": {"uv": [2, 1.5, 2.5, 6.5], "rotation": 90, "texture": "#3"}, + "up": {"uv": [2, 1.5, 6, 6.5], "rotation": 180, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Anvil top", + "from": [3, 10, 0], + "to": [13, 16, 16], + "faces": { + "north": {"uv": [11, 8, 16, 11], "texture": "#3"}, + "east": {"uv": [8, 0, 5, 8], "rotation": 270, "texture": "#3"}, + "south": {"uv": [11, 8, 16, 11], "rotation": 180, "texture": "#3"}, + "west": {"uv": [5, 0, 8, 8], "rotation": 90, "texture": "#3"}, + "up": {"uv": [0, 0, 5, 8], "rotation": 180, "texture": "#2"}, + "down": {"uv": [6, 11, 14, 16], "rotation": 90, "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [13, 10, 2], + "to": [14, 15, 4], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [13, 10, 12], + "to": [14, 15, 14], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 10, 12], + "to": [3, 15, 14], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 10, 2], + "to": [3, 15, 4], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 8, 12], + "to": [14, 10, 14], + "faces": { + "north": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "east": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "south": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "west": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "down": {"uv": [9, 3, 10, 9], "rotation": 90, "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 8, 2], + "to": [14, 10, 4], + "faces": { + "north": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "east": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "south": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "west": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "down": {"uv": [9, 3, 10, 9], "rotation": 90, "texture": "#3"} + } + }, + { + "name": "Lower narrow portion support", + "from": [5, 5, 6], + "to": [6, 8, 10], + "faces": { + "north": {"uv": [12, 1, 12.5, 2.5], "texture": "#3"}, + "east": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "south": {"uv": [14.5, 1, 15, 2.5], "texture": "#3"}, + "west": {"uv": [12.5, 1, 14.5, 2.5], "texture": "#3"}, + "up": {"uv": [12.5, 0.5, 14.5, 1], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Lower narrow portion support", + "from": [10, 5, 6], + "to": [11, 8, 10], + "faces": { + "north": {"uv": [12, 1, 12.5, 2.5], "texture": "#3"}, + "east": {"uv": [12.5, 1, 14.5, 2.5], "texture": "#3"}, + "south": {"uv": [14.5, 1, 15, 2.5], "texture": "#3"}, + "west": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "up": {"uv": [12.5, 0.5, 14.5, 1], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 225, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "scale": [0.5, 0.5, 0.5] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil2.json b/src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil2.json new file mode 100644 index 000000000..e51b97f72 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil2.json @@ -0,0 +1,198 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [32, 32], + "textures": { + "2": "overdrive_that_matters:block/tritanium_anvil_top", + "3": "overdrive_that_matters:block/tritanium_anvil", + "particle": "overdrive_that_matters:block/tritanium_anvil" + }, + "elements": [ + { + "name": "Anvil base", + "from": [2, 0, 2], + "to": [14, 4, 14], + "faces": { + "north": {"uv": [0, 8, 6, 10], "texture": "#3"}, + "east": {"uv": [0, 10, 6, 8], "rotation": 180, "texture": "#3"}, + "south": {"uv": [0, 8, 6, 10], "texture": "#3"}, + "west": {"uv": [0, 8, 6, 10], "texture": "#3"}, + "up": {"uv": [1, 1, 7, 7], "rotation": 180, "texture": "#3"}, + "down": {"uv": [0, 10, 6, 16], "rotation": 180, "texture": "#3", "cullface": "down"} + } + }, + { + "name": "Wider section beneath top portion", + "from": [6, 5, 4], + "to": [10, 10, 12], + "faces": { + "north": {"uv": [3, 3, 5, 5.5], "texture": "#3"}, + "east": {"uv": [5, 2, 2.5, 6], "rotation": 270, "texture": "#3"}, + "south": {"uv": [3, 3, 5, 5.5], "texture": "#3"}, + "west": {"uv": [2.5, 2, 5, 6], "rotation": 90, "texture": "#3"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Lower narrow portion", + "from": [4, 4, 3], + "to": [12, 5, 13], + "faces": { + "north": {"uv": [2, 5.5, 6, 6], "texture": "#3"}, + "east": {"uv": [2.5, 1.5, 2, 6.5], "rotation": 270, "texture": "#3"}, + "south": {"uv": [2, 5.5, 6, 6], "texture": "#3"}, + "west": {"uv": [2, 1.5, 2.5, 6.5], "rotation": 90, "texture": "#3"}, + "up": {"uv": [2, 1.5, 6, 6.5], "rotation": 180, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Anvil top", + "from": [3, 10, 0], + "to": [13, 16, 16], + "faces": { + "north": {"uv": [11, 8, 16, 11], "texture": "#3"}, + "east": {"uv": [8, 0, 5, 8], "rotation": 270, "texture": "#3"}, + "south": {"uv": [11, 8, 16, 11], "rotation": 180, "texture": "#3"}, + "west": {"uv": [5, 0, 8, 8], "rotation": 90, "texture": "#3"}, + "up": {"uv": [5, 0, 10, 8], "rotation": 180, "texture": "#2"}, + "down": {"uv": [6, 11, 14, 16], "rotation": 90, "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [13, 10, 2], + "to": [14, 15, 4], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [13, 10, 12], + "to": [14, 15, 14], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 10, 12], + "to": [3, 15, 14], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 10, 2], + "to": [3, 15, 4], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 8, 12], + "to": [14, 10, 14], + "faces": { + "north": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "east": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "south": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "west": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "down": {"uv": [9, 3, 10, 9], "rotation": 90, "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 8, 2], + "to": [14, 10, 4], + "faces": { + "north": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "east": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "south": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "west": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "down": {"uv": [9, 3, 10, 9], "rotation": 90, "texture": "#3"} + } + }, + { + "name": "Lower narrow portion support", + "from": [5, 5, 6], + "to": [6, 8, 10], + "faces": { + "north": {"uv": [12, 1, 12.5, 2.5], "texture": "#3"}, + "east": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "south": {"uv": [14.5, 1, 15, 2.5], "texture": "#3"}, + "west": {"uv": [12.5, 1, 14.5, 2.5], "texture": "#3"}, + "up": {"uv": [12.5, 0.5, 14.5, 1], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Lower narrow portion support", + "from": [10, 5, 6], + "to": [11, 8, 10], + "faces": { + "north": {"uv": [12, 1, 12.5, 2.5], "texture": "#3"}, + "east": {"uv": [12.5, 1, 14.5, 2.5], "texture": "#3"}, + "south": {"uv": [14.5, 1, 15, 2.5], "texture": "#3"}, + "west": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "up": {"uv": [12.5, 0.5, 14.5, 1], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 225, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "scale": [0.5, 0.5, 0.5] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil3.json b/src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil3.json new file mode 100644 index 000000000..8eec83631 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil3.json @@ -0,0 +1,198 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [32, 32], + "textures": { + "2": "overdrive_that_matters:block/tritanium_anvil_top", + "3": "overdrive_that_matters:block/tritanium_anvil", + "particle": "overdrive_that_matters:block/tritanium_anvil" + }, + "elements": [ + { + "name": "Anvil base", + "from": [2, 0, 2], + "to": [14, 4, 14], + "faces": { + "north": {"uv": [0, 8, 6, 10], "texture": "#3"}, + "east": {"uv": [0, 10, 6, 8], "rotation": 180, "texture": "#3"}, + "south": {"uv": [0, 8, 6, 10], "texture": "#3"}, + "west": {"uv": [0, 8, 6, 10], "texture": "#3"}, + "up": {"uv": [1, 1, 7, 7], "rotation": 180, "texture": "#3"}, + "down": {"uv": [0, 10, 6, 16], "rotation": 180, "texture": "#3", "cullface": "down"} + } + }, + { + "name": "Wider section beneath top portion", + "from": [6, 5, 4], + "to": [10, 10, 12], + "faces": { + "north": {"uv": [3, 3, 5, 5.5], "texture": "#3"}, + "east": {"uv": [5, 2, 2.5, 6], "rotation": 270, "texture": "#3"}, + "south": {"uv": [3, 3, 5, 5.5], "texture": "#3"}, + "west": {"uv": [2.5, 2, 5, 6], "rotation": 90, "texture": "#3"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Lower narrow portion", + "from": [4, 4, 3], + "to": [12, 5, 13], + "faces": { + "north": {"uv": [2, 5.5, 6, 6], "texture": "#3"}, + "east": {"uv": [2.5, 1.5, 2, 6.5], "rotation": 270, "texture": "#3"}, + "south": {"uv": [2, 5.5, 6, 6], "texture": "#3"}, + "west": {"uv": [2, 1.5, 2.5, 6.5], "rotation": 90, "texture": "#3"}, + "up": {"uv": [2, 1.5, 6, 6.5], "rotation": 180, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Anvil top", + "from": [3, 10, 0], + "to": [13, 16, 16], + "faces": { + "north": {"uv": [11, 8, 16, 11], "texture": "#3"}, + "east": {"uv": [8, 0, 5, 8], "rotation": 270, "texture": "#3"}, + "south": {"uv": [11, 8, 16, 11], "rotation": 180, "texture": "#3"}, + "west": {"uv": [5, 0, 8, 8], "rotation": 90, "texture": "#3"}, + "up": {"uv": [10, 0, 15, 8], "rotation": 180, "texture": "#2"}, + "down": {"uv": [6, 11, 14, 16], "rotation": 90, "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [13, 10, 2], + "to": [14, 15, 4], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [13, 10, 12], + "to": [14, 15, 14], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 10, 12], + "to": [3, 15, 14], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 10, 2], + "to": [3, 15, 4], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 8, 12], + "to": [14, 10, 14], + "faces": { + "north": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "east": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "south": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "west": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "down": {"uv": [9, 3, 10, 9], "rotation": 90, "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 8, 2], + "to": [14, 10, 4], + "faces": { + "north": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "east": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "south": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "west": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "down": {"uv": [9, 3, 10, 9], "rotation": 90, "texture": "#3"} + } + }, + { + "name": "Lower narrow portion support", + "from": [5, 5, 6], + "to": [6, 8, 10], + "faces": { + "north": {"uv": [12, 1, 12.5, 2.5], "texture": "#3"}, + "east": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "south": {"uv": [14.5, 1, 15, 2.5], "texture": "#3"}, + "west": {"uv": [12.5, 1, 14.5, 2.5], "texture": "#3"}, + "up": {"uv": [12.5, 0.5, 14.5, 1], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Lower narrow portion support", + "from": [10, 5, 6], + "to": [11, 8, 10], + "faces": { + "north": {"uv": [12, 1, 12.5, 2.5], "texture": "#3"}, + "east": {"uv": [12.5, 1, 14.5, 2.5], "texture": "#3"}, + "south": {"uv": [14.5, 1, 15, 2.5], "texture": "#3"}, + "west": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "up": {"uv": [12.5, 0.5, 14.5, 1], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 225, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "scale": [0.5, 0.5, 0.5] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil4.json b/src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil4.json new file mode 100644 index 000000000..ab6d26a62 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil4.json @@ -0,0 +1,198 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [32, 32], + "textures": { + "2": "overdrive_that_matters:block/tritanium_anvil_top", + "3": "overdrive_that_matters:block/tritanium_anvil", + "particle": "overdrive_that_matters:block/tritanium_anvil" + }, + "elements": [ + { + "name": "Anvil base", + "from": [2, 0, 2], + "to": [14, 4, 14], + "faces": { + "north": {"uv": [0, 8, 6, 10], "texture": "#3"}, + "east": {"uv": [0, 10, 6, 8], "rotation": 180, "texture": "#3"}, + "south": {"uv": [0, 8, 6, 10], "texture": "#3"}, + "west": {"uv": [0, 8, 6, 10], "texture": "#3"}, + "up": {"uv": [1, 1, 7, 7], "rotation": 180, "texture": "#3"}, + "down": {"uv": [0, 10, 6, 16], "rotation": 180, "texture": "#3", "cullface": "down"} + } + }, + { + "name": "Wider section beneath top portion", + "from": [6, 5, 4], + "to": [10, 10, 12], + "faces": { + "north": {"uv": [3, 3, 5, 5.5], "texture": "#3"}, + "east": {"uv": [5, 2, 2.5, 6], "rotation": 270, "texture": "#3"}, + "south": {"uv": [3, 3, 5, 5.5], "texture": "#3"}, + "west": {"uv": [2.5, 2, 5, 6], "rotation": 90, "texture": "#3"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Lower narrow portion", + "from": [4, 4, 3], + "to": [12, 5, 13], + "faces": { + "north": {"uv": [2, 5.5, 6, 6], "texture": "#3"}, + "east": {"uv": [2.5, 1.5, 2, 6.5], "rotation": 270, "texture": "#3"}, + "south": {"uv": [2, 5.5, 6, 6], "texture": "#3"}, + "west": {"uv": [2, 1.5, 2.5, 6.5], "rotation": 90, "texture": "#3"}, + "up": {"uv": [2, 1.5, 6, 6.5], "rotation": 180, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Anvil top", + "from": [3, 10, 0], + "to": [13, 16, 16], + "faces": { + "north": {"uv": [11, 8, 16, 11], "texture": "#3"}, + "east": {"uv": [8, 0, 5, 8], "rotation": 270, "texture": "#3"}, + "south": {"uv": [11, 8, 16, 11], "rotation": 180, "texture": "#3"}, + "west": {"uv": [5, 0, 8, 8], "rotation": 90, "texture": "#3"}, + "up": {"uv": [0, 8, 5, 16], "rotation": 180, "texture": "#2"}, + "down": {"uv": [6, 11, 14, 16], "rotation": 90, "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [13, 10, 2], + "to": [14, 15, 4], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [13, 10, 12], + "to": [14, 15, 14], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 10, 12], + "to": [3, 15, 14], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 10, 2], + "to": [3, 15, 4], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 8, 12], + "to": [14, 10, 14], + "faces": { + "north": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "east": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "south": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "west": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "down": {"uv": [9, 3, 10, 9], "rotation": 90, "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 8, 2], + "to": [14, 10, 4], + "faces": { + "north": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "east": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "south": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "west": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "down": {"uv": [9, 3, 10, 9], "rotation": 90, "texture": "#3"} + } + }, + { + "name": "Lower narrow portion support", + "from": [5, 5, 6], + "to": [6, 8, 10], + "faces": { + "north": {"uv": [12, 1, 12.5, 2.5], "texture": "#3"}, + "east": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "south": {"uv": [14.5, 1, 15, 2.5], "texture": "#3"}, + "west": {"uv": [12.5, 1, 14.5, 2.5], "texture": "#3"}, + "up": {"uv": [12.5, 0.5, 14.5, 1], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Lower narrow portion support", + "from": [10, 5, 6], + "to": [11, 8, 10], + "faces": { + "north": {"uv": [12, 1, 12.5, 2.5], "texture": "#3"}, + "east": {"uv": [12.5, 1, 14.5, 2.5], "texture": "#3"}, + "south": {"uv": [14.5, 1, 15, 2.5], "texture": "#3"}, + "west": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "up": {"uv": [12.5, 0.5, 14.5, 1], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 225, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "scale": [0.5, 0.5, 0.5] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil5.json b/src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil5.json new file mode 100644 index 000000000..164a165d1 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil5.json @@ -0,0 +1,198 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [32, 32], + "textures": { + "2": "overdrive_that_matters:block/tritanium_anvil_top", + "3": "overdrive_that_matters:block/tritanium_anvil", + "particle": "overdrive_that_matters:block/tritanium_anvil" + }, + "elements": [ + { + "name": "Anvil base", + "from": [2, 0, 2], + "to": [14, 4, 14], + "faces": { + "north": {"uv": [0, 8, 6, 10], "texture": "#3"}, + "east": {"uv": [0, 10, 6, 8], "rotation": 180, "texture": "#3"}, + "south": {"uv": [0, 8, 6, 10], "texture": "#3"}, + "west": {"uv": [0, 8, 6, 10], "texture": "#3"}, + "up": {"uv": [1, 1, 7, 7], "rotation": 180, "texture": "#3"}, + "down": {"uv": [0, 10, 6, 16], "rotation": 180, "texture": "#3", "cullface": "down"} + } + }, + { + "name": "Wider section beneath top portion", + "from": [6, 5, 4], + "to": [10, 10, 12], + "faces": { + "north": {"uv": [3, 3, 5, 5.5], "texture": "#3"}, + "east": {"uv": [5, 2, 2.5, 6], "rotation": 270, "texture": "#3"}, + "south": {"uv": [3, 3, 5, 5.5], "texture": "#3"}, + "west": {"uv": [2.5, 2, 5, 6], "rotation": 90, "texture": "#3"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Lower narrow portion", + "from": [4, 4, 3], + "to": [12, 5, 13], + "faces": { + "north": {"uv": [2, 5.5, 6, 6], "texture": "#3"}, + "east": {"uv": [2.5, 1.5, 2, 6.5], "rotation": 270, "texture": "#3"}, + "south": {"uv": [2, 5.5, 6, 6], "texture": "#3"}, + "west": {"uv": [2, 1.5, 2.5, 6.5], "rotation": 90, "texture": "#3"}, + "up": {"uv": [2, 1.5, 6, 6.5], "rotation": 180, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Anvil top", + "from": [3, 10, 0], + "to": [13, 16, 16], + "faces": { + "north": {"uv": [11, 8, 16, 11], "texture": "#3"}, + "east": {"uv": [8, 0, 5, 8], "rotation": 270, "texture": "#3"}, + "south": {"uv": [11, 8, 16, 11], "rotation": 180, "texture": "#3"}, + "west": {"uv": [5, 0, 8, 8], "rotation": 90, "texture": "#3"}, + "up": {"uv": [5, 8, 10, 16], "rotation": 180, "texture": "#2"}, + "down": {"uv": [6, 11, 14, 16], "rotation": 90, "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [13, 10, 2], + "to": [14, 15, 4], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [13, 10, 12], + "to": [14, 15, 14], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 10, 12], + "to": [3, 15, 14], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 10, 2], + "to": [3, 15, 4], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 8, 12], + "to": [14, 10, 14], + "faces": { + "north": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "east": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "south": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "west": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "down": {"uv": [9, 3, 10, 9], "rotation": 90, "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 8, 2], + "to": [14, 10, 4], + "faces": { + "north": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "east": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "south": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "west": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "down": {"uv": [9, 3, 10, 9], "rotation": 90, "texture": "#3"} + } + }, + { + "name": "Lower narrow portion support", + "from": [5, 5, 6], + "to": [6, 8, 10], + "faces": { + "north": {"uv": [12, 1, 12.5, 2.5], "texture": "#3"}, + "east": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "south": {"uv": [14.5, 1, 15, 2.5], "texture": "#3"}, + "west": {"uv": [12.5, 1, 14.5, 2.5], "texture": "#3"}, + "up": {"uv": [12.5, 0.5, 14.5, 1], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Lower narrow portion support", + "from": [10, 5, 6], + "to": [11, 8, 10], + "faces": { + "north": {"uv": [12, 1, 12.5, 2.5], "texture": "#3"}, + "east": {"uv": [12.5, 1, 14.5, 2.5], "texture": "#3"}, + "south": {"uv": [14.5, 1, 15, 2.5], "texture": "#3"}, + "west": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "up": {"uv": [12.5, 0.5, 14.5, 1], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 225, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "scale": [0.5, 0.5, 0.5] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil6.json b/src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil6.json new file mode 100644 index 000000000..9118700b3 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/tritanium_anvil6.json @@ -0,0 +1,198 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [32, 32], + "textures": { + "2": "overdrive_that_matters:block/tritanium_anvil_top", + "3": "overdrive_that_matters:block/tritanium_anvil", + "particle": "overdrive_that_matters:block/tritanium_anvil" + }, + "elements": [ + { + "name": "Anvil base", + "from": [2, 0, 2], + "to": [14, 4, 14], + "faces": { + "north": {"uv": [0, 8, 6, 10], "texture": "#3"}, + "east": {"uv": [0, 10, 6, 8], "rotation": 180, "texture": "#3"}, + "south": {"uv": [0, 8, 6, 10], "texture": "#3"}, + "west": {"uv": [0, 8, 6, 10], "texture": "#3"}, + "up": {"uv": [1, 1, 7, 7], "rotation": 180, "texture": "#3"}, + "down": {"uv": [0, 10, 6, 16], "rotation": 180, "texture": "#3", "cullface": "down"} + } + }, + { + "name": "Wider section beneath top portion", + "from": [6, 5, 4], + "to": [10, 10, 12], + "faces": { + "north": {"uv": [3, 3, 5, 5.5], "texture": "#3"}, + "east": {"uv": [5, 2, 2.5, 6], "rotation": 270, "texture": "#3"}, + "south": {"uv": [3, 3, 5, 5.5], "texture": "#3"}, + "west": {"uv": [2.5, 2, 5, 6], "rotation": 90, "texture": "#3"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Lower narrow portion", + "from": [4, 4, 3], + "to": [12, 5, 13], + "faces": { + "north": {"uv": [2, 5.5, 6, 6], "texture": "#3"}, + "east": {"uv": [2.5, 1.5, 2, 6.5], "rotation": 270, "texture": "#3"}, + "south": {"uv": [2, 5.5, 6, 6], "texture": "#3"}, + "west": {"uv": [2, 1.5, 2.5, 6.5], "rotation": 90, "texture": "#3"}, + "up": {"uv": [2, 1.5, 6, 6.5], "rotation": 180, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Anvil top", + "from": [3, 10, 0], + "to": [13, 16, 16], + "faces": { + "north": {"uv": [11, 8, 16, 11], "texture": "#3"}, + "east": {"uv": [8, 0, 5, 8], "rotation": 270, "texture": "#3"}, + "south": {"uv": [11, 8, 16, 11], "rotation": 180, "texture": "#3"}, + "west": {"uv": [5, 0, 8, 8], "rotation": 90, "texture": "#3"}, + "up": {"uv": [10, 8, 15, 16], "rotation": 180, "texture": "#2"}, + "down": {"uv": [6, 11, 14, 16], "rotation": 90, "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [13, 10, 2], + "to": [14, 15, 4], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [13, 10, 12], + "to": [14, 15, 14], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 10, 12], + "to": [3, 15, 14], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 10, 2], + "to": [3, 15, 4], + "faces": { + "north": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "east": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "south": {"uv": [9, 0.5, 9.5, 3], "texture": "#3"}, + "west": {"uv": [8, 0.5, 9, 3], "texture": "#3"}, + "up": {"uv": [8, 0, 9, 0.5], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 8, 12], + "to": [14, 10, 14], + "faces": { + "north": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "east": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "south": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "west": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "down": {"uv": [9, 3, 10, 9], "rotation": 90, "texture": "#3"} + } + }, + { + "name": "Support frame", + "from": [2, 8, 2], + "to": [14, 10, 4], + "faces": { + "north": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "east": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "south": {"uv": [8, 3, 9, 9], "rotation": 90, "texture": "#3"}, + "west": {"uv": [9.5, 2, 10.5, 3], "texture": "#3"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "down": {"uv": [9, 3, 10, 9], "rotation": 90, "texture": "#3"} + } + }, + { + "name": "Lower narrow portion support", + "from": [5, 5, 6], + "to": [6, 8, 10], + "faces": { + "north": {"uv": [12, 1, 12.5, 2.5], "texture": "#3"}, + "east": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "south": {"uv": [14.5, 1, 15, 2.5], "texture": "#3"}, + "west": {"uv": [12.5, 1, 14.5, 2.5], "texture": "#3"}, + "up": {"uv": [12.5, 0.5, 14.5, 1], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + }, + { + "name": "Lower narrow portion support", + "from": [10, 5, 6], + "to": [11, 8, 10], + "faces": { + "north": {"uv": [12, 1, 12.5, 2.5], "texture": "#3"}, + "east": {"uv": [12.5, 1, 14.5, 2.5], "texture": "#3"}, + "south": {"uv": [14.5, 1, 15, 2.5], "texture": "#3"}, + "west": {"uv": [0, 0, 0, 0], "texture": "#3"}, + "up": {"uv": [12.5, 0.5, 14.5, 1], "rotation": 90, "texture": "#3"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#3"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 225, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "scale": [0.5, 0.5, 0.5] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/tritanium_anvil.png b/src/main/resources/assets/overdrive_that_matters/textures/block/tritanium_anvil.png index 3d489f5fa1e0560ff213168fbf19a4eadcf7414b..30c8ad6d68329c640fb3f98d30d71b7b3b33798a 100644 GIT binary patch delta 438 zcmV;n0ZIP!1FHm(UKVC~gj8g09v&V?R9h=6D*ylh4l#8ok#r@0!T3!)tl$>cw?~=Yi8b# zOl92%4dv!1&rauAP#_Z=F;6~Juz~~EL#(hnr25ERmW43Ogj`g42f)xJX$Rn zNs1?g2cWSJ*C9S05R(AF#gzm}ULjZnQIhClLjD4gWS(NqF=kMF=LcAqJ-BK`5EX-x zz>;-QrrohUxTqok_oOs@-pZZF+{(RYpiW2+8?a{}Ag|hgt`-p(2%g4;DcIM} zN*jWx3i@$jcYvx#ne<9v3lR;Ro8$QpPz+^2q}Ff1Spv|%j#{^#N$wX#D z0Xa!TK~y+Tt&-bv!ypVqg(4i{kpKVPo)yN%Gwnk=-5Fn^J!l1vnU%ujt~=M`@j+S1 znpxCsdp@7FZnf3`5Mi?f*{E+@QWVMn$}AQ0palpksD-~?F9EXzKwq_xcsL#CVY6iB z4L^2V9<5E_8q(!|H&Hbrc7LPWE;NHYZp_kL20+*E-g`!rU54*_W_rlAS6AcGu$eQ#|~isybtj26{7Y9)xum$F23C^ysU zT%KI+A0U@^%`iSPW!>}AHXSnwr@=LW{s}XJwjcoO1OmogQI8>W7t-5QHWM(!2gq#* zkay^CQ5klRvib{PoRh`~HOLfn1Fp|~`n(?QP5%Ha`XjJJEC+SzSHKSuC$S#XrFqoy czX3j00022a!yo{Ya)Na000ib0l1NC?EnA)BS}O-R5(wC zlYx?hAPhw91qku~Klt7T!JcKV&eXnk)=kL9<2YVFTrXfl=XqGET%{D-5rW3Ie%6xY zBKJuM+-h|_WRQDL3cpB#65i2T8-(~Km!MgXz`a3%^B@nA1T8zlvo%-QKa>su6z^et zo-}_1HM;(l>yttyIBz&NyD1h)z!8m-rQPH{>1q-;dcSGRL6ib3%s~!|+@cRcFz0UL zybqGVG9GH~2*KC5zY1nOEQ<#GPM&GH67m{s!GpLvV>|fziSI_y7nQnr>Go6!(oyH xx%ITb>jL#Ls3a}~&n?hWC*}Kq;QzSK^A`t!71({APDOoSk(Xj;3YtN5drC<>nlT!SCSt%gXg4fRqHcn1`N;q_i|p^8(}9t0^Q9+A)|P`ZhnZsB`C zpO=u!efQ9y;N3%($D&3&2-p*4cw&!9_}A{8uz)#%F`Q|+hXo{)@h zV~5%Q9YL7<-{B%>|95zY^#4eB{5Sf)gM>oxpDH4^z(+uzLTNc_NdL7&Zb5W_|Je5N sn*QM^x*YewH^eFiMQ#BJKkV-P3sLGGOYmyn3jhEB07*qoM6N<$g7$!;nE(I) From d151fd6727e88f8315ffde64d28ba8bae7576c48 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 2 Mar 2023 20:55:41 +0700 Subject: [PATCH 0265/1199] Display equipment in energy servo, display curios in android station --- .../client/screen/ExoPackInventoryScreen.kt | 41 ++-------- .../mc/otm/client/screen/MatteryScreen.kt | 25 +----- .../screen/panels/PlayerEquipmentPanel.kt | 81 +++++++++++++++++++ .../screen/tech/AndroidStationScreen.kt | 12 +-- .../client/screen/tech/EnergyServoScreen.kt | 24 ++++-- .../mc/otm/compat/curios/CuriosCompat.kt | 11 +-- .../mc/otm/menu/ExoPackInventoryMenu.kt | 22 +++-- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 41 ++++++++-- .../mc/otm/menu/tech/AndroidStationMenu.kt | 28 ++----- .../mc/otm/menu/tech/EnergyServoMenu.kt | 2 + 10 files changed, 171 insertions(+), 116 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/PlayerEquipmentPanel.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt index d7d107bf2..5c2d28a0c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt @@ -97,18 +97,13 @@ class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen 4) - ScrollbarBackgroundPanel.padded(this, frame, x, - width = curiosWidth, - height = curiosHeight, alwaysShowScrollbar = true) - else - BackgroundPanel.padded(this, frame, x, - width = curiosWidth, - height = curiosHeight) - - x -= curiosRect.width - curiosRect.x = x - - for ((slot, cosmetic) in menu.curiosSlots) { - val row = EditablePanel(this, if (curiosRect is ScrollbarBackgroundPanel) curiosRect.canvas else curiosRect, height = AbstractSlotPanel.SIZE) - row.dock = Dock.TOP - - SlotPanel(this, row, slot).dock = Dock.RIGHT - - if (cosmetic != null) { - SlotPanel(this, row, cosmetic).dock = Dock.LEFT - } - } + x -= curios.width + curios.x = x } EffectListPanel(this, frame, menu.ply, x - 56f, gridHeight = 6).tick() 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 41dee7093..1f7d24ad1 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 @@ -29,6 +29,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.util.ScrollBarConstants import ru.dbotthepony.mc.otm.compat.cos.CosmeticToggleButton import ru.dbotthepony.mc.otm.core.math.integerDivisionDown import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.menu.PlayerSlot import java.util.Collections /** @@ -583,30 +584,6 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } } - fun makeArmorStrip(slots: Collection>, parent: EditablePanel<*>? = null): EditablePanel<*> { - val armorSlotsStrip = EditablePanel(this, parent, width = 18f) - armorSlotsStrip.dock = Dock.LEFT - - for ((slot, cosmeticSlot) in slots) { - if (cosmeticSlot == null) { - SlotPanel(this, armorSlotsStrip, slot).also { - it.dock = Dock.TOP - } - } else { - FoldableSlotPanel(this, armorSlotsStrip, - SlotPanel(this, null, slot).also { - CosmeticToggleButton(this, it, slot.type) - }, - listOf(SlotPanel(this, null, cosmeticSlot)) - ).also { - it.dock = Dock.TOP - } - } - } - - return armorSlotsStrip - } - companion object { const val DEFAULT_FRAME_WIDTH = AbstractSlotPanel.SIZE * 9f + 16f const val DEFAULT_FRAME_HEIGHT = 100f diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/PlayerEquipmentPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/PlayerEquipmentPanel.kt new file mode 100644 index 000000000..08bb2fbc0 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/PlayerEquipmentPanel.kt @@ -0,0 +1,81 @@ +package ru.dbotthepony.mc.otm.client.screen.panels + +import net.minecraft.world.inventory.Slot +import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.FoldableSlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.BackgroundPanel +import ru.dbotthepony.mc.otm.compat.cos.CosmeticToggleButton +import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.menu.PlayerSlot + +fun > makeCuriosPanel(screen: S, parent: FramePanel, slots: List>, autoAlign: Boolean = false): EditablePanel? { + if (slots.isEmpty()) { + return null + } + + val curiosWidth = if (slots.any { it.cosmetic != null }) AbstractSlotPanel.SIZE * 2f else AbstractSlotPanel.SIZE + val curiosHeight = slots.size.coerceAtMost(4) * AbstractSlotPanel.SIZE + + val curiosRect = + if (slots.size > 4) + ScrollbarBackgroundPanel.padded(screen, parent, 0f, + width = curiosWidth, + height = curiosHeight, alwaysShowScrollbar = true) + else + BackgroundPanel.padded(screen, parent, 0f, + width = curiosWidth, + height = curiosHeight) + + if (autoAlign) { + curiosRect.x = -4f - curiosRect.width + } + + for ((slot, cosmetic) in slots) { + val row = EditablePanel(screen, if (curiosRect is ScrollbarBackgroundPanel) curiosRect.canvas else curiosRect, height = AbstractSlotPanel.SIZE) + row.dock = Dock.TOP + + SlotPanel(screen, row, slot).dock = Dock.RIGHT + + if (cosmetic != null) { + SlotPanel(screen, row, cosmetic).dock = Dock.LEFT + } + } + + return curiosRect +} + +@Suppress("LeakingThis") +open class PlayerEquipmentPanel>( + screen: S, + parent: EditablePanel<*>?, + x: Float = 0f, + y: Float = 0f, + val armorSlots: List> +) : EditablePanel(screen, parent, x, y, height = HEIGHT, width = WIDTH) { + val armorSlotsStrip = EditablePanel(screen, this, width = AbstractSlotPanel.SIZE) + val entityPanel = EntityRendererPanel(screen, this, minecraft.player!!) + + init { + entityPanel.dock = Dock.LEFT + armorSlotsStrip.dock = Dock.LEFT + + for ((slot, cosmeticSlot) in armorSlots) { + if (cosmeticSlot == null) { + SlotPanel(screen, armorSlotsStrip, slot).dock = Dock.TOP + } else { + FoldableSlotPanel(screen, armorSlotsStrip, + SlotPanel(screen, null, slot).also { CosmeticToggleButton(screen, it, slot.type) }, + listOf(SlotPanel(screen, null, cosmeticSlot))).dock = Dock.TOP + + } + } + } + + companion object { + val HEIGHT = EntityRendererPanel.ENTITY_RECTANGLE.height + val WIDTH = AbstractSlotPanel.SIZE + EntityRendererPanel.ENTITY_RECTANGLE.width + } +} 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 1d3fbfa6e..0ed9bbfad 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 @@ -707,17 +707,11 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I it.dockTop = 6f } - val playerStrip = EditablePanel(this, frame, height = 72f) + makeCuriosPanel(this, frame, menu.equipment.curiosSlots, autoAlign = true) + + val playerStrip = PlayerEquipmentPanel(this, frame, armorSlots = menu.equipment.armorSlots) playerStrip.dock = Dock.TOP - makeArmorStrip(menu.armorSlots, playerStrip).also { - it.dock = Dock.LEFT - } - - EntityRendererPanel(this, playerStrip, minecraft!!.player!!).also { - it.dock = Dock.LEFT - } - val androidStrip = EditablePanel(this, playerStrip, width = AbstractSlotPanel.SIZE) androidStrip.dock = Dock.LEFT diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt index 159c496cb..d3a0a114e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt @@ -7,9 +7,12 @@ import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.Dock +import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.PlayerEquipmentPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls +import ru.dbotthepony.mc.otm.client.screen.panels.makeCuriosPanel import ru.dbotthepony.mc.otm.client.screen.widget.HorizontalPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalPowerGaugePanel @@ -19,14 +22,23 @@ class EnergyServoScreen(menu: EnergyServoMenu, inventory: Inventory, title: Comp override fun makeMainFrame(): FramePanel> { val frame = FramePanel.padded(this, width = AbstractSlotPanel.SIZE * 2f + HorizontalPowerGaugePanel.GAUGE_BACKGROUND_TALL.width + 8f + ProgressGaugePanel.GAUGE_BACKGROUND.width * 2f, - AbstractSlotPanel.SIZE, title) + AbstractSlotPanel.SIZE + PlayerEquipmentPanel.HEIGHT + 4f, title) - BatterySlotPanel(this, frame, menu.dischargeSlot).also { + val equipment = PlayerEquipmentPanel(this, frame, armorSlots = menu.equipment.armorSlots) + equipment.dock = Dock.FILL + equipment.dockResize = DockResizeMode.NONE + + makeCuriosPanel(this, frame, menu.equipment.curiosSlots, autoAlign = true) + + val strip = EditablePanel(this, frame, height = AbstractSlotPanel.SIZE) + strip.dock = Dock.BOTTOM + + BatterySlotPanel(this, strip, menu.dischargeSlot).also { it.dock = Dock.LEFT it.dockRight = 2f } - object : EditablePanel(this@EnergyServoScreen, frame) { + object : EditablePanel(this@EnergyServoScreen, strip) { init { dock = Dock.LEFT dockRight = 2f @@ -39,12 +51,12 @@ class EnergyServoScreen(menu: EnergyServoMenu, inventory: Inventory, title: Comp } } - TallHorizontalPowerGaugePanel(this, frame, menu.powerGauge).also { + TallHorizontalPowerGaugePanel(this, strip, menu.powerGauge).also { it.dock = Dock.LEFT it.dockRight = 2f } - object : EditablePanel(this@EnergyServoScreen, frame) { + object : EditablePanel(this@EnergyServoScreen, strip) { init { dock = Dock.LEFT dockRight = 2f @@ -57,7 +69,7 @@ class EnergyServoScreen(menu: EnergyServoMenu, inventory: Inventory, title: Comp } } - BatterySlotPanel(this, frame, menu.chargeSlot).also { + BatterySlotPanel(this, strip, menu.chargeSlot).also { it.dock = Dock.LEFT it.dockRight } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt index 41f0ef33e..1c8306127 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt @@ -10,6 +10,7 @@ import ru.dbotthepony.mc.otm.container.awareStream import ru.dbotthepony.mc.otm.container.stream import ru.dbotthepony.mc.otm.core.collect.AwareItemStack import ru.dbotthepony.mc.otm.core.orNull +import ru.dbotthepony.mc.otm.menu.PlayerSlot import top.theillusivec4.curios.api.CuriosApi import top.theillusivec4.curios.common.inventory.CosmeticCurioSlot import top.theillusivec4.curios.common.inventory.CurioSlot @@ -20,10 +21,10 @@ val isCuriosLoaded by lazy { ModList.get().isLoaded(CuriosApi.MODID) } -private fun Player.getCuriosSlotsImpl(): Collection> { +private fun Player.getCuriosSlotsImpl(): List> { val handler = getCapability(MatteryCapability.CURIOS_INVENTORY).orNull() ?: return listOf() - val result = ArrayList>() + val result = ArrayList>() val sortedIdentifiers = ArrayList(handler.curios.keys.size) sortedIdentifiers.addAll(handler.curios.keys) @@ -44,9 +45,9 @@ private fun Player.getCuriosSlotsImpl(): Collection> { if (curio.hasCosmetic()) { val cosmetic = CosmeticCurioSlot(this, curio.cosmeticStacks, slot, identifier, 0, 0) - result.add(regular to cosmetic) + result.add(PlayerSlot(regular, cosmetic)) } else { - result.add(regular to null) + result.add(PlayerSlot(regular)) } } } @@ -58,7 +59,7 @@ private fun Player.getCuriosSlotsImpl(): Collection> { /** * [Pair] */ -val Player.curiosSlots: Collection> get() { +val Player.curiosSlots: List> get() { if (!isCuriosLoaded) { return listOf() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt index 042c23baf..c13660f8d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt @@ -50,7 +50,10 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen } } - val armorSlots: List> = makeArmorSlots() + init { + addInventorySlots(autoFrame = false) + craftingSlots.forEach(this::addSlot) + } val offhandSlot = object : InventorySlot(capability.ply.inventory, 40) { override fun getNoItemIcon(): Pair { @@ -58,19 +61,12 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen } } + val armorSlots = makeArmorSlots() val allAccessibleSlots: List init { - addInventorySlots(autoFrame = false) - - craftingSlots.forEach(this::addSlot) addSlot(offhandSlot) - for ((a, b) in armorSlots) { - addSlot(a) - if (b != null) addSlot(b) - } - val builder = ImmutableList.builder() builder.addAll(playerInventorySlots) @@ -80,7 +76,7 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen allAccessibleSlots = builder.build() } - val curiosSlots: List> = ImmutableList.copyOf(ply.curiosSlots) + val curiosSlots: ImmutableList> = ImmutableList.copyOf(ply.curiosSlots) init { for ((a, b) in curiosSlots) { @@ -163,10 +159,10 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen } for (slot in armorSlots) { - quickMoveMapping[slot.first] = ::playerInventorySlots + quickMoveMapping[slot.functional] = ::playerInventorySlots - if (slot.second != null) { - quickMoveMapping[slot.first] = ::playerInventorySlots + if (slot.cosmetic != null) { + quickMoveMapping[slot.cosmetic] = ::playerInventorySlots } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index a04aaf714..1f3079afe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -20,6 +20,7 @@ import net.minecraftforge.network.PacketDistributor import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.compat.cos.cosmeticArmorSlots +import ru.dbotthepony.mc.otm.compat.curios.curiosSlots import ru.dbotthepony.mc.otm.compat.curios.isCurioSlot import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot @@ -44,6 +45,13 @@ import java.util.function.Predicate import java.util.function.Supplier import kotlin.collections.ArrayList +data class PlayerSlot(val functional: A, val cosmetic: B? = null) + +data class EquipmentSlots( + val armorSlots: List>, + val curiosSlots: List> +) + abstract class MatteryMenu @JvmOverloads protected constructor( menuType: MenuType<*>?, containerId: Int, @@ -367,10 +375,16 @@ abstract class MatteryMenu @JvmOverloads protected constructor( abstract val storageSlots: Collection protected val quickMoveMapping = Reference2ObjectOpenHashMap Collection?>() + /** + * Marks slot as "storage" - shift clicking it will move its contents to Player's inventory + */ protected fun storage2Inventory(slot: Slot) { quickMoveMapping[slot] = ::playerInventorySlots } + /** + * Marks slot as "inventory" - shift clicking it will move its contents to menu's storage slots + */ protected fun inventory2Storage(slot: Slot) { quickMoveMapping[slot] = ::storageSlots } @@ -536,14 +550,31 @@ abstract class MatteryMenu @JvmOverloads protected constructor( super.addDataSlots(p_38885_) } - fun makeArmorSlots(): List> { + fun makeArmorSlots(): List> { val cosmetic = ply.cosmeticArmorSlots return ImmutableList.of( - EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.HEAD) to cosmetic?.get(net.minecraft.world.entity.EquipmentSlot.HEAD), - EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.CHEST) to cosmetic?.get(net.minecraft.world.entity.EquipmentSlot.CHEST), - EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.LEGS) to cosmetic?.get(net.minecraft.world.entity.EquipmentSlot.LEGS), - EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.FEET) to cosmetic?.get(net.minecraft.world.entity.EquipmentSlot.FEET), + PlayerSlot(EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.HEAD), cosmetic?.get(net.minecraft.world.entity.EquipmentSlot.HEAD)), + PlayerSlot(EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.CHEST), cosmetic?.get(net.minecraft.world.entity.EquipmentSlot.CHEST)), + PlayerSlot(EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.LEGS), cosmetic?.get(net.minecraft.world.entity.EquipmentSlot.LEGS)), + PlayerSlot(EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.FEET), cosmetic?.get(net.minecraft.world.entity.EquipmentSlot.FEET)), + ).also { + for ((a, b) in it) { + addSlot(a) + if (b != null) addSlot(b) + } + } + } + + fun makeEquipmentSlots(): EquipmentSlots { + return EquipmentSlots( + armorSlots = makeArmorSlots(), + curiosSlots = ImmutableList.copyOf(ply.curiosSlots).also { + for ((a, b) in it) { + addSlot(a) + if (b != null) addSlot(b) + } + } ) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt index aafee79a1..168959471 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt @@ -12,6 +12,7 @@ import net.minecraftforge.common.capabilities.ForgeCapabilities import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.registry.MMenus @@ -98,12 +99,12 @@ class AndroidStationMenu @JvmOverloads constructor( return super.mayPickup(player) && powerWidget.level >= AndroidStationBlockEntity.ENERGY_PER_OPERATION } - override fun mayPlace(p_40231_: ItemStack): Boolean { + override fun mayPlace(itemStack: ItemStack): Boolean { if (tile is AndroidStationBlockEntity) { - return tile.energy.batteryLevel >= AndroidStationBlockEntity.ENERGY_PER_OPERATION && condition.invoke(p_40231_) + return tile.energy.batteryLevel >= AndroidStationBlockEntity.ENERGY_PER_OPERATION && condition.invoke(itemStack) } - return powerWidget.level >= AndroidStationBlockEntity.ENERGY_PER_OPERATION && condition.invoke(p_40231_) + return powerWidget.level >= AndroidStationBlockEntity.ENERGY_PER_OPERATION && condition.invoke(itemStack) } } @@ -111,28 +112,15 @@ class AndroidStationMenu @JvmOverloads constructor( it.getCapability(ForgeCapabilities.ENERGY).isPresent } - override val storageSlots: ImmutableList - - val armorSlots = makeArmorSlots() + val equipment = makeEquipmentSlots() init { - for ((a, b) in armorSlots) { - addSlot(a) - if (b != null) addSlot(b) - } - addInventorySlots() - addSlot(androidBattery) + } - val builder = ImmutableList.builder() - - for ((a, _) in armorSlots) { - builder.add(a) - } - - builder.add(androidBattery) - storageSlots = builder.build() + override val storageSlots = immutableList { + accept(androidBattery) } override fun stillValid(player: Player): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt index 04b0e8892..973327dc8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt @@ -33,6 +33,8 @@ class EnergyServoMenu @JvmOverloads constructor( } } + val equipment = makeEquipmentSlots() + val powerGauge = LevelGaugeWidget(this, tile?.energy) val itemConfig = ItemHandlerPlayerInput(this) val energyConfig = EnergyPlayerInput(this, true, true) From dd4be8b961a3b44ebc01d097fd3e572ac7cf48c7 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 2 Mar 2023 22:14:02 +0700 Subject: [PATCH 0266/1199] New quickmove implementation --- .../mc/otm/menu/ExoPackInventoryMenu.kt | 46 +++---- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 124 ++++++++++++++---- .../mc/otm/menu/MatteryPoweredMenu.kt | 1 + .../mc/otm/menu/decorative/CargoCrateMenu.kt | 6 +- .../mc/otm/menu/decorative/HoloSignMenu.kt | 3 - .../menu/decorative/MinecartCargoCrateMenu.kt | 6 +- .../mc/otm/menu/matter/MatterBottlerMenu.kt | 4 +- .../menu/matter/MatterCapacitorBankMenu.kt | 6 +- .../otm/menu/matter/MatterDecomposerMenu.kt | 10 +- .../mc/otm/menu/matter/MatterPanelMenu.kt | 3 - .../mc/otm/menu/matter/MatterRecyclerMenu.kt | 4 +- .../otm/menu/matter/MatterReplicatorMenu.kt | 6 +- .../mc/otm/menu/matter/MatterScannerMenu.kt | 4 +- .../mc/otm/menu/matter/PatternStorageMenu.kt | 6 +- .../mc/otm/menu/storage/DriveRackMenu.kt | 6 +- .../mc/otm/menu/storage/DriveViewerMenu.kt | 4 +- .../mc/otm/menu/storage/ItemMonitorMenu.kt | 2 - .../mc/otm/menu/storage/StorageBusMenu.kt | 3 +- .../otm/menu/storage/StorageExporterMenu.kt | 2 - .../otm/menu/storage/StorageImporterMenu.kt | 2 - .../menu/storage/StoragePowerSupplierMenu.kt | 3 +- .../mc/otm/menu/tech/AndroidStationMenu.kt | 6 +- .../mc/otm/menu/tech/BatteryBankMenu.kt | 6 +- .../mc/otm/menu/tech/ChemicalGeneratorMenu.kt | 10 +- .../mc/otm/menu/tech/CobblerMenu.kt | 2 +- .../mc/otm/menu/tech/EnergyCounterMenu.kt | 3 - .../mc/otm/menu/tech/EnergyServoMenu.kt | 10 +- .../mc/otm/menu/tech/PlatePressMenu.kt | 7 +- .../mc/otm/menu/widget/AbstractWidget.kt | 4 - 29 files changed, 152 insertions(+), 147 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt index c13660f8d..2aafa2b0a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt @@ -18,8 +18,6 @@ import ru.dbotthepony.mc.otm.network.ExoSuitSlotPacket import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMenu(null, CONTAINER_ID, capability.ply.inventory) { - override val storageSlots: Collection get() = listOf() - val craftingGrid: CraftingContainer val craftingSlots: List @@ -52,6 +50,19 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen init { addInventorySlots(autoFrame = false) + + for (slot in playerCombinedInventorySlots) { + mapQuickMove(slot, playerHotbarSlots) + } + + for (slot in playerHotbarSlots) { + mapQuickMove(slot, playerCombinedInventorySlots) + } + + for (slot in craftingSlots) { + mapQuickMove(slot, playerInventorySlots) + } + craftingSlots.forEach(this::addSlot) } @@ -65,6 +76,7 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen val allAccessibleSlots: List init { + mapQuickMove(offhandSlot, playerInventorySlots) addSlot(offhandSlot) val builder = ImmutableList.builder() @@ -81,11 +93,11 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen init { for ((a, b) in curiosSlots) { addSlot(a) - storage2Inventory(a) + mapQuickMoveToInventory(a) if (b != null) { addSlot(b) - storage2Inventory(b) + mapQuickMoveToInventory(b) } } } @@ -143,32 +155,6 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen return ItemStack.EMPTY } - if (!autoRegisteredStorageSlots) { - autoRegisteredStorageSlots = true - - for (slot in playerCombinedInventorySlots) { - quickMoveMapping[slot] = ::playerHotbarSlots - } - - for (slot in playerHotbarSlots) { - quickMoveMapping[slot] = ::playerCombinedInventorySlots - } - - for (slot in craftingSlots) { - quickMoveMapping[slot] = ::playerInventorySlots - } - - for (slot in armorSlots) { - quickMoveMapping[slot.functional] = ::playerInventorySlots - - if (slot.cosmetic != null) { - quickMoveMapping[slot.cosmetic] = ::playerInventorySlots - } - } - - quickMoveMapping[offhandSlot] = ::playerInventorySlots - } - if (slotIndex == craftingResultSlot.index) { val item = craftingResultSlot.item val leftover = moveItemStackToSlots(item, playerInventorySlots2, simulate = true) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 1f3079afe..ade950f70 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableList import com.mojang.datafixers.util.Pair import it.unimi.dsi.fastutil.io.FastByteArrayInputStream import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream +import it.unimi.dsi.fastutil.objects.Reference2ObjectFunction import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation @@ -281,7 +282,9 @@ abstract class MatteryMenu @JvmOverloads protected constructor( _playerInventorySlots2.add(slot) _playerMainSlots.add(slot) _playerCombinedInventorySlots.add(slot) - inventory2Storage(slot) + + mapQuickMove(slot, equipmentSlots) + mapQuickMoveToExternal(slot) addSlot(slot) } @@ -295,7 +298,9 @@ abstract class MatteryMenu @JvmOverloads protected constructor( _playerInventorySlots2.add(slot) _playerExoSuitSlots.add(slot) _playerCombinedInventorySlots.add(slot) - inventory2Storage(slot) + + mapQuickMove(slot, equipmentSlots) + mapQuickMoveToExternal(slot) addSlot(slot) } } @@ -303,11 +308,13 @@ abstract class MatteryMenu @JvmOverloads protected constructor( for (i in 0..8) { val slot = InventorySlot(inventory, i) - addSlot(slot) _playerInventorySlots2.add(i, slot) _playerInventorySlots.add(slot) _playerHotbarSlots.add(slot) - inventory2Storage(slot) + + mapQuickMove(slot, equipmentSlots) + mapQuickMoveToExternal(slot) + addSlot(slot) } } @@ -372,48 +379,97 @@ abstract class MatteryMenu @JvmOverloads protected constructor( return player.distanceToSqr(pos.x.toDouble() + 0.5, pos.y.toDouble() + 0.5, pos.z.toDouble() + 0.5) <= 64.0 } - abstract val storageSlots: Collection - protected val quickMoveMapping = Reference2ObjectOpenHashMap Collection?>() + private val externalSlots = ArrayList() + private val quickMoveMapping = Reference2ObjectOpenHashMap>>() + + override fun addSlot(pSlot: Slot): Slot { + if (pSlot in slots) { + return pSlot + } + + return super.addSlot(pSlot) + } + + /** + * Adds slot to "storage slots" list (utilized by quick move) and calls [addSlot] + */ + protected fun addStorageSlot(slot: T, addMapping: Boolean = true): T { + if (slot !in externalSlots) { + addSlot(slot) + externalSlots.add(slot) + + if (addMapping) { + mapQuickMove(slot, equipmentSlots) + mapQuickMoveToInventory(slot) + } + } + + return slot + } + + protected fun addStorageSlot(slot: Iterable, addMapping: Boolean = true) { + for (value in slot) + addStorageSlot(value, addMapping) + } /** * Marks slot as "storage" - shift clicking it will move its contents to Player's inventory */ - protected fun storage2Inventory(slot: Slot) { - quickMoveMapping[slot] = ::playerInventorySlots + protected fun mapQuickMoveToInventory(slot: Slot, prepend: Boolean = false) { + mapQuickMove(slot, playerInventorySlots, prepend = prepend) } /** * Marks slot as "inventory" - shift clicking it will move its contents to menu's storage slots */ - protected fun inventory2Storage(slot: Slot) { - quickMoveMapping[slot] = ::storageSlots + protected fun mapQuickMoveToExternal(slot: Slot, prepend: Boolean = false) { + mapQuickMove(slot, externalSlots, prepend = prepend) } - protected var autoRegisteredStorageSlots = false + protected fun mapQuickMove(slot: Slot, target: Collection, prepend: Boolean = false) { + val listing = quickMoveMapping.computeIfAbsent(slot, Reference2ObjectFunction { ArrayList(1) }) + listing.remove(target) + + if (prepend) + listing.add(0, target) + else + listing.add(target) + } + + protected fun mapQuickMove(slot: Slot, vararg target: Collection) { + for (value in target) { + mapQuickMove(slot, value) + } + } // This method receive Player interactor and slot_index where Shift + Right click occurred // It shall return item stack that got moved override fun quickMoveStack(ply: Player, slotIndex: Int): ItemStack { - if (!slots[slotIndex].hasItem() || !slots[slotIndex].mayPickup(ply)) { + val slot = slots[slotIndex] + + if (!slot.hasItem() || !slot.mayPickup(ply)) { return ItemStack.EMPTY } - if (!autoRegisteredStorageSlots) { - autoRegisteredStorageSlots = true + val target = quickMoveMapping[slot] ?: return ItemStack.EMPTY + val copy = slot.item.copy() + var any = false - for (slot in storageSlots) { - storage2Inventory(slot) + for (collection in target) { + if (moveItemStackTo(slot, collection)) { + any = true + + if (!slot.hasItem()) { + return copy + } } } - val slot = slots[slotIndex] - val target = quickMoveMapping[slot]?.invoke() ?: return ItemStack.EMPTY - val copy = slots[slotIndex].item.copy() - - if (moveItemStackTo(slots[slotIndex], target)) + if (any) { return copy - else + } else { return ItemStack.EMPTY + } } fun quickMoveToInventory(stack: ItemStack, simulate: Boolean): ItemStack { @@ -546,11 +602,15 @@ abstract class MatteryMenu @JvmOverloads protected constructor( return moveItemStackToSlots(item, slots, simulate) } - public override fun addDataSlots(p_38885_: ContainerData) { - super.addDataSlots(p_38885_) - } + private var armorSlots: ImmutableList>? = null + private var curiosSlots: ImmutableList>? = null + private val equipmentSlots = ArrayList() fun makeArmorSlots(): List> { + if (armorSlots != null) { + return armorSlots!! + } + val cosmetic = ply.cosmeticArmorSlots return ImmutableList.of( @@ -559,9 +619,15 @@ abstract class MatteryMenu @JvmOverloads protected constructor( PlayerSlot(EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.LEGS), cosmetic?.get(net.minecraft.world.entity.EquipmentSlot.LEGS)), PlayerSlot(EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.FEET), cosmetic?.get(net.minecraft.world.entity.EquipmentSlot.FEET)), ).also { + armorSlots = it + for ((a, b) in it) { + equipmentSlots.add(a) addSlot(a) if (b != null) addSlot(b) + + mapQuickMoveToInventory(a) + if (b != null) mapQuickMoveToInventory(b) } } } @@ -569,12 +635,16 @@ abstract class MatteryMenu @JvmOverloads protected constructor( fun makeEquipmentSlots(): EquipmentSlots { return EquipmentSlots( armorSlots = makeArmorSlots(), - curiosSlots = ImmutableList.copyOf(ply.curiosSlots).also { + curiosSlots = curiosSlots ?: ImmutableList.copyOf(ply.curiosSlots).also { for ((a, b) in it) { + equipmentSlots.add(a) addSlot(a) if (b != null) addSlot(b) + + mapQuickMoveToInventory(a) + if (b != null) mapQuickMoveToInventory(b) } - } + }.also { curiosSlots = it } ) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt index 9ac648a32..4156116c1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt @@ -28,5 +28,6 @@ abstract class MatteryPoweredMenu protected constructor( } addSlot(batterySlot) + mapQuickMoveToInventory(batterySlot) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt index 824ecf6e0..003536e28 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt @@ -14,7 +14,7 @@ class CargoCrateMenu @JvmOverloads constructor( inventory: Inventory, tile: CargoCrateBlockEntity? = null ) : MatteryMenu(MMenus.CARGO_CRATE, p_38852_, inventory, tile) { - override val storageSlots: List + val storageSlots: List private val trackedPlayerOpen = !inventory.player.isSpectator @@ -22,9 +22,7 @@ class CargoCrateMenu @JvmOverloads constructor( val container = tile?.container ?: SimpleContainer(CargoCrateBlockEntity.CAPACITY) storageSlots = ImmutableList(CargoCrateBlockEntity.CAPACITY) { - val slot = MatterySlot(container, it) - addSlot(slot) - return@ImmutableList slot + addStorageSlot(MatterySlot(container, it)) } if (trackedPlayerOpen) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt index 205f3e5f7..bc3562c0e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/HoloSignMenu.kt @@ -30,7 +30,4 @@ class HoloSignMenu @JvmOverloads constructor( redstone.with(tile.redstoneControl::redstoneSetting) } } - - override val storageSlots: Collection - get() = listOf() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt index 8959e986f..7d271b1c1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt @@ -16,7 +16,7 @@ class MinecartCargoCrateMenu @JvmOverloads constructor( inventory: Inventory, val cart: MinecartCargoCrate? = null ) : MatteryMenu(MMenus.CARGO_CRATE, p_38852_, inventory) { - override val storageSlots: List + val storageSlots: List private val trackedPlayerOpen = !inventory.player.isSpectator @@ -24,9 +24,7 @@ class MinecartCargoCrateMenu @JvmOverloads constructor( val container = cart as Container? ?: SimpleContainer(CargoCrateBlockEntity.CAPACITY) storageSlots = ImmutableList(CargoCrateBlockEntity.CAPACITY) { - val slot = MatterySlot(container, it) - addSlot(slot) - return@ImmutableList slot + addStorageSlot(MatterySlot(container, it)) } if (trackedPlayerOpen) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt index f1b061dfb..217c1b301 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt @@ -28,7 +28,7 @@ class MatterBottlerMenu @JvmOverloads constructor( val progressWidget: ProgressGaugeWidget val matterWidget: LevelGaugeWidget - override val storageSlots: List + val storageSlots: List init { val container = tile?.container ?: SimpleContainer(6) @@ -57,7 +57,7 @@ class MatterBottlerMenu @JvmOverloads constructor( } } - storageSlots.forEach(this::addSlot) + storageSlots.forEach(this::addStorageSlot) addInventorySlots() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterCapacitorBankMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterCapacitorBankMenu.kt index c96ac0f08..78fdd963c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterCapacitorBankMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterCapacitorBankMenu.kt @@ -20,7 +20,7 @@ class MatterCapacitorBankMenu @JvmOverloads constructor( val matterGauge: LevelGaugeWidget val totalMatterGauge: LevelGaugeWidget - override val storageSlots: List + val storageSlots: List init { if (tile == null) { @@ -38,9 +38,7 @@ class MatterCapacitorBankMenu @JvmOverloads constructor( val container = tile?.container ?: SimpleContainer(2 * 6) storageSlots = ImmutableList(2 * 6) { - val slot = MatterContainerInputSlot(container, it) - addSlot(slot) - slot + addStorageSlot(MatterContainerInputSlot(container, it)) } addInventorySlots() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt index 6d6b58960..cbe45dfdc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt @@ -48,12 +48,10 @@ class MatterDecomposerMenu @JvmOverloads constructor( progressWidget = ProgressGaugeWidget(this, tile::workProgress, tile::isUnableToProcess) } + addStorageSlot(outputMain) + addStorageSlot(outputStacking) + addStorageSlot(input) + addInventorySlots() } - - override val storageSlots: List = ImmutableList.of( - addSlot(outputMain), - addSlot(outputStacking), - addSlot(input), - ) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt index 250d8d8df..966bbbbff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt @@ -294,9 +294,6 @@ class MatterPanelMenu @JvmOverloads constructor( } } - override val storageSlots: Collection - get() = emptyList() - companion object { private val LOGGER = LogManager.getLogger() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt index 1c6e4b6b0..d590773c9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt @@ -37,9 +37,7 @@ class MatterRecyclerMenu @JvmOverloads constructor( progress = ProgressGaugeWidget(this, tile::workProgress, tile::isUnableToProcess) } - addSlot(input) + addStorageSlot(input) addInventorySlots() } - - override val storageSlots: Collection = ImmutableList.of(input) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt index a5fbfa75d..cb2f177c5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt @@ -20,15 +20,13 @@ class MatterReplicatorMenu @JvmOverloads constructor( ) { val matter: LevelGaugeWidget val progress: ProgressGaugeWidget - override val storageSlots: List + val storageSlots: List init { val container = tile?.container ?: SimpleContainer(5) storageSlots = ImmutableList(5) { - val slot = MachineOutputSlot(container, it) - addSlot(slot) - return@ImmutableList slot + addStorageSlot(MachineOutputSlot(container, it)) } if (tile != null) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt index 8357aeb71..d0b36b5b8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt @@ -31,7 +31,7 @@ class MatterScannerMenu @JvmOverloads constructor( override fun mayPlace(itemStack: ItemStack) = MatterManager.canDecompose(itemStack) } - addSlot(input) + addStorageSlot(input) if (tile != null) { progress = ProgressGaugeWidget(this, tile::workProgress, tile::isUnableToProcess) @@ -45,6 +45,4 @@ class MatterScannerMenu @JvmOverloads constructor( addInventorySlots() } - - override val storageSlots: List = listOf(input) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt index 530349417..3e8430154 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt @@ -20,7 +20,7 @@ class PatternStorageMenu @JvmOverloads constructor( val storedThis: LevelGaugeWidget val storedGrid: LevelGaugeWidget - override val storageSlots: List + val storageSlots: List init { if (tile == null) { @@ -38,11 +38,9 @@ class PatternStorageMenu @JvmOverloads constructor( val patterns = tile?.container ?: SimpleContainer(2 * 4) storageSlots = ImmutableList(2 * 4) { - PatternSlot(patterns, it) + addStorageSlot(PatternSlot(patterns, it)) } - storageSlots.forEach(this::addSlot) - addInventorySlots() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveRackMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveRackMenu.kt index fd0bad009..053674d5a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveRackMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveRackMenu.kt @@ -14,15 +14,13 @@ class DriveRackMenu @JvmOverloads constructor( inventory: Inventory, tile: DriveRackBlockEntity? = null ) : MatteryPoweredMenu(MMenus.DRIVE_RACK, p_38852_, inventory, tile) { - override val storageSlots: List + val storageSlots: List init { val container = tile?.container ?: SimpleContainer(4) storageSlots = ImmutableList(4) { - val slot = DriveSlot(container, it) - addSlot(slot) - slot + addStorageSlot(DriveSlot(container, it)) } addInventorySlots() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt index cc0502f73..bd39f67dd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt @@ -56,12 +56,10 @@ class DriveViewerMenu @JvmOverloads constructor( powered = null } - addSlot(driveSlot) + addStorageSlot(driveSlot) addInventorySlots() } - override val storageSlots: List = ImmutableList.of(driveSlot, batterySlot) - val driveFilter = ItemFilter(PortableCondensationDriveItem.MAX_FILTERS) { self, _, _, _ -> if (tile?.container?.get(0)?.item is PortableCondensationDriveItem) { tile.container[0].getOrCreateTag().put(PortableCondensationDriveItem.FILTER_PATH, self.serializeNBT()) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt index 6fb8bbddb..fe5cb8824 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt @@ -130,8 +130,6 @@ class ItemMonitorMenu @JvmOverloads constructor( } } - override val storageSlots: List = listOf(batterySlot) - override fun quickMoveStack(ply: Player, slotIndex: Int): ItemStack { if (playerInventorySlots.any { it.index == slotIndex }) { if (tile == null) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageBusMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageBusMenu.kt index e29d7526e..f7a918788 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageBusMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageBusMenu.kt @@ -27,8 +27,7 @@ class StorageBusMenu @JvmOverloads constructor( busFilterState = BooleanInputWithFeedback(this) } + addStorageSlot(batterySlot) addInventorySlots() } - - override val storageSlots: Collection = listOf(batterySlot) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageExporterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageExporterMenu.kt index 391633a96..168a26c07 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageExporterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageExporterMenu.kt @@ -29,6 +29,4 @@ class StorageExporterMenu @JvmOverloads constructor( addInventorySlots() } - - override val storageSlots: List = listOf(batterySlot) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageImporterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageImporterMenu.kt index e568a0a8f..36415e95a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageImporterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageImporterMenu.kt @@ -29,6 +29,4 @@ class StorageImporterMenu @JvmOverloads constructor( addInventorySlots() } - - override val storageSlots: List = listOf(batterySlot) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StoragePowerSupplierMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StoragePowerSupplierMenu.kt index a4be8757b..e62778ed3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StoragePowerSupplierMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StoragePowerSupplierMenu.kt @@ -15,6 +15,7 @@ class StoragePowerSupplierMenu @JvmOverloads constructor( var activeNodes by mSynchronizer.int() init { + addStorageSlot(batterySlot) addInventorySlots() } @@ -26,6 +27,4 @@ class StoragePowerSupplierMenu @JvmOverloads constructor( super.broadcastChanges() } - - override val storageSlots: List = listOf(batterySlot) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt index 168959471..219bad732 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt @@ -116,11 +116,7 @@ class AndroidStationMenu @JvmOverloads constructor( init { addInventorySlots() - addSlot(androidBattery) - } - - override val storageSlots = immutableList { - accept(androidBattery) + addStorageSlot(androidBattery) } override fun stillValid(player: Player): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt index 69ba6fe18..eebcfa2e4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt @@ -22,7 +22,7 @@ class BatteryBankMenu @JvmOverloads constructor( tile: BatteryBankBlockEntity? = null, ) : MatteryMenu(MMenus.BATTERY_BANK, p_38852_, inventory, tile) { val powerLevel: LevelGaugeWidget - override val storageSlots: List + val storageSlots: List val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java) init { @@ -34,9 +34,7 @@ class BatteryBankMenu @JvmOverloads constructor( powerLevel = LevelGaugeWidget(this, tile?.getCapability(MatteryCapability.ENERGY)?.orNull()) storageSlots = ImmutableList(BatteryBankBlockEntity.CAPACITY) { - val slot = BatterySlot(container, it) - addSlot(slot) - return@ImmutableList slot + addStorageSlot(BatterySlot(container, it)) } addInventorySlots() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt index 71f02822a..d164355ab 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt @@ -58,11 +58,11 @@ class ChemicalGeneratorMenu @JvmOverloads constructor(id: Int, inv: Inventory, t val energy = LevelGaugeWidget(this, tile?.energy) var burnTime by mSynchronizer.int() - override val storageSlots = listOf( - addSlot(fuelSlot), - addSlot(batterySlot), - addSlot(residueSlot), - ) + init { + addStorageSlot(fuelSlot) + addStorageSlot(batterySlot) + addStorageSlot(residueSlot) + } init { addInventorySlots() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt index 8519d30f3..fc442d141 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt @@ -17,7 +17,7 @@ class CobblerMenu @JvmOverloads constructor( inventory: Inventory, tile: CobblerBlockEntity? = null ) : MatteryMenu(MMenus.COBBLESTONE_GENERATOR, p_38852_, inventory, tile) { - override val storageSlots = (tile?.container ?: SimpleContainer(CobblerBlockEntity.CONTAINER_SIZE)).let { c -> ImmutableList(c.containerSize) { addSlot(MachineOutputSlot(c, it)) } } + val storageSlots = (tile?.container ?: SimpleContainer(CobblerBlockEntity.CONTAINER_SIZE)).let { c -> ImmutableList(c.containerSize) { addStorageSlot(MachineOutputSlot(c, it)) } } val redstone = EnumInputWithFeedback(this) val itemConfig = ItemHandlerPlayerInput(this, false, false) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyCounterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyCounterMenu.kt index 1242fe4db..80d56a523 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyCounterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyCounterMenu.kt @@ -72,9 +72,6 @@ class EnergyCounterMenu @JvmOverloads constructor( super.broadcastChanges() } - - override val storageSlots: Collection get() = emptySet() - companion object { private val MINUS_ONE = -BigDecimal.ONE } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt index 973327dc8..312d8c029 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt @@ -1,9 +1,7 @@ package ru.dbotthepony.mc.otm.menu.tech -import com.google.common.collect.ImmutableList import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory -import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.block.entity.tech.EnergyServoBlockEntity @@ -49,10 +47,10 @@ class EnergyServoMenu @JvmOverloads constructor( } init { - addSlot(dischargeSlot) - addSlot(chargeSlot) + // charge then discharge for charging to take priority over discharging + addStorageSlot(chargeSlot) + addStorageSlot(dischargeSlot) + addInventorySlots() } - - override val storageSlots: Collection = ImmutableList.of(dischargeSlot, chargeSlot) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt index dbae50e25..512bfae03 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.menu.tech -import com.google.common.collect.ImmutableList import net.minecraft.server.level.ServerPlayer import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory @@ -21,16 +20,14 @@ class PlatePressMenu @JvmOverloads constructor( val inputSlot = MatterySlot(tile?.inputContainer ?: SimpleContainer(1), 0) val outputSlot = MachineOutputSlot(tile?.outputContainer ?: SimpleContainer(1), 0) { tile?.popExperience(ply as ServerPlayer) } - override val storageSlots: List = ImmutableList.of(inputSlot, outputSlot) - val progressGauge = if (tile != null) ProgressGaugeWidget(this, tile::workProgress, tile::isUnableToProcess) else ProgressGaugeWidget(this) val itemConfig = ItemHandlerPlayerInput(this, allowPush = true) val energyConfig = EnergyPlayerInput(this, allowPull = true) init { - addSlot(inputSlot) - addSlot(outputSlot) + addStorageSlot(inputSlot) + addStorageSlot(outputSlot) addInventorySlots() if (tile != null) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/AbstractWidget.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/AbstractWidget.kt index e040090f1..cfd9a6147 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/AbstractWidget.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/AbstractWidget.kt @@ -7,8 +7,4 @@ abstract class AbstractWidget(val menu: MatteryMenu,) { val slotID: Int = menu.addWidget(this) abstract fun updateServer() - - protected fun addDataSlots(slots: ContainerData) { - menu.addDataSlots(slots) - } } From c671d2e13d7eb6bd2aadc48216520bb63dab6220 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 2 Mar 2023 22:17:22 +0700 Subject: [PATCH 0267/1199] Wasn't the best idea to write immutable list helper with uppercase I --- .../block/entity/matter/MatterCapacitorBankBlockEntity.kt | 4 ++-- .../mc/otm/block/entity/tech/BatteryBankBlockEntity.kt | 4 ++-- .../mc/otm/client/render/blockentity/BankRenderer.kt | 6 +++--- src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 2 +- .../ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt | 4 ++-- .../mc/otm/menu/decorative/MinecartCargoCrateMenu.kt | 4 ++-- .../ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt | 4 ++-- .../mc/otm/menu/matter/MatterCapacitorBankMenu.kt | 4 ++-- .../dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt | 4 ++-- .../ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt | 4 ++-- .../ru/dbotthepony/mc/otm/menu/storage/DriveRackMenu.kt | 4 ++-- .../ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt | 4 ++-- .../kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt | 4 ++-- 13 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt index 75750314b..3777bb4de 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt @@ -14,7 +14,7 @@ import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage import ru.dbotthepony.mc.otm.container.MatteryContainer -import ru.dbotthepony.mc.otm.core.ImmutableList +import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.graph.Graph6Node @@ -130,7 +130,7 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) } }.also(::addDroppableContainer) - val capacitorStatus = ImmutableList(BatteryBankBlockEntity.CAPACITY) { + val capacitorStatus = immutableList(BatteryBankBlockEntity.CAPACITY) { synchronizer.bool(false, name = "capacitor$it") } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index 893e98528..f8753ac68 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -17,7 +17,7 @@ import ru.dbotthepony.mc.otm.capability.maxEnergyStoredMattery import ru.dbotthepony.mc.otm.capability.receiveEnergy import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer -import ru.dbotthepony.mc.otm.core.ImmutableList +import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.getValue import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.math.Decimal @@ -38,7 +38,7 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte } }.also(::addDroppableContainer) - val batteryStatus = ImmutableList(CAPACITY) { + val batteryStatus = immutableList(CAPACITY) { synchronizer.bool(false, name = "battery$it") } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt index ae1c202e6..f83d5ef4d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt @@ -19,7 +19,7 @@ import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel -import ru.dbotthepony.mc.otm.core.ImmutableList +import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.math.facingOne @@ -117,7 +117,7 @@ abstract class BankRenderer(private val context: B class BatteryBankRenderer(context: BlockEntityRendererProvider.Context) : BankRenderer(context) { override val models: List by lazy { - ImmutableList(12) { + immutableList(12) { minecraft.modelManager.modelBakery.bakedTopLevelModels[ResourceLocation(OverdriveThatMatters.MOD_ID, "block/battery/battery$it")]!! } } @@ -144,7 +144,7 @@ class BatteryBankRenderer(context: BlockEntityRendererProvider.Context) : BankRe class MatterBatteryBankRenderer(context: BlockEntityRendererProvider.Context) : BankRenderer(context) { override val models: List by lazy { - ImmutableList(12) { + immutableList(12) { minecraft.modelManager.modelBakery.bakedTopLevelModels[ResourceLocation(OverdriveThatMatters.MOD_ID, "block/battery/matter_capacitor$it")]!! } } 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 05c455fe9..45a7304c4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -115,7 +115,7 @@ fun > T.prev(values: Array): T { return values[next] } -inline fun ImmutableList(size: Int, initializer: (index: Int) -> T): ImmutableList { +inline fun immutableList(size: Int, initializer: (index: Int) -> T): ImmutableList { require(size >= 0) { "Invalid list size $size" } return when (size) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt index 003536e28..0a2ee3dc2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt @@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.menu.decorative import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player -import ru.dbotthepony.mc.otm.core.ImmutableList +import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.block.entity.decorative.CargoCrateBlockEntity import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatterySlot @@ -21,7 +21,7 @@ class CargoCrateMenu @JvmOverloads constructor( init { val container = tile?.container ?: SimpleContainer(CargoCrateBlockEntity.CAPACITY) - storageSlots = ImmutableList(CargoCrateBlockEntity.CAPACITY) { + storageSlots = immutableList(CargoCrateBlockEntity.CAPACITY) { addStorageSlot(MatterySlot(container, it)) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt index 7d271b1c1..6b1f0253e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt @@ -4,7 +4,7 @@ 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 ru.dbotthepony.mc.otm.core.ImmutableList +import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.block.entity.decorative.CargoCrateBlockEntity import ru.dbotthepony.mc.otm.entity.MinecartCargoCrate import ru.dbotthepony.mc.otm.menu.MatteryMenu @@ -23,7 +23,7 @@ class MinecartCargoCrateMenu @JvmOverloads constructor( init { val container = cart as Container? ?: SimpleContainer(CargoCrateBlockEntity.CAPACITY) - storageSlots = ImmutableList(CargoCrateBlockEntity.CAPACITY) { + storageSlots = immutableList(CargoCrateBlockEntity.CAPACITY) { addStorageSlot(MatterySlot(container, it)) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt index 217c1b301..33371430e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt @@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.menu.matter import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack -import ru.dbotthepony.mc.otm.core.ImmutableList +import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.matter.canExtractMatter @@ -43,7 +43,7 @@ class MatterBottlerMenu @JvmOverloads constructor( workFlow = BooleanInputWithFeedback(this, tile::isBottling) } - storageSlots = ImmutableList(6) { index -> + storageSlots = immutableList(6) { index -> object : MatterySlot(container, index) { override fun mayPlace(p_40231_: ItemStack): Boolean { val cap = p_40231_.getCapability(MatteryCapability.MATTER).orNull() ?: return false diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterCapacitorBankMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterCapacitorBankMenu.kt index 78fdd963c..4993feffe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterCapacitorBankMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterCapacitorBankMenu.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.menu.matter import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory -import ru.dbotthepony.mc.otm.core.ImmutableList +import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.block.entity.matter.MatterCapacitorBankBlockEntity import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.menu.MatterContainerInputSlot @@ -37,7 +37,7 @@ class MatterCapacitorBankMenu @JvmOverloads constructor( val container = tile?.container ?: SimpleContainer(2 * 6) - storageSlots = ImmutableList(2 * 6) { + storageSlots = immutableList(2 * 6) { addStorageSlot(MatterContainerInputSlot(container, it)) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt index cb2f177c5..71350a85a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt @@ -6,7 +6,7 @@ import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import net.minecraft.world.SimpleContainer -import ru.dbotthepony.mc.otm.core.ImmutableList +import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.menu.MachineOutputSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.registry.MMenus @@ -25,7 +25,7 @@ class MatterReplicatorMenu @JvmOverloads constructor( init { val container = tile?.container ?: SimpleContainer(5) - storageSlots = ImmutableList(5) { + storageSlots = immutableList(5) { addStorageSlot(MachineOutputSlot(container, it)) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt index 3e8430154..7307b7867 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.menu.matter import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory -import ru.dbotthepony.mc.otm.core.ImmutableList +import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.block.entity.matter.PatternStorageBlockEntity import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.menu.MatteryMenu @@ -37,7 +37,7 @@ class PatternStorageMenu @JvmOverloads constructor( val patterns = tile?.container ?: SimpleContainer(2 * 4) - storageSlots = ImmutableList(2 * 4) { + storageSlots = immutableList(2 * 4) { addStorageSlot(PatternSlot(patterns, it)) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveRackMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveRackMenu.kt index 053674d5a..580b7512f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveRackMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveRackMenu.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.menu.storage import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory -import ru.dbotthepony.mc.otm.core.ImmutableList +import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.block.entity.storage.DriveRackBlockEntity import ru.dbotthepony.mc.otm.menu.DriveSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu @@ -19,7 +19,7 @@ class DriveRackMenu @JvmOverloads constructor( init { val container = tile?.container ?: SimpleContainer(4) - storageSlots = ImmutableList(4) { + storageSlots = immutableList(4) { addStorageSlot(DriveSlot(container, it)) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt index eebcfa2e4..58b2cd957 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt @@ -6,7 +6,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.block.entity.tech.BatteryBankBlockEntity import net.minecraft.world.SimpleContainer import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting -import ru.dbotthepony.mc.otm.core.ImmutableList +import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.core.orNull @@ -33,7 +33,7 @@ class BatteryBankMenu @JvmOverloads constructor( val container: Container = tile?.container ?: SimpleContainer(BatteryBankBlockEntity.CAPACITY) powerLevel = LevelGaugeWidget(this, tile?.getCapability(MatteryCapability.ENERGY)?.orNull()) - storageSlots = ImmutableList(BatteryBankBlockEntity.CAPACITY) { + storageSlots = immutableList(BatteryBankBlockEntity.CAPACITY) { addStorageSlot(BatterySlot(container, it)) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt index fc442d141..0602bbf95 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt @@ -4,7 +4,7 @@ import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.block.entity.tech.CobblerBlockEntity -import ru.dbotthepony.mc.otm.core.ImmutableList +import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.menu.MachineOutputSlot import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback @@ -17,7 +17,7 @@ class CobblerMenu @JvmOverloads constructor( inventory: Inventory, tile: CobblerBlockEntity? = null ) : MatteryMenu(MMenus.COBBLESTONE_GENERATOR, p_38852_, inventory, tile) { - val storageSlots = (tile?.container ?: SimpleContainer(CobblerBlockEntity.CONTAINER_SIZE)).let { c -> ImmutableList(c.containerSize) { addStorageSlot(MachineOutputSlot(c, it)) } } + val storageSlots = (tile?.container ?: SimpleContainer(CobblerBlockEntity.CONTAINER_SIZE)).let { c -> immutableList(c.containerSize) { addStorageSlot(MachineOutputSlot(c, it)) } } val redstone = EnumInputWithFeedback(this) val itemConfig = ItemHandlerPlayerInput(this, false, false) From fed79e273bf93274d550887473822e05ed516cb0 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 2 Mar 2023 23:51:06 +0700 Subject: [PATCH 0268/1199] =?UTF-8?q?=D0=9E=D0=BA=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index 1b356d032..933bfdb14 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -235,7 +235,8 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : // примем из сети недостающее количество бака материи, или 200 тиков репликации, что меньше val drain = graph.extractMatter(matter.missingMatter .coerceAtMost(drainPerTick * DRAIN_MULT) - .coerceAtMost(job.matterPerTick * (job.ticks - workTicks - ticksAdvanced)), true) + .coerceAtMost(job.matterPerTick * (job.ticks - workTicks - ticksAdvanced)) + .coerceAtLeast(Decimal.ONE), true) if (drain.isZero) { // в сети нет материи From 6fa598d5fca71e9f114dfd8ea2b66fd5b87953cd Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 3 Mar 2023 07:57:24 +0700 Subject: [PATCH 0269/1199] Add -> Once --- .../kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt | 9 ++++----- .../ru/dbotthepony/mc/otm/client/ClientTickHandler.kt | 4 ++-- .../kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt | 6 +++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt index 1d5d80e8f..4803fafc4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt @@ -5,7 +5,6 @@ package ru.dbotthepony.mc.otm import net.minecraft.client.server.IntegratedServer import net.minecraft.server.MinecraftServer -import net.minecraft.server.level.ServerLevel import net.minecraft.world.level.Level import net.minecraftforge.api.distmarker.Dist import net.minecraftforge.event.TickEvent @@ -164,11 +163,11 @@ fun onWorldTick(event: LevelTickEvent) { } fun onceServerPre(ticker: ITickable) { - preServerTick.add(ticker, SERVER_IS_LIVE, "Server is stopping") + preServerTick.once(ticker, SERVER_IS_LIVE, "Server is stopping") } fun onceServer(ticker: ITickable) { - postServerTick.add(ticker, SERVER_IS_LIVE, "Server is stopping") + postServerTick.once(ticker, SERVER_IS_LIVE, "Server is stopping") } fun tickServerPre(ticker: IConditionalTickable) { @@ -203,7 +202,7 @@ fun Level.once(ticker: ITickable) { return } - postWorldTick.computeIfAbsent(this) { TickList() }.add(ticker) + postWorldTick.computeIfAbsent(this) { TickList() }.once(ticker) } fun Level.oncePre(ticker: ITickable) { @@ -214,7 +213,7 @@ fun Level.oncePre(ticker: ITickable) { return } - preWorldTick.computeIfAbsent(this) { TickList() }.add(ticker) + preWorldTick.computeIfAbsent(this) { TickList() }.once(ticker) } fun Level.addTicker(ticker: IConditionalTickable) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientTickHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientTickHandler.kt index 7b04b4ebc..4f5473b31 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientTickHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientTickHandler.kt @@ -17,12 +17,12 @@ var LOGGED_IN = false fun onceClient(ticker: ITickable) { check(isClient) { "Illegal side" } - postTickList.add(ticker, LOGGED_IN, "Not logged in") + postTickList.once(ticker, LOGGED_IN, "Not logged in") } fun onceClientPre(ticker: ITickable) { check(isClient) { "Illegal side" } - preTickList.add(ticker, LOGGED_IN, "Not logged in") + preTickList.once(ticker, LOGGED_IN, "Not logged in") } fun onceClient(inTicks: Int, ticker: Runnable) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt index f244f5381..23060d6d0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt @@ -21,7 +21,7 @@ class TickList { } } - fun add(ticker: ITickable) { + fun once(ticker: ITickable) { if (inTicker) { onceValveTime.add(ticker) } else { @@ -46,13 +46,13 @@ class TickList { return add(ticker) } - fun add(ticker: ITickable, condition: Boolean, reason: String) { + fun once(ticker: ITickable, condition: Boolean, reason: String) { if (!condition) { LOGGER.error("Refusing to add tickable $ticker because we $reason", IllegalStateException(reason)) return } - return add(ticker) + return once(ticker) } fun until(ticker: () -> Boolean) = add(IConditionalTickable.wrap(ticker)) From 289c3642d557fe1fc6e9bf028a6fca5048a6447c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 3 Mar 2023 08:05:41 +0700 Subject: [PATCH 0270/1199] Payload may not be larger than 1048576 bytes --- .../mc/otm/core/util/FriendlyStreams.kt | 18 +++++++++++++++++- .../dbotthepony/mc/otm/matter/MatterManager.kt | 6 ++++-- 2 files changed, 21 insertions(+), 3 deletions(-) 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 cb67e89bd..13d79bef0 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 @@ -14,11 +14,11 @@ import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.NbtAccounter import net.minecraft.nbt.NbtIo import net.minecraft.network.FriendlyByteBuf +import net.minecraft.network.chat.Component import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraftforge.registries.ForgeRegistries import net.minecraftforge.registries.ForgeRegistry -import org.apache.commons.lang3.mutable.MutableInt import java.io.* import java.math.BigDecimal import java.math.BigInteger @@ -239,6 +239,14 @@ fun InputStream.readJson(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 } } +fun InputStream.readBinaryComponent(): Component? { + return Component.Serializer.fromJson(readJson()) +} + +fun OutputStream.writeBinaryComponent(component: Component) { + writeJson(Component.Serializer.toJsonTree(component)) +} + fun FriendlyByteBuf.readJson(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18)): JsonElement { return ByteBufInputStream(this).readJson(sizeLimit) } @@ -246,3 +254,11 @@ fun FriendlyByteBuf.readJson(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18)): fun FriendlyByteBuf.writeJson(value: JsonElement) { ByteBufOutputStream(this).writeJson(value) } + +fun FriendlyByteBuf.readBinaryComponent(): Component { + return Component.Serializer.fromJson(readJson()) ?: throw NullPointerException("Received null component") +} + +fun FriendlyByteBuf.writeBinaryComponent(component: Component) { + writeJson(Component.Serializer.toJsonTree(component)) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index b207035f8..683c9953d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -77,6 +77,8 @@ import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.core.readItemType import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.core.stream +import ru.dbotthepony.mc.otm.core.util.readBinaryComponent +import ru.dbotthepony.mc.otm.core.util.writeBinaryComponent import ru.dbotthepony.mc.otm.core.writeItemType import ru.dbotthepony.mc.otm.milliTime import ru.dbotthepony.mc.otm.network.MatteryPacket @@ -1399,7 +1401,7 @@ object MatterManager { val result = SyncPacket( buff.readMap(FriendlyByteBuf::readItemType, FriendlyByteBuf::readMatterValue), - buff.readMap(FriendlyByteBuf::readItemType) { self -> self.readCollection(::ArrayList, FriendlyByteBuf::readComponent) } + buff.readMap(FriendlyByteBuf::readItemType) { self -> self.readCollection(::ArrayList, FriendlyByteBuf::readBinaryComponent) } ) LOGGER.debug("Reading matter registry packet took ${time.millis}ms") @@ -1414,7 +1416,7 @@ object MatterManager { override fun write(buff: FriendlyByteBuf) { val time = SystemTime() buff.writeMap(values, FriendlyByteBuf::writeItemType, FriendlyByteBuf::writeMatterValue) - buff.writeMap(comments, FriendlyByteBuf::writeItemType) { self, value -> self.writeCollection(value, FriendlyByteBuf::writeComponent) } + buff.writeMap(comments, FriendlyByteBuf::writeItemType) { self, value -> self.writeCollection(value, FriendlyByteBuf::writeBinaryComponent) } LOGGER.debug("Encoding matter registry packet took ${time.millis}ms, written total ${buff.writerIndex() - 1} bytes") } From 29777706aa38b5bedd1f57ef3bb5e65731063ea0 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 3 Mar 2023 21:24:25 +0700 Subject: [PATCH 0271/1199] Compress matter registry packet --- .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 7 + .../mc/otm/core/util/FriendlyStreams.kt | 21 +++ .../dbotthepony/mc/otm/matter/IMatterValue.kt | 20 +++ .../mc/otm/matter/MatterManager.kt | 132 ++++++++++++++++-- 4 files changed, 170 insertions(+), 10 deletions(-) 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 45a7304c4..efbf4442b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -31,6 +31,9 @@ import net.minecraftforge.registries.ForgeRegistries import net.minecraftforge.registries.ForgeRegistry import net.minecraftforge.registries.IForgeRegistry import ru.dbotthepony.mc.otm.core.math.Vector +import ru.dbotthepony.mc.otm.core.util.readInt +import java.io.InputStream +import java.io.OutputStream import java.lang.ref.Reference import java.math.BigInteger import java.util.Arrays @@ -169,6 +172,10 @@ fun FriendlyByteBuf.readItemType(): Item? { return ForgeRegistries.ITEMS.getValue(readInt()) } +fun InputStream.readItemType(): Item? { + return ForgeRegistries.ITEMS.getValue(readInt()) +} + operator fun > StateHolder<*, *>.get(property: Property): T { return getValue(property) } 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 13d79bef0..05f07044d 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 @@ -262,3 +262,24 @@ fun FriendlyByteBuf.readBinaryComponent(): Component { fun FriendlyByteBuf.writeBinaryComponent(component: Component) { writeJson(Component.Serializer.toJsonTree(component)) } + +fun S.writeCollection(collection: Collection, writer: S.(V) -> Unit) { + writeVarIntLE(collection.size) + + for (value in collection) { + writer(this, value) + } +} + +fun > S.readCollection(reader: S.() -> V, factory: (Int) -> C): C { + val size = readVarIntLE() + val collection = factory.invoke(size) + + for (i in 0 until size) { + collection.add(reader(this)) + } + + return collection +} + +fun S.readCollection(reader: S.() -> V) = readCollection(reader, ::ArrayList) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/IMatterValue.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/IMatterValue.kt index 6367157d2..ffe05bf75 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/IMatterValue.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/IMatterValue.kt @@ -4,6 +4,10 @@ import net.minecraft.network.FriendlyByteBuf import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.readDecimal import ru.dbotthepony.mc.otm.core.math.writeDecimal +import ru.dbotthepony.mc.otm.core.util.readDouble +import ru.dbotthepony.mc.otm.core.util.writeDouble +import java.io.InputStream +import java.io.OutputStream interface IMatterValue : Comparable { val matter: Decimal @@ -51,6 +55,11 @@ fun FriendlyByteBuf.writeMatterValue(value: IMatterValue) { writeDouble(value.complexity) } +fun OutputStream.writeMatterValue(value: IMatterValue) { + writeDecimal(value.matter) + writeDouble(value.complexity) +} + fun FriendlyByteBuf.readMatterValue(): IMatterValue { val matter = readDecimal() val complexity = readDouble() @@ -62,6 +71,17 @@ fun FriendlyByteBuf.readMatterValue(): IMatterValue { } } +fun InputStream.readMatterValue(): IMatterValue { + val matter = readDecimal() + val complexity = readDouble() + + if (matter.isZero && complexity == 0.0) { + return IMatterValue.Companion + } else { + return MatterValue(matter, complexity) + } +} + data class MatterValue( override val matter: Decimal, override val complexity: Double diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 683c9953d..34056cfe8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -10,6 +10,8 @@ import com.google.gson.JsonParseException import com.google.gson.JsonSyntaxException import com.mojang.brigadier.arguments.StringArgumentType import com.mojang.brigadier.context.CommandContext +import it.unimi.dsi.fastutil.io.FastByteArrayInputStream +import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream import it.unimi.dsi.fastutil.objects.Object2BooleanFunction import it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap import it.unimi.dsi.fastutil.objects.Reference2BooleanFunction @@ -66,6 +68,7 @@ import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.filterNotNull +import ru.dbotthepony.mc.otm.core.getID import ru.dbotthepony.mc.otm.core.util.formatMatter import ru.dbotthepony.mc.otm.core.util.formatMatterFull import ru.dbotthepony.mc.otm.core.util.formatSiComponent @@ -78,19 +81,25 @@ import ru.dbotthepony.mc.otm.core.readItemType import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.core.stream import ru.dbotthepony.mc.otm.core.util.readBinaryComponent +import ru.dbotthepony.mc.otm.core.util.readCollection import ru.dbotthepony.mc.otm.core.util.writeBinaryComponent -import ru.dbotthepony.mc.otm.core.writeItemType +import ru.dbotthepony.mc.otm.core.util.writeCollection import ru.dbotthepony.mc.otm.milliTime import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.RegistryNetworkChannel import ru.dbotthepony.mc.otm.registry.RegistryDelegate import ru.dbotthepony.mc.otm.storage.ItemStackWrapper +import java.io.DataInputStream +import java.io.DataOutputStream import java.io.File +import java.io.OutputStream import java.math.BigInteger import java.util.* import java.util.function.BooleanSupplier import java.util.function.Supplier import java.util.stream.Stream +import java.util.zip.Deflater +import java.util.zip.Inflater import kotlin.ConcurrentModificationException import kotlin.collections.ArrayDeque import kotlin.collections.ArrayList @@ -1399,12 +1408,70 @@ object MatterManager { val time = SystemTime() - val result = SyncPacket( - buff.readMap(FriendlyByteBuf::readItemType, FriendlyByteBuf::readMatterValue), - buff.readMap(FriendlyByteBuf::readItemType) { self -> self.readCollection(::ArrayList, FriendlyByteBuf::readBinaryComponent) } - ) + val bbytes = ByteArray(buff.readableBytes()) + buff.readBytes(bbytes) - LOGGER.debug("Reading matter registry packet took ${time.millis}ms") + val chunks = ArrayList() + var size = 0 + val inflater = Inflater() + inflater.setInput(bbytes) + + while (!inflater.finished()) { + val chunk = ByteArray(4096) + val inflated = inflater.inflate(chunk) + + if (inflated == 0) { + break + } else { + size += inflated + + if (size >= 1 shl 24 /* 16 MiB */) { + throw IndexOutOfBoundsException("Pipe Bomb") + } + + if (inflated == 4096) { + chunks.add(chunk) + } else { + chunks.add(chunk.copyOfRange(0, inflated)) + } + } + } + + val spliced = ByteArray(size) + var pointer = 0 + + for (chunk in chunks) { + for (i in chunk.indices) { + spliced[pointer++] = chunk[i] + } + } + + val stream = FastByteArrayInputStream(spliced) + val data = DataInputStream(stream) + + val valuesSize = data.readInt() + val values = Reference2ObjectOpenHashMap(valuesSize) + val comments = Reference2ObjectOpenHashMap>() + + for (i in 0 until valuesSize) { + val type = data.readItemType() + check(values.put(type, data.readMatterValue()) == null) { "Duplicate item type $type" } + + if (data.read() > 0) { + comments[type] = data.readCollection { readBinaryComponent()!! } + } + } + + val commentsSize = data.readInt() + + for (i in 0 until commentsSize) { + val type = data.readItemType() + check(comments.put(type, data.readCollection { readBinaryComponent()!! }) == null) { "Duplicate commentary item type $type" } + } + + val result = SyncPacket(values, comments) + + LOGGER.debug("Reading matter registry packet took ${time.millis}ms (${bbytes.size} bytes compressed, $size bytes total)") return result } @@ -1415,9 +1482,54 @@ object MatterManager { ) : MatteryPacket { override fun write(buff: FriendlyByteBuf) { val time = SystemTime() - buff.writeMap(values, FriendlyByteBuf::writeItemType, FriendlyByteBuf::writeMatterValue) - buff.writeMap(comments, FriendlyByteBuf::writeItemType) { self, value -> self.writeCollection(value, FriendlyByteBuf::writeBinaryComponent) } - LOGGER.debug("Encoding matter registry packet took ${time.millis}ms, written total ${buff.writerIndex() - 1} bytes") + + val stream = FastByteArrayOutputStream() + val data = DataOutputStream(stream) + + var commentsSize = comments.size + data.writeInt(values.size) + + for ((k, v) in values) { + data.writeInt(ForgeRegistries.ITEMS.getID(k)) + data.writeMatterValue(v) + + val comment = comments[k] + + if (comment != null) { + commentsSize-- + data.write(1) + data.writeCollection(comment, OutputStream::writeBinaryComponent) + } else { + data.write(0) + } + } + + data.writeInt(commentsSize) + + for ((k, v) in comments) { + if (!values.containsKey(k)) { + data.writeInt(ForgeRegistries.ITEMS.getID(k)) + data.writeCollection(v, OutputStream::writeBinaryComponent) + } + } + + val deflater = Deflater(5) + deflater.setInput(stream.array, 0, stream.length) + deflater.finish() + + val bytes = ByteArray(4096) + + while (true) { + val written = deflater.deflate(bytes) + + if (written == 0) { + break + } else { + buff.writeBytes(bytes, 0, written) + } + } + + LOGGER.debug("Encoding matter registry packet took ${time.millis}ms, (${stream.length} bytes total, ${buff.writerIndex() - 1} bytes compressed)") } override fun play(context: Supplier) { @@ -1432,7 +1544,7 @@ object MatterManager { commentary.clear() for ((k, v) in comments) { - commentary[k] = ArrayList(v.size).also { it.addAll(v) } + commentary[k] = ArrayList(v) } LOGGER.debug("Updating matter registry from packet took ${time.millis}ms") From f004c6299042ad03b990671213d86198079371cb Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 3 Mar 2023 21:26:44 +0700 Subject: [PATCH 0272/1199] Increase (de)compress buffer sizes --- .../kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 34056cfe8..b6a9c2a0b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -1417,7 +1417,7 @@ object MatterManager { inflater.setInput(bbytes) while (!inflater.finished()) { - val chunk = ByteArray(4096) + val chunk = ByteArray(2 shl 16) val inflated = inflater.inflate(chunk) if (inflated == 0) { @@ -1429,7 +1429,7 @@ object MatterManager { throw IndexOutOfBoundsException("Pipe Bomb") } - if (inflated == 4096) { + if (inflated == 2 shl 16) { chunks.add(chunk) } else { chunks.add(chunk.copyOfRange(0, inflated)) @@ -1517,7 +1517,7 @@ object MatterManager { deflater.setInput(stream.array, 0, stream.length) deflater.finish() - val bytes = ByteArray(4096) + val bytes = ByteArray(2 shl 16) while (true) { val written = deflater.deflate(bytes) From 024d46638ed39dbb8a08a2a5cd1a5a45225d7e98 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 3 Mar 2023 22:02:34 +0700 Subject: [PATCH 0273/1199] Multi packet mattery registry sync --- .../mc/otm/matter/MatterManager.kt | 212 +++++++++++------- 1 file changed, 128 insertions(+), 84 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index b6a9c2a0b..c9839c011 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -1379,7 +1379,7 @@ object MatterManager { matterValues[item] = value } - RegistryNetworkChannel.send(PacketDistributor.ALL.noArg(), SyncPacket(matterValues, commentary)) + syncRegistry(PacketDistributor.ALL.noArg()) } fun onDataPackSync(event: OnDatapackSyncEvent) { @@ -1387,9 +1387,9 @@ object MatterManager { return if (event.player == null) { - RegistryNetworkChannel.send(PacketDistributor.ALL.noArg(), SyncPacket(matterValues, commentary)) + syncRegistry(PacketDistributor.ALL.noArg()) } else { - RegistryNetworkChannel.send(PacketDistributor.PLAYER.with { event.player ?: throw ConcurrentModificationException() }, SyncPacket(matterValues, commentary)) + syncRegistry(PacketDistributor.PLAYER.with { event.player ?: throw ConcurrentModificationException() }) } } @@ -1403,18 +1403,100 @@ object MatterManager { return matterValues[value] ?: IMatterValue.Companion } - fun readSyncPacket(buff: FriendlyByteBuf): SyncPacket { - LOGGER.info("Received matter registry packet, ${buff.readableBytes()} bytes in size") + private val receivedPackets = ArrayList() + private fun syncRegistry(distributor: PacketDistributor.PacketTarget) { val time = SystemTime() + val stream = FastByteArrayOutputStream() + val data = DataOutputStream(stream) - val bbytes = ByteArray(buff.readableBytes()) - buff.readBytes(bbytes) + var commentsSize = commentary.size + data.writeInt(matterValues.size) + + for ((k, v) in matterValues) { + data.writeInt(ForgeRegistries.ITEMS.getID(k)) + data.writeMatterValue(v) + + val comment = commentary[k] + + if (comment != null) { + commentsSize-- + data.write(1) + data.writeCollection(comment, OutputStream::writeBinaryComponent) + } else { + data.write(0) + } + } + + data.writeInt(commentsSize) + + for ((k, v) in commentary) { + if (!matterValues.containsKey(k)) { + data.writeInt(ForgeRegistries.ITEMS.getID(k)) + data.writeCollection(v, OutputStream::writeBinaryComponent) + } + } + + val deflater = Deflater(5) + deflater.setInput(stream.array, 0, stream.length) + deflater.finish() + + val chunks = ArrayList() + var totalSize = 0 + var first = true + + while (true) { + val bytes = ByteArray(2 shl 20 - 1024) + val written = deflater.deflate(bytes) + + if (written == 0) { + break + } else { + totalSize += written + chunks.add(SyncPacket(bytes, written, if (first) { first = false; FIRST } else NORMAL)) + } + } + + if (chunks.size == 1) { + chunks[0].mode = FIRST_AND_LAST + } else if(chunks.size > 1) { + chunks.last().mode = LAST + } + + LOGGER.debug("Encoding matter registry packet took ${time.millis}ms, (${stream.length} bytes total, $totalSize bytes compressed)") + + for (chunk in chunks) { + RegistryNetworkChannel.send(distributor, chunk) + } + } + + private fun playRegistryPackets() { + val time = SystemTime() + var totalCompressedSize = 0 + + for (chunk in receivedPackets) { + totalCompressedSize += chunk.length + } + + if (totalCompressedSize == 0) { + return // what. + } + + val compressed = ByteArray(totalCompressedSize) + var pointer = 0 + + for (chunk in receivedPackets) { + for (i in 0 until chunk.length) { + compressed[pointer++] = chunk.payload[i] + } + } + + receivedPackets.clear() val chunks = ArrayList() var size = 0 val inflater = Inflater() - inflater.setInput(bbytes) + inflater.setInput(compressed) while (!inflater.finished()) { val chunk = ByteArray(2 shl 16) @@ -1438,11 +1520,11 @@ object MatterManager { } val spliced = ByteArray(size) - var pointer = 0 + var pointer2 = 0 for (chunk in chunks) { for (i in chunk.indices) { - spliced[pointer++] = chunk[i] + spliced[pointer2++] = chunk[i] } } @@ -1450,15 +1532,16 @@ object MatterManager { val data = DataInputStream(stream) val valuesSize = data.readInt() - val values = Reference2ObjectOpenHashMap(valuesSize) - val comments = Reference2ObjectOpenHashMap>() + + matterValues.clear() + commentary.clear() for (i in 0 until valuesSize) { val type = data.readItemType() - check(values.put(type, data.readMatterValue()) == null) { "Duplicate item type $type" } + check(matterValues.put(type, data.readMatterValue()) == null) { "Duplicate item type $type" } if (data.read() > 0) { - comments[type] = data.readCollection { readBinaryComponent()!! } + commentary[type] = data.readCollection { readBinaryComponent()!! } } } @@ -1466,88 +1549,49 @@ object MatterManager { for (i in 0 until commentsSize) { val type = data.readItemType() - check(comments.put(type, data.readCollection { readBinaryComponent()!! }) == null) { "Duplicate commentary item type $type" } + check(commentary.put(type, data.readCollection { readBinaryComponent()!! }) == null) { "Duplicate commentary item type $type" } } - val result = SyncPacket(values, comments) - - LOGGER.debug("Reading matter registry packet took ${time.millis}ms (${bbytes.size} bytes compressed, $size bytes total)") - - return result + LOGGER.debug("Decoding matter registry packets took ${time.millis}ms ($totalCompressedSize bytes compressed, $size bytes total)") } - class SyncPacket( - val values: Map, - val comments: Map> - ) : MatteryPacket { + fun readSyncPacket(buff: FriendlyByteBuf): SyncPacket { + LOGGER.info("Received matter registry packet, ${buff.readableBytes()} bytes in size") + + val mode = buff.readByte() + val bytes = ByteArray(buff.readableBytes()) + buff.readBytes(bytes) + return SyncPacket(bytes, bytes.size, mode.toInt()) + } + + private const val FIRST = 0 + private const val NORMAL = 1 + private const val LAST = 2 + private const val FIRST_AND_LAST = 3 + + class SyncPacket(val payload: ByteArray, val length: Int, var mode: Int) : MatteryPacket { override fun write(buff: FriendlyByteBuf) { - val time = SystemTime() - - val stream = FastByteArrayOutputStream() - val data = DataOutputStream(stream) - - var commentsSize = comments.size - data.writeInt(values.size) - - for ((k, v) in values) { - data.writeInt(ForgeRegistries.ITEMS.getID(k)) - data.writeMatterValue(v) - - val comment = comments[k] - - if (comment != null) { - commentsSize-- - data.write(1) - data.writeCollection(comment, OutputStream::writeBinaryComponent) - } else { - data.write(0) - } - } - - data.writeInt(commentsSize) - - for ((k, v) in comments) { - if (!values.containsKey(k)) { - data.writeInt(ForgeRegistries.ITEMS.getID(k)) - data.writeCollection(v, OutputStream::writeBinaryComponent) - } - } - - val deflater = Deflater(5) - deflater.setInput(stream.array, 0, stream.length) - deflater.finish() - - val bytes = ByteArray(2 shl 16) - - while (true) { - val written = deflater.deflate(bytes) - - if (written == 0) { - break - } else { - buff.writeBytes(bytes, 0, written) - } - } - - LOGGER.debug("Encoding matter registry packet took ${time.millis}ms, (${stream.length} bytes total, ${buff.writerIndex() - 1} bytes compressed)") + buff.writeByte(mode) + buff.writeBytes(payload, 0, length) } override fun play(context: Supplier) { if (SERVER_IS_LIVE) return // singleplayer or LAN host - val time = SystemTime() - - matterValues.clear() - matterValues.putAll(values) - - commentary.clear() - - for ((k, v) in comments) { - commentary[k] = ArrayList(v) + if (mode == FIRST) { + receivedPackets.clear() + receivedPackets.add(this) + } else if (mode == LAST) { + receivedPackets.add(this) + playRegistryPackets() + } else if (mode == FIRST_AND_LAST) { + receivedPackets.clear() + receivedPackets.add(this) + playRegistryPackets() + } else { + receivedPackets.add(this) } - - LOGGER.debug("Updating matter registry from packet took ${time.millis}ms") } } } From f4146ffea98bf95a16fdbe1943aaea7a34be3229 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 3 Mar 2023 22:09:12 +0700 Subject: [PATCH 0274/1199] Tritanium anvil matter values --- src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt index d441ceef3..6312d20f2 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt @@ -16,6 +16,10 @@ fun addMatterData(provider: MatterDataProvider) { provider.inherit(Items.CHIPPED_ANVIL, Items.ANVIL, 0.75) provider.inherit(Items.DAMAGED_ANVIL, Items.ANVIL, 0.5) + for (i in 1 until MItems.TRITANIUM_ANVIL.size) { + provider.inherit(MItems.TRITANIUM_ANVIL[i], MItems.TRITANIUM_ANVIL[i - 1], 0.85) + } + val copper = listOf, Item>>( listOf( Items.EXPOSED_COPPER, From 441f358e121487e805da67877f58ecda289805fe Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 6 Mar 2023 00:20:59 +0700 Subject: [PATCH 0275/1199] Matter panel sorting (with buttons), cleanup nbt extensions --- .../mc/otm/datagen/lang/English.kt | 8 ++ .../mc/otm/datagen/lang/Russian.kt | 8 ++ .../block/entity/MatteryPoweredBlockEntity.kt | 7 - .../mc/otm/block/entity/RedstoneControl.kt | 4 +- .../entity/blackhole/BlackHoleBlockEntity.kt | 4 +- .../entity/matter/MatterPanelBlockEntity.kt | 60 ++++++-- .../entity/storage/ItemMonitorBlockEntity.kt | 8 +- .../entity/tech/EnergyCounterBlockEntity.kt | 3 +- .../capability/drive/AbstractMatteryDrive.kt | 7 +- .../energy/BlockEnergyStorageImpl.kt | 8 +- .../mc/otm/client/render/WidgetLocation.kt | 2 +- .../mc/otm/client/render/Widgets18.kt | 12 +- .../client/screen/matter/MatterPanelScreen.kt | 43 +++++- .../otm/client/screen/panels/EditablePanel.kt | 38 ++--- .../mc/otm/client/screen/panels/FramePanel.kt | 12 ++ .../button/BooleanRectangleButtonPanel.kt | 46 +++++- .../client/screen/panels/button/Buttons.kt | 135 +++++++++++------- .../panels/button/EnumRectangleButtonPanel.kt | 6 +- .../LargeBooleanRectangleButtonPanel.kt | 5 +- .../mc/otm/container/ItemFilter.kt | 4 +- .../mc/otm/container/MatteryContainer.kt | 4 +- .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 70 ++++++++- .../mc/otm/core/nbt/CompoundTagExt.kt | 55 ++----- .../mc/otm/core/util/ItemSorter.kt | 83 +++++++++++ .../mc/otm/item/PatternStorageItem.kt | 18 +-- .../otm/item/PortableCondensationDriveItem.kt | 4 +- .../mc/otm/menu/matter/MatterPanelMenu.kt | 59 ++++---- .../mc/otm/network/FieldSynchronizer.kt | 5 +- .../mc/otm/registry/MCreativeTabs.kt | 3 + .../textures/gui/widgets/storage_controls.png | Bin 711 -> 803 bytes .../textures/gui/widgets/storage_controls.xcf | Bin 3189 -> 4408 bytes .../mc/otm/tests/ComparatorTests.kt | 34 +++++ 32 files changed, 534 insertions(+), 221 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt create mode 100644 src/test/kotlin/ru/dbotthepony/mc/otm/tests/ComparatorTests.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 72e387605..4305eb16f 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -638,6 +638,14 @@ private fun gui(provider: MatteryLanguageProvider) { gui("side_mode.pull", "Pull") gui("side_mode.push", "Push") + + gui("sorting.default", "Default sorting") + gui("sorting.name", "Sort by name") + gui("sorting.id", "Sort by ID") + gui("sorting.modid", "Sort by Namespace (mod) ID") + gui("sorting.count", "Sort by amount") + gui("sorting.ascending", "Ascending") + gui("sorting.descending", "Descending") } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index e1390b173..8a2872690 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -643,6 +643,14 @@ private fun gui(provider: MatteryLanguageProvider) { gui("side_mode.pull", "Автоматическое вытягивание") gui("side_mode.push", "Автоматическое выталкивание") + + gui("sorting.default", "Сортировка по умолчанию") + gui("sorting.name", "Сортировка по имени") + gui("sorting.id", "Сортировка по ID") + gui("sorting.modid", "Сортировка по пространству имён (моду)") + gui("sorting.count", "Сортировка по количеству") + gui("sorting.ascending", "Возрастающая") + gui("sorting.descending", "Убывающая") } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt index 05de98e43..9a7390335 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt @@ -2,30 +2,23 @@ package ru.dbotthepony.mc.otm.block.entity import net.minecraft.ChatFormatting import net.minecraft.core.BlockPos -import net.minecraft.core.Direction import net.minecraft.nbt.CompoundTag import net.minecraft.network.chat.Component import net.minecraft.world.item.BlockItem import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.BlockGetter -import net.minecraft.world.level.Level import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState -import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities -import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.capability.* -import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.energy.ItemEnergyStorageImpl import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.nbt.ifHas import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.nbt.map -import ru.dbotthepony.mc.otm.core.nbt.set abstract class MatteryPoweredBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(p_155228_, p_155229_, p_155230_) { val batteryContainer = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt index e6d4c3180..4650d6263 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.block.entity import net.minecraft.nbt.CompoundTag import net.minecraftforge.common.util.INBTSerializable -import ru.dbotthepony.mc.otm.core.nbt.getEnum +import ru.dbotthepony.mc.otm.core.nbt.mapString import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.network.FieldSynchronizer @@ -30,7 +30,7 @@ abstract class AbstractRedstoneControl : INBTSerializable { return } - redstoneSetting = nbt.getEnum(SETTING_KEY) + redstoneSetting = nbt.mapString(SETTING_KEY, RedstoneSetting::valueOf, RedstoneSetting.LOW) redstoneSignal = nbt.getInt(SIGNAL_KEY) } 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 52df29f0b..e95438428 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 @@ -27,7 +27,7 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRegistry import ru.dbotthepony.mc.otm.core.math.getSphericalBlockPositions -import ru.dbotthepony.mc.otm.core.nbt.mapIf +import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.triggers.BlackHoleTrigger @@ -164,7 +164,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery override fun load(tag: CompoundTag) { super.load(tag) - mass = tag.mapIf("mass", Decimal::deserializeNBT) ?: BASELINE_MASS + mass = tag.map("mass", Decimal::deserializeNBT) ?: BASELINE_MASS spinDirection = tag.getBoolean("spin_direction") } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt index 86e34f8c2..7aabff5bb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt @@ -1,5 +1,7 @@ package ru.dbotthepony.mc.otm.block.entity.matter +import it.unimi.dsi.fastutil.objects.Object2ObjectFunction +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap import net.minecraft.core.BlockPos import net.minecraft.world.level.block.state.BlockState import ru.dbotthepony.mc.otm.menu.matter.MatterPanelMenu @@ -11,13 +13,17 @@ import java.util.HashMap import java.util.UUID import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.ListTag -import net.minecraft.nbt.Tag -import net.minecraft.network.chat.Component import net.minecraft.server.level.ServerLevel import net.minecraft.world.level.Level -import ru.dbotthepony.mc.otm.core.TranslatableComponent +import net.minecraftforge.common.util.INBTSerializable import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.matter.* +import ru.dbotthepony.mc.otm.core.nbt.getBoolean +import ru.dbotthepony.mc.otm.core.nbt.getCompoundList +import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.nbt.mapString +import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.core.util.ItemSorter import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph @@ -28,6 +34,26 @@ import java.util.stream.Stream class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.MATTER_PANEL, p_155229_, p_155230_), IMatterGraphNode, IReplicationTaskProvider { + class PlayerSettings(var sorter: ItemSorter = ItemSorter.DEFAULT, var ascending: Boolean = true) : INBTSerializable { + override fun serializeNBT(): CompoundTag { + return CompoundTag().also { + it["sorter"] = sorter.name + it["ascending"] = ascending + } + } + + override fun deserializeNBT(nbt: CompoundTag) { + sorter = nbt.mapString("sorter", ItemSorter::valueOf, ItemSorter.DEFAULT) + ascending = nbt.getBoolean("ascending", true) + } + } + + private val playerSettings = Object2ObjectOpenHashMap() + + fun getPlayerSettings(ply: Player): PlayerSettings { + return playerSettings.computeIfAbsent(ply.uuid, Object2ObjectFunction { PlayerSettings() }) + } + private val listeners = ArrayList() override val matterNode = Graph6Node(this) @@ -39,9 +65,6 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : listeners.remove(menu) } - override val defaultDisplayName: Component - get() = MACHINE_NAME - override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { return MatterPanelMenu(containerID, inventory, this) } @@ -131,13 +154,21 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : list.add(task.serializeNBT()) } - nbt.put("tasks", list) + nbt["tasks"] = list + + val settings = CompoundTag() + + for ((uuid, value) in playerSettings) { + settings[uuid.toString()] = value.serializeNBT() + } + + nbt["settings"] = settings } override fun load(nbt: CompoundTag) { super.load(nbt) _tasks.clear() - val list = nbt.getList("tasks", Tag.TAG_COMPOUND.toInt()) + val list = nbt.getCompoundList("tasks") for (tag in list) { val task = ReplicationTask.deserializeNBT(tag) @@ -146,6 +177,15 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : _tasks[task.id] = task } } + + playerSettings.clear() + + nbt.map("settings") { it: CompoundTag -> + for (k in it.allKeys) { + playerSettings.computeIfAbsent(UUID.fromString(k), Object2ObjectFunction { PlayerSettings() }) + .deserializeNBT(it.getCompound(k)) + } + } } override fun getTask(id: UUID): ReplicationTask? { @@ -184,8 +224,4 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : _tasks.clear() } - - companion object { - private val MACHINE_NAME = TranslatableComponent("block.overdrive_that_matters.matter_panel") - } } 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 224c4df97..614b60b56 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 @@ -35,7 +35,7 @@ import ru.dbotthepony.mc.otm.graph.storage.StorageNetworkGraph import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.container.set -import ru.dbotthepony.mc.otm.core.nbt.getEnum +import ru.dbotthepony.mc.otm.core.nbt.mapString import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.menu.storage.ItemMonitorMenu import ru.dbotthepony.mc.otm.storage.* @@ -93,9 +93,9 @@ class ItemMonitorPlayerSettings : INBTSerializable, MatteryPacket { } override fun deserializeNBT(nbt: CompoundTag) { - ingredientPriority = nbt.getEnum(INGREDIENT_PRIORITY_KEY) - resultTarget = nbt.getEnum(RESULT_TARGET_KEY) - craftingAmount = nbt.getEnum(QUICK_CRAFT_AMOUNT_KEY) + ingredientPriority = nbt.mapString(INGREDIENT_PRIORITY_KEY, IngredientPriority::valueOf, IngredientPriority.SYSTEM) + resultTarget = nbt.mapString(RESULT_TARGET_KEY, ResultTarget::valueOf, ResultTarget.MIXED) + craftingAmount = nbt.mapString(QUICK_CRAFT_AMOUNT_KEY, Amount::valueOf, Amount.STACK) } fun read(buff: FriendlyByteBuf) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt index 82fcf0fee..3819c32bb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt @@ -20,7 +20,6 @@ import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.getDecimal import ru.dbotthepony.mc.otm.core.nbt.getByteArrayList -import ru.dbotthepony.mc.otm.core.nbt.ifHas import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.menu.tech.EnergyCounterMenu @@ -101,7 +100,7 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat passed = nbt.getDecimal(PASSED_ENERGY_KEY) ioLimit = nbt.map(IO_LIMIT_KEY, Decimal.Companion::deserializeNBT) - nbt.ifHas(POWER_HISTORY_POINTER_KEY, IntTag::class.java) { + nbt.map(POWER_HISTORY_POINTER_KEY) { it: IntTag -> historyTick = it.asInt } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/AbstractMatteryDrive.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/AbstractMatteryDrive.kt index 60f568e8c..fec2c6b25 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/AbstractMatteryDrive.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/AbstractMatteryDrive.kt @@ -11,7 +11,7 @@ import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.math.BigInteger import ru.dbotthepony.mc.otm.core.math.isPositive import ru.dbotthepony.mc.otm.core.math.serializeNBT -import ru.dbotthepony.mc.otm.core.nbt.ifHas +import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.storage.* import java.math.BigInteger @@ -176,10 +176,7 @@ abstract class AbstractMatteryDrive @JvmOverloads constructor storedDifferentStacks = 0 // nextID = 0L - nbt.ifHas("capacity") { - driveCapacity = BigInteger(it) - } - + driveCapacity = nbt.map("capacity", ::BigInteger) ?: driveCapacity maxDifferentStacks = nbt.getInt("max_different_stacks") for (entry in nbt.getList("items", Tag.TAG_COMPOUND.toInt())) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt index 9afcbe58d..26ae42578 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt @@ -16,12 +16,10 @@ import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.config.VerboseBalanceValues -import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.core.nbt.map -import ru.dbotthepony.mc.otm.core.nbt.mapIf import ru.dbotthepony.mc.otm.core.nbt.set sealed class BlockEnergyStorageImpl( @@ -142,9 +140,9 @@ sealed class BlockEnergyStorageImpl( override fun deserializeNBT(nbt: CompoundTag?) { if (nbt == null) return batteryLevel = nbt.map(ENERGY_STORED_KEY, Decimal.Companion::deserializeNBT) ?: Decimal.ZERO - maxBatteryLevelStorage = nbt.mapIf(ENERGY_STORED_MAX_KEY, Decimal.Companion::deserializeNBT) - maxInputStorage = nbt.mapIf(MAX_INPUT_KEY, Decimal.Companion::deserializeNBT) - maxOutputStorage = nbt.mapIf(MAX_OUTPUT_KEY, Decimal.Companion::deserializeNBT) + maxBatteryLevelStorage = nbt.map(ENERGY_STORED_MAX_KEY, Decimal.Companion::deserializeNBT) + maxInputStorage = nbt.map(MAX_INPUT_KEY, Decimal.Companion::deserializeNBT) + maxOutputStorage = nbt.map(MAX_OUTPUT_KEY, Decimal.Companion::deserializeNBT) } var resolver: LazyOptional = LazyOptional.of { this } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt index 5b13d0273..2588604cf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt @@ -5,7 +5,7 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters object WidgetLocation { val LARGE_BUTTON = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/large_button.png"), 72f, 18f) - val STORAGE_CONTROLS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/storage_controls.png"), 90f, 18f) + val STORAGE_CONTROLS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/storage_controls.png"), 90f, 36f) val MISC_18 = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/misc18.png"), 72f, 72f) val SLOT_BACKGROUNDS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/slot_backgrounds.png"), 72f, 72f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt index 603a47cb6..09c145a92 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt @@ -34,12 +34,14 @@ object Widgets18 { val BUTTON_DISABLED_STRETCHABLE = makeButton(buttonGrids) val BUTTON_DISABLED = buttonGrids.next() - private val storageGrid = WidgetLocation.STORAGE_CONTROLS.grid(rows = 1, columns = 5) + private val storageGrid = WidgetLocation.STORAGE_CONTROLS.grid(rows = 2, columns = 5) val ARROW_DOWN = storageGrid.next() - val AZ = storageGrid.next() - val COUNT = storageGrid.next() - val COLON = storageGrid.next() - val C = storageGrid.next() + val ARROW_UP = storageGrid.next() + val SORT_DEFAULT = storageGrid.next() + val SORT_ALPHABET = storageGrid.next() + val SORT_COUNT = storageGrid.next() + val SORT_MODID = storageGrid.next() + val SORT_ID = storageGrid.next() private val miscGrid = WidgetLocation.MISC_18.grid(4, 4) 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 75c0a72fe..f5c9b847f 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 @@ -8,15 +8,20 @@ import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.capability.matter.IPatternState import ru.dbotthepony.mc.otm.capability.matter.IReplicationTask import ru.dbotthepony.mc.otm.client.render.WidgetLocation +import ru.dbotthepony.mc.otm.client.render.Widgets18 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 +import ru.dbotthepony.mc.otm.client.screen.panels.button.DeviceControls +import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeBooleanRectangleButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeEnumRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.input.EditBoxPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.ScrollBarConstants import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.integerDivisionDown +import ru.dbotthepony.mc.otm.core.util.ItemSorter import ru.dbotthepony.mc.otm.menu.matter.MatterPanelMenu import ru.dbotthepony.mc.otm.menu.matter.ReplicationRequestPacket import ru.dbotthepony.mc.otm.network.MenuNetworkChannel @@ -28,26 +33,50 @@ class MatterPanelScreen( inventory: Inventory, title: Component ) : MatteryScreen(menu, inventory, title) { - override fun makeMainFrame(): FramePanel> { + override fun makeMainFrame(): FramePanel> { var isPatternView = true + var scrollPatterns = 0 + var scrollTasks = 0 val frame = FramePanel.padded(this, null, GRID_WIDTH * AbstractSlotPanel.SIZE + ScrollBarConstants.WIDTH + 4f, GRID_HEIGHT * AbstractSlotPanel.SIZE, title) + val controls = DeviceControls(this, frame) + + LargeBooleanRectangleButtonPanel(this, controls, + prop = menu.isAscendingGS, + skinElementActive = Widgets18.ARROW_UP, + skinElementInactive = Widgets18.ARROW_DOWN, + tooltipActive = TranslatableComponent("otm.gui.sorting.ascending"), + tooltipInactive = TranslatableComponent("otm.gui.sorting.descending"), + ).also { + controls.addButton(it) + } + + LargeEnumRectangleButtonPanel(this, controls, enum = ItemSorter::class.java, prop = menu.sortingGS, defaultValue = ItemSorter.DEFAULT).also { + controls.addButton(it) + it.add(ItemSorter.DEFAULT, skinElement = Widgets18.SORT_DEFAULT, tooltip = ItemSorter.DEFAULT.title) + it.add(ItemSorter.NAME, skinElement = Widgets18.SORT_ALPHABET, tooltip = ItemSorter.NAME.title) + it.add(ItemSorter.ID, skinElement = Widgets18.SORT_ID, tooltip = ItemSorter.ID.title) + it.add(ItemSorter.MOD, skinElement = Widgets18.SORT_MODID, tooltip = ItemSorter.MOD.title) + } + val scrollBar = DiscreteScrollBarPanel(this, frame, { if (isPatternView) { - integerDivisionDown(menu.patterns.size, GRID_WIDTH) + scrollPatterns = integerDivisionDown(menu.patterns.size, GRID_WIDTH) + scrollPatterns } else { - integerDivisionDown(menu.tasks.size, GRID_WIDTH) + scrollTasks = integerDivisionDown(menu.tasks.size, GRID_WIDTH) + scrollTasks } }, { _, _, _ -> }) scrollBar.dock = Dock.RIGHT - frame.Tab(onOpen = { isPatternView = true }, activeIcon = PATTERN_LIST_ACTIVE, inactiveIcon = PATTERN_LIST_INACTIVE).also { + frame.Tab(onOpen = { isPatternView = true; scrollBar.scroll = scrollPatterns }, activeIcon = PATTERN_LIST_ACTIVE, inactiveIcon = PATTERN_LIST_INACTIVE).also { it.tooltip = TranslatableComponent("otm.container.matter_panel.patterns") } - frame.Tab(onOpen = { isPatternView = false }, activeIcon = TASK_LIST_ACTIVE, inactiveIcon = TASK_LIST_INACTIVE).also { + frame.Tab(onOpen = { isPatternView = false; scrollBar.scroll = scrollTasks }, activeIcon = TASK_LIST_ACTIVE, inactiveIcon = TASK_LIST_INACTIVE).also { it.tooltip = TranslatableComponent("otm.container.matter_panel.tasks") } @@ -133,6 +162,8 @@ class MatterPanelScreen( private fun openTask(task: IReplicationTask<*>) { val frame = FramePanel.padded(this, null, 170f, 20f, TranslatableComponent("otm.container.matter_panel.task")) + frame.closeOnEscape = true + object : AbstractSlotPanel(this@MatterPanelScreen, frame) { init { dock = Dock.LEFT @@ -175,6 +206,8 @@ class MatterPanelScreen( private fun openPattern(pattern: IPatternState) { val frame = FramePanel.padded(this, null, 213f, (ButtonPanel.HEIGHT + 3f) * 4f, TranslatableComponent("otm.container.matter_panel.task")) + frame.closeOnEscape = true + val rowTop = EditablePanel(this, frame, height = ButtonPanel.HEIGHT) val rowInput = EditablePanel(this, frame, height = ButtonPanel.HEIGHT) val rowBottom = EditablePanel(this, frame, height = ButtonPanel.HEIGHT) 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 23b8853fb..5f7f9d528 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 @@ -345,10 +345,7 @@ open class EditablePanel @JvmOverloads constructor( fun flash() { isFlashing = true - - if (parent == null) { - popup() - } + popup() } val isFlashFrame: Boolean @@ -1338,11 +1335,7 @@ open class EditablePanel @JvmOverloads constructor( final override fun mouseClicked(x: Double, y: Double, button: Int): Boolean { if (!isVisible() || !acceptMouseInput) return false - - if (flashAnyBlocker()) { - return true - } - + if (flashAnyBlocker()) return true if (grabMouseInput) return mouseClickedInner(x, y, button) for (child in visibleChildrenInternal) { @@ -1366,9 +1359,11 @@ open class EditablePanel @JvmOverloads constructor( if (!isVisible() || !acceptMouseInput) return false if (isGrabbingMouseInput() || withinBounds(x, y)) { - if (acceptMouseInput && parent == null) popup() + popup() return mouseClicked(x, y, button) } else if (withinExtendedBounds(x, y)) { + popup(false) + for (child in visibleChildrenInternal) { if (child.mouseClickedChecked(x, y, button)) { killFocusForEverythingExcept(child) @@ -1390,11 +1385,7 @@ open class EditablePanel @JvmOverloads constructor( final override fun mouseReleased(x: Double, y: Double, button: Int): Boolean { if (!isVisible() || !acceptMouseInput) return false - - if (flashAnyBlocker(false)) { - return true - } - + if (flashAnyBlocker(false)) return true if (grabMouseInput) return mouseReleasedInner(x, y, button) for (child in visibleChildrenInternal) { @@ -1434,11 +1425,7 @@ open class EditablePanel @JvmOverloads constructor( final override fun mouseDragged(x: Double, y: Double, button: Int, xDelta: Double, yDelta: Double): Boolean { if (!isVisible() || !acceptMouseInput) return false - - if (flashAnyBlocker(false)) { - return true - } - + if (flashAnyBlocker(false)) return true if (grabMouseInput) return mouseDraggedInner(x, y, button, xDelta, yDelta) for (child in visibleChildrenInternal) { @@ -1472,7 +1459,6 @@ open class EditablePanel @JvmOverloads constructor( return false } - protected open fun mouseScrolledInner(x: Double, y: Double, scroll: Double): Boolean { return true } @@ -1537,6 +1523,7 @@ open class EditablePanel @JvmOverloads constructor( } } + if (focusedAsParent) return keyPressedInternal(key, scancode, mods) return false } @@ -1560,6 +1547,7 @@ open class EditablePanel @JvmOverloads constructor( } } + if (focusedAsParent) return keyReleasedInternal(key, scancode, mods) return false } @@ -1641,14 +1629,18 @@ open class EditablePanel @JvmOverloads constructor( isRemoved = true } - fun popup() { + fun popup(focus: Boolean = true) { if (isRemoved) { return } - if (screen is MatteryScreen<*>) { + if (screen is MatteryScreen<*> && parent == null) { screen.popup(this as EditablePanel>) } + + if (focus && !isEverFocused()) { + requestFocus() + } } fun asGrid(): FlexGridPanel<*> { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index 1eb70ae8b..52d3bd56a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.client.screen.panels +import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.narration.NarratableEntry @@ -133,6 +134,8 @@ open class FramePanel( protected var dragging = false + var closeOnEscape = false + init { setDockPadding(PADDING, if (title != null) PADDING_TOP else PADDING, PADDING, PADDING) } @@ -182,6 +185,15 @@ open class FramePanel( } + override fun keyPressedInternal(key: Int, scancode: Int, mods: Int): Boolean { + if (key == InputConstants.KEY_ESCAPE && closeOnEscape) { + remove() + return true + } + + return super.keyPressedInternal(key, scancode, mods) + } + override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { RECTANGLE.render(stack, width = width, height = height) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt index 8d568d90c..9c5f2fbc7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt @@ -1,11 +1,14 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.ChatFormatting import net.minecraft.client.gui.screens.Screen +import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.GetterSetter +import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.value import ru.dbotthepony.mc.otm.menu.input.IPlayerInputWithFeedback @@ -17,9 +20,11 @@ abstract class BooleanRectangleButtonPanel( width: Float, height: Float, val prop: GetterSetter, - val skinElementActive: AbstractMatterySprite? = null, - val skinElementInactive: AbstractMatterySprite? = null, + var skinElementActive: AbstractMatterySprite? = null, + var skinElementInactive: AbstractMatterySprite? = null, val onChange: ((newValue: Boolean) -> Unit)? = null, + var tooltipActive: Component? = null, + var tooltipInactive: Component? = null, ) : RectangleButtonPanel(screen, parent, x, y, width, height, null) { override fun onClick(mouseButton: Int) { val newValue = !prop.value @@ -27,6 +32,39 @@ abstract class BooleanRectangleButtonPanel( onChange?.invoke(newValue) } + override fun innerRenderTooltips(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + if (isHovered) { + val tooltipActive = tooltipActive + val tooltipInactive = tooltipInactive + val tooltipList = tooltipList + val tooltip = tooltip + + if (tooltipActive != null || tooltipInactive != null || tooltipList != null || tooltip != null) { + val tooltips = ArrayList(2) + + if (tooltipList != null) { + tooltips.addAll(tooltipList) + tooltips.add(SPACE) + } else if (tooltip != null) { + tooltips.add(tooltip) + tooltips.add(SPACE) + } + + if (tooltipActive != null) { + tooltips.add(tooltipActive.copy().withStyle(if (prop.get()) ChatFormatting.WHITE else ChatFormatting.GRAY)) + } + + if (tooltipInactive != null) { + tooltips.add(tooltipInactive.copy().withStyle(if (!prop.get()) ChatFormatting.WHITE else ChatFormatting.GRAY)) + } + + screen.renderComponentTooltip(stack, tooltips, mouseX.toInt(), mouseY.toInt(), font) + } + } + + return super.innerRenderTooltips(stack, mouseX, mouseY, partialTick) + } + override var isDisabled: Boolean get() { if (prop is IPlayerInputWithFeedback) { @@ -46,4 +84,8 @@ abstract class BooleanRectangleButtonPanel( skinElementInactive?.render(stack, width = width, height = height) } } + + companion object { + private val SPACE = TextComponent("") + } } 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 72ef6acce..ef1e43b1f 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 @@ -5,7 +5,6 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel @@ -192,61 +191,93 @@ private fun > makeEnergyConfigPanel( return frame } -fun > makeDeviceControls( +class DeviceControls>( screen: S, parent: FramePanel, - redstone: IPlayerInputWithFeedback? = null, - itemConfig: ItemHandlerPlayerInput? = null, - energyConfig: EnergyPlayerInput? = null, -): EditablePanel { - val panel = object : EditablePanel(screen, parent, width = LargeEnumRectangleButtonPanel.SIZE, height = 0f, x = parent.width + 3f) { - override fun tickInner() { - super.tickInner() - x = parent.width + 3f - y = 0f + extra: Iterable> = listOf(), + val redstoneConfig: IPlayerInputWithFeedback? = null, + val itemConfig: ItemHandlerPlayerInput? = null, + val energyConfig: EnergyPlayerInput? = null, +) : EditablePanel(screen, parent, x = parent.width + 3f, height = 0f, width = 0f) { + val itemConfigButton: LargeRectangleButtonPanel? + val energyConfigButton: LargeRectangleButtonPanel? + val redstoneControlsButton: LargeEnumRectangleButtonPanel? + private var nextY = 0f + + fun

> addButton(button: P): P { + button.parent = this + button.x = 0f + button.y = nextY + nextY += button.height + 2f + height = nextY - 2f + width = button.width.coerceAtLeast(width) + return button + } + + init { + for (button in extra) { + addButton(button) + } + + if (redstoneConfig != null) { + redstoneControlsButton = addButton(makeRedstoneSettingButton(screen, this, control = redstoneConfig)) + } else { + redstoneControlsButton = null + } + + if (itemConfig != null) { + itemConfigButton = addButton(object : LargeRectangleButtonPanel(screen, this@DeviceControls, skinElement = Widgets18.ITEMS_CONFIGURATION) { + init { + tooltip = TranslatableComponent("otm.gui.sides.item_config") + } + + override fun onClick(mouseButton: Int) { + if (mouseButton == InputConstants.MOUSE_BUTTON_LEFT) { + val frame = makeItemHandlerControlPanel(screen, itemConfig) + + frame.x = absoluteX + width / 2f - frame.width / 2f + frame.y = absoluteY + height + 8f + } + } + }) + } else { + itemConfigButton = null + } + + if (energyConfig != null) { + energyConfigButton = addButton(object : LargeRectangleButtonPanel(screen, this@DeviceControls, y = nextY, skinElement = Widgets18.ENERGY_CONFIGURATION) { + init { + tooltip = TranslatableComponent("otm.gui.sides.energy_config") + } + + override fun onClick(mouseButton: Int) { + if (mouseButton == InputConstants.MOUSE_BUTTON_LEFT) { + val frame = makeEnergyConfigPanel(screen, energyConfig) + + frame.x = absoluteX + width / 2f - frame.width / 2f + frame.y = absoluteY + height + 8f + } + } + }) + } else { + energyConfigButton = null } } - var y = 0f - - if (redstone != null) { - y += makeRedstoneSettingButton(screen, panel, y = y, control = redstone).height + 2f + override fun tickInner() { + super.tickInner() + x = (parent?.width ?: 0f) + 3f + y = 0f } - - if (itemConfig != null) { - y += object : LargeRectangleButtonPanel(screen, panel, y = y, skinElement = Widgets18.ITEMS_CONFIGURATION) { - init { - tooltip = TranslatableComponent("otm.gui.sides.item_config") - } - - override fun onClick(mouseButton: Int) { - if (mouseButton == InputConstants.MOUSE_BUTTON_LEFT) { - val frame = makeItemHandlerControlPanel(screen, itemConfig) - - frame.x = absoluteX + width / 2f - frame.width / 2f - frame.y = absoluteY + height + 8f - } - } - }.height + 2f - } - - if (energyConfig != null) { - y += object : LargeRectangleButtonPanel(screen, panel, y = y, skinElement = Widgets18.ENERGY_CONFIGURATION) { - init { - tooltip = TranslatableComponent("otm.gui.sides.energy_config") - } - - override fun onClick(mouseButton: Int) { - if (mouseButton == InputConstants.MOUSE_BUTTON_LEFT) { - val frame = makeEnergyConfigPanel(screen, energyConfig) - - frame.x = absoluteX + width / 2f - frame.width / 2f - frame.y = absoluteY + height + 8f - } - } - }.height + 2f - } - - panel.height = (y - 2f).coerceAtLeast(0f) - return panel +} + +fun > makeDeviceControls( + screen: S, + parent: FramePanel, + extra: Iterable> = listOf(), + redstone: IPlayerInputWithFeedback? = null, + itemConfig: ItemHandlerPlayerInput? = null, + energyConfig: EnergyPlayerInput? = null, +): DeviceControls { + return DeviceControls(screen, parent, extra = extra, redstoneConfig = redstone, itemConfig = itemConfig, energyConfig = energyConfig) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt index b699f1bfb..894809386 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt @@ -158,12 +158,14 @@ abstract class EnumRectangleButtonPanel>( } val listing = ArrayList() + val tooltipList = tooltipList + val tooltip = tooltip if (tooltipList != null) { - listing.addAll(tooltipList!!) + listing.addAll(tooltipList) listing.add(SPACE) } else if (tooltip != null) { - listing.add(tooltip!!) + listing.add(tooltip) listing.add(SPACE) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeBooleanRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeBooleanRectangleButtonPanel.kt index 531f520cc..f2003f88f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeBooleanRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeBooleanRectangleButtonPanel.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import net.minecraft.client.gui.screens.Screen +import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.Widgets18 @@ -19,7 +20,9 @@ open class LargeBooleanRectangleButtonPanel( skinElementActive: AbstractMatterySprite? = null, skinElementInactive: AbstractMatterySprite? = null, onChange: ((newValue: Boolean) -> Unit)? = null, -) : BooleanRectangleButtonPanel(screen, parent, x, y, width, height, prop, skinElementActive, skinElementInactive, onChange) { + tooltipActive: Component? = null, + tooltipInactive: Component? = null, +) : BooleanRectangleButtonPanel(screen, parent, x, y, width, height, prop, skinElementActive, skinElementInactive, onChange, tooltipActive, tooltipInactive) { final override val IDLE = Widgets18.BUTTON_IDLE final override val HOVERED = Widgets18.BUTTON_HOVERED final override val PRESSED = Widgets18.BUTTON_PRESSED diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemFilter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemFilter.kt index 5e6e69ac2..668f7d1c5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemFilter.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemFilter.kt @@ -11,7 +11,7 @@ import net.minecraftforge.common.util.INBTSerializable import net.minecraftforge.network.NetworkEvent import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.core.nbt.ifHas +import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.core.nbt.set @@ -266,7 +266,7 @@ class ItemFilter( if (nbt == null) return - nbt.ifHas("items", ListTag::class.java) { + nbt.map("items") { it: ListTag -> for ((i, value) in it.withIndex()) { if (value is CompoundTag) { filter[i] = ItemStack.of(value) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt index 5ed8462ec..f2bc86f6e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt @@ -10,7 +10,7 @@ import kotlin.jvm.JvmOverloads import net.minecraft.world.entity.player.Player import net.minecraft.world.level.block.entity.BlockEntity import net.minecraftforge.common.util.INBTSerializable -import ru.dbotthepony.mc.otm.core.nbt.ifHas +import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set import java.util.* @@ -53,7 +53,7 @@ open class MatteryContainer(val watcher: Runnable, private val size: Int) : Cont } // нам не интересен размер - tag.ifHas("items", ListTag::class.java) { + tag.map("items") { it: ListTag -> for (i in 0 until it.size.coerceAtMost(size)) { slots[i] = ItemStack.of(it[i] as CompoundTag) } 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 efbf4442b..e35bea5f9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -33,7 +33,6 @@ import net.minecraftforge.registries.IForgeRegistry import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.util.readInt import java.io.InputStream -import java.io.OutputStream import java.lang.ref.Reference import java.math.BigInteger import java.util.Arrays @@ -313,3 +312,72 @@ fun Stream.asIterable(): Iterable { } } } + +// Kotlin type safety: +// since Java generics are invariant, +// and can not distinguish between null and non-null type parameters +// we need to tell compiler that Comparator.nullsFirst actually has next signature: +// fun Comparator.nullsFirst(original: Comparator): Comparator +fun Comparator.nullsFirst(): Comparator { + return Comparator.nullsFirst(this as Comparator) +} + +fun Comparator.nullsLast(): Comparator { + return Comparator.nullsLast(this as Comparator) +} + +/** + * Returns applicable index to put [element] into [List] determined by [comparator], optionally specifying ranges as [fromIndex] and [toIndex] + * + * If [List] is not sorted, result of this function is undefined + */ +fun List.searchInsertionIndex(element: E, comparator: Comparator, fromIndex: Int = 0, toIndex: Int = size): Int { + require(toIndex >= fromIndex) { "Invalid range: to $toIndex >= from $fromIndex" } + require(fromIndex >= 0) { "Invalid from index: $fromIndex" } + require(toIndex >= 0) { "Invalid to index: $toIndex" } + require(fromIndex <= size) { "Invalid from index: $fromIndex (list size $size)" } + require(toIndex <= size) { "Invalid to index: $toIndex (list size $size)" } + + if (fromIndex == size || fromIndex == toIndex || comparator.compare(element, this[fromIndex]) <= 0) { + return fromIndex + } + + if (toIndex - fromIndex <= 10) { + for (i in fromIndex + 1 until toIndex) { + val compare = comparator.compare(element, this[i]) + + if (compare <= 0) { + return i + } + } + + return size + } else { + var lower = fromIndex + var upper = toIndex - 1 + + while (upper - lower >= 10) { + val middle = (upper + lower) / 2 + val compare = comparator.compare(element, this[middle]) + + if (compare == 0) { + return middle + } else if (compare < 0) { + upper = middle + } else { + lower = middle + } + } + + return searchInsertionIndex(element, comparator, lower, upper + 1) + } +} + +/** + * Inserts [element] into [MutableList] at index determined by [comparator] + * + * If [MutableList] is not sorted, result of this function is undefined + */ +fun MutableList.addSorted(element: E, comparator: Comparator) { + add(searchInsertionIndex(element, comparator), element) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt index ae8e344da..6c4ab1256 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt @@ -15,6 +15,7 @@ import net.minecraft.nbt.LongArrayTag import net.minecraft.nbt.LongTag import net.minecraft.nbt.NbtAccounter import net.minecraft.nbt.NbtUtils +import net.minecraft.nbt.NumericTag import net.minecraft.nbt.ShortTag import net.minecraft.nbt.StringTag import net.minecraft.nbt.Tag @@ -58,57 +59,13 @@ inline fun CompoundTag.map(key: String, consumer: (T) -> R return null } -inline fun CompoundTag.mapIf(key: String, consumer: (T) -> R): R? { - val tag = get(key) - - if (tag is T) { - return consumer(tag) - } - - return null -} - -inline fun > CompoundTag.getEnum(key: String, ifNothing: () -> R = { R::class.java.enumConstants[0] }): R { - val tag = get(key) - - if (tag is StringTag) { - val str = tag.asString - return R::class.java.enumConstants.first { it.name == str } - } - - return ifNothing.invoke() +fun CompoundTag.mapString(index: String, mapper: (String) -> T, orElse: T): T { + val tag = this[index] as? StringTag ?: return orElse + return mapper.invoke(tag.asString) } fun CompoundTag.getItemStack(key: String): ItemStack = map(key, ItemStack::of) ?: ItemStack.EMPTY -inline fun CompoundTag.ifHas(s: String, consumer: (Tag) -> Unit) { - val tag = get(s) - - if (tag != null) { - consumer(tag) - } -} - -inline fun CompoundTag.ifHas(s: String, type: Byte, consumer: (Tag) -> Unit) { - val tag = get(s) - - if (tag != null && tag.id == type) { - consumer(tag) - } -} - -inline fun CompoundTag.ifHas(s: String, type: Class, consumer: (T) -> Unit) { - val tag = get(s) - - if (tag != null && tag::class.java === type) { - consumer(tag as T) - } -} - -fun CompoundTag.getList(key: String): ListTag { - return this[key] as? ListTag ?: ListTag() -} - @Suppress("unchecked_cast") // type is checked inside getList fun CompoundTag.getByteList(key: String): MutableList = getList(key, Tag.TAG_BYTE.toInt()) as MutableList @Suppress("unchecked_cast") // type is checked inside getList @@ -153,3 +110,7 @@ fun CompoundTag.getJson(key: String, sizeLimit: NbtAccounter = NbtAccounter.UNLI return FastByteArrayInputStream(bytes).readJson(sizeLimit) } + +fun CompoundTag.getBoolean(index: String, orElse: Boolean): Boolean { + return (this[index] as? NumericTag)?.asInt?.let { it > 0 } ?: orElse +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt new file mode 100644 index 000000000..76a467de8 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt @@ -0,0 +1,83 @@ +package ru.dbotthepony.mc.otm.core.util + +import it.unimi.dsi.fastutil.objects.Reference2IntFunction +import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap +import net.minecraft.network.chat.Component +import net.minecraft.world.item.Item +import net.minecraftforge.common.CreativeModeTabRegistry +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.nullsFirst +import ru.dbotthepony.mc.otm.core.nullsLast +import ru.dbotthepony.mc.otm.core.registryName + +object CreativeMenuComparator : Comparator { + override fun compare(o1: Item, o2: Item): Int { + rebuild() + return item2index.getInt(o1).compareTo(item2index.getInt(o2)) + } + + private val item2index = Reference2IntOpenHashMap() + + init { + item2index.defaultReturnValue(Int.MAX_VALUE) + } + + private fun rebuild() { + if (item2index.isEmpty()) { + var i = 0 + + for (tab in CreativeModeTabRegistry.getSortedCreativeModeTabs()) { + for (item in tab.displayItems) { + item2index.computeIfAbsent(item.item, Reference2IntFunction { i++ }) + } + } + } + } + + internal fun invalidate() { + item2index.clear() + } + + val NullsFirst = nullsFirst() + val NullsLast = nullsLast() +} + +object ItemLocalizedNameComparator : Comparator { + override fun compare(o1: Item, o2: Item): Int { + return o1.description.string.compareTo(o2.description.string) + } + + val NullsFirst = nullsFirst() + val NullsLast = nullsLast() +} + +object ItemModComparator : Comparator { + override fun compare(o1: Item, o2: Item): Int { + val a = o1.registryName?.namespace ?: return 0 + val b = o2.registryName?.namespace ?: return 0 + return a.compareTo(b) + } + + val NullsFirst = nullsFirst() + val NullsLast = nullsLast() +} + +object ItemIDComparator : Comparator { + override fun compare(o1: Item, o2: Item): Int { + val a = o1.registryName ?: return 0 + val b = o2.registryName ?: return 0 + return a.compareTo(b) + } + + val NullsFirst = nullsFirst() + val NullsLast = nullsLast() +} + +enum class ItemSorter(val comparator: Comparator, private val sTitle: Component) { + DEFAULT(CreativeMenuComparator.NullsFirst, TranslatableComponent("otm.gui.sorting.default")), + NAME(ItemLocalizedNameComparator.NullsFirst.thenComparing(CreativeMenuComparator.NullsFirst), TranslatableComponent("otm.gui.sorting.name")), + ID(ItemIDComparator.NullsFirst.thenComparing(CreativeMenuComparator.NullsFirst), TranslatableComponent("otm.gui.sorting.id")), + MOD(ItemModComparator.NullsFirst.thenComparing(CreativeMenuComparator.NullsFirst), TranslatableComponent("otm.gui.sorting.modid")); + + val title: Component get() = sTitle.copy() +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PatternStorageItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PatternStorageItem.kt index f1812f5b9..db5c2a7d5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PatternStorageItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PatternStorageItem.kt @@ -16,7 +16,7 @@ import net.minecraft.world.level.Level import net.minecraftforge.common.capabilities.Capability import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.capability.matter.* -import ru.dbotthepony.mc.otm.core.nbt.ifHas +import ru.dbotthepony.mc.otm.core.nbt.map import java.util.* import java.util.stream.Stream @@ -99,11 +99,9 @@ class PatternStorageItem : Item { } override val storedPatterns: Int get() { - stack.tag?.ifHas("otm_patterns", ListTag::class.java) { - return it.size - } - - return 0 + return stack.tag?.map("otm_patterns") { it: ListTag -> + it.size + } ?: 0 } override fun getCapability(cap: Capability, side: Direction?): LazyOptional { @@ -111,11 +109,9 @@ class PatternStorageItem : Item { } override val patterns: Stream get() { - stack.tag?.ifHas("otm_patterns", ListTag::class.java) { - return it.stream().map { PatternState.deserializeNBT(it) }.filter { it != null } as Stream - } - - return Stream.empty() + return stack.tag?.map("otm_patterns") { it: ListTag -> + it.stream().map { PatternState.deserializeNBT(it) }.filter { it != null } as Stream + } ?: Stream.empty() } override fun insertPattern( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableCondensationDriveItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableCondensationDriveItem.kt index 4aa4e152c..fe5d55909 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableCondensationDriveItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableCondensationDriveItem.kt @@ -21,7 +21,7 @@ import net.minecraftforge.event.entity.player.EntityItemPickupEvent import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.capability.drive.DrivePool import ru.dbotthepony.mc.otm.container.ItemFilter -import ru.dbotthepony.mc.otm.core.nbt.ifHas +import ru.dbotthepony.mc.otm.core.nbt.map import java.math.BigInteger import java.util.* @@ -88,7 +88,7 @@ class PortableCondensationDriveItem(capacity: Int) : fun getFilterSettings(drive: ItemStack): ItemFilter { val filter = ItemFilter(MAX_FILTERS) filter.isWhitelist = true - drive.tag?.ifHas(FILTER_PATH, CompoundTag::class.java, filter::deserializeNBT) + drive.tag?.map(FILTER_PATH, filter::deserializeNBT) return filter } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt index 966bbbbff..f04e9f742 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt @@ -4,21 +4,26 @@ import net.minecraft.network.FriendlyByteBuf import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player -import net.minecraft.world.inventory.Slot import net.minecraftforge.network.NetworkEvent import net.minecraftforge.network.PacketDistributor import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.block.entity.matter.MatterPanelBlockEntity import ru.dbotthepony.mc.otm.capability.matter.* import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.core.GetterSetter +import ru.dbotthepony.mc.otm.core.addSorted +import ru.dbotthepony.mc.otm.core.util.BooleanValueCodec +import ru.dbotthepony.mc.otm.core.util.EnumValueCodec +import ru.dbotthepony.mc.otm.core.util.ItemSorter import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphListener import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.network.* import ru.dbotthepony.mc.otm.registry.MMenus import java.util.* -import java.util.function.Consumer import java.util.function.Supplier +import kotlin.Comparator +import kotlin.collections.ArrayList class CancelTaskPacket(val id: UUID) : MatteryPacket { override fun write(buff: FriendlyByteBuf) { @@ -146,66 +151,70 @@ class MatterPanelMenu @JvmOverloads constructor( sendNetwork(TasksChangePacket(false, listOf(task))) } - // client code + val sorting: ItemSorter by mSynchronizer.ComputedField( + getter = { tile?.getPlayerSettings(ply)?.sorter ?: ItemSorter.DEFAULT }, + codec = EnumValueCodec(ItemSorter::class.java), + observer = { + patterns.sortWith(actualComparator) + tasks.sortWith(actualTaskComparator) + }) + + val isAscending: Boolean by mSynchronizer.ComputedField( + getter = { tile?.getPlayerSettings(ply)?.ascending ?: true }, + codec = BooleanValueCodec, + observer = { + patterns.sortWith(actualComparator) + tasks.sortWith(actualTaskComparator) + }) + + val changeIsAscending = booleanInput(allowSpectators = true) { tile?.getPlayerSettings(ply)?.ascending = it } + val changeSorting = PlayerInput(EnumValueCodec(ItemSorter::class.java), allowSpectators = true) { tile?.getPlayerSettings(ply)?.sorter = it } + + val sortingGS = GetterSetter.of(::sorting, changeSorting::input) + val isAscendingGS = GetterSetter.of(::isAscending, changeIsAscending::input) + + private val actualComparator = Comparator { o1, o2 -> sorting.comparator.compare(o1.item, o2.item) * (if (isAscending) 1 else -1) } + private val actualTaskComparator = Comparator> { o1, o2 -> sorting.comparator.compare(o1.item, o2.item) * (if (isAscending) 1 else -1) } + val patterns = ArrayList() val tasks = ArrayList>() - var changeset = 0 fun networkPatternsUpdated(patterns: Collection) { - changeset++ - for (pattern in patterns) { val index = this.patterns.indexOfFirst(pattern::matchId) if (index != -1) { this.patterns[index] = pattern } else { - this.patterns.add(pattern) + this.patterns.addSorted(pattern, actualComparator) } } } fun networkPatternsRemoved(patterns: Collection) { - changeset++ - for (pattern in patterns) { this.patterns.remove(pattern) } } fun networkTasksUpdated(tasks: Collection>) { - changeset++ - for (task in tasks) { val index = this.tasks.indexOfFirst(task::matchId) if (index != -1) { this.tasks[index] = task } else { - this.tasks.add(task) + this.tasks.addSorted(task, actualTaskComparator) } - - updateWatcher?.accept(task) } } fun networkTasksRemoved(tasks: Collection>) { - changeset++ - for (task in tasks) { this.tasks.remove(task) - deleteWatcher?.accept(task) } } - private var deleteWatcher: Consumer>? = null - private var updateWatcher: Consumer>? = null - - fun networkTaskWatcher(updateWatcher: Consumer>, deleteWatcher: Consumer>) { - this.deleteWatcher = deleteWatcher - this.updateWatcher = updateWatcher - } - // server code fun requestReplication(ply: ServerPlayer, id: UUID, count: Int) { if (ply.isSpectator) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt index eb573c63f..3b250b558 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt @@ -688,6 +688,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa private val getter: () -> V, private val codec: IStreamCodec, name: String = nextFieldName(), + private val observer: (new: V) -> Unit = {} ) : AbstractField(name), IField { private var remote: V? = null private var clientValue: V? = null @@ -726,7 +727,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } override fun read(stream: DataInputStream) { - clientValue = codec.read(stream) + val newValue = codec.read(stream) + clientValue = newValue + observer.invoke(newValue) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt index 415c331dc..a8139397e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt @@ -5,6 +5,7 @@ import net.minecraft.world.item.CreativeModeTab import net.minecraft.world.item.ItemStack import net.minecraftforge.event.CreativeModeTabEvent import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.core.util.CreativeMenuComparator import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.registry.MItems.BATTERY_CREATIVE @@ -16,6 +17,8 @@ object MCreativeTabs { private set fun register(event: CreativeModeTabEvent.Register) { + CreativeMenuComparator.invalidate() + MAIN = event.registerCreativeModeTab(ResourceLocation(OverdriveThatMatters.MOD_ID, "main")) { it.icon { ItemStack(BATTERY_CREATIVE, 1) } it.title(TranslatableComponent("itemGroup.otm")) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/storage_controls.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/storage_controls.png index 9346529e2d65a83ff9af3015c31308c15028e4ed..9905a78ace4c217229c6ee8f66bd03428dea1164 100644 GIT binary patch delta 768 zcmV+b1ONQT1)~O#7YZZ@1^@s634krLks%y^Kpe$i(@I4v4t6NwkfAzR5S8L6RV;#q z(pG5I!Q|2}XktiGTpR`0f`cE6RR z_@99*t>fQl0yCeaH#%DM2pHT3F0MP8ya!zF0FftMG9*Xx(-cZ2;QfrgsQ?V!0)4A) zZ|!}YJ^(rDYUu_zI0VMZl)dKh?%wX+{yo#~?+1Zxa;^GU+JFE600v@9M??UB00000 z0Qp0^e*gdg32;bRa{vGf6951U69E94oEQKA00(qQO+^Ri0|gB`9G8GATmS$8AW1|) zRA}DqnqdxuFbIXM@mL(6d+9F{LbL-`x~cC=mNcf8@}NX<%K`uZ<6-8VnfHHL=dP@? zf^{~A&_yCg#g&vf7 zi*2UJ+Bp#?_hFOAds-uFrK3gbS=PB< z1Zn1JNDG~b^xK3U_QG=Z{0jg8000000JCuSUNbK&w!!{pp-aE8=tjE;|MrixWqfKW yBBKF>ex%T-sW-@I{g(h6IJ8{>00000DmVaxk3T`%wah610000+V2Rn#}WQa}{L`58>ibb$c z+6t{Yn7s54nlvOSE{=k0!NH%!s)LKOt`4q(Aov5~>f)s6A|>9J6k5c1;qgAsyXWxU zeSpxYFwN?k05sh;Q}LLX&8><(uLxiSVMvft?1$8VgAE(<&}VrEkF#1Ue#*uhE% zvy!P1PZLY3rc=I<^;qS+#aXM=SnHnrg`vE@lIA+CVZ^b71d~sYx#>6a%_n9Oq*c=-CCDb;tQWcAVx3 z5PSx%^tQj+0A@c)ueUYn2ncTj7uRh~*#j><;QfrgDF+PP0)1=V z+*;>2eE>2vtK}Qu;1C!qQueyfyL&t5_HR#Xem}UQa>E3@&nN%@00v@9M??UB{{a60 z|De66lK=n!32;bRa{vGf6951U69E94oEQKA00(qQO+^Ri0UrcA4Y!5Vx&QzG#7RU! zR9M69m)#D4AP9xC`B*$Y?^RcB%pqw|_H(|i%{Hym0SuP~0081)=8c&*IN>A10$&o! zdm>6xj4nc?0IfPKf%WssTse+^(l)xjUTbN}SDLJuqKW%M_NOZ%-y7}TtUL;aC$l3G zY3d$*WX_0Ctunk@$K9->2KCM%q9iX*Hhi}0u#E8Tsb@@<@6^U`2-<3uY4o4E?#+99 zbXgUx@e|Gm*7I`f!)hTTCTnwAUB_QYQ4Ki`EKYxL1P1_sY3z@Uy-ObtdhYE20000< KMNUMnLSTX@{4^Z^ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/storage_controls.xcf b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/storage_controls.xcf index 2e3d11ece63bb479b22eae7e67d46b6a2ed8e80f..54ab55958412f706096ff5974c650784cd950eec 100644 GIT binary patch literal 4408 zcmdT{&1+Ow6uK9q1t(|b+;i?Z_uia)?r+Y$ zX|=B`h1X{0!|%o$4FUQFJVpid3-}|j=b@F^}XHOJr z^R1c1g~jEtrbKe8=?BpeXYCHoN0GjVPhP<>peZwsejvPuY~Q+ z%;mW*XDrUocjs0@HQv#++B=vrJLLVQJE_-NW^ZVjD`}a3t7YkomX()U_OwhsnYqZt z5996d>$4od9FwwO=2e1^Q9r$k7GuG*b6(!)5aM%3KkDcOM-Lsn=;(}_Ym&-ft5>1( z@7Y)bH4}B3ZIN^fM=| z@gh)B5q~NaX^dpVj_O6ekWsLot7n`ad01*sL`&iTttqj0g+7fk>|OOF_Aasae|Pna z^Ck8!_k>(xT5X<*(u%5V@pEADNphRsVL~F~VYGuHk@Fl1?l>Kr1%t%kQ6C>n!KSr0 zg@?N4Mdys9-W31Qiu&S7te|9n};lR8$xD(Q# znByDUq4H&?W3yy1SH9E72UGchwNC&o6_JWcs)BgYj)(v#g)I**asaIP3RDu$TYV+) zDsXv14CO+2Or#{X1~hqc2Z+KKKN~y_G-GQ(pr=rXt*JYT_m#^NOqIxU)r$_;0*tXBWU({Yd3J|cP#Hf-%Z2nk4oO>7NtO#!x^oDhEl5%ou? literal 3189 zcmd5;&ubGw6rLpABu!dd>yML#)mCVQKq6T1Py|oCSnwoxsNJSX475o}sOnkJ zJa`a9Ja`k4LLpR}A}r!@a?^jMv>m^1cSokO)e=1HOTT$<-kW)y_vY=}tyCA6?3H5K zewZ&51n4d>L;>^)I1R*N7^pl8OvN!wa2Vw<#NiB(zWG830>pJaKpHq7$nYgFbOJMaAp<1o*K zmTKA@i0|a4Y|de0cKhO7b)LZ z!{}$8dV1~!D3dM$TE1Y&8AG-WIcvy$hTLz+1CV*sQvfLi@PE+%T?r#0N?%v2xa<{XFaTD#w zD?Yhpch>R6v4$?xf~gJDcJyjemqWKTna~b=o(=2&K}}|_8*6ofp~~LY`pMv(!1sd* zeuKoldSyYzP>?>-;CsSFQKExc_+&}Ar=Xe?k#yv}xcCw?!4DIJ7F1?TAv6yNP3^&k PKZJ(wn1n)TYEt|HFMOI3 diff --git a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/ComparatorTests.kt b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/ComparatorTests.kt new file mode 100644 index 000000000..1a943112e --- /dev/null +++ b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/ComparatorTests.kt @@ -0,0 +1,34 @@ +package ru.dbotthepony.mc.otm.tests + +import it.unimi.dsi.fastutil.ints.IntComparators +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.DisplayName +import org.junit.jupiter.api.Test +import ru.dbotthepony.mc.otm.core.addSorted +import java.util.Random + +object ComparatorTests { + @Test + @DisplayName("Comparator tests") + fun test() { + val sortedList = mutableListOf(1, 4, 6) + sortedList.addSorted(2, IntComparators.NATURAL_COMPARATOR) + sortedList.addSorted(3, IntComparators.NATURAL_COMPARATOR) + sortedList.addSorted(7, IntComparators.NATURAL_COMPARATOR) + sortedList.addSorted(-1, IntComparators.NATURAL_COMPARATOR) + + assertEquals(mutableListOf(-1, 1, 2, 3, 4, 6, 7), sortedList) + + val rand = Random() + val sorted2 = ArrayList() + + for (i in 0 .. 100) { + sorted2.addSorted(rand.nextInt(-100, 100), IntComparators.NATURAL_COMPARATOR) + } + + val sorted22 = ArrayList(sorted2) + sorted22.sort() + + assertEquals(sorted22, sorted2) + } +} From 6d434f2c2b3230909c1c2a94ab9ed9bc8f2e6d04 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 6 Mar 2023 00:22:19 +0700 Subject: [PATCH 0276/1199] =?UTF-8?q?YuRaNnNzZZ=20=E2=80=94=20=D0=A1=D0=B5?= =?UTF-8?q?=D0=B3=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=200:20=2024=3F=3F=3F?= =?UTF-8?q?=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F=3F?= =?UTF-8?q?=3F=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt index 32f1f15c6..480392dd9 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt @@ -316,7 +316,7 @@ fun addDecorativesRecipes(provider: MatteryRecipeProvider, consumer: Consumer Date: Mon, 6 Mar 2023 00:22:57 +0700 Subject: [PATCH 0277/1199] Add tritanium nugget to creative tab --- src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt index 07546d9c5..f0a269713 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt @@ -113,6 +113,7 @@ internal fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { accept(MItems.TRITANIUM_ORE_CLUMP) accept(MItems.TRITANIUM_DUST) + accept(MItems.TRITANIUM_NUGGET) accept(MItems.TRITANIUM_INGOT) accept(MItems.TRITANIUM_INGOT_BLOCK) From b8837d431234a1ca8f759a595a434760e93dedff Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Mon, 6 Mar 2023 00:52:12 +0300 Subject: [PATCH 0278/1199] update curios dep version --- build.gradle.kts | 14 +++++++++++--- gradle.properties | 3 ++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 84e10ceca..dfcea109e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -181,11 +181,12 @@ dependencies { val configured_id: String by project val worldedit_fileid: String by project val more_overlays_version: String by project + val curios_version: String by project val deps_mc_version: String by project val jei_mc_version: String by project - val curios_file_id: String by project + val curios_mc_version: String by project - implementation(fg.deobf("curse.maven:curios-309927:$curios_file_id")) + implementation(fg.deobf("top.theillusivec4.curios:curios-forge:${curios_mc_version}-${curios_version}")) implementation(fg.deobf("curse.maven:cosmetic-armor-reworked-237307:$cosmetic_armor_reworked_id")) compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-common-api:${jei_version}")) @@ -320,7 +321,6 @@ repositories { url = uri("https://maven.dbotthepony.ru") content { - includeGroup("top.theillusivec4.curios") includeGroup("yalter.mousetweaks") includeGroup("mekanism") includeGroup("lain.mods.cos") @@ -356,6 +356,14 @@ repositories { } } + maven { + url = uri("https://maven.theillusivec4.top/") + + content { + includeGroup("top.theillusivec4.curios") + } + } + // mavenCentral() } diff --git a/gradle.properties b/gradle.properties index 955a80ded..af6b696a1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,6 +17,7 @@ mc_version=1.19.3 parchment_version=2022.12.18-1.19.3 jei_mc_version=1.19.3 deps_mc_version=1.19.2 +curios_mc_version=1.19.3 forge_gradle_version=5.1.27 forge_version=44.1.5 @@ -26,7 +27,7 @@ mixin_version=0.8.5 jei_version=12.0.2.2 jupiter_version=5.8.2 mekanism_version=10.3.5.homebaked -curios_file_id=4325469 +curios_version=5.1.4.0 cosmetic_armor_reworked_id=4145717 jade_id=4330163 configured_id=4166861 From 3e4d6dcc1155f9b3431b9a7dfd44690b0147fd4b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 6 Mar 2023 14:47:42 +0700 Subject: [PATCH 0279/1199] Revisit enumvaluecodec --- .../mc/otm/block/entity/RedstoneControl.kt | 2 +- .../mc/otm/core/util/DataStreams.kt | 66 +++++++++++++++---- .../ru/dbotthepony/mc/otm/data/EnumCodec.kt | 30 --------- .../otm/menu/input/EnumInputWithFeedback.kt | 4 +- .../mc/otm/menu/matter/MatterPanelMenu.kt | 5 +- .../mc/otm/network/FieldSynchronizer.kt | 27 +++++--- 6 files changed, 76 insertions(+), 58 deletions(-) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/EnumCodec.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt index 4650d6263..8b3a74510 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt @@ -77,7 +77,7 @@ class SynchronizedRedstoneControl( val state = isBlockedByRedstone valueChanges.invoke(state, old) } - }, name = if (fieldNamePrefix != null) "${fieldNamePrefix}_redstoneSetting" else null, writeByIndices = true) + }, name = if (fieldNamePrefix != null) "${fieldNamePrefix}_redstoneSetting" else null) override var redstoneSignal: Int by synchronizer.int(0, setter = { value, access, setByRemote -> if (access.read() == value) return@int diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt index b4ea5972d..6916c5589 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt @@ -1,7 +1,14 @@ package ru.dbotthepony.mc.otm.core.util +import com.google.common.collect.ImmutableList +import com.mojang.datafixers.util.Pair +import com.mojang.serialization.Codec +import com.mojang.serialization.DataResult +import com.mojang.serialization.DynamicOps import net.minecraft.nbt.NbtAccounter +import net.minecraft.util.StringRepresentable import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.core.immutableMap import ru.dbotthepony.mc.otm.core.math.readDecimal import ru.dbotthepony.mc.otm.core.math.writeDecimal import java.io.DataInput @@ -14,6 +21,7 @@ import java.util.* import java.util.function.Predicate import kotlin.NoSuchElementException import kotlin.math.absoluteValue +import kotlin.reflect.KClass /** * Represents value which can be encoded onto or decoded from stream. @@ -86,25 +94,20 @@ val VarIntValueCodec = StreamCodec(DataInputStream::readVarIntLE, DataOutputStre val VarLongValueCodec = StreamCodec(DataInputStream::readVarLongLE, DataOutputStream::writeVarLongLE) val BinaryStringCodec = StreamCodec(DataInputStream::readBinaryString, DataOutputStream::writeBinaryString) -class EnumValueCodec>(clazz: Class, val writeByIndices: Boolean = false) : IStreamCodec { +class EnumValueCodec> private constructor(clazz: Class) : IStreamCodec, Codec { val clazz = searchClass(clazz) - private val values = searchClass(clazz).enumConstants!! + val values: ImmutableList = ImmutableList.copyOf(this.clazz.enumConstants!!) + val valuesMap = immutableMap { + for (v in values) put(v.name, v) + } override fun read(stream: DataInputStream, sizeLimit: NbtAccounter): V { - if (writeByIndices) { - val id = stream.readVarIntLE(sizeLimit) - return values.getOrNull(id) ?: throw NoSuchElementException("No such enum with index $id") - } - - val id = stream.readBinaryString(sizeLimit) - return values.firstOrNull { id == it.name } ?: throw NoSuchElementException("No such enum $id") + val id = stream.readVarIntLE(sizeLimit) + return values.getOrNull(id) ?: throw NoSuchElementException("No such enum with index $id") } override fun write(stream: DataOutputStream, value: V) { - if (writeByIndices) - stream.writeVarIntLE(value.ordinal) - else - stream.writeBinaryString(value.name) + stream.writeVarIntLE(value.ordinal) } override fun copy(value: V): V { @@ -115,7 +118,41 @@ class EnumValueCodec>(clazz: Class, val writeByIndices: Boole return a === b } + override fun encode(input: V, ops: DynamicOps, prefix: T): DataResult { + if (ops.compressMaps()) { + return DataResult.success(ops.createInt(input.ordinal)) + } + + return DataResult.success(ops.createString(input.name)) + } + + override fun decode(ops: DynamicOps, input: T): DataResult> { + if (ops.compressMaps()) { + return ops.getNumberValue(input) + .flatMap { values.getOrNull(it.toInt())?.let { DataResult.success(Pair(it, ops.empty())) } ?: DataResult.error("No such enum with ordinal index $it") } + } + + return ops.getStringValue(input) + .flatMap { valuesMap[it]?.let { DataResult.success(Pair(it, ops.empty())) } ?: DataResult.error("No such enum value $it") } + } + companion object { + private val codecs = WeakHashMap, EnumValueCodec<*>>() + + fun > of(clazz: Class): EnumValueCodec { + synchronized(codecs) { + val search = searchClass(clazz) + + if (search !== clazz) { + val result = codecs.computeIfAbsent(search) { EnumValueCodec(it as Class) } as EnumValueCodec + codecs.putIfAbsent(clazz, result) + return result + } + + return codecs.computeIfAbsent(clazz) { EnumValueCodec(it as Class) } as EnumValueCodec + } + } + /** * FIXME: enums with abstract methods which get compiled to subclasses, whose DO NOT expose "parent's" enum constants array * @@ -137,6 +174,9 @@ class EnumValueCodec>(clazz: Class, val writeByIndices: Boole } } +fun > Class.codec() = EnumValueCodec.of(this) +fun > KClass.codec() = EnumValueCodec.of(this.java) + fun OutputStream.writeInt(value: Int) { if (this is DataOutput) { writeInt(value) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/EnumCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/EnumCodec.kt deleted file mode 100644 index e760a5a69..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/EnumCodec.kt +++ /dev/null @@ -1,30 +0,0 @@ -package ru.dbotthepony.mc.otm.data - -import com.google.common.collect.ImmutableMap -import com.mojang.datafixers.util.Pair -import com.mojang.serialization.Codec -import com.mojang.serialization.DataResult -import com.mojang.serialization.DynamicOps -import kotlin.reflect.KClass - -class EnumCodec>(val type: Class) : Codec { - private val values: Map by lazy { - val builder = ImmutableMap.Builder() - for (value in type.enumConstants) builder.put(value.name, value) - builder.build() - } - - override fun encode(input: E, ops: DynamicOps, prefix: T): DataResult { - require(prefix == ops.empty()) { "Non-empty prefix: $prefix" } - return DataResult.success(ops.createString(input.name)) - } - - override fun decode(ops: DynamicOps, input: T): DataResult> { - return ops.getStringValue(input).flatMap { - DataResult.success(values[it] ?: return@flatMap DataResult.error("No such enum $it (valid ones are: ${values.keys.joinToString(", ")})")) - }.map { Pair.of(it, ops.empty()) } - } -} - -fun > Class.codec() = EnumCodec(this) -fun > KClass.codec() = EnumCodec(this.java) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt index fe9dfabfd..d066f388c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt @@ -10,8 +10,8 @@ inline fun > EnumInputWithFeedback(menu: MatteryMenu, state: inline fun > EnumInputWithFeedback(menu: MatteryMenu, state: GetterSetter) = EnumInputWithFeedback(menu, E::class.java, state) class EnumInputWithFeedback>(menu: MatteryMenu, clazz: Class) : AbstractPlayerInputWithFeedback() { - val codec = EnumValueCodec(clazz) - private val default = codec.clazz.enumConstants!![0] + val codec = EnumValueCodec.of(clazz) + private val default = codec.values.first() override val input = menu.PlayerInput(codec, false) { consumer?.invoke(it) } override val value by menu.mSynchronizer.ComputedField(getter = { supplier?.invoke() ?: default }, codec) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt index f04e9f742..1fc56d8d8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt @@ -15,6 +15,7 @@ import ru.dbotthepony.mc.otm.core.addSorted import ru.dbotthepony.mc.otm.core.util.BooleanValueCodec import ru.dbotthepony.mc.otm.core.util.EnumValueCodec import ru.dbotthepony.mc.otm.core.util.ItemSorter +import ru.dbotthepony.mc.otm.core.util.codec import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphListener import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph import ru.dbotthepony.mc.otm.menu.MatteryMenu @@ -153,7 +154,7 @@ class MatterPanelMenu @JvmOverloads constructor( val sorting: ItemSorter by mSynchronizer.ComputedField( getter = { tile?.getPlayerSettings(ply)?.sorter ?: ItemSorter.DEFAULT }, - codec = EnumValueCodec(ItemSorter::class.java), + codec = ItemSorter::class.codec(), observer = { patterns.sortWith(actualComparator) tasks.sortWith(actualTaskComparator) @@ -168,7 +169,7 @@ class MatterPanelMenu @JvmOverloads constructor( }) val changeIsAscending = booleanInput(allowSpectators = true) { tile?.getPlayerSettings(ply)?.ascending = it } - val changeSorting = PlayerInput(EnumValueCodec(ItemSorter::class.java), allowSpectators = true) { tile?.getPlayerSettings(ply)?.sorter = it } + val changeSorting = PlayerInput(ItemSorter::class.codec(), allowSpectators = true) { tile?.getPlayerSettings(ply)?.sorter = it } val sortingGS = GetterSetter.of(::sorting, changeSorting::input) val isAscendingGS = GetterSetter.of(::isAscending, changeIsAscending::input) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt index 3b250b558..50aa0ff4e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt @@ -202,14 +202,14 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa @JvmOverloads fun item(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, ItemStackValueCodec, name ?: nextFieldName()) @JvmOverloads fun string(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, BinaryStringCodec, name ?: nextFieldName()) - @JvmOverloads fun > enum(type: Class, getter: () -> T, name: String? = nextFieldName()) = ComputedField(getter, EnumValueCodec(type), name ?: nextFieldName()) - inline fun > enum(noinline getter: () -> T, name: String? = nextFieldName()) = ComputedField(getter, EnumValueCodec(T::class.java), name ?: nextFieldName()) + @JvmOverloads fun > enum(type: Class, getter: () -> T, name: String? = nextFieldName()) = ComputedField(getter, EnumValueCodec.of(type), name ?: nextFieldName()) + inline fun > enum(noinline getter: () -> T, name: String? = nextFieldName()) = ComputedField(getter, EnumValueCodec.of(T::class.java), name ?: nextFieldName()) - @JvmOverloads fun > enum(type: Class, getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, EnumValueCodec(type), name ?: nextFieldName()) - inline fun > enum(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, EnumValueCodec(T::class.java), name ?: nextFieldName()) + @JvmOverloads fun > enum(type: Class, getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, EnumValueCodec.of(type), name ?: nextFieldName()) + inline fun > enum(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, EnumValueCodec.of(T::class.java), name ?: nextFieldName()) - @JvmOverloads fun > enum(type: Class, getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, EnumValueCodec(type), name ?: nextFieldName()) - inline fun > enum(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, EnumValueCodec(T::class.java), name ?: nextFieldName()) + @JvmOverloads fun > enum(type: Class, getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, EnumValueCodec.of(type), name ?: nextFieldName()) + inline fun > enum(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, EnumValueCodec.of(T::class.java), name ?: nextFieldName()) @JvmOverloads fun byte( @@ -347,10 +347,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: T = type.enumConstants[0], getter: FieldGetter? = null, setter: FieldSetter? = null, - writeByIndices: Boolean = false, name: String? = nextFieldName(), ): Field { - return Field(value, EnumValueCodec(type, writeByIndices = writeByIndices), getter, setter, name = name ?: nextFieldName()) + return Field(value, EnumValueCodec.of(type), getter, setter, name = name ?: nextFieldName()) } @JvmOverloads @@ -358,10 +357,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: T, getter: FieldGetter? = null, setter: FieldSetter? = null, - writeByIndices: Boolean = false, name: String? = nextFieldName(), ): Field { - return Field(value, EnumValueCodec(value::class.java, writeByIndices = writeByIndices), getter, setter, name = name ?: nextFieldName()) + return Field(value, EnumValueCodec.of(value::class.java), getter, setter, name = name ?: nextFieldName()) } @JvmOverloads @@ -584,6 +582,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } } + /** + * Networked variable with backing field holding immutable value + */ inner class Field( private var field: V, private val codec: IStreamCodec, @@ -684,6 +685,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } } + /** + * Networked value with backing getter which is constantly polled + */ inner class ComputedField( private val getter: () -> V, private val codec: IStreamCodec, @@ -733,6 +737,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } } + /** + * Networked variable with backing field holding mutable value, which is constantly observed for changes + */ inner class ObservedField : AbstractField, IMutableField { private val codec: IStreamCodec private val getter: () -> V From f75880d5ed4c1c666ad5220e2d0d9061709c848b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 6 Mar 2023 15:10:11 +0700 Subject: [PATCH 0280/1199] Remove named fields from field synchronizer --- .../mc/otm/block/entity/RedstoneControl.kt | 7 +- .../entity/decorative/HoloSignBlockEntity.kt | 2 +- .../matter/MatterCapacitorBankBlockEntity.kt | 2 +- .../entity/tech/BatteryBankBlockEntity.kt | 2 +- .../otm/capability/MatteryPlayerCapability.kt | 13 +- .../capability/energy/AndroidPowerSource.kt | 6 +- .../mc/otm/network/FieldSynchronizer.kt | 295 ++++++------------ .../network/MatteryPlayerNetworkChannel.kt | 2 +- .../mc/otm/network/WeaponNetworkChannel.kt | 2 +- .../mc/otm/network/WorldNetworkChannel.kt | 2 +- .../mc/otm/tests/FieldSynchronizerTests.kt | 28 -- 11 files changed, 112 insertions(+), 249 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt index 8b3a74510..a93faed9a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt @@ -62,11 +62,8 @@ class RedstoneControl(private val valueChanges: (new: Boolean, old: Boolean) -> class SynchronizedRedstoneControl( synchronizer: FieldSynchronizer, - fieldNamePrefix: String?, private val valueChanges: (new: Boolean, old: Boolean) -> Unit, ) : AbstractRedstoneControl() { - constructor(synchronizer: FieldSynchronizer, valueChanges: (new: Boolean, old: Boolean) -> Unit) : this(synchronizer, "", valueChanges) - override var redstoneSetting: RedstoneSetting by synchronizer.enum(RedstoneSetting.LOW, setter = { value, access, setByRemote -> if (access.read() == value) return@enum if (setByRemote) { @@ -77,7 +74,7 @@ class SynchronizedRedstoneControl( val state = isBlockedByRedstone valueChanges.invoke(state, old) } - }, name = if (fieldNamePrefix != null) "${fieldNamePrefix}_redstoneSetting" else null) + }) override var redstoneSignal: Int by synchronizer.int(0, setter = { value, access, setByRemote -> if (access.read() == value) return@int @@ -89,5 +86,5 @@ class SynchronizedRedstoneControl( val state = isBlockedByRedstone valueChanges.invoke(state, old) } - }, name = if (fieldNamePrefix != null) "${fieldNamePrefix}_redstoneSignal" else null) + }) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt index dd121d04a..e6eecaf09 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt @@ -20,7 +20,7 @@ import ru.dbotthepony.mc.otm.registry.MBlocks class HoloSignBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryBlockEntity(MBlockEntities.HOLO_SIGN, blockPos, blockState), MenuProvider, IRedstoneControlled { override val redstoneControl = SynchronizedRedstoneControl(synchronizer) { _, _ -> setChanged() } - var signText by synchronizer.string("", name = "text", setter = { value, access, remote -> + var signText by synchronizer.string("", setter = { value, access, remote -> setChanged() access.write(value) }) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt index 3777bb4de..986da9232 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt @@ -131,7 +131,7 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) }.also(::addDroppableContainer) val capacitorStatus = immutableList(BatteryBankBlockEntity.CAPACITY) { - synchronizer.bool(false, name = "capacitor$it") + synchronizer.bool(false) } init { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index f8753ac68..a0f1de59c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -39,7 +39,7 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte }.also(::addDroppableContainer) val batteryStatus = immutableList(CAPACITY) { - synchronizer.bool(false, name = "battery$it") + synchronizer.bool(false) } private val itemHandler = container.handler( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 10fb5fb41..60f2b8c83 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -121,12 +121,12 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial /** * Whenever player has Exopack */ - var hasExoPack by publicSynchronizer.bool(name = "hasExoPack") + var hasExoPack by publicSynchronizer.bool() /** * Whenever to render Exopack on player */ - var displayExoPack by publicSynchronizer.bool(true, name = "displayExoPack") + var displayExoPack by publicSynchronizer.bool(true) private val exoPackSlotModifierMap: MutableMap by synchronizer.Map( keyCodec = UUIDValueCodec, @@ -135,7 +135,6 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial callback = { this.exoPackSlotModifier.recompute() }, - name = "exoPackSlotModifierMap" ) /** @@ -167,7 +166,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial _exoPackMenu = null exoPackContainer = PlayerMatteryContainer(value) } - }, name = "exoPackSlotCount") + }) /** * Exopack container, which actually store items inside Exopack @@ -202,7 +201,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial access.write(value) _exoPackMenu = null } - }, name = "isExoPackCraftingUpgraded") + }) private var _exoPackMenu: ExoPackInventoryMenu? = null set(value) { @@ -276,7 +275,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial /** * Whenever player should become an Android once transformation conditions are met (e.g. player dies or sleeps in bed) */ - var willBecomeAndroid by publicSynchronizer.bool(name = "willBecomeAndroid") + var willBecomeAndroid by publicSynchronizer.bool() /** * Whenever player is an Android @@ -290,7 +289,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial * * Android-immune (de)buffs are specified in `data/overdrive_that_matters/tags/mob_effect/android_immune_effects.json` */ - var isAndroid by publicSynchronizer.bool(name = "isAndroid") + var isAndroid by publicSynchronizer.bool() /** * [IMatteryEnergyStorage] instance, representing Android' battery charge diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt index 1f1bc6445..82f17061f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt @@ -27,8 +27,8 @@ class AndroidPowerSource( override val energyFlow: FlowDirection get() = FlowDirection.INPUT - private var battery by synchronizer.fraction(initialCharge, name = "android battery") - private var maxBattery by synchronizer.fraction(maxCharge, name = "android max battery") + private var battery by synchronizer.fraction(initialCharge) + private var maxBattery by synchronizer.fraction(maxCharge) var item by synchronizer.item(setter = setter@{ value, access, setByRemote -> access.write(value) @@ -36,7 +36,7 @@ class AndroidPowerSource( if (ply is ServerPlayer) { AndroidBatteryTrigger.trigger(ply, value) } - }, name = "android battery item") + }) override fun serializeNBT(): CompoundTag { return CompoundTag().also { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt index 50aa0ff4e..bf67dfcda 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt @@ -1,14 +1,9 @@ package ru.dbotthepony.mc.otm.network -import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap -import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap -import it.unimi.dsi.fastutil.io.FastByteArrayInputStream import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream -import it.unimi.dsi.fastutil.objects.ObjectArraySet import it.unimi.dsi.fastutil.objects.Reference2ObjectFunction import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.ReferenceArraySet -import net.minecraft.nbt.NbtAccounter import net.minecraft.world.item.ItemStack import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.core.* @@ -40,9 +35,6 @@ import java.lang.ref.WeakReference import java.math.BigDecimal import java.util.* import java.util.function.Supplier -import kotlin.ConcurrentModificationException -import kotlin.collections.ArrayList -import kotlin.collections.HashMap import kotlin.properties.ReadOnlyProperty import kotlin.reflect.KMutableProperty0 import kotlin.reflect.KProperty @@ -66,13 +58,8 @@ sealed interface IField : ReadOnlyProperty, Supplier, () -> V { fun markDirty() fun markDirty(endpoint: FieldSynchronizer.Endpoint) val value: V - val name: String fun write(stream: DataOutputStream, endpoint: FieldSynchronizer.Endpoint) - fun read(stream: DataInputStream, payloadSize: Int) { - read(stream) - } - fun read(stream: DataInputStream) override fun getValue(thisRef: Any?, property: KProperty<*>): V { @@ -128,12 +115,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa private var nextFieldID = 0 - /** - * returns dummy field name - */ - fun nextFieldName() = "___field_${nextFieldID++}" - private var mappingVersion = 0 - val hasObservers: Boolean get() = observers.isNotEmpty() val isEmpty: Boolean get() = fields.isEmpty() val isNotEmpty: Boolean get() = fields.isNotEmpty() @@ -157,68 +138,68 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa hasChanges = false } - @JvmOverloads fun byte(getter: () -> Byte, name: String? = nextFieldName()) = ComputedField(getter, ByteValueCodec, name ?: nextFieldName()) - @JvmOverloads fun bool(getter: () -> Boolean, name: String? = nextFieldName()) = ComputedField(getter, BooleanValueCodec, name ?: nextFieldName()) - @JvmOverloads fun short(getter: () -> Short, name: String? = nextFieldName()) = ComputedField(getter, ShortValueCodec, name ?: nextFieldName()) - @JvmOverloads fun long(getter: () -> Long, name: String? = nextFieldName()) = ComputedField(getter, VarLongValueCodec, name ?: nextFieldName()) - @JvmOverloads fun fixedLong(getter: () -> Long, name: String? = nextFieldName()) = ComputedField(getter, LongValueCodec, name ?: nextFieldName()) - @JvmOverloads fun float(getter: () -> Float, name: String? = nextFieldName()) = ComputedField(getter, FloatValueCodec, name ?: nextFieldName()) - @JvmOverloads fun double(getter: () -> Double, name: String? = nextFieldName()) = ComputedField(getter, DoubleValueCodec, name ?: nextFieldName()) - @JvmOverloads fun uuid(getter: () -> UUID, name: String? = nextFieldName()) = ComputedField(getter, UUIDValueCodec, name ?: nextFieldName()) - @JvmOverloads fun int(getter: () -> Int, name: String? = nextFieldName()) = ComputedField(getter, VarIntValueCodec, name ?: nextFieldName()) - @JvmOverloads fun fixedInt(getter: () -> Int, name: String? = nextFieldName()) = ComputedField(getter, IntValueCodec, name ?: nextFieldName()) - @JvmOverloads fun fraction(getter: () -> Decimal, name: String? = nextFieldName()) = ComputedField(getter, ImpreciseFractionValueCodec, name ?: nextFieldName()) - @JvmOverloads fun bigDecimal(getter: () -> BigDecimal, name: String? = nextFieldName()) = ComputedField(getter, BigDecimalValueCodec, name ?: nextFieldName()) - @JvmOverloads fun item(getter: () -> ItemStack, name: String? = nextFieldName()) = ComputedField(getter, ItemStackValueCodec, name ?: nextFieldName()) - @JvmOverloads fun string(getter: () -> String, name: String? = nextFieldName()) = ComputedField(getter, BinaryStringCodec, name ?: nextFieldName()) + fun byte(getter: () -> Byte) = ComputedField(getter, ByteValueCodec) + fun bool(getter: () -> Boolean) = ComputedField(getter, BooleanValueCodec) + fun short(getter: () -> Short) = ComputedField(getter, ShortValueCodec) + fun long(getter: () -> Long) = ComputedField(getter, VarLongValueCodec) + fun fixedLong(getter: () -> Long) = ComputedField(getter, LongValueCodec) + fun float(getter: () -> Float) = ComputedField(getter, FloatValueCodec) + fun double(getter: () -> Double) = ComputedField(getter, DoubleValueCodec) + fun uuid(getter: () -> UUID) = ComputedField(getter, UUIDValueCodec) + fun int(getter: () -> Int) = ComputedField(getter, VarIntValueCodec) + fun fixedInt(getter: () -> Int) = ComputedField(getter, IntValueCodec) + fun fraction(getter: () -> Decimal) = ComputedField(getter, ImpreciseFractionValueCodec) + fun bigDecimal(getter: () -> BigDecimal) = ComputedField(getter, BigDecimalValueCodec) + fun item(getter: () -> ItemStack) = ComputedField(getter, ItemStackValueCodec) + fun string(getter: () -> String) = ComputedField(getter, BinaryStringCodec) - @JvmOverloads fun byte(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, ByteValueCodec, name ?: nextFieldName()) - @JvmOverloads fun bool(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, BooleanValueCodec, name ?: nextFieldName()) - @JvmOverloads fun short(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, ShortValueCodec, name ?: nextFieldName()) - @JvmOverloads fun long(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, VarLongValueCodec, name ?: nextFieldName()) - @JvmOverloads fun fixedLong(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, LongValueCodec, name ?: nextFieldName()) - @JvmOverloads fun float(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, FloatValueCodec, name ?: nextFieldName()) - @JvmOverloads fun double(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, DoubleValueCodec, name ?: nextFieldName()) - @JvmOverloads fun uuid(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, UUIDValueCodec, name ?: nextFieldName()) - @JvmOverloads fun int(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, VarIntValueCodec, name ?: nextFieldName()) - @JvmOverloads fun fixedInt(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, IntValueCodec, name ?: nextFieldName()) - @JvmOverloads fun fraction(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, ImpreciseFractionValueCodec, name ?: nextFieldName()) - @JvmOverloads fun bigDecimal(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, BigDecimalValueCodec, name ?: nextFieldName()) - @JvmOverloads fun item(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, ItemStackValueCodec, name ?: nextFieldName()) - @JvmOverloads fun string(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, BinaryStringCodec, name ?: nextFieldName()) + fun byte(getter: KProperty0) = ComputedField(getter, ByteValueCodec) + fun bool(getter: KProperty0) = ComputedField(getter, BooleanValueCodec) + fun short(getter: KProperty0) = ComputedField(getter, ShortValueCodec) + fun long(getter: KProperty0) = ComputedField(getter, VarLongValueCodec) + fun fixedLong(getter: KProperty0) = ComputedField(getter, LongValueCodec) + fun float(getter: KProperty0) = ComputedField(getter, FloatValueCodec) + fun double(getter: KProperty0) = ComputedField(getter, DoubleValueCodec) + fun uuid(getter: KProperty0) = ComputedField(getter, UUIDValueCodec) + fun int(getter: KProperty0) = ComputedField(getter, VarIntValueCodec) + fun fixedInt(getter: KProperty0) = ComputedField(getter, IntValueCodec) + fun fraction(getter: KProperty0) = ComputedField(getter, ImpreciseFractionValueCodec) + fun bigDecimal(getter: KProperty0) = ComputedField(getter, BigDecimalValueCodec) + fun item(getter: KProperty0) = ComputedField(getter, ItemStackValueCodec) + fun string(getter: KProperty0) = ComputedField(getter, BinaryStringCodec) - @JvmOverloads fun byte(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, ByteValueCodec, name ?: nextFieldName()) - @JvmOverloads fun bool(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, BooleanValueCodec, name ?: nextFieldName()) - @JvmOverloads fun short(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, ShortValueCodec, name ?: nextFieldName()) - @JvmOverloads fun long(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, VarLongValueCodec, name ?: nextFieldName()) - @JvmOverloads fun fixedLong(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, LongValueCodec, name ?: nextFieldName()) - @JvmOverloads fun float(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, FloatValueCodec, name ?: nextFieldName()) - @JvmOverloads fun double(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, DoubleValueCodec, name ?: nextFieldName()) - @JvmOverloads fun uuid(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, UUIDValueCodec, name ?: nextFieldName()) - @JvmOverloads fun int(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, VarIntValueCodec, name ?: nextFieldName()) - @JvmOverloads fun fixedInt(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, IntValueCodec, name ?: nextFieldName()) - @JvmOverloads fun fraction(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, ImpreciseFractionValueCodec, name ?: nextFieldName()) - @JvmOverloads fun bigDecimal(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, BigDecimalValueCodec, name ?: nextFieldName()) - @JvmOverloads fun item(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, ItemStackValueCodec, name ?: nextFieldName()) - @JvmOverloads fun string(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, BinaryStringCodec, name ?: nextFieldName()) + fun byte(getter: Supplier) = ComputedField(getter::get, ByteValueCodec) + fun bool(getter: Supplier) = ComputedField(getter::get, BooleanValueCodec) + fun short(getter: Supplier) = ComputedField(getter::get, ShortValueCodec) + fun long(getter: Supplier) = ComputedField(getter::get, VarLongValueCodec) + fun fixedLong(getter: Supplier) = ComputedField(getter::get, LongValueCodec) + fun float(getter: Supplier) = ComputedField(getter::get, FloatValueCodec) + fun double(getter: Supplier) = ComputedField(getter::get, DoubleValueCodec) + fun uuid(getter: Supplier) = ComputedField(getter::get, UUIDValueCodec) + fun int(getter: Supplier) = ComputedField(getter::get, VarIntValueCodec) + fun fixedInt(getter: Supplier) = ComputedField(getter::get, IntValueCodec) + fun fraction(getter: Supplier) = ComputedField(getter::get, ImpreciseFractionValueCodec) + fun bigDecimal(getter: Supplier) = ComputedField(getter::get, BigDecimalValueCodec) + fun item(getter: Supplier) = ComputedField(getter::get, ItemStackValueCodec) + fun string(getter: Supplier) = ComputedField(getter::get, BinaryStringCodec) - @JvmOverloads fun > enum(type: Class, getter: () -> T, name: String? = nextFieldName()) = ComputedField(getter, EnumValueCodec.of(type), name ?: nextFieldName()) - inline fun > enum(noinline getter: () -> T, name: String? = nextFieldName()) = ComputedField(getter, EnumValueCodec.of(T::class.java), name ?: nextFieldName()) + fun > enum(type: Class, getter: () -> T) = ComputedField(getter, EnumValueCodec.of(type)) + inline fun > enum(noinline getter: () -> T) = ComputedField(getter, EnumValueCodec.of(T::class.java)) - @JvmOverloads fun > enum(type: Class, getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, EnumValueCodec.of(type), name ?: nextFieldName()) - inline fun > enum(getter: KProperty0, name: String? = nextFieldName()) = ComputedField(getter, EnumValueCodec.of(T::class.java), name ?: nextFieldName()) + fun > enum(type: Class, getter: KProperty0) = ComputedField(getter, EnumValueCodec.of(type)) + inline fun > enum(getter: KProperty0) = ComputedField(getter, EnumValueCodec.of(T::class.java)) - @JvmOverloads fun > enum(type: Class, getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, EnumValueCodec.of(type), name ?: nextFieldName()) - inline fun > enum(getter: Supplier, name: String? = nextFieldName()) = ComputedField(getter::get, EnumValueCodec.of(T::class.java), name ?: nextFieldName()) + fun > enum(type: Class, getter: Supplier) = ComputedField(getter::get, EnumValueCodec.of(type)) + inline fun > enum(getter: Supplier) = ComputedField(getter::get, EnumValueCodec.of(T::class.java)) @JvmOverloads fun byte( value: Byte = 0, getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String? = nextFieldName(), + ): Field { - return Field(value, ByteValueCodec, getter, setter, name = name ?: nextFieldName()) + return Field(value, ByteValueCodec, getter, setter) } @JvmOverloads @@ -226,9 +207,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: Boolean = false, getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String? = nextFieldName(), + ): Field { - return Field(value, BooleanValueCodec, getter, setter, name = name ?: nextFieldName()) + return Field(value, BooleanValueCodec, getter, setter) } @JvmOverloads @@ -236,9 +217,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: Short = 0, getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String? = nextFieldName(), + ): Field { - return Field(value, ShortValueCodec, getter, setter, name = name ?: nextFieldName()) + return Field(value, ShortValueCodec, getter, setter) } @JvmOverloads @@ -246,9 +227,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: Long = 0L, getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String? = nextFieldName(), + ): Field { - return Field(value, VarLongValueCodec, getter, setter, name = name ?: nextFieldName()) + return Field(value, VarLongValueCodec, getter, setter) } @JvmOverloads @@ -256,9 +237,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: Long = 0L, getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String? = nextFieldName(), + ): Field { - return Field(value, LongValueCodec, getter, setter, name = name ?: nextFieldName()) + return Field(value, LongValueCodec, getter, setter) } @JvmOverloads @@ -266,9 +247,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: Float = 0f, getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String? = nextFieldName(), + ): Field { - return Field(value, FloatValueCodec, getter, setter, name = name ?: nextFieldName()) + return Field(value, FloatValueCodec, getter, setter) } @JvmOverloads @@ -276,9 +257,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: Double = 0.0, getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String? = nextFieldName(), + ): Field { - return Field(value, DoubleValueCodec, getter, setter, name = name ?: nextFieldName()) + return Field(value, DoubleValueCodec, getter, setter) } @JvmOverloads @@ -286,9 +267,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: UUID = UUID(0L, 0L), getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String? = nextFieldName(), + ): Field { - return Field(value, UUIDValueCodec, getter, setter, name = name ?: nextFieldName()) + return Field(value, UUIDValueCodec, getter, setter) } @JvmOverloads @@ -296,9 +277,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: Int = 0, getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String? = nextFieldName(), + ): Field { - return Field(value, VarIntValueCodec, getter, setter, name = name ?: nextFieldName()) + return Field(value, VarIntValueCodec, getter, setter) } @JvmOverloads @@ -306,9 +287,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: String = "", getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String? = nextFieldName(), + ): Field { - return Field(value, BinaryStringCodec, getter, setter, name = name ?: nextFieldName()) + return Field(value, BinaryStringCodec, getter, setter) } @JvmOverloads @@ -316,9 +297,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: Int = 0, getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String? = nextFieldName(), + ): Field { - return Field(value, IntValueCodec, getter, setter, name = name ?: nextFieldName()) + return Field(value, IntValueCodec, getter, setter) } @JvmOverloads @@ -326,9 +307,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: Decimal = Decimal.ZERO, getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String? = nextFieldName(), + ): Field { - return Field(value, ImpreciseFractionValueCodec, getter, setter, name = name ?: nextFieldName()) + return Field(value, ImpreciseFractionValueCodec, getter, setter) } @JvmOverloads @@ -336,9 +317,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: BigDecimal = BigDecimal.ZERO, getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String? = nextFieldName(), + ): Field { - return Field(value, BigDecimalValueCodec, getter, setter, name = name ?: nextFieldName()) + return Field(value, BigDecimalValueCodec, getter, setter) } @JvmOverloads @@ -347,9 +328,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: T = type.enumConstants[0], getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String? = nextFieldName(), + ): Field { - return Field(value, EnumValueCodec.of(type), getter, setter, name = name ?: nextFieldName()) + return Field(value, EnumValueCodec.of(type), getter, setter) } @JvmOverloads @@ -357,9 +338,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: T, getter: FieldGetter? = null, setter: FieldSetter? = null, - name: String? = nextFieldName(), + ): Field { - return Field(value, EnumValueCodec.of(value::class.java), getter, setter, name = name ?: nextFieldName()) + return Field(value, EnumValueCodec.of(value::class.java), getter, setter) } @JvmOverloads @@ -368,17 +349,14 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa getter: FieldGetter? = null, setter: FieldSetter? = null, observe: Boolean = true, - name: String? = nextFieldName(), ): Field { - return Field(value, ItemStackValueCodec, getter, setter, isObserver = observe, name = name ?: nextFieldName()) + return Field(value, ItemStackValueCodec, getter, setter, isObserver = observe) } - @JvmOverloads fun item( delegate: KMutableProperty0, - name: String? = nextFieldName(), ): ObservedField { - return ObservedField(delegate, ItemStackValueCodec, name = name ?: nextFieldName()) + return ObservedField(delegate, ItemStackValueCodec) } @JvmOverloads @@ -388,7 +366,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa callback: ((changes: Collection>) -> Unit)? = null, backingMap: MutableMap = HashMap(), observingBackingMap: MutableMap? = null, - name: String? = nextFieldName(), ): Map { return Map( keyCodec = keyCodec, @@ -396,7 +373,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa callback = callback, backingMap = backingMap, observingBackingMap = observingBackingMap, - name = name ?: nextFieldName(), ) } @@ -516,36 +492,11 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } val stream = FastByteArrayOutputStream() - - if (mappingVersion != this@FieldSynchronizer.mappingVersion) { - stream.write(1) - - for (field in fields) { - check(field.id > 0) { "This should never happen: $field maps to invalid ID: ${field.id}!" } - stream.writeVarIntLE(field.id) - val bytes = field.name.toByteArray(Charsets.UTF_8) - stream.writeVarIntLE(bytes.size) - stream.write(bytes) - } - - stream.writeVarIntLE(0) - mappingVersion = this@FieldSynchronizer.mappingVersion - } else { - stream.write(0) - } + val dataStream = DataOutputStream(stream) for (field in dirtyFields) { - val id = field.id - check(id > 0) { "This should never happen: $field maps to invalid ID: $id!" } - stream.writeVarIntLE(id) - - val innerStream = FastByteArrayOutputStream() - val dataStream = DataOutputStream(innerStream) - + stream.writeVarIntLE(field.id) field.write(dataStream, this) - - stream.writeVarIntLE(innerStream.length) - stream.write(innerStream.array, 0, innerStream.length) } dirtyFields.clear() @@ -570,15 +521,11 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } @Suppress("LeakingThis") - abstract inner class AbstractField( - final override val name: String = nextFieldName(), - ) : IField { - var id: Int = fields.size + 1 + abstract inner class AbstractField : IField { + val id: Int = fields.size + 1 init { - check(!fields.any { it.name == name }) { "Duplicate field name $name" } fields.add(this) - mappingVersion++ } } @@ -591,8 +538,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa private val getter: FieldGetter? = null, private val setter: FieldSetter? = null, isObserver: Boolean = false, - name: String = nextFieldName(), - ) : AbstractField(name), IMutableField { + ) : AbstractField(), IMutableField { private var remote: V = codec.copy(field) init { @@ -691,9 +637,8 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa inner class ComputedField( private val getter: () -> V, private val codec: IStreamCodec, - name: String = nextFieldName(), private val observer: (new: V) -> Unit = {} - ) : AbstractField(name), IField { + ) : AbstractField(), IField { private var remote: V? = null private var clientValue: V? = null private var isDirty = false @@ -750,14 +695,14 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa get() = getter.invoke() set(value) { setter.invoke(value) } - constructor(field: KMutableProperty0, codec: IStreamCodec, name: String = nextFieldName()) : super(name) { + constructor(field: KMutableProperty0, codec: IStreamCodec) : super() { this.codec = codec getter = field::get setter = field::set remote = codec.copy(value) } - constructor(getter: () -> V, setter: (V) -> Unit, codec: IStreamCodec, name: String = nextFieldName()) : super(name) { + constructor(getter: () -> V, setter: (V) -> Unit, codec: IStreamCodec) : super() { this.codec = codec this.getter = getter this.setter = setter @@ -806,8 +751,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa private val backingMap: MutableMap, private val observingBackingMap: MutableMap? = null, private val callback: ((changes: Collection>) -> Unit)? = null, - name: String = nextFieldName(), - ) : AbstractField>(name), IField> { + ) : AbstractField>(), IField> { private var isDirty = false private var sentAllValues = false private var isRemote = false @@ -1116,63 +1060,15 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return values } - private val idToField = Int2ObjectOpenHashMap>() - private val missingFields = ObjectArraySet() - private val missingFieldsMap = Int2ObjectArrayMap() - - fun read(stream: InputStream, sizeLimit: NbtAccounter = NbtAccounter(1L shl 21 /* 2 MiB */)): Int { - if (stream.read() > 0) { - idToField.clear() - missingFieldsMap.clear() - - var fieldId = stream.readVarIntLE(sizeLimit) - - while (fieldId != 0) { - val size = stream.readVarIntLE(sizeLimit) - val nameBytes = ByteArray(size) - stream.read(nameBytes) - val name = String(nameBytes, Charsets.UTF_8) - - val findField = fields.firstOrNull { it.name == name } - - if (findField == null) { - if (missingFields.add(name)) { - LOGGER.error("Unable to find field $name in $this, expect issues!") - } - - missingFieldsMap[fieldId] = name - } else { - idToField[fieldId] = findField - findField.id = fieldId - } - - fieldId = stream.readVarIntLE(sizeLimit) - } - } - - if (idToField.isEmpty()) { - throw IllegalStateException("Can't read anything, field ID mapping is empty!") - } - - var fieldId = stream.readVarIntLE(sizeLimit) + fun read(stream: InputStream): Int { + var fieldId = stream.readVarIntLE() var i = 0 + val dataStream = DataInputStream(stream) while (fieldId != 0) { - val field = idToField[fieldId] - val payloadSize = stream.readVarIntLE(sizeLimit) - - if (field == null) { - LOGGER.error("Unable to read field $fieldId (${missingFieldsMap[fieldId]}) because we don't know anything about it! Skipping $payloadSize bytes", IllegalStateException("Unknown field $fieldId")) - sizeLimit.accountBytes(payloadSize.toLong()) - stream.skipNBytes(payloadSize.toLong()) - continue - } - - sizeLimit.accountBytes(payloadSize.toLong()) - val bytes = ByteArray(payloadSize) - stream.read(bytes) - field.read(DataInputStream(FastByteArrayInputStream(bytes)), payloadSize) - fieldId = stream.readVarIntLE(sizeLimit) + val field = fields.getOrNull(fieldId - 1) ?: throw IllegalArgumentException("Unknown field ID ${fieldId - 1}") + field.read(dataStream) + fieldId = stream.readVarIntLE() i++ } @@ -1183,6 +1079,5 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa private val ClearBacklogEntry = { stream: DataOutputStream -> stream.write(MapAction.CLEAR.ordinal + 1) } private val MapActionList = MapAction.values() private val ClearMapChangeset = MapChangeset(MapAction.CLEAR, null, null) - private val LOGGER = LogManager.getLogger() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt index 1d66bc2fa..6d709eda3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt @@ -511,7 +511,7 @@ object HideExosuitPacket : MatteryPacket { } object MatteryPlayerNetworkChannel : MatteryNetworkChannel( - version = "1", + version = "2", name = "player" ) { fun register() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/WeaponNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/WeaponNetworkChannel.kt index 694b593c6..d879bed32 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/WeaponNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/WeaponNetworkChannel.kt @@ -5,7 +5,7 @@ import ru.dbotthepony.mc.otm.item.weapon.WeaponFireInputPacket import ru.dbotthepony.mc.otm.item.weapon.WeaponScopePacket object WeaponNetworkChannel : MatteryNetworkChannel( - version = "1", + version = "2", name = "weapon" ) { fun register() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt index 30a9e1273..c500243d1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt @@ -93,7 +93,7 @@ class BlockEntitySyncPacket(val position: BlockPos, val buffer: ByteArray, val v } object WorldNetworkChannel : MatteryNetworkChannel( - version = "3", + version = "4", name = "world" ) { fun register() { diff --git a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FieldSynchronizerTests.kt b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FieldSynchronizerTests.kt index 550469f3f..dae1dc541 100644 --- a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FieldSynchronizerTests.kt +++ b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FieldSynchronizerTests.kt @@ -131,32 +131,4 @@ object FieldSynchronizerTests { assertEquals(fieldsa[i].value, fieldsb[i].value) } } - - @Test - @DisplayName("Field Synchronizer field order definition mismatch") - fun orderMismatch() { - val a = FieldSynchronizer() - val b = FieldSynchronizer() - - val fieldsa = ArrayList>() - val fieldsb = ArrayList>() - - for (i in 0 .. 900) { - fieldsa.add(a.int(name = "int$i")) - } - - for (i in 900 downTo 0) { - fieldsb.add(0, b.int(name = "int$i")) - } - - for (i in 0 .. 900) { - fieldsa[i].value = i - } - - b.read(a.collectNetworkPayload()!!.let { ByteArrayInputStream(it.array, 0, it.length) }) - - for (i in 0 .. 900) { - assertEquals(fieldsa[i].value, fieldsb[i].value) - } - } } From 651759ddc39086e028c40460be60d09587b98419 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 6 Mar 2023 15:18:04 +0700 Subject: [PATCH 0281/1199] Actual scroll position remember in pattern screen --- .../otm/client/screen/matter/MatterPanelScreen.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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 f5c9b847f..54d007f49 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 @@ -62,13 +62,16 @@ class MatterPanelScreen( val scrollBar = DiscreteScrollBarPanel(this, frame, { if (isPatternView) { - scrollPatterns = integerDivisionDown(menu.patterns.size, GRID_WIDTH) - scrollPatterns + integerDivisionDown(menu.patterns.size, GRID_WIDTH) } else { - scrollTasks = integerDivisionDown(menu.tasks.size, GRID_WIDTH) - scrollTasks + integerDivisionDown(menu.tasks.size, GRID_WIDTH) } - }, { _, _, _ -> }) + }, { _, _, new -> + if (isPatternView) + scrollPatterns = new + else + scrollTasks = new + }) scrollBar.dock = Dock.RIGHT From d7d731bea997c4c6a0a6f47161dcf31d74cc1cae Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 6 Mar 2023 15:28:41 +0700 Subject: [PATCH 0282/1199] Fix being unable to repair shields or shears in anvil :thinkies: --- .../kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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 f566f338b..60ea8a299 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -156,8 +156,17 @@ object MItems { val TRITANIUM_AXE: MatteryAxeItem by registry.register(MNames.TRITANIUM_AXE) { MatteryAxeItem(TRITANIUM_COMPONENT, 8.5f, -3.4f, TOOLS_PROPRTIES) } val TRITANIUM_PICKAXE: PickaxeItem by registry.register(MNames.TRITANIUM_PICKAXE) { PickaxeItem(TRITANIUM_COMPONENT, 2, -2.8f, TOOLS_PROPRTIES) } val TRITANIUM_HOE: HoeItem by registry.register(MNames.TRITANIUM_HOE) { HoeItem(TRITANIUM_COMPONENT, 0, -3.4f, TOOLS_PROPRTIES) } - val TRITANIUM_SHEARS: ShearsItem by registry.register(MNames.TRITANIUM_SHEARS) { ShearsItem(Item.Properties().durability(3072)) } - val TRITANIUM_SHIELD: ShieldItem by registry.register(MNames.TRITANIUM_SHIELD) { ShieldItem(Item.Properties().durability(2048)) } + val TRITANIUM_SHEARS: ShearsItem by registry.register(MNames.TRITANIUM_SHEARS) { object : ShearsItem(Properties().durability(3072)) { + override fun isValidRepairItem(pToRepair: ItemStack, pRepair: ItemStack): Boolean { + return pRepair.`is`(MItemTags.TRITANIUM_INGOTS) + } + } } + + val TRITANIUM_SHIELD: ShieldItem by registry.register(MNames.TRITANIUM_SHIELD) { object : ShieldItem(Properties().durability(2048)) { + override fun isValidRepairItem(pToRepair: ItemStack, pRepair: ItemStack): Boolean { + return pRepair.`is`(MItemTags.TRITANIUM_INGOTS) + } + } } val TRITANIUM_TOOLS = SupplierList( ::TRITANIUM_SWORD, From 59f275c91e9410de61df24c76b03f99293e5a5da Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 6 Mar 2023 15:41:45 +0700 Subject: [PATCH 0283/1199] Fix quickmove behaving weirdly --- src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index ade950f70..cf2c8d18b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -6,6 +6,7 @@ import it.unimi.dsi.fastutil.io.FastByteArrayInputStream import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream import it.unimi.dsi.fastutil.objects.Reference2ObjectFunction import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap +import it.unimi.dsi.fastutil.objects.ReferenceArrayList import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer @@ -380,7 +381,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( } private val externalSlots = ArrayList() - private val quickMoveMapping = Reference2ObjectOpenHashMap>>() + private val quickMoveMapping = Reference2ObjectOpenHashMap>>() override fun addSlot(pSlot: Slot): Slot { if (pSlot in slots) { @@ -427,7 +428,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( } protected fun mapQuickMove(slot: Slot, target: Collection, prepend: Boolean = false) { - val listing = quickMoveMapping.computeIfAbsent(slot, Reference2ObjectFunction { ArrayList(1) }) + val listing = quickMoveMapping.computeIfAbsent(slot, Reference2ObjectFunction { ReferenceArrayList(1) }) listing.remove(target) if (prepend) From b063175b8c4a8a153c2d0454a5d0832f223d3cd7 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 6 Mar 2023 18:18:02 +0700 Subject: [PATCH 0284/1199] Undo caching of enum value codec --- .../mc/otm/core/util/DataStreams.kt | 27 ++++--------------- .../otm/menu/input/EnumInputWithFeedback.kt | 2 +- .../mc/otm/network/FieldSynchronizer.kt | 27 +++++++++---------- 3 files changed, 19 insertions(+), 37 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt index 6916c5589..15fb51b18 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt @@ -6,7 +6,6 @@ import com.mojang.serialization.Codec import com.mojang.serialization.DataResult import com.mojang.serialization.DynamicOps import net.minecraft.nbt.NbtAccounter -import net.minecraft.util.StringRepresentable import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.core.immutableMap import ru.dbotthepony.mc.otm.core.math.readDecimal @@ -87,14 +86,14 @@ val LongValueCodec = StreamCodec(DataInputStream::readLong, 8L, DataOutputStream val FloatValueCodec = StreamCodec(DataInputStream::readFloat, 4L, DataOutputStream::writeFloat) val DoubleValueCodec = StreamCodec(DataInputStream::readDouble, 8L, DataOutputStream::writeDouble) val ItemStackValueCodec = StreamCodec(DataInputStream::readItem, DataOutputStream::writeItem, ItemStack::copy) { a, b -> a.equals(b, true) } -val ImpreciseFractionValueCodec = StreamCodec(DataInputStream::readDecimal, DataOutputStream::writeDecimal) +val DecimalValueCodec = StreamCodec(DataInputStream::readDecimal, DataOutputStream::writeDecimal) val BigDecimalValueCodec = StreamCodec(DataInputStream::readBigDecimal, DataOutputStream::writeBigDecimal) val UUIDValueCodec = StreamCodec({ s, a -> a.accountBytes(8L); UUID(s.readLong(), s.readLong()) }, { s, v -> s.writeLong(v.mostSignificantBits); s.writeLong(v.leastSignificantBits) }) val VarIntValueCodec = StreamCodec(DataInputStream::readVarIntLE, DataOutputStream::writeVarIntLE) val VarLongValueCodec = StreamCodec(DataInputStream::readVarLongLE, DataOutputStream::writeVarLongLE) val BinaryStringCodec = StreamCodec(DataInputStream::readBinaryString, DataOutputStream::writeBinaryString) -class EnumValueCodec> private constructor(clazz: Class) : IStreamCodec, Codec { +class EnumValueCodec>(clazz: Class) : IStreamCodec, Codec { val clazz = searchClass(clazz) val values: ImmutableList = ImmutableList.copyOf(this.clazz.enumConstants!!) val valuesMap = immutableMap { @@ -137,22 +136,6 @@ class EnumValueCodec> private constructor(clazz: Class) : ISt } companion object { - private val codecs = WeakHashMap, EnumValueCodec<*>>() - - fun > of(clazz: Class): EnumValueCodec { - synchronized(codecs) { - val search = searchClass(clazz) - - if (search !== clazz) { - val result = codecs.computeIfAbsent(search) { EnumValueCodec(it as Class) } as EnumValueCodec - codecs.putIfAbsent(clazz, result) - return result - } - - return codecs.computeIfAbsent(clazz) { EnumValueCodec(it as Class) } as EnumValueCodec - } - } - /** * FIXME: enums with abstract methods which get compiled to subclasses, whose DO NOT expose "parent's" enum constants array * @@ -174,8 +157,8 @@ class EnumValueCodec> private constructor(clazz: Class) : ISt } } -fun > Class.codec() = EnumValueCodec.of(this) -fun > KClass.codec() = EnumValueCodec.of(this.java) +fun > Class.codec() = EnumValueCodec(this) +fun > KClass.codec() = EnumValueCodec(this.java) fun OutputStream.writeInt(value: Int) { if (this is DataOutput) { @@ -376,7 +359,7 @@ private val codecs: List> = com.google.common.collect.Immu it.add(IndexedStreamCodec(codecID++, FloatValueCodec)) it.add(IndexedStreamCodec(codecID++, DoubleValueCodec)) it.add(IndexedStreamCodec(codecID++, ItemStackValueCodec)) - it.add(IndexedStreamCodec(codecID++, ImpreciseFractionValueCodec)) + it.add(IndexedStreamCodec(codecID++, DecimalValueCodec)) it.add(IndexedStreamCodec(codecID++, BigDecimalValueCodec)) it.add(IndexedStreamCodec(codecID++, UUIDValueCodec)) it.add(IndexedStreamCodec(codecID++, BinaryStringCodec)) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt index d066f388c..457b3674b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt @@ -10,7 +10,7 @@ inline fun > EnumInputWithFeedback(menu: MatteryMenu, state: inline fun > EnumInputWithFeedback(menu: MatteryMenu, state: GetterSetter) = EnumInputWithFeedback(menu, E::class.java, state) class EnumInputWithFeedback>(menu: MatteryMenu, clazz: Class) : AbstractPlayerInputWithFeedback() { - val codec = EnumValueCodec.of(clazz) + val codec = EnumValueCodec(clazz) private val default = codec.values.first() override val input = menu.PlayerInput(codec, false) { consumer?.invoke(it) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt index bf67dfcda..371d2f0c2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt @@ -5,7 +5,6 @@ import it.unimi.dsi.fastutil.objects.Reference2ObjectFunction import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.ReferenceArraySet import net.minecraft.world.item.ItemStack -import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.collect.ProxiedMap import ru.dbotthepony.mc.otm.core.math.Decimal @@ -17,7 +16,7 @@ import ru.dbotthepony.mc.otm.core.util.DoubleValueCodec import ru.dbotthepony.mc.otm.core.util.EnumValueCodec import ru.dbotthepony.mc.otm.core.util.FloatValueCodec import ru.dbotthepony.mc.otm.core.util.IStreamCodec -import ru.dbotthepony.mc.otm.core.util.ImpreciseFractionValueCodec +import ru.dbotthepony.mc.otm.core.util.DecimalValueCodec import ru.dbotthepony.mc.otm.core.util.IntValueCodec import ru.dbotthepony.mc.otm.core.util.ItemStackValueCodec import ru.dbotthepony.mc.otm.core.util.LongValueCodec @@ -148,7 +147,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa fun uuid(getter: () -> UUID) = ComputedField(getter, UUIDValueCodec) fun int(getter: () -> Int) = ComputedField(getter, VarIntValueCodec) fun fixedInt(getter: () -> Int) = ComputedField(getter, IntValueCodec) - fun fraction(getter: () -> Decimal) = ComputedField(getter, ImpreciseFractionValueCodec) + fun fraction(getter: () -> Decimal) = ComputedField(getter, DecimalValueCodec) fun bigDecimal(getter: () -> BigDecimal) = ComputedField(getter, BigDecimalValueCodec) fun item(getter: () -> ItemStack) = ComputedField(getter, ItemStackValueCodec) fun string(getter: () -> String) = ComputedField(getter, BinaryStringCodec) @@ -163,7 +162,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa fun uuid(getter: KProperty0) = ComputedField(getter, UUIDValueCodec) fun int(getter: KProperty0) = ComputedField(getter, VarIntValueCodec) fun fixedInt(getter: KProperty0) = ComputedField(getter, IntValueCodec) - fun fraction(getter: KProperty0) = ComputedField(getter, ImpreciseFractionValueCodec) + fun fraction(getter: KProperty0) = ComputedField(getter, DecimalValueCodec) fun bigDecimal(getter: KProperty0) = ComputedField(getter, BigDecimalValueCodec) fun item(getter: KProperty0) = ComputedField(getter, ItemStackValueCodec) fun string(getter: KProperty0) = ComputedField(getter, BinaryStringCodec) @@ -178,19 +177,19 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa fun uuid(getter: Supplier) = ComputedField(getter::get, UUIDValueCodec) fun int(getter: Supplier) = ComputedField(getter::get, VarIntValueCodec) fun fixedInt(getter: Supplier) = ComputedField(getter::get, IntValueCodec) - fun fraction(getter: Supplier) = ComputedField(getter::get, ImpreciseFractionValueCodec) + fun fraction(getter: Supplier) = ComputedField(getter::get, DecimalValueCodec) fun bigDecimal(getter: Supplier) = ComputedField(getter::get, BigDecimalValueCodec) fun item(getter: Supplier) = ComputedField(getter::get, ItemStackValueCodec) fun string(getter: Supplier) = ComputedField(getter::get, BinaryStringCodec) - fun > enum(type: Class, getter: () -> T) = ComputedField(getter, EnumValueCodec.of(type)) - inline fun > enum(noinline getter: () -> T) = ComputedField(getter, EnumValueCodec.of(T::class.java)) + fun > enum(type: Class, getter: () -> T) = ComputedField(getter, EnumValueCodec(type)) + inline fun > enum(noinline getter: () -> T) = ComputedField(getter, EnumValueCodec(T::class.java)) - fun > enum(type: Class, getter: KProperty0) = ComputedField(getter, EnumValueCodec.of(type)) - inline fun > enum(getter: KProperty0) = ComputedField(getter, EnumValueCodec.of(T::class.java)) + fun > enum(type: Class, getter: KProperty0) = ComputedField(getter, EnumValueCodec(type)) + inline fun > enum(getter: KProperty0) = ComputedField(getter, EnumValueCodec(T::class.java)) - fun > enum(type: Class, getter: Supplier) = ComputedField(getter::get, EnumValueCodec.of(type)) - inline fun > enum(getter: Supplier) = ComputedField(getter::get, EnumValueCodec.of(T::class.java)) + fun > enum(type: Class, getter: Supplier) = ComputedField(getter::get, EnumValueCodec(type)) + inline fun > enum(getter: Supplier) = ComputedField(getter::get, EnumValueCodec(T::class.java)) @JvmOverloads fun byte( @@ -309,7 +308,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa setter: FieldSetter? = null, ): Field { - return Field(value, ImpreciseFractionValueCodec, getter, setter) + return Field(value, DecimalValueCodec, getter, setter) } @JvmOverloads @@ -330,7 +329,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa setter: FieldSetter? = null, ): Field { - return Field(value, EnumValueCodec.of(type), getter, setter) + return Field(value, EnumValueCodec(type), getter, setter) } @JvmOverloads @@ -340,7 +339,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa setter: FieldSetter? = null, ): Field { - return Field(value, EnumValueCodec.of(value::class.java), getter, setter) + return Field(value, EnumValueCodec(value::class.java), getter, setter) } @JvmOverloads From 75b06f34c28e563178db00a39b673ed1e646edfd Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 7 Mar 2023 19:31:32 +0700 Subject: [PATCH 0285/1199] Display total matter required, stored, and total complexity in pattern grid --- .../mc/otm/datagen/lang/English.kt | 34 +++--- .../mc/otm/datagen/lang/Russian.kt | 28 +++-- .../client/screen/matter/MatterPanelScreen.kt | 107 ++++++++++++++---- .../mc/otm/menu/matter/MatterPanelMenu.kt | 8 +- 4 files changed, 128 insertions(+), 49 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 4305eb16f..cc2c3c63c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -215,19 +215,6 @@ private fun misc(provider: MatteryLanguageProvider) { misc("suffix_raw.zepto", "z") misc("suffix_raw.yocto", "y") - misc("container.matter_panel.increase_by", "+%s") - misc("container.matter_panel.decrease_by", "-%s") - misc("container.matter_panel.send", "Send") - misc("container.matter_panel.close", "Close") - misc("container.matter_panel.cancel_task", "Cancel task") - misc("container.matter_panel.cancel", "Cancel") - misc("container.matter_panel.label", "Replication request") - misc("container.matter_panel.task", "Ongoing replication task") - misc("container.matter_panel.task_line", "%s: %s | %s / %s") - - misc("container.matter_panel.tasks", "Tasks") - misc("container.matter_panel.patterns", "Patterns") - misc("item.power.infinite.storage", "Stored energy: ∞ / ∞") misc("item.power.infinite.throughput", "Max I/O: ∞ / ∞") misc("item.power.passed", "Passed energy: %s") @@ -330,8 +317,6 @@ private fun misc(provider: MatteryLanguageProvider) { misc("matter_bottler.switch_mode", "Switch work mode") - misc("container.matter_panel.number_input", "Input replication task count") - misc("item.quantum_battery.creative", "Fill this to win Minecraft.") misc("item.quantum_battery.creative2", "See ya after millions of stars burn out.") misc("item.quantum_battery.creative_power", "Stored energy: %s / Infinity") @@ -646,6 +631,25 @@ private fun gui(provider: MatteryLanguageProvider) { gui("sorting.count", "Sort by amount") gui("sorting.ascending", "Ascending") gui("sorting.descending", "Descending") + + gui("matter_panel.increase_by", "+%s") + gui("matter_panel.decrease_by", "-%s") + gui("matter_panel.send", "Send") + gui("matter_panel.close", "Close") + gui("matter_panel.cancel_task", "Cancel task") + gui("matter_panel.cancel", "Cancel") + gui("matter_panel.label", "Replication request") + gui("matter_panel.task", "Ongoing replication task") + gui("matter_panel.task_line", "%s: %s | %s / %s") + + gui("matter_panel.tasks", "Tasks") + gui("matter_panel.patterns", "Patterns") + + gui("matter_panel.number_input", "Input replication task count") + + gui("matter_panel.matter_stored", "Matter stored: %s") + gui("matter_panel.matter_required", "Matter required: %s") + gui("matter_panel.complexity", "Total complexity: %s") } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 8a2872690..e78534980 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -224,16 +224,6 @@ private fun misc(provider: MatteryLanguageProvider) { misc("suffix_raw.zepto", "з") misc("suffix_raw.yocto", "и") - misc("container.matter_panel.send", "Запросить") - misc("container.matter_panel.close", "Закрыть") - misc("container.matter_panel.cancel_task", "Отменить задание") - misc("container.matter_panel.cancel", "Отмена") - misc("container.matter_panel.label", "Запрос на репликацию") - misc("container.matter_panel.task", "Будущий запрос на репликацию") - - misc("container.matter_panel.tasks", "Задачи") - misc("container.matter_panel.patterns", "Шаблоны") - misc("item.power.infinite.storage", "Хранимая энергия неиссякаема") misc("item.power.infinite.throughput", "Максимальный ввод/вывод неограничен") misc("item.power.passed", "Переданная энергия: %s") @@ -335,8 +325,6 @@ private fun misc(provider: MatteryLanguageProvider) { misc("matter_bottler.switch_mode", "Переключить режим работы") - misc("container.matter_panel.number_input", "Введите кол-во единиц репликации") - misc("item.quantum_battery.creative", "Наполните этот аккумулятор чтоб выиграть Minecraft.") misc("item.quantum_battery.creative2", "Встретимся после выгорания миллионов звёзд.") misc("item.quantum_battery.creative_power", "Хранимая энергия: %s / ∞") @@ -651,6 +639,22 @@ private fun gui(provider: MatteryLanguageProvider) { gui("sorting.count", "Сортировка по количеству") gui("sorting.ascending", "Возрастающая") gui("sorting.descending", "Убывающая") + + gui("matter_panel.send", "Запросить") + gui("matter_panel.close", "Закрыть") + gui("matter_panel.cancel_task", "Отменить задание") + gui("matter_panel.cancel", "Отмена") + gui("matter_panel.label", "Запрос на репликацию") + gui("matter_panel.task", "Будущий запрос на репликацию") + + gui("matter_panel.tasks", "Задачи") + gui("matter_panel.patterns", "Шаблоны") + + gui("matter_panel.number_input", "Введите кол-во единиц репликации") + + gui("matter_panel.matter_stored", "Материи хранится: %s") + gui("matter_panel.matter_required", "Материи требуется: %s") + gui("matter_panel.complexity", "Общая сложность: %s") } } 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 54d007f49..3edc1fe4d 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 @@ -7,6 +7,7 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.capability.matter.IPatternState import ru.dbotthepony.mc.otm.capability.matter.IReplicationTask +import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.MatteryScreen @@ -19,13 +20,18 @@ import ru.dbotthepony.mc.otm.client.screen.panels.input.EditBoxPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.ScrollBarConstants +import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.integerDivisionDown import ru.dbotthepony.mc.otm.core.util.ItemSorter +import ru.dbotthepony.mc.otm.core.util.formatMatter +import ru.dbotthepony.mc.otm.core.util.formatTickDuration +import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.menu.matter.MatterPanelMenu import ru.dbotthepony.mc.otm.menu.matter.ReplicationRequestPacket import ru.dbotthepony.mc.otm.network.MenuNetworkChannel import yalter.mousetweaks.api.MouseTweaksDisableWheelTweak +import kotlin.math.roundToInt @MouseTweaksDisableWheelTweak class MatterPanelScreen( @@ -76,11 +82,11 @@ class MatterPanelScreen( scrollBar.dock = Dock.RIGHT frame.Tab(onOpen = { isPatternView = true; scrollBar.scroll = scrollPatterns }, activeIcon = PATTERN_LIST_ACTIVE, inactiveIcon = PATTERN_LIST_INACTIVE).also { - it.tooltip = TranslatableComponent("otm.container.matter_panel.patterns") + it.tooltip = TranslatableComponent("otm.gui.matter_panel.patterns") } frame.Tab(onOpen = { isPatternView = false; scrollBar.scroll = scrollTasks }, activeIcon = TASK_LIST_ACTIVE, inactiveIcon = TASK_LIST_INACTIVE).also { - it.tooltip = TranslatableComponent("otm.container.matter_panel.tasks") + it.tooltip = TranslatableComponent("otm.gui.matter_panel.tasks") } val canvas = object : EditablePanel(this@MatterPanelScreen, frame, width = GRID_WIDTH * AbstractSlotPanel.SIZE) { @@ -163,7 +169,7 @@ class MatterPanelScreen( } private fun openTask(task: IReplicationTask<*>) { - val frame = FramePanel.padded(this, null, 170f, 20f, TranslatableComponent("otm.container.matter_panel.task")) + val frame = FramePanel.padded(this, null, 170f, 20f, TranslatableComponent("otm.gui.matter_panel.task")) frame.closeOnEscape = true @@ -185,13 +191,13 @@ class MatterPanelScreen( } } - ButtonPanel(this@MatterPanelScreen, frame, width = 40f, label = TranslatableComponent("otm.container.matter_panel.close"), onPress = frame::remove).also { + ButtonPanel(this@MatterPanelScreen, frame, width = 40f, label = TranslatableComponent("otm.gui.matter_panel.close"), onPress = frame::remove).also { it.dock = Dock.RIGHT it.dockLeft = 2f } if (minecraft?.player?.isSpectator != true) { - ButtonPanel(this@MatterPanelScreen, frame, width = 80f, label = TranslatableComponent("otm.container.matter_panel.cancel_task"), onPress = Runnable { + ButtonPanel(this@MatterPanelScreen, frame, width = 80f, label = TranslatableComponent("otm.gui.matter_panel.cancel_task"), onPress = Runnable { menu.requestTaskCancel(task.id) frame.remove() }).also { @@ -207,7 +213,7 @@ class MatterPanelScreen( } private fun openPattern(pattern: IPatternState) { - val frame = FramePanel.padded(this, null, 213f, (ButtonPanel.HEIGHT + 3f) * 4f, TranslatableComponent("otm.container.matter_panel.task")) + val frame = FramePanel.padded(this, null, 213f, (ButtonPanel.HEIGHT + 3f) * 4f + 38f, TranslatableComponent("otm.gui.matter_panel.task")) frame.closeOnEscape = true @@ -253,6 +259,8 @@ class MatterPanelScreen( } } + var count = 1 + val input = object : EditBoxPanel(this@MatterPanelScreen, rowInput) { init { dock = Dock.FILL @@ -269,68 +277,77 @@ class MatterPanelScreen( } fun increase(amount: Int) { - var value = 1 + count = 1 try { - value = getOrCreateWidget().value.toInt() + count = getOrCreateWidget().value.toInt().coerceIn(1, 99999) } catch (_: NumberFormatException) { } - if (value == 1 && amount > 0) + if (count == 1 && amount > 0) getOrCreateWidget().value = amount.toString() else - getOrCreateWidget().value = 1.coerceAtLeast(99999.coerceAtMost(value + amount)).toString() + getOrCreateWidget().value = (count + amount).coerceIn(1, 99999).toString() + } + + override fun tickInner() { + super.tickInner() + + try { + count = getOrCreateWidget().value.toInt().coerceIn(1, 99999) + } catch (_: NumberFormatException) { + } } fun send() { - var value = 1 + count = 1 try { - value = getOrCreateWidget().value.toInt() + count = getOrCreateWidget().value.toInt().coerceIn(1, 99999) } catch (_: NumberFormatException) { } - MenuNetworkChannel.sendToServer(ReplicationRequestPacket(pattern.id, value)) + MenuNetworkChannel.sendToServer(ReplicationRequestPacket(pattern.id, count)) frame.remove() } } - ButtonPanel(this, rowTop, width = 40f, label = TranslatableComponent("otm.container.matter_panel.increase_by", 8), onPress = Runnable { input.increase(8) }).also { + ButtonPanel(this, rowTop, width = 40f, label = TranslatableComponent("otm.gui.matter_panel.increase_by", 8), onPress = Runnable { input.increase(8) }).also { it.dock = Dock.RIGHT it.dockLeft = 2f } - ButtonPanel(this, rowTop, width = 40f, label = TranslatableComponent("otm.container.matter_panel.increase_by", 64), onPress = Runnable { input.increase(64) }).also { + ButtonPanel(this, rowTop, width = 40f, label = TranslatableComponent("otm.gui.matter_panel.increase_by", 64), onPress = Runnable { input.increase(64) }).also { it.dock = Dock.RIGHT it.dockLeft = 2f } - ButtonPanel(this, rowTop, width = 40f, label = TranslatableComponent("otm.container.matter_panel.increase_by", 256), onPress = Runnable { input.increase(256) }).also { + ButtonPanel(this, rowTop, width = 40f, label = TranslatableComponent("otm.gui.matter_panel.increase_by", 256), onPress = Runnable { input.increase(256) }).also { it.dock = Dock.RIGHT it.dockLeft = 2f } - ButtonPanel(this, rowBottom, width = 40f, label = TranslatableComponent("otm.container.matter_panel.decrease_by", 8), onPress = Runnable { input.increase(-8) }).also { + ButtonPanel(this, rowBottom, width = 40f, label = TranslatableComponent("otm.gui.matter_panel.decrease_by", 8), onPress = Runnable { input.increase(-8) }).also { it.dock = Dock.RIGHT it.dockLeft = 2f } - ButtonPanel(this, rowBottom, width = 40f, label = TranslatableComponent("otm.container.matter_panel.decrease_by", 64), onPress = Runnable { input.increase(-64) }).also { + ButtonPanel(this, rowBottom, width = 40f, label = TranslatableComponent("otm.gui.matter_panel.decrease_by", 64), onPress = Runnable { input.increase(-64) }).also { it.dock = Dock.RIGHT it.dockLeft = 2f } - ButtonPanel(this, rowBottom, width = 40f, label = TranslatableComponent("otm.container.matter_panel.decrease_by", 256), onPress = Runnable { input.increase(-256) }).also { + ButtonPanel(this, rowBottom, width = 40f, label = TranslatableComponent("otm.gui.matter_panel.decrease_by", 256), onPress = Runnable { input.increase(-256) }).also { it.dock = Dock.RIGHT it.dockLeft = 2f } - ButtonPanel(this, rowControls, width = 40f, label = TranslatableComponent("otm.container.matter_panel.cancel"), onPress = frame::remove).also { + ButtonPanel(this, rowControls, width = 40f, label = TranslatableComponent("otm.gui.matter_panel.cancel"), onPress = frame::remove).also { it.dock = Dock.RIGHT it.dockLeft = 2f } - ButtonPanel(this, rowControls, width = 82f, label = TranslatableComponent("otm.container.matter_panel.send"), onPress = input::send).also { + ButtonPanel(this, rowControls, width = 82f, label = TranslatableComponent("otm.gui.matter_panel.send"), onPress = input::send).also { it.dock = Dock.RIGHT it.dockLeft = 2f } @@ -338,6 +355,54 @@ class MatterPanelScreen( addPanel(frame) popup(frame) + object : Label(this@MatterPanelScreen, frame, text = TextComponent("")) { + init { + dock = Dock.TOP + dockTop = 5f + } + + override fun tickInner() { + super.tickInner() + + text = TranslatableComponent( + "otm.gui.matter_panel.matter_stored", + menu.totalMatterStored.formatMatter(formatAsReadable = ShiftPressedCond), + ) + } + } + + object : Label(this@MatterPanelScreen, frame, text = TextComponent("")) { + init { + dock = Dock.TOP + dockTop = 3f + } + + override fun tickInner() { + super.tickInner() + + text = TranslatableComponent( + "otm.gui.matter_panel.matter_required", + (MatterManager.get(pattern.item).matter * count).formatMatter(formatAsReadable = ShiftPressedCond), + ) + } + } + + object : Label(this@MatterPanelScreen, frame, text = TextComponent("")) { + init { + dock = Dock.TOP + dockTop = 3f + } + + override fun tickInner() { + super.tickInner() + + text = TranslatableComponent( + "otm.gui.matter_panel.complexity", + formatTickDuration((MatterManager.get(pattern.item).complexity * count).roundToInt(), true), + ) + } + } + frame.toScreenCenter() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt index 1fc56d8d8..c9a62439e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt @@ -12,8 +12,9 @@ import ru.dbotthepony.mc.otm.capability.matter.* import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.addSorted +import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.util.BooleanValueCodec -import ru.dbotthepony.mc.otm.core.util.EnumValueCodec +import ru.dbotthepony.mc.otm.core.util.DecimalValueCodec import ru.dbotthepony.mc.otm.core.util.ItemSorter import ru.dbotthepony.mc.otm.core.util.codec import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphListener @@ -168,6 +169,11 @@ class MatterPanelMenu @JvmOverloads constructor( tasks.sortWith(actualTaskComparator) }) + val totalMatterStored: Decimal by mSynchronizer.ComputedField( + getter = { tile?.matterGraph?.getMatterStorageLevel() ?: Decimal.ZERO }, + codec = DecimalValueCodec, + ) + val changeIsAscending = booleanInput(allowSpectators = true) { tile?.getPlayerSettings(ply)?.ascending = it } val changeSorting = PlayerInput(ItemSorter::class.codec(), allowSpectators = true) { tile?.getPlayerSettings(ply)?.sorter = it } From 9fd4c22c36cff2febaff44865b8740aa9bc7004f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 7 Mar 2023 19:34:44 +0700 Subject: [PATCH 0286/1199] Fix referencing Decimal::deserializeNBT not pointing at proper function --- src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Decimal.kt | 5 ----- 1 file changed, 5 deletions(-) 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 39f471d84..3e530f0c6 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 @@ -845,11 +845,6 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 return ZERO } - @JvmStatic - fun deserializeNBT(input: ByteArrayTag): Decimal { - return fromByteArray(input.asByteArray) - } - @JvmStatic fun read(buff: FriendlyByteBuf): Decimal { return Decimal(BigInteger(buff.readByteArray()), buff.readDouble()) From fda82f335702939953f9fe3976d9b7d7990ff0db Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 7 Mar 2023 19:35:36 +0700 Subject: [PATCH 0287/1199] Fix creative matter capacitor not exposing Long.MAX_VALUE stored matter --- .../dbotthepony/mc/otm/item/MatterCapacitorItem.kt | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt index b58b41715..465ee309a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt @@ -21,6 +21,7 @@ import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.util.formatMatter import ru.dbotthepony.mc.otm.core.ifPresentK +import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.tagNotNull import javax.annotation.ParametersAreNonnullByDefault @@ -36,22 +37,18 @@ class MatterCapacitorItem : Item { override var storedMatter: Decimal get() { - val tag = stack.orCreateTag - return if (tag.contains("matter")) { - Decimal.deserializeNBT(tag["matter"]) - } else Decimal.ZERO + if (isCreative) return Decimal.LONG_MAX_VALUE + return stack.tag?.map("matter", Decimal.Companion::deserializeNBT) ?: Decimal.ZERO } set(value) { stack.tagNotNull.put("matter", value.serializeNBT()) } - override val maxStoredMatter: Decimal - get() { + override val maxStoredMatter: Decimal get() { return capacity } - override val missingMatter: Decimal - get() { + override val missingMatter: Decimal get() { return if (isCreative) Decimal.LONG_MAX_VALUE else super.missingMatter } From 986be8fa1a54fd781efde6a324161c6f438794b5 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 7 Mar 2023 20:41:12 +0700 Subject: [PATCH 0288/1199] Un-hellish panel focus logic --- .../mc/otm/client/screen/MatteryScreen.kt | 2 +- .../otm/client/screen/panels/EditablePanel.kt | 194 +++++++----------- .../screen/panels/input/EditBoxPanel.kt | 22 +- .../panels/input/NetworkNumberInputPanel.kt | 2 +- .../panels/input/NetworkedStringInputPanel.kt | 6 +- .../screen/panels/input/TextInputPanel.kt | 4 +- 6 files changed, 99 insertions(+), 131 deletions(-) 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 1f7d24ad1..be943534f 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 @@ -358,7 +358,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit for (panel in panels) { if (click || !panel.mouseClickedChecked(x, y, button)) { - focusKilled = panel.killFocusForEverythingExceptInner() || focusKilled + focusKilled = panel.killFocus() || focusKilled } else { if (returnSlot != null) { super.mouseClicked(x, y, button) 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 5f7f9d528..ff5518306 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 @@ -560,19 +560,23 @@ open class EditablePanel @JvmOverloads constructor( protected open fun onHovered() {} protected open fun onUnHovered() {} - var isFocused = false - set(value) { + var hasFocusedChildren = false + private set(value) { if (field != value) { - val old = field field = value - - onFocusChanged(value, old) - findAbsoluteRoot().updateFocus() + onHierarchicalFocusChanged() } } - var autoKillFocus = true - private var focusedAsParent = false + var isFocusedThis = false + private set(value) { + if (field != value) { + field = value + onFocusChanged() + } + } + + var autoRequestFocus = true val font: Font get() = if (screen is MatteryScreen<*>) screen.font else minecraft.font @@ -1105,15 +1109,24 @@ open class EditablePanel @JvmOverloads constructor( } } - private fun killFocusInternal(): Boolean { - var status = false - + private fun killGrabMouseInput() { for (child in childrenInternal) { - status = child.killFocusInternal() || status + child.killGrabMouseInput() } - if (isFocused) { - isFocused = false + grabMouseInput = false + } + + private fun killFocusThis(children: Boolean): Boolean { + var status = false + + if (isFocusedThis) { + isFocusedThis = false + status = true + } + + if (children && hasFocusedChildren) { + hasFocusedChildren = false status = true } @@ -1125,29 +1138,19 @@ open class EditablePanel @JvmOverloads constructor( return status } - private fun killGrabMouseInput() { - for (child in childrenInternal) { - child.killGrabMouseInput() - } - - grabMouseInput = false - } - fun killFocus(): Boolean { - if (isEverFocused()) { - val status = killFocusInternal() - findAbsoluteRoot().updateFocus() - return status - } else if (isGrabbingMouseInput()) { - killGrabMouseInput() - return true + var status = false + status = killFocusThis(true) || status + + for (child in childrenInternal) { + status = child.killFocus() || status } - return false + return status } fun findHierarchicalFocus(): EditablePanel<*>? { - if (isFocused) { + if (isFocusedThis) { return this } @@ -1166,46 +1169,35 @@ open class EditablePanel @JvmOverloads constructor( return findHierarchicalFocus() != null } - protected open fun onHierarchicalFocusChanged(new: Boolean, old: Boolean) { - - } - - protected open fun onFocusChanged(new: Boolean, old: Boolean) { - - } - - private fun updateFocus() { - val old = focusedAsParent - focusedAsParent = hasHierarchicalFocus() - - if (focusedAsParent != old) { - onHierarchicalFocusChanged(focusedAsParent, old) - } - - for (child in childrenInternal) { - child.updateFocus() - } - } + protected open fun onHierarchicalFocusChanged() {} + protected open fun onFocusChanged() {} fun isEverFocused(): Boolean { - return isFocused || focusedAsParent + return isFocusedThis || hasFocusedChildren } fun requestFocus() { - if (isFocused) { + if (isFocusedThis || !isVisible()) { return } - if (focusedAsParent) { - var child = findHierarchicalFocus() + var filter: EditablePanel<*>? = null + var parent: EditablePanel<*>? = this - while (child != null) { - child.isFocused = false - child = findHierarchicalFocus() + while (parent != null) { + for (child in parent.childrenInternal) { + if (child !== filter) { + child.killFocus() + } } + + filter = parent + parent = parent.parent + parent?.killFocusThis(false) + parent?.hasFocusedChildren = true } - isFocused = true + isFocusedThis = true } protected open fun xPosUpdated(new: Float, old: Float) {} @@ -1311,69 +1303,52 @@ open class EditablePanel @JvmOverloads constructor( y in pos.y .. pos2.y } - fun killFocusForEverythingExcept(except: EditablePanel<*>) { - for (child in childrenInternal) { - if (child !== except) { - child.killFocusForEverythingExceptInner() - } - } - } - - fun killFocusForEverythingExceptInner(): Boolean { - var focusKilled = false - - for (child in childrenInternal) { - focusKilled = child.killFocusForEverythingExceptInner() || focusKilled - } - - if (autoKillFocus) { - focusKilled = killFocus() || focusKilled - } - - return focusKilled - } - final override fun mouseClicked(x: Double, y: Double, button: Int): Boolean { if (!isVisible() || !acceptMouseInput) return false if (flashAnyBlocker()) return true - if (grabMouseInput) return mouseClickedInner(x, y, button) + + if (grabMouseInput) { + if (mouseClickedInner(x, y, button)) { + if (autoRequestFocus) requestFocus() + return true + } + + return false + } for (child in visibleChildrenInternal) { if (child.isGrabbingMouseInput() && child.mouseClickedChecked(x, y, button)) { - killFocusForEverythingExcept(child) return true } } for (child in visibleChildrenInternal) { if (child.mouseClickedChecked(x, y, button)) { - killFocusForEverythingExcept(child) return true } } - return mouseClickedInner(x, y, button) + if (mouseClickedInner(x, y, button)) { + if (autoRequestFocus) requestFocus() + return true + } + + return false } fun mouseClickedChecked(x: Double, y: Double, button: Int): Boolean { if (!isVisible() || !acceptMouseInput) return false if (isGrabbingMouseInput() || withinBounds(x, y)) { - popup() return mouseClicked(x, y, button) } else if (withinExtendedBounds(x, y)) { popup(false) for (child in visibleChildrenInternal) { if (child.mouseClickedChecked(x, y, button)) { - killFocusForEverythingExcept(child) return true } } - - if (autoKillFocus) killFocus() - } else if (autoKillFocus) { - killFocus() } return false @@ -1509,13 +1484,9 @@ open class EditablePanel @JvmOverloads constructor( final override fun keyPressed(key: Int, scancode: Int, mods: Int): Boolean { if (!isVisible() || !acceptKeyboardInput) return false - if (!focusedAsParent) return false - - if (flashAnyBlocker(true)) { - return true - } - - if (isFocused) return keyPressedInternal(key, scancode, mods) + if (!isEverFocused()) return false + if (flashAnyBlocker(true)) return true + if (isFocusedThis) return keyPressedInternal(key, scancode, mods) for (child in visibleChildrenInternal) { if (child.keyPressed(key, scancode, mods)) { @@ -1523,7 +1494,7 @@ open class EditablePanel @JvmOverloads constructor( } } - if (focusedAsParent) return keyPressedInternal(key, scancode, mods) + if (hasFocusedChildren) return keyPressedInternal(key, scancode, mods) return false } @@ -1533,13 +1504,9 @@ open class EditablePanel @JvmOverloads constructor( final override fun keyReleased(key: Int, scancode: Int, mods: Int): Boolean { if (!isVisible() || !acceptKeyboardInput) return false - if (!focusedAsParent) return false - - if (flashAnyBlocker(false)) { - return true - } - - if (isFocused) return keyReleasedInternal(key, scancode, mods) + if (!isEverFocused()) return false + if (flashAnyBlocker(false)) return true + if (isFocusedThis) return keyReleasedInternal(key, scancode, mods) for (child in visibleChildrenInternal) { if (child.keyReleased(key, scancode, mods)) { @@ -1547,7 +1514,7 @@ open class EditablePanel @JvmOverloads constructor( } } - if (focusedAsParent) return keyReleasedInternal(key, scancode, mods) + if (hasFocusedChildren) return keyReleasedInternal(key, scancode, mods) return false } @@ -1557,13 +1524,9 @@ open class EditablePanel @JvmOverloads constructor( final override fun charTyped(codepoint: Char, mods: Int): Boolean { if (!isVisible() || !acceptKeyboardInput) return false - if (!focusedAsParent) return false - - if (flashAnyBlocker()) { - return true - } - - if (isFocused) return charTypedInternal(codepoint, mods) + if (!isEverFocused()) return false + if (flashAnyBlocker(false)) return true + if (isFocusedThis) return charTypedInternal(codepoint, mods) for (child in visibleChildrenInternal) { if (child.charTyped(codepoint, mods)) { @@ -1571,6 +1534,7 @@ open class EditablePanel @JvmOverloads constructor( } } + if (hasFocusedChildren) return charTypedInternal(codepoint, mods) return true } @@ -1638,7 +1602,7 @@ open class EditablePanel @JvmOverloads constructor( screen.popup(this as EditablePanel>) } - if (focus && !isEverFocused()) { + if (focus) { requestFocus() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/EditBoxPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/EditBoxPanel.kt index 2bdebef73..7266ec218 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/EditBoxPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/EditBoxPanel.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.client.screen.panels.input +import com.mojang.blaze3d.platform.InputConstants import net.minecraft.client.gui.components.EditBox import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component @@ -23,15 +24,11 @@ open class EditBoxPanel( } override fun isFocused(): Boolean { - return this@EditBoxPanel.isFocused + return this@EditBoxPanel.isFocusedThis } } } - init { - autoKillFocus = true - } - override fun copyValues(new_widget: EditBox, old_widget: EditBox) { new_widget.value = old_widget.value } @@ -42,11 +39,11 @@ open class EditBoxPanel( } override fun configureNew(widget: EditBox, recreation: Boolean) { - widget.setFocus(isFocused) + widget.setFocus(isFocusedThis) } - override fun onFocusChanged(new: Boolean, old: Boolean) { - widget?.setFocus(new) + override fun onFocusChanged() { + widget?.setFocus(isFocusedThis) } override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { @@ -54,4 +51,13 @@ open class EditBoxPanel( requestFocus() return true } + + override fun keyPressedInternal(key: Int, scancode: Int, mods: Int): Boolean { + if (key == InputConstants.KEY_ESCAPE && widget?.isActive == true) { + widget?.setFocus(false) + return true + } + + return super.keyPressedInternal(key, scancode, mods) + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkNumberInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkNumberInputPanel.kt index b92c12a83..53d3ac70d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkNumberInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkNumberInputPanel.kt @@ -58,7 +58,7 @@ open class NetworkNumberInputPanel @JvmOverloads constructor( override fun tickInner() { super.tickInner() - if (isFocused) { + if (isFocusedThis) { if (!isAvailable.asBoolean) { killFocus() return diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt index 4026ccdaa..be566b427 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt @@ -19,10 +19,10 @@ open class NetworkedStringInputPanel( get() = backend.test(minecraft.player) set(value) {} - override fun onFocusChanged(new: Boolean, old: Boolean) { - super.onFocusChanged(new, old) + override fun onFocusChanged() { + super.onFocusChanged() - if (new && !backend.test(minecraft.player)) { + if (isFocusedThis && !backend.test(minecraft.player)) { killFocus() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt index f9c850265..784eb3605 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt @@ -27,7 +27,6 @@ import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.addAll import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.milliTime -import kotlin.math.roundToInt open class TextInputPanel( screen: S, @@ -149,7 +148,6 @@ open class TextInputPanel( init { scissor = true dockPadding = DockProperty(2f, 2f, 2f, 2f) - autoKillFocus = true } private var oldText = ArrayList() @@ -1138,7 +1136,7 @@ open class TextInputPanel( break } - if (isFocused && milliTime % 1000L > 500L) { + if (isFocusedThis && milliTime % 1000L > 500L) { val activeLine = this[cursorLine] if (activeLine == null || cursorRow >= activeLine.length) { From c91124d25c3dbd09d91a4067ec0d3c9199bf5974 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 7 Mar 2023 21:04:25 +0700 Subject: [PATCH 0289/1199] Align text vertically when not multilining --- .../screen/panels/input/TextInputPanel.kt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt index 784eb3605..b3f29b3ec 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt @@ -27,6 +27,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.addAll import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.milliTime +import kotlin.math.roundToInt open class TextInputPanel( screen: S, @@ -1049,6 +1050,8 @@ open class TextInputPanel( if (!backgroundColor.isFullyTransparent) drawRect(stack, 0f, 0f, width, height, backgroundColor) + var topPadding = dockPadding.top + if (multiLine) { val heightInLines = ((height - dockPadding.top - dockPadding.bottom) / (font.lineHeight + rowSpacing)).toInt() @@ -1061,6 +1064,8 @@ open class TextInputPanel( } } else { scrollLines = 0 + + topPadding += ((height - dockPadding.top - dockPadding.bottom - font.lineHeight).coerceAtLeast(0f) / 2f).roundToInt() } val selectedLine = this[cursorLine] @@ -1078,7 +1083,7 @@ open class TextInputPanel( stack.pushPose() stack.translate(-scrollPixels, 0f, 0f) - var y = dockPadding.top + var y = topPadding for (i in scrollLines until lines.size) { val line = lines[i] @@ -1146,7 +1151,7 @@ open class TextInputPanel( text = "_", align = TextAlign.TOP_LEFT, x = dockPadding.left + (if (activeLine == null) 0f else font.width(activeLine).toFloat()), - y = dockPadding.top + (cursorLine - scrollLines) * (font.lineHeight + rowSpacing), + y = topPadding + (cursorLine - scrollLines) * (font.lineHeight + rowSpacing), color = cursorColor ) } else { @@ -1156,7 +1161,7 @@ open class TextInputPanel( text = "|", align = TextAlign.TOP_LEFT, x = dockPadding.left + font.width(activeLine.substring(0, cursorRow)).toFloat() - 1f, - y = dockPadding.top + (cursorLine - scrollLines) * (font.lineHeight + rowSpacing), + y = topPadding + (cursorLine - scrollLines) * (font.lineHeight + rowSpacing), color = cursorColor ) } @@ -1171,7 +1176,7 @@ open class TextInputPanel( text = cursorLine.toString(), align = TextAlign.TOP_RIGHT, x = width, - y = dockPadding.top, + y = topPadding, color = cursorColor ) @@ -1181,7 +1186,7 @@ open class TextInputPanel( text = cursorRow.toString(), align = TextAlign.TOP_RIGHT, x = width - dockPadding.right, - y = dockPadding.top + font.lineHeight + rowSpacing, + y = topPadding + font.lineHeight + rowSpacing, color = cursorColor ) @@ -1191,7 +1196,7 @@ open class TextInputPanel( text = lines.size.toString(), align = TextAlign.TOP_RIGHT, x = width - dockPadding.right, - y = dockPadding.top + font.lineHeight * 2f + rowSpacing * 2f, + y = topPadding + font.lineHeight * 2f + rowSpacing * 2f, color = cursorColor ) } From 27c7ef7b504174cf41f75d2b784ddcd8c28082b6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 7 Mar 2023 21:04:33 +0700 Subject: [PATCH 0290/1199] Use TextInputPanel --- .../client/screen/matter/MatterPanelScreen.kt | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) 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 3edc1fe4d..eb86c69f5 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 @@ -17,6 +17,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.button.DeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeBooleanRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeEnumRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.input.EditBoxPanel +import ru.dbotthepony.mc.otm.client.screen.panels.input.TextInputPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.ScrollBarConstants @@ -261,40 +262,32 @@ class MatterPanelScreen( var count = 1 - val input = object : EditBoxPanel(this@MatterPanelScreen, rowInput) { + val input = object : TextInputPanel(this@MatterPanelScreen, rowInput) { init { dock = Dock.FILL + text = "1" requestFocus() } - override fun configureNew(widget: EditBox, recreation: Boolean) { - super.configureNew(widget, recreation) - widget.setMaxLength(6) - - if (!recreation) { - widget.value = "1" - } - } - fun increase(amount: Int) { count = 1 try { - count = getOrCreateWidget().value.toInt().coerceIn(1, 99999) + count = text.toInt().coerceIn(1, 99999) } catch (_: NumberFormatException) { } if (count == 1 && amount > 0) - getOrCreateWidget().value = amount.toString() + text = amount.toString() else - getOrCreateWidget().value = (count + amount).coerceIn(1, 99999).toString() + text = (count + amount).coerceIn(1, 99999).toString() } override fun tickInner() { super.tickInner() try { - count = getOrCreateWidget().value.toInt().coerceIn(1, 99999) + count = text.toInt().coerceIn(1, 99999) } catch (_: NumberFormatException) { } } @@ -303,7 +296,7 @@ class MatterPanelScreen( count = 1 try { - count = getOrCreateWidget().value.toInt().coerceIn(1, 99999) + count = text.toInt().coerceIn(1, 99999) } catch (_: NumberFormatException) { } From 4039143974ac5908fbe151a110b577edd88c0ede Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 7 Mar 2023 22:34:30 +0700 Subject: [PATCH 0291/1199] If your tier is equivalent to another tier, then Tier#getTag should return an empty tag reference defined by BlockTags#create and have the equivalent tier be placed in the after list when registering. If the tier is a vanilla tier, you should also specify the next tier above in the before list. If your tier is equivalent to another tier, then Tier#getTag should return an empty tag reference defined by BlockTags#create and have the equivalent tier be placed in the after list when registering. If the tier is a vanilla tier, you should also specify the next tier above in the before list. If your tier is equivalent to another tier, then Tier#getTag should return an empty tag reference defined by BlockTags#create and have the equivalent tier be placed in the after list when registering. If the tier is a vanilla tier, you should also specify the next tier above in the before list. If your tier is equivalent to another tier, then Tier#getTag should return an empty tag reference defined by BlockTags#create and have the equivalent tier be placed in the after list when registering. If the tier is a vanilla tier, you should also specify the next tier above in the before list. If your tier is equivalent to another tier, then Tier#getTag should return an empty tag reference defined by BlockTags#create and have the equivalent tier be placed in the after list when registering. If the tier is a vanilla tier, you should also specify the next tier above in the before list. If your tier is equivalent to another tier, then Tier#getTag should return an empty tag reference defined by BlockTags#create and have the equivalent tier be placed in the after list when registering. If the tier is a vanilla tier, you should also specify the next tier above in the before list. If your tier is equivalent to another tier, then Tier#getTag should return an empty tag reference defined by BlockTags#create and have the equivalent tier be placed in the after list when registering. If the tier is a vanilla tier, you should also specify the next tier above in the before list. If your tier is equivalent to another tier, then Tier#getTag should return an empty tag reference defined by BlockTags#create and have the equivalent tier be placed in the after list when registering. If the tier is a vanilla tier, you should also specify the next tier above in the before list. If your tier is equivalent to another tier, then Tier#getTag should return an empty tag reference defined by BlockTags#create and have the equivalent tier be placed in the after list when registering. If the tier is a vanilla tier, you should also specify the next tier above in the before list. If your tier is equivalent to another tier, then Tier#getTag should return an empty tag reference defined by BlockTags#create and have the equivalent tier be placed in the after list when registering. If the tier is a vanilla tier, you should also specify the next tier above in the before list. If your tier is equivalent to another tier, then Tier#getTag should return an empty tag reference defined by BlockTags#create and have the equivalent tier be placed in the after list when registering. If the tier is a vanilla tier, you should also specify the next tier above in the before list. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gigaherz — 22.06.2022 13:53 we decided that we wouldn't support equivalent grades , due to API complexity, instead we recommend having one explicitly "just above the other but with an empty tag" --- src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt | 4 ++-- src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) 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 60ea8a299..0b6858f21 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -140,13 +140,13 @@ object MItems { Tiers.IRON.speed * 1.1f, 3.5f, 16, - BlockTags.NEEDS_IRON_TOOL + MBlockTags.REQUIRES_TRITANIUM_TOOL ) { Ingredient.of(TRITANIUM_INGOT) } val TRITANIUM_COMPONENT_NAME = ResourceLocation(OverdriveThatMatters.MOD_ID, "tritanium") init { - TierSortingRegistry.registerTier(TRITANIUM_COMPONENT, TRITANIUM_COMPONENT_NAME, listOf(Tiers.IRON), listOf(Tiers.DIAMOND)) + TierSortingRegistry.registerTier(TRITANIUM_COMPONENT, TRITANIUM_COMPONENT_NAME, listOf(Tiers.IRON), listOf()) } private val TOOLS_PROPRTIES = Item.Properties() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt index 42fc27a72..433e40e59 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt @@ -82,6 +82,8 @@ object MBlockTags { val CRAFTING_TABLES: TagKey = BlockTags.create(ResourceLocation("forge", "crafting_tables")) + val REQUIRES_TRITANIUM_TOOL: TagKey = BlockTags.create(ResourceLocation("minecraft", "requires_tritanium_tool")) + val HARDENED_GLASS_PANES: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes")) val HARDENED_GLASS_PANES_BLACK: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/black")) val HARDENED_GLASS_PANES_BLUE: TagKey = BlockTags.create(ResourceLocation("forge", "hardened_glass_panes/blue")) From a666c8ec2febd91311e5efb2acc83970a6929ff2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 7 Mar 2023 22:48:30 +0700 Subject: [PATCH 0292/1199] put tritanium before diamond --- src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 0b6858f21..5cdc211c0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -146,7 +146,7 @@ object MItems { val TRITANIUM_COMPONENT_NAME = ResourceLocation(OverdriveThatMatters.MOD_ID, "tritanium") init { - TierSortingRegistry.registerTier(TRITANIUM_COMPONENT, TRITANIUM_COMPONENT_NAME, listOf(Tiers.IRON), listOf()) + TierSortingRegistry.registerTier(TRITANIUM_COMPONENT, TRITANIUM_COMPONENT_NAME, listOf(Tiers.IRON), listOf(Tiers.DIAMOND)) } private val TOOLS_PROPRTIES = Item.Properties() From 1315636948b1e5b1f32b8696b45b8d8cb7bb3f3a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 7 Mar 2023 22:50:38 +0700 Subject: [PATCH 0293/1199] how --- .../kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt index f6aa71efe..b05ae629c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt @@ -21,7 +21,7 @@ import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes -class EnergyServoBlock : RotatableMatteryBlock(Properties.of(Material.METAL, MaterialColor.COLOR_BLUE).explosionResistance(12f).destroyTime(2f)), EntityBlock { +class EnergyServoBlock : RotatableMatteryBlock(Properties.of(Material.METAL, MaterialColor.COLOR_BLUE).explosionResistance(12f).destroyTime(2f).requiresCorrectToolForDrops()), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return EnergyServoBlockEntity(p_153215_, p_153216_) } From dd74643c6721f22d8cfebc4bb93c1f3acb121718 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 8 Mar 2023 09:34:06 +0700 Subject: [PATCH 0294/1199] Quick search in pattern grid --- .../mc/otm/datagen/lang/English.kt | 2 + .../mc/otm/datagen/lang/Russian.kt | 2 + .../client/screen/matter/MatterPanelScreen.kt | 45 +++++++++++----- .../screen/panels/input/TextInputPanel.kt | 16 ++++++ .../panels/util/DiscreteScrollBarPanel.kt | 2 +- .../mc/otm/menu/matter/MatterPanelMenu.kt | 52 ++++++++++++++++++- 6 files changed, 104 insertions(+), 15 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index cc2c3c63c..eaf589cda 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -586,6 +586,8 @@ private fun androidFeatures(provider: MatteryLanguageProvider) { private fun gui(provider: MatteryLanguageProvider) { with(provider.english) { + gui("quicksearch", "Quick search...") + gui("item_monitor.refill_source.desc", "Controls from where to take items for slot auto refill") gui("item_monitor.refill_source.system", "System only. Crafting grid will be auto refilled only from storage system. This is the behavior you see in AE2 and Refined Storage") gui("item_monitor.refill_source.inventory", "Inventory only. Crafting grid will be auto refilled only from player's inventory") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index e78534980..cdce390c5 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -594,6 +594,8 @@ private fun androidFeatures(provider: MatteryLanguageProvider) { private fun gui(provider: MatteryLanguageProvider) { with(provider.russian) { + gui("quicksearch", "Быстрый поиск...") + gui("item_monitor.refill_source.desc", "Контролирует источник предметов для заполнения сетки создания") gui("item_monitor.refill_source.system", "Только система. Сетка создания будет заполняться только из системы предметов. Данный параметр соответствует поведению AE2 и Refined Storage") gui("item_monitor.refill_source.inventory", "Только инвентарь. Сетка создания будет заполняться только из инвентаря игрока") 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 eb86c69f5..baabc38e2 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 @@ -32,6 +32,7 @@ import ru.dbotthepony.mc.otm.menu.matter.MatterPanelMenu import ru.dbotthepony.mc.otm.menu.matter.ReplicationRequestPacket import ru.dbotthepony.mc.otm.network.MenuNetworkChannel import yalter.mousetweaks.api.MouseTweaksDisableWheelTweak +import java.util.function.Predicate import kotlin.math.roundToInt @MouseTweaksDisableWheelTweak @@ -45,7 +46,8 @@ class MatterPanelScreen( var scrollPatterns = 0 var scrollTasks = 0 - val frame = FramePanel.padded(this, null, GRID_WIDTH * AbstractSlotPanel.SIZE + ScrollBarConstants.WIDTH + 4f, GRID_HEIGHT * AbstractSlotPanel.SIZE, title) + val frame = FramePanel.padded(this, null, GRID_WIDTH * AbstractSlotPanel.SIZE + ScrollBarConstants.WIDTH + 4f, GRID_HEIGHT * AbstractSlotPanel.SIZE + 2f, title) + frame.dockPadding = frame.dockPadding.copy(top = frame.dockPadding.top + 2f) val controls = DeviceControls(this, frame) @@ -69,9 +71,9 @@ class MatterPanelScreen( val scrollBar = DiscreteScrollBarPanel(this, frame, { if (isPatternView) { - integerDivisionDown(menu.patterns.size, GRID_WIDTH) + integerDivisionDown(menu.patternsFiltered.size, GRID_WIDTH) } else { - integerDivisionDown(menu.tasks.size, GRID_WIDTH) + integerDivisionDown(menu.tasksFiltered.size, GRID_WIDTH) } }, { _, _, new -> if (isPatternView) @@ -80,6 +82,25 @@ class MatterPanelScreen( scrollTasks = new }) + object : TextInputPanel(this@MatterPanelScreen, frame) { + init { + width = frame.width * 0.4f + x = frame.width - width - FramePanel.PADDING + y = 4f + placeholder = TranslatableComponent("otm.gui.quicksearch") + } + + override fun onTextChanged(old: String, new: String) { + if (new == "") { + menu.filter = Predicate { true } + } else { + val new = new.lowercase() + menu.filter = Predicate { it.description.string.lowercase().contains(new) } + scrollBar.scroll = scrollBar.scroll + } + } + } + scrollBar.dock = Dock.RIGHT frame.Tab(onOpen = { isPatternView = true; scrollBar.scroll = scrollPatterns }, activeIcon = PATTERN_LIST_ACTIVE, inactiveIcon = PATTERN_LIST_INACTIVE).also { @@ -121,9 +142,9 @@ class MatterPanelScreen( override val itemStack: ItemStack get() { if (isPatternView) { - return menu.patterns.getOrNull(index)?.stack() ?: ItemStack.EMPTY + return menu.patternsFiltered.getOrNull(index)?.stack() ?: ItemStack.EMPTY } else { - return menu.tasks.getOrNull(index)?.let { it.stack(it.required + it.inProgress) } ?: ItemStack.EMPTY + return menu.tasksFiltered.getOrNull(index)?.let { it.stack(it.required + it.inProgress) } ?: ItemStack.EMPTY } } @@ -131,13 +152,13 @@ class MatterPanelScreen( val list = super.getItemStackTooltip(stack).toMutableList() if (isPatternView) { - menu.patterns.getOrNull(index)?.let { + menu.patternsFiltered.getOrNull(index)?.let { list.add(TranslatableComponent( "otm.item.pattern.research", String.format("%.2f", it.researchPercent * 100.0) ).withStyle(ChatFormatting.AQUA)) } } else { - menu.tasks.getOrNull(index)?.let { + menu.tasksFiltered.getOrNull(index)?.let { list.add(TranslatableComponent("otm.gui.matter_task.total", it.total).withStyle(ChatFormatting.GRAY)) list.add(TranslatableComponent("otm.gui.matter_task.required", it.required).withStyle(ChatFormatting.GRAY)) list.add(TranslatableComponent("otm.gui.matter_task.in_progress", it.inProgress).withStyle(ChatFormatting.GRAY)) @@ -151,9 +172,9 @@ class MatterPanelScreen( override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { if (isPatternView) { if (minecraft?.player?.isSpectator != true) - menu.patterns.getOrNull(index)?.let(this@MatterPanelScreen::openPattern) + menu.patternsFiltered.getOrNull(index)?.let(this@MatterPanelScreen::openPattern) } else { - menu.tasks.getOrNull(index)?.let(this@MatterPanelScreen::openTask) + menu.tasksFiltered.getOrNull(index)?.let(this@MatterPanelScreen::openTask) } return true @@ -180,13 +201,13 @@ class MatterPanelScreen( } override val itemStack: ItemStack get() { - return menu.tasks.firstOrNull { it.id == task.id }?.let { it.stack((it.required + it.inProgress).coerceAtLeast(1)) } ?: task.stack((task.required + task.inProgress).coerceAtLeast(1)) + return menu.tasksFiltered.firstOrNull { it.id == task.id }?.let { it.stack((it.required + it.inProgress).coerceAtLeast(1)) } ?: task.stack((task.required + task.inProgress).coerceAtLeast(1)) } override fun tickInner() { super.tickInner() - if (!menu.tasks.any { it.id == task.id }) { + if (!menu.tasksFiltered.any { it.id == task.id }) { frame.remove() } } @@ -254,7 +275,7 @@ class MatterPanelScreen( override fun tickInner() { super.tickInner() - if (!menu.patterns.any { it.id == pattern.id }) { + if (!menu.patternsFiltered.any { it.id == pattern.id }) { frame.remove() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt index b3f29b3ec..c93619f69 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt @@ -12,6 +12,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectAVLTreeMap import it.unimi.dsi.fastutil.ints.Int2ObjectMap import net.minecraft.client.gui.screens.Screen import net.minecraft.client.renderer.GameRenderer +import net.minecraft.network.chat.Component import org.joml.Vector2i import ru.dbotthepony.mc.otm.client.isCtrlDown import ru.dbotthepony.mc.otm.client.isShiftDown @@ -24,6 +25,7 @@ import ru.dbotthepony.mc.otm.client.render.drawRect import ru.dbotthepony.mc.otm.client.render.tesselator import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.addAll import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.milliTime @@ -141,7 +143,9 @@ open class TextInputPanel( var cursorLine = 0 var cursorRow = 0 + open var placeholder: Component = TextComponent("") open var textColor = RGBAColor.WHITE + open var placeholderColor = RGBAColor.DARK_GRAY open var cursorColor = RGBAColor.GREEN open var backgroundColor = RGBAColor.BLACK open var isActive = true @@ -1085,6 +1089,18 @@ open class TextInputPanel( var y = topPadding + if (lines.isEmpty() || lines.size == 1 && lines[0] == "") { + font.drawAligned( + poseStack = stack, + buffer = BUFFER, + text = placeholder, + align = TextAlign.TOP_LEFT, + x = dockPadding.left, + y = y, + color = placeholderColor + ) + } + for (i in scrollLines until lines.size) { val line = lines[i] val selection = selections[i] diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/DiscreteScrollBarPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/DiscreteScrollBarPanel.kt index 6bd79d6d2..43c06c6aa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/DiscreteScrollBarPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/DiscreteScrollBarPanel.kt @@ -109,7 +109,7 @@ open class DiscreteScrollBarPanel( var scroll = 0 set(value) { - val newValue = value.coerceAtLeast(0).coerceAtMost(maxScroll.invoke(this)) + val newValue = value.coerceIn(0, maxScroll.invoke(this)) if (newValue != field) { val old = field diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt index c9a62439e..e7b237950 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt @@ -4,6 +4,7 @@ import net.minecraft.network.FriendlyByteBuf import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player +import net.minecraft.world.item.Item import net.minecraftforge.network.NetworkEvent import net.minecraftforge.network.PacketDistributor import org.apache.logging.log4j.LogManager @@ -23,6 +24,7 @@ import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.network.* import ru.dbotthepony.mc.otm.registry.MMenus import java.util.* +import java.util.function.Predicate import java.util.function.Supplier import kotlin.Comparator import kotlin.collections.ArrayList @@ -158,7 +160,9 @@ class MatterPanelMenu @JvmOverloads constructor( codec = ItemSorter::class.codec(), observer = { patterns.sortWith(actualComparator) + patternsFiltered.sortWith(actualComparator) tasks.sortWith(actualTaskComparator) + tasksFiltered.sortWith(actualTaskComparator) }) val isAscending: Boolean by mSynchronizer.ComputedField( @@ -166,7 +170,9 @@ class MatterPanelMenu @JvmOverloads constructor( codec = BooleanValueCodec, observer = { patterns.sortWith(actualComparator) + patternsFiltered.sortWith(actualComparator) tasks.sortWith(actualTaskComparator) + tasksFiltered.sortWith(actualTaskComparator) }) val totalMatterStored: Decimal by mSynchronizer.ComputedField( @@ -174,6 +180,25 @@ class MatterPanelMenu @JvmOverloads constructor( codec = DecimalValueCodec, ) + var filter: Predicate = Predicate { true } + set(value) { + field = value + patternsFiltered.clear() + tasksFiltered.clear() + + for (pattern in patterns) { + if (value.test(pattern.item)) { + patternsFiltered.add(pattern) + } + } + + for (task in tasks) { + if (value.test(task.item)) { + tasksFiltered.add(task) + } + } + } + val changeIsAscending = booleanInput(allowSpectators = true) { tile?.getPlayerSettings(ply)?.ascending = it } val changeSorting = PlayerInput(ItemSorter::class.codec(), allowSpectators = true) { tile?.getPlayerSettings(ply)?.sorter = it } @@ -183,8 +208,11 @@ class MatterPanelMenu @JvmOverloads constructor( private val actualComparator = Comparator { o1, o2 -> sorting.comparator.compare(o1.item, o2.item) * (if (isAscending) 1 else -1) } private val actualTaskComparator = Comparator> { o1, o2 -> sorting.comparator.compare(o1.item, o2.item) * (if (isAscending) 1 else -1) } - val patterns = ArrayList() - val tasks = ArrayList>() + private val patterns = ArrayList() + private val tasks = ArrayList>() + + val patternsFiltered = ArrayList() + val tasksFiltered = ArrayList>() fun networkPatternsUpdated(patterns: Collection) { for (pattern in patterns) { @@ -195,6 +223,16 @@ class MatterPanelMenu @JvmOverloads constructor( } else { this.patterns.addSorted(pattern, actualComparator) } + + if (filter.test(pattern.item)) { + val index = this.patternsFiltered.indexOfFirst(pattern::matchId) + + if (index != -1) { + this.patternsFiltered[index] = pattern + } else { + this.patternsFiltered.addSorted(pattern, actualComparator) + } + } } } @@ -213,6 +251,16 @@ class MatterPanelMenu @JvmOverloads constructor( } else { this.tasks.addSorted(task, actualTaskComparator) } + + if (filter.test(task.item)) { + val index = this.tasksFiltered.indexOfFirst(task::matchId) + + if (index != -1) { + this.tasksFiltered[index] = task + } else { + this.tasksFiltered.addSorted(task, actualTaskComparator) + } + } } } From fc0bc694886c71371be9649cfa4b0ec3549e678b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 8 Mar 2023 15:08:10 +0700 Subject: [PATCH 0295/1199] more focus fixes --- .../mc/otm/client/screen/MatteryScreen.kt | 11 +++-------- .../otm/client/screen/panels/EditablePanel.kt | 19 +++++++++++-------- 2 files changed, 14 insertions(+), 16 deletions(-) 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 be943534f..87c764b67 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 @@ -300,17 +300,12 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit * * @param panel panel to be pushed up */ - fun popup(panel: EditablePanel>) { + fun popup(panel: EditablePanel>): Boolean { val indexOf = panels.indexOf(panel) - - require(indexOf != -1) { "No such panel $panel" } - - if (indexOf == 0) { - return - } - + if (indexOf <= 0) return false panels.removeAt(indexOf) panels.addFirst(panel) + return true } /** 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 ff5518306..189e3d6e9 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 @@ -1185,6 +1185,10 @@ open class EditablePanel @JvmOverloads constructor( var parent: EditablePanel<*>? = this while (parent != null) { + if (parent.parent == null) { + parent.popup(false) + } + for (child in parent.childrenInternal) { if (child !== filter) { child.killFocus() @@ -1193,8 +1197,11 @@ open class EditablePanel @JvmOverloads constructor( filter = parent parent = parent.parent - parent?.killFocusThis(false) - parent?.hasFocusedChildren = true + + if (parent != null) { + parent.killFocusThis(false) + parent.hasFocusedChildren = true + } } isFocusedThis = true @@ -1328,12 +1335,8 @@ open class EditablePanel @JvmOverloads constructor( } } - if (mouseClickedInner(x, y, button)) { - if (autoRequestFocus) requestFocus() - return true - } - - return false + if (autoRequestFocus) requestFocus() + return mouseClickedInner(x, y, button) } fun mouseClickedChecked(x: Double, y: Double, button: Int): Boolean { From c4b36d497f534f4d1262c187133b13d54c6441ba Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 8 Mar 2023 16:59:27 +0700 Subject: [PATCH 0296/1199] Polishing fixes to TextInputPanel --- .../screen/panels/input/TextInputPanel.kt | 35 +++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt index c93619f69..d6d118db5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt @@ -881,6 +881,11 @@ open class TextInputPanel( selections[i] = TextSelection(0, line.length + 1) } + if (lines.isNotEmpty()) { + cursorLine = lines.size - 1 + cursorRow = lines[lines.size - 1].length + } + return true } @@ -889,30 +894,43 @@ open class TextInputPanel( pushbackSnapshot() if (multiLine) { - val insert = minecraft.keyboardHandler.clipboard.replace("\t", " ").split(NEWLINES) - + val insert = minecraft.keyboardHandler.clipboard.replace("\t", " ").split(NEWLINES).toMutableList() + val actualLastSize = insert.lastOrNull()?.length ?: 0 val line = this[cursorLine] if (line == null) { insertLine(cursorLine, insert[0]) + cursorRow = insert[0].length } else if (line.isEmpty()) { this[cursorLine] = insert[0] + cursorRow = insert[0].length } else { - this[cursorLine] = line.substring(0, cursorRow.coerceAtMost(line.length - 1)) + insert[0] + line.substring(cursorRow.coerceAtMost(line.length)) + if (insert.size == 1) { + this[cursorLine] = line.substring(0, cursorRow.coerceAtMost(line.length - 1)) + insert[0] + line.substring(cursorRow.coerceAtMost(line.length)) + } else { + this[cursorLine] = line.substring(0, cursorRow.coerceAtMost(line.length - 1)) + insert[0] + insert[insert.size - 1] += line.substring(cursorRow.coerceAtMost(line.length)) + } + + cursorRow += insert[0].length } for (i in 1 until insert.size - 1) { insertLine(++cursorLine, insert[i]) + cursorRow = insert[i].length } - if (insert.size >= 3) { + if (insert.size >= 2) { val line2 = this[++cursorLine] + val last = insert.last() if (line2 == null) { - insertLine(cursorLine, insert.last()) + insertLine(cursorLine, last) } else { - this[cursorLine] = insert.last() + line2 + this[cursorLine] = last + line2 } + + cursorRow = actualLastSize } } else { val insert = minecraft.keyboardHandler.clipboard.replace("\t", " ").replace(NEWLINES, "") @@ -920,10 +938,13 @@ open class TextInputPanel( if (line == null) { insertLine(cursorLine, insert) + cursorRow = insert.length } else if (line.isEmpty()) { this[cursorLine] = insert + cursorRow = insert.length } else { this[cursorLine] = line.substring(0, cursorRow.coerceAtMost(line.length - 1)) + insert + line.substring(cursorRow.coerceAtMost(line.length)) + cursorRow += insert.length } } @@ -1082,6 +1103,8 @@ open class TextInputPanel( } else if (w >= width - dockPadding.right) { scrollPixels += 30f } + } else { + scrollPixels = 0f } stack.pushPose() From b37df1c347a653b9c991ba1b89da7ce6dfa17152 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 8 Mar 2023 17:05:40 +0700 Subject: [PATCH 0297/1199] Opening pattern or task frames now block inputs to main panel --- .../client/screen/matter/MatterPanelScreen.kt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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 baabc38e2..b0d37957b 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 @@ -172,9 +172,13 @@ class MatterPanelScreen( override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { if (isPatternView) { if (minecraft?.player?.isSpectator != true) - menu.patternsFiltered.getOrNull(index)?.let(this@MatterPanelScreen::openPattern) + menu.patternsFiltered.getOrNull(index)?.let(this@MatterPanelScreen::openPattern)?.let { + frame.blockingWindow = it + } } else { - menu.tasksFiltered.getOrNull(index)?.let(this@MatterPanelScreen::openTask) + menu.tasksFiltered.getOrNull(index)?.let(this@MatterPanelScreen::openTask)?.let { + frame.blockingWindow = it + } } return true @@ -190,7 +194,7 @@ class MatterPanelScreen( return frame } - private fun openTask(task: IReplicationTask<*>) { + private fun openTask(task: IReplicationTask<*>): FramePanel { val frame = FramePanel.padded(this, null, 170f, 20f, TranslatableComponent("otm.gui.matter_panel.task")) frame.closeOnEscape = true @@ -232,9 +236,11 @@ class MatterPanelScreen( popup(frame) frame.toScreenCenter() + + return frame } - private fun openPattern(pattern: IPatternState) { + private fun openPattern(pattern: IPatternState): FramePanel { val frame = FramePanel.padded(this, null, 213f, (ButtonPanel.HEIGHT + 3f) * 4f + 38f, TranslatableComponent("otm.gui.matter_panel.task")) frame.closeOnEscape = true @@ -418,6 +424,8 @@ class MatterPanelScreen( } frame.toScreenCenter() + + return frame } companion object { From 33aadb2487fecb4e6c7d1da0ccf428248df77117 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 8 Mar 2023 17:11:31 +0700 Subject: [PATCH 0298/1199] Fix window flashing being eternal --- .../otm/client/screen/panels/EditablePanel.kt | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) 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 189e3d6e9..abb29655d 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 @@ -334,22 +334,29 @@ open class EditablePanel @JvmOverloads constructor( private set var isFlashing: Boolean - get() = (flashingSince?.seconds ?: Long.MAX_VALUE) <= 1 + get() { + if (flashingSince == null) { + return false + } + + if (flashingSince!!.millis >= 1200L) { + flashingSince = null + return false + } + + return true + } set(value) { if (value) { flashingSince = SystemTime() + popup() } else { flashingSince = null } } - fun flash() { - isFlashing = true - popup() - } - val isFlashFrame: Boolean - get() = flashingSince != null && flashingSince!!.millis % 400L <= 200L + get() = isFlashing && flashingSince!!.millis % 400L <= 200L val isFlashFrameRecursive: Boolean get() { @@ -375,7 +382,7 @@ open class EditablePanel @JvmOverloads constructor( if (blockingWindow != null) { if (doFlash) { - blockingWindow.flash() + blockingWindow.isFlashing = true } return true @@ -404,7 +411,7 @@ open class EditablePanel @JvmOverloads constructor( } if (doFlash) { - blockingWindow.flash() + blockingWindow.isFlashing = true } return true @@ -1566,6 +1573,8 @@ open class EditablePanel @JvmOverloads constructor( for (child in Array(visibleChildrenInternal.size) { visibleChildrenInternal[it] }) { child.tick() } + + } var isRemoved = false From f403ce90514194bbf3e61826dcca06ceda7df106 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 8 Mar 2023 19:59:58 +0700 Subject: [PATCH 0299/1199] Remove query panel when pressing escape --- .../otm/client/screen/panels/input/QueryUserPanel.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/QueryUserPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/QueryUserPanel.kt index 78e634dec..4b7a8ec99 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/QueryUserPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/QueryUserPanel.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.client.screen.panels.input +import com.mojang.blaze3d.platform.InputConstants import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.client.screen.MatteryScreen @@ -63,4 +64,14 @@ open class QueryUserPanel( toScreenCenter() } + + override fun keyPressedInternal(key: Int, scancode: Int, mods: Int): Boolean { + if (key == InputConstants.KEY_ESCAPE) { + onCancel?.run() + remove() + return true + } + + return super.keyPressedInternal(key, scancode, mods) + } } From cd958254604bfd0a3ef1f812c13ec8035913a5eb Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Thu, 9 Mar 2023 08:44:18 +0300 Subject: [PATCH 0300/1199] =?UTF-8?q?=D0=BF=D0=BE=D1=87=D0=B5=D0=BC=D1=83-?= =?UTF-8?q?=D1=82=D0=BE=20=D0=BD=D0=B5=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/item/tritanium_shield.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/models/item/tritanium_shield.json b/src/main/resources/assets/overdrive_that_matters/models/item/tritanium_shield.json index 2a49c326d..5789c6bf2 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/item/tritanium_shield.json +++ b/src/main/resources/assets/overdrive_that_matters/models/item/tritanium_shield.json @@ -137,11 +137,11 @@ } }, "overrides": [ - { - "predicate": { - "blocking": 1 - }, - "model": "overdrive_that_matters:item/tritanium_shield_blocking" - } - ] + { + "predicate": { + "overdrive_that_matters:blocking": 1 + }, + "model": "overdrive_that_matters:item/tritanium_shield_blocking" + } + ] } \ No newline at end of file From 3c66f2a9d808fcee52f7f6b19a006ad777e8d583 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 9 Mar 2023 15:28:34 +0700 Subject: [PATCH 0301/1199] Add missing prismarine shard matter value --- src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt index 6312d20f2..2b070eb1a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt @@ -209,6 +209,7 @@ fun addMatterData(provider: MatterDataProvider) { relative(Items.HONEY_BLOCK, 6, 1.75) relative(Tags.Items.GEMS_PRISMARINE, 6, 2.75) + relative(Items.PRISMARINE_SHARD, 6, 2.75) relative(Tags.Items.RODS_BLAZE, 1.4, 2) relative(Items.GHAST_TEAR, 2.5, 2.5) From 4810894d72c955221233b2fa2bd7a95d66397f14 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 9 Mar 2023 15:32:13 +0700 Subject: [PATCH 0302/1199] fix no_exosuit to no_exopack --- .../dbotthepony/mc/otm/item/AbstractExoPackSlotUpgradeItem.kt | 2 +- .../ru/dbotthepony/mc/otm/item/ExoPackCraftingUpgradeItem.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/AbstractExoPackSlotUpgradeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/AbstractExoPackSlotUpgradeItem.kt index 37f7b0d12..2fc022a71 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/AbstractExoPackSlotUpgradeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/AbstractExoPackSlotUpgradeItem.kt @@ -43,7 +43,7 @@ abstract class AbstractExoPackSlotUpgradeItem(properties: Properties = defaultPr } if (!alreadyHasExosuit) { - tooltip.add(TranslatableComponent("otm.gui.exopack_upgrades.no_exosuit").withStyle(ChatFormatting.GRAY)) + tooltip.add(TranslatableComponent("otm.gui.exopack_upgrades.no_exopack").withStyle(ChatFormatting.GRAY)) if (runIfClient(false) { minecraft.player?.isCreative != true }) { return diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ExoPackCraftingUpgradeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ExoPackCraftingUpgradeItem.kt index cac3c7778..b753f7291 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ExoPackCraftingUpgradeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ExoPackCraftingUpgradeItem.kt @@ -28,7 +28,7 @@ class ExoPackCraftingUpgradeItem : Item(Properties().stacksTo(1).rarity(Rarity.R } if (!alreadyHasExosuit) { - tooltip.add(TranslatableComponent("otm.gui.exopack_upgrades.no_exosuit").withStyle(ChatFormatting.GRAY)) + tooltip.add(TranslatableComponent("otm.gui.exopack_upgrades.no_exopack").withStyle(ChatFormatting.GRAY)) if (runIfClient(false) { minecraft.player?.isCreative != true }) { return From 194aca51ea6f7a0f4119d24dff99a21ef2b7db1e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 9 Mar 2023 16:51:30 +0700 Subject: [PATCH 0303/1199] Add matter value and complexity sorters --- .../mc/otm/datagen/lang/English.kt | 2 ++ .../mc/otm/datagen/lang/Russian.kt | 2 ++ .../mc/otm/core/util/ItemSorter.kt | 24 ++++++++++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index eaf589cda..7c4275819 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -633,6 +633,8 @@ private fun gui(provider: MatteryLanguageProvider) { gui("sorting.count", "Sort by amount") gui("sorting.ascending", "Ascending") gui("sorting.descending", "Descending") + gui("sorting.matter_value", "Matter value") + gui("sorting.matter_complexity", "Replication complexity") gui("matter_panel.increase_by", "+%s") gui("matter_panel.decrease_by", "-%s") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index cdce390c5..6054bcecf 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -641,6 +641,8 @@ private fun gui(provider: MatteryLanguageProvider) { gui("sorting.count", "Сортировка по количеству") gui("sorting.ascending", "Возрастающая") gui("sorting.descending", "Убывающая") + gui("sorting.matter_value", "Значение материи") + gui("sorting.matter_complexity", "Сложность репликации") gui("matter_panel.send", "Запросить") gui("matter_panel.close", "Закрыть") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt index 76a467de8..fe6c1b229 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt @@ -9,6 +9,7 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.nullsFirst import ru.dbotthepony.mc.otm.core.nullsLast import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.matter.MatterManager object CreativeMenuComparator : Comparator { override fun compare(o1: Item, o2: Item): Int { @@ -42,6 +43,24 @@ object CreativeMenuComparator : Comparator { val NullsLast = nullsLast() } +object MatterValueComparator : Comparator { + override fun compare(o1: Item, o2: Item): Int { + return MatterManager.get(o1).matter.compareTo(MatterManager.get(o2).matter) + } + + val NullsFirst = nullsFirst() + val NullsLast = nullsLast() +} + +object MatterComplexityComparator : Comparator { + override fun compare(o1: Item, o2: Item): Int { + return MatterManager.get(o1).complexity.compareTo(MatterManager.get(o2).complexity) + } + + val NullsFirst = nullsFirst() + val NullsLast = nullsLast() +} + object ItemLocalizedNameComparator : Comparator { override fun compare(o1: Item, o2: Item): Int { return o1.description.string.compareTo(o2.description.string) @@ -77,7 +96,10 @@ enum class ItemSorter(val comparator: Comparator, private val sTitle: Com DEFAULT(CreativeMenuComparator.NullsFirst, TranslatableComponent("otm.gui.sorting.default")), NAME(ItemLocalizedNameComparator.NullsFirst.thenComparing(CreativeMenuComparator.NullsFirst), TranslatableComponent("otm.gui.sorting.name")), ID(ItemIDComparator.NullsFirst.thenComparing(CreativeMenuComparator.NullsFirst), TranslatableComponent("otm.gui.sorting.id")), - MOD(ItemModComparator.NullsFirst.thenComparing(CreativeMenuComparator.NullsFirst), TranslatableComponent("otm.gui.sorting.modid")); + MOD(ItemModComparator.NullsFirst.thenComparing(CreativeMenuComparator.NullsFirst), TranslatableComponent("otm.gui.sorting.modid")), + MATTER_VALUE(MatterValueComparator.NullsFirst.thenComparing(MatterComplexityComparator.NullsFirst).thenComparing(CreativeMenuComparator.NullsFirst), TranslatableComponent("otm.gui.sorting.matter_value")), + MATTER_COMPLEXITY(MatterComplexityComparator.NullsFirst.thenComparing(MatterValueComparator.NullsFirst).thenComparing(CreativeMenuComparator.NullsFirst), TranslatableComponent("otm.gui.sorting.matter_complexity")), + ; val title: Component get() = sTitle.copy() } From 4dfb4c52344cda33037b47fa2e8539c83e538f8f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 9 Mar 2023 21:02:32 +0700 Subject: [PATCH 0304/1199] Lenient matter value calculation --- build.gradle.kts | 12 +- .../mc/otm/matter/MatterManager.kt | 103 ++++++++++++++++-- 2 files changed, 101 insertions(+), 14 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index dfcea109e..361d035c9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -201,12 +201,12 @@ dependencies { compileOnly(fg.deobf("mekanism:Mekanism:${deps_mc_version}-${mekanism_version}:all")) - runtimeOnly(fg.deobf("curse.maven:cyclops-core-232758:4392602")) - runtimeOnly(fg.deobf("curse.maven:integrated-dynamics-236307:4391535")) - runtimeOnly(fg.deobf("curse.maven:integrated-crafting-287357:4391487")) - runtimeOnly(fg.deobf("curse.maven:integrated-terminals-295910:4400924")) - runtimeOnly(fg.deobf("curse.maven:common-capabilities-247007:4391468")) - runtimeOnly(fg.deobf("curse.maven:integrated-tunnels-251389:4344632")) + // runtimeOnly(fg.deobf("curse.maven:cyclops-core-232758:4392602")) + // runtimeOnly(fg.deobf("curse.maven:integrated-dynamics-236307:4391535")) + // runtimeOnly(fg.deobf("curse.maven:integrated-crafting-287357:4391487")) + // runtimeOnly(fg.deobf("curse.maven:integrated-terminals-295910:4400924")) + // runtimeOnly(fg.deobf("curse.maven:common-capabilities-247007:4391468")) + // runtimeOnly(fg.deobf("curse.maven:integrated-tunnels-251389:4344632")) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index c9839c011..3c93b2f80 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -14,6 +14,7 @@ import it.unimi.dsi.fastutil.io.FastByteArrayInputStream import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream import it.unimi.dsi.fastutil.objects.Object2BooleanFunction import it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap +import it.unimi.dsi.fastutil.objects.Object2IntArrayMap import it.unimi.dsi.fastutil.objects.Reference2BooleanFunction import it.unimi.dsi.fastutil.objects.Reference2BooleanOpenHashMap import it.unimi.dsi.fastutil.objects.Reference2ObjectFunction @@ -88,6 +89,7 @@ import ru.dbotthepony.mc.otm.milliTime import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.RegistryNetworkChannel import ru.dbotthepony.mc.otm.registry.RegistryDelegate +import ru.dbotthepony.mc.otm.secondTime import ru.dbotthepony.mc.otm.storage.ItemStackWrapper import java.io.DataInputStream import java.io.DataOutputStream @@ -105,6 +107,7 @@ import kotlin.collections.ArrayDeque import kotlin.collections.ArrayList import kotlin.collections.HashMap import kotlin.collections.LinkedHashMap +import kotlin.jvm.optionals.getOrNull import kotlin.math.pow import kotlin.math.roundToInt @@ -596,6 +599,8 @@ object MatterManager { private val seenItems = ArrayDeque() private var changes = false + private var iteration = 0 + private var lenientStage = false private var cachedIterationResults = Reference2ObjectOpenHashMap() private fun doTryToBacktrack(item: Item, makeCommentary: Boolean): Result { @@ -708,6 +713,8 @@ object MatterManager { inputsLoop@ for ((i, inputs) in recipe.inputs.withIndex()) { var minimal: IMatterValue? = null var minimalMultiplier = 0.0 + val skips = ArrayList() + val recursiveSkips = ArrayList() innerInputsLoop@ for (input in inputs) { val ivalue = determineValue(input.item) @@ -715,13 +722,19 @@ object MatterManager { if (ivalue.isMissing) { comment(item, TextComponent("Input '${input.item.registryName}' at input slot $i in ${recipe.formattedName} has no matter value")) - if (recipe.isCritical) { + if (recipe.isCritical && !lenientStage) { return Result.MISSING } else { - continue@recipesLoop + if (recipe.isCritical) { + skips.add(input) + continue@innerInputsLoop + } else { + continue@recipesLoop + } } } else if (ivalue.isSkipped) { comment(item, TextComponent("Input '${input.item.registryName}' at input slot $i in ${recipe.formattedName} is recursive")) + recursiveSkips.add(input) if (inputs.size == 1) { hadSkips = true @@ -737,6 +750,53 @@ object MatterManager { } } + if (skips.size > inputs.size / 2 || skips.isNotEmpty() && inputs.size == 1) { + comment(item, TextComponent("More than half inputs (${skips.joinToString(", ") { it.item.registryName.toString() }}) at input slot $i in ${recipe.formattedName} have no matter values")) + return Result.MISSING + } else if (skips.isNotEmpty()) { + /** + * Эвристический анализ тегов + * + * Если у 60% <= предметов со значением материи есть тег, и он есть у всех + * предметов без значения материи, то предметы без материи игнорируются + */ + val manager = ForgeRegistries.ITEMS.tags()!! + val tagSetsPresent = Object2IntArrayMap>() + val tagSetsMissing = Object2IntArrayMap>() + + for (input in inputs) { + if (input in recursiveSkips) { + continue + } + + val list = manager.getReverseTag(input.item).getOrNull()?.tagKeys?.collect(ImmutableList.toImmutableList()) ?: ImmutableList.of() + + if (input !in skips) { + for (tag in list) + tagSetsPresent.computeInt(tag) { _, e -> (e ?: 0) + 1 } + } else { + for (tag in list) + tagSetsMissing.computeInt(tag) { _, e -> (e ?: 0) + 1 } + } + } + + val filtered = tagSetsPresent.object2IntEntrySet() + .filter { it.intValue.toDouble() >= (inputs.size - skips.size - recursiveSkips.size) * 0.6 } + + val result = filtered.all { tagSetsMissing.getInt(it.key) == skips.size } + + if (!result) { + comment(item, TextComponent("More than half inputs (${skips.joinToString(", ") { it.item.registryName.toString() }}) at input slot $i in ${recipe.formattedName} have no matter values")) + return Result.MISSING + } else { + comment(item, TextComponent("${recipe.formattedName} with inputs at slot $i without matter values were allowed to be skipped due to next tags:")) + + for (tag in filtered) { + comment(item, TextComponent(tag.key.location.toString())) + } + } + } + if (minimal == null || !minimal.hasMatterValue) { comment(item, TextComponent("'${recipe.formattedName}' has invalid input at slot $i (possible inputs: ${inputs.joinToString(", ", transform = { it.item.registryName.toString() }) }) (???)")) return Result.MISSING @@ -907,6 +967,26 @@ object MatterManager { time = SystemTime() + lenientStage = false + + while (changes) { + ops += cachedIterationResults.size + cachedIterationResults = Reference2ObjectOpenHashMap() + changes = false + iteration++ + + val iterator = toDetermine.iterator() + + for (value in iterator) { + if (determineValue(value).value?.hasMatterValue == true) { + iterator.remove() + } + } + } + + lenientStage = true + changes = true + while (changes) { ops += cachedIterationResults.size cachedIterationResults = Reference2ObjectOpenHashMap() @@ -936,8 +1016,6 @@ object MatterManager { } } - var iteration = 0 - internal fun compute(value: Item): Result { return Resolver.determineValue(value) } @@ -1132,11 +1210,20 @@ object MatterManager { if (commentary != null) { if (commentary.size > 3) { - event.toolTip.add(TextComponent("...").withStyle(ChatFormatting.DARK_GRAY)) - } + var index = ((secondTime / 3L) % commentary.size).toInt() - for (i in (commentary.size - 3).coerceAtLeast(0) until commentary.size) { - event.toolTip.add(commentary[i].withStyle(ChatFormatting.DARK_GRAY)) + for (i in 0 .. 2) { + if (index == commentary.size) { + event.toolTip.add(TextComponent("=========").withStyle(ChatFormatting.DARK_GRAY)) + index = 0 + } + + event.toolTip.add(commentary[index++].withStyle(ChatFormatting.DARK_GRAY)) + } + } else { + for (comment in commentary) { + event.toolTip.add(comment.withStyle(ChatFormatting.DARK_GRAY)) + } } } } From 7e914f010ef9e652a8ad671adba84355d17c6498 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Fri, 10 Mar 2023 00:32:47 +0600 Subject: [PATCH 0305/1199] Make shields normal --- .../mc/otm/datagen/blocks/BlockStates.kt | 1 + .../mc/otm/datagen/items/ItemModels.kt | 1 + .../models/block/cobblestone_generator.json | 84 ++++++++++++++++++ .../item/tritanium_shield_blocking.json | 14 +-- .../textures/block/cobblestone_generator.png | Bin 0 -> 1104 bytes .../item/component/tritanium_nugget.png | Bin 2437 -> 224 bytes 6 files changed, 93 insertions(+), 7 deletions(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/cobblestone_generator.json create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator.png diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt index 1d7daaded..3182f3a45 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt @@ -87,6 +87,7 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { provider.block(MBlocks.STORAGE_POWER_SUPPLIER) provider.block(MBlocks.MATTER_RECYCLER) provider.block(MBlocks.ENERGY_SERVO) + provider.block(MBlocks.COBBLESTONE_GENERATOR) provider.exec { for (crate in MRegistry.CARGO_CRATES.allBlocks.values) { diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index ead8fb642..c2773104a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -122,6 +122,7 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.block(MItems.PLATE_PRESS, "plate_press_idle") provider.block(MItems.STORAGE_POWER_SUPPLIER, "storage_power_supplier") provider.block(MItems.MATTER_RECYCLER, "matter_recycler_working") + provider.block(MItems.COBBLESTONE_GENERATOR, "cobblestone_generator") provider.block(MItems.STORAGE_BUS) provider.block(MItems.STORAGE_IMPORTER) diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/cobblestone_generator.json b/src/main/resources/assets/overdrive_that_matters/models/block/cobblestone_generator.json new file mode 100644 index 000000000..2f06eb12d --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/cobblestone_generator.json @@ -0,0 +1,84 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [32, 64], + "textures": { + "0": "overdrive_that_matters:block/cobblestone_generator", + "particle": "overdrive_that_matters:block/cobblestone_generator" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 6, 16], + "faces": { + "north": {"uv": [8, 0, 16, 1.5], "texture": "#0"}, + "east": {"uv": [8, 0, 16, 1.5], "texture": "#0"}, + "south": {"uv": [8, 0, 16, 1.5], "texture": "#0"}, + "west": {"uv": [8, 0, 16, 1.5], "texture": "#0"}, + "up": {"uv": [0, 10, 8, 14], "texture": "#0"}, + "down": {"uv": [0, 0, 8, 4], "texture": "#0"} + } + }, + { + "from": [4, 6, 0], + "to": [12, 16, 16], + "faces": { + "north": {"uv": [12, 4, 16, 6.5], "texture": "#0"}, + "east": {"uv": [8, 1.5, 16, 4], "texture": "#0"}, + "south": {"uv": [12, 8.5, 16, 11], "texture": "#0"}, + "west": {"uv": [8, 1.5, 16, 4], "texture": "#0"}, + "up": {"uv": [8.5, 6.5, 16, 8.5], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [1, 6, 1], + "to": [4, 15, 15], + "faces": { + "north": {"uv": [8.5, 7, 7, 9.25], "texture": "#0"}, + "south": {"uv": [7, 7, 8.5, 9.25], "texture": "#0"}, + "west": {"uv": [0, 7, 7, 9.25], "texture": "#0"}, + "up": {"uv": [0, 9.25, 7, 10], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [12, 6, 1], + "to": [15, 15, 15], + "faces": { + "north": {"uv": [7, 4, 8.5, 6.25], "texture": "#0"}, + "east": {"uv": [0, 4, 7, 6.25], "texture": "#0"}, + "south": {"uv": [8.5, 4, 7, 6.25], "texture": "#0"}, + "up": {"uv": [0, 6.25, 7, 7], "rotation": 90, "texture": "#0"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 225, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "scale": [0.5, 0.5, 0.5] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/item/tritanium_shield_blocking.json b/src/main/resources/assets/overdrive_that_matters/models/item/tritanium_shield_blocking.json index ee8421417..22d720b39 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/item/tritanium_shield_blocking.json +++ b/src/main/resources/assets/overdrive_that_matters/models/item/tritanium_shield_blocking.json @@ -105,20 +105,20 @@ ], "display": { "thirdperson_righthand": { - "rotation": [90, 39, -40], + "rotation": [120, 0, -45], "translation": [1, -2, 0] }, "thirdperson_lefthand": { - "rotation": [90, 0, 180], - "translation": [0, -2, 4] + "rotation": [120, 0, 135], + "translation": [1, -2, 0] }, "firstperson_righthand": { - "rotation": [90, -5, -90], - "translation": [-1.75, -7, 4] + "rotation": [82, 6, -90], + "translation": [-1.5, -4.75, 4.75] }, "firstperson_lefthand": { - "rotation": [90, -5, 90], - "translation": [-1.75, -7, 4] + "rotation": [82, 6, 90], + "translation": [-1.75, -4.75, 4] }, "ground": { "rotation": [90, 0, 0], diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator.png new file mode 100644 index 0000000000000000000000000000000000000000..d1c82ec86ab9b99853eec50a33dbeefcc652268c GIT binary patch literal 1104 zcmeAS@N?(olHy`uVBq!ia0vp^3P9|@!3-pQ0$S$)DaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(ehKlmmQ1Tun_)wY9ay#KhFp)Y2+ja+~`9|Nmc9R8(JI-`?IH5)zV-kYF6V z-Xv^`Mf5?J{Fhbas@zN!yO}2TVv+5u zm5!GJd9TF?UJmBH9Kv^}Q1(%~_Vsw->#;%)+jZ_$Dc#DHc-*IdGez`vuJp4RX0KK` z-z}Cq>%?(8N9yHLhlj127reM`=Sp3T6u1(~cfUsE-7dek+k752s-Jb?yy(My(vt07 zh2pd6rsqAlE(h^mPY^z7!FIxo^@11o+pS)&*Sfr1=J0f?$?NrQ7k#-;S+gBCVLffj ze#VjGdYsUwv(b;*wVuzmIOoQBJ6rNnAkVEV$wwVJ4_h>^MhKku;<{TZeP!%DzPNUFBlj&GzARn8uAT+mT?w%L>4nJ@ErnSMo|r~1_lNuPfr)e5D)LC zQ>()-I|v+2-?VaVtl8ETf-J!<7lTBn1l4FO?Q>wfpMU%Pf6YC+tvwI7$(;-Q|GE5D z$>p8a)#+ukg$kE&DJ{DZwEC#2eMhHe(3u|!X`+JjITmOfGHEP)tTs&{^*Q&6g|EII z^YmuEBK_5BrP7-K-vzUyZu3`jvh+mH5DUI0tjSp!k@?{HE}31E9KDY+u?T&NVD!?o zaJmrk^qA(1DH8;^R>`fBY;p@_DKHXyuuSR0?57)h9Yt3hb~S8Jxbx0yW|Z-**3df) z(XTORw@>;3(4^S*!e z{!hmIDsjrc6(&wf{_QgH#}6Bm_QMO0B=a0+YW$Mu82o6du&JklkI0jjrl5uM>L(-y z&9pqOFPQS9`rt;ne@pm(yq{2!vpsH~{)zb(!awy{7GKQYEo~fndW*z6U`k`~boFyt I=akR{0I=K?MF0Q* literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/component/tritanium_nugget.png b/src/main/resources/assets/overdrive_that_matters/textures/item/component/tritanium_nugget.png index d36635b4d3d72a5dd2644f4bd55341d6da866d5b..477a509933873bb793c436ad52653d9f6194b16b 100644 GIT binary patch delta 202 zcmZn_e!!^M8Q|y6%O%Cdz`(%k>ERLtqy<2jgBeI_=<)|oR8**!2=EDUjfl^P&97>l zwPNn>GnO_EezEDfP5nScJ@I_&fD}hbkYDhB2w=F^yf+dk##!JIS^M7Zw^N&9NA*$7}|A%QFZAQ omUjwy*M9%m7zZJjkY>wb;}+i^bu_gMVX#MEe?A$v*Na(MM4QcKvNOrc zVt#pbv5sJ!F;>@gp66QYx>Ssko*|F+b~vfvjo)&zJV}yR)rwHAdF9Y#e=9J0gTAr@ zH)yX@#d@8fNU|s29e2Vu&SY6CxO_G}Rf^zIO2Kvf#!Z}3-{SXPyt}%bQ%d|+3tK9s zYfUNTRB)S1-?d!FF7bjJhzy=F&-0SJ==AzOJUbZwv<+sO=GpoAcxSKM>Bn&l zC_erC;cPZ1gx0$84G&PlV@rMa_I{q1Cl}|sCWdKHgjrXDQ&}Uie3t^a!=ZQk=qH}rKEJqtoB#aRCyR9gJbL}!<@Ex{ zfJIF<2x$kw>Dk%r8krNSX0~YpAIq_eB9Ee!(Ha2NH3M#oWyB3*dUE>Z*Z*O+j_%B6 zvvANd4C~qSY#m3VfAJW=7eyfi(m-&EGQ~w*sA>^s8Q2OBYrvyxN|wuYr9e?&ML97l zt*TO`X?%SAG)gvUq4@89^NwTtzyK)y+8Bo;<(=%B7aGmAs;pFk_@iEC*WyFp>51W&NQzpQa7f- zku1yb1;hhne`#5moG{<_vHHzdU-_QdYdN9glz^!yuU9GRF3sZg^}>?+&i=sl`FuVb zj|K-j+oH&1oj4K>Da$krA@RX}R8?Koy3|Mts??H+6e$pM9!x)eb_(b#31_ zObem}Xi)-E8ohSwjn`hN^JJ?(^aAhU7hkkOKlJ_Wf9*kDD#vsb3c9M0cHoKX!A+7= z+>27-AH08m`u(>p*B*r7{A&K>*=a`PaS4+Y;QhaN7>)l^I@H{iiV-(%;Vh)tumYZe;vYD4O z&lFU*$dWA2fNG~5T2ymgwnGnb@PmPbGnUEHe=IjmHl1C>Inh)>04}c9wJL}G&Rh52 z0A~zSY*uT_u)LO^7WsUgetUX3y;@x@mYkC;-!NtxASWk-w&y`wYvrLi_`WL*PHG+m zodObJImgqJ>GkHv`3AL3h1lKQ&$BA4;L#9DZrjf6eE#V8`+tA&==^w7O|Q88^LF@8ID1qdRv8-9ayCyJ$zGoQy{=-+M7h zV~AR&Rd2MtxLo9E5rn;(K=-Azd%fZA)zzZi^7p#I!4`nwd6cAS8U$_A^!R%Zei62O z!?HD_Uf92N=jgRpUfJE7kUV>E|BZJaf4mKRQU4$-;_y7@@mJqCmiz7F$2$jyagv}L z=saUYO-B8G+YUU-6wGtM9%|dJW!wCnH-F~(es^mSc0rs@(CYO2-SM#Z@=srotVWi? z0F3v9Fj1$-XrgF=a zf)mGTioviN>BSaT@2FXY^$@OX}UAr?J5J|b= zI9?F=t+Ys2i%Y1I;FuB!+%<5$f8&5gMHca2|LS$LJzAG|2R(sl&-e2p2d}O!&Uus> zS&8Y0Gk%VRC5|ifooK|KPnh8|jb& zuQ?YCs?K;6ML??;29F+o<|tUNQeDg!S6&FQ^5Zl%g+O!W=#I3qOzz?=f1}dyOxpvq zi?XT-N#g|Vn!oq^J7h6TonID#4y4khW)cmP2`LN{ zXPZS`gT_!UDs5@FOjTINa3+xIn`}3YiGXv!@@6RVFjCrK(CZLOP=E;ytBbr$DqX-8 z3?JCj Date: Fri, 10 Mar 2023 02:36:08 +0300 Subject: [PATCH 0306/1199] node shapegen.js cobblestone_generator --- .../dbotthepony/mc/otm/shapes/BlockShapes.java | 7 +++++++ .../mc/otm/block/tech/CobblerBlock.kt | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java index 6809d213d..f2f64a10c 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java +++ b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java @@ -615,4 +615,11 @@ public class BlockShapes { new SimpleCuboid(0.875d, 0.375d, 0.5625d, 0.875d, 0.625d, 0.625d), new SimpleCuboid(0.125d, 0.375d, 0.5625d, 0.125d, 0.625d, 0.625d) ); + + public static final BlockShape COBBLESTONE_GENERATOR = new BlockShape( + new SimpleCuboid(0d, 0d, 0d, 1d, 0.375d, 1d), + new SimpleCuboid(0.25d, 0.375d, 0d, 0.75d, 1d, 1d), + new SimpleCuboid(0.0625d, 0.375d, 0.0625d, 0.25d, 0.9375d, 0.9375d), + new SimpleCuboid(0.75d, 0.375d, 0.0625d, 0.9375d, 0.9375d, 0.9375d) + ); } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/CobblerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/CobblerBlock.kt index 0271d346c..8be327fc1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/CobblerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/CobblerBlock.kt @@ -1,14 +1,20 @@ package ru.dbotthepony.mc.otm.block.tech import net.minecraft.core.BlockPos +import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraft.world.level.block.EntityBlock import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.entity.BlockEntityTicker import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.phys.shapes.CollisionContext +import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.block.entity.tech.CobblerBlockEntity +import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.shapes.BlockShapes class CobblerBlock : RotatableMatteryBlock(), EntityBlock { override fun newBlockEntity(pPos: BlockPos, pState: BlockState): BlockEntity { @@ -26,4 +32,16 @@ class CobblerBlock : RotatableMatteryBlock(), EntityBlock { return null } + + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.COBBLESTONE_GENERATOR.rotateFromNorth(it[rotationProperty]).computeShape() } + + @Suppress("override_deprecation") + override fun getShape( + state: BlockState, + blockGetter: BlockGetter, + pos: BlockPos, + context: CollisionContext + ): VoxelShape { + return shapes[state]!! + } } From 8ce67a7fae457aaf65b9cfca195b4cb386279b49 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 10 Mar 2023 22:48:34 +0700 Subject: [PATCH 0307/1199] Make special recipe finder for crafting table recipes, make use of residue logic --- .../mc/otm/matter/MatterManager.kt | 235 +++++++++++++++--- .../otm_recipe_finder/crafting.json | 2 +- 2 files changed, 206 insertions(+), 31 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 3c93b2f80..3ceaa4060 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -15,6 +15,7 @@ import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream import it.unimi.dsi.fastutil.objects.Object2BooleanFunction import it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap import it.unimi.dsi.fastutil.objects.Object2IntArrayMap +import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet import it.unimi.dsi.fastutil.objects.Reference2BooleanFunction import it.unimi.dsi.fastutil.objects.Reference2BooleanOpenHashMap import it.unimi.dsi.fastutil.objects.Reference2ObjectFunction @@ -35,12 +36,16 @@ import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener import net.minecraft.tags.TagKey import net.minecraft.util.profiling.ProfilerFiller import net.minecraft.world.Container +import net.minecraft.world.entity.player.Player +import net.minecraft.world.inventory.AbstractContainerMenu +import net.minecraft.world.inventory.CraftingContainer import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Recipe import net.minecraft.world.item.crafting.RecipeType import net.minecraft.world.level.ItemLike import net.minecraftforge.common.capabilities.ForgeCapabilities +import net.minecraftforge.common.crafting.IShapedRecipe import net.minecraftforge.event.AddReloadListenerEvent import net.minecraftforge.event.OnDatapackSyncEvent import net.minecraftforge.event.RegisterCommandsEvent @@ -64,6 +69,7 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.drive.IMatteryDrive import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.container.set import ru.dbotthepony.mc.otm.container.stream import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.TextComponent @@ -494,7 +500,7 @@ object MatterManager { ResolvedRecipe( it.ingredients.stream() .filter { !it.isActuallyEmpty } - .map { it.items.stream().map(::ImmutableStack) }, + .map { it.items.stream().map(::RecipeEntry) }, ImmutableStack(it.resultItem), isCritical = isCritical, name = it.id, @@ -511,6 +517,91 @@ object MatterManager { } } } + + registrar.register("crafting") { + Finder { server, data -> + val allowBacktrack = data["allow_backtrack"]?.asBoolean ?: true + val ignoreDamageables = data["ignore_damageables"]?.asBoolean ?: false + val isCritical = data["is_critical"]?.asBoolean ?: true + var stream = server.recipeManager.byType(RecipeType.CRAFTING).values.parallelStream().filter { !it.isIncomplete } + + if (ignoreDamageables) { + stream = stream.filter { it.ingredients.stream().flatMap { it.items.stream() }.noneMatch { it.isDamageableItem } } + } + + stream.map { + val width: Int + val height: Int + + if (it is IShapedRecipe<*>) { + width = it.recipeWidth + height = it.recipeHeight + } else { + width = it.ingredients.size + height = 1 + } + + val container = CraftingContainer(object : AbstractContainerMenu(null, 0) { + override fun quickMoveStack(pPlayer: Player, pIndex: Int): ItemStack { + return ItemStack.EMPTY + } + + override fun stillValid(pPlayer: Player): Boolean { + return false + } + }, width, height) + + val realIngredients = ArrayList>() + + for (c in it.ingredients.indices) { + if (it.ingredients[c].isActuallyEmpty) { + continue + } + + for ((i, ingredient) in it.ingredients.withIndex()) { + if (i != c) { + container[i] = if (ingredient.isActuallyEmpty) ItemStack.EMPTY else ingredient.items.firstOrNull() ?: ItemStack.EMPTY + } + } + + val result = ArrayList() + + for (item in it.ingredients[c].items) { + container[c] = item + + if (!it.assemble(container).isEmpty) { + val residue = it.getRemainingItems(container) + + val thisResidue = residue[c] + + if (thisResidue.isEmpty) { + result.add(RecipeEntry(item)) + } else { + result.add(RecipeEntry(ImmutableStack(item), ImmutableStack(thisResidue))) + } + } + } + + realIngredients.add(result) + } + + ResolvedRecipe( + realIngredients.stream().map { it.stream() }, + ImmutableStack(it.resultItem), + isCritical = isCritical, + name = it.id, + allowBacktrack = allowBacktrack + ) + }.filter { + if (it.inputs.isEmpty()) { + LOGGER.warn("${it.formattedName} with output '${it.output.item.registryName}' ended up with no inputs!") + false + } else { + true + } + } + } + } } private var foundResolvers: Map> = ImmutableMap.of() @@ -586,7 +677,7 @@ object MatterManager { for (input1 in recipe.inputs) { for (input in input1) { - input2Recipes.computeIfAbsent(input.item, Reference2ObjectFunction { ReferenceOpenHashSet() }).add(recipe) + input2Recipes.computeIfAbsent(input.input.item, Reference2ObjectFunction { ReferenceOpenHashSet() }).add(recipe) } } } @@ -606,7 +697,7 @@ object MatterManager { private fun doTryToBacktrack(item: Item, makeCommentary: Boolean): Result { val recipes = input2Recipes[item] - if (recipes == null || recipes.isEmpty() || !recipes.all { it.allowBacktrack } || !recipes.all { it.inputs.all { it.all { it.item == item } } }) { + if (recipes == null || recipes.isEmpty() || !recipes.all { it.allowBacktrack } || !recipes.all { it.inputs.all { it.all { it.input.item == item } } }) { if (makeCommentary) comment(item, TextComponent("Item '${item.registryName}' has no recipes")) @@ -713,28 +804,29 @@ object MatterManager { inputsLoop@ for ((i, inputs) in recipe.inputs.withIndex()) { var minimal: IMatterValue? = null var minimalMultiplier = 0.0 - val skips = ArrayList() - val recursiveSkips = ArrayList() + val skips = ArrayList() + val recursiveSkips = ArrayList() + var hadResidue = false - innerInputsLoop@ for (input in inputs) { - val ivalue = determineValue(input.item) + innerInputsLoop@ for (entry in inputs) { + val ivalue = determineValue(entry.input.item) if (ivalue.isMissing) { - comment(item, TextComponent("Input '${input.item.registryName}' at input slot $i in ${recipe.formattedName} has no matter value")) + comment(item, TextComponent("Input $entry at input slot $i in ${recipe.formattedName} has no matter value")) if (recipe.isCritical && !lenientStage) { return Result.MISSING } else { if (recipe.isCritical) { - skips.add(input) + skips.add(entry) continue@innerInputsLoop } else { continue@recipesLoop } } } else if (ivalue.isSkipped) { - comment(item, TextComponent("Input '${input.item.registryName}' at input slot $i in ${recipe.formattedName} is recursive")) - recursiveSkips.add(input) + comment(item, TextComponent("Input $entry at input slot $i in ${recipe.formattedName} is recursive")) + recursiveSkips.add(entry) if (inputs.size == 1) { hadSkips = true @@ -744,14 +836,52 @@ object MatterManager { } } - if (minimal == null || minimal > ivalue.value!!) { - minimal = ivalue.value - minimalMultiplier = input.multiplier + var realValue = ivalue.value!! + val ivalue2 = entry.remainder?.item?.let(::determineValue) + + if (ivalue2 != null) { + if (ivalue2.isMissing) { + comment(item, TextComponent("Remainder of $entry at input slot $i in ${recipe.formattedName} has no matter value")) + + if (recipe.isCritical && !lenientStage) { + return Result.MISSING + } else { + if (recipe.isCritical) { + skips.add(entry) + continue@innerInputsLoop + } else { + continue@recipesLoop + } + } + } else if (ivalue2.isSkipped) { + comment(item, TextComponent("Remainder of $entry at input slot $i in ${recipe.formattedName} is recursive")) + recursiveSkips.add(entry) + + if (inputs.size == 1) { + hadSkips = true + continue@recipesLoop + } else { + continue@innerInputsLoop + } + } + + realValue = MatterValue(realValue.matter - ivalue2.value!!.matter, realValue.complexity - ivalue2.value.complexity) + hadResidue = true + + if (realValue.matter.isNegative || realValue.complexity < 0.0) { + comment(item, TextComponent("Entry $entry at input slot $i in ${recipe.formattedName} ended up with negative matter value or/and complexity")) + return Result.MISSING + } + } + + if (minimal == null || minimal > realValue) { + minimal = realValue + minimalMultiplier = entry.input.multiplier } } if (skips.size > inputs.size / 2 || skips.isNotEmpty() && inputs.size == 1) { - comment(item, TextComponent("More than half inputs (${skips.joinToString(", ") { it.item.registryName.toString() }}) at input slot $i in ${recipe.formattedName} have no matter values")) + comment(item, TextComponent("More than half inputs (${skips.joinToString(", ")}) at input slot $i in ${recipe.formattedName} have no matter values")) return Result.MISSING } else if (skips.isNotEmpty()) { /** @@ -769,7 +899,7 @@ object MatterManager { continue } - val list = manager.getReverseTag(input.item).getOrNull()?.tagKeys?.collect(ImmutableList.toImmutableList()) ?: ImmutableList.of() + val list = manager.getReverseTag(input.input.item).getOrNull()?.tagKeys?.collect(ImmutableList.toImmutableList()) ?: ImmutableList.of() if (input !in skips) { for (tag in list) @@ -786,7 +916,7 @@ object MatterManager { val result = filtered.all { tagSetsMissing.getInt(it.key) == skips.size } if (!result) { - comment(item, TextComponent("More than half inputs (${skips.joinToString(", ") { it.item.registryName.toString() }}) at input slot $i in ${recipe.formattedName} have no matter values")) + comment(item, TextComponent("More than half inputs (${skips.joinToString(", ")}) at input slot $i in ${recipe.formattedName} have no matter values")) return Result.MISSING } else { comment(item, TextComponent("${recipe.formattedName} with inputs at slot $i without matter values were allowed to be skipped due to next tags:")) @@ -797,8 +927,13 @@ object MatterManager { } } + if (minimal != null && !minimal.hasMatterValue && hadResidue && inputs.size == 1) { + // ингредиент ничего не стоит ибо не потребляется в крафте + continue@inputsLoop + } + if (minimal == null || !minimal.hasMatterValue) { - comment(item, TextComponent("'${recipe.formattedName}' has invalid input at slot $i (possible inputs: ${inputs.joinToString(", ", transform = { it.item.registryName.toString() }) }) (???)")) + comment(item, TextComponent("'${recipe.formattedName}' has invalid input at slot $i (possible inputs: ${inputs.joinToString(", ")}) (???)")) return Result.MISSING } @@ -1241,8 +1376,20 @@ object MatterManager { constructor(item: ItemStack) : this(item.item, item.count) } + data class RecipeEntry( + val input: ImmutableStack, + val remainder: ImmutableStack? = null + ) { + constructor(item: Item, count: Int) : this(ImmutableStack(item, count)) + constructor(item: ItemStack) : this(ImmutableStack(item)) + + override fun toString(): String { + return "RecipeEntry[${input.item.registryName} to ${remainder?.item?.registryName}]" + } + } + class ResolvedRecipe( - inputs: Stream>, + inputs: Stream>, val output: ImmutableStack, val transformMatterValue: (Decimal) -> Decimal = { it }, val transformComplexity: (Double) -> Double = { it }, @@ -1260,25 +1407,42 @@ object MatterManager { * (e.g. 4 rabbit hides -> 1 leather), we can assume that we can determine matter value of ingredients based on matter value of output * * "Backtrack" can happen if everything of the next holds true: - * * All recipes with item in question contains only that item; and + * * All recipes with item in question contains only that item; * * All recipes allow backtracking */ val allowBacktrack: Boolean = true, ) { - val inputs: List> = inputs - .map { it.filter { it.multiplier > 0.0 }.collect(ImmutableList.toImmutableList()) } + val inputs: List> = inputs + .map { it.filter { it.input.multiplier > 0.0 }.collect(ImmutableList.toImmutableList()) } .filter { it.isNotEmpty() } .collect(ImmutableList.toImmutableList()) - constructor( - inputs: Collection>, - output: ImmutableStack, - transformMatterValue: (Decimal) -> Decimal = { it }, - transformComplexity: (Double) -> Double = { it }, - ) : this(inputs.stream().map { it.stream() }, output, transformMatterValue, transformComplexity) - val formattedName: String get() = if (name == null) "One of recipes" else "Recipe '$name'" + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is ResolvedRecipe) return false + + if (output != other.output) return false + if (transformMatterValue != other.transformMatterValue) return false + if (transformComplexity != other.transformComplexity) return false + if (isCritical != other.isCritical) return false + if (allowBacktrack != other.allowBacktrack) return false + if (inputs != other.inputs) return false + + return true + } + + override fun hashCode(): Int { + var result = output.hashCode() + result = 31 * result + transformMatterValue.hashCode() + result = 31 * result + transformComplexity.hashCode() + result = 31 * result + isCritical.hashCode() + result = 31 * result + allowBacktrack.hashCode() + result = 31 * result + inputs.hashCode() + return result + } } fun interface Finder { @@ -1293,7 +1457,7 @@ object MatterManager { * * You can safely call [MatterManager.getDirect] inside returned stream, both parallel and sequential. */ - fun find(server: MinecraftServer, json: JsonObject): Stream + fun find(server: MinecraftServer, data: JsonObject): Stream } /** @@ -1304,7 +1468,18 @@ object MatterManager { return Registry.direct(value) } + /** + * Access recipe finders registry + * + * @throws IllegalStateException if calling too early + */ @JvmStatic val recipeFinders get() = Resolver.delegate.get() + + /** + * Access recipe finders registry key + * + * Use this with your [DeferredRegister] + */ @JvmStatic val recipeFindersKey get() = Resolver.delegate.key private val commentary = Reference2ObjectOpenHashMap>() diff --git a/src/main/resources/data/overdrive_that_matters/otm_recipe_finder/crafting.json b/src/main/resources/data/overdrive_that_matters/otm_recipe_finder/crafting.json index b24f469cb..2e0353a3a 100644 --- a/src/main/resources/data/overdrive_that_matters/otm_recipe_finder/crafting.json +++ b/src/main/resources/data/overdrive_that_matters/otm_recipe_finder/crafting.json @@ -1,5 +1,5 @@ { "recipe_type": "minecraft:crafting", - "type": "overdrive_that_matters:simple", + "type": "overdrive_that_matters:crafting", "is_critical": true } \ No newline at end of file From 059d8e3065f09bcfa3483f8f1ebbad0d52c8e519 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 10 Mar 2023 22:57:49 +0700 Subject: [PATCH 0308/1199] Milk bucket matter values --- .../kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt index 2b070eb1a..858317b6a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt @@ -5,7 +5,9 @@ import net.minecraft.world.item.Item import net.minecraft.world.item.Items import net.minecraftforge.common.Tags import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.matter.ComputeAction import ru.dbotthepony.mc.otm.matter.MatterDataProvider +import ru.dbotthepony.mc.otm.matter.MatterFunction import ru.dbotthepony.mc.otm.registry.MItemTags import ru.dbotthepony.mc.otm.registry.MItems @@ -20,6 +22,10 @@ fun addMatterData(provider: MatterDataProvider) { provider.inherit(MItems.TRITANIUM_ANVIL[i], MItems.TRITANIUM_ANVIL[i - 1], 0.85) } + provider.inherit(Items.MILK_BUCKET, Items.BUCKET) { + plus(Decimal(7), 480.0) + } + val copper = listOf, Item>>( listOf( Items.EXPOSED_COPPER, @@ -105,7 +111,7 @@ fun addMatterData(provider: MatterDataProvider) { relative(Items.NETHER_STAR, 2000, 1200) - relative(MItems.ZPM_BATTERY, 60000, 7200) + relative(MItems.ZPM_BATTERY, 160000, 7200) relative(MItems.PILL_HEAL, 14, 8) relative(MItems.PILL_ANDROID, 20, 20) From ede087f4a0471626048bd9aeaf5d952e84109d4e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 10 Mar 2023 23:25:26 +0700 Subject: [PATCH 0309/1199] lol --- .../overdrive_that_matters/otm_recipe_finder/smithing.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/resources/data/overdrive_that_matters/otm_recipe_finder/smithing.json b/src/main/resources/data/overdrive_that_matters/otm_recipe_finder/smithing.json index 00593b9d0..f5aebe2b2 100644 --- a/src/main/resources/data/overdrive_that_matters/otm_recipe_finder/smithing.json +++ b/src/main/resources/data/overdrive_that_matters/otm_recipe_finder/smithing.json @@ -1,6 +1,5 @@ { "recipe_type": "minecraft:smithing", "type": "overdrive_that_matters:simple", - "is_critical": false, - "ignore_damageables": true + "is_critical": false } \ No newline at end of file From e8d76a4a8ea1e73877dd915930ca320e7b48216d Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Fri, 10 Mar 2023 21:12:01 +0300 Subject: [PATCH 0310/1199] =?UTF-8?q?=D0=B6=D1=91=D1=81=D1=82=D0=BA=D0=BE?= =?UTF-8?q?=20=D0=BA=D0=B0=D0=BA=D0=BD=D1=83=D0=BB=20=D1=82=D0=B5=D0=B3?= =?UTF-8?q?=D0=B0=D0=BC=D0=B8=20+=20=D1=80=D1=83=D0=B4=D1=8B=20=D0=B2=20?= =?UTF-8?q?=D0=BA=D1=80=D0=B5=D0=B0=D1=82=D0=B8=D0=B2=20=D1=82=D0=B0=D0=B1?= =?UTF-8?q?=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dbotthepony/mc/otm/datagen/tags/Tags.kt | 9 +++- .../mc/otm/datagen/tags/TagsProvider.kt | 41 +++++++++++++++++++ .../mc/otm/registry/CreativeTabs.kt | 2 + 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index a2d6469f3..873faa61f 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -29,8 +29,13 @@ fun addTags(tagsProvider: TagsProvider) { tagsProvider.storageBlocksAsItem.add("tritanium", MItems.TRITANIUM_INGOT_BLOCK) tagsProvider.storageBlocksAsBlock.add("tritanium", MBlocks.TRITANIUM_INGOT_BLOCK) - tagsProvider.ore("tritanium", MBlocks.TRITANIUM_ORE) - tagsProvider.ore("tritanium", MBlocks.DEEPSLATE_TRITANIUM_ORE) + tagsProvider.stoneOre("tritanium", MBlocks.TRITANIUM_ORE) + tagsProvider.deepslateOre("tritanium", MBlocks.DEEPSLATE_TRITANIUM_ORE) + tagsProvider.singleDropOre( + MBlocks.TRITANIUM_ORE, + MBlocks.DEEPSLATE_TRITANIUM_ORE + ) + tagsProvider.clump("tritanium", MItems.TRITANIUM_ORE_CLUMP, MBlocks.TRITANIUM_RAW_BLOCK) tagsProvider.wires.add("copper", MItems.COPPER_WIRING) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt index bc575e784..67bbdcb67 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt @@ -201,6 +201,33 @@ class TagsProvider( val witherImmune = blocks.appender(BlockTags.WITHER_IMMUNE) val dragonImmune = blocks.appender(BlockTags.DRAGON_IMMUNE) + fun stoneOre(key: String, block: Block): TagsProvider { + ore(key, block) + + itemGroundOresStone.add(block.asItem()) + blockGroundOresStone.add(block) + + return this + } + + fun deepslateOre(key: String, block: Block): TagsProvider { + ore(key, block) + + itemGroundOresDeepslate.add(block.asItem()) + blockGroundOresDeepslate.add(block) + + return this + } + + fun singleDropOre(vararg blocks: Block): TagsProvider { + for (block in blocks) { + itemOreRatesSingular.add(block.asItem()) + blockOreRatesSingular.add(block) + } + + return this + } + fun ore(key: String, block: Block): TagsProvider { val forgeKey = ResourceLocation("forge", "ores/$key") val b = TagKey.create(Registries.BLOCK, forgeKey) @@ -244,6 +271,20 @@ class TagsProvider( val rawMaterials = items.forge("raw_materials") val wires = items.forge("wires") + val blockGroundOresStone = blocks.forge("ores_in_ground/stone") + val blockGroundOresDeepslate = blocks.forge("ores_in_ground/deepslate") +// val blockGroundOresNetherrack = blocks.forge("ores_in_ground/netherrack") + val itemGroundOresStone = items.forge("ores_in_ground/stone") + val itemGroundOresDeepslate = items.forge("ores_in_ground/deepslate") +// val itemGroundOresNetherrack = items.forge("ores_in_ground/netherrack") + +// val blockOreRatesSparse = blocks.forge("ore_rates/sparse") + val blockOreRatesSingular = blocks.forge("ore_rates/singular") +// val blockOreRatesDense = blocks.forge("ore_rates/dense") +// val itemOreRatesSparse = items.forge("ore_rates/sparse") + val itemOreRatesSingular = items.forge("ore_rates/singular") +// val itemOreRatesDense = items.forge("ore_rates/dense") + val gameEvents = Delegate(Registries.GAME_EVENT) val vibrations = gameEvents.appender(GameEventTags.VIBRATIONS) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt index f0a269713..45689ba1b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt @@ -111,6 +111,8 @@ internal fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { // accept(MItems.MATTER_DUST) + accept(MItems.TRITANIUM_ORE) + accept(MItems.DEEPSLATE_TRITANIUM_ORE) accept(MItems.TRITANIUM_ORE_CLUMP) accept(MItems.TRITANIUM_DUST) accept(MItems.TRITANIUM_NUGGET) From 0ea4669d499b4778eb7e7b706f7baa2ad5ff8aed Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 11 Mar 2023 01:15:10 +0700 Subject: [PATCH 0311/1199] pretty lomp. --- .../ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt | 2 +- .../kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt index 17ace9ebe..1392e4894 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt @@ -119,7 +119,7 @@ class LaboratoryLamp(val invertRedstone: Boolean) : Block(Properties.of(Material override fun getStateForPlacement(context: BlockPlaceContext): BlockState { return super.getStateForPlacement(context)!! .setValue(BlockStateProperties.LIT, !invertRedstone) - .setValue(FACING_FULL, -context.nearestLookingDirection.blockRotation) + .setValue(FACING_FULL, context.nearestLookingDirection.blockRotation.oppositeFront) } override fun appendHoverText( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt index 496ce6645..1985f0925 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotation.kt @@ -155,6 +155,8 @@ enum class BlockRotation( val opposite by lazy { of(front.opposite, top.opposite) } val normal: Vec3i get() = front.normal + val oppositeFront by lazy { of(front.opposite, top) } + companion object { @JvmStatic fun of(direction: Direction): BlockRotation { From 288b2522c72ca20d99527c80ab18bb3bb31b73b5 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Fri, 10 Mar 2023 22:24:28 +0300 Subject: [PATCH 0312/1199] fix sword and android station emissive --- .../models/block/android_station_working.json | 41 +++++++++---------- .../models/item/energy_sword_powered.json | 13 +++--- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/android_station_working.json b/src/main/resources/assets/overdrive_that_matters/models/block/android_station_working.json index 97b5b2064..7a63ccca3 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/android_station_working.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/android_station_working.json @@ -25,13 +25,14 @@ "from": [0, 7, 0], "to": [16, 9, 16], "faces": { - "north": {"uv": [8, 4, 16, 4.5], "texture": "#1", "emissivity": 15}, - "east": {"uv": [0, 4, 8, 4.5], "texture": "#1", "emissivity": 15}, - "south": {"uv": [8, 4, 16, 4.5], "texture": "#1", "emissivity": 15}, - "west": {"uv": [0, 4, 8, 4.5], "texture": "#1", "emissivity": 15}, - "up": {"uv": [8, 0, 16, 4], "texture": "#1", "emissivity": 15}, - "down": {"uv": [8, 4.5, 16, 8.5], "texture": "#1", "emissivity": 15} - } + "north": {"uv": [8, 4, 16, 4.5], "texture": "#1"}, + "east": {"uv": [0, 4, 8, 4.5], "texture": "#1"}, + "south": {"uv": [8, 4, 16, 4.5], "texture": "#1"}, + "west": {"uv": [0, 4, 8, 4.5], "texture": "#1"}, + "up": {"uv": [8, 0, 16, 4], "texture": "#1"}, + "down": {"uv": [8, 4.5, 16, 8.5], "texture": "#1"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } }, { "name": "base", @@ -64,13 +65,14 @@ "from": [2, 4, 2], "to": [14, 7, 14], "faces": { - "north": {"uv": [1, 0, 7, 0.75], "texture": "#1", "emissivity": 15}, - "east": {"uv": [1, 0, 7, 0.75], "texture": "#1", "emissivity": 15}, - "south": {"uv": [1, 0, 7, 0.75], "texture": "#1", "emissivity": 15}, - "west": {"uv": [1, 0, 7, 0.75], "texture": "#1", "emissivity": 15}, - "up": {"uv": [9, 5, 15, 8], "texture": "#1", "emissivity": 15}, - "down": {"uv": [9, 5, 15, 8], "texture": "#1", "emissivity": 15} - } + "north": {"uv": [1, 0, 7, 0.75], "texture": "#1"}, + "east": {"uv": [1, 0, 7, 0.75], "texture": "#1"}, + "south": {"uv": [1, 0, 7, 0.75], "texture": "#1"}, + "west": {"uv": [1, 0, 7, 0.75], "texture": "#1"}, + "up": {"uv": [9, 5, 15, 8], "texture": "#1"}, + "down": {"uv": [9, 5, 15, 8], "texture": "#1"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } }, { "name": "frame", @@ -128,13 +130,10 @@ "from": [-1, 10, -1], "to": [17, 10, 17], "faces": { - "north": {"uv": [0, 0, 8, 0], "texture": "#missing"}, - "east": {"uv": [0, 0, 8, 0], "texture": "#missing"}, - "south": {"uv": [0, 0, 8, 0], "texture": "#missing"}, - "west": {"uv": [0, 0, 8, 0], "texture": "#missing"}, - "up": {"uv": [0, 9.5, 8, 13.5], "texture": "#0", "emissivity": 15}, - "down": {"uv": [0, 9.5, 8, 13.5], "texture": "#0", "emissivity": 15} - } + "up": {"uv": [0, 9.5, 8, 13.5], "texture": "#0"}, + "down": {"uv": [0, 9.5, 8, 13.5], "texture": "#0"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } } ], "display": { diff --git a/src/main/resources/assets/overdrive_that_matters/models/item/energy_sword_powered.json b/src/main/resources/assets/overdrive_that_matters/models/item/energy_sword_powered.json index 2e897f089..54f7f965a 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/item/energy_sword_powered.json +++ b/src/main/resources/assets/overdrive_that_matters/models/item/energy_sword_powered.json @@ -260,13 +260,14 @@ "from": [7.1, 7, 6.9], "to": [8.8, 29.3, 12], "faces": { - "north": {"uv": [2.45, 1, 3.45, 12], "texture": "#1", "emissivity": 15}, - "east": {"uv": [0, 1, 2.5, 12], "texture": "#1", "emissivity": 15}, - "south": {"uv": [6, 1, 7, 12], "texture": "#1", "emissivity": 15}, - "west": {"uv": [3.5, 1, 6, 12], "texture": "#1", "emissivity": 15}, - "up": {"uv": [3.5, 0, 6, 1], "rotation": 90, "texture": "#1", "emissivity": 15}, + "north": {"uv": [2.45, 1, 3.45, 12], "texture": "#1"}, + "east": {"uv": [0, 1, 2.5, 12], "texture": "#1"}, + "south": {"uv": [6, 1, 7, 12], "texture": "#1"}, + "west": {"uv": [3.5, 1, 6, 12], "texture": "#1"}, + "up": {"uv": [3.5, 0, 6, 1], "rotation": 90, "texture": "#1"}, "down": {"uv": [0, 0, 1, 2.5], "texture": "#missing"} - } + }, + "forge_data": { "block_light": 15, "sky_light": 15 } }, { "name": "capacitor", From 9025036a6fe7455afcb44c2945c9cbe415b9203e Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Fri, 10 Mar 2023 23:44:34 +0300 Subject: [PATCH 0313/1199] =?UTF-8?q?=D0=BF=D0=BE=D1=87=D0=B5=D0=BC=D1=83?= =?UTF-8?q?=20=D1=83=20=D0=BF=D1=80=D0=BE=D0=B7=D1=80=D0=B0=D1=87=D0=BD?= =?UTF-8?q?=D0=BE=D0=B3=D0=BE=20=D0=B1=D0=BB=D0=BE=D0=BA=D0=B0=20=D0=B5?= =?UTF-8?q?=D1=81=D1=82=D1=8C=20=D0=A1=D0=A2=D0=9E=D0=A0=D0=9E=D0=9D=D0=AB?= =?UTF-8?q?=20=D0=91=D0=9B=D0=AF=D0=A2=D0=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt index 1392e4894..b6e107560 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt @@ -185,8 +185,9 @@ class LaboratoryLamp(val invertRedstone: Boolean) : Block(Properties.of(Material if (shouldBeLit) { if (targetState.isAir && targetState.block != MBlocks.LABORATORY_LAMP_LIGHT) { - level.setBlockAndUpdate(target, MBlocks.LABORATORY_LAMP_LIGHT.defaultBlockState().setValue( - FACING_FULL, -facing)) + level.setBlockAndUpdate(target, MBlocks.LABORATORY_LAMP_LIGHT.defaultBlockState() + .setValue(FACING_FULL, facing.opposite) + ) } } else { if (targetState.block == MBlocks.LABORATORY_LAMP_LIGHT) { From 92c9339dbbf9c6a8958ca69536cf6379352b6da3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 11 Mar 2023 08:35:46 +0700 Subject: [PATCH 0314/1199] =?UTF-8?q?=D0=9F=D0=BE=D1=82=D0=BE=D0=BC=D1=83-?= =?UTF-8?q?=D1=87=D1=82=D0=BE=20=D1=81=D0=B2=D0=B5=D1=82=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=BB=D0=B6=D0=B5=D0=BD=20=D0=B7=D0=BD=D0=B0=D1=82=D1=8C,=20?= =?UTF-8?q?=D0=BA=20=D0=BA=D0=B0=D0=BA=D0=BE=D0=B9=20=D0=BB=D0=B0=D0=BC?= =?UTF-8?q?=D0=BF=D0=B5=20=D0=BE=D0=BD=20=D0=BF=D1=80=D0=B8=D0=BD=D0=B0?= =?UTF-8?q?=D0=B4=D0=BB=D0=B5=D0=B6=D0=B8=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt index b6e107560..f4dc91b9e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt @@ -26,6 +26,7 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.math.blockRotation import ru.dbotthepony.mc.otm.core.math.plus +import ru.dbotthepony.mc.otm.core.math.unaryMinus import ru.dbotthepony.mc.otm.once import ru.dbotthepony.mc.otm.registry.MBlocks @@ -186,7 +187,7 @@ class LaboratoryLamp(val invertRedstone: Boolean) : Block(Properties.of(Material if (shouldBeLit) { if (targetState.isAir && targetState.block != MBlocks.LABORATORY_LAMP_LIGHT) { level.setBlockAndUpdate(target, MBlocks.LABORATORY_LAMP_LIGHT.defaultBlockState() - .setValue(FACING_FULL, facing.opposite) + .setValue(FACING_FULL, facing.oppositeFront) ) } } else { From d811a671c5ac160ffaf053b191665d72847972e5 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 11 Mar 2023 12:05:30 +0700 Subject: [PATCH 0315/1199] Fix block energy storage "deserializing" stuff even if it is missing --- .../mc/otm/capability/energy/BlockEnergyStorageImpl.kt | 9 +++++---- .../ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt | 10 ++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt index 26ae42578..42d35b2c7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt @@ -20,6 +20,7 @@ import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.nbt.mapPresent import ru.dbotthepony.mc.otm.core.nbt.set sealed class BlockEnergyStorageImpl( @@ -139,10 +140,10 @@ sealed class BlockEnergyStorageImpl( override fun deserializeNBT(nbt: CompoundTag?) { if (nbt == null) return - batteryLevel = nbt.map(ENERGY_STORED_KEY, Decimal.Companion::deserializeNBT) ?: Decimal.ZERO - maxBatteryLevelStorage = nbt.map(ENERGY_STORED_MAX_KEY, Decimal.Companion::deserializeNBT) - maxInputStorage = nbt.map(MAX_INPUT_KEY, Decimal.Companion::deserializeNBT) - maxOutputStorage = nbt.map(MAX_OUTPUT_KEY, Decimal.Companion::deserializeNBT) + batteryLevel = nbt.mapPresent(ENERGY_STORED_KEY, Decimal.Companion::deserializeNBT) ?: Decimal.ZERO + maxBatteryLevelStorage = nbt.mapPresent(ENERGY_STORED_MAX_KEY, Decimal.Companion::deserializeNBT) + maxInputStorage = nbt.mapPresent(MAX_INPUT_KEY, Decimal.Companion::deserializeNBT) + maxOutputStorage = nbt.mapPresent(MAX_OUTPUT_KEY, Decimal.Companion::deserializeNBT) } var resolver: LazyOptional = LazyOptional.of { this } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt index 6c4ab1256..140619739 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt @@ -59,6 +59,16 @@ inline fun CompoundTag.map(key: String, consumer: (T) -> R return null } +inline fun CompoundTag.mapPresent(key: String, consumer: (T) -> R): R? { + val tag = get(key) + + if (tag is T) { + return consumer(tag) + } + + return null +} + fun CompoundTag.mapString(index: String, mapper: (String) -> T, orElse: T): T { val tag = this[index] as? StringTag ?: return orElse return mapper.invoke(tag.asString) From 2ec47c5d59074bd2af6085180f20d024516806df Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 11 Mar 2023 13:29:53 +0700 Subject: [PATCH 0316/1199] Don't use parallelStream because https://github.com/MinecraftForge/EventBus/issues/44 --- src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 3 ++- .../ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt | 2 +- .../ru/dbotthepony/mc/otm/matter/InsertAction.kt | 10 ++++------ .../ru/dbotthepony/mc/otm/matter/MatterManager.kt | 4 ++-- 4 files changed, 9 insertions(+), 10 deletions(-) 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 e35bea5f9..906cdda22 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -246,7 +246,8 @@ fun String.toUUID(): UUID { fun Collection.probablyParallelStream(): Stream { if (size >= 400) { - return parallelStream() + // TODO: https://github.com/MinecraftForge/EventBus/issues/44 + return stream() } return stream() 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 50e9b1cc9..fa77f9fe6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt @@ -392,7 +392,7 @@ class QuantumBatteryItem : Item { companion object { fun clientDisconnect(event: ClientPlayerNetworkEvent.LoggingOut) { - ForgeRegistries.ITEMS.values.parallelStream().forEach { if (it is QuantumBatteryItem) it.clientPowerMap.clear() } + ForgeRegistries.ITEMS.values.stream().forEach { if (it is QuantumBatteryItem) it.clientPowerMap.clear() } } fun readPacket(buff: FriendlyByteBuf): ChargePacket { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/InsertAction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/InsertAction.kt index 31f0ce082..116b9fa2e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/InsertAction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/InsertAction.kt @@ -5,8 +5,6 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.tags.TagKey import net.minecraft.world.item.Item import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.probablyParallelStream -import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set class InsertAction : AbstractRegistryAction { @@ -68,7 +66,7 @@ class InsertAction : AbstractRegistryAction { if (key != null) { if (replaceIfExists) { // search & replace in parallel, if possible - val replaced = registry.probablyParallelStream().anyMatch { + val replaced = registry.stream().anyMatch { if (it is MutableKeyEntry && it.key == key) { if (!comparePriority || it.priority < priority!!) { it.matter = matter @@ -93,7 +91,7 @@ class InsertAction : AbstractRegistryAction { ) } } else { - if (registry.probablyParallelStream().anyMatch { it is MutableKeyEntry && it.key == key }) { + if (registry.stream().anyMatch { it is MutableKeyEntry && it.key == key }) { fail { "Value with key $key already exists" } return } @@ -110,7 +108,7 @@ class InsertAction : AbstractRegistryAction { } else { if (replaceIfExists) { // search & replace in parallel, if possible - val replaced = registry.probablyParallelStream().anyMatch { + val replaced = registry.stream().anyMatch { if (it is MutableTagEntry && it.tag == tag) { if (!comparePriority || it.priority < priority!!) { it.matter = matter @@ -135,7 +133,7 @@ class InsertAction : AbstractRegistryAction { ) } } else { - if (registry.probablyParallelStream().anyMatch { it is MutableTagEntry && it.tag == tag }) { + if (registry.stream().anyMatch { it is MutableTagEntry && it.tag == tag }) { fail { "Value with tag $tag already exists" } return } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 3ceaa4060..fd97ccd81 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -490,7 +490,7 @@ object MatterManager { val ignoreDamageables = data["ignore_damageables"]?.asBoolean ?: false val allowBacktrack = data["allow_backtrack"]?.asBoolean ?: true - var stream = server.recipeManager.byType(findRecipeType).values.parallelStream().filter { !it.isIncomplete } + var stream = server.recipeManager.byType(findRecipeType).values.stream().filter { !it.isIncomplete } if (ignoreDamageables) { stream = stream.filter { it.ingredients.stream().flatMap { it.items.stream() }.noneMatch { it.isDamageableItem } } @@ -523,7 +523,7 @@ object MatterManager { val allowBacktrack = data["allow_backtrack"]?.asBoolean ?: true val ignoreDamageables = data["ignore_damageables"]?.asBoolean ?: false val isCritical = data["is_critical"]?.asBoolean ?: true - var stream = server.recipeManager.byType(RecipeType.CRAFTING).values.parallelStream().filter { !it.isIncomplete } + var stream = server.recipeManager.byType(RecipeType.CRAFTING).values.stream().filter { !it.isIncomplete } if (ignoreDamageables) { stream = stream.filter { it.ingredients.stream().flatMap { it.items.stream() }.noneMatch { it.isDamageableItem } } From 63f1f489a4d4ccd740192c69f952c5898f905114 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 11 Mar 2023 14:24:49 +0700 Subject: [PATCH 0317/1199] typo --- .../dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt index 482b73656..5ac77cd56 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt @@ -45,7 +45,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist title = translation.add("crude_battery", "Potato Power!") { russian("Сила картофеля!") }, - description = translation.add("crude_battery.desc", "Put together a Crude Battery. Better hope for getter better power source soon") { + description = translation.add("crude_battery.desc", "Put together a Crude Battery. Better hope for getting better power source soon") { russian("Создайте Простой Аккумулятор. Надо бы поторопиться с созданием более продвинутого аккумулятора") }, ) From 1b8e1d147fb7442a50451c0425725ee274c938d5 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 11 Mar 2023 14:38:54 +0700 Subject: [PATCH 0318/1199] Manually write android_immune_effects.json to add effects from other mods easily --- .../ru/dbotthepony/mc/otm/datagen/tags/Tags.kt | 17 ----------------- .../mc/otm/datagen/tags/TagsProvider.kt | 2 -- .../tags/mob_effect/android_immune_effects.json | 15 +++++++++++++++ 3 files changed, 15 insertions(+), 19 deletions(-) create mode 100644 src/main/resources/data/overdrive_that_matters/tags/mob_effect/android_immune_effects.json diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index 873faa61f..4e24d9fd4 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -227,21 +227,4 @@ fun addTags(tagsProvider: TagsProvider) { tagsProvider.witherImmune.add( MBlocks.BLACK_HOLE, ) - - tagsProvider.androidImmuneEffects.add( - MobEffects.CONDUIT_POWER, - MobEffects.HEAL, - // maybe it makes things go haywire idk - // MobEffects.HARM, - MobEffects.REGENERATION, - MobEffects.WATER_BREATHING, - MobEffects.POISON, - // even skeletons can be withered - // MobEffects.WITHER, - MobEffects.HEALTH_BOOST, - MobEffects.ABSORPTION, - MobEffects.SATURATION, - MobEffects.DOLPHINS_GRACE, - MobEffects.CONFUSION, - ) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt index 67bbdcb67..4abe105c9 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt @@ -187,8 +187,6 @@ class TagsProvider( val items = Delegate(ForgeRegistries.ITEMS) val mobEffects = Delegate(ForgeRegistries.MOB_EFFECTS) - val androidImmuneEffects = mobEffects.appender(MatteryPlayerCapability.ANDROID_IMMUNE_EFFECTS) - val requiresShovel = blocks.appender(BlockTags.MINEABLE_WITH_SHOVEL) val requiresAxe = blocks.appender(BlockTags.MINEABLE_WITH_AXE) val requiresHoe = blocks.appender(BlockTags.MINEABLE_WITH_HOE) diff --git a/src/main/resources/data/overdrive_that_matters/tags/mob_effect/android_immune_effects.json b/src/main/resources/data/overdrive_that_matters/tags/mob_effect/android_immune_effects.json new file mode 100644 index 000000000..40a9eca7b --- /dev/null +++ b/src/main/resources/data/overdrive_that_matters/tags/mob_effect/android_immune_effects.json @@ -0,0 +1,15 @@ +{ + "values": [ + "minecraft:conduit_power", + "minecraft:instant_health", + "minecraft:regeneration", + "minecraft:water_breathing", + "minecraft:poison", + "minecraft:health_boost", + "minecraft:absorption", + "minecraft:saturation", + "minecraft:dolphins_grace", + "minecraft:nausea", + "hordes:infected" + ] +} \ No newline at end of file From e2e256cf9724d0755170c54cf7dd297f222ce7a7 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 11 Mar 2023 14:57:19 +0700 Subject: [PATCH 0319/1199] need to sleep --- .../dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index 477a9faeb..a2719b6cb 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -278,7 +278,7 @@ fun addCraftingTableRecipes(consumer: Consumer) { .unlockedBy(MItemTags.TRITANIUM_NUGGETS) .save(consumer) - ShapelessRecipeBuilder(RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 9) + ShapelessRecipeBuilder(RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1) .requires(Ingredient.of(MItemTags.TRITANIUM_NUGGETS), 9) .unlockedBy(MItemTags.TRITANIUM_INGOTS) .unlockedBy(MItemTags.TRITANIUM_NUGGETS) From 45084e8fe015ad7851fb9c656d06a8347a891cff Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sat, 11 Mar 2023 12:55:55 +0300 Subject: [PATCH 0320/1199] =?UTF-8?q?DBotThePony=20=E2=80=94=20=D0=A1?= =?UTF-8?q?=D0=B5=D0=B3=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=2012:31=20=D1=87?= =?UTF-8?q?=D1=82=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (closes #237) --- .../dbotthepony/mc/otm/item/MatterDustItem.kt | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt index da8f40f3e..87cb9b192 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt @@ -2,6 +2,10 @@ package ru.dbotthepony.mc.otm.item import net.minecraft.ChatFormatting import net.minecraft.network.chat.Component +import net.minecraft.world.entity.SlotAccess +import net.minecraft.world.entity.player.Player +import net.minecraft.world.inventory.ClickAction +import net.minecraft.world.inventory.Slot import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag @@ -73,6 +77,71 @@ class MatterDustItem : Item(Properties().stacksTo(64)), IMatterItem { return matter(stack) >= ItemsConfig.MATTER_DUST_CAPACITY } + override fun overrideStackedOnOther( + pStack: ItemStack, + pSlot: Slot, + pAction: ClickAction, + pPlayer: Player + ): Boolean { + if (pStack.isEmpty || pStack.count > 1) + return super.overrideStackedOnOther(pStack, pSlot, pAction, pPlayer) + + if (pAction == ClickAction.SECONDARY && pSlot.allowModification(pPlayer)) { + val matterHalf = getMatterValue(pStack)?.matter?.div(2) ?: return true + + if (!pSlot.hasItem()) { + val halfStack = pStack.copyWithCount(1) + + matter(halfStack, -addMatterValue(pStack, -matterHalf, pPlayer.level.isClientSide())) + + pSlot.set(halfStack) + + return true + } + } + + return super.overrideStackedOnOther(pStack, pSlot, pAction, pPlayer) + } + + override fun overrideOtherStackedOnMe( + pStack: ItemStack, + pOther: ItemStack, + pSlot: Slot, + pAction: ClickAction, + pPlayer: Player, + pAccess: SlotAccess + ): Boolean { + if (pStack.isEmpty || pStack.count > 1) + return super.overrideStackedOnOther(pStack, pSlot, pAction, pPlayer) + + if (pAction == ClickAction.SECONDARY && pSlot.allowModification(pPlayer)) { + val matterHalf = getMatterValue(pStack)?.matter?.div(2) ?: return true + + if (pOther.isEmpty) { + val halfStack = pStack.copyWithCount(1) + + matter(halfStack, -addMatterValue(pStack, -matterHalf, pPlayer.level.isClientSide())) + + pAccess.set(halfStack) + + return true + } else if (pOther.item is MatterDustItem && pOther.count == 1) { + val matterOther = getMatterValue(pOther)?.matter ?: return true + val diff = addMatterValue(pStack, matterOther, pPlayer.level.isClientSide()) + + if (matterOther - diff <= Decimal.ZERO) { + pOther.shrink(1) + } else { + matter(pStack, matterOther - diff) + } + + return true + } + } + + return super.overrideOtherStackedOnMe(pStack, pOther, pSlot, pAction, pPlayer, pAccess) + } + companion object { private val DESC = TranslatableComponent("item.overdrive_that_matters.matter_dust.desc").withStyle(ChatFormatting.DARK_GRAY) private val DESC2 = TranslatableComponent("item.overdrive_that_matters.matter_dust.desc2").withStyle(ChatFormatting.GRAY) From b80fa51fbc7d8ab4b8106908a36f0e38ca972fa0 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sat, 11 Mar 2023 13:16:46 +0300 Subject: [PATCH 0321/1199] shrink zero-matter dust stack on split (even if it will never go truly empty) --- .../ru/dbotthepony/mc/otm/item/MatterDustItem.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt index 87cb9b192..4a6a52d04 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt @@ -87,15 +87,17 @@ class MatterDustItem : Item(Properties().stacksTo(64)), IMatterItem { return super.overrideStackedOnOther(pStack, pSlot, pAction, pPlayer) if (pAction == ClickAction.SECONDARY && pSlot.allowModification(pPlayer)) { - val matterHalf = getMatterValue(pStack)?.matter?.div(2) ?: return true - if (!pSlot.hasItem()) { + val matterHalf = getMatterValue(pStack)?.matter?.div(2) ?: return true + val halfStack = pStack.copyWithCount(1) - matter(halfStack, -addMatterValue(pStack, -matterHalf, pPlayer.level.isClientSide())) - pSlot.set(halfStack) + if (getMatterValue(pStack)?.matter!! <= Decimal.ZERO) { + pStack.shrink(1) + } + return true } } @@ -115,13 +117,11 @@ class MatterDustItem : Item(Properties().stacksTo(64)), IMatterItem { return super.overrideStackedOnOther(pStack, pSlot, pAction, pPlayer) if (pAction == ClickAction.SECONDARY && pSlot.allowModification(pPlayer)) { - val matterHalf = getMatterValue(pStack)?.matter?.div(2) ?: return true - if (pOther.isEmpty) { + val matterHalf = getMatterValue(pStack)?.matter?.div(2) ?: return true + val halfStack = pStack.copyWithCount(1) - matter(halfStack, -addMatterValue(pStack, -matterHalf, pPlayer.level.isClientSide())) - pAccess.set(halfStack) return true From aeeabe90ee3b372fcf52c04c2c3c39ed5819c497 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 12 Mar 2023 14:42:05 +0700 Subject: [PATCH 0322/1199] Tritanium plates as shield ingredient --- .../mc/otm/datagen/recipes/CraftingTableRecipes.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index a2719b6cb..ad428b70c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -267,9 +267,9 @@ fun addCraftingTableRecipes(consumer: Consumer) { .build(consumer) MatteryRecipe(MItems.TRITANIUM_SHIELD, category = RecipeCategory.COMBAT) - .row(MItemTags.TRITANIUM_INGOTS, Items.SHIELD, MItemTags.TRITANIUM_INGOTS) - .row(MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS) - .rowB(MItemTags.TRITANIUM_INGOTS) + .row(MItemTags.TRITANIUM_PLATES, Items.SHIELD, MItemTags.TRITANIUM_PLATES) + .row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) + .rowB(MItemTags.TRITANIUM_PLATES) .build(consumer) ShapelessRecipeBuilder(RecipeCategory.MISC, MItems.TRITANIUM_NUGGET, 9) From f88163d1e5e0a724f044e58f18577b0130b9cd54 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 12 Mar 2023 17:57:39 +0700 Subject: [PATCH 0323/1199] Battery bank now have configurable item and energy sides --- .../entity/tech/BatteryBankBlockEntity.kt | 236 ++++++++---------- .../client/screen/tech/BatteryBankScreen.kt | 2 +- .../mc/otm/menu/tech/BatteryBankMenu.kt | 6 + 3 files changed, 109 insertions(+), 135 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index a0f1de59c..6367dbfdc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -25,7 +25,7 @@ import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.menu.tech.BatteryBankMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities -class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.BATTERY_BANK, p_155229_, p_155230_) { +class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.BATTERY_BANK, p_155229_, p_155230_), IMatteryEnergyStorage { var gaugeLevel by synchronizer.float() private set @@ -34,7 +34,7 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { super.setChanged(slot, new, old) batteryStatus[slot].value = new.getCapability(ForgeCapabilities.ENERGY).isPresent - gaugeLevel = (energy.batteryLevel / energy.maxBatteryLevel).toFloat() + gaugeLevel = (batteryLevel / maxBatteryLevel).toFloat() } }.also(::addDroppableContainer) @@ -42,35 +42,73 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte synchronizer.bool(false) } - private val itemHandler = container.handler( - object : HandlerFilter { - override fun canInsert(slot: Int, stack: ItemStack): Boolean { - return stack.getCapability(ForgeCapabilities.ENERGY).isPresent - } - - override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { - return true - } - } + val itemConfig = ConfigurableItemHandler( + input = container.handler(HandlerFilter.Dischargeable.and(HandlerFilter.OnlyIn)), + output = container.handler(HandlerFilter.OnlyOut), + frontDefault = ItemHandlerMode.INPUT_OUTPUT, + backDefault = ItemHandlerMode.INPUT_OUTPUT, + leftDefault = ItemHandlerMode.INPUT_OUTPUT, + rightDefault = ItemHandlerMode.INPUT_OUTPUT, + topDefault = ItemHandlerMode.INPUT_OUTPUT, + bottomDefault = ItemHandlerMode.INPUT_OUTPUT, ) init { - exposeItemsGlobally(itemHandler) savetable(::container, INVENTORY_KEY) } private data class BatteryBankDistribution(val distribution: Array, val maxThroughput: Decimal) - private inner class BatteryBankEnergy(override val energyFlow: FlowDirection) : IMatteryEnergyStorage { - override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { - return distributeEnergy(isReceiving = false, howMuch, simulate) + override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { + return distributeEnergy(isReceiving = false, howMuch, simulate) + } + + private fun getDistribution(isReceiving: Boolean): BatteryBankDistribution { + val distribution = Array(container.containerSize) { Decimal.ZERO } + var summ = Decimal.ZERO + + for (i in 0 until container.containerSize) { + val stack = container.getItem(i) + + if (!stack.isEmpty) { + stack.energy?.let { + val diff: Decimal + + if (isReceiving) { + diff = it.receiveEnergy(it.maxEnergyStoredMattery, true) + } else { + diff = it.extractEnergy(it.energyStoredMattery, true) + } + + distribution[i] = diff + summ += distribution[i] + } + } } - fun getDistribution(isReceiving: Boolean): BatteryBankDistribution { - val distribution = Array(container.containerSize) { Decimal.ZERO } - var summ = Decimal.ZERO - + if (!summ.isZero) { for (i in 0 until container.containerSize) { + distribution[i] = distribution[i] / summ + } + } + + return BatteryBankDistribution(distribution, summ) + } + + private fun distributeEnergy(isReceiving: Boolean, howMuch: Decimal, simulate: Boolean, set: Boolean = false): Decimal { + if (!howMuch.isPositive) + return Decimal.ZERO + + val distribution = getDistribution(isReceiving) + + if (distribution.maxThroughput.isZero) + return Decimal.ZERO + + val distList = distribution.distribution + var summ = Decimal.ZERO + + for (i in 0 until container.containerSize) { + if (!distList[i].isZero) { val stack = container.getItem(i) if (!stack.isEmpty) { @@ -78,95 +116,57 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte val diff: Decimal if (isReceiving) { - diff = it.receiveEnergy(it.maxEnergyStoredMattery, true) + diff = it.receiveEnergy(howMuch * distList[i], simulate) } else { - diff = it.extractEnergy(it.energyStoredMattery, true) + diff = it.extractEnergy(howMuch * distList[i], simulate) } - distribution[i] = diff - summ += distribution[i] + summ += diff } } } - - if (!summ.isZero) { - for (i in 0 until container.containerSize) { - distribution[i] = distribution[i] / summ - } - } - - return BatteryBankDistribution(distribution, summ) } - private fun distributeEnergy(isReceiving: Boolean, howMuch: Decimal, simulate: Boolean, set: Boolean = false): Decimal { - if (!howMuch.isPositive) - return Decimal.ZERO + if (!simulate && !summ.isZero) { + setChangedLight() + gaugeLevel = (batteryLevel / maxBatteryLevel).toFloat() + } - val distribution = getDistribution(isReceiving) + return summ + } - if (distribution.maxThroughput.isZero) - return Decimal.ZERO + override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { + return distributeEnergy(isReceiving = true, howMuch, simulate) + } - val distList = distribution.distribution - var summ = Decimal.ZERO + override val canSetBatteryLevel: Boolean + get() = false + + override val energyFlow: FlowDirection + get() = FlowDirection.BI_DIRECTIONAL + + override var batteryLevel: Decimal + get() { + var result = Decimal.ZERO for (i in 0 until container.containerSize) { - if (!distList[i].isZero) { - val stack = container.getItem(i) + val stack = container.getItem(i) - if (!stack.isEmpty) { - stack.energy?.let { - val diff: Decimal - - if (isReceiving) { - diff = it.receiveEnergy(howMuch * distList[i], simulate) - } else { - diff = it.extractEnergy(howMuch * distList[i], simulate) - } - - summ += diff - } + if (!stack.isEmpty) { + stack.energy?.let { + result += it.energyStoredMattery } } } - if (!simulate && !summ.isZero) { - setChangedLight() - gaugeLevel = (batteryLevel / maxBatteryLevel).toFloat() - } - - return summ + return result + } + set(value) { + throw UnsupportedOperationException("Can't set battery value for battery bank") } - override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { - return distributeEnergy(isReceiving = true, howMuch, simulate) - } - - override val canSetBatteryLevel: Boolean - get() = false - - override var batteryLevel: Decimal - get() { - var result = Decimal.ZERO - - for (i in 0 until container.containerSize) { - val stack = container.getItem(i) - - if (!stack.isEmpty) { - stack.energy?.let { - result += it.energyStoredMattery - } - } - } - - return result - } - set(value) { - throw UnsupportedOperationException("Can't set battery value for battery bank") - } - - override val maxBatteryLevel: Decimal - get() { + override val maxBatteryLevel: Decimal + get() { var result = Decimal.ZERO for (i in 0 until container.containerSize) { @@ -181,57 +181,25 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte return result } - } - private val energyReceiver = BatteryBankEnergy(FlowDirection.INPUT) - private val energyExtractor = BatteryBankEnergy(FlowDirection.OUTPUT) - private val energy = BatteryBankEnergy(FlowDirection.BI_DIRECTIONAL) + val energyConfig = ConfigurableEnergy( + this, + frontDefault = FlowDirection.OUTPUT, + backDefault = FlowDirection.INPUT, + leftDefault = FlowDirection.INPUT, + rightDefault = FlowDirection.INPUT, + topDefault = FlowDirection.INPUT, + bottomDefault = FlowDirection.INPUT + ) + + init { + energyConfig.front.automatePush = true + } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { return BatteryBankMenu(containerID, inventory, this) } - init { - exposeEnergySideless(energy) - exposeEnergy(RelativeSide.FRONT, energyExtractor) - - for (side in RelativeSide.values()) { - if (side != RelativeSide.FRONT) { - exposeEnergy(side, energyReceiver) - } - } - } - - private val consumers by front.track(ForgeCapabilities.ENERGY) - - override fun tick() { - super.tick() - - if (redstoneControl.isBlockedByRedstone) - return - - consumers.ifPresentK { - val (_, maxThroughput) = energy.getDistribution(false) - - if (maxThroughput.isZero) - return@ifPresentK - - val diff = it.receiveEnergy(maxThroughput, true) - - if (!diff.isZero) { - val newExtract = energy.extractEnergy(diff, true) - val newReceive = it.receiveEnergy(newExtract, true) - - val extracted = energy.extractEnergy(newReceive, false) - val received = it.receiveEnergy(extracted, false) - - if (received < extracted) { - energy.receiveEnergy(extracted - received, false) - } - } - } - } - companion object { const val CAPACITY = 6 * 2 } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BatteryBankScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BatteryBankScreen.kt index bdc576dd3..df622243a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BatteryBankScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BatteryBankScreen.kt @@ -23,7 +23,7 @@ class BatteryBankScreen(menu: BatteryBankMenu, p_97742_: Inventory, p_97743_: Co for (i in 6 .. 11) BatterySlotPanel(this, frame, menu.storageSlots[i], 44f + 18 * (i - 6), 32f + 18f) - makeDeviceControls(this, frame, redstone = menu.redstone) + makeDeviceControls(this, frame, redstone = menu.redstone, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt index 58b2cd957..8b25a38f7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt @@ -13,7 +13,9 @@ import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.menu.BatterySlot import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.registry.MMenus class BatteryBankMenu @JvmOverloads constructor( @@ -24,10 +26,14 @@ class BatteryBankMenu @JvmOverloads constructor( val powerLevel: LevelGaugeWidget val storageSlots: List val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java) + val energyConfig = EnergyPlayerInput(this, allowPull = false, allowPush = true) + val itemConfig = ItemHandlerPlayerInput(this, allowPull = false, allowPush = false) init { if (tile != null) { redstone.with(tile.redstoneControl::redstoneSetting) + energyConfig.configure(tile.energyConfig) + itemConfig.configure(tile.itemConfig) } val container: Container = tile?.container ?: SimpleContainer(BatteryBankBlockEntity.CAPACITY) From 938df857cb0f369acfb3e696fb56f154d6ff1a4e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 12 Mar 2023 20:48:30 +0700 Subject: [PATCH 0324/1199] Fix wrong translation key --- .../mc/otm/client/screen/tech/AndroidStationScreen.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 0ed9bbfad..2644c3204 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 @@ -644,7 +644,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I researchCanvas.parent = research val bottom = EditablePanel(this, research, 0f, 0f, 0f, 20f) - val close = ButtonPanel(this, bottom, 0f, 0f, 90f, 20f, TranslatableComponent("otm.container.matter_panel.close"), onPress = Runnable { research!!.remove() }) + val close = ButtonPanel(this, bottom, 0f, 0f, 90f, 20f, TranslatableComponent("otm.gui.matter_panel.close"), onPress = Runnable { research!!.remove() }) bottom.dock = Dock.BOTTOM close.dock = Dock.RIGHT From ab0943d4c4da7318173659a7599140a5da798ee3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 12 Mar 2023 22:17:34 +0700 Subject: [PATCH 0325/1199] Micro optimization --- .../dbotthepony/mc/otm/core/util/TickList.kt | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt index 23060d6d0..9ffd22961 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt @@ -93,19 +93,26 @@ class TickList { ticker.tick() } - always.addAll(alwaysValveTime) - alwaysValveTime.clear() - - for (ticker in conditionalValveTime) { - conditional.addFirst(ticker) + if (alwaysValveTime.isNotEmpty()) { + always.addAll(alwaysValveTime) + alwaysValveTime.clear() } - for (ticker in onceValveTime) { - once.addFirst(ticker) + if (conditionalValveTime.isNotEmpty()) { + for (ticker in conditionalValveTime) { + conditional.addFirst(ticker) + } + + conditionalValveTime.clear() } - conditionalValveTime.clear() - onceValveTime.clear() + if (onceValveTime.isNotEmpty()) { + for (ticker in onceValveTime) { + once.addFirst(ticker) + } + + onceValveTime.clear() + } inTicker = false } From bec79a1ea53d1b18e5546ff72b7b305d4896143d Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sun, 12 Mar 2023 20:16:18 +0300 Subject: [PATCH 0326/1199] android health bar + 1px wider energy bar --- .../dbotthepony/mc/otm/client/MatteryGUI.kt | 110 +++++++++++++++++- .../dbotthepony/mc/otm/config/ClientConfig.kt | 4 + .../textures/gui/player_bars.png | Bin 290 -> 234 bytes .../textures/gui/player_bars_health.png | Bin 0 -> 292 bytes 4 files changed, 109 insertions(+), 5 deletions(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/player_bars_health.png diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index 4d0eabd97..73e5a3a36 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -21,6 +21,7 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.render.* +import ru.dbotthepony.mc.otm.config.ClientConfig import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.core.ifPresentK @@ -28,13 +29,23 @@ import java.util.* import kotlin.math.ceil object MatteryGUI { - private val BARS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/player_bars.png"), 80f, 36f) + private val BARS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/player_bars.png"), 81f, 36f) val CHARGE = BARS.sprite(height = 9f) val CHARGE_BG = BARS.sprite(y = 9f, height = 9f) val CHARGE_HUNGER = BARS.sprite(y = 18f, height = 9f) val CHARGE_HUNGER_BG = BARS.sprite(y = 27f, height = 9f) + private val BARS_HP = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/player_bars_health.png"), 81f, 54f) + + val HEALTH = BARS_HP.sprite(height = 9f) + val HEALTH_BG = BARS_HP.sprite(y = 9f, height = 9f) + + val HEALTH_POISON = BARS_HP.sprite(y = 18f, height = 9f) + val HEALTH_WITHER = BARS_HP.sprite(y = 27f, height = 9f) + val HEALTH_ABSORB = BARS_HP.sprite(y = 36f, height = 9f) + val HEALTH_FROZEN = BARS_HP.sprite(y = 45f, height = 9f) + private var originalBedButtonX = -1 private var originalBedButtonY = -1 @@ -97,6 +108,10 @@ object MatteryGUI { GuiOverlayManager.findOverlay(ResourceLocation("minecraft", "air_level")) } + private val PLAYER_HEALTH_ELEMENT by lazy { + GuiOverlayManager.findOverlay(ResourceLocation("minecraft", "player_health")) + } + var iteration = 0 var showIterationUntil = 0L var showIterationUntilFade = 0L @@ -175,7 +190,7 @@ object MatteryGUI { showIteration(event) } - fun onLayerRenderEvent(event: RenderGuiOverlayEvent.Pre) { + private fun renderFoodAndAir(event: RenderGuiOverlayEvent.Pre) { if (event.overlay != FOOD_LEVEL_ELEMENT && event.overlay != AIR_LEVEL_ELEMENT) { return } @@ -206,6 +221,8 @@ object MatteryGUI { return } + if (!gui.shouldDrawSurvivalElements()) return + var level: Float if (mattery.androidEnergy.maxBatteryLevel.isZero) { @@ -226,14 +243,14 @@ object MatteryGUI { val top: Int = height - gui.rightHeight gui.rightHeight += 10 - val leftPadding = ceil(level * 79f - 0.5f) + val leftPadding = ceil(level * 80f - 0.5f) if (ply.hasEffect(MobEffects.HUNGER)) { CHARGE_HUNGER_BG.render(event.poseStack, left.toFloat(), top.toFloat()) - CHARGE_HUNGER.renderPartial(event.poseStack, left.toFloat() - leftPadding + 79f, top.toFloat(), width = leftPadding) + CHARGE_HUNGER.renderPartial(event.poseStack, left.toFloat() - leftPadding + 80f, top.toFloat(), width = leftPadding) } else { CHARGE_BG.render(event.poseStack, left.toFloat(), top.toFloat()) - CHARGE.renderPartial(event.poseStack, left.toFloat() - leftPadding + 79f, top.toFloat(), width = leftPadding) + CHARGE.renderPartial(event.poseStack, left.toFloat() - leftPadding + 80f, top.toFloat(), width = leftPadding) } val formattedPower = mattery.androidEnergy.batteryLevel.formatPower() @@ -247,4 +264,87 @@ object MatteryGUI { event.poseStack.popPose() } } + + private fun getSpriteForPlayer(player: Player): MatterySprite { + if (player.hasEffect(MobEffects.POISON)) { + return HEALTH_POISON + } else if (player.hasEffect(MobEffects.WITHER)) { + return HEALTH_WITHER + } else if (player.isFullyFrozen()) { + return HEALTH_FROZEN + } + + return HEALTH + } + + private fun getHealthColorForPlayer(player: Player): Int { + if (player.hasEffect(MobEffects.POISON)) { + return RGBAColor.DARK_GREEN.toInt() + } else if (player.hasEffect(MobEffects.WITHER)) { + return RGBAColor.WHITE.toInt() + } else if (player.isFullyFrozen()) { + return RGBAColor.AQUA.toInt() + } + + return RGBAColor.RED.toInt() + } // можно вынести в конфиг, но для этого нужен селектор цвета + + private fun renderPlayerHealth(event: RenderGuiOverlayEvent.Pre) { + if (!ClientConfig.ANDROID_HEALTH_HUD) return + + val ply: LocalPlayer = minecraft.player ?: return + + var mattery = ply.matteryPlayer + + if (!ply.isAlive && mattery == null) { + mattery = lastState + } + + val gui = minecraft.gui as? ForgeGui ?: return + + if (mattery != null && mattery.isAndroid) { + event.isCanceled = true + lastState = mattery + + if (!gui.shouldDrawSurvivalElements()) return + + val level: Float = (ply.health / ply.maxHealth).coerceIn(0.0f, 1.0f) + val levelAbsorb: Float = (ply.absorptionAmount / ply.maxHealth).coerceIn(0.0f, 1.0f) + + gui.setupOverlayRenderState(true, false) + RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f) + + val width = event.window.guiScaledWidth + val height = event.window.guiScaledHeight + val left = width / 2 - 10 - 81 + val top: Int = height - gui.leftHeight + gui.leftHeight += 10 + + HEALTH_BG.render(event.poseStack, left.toFloat(), top.toFloat()) + getSpriteForPlayer(ply).renderPartial(event.poseStack, left.toFloat(), top.toFloat(), width = ceil(level * 80f - 0.5f)) + if (levelAbsorb > 0) { + HEALTH_ABSORB.renderPartial(event.poseStack, left.toFloat(), top.toFloat(), width = ceil(levelAbsorb * 80f - 0.5f)) + } + + var formattedHealth = "%d/%d".format(ply.health.toInt(), ply.maxHealth.toInt()) + if (ply.absorptionAmount > 0) + formattedHealth = "%d+%d/%d".format(ply.health.toInt(), ply.absorptionAmount.toInt(), ply.maxHealth.toInt()) + + event.poseStack.pushPose() + event.poseStack.scale(0.5f, 0.5f, 0.5f) + + minecraft.font.drawAligned(event.poseStack, formattedHealth, TextAlign.CENTER_RIGHT, (left - 1f) * 2f, (top + 5.5f) * 2f, RGBAColor.BLACK.toInt()) + minecraft.font.drawAligned(event.poseStack, formattedHealth, TextAlign.CENTER_RIGHT, (left - 2f) * 2f, (top + 4.5f) * 2f, getHealthColorForPlayer(ply)) + + event.poseStack.popPose() + } + } + + fun onLayerRenderEvent(event: RenderGuiOverlayEvent.Pre) { + if (event.overlay == FOOD_LEVEL_ELEMENT || event.overlay == AIR_LEVEL_ELEMENT) { + renderFoodAndAir(event) + } else if (event.overlay == PLAYER_HEALTH_ELEMENT) { + renderPlayerHealth(event) + } + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ClientConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ClientConfig.kt index 4327156de..089a1ada3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ClientConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ClientConfig.kt @@ -25,6 +25,10 @@ object ClientConfig { .comment("Allow to scroll Exopack inventory in non OTM inventories when hovering just over inventory slots, not only scrollbar") .define("EXOPACK_FREE_SCROLL", true) + var ANDROID_HEALTH_HUD: Boolean by specBuilder + .comment("Replace hearts with health bar on HUD when you are an android") + .define("ANDROID_HEALTH_HUD", true) + init { spec = specBuilder.build() } diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/player_bars.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/player_bars.png index dd0ef990b9d74087e9227312fdb572d697a895f2..bd9894af7c56741fe1fee286de417e4771bd8c1b 100644 GIT binary patch delta 191 zcmZ3)^omijGr-TCmrII^fq{Y7)59eQNCyJ33I{WgJho4*Y@(uqsYHNJi0l6cp8szE z1sOCnG&VktS$I=c$dMb!{jmD5Hjv^d3Gxg64*?AKn)gOdw3CQ&_jGX#@$i0oWhXC# z0ncHFr<=duxA1jK;9|7;`XGnRJip&(A_2y#1R&@ZFQt= z!%6XNKlu-Bc&o0nd7=G@>&fRdHx=KJxpmgd(KpTEM8gC|MP?_qkl3@owSV_4(`3B8 z?e82DFRzo<6O0s69Fm|4-Zieu{=xkCPWjJ|dyW+C1$O0 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/player_bars_health.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/player_bars_health.png new file mode 100644 index 0000000000000000000000000000000000000000..abf4b1d3a4372b2fe23b8ae3a5aa23d84defd11e GIT binary patch literal 292 zcmeAS@N?(olHy`uVBq!ia0vp^fk14=!3-oj7PLMCQjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`bpw1tT>lFT?-mvY@-#Fwrc_8|1an-ua^?R0`w9vQ+S=Mz)|+2h#L)2c zJ>$MlKsEA}Li>Oee@T#E@P8D*aOKX7g+M9J0*}aI1_r(ZAk3I`t&*0S6vt$6s?M|N9@)erj)cD?`!mOcoDE|Al;Km4XE)&Xcm;I&ZFPnyX8dqKL^k4UNFP#?HE(=y4*H$qnLu_VO#~UR*jWexz8gEm2 QfEF@%y85}Sb4q9e07nXK-v9sr literal 0 HcmV?d00001 From 8249c9a9cdc5873082acc2c2d231c61a4b0524d9 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Mon, 13 Mar 2023 04:15:25 +0600 Subject: [PATCH 0327/1199] Junk metal and Metal mesh blocks --- .../mc/otm/datagen/blocks/BlockStates.kt | 1 + .../mc/otm/datagen/items/ItemModels.kt | 2 ++ .../mc/otm/datagen/lang/English.kt | 3 +++ .../mc/otm/registry/CreativeTabs.kt | 3 +++ .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 16 +++++++++--- .../ru/dbotthepony/mc/otm/registry/MItems.kt | 2 ++ .../ru/dbotthepony/mc/otm/registry/MNames.kt | 2 ++ .../blockstates/metal_junk.json | 24 ++++++++++++++++++ .../models/block/metal_junk.json | 6 +++++ .../models/block/metal_junk_b.json | 6 +++++ .../models/block/metal_junk_c.json | 6 +++++ .../models/block/metal_mesh.json | 7 +++++ .../block/decorative/metal_junk_a.png | Bin 0 -> 369 bytes .../block/decorative/metal_junk_b.png | Bin 0 -> 329 bytes .../block/decorative/metal_junk_c.png | Bin 0 -> 315 bytes .../textures/block/decorative/metal_mesh.png | Bin 0 -> 253 bytes .../mob_effect/android_immune_effects.json | 15 ----------- 17 files changed, 75 insertions(+), 18 deletions(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/blockstates/metal_junk.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/metal_junk.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/metal_junk_b.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/metal_junk_c.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/metal_mesh.json create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/decorative/metal_junk_a.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/decorative/metal_junk_b.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/decorative/metal_junk_c.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/decorative/metal_mesh.png delete mode 100644 src/main/resources/data/overdrive_that_matters/tags/mob_effect/android_immune_effects.json diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt index 3182f3a45..1ac73e92c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt @@ -28,6 +28,7 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { provider.ore(MBlocks.TRITANIUM_ORE) provider.ore(MBlocks.TRITANIUM_RAW_BLOCK) provider.block(MBlocks.TRITANIUM_INGOT_BLOCK) + provider.block(MBlocks.METAL_MESH) provider.block(MBlocks.CHEMICAL_GENERATOR) provider.block(MBlocks.MATTER_SCANNER) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index c2773104a..c29cc52a1 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -23,6 +23,8 @@ fun addItemModels(provider: MatteryItemModelProvider) { } provider.block(MItems.CARBON_FIBRE_BLOCK) + provider.block(MItems.METAL_JUNK) + provider.block(MItems.METAL_MESH) provider.block(MItems.DEEPSLATE_TRITANIUM_ORE) provider.block(MItems.TRITANIUM_ORE) provider.block(MItems.TRITANIUM_STRIPED_BLOCK) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 7c4275819..80b330466 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -66,6 +66,7 @@ private fun decoratives(provider: MatteryLanguageProvider) { add(MRegistry.VENT.block, "Vent") add(MRegistry.VENT_ALTERNATIVE.block, "Alternative Vent") + for ((block, colors) in MRegistry.TRITANIUM_STRIPED_BLOCK.blocksWithColor) { val (base, stripe) = colors @@ -382,6 +383,8 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.ENERGY_SERVO, "desc", "Charges, Discharges or Exchanges energy of items") add(MBlocks.CARBON_FIBRE_BLOCK, "Carbon Fibre Block") + add(MBlocks.METAL_JUNK, "Metal Junk Block") + add(MBlocks.METAL_MESH, "Metal Mesh") add(MBlocks.TRITANIUM_STRIPED_BLOCK, "Tritanium Striped Block") add(MBlocks.TRITANIUM_STRIPED_STAIRS, "Tritanium Striped Stairs") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt index 45689ba1b..266c0cad7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt @@ -174,6 +174,9 @@ internal fun addDecorativeTabItems(consumer: CreativeModeTab.Output) { accept(MItems.TRITANIUM_STRIPED_SLAB) accept(MItems.TRITANIUM_STRIPED_WALL) accept(MItems.CARBON_FIBRE_BLOCK) + accept(MItems.METAL_JUNK) + accept(MItems.METAL_MESH) + accept(MItems.TRITANIUM_BARS) colored(MItems.TRITANIUM_DOOR) 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 6aeae5d1a..416ea502f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -6,6 +6,7 @@ import net.minecraft.network.chat.Component import net.minecraft.sounds.SoundEvents import net.minecraft.util.valueproviders.UniformInt import net.minecraft.world.entity.Entity +import net.minecraft.world.entity.EntityType import net.minecraft.world.entity.monster.Zombie import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack @@ -121,6 +122,17 @@ object MBlocks { Block(BlockBehaviour.Properties.of(Material.METAL, MaterialColor.COLOR_BLUE).explosionResistance(400f).destroyTime(3f).requiresCorrectToolForDrops()) } + val METAL_JUNK: Block by registry.register(MNames.METAL_JUNK) { + Block(BlockBehaviour.Properties.of(Material.HEAVY_METAL, MaterialColor.COLOR_GRAY).sound(SoundType.NETHERITE_BLOCK).explosionResistance(45f).destroyTime(3f).requiresCorrectToolForDrops()) + } + + val METAL_MESH: Block by registry.register(MNames.METAL_MESH) { + Block(BlockBehaviour.Properties.of(Material.GLASS, MaterialColor.COLOR_GRAY) + .noOcclusion() + .sound(SoundType.COPPER).explosionResistance(30f) + .destroyTime(2f).requiresCorrectToolForDrops()) + } + val TRITANIUM_BARS: IronBarsBlock by registry.register(MNames.TRITANIUM_BARS) { IronBarsBlock(BlockBehaviour.Properties.of(Material.METAL, MaterialColor.COLOR_BLUE).explosionResistance(45f).destroyTime(2.5f).requiresCorrectToolForDrops()) } @@ -133,9 +145,7 @@ object MBlocks { ) } val TRITANIUM_RAW_BLOCK: Block by registry.register(MNames.TRITANIUM_RAW_BLOCK) { Block( - BlockBehaviour.Properties.of(Material.STONE) - .strength(8.0f, 10f) - .requiresCorrectToolForDrops() + BlockBehaviour.Properties.of(Material.STONE).strength(8.0f, 10f).requiresCorrectToolForDrops() ) } val LABORATORY_LAMP: Block by registry.register(MNames.LABORATORY_LAMP) { LaboratoryLamp(false) } 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 5cdc211c0..12854b3d2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -424,6 +424,8 @@ object MItems { val TRITANIUM_STRIPED_SLAB: Item by registry.register(MNames.TRITANIUM_STRIPED_SLAB) { BlockItem(MBlocks.TRITANIUM_STRIPED_SLAB, DEFAULT_PROPERTIES) } val TRITANIUM_STRIPED_WALL: Item by registry.register(MNames.TRITANIUM_STRIPED_WALL) { BlockItem(MBlocks.TRITANIUM_STRIPED_WALL, DEFAULT_PROPERTIES) } val CARBON_FIBRE_BLOCK: Item by registry.register(MNames.CARBON_FIBRE_BLOCK) { BlockItem(MBlocks.CARBON_FIBRE_BLOCK, DEFAULT_PROPERTIES) } + val METAL_JUNK: Item by registry.register(MNames.METAL_JUNK) { BlockItem(MBlocks.METAL_JUNK, DEFAULT_PROPERTIES) } + val METAL_MESH: Item by registry.register(MNames.METAL_MESH) { BlockItem(MBlocks.METAL_MESH, DEFAULT_PROPERTIES) } init { MRegistry.INDUSTRIAL_GLASS.registerItems(registry) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index e5becbf8b..8425a98f6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -66,6 +66,8 @@ object MNames { const val INDUSTRIAL_GLASS = "industrial_glass" const val INDUSTRIAL_GLASS_PANE = "industrial_glass_pane" + const val METAL_MESH = "metal_mesh" + const val METAL_JUNK = "metal_junk" const val CARBON_FIBRE_BLOCK = "carbon_fibre_block" const val FLOOR_TILES = "floor_tiles" diff --git a/src/main/resources/assets/overdrive_that_matters/blockstates/metal_junk.json b/src/main/resources/assets/overdrive_that_matters/blockstates/metal_junk.json new file mode 100644 index 000000000..72d81da32 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/blockstates/metal_junk.json @@ -0,0 +1,24 @@ +{ + "variants": { + "":[ + { + "model": "overdrive_that_matters:block/metal_junk", "weight": 2 + }, + { + "model": "overdrive_that_matters:block/metal_junk", "y": 180, "weight": 2 + }, + { + "model": "overdrive_that_matters:block/metal_junk_b", "weight": 4 + }, + { + "model": "overdrive_that_matters:block/metal_junk_b", "y": 180, "weight": 4 + }, + { + "model": "overdrive_that_matters:block/metal_junk_c", "weight": 3 + }, + { + "model": "overdrive_that_matters:block/metal_junk_c", "y": 180, "weight": 3 + } + ] + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/metal_junk.json b/src/main/resources/assets/overdrive_that_matters/models/block/metal_junk.json new file mode 100644 index 000000000..02695dce8 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/metal_junk.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cube_all", + "textures": { + "all": "overdrive_that_matters:block/decorative/metal_junk_a" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/metal_junk_b.json b/src/main/resources/assets/overdrive_that_matters/models/block/metal_junk_b.json new file mode 100644 index 000000000..f0e21c790 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/metal_junk_b.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cube_all", + "textures": { + "all": "overdrive_that_matters:block/decorative/metal_junk_b" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/metal_junk_c.json b/src/main/resources/assets/overdrive_that_matters/models/block/metal_junk_c.json new file mode 100644 index 000000000..29eebec2b --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/metal_junk_c.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cube_all", + "textures": { + "all": "overdrive_that_matters:block/decorative/metal_junk_c" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/metal_mesh.json b/src/main/resources/assets/overdrive_that_matters/models/block/metal_mesh.json new file mode 100644 index 000000000..33d08171a --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/metal_mesh.json @@ -0,0 +1,7 @@ +{ + "parent": "minecraft:block/cube_all", + "render_type": "translucent", + "textures": { + "all": "overdrive_that_matters:block/decorative/metal_mesh" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/metal_junk_a.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/metal_junk_a.png new file mode 100644 index 0000000000000000000000000000000000000000..c2e99bcb68f1f64621c2574a0f64024c616a4bfc GIT binary patch literal 369 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%Lh(0G|+7ZEfwixHvU6H8V3aPjj=w$1-r`zHPSu)}>* z3d6J$Z>lUfUwJLf(Y&s9A>TQDWpUohv%g>cPImWRx+!mEnAP#~!pDqOJ9JzB{#UK= zW9~(rxam#DrcBabdemach6&dnp2$z0uGH{UykP3WgFNs4UVC^tobObVc705PV(XT_ zpQr10ue$9r?U6*(v)$g-C!fzW-r@7#Av^t_K*3oTiCJ@b8-1Go-&xOIy#L?TcA%pf NJYD@<);T3K0Ra6qmV^KR literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/metal_junk_b.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/metal_junk_b.png new file mode 100644 index 0000000000000000000000000000000000000000..47ea780615ff80226b8615d8917ff071474431bb GIT binary patch literal 329 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}}0G|-oxVSiNZSCBqe!tlCrluw{GqYqb&lM|H+`M^nVotWFxmjp-Y_73F z)Y`UL0ouQhY-v0)D|_aoKeL(=LtMnf#5VC=vIQE&S>O>_%)r3S2f~aF`yK-AVVLac z;uxY4Y}(%_bXbAI*;6%Y!|hvZ|Nmdh{f@0d@SS2t+gekHF_vphFOyjD>4vWo z?`FA+JNf@-`k%fh{4CmucoHvX>K+#Cws+;6*q6*Oh`zu z*H;n~6U(V7cLQqVEbxddW?yUv2+k@*}4^(Qd zB^}?g)1i*z%2Cg|-6Fqw+sEc z)9IB{^laBW9mU=2E?uepOE|INZxiBr02_PeAg3OxMj^e*}J(R3E2clDc1 z6<^%oI>~#dxjH&j%RRo(dw@=4@O1TaS?83{ F1OT{)bff?P literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/metal_mesh.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/metal_mesh.png new file mode 100644 index 0000000000000000000000000000000000000000..a04f5637527431ca1514cb2b339c6110fc7e2f6c GIT binary patch literal 253 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G~10G|+79UYy-#6)|0dnqX?pqPlr`-wn`wIs+d_&*RZ{NBa~GKjOlBeIx* zftwG686EaL1RBJU=IP=Xq7m%d&&k)|z{Aw|?SH=5uIaNn(=;dRIygAVIjMMrik_`u zU3fz##b$X~UE$9s(zE^632Z&TwbQwR?|jdf_a4umB(AIcJ#%V*T;8VRuj1IJ=DZVd nzg7~?d@Fz3Hp}Se{682ZFE9zNRaeXe+Q{JP>gTe~DWM4f#|}|6 literal 0 HcmV?d00001 diff --git a/src/main/resources/data/overdrive_that_matters/tags/mob_effect/android_immune_effects.json b/src/main/resources/data/overdrive_that_matters/tags/mob_effect/android_immune_effects.json deleted file mode 100644 index 40a9eca7b..000000000 --- a/src/main/resources/data/overdrive_that_matters/tags/mob_effect/android_immune_effects.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "values": [ - "minecraft:conduit_power", - "minecraft:instant_health", - "minecraft:regeneration", - "minecraft:water_breathing", - "minecraft:poison", - "minecraft:health_boost", - "minecraft:absorption", - "minecraft:saturation", - "minecraft:dolphins_grace", - "minecraft:nausea", - "hordes:infected" - ] -} \ No newline at end of file From 93440f44cc0c42b62e2407c488251742b2bc5d35 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Mon, 13 Mar 2023 04:15:41 +0600 Subject: [PATCH 0328/1199] Some changes to metal beam textures --- .../block/decorative/metal_beam_side.png | Bin 459 -> 225 bytes .../block/decorative/metal_beam_top.png | Bin 441 -> 229 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/metal_beam_side.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/metal_beam_side.png index f4f5a7d8a1ad828540579689b90562fe565aba9d..f82330696db10952b5c8b91a401daf949abe5652 100644 GIT binary patch delta 160 zcmV;R0AK&h1K|OX7zqRe0002(-QrS_As`zPP)t-sQBhGfH8ma{9u^iBD=RBtU|@I4 zPHd6R7;RWdL_t&-(?yQk4S+BRMX7NBY8aqWx&SzU;0E1)7}J>G-%0KhO7CW>2sIW+ zg`F1o4bva9iv~;~W{&}zdI%;M delta 396 zcmV;70dxN00m}oB7zqdi0000eEe}(XAs~N*P)t-sHa0dgGBO|_AQl!D6%`d692_4X z9~c-I7Z(>IA|f<2G&MCfDk>@w5fKy=6dfHM9v&VuGc#0FR5v#_DJdx%8ygc76A}^< zPft%REiF(`P*PG-D=RB8F)=SMFB%#eOiWBJE-o1v8BI-1EG#TjQ&UkP-)J%N;CNEtv? z5$nKA_Y2-oxQcXYD1$_JZ&;1@L3&}a9%9uKlW7d5$4^{xv&X&ACw%m~k?{bawil&u S58qS(0000z0? z7k|x3L_t(2Qw`4xmV_V-MA6VN_=^yTiWqId?wS2Baah1RbqfI0OB-c=wCz;a0}SJY zI6F@v21mSrn#O4jNEFcVmNck!&j-rMF>anjLl^zEyl>A~Qe}C-VwEHB{-mwMax1Vg zx%C3ueQ0$_EM&K#%%&eryd{+ZvUmxiAY&_x!fpf;n}7%N^v4`h&|q6wsSq7`LLWNN zfww}4H#@57iy8V{tnH-cS1zs8N;<)8otRp6luwf=ic6adSjLO)sIpy^Y>l; Y0e5o{($D`9@c;k-07*qoM6N<$f)o;m&;S4c From 4437634234820f812f16677a816958a492d286bd Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 13 Mar 2023 09:24:55 +0700 Subject: [PATCH 0329/1199] revert wrong file removal --- .../tags/mob_effect/android_immune_effects.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/main/resources/data/overdrive_that_matters/tags/mob_effect/android_immune_effects.json diff --git a/src/main/resources/data/overdrive_that_matters/tags/mob_effect/android_immune_effects.json b/src/main/resources/data/overdrive_that_matters/tags/mob_effect/android_immune_effects.json new file mode 100644 index 000000000..40a9eca7b --- /dev/null +++ b/src/main/resources/data/overdrive_that_matters/tags/mob_effect/android_immune_effects.json @@ -0,0 +1,15 @@ +{ + "values": [ + "minecraft:conduit_power", + "minecraft:instant_health", + "minecraft:regeneration", + "minecraft:water_breathing", + "minecraft:poison", + "minecraft:health_boost", + "minecraft:absorption", + "minecraft:saturation", + "minecraft:dolphins_grace", + "minecraft:nausea", + "hordes:infected" + ] +} \ No newline at end of file From 419097ce88e2b64ea28189eb588b059e3f49a7d9 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 13 Mar 2023 09:28:41 +0700 Subject: [PATCH 0330/1199] A bit smarter battery bank energy distribution --- .../entity/tech/BatteryBankBlockEntity.kt | 150 ++++++++++-------- .../ru/dbotthepony/mc/otm/capability/Ext.kt | 7 + 2 files changed, 88 insertions(+), 69 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index 6367dbfdc..2c5d49e64 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -7,21 +7,21 @@ import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.capabilities.ForgeCapabilities +import net.minecraftforge.energy.IEnergyStorage import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.energy import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.energyStoredMattery import ru.dbotthepony.mc.otm.capability.extractEnergy +import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.capability.maxEnergyStoredMattery import ru.dbotthepony.mc.otm.capability.receiveEnergy +import ru.dbotthepony.mc.otm.capability.transcieveEnergy import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.core.immutableList -import ru.dbotthepony.mc.otm.core.getValue -import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.menu.tech.BatteryBankMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -57,82 +57,94 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte savetable(::container, INVENTORY_KEY) } - private data class BatteryBankDistribution(val distribution: Array, val maxThroughput: Decimal) - - override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { - return distributeEnergy(isReceiving = false, howMuch, simulate) - } - - private fun getDistribution(isReceiving: Boolean): BatteryBankDistribution { - val distribution = Array(container.containerSize) { Decimal.ZERO } - var summ = Decimal.ZERO - - for (i in 0 until container.containerSize) { - val stack = container.getItem(i) - - if (!stack.isEmpty) { - stack.energy?.let { - val diff: Decimal - - if (isReceiving) { - diff = it.receiveEnergy(it.maxEnergyStoredMattery, true) - } else { - diff = it.extractEnergy(it.energyStoredMattery, true) - } - - distribution[i] = diff - summ += distribution[i] - } - } - } - - if (!summ.isZero) { - for (i in 0 until container.containerSize) { - distribution[i] = distribution[i] / summ - } - } - - return BatteryBankDistribution(distribution, summ) - } - - private fun distributeEnergy(isReceiving: Boolean, howMuch: Decimal, simulate: Boolean, set: Boolean = false): Decimal { + private fun distributeEnergy(isReceiving: Boolean, howMuch: Decimal, simulate: Boolean): Decimal { if (!howMuch.isPositive) return Decimal.ZERO - val distribution = getDistribution(isReceiving) + val energies = ArrayList() - if (distribution.maxThroughput.isZero) - return Decimal.ZERO + for (item in container) { + if (!item.isEmpty) { + val energy = item.matteryEnergy ?: item.energy - val distList = distribution.distribution - var summ = Decimal.ZERO - - for (i in 0 until container.containerSize) { - if (!distList[i].isZero) { - val stack = container.getItem(i) - - if (!stack.isEmpty) { - stack.energy?.let { - val diff: Decimal - - if (isReceiving) { - diff = it.receiveEnergy(howMuch * distList[i], simulate) - } else { - diff = it.extractEnergy(howMuch * distList[i], simulate) - } - - summ += diff - } + if (energy != null) { + energies.add(energy) } } } - if (!simulate && !summ.isZero) { - setChangedLight() - gaugeLevel = (batteryLevel / maxBatteryLevel).toFloat() - } + if (energies.isEmpty()) + return Decimal.ZERO - return summ + if (howMuch.toInt() < energies.size || !energies.any { it is IMatteryEnergyStorage && it.transcieveEnergy(Decimal.ONE, isReceiving, true) == Decimal.ONE }) { + // sequential + var summ = Decimal.ZERO + var remaining = howMuch + + for (energy in energies) { + val diff = energy.transcieveEnergy(remaining, isReceiving, simulate) + summ += diff + remaining -= diff + + if (!remaining.isPositive) { + break + } + } + + if (!simulate && !summ.isZero) { + setChangedLight() + gaugeLevel = (batteryLevel / maxBatteryLevel).toFloat() + } + + return summ + } else { + val distribution = Array(energies.size) { Decimal.ZERO } + var summ2 = Decimal.ZERO + + for ((i, energy) in energies.withIndex()) { + val diff = energy.transcieveEnergy(howMuch, isReceiving, simulate) + distribution[i] = diff + summ2 += distribution[i] + } + + if (summ2.isPositive) { + for (i in distribution.indices) { + distribution[i] = distribution[i] / summ2 + } + } else { + return Decimal.ZERO + } + + var summ = Decimal.ZERO + var remaining = howMuch + + for ((i, energy) in energies.withIndex()) { + val diff = energy.transcieveEnergy((howMuch * distribution[i]).coerceAtMost(remaining), isReceiving, simulate) + summ += diff + remaining -= diff + + if (!remaining.isPositive) { + break + } + } + + if (remaining.isPositive) { + val diff = energies.first { it is IMatteryEnergyStorage }.transcieveEnergy(remaining, isReceiving, simulate) + summ += diff + remaining -= diff + } + + if (!simulate && !summ.isZero) { + setChangedLight() + gaugeLevel = (batteryLevel / maxBatteryLevel).toFloat() + } + + return summ + } + } + + override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { + return distributeEnergy(isReceiving = false, howMuch, simulate) } override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt index 65fe3ae74..2192faf38 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt @@ -49,6 +49,13 @@ internal fun IEnergyStorage.receiveEnergy(amount: Decimal, simulate: Boolean): D return Decimal.valueOf(receiveEnergy(amount.toInt(), simulate)) } +internal fun IEnergyStorage.transcieveEnergy(amount: Decimal, isReceiving: Boolean, simulate: Boolean): Decimal { + if (isReceiving) + return receiveEnergy(amount, simulate) + else + return extractEnergy(amount, simulate) +} + /** * Does a checked energy extraction, calls [IMatteryEnergyStorage.extractEnergyChecked] if possible */ From 1ed2eb21346e2a0c97e056408e4128d9b1466695 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 13 Mar 2023 09:43:18 +0700 Subject: [PATCH 0331/1199] Much more lenient Decimal, solving much more problems than it can potentially create --- .../dbotthepony/mc/otm/core/math/Decimal.kt | 62 ++++++------------- 1 file changed, 18 insertions(+), 44 deletions(-) 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 3e530f0c6..5d4483a41 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 @@ -149,8 +149,12 @@ fun Decimal(value: Long) = Decimal.valueOf(value) * not guaranteed to be precise (stored as [Double]). The reason behind creation of this class, however, * is to allow infinite precision of [whole] part, while leaving [decimal] part to be rounded in inexact operations. * - * This class is value based, however, [equals] and [compareTo] are not doing *exact* comparison. Whole part is always compared - * exactly, but decimal part is considered equal if their difference is less than [EPSILON]. + * This class is value based, hence it is immutable, and can not be utilized as synchronization lock, and should not be compared + * using identity (`===`) comparison. + * + * **In general, this class is lenient about precision**, to avoid gameplay-wise player frustration, rounding is placed in multiple parts of this class, + * including its constructor (e.g. it is possible to get `Decimal.ZERO == Decimal("0.00000001")`). [EPSILON] is the reference point of precision, + * any value lesser than [EPSILON] is considered zero (including difference between *the value* and (-)1.0). */ @Suppress("unused") class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0) : Number(), Comparable, java.io.Serializable { @@ -176,6 +180,13 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 init { @Suppress("name_shadowing") var decimal = decimal + + if (decimal < 1.0 && decimal + EPSILON >= 1.0) { + decimal = 1.0 + } else if (decimal > -1.0 && decimal - EPSILON <= -1.0) { + decimal = -1.0 + } + @Suppress("name_shadowing") var whole = whole @@ -553,18 +564,7 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 return false if (other is Decimal) { - return other.whole == whole && weakEqualDoubles(decimal, other.decimal) - } - - return super.equals(other) - } - - fun equalsStrict(other: Any?): Boolean { - if (isNaN) - return other is Decimal && other.isNaN // ибо hashCode() так требует - - if (other is Decimal) { - return other.whole == whole && other.decimal == decimal + return other.whole == whole && decimal == other.decimal } return super.equals(other) @@ -574,7 +574,7 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 if (isNaN) return Double.NaN.hashCode() - return 31 * (decimal - decimal % EPSILON).hashCode() + whole.hashCode() + return 31 * decimal.hashCode() + whole.hashCode() } fun floor(): Decimal { @@ -639,36 +639,10 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 else if (a > b) return 1 - if (other.whole == whole) { - return weakCompareDoubles(decimal, other.decimal) - } + var cmp = whole.compareTo(other.whole) + if (cmp == 0) cmp = decimal.compareTo(other.decimal) - return whole.compareTo(other.whole) - } - - fun compareToStrict(other: Decimal): Int { - if (isNaN) - return 1 - else if (other.isNaN) - return -1 - - val a = signum() - val b = other.signum() - - if (a < b) - return -1 - else if (a > b) - return 1 - - if (other.whole == whole) { - if (other.decimal == decimal) { - return 0 - } - - return if (other.decimal < decimal) 1 else -1 - } - - return whole.compareTo(other.whole) + return cmp } fun toByteArray(): ByteArray { From de67209d24c7c5cf38024914cd7a9f1201e9935b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 13 Mar 2023 09:47:37 +0700 Subject: [PATCH 0332/1199] Do not store minus zero in Decimal --- .../dbotthepony/mc/otm/core/math/Decimal.kt | 28 ++++--------------- 1 file changed, 6 insertions(+), 22 deletions(-) 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 5d4483a41..f6efc24fd 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 @@ -182,14 +182,17 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 var decimal = decimal if (decimal < 1.0 && decimal + EPSILON >= 1.0) { + // разница между дробью и 1 крайне мала decimal = 1.0 } else if (decimal > -1.0 && decimal - EPSILON <= -1.0) { + // разница между дробью и -1 крайне мала decimal = -1.0 } @Suppress("name_shadowing") var whole = whole + // нормализуем if (decimal <= -1f || decimal >= 1f) { val frac = decimal % 1f whole += BigInteger.valueOf((decimal - frac).toLong()) @@ -198,13 +201,8 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 // дробная часть равна или очень близка к нулю if (weakEqualDoubles(decimal, 0.0)) { - if (!isZero(whole)) { - this.decimal = 0.0 - this.whole = whole - } else { // сохраняет минус ноль - this.decimal = decimal - this.whole = whole - } + this.decimal = 0.0 + this.whole = whole // целая часть и дробная часть имеют одинаковые знаки } else if (decimal > 0.0 && whole.signum() >= 0 || decimal < 0.0 && whole.signum() <= 0) { this.decimal = decimal @@ -608,21 +606,7 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 } fun signum(): Int { - val sign = whole.signum() - - if (sign != 0) { - return sign - } - - // exactly zero - if (decimal == 0.0) - return if (1.0 / decimal > 0) 1 else -1 - - // inexactly zero - if (weakEqualDoubles(decimal, 0.0)) - return 0 - - return if (decimal > 0.0) 1 else -1 + return whole.signum() } override fun compareTo(other: Decimal): Int { From 5626ca22d8d378c2916fa4b3ddca276e9416b89e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 13 Mar 2023 10:05:20 +0700 Subject: [PATCH 0333/1199] Fix previous commit losing sign in fractional numbers --- .../kotlin/ru/dbotthepony/mc/otm/core/math/Decimal.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 f6efc24fd..8edc18204 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 @@ -605,8 +605,16 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 return BigDecimal(whole) + BigDecimal(decimal) } + private var _signum = Int.MIN_VALUE + fun signum(): Int { - return whole.signum() + if (_signum == Int.MIN_VALUE) { + var cmp = whole.signum() + if (cmp == 0) cmp = if (decimal == 0.0) 0 else if (1.0 / decimal > 0.0) 1 else -1 + _signum = cmp + } + + return _signum } override fun compareTo(other: Decimal): Int { From 0b64ffafaaf9b4ea2b5af8d9bca448b5bafd0380 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 13 Mar 2023 10:28:31 +0700 Subject: [PATCH 0334/1199] Add MtU and complexity sorting buttons --- .../mc/otm/client/render/Widgets18.kt | 2 ++ .../client/screen/matter/MatterPanelScreen.kt | 3 +++ .../textures/gui/widgets/storage_controls.png | Bin 803 -> 847 bytes .../textures/gui/widgets/storage_controls.xcf | Bin 4408 -> 5791 bytes 4 files changed, 5 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt index 09c145a92..75194029f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt @@ -42,6 +42,8 @@ object Widgets18 { val SORT_COUNT = storageGrid.next() val SORT_MODID = storageGrid.next() val SORT_ID = storageGrid.next() + val SORT_MATTER_VALUE = storageGrid.next() + val SORT_MATTER_COMPLEXITY = storageGrid.next() private val miscGrid = WidgetLocation.MISC_18.grid(4, 4) 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 b0d37957b..9f16c5b60 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 @@ -67,6 +67,9 @@ class MatterPanelScreen( it.add(ItemSorter.NAME, skinElement = Widgets18.SORT_ALPHABET, tooltip = ItemSorter.NAME.title) it.add(ItemSorter.ID, skinElement = Widgets18.SORT_ID, tooltip = ItemSorter.ID.title) it.add(ItemSorter.MOD, skinElement = Widgets18.SORT_MODID, tooltip = ItemSorter.MOD.title) + it.add(ItemSorter.MATTER_VALUE, skinElement = Widgets18.SORT_MATTER_VALUE, tooltip = ItemSorter.MATTER_VALUE.title) + it.add(ItemSorter.MATTER_COMPLEXITY, skinElement = Widgets18.SORT_MATTER_COMPLEXITY, tooltip = ItemSorter.MATTER_COMPLEXITY.title) + it.finish() } val scrollBar = DiscreteScrollBarPanel(this, frame, { diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/storage_controls.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/storage_controls.png index 9905a78ace4c217229c6ee8f66bd03428dea1164..5955c8eff8e2a38ed3a539a9918b665f847bfee1 100644 GIT binary patch delta 761 zcmV$1yloJ$T1JTqcs)APg;VzJc4au>6*p%PCMM-^40d?Dwu z!g-6cTCKBopZtZvg0_<3I@K@|SV9shh>%f71yxvx(XNqVB2DLU5C4$kPmxO|R|Sk5 z3#dVbVi9;hqi@Os1Ghl`nmf1lIZhvdEX`{91~@nb z#!8gE?(y!v?z#PYr#-(PG!k--GDy7v00006VoOIv0F$}_DSr(E7aRZo(6j&m0Zd6m zK~!ko?V4c@!ypKS+os3j_}r`eWnzdLKyY?@U$UfGEXWhc)Ex%^0K~)04>Lcz*m*10 zs>NzOL+B)ttzwrdh+G_LtM*~_Wl5lGg~&v7mhZ~5HXtH8iRdijr63l8nE9z~)%MFL zON)D@$aQc<9Dh%6@*Rzh+E?)}-_y>gm&v1;@63!IO!ar(lSf;vmez4v`9QfZbD{uq_cKXcZRdn2kjo= z>su6!kiBslJF`i(MMYRd>4`JC${N{>va@wYM^;6zN;2$ZoaWfyYr9AEeF@%1jov%Js!IR=!X$$tQ!NIc7Q!y;ZMj&E8z z=Y8TZt4Ip*Iq|qb7bJe%f76*X9h(W;SRB18KL5C5>^Pm@a~R~3vL z^Von2$?=2#!GG^=&C=AQn-od_JukNXF$x5CfmXw|zmILZbprUGfh(=!-)I6epQJZB zTJ#7Q+y*YLJDR))T$kv=JD>{?%w`A)9&vFfo*cF`dHe400006VoOIv0F$}_DSrhGI~&vf7 zi*2UJ+Bp#?Ju;@m+2> diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/storage_controls.xcf b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/storage_controls.xcf index 54ab55958412f706096ff5974c650784cd950eec..c0afe1cb225b7415257a4f7d1d11cd5641b3a22c 100644 GIT binary patch delta 1206 zcmcgrziSjh6n^t=H+#RmA2|tH7__iSxXwyUBLo!@jNLU#>?Af85k%GtSer0f$CQFa zU{y}kLu5+9xlaE8A#h-MV16*Z_huuvCWR#gyZ{C}C`+c*$lk2mq%c`|@cNo6_ z8Nn%!QPX2#&SUAT$I2a#M;1KRpLv`-?J+YqDB@euJ!RKze|pfhZ*1SbvhQqv&>gJU z9v2{h{-D;>89fut)zi+rzym+(>y=}OTlzg7jdPx)xdVYIgE9`#1cU+M9vCPXMUjG1 z1|5_s4k&wqv&^kOtB?P7gG{}12+q+Ly1P| z;?L||CXjZ!&0>w4FexV3w|0}He>r$yd$yvsv+4r!ky@+j>UlcoQy*&)5+fAD4*^GQW^ zjZ{3$|IxKyJw9Oi0U|vG=$6>I@l%kOQ*hxtIlrnG@CxReVs*aFR%3oX`HWMD#T&vF z?=xE{K1mON?uO5kFX4v5@{kgat4OLUCz8$Rro!q&sj6-WTYa5eEId_M>j+z07Pj^% pnJ%3}Y7F_aF?{cl^(Rxc-8m2V1L^ODe7l(N>nq+FX(KLB(YajpOW delta 276 zcmbQQyF+P0Iiujjiq{cK7{Gw}283p-gU}p25SsH1gywOA(0m6VGzuvMHDVPxWz1B-H6fkiokHgDuxz{te)1uV)f02bxe*xW8)$Hc^& r0T$(L0gLj^+5B6`iHV8-0a%p(4@i_#Km_Xg$vk4dlLf>)fw&(4wOl(4 From 2243b65cece7a2b6ba2449e64ed00890f4bfde89 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 13 Mar 2023 10:40:38 +0700 Subject: [PATCH 0335/1199] sigh --- .../ru/dbotthepony/mc/otm/core/math/Decimal.kt | 12 +++--------- .../ru/dbotthepony/mc/otm/tests/DecimalTests.kt | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) 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 8edc18204..3332158ed 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 @@ -558,14 +558,8 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 } override fun equals(other: Any?): Boolean { - if (isNaN) - return false - - if (other is Decimal) { - return other.whole == whole && decimal == other.decimal - } - - return super.equals(other) + if (isNaN) return false + return other === this || other is Decimal && other.whole == whole && weakEqualDoubles(decimal, other.decimal) } override fun hashCode(): Int { @@ -632,7 +626,7 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 return 1 var cmp = whole.compareTo(other.whole) - if (cmp == 0) cmp = decimal.compareTo(other.decimal) + if (cmp == 0) cmp = weakCompareDoubles(decimal, other.decimal) return cmp } diff --git a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/DecimalTests.kt b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/DecimalTests.kt index 801639431..9f27dde91 100644 --- a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/DecimalTests.kt +++ b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/DecimalTests.kt @@ -30,7 +30,7 @@ object DecimalTests { check((Decimal(0, 0.5) + Decimal(0, 0.5)) == Decimal(1)) { "0.5 + 0.5 != 1" } check((Decimal(0, 0.5) + Decimal(0, -0.5)) == Decimal(0)) { "0.5 + -0.5 != 1" } check((Decimal(0, 0.5) - Decimal(0, -0.5)) == Decimal(1)) { "0.5 - -0.5 != 1" } - check((Decimal(0, 0.3) - Decimal(1, 0.2)) == Decimal(0, -0.9)) { "0.3 - 1.2 != -0.9" } + check((Decimal(0, 0.3) - Decimal(1, 0.2)) == Decimal(0, -0.9)) { "0.3 - 1.2 != -0.9 ${Decimal(0, -0.9)} ${Decimal(0, 0.3) - Decimal(1, 0.2)}" } check((Decimal(0, 0.3) * Decimal(0, 0.3)) == Decimal(0, 0.09)) { "0.3 * 0.3 != 0.9 ${Decimal(0, 0.3) * Decimal(0, 0.3)}" } check((Decimal(2, 0.3) * Decimal(2, 0.3)) == Decimal(5, 0.29)) { "2.3 * 2.3 != 5.29 ${Decimal(2, 0.3) * Decimal(2, 0.3)}" } check((Decimal(4) / Decimal(2)) == Decimal(2)) { "4 / 2 != 2" } From 5748908ac299ab60a485231ba04bb64e8388a3d4 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 13 Mar 2023 12:34:26 +0700 Subject: [PATCH 0336/1199] tick faaaster bana-na --- .../dbotthepony/mc/otm/core/util/TickList.kt | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt index 9ffd22961..f7404d92d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt @@ -73,24 +73,31 @@ class TickList { } inTicker = true - val iterator = conditional.iterator() - for (ticker in iterator) { - if (!ticker.canTick) { - iterator.remove() - } else { - ticker.tick() + if (conditional.isNotEmpty()) { + val iterator = conditional.iterator() + + for (ticker in iterator) { + if (!ticker.canTick) { + iterator.remove() + } else { + ticker.tick() + } } } - for (ticker in once) { - ticker.tick() + if (once.isNotEmpty()) { + for (ticker in once) { + ticker.tick() + } + + once.clear() } - once.clear() - - for (ticker in always) { - ticker.tick() + if (always.isNotEmpty()) { + for (ticker in always) { + ticker.tick() + } } if (alwaysValveTime.isNotEmpty()) { From 40da26033dc64b9c5345791077f1676fa0b19853 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 13 Mar 2023 18:10:02 +0700 Subject: [PATCH 0337/1199] Essence storage, servo, capsules --- .../mc/otm/datagen/lang/English.kt | 19 ++ .../mc/otm/datagen/lang/Russian.kt | 19 ++ .../dbotthepony/mc/otm/block/MatteryBlock.kt | 2 +- .../entity/tech/EssenceStorageBlockEntity.kt | 56 ++++ .../mc/otm/block/tech/EssenceStorageBlock.kt | 39 +++ .../mc/otm/client/screen/panels/Label.kt | 15 +- .../panels/util/HorizontalStripPanel.kt | 52 ++++ .../screen/tech/EssenceStorageScreen.kt | 269 ++++++++++++++++++ .../mc/otm/core/util/ExperienceUtils.kt | 97 +++++++ .../mc/otm/core/util/Savetables.kt | 13 + .../mc/otm/item/EssenceCapsuleItem.kt | 48 ++++ .../mc/otm/item/EssenceServoItem.kt | 80 ++++++ .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 4 +- .../mc/otm/menu/tech/EssenceStorageMenu.kt | 93 ++++++ .../mc/otm/registry/CreativeTabs.kt | 2 + .../mc/otm/registry/MBlockEntities.kt | 1 + .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 2 + .../ru/dbotthepony/mc/otm/registry/MItems.kt | 16 +- .../ru/dbotthepony/mc/otm/registry/MMenus.kt | 4 + .../ru/dbotthepony/mc/otm/registry/MNames.kt | 1 + .../textures/gui/essence_storage.png | Bin 0 -> 1051 bytes .../textures/gui/essence_storage.xcf | Bin 0 -> 17933 bytes .../mc/otm/tests/ExperienceUtilsTest.kt | 124 ++++++++ 23 files changed, 951 insertions(+), 5 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EssenceStorageBlock.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/HorizontalStripPanel.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ExperienceUtils.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/item/EssenceCapsuleItem.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/item/EssenceServoItem.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/essence_storage.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/essence_storage.xcf create mode 100644 src/test/kotlin/ru/dbotthepony/mc/otm/tests/ExperienceUtilsTest.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 80b330466..e558c82c3 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -362,6 +362,7 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.DRIVE_VIEWER, "Drive Viewer") add(MBlocks.BLACK_HOLE, "Local Anomalous Singular Gravitation Field") add(MBlocks.COBBLESTONE_GENERATOR, "Cobblestone Generator") + add(MBlocks.ESSENCE_STORAGE, "Essence Storage") add(MBlocks.ENGINE, "Ship Engine") add(MBlocks.HOLO_SIGN, "Holo Sign") @@ -445,6 +446,12 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, "Indescribable Exopack Inventory Upgrade") add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, "description", "They normally generate in dungeons with appropriate NBT tag attached") + add(MItems.ESSENCE_CAPSULE, "Essence Capsule") + add(MItems.ESSENCE_DRIVE, "Essence Memory Drive") + add(MItems.ESSENCE_SERVO, "Essence Servo") + add(MItems.ESSENCE_SERVO, "desc", "Allows to 'pump' essence involving fleshy humanoids") + add(MItems.ESSENCE_SERVO, "desc2", "Can be used standalone, or as tool inside Essence Servo") + add(MItems.NUTRIENT_PASTE, "Nutrient Paste") add(MItems.BLACK_HOLE_SCANNER, "Singularity Scanner") @@ -657,6 +664,18 @@ private fun gui(provider: MatteryLanguageProvider) { gui("matter_panel.matter_stored", "Matter stored: %s") gui("matter_panel.matter_required", "Matter required: %s") gui("matter_panel.complexity", "Total complexity: %s") + + gui("experience", "%s experience points") + gui("experience_levels", "%s experience levels") + + gui("experience.store", "Store %s experience levels") + gui("experience.store_all", "Store all experience levels") + gui("experience.dispense", "Dispense %s experience levels") + gui("experience.dispense_all", "Dispense all experience levels") + gui("experience.set_exact", "Set your experience level to %s") + + gui("essence_capsule", "(Almost) Everything you ever knew is within") + gui("essence_capsule2", "This item can be recycled at Essence Servo") } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 6054bcecf..08e3317bf 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -369,6 +369,7 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.DRIVE_VIEWER, "Просмотрщик дисков конденсации") add(MBlocks.BLACK_HOLE, "Локализированное аномальное сингулярное гравитационное поле") add(MBlocks.COBBLESTONE_GENERATOR, "Генератор булыжника") + add(MBlocks.ESSENCE_STORAGE, "Хранилище эссенции") add(MBlocks.ENGINE, "Двигатель корабля") add(MBlocks.HOLO_SIGN, "Голографическая табличка") @@ -450,6 +451,12 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, "Неописуемое обновление инвентаря экзопака") add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, "description", "В нормальных условиях, они появляются в сундуках") + add(MItems.ESSENCE_CAPSULE, "Капсула эссенции") + add(MItems.ESSENCE_DRIVE, "Диск эссенции") + add(MItems.ESSENCE_SERVO, "Помпа эссенции") + add(MItems.ESSENCE_SERVO, "desc", "Позволяет 'перекачивать' эссенцию гуманоидов из плоти") + add(MItems.ESSENCE_SERVO, "desc2", "Может быть использовано напрямую, или как инструмент внутри хранилища эссенции") + add(MItems.NUTRIENT_PASTE, "Питательная паста") add(MItems.BLACK_HOLE_SCANNER, "Сканер сингулярностей") @@ -659,6 +666,18 @@ private fun gui(provider: MatteryLanguageProvider) { gui("matter_panel.matter_stored", "Материи хранится: %s") gui("matter_panel.matter_required", "Материи требуется: %s") gui("matter_panel.complexity", "Общая сложность: %s") + + gui("experience", "%s очков опыта") + gui("experience_levels", "%s уровней опыта") + + gui("experience.store", "Передать %s уровней опыта") + gui("experience.store_all", "Передать все уровни опыта") + gui("experience.dispense", "Вывести %s уровней опыта") + gui("experience.dispense_all", "Вывести все уровни опыта") + gui("experience.set_exact", "Установить уровень опыта в %s") + + gui("essence_capsule", "(Почти) Всё, что вы знали, хранится внутри") + gui("essence_capsule2", "Данный предмет может быть переработан внутри хранилища эссенции") } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt index dd0cb5212..b7f082f90 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt @@ -225,7 +225,7 @@ abstract class MatteryBlock @JvmOverloads constructor( } companion object { - val DEFAULT_PROPERTIES: Properties = Properties.of(Material.STONE, MaterialColor.METAL).requiresCorrectToolForDrops().strength(1.5f, 25.0f) + val DEFAULT_PROPERTIES: Properties = Properties.of(Material.STONE, MaterialColor.METAL).requiresCorrectToolForDrops().destroyTime(1.5f).explosionResistance(25.0f) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt new file mode 100644 index 000000000..5413f446a --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt @@ -0,0 +1,56 @@ +package ru.dbotthepony.mc.otm.block.entity.tech + +import net.minecraft.core.BlockPos +import net.minecraft.server.level.ServerPlayer +import net.minecraft.world.entity.player.Inventory +import net.minecraft.world.entity.player.Player +import net.minecraft.world.inventory.AbstractContainerMenu +import net.minecraft.world.item.ItemStack +import net.minecraft.world.level.block.state.BlockState +import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity +import ru.dbotthepony.mc.otm.container.HandlerFilter +import ru.dbotthepony.mc.otm.container.MatteryContainer +import ru.dbotthepony.mc.otm.item.EssenceCapsuleItem +import ru.dbotthepony.mc.otm.menu.tech.EssenceStorageMenu +import ru.dbotthepony.mc.otm.registry.MBlockEntities + +class EssenceStorageBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.ESSENCE_STORAGE, blockPos, blockState) { + var experienceStored = 0L + set(value) { + require(value >= 0L) { "Negative experience: $value" } + field = value + setChangedLight() + } + + val capsuleContainer = MatteryContainer(::setChangedLight, 1) + val servoContainer = MatteryContainer(::setChangedLight, 1) + + init { + savetables.long(::experienceStored) + savetables.stateful(::capsuleContainer) + savetables.stateful(::servoContainer) + } + + override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { + return EssenceStorageMenu(containerID, inventory, this) + } + + val itemConfig = ConfigurableItemHandler( + input = capsuleContainer.handler(HandlerFilter.OnlyIn.and(object : HandlerFilter { + override fun canInsert(slot: Int, stack: ItemStack): Boolean { + return stack.item is EssenceCapsuleItem + } + })) + ) + + override fun tick() { + super.tick() + + val capsule = capsuleContainer[0] + + if (!capsule.isEmpty && capsule.item is EssenceCapsuleItem) { + experienceStored += EssenceCapsuleItem.experienceStored(capsule) + capsuleContainer.clearContent() + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EssenceStorageBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EssenceStorageBlock.kt new file mode 100644 index 000000000..0d4faf442 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EssenceStorageBlock.kt @@ -0,0 +1,39 @@ +package ru.dbotthepony.mc.otm.block.tech + +import net.minecraft.core.BlockPos +import net.minecraft.world.InteractionHand +import net.minecraft.world.InteractionResult +import net.minecraft.world.entity.player.Player +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.EntityBlock +import net.minecraft.world.level.block.entity.BlockEntity +import net.minecraft.world.level.block.entity.BlockEntityTicker +import net.minecraft.world.level.block.entity.BlockEntityType +import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.phys.BlockHitResult +import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.entity.tech.EssenceStorageBlockEntity +import ru.dbotthepony.mc.otm.registry.MItems + +class EssenceStorageBlock : RotatableMatteryBlock(), EntityBlock { + override fun newBlockEntity(pPos: BlockPos, pState: BlockState): BlockEntity { + return EssenceStorageBlockEntity(pPos, pState) + } + + override fun getTicker(pLevel: Level, pState: BlockState, pBlockEntityType: BlockEntityType): BlockEntityTicker? { + if (!pLevel.isClientSide) { + return BlockEntityTicker { _, _, _, pBlockEntity -> if (pBlockEntity is EssenceStorageBlockEntity) pBlockEntity.tick() } + } + + return null + } + + @Suppress("OVERRIDE_DEPRECATION") + override fun use(blockState: BlockState, level: Level, blockPos: BlockPos, ply: Player, hand: InteractionHand, blockHitResult: BlockHitResult): InteractionResult { + if (ply.getItemInHand(hand).item == MItems.ESSENCE_SERVO) { + return MItems.ESSENCE_SERVO.useServo(ply, blockPos) + } + + return super.use(blockState, level, blockPos, ply, hand, blockHitResult) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt index 9c506ab41..16cf68597 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt @@ -3,6 +3,8 @@ package ru.dbotthepony.mc.otm.client.screen.panels import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component +import ru.dbotthepony.mc.otm.client.render.TextAlign +import ru.dbotthepony.mc.otm.client.render.drawAligned import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.math.RGBAColor @@ -27,6 +29,7 @@ open class Label @JvmOverloads constructor( } var color = RGBAColor.SLATE_GRAY + var align = TextAlign.TOP_RIGHT override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { clearDepth(stack) @@ -35,7 +38,17 @@ open class Label @JvmOverloads constructor( font.draw(stack, text, shadowX, shadowY, shadowColor.toInt()) } - font.draw(stack, text, 0f, 0f, color.toInt()) + when (align) { + TextAlign.TOP_LEFT -> font.drawAligned(stack, text, align, 0f, 0f, color.toInt()) + TextAlign.TOP_CENTER -> font.drawAligned(stack, text, align, width / 2f, 0f, color.toInt()) + TextAlign.TOP_RIGHT -> font.drawAligned(stack, text, align, width, 0f, color.toInt()) + TextAlign.CENTER_LEFT -> font.drawAligned(stack, text, align, 0f, height / 2f, color.toInt()) + TextAlign.CENTER_CENTER -> font.drawAligned(stack, text, align, width / 2f, height / 2f, color.toInt()) + TextAlign.CENTER_RIGHT -> font.drawAligned(stack, text, align, width, height / 2f, color.toInt()) + TextAlign.BOTTOM_LEFT -> font.drawAligned(stack, text, align, 0f, height, color.toInt()) + TextAlign.BOTTOM_CENTER -> font.drawAligned(stack, text, align, width / 2f, height, color.toInt()) + TextAlign.BOTTOM_RIGHT -> font.drawAligned(stack, text, align, width, height, color.toInt()) + } } override fun sizeToContents() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/HorizontalStripPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/HorizontalStripPanel.kt new file mode 100644 index 000000000..64c81c1fa --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/HorizontalStripPanel.kt @@ -0,0 +1,52 @@ +package ru.dbotthepony.mc.otm.client.screen.panels.util + +import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.screen.panels.Dock +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import kotlin.math.roundToInt + +class HorizontalStripPanel( + screen: S, + parent: EditablePanel<*>?, + x: Float = 0f, + y: Float = 0f, + width: Float = 0f, + height: Float = 0f, +) : EditablePanel(screen, parent, x, y, width, height) { + override fun sizeToContents() { + var w = 0f + var h = 0f + + for (child in children) { + if (child.dock == Dock.NONE) { + w += child.width + child.dockMargin.left + child.dockMargin.right + h = h.coerceAtLeast(child.height) + } + } + + width = w + height = h + } + + override fun performLayout() { + super.performLayout() + + var w = 0f + + for (child in children) { + if (child.dock == Dock.NONE) { + w += child.width + child.dockMargin.left + child.dockMargin.right + } + } + + w = width / 2f - w / 2f + + for (child in children) { + if (child.dock == Dock.NONE) { + child.y = (height / 2f - child.height / 2f).roundToInt().toFloat() + child.x = (w + child.dockMargin.left).roundToInt().toFloat() + w += child.dockMargin.left + child.width + child.dockMargin.right + } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt new file mode 100644 index 000000000..feba92c9b --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt @@ -0,0 +1,269 @@ +package ru.dbotthepony.mc.otm.client.screen.tech + +import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.ChatFormatting +import net.minecraft.network.chat.Component +import net.minecraft.resources.ResourceLocation +import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.client.isShiftDown +import ru.dbotthepony.mc.otm.client.render.MatteryAtlas +import ru.dbotthepony.mc.otm.client.render.TextAlign +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.Dock +import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty +import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.Label +import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeRectangleButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.input.TextInputPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.HorizontalStripPanel +import ru.dbotthepony.mc.otm.core.TextComponent +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.util.getLevelFromXp +import ru.dbotthepony.mc.otm.core.util.getTotalXpRequiredForLevel +import ru.dbotthepony.mc.otm.core.util.getXpRequiredForLevelUp +import ru.dbotthepony.mc.otm.menu.tech.EssenceStorageMenu +import ru.dbotthepony.mc.otm.registry.MItems + +class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, title) { + override fun makeMainFrame(): FramePanel> { + val frame = FramePanel.padded(this, width = DEFAULT_FRAME_WIDTH, height = 18f * 2f + 36f + 25f, title) + + val inputs = HorizontalStripPanel(this, frame, height = 18f) + inputs.dock = Dock.TOP + inputs.dockMargin = DockProperty(bottom = 3f, top = 3f) + + SlotPanel(this, inputs, menu.capsuleSlot).also { + it.dock = Dock.RIGHT + it.tooltip = MItems.ESSENCE_CAPSULE.description.copy().withStyle(ChatFormatting.GRAY) + } + + HorizontalStripPanel(this, frame, height = 18f).also { + it.dock = Dock.TOP + it.dockMargin = DockProperty(bottom = 3f) + + object : EditablePanel(this@EssenceStorageScreen, it, width = 108f, height = 15f) { + init { + dockResize = DockResizeMode.NONE + dockMargin = DockProperty(bottom = 3f) + } + + override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + BAR_BACKGROUND.render(stack, width = width, height = height) + val level = getLevelFromXp(menu.experienceStored) + val progress = (menu.experienceStored - getTotalXpRequiredForLevel(level)).toDouble() / getXpRequiredForLevelUp(level).toDouble() + BAR_FOREGROUND.renderPartial(stack, width = width * progress.toFloat(), height = height) + } + } + + SlotPanel(this, it, menu.servoSlot).also { + it.dock = Dock.RIGHT + it.tooltip = MItems.ESSENCE_SERVO.description.copy().withStyle(ChatFormatting.GRAY) + } + } + + object : Label(this@EssenceStorageScreen, frame, text = TextComponent("")) { + init { + dock = Dock.TOP + dockMargin = DockProperty(bottom = 3f) + align = TextAlign.TOP_CENTER + } + + override fun tickInner() { + super.tickInner() + + if (minecraft?.window?.isShiftDown == true) { + text = TranslatableComponent("otm.gui.experience", menu.experienceStored) + } else { + text = TranslatableComponent("otm.gui.experience_levels", getLevelFromXp(menu.experienceStored)) + } + } + } + + val outputs = HorizontalStripPanel(this, frame, width = 18f * 3 + 3f * 3, height = 18f) + outputs.dock = Dock.TOP + outputs.dockResize = DockResizeMode.NONE + outputs.dockMargin = DockProperty(bottom = 3f) + + object : LargeRectangleButtonPanel(this@EssenceStorageScreen, inputs, skinElement = STORE_1) { + init { + dockRight = 3f + tooltip = TranslatableComponent("otm.gui.experience.store", 1) + } + + override fun onClick(mouseButton: Int) { + menu.storeLevels.input(1) + } + + override var isDisabled: Boolean + get() = !menu.storeLevels.test(minecraft?.player) + set(value) {} + } + + object : LargeRectangleButtonPanel(this@EssenceStorageScreen, inputs, skinElement = STORE_10) { + init { + dockRight = 3f + tooltip = TranslatableComponent("otm.gui.experience.store", 10) + } + + override fun onClick(mouseButton: Int) { + menu.storeLevels.input(10) + } + + override var isDisabled: Boolean + get() = !menu.storeLevels.test(minecraft?.player) + set(value) {} + } + + object : LargeRectangleButtonPanel(this@EssenceStorageScreen, inputs, skinElement = STORE_ALL) { + init { + dockRight = 3f + tooltip = TranslatableComponent("otm.gui.experience.store_all") + } + + override fun onClick(mouseButton: Int) { + menu.storeLevels.input(minecraft?.player?.experienceLevel ?: 0) + } + + override var isDisabled: Boolean + get() = !menu.storeLevels.test(minecraft?.player) + set(value) {} + } + + object : LargeRectangleButtonPanel(this@EssenceStorageScreen, outputs, skinElement = DISPENSE_1) { + init { + dockRight = 3f + tooltip = TranslatableComponent("otm.gui.experience.dispense", 1) + } + + override fun onClick(mouseButton: Int) { + menu.dispenseLevels.input(1) + } + + override var isDisabled: Boolean + get() = !menu.dispenseLevels.test(minecraft?.player) + set(value) {} + } + + object : LargeRectangleButtonPanel(this@EssenceStorageScreen, outputs, skinElement = DISPENSE_10) { + init { + dockRight = 3f + tooltip = TranslatableComponent("otm.gui.experience.dispense", 10) + } + + override fun onClick(mouseButton: Int) { + menu.dispenseLevels.input(10) + } + + override var isDisabled: Boolean + get() = !menu.dispenseLevels.test(minecraft?.player) + set(value) {} + } + + object : LargeRectangleButtonPanel(this@EssenceStorageScreen, outputs, skinElement = DISPENSE_ALL) { + init { + dockRight = 3f + tooltip = TranslatableComponent("otm.gui.experience.dispense_all") + } + + override fun onClick(mouseButton: Int) { + menu.dispenseLevels.input(getLevelFromXp(menu.experienceStored) + 1) + } + + override var isDisabled: Boolean + get() = !menu.dispenseLevels.test(minecraft?.player) + set(value) {} + } + + val customBar = HorizontalStripPanel(this, frame, height = 18f) + customBar.dock = Dock.TOP + + object : LargeRectangleButtonPanel(this@EssenceStorageScreen, customBar, skinElement = STORE_CUSTOM) { + init { + tooltip = TranslatableComponent("otm.gui.experience.store", customDispense) + } + + override fun onClick(mouseButton: Int) { + menu.storeLevels.input(customDispense) + } + + override var isDisabled: Boolean + get() = !menu.storeLevels.test(minecraft?.player) + set(value) {} + } + + object : TextInputPanel(this@EssenceStorageScreen, customBar, width = 60f) { + init { + dockMargin = DockProperty(left = 3f, right = 3f) + text = customDispense.toString() + } + + override fun onTextChanged(old: String, new: String) { + customDispense = (new.toIntOrNull() ?: 30).coerceAtLeast(1) + } + } + + object : LargeRectangleButtonPanel(this@EssenceStorageScreen, customBar, skinElement = DISPENSE_CUSTOM) { + init { + tooltip = TranslatableComponent("otm.gui.experience.dispense", customDispense) + } + + override fun onClick(mouseButton: Int) { + menu.dispenseLevels.input(customDispense) + } + + override var isDisabled: Boolean + get() = !menu.dispenseLevels.test(minecraft?.player) + set(value) {} + } + + object : LargeRectangleButtonPanel(this@EssenceStorageScreen, customBar, skinElement = SET_EXACT) { + init { + tooltip = TranslatableComponent("otm.gui.experience.set_exact", customDispense) + dock = Dock.RIGHT + dockMargin = DockProperty(right = 4f) + } + + override fun onClick(mouseButton: Int) { + val player = minecraft?.player ?: return + + if (player.experienceLevel == customDispense) { + if (player.experienceProgress > 0f) { + menu.storeLevels.input(1) + } + } else if (player.experienceLevel > customDispense) { + menu.storeLevels.input(player.experienceLevel - customDispense) + } else { + menu.dispenseLevels.input(customDispense - player.experienceLevel) + } + } + + override var isDisabled: Boolean + get() = !menu.dispenseLevels.test(minecraft?.player) && !menu.storeLevels.test(minecraft?.player) + set(value) {} + } + + return frame + } + + companion object { + private var customDispense = 30 + + val ATLAS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/essence_storage.png"), 108f, 66f) + val STORE_1 = ATLAS.sprite(width = 18f, height = 18f) + val STORE_10 = ATLAS.sprite(x = 18f, width = 18f, height = 18f) + val STORE_ALL = ATLAS.sprite(x = 18f * 2, width = 18f, height = 18f) + val DISPENSE_1 = ATLAS.sprite(x = 18f * 3, width = 18f, height = 18f) + val DISPENSE_10 = ATLAS.sprite(x = 18f * 4, width = 18f, height = 18f) + val DISPENSE_ALL = ATLAS.sprite(x = 18f * 5, width = 18f, height = 18f) + val BAR_BACKGROUND = ATLAS.sprite(y = 18f, height = 15f) + val BAR_FOREGROUND = ATLAS.sprite(y = 18f + 15f, height = 15f) + + val STORE_CUSTOM = ATLAS.sprite(width = 18f, height = 18f, y = 48f) + val DISPENSE_CUSTOM = ATLAS.sprite(width = 18f, height = 18f, y = 48f, x = 18f) + val SET_EXACT = ATLAS.sprite(width = 18f, height = 18f, y = 48f, x = 18f * 2f) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ExperienceUtils.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ExperienceUtils.kt new file mode 100644 index 000000000..5d979d0f4 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ExperienceUtils.kt @@ -0,0 +1,97 @@ +package ru.dbotthepony.mc.otm.core.util + +import it.unimi.dsi.fastutil.longs.LongArrayList +import net.minecraft.world.entity.player.Player + +private val levelsTable = LongArrayList() +private val totalLevelsTable = LongArrayList().also { it.add(0L) } + +private fun calculate(level: Int): Long { + return if (level >= 30) { + 112L + (level - 30) * 9L + } else { + if (level >= 15) 37L + (level - 15) * 5L else 7L + level * 2L + } +} + +/** + * Experience points required for leveling **up from** specified [level]. + * + * Works exactly like [Player.getXpNeededForNextLevel], + * meaning that to achieve `level + 1` player need to acquire [getXpRequiredForLevelUp] experience points + */ +fun getXpRequiredForLevelUp(level: Int): Long { + require(level >= 0) { "Negative level: $level" } + + if (levelsTable.size <= level) { + synchronized(levelsTable) { + while (levelsTable.size <= level) { + levelsTable.add(calculate(levelsTable.size)) + } + } + } + + return levelsTable.getLong(level) +} + +/** + * Experience points required for achieving **exact** [level] specified. + * + * Example: + * * 0 level -> 0 points (because player starts at level 0) + * * 1 level -> [getXpRequiredForLevelUp]`(0)` + * * 2 level -> [getXpRequiredForLevelUp]`(0)` + [getXpRequiredForLevelUp]`(1)` + * * and so on + */ +fun getTotalXpRequiredForLevel(level: Int): Long { + require(level >= 0) { "Negative level: $level" } + + if (totalLevelsTable.size <= level) { + synchronized(totalLevelsTable) { + while (totalLevelsTable.size <= level) { + totalLevelsTable.add(totalLevelsTable.getLong(totalLevelsTable.size - 1) + getXpRequiredForLevelUp(totalLevelsTable.size - 1)) + } + } + } + + return totalLevelsTable.getLong(level) +} + +/** + * Determines current level from [experience] points provided + */ +fun getLevelFromXp(experience: Long): Int { + require(experience >= 0L) { "Negative experience: $experience" } + + if (totalLevelsTable.getLong(totalLevelsTable.size - 1) < experience) { + synchronized(totalLevelsTable) { + while (totalLevelsTable.getLong(totalLevelsTable.size - 1) < experience) { + totalLevelsTable.add(totalLevelsTable.getLong(totalLevelsTable.size - 1) + getXpRequiredForLevelUp(totalLevelsTable.size - 1)) + } + } + } + + var bottom = 0 + var top = totalLevelsTable.size - 1 + + while (top - bottom > 4) { + val middle = bottom + (top - bottom) / 2 + val middleValue = totalLevelsTable.getLong(middle) + + if (middleValue == experience) { + return middle + } else if (middleValue > experience) { + top = middle - 1 + } else { + bottom = middle + 1 + } + } + + for (i in bottom + 1 .. top) { + if (totalLevelsTable.getLong(i) > experience) { + return i - 1 + } + } + + return top +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt index 000799c2c..acc1b2845 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt @@ -6,6 +6,7 @@ import net.minecraft.nbt.DoubleTag import net.minecraft.nbt.FloatTag import net.minecraft.nbt.IntTag import net.minecraft.nbt.ListTag +import net.minecraft.nbt.LongTag import net.minecraft.nbt.NumericTag import net.minecraft.nbt.StringTag import net.minecraft.nbt.Tag @@ -126,6 +127,18 @@ class Savetables : INBTSerializable { .withDeserializer { it.asInt } } + fun long(prop: GetterSetter, name: String): Stateless { + return Stateless(prop, name, NumericTag::class.java) + .withSerializer { LongTag.valueOf(it) } + .withDeserializer { it.asLong } + } + + fun long(prop: KMutableProperty0, name: String = prop.name): Stateless { + return Stateless(prop, name, NumericTag::class.java) + .withSerializer { LongTag.valueOf(it) } + .withDeserializer { it.asLong } + } + fun bool(prop: GetterSetter, name: String): Stateless { return Stateless(prop, name, NumericTag::class.java) .withSerializer { ByteTag.valueOf(it) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EssenceCapsuleItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EssenceCapsuleItem.kt new file mode 100644 index 000000000..922a37662 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EssenceCapsuleItem.kt @@ -0,0 +1,48 @@ +package ru.dbotthepony.mc.otm.item + +import net.minecraft.ChatFormatting +import net.minecraft.network.chat.Component +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.Rarity +import net.minecraft.world.item.TooltipFlag +import net.minecraft.world.level.Level +import ru.dbotthepony.mc.otm.client.isShiftDown +import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.core.tagNotNull +import ru.dbotthepony.mc.otm.core.util.getLevelFromXp +import ru.dbotthepony.mc.otm.runIfClient + +class EssenceCapsuleItem : Item(Properties().stacksTo(1).rarity(Rarity.UNCOMMON)) { + override fun appendHoverText(pStack: ItemStack, pLevel: Level?, pTooltipComponents: MutableList, pIsAdvanced: TooltipFlag) { + super.appendHoverText(pStack, pLevel, pTooltipComponents, pIsAdvanced) + pTooltipComponents.add(TranslatableComponent("otm.gui.essence_capsule").withStyle(ChatFormatting.GRAY)) + pTooltipComponents.add(TranslatableComponent("otm.gui.essence_capsule2").withStyle(ChatFormatting.GRAY)) + + if (runIfClient(false) { minecraft.window.isShiftDown }) { + pTooltipComponents.add(TranslatableComponent("otm.gui.experience", experienceStored(pStack)).withStyle(ChatFormatting.GRAY)) + } else { + pTooltipComponents.add(TranslatableComponent("otm.gui.experience_levels", getLevelFromXp(experienceStored(pStack))).withStyle(ChatFormatting.GRAY)) + } + } + + fun make(experience: Long): ItemStack { + return ItemStack(this, 1).also { + setExperience(it, experience) + } + } + + companion object { + @JvmStatic + fun setExperience(itemStack: ItemStack, experience: Long) { + itemStack.tagNotNull["experience"] = experience + } + + @JvmStatic + fun experienceStored(itemStack: ItemStack): Long { + return (itemStack.tag?.getLong("experience") ?: 0L) * itemStack.count + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EssenceServoItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EssenceServoItem.kt new file mode 100644 index 000000000..f6417fdc8 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EssenceServoItem.kt @@ -0,0 +1,80 @@ +package ru.dbotthepony.mc.otm.item + +import net.minecraft.ChatFormatting +import net.minecraft.core.BlockPos +import net.minecraft.network.chat.Component +import net.minecraft.server.level.ServerPlayer +import net.minecraft.world.InteractionResult +import net.minecraft.world.entity.player.Player +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.TooltipFlag +import net.minecraft.world.item.context.UseOnContext +import net.minecraft.world.level.Level +import ru.dbotthepony.mc.otm.block.entity.tech.EssenceStorageBlockEntity +import ru.dbotthepony.mc.otm.core.TranslatableComponent + +class EssenceServoItem : Item(Properties().stacksTo(64)) { + override fun appendHoverText(pStack: ItemStack, pLevel: Level?, pTooltipComponents: MutableList, pIsAdvanced: TooltipFlag) { + super.appendHoverText(pStack, pLevel, pTooltipComponents, pIsAdvanced) + pTooltipComponents.add(TranslatableComponent("$descriptionId.desc2").withStyle(ChatFormatting.GRAY)) + pTooltipComponents.add(TranslatableComponent("$descriptionId.desc").withStyle(ChatFormatting.DARK_GRAY)) + } + + fun useServo(player: Player, pos: BlockPos): InteractionResult { + val block = player.level.getBlockEntity(pos) ?: return InteractionResult.FAIL + + // TODO: опыт как жидкость + if (block is EssenceStorageBlockEntity) { + if (player.level.isClientSide) return InteractionResult.SUCCESS + if (player !is ServerPlayer) return InteractionResult.FAIL + + if (player.isCrouching) { // выгружаем в блок + storeLevel(player, block) + } else { // выгружаем из блока + dispenseLevel(player, block) + } + + return InteractionResult.SUCCESS + } + + return InteractionResult.FAIL + } + + override fun useOn(pContext: UseOnContext): InteractionResult { + val player = pContext.player ?: return InteractionResult.FAIL + return useServo(player, pContext.clickedPos) + } + + companion object { + @JvmStatic + fun storeLevel(player: ServerPlayer, block: EssenceStorageBlockEntity) { + val fpoints = (player.experienceProgress * player.xpNeededForNextLevel).toInt() + + if (fpoints > 0) { + block.experienceStored += fpoints + player.setExperiencePoints(0) + } else if (player.experienceLevel > 0) { + player.setExperienceLevels(player.experienceLevel - 1) + block.experienceStored += player.xpNeededForNextLevel + player.setExperiencePoints(0) // для надёжности + } + } + + @JvmStatic + fun dispenseLevel(player: ServerPlayer, block: EssenceStorageBlockEntity) { + val fpoints = (player.experienceProgress * player.xpNeededForNextLevel).toInt() + val missingPoints = player.xpNeededForNextLevel - fpoints + val diff = block.experienceStored.coerceAtMost(missingPoints.toLong()).toInt() + + if (diff == missingPoints) { + player.setExperienceLevels(player.experienceLevel + 1) + player.setExperiencePoints(0) + } else { + player.setExperiencePoints(fpoints + diff) + } + + block.experienceStored -= diff + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index cf2c8d18b..be6448075 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -31,6 +31,7 @@ import ru.dbotthepony.mc.otm.core.util.BinaryStringCodec import ru.dbotthepony.mc.otm.core.util.BooleanValueCodec import ru.dbotthepony.mc.otm.core.util.IStreamCodec import ru.dbotthepony.mc.otm.core.util.NullValueCodec +import ru.dbotthepony.mc.otm.core.util.VarIntValueCodec import ru.dbotthepony.mc.otm.menu.widget.AbstractWidget import ru.dbotthepony.mc.otm.network.FieldSynchronizer import ru.dbotthepony.mc.otm.network.MatteryPacket @@ -92,7 +93,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( context.enqueueWork { val menu = context.sender?.containerMenu as? MatteryMenu ?: return@enqueueWork - if (menu.containerId != containerId) return@enqueueWork + if (menu.containerId != containerId || !menu.stillValid(context.sender!!)) return@enqueueWork val input = menu.playerInputs.getOrNull(inputId) ?: return@enqueueWork if (!input.test(context.sender)) return@enqueueWork input.invoke(input.codec.read(DataInputStream(FastByteArrayInputStream(payload)))) @@ -149,6 +150,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( fun bigDecimalInput(allowSpectators: Boolean = false, handler: (BigDecimal) -> Unit) = PlayerInput(BigDecimalValueCodec, allowSpectators, handler) fun booleanInput(allowSpectators: Boolean = false, handler: (Boolean) -> Unit) = PlayerInput(BooleanValueCodec, allowSpectators, handler) fun stringInput(allowSpectators: Boolean = false, handler: (String) -> Unit) = PlayerInput(BinaryStringCodec, allowSpectators, handler) + fun intInput(allowSpectators: Boolean = false, handler: (Int) -> Unit) = PlayerInput(VarIntValueCodec, allowSpectators, handler) /** * inventory + exosuit + hotbar (in this order) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt new file mode 100644 index 000000000..c3b8a6bf3 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt @@ -0,0 +1,93 @@ +package ru.dbotthepony.mc.otm.menu.tech + +import net.minecraft.server.level.ServerPlayer +import net.minecraft.world.SimpleContainer +import net.minecraft.world.entity.player.Inventory +import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.block.entity.tech.EssenceStorageBlockEntity +import ru.dbotthepony.mc.otm.capability.itemsStream +import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.core.util.LongValueCodec +import ru.dbotthepony.mc.otm.core.util.getTotalXpRequiredForLevel +import ru.dbotthepony.mc.otm.item.EssenceCapsuleItem +import ru.dbotthepony.mc.otm.item.EssenceServoItem +import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.registry.MItems +import ru.dbotthepony.mc.otm.registry.MMenus + +class EssenceStorageMenu @JvmOverloads constructor( + containerID: Int, + inventory: Inventory, + tile: EssenceStorageBlockEntity? = null +) : MatteryMenu(MMenus.ESSENCE_STORAGE, containerID, inventory, tile) { + val experienceStored by mSynchronizer.ComputedField(getter = { tile?.experienceStored ?: 0L }, LongValueCodec) + + val capsuleSlot = object : MatterySlot(tile?.capsuleContainer ?: SimpleContainer(1), 0) { + override fun mayPlace(itemStack: ItemStack): Boolean { + return itemStack.item is EssenceCapsuleItem && super.mayPlace(itemStack) + } + } + + val servoSlot = object : MatterySlot(tile?.servoContainer ?: SimpleContainer(1), 0) { + override fun mayPlace(itemStack: ItemStack): Boolean { + return itemStack.item == MItems.ESSENCE_SERVO && super.mayPlace(itemStack) + } + } + + val storeLevels = intInput { + if (it > 0) { + val ply = ply as ServerPlayer + tile!! + + if (it == 1) { + EssenceServoItem.storeLevel(ply, tile) + } else { + if (ply.experienceProgress > 0f) { + EssenceServoItem.storeLevel(ply, tile) + } + + if (ply.experienceLevel > 0) { + val old = ply.experienceLevel + val new = (old - it).coerceAtLeast(0) + + tile.experienceStored += getTotalXpRequiredForLevel(old) - getTotalXpRequiredForLevel(new) + ply.setExperienceLevels(new) + } + } + } + } + + val dispenseLevels = intInput { + if (it > 0) { + val ply = ply as ServerPlayer + tile!! + + if (it == 1) { + EssenceServoItem.dispenseLevel(ply, tile) + } else { + var i = 0 + + while (i++ < it && tile.experienceStored > 0L) { + EssenceServoItem.dispenseLevel(ply, tile) + } + } + } + } + + init { + storeLevels.filter { + it.isCreative || it.matteryPlayer?.isAndroid == true || servoSlot.item.item == MItems.ESSENCE_SERVO //|| it.itemsStream(true).anyMatch { it.item == MItems.ESSENCE_SERVO } + } + + dispenseLevels.filter { + it.isCreative || it.matteryPlayer?.isAndroid == true || servoSlot.item.item == MItems.ESSENCE_SERVO //|| it.itemsStream(true).anyMatch { it.item == MItems.ESSENCE_SERVO } + } + + dispenseLevels.filter { (tile?.experienceStored ?: experienceStored) > 0L } + + addStorageSlot(capsuleSlot) + addStorageSlot(servoSlot) + addInventorySlots() + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt index 266c0cad7..42a065f10 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt @@ -132,6 +132,8 @@ internal fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { accept(MItems.BLACK_HOLE) accept(MItems.GRAVITATIONAL_DISRUPTOR) + accept(MItems.ESSENCE_SERVO) + energized(MItems.ALL_BATTERIES) mattery(MItems.MATTER_CAPACITORS) accept(MItems.PATTERN_DRIVE_NORMAL) 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 b0e1e28c5..68fa57c9c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt @@ -56,6 +56,7 @@ object MBlockEntities { val MATTER_RECYCLER: BlockEntityType by registry.register(MNames.MATTER_RECYCLER) { BlockEntityType.Builder.of(::MatterRecyclerBlockEntity, MBlocks.MATTER_RECYCLER).build(null) } val ENERGY_SERVO: BlockEntityType by registry.register(MNames.ENERGY_SERVO) { BlockEntityType.Builder.of(::EnergyServoBlockEntity, MBlocks.ENERGY_SERVO).build(null) } val COBBLESTONE_GENERATOR: BlockEntityType by registry.register(MNames.COBBLESTONE_GENERATOR) { BlockEntityType.Builder.of(::CobblerBlockEntity, MBlocks.COBBLESTONE_GENERATOR).build(null) } + val ESSENCE_STORAGE: BlockEntityType by registry.register(MNames.ESSENCE_STORAGE) { BlockEntityType.Builder.of(::EssenceStorageBlockEntity, MBlocks.ESSENCE_STORAGE).build(null) } val STORAGE_BUS: BlockEntityType by registry.register(MNames.STORAGE_BUS) { BlockEntityType.Builder.of(::StorageBusBlockEntity, MBlocks.STORAGE_BUS).build(null) } val STORAGE_IMPORTER: BlockEntityType by registry.register(MNames.STORAGE_IMPORTER) { BlockEntityType.Builder.of(::StorageImporterBlockEntity, MBlocks.STORAGE_IMPORTER).build(null) } 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 416ea502f..b18d5965b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -64,6 +64,7 @@ import ru.dbotthepony.mc.otm.block.storage.StorageExporterBlock import ru.dbotthepony.mc.otm.block.storage.StorageImporterBlock import ru.dbotthepony.mc.otm.block.storage.StoragePowerSupplierBlock import ru.dbotthepony.mc.otm.block.tech.CobblerBlock +import ru.dbotthepony.mc.otm.block.tech.EssenceStorageBlock import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.collect.SupplierList import java.util.function.Supplier @@ -91,6 +92,7 @@ object MBlocks { val MATTER_RECYCLER: Block by registry.register(MNames.MATTER_RECYCLER) { MatterRecyclerBlock() } val ENERGY_SERVO: Block by registry.register(MNames.ENERGY_SERVO) { EnergyServoBlock() } val COBBLESTONE_GENERATOR: Block by registry.register(MNames.COBBLESTONE_GENERATOR) { CobblerBlock() } + val ESSENCE_STORAGE: EssenceStorageBlock by registry.register(MNames.ESSENCE_STORAGE) { EssenceStorageBlock() } val STORAGE_BUS: Block by registry.register(MNames.STORAGE_BUS) { StorageBusBlock() } val STORAGE_IMPORTER: Block by registry.register(MNames.STORAGE_IMPORTER) { StorageImporterBlock() } 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 12854b3d2..ed3e6a8bb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -4,7 +4,6 @@ package ru.dbotthepony.mc.otm.registry import net.minecraft.ChatFormatting import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation -import net.minecraft.tags.BlockTags import net.minecraft.world.entity.EquipmentSlot import net.minecraft.world.food.FoodProperties import net.minecraft.world.item.* @@ -101,13 +100,22 @@ object MItems { } } + val ESSENCE_STORAGE: BlockItem by registry.register(MNames.ESSENCE_STORAGE) { + object : BlockItem(MBlocks.ESSENCE_STORAGE, DEFAULT_PROPERTIES) { + override fun appendHoverText(p_40572_: ItemStack, p_40573_: Level?, p_40574_: MutableList, p_40575_: TooltipFlag) { + super.appendHoverText(p_40572_, p_40573_, p_40574_, p_40575_) + p_40574_.add(TranslatableComponent("$descriptionId.desc").withStyle(ChatFormatting.GRAY)) + } + } + } + val MACHINES = SupplierList( ::ANDROID_STATION, ::BATTERY_BANK, ::MATTER_DECOMPOSER, ::MATTER_CAPACITOR_BANK, ::MATTER_CABLE, ::PATTERN_STORAGE, ::MATTER_SCANNER, ::MATTER_PANEL, ::MATTER_REPLICATOR, ::MATTER_BOTTLER, ::ENERGY_COUNTER, ::CHEMICAL_GENERATOR, ::PLATE_PRESS, ::MATTER_RECYCLER, ::STORAGE_BUS, ::STORAGE_IMPORTER, ::STORAGE_EXPORTER, ::DRIVE_VIEWER, ::DRIVE_RACK, ::ITEM_MONITOR, ::STORAGE_CABLE, ::STORAGE_POWER_SUPPLIER, ::ENERGY_SERVO, ::PHANTOM_ATTRACTOR, - ::GRAVITATION_STABILIZER, ::COBBLESTONE_GENERATOR + ::GRAVITATION_STABILIZER, ::COBBLESTONE_GENERATOR, ::ESSENCE_STORAGE ) val DEBUG_EXPLOSION_SMALL: Item by registry.register(MNames.DEBUG_EXPLOSION_SMALL) { BlockItem(MBlocks.DEBUG_EXPLOSION_SMALL, Item.Properties().stacksTo(64)) } @@ -134,6 +142,10 @@ object MItems { val TRITANIUM_INGOT_BLOCK: BlockItem by registry.register(MNames.TRITANIUM_INGOT_BLOCK) { BlockItem(MBlocks.TRITANIUM_INGOT_BLOCK, DEFAULT_PROPERTIES) } val TRITANIUM_BARS: BlockItem by registry.register(MNames.TRITANIUM_BARS) { BlockItem(MBlocks.TRITANIUM_BARS, DEFAULT_PROPERTIES) } + val ESSENCE_SERVO: EssenceServoItem by registry.register("essence_servo") { EssenceServoItem() } + val ESSENCE_CAPSULE: EssenceCapsuleItem by registry.register("essence_capsule") { EssenceCapsuleItem() } + val ESSENCE_DRIVE: EssenceCapsuleItem by registry.register("essence_drive") { EssenceCapsuleItem() } + val TRITANIUM_COMPONENT: ForgeTier = ForgeTier( Tiers.IRON.level, 3072, 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 ca87fe476..3c3d70b9e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt @@ -31,6 +31,7 @@ import ru.dbotthepony.mc.otm.client.screen.tech.ChemicalGeneratorScreen import ru.dbotthepony.mc.otm.client.screen.tech.CobblerScreen import ru.dbotthepony.mc.otm.client.screen.tech.EnergyCounterScreen import ru.dbotthepony.mc.otm.client.screen.tech.EnergyServoScreen +import ru.dbotthepony.mc.otm.client.screen.tech.EssenceStorageScreen import ru.dbotthepony.mc.otm.client.screen.tech.PlatePressScreen import ru.dbotthepony.mc.otm.menu.decorative.CargoCrateMenu import ru.dbotthepony.mc.otm.menu.decorative.HoloSignMenu @@ -56,6 +57,7 @@ import ru.dbotthepony.mc.otm.menu.tech.ChemicalGeneratorMenu import ru.dbotthepony.mc.otm.menu.tech.CobblerMenu import ru.dbotthepony.mc.otm.menu.tech.EnergyCounterMenu import ru.dbotthepony.mc.otm.menu.tech.EnergyServoMenu +import ru.dbotthepony.mc.otm.menu.tech.EssenceStorageMenu import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu object MMenus { @@ -82,6 +84,7 @@ object MMenus { val ENERGY_SERVO: MenuType<*> by registry.register(MNames.ENERGY_SERVO) { MenuType(::EnergyServoMenu) } val HOLO_SIGN: MenuType by registry.register(MNames.HOLO_SIGN) { MenuType(::HoloSignMenu) } val COBBLESTONE_GENERATOR: MenuType by registry.register(MNames.COBBLESTONE_GENERATOR) { MenuType(::CobblerMenu) } + val ESSENCE_STORAGE: MenuType by registry.register(MNames.ESSENCE_STORAGE) { MenuType(::EssenceStorageMenu) } val STORAGE_BUS: MenuType<*> by registry.register(MNames.STORAGE_BUS) { MenuType(::StorageBusMenu) } val STORAGE_EXPORTER: MenuType<*> by registry.register(MNames.STORAGE_EXPORTER) { MenuType(::StorageExporterMenu) } @@ -121,6 +124,7 @@ object MMenus { MenuScreens.register(ENERGY_SERVO as MenuType, ::EnergyServoScreen) MenuScreens.register(HOLO_SIGN, ::HoloSignScreen) MenuScreens.register(COBBLESTONE_GENERATOR, ::CobblerScreen) + MenuScreens.register(ESSENCE_STORAGE, ::EssenceStorageScreen) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index 8425a98f6..02bfadbcd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -32,6 +32,7 @@ object MNames { const val MATTER_RECYCLER = "matter_recycler" const val ENERGY_SERVO = "energy_servo" const val COBBLESTONE_GENERATOR = "cobblestone_generator" + const val ESSENCE_STORAGE = "essence_storage" const val TRITANIUM_ANVIL = "tritanium_anvil" const val STORAGE_CABLE = "storage_cable" // нужен рецепт diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/essence_storage.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/essence_storage.png new file mode 100644 index 0000000000000000000000000000000000000000..e98895aac5658293a46910a28c4025af3f6d71e8 GIT binary patch literal 1051 zcmV+$1mydPP)EX>4Tx04R}tkv&MmP!xqvQ>7v;9qb??n4vmZ5EXHhDi*;)X)CnqVDi#GXws0R zxHt-~1qXi?s}3&Cx;nTDg5VE`tBaGOih|h_~4Qi11k?XR{Z=6dG3p_JoWYhD+5n{2_#c~(3vY`@B6Gs(QqkJLf zvch?bvs$gQcAxx(!GgAu;X2hY5?DeKDTt6!M+H?_h|#W*Vj@lFaS#8H<4=)GCRYWF z91EyHh2;3b|KRs*&EnLgn-q)#y)U-?F$x5BfmXw|zmILZbprUGfh(=!uQh?$PtqG5 zEqVlmw}Ff6jwbH`mpj1VlP(#OBl)R>Vi9;hqi@Os1Ghl`nmf1lIZhvdEX`{91~@nb z#!8gE?(y!v?z#PYr#-(PG!k--GDy7v00006VoOIv0Nwyw09#YmGim?;010qNS#tmY z3ljhU3ljkVnw%H_000McNliru=K~E2A`@K1p}znC0vJg|K~#9!?VLSI13?sk-$+g% z7D6HjcCm>F2E2u(jUK|>!6qIemL9_{f@ot3Dx~FhLih|77=;5+NhX+lv|wRyC*Fo@^*8URU8pf zR2VH0dMT`EU!mvfijxYXeFdEhdGC0>)U8yQEumGCoGMP8(n4gpK2s*Ec45V0U?w(Z zX|TmvYagu+JW0EJp*A~t3VN=>UWQ z!Vm_{2=lFxK!pLq5C#YXgdq$7005vRCX1n-EQZmyrN{H7_C1zo+c+t{PcOGbGco@; zNu3a86NI!(g%x66uRs4T=>;N|4)|wV zqO1MU8fy?{TRKumi;=aOO;y$J(g(ah+_o{Ms4`|*rZdbYCPo%lIvRj25dZ*c;1}q} VZzz%Df*t?>002ovPDHLkV1j?5$MOIG literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/essence_storage.xcf b/src/main/resources/assets/overdrive_that_matters/textures/gui/essence_storage.xcf new file mode 100644 index 0000000000000000000000000000000000000000..e5f6ecdae18ff3124a7e4af547132154aa78353e GIT binary patch literal 17933 zcmeI4Pi)*r6~|}oY`1otx^+Ve+N5mK5ILJTtW(mURBMNXR0tW-YdDcQu`zO!Dh{Z* z;J8R|U=I`!aG|h>OA!)jMM?~6fJ@8X)*O(K;DC^P=#2wXWJO&*Z~pC!{oCN(-@%LY zoAujyGjHB_=Ka3&X7cl!%rCtBO6k?vxzg7wlaq?H2%Qs#^h4+gD3{}F3>t+F5AbzR z*T~nC(4*(RixNcI3+;klfc9Bl+I!op>O?Az`$x~`U2Zf)$#Wzn9l6vWF$ns?BP{8jG z_~C#r1^n)S9|?GwvGgxVz$Cx#FjRpGkjSL}PgtHz%XhU%@XtuS>~g-#KtUK}OZ!dezM*P$wZ2Y&>q=OKn5OjS+tc4V{XtHk`)d^G zZ?#cerN7k&1dKA3`4NOHg`r(2<~c_|BNeeg6`M8AlBaYGf0{GbnpU=@-aFv{sx=xbie zLIyzSx6p5)-`Y?t)K&|9)~l>pBnDp63jGLbTVQpx`6HayTLA0-3{6x|IPH z`W`AFbkKLmLf_#HeSl^Fra`rcL1c#!Up0!ay4Uh~`czYCPaVqiGyA8p zz)s_5x~f;voA0IiR8wic_hzP_**}d1b{ao+6}@;M)u)N5|z=$a9dqpONI=m&m)6ea&C+YU$ll^AEurrn}Or-`;r3i^5*tFpbEB z+G+oEoA=hRZ7PklDc;V=aQZaE2;tt1Xb(!5qPktL1?o z5Ns5^{gF38@-9W*{*1=aYSgF$@S-Dpj$`;+-`W{ z65G*l0V|TEeumJI*tp%6Bt~wJB^OaAW0jfc+4z__YCG~#44n_BW6Z?R`H(sWK7xiV5SU;&{HpKiDbPI_NWHy8YdgX`}iC2!;f{q(xCg_{^L1seV?Px<8x1WuV zC#1F`AH^5?P(#M716h4|tB*Vs39}*iwV+!_tRk}sBVd^gUPK4Of+r+iIbsX+kw@2% zL^CoIO(4yWS7t+Uai6jti@be~W3iiWa}D72(lh$z!P7L6C7g#O^^34#HLz_k7 z>Axh%s5)(!l!UWdc`8Iif=RlfUugFF%QdBNg|d3c3YHstQM{@KRLJ5BnJsuN<)j`pBbeh@Fmp z4FL*2R)0W@?nW`2#4@v~+pATK!m*55-?Z}gul!XkkuV!>XBBh{W>aT2;T5f*A7+EZ zD@SaBKJw@qVm9<^h}rnD`q@M`wU|v}nc29DUW~%Aj9K6N^0&eK#W0aD8}5n~bPHxv zWH#Z2v7jGjgTyOGY=J)V=o(@+^lOOO__6xg_{APB{LOsi2>dR?nEUte{?RR4n>oD8 zGIJ+)+0-QU)8=;A45{anyZhIO?PluxmXU1J<~H@~1Q}IR@4I@rMF|!(McyWG3*sf( zBz{5sf%pNvx%l-Ht?ytV%DQZmtVCIXvhuXPM{KmB0_e+1Xp>-HFfUk-H@67G{&bGONJab9C?sInEGM#X5?O%=~--M^L96x<>GAcgvl&k&UcyjpR zFzYrnyqmke>!jO7mqQc1xeX=o{7$-EtkGU$i{6|=4?M4vZWnp9@AcUJuZ=sGa@`L70L2Q>@T^WRF4QFZPCxC0G9F32LPnNAkS_cr wD7fic$Xxi7k-Z@1aLKiyeBqy_^1{EJaCum@0#eKQpS1##W+x%}&otD30d|Uql>h($ literal 0 HcmV?d00001 diff --git a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/ExperienceUtilsTest.kt b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/ExperienceUtilsTest.kt new file mode 100644 index 000000000..cf617fc77 --- /dev/null +++ b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/ExperienceUtilsTest.kt @@ -0,0 +1,124 @@ +package ru.dbotthepony.mc.otm.tests + +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.DisplayName +import org.junit.jupiter.api.Test +import ru.dbotthepony.mc.otm.core.util.getLevelFromXp +import ru.dbotthepony.mc.otm.core.util.getTotalXpRequiredForLevel +import ru.dbotthepony.mc.otm.core.util.getXpRequiredForLevelUp + +object ExperienceUtilsTest { + @Test + @DisplayName("Experience utils xp required for level up") + fun levelUp() { + var i = 0 + assertEquals(7L, getXpRequiredForLevelUp(i++)) + assertEquals(9L, getXpRequiredForLevelUp(i++)) + assertEquals(11L, getXpRequiredForLevelUp(i++)) + assertEquals(13L, getXpRequiredForLevelUp(i++)) + assertEquals(15L, getXpRequiredForLevelUp(i++)) + assertEquals(17L, getXpRequiredForLevelUp(i++)) + assertEquals(19L, getXpRequiredForLevelUp(i++)) + assertEquals(21L, getXpRequiredForLevelUp(i++)) + assertEquals(23L, getXpRequiredForLevelUp(i++)) + assertEquals(25L, getXpRequiredForLevelUp(i++)) + assertEquals(27L, getXpRequiredForLevelUp(i++)) + assertEquals(29L, getXpRequiredForLevelUp(i++)) + assertEquals(31L, getXpRequiredForLevelUp(i++)) + assertEquals(33L, getXpRequiredForLevelUp(i++)) + assertEquals(35L, getXpRequiredForLevelUp(i++)) + assertEquals(37L, getXpRequiredForLevelUp(i++)) + assertEquals(42L, getXpRequiredForLevelUp(i++)) + assertEquals(47L, getXpRequiredForLevelUp(i++)) + assertEquals(52L, getXpRequiredForLevelUp(i++)) + assertEquals(57L, getXpRequiredForLevelUp(i++)) + assertEquals(62L, getXpRequiredForLevelUp(i++)) + assertEquals(67L, getXpRequiredForLevelUp(i++)) + assertEquals(72L, getXpRequiredForLevelUp(i++)) + assertEquals(77L, getXpRequiredForLevelUp(i++)) + assertEquals(82L, getXpRequiredForLevelUp(i++)) + assertEquals(87L, getXpRequiredForLevelUp(i++)) + assertEquals(92L, getXpRequiredForLevelUp(i++)) + assertEquals(97L, getXpRequiredForLevelUp(i++)) + assertEquals(102L, getXpRequiredForLevelUp(i++)) + assertEquals(107L, getXpRequiredForLevelUp(i++)) + assertEquals(112L, getXpRequiredForLevelUp(i++)) + assertEquals(121L, getXpRequiredForLevelUp(i++)) + assertEquals(130L, getXpRequiredForLevelUp(i++)) + assertEquals(139L, getXpRequiredForLevelUp(i++)) + assertEquals(148L, getXpRequiredForLevelUp(i++)) + assertEquals(157L, getXpRequiredForLevelUp(i++)) + assertEquals(166L, getXpRequiredForLevelUp(i++)) + assertEquals(175L, getXpRequiredForLevelUp(i++)) + assertEquals(184L, getXpRequiredForLevelUp(i++)) + assertEquals(193L, getXpRequiredForLevelUp(i++)) + } + + @Test + @DisplayName("Experience utils total xp required for level") + fun totalXp() { + var i = 1 + assertEquals(7L, getTotalXpRequiredForLevel(i++)) // 1 + assertEquals(16L, getTotalXpRequiredForLevel(i++)) // 2 + assertEquals(27L, getTotalXpRequiredForLevel(i++)) // 3 + assertEquals(40L, getTotalXpRequiredForLevel(i++)) // 4 + assertEquals(55L, getTotalXpRequiredForLevel(i++)) // 5 + assertEquals(72L, getTotalXpRequiredForLevel(i++)) // 6 + assertEquals(91L, getTotalXpRequiredForLevel(i++)) // 7 + assertEquals(112L, getTotalXpRequiredForLevel(i++)) // 8 + assertEquals(135L, getTotalXpRequiredForLevel(i++)) // 9 + assertEquals(160L, getTotalXpRequiredForLevel(i++)) // 10 + assertEquals(187L, getTotalXpRequiredForLevel(i++)) // 11 + assertEquals(216L, getTotalXpRequiredForLevel(i++)) // 12 + assertEquals(247L, getTotalXpRequiredForLevel(i++)) // 13 + assertEquals(280L, getTotalXpRequiredForLevel(i++)) // 14 + assertEquals(315L, getTotalXpRequiredForLevel(i++)) // 15 + assertEquals(352L, getTotalXpRequiredForLevel(i++)) // 16 + assertEquals(394L, getTotalXpRequiredForLevel(i++)) // 17 + assertEquals(441L, getTotalXpRequiredForLevel(i++)) // 18 + assertEquals(493L, getTotalXpRequiredForLevel(i++)) // 19 + assertEquals(550L, getTotalXpRequiredForLevel(i++)) // 20 + assertEquals(612L, getTotalXpRequiredForLevel(i++)) // 21 + assertEquals(679L, getTotalXpRequiredForLevel(i++)) // 22 + assertEquals(751L, getTotalXpRequiredForLevel(i++)) // 23 + assertEquals(828L, getTotalXpRequiredForLevel(i++)) // 24 + assertEquals(910L, getTotalXpRequiredForLevel(i++)) // 25 + assertEquals(997L, getTotalXpRequiredForLevel(i++)) // 26 + assertEquals(1089L, getTotalXpRequiredForLevel(i++)) // 27 + assertEquals(1186L, getTotalXpRequiredForLevel(i++)) // 28 + assertEquals(1288L, getTotalXpRequiredForLevel(i++)) // 29 + assertEquals(1395L, getTotalXpRequiredForLevel(i++)) // 30 + assertEquals(1507L, getTotalXpRequiredForLevel(i++)) // 31 + assertEquals(1628L, getTotalXpRequiredForLevel(i++)) // 32 + assertEquals(1758L, getTotalXpRequiredForLevel(i++)) // 33 + assertEquals(1897L, getTotalXpRequiredForLevel(i++)) // 34 + assertEquals(2045L, getTotalXpRequiredForLevel(i++)) // 35 + assertEquals(2202L, getTotalXpRequiredForLevel(i++)) // 36 + assertEquals(2368L, getTotalXpRequiredForLevel(i++)) // 37 + assertEquals(2543L, getTotalXpRequiredForLevel(i++)) // 38 + assertEquals(2727L, getTotalXpRequiredForLevel(i++)) // 39 + assertEquals(2920L, getTotalXpRequiredForLevel(i++)) // 40 + } + + @Test + @DisplayName("Experience utils reverse search xp -> level") + fun reverseSearch() { + assertEquals(0, getLevelFromXp(4L)) + assertEquals(0, getLevelFromXp(6L)) + assertEquals(1, getLevelFromXp(7L)) + assertEquals(1, getLevelFromXp(8L)) + + assertEquals(19, getLevelFromXp(540L)) + assertEquals(19, getLevelFromXp(545L)) + assertEquals(20, getLevelFromXp(550L)) + assertEquals(21, getLevelFromXp(551L)) + assertEquals(21, getLevelFromXp(554L)) + assertEquals(21, getLevelFromXp(556L)) + + for (i in 50 .. 100) { + assertEquals(i, getLevelFromXp(getTotalXpRequiredForLevel(i))) + assertEquals(i - 1, getLevelFromXp(getTotalXpRequiredForLevel(i) - 1L)) + assertEquals(i, getLevelFromXp(getTotalXpRequiredForLevel(i) + 1L)) + } + } +} From 398bff70b88582063816a1aec1a77bb606814abe Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 13 Mar 2023 18:15:47 +0700 Subject: [PATCH 0338/1199] Add loottables, advancement and mineable tag to essence stuff --- .../otm/datagen/advancements/AdvancementData.kt | 16 ++++++++++++++++ .../mc/otm/datagen/loot/LootTablesData.kt | 1 + .../ru/dbotthepony/mc/otm/datagen/tags/Tags.kt | 1 + 3 files changed, 18 insertions(+) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt index 5ac77cd56..f63082661 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt @@ -537,4 +537,20 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .addCriterion("pill3", criterion(MItems.PILL_HUMANE)) .addCriterion("pill4", criterion(MItems.PILL_OBLIVION)) .save(serializer, modLocation("regular/all_pills"), existingFileHelper) + + AdvancementBuilder() + .parent(root) + .display( + itemStack = ItemStack(MItems.ESSENCE_CAPSULE), + title = translation.add("essence_capsule", "Forgot To Forget") { + russian("Я забыл забыть") + }, + description = translation.add("essence_capsule.desc", "Recover Essence Capsule. Memories...") { + russian("Верните капсулу эссенции. Воспоминания...") + }, + ) + .requirements(RequirementsStrategy.OR) + .addCriterion("essence1", criterion(MItems.ESSENCE_CAPSULE)) + .addCriterion("essence2", criterion(MItems.ESSENCE_DRIVE)) + .save(serializer, modLocation("regular/essence_capsule"), existingFileHelper) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index e86310f86..456b343df 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -136,6 +136,7 @@ fun addLootTables(lootTables: LootTables) { } lootTables.tile(MBlocks.COBBLESTONE_GENERATOR) + lootTables.tile(MBlocks.ESSENCE_STORAGE) lootTables.tile(MBlocks.ENERGY_SERVO) lootTables.tile(MBlocks.ENERGY_COUNTER) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index 4e24d9fd4..aaf8e4147 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -171,6 +171,7 @@ fun addTags(tagsProvider: TagsProvider) { MBlocks.ENGINE, MBlocks.HOLO_SIGN, MBlocks.COBBLESTONE_GENERATOR, + MBlocks.ESSENCE_STORAGE, ), Tiers.IRON) tagsProvider.requiresPickaxe(MBlocks.TRITANIUM_ANVIL, Tiers.IRON) From a49316000bc50a1b5949d7ccc8213daf59bb66e1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 13 Mar 2023 18:58:06 +0700 Subject: [PATCH 0339/1199] Functional essence capsule drops! --- .../mc/otm/datagen/lang/English.kt | 2 +- .../mc/otm/datagen/lang/Russian.kt | 2 +- .../mc/otm/mixin/MixinLivingEntity.java | 59 +++++++++++++++++++ .../dbotthepony/mc/otm/config/ServerConfig.kt | 21 +++++++ .../mc/otm/item/EssenceCapsuleItem.kt | 4 +- 5 files changed, 84 insertions(+), 4 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index e558c82c3..9391e8d34 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -447,7 +447,7 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, "description", "They normally generate in dungeons with appropriate NBT tag attached") add(MItems.ESSENCE_CAPSULE, "Essence Capsule") - add(MItems.ESSENCE_DRIVE, "Essence Memory Drive") + add(MItems.ESSENCE_DRIVE, "Essence Memory Holotape") add(MItems.ESSENCE_SERVO, "Essence Servo") add(MItems.ESSENCE_SERVO, "desc", "Allows to 'pump' essence involving fleshy humanoids") add(MItems.ESSENCE_SERVO, "desc2", "Can be used standalone, or as tool inside Essence Servo") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 08e3317bf..e385cdf2e 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -452,7 +452,7 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, "description", "В нормальных условиях, они появляются в сундуках") add(MItems.ESSENCE_CAPSULE, "Капсула эссенции") - add(MItems.ESSENCE_DRIVE, "Диск эссенции") + add(MItems.ESSENCE_DRIVE, "Голодиск воспоминаний андроида") add(MItems.ESSENCE_SERVO, "Помпа эссенции") add(MItems.ESSENCE_SERVO, "desc", "Позволяет 'перекачивать' эссенцию гуманоидов из плоти") add(MItems.ESSENCE_SERVO, "desc2", "Может быть использовано напрямую, или как инструмент внутри хранилища эссенции") diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java index 8f4aae057..338337d93 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java @@ -2,12 +2,22 @@ package ru.dbotthepony.mc.otm.mixin; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraftforge.event.ForgeEventFactory; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import ru.dbotthepony.mc.otm.capability.MatteryCapability; +import ru.dbotthepony.mc.otm.config.ServerConfig; +import ru.dbotthepony.mc.otm.core.util.ExperienceUtilsKt; import ru.dbotthepony.mc.otm.registry.MItems; +import java.util.Random; + +@SuppressWarnings("ConstantConditions") @Mixin(LivingEntity.class) public class MixinLivingEntity { @Inject( @@ -27,4 +37,53 @@ public class MixinLivingEntity { hook.setReturnValue(false); } } + + @Shadow Player lastHurtByPlayer; + + @Inject( + method = "dropExperience()V", + at = @At("HEAD"), + cancellable = true) + public void dropExperience(CallbackInfo hook) { + if (((Object) this) instanceof Player player && ServerConfig.INSTANCE.getDROP_EXPERIENCE_CAPSULES()) { + player.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresent(it -> { + hook.cancel(); + + long totalExperience = ExperienceUtilsKt.getTotalXpRequiredForLevel(player.experienceLevel); + totalExperience += (long) (player.experienceProgress * player.getXpNeededForNextLevel()); + + double min = ServerConfig.INSTANCE.getMIN_EXPERIENCE_DROPPED(); + double max = ServerConfig.INSTANCE.getMAX_EXPERIENCE_DROPPED(); + + if (min == max) { + totalExperience *= min; + } else { + if (min > max) { + min = 0.4; + max = 0.8; + } + + totalExperience *= new Random().nextDouble(min, max); + } + + if (totalExperience >= Integer.MAX_VALUE) { + int hooked = ForgeEventFactory.getExperienceDrop(player, lastHurtByPlayer, Integer.MAX_VALUE); + + if (hooked != Integer.MAX_VALUE) { + totalExperience = hooked; + } + } else { + totalExperience = ForgeEventFactory.getExperienceDrop(player, lastHurtByPlayer, (int) totalExperience); + } + + if (totalExperience > 0L) { + if (it.isAndroid()) { + player.drop(MItems.INSTANCE.getESSENCE_DRIVE().make(totalExperience), true, false); + } else { + player.drop(MItems.INSTANCE.getESSENCE_CAPSULE().make(totalExperience), true, false); + } + } + }); + } + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt index c1f3e2783..686a85282 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt @@ -19,4 +19,25 @@ import ru.dbotthepony.mc.otm.registry.MNames object ServerConfig : AbstractConfig("misc") { val LABORATORY_LAMP_LIGHT_LENGTH: Int by builder.comment("In blocks").defineInRange("LABORATORY_LAMP_LIGHT_LENGTH", 6, 1, 128) val INFINITE_EXOSUIT_UPGRADES: Boolean by builder.comment("Allows to apply the same upgrade over and over again.", "Obviously completely breaks balance.").define("INFINITE_EXOSUIT_UPGRADES", false) + + init { + builder.push("EXPERIENCE_CAPSULES") + } + + val DROP_EXPERIENCE_CAPSULES: Boolean by builder + .comment("Whenever to replace regular player experience drops with experience capsules") + .comment("These capsules can be collected by gravestone mods, and are not limited in experience they can contain") + .define("ENABLED", true) + + val MIN_EXPERIENCE_DROPPED: Double by builder + .comment("Minimal percent of experience dropped on death into capsules") + .defineInRange("MINIMAL_PERCENT", 0.4, 0.0, 1.0) + + val MAX_EXPERIENCE_DROPPED: Double by builder + .comment("Maximal percent of experience dropped on death into capsules") + .defineInRange("MAXIMAL_PERCENT", 0.8, 0.0, 1.0) + + init { + builder.pop() + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EssenceCapsuleItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EssenceCapsuleItem.kt index 922a37662..8ba7a3c00 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EssenceCapsuleItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EssenceCapsuleItem.kt @@ -18,8 +18,8 @@ import ru.dbotthepony.mc.otm.runIfClient class EssenceCapsuleItem : Item(Properties().stacksTo(1).rarity(Rarity.UNCOMMON)) { override fun appendHoverText(pStack: ItemStack, pLevel: Level?, pTooltipComponents: MutableList, pIsAdvanced: TooltipFlag) { super.appendHoverText(pStack, pLevel, pTooltipComponents, pIsAdvanced) - pTooltipComponents.add(TranslatableComponent("otm.gui.essence_capsule").withStyle(ChatFormatting.GRAY)) - pTooltipComponents.add(TranslatableComponent("otm.gui.essence_capsule2").withStyle(ChatFormatting.GRAY)) + pTooltipComponents.add(TranslatableComponent("otm.gui.essence_capsule").withStyle(ChatFormatting.DARK_GRAY)) + pTooltipComponents.add(TranslatableComponent("otm.gui.essence_capsule2").withStyle(ChatFormatting.DARK_GRAY)) if (runIfClient(false) { minecraft.window.isShiftDown }) { pTooltipComponents.add(TranslatableComponent("otm.gui.experience", experienceStored(pStack)).withStyle(ChatFormatting.GRAY)) From c67add64e60cb7126f9bfc6c767ee70440dff66e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 13 Mar 2023 19:05:03 +0700 Subject: [PATCH 0340/1199] Add missing essence storage description --- src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt | 1 + src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt | 1 + 2 files changed, 2 insertions(+) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 9391e8d34..2e8e1c4ec 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -363,6 +363,7 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.BLACK_HOLE, "Local Anomalous Singular Gravitation Field") add(MBlocks.COBBLESTONE_GENERATOR, "Cobblestone Generator") add(MBlocks.ESSENCE_STORAGE, "Essence Storage") + add(MBlocks.ESSENCE_STORAGE, "desc", "Allows to store and retrieve experience levels") add(MBlocks.ENGINE, "Ship Engine") add(MBlocks.HOLO_SIGN, "Holo Sign") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index e385cdf2e..451628da2 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -370,6 +370,7 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.BLACK_HOLE, "Локализированное аномальное сингулярное гравитационное поле") add(MBlocks.COBBLESTONE_GENERATOR, "Генератор булыжника") add(MBlocks.ESSENCE_STORAGE, "Хранилище эссенции") + add(MBlocks.ESSENCE_STORAGE, "desc", "Позволяет хранить очки опыта") add(MBlocks.ENGINE, "Двигатель корабля") add(MBlocks.HOLO_SIGN, "Голографическая табличка") From a54104638ab2ec067aab5e766e80ecc528823d55 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 13 Mar 2023 19:27:08 +0700 Subject: [PATCH 0341/1199] Recipes for essence storage and essence servo --- .../mc/otm/datagen/recipes/CraftingTableRecipes.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index ad428b70c..5b471d904 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -283,4 +283,16 @@ fun addCraftingTableRecipes(consumer: Consumer) { .unlockedBy(MItemTags.TRITANIUM_INGOTS) .unlockedBy(MItemTags.TRITANIUM_NUGGETS) .save(consumer, modLocation("ingot_from_nuggets")) + + MatteryRecipe(MItems.ESSENCE_STORAGE, category = machinesCategory) + .row(MItems.MATTER_CAPACITOR_PARTS, Items.ENDER_EYE, MItemTags.ADVANCED_CIRCUIT) + .row(MItemTags.TRITANIUM_PLATES, MItems.MACHINE_FRAME, MItemTags.TRITANIUM_PLATES) + .row(MItemTags.GOLD_WIRES, MItemTags.HARDENED_GLASS, MItemTags.HARDENED_GLASS) + .build(consumer) + + MatteryRecipe(MItems.ESSENCE_SERVO, category = RecipeCategory.TOOLS) + .row(MItemTags.TRITANIUM_PLATES, MItems.QUANTUM_TRANSCEIVER, MItemTags.TRITANIUM_PLATES) + .rowB(Tags.Items.RODS_WOODEN) + .rowB(Tags.Items.RODS_WOODEN) + .build(consumer) } From 95989fb101cd9cbc1ac8ecf9bf160f5e73ba0c96 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Mon, 13 Mar 2023 19:12:04 +0600 Subject: [PATCH 0342/1199] Fatter mirror corners and darker vent overlay --- .../decorative/vent_alternative_overlay.png | Bin 236 -> 157 bytes .../textures/block/decorative/vent_overlay.png | Bin 371 -> 221 bytes .../textures/item/component/mirror.png | Bin 244 -> 238 bytes .../textures/item/component/mirror_compound.png | Bin 247 -> 240 bytes 4 files changed, 0 insertions(+), 0 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_overlay.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_overlay.png index b68a652162dd5fc1d93624acd9e3c52f8289c412..4fe72658809de14a0589afc63744e30199e30b3c 100644 GIT binary patch delta 78 zcmaFEIG1rkn7fgui(`m|f3gJY3I{*GclJ{{g%_+&Y`K(h;OJ4;3k(83zP*+1vU}AS isL#Wu&*OUF00YDM*&m9-X delta 158 zcmV;P0Ac@~0qg;gR)2v>L_t(IPwkOQ3cw%?MC0!mx^O2hy#Hy$YY3VWs|5>%LhGW? zw{b#7m?7{pECfQ$A;pnWcF{vx+>!Z6hk3U^PZNjM8>OJb tEl;JRKVSc#T*>z6FMmK~SF>7(`28u&-RCSfvI8w(@O1TaS?83{1OR)KGZg>; delta 296 zcmcc1_?c;fW4&L1Pl&66f`W{UjI^}0tgNh}qN1dvq`0`agoK2Mh={1DsF0A5n3$NZ zuCA7rmY$xToSdALl$55Xrna`Wj*gDJyu7fmu)4asl9G~!h6V!zL${2kA&`RUkI_D5p#8UZqdsVuH$-rhD~qVky(wq4Gyp_yYg$}h5EM(wg$^Z==YX2&97*< aw$IZ~@BsVFXm_CN89ZJ6T-G@yGywo{pKpEu diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/component/mirror.png b/src/main/resources/assets/overdrive_that_matters/textures/item/component/mirror.png index a89a6dadfc146eb3c1c309aac08354e0a6f7aadc..f3175d283971fcc9e057cafffc98fb3ea59c238c 100644 GIT binary patch delta 111 zcmV-#0FeLm0qy~ihG_H(I07${0J*!=zCem|)VZ6h51#ic8>UlOD$fZ7B6S^W8oyu@=!Uym7%^u+F0mw7% R*ChY|002ovPDHLkV1hy|FH`^k delta 117 zcmV-*0E++a0rUZohHhC&L_t(2Q&o>!4gett1J%O)ue>dC-10uqn=InK&cx2QY9 zyAtxgiG))C5P~8`nkA|uIXftZTMU=5W;`Rt+GHRfwc+Z}h(c*Zij^4og Date: Mon, 13 Mar 2023 19:31:59 +0600 Subject: [PATCH 0343/1199] Texture updates --- .../block/decorative/danger_stripe_block.png | Bin 402 -> 180 bytes .../block/decorative/laboratory_lamp_front.png | Bin 420 -> 307 bytes .../decorative/laboratory_lamp_front_off.png | Bin 415 -> 303 bytes .../block/decorative/tritanium_block.png | Bin 429 -> 206 bytes .../block/decorative/tritanium_block_white.png | Bin 413 -> 207 bytes .../decorative/tritanium_striped_block.png | Bin 434 -> 207 bytes .../tritanium_striped_block_colorless_base.png | Bin 434 -> 203 bytes .../block/decorative/vent_alternative_white.png | Bin 468 -> 229 bytes .../textures/block/decorative/vent_white.png | Bin 520 -> 250 bytes .../block/resource/tritanium_ingot_block.png | Bin 417 -> 246 bytes 10 files changed, 0 insertions(+), 0 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/danger_stripe_block.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/danger_stripe_block.png index d01e2e4c8130b3ee8c1e24d063f4ced92d5e34df..c292cfe09f96a4676092fd898fa00a7c3e6792b8 100644 GIT binary patch delta 135 zcmbQlyoGUs1SbnK0|Ud`yN`kCn2Ka=y9@`QwCnqN+CKeT|*#?y4EbxddW?dA^qVuzo$x!^V935Y*F8Nmg>bhEZ{I< kYiARr(X78V>F91;=|A0HnR6BEF$QOmhp z9UUDS8X6D~5W%lfAt50V5fLOLBx;;ZWdHyG32;bRa{vGizW@LZzX3P}QzQTY0KR`o zL_t(2Qx%Uva)dAp1Vo5CIbxxrNDOaXa<%nj;zEyL-6Y#+C~qe|6t#|Q^;D=&Ku?I6*i}*@fB4EUv#*AO zN^(lC5vb$)+K4@|{D002ovPDHLk FV1oA5ih2M5 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/laboratory_lamp_front.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/laboratory_lamp_front.png index dfc103e87f5455b75dc1c61333db3f804d97b5db..be33b5c4d17e4590cf54f8b3718ab2a1eed23118 100644 GIT binary patch delta 250 zcmV=GSX(fZ2$kSGg+jmJ1-Hj0doT^W~7(u$a4P~(z55rlm$_6+#NQCPF)5K z&9zhC#@cVNp=U6|`5(R9kGp_Z*WqV*uVn8RK80Tf`aAD#(EtDd07*qoM6N<$f&d0$ AA^-pY delta 364 zcmV-y0h9i-0;B_wL4SKtOjJcIEG#rMG*eSkR8&+|RaH__QaCs`Gcz+$QBhD(P)$uu zHa0dXDJd2f78Mm07Z(>RD=RH6Ehs1`6ciK~7#JrfCpR}YFE1}oPfsc;DiaeEH8nL( zPEP;-|J&Q!CMG5^F)>R^OIKG{R#sLnE-o@MG8q{eJv}`-I)6G{R-?-R000SaNLh0L z01m$Z01m$aI0aKA00028Nkl3uITj1cc%Cnbj)?0jDf zAAJ}e_wx-@%_TsHtjkc9u#yXTt`YG$d+00NuP##fZz2}qQ~d{s#1fbkmN9Jr0000< KMNUMnLSTXftcG9! diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/laboratory_lamp_front_off.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/laboratory_lamp_front_off.png index c1f603efe216b06144ed5a89b5cc91ef63d72b36..3aaa9fa92794eb062d449f7eefd2d6a348cde27c 100644 GIT binary patch delta 246 zcmVq5wt6G00009a7bBm000iZ000iZ0XPLyBme*a ze@R3^R47wjkKq!7FbIPqp_SS>-QNFU4YhYW_x&m~q-D>KDGQ?D{dCwEI&~Q|G}lf& w#@ajB&@-6f_>W$m$DP2Z>+qv|H?sE=7cBS&OxO_^od5s;07*qoM6N<$f@UXN5dZ)H delta 359 zcmV-t0hs=;0-pnrL4SBqOjJcIEG#rMG*eSkR8&+|RaH__QaCs`Gcz+$QBhD(P)$uu zHa0dXDJd2f78Mm07Z(>RD=RH6Ehs1`6ciK~7#JrfCpR}YFE1}oPfsc;DiaeEH8nL( zPEH;k9wsIxF)=YqOG{T*S5{V5E-o%IGBOz%89hBcIyyRVh<~Q<00009a7bBm000iZ z000iZ0XPLyBme*aut`KgR47wD%-e3mAP_~-!{7;w&9xyZ*zPT9(*OU%VhLrx%`E8v ziuA;EGFE8j#lcMQA*PJCb14_OLcgnAvQ%N`lW7`u%^U9@y=oW49X1B?qq+14ub+JQ zkxeT>=Q_Nn9bn-r%kZ8w1=C&=-tS4_8#K6Q+Yff{WVo*>&gj=`q?UMt4fn0`;nVbc zKi@#jTq1e2#H~1SbnK0|Ud`yN`kzopr05z06LI3~& delta 386 zcmV-|0e$|?0j&d&7zqdi0000eEe}(XAs~NvP)t-sOIl=HZh2X2c3W+DU2l3|a(!BC zcV2LNUvYd0jbn9yO8 z+ROXDVfn>@Gap05DG5V!%EsnzWag#TvXt_^t8gKf()I>12j>PO`#7{CCkAlp7@2q> z>@+m6fJY~;E6xUko@Ta-&}Y3m!i#QOjGK{v9e}KgJKW_VBxP@=J)VZb!-$`&AQ`|x ze6y%nMMa^0caa%~SHqLVz+RCjD1ZO(B{qhfA)AoOFOHE&-NkR7$vn?7{>Gf!9L7v7 g8l-awPtN`N545=n$d27|vH$=807*qoM6N<$g5AubLI3~& diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_block_white.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_block_white.png index 528e7c752c1e1797b978b8cc5aac387e40cb488a..5b194ea7d0e5aacdb0509531eef80a936002f98f 100644 GIT binary patch delta 163 zcmbQse4cTF1SbnK0|Ud`yN`ko!Gi~D*RK8l|9|6dzxzOW&H|6f zVg?4j{UFR}!5XXr6!h_QaSV~TT-tY#x50piS$3DhI-P(S4PAfBl_Q>Z+FRbV(&U;W zaywE|qg}=5%Ihme+ZZpOD7B@4a z`HeOyd)w3#fDQ%TRbpKL8=21V(}Z5cc_AH^v`UqMj|)b1WO#)N8ttwQ59}yX8Qwnm z#fVgP=HcRJ;UoX2jnJ%17oHM7%6#T QbpQYW07*qoM6N<$f>x`+l>h($ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_striped_block.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_striped_block.png index 66118acc715e6870d93870c27941f76f821d52fe..93324432bd8790d1d04e7615bf232737d3189b7a 100644 GIT binary patch delta 163 zcmdnQe4cTF1SbnK0|Ud`yN`kNN(Wl>;iPhMzkf{##NX<%}FIz~-mbboGxka32S zS!;H0gpq52jckFAX?}~xwOGlwTEwzd#j{qxu2IOgS;n+i%D7v?uv5daR8wMXViSL- z>;M1&32;bRa{vGizyJUazyWI3i3tDz0K-W{K~yMH9gb0Q!Y~j+cfBhm!4&EmD1q8Z zos!=FhV}GMdLwBhqQM+WSL)zn_wLhlh*LbqOOaUhNZ4gc}G8=QV_DuMM;2?xL?4B8zvMAI1xZR##kLNtkP|0vO ziD0=Oq>3Wz-C$!cBD+edWm(s?ez&F6tv2~tODpZQ?cFY~(qwJhR!ePV-@0tO;QumB loz}-GzdFpFbo4-CdicqN;inue>Z}Q`r=*}Tb81R331F~pctw&n!5BhS#m+Q sB%G9Z=EU<9w_)9dHuK|0HtP-I0nnNXGECle0ssI207*qoM6N<$g3O{lc>n+a delta 391 zcmV;20eJq)0kQ*-7zqdi0000eEe}(XAs~NsP)t-st*x!z-rm^Q*x}*f+uPgR+}zR8 z(bw14+1c5!u&~|T-H3>Yi;Ihjii(MeiGqTHhlhvX-{0EW+OMy#s;a81tE>F{{P_6z zsi~>f*4DAHvEt(5|NsAnhK8=LuKxc1;NalZ)z!4Lw5+VGva+(Xv$LqEsN#F7`~ZId z010qNS#tmY4!-~Z4!;371ydvd0072GL_t(2Qw`8dLc=f&08z=7(5FeM<)+lZxIhx_ ze?+pF?OO~0rj&{En=Q3KnE6^aI0wM;&Xe%eI@1JM3eu1M0ILd$oEDfMqkYeHo!Gi~D*RK8l|G%7^92XbYy{`Sc zfvPwQJR*x37`XXBn9*V1Lr0)sjHioZh{WaEzJt6C20YAjeFRo>hv@P+G}U>E%$NBU3w+0U}+SaxN@@crHanW6HYasx^OkGzAIZboPB?@ lW%i+|dQTZ=xZO9`$t#fLclvF3U@Oof22WQ%mvv4FO#rd^ND}}6 delta 405 zcmV;G0c!r`0n`JK7zqdi0000eEe}(XAs~N^P)t-sudlD$+uPjS+_12)+1c6M-QCyM z*WTXVv9Yn(*w}=Gg#Z8l{{H^`{r!rHim9oo+S=N)v$KYVhKGlTiHV7bh={JPu8WI{ zjEsyeEiJ9Btt>1o9v&VbARrkT85$ZI92^`YBO@UpAt@;-{QUeYD=Qlt8yy`TA0HPV zjg5`8w6v?MtE{Z7va+(()z!&7N^g-|7=O@7L_t(2Qx%TeQo}F|1?5YK6D2}KvYi%( z2HGaQ0RR7anDe+ZJ9_|(b-sD=t+6&V9-wQW_lN`HXzA59z;A>&iBc3CB(#teW6UIx zbQUBB%y>xu0^;!<*nmMQ%SSn_%jZ`i*H)mKdm_?lRsjz@$Qkf5;&5?SId;%sE@s1m%5H3Gn@tov!V&~b%6l_-H3d=x{Fs^D*b=XI^z~g6aNDD#YPC>ScHz4o zo~DFiAr{FQ3ePkc)+R7>889xL!6G3c(KyX%&Or?ZhGceG*YoQxoB>+O;OXk;vd$@? F2>`sVKz;xK delta 478 zcmV<40U`eS0f+>U7zqdi0000eEe}(XAs~OTP)t-suCA`!+}zvS+uGXN-QC^T*x0M9 ztJl}p-{0S`u&~+L+1A$9hlhv%|Ns8}{`~y>h=_=)s;Y~Ni~arm9v&VY9UUJZA0Z(j ziHV7=t*wNFgcTJP7#J8A7Z(&16c!d1C@3f_EG#Q4D;gRaudlBY6B7~=60)+g92|cf zDJdx`Dk?24EiNuDARr(c8yguJ84(c?CnqN_FE1q}B_bjsjEsz|tgMQPinFt`v9Yn< z-rgTM9^e1~010qNS#tmY3l0DP3l0H5zTrUt007`gL_t(2Qw@;oa)K}z1y8<6HL(H2 z1WU<9L{W%}_O9>$VCDDOnVmfVV<3OdXGA=CnJ)z7QoJ&iDwQdoulO8c6}eu+Eg>}G`M=2op(2H!Ld*qZH9P{_m9s~3kFG(Cb&w`w{_WNlqluOqD000SaNLh0L01FNP01FNQK)&HY0001FNklP*oz>%yGcYrR47vwj$3xbFbG3Q6WvHvxeaQH#e z5tnFsndg*<(sE0*WXffI-R^75+g@sUC))9Gpn(O@Rwtr6x+oM3HCPB6!exznFo!U2 zmmkYls4w(s;BiF30SH&8^ffTTm(gPM;671Wqe3tgjnN*#bILXGlOe6ol#Mk45VX*H zrlm%iigK_)%;~vnfe3?n)C(+^pcK&yzQIy-ShfCrb~AgNKTebTuhY%{G9`D<|5=L> Uj!oXQzW@LL07*qoM6N<$g7gBWSO5S3 From be56aaae0c23e33059b24c4d2c961a30131d63d3 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Mon, 13 Mar 2023 19:48:13 +0600 Subject: [PATCH 0344/1199] Paint tritanium block and vents --- .../block/decorative/tritanium_block_black.png | Bin 456 -> 422 bytes .../block/decorative/tritanium_block_blue.png | Bin 546 -> 422 bytes .../block/decorative/tritanium_block_brown.png | Bin 527 -> 422 bytes .../block/decorative/tritanium_block_cyan.png | Bin 555 -> 422 bytes .../block/decorative/tritanium_block_gray.png | Bin 519 -> 422 bytes .../block/decorative/tritanium_block_green.png | Bin 531 -> 422 bytes .../decorative/tritanium_block_light_blue.png | Bin 577 -> 422 bytes .../decorative/tritanium_block_light_gray.png | Bin 551 -> 422 bytes .../block/decorative/tritanium_block_lime.png | Bin 565 -> 422 bytes .../decorative/tritanium_block_magenta.png | Bin 570 -> 422 bytes .../block/decorative/tritanium_block_orange.png | Bin 574 -> 422 bytes .../block/decorative/tritanium_block_pink.png | Bin 573 -> 422 bytes .../block/decorative/tritanium_block_purple.png | Bin 555 -> 422 bytes .../block/decorative/tritanium_block_red.png | Bin 537 -> 422 bytes .../block/decorative/tritanium_block_yellow.png | Bin 577 -> 422 bytes .../block/decorative/vent_alternative_black.png | Bin 499 -> 229 bytes .../block/decorative/vent_alternative_blue.png | Bin 591 -> 229 bytes .../block/decorative/vent_alternative_brown.png | Bin 580 -> 229 bytes .../block/decorative/vent_alternative_cyan.png | Bin 601 -> 229 bytes .../block/decorative/vent_alternative_gray.png | Bin 573 -> 229 bytes .../block/decorative/vent_alternative_green.png | Bin 576 -> 229 bytes .../decorative/vent_alternative_light_blue.png | Bin 626 -> 229 bytes .../decorative/vent_alternative_light_gray.png | Bin 592 -> 229 bytes .../block/decorative/vent_alternative_lime.png | Bin 611 -> 229 bytes .../decorative/vent_alternative_magenta.png | Bin 615 -> 229 bytes .../decorative/vent_alternative_orange.png | Bin 621 -> 229 bytes .../block/decorative/vent_alternative_pink.png | Bin 626 -> 229 bytes .../decorative/vent_alternative_purple.png | Bin 606 -> 229 bytes .../block/decorative/vent_alternative_red.png | Bin 584 -> 229 bytes .../decorative/vent_alternative_yellow.png | Bin 626 -> 229 bytes .../textures/block/decorative/vent_black.png | Bin 581 -> 250 bytes .../textures/block/decorative/vent_blue.png | Bin 645 -> 250 bytes .../textures/block/decorative/vent_brown.png | Bin 635 -> 250 bytes .../textures/block/decorative/vent_cyan.png | Bin 654 -> 250 bytes .../textures/block/decorative/vent_gray.png | Bin 631 -> 250 bytes .../textures/block/decorative/vent_green.png | Bin 628 -> 250 bytes .../block/decorative/vent_light_blue.png | Bin 671 -> 250 bytes .../block/decorative/vent_light_gray.png | Bin 651 -> 250 bytes .../textures/block/decorative/vent_lime.png | Bin 658 -> 250 bytes .../textures/block/decorative/vent_magenta.png | Bin 664 -> 250 bytes .../textures/block/decorative/vent_orange.png | Bin 671 -> 250 bytes .../textures/block/decorative/vent_pink.png | Bin 671 -> 250 bytes .../textures/block/decorative/vent_purple.png | Bin 660 -> 250 bytes .../textures/block/decorative/vent_red.png | Bin 639 -> 250 bytes .../textures/block/decorative/vent_yellow.png | Bin 671 -> 250 bytes 45 files changed, 0 insertions(+), 0 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_block_black.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_block_black.png index 42ea98a8707d38c25a00e4fe23b47833fe1563a8..7cab729045509c9bc478ee7f9c463374525bda06 100644 GIT binary patch delta 314 zcmX@Xyo`B5LOp+gPl&68gp9PboT#X{yu9-N|NobKwfn}vz`&T~?e4H=O_UFvJyc&AHd4v}Ng}gmo978y+m-ZdxZ7|?rmfhvB zPA6bSL)YJO<%lnx_LeuTG`Z%8+>VsgXjd`1@>=zZ5jWq9Hco5SYj+~z&+_lt_3-lL zFz$=*PPJZ>=3jW1^W2TK5)G517^Uhhbq!2H3@xk-O{|Q~v<(cb3=B?nFa`kaR4s9h zC`m~yNwvz&PsvQHWH2%?GS)RP)-^N^F*LR^G_^7|g=m-*Vx0%npaIuVl9`)YT#}eu dfTqX9z{&(_Nv2SqF;EXDgQu&X%Q~loCIFchVAlWu delta 369 zcmZ3+e1dsGLcKwNPl&6isD!k%oRkz0$%=_d2nq@d2nY!X2un-L%gZZ^i%ZGLDT#`T z%gZZ?iAnzd|9{`ADX9z$42((M?k@ZiyBKZ)Ih+L^k;M!Qd<_byIhRzY$!RVvq@Irt*1MyNrIKZp@8!j z4^E8bkPTo;y}-+T^YZnc71oaS9B+$arv>X%a+YcMM zgWRW@RpJ^^l9E`GYL#4+3Zxi}42+C)4NP?n%|Z;!tW3>;NZY``%D|v3;zlw^2V6sL beoAIqC2kGutO@sl8W=oX{an^LB{Ts54~%q| diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_block_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_block_blue.png index bb4605b982d3c9fa8e1bac9ae2a66ae471397a5a..e0d31aeac00433588a1d22f82c0adc292e6cd1e0 100644 GIT binary patch delta 348 zcmZ3)vW$6x1SbnK0|Ud`yN`k!dGxg9B~(XL{2<#qiPBW}JIZJgGu z*X~5bpXJ}P>*3|gVcZwrooc-%&A;$2=eZkeB^rR{s+PD$l%yn9EWMW`tVh*w8d}?YtP!EHrtDnm{r-UW|T3>6c delta 473 zcmZ3+yohCj1SbbG0|SGGE`RVuMf>{L0G|+7WtA))-BxYg79G8IZQW)ay*3@aR&AXo zWz`%R*)VCDU}>2^X_+7y*-#nT5M8|vWz}q5{SFn?9Anej+B%J@>P1E-Gi2n#lvOg7 zR5FZBXQ`F&>#3o&PAe&+6^}|7odd zUz!*UjXrx=IC4&$epKXNV0LZY)i6;@oygNy=RPzq5cf^xo;5+_5zpnc#a8Y2SM+#x z-zx0qaJ?rQ+;+?M=7)z*4%hSEb~>gIe8M|=gIwwEgsgXU~<}!cQ8v?Kod~X5Rhes$DZnUOTuvs5yAweu*Y~ z{Q<_i6M!yPEpd$~Nl7e8wMs5Z1yT$~21Z7@2Bx}(W+4VJ1&{{R1fyyEOZpc2L; zZ+91#{*0S}Kn`btM`SSr1K)lSX0%`pRsjmKmw5WRvOj0$<<-#p%_F=JDCF(w;uykl zy|nKjZ-W63v+OR1bvgkv8oK_LD@T0kw70xzrO7o%usf&e}$`!h4 z{Qv(yHqY@p&=STZZ+91|()1@rKn`btM`SSr1K$AldBsxG%RjPk{T^6uUW&F5OvL%|Dm_-+F86Bcrm*le4Af zCrdWAAKDtiDe};6|E~SZE}vZ@7|OZjYtv_5URyS`S$Fq}0-dZ{;u=wsl30>zm0Xkx zq!^40jEr;*Omz*-LJZ8TOwEBv+rYrez@RMRMlzBHqg1Qh{FKbJO58fwSrhI9buf6k L`njxgN@xNAKJJ`K diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_block_cyan.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_block_cyan.png index 5f004ef762014c7311ecffe67c1f6ce563c0a8ec..450bce26255c73f4119f27f8dc8021f704949666 100644 GIT binary patch delta 308 zcmZ3@vW$6x1SbnK0|Ud`yN`kgTe~DWM4fo+x2l delta 482 zcmZ3+yqaZ#1SbbG0|SGGE`RVuMf>`M0G|+7{+JZu;u_(iYT?p4;gVY6k~-nyTA_j} z{@7F=uK*r*UmiCf9uGerPe0+(df~Eq{xl0nkpyByV>Yc~)M5y+96Ufk$L9Lp=lE0R|vu z%(~Xe2^3{7@$_|Nf5s}n&8G6nMlB5}wAs_eF+}3B=!C$c!wwwIjvPlL^UdB}%e-v$ z_HV!B86JD7mkSS`5iC$rRnY6^tjo>LzFzlQ)=+1Y{tc!wY{W{K6zDns)%geOI z;_dURxzCt<;pJy=vT4!0eY^hIM3q{LpHJIvJ0+#KRq9P{E1mf0O=Hp21No0vNOx*n z=FIiyXWOyaL)GQ?#r&;);o)+L8)wB;hMm6Nq1;>1wXXOCvuNS`&oj2xAOBKd{PLU= z)9;^6|IH^`uvcwAGc6V9e$^7!h?11Vl2ohYqEsNoU}Ruqq-$WRYiJf?;AduKY7Ru& p1_o9J24xX9l2LTz=BH$)RifxX(ZJ4{a383F!PC{xWt~$(69AoYswMyc diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_block_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_block_gray.png index 70690a2a53039c9566e3652c70d4742bf1d9718c..0edfeaee3353dacb78abee405550f5af00e5b184 100644 GIT binary patch delta 348 zcmZo?S;jm;f|G@rfq~)e-A6$a747T!1AIbU4NWY}EN!)P^zEG7{{R1fNcQh9pc2L; zZ+91#{*0S}Kn`btM`SSr1K)lSX0%`pRsjmKmw5WRvOj0$<<-#p%_F=JDCF(w;uykl zy|nKjZ-W63v+OR1bvgkv8oK_LD@T0kw70xzrO7o%cps|0B<)-^EJH8c(}G`2D{wK6u< yHt+!Hm=t222h^bfx1uC7H?_DVF}DCslZkQp^}Qa zqOz)zikhObnwgcYww{5Ou7RDCn~AxViG{VUfw8TltFo%Pmae{*j=r9uiJhaXj-KKF z|Np;u9{vHeficP3-9_?E-qsEvhqJ&VvY3H^?*IrhW?k##1PZd3c-H&6vOi-L;AT_# zWTTb_6kF)&;us=vS#?5W5woIzb9C0s4Hgw|Do+0Om-^}=AEG$V#hK+m%cP*D>0(U# zc9}k#Aspj)uFRBmO^UGd=iRCbr%$_O9GRt7Vr{iia)$1E1EzbeYb~mnBO9NdV4k@6 zYMa?)ap9Y}7aCu!>8M*5@@nY)<`G^96!P|TaSY+O zUfOq%x50piS$3DhI-P(S4PAfBl_S1%+FRbV(&U;WaywE|qg}=5%Io?oM%;Wa+BmIQ zuic4=Kg+*o*Tc(~!?-WLJJotknt$P4&T}``N;Ck?RV{IiC`m~yNwrEYN(E93Mg~Sk zx(1fI1|}hf7FLEPR>o%91_o9J2B$h015h;N=BH$)Rf04a>lzsA8XAWf8e18fS{a*a y8+d?pObW5i1M1L#TTzmkn_66wm|K9R$;80Q1ZqpBP@XYR4}+(xpUXO@geCw9k85oJ delta 458 zcmZ3+Jeg&J1SbbG0|SGGE`RVuMf>`Y0G|+7D{ooaYksc;NoyYwOE2M&Tp7Cn(V%Q;eOmzwPhmZ4e!D=?;B1-T z92sk0k^leyXHEaS0ca0nlDE5yG*iNrB|r{mfk$L90|Vay5N6D}*2!596lE{*^mS!_ z#wx(grt--~Ee$BN+|$J|MB=jQgutT14m?h(jGL0nlk+c`<-V`K@QAbi^nqwM!N`Oz z-HjX8EIf64TfY4EL{Whk8{N{v@7-*-GC4PO<|eOMsmcatE*|1Fwa${M37N{pe>J4Q zTIin>=l6M%GOKUDXzO_D^`_oz!K?0>W?v-hynQWFG`1Tn22AlZ+fe&5I%RoVRn<$m zs;{PN;~Rt@WzM)at3?)FK#IZ0z{p6~z*N`JEX2Uf%G4Z)v<(cb3=GO5ZX`oBm_c;p=BH$)RpQpc&YEx^ PsDr`N)z4*}Q$iB}yj7Uo diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_block_light_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_block_light_blue.png index 3d61fe78ae37cccf2dbeb50fa5ec314524ec5ce4..30dfc051005e1d7e215d61e089c0bdd0642f20c4 100644 GIT binary patch delta 348 zcmX@evW$6x1SbnK0|Ud`yN`kQ7j2Jnw);)fDS3xBvhDzkR_U9iS4% zByV>Ymi~;Jfj|ytfk$L90|VcF5N5Ps4ORgPvX^-Jy0SlK=H=DU`^_V~5GdsB>Eal| zalN$fAa8>K53}qphjlsuGa9=7mMcem>9n`JX{E_EN91;-q(-}n(UsTrSB$v%UbJyq zvtGLs5r39{&#s4;FNbkoe0Qq#nl%5yyPW54td(d0nyXsk8c~vxSdwa$T$Bo=7>o>z zjC2hwbq!2H3@xk-O{|Q~v<(cb3=B?nFb1G#$jwj5OsfQGFxE9N)-^N^F*LR^G_^7| z)i&?|>6jE^od?vR0k@(gGdH!kBr&%DO_Pa%l?l|AOrbnupdJQKS3j3^P6{v0G|+7jhbmjvvwQJ++{p>ztN0c#6jLhY6H4Xdi{;}>6p||x63Y}4%T4AU(5#tmGVg$9-As+@sn%O=8&2D9 zG-IcB%R;LS*A-K$G^(a*R8Ce%D!1NzOQ&^_)y5mvn{R5?&HDfUf5jiaGN2O}lf2#Q zT~xNP{hSHpaTa()7BevL9ROj*tZSW|Ktc8rPhVH|XRHF;Y$~5@)Y5=LyF6VSLnJPX zPPiR(*n!8ncJkE?jc2#LoaCga`{%!X*<;DQ8BdaXU9Z@POiY2DY|`LQfcq(nHT@Ky`Hjm%_~la*-Y_T z8+{tK`lSC@>6|prqg^$3Nn7K4<6Ao>K2$bY5cuxZhXZYnQf<@a{~0Mwow{@P51pDP zfx7Z%zl$818z9I0#xN|T`u^_=pVzNm%~5&KVOH*O?tk&g%Qz)0#aFBadPB9uHKHUX zF{LEcD!C{%u_Tqj$iT=**T7WQ&@9Bj%*xaph_nq1tPBjwB5oujbO1Hv=BH$)RpQpb T&YEx^sDZ)L)z4*}Q$iB}cmv1y diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_block_light_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_block_light_gray.png index 290fb6bb87a2fdb32ce4eb3727609bd3040d298d..84402f1b1d2afa1f53d19da7154dc8fbf14a0d30 100644 GIT binary patch delta 348 zcmZ3^vW$6x1SbnK0|Ud`yN`k8MPzhs_ zx4R2Vf5y!~AcwQSBeIx*fp0$uGg`0)s{jSrOFVsD*`G7>@@nY)<`G^96!P|TaSY+O zUfOq%x50piS$3DhI-P(S4PAfBl_S1%+FRbV(&U;WaywE|qg}=5%Io?oM%;Wa+BmIQ zuic4=Kg+*o*Tc(~!?-WLJJotknt$P4&T}``N;Ck?RV{IiC`m~yNwrEYN(E93Mg~Sk zx(1fI1|}hf7FLEPR>o%91_o9J2B$h015h;N=BH$)Rf04a>lzsA8XAWf8e18fS{a*a y8+d?pObW5i1M1L#TTzmkn_66wm|K9R$;80Q1ZqpBP@XYR4}+(xpUXO@geCxP=xtO0 delta 478 zcmZ3+yqsl%1SbbG0|SGGE`RVuMf>{L0G|-ogoLPyih}a;{Hm&=%F4pZ%A$&j!qU>b z#KdS{Uk`6@H!m+&A0PLss^Y}NsOswCq@?JCgvg$r=F-yKva-DN^n}jN20uT~`1r`U zxQOoVri_fluCB(Uq?rHz|9gE%dkVCWG0EHAMXrcTK^w^7EbxddW?Rjh>$O|Nm@d z*GES;@r$MPH3(}m7S8nfkbTxPK6|Cp8nMXBXKf#rKUrpS^*BrUD&!C8<`)MX5lF!N|bKNY}tr*U&7)z|6|j+zW`c4GgRd l49X&IB%|oa%}>cptHjU&*TBx2a383F!PC{xWt~$(695f(wFdwI diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_block_lime.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_block_lime.png index 97bf58f142dc9d806a9052aab923f5ee3ac0f666..f6ddf7848b5965d6bd54a299cd3a1025cdf10411 100644 GIT binary patch delta 348 zcmdnWvW$6x1SbnK0|Ud`yN`kTq5dSCy>8e;{X5ucNknI0F^K% zdAqx?^k>`*1adeFJR*x382I*sFrx))unJI+y~NYkmHjz0FRzB)Zyw==Kp}5W7sn8e z>!p1Mc^eFPm}Pf4tkVgY(a`m`Tsh)Pr@iG(D^0FBBDW(YHQH5-uDq_lV#Lk&qK(s< z_1c|?__O?bc0Ig&IgI<_yHl;#r1=-#v95u!uAy;=p|O>rsg<#* zwt)vo$D|PJJfIE@xD_Rtxv9k^iMa)6noJC=OrW-83gsCC^)Pt4`njxgN@xNAWOQtO delta 492 zcmZ3+yp?5w1SbbG0|SGGE`RVuMf>`+0G|+7p9X>W1)_2DMG_Z_#?2E+SSXsXNHl(- zXzW}O-zGuZbYANeUaKTt>ttS=6keND-oz!MzKw!OK(bjdf44;J9Ff3Iq1^2fb{V|h z^#WeC0=8+q`MV^7x`lFgNaXF3@M{+Q|Nnn#+}0qV&5TLj?kq; zwoa=P*Ps94k1E{srG7>v3!3t~sz^SY?wV1Rn_a#8+uHKait}oBu3YxgwkVxzx6VSY zNp3#Ec}7)*ALP#FE{nMTxIQt>r2c}M>aBJ27)mrgEEKxUbmK%xTfCaewbqh|OIo39 zcKH&e%7?W>E@b$ZRwx84G1^o6akk*fH)jqX4S%S8KI^Ac-4ca)EuUl_bVLQt{XApo z{QE1{DLvWSkSO+?``zm0Xkxq!^40B8-f54NP?n z%|Z;!tW3>;NZY``%D|v3;zlxxj@C22{eB zwGs`J&oD}fTk0B^gcw>_8Jbubn`s*u zSQ!|c>R=3*{FhNY%2?OHSl7@v#L(Ev(A3J<6e2w-#5xb?B#jc+h?11Vl2ogb%-q!C klEmBs1|tI_Bt0euRwhs*GllYufqED`UHx3vIVCg!0CI_B5C8xG delta 497 zcmZ3+yo+Um1SbbG0|SGGE`RVuMf>{90G|-o2JMRZX4B@GO@O7y{2bsiDX~t|>GJknSHAae+m?3k=;o=bvu52> zGGDf#c3J?dr*a!-_{-d)4_m{x*H28!?cP1};vYZhDSPu?aXRc~y05iS>_F8r<3C0U z8$~W9dd^;%`QUk%U4F_B9^Z^B?N&A$k|!;D_;tFra?s5g?cMr^(&t_Mbn~x=qYcMX z%L9VNuBAQ6K70EXu2Xu#E1bD)zW$Hj?6F-Oe-!rIlLGoewZt`|BqgyV)hf9tH8Hj% zmBGls$Vk_~RM*ff#K6qT)EtPk4GgRd49X&IB%|oa%}>cptHiB=oi*V;Py>UftDnm{ Hr-UW|KncE! diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_block_orange.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_block_orange.png index 993d660e09e4f224f29afafe5ef1c2749ad766be..d9e5e99f0ae9ad7aee96fbbcf089a086aded73e6 100644 GIT binary patch delta 308 zcmdnTvW$6x1SbnK0|Ud`yN`kCd*(qoM0>xpKspPJ7FnR+?OML~ch)YP72uU3sl~#fY2lMH{Cz z>$N)(@n`w>?0R_lav1l;cc)sfN%Jqf%X#j`T8W0q7Z|0)Ep-h{LJTde3{9+z&9n^+ ztPBiJbub1@W@HkNGS)RP)-^N^F*LR^G_^7|g-A~dvCacJNu$Iyq9i4;B-N@UGdH!k jBr&&u!N|Y}Nsozvl?l|yOrbnupdJQKS3j3^P6`k0G|-o6#?8Alld+r^Ic8lyO6|pIfd^^D&M6P zzH^DZs{*;(9XOlqI2&y_nrt~*>^NKPIj^PitqkD4p2oL2kbAj5_tz4Evx&UtlX$m; z@_Z-~=y2p*=Fh#vkGsvD^Gk`qwlJQLMFO9T1=a*||NsAAN3pOEXg_0;x4Vn7R((>A z6_CeS;1OBOz`%C^gc-B0b#ej)*-JcqUD=!!3~?L7k~gYf`Na z`^yS_cCpgQR5scYb}7d??!$jJ#}gdaD)t}00`!JziEBhjN@7W>Rbp~c zDv)L{GB7gIH89mRGz&2>vobXYB5eZ$D+7bFh#Sc$I&$+>&_y8{3K diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_block_pink.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_block_pink.png index 6150820a80f518b2a29ed7ca8cafaf5df0e97d1e..d096a6d4591e2f08365c2a8688e1255d800c4523 100644 GIT binary patch delta 307 zcmdnXvW$6x1SbnK0|Ud`yN`kYmi~;Jfj|ytfk$L90|VcF5N5Ps4ORgPvX^-Jy0SlK=H=DU`^_V~5GdsB>Eal| zalN$fAa8>K53}qphjlsuGa9=7mMcem>9n`JX{E_EN91;-q(-}n(UsS#SB$v%UbJyq zvtGLs5r39{&#s4;FNbkoe0Qq#nl%5yyPW54td(e(e4bHC+)~%TB*f6d%Fx8h*i75N zz{pY-~G)i0}N>UO_Qmsldb5n~; j5_1a}j0}vB^q3e}nLtg<6v{IO>S6G7^>bP0l+XkKa}s5f delta 500 zcmZ3+yq9Hy1SbbG0|SGGE`RVuMf>`k0G|-oD zY{1j}S1nty)kJ$?v!nTs|Mruvl>b^ZS^l-oqGt;`R1W_MYFVaVx^jJfZtmGV-Raul zS54kdln%ae&wEAF62ZeQtG}38{;0pP`nJc$ZAZ_Z$*5b*dn(TSE6ak|M*pc1+zGaq zCF>+7L~y;_u;lC&lMkh?^UaNF+SE*5#mdUvF!a3q;n!Jtw-{6R4suWiNdt_Au+wZt`|BqgyV)haom zC>2OE7#SED=^B{o8k&U|m|2;c1Ch3Yft7(lS;UQG6dk$wDVb@NxHYh|Cfo;VVDNPH Kb6Mw<&;$U5Sj>F@ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_block_purple.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_block_purple.png index b901bce3afcd3020b1be7f63674880b51a35c7fc..7195de5aa7e593210b9a2f9221114d8f9f2abd7b 100644 GIT binary patch delta 308 zcmZ3@vW$6x1SbnK0|Ud`yN`klm&Do*i}EGki3`TzfaZQoE?pc2L; zZ+91#{*0S}Kn`btM`SSr1K)lSX0%`pRsjmKmw5WRvOj0$<<-#p%_F=JDCF(w;uykl zy|nKjZ-W63v+OR1bvgkv8oK_LD@T0kw70xzrO7o%gTe~DWM4f3zcBY delta 482 zcmZ3+yqaZ#1SbbG0|SGGE`RVuMf>`M0G|-o0I8B>g$b#OlamzsQxqqqDo#pKoS3N4 z7bsQgAR22Y5@jnAX(tkGFB+YyI3+-;G)-|zpmdqPRB?&g%0z|UB!#|EnVKTiWsah8 zev*auqA?|EE5c-Ii`7;HN|*ot|6kyZ^){fLj7i?^F7m9r0(*fR&H|6fVupGKz5@(E z%$RkplM^V)UgGKN%KnU1fSXO_lZ{#$P-wHKi(`nyWzh+NMTZ?YoCP_KM&{4C5v`s( z_uIeYJZWwGCXYG~@_b-WUfK|^CR~tPJbV4$Yt}V}=k4w`vdB$bed)?}O$M(fi-cV_ zFLfVYzt_@D>X(#1Lz8{0;_ch@T>g_H9QGv?&OWDjS+q`a%MA6CogtC|O#9!*Xel2) z9daQf+O?t}eWKTgZ;RtyRjy2JpM8E=`Ml*%t3N9DZtT1e`9yFlQ%_;ftLyh04*OJX zm~fzO--G|mi+R{5Foh*80lHtc#5JNMC9x#cD!C{XNHG{07#ZmrnCcpug&6pmS(%yx rk+y+>m4QK7#EoPW9l7}_nQ4_MI#4vQvnJdJYGCkm^>bP0l+XkKTYszD diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_block_red.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_block_red.png index 8d1887300524ee8ea3b97d1c254e657aacd1c856..5ea7763b57c52f6ed2b17976d517fe9d971394c7 100644 GIT binary patch delta 327 zcmbQqvW$6x1SbnK0|Ud`yN`kw!%6!P|TaSY+O zUfOq%x50piS$3DhI-P(S4PAfBl_S1%+FRbV(&U;WaywE|qg}=5%4^jtM%;Wa+BmIQ zuic4=Kg+*o*Tc(~!?-WLJJotknt$P4&T}``N;FJf%_voGscT>oVrXGyXkuk-rfpzg zWngfsgE0VTr)r67L`h0wNvc(DeoAIqC4-THk+H6Uv96(Uh@r8Sp{bRzDMZ7h5bHdk r1`W7|lFZ!H;*!MN0yI4)2398K5IyHpQ`>=hI2k-${an^LB{Ts5s=8&{ delta 464 zcmZ3+Jd{j0G|-oY)SD}1=&`4*$xG{7J1or1=%(Q*=Bj! z94Uz~5#eAFp&((Q5D}pqDe+E4xm+oUEJ^V>s!C1rGDXsoGgTDBMTIjZ#Y07eXR9ie zNK4LAQOuK)`2YWZZD;!upjC`X-tI0kb66bNfgH{PkH}&M2EGFz%$QYwt& z>&pI&Re+mK<&%wC8c=AJr;B5V#AVTdx09F*c}|H(?7n(;ReAXN@AdwXX`k8|5|f@y ze5x@)v@-M9hwS@R`}q`&bPaEvm3{dAke|fyi(V`z71BC3$ecR3xawHT(HpNN1$%0Y z)Ykrb$9eE_k{hFp? z0dHUP$I|JhdyJRdP`(kYX@0Ff!6LFx53Q3o$UWGBpPxZ36=<1B0@N8_5hd$U1WKQ!>*k WaqD1bO}G!Vg2B_(&t;ucLK6USKA*n; diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_block_yellow.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_block_yellow.png index a7b8b6289ec89c249a3ccaacd590784c4d70cba8..61a433739230bba0bde9720521517a8b8438d167 100644 GIT binary patch delta 348 zcmX@evW$6x1SbnK0|Ud`yN`kzpuNsV?DqbslLuNZOjy=ddK zX1#VNBK|D@o?QBG`0iBeHEI5ZcRA19SS!&0G*`96HKHUXu_VKd4Y7+P2vnphc|X&V?=85o@EU<^Rfkei>9nN|tXV61CktZQf-VrXn-Xli9_ zs%_u_(lIH-IuEEr18zl0W^QV6Nn&mRnkEwiD-)HSKs^keu6{1-oD!M<$b@ha delta 504 zcmZ3+e2`^=1SbbG0|SGGE`RVuMf>{v0G|-owVjgJSIJ*nDSvyd{MD6mH`mDDS|fjB zwfyDfa_hS!yYocavV>bQgI;yg21sKVuc(W>fiOqm~8~+U4ou7$R|5 zbi(bR!wx*owUe)IXgs^^IX-9P{B%N|Sa&3KaB>w3jTWMayU`DzPaM$bI`+dVeR zH2+cL^37SZ;*`RdZHQYQ!0M^Ii&MNlv$WvDPSNf2l1h7L&%F4@?e&zkYhH0W%w~$$ z+UV1;)hGSOO6R0`9_^~ROWGRW8{gV7@u9NGg1~pLJ{)LslxmwU|IbKi>eQXPf9TXa z3DlK8`(5P7+yFV|H-=#$)%Sm2_`H7gYL3c-4zqHPbN`D^UdAb5DZXMY&>N~Ht`Q|E zi76$iR>?)Fi6yBFMg~Skx(24YhGroKW>%)=K%{M8U}a!X7I7mPp#!KPH$NpatrE8e TcGiUZKn)C@u6{1-oD!MQN3MHmT- f14Ba#1H&(%P{RubhEf9thF1v;3|2E37{m+a>+8$O$;rsbC@3h%%gf8k$|@--DJm*zYHBJg zD@%cZ?EnA&oger92b#&4&pI& zRg~F8hOapr!7L>Jm>vlJvrk)s8$GIN;Pa;^( z7d^cbrGH)d=k5Z5te1axTqxd=dw%}C>b>vHat?EC3;B@nD$sE8<@Uoz`zO{mJ3pGz zv!(B2gTnm}%%_A{L+9+frU7)GYKdz^NlIc#s#S7PDv)9@GB7gIH89mRG6*p=w=yxd qGBngSFt9Q(kTjjvg`y!hKP5A*61Rqo3_UZT1_n=8KbLh*2~7ZT)sf2p diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_blue.png index 87278e1f8dead0336fcfa1e23cf4096f64b8e088..f31f8d007c46b977273b7763e461dfeed87e0f51 100644 GIT binary patch delta 198 zcmX@l@|1Ccgcu7m0|Ud`yN`l^6k~CayA#8@b22X{Dhk&N1^9%xYG~Ey=yfP5XBwN% zmXnj?;^Ojur!Wzymb1VkvY3H^n-7E;9ritR1PaD@x;TbNT(0dq$lGAR!#vkVU^RD$ zE{{W_eG*g4k$0!eTKX*~X@`WMo5>l+$%|TUAtZrDX!8WkQ0aWrAg7L$$TFl~pqJ_4VcCh5%WsOW`Dk&)`Dk^GfYAP!$OG!z|$c8DYWGJa*s;K5@>oorV|6j?21sKVubTHj&|L&IbANkf)1dh{R>t{?}!P4LF)p-yAvE zb4(>yX!q-D?>_xoZ(+o@zvPP|3rkmLn+e+@A5IC5;3U0$D)}xKx(&`>J)$*zmivJl zK2JiXof2AjO8b<3@m@z}rqkQryIc3&n|0(OtGb%t#>$OdEV`wv_v^W*SI4|AW!Sjq zeSdED+V}j8yAJ!+$J!iI(PCRCpD;h@k?$s@o;%ym-~0Ws#_WBgPL6)0-zhPU35yEm zygKc#F#GtV=?hPbKQb?An|}J=+AI#ump`2M|K$I3kNau1&&6**@2HlzMwFx^mZVxG z7o`Fz1|tI_BV7YiT_b}KLqBsX6JskwLu~^CD+2>b(`j8OI&$+bP0l+XkKzG}He diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_brown.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_brown.png index fdd156265de914c1537b717b608e4a4e475415c0..48bd12cea4a06305d1ae06d3840a27e94e1dd558 100644 GIT binary patch delta 198 zcmX@Y@|1Ccgcu7m0|Ud`yN`l^6k~CayA#8@b22X{Dhk&N1^9%xMq4PP*eUxONEf+l z$jQlZadG`i`S=50!e8>M7Bnm8#Pf|HE&Tr18F;TF?)3}ZEbB|18IGIeK|Qf z85tP`1qFF|d0AOmB_$Xr7_uZ{p-B%ccUje-Vy2UxDlqy*jRL{@v(ql{r3_97QOiEpKYRFU*DX<+N-uS zVpUk1E9;{#bN~PE`Z1%C`_B3B_kZj5N0-TM*but%vDcb(`j8OI&$+bP0l+XkK DU>CGF diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_cyan.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_cyan.png index 3a3d3d7deefd53e92323925c7256771e3ca70df5..a0d721bbb48e63af7efb5996318d6ea34d002b81 100644 GIT binary patch delta 177 zcmV;i08ane1myvc7#0Kr0002(-QrRJ0004VQb$4nuFf3kks%Ws5>QN3MGT- f14Ba#1H&(%P{RubhEf9thF1v;3|2E37{m+a>m5376LK$EI?-dW*G96lv?$+$@KmOaxNH2fvXT`!) zAeUIhx%so5AEVm_mPIKa{=8B@AuYUiR^-%4$0SuJXPKVbscER-w0zP(+vnUz4hrV~ zuKV&>Vy|(UaM3z$>Zl_X)ZG{r0x6cHg3PKbargx@ud_S|R8(%NuM?{gjqEn> zUMgCs$1-#OU;jU>H7UHt?qxPoKp&}=xJHzuB$lLFB^RXvDF!10BO_e{Q(Ys25JPh- t6JskwLu~^CD+2>b(`j8O8glbfGSez?YskpZGXrX1@O1TaS?83{1OQXXzSRH# diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_gray.png index efe599032bc1350103ac10fad9fe268d74de0a75..a0a058b3c93204658caa9d305cc680d252966f47 100644 GIT binary patch delta 198 zcmdnX@|1Ccgcu7m0|Ud`yN`l^6k~CayA#8@b22X{Dhk&N1^9%x8k$&`S=wsp=-WBD z$;ruaadDX(iC6(t%UR$NS(Fu$ntW zm&c*eK8dO2$iLMOnDXBxd#fL9WNl@AkvVU14Ba#1H&(%P{RubhEf9thF1v;3|2E37{m+a>Q1A<#Dr>?NMQuI$fPMVU=x_?ojp{@v;6;us=v zS-0^$JJa_Ykt?T7;OP9o)9I44PX0j7&Itw^6Yp-@`?flt*YmIjt8#14Ba#1H&(%P{RubhEf9thF1v;3|2E37{m+a>P932Kjf7r;B5V z#AVt3i$%=_JS_ffJpm#qH(54JHp~70Upc#|YWGapw~Q_vhb7dMx||t~F&012=04fW z_9AvhxUlE3oWdsVUr*D*OPy|T@&A)wvXeMv((CXw5@*owR7KhSKSvh z_I|0J6tt(Cl_PoEYDW?N1$J%k?D@)L?LD@Ks&Y9lkN?&Ef3-1pTFdQdP)w?pxJHzu zB$lLFB^RXvDF!10BO_e{Q(Ys25JPh-6JskwLu~^CD+2>b(`j8O8glbfGSez?YskpZ RGXrX1@O1TaS?83{1OWLFs-FM= diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_light_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_light_blue.png index 27db6aba36f42b65bdfad54bed717f9c3c44ec81..3fa16afa7744cbe4cc1d72a20d6d5ac03c8780d0 100644 GIT binary patch delta 177 zcmV;i08an%1myvc7#0Kr0002(-QrRJ0004VQb$4nuFf3kks%Ws5>QN3MK6%AGoHXG zdXzh~+a4Ys3JMAl3-2$I0T^*yNklT- f<&W& delta 592 zcmaFL_=#nLL_G&H0|SGGE`KnPVo7)Ob!1@J*w6hZkrl{SNcITwWnidMV_;}#VPN@=RcU$b_G(TrX4v4z%KZd-4@Wxe^PLSngk`9z~xnY%UXX357F%g2`}B$ml1lxkE@ zRY)pVNUqS<*4C(+s;{pvCnqN(Bcq_8ATKX3D=TZY>4uV$lA@xbrlzK{va*zvlwwMy zR{d;^%E=m)Q#9*l8cy5(|NsA*=D;67XE7#uySwO~z2#^-F-D@Ey~NYkmHip3D6@$S zUvoCd>lZv-977~7i}u|vYBu0uead}QAs|%cwhH4LliW#h|Nj4eHShS`n>U#g)_lI( z{l0hW!p{uO?2Fy!2&8+j-^N_0e8hFiq6aDq+m}crt933}tzemOEclnWz$b++Z^)AC^q5{B%4+jLMg73*p37I~KCy9V|5>{~H(IlF|I;G}ikHk;yk=JP zSwkKTdCuFMJxjVMV;EJ?LWE=o--iAiNJGB7gI zH89mRG6*p=w=yxdGBngSFt9Q(kTjjvg`y)jKP5A*61Rqo3_UZT1_n=8KbLh*2~7Yo CE80H* diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_light_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_light_gray.png index 98206fda1ca17df843dd2b17fa8ec9482b2b8ebb..ce2e8778388c525991b9612f91c216654f749068 100644 GIT binary patch delta 198 zcmcb>@|1Ccgcu7m0|Ud`yN`l^6k~CayA#8@b22X{Dhk&N1^9%x78GPuRTam@MfCJE z%gM=cad8#w_1*$h%UR$NS(Fu$ntW zm&c*eK8dO2$iLMOnDXBxd#fL9WNl@AkvVUm!6*H?(QZZANSbU@QR9pq@)-xuMk&nZ?}YmNMBzMZEfxN_(*+yeK|Qf z85tP`1qFF|d0AQ6uC7KUB_%~gMNLgjWo2b4DXHY-n7Fuzq@?K5(%k?5|NoHv^9ASv z#w2fd7quvk8CxgDNYt~Jc>21sKVubTHj&|L&IbANu&0Y-h{R>x{)a_}6?mF?XE^pe zPn>MVS#tMQ-uwSui}$|#EYC95<|bK4F<*XKQ7d$=U{mrSn`X zab*7Q(%V(?zo+`9IsN}^b5o%qWPi^xFV6IHOnMh@>^m-T{Oz@~l_z{|?XcC%J@$F} z0g-9ptSP1}`sLrgx3{)?n%Ym?8Fs|d#nb+u`G3Z#fxK?*@-a?8|EQL@MwFx^mZVxG z7o`Fz1|tI_BV7YiT_b}Ke?xOC6JskwLu~^CD+2>b(`j8OI&$+bP0l+XkKw-Cki diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_lime.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_lime.png index d6e1f107674d1c8ef937466a4ca8dc69d318799d..9d1d1f80784c316713285f594230fad795e96bec 100644 GIT binary patch delta 198 zcmaFN@|1Ccgcu7m0|Ud`yN`l^6k~CayA#8@b22X{Dhk&N1^9%xMobk>Tq5dSCy>8e zLQYPOi;GLWH9rHWmb1VkvY3H^n-7E;9ritR1PaD@x;TbNT(0dq$lGAR!#vkVU^RD$ zE{{W_eG*g4k$0!eDDsk~k_0`Ut({hAX5t&(`HlX-1Yc&$@-ZPR#d(|NVE zwY}>F^!4@SBQDJm*zYHBJgD@#d9`Lzgo)e3mm3HUY( z#?BG>|NsA7ot{#lYZ#Nf-CeYT_g$GcF-D@Ey~NYkmHip3D6@$SUvoCd$EQ49977~7 zi}v3vYc>#Ye#&aVd|6ZOwn~HNCAHXp|Jh%^3ViMn&eT)7@Acn=HN11#fAK9=pVg6e zI)7X99^;EbQ-haiwlM~HX%_peQ5CZ8xX|^V;o?&+LxUr?_sM^?I2U!3_iVsfW#iXD zCWq>sm+ffEGxjy#e$2bS?^A7kPW0O6|4s;;m}Bu=r2Cm$anrm<>?<@Tq8#UBWMt@>0W~mqy85}Sb4q9e0H=n;j{pDw diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_magenta.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_magenta.png index 95c14e251df8fdc7ad8be2dfda64965b0bb64ae2..3651040a0b0c6485fa2cb5344ffc134c5bb82d62 100644 GIT binary patch delta 198 zcmaFP@|1Ccgcu7m0|Ud`yN`l^6k~CayA#8@b22X{Dhk&N1^9%xPBH3PY(BG2t8AD3 zdO0~cE-tPsyIN)f)p8biL>4nJaPxsMqr<+3jzGZ}PZ!4!iOaQp2YDL|c$nw<2(0D~ z(dBVyv`=DcIr4Ay1E&0U$=>Qm8(CXfUu4c(?&FfX^h#R6(kM1@_b!ao-)pGyKkjR-i=;p00i_>zopr0L%18LjV8( delta 581 zcmaFL_?%^eL_G&H0|SGGE`KnPVo7)Ob!1@J*w6hZkrl{SNcITwWnidMV_;}#VPN5Rku1->nNm7hWQHo1eimlf!Pg73N z*4D1mF4x!Bmy?r|k&#hQP>`3Gmz9;>VYgOENl8&rQBzY>Sy@?1N-AABv0104R;#pD ztE@?2R&ez4e64&N^O!8o`_MIL5`@ejIziHJak7AdUHJ|U!e&4%w;b#|T z_r>XbXT{!cQ~t^Dd5TE!qZv;Ak(KirO`NA6DNs3--S>a?<(Wq&B7|*$I;H7qPaL>CQ zg_Npwx69Xl-Er5;Y#LL<`v@u3my;Zy$lmCExh{ZfmThF^0lRrO_ipmJxy`d$JE`aU zrT;hXe_#)D<-7l>D|!#mU#cap5hW>!C8<`)MX5lF!N|ZU+(_5JRM*HL#L(Qz#MsKv rP}{)3%D_OQN3MZ{bT*JTc- zP73vO5FQ>L3JMDN+A)2R{TOjvNklT- fh5%Wj_@QC@Co^Dk^GfYAP!$OG!zs4dPzn z$Gy~#dvzf9*+ky||No~XPxAx1i80CB-9=~D-NMxqV(aX0z!54RT}0l^WF95|NpCVk6S)JC(E$3S2k`!nem3uPe7j zo!k-E@uagOMYmq)0Mq$I<~_O=_s@vwDf7&@-~W5x^;><_emr|zPFc1o?Yzx%xZ|O6 z;`vQ8vcK`1O1y0!o&EfA;N(jWjJ+0K(slGwV#ww=dqv&jfcK^aKRti_oO-7Gk?G66 zFWb*}MV@}={{NT#U1|PDKc@UT5A>R9iEBhjN@7W>RdP`(kYb23GB7gIH89mRG6*p= vw=yxdGBngSFt9Q(kTjjvg`y)jKP5A*k^!fNj0`<9paup{S3j3^P6QN3MZ#~0)q0hr zUUTz{svaI53JMD5!$N720T^*yNklT- f4-KIJ~D5D=9aH)D$u3~aBx-F&U;&U;l!ZpFoR8M&etO$8guTk@u~Pjb5OSk6r~sR<)x=3a KUMwFx^mZVxG7o{ea#H2D985kMq z8kp)D8H5;`TbUSJ85(LE7+4t?NSaRTLeY_%pOTqYiCaTPhMpNv1B0ilpUXO@geCy3 CnBwLD diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_purple.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_purple.png index 9119e16acf46363a143041d3dac2f18ad3bbe7ad..66983b8849291f99ccdf074f4e71337b42560267 100644 GIT binary patch delta 198 zcmcb|@|1Ccgcu7m0|Ud`yN`l^6k~CayA#8@b22X{Dhk&N1^9%x#>lm&Do*i}EGki3 zDJLh##lEak7ak;kdAa8>K5A$3ffz{k0 zx;zez_DM`FNB*sTz?A!I&~GCWUZS?LL~TW}+6sHoXkW>KKzrg5CYn_3z~R{#TTPgr{Bau4$?F|TNxT^8yHv_7)Y8<>q60y do1c=IRteRCMMFl0o*7UBgQu&X%Q~loCICe1zpMZN diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_red.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_red.png index 3bf12573ac7f6b9042e19c7a8deeb61dee1e5479..6c1f55cc761ab1d7b133e8c1c4dbacb6316c572c 100644 GIT binary patch delta 198 zcmX@X@|1Ccgcu7m0|Ud`yN`l^6k~CayA#8@b22X{Dhk&N1^9%x*2qeCD#&I^iqBD1 zl9Q9;;^JBzyq*)Nmb1VkvY3H^n-7E;9ritR1PaD@x;TbNT(0dq$lGAR!#vkVU^RD$ zE{{W_eG*g4k$0!e14Ba#1H&(%P{RubhEf9thF1v;3|2E37{m+a>Yl`U*PX978#1s;*b3=G_SAk65n?;+4b4D2PIzOL-gSVfslWcZr1L0&%S z>Eak7aaq=%G4F^0hq6kpmqfTnRqo{5x#hS2|F^J`R=mk{l8r+`*e{c>LsIxa%LbK2 zkDC89aug*m3Y{6cGGpGs86m5^pDjBg=#sJd)Boi12@H)D_I;b@KYuazagAh*c-fj> zQ6Z0uye|S**gRTh#u)V1X5R06zb)oneX{F8RH*dtRe=dge~pT!2)#GuZkc)PpY1V= z`1N^=is6r*eOYm*hcPInt2>S_WgE+j)DPdb{Vdpgx$Tgb`F=>LQKf6S^3JP}e3 zMx{W{sFt`!l%ynwV0|P4q14+|qT__rI b^HVa@DsgMb$j~zbYGCkm^>bP0l+XkK#z(Sg diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_yellow.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_alternative_yellow.png index 7f2f6a0967fdf25f428406f328b7321adf7686cf..e58ac59d0c6ecef2cdd4584c5d56a495501a4c2f 100644 GIT binary patch delta 177 zcmV;i08an%1myvc7#0Kr0002(-QrRJ0004VQb$4nuFf3kks%Ws5>QN3MaiEW-L4<1 zhZy|FBpx0f3JMC2Dg4-y0T^*yNklT- fB4`GtNcEu^6RKdM~?9F7K!VtGUYe+NVa4Ow`K~rXA8Gw39spp z?937A$`#Sp)?VE%p|7tmCnqN(Bcq_8ATKX3D=Yi+sEU%3lA@xbrlzK{va*zvRCk`p zrXIqLO`g>Z575hCb^U1{{8>`YTog=H*Yd0toeMm z`+e`$g`XLm*%!Od5lHu5zm2(0`H1V3MGsUKwl9%LR_k1{TEQ~mSnw}#f%D=C%xsyr zzb}??*KLit-;gEO=`p=Nl-1^giu!@qJ(sV}ePZL#{xc+ITn zvxYnx@|?Gy-Ha_tFtEM$cJsBWJMUE`xfK`NW#o!pG!<+pZ^@g|KFR6AlY^fozxk}a z^ZgO;O}?4=GkZVI`z`-l`X9sNqXKNcRud-yJ*QgY8c~vxSdwa$T$Gwv5|hecWME{Z zYhbEtWDsI#Ze?O@WoW2vU|?lnAZa?S3q?n6eoAIqC2kEF8G2?w4Gf;HelF{r5}E-1 CUfkRO diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_black.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_black.png index 96a3d194c89292848808321b7779edaa2d4b0916..b7eaa7839845c0e23b5d16834c979a1bd975cc8c 100644 GIT binary patch delta 219 zcmX@g@{4hTgcu7m0|Ud`yN`l^6k~CayA#8@b22X{Dhk(22l#}zN=V2^OUsFhip$F@ z%gM>9si|>safykEX=`g|pA_E+)Wlif5n0T@z|9B3j1K!AIsyeVJY5_^BrYc>hzPJS zxiPXiswE~TJF_~nF{Vzw5Rk6y#-_H}M8P90LBOQEH-lGGAVt8Bnc0mk@p?yJ-!%cZ zJxZ!p3uR>&zU$#>N+=d$k({CMOoL%<0yCEZvpW|wt6zwW{r Pprs6+u6{1-oD!M14Ba#1H&(%P{RubhEf9thF1v;3|2E37{m+a>FVlgX=&-{>B-5-iHS)_Nl9sHYHDk1>*(mn%gYN33#+TED=8^yXlRIuN&f%; z|3m#=383waN#5=*s)rd*@&h@X1s;*b3=G_SAk65n?;+4n4D2PIzOL-gSVftQMJ?o9 z6M#ayJzX3_BrePLMP6rwhGXqF9xV9& zHE?3e&O#7$+7#Un+9uuY%sLTj{GrjowxXZ1{S@ zBH4~XXWEzK+`HfJpX=EmVea`d)M$=@%E9TnhJOVws&zE&I3qo2{!h=Ae~g^_x%aUz z$m0QeL$$;;q9i4;B-JXpC>2OC7#SED=^B{o8X1Hbnp>F|TNxT^8yHv_7)Y8<>q60x bo1c=IR*73fMuwglPy>UftDnm{r-UW|!9%Tx diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_blue.png index 9dfb6238b9b3c06835c22ffaaffb3fa4ab8466fc..1f37f20b37a4824c24c78b734ef828410077a05c 100644 GIT binary patch delta 199 zcmV;&0671J1^NMy7#0Kr0002(-QrRJ0004VQb$4nuFf3kks%W#8&FJCMJOtKEG~#5 zBWW`=n;sq>CMG5d3JMk$7Aq?&s>{NblMewHeP~HUK~xyiV_*~z1Oi3@20`#8JHmEC;+Ws0}3z!rI-X57#M+;LY%=U003hL9YxQs(98e;002ovPDHLkV1nKW BIyC?Q literal 645 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJOS+@4BLl<6e(pbstU$g(vPY0F z14ES>14Ba#1H&(%P{RubhEf9thF1v;3|2E37{m+a>0w_f{cuew6wIW ztgND&pI&Rg~FS)I!cR0Vs6E)5S4F;xcc* z&9Y_%5gENO568uVYwrk!_?TqwQu+VC`01I)XJ+yWFsUq6m~=EcQ0ql=mH08KV97}N zR7R)d)!(k{yeApWFZ5%>;_rW69-f(el_4r@`8D6qdv@5Rn#-KIS=^I+?Z?D$PNV51 zcbBE!`~LdvHlY(npXXY(bf?R4+}crhZ{Mb*n=w)>OL!N4HavEwy3HkXQnkkPE>R?O;ZIh^Ml+|sj1^*)UY&QodFuZa z`q{Mb!VmVMKSD39&#(3a`cJjQHKHUXu_VKYk@7@Av|7+V<{ oY8x0>85l^KPU}L^kei>9nO2EgLq>+48Bha*r>mdKI;Vst0M6*iNB{r; diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_brown.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_brown.png index 79a1a3f5f29bab40229f1f33fa6a8f6c39d64ea1..b39d35cec94c76a43dd1a40c28d9b9a3b0e01648 100644 GIT binary patch delta 219 zcmey(@{4hTgcu7m0|Ud`yN`l^6k~CayA#8@b22X{Dhk(22l#}zMq4PP*eUxONEf+l z$jQm6si|>safykEX=`ie`h05#YT_*Lh%9Dc;N}BiMu&Y59f5)wo-U3d5|@(`Lq@0x(y z9wk+)g|e~>-}Ue`B@_#>NX}4rropf_ftkyIap?>e2?>eDX-;zvYA`S)v&*`kUw7dQ P&{76ZS3j3^P614Ba#1H&(%P{RubhEf9thF1v;3|2E37{m+a> zv{g#BQ%_+4k(QR0m6cUg zRP;5FwpJCDl#~<~7nhKb5D^g(6%`c{5)u;=)7910($dn?)02~v^D~qVFp`mylG4=F z)YjJ4(b18YmlqZmR##V7Qc}{;(6Cn*vr`lM|NlSF-Q#RPw=pJpySwNsUr`VQaySb- zB8wRqxcNYs(P7_1ppO~YOFVsD*`KkBG8>Cp$hjr}g)V!#IEF}E=AH1mtXV;zrQLOv zNRQi=O|FZMuoP$h{?{K~_Wx{6`tvhPP7O=ebS(L`LYg=9wSVHN2<6+8*Eqgd^Y(nR z^xTbaRT}k;tIyxJ(~-$#*T_7-clVmt&yJO-cHYvNmpq62ar!;g6L&7z#&7#-@vi^4 zpKHQ1^I7MZ_Y>_E9{safykEX=`iG$`(rpYT_*Lh%9Dc;N}BiMu&Y59f5)wo-U3d5|@(`Lq@0x(y z9wk+)g|e~>-}Ue`B@_#>NX}4rropf_ftkyIap?>e2?>eDX-;zvYA`S)v&*`kUw7dQ P&{76ZS3j3^P614Ba#1H&(%P{RubhEf9thF1v;3|2E37{m+a>W#G&D4LyaM>6l6XA*_~X*}V^f7o>;C`$-}9^966jRM zByV>Yla(7^{snS43p^r=85p?vK$y{C-$P&kFtC?+`ns||V-;mK7PXLbO#ljA_jGX# zk+{q|;bu{@fr#_d*EC@=$^ZXrF>Y<_8b{D$hW z@;x3CEYD9bopCI8cg%Y3Mjhk(Gn_4|pG{lPlYQ*#ypGJ$;@!<#6tCDFn^ALq!ih6) zut4H&%MldkSSiBZ@5Hl!Joi@q@SX{_zwg> zU3+H2Hv5-L9j5s4Y~O#nQ4`{HDqMynE^F0c)I$ztaD0e0sx7)(!u}$ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_gray.png index 6b6335f6458a9ed9ab5e3962d61be48d2ba41507..92a4adc7469ce3e6c15ffa2cc33791e4e5d2884e 100644 GIT binary patch delta 219 zcmey)@{4hTgcu7m0|Ud`yN`l^6k~CayA#8@b22X{Dhk(22l#}z8k$&`S=wsp=-WBD z$;rv7si|>safykEX=`i89$ESdsEM<{BeIx*ftwG686EaLbOZ`!c)B=-NL)@%5D{Qu za${t3R7*@wc4l>CV@#cVAs}7ZjZJN{iGoL1f`CbRZw9ZXK#G7LGqW38;`NTczH0(* zdz4hI7Rt&leAmO%lu#_hA~{3hnFhn!1ZFM+#-%e@BqSsnr#a0zsKLOH%r5JCe%*yL QKuZ}sUHx3vIVCg!0Q#Uj`2YX_ literal 631 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJOS+@4BLl<6e(pbstU$g(vPY0F z14ES>14Ba#1H&(%P{RubhEf9thF1v;3|2E37{m+a>_+4k(QR0m6cTl z0%bKVU3~>56-h}+adB}82?-Gq5m8Z5At50#F)>|TT`eswJv}`+IXP`z18qG+DJdyU zO-*fWZ5&pI&Rg~FS)I!cR0Vs6d)5S4F;xcc*#iV8f4we#A(bd;1 z(j$6iE$e-|>+k>PycLi6-tjTGI4okCc&a}*wc*?{w`*B5UUAQ5Son6QeE?;^nTytk2PvjQv@qJ zE9%RYgqb$VZvV5m$M&{`sMUwM0!5aia~T|uUfg$m&Q~A##TP|W)Z?l@`t>|BFx{U! zzyERhhHEPf_guOAR&M}J*BXQx!udKnIANW&yg{)hf_I(3- zO|`@|q9i4;B-JXpC>2OC7#SED0i#aW$RNbf+{(n*%Fs~Tz`)ADK+<$t7m9}5{FKbJ XO57SUGW5)V8W=oX{an^LB{Ts5J=4G0 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_green.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_green.png index a1be5289557ab00ad95f235b654dd9e1ceba007d..2af91963d0b3c15d6e7a38d6d4377d5b220dc489 100644 GIT binary patch delta 219 zcmeyu@{4hTgcu7m0|Ud`yN`l^6k~CayA#8@b22X{Dhk(22l#}zI){sS#!Fau3Wem# z$jQm6si|>safykEX=`g|v#vP`)Wlif5n0T@z|9B3j1K!AIsyeVJY5_^BrYc>hzPJS zxiPXiswE~TJF_~nF{Vzw5Rk6y#-_H}M8P90LBOQEH-lGGAVt8Bnc0mk@p?yJ-!%cZ zJxZ!p3uR>&zU$#>N+=d$k({CMOoL%<0yCEZvpW|wt6zwW{r Pprs6+u6{1-oD!M14Ba#1H&(%P{RubhEf9thF1v;3|2E37{m+a>saxJsj+FC@9Ft$Vf{|%gV|sDk|z) z^J`o1NlHqJi;GK0NQj7th>D5|2?>dbiRtRFLSI$yxh|NJ&X)YHDh0YwPIf z$ji$M3k$2Ot1BrfX=rHZ+3;KYidgvw|NsC0P&LM{um138=p9+AZi z4BUJm%;>Q1A<(-F>?NMQuI$fPMVXC7E#zDifI{azT^vIsE{jfxE^9X6adGEMSZ<^^ zLuB=_JwhiI=YHG2ch#lk>q`3B6qqE76^vXXL&V-?*mrETnZ3(|l|%jg>|*I%2mUcJ z*A&Swt~qMr@lE}JWPRQt3*X`wV%}`-a*Lka(H5?bF6=KcKdzgKyQO>Fn@ zx~{Q^@A$&m+m;J`788?6uvlvLY)+}1>sC?yho*V6=VgjrJs{}rdCR#g=_`NqXKj<) z`|7tV-jHuNb?dgfUlx;J!LChlC;l;2h@1K>?WhcXy6QhifW;ri*%AWB4tMgG1HGnN z;u=wsl30>zm0Xkxq!^40jEr;*Om&S6LJZBVOpL7z4YdsntPBh!O{aCCXvob^$xN%n Vtsx^r&kU%6!PC{xWt~$(699I*wv7M) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_light_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_light_blue.png index 478b507d59e0f091f9602c90d45f4d739c963846..fddaaf3d4632dc2eebc468e8b35e3be891cffb09 100644 GIT binary patch delta 199 zcmV;&0671j1^NMy7#0Kr0002(-QrRJ0004VQb$4nuFf3kks%W#8&FJCMK6%AGoHXG zdXzh~+a4YsCMG5d3JMk$7Aq?&?)PjplOX{ZeP~HUK~xyiV_*~z1Oi3@20`#8JHmEC;+Ws0}3z!rI-X57#M+;LY%=U003hL9YxQs(98e;002ovPDHLkV1jM3 BJh%V= literal 671 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJOS+@4BLl<6e(pbstU$g(vPY0F z14ES>14Ba#1H&(%P{RubhEf9thF1v;3|2E37{m+a>331h^o@zXMukq|X zMzeMs&)H`*W0ywdWTP27P39iZteI{!bC=Qd9rE!d)?02{Z@y)<>4tnlsd~jEg`{%p z%{LVk6l7#%q@|^0Wn~o=6%`W8G^(b`#}-OTN{Wk%OGrqFh=_=aiV6t{iHV8n>gsA~ zY3b?d$;ruS)J)T?n<*tFrKzc@t*x!2qa!abFDxvquCA`6q@Y0Rv_nlw-F>OwjpL+1*21__}Qw*+s<9f*JXbH^IY}M4~hC4 zS1=qtx~s5#-Rrw$7DCCH-{X?*s2+R&(zk=%YE62dcV{2V{B_G> z`F_T&TCX4Lwq0Qfv1fCeTQ~I|^M@JJb<;g=%YQNPpQ@MfobA7ejhGROf>$EYpQ!C8<`)MX5lF!N|bKNY}tr*T^8m(A>(z*vimQ+rYrez(CS;S{I6j-29Zxv`X9> UGBWhcfEpM)UHx3vIVCg!0CcP1x&QzG diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_light_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_light_gray.png index 6e38365fb2d1079115121030437b5c47aebc89a4..753976f576e5759ac43941022bf368951356ce63 100644 GIT binary patch delta 219 zcmeBX{lz#zLX3r(fq~)e-A6${im^Dz-HBn{IhmIe6@}}i1AIbU3kou-s*2;{B6@n7 z<>chl)YQ1RxWvT7w6(Q4Z2unxYT_*Lh%9Dc;N}BiMu&Y59f5)wo-U3d5|@(`Lq@0x(y z9wk+)g|e~>-}Ue`B@_#>NX}4rropf_ftkyIap?>e2?>eDX-;zvYA`S)v&*`kUw7dQ P&{76ZS3j3^P614Ba#1H&(%P{RubhEf9thF1v;3|2E37{m+a>{MaB5|NDmJeNl8g@ad8O=2@w$yQBhGLAt5m_FJ#$9UUEcd3j-BVRdzNB_$;d4GmvkkEEoS#Kh>Ts-pk@|0{ovNCUc)G0EHA z#n}96O&pNJS>O>_%)r3S2f~aF`yK*)&%j>d>Fdh=j8&A`Skyw!H32Ae-P6S}MB*~< zgxvBb1Ci#-(W|d)Rq#msvTlla;Dw#O|Nr+#``f9hTlzC7It0DzSaM6=h`02L{Go{C zBIWMMHVpx{_E=qCS9nZpEsI_5bKCl#7mCk#JDmIzvoldf{rVa4Nfxv275BuR`q3xO zX>|SPHonU{a<~7kRh*FejJ=p6{QMoEDTQZu)Ga@-iUb1;5t4Hc1}d4m-mGk~CZYF@Ff+RCP|O zzZkvOb=QJWuK(G`BJ_ rwlXx-HZZUTq5dSCy>8e zLQYOjO-+r9i%U#QOj}!<*YuMeP!nf?M`SSr12-QCGdk>h=m-?d@N{tuk+__kAR@rR zeb)rs z_9&@ZEtHjA_^yYiDWO=1MRJD1GYy8d3Cvsuj7w**NJvODPIH=bP=kRXnO)ZP{JINg QfR-|Ny85}Sb4q9e00yHx_y7O^ literal 658 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJOS+@4BLl<6e(pbstU$g(vPY0F z14ES>14Ba#1H&(%P{RubhEf9thF1v;3|2E37{m+a>c{?SnQ+RFDc=L8iC@3h%$jC@b zOUug2Dk>`4r0{yz3s@%dNJ>hIi;GK0NQj7th>D5|2?>dbiRtRFLSI$@w-5 zN=Zp+YHDh0YwPIf$ji$M3k$2Ot1BrfX=rHJrt^B&3D~6a`ZWvsHVGy!7XAPKzm)08 z9-wO(lf2zsOz&;GnGNJ{7I;J!Gca)TfiR=PzK6gtU|=ut^mS!_#wyBeENUU=ngA5K z;pyTSB5|2_!pmvR3L?$SA+3DtM2}Cj?&w-uHgj$5|8!};I<@ECehkMBv|1GCO)@#D zawTw|;oR)ljKF0|jP9Z0XIGlez4*0SzoEZo!!*0K(kI157q}E=oiRDz{nBa4!xiq{ z_xKHy*`ru@*tMTF)BU_Je%M<21)F8aW)xIiRm;#13eKtHOMxJHzuB$lLFB^RXvDF!10BO_e{ zQ(Ys25JPh-6JskwLu~^CD+2>b(`j8O8glbfGSez?YskpZGXrX1@O1TaS?83{1ONh! B&)NV0 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_magenta.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_magenta.png index df71299f5508c53314a689869940c72129fb9669..200954e487901e1735e793136099ea17471a1c17 100644 GIT binary patch delta 219 zcmbQi`ipUbgcu7m0|Ud`yN`l^6k~CayA#8@b22X{Dhk(22l#}zPBH3PY(BG2t8AD3 zdO0~cH8nLZE-o=KF>P(_`TC3Q05x$IctjR6FmUsMFr&l1hmJtO3{Mxw5Q)pl2_gb4 zOm2*9j%ta?$cUsF9f73yRoTlHc{{hOAs(A@6F)V6i5;9V`g?^OT6CE*LO|8 zZI6h3|TJni7hISR`jCJkwxUo50Lvz_@emdKI;Vst0CxXBE&u=k literal 664 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJOS+@4BLl<6e(pbstU$g(vPY0F z14ES>14Ba#1H&(%P{RubhEf9thF1v;3|2E37{m+a>tbgt=?#pW{`v@7SCO`T&pIY}{gm;L&k_Um@otxZ;nt_+4k(QR0m6cUgR7_EdtJ5w|P>hz8loS^imynPU5fKp;6%`T^5)%{C)z#I~($dq@ zlarHc(5`6GsgjbC($v({*4Eb1(UF&z7Zw&)S65e3Qqs`SNK;Oz)hcV&sczJ%Tx34u z|NsAvpJ%)TI+!uZ+ug;?eSgPAAcwQSBeIx*ftwG686EaL1O@{Gdx@v7EBiB6QD$RN z3pv*WpwMkk7sn8Z%e)g_7adX%X_?*}cF-v)X~W7nLPCbKDqgzY|9|z=oAZCu%F7rP z9fI^ao_xyP8g@bYt6q=kGJ{QbPKk0%)qNHF_}jS~{b5Y=zdf+6|9PQMN6X=KQuyvV ziN3t~ekvOc=RTLy)PVl+x~K1=i?_q zyBoGBn%EtiQG0$u#Ox<>e@&jwuu@fBaI%6gGWNrojs;%73%;71zu#N@ie2FLrFnUV zPt+Ftx_TjLP0KIl4>8l$#wh34U-I7XvTs3b)*t4*nWDKrx%X59y{TH_8c~vxSdwa$ zT$Bo=7>o>zjC2i5b&U){49%@fjI9g}wG9lc3=AYqr*)xd$jwj5OsmALAtOW245)#@ M)78&qol`;+06i+?wEzGB diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_orange.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_orange.png index c83528225e3f46ca51e93fb720ed1ad44b544e02..a76a4088477386e2ff8a9fa3e4d552e597aa9313 100644 GIT binary patch delta 199 zcmV;&0671j1^NMy7#0Kr0002(-QrRJ0004VQb$4nuFf3kks%W#8&FJCMZ{bT*JTc- zP73vO5FQ>LCMG5d3JMk$7Aq?&ojW5?lOX{ZeP~HUK~xyiV_*~z1Oi3@20`#8JHmEC;+Ws0}3z!rI-X57#M+;LY%=U003hL9YxQs(98e;002ovPDHLkV1g)@ BI%@y` literal 671 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJOS+@4BLl<6e(pbstU$g(vPY0F z14ES>14Ba#1H&(%P{RubhEf9thF1v;3|2E37{m+a>32|NS&wV+C?@|ii z#bmxKseBib_?Gx_pHJewmddv>fcru+-?>EICR>iLB?4bc1U?lDG~015_T_G~=lonO zprD{2BO@a%EiEf6tEi~hV#m46pS#|MLsC*wTwGj2LPA7DL{wB%NJvObOiWi-S4&Gv zPft%yPHsg2_v%1yDJdyUO-*fWZ5Fdh= zj8&A`Skyw!H32Ae$J50zMB*~Tg`Z zaQNu1!uEBq@0M8zC1-w*OS+?a?ERA?3e|FYj~BjQ_OfX2JdP>dCwx^}Hj8I+9@~{` zUZ=K5{_cfy2P!$F<&%B(i5nPM@A#c46YOKm6LoOHSD{JY4tA?G>3!aveJu0WEsN#* z8MkV^eyrPeg(bwE&24Vo)PKw$W=z*j_qZ+p#l(NAUdD5_{~|VGMl1?mi9mmnC}Q!>*kacjuP S&@%&SVDNPHb6Mw<&;$T|LE2aV diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_pink.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_pink.png index b746081b9ffce011ae111a4711e08a5a36eb5374..696132048fab7771635aa4f62bd94ab7864f2bbb 100644 GIT binary patch delta 199 zcmV;&0671j1^NMy7#0Kr0002(-QrRJ0004VQb$4nuFf3kks%W#8&FJCMZ#~0)q0hr zUUTz{svaI5CMG5d3JMk$7Aq?&g;E@-lOX{ZeP~HUK~xyiV_*~z1Oi3@20`#8JHmEC;+Ws0}3z!rI-X57#M+;LY%=U003hL9YxQs(98e;002ovPDHLkV1l&B BJqQ2* literal 671 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJOS+@4BLl<6e(pbstU$g(vPY0F z14ES>14Ba#1H&(%P{RubhEf9thF1v;3|2E37{m+a>32|K(UvjBp^2PE= z7s@AIu9$qTY{KH$qO+y_SF5J3NGLsDHt|epf1_8_=k8UXx>kPZT+!qey(qS@#V7V- z*GdHi1sNF`X=!O$Sy@Fz#b)p5rE$e|9ubm~lH%gx5)u+3A|j%qqC!GKVq#*ty1H6g zT6%hVa&mIZ<4ad1mP<)VX=-X}YisN1=*Y{<3kwUYtE($1DQReEwEDy@i7RgLj#-^l zzA~ZgO68RQ|Nk5O;&lZ&n=#4T-Nj-7`_gMb4rhT!WHAE+Hy;QyI_!H03=9VL5>H=O z_Ghf3%*LV?a;^zLp*x-~jv*44c_+LsYcddMQQsZqnZv-?yEIK&`2p*eZ_D2QPdhtv z{^z+fjhQuAljaG2{F6E{bH>uTP_ymZHpHx}U~~!$a=@`M44b8W1gsk6TS*f`gX8etx50m?(AckziwG9 z-_N*J>-A&Zwks?l_H1r*>!$u={xD;@Zo0>9`7b8^Q}r^Qv;7yb5i?>@@Ja;wQ?2OC7#SED=^B{o8X1Hbnp>F|TNxT^8yHv_7)Y8<>q60xo1c=IR*73f TMuwglPy>UftDnm{r-UW|S7GTW diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_purple.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_purple.png index e521a3972ffc4f554186080fc984cf962314b2b4..0732760a25335689293ed47a3d46a50c4c263532 100644 GIT binary patch delta 219 zcmbQj`ipUbgcu7m0|Ud`yN`l^6k~CayA#8@b22X{Dhk(22l#}z#>lm&Do*i}EGki3 zDJLhVrl!Wl#U&;trmd~b`fX_iP!nf?M`SSr12-QCGdk>h=m-?d@N{tuk+__kAR@rR zeb)rs z_9&@ZEtHjA_^yYiDWO=1MRJD1GYy8d3Cvsuj7w**NJvODPIH=bP=kRXnO)ZP{JINg QfR-|Ny85}Sb4q9e0BY$yq5uE@ literal 660 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJOS+@4BLl<6e(pbstU$g(vPY0F z14ES>14Ba#1H&(%P{RubhEf9thF1v;3|2E37{m+a> zSz$t|;-n;nem}{=B!#|I#VG+&rHKlCwjz-wYAZ|BRuro(w-br-l`OOujVV@Jp`f53 zBO@a%EiEf6tEi}GClYNV5-uqzDK0K9At50mA|fg(DkLN%CMKq0t*xV@BQGy6EG(?9uCAn{q@khVAR6l@Rb($39VlHMC{>!OIQjqo z{}B(9K@Mh2@^*JIbKl=_5y;^z@Q5sCVBqEhVMd324}rnJz+U3%>&pI&Rg~FS)I!cR z0Vs6c)5S4F;xg}q-0~&^k><;BbFYXBOxSdBchG`GuFvm%`Tu|G*C)wEpXRU#Fipx( zR?Uqso5}R{>go$SueC1wFyyd$v!rUn6}(T+|^%M%vi#a?Y-T zNiBQjbgJ(!?|ECP=uyiz-QwKkU2*HKyE;8PQdgCPov(jgm0G-yu~6gn<+Hn8m{!R% zbv_MWVb9Q?%Xwh=m-?d@N{tuk+__kAR@rR zeb)rs z_9&@ZEtHjA_^yYiDWO=1MRJD1GYy8d3Cvsuj7w**NJvODPIH=bP=kRXnO)ZP{JINg QfR-|Ny85}Sb4q9e04P2^E&u=k literal 639 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJOS+@4BLl<6e(pbstU$g(vPY0F z14ES>14Ba#1H&(%P{RubhEf9thF1v;3|2E37{m+a>sEDwFf`W{UjI^}0tgNh} zqGE`MP@u4oq@<*{xVVIbgoucUsHmurkdT;|n69p_mX?;Do}QeXT(+cmu9Sq7l$55X zrna`Wj*gDJyu7fmu)4asl9G~!hDMl(aGsPzj+Dgz|NmD8|Gfuv9%GWXyNkiPJGxJR z9L@rd$YKTtZaxrZblCS0=xGM_5>H=O_Ghf3%*LV?a;^zLp(~y)jv*44c_+M{)T|)V zeE1-j=$f!Mry^aJZo75*-M7E@^Jf0>QM<3wAfTYhI#Gwub>)KoRYJ$4f~6zprZ74s zzy5Y-=RL{lMwWeV9@y6ZHYi#n?Qr_non4vp#IG;c_LMpM!t$76`kw=%D-&% z{`cRH5u7PAf1Z>%bk;b%&1~KL?cshpv%Li-n6;ccF0uK&WwQ6=JJq+g#av#tgvCVi zyka)bJW;`r)cfo1e*3$;*zYgXqmY}gjoW;fW;M5oy>?w;&oF;clg`BL^((F{Jt4l} z!Vh-k&4L$x$Xf&g{ij;u8c~vxSdwa$T$Bo=7>o>zjC2i5b&U){49%@fjI9g}wG9lc k3=AYqr*)xd$jwj5OsmALAtOW245)#@)78&qol`;+0N2~dy#N3J diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_yellow.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/vent_yellow.png index 2d492e7cec198d4b619d8b4d2d069ba9efed1bb2..8a210033d46fb2ab59e729aa241aff6784ac3be0 100644 GIT binary patch delta 199 zcmV;&0671j1^NMy7#0Kr0002(-QrRJ0004VQb$4nuFf3kks%W#8&FJCMaiEW-L4<1 zhZy|FBpx0fCMG5d3JMk$7Aq?&T1I${lOX{ZeP~HUK~xyiV_*~z1Oi3@20`#8JHmEC;+Ws0}3z!rI-X57#M+;LY%=U003hL9YxQs(98e;002ovPDHLkV1hOY BJT?FT literal 671 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJOS+@4BLl<6e(pbstU$g(vPY0F z14ES>14Ba#1H&(%P{RubhEf9thF1v;3|2E37{m+a>32|N1A$fC+{EgM} z*H_8kS|fjTrQFI^i7PAQ?yQqv*C}~zrTpdPa;=%de~zpCKBn^Xs7hOw@QPN6&K!|n zM^zLQ6l7#%q@|^0Wn~o=72C6gSGP+vr3*_+N{Wk%OGrqFh=_=aiV6t{iHV8n>gsA~ zY3b?d$;rvB?UdZmEh!}>rKzc@t*x!2qa!abFDxvquCA`6q@`Si!Ih+L^k;M!Q+Cp$hjr}h3oULpd9M2BheZ92 zD;N$R-BsAW?)BX=3!&u9?{P_YRFA!Xazvq8PVe!;_sd=u?VZOlrTc`hO3P;POwMDw za?R`17RleeaPB}QhqQdM&pvSjBkLW%6J>&ZjCrCCPWUP`>D$3>wI;pKyR(mF{<>wc zd_Ut>t=Err+pe&L*t5CKt(*Ff`NNFqy6GOb<-eHtPu0tK&h}r#M$Cvs!7CByPt_9F zh?11Vl2ohYqEsNoU}Ruqq-$WRYh(~&Xl`X Date: Mon, 13 Mar 2023 20:21:36 +0600 Subject: [PATCH 0345/1199] essence drive and capsule --- .../mc/otm/datagen/items/ItemModels.kt | 3 +++ .../textures/item/essence_capsule.png | Bin 0 -> 299 bytes .../textures/item/essence_drive.png | Bin 0 -> 307 bytes 3 files changed, 3 insertions(+) create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/essence_capsule.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/essence_drive.png diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index c29cc52a1..03b014868 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -58,6 +58,9 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.generated(MItems.PILL_HEAL) provider.generated(MItems.NUTRIENT_PASTE) + provider.generated(MItems.ESSENCE_DRIVE) + provider.generated(MItems.ESSENCE_CAPSULE) + for (item in MItems.ExopackUpgrades.INVENTORY_UPGRADES) { provider.generated(item, modLocation("item/exosuit_inventory_upgrade")) } diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/essence_capsule.png b/src/main/resources/assets/overdrive_that_matters/textures/item/essence_capsule.png new file mode 100644 index 0000000000000000000000000000000000000000..d1cb9fc8582da5b5298254e1399638b2dd226dd9 GIT binary patch literal 299 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}@0G|-oumAgRJc$w$6AKIsR8v#4@$mPHP0wxW_xaDzIBSK?enxF=ZJ^qn z2R^3*Dc+JGzu^B!fWh{KQX5c$v%n*=n1O-s5C}7hYIrpO1xq|#978mML;C}T4hZnL zOy1H`^#5~N`Nf&fj_+yTnlsO^T$icGo#i1%|La}M>DwOE9k`+HwN}vlj8NDnvsndC zBVO*^x;*dTZ_i_b?#E7@U;g~T?y^st`AwS{4C_~Dutxk$+T*a~MsL8|<2hQz5m$5n d%NRfBKD37I#g8xP20;56JYD@<);T3K0RW9YbB6!` literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/essence_drive.png b/src/main/resources/assets/overdrive_that_matters/textures/item/essence_drive.png new file mode 100644 index 0000000000000000000000000000000000000000..8ed76f51b84ae3f5a89cc7b6ecd0ab1c08cfa0bb GIT binary patch literal 307 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}r0G|-o8&9HaJp8}@@6T=OZ=AKl=RZSWU|>^I(~1= Date: Mon, 13 Mar 2023 22:37:25 +0700 Subject: [PATCH 0346/1199] fix store all not storing everything if player level is 1 and has partial level --- .../mc/otm/client/screen/tech/EssenceStorageScreen.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt index feba92c9b..6b199f79b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt @@ -125,7 +125,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title } override fun onClick(mouseButton: Int) { - menu.storeLevels.input(minecraft?.player?.experienceLevel ?: 0) + menu.storeLevels.input((minecraft?.player?.experienceLevel ?: 0) + 1) } override var isDisabled: Boolean From db2ab57bfc4e96f12608460cf14a20578285e60c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 13 Mar 2023 22:53:41 +0700 Subject: [PATCH 0347/1199] don't trigger AndroidTravelUnderwater if you have air bags --- .../dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 60f2b8c83..0cfa76cc1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -816,8 +816,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } else { if (wasInLiquid) { wasInLiquid = false - val distance = (lastOutsideLiquid - ply.position).length() - AndroidTravelUnderwater.trigger(ply, distance) + + if (!hasFeature(AndroidFeatures.AIR_BAGS)) + AndroidTravelUnderwater.trigger(ply, (lastOutsideLiquid - ply.position).length()) } lastOutsideLiquid = ply.position From 312795df9348e24738f0f5747a9a61c6ddb8115f Mon Sep 17 00:00:00 2001 From: GearShocky Date: Tue, 14 Mar 2023 13:15:38 +0600 Subject: [PATCH 0348/1199] Change translucent to cutout --- .../assets/overdrive_that_matters/models/block/metal_mesh.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/metal_mesh.json b/src/main/resources/assets/overdrive_that_matters/models/block/metal_mesh.json index 33d08171a..b18a8d695 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/metal_mesh.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/metal_mesh.json @@ -1,6 +1,6 @@ { "parent": "minecraft:block/cube_all", - "render_type": "translucent", + "render_type": "cutout", "textures": { "all": "overdrive_that_matters:block/decorative/metal_mesh" } From 594e6c9fbf1e459e01eebf08fcd1e6997ffa1321 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 14 Mar 2023 16:19:00 +0700 Subject: [PATCH 0349/1199] Androids don't need to breathe oxygen --- build.gradle.kts | 11 +++++-- gradle.properties | 1 + .../mc/otm/OverdriveThatMatters.java | 7 +++++ .../ad_astra/EntityOxygenSystemMixin.java | 31 +++++++++++++++++++ .../compat/ad_astra/OxygenUtilsMixin.java | 31 +++++++++++++++++++ .../mc/otm/compat/adastra/AdAstraCompat.kt | 28 +++++++++++++++++ .../mc/otm/config/ServerCompatConfig.kt | 21 +++++++++++++ ...verdrive_that_matters.ad_astra.mixins.json | 12 +++++++ 8 files changed, 139 insertions(+), 3 deletions(-) create mode 100644 src/main/java/ru/dbotthepony/mc/otm/mixin/compat/ad_astra/EntityOxygenSystemMixin.java create mode 100644 src/main/java/ru/dbotthepony/mc/otm/mixin/compat/ad_astra/OxygenUtilsMixin.java create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerCompatConfig.kt create mode 100644 src/main/resources/overdrive_that_matters.ad_astra.mixins.json diff --git a/build.gradle.kts b/build.gradle.kts index 361d035c9..55a604fcb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -185,6 +185,7 @@ dependencies { val deps_mc_version: String by project val jei_mc_version: String by project val curios_mc_version: String by project + val ad_astra_id: String by project implementation(fg.deobf("top.theillusivec4.curios:curios-forge:${curios_mc_version}-${curios_version}")) implementation(fg.deobf("curse.maven:cosmetic-armor-reworked-237307:$cosmetic_armor_reworked_id")) @@ -196,6 +197,11 @@ dependencies { runtimeOnly(fg.deobf("curse.maven:jade-324717:${jade_id}")) runtimeOnly(fg.deobf("curse.maven:configured-457570:${configured_id}")) + implementation(fg.deobf("curse.maven:ad-astra-635042:${ad_astra_id}")) + implementation(fg.deobf("curse.maven:resourceful-lib-570073:4378849")) + implementation(fg.deobf("curse.maven:resourceful-config-714059:4394154")) + implementation(fg.deobf("curse.maven:botarium-704113:4416456")) + // runtimeOnly(fg.deobf("curse.maven:worldedit-225608:${worldedit_fileid}")) // runtimeOnly(fg.deobf("at.ridgo8.moreoverlays:MoreOverlays-updated:${more_overlays_version}")) @@ -256,8 +262,6 @@ minecraft { } else { args("--username", "Dev_${System.getProperty("user.name")}") } - - args("-mixin.config=$mod_id.mixins.json") } create("server") { @@ -267,7 +271,7 @@ minecraft { } } - args("nogui", "-mixin.config=$mod_id.mixins.json") + args("nogui") } create("data") { @@ -287,6 +291,7 @@ minecraft { mixin { add(sourceSets.main.get(), "$mod_id.refmap.json") config("$mod_id.mixins.json") + config("$mod_id.ad_astra.mixins.json") } minecraft.runs.all { diff --git a/gradle.properties b/gradle.properties index af6b696a1..da9732d31 100644 --- a/gradle.properties +++ b/gradle.properties @@ -29,6 +29,7 @@ jupiter_version=5.8.2 mekanism_version=10.3.5.homebaked curios_version=5.1.4.0 cosmetic_armor_reworked_id=4145717 +ad_astra_id=4390126 jade_id=4330163 configured_id=4166861 worldedit_fileid=3922622 diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 46bf4ab8b..5915b8e75 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -33,12 +33,14 @@ import ru.dbotthepony.mc.otm.client.model.TritaniumArmorModel; import ru.dbotthepony.mc.otm.client.render.ShockwaveRenderer; import ru.dbotthepony.mc.otm.client.render.blockentity.BatteryBankRenderer; import ru.dbotthepony.mc.otm.client.render.blockentity.MatterBatteryBankRenderer; +import ru.dbotthepony.mc.otm.compat.adastra.AdAstraCompatKt; import ru.dbotthepony.mc.otm.compat.mekanism.QIOKt; import ru.dbotthepony.mc.otm.compat.mekanism.TooltipsKt; import ru.dbotthepony.mc.otm.config.AndroidConfig; import ru.dbotthepony.mc.otm.config.ClientConfig; import ru.dbotthepony.mc.otm.config.ItemsConfig; import ru.dbotthepony.mc.otm.config.MachinesConfig; +import ru.dbotthepony.mc.otm.config.ServerCompatConfig; import ru.dbotthepony.mc.otm.config.ServerConfig; import ru.dbotthepony.mc.otm.config.ToolsConfig; import ru.dbotthepony.mc.otm.core.math.Decimal; @@ -130,6 +132,7 @@ public final class OverdriveThatMatters { ClientConfig.INSTANCE.register(); ServerConfig.INSTANCE.register(); + ServerCompatConfig.INSTANCE.register(); AndroidConfig.INSTANCE.register(); ItemsConfig.INSTANCE.register(); MachinesConfig.INSTANCE.register(); @@ -195,6 +198,10 @@ public final class OverdriveThatMatters { if (ModList.get().isLoaded("mekanism")) { EVENT_BUS.addGenericListener(BlockEntity.class, EventPriority.NORMAL, QIOKt::attachCapabilities); } + + if (AdAstraCompatKt.isAdAstraLoaded()) { + EVENT_BUS.addListener(EventPriority.NORMAL, AdAstraCompatKt::onDamageEvent); + } } private void setupClient(final FMLClientSetupEvent event) { diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/compat/ad_astra/EntityOxygenSystemMixin.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/compat/ad_astra/EntityOxygenSystemMixin.java new file mode 100644 index 000000000..846e5b221 --- /dev/null +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/compat/ad_astra/EntityOxygenSystemMixin.java @@ -0,0 +1,31 @@ +package ru.dbotthepony.mc.otm.mixin.compat.ad_astra; + +import earth.terrarium.ad_astra.common.entity.system.EntityOxygenSystem; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import ru.dbotthepony.mc.otm.capability.MatteryCapability; +import ru.dbotthepony.mc.otm.config.ServerCompatConfig; + +@Mixin(EntityOxygenSystem.class) +public class EntityOxygenSystemMixin { + @Inject( + method = "oxygenTick()V", + at = @At("HEAD"), + cancellable = true, + remap = false + ) + private static void oxygenTick(LivingEntity entity, ServerLevel level, CallbackInfo hook) { + if (entity instanceof Player && ServerCompatConfig.AdAstra.INSTANCE.getANDROIDS_DO_NOT_NEED_OXYGEN()) { + entity.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresent(it -> { + if (it.isAndroid()) { + hook.cancel(); + } + }); + } + } +} diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/compat/ad_astra/OxygenUtilsMixin.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/compat/ad_astra/OxygenUtilsMixin.java new file mode 100644 index 000000000..30f8e465d --- /dev/null +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/compat/ad_astra/OxygenUtilsMixin.java @@ -0,0 +1,31 @@ +package ru.dbotthepony.mc.otm.mixin.compat.ad_astra; + +import earth.terrarium.ad_astra.common.util.OxygenUtils; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import ru.dbotthepony.mc.otm.capability.MatteryCapability; +import ru.dbotthepony.mc.otm.config.ServerCompatConfig; + +@Mixin(OxygenUtils.class) +public class OxygenUtilsMixin { + @Inject( + method = "entityHasOxygen()Z", + at = @At("HEAD"), + cancellable = true, + remap = false + ) + private static void entityHasOxygen(Level level, LivingEntity entity, CallbackInfoReturnable hook) { + if (entity instanceof Player && ServerCompatConfig.AdAstra.INSTANCE.getANDROIDS_DO_NOT_NEED_OXYGEN()) { + entity.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresent(it -> { + if (it.isAndroid()) { + hook.setReturnValue(true); + } + }); + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt new file mode 100644 index 000000000..61d89098b --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt @@ -0,0 +1,28 @@ +package ru.dbotthepony.mc.otm.compat.adastra + +import earth.terrarium.ad_astra.AdAstra +import earth.terrarium.ad_astra.common.registry.ModDamageSource +import net.minecraft.world.entity.player.Player +import net.minecraftforge.event.entity.living.LivingHurtEvent +import net.minecraftforge.fml.ModList +import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.config.ServerCompatConfig + +val isAdAstraLoaded by lazy { + ModList.get().isLoaded(AdAstra.MOD_ID) +} + +// для надёжности +fun onDamageEvent(event: LivingHurtEvent) { + check(isAdAstraLoaded) { "Ad Astra is not loaded!" } + val ply = event.entity as? Player ?: return + + if (ServerCompatConfig.AdAstra.ANDROIDS_DO_NOT_NEED_OXYGEN) { + if (ply.matteryPlayer?.isAndroid != true) return + + if (event.source === ModDamageSource.OXYGEN) { + event.amount = 0f + event.isCanceled = true + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerCompatConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerCompatConfig.kt new file mode 100644 index 000000000..7c300186f --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerCompatConfig.kt @@ -0,0 +1,21 @@ +package ru.dbotthepony.mc.otm.config + +object ServerCompatConfig : AbstractConfig("compat-server") { + object AdAstra { + init { + builder.push("AD_ASTRA") + } + + val ANDROIDS_DO_NOT_NEED_OXYGEN: Boolean by builder + .comment("Android do not need oxygen in space") + .define("ANDROIDS_DO_NOT_NEED_OXYGEN", true) + + init { + builder.pop() + } + } + + init { + AdAstra + } +} diff --git a/src/main/resources/overdrive_that_matters.ad_astra.mixins.json b/src/main/resources/overdrive_that_matters.ad_astra.mixins.json new file mode 100644 index 000000000..9ee2f082a --- /dev/null +++ b/src/main/resources/overdrive_that_matters.ad_astra.mixins.json @@ -0,0 +1,12 @@ + +{ + "required": false, + "package": "ru.dbotthepony.mc.otm.mixin.compat.ad_astra", + "compatibilityLevel": "JAVA_17", + "minVersion": "0.8", + "refmap": "overdrive_that_matters.refmap.json", + "mixins": [ + "EntityOxygenSystemMixin", + "OxygenUtilsMixin" + ] +} From efc1642254042e5c22588a9683c8af1a9e4b0666 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 14 Mar 2023 16:21:19 +0700 Subject: [PATCH 0350/1199] Revert "Manually write android_immune_effects.json" This reverts commit 1b8e1d147fb7442a50451c0425725ee274c938d5. because minecraft engine is stupid --- .../ru/dbotthepony/mc/otm/datagen/tags/Tags.kt | 17 +++++++++++++++++ .../mc/otm/datagen/tags/TagsProvider.kt | 2 ++ .../tags/mob_effect/android_immune_effects.json | 15 --------------- 3 files changed, 19 insertions(+), 15 deletions(-) delete mode 100644 src/main/resources/data/overdrive_that_matters/tags/mob_effect/android_immune_effects.json diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index aaf8e4147..2b23f8acf 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -228,4 +228,21 @@ fun addTags(tagsProvider: TagsProvider) { tagsProvider.witherImmune.add( MBlocks.BLACK_HOLE, ) + + tagsProvider.androidImmuneEffects.add( + MobEffects.CONDUIT_POWER, + MobEffects.HEAL, + // maybe it makes things go haywire idk + // MobEffects.HARM, + MobEffects.REGENERATION, + MobEffects.WATER_BREATHING, + MobEffects.POISON, + // even skeletons can be withered + // MobEffects.WITHER, + MobEffects.HEALTH_BOOST, + MobEffects.ABSORPTION, + MobEffects.SATURATION, + MobEffects.DOLPHINS_GRACE, + MobEffects.CONFUSION, + ) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt index 4abe105c9..67bbdcb67 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt @@ -187,6 +187,8 @@ class TagsProvider( val items = Delegate(ForgeRegistries.ITEMS) val mobEffects = Delegate(ForgeRegistries.MOB_EFFECTS) + val androidImmuneEffects = mobEffects.appender(MatteryPlayerCapability.ANDROID_IMMUNE_EFFECTS) + val requiresShovel = blocks.appender(BlockTags.MINEABLE_WITH_SHOVEL) val requiresAxe = blocks.appender(BlockTags.MINEABLE_WITH_AXE) val requiresHoe = blocks.appender(BlockTags.MINEABLE_WITH_HOE) diff --git a/src/main/resources/data/overdrive_that_matters/tags/mob_effect/android_immune_effects.json b/src/main/resources/data/overdrive_that_matters/tags/mob_effect/android_immune_effects.json deleted file mode 100644 index 40a9eca7b..000000000 --- a/src/main/resources/data/overdrive_that_matters/tags/mob_effect/android_immune_effects.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "values": [ - "minecraft:conduit_power", - "minecraft:instant_health", - "minecraft:regeneration", - "minecraft:water_breathing", - "minecraft:poison", - "minecraft:health_boost", - "minecraft:absorption", - "minecraft:saturation", - "minecraft:dolphins_grace", - "minecraft:nausea", - "hordes:infected" - ] -} \ No newline at end of file From 2c745a302fe916d576e12a188b71c95bfa43732a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 14 Mar 2023 16:55:43 +0700 Subject: [PATCH 0351/1199] fix ad astra temperature system --- build.gradle.kts | 8 +++--- .../EntityTemperatureSystemMixin.java | 28 +++++++++++++++++++ .../mc/otm/config/ServerCompatConfig.kt | 5 ++++ ...verdrive_that_matters.ad_astra.mixins.json | 1 + 4 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 src/main/java/ru/dbotthepony/mc/otm/mixin/compat/ad_astra/EntityTemperatureSystemMixin.java diff --git a/build.gradle.kts b/build.gradle.kts index 55a604fcb..00f759523 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -197,10 +197,10 @@ dependencies { runtimeOnly(fg.deobf("curse.maven:jade-324717:${jade_id}")) runtimeOnly(fg.deobf("curse.maven:configured-457570:${configured_id}")) - implementation(fg.deobf("curse.maven:ad-astra-635042:${ad_astra_id}")) - implementation(fg.deobf("curse.maven:resourceful-lib-570073:4378849")) - implementation(fg.deobf("curse.maven:resourceful-config-714059:4394154")) - implementation(fg.deobf("curse.maven:botarium-704113:4416456")) + compileOnly(fg.deobf("curse.maven:ad-astra-635042:${ad_astra_id}")) + // implementation(fg.deobf("curse.maven:resourceful-lib-570073:4378849")) + // implementation(fg.deobf("curse.maven:resourceful-config-714059:4394154")) + // implementation(fg.deobf("curse.maven:botarium-704113:4416456")) // runtimeOnly(fg.deobf("curse.maven:worldedit-225608:${worldedit_fileid}")) // runtimeOnly(fg.deobf("at.ridgo8.moreoverlays:MoreOverlays-updated:${more_overlays_version}")) diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/compat/ad_astra/EntityTemperatureSystemMixin.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/compat/ad_astra/EntityTemperatureSystemMixin.java new file mode 100644 index 000000000..a68cc5728 --- /dev/null +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/compat/ad_astra/EntityTemperatureSystemMixin.java @@ -0,0 +1,28 @@ +package ru.dbotthepony.mc.otm.mixin.compat.ad_astra; + +import earth.terrarium.ad_astra.common.data.Planet; +import earth.terrarium.ad_astra.common.data.PlanetData; +import earth.terrarium.ad_astra.common.entity.system.EntityTemperatureSystem; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.LivingEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import ru.dbotthepony.mc.otm.config.ServerCompatConfig; + +// STAHP! +@Mixin(EntityTemperatureSystem.class) +public class EntityTemperatureSystemMixin { + @Inject( + method = "temperatureTick(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/server/level/ServerLevel;)V", + at = @At("HEAD"), + cancellable = true, + remap = false + ) + private static void temperatureTick(LivingEntity entity, ServerLevel level, CallbackInfo hook) { + if (ServerCompatConfig.AdAstra.INSTANCE.getWHATS_UP_WITH_TEMPERATURE() && !PlanetData.getPlanetFromLevel(level.dimension()).map(Planet::hasAtmosphere).orElse(true)) { + hook.cancel(); + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerCompatConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerCompatConfig.kt index 7c300186f..1b1150dc4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerCompatConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerCompatConfig.kt @@ -10,6 +10,11 @@ object ServerCompatConfig : AbstractConfig("compat-server") { .comment("Android do not need oxygen in space") .define("ANDROIDS_DO_NOT_NEED_OXYGEN", true) + val WHATS_UP_WITH_TEMPERATURE: Boolean by builder + .comment("Disables temperature mechanics on planets without atmosphere.") + .comment("I attended physics classes in middle school, and this kills me.") + .define("WHATS_UP_WITH_TEMPERATURE", true) + init { builder.pop() } diff --git a/src/main/resources/overdrive_that_matters.ad_astra.mixins.json b/src/main/resources/overdrive_that_matters.ad_astra.mixins.json index 9ee2f082a..2ee1936df 100644 --- a/src/main/resources/overdrive_that_matters.ad_astra.mixins.json +++ b/src/main/resources/overdrive_that_matters.ad_astra.mixins.json @@ -7,6 +7,7 @@ "refmap": "overdrive_that_matters.refmap.json", "mixins": [ "EntityOxygenSystemMixin", + "EntityTemperatureSystemMixin", "OxygenUtilsMixin" ] } From 34aaab371ec93be8c1af8fdba6d7911221af7a2d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 14 Mar 2023 17:36:23 +0700 Subject: [PATCH 0352/1199] Androids now get damaged without spacesuits on planets without atmosphere --- .../mc/otm/datagen/lang/English.kt | 1 + .../mc/otm/datagen/lang/Russian.kt | 1 + .../mc/otm/OverdriveThatMatters.java | 1 + .../EntityTemperatureSystemMixin.java | 5 +-- .../otm/capability/MatteryPlayerCapability.kt | 37 +++++++++++++++++++ .../mc/otm/compat/adastra/AdAstraCompat.kt | 26 +++++++++++++ .../mc/otm/config/ServerCompatConfig.kt | 14 +++++++ .../mc/otm/registry/DamageSources.kt | 2 +- .../dbotthepony/mc/otm/registry/MRegistry.kt | 9 +++-- 9 files changed, 89 insertions(+), 7 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 2e8e1c4ec..8efb2f333 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -334,6 +334,7 @@ private fun death(provider: MatteryLanguageProvider) { death("otm_event_horizon", "%1\$s never crossed the event horizon") death("otm_hawking_radiation", "%1\$s discovered Hawking radiation") death("otm_emp", "%1\$s electronics' fried") + death("otm_cosmic_rays", "%1\$s electronics' got scrambled by cosmic radiation") death("otm_become_android.player", "%1\$s lost their humanity whilst %2\$s tried to reason with them") death("otm_become_humane.player", "%1\$s gained their humanity whilst %2\$s tried to reason with them") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 451628da2..de15bde54 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -341,6 +341,7 @@ private fun death(provider: MatteryLanguageProvider) { death("otm_event_horizon", "%1\$s никогда не пересёк горизонт событий") death("otm_hawking_radiation", "%1\$s открыл излучение Хокинга") death("otm_emp", "Электроника %1\$s перегорела") + death("otm_cosmic_rays", "Электроника %1\$s была ошеломлена космическим излучением") death("otm_become_android.player", "%1\$s потерял свою человечность, когда %2\$s пытался образумить их") death("otm_become_humane.player", "%1\$s восстановил свою человечность, когда %2\$s пытался образумить их") diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 5915b8e75..748bb0dc1 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -201,6 +201,7 @@ public final class OverdriveThatMatters { if (AdAstraCompatKt.isAdAstraLoaded()) { EVENT_BUS.addListener(EventPriority.NORMAL, AdAstraCompatKt::onDamageEvent); + EVENT_BUS.addListener(EventPriority.NORMAL, AdAstraCompatKt::onMatteryTick); } } diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/compat/ad_astra/EntityTemperatureSystemMixin.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/compat/ad_astra/EntityTemperatureSystemMixin.java index a68cc5728..421069a9c 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/compat/ad_astra/EntityTemperatureSystemMixin.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/compat/ad_astra/EntityTemperatureSystemMixin.java @@ -1,8 +1,7 @@ package ru.dbotthepony.mc.otm.mixin.compat.ad_astra; -import earth.terrarium.ad_astra.common.data.Planet; -import earth.terrarium.ad_astra.common.data.PlanetData; import earth.terrarium.ad_astra.common.entity.system.EntityTemperatureSystem; +import earth.terrarium.ad_astra.common.util.ModUtils; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.LivingEntity; import org.spongepowered.asm.mixin.Mixin; @@ -21,7 +20,7 @@ public class EntityTemperatureSystemMixin { remap = false ) private static void temperatureTick(LivingEntity entity, ServerLevel level, CallbackInfo hook) { - if (ServerCompatConfig.AdAstra.INSTANCE.getWHATS_UP_WITH_TEMPERATURE() && !PlanetData.getPlanetFromLevel(level.dimension()).map(Planet::hasAtmosphere).orElse(true)) { + if (ServerCompatConfig.AdAstra.INSTANCE.getWHATS_UP_WITH_TEMPERATURE() && !ModUtils.planetHasAtmosphere(level)) { hook.cancel(); } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 0cfa76cc1..448ca8554 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -21,8 +21,10 @@ import net.minecraft.world.entity.player.Player import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ProjectileWeaponItem import net.minecraft.world.item.enchantment.EnchantmentHelper.hasVanishingCurse +import net.minecraft.world.level.Level import net.minecraft.world.phys.Vec3 import net.minecraftforge.common.ForgeHooks +import net.minecraftforge.common.MinecraftForge import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ICapabilityProvider import net.minecraftforge.common.util.INBTSerializable @@ -80,6 +82,32 @@ import kotlin.collections.HashMap @Suppress("unused") class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerializable { + /** + * This event is fired on main event bus before ticking logic takes place. + * + * Cancelling it is probably not a good idea, but you can do it anyway. + */ + data class PreTick(val capability: MatteryPlayerCapability) : Event() { + override fun isCancelable() = true + override fun hasResult() = false + override fun setResult(value: Result) {} + + val player get() = capability.ply + val level: Level get() = capability.ply.level + } + + /** + * This event is fired on main event bus after ticking logic took place. + */ + data class PostTick(val capability: MatteryPlayerCapability) : Event() { + override fun isCancelable() = false + override fun hasResult() = false + override fun setResult(value: Result) {} + + val player get() = capability.ply + val level: Level get() = capability.ply.level + } + private inner class PlayerMatteryContainer(size: Int) : MatteryContainer(size) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { super.setChanged(slot, new, old) @@ -777,6 +805,11 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial private fun tick() { if (!ply.isAlive) return + PreTick(this).also { + MinecraftForge.EVENT_BUS.post(it) + if (it.isCanceled) return + } + ticksIExist++ if (willBecomeAndroid) { @@ -930,6 +963,10 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } tickInventory() + + PostTick(this).also { + MinecraftForge.EVENT_BUS.post(it) + } } private val resolver = LazyOptional.of { this } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt index 61d89098b..c9f5af444 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt @@ -1,12 +1,18 @@ package ru.dbotthepony.mc.otm.compat.adastra import earth.terrarium.ad_astra.AdAstra +import earth.terrarium.ad_astra.common.data.PlanetData +import earth.terrarium.ad_astra.common.item.armor.SpaceSuit import earth.terrarium.ad_astra.common.registry.ModDamageSource +import earth.terrarium.ad_astra.common.util.ModUtils import net.minecraft.world.entity.player.Player import net.minecraftforge.event.entity.living.LivingHurtEvent import net.minecraftforge.fml.ModList +import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.config.ServerCompatConfig +import ru.dbotthepony.mc.otm.registry.MItems +import ru.dbotthepony.mc.otm.registry.MRegistry val isAdAstraLoaded by lazy { ModList.get().isLoaded(AdAstra.MOD_ID) @@ -26,3 +32,23 @@ fun onDamageEvent(event: LivingHurtEvent) { } } } + +fun onMatteryTick(event: MatteryPlayerCapability.PostTick) { + check(isAdAstraLoaded) { "Ad Astra is not loaded!" } + + if ( + ServerCompatConfig.AdAstra.ANDROID_COSMIC_RAYS && + !event.player.abilities.invulnerable && + event.capability.isAndroid && + !ModUtils.planetHasAtmosphere(event.level) + ) { + val rand = event.level.random + + val noSpacesuits = event.player.armorSlots.count { it.item !is SpaceSuit } + val yesTritanium = if (!ServerCompatConfig.AdAstra.TRITANIUM_ARMOR_PROTECTS_AGAINST_COSMIC_RAYS) 0.0 else event.player.armorSlots.count { it.item in MItems.TRITANIUM_ARMOR } * 0.5 + + if (rand.nextDouble() <= (noSpacesuits - yesTritanium) * ServerCompatConfig.AdAstra.ANDROID_COSMIC_RAYS_CHANCE) { + event.player.hurt(MRegistry.DAMAGE_COSMIC_RAYS, 1f) + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerCompatConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerCompatConfig.kt index 1b1150dc4..ab60743e0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerCompatConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerCompatConfig.kt @@ -15,6 +15,20 @@ object ServerCompatConfig : AbstractConfig("compat-server") { .comment("I attended physics classes in middle school, and this kills me.") .define("WHATS_UP_WITH_TEMPERATURE", true) + val ANDROID_COSMIC_RAYS: Boolean by builder + .comment("Androids without spacesuit will get damaged over time by cosmic radiation") + .comment("on planets without atmosphere.") + .define("ANDROID_COSMIC_RAYS", true) + + val ANDROID_COSMIC_RAYS_CHANCE: Double by builder + .comment("Chance in percent android will be damaged this tick per missing piece of spacesuit") + .comment("Max chance in tick of damage is this value multiplied by 4 (spacesuit is completely missing)") + .defineInRange("ANDROID_COSMIC_RAYS_CHANCE", 0.015, 0.0, 1.0) + + val TRITANIUM_ARMOR_PROTECTS_AGAINST_COSMIC_RAYS: Boolean by builder + .comment("Should androids get half protection from cosmic rays per piece of tritanium armor") + .define("TRITANIUM_ARMOR_PROTECTS_AGAINST_COSMIC_RAYS", true) + init { builder.pop() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/DamageSources.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/DamageSources.kt index 5d6580085..64b91e687 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/DamageSources.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/DamageSources.kt @@ -138,7 +138,7 @@ class ImmutableDamageSource(private val parent: DamageSource) : DamageSource(par } } -abstract class MatteryDamageSource(name: String, private val entity: Entity? = null, private val inflictor: ItemStack? = null) : DamageSource(name) { +abstract class MatteryDamageSource(name: String, private val entity: Entity? = null, val inflictor: ItemStack? = null) : DamageSource(name) { override fun getLocalizedDeathMessage(victim: LivingEntity): Component { val itemStack = inflictor ?: (entity as LivingEntity?)?.mainHandItem ?: ItemStack.EMPTY 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 82e118108..244a0a876 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -192,6 +192,10 @@ object MRegistry { const val DAMAGE_EVENT_HORIZON_ID = "otm_event_horizon" const val DAMAGE_HAWKING_RADIATION_ID = "otm_hawking_radiation" const val DAMAGE_EXOPACK_PROBE_ID = "otm_exopack_probe" + const val DAMAGE_EMP_NAME = "otm_emp" + const val DAMAGE_SHOCKWAVE_NAME = "otm_shockwave" + const val DAMAGE_PLASMA_NAME = "otm_plasma" + const val DAMAGE_COSMIC_RAYS_NAME = "otm_cosmic_rays" val DAMAGE_EXOPACK_PROBE = ImmutableDamageSource(DamageSource(DAMAGE_EXOPACK_PROBE_ID).bypassArmor().bypassMagic()) @@ -199,9 +203,8 @@ object MRegistry { val DAMAGE_BECOME_HUMANE = ImmutableDamageSource(DamageSource(DAMAGE_BECOME_HUMANE_ID).bypassArmor().bypassInvul().bypassMagic()) val DAMAGE_EVENT_HORIZON = ImmutableDamageSource(DamageSource(DAMAGE_EVENT_HORIZON_ID).bypassMagic().bypassArmor()) val DAMAGE_HAWKING_RADIATION = ImmutableDamageSource(DamageSource(DAMAGE_HAWKING_RADIATION_ID)) - const val DAMAGE_EMP_NAME = "otm_emp" - const val DAMAGE_SHOCKWAVE_NAME = "otm_shockwave" - const val DAMAGE_PLASMA_NAME = "otm_plasma" + val DAMAGE_COSMIC_RAYS = ImmutableDamageSource(DamageSource(DAMAGE_COSMIC_RAYS_NAME).bypassArmor().bypassMagic()) + val DAMAGE_EMP: DamageSource = ImmutableDamageSource(EMPDamageSource()) val TRITANIUM_STRIPED_BLOCK = StripedColoredDecorativeBlock(MNames.TRITANIUM_STRIPED_BLOCK, { colorA, _ -> From 0764f2bae69ad4ffafdeef0321c4d84744158b06 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 14 Mar 2023 17:37:36 +0700 Subject: [PATCH 0353/1199] Useless --- build.gradle.kts | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 00f759523..981c58c2d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -245,17 +245,7 @@ minecraft { val originalUsername = usernameStream.array.copyOfRange(0, usernameStream.length).toString(Charsets.UTF_8).trim() if (originalUsername.isNotEmpty()) { - var username = originalUsername - var speculatedUUID = UUID.nameUUIDFromBytes("OfflinePlayer:$username".toByteArray(Charsets.UTF_8)) - var counter = 1 - - while (speculatedUUID.hashCode() and 1 == 1) { - username = originalUsername + "_".repeat(counter) - speculatedUUID = UUID.nameUUIDFromBytes("OfflinePlayer:$username".toByteArray(Charsets.UTF_8)) - counter++ - } - - args("--username", username) + args("--username", originalUsername) } else { args("--username", "Dev_${System.getProperty("user.name")}") } From 9ed3a8788f117ac45d4ec850638714b0bf58de80 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 14 Mar 2023 18:39:01 +0700 Subject: [PATCH 0354/1199] ok --- build.gradle.kts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 981c58c2d..f4dbd601b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -198,9 +198,9 @@ dependencies { runtimeOnly(fg.deobf("curse.maven:configured-457570:${configured_id}")) compileOnly(fg.deobf("curse.maven:ad-astra-635042:${ad_astra_id}")) - // implementation(fg.deobf("curse.maven:resourceful-lib-570073:4378849")) - // implementation(fg.deobf("curse.maven:resourceful-config-714059:4394154")) - // implementation(fg.deobf("curse.maven:botarium-704113:4416456")) + compileOnly(fg.deobf("curse.maven:resourceful-lib-570073:4378849")) + compileOnly(fg.deobf("curse.maven:resourceful-config-714059:4394154")) + compileOnly(fg.deobf("curse.maven:botarium-704113:4416456")) // runtimeOnly(fg.deobf("curse.maven:worldedit-225608:${worldedit_fileid}")) // runtimeOnly(fg.deobf("at.ridgo8.moreoverlays:MoreOverlays-updated:${more_overlays_version}")) From 4e064c2ac5672d3bf406757fc8767b67e1411e18 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 14 Mar 2023 19:16:11 +0700 Subject: [PATCH 0355/1199] :pray: thanks ad astra --- .../ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt index c9f5af444..214e15b9d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.compat.adastra import earth.terrarium.ad_astra.AdAstra +import earth.terrarium.ad_astra.common.data.Planet import earth.terrarium.ad_astra.common.data.PlanetData import earth.terrarium.ad_astra.common.item.armor.SpaceSuit import earth.terrarium.ad_astra.common.registry.ModDamageSource @@ -40,7 +41,7 @@ fun onMatteryTick(event: MatteryPlayerCapability.PostTick) { ServerCompatConfig.AdAstra.ANDROID_COSMIC_RAYS && !event.player.abilities.invulnerable && event.capability.isAndroid && - !ModUtils.planetHasAtmosphere(event.level) + !PlanetData.getPlanetFromLevel(event.level.dimension()).map(Planet::hasAtmosphere).orElse(true) ) { val rand = event.level.random From d65717e21312ef714b0c376da696f2f4ae22b811 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Tue, 14 Mar 2023 18:32:54 +0600 Subject: [PATCH 0356/1199] Pillar textures --- .../block/decorative/tritanium_pillar.png | Bin 0 -> 183 bytes .../block/decorative/tritanium_pillar_black.png | Bin 0 -> 398 bytes .../block/decorative/tritanium_pillar_blue.png | Bin 0 -> 398 bytes .../block/decorative/tritanium_pillar_brown.png | Bin 0 -> 398 bytes .../block/decorative/tritanium_pillar_cyan.png | Bin 0 -> 398 bytes .../block/decorative/tritanium_pillar_gray.png | Bin 0 -> 398 bytes .../block/decorative/tritanium_pillar_green.png | Bin 0 -> 398 bytes .../decorative/tritanium_pillar_light_blue.png | Bin 0 -> 398 bytes .../decorative/tritanium_pillar_light_gray.png | Bin 0 -> 398 bytes .../block/decorative/tritanium_pillar_lime.png | Bin 0 -> 398 bytes .../block/decorative/tritanium_pillar_magenta.png | Bin 0 -> 398 bytes .../block/decorative/tritanium_pillar_orange.png | Bin 0 -> 398 bytes .../block/decorative/tritanium_pillar_pink.png | Bin 0 -> 398 bytes .../block/decorative/tritanium_pillar_purple.png | Bin 0 -> 398 bytes .../block/decorative/tritanium_pillar_red.png | Bin 0 -> 398 bytes .../block/decorative/tritanium_pillar_white.png | Bin 0 -> 183 bytes .../block/decorative/tritanium_pillar_yellow.png | Bin 0 -> 398 bytes 17 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_black.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_blue.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_brown.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_cyan.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_gray.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_green.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_light_blue.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_light_gray.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_lime.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_magenta.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_orange.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_pink.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_purple.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_red.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_white.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_yellow.png diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar.png new file mode 100644 index 0000000000000000000000000000000000000000..69a92c2ef04e35cdfc785ca6c47d25bc877a2e5e GIT binary patch literal 183 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFOp<2WqP%s9!&$SjP_n5UAf83^QX7I;J!GcfS&2Vq7F)?gK&AbW|YuPgg=WJeKTx}BiEBhjN@7W>RdP`(kYX@0Ff!IPFxE9R2{AOZGBUC< zG1fLPure^nY46{Tq9HdwB{QuOQ-i4mM8oCsAf83^QX7I;J!GcfS&2Vq7F)?gK&AbW|YuPgg=WJeKTx}BiEBhjN@7W>RdP`(kYX@0Ff!IPFxE9R2{AOZGBUC< zG1fLPure^nY46{Tq9HdwB{QuOQ-i4mM8oCst>DI1URmGfpxxG7Dof=IQC38Mw6Ig;SD&(-vu^ zEr)eox5o-Fv{4$x#AE;fm#5JNMC9x#cD!C{XNHG{07#Zst80#9EgcurH85vob z7;76CSQ!}PwD)gE(U6;;l9^VCsln6&qTzCRaz0Rl2Hb{{%-q!ClEmBsG(E;9Rt6>z VJ;yh7ssr^fc)I$ztaD0e0ssa0X%zqf literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_cyan.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_cyan.png new file mode 100644 index 0000000000000000000000000000000000000000..f13cea8800f5c11c1101b0bec3d17e195d478bf2 GIT binary patch literal 398 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPF+{}*4Wt_+l7O!9VjVd>Af83^QX7I;J!GcfS&2Vq7F)?gK&AbW|YuPgg=WJeKTx}BiEBhjN@7W>RdP`(kYX@0Ff!IPFxE9R2{AOZGBUC< zG1fLPure^nY46{Tq9HdwB{QuOQ-i4mM8oCst>DI1URmGfpxxG7Dof=IQC38Mw6Ig;SD&(-vu^ zEr)eox5o-Fv{4$x#AE;fm#5JNMC9x#cD!C{XNHG{07#Zst80#9EgcurH85vob z7;76CSQ!}PwD)gE(U6;;l9^VCsln6&qTzCRaz0Rl2Hb{{%-q!ClEmBsG(E;9Rt6>z VJ;yh7ssr^fc)I$ztaD0e0sygXXv_cr literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_green.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_green.png new file mode 100644 index 0000000000000000000000000000000000000000..dbd621860a8650c42b56d88162e41e2dcd21d328 GIT binary patch literal 398 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPF zc!~f2|C=4zwgD)`nB?v5!qT5{GZ4t(EbxddW?Op<2WqP%s9!&$SjP_n5U|?j@XKT_f1q~N64!{5l*E!$tK_0oAjM#0U}UUoV61Cs5@Kj*Wn^S! zVytaoU}a#C)84-wMMG|WN@iLmrUp|Bh=$AM$@xGH8gLs*GILXlOA>Pn(DWFaSQ(f= V^c>&RsSeb`;OXk;vd$@?2>|LIY32X` literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_light_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_light_blue.png new file mode 100644 index 0000000000000000000000000000000000000000..d8b91422414fdb07a0e769a2e2aa4c02919dd204 GIT binary patch literal 398 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPF)^mS!_&dkTH z#BwI#;Xs0gb))pCT2&rG>*dp&5V};Iu_r zY0F_<*X^+a3@w7f3%^X}@&{^HEpd$~Nl7e8wMs5Z1yT$~21drZ2FALECLxA~Rz^lv zCdS$Z237_JIqm)1Q8eV{r(~v8Vrnq8fM~c}o}3TVpaHj`Br`X)xFj*R08NjviIsr~ VM9=X}o$5e644$rjF6*2UngAuKYtaAz literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_light_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_light_gray.png new file mode 100644 index 0000000000000000000000000000000000000000..df09284293c349d535bf0f4d1b701ce082a5eec9 GIT binary patch literal 398 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFt>DI1URmGfpxxG7Dof=IQC38Mw6Ig;SD&(-vu^ zEr)eox5o-Fv{4$x#AE;fm#5JNMC9x#cD!C{XNHG{07#Zst80#9EgcurH85vob z7;76CSQ!}PwD)gE(U6;;l9^VCsln6&qTzCRaz0Rl2Hb{{%-q!ClEmBsG(E;9Rt6>z VJ;yh7ssr^fc)I$ztaD0e0ssl|YrFse literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_lime.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_lime.png new file mode 100644 index 0000000000000000000000000000000000000000..62e14afdaedec4478a98efcc0281a894a5797d59 GIT binary patch literal 398 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFOp<2WqP%s9!&$SjP_n5U|?j@XKT_f1q~N64!{5l*E!$tK_0oAjM#0U}UUoV61Cs5@Kj*Wn^S! zVytaoU}a#C)84-wMMG|WN@iLmrUp|Bh=$AM$@xGH8gLs*GILXlOA>Pn(DWFaSQ(f= V^c>&RsSeb`;OXk;vd$@?2>{B|X}bUb literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_magenta.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_magenta.png new file mode 100644 index 0000000000000000000000000000000000000000..cc61e32d3c21d7f886d135e3f9eb8072412155be GIT binary patch literal 398 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPF!%p?)M=G1 zHlO+b|9|0+dgVYV#w2fd7nc5vn}I+MXMsm#F#`kNeh_A~U=3CQ3bL1Y`ns||XXfKp zVmXuWa3N60*we)^gyVX0LWl_)6SE^*8pmOQX2wZIMrL7b#ymZ}GXs|vyl_e~aM~iR zwB@j_>-Jayh898LgnC}Q!>*kF*TT4Kr~z~PtFHw(16=el9`)YT#}eufTqXT#LB<~ VqUZRgPIaIj22WQ%mvv4FO#mzLYuW$+ literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_orange.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_orange.png new file mode 100644 index 0000000000000000000000000000000000000000..f7c76547a3e2763c9f2f2db159ac2a609b4eda51 GIT binary patch literal 398 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPF)^mS!_&dkTH z#BwI#;Xs0gb))pCT2&rG>*dp&5V};Iu_r zY0F_<*X^+a3@w7f3%^X}@&{^HEpd$~Nl7e8wMs5Z1yT$~21drZ2FALECLxA~Rz^lv zCdS$Z237_JIqm)1Q8eV{r(~v8Vrnq8fM~c}o}3TVpaHj`Br`X)xFj*R08NjviIsr~ VM9=X}o$5e644$rjF6*2UngA_SY{&or literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_pink.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_pink.png new file mode 100644 index 0000000000000000000000000000000000000000..6154567687ae08a2eda77c5a32f4ce31165ae6a2 GIT binary patch literal 398 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPF)^mS!_&dkTH z#BwI#;Xs0gb))pCT2&rG>*dp&5V};Iu_r zY0F_<*X^+a3@w7f3%^X}@&{^HEpd$~Nl7e8wMs5Z1yT$~21drZ2FALECLxA~Rz^lv zCdS$Z237_JIqm)1Q8eV{r(~v8Vrnq8fM~c}o}3TVpaHj`Br`X)xFj*R08NjviIsr~ VM9=X}o$5e644$rjF6*2UngGrBZAJh9 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_purple.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_purple.png new file mode 100644 index 0000000000000000000000000000000000000000..00606ba4e41c07f291158cf4069ece3957afe85f GIT binary patch literal 398 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFJO!9VjVd>Af83^QX7I;J!GcfS&2Vq7F)?gK&AbW|YuPgg=WJeKTx}BiEBhjN@7W>RdP`(kYX@0Ff!IPFxE9R2{AOZGBUC< zG1fLPure^nY46{Tq9HdwB{QuOQ-i4mM8oCs literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_red.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_red.png new file mode 100644 index 0000000000000000000000000000000000000000..3d60fa894d8dc753a82792e401012bcc6424ecaa GIT binary patch literal 398 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFAf83^QX7I;J!GcfS&2Vq7F)?gK&AbW|YuPgg=WJeKTx}BiEBhjN@7W>RdP`(kYX@0Ff!IPFxE9R2{AOZGBUC< zG1fLPure^nY46{Tq9HdwB{QuOQ-i4mM8oCsDK%md0^dpqX)!k&#&#n=wyM@65oZ1uvYE44k$|D{VQf>$>@_g8)N| WpzuPGn!b}j{S2P2elF{r5}E+58Z}}7 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_yellow.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_pillar_yellow.png new file mode 100644 index 0000000000000000000000000000000000000000..a99585040247447cdcd97404c2369d2efc490f54 GIT binary patch literal 398 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFFdh=oSBbX ziRDbf!-YU0V^0^y5RU7~2_YtIOw5jKX&i?Ini(e<8JUH#8T0h?&J0{y@WLs{z-f!L z(w4)zuG?b;7+M5{7k-({NoH Date: Tue, 14 Mar 2023 20:56:46 +0700 Subject: [PATCH 0357/1199] HOLY SHIT --- .../mc/otm/block/entity/tech/BatteryBankBlockEntity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index 2c5d49e64..5d64f1744 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -102,7 +102,7 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte var summ2 = Decimal.ZERO for ((i, energy) in energies.withIndex()) { - val diff = energy.transcieveEnergy(howMuch, isReceiving, simulate) + val diff = energy.transcieveEnergy(howMuch, isReceiving, true) distribution[i] = diff summ2 += distribution[i] } From 9b270b6891ec152ceefa1c99a054aaeb5015959b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 14 Mar 2023 21:38:05 +0700 Subject: [PATCH 0358/1199] Division free energy distribution in battery bank --- .../entity/tech/BatteryBankBlockEntity.kt | 111 ++++++------------ 1 file changed, 38 insertions(+), 73 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index 5d64f1744..21a3300ec 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -7,16 +7,13 @@ import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.capabilities.ForgeCapabilities -import net.minecraftforge.energy.IEnergyStorage import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.energy import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.energyStoredMattery -import ru.dbotthepony.mc.otm.capability.extractEnergy import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.capability.maxEnergyStoredMattery -import ru.dbotthepony.mc.otm.capability.receiveEnergy import ru.dbotthepony.mc.otm.capability.transcieveEnergy import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer @@ -53,94 +50,56 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte bottomDefault = ItemHandlerMode.INPUT_OUTPUT, ) + private var currentChangeSlot = 0 + private var currentDischangeSlot = 0 + init { savetable(::container, INVENTORY_KEY) + savetables.int(::currentChangeSlot) + savetables.int(::currentDischangeSlot) } private fun distributeEnergy(isReceiving: Boolean, howMuch: Decimal, simulate: Boolean): Decimal { if (!howMuch.isPositive) return Decimal.ZERO - val energies = ArrayList() + var summ = Decimal.ZERO + var remaining = howMuch + var currentSlot = if (isReceiving) currentChangeSlot else currentDischangeSlot + + for (i in 0 until container.containerSize - 1) { + val item = container[currentSlot] - for (item in container) { if (!item.isEmpty) { val energy = item.matteryEnergy ?: item.energy if (energy != null) { - energies.add(energy) + val diff = energy.transcieveEnergy(remaining, isReceiving, simulate) + summ += diff + remaining -= diff + + if (!remaining.isPositive) { + break + } } } + + currentSlot = (currentSlot + 1) % container.containerSize } - if (energies.isEmpty()) - return Decimal.ZERO - - if (howMuch.toInt() < energies.size || !energies.any { it is IMatteryEnergyStorage && it.transcieveEnergy(Decimal.ONE, isReceiving, true) == Decimal.ONE }) { - // sequential - var summ = Decimal.ZERO - var remaining = howMuch - - for (energy in energies) { - val diff = energy.transcieveEnergy(remaining, isReceiving, simulate) - summ += diff - remaining -= diff - - if (!remaining.isPositive) { - break - } - } - - if (!simulate && !summ.isZero) { - setChangedLight() - gaugeLevel = (batteryLevel / maxBatteryLevel).toFloat() - } - - return summ - } else { - val distribution = Array(energies.size) { Decimal.ZERO } - var summ2 = Decimal.ZERO - - for ((i, energy) in energies.withIndex()) { - val diff = energy.transcieveEnergy(howMuch, isReceiving, true) - distribution[i] = diff - summ2 += distribution[i] - } - - if (summ2.isPositive) { - for (i in distribution.indices) { - distribution[i] = distribution[i] / summ2 - } - } else { - return Decimal.ZERO - } - - var summ = Decimal.ZERO - var remaining = howMuch - - for ((i, energy) in energies.withIndex()) { - val diff = energy.transcieveEnergy((howMuch * distribution[i]).coerceAtMost(remaining), isReceiving, simulate) - summ += diff - remaining -= diff - - if (!remaining.isPositive) { - break - } - } - - if (remaining.isPositive) { - val diff = energies.first { it is IMatteryEnergyStorage }.transcieveEnergy(remaining, isReceiving, simulate) - summ += diff - remaining -= diff - } - - if (!simulate && !summ.isZero) { - setChangedLight() - gaugeLevel = (batteryLevel / maxBatteryLevel).toFloat() - } - - return summ + if (!simulate && !summ.isZero) { + setChangedLight() + gaugeLevel = (batteryLevel / maxBatteryLevel).toFloat() } + + if (!simulate) { + if (isReceiving) + this.currentChangeSlot = currentSlot + else + this.currentDischangeSlot = currentSlot + } + + return summ } override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { @@ -151,6 +110,12 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte return distributeEnergy(isReceiving = true, howMuch, simulate) } + override fun tick() { + super.tick() + currentChangeSlot = (currentChangeSlot + 1) % container.containerSize + currentDischangeSlot = (currentDischangeSlot + 1) % container.containerSize + } + override val canSetBatteryLevel: Boolean get() = false From 5ecfc99533eadef673455c78a75970b2a734b5ef Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Tue, 14 Mar 2023 18:09:46 +0300 Subject: [PATCH 0359/1199] =?UTF-8?q?DBotThePony=20=E2=80=94=20=D0=A1?= =?UTF-8?q?=D0=B5=D0=B3=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=2017:11=20=D0=B0?= =?UTF-8?q?=D1=85=20=D0=B4=D0=B0=20=D1=82=D1=8B=20=D0=BF=D1=80=D0=BE=D1=81?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=B2=D0=B8=D0=B7=D1=83=D0=B0=D0=BB=D0=BA=D1=83?= =?UTF-8?q?=20=D0=B1=D1=80=D0=BE=D0=BD=D0=B8=20=D0=BD=D0=B0=D0=BD=D0=BE?= =?UTF-8?q?=D0=B1=D0=BE=D1=82=D0=BE=D0=B2=20=D1=82=D0=B0=D0=BA=20=D1=82?= =?UTF-8?q?=D1=8B=D0=B6=20=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D0=BE=D1=81=D0=BA=D1=83=20=D1=85=D0=BF,=20=D0=BC?= =?UTF-8?q?=D0=BE=D0=B6=D0=BD=D0=BE=20=D1=82=D1=83=D0=B4=D0=B0=20=D0=B8=20?= =?UTF-8?q?=D0=BD=D0=B0=D0=BD=D0=BE=D0=B1=D0=BE=D1=82=D0=BE=D0=B2=20=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BF=D0=B8=D1=82=D1=8C=20:Pogomega:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../android/feature/NanobotsArmorFeature.kt | 9 ++++--- .../dbotthepony/mc/otm/client/MatteryGUI.kt | 25 +++++++++++++----- .../textures/gui/player_bars_health.png | Bin 292 -> 325 bytes 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt index 4ecedb8c3..168b402a8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt @@ -18,14 +18,17 @@ import ru.dbotthepony.mc.otm.triggers.NanobotsArmorTrigger import kotlin.math.roundToInt class NanobotsArmorFeature(android: MatteryPlayerCapability) : AndroidFeature(AndroidFeatures.NANOBOTS_ARMOR, android) { - var strength: Int = 0 - set(value) { field = value.coerceIn(0 .. 3) } + var strength by synchronizer.int( + setter = setter@{ + value, access, _ -> access.write(value.coerceIn(0 .. 3)) + } + ) var speed: Int = 0 set(value) { field = value.coerceIn(0 .. 3) } private var ticksPassed = 0 - private var layers = 0 + var layers by synchronizer.int() override fun tickServer() { if (layers < strength + 1 && android.androidEnergy.extractEnergyExact(ENERGY_PER_LAYER, true)) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index 73e5a3a36..0d7607c15 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -16,6 +16,7 @@ import net.minecraftforge.client.event.ScreenEvent import net.minecraftforge.client.gui.overlay.ForgeGui import net.minecraftforge.client.gui.overlay.GuiOverlayManager import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.android.feature.NanobotsArmorFeature import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability @@ -25,6 +26,7 @@ import ru.dbotthepony.mc.otm.config.ClientConfig import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.core.ifPresentK +import ru.dbotthepony.mc.otm.registry.AndroidFeatures import java.util.* import kotlin.math.ceil @@ -36,15 +38,16 @@ object MatteryGUI { val CHARGE_HUNGER = BARS.sprite(y = 18f, height = 9f) val CHARGE_HUNGER_BG = BARS.sprite(y = 27f, height = 9f) - private val BARS_HP = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/player_bars_health.png"), 81f, 54f) + private val BARS_HP = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/player_bars_health.png"), 81f, 63f) val HEALTH = BARS_HP.sprite(height = 9f) val HEALTH_BG = BARS_HP.sprite(y = 9f, height = 9f) + val HEALTH_BG_NANOBOTS = BARS_HP.sprite(y = 18f, height = 9f) - val HEALTH_POISON = BARS_HP.sprite(y = 18f, height = 9f) - val HEALTH_WITHER = BARS_HP.sprite(y = 27f, height = 9f) - val HEALTH_ABSORB = BARS_HP.sprite(y = 36f, height = 9f) - val HEALTH_FROZEN = BARS_HP.sprite(y = 45f, height = 9f) + val HEALTH_POISON = BARS_HP.sprite(y = 27f, height = 9f) + val HEALTH_WITHER = BARS_HP.sprite(y = 36f, height = 9f) + val HEALTH_ABSORB = BARS_HP.sprite(y = 45f, height = 9f) + val HEALTH_FROZEN = BARS_HP.sprite(y = 54f, height = 9f) private var originalBedButtonX = -1 private var originalBedButtonY = -1 @@ -308,8 +311,8 @@ object MatteryGUI { if (!gui.shouldDrawSurvivalElements()) return - val level: Float = (ply.health / ply.maxHealth).coerceIn(0.0f, 1.0f) - val levelAbsorb: Float = (ply.absorptionAmount / ply.maxHealth).coerceIn(0.0f, 1.0f) + val level: Float = (ply.health / ply.maxHealth).coerceIn(0.0f .. 1.0f) + val levelAbsorb: Float = (ply.absorptionAmount / ply.maxHealth).coerceIn(0.0f .. 1.0f) gui.setupOverlayRenderState(true, false) RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f) @@ -321,6 +324,14 @@ object MatteryGUI { gui.leftHeight += 10 HEALTH_BG.render(event.poseStack, left.toFloat(), top.toFloat()) + + if (mattery.hasFeature(AndroidFeatures.NANOBOTS_ARMOR)) { + val featArmor = mattery.getFeature(AndroidFeatures.NANOBOTS_ARMOR) as NanobotsArmorFeature + val levelArmor: Float = (featArmor.layers.toFloat() / (featArmor.strength + 1).toFloat()).coerceIn(0.0f .. 1.0f) + + HEALTH_BG_NANOBOTS.renderPartial(event.poseStack, left.toFloat(), top.toFloat(), width = ceil(levelArmor * 81f)) + } + getSpriteForPlayer(ply).renderPartial(event.poseStack, left.toFloat(), top.toFloat(), width = ceil(level * 80f - 0.5f)) if (levelAbsorb > 0) { HEALTH_ABSORB.renderPartial(event.poseStack, left.toFloat(), top.toFloat(), width = ceil(levelAbsorb * 80f - 0.5f)) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/player_bars_health.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/player_bars_health.png index abf4b1d3a4372b2fe23b8ae3a5aa23d84defd11e..91269787329a435ef2bde45c6ec3bac8b43d86a4 100644 GIT binary patch delta 283 zcmZ3&bd+g=IF~&KGXn#|`t?`zCMqh_TL$=qxc(Ow-YqN)6xGnsVEF%^VgG&xeSHQ8 zhba{j8NnP^u3Wi)|Gt8Pg0{BymG$OV7BMtDeb2b>6Hq-9@16rdO1LD*FZe$OVAxc9 zhXW|hS>O>_%)r36AA}h#Sc6r7f@PjAjv*2C?r*PY3LP-uVL90Q_|EqK|8K~guu)#1 z_4b3B(FQJCQPT`XBTK=Tniqq!ZnmB{)9K;AvpM)3`xb$jb2`38D{cC*v`09q!^h91 zO6<{|1$!UuYHU66rSt33f8RU4=p6a$z&-I~r^k6G8-1{jH(om#H)|ZbTG!e&59kC2 NPggcSmvv4FO#tOqd}{yz delta 220 zcmX@gw1jDbIF}g*GXn!d$AZ>p6BQK%bpw1tT>lFT?-mvYifU+ROpH^km#-As2juaW z1o;L3M*$31?#x&Sl;SM#h%9Dc;5z`qj9J$@Ie~(yo-U3d5$QNp*GOE{F%lJgnc8u==Uc~V zt~8^GFGcrH|8-yY(rJP1vS1ByZ54Ae#AbGNyiwBAIMbS^@iwIgXd{ECtDnm{r-UW| D!TMOH From 934366000b38665c9b3aac2fdb37dd500dbd1e73 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 14 Mar 2023 22:33:07 +0700 Subject: [PATCH 0360/1199] =?UTF-8?q?[CHAT]=20=20=D0=B4=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D1=8C=20=D0=B2=D0=BE?= =?UTF-8?q?=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE=D1=81=D1=82=D1=8C=20=D0=BA?= =?UTF-8?q?=D1=80=D0=B0=D1=81=D0=B8=D1=82=D1=8C=20Floor=20Tile=20=D0=BF?= =?UTF-8?q?=D0=BE=D1=81=D0=BB=D0=B5=20=D0=BA=D1=80=D0=B0=D1=84=D1=82=D0=B0?= =?UTF-8?q?=20[CHAT]=20=20=D0=B1=D0=B5=D0=BB=D1=8B=D0=B2=D0=B9=20[CH?= =?UTF-8?q?AT]=20=20=D0=B1=D0=B5=D0=BB=D1=8B=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/datagen/recipes/DecorativesRecipes.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt index 480392dd9..510397b8e 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt @@ -12,6 +12,7 @@ import net.minecraftforge.common.Tags import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.datagen.DataGen +import ru.dbotthepony.mc.otm.datagen.modLocation import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MItemTags import ru.dbotthepony.mc.otm.registry.MItems @@ -73,6 +74,13 @@ fun addDecorativesRecipes(provider: MatteryRecipeProvider, consumer: Consumer Date: Wed, 15 Mar 2023 07:19:11 +0700 Subject: [PATCH 0361/1199] why did i do this --- .../mc/otm/mixin/compat/ad_astra/EntityOxygenSystemMixin.java | 2 +- .../mc/otm/mixin/compat/ad_astra/OxygenUtilsMixin.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/compat/ad_astra/EntityOxygenSystemMixin.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/compat/ad_astra/EntityOxygenSystemMixin.java index 846e5b221..6201620d0 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/compat/ad_astra/EntityOxygenSystemMixin.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/compat/ad_astra/EntityOxygenSystemMixin.java @@ -14,7 +14,7 @@ import ru.dbotthepony.mc.otm.config.ServerCompatConfig; @Mixin(EntityOxygenSystem.class) public class EntityOxygenSystemMixin { @Inject( - method = "oxygenTick()V", + method = "oxygenTick(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/server/level/ServerLevel;)V", at = @At("HEAD"), cancellable = true, remap = false diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/compat/ad_astra/OxygenUtilsMixin.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/compat/ad_astra/OxygenUtilsMixin.java index 30f8e465d..e8a1a7d57 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/compat/ad_astra/OxygenUtilsMixin.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/compat/ad_astra/OxygenUtilsMixin.java @@ -14,7 +14,7 @@ import ru.dbotthepony.mc.otm.config.ServerCompatConfig; @Mixin(OxygenUtils.class) public class OxygenUtilsMixin { @Inject( - method = "entityHasOxygen()Z", + method = "entityHasOxygen(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/LivingEntity;)Z", at = @At("HEAD"), cancellable = true, remap = false From 3354c698c481905c39a85a3a3182f37037942023 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 15 Mar 2023 07:52:37 +0700 Subject: [PATCH 0362/1199] Check if we gonna automate anything before checking neighbour slot count --- .../dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index 7c6e8bb9c..878120d13 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -358,7 +358,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo private var outerSlotPush = 0 override fun tick() { - if (mode == ItemHandlerMode.DISABLED || currentHandler.slots == 0 || redstoneControl.isBlockedByRedstone) + if (mode == ItemHandlerMode.DISABLED || !automatePull && !automatePush || redstoneControl.isBlockedByRedstone || currentHandler.slots == 0) return neighbour.ifPresentK { From 30f07e2fedfaf168e73e5354c690dd83a717a87a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 16 Mar 2023 07:56:48 +0700 Subject: [PATCH 0363/1199] Inventory filters preview --- .../mc/otm/mixin/MixinInventory.java | 49 +++ .../otm/capability/MatteryPlayerCapability.kt | 282 +++++++++++++++--- .../capability/energy/AndroidPowerSource.kt | 5 +- .../client/screen/ExoPackInventoryScreen.kt | 15 +- .../mc/otm/client/screen/MatteryScreen.kt | 26 +- .../screen/panels/slot/AbstractSlotPanel.kt | 3 +- .../screen/panels/slot/FilteredSlotPanel.kt | 113 +++++++ .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 18 +- .../mc/otm/core/util/DataStreams.kt | 29 +- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 117 ++++++-- .../network/MatteryPlayerNetworkChannel.kt | 56 +++- .../resources/META-INF/accesstransformer.cfg | 2 + src/main/resources/coremods/code_injector.js | 162 ---------- .../overdrive_that_matters.mixins.json | 1 + 14 files changed, 615 insertions(+), 263 deletions(-) create mode 100644 src/main/java/ru/dbotthepony/mc/otm/mixin/MixinInventory.java create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/FilteredSlotPanel.kt diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinInventory.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinInventory.java new file mode 100644 index 000000000..a8f494406 --- /dev/null +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinInventory.java @@ -0,0 +1,49 @@ +package ru.dbotthepony.mc.otm.mixin; + +import net.minecraft.CrashReport; +import net.minecraft.CrashReportCategory; +import net.minecraft.ReportedException; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.registries.ForgeRegistries; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import ru.dbotthepony.mc.otm.capability.MatteryCapability; + +@Mixin(Inventory.class) +public class MixinInventory { + @Shadow Player player; + + @Inject( + method = "add(ILnet/minecraft/world/item/ItemStack;)Z", + at = @At("HEAD"), + cancellable = true + ) + private void add(int pSlot, ItemStack pStack, CallbackInfoReturnable hook) { + if (pStack.isEmpty()) { + return; + } + + if (pSlot == -1) { + this.player.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresent(it -> { + try { + hook.setReturnValue(it.inventoryAddImpl(pStack)); + } catch (Throwable throwable) { + CrashReport crashreport = CrashReport.forThrowable(throwable, "Adding item to inventory (Overdrive That Matters detour)"); + CrashReportCategory crashreportcategory = crashreport.addCategory("Item being added"); + crashreportcategory.setDetail("Registry Name", () -> String.valueOf(ForgeRegistries.ITEMS.getKey(pStack.getItem()))); + crashreportcategory.setDetail("Item Class", () -> pStack.getItem().getClass().getName()); + crashreportcategory.setDetail("Item ID", Item.getId(pStack.getItem())); + crashreportcategory.setDetail("Item data", pStack.getDamageValue()); + crashreportcategory.setDetail("Item name", () -> pStack.getHoverName().getString()); + throw new ReportedException(crashreport); + } + }); + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 448ca8554..27895053c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -1,10 +1,12 @@ package ru.dbotthepony.mc.otm.capability +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import net.minecraft.ChatFormatting import net.minecraft.core.Direction import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.ListTag +import net.minecraft.nbt.NumericTag import net.minecraft.nbt.StringTag import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation @@ -18,7 +20,9 @@ import net.minecraft.world.entity.boss.wither.WitherBoss import net.minecraft.world.entity.monster.Phantom import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player +import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.Items import net.minecraft.world.item.ProjectileWeaponItem import net.minecraft.world.item.enchantment.EnchantmentHelper.hasVanishingCurse import net.minecraft.world.level.Level @@ -58,11 +62,15 @@ import ru.dbotthepony.mc.otm.core.collect.nonEmpty import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.minus import ru.dbotthepony.mc.otm.core.nbt.getCompoundList +import ru.dbotthepony.mc.otm.core.nbt.getStringList import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.IntValueCodec +import ru.dbotthepony.mc.otm.core.util.ItemStackValueCodec +import ru.dbotthepony.mc.otm.core.util.ItemValueCodec import ru.dbotthepony.mc.otm.core.util.Savetables import ru.dbotthepony.mc.otm.core.util.UUIDValueCodec +import ru.dbotthepony.mc.otm.core.util.VarIntValueCodec import ru.dbotthepony.mc.otm.menu.ExoPackInventoryMenu import ru.dbotthepony.mc.otm.network.* import ru.dbotthepony.mc.otm.registry.AndroidFeatures @@ -108,6 +116,19 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial val level: Level get() = capability.ply.level } + /** + * This event is fired on main event bus when [Inventory.add] was called and entire [ItemStack] can not be stored + * (both in [Inventory] and [MatteryPlayerCapability] exopack due to inventory filters or no free space). + */ + data class ItemStackLeftoverEvent(val stack: ItemStack, val capability: MatteryPlayerCapability) : Event() { + override fun isCancelable() = false + override fun hasResult() = false + override fun setResult(value: Result) {} + + val player get() = capability.ply + val level: Level get() = capability.ply.level + } + private inner class PlayerMatteryContainer(size: Int) : MatteryContainer(size) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { super.setChanged(slot, new, old) @@ -181,6 +202,16 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } }, backingMap = this.exoPackSlotModifierMap) + val regularSlotFilters = immutableList(Inventory.INVENTORY_SIZE) { + synchronizer.Field(null, ItemValueCodec.nullable) + } + + val exoPackSlotFilters by synchronizer.Map( + keyCodec = VarIntValueCodec, + valueCodec = ItemValueCodec, + backingMap = Int2ObjectOpenHashMap() + ) + /** * Current slot count of Exopack * @@ -291,15 +322,6 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial private var wasInLiquid = false private var lastDimension = ResourceLocation("overworld") - init { - savetables.int(::ticksIExist) - savetables.int(::iteration) - savetables.bool(::shouldSendIteration) - savetables.bool(::wasInLiquid) - savetables.vector(::lastOutsideLiquid) - savetables.location(::lastDimension) - } - /** * Whenever player should become an Android once transformation conditions are met (e.g. player dies or sleeps in bed) */ @@ -324,6 +346,26 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial */ val androidEnergy = AndroidPowerSource(ply, synchronizer, AndroidConfig.ANDROID_MAX_ENERGY, AndroidConfig.ANDROID_MAX_ENERGY) + init { + savetables.int(::ticksIExist) + savetables.int(::iteration) + + savetables.bool(::shouldSendIteration) + savetables.bool(::wasInLiquid) + savetables.bool(::isAndroid) + savetables.bool(::willBecomeAndroid) + savetables.bool(::hasExoPack, "hasExoSuit") + savetables.bool(::displayExoPack, "displayExoSuit") + savetables.bool(::isExoPackCraftingUpgraded, "isExoSuitCraftingUpgraded") + + savetables.vector(::lastOutsideLiquid) + savetables.location(::lastDimension) + + savetables.stateful(::exoPackSlotModifier, "exoSuitSlotCountModifiers") + savetables.stateful(::exoPackContainer, "exoSuitContainer") + savetables.stateful(::androidEnergy) + } + fun invalidateNetworkState() { synchronizer.invalidate() publicSynchronizer.invalidate() @@ -641,36 +683,36 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } } - // exosuit - tag["hasExoSuit"] = hasExoPack - tag["displayExoSuit"] = displayExoPack - tag["exoSuitContainer"] = exoPackContainer.serializeNBT() - tag["isExoSuitCraftingUpgraded"] = isExoPackCraftingUpgraded - tag["exoSuitSlotCountModifiers"] = exoPackSlotModifier.serializeNBT() - - // android - tag["androidEnergy"] = androidEnergy.serializeNBT() - - tag["isAndroid"] = isAndroid - tag["willBecomeAndroid"] = willBecomeAndroid - - val featureList = ListTag() - val researchList = ListTag() - - for (feature in featureMap.values) { - featureList.add(feature.serializeNBT().also { - it["id"] = feature.type.registryName!!.toString() - }) + tag["features"] = ListTag().also { + for (feature in featureMap.values) { + it.add(feature.serializeNBT().also { + it["id"] = feature.type.registryName!!.toString() + }) + } } - for ((type, instance) in research) { - researchList.add(instance.serializeNBT().also { - it["id"] = type.id.toString() - }) + tag["research"] = ListTag().also { + for ((type, instance) in research) { + it.add(instance.serializeNBT().also { + it["id"] = type.id.toString() + }) + } } - tag["features"] = featureList - tag["research"] = researchList + tag["exoPackSlotFilters"] = ListTag().also { + for ((slot, filter) in exoPackSlotFilters) { + it.add(CompoundTag().also { + it["slot"] = slot + it["filter"] = filter.registryName!!.toString() + }) + } + } + + tag["regularSlotFilters"] = ListTag().also { + for (filter in regularSlotFilters) { + it.add(StringTag.valueOf(filter.value?.registryName?.toString() ?: "")) + } + } return tag } @@ -678,6 +720,29 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial override fun deserializeNBT(tag: CompoundTag) { savetables.deserializeNBT(tag) + for (filter in regularSlotFilters) { + filter.value = null + } + + exoPackSlotFilters.clear() + + for (elem in tag.getCompoundList("exoPackSlotFilters")) { + val slot = (elem["slot"] as? NumericTag)?.asInt ?: continue + val filter = (elem["filter"] as? StringTag)?.asString ?: continue + + if (slot >= 0) { + exoPackSlotFilters[slot] = ForgeRegistries.ITEMS.getValue(ResourceLocation.tryParse(filter) ?: continue) ?: Items.AIR + } + } + + val regularSlotFilters = tag.getStringList("regularSlotFilters") + + for (i in 0 until regularSlotFilters.size.coerceAtMost(this.regularSlotFilters.size)) { + val path = regularSlotFilters[i].asString + if (path == "") continue + this.regularSlotFilters[i].value = ForgeRegistries.ITEMS.getValue(ResourceLocation.tryParse(path) ?: continue) ?: Items.AIR + } + // iterations deathLog.clear() @@ -689,20 +754,6 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } } - // exosuit - hasExoPack = tag.getBoolean("hasExoSuit") - displayExoPack = tag.getBoolean("displayExoSuit") - tag.map("exoSuitSlotCountModifiers", exoPackSlotModifier::deserializeNBT) - - exoPackContainer.deserializeNBT(tag["exoSuitContainer"]) - isExoPackCraftingUpgraded = tag.getBoolean("isExoSuitCraftingUpgraded") - - // android - isAndroid = tag.getBoolean("isAndroid") - willBecomeAndroid = tag.getBoolean("willBecomeAndroid") - - tag.map("androidEnergy", androidEnergy::deserializeNBT) - featureMap.clear() research.clear() @@ -977,8 +1028,141 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } else LazyOptional.empty() } + /** + * This re-implement [Inventory.add] logic (original method is redirected to this) + */ + fun inventoryAddImpl(stack: ItemStack): Boolean { + val items = ply.inventory.items + val exoPackContainer = exoPackContainer + + if (!stack.isStackable) { + for (i in items.indices) { + if (items[i].isEmpty && (regularSlotFilters[i].value === null || regularSlotFilters[i].value === stack.item)) { + items[i] = stack.copy() + items[i].popTime = 5 + stack.count = 0 + return true + } + } + + for (i in 0 until exoPackContainer.containerSize) { + if (exoPackContainer[i].isEmpty && (exoPackSlotFilters[i] === null || exoPackSlotFilters[i] === stack.item)) { + exoPackContainer[i] = stack.copy() + exoPackContainer[i].popTime = 5 + stack.count = 0 + return true + } + } + + MinecraftForge.EVENT_BUS.post(ItemStackLeftoverEvent(stack, this)) + + if (ply.abilities.instabuild) { + stack.count = 0 + } + + return !stack.isEmpty + } + + // двигаем в существующие слоты + items[ply.inventory.selected].also { stackStacks(it, stack) } + if (stack.isEmpty) return true + ply.inventory.offhand[0].also { stackStacks(it, stack) } + if (stack.isEmpty) return true + + for (i in items.indices) { + if (stackStacks(items[i], stack) && stack.isEmpty) { + return true + } + } + + for (i in 0 until exoPackContainer.containerSize) { + if (stackStacks(exoPackContainer[i], stack)) { + exoPackContainer.setChanged(i) + + if (stack.isEmpty) { + return true + } + } + } + + // двигаем в пустые слоты + + // двигаем в отфильтрованные слоты + for (i in items.indices) { + if (items[i].isEmpty && regularSlotFilters[i].value === stack.item) { + items[i] = stack.split(stack.count.coerceAtMost(stack.maxStackSize)) + items[i].popTime = 5 + + if (stack.isEmpty) { + return true + } + } + } + + for (i in 0 until exoPackContainer.containerSize) { + if (exoPackContainer[i].isEmpty && exoPackSlotFilters[i] === stack.item) { + exoPackContainer[i] = stack.split(stack.count.coerceAtMost(stack.maxStackSize)) + exoPackContainer[i].popTime = 5 + + if (stack.isEmpty) { + return true + } + } + } + + // двигаем в обычные слоты + for (i in items.indices) { + if (items[i].isEmpty && regularSlotFilters[i].value === null) { + items[i] = stack.split(stack.count.coerceAtMost(stack.maxStackSize)) + items[i].popTime = 5 + + if (stack.isEmpty) { + return true + } + } + } + + for (i in 0 until exoPackContainer.containerSize) { + if (exoPackContainer[i].isEmpty && exoPackSlotFilters[i] === null) { + exoPackContainer[i] = stack.split(stack.count.coerceAtMost(stack.maxStackSize)) + exoPackContainer[i].popTime = 5 + + if (stack.isEmpty) { + return true + } + } + } + + MinecraftForge.EVENT_BUS.post(ItemStackLeftoverEvent(stack, this)) + + if (ply.abilities.instabuild) { + stack.count = 0 + } + + return !stack.isEmpty + } + @Suppress("unused") companion object { + private fun stackStacks(it: ItemStack, stack: ItemStack): Boolean { + if ( + !it.isEmpty && + it.maxStackSize > it.count && + it.isStackable && + ItemStack.isSameItemSameTags(it, stack) + ) { + val new = (it.count + stack.count).coerceAtMost(it.maxStackSize) + val diff = new - it.count + it.count = new + stack.count -= diff + it.popTime = 5 + + return true + } + + return false + } + init { WitherBoss.TARGETING_CONDITIONS.selector(WitherBoss.TARGETING_CONDITIONS.selector!!.and { it.matteryPlayer?.isAndroid != true }) WitherBoss.LIVING_ENTITY_SELECTOR = WitherBoss.LIVING_ENTITY_SELECTOR.and { it.matteryPlayer?.isAndroid != true } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt index 82f17061f..f7c63478c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt @@ -23,7 +23,7 @@ class AndroidPowerSource( synchronizer: FieldSynchronizer, initialCharge: Decimal, maxCharge: Decimal -) : IMatteryEnergyStorage, INBTSerializable { +) : IMatteryEnergyStorage, INBTSerializable { override val energyFlow: FlowDirection get() = FlowDirection.INPUT @@ -46,7 +46,8 @@ class AndroidPowerSource( } } - override fun deserializeNBT(tag: CompoundTag) { + override fun deserializeNBT(tag: CompoundTag?) { + tag ?: return battery = tag.getDecimal("battery") maxBattery = tag.getDecimal("maxBattery") item = tag.getItemStack("item") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt index 5c2d28a0c..fdea69675 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt @@ -10,8 +10,8 @@ import ru.dbotthepony.mc.otm.client.render.sprite import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.FilteredSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel -import ru.dbotthepony.mc.otm.client.screen.panels.util.BackgroundPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel import ru.dbotthepony.mc.otm.client.setMousePos import ru.dbotthepony.mc.otm.client.shouldOpenVanillaInventory @@ -48,10 +48,10 @@ class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen> { val frame = FramePanel(this, width = 200f, height = FRAME_BASE_HEIGHT + inventoryRows * AbstractSlotPanel.SIZE, title = this.title) - val toolbeltLine = EditablePanel(this, frame, height = 18f) - toolbeltLine.dock = Dock.BOTTOM + val hotbarStrip = EditablePanel(this, frame, height = 18f) + hotbarStrip.dock = Dock.BOTTOM - toolbeltLine.setDockMargin(top = 3f) + hotbarStrip.setDockMargin(top = 3f) scrollPanel = DiscreteScrollBarPanel(this, null, maxScroll = { integerDivisionDown(menu.playerCombinedInventorySlots.size, 9) }, scrollCallback = { @@ -83,11 +83,12 @@ class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen(menu: T, inventory: Inventory, tit hotbarStrip.dock = Dock.BOTTOM for (slot in menu.playerHotbarSlots) { - SlotPanel(this, hotbarStrip, slot).also { it.dock = Dock.LEFT } + FilteredSlotPanel.of(this, hotbarStrip, slot, filter = slot.filter!!).also { + it.dock = Dock.LEFT + } } val canvas = EditablePanel(this, inventoryFrame) @@ -211,7 +219,9 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit hotbarStrip.dock = Dock.BOTTOM for (slot in menu.playerHotbarSlots) { - SlotPanel(this, hotbarStrip, slot).also { it.dock = Dock.LEFT } + FilteredSlotPanel.of(this, hotbarStrip, slot, filter = slot.filter!!).also { + it.dock = Dock.LEFT + } } inventoryScrollbar.parent = slotListCanvas @@ -250,13 +260,19 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } for (i in 0 .. (8).coerceAtMost(menu.playerCombinedInventorySlots.size - offset - 1)) { - val slot = object : SlotPanel, Slot>(this@MatteryScreen, canvas, menu.playerCombinedInventorySlots[offset + i]) { + val slot = menu.playerCombinedInventorySlots[offset + i] + + object : FilteredSlotPanel, Slot>(this@MatteryScreen, canvas, slot) { + init { + dock = Dock.LEFT + } + override fun mouseScrolledInner(x: Double, y: Double, scroll: Double): Boolean { return false } - } - slot.dock = Dock.LEFT + override var slotFilter: Item? by slot.filter!! + } } return@Int2ObjectFunction canvas diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt index 37422cba5..9c5b1516f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt @@ -59,7 +59,7 @@ abstract class AbstractSlotPanel> @JvmOverloads constru if (!itemstack.isEmpty) { // val font = RenderProperties.get(itemstack).getFont(itemstack) - val font = (itemstack.item.renderPropertiesInternal as? IClientItemExtensions)?.getFont(itemstack, IClientItemExtensions.FontContext.TOOLTIP) + val font = IClientItemExtensions.of(itemstack).getFont(itemstack, IClientItemExtensions.FontContext.TOOLTIP) // TODO: WHERE???????????? // GuiUtils.preItemToolTip(itemstack); @@ -84,5 +84,6 @@ abstract class AbstractSlotPanel> @JvmOverloads constru val SLOT_HIGHLIGHT_DRAG = RGBAColor(200, 200, 200, 150) const val SIZE = 18f val SLOT_BACKGROUND = WidgetLocation.MISC.sprite(0f, 0f, SIZE, SIZE) + val FILTERED_SLOT_BACKGROUND = WidgetLocation.MISC.sprite(46f, 0f, SIZE, SIZE) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/FilteredSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/FilteredSlotPanel.kt new file mode 100644 index 000000000..b031c0d88 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/FilteredSlotPanel.kt @@ -0,0 +1,113 @@ +package ru.dbotthepony.mc.otm.client.screen.panels.slot + +import com.mojang.blaze3d.platform.InputConstants +import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.world.inventory.Slot +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.Items +import net.minecraftforge.client.extensions.common.IClientItemExtensions +import ru.dbotthepony.mc.otm.client.isCtrlDown +import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.client.playGuiClickSound +import ru.dbotthepony.mc.otm.client.render.MatterySprite +import ru.dbotthepony.mc.otm.client.render.drawColor +import ru.dbotthepony.mc.otm.client.render.drawRect +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.core.GetterSetter +import ru.dbotthepony.mc.otm.core.math.RGBAColor + +abstract class FilteredSlotPanel, out T : Slot>( + screen: S, + parent: EditablePanel<*>?, + slot: T, + x: Float = 0f, + y: Float = 0f, + width: Float = SIZE, + height: Float = SIZE, + noItemIcon: MatterySprite? = null +) : SlotPanel(screen, parent, slot, x, y, width, height, noItemIcon) { + abstract var slotFilter: Item? + + override fun renderSlotBackground(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + super.renderSlotBackground(stack, mouseX, mouseY, partialTick) + + if (slotFilter != null) { + if (slotFilter !== Items.AIR) { + val itemStack = ItemStack(slotFilter!!, 1) + + screen.renderItemStack(absoluteX, absoluteY, itemStack, null) + clearDepth(stack) + } + + drawColor = SLOT_FILTER_COLOR + drawRect(stack, 0f, 0f, width, height) + } + } + + override fun innerRenderTooltips(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + if (isHovered && slotFilter != null && slotFilter !== Items.AIR && itemStack.isEmpty) { + val itemstack = ItemStack(slotFilter!!, 1) + + screen.renderComponentTooltip( + stack, + getItemStackTooltip(itemstack), + mouseX.toInt(), + mouseY.toInt(), + IClientItemExtensions.of(itemstack).getFont(itemstack, IClientItemExtensions.FontContext.TOOLTIP) ?: screen.font, + itemstack + ) + } + + return super.innerRenderTooltips(stack, mouseX, mouseY, partialTick) + } + + override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { + if (button == InputConstants.MOUSE_BUTTON_LEFT && minecraft.window.isCtrlDown) { + if (slotFilter === null) { + if (screen.menu.carried.isEmpty) { + slotFilter = slot.item.item + } else { + slotFilter = screen.menu.carried.item + } + } else { + slotFilter = null + } + + playGuiClickSound() + + return true + } else { + return super.mouseClickedInner(x, y, button) + } + } + + override fun mouseReleasedInner(x: Double, y: Double, button: Int): Boolean { + if (button == InputConstants.MOUSE_BUTTON_LEFT && minecraft.window.isCtrlDown) { + return true + } + + return super.mouseReleasedInner(x, y, button) + } + + companion object { + val SLOT_FILTER_COLOR = RGBAColor(85, 113, 216, 150) + + fun , T : Slot> of( + screen: S, + parent: EditablePanel<*>?, + slot: T, + x: Float = 0f, + y: Float = 0f, + width: Float = SIZE, + height: Float = SIZE, + noItemIcon: MatterySprite? = null, + filter: GetterSetter + ): FilteredSlotPanel { + return object : FilteredSlotPanel(screen, parent, slot, x, y, width, height, noItemIcon) { + override var slotFilter: Item? by filter + } + } + } +} 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 906cdda22..181419a23 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -11,6 +11,7 @@ import com.google.gson.JsonObject import com.google.gson.JsonPrimitive import net.minecraft.core.BlockPos import net.minecraft.nbt.CompoundTag +import net.minecraft.nbt.NbtAccounter import net.minecraft.network.FriendlyByteBuf import net.minecraft.network.chat.ComponentContents import net.minecraft.network.chat.contents.TranslatableContents @@ -18,6 +19,7 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.Entity import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.Items import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.block.state.BlockState @@ -32,7 +34,11 @@ import net.minecraftforge.registries.ForgeRegistry import net.minecraftforge.registries.IForgeRegistry import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.util.readInt +import ru.dbotthepony.mc.otm.core.util.readVarIntLE +import ru.dbotthepony.mc.otm.core.util.writeInt +import ru.dbotthepony.mc.otm.core.util.writeVarIntLE import java.io.InputStream +import java.io.OutputStream import java.lang.ref.Reference import java.math.BigInteger import java.util.Arrays @@ -167,12 +173,16 @@ fun FriendlyByteBuf.writeItemType(value: Item) { writeInt(ForgeRegistries.ITEMS.getID(value)) } -fun FriendlyByteBuf.readItemType(): Item? { - return ForgeRegistries.ITEMS.getValue(readInt()) +fun OutputStream.writeItemType(value: Item) { + writeVarIntLE(ForgeRegistries.ITEMS.getID(value)) } -fun InputStream.readItemType(): Item? { - return ForgeRegistries.ITEMS.getValue(readInt()) +fun FriendlyByteBuf.readItemType(): Item { + return ForgeRegistries.ITEMS.getValue(readInt()) ?: Items.AIR +} + +fun InputStream.readItemType(sizeLimit: NbtAccounter? = null): Item { + return ForgeRegistries.ITEMS.getValue(readVarIntLE(sizeLimit)) ?: Items.AIR } operator fun > StateHolder<*, *>.get(property: Property): T { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt index 15fb51b18..b5b81aa6d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt @@ -10,6 +10,8 @@ import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.core.immutableMap import ru.dbotthepony.mc.otm.core.math.readDecimal import ru.dbotthepony.mc.otm.core.math.writeDecimal +import ru.dbotthepony.mc.otm.core.readItemType +import ru.dbotthepony.mc.otm.core.writeItemType import java.io.DataInput import java.io.DataInputStream import java.io.DataOutput @@ -60,6 +62,30 @@ class StreamCodec( comparator: ((a: V, b: V) -> Boolean) = { a, b -> a == b } ) : this({ stream, sizeLimit -> sizeLimit.accountBytes(payloadSize); reader.invoke(stream) }, writer, copier, comparator) + val nullable = object : IStreamCodec { + override fun read(stream: DataInputStream, sizeLimit: NbtAccounter): V? { + sizeLimit.accountBytes(1L) + return if (stream.read() == 0) null else reader.invoke(stream, sizeLimit) + } + + override fun write(stream: DataOutputStream, value: V?) { + if (value === null) stream.write(0) else { + stream.write(1) + writer.invoke(stream, value) + } + } + + override fun copy(value: V?): V? { + return if (value === null) null else copier.invoke(value) + } + + override fun compare(a: V?, b: V?): Boolean { + if (a === null && b === null) return true + if (a === null || b === null) return false + return comparator.invoke(a, b) + } + } + override fun read(stream: DataInputStream, sizeLimit: NbtAccounter): V { return reader.invoke(stream, sizeLimit) } @@ -86,6 +112,7 @@ val LongValueCodec = StreamCodec(DataInputStream::readLong, 8L, DataOutputStream val FloatValueCodec = StreamCodec(DataInputStream::readFloat, 4L, DataOutputStream::writeFloat) val DoubleValueCodec = StreamCodec(DataInputStream::readDouble, 8L, DataOutputStream::writeDouble) val ItemStackValueCodec = StreamCodec(DataInputStream::readItem, DataOutputStream::writeItem, ItemStack::copy) { a, b -> a.equals(b, true) } +val ItemValueCodec = StreamCodec(DataInputStream::readItemType, DataOutputStream::writeItemType) val DecimalValueCodec = StreamCodec(DataInputStream::readDecimal, DataOutputStream::writeDecimal) val BigDecimalValueCodec = StreamCodec(DataInputStream::readBigDecimal, DataOutputStream::writeBigDecimal) val UUIDValueCodec = StreamCodec({ s, a -> a.accountBytes(8L); UUID(s.readLong(), s.readLong()) }, { s, v -> s.writeLong(v.mostSignificantBits); s.writeLong(v.leastSignificantBits) }) @@ -331,7 +358,7 @@ fun OutputStream.writeBinaryString(input: String) { private data class IndexedStreamCodec( val condition: Predicate, val id: Int, - val codec: StreamCodec + val codec: IStreamCodec ) { fun read(stream: DataInputStream, sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 KiB */)): T { return codec.read(stream, sizeLimit) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index be6448075..0aab8f4b5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -14,6 +14,7 @@ import net.minecraft.world.Container import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.* +import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.enchantment.EnchantmentHelper.hasBindingCurse import net.minecraft.world.level.block.entity.BlockEntity @@ -26,6 +27,7 @@ import ru.dbotthepony.mc.otm.compat.curios.curiosSlots import ru.dbotthepony.mc.otm.compat.curios.isCurioSlot import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot +import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.util.BigDecimalValueCodec import ru.dbotthepony.mc.otm.core.util.BinaryStringCodec import ru.dbotthepony.mc.otm.core.util.BooleanValueCodec @@ -35,8 +37,10 @@ import ru.dbotthepony.mc.otm.core.util.VarIntValueCodec import ru.dbotthepony.mc.otm.menu.widget.AbstractWidget import ru.dbotthepony.mc.otm.network.FieldSynchronizer import ru.dbotthepony.mc.otm.network.MatteryPacket +import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel import ru.dbotthepony.mc.otm.network.MenuFieldPacket import ru.dbotthepony.mc.otm.network.MenuNetworkChannel +import ru.dbotthepony.mc.otm.network.SetInventoryFilterPacket import ru.dbotthepony.mc.otm.network.enqueueWork import ru.dbotthepony.mc.otm.network.packetHandled import ru.dbotthepony.mc.otm.network.sender @@ -70,12 +74,12 @@ abstract class MatteryMenu @JvmOverloads protected constructor( private val _matteryWidgets = ArrayList() val matteryWidgets: List = Collections.unmodifiableList(_matteryWidgets) - private val _playerInventorySlots = ArrayList() - private val _playerInventorySlots2 = ArrayList() - private val _playerHotbarSlots = ArrayList() - private val _playerMainSlots = ArrayList() - private val _playerExoSuitSlots = ArrayList() - private val _playerCombinedInventorySlots = ArrayList() + private val _playerInventorySlots = ArrayList() + private val _playerInventorySlots2 = ArrayList() + private val _playerHotbarSlots = ArrayList() + private val _playerMainSlots = ArrayList() + private val _playerExoSuitSlots = ArrayList() + private val _playerCombinedInventorySlots = ArrayList() private val playerInputs = ArrayList>() @@ -155,32 +159,32 @@ abstract class MatteryMenu @JvmOverloads protected constructor( /** * inventory + exosuit + hotbar (in this order) */ - val playerInventorySlots: List = Collections.unmodifiableList(_playerInventorySlots) + val playerInventorySlots: List = Collections.unmodifiableList(_playerInventorySlots) /** * hotbar + inventory + exosuit (in this order) */ - val playerInventorySlots2: List = Collections.unmodifiableList(_playerInventorySlots2) + val playerInventorySlots2: List = Collections.unmodifiableList(_playerInventorySlots2) /** * hotbar only */ - val playerHotbarSlots: List = Collections.unmodifiableList(_playerHotbarSlots) + val playerHotbarSlots: List = Collections.unmodifiableList(_playerHotbarSlots) /** * inventory only */ - val playerMainSlots: List = Collections.unmodifiableList(_playerMainSlots) + val playerMainSlots: List = Collections.unmodifiableList(_playerMainSlots) /** * exosuit only */ - val playerExoSuitSlots: List = Collections.unmodifiableList(_playerExoSuitSlots) + val playerExoSuitSlots: List = Collections.unmodifiableList(_playerExoSuitSlots) /** * inventory + exosuit (in this order) */ - val playerCombinedInventorySlots: List = Collections.unmodifiableList(_playerCombinedInventorySlots) + val playerCombinedInventorySlots: List = Collections.unmodifiableList(_playerCombinedInventorySlots) var autoCreateInventoryFrame = true private set @@ -250,6 +254,32 @@ abstract class MatteryMenu @JvmOverloads protected constructor( return super.isSameInventory(other) } + + // фильтр существует только для автоматизации + // игрок всё равно может класть предмет вручную, даже если он не соответствует фильтру + internal val filter: GetterSetter? + + init { + val mattery = ply.matteryPlayer + + if (mattery != null) { + if (container === inventory && slotIndex in mattery.regularSlotFilters.indices) { + filter = GetterSetter.of( + getter = { mattery.regularSlotFilters[slotIndex].value }, + setter = { MatteryPlayerNetworkChannel.sendToServer(SetInventoryFilterPacket(SetInventoryFilterPacket.Type.INVENTORY, slotIndex, it)) } + ) + } else if (container === mattery.exoPackContainer) { + filter = GetterSetter.of( + getter = { mattery.exoPackSlotFilters[slotIndex] }, + setter = { MatteryPlayerNetworkChannel.sendToServer(SetInventoryFilterPacket(SetInventoryFilterPacket.Type.EXOPACK, slotIndex, it)) } + ) + } else { + filter = null + } + } else { + filter = null + } + } } open inner class EquipmentSlot(container: Container, index: Int, val type: net.minecraft.world.entity.EquipmentSlot, x: Int = 0, y: Int = 0) : InventorySlot(container, index, x, y) { @@ -458,6 +488,18 @@ abstract class MatteryMenu @JvmOverloads protected constructor( val copy = slot.item.copy() var any = false + if (target.any { it.any { it is InventorySlot && it.filter != null } }) { + for (collection in target) { + if (moveItemStackTo(slot, collection, onlyFiltered = true)) { + any = true + + if (!slot.hasItem()) { + return copy + } + } + } + } + for (collection in target) { if (moveItemStackTo(slot, collection)) { any = true @@ -506,25 +548,12 @@ abstract class MatteryMenu @JvmOverloads protected constructor( return true } - fun moveItemStackTo( - item: ItemStack, - slots: Collection - ): Boolean { - val remainder = moveItemStackToSlots(item, slots) - - if (remainder.count == item.count) { - return false - } - - item.count = remainder.count - return true - } - fun moveItemStackTo( source: Slot, - slots: Collection + slots: Collection, + onlyFiltered: Boolean = false ): Boolean { - val remainder = moveItemStackToSlots(source.item, slots) + val remainder = moveItemStackToSlots(source.item, slots, onlyFiltered = onlyFiltered) if (remainder.count == source.item.count) { return false @@ -540,15 +569,25 @@ abstract class MatteryMenu @JvmOverloads protected constructor( return true } - fun moveItemStackToSlots(item: ItemStack, slots: Collection, simulate: Boolean = false): ItemStack { + fun moveItemStackToSlots(item: ItemStack, slots: Collection, simulate: Boolean = false, onlyFiltered: Boolean = false): ItemStack { + if (item.isEmpty) { + return ItemStack.EMPTY + } + val copy = item.copy() // first pass - stack with existing slots if (copy.isStackable) { for (slot in slots) { + if (onlyFiltered && (slot !is InventorySlot || slot.filter == null || slot.filter.get() != item.item)) { + continue + } else if (!onlyFiltered && slot is InventorySlot && slot.filter != null && slot.filter.get() != null && slot.filter.get() != item.item) { + continue + } + val limit = slot.getMaxStackSize(copy) - if (limit > slot.item.count && ItemStack.isSameItemSameTags(slot.item, copy) && slot.mayPlace(item)) { + if (limit > slot.item.count && slot.mayPlace(item) && ItemStack.isSameItemSameTags(slot.item, copy)) { val newCount = (slot.item.count + copy.count).coerceAtMost(limit) val diff = newCount - slot.item.count copy.count -= diff @@ -567,6 +606,12 @@ abstract class MatteryMenu @JvmOverloads protected constructor( // second pass - drop stack into first free slot for (slot in slots) { + if (onlyFiltered && (slot !is InventorySlot || slot.filter == null || slot.filter.get() != item.item)) { + continue + } else if (!onlyFiltered && slot is InventorySlot && slot.filter != null && slot.filter.get() != null && slot.filter.get() != item.item) { + continue + } + val limit = slot.getMaxStackSize(copy) if (!slot.hasItem() && slot.mayPlace(item)) { @@ -597,9 +642,19 @@ abstract class MatteryMenu @JvmOverloads protected constructor( require(finalSlot < slots.size) { "Final slot $finalSlot is bigger than total size of array of ${slots.size}" } val slots = ArrayList(finalSlot - initialSlot + 1) + var filters = false for (i in (if (inverse) finalSlot downTo initialSlot else initialSlot .. finalSlot)) { - slots.add(slots[i]) + val slot = slots[i] + slots.add(slot) + + if (slot is InventorySlot && slot.filter != null) { + filters = true + } + } + + if (filters) { + return moveItemStackToSlots(moveItemStackToSlots(item, slots, simulate, onlyFiltered = true), slots, simulate, onlyFiltered = false) } return moveItemStackToSlots(item, slots, simulate) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt index 6d709eda3..c8ed89fc6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt @@ -6,7 +6,9 @@ import net.minecraft.network.chat.Component import net.minecraft.network.protocol.game.ClientboundSetCarriedItemPacket import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.player.Inventory +import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.Items import net.minecraftforge.network.NetworkDirection.PLAY_TO_CLIENT import net.minecraftforge.network.NetworkDirection.PLAY_TO_SERVER import net.minecraftforge.network.NetworkEvent @@ -27,6 +29,8 @@ import ru.dbotthepony.mc.otm.client.render.ShockwaveRenderer import ru.dbotthepony.mc.otm.container.get import ru.dbotthepony.mc.otm.container.set import ru.dbotthepony.mc.otm.core.math.Vector +import ru.dbotthepony.mc.otm.core.readItemType +import ru.dbotthepony.mc.otm.core.writeItemType import ru.dbotthepony.mc.otm.menu.tech.AndroidStationMenu import ru.dbotthepony.mc.otm.menu.ExoPackInventoryMenu import ru.dbotthepony.mc.otm.registry.AndroidFeatures @@ -510,8 +514,56 @@ object HideExosuitPacket : MatteryPacket { } } +class SetInventoryFilterPacket(val type: Type, val slot: Int, val item: Item?) : MatteryPacket { + enum class Type { + INVENTORY, + EXOPACK + } + + override fun write(buff: FriendlyByteBuf) { + buff.writeEnum(type) + buff.writeVarInt(slot) + + if (item == null) { + buff.writeByte(0) + } else { + buff.writeByte(1) + buff.writeItemType(item) + } + } + + override fun play(context: Supplier) { + context.packetHandled = true + val player = context.sender?.matteryPlayer ?: return + + when (type) { + Type.INVENTORY -> { + if (slot in 0 until player.regularSlotFilters.size) { + player.regularSlotFilters[slot].value = item + } + } + + Type.EXOPACK -> { + if (slot in 0 until player.exoPackSlotCount) { + if (item == null) { + player.exoPackSlotFilters.remove(slot) + } else { + player.exoPackSlotFilters[slot] = item + } + } + } + } + } + + companion object { + fun read(buff: FriendlyByteBuf): SetInventoryFilterPacket { + return SetInventoryFilterPacket(buff.readEnum(Type::class.java), buff.readVarInt(), if (buff.readByte() > 0) buff.readItemType() else null) + } + } +} + object MatteryPlayerNetworkChannel : MatteryNetworkChannel( - version = "2", + version = "3", name = "player" ) { fun register() { @@ -543,5 +595,7 @@ object MatteryPlayerNetworkChannel : MatteryNetworkChannel( add(DisplayExosuitPacket::class, { DisplayExosuitPacket }, PLAY_TO_SERVER) add(HideExosuitPacket::class, { HideExosuitPacket }, PLAY_TO_SERVER) + + add(SetInventoryFilterPacket::class, SetInventoryFilterPacket.Companion::read, PLAY_TO_SERVER) } } diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 4000db026..4c3be4b7f 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -2,6 +2,8 @@ public-f net.minecraft.client.gui.screens.Screen f_96539_ # title public net.minecraft.server.MinecraftServer f_129744_ # storageSource +public net.minecraft.world.entity.player.Inventory f_150070_ # SELECTION_SIZE + # for accessing and setting from MatteryScreen class public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_169600_ public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_169605_ diff --git a/src/main/resources/coremods/code_injector.js b/src/main/resources/coremods/code_injector.js index f733d2489..5de443d1f 100644 --- a/src/main/resources/coremods/code_injector.js +++ b/src/main/resources/coremods/code_injector.js @@ -533,46 +533,6 @@ function injectAtTail(path, instructions) { }) } -function injectInventoryInsertHook( - instructions, - determinedOffset, - hookName, - hookDesc, - pre -) { - var last = instructions.get(determinedOffset) - - // print('Patching Inventory#add at instruction ' + determinedOffset + ' to add ' + hookName + hookDesc) - - // loading this (Inventory) to stack - - if (pre != undefined) { - instructions.insert(last, pre) - last = pre - } - - var next = new VarInsnNode(opcodesRemapped.aload, 0) - instructions.insert(last, next) - - last = next - // loading itemstack to stack - next = new VarInsnNode(opcodesRemapped.aload, 2) - - instructions.insert(last, next) - - last = next - // dispatching hook method - next = new MethodInsnNode( - opcodesRemapped.invokestatic, - 'ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability', - hookName, - hookDesc, - false - ) - - instructions.insert(last, next) -} - function patchBlendFunc(node) { var last = new MethodInsnNode( opcodesRemapped.invokestatic, @@ -795,128 +755,6 @@ function initializeCoreMod() { return node }), - 'Inventory#add patch': { - 'target': { - 'type': 'METHOD', - 'class': 'net.minecraft.world.entity.player.Inventory', - 'methodName': ASMAPI.mapMethod('m_36040_'), // add - 'methodDesc': '(ILnet/minecraft/world/item/ItemStack;)Z' - }, - - 'transformer': function(node) { - // If item is not "damaged": - // 113: invokevirtual #144 // Method addResource:(ILnet/minecraft/world/item/ItemStack;)I - // 116: invokevirtual #158 // Method net/minecraft/world/item/ItemStack.setCount:(I)V - // 119: aload_2 - // 120: invokevirtual #57 // Method net/minecraft/world/item/ItemStack.isEmpty:()Z - // 123: ifne 134 - // 126: aload_2 - // 127: invokevirtual #68 // Method net/minecraft/world/item/ItemStack.getCount:()I - // 130: iload_3 - // 131: if_icmplt 87 - // <-- our target - // 134: aload_2 - // 135: invokevirtual #68 // Method net/minecraft/world/item/ItemStack.getCount:()I - // 138: iload_3 - // 139: if_icmpne 162 - // 142: aload_0 - - // If item returned that it is damaged: - // 10: invokevirtual #97 // Method net/minecraft/world/item/ItemStack.isDamaged:()Z - // 13: ifeq 87 - // 16: iload_1 - // 17: iconst_m1 - // 18: if_icmpne 26 - // 21: aload_0 - // 22: invokevirtual #86 // Method getFreeSlot:()I - // 25: istore_1 - // <-- our target - // 26: iload_1 - // 27: iflt 65 - // 30: aload_0 - // 31: getfield #19 // Field items:Lnet/minecraft/core/NonNullList; - // 34: iload_1 - // 35: aload_2 - - var i - - // 83: iconst_1 - // 84: ireturn - // 85: iconst_0 - // 86: ireturn - // 87: aload_2 - // 88: invokevirtual #68 // Method net/minecraft/world/item/ItemStack.getCount:()I - - // patch "not damaged" before loop - for (i = 0; i < node.instructions.size(); i++) { - var determinedOffset = test([ - opcodesRemapped.iconst_1, - opcodesRemapped.ireturn, - opcodesRemapped.iconst_0, - opcodesRemapped.ireturn, - opcodesRemapped.aload, - opcodesRemapped.invokevirtual, - ], node.instructions, i) - - if (determinedOffset != -1) { - injectInventoryInsertHook(node.instructions, determinedOffset - 1, - 'inventoryAddItemHookPre', - '(Lnet/minecraft/world/entity/player/Inventory;Lnet/minecraft/world/item/ItemStack;)V') - - break - } - } - - // patch "not damaged" after loop - for (i = 0; i < node.instructions.size(); i++) { - var determinedOffset = test([ - opcodesRemapped.invokevirtual, - opcodesRemapped.invokevirtual, - opcodesRemapped.aload, - opcodesRemapped.invokevirtual, - opcodesRemapped.ifne, - opcodesRemapped.aload, - opcodesRemapped.invokevirtual, - opcodesRemapped.iload, - opcodesRemapped.if_icmplt, - ], node.instructions, i) - - if (determinedOffset != -1) { - injectInventoryInsertHook(node.instructions, determinedOffset, - 'inventoryAddItemHook', - '(Lnet/minecraft/world/entity/player/Inventory;Lnet/minecraft/world/item/ItemStack;)V') - - break - } - } - - // patch "damaged" - for (i = 0; i < node.instructions.size(); i++) { - var determinedOffset = test([ - opcodesRemapped.invokevirtual, - opcodesRemapped.ifeq, - opcodesRemapped.iload, - opcodesRemapped.iconst_m1, - opcodesRemapped.if_icmpne, - opcodesRemapped.aload, - opcodesRemapped.invokevirtual, - opcodesRemapped.istore, - ], node.instructions, i) - - if (determinedOffset != -1) { - injectInventoryInsertHook(node.instructions, determinedOffset, - 'inventoryAddDamagedItemHook', - '(ILnet/minecraft/world/entity/player/Inventory;Lnet/minecraft/world/item/ItemStack;)V', - new VarInsnNode(opcodesRemapped.iload, node.instructions.get(determinedOffset - 1)['var'])) - - break - } - } - - return node - } - }, - 'GameRenderer#render hook': { 'target': { 'type': 'METHOD', diff --git a/src/main/resources/overdrive_that_matters.mixins.json b/src/main/resources/overdrive_that_matters.mixins.json index c0527a2d9..cbdb3b6c4 100644 --- a/src/main/resources/overdrive_that_matters.mixins.json +++ b/src/main/resources/overdrive_that_matters.mixins.json @@ -9,6 +9,7 @@ "MixinPatchProjectileFinder", "MixinLivingEntity", "MixinAnvilBlock", + "MixinInventory", "MixinAbstractHurtingProjectile" ] } From 3c61a03fd820509ff0ba534a327b59f640101316 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 16 Mar 2023 21:30:19 +0700 Subject: [PATCH 0364/1199] User defined slot filters on MatteryContainer level, streamlined slot-level filter interface, cargo crates now allow slots to be filtered --- .../mc/otm/datagen/lang/English.kt | 4 + .../mc/otm/datagen/lang/Russian.kt | 4 + .../entity/storage/ItemMonitorBlockEntity.kt | 2 +- .../otm/capability/MatteryPlayerCapability.kt | 83 ++------- .../client/screen/ExoPackInventoryScreen.kt | 4 +- .../mc/otm/client/screen/MatteryScreen.kt | 16 +- .../screen/decorative/CargoCrateScreen.kt | 3 +- ...dSlotPanel.kt => UserFilteredSlotPanel.kt} | 51 +++++- .../mc/otm/container/ContainerHandler.kt | 10 +- .../mc/otm/container/MatteryContainer.kt | 166 +++++++++++++----- .../mc/otm/menu/ExoPackInventoryMenu.kt | 4 +- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 54 ++++-- .../ru/dbotthepony/mc/otm/menu/Slots.kt | 31 ++++ .../mc/otm/menu/decorative/CargoCrateMenu.kt | 5 +- .../mc/otm/network/FieldSynchronizer.kt | 119 +++++++++++-- .../network/MatteryPlayerNetworkChannel.kt | 8 +- .../mc/otm/network/MenuNetworkChannel.kt | 24 ++- 17 files changed, 397 insertions(+), 191 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/{FilteredSlotPanel.kt => UserFilteredSlotPanel.kt} (64%) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 8efb2f333..afbde691b 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -678,6 +678,10 @@ private fun gui(provider: MatteryLanguageProvider) { gui("essence_capsule", "(Almost) Everything you ever knew is within") gui("essence_capsule2", "This item can be recycled at Essence Servo") + + gui("slot_filter.filtered", "This slot is filtered for automation") + gui("slot_filter.forbidden", "This slot is forbidden for automation mechanisms") + gui("slot_filter.hint", "To remove slot filter press Ctrl + LMB") } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index de15bde54..859b16be3 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -680,6 +680,10 @@ private fun gui(provider: MatteryLanguageProvider) { gui("essence_capsule", "(Почти) Всё, что вы знали, хранится внутри") gui("essence_capsule2", "Данный предмет может быть переработан внутри хранилища эссенции") + + gui("slot_filter.filtered", "Данный слот отфильтрован для автоматизации") + gui("slot_filter.forbidden", "Данный слот запрещён для взаимодействия средствами автоматизации") + gui("slot_filter.hint", "Для удаления фильтра нажмите Ctrl + ЛКМ") } } 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 614b60b56..e19cee385 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 @@ -214,7 +214,7 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : // a lot of code is hardcoded to take CraftingContainer as it's input // hence we are forced to work around this by providing proxy container - val craftingGrid = object : MatteryContainer(this, 3 * 3) { + val craftingGrid = object : MatteryContainer(::setChangedLight, 3 * 3) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { super.setChanged(slot, new, old) craftingGridDummy[slot] = new diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 27895053c..31e6b749f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -1,12 +1,10 @@ package ru.dbotthepony.mc.otm.capability -import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import net.minecraft.ChatFormatting import net.minecraft.core.Direction import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.ListTag -import net.minecraft.nbt.NumericTag import net.minecraft.nbt.StringTag import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation @@ -20,7 +18,6 @@ import net.minecraft.world.entity.boss.wither.WitherBoss import net.minecraft.world.entity.monster.Phantom import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player -import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.item.ProjectileWeaponItem @@ -63,14 +60,11 @@ import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.minus import ru.dbotthepony.mc.otm.core.nbt.getCompoundList import ru.dbotthepony.mc.otm.core.nbt.getStringList -import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.IntValueCodec -import ru.dbotthepony.mc.otm.core.util.ItemStackValueCodec import ru.dbotthepony.mc.otm.core.util.ItemValueCodec import ru.dbotthepony.mc.otm.core.util.Savetables import ru.dbotthepony.mc.otm.core.util.UUIDValueCodec -import ru.dbotthepony.mc.otm.core.util.VarIntValueCodec import ru.dbotthepony.mc.otm.menu.ExoPackInventoryMenu import ru.dbotthepony.mc.otm.network.* import ru.dbotthepony.mc.otm.registry.AndroidFeatures @@ -144,10 +138,8 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial * For fields that need to be synchronized only to owning player * * Please mind if you really need to use this in your mod; - * don't forget to specify field names when you add them to synchronizer. + * any differences in field order/types/etc will break *everything* * - * Even if other side does not have your field defined, both sides will negotiate - * and figure out how to deal with this situation as long as you specify field name. */ val synchronizer = FieldSynchronizer() @@ -160,10 +152,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial * For fields that need to be synchronized to everyone * * Please mind if you really need to use this in your mod; - * don't forget to specify field names when you add them to synchronizer. - * - * Even if other side does not have your field defined, both sides will negotiate - * and figure out how to deal with this situation as long as you specify field name. + * any differences in field order/types/etc will break *everything* */ val publicSynchronizer = FieldSynchronizer() @@ -192,13 +181,10 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial * If you want to properly extend Exopack suit capacity, add your value into this map */ val exoPackSlotModifier = UUIDIntModifiersMap(observer = observer@{ - if (ply !is ServerPlayer) - return@observer - if (it < 0) { - exoPackSlotCount = 0 + exoPackContainer = PlayerMatteryContainer(0) } else { - exoPackSlotCount = it + exoPackContainer = PlayerMatteryContainer(it) } }, backingMap = this.exoPackSlotModifierMap) @@ -206,49 +192,28 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial synchronizer.Field(null, ItemValueCodec.nullable) } - val exoPackSlotFilters by synchronizer.Map( - keyCodec = VarIntValueCodec, - valueCodec = ItemValueCodec, - backingMap = Int2ObjectOpenHashMap() - ) - - /** - * Current slot count of Exopack - * - * For properly affecting this value please look at [exoPackSlotModifier] - */ - var exoPackSlotCount by publicSynchronizer.int(setter = setter@{ value, access, _ -> - require(value >= 0) { "Invalid slot count $value" } - - if (value != access.read()) { - access.write(value) - _exoPackMenu = null - exoPackContainer = PlayerMatteryContainer(value) - } - }) - /** * Exopack container, which actually store items inside Exopack */ var exoPackContainer: MatteryContainer = PlayerMatteryContainer(0) private set(value) { _exoPackMenu = null + field.removeFilterSynchronizer() @Suppress("SENSELESS_COMPARISON") // false positive - fields of player can easily be nulls, despite annotations saying otherwise if (ply.containerMenu != null && (ply !is ServerPlayer || ply.connection != null)) { ply.closeContainer() } - for (i in 0 until value.containerSize.coerceAtMost(field.containerSize)) { - if (!field[i].isEmpty) { - value[i] = field[i] - } - } - for (i in value.containerSize until field.containerSize) { - ply.spawnAtLocation(field[i]) + if (ply is ServerPlayer) + ply.spawnAtLocation(field[i]) + + field[i] = ItemStack.EMPTY } + value.deserializeNBT(field.serializeNBT()) + value.addFilterSynchronizer(synchronizer) field = value } @@ -699,15 +664,6 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } } - tag["exoPackSlotFilters"] = ListTag().also { - for ((slot, filter) in exoPackSlotFilters) { - it.add(CompoundTag().also { - it["slot"] = slot - it["filter"] = filter.registryName!!.toString() - }) - } - } - tag["regularSlotFilters"] = ListTag().also { for (filter in regularSlotFilters) { it.add(StringTag.valueOf(filter.value?.registryName?.toString() ?: "")) @@ -724,17 +680,6 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial filter.value = null } - exoPackSlotFilters.clear() - - for (elem in tag.getCompoundList("exoPackSlotFilters")) { - val slot = (elem["slot"] as? NumericTag)?.asInt ?: continue - val filter = (elem["filter"] as? StringTag)?.asString ?: continue - - if (slot >= 0) { - exoPackSlotFilters[slot] = ForgeRegistries.ITEMS.getValue(ResourceLocation.tryParse(filter) ?: continue) ?: Items.AIR - } - } - val regularSlotFilters = tag.getStringList("regularSlotFilters") for (i in 0 until regularSlotFilters.size.coerceAtMost(this.regularSlotFilters.size)) { @@ -1046,7 +991,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } for (i in 0 until exoPackContainer.containerSize) { - if (exoPackContainer[i].isEmpty && (exoPackSlotFilters[i] === null || exoPackSlotFilters[i] === stack.item)) { + if (exoPackContainer[i].isEmpty && exoPackContainer.testSlotFilter(i, stack)) { exoPackContainer[i] = stack.copy() exoPackContainer[i].popTime = 5 stack.count = 0 @@ -1100,7 +1045,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } for (i in 0 until exoPackContainer.containerSize) { - if (exoPackContainer[i].isEmpty && exoPackSlotFilters[i] === stack.item) { + if (exoPackContainer[i].isEmpty && exoPackContainer.hasSlotFilter(i) && exoPackContainer.testSlotFilter(i, stack)) { exoPackContainer[i] = stack.split(stack.count.coerceAtMost(stack.maxStackSize)) exoPackContainer[i].popTime = 5 @@ -1123,7 +1068,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } for (i in 0 until exoPackContainer.containerSize) { - if (exoPackContainer[i].isEmpty && exoPackSlotFilters[i] === null) { + if (exoPackContainer[i].isEmpty && !exoPackContainer.hasSlotFilter(i)) { exoPackContainer[i] = stack.split(stack.count.coerceAtMost(stack.maxStackSize)) exoPackContainer[i].popTime = 5 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt index fdea69675..739edf842 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt @@ -10,7 +10,7 @@ import ru.dbotthepony.mc.otm.client.render.sprite import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel -import ru.dbotthepony.mc.otm.client.screen.panels.slot.FilteredSlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.UserFilteredSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel import ru.dbotthepony.mc.otm.client.setMousePos @@ -83,7 +83,7 @@ class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen(menu: T, inventory: Inventory, tit hotbarStrip.dock = Dock.BOTTOM for (slot in menu.playerHotbarSlots) { - FilteredSlotPanel.of(this, hotbarStrip, slot, filter = slot.filter!!).also { + UserFilteredSlotPanel.of(this, hotbarStrip, slot).also { it.dock = Dock.LEFT } } @@ -219,7 +211,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit hotbarStrip.dock = Dock.BOTTOM for (slot in menu.playerHotbarSlots) { - FilteredSlotPanel.of(this, hotbarStrip, slot, filter = slot.filter!!).also { + UserFilteredSlotPanel.of(this, hotbarStrip, slot).also { it.dock = Dock.LEFT } } @@ -262,7 +254,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit for (i in 0 .. (8).coerceAtMost(menu.playerCombinedInventorySlots.size - offset - 1)) { val slot = menu.playerCombinedInventorySlots[offset + i] - object : FilteredSlotPanel, Slot>(this@MatteryScreen, canvas, slot) { + object : UserFilteredSlotPanel, Slot>(this@MatteryScreen, canvas, slot) { init { dock = Dock.LEFT } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt index a4f7c0206..a3febd6c8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt @@ -6,6 +6,7 @@ import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.UserFilteredSlotPanel import ru.dbotthepony.mc.otm.menu.decorative.CargoCrateMenu class CargoCrateScreen(menu: CargoCrateMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { @@ -14,7 +15,7 @@ class CargoCrateScreen(menu: CargoCrateMenu, inventory: Inventory, title: Compon val grid = GridPanel(this, frame, 8f, 18f, 9f * 18f, 6f * 18f, 9, 6) for (slot in menu.storageSlots) - SlotPanel(this, grid, slot) + UserFilteredSlotPanel.of(this, grid, slot) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/FilteredSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt similarity index 64% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/FilteredSlotPanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt index b031c0d88..97772a9bc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/FilteredSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt @@ -2,6 +2,8 @@ package ru.dbotthepony.mc.otm.client.screen.panels.slot import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.ChatFormatting +import net.minecraft.network.chat.Component import net.minecraft.world.inventory.Slot import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack @@ -16,9 +18,12 @@ import ru.dbotthepony.mc.otm.client.render.drawRect import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.GetterSetter +import ru.dbotthepony.mc.otm.core.TextComponent +import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.RGBAColor +import ru.dbotthepony.mc.otm.menu.UserFilteredSlot -abstract class FilteredSlotPanel, out T : Slot>( +abstract class UserFilteredSlotPanel, out T : Slot>( screen: S, parent: EditablePanel<*>?, slot: T, @@ -39,9 +44,12 @@ abstract class FilteredSlotPanel, out T : Slot>( screen.renderItemStack(absoluteX, absoluteY, itemStack, null) clearDepth(stack) + + drawColor = SLOT_FILTER_COLOR + } else { + drawColor = SLOT_BLOCK_COLOR } - drawColor = SLOT_FILTER_COLOR drawRect(stack, 0f, 0f, width, height) } } @@ -52,12 +60,27 @@ abstract class FilteredSlotPanel, out T : Slot>( screen.renderComponentTooltip( stack, - getItemStackTooltip(itemstack), + getItemStackTooltip(itemstack).toMutableList().also { + it.add(0, TranslatableComponent("otm.gui.slot_filter.filtered").withStyle(ChatFormatting.GRAY)) + it.add(1, TranslatableComponent("otm.gui.slot_filter.hint").withStyle(ChatFormatting.GRAY)) + it.add(2, TextComponent("")) + }, mouseX.toInt(), mouseY.toInt(), IClientItemExtensions.of(itemstack).getFont(itemstack, IClientItemExtensions.FontContext.TOOLTIP) ?: screen.font, itemstack ) + } else if (isHovered && slotFilter === Items.AIR && itemStack.isEmpty) { + screen.renderComponentTooltip( + stack, + ArrayList().also { + it.add(TranslatableComponent("otm.gui.slot_filter.forbidden").withStyle(ChatFormatting.GRAY)) + it.add(TranslatableComponent("otm.gui.slot_filter.hint").withStyle(ChatFormatting.GRAY)) + }, + mouseX.toInt(), + mouseY.toInt(), + screen.font + ) } return super.innerRenderTooltips(stack, mouseX, mouseY, partialTick) @@ -93,6 +116,7 @@ abstract class FilteredSlotPanel, out T : Slot>( companion object { val SLOT_FILTER_COLOR = RGBAColor(85, 113, 216, 150) + val SLOT_BLOCK_COLOR = RGBAColor(219, 113, 113, 150) fun , T : Slot> of( screen: S, @@ -104,10 +128,27 @@ abstract class FilteredSlotPanel, out T : Slot>( height: Float = SIZE, noItemIcon: MatterySprite? = null, filter: GetterSetter - ): FilteredSlotPanel { - return object : FilteredSlotPanel(screen, parent, slot, x, y, width, height, noItemIcon) { + ): UserFilteredSlotPanel { + return object : UserFilteredSlotPanel(screen, parent, slot, x, y, width, height, noItemIcon) { override var slotFilter: Item? by filter } } + + fun , T : UserFilteredSlot> of( + screen: S, + parent: EditablePanel<*>?, + slot: T, + x: Float = 0f, + y: Float = 0f, + width: Float = SIZE, + height: Float = SIZE, + noItemIcon: MatterySprite? = null + ): UserFilteredSlotPanel { + return object : UserFilteredSlotPanel(screen, parent, slot, x, y, width, height, noItemIcon) { + override var slotFilter: Item? + get() = slot.filter?.get() + set(value) { slot.filter?.accept(value) } + } + } } } 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 cbba0cd31..7a6c610b0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHandler.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.mc.otm.container import net.minecraft.world.item.ItemStack -import net.minecraftforge.common.util.LazyOptional +import net.minecraft.world.item.Items import net.minecraftforge.items.IItemHandler class ContainerHandler @JvmOverloads internal constructor( @@ -12,7 +12,7 @@ class ContainerHandler @JvmOverloads internal constructor( override fun getStackInSlot(slot: Int) = container[slot] override fun insertItem(slot: Int, stack: ItemStack, simulate: Boolean): ItemStack { - if (!filter.canInsert(slot, stack)) + if (!container.testSlotFilter(slot, stack) || !filter.canInsert(slot, stack)) return stack filter.preInsert(slot, stack, simulate) @@ -47,11 +47,9 @@ class ContainerHandler @JvmOverloads internal constructor( } override fun extractItem(slot: Int, amount: Int, simulate: Boolean): ItemStack { - if (amount == 0) + if (amount <= 0 || container.isSlotForbiddenForAutomation(slot)) return ItemStack.EMPTY - require(amount >= 0) { "Can not extract negative amount of items" } - filter.preExtract(slot, amount, simulate) val localStack = container.getItem(slot) @@ -76,6 +74,6 @@ class ContainerHandler @JvmOverloads internal constructor( } override fun isItemValid(slot: Int, stack: ItemStack): Boolean { - return filter.canInsert(slot, stack) + return container.testSlotFilter(slot, stack) && filter.canInsert(slot, stack) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt index f2bc86f6e..b0af02659 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt @@ -1,22 +1,33 @@ package ru.dbotthepony.mc.otm.container +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import it.unimi.dsi.fastutil.ints.IntAVLTreeSet import net.minecraft.world.item.ItemStack import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.ListTag import net.minecraft.nbt.Tag +import net.minecraft.resources.ResourceLocation import net.minecraft.world.Container import kotlin.jvm.JvmOverloads import net.minecraft.world.entity.player.Player -import net.minecraft.world.level.block.entity.BlockEntity +import net.minecraft.world.item.Item +import net.minecraft.world.item.Items import net.minecraftforge.common.util.INBTSerializable +import net.minecraftforge.registries.ForgeRegistries +import ru.dbotthepony.mc.otm.core.forValidRefs import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.core.util.ItemValueCodec +import ru.dbotthepony.mc.otm.core.util.VarIntValueCodec +import ru.dbotthepony.mc.otm.network.FieldSynchronizer +import ru.dbotthepony.mc.otm.network.IField +import java.lang.ref.WeakReference import java.util.* +import kotlin.collections.ArrayList @Suppress("UNUSED") -open class MatteryContainer(val watcher: Runnable, private val size: Int) : Container, Iterable, INBTSerializable { - constructor(watcher: BlockEntity, size: Int) : this(watcher::setChanged, size) +open class MatteryContainer(protected val watcher: Runnable, private val size: Int) : Container, Iterable, INBTSerializable { constructor(size: Int) : this({}, size) init { @@ -26,6 +37,72 @@ open class MatteryContainer(val watcher: Runnable, private val size: Int) : Cont private var ignoreChangeNotifications = 0 protected val slots: Array = Array(size) { ItemStack.EMPTY } private val trackedSlots: Array = Array(size) { ItemStack.EMPTY } + private val filters: Array = arrayOfNulls(size) + private var filterSynchronizer: WeakReference>>? = null + + fun clearSlotFilters() { + Arrays.fill(filters, null) + filterSynchronizer?.get()?.value?.clear() + } + + fun removeFilterSynchronizer() { + filterSynchronizer?.get()?.remove() + filterSynchronizer = null + } + + fun addFilterSynchronizer(synchronizer: FieldSynchronizer): IField> { + check(filterSynchronizer?.get() == null) { "Already has filter synchronizer" } + + val field = synchronizer.Map( + keyCodec = VarIntValueCodec, + valueCodec = ItemValueCodec, + backingMap = Int2ObjectOpenHashMap(), + callback = { + for (change in it) { + change.map({ k, v -> filters[k] = v }, { k -> filters[k] = null }, { Arrays.fill(filters, null) }) + } + } + ) + + for ((i, filter) in filters.withIndex()) { + if (filter != null) { + field.value[i] = filter + } + } + + filterSynchronizer = WeakReference(field) + return field + } + + fun setSlotFilter(slot: Int, filter: Item? = null) { + if (filters[slot] !== filter) { + filters[slot] = filter + + filterSynchronizer?.get()?.let { + if (filter == null) { + it.value.remove(slot) + } else { + it.value[slot] = filter + } + } + } + } + + fun getSlotFilter(slot: Int) = filters[slot] + fun hasSlotFilter(slot: Int) = filters[slot] !== null + fun isSlotForbiddenForAutomation(slot: Int) = filters[slot] === Items.AIR + + fun testSlotFilter(slot: Int, itemStack: ItemStack): Boolean { + return testSlotFilter(slot, itemStack.item) + } + + fun testSlotFilter(slot: Int, item: Item): Boolean { + if (filters[slot] == null) { + return true + } else { + return filters[slot] === item + } + } final override fun getContainerSize() = size @@ -44,42 +121,31 @@ open class MatteryContainer(val watcher: Runnable, private val size: Int) : Cont protected open fun startedIgnoringUpdates() {} protected open fun stoppedIgnoringUpdates() {} - private fun deserializeNBT(tag: CompoundTag?) { - Arrays.fill(slots, ItemStack.EMPTY) - - if (tag == null) { - setChanged() - return - } - + private fun deserializeNBT(tag: CompoundTag) { // нам не интересен размер tag.map("items") { it: ListTag -> + deserializeNBT(it) + } + + tag.map("filters") { it: ListTag -> + val map = filterSynchronizer?.get() + for (i in 0 until it.size.coerceAtMost(size)) { - slots[i] = ItemStack.of(it[i] as CompoundTag) + val nbt = it[i] as CompoundTag + val index = nbt.getInt("slotIndex") + filters[index] = ForgeRegistries.ITEMS.getValue(ResourceLocation.tryParse(nbt.getString("filter")) ?: continue) + + if (filters[index] != null) { + map?.value?.put(index, filters[index]!!) + } } } setChanged() } - private fun deserializeNBT(tag: ListTag?) { - Arrays.fill(slots, ItemStack.EMPTY) - - if (tag == null) { - setChanged() - return - } - - var isIndexed = true - - for (i in 0 until tag.size.coerceAtMost(size)) { - if (!(tag[i] as CompoundTag).contains("slotIndex")) { - isIndexed = false - break - } - } - - if (isIndexed) { + private fun deserializeNBT(tag: ListTag) { + if (tag.all { (it as CompoundTag).contains("slotIndex") }) { val freeSlots = IntAVLTreeSet() for (i in 0 until size) @@ -104,18 +170,21 @@ open class MatteryContainer(val watcher: Runnable, private val size: Int) : Cont slots[i] = ItemStack.of(tag[i] as CompoundTag) } } - - setChanged() } override fun deserializeNBT(tag: Tag?) { + Arrays.fill(slots, ItemStack.EMPTY) + Arrays.fill(filters, null) + filterSynchronizer?.get()?.value?.clear() + when (tag) { is CompoundTag -> deserializeNBT(tag) - is ListTag -> deserializeNBT(tag) - else -> { - Arrays.fill(slots, ItemStack.EMPTY) + is ListTag -> { + deserializeNBT(tag) setChanged() } + + else -> setChanged() } } @@ -123,13 +192,26 @@ open class MatteryContainer(val watcher: Runnable, private val size: Int) : Cont if (ignoreChangeNotifications == 0) watcher.run() } - override fun serializeNBT(): ListTag { - return ListTag().also { - for ((i, item) in slots.withIndex()) { - if (!item.isEmpty) { - it.add(item.serializeNBT().also { - it["slotIndex"] = i - }) + override fun serializeNBT(): CompoundTag { + return CompoundTag().also { + it["items"] = ListTag().also { + for ((i, item) in slots.withIndex()) { + if (!item.isEmpty) { + it.add(item.serializeNBT().also { + it["slotIndex"] = i + }) + } + } + } + + it["filters"] = ListTag().also { + for ((i, filter) in filters.withIndex()) { + if (filter != null) { + it.add(CompoundTag().also { + it["filter"] = filter.registryName!!.toString() + it["slotIndex"] = i + }) + } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt index 2aafa2b0a..ee2b9525b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt @@ -173,8 +173,8 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen return super.quickMoveStack(ply, slotIndex) } - override fun canTakeItemForPickAll(p_38908_: ItemStack, p_38909_: Slot): Boolean { - return p_38909_.container != craftingResultContainer && super.canTakeItemForPickAll(p_38908_, p_38909_) + override fun canTakeItemForPickAll(itemStack: ItemStack, slot: Slot): Boolean { + return slot.container != craftingResultContainer && super.canTakeItemForPickAll(itemStack, slot) } companion object : ContainerSynchronizer { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 0aab8f4b5..bb5872939 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -27,15 +27,18 @@ import ru.dbotthepony.mc.otm.compat.curios.curiosSlots import ru.dbotthepony.mc.otm.compat.curios.isCurioSlot import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot +import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.util.BigDecimalValueCodec import ru.dbotthepony.mc.otm.core.util.BinaryStringCodec import ru.dbotthepony.mc.otm.core.util.BooleanValueCodec import ru.dbotthepony.mc.otm.core.util.IStreamCodec +import ru.dbotthepony.mc.otm.core.util.ItemValueCodec import ru.dbotthepony.mc.otm.core.util.NullValueCodec import ru.dbotthepony.mc.otm.core.util.VarIntValueCodec import ru.dbotthepony.mc.otm.menu.widget.AbstractWidget import ru.dbotthepony.mc.otm.network.FieldSynchronizer +import ru.dbotthepony.mc.otm.network.IField import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel import ru.dbotthepony.mc.otm.network.MenuFieldPacket @@ -239,26 +242,22 @@ abstract class MatteryMenu @JvmOverloads protected constructor( return _matteryWidgets[index] } - open inner class InventorySlot(container: Container, index: Int, x: Int = 0, y: Int = 0) : MatterySlot(container, index, x, y) { + open inner class InventorySlot(container: Container, index: Int, x: Int = 0, y: Int = 0) : UserFilteredSlot(container, index, x, y) { override fun mayPlace(itemStack: ItemStack): Boolean { - return super.mayPlace(itemStack) && !isInventorySlotLocked(index) + return !isInventorySlotLocked(index) && super.mayPlace(itemStack) } override fun mayPickup(player: Player): Boolean { - return super.mayPickup(player) && !isInventorySlotLocked(index) + return !isInventorySlotLocked(index) && super.mayPickup(player) } override fun isSameInventory(other: Slot): Boolean { if (container === inventory || container === ply.matteryPlayer?.exoPackContainer) - return other.container === inventory || other.container === ply.matteryPlayer?.exoPackContainer + return (other.container === inventory || other.container === ply.matteryPlayer?.exoPackContainer) && isSameFilter(other) return super.isSameInventory(other) } - // фильтр существует только для автоматизации - // игрок всё равно может класть предмет вручную, даже если он не соответствует фильтру - internal val filter: GetterSetter? - init { val mattery = ply.matteryPlayer @@ -270,7 +269,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( ) } else if (container === mattery.exoPackContainer) { filter = GetterSetter.of( - getter = { mattery.exoPackSlotFilters[slotIndex] }, + getter = { mattery.exoPackContainer.getSlotFilter(slotIndex) }, setter = { MatteryPlayerNetworkChannel.sendToServer(SetInventoryFilterPacket(SetInventoryFilterPacket.Type.EXOPACK, slotIndex, it)) } ) } else { @@ -359,7 +358,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( val payload = mSynchronizer.collectNetworkPayload() if (payload != null) { - MenuNetworkChannel.send(ply, MenuFieldPacket(payload)) + MenuNetworkChannel.send(ply, MenuFieldPacket(containerId, payload)) } super.broadcastChanges() @@ -384,7 +383,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( val payload = mSynchronizer.collectNetworkPayload() if (payload != null) { - MenuNetworkChannel.send(ply, MenuFieldPacket(payload)) + MenuNetworkChannel.send(ply, MenuFieldPacket(containerId, payload)) } super.broadcastFullState() @@ -420,6 +419,23 @@ abstract class MatteryMenu @JvmOverloads protected constructor( return pSlot } + if (pSlot is UserFilteredSlot && !pSlot.hasSetFilter) { + val container = pSlot.container + + val input: PlayerInput + val field: IField + + if (container is MatteryContainer) { + input = PlayerInput(ItemValueCodec.nullable, handler = { container.setSlotFilter(pSlot.slotIndex, it) }) + field = mSynchronizer.ComputedField(getter = { container.getSlotFilter(pSlot.slotIndex) }, ItemValueCodec.nullable) + } else { + input = PlayerInput(ItemValueCodec.nullable, handler = { throw UnsupportedOperationException() }) + field = mSynchronizer.ComputedField(getter = { null }, ItemValueCodec.nullable) + } + + pSlot.filter = GetterSetter.of(getter = field::value, setter = input::input) + } + return super.addSlot(pSlot) } @@ -488,7 +504,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( val copy = slot.item.copy() var any = false - if (target.any { it.any { it is InventorySlot && it.filter != null } }) { + if (target.any { it.any { it is UserFilteredSlot && it.filter != null } }) { for (collection in target) { if (moveItemStackTo(slot, collection, onlyFiltered = true)) { any = true @@ -525,11 +541,11 @@ abstract class MatteryMenu @JvmOverloads protected constructor( return moveItemStackToSlots(stack, _playerInventorySlots, simulate = simulate) } - override fun canTakeItemForPickAll(p_38908_: ItemStack, p_38909_: Slot): Boolean { - if (p_38909_ is EquipmentSlot) + override fun canTakeItemForPickAll(itemStack: ItemStack, slot: Slot): Boolean { + if (slot is EquipmentSlot) return false - return super.canTakeItemForPickAll(p_38908_, p_38909_) && (p_38909_ !is MatterySlot || p_38909_.canTakeItemForPickAll()) && !p_38909_.isCurioSlot + return super.canTakeItemForPickAll(itemStack, slot) && (slot !is MatterySlot || slot.canTakeItemForPickAll()) && !slot.isCurioSlot } override fun moveItemStackTo( @@ -579,9 +595,9 @@ abstract class MatteryMenu @JvmOverloads protected constructor( // first pass - stack with existing slots if (copy.isStackable) { for (slot in slots) { - if (onlyFiltered && (slot !is InventorySlot || slot.filter == null || slot.filter.get() != item.item)) { + if (onlyFiltered && (slot !is UserFilteredSlot || slot.filter == null || slot.filter!!.get() != item.item)) { continue - } else if (!onlyFiltered && slot is InventorySlot && slot.filter != null && slot.filter.get() != null && slot.filter.get() != item.item) { + } else if (!onlyFiltered && slot is UserFilteredSlot && slot.filter != null && slot.filter!!.get() != null && slot.filter!!.get() != item.item) { continue } @@ -606,9 +622,9 @@ abstract class MatteryMenu @JvmOverloads protected constructor( // second pass - drop stack into first free slot for (slot in slots) { - if (onlyFiltered && (slot !is InventorySlot || slot.filter == null || slot.filter.get() != item.item)) { + if (onlyFiltered && (slot !is UserFilteredSlot || slot.filter == null || slot.filter!!.get() != item.item)) { continue - } else if (!onlyFiltered && slot is InventorySlot && slot.filter != null && slot.filter.get() != null && slot.filter.get() != item.item) { + } else if (!onlyFiltered && slot is UserFilteredSlot && slot.filter != null && slot.filter!!.get() != null && slot.filter!!.get() != item.item) { continue } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt index 3b545428b..0d312681e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt @@ -3,11 +3,13 @@ package ru.dbotthepony.mc.otm.menu import net.minecraft.world.Container import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.Slot +import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.runOnClient open class MatterySlot @JvmOverloads constructor(container: Container, index: Int, x: Int = 0, y: Int = 0) : Slot(container, index, x, y) { @@ -26,6 +28,35 @@ open class MatterySlot @JvmOverloads constructor(container: Container, index: In } } +open class UserFilteredSlot(container: Container, index: Int, x: Int = 0, y: Int = 0) : MatterySlot(container, index, x, y) { + var hasSetFilter = false + private set + + var filter: GetterSetter? = null + set(value) { + hasSetFilter = true + field = value + } + + override fun canTakeItemForPickAll(): Boolean { + return filter?.get() == null + } + + fun isSameFilter(other: Slot): Boolean { + if (other !is UserFilteredSlot) + return filter?.get() == null + + return ( + (other.filter == null && filter == null) || + (other.filter != null && filter != null && other.filter!!.get() == filter!!.get()) + ) + } + + override fun isSameInventory(other: Slot): Boolean { + return isSameFilter(other) && super.isSameInventory(other) + } +} + open class MachineOutputSlot @JvmOverloads constructor(container: Container, index: Int, x: Int = 0, y: Int = 0, val onTake: () -> Unit = {}) : MatterySlot(container, index, x, y) { override fun mayPlace(itemStack: ItemStack): Boolean { return false diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt index 0a2ee3dc2..df4e05718 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt @@ -7,6 +7,7 @@ import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.block.entity.decorative.CargoCrateBlockEntity import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.UserFilteredSlot import ru.dbotthepony.mc.otm.registry.MMenus class CargoCrateMenu @JvmOverloads constructor( @@ -14,7 +15,7 @@ class CargoCrateMenu @JvmOverloads constructor( inventory: Inventory, tile: CargoCrateBlockEntity? = null ) : MatteryMenu(MMenus.CARGO_CRATE, p_38852_, inventory, tile) { - val storageSlots: List + val storageSlots: List private val trackedPlayerOpen = !inventory.player.isSpectator @@ -22,7 +23,7 @@ class CargoCrateMenu @JvmOverloads constructor( val container = tile?.container ?: SimpleContainer(CargoCrateBlockEntity.CAPACITY) storageSlots = immutableList(CargoCrateBlockEntity.CAPACITY) { - addStorageSlot(MatterySlot(container, it)) + addStorageSlot(UserFilteredSlot(container, it)) } if (trackedPlayerOpen) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt index 371d2f0c2..00a0d1dd8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt @@ -57,6 +57,9 @@ sealed interface IField : ReadOnlyProperty, Supplier, () -> V { fun markDirty() fun markDirty(endpoint: FieldSynchronizer.Endpoint) val value: V + val isRemoved: Boolean + + fun remove() fun write(stream: DataOutputStream, endpoint: FieldSynchronizer.Endpoint) fun read(stream: DataInputStream) @@ -94,7 +97,23 @@ data class MapChangeset( val action: MapAction, val key: K?, val value: V? -) +) { + inline fun map(add: (K, V) -> Unit, remove: (K) -> Unit) { + when (action) { + MapAction.ADD -> add.invoke(key!!, value!!) + MapAction.REMOVE -> remove.invoke(key!!) + else -> {} + } + } + + inline fun map(add: (K, V) -> Unit, remove: (K) -> Unit, clear: () -> Unit) { + when (action) { + MapAction.CLEAR -> clear.invoke() + MapAction.ADD -> add.invoke(key!!, value!!) + MapAction.REMOVE -> remove.invoke(key!!) + } + } +} enum class MapAction { CLEAR, ADD, REMOVE @@ -109,7 +128,13 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa constructor() : this(Runnable {}, false) constructor(callback: Runnable) : this(callback, false) - private val fields = ArrayList>(0) + private var freeSlots = 0 + // почему не удалять поля напрямую? + // чтоб не возникло проблем в состоянии гонки + // формируем пакет -> удаляем поле по обе стороны -> клиент принимает пакет -> клиент считывает неверные данные + // конечно, всё равно всё сломается если было удалено поле, которое находится в пакете + // но если поля нет в пакете, то всё окей + private val fields = ArrayList?>(0) private val observers = ArrayList>(0) private var nextFieldID = 0 @@ -463,7 +488,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa fun markDirty() { for (field in fields) { - field.markDirty(this) + field?.markDirty(this) } } @@ -475,6 +500,10 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa dirtyFields.add(field) } + internal fun removeDirtyField(field: AbstractField<*>) { + dirtyFields.remove(field) + } + internal fun getMapBacklog(map: Map): LinkedList Unit>> { if (unused) { return LinkedList() @@ -521,10 +550,57 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa @Suppress("LeakingThis") abstract inner class AbstractField : IField { - val id: Int = fields.size + 1 + val id: Int init { - fields.add(this) + if (freeSlots > 0) { + var found = -1 + + for (i in fields.indices) { + if (fields[i] == null) { + fields[i] = this + found = i + 1 + freeSlots-- + break + } + } + + if (found == -1) { + throw RuntimeException("freeSlots = $freeSlots but no null entries in field list!") + } else { + id = found + } + } else { + fields.add(this) + id = fields.size + } + } + + final override var isRemoved = false + private set + + override fun remove() { + if (isRemoved) + return + + isRemoved = true + freeSlots++ + fields[id - 1] = null + observers.remove(this) + + while (fields[fields.size - 1] == null) { + fields.removeAt(fields.size - 1) + freeSlots-- + } + + forEachEndpoint { + it.removeDirtyField(this) + } + } + + override fun markDirty(endpoint: Endpoint) { + check(!isRemoved) { "Field was removed" } + endpoint.addDirtyField(this) } } @@ -564,6 +640,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } override fun observe(): Boolean { + check(!isRemoved) { "Field was removed" } if (!isDirty && !codec.compare(remote, field)) { notifyEndpoints(this@Field) isDirty = true @@ -603,21 +680,20 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } override fun markDirty() { + check(!isRemoved) { "Field was removed" } notifyEndpoints(this@Field) isDirty = true } - override fun markDirty(endpoint: Endpoint) { - endpoint.addDirtyField(this) - } - override fun write(stream: DataOutputStream, endpoint: Endpoint) { + check(!isRemoved) { "Field was removed" } codec.write(stream, field) isDirty = false remote = codec.copy(field) } override fun read(stream: DataInputStream) { + check(!isRemoved) { "Field was removed" } val value = codec.read(stream) val setter = this.setter @@ -647,6 +723,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } override fun observe(): Boolean { + check(!isRemoved) { "Field was removed" } if (!isDirty && (remote == null || !codec.compare(remote ?: throw ConcurrentModificationException(), value))) { notifyEndpoints(this) isDirty = true @@ -657,24 +734,23 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } override fun markDirty() { + check(!isRemoved) { "Field was removed" } notifyEndpoints(this) isDirty = true } - override fun markDirty(endpoint: Endpoint) { - endpoint.addDirtyField(this) - } - override val value: V get() = clientValue ?: getter.invoke() override fun write(stream: DataOutputStream, endpoint: Endpoint) { + check(!isRemoved) { "Field was removed" } val value = value codec.write(stream, value) isDirty = false } override fun read(stream: DataInputStream) { + check(!isRemoved) { "Field was removed" } val newValue = codec.read(stream) clientValue = newValue observer.invoke(newValue) @@ -715,6 +791,8 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } override fun observe(): Boolean { + check(!isRemoved) { "Field was removed" } + if (!isDirty && !codec.compare(remote, value)) { notifyEndpoints(this) isDirty = true @@ -725,21 +803,20 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } override fun markDirty() { + check(!isRemoved) { "Field was removed" } notifyEndpoints(this) isDirty = true } - override fun markDirty(endpoint: Endpoint) { - endpoint.addDirtyField(this) - } - override fun write(stream: DataOutputStream, endpoint: Endpoint) { + check(!isRemoved) { "Field was removed" } val value = value codec.write(stream, value) isDirty = false } override fun read(stream: DataInputStream) { + check(!isRemoved) { "Field was removed" } this.value = codec.read(stream) } } @@ -782,6 +859,8 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } override fun observe(): Boolean { + check(!isRemoved) { "Field was removed" } + if (isRemote) { return false } @@ -815,6 +894,8 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } override fun markDirty() { + check(!isRemoved) { "Field was removed" } + if (isRemote) { return } @@ -857,6 +938,8 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } override fun markDirty(endpoint: Endpoint) { + check(!isRemoved) { "Field was removed" } + if (isRemote) { return } @@ -1025,7 +1108,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa */ fun invalidate() { for (field in fields) { - field.markDirty() + field?.markDirty() } forEachEndpoint { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt index c8ed89fc6..8445f9c01 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt @@ -544,12 +544,8 @@ class SetInventoryFilterPacket(val type: Type, val slot: Int, val item: Item?) : } Type.EXOPACK -> { - if (slot in 0 until player.exoPackSlotCount) { - if (item == null) { - player.exoPackSlotFilters.remove(slot) - } else { - player.exoPackSlotFilters[slot] = item - } + if (slot in 0 until player.exoPackContainer.containerSize) { + player.exoPackContainer.setSlotFilter(slot, item) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt index 0c5fd3cb4..5cd4aeabb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt @@ -6,9 +6,11 @@ import net.minecraft.world.item.ItemStack import net.minecraftforge.network.NetworkDirection import net.minecraftforge.network.NetworkEvent import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorPlayerSettings +import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.compat.InventoryScrollPacket import ru.dbotthepony.mc.otm.container.ItemFilterSlotPacket +import ru.dbotthepony.mc.otm.menu.ExoPackInventoryMenu import ru.dbotthepony.mc.otm.menu.matter.CancelTaskPacket import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.matter.PatternsChangePacket @@ -22,24 +24,34 @@ import ru.dbotthepony.mc.otm.menu.data.StackRemovePacket import java.io.ByteArrayInputStream import java.util.function.Supplier -class MenuFieldPacket(val bytes: ByteArray, val length: Int) : MatteryPacket { - constructor(stream: FastByteArrayOutputStream) : this(stream.array, stream.length) +class MenuFieldPacket(val containerId: Int, val bytes: ByteArray, val length: Int) : MatteryPacket { + constructor(containerId: Int, stream: FastByteArrayOutputStream) : this(containerId, stream.array, stream.length) override fun write(buff: FriendlyByteBuf) { + buff.writeVarInt(containerId) buff.writeBytes(bytes, 0, length) } override fun play(context: Supplier) { context.packetHandled = true - context.get().enqueueWork { - (minecraft.player?.containerMenu as? MatteryMenu)?.mSynchronizer?.read(ByteArrayInputStream(bytes, 0, length)) + + context.enqueueWork { + if (containerId == ExoPackInventoryMenu.CONTAINER_ID) { + minecraft.player?.matteryPlayer?.exoPackMenu?.mSynchronizer?.read(ByteArrayInputStream(bytes, 0, length)) + } else { + val menu = minecraft.player?.containerMenu as? MatteryMenu ?: return@enqueueWork + + if (menu.containerId == containerId) + menu.mSynchronizer.read(ByteArrayInputStream(bytes, 0, length)) + } } } companion object { fun read(buff: FriendlyByteBuf): MenuFieldPacket { + val containerId = buff.readVarInt() val readable = buff.readableBytes() - return MenuFieldPacket(ByteArray(readable).also(buff::readBytes), readable) + return MenuFieldPacket(containerId, ByteArray(readable).also(buff::readBytes), readable) } } } @@ -62,7 +74,7 @@ class SetCarriedPacket(val item: ItemStack) : MatteryPacket { } object MenuNetworkChannel : MatteryNetworkChannel( - version = "2", + version = "3", name = "menu" ) { fun register() { From 9cfd1e2119fd9e766ec50ebe38116a8c682b6fd8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 16 Mar 2023 21:41:15 +0700 Subject: [PATCH 0365/1199] Make use of Curios' SlotModifiersUpdatedEvent --- .../mc/otm/OverdriveThatMatters.java | 6 ++++++ .../otm/capability/MatteryPlayerCapability.kt | 20 +++++++++++++++++-- .../mc/otm/compat/curios/CuriosCompat.kt | 7 +++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 748bb0dc1..517f12683 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -34,6 +34,7 @@ import ru.dbotthepony.mc.otm.client.render.ShockwaveRenderer; import ru.dbotthepony.mc.otm.client.render.blockentity.BatteryBankRenderer; import ru.dbotthepony.mc.otm.client.render.blockentity.MatterBatteryBankRenderer; import ru.dbotthepony.mc.otm.compat.adastra.AdAstraCompatKt; +import ru.dbotthepony.mc.otm.compat.curios.CuriosCompatKt; import ru.dbotthepony.mc.otm.compat.mekanism.QIOKt; import ru.dbotthepony.mc.otm.compat.mekanism.TooltipsKt; import ru.dbotthepony.mc.otm.config.AndroidConfig; @@ -53,6 +54,7 @@ import ru.dbotthepony.mc.otm.network.*; import ru.dbotthepony.mc.otm.registry.*; import ru.dbotthepony.mc.otm.storage.*; import ru.dbotthepony.mc.otm.triggers.KillAsAndroidTrigger; +import top.theillusivec4.curios.api.CuriosApi; import static net.minecraftforge.common.MinecraftForge.EVENT_BUS; @@ -199,6 +201,10 @@ public final class OverdriveThatMatters { EVENT_BUS.addGenericListener(BlockEntity.class, EventPriority.NORMAL, QIOKt::attachCapabilities); } + if (ModList.get().isLoaded(CuriosApi.MODID)) { + EVENT_BUS.addListener(EventPriority.NORMAL, CuriosCompatKt::onCuriosSlotModifiersUpdated); + } + if (AdAstraCompatKt.isAdAstraLoaded()) { EVENT_BUS.addListener(EventPriority.NORMAL, AdAstraCompatKt::onDamageEvent); EVENT_BUS.addListener(EventPriority.NORMAL, AdAstraCompatKt::onMatteryTick); diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 31e6b749f..b020e4021 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -230,6 +230,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial private var _exoPackMenu: ExoPackInventoryMenu? = null set(value) { if (field == ply.containerMenu) { ply.closeContainer() } + field?.removed(ply) field = value } @@ -245,6 +246,10 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial return _exoPackMenu!! } + fun recreateExoPackMenu() { + _exoPackMenu = ExoPackInventoryMenu(this) + } + private var shouldSendIteration = false /** @@ -1160,8 +1165,13 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } fun onPlayerChangeDimensionEvent(event: PlayerEvent.PlayerChangedDimensionEvent) { - event.entity.getCapability(MatteryCapability.MATTERY_PLAYER) - .ifPresentK { it.invalidateNetworkState() } + event.entity.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresentK { + it.invalidateNetworkState() + + onceServer(20) { + it.recreateExoPackMenu() + } + } } fun onPlayerDeath(event: LivingDeathEvent) { @@ -1215,6 +1225,12 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial it.deserializeNBT(original.serializeNBT()) it.invalidateNetworkState() event.original.invalidateCaps() + + if (SERVER_IS_LIVE) { + onceServer(20) { + it.recreateExoPackMenu() + } + } } const val SLEEP_TICKS_LIMIT = 80 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt index 1c8306127..342e21dc2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt @@ -6,12 +6,14 @@ import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack import net.minecraftforge.fml.ModList import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.container.awareStream import ru.dbotthepony.mc.otm.container.stream import ru.dbotthepony.mc.otm.core.collect.AwareItemStack import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.menu.PlayerSlot import top.theillusivec4.curios.api.CuriosApi +import top.theillusivec4.curios.api.event.SlotModifiersUpdatedEvent import top.theillusivec4.curios.common.inventory.CosmeticCurioSlot import top.theillusivec4.curios.common.inventory.CurioSlot import java.util.* @@ -21,6 +23,11 @@ val isCuriosLoaded by lazy { ModList.get().isLoaded(CuriosApi.MODID) } +fun onCuriosSlotModifiersUpdated(event: SlotModifiersUpdatedEvent) { + check(isCuriosLoaded) { "Curios is not loaded!" } + event.entity.matteryPlayer?.recreateExoPackMenu() +} + private fun Player.getCuriosSlotsImpl(): List> { val handler = getCapability(MatteryCapability.CURIOS_INVENTORY).orNull() ?: return listOf() From 833284db6f1f9fe5381ef069dc2d6c8691016e94 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 16 Mar 2023 21:44:04 +0700 Subject: [PATCH 0366/1199] Fix wrong translation strings involving exopack --- .../mc/otm/client/screen/ExoPackInventoryScreen.kt | 6 +++--- .../mc/otm/client/screen/panels/EntityRendererPanel.kt | 2 +- .../mc/otm/network/MatteryPlayerNetworkChannel.kt | 5 ++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt index 739edf842..c47c6e232 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt @@ -17,7 +17,7 @@ import ru.dbotthepony.mc.otm.client.setMousePos import ru.dbotthepony.mc.otm.client.shouldOpenVanillaInventory import ru.dbotthepony.mc.otm.core.math.integerDivisionDown import ru.dbotthepony.mc.otm.menu.ExoPackInventoryMenu -import ru.dbotthepony.mc.otm.network.ExoSuitMenuOpen +import ru.dbotthepony.mc.otm.network.ExoPackMenuOpen import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel import yalter.mousetweaks.api.MouseTweaksDisableWheelTweak @@ -157,7 +157,7 @@ class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen frame.y += movePixels @@ -179,7 +179,7 @@ class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen @JvmOverloads constructor( } ) - exosuitButton.tooltip = TranslatableComponent("otm.gui.exosuit.toggle_visibility") + exosuitButton.tooltip = TranslatableComponent("otm.gui.exopack.toggle_visibility") } else { exosuitButton = null } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt index 8445f9c01..8915ec7f1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt @@ -8,7 +8,6 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.Items import net.minecraftforge.network.NetworkDirection.PLAY_TO_CLIENT import net.minecraftforge.network.NetworkDirection.PLAY_TO_SERVER import net.minecraftforge.network.NetworkEvent @@ -334,7 +333,7 @@ class ExoSuitMenuInitPacket(val slots: List, val carried: ItemStack, } } -object ExoSuitMenuOpen : MatteryPacket { +object ExoPackMenuOpen : MatteryPacket { override fun write(buff: FriendlyByteBuf) {} override fun play(context: Supplier) { @@ -576,7 +575,7 @@ object MatteryPlayerNetworkChannel : MatteryNetworkChannel( add(ExoSuitSlotPacket::class, ExoSuitSlotPacket.Companion::read, PLAY_TO_CLIENT) add(ExoSuitMenuInitPacket::class, ExoSuitMenuInitPacket.Companion::read, PLAY_TO_CLIENT) - add(ExoSuitMenuOpen::class, { ExoSuitMenuOpen }, PLAY_TO_SERVER) + add(ExoPackMenuOpen::class, { ExoPackMenuOpen }, PLAY_TO_SERVER) add(SwitchAndroidFeaturePacket::class, SwitchAndroidFeaturePacket.Companion::read, PLAY_TO_SERVER) add(ActivateAndroidFeaturePacket::class, ActivateAndroidFeaturePacket.Companion::read, PLAY_TO_SERVER) From b7e58c09fffb66553ecde90ff7fd08d37055fb6d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 16 Mar 2023 21:45:07 +0700 Subject: [PATCH 0367/1199] Fix RectangleButtonPanel adding extra space when not required --- .../screen/panels/button/BooleanRectangleButtonPanel.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt index 9c5f2fbc7..2afbdf2fd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt @@ -44,10 +44,14 @@ abstract class BooleanRectangleButtonPanel( if (tooltipList != null) { tooltips.addAll(tooltipList) - tooltips.add(SPACE) + + if (tooltipActive != null || tooltipInactive != null) + tooltips.add(SPACE) } else if (tooltip != null) { tooltips.add(tooltip) - tooltips.add(SPACE) + + if (tooltipActive != null || tooltipInactive != null) + tooltips.add(SPACE) } if (tooltipActive != null) { From d9190efdf19ae7d72f48e7deb40e4947b0ecd657 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 16 Mar 2023 21:53:34 +0700 Subject: [PATCH 0368/1199] Micro optimization involving marking fields dirty in endpoints --- .../mc/otm/network/FieldSynchronizer.kt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt index 00a0d1dd8..3d4884440 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt @@ -4,6 +4,7 @@ import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream import it.unimi.dsi.fastutil.objects.Reference2ObjectFunction import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.ReferenceArraySet +import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.collect.ProxiedMap @@ -34,6 +35,7 @@ import java.lang.ref.WeakReference import java.math.BigDecimal import java.util.* import java.util.function.Supplier +import kotlin.collections.ArrayList import kotlin.properties.ReadOnlyProperty import kotlin.reflect.KMutableProperty0 import kotlin.reflect.KProperty @@ -452,7 +454,8 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } } - private val dirtyFields = ReferenceArraySet>(fields.size) + private val dirtyFields = ReferenceOpenHashSet>(fields.size) + private val dirtyFields2 = ArrayList>() // use LinkedList because it is ensured memory is freed on LinkedList#clear private val mapBacklogs = Reference2ObjectOpenHashMap, LinkedList Unit>>>() @@ -472,6 +475,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa unused = true mapBacklogs.clear() dirtyFields.clear() + dirtyFields2.clear() val iterator = endpoints.listIterator() @@ -497,11 +501,14 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return } - dirtyFields.add(field) + if (dirtyFields.add(field)) { + dirtyFields2.add(field) + } } internal fun removeDirtyField(field: AbstractField<*>) { dirtyFields.remove(field) + dirtyFields2.remove(field) } internal fun getMapBacklog(map: Map): LinkedList Unit>> { @@ -515,19 +522,20 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } fun collectNetworkPayload(): FastByteArrayOutputStream? { - if (unused || dirtyFields.isEmpty()) { + if (unused || dirtyFields2.isEmpty()) { return null } val stream = FastByteArrayOutputStream() val dataStream = DataOutputStream(stream) - for (field in dirtyFields) { + for (field in dirtyFields2) { stream.writeVarIntLE(field.id) field.write(dataStream, this) } dirtyFields.clear() + dirtyFields2.clear() stream.write(0) return stream From 8bcc169c62c9b12cc0d484379a6acdf3b03c73ce Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 16 Mar 2023 21:56:40 +0700 Subject: [PATCH 0369/1199] Micro optimize MatteryBlockEntity#getCapability --- .../mc/otm/block/entity/MatteryBlockEntity.kt | 27 ++++--------------- 1 file changed, 5 insertions(+), 22 deletions(-) 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 cc484d733..fd2b92b48 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 @@ -1,12 +1,12 @@ package ru.dbotthepony.mc.otm.block.entity import com.google.common.collect.ImmutableList -import com.google.common.collect.ImmutableSet import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import it.unimi.dsi.fastutil.longs.Long2ObjectFunction import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.ObjectArraySet import it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap +import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.core.BlockPos import net.minecraft.core.Direction @@ -18,7 +18,6 @@ import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerPlayer import net.minecraft.world.Container import net.minecraft.world.entity.player.Player -import net.minecraft.world.item.ItemStack import net.minecraft.world.level.ChunkPos import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block @@ -39,28 +38,19 @@ import net.minecraftforge.event.server.ServerStoppingEvent import net.minecraftforge.items.IItemHandler import ru.dbotthepony.mc.otm.SERVER_IS_LIVE import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock -import ru.dbotthepony.mc.otm.capability.CombinedItemHandler -import ru.dbotthepony.mc.otm.capability.EmptyItemHandler import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.capability.UnmodifiableItemHandler import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.isMekanismLoaded -import ru.dbotthepony.mc.otm.capability.moveBetweenSlots import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper import ru.dbotthepony.mc.otm.core.collect.SupplierList import ru.dbotthepony.mc.otm.core.collect.WeakHashSet import ru.dbotthepony.mc.otm.core.forValidRefs import ru.dbotthepony.mc.otm.core.get -import ru.dbotthepony.mc.otm.core.getValue -import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.immutableList -import ru.dbotthepony.mc.otm.core.immutableMap -import ru.dbotthepony.mc.otm.core.immutableSet import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.core.math.minus import ru.dbotthepony.mc.otm.core.math.plus -import ru.dbotthepony.mc.otm.core.util.ITickable import ru.dbotthepony.mc.otm.core.util.Savetables import ru.dbotthepony.mc.otm.core.util.TickList import ru.dbotthepony.mc.otm.network.BlockEntitySyncPacket @@ -70,9 +60,7 @@ import ru.dbotthepony.mc.otm.once import ru.dbotthepony.mc.otm.oncePre import ru.dbotthepony.mc.otm.onceServer import java.lang.ref.WeakReference -import java.util.Collections -import java.util.EnumMap -import java.util.WeakHashMap +import java.util.* import java.util.function.Supplier import kotlin.properties.ReadWriteProperty import kotlin.reflect.KProperty @@ -201,8 +189,8 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc _sides[side] = this } - private val caps = Reference2ObjectArrayMap, Cap<*>>() - private val subscriptions = Reference2ObjectArrayMap, SubRef<*>>() + private val caps = Reference2ObjectOpenHashMap, Cap<*>>() + private val subscriptions = Reference2ObjectOpenHashMap, SubRef<*>>() private val knownLOs = WeakHashSet>() private inner class SubRef(var value: LazyOptional) : Supplier> { @@ -389,12 +377,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc override fun getCapability(cap: Capability, side: Direction?): LazyOptional { if (side != null) { - val get = _sides[blockRotation.dir2Side(side)]!![cap] - - if (get != null) - return get.optional - - return super.getCapability(cap, side) + return _sides[blockRotation.dir2Side(side)]!![cap]?.optional ?: super.getCapability(cap, side) } return sidelessCaps[cap]?.optional?.cast() ?: super.getCapability(cap, side) From d0963c7fe937bf8ff37ca3f2a61bac1f4fb1fe6e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 16 Mar 2023 22:03:08 +0700 Subject: [PATCH 0370/1199] Ignore slotsChanged when removing exopack menu --- .../ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt index ee2b9525b..73ca8a4bb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt @@ -102,7 +102,12 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen } } + private var isRemoved = false + override fun slotsChanged(container: Container) { + if (isRemoved) + return // кому это интересно + super.slotsChanged(container) if (container == craftingGrid) { @@ -121,6 +126,7 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen throw RuntimeException("what.") } + isRemoved = true super.removed(player) craftingResultContainer.clearContent() From 4c4b07ea4e1114a43b1057a4025b9cc069216c72 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 16 Mar 2023 22:30:06 +0700 Subject: [PATCH 0371/1199] OTM singleplayer edition --- .../kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index fd97ccd81..662261ad6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -91,6 +91,7 @@ import ru.dbotthepony.mc.otm.core.util.readBinaryComponent import ru.dbotthepony.mc.otm.core.util.readCollection import ru.dbotthepony.mc.otm.core.util.writeBinaryComponent import ru.dbotthepony.mc.otm.core.util.writeCollection +import ru.dbotthepony.mc.otm.core.writeItemType import ru.dbotthepony.mc.otm.milliTime import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.RegistryNetworkChannel @@ -1676,7 +1677,7 @@ object MatterManager { data.writeInt(matterValues.size) for ((k, v) in matterValues) { - data.writeInt(ForgeRegistries.ITEMS.getID(k)) + data.writeItemType(k) data.writeMatterValue(v) val comment = commentary[k] @@ -1694,7 +1695,7 @@ object MatterManager { for ((k, v) in commentary) { if (!matterValues.containsKey(k)) { - data.writeInt(ForgeRegistries.ITEMS.getID(k)) + data.writeItemType(k) data.writeCollection(v, OutputStream::writeBinaryComponent) } } From 704225cd9f94ac453de4c4b000a53c2e6ed5b3b9 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 16 Mar 2023 22:48:15 +0700 Subject: [PATCH 0372/1199] Rebalance matter capacitors' capacity --- src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt index 1cac81e2b..af6bb77b0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt @@ -76,9 +76,9 @@ object ItemsConfig : AbstractConfig("items") { } object Capacitors { - val BASIC by builder.defineDecimal(MNames.MATTER_CAPACITOR_BASIC, Decimal(2_000), minimum = Decimal.ONE_TENTH) - val NORMAL by builder.defineDecimal(MNames.MATTER_CAPACITOR_NORMAL, Decimal(40_000), minimum = Decimal.ONE_TENTH) - val DENSE by builder.defineDecimal(MNames.MATTER_CAPACITOR_DENSE, Decimal(400_000), minimum = Decimal.ONE_TENTH) + val BASIC by builder.defineDecimal(MNames.MATTER_CAPACITOR_BASIC, Decimal(10_000), minimum = Decimal.ONE_TENTH) + val NORMAL by builder.defineDecimal(MNames.MATTER_CAPACITOR_NORMAL, Decimal(30_000), minimum = Decimal.ONE_TENTH) + val DENSE by builder.defineDecimal(MNames.MATTER_CAPACITOR_DENSE, Decimal(100_000), minimum = Decimal.ONE_TENTH) } init { From 6b2909fc1c670d2b791a51d4f635a7f68c3e66d8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 16 Mar 2023 23:18:30 +0700 Subject: [PATCH 0373/1199] Fix addMatterValue speculation being wrong with negative matter values --- src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt index 4a6a52d04..06b29621e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt @@ -61,7 +61,7 @@ class MatterDustItem : Item(Properties().stacksTo(64)), IMatterItem { val matterThis = matter(stack) - if (matterThis >= ItemsConfig.MATTER_DUST_CAPACITY) + if (matterThis >= ItemsConfig.MATTER_DUST_CAPACITY && matter.isPositive) return Decimal.ZERO val newMatter = (matterThis + matter).coerceAtMost(ItemsConfig.MATTER_DUST_CAPACITY) From bcd810a5aaaf5ce14fcd33c401f9899c916f45fc Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 16 Mar 2023 23:24:07 +0700 Subject: [PATCH 0374/1199] Rebalance matter capacity values once again --- .../otm/block/entity/matter/MatterDecomposerBlockEntity.kt | 2 +- .../mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt | 2 +- .../otm/block/entity/matter/MatterReplicatorBlockEntity.kt | 2 +- src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt | 6 +++--- .../kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt | 1 - 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index f166e6842..b9f889f36 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -246,7 +246,7 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) ENERGY_VALUES = BlockEnergyStorageImpl.makeConfigEntry(builder, capacity = Decimal(400_000), throughput = Decimal(2_000)) - _CAPACITY = builder.defineDecimal("matterCapacity", Decimal(20_000), Decimal.ONE_TENTH) + _CAPACITY = builder.defineDecimal("matterCapacity", Decimal(500), Decimal.ONE_TENTH) _BASE_CONSUMPTION = builder.defineDecimal("baseConsumption", Decimal(240), Decimal.ONE) builder.pop() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index db1279f35..432ba23e8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -180,7 +180,7 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) ENERGY_CONFIG = BlockEnergyStorageImpl.makeConfigEntry(builder, capacity = Decimal(80_000)) - _CAPACITY = builder.defineDecimal("matterCapacity", Decimal(2_000), Decimal.ONE) + _CAPACITY = builder.defineDecimal("matterCapacity", Decimal(500), Decimal.ONE) _POWER_CONSUMPTION = builder.defineDecimal("powerConsumption", Decimal(80), Decimal.ONE) _TICKS_PER_MATTER = builder.define("ticksPerMatter", 2.0) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index 933bfdb14..1adca7549 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -282,7 +282,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : _BASE_CONSUMPTION = builder.defineDecimal("basePowerConsumption", Decimal(400), Decimal.ONE) _DRAIN_MULT = builder.comment("How much 'ticks' of replication should replicator drain matter from network when running low on internal matter buffer. This is ultimately a performance value.").defineDecimal("drainMultiplier", Decimal(200), Decimal.ONE) - _MATTER_CAPACITY = builder.defineDecimal("matterCapacity", Decimal(400), Decimal.ONE_TENTH) + _MATTER_CAPACITY = builder.defineDecimal("matterCapacity", Decimal(1_000), Decimal.ONE_TENTH) builder.pop() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt index af6bb77b0..53d52e7ff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt @@ -76,9 +76,9 @@ object ItemsConfig : AbstractConfig("items") { } object Capacitors { - val BASIC by builder.defineDecimal(MNames.MATTER_CAPACITOR_BASIC, Decimal(10_000), minimum = Decimal.ONE_TENTH) - val NORMAL by builder.defineDecimal(MNames.MATTER_CAPACITOR_NORMAL, Decimal(30_000), minimum = Decimal.ONE_TENTH) - val DENSE by builder.defineDecimal(MNames.MATTER_CAPACITOR_DENSE, Decimal(100_000), minimum = Decimal.ONE_TENTH) + val BASIC by builder.defineDecimal(MNames.MATTER_CAPACITOR_BASIC, Decimal(2_500), minimum = Decimal.ONE_TENTH) + val NORMAL by builder.defineDecimal(MNames.MATTER_CAPACITOR_NORMAL, Decimal(10_000), minimum = Decimal.ONE_TENTH) + val DENSE by builder.defineDecimal(MNames.MATTER_CAPACITOR_DENSE, Decimal(25_000), minimum = Decimal.ONE_TENTH) } init { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt index 9e8ef569f..c80357cd2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt @@ -22,7 +22,6 @@ object MachinesConfig : AbstractConfig("machines") { MatterDecomposerBlockEntity.registerConfig(builder) } - val PLATE_PRESS = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.PLATE_PRESS) val STORAGE_POWER_SUPPLIER = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.STORAGE_POWER_SUPPLIER, capacity = Decimal(100_000), throughput = Decimal(320)) val STORAGE_INTERFACES = BlockEnergyStorageImpl.makeConfigEntry(builder, "STORAGE_INTERFACES", capacity = Decimal(10_000)) From 5f95f9e75a4dc78d0ffa0598594077fc32e2ff47 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 16 Mar 2023 23:26:55 +0700 Subject: [PATCH 0375/1199] One more wrong exopack locale id --- .../kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt index 17138d59a..cddf388fb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt @@ -98,7 +98,7 @@ private fun inventoryLogic(event: ScreenEvent.Init.Post) { minecraft.setScreen(ExoPackInventoryScreen(player.exoPackMenu)) InputConstants.grabOrReleaseMouse(minecraft.window.window, 212993, mouseX, mouseY) - }).also { it.tooltip = TranslatableComponent("otm.gui.exosuit.go_in") }) + }).also { it.tooltip = TranslatableComponent("otm.gui.exopack.go_in") }) event.addListener(widget) From 13f140ac31d7426707b3fdc7b4e5c3d34ab279fd Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 16 Mar 2023 23:36:23 +0700 Subject: [PATCH 0376/1199] Disable "store xp" buttons when player has no xp --- .../ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt index c3b8a6bf3..5a0b03b24 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt @@ -80,6 +80,10 @@ class EssenceStorageMenu @JvmOverloads constructor( it.isCreative || it.matteryPlayer?.isAndroid == true || servoSlot.item.item == MItems.ESSENCE_SERVO //|| it.itemsStream(true).anyMatch { it.item == MItems.ESSENCE_SERVO } } + storeLevels.filter { + it.experienceProgress > 0f || it.experienceLevel > 0 + } + dispenseLevels.filter { it.isCreative || it.matteryPlayer?.isAndroid == true || servoSlot.item.item == MItems.ESSENCE_SERVO //|| it.itemsStream(true).anyMatch { it.item == MItems.ESSENCE_SERVO } } From a289d9d1c1986d1733965080056bf5bfd579d6dc Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 17 Mar 2023 14:08:27 +0700 Subject: [PATCH 0377/1199] Add actuallyRemoved method to exopack menu --- .../mc/otm/capability/MatteryPlayerCapability.kt | 2 +- .../ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index b020e4021..42c20b78d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -230,7 +230,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial private var _exoPackMenu: ExoPackInventoryMenu? = null set(value) { if (field == ply.containerMenu) { ply.closeContainer() } - field?.removed(ply) + field?.actuallyRemoved() field = value } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt index 73ca8a4bb..9c70413a4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt @@ -121,12 +121,16 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen } } + fun actuallyRemoved() { + isRemoved = true + removed(capability.ply) + } + override fun removed(player: Player) { if (player != capability.ply) { throw RuntimeException("what.") } - isRemoved = true super.removed(player) craftingResultContainer.clearContent() From 8511c2c01bc0c18a772ca2dc8743bfef55c79ac6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 17 Mar 2023 14:32:22 +0700 Subject: [PATCH 0378/1199] Merge TimerQueue into TickList --- .../dbotthepony/mc/otm/GlobalEventHandler.kt | 16 +- .../mc/otm/client/ClientTickHandler.kt | 14 +- .../dbotthepony/mc/otm/core/util/TickList.kt | 197 +++++++++++++----- .../mc/otm/core/util/TimerQueue.kt | 85 -------- .../mc/otm/tests/TimerQueueTests.kt | 4 +- 5 files changed, 151 insertions(+), 165 deletions(-) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TimerQueue.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt index 4803fafc4..0130a93d4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt @@ -19,7 +19,6 @@ import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.util.IConditionalTickable import ru.dbotthepony.mc.otm.core.util.ITickable import ru.dbotthepony.mc.otm.core.util.TickList -import ru.dbotthepony.mc.otm.core.util.TimerQueue import java.util.* private val preServerTick = TickList() @@ -27,25 +26,22 @@ private val postServerTick = TickList() private val preWorldTick = WeakHashMap() private val postWorldTick = WeakHashMap() -private val preServerTickTimers = TimerQueue() -private val postServerTickTimers = TimerQueue() - -fun onceServerPre(inTicks: Int, callback: Runnable): TimerQueue.Timer? { +fun onceServerPre(inTicks: Int, callback: Runnable): TickList.Timer? { if (!SERVER_IS_LIVE) { LOGGER.error("Refusing to add timer $callback in ticks $inTicks while server is dying", IllegalStateException("Server is stopping")) return null } - return preServerTickTimers.Timer(inTicks, callback) + return preServerTick.Timer(inTicks, callback) } -fun onceServer(inTicks: Int, callback: Runnable): TimerQueue.Timer? { +fun onceServer(inTicks: Int, callback: Runnable): TickList.Timer? { if (!SERVER_IS_LIVE) { LOGGER.error("Refusing to add ticker $callback in ticks $inTicks while server is dying", IllegalStateException("Server is stopping")) return null } - return postServerTickTimers.Timer(inTicks, callback) + return postServerTick.Timer(inTicks, callback) } private var _server: MinecraftServer? = null @@ -146,10 +142,8 @@ private val LOGGER = LogManager.getLogger() fun onServerTick(event: ServerTickEvent) { if (event.phase === TickEvent.Phase.START) { - preServerTickTimers.tick() preServerTick.tick() } else { - postServerTickTimers.tick() postServerTick.tick() } } @@ -259,8 +253,6 @@ fun Level.whilePre(condition: () -> Boolean, ticker: () -> Unit) { } private fun clear() { - preServerTickTimers.clear() - postServerTickTimers.clear() preServerTick.clear() postServerTick.clear() preWorldTick.clear() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientTickHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientTickHandler.kt index 4f5473b31..0d812203e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientTickHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientTickHandler.kt @@ -5,13 +5,11 @@ import net.minecraftforge.event.TickEvent import ru.dbotthepony.mc.otm.core.util.IConditionalTickable import ru.dbotthepony.mc.otm.core.util.ITickable import ru.dbotthepony.mc.otm.core.util.TickList -import ru.dbotthepony.mc.otm.core.util.TimerQueue import ru.dbotthepony.mc.otm.isClient private val preTickList = TickList() private val postTickList = TickList() -private val preTimerList = TimerQueue() -private val postTimerList = TimerQueue() + var LOGGED_IN = false private set @@ -27,12 +25,12 @@ fun onceClientPre(ticker: ITickable) { fun onceClient(inTicks: Int, ticker: Runnable) { check(isClient) { "Illegal side" } - postTimerList.add(inTicks, ticker, LOGGED_IN, "Not logged in") + postTickList.timer(inTicks, ticker, LOGGED_IN, "Not logged in") } fun onceClientPre(inTicks: Int, ticker: Runnable) { check(isClient) { "Illegal side" } - preTimerList.add(inTicks, ticker, LOGGED_IN, "Not logged in") + preTickList.timer(inTicks, ticker, LOGGED_IN, "Not logged in") } fun tickClient(ticker: IConditionalTickable) { @@ -63,10 +61,8 @@ fun tickWhileClientPre(condition: () -> Boolean, ticker: () -> Unit) { fun onClientTick(event: TickEvent.ClientTickEvent) { if (event.phase == TickEvent.Phase.START) { - preTimerList.tick() preTickList.tick() } else { - postTimerList.tick() postTickList.tick() } } @@ -74,17 +70,13 @@ fun onClientTick(event: TickEvent.ClientTickEvent) { fun onClientDisconnected(event: ClientPlayerNetworkEvent.LoggingOut) { LOGGED_IN = false - preTimerList.clear() preTickList.clear() - postTimerList.clear() postTickList.clear() } fun onClientConnected(event: ClientPlayerNetworkEvent.LoggingIn) { LOGGED_IN = true - preTimerList.clear() preTickList.clear() - postTimerList.clear() postTickList.clear() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt index f7404d92d..703e349e8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt @@ -2,16 +2,66 @@ package ru.dbotthepony.mc.otm.core.util import org.apache.logging.log4j.LogManager -class TickList { +class TickList : ITickable { private val conditional = ArrayDeque() + private val conditionalValveTime = ArrayList() + private val once = ArrayDeque() + private val onceValveTime = ArrayList() + private val always = ArrayList() private val alwaysValveTime = ArrayList() - private val conditionalValveTime = ArrayList() - private val onceValveTime = ArrayList() + private val timers = ArrayDeque() - private var inTicker = false + var inTicker = false + private set + var ticks = 0 + private set + + inner class Timer(val timerTicks: Int, val runnable: Runnable) { + val ringAt = ticks + timerTicks + + var finished = false + private set + + init { + if (timers.isEmpty()) { + timers.addLast(this) + } else { + val iterator = timers.listIterator() + var hit = false + + for (value in iterator) { + if (value.ringAt == ringAt) { + hit = true + iterator.add(this) + break + } else if (value.ringAt > ringAt) { + if (iterator.hasPrevious()) { + iterator.previous() + iterator.add(this) + } else { + timers.addFirst(this) + } + + hit = true + break + } + } + + if (!hit) { + timers.addLast(this) + } + } + } + + fun execute() { + if (finished) return + runnable.run() + finished = true + } + } fun add(ticker: IConditionalTickable) { if (inTicker) { @@ -21,22 +71,6 @@ class TickList { } } - fun once(ticker: ITickable) { - if (inTicker) { - onceValveTime.add(ticker) - } else { - once.addFirst(ticker) - } - } - - fun always(ticker: ITickable) { - if (inTicker) { - alwaysValveTime.add(ticker) - } else { - always.add(ticker) - } - } - fun add(ticker: IConditionalTickable, condition: Boolean, reason: String) { if (!condition) { LOGGER.error("Refusing to add tickable $ticker because we $reason", IllegalStateException(reason)) @@ -46,6 +80,14 @@ class TickList { return add(ticker) } + fun once(ticker: ITickable) { + if (inTicker) { + onceValveTime.add(ticker) + } else { + once.addFirst(ticker) + } + } + fun once(ticker: ITickable, condition: Boolean, reason: String) { if (!condition) { LOGGER.error("Refusing to add tickable $ticker because we $reason", IllegalStateException(reason)) @@ -55,6 +97,27 @@ class TickList { return once(ticker) } + fun always(ticker: ITickable) { + if (inTicker) { + alwaysValveTime.add(ticker) + } else { + always.add(ticker) + } + } + + fun timer(timerTicks: Int, action: Runnable, condition: Boolean, reason: String): Timer? { + if (!condition) { + LOGGER.error("Refusing to add timer $action in $timerTicks ticks because we $reason", IllegalStateException(reason)) + return null + } + + return Timer(timerTicks, action) + } + + fun timer(timerTicks: Int, action: Runnable): Timer { + return Timer(timerTicks, action) + } + fun until(ticker: () -> Boolean) = add(IConditionalTickable.wrap(ticker)) fun `while`(tickerCondition: () -> Boolean, ticker: () -> Unit) = add( IConditionalTickable.wrap( @@ -67,66 +130,90 @@ class TickList { fun `while`(tickerCondition: () -> Boolean, ticker: () -> Unit, condition: Boolean, reason: String) = add( IConditionalTickable.wrap(tickerCondition, ticker), condition, reason) - fun tick() { + override fun tick() { if (inTicker) { throw ConcurrentModificationException("Already ticking") } + ticks++ inTicker = true - if (conditional.isNotEmpty()) { - val iterator = conditional.iterator() + try { + if (conditional.isNotEmpty()) { + val iterator = conditional.iterator() - for (ticker in iterator) { - if (!ticker.canTick) { - iterator.remove() - } else { + for (ticker in iterator) { + if (!ticker.canTick) { + iterator.remove() + } else { + ticker.tick() + } + } + } + + if (once.isNotEmpty()) { + for (ticker in once) { + ticker.tick() + } + + once.clear() + } + + if (always.isNotEmpty()) { + for (ticker in always) { ticker.tick() } } - } - if (once.isNotEmpty()) { - for (ticker in once) { - ticker.tick() + if (alwaysValveTime.isNotEmpty()) { + always.addAll(alwaysValveTime) + alwaysValveTime.clear() } - once.clear() - } + if (conditionalValveTime.isNotEmpty()) { + for (ticker in conditionalValveTime) { + conditional.addFirst(ticker) + } - if (always.isNotEmpty()) { - for (ticker in always) { - ticker.tick() - } - } - - if (alwaysValveTime.isNotEmpty()) { - always.addAll(alwaysValveTime) - alwaysValveTime.clear() - } - - if (conditionalValveTime.isNotEmpty()) { - for (ticker in conditionalValveTime) { - conditional.addFirst(ticker) + conditionalValveTime.clear() } - conditionalValveTime.clear() - } + if (onceValveTime.isNotEmpty()) { + for (ticker in onceValveTime) { + once.addFirst(ticker) + } - if (onceValveTime.isNotEmpty()) { - for (ticker in onceValveTime) { - once.addFirst(ticker) + onceValveTime.clear() } - onceValveTime.clear() - } + while (timers.isNotEmpty()) { + val head = timers.first() - inTicker = false + if (head.ringAt <= ticks) { + head.execute() + timers.removeFirst() + } else { + break + } + } + } finally { + inTicker = false + } } fun clear() { + if (inTicker) throw ConcurrentModificationException() + conditional.clear() + conditionalValveTime.clear() + once.clear() + onceValveTime.clear() + + always.clear() + alwaysValveTime.clear() + + timers.clear() } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TimerQueue.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TimerQueue.kt deleted file mode 100644 index 2ecbc87eb..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TimerQueue.kt +++ /dev/null @@ -1,85 +0,0 @@ -package ru.dbotthepony.mc.otm.core.util - -import org.apache.logging.log4j.LogManager - -class TimerQueue { - private var ticks = 0 - private val list = ArrayDeque() - - inner class Timer(val timerTicks: Int, val runnable: Runnable) { - val ringAt = ticks + timerTicks - - var finished = false - private set - - init { - if (list.isEmpty()) { - list.addLast(this) - } else { - val iterator = list.listIterator() - var hit = false - - for (value in iterator) { - if (value.ringAt == ringAt) { - hit = true - iterator.add(this) - break - } else if (value.ringAt > ringAt) { - if (iterator.hasPrevious()) { - iterator.previous() - iterator.add(this) - } else { - list.addFirst(this) - } - - hit = true - break - } - } - - if (!hit) { - list.addLast(this) - } - } - } - - fun execute() { - if (finished) return - runnable.run() - finished = true - } - } - - fun add(timerTicks: Int, ticker: Runnable, condition: Boolean, reason: String): Timer? { - if (!condition) { - LOGGER.error("Refusing to add timer $ticker in $timerTicks ticks because we $reason", IllegalStateException(reason)) - return null - } - - return Timer(timerTicks, ticker) - } - - fun tick() { - ticks++ - - while (list.isNotEmpty()) { - val head = list.first() - - if (head.ringAt <= ticks) { - head.execute() - list.removeFirst() - } else { - break - } - } - } - - fun clear() { - ticks = 0 - list.clear() - } - - companion object { - private val LOGGER = LogManager.getLogger() - } -} diff --git a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/TimerQueueTests.kt b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/TimerQueueTests.kt index efd9f31be..d38e66af7 100644 --- a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/TimerQueueTests.kt +++ b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/TimerQueueTests.kt @@ -3,13 +3,13 @@ package ru.dbotthepony.mc.otm.tests import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test -import ru.dbotthepony.mc.otm.core.util.TimerQueue +import ru.dbotthepony.mc.otm.core.util.TickList object TimerQueueTests { @Test @DisplayName("TimerQueue test") fun test() { - val queue = TimerQueue() + val queue = TickList() var state = 0 From bc99bc0c4145ea642ee26a62091d605fa90f20b5 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 17 Mar 2023 14:35:58 +0700 Subject: [PATCH 0379/1199] Add TickList to mattery player capability --- .../otm/capability/MatteryPlayerCapability.kt | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 42c20b78d..d1e1ebd3b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -64,6 +64,7 @@ import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.IntValueCodec import ru.dbotthepony.mc.otm.core.util.ItemValueCodec import ru.dbotthepony.mc.otm.core.util.Savetables +import ru.dbotthepony.mc.otm.core.util.TickList import ru.dbotthepony.mc.otm.core.util.UUIDValueCodec import ru.dbotthepony.mc.otm.menu.ExoPackInventoryMenu import ru.dbotthepony.mc.otm.network.* @@ -166,6 +167,11 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial */ var displayExoPack by publicSynchronizer.bool(true) + /** + * Tick event schedulers + */ + val tickList = TickList() + private val exoPackSlotModifierMap: MutableMap by synchronizer.Map( keyCodec = UUIDValueCodec, valueCodec = IntValueCodec, @@ -351,6 +357,10 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial for (i in 0 until exoPackMenu.slots.size) { exoPackMenu.setRemoteSlotNoCopy(i, ItemStack.EMPTY) } + + tickList.timer(20) { + recreateExoPackMenu() + } } /** @@ -731,7 +741,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial this.research[research] = instance if (instance.isResearched && ply is ServerPlayer) { - onceServer(20) { + tickList.timer(20) { if (!ply.hasDisconnected()) AndroidResearchTrigger.trigger(ply, instance.type) } @@ -740,7 +750,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } if (isAndroid && ply is ServerPlayer) { - onceServer(20) { + tickList.timer(20) { if (!ply.hasDisconnected()) BecomeAndroidTrigger.trigger(ply) } @@ -1167,10 +1177,6 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial fun onPlayerChangeDimensionEvent(event: PlayerEvent.PlayerChangedDimensionEvent) { event.entity.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresentK { it.invalidateNetworkState() - - onceServer(20) { - it.recreateExoPackMenu() - } } } @@ -1227,7 +1233,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial event.original.invalidateCaps() if (SERVER_IS_LIVE) { - onceServer(20) { + it.tickList.timer(20) { it.recreateExoPackMenu() } } From f3b824b484b5965404155f5bcb5239ef1f4ca1da Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 17 Mar 2023 15:20:15 +0700 Subject: [PATCH 0380/1199] Use tick list for adding "tick once" stuff --- .../mc/otm/block/entity/MatteryBlockEntity.kt | 32 ++----------- .../entity/storage/DriveViewerBlockEntity.kt | 48 +++++++++++-------- .../entity/storage/StorageBusBlockEntity.kt | 2 +- 3 files changed, 33 insertions(+), 49 deletions(-) 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 fd2b92b48..1e8dd0ef1 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 @@ -7,7 +7,6 @@ import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.ObjectArraySet import it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap -import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.core.BlockPos import net.minecraft.core.Direction import net.minecraft.core.SectionPos @@ -57,7 +56,6 @@ import ru.dbotthepony.mc.otm.network.BlockEntitySyncPacket import ru.dbotthepony.mc.otm.network.FieldSynchronizer import ru.dbotthepony.mc.otm.network.WorldNetworkChannel import ru.dbotthepony.mc.otm.once -import ru.dbotthepony.mc.otm.oncePre import ru.dbotthepony.mc.otm.onceServer import java.lang.ref.WeakReference import java.util.* @@ -435,31 +433,11 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc _sides[blockRotation.dir2Side(dir)]!!.updateTracked() } - protected fun tickOnce(func: Runnable) { - level?.oncePre { if (!isRemoved) func.run() } - } - - protected fun tickOnceServer(func: Runnable) { - (level as? ServerLevel)?.oncePre { if (!isRemoved) func.run() } - } - - protected fun tickOnceClient(func: Runnable) { - (level as? ClientLevel)?.oncePre { if (!isRemoved) func.run() } - } - - protected fun tickOnce(func: (Level) -> Unit) { + protected fun onceServer(action: (ServerLevel) -> Unit) { val level = level - level?.oncePre { if (!isRemoved) func.invoke(level) } - } - - protected fun tickOnceServer(func: (ServerLevel) -> Unit) { - val level = level as? ServerLevel ?: return - level.oncePre { if (!isRemoved) func.invoke(level) } - } - - protected fun tickOnceClient(func: (ClientLevel) -> Unit) { - val level = level as? ClientLevel ?: return - level.oncePre { if (!isRemoved) func.invoke(level) } + if (level is ServerLevel) { + tickList.once { action.invoke(level) } + } } // Just to mark chunk unsaved @@ -477,7 +455,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc return@FieldSynchronizer if (!isRemoved && level?.isClientSide == false && (_subCache == null || (_subCache ?: throw ConcurrentModificationException()).players.isNotEmpty())) { - onceServer { + ru.dbotthepony.mc.otm.onceServer { synchronizeToPlayers(true) } } else { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt index 9e8f3b45c..d442b950c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.block.entity.storage import net.minecraft.core.BlockPos +import net.minecraft.server.level.ServerLevel import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu @@ -22,19 +23,21 @@ class DriveViewerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte override fun setChanged() { super.setChanged() - tickOnceServer { - var state = blockState + val level = level + if (level is ServerLevel) + tickList.once { + var state = blockState - if (container.getItem(0).getCapability(MatteryCapability.DRIVE).isPresent && energy.batteryLevel >= OverdriveThatMatters.INSTANCE.ITEM_STORAGE().energyPerOperation) { - state = state.setValue(WorkerState.SEMI_WORKER_STATE, WorkerState.WORKING) - } else { - state = state.setValue(WorkerState.SEMI_WORKER_STATE, WorkerState.IDLE) - } + if (container.getItem(0).getCapability(MatteryCapability.DRIVE).isPresent && energy.batteryLevel >= OverdriveThatMatters.INSTANCE.ITEM_STORAGE().energyPerOperation) { + state = state.setValue(WorkerState.SEMI_WORKER_STATE, WorkerState.WORKING) + } else { + state = state.setValue(WorkerState.SEMI_WORKER_STATE, WorkerState.IDLE) + } - if (state !== blockState) { - it.setBlock(blockPos, state, Block.UPDATE_CLIENTS) + if (state !== blockState) { + level.setBlock(blockPos, state, Block.UPDATE_CLIENTS) + } } - } } val energy = WorkerEnergyStorage(this, MachinesConfig.DRIVE_VIEWER) @@ -43,21 +46,24 @@ class DriveViewerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { super.setChanged(slot, new, old) - tickOnceServer { - if (!isRemoved) { - var state = blockState + val level = level - if (new.getCapability(MatteryCapability.DRIVE).isPresent) { - state = state.setValue(DriveViewerBlock.DRIVE_PRESENT, true) - } else { - state = state.setValue(DriveViewerBlock.DRIVE_PRESENT, false) - } + if (level is ServerLevel) + tickList.once { + if (!isRemoved) { + var state = blockState - if (state !== blockState) { - it.setBlock(blockPos, state, Block.UPDATE_CLIENTS) + if (new.getCapability(MatteryCapability.DRIVE).isPresent) { + state = state.setValue(DriveViewerBlock.DRIVE_PRESENT, true) + } else { + state = state.setValue(DriveViewerBlock.DRIVE_PRESENT, false) + } + + if (state !== blockState) { + level.setBlock(blockPos, state, Block.UPDATE_CLIENTS) + } } } - } } }.also(::addDroppableContainer) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt index af2a6edbe..c11ce88fa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt @@ -114,7 +114,7 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter StorageNetworkGraph.discoverFull(this, cell.storageNode) } - tickOnceServer(this::checkSurroundings) + tickList.once(this::checkSurroundings) } private var neighbour: LazyOptional? = null From dfb0f5d3f3a66f6327c17f44e3f468493cf1e0d3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 17 Mar 2023 17:25:43 +0700 Subject: [PATCH 0381/1199] Fix default text align being wrong, fix shadow not being aligned --- .../mc/otm/client/screen/panels/Label.kt | 20 ++++++++++++++----- .../screen/tech/AndroidStationScreen.kt | 2 ++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt index 16cf68597..056cb7d36 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt @@ -29,25 +29,35 @@ open class Label @JvmOverloads constructor( } var color = RGBAColor.SLATE_GRAY - var align = TextAlign.TOP_RIGHT + var align = TextAlign.TOP_LEFT override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { clearDepth(stack) if (shadow) { - font.draw(stack, text, shadowX, shadowY, shadowColor.toInt()) + when (align) { + TextAlign.TOP_LEFT -> font.drawAligned(stack, text, align, shadowX, shadowY, shadowColor.toInt()) + TextAlign.TOP_CENTER -> font.drawAligned(stack, text, align, shadowX + width / 2f, shadowY, shadowColor.toInt()) + TextAlign.TOP_RIGHT -> font.drawAligned(stack, text, align, shadowX + width, shadowY, shadowColor.toInt()) + TextAlign.CENTER_LEFT -> font.drawAligned(stack, text, align, shadowX, height / 2f + shadowY, shadowColor.toInt()) + TextAlign.CENTER_CENTER -> font.drawAligned(stack, text, align, shadowX + width / 2f, height / 2f + shadowY, shadowColor.toInt()) + TextAlign.CENTER_RIGHT -> font.drawAligned(stack, text, align, shadowX + width, height / 2f + shadowY, shadowColor.toInt()) + TextAlign.BOTTOM_LEFT -> font.drawAligned(stack, text, align, shadowX, height + shadowY, shadowColor.toInt()) + TextAlign.BOTTOM_CENTER -> font.drawAligned(stack, text, align, shadowX + width / 2f, height + shadowY, shadowColor.toInt()) + TextAlign.BOTTOM_RIGHT -> font.drawAligned(stack, text, align, shadowX + width, height + shadowY, shadowColor.toInt()) + } } when (align) { TextAlign.TOP_LEFT -> font.drawAligned(stack, text, align, 0f, 0f, color.toInt()) TextAlign.TOP_CENTER -> font.drawAligned(stack, text, align, width / 2f, 0f, color.toInt()) - TextAlign.TOP_RIGHT -> font.drawAligned(stack, text, align, width, 0f, color.toInt()) + TextAlign.TOP_RIGHT -> font.drawAligned(stack, text, align, width - (if (shadow) shadowX else 0f), 0f, color.toInt()) TextAlign.CENTER_LEFT -> font.drawAligned(stack, text, align, 0f, height / 2f, color.toInt()) TextAlign.CENTER_CENTER -> font.drawAligned(stack, text, align, width / 2f, height / 2f, color.toInt()) - TextAlign.CENTER_RIGHT -> font.drawAligned(stack, text, align, width, height / 2f, color.toInt()) + TextAlign.CENTER_RIGHT -> font.drawAligned(stack, text, align, width - (if (shadow) shadowX else 0f), height / 2f, color.toInt()) TextAlign.BOTTOM_LEFT -> font.drawAligned(stack, text, align, 0f, height, color.toInt()) TextAlign.BOTTOM_CENTER -> font.drawAligned(stack, text, align, width / 2f, height, color.toInt()) - TextAlign.BOTTOM_RIGHT -> font.drawAligned(stack, text, align, width, height, color.toInt()) + TextAlign.BOTTOM_RIGHT -> font.drawAligned(stack, text, align, width - (if (shadow) shadowX else 0f), height, color.toInt()) } } 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 2644c3204..349007b01 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 @@ -21,6 +21,7 @@ import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.playGuiClickSound +import ru.dbotthepony.mc.otm.client.render.TextAlign import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.render.drawColor import ru.dbotthepony.mc.otm.client.render.drawLine @@ -675,6 +676,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I init { dock = Dock.BOTTOM dockTop = 2f + align = TextAlign.TOP_RIGHT } override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { From f5b55f3ab17cc14644c95a9bb9aeb76ba83a590e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 17 Mar 2023 18:18:55 +0700 Subject: [PATCH 0382/1199] oh my god --- .../dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index d1e1ebd3b..b8068c354 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -1020,7 +1020,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial stack.count = 0 } - return !stack.isEmpty + return stack.isEmpty } // двигаем в существующие слоты @@ -1099,7 +1099,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial stack.count = 0 } - return !stack.isEmpty + return stack.isEmpty } @Suppress("unused") From 4c97c99ee67e7784bdc665d159605a3fcbc60852 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 17 Mar 2023 19:00:16 +0700 Subject: [PATCH 0383/1199] Format as readable research tooltips --- .../mc/otm/android/feature/EnderTeleporterFeature.kt | 3 ++- .../ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt | 3 ++- .../ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt | 3 ++- .../ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt index a03bc1074..437045998 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt @@ -31,6 +31,7 @@ import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.client.render.sprite @@ -400,7 +401,7 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv AndroidResearchManager.descriptionFunc( ResourceLocation(OverdriveThatMatters.MOD_ID, MNames.ENDER_TELEPORTER), "otm.gui.power_cost_per_use", - { AndroidConfig.EnderTeleporter.ENERGY_COST.formatPower().copy().withStyle(ChatFormatting.YELLOW) }) + { AndroidConfig.EnderTeleporter.ENERGY_COST.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.YELLOW) }) fun onEntityDeath(event: LivingDeathEvent) { val android = event.entity.matteryPlayer ?: return diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt index 6542e1513..0d32d25b3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt @@ -14,6 +14,7 @@ import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact +import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.core.math.Vector @@ -136,6 +137,6 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable AndroidResearchManager.descriptionFunc(ResourceLocation( OverdriveThatMatters.MOD_ID, MNames.ITEM_MAGNET), "otm.gui.power_cost_per_tick", - { AndroidConfig.Magnet.POWER_DRAW.formatPower().copy().withStyle(ChatFormatting.YELLOW) }) + { AndroidConfig.Magnet.POWER_DRAW.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.YELLOW) }) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt index 29db42b6d..b8b727dca 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt @@ -16,6 +16,7 @@ import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.util.formatPower @@ -130,6 +131,6 @@ class JumpBoostFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF AndroidResearchManager.descriptionFunc( ResourceLocation(OverdriveThatMatters.MOD_ID, MNames.JUMP_BOOST), "otm.gui.power_cost_per_use", - { AndroidConfig.JumpBoost.ENERGY_COST.formatPower().copy().withStyle(ChatFormatting.YELLOW) }) + { AndroidConfig.JumpBoost.ENERGY_COST.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.YELLOW) }) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt index 7ac93da7c..70b6605e9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt @@ -31,6 +31,7 @@ import ru.dbotthepony.mc.otm.core.math.roundToIntVector import ru.dbotthepony.mc.otm.core.math.times import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.ShockwaveEffectPacket import ru.dbotthepony.mc.otm.network.enqueueWork @@ -253,6 +254,6 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF AndroidResearchManager.descriptionFunc( ResourceLocation(OverdriveThatMatters.MOD_ID, MNames.SHOCKWAVE), "otm.gui.power_cost_per_use", - { AndroidConfig.Shockwave.ENERGY_COST.formatPower().copy().withStyle(ChatFormatting.YELLOW) }) + { AndroidConfig.Shockwave.ENERGY_COST.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.YELLOW) }) } } From 5b5c4de9f7bfd8952a2040f2bbb21a2ad7597b36 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 17 Mar 2023 22:48:48 +0700 Subject: [PATCH 0384/1199] Fix energy counter setting ioLimit to not null when it is missing from nbt tag --- .../mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt index 3819c32bb..189ac1b99 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt @@ -21,6 +21,7 @@ import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.getDecimal import ru.dbotthepony.mc.otm.core.nbt.getByteArrayList import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.nbt.mapPresent import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.menu.tech.EnergyCounterMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -98,7 +99,7 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat super.load(nbt) passed = nbt.getDecimal(PASSED_ENERGY_KEY) - ioLimit = nbt.map(IO_LIMIT_KEY, Decimal.Companion::deserializeNBT) + ioLimit = nbt.mapPresent(IO_LIMIT_KEY, Decimal.Companion::deserializeNBT) nbt.map(POWER_HISTORY_POINTER_KEY) { it: IntTag -> historyTick = it.asInt From 1e68baea9dce643f35874cccfa7d580b6a45db5b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 17 Mar 2023 23:08:33 +0700 Subject: [PATCH 0385/1199] Revert using open hash set in dirtyFields --- .../mc/otm/network/FieldSynchronizer.kt | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt index 3d4884440..be238eedf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt @@ -454,8 +454,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } } - private val dirtyFields = ReferenceOpenHashSet>(fields.size) - private val dirtyFields2 = ArrayList>() + private val dirtyFields = ReferenceArraySet>(fields.size) // use LinkedList because it is ensured memory is freed on LinkedList#clear private val mapBacklogs = Reference2ObjectOpenHashMap, LinkedList Unit>>>() @@ -475,7 +474,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa unused = true mapBacklogs.clear() dirtyFields.clear() - dirtyFields2.clear() val iterator = endpoints.listIterator() @@ -501,14 +499,11 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return } - if (dirtyFields.add(field)) { - dirtyFields2.add(field) - } + dirtyFields.add(field) } internal fun removeDirtyField(field: AbstractField<*>) { dirtyFields.remove(field) - dirtyFields2.remove(field) } internal fun getMapBacklog(map: Map): LinkedList Unit>> { @@ -522,20 +517,19 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } fun collectNetworkPayload(): FastByteArrayOutputStream? { - if (unused || dirtyFields2.isEmpty()) { + if (unused || dirtyFields.isEmpty()) { return null } val stream = FastByteArrayOutputStream() val dataStream = DataOutputStream(stream) - for (field in dirtyFields2) { + for (field in dirtyFields) { stream.writeVarIntLE(field.id) field.write(dataStream, this) } dirtyFields.clear() - dirtyFields2.clear() stream.write(0) return stream From 34ed1322ba5e6b7546aafe2cfeaeab9eb0d45fcc Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 17 Mar 2023 23:34:35 +0700 Subject: [PATCH 0386/1199] Avoid unnecessary comparison --- .../mc/otm/network/FieldSynchronizer.kt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt index be238eedf..055351d11 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt @@ -643,6 +643,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa override fun observe(): Boolean { check(!isRemoved) { "Field was removed" } + if (!isDirty && !codec.compare(remote, field)) { notifyEndpoints(this@Field) isDirty = true @@ -669,10 +670,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return } - if (this.field == value) { - return - } - if (!isDirty && !codec.compare(remote, value)) { notifyEndpoints(this@Field) isDirty = true @@ -726,6 +723,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa override fun observe(): Boolean { check(!isRemoved) { "Field was removed" } + + val value = value + if (!isDirty && (remote == null || !codec.compare(remote ?: throw ConcurrentModificationException(), value))) { notifyEndpoints(this) isDirty = true @@ -746,7 +746,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa override fun write(stream: DataOutputStream, endpoint: Endpoint) { check(!isRemoved) { "Field was removed" } - val value = value codec.write(stream, value) isDirty = false } @@ -795,6 +794,8 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa override fun observe(): Boolean { check(!isRemoved) { "Field was removed" } + val value = value + if (!isDirty && !codec.compare(remote, value)) { notifyEndpoints(this) isDirty = true @@ -812,7 +813,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa override fun write(stream: DataOutputStream, endpoint: Endpoint) { check(!isRemoved) { "Field was removed" } - val value = value codec.write(stream, value) isDirty = false } @@ -835,8 +835,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa private var isRemote = false init { - if (observingBackingMap != null) + if (observingBackingMap != null) { observers.add(this) + } } private fun pushBacklog(key: Any?, value: (DataOutputStream) -> Unit) { From b4225af3530180e478fbe6ddd4f699510640f137 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Mar 2023 01:08:15 +0700 Subject: [PATCH 0387/1199] Type specific primitive fields in field synchronizer --- .../otm/capability/MatteryPlayerCapability.kt | 10 +- .../mc/otm/network/FieldSynchronizer.kt | 1275 +++++++++++++++-- 2 files changed, 1188 insertions(+), 97 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index b8068c354..4f67fa783 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -160,12 +160,12 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial /** * Whenever player has Exopack */ - var hasExoPack by publicSynchronizer.bool() + var hasExoPack by publicSynchronizer.bool().property /** * Whenever to render Exopack on player */ - var displayExoPack by publicSynchronizer.bool(true) + var displayExoPack by publicSynchronizer.bool(true).property /** * Tick event schedulers @@ -231,7 +231,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial access.write(value) _exoPackMenu = null } - }) + }).property private var _exoPackMenu: ExoPackInventoryMenu? = null set(value) { @@ -301,7 +301,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial /** * Whenever player should become an Android once transformation conditions are met (e.g. player dies or sleeps in bed) */ - var willBecomeAndroid by publicSynchronizer.bool() + var willBecomeAndroid by publicSynchronizer.bool().property /** * Whenever player is an Android @@ -315,7 +315,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial * * Android-immune (de)buffs are specified in `data/overdrive_that_matters/tags/mob_effect/android_immune_effects.json` */ - var isAndroid by publicSynchronizer.bool() + var isAndroid by publicSynchronizer.bool().property /** * [IMatteryEnergyStorage] instance, representing Android' battery charge diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt index 055351d11..f161c5fe4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt @@ -1,30 +1,27 @@ +@file:Suppress("DeprecatedCallableAddReplaceWith") + package ru.dbotthepony.mc.otm.network +import it.unimi.dsi.fastutil.booleans.BooleanConsumer +import it.unimi.dsi.fastutil.floats.FloatConsumer import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream import it.unimi.dsi.fastutil.objects.Reference2ObjectFunction import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.ReferenceArraySet -import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet +import mekanism.api.functions.FloatSupplier import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.collect.ProxiedMap import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.util.BigDecimalValueCodec import ru.dbotthepony.mc.otm.core.util.BinaryStringCodec -import ru.dbotthepony.mc.otm.core.util.BooleanValueCodec import ru.dbotthepony.mc.otm.core.util.ByteValueCodec -import ru.dbotthepony.mc.otm.core.util.DoubleValueCodec -import ru.dbotthepony.mc.otm.core.util.EnumValueCodec -import ru.dbotthepony.mc.otm.core.util.FloatValueCodec -import ru.dbotthepony.mc.otm.core.util.IStreamCodec import ru.dbotthepony.mc.otm.core.util.DecimalValueCodec -import ru.dbotthepony.mc.otm.core.util.IntValueCodec +import ru.dbotthepony.mc.otm.core.util.EnumValueCodec +import ru.dbotthepony.mc.otm.core.util.IStreamCodec import ru.dbotthepony.mc.otm.core.util.ItemStackValueCodec -import ru.dbotthepony.mc.otm.core.util.LongValueCodec import ru.dbotthepony.mc.otm.core.util.ShortValueCodec import ru.dbotthepony.mc.otm.core.util.UUIDValueCodec -import ru.dbotthepony.mc.otm.core.util.VarIntValueCodec -import ru.dbotthepony.mc.otm.core.util.VarLongValueCodec import ru.dbotthepony.mc.otm.core.util.readVarIntLE import ru.dbotthepony.mc.otm.core.util.writeVarIntLE import ru.dbotthepony.mc.otm.secondTime @@ -34,8 +31,14 @@ import java.io.InputStream import java.lang.ref.WeakReference import java.math.BigDecimal import java.util.* +import java.util.function.BooleanSupplier +import java.util.function.DoubleConsumer +import java.util.function.DoubleSupplier +import java.util.function.IntConsumer +import java.util.function.IntSupplier +import java.util.function.LongConsumer +import java.util.function.LongSupplier import java.util.function.Supplier -import kotlin.collections.ArrayList import kotlin.properties.ReadOnlyProperty import kotlin.reflect.KMutableProperty0 import kotlin.reflect.KProperty @@ -46,14 +49,139 @@ interface FieldAccess { fun write(value: V) } +interface FloatFieldAccess : FieldAccess { + override fun write(value: Float) + @Deprecated("Use type specific method", replaceWith = ReplaceWith("this.readFloat()")) + override fun read() = readFloat() + fun readFloat(): Float +} + +interface DoubleFieldAccess : FieldAccess { + override fun write(value: Double) + @Deprecated("Use type specific method", replaceWith = ReplaceWith("this.readDouble()")) + override fun read() = readDouble() + fun readDouble(): Double +} + +interface IntFieldAccess : FieldAccess { + override fun write(value: Int) + @Deprecated("Use type specific method", replaceWith = ReplaceWith("this.readInt()")) + override fun read() = readInt() + fun readInt(): Int +} + +interface LongFieldAccess : FieldAccess { + override fun write(value: Long) + @Deprecated("Use type specific method", replaceWith = ReplaceWith("this.readLong()")) + override fun read() = readLong() + fun readLong(): Long +} + +interface BooleanFieldAccess : FieldAccess { + override fun write(value: Boolean) + @Deprecated("Use type specific method", replaceWith = ReplaceWith("this.readBoolean()")) + override fun read() = readBoolean() + fun readBoolean(): Boolean +} + fun interface FieldGetter { fun invoke(field: FieldAccess): V } +fun interface FloatFieldGetter : FieldGetter { + fun invoke(field: FloatFieldAccess): Float + + @Deprecated("Use type specific invoke") + override fun invoke(field: FieldAccess): Float { + return invoke(field as FloatFieldAccess) + } +} + +fun interface DoubleFieldGetter : FieldGetter { + fun invoke(field: DoubleFieldAccess): Double + + @Deprecated("Use type specific invoke") + override fun invoke(field: FieldAccess): Double { + return invoke(field as DoubleFieldAccess) + } +} + +fun interface IntFieldGetter : FieldGetter { + fun invoke(field: IntFieldAccess): Int + + @Deprecated("Use type specific invoke") + override fun invoke(field: FieldAccess): Int { + return invoke(field as IntFieldAccess) + } +} + +fun interface LongFieldGetter : FieldGetter { + fun invoke(field: LongFieldAccess): Long + + @Deprecated("Use type specific invoke") + override fun invoke(field: FieldAccess): Long { + return invoke(field as LongFieldAccess) + } +} + +fun interface BooleanFieldGetter : FieldGetter { + fun invoke(field: BooleanFieldAccess): Boolean + + @Deprecated("Use type specific invoke") + override fun invoke(field: FieldAccess): Boolean { + return invoke(field as BooleanFieldAccess) + } +} + fun interface FieldSetter { fun invoke(value: V, access: FieldAccess, setByRemote: Boolean) } +fun interface FloatFieldSetter : FieldSetter { + fun invoke(value: Float, access: FloatFieldAccess, setByRemote: Boolean) + + @Deprecated("Use type specific invoke") + override fun invoke(value: Float, access: FieldAccess, setByRemote: Boolean) { + invoke(value, access as FloatFieldAccess, setByRemote) + } +} + +fun interface DoubleFieldSetter : FieldSetter { + fun invoke(value: Double, access: DoubleFieldAccess, setByRemote: Boolean) + + @Deprecated("Use type specific invoke") + override fun invoke(value: Double, access: FieldAccess, setByRemote: Boolean) { + invoke(value, access as DoubleFieldAccess, setByRemote) + } +} + +fun interface IntFieldSetter : FieldSetter { + fun invoke(value: Int, access: IntFieldAccess, setByRemote: Boolean) + + @Deprecated("Use type specific invoke") + override fun invoke(value: Int, access: FieldAccess, setByRemote: Boolean) { + invoke(value, access as IntFieldAccess, setByRemote) + } +} + +fun interface LongFieldSetter : FieldSetter { + fun invoke(value: Long, access: LongFieldAccess, setByRemote: Boolean) + + @Deprecated("Use type specific invoke") + override fun invoke(value: Long, access: FieldAccess, setByRemote: Boolean) { + invoke(value, access as LongFieldAccess, setByRemote) + } +} + +fun interface BooleanFieldSetter : FieldSetter { + fun invoke(value: Boolean, access: BooleanFieldAccess, setByRemote: Boolean) + + @Deprecated("Use type specific invoke") + override fun invoke(value: Boolean, access: FieldAccess, setByRemote: Boolean) { + invoke(value, access as BooleanFieldAccess, setByRemote) + } +} + sealed interface IField : ReadOnlyProperty, Supplier, () -> V { fun observe(): Boolean fun markDirty() @@ -79,6 +207,111 @@ sealed interface IField : ReadOnlyProperty, Supplier, () -> V { } } +interface IFloatProperty { + operator fun getValue(thisRef: Any?, property: KProperty<*>): Float +} + +sealed interface IFloatField : IField, FloatSupplier { + val float: Float + val property: IFloatProperty + + override val value: Float + get() = float + + override fun getAsFloat(): Float { + return float + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun getValue(thisRef: Any?, property: KProperty<*>): Float { + return float + } +} + +interface IDoubleProperty { + operator fun getValue(thisRef: Any?, property: KProperty<*>): Double +} + +sealed interface IDoubleField : IField, DoubleSupplier { + val double: Double + val property: IDoubleProperty + + override val value: Double + get() = double + + override fun getAsDouble(): Double { + return double + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun getValue(thisRef: Any?, property: KProperty<*>): Double { + return double + } +} + +interface IIntProperty { + operator fun getValue(thisRef: Any?, property: KProperty<*>): Int +} + +sealed interface IIntField : IField, IntSupplier { + val int: Int + val property: IIntProperty + + override val value: Int + get() = int + + override fun getAsInt(): Int { + return int + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun getValue(thisRef: Any?, property: KProperty<*>): Int { + return int + } +} + +interface ILongProperty { + operator fun getValue(thisRef: Any?, property: KProperty<*>): Long +} + +sealed interface ILongField : IField, LongSupplier { + val long: Long + val property: ILongProperty + + override val value: Long + get() = long + + override fun getAsLong(): Long { + return long + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun getValue(thisRef: Any?, property: KProperty<*>): Long { + return long + } +} + +interface IBooleanProperty { + operator fun getValue(thisRef: Any?, property: KProperty<*>): Boolean +} + +sealed interface IBooleanField : IField, BooleanSupplier { + val boolean: Boolean + val property: IBooleanProperty + + override val value: Boolean + get() = boolean + + override fun getAsBoolean(): Boolean { + return boolean + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun getValue(thisRef: Any?, property: KProperty<*>): Boolean { + return boolean + } +} + sealed interface IMutableField : IField, GetterSetter { override fun getValue(thisRef: Any?, property: KProperty<*>): V { return this.value @@ -95,6 +328,146 @@ sealed interface IMutableField : IField, GetterSetter { } } +interface IMutableFloatProperty : IFloatProperty { + operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Float) +} + +sealed interface IMutableFloatField : IMutableField, FloatConsumer { + var float: Float + val property: IMutableFloatProperty + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.float")) + override var value: Float + get() = float + set(value) { float = value } + + override fun accept(t: Float) { + float = t + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun getValue(thisRef: Any?, property: KProperty<*>): Float { + return float + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun setValue(thisRef: Any?, property: KProperty<*>, value: Float) { + float = value + } +} + +interface IMutableDoubleProperty : IDoubleProperty { + operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Double) +} + +sealed interface IMutableDoubleField : IMutableField, DoubleConsumer { + var double: Double + val property: IMutableDoubleProperty + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.double")) + override var value: Double + get() = double + set(value) { double = value } + + override fun accept(t: Double) { + double = t + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun getValue(thisRef: Any?, property: KProperty<*>): Double { + return double + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun setValue(thisRef: Any?, property: KProperty<*>, value: Double) { + double = value + } +} + +interface IMutableIntProperty : IIntProperty { + operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Int) +} + +sealed interface IMutableIntField : IMutableField, IntConsumer { + var int: Int + val property: IMutableIntProperty + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.int")) + override var value: Int + get() = int + set(value) { int = value } + + override fun accept(t: Int) { + int = t + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun getValue(thisRef: Any?, property: KProperty<*>): Int { + return int + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun setValue(thisRef: Any?, property: KProperty<*>, value: Int) { + int = value + } +} + +interface IMutableLongProperty : ILongProperty { + operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Long) +} + +sealed interface IMutableLongField : IMutableField, LongConsumer { + var long: Long + val property: IMutableLongProperty + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.long")) + override var value: Long + get() = long + set(value) { long = value } + + override fun accept(t: Long) { + long = t + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun getValue(thisRef: Any?, property: KProperty<*>): Long { + return long + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun setValue(thisRef: Any?, property: KProperty<*>, value: Long) { + long = value + } +} + +interface IMutableBooleanProperty : IBooleanProperty { + operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Boolean) +} + +sealed interface IMutableBooleanField : IMutableField, BooleanConsumer { + var boolean: Boolean + val property: IMutableBooleanProperty + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.boolean")) + override var value: Boolean + get() = boolean + set(value) { boolean = value } + + override fun accept(t: Boolean) { + boolean = t + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun getValue(thisRef: Any?, property: KProperty<*>): Boolean { + return boolean + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun setValue(thisRef: Any?, property: KProperty<*>, value: Boolean) { + boolean = value + } +} + data class MapChangeset( val action: MapAction, val key: K?, @@ -165,45 +538,45 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } fun byte(getter: () -> Byte) = ComputedField(getter, ByteValueCodec) - fun bool(getter: () -> Boolean) = ComputedField(getter, BooleanValueCodec) + fun bool(getter: BooleanSupplier) = ComputedBooleanField(getter) fun short(getter: () -> Short) = ComputedField(getter, ShortValueCodec) - fun long(getter: () -> Long) = ComputedField(getter, VarLongValueCodec) - fun fixedLong(getter: () -> Long) = ComputedField(getter, LongValueCodec) - fun float(getter: () -> Float) = ComputedField(getter, FloatValueCodec) - fun double(getter: () -> Double) = ComputedField(getter, DoubleValueCodec) + fun long(getter: LongSupplier) = ComputedLongField(getter) + fun fixedLong(getter: LongSupplier) = ComputedLongField(getter) + fun float(getter: FloatSupplier) = ComputedFloatField(getter) + fun double(getter: DoubleSupplier) = ComputedDoubleField(getter) fun uuid(getter: () -> UUID) = ComputedField(getter, UUIDValueCodec) - fun int(getter: () -> Int) = ComputedField(getter, VarIntValueCodec) - fun fixedInt(getter: () -> Int) = ComputedField(getter, IntValueCodec) + fun int(getter: IntSupplier) = ComputedIntField(getter) + fun fixedInt(getter: IntSupplier) = ComputedIntField(getter) fun fraction(getter: () -> Decimal) = ComputedField(getter, DecimalValueCodec) fun bigDecimal(getter: () -> BigDecimal) = ComputedField(getter, BigDecimalValueCodec) fun item(getter: () -> ItemStack) = ComputedField(getter, ItemStackValueCodec) fun string(getter: () -> String) = ComputedField(getter, BinaryStringCodec) fun byte(getter: KProperty0) = ComputedField(getter, ByteValueCodec) - fun bool(getter: KProperty0) = ComputedField(getter, BooleanValueCodec) + fun bool(getter: KProperty0) = ComputedBooleanField(getter::get) fun short(getter: KProperty0) = ComputedField(getter, ShortValueCodec) - fun long(getter: KProperty0) = ComputedField(getter, VarLongValueCodec) - fun fixedLong(getter: KProperty0) = ComputedField(getter, LongValueCodec) - fun float(getter: KProperty0) = ComputedField(getter, FloatValueCodec) - fun double(getter: KProperty0) = ComputedField(getter, DoubleValueCodec) + fun long(getter: KProperty0) = ComputedLongField(getter::get) + fun fixedLong(getter: KProperty0) = ComputedLongField(getter::get) + fun float(getter: KProperty0) = ComputedFloatField(getter::get) + fun double(getter: KProperty0) = ComputedDoubleField(getter::get) fun uuid(getter: KProperty0) = ComputedField(getter, UUIDValueCodec) - fun int(getter: KProperty0) = ComputedField(getter, VarIntValueCodec) - fun fixedInt(getter: KProperty0) = ComputedField(getter, IntValueCodec) + fun int(getter: KProperty0) = ComputedIntField(getter::get) + fun fixedInt(getter: KProperty0) = ComputedIntField(getter::get) fun fraction(getter: KProperty0) = ComputedField(getter, DecimalValueCodec) fun bigDecimal(getter: KProperty0) = ComputedField(getter, BigDecimalValueCodec) fun item(getter: KProperty0) = ComputedField(getter, ItemStackValueCodec) fun string(getter: KProperty0) = ComputedField(getter, BinaryStringCodec) fun byte(getter: Supplier) = ComputedField(getter::get, ByteValueCodec) - fun bool(getter: Supplier) = ComputedField(getter::get, BooleanValueCodec) + fun bool(getter: Supplier) = ComputedBooleanField(getter::get) fun short(getter: Supplier) = ComputedField(getter::get, ShortValueCodec) - fun long(getter: Supplier) = ComputedField(getter::get, VarLongValueCodec) - fun fixedLong(getter: Supplier) = ComputedField(getter::get, LongValueCodec) - fun float(getter: Supplier) = ComputedField(getter::get, FloatValueCodec) - fun double(getter: Supplier) = ComputedField(getter::get, DoubleValueCodec) + fun long(getter: Supplier) = ComputedLongField(getter::get) + fun fixedLong(getter: Supplier) = ComputedLongField(getter::get) + fun float(getter: Supplier) = ComputedFloatField(getter::get) + fun double(getter: Supplier) = ComputedDoubleField(getter::get) fun uuid(getter: Supplier) = ComputedField(getter::get, UUIDValueCodec) - fun int(getter: Supplier) = ComputedField(getter::get, VarIntValueCodec) - fun fixedInt(getter: Supplier) = ComputedField(getter::get, IntValueCodec) + fun int(getter: Supplier) = ComputedIntField(getter::get) + fun fixedInt(getter: Supplier) = ComputedIntField(getter::get) fun fraction(getter: Supplier) = ComputedField(getter::get, DecimalValueCodec) fun bigDecimal(getter: Supplier) = ComputedField(getter::get, BigDecimalValueCodec) fun item(getter: Supplier) = ComputedField(getter::get, ItemStackValueCodec) @@ -223,7 +596,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: Byte = 0, getter: FieldGetter? = null, setter: FieldSetter? = null, - ): Field { return Field(value, ByteValueCodec, getter, setter) } @@ -231,11 +603,10 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa @JvmOverloads fun bool( value: Boolean = false, - getter: FieldGetter? = null, - setter: FieldSetter? = null, - - ): Field { - return Field(value, BooleanValueCodec, getter, setter) + getter: BooleanFieldGetter? = null, + setter: BooleanFieldSetter? = null, + ): BooleanField { + return BooleanField(value, getter, setter) } @JvmOverloads @@ -243,7 +614,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: Short = 0, getter: FieldGetter? = null, setter: FieldSetter? = null, - ): Field { return Field(value, ShortValueCodec, getter, setter) } @@ -251,41 +621,37 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa @JvmOverloads fun long( value: Long = 0L, - getter: FieldGetter? = null, - setter: FieldSetter? = null, - - ): Field { - return Field(value, VarLongValueCodec, getter, setter) + getter: LongFieldGetter? = null, + setter: LongFieldSetter? = null, + ): LongField { + return LongField(value, getter, setter) } @JvmOverloads fun fixedLong( value: Long = 0L, - getter: FieldGetter? = null, - setter: FieldSetter? = null, - - ): Field { - return Field(value, LongValueCodec, getter, setter) + getter: LongFieldGetter? = null, + setter: LongFieldSetter? = null, + ): LongField { + return LongField(value, getter, setter) } @JvmOverloads fun float( value: Float = 0f, - getter: FieldGetter? = null, - setter: FieldSetter? = null, - - ): Field { - return Field(value, FloatValueCodec, getter, setter) + getter: FloatFieldGetter? = null, + setter: FloatFieldSetter? = null, + ): FloatField { + return FloatField(value, getter, setter) } @JvmOverloads fun double( value: Double = 0.0, - getter: FieldGetter? = null, - setter: FieldSetter? = null, - - ): Field { - return Field(value, DoubleValueCodec, getter, setter) + getter: DoubleFieldGetter? = null, + setter: DoubleFieldSetter? = null, + ): DoubleField { + return DoubleField(value, getter, setter) } @JvmOverloads @@ -293,7 +659,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: UUID = UUID(0L, 0L), getter: FieldGetter? = null, setter: FieldSetter? = null, - ): Field { return Field(value, UUIDValueCodec, getter, setter) } @@ -301,11 +666,10 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa @JvmOverloads fun int( value: Int = 0, - getter: FieldGetter? = null, - setter: FieldSetter? = null, - - ): Field { - return Field(value, VarIntValueCodec, getter, setter) + getter: IntFieldGetter? = null, + setter: IntFieldSetter? = null, + ): IntField { + return IntField(value, getter, setter) } @JvmOverloads @@ -313,7 +677,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: String = "", getter: FieldGetter? = null, setter: FieldSetter? = null, - ): Field { return Field(value, BinaryStringCodec, getter, setter) } @@ -321,11 +684,10 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa @JvmOverloads fun fixedInt( value: Int = 0, - getter: FieldGetter? = null, - setter: FieldSetter? = null, - - ): Field { - return Field(value, IntValueCodec, getter, setter) + getter: IntFieldGetter? = null, + setter: IntFieldSetter? = null, + ): IntField { + return IntField(value, getter, setter) } @JvmOverloads @@ -333,7 +695,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: Decimal = Decimal.ZERO, getter: FieldGetter? = null, setter: FieldSetter? = null, - ): Field { return Field(value, DecimalValueCodec, getter, setter) } @@ -343,7 +704,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: BigDecimal = BigDecimal.ZERO, getter: FieldGetter? = null, setter: FieldSetter? = null, - ): Field { return Field(value, BigDecimalValueCodec, getter, setter) } @@ -354,7 +714,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: T = type.enumConstants[0], getter: FieldGetter? = null, setter: FieldSetter? = null, - ): Field { return Field(value, EnumValueCodec(type), getter, setter) } @@ -364,7 +723,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: T, getter: FieldGetter? = null, setter: FieldSetter? = null, - ): Field { return Field(value, EnumValueCodec(value::class.java), getter, setter) } @@ -385,23 +743,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return ObservedField(delegate, ItemStackValueCodec) } - @JvmOverloads - fun map( - keyCodec: IStreamCodec, - valueCodec: IStreamCodec, - callback: ((changes: Collection>) -> Unit)? = null, - backingMap: MutableMap = HashMap(), - observingBackingMap: MutableMap? = null, - ): Map { - return Map( - keyCodec = keyCodec, - valueCodec = valueCodec, - callback = callback, - backingMap = backingMap, - observingBackingMap = observingBackingMap, - ) - } - private var endpointsMaxCapacity = 1 private val endpoints = ArrayList>(1) val defaultEndpoint = Endpoint() @@ -705,6 +1046,421 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } } + /** + * Type specific field, storing primitive [Float] directly + */ + inner class FloatField(private var field: Float, private val getter: FloatFieldGetter? = null, private val setter: FloatFieldSetter? = null) : AbstractField(), IMutableFloatField { + private var isDirty = false + + override val property = object : IMutableFloatProperty { + override fun getValue(thisRef: Any?, property: KProperty<*>): Float { + return this@FloatField.float + } + + override fun setValue(thisRef: Any?, property: KProperty<*>, value: Float) { + this@FloatField.float = value + } + } + + private val access = object : FloatFieldAccess { + override fun readFloat(): Float { + return this@FloatField.field + } + + override fun write(value: Float) { + if (!isDirty && value != this@FloatField.field) { + notifyEndpoints(this@FloatField) + isDirty = true + } + + this@FloatField.field = value + } + } + + override fun observe(): Boolean { + check(!isRemoved) { "Field was removed" } + return isDirty + } + + override var float: Float + get() { + return getter?.invoke(access) ?: this.field + } + set(value) { + val setter = this.setter + + if (setter != null) { + setter.invoke(value, access, false) + return + } + + if (value != this.field) { + if (!isDirty) { + notifyEndpoints(this) + isDirty = true + } + + this.field = value + } + } + + override fun markDirty() { + check(!isRemoved) { "Field was removed" } + notifyEndpoints(this) + isDirty = true + } + + override fun write(stream: DataOutputStream, endpoint: Endpoint) { + check(!isRemoved) { "Field was removed" } + stream.writeFloat(this.field) + isDirty = false + } + + override fun read(stream: DataInputStream) { + check(!isRemoved) { "Field was removed" } + val value = stream.readFloat() + val setter = this.setter + + if (setter != null) { + setter.invoke(value, access, true) + } else { + this.field = value + } + } + } + + /** + * Type specific field, storing primitive [Double] directly + */ + inner class DoubleField(private var field: Double, private val getter: DoubleFieldGetter? = null, private val setter: DoubleFieldSetter? = null) : AbstractField(), IMutableDoubleField { + private var isDirty = false + + override val property = object : IMutableDoubleProperty { + override fun getValue(thisRef: Any?, property: KProperty<*>): Double { + return this@DoubleField.double + } + + override fun setValue(thisRef: Any?, property: KProperty<*>, value: Double) { + this@DoubleField.double = value + } + } + + private val access = object : DoubleFieldAccess { + override fun readDouble(): Double { + return this@DoubleField.field + } + + override fun write(value: Double) { + if (!isDirty && value != this@DoubleField.field) { + notifyEndpoints(this@DoubleField) + isDirty = true + } + + this@DoubleField.field = value + } + } + + override fun observe(): Boolean { + check(!isRemoved) { "Field was removed" } + return isDirty + } + + override var double: Double + get() { + return getter?.invoke(access) ?: this.field + } + set(value) { + val setter = this.setter + + if (setter != null) { + setter.invoke(value, access, false) + return + } + + if (value != this.field) { + if (!isDirty) { + notifyEndpoints(this) + isDirty = true + } + + this.field = value + } + } + + override fun markDirty() { + check(!isRemoved) { "Field was removed" } + notifyEndpoints(this) + isDirty = true + } + + override fun write(stream: DataOutputStream, endpoint: Endpoint) { + check(!isRemoved) { "Field was removed" } + stream.writeDouble(this.field) + isDirty = false + } + + override fun read(stream: DataInputStream) { + check(!isRemoved) { "Field was removed" } + val value = stream.readDouble() + val setter = this.setter + + if (setter != null) { + setter.invoke(value, access, true) + } else { + this.field = value + } + } + } + + /** + * Type specific field, storing primitive [Int] directly + */ + inner class IntField(private var field: Int, private val getter: IntFieldGetter? = null, private val setter: IntFieldSetter? = null) : AbstractField(), IMutableIntField { + private var isDirty = false + + override val property = object : IMutableIntProperty { + override fun getValue(thisRef: Any?, property: KProperty<*>): Int { + return this@IntField.int + } + + override fun setValue(thisRef: Any?, property: KProperty<*>, value: Int) { + this@IntField.int = value + } + } + + private val access = object : IntFieldAccess { + override fun readInt(): Int { + return this@IntField.field + } + + override fun write(value: Int) { + if (!isDirty && value != this@IntField.field) { + notifyEndpoints(this@IntField) + isDirty = true + } + + this@IntField.field = value + } + } + + override fun observe(): Boolean { + check(!isRemoved) { "Field was removed" } + return isDirty + } + + override var int: Int + get() { + return getter?.invoke(access) ?: this.field + } + set(value) { + val setter = this.setter + + if (setter != null) { + setter.invoke(value, access, false) + return + } + + if (value != this.field) { + if (!isDirty) { + notifyEndpoints(this) + isDirty = true + } + + this.field = value + } + } + + override fun markDirty() { + check(!isRemoved) { "Field was removed" } + notifyEndpoints(this) + isDirty = true + } + + override fun write(stream: DataOutputStream, endpoint: Endpoint) { + check(!isRemoved) { "Field was removed" } + stream.writeInt(this.field) + isDirty = false + } + + override fun read(stream: DataInputStream) { + check(!isRemoved) { "Field was removed" } + val value = stream.readInt() + val setter = this.setter + + if (setter != null) { + setter.invoke(value, access, true) + } else { + this.field = value + } + } + } + + /** + * Type specific field, storing primitive [Long] directly + */ + inner class LongField(private var field: Long, private val getter: LongFieldGetter? = null, private val setter: LongFieldSetter? = null) : AbstractField(), IMutableLongField { + private var isDirty = false + + override val property = object : IMutableLongProperty { + override fun getValue(thisRef: Any?, property: KProperty<*>): Long { + return this@LongField.long + } + + override fun setValue(thisRef: Any?, property: KProperty<*>, value: Long) { + this@LongField.long = value + } + } + + private val access = object : LongFieldAccess { + override fun readLong(): Long { + return this@LongField.field + } + + override fun write(value: Long) { + if (!isDirty && value != this@LongField.field) { + notifyEndpoints(this@LongField) + isDirty = true + } + + this@LongField.field = value + } + } + + override fun observe(): Boolean { + check(!isRemoved) { "Field was removed" } + return isDirty + } + + override var long: Long + get() { + return getter?.invoke(access) ?: this.field + } + set(value) { + val setter = this.setter + + if (setter != null) { + setter.invoke(value, access, false) + return + } + + if (value != this.field) { + if (!isDirty) { + notifyEndpoints(this) + isDirty = true + } + + this.field = value + } + } + + override fun markDirty() { + check(!isRemoved) { "Field was removed" } + notifyEndpoints(this) + isDirty = true + } + + override fun write(stream: DataOutputStream, endpoint: Endpoint) { + check(!isRemoved) { "Field was removed" } + stream.writeLong(this.field) + isDirty = false + } + + override fun read(stream: DataInputStream) { + check(!isRemoved) { "Field was removed" } + val value = stream.readLong() + val setter = this.setter + + if (setter != null) { + setter.invoke(value, access, true) + } else { + this.field = value + } + } + } + + /** + * Type specific field, storing primitive [Boolean] directly + */ + inner class BooleanField(private var field: Boolean, private val getter: BooleanFieldGetter? = null, private val setter: BooleanFieldSetter? = null) : AbstractField(), IMutableBooleanField { + private var isDirty = false + + override val property = object : IMutableBooleanProperty { + override fun getValue(thisRef: Any?, property: KProperty<*>): Boolean { + return this@BooleanField.boolean + } + + override fun setValue(thisRef: Any?, property: KProperty<*>, value: Boolean) { + this@BooleanField.boolean = value + } + } + + private val access = object : BooleanFieldAccess { + override fun readBoolean(): Boolean { + return this@BooleanField.field + } + + override fun write(value: Boolean) { + if (!isDirty && value != this@BooleanField.field) { + notifyEndpoints(this@BooleanField) + isDirty = true + } + + this@BooleanField.field = value + } + } + + override fun observe(): Boolean { + check(!isRemoved) { "Field was removed" } + return isDirty + } + + override var boolean: Boolean + get() { + return getter?.invoke(access) ?: this.field + } + set(value) { + val setter = this.setter + + if (setter != null) { + setter.invoke(value, access, false) + return + } + + if (value != this.field) { + if (!isDirty) { + notifyEndpoints(this) + isDirty = true + } + + this.field = value + } + } + + override fun markDirty() { + check(!isRemoved) { "Field was removed" } + notifyEndpoints(this) + isDirty = true + } + + override fun write(stream: DataOutputStream, endpoint: Endpoint) { + check(!isRemoved) { "Field was removed" } + stream.writeBoolean(this.field) + isDirty = false + } + + override fun read(stream: DataInputStream) { + check(!isRemoved) { "Field was removed" } + val value = stream.readBoolean() + val setter = this.setter + + if (setter != null) { + setter.invoke(value, access, true) + } else { + this.field = value + } + } + } + /** * Networked value with backing getter which is constantly polled */ @@ -758,6 +1514,341 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } } + /** + * Networked value with backing getter which is constantly polled + * + * This class has concrete implementation for [Float] primitive + */ + inner class ComputedFloatField(private val getter: FloatSupplier, private val observer: FloatConsumer = FloatConsumer {}) : AbstractField(), IFloatField { + private var remote: Float = 0f + private var isRemoteSet = false + private var clientValue: Float = 0f + private var isClientValue = false + private var isDirty = false + + override val property = object : IFloatProperty { + override fun getValue(thisRef: Any?, property: KProperty<*>): Float { + return float + } + } + + init { + observers.add(this) + } + + override fun observe(): Boolean { + check(!isRemoved) { "Field was removed" } + + val value = getter.asFloat + + if (!isDirty && (!isRemoteSet || remote != value)) { + notifyEndpoints(this) + isDirty = true + isRemoteSet = true + remote = value + } + + return isDirty + } + + override fun markDirty() { + check(!isRemoved) { "Field was removed" } + notifyEndpoints(this) + isDirty = true + } + + override val float: Float + get() { + if (isClientValue) { + return clientValue + } else { + return getter.asFloat + } + } + + override fun write(stream: DataOutputStream, endpoint: Endpoint) { + check(!isRemoved) { "Field was removed" } + stream.writeFloat(getter.asFloat) + isDirty = false + } + + override fun read(stream: DataInputStream) { + check(!isRemoved) { "Field was removed" } + val newValue = stream.readFloat() + clientValue = newValue + isClientValue = true + observer.accept(newValue) + } + } + + /** + * Networked value with backing getter which is constantly polled + * + * This class has concrete implementation for [Double] primitive + */ + inner class ComputedDoubleField(private val getter: DoubleSupplier, private val observer: DoubleConsumer = DoubleConsumer {}) : AbstractField(), IDoubleField { + private var remote: Double = 0.0 + private var isRemoteSet = false + private var clientValue: Double = 0.0 + private var isClientValue = false + private var isDirty = false + + override val property = object : IDoubleProperty { + override fun getValue(thisRef: Any?, property: KProperty<*>): Double { + return double + } + } + + init { + observers.add(this) + } + + override fun observe(): Boolean { + check(!isRemoved) { "Field was removed" } + + val value = getter.asDouble + + if (!isDirty && (!isRemoteSet || remote != value)) { + notifyEndpoints(this) + isDirty = true + isRemoteSet = true + remote = value + } + + return isDirty + } + + override fun markDirty() { + check(!isRemoved) { "Field was removed" } + notifyEndpoints(this) + isDirty = true + } + + override val double: Double + get() { + if (isClientValue) { + return clientValue + } else { + return getter.asDouble + } + } + + override fun write(stream: DataOutputStream, endpoint: Endpoint) { + check(!isRemoved) { "Field was removed" } + stream.writeDouble(getter.asDouble) + isDirty = false + } + + override fun read(stream: DataInputStream) { + check(!isRemoved) { "Field was removed" } + val newValue = stream.readDouble() + clientValue = newValue + isClientValue = true + observer.accept(newValue) + } + } + + /** + * Networked value with backing getter which is constantly polled + * + * This class has concrete implementation for [Int] primitive + */ + inner class ComputedIntField(private val getter: IntSupplier, private val observer: IntConsumer = IntConsumer {}) : AbstractField(), IIntField { + private var remote: Int = 0 + private var isRemoteSet = false + private var clientValue: Int = 0 + private var isClientValue = false + private var isDirty = false + + override val property = object : IIntProperty { + override fun getValue(thisRef: Any?, property: KProperty<*>): Int { + return int + } + } + + init { + observers.add(this) + } + + override fun observe(): Boolean { + check(!isRemoved) { "Field was removed" } + + val value = getter.asInt + + if (!isDirty && (!isRemoteSet || remote != value)) { + notifyEndpoints(this) + isDirty = true + isRemoteSet = true + remote = value + } + + return isDirty + } + + override fun markDirty() { + check(!isRemoved) { "Field was removed" } + notifyEndpoints(this) + isDirty = true + } + + override val int: Int + get() { + if (isClientValue) { + return clientValue + } else { + return getter.asInt + } + } + + override fun write(stream: DataOutputStream, endpoint: Endpoint) { + check(!isRemoved) { "Field was removed" } + stream.writeInt(getter.asInt) + isDirty = false + } + + override fun read(stream: DataInputStream) { + check(!isRemoved) { "Field was removed" } + val newValue = stream.readInt() + clientValue = newValue + isClientValue = true + observer.accept(newValue) + } + } + + /** + * Networked value with backing getter which is constantly polled + * + * This class has concrete implementation for [Long] primitive + */ + inner class ComputedLongField(private val getter: LongSupplier, private val observer: LongConsumer = LongConsumer {}) : AbstractField(), ILongField { + private var remote: Long = 0L + private var isRemoteSet = false + private var clientValue: Long = 0L + private var isClientValue = false + private var isDirty = false + + override val property = object : ILongProperty { + override fun getValue(thisRef: Any?, property: KProperty<*>): Long { + return long + } + } + + init { + observers.add(this) + } + + override fun observe(): Boolean { + check(!isRemoved) { "Field was removed" } + + val value = getter.asLong + + if (!isDirty && (!isRemoteSet || remote != value)) { + notifyEndpoints(this) + isDirty = true + isRemoteSet = true + remote = value + } + + return isDirty + } + + override fun markDirty() { + check(!isRemoved) { "Field was removed" } + notifyEndpoints(this) + isDirty = true + } + + override val long: Long + get() { + if (isClientValue) { + return clientValue + } else { + return getter.asLong + } + } + + override fun write(stream: DataOutputStream, endpoint: Endpoint) { + check(!isRemoved) { "Field was removed" } + stream.writeLong(getter.asLong) + isDirty = false + } + + override fun read(stream: DataInputStream) { + check(!isRemoved) { "Field was removed" } + val newValue = stream.readLong() + clientValue = newValue + isClientValue = true + observer.accept(newValue) + } + } + + /** + * Networked value with backing getter which is constantly polled + * + * This class has concrete implementation for [Boolean] primitive + */ + inner class ComputedBooleanField(private val getter: BooleanSupplier, private val observer: BooleanConsumer = BooleanConsumer {}) : AbstractField(), IBooleanField { + private var remote: Boolean = false + private var isRemoteSet = false + private var clientValue: Boolean = false + private var isClientValue = false + private var isDirty = false + + override val property = object : IBooleanProperty { + override fun getValue(thisRef: Any?, property: KProperty<*>): Boolean { + return boolean + } + } + + init { + observers.add(this) + } + + override fun observe(): Boolean { + check(!isRemoved) { "Field was removed" } + + val value = getter.asBoolean + + if (!isDirty && (!isRemoteSet || remote != value)) { + notifyEndpoints(this) + isDirty = true + isRemoteSet = true + remote = value + } + + return isDirty + } + + override fun markDirty() { + check(!isRemoved) { "Field was removed" } + notifyEndpoints(this) + isDirty = true + } + + override val boolean: Boolean + get() { + if (isClientValue) { + return clientValue + } else { + return getter.asBoolean + } + } + + override fun write(stream: DataOutputStream, endpoint: Endpoint) { + check(!isRemoved) { "Field was removed" } + stream.writeBoolean(getter.asBoolean) + isDirty = false + } + + override fun read(stream: DataInputStream) { + check(!isRemoved) { "Field was removed" } + val newValue = stream.readBoolean() + clientValue = newValue + isClientValue = true + observer.accept(newValue) + } + } + /** * Networked variable with backing field holding mutable value, which is constantly observed for changes */ From 48a156cd9a4d16d2cd439babfd534dd277c6a043 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Mar 2023 07:49:58 +0700 Subject: [PATCH 0388/1199] Reimplement variable length int field synchronizers, mark Supplier interface as deprecated --- .../mc/otm/network/FieldSynchronizer.kt | 363 +++++++++++------- 1 file changed, 217 insertions(+), 146 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt index f161c5fe4..4fee277fc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt @@ -23,7 +23,9 @@ import ru.dbotthepony.mc.otm.core.util.ItemStackValueCodec import ru.dbotthepony.mc.otm.core.util.ShortValueCodec import ru.dbotthepony.mc.otm.core.util.UUIDValueCodec import ru.dbotthepony.mc.otm.core.util.readVarIntLE +import ru.dbotthepony.mc.otm.core.util.readVarLongLE import ru.dbotthepony.mc.otm.core.util.writeVarIntLE +import ru.dbotthepony.mc.otm.core.util.writeVarLongLE import ru.dbotthepony.mc.otm.secondTime import java.io.DataInputStream import java.io.DataOutputStream @@ -218,6 +220,11 @@ sealed interface IFloatField : IField, FloatSupplier { override val value: Float get() = float + @Deprecated("Use type specific Supplier interface") + override fun get(): Float { + return float + } + override fun getAsFloat(): Float { return float } @@ -236,6 +243,11 @@ sealed interface IDoubleField : IField, DoubleSupplier { val double: Double val property: IDoubleProperty + @Deprecated("Use type specific Supplier interface") + override fun get(): Double { + return double + } + override val value: Double get() = double @@ -257,6 +269,11 @@ sealed interface IIntField : IField, IntSupplier { val int: Int val property: IIntProperty + @Deprecated("Use type specific Supplier interface") + override fun get(): Int { + return int + } + override val value: Int get() = int @@ -278,6 +295,11 @@ sealed interface ILongField : IField, LongSupplier { val long: Long val property: ILongProperty + @Deprecated("Use type specific Supplier interface") + override fun get(): Long { + return long + } + override val value: Long get() = long @@ -299,6 +321,11 @@ sealed interface IBooleanField : IField, BooleanSupplier { val boolean: Boolean val property: IBooleanProperty + @Deprecated("Use type specific Supplier interface") + override fun get(): Boolean { + return boolean + } + override val value: Boolean get() = boolean @@ -332,9 +359,9 @@ interface IMutableFloatProperty : IFloatProperty { operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Float) } -sealed interface IMutableFloatField : IMutableField, FloatConsumer { - var float: Float - val property: IMutableFloatProperty +sealed interface IMutableFloatField : IMutableField, IFloatField, FloatConsumer { + override var float: Float + override val property: IMutableFloatProperty @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.float")) override var value: Float @@ -360,9 +387,9 @@ interface IMutableDoubleProperty : IDoubleProperty { operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Double) } -sealed interface IMutableDoubleField : IMutableField, DoubleConsumer { - var double: Double - val property: IMutableDoubleProperty +sealed interface IMutableDoubleField : IMutableField, IDoubleField, DoubleConsumer { + override var double: Double + override val property: IMutableDoubleProperty @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.double")) override var value: Double @@ -388,9 +415,9 @@ interface IMutableIntProperty : IIntProperty { operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Int) } -sealed interface IMutableIntField : IMutableField, IntConsumer { - var int: Int - val property: IMutableIntProperty +sealed interface IMutableIntField : IMutableField, IIntField, IntConsumer { + override var int: Int + override val property: IMutableIntProperty @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.int")) override var value: Int @@ -416,9 +443,9 @@ interface IMutableLongProperty : ILongProperty { operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Long) } -sealed interface IMutableLongField : IMutableField, LongConsumer { - var long: Long - val property: IMutableLongProperty +sealed interface IMutableLongField : IMutableField, ILongField, LongConsumer { + override var long: Long + override val property: IMutableLongProperty @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.long")) override var value: Long @@ -444,9 +471,9 @@ interface IMutableBooleanProperty : IBooleanProperty { operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Boolean) } -sealed interface IMutableBooleanField : IMutableField, BooleanConsumer { - var boolean: Boolean - val property: IMutableBooleanProperty +sealed interface IMutableBooleanField : IMutableField, IBooleanField, BooleanConsumer { + override var boolean: Boolean + override val property: IMutableBooleanProperty @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.boolean")) override var value: Boolean @@ -541,12 +568,12 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa fun bool(getter: BooleanSupplier) = ComputedBooleanField(getter) fun short(getter: () -> Short) = ComputedField(getter, ShortValueCodec) fun long(getter: LongSupplier) = ComputedLongField(getter) - fun fixedLong(getter: LongSupplier) = ComputedLongField(getter) + fun fixedLong(getter: LongSupplier) = ComputedFixedLongField(getter) fun float(getter: FloatSupplier) = ComputedFloatField(getter) fun double(getter: DoubleSupplier) = ComputedDoubleField(getter) fun uuid(getter: () -> UUID) = ComputedField(getter, UUIDValueCodec) fun int(getter: IntSupplier) = ComputedIntField(getter) - fun fixedInt(getter: IntSupplier) = ComputedIntField(getter) + fun fixedInt(getter: IntSupplier) = ComputedFixedIntField(getter) fun fraction(getter: () -> Decimal) = ComputedField(getter, DecimalValueCodec) fun bigDecimal(getter: () -> BigDecimal) = ComputedField(getter, BigDecimalValueCodec) fun item(getter: () -> ItemStack) = ComputedField(getter, ItemStackValueCodec) @@ -556,12 +583,12 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa fun bool(getter: KProperty0) = ComputedBooleanField(getter::get) fun short(getter: KProperty0) = ComputedField(getter, ShortValueCodec) fun long(getter: KProperty0) = ComputedLongField(getter::get) - fun fixedLong(getter: KProperty0) = ComputedLongField(getter::get) + fun fixedLong(getter: KProperty0) = ComputedFixedLongField(getter::get) fun float(getter: KProperty0) = ComputedFloatField(getter::get) fun double(getter: KProperty0) = ComputedDoubleField(getter::get) fun uuid(getter: KProperty0) = ComputedField(getter, UUIDValueCodec) fun int(getter: KProperty0) = ComputedIntField(getter::get) - fun fixedInt(getter: KProperty0) = ComputedIntField(getter::get) + fun fixedInt(getter: KProperty0) = ComputedFixedIntField(getter::get) fun fraction(getter: KProperty0) = ComputedField(getter, DecimalValueCodec) fun bigDecimal(getter: KProperty0) = ComputedField(getter, BigDecimalValueCodec) fun item(getter: KProperty0) = ComputedField(getter, ItemStackValueCodec) @@ -571,12 +598,12 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa fun bool(getter: Supplier) = ComputedBooleanField(getter::get) fun short(getter: Supplier) = ComputedField(getter::get, ShortValueCodec) fun long(getter: Supplier) = ComputedLongField(getter::get) - fun fixedLong(getter: Supplier) = ComputedLongField(getter::get) + fun fixedLong(getter: Supplier) = ComputedFixedLongField(getter::get) fun float(getter: Supplier) = ComputedFloatField(getter::get) fun double(getter: Supplier) = ComputedDoubleField(getter::get) fun uuid(getter: Supplier) = ComputedField(getter::get, UUIDValueCodec) fun int(getter: Supplier) = ComputedIntField(getter::get) - fun fixedInt(getter: Supplier) = ComputedIntField(getter::get) + fun fixedInt(getter: Supplier) = ComputedFixedIntField(getter::get) fun fraction(getter: Supplier) = ComputedField(getter::get, DecimalValueCodec) fun bigDecimal(getter: Supplier) = ComputedField(getter::get, BigDecimalValueCodec) fun item(getter: Supplier) = ComputedField(getter::get, ItemStackValueCodec) @@ -632,8 +659,8 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: Long = 0L, getter: LongFieldGetter? = null, setter: LongFieldSetter? = null, - ): LongField { - return LongField(value, getter, setter) + ): FixedLongField { + return FixedLongField(value, getter, setter) } @JvmOverloads @@ -686,8 +713,8 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa value: Int = 0, getter: IntFieldGetter? = null, setter: IntFieldSetter? = null, - ): IntField { - return IntField(value, getter, setter) + ): FixedIntField { + return FixedIntField(value, getter, setter) } @JvmOverloads @@ -1046,12 +1073,25 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } } + abstract inner class PrimitiveField() : AbstractField() { + protected var isDirty = false + + override fun observe(): Boolean { + check(!isRemoved) { "Field was removed" } + return isDirty + } + + override fun markDirty() { + check(!isRemoved) { "Field was removed" } + notifyEndpoints(this) + isDirty = true + } + } + /** * Type specific field, storing primitive [Float] directly */ - inner class FloatField(private var field: Float, private val getter: FloatFieldGetter? = null, private val setter: FloatFieldSetter? = null) : AbstractField(), IMutableFloatField { - private var isDirty = false - + inner class FloatField(private var field: Float, private val getter: FloatFieldGetter? = null, private val setter: FloatFieldSetter? = null) : PrimitiveField(), IMutableFloatField { override val property = object : IMutableFloatProperty { override fun getValue(thisRef: Any?, property: KProperty<*>): Float { return this@FloatField.float @@ -1077,11 +1117,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } } - override fun observe(): Boolean { - check(!isRemoved) { "Field was removed" } - return isDirty - } - override var float: Float get() { return getter?.invoke(access) ?: this.field @@ -1091,10 +1126,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa if (setter != null) { setter.invoke(value, access, false) - return - } - - if (value != this.field) { + } else if (value != this.field) { if (!isDirty) { notifyEndpoints(this) isDirty = true @@ -1104,12 +1136,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } } - override fun markDirty() { - check(!isRemoved) { "Field was removed" } - notifyEndpoints(this) - isDirty = true - } - override fun write(stream: DataOutputStream, endpoint: Endpoint) { check(!isRemoved) { "Field was removed" } stream.writeFloat(this.field) @@ -1132,9 +1158,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa /** * Type specific field, storing primitive [Double] directly */ - inner class DoubleField(private var field: Double, private val getter: DoubleFieldGetter? = null, private val setter: DoubleFieldSetter? = null) : AbstractField(), IMutableDoubleField { - private var isDirty = false - + inner class DoubleField(private var field: Double, private val getter: DoubleFieldGetter? = null, private val setter: DoubleFieldSetter? = null) : PrimitiveField(), IMutableDoubleField { override val property = object : IMutableDoubleProperty { override fun getValue(thisRef: Any?, property: KProperty<*>): Double { return this@DoubleField.double @@ -1160,11 +1184,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } } - override fun observe(): Boolean { - check(!isRemoved) { "Field was removed" } - return isDirty - } - override var double: Double get() { return getter?.invoke(access) ?: this.field @@ -1174,10 +1193,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa if (setter != null) { setter.invoke(value, access, false) - return - } - - if (value != this.field) { + } else if (value != this.field) { if (!isDirty) { notifyEndpoints(this) isDirty = true @@ -1187,12 +1203,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } } - override fun markDirty() { - check(!isRemoved) { "Field was removed" } - notifyEndpoints(this) - isDirty = true - } - override fun write(stream: DataOutputStream, endpoint: Endpoint) { check(!isRemoved) { "Field was removed" } stream.writeDouble(this.field) @@ -1212,43 +1222,33 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } } - /** - * Type specific field, storing primitive [Int] directly - */ - inner class IntField(private var field: Int, private val getter: IntFieldGetter? = null, private val setter: IntFieldSetter? = null) : AbstractField(), IMutableIntField { - private var isDirty = false - - override val property = object : IMutableIntProperty { + abstract inner class AbstractIntField(protected var field: Int, private val getter: IntFieldGetter? = null, protected val setter: IntFieldSetter? = null) : PrimitiveField(), IMutableIntField { + final override val property = object : IMutableIntProperty { override fun getValue(thisRef: Any?, property: KProperty<*>): Int { - return this@IntField.int + return this@AbstractIntField.int } override fun setValue(thisRef: Any?, property: KProperty<*>, value: Int) { - this@IntField.int = value + this@AbstractIntField.int = value } } - private val access = object : IntFieldAccess { + protected val access = object : IntFieldAccess { override fun readInt(): Int { - return this@IntField.field + return this@AbstractIntField.field } override fun write(value: Int) { - if (!isDirty && value != this@IntField.field) { - notifyEndpoints(this@IntField) + if (!isDirty && value != this@AbstractIntField.field) { + notifyEndpoints(this@AbstractIntField) isDirty = true } - this@IntField.field = value + this@AbstractIntField.field = value } } - override fun observe(): Boolean { - check(!isRemoved) { "Field was removed" } - return isDirty - } - - override var int: Int + final override var int: Int get() { return getter?.invoke(access) ?: this.field } @@ -1257,10 +1257,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa if (setter != null) { setter.invoke(value, access, false) - return - } - - if (value != this.field) { + } else if (value != this.field) { if (!isDirty) { notifyEndpoints(this) isDirty = true @@ -1269,13 +1266,35 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa this.field = value } } + } - override fun markDirty() { + /** + * Type specific field, storing primitive [Int] directly, and networking it as variable length integer + */ + inner class IntField(field: Int, getter: IntFieldGetter? = null, setter: IntFieldSetter? = null) : AbstractIntField(field, getter, setter) { + override fun write(stream: DataOutputStream, endpoint: Endpoint) { check(!isRemoved) { "Field was removed" } - notifyEndpoints(this) - isDirty = true + stream.writeVarIntLE(this.field) + isDirty = false } + override fun read(stream: DataInputStream) { + check(!isRemoved) { "Field was removed" } + val value = stream.readVarIntLE() + val setter = this.setter + + if (setter != null) { + setter.invoke(value, access, true) + } else { + this.field = value + } + } + } + + /** + * Type specific field, storing primitive [Int] directly, and networking it as 4 octets + */ + inner class FixedIntField(field: Int, getter: IntFieldGetter? = null, setter: IntFieldSetter? = null) : AbstractIntField(field, getter, setter) { override fun write(stream: DataOutputStream, endpoint: Endpoint) { check(!isRemoved) { "Field was removed" } stream.writeInt(this.field) @@ -1298,40 +1317,33 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa /** * Type specific field, storing primitive [Long] directly */ - inner class LongField(private var field: Long, private val getter: LongFieldGetter? = null, private val setter: LongFieldSetter? = null) : AbstractField(), IMutableLongField { - private var isDirty = false - - override val property = object : IMutableLongProperty { + abstract inner class AbstractLongField(protected var field: Long, private val getter: LongFieldGetter? = null, protected val setter: LongFieldSetter? = null) : PrimitiveField(), IMutableLongField { + final override val property = object : IMutableLongProperty { override fun getValue(thisRef: Any?, property: KProperty<*>): Long { - return this@LongField.long + return this@AbstractLongField.long } override fun setValue(thisRef: Any?, property: KProperty<*>, value: Long) { - this@LongField.long = value + this@AbstractLongField.long = value } } - private val access = object : LongFieldAccess { + protected val access = object : LongFieldAccess { override fun readLong(): Long { - return this@LongField.field + return this@AbstractLongField.field } override fun write(value: Long) { - if (!isDirty && value != this@LongField.field) { - notifyEndpoints(this@LongField) + if (!isDirty && value != this@AbstractLongField.field) { + notifyEndpoints(this@AbstractLongField) isDirty = true } - this@LongField.field = value + this@AbstractLongField.field = value } } - override fun observe(): Boolean { - check(!isRemoved) { "Field was removed" } - return isDirty - } - - override var long: Long + final override var long: Long get() { return getter?.invoke(access) ?: this.field } @@ -1340,10 +1352,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa if (setter != null) { setter.invoke(value, access, false) - return - } - - if (value != this.field) { + } else if (value != this.field) { if (!isDirty) { notifyEndpoints(this) isDirty = true @@ -1352,13 +1361,35 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa this.field = value } } + } - override fun markDirty() { + /** + * Type specific field, storing primitive [Long] directly, and networking it as variable length integer + */ + inner class LongField(field: Long, getter: LongFieldGetter? = null, setter: LongFieldSetter? = null) : AbstractLongField(field, getter, setter) { + override fun write(stream: DataOutputStream, endpoint: Endpoint) { check(!isRemoved) { "Field was removed" } - notifyEndpoints(this) - isDirty = true + stream.writeVarLongLE(this.field) + isDirty = false } + override fun read(stream: DataInputStream) { + check(!isRemoved) { "Field was removed" } + val value = stream.readVarLongLE() + val setter = this.setter + + if (setter != null) { + setter.invoke(value, access, true) + } else { + this.field = value + } + } + } + + /** + * Type specific field, storing primitive [Long] directly, and networking it as 8 octets + */ + inner class FixedLongField(field: Long, getter: LongFieldGetter? = null, setter: LongFieldSetter? = null) : AbstractLongField(field, getter, setter) { override fun write(stream: DataOutputStream, endpoint: Endpoint) { check(!isRemoved) { "Field was removed" } stream.writeLong(this.field) @@ -1381,9 +1412,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa /** * Type specific field, storing primitive [Boolean] directly */ - inner class BooleanField(private var field: Boolean, private val getter: BooleanFieldGetter? = null, private val setter: BooleanFieldSetter? = null) : AbstractField(), IMutableBooleanField { - private var isDirty = false - + inner class BooleanField(private var field: Boolean, private val getter: BooleanFieldGetter? = null, private val setter: BooleanFieldSetter? = null) : PrimitiveField(), IMutableBooleanField { override val property = object : IMutableBooleanProperty { override fun getValue(thisRef: Any?, property: KProperty<*>): Boolean { return this@BooleanField.boolean @@ -1409,11 +1438,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } } - override fun observe(): Boolean { - check(!isRemoved) { "Field was removed" } - return isDirty - } - override var boolean: Boolean get() { return getter?.invoke(access) ?: this.field @@ -1423,10 +1447,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa if (setter != null) { setter.invoke(value, access, false) - return - } - - if (value != this.field) { + } else if (value != this.field) { if (!isDirty) { notifyEndpoints(this) isDirty = true @@ -1436,12 +1457,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } } - override fun markDirty() { - check(!isRemoved) { "Field was removed" } - notifyEndpoints(this) - isDirty = true - } - override fun write(stream: DataOutputStream, endpoint: Endpoint) { check(!isRemoved) { "Field was removed" } stream.writeBoolean(this.field) @@ -1653,14 +1668,14 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa * * This class has concrete implementation for [Int] primitive */ - inner class ComputedIntField(private val getter: IntSupplier, private val observer: IntConsumer = IntConsumer {}) : AbstractField(), IIntField { + abstract inner class AbstractComputedIntField(protected val getter: IntSupplier, protected val observer: IntConsumer = IntConsumer {}) : AbstractField(), IIntField { private var remote: Int = 0 private var isRemoteSet = false - private var clientValue: Int = 0 - private var isClientValue = false - private var isDirty = false + protected var clientValue: Int = 0 + protected var isClientValue = false + protected var isDirty = false - override val property = object : IIntProperty { + final override val property = object : IIntProperty { override fun getValue(thisRef: Any?, property: KProperty<*>): Int { return int } @@ -1670,7 +1685,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa observers.add(this) } - override fun observe(): Boolean { + final override fun observe(): Boolean { check(!isRemoved) { "Field was removed" } val value = getter.asInt @@ -1685,13 +1700,13 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return isDirty } - override fun markDirty() { + final override fun markDirty() { check(!isRemoved) { "Field was removed" } notifyEndpoints(this) isDirty = true } - override val int: Int + final override val int: Int get() { if (isClientValue) { return clientValue @@ -1699,7 +1714,35 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return getter.asInt } } + } + /** + * Networked value with backing getter which is constantly polled + * + * This class has concrete implementation for [Int] primitive, networking it as variable length integer + */ + inner class ComputedIntField(getter: IntSupplier, observer: IntConsumer = IntConsumer {}) : AbstractComputedIntField(getter, observer) { + override fun write(stream: DataOutputStream, endpoint: Endpoint) { + check(!isRemoved) { "Field was removed" } + stream.writeVarIntLE(getter.asInt) + isDirty = false + } + + override fun read(stream: DataInputStream) { + check(!isRemoved) { "Field was removed" } + val newValue = stream.readVarIntLE() + clientValue = newValue + isClientValue = true + observer.accept(newValue) + } + } + + /** + * Networked value with backing getter which is constantly polled + * + * This class has concrete implementation for [Int] primitive, networking it as 4 octets + */ + inner class ComputedFixedIntField(getter: IntSupplier, observer: IntConsumer = IntConsumer {}) : AbstractComputedIntField(getter, observer) { override fun write(stream: DataOutputStream, endpoint: Endpoint) { check(!isRemoved) { "Field was removed" } stream.writeInt(getter.asInt) @@ -1720,14 +1763,14 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa * * This class has concrete implementation for [Long] primitive */ - inner class ComputedLongField(private val getter: LongSupplier, private val observer: LongConsumer = LongConsumer {}) : AbstractField(), ILongField { + abstract inner class AbstractComputedLongField(protected val getter: LongSupplier, protected val observer: LongConsumer = LongConsumer {}) : AbstractField(), ILongField { private var remote: Long = 0L private var isRemoteSet = false - private var clientValue: Long = 0L - private var isClientValue = false - private var isDirty = false + protected var clientValue: Long = 0L + protected var isClientValue = false + protected var isDirty = false - override val property = object : ILongProperty { + final override val property = object : ILongProperty { override fun getValue(thisRef: Any?, property: KProperty<*>): Long { return long } @@ -1737,7 +1780,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa observers.add(this) } - override fun observe(): Boolean { + final override fun observe(): Boolean { check(!isRemoved) { "Field was removed" } val value = getter.asLong @@ -1752,13 +1795,13 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return isDirty } - override fun markDirty() { + final override fun markDirty() { check(!isRemoved) { "Field was removed" } notifyEndpoints(this) isDirty = true } - override val long: Long + final override val long: Long get() { if (isClientValue) { return clientValue @@ -1766,7 +1809,35 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return getter.asLong } } + } + /** + * Networked value with backing getter which is constantly polled + * + * This class has concrete implementation for [Long] primitive, networking it as variable length integer + */ + inner class ComputedLongField(getter: LongSupplier, observer: LongConsumer = LongConsumer {}) : AbstractComputedLongField(getter, observer) { + override fun write(stream: DataOutputStream, endpoint: Endpoint) { + check(!isRemoved) { "Field was removed" } + stream.writeVarLongLE(getter.asLong) + isDirty = false + } + + override fun read(stream: DataInputStream) { + check(!isRemoved) { "Field was removed" } + val newValue = stream.readVarLongLE() + clientValue = newValue + isClientValue = true + observer.accept(newValue) + } + } + + /** + * Networked value with backing getter which is constantly polled + * + * This class has concrete implementation for [Long] primitive, networking it as 8 octets + */ + inner class ComputedFixedLongField(getter: LongSupplier, observer: LongConsumer = LongConsumer {}) : AbstractComputedLongField(getter, observer) { override fun write(stream: DataOutputStream, endpoint: Endpoint) { check(!isRemoved) { "Field was removed" } stream.writeLong(getter.asLong) From 3672b9c3ac9599fbf9e23e4d0c4382eeb21728b5 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Mar 2023 08:11:34 +0700 Subject: [PATCH 0389/1199] Split field synchronizer into its own package --- .../mc/otm/android/AndroidFeature.kt | 2 +- .../mc/otm/android/AndroidResearch.kt | 2 +- .../mc/otm/block/entity/MatteryBlockEntity.kt | 2 +- .../mc/otm/block/entity/RedstoneControl.kt | 2 +- .../otm/capability/MatteryPlayerCapability.kt | 1 + .../capability/energy/AndroidPowerSource.kt | 2 +- .../mc/otm/container/MatteryContainer.kt | 6 +- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 4 +- .../otm/network/synchronizer/FieldAccess.kt | 41 ++ .../otm/network/synchronizer/FieldGetter.kt | 50 ++ .../otm/network/synchronizer/FieldSetter.kt | 50 ++ .../{ => synchronizer}/FieldSynchronizer.kt | 480 +----------------- .../mc/otm/network/synchronizer/Fields.kt | 167 ++++++ .../mc/otm/network/synchronizer/MapAction.kt | 5 + .../otm/network/synchronizer/MapChangeset.kt | 23 + .../otm/network/synchronizer/MutableFields.kt | 165 ++++++ .../mc/otm/tests/FieldSynchronizerTests.kt | 4 +- 17 files changed, 515 insertions(+), 491 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldAccess.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldGetter.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSetter.kt rename src/main/kotlin/ru/dbotthepony/mc/otm/network/{ => synchronizer}/FieldSynchronizer.kt (78%) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/Fields.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/MapAction.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/MapChangeset.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/MutableFields.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeature.kt index 736a3da2c..fc9fb84d9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeature.kt @@ -6,7 +6,7 @@ import net.minecraftforge.common.util.INBTSerializable import net.minecraftforge.event.entity.living.LivingHurtEvent import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.network.FieldSynchronizer +import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer import java.io.InputStream abstract class AndroidFeature(val type: AndroidFeatureType<*>, val android: MatteryPlayerCapability) : INBTSerializable { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt index 154d7dba9..c9cc9e664 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt @@ -20,7 +20,7 @@ import ru.dbotthepony.mc.otm.core.nbt.getCompoundList import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.milliTime -import ru.dbotthepony.mc.otm.network.FieldSynchronizer +import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer import ru.dbotthepony.mc.otm.registry.MRegistry import ru.dbotthepony.mc.otm.triggers.AndroidResearchTrigger import java.io.InputStream 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 1e8dd0ef1..d8d125c92 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 @@ -53,7 +53,7 @@ import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.core.util.Savetables import ru.dbotthepony.mc.otm.core.util.TickList import ru.dbotthepony.mc.otm.network.BlockEntitySyncPacket -import ru.dbotthepony.mc.otm.network.FieldSynchronizer +import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer import ru.dbotthepony.mc.otm.network.WorldNetworkChannel import ru.dbotthepony.mc.otm.once import ru.dbotthepony.mc.otm.onceServer diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt index a93faed9a..8316ed787 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt @@ -4,7 +4,7 @@ import net.minecraft.nbt.CompoundTag import net.minecraftforge.common.util.INBTSerializable import ru.dbotthepony.mc.otm.core.nbt.mapString import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.network.FieldSynchronizer +import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer interface IRedstoneControlled { val redstoneControl: AbstractRedstoneControl diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 4f67fa783..05c431d45 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -68,6 +68,7 @@ import ru.dbotthepony.mc.otm.core.util.TickList import ru.dbotthepony.mc.otm.core.util.UUIDValueCodec import ru.dbotthepony.mc.otm.menu.ExoPackInventoryMenu import ru.dbotthepony.mc.otm.network.* +import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer import ru.dbotthepony.mc.otm.registry.AndroidFeatures import ru.dbotthepony.mc.otm.registry.MRegistry import ru.dbotthepony.mc.otm.triggers.AndroidResearchTrigger diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt index f7c63478c..75550ca61 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt @@ -14,7 +14,7 @@ import ru.dbotthepony.mc.otm.core.math.getDecimal import ru.dbotthepony.mc.otm.core.nbt.getItemStack import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.network.FieldSynchronizer +import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer import ru.dbotthepony.mc.otm.registry.StatNames import ru.dbotthepony.mc.otm.triggers.AndroidBatteryTrigger diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt index b0af02659..6fc6f998f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt @@ -14,17 +14,15 @@ import net.minecraft.world.item.Item import net.minecraft.world.item.Items import net.minecraftforge.common.util.INBTSerializable import net.minecraftforge.registries.ForgeRegistries -import ru.dbotthepony.mc.otm.core.forValidRefs import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.core.util.ItemValueCodec import ru.dbotthepony.mc.otm.core.util.VarIntValueCodec -import ru.dbotthepony.mc.otm.network.FieldSynchronizer -import ru.dbotthepony.mc.otm.network.IField +import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer +import ru.dbotthepony.mc.otm.network.synchronizer.IField import java.lang.ref.WeakReference import java.util.* -import kotlin.collections.ArrayList @Suppress("UNUSED") open class MatteryContainer(protected val watcher: Runnable, private val size: Int) : Container, Iterable, INBTSerializable { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index bb5872939..a0b080b93 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -37,8 +37,8 @@ import ru.dbotthepony.mc.otm.core.util.ItemValueCodec import ru.dbotthepony.mc.otm.core.util.NullValueCodec import ru.dbotthepony.mc.otm.core.util.VarIntValueCodec import ru.dbotthepony.mc.otm.menu.widget.AbstractWidget -import ru.dbotthepony.mc.otm.network.FieldSynchronizer -import ru.dbotthepony.mc.otm.network.IField +import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer +import ru.dbotthepony.mc.otm.network.synchronizer.IField import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel import ru.dbotthepony.mc.otm.network.MenuFieldPacket diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldAccess.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldAccess.kt new file mode 100644 index 000000000..c43201a31 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldAccess.kt @@ -0,0 +1,41 @@ +package ru.dbotthepony.mc.otm.network.synchronizer + +interface FieldAccess { + fun read(): V + fun write(value: V) +} + +interface FloatFieldAccess : FieldAccess { + override fun write(value: Float) + @Deprecated("Use type specific method", replaceWith = ReplaceWith("this.readFloat()")) + override fun read() = readFloat() + fun readFloat(): Float +} + +interface DoubleFieldAccess : FieldAccess { + override fun write(value: Double) + @Deprecated("Use type specific method", replaceWith = ReplaceWith("this.readDouble()")) + override fun read() = readDouble() + fun readDouble(): Double +} + +interface IntFieldAccess : FieldAccess { + override fun write(value: Int) + @Deprecated("Use type specific method", replaceWith = ReplaceWith("this.readInt()")) + override fun read() = readInt() + fun readInt(): Int +} + +interface LongFieldAccess : FieldAccess { + override fun write(value: Long) + @Deprecated("Use type specific method", replaceWith = ReplaceWith("this.readLong()")) + override fun read() = readLong() + fun readLong(): Long +} + +interface BooleanFieldAccess : FieldAccess { + override fun write(value: Boolean) + @Deprecated("Use type specific method", replaceWith = ReplaceWith("this.readBoolean()")) + override fun read() = readBoolean() + fun readBoolean(): Boolean +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldGetter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldGetter.kt new file mode 100644 index 000000000..4389e1ca3 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldGetter.kt @@ -0,0 +1,50 @@ +package ru.dbotthepony.mc.otm.network.synchronizer + +fun interface FieldGetter { + fun invoke(field: FieldAccess): V +} + +fun interface FloatFieldGetter : FieldGetter { + fun invoke(field: FloatFieldAccess): Float + + @Deprecated("Use type specific invoke") + override fun invoke(field: FieldAccess): Float { + return invoke(field as FloatFieldAccess) + } +} + +fun interface DoubleFieldGetter : FieldGetter { + fun invoke(field: DoubleFieldAccess): Double + + @Deprecated("Use type specific invoke") + override fun invoke(field: FieldAccess): Double { + return invoke(field as DoubleFieldAccess) + } +} + +fun interface IntFieldGetter : FieldGetter { + fun invoke(field: IntFieldAccess): Int + + @Deprecated("Use type specific invoke") + override fun invoke(field: FieldAccess): Int { + return invoke(field as IntFieldAccess) + } +} + +fun interface LongFieldGetter : FieldGetter { + fun invoke(field: LongFieldAccess): Long + + @Deprecated("Use type specific invoke") + override fun invoke(field: FieldAccess): Long { + return invoke(field as LongFieldAccess) + } +} + +fun interface BooleanFieldGetter : FieldGetter { + fun invoke(field: BooleanFieldAccess): Boolean + + @Deprecated("Use type specific invoke") + override fun invoke(field: FieldAccess): Boolean { + return invoke(field as BooleanFieldAccess) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSetter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSetter.kt new file mode 100644 index 000000000..3a5e4fb40 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSetter.kt @@ -0,0 +1,50 @@ +package ru.dbotthepony.mc.otm.network.synchronizer + +fun interface FieldSetter { + fun invoke(value: V, access: FieldAccess, setByRemote: Boolean) +} + +fun interface FloatFieldSetter : FieldSetter { + fun invoke(value: Float, access: FloatFieldAccess, setByRemote: Boolean) + + @Deprecated("Use type specific invoke") + override fun invoke(value: Float, access: FieldAccess, setByRemote: Boolean) { + invoke(value, access as FloatFieldAccess, setByRemote) + } +} + +fun interface DoubleFieldSetter : FieldSetter { + fun invoke(value: Double, access: DoubleFieldAccess, setByRemote: Boolean) + + @Deprecated("Use type specific invoke") + override fun invoke(value: Double, access: FieldAccess, setByRemote: Boolean) { + invoke(value, access as DoubleFieldAccess, setByRemote) + } +} + +fun interface IntFieldSetter : FieldSetter { + fun invoke(value: Int, access: IntFieldAccess, setByRemote: Boolean) + + @Deprecated("Use type specific invoke") + override fun invoke(value: Int, access: FieldAccess, setByRemote: Boolean) { + invoke(value, access as IntFieldAccess, setByRemote) + } +} + +fun interface LongFieldSetter : FieldSetter { + fun invoke(value: Long, access: LongFieldAccess, setByRemote: Boolean) + + @Deprecated("Use type specific invoke") + override fun invoke(value: Long, access: FieldAccess, setByRemote: Boolean) { + invoke(value, access as LongFieldAccess, setByRemote) + } +} + +fun interface BooleanFieldSetter : FieldSetter { + fun invoke(value: Boolean, access: BooleanFieldAccess, setByRemote: Boolean) + + @Deprecated("Use type specific invoke") + override fun invoke(value: Boolean, access: FieldAccess, setByRemote: Boolean) { + invoke(value, access as BooleanFieldAccess, setByRemote) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt similarity index 78% rename from src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt index 4fee277fc..e7e65743e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt @@ -1,6 +1,6 @@ @file:Suppress("DeprecatedCallableAddReplaceWith") -package ru.dbotthepony.mc.otm.network +package ru.dbotthepony.mc.otm.network.synchronizer import it.unimi.dsi.fastutil.booleans.BooleanConsumer import it.unimi.dsi.fastutil.floats.FloatConsumer @@ -41,488 +41,12 @@ import java.util.function.IntSupplier import java.util.function.LongConsumer import java.util.function.LongSupplier import java.util.function.Supplier -import kotlin.properties.ReadOnlyProperty import kotlin.reflect.KMutableProperty0 import kotlin.reflect.KProperty import kotlin.reflect.KProperty0 -interface FieldAccess { - fun read(): V - fun write(value: V) -} - -interface FloatFieldAccess : FieldAccess { - override fun write(value: Float) - @Deprecated("Use type specific method", replaceWith = ReplaceWith("this.readFloat()")) - override fun read() = readFloat() - fun readFloat(): Float -} - -interface DoubleFieldAccess : FieldAccess { - override fun write(value: Double) - @Deprecated("Use type specific method", replaceWith = ReplaceWith("this.readDouble()")) - override fun read() = readDouble() - fun readDouble(): Double -} - -interface IntFieldAccess : FieldAccess { - override fun write(value: Int) - @Deprecated("Use type specific method", replaceWith = ReplaceWith("this.readInt()")) - override fun read() = readInt() - fun readInt(): Int -} - -interface LongFieldAccess : FieldAccess { - override fun write(value: Long) - @Deprecated("Use type specific method", replaceWith = ReplaceWith("this.readLong()")) - override fun read() = readLong() - fun readLong(): Long -} - -interface BooleanFieldAccess : FieldAccess { - override fun write(value: Boolean) - @Deprecated("Use type specific method", replaceWith = ReplaceWith("this.readBoolean()")) - override fun read() = readBoolean() - fun readBoolean(): Boolean -} - -fun interface FieldGetter { - fun invoke(field: FieldAccess): V -} - -fun interface FloatFieldGetter : FieldGetter { - fun invoke(field: FloatFieldAccess): Float - - @Deprecated("Use type specific invoke") - override fun invoke(field: FieldAccess): Float { - return invoke(field as FloatFieldAccess) - } -} - -fun interface DoubleFieldGetter : FieldGetter { - fun invoke(field: DoubleFieldAccess): Double - - @Deprecated("Use type specific invoke") - override fun invoke(field: FieldAccess): Double { - return invoke(field as DoubleFieldAccess) - } -} - -fun interface IntFieldGetter : FieldGetter { - fun invoke(field: IntFieldAccess): Int - - @Deprecated("Use type specific invoke") - override fun invoke(field: FieldAccess): Int { - return invoke(field as IntFieldAccess) - } -} - -fun interface LongFieldGetter : FieldGetter { - fun invoke(field: LongFieldAccess): Long - - @Deprecated("Use type specific invoke") - override fun invoke(field: FieldAccess): Long { - return invoke(field as LongFieldAccess) - } -} - -fun interface BooleanFieldGetter : FieldGetter { - fun invoke(field: BooleanFieldAccess): Boolean - - @Deprecated("Use type specific invoke") - override fun invoke(field: FieldAccess): Boolean { - return invoke(field as BooleanFieldAccess) - } -} - -fun interface FieldSetter { - fun invoke(value: V, access: FieldAccess, setByRemote: Boolean) -} - -fun interface FloatFieldSetter : FieldSetter { - fun invoke(value: Float, access: FloatFieldAccess, setByRemote: Boolean) - - @Deprecated("Use type specific invoke") - override fun invoke(value: Float, access: FieldAccess, setByRemote: Boolean) { - invoke(value, access as FloatFieldAccess, setByRemote) - } -} - -fun interface DoubleFieldSetter : FieldSetter { - fun invoke(value: Double, access: DoubleFieldAccess, setByRemote: Boolean) - - @Deprecated("Use type specific invoke") - override fun invoke(value: Double, access: FieldAccess, setByRemote: Boolean) { - invoke(value, access as DoubleFieldAccess, setByRemote) - } -} - -fun interface IntFieldSetter : FieldSetter { - fun invoke(value: Int, access: IntFieldAccess, setByRemote: Boolean) - - @Deprecated("Use type specific invoke") - override fun invoke(value: Int, access: FieldAccess, setByRemote: Boolean) { - invoke(value, access as IntFieldAccess, setByRemote) - } -} - -fun interface LongFieldSetter : FieldSetter { - fun invoke(value: Long, access: LongFieldAccess, setByRemote: Boolean) - - @Deprecated("Use type specific invoke") - override fun invoke(value: Long, access: FieldAccess, setByRemote: Boolean) { - invoke(value, access as LongFieldAccess, setByRemote) - } -} - -fun interface BooleanFieldSetter : FieldSetter { - fun invoke(value: Boolean, access: BooleanFieldAccess, setByRemote: Boolean) - - @Deprecated("Use type specific invoke") - override fun invoke(value: Boolean, access: FieldAccess, setByRemote: Boolean) { - invoke(value, access as BooleanFieldAccess, setByRemote) - } -} - -sealed interface IField : ReadOnlyProperty, Supplier, () -> V { - fun observe(): Boolean - fun markDirty() - fun markDirty(endpoint: FieldSynchronizer.Endpoint) - val value: V - val isRemoved: Boolean - - fun remove() - - fun write(stream: DataOutputStream, endpoint: FieldSynchronizer.Endpoint) - fun read(stream: DataInputStream) - - override fun getValue(thisRef: Any?, property: KProperty<*>): V { - return this.value - } - - override fun get(): V { - return value - } - - override fun invoke(): V { - return value - } -} - -interface IFloatProperty { - operator fun getValue(thisRef: Any?, property: KProperty<*>): Float -} - -sealed interface IFloatField : IField, FloatSupplier { - val float: Float - val property: IFloatProperty - - override val value: Float - get() = float - - @Deprecated("Use type specific Supplier interface") - override fun get(): Float { - return float - } - - override fun getAsFloat(): Float { - return float - } - - @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) - override fun getValue(thisRef: Any?, property: KProperty<*>): Float { - return float - } -} - -interface IDoubleProperty { - operator fun getValue(thisRef: Any?, property: KProperty<*>): Double -} - -sealed interface IDoubleField : IField, DoubleSupplier { - val double: Double - val property: IDoubleProperty - - @Deprecated("Use type specific Supplier interface") - override fun get(): Double { - return double - } - - override val value: Double - get() = double - - override fun getAsDouble(): Double { - return double - } - - @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) - override fun getValue(thisRef: Any?, property: KProperty<*>): Double { - return double - } -} - -interface IIntProperty { - operator fun getValue(thisRef: Any?, property: KProperty<*>): Int -} - -sealed interface IIntField : IField, IntSupplier { - val int: Int - val property: IIntProperty - - @Deprecated("Use type specific Supplier interface") - override fun get(): Int { - return int - } - - override val value: Int - get() = int - - override fun getAsInt(): Int { - return int - } - - @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) - override fun getValue(thisRef: Any?, property: KProperty<*>): Int { - return int - } -} - -interface ILongProperty { - operator fun getValue(thisRef: Any?, property: KProperty<*>): Long -} - -sealed interface ILongField : IField, LongSupplier { - val long: Long - val property: ILongProperty - - @Deprecated("Use type specific Supplier interface") - override fun get(): Long { - return long - } - - override val value: Long - get() = long - - override fun getAsLong(): Long { - return long - } - - @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) - override fun getValue(thisRef: Any?, property: KProperty<*>): Long { - return long - } -} - -interface IBooleanProperty { - operator fun getValue(thisRef: Any?, property: KProperty<*>): Boolean -} - -sealed interface IBooleanField : IField, BooleanSupplier { - val boolean: Boolean - val property: IBooleanProperty - - @Deprecated("Use type specific Supplier interface") - override fun get(): Boolean { - return boolean - } - - override val value: Boolean - get() = boolean - - override fun getAsBoolean(): Boolean { - return boolean - } - - @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) - override fun getValue(thisRef: Any?, property: KProperty<*>): Boolean { - return boolean - } -} - -sealed interface IMutableField : IField, GetterSetter { - override fun getValue(thisRef: Any?, property: KProperty<*>): V { - return this.value - } - - override var value: V - - override fun accept(t: V) { - value = t - } - - override fun invoke(): V { - return this.value - } -} - -interface IMutableFloatProperty : IFloatProperty { - operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Float) -} - -sealed interface IMutableFloatField : IMutableField, IFloatField, FloatConsumer { - override var float: Float - override val property: IMutableFloatProperty - - @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.float")) - override var value: Float - get() = float - set(value) { float = value } - - override fun accept(t: Float) { - float = t - } - - @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) - override fun getValue(thisRef: Any?, property: KProperty<*>): Float { - return float - } - - @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) - override fun setValue(thisRef: Any?, property: KProperty<*>, value: Float) { - float = value - } -} - -interface IMutableDoubleProperty : IDoubleProperty { - operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Double) -} - -sealed interface IMutableDoubleField : IMutableField, IDoubleField, DoubleConsumer { - override var double: Double - override val property: IMutableDoubleProperty - - @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.double")) - override var value: Double - get() = double - set(value) { double = value } - - override fun accept(t: Double) { - double = t - } - - @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) - override fun getValue(thisRef: Any?, property: KProperty<*>): Double { - return double - } - - @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) - override fun setValue(thisRef: Any?, property: KProperty<*>, value: Double) { - double = value - } -} - -interface IMutableIntProperty : IIntProperty { - operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Int) -} - -sealed interface IMutableIntField : IMutableField, IIntField, IntConsumer { - override var int: Int - override val property: IMutableIntProperty - - @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.int")) - override var value: Int - get() = int - set(value) { int = value } - - override fun accept(t: Int) { - int = t - } - - @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) - override fun getValue(thisRef: Any?, property: KProperty<*>): Int { - return int - } - - @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) - override fun setValue(thisRef: Any?, property: KProperty<*>, value: Int) { - int = value - } -} - -interface IMutableLongProperty : ILongProperty { - operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Long) -} - -sealed interface IMutableLongField : IMutableField, ILongField, LongConsumer { - override var long: Long - override val property: IMutableLongProperty - - @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.long")) - override var value: Long - get() = long - set(value) { long = value } - - override fun accept(t: Long) { - long = t - } - - @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) - override fun getValue(thisRef: Any?, property: KProperty<*>): Long { - return long - } - - @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) - override fun setValue(thisRef: Any?, property: KProperty<*>, value: Long) { - long = value - } -} - -interface IMutableBooleanProperty : IBooleanProperty { - operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Boolean) -} - -sealed interface IMutableBooleanField : IMutableField, IBooleanField, BooleanConsumer { - override var boolean: Boolean - override val property: IMutableBooleanProperty - - @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.boolean")) - override var value: Boolean - get() = boolean - set(value) { boolean = value } - - override fun accept(t: Boolean) { - boolean = t - } - - @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) - override fun getValue(thisRef: Any?, property: KProperty<*>): Boolean { - return boolean - } - - @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) - override fun setValue(thisRef: Any?, property: KProperty<*>, value: Boolean) { - boolean = value - } -} - -data class MapChangeset( - val action: MapAction, - val key: K?, - val value: V? -) { - inline fun map(add: (K, V) -> Unit, remove: (K) -> Unit) { - when (action) { - MapAction.ADD -> add.invoke(key!!, value!!) - MapAction.REMOVE -> remove.invoke(key!!) - else -> {} - } - } - - inline fun map(add: (K, V) -> Unit, remove: (K) -> Unit, clear: () -> Unit) { - when (action) { - MapAction.CLEAR -> clear.invoke() - MapAction.ADD -> add.invoke(key!!, value!!) - MapAction.REMOVE -> remove.invoke(key!!) - } - } -} - -enum class MapAction { - CLEAR, ADD, REMOVE -} - /** - * Universal one-to-many value synchronizer, allowing to synchronize values from server to client + * Universal, one-to-many value synchronizer, allowing to synchronize values from server to client * anywhere, where input/output streams are supported */ @Suppress("unused") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/Fields.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/Fields.kt new file mode 100644 index 000000000..2985be01a --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/Fields.kt @@ -0,0 +1,167 @@ +package ru.dbotthepony.mc.otm.network.synchronizer + +import mekanism.api.functions.FloatSupplier +import java.io.DataInputStream +import java.io.DataOutputStream +import java.util.function.BooleanSupplier +import java.util.function.DoubleSupplier +import java.util.function.IntSupplier +import java.util.function.LongSupplier +import java.util.function.Supplier +import kotlin.properties.ReadOnlyProperty +import kotlin.reflect.KProperty + +sealed interface IField : ReadOnlyProperty, Supplier, () -> V { + fun observe(): Boolean + fun markDirty() + fun markDirty(endpoint: FieldSynchronizer.Endpoint) + val value: V + val isRemoved: Boolean + + fun remove() + + fun write(stream: DataOutputStream, endpoint: FieldSynchronizer.Endpoint) + fun read(stream: DataInputStream) + + override fun getValue(thisRef: Any?, property: KProperty<*>): V { + return this.value + } + + override fun get(): V { + return value + } + + override fun invoke(): V { + return value + } +} + +interface IFloatProperty { + operator fun getValue(thisRef: Any?, property: KProperty<*>): Float +} + +sealed interface IFloatField : IField, FloatSupplier { + val float: Float + val property: IFloatProperty + + override val value: Float + get() = float + + @Deprecated("Use type specific Supplier interface") + override fun get(): Float { + return float + } + + override fun getAsFloat(): Float { + return float + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun getValue(thisRef: Any?, property: KProperty<*>): Float { + return float + } +} + +interface IDoubleProperty { + operator fun getValue(thisRef: Any?, property: KProperty<*>): Double +} + +sealed interface IDoubleField : IField, DoubleSupplier { + val double: Double + val property: IDoubleProperty + + @Deprecated("Use type specific Supplier interface") + override fun get(): Double { + return double + } + + override val value: Double + get() = double + + override fun getAsDouble(): Double { + return double + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun getValue(thisRef: Any?, property: KProperty<*>): Double { + return double + } +} + +interface IIntProperty { + operator fun getValue(thisRef: Any?, property: KProperty<*>): Int +} + +sealed interface IIntField : IField, IntSupplier { + val int: Int + val property: IIntProperty + + @Deprecated("Use type specific Supplier interface") + override fun get(): Int { + return int + } + + override val value: Int + get() = int + + override fun getAsInt(): Int { + return int + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun getValue(thisRef: Any?, property: KProperty<*>): Int { + return int + } +} + +interface ILongProperty { + operator fun getValue(thisRef: Any?, property: KProperty<*>): Long +} + +sealed interface ILongField : IField, LongSupplier { + val long: Long + val property: ILongProperty + + @Deprecated("Use type specific Supplier interface") + override fun get(): Long { + return long + } + + override val value: Long + get() = long + + override fun getAsLong(): Long { + return long + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun getValue(thisRef: Any?, property: KProperty<*>): Long { + return long + } +} + +interface IBooleanProperty { + operator fun getValue(thisRef: Any?, property: KProperty<*>): Boolean +} + +sealed interface IBooleanField : IField, BooleanSupplier { + val boolean: Boolean + val property: IBooleanProperty + + @Deprecated("Use type specific Supplier interface") + override fun get(): Boolean { + return boolean + } + + override val value: Boolean + get() = boolean + + override fun getAsBoolean(): Boolean { + return boolean + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun getValue(thisRef: Any?, property: KProperty<*>): Boolean { + return boolean + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/MapAction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/MapAction.kt new file mode 100644 index 000000000..2065e8c65 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/MapAction.kt @@ -0,0 +1,5 @@ +package ru.dbotthepony.mc.otm.network.synchronizer + +enum class MapAction { + CLEAR, ADD, REMOVE +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/MapChangeset.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/MapChangeset.kt new file mode 100644 index 000000000..f7cf986e4 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/MapChangeset.kt @@ -0,0 +1,23 @@ +package ru.dbotthepony.mc.otm.network.synchronizer + +data class MapChangeset( + val action: MapAction, + val key: K?, + val value: V? +) { + inline fun map(add: (K, V) -> Unit, remove: (K) -> Unit) { + when (action) { + MapAction.ADD -> add.invoke(key!!, value!!) + MapAction.REMOVE -> remove.invoke(key!!) + else -> {} + } + } + + inline fun map(add: (K, V) -> Unit, remove: (K) -> Unit, clear: () -> Unit) { + when (action) { + MapAction.CLEAR -> clear.invoke() + MapAction.ADD -> add.invoke(key!!, value!!) + MapAction.REMOVE -> remove.invoke(key!!) + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/MutableFields.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/MutableFields.kt new file mode 100644 index 000000000..a6937cf89 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/MutableFields.kt @@ -0,0 +1,165 @@ +package ru.dbotthepony.mc.otm.network.synchronizer + +import it.unimi.dsi.fastutil.booleans.BooleanConsumer +import it.unimi.dsi.fastutil.floats.FloatConsumer +import ru.dbotthepony.mc.otm.core.GetterSetter +import java.util.function.DoubleConsumer +import java.util.function.IntConsumer +import java.util.function.LongConsumer +import kotlin.reflect.KProperty + +sealed interface IMutableField : IField, GetterSetter { + override fun getValue(thisRef: Any?, property: KProperty<*>): V { + return this.value + } + + override var value: V + + override fun accept(t: V) { + value = t + } + + override fun invoke(): V { + return this.value + } +} + +interface IMutableFloatProperty : IFloatProperty { + operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Float) +} + +sealed interface IMutableFloatField : IMutableField, IFloatField, FloatConsumer { + override var float: Float + override val property: IMutableFloatProperty + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.float")) + override var value: Float + get() = float + set(value) { float = value } + + override fun accept(t: Float) { + float = t + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun getValue(thisRef: Any?, property: KProperty<*>): Float { + return float + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun setValue(thisRef: Any?, property: KProperty<*>, value: Float) { + float = value + } +} + +interface IMutableDoubleProperty : IDoubleProperty { + operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Double) +} + +sealed interface IMutableDoubleField : IMutableField, IDoubleField, DoubleConsumer { + override var double: Double + override val property: IMutableDoubleProperty + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.double")) + override var value: Double + get() = double + set(value) { double = value } + + override fun accept(t: Double) { + double = t + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun getValue(thisRef: Any?, property: KProperty<*>): Double { + return double + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun setValue(thisRef: Any?, property: KProperty<*>, value: Double) { + double = value + } +} + +interface IMutableIntProperty : IIntProperty { + operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Int) +} + +sealed interface IMutableIntField : IMutableField, IIntField, IntConsumer { + override var int: Int + override val property: IMutableIntProperty + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.int")) + override var value: Int + get() = int + set(value) { int = value } + + override fun accept(t: Int) { + int = t + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun getValue(thisRef: Any?, property: KProperty<*>): Int { + return int + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun setValue(thisRef: Any?, property: KProperty<*>, value: Int) { + int = value + } +} + +interface IMutableLongProperty : ILongProperty { + operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Long) +} + +sealed interface IMutableLongField : IMutableField, ILongField, LongConsumer { + override var long: Long + override val property: IMutableLongProperty + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.long")) + override var value: Long + get() = long + set(value) { long = value } + + override fun accept(t: Long) { + long = t + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun getValue(thisRef: Any?, property: KProperty<*>): Long { + return long + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun setValue(thisRef: Any?, property: KProperty<*>, value: Long) { + long = value + } +} + +interface IMutableBooleanProperty : IBooleanProperty { + operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Boolean) +} + +sealed interface IMutableBooleanField : IMutableField, IBooleanField, BooleanConsumer { + override var boolean: Boolean + override val property: IMutableBooleanProperty + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.boolean")) + override var value: Boolean + get() = boolean + set(value) { boolean = value } + + override fun accept(t: Boolean) { + boolean = t + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun getValue(thisRef: Any?, property: KProperty<*>): Boolean { + return boolean + } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun setValue(thisRef: Any?, property: KProperty<*>, value: Boolean) { + boolean = value + } +} diff --git a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FieldSynchronizerTests.kt b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FieldSynchronizerTests.kt index dae1dc541..001768a4e 100644 --- a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FieldSynchronizerTests.kt +++ b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FieldSynchronizerTests.kt @@ -3,8 +3,8 @@ package ru.dbotthepony.mc.otm.tests import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test -import ru.dbotthepony.mc.otm.network.FieldSynchronizer -import ru.dbotthepony.mc.otm.network.IMutableField +import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer +import ru.dbotthepony.mc.otm.network.synchronizer.IMutableField import java.io.ByteArrayInputStream object FieldSynchronizerTests { From 6b3e80b62977857d2c1170e619151d03f52236f6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Mar 2023 08:21:12 +0700 Subject: [PATCH 0390/1199] Make tick list even faster --- .../dbotthepony/mc/otm/core/util/TickList.kt | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt index 703e349e8..492a1d766 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt @@ -19,6 +19,8 @@ class TickList : ITickable { var ticks = 0 private set + private var nothingToDo = true + inner class Timer(val timerTicks: Int, val runnable: Runnable) { val ringAt = ticks + timerTicks @@ -26,6 +28,8 @@ class TickList : ITickable { private set init { + nothingToDo = false + if (timers.isEmpty()) { timers.addLast(this) } else { @@ -68,6 +72,7 @@ class TickList : ITickable { conditionalValveTime.add(ticker) } else { conditional.addFirst(ticker) + nothingToDo = false } } @@ -85,6 +90,7 @@ class TickList : ITickable { onceValveTime.add(ticker) } else { once.addFirst(ticker) + nothingToDo = false } } @@ -102,6 +108,7 @@ class TickList : ITickable { alwaysValveTime.add(ticker) } else { always.add(ticker) + nothingToDo = false } } @@ -131,6 +138,10 @@ class TickList : ITickable { IConditionalTickable.wrap(tickerCondition, ticker), condition, reason) override fun tick() { + if (nothingToDo) { + return + } + if (inTicker) { throw ConcurrentModificationException("Already ticking") } @@ -139,6 +150,15 @@ class TickList : ITickable { inTicker = true try { + var nothingToDo = true + val conditional = conditional + val once = once + val always = always + val alwaysValveTime = alwaysValveTime + val conditionalValveTime = conditionalValveTime + val onceValveTime = onceValveTime + val timers = timers + if (conditional.isNotEmpty()) { val iterator = conditional.iterator() @@ -147,6 +167,7 @@ class TickList : ITickable { iterator.remove() } else { ticker.tick() + nothingToDo = false } } } @@ -163,11 +184,14 @@ class TickList : ITickable { for (ticker in always) { ticker.tick() } + + nothingToDo = false } if (alwaysValveTime.isNotEmpty()) { always.addAll(alwaysValveTime) alwaysValveTime.clear() + nothingToDo = false } if (conditionalValveTime.isNotEmpty()) { @@ -176,6 +200,7 @@ class TickList : ITickable { } conditionalValveTime.clear() + nothingToDo = false } if (onceValveTime.isNotEmpty()) { @@ -184,9 +209,11 @@ class TickList : ITickable { } onceValveTime.clear() + nothingToDo = false } while (timers.isNotEmpty()) { + nothingToDo = false val head = timers.first() if (head.ringAt <= ticks) { @@ -196,6 +223,8 @@ class TickList : ITickable { break } } + + this.nothingToDo = nothingToDo } finally { inTicker = false } From fdae27844afdb68b56056a04f4434c50407a3efa Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Mar 2023 08:32:28 +0700 Subject: [PATCH 0391/1199] Reimagine IConditionalTickable --- .../mc/otm/core/util/IConditionalTickable.kt | 37 +++++++++---------- .../dbotthepony/mc/otm/core/util/ITickable.kt | 5 ++- .../dbotthepony/mc/otm/core/util/TickList.kt | 3 +- .../mc/otm/graph/Abstract6Graph.kt | 34 +++++------------ .../ru/dbotthepony/mc/otm/graph/Graph6Node.kt | 18 +++------ 5 files changed, 38 insertions(+), 59 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/IConditionalTickable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/IConditionalTickable.kt index 7a9491798..f100b383f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/IConditionalTickable.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/IConditionalTickable.kt @@ -1,35 +1,34 @@ package ru.dbotthepony.mc.otm.core.util +import java.util.function.BooleanSupplier + /** - * Represents tick callback with condition, once + * Represents something that can tick without any additional callback, + * with sign whenever can it tick more */ -interface IConditionalTickable : ITickable { +fun interface IConditionalTickable { /** - * Once this returns false, it should stay false. + * Function to be called by tick executors * - * If it suddenly turns true after being false, result is undefined. + * Once this returns false, ticker is considered finished, and should be removed from ticking list */ - val canTick: Boolean + fun tick(): Boolean companion object { - fun wrap(ticker: () -> Boolean): IConditionalTickable { - return object : IConditionalTickable { - override var canTick: Boolean = true - private set + fun wrap(ticker: () -> Boolean): IConditionalTickable = IConditionalTickable { ticker.invoke() } + fun wrap(ticker: BooleanSupplier): IConditionalTickable = IConditionalTickable { ticker.asBoolean } - override fun tick() { - canTick = !ticker.invoke() - } + fun wrap(condition: () -> Boolean, ticker: () -> Unit): IConditionalTickable { + return IConditionalTickable { + ticker.invoke() + condition.invoke() } } - fun wrap(condition: () -> Boolean, ticker: () -> Unit): IConditionalTickable { - return object : IConditionalTickable { - override val canTick: Boolean get() = condition.invoke() - - override fun tick() { - ticker.invoke() - } + fun wrap(condition: BooleanSupplier, ticker: () -> Unit): IConditionalTickable { + return IConditionalTickable { + ticker.invoke() + condition.asBoolean } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ITickable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ITickable.kt index 80c55d765..97e828be0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ITickable.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ITickable.kt @@ -1,8 +1,11 @@ package ru.dbotthepony.mc.otm.core.util /** - * Represents tick callback + * Represents something that can tick without any additional context */ fun interface ITickable { + /** + * Function to be called by tick executors + */ fun tick() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt index 492a1d766..e7a95b0da 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt @@ -163,10 +163,9 @@ class TickList : ITickable { val iterator = conditional.iterator() for (ticker in iterator) { - if (!ticker.canTick) { + if (!ticker.tick()) { iterator.remove() } else { - ticker.tick() nothingToDo = false } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Abstract6Graph.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Abstract6Graph.kt index 794e61d1c..4a7b15557 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Abstract6Graph.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Abstract6Graph.kt @@ -27,19 +27,16 @@ abstract class Abstract6Graph : IConditionalTickable { abstract fun onNodeRemoved(node: Graph6Node) abstract fun onNodeAdded(node: Graph6Node) - override val canTick: Boolean - get() = nodes.size > 0 - - override fun tick() { + override fun tick(): Boolean { for (i in tickable.size - 1 downTo 0) { val node = tickable[i] - if (node.canTick) { - node.tick() - } else { + if (!node.tick()) { tickable.removeAt(i) } } + + return nodes.size > 0 } fun removeNode(node: Graph6Node) { @@ -48,10 +45,7 @@ abstract class Abstract6Graph : IConditionalTickable { node.graph = null onNodeRemoved(node) - - if (node.canTick) { - tickable.remove(node) - } + tickable.remove(node) } fun addNode(node: Graph6Node) { @@ -61,10 +55,7 @@ abstract class Abstract6Graph : IConditionalTickable { nodes.add(node) node.graph = this onNodeAdded(node) - - if (node.canTick) { - tickable.add(node) - } + tickable.add(node) } fun merge(other: Abstract6Graph): Abstract6Graph { @@ -92,16 +83,9 @@ abstract class Abstract6Graph : IConditionalTickable { nodeGetter: (BlockEntity) -> Graph6Node?, factory: () -> Abstract6Graph ) { - level.addTicker(object : IConditionalTickable { - override fun tick() { - discovered = discover(level, blockPos, node, nodeGetter, factory) - } - - private var discovered = false - - override val canTick: Boolean - get() = !discovered && node.valid - }) + level.addTicker { + !discover(level, blockPos, node, nodeGetter, factory) && node.valid + } } @JvmStatic diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Graph6Node.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Graph6Node.kt index c8b12be6b..2ca4c3e02 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Graph6Node.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Graph6Node.kt @@ -185,20 +185,14 @@ class Graph6Node(@JvmField val value: T, graph: Abstract6Graph? = null) : } } - override val canTick: Boolean - get() { - return if (value is IConditionalTickable) { - value.canTick - } else { - value is ITickable - } - } - - override fun tick() { - if (value is ITickable) { + override fun tick(): Boolean { + if (value is IConditionalTickable) { + return value.tick() + } else if (value is ITickable) { value.tick() + return true } else { - throw ClassCastException("$value is not tickable") + return false } } From 743f9b64f166b816c9e412f15bef463055b12474 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Mar 2023 08:42:07 +0700 Subject: [PATCH 0392/1199] Surprised FloatSupplier does not exist in either fastutil nor java base loal --- .../kotlin/ru/dbotthepony/mc/otm/core/FloatSupplier.kt | 5 +++++ .../mc/otm/network/synchronizer/FieldSynchronizer.kt | 7 +++---- .../ru/dbotthepony/mc/otm/network/synchronizer/Fields.kt | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/FloatSupplier.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/FloatSupplier.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/FloatSupplier.kt new file mode 100644 index 000000000..79c5bdd98 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/FloatSupplier.kt @@ -0,0 +1,5 @@ +package ru.dbotthepony.mc.otm.core + +fun interface FloatSupplier { + fun getAsFloat(): Float +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt index e7e65743e..da6aa38ce 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt @@ -8,7 +8,6 @@ import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream import it.unimi.dsi.fastutil.objects.Reference2ObjectFunction import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.ReferenceArraySet -import mekanism.api.functions.FloatSupplier import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.collect.ProxiedMap @@ -1078,7 +1077,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa override fun observe(): Boolean { check(!isRemoved) { "Field was removed" } - val value = getter.asFloat + val value = getter.getAsFloat() if (!isDirty && (!isRemoteSet || remote != value)) { notifyEndpoints(this) @@ -1101,13 +1100,13 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa if (isClientValue) { return clientValue } else { - return getter.asFloat + return getter.getAsFloat() } } override fun write(stream: DataOutputStream, endpoint: Endpoint) { check(!isRemoved) { "Field was removed" } - stream.writeFloat(getter.asFloat) + stream.writeFloat(getter.getAsFloat()) isDirty = false } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/Fields.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/Fields.kt index 2985be01a..3cbfeb41b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/Fields.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/Fields.kt @@ -1,6 +1,6 @@ package ru.dbotthepony.mc.otm.network.synchronizer -import mekanism.api.functions.FloatSupplier +import ru.dbotthepony.mc.otm.core.FloatSupplier import java.io.DataInputStream import java.io.DataOutputStream import java.util.function.BooleanSupplier From d32cffe86b847d1117dd88cef84448471b332f67 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Mar 2023 11:14:37 +0700 Subject: [PATCH 0393/1199] Fix binding android wheel to mouse button breaking everything --- .../mc/otm/client/AndroidMenuKeyMapping.kt | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt index 4ab602abd..277289b7c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt @@ -45,6 +45,20 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon private var clickOnce = false + private fun resetState() { + selectedFeature = null + lastSelectedFeature = null + lastSelectedDegree = null + lastSelectProgress.clear() + clickOnce = false + holdIt = null + } + + private fun ohNoIHaveHitSomethingNastyInMinecraftCode() { + grabbedInput = false + resetState() + } + override fun setDown(isDown: Boolean) { val old = this.isDown super.setDown(isDown) @@ -77,17 +91,24 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon } } - selectedFeature = null - lastSelectedFeature = null - lastSelectedDegree = null - lastSelectProgress.clear() - clickOnce = false - holdIt = null + resetState() } } fun onMouseClick(event: InputEvent.MouseButton.Pre) { + // fix binding wheel menu to mouse button not calling back setIsDown(false) + if (isDown && event.action == 0 && key.type == InputConstants.Type.MOUSE && InputConstants.Type.MOUSE.getOrCreate(event.button) == key) { + isDown = false + return + } + if (grabbedInput) { + if (minecraft.screen != null) { + // whoopsie + ohNoIHaveHitSomethingNastyInMinecraftCode() + return + } + clickOnce = true event.isCanceled = true @@ -298,7 +319,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon renderWheel(event) if (minecraft.screen != null) { - isDown = false + ohNoIHaveHitSomethingNastyInMinecraftCode() } } } From 9a841bf43bc359c89360ea23e628335511c3f4d3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Mar 2023 11:41:19 +0700 Subject: [PATCH 0394/1199] Specify type specific properties of some field synchronizer users --- .../mc/otm/block/entity/RedstoneControl.kt | 4 ++-- .../matter/MatterCapacitorBankBlockEntity.kt | 2 +- .../entity/tech/BatteryBankBlockEntity.kt | 4 ++-- .../client/render/blockentity/BankRenderer.kt | 9 +++++---- .../mc/otm/core/util/DataStreams.kt | 20 +++++++++---------- .../mc/otm/menu/tech/EssenceStorageMenu.kt | 2 +- 6 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt index 8316ed787..e49245b47 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt @@ -77,7 +77,7 @@ class SynchronizedRedstoneControl( }) override var redstoneSignal: Int by synchronizer.int(0, setter = { value, access, setByRemote -> - if (access.read() == value) return@int + if (access.readInt() == value) return@int if (setByRemote) { access.write(value) } else { @@ -86,5 +86,5 @@ class SynchronizedRedstoneControl( val state = isBlockedByRedstone valueChanges.invoke(state, old) } - }) + }).property } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt index 986da9232..78f70be78 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt @@ -24,7 +24,7 @@ import ru.dbotthepony.mc.otm.menu.matter.MatterCapacitorBankMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.MATTER_CAPACITOR_BANK, p_155229_, p_155230_), IMatterGraphNode, IMatterStorage { - var gaugeLevel by synchronizer.float() + var gaugeLevel by synchronizer.float().property private set override val matterNode = Graph6Node(this) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index 21a3300ec..f60c07021 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -23,14 +23,14 @@ import ru.dbotthepony.mc.otm.menu.tech.BatteryBankMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.BATTERY_BANK, p_155229_, p_155230_), IMatteryEnergyStorage { - var gaugeLevel by synchronizer.float() + var gaugeLevel by synchronizer.float().property private set // 6 на 2 val container: MatteryContainer = object : MatteryContainer(::setChanged, CAPACITY) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { super.setChanged(slot, new, old) - batteryStatus[slot].value = new.getCapability(ForgeCapabilities.ENERGY).isPresent + batteryStatus[slot].boolean = new.getCapability(ForgeCapabilities.ENERGY).isPresent gaugeLevel = (batteryLevel / maxBatteryLevel).toFloat() } }.also(::addDroppableContainer) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt index f83d5ef4d..bc4e42e8d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt @@ -26,6 +26,7 @@ import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.core.math.rotate import ru.dbotthepony.mc.otm.core.math.rotateY import ru.dbotthepony.mc.otm.nanoTime +import java.util.function.BooleanSupplier import java.util.function.Supplier import kotlin.math.PI @@ -33,7 +34,7 @@ abstract class BankRenderer(private val context: B protected abstract fun gaugeLevel(entity: T): Float protected abstract val texture: AbstractMatterySprite protected abstract val models: List - protected abstract fun status(entity: T): List> + protected abstract fun status(entity: T): List private val random = XoroshiroRandomSource(nanoTime) @@ -53,7 +54,7 @@ abstract class BankRenderer(private val context: B stack.translate(-0.5f, -0.5f, -0.5f) for ((i, model) in models.withIndex()) { - if (!status[i].get()) { + if (!status[i].asBoolean) { continue } @@ -122,7 +123,7 @@ class BatteryBankRenderer(context: BlockEntityRendererProvider.Context) : BankRe } } - override fun status(entity: BatteryBankBlockEntity): List> { + override fun status(entity: BatteryBankBlockEntity): List { return entity.batteryStatus } @@ -149,7 +150,7 @@ class MatterBatteryBankRenderer(context: BlockEntityRendererProvider.Context) : } } - override fun status(entity: MatterCapacitorBankBlockEntity): List> { + override fun status(entity: MatterCapacitorBankBlockEntity): List { return entity.capacitorStatus } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt index b5b81aa6d..4aeb78a21 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt @@ -104,20 +104,20 @@ class StreamCodec( } val NullValueCodec = StreamCodec({ _, _ -> null }, { _, _ -> }) -val BooleanValueCodec = StreamCodec(DataInputStream::readBoolean, 1L, DataOutputStream::writeBoolean) -val ByteValueCodec = StreamCodec(DataInputStream::readByte, 1L, { s, v -> s.writeByte(v.toInt()) }) -val ShortValueCodec = StreamCodec(DataInputStream::readShort, 2L, { s, v -> s.writeShort(v.toInt()) }) -val IntValueCodec = StreamCodec(DataInputStream::readInt, 4L, DataOutputStream::writeInt) -val LongValueCodec = StreamCodec(DataInputStream::readLong, 8L, DataOutputStream::writeLong) -val FloatValueCodec = StreamCodec(DataInputStream::readFloat, 4L, DataOutputStream::writeFloat) -val DoubleValueCodec = StreamCodec(DataInputStream::readDouble, 8L, DataOutputStream::writeDouble) +val BooleanValueCodec = StreamCodec(DataInputStream::readBoolean, 1L, DataOutputStream::writeBoolean) { a, b -> a == b } +val ByteValueCodec = StreamCodec(DataInputStream::readByte, 1L, { s, v -> s.writeByte(v.toInt()) }) { a, b -> a == b } +val ShortValueCodec = StreamCodec(DataInputStream::readShort, 2L, { s, v -> s.writeShort(v.toInt()) }) { a, b -> a == b } +val IntValueCodec = StreamCodec(DataInputStream::readInt, 4L, DataOutputStream::writeInt) { a, b -> a == b } +val LongValueCodec = StreamCodec(DataInputStream::readLong, 8L, DataOutputStream::writeLong) { a, b -> a == b } +val FloatValueCodec = StreamCodec(DataInputStream::readFloat, 4L, DataOutputStream::writeFloat) { a, b -> a == b } +val DoubleValueCodec = StreamCodec(DataInputStream::readDouble, 8L, DataOutputStream::writeDouble) { a, b -> a == b } val ItemStackValueCodec = StreamCodec(DataInputStream::readItem, DataOutputStream::writeItem, ItemStack::copy) { a, b -> a.equals(b, true) } -val ItemValueCodec = StreamCodec(DataInputStream::readItemType, DataOutputStream::writeItemType) +val ItemValueCodec = StreamCodec(DataInputStream::readItemType, DataOutputStream::writeItemType) { a, b -> a === b } val DecimalValueCodec = StreamCodec(DataInputStream::readDecimal, DataOutputStream::writeDecimal) val BigDecimalValueCodec = StreamCodec(DataInputStream::readBigDecimal, DataOutputStream::writeBigDecimal) val UUIDValueCodec = StreamCodec({ s, a -> a.accountBytes(8L); UUID(s.readLong(), s.readLong()) }, { s, v -> s.writeLong(v.mostSignificantBits); s.writeLong(v.leastSignificantBits) }) -val VarIntValueCodec = StreamCodec(DataInputStream::readVarIntLE, DataOutputStream::writeVarIntLE) -val VarLongValueCodec = StreamCodec(DataInputStream::readVarLongLE, DataOutputStream::writeVarLongLE) +val VarIntValueCodec = StreamCodec(DataInputStream::readVarIntLE, DataOutputStream::writeVarIntLE) { a, b -> a == b } +val VarLongValueCodec = StreamCodec(DataInputStream::readVarLongLE, DataOutputStream::writeVarLongLE) { a, b -> a == b } val BinaryStringCodec = StreamCodec(DataInputStream::readBinaryString, DataOutputStream::writeBinaryString) class EnumValueCodec>(clazz: Class) : IStreamCodec, Codec { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt index 5a0b03b24..f0b88e85a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt @@ -21,7 +21,7 @@ class EssenceStorageMenu @JvmOverloads constructor( inventory: Inventory, tile: EssenceStorageBlockEntity? = null ) : MatteryMenu(MMenus.ESSENCE_STORAGE, containerID, inventory, tile) { - val experienceStored by mSynchronizer.ComputedField(getter = { tile?.experienceStored ?: 0L }, LongValueCodec) + val experienceStored by mSynchronizer.ComputedLongField(getter = { tile?.experienceStored ?: 0L }) val capsuleSlot = object : MatterySlot(tile?.capsuleContainer ?: SimpleContainer(1), 0) { override fun mayPlace(itemStack: ItemStack): Boolean { From 982554d2f0fc1d062a08240cf1a6b8fb9d7b5a51 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Mar 2023 14:11:39 +0700 Subject: [PATCH 0395/1199] Fix computed boolean field being ambiguous --- .../dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt | 4 ++-- src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 2 +- .../mc/otm/menu/input/BooleanInputWithFeedback.kt | 3 ++- .../dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt | 2 +- .../mc/otm/menu/input/StringInputWithFeedback.kt | 2 +- .../dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt | 2 +- .../mc/otm/network/synchronizer/FieldSynchronizer.kt | 6 +++--- 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt index 2fa707c29..8b1651eba 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt @@ -7,7 +7,7 @@ import ru.dbotthepony.mc.otm.core.nbt.set abstract class AndroidSwitchableFeature(type: AndroidFeatureType<*>, android: MatteryPlayerCapability) : AndroidFeature(type, android) { var isActive by synchronizer.bool(setter = setter@{ value, access, setByRemote -> - if (value != access.read()) { + if (value != access.readBoolean()) { access.write(value) if (!setByRemote) { @@ -18,7 +18,7 @@ abstract class AndroidSwitchableFeature(type: AndroidFeatureType<*>, android: Ma } } } - }) + }).property open val allowToSwitchByPlayer: Boolean get() = true open val allowToSwitchByPlayerWhileSpectator: Boolean get() = true diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index a0b080b93..fa3232943 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -113,7 +113,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( */ inner class PlayerInput(val codec: IStreamCodec, allowSpectators: Boolean = false, val handler: (V) -> Unit) : Predicate { val id = playerInputs.size - var allowSpectators by mSynchronizer.bool(allowSpectators) + var allowSpectators by mSynchronizer.bool(allowSpectators).property init { playerInputs.add(this) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/BooleanInputWithFeedback.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/BooleanInputWithFeedback.kt index 7d2346604..14291198f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/BooleanInputWithFeedback.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/BooleanInputWithFeedback.kt @@ -2,11 +2,12 @@ package ru.dbotthepony.mc.otm.menu.input import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.menu.MatteryMenu +import java.util.function.BooleanSupplier import kotlin.reflect.KMutableProperty0 class BooleanInputWithFeedback(menu: MatteryMenu) : AbstractPlayerInputWithFeedback() { override val input = menu.booleanInput { consumer?.invoke(it) } - override val value by menu.mSynchronizer.bool(getter = { supplier?.invoke() ?: false }) + override val value by menu.mSynchronizer.computedBool(BooleanSupplier { supplier?.invoke() ?: false }) constructor(menu: MatteryMenu, state: KMutableProperty0) : this(menu) { with(state) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt index c565c407e..12d721a50 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt @@ -10,7 +10,7 @@ import ru.dbotthepony.mc.otm.menu.MatteryMenu */ class ItemHandlerPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = false, val allowPush: Boolean = false) { private val allowedFlags = MatteryDeviceBlockEntity.ItemHandlerMode.values().map { menu.mSynchronizer.bool() to it } - fun isAllowed(value: MatteryDeviceBlockEntity.ItemHandlerMode) = allowedFlags[value.ordinal].first.value + fun isAllowed(value: MatteryDeviceBlockEntity.ItemHandlerMode) = allowedFlags[value.ordinal].first.boolean inner class Piece(val side: RelativeSide) { fun isAllowed(value: MatteryDeviceBlockEntity.ItemHandlerMode) = this@ItemHandlerPlayerInput.isAllowed(value) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/StringInputWithFeedback.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/StringInputWithFeedback.kt index 891ba3021..fb4f7760d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/StringInputWithFeedback.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/StringInputWithFeedback.kt @@ -6,7 +6,7 @@ import kotlin.reflect.KMutableProperty0 class StringInputWithFeedback(menu: MatteryMenu) : AbstractPlayerInputWithFeedback() { override val input = menu.stringInput { consumer?.invoke(it.replace('\u0000', ' ')) } - override val value by menu.mSynchronizer.string(getter = { supplier?.invoke() ?: "" }) + override val value by menu.mSynchronizer.string { supplier?.invoke() ?: "" } constructor(menu: MatteryMenu, state: KMutableProperty0) : this(menu) { with(state) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt index 035afb526..148a968e9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt @@ -7,7 +7,7 @@ class ProgressGaugeWidget(menu: MatteryMenu) : AbstractWidget(menu) { var progress = {0f} var stuck = {false} var progressContainer by menu.mSynchronizer.short() - var stuckContainer by menu.mSynchronizer.bool() + var stuckContainer by menu.mSynchronizer.bool().property constructor( menu: MatteryMenu, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt index da6aa38ce..6f9bac7c5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt @@ -88,7 +88,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } fun byte(getter: () -> Byte) = ComputedField(getter, ByteValueCodec) - fun bool(getter: BooleanSupplier) = ComputedBooleanField(getter) + fun computedBool(getter: BooleanSupplier) = ComputedBooleanField(getter) fun short(getter: () -> Short) = ComputedField(getter, ShortValueCodec) fun long(getter: LongSupplier) = ComputedLongField(getter) fun fixedLong(getter: LongSupplier) = ComputedFixedLongField(getter) @@ -103,7 +103,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa fun string(getter: () -> String) = ComputedField(getter, BinaryStringCodec) fun byte(getter: KProperty0) = ComputedField(getter, ByteValueCodec) - fun bool(getter: KProperty0) = ComputedBooleanField(getter::get) + fun computedBool(getter: KProperty0) = ComputedBooleanField(getter::get) fun short(getter: KProperty0) = ComputedField(getter, ShortValueCodec) fun long(getter: KProperty0) = ComputedLongField(getter::get) fun fixedLong(getter: KProperty0) = ComputedFixedLongField(getter::get) @@ -118,7 +118,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa fun string(getter: KProperty0) = ComputedField(getter, BinaryStringCodec) fun byte(getter: Supplier) = ComputedField(getter::get, ByteValueCodec) - fun bool(getter: Supplier) = ComputedBooleanField(getter::get) + fun computedBool(getter: Supplier) = ComputedBooleanField(getter::get) fun short(getter: Supplier) = ComputedField(getter::get, ShortValueCodec) fun long(getter: Supplier) = ComputedLongField(getter::get) fun fixedLong(getter: Supplier) = ComputedFixedLongField(getter::get) From f68d3e749d5b8bd1550592f72db2a108cad830e4 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Mar 2023 14:25:21 +0700 Subject: [PATCH 0396/1199] Rename computed field factories to be prefixed with computed to avoid shooting in foot --- .../otm/menu/input/StringInputWithFeedback.kt | 2 +- .../network/synchronizer/FieldSynchronizer.kt | 90 +++++++++---------- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/StringInputWithFeedback.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/StringInputWithFeedback.kt index fb4f7760d..9d918dd2d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/StringInputWithFeedback.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/StringInputWithFeedback.kt @@ -6,7 +6,7 @@ import kotlin.reflect.KMutableProperty0 class StringInputWithFeedback(menu: MatteryMenu) : AbstractPlayerInputWithFeedback() { override val input = menu.stringInput { consumer?.invoke(it.replace('\u0000', ' ')) } - override val value by menu.mSynchronizer.string { supplier?.invoke() ?: "" } + override val value by menu.mSynchronizer.computedString { supplier?.invoke() ?: "" } constructor(menu: MatteryMenu, state: KMutableProperty0) : this(menu) { with(state) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt index 6f9bac7c5..a4b68d91f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt @@ -87,59 +87,59 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa hasChanges = false } - fun byte(getter: () -> Byte) = ComputedField(getter, ByteValueCodec) + fun computedByte(getter: () -> Byte) = ComputedField(getter, ByteValueCodec) fun computedBool(getter: BooleanSupplier) = ComputedBooleanField(getter) - fun short(getter: () -> Short) = ComputedField(getter, ShortValueCodec) - fun long(getter: LongSupplier) = ComputedLongField(getter) - fun fixedLong(getter: LongSupplier) = ComputedFixedLongField(getter) - fun float(getter: FloatSupplier) = ComputedFloatField(getter) - fun double(getter: DoubleSupplier) = ComputedDoubleField(getter) - fun uuid(getter: () -> UUID) = ComputedField(getter, UUIDValueCodec) - fun int(getter: IntSupplier) = ComputedIntField(getter) - fun fixedInt(getter: IntSupplier) = ComputedFixedIntField(getter) - fun fraction(getter: () -> Decimal) = ComputedField(getter, DecimalValueCodec) - fun bigDecimal(getter: () -> BigDecimal) = ComputedField(getter, BigDecimalValueCodec) - fun item(getter: () -> ItemStack) = ComputedField(getter, ItemStackValueCodec) - fun string(getter: () -> String) = ComputedField(getter, BinaryStringCodec) + fun computedShort(getter: () -> Short) = ComputedField(getter, ShortValueCodec) + fun computedLong(getter: LongSupplier) = ComputedLongField(getter) + fun computedFixedLong(getter: LongSupplier) = ComputedFixedLongField(getter) + fun computedFloat(getter: FloatSupplier) = ComputedFloatField(getter) + fun computedDouble(getter: DoubleSupplier) = ComputedDoubleField(getter) + fun computedUuid(getter: () -> UUID) = ComputedField(getter, UUIDValueCodec) + fun computedInt(getter: IntSupplier) = ComputedIntField(getter) + fun computedFixedInt(getter: IntSupplier) = ComputedFixedIntField(getter) + fun computedDecimal(getter: () -> Decimal) = ComputedField(getter, DecimalValueCodec) + fun computedBigDecimal(getter: () -> BigDecimal) = ComputedField(getter, BigDecimalValueCodec) + fun computedItem(getter: () -> ItemStack) = ComputedField(getter, ItemStackValueCodec) + fun computedString(getter: () -> String) = ComputedField(getter, BinaryStringCodec) - fun byte(getter: KProperty0) = ComputedField(getter, ByteValueCodec) + fun computedByte(getter: KProperty0) = ComputedField(getter, ByteValueCodec) fun computedBool(getter: KProperty0) = ComputedBooleanField(getter::get) - fun short(getter: KProperty0) = ComputedField(getter, ShortValueCodec) - fun long(getter: KProperty0) = ComputedLongField(getter::get) - fun fixedLong(getter: KProperty0) = ComputedFixedLongField(getter::get) - fun float(getter: KProperty0) = ComputedFloatField(getter::get) - fun double(getter: KProperty0) = ComputedDoubleField(getter::get) - fun uuid(getter: KProperty0) = ComputedField(getter, UUIDValueCodec) - fun int(getter: KProperty0) = ComputedIntField(getter::get) - fun fixedInt(getter: KProperty0) = ComputedFixedIntField(getter::get) - fun fraction(getter: KProperty0) = ComputedField(getter, DecimalValueCodec) - fun bigDecimal(getter: KProperty0) = ComputedField(getter, BigDecimalValueCodec) - fun item(getter: KProperty0) = ComputedField(getter, ItemStackValueCodec) - fun string(getter: KProperty0) = ComputedField(getter, BinaryStringCodec) + fun computedShort(getter: KProperty0) = ComputedField(getter, ShortValueCodec) + fun computedLong(getter: KProperty0) = ComputedLongField(getter::get) + fun computedFixedLong(getter: KProperty0) = ComputedFixedLongField(getter::get) + fun computedFloat(getter: KProperty0) = ComputedFloatField(getter::get) + fun computedDouble(getter: KProperty0) = ComputedDoubleField(getter::get) + fun computedUuid(getter: KProperty0) = ComputedField(getter, UUIDValueCodec) + fun computedInt(getter: KProperty0) = ComputedIntField(getter::get) + fun computedFixedInt(getter: KProperty0) = ComputedFixedIntField(getter::get) + fun computedDecimal(getter: KProperty0) = ComputedField(getter, DecimalValueCodec) + fun computedBigDecimal(getter: KProperty0) = ComputedField(getter, BigDecimalValueCodec) + fun computedItem(getter: KProperty0) = ComputedField(getter, ItemStackValueCodec) + fun computedString(getter: KProperty0) = ComputedField(getter, BinaryStringCodec) - fun byte(getter: Supplier) = ComputedField(getter::get, ByteValueCodec) + fun computedByte(getter: Supplier) = ComputedField(getter::get, ByteValueCodec) fun computedBool(getter: Supplier) = ComputedBooleanField(getter::get) - fun short(getter: Supplier) = ComputedField(getter::get, ShortValueCodec) - fun long(getter: Supplier) = ComputedLongField(getter::get) - fun fixedLong(getter: Supplier) = ComputedFixedLongField(getter::get) - fun float(getter: Supplier) = ComputedFloatField(getter::get) - fun double(getter: Supplier) = ComputedDoubleField(getter::get) - fun uuid(getter: Supplier) = ComputedField(getter::get, UUIDValueCodec) - fun int(getter: Supplier) = ComputedIntField(getter::get) - fun fixedInt(getter: Supplier) = ComputedFixedIntField(getter::get) - fun fraction(getter: Supplier) = ComputedField(getter::get, DecimalValueCodec) - fun bigDecimal(getter: Supplier) = ComputedField(getter::get, BigDecimalValueCodec) - fun item(getter: Supplier) = ComputedField(getter::get, ItemStackValueCodec) - fun string(getter: Supplier) = ComputedField(getter::get, BinaryStringCodec) + fun computedShort(getter: Supplier) = ComputedField(getter::get, ShortValueCodec) + fun computedLong(getter: Supplier) = ComputedLongField(getter::get) + fun computedFixedLong(getter: Supplier) = ComputedFixedLongField(getter::get) + fun computedFloat(getter: Supplier) = ComputedFloatField(getter::get) + fun computedDouble(getter: Supplier) = ComputedDoubleField(getter::get) + fun computedUuid(getter: Supplier) = ComputedField(getter::get, UUIDValueCodec) + fun computedInt(getter: Supplier) = ComputedIntField(getter::get) + fun computedFixedInt(getter: Supplier) = ComputedFixedIntField(getter::get) + fun computedDecimal(getter: Supplier) = ComputedField(getter::get, DecimalValueCodec) + fun computedBigDecimal(getter: Supplier) = ComputedField(getter::get, BigDecimalValueCodec) + fun computedItem(getter: Supplier) = ComputedField(getter::get, ItemStackValueCodec) + fun computedString(getter: Supplier) = ComputedField(getter::get, BinaryStringCodec) - fun > enum(type: Class, getter: () -> T) = ComputedField(getter, EnumValueCodec(type)) - inline fun > enum(noinline getter: () -> T) = ComputedField(getter, EnumValueCodec(T::class.java)) + fun > computedEnum(type: Class, getter: () -> T) = ComputedField(getter, EnumValueCodec(type)) + inline fun > computedEnum(noinline getter: () -> T) = ComputedField(getter, EnumValueCodec(T::class.java)) - fun > enum(type: Class, getter: KProperty0) = ComputedField(getter, EnumValueCodec(type)) - inline fun > enum(getter: KProperty0) = ComputedField(getter, EnumValueCodec(T::class.java)) + fun > computedEnum(type: Class, getter: KProperty0) = ComputedField(getter, EnumValueCodec(type)) + inline fun > computedEnum(getter: KProperty0) = ComputedField(getter, EnumValueCodec(T::class.java)) - fun > enum(type: Class, getter: Supplier) = ComputedField(getter::get, EnumValueCodec(type)) - inline fun > enum(getter: Supplier) = ComputedField(getter::get, EnumValueCodec(T::class.java)) + fun > computedEnum(type: Class, getter: Supplier) = ComputedField(getter::get, EnumValueCodec(type)) + inline fun > computedEnum(getter: Supplier) = ComputedField(getter::get, EnumValueCodec(T::class.java)) @JvmOverloads fun byte( From 2314b7d91c8bbd53b314f15aa3e123d3354ab94f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Mar 2023 14:47:29 +0700 Subject: [PATCH 0397/1199] a --- .../ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt index 342e21dc2..c230f0066 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt @@ -16,8 +16,8 @@ import top.theillusivec4.curios.api.CuriosApi import top.theillusivec4.curios.api.event.SlotModifiersUpdatedEvent import top.theillusivec4.curios.common.inventory.CosmeticCurioSlot import top.theillusivec4.curios.common.inventory.CurioSlot -import java.util.* import java.util.stream.Stream +import kotlin.collections.ArrayList val isCuriosLoaded by lazy { ModList.get().isLoaded(CuriosApi.MODID) @@ -77,7 +77,7 @@ val Player.curiosSlots: List> get() { private fun Player.curiosStreamImpl(includeCosmetics: Boolean): Stream { val handler = getCapability(MatteryCapability.CURIOS_INVENTORY).orNull() ?: return Stream.empty() - val result = LinkedList>() + val result = ArrayList>() for ((identifier, curio) in handler.curios) { result.add(curio.stacks.stream()) @@ -101,7 +101,7 @@ fun Player.curiosStream(includeCosmetics: Boolean = true): Stream private fun Player.curiosAwareStreamImpl(includeCosmetics: Boolean): Stream { val handler = getCapability(MatteryCapability.CURIOS_INVENTORY).orNull() ?: return Stream.empty() - val result = LinkedList>() + val result = ArrayList>() for ((identifier, curio) in handler.curios) { result.add(curio.stacks.awareStream()) From 90e6fe5f5d1bd26c7513ca5b957c5a5794bb6cf8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Mar 2023 15:13:53 +0700 Subject: [PATCH 0398/1199] Greatly buff android attack boost --- src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt | 2 +- .../ru/dbotthepony/mc/otm/android/feature/AttackBoostFeature.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt index b800419d7..d2ea2ca9b 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt @@ -152,7 +152,7 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang .withDescription( TranslatableComponent( "android_research.overdrive_that_matters.attack_boost.description", - (i + 1) * 6 + (i + 1) * 12 ) ) .addFeatureResult(AndroidFeatures.ATTACK_BOOST, i) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/AttackBoostFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/AttackBoostFeature.kt index 6f1df894e..b0b3a0877 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/AttackBoostFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/AttackBoostFeature.kt @@ -13,7 +13,7 @@ class AttackBoostFeature(android: MatteryPlayerCapability) : AndroidFeature(Andr if (modifier != null) { modifier.removePermanentModifier(MODIFIER_ID) - modifier.addPermanentModifier(AttributeModifier(MODIFIER_ID, type.displayName.toString(), (level + 1) * 0.06, AttributeModifier.Operation.MULTIPLY_TOTAL)) + modifier.addPermanentModifier(AttributeModifier(MODIFIER_ID, type.displayName.toString(), (level + 1) * 0.12, AttributeModifier.Operation.MULTIPLY_TOTAL)) } } From e01d319517633af280fdf36747e6186003b30ea0 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Mar 2023 15:21:13 +0700 Subject: [PATCH 0399/1199] Typo --- src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index afbde691b..5aaf415a2 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -323,7 +323,7 @@ private fun misc(provider: MatteryLanguageProvider) { misc("item.quantum_battery.creative_power", "Stored energy: %s / Infinity") misc("item.quantum_link_id", "Quantum link ID: %s") - misc("item.quantum_description", "This item is sharing it's contents with other similar items using quantum entanglement") + misc("item.quantum_description", "This item is sharing its contents with other similar items using quantum entanglement") } } From 24aa9bfcbcb9525c5e3e0b8968da0e63fe65923b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Mar 2023 15:22:46 +0700 Subject: [PATCH 0400/1199] =?UTF-8?q?Add=20missing=20=E2=88=9E=20to=20quan?= =?UTF-8?q?tum=20creative=20battery?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 5aaf415a2..cb3de77d3 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -320,7 +320,7 @@ private fun misc(provider: MatteryLanguageProvider) { misc("item.quantum_battery.creative", "Fill this to win Minecraft.") misc("item.quantum_battery.creative2", "See ya after millions of stars burn out.") - misc("item.quantum_battery.creative_power", "Stored energy: %s / Infinity") + misc("item.quantum_battery.creative_power", "Stored energy: %s / ∞") misc("item.quantum_link_id", "Quantum link ID: %s") misc("item.quantum_description", "This item is sharing its contents with other similar items using quantum entanglement") From fcd1de644a2ccc790fbf8ec1d8c6d329c1800b5a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Mar 2023 15:27:15 +0700 Subject: [PATCH 0401/1199] Fix nanobots armor almost instantly regenerating all armor layers --- .../mc/otm/android/feature/NanobotsArmorFeature.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt index 168b402a8..268f86caf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt @@ -22,13 +22,13 @@ class NanobotsArmorFeature(android: MatteryPlayerCapability) : AndroidFeature(An setter = setter@{ value, access, _ -> access.write(value.coerceIn(0 .. 3)) } - ) + ).property var speed: Int = 0 set(value) { field = value.coerceIn(0 .. 3) } private var ticksPassed = 0 - var layers by synchronizer.int() + var layers by synchronizer.int().property override fun tickServer() { if (layers < strength + 1 && android.androidEnergy.extractEnergyExact(ENERGY_PER_LAYER, true)) { @@ -37,6 +37,7 @@ class NanobotsArmorFeature(android: MatteryPlayerCapability) : AndroidFeature(An if (ticksPassed >= TICKS[speed]) { layers++ android.androidEnergy.extractEnergy(ENERGY_PER_LAYER, false) + ticksPassed = 0 } } else { ticksPassed = 0 From 4068444e63351596db5dfde81a2913314513a8ce Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Mar 2023 15:28:03 +0700 Subject: [PATCH 0402/1199] Buff attack boost even more --- src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt | 2 +- .../ru/dbotthepony/mc/otm/android/feature/AttackBoostFeature.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt index d2ea2ca9b..5d8dc61b8 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt @@ -152,7 +152,7 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang .withDescription( TranslatableComponent( "android_research.overdrive_that_matters.attack_boost.description", - (i + 1) * 12 + (i + 1) * 15 ) ) .addFeatureResult(AndroidFeatures.ATTACK_BOOST, i) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/AttackBoostFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/AttackBoostFeature.kt index b0b3a0877..b04db591f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/AttackBoostFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/AttackBoostFeature.kt @@ -13,7 +13,7 @@ class AttackBoostFeature(android: MatteryPlayerCapability) : AndroidFeature(Andr if (modifier != null) { modifier.removePermanentModifier(MODIFIER_ID) - modifier.addPermanentModifier(AttributeModifier(MODIFIER_ID, type.displayName.toString(), (level + 1) * 0.12, AttributeModifier.Operation.MULTIPLY_TOTAL)) + modifier.addPermanentModifier(AttributeModifier(MODIFIER_ID, type.displayName.toString(), (level + 1) * 0.15, AttributeModifier.Operation.MULTIPLY_TOTAL)) } } From ce224d6fe755a1bb64fe38a5152653d70d8fe802 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Mar 2023 16:20:23 +0700 Subject: [PATCH 0403/1199] Remove the most useless mob in the game from ever spawning when not asked to --- .../mc/otm/capability/MatteryPlayerCapability.kt | 16 ++++++++++------ src/main/resources/coremods/code_injector.js | 12 ++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 05c431d45..c01b919b1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -55,6 +55,7 @@ import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.stream import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.collect.UUIDIntModifiersMap +import ru.dbotthepony.mc.otm.core.collect.filter import ru.dbotthepony.mc.otm.core.collect.nonEmpty import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.minus @@ -79,6 +80,7 @@ import ru.dbotthepony.mc.otm.triggers.BecomeAndroidTrigger import ru.dbotthepony.mc.otm.triggers.BecomeHumaneTrigger import ru.dbotthepony.mc.otm.triggers.PhantomSpawnDeniedTrigger import java.util.* +import java.util.function.Predicate import java.util.stream.Stream import kotlin.collections.ArrayDeque import kotlin.collections.ArrayList @@ -1248,13 +1250,15 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial * hooked into PhantomSpawner through coremod script */ @JvmStatic - fun phantomSpawnHook(player: Player): Boolean { - if (player.matteryPlayer?.isAndroid == true) { - val feature = player.matteryPlayer?.getFeature(AndroidFeatures.PHANTOM_ATTRACTOR) as AndroidSwitchableFeature? - return feature?.isActive == true + fun phantomSpawnHook(iterator: Iterator): Iterator { + return iterator.filter { + if (it.matteryPlayer?.isAndroid == true) { + val feature = it.matteryPlayer?.getFeature(AndroidFeatures.PHANTOM_ATTRACTOR) as AndroidSwitchableFeature? + feature?.isActive == true + } else { + true + } } - - return true } fun canEntitySpawn(event: LivingSpawnEvent.CheckSpawn) { diff --git a/src/main/resources/coremods/code_injector.js b/src/main/resources/coremods/code_injector.js index 5de443d1f..040e5eacf 100644 --- a/src/main/resources/coremods/code_injector.js +++ b/src/main/resources/coremods/code_injector.js @@ -577,23 +577,19 @@ function backtrack(instructions, from, opcode, skipAmount) { function initializeCoreMod() { return { 'PhantomSpawner block spawns as android': method('net.minecraft.world.level.levelgen.PhantomSpawner.m_7995_(Lnet/minecraft/server/level/ServerLevel;ZZ)I', function(node) { - var isSpectator = ASMAPI.mapMethod('m_5833_') + var players = ASMAPI.mapMethod('m_6907_') for (var i = 0; i < node.instructions.size(); i++) { var instr = node.instructions.get(i) - if (instr.getOpcode() == opcodesRemapped.invokevirtual && instr.name == isSpectator) { - var aload = backtrack(node.instructions, i, opcodesRemapped.aload) - - putInstructions(node, instr, [ - new VarInsnNode(opcodesRemapped.aload, aload["var"]), + if (instr.getOpcode() == opcodesRemapped.invokevirtual && instr.name == players) { + putInstructions(node, node.instructions.get(i + 1), [ new MethodInsnNode( opcodesRemapped.invokestatic, 'ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability', 'phantomSpawnHook', - '(Lnet/minecraft/world/entity/player/Player;)Z' + '(Ljava/util/Iterator;)Ljava/util/Iterator;' ), - new InsnNode(opcodesRemapped.iand) ]) return node From 9f78291b79bd7d0dd5f3c00e2c1162295a6549c4 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Mar 2023 16:24:22 +0700 Subject: [PATCH 0404/1199] Remove "phantom not spawned" achievement --- .../advancements/AndroidAdvancementsData.kt | 25 +-------------- .../otm/capability/MatteryPlayerCapability.kt | 28 ---------------- .../dbotthepony/mc/otm/registry/MRegistry.kt | 1 - .../otm/triggers/PhantomSpawnDeniedTrigger.kt | 32 ------------------- 4 files changed, 1 insertion(+), 85 deletions(-) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/triggers/PhantomSpawnDeniedTrigger.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt index b560066f9..436127d29 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt @@ -4,24 +4,17 @@ import net.minecraft.advancements.Advancement import net.minecraft.advancements.AdvancementRewards import net.minecraft.advancements.FrameType import net.minecraft.advancements.RequirementsStrategy -import net.minecraft.advancements.critereon.DamagePredicate -import net.minecraft.advancements.critereon.DamageSourcePredicate import net.minecraft.advancements.critereon.EntityPredicate -import net.minecraft.advancements.critereon.InventoryChangeTrigger import net.minecraft.advancements.critereon.ItemPredicate import net.minecraft.advancements.critereon.MinMaxBounds.Doubles -import net.minecraft.advancements.critereon.PlayerHurtEntityTrigger -import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.EntityType import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraftforge.common.data.ExistingFileHelper -import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.datagen.DataGen import ru.dbotthepony.mc.otm.datagen.lang.MatteryLanguageProvider import ru.dbotthepony.mc.otm.datagen.modLocation import ru.dbotthepony.mc.otm.registry.AndroidFeatures -import ru.dbotthepony.mc.otm.registry.MItemTags import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.triggers.AndroidBatteryTrigger @@ -35,7 +28,6 @@ import ru.dbotthepony.mc.otm.triggers.EnderTeleporterFallDeathTrigger import ru.dbotthepony.mc.otm.triggers.FallDampenersSaveTrigger import ru.dbotthepony.mc.otm.triggers.KillAsAndroidTrigger import ru.dbotthepony.mc.otm.triggers.NanobotsArmorTrigger -import ru.dbotthepony.mc.otm.triggers.PhantomSpawnDeniedTrigger import ru.dbotthepony.mc.otm.triggers.ShockwaveDamageMobTrigger import ru.dbotthepony.mc.otm.triggers.ShockwaveTrigger import java.util.function.Consumer @@ -139,23 +131,8 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .addCriterion("become_humane", BecomeHumaneTrigger.Instance) .save(serializer, modLocation("android/become_humane"), existingFileHelper) - val phantoms = AdvancementBuilder() - .parent(root) - .display( - itemStack = ItemStack(Items.PHANTOM_MEMBRANE), - title = translation.add("phantom_spawn_denied", "Insomnia Immune") { - russian("Пере-бессоница") - }, - description = translation.add("phantom_spawn_denied.desc", "Have Phantoms not come after you because you are not someone who needs to sleep") { - russian("Не привлеките внимание Фантомов, так как вы не тот, кому надо спать") - }, - hidden = true - ) - .addCriterion("phantom_spawn_denied", PhantomSpawnDeniedTrigger.Instance) - .save(serializer, modLocation("android/phantom_spawn_denied"), existingFileHelper) - val attractor = AdvancementBuilder() - .parent(phantoms) + .parent(root) .display( itemStack = ItemStack(MItems.PHANTOM_ATTRACTOR), title = translation.add("phantom_attractor", "Eversleeping Decoy") { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index c01b919b1..276c8d165 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -78,9 +78,7 @@ import ru.dbotthepony.mc.otm.triggers.BecomeAndroidDeathTrigger import ru.dbotthepony.mc.otm.triggers.BecomeAndroidSleepTrigger import ru.dbotthepony.mc.otm.triggers.BecomeAndroidTrigger import ru.dbotthepony.mc.otm.triggers.BecomeHumaneTrigger -import ru.dbotthepony.mc.otm.triggers.PhantomSpawnDeniedTrigger import java.util.* -import java.util.function.Predicate import java.util.stream.Stream import kotlin.collections.ArrayDeque import kotlin.collections.ArrayList @@ -1261,32 +1259,6 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } } - fun canEntitySpawn(event: LivingSpawnEvent.CheckSpawn) { - if (event.spawnReason == MobSpawnType.NATURAL && event.entity is Phantom) { - for (ply in event.entity.level.players()) { - if (!ply.isSpectator && ply.matteryPlayer?.isAndroid == true) { - val feature = (ply.matteryPlayer?.getFeature(AndroidFeatures.PHANTOM_ATTRACTOR) as AndroidSwitchableFeature?) - - if (feature?.isActive != true) { - if ( - ply.position.y in event.y - 36.0 .. event.y - 19.0 && - ply.position.x in event.x - 12.0 .. event.x + 12.0 && - ply.position.z in event.z - 12.0 .. event.z + 12.0 - ) { - event.result = Event.Result.DENY - - if (feature == null && ply is ServerPlayer) { - PhantomSpawnDeniedTrigger.trigger(ply) - } - - return - } - } - } - } - } - } - /** * this method is hooked through coremod transformer */ 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 244a0a876..492a6395e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -45,7 +45,6 @@ import ru.dbotthepony.mc.otm.triggers.BlackHoleTrigger import ru.dbotthepony.mc.otm.triggers.EnderTeleporterFallDeathTrigger import ru.dbotthepony.mc.otm.triggers.FallDampenersSaveTrigger import ru.dbotthepony.mc.otm.triggers.NanobotsArmorTrigger -import ru.dbotthepony.mc.otm.triggers.PhantomSpawnDeniedTrigger import ru.dbotthepony.mc.otm.triggers.ShockwaveDamageMobTrigger import ru.dbotthepony.mc.otm.triggers.ShockwaveTrigger diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/PhantomSpawnDeniedTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/PhantomSpawnDeniedTrigger.kt deleted file mode 100644 index 1be863f36..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/PhantomSpawnDeniedTrigger.kt +++ /dev/null @@ -1,32 +0,0 @@ -package ru.dbotthepony.mc.otm.triggers - -import com.google.gson.JsonObject -import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance -import net.minecraft.advancements.critereon.DeserializationContext -import net.minecraft.advancements.critereon.EntityPredicate.Composite -import net.minecraft.advancements.critereon.SimpleCriterionTrigger -import net.minecraft.resources.ResourceLocation -import net.minecraft.server.level.ServerPlayer -import ru.dbotthepony.mc.otm.OverdriveThatMatters - -object PhantomSpawnDeniedTrigger : SimpleCriterionTrigger() { - val ID = ResourceLocation(OverdriveThatMatters.MOD_ID, "phantom_spawn_denied") - - override fun getId(): ResourceLocation { - return ID - } - - override fun createInstance( - p_66248_: JsonObject, - p_66249_: Composite, - p_66250_: DeserializationContext - ): Instance { - return Instance - } - - fun trigger(player: ServerPlayer) { - trigger(player) { true } - } - - object Instance : AbstractCriterionTriggerInstance(ID, Composite.ANY) -} From 04c295a3593455e9e8fb8b13bdca2dec52205404 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Mar 2023 16:29:42 +0700 Subject: [PATCH 0405/1199] Semantic fix for remove of MutablePredicateIterator --- .../dbotthepony/mc/otm/core/collect/PredicateIterator.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/PredicateIterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/PredicateIterator.kt index ff7c47461..631bd998b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/PredicateIterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/PredicateIterator.kt @@ -22,6 +22,9 @@ class PredicateIterator : Iterator { private var foundValue: Any? = Companion + var once: Boolean = false + private set + override fun hasNext(): Boolean { if (foundValue === Companion) { while (parent.hasNext()) { @@ -29,6 +32,7 @@ class PredicateIterator : Iterator { if (predicate.test(next)) { foundValue = next + once = true return true } } @@ -84,6 +88,10 @@ class MutablePredicateIterator : MutableIterator { } override fun remove() { + if (!predicateParent.once) { + throw NoSuchElementException() + } + return parent.remove() } } From 38e4c078feafccb7257ae26959cf047329f6d17c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Mar 2023 20:57:23 +0700 Subject: [PATCH 0406/1199] Fix health bar rendering when it shouldn't --- .../dbotthepony/mc/otm/client/MatteryGUI.kt | 30 +++++++------------ 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index 0d7607c15..9c2ec1590 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -193,18 +193,10 @@ object MatteryGUI { showIteration(event) } - private fun renderFoodAndAir(event: RenderGuiOverlayEvent.Pre) { - if (event.overlay != FOOD_LEVEL_ELEMENT && event.overlay != AIR_LEVEL_ELEMENT) { - return - } - + private fun renderFoodAndAir(event: RenderGuiOverlayEvent.Pre, gui: ForgeGui) { val ply: LocalPlayer = minecraft.player ?: return - if (ply.vehicle is LivingEntity || - minecraft.options.hideGui || - minecraft.gameMode?.canHurtPlayer() == false || - minecraft.getCameraEntity() !is Player - ) { + if (ply.vehicle is LivingEntity) { return } @@ -214,8 +206,6 @@ object MatteryGUI { mattery = lastState } - val gui = minecraft.gui as? ForgeGui ?: return - if (mattery != null && mattery.isAndroid) { event.isCanceled = true lastState = mattery @@ -273,7 +263,7 @@ object MatteryGUI { return HEALTH_POISON } else if (player.hasEffect(MobEffects.WITHER)) { return HEALTH_WITHER - } else if (player.isFullyFrozen()) { + } else if (player.isFullyFrozen) { return HEALTH_FROZEN } @@ -285,26 +275,23 @@ object MatteryGUI { return RGBAColor.DARK_GREEN.toInt() } else if (player.hasEffect(MobEffects.WITHER)) { return RGBAColor.WHITE.toInt() - } else if (player.isFullyFrozen()) { + } else if (player.isFullyFrozen) { return RGBAColor.AQUA.toInt() } return RGBAColor.RED.toInt() } // можно вынести в конфиг, но для этого нужен селектор цвета - private fun renderPlayerHealth(event: RenderGuiOverlayEvent.Pre) { + private fun renderPlayerHealth(event: RenderGuiOverlayEvent.Pre, gui: ForgeGui) { if (!ClientConfig.ANDROID_HEALTH_HUD) return val ply: LocalPlayer = minecraft.player ?: return - var mattery = ply.matteryPlayer if (!ply.isAlive && mattery == null) { mattery = lastState } - val gui = minecraft.gui as? ForgeGui ?: return - if (mattery != null && mattery.isAndroid) { event.isCanceled = true lastState = mattery @@ -352,10 +339,13 @@ object MatteryGUI { } fun onLayerRenderEvent(event: RenderGuiOverlayEvent.Pre) { + val gui = minecraft.gui as? ForgeGui ?: return + if (minecraft.options.hideGui || !gui.shouldDrawSurvivalElements()) return + if (event.overlay == FOOD_LEVEL_ELEMENT || event.overlay == AIR_LEVEL_ELEMENT) { - renderFoodAndAir(event) + renderFoodAndAir(event, gui) } else if (event.overlay == PLAYER_HEALTH_ELEMENT) { - renderPlayerHealth(event) + renderPlayerHealth(event, gui) } } } From 89c2a99dfe4a6804043f3a179a543b49f9dffae6 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Sat, 18 Mar 2023 21:57:40 +0600 Subject: [PATCH 0407/1199] METAL JUNK TEXTURE 4!!! ! !!!! --- .../blockstates/metal_junk.json | 10 ++++++++-- .../models/block/metal_junk_d.json | 6 ++++++ .../textures/block/decorative/metal_junk_d.png | Bin 0 -> 317 bytes 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/metal_junk_d.json create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/decorative/metal_junk_d.png diff --git a/src/main/resources/assets/overdrive_that_matters/blockstates/metal_junk.json b/src/main/resources/assets/overdrive_that_matters/blockstates/metal_junk.json index 72d81da32..0452e9c4c 100644 --- a/src/main/resources/assets/overdrive_that_matters/blockstates/metal_junk.json +++ b/src/main/resources/assets/overdrive_that_matters/blockstates/metal_junk.json @@ -14,10 +14,16 @@ "model": "overdrive_that_matters:block/metal_junk_b", "y": 180, "weight": 4 }, { - "model": "overdrive_that_matters:block/metal_junk_c", "weight": 3 + "model": "overdrive_that_matters:block/metal_junk_c", "weight": 2 }, { - "model": "overdrive_that_matters:block/metal_junk_c", "y": 180, "weight": 3 + "model": "overdrive_that_matters:block/metal_junk_c", "y": 180, "weight": 2 + }, + { + "model": "overdrive_that_matters:block/metal_junk_d", "weight": 2 + }, + { + "model": "overdrive_that_matters:block/metal_junk_d", "y": 180, "weight": 2 } ] } diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/metal_junk_d.json b/src/main/resources/assets/overdrive_that_matters/models/block/metal_junk_d.json new file mode 100644 index 000000000..aa4b745af --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/metal_junk_d.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cube_all", + "textures": { + "all": "overdrive_that_matters:block/decorative/metal_junk_d" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/metal_junk_d.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/metal_junk_d.png new file mode 100644 index 0000000000000000000000000000000000000000..0cd41d4701c08bc60831fe1dda742959b4aace90 GIT binary patch literal 317 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFm=&OX zFv{%Dtft>bw&a9gpAOW^S>O>_%)r3S2f~aF`yK)fW|-#b;us=vIXOWfz$mORF(D-( zs31#S?3p8(a%O?(yGM^UWwk0gU;nbGXlY+s zV%xf@!Ol)iVY(?VqP8Bnc{B4V4_kNNr%#_AP1TlIa$ZV$wknhBx4*Y@<{Ue=v+3Zk zH47P;nJ2Raq$o=>Z}znC=w)b5Tq)eVap4Aq%^NBV87_a-xcB-|-f^G{89ZJ6T-G@y GGywqC#C2%^ literal 0 HcmV?d00001 From 75186cc272f5cb50fd17b10b6b576896790a84c3 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Sat, 18 Mar 2023 22:04:20 +0600 Subject: [PATCH 0408/1199] METAL JUNK RU!! ! --- src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 859b16be3..41f5fc203 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -393,6 +393,8 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.ENERGY_SERVO, "Desc", "заряжает, разряжает и передаёт энергию между предметами") add(MBlocks.CARBON_FIBRE_BLOCK, "Блок углеродных трубок") + add(MBlocks.METAL_MESH, "Блок металлической сетки") + add(MBlocks.METAL_JUNK, "Металлический хлам") add(MBlocks.TRITANIUM_STRIPED_BLOCK, "Тритановый блок с полоской") add(MBlocks.TRITANIUM_STRIPED_STAIRS, "Тритановые ступеньки с полоской") From 0de73d9eb20fe0f99148eb94634a7640fc3d7dd1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Mar 2023 23:24:45 +0700 Subject: [PATCH 0409/1199] Remove leftover phantom denied spawn trigger --- src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt | 1 - 1 file changed, 1 deletion(-) 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 492a6395e..002eb701a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -264,7 +264,6 @@ object MRegistry { CriteriaTriggers.register(AndroidResearchTrigger) CriteriaTriggers.register(ShockwaveDamageMobTrigger) CriteriaTriggers.register(ShockwaveTrigger) - CriteriaTriggers.register(PhantomSpawnDeniedTrigger) CriteriaTriggers.register(AndroidBatteryTrigger) CriteriaTriggers.register(NanobotsArmorTrigger) CriteriaTriggers.register(FallDampenersSaveTrigger) From 3f2deae8632a2649c090b6515939ba55b4acf3e9 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Sat, 18 Mar 2023 22:40:52 +0600 Subject: [PATCH 0410/1199] essence storage and essence servo --- .../models/block/essence_storage.json | 132 ++++++++++++++++++ .../textures/block/essence_storage.png | Bin 0 -> 1275 bytes .../textures/item/essence_servo.png | Bin 0 -> 298 bytes 3 files changed, 132 insertions(+) create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/essence_storage.json create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/essence_storage.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/essence_servo.png diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/essence_storage.json b/src/main/resources/assets/overdrive_that_matters/models/block/essence_storage.json new file mode 100644 index 000000000..52e8636b9 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/essence_storage.json @@ -0,0 +1,132 @@ +{ + "texture_size": [32, 64], + "render_type": "cutout", + "textures": { + "0": "overdrive_that_matters:block/essence_storage", + "particle": "overdrive_that_matters:block/essence_storage" + }, + "elements": [ + { + "name": "body", + "from": [0, 0, 0], + "to": [16, 2, 16], + "faces": { + "north": {"uv": [0, 4, 8, 4.5], "texture": "#0"}, + "east": {"uv": [0, 4, 8, 4.5], "texture": "#0"}, + "south": {"uv": [0, 4, 8, 4.5], "texture": "#0"}, + "west": {"uv": [0, 4, 8, 4.5], "texture": "#0"}, + "up": {"uv": [0, 0, 8, 4], "texture": "#0"}, + "down": {"uv": [0, 0, 8, 4], "texture": "#0"} + } + }, + { + "name": "body", + "from": [0, 3, 0], + "to": [16, 5, 16], + "faces": { + "north": {"uv": [8, 7.25, 16, 7.75], "texture": "#0"}, + "east": {"uv": [8, 7.25, 16, 7.75], "texture": "#0"}, + "south": {"uv": [8, 7.25, 16, 7.75], "texture": "#0"}, + "west": {"uv": [8, 7.25, 16, 7.75], "texture": "#0"}, + "up": {"uv": [0, 7.25, 8, 11.25], "rotation": 180, "texture": "#0"}, + "down": {"uv": [0, 0, 8, 4], "texture": "#0"} + } + }, + { + "name": "body", + "from": [9, 5, 0], + "to": [16, 16, 14], + "faces": { + "north": {"uv": [12, 0, 15.5, 2.75], "texture": "#0"}, + "east": {"uv": [9, 7.75, 16, 10.5], "texture": "#0"}, + "south": {"uv": [11, 4.5, 14.5, 7.25], "texture": "#0"}, + "west": {"uv": [0, 4.5, 7, 7.25], "texture": "#0"}, + "up": {"uv": [0, 7.75, 3.5, 11.25], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "body", + "from": [0, 10, 14], + "to": [16, 16, 16], + "faces": { + "east": {"uv": [8, 7.75, 9, 9.25], "texture": "#0"}, + "south": {"uv": [0, 11.25, 8, 12.75], "texture": "#0"}, + "west": {"uv": [14.5, 4.5, 15.5, 6], "texture": "#0"}, + "up": {"uv": [0, 7.25, 8, 7.75], "rotation": 180, "texture": "#0"}, + "down": {"uv": [0, 7.25, 8, 7.75], "texture": "#0"} + } + }, + { + "name": "body", + "from": [0, 5, 9], + "to": [9, 16, 14], + "faces": { + "north": {"uv": [7, 4.5, 11.5, 7.25], "texture": "#0"}, + "south": {"uv": [5, 4.5, 9.5, 7.25], "texture": "#0"}, + "west": {"uv": [12, 4.5, 14.5, 7.25], "texture": "#0"}, + "up": {"uv": [3.5, 7.75, 8, 9], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "body", + "from": [1, 2, 1], + "to": [15, 3, 15], + "faces": { + "north": {"uv": [0.5, 4.25, 7.5, 4.5], "texture": "#0"}, + "east": {"uv": [0.5, 4.25, 7.5, 4.5], "texture": "#0"}, + "south": {"uv": [0.5, 4.25, 7.5, 4.5], "texture": "#0"}, + "west": {"uv": [0.5, 4.25, 7.5, 4.5], "texture": "#0"} + } + }, + { + "name": "body", + "from": [1, 5, 14], + "to": [15, 10, 15], + "faces": { + "north": {"uv": [0, 0, 7, 1.25], "texture": "#missing"}, + "east": {"uv": [15.5, 10.5, 16, 11.75], "texture": "#0"}, + "south": {"uv": [8.5, 10.5, 15.5, 11.75], "texture": "#0"}, + "west": {"uv": [8, 10.5, 8.5, 11.75], "texture": "#0"} + } + }, + { + "name": "container", + "from": [1, 15, 1], + "to": [9, 15, 9], + "faces": { + "up": {"uv": [8, 0, 12, 2], "texture": "#0"}, + "down": {"uv": [8, 0, 12, 2], "texture": "#0"} + } + }, + { + "name": "container", + "from": [1, 5, 1], + "to": [9, 15, 1], + "faces": { + "north": {"uv": [8, 2, 12, 4.5], "texture": "#0"}, + "south": {"uv": [8, 2, 12, 4.5], "texture": "#0"} + } + }, + { + "name": "experience", + "from": [1.5, 5, 1.5], + "to": [8.5, 11, 8.5], + "faces": { + "north": {"uv": [8, 14.5, 11.5, 16], "texture": "#0"}, + "east": {"uv": [12.5, 12, 16, 13.5], "texture": "#0"}, + "south": {"uv": [9, 12, 12.5, 13.5], "texture": "#0"}, + "west": {"uv": [11.5, 14.5, 15, 16], "texture": "#0"}, + "up": {"uv": [9.5, 12.5, 13, 14.25], "texture": "#0"} + } + }, + { + "name": "container", + "from": [1, 5, 1], + "to": [1, 15, 9], + "faces": { + "east": {"uv": [8, 2, 12, 4.5], "texture": "#0"}, + "west": {"uv": [8, 2, 12, 4.5], "texture": "#0"} + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/essence_storage.png b/src/main/resources/assets/overdrive_that_matters/textures/block/essence_storage.png new file mode 100644 index 0000000000000000000000000000000000000000..f0136b877e34d1fd21a6ec81edce323490c58e7c GIT binary patch literal 1275 zcmcJO`!^c~6vuBON|GX;!?d#Lw5ks?*0pO#j6)>Rh)~QXRITMq6wzu|Nk}}_S=4B~ zqSPx6qHKK_-C`733A(jaI^AI%tw%YhrL(Sg=^wFs&i8)Kz4wQE?)RLV&kgc7q1aOZ zz=Rp#%hQvtm$$KjKC`*l_~I3)1Hd4g;WFL46rxsGm7;*?d1wPfu4@ zR~s7}XJ_Y>l#~M1HEFp@EEa!}rHIdv@%em#K!Au`0zx@LDndR&20|mkX@mp>A;KpJi3sTkMF>p@HxMo(C=t{MB7}H^ zefS|0&A&!yM(9M4Aao(H&^!Pw1JSe&Ar|2TLJ7iQgaU*LgffJS2;m4^q-G<8AUO$v ziPkK%N*ms~V=lh4j^$D1(Mv@vUjIqP zE&d$4;-{0R2vsotyC}+BzF$s?-i!SFJ`MTp<05Bu9@2^V&zRr(~8m# zj@4Dj(kXSfWK>f}Zbo!ZUxj?{CE>OQ410O@m{FO_e|8>mTKMHvTw0QBdEXV4t-wxH*y2c4z5@u2wWTIlizxbv(gvb!Kr{ z8}z&>@##mChu!%NtyPxtf2MkPNS%G}@0G|+7F)=YUHMPLNz=DE;`ucjEvm3d6otV`W+I4k({xjUXd2_{z6+pFn z9;Ph>QoJQWe!>5d0E6udr8b}hXMsm#F#`kNeh_A~U=3CQ3Ko01IEH8hhxT*x9Z=wK zj&!_x{P+CwrDsx=vp&u9SbR2gTVZynWR3CWa0w-)UKU%K0;$q~$}N% a_b?`>v+L{^T%HfKp25@A&t;ucLK6UrwP{xX literal 0 HcmV?d00001 From b57b954e5c7719f2b8adbc5027c5ba1ca20dfb74 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Sun, 19 Mar 2023 00:13:40 +0600 Subject: [PATCH 0411/1199] essence storage glows oooo --- .../mc/otm/datagen/blocks/BlockStates.kt | 1 + .../mc/otm/datagen/items/ItemModels.kt | 2 + .../models/block/essence_storage.json | 38 +++++++++++++++++-- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt index 1ac73e92c..52135accd 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt @@ -89,6 +89,7 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { provider.block(MBlocks.MATTER_RECYCLER) provider.block(MBlocks.ENERGY_SERVO) provider.block(MBlocks.COBBLESTONE_GENERATOR) + provider.block(MBlocks.ESSENCE_STORAGE) provider.exec { for (crate in MRegistry.CARGO_CRATES.allBlocks.values) { diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index 03b014868..8c2d8c79b 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -60,6 +60,7 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.generated(MItems.ESSENCE_DRIVE) provider.generated(MItems.ESSENCE_CAPSULE) + provider.generated(MItems.ESSENCE_SERVO) for (item in MItems.ExopackUpgrades.INVENTORY_UPGRADES) { provider.generated(item, modLocation("item/exosuit_inventory_upgrade")) @@ -123,6 +124,7 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.block(MItems.MATTER_CABLE, "matter_cable_core") provider.block(MItems.MATTER_DECOMPOSER, "matter_decomposer_working") provider.block(MItems.ENERGY_SERVO, "energy_servo") + provider.block(MItems.ESSENCE_STORAGE, "essence_storage") provider.block(MItems.PLATE_PRESS, "plate_press_idle") provider.block(MItems.STORAGE_POWER_SUPPLIER, "storage_power_supplier") diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/essence_storage.json b/src/main/resources/assets/overdrive_that_matters/models/block/essence_storage.json index 52e8636b9..5f9f56224 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/essence_storage.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/essence_storage.json @@ -1,6 +1,6 @@ { - "texture_size": [32, 64], "render_type": "cutout", + "texture_size": [32, 64], "textures": { "0": "overdrive_that_matters:block/essence_storage", "particle": "overdrive_that_matters:block/essence_storage" @@ -117,7 +117,8 @@ "south": {"uv": [9, 12, 12.5, 13.5], "texture": "#0"}, "west": {"uv": [11.5, 14.5, 15, 16], "texture": "#0"}, "up": {"uv": [9.5, 12.5, 13, 14.25], "texture": "#0"} - } + }, + "forge_data": { "block_light": 15, "sky_light": 15 } }, { "name": "container", @@ -128,5 +129,36 @@ "west": {"uv": [8, 2, 12, 4.5], "texture": "#0"} } } - ] + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 225, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "scale": [0.5, 0.5, 0.5] + } + } } \ No newline at end of file From 8c3eabb3bd1de8fa85b1e77e0ac8fdaf55fc66a6 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Sun, 19 Mar 2023 07:36:18 +0600 Subject: [PATCH 0412/1199] ship wreckage structure --- .../structures/wreckage/wreckage_body.nbt | Bin 0 -> 15023 bytes .../structures/wreckage/wreckage_front.nbt | Bin 0 -> 27618 bytes .../structures/wreckage/wreckage_tail.nbt | Bin 0 -> 33361 bytes .../tags/worldgen/biome/wreckage.json | 7 +++++ .../worldgen/structure/laboratory.json | 2 +- .../worldgen/structure/wreckage.json | 28 ++++++++++++++++++ .../worldgen/structure_set/wreckage.json | 14 +++++++++ .../template_pool/wreckage/wreckage_body.json | 15 ++++++++++ .../wreckage/wreckage_front.json | 15 ++++++++++ .../template_pool/wreckage/wreckage_tail.json | 15 ++++++++++ 10 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/data/overdrive_that_matters/structures/wreckage/wreckage_body.nbt create mode 100644 src/main/resources/data/overdrive_that_matters/structures/wreckage/wreckage_front.nbt create mode 100644 src/main/resources/data/overdrive_that_matters/structures/wreckage/wreckage_tail.nbt create mode 100644 src/main/resources/data/overdrive_that_matters/tags/worldgen/biome/wreckage.json create mode 100644 src/main/resources/data/overdrive_that_matters/worldgen/structure/wreckage.json create mode 100644 src/main/resources/data/overdrive_that_matters/worldgen/structure_set/wreckage.json create mode 100644 src/main/resources/data/overdrive_that_matters/worldgen/template_pool/wreckage/wreckage_body.json create mode 100644 src/main/resources/data/overdrive_that_matters/worldgen/template_pool/wreckage/wreckage_front.json create mode 100644 src/main/resources/data/overdrive_that_matters/worldgen/template_pool/wreckage/wreckage_tail.json diff --git a/src/main/resources/data/overdrive_that_matters/structures/wreckage/wreckage_body.nbt b/src/main/resources/data/overdrive_that_matters/structures/wreckage/wreckage_body.nbt new file mode 100644 index 0000000000000000000000000000000000000000..691ce2bf70bd908be4b4e172e929cb9681c522d0 GIT binary patch literal 15023 zcmaib3s_TEwtp)kJ`ku{2ok`yzC}q)L6Fxly|rUSsRJUQLLg(J5J61|@<>u(6qEon zvZnDf4<*$vd=mDoU`{{ z@3j}Mxl7+M{TW50M=qm3OD&t)c!pP8A^U}*@Q(eeGiJN~^IbNdg+KNge(%y3;q5Wj zKYg%l`%=tTkAJS-##q9L4YtrIJadPIde^`IT<6&N)fL?b^8T81$=#ZX$y8sI@7jlk z7rN-WN$Vw9KXJLOv&kRNs_#E~EP5ax9IUVRx87)kF2C-1p%d(SQ zU+pVf>2IK%CY@GwX`X5hX?Kld+pVzVNk8E6>~J>ByvGIsf1fX^ zNQm-rU@0GkQ+HrIFQEF4GxMOwi$K$3rnVJ9ZAT#Fz~e)xShBV25@^q6v8Ou2cM!j<1X}<^6sxg=yo4t; zq0Rx-%8Mb-s$D_YMUm1tC-JM*anPwZrF5Vz;_zFa|=J_syRj ze>=&Euz7twhmGzIw~2Lw=d#}Fj$9sUOJ0AWIo-(d%1>?a*6HR6JAzZ(#_KKpeiWMpY$e|`HD znTi9i?hNZj2h9E-bGxrLZkC?JllSMg*m1;;eaZYxCXV;gnV`LeZPLO_oDn9GV6Ui9 zeaXzHKBilIIAtmE35vzUU6{0tVO!=g3btvoCwza$YlN%#wC6t3K)l;kELF)H(m4_a z6PU+Zu~+&Kwtl*kCl;a}bj8B$D;21|5GJi|89}%PL$$Rh=;4g`4lJ6Zm3mmrL+(C( zw1=d?S)lryna8ZKROjxYBs+pUidmb6z2bvv1u`UK78+a(jQefM!hC_?@dRYz&=`aj zctj*gzukzpU&KMNzU^?cB5uG`XE-h)ZpX+ohL`e*_@+gKL9c~{jX%h&{S=mxm37@2 z*xbf~vW7L@QJgb8!K}q$3;vRhDX_qS1neLvZZX*&+j-&!)RBQ$SW@Jqt`9ju?#Oo% zaVL7=yn2}#tmoHGCtrZ;ytqY3zlArX-9cIh)^qoi6podR6~)vf;NO7k&SdK&QPoZh zI3gsF{R-H(G7y+=z@<0cp#istFOOs{bTM}{A2oAS(%U`FZE~CGU8XLDbxwx0`4KDm z7_Td%RvqD^2!>KEIPXu#uVE>FyFf^?Ae0T>VOkKhU0AB?JIJ{_uS8&e;(t5Bo1i1k znkicOKfrHS?+}H;T=@BYm%LE{!fWk>-!bQGK3l&E)#{$XHdrFe3g_v)(2dM6UGd+P zwQyeY6+3Cs+dbe#P27$k#uX`Ds7OL+f{4Kf*cBOU8OV`;4)XJx5Uj?$Efc2C47I;Q z&@bXgVHh(O6g$?Lw*==Uon+P&t@k0$9d`_b;E?M#t0Wt-kX-Uux<##Pj&tu7@Bt`=#!Zu`vuf)z)*!~g78Po z4AYv>X!&o5UuN#bzx*h?X{;mM&}oAABva)2dnk`%!Wh2?)z+1uv08w317<)|VVt$+ z2jXky|Gy~yk~d+CVDj64>#Oiz#+yuut!cso6tnAiaVr+ismH;Fp2}jUm9nxPg@+x% zm_aRD{BN^rv{b{AA$Je>sQ)1Fk;dH17j0&~jZsz4kjqL$60rzIjh*4nUB3hPD-$RH z7$W`HVso1}X~fs$#|Sdd!SOXplBAS~f!N6i4m!w`-TVtM4*oN_%1e zJ2DBwejoE!V1s?Y8uE+5UyRIVt9Ih;EjVjX)k!FQ$-7L^ZUlb0-Ql%e|B0bwN6gG^ z_}2Lj^G);;?1T1I1mTCjtuie4OoSVM;JR~lHtGl`rp6_<#>HR0@MiP-MZ5WD@#JIK z$N<_l@x)2U=ikPIve+7N3_w9~FyCOE0S^*75zJsc-z_%QZbc>!#27G9>6VE+Ns4c9 zVZ9hYQ$Wwq{2GFA5vGaQHN<&`Nuz^luqMQNnjc#@`mN{~y0#Lz@#Y?_-gFK=L+vmo zO#T|?SEgDcoR55=GCH+LsaZ8y8%$*VYZOT^l>!wuT_WL)R7)%7Wk6NJNmpf%7l>iha!lM4fXd z7F<*zXxmmlldrXfH`)1?k+R{PwIZ}+u^)DZPvRA0TaeQ-C351HJV~2Nq@TLw%CgEx zL9sq-#>~t;Idh{Vf;UpQVx+M3Q=cmptmodw>m+H`In0dp3ICjw_V?5^=iH>{*Abb1 z4%*5(daSQIW4>DSfdEZ?cd8fz^y7ib)$o5eA*%5ikjT z?))$5n)+x{kTMr(YmTuDmc$626%uWEI1x8Ptol0WDhlK`S#>fq=@E2L9N#YlY3&sk z*-6g4I#bYg%pASd=k1|u2D1^@UkOfrH0x_5a#85cM_h*3QS*UmLAUaxun>{IMUOBw zavgXkKMb>~4aqNJ6p>%C4L&?E0d=InB-KEM86Q?7K3(De4zJDK3v zc>c+kkdPK2?7$=B+F*rk8bc-V#)_D1V8u6RT*(uABD6!u2P05@h1?^phI2$*fw=&p zC}zJ%iHGUb#g@w^ZaA7IyB&3;8DHa1AdhCUTQU$|78s$`DiaB(;k<>tx;U9xlFY0< zjHQktYzfC1Z#yQ+O*=q;HdpiK$a|EO0we zuQdsIC&DkzNJEc)?`;kCX1KKmj7Z;I{jhTgtdV>-Vy2OZoo2rV*2f$x0^cULk_A;$>fvIQy3u*WXd&oZ) z_adxY@;OR>+tn0{!u2ek!cukz2}~hRfutNl+E%pQbwghPBUOg6C3C3d4dh*o(j_q0bD*3$%7>!EZWf>dk5;2P$! z5EJpr@d|%W-sC1cnVSX65~_N)-mG~{^5Eu<*&7wA;?=@nTe2$0VvfDxA`QwsqslSL zs1S?>GM(iZQCb}k1wu*5KM~Tx^H&^L6D9W#MHPF#{DuL+B`7sN|2OphtxwxehTG2u zLGjC$BE$2ObcU*I>X1n!Ba;xd?yQD+nIUnzGep^gh}UZbX%0MyGYOeOe+E9-WJvMq z3ssS8r5}{1y2g5dvy`?UrEha)g35jkJ_hAllnuTAC39;MiZ)%k0MvzhVTc30sti4Qrv4sxUvTtp{kn-$pfHigcGm5;w#AG45hl5 zl=M33dM|M$t0HT6Fjk~@toH2*Rgr2S(#Fz+wtNfmqi2Ie%mpgLnouU}9#XI2 zC)f$2?zx*XaEO&zNXvz^QL65`2Wb*+ZslUA5?in^keM^oEk&ftY`hwmL6)LV{0$;} zG`clGa>OKjY64u~dwGdt@TT-2knZzCbXb&Y8g;d+ZFwpw;%iVIE0|9qeXs~9gLs9&?6 zso{Nv8f8g&pYR6ptC;nU4SHnFFu%aKd72BH-iL1cN6rKq^*kKER*WRWSB<4*3N$mD{jLcCB2u zzwaVDIh;@>DJ({{0yhoY^V(NmVoL_PLb@`a6V9rp(5k8m|xBb%a ze`C8tCB3Tp4a7$9AVX*c?Gt*hXW$82Fxk2+c8b|vg3ilePkED>Lbni_>SlmHCrHya zUIl?d^kc<$hI3 zMW9b`;{E)#0eb@18Ip1Y)`Xg1&^)f856gV9B3ZA_Bkl@YlHNhyR~oA*#ULpVp*w~e z{3-&&z=&iwbg~A`>|ZCs9Xi=N63*02w4@}tnb|SKuWwRYt$E0q7|gw1a#~Gum^--4r6iXYR!&|RV4@S38=tQZS_?pB^?S+ z!AW_0n6X%}6S}N?GQ2|9?$E$-1&2lB95VV*m9E{jJN;fxOA`0#c)Hu9F|>EBRqvfp z?H{TL&P#xVqmpN`!}9k33Mdt~Wmc&^15$8lp*@r}-4rySf#Skc4;*2|CHl{DMv8*x zYi6XE1FG9*e-*xc$uM^f%;k3IHqSm_#gh(k9u>z{`H@9}Pj8fnOWD@~SaG&T`paa2 zzV3_EJ2CZ{^tRwC7{co#W5_3-wX+rAh9pWsiXXZK2Osc1ovSB8Ab%@e$Q~5~RfgnxcrHc{Ef*P|+ z;PXCMkqZ?DrRWY#8@gCI^Zjaq@H|%JpB&2z-w8`#J{lj@*vXW9g%dDJf5f!^y z_O3NyBmrIB=uns6IO-)nO5h%CZmXX1wjS|b{=^$-*yvi5pY+fxEIuIIS?-%Ndy-T|J8HbPvoBPCbH4F< zWAimuoa-(aS3;~JVpaJ_?|!E8eyN9UY~;ux*^>`X$Wrdvl#ehD$(%!!TphM~Ci)QH zJrlH_A@%)fx!}>j*iTPdoLFfYEsPZeu4Zc830dd%5w^rS1%;N!jE5Uk-}~O~VJoz9 z7t1N%G1%W7$0PE9a&l$n*%EhK>B~C1Ogm-R zu8tv;z;YbfD;rXs!`G-Nfm~@Oz2AyrL7?@9OR!???Dc4MAlE*VzI}0Tr1eMyAg*CR zH-C5}Uqkcu5}!R?^YjS1k4{=f;Bp#Pb>Cjq%~{o*RXJI3s5f$D{&_a&v^E!%er2)f zdUO}Q7%N5?nm}`1f~~hiROw{>2Ju>~aAy-Yd_`=OZ7k3FX}CO)E6$?VS|RGQ^ti&% zf~YWE<9pq=hd}@mzh@ZYM(gF#Tw>wGe4KIZuD(z$UO(W%2yw7x^!CMWnLqfXc8JRRS9zh3M&Q56k23Th@@x!5qWOxHN@?68~@cZf^PqAQme zMpo(?ou=b=JsXU=SKqd-v~7>CVWicen88y3+G!JiD4FjJ=o4q$M~m@IW%Neyj8g(EDP97y#|<&2k|dBtZ@1Y zJcsC&e!vrL~o02hTPMg4|}4>lGO!fcbB zDC8^bv@@s&yJE2Lc5gwC*O07nENzoGUNCOgoV zdH@R$k+xP*E9_iJ2e35d@YH7b3g?F|4Nm{EJA@8-_9Q2IMJt zb_5S}2+gK;Eusn$E(F~NbJlyZ*uTOaz9pbsR~+SWf%VT{ck-!(x)y8_;f za*_?;U$dOD6)7)({dqI{O)TN@X2~!5^iBpCE6h~uj+rrdy;&%J;Jx}Yc$hDepg>kg zx8BP%WqmP*cnq9p0m#%AUi-fDY^XdiLz`D>WlHmzlYPih)wD3EnW)3eJoNz2tJ!~G z%vBaqt|O;2ib;-$gg}u5Oix{d^*5ZufTDkeSF~E7^po%KbadDy`taG{r}ye}uSYus za(86X{XoHh4NI|8tJg^#0)4;`xqN91<9-`b_*q5@n$^<5w<3Ok*_RPv1DoF$O4zb> z@gYRv1c&SwLr zI^Fub2vtJ+8U2`!86h%T1qr$Pq0TKVsl6$a)ojLEY_q@qV=Tn|A+!rs6JQ618-6fD)sUbn?SIDWUa1yq7KTJgsE^GxibT0G7ybdk-gTw{5waJtOWhkPNvyUx-cz zY52`mk5P~ZuhPDn){9avgy*Tfa;yl0chA@fV*nqOMkqst_rWK##JXB3@ixDvgDc2R z-s)_HEnAE&`*`G}U-EY&orrCPDH}e{nRUyV-HR6_#)yAC3Q2=s2Ofn7XA%6`df1-b zzAK)j*rVgm20V_rFGzp0H=oR#nEM7)`PaR$(SuR4i%v)R(%0n#ID3+AA+P60j=EDTNtUy(5X}_$!q&TMqeJm4Is< zSN3PkiV&rH6|1+C%?tF&HsP}jZySg`B89<0jiqI*IKSwg^i|#IsVhQiMb&gDuptHd z1}~zxuqrZA>{+=NPWt86@N+wETl1?s+^qfmjGTuN*8D%?ulNu&B&bUO$Gi=-L}{Hx z6=#|Neq%z6A{=qhn_6;1D2F@6GvGlr;;iV(P&yj$LnzC47&>uPg`0q=s7?rK2mmh?}JM5gor(p zscr`c#m+}HUU?DYw(yR9t}PUmf%JV zf`y9&mQ{;tyC*Jinv70N%Gye++xqxY@~`qxI1Sk6*Joe69I6I(%*T zNAc2y@WGM@bC-+SPu700jpKp_&athAV8IkAh_fN2mv?PNSR3BH`2@+wgiT%*K7l^1 zfxfMQK4~WCA!b)^@JWAsA4X0>cjFSe zaed*wV2QIK_)GideC&J;wY*AQSva<$dGhh$sT#}P$QAkL3vHQgmucH`Qrg}NhTx@# zMH}AwNmVI$lckdldPx^&+oCBnwiN^hZc- zXe+B(p9T8fSXZhvq2$p~#bTvmiBe%nG}`lKzD7Mb9ILo?)($Pdex^pOY1l2kd8Q_! ze8l~5?={86jcJ?odE%!XHH(QFdtwA1bAmKBp<+ry#v@%&MBT3sK$kxp~*4Q4cD>h9aCVH0{58XPA8I)0azIO?<;DCCo|RcZSV@mUj51KmS@g@$!f z0}!h5M1VA+{8m9|Pr6+<0*K}tCu?K#X2^4t*FH%o&=vigPggtVK!`Da-gLEN-O|{QLa3#|Oh+8Qs-X};KPLQ73 zD~A$!bxV*?tZ^+m9)*q{@)EmUhJa0SZhH>N45j^4sH9}>RSFcq0dKi84Rm*2-F|bx zSgzy$dBHj(-u+C`3sl-B8*u1p2`L<$h~5%#fx|T9f6Sw+(O`Qk$KD@v?TU~F@xvf< zzAYt$bYUjIE6AqO{FEJ%gi#z=h}BC9v<3*16#Px;fi4dE8k z3BbjPk}4QA z5xo4Qd%(&23t1EXM?gxw5WW{{xm9O);gW((YJOsjpu2eSRPhpJvE@{;rP6oVNXjZm z)gVxRd_o2Wg3}RH=W{vj$jpJ}yd#hv))7hN+^-W zyPb3&PSDrUphss#i4~3Fs)bi6787ndvD!Km*%ZRgY-(=H!9vpm*PIMgVxc-VVfw+z z{yea_Ee9KM%SVQ7OjyQCL5d(9scJ$6E8y!0TmBxrr%ytf;3o29XFe(wIT8=$Yk)XMNmu^m3|eyvj&HKnt@m}CnI7dJ3C zkjK-s?X>mbpi%L%gCzS!mm6?x`6J|`SK(v!7KABZnsla%+-@=r&m5%do*n*KyZX7l?|QU*7QM|nmhRZi^j@RhdP2sT3{KmavE8<;*=V)oR=(iZzZl){Em$&v}#i zd34{;^7H`)x<+eLv2q~5fs~Q5idC_a^6(~j1_7#|MxnBKpscz+lch>Bj--y$N#)x8 z23fQ=i|Vo%mZ4W_K=^b!z)1q|5?pxgOyBm-A#`o^Gs@ z_6GV;psKt$v0)&!{b7JZt*r0sh~@c>KR?sEakdaWp7{{hG;p>b}{uB@#>@@iFV&VMC46&wdw>=T(CH@ot=HGp4 z)7BmGMalIsr)$RdOimB}ZPUsDF0~9)c2|SH?eH#xT>t6m8i$M&N7he~$Q!O2Z+iy9#&%6>OSi2Y5az~^ z$ja=>(o?WjiTZ{~Whk*3H=t$c(s*rxpy;c5VeO1lxdweI)@3hj33L8&kxkm*kVm<% z8dP`OUdr$52%7oDHrIRRW=y0c_<51|;kj_8no1Hw4VK?059Pqk&jTpKDrSG)nXc)w zG?ygef&8SOb6U7AMRGxQN$&X$wuqbffA{Id%9pfQagW0D$w|XxXRo&RPm_4a(x_*z;|3b*82!%4JTZBE4_Bvt@jb{R zJh>|H!TPU9%jOfM&2^&&?al^za-Gp8CxWO8H#By8<;XT;=JE}z3!QFU zIH{!Qxt!6+>|lON1F~P`(9ordJls1`H1DPI4BA#2eXTdkCy{%b?se{!L8N&)cy;jV zbWk=c7|bQqFQ@Za@45ImTLp(NrrKKkx^Sz#A@v_u0DBI%?QpnwhEW* zyF5;to$PIn=F;`btEzb|sqNtWKtRZiIoJ7*?`r2~NB7TNo;s(NzU}pH)eOCCP(r^s z_gs23D!Sb`Gm-kD=2F7h9QXDV<79a}7o9hs`0m_(@3l{-{PTIe<5;x&_~U2uBlV62 z16$k0U%c?Bdj8K>1y8>yK9qecT`$^y3v0cPVWXSSyVe}5A|vCA2s{8Mz_-pDeD3ck- zu@74#lt&rbt2R%%`nTxzS)I{VR7)O_f9&Q`43pW6)&^aKym`w3qmFNQ|FhXIt2Sbd z=LG}xOCL2~t99iVC;PvC+0VE0cX>AXAUSc9Q65rGHOdDze`y?7yE1N`d}b(UZrN@4 zlJan-a(2yN#TAdb;C~u5JsS0tZq3s~lmkO1+s2n{eOR_~ykf|>^1_s$C^^7j^p^X7 zI)B(fEX?$sH|36JR`zs_@e8fM==JSrj9 zu8mgD)9SZ3hfniw(L_h4A0`ZFI6V)z^GmtIv$e_cGJz`5xm)Ww{{S@N-GKlA literal 0 HcmV?d00001 diff --git a/src/main/resources/data/overdrive_that_matters/structures/wreckage/wreckage_front.nbt b/src/main/resources/data/overdrive_that_matters/structures/wreckage/wreckage_front.nbt new file mode 100644 index 0000000000000000000000000000000000000000..e56d01ec0584184b2e518fef861692dd000123fa GIT binary patch literal 27618 zcmcJ230zZGzJF_rjG)-53sJUq`ifFnf*>@8Ws0p9Wf`R^h+#`1pe)r06fmKMB5e)O zDHfw_V?`Jh!N?{{pn!&{Bm_Z8AVS7cl41f;gNYCV|KGU*MBC|`|9fxz{Bk(=-gC}9 z_pHC~Z#i0={KHGwzu6muyK+qX&q$K^KikBb-~Xez`S=m_mv8v(*_-HlCB=dH0XbpI zD~@>PnXEs1e)RR;izPpl>?EyEV{24?C)x{aA(g>%nbTg-ESG}?-Wlzyk9r_w0DT| zaCW?_NITl@JN?#7%1pHCr!wC-cecsw2Yjx@nK(;sXshWO?)M?thLVzyJU!|G{N*%4 z%E!%xcv)Ki>c03Oys;iN0KZ?4O8Q0M-Fj~=x3;^eF|FQM$&0im;yR5u*V0+?kojo9 z+Ns$7R{sQio*5%tpZq(~@8m9DP9`|!*>O*%5x!|ATbJQFtvE-&W)*~G8)~;&EnF>n zpo?z)lC?Z6)=+kBd6;!NuJer!LZ`9hNOO@l^Rym$-3|X{e4ZU+#E{(a9)wla6SC^7 z1$#qHiq;H7Pqr;QooqV@Hz4^^`vg;z>AU0Xym(g&p2Ip5^zLjZ8rA2FF(Z5(^&|i6 zk=10vO@ANzvWziZM3x41MOAu()AfOU-g}Jj*Q#vbN^u{`ge_d?2RjQUMXO&Y6-Y^|`{K~C!M zAF|I&gbI-ZIHqeEBWAi=PCLH9lHfXtoa}lOKF(ga@i@EQmYJ_BW6`6^?T}YE=>YFw zS(B|hah;nZcH{HH8Q6E08|b>iDI>nnSa%CPJA3-6rkihq6gSezr)A&bYu zbDh6v9Q>=OY6p2f%b*&4TSrEGz_Tx0^sx|4;A3MCB0Mxa=erb(>YwjV{kX_?VMNQ5 zUudl7i(07o3-9uJJ3a1W4R=RXFn<2SgNhew)9T-0%F^nsn4+})wOmr`J!9^+)+Sr#&b*df zrS$x5A;F20J%}SFkmbTG7TNj##>uybJFcKR>(|jr7G)DQ+Q)Zr04t z7V%dEb6(M%R~dH~QQ<2g(Qc;XEieB|QoI~mZW;2sRKWPHnlZYbu>3vt!(~_`f0A zj`h!1SbEekN9L>HZD$nDhLq1BGBV)MUs*yH*KmZ&2mh0LYfd=nT2m6g(De1|d7B7z zt@71*#84wWalGw#|W8a&@2 zbWNVS&{`UE9^g1#HTZoU&(U{VRTk!FR4G@T&$Gm?txey?hnDyKXNkTSpStPE!vx2K z@l4iXf5zQy|54)F8FCI;O5#c)Vt0_GnYhdUL1K11x$0`s?(cfTr6SXA16RD7QAioe zg7^Ptsq0PqoWl`;GWesc$*1_|Br{J7zvg#CKJeY$i-Y2>RUwTLk{;fvSwZP7ed z%sj!RYzZ|ol>9x!JcpGqw6yA!HQC27VlQ5rp%UWSg{+sTdxdTSJ*wX?f|%B5LrKL| z+PI?z0b+tin5We93ymAZ)_rXWsC)#pf9^MwXE4 zf6zsFaUs#>uPz+E0S#@fR!8#ZspLv6G^mB-qOTRCqv@a^=pz%~} zJ@6N%y65AD!&kpG)bw@xyg7$o3Eyh7p=r(h0622bFeuyuDk5h*Fw`2oM{+Hs!XT#h zU)QP4IIkClJH z=M}O&UIfc#iKre?FQ90I@ibR;fE)Umx_=&G_uG9u2eehdLKPuS%6T4?GxxU6qZ{h( zNIo!h7&vy#`GR#k)H)c~39NJm7S+#KbR)$Ro`5`HA;sZM3?2b+DjGxc;AXsq3@9fb zSkA>bMVhfZEV}DuGSvv-Vu0$HY@kt)L)gTGJ@>_LeNjg6(KRw(39zIn80OtSPcB;w zDm&f<+(|v~OXEEHbV~hlFwIlNGqIAY)F>$V6lw^=kyY=K(1o(60UVfOP># ztN(#dDEdkV%XQz@SeLQzk(jJOKIn|_ZO2XqyZGA1kADliaj$io!}nI`+b>83tT;t5 znlaGqYMi;aq8R8U?lU*ml}_8l{VQV|$YAC{Bf+McvKL`IUg7ibcmYAyX2kb57A#y^ zmu;x3%qjC*3;@TEU{eA^_XugHOyE++4MA?;pEvjAQVwALg)Br#7$yXmztI`cg&v;S zwbVYR>Ryl^S$+?v%MF)ZB9Il46{(?+C1q&o;!*=R2JN`q&mg9E0p?q>?ncdcrm6?4KANUqOSUBth1lJNYt0mV^ThOG4zZs zTA>4~%IlWZQe}R>U`yz&1?=}b5rBnE?{f;N-ZPvlc#2S1ivB$Gr7E7GJ)-Zs#Usi^ zIGJ~Ut{!qt^s{6O5HKZZ^|OL?U|L`V>6kGHOA1Zhp5fK5Rkqv7VxJB`TRIXJyuukD zCYQ&C$cHQt^cvcG!`cwtLJNxek-ZL3sodU@eBW)p7{fI-{~)Y?l{2mll^r zu6+^jkUB%;&ViK?^%zFcA(h_`~lr)h)L$W_6@eRgWg~UJb4Pxj)kxFIT(V*3N%I~ihoX!{ti8cwtsM)%Da_>1_r9o%E zl{Ka8YQbRJQGD$RdyEo`yCoC(pIr=2$%r3Y(^nJhFQ8LMZ1Ij=vaK7-4apiE$^O<| zneNdd$)NKLWoM21;)MbG73$T13F6HX1{`V%E~l}?dpZyZ2muUm4weh6Yy-_|>f5rd z56UmAy%p8Aj6#hKs;=ULFnQwF_M)_l6RtGAON@or)QN!ID=Pmyc+<(OX5Z@P+#YgLP>dsUQWYz!(_Naq15oIOE08 zu73lb*=veUx`k=2;<^xnOBDYgbbSNeZD{@h24n)Gy+k3nV2w)JlgFn7TMQ?QgLWl# zl*IL3Xd?I2jqbs8F!R!6kkz`L%oWGk+OxgU6h>v>B_u^9|g69Xf?^1?tGYaneQQQjd#OIpg6D>ikK6PC@_{%59QW%VdWNLFX-0*dYnKt*4vLUjqGpt}4j4;eMa zvuwINqJU=0wvxD0Sjii)l6PYzpNEpYrnW<|xXVy-)-_bJNjUbEx3Jp0m!k)N`w>(Fn5iM**vmUNp_k|F$A)j^Z)U&-(&Iyi+dlH?O>7uA+pUT9 z%^!hbQ~2FAhNrk|X8@-pj)JCiUDcjE`_49}gT@TkoGg}SgzzW|CsJ6KCzR$rfOq(=a9|K62+DaEEv{@4|Q-(!JnPvVbLSSgtqvS zr+Cb>GbzZw3q(3-mpM93q~%Hj9O$rITKXR1Ury^!f^{;zF(c+nPqD~Tq@UYdmpfGx z_=_Ou-2C<;hHWEoYZOV75pTA-59%WF)Ihx;UHo5u5j0(Gkrc*1flJ*6WAbjhcvpZR zw9M776Oyi*@j<~5bo@})!^FA3r?D_aESlV05grXAJZT_CsIl}NP@HUQSep?a+M`Z5 z(bB6<7@%zpFAwg>fUPC*=pJ#7;TXZH8fqAqI{@uh7p1wI-Ja{wl7}UT+M|oqh3ygB zj|SRDxsan>plQQ;n%}jN!)iRfbKnGXV(_~=64+QTw;k;==xi-f5K7{&7|LL{zID96 zPA_+;!&iI2c&g?MjTU|Abh@WvU}b7q;+SZxH$^(Ni)O=I^`kMT*1?jUTXbl(q@ufM zA}C>?j5$#h(de6^C@!Ua?Wyo9+nR$yc?d|SfROou|7jX!S?*A}4|#d+kd^sN?XZz0 z+wWfX-HWudLsk{pcPFy%KTJ$6d-txr7lc_!x{yIi3F{%=9Ag%5-nY`;Nn)?!y@sC5 z%O?_M(pgFiu6Jum;^%%o_M@bKI+giZvJDH4LOmvG2!)$R&4y0-c_n8$kF3rex*tQ` z8s0-}vcilSnv*g-6%R`b;0;YNK4rQ@AXyY@mvG}-g-_n#&_Oi?8${x#ena-CphT}^ zahpPV8tY;P znVV0hc`AlVb^8Do(Op7V8&5uD60{of)Lt=xFHgyTuvAjp9f5X$@fb8Yv2f?$hjaPv zLNT6-yO8fziTaSJ!9Khvr3TIP-wM&YN7(~tcF%{kv0m#?;Xzp8K{0{OrC!OEPIt3J zz+<0xb-z)P7~uyy&HpS^hx&Q{Q1W~zI@>Lw5j&-?GbbtzqxSkAhq{dsvP1pn!$9X` zMa#<6Sr6`@TsE*dyhn2tt;he1uzWtdxgbw<=FeWq7PVJw*y`au@MVc4^nK5VqOT8HPeUslNJ%207v$bglSo3u8S*3CTdGbEjhf7q zB)*dA?o>GgjJI*dNRz2|vO;A?}d_>6GOoR##k7vk63Tb;UIrlB`eyy8j=-1 zt%$IaZIxG34iQG#Ev+T$nWa=eya>kkQur2=cj2o-8tsx5OG~xco(k;+Ef^WFGp}!~ zrtFSfxsbpYYUzxBBD>yOnV>Os4<*IjC|Er}-QzFt3?+58HQ+~S>}nc*RC~SJ*B*s5 zA46J)zt|U6P$a~Q^m!70ul zW@z<5lT~$+U!=0MTcY&H=Nrawg!OA-{o4YI-bX3&qRpd&7phm-j~0HZ`gFinKX-_* z-YZ%9_d#Pnj!Msx?R#guawx?X3RF~U!r-g5ryewas3={YXY z?a(8k-4Zr!gk{JycPRhE;n%S6;U&BgdY$8Mg`mBFN6@ZjJ)d$Q9C+js9&NNXm%hWA zlo~2`fr8%qaI&o=@wGk8_=L)_hTKZ4+#xe`OFXu7AxzYV$DPnCMo>@UH=DnNSP7Ca zGbb8J=`76~umJoyzt;-Ma%(e2O4LhW10Q97b}HN}xj7N9lG|FkDvL3Zo1F9}gT3hs zR$>NTRq@)w?H-3&E8vj1skev`enPj=GqX+#zs`DVbPFbVep>@%Pm_-w#Ya0?& zeRRkpS>leC$oUW~79hnau*5}^zQCRQ>o86Rya9i@43@u^+`D~QR%EoI1pRsIX;^TU z3}6f4%NJv#DZzp)XcEH@p|t-+2;#06vPa6cE7+g43R7NY27g_jKLY%$La$^|SY2}g z)R?F(K_#YSV=VzI6|~21gt+`h#L)}c?pR}FY5E1ym)MjieoO5~3DZvLY-zD*xzCvi zQ#z4enwMMjW?YAFqaA*9-Q$GmiK3T%G(SCA#c+MaWm?s7@{IfWr{y6<#$fW76o9WZ zh$tf`^G{h;IiH>IiaO9m4<%@P{e6;y9Iwd!cC{kCtwE9zzX(#--)glECuJ6@ylghO zwiB2W%camM1?lxRAYLqyy6EQ?DNVhSyQ&6**;1EY;SX@HSLn}(*ng<)`|hF-FiwfT ztyC4FGC&#zczij=hyO{bQ}OD7<9i~Np67TQGMwxXn?iX{BnLMBc*G%o6y)Pb{tk0G zV9h|)JM+^Trtz~m9e>Uhlw`VT-M@OE%Bq^;7s)T}E>c1&;@GI`d025=KECyarK^lN z6~Frz!3Sl*Y|0X-^6qHO-IQ2ZWWMjN?DS~CQ==R>Q`w&U$16BPBR5K<6Fp8hN+?4; zPEBWNG=|JolnZQ;t4W`Vt>*5@FT6M+Jif%zRd5Q{O;^L)vF)|4@TNV81)JtW^AOTK z`9GJ?K8J9*rE9JOF5mZu5=zw4DjWI932X25?o0^dr%N;vNcdw3Fv---F}#A!ql7cH z5zwy%Uil}ja*J};c_lB6fNo`;vg0;@SY)|ZKFsK%&vp0re{08$4<*23r%u0!KzyPe zJc_Dv3GZ>hTXoh|RaV{W+vt^?aDn$2CPzhe04!(y-$7bS*T!#whvFBM0DI)HVf5WE zQG6KMiP|GMcB_QqGf)7v;CjL$kXuCX>^KO+u!J{y%2S=)Yj2!ew8oQgvxM@&9$?A> z{)#v-r?-HaFXEw!FrKlT4 zEMVW1FGZDyndjUcqA3%~p$;y8ChjYn`mRX-L-LbQ$I+s=&2dE_s(y5`pRYb#d9%rM zw%{KPL2jW0=dhqG$&nSQTSCiSkr7pXukf`k_2s%W; znhY(dZZV>L&Z2!D0CERVPX^$T9vUeXYeVG6*ZB1-R)!gE&nDHQa^} zCq11AFX2iiXc^^CLH7*yd^(LIbE1H93-pii!XNi5>Tfv(`*DgkJZFrYTjU+1+!Eep z5JAG{rxENx)s5EegRuba;Ct%yfVFK*V@c2ASL%`ZBbff`@oj61P4)@pH-xO$k;aZD z#*xL&9AwW0$~oPA>OP?{vTo)kwH{oJq-RxqxO_^x@QE>K`Q_I^brs7%n;66}HPXe8 zCym3_Ru#+{AnI)OK-M&8y|=3ktYu*fLTWwcMDw;=Z*U|H_H}dipqMph?vShJIxr#4 zp%5^o>v%uXzBa0!87nLPitd<@7YG;>A0j7N(N=<~_K|{L`ZnH)j_*_@$S*nY3|_}?s1*Y3H}j$~(8sFR}!2{t;j1536hPiKOV4F(RE zfy&Oa)a&e>ieQItc7%}K0->sWJ!iZlGo2H(F>CEPOIZ^CD5i;> zR~_qacf8AG{k()s-MmPXI;Xat*K!wux_+^K+qtR$8G7e7hyN8x3mPMpcgGEp&PJyz zhZ&<<4klrGm}t>x&JGy5TOP0;%|2M(#2zpdN)&Y%nf%~ zelFdC#k=`Y{@BwDmU;%P6u83&t2+)d*na6?DWMaNf^`uXTnz4N1Cxo-Mt>_Xdbk;` zGqFJP@ke@xux1Ts{N+%2@|>LkC=Y+fuzyr^*vfc+1}dJptsjQFp01DOL9c^Z0vLH< zMh67Dav5m6(QL5P!q{0bM9@9<6p!rcuw;ZkOjbSFvRjc7sYBA)!MJ>rIi>oG7Ux(u zc}-q%4oo(z@-n$s=#B`QA7EjS5i!a|0s^76!v0?qGd>vgL zTr(d-4@7A!#on-JBMbD%zqz(hKGD3aFM@JQ=v-|-DmpgiUwDWLB3mM70I<0DWe^>= zURa;ailc-gCRlv#aGkG$NQ%;gL~Fo`mQ}ffEFN9oJpAY#2Ivdu9tVs#%_G^Ylmyrl z^fR3JJ93-v;&Ga6S70ny&E%fO*^6L;9Pv^v-R|O`8$0pyUKLUyAfkbBt~w0t?yGE> z-mOB=&$B6+s3cgdN)kbAMWN}vL&PqaLb~%z&3KBEH z#K)!scqqlwYFhCj-zl5gS_K<0O0#+>KT_jXV><64(W7}|%&FkP{$$P;(3>Pj5M$co z&jrgoTKY2RF$VR*V^eoiYVlxuX!gktFjGbEt=4(LhtdL_@`@9t&rG@(5XpN~#0 z$t_CSC3^V%RZMd;%8vWOpAwx$o+ZaGvx~Zf& z#N5Dg5OjL40TVzL=>z4`gY9B07@+@YSeXwh8Xz#G!n&^<;7rOM=s_6~-8hixsopL+ z@@{x^_8-XNFFHz6&Zn~`y%?m9&~jCnPBPZRzU>HVnP$q?oVF58(b$%OQ>>)j4BpAG zXi(TIzsIGRzmz+^zm`nDRigP0Nx??x;Y3Lp!bRF!$7UFw>P@{&aW-c>pX_4*>-Xg} zbO#LnVf8?3)OboQxn@gyYI|IsONGtYKo(ZOB+hZ4>E@Z_tdx#O!=SPpK0rL(*8 zSaBp?LHFQ^chq}aV z)jr@|E_=lAR8B{6$vrNq>y^?BDBC6V5}E0kDUK~3GMx$OF{NM1giEZ9`(?vcmOOr) z^fJ3%t#YB>!nhbiud^w>qKDUX_#h|eyD`u+jT1w93X&dZ_MTHP9W9Ec=yyj2r#z{H z7lQ>zOnWeKeWoD8DcE@6ILH*d&+(X!J6z#c*d@c)(!jXL>ui}fHqvzCjm+-}>2Zk( z++XH(HaJGQs+8fH_%&jW#s06q4k zwvENNo(e#&BPB`0t;pa`@)JI4=sNG8r&uYbxW?(4Of?85&m)6(p^9-%&U+A!+D6x;6ui7Feqta|~r$t;%I3 zS8ct{%FMmac9;VL+~bl!bSfRll@#k%#S+4UR`@v?`&shb%bJT5rnZFlOjAXbAoH4( z)&~2@b}IQXEy>jSxd2eGq*&DKYqNo8Q%6(KF1x_6YUUSD(f9o#2sjr^$)H~`#Dw1q z!vz+dd><&{j#WDRMFq42zK(Kpc_M4-l?>f`jB0i1jMO)>ioF5Qqp>9vEd}8l3^1qQ zwFAckB9$OXJ6-6c2Cd%!6$DQpbpj?KXwATJQltZ?xiH&PS$)yfIYR{_E;_#zv?H2R zutZX?Mx}a<-0* z@|KmULgX6GNsoNsO6?3{+-$2SuXjs^J@R$B5NSzwQLaadkHJ{LT9DZ(+35j0^X;R2 zuJe52eBON`JLVYW^C=##$2512_7r>qgCqU|;r<;A>}lKlb+}Jf-u?UySS*Y=ut3s7 z%Y$(;V1!N_cmQ3i1|7fLWmT@^3qP@a6n)DRZBuXM(81UgH>a8c$2b>2_S8#k=1y_% zy`x)8Ltro-;(u_?^>l{nAQ*=BNBKgXuE;K3t+?FQP+{0vZ)+_ry;_jpb~M%yG%^3E zYVzpuS8^p21JLaq>+YSwgU9AVGL9q*aYm?s$}m*Gx+Xih`u>@F+KA#>fdZ!?IWTG{ zbysa+&m511;jJOz7+TxqoTA)Tf3bQya`=QTQ(O999J*|70E0uO2#_%%q>=(d2$jf7 zhok30&5FMOL&4BG0i-4_kR@${^yDU-iOIi1%!#q{u)R9{do;?usD=Afob`z=|*f-9CuBj8kv z;H!prgpozz4nMk=Qe=|_h9(#l?g*7n8IoJT6%Txt;0jchz<@%CbeF`@D3{_j956ze zr=bmP{xpv8Q;e$Cf#E;yG9QIHYK*wC@VF%Ik0p(KHpG6updX`O!>3G@30f=U4&rpz0*KVmF`zn% zy&hTm;jjFzb=Y{~_@|($aWyHP_sJ%X&sAus6=aArqJv&G(j&IX;;1;PeYg((Ju{QB zWUu<`(a$gb{3o`vJ*ZXQzhx}>%K(G$&ND=8j7tF@Nx>U)m@Z}20=UzaH69fPpl@Qv z=hn^e4aQ^CHi&nH$QutW)HgePI>ZO8;$@*atN02KOPMi9U`qaLUvkfuxBr?A#Z?64 zpBzewiLot(wygRF8s%U}G?%%}ZWSW=;e?hyp4C%sX7MrtJ zqBhWjCD}dmdw?kxJ@XnF>}vBtZK?1og--xE7&6=`{4v4Bcby5JIYD#-MS2fW6Xg$l+1TZKoB3_1xL ztr6?rbhV(p>u9o~dj$s&bhd#doBS@?DxwW_78l=v0HY!r*m4D~6r`C+PtJEW42)PC z$PTRTtJzpCyMDD|xUIp*fGq!cStkp86AA@3NH^%vlifa~(Yxr{>64Po&xAd_$6@Ru zuMA+vIuV%AIR~v#jb7@m+wp>{ST$dN1z$Y^KGVQgqS8XR~ zIz}EivpG1po%$EN%Jh$xu9x!wjDcaK4wcpNlR`BiJ=DnbfKCw9OKX;b4P$~&8f%Q< z$=`BejBznqI&si16QHl(u%>%7h?yusDq)tE6z1z7?1 z2U%=?7a|W@X35K}>p!zO%B_jl1^oZpxW@fy@Q3NB9zv21_UiyHqv_^k^-jfo>B%Jb z@VmeX*NMuUD~mum0!%TDwXyv0Zhyg%)`DYRaWnOYdhQ)<6sJ(@$LPhIqsAR;k`{Ec zlnhnDn!fmb{(@x3gt7YZ>N4lVvjbIhkCdJQ${`0!_Gw_GL1!W^SdTaxU|k<*k`U-B z?pLv$SN5xDw@N0t$E<%SslQcCv)!I6!Sy=b0N1Dz0>{zG7Wz&;aalbc_&^XIO4^?h z^XXoH!QN03h&c}eX7%&$@(v}`q0jp300ap=M*%WfUXfKGP*N9#l!>s3q8}?U6tC)f z%aSKr&S_5keC{?foroGL1)~g3(f*E-r2JN)2G(i)RpgF$Q33p#QuyO3on|`5Y_?H{diUdSYAUuB|2YmDL5>wxdQ{X{g~h z0rrnn&ME1s!BHeYzE0Dg)X2;#m&^nqLkggv`-FRx(UrjyY>=XW;i)#mQyCpqYzw?M zDAqPsORrxo7>4CTjPvaba07mp4eXR;qNl;furpvy9w_L*nn2JG4wA2vl{SvEQ9gEn)aY-yVUw_Avf)l5JkvZ* z`LGATVdXBJU`8U_(_(9=ZGeMCuJuZs(h=LeMhCgdT-kAtOH>EJ1eoM6hz}(>XT%R4 z>$@8(1vN9ASkhoqE~~v-5d#Jd1WxseIxy#wtn6(V-zqz#iQn%ppoNlf`TQHg4bf8Ol(HA~u!R|W3Ir5LS14~TW(-)PCHXu+e5z~z7n zqv!Z8q>Wf8i!I23BDurIYt*;#Weepc8Cvpa7r?Ut-WBb(3QA)-8VgWIAGZYLj2)?G_OC zUahJanhrex0B0MRV7!&;*s1(xN0rM;0!}mL;&nDNx-K-%eDj#yvuH1%nv)(WYYSBq z^u*0JsONLrj^>&5rkr-Mp=?=CjB6F%6I|-XdS{FvE5Gc_&&#W#w;e6#L5suTB{2rF zt#)9kEqDX`G7Az1dh@Gxu4~#@J^6jNc6#E{|&9mBP(CmoM*|v3LII?u$;){Jdh%j z!CoFYk~Nd%XPgnxLRib^RStc_l3dBsUNBCltOkvY(;VQ^sJ4Jz3a9z<2~b1=B{kU% zXo#7GwA=a0=sM*oIF!b*Wgu3HR+Yvy79|Cgcu1%K#@qAE8EiH4{Ffy_^k#DTyv&nq z0H~;3(Q%#y&_}f*b*?&4UyyBKE|F&29Z9;C?$)M{DfV&{FDv^pWw;R+a16|f&Rsb0;uYv zHlf?iIjUcQ7|u(4=34>A91h5U=cySE(g4eNpg1dJDvx$>ovv0FCfI(?qQ(RI@k*|E z12B+QVuqA&^Ar&PR{5B?9xNcI=%0eDcOaTwqbxK<>4Y0!Wmvq0^ z$t_l2u_#ON^Xd^{+|Dq$^V{eEAcVkyAyxbwA}11XjR`+2(x5?~&go`Ais287)7;e@ z$PmZhTu9s^`x<&rUJr__-*UNR@XnCs^p_Er%iml2q7p~vd^&%(sIXmEEN={XS>}V* zWwBCEcWO~?k+Tm{6V07r)Dj1M;oPxs&94lTPwv<5v{;s%$grV7hXz2}we{`T|V zFZ~|zVGH#F?Pb34vsS}0tFEjBU)7V?Yr&E#&I-NHl3j-cG>d8lW)|A2ZXOKj2b~A;}U@gjK{Olrq?cNRY)|c~Y0^;lm=yBd!$e%mOJ<1n_Wn176bY zEWG0ozp2}tF<5sNr0POYHn3}Jd48DS#*)45^i<78=5QM3=NxSyIqvABjt8)FGqT5- z)7xNcAZq~AM~?Ls*)`Y)m9H=CHY9&z$)iWrYMW9!#g#SOBdz`|6-4cWL9(~D0ff_~ zS1Vw*S#U{;1J1){;xO2aBSr$-dP3)YnTFO(#qa+`Ksy(#h7HNM@5x{MjY0C8f%JxQ zQ2;JwMxU%c2+sK@p;2Ne7}HMkWx(N9!YY02DgU2XLJj*v?BQ`cjwA&&w5ABBNmz@@ z@)Xotr8AEeiqK9YyN7lflC&0fn$fLwXr~dhp`E57C>BY1pBzP-Q^jc{nK--~JBW@u87bd74!{xY z>un9de9u}xx8lh_{F92?OCi$JPyy|0TW$#P=Hq4OLwah09th&W#7cJkP97mlFv{!0K58r*ttna^XMr^z8IXCK_4`pg6$kJWGge`U00)~6v&_( z5=g*W?PQSlhsn(-3|i_dfQp!KQUt8}iyi^z31F$Q;)XE(ZB7N4qdd#?+@sA;Bk~+z z8POH^+@s&g_4|+VTH`40spokWSBlnfV_QvEbElVC4w}S3i>gqws=NS3gDMu-zbad> zQo~EndkV^;2weT>g8_c~MRMU@BcHckys59|(LrYRhDV>x! zbr%vY9-pHF4xmAW9KRl(Jv9`tMmsik=2xRrunlWpHr8>j(4(#*ty{Rf$dUt+q@Efn z(%DsD_tCR|`6G*;-W00$+pA~?kiru30dhqz)U~gtpa>h2s%SJOYbe;5bj8NxSU(z* zhxyo;gfqEd7!Ooo!}zzd_$|$pwf2Tc^r%967+BQ>RY-Un;h3=Enw7N_1}C@}qQUu# zby;FoULG~TziTfXB9cKTU`j)KYTDr=+fR#Gw(ybox!=R^>~eJbcYpGf z$VFMOtT>JBMoSWLIs8hNH=h{+aZ$}StclDJPkC&t8*8FWtci#SF^&$L!B@`Q_vYj5&^dlj}Q|-4$H!(a=_Zq%1%vyQJ}pu z7up*@0P`5zW$rgU;yh+xNwQlx_bY>AM-(?hAzpgp&*Y-PLk5xgKkFT^2##;?=ZlIeq^>jGzwS3j?bz2!ZFL>yvi=-$381RlY1q|{7LJ1Tw z$3460L)ii2z8YJs*+> z%32@LIvsvcjYje~bPzN%jO4jyhTRW(2bv7~rA}rk(>w)tprf$gSi(3-MmqyeY{$G^ zna5Tp<5l_p(8bX;{3fO!g!F8A0uC&>^O+X^y=bl*(p%!OA$<{>_1=TnkbZy-X+N|R zjh=15+V&3C9i`aj^_y8vwJHqy(bt?Z^J*vsdHg~Yan3W7a;Z#TRAyHc5?$O3dlY$C z3PPVsn7)81FM|}5e9I@4L@bQ=2IVlRBz|mdA94X3iY&L3gKe=OihqiwlIL(92V{FR`b+*qB2gecvTq;ouQ6_92)S!7Ed9l5IZNfuRF z!O1XcJvdqhRBmJYMe6e)*<_4WKKqlb{N`ftNspGb8FU*1?Sa+6woJ&bcUKO3w4j4m z0o;SPLv4jQtnp{T>B|RXq*fEMlI}{~#er;27i(TpiB!*9*Ec4-YXhgOc31X7azjve zHskx$V3(jXP(g2(KZQ zRCvByB)^CiFVQe>M=R_DVB zLV9FSwdrWfDzc6i?qHGJA{zLBsG>lCYJp5a)xc^fR+7~`Fe^4iDujPUR4_ixYXx0M ziFyG1H|CTg5YZ-bhcycQRmjk1u}TIciluO(E?B^VEtKQj$xPTGO+puUOIN$I&(ugr z$wl#jUEoCigmf9F`823ATYwFS4J9?|P8$#e2<{w>M&6)fu>1ly`W}Vk$LWg)RulxN zu>T=pcu`F3>E4uDLXGtA;NcKTz>XB_B!J4lL?RUkS_ttq(7;Gy7m zK=oCWnCB24jpdfrz|_HCD!RCFztEZlT(~oh63dFtA@Q#TGhc1zEqAnsxI#*9+1bo#GO0v4E6>LCt`3ZpsN$Sz_TQq@8ne%6t*2r*xDJ@!5NRV^%(q6)+V%% zjdM(}{y}JOMD8#I9|V7~eL`&d#R=_uTso){;e)clWb_>*7}OCMeq!4QoZ44j3nz$h zRGRl-)FV?1*pE!iVNN0c@b1c_bKpY2N82tqZ`7`Y<3=#ifI0Y7a)7{Cbh-JOfpiw_ z$VZX<-5^`PZEe8mT4}#;C73-~04seE1O|ufIJJDwPz^Xb&iO=vqhlVh+FeIiATJSN z(jbi6yC5cxA1?oYxgm^!1Hewd#P$5I9*coChS9-0<)y_pDKU3oF5qs78q+$d)h zf9y0Y&XETC5NWCAwfs6?e1iE*IeB1A*#z>CgjnyC!D>Hzqgn6xNnWIRT>ITG2*wW4 z#m47c`3927Nb}&tVsECS;FRtJ7cg|I(ATf}HlA%=tzTt@JFL9yksrKfU>cSp@H;6F zCIa&WE|uVf)wOB>1g>@6l0lD@1jDiZ6!0X$d#7R)BSPLd+Aud4QFhK5aWXegk}dgipFUJyP&s zg<8(T5fwMl(XY)d?@VYx%M4oFwtH(CPYzQYNAE@8Vd;T!+z94pn$2L|8V>usAxIRi z1}=!?2Y2n%4$wSW;v4IXbLxrsRbLsj(eaKgN3)j;xzQHlx+>!hM08%`N`zmW>84?J_F~qG{YM1X2V$FwKdpV zdmx@OeTqfh%_uaf+^RjhxzCP!fmzko&;|N-aL@;~U;9OTK#NnMs+=f&Fj@cykKGS* zblRV^8wSgR2gvZOP*p7gJ&HM;)Qc?8?gs1^6#=)KEYNGOm(ZEHo)HvBr?R?0Y?Vua z2^gQ(+hsAHBYD*HOGMl84U!N?rwzxu1GQ7^M3IVDugZCb zMVJPZh4UUTjv^?tM+b96;D_1htQ<(W9nd9PMzxjD9Zh~DN)8OTLj2J*m2 z^!D5b4^At(J|wX%c&t0Gay|b6pke4!w@A+MMq9?+_WSqZh8WTWlkwHu*p6yZQmUg9 z2c&h6UR8c-GIJ@n5+tDT>GuNm2d?tjDm%MbKP)d}#2Qvn8*AwVm}fM@(Mq6}rS=7M ziM^PDFgTi8I&G{+bze{1=f>by=D|x60RYVK-0o3S4P?o;9pFLLvA8SJMGXI0=F#$Q(p=U~L}tKqNm3EXxPJ&8vD~ zUA8}PPfH&xDeBDI)*iM-+nP_`A20wmg06K73v;yPqF_?-~`qUSzxhI#>h%TQC_JZ95X? zSi3?D=f-E~*kyD)Xfvt{CdW^3JHZ;(<8*c46Wml|@16kvNmvb`HCA)SS26Auv)hiU z3?+XfCwGkWO^gSZ#G3(X>tp4%9rfATIm$~ao$CoWPLh%la~-(CqmKK|N07w{7lOsd zycGF9QG`X-Iv^VG5U&J7%2Ve-d@@X^p-jF??r25Qn7*2Ktfl2w3##CO^g-~r>zDQG zv$7@?+o>BT+f3ImNQ#hXTRk$h40R{L1PpS)W6!wCJ=;N4b~1a^%nq!R`d?KfG42Jv}sV)WX zfOrmy^TR@;yH-)H=3Gd?i{u;e-s-V*7DnK8B@=)}_6qeev(%wK@#)iGAlBbyA*Lm38taOOj7%PnScp@npWYvqPl{*bQfGsk&zLpO z&UCD_5Nl7*|2I40;|?iL%2uW(sUHn0BKQ=3YO;D#@u-DAJ26)5uD!2xAJhbk+1jVU zv)KQ{!!I_TdDJdl(>(idn7`||Q_4&|X;#Xg{pX~G`}Fvrd@@xVJd^V%b+#oUc>VNG zW$Ib&V93n4baryqd`4f)Kn)S1*1DMgj^srJm4Cfe)~|DK$<*{888 zNxM5+^RzKXF*`a~33V7N3!Z&6R_3d4o0%w{ef(%J4ldOSx>l28L7%>NKTbRwn=sR% zc5l{L`hI9JIO7|u$Z>6GW-~m7Ir}mXqv$%=b2|=nV ze`SlNNvlqU#;kLno{~zqvln`c>qLB$ut#>YBKM}*nXm5q2aWRzEv%rHYWQX zQI%T*e-cIfpzYvG?iLTtJRDbgoWReN@kvvf&{ytxmq+08pg5@WRQvMer*>KJ0pi)2 z%2`d~s*_JAlB%1ukF>?JPn8vgclS-MOr3cY{LA?w{=3s_nwlr%$)E1Ds{qFapH*c_ZJJN8tdHYv*W|k z&mTkKLtF9>KM+@6S$C^#C|Z#^`}97vy3v!LlutFC(pcK`{dToDb!L|RR4cNeuU|S- zmO9hh2>(qJ?Ws~~IvsD*^7Y}#QR*i%S)0!66tx8X=(q1-{>oxE+SB2dBYOPVhpJ3* zRryy>*iT1S#<^F1B30TZYi2a=$8DF{rOvAAig(?XPeO%gU#E}lHguz9&-%`G#XRk7 zOwDw13Ed`rZ!-M)anBFy%J@)Z@2qeBfd)eL193QBoBCkrB!7p-H}z@V$_sXZqx~x_ zW;XYyt(-l-?(mQA;a>gzeeZ+61h`~SJ~{lMyzPrWr+=@0c*AJ_b;?Q>oleb>9;DTSLAKEn6W8ug%zXYeEZEC zOLpwYJ@n>Re<#GJvs^RZyZbnp8~$C@(Imuv|eiYffyRLQdQx8Ptf)9Sd-ex&=q%`AB1v)5va zBH!MbwWNOarY*OcZf-ZA&sY+Qcik^@I&u9aqq40RhX3)GKh5fW|JN^nzD19Y4*DhL z!vm@9N4|Z}qlg&WSbEs3==}Q4)Sk+>c3tc5-Q@bxX4mv+i=USnRP>x>X1@B;{{#A< BnP8|1D(lO1rcP(5P8)U+0p<|YET1Coq~j|5hEh9RSC9iwi1FMU`q`(0iumbWC?u#bHk=>XWsYyec$KrB;1^P z?z!ild!FY!%l~G+w^vv7rj08)Gyj6r{7%k+w02;xU$G=!cE6k{Msr1wCBd^3C;B2^hA}% z%9Sg7)2DmWrwnR*Dr~llPWMi0ou&tUrkd-G6QAqrEmp=%H%}XVraPw91GqTFIPG-$ z_E`G#P`!5gVaw;~Mh&_tnx1l+o=BhUZJTb+AKTk9IoOcmAWSgRZf_O&o?_J7v^tq_ zYc%!t!U{8OJgY9N+T%M9*?7(v`+i7QqCn@sPHpxZpBg+~T`9cT_=r`ip{c3!ZacMx z3`t#q6=}O$GDt-8&YT~UCkL|Jl2{(#?lfS3q{gicKat9 zVT>7Dazql`6kHlbouOp~wBBt9_GGWgXDsayCYou}Sl*V(&Tp2pA50F*JpaLes&z0U zX+3?bh3tD5QlcE$j9iJZIk=U*M#)&JrDY`vnmiw?K19wO6V^Lk`?@G&%#&XKK~fq! z?dX6&=wZf9WNoof#<51NT8$Z!$;`R3$q9qgrm(^-TbmlL*b9Tqw8^Y>7D^7Q-?Ftg zBWVL&W1+m-kYX>4z));VCHf!f!(%jAes1K-O}(i7UKTvs^#4z} z-CnC6VA7BC87S#r#ME9U2UT3ny$s3iEK{l8urv2=xZr`jyB-wPg|Aam2=ZsYYb5fOaANq4W2*p8iXaj18WUY{no8D8A(1fk7RnV zh2Ietv19v2y}sbhR0cUG2<`?5ytX#n{^(I-aClR<*IL>4tA45|n;OC_$putty?e&% zco4%>_HE6QTsbmEr_a@x4lX)B#ZFp+0;aO2B5F-Vcpt4L&s2mrGbH>s1zwp=-Q1@H zcm3u{>liC#O-$5W3C9G@pMB!EwK+p_`h)qxf3x*OV{#R$jMhR;raHJih0ESzKJ!fZ zWDHU5Ge4F4!o57^hrG}E2p;0!m7x+^O9_o%H`9o4C91k_B5g-){d} z?HJQ4%Bc3B7nyP0=mvA;RD-9ju-QzzgOzVB5Mi*|pVRk+KP_utO%~YW73iWn={cH5 z#Z&B|C9L5q&n!5vOlEmowGL&BVaKv;Rb-60(FZJ)%?*?GLLUp+-baV**qiLxhOcQg zHqG6s8)c(c8G+6jl8N1dzC-L`?}bIOs}vIO#fMy@lLseVJ(3v6euC1WsMPTH6* zFAaZ&oj!4u)aM^#4KH^kz0Y*vbyn8R{iOhZChfn?riRi?hN8_%S*mPrxa~k|`TGC! z!ax4L#6E{AQ|j#5LsP|qZ(C2n-QEADw8n-+%#3w{{~OufjsLmiV{((Ic2nUWNQTIx z6882#xblZ>rV2lpA3A1U{w8}3c4evzC!Bm@7KOc=CV#s*)q&P~^U(ZdWEQ6Gk;T}p z-7WCKTEL%w`_S`e<)5(T?uP@iXt1Ov&NGf*ohgAQ=H_|9v|^}Ue`&;xu#21C!5A69 z|Eh%j39`-X!~XCfZoultCpG^Q*3A6R&*!6r|LYr=@8ic`Ac$~oY^K{P_gP02+>NTU zA=8LipdNbKNIgHuMFlDZ8I9v*9%7ebLUoT5gGbP_WR6kzDfGE%#=$v5>U zAcHhL%YMctXSvYcM<*!0^wSs5-y`OqKR%G*)9K_{pk z0h0NDoE+1lA@BDGRMnjq1im12&g6~rSanvdhKw-=-N!;nC~?ZP3>~iq|3vBbUM9H9 z_;+Q5+ej{shY&%NeczpH$5y|Hq7ClJl<XQgGO{6mqL%Q zFrI(V=qGE|Tb~{gd_7)eC&+$DCVPR+J}hBe>!wA;Su)%X((JDCJ=m9&j8=6VS&+4a=x&fz$>c(sdSI4-xkG`<%>z}ylTkmK+uG@X1;!tLq*X?_X zp8U-o@!=KPoi~)5Gu?c8-qF6vFKx@Uh)?s}sU7q^otaUJlKEvW`)juDATP#b7Aay@Trc(o|GN^f2z;# z6ZYzU84K~qiN;rcAgR9e?P(=X%evDzP$0W2oylTsqRFBx*^GmE z*MwdJRHaeY++F<|%_HJP_NJe6y)NZ=aT~g|O9fs|S5uak-t=km^tpHXJqcBk*5K_@ zn${z1kzY4vB)RSE&}Jkt=*!Hsds%B%vW9DZ$u>Min<&2)yrtoa!>s-c>3WR!f{!9o zonkBO$m}>j)8qYbzO5hno34@`7?XorB&|tp#&thcx>KK#?R`czx|n|a$BH6zsb5qv~3!yw9vNwSeZy`?)LJLb*-1BEn>&5eX^8WkW=&J`<7$j zq#I$;SI&Ym=1&$P8G0-;k@UiEE?-n`SS#FWHdje%I`&409=bOXDX?q3@`F|ou*bhE zbtf1X`+u?&Sd2(?ITGE}_`ekEm30>^*s;smhHlJ)un6~c_;&?T?#z6dW^Mjk*kQ)z z1>)?9m9_nhD#N0RdM?8N?ln`CpEm^e|6fYCCQ)$LiYnP9cHH&!;~VHj|G*pGMv8vo z8Fuw^q!|8-HevO?YX5PS?5z zEEs_{A4slb{IFCzmO8Z9(OT?;ulIkNsJ`NLj~Ze1iqz)rT8LIJK3QgMHFHLr#}3jK zN3NM>{jdyM{zhOddzL+B!R~mAuCMw>;!4q3`f;ix!T^Ll zZ?GkQ)+qjSDNP$RzCPsM>a#0PTIj&m9Q!QT``W_NJ@GGkE>^)yGKlPJoTB~@1!RWH zzkf+t)i{3M@Oot2R)$Rf5B6|sDUEOQq7uqr3_ES(J%|Vsup2zCfA&>G4W}(3YOnO# z5A90A-s(iJ<|XsCvmdd-$e(9J^&a+K%r@lFJc_X3W=v(;Ay)0SaO3{3V0nPjHKYCS zeOWeFM*qmTSYWG-+btS0(?+q@nJe!$T(PBjEV5?DJRdcD`!B7heEG8m6(@7$U<3HE zpf4-xCuZK5{8hCz+f+6|+WI+L`fHkp^D=glCD;4AiOP&5Z~F0O`m)TlTOO~_^}9Cy zl!(#V+<1D*onEEwPEJ28nQ#}}HI-SJ#H-|5uw#w)JwcuTibEUi5g4VK@ z#!s-GP+jvTGT>iJY^8nGQ+=t+c#P`|IcAS{bLG z9;iJi(Y)`oWxVDow&4)1#^+ja`%Iyx++E;R&>UtdyAKn2`BhWt9^=t^7ay4!ooS5t zPIP{3iPu@mnn!II#~0U~e)sVmzB{?O+lZ-sM%e^=9hn8zuyMUmk?9ukMe@8jaOIfm zVM*dO_Hf8zA_V++`Ak7J{Fd1Qv7Ypv+iGnr{nbLu+&5>+s>OLJ6w}s&rK|AFv7}3Zm;e5)zb(u`L zh|SG_TpT>WAf6gy0VV!U+g}(f$aI_L-cY75zc6;<)HFDp-m4*5_Kd8(rRnyR$Mx~@ z%N`yhAwKH%GhT`2Bh{5R^Lgt=t$VnMHym5Hz0=X>drD*7lj6QpdvD7r#l+>CA~&b) zLwya9V)yl2xi}PeLs{v2s>3|q+wQ_xKbq{XtGcONq20&ow-QLl;OsG2#Mk-k)EXf; z-=_7Rnq(EVsZ+eV-_hFI+3f2{dDkJ!sRD)Be7SzwJ^26dbQKzmg3Q-_4=xd%Q7D|;@9dl`cfZSmXn~# zhUi`oGK&o#1WmHmq|tT#BPSF6Y7=XyMNpi`Ra{}mL4+GhHJ*BLW@Yf#`qlE2MTWC( z3XhYq{fvG2V=awW*eZuM*CN^}rl9Q=nes(8_einfMFq8lblw9eZw6(Keb&j}A4~K* zvZC6^I$~<_%Ha4I`>Z>0Lt+1|Q11A+?DTc_rcVC$)jn)hZMiz(N+SOn|B&KmGo0i4!t36Rk=`y4m8h+85<6O!m7vL77B$%RD>u5XuD-3aW^&c++?gn4 zz=L*bj%ud%(Tjx19X-)1<4#wNFxe;6)Clrn$6~rZl@MIF;W-%y4!@6ee|q}8Vne(< zVXHuXr`GP;s>1%N0LhW!L{@;w#Yo0Jr-xze-D$7kXJJ3rzrKvFA6~@X^C<0wL%8Fc zq;~a%yhCP8jiWf_u*plQ^71}aZGWM8fnFcy>{!^(tjrs*DC~c`QZ{+CII-Ekm96Sy zoFYfzO~fUmfi=KIxzAHm`|6JDp%qNcYq$Jr?cUzLY;$3M_W8Wz4PRWY%YomASRMGk z^sCMKSKT7I&iZIur^g?TV#+*GoVc&Fz9zSv&9kPJaA9urN2DrL-O8 z)E#%-RMwGz){g`>GJO#%F8${+eIP3?!cI1N3sl1n*8KV0#%rDY7gkv_bdG;Ja#ihX zACUB8`E9_5);-PU{odr6F+D0Vwuw@bzF4uFGh>c83X7 z7=BgQzPKEOlk}NuM7<3NCg!<>!uFr{`-zrZ$#Y-5--Q==KU!6K$5oay9uV_f#e>Sk zF14*4Kc=I6V9#cyBBNLvq@a1I_@esDdG6^v7v7X=y!Y$tons~H%NtceqOwr+Gt8Kh zK*y_{x5P`>Lien_plo$#$cL^6Bh1;Dgx|(mGI&eh&c>{bmM}1DsW@XXm|4sn6Km!~ zFrj-;nQS?8NG#u&-n)FLmRr!Z$9p~aoO=mpWa7&hc}RfVpdq}H*Y(%buH42LBi!ud zk9|s)^M>jEG<{v-MVV-EMMSO3rS`u1NR{Q0dfB!#W`VW$B6!wS!-vO9D;r}(R^ICV z_LvdT)lbv9`fvS=Cz{AqdtMr=YTp{{6RU~)o2`?di2v6D-R}D#x#ryQox8!!)t-)F zL!Yxw7g&0$KOcBh+M}2b+Vyu3Gf4Vn5YV|F9O zUYn&5ZmOPPcRbw>(-?E&Jx&T;njYg&;0ohJ-7@xoM%crD3opHPrK`8F$K`xZN55k> znVYh6SQB+0*uLsFaw@p_{&i29uxEp$z3Hf=x}h`t;7Mn{5r^)nvRbp=`gBXb5$9m` z;PuX__m5cN_?+%Qajn@$1&n2w%4aU7$3`?@>J|mFhp%_my*Dz@v+RD*sJ*af*{6h4 zot$Xa^&P9KY5&j7A4+QEqj6K`uP&AQ2cuN9-03ed$U~%ReM1r0VlSxA0^Qb z3dJpDS2Bt(-yRtdxAaYw{o8{hc$%Amf=F@x#i-#bU(5DVVZoiKnY_B?JK4|pMj@3CZbtUpdKY2yqK)v;NPVu;02wH4Rh#Mp;^F?>)trF(L6PgD*dASXgV@UiR|$`btr);piLL zBLmeQgtqrMOz`jCyHmNvqJZaisr^Cu7 z%0reP>jge>wK2xaHf-q2JMOs_+Nu4!MJqSRIL|Nw7auORZRb!z86*q&vr(ll-@nI7 zp$9Cwyu4<5#>RVmh!MaH9pu)zcoW&l@hPV3CxphF{Nx{&4{~=5PZ)2JYtSaM_~ch@ z{%_oi78hRV@+jo|ITmtokx={`UMwMMj_(Gh^b9rv)ND-gKK!bm{QdGhm(tQBAu#Xr z$t@1O0n(7a-}Q(kUV6b~Y8E#8uicq#Q^@g+O`+>{iEN!(M;_cNd2W02&~^V>oQYoV zJ$>cvuKLBb_5xyiX7Y;Ui2`|29c;oqhM-KhdfN+Q@-uA}kU+h5YSo~8*oKoS+FoZd zf{lKN^8!1_qdTQ7xqkA(a_*iT!;a50 zrNyohLh&1YR8{g0@#qER!>g<6N2=e~mXaF-)V0(ovEmKY(@5}oC<_@+qujqPk5nJlk_Mtno&QT@;X^Tda4qoO=%>bk$zx5)#0e|HeIY0K($yI7`wcLj$(ged?AVW*}`ZyIVZe*q2!_DKDm$~h>ht9N|pz)p|3=ARm^ zQ=7J5LZY|d=?EWryDX~&yYapr?QTYbd4Vqaen`TUEG8f|8cr9ls>bdsY;leRo3QKY zC3Zsb*QFX?KlyGl6H~igR(>BssueC;9nvaa-W`f1VbDBKS0l9|IxT`gK7M1VW zze8O3t_xVJBm=A!d%yg{uG3NC@C$@qJ_eg3TMho=0SIwAheEvBbXsoM3d;goVQ!PZ zBwNoPOEd)#ef&j3(c*Tl%U1J|BzO9d858@DQFc_4I0hgM*tKFJdj+^VVbHIXZM^3H z#yd@4C#*Eq3dqedOYeiInzLa;{de3A`^qbWnu8V9K9|}v?U>RWS8tnr-sLW~m1-ZNeU7Q{uYTMG$2grQG< z;YoW%XL$Q%*oEf}F$;_tHTKtLj86mvFv%)4w_)-Vu-K%_F3lJu8-i0Eh^>Sd5#%9} z=ohgKf1=fF{;b>Um!uY~B=yF;jfPYJbg^$blla{pB@qZ_q5dCG&S$Mag4A?~ea|yB zE5!o>+Cu;7b`O~WjuzPNmGKZG z>Bbz|Um81h{V~EWuH4L7o4)a$R8Y+QqsqgYJ+Oy1k#n^>(H^@kowxMQsm<{5{j9M4 zFSq7LFTd;j_SwM$4T!W2` zdZ8{ctK8^3rC-}~N_|*q{Ru{dg)Gg3rP_YTHA1m+IDI za{NU1E|lLqTc^m|BHhB!!zs(S9G`mwp9)n!nGirF#TG{*`oH%mT#~fxXmrJW2ceJW*e|iKaExW+67ub&%W{fDnK5h9m*m~Sc zs3)Igz<#2RK=h@(HOs5!xKwfC>L7c(LtIn%_cSBE_Ry9>;cPXP;F+zJ|Fk#->o)6xk4CmUSfwnA$hJ)$i^W-E8Ew zn=3Z;R=4+8=RkjK=Y>^NCYH0e55Y)iv&&DU4ldBKhAMI5Hu*6)Nm+&zNf2EJA-dX> zYrmCshQzooBjUvO8+tGa@r4lK)4clL(I$7@xaoVU06q%uogHImyoNkRHm&Cs{uvgQ zm^&cI2GC3f6Ka6VZcZJYXWkxNZV_MZvfB-(J5#(Mi^--6-;>n8!WvFpO!Jt2ff-ZT znGy-)bGe1`W49;v-*wNXw&Ww2% z!ugIFR1)50;+wNbB?^ZGPSoAn;X4oy(_Q|nk3*SMf&*&YGZekO9zHB0Zd{gi$PQp9c9W}(fl^cnU^nZY{_US@B4GI$gUeX|m zY|O~Q!LkGwsn0GKsUco;a|L_g4PlQ{5Ugt34brNLc$X@5ouh-WC8OF_2%{C*)(W;$ z+ZuC1=SF?_54tpl71-IpRyor_I63+bLz)}sGW#J$rt4i&?hcOAt;_pz{6>cCBnJEi-)^B?v!c6t|wdeF9c2z#*2e*Gq&Q!lqY1WVvHIpy7uCX^^2 zDjH8manhNT>w`J*udeEim)l{-uD==u&#=iGVvKMtQospfddd1L%h(-!hTgywj5su0 zp$W4xBnDrg7;Xp^WSpxIA4H7Pej_0z8z2=~z{$KN~Qa;&{!b zQ2!hG6*ed0tu_y({)%Q~Nhp+n&bog=^7kA0ix^ltcx*&ES53X>q1W?NfE1gv^$p!3 z=ER@H5wP&R1wKl^ZFrr!a}O{HIpf*6#i@(Q>L4qkQ2#6cQ}vcTh^%6lwh^;|FF#>wS;-?U(Rn-`iYM0VwXygG1mu6Y665m_wtaOBA!aZ`7?TM$j-ubmcW>ltefjMcBbx@^>EPsBc`t&B zaLQ!qc?U2sorB9gzWl>o%H$hL@hg1-`G?;14E%k2I9j=}JF zLRIalpLN!J45O{-l@Wb0%o?&8xB_;TiGOfR_(fvXiC%v&us)gh6~JBGjAFy$GOon1 zOT=53BcRv-Y=N*}P%(L>FE3|v$CdENr9`SkzPzpP7bluyRly;s&kqsQ#w=y(WTZBE zFtmkov$>oj@*u3LF3l7Kbif)mT8)_)oB>iU38yo`L<>3fir~HybvZFu+zN+P2j{zj zz1HvRvXHfpH_ZGBs0fEvWq3NklfA21JC0qm-h!d`c+Lb<^)E{^j>`PYrlMgB?s~3} zGaL&6D)ql%)zo>P30)>kcKRz3<(O}s9-Dr*s;cP}Wy=|_2n%IzLwD+nveC12X;C3T znUGT0U*iumk!E`+x8-QDVO_v3Q0y7F)^I7F{2@9z1GAbb*ibY584v*+pEnnPd$D>} zy;FE*AEj@CPaYe1i**-&Qg4lO6*bff53n+DKb5 z&bUPS)eaUzSk(VK0PsG_Lk55z>D0-ucD0!JT#tz1B^oOvKNFzd#!)vezCgTC&79~xw%pvwc5s>DVMp;4w2qi9ti4VGH9_w{!AH#d* zS6hI!3-2j)rsfcJX7r!b8UDGb;at(9kmeVdnk8cU1I31)2jsw+ePGq*Nchb4?SX>Y zO008Bat;(?^epUO?*Bmh_6rz<(_fox3i~bmiIe?lJQQ)VmlurZTm!EH+z?;^TYSVV8j2@gEH<5V1dfP>mwJ2Zp&$D1YdI^ zWPbu#(d;7(E=)D2M-Fn*J&9Hpb7O0JlN0RZW}{ z)m4l%b~;{$WlDcTp4^N>;sz6yGE(@I_E{?5$c8AAY6D9{5F9!B^s>Q}9USKXa{LxK z8Sz%CGrqryCOh>qvT3J8a&ot}DJB|IBBx$5ln8q)F0|hRJ8>m%xQEGvlP7f@B$mfM zu+R1I&&yO_ZdCLibIr#VKiJ*sV^OG2hI5}&vH9+AVbM6J2_tq5%C^ze0G}OiyZ!PK z*Uvg9dKs3Vhj;P^yTUCwr$ zrrA+m3za0+GTlz_QXx42Y+opjFQ>LpasMUReM2J+n$lB+oPTU!$J~q@KKz+)wnM1Mnz0! zTBJBI-X);qVxBmlMA+O7Uq)bAlq1(`Cs!_xmvQ8DH%&*PGF7wP4$E+Rk?IzQh&>$^ z6scvA-~(|?Nm?!Kp}Ofz#4-cimFuJGo#==o!9XW9|~1q-qZ zjFfmQ<$wGA3YcV3P~lxXrfkUmMs5 zPwLW=?@2XhB*nhe0oTYAUL)V!=lw)qUY31*wAdw7eGB%G)83wR;)EP2-elwfXVlBR z9Aw64Lmn(h~HAUNJt>Yd{qfu9?elUHZwtjVt8rbz{12f^X~8xYuFw zErKL?s?ERl4P$?!zm*^O8HWX-BEYON=j(8*)*gejEy6s03h=oTzNhMk5uV~N@{^9K zK}G<(0rjU4xm65K#uv5mUFor>aslb<-Et}yo*TDq#*Eq;Rr>&4zvYt}50J{|#p=`6 z<=o3$QSHgo*s5GN@kD&;L`X$tPy%z-Bp$;E7;qX+=?Z_NJzD&7kx7HlP92`!vE8!= z6qbDIUQECnTckq|&Ug{9-wrf_R(tX^+{q+O#TOfWmOoVA%a(-xLLfiF5??HWE3wYU zVU~m*r>BvJSmr0X_q%fNbaUAP5=NzCQKT1}#As|3zyu>Pm3cpw4dkT)^I&9h;;2`lXq4bGE#9#!` z#Z(AOA?G+Jg#v>}Un8r=Rjhd#0f2sT+c%nvIN5l%*NC6fRg5K4_9j?xze|>+{!8|7 z!b8f*wxWy+m#|~8@}ZHqgmcL*mPDrqR9=w5Q^S3mF^A`a#D{%Oyt&6uz9L?k3lGsJ zl;3C#Bsq)*!Y$`GAuQdW;E|%*iL5A?9H&A;Zt;!_de1XmFE_&flfB9iCGI*GH8uDv z_)lZ~>%XMqyW@4b{xn?4e}ZcOt;I1=Jwn9Y4gPI!HQ}P;5VHa*{fUF>6L132W`F2e zCqE%O6ZW0x;yMsoC8=}Cf|`Xxf)eQ(@gF=`s){t3&->T~z+0A}W zChr$wXwWrpl;G5Kaow~x8miLWm^vS_JjUZ8H70gJYUJ=$`A&o)F|obHFiXNL9{4O% zv%A!dKx$h+4BjQG!{Rx50T}_wO7d2gKbcfAAm%F6GwXBUT_yxiW`$QvDn zdc7sO7Pbyjb8E(J^q0zTRKuB{zFTCmp|HIw#3#1mcp-dkp(pD(zB@)d;jZkj=~yMB z>$l&ZN5=w)a~fh1b{`wl#sdt7Cp~cR!4Bfr()(jFdYLfo_T-bv(RX5B2hmKu3uG1c ziRC33o96Z(5Kpq(cZy2idhA4C!TCT5fG=Gv>ar#r2k4aE$~A>9^!*I07x&3s@?!4^W#abwnE~&ZSap{t)Z$w4z@xfoHcZU zNX!eVh{?ICM=7>IXA&Zy%bfwFMNeXr|JKTng4g+{{)ISx*AmBX6&4QAvn5Mecd3WitE? zJ*gt@ReHc*n8tCkxqw)RAh9JnzT>E*W87Pqg=8I*_F*w4y|<Sl-@i9@VNa2 zyloFTg($bZF!Uuhmjr=4gH>w%?SnHBxmfpC5T-ey#*eMgSJr>0I7Ws#%|s*^RGYX0 z+kzqwfRai9Q_}em2f6XynFwqQBAaoZ_jii1*&n(%)8cj(AUf0E*b%V@FJ_tv{0*23 z0)Qy6b?eB`1$Ff`vMM#st%&JL#%5;+ zfyiths^w6{NRJh03mb(9=|e=raS8ZR zw|miM1eY;&Y#_VEP9=aYj!VAK!fuQEwRKMPU`LE3I3!4-BC;QuB+|s+V5D99y-ym% z6XIaw#=`*+G6C;~jOh|!kmiXeLSY0#7u1$_Fdk`|{EgkwkmO;FfD$2aXnGCOJY~GV zXrK*^O9;W`!T^Xy1d+lf0-O_hKs*c{u$5!!V}%p0(Et(Jq3u7(ELxYzhO`9Vb|{bv zeD*Kv0p2FQJXC61Fkp_&3K z`9@{H68T0|Wm(ASC*P`XIQ@)(WkHPG;>(wgB%xIR7W1+ol81{ZM7$gM6`A@JhYLf* zX}qte5(>dZz~0J2r9;S_GHEC4(GE4l@%C&hyE-x;;JYTALbyzVh0I$$nq5t!#Ue6< zPvS(NW8FLBRg|eejUNaozIDbc20yHNxCz(;T{Ex;5)k=H<Nx?Gf$whpv5ZWfhsaZr0%xeC9 zdz)l8eJRGebT06Ka*BqkPf`&Eh~!1Sh=9uN+#>{JG3y8=krwV+-WEf@%Ql>u9g*Hn zf2;lUsQhD742Ij>0EY=$iao8!KeR2nqJ6T$6%2!2pC^_K_{qBykZ}pNL0DTux4v&m z1<-FJ`;;>Uz{|AG&WgKs0K3f?nocT0)6%{|0MtM=jjzv()spB&CO$*4d^ABgii$b*!-t^_04uGPVdnge( zDed@#@~6x_D0HHpQ%r5 zmO?D-17e{CiQg8)-gu?nd{mqo4+{feo{#x?ggqs}vlY9VyH5r&DBq9YNY?GvT;EB8 zU`b#R1k0Ad$517OdcLV**)Q2Ne$L-aPHZ^hnqE>4u`E~a3FiB+2L5BS6d_@=un^?5 zlU7_@P(jkdMJ>@zoQW9tuRz9t1^W@3h2(V7h)YpZMo8AuW&5+oR?H`*^Bai>XHQ*+ zfg33!m=h-eUR@*81tt4m@9{1d>Rh*a5Bd(#V=RGtUs`fHc>}~ z#?(2}rCYDy8__b=wRL*^#tJny8;?J@&4%T23Laf1POQZhnvH%VPe&*wjv@<_e)|Vw zjNk|#3z`0E6lWkA!6GBufWfDt+h@LuYxRgHkt)($W*RP(1G7MwGK+TY)|CUF(e{r8FY+rtEHr0VC;X!fbFIKH&#aTtECjSy8i@)h7Dm(5m9f*j3gDOMzRz93leN+B_7XifMvg<#|4F4fk)j z#)(|>v(Ul&*SiNc()Amx1;%VMcKTogL~Vt%JSA%3foh~v;5A)Rzv{-V26ntyHZje z1e95jVAN%h8{uo_nFnQmT}7tBvYcm`yAZdwt2?*x5tYOXdwiwHARQ^bSXsfSDsU~+ zJvHNY#*WaF5_3c8k?A%7F~9vxTO!G=QQDS>Fbj{JT0}2ywTSn2xG)AQH=K^-2jUc; z3|cg_yKn1F*|CmF&v+PH6p2>U*z}~N-%w7#Hhu{Y-xIAGmI7u~i)41Q3_z7~v8{6~ z4x4@NV5K+meLZ3Ugk;KM(z$#WWW*+Or4#};d<4{X#_I~9q->JgkZf+PcFTcGdOi@? z%IaVW`A!`B*!&RuiGYR5N@6%79^aX2$OJBh2=SrPZX%M=ge>TH2tx-+e@L$_*^daV zdg&Gh&+*G>mFLH8s3jWu2{W!onjV_ZJYY~*1xe7(gb}tcZ2v1l)QAOy;2&t)GCM3_ z9FBPwLQc5NJVNY25`%^e4KZ-c!mQEH~xry_uon|x8Py^E^rqixbTF(TBfT*Pv`y2}3K;*2Jc~jv#%QrA5<~|Cc z&w9P*&zTdyR*bo?mpbot(c3@I?l?-9*6($h|D2B+R=||WNe}Zn(a2}jK|*(sn@{BP*+v1MKZv2IQrk-Ei&bG)d-uj zfcV^Ib+uBsNMP*Z(=S;Us_fn7(y$`l`UCp4JB z+3F3k^O!%;TV$ewyG zvfAG$14^fm5?rq(h9x(K&5qLC-c z2{S}R(U21csZ6>J9&-`;c(|@BdtN+*tBpZCYpHpGP1moKdfVH4o6gJTxvj`SiSTp; zncH})DFBf8#JO1x^+O~<{A(uf#sW4r+XxRp*=c9dI?LJVRiBxxjBYR^B4X)SCx!5# zei83J$$mNuK%o>vsNDb~Q8|}PF}a1DcQ`X5+I$>u@~K(ekxBZ2N!S$Q+fgtlMIoF` z3&-@pqH=R8t{m_Z$XLtPFI!+_QzFIWZ1gN;zhS!iFY!S-lsR#TsS8EL0^!Jn4W+Ik zIu1C>jD#!{zghy@okJ+%b4>y36r=_B4A2I`Q4I`ecY~>MKtvEVq}fYnqk7Gl(v;Y^ zVfpuR0ANfJ#fZk}W08noGZF$n+oKy4KA%!-_X{fymEzZoxN4Hc3pp=Cw9ZAQU}T6% zPlx$J89l7oNt^Jnl_4qsdd$p`q#j9C=1=^{Pk`IELu;Ux$AEdEYD=tWJ}Yax1p>ho z`@Po(Sk%anE~?*JAV0?Hw-KZ+LsF%u*aOeeCe}6hi*}nbI8j-);H?vHD@XJS)Qp+D zPV@7VyIu0&o!z32Of{=iHe4lA1N3QDU9O!lkuoSc!dx-7{!+W5kykgD1cLaJhZ-hZ z8Ya~ZaWT*D(k-vjykuy%yDg}#SxizPAFi&tnO|G^>;{tTMG{!R&gzH|&?hzmw3k+W3@Z_T^(+zwE=agSndgvyLMlM4VmBNvBa6bHyi^+j$iEnB6P(W`iXU z1t92Uhw91~ZOHUOvY!!XH+-b1A#PexP_;~Zv{<`pgI0}H3^QGvbA6QZsX61~I{N>% zNS77PN`AL<Bz;(@77B<<;XmH$Po3``@TJefbe<3+QH@-*=ni&) z?n+;h2N%Ge{L&*-<~L;V9ew)WTsl#9XhHI9h}wa3<1uCBnfp196Z+u*5Gt#N1ZPUX zZ5qwv==Ryv+%w7O3?;Oh2vf>#XN&*Q9Uh;q$#o;uw%4exBQoIQ1!%fPZqIsROP0P9-OoGdB}MPti#5L-4{}<@2}d*-!E* zn;IuAVe+Ga#p+!gY8nJm0L)JB4@X@wm-!r*7wX3Xku6}#VWunKn|^pjAY)%WmAiO; zEW)1pFzR021HlYkJHX(iv;HxH2RD4?5AnQ~4nRY4qTk&BzgiEhXr?Bo7%R=O|A;&S zcoj&FBqIhg#5oEF%#{X*$||4o))N`T1wXH2P6FnE6pRt((GvrK_1_=5FyypBnGrVR z;@bB5&?3{8X}xA-~|Z*FpvxE8_A3z5L>lC@Hwc(Z@1v8~&k96+U3 z_AWzg!t|Z!VTa#As8y#xa`9@o?O0Ijl}ZAmwZYmPlj({`rARQCM28)7Bne?akk|XI zd*UEf*Pce04vBK}$~B3n*bE78+O#^x8y53Iy(gl*!oL7YIE`M_9McBFKnsHA_TNZs zb$JI7GQ=t*Nw)JFd9^exlH(L*3RMRzr8~rrU?9qzTXk3u(<~x7yugk{wi;Nt(gB4e zW@8UyPp?8BWHhX;tgBc`C89zr=7a@gMhgWncy19S!9lH)(1w7G;^-P-5BpLcK1wh& zzNKQL=Xz=LZs5_m3_1>6q|Kk=74a>JMFI6l7=cFEp5}jO-Y0b%*nCUKLO{9Llrz$Y zkX9VrAALAmD3O5QaYoBBqq4bxl_Ryc6A&ymU0w}YAS67_-144ZOFz2e2siTymLxM^ zY#nh5WAnTQXyA59j7vG_qJ0O^KZn=sBFna4^B$<=ibGg4EFEdP9gxz$xsgZirE2+! zo9d=6nHb(Ir=6u2-1O4&iJGC3pSp1L%1>V?Q}sJa5Ee1wREo4^7}+R{J+r)vZpm~EJ*6>!^68kG#!@f@J{=wY*m$X@ zn-GDmVIBO$#QnP&B@EFg7`%}h@{ir&$ELM&s_}~wC)2AS8?VQ!PtA~26*3N!bSKjE z-6S7@iO!z*L5PUlF5SVz-bliqG&>>Eiz8%iJ)Hu6rZ@@X({Jmmv^}p@EiW0GhL#n9 z5WuQK<>lO%8~H#+Y+B!y4;bGT3&ke8Fbl57AK|0hy;rX8XNi&eg-LgG8Rz7`Yj=gp%Ge>pjg6*h^-xYQPBc!y3~EJ zToB+{WiLK(t3W4*YE*(NV6?HEfe9>de;ueco=Q%bRzzs30G-XMLc9_Q@{dmgpbG7tVZ;OfR_9n^?2-MpPQh#_j_RUk?kL-^j!^SS)b4w(ECoI1L6=p1sp@DGqfo1GIK`D^P%Rf!^Xi*!Sr^ zchDUsqWmoOk*Ey)z1DWkx11Q(QuJWv7LZD<;Li!{B|g{Cr|sG`K^;1O6mTRR!Lm@~lq}4^<$hYwrxmEH{u|9Ad3AT(shqR0O5JfUuuzP7 zUTRN(lz>op4gPpvYInkRKV~QMjxD*{o8RYOI}k1IPpEAl4@oqqFtm^%2-)>jw{sAX z)EJx(I3d->B|sBoyu1OJAeFJJP9wilmg=*<3qJ1&IMa-rlu=ltn7TCeqha}-fH)R< zbttIq`HZ;ZCWz~n zc@{ws_d^2sAzIzLblkwM)bn8Rg27LWs2awENck$CKVgE=vW@6VD%2 ztpJ=9!HnWvyIle{T*@!I|3+%SY>Hna;vO=rA>;>)kJ)e=4x0I~Bi=SeVN)M1ly0#RHG(HlGw4H`bFc4D2K4JA1 zxqkBBmJeiZE>zJJnnsK|M{U3zlCSId_pkf6eLL=j829q?;NiTFunmI~ic3o2S>OIP z0S&Gq0pvj;gfhN3SwW(Ja00i$3DCjp35+HHqlv3qXQ4e%?G>ROb2|a_BV3(QB+6S0 zWC}@P0l2t4AP^K;ejXrk+zqRuq;xE~(q$QcNYq6r^gJk(_YtAc5|RM|w|Wk@T3rDg z(|M%F!VM9Sjno)?H$QnymzNy^+SU11h@$6p0Bw8Ya?DkdUgM?cUmnsA8~d`8Hj=C; zh{QnjJlx42lA9M^Km>s6Cp@Q|V%s|>ZyG#+MobLF1D^bf%<6|^R?&vU*kD$DcAWOH z>{1+p$&kQW-D}6!P{f?J14tE>r$Y1L3T-G%vIIelVGx8?BKhx>Uh|?etz_p0dx2ki0Q16mY03Ykh381e530>|G44p0wki~k{ zgwYqCZVmRqiY*n&7iZ{?&|6%Jqvaeyf~00>6*xkY0|%E<$sR)MREo0%v(W-KxBuD! zq-Z+XK+w7m2>|S7Nt%}Uh{rjZtS$L0wx=#iv5a@~(a1g0)k z!*#P=cOiYqeMH=tZo5s3@NnBJ0DNN%+Z0I76a%aSb%bh!%FG?lH<@X#2I`0O9$wZs zl<7)FPtx%i>Sieooq!I|H=(pfvX$cDKxrhqpX+{ClIxEQ8Oy=EVx|grD;XP)koSco zYzsQxv`2P4F68_Fdh`5m-!gNxxoF=R>t*1cEf|-diSG&g^HhDGZnLk@?|pJKdbjghB=+g`q9G@XMy_F)q?>thqL`z+ibcj z9ZQQAlVU--n_}U@7AG{}j%DJ8>(bHx+Uyg_74NJ#{EAFhSuKnT^Es9Ea&FlZhvTKTgX5*-Ove}Gs)dJNaLaXn z{b(pm{m;D*daPxQm%`6}Z&|clvDrUg`@6y9zuDq*du;gGp~}UAn>Mn07K6j)g<}fO z3SRx|s#ejFSB5^jr1>p(@V1pKZxK~&WO)?=rur9q2U)u!&T_ndpMA?((4#Q2yl9He zoitsaP}n;m*8R-&HTn8z4_dR%wtD~CXNNNP)V_9itTXvCk@20Luk)6{vqFf4JQDxZtQSAwCWLU+U?68WXHI7l8x)%nMv+<I&v9C z);e7Ljc()h0D*e*D)yV|U#wy?+RnLLJEx|}jIW733RX7uGgjF!%AJbwxu;IJ`s{0W zJux;{d_Ll#EncM)Za{sGl9&FAz110eFdO*X)$KlsKW~?BaVg(?u2ud{p#x2^;-N0> zbyisJ-&>ZizXCLLhadYPMUe`kjNOK2J!_ zr;)75#bkN@_+iBvhAP!gaO63eZsnz57JA5f{Lt}3$vK_l|I^sHKqZy!e|#oWDovWq z#4>IEbE}(`9Wo!}gXzu;&D^oNjGB|7kY07tMu*58P;!(pOOHA0UrwYLccKTQBKap% zR8Ug!jv+2bg?v{ej94(GNQ#fU4_4P%>#lYGYkfHEz0W>y9^d`_{SF5>mo+^GK|MR! zcD%2WLwoLiny&1I>rTY8c? z^)iOmQ*+tK?6B1+PzZzea@pOKtNl#9d~%t{l`UwhHLAXOalbbGNr9O8TrhOot23c^ z%r@Q|I+jH>cMQ3DEl)TP3L8Z`WAcu!gxf#*H}wk!<@EkN!iO%cDxxfVsBQFenrt6|5sKCX1+!h8fH(>fBmG)mmOm z9ueC*$uiYmTjgSI+dqh{ynP)$A?W-G9^2dP2s0X*PTCQo+Mr6m=F*8vj~uXiD`j55 zcCI6xD@sogdL0oEF}-g!Auz+`dV@QVxQn%@-~tW)Rtz=Uqn_Vo^~?BgsJ-U*<_#9#=08u>ES-KC&x&Sd zjub@+djl!u_)(Wp%SMc87;K&GYnUnC|E|1k9rY%RdT;$D!6fa7{9yu9^ak^>t6p5J zrxm?76I0ZQF$M1;%pI`@{a+*LEF_A79_qa!xVGXvP^SNBDu?cdQJ3gnS|vq459IV8 zp$0X1q1CLw7XBi$GJb7rSO~TZy?RkSd=M22@8(BrJMRKCz*D-uW@Ziof~*t{ls+bm zIwUcNlF68A;Nu{Cep=5=Weqm*leQ9`Z{h`83aKNh+NoZ9)gXel-$C170Ro9QRddod zX?T^YVUwbI5hu2m9GY7haW7Ur4F+*87{Sqfr#Po717!YbEUMv%e0v8ejuR=YIM$f~ zDFG4+C%uT;&KyF^#U8L|4Z_6c^J*4_(`w}=g#*al9~I~zr>}!qh*Q(ovTtV{byWP7 z(w}v7HO#p9JvHca;NPDY^sNZ-gY+g_0`uN7k+b5a)Uv`FAK~%BQ`58l7~N-(@)Ct} zyJ(OdPip-5D!v=mAO6x&8+q-xTd(fU+GoryU!vth2X;)*i;0%VtH;TP=0nqZ#&2OE^zde+2LQ2(ELF88q9}f?#Ahh%rm+@>?Un z0e!d0%roL4meu90i87@B!f~qmRP9j8EBGFUT?$45f z9;z94gohBcZz-SzZIm&5vrQ+LkB`|c!Ioyq7Bgg|k|J>;*J-z|IDXI)nM^(=litf_ zevQ(cL}~7B#XTJ^OjN{B-0cWMC>cL#T|6G6+YA}J#|#;e9x#_+-JXSueXHet_V7MX zO@Pxqel7JTFonSc@HAv|pHGwXgHbS}GKYvOB)+)MA4elDGi=%!9`?bMO|M0xoX*hf}XzU^pqBS^O1=kIGpR6L0FG+><5;Cl3vCl`s- zwxw-(0R##6JEU>ko6x$62Rd|)Lk4M4e!%PMlK#CPT_hUEj)%=t-qNE9AdG?|Ej&HV zB7&rEq(<`+c=!^eoo*s0Oc8z&Hb|3DAeQ_bWqpyswAErT)RxkDhti{K!5aKnB=?xG zKSJWN(o3_EkTBBv6aq*^Y2(s9l*mDNCO89q)2zlooARk9;S?4q$ln2>q?Kg;kfkyZnD=-{{t4sroFl- zkBV}8m@%A99oh05@M(8@NKdy19xR`Wz5(WxS($Ns7oLGJa%SOm5J)WUpG1%`sf{bU z(MV8XxaSZHw`0P|7`2B12v85sB@%w^bs;Q4&h)#rGz2k}=ZH)OrZ@cpF{lz*6p)Iy z>esyy0%ER2t0eQ0=#T_EUL}5G)|lNbKNhj-A!3cAJKBCWy%d{Hf}F=u-nTLY|Igl` zri#N)e$tmau?t+`vQW6aIT?!ZW0!AK^xA9n;o4%~i^WNzJ%@HhJfJ3u^(v8bMMA(s z%Na-wI0T5RJVEH_eVyuSo*`Zu4JiR$>d~QfN1edAvso zC6d`^DN{M%dzt9?gU>dBJSz$tF@bCG$n(zlg57(8j=}gSBO&EXi`xZe>Naf^CSeEL zzS{+yJD_+|z&aGypa2;OknSYfu9$C`T*i~*IP7g%bWa8Gj+sZP)NH=hCL^&2=&w%a z(YMNRD^;|$iX33?aai?O%gzfM0#~bO8!Au}d!ZdM9SKD~SJZVPN=JgM82h}b!j3R% z7as(b*G_zBb^G=UvJ zQ(>#2^h{US(t_-@_xTg_^@?hD0Njl%qVp}KR2ERY;Jj9X^^gZN``3{D1YyG|RK%`* zSyae#J@|C?n2dxm^}ow|QVouMN=#4E-MI_ILR*W>ALT@|RMls=pIxI!1$>Fqy%die zhm>6{e6!!hY%z4$M&zk@(ZW~nX_GN7vP_g8Z7x;N53(;&g0{&>+q@N~oscK`@Q$iK za~C*v*jXNd?3`}s=PXZV}o2c*EzIag`-7ct7nS6#nkm|T^9X4_C(X( zPH)}8kN_uMOcfscd5jyJuGrPKy%Ss*JdkzbTFRjJw1|uyb#-5^g`kdcq2-gEDo_*_oZsB;e-l^6e(6wXLtD!hH8reI&F;Z~UmNUYer&JhaP8u8&<^K`inVD8`A^ul*{f2j>wHA~?grtyUbRTtjI;p(vYu zcHf(Ug;=fq6q;1ZeRKKM1XO^4z7 z`5W2~pUv&X=m0w*iy%e)!iH!>W#LLNX+fuN(F2*0itzMgQt>GctEr+|8l?MM;e!At zk=NA4u@&8Dg`vgmyy;nZ$gXImo87Goy?=dx7w$MnFNhSdPmzIAs3QV)Qc@zjcFYB-h&t@Z}>8P)R}--JMm82qC!asIvo8p!Iq z%Kn5JJlFKhHXaYno}rUD=tfgTOkSU}bxcjQ_?N00=cNhLbr(jk8I(lGM_>FM6{nT= ztx}1CSVY?M<>yAizA*PgdNGy|WE?gBudj`0mqTODjmp#q;KK)&Ppt2U9LI zNc6}!lFbw>x7?q!(FD6Zn(B2#$QiREJeLGDOM7S=&!Rtl&h&YxPP`-RrI6W@Cce2q zo$VvEO^UYHGS<6YDmDO|{VaMw71QW<93$d7`Hk)p^^w;v+f{ z(e*azaGD)2rY;;?O|6SJN}7JBOYr1$mt$$d=)(1p6Zj}HsUXtcPkrSIOMRs|M>W{{ zNOLFk%-n(j`9*?V{ zq8k<SV!HuurD~b zEEft7@Wu->so7#Q>p>dq z6DOVS^sv*cbdhJd?R|`i(A3LH^2^NvF*%oez?YgVpk%zLot|~^9V-{~J*}v!3#gl) z%*3^htSx)|DByejz=qVdi%b!zltY4SY3}A+hYAPyBM$Vf(6@M;(X38w`||}7s%8~IsgCw literal 0 HcmV?d00001 diff --git a/src/main/resources/data/overdrive_that_matters/tags/worldgen/biome/wreckage.json b/src/main/resources/data/overdrive_that_matters/tags/worldgen/biome/wreckage.json new file mode 100644 index 000000000..b342d23e7 --- /dev/null +++ b/src/main/resources/data/overdrive_that_matters/tags/worldgen/biome/wreckage.json @@ -0,0 +1,7 @@ +{ + "replace": false, + "values": [ + "#forge:is_desert", + "minecraft:desert" + ] +} \ No newline at end of file diff --git a/src/main/resources/data/overdrive_that_matters/worldgen/structure/laboratory.json b/src/main/resources/data/overdrive_that_matters/worldgen/structure/laboratory.json index 3f457fd5f..b669b3896 100644 --- a/src/main/resources/data/overdrive_that_matters/worldgen/structure/laboratory.json +++ b/src/main/resources/data/overdrive_that_matters/worldgen/structure/laboratory.json @@ -1,7 +1,7 @@ { "type": "minecraft:jigsaw", "biomes": "#overdrive_that_matters:laboratory", - "max_distance_from_center": 80, + "max_distance_from_center": 100, "size": 7, "project_start_to_heightmap": "WORLD_SURFACE_WG", "start_height": { diff --git a/src/main/resources/data/overdrive_that_matters/worldgen/structure/wreckage.json b/src/main/resources/data/overdrive_that_matters/worldgen/structure/wreckage.json new file mode 100644 index 000000000..7ddbd2358 --- /dev/null +++ b/src/main/resources/data/overdrive_that_matters/worldgen/structure/wreckage.json @@ -0,0 +1,28 @@ +{ + "type": "minecraft:jigsaw", + "biomes": "#overdrive_that_matters:wreckage", + "max_distance_from_center": 100, + "size": 1, + "project_start_to_heightmap": "WORLD_SURFACE_WG", + "start_height": { + "absolute": 0 + }, + "spawn_overrides": { + "monster": { + "bounding_box": "piece", + "spawns": [ + { + "type": "minecraft:pillager", + "weight": 1, + "minCount": 1, + "maxCount": 2 + } + ] + } + }, + "start_jigsaw_name": "overdrive_that_matters:wreckage_anchor", + "start_pool": "overdrive_that_matters:wreckage/wreckage_body", + "step": "surface_structures", + "terrain_adaption": "beard_box", + "use_expansion_hack": false +} \ No newline at end of file diff --git a/src/main/resources/data/overdrive_that_matters/worldgen/structure_set/wreckage.json b/src/main/resources/data/overdrive_that_matters/worldgen/structure_set/wreckage.json new file mode 100644 index 000000000..ad8f6613a --- /dev/null +++ b/src/main/resources/data/overdrive_that_matters/worldgen/structure_set/wreckage.json @@ -0,0 +1,14 @@ +{ + "placement": { + "type": "minecraft:random_spread", + "salt": 20383242, + "separation": 8, + "spacing": 1200 + }, + "structures": [ + { + "structure": "overdrive_that_matters:wreckage", + "weight": 1 + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/overdrive_that_matters/worldgen/template_pool/wreckage/wreckage_body.json b/src/main/resources/data/overdrive_that_matters/worldgen/template_pool/wreckage/wreckage_body.json new file mode 100644 index 000000000..819e73030 --- /dev/null +++ b/src/main/resources/data/overdrive_that_matters/worldgen/template_pool/wreckage/wreckage_body.json @@ -0,0 +1,15 @@ +{ + "name": "overdrive_that_matters:wreckage_body", + "fallback": "minecraft:empty", + "elements": [ + { + "element": { + "element_type": "minecraft:single_pool_element", + "location": "overdrive_that_matters:wreckage/wreckage_body", + "processors": "minecraft:empty", + "projection": "rigid" + }, + "weight": 1 + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/overdrive_that_matters/worldgen/template_pool/wreckage/wreckage_front.json b/src/main/resources/data/overdrive_that_matters/worldgen/template_pool/wreckage/wreckage_front.json new file mode 100644 index 000000000..e8ad4eb44 --- /dev/null +++ b/src/main/resources/data/overdrive_that_matters/worldgen/template_pool/wreckage/wreckage_front.json @@ -0,0 +1,15 @@ +{ + "name": "overdrive_that_matters:wreckage_front", + "fallback": "minecraft:empty", + "elements": [ + { + "element": { + "element_type": "minecraft:single_pool_element", + "location": "overdrive_that_matters:wreckage/wreckage_front", + "processors": "minecraft:empty", + "projection": "rigid" + }, + "weight": 1 + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/overdrive_that_matters/worldgen/template_pool/wreckage/wreckage_tail.json b/src/main/resources/data/overdrive_that_matters/worldgen/template_pool/wreckage/wreckage_tail.json new file mode 100644 index 000000000..ed70193be --- /dev/null +++ b/src/main/resources/data/overdrive_that_matters/worldgen/template_pool/wreckage/wreckage_tail.json @@ -0,0 +1,15 @@ +{ + "name": "overdrive_that_matters:wreckage_tail", + "fallback": "minecraft:empty", + "elements": [ + { + "element": { + "element_type": "minecraft:single_pool_element", + "location": "overdrive_that_matters:wreckage/wreckage_tail", + "processors": "minecraft:empty", + "projection": "rigid" + }, + "weight": 1 + } + ] +} \ No newline at end of file From 198c9b4aa33a52a6910e5d41cfce00ed4333b90a Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sun, 19 Mar 2023 19:05:20 +0300 Subject: [PATCH 0413/1199] essence storage block shape MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit оно компилится и похуй --- .../mc/otm/shapes/BlockShapes.java | 11 +++++++++ .../mc/otm/block/tech/EssenceStorageBlock.kt | 18 ++++++++++++++ .../models/block/essence_storage.json | 24 +++---------------- 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java index f2f64a10c..b1f97bd01 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java +++ b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java @@ -622,4 +622,15 @@ public class BlockShapes { new SimpleCuboid(0.0625d, 0.375d, 0.0625d, 0.25d, 0.9375d, 0.9375d), new SimpleCuboid(0.75d, 0.375d, 0.0625d, 0.9375d, 0.9375d, 0.9375d) ); + + public static final BlockShape ESSENCE_STORAGE = new BlockShape( + new SimpleCuboid(0d, 0d, 0d, 1d, 0.125d, 1d), + new SimpleCuboid(0d, 0.1875d, 0d, 1d, 0.3125d, 1d), + new SimpleCuboid(0.5625d, 0.3125d, 0d, 1d, 1d, 0.875d), + new SimpleCuboid(0d, 0.625d, 0.875d, 1d, 1d, 1d), + new SimpleCuboid(0d, 0.3125d, 0.5625d, 0.5625d, 1d, 0.875d), + new SimpleCuboid(0.0625d, 0.125d, 0.0625d, 0.9375d, 0.1875d, 0.9375d), + new SimpleCuboid(0.0625d, 0.3125d, 0.875d, 0.9375d, 0.625d, 0.9375d), + new SimpleCuboid(0.0625d, 0.3125d, 0.0625d, 0.5625d, 0.9375d, 0.5625d) + ); } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EssenceStorageBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EssenceStorageBlock.kt index 0d4faf442..85b813e2f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EssenceStorageBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EssenceStorageBlock.kt @@ -4,6 +4,7 @@ import net.minecraft.core.BlockPos import net.minecraft.world.InteractionHand import net.minecraft.world.InteractionResult import net.minecraft.world.entity.player.Player +import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraft.world.level.block.EntityBlock import net.minecraft.world.level.block.entity.BlockEntity @@ -11,9 +12,14 @@ import net.minecraft.world.level.block.entity.BlockEntityTicker import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.phys.BlockHitResult +import net.minecraft.world.phys.shapes.CollisionContext +import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.tech.EssenceStorageBlockEntity +import ru.dbotthepony.mc.otm.block.getShapeForEachState +import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.registry.MItems +import ru.dbotthepony.mc.otm.shapes.BlockShapes class EssenceStorageBlock : RotatableMatteryBlock(), EntityBlock { override fun newBlockEntity(pPos: BlockPos, pState: BlockState): BlockEntity { @@ -36,4 +42,16 @@ class EssenceStorageBlock : RotatableMatteryBlock(), EntityBlock { return super.use(blockState, level, blockPos, ply, hand, blockHitResult) } + + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.ESSENCE_STORAGE.rotateFromNorth(it[rotationProperty]).computeShape() } + + @Suppress("override_deprecation") + override fun getShape( + state: BlockState, + blockGetter: BlockGetter, + pos: BlockPos, + context: CollisionContext + ): VoxelShape { + return shapes[state]!! + } } diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/essence_storage.json b/src/main/resources/assets/overdrive_that_matters/models/block/essence_storage.json index 5f9f56224..232c1ec45 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/essence_storage.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/essence_storage.json @@ -83,7 +83,6 @@ "from": [1, 5, 14], "to": [15, 10, 15], "faces": { - "north": {"uv": [0, 0, 7, 1.25], "texture": "#missing"}, "east": {"uv": [15.5, 10.5, 16, 11.75], "texture": "#0"}, "south": {"uv": [8.5, 10.5, 15.5, 11.75], "texture": "#0"}, "west": {"uv": [8, 10.5, 8.5, 11.75], "texture": "#0"} @@ -91,20 +90,12 @@ }, { "name": "container", - "from": [1, 15, 1], + "from": [1, 5, 1], "to": [9, 15, 9], - "faces": { - "up": {"uv": [8, 0, 12, 2], "texture": "#0"}, - "down": {"uv": [8, 0, 12, 2], "texture": "#0"} - } - }, - { - "name": "container", - "from": [1, 5, 1], - "to": [9, 15, 1], "faces": { "north": {"uv": [8, 2, 12, 4.5], "texture": "#0"}, - "south": {"uv": [8, 2, 12, 4.5], "texture": "#0"} + "west": {"uv": [8, 2, 12, 4.5], "texture": "#0"}, + "up": {"uv": [8, 0, 12, 2], "texture": "#0"} } }, { @@ -119,15 +110,6 @@ "up": {"uv": [9.5, 12.5, 13, 14.25], "texture": "#0"} }, "forge_data": { "block_light": 15, "sky_light": 15 } - }, - { - "name": "container", - "from": [1, 5, 1], - "to": [1, 15, 9], - "faces": { - "east": {"uv": [8, 2, 12, 4.5], "texture": "#0"}, - "west": {"uv": [8, 2, 12, 4.5], "texture": "#0"} - } } ], "display": { From ec99243b15d522183618c9b85ac897e2af7e4c43 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 20 Mar 2023 14:14:25 +0700 Subject: [PATCH 0414/1199] Increase ZPM matter values again --- src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt index 858317b6a..b6df91306 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt @@ -111,7 +111,7 @@ fun addMatterData(provider: MatterDataProvider) { relative(Items.NETHER_STAR, 2000, 1200) - relative(MItems.ZPM_BATTERY, 160000, 7200) + relative(MItems.ZPM_BATTERY, 80000000, 720000) relative(MItems.PILL_HEAL, 14, 8) relative(MItems.PILL_ANDROID, 20, 20) From 0481507217dce35ee0af53ce50095aabef4ba274 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 20 Mar 2023 18:03:45 +0700 Subject: [PATCH 0415/1199] Battery bank a bit smarter distribution --- .../entity/tech/BatteryBankBlockEntity.kt | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index f60c07021..ad1a054a4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -53,10 +53,15 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte private var currentChangeSlot = 0 private var currentDischangeSlot = 0 + private var lastTickCharged = false + private var lastTickDischarged = false + init { savetable(::container, INVENTORY_KEY) savetables.int(::currentChangeSlot) savetables.int(::currentDischangeSlot) + savetables.bool(::lastTickCharged) + savetables.bool(::lastTickDischarged) } private fun distributeEnergy(isReceiving: Boolean, howMuch: Decimal, simulate: Boolean): Decimal { @@ -93,10 +98,15 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte } if (!simulate) { - if (isReceiving) + if (isReceiving) { + this.lastTickCharged = true + if (currentSlot == this.currentChangeSlot) currentSlot = (currentSlot + 1) % container.containerSize this.currentChangeSlot = currentSlot - else + } else { + this.lastTickDischarged = true + if (currentSlot == this.currentDischangeSlot) currentSlot = (currentSlot + 1) % container.containerSize this.currentDischangeSlot = currentSlot + } } return summ @@ -112,8 +122,15 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte override fun tick() { super.tick() - currentChangeSlot = (currentChangeSlot + 1) % container.containerSize - currentDischangeSlot = (currentDischangeSlot + 1) % container.containerSize + + if (!lastTickCharged) + currentChangeSlot = (currentChangeSlot + 1) % container.containerSize + + if (!lastTickDischarged) + currentDischangeSlot = (currentDischangeSlot + 1) % container.containerSize + + lastTickCharged = false + lastTickDischarged = false } override val canSetBatteryLevel: Boolean From 9f6927cb8ae747454ec634ab61d705754cd18218 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 20 Mar 2023 18:06:08 +0700 Subject: [PATCH 0416/1199] Multiplication of matter values --- .../kotlin/ru/dbotthepony/mc/otm/matter/IMatterValue.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/IMatterValue.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/IMatterValue.kt index ffe05bf75..ab6fb81d8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/IMatterValue.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/IMatterValue.kt @@ -28,6 +28,14 @@ interface IMatterValue : Comparable { return MatterValue(matter - other.matter, complexity - other.complexity) } + operator fun times(other: IMatterValue): IMatterValue { + return MatterValue(matter * other.matter, complexity * other.complexity) + } + + operator fun times(other: Int): IMatterValue { + return MatterValue(matter * other, complexity * other) + } + override fun compareTo(other: IMatterValue): Int { val matterComparison = matter.compareTo(other.matter) From aa31ff4ccea62e787e09b8735b4b410a540c437c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 22 Mar 2023 17:49:46 +0700 Subject: [PATCH 0417/1199] Fix wrong bounds operations when extracting matter from grid --- .../block/entity/matter/MatterReplicatorBlockEntity.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index 1adca7549..74ade4275 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -233,18 +233,17 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } else { // в тик требуется меньше материи, чем её может хранить репликатор // примем из сети недостающее количество бака материи, или 200 тиков репликации, что меньше - val drain = graph.extractMatter(matter.missingMatter - .coerceAtMost(drainPerTick * DRAIN_MULT) + val drain = graph.extractMatter((drainPerTick * DRAIN_MULT) .coerceAtMost(job.matterPerTick * (job.ticks - workTicks - ticksAdvanced)) - .coerceAtLeast(Decimal.ONE), true) + .coerceAtLeast(Decimal.ONE) + .coerceAtMost(matter.missingMatter), false) if (drain.isZero) { // в сети нет материи return Status.FAILURE_MATTER } - val received = matter.receiveMatter(drain, false) - graph.extractMatter(received, false) + matter.receiveMatter(drain, false) // получили материю, проверяем возможность работы if (matter.extractMatterInner(drainPerTick, true) >= drainPerTick) { From e3993f439e0132cab5a44c9ff52a744e76728a2a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 22 Mar 2023 23:48:23 +0700 Subject: [PATCH 0418/1199] Item repairer block --- .../mc/otm/datagen/lang/English.kt | 2 + .../mc/otm/datagen/lang/Russian.kt | 2 + .../mc/otm/datagen/loot/LootTablesData.kt | 1 + .../dbotthepony/mc/otm/datagen/tags/Tags.kt | 1 + .../entity/matter/ItemRepairerBlockEntity.kt | 290 ++++++++++++++++++ .../entity/matter/MatterBottlerBlockEntity.kt | 2 - .../mc/otm/block/matter/ItemRepairerBlock.kt | 24 ++ .../otm/capability/MatteryPlayerCapability.kt | 12 +- .../screen/matter/ItemRepairerScreen.kt | 26 ++ .../mc/otm/config/MachinesConfig.kt | 2 + .../mc/otm/core/collect/ItemStackIterators.kt | 3 +- .../mc/otm/core/collect/PredicateIterator.kt | 99 ------ .../mc/otm/core/collect/StreamyIterator.kt | 210 +++++++++++++ .../mc/otm/graph/matter/MatterNetworkGraph.kt | 3 +- .../dbotthepony/mc/otm/matter/IMatterValue.kt | 2 + .../mc/otm/menu/MatteryPoweredMenu.kt | 8 +- .../mc/otm/menu/matter/ItemRepairerMenu.kt | 29 ++ .../mc/otm/registry/MBlockEntities.kt | 1 + .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 2 + .../ru/dbotthepony/mc/otm/registry/MItems.kt | 13 +- .../ru/dbotthepony/mc/otm/registry/MMenus.kt | 4 + .../ru/dbotthepony/mc/otm/registry/MNames.kt | 1 + 22 files changed, 621 insertions(+), 116 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/ItemRepairerBlock.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/ItemRepairerScreen.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/PredicateIterator.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/ItemRepairerMenu.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index cb3de77d3..180d0ab7e 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -365,6 +365,8 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.COBBLESTONE_GENERATOR, "Cobblestone Generator") add(MBlocks.ESSENCE_STORAGE, "Essence Storage") add(MBlocks.ESSENCE_STORAGE, "desc", "Allows to store and retrieve experience levels") + add(MBlocks.ITEM_REPAIRER, "Matter Reconstructor") + add(MBlocks.ITEM_REPAIRER, "desc", "Repairs tools using matter") add(MBlocks.ENGINE, "Ship Engine") add(MBlocks.HOLO_SIGN, "Holo Sign") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 41f5fc203..d901d0db2 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -372,6 +372,8 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.COBBLESTONE_GENERATOR, "Генератор булыжника") add(MBlocks.ESSENCE_STORAGE, "Хранилище эссенции") add(MBlocks.ESSENCE_STORAGE, "desc", "Позволяет хранить очки опыта") + add(MBlocks.ITEM_REPAIRER, "Материальный реконструктор") + add(MBlocks.ITEM_REPAIRER, "desc", "Чинит инструменты используя материю") add(MBlocks.ENGINE, "Двигатель корабля") add(MBlocks.HOLO_SIGN, "Голографическая табличка") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index 456b343df..6451c3831 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -137,6 +137,7 @@ fun addLootTables(lootTables: LootTables) { lootTables.tile(MBlocks.COBBLESTONE_GENERATOR) lootTables.tile(MBlocks.ESSENCE_STORAGE) + lootTables.tile(MBlocks.ITEM_REPAIRER) lootTables.tile(MBlocks.ENERGY_SERVO) lootTables.tile(MBlocks.ENERGY_COUNTER) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index 2b23f8acf..3a5c7f456 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -172,6 +172,7 @@ fun addTags(tagsProvider: TagsProvider) { MBlocks.HOLO_SIGN, MBlocks.COBBLESTONE_GENERATOR, MBlocks.ESSENCE_STORAGE, + MBlocks.ITEM_REPAIRER, ), Tiers.IRON) tagsProvider.requiresPickaxe(MBlocks.TRITANIUM_ANVIL, Tiers.IRON) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt new file mode 100644 index 000000000..9c423d202 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt @@ -0,0 +1,290 @@ +package ru.dbotthepony.mc.otm.block.entity.matter + +import net.minecraft.core.BlockPos +import net.minecraft.nbt.StringTag +import net.minecraft.resources.ResourceLocation +import net.minecraft.server.level.ServerLevel +import net.minecraft.world.entity.player.Inventory +import net.minecraft.world.entity.player.Player +import net.minecraft.world.inventory.AbstractContainerMenu +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.state.BlockState +import net.minecraftforge.common.ForgeConfigSpec +import net.minecraftforge.common.ForgeConfigSpec.ConfigValue +import net.minecraftforge.registries.ForgeRegistries +import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity +import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl +import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage +import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl +import ru.dbotthepony.mc.otm.config.ConciseBalanceValues +import ru.dbotthepony.mc.otm.container.HandlerFilter +import ru.dbotthepony.mc.otm.container.MatteryContainer +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue +import ru.dbotthepony.mc.otm.core.math.defineDecimal +import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.core.util.WriteOnce +import ru.dbotthepony.mc.otm.graph.Graph6Node +import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode +import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph +import ru.dbotthepony.mc.otm.matter.IMatterValue +import ru.dbotthepony.mc.otm.matter.MatterManager +import ru.dbotthepony.mc.otm.menu.matter.ItemRepairerMenu +import ru.dbotthepony.mc.otm.registry.MBlockEntities +import ru.dbotthepony.mc.otm.registry.MNames + +class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.ITEM_REPAIRER, blockPos, blockState), IMatterGraphNode { + val repairContainer = MatteryContainer(::containerChanged, 1).also(::addDroppableContainer) + + private var matterPerTick = Decimal.ZERO + private var progressPerTick = 0.0 + private var repairProgress = 0.0 + private var lastItem: Item? = null + + var canNotWork = false + + override val matterNode = Graph6Node(this) + val matter = MatterStorageImpl(::setChangedLight, FlowDirection.INPUT, ::CAPACITY) + val energy = WorkerEnergyStorage(::setChangedLight, ENERGY_VALUES) + + init { + exposeGlobally(MatteryCapability.MATTER, matter) + exposeGlobally(MatteryCapability.MATTER_NODE, this) + + savetables.stateful(::repairContainer) + savetables.stateful(::matter) + savetables.stateful(::energy) + + savetables.decimal(::matterPerTick) + savetables.double(::progressPerTick) + savetables.double(::repairProgress) + + savetables.Stateless(::lastItem, type = StringTag::class.java) + .withSerializer { it?.registryName?.toString()?.let(StringTag::valueOf) } + .withDeserializer { ResourceLocation.tryParse(it.asString)?.let { ForgeRegistries.ITEMS.getValue(it) } } + } + + val energyConfig = ConfigurableEnergy(energy) + val itemConfig = ConfigurableItemHandler( + input = repairContainer.handler(object : HandlerFilter { + override fun canInsert(slot: Int, stack: ItemStack): Boolean { + if (!stack.isRepairable || !stack.isDamaged) { + return false + } + + if (!ONLY_ANVIL) { + if (MatterManager.get(stack.item).hasMatterValue) { + return true + } + } + + return (matterNode.graph as MatterNetworkGraph?) + ?.patterns + ?.filter { stack.item.isValidRepairItem(stack, ItemStack(it.item, 1)) } + ?.findFirst()?.orElse(null).let { + if (it == null) { + IMatterValue.ZERO + } else { + MatterManager.get(it.item) + } + }.hasMatterValue + } + + override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { + return false + } + }), + + output = repairContainer.handler(object : HandlerFilter { + override fun canInsert(slot: Int, stack: ItemStack): Boolean { + return false + } + + override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { + return progressPerTick <= 0.0 || matterPerTick <= Decimal.ZERO + } + }) + ) + + override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { + return ItemRepairerMenu(containerID, inventory, this) + } + + override fun getMatterHandler(): IMatterStorage { + return matter + } + + override fun setRemoved() { + super.setRemoved() + matterNode.destroy(::MatterNetworkGraph) + } + + override fun setLevel(level: Level) { + super.setLevel(level) + + if (level is ServerLevel) + MatterNetworkGraph.discoverFull(this, matterNode) + } + + private fun containerChanged() { + matterPerTick = Decimal.ZERO + progressPerTick = 0.0 + + val item = repairContainer[0] + + tickList.once { + if (lastItem != item.item) { + lastItem = item.item + repairProgress = 0.0 + } + + if (item.isEmpty || !item.isRepairable || !item.isDamaged) { + matterPerTick = Decimal.ZERO + progressPerTick = 0.0 + } else { + if (!ONLY_ANVIL) { + val matter = MatterManager.get(item.item) + + if (matter.hasMatterValue) { + progressPerTick = (item.maxDamage / matter.complexity) / DIVISOR + matterPerTick = (matter.matter / matter.complexity) / DIVISOR + return@once + } + } + + val found = (matterNode.graph as MatterNetworkGraph?)?.patterns?.filter { item.item.isValidRepairItem(item, ItemStack(it.item, 1)) }?.findFirst()?.orElse(null) + + if (found != null) { + @Suppress("name_shadowing") + val matter = MatterManager.get(found.item) * 2 + + progressPerTick = (item.maxDamage / matter.complexity) / DIVISOR + matterPerTick = (matter.matter / matter.complexity) / DIVISOR + } else { + matterPerTick = Decimal.ZERO + progressPerTick = 0.0 + } + } + } + } + + override fun tick() { + super.tick() + + if (!redstoneControl.isBlockedByRedstone) { + canNotWork = false + + val item = repairContainer[0] + + if (!item.isEmpty && matterPerTick.isPositive && progressPerTick > 0.0 && item.isRepairable && item.isDamaged) { + var progressPerTick = (repairProgress + progressPerTick).coerceAtMost(item.damageValue.toDouble()) - repairProgress + if (progressPerTick <= 0.0) return + + if (ENERGY_CONSUMPTION.isPositive) { + if (!energy.batteryLevel.isPositive) return + val multEnergy = ENERGY_CONSUMPTION * (progressPerTick / this.progressPerTick) + progressPerTick *= (energy.extractEnergy(multEnergy, true) / multEnergy).toDouble() + + if (progressPerTick <= 0.0) { + canNotWork = true + return + } + } + + if (matter.storedMatter < matterPerTick) { + val graph = matterNode.graph as MatterNetworkGraph? + + if (graph != null) { + val toDrain = (matterPerTick * EXTRACT_TICKS.coerceAtMost(item.damageValue)).coerceAtLeast(Decimal.ZERO).coerceAtMost(matter.missingMatter) + matter.receiveMatterInner(graph.extractMatter(toDrain, false), false) + } + } + + val toDrain = matterPerTick * (progressPerTick / this.progressPerTick) + val drain = matter.extractMatterInner(toDrain, true) + if (!drain.isPositive) { + canNotWork = true + return + } + + progressPerTick *= (drain / toDrain).toDouble() + if (progressPerTick <= 0.0) { + canNotWork = true + return + } + + if (FAILURE_CHANCE <= 0.0 || level!!.random.nextDouble() >= FAILURE_CHANCE) + repairProgress += progressPerTick + + energy.extractEnergy(ENERGY_CONSUMPTION * (progressPerTick / this.progressPerTick), false) + matter.extractMatterInner(matterPerTick * (progressPerTick / this.progressPerTick), false) + + if (repairProgress >= 1.0) { + item.damageValue = (item.damageValue - repairProgress.toInt()).coerceAtLeast(0) + repairProgress %= 1.0 + } + } + } + } + + companion object { + val CAPACITY get() = _CAPACITY.get() + val ENERGY_CONSUMPTION get() = _ENERGY_CONSUMPTION.get() + val DIVISOR: Double get() = _DIVISOR.get() + val EXTRACT_TICKS: Int get() = _EXTRACT_TICKS.get() + val FAILURE_CHANCE: Double get() = _FAILURE_CHANCE.get() + val ONLY_ANVIL: Boolean get() = _ONLY_ANVIL.get() + + private var _CAPACITY: DecimalConfigValue by WriteOnce() + private var _ENERGY_CONSUMPTION: DecimalConfigValue by WriteOnce() + private var _DIVISOR: ConfigValue by WriteOnce() + private var _FAILURE_CHANCE: ConfigValue by WriteOnce() + private var _EXTRACT_TICKS: ConfigValue by WriteOnce() + private var _ONLY_ANVIL: ConfigValue by WriteOnce() + + var ENERGY_VALUES: ConciseBalanceValues by WriteOnce() + private set + + fun registerConfig(builder: ForgeConfigSpec.Builder) { + builder.push(MNames.ITEM_REPAIRER) + + ENERGY_VALUES = BlockEnergyStorageImpl.makeConfigEntry(builder, capacity = Decimal(400_000), throughput = Decimal(2_000)) + + _CAPACITY = builder.defineDecimal("matterCapacity", Decimal(4_000), Decimal.ONE_TENTH) + _ENERGY_CONSUMPTION = builder.defineDecimal("energyConsumption", Decimal(600), Decimal.ONE) + + _ONLY_ANVIL = builder + .comment("Force repairing only by matter value of anvil materials") + .comment("Doesn't make logical sense but might be good for balancing") + .define("onlyAnvil", false) + + _EXTRACT_TICKS = builder + .comment("How much ticks of matter work will be attempted to be extracted from matter network") + .comment("on matter starvation") + .comment("---") + .comment("This is a performance tuning value, do not change it if you don't know what you are doing!") + .defineInRange("extractTicks", 200, 1, Int.MAX_VALUE) + + _FAILURE_CHANCE = builder + .comment("Chance that replication will fail at any given tick") + .comment("In event of failure repair tick is wasted, wasting resources") + .defineInRange("failureChance", 0.01, 0.0, 0.99) + + _DIVISOR = builder + .comment("Magnitute of **slowdown** of repairer.") + .comment("If this value is 1, repairer will repair item from 0% to 100% in COMPLEXITY (of tool) ticks") + .comment("(or twice the complexity of anvil repair ingredients if tool itself has no matter value)") + .comment("---") + .comment("If value is smaller than 1, repairer will repair items faster") + .comment("If value is bigger than 1, repairer will repair items slower") + .defineInRange("divisor", 3.0, 0.1, Double.MAX_VALUE) + + builder.pop() + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index a92b0ed2c..697386f75 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -317,7 +317,5 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : builder.pop() } - - const val IS_BOTTLING_KEY = "isBottling" } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/ItemRepairerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/ItemRepairerBlock.kt new file mode 100644 index 000000000..471b7d7ed --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/ItemRepairerBlock.kt @@ -0,0 +1,24 @@ +package ru.dbotthepony.mc.otm.block.matter + +import net.minecraft.core.BlockPos +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.EntityBlock +import net.minecraft.world.level.block.entity.BlockEntity +import net.minecraft.world.level.block.entity.BlockEntityTicker +import net.minecraft.world.level.block.entity.BlockEntityType +import net.minecraft.world.level.block.state.BlockState +import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.entity.matter.ItemRepairerBlockEntity + +class ItemRepairerBlock : RotatableMatteryBlock(), EntityBlock { + override fun newBlockEntity(pPos: BlockPos, pState: BlockState): BlockEntity { + return ItemRepairerBlockEntity(pPos, pState) + } + + override fun getTicker(pLevel: Level, pState: BlockState, pBlockEntityType: BlockEntityType): BlockEntityTicker? { + if (pLevel.isClientSide) + return null + + return BlockEntityTicker { _, _, _, pBlockEntity -> if (pBlockEntity is ItemRepairerBlockEntity) pBlockEntity.tick() } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 276c8d165..fcd6c734b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -1315,11 +1315,13 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial return } - val iterator = inventory.player.matteryPlayer?.exoPackContainer?.iterator()?.nonEmpty() ?: return + val iterator = inventory.player.matteryPlayer?.exoPackContainer?.iterator() ?: return for (item in iterator) { - inventory.player.drop(item, true, false) - iterator.remove() + if (!item.isEmpty) { + inventory.player.drop(item, true, false) + iterator.remove() + } } } @@ -1338,10 +1340,10 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial return } - val iterator = player.matteryPlayer?.exoPackContainer?.iterator()?.nonEmpty() ?: return + val iterator = player.matteryPlayer?.exoPackContainer?.iterator() ?: return for (item in iterator) { - if (hasVanishingCurse(item)) { + if (!item.isEmpty && hasVanishingCurse(item)) { iterator.remove() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/ItemRepairerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/ItemRepairerScreen.kt new file mode 100644 index 000000000..f4ceb099c --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/ItemRepairerScreen.kt @@ -0,0 +1,26 @@ +package ru.dbotthepony.mc.otm.client.screen.matter + +import net.minecraft.network.chat.Component +import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel +import ru.dbotthepony.mc.otm.menu.matter.ItemRepairerMenu + +class ItemRepairerScreen(menu: ItemRepairerMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { + override fun makeMainFrame(): FramePanel> { + val frame = super.makeMainFrame()!! + + val p = PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) + MatterGaugePanel(this, frame, menu.matterWidget, LEFT_MARGIN + p.width, GAUGE_TOP_WITH_SLOT) + + BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) + + SlotPanel(this, frame, menu.slot, 80f, PROGRESS_SLOT_TOP) + + return frame + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt index c80357cd2..b8b6213ba 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.config +import ru.dbotthepony.mc.otm.block.entity.matter.ItemRepairerBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterDecomposerBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterRecyclerBlockEntity @@ -20,6 +21,7 @@ object MachinesConfig : AbstractConfig("machines") { MatterReplicatorBlockEntity.registerConfig(builder) MatterScannerBlockEntity.registerConfig(builder) MatterDecomposerBlockEntity.registerConfig(builder) + ItemRepairerBlockEntity.registerConfig(builder) } val PLATE_PRESS = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.PLATE_PRESS) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ItemStackIterators.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ItemStackIterators.kt index f3da0a85d..ea38e5fec 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ItemStackIterators.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ItemStackIterators.kt @@ -2,5 +2,4 @@ package ru.dbotthepony.mc.otm.core.collect import net.minecraft.world.item.ItemStack -fun Iterator.nonEmpty() = PredicateIterator(this) { !it.isEmpty } -fun MutableIterator.nonEmpty() = MutablePredicateIterator(this) { !it.isEmpty } +fun Iterator.nonEmpty() = FilteredIterator(this) { !it.isEmpty } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/PredicateIterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/PredicateIterator.kt deleted file mode 100644 index 631bd998b..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/PredicateIterator.kt +++ /dev/null @@ -1,99 +0,0 @@ -package ru.dbotthepony.mc.otm.core.collect - -import java.util.function.Consumer -import java.util.function.Predicate - -class PredicateIterator : Iterator { - private val parent: Iterator - private val predicate: Predicate - private val consumer: Consumer? - - constructor(parent: Iterator, predicate: Predicate) { - this.parent = parent - this.predicate = predicate - this.consumer = null - } - - constructor(parent: Iterator, predicate: Predicate, consumer: Consumer) { - this.parent = parent - this.predicate = predicate - this.consumer = consumer - } - - private var foundValue: Any? = Companion - - var once: Boolean = false - private set - - override fun hasNext(): Boolean { - if (foundValue === Companion) { - while (parent.hasNext()) { - val next = parent.next() - - if (predicate.test(next)) { - foundValue = next - once = true - return true - } - } - - return false - } - - return true - } - - @Suppress("unchecked_cast") - override fun next(): T { - if (!hasNext()) { - throw NoSuchElementException() - } - - val foundValue = foundValue - - if (foundValue === Companion) { - throw ConcurrentModificationException() - } - - this.foundValue = Companion - consumer?.accept(foundValue as T) - return foundValue as T - } - - private companion object -} - -fun Iterator.filter(condition: Predicate) = PredicateIterator(this, condition) - -class MutablePredicateIterator : MutableIterator { - private val parent: MutableIterator - private val predicateParent: PredicateIterator - - constructor(parent: MutableIterator, predicate: Predicate) { - this.parent = parent - this.predicateParent = PredicateIterator(parent, predicate) - } - - constructor(parent: MutableIterator, predicate: Predicate, consumer: Consumer) { - this.parent = parent - this.predicateParent = PredicateIterator(parent, predicate, consumer) - } - - override fun hasNext(): Boolean { - return predicateParent.hasNext() - } - - override fun next(): T { - return predicateParent.next() - } - - override fun remove() { - if (!predicateParent.once) { - throw NoSuchElementException() - } - - return parent.remove() - } -} - -fun MutableIterator.filter(condition: Predicate) = MutablePredicateIterator(this, condition) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt new file mode 100644 index 000000000..d0d195ba1 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt @@ -0,0 +1,210 @@ +package ru.dbotthepony.mc.otm.core.collect + +import java.util.Optional +import java.util.function.BinaryOperator +import java.util.function.Predicate +import java.util.stream.Collector + +class FilteredIterator(private val parent: Iterator, private val predicate: Predicate) : Iterator { + private var foundValue: Any? = Companion + + override fun hasNext(): Boolean { + if (foundValue === Companion) { + while (parent.hasNext()) { + val next = parent.next() + + if (predicate.test(next)) { + foundValue = next + return true + } + } + + return false + } + + return true + } + + @Suppress("unchecked_cast") + override fun next(): T { + var foundValue = foundValue + + if (foundValue === Companion) { + if (!hasNext()) { + throw NoSuchElementException() + } + + foundValue = this.foundValue + + if (foundValue === Companion) { + throw ConcurrentModificationException() + } + } + + this.foundValue = Companion + return foundValue as T + } + + private companion object +} + +class MappingIterator(private val parent: Iterator, private val transform: (T) -> R) : Iterator { + override fun hasNext(): Boolean { + return parent.hasNext() + } + + override fun next(): R { + return transform.invoke(parent.next()) + } +} + +fun Iterator.filter(condition: Predicate): Iterator = FilteredIterator(this, condition) +fun Iterator.map(mapper: (T) -> R): Iterator = MappingIterator(this, mapper) +fun Iterator.map(mapper: java.util.function.Function): Iterator = MappingIterator(this, mapper::apply) + +fun Iterator.reduce(identity: T, reducer: (T, T) -> T): T { + var result = identity + + for (value in this) { + result = reducer.invoke(result, value) + } + + return result +} + +fun Iterator.reduce(identity: T, reducer: BinaryOperator): T = reduce(identity, reducer::apply) +fun Iterator.filterNotNull(): Iterator = filter { it != null } as Iterator + +fun Iterator.anyMatch(predicate: Predicate): Boolean { + for (value in this) { + if (predicate.test(value)) { + return true + } + } + + return false +} + +fun Iterator.allMatch(predicate: Predicate): Boolean { + for (value in this) { + if (!predicate.test(value)) { + return false + } + } + + return true +} + +fun Iterator.noneMatch(predicate: Predicate): Boolean { + for (value in this) { + if (predicate.test(value)) { + return false + } + } + + return true +} + +fun Iterator.collect(collector: Collector): R { + val accumulator = collector.accumulator() + val instance = collector.supplier().get() + + for (value in this) { + accumulator.accept(instance, value) + } + + return collector.finisher().apply(instance) +} + +fun Iterator.findFirst(): Optional { + if (hasNext()) { + return Optional.of(next()) + } + + return Optional.empty() +} + +fun Iterator.findAny() = findFirst() + +fun Iterator.limit(limit: Long): Iterator { + require(limit > 0) { "Invalid limit $limit" } + + return object : Iterator { + var found = 0L + + override fun hasNext(): Boolean { + return found < limit && this@limit.hasNext() + } + + override fun next(): T { + if (found >= limit) { + throw NoSuchElementException() + } + + return this@limit.next() + } + } +} + +fun Iterator.skip(skip: Long): Iterator { + require(skip > 0) { "Invalid skip $skip" } + + return object : Iterator { + var found = skip + + override fun hasNext(): Boolean { + while (this@skip.hasNext() && found > 0L) { + found-- + this@skip.next() + } + + return this@skip.hasNext() + } + + override fun next(): T { + if (!hasNext()) { + throw NoSuchElementException() + } + + return this@skip.next() + } + } +} + +inline fun Iterator.forEach(action: (T) -> Unit) { + for (value in this) { + action.invoke(value) + } +} + +fun Iterator.min(comparator: Comparator): Optional { + if (!hasNext()) { + return Optional.empty() + } + + var min = next() + + for (value in this) { + if (comparator.compare(min, value) > 0) { + min = value + } + } + + return Optional.of(min) +} + +fun Iterator.max(comparator: Comparator): Optional { + if (!hasNext()) { + return Optional.empty() + } + + var max = next() + + for (value in this) { + if (comparator.compare(max, value) < 0) { + max = value + } + } + + return Optional.of(max) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNetworkGraph.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNetworkGraph.kt index 9cc19b1e8..8fea4f865 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNetworkGraph.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNetworkGraph.kt @@ -7,6 +7,7 @@ import net.minecraft.world.level.block.entity.BlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.matter.* +import ru.dbotthepony.mc.otm.core.filterNotNull import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.graph.Abstract6Graph import ru.dbotthepony.mc.otm.graph.Graph6Node @@ -206,7 +207,7 @@ class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListe } val patterns: Stream get() { - return Streams.concat(*nodes.mapNotNull { it.value.getPatternHandler()?.patterns }.toTypedArray()) + return nodes.stream().map { it.value.getPatternHandler()?.patterns }.filterNotNull().flatMap { it } } val patternCount: Long get() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/IMatterValue.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/IMatterValue.kt index ab6fb81d8..17fa4e5c2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/IMatterValue.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/IMatterValue.kt @@ -50,6 +50,8 @@ interface IMatterValue : Comparable { * ZERO */ companion object : IMatterValue { + val ZERO: IMatterValue get() = this + override val matter: Decimal get() = Decimal.ZERO override val complexity: Double diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt index 4156116c1..844cd97be 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt @@ -6,6 +6,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import net.minecraft.world.SimpleContainer import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting +import ru.dbotthepony.mc.otm.capability.matter.matter import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback @@ -16,14 +17,11 @@ abstract class MatteryPoweredMenu protected constructor( tile: MatteryPoweredBlockEntity? = null ) : MatteryMenu(menuType, containerID, inventory, tile) { val powerWidget = LevelGaugeWidget(this, tile?.matteryEnergy) - val batterySlot: BatterySlot + val batterySlot = BatterySlot(tile?.batteryContainer ?: SimpleContainer(1), 0) val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java) init { - if (tile == null) { - batterySlot = BatterySlot(SimpleContainer(1), 0) - } else { - batterySlot = BatterySlot(tile.batteryContainer, 0) + if (tile != null) { redstone.with(tile.redstoneControl::redstoneSetting) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/ItemRepairerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/ItemRepairerMenu.kt new file mode 100644 index 000000000..22899909e --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/ItemRepairerMenu.kt @@ -0,0 +1,29 @@ +package ru.dbotthepony.mc.otm.menu.matter + +import net.minecraft.world.SimpleContainer +import net.minecraft.world.entity.player.Inventory +import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.block.entity.matter.ItemRepairerBlockEntity +import ru.dbotthepony.mc.otm.capability.matter.matter +import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu +import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget +import ru.dbotthepony.mc.otm.registry.MMenus + +class ItemRepairerMenu( + containerId: Int, + inventory: Inventory, + tile: ItemRepairerBlockEntity? = null +) : MatteryPoweredMenu(MMenus.ITEM_REPAIER, containerId, inventory, tile) { + val matterWidget = LevelGaugeWidget(this, tile?.matter) + val slot = object : MatterySlot(tile?.repairContainer ?: SimpleContainer(1), 0) { + override fun mayPlace(itemStack: ItemStack): Boolean { + return itemStack.isRepairable && itemStack.isDamaged && super.mayPlace(itemStack) + } + } + + init { + addStorageSlot(slot) + addInventorySlots() + } +} 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 68fa57c9c..c59564892 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt @@ -57,6 +57,7 @@ object MBlockEntities { val ENERGY_SERVO: BlockEntityType by registry.register(MNames.ENERGY_SERVO) { BlockEntityType.Builder.of(::EnergyServoBlockEntity, MBlocks.ENERGY_SERVO).build(null) } val COBBLESTONE_GENERATOR: BlockEntityType by registry.register(MNames.COBBLESTONE_GENERATOR) { BlockEntityType.Builder.of(::CobblerBlockEntity, MBlocks.COBBLESTONE_GENERATOR).build(null) } val ESSENCE_STORAGE: BlockEntityType by registry.register(MNames.ESSENCE_STORAGE) { BlockEntityType.Builder.of(::EssenceStorageBlockEntity, MBlocks.ESSENCE_STORAGE).build(null) } + val ITEM_REPAIRER: BlockEntityType by registry.register(MNames.ITEM_REPAIRER) { BlockEntityType.Builder.of(::ItemRepairerBlockEntity, MBlocks.ITEM_REPAIRER).build(null) } val STORAGE_BUS: BlockEntityType by registry.register(MNames.STORAGE_BUS) { BlockEntityType.Builder.of(::StorageBusBlockEntity, MBlocks.STORAGE_BUS).build(null) } val STORAGE_IMPORTER: BlockEntityType by registry.register(MNames.STORAGE_IMPORTER) { BlockEntityType.Builder.of(::StorageImporterBlockEntity, MBlocks.STORAGE_IMPORTER).build(null) } 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 b18d5965b..07e803b92 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -48,6 +48,7 @@ import ru.dbotthepony.mc.otm.block.tech.PlatePressBlock import ru.dbotthepony.mc.otm.block.StorageCableBlock import ru.dbotthepony.mc.otm.block.decorative.EngineBlock import ru.dbotthepony.mc.otm.block.decorative.HoloSignBlock +import ru.dbotthepony.mc.otm.block.matter.ItemRepairerBlock import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock import ru.dbotthepony.mc.otm.block.matter.MatterCapacitorBankBlock import ru.dbotthepony.mc.otm.block.matter.MatterDecomposerBlock @@ -93,6 +94,7 @@ object MBlocks { val ENERGY_SERVO: Block by registry.register(MNames.ENERGY_SERVO) { EnergyServoBlock() } val COBBLESTONE_GENERATOR: Block by registry.register(MNames.COBBLESTONE_GENERATOR) { CobblerBlock() } val ESSENCE_STORAGE: EssenceStorageBlock by registry.register(MNames.ESSENCE_STORAGE) { EssenceStorageBlock() } + val ITEM_REPAIRER: ItemRepairerBlock by registry.register(MNames.ITEM_REPAIRER) { ItemRepairerBlock() } val STORAGE_BUS: Block by registry.register(MNames.STORAGE_BUS) { StorageBusBlock() } val STORAGE_IMPORTER: Block by registry.register(MNames.STORAGE_IMPORTER) { StorageImporterBlock() } 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 ed3e6a8bb..11bca8c79 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -109,13 +109,22 @@ object MItems { } } + val ITEM_REPAIRER: BlockItem by registry.register(MNames.ITEM_REPAIRER) { + object : BlockItem(MBlocks.ITEM_REPAIRER, DEFAULT_PROPERTIES) { + override fun appendHoverText(p_40572_: ItemStack, p_40573_: Level?, p_40574_: MutableList, p_40575_: TooltipFlag) { + super.appendHoverText(p_40572_, p_40573_, p_40574_, p_40575_) + p_40574_.add(TranslatableComponent("$descriptionId.desc").withStyle(ChatFormatting.GRAY)) + } + } + } + val MACHINES = SupplierList( ::ANDROID_STATION, ::BATTERY_BANK, ::MATTER_DECOMPOSER, ::MATTER_CAPACITOR_BANK, ::MATTER_CABLE, ::PATTERN_STORAGE, ::MATTER_SCANNER, ::MATTER_PANEL, ::MATTER_REPLICATOR, ::MATTER_BOTTLER, ::ENERGY_COUNTER, ::CHEMICAL_GENERATOR, ::PLATE_PRESS, ::MATTER_RECYCLER, ::STORAGE_BUS, ::STORAGE_IMPORTER, ::STORAGE_EXPORTER, ::DRIVE_VIEWER, ::DRIVE_RACK, ::ITEM_MONITOR, ::STORAGE_CABLE, ::STORAGE_POWER_SUPPLIER, ::ENERGY_SERVO, - ::PHANTOM_ATTRACTOR, - ::GRAVITATION_STABILIZER, ::COBBLESTONE_GENERATOR, ::ESSENCE_STORAGE + ::PHANTOM_ATTRACTOR, ::GRAVITATION_STABILIZER, ::COBBLESTONE_GENERATOR, ::ESSENCE_STORAGE, + ::ITEM_REPAIRER ) val DEBUG_EXPLOSION_SMALL: Item by registry.register(MNames.DEBUG_EXPLOSION_SMALL) { BlockItem(MBlocks.DEBUG_EXPLOSION_SMALL, Item.Properties().stacksTo(64)) } 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 3c3d70b9e..245456f38 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt @@ -10,6 +10,7 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.client.screen.decorative.CargoCrateScreen import ru.dbotthepony.mc.otm.client.screen.decorative.HoloSignScreen import ru.dbotthepony.mc.otm.client.screen.decorative.MinecartCargoCrateScreen +import ru.dbotthepony.mc.otm.client.screen.matter.ItemRepairerScreen import ru.dbotthepony.mc.otm.client.screen.matter.MatterBottlerScreen import ru.dbotthepony.mc.otm.client.screen.matter.MatterCapacitorBankScreen import ru.dbotthepony.mc.otm.client.screen.matter.MatterDecomposerScreen @@ -36,6 +37,7 @@ import ru.dbotthepony.mc.otm.client.screen.tech.PlatePressScreen import ru.dbotthepony.mc.otm.menu.decorative.CargoCrateMenu import ru.dbotthepony.mc.otm.menu.decorative.HoloSignMenu import ru.dbotthepony.mc.otm.menu.decorative.MinecartCargoCrateMenu +import ru.dbotthepony.mc.otm.menu.matter.ItemRepairerMenu import ru.dbotthepony.mc.otm.menu.matter.MatterBottlerMenu import ru.dbotthepony.mc.otm.menu.matter.MatterCapacitorBankMenu import ru.dbotthepony.mc.otm.menu.matter.MatterDecomposerMenu @@ -85,6 +87,7 @@ object MMenus { val HOLO_SIGN: MenuType by registry.register(MNames.HOLO_SIGN) { MenuType(::HoloSignMenu) } val COBBLESTONE_GENERATOR: MenuType by registry.register(MNames.COBBLESTONE_GENERATOR) { MenuType(::CobblerMenu) } val ESSENCE_STORAGE: MenuType by registry.register(MNames.ESSENCE_STORAGE) { MenuType(::EssenceStorageMenu) } + val ITEM_REPAIER: MenuType by registry.register(MNames.ITEM_REPAIRER) { MenuType(::ItemRepairerMenu) } val STORAGE_BUS: MenuType<*> by registry.register(MNames.STORAGE_BUS) { MenuType(::StorageBusMenu) } val STORAGE_EXPORTER: MenuType<*> by registry.register(MNames.STORAGE_EXPORTER) { MenuType(::StorageExporterMenu) } @@ -125,6 +128,7 @@ object MMenus { MenuScreens.register(HOLO_SIGN, ::HoloSignScreen) MenuScreens.register(COBBLESTONE_GENERATOR, ::CobblerScreen) MenuScreens.register(ESSENCE_STORAGE, ::EssenceStorageScreen) + MenuScreens.register(ITEM_REPAIER, ::ItemRepairerScreen) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index 02bfadbcd..205d773c2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -23,6 +23,7 @@ object MNames { const val MATTER_PANEL = "matter_panel" const val MATTER_REPLICATOR = "matter_replicator" const val MATTER_BOTTLER = "matter_bottler" + const val ITEM_REPAIRER = "item_repairer" const val DRIVE_VIEWER = "drive_viewer" const val DRIVE_RACK = "drive_rack" const val ITEM_MONITOR = "item_monitor" From d47e5b3d7a4407b636b0b06d366d49e2fc49ec00 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 23 Mar 2023 08:04:41 +0700 Subject: [PATCH 0419/1199] ConfigurableItemHandler now has inputOutput variant --- .../otm/block/entity/MatteryDeviceBlockEntity.kt | 16 ++++++++++++++-- .../entity/matter/ItemRepairerBlockEntity.kt | 12 +----------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index 878120d13..a30caeb8a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -223,6 +223,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo inner class ConfigurableItemHandler( val input: IItemHandler? = null, val output: IItemHandler? = null, + inputOutput: IItemHandler? = null, val battery: IItemHandler? = null, val frontDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.FRONT), val backDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.BACK), @@ -236,6 +237,9 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo val inputOutput: IItemHandler? init { + if ((input != null || output != null) && inputOutput != null) + throw IllegalArgumentException("Either specify input or/and output separately, or specify inputOutput") + val builder = ImmutableSet.Builder() builder.add(ItemHandlerMode.DISABLED) @@ -243,20 +247,28 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo if (input != null) builder.add(ItemHandlerMode.INPUT) if (output != null) builder.add(ItemHandlerMode.OUTPUT) if (input != null && output != null) builder.add(ItemHandlerMode.INPUT_OUTPUT) + + if (inputOutput != null) { + builder.add(ItemHandlerMode.INPUT) + builder.add(ItemHandlerMode.OUTPUT) + builder.add(ItemHandlerMode.INPUT_OUTPUT) + } + if (battery != null) builder.add(ItemHandlerMode.BATTERY) possibleViews = builder.build() if (input != null && output != null) { - inputOutput = CombinedItemHandler(input, output) + this.inputOutput = CombinedItemHandler(input, output) } else { - inputOutput = null + this.inputOutput = inputOutput } val caps = ArrayList() if (input != null) caps.add(input) if (output != null) caps.add(output) + if (inputOutput != null) caps.add(inputOutput) if (battery != null) caps.add(battery) sideless = UnmodifiableItemHandler(CombinedItemHandler(caps)) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt index 9c423d202..4ad22dacc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt @@ -71,7 +71,7 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt val energyConfig = ConfigurableEnergy(energy) val itemConfig = ConfigurableItemHandler( - input = repairContainer.handler(object : HandlerFilter { + inputOutput = repairContainer.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { if (!stack.isRepairable || !stack.isDamaged) { return false @@ -95,16 +95,6 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt }.hasMatterValue } - override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { - return false - } - }), - - output = repairContainer.handler(object : HandlerFilter { - override fun canInsert(slot: Int, stack: ItemStack): Boolean { - return false - } - override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { return progressPerTick <= 0.0 || matterPerTick <= Decimal.ZERO } From 5b1d52489ea3413d2d4be091d029568bb741074f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 23 Mar 2023 08:05:04 +0700 Subject: [PATCH 0420/1199] CombinedItemHandler no longer checks underlying handlers if they are mattery container handlers --- .../mc/otm/capability/CombinedItemHandler.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/CombinedItemHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/CombinedItemHandler.kt index b43fc9121..450e614cd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/CombinedItemHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/CombinedItemHandler.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.capability import com.google.common.collect.ImmutableList import net.minecraft.world.item.ItemStack import net.minecraftforge.items.IItemHandler +import ru.dbotthepony.mc.otm.container.ContainerHandler import java.util.stream.Stream class CombinedItemHandler(val handlers: ImmutableList) : IItemHandler { @@ -10,12 +11,20 @@ class CombinedItemHandler(val handlers: ImmutableList) : IItemHand constructor(handlers: Collection) : this(ImmutableList.copyOf(handlers)) constructor(vararg handlers: IItemHandler) : this(ImmutableList.copyOf(handlers)) + private val needsChecking = handlers.any { it !is ContainerHandler } private val lastSizes = IntArray(this.handlers.size) private var totalSize = 0 private val mappings = ArrayList() private data class Mapping(val handler: IItemHandler, val slot: Int) - private fun check() { + init { + check(true) + } + + private fun check(force: Boolean = false) { + if (!needsChecking && !force) + return + for ((i, handler) in handlers.withIndex()) { var oldSize = lastSizes[i] From 2b4a8ec2c4a9f7a514119545f94159d9f38a20af Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 23 Mar 2023 08:13:54 +0700 Subject: [PATCH 0421/1199] :sip: --- .../mc/otm/container/ContainerHandler.kt | 1 - .../mc/otm/container/MatteryContainer.kt | 16 +--------------- 2 files changed, 1 insertion(+), 16 deletions(-) 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 7a6c610b0..c0d59ac10 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHandler.kt @@ -21,7 +21,6 @@ class ContainerHandler @JvmOverloads internal constructor( if (localStack.isEmpty) { if (!simulate) { val copy = stack.copy() - container.setChanged(slot, copy, ItemStack.EMPTY) container.setItem(slot, copy) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt index 6fc6f998f..aa3f35760 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt @@ -32,7 +32,6 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I require(size >= 0) { "Invalid container size $size" } } - private var ignoreChangeNotifications = 0 protected val slots: Array = Array(size) { ItemStack.EMPTY } private val trackedSlots: Array = Array(size) { ItemStack.EMPTY } private val filters: Array = arrayOfNulls(size) @@ -103,19 +102,6 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I } final override fun getContainerSize() = size - - fun startIgnoreUpdates() { - if (++ignoreChangeNotifications == 1) { - startedIgnoringUpdates() - } - } - - fun stopIgnoreUpdates() { - if (--ignoreChangeNotifications == 0) { - stoppedIgnoringUpdates() - } - } - protected open fun startedIgnoringUpdates() {} protected open fun stoppedIgnoringUpdates() {} @@ -187,7 +173,7 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I } open fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { - if (ignoreChangeNotifications == 0) watcher.run() + watcher.run() } override fun serializeNBT(): CompoundTag { From f0caf66b68279046f93d6de1befec30b3ba0f293 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 23 Mar 2023 15:15:04 +0700 Subject: [PATCH 0422/1199] Fix containerhandler stack size logic --- .../mc/otm/container/ContainerHandler.kt | 19 ++++++++++--------- .../mc/otm/container/MatteryContainer.kt | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) 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 c0d59ac10..57121bce9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHandler.kt @@ -20,20 +20,22 @@ class ContainerHandler @JvmOverloads internal constructor( if (localStack.isEmpty) { if (!simulate) { - val copy = stack.copy() - container.setItem(slot, copy) + container.setItem(slot, stack.copyWithCount(stack.count.coerceAtMost(stack.maxStackSize).coerceAtMost(container.getMaxStackSize(slot)))) } - return ItemStack.EMPTY - } else if (localStack.isStackable && localStack.maxStackSize > localStack.count && ItemStack.isSameItemSameTags(localStack, stack)) { - val newCount = localStack.maxStackSize.coerceAtMost(localStack.count + stack.count) + if (stack.count <= container.getMaxStackSize(slot).coerceAtMost(stack.maxStackSize)) { + return ItemStack.EMPTY + } else { + return stack.copyWithCount(container.getMaxStackSize(slot)) + } + } else if (localStack.isStackable && localStack.maxStackSize.coerceAtMost(container.getMaxStackSize(slot)) > localStack.count && ItemStack.isSameItemSameTags(localStack, stack)) { + val newCount = localStack.maxStackSize.coerceAtMost(localStack.count + stack.count).coerceAtMost(container.getMaxStackSize(slot)) val diff = newCount - localStack.count if (diff != 0) { if (!simulate) { - val old = localStack.copy() localStack.grow(diff) - container.setChanged(slot, localStack, old) + container.setChanged(slot) } val copy = stack.copy() @@ -60,9 +62,8 @@ class ContainerHandler @JvmOverloads internal constructor( copy.count = minimal if (!simulate) { - val old = localStack.copy() localStack.shrink(minimal) - container.setChanged(slot, localStack, old) + container.setChanged(slot) } return copy diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt index aa3f35760..7f445dd50 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt @@ -172,7 +172,7 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I } } - open fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { + protected open fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { watcher.run() } From 5f16804febcd823c1a7b0f86fb2120d33d4180eb Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 24 Mar 2023 20:25:35 +0700 Subject: [PATCH 0423/1199] New graph implementation --- .../mc/otm/capability/MatteryCapability.java | 12 +- .../dbotthepony/mc/otm/GlobalEventHandler.kt | 3 + .../dbotthepony/mc/otm/block/entity/Cables.kt | 136 ++--- .../entity/matter/ItemRepairerBlockEntity.kt | 35 +- .../entity/matter/MatterBottlerBlockEntity.kt | 25 +- .../matter/MatterCapacitorBankBlockEntity.kt | 21 +- .../matter/MatterDecomposerBlockEntity.kt | 44 +- .../entity/matter/MatterPanelBlockEntity.kt | 31 +- .../matter/MatterRecyclerBlockEntity.kt | 22 +- .../matter/MatterReplicatorBlockEntity.kt | 95 ++-- .../entity/matter/MatterScannerBlockEntity.kt | 71 ++- .../matter/PatternStorageBlockEntity.kt | 42 +- .../entity/storage/DriveRackBlockEntity.kt | 12 +- .../entity/storage/ItemMonitorBlockEntity.kt | 16 +- .../entity/storage/StorageBusBlockEntity.kt | 25 +- .../block/entity/storage/StorageInterfaces.kt | 34 +- .../StoragePowerSupplierBlockEntity.kt | 23 +- .../dbotthepony/mc/otm/compat/mekanism/QIO.kt | 40 +- .../dbotthepony/mc/otm/core/util/LOHolder.kt | 20 + .../mc/otm/graph/Abstract6Graph.kt | 254 +++++---- .../ru/dbotthepony/mc/otm/graph/Graph6Node.kt | 527 ++++++++---------- .../dbotthepony/mc/otm/graph/GraphFlooder.kt | 64 --- ...erGraphNode.kt => IMatterGraphListener.kt} | 10 - .../{MatterNetworkGraph.kt => MatterGraph.kt} | 127 ++--- .../mc/otm/graph/matter/MatterNode.kt | 18 + .../mc/otm/graph/matter/SimpleMatterNode.kt | 23 + .../mc/otm/graph/storage/IStorageGraphNode.kt | 22 - ...StorageNetworkGraph.kt => StorageGraph.kt} | 51 +- ...asicStorageGraphNode.kt => StorageNode.kt} | 103 ++-- .../mc/otm/menu/matter/MatterBottlerMenu.kt | 4 +- .../menu/matter/MatterCapacitorBankMenu.kt | 4 +- .../mc/otm/menu/matter/MatterPanelMenu.kt | 24 +- .../mc/otm/menu/matter/MatterRecyclerMenu.kt | 6 +- .../mc/otm/menu/matter/MatterScannerMenu.kt | 4 +- .../mc/otm/menu/matter/PatternStorageMenu.kt | 4 +- .../menu/storage/StoragePowerSupplierMenu.kt | 2 +- 36 files changed, 808 insertions(+), 1146 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/util/LOHolder.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/graph/GraphFlooder.kt rename src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/{IMatterGraphNode.kt => IMatterGraphListener.kt} (58%) rename src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/{MatterNetworkGraph.kt => MatterGraph.kt} (64%) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNode.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/SimpleMatterNode.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/IStorageGraphNode.kt rename src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/{StorageNetworkGraph.kt => StorageGraph.kt} (60%) rename src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/{BasicStorageGraphNode.kt => StorageNode.kt} (61%) diff --git a/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java b/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java index 4b182e74a..ad3d8aeff 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java +++ b/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java @@ -11,8 +11,8 @@ import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage; import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage; import ru.dbotthepony.mc.otm.capability.matter.IReplicationTaskProvider; import ru.dbotthepony.mc.otm.capability.matter.IPatternStorage; -import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode; -import ru.dbotthepony.mc.otm.graph.storage.IStorageGraphNode; +import ru.dbotthepony.mc.otm.graph.matter.MatterNode; +import ru.dbotthepony.mc.otm.graph.storage.StorageNode; import top.theillusivec4.curios.api.type.capability.ICurio; import top.theillusivec4.curios.api.type.capability.ICuriosItemHandler; @@ -33,7 +33,7 @@ public class MatteryCapability { @Nonnull @NotNull - public static final Capability MATTER_NODE = CapabilityManager.get(new CapabilityToken<>() {}); + public static final Capability MATTER_NODE = CapabilityManager.get(new CapabilityToken<>() {}); @Nonnull @NotNull @@ -49,7 +49,7 @@ public class MatteryCapability { @Nonnull @NotNull - public static final Capability STORAGE_NODE = CapabilityManager.get(new CapabilityToken<>() {}); + public static final Capability STORAGE_NODE = CapabilityManager.get(new CapabilityToken<>() {}); @Nonnull @NotNull @@ -67,10 +67,10 @@ public class MatteryCapability { event.register(IMatteryEnergyStorage.class); event.register(MatteryPlayerCapability.class); event.register(IMatterStorage.class); - event.register(IMatterGraphNode.class); + event.register(MatterNode.class); event.register(IPatternStorage.class); event.register(IReplicationTaskProvider.class); event.register(IMatteryDrive.class); - event.register(IStorageGraphNode.class); + event.register(StorageNode.class); } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt index 0130a93d4..d52964449 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt @@ -19,6 +19,7 @@ import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.util.IConditionalTickable import ru.dbotthepony.mc.otm.core.util.ITickable import ru.dbotthepony.mc.otm.core.util.TickList +import ru.dbotthepony.mc.otm.graph.Abstract6Graph import java.util.* private val preServerTick = TickList() @@ -145,6 +146,8 @@ fun onServerTick(event: ServerTickEvent) { preServerTick.tick() } else { postServerTick.tick() + // чтоб не плодить кучу подписчиков, вызовем напрямую отсюда + Abstract6Graph.tick() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Cables.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Cables.kt index 7b091594c..12d498cf7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Cables.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Cables.kt @@ -2,135 +2,81 @@ package ru.dbotthepony.mc.otm.block.entity import net.minecraft.core.BlockPos import net.minecraft.core.Direction -import net.minecraft.server.level.ServerLevel import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block -import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.state.BlockState -import net.minecraftforge.common.capabilities.Capability -import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.SERVER_IS_LIVE import ru.dbotthepony.mc.otm.block.CableBlock import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.graph.Graph6Node -import ru.dbotthepony.mc.otm.graph.GraphNodeListener -import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode -import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph -import ru.dbotthepony.mc.otm.graph.storage.IStorageGraphNode -import ru.dbotthepony.mc.otm.graph.storage.StorageNetworkGraph +import ru.dbotthepony.mc.otm.graph.matter.MatterNode +import ru.dbotthepony.mc.otm.graph.storage.StorageGraph +import ru.dbotthepony.mc.otm.graph.storage.StorageNode import ru.dbotthepony.mc.otm.registry.MBlockEntities -class MatterCableBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : - BlockEntity(MBlockEntities.MATTER_CABLE, p_155229_, p_155230_), IMatterGraphNode, GraphNodeListener { +class MatterCableBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryBlockEntity(MBlockEntities.MATTER_CABLE, p_155229_, p_155230_) { + val matterNode = object : MatterNode() { + override fun onNeighbour(direction: Direction) { + val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, true) - private var valid = true - override val matterNode = Graph6Node(this) - private val resolverNode = LazyOptional.of { this } - - override fun invalidateCaps() { - super.invalidateCaps() - valid = false - } - - override fun reviveCaps() { - super.reviveCaps() - valid = true - } - - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - if (valid) { - if (cap === MatteryCapability.MATTER_NODE) - return resolverNode.cast() + if (newState !== blockState && SERVER_IS_LIVE) + level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) } - return super.getCapability(cap, side) + override fun onUnNeighbour(direction: Direction) { + val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, false) + + if (newState !== blockState && SERVER_IS_LIVE) + level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + } } - override fun setLevel(p_155231_: Level) { - super.setLevel(p_155231_) - - if (p_155231_ is ServerLevel) - MatterNetworkGraph.discoverFull(this, matterNode) + init { + exposeGlobally(MatteryCapability.MATTER_NODE, matterNode) } - override fun onNeighbour(node: Graph6Node<*>, direction: Direction) { - val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, true) - - if (newState !== blockState && SERVER_IS_LIVE) - level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) - } - - override fun onUnNeighbour(node: Graph6Node<*>, direction: Direction) { - val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, false) - - if (newState !== blockState && SERVER_IS_LIVE) - level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + override fun setLevel(level: Level) { + super.setLevel(level) + matterNode.discover(this) } override fun setRemoved() { super.setRemoved() - matterNode.destroy(::MatterNetworkGraph) + matterNode.isValid = false } } -class StorageCableBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : - BlockEntity(MBlockEntities.STORAGE_CABLE, p_155229_, p_155230_), IStorageGraphNode, GraphNodeListener { +class StorageCableBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryBlockEntity(MBlockEntities.STORAGE_CABLE, p_155229_, p_155230_) { + val storageNode = object : StorageNode() { + override fun attachComponents(to: StorageGraph) {} + override fun removeComponents(from: StorageGraph) {} - private var valid = true - private val resolverNode = LazyOptional.of { this } + override fun onNeighbour(direction: Direction) { + val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, true) - override fun attachComponents(to: StorageNetworkGraph) {} - override fun removeComponents(from: StorageNetworkGraph) {} - override val storageNode = Graph6Node(this) - - override fun invalidateCaps() { - super.invalidateCaps() - valid = false - } - - override fun reviveCaps() { - super.reviveCaps() - valid = true - } - - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - if (valid) { - if (cap === MatteryCapability.STORAGE_NODE) - return resolverNode.cast() + if (newState !== blockState && SERVER_IS_LIVE) + level!!.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) } - return super.getCapability(cap, side) + override fun onUnNeighbour(direction: Direction) { + val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, false) + + if (newState !== blockState && SERVER_IS_LIVE) + level!!.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + } } - override fun setLevel(p_155231_: Level) { - super.setLevel(p_155231_) - - if (p_155231_ is ServerLevel) - StorageNetworkGraph.discoverFull(this, storageNode) + init { + exposeGlobally(MatteryCapability.STORAGE_NODE, storageNode) } - override fun onNeighbour(node: Graph6Node<*>, direction: Direction) { - val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, true) - - if (newState !== blockState && SERVER_IS_LIVE) - level!!.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) - } - - override fun onUnNeighbour(node: Graph6Node<*>, direction: Direction) { - val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, false) - - if (newState !== blockState && SERVER_IS_LIVE) - level!!.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + override fun setLevel(level: Level) { + super.setLevel(level) + storageNode.discover(this) } override fun setRemoved() { super.setRemoved() - - val level = level!! - - storageNode.destroy { - StorageNetworkGraph(level) - } + storageNode.isValid = false } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt index 4ad22dacc..625df3d54 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt @@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.block.entity.matter import net.minecraft.core.BlockPos import net.minecraft.nbt.StringTag import net.minecraft.resources.ResourceLocation -import net.minecraft.server.level.ServerLevel import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu @@ -29,16 +28,16 @@ import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.core.util.WriteOnce -import ru.dbotthepony.mc.otm.graph.Graph6Node -import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode -import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph +import ru.dbotthepony.mc.otm.graph.matter.MatterGraph +import ru.dbotthepony.mc.otm.graph.matter.MatterNode +import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode import ru.dbotthepony.mc.otm.matter.IMatterValue import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.menu.matter.ItemRepairerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MNames -class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.ITEM_REPAIRER, blockPos, blockState), IMatterGraphNode { +class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.ITEM_REPAIRER, blockPos, blockState) { val repairContainer = MatteryContainer(::containerChanged, 1).also(::addDroppableContainer) private var matterPerTick = Decimal.ZERO @@ -48,13 +47,13 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt var canNotWork = false - override val matterNode = Graph6Node(this) val matter = MatterStorageImpl(::setChangedLight, FlowDirection.INPUT, ::CAPACITY) + val matterNode = SimpleMatterNode(matter = matter) val energy = WorkerEnergyStorage(::setChangedLight, ENERGY_VALUES) init { exposeGlobally(MatteryCapability.MATTER, matter) - exposeGlobally(MatteryCapability.MATTER_NODE, this) + exposeGlobally(MatteryCapability.MATTER_NODE, matterNode) savetables.stateful(::repairContainer) savetables.stateful(::matter) @@ -83,10 +82,10 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt } } - return (matterNode.graph as MatterNetworkGraph?) - ?.patterns - ?.filter { stack.item.isValidRepairItem(stack, ItemStack(it.item, 1)) } - ?.findFirst()?.orElse(null).let { + return matterNode.graph + .patterns + .filter { stack.item.isValidRepairItem(stack, ItemStack(it.item, 1)) } + .findFirst().orElse(null).let { if (it == null) { IMatterValue.ZERO } else { @@ -105,20 +104,14 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt return ItemRepairerMenu(containerID, inventory, this) } - override fun getMatterHandler(): IMatterStorage { - return matter - } - override fun setRemoved() { super.setRemoved() - matterNode.destroy(::MatterNetworkGraph) + matterNode.isValid = false } override fun setLevel(level: Level) { super.setLevel(level) - - if (level is ServerLevel) - MatterNetworkGraph.discoverFull(this, matterNode) + matterNode.discover(this) } private fun containerChanged() { @@ -147,7 +140,7 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt } } - val found = (matterNode.graph as MatterNetworkGraph?)?.patterns?.filter { item.item.isValidRepairItem(item, ItemStack(it.item, 1)) }?.findFirst()?.orElse(null) + val found = matterNode.graph.patterns.filter { item.item.isValidRepairItem(item, ItemStack(it.item, 1)) }.findFirst().orElse(null) if (found != null) { @Suppress("name_shadowing") @@ -187,7 +180,7 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt } if (matter.storedMatter < matterPerTick) { - val graph = matterNode.graph as MatterNetworkGraph? + val graph = matterNode.graph as MatterGraph? if (graph != null) { val toDrain = (matterPerTick * EXTRACT_TICKS.coerceAtMost(item.damageValue)).coerceAtLeast(Decimal.ZERO).coerceAtMost(matter.missingMatter) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index 697386f75..799e86601 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -22,9 +22,7 @@ import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.HandlerFilter -import ru.dbotthepony.mc.otm.graph.Graph6Node -import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode -import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph +import ru.dbotthepony.mc.otm.graph.matter.MatterGraph import ru.dbotthepony.mc.otm.menu.matter.MatterBottlerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.core.* @@ -33,11 +31,12 @@ import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal +import ru.dbotthepony.mc.otm.graph.matter.MatterNode +import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : - MatteryPoweredBlockEntity(MBlockEntities.MATTER_BOTTLER, p_155229_, p_155230_), IMatterGraphNode { + MatteryPoweredBlockEntity(MBlockEntities.MATTER_BOTTLER, p_155229_, p_155230_) { - override val matterNode = Graph6Node(this) val energy = WorkerEnergyStorage(this, ENERGY_VALUES) var isBottling: Boolean = true @@ -110,9 +109,11 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } + val matterNode = SimpleMatterNode(matter = matter) + init { exposeGlobally(MatteryCapability.MATTER, matter) - exposeGlobally(MatteryCapability.MATTER_NODE, this) + exposeGlobally(MatteryCapability.MATTER_NODE, matterNode) exposeItemsGlobally(itemHandler) savetables.bool(::isBottling) @@ -126,15 +127,9 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : private var initialCapacity: Decimal? = null private var lastWorkStack: ItemStack? = null - override fun getMatterHandler(): IMatterStorage { - return matter - } - override fun setLevel(level: Level) { super.setLevel(level) - - if (level is ServerLevel) - MatterNetworkGraph.discoverFull(this, matterNode) + matterNode.discover(this) } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { @@ -163,7 +158,7 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : override fun setRemoved() { super.setRemoved() - matterNode.destroy(::MatterNetworkGraph) + matterNode.isValid = false } override fun tick() { @@ -212,7 +207,7 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : initialCapacity = capability!!.storedMatter } - val graph = matterNode.graph as MatterNetworkGraph? + val graph = matterNode.graph as MatterGraph? if (capability != null) { if (blockState.getValue(WorkerState.SEMI_WORKER_STATE) !== WorkerState.WORKING) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt index 78f70be78..bc77a87fd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.block.entity.matter import net.minecraft.core.BlockPos -import net.minecraft.server.level.ServerLevel import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu @@ -17,17 +16,15 @@ import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.ifPresentK -import ru.dbotthepony.mc.otm.graph.Graph6Node -import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode -import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph +import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode import ru.dbotthepony.mc.otm.menu.matter.MatterCapacitorBankMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities -class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.MATTER_CAPACITOR_BANK, p_155229_, p_155230_), IMatterGraphNode, IMatterStorage { +class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.MATTER_CAPACITOR_BANK, p_155229_, p_155230_), IMatterStorage { var gaugeLevel by synchronizer.float().property private set - override val matterNode = Graph6Node(this) + val matterNode = SimpleMatterNode(matter = this) override val canSetMatterLevel: Boolean get() = false @@ -137,7 +134,7 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) init { savetable(::container, INVENTORY_KEY) exposeGlobally(MatteryCapability.MATTER, this) - exposeGlobally(MatteryCapability.MATTER_NODE, this) + exposeGlobally(MatteryCapability.MATTER_NODE, matterNode) } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { @@ -146,17 +143,11 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) override fun setRemoved() { super.setRemoved() - matterNode.destroy(::MatterNetworkGraph) + matterNode.isValid = false } override fun setLevel(level: Level) { super.setLevel(level) - - if (level is ServerLevel) - MatterNetworkGraph.discoverFull(this, matterNode) - } - - override fun getMatterHandler(): IMatterStorage { - return this + matterNode.discover(this) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index b9f889f36..60fa7ae59 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.block.entity.matter import net.minecraft.core.BlockPos import net.minecraft.nbt.CompoundTag -import net.minecraft.server.level.ServerLevel import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu @@ -10,32 +9,30 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeConfigSpec -import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection -import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage -import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl -import ru.dbotthepony.mc.otm.container.MatteryContainer +import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.container.HandlerFilter -import ru.dbotthepony.mc.otm.graph.Graph6Node -import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode -import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph -import ru.dbotthepony.mc.otm.item.MatterDustItem -import ru.dbotthepony.mc.otm.menu.matter.MatterDecomposerMenu -import ru.dbotthepony.mc.otm.registry.MBlockEntities -import ru.dbotthepony.mc.otm.registry.MItems -import ru.dbotthepony.mc.otm.registry.MNames -import ru.dbotthepony.mc.otm.core.util.WriteOnce +import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.core.math.getDecimal import ru.dbotthepony.mc.otm.core.math.set import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.core.util.WriteOnce +import ru.dbotthepony.mc.otm.graph.matter.MatterGraph +import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode +import ru.dbotthepony.mc.otm.item.MatterDustItem import ru.dbotthepony.mc.otm.matter.MatterManager +import ru.dbotthepony.mc.otm.menu.matter.MatterDecomposerMenu +import ru.dbotthepony.mc.otm.registry.MBlockEntities +import ru.dbotthepony.mc.otm.registry.MItems +import ru.dbotthepony.mc.otm.registry.MNames fun moveMatterAsDustIntoContainer(_matterValue: Decimal, container: MatteryContainer, OUTPUT_DUST_MAIN: Int, OUTPUT_DUST_STACKING: Int): Decimal { var matterValue = _matterValue @@ -91,7 +88,7 @@ fun moveMatterAsDustIntoContainer(_matterValue: Decimal, container: MatteryConta } class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) - : MatteryWorkerBlockEntity(MBlockEntities.MATTER_DECOMPOSER, pos, state, ::DecomposerJob), IMatterGraphNode { + : MatteryWorkerBlockEntity(MBlockEntities.MATTER_DECOMPOSER, pos, state, ::DecomposerJob) { class DecomposerJob : Job { val toDust: Boolean @@ -127,13 +124,12 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) savetable(::energy, ENERGY_KEY) } - override val matterNode = Graph6Node(this) - val matter = MatterStorageImpl(::setChangedLight, FlowDirection.OUTPUT, ::CAPACITY) + val matterNode = SimpleMatterNode(matter = matter) init { exposeGlobally(MatteryCapability.MATTER, matter) - exposeGlobally(MatteryCapability.MATTER_NODE, this) + exposeGlobally(MatteryCapability.MATTER_NODE, matterNode) savetable(::matter, MATTER_STORAGE_KEY) } @@ -199,24 +195,18 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) override fun setRemoved() { super.setRemoved() - matterNode.destroy(::MatterNetworkGraph) + matterNode.isValid = false } override fun setLevel(level: Level) { super.setLevel(level) - - if (level is ServerLevel) - MatterNetworkGraph.discoverFull(this, matterNode) - } - - override fun getMatterHandler(): IMatterStorage { - return matter + matterNode.discover(this) } override fun tick() { super.tick() - val grid = matterNode.graph as MatterNetworkGraph? ?: return + val grid = matterNode.graph as MatterGraph? ?: return if (!matter.storedMatter.isZero) { val diff = matter.extractMatterInner(matter.storedMatter, true) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt index 7aabff5bb..2bce86dcf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt @@ -25,14 +25,15 @@ import ru.dbotthepony.mc.otm.core.nbt.mapString import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.ItemSorter import ru.dbotthepony.mc.otm.graph.Graph6Node -import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode -import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph +import ru.dbotthepony.mc.otm.graph.matter.MatterGraph +import ru.dbotthepony.mc.otm.graph.matter.MatterNode +import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode import ru.dbotthepony.mc.otm.registry.MBlockEntities import java.util.ArrayList import java.util.stream.Stream class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : - MatteryDeviceBlockEntity(MBlockEntities.MATTER_PANEL, p_155229_, p_155230_), IMatterGraphNode, IReplicationTaskProvider { + MatteryDeviceBlockEntity(MBlockEntities.MATTER_PANEL, p_155229_, p_155230_), IReplicationTaskProvider { class PlayerSettings(var sorter: ItemSorter = ItemSorter.DEFAULT, var ascending: Boolean = true) : INBTSerializable { override fun serializeNBT(): CompoundTag { @@ -55,7 +56,7 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } private val listeners = ArrayList() - override val matterNode = Graph6Node(this) + val matterNode = SimpleMatterNode(tasks = this) fun attachMenu(menu: MatterPanelMenu) { listeners.add(menu) @@ -70,24 +71,18 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } init { - exposeGlobally(MatteryCapability.MATTER_NODE, this) + exposeGlobally(MatteryCapability.MATTER_NODE, matterNode) exposeGlobally(MatteryCapability.TASK, this) } override fun setLevel(level: Level) { super.setLevel(level) - - if (level is ServerLevel) - MatterNetworkGraph.discoverFull(this, matterNode) + matterNode.discover(this) } override fun setRemoved() { super.setRemoved() - matterNode.destroy(::MatterNetworkGraph) - } - - override fun getTaskHandler(): IReplicationTaskProvider { - return this + matterNode.isValid = false } private val _tasks = HashMap() @@ -101,7 +96,7 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } override fun allocateTask(simulate: Boolean): ReplicationTaskAllocation? { - val graph = matterNode.graph as MatterNetworkGraph? ?: return null + val graph = matterNode.graph as MatterGraph? ?: return null for ((key, task) in _tasks) { if (task.required > 0) { @@ -127,7 +122,7 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val oldTask = localTask localTask = localTask.finish() - val graph = matterNode.graph as MatterNetworkGraph? + val graph = matterNode.graph as MatterGraph? // Задача полностью выполнена if (localTask.required <= 0 && localTask.inProgress <= 0) { @@ -196,7 +191,7 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val task = _tasks[id] ?: return _tasks.remove(id) - (matterNode.graph as MatterNetworkGraph?)?.onMatterTaskRemoved(task) + (matterNode.graph as MatterGraph?)?.onMatterTaskRemoved(task) listeners.forEach { it.taskRemoved(task) } setChanged() @@ -206,7 +201,7 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val task = ReplicationTask(UUID.randomUUID(), state.id, state.item, 0, 0, count) _tasks[task.id] = task - (matterNode.graph as MatterNetworkGraph?)?.onMatterTaskCreated(task) + (matterNode.graph as MatterGraph?)?.onMatterTaskCreated(task) listeners.forEach { it.taskUpdated(task) } setChanged() @@ -215,7 +210,7 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } override fun dropAllTasks() { - val graph = matterNode.graph as MatterNetworkGraph? + val graph = matterNode.graph as MatterGraph? for (task in _tasks.values) { graph?.onMatterTaskRemoved(task) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index 432ba23e8..9db761ccd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -23,8 +23,7 @@ import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.graph.Graph6Node -import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode -import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph +import ru.dbotthepony.mc.otm.graph.matter.MatterGraph import ru.dbotthepony.mc.otm.item.MatterDustItem import ru.dbotthepony.mc.otm.menu.matter.MatterRecyclerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -34,9 +33,10 @@ import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.core.math.getDecimal import ru.dbotthepony.mc.otm.core.math.set +import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) - : MatteryWorkerBlockEntity(MBlockEntities.MATTER_RECYCLER, blockPos, blockState, ::RecyclerJob), IMatterGraphNode { + : MatteryWorkerBlockEntity(MBlockEntities.MATTER_RECYCLER, blockPos, blockState, ::RecyclerJob) { class RecyclerJob : Job { var totalMatter: Decimal @@ -72,13 +72,9 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) val container = MatteryContainer(this::itemContainerUpdated, 1).also(::addDroppableContainer) - override val matterNode = Graph6Node(this) + val matterNode = SimpleMatterNode(matter = matter) val energy = WorkerEnergyStorage(this::powerLevelUpdated, ENERGY_CONFIG) - override fun getMatterHandler(): IMatterStorage { - return matter - } - private val itemHandler = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { return stack.item is MatterDustItem @@ -93,7 +89,7 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) exposeItemsGlobally(itemHandler) exposeEnergyGlobally(energy) exposeGlobally(MatteryCapability.MATTER, matter) - exposeGlobally(MatteryCapability.MATTER_NODE, this) + exposeGlobally(MatteryCapability.MATTER_NODE, matterNode) savetable(::energy, ENERGY_KEY) savetable(::container, INVENTORY_KEY) savetable(::matter, MATTER_STORAGE_KEY) @@ -101,14 +97,12 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) override fun setRemoved() { super.setRemoved() - matterNode.destroy(::MatterNetworkGraph) + matterNode.isValid = false } override fun setLevel(level: Level) { super.setLevel(level) - - if (level is ServerLevel) - MatterNetworkGraph.discoverFull(this, matterNode) + matterNode.discover(this) } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { @@ -155,7 +149,7 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) override fun tick() { super.tick() - val graph = matterNode.graph as MatterNetworkGraph? ?: return + val graph = matterNode.graph as MatterGraph? ?: return val received = graph.receiveMatter(matter.storedMatter, false) if (!received.isZero) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index 74ade4275..1206dc3aa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.block.entity.matter import net.minecraft.core.BlockPos import net.minecraft.nbt.CompoundTag -import net.minecraft.server.level.ServerLevel import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu @@ -10,22 +9,20 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeConfigSpec -import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection -import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage -import ru.dbotthepony.mc.otm.capability.matter.* -import ru.dbotthepony.mc.otm.container.MatteryContainer +import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage +import ru.dbotthepony.mc.otm.capability.matter.IPatternState +import ru.dbotthepony.mc.otm.capability.matter.IReplicationTask +import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl +import ru.dbotthepony.mc.otm.capability.matter.PatternState +import ru.dbotthepony.mc.otm.capability.matter.ReplicationTask +import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.container.HandlerFilter -import ru.dbotthepony.mc.otm.graph.Graph6Node -import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode -import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph -import ru.dbotthepony.mc.otm.menu.matter.MatterReplicatorMenu -import ru.dbotthepony.mc.otm.registry.MBlockEntities -import ru.dbotthepony.mc.otm.registry.MNames -import ru.dbotthepony.mc.otm.core.util.WriteOnce +import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal @@ -33,7 +30,12 @@ import ru.dbotthepony.mc.otm.core.math.getDecimal import ru.dbotthepony.mc.otm.core.math.set import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.core.util.WriteOnce +import ru.dbotthepony.mc.otm.graph.matter.MatterNode import ru.dbotthepony.mc.otm.matter.MatterManager +import ru.dbotthepony.mc.otm.menu.matter.MatterReplicatorMenu +import ru.dbotthepony.mc.otm.registry.MBlockEntities +import ru.dbotthepony.mc.otm.registry.MNames class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryWorkerBlockEntity(MBlockEntities.MATTER_REPLICATOR, p_155229_, p_155230_, { @@ -42,7 +44,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } catch(err: NoSuchElementException) { null } - }), IMatterGraphNode { + }) { class ReplicatorJob : ItemJob { val matterPerTick: Decimal @@ -98,16 +100,39 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } val energy = WorkerEnergyStorage(this::powerLevelUpdated, ENERGY_VALUES) - override val matterNode = Graph6Node(this) val matter = MatterStorageImpl(this::matterLevelUpdated, FlowDirection.INPUT, ::MATTER_CAPACITY) val container = MatteryContainer(this::itemContainerUpdated, 5).also(::addDroppableContainer) val itemHandler = container.handler(HandlerFilter.OnlyOut) + val matterNode = object : MatterNode() { + override fun getMatterHandler(): IMatterStorage { + return matter + } + + override fun onMatterTaskCreated(task: IReplicationTask<*>) { + if (idleReason == IdleReason.OBSERVING) { + isIdling = false + } + } + + override fun > onMatterTaskUpdated(newState: T, oldState: T) { + if (idleReason == IdleReason.OBSERVING) { + isIdling = false + } + } + + override fun onPatternAdded(state: IPatternState) { + if (idleReason == IdleReason.OBSERVING) { + isIdling = false + } + } + } + init { exposeEnergyGlobally(energy) exposeItemsGlobally(itemHandler) exposeGlobally(MatteryCapability.MATTER, matter) - exposeGlobally(MatteryCapability.MATTER_NODE, this) + exposeGlobally(MatteryCapability.MATTER_NODE, matterNode) savetable(::energy, ENERGY_KEY) savetable(::matter, MATTER_STORAGE_KEY) @@ -126,7 +151,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return Status.FAILURE_WAIT } - (matterNode.graph as MatterNetworkGraph?)?.notifyTaskCompletion(job.task.id) + matterNode.graph.notifyTaskCompletion(job.task.id) return Status.SUCCESS } @@ -134,38 +159,18 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return Status.FAILURE_ITEM } - (matterNode.graph as MatterNetworkGraph?)?.notifyTaskCompletion(job.task.id) + matterNode.graph.notifyTaskCompletion(job.task.id) return Status.SUCCESS } - override fun onMatterTaskCreated(task: IReplicationTask<*>) { - if (idleReason == IdleReason.OBSERVING) { - isIdling = false - } - } - - override fun > onMatterTaskUpdated(newState: T, oldState: T) { - if (idleReason == IdleReason.OBSERVING) { - isIdling = false - } - } - - override fun onPatternAdded(state: IPatternState) { - if (idleReason == IdleReason.OBSERVING) { - isIdling = false - } - } - override fun setRemoved() { super.setRemoved() - matterNode.destroy(::MatterNetworkGraph) + matterNode.isValid = false } override fun setLevel(level: Level) { super.setLevel(level) - - if (level is ServerLevel) - MatterNetworkGraph.discoverFull(this, matterNode) + matterNode.discover(this) } override fun jobUpdated(oldJob: ReplicatorJob?, newJob: ReplicatorJob?) { @@ -176,7 +181,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : var visualItemStack by synchronizer.item(observe = false) private set - var visualProgress by synchronizer.float() + var visualProgress by synchronizer.float().property private set var renderRotation = 0f @@ -188,8 +193,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return null to IdleReason.POWER } - val graph = matterNode.graph as MatterNetworkGraph? ?: return null to null - val allocation = graph.allocateTask(simulate = false) ?: return null to IdleReason.OBSERVING + val allocation = matterNode.graph.allocateTask(simulate = false) ?: return null to IdleReason.OBSERVING val stack = allocation.task.stack(1) val matter = MatterManager.get(stack) @@ -211,7 +215,6 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : override fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: ReplicatorJob): Status { val drainPerTick = job.matterPerTick * ticksAdvanced - val graph = matterNode.graph as MatterNetworkGraph? ?: return Status.FAILURE_WAIT_FAST if (matter.extractMatterInner(drainPerTick, true) < drainPerTick) { // в машине недостаточно материи @@ -219,7 +222,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : if (drainPerTick > matter.maxStoredMatter) { // в тик требуется больше материи, чем её может хранить репликатор val toExtract = drainPerTick - matter.extractMatterInner(drainPerTick, true) - val drain = graph.extractMatter(toExtract, true) + val drain = matterNode.graph.extractMatter(toExtract, true) if (drain != toExtract) { // недостаточно материи в сети @@ -228,12 +231,12 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : // достаточно материи в сети + внутри машины matter.extractMatterInner(drainPerTick, false) - graph.extractMatter(drain, false) + matterNode.graph.extractMatter(drain, false) return Status.SUCCESS } else { // в тик требуется меньше материи, чем её может хранить репликатор // примем из сети недостающее количество бака материи, или 200 тиков репликации, что меньше - val drain = graph.extractMatter((drainPerTick * DRAIN_MULT) + val drain = matterNode.graph.extractMatter((drainPerTick * DRAIN_MULT) .coerceAtMost(job.matterPerTick * (job.ticks - workTicks - ticksAdvanced)) .coerceAtLeast(Decimal.ONE) .coerceAtMost(matter.missingMatter), false) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt index 2d31a57fb..93b068c2d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt @@ -22,18 +22,18 @@ import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.graph.Graph6Node -import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode -import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph +import ru.dbotthepony.mc.otm.graph.matter.MatterGraph import ru.dbotthepony.mc.otm.menu.matter.MatterScannerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.core.util.WriteOnce +import ru.dbotthepony.mc.otm.graph.matter.MatterNode import ru.dbotthepony.mc.otm.matter.MatterManager import java.util.* import kotlin.math.pow class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : - MatteryWorkerBlockEntity(MBlockEntities.MATTER_SCANNER, p_155229_, p_155230_, ::ItemJob), IMatterGraphNode { + MatteryWorkerBlockEntity(MBlockEntities.MATTER_SCANNER, p_155229_, p_155230_, ::ItemJob) { val container = MatteryContainer(this::itemContainerUpdated, 1).also(::addDroppableContainer) val energy = WorkerEnergyStorage(this::powerLevelUpdated, ENERGY_VALUES) @@ -47,45 +47,43 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } }) + val matterNode = object : MatterNode() { + override fun onPatternAdded(state: IPatternState) { + if (idleReason == IdleReason.OBSERVING) { + isIdling = false + } + } + + override fun onPatternRemoved(state: IPatternState) { + if (idleReason == IdleReason.OBSERVING) { + isIdling = false + } + } + + override fun onPatternUpdated(newState: IPatternState, oldState: IPatternState) { + if (idleReason == IdleReason.OBSERVING) { + isIdling = false + } + } + } + init { exposeItemsGlobally(itemHandler) exposeEnergyGlobally(energy) - exposeGlobally(MatteryCapability.MATTER_NODE, this) + exposeGlobally(MatteryCapability.MATTER_NODE, matterNode) savetable(::container, INVENTORY_KEY) savetable(::energy, ENERGY_KEY) } - // IMatterGraphNode - override fun onPatternAdded(state: IPatternState) { - if (idleReason == IdleReason.OBSERVING) { - isIdling = false - } - } - - override fun onPatternRemoved(state: IPatternState) { - if (idleReason == IdleReason.OBSERVING) { - isIdling = false - } - } - - override fun onPatternUpdated(newState: IPatternState, oldState: IPatternState) { - if (idleReason == IdleReason.OBSERVING) { - isIdling = false - } - } - // /IMatterGraphNode - - override val matterNode: Graph6Node = Graph6Node(this) - override fun invalidateCaps() { super.invalidateCaps() - matterNode.destroy(::MatterNetworkGraph) + matterNode.isValid = false } override fun setRemoved() { super.setRemoved() - matterNode.destroy(::MatterNetworkGraph) + matterNode.isValid = false } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { @@ -93,14 +91,12 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } override fun onJobFinish(job: ItemJob): Status { - val grid = matterNode.graph as MatterNetworkGraph? ?: return Status.FAILURE_WAIT - val stack = job.itemStack if (stack.isEmpty || !MatterManager.hasMatterValue(stack)) return Status.SUCCESS var findState: IPatternState? = null - for (state in grid.patterns.filter { it.item === stack.item }) { + for (state in matterNode.graph.patterns.filter { it.item === stack.item }) { if (findState == null && state.researchPercent < 1.0) { findState = state } else if (findState != null && findState.researchPercent < state.researchPercent && state.researchPercent < 1.0) { @@ -117,7 +113,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : PatternState(UUID.randomUUID(), stack.item, researchAdvance) } - if (!grid.insertPattern(new, onlyUpdate = false, simulate = false).isFailed) { + if (!matterNode.graph.insertPattern(new, onlyUpdate = false, simulate = false).isFailed) { return Status.SUCCESS } else { return Status.FAILURE_WAIT @@ -129,14 +125,12 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return null to IdleReason.POWER } - val grid = matterNode.graph as MatterNetworkGraph? ?: return null to null - val stack = container.getItem(0) if (stack.isEmpty || !MatterManager.canDecompose(stack)) return null to IdleReason.ITEM var findState: IPatternState? = null - for (state in grid.patterns.filter { it.item === stack.item }) { + for (state in matterNode.graph.patterns.filter { it.item === stack.item }) { if (state.researchPercent < 1.0) { findState = state } else if (state.researchPercent >= 1.0) { @@ -155,7 +149,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : PatternState(UUID.randomUUID(), stack.item, researchAdvance) } - if (!grid.insertPattern(new, onlyUpdate = false, simulate = true).isFailed) { + if (!matterNode.graph.insertPattern(new, onlyUpdate = false, simulate = true).isFailed) { val copy = stack.copy().also { it.count = 1 } stack.shrink(1) container.setChanged() @@ -168,10 +162,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : override fun setLevel(level: Level) { super.setLevel(level) - - if (level is ServerLevel) { - MatterNetworkGraph.discoverFull(this, matterNode) - } + matterNode.discover(this) } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt index fd6cbf42a..36c49590d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt @@ -20,8 +20,8 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.matter.* import ru.dbotthepony.mc.otm.core.collect.iterator import ru.dbotthepony.mc.otm.graph.Graph6Node -import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphNode -import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph +import ru.dbotthepony.mc.otm.graph.matter.MatterGraph +import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode import ru.dbotthepony.mc.otm.registry.MBlockEntities import java.util.ArrayList import java.util.stream.Stream @@ -29,24 +29,22 @@ import java.util.stream.Stream @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : - MatteryDeviceBlockEntity(MBlockEntities.PATTERN_STORAGE, p_155229_, p_155230_), IMatterGraphNode, IPatternStorage { + MatteryDeviceBlockEntity(MBlockEntities.PATTERN_STORAGE, p_155229_, p_155230_), IPatternStorage { - override val matterNode = Graph6Node(this) + val matterNode = SimpleMatterNode(patterns = this) val container: MatteryContainer = object : MatteryContainer(this::setChanged, 8) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { - val grid = matterNode.graph as MatterNetworkGraph? - - if (grid != null && !ItemStack.isSameItemSameTags(new, old)) { + if (!ItemStack.isSameItemSameTags(new, old)) { if (!old.isEmpty) { old.getCapability(MatteryCapability.PATTERN).ifPresent { cap: IPatternStorage -> - cap.patterns.forEach { grid.onPatternRemoved(it) } + cap.patterns.forEach { matterNode.graph.onPatternRemoved(it) } } } if (!new.isEmpty) { new.getCapability(MatteryCapability.PATTERN).ifPresent { cap: IPatternStorage -> - cap.patterns.forEach { grid.onPatternAdded(it) } + cap.patterns.forEach { matterNode.graph.onPatternAdded(it) } } } @@ -82,23 +80,17 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : override fun setLevel(level: Level) { super.setLevel(level) - - if (level is ServerLevel) - MatterNetworkGraph.discoverFull(this, matterNode) - } - - override fun getPatternHandler(): IPatternStorage { - return this + matterNode.discover(this) } override fun invalidateCaps() { super.invalidateCaps() - matterNode.destroy(::MatterNetworkGraph) + matterNode.isValid = false } init { exposeGlobally(MatteryCapability.PATTERN, this) - exposeGlobally(MatteryCapability.MATTER_NODE, this) + exposeGlobally(MatteryCapability.MATTER_NODE, matterNode) exposeItemsGlobally(itemHandler) savetable(::container, INVENTORY_KEY) @@ -138,7 +130,7 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : override fun setRemoved() { super.setRemoved() - matterNode.destroy(::MatterNetworkGraph) + matterNode.isValid = false } override fun insertPattern(pattern: IPatternState, onlyUpdate: Boolean, simulate: Boolean): PatternInsertStatus { @@ -149,14 +141,10 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : if (!simulate) { setChanged() - val graph = matterNode.graph as MatterNetworkGraph? - - if (graph != null) { - if (status.isInserted) { - graph.onPatternAdded(status.newState!!) - } else { - graph.onPatternUpdated(status.newState!!, status.oldState!!) - } + if (status.isInserted) { + matterNode.graph.onPatternAdded(status.newState!!) + } else { + matterNode.graph.onPatternUpdated(status.newState!!, status.oldState!!) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt index caba91cdf..8f8405bab 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt @@ -9,13 +9,13 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity -import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode +import ru.dbotthepony.mc.otm.graph.storage.StorageNode import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.menu.storage.DriveRackMenu -import ru.dbotthepony.mc.otm.graph.storage.StorageNetworkGraph +import ru.dbotthepony.mc.otm.graph.storage.StorageGraph import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.storage.* @@ -41,7 +41,7 @@ class DriveRackBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } }.also(::addDroppableContainer) - val cell = BasicStorageGraphNode(energy) + val cell = StorageNode(energy) init { savetable(::energy, ENERGY_KEY) @@ -52,9 +52,7 @@ class DriveRackBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : override fun setLevel(level: Level) { super.setLevel(level) - - if (level is ServerLevel) - StorageNetworkGraph.discoverFull(this, cell.storageNode) + cell.discover(this) } override fun tick() { @@ -68,6 +66,6 @@ class DriveRackBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : override fun setRemoved() { super.setRemoved() - cell.destroy(level) + cell.isValid = false } } 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 e19cee385..b24bde36f 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 @@ -30,8 +30,8 @@ import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.get -import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode -import ru.dbotthepony.mc.otm.graph.storage.StorageNetworkGraph +import ru.dbotthepony.mc.otm.graph.storage.StorageNode +import ru.dbotthepony.mc.otm.graph.storage.StorageGraph import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.container.set @@ -188,13 +188,13 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : var poweredView: PoweredVirtualComponent? = null private set - val cell = object : BasicStorageGraphNode(energy) { - override fun attachComponents(to: StorageNetworkGraph) { + val cell = object : StorageNode(energy) { + override fun attachComponents(to: StorageGraph) { super.attachComponents(to) poweredView = PoweredVirtualComponent(to.getVirtualComponent(ITEM_STORAGE), energy) } - override fun removeComponents(from: StorageNetworkGraph) { + override fun removeComponents(from: StorageGraph) { super.removeComponents(from) poweredView?.removeListeners() poweredView = null @@ -499,13 +499,11 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : override fun setLevel(level: Level) { super.setLevel(level) - - if (level is ServerLevel) - StorageNetworkGraph.discoverFull(this, cell.storageNode) + cell.discover(this) } override fun setRemoved() { super.setRemoved() - cell.destroy(level) + cell.isValid = false } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt index c11ce88fa..4ae09678d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt @@ -4,8 +4,6 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectAVLTreeMap import it.unimi.dsi.fastutil.ints.IntAVLTreeSet import net.minecraft.core.BlockPos import net.minecraft.core.Direction -import net.minecraft.network.chat.Component -import net.minecraft.server.level.ServerLevel import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu @@ -31,21 +29,14 @@ import ru.dbotthepony.mc.otm.core.math.getCapability import ru.dbotthepony.mc.otm.core.math.isPositive import ru.dbotthepony.mc.otm.core.math.isZero import ru.dbotthepony.mc.otm.core.math.plus -import ru.dbotthepony.mc.otm.graph.Graph6Node -import ru.dbotthepony.mc.otm.graph.GraphNodeListener -import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode -import ru.dbotthepony.mc.otm.graph.storage.StorageNetworkGraph +import ru.dbotthepony.mc.otm.graph.storage.StorageNode import ru.dbotthepony.mc.otm.menu.storage.StorageBusMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities -import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.storage.* import java.lang.ref.WeakReference import java.math.BigInteger import java.util.* import java.util.stream.Stream -import kotlin.NoSuchElementException -import kotlin.collections.ArrayList -import kotlin.collections.HashMap private class SlotTuple(val slot: Int, val stack: ItemStack) private class TrackedTuple(override val stack: ItemStackWrapper, override val id: UUID) : IStorageTuple { @@ -77,15 +68,15 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter savetable(::energy, ENERGY_KEY) } - val cell: BasicStorageGraphNode = object : BasicStorageGraphNode(energy), GraphNodeListener { - override fun onNeighbour(node: Graph6Node<*>, direction: Direction) { + val cell: StorageNode = object : StorageNode(energy) { + override fun onNeighbour(direction: Direction) { val newState = this@StorageBusBlockEntity.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, true) if (newState !== this@StorageBusBlockEntity.blockState && SERVER_IS_LIVE) level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) } - override fun onUnNeighbour(node: Graph6Node<*>, direction: Direction) { + override fun onUnNeighbour(direction: Direction) { val newState = this@StorageBusBlockEntity.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, false) if (newState !== this@StorageBusBlockEntity.blockState && SERVER_IS_LIVE) @@ -109,11 +100,7 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter override fun setLevel(level: Level) { super.setLevel(level) - - if (level is ServerLevel) { - StorageNetworkGraph.discoverFull(this, cell.storageNode) - } - + cell.discover(this) tickList.once(this::checkSurroundings) } @@ -128,7 +115,7 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter override fun setRemoved() { super.setRemoved() - cell.destroy(level) + cell.isValid = false } fun checkSurroundings() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt index ec4d9b8b9..a37b4b10e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt @@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.block.entity.storage import net.minecraft.core.BlockPos import net.minecraft.core.Direction import net.minecraft.network.chat.Component -import net.minecraft.server.level.ServerLevel import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu @@ -26,14 +25,10 @@ import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.core.math.toIntSafe import ru.dbotthepony.mc.otm.core.orNull -import ru.dbotthepony.mc.otm.graph.Graph6Node -import ru.dbotthepony.mc.otm.graph.GraphNodeListener -import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode -import ru.dbotthepony.mc.otm.graph.storage.StorageNetworkGraph +import ru.dbotthepony.mc.otm.graph.storage.StorageNode import ru.dbotthepony.mc.otm.menu.storage.StorageExporterMenu import ru.dbotthepony.mc.otm.menu.storage.StorageImporterMenu import ru.dbotthepony.mc.otm.once @@ -62,8 +57,8 @@ abstract class AbstractStorageImportExport( savetable(::energy, ENERGY_KEY) } - val cell: BasicStorageGraphNode = object : BasicStorageGraphNode(energy), GraphNodeListener { - override fun onNeighbour(node: Graph6Node<*>, direction: Direction) { + val cell: StorageNode = object : StorageNode(energy) { + override fun onNeighbour(direction: Direction) { level?.once { if (!isRemoved) { val newState = this@AbstractStorageImportExport.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, true) @@ -74,7 +69,7 @@ abstract class AbstractStorageImportExport( } } - override fun onUnNeighbour(node: Graph6Node<*>, direction: Direction) { + override fun onUnNeighbour(direction: Direction) { level?.once { if (!isRemoved) { val newState = this@AbstractStorageImportExport.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, false) @@ -93,15 +88,12 @@ abstract class AbstractStorageImportExport( override fun setRemoved() { super.setRemoved() - cell.destroy(level) + cell.isValid = false } override fun setLevel(level: Level) { super.setLevel(level) - - if (level is ServerLevel) { - StorageNetworkGraph.discoverFull(this, cell.storageNode) - } + cell.discover(this) } protected abstract val targetCapability: Capability @@ -117,7 +109,6 @@ abstract class AbstractStorageImportExport( } companion object { - val MAX_POWER = Decimal(10_000) const val FILTER_KEY = "filter" } } @@ -155,7 +146,7 @@ class StorageImporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : A if (redstoneControl.isBlockedByRedstone || !filter.match(stack)) return stack - val view = cell.storageGraph?.getVirtualComponent(ITEM_STORAGE) ?: return stack + val view = cell.graph.getVirtualComponent(ITEM_STORAGE) val maxMove = energy.extractEnergyExact(ITEM_STORAGE.energyPerOperation, stack.count.toBigInteger(), true) if (maxMove == BigInteger.ZERO) @@ -195,8 +186,7 @@ class StorageImporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : A val target = target.get().orNull() if (nextTick <= 0 && target != null && enoughEnergy) { - val graph = cell.storageGraph ?: return - val items = graph.getVirtualComponent(ITEM_STORAGE) + val items = cell.graph.getVirtualComponent(ITEM_STORAGE) if (lastSlot >= target.slots) { lastSlot = 0 @@ -227,7 +217,6 @@ class StorageImporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : A companion object { const val MAX_MOVE_PER_OPERATION = 4 - private val MACHINE_NAME = TranslatableComponent("block.${OverdriveThatMatters.MOD_ID}.${MNames.STORAGE_IMPORTER}") private const val INTERVAL = 5 const val MAX_FILTERS = 6 * 3 } @@ -271,7 +260,7 @@ class StorageExporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : override val filter = ItemFilter(MAX_FILTERS) { _, _, _ -> relevantTuples.clear() - val component = cell.storageGraph?.getVirtualComponent(ITEM_STORAGE) ?: return@ItemFilter + val component = cell.graph.getVirtualComponent(ITEM_STORAGE) for (tuple in component.stacks) { addStack(tuple, component) @@ -291,7 +280,7 @@ class StorageExporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : private val exportStacks: Stream> get() { - val view = cell.storageGraph?.getVirtualComponent(ITEM_STORAGE) ?: return Stream.empty() + val view = cell.graph.getVirtualComponent(ITEM_STORAGE) return relevantTuples.stream().map { it to view[it] } } @@ -308,8 +297,7 @@ class StorageExporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : val target = target.get().orNull() if (nextTick <= 0 && target != null && enoughEnergy) { - val graph = cell.storageGraph ?: return - val items = graph.getVirtualComponent(ITEM_STORAGE) + val items = cell.graph.getVirtualComponent(ITEM_STORAGE) if (lastSlot >= target.slots) { lastSlot = 0 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt index fa0dbb017..61c395979 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt @@ -13,8 +13,8 @@ import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.transferChecked import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode -import ru.dbotthepony.mc.otm.graph.storage.StorageNetworkGraph +import ru.dbotthepony.mc.otm.graph.storage.StorageNode +import ru.dbotthepony.mc.otm.graph.storage.StorageGraph import ru.dbotthepony.mc.otm.menu.storage.StoragePowerSupplierMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -23,7 +23,7 @@ class StoragePowerSupplierBlockEntity(blockPos: BlockPos, blockState: BlockState return StoragePowerSupplierMenu(containerID, inventory, this) } - val cell = BasicStorageGraphNode() + val cell = StorageNode() val energy = WorkerEnergyStorage(this, MachinesConfig.STORAGE_POWER_SUPPLIER) init { @@ -42,15 +42,12 @@ class StoragePowerSupplierBlockEntity(blockPos: BlockPos, blockState: BlockState override fun setLevel(level: Level) { super.setLevel(level) - - if (level is ServerLevel) { - StorageNetworkGraph.discoverFull(this, cell.storageNode) - } + cell.discover(this) } override fun setRemoved() { super.setRemoved() - cell.destroy(level) + cell.isValid = false } override fun tick() { @@ -62,9 +59,7 @@ class StoragePowerSupplierBlockEntity(blockPos: BlockPos, blockState: BlockState if (energy.batteryLevel.isZero) return - val graph = cell.storageGraph ?: return - - if (graph.powerDemandingNodes.isEmpty()) + if (cell.graph.powerDemandingNodes.isEmpty()) return var demand = Decimal.ZERO @@ -72,7 +67,7 @@ class StoragePowerSupplierBlockEntity(blockPos: BlockPos, blockState: BlockState val available = energy.batteryLevel.coerceAtMost(MachinesConfig.STORAGE_POWER_SUPPLIER.throughput) - for (demanding in graph.powerDemandingNodes) { + for (demanding in cell.graph.powerDemandingNodes) { val received = demanding.receiveEnergy(available, true) if (received.isPositive) { @@ -84,13 +79,13 @@ class StoragePowerSupplierBlockEntity(blockPos: BlockPos, blockState: BlockState if (demand.isZero) { return } else if (demand < available) { - for (demanding in graph.powerDemandingNodes) { + for (demanding in cell.graph.powerDemandingNodes) { powerPassed += energy.transferChecked(demanding, available, false) } } else { val forEach = available / i - for (demanding in graph.powerDemandingNodes) { + for (demanding in cell.graph.powerDemandingNodes) { powerPassed += energy.transferChecked(demanding, forEach, false) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/QIO.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/QIO.kt index 5556f0819..b63a601e7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/QIO.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/QIO.kt @@ -21,8 +21,9 @@ import ru.dbotthepony.mc.otm.onceServer import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.isMekanismLoaded import ru.dbotthepony.mc.otm.core.math.isPositive -import ru.dbotthepony.mc.otm.graph.storage.BasicStorageGraphNode -import ru.dbotthepony.mc.otm.graph.storage.StorageNetworkGraph +import ru.dbotthepony.mc.otm.core.util.LOHolder +import ru.dbotthepony.mc.otm.graph.storage.StorageNode +import ru.dbotthepony.mc.otm.graph.storage.StorageGraph import ru.dbotthepony.mc.otm.storage.* import java.math.BigInteger import java.util.UUID @@ -206,14 +207,14 @@ private class QIOStorage(private val tile: TileEntityQIODriveArray) : ICapabilit private var frequencyAccess: QIOFrequencyAccess? = null private var wasAttached = false - val cell: BasicStorageGraphNode = object : BasicStorageGraphNode(), ITickable { + val cell: StorageNode = object : StorageNode(), ITickable { init { manualAttaching = true } override fun tick() { if (tile.isRemoved) { - destroy(tile.level) + isValid = false return } @@ -225,9 +226,7 @@ private class QIOStorage(private val tile: TileEntityQIODriveArray) : ICapabilit val lastFrequency = lastFrequency ?: throw IllegalStateException("lastFrequency is null") - checkNotNull(storageGraph) { - "Unexpected internal state (expected storage graph to be present, something detached $this from storage grid, but did not call removeComponents())" - }.userData.remove(key(lastFrequency)) + graph.userData.remove(key(lastFrequency)) } frequencyAccess?.let(this::removeStorageComponent) @@ -240,17 +239,16 @@ private class QIOStorage(private val tile: TileEntityQIODriveArray) : ICapabilit val frequencyAccess = frequencyAccess ?: return frequencyAccess.scan() - val storageGraph = storageGraph ?: return val key = key(frequencyAccess.parent) - if (!storageGraph.userData.containsKey(key)) { - storageGraph.userData[key] = true + if (!graph.userData.containsKey(key)) { + graph.userData[key] = true wasAttached = true - storageGraph.add(frequencyAccess) + graph.add(frequencyAccess) } } - override fun removeComponents(from: StorageNetworkGraph) { + override fun removeComponents(from: StorageGraph) { super.removeComponents(from) if (wasAttached) { @@ -259,11 +257,23 @@ private class QIOStorage(private val tile: TileEntityQIODriveArray) : ICapabilit wasAttached = false } } + + override fun invalidate() { + super.invalidate() + holder.invalidate() + } + + override fun revive() { + super.revive() + holder.revive() + } } + private val holder = LOHolder(cell) + override fun getCapability(cap: Capability, side: Direction?): LazyOptional { if (cap === MatteryCapability.STORAGE_NODE) - return cell.get().cast() + return holder.get() return LazyOptional.empty() } @@ -286,8 +296,8 @@ fun attachCapabilities(event: AttachCapabilitiesEvent) { event.addCapability(QIO_LOCATION, capability) onceServer { - if (!event.`object`.isRemoved && event.`object`.level?.isClientSide == false) { - StorageNetworkGraph.discoverFull(event.`object`, capability.cell.storageNode) + if (!event.`object`.isRemoved) { + capability.cell.discover(event.`object`, MatteryCapability.STORAGE_NODE) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/LOHolder.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/LOHolder.kt new file mode 100644 index 000000000..289c1785f --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/LOHolder.kt @@ -0,0 +1,20 @@ +package ru.dbotthepony.mc.otm.core.util + +import net.minecraftforge.common.util.LazyOptional + +class LOHolder(val value: T) { + private var lazyOptional: LazyOptional = LazyOptional.of { value } + + fun invalidate() { + lazyOptional.invalidate() + } + + fun revive() { + lazyOptional.invalidate() + lazyOptional = LazyOptional.of { value } + } + + fun get(): LazyOptional { + return lazyOptional.cast() + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Abstract6Graph.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Abstract6Graph.kt index 4a7b15557..6999a110e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Abstract6Graph.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Abstract6Graph.kt @@ -1,178 +1,172 @@ package ru.dbotthepony.mc.otm.graph -import net.minecraft.core.BlockPos -import net.minecraft.core.Direction -import net.minecraft.core.SectionPos -import net.minecraft.server.level.ServerLevel -import net.minecraft.world.level.block.entity.BlockEntity import ru.dbotthepony.mc.otm.core.util.IConditionalTickable -import ru.dbotthepony.mc.otm.core.math.plus -import ru.dbotthepony.mc.otm.addTicker +import ru.dbotthepony.mc.otm.core.util.ITickable +import java.lang.ref.WeakReference import java.util.* import kotlin.collections.ArrayList -import kotlin.collections.HashMap -abstract class Abstract6Graph : IConditionalTickable { - protected val nodes = ArrayList>() - fun size() = nodes.size - private val tickable = ArrayList>() - val nodeList: Collection> = Collections.unmodifiableCollection(nodes) +open class Abstract6Graph, G : Abstract6Graph> : IConditionalTickable { + private val nodesInternal = ArrayList() + private val conditional = ArrayList() + private val always = ArrayList() + + protected val nodes: List = Collections.unmodifiableList(nodesInternal) + + val size get() = nodesInternal.size + + var isMerged = false + private set + + private var isTicking = false /** * Allows storing arbitrary data by external code */ - @JvmField val userData = HashMap() - abstract fun onNodeRemoved(node: Graph6Node) - abstract fun onNodeAdded(node: Graph6Node) + open fun onNodeRemoved(node: N) {} + open fun onNodeAdded(node: N) {} + open fun onMergedInto(other: G) {} - override fun tick(): Boolean { - for (i in tickable.size - 1 downTo 0) { - val node = tickable[i] + protected open fun innerTick(): Boolean { + return false + } + + final override fun tick(): Boolean { + if (isMerged) + return false + + // позволяет вершинам изменять список тикающих вершин + for (i in conditional.size - 1 downTo 0) { + val node = conditional[i] if (!node.tick()) { - tickable.removeAt(i) + conditional.removeAt(i) } } - return nodes.size > 0 + // позволяет вершинам изменять список тикающих вершин + for (node in always.size - 1 downTo 0) { + always[node].tick() + } + + return innerTick() || always.isNotEmpty() || conditional.isNotEmpty() } - fun removeNode(node: Graph6Node) { - if (!nodes.remove(node)) - throw IllegalStateException("Not containing node $node") + fun addNode(node: N): Boolean { + if (node in nodesInternal) + return false - node.graph = null - onNodeRemoved(node) - tickable.remove(node) - } + nodesInternal.add(node) - fun addNode(node: Graph6Node) { - if (nodes.contains(node)) - throw IllegalStateException("Already containing node $node") + if (node is IConditionalTickable) { + conditional.add(node) + + if (!isTicking) { + isTicking = true + next.add(WeakReference(this)) + } + } else if (node is ITickable) { + always.add(node) + + if (!isTicking) { + isTicking = true + next.add(WeakReference(this)) + } + } - nodes.add(node) - node.graph = this onNodeAdded(node) - tickable.add(node) + return true } - fun merge(other: Abstract6Graph): Abstract6Graph { + fun removeNode(node: N): Boolean { + if (!nodesInternal.remove(node)) + return false + + nodesInternal.remove(node) + + if (node is IConditionalTickable) + conditional.remove(node) + else if (node is ITickable) + always.remove(node) + + onNodeRemoved(node) + return true + } + + fun retain(nodes: Set) { + for (i in this.nodesInternal.size - 1 downTo 0) { + if (this.nodesInternal[i] !in nodes) { + val node = this.nodesInternal[i] + + this.nodesInternal.removeAt(i) + + if (node is IConditionalTickable) + conditional.remove(node) + else if (node is ITickable) + always.remove(node) + + onNodeRemoved(node) + } + } + } + + fun merge(other: G, setter: (N, G) -> Unit): G { if (other === this) return this - if (size() >= other.size()) { - for (node in other.nodes) { - nodes.add(node) - node.graph = this + if (size >= other.size) { + for (node in other.nodesInternal) { + nodesInternal.add(node) + setter.invoke(node, this as G) onNodeAdded(node) + + if (node is IConditionalTickable) { + conditional.add(node) + + if (!isTicking) { + isTicking = true + next.add(WeakReference(this)) + } + } else if (node is ITickable) { + always.add(node) + + if (!isTicking) { + isTicking = true + next.add(WeakReference(this)) + } + } } + other.isMerged = true + other.onMergedInto(this as G) return this } else { - return other.merge(this) + return other.merge(this as G, setter) } } companion object { - fun discoverFull( - level: ServerLevel, - blockPos: BlockPos, - node: Graph6Node, - nodeGetter: (BlockEntity) -> Graph6Node?, - factory: () -> Abstract6Graph - ) { - level.addTicker { - !discover(level, blockPos, node, nodeGetter, factory) && node.valid - } - } + private val graphs = ArrayList>>() + private val next = ArrayList>>() - @JvmStatic - fun discover( - level: ServerLevel, - blockPos: BlockPos, - node: Graph6Node, - nodeGetter: (BlockEntity) -> Graph6Node?, - factory: () -> Abstract6Graph - ): Boolean { - var fullDiscovery = true - - node.nullifyConnections() - - var _graph = node.graph - - // для начала найдем граф к которому будем принадлежать - if (_graph == null) { - for (dir in Direction.values()) { - val offset = blockPos + dir - val chunk = level.chunkSource.getChunkNow(SectionPos.blockToSectionCoord(offset.x), SectionPos.blockToSectionCoord(offset.z)) - - if (chunk == null) { - fullDiscovery = false - continue - } - - val entity = chunk.getBlockEntity(offset) - - if (entity != null) { - val getNode = nodeGetter(entity) - - if (getNode?.graph != null) { - _graph = getNode.graph - break - } - } - } - - // мы нашли граф рядом - if (_graph != null) { - node.graph = _graph - _graph.addNode(node) - } else { - // графов рядом нет, создаем свой - _graph = factory() - node.graph = _graph - _graph.addNode(node) - } + fun tick() { + if (next.isNotEmpty()) { + graphs.addAll(next) + next.clear() } - // теперь снова смотрим на соседей, если у них нет графа - присоединяем к своему - // если у них есть граф - слияем его со своим или свой с его - for (dir in Direction.values()) { - val offset = blockPos + dir - val chunk = level.chunkSource.getChunkNow(SectionPos.blockToSectionCoord(offset.x), SectionPos.blockToSectionCoord(offset.z)) + val iterator = graphs.iterator() - if (chunk == null) { - fullDiscovery = false - continue - } + for (value in iterator) { + val graph = value.get() - val entity = chunk.getBlockEntity(offset) - - if (entity != null) { - val getNode = nodeGetter(entity) - - if (getNode != null) { - // у вершины нет своего графа - // добавляем в свой граф - if (getNode.graph == null) { - getNode.graph = node.graph!! - node.graph!!.addNode(getNode) - } else if (getNode.graph != node.graph) { - // у вершины уже есть свой граф, и он не наш - // произведём слияние графов - val merged = getNode.graph!!.merge(node.graph!!) - getNode.graph = merged - node.graph = merged - } - - node.setToNeightbour(getNode, dir) - } + if (graph == null || !graph.tick()) { + graph?.isTicking = false + iterator.remove() } } - - return fullDiscovery } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Graph6Node.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Graph6Node.kt index 2ca4c3e02..9c0ff9ebe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Graph6Node.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Graph6Node.kt @@ -1,313 +1,268 @@ package ru.dbotthepony.mc.otm.graph +import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet +import net.minecraft.core.BlockPos import net.minecraft.core.Direction -import ru.dbotthepony.mc.otm.core.util.IConditionalTickable -import ru.dbotthepony.mc.otm.core.util.ITickable -import ru.dbotthepony.mc.otm.SERVER_IS_LIVE +import net.minecraft.core.SectionPos +import net.minecraft.server.level.ServerLevel +import net.minecraft.world.level.block.entity.BlockEntity +import net.minecraftforge.common.capabilities.Capability +import ru.dbotthepony.mc.otm.addTicker +import ru.dbotthepony.mc.otm.core.math.plus +import ru.dbotthepony.mc.otm.core.math.unaryMinus +import ru.dbotthepony.mc.otm.core.orNull +import java.util.EnumMap +import java.util.concurrent.atomic.AtomicInteger -interface GraphNodeListener { - fun onNeighbourTop(node: Graph6Node<*>) = onNeighbour(node, Direction.UP) - fun onNeighbourBottom(node: Graph6Node<*>) = onNeighbour(node, Direction.DOWN) - fun onNeighbourLeft(node: Graph6Node<*>) = onNeighbour(node, Direction.WEST) - fun onNeighbourRight(node: Graph6Node<*>) = onNeighbour(node, Direction.EAST) - fun onNeighbourFront(node: Graph6Node<*>) = onNeighbour(node, Direction.SOUTH) - fun onNeighbourBack(node: Graph6Node<*>) = onNeighbour(node, Direction.NORTH) +open class Graph6Node, G : Abstract6Graph>(val graphFactory: () -> G) { + private val neighbours = EnumMap(Direction::class.java) - fun onNeighbour(node: Graph6Node<*>, direction: Direction) - - fun onUnNeighbourTop(node: Graph6Node<*>) = onUnNeighbour(node, Direction.UP) - fun onUnNeighbourBottom(node: Graph6Node<*>) = onUnNeighbour(node, Direction.DOWN) - fun onUnNeighbourLeft(node: Graph6Node<*>) = onUnNeighbour(node, Direction.WEST) - fun onUnNeighbourRight(node: Graph6Node<*>) = onUnNeighbour(node, Direction.EAST) - fun onUnNeighbourFront(node: Graph6Node<*>) = onUnNeighbour(node, Direction.SOUTH) - fun onUnNeighbourBack(node: Graph6Node<*>) = onUnNeighbour(node, Direction.NORTH) - - fun onUnNeighbour(node: Graph6Node<*>, direction: Direction) -} - -// Вершина графа, содержит то, к какому графу принадлежит, соседей и своё "значение" -class Graph6Node(@JvmField val value: T, graph: Abstract6Graph? = null) : IConditionalTickable { - var graph: Abstract6Graph? = null - - init { - this.graph = graph - } - - var top: Graph6Node? = null - set(value) { - if (value != null && (graph == null || value.graph !== graph)) throw IllegalStateException("Can not be neighbour with node from different graph") - - if (field != value && this.value is GraphNodeListener) { - if (field != null) { - this.value.onUnNeighbourTop(field!!) - } - - if (value != null) { - this.value.onNeighbourTop(value) - } - } - - field = value - } - - var bottom: Graph6Node? = null - set(value) { - if (value != null && (graph == null || value.graph !== graph)) throw IllegalStateException("Can not be neighbour with node from different graph") - - if (field != value && this.value is GraphNodeListener) { - if (field != null) { - this.value.onUnNeighbourBottom(field!!) - } - - if (value != null) { - this.value.onNeighbourBottom(value) - } - } - - field = value - } - - var left: Graph6Node? = null - set(value) { - if (value != null && (graph == null || value.graph !== graph)) throw IllegalStateException("Can not be neighbour with node from different graph") - - if (field != value && this.value is GraphNodeListener) { - if (field != null) { - this.value.onUnNeighbourLeft(field!!) - } - - if (value != null) { - this.value.onNeighbourLeft(value) - } - } - - field = value - } - - var right: Graph6Node? = null - set(value) { - if (value != null && (graph == null || value.graph !== graph)) throw IllegalStateException("Can not be neighbour with node from different graph") - - if (field != value && this.value is GraphNodeListener) { - if (field != null) { - this.value.onUnNeighbourRight(field!!) - } - - if (value != null) { - this.value.onNeighbourRight(value) - } - } - - field = value - } - - var front: Graph6Node? = null - set(value) { - if (value != null && (graph == null || value.graph !== graph)) throw IllegalStateException("Can not be neighbour with node from different graph") - - if (field != value && this.value is GraphNodeListener) { - if (field != null) { - this.value.onUnNeighbourFront(field!!) - } - - if (value != null) { - this.value.onNeighbourFront(value) - } - } - - field = value - } - - var back: Graph6Node? = null - set(value) { - if (value != null && (graph == null || value.graph !== graph)) throw IllegalStateException("Can not be neighbour with node from different graph") - - if (field != value && this.value is GraphNodeListener) { - if (field != null) { - this.value.onUnNeighbourBack(field!!) - } - - if (value != null) { - this.value.onNeighbourBack(value) - } - } - - field = value - } - - fun nullifyConnections() { - top?.bottom = null - bottom?.top = null - left?.right = null - right?.left = null - front?.back = null - back?.front = null - - top = null - bottom = null - left = null - right = null - front = null - back = null - } - - fun setToNeightbour(node: Graph6Node, direction: Direction) { - when (direction) { - Direction.DOWN -> { - node.top = this - bottom = node - } - - Direction.UP -> { - node.bottom = this - top = node - } - - Direction.NORTH -> { - node.front = this - back = node - } - - Direction.SOUTH -> { - node.back = this - front = node - } - - Direction.WEST -> { - node.right = this - left = node - } - - Direction.EAST -> { - node.left = this - right = node - } - } - } - - override fun tick(): Boolean { - if (value is IConditionalTickable) { - return value.tick() - } else if (value is ITickable) { - value.tick() - return true - } else { - return false - } - } - - var seen: Int = 0 - - private fun _flood(): List> { - val list = ArrayList>() - var seen = Int.MAX_VALUE - - GraphFlooder.floodIf(top, seen) { - seen = it.seen - list.add(it) - } - - GraphFlooder.floodIf(bottom, seen) { - seen = it.seen - list.add(it) - } - - GraphFlooder.floodIf(left, seen) { - seen = it.seen - list.add(it) - } - - GraphFlooder.floodIf(right, seen) { - seen = it.seen - list.add(it) - } - - GraphFlooder.floodIf(front, seen) { - seen = it.seen - list.add(it) - } - - GraphFlooder.floodIf(back, seen) { - seen = it.seen - list.add(it) - } - - return list - } - - fun flood(): List> { - top?.bottom = null - bottom?.top = null - left?.right = null - right?.left = null - front?.back = null - back?.front = null - - val list = _flood() - - top?.bottom = this - bottom?.top = this - left?.right = this - right?.left = this - front?.back = this - back?.front = this - - return list - } - - var valid = true + var graph: G = graphFactory.invoke() private set - fun destroy(factory: () -> Abstract6Graph): List> { - if (!valid || !SERVER_IS_LIVE) return emptyList() + init { + graph.addNode(this as N) + } - top?.bottom = null - bottom?.top = null - left?.right = null - right?.left = null - front?.back = null - back?.front = null + private var seen: Int = 0 - graph?.removeNode(this) + operator fun get(direction: Direction): N? = neighbours[direction] - var num = 0 + operator fun set(direction: Direction, node: N?) { + set(direction, node, false) + } - if (top != null) num++ - if (bottom != null) num++ - if (left != null) num++ - if (right != null) num++ - if (front != null) num++ - if (back != null) num++ + fun set(direction: Direction, node: N?, allowReplacement: Boolean) { + check(isValid) { "Can not neighbour any node while this node is invalid" } - if (num < 2) { - return emptyList() + val old = neighbours[direction] + if (old === node) return + + if (old != null) + breakConnection(this as N, old, direction) + + if (node != null) { + require(node.isValid) { "Can not neighbour invalid node" } + + val opposite = -direction + + if (allowReplacement) { + node.neighbours[opposite]?.let { + breakConnection(node, it, opposite) + } + + check(node.neighbours[opposite] == null) { "$node didn't break connection at direction $opposite" } + } else { + check(node.neighbours[opposite] == null) { "Trying to form connection from $this to $node at direction $direction, but $node already has neighbour at $opposite (${node.neighbours[opposite]})!" } + } + + node.neighbours[opposite] = this as N + neighbours[direction] = node + node.graph.merge(graph, setter) + node.onNeighbour(opposite) + onNeighbour(direction) + } else { + neighbours.remove(direction) + } + } + + var top: N? + get() = neighbours[Direction.UP] + set(value) { + set(Direction.UP, value) } - val paths = _flood() - - if (paths.size < 2) { - return paths + var bottom: N? + get() = neighbours[Direction.DOWN] + set(value) { + set(Direction.DOWN, value) } - var biggest = paths[0] + var south: N? + get() = neighbours[Direction.SOUTH] + set(value) { + set(Direction.SOUTH, value) + } - for (i in 1 until paths.size) { - if (biggest.size() < paths[i].size()) { - biggest = paths[i] + var north: N? + get() = neighbours[Direction.NORTH] + set(value) { + set(Direction.NORTH, value) + } + + var west: N? + get() = neighbours[Direction.WEST] + set(value) { + set(Direction.WEST, value) + } + + var east: N? + get() = neighbours[Direction.EAST] + set(value) { + set(Direction.EAST, value) + } + + open fun onNeighbour(direction: Direction) {} + open fun onUnNeighbour(direction: Direction) {} + + protected open fun invalidate() {} + protected open fun revive() {} + + var isValid: Boolean = true + set(value) { + if (value == field) return + field = value + + if (!value) { + val neighbours = ArrayList(neighbours.entries) + + for ((dir, node) in neighbours) { + breakConnection(this as N, node, dir) + } + + graph.removeNode(this as N) + invalidate() + } else { + revive() } } - for (flooder in paths) { - if (flooder == biggest) continue + fun discover( + level: ServerLevel, + blockPos: BlockPos, + nodeGetter: (BlockEntity) -> N? + ) { + if (!isValid) return - val graph = factory() + level.addTicker { + isValid && !discoverStep(level, blockPos, nodeGetter) + } + } - for (node in flooder.nodes) { - node.graph?.removeNode(node) - graph.addNode(node) + fun discover( + level: ServerLevel, + blockPos: BlockPos, + capability: Capability + ) { + if (!isValid) return + + level.addTicker { + isValid && !discoverStep(level, blockPos) { it.getCapability(capability).orNull() } + } + } + + fun discover(blockEntity: BlockEntity, nodeGetter: (BlockEntity) -> N?) { + discover(blockEntity.level as? ServerLevel ?: return, blockEntity.blockPos, nodeGetter) + } + + fun discover(blockEntity: BlockEntity, capability: Capability) { + discover(blockEntity.level as? ServerLevel ?: return, blockEntity.blockPos, capability) + } + + fun discoverStep( + level: ServerLevel, + blockPos: BlockPos, + nodeGetter: (BlockEntity) -> N?, + ): Boolean { + if (!isValid) return false + var fullDiscovery = true + + for (dir in directions) { + val offset = blockPos + dir + val chunk = level.chunkSource.getChunkNow(SectionPos.blockToSectionCoord(offset.x), SectionPos.blockToSectionCoord(offset.z)) + + if (chunk == null) { + fullDiscovery = false + set(dir, null) + continue + } + + val entity = chunk.getBlockEntity(offset) + + if (entity != null) { + set(dir, nodeGetter(entity)) + } else { + set(dir, null) } } - return paths + return fullDiscovery + } + + companion object { + private val setter = Graph6Node<*, *>::graph::set + private val nextSeen = AtomicInteger() + private val directions = Direction.values() + + private fun , G : Abstract6Graph> breakConnection(a: N, b: N, direction: Direction) { + val opposite = -direction + + require(a.neighbours[direction] === b) { "$a does not neighbour with $b at direction $direction (forward)" } + require(b.neighbours[opposite] === a) { "$b does not neighbour with $a at direction $opposite (backward)" } + require(a.graph === b.graph) { "$a and $b belong to different graphs (${a.graph} vs ${b.graph})" } + + a.neighbours.remove(direction) + b.neighbours.remove(opposite) + + val seen = nextSeen.incrementAndGet() + val flood1 = flood(a, seen) + + if (b.seen != seen) { + val flood2 = flood(b, seen) + + val big: ArrayList + val small: ArrayList + + if (flood1.size >= flood2.size) { + big = flood1 + small = flood2 + } else { + big = flood2 + small = flood1 + } + + a.graph.retain(ReferenceOpenHashSet(big)) + val newGraph = a.graphFactory.invoke() + + for (node in small) { + node.graph = newGraph + } + + for (node in small) { + if (node.isValid) { + newGraph.addNode(node) + } + } + } + + if (a.isValid) + a.onUnNeighbour(direction) + + if (b.isValid) + b.onUnNeighbour(opposite) + } + + private fun , G : Abstract6Graph> flood(startingNode: N, seen: Int): ArrayList { + val unopen = ArrayList() + val result = ArrayList() + unopen.add(startingNode) + + while (unopen.isNotEmpty()) { + val last = unopen.removeLast() + + if (last.seen < seen) { + result.add(last) + last.seen = seen + + for (node in last.neighbours.values) { + if (node.seen < seen) { + unopen.add(node) + } + } + } + } + + return result + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/GraphFlooder.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/GraphFlooder.kt deleted file mode 100644 index 5c0a4d1c3..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/GraphFlooder.kt +++ /dev/null @@ -1,64 +0,0 @@ -package ru.dbotthepony.mc.otm.graph - -import java.util.* -import kotlin.collections.ArrayList - -class GraphFlooder(val startNode: Graph6Node, @JvmField val seen: Int = nextSeen++) { - var flooded = false - private set - - private val _nodes = ArrayList>() - - @JvmField - val nodes = Collections.unmodifiableCollection(_nodes)!! - - fun size() = _nodes.size - - private fun flood(node: Graph6Node) { - if (node.seen >= seen) return - - _nodes.add(node) - node.seen = seen - - if (node.top != null) flood(node.top!!) - if (node.bottom != null) flood(node.bottom!!) - if (node.left != null) flood(node.left!!) - if (node.right != null) flood(node.right!!) - if (node.front != null) flood(node.front!!) - if (node.back != null) flood(node.back!!) - } - - fun flood() { - if (flooded) throw IllegalStateException("Already flooded") - - flooded = true - - _nodes.add(startNode) - startNode.seen = seen - - if (startNode.top != null) flood(startNode.top!!) - if (startNode.bottom != null) flood(startNode.bottom!!) - if (startNode.left != null) flood(startNode.left!!) - if (startNode.right != null) flood(startNode.right!!) - if (startNode.front != null) flood(startNode.front!!) - if (startNode.back != null) flood(startNode.back!!) - } - - companion object { - private var nextSeen = 0 - - fun floodIf(node: Graph6Node?, seen: Int, runnable: (GraphFlooder) -> Unit) { - if (node != null && node.seen < seen) { - if (seen == Int.MAX_VALUE) { - val flooder = GraphFlooder(node) - flooder.flood() - runnable(flooder) - } else { - val flooder = GraphFlooder(node, seen) - flooder.flood() - runnable(flooder) - } - } - } - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/IMatterGraphNode.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/IMatterGraphListener.kt similarity index 58% rename from src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/IMatterGraphNode.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/IMatterGraphListener.kt index c64294c2c..1d2177c8e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/IMatterGraphNode.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/IMatterGraphListener.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.graph.matter import ru.dbotthepony.mc.otm.capability.matter.* -import ru.dbotthepony.mc.otm.graph.Graph6Node interface IMatterGraphListener { fun onPatternAdded(state: IPatternState) {} @@ -13,12 +12,3 @@ interface IMatterGraphListener { fun onMatterTaskFinished(state: IReplicationTask<*>) {} fun onMatterTaskRemoved(state: IReplicationTask<*>) {} } - -interface IMatterGraphNode : IMatterGraphListener { - fun getMatterHandler(): IMatterStorage? = null - fun getPatternHandler(): IPatternStorage? = null - fun getTaskHandler(): IReplicationTaskProvider? = null - - val matterNode: Graph6Node - val matterGraph: MatterNetworkGraph? get() = matterNode.graph as MatterNetworkGraph? -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNetworkGraph.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterGraph.kt similarity index 64% rename from src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNetworkGraph.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterGraph.kt index 8fea4f865..b0e0e2a10 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNetworkGraph.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterGraph.kt @@ -1,30 +1,25 @@ package ru.dbotthepony.mc.otm.graph.matter -import com.google.common.collect.Streams -import net.minecraft.server.level.ServerLevel +import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet import net.minecraft.world.item.Item -import net.minecraft.world.level.block.entity.BlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection -import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.matter.* import ru.dbotthepony.mc.otm.core.filterNotNull import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.graph.Abstract6Graph -import ru.dbotthepony.mc.otm.graph.Graph6Node import java.util.* import java.util.function.Predicate import java.util.stream.Stream -import kotlin.collections.HashSet @Suppress("unused") -class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListener { - private val listeners = HashSet() +class MatterGraph : Abstract6Graph(), IMatterGraphListener { + private val listeners = ObjectOpenHashSet() fun addListener(listener: IMatterGraphListener) = listeners.add(listener) fun removeListener(listener: IMatterGraphListener) = listeners.remove(listener) - override fun onNodeRemoved(node: Graph6Node) { - val patterns = node.value.getPatternHandler() + override fun onNodeRemoved(node: MatterNode) { + val patterns = node.getPatternHandler() if (patterns != null) { for (pattern in patterns.patterns) { @@ -32,7 +27,7 @@ class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListe } } - val tasks = node.value.getTaskHandler() + val tasks = node.getTaskHandler() if (tasks != null) { for (task in tasks.replicationTasks) { @@ -41,24 +36,24 @@ class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListe } for (pattern in this.patterns) { - node.value.onPatternRemoved(pattern) + node.onPatternRemoved(pattern) } for (task in this.tasks) { - node.value.onMatterTaskRemoved(task) + node.onMatterTaskRemoved(task) } } - override fun onNodeAdded(node: Graph6Node) { + override fun onNodeAdded(node: MatterNode) { for (pattern in this.patterns) { - node.value.onPatternAdded(pattern) + node.onPatternAdded(pattern) } for (task in this.tasks) { - node.value.onMatterTaskCreated(task) + node.onMatterTaskCreated(task) } - val patterns = node.value.getPatternHandler() + val patterns = node.getPatternHandler() if (patterns != null) { for (pattern in patterns.patterns) { @@ -66,7 +61,7 @@ class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListe } } - val tasks = node.value.getTaskHandler() + val tasks = node.getTaskHandler() if (tasks != null) { for (task in tasks.replicationTasks) { @@ -79,7 +74,7 @@ class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListe var level = Decimal.ZERO for (node in nodes) { - val matter = node.value.getMatterHandler() + val matter = node.getMatterHandler() if (matter != null && matter.matterFlow == FlowDirection.BI_DIRECTIONAL) { level += matter.storedMatter @@ -93,7 +88,7 @@ class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListe var level = Decimal.ZERO for (node in nodes) { - val matter = node.value.getMatterHandler() + val matter = node.getMatterHandler() if (matter != null && matter.matterFlow == FlowDirection.BI_DIRECTIONAL) { level += matter.maxStoredMatter @@ -112,7 +107,7 @@ class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListe var extracted = Decimal.ZERO for (node in nodes) { - val matter = node.value.getMatterHandler() + val matter = node.getMatterHandler() if (matter != null) { val value = matter.extractMatter(howMuch, simulate) @@ -136,7 +131,7 @@ class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListe var received = Decimal.ZERO for (node in nodes) { - val matter = node.value.getMatterHandler() + val matter = node.getMatterHandler() if (matter != null && matter.matterFlow == FlowDirection.BI_DIRECTIONAL) { val value = matter.receiveMatter(howMuch, simulate) @@ -160,7 +155,7 @@ class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListe var received = Decimal.ZERO for (node in nodes) { - val matter = node.value.getMatterHandler() + val matter = node.getMatterHandler() if (matter != null && matter.matterFlow != FlowDirection.OUTPUT) { val value = matter.receiveMatter(howMuch, simulate) @@ -177,7 +172,7 @@ class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListe private fun doInsertPattern(state: IPatternState, onlyUpdate: Boolean, simulate: Boolean): PatternInsertStatus { for (node in nodes) { - val storage = node.value.getPatternHandler() + val storage = node.getPatternHandler() if (storage != null) { val status = storage.insertPattern(state, onlyUpdate, simulate) @@ -198,23 +193,23 @@ class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListe return doInsertPattern(state, false, simulate) } - val tasks: Stream> get() { - return Streams.concat(*nodes.mapNotNull { it.value.getTaskHandler()?.replicationTasks }.toTypedArray()) + val tasks: Stream> get() { + return nodes.stream().map { it.getTaskHandler()?.replicationTasks }.filterNotNull().flatMap { it } } - val allTasks: Stream> get() { - return Streams.concat(*nodes.mapNotNull { it.value.getTaskHandler()?.allReplicationTasks }.toTypedArray()) + val allTasks: Stream> get() { + return nodes.stream().map { it.getTaskHandler()?.allReplicationTasks }.filterNotNull().flatMap { it } } - val patterns: Stream get() { - return nodes.stream().map { it.value.getPatternHandler()?.patterns }.filterNotNull().flatMap { it } + val patterns: Stream get() { + return nodes.stream().map { it.getPatternHandler()?.patterns }.filterNotNull().flatMap { it } } val patternCount: Long get() { var value = 0L for (node in nodes) { - val storage = node.value.getPatternHandler() + val storage = node.getPatternHandler() if (storage != null) { value += storage.storedPatterns @@ -228,7 +223,7 @@ class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListe var value = 0L for (node in nodes) { - val storage = node.value.getPatternHandler() + val storage = node.getPatternHandler() if (storage != null) { value += storage.patternCapacity @@ -240,7 +235,7 @@ class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListe fun getPattern(id: UUID): IPatternState? { for (node in nodes) { - val storage = node.value.getPatternHandler() + val storage = node.getPatternHandler() if (storage != null) { val get = storage.getPattern(id) @@ -260,7 +255,7 @@ class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListe fun findPattern(predicate: Predicate): IPatternState? { for (node in nodes) { - val storage = node.value.getPatternHandler() + val storage = node.getPatternHandler() if (storage != null) { val find = storage.patterns.filter(predicate).findAny() @@ -284,7 +279,7 @@ class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListe fun allocateTask(simulate: Boolean): ReplicationTaskAllocation? { for (node in nodes) { - val tasks = node.value.getTaskHandler() + val tasks = node.getTaskHandler() if (tasks != null) { val allocated = tasks.allocateTask(simulate) @@ -299,87 +294,41 @@ class MatterNetworkGraph : Abstract6Graph(), IMatterGraphListe } fun notifyTaskCompletion(taskId: UUID): Boolean { - return nodes.any { it.value.getTaskHandler()?.notifyTaskCompletion(taskId) == true } + return nodes.any { it.getTaskHandler()?.notifyTaskCompletion(taskId) == true } } override fun onPatternAdded(state: IPatternState) { - for (node in nodes) node.value.onPatternAdded(state) + for (node in nodes) node.onPatternAdded(state) for (node in listeners) node.onPatternAdded(state) } override fun onPatternRemoved(state: IPatternState) { - for (node in nodes) node.value.onPatternRemoved(state) + for (node in nodes) node.onPatternRemoved(state) for (node in listeners) node.onPatternRemoved(state) } override fun onPatternUpdated(newState: IPatternState, oldState: IPatternState) { - for (node in nodes) node.value.onPatternUpdated(newState, oldState) + for (node in nodes) node.onPatternUpdated(newState, oldState) for (node in listeners) node.onPatternUpdated(newState, oldState) } override fun onMatterTaskCreated(task: IReplicationTask<*>) { - for (node in nodes) node.value.onMatterTaskCreated(task) + for (node in nodes) node.onMatterTaskCreated(task) for (node in listeners) node.onMatterTaskCreated(task) } override fun > onMatterTaskUpdated(newState: T, oldState: T) { - for (node in nodes) node.value.onMatterTaskUpdated(newState, oldState) + for (node in nodes) node.onMatterTaskUpdated(newState, oldState) for (node in listeners) node.onMatterTaskUpdated(newState, oldState) } override fun onMatterTaskFinished(state: IReplicationTask<*>) { - for (node in nodes) node.value.onMatterTaskFinished(state) + for (node in nodes) node.onMatterTaskFinished(state) for (node in listeners) node.onMatterTaskFinished(state) } override fun onMatterTaskRemoved(state: IReplicationTask<*>) { - for (node in nodes) node.value.onMatterTaskRemoved(state) + for (node in nodes) node.onMatterTaskRemoved(state) for (node in listeners) node.onMatterTaskRemoved(state) } - - companion object { - @JvmStatic - fun discoverFull(tile: BlockEntity, node: Graph6Node) { - if (tile.level !is ServerLevel) - return - - return discoverFull( - tile.level!! as ServerLevel, - tile.blockPos, - node, - fun(_tile): Graph6Node? { - val resolve = _tile.getCapability(MatteryCapability.MATTER_NODE) - - return if (resolve.isPresent) { - resolve.resolve().get().matterNode - } else { - null - } - }, - ::MatterNetworkGraph - ) - } - - @JvmStatic - fun discover(tile: BlockEntity, node: Graph6Node): Boolean { - if (tile.level !is ServerLevel) - return false - - return discover( - tile.level!! as ServerLevel, - tile.blockPos, - node, - fun(_tile): Graph6Node? { - val resolve = _tile.getCapability(MatteryCapability.MATTER_NODE) - - return if (resolve.isPresent) { - resolve.resolve().get().matterNode - } else { - null - } - }, - ::MatterNetworkGraph - ) - } - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNode.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNode.kt new file mode 100644 index 000000000..33b885a98 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNode.kt @@ -0,0 +1,18 @@ +package ru.dbotthepony.mc.otm.graph.matter + +import net.minecraft.world.level.block.entity.BlockEntity +import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage +import ru.dbotthepony.mc.otm.capability.matter.IPatternStorage +import ru.dbotthepony.mc.otm.capability.matter.IReplicationTaskProvider +import ru.dbotthepony.mc.otm.graph.Graph6Node + +open class MatterNode : Graph6Node(::MatterGraph), IMatterGraphListener { + open fun getMatterHandler(): IMatterStorage? = null + open fun getPatternHandler(): IPatternStorage? = null + open fun getTaskHandler(): IReplicationTaskProvider? = null + + fun discover(blockEntity: BlockEntity) { + discover(blockEntity, MatteryCapability.MATTER_NODE) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/SimpleMatterNode.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/SimpleMatterNode.kt new file mode 100644 index 000000000..6f171f85c --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/SimpleMatterNode.kt @@ -0,0 +1,23 @@ +package ru.dbotthepony.mc.otm.graph.matter + +import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage +import ru.dbotthepony.mc.otm.capability.matter.IPatternStorage +import ru.dbotthepony.mc.otm.capability.matter.IReplicationTaskProvider + +open class SimpleMatterNode( + private val matter: IMatterStorage? = null, + private val patterns: IPatternStorage? = null, + private val tasks: IReplicationTaskProvider? = null, +) : MatterNode() { + override fun getMatterHandler(): IMatterStorage? { + return matter + } + + override fun getPatternHandler(): IPatternStorage? { + return patterns + } + + override fun getTaskHandler(): IReplicationTaskProvider? { + return tasks + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/IStorageGraphNode.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/IStorageGraphNode.kt deleted file mode 100644 index 4362f1b55..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/IStorageGraphNode.kt +++ /dev/null @@ -1,22 +0,0 @@ -package ru.dbotthepony.mc.otm.graph.storage - -import ru.dbotthepony.mc.otm.graph.Graph6Node -import ru.dbotthepony.mc.otm.storage.IStorage - -interface IStorageGraphNode { - /** - * Called by storage graph on node being attached to it - */ - fun attachComponents(to: StorageNetworkGraph) - - /** - * Called by storage graph on node being detached from it - * - * This is NOT called when graph is being destroyed (e.g. even by merging - * with another graph). - */ - fun removeComponents(from: StorageNetworkGraph) - - val storageNode: Graph6Node - val storageGraph: StorageNetworkGraph? get() = storageNode.graph as StorageNetworkGraph? -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNetworkGraph.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageGraph.kt similarity index 60% rename from src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNetworkGraph.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageGraph.kt index a86764829..4e06a4d53 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNetworkGraph.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageGraph.kt @@ -14,8 +14,9 @@ import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.storage.* import java.util.LinkedList -class StorageNetworkGraph(private val level: Level) : Abstract6Graph() { +class StorageGraph : Abstract6Graph() { private val virtualComponents = Object2ObjectArrayMap, VirtualComponent<*>>() + val powerDemandingNodes = LinkedList() /** * Returns a [VirtualComponent] representing [type] storage @@ -31,8 +32,6 @@ class StorageNetworkGraph(private val level: Level) : Abstract6Graph } - private var addedTicker = false - fun add(storage: IStorage) { getVirtualComponent(storage.storageType).add(storage) } @@ -46,50 +45,12 @@ class StorageNetworkGraph(private val level: Level) : Abstract6Graph).contains(storage) } - override fun onNodeAdded(node: Graph6Node) { - node.value.attachComponents(this) - - if (!addedTicker) { - addedTicker = true - level.addTickerPre(this) - } + override fun onNodeAdded(node: StorageNode) { + node.attachComponents(this) } - override fun onNodeRemoved(node: Graph6Node) { - node.value.removeComponents(this) + override fun onNodeRemoved(node: StorageNode) { + node.removeComponents(this) } - val powerDemandingNodes = LinkedList() - - companion object { - @JvmStatic - fun discoverFull(tile: BlockEntity, node: Graph6Node) { - if (tile.level !is ServerLevel) - return - - return discoverFull( - tile.level as ServerLevel, - tile.blockPos, - node, - fun(_tile): Graph6Node? { - return _tile.getCapability(MatteryCapability.STORAGE_NODE).orNull()?.storageNode - } - ) { StorageNetworkGraph(tile.level!!) } - } - - @JvmStatic - fun discover(tile: BlockEntity, node: Graph6Node): Boolean { - if (tile.level !is ServerLevel) - return false - - return discover( - tile.level as ServerLevel, - tile.blockPos, - node, - fun(_tile): Graph6Node? { - return _tile.getCapability(MatteryCapability.STORAGE_NODE).orNull()?.storageNode - }, - ) { StorageNetworkGraph(tile.level!!) } - } - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/BasicStorageGraphNode.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNode.kt similarity index 61% rename from src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/BasicStorageGraphNode.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNode.kt index b0f52a83b..a5b57a4b5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/BasicStorageGraphNode.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNode.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.mc.otm.graph.storage -import net.minecraft.world.level.Level -import net.minecraftforge.common.util.LazyOptional +import net.minecraft.world.level.block.entity.BlockEntity +import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.storage.IStorage @@ -9,9 +9,7 @@ import ru.dbotthepony.mc.otm.storage.IStorageStack import ru.dbotthepony.mc.otm.storage.StorageStackType import java.util.* -open class BasicStorageGraphNode(private val energyDemander: IMatteryEnergyStorage? = null) : IStorageGraphNode { - private var resolver = LazyOptional.of { this } - private var valid = true +open class StorageNode(private val energyDemander: IMatteryEnergyStorage? = null) : Graph6Node(::StorageGraph) { protected val components = ArrayList>() /** @@ -22,13 +20,12 @@ open class BasicStorageGraphNode(private val energyDemander: IMatteryEnergyStora * [invalidate] and [removeComponents] still detach all components */ protected var manualAttaching = false - - @Suppress("LeakingThis") - final override val storageNode = Graph6Node(this) - private var demandingEnergy = false - override fun attachComponents(to: StorageNetworkGraph) { + /** + * Called by storage graph on node being attached to it + */ + open fun attachComponents(to: StorageGraph) { if (energyDemander != null) { if (energyDemander.missingPower.isPositive) { demandingEnergy = true @@ -45,19 +42,13 @@ open class BasicStorageGraphNode(private val energyDemander: IMatteryEnergyStora } } - fun tickEnergyDemanding() { - energyDemander ?: throw IllegalStateException("No energy demander") - - if (!demandingEnergy && storageGraph != null && energyDemander.missingPower.isPositive) { - demandingEnergy = true - storageGraph!!.powerDemandingNodes.add(energyDemander) - } else if (demandingEnergy && storageGraph != null && !energyDemander.missingPower.isPositive) { - demandingEnergy = false - storageGraph!!.powerDemandingNodes.remove(energyDemander) - } - } - - override fun removeComponents(from: StorageNetworkGraph) { + /** + * Called by storage graph on node being detached from it + * + * This is NOT called when graph is being destroyed (e.g. even by merging + * with another graph). + */ + open fun removeComponents(from: StorageGraph) { for (component in components) { from.remove(component) } @@ -68,6 +59,18 @@ open class BasicStorageGraphNode(private val energyDemander: IMatteryEnergyStora } } + fun tickEnergyDemanding() { + energyDemander ?: throw IllegalStateException("No energy demander") + + if (!demandingEnergy && energyDemander.missingPower.isPositive) { + demandingEnergy = true + graph.powerDemandingNodes.add(energyDemander) + } else if (demandingEnergy && !energyDemander.missingPower.isPositive) { + demandingEnergy = false + graph.powerDemandingNodes.remove(energyDemander) + } + } + @Suppress("unchecked_cast") fun > computeIfAbsent(identity: StorageStackType, provider: (StorageStackType) -> U): U { for (component in components) { @@ -90,8 +93,8 @@ open class BasicStorageGraphNode(private val energyDemander: IMatteryEnergyStora components.add(component) - if (valid && !manualAttaching) - storageGraph?.add(component) + if (isValid && !manualAttaching) + graph.add(component) } fun removeStorageComponent(component: IStorage<*>) { @@ -111,8 +114,8 @@ open class BasicStorageGraphNode(private val energyDemander: IMatteryEnergyStora val self = components[indexOf] components.removeAt(indexOf) - if (valid) - storageGraph?.remove(self) + if (isValid) + graph.remove(self) } fun removeStorageComponent(component: StorageStackType<*>) { @@ -132,47 +135,25 @@ open class BasicStorageGraphNode(private val energyDemander: IMatteryEnergyStora val self = components[indexOf] components.removeAt(indexOf) - if (valid && !manualAttaching) - storageGraph?.remove(self) + if (isValid && !manualAttaching) + graph.remove(self) } - open fun invalidate() { - if (!valid) return - valid = false - resolver.invalidate() + override fun invalidate() { + for (component in components) { + graph.remove(component) + } + } - val storageGraph = storageGraph - - if (storageGraph != null) { + override fun revive() { + if (!manualAttaching) { for (component in components) { - storageGraph.remove(component) + graph.add(component) } } } - open fun revive() { - if (valid) return - valid = true - resolver = LazyOptional.of { this } - - val storageGraph = storageGraph - - if (storageGraph != null && !manualAttaching) { - for (component in components) { - storageGraph.add(component) - } - } - } - - fun get(): LazyOptional { - return if (valid) resolver else LazyOptional.empty() - } - - fun destroy(level: Level?) { - if (level != null) { - storageNode.destroy { StorageNetworkGraph(level) } - } else { - storageGraph?.removeNode(storageNode) - } + fun discover(blockEntity: BlockEntity) { + discover(blockEntity, MatteryCapability.STORAGE_NODE) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt index 33371430e..ec591c7c7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt @@ -45,8 +45,8 @@ class MatterBottlerMenu @JvmOverloads constructor( storageSlots = immutableList(6) { index -> object : MatterySlot(container, index) { - override fun mayPlace(p_40231_: ItemStack): Boolean { - val cap = p_40231_.getCapability(MatteryCapability.MATTER).orNull() ?: return false + override fun mayPlace(itemStack: ItemStack): Boolean { + val cap = itemStack.getCapability(MatteryCapability.MATTER).orNull() ?: return false if (workFlow.value) { return index < 3 && cap.canReceiveMatter diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterCapacitorBankMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterCapacitorBankMenu.kt index 4993feffe..6582c186a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterCapacitorBankMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterCapacitorBankMenu.kt @@ -29,9 +29,9 @@ class MatterCapacitorBankMenu @JvmOverloads constructor( } else { matterGauge = LevelGaugeWidget(this, tile) totalMatterGauge = LevelGaugeWidget(this, { - tile.matterGraph?.getMatterStorageLevel() ?: Decimal.ZERO + tile.matterNode.graph.getMatterStorageLevel() }, { - tile.matterGraph?.getMatterStorageMaxLevel() ?: Decimal.ZERO + tile.matterNode.graph.getMatterStorageMaxLevel() }) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt index e7b237950..28397e409 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt @@ -19,7 +19,7 @@ import ru.dbotthepony.mc.otm.core.util.DecimalValueCodec import ru.dbotthepony.mc.otm.core.util.ItemSorter import ru.dbotthepony.mc.otm.core.util.codec import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphListener -import ru.dbotthepony.mc.otm.graph.matter.MatterNetworkGraph +import ru.dbotthepony.mc.otm.graph.matter.MatterGraph import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.network.* import ru.dbotthepony.mc.otm.registry.MMenus @@ -176,7 +176,7 @@ class MatterPanelMenu @JvmOverloads constructor( }) val totalMatterStored: Decimal by mSynchronizer.ComputedField( - getter = { tile?.matterGraph?.getMatterStorageLevel() ?: Decimal.ZERO }, + getter = { tile?.matterNode?.graph?.getMatterStorageLevel() ?: Decimal.ZERO }, codec = DecimalValueCodec, ) @@ -278,8 +278,7 @@ class MatterPanelMenu @JvmOverloads constructor( val tile = tile as MatterPanelBlockEntity? ?: return - val graph = tile.matterGraph ?: return - val state = graph.getPattern(id) + val state = tile.matterNode.graph.getPattern(id) if (state == null) { LOGGER.error("Received replication request from {} of {}, but it is not found in grid", ply, id) @@ -312,14 +311,13 @@ class MatterPanelMenu @JvmOverloads constructor( } private var initialSend = false - - private var listeningGrid: MatterNetworkGraph? = null + private var listeningGrid: MatterGraph? = null init { if (tile != null) { - listeningGrid = tile.matterGraph + listeningGrid = tile.matterNode.graph tile.attachMenu(this) - listeningGrid?.addListener(this) + listeningGrid!!.addListener(this) } } @@ -347,13 +345,9 @@ class MatterPanelMenu @JvmOverloads constructor( val tile = tile as MatterPanelBlockEntity? if (tile != null) { - val grid = tile.matterGraph - - if (grid != null) { - initialSend = true - sendNetwork(PatternsChangePacket(true, grid.patterns.toList())) - } - + val grid = tile.matterNode.graph + initialSend = true + sendNetwork(PatternsChangePacket(true, grid.patterns.toList())) sendNetwork(TasksChangePacket(true, tile.allReplicationTasks.toList())) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt index d590773c9..b025ddf03 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt @@ -1,9 +1,7 @@ package ru.dbotthepony.mc.otm.menu.matter -import com.google.common.collect.ImmutableList import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory -import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.block.entity.matter.MatterRecyclerBlockEntity import ru.dbotthepony.mc.otm.item.MatterDustItem @@ -26,8 +24,8 @@ class MatterRecyclerMenu @JvmOverloads constructor( val container = tile?.container ?: SimpleContainer(1) input = object : MatterySlot(container, 0) { - override fun mayPlace(p_40231_: ItemStack): Boolean { - return p_40231_.item is MatterDustItem && (p_40231_.item as MatterDustItem).getMatterValue(p_40231_) != null + override fun mayPlace(itemStack: ItemStack): Boolean { + return itemStack.item is MatterDustItem && (itemStack.item as MatterDustItem).getMatterValue(itemStack) != null } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt index d0b36b5b8..e218d2630 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt @@ -36,8 +36,8 @@ class MatterScannerMenu @JvmOverloads constructor( if (tile != null) { progress = ProgressGaugeWidget(this, tile::workProgress, tile::isUnableToProcess) patterns = LevelGaugeWidget(this, - { Decimal(tile.matterGraph?.patternCount ?: 0L) }, - { Decimal(tile.matterGraph?.patternCapacity ?: 0L) }) + { Decimal(tile.matterNode.graph.patternCount) }, + { Decimal(tile.matterNode.graph.patternCapacity) }) } else { progress = ProgressGaugeWidget(this) patterns = LevelGaugeWidget(this) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt index 7307b7867..a5163cd6a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt @@ -29,9 +29,9 @@ class PatternStorageMenu @JvmOverloads constructor( } else { storedThis = LevelGaugeWidget(this, tile) storedGrid = LevelGaugeWidget(this, { - Decimal(tile.matterGraph?.patternCount ?: 0) + Decimal(tile.matterNode.graph.patternCount) }, { - Decimal(tile.matterGraph?.patternCapacity ?: 0) + Decimal(tile.matterNode.graph.patternCapacity) }) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StoragePowerSupplierMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StoragePowerSupplierMenu.kt index e62778ed3..e1f84a444 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StoragePowerSupplierMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StoragePowerSupplierMenu.kt @@ -22,7 +22,7 @@ class StoragePowerSupplierMenu @JvmOverloads constructor( override fun broadcastChanges() { if (tile is StoragePowerSupplierBlockEntity) { totalTransferred = tile.powerPassed - activeNodes = tile.cell.storageGraph?.powerDemandingNodes?.size ?: 0 + activeNodes = tile.cell.graph.powerDemandingNodes.size } super.broadcastChanges() From c6ded6b13425f6d23692bcc1f8af788f33528c48 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 24 Mar 2023 20:37:30 +0700 Subject: [PATCH 0424/1199] Fix displaying the same gauge twice --- .../mc/otm/client/screen/matter/MatterCapacitorBankScreen.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterCapacitorBankScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterCapacitorBankScreen.kt index 006b8be44..f1c7767f3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterCapacitorBankScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterCapacitorBankScreen.kt @@ -10,11 +10,11 @@ import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel class MatterCapacitorBankScreen(p_97741_: MatterCapacitorBankMenu, p_97742_: Inventory, p_97743_: Component) : MatteryScreen(p_97741_, p_97742_, p_97743_) { - override fun makeMainFrame(): FramePanel> { + override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! val m = MatterGaugePanel(this, frame, menu.matterGauge, LEFT_MARGIN, GAUGE_TOP_WITHOUT_SLOT) - MatterGaugePanel(this, frame, menu.matterGauge, LEFT_MARGIN + m.width, GAUGE_TOP_WITHOUT_SLOT) + MatterGaugePanel(this, frame, menu.totalMatterGauge, LEFT_MARGIN + m.width, GAUGE_TOP_WITHOUT_SLOT) for (i in 0 .. 5) MatterCapacitorSlotPanel(this, frame, menu.storageSlots[i], 44f + 18 * i, 32f) From d1978d7e04dff8c2d8b4df6ffd51d201ffd62290 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 24 Mar 2023 20:59:05 +0700 Subject: [PATCH 0425/1199] Pattern panel now properly react to removed replication tasks --- .../block/entity/matter/MatterPanelBlockEntity.kt | 4 ++-- .../mc/otm/menu/matter/MatterPanelMenu.kt | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt index 2bce86dcf..76284295d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt @@ -191,7 +191,7 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val task = _tasks[id] ?: return _tasks.remove(id) - (matterNode.graph as MatterGraph?)?.onMatterTaskRemoved(task) + matterNode.graph.onMatterTaskRemoved(task) listeners.forEach { it.taskRemoved(task) } setChanged() @@ -201,7 +201,7 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val task = ReplicationTask(UUID.randomUUID(), state.id, state.item, 0, 0, count) _tasks[task.id] = task - (matterNode.graph as MatterGraph?)?.onMatterTaskCreated(task) + matterNode.graph.onMatterTaskCreated(task) listeners.forEach { it.taskUpdated(task) } setChanged() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt index 28397e409..41a482a87 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt @@ -266,7 +266,19 @@ class MatterPanelMenu @JvmOverloads constructor( fun networkTasksRemoved(tasks: Collection>) { for (task in tasks) { - this.tasks.remove(task) + val index = this.tasks.indexOfFirst(task::matchId) + + if (index != -1) { + this.tasks.removeAt(index) + + if (filter.test(task.item)) { + val index = this.tasksFiltered.indexOfFirst(task::matchId) + + if (index != -1) { + this.tasksFiltered.removeAt(index) + } + } + } } } From 66140d33a2081bd3ffc66a7a29072b5259409ca3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 24 Mar 2023 23:28:06 +0700 Subject: [PATCH 0426/1199] Item repairer recipe --- .../datagen/recipes/CraftingTableRecipes.kt | 13 ++ .../mc/otm/datagen/recipes/MatteryRecipe.kt | 60 ++++- .../dbotthepony/mc/otm/registry/MRecipes.java | 5 + .../mc/otm/core/collect/JsonArrayCollector.kt | 31 +++ .../mc/otm/recipe/EnergyContainerRecipe.kt | 32 +-- .../mc/otm/recipe/UpgradeRecipe.kt | 205 ++++++++++++++++++ 6 files changed, 324 insertions(+), 22 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/JsonArrayCollector.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index 5b471d904..a33668476 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -8,12 +8,14 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.item.crafting.Ingredient import net.minecraftforge.common.Tags +import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MItemTags import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRegistry import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.datagen.modLocation +import ru.dbotthepony.mc.otm.recipe.UpgradeRecipe import java.util.function.Consumer fun addCraftingTableRecipes(consumer: Consumer) { @@ -295,4 +297,15 @@ fun addCraftingTableRecipes(consumer: Consumer) { .rowB(Tags.Items.RODS_WOODEN) .rowB(Tags.Items.RODS_WOODEN) .build(consumer) + + MatteryRecipe(MItems.ITEM_REPAIRER, category = machinesCategory) + .setUpgradeSource(MItems.MATTER_REPLICATOR) + .addUpgradeOps( + UpgradeRecipe.Indirect("BlockEntityTag.${MatteryBlockEntity.ENERGY_KEY}", "BlockEntityTag.energy"), + UpgradeRecipe.Indirect("BlockEntityTag.${MatteryBlockEntity.MATTER_STORAGE_KEY}", "BlockEntityTag.matter"), + ) + .row(MItemTags.ADVANCED_CIRCUIT, Tags.Items.GEMS_EMERALD, MItemTags.ADVANCED_CIRCUIT) + .row(MItems.ELECTRIC_PARTS, MItems.MATTER_REPLICATOR, MItems.ELECTRIC_PARTS) + .row(MItems.ELECTROMAGNET, MItems.ELECTROMAGNET, MItems.ELECTROMAGNET) + .build(consumer) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt index 8d0c7f1f3..22ad6f598 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt @@ -1,13 +1,11 @@ package ru.dbotthepony.mc.otm.datagen.recipes -import com.google.common.collect.ImmutableList +import com.google.gson.JsonObject import net.minecraft.advancements.CriterionTriggerInstance import net.minecraft.data.recipes.FinishedRecipe -import net.minecraft.data.recipes.RecipeBuilder import net.minecraft.data.recipes.RecipeCategory import net.minecraft.data.recipes.ShapedRecipeBuilder -import net.minecraft.data.recipes.ShapelessRecipeBuilder import net.minecraft.resources.ResourceLocation import net.minecraft.tags.TagKey import net.minecraft.world.item.Item @@ -15,8 +13,11 @@ import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.item.crafting.RecipeSerializer import net.minecraft.world.level.ItemLike import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.core.collect.JsonArrayCollector import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.recipe.EnergyContainerRecipe +import ru.dbotthepony.mc.otm.recipe.UpgradeRecipe import java.util.function.Consumer private interface RecipeCell { @@ -116,7 +117,7 @@ class MatteryRecipe(val result: ItemLike, val count: Int = 1, val category: Reci } } - fun build(consumer: Consumer, name: String? = null) { + private fun buildRegular(): ShapedRecipeBuilder { if (index == 0) { throw NoSuchElementException("No recipe rows were defined") } @@ -140,15 +141,62 @@ class MatteryRecipe(val result: ItemLike, val count: Int = 1, val category: Reci builder.unlockedBy(a, b) } + return builder + } + + private var source: ResourceLocation? = null + private val copyPaths = ArrayList() + + fun setUpgradeSource(source: ResourceLocation): MatteryRecipe { + this.source = source + return this + } + + fun setUpgradeSource(source: ItemLike): MatteryRecipe { + this.source = source.asItem().registryName!! + return this + } + + fun addUpgradeOps(vararg operations: UpgradeRecipe.Op): MatteryRecipe { + for (op in operations) copyPaths.add(op) + return this + } + + private fun filter(consumer: Consumer): Consumer { + if (source != null) { + check(copyPaths.isNotEmpty()) { "Defined upgrade recipe without nbt migration operations" } + + return Consumer { + consumer.accept(object : FinishedRecipe by it { + override fun serializeRecipeData(pJson: JsonObject) { + it.serializeRecipeData(pJson) + + pJson["copyPaths"] = copyPaths.stream().map { it.serialize() }.collect(JsonArrayCollector) + pJson["source"] = source!!.toString() + } + + override fun getType(): RecipeSerializer<*> { + return UpgradeRecipe.Companion + } + }) + } + } + + return consumer + } + + fun build(consumer: Consumer, name: String? = null) { + val builder = buildRegular() + if (name != null) { - builder.save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, + builder.save(filter(consumer), ResourceLocation(OverdriveThatMatters.MOD_ID, if (result.asItem().registryName!!.namespace == OverdriveThatMatters.MOD_ID) "${result.asItem().registryName!!.path}_$name" else "${result.asItem().registryName!!.namespace}_${result.asItem().registryName!!.path}_$name" )) } else { - builder.save(consumer) + builder.save(filter(consumer)) } } diff --git a/src/main/java/ru/dbotthepony/mc/otm/registry/MRecipes.java b/src/main/java/ru/dbotthepony/mc/otm/registry/MRecipes.java index 1f4d002cb..f7a72fec6 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/registry/MRecipes.java +++ b/src/main/java/ru/dbotthepony/mc/otm/registry/MRecipes.java @@ -11,6 +11,7 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters; import ru.dbotthepony.mc.otm.recipe.EnergyContainerRecipe; import ru.dbotthepony.mc.otm.recipe.PlatePressRecipe; import ru.dbotthepony.mc.otm.recipe.PlatePressRecipeFactory; +import ru.dbotthepony.mc.otm.recipe.UpgradeRecipe; public class MRecipes { public static class MatteryRecipeType> implements RecipeType { @@ -28,6 +29,7 @@ public class MRecipes { public static final MatteryRecipeType PLATE_PRESS = new MatteryRecipeType<>(OverdriveThatMatters.loc(MNames.PLATE_PRESS)); public static final MatteryRecipeType ENERGY_CONTAINER = new MatteryRecipeType<>(OverdriveThatMatters.loc("energy_container")); + public static final MatteryRecipeType UPGRADE = new MatteryRecipeType<>(OverdriveThatMatters.loc("upgrade")); private static final DeferredRegister> serializerRegistry = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, OverdriveThatMatters.MOD_ID); private static final DeferredRegister> typeRegistry = DeferredRegister.create(ForgeRegistries.RECIPE_TYPES, OverdriveThatMatters.MOD_ID); @@ -35,8 +37,11 @@ public class MRecipes { static { serializerRegistry.register(MNames.PLATE_PRESS, () -> PlatePressRecipeFactory.INSTANCE); serializerRegistry.register(ENERGY_CONTAINER.name.getPath(), () -> EnergyContainerRecipe.Companion); + serializerRegistry.register(UPGRADE.name.getPath(), () -> UpgradeRecipe.Companion); + typeRegistry.register(MNames.PLATE_PRESS, () -> PLATE_PRESS); typeRegistry.register(ENERGY_CONTAINER.name.getPath(), () -> ENERGY_CONTAINER); + typeRegistry.register(UPGRADE.name.getPath(), () -> UPGRADE); } public static void register(IEventBus bus) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/JsonArrayCollector.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/JsonArrayCollector.kt new file mode 100644 index 000000000..2922a2270 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/JsonArrayCollector.kt @@ -0,0 +1,31 @@ +package ru.dbotthepony.mc.otm.core.collect + +import com.google.gson.JsonArray +import com.google.gson.JsonElement +import java.util.function.BiConsumer +import java.util.function.BinaryOperator +import java.util.function.Function +import java.util.function.Supplier +import java.util.stream.Collector + +object JsonArrayCollector : Collector { + override fun supplier(): Supplier { + return Supplier { JsonArray() } + } + + override fun accumulator(): BiConsumer { + return BiConsumer { t, u -> t.add(u) } + } + + override fun combiner(): BinaryOperator { + return BinaryOperator { t, u -> t.addAll(u); t } + } + + override fun finisher(): Function { + return Function.identity() + } + + override fun characteristics(): Set { + return setOf(Collector.Characteristics.IDENTITY_FINISH) + } +} 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 8c911b316..253ac43b1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/EnergyContainerRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/EnergyContainerRecipe.kt @@ -17,14 +17,14 @@ import ru.dbotthepony.mc.otm.container.stream import ru.dbotthepony.mc.otm.core.filterNotNull class EnergyContainerRecipe( - p_44153_: ResourceLocation, - p_44154_: String, + id: ResourceLocation, + group: String, category: CraftingBookCategory, - p_44155_: Int, - p_44156_: Int, - p_44157_: NonNullList, - p_44158_: ItemStack, -) : ShapedRecipe(p_44153_, p_44154_, category, p_44155_, p_44156_, p_44157_, p_44158_) { + width: Int, + height: Int, + ingredients: NonNullList, + result: ItemStack, +) : ShapedRecipe(id, group, category, width, height, ingredients, result) { constructor(parent: ShapedRecipe) : this(parent.id, parent.group, parent.category(), parent.width, parent.height, parent.ingredients, parent.resultItem) override fun assemble(container: CraftingContainer): ItemStack { @@ -53,25 +53,25 @@ class EnergyContainerRecipe( return itemStack } - override fun matches(p_44002_: CraftingContainer, p_44003_: Level): Boolean { - return super.matches(p_44002_, p_44003_) && !p_44002_.stream().anyMatch { it.isDamaged } + override fun matches(container: CraftingContainer, level: Level): Boolean { + return super.matches(container, level) && !container.stream().anyMatch { it.isDamaged } } - override fun getSerializer(): RecipeSerializer<*> { + override fun getSerializer(): RecipeSerializer { return Companion } companion object : RecipeSerializer { - override fun fromJson(p_44103_: ResourceLocation, p_44104_: JsonObject): EnergyContainerRecipe { - return EnergyContainerRecipe(Serializer.SHAPED_RECIPE.fromJson(p_44103_, p_44104_)) + override fun fromJson(id: ResourceLocation, data: JsonObject): EnergyContainerRecipe { + return EnergyContainerRecipe(Serializer.SHAPED_RECIPE.fromJson(id, data)) } - override fun fromNetwork(p_44105_: ResourceLocation, p_44106_: FriendlyByteBuf): EnergyContainerRecipe? { - return Serializer.SHAPED_RECIPE.fromNetwork(p_44105_, p_44106_)?.let(::EnergyContainerRecipe) + override fun fromNetwork(id: ResourceLocation, data: FriendlyByteBuf): EnergyContainerRecipe? { + return Serializer.SHAPED_RECIPE.fromNetwork(id, data)?.let(::EnergyContainerRecipe) } - override fun toNetwork(p_44101_: FriendlyByteBuf, p_44102_: EnergyContainerRecipe) { - Serializer.SHAPED_RECIPE.toNetwork(p_44101_, p_44102_) + override fun toNetwork(buff: FriendlyByteBuf, value: EnergyContainerRecipe) { + Serializer.SHAPED_RECIPE.toNetwork(buff, value) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt new file mode 100644 index 000000000..6131ac60b --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt @@ -0,0 +1,205 @@ +package ru.dbotthepony.mc.otm.recipe + +import com.google.common.collect.ImmutableList +import com.google.gson.JsonObject +import com.google.gson.JsonPrimitive +import net.minecraft.core.NonNullList +import net.minecraft.nbt.CompoundTag +import net.minecraft.network.FriendlyByteBuf +import net.minecraft.resources.ResourceLocation +import net.minecraft.util.GsonHelper +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.Ingredient +import net.minecraft.world.item.crafting.RecipeSerializer +import net.minecraft.world.item.crafting.ShapedRecipe +import ru.dbotthepony.mc.otm.container.stream +import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.tagNotNull +import ru.dbotthepony.mc.otm.core.util.readJson +import ru.dbotthepony.mc.otm.core.util.writeJson +import ru.dbotthepony.mc.otm.data.stream +import java.util.stream.Stream + +class UpgradeRecipe( + id: ResourceLocation, + group: String, + category: CraftingBookCategory, + width: Int, + height: Int, + ingredients: NonNullList, + result: ItemStack, + copyPaths: Stream, + val source: ResourceLocation, +) : ShapedRecipe(id, group, category, width, height, ingredients, result) { + constructor(parent: ShapedRecipe, copyPaths: Stream, source: ResourceLocation) : this(parent.id, parent.group, parent.category(), parent.width, parent.height, parent.ingredients, parent.resultItem, copyPaths, source) + + enum class OpType { + DIRECT { + override fun deserialize(obj: JsonObject): Op { + return Direct(GsonHelper.getAsString(obj, "path")) + } + }, INDIRECT { + override fun deserialize(obj: JsonObject): Op { + return Indirect(GsonHelper.getAsString(obj, "source"), GsonHelper.getAsString(obj, "destination")) + } + }; + + abstract fun deserialize(obj: JsonObject): Op + } + + interface Op { + val type: OpType + fun apply(source: CompoundTag, destination: CompoundTag) + fun serialize(json: JsonObject) + + fun serialize(): JsonObject { + return JsonObject().also { + it["type"] = JsonPrimitive(type.name) + serialize(it) + } + } + } + + data class Direct(val path: String) : Op { + private val split = path.split('.') + override val type: OpType + get() = OpType.DIRECT + + override fun serialize(json: JsonObject) { + json["path"] = JsonPrimitive("path") + } + + override fun apply(source: CompoundTag, destination: CompoundTag) { + var a = source + var b = destination + + for (i in 0 until split.size - 1) { + val value = split[i] + + if (value !in a) { + a[value] = CompoundTag() + } + + if (value !in b) { + b[value] = CompoundTag() + } + + a = a[value] as CompoundTag + b = b[value] as CompoundTag + } + + val value = split.last() + + if (value in a) { + b[value] = a[value]!!.copy() + } + } + } + + data class Indirect(val pathSource: String, val pathDestination: String) : Op { + private val splitSource = pathSource.split('.') + private val splitDestination = pathDestination.split('.') + + override val type: OpType + get() = OpType.INDIRECT + + override fun serialize(json: JsonObject) { + json["source"] = JsonPrimitive(pathSource) + json["destination"] = JsonPrimitive(pathDestination) + } + + override fun apply(source: CompoundTag, destination: CompoundTag) { + var a = source + var b = destination + + for (i in 0 until splitSource.size - 1) { + val value = splitSource[i] + + if (value !in a) { + a[value] = CompoundTag() + } + + a = a[value] as CompoundTag + } + + for (i in 0 until splitDestination.size - 1) { + val value = splitDestination[i] + + if (value !in b) { + b[value] = CompoundTag() + } + + b = b[value] as CompoundTag + } + + val valueA = splitSource.last() + val valueB = splitDestination.last() + + if (valueA in a) { + b[valueB] = a[valueA]!!.copy() + } + } + } + + val copyPaths: ImmutableList = copyPaths.collect(ImmutableList.toImmutableList()) + + override fun assemble(pInv: CraftingContainer): ItemStack { + val result = super.assemble(pInv) + + if (result.isEmpty) { + return result + } + + val sources = pInv.stream().filter { !it.isEmpty && it.item.registryName == source }.toList() + + if (sources.size != 1) { + return ItemStack.EMPTY + } + + val source = sources.first() + + for (op in copyPaths) { + op.apply(source.tagNotNull, result.tagNotNull) + } + + return result + } + + override fun getSerializer(): RecipeSerializer { + return Companion + } + + companion object : RecipeSerializer { + fun deserializeOp(json: JsonObject): Op { + return OpType.valueOf(GsonHelper.getAsString(json, "type")).deserialize(json) + } + + override fun fromJson(id: ResourceLocation, data: JsonObject): UpgradeRecipe { + return UpgradeRecipe( + Serializer.SHAPED_RECIPE.fromJson(id, data), + GsonHelper.getAsJsonArray(data, "copyPaths").stream().map { deserializeOp(it as JsonObject) }, + ResourceLocation(GsonHelper.getAsString(data, "source")) + ) + } + + override fun fromNetwork(id: ResourceLocation, buff: FriendlyByteBuf): UpgradeRecipe? { + val recipe = Serializer.SHAPED_RECIPE.fromNetwork(id, buff) ?: return null + + return UpgradeRecipe( + recipe, + buff.readCollection({ ArrayList(it) }, { deserializeOp(it.readJson() as JsonObject) }).stream(), + buff.readResourceLocation() + ) + } + + override fun toNetwork(buff: FriendlyByteBuf, value: UpgradeRecipe) { + Serializer.SHAPED_RECIPE.toNetwork(buff, value) + buff.writeCollection(value.copyPaths) { it, v -> it.writeJson(v.serialize()) } + buff.writeResourceLocation(value.source) + } + } +} From 72d4cdf29b61e291408b633fa3a25a833f803c06 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 24 Mar 2023 23:30:29 +0700 Subject: [PATCH 0427/1199] Move JsonArraySpliterator to proper package --- .../ru/dbotthepony/mc/otm/android/AndroidResearchType.kt | 3 +-- .../mc/otm/{data => core/collect}/JsonArraySpliterator.kt | 2 +- .../ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt | 2 +- src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt | 3 +-- src/main/kotlin/ru/dbotthepony/mc/otm/matter/UpdateAction.kt | 3 +-- src/main/kotlin/ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt | 2 +- 6 files changed, 6 insertions(+), 9 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/{data => core/collect}/JsonArraySpliterator.kt (96%) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt index 3dd3c0c58..2386bb3bc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt @@ -27,10 +27,9 @@ import ru.dbotthepony.mc.otm.core.collect.ListSet import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.isActuallyEmpty import ru.dbotthepony.mc.otm.core.registryName -import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.core.toImmutableList -import ru.dbotthepony.mc.otm.data.stream +import ru.dbotthepony.mc.otm.core.collect.stream import ru.dbotthepony.mc.otm.isClient import ru.dbotthepony.mc.otm.registry.MRegistry import java.util.LinkedList diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/JsonArraySpliterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/JsonArraySpliterator.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/mc/otm/data/JsonArraySpliterator.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/JsonArraySpliterator.kt index 9e4b2ed30..c6ac299d3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/JsonArraySpliterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/JsonArraySpliterator.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.data +package ru.dbotthepony.mc.otm.core.collect import com.google.gson.JsonArray import com.google.gson.JsonElement diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt index c1958d418..8b84bc86e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt @@ -17,7 +17,7 @@ import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.core.stream import ru.dbotthepony.mc.otm.core.tagNotNull -import ru.dbotthepony.mc.otm.data.stream +import ru.dbotthepony.mc.otm.core.collect.stream import ru.dbotthepony.mc.otm.registry.MItemFunctionTypes import java.util.stream.Stream diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt index bdb723c09..ba23936bd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt @@ -12,9 +12,8 @@ import net.minecraft.world.level.ItemLike import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.registryName -import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set -import ru.dbotthepony.mc.otm.data.stream +import ru.dbotthepony.mc.otm.core.collect.stream import java.util.stream.Stream class ComputeAction : AbstractRegistryAction { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/UpdateAction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/UpdateAction.kt index e1a0d0799..ffa1ee732 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/UpdateAction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/UpdateAction.kt @@ -9,9 +9,8 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.tags.TagKey import net.minecraft.world.item.Item import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set -import ru.dbotthepony.mc.otm.data.stream +import ru.dbotthepony.mc.otm.core.collect.stream class UpdateAction : AbstractRegistryAction { companion object { 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 6131ac60b..08d766c8a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt @@ -21,7 +21,7 @@ import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.core.tagNotNull import ru.dbotthepony.mc.otm.core.util.readJson import ru.dbotthepony.mc.otm.core.util.writeJson -import ru.dbotthepony.mc.otm.data.stream +import ru.dbotthepony.mc.otm.core.collect.stream import java.util.stream.Stream class UpgradeRecipe( From 11e3ff516120054f7d612bb9dd136408446a38f2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 24 Mar 2023 23:31:16 +0700 Subject: [PATCH 0428/1199] Nerf matter capacity of matter reconstructor --- .../mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt index 625df3d54..7efd8d3ad 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt @@ -238,7 +238,7 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt ENERGY_VALUES = BlockEnergyStorageImpl.makeConfigEntry(builder, capacity = Decimal(400_000), throughput = Decimal(2_000)) - _CAPACITY = builder.defineDecimal("matterCapacity", Decimal(4_000), Decimal.ONE_TENTH) + _CAPACITY = builder.defineDecimal("matterCapacity", Decimal(800), Decimal.ONE_TENTH) _ENERGY_CONSUMPTION = builder.defineDecimal("energyConsumption", Decimal(600), Decimal.ONE) _ONLY_ANVIL = builder From d2da3535c169573977459271c08adf2e1794ce29 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 24 Mar 2023 23:32:14 +0700 Subject: [PATCH 0429/1199] Clarify variable --- .../mc/otm/datagen/recipes/MatteryRecipe.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt index 22ad6f598..70fc856aa 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt @@ -144,16 +144,16 @@ class MatteryRecipe(val result: ItemLike, val count: Int = 1, val category: Reci return builder } - private var source: ResourceLocation? = null + private var upgradeSource: ResourceLocation? = null private val copyPaths = ArrayList() fun setUpgradeSource(source: ResourceLocation): MatteryRecipe { - this.source = source + this.upgradeSource = source return this } fun setUpgradeSource(source: ItemLike): MatteryRecipe { - this.source = source.asItem().registryName!! + this.upgradeSource = source.asItem().registryName!! return this } @@ -163,7 +163,7 @@ class MatteryRecipe(val result: ItemLike, val count: Int = 1, val category: Reci } private fun filter(consumer: Consumer): Consumer { - if (source != null) { + if (upgradeSource != null) { check(copyPaths.isNotEmpty()) { "Defined upgrade recipe without nbt migration operations" } return Consumer { @@ -172,7 +172,7 @@ class MatteryRecipe(val result: ItemLike, val count: Int = 1, val category: Reci it.serializeRecipeData(pJson) pJson["copyPaths"] = copyPaths.stream().map { it.serialize() }.collect(JsonArrayCollector) - pJson["source"] = source!!.toString() + pJson["source"] = upgradeSource!!.toString() } override fun getType(): RecipeSerializer<*> { From 013fc649b289f8415509512e114a454a1cd2d745 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 24 Mar 2023 23:53:51 +0700 Subject: [PATCH 0430/1199] Structurize decorative recipes --- .../ru/dbotthepony/mc/otm/datagen/DataGen.kt | 2 +- .../otm/datagen/recipes/DecorativesRecipes.kt | 86 ++++++++++--------- .../mc/otm/datagen/recipes/MatteryRecipe.kt | 4 + 3 files changed, 51 insertions(+), 41 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt index e02056fcb..f0bbc3120 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -55,7 +55,7 @@ import ru.dbotthepony.mc.otm.registry.objects.ColoredDecorativeBlock import ru.dbotthepony.mc.otm.registry.objects.DecorativeBlock import kotlin.properties.Delegates -fun modLocation(string: String) = ResourceLocation(DataGen.MOD_ID, string) +internal fun modLocation(string: String) = ResourceLocation(DataGen.MOD_ID, string) @Mod.EventBusSubscriber(modid = DataGen.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) object DataGen { diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt index 510397b8e..5a93ca0ec 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt @@ -25,14 +25,14 @@ private fun stairs(base: ItemLike, result: ItemLike, consumer: Consumer) { MatteryRecipe(result, 6, category = RecipeCategory.BUILDING_BLOCKS) .row(base, base, base) .unlockedBy(base) - .build(consumer) + .build(consumer, modLocation("decorative/slabs/${base.asItem().registryName!!.path}")) } private fun wall(base: ItemLike, result: ItemLike, consumer: Consumer) { @@ -40,7 +40,7 @@ private fun wall(base: ItemLike, result: ItemLike, consumer: Consumer) { @@ -73,14 +73,14 @@ fun addDecorativesRecipes(provider: MatteryRecipeProvider, consumer: Consumer, name: ResourceLocation) { + buildRegular().save(filter(consumer), name) + } + fun buildEnergetic(consumer: Consumer, name: String? = null) { build({ consumer.accept(object : FinishedRecipe by it { From 2f770e6e706317afe553bcd0a71b19aa56544a4c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Mar 2023 00:11:35 +0700 Subject: [PATCH 0431/1199] Account research percent of patterns in system in matter reconstructor --- .../entity/matter/ItemRepairerBlockEntity.kt | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt index 7efd8d3ad..f80417776 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt @@ -19,6 +19,7 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage +import ru.dbotthepony.mc.otm.capability.matter.IPatternState import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.container.HandlerFilter @@ -43,14 +44,32 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt private var matterPerTick = Decimal.ZERO private var progressPerTick = 0.0 private var repairProgress = 0.0 + private var failureChance = 0.0 private var lastItem: Item? = null var canNotWork = false val matter = MatterStorageImpl(::setChangedLight, FlowDirection.INPUT, ::CAPACITY) - val matterNode = SimpleMatterNode(matter = matter) val energy = WorkerEnergyStorage(::setChangedLight, ENERGY_VALUES) + val matterNode = object : MatterNode() { + override fun getMatterHandler(): IMatterStorage { + return matter + } + + override fun onPatternAdded(state: IPatternState) { + containerChanged() + } + + override fun onPatternRemoved(state: IPatternState) { + containerChanged() + } + + override fun onPatternUpdated(newState: IPatternState, oldState: IPatternState) { + containerChanged() + } + } + init { exposeGlobally(MatteryCapability.MATTER, matter) exposeGlobally(MatteryCapability.MATTER_NODE, matterNode) @@ -148,6 +167,7 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt progressPerTick = (item.maxDamage / matter.complexity) / DIVISOR matterPerTick = (matter.matter / matter.complexity) / DIVISOR + failureChance = (1.0 - found.researchPercent) + FAILURE_CHANCE } else { matterPerTick = Decimal.ZERO progressPerTick = 0.0 @@ -201,7 +221,7 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt return } - if (FAILURE_CHANCE <= 0.0 || level!!.random.nextDouble() >= FAILURE_CHANCE) + if (failureChance <= 0.0 || level!!.random.nextDouble() >= failureChance) repairProgress += progressPerTick energy.extractEnergy(ENERGY_CONSUMPTION * (progressPerTick / this.progressPerTick), false) From 917a498e1e693f6542a1275fc30b280de9b92bea Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Mar 2023 00:20:28 +0700 Subject: [PATCH 0432/1199] Make matter reconstructor work only with anvil repair items by default --- .../entity/matter/ItemRepairerBlockEntity.kt | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt index f80417776..2abbe7fa6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt @@ -31,7 +31,6 @@ import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.graph.matter.MatterGraph import ru.dbotthepony.mc.otm.graph.matter.MatterNode -import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode import ru.dbotthepony.mc.otm.matter.IMatterValue import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.menu.matter.ItemRepairerMenu @@ -95,7 +94,7 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt return false } - if (!ONLY_ANVIL) { + if (ALLOW_TO_SKIP_ANVIL && !ONLY_ANVIL) { if (MatterManager.get(stack.item).hasMatterValue) { return true } @@ -149,10 +148,11 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt matterPerTick = Decimal.ZERO progressPerTick = 0.0 } else { - if (!ONLY_ANVIL) { + if (ALLOW_TO_SKIP_ANVIL && !ONLY_ANVIL) { val matter = MatterManager.get(item.item) if (matter.hasMatterValue) { + failureChance = FAILURE_CHANCE progressPerTick = (item.maxDamage / matter.complexity) / DIVISOR matterPerTick = (matter.matter / matter.complexity) / DIVISOR return@once @@ -162,12 +162,23 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt val found = matterNode.graph.patterns.filter { item.item.isValidRepairItem(item, ItemStack(it.item, 1)) }.findFirst().orElse(null) if (found != null) { + failureChance = (1.0 - found.researchPercent) + FAILURE_CHANCE + + if (!ONLY_ANVIL) { + val matter = MatterManager.get(item.item) + + if (matter.hasMatterValue) { + progressPerTick = (item.maxDamage / matter.complexity) / DIVISOR + matterPerTick = (matter.matter / matter.complexity) / DIVISOR + return@once + } + } + @Suppress("name_shadowing") val matter = MatterManager.get(found.item) * 2 progressPerTick = (item.maxDamage / matter.complexity) / DIVISOR matterPerTick = (matter.matter / matter.complexity) / DIVISOR - failureChance = (1.0 - found.researchPercent) + FAILURE_CHANCE } else { matterPerTick = Decimal.ZERO progressPerTick = 0.0 @@ -242,6 +253,7 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt val EXTRACT_TICKS: Int get() = _EXTRACT_TICKS.get() val FAILURE_CHANCE: Double get() = _FAILURE_CHANCE.get() val ONLY_ANVIL: Boolean get() = _ONLY_ANVIL.get() + val ALLOW_TO_SKIP_ANVIL: Boolean get() = _ALLOW_TO_SKIP_ANVIL.get() private var _CAPACITY: DecimalConfigValue by WriteOnce() private var _ENERGY_CONSUMPTION: DecimalConfigValue by WriteOnce() @@ -249,6 +261,7 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt private var _FAILURE_CHANCE: ConfigValue by WriteOnce() private var _EXTRACT_TICKS: ConfigValue by WriteOnce() private var _ONLY_ANVIL: ConfigValue by WriteOnce() + private var _ALLOW_TO_SKIP_ANVIL: ConfigValue by WriteOnce() var ENERGY_VALUES: ConciseBalanceValues by WriteOnce() private set @@ -261,6 +274,11 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt _CAPACITY = builder.defineDecimal("matterCapacity", Decimal(800), Decimal.ONE_TENTH) _ENERGY_CONSUMPTION = builder.defineDecimal("energyConsumption", Decimal(600), Decimal.ONE) + _ALLOW_TO_SKIP_ANVIL = builder + .comment("Allow to repair tools without having their anvil-repair items researched") + .comment("Ignored if onlyAnvil is true") + .define("allowToSkipAnvil", false) + _ONLY_ANVIL = builder .comment("Force repairing only by matter value of anvil materials") .comment("Doesn't make logical sense but might be good for balancing") @@ -274,7 +292,7 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt .defineInRange("extractTicks", 200, 1, Int.MAX_VALUE) _FAILURE_CHANCE = builder - .comment("Chance that replication will fail at any given tick") + .comment("Constant additional chance (over pattern research factor) that replication will fail at any given tick") .comment("In event of failure repair tick is wasted, wasting resources") .defineInRange("failureChance", 0.01, 0.0, 0.99) From df130211c324a0c10c7f1b01df04923b74f1484d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Mar 2023 00:30:17 +0700 Subject: [PATCH 0433/1199] Add matter reconstructor controls --- .../otm/client/screen/matter/ItemRepairerScreen.kt | 3 +++ .../mc/otm/menu/matter/ItemRepairerMenu.kt | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/ItemRepairerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/ItemRepairerScreen.kt index f4ceb099c..96437f10b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/ItemRepairerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/ItemRepairerScreen.kt @@ -4,6 +4,7 @@ import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel @@ -21,6 +22,8 @@ class ItemRepairerScreen(menu: ItemRepairerMenu, inventory: Inventory, title: Co SlotPanel(this, frame, menu.slot, 80f, PROGRESS_SLOT_TOP) + makeDeviceControls(this, frame, redstone = menu.redstoneControl, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig) + return frame } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/ItemRepairerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/ItemRepairerMenu.kt index 22899909e..8d91077de 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/ItemRepairerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/ItemRepairerMenu.kt @@ -3,10 +3,14 @@ package ru.dbotthepony.mc.otm.menu.matter import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.block.entity.matter.ItemRepairerBlockEntity import ru.dbotthepony.mc.otm.capability.matter.matter import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput +import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -22,8 +26,18 @@ class ItemRepairerMenu( } } + val redstoneControl = EnumInputWithFeedback(this) + val energyConfig = EnergyPlayerInput(this) + val itemConfig = ItemHandlerPlayerInput(this) + init { addStorageSlot(slot) addInventorySlots() + + if (tile != null) { + redstoneControl.with(tile.redstoneControl::redstoneSetting) + itemConfig.configure(tile.itemConfig) + energyConfig.configure(tile.energyConfig) + } } } From 5b36988ac1339b63c6bfd273b78f24d8972ee9e9 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Mar 2023 00:31:55 +0700 Subject: [PATCH 0434/1199] Rename itemrepairer to matter reconstructor internally everywhere but resource location --- .../kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt | 4 ++-- .../kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt | 4 ++-- .../ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt | 2 +- .../mc/otm/datagen/recipes/CraftingTableRecipes.kt | 2 +- .../kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt | 2 +- ...erBlockEntity.kt => MatterReconstructorBlockEntity.kt} | 8 ++++---- .../dbotthepony/mc/otm/block/matter/ItemRepairerBlock.kt | 6 +++--- ...ItemRepairerScreen.kt => MatterReconstructorScreen.kt} | 4 ++-- .../kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt | 4 ++-- .../{ItemRepairerMenu.kt => MatterReconstructorMenu.kt} | 7 +++---- .../ru/dbotthepony/mc/otm/registry/MBlockEntities.kt | 2 +- src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt | 4 +--- src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt | 6 +++--- src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt | 8 ++++---- src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt | 2 +- 15 files changed, 31 insertions(+), 34 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/{ItemRepairerBlockEntity.kt => MatterReconstructorBlockEntity.kt} (96%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/{ItemRepairerScreen.kt => MatterReconstructorScreen.kt} (83%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/{ItemRepairerMenu.kt => MatterReconstructorMenu.kt} (88%) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 180d0ab7e..ceebf124c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -365,8 +365,8 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.COBBLESTONE_GENERATOR, "Cobblestone Generator") add(MBlocks.ESSENCE_STORAGE, "Essence Storage") add(MBlocks.ESSENCE_STORAGE, "desc", "Allows to store and retrieve experience levels") - add(MBlocks.ITEM_REPAIRER, "Matter Reconstructor") - add(MBlocks.ITEM_REPAIRER, "desc", "Repairs tools using matter") + add(MBlocks.MATTER_RECONSTRUCTOR, "Matter Reconstructor") + add(MBlocks.MATTER_RECONSTRUCTOR, "desc", "Repairs tools using matter") add(MBlocks.ENGINE, "Ship Engine") add(MBlocks.HOLO_SIGN, "Holo Sign") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index d901d0db2..43a038fa4 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -372,8 +372,8 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.COBBLESTONE_GENERATOR, "Генератор булыжника") add(MBlocks.ESSENCE_STORAGE, "Хранилище эссенции") add(MBlocks.ESSENCE_STORAGE, "desc", "Позволяет хранить очки опыта") - add(MBlocks.ITEM_REPAIRER, "Материальный реконструктор") - add(MBlocks.ITEM_REPAIRER, "desc", "Чинит инструменты используя материю") + add(MBlocks.MATTER_RECONSTRUCTOR, "Материальный реконструктор") + add(MBlocks.MATTER_RECONSTRUCTOR, "desc", "Чинит инструменты используя материю") add(MBlocks.ENGINE, "Двигатель корабля") add(MBlocks.HOLO_SIGN, "Голографическая табличка") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index 6451c3831..b2c7d1146 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -137,7 +137,7 @@ fun addLootTables(lootTables: LootTables) { lootTables.tile(MBlocks.COBBLESTONE_GENERATOR) lootTables.tile(MBlocks.ESSENCE_STORAGE) - lootTables.tile(MBlocks.ITEM_REPAIRER) + lootTables.tile(MBlocks.MATTER_RECONSTRUCTOR) lootTables.tile(MBlocks.ENERGY_SERVO) lootTables.tile(MBlocks.ENERGY_COUNTER) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index a33668476..ef76205cf 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -298,7 +298,7 @@ fun addCraftingTableRecipes(consumer: Consumer) { .rowB(Tags.Items.RODS_WOODEN) .build(consumer) - MatteryRecipe(MItems.ITEM_REPAIRER, category = machinesCategory) + MatteryRecipe(MItems.MATTER_RECONSTRUCTOR, category = machinesCategory) .setUpgradeSource(MItems.MATTER_REPLICATOR) .addUpgradeOps( UpgradeRecipe.Indirect("BlockEntityTag.${MatteryBlockEntity.ENERGY_KEY}", "BlockEntityTag.energy"), diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index 3a5c7f456..f135411d7 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -172,7 +172,7 @@ fun addTags(tagsProvider: TagsProvider) { MBlocks.HOLO_SIGN, MBlocks.COBBLESTONE_GENERATOR, MBlocks.ESSENCE_STORAGE, - MBlocks.ITEM_REPAIRER, + MBlocks.MATTER_RECONSTRUCTOR, ), Tiers.IRON) tagsProvider.requiresPickaxe(MBlocks.TRITANIUM_ANVIL, Tiers.IRON) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt index 2abbe7fa6..bd69bd6a2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/ItemRepairerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt @@ -33,11 +33,11 @@ import ru.dbotthepony.mc.otm.graph.matter.MatterGraph import ru.dbotthepony.mc.otm.graph.matter.MatterNode import ru.dbotthepony.mc.otm.matter.IMatterValue import ru.dbotthepony.mc.otm.matter.MatterManager -import ru.dbotthepony.mc.otm.menu.matter.ItemRepairerMenu +import ru.dbotthepony.mc.otm.menu.matter.MatterReconstructorMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MNames -class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.ITEM_REPAIRER, blockPos, blockState) { +class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.MATTER_RECONSTRUCTOR, blockPos, blockState) { val repairContainer = MatteryContainer(::containerChanged, 1).also(::addDroppableContainer) private var matterPerTick = Decimal.ZERO @@ -119,7 +119,7 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt ) override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { - return ItemRepairerMenu(containerID, inventory, this) + return MatterReconstructorMenu(containerID, inventory, this) } override fun setRemoved() { @@ -267,7 +267,7 @@ class ItemRepairerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matt private set fun registerConfig(builder: ForgeConfigSpec.Builder) { - builder.push(MNames.ITEM_REPAIRER) + builder.push(MNames.MATTER_RECONSTRUCTOR) ENERGY_VALUES = BlockEnergyStorageImpl.makeConfigEntry(builder, capacity = Decimal(400_000), throughput = Decimal(2_000)) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/ItemRepairerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/ItemRepairerBlock.kt index 471b7d7ed..d3fc0928b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/ItemRepairerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/ItemRepairerBlock.kt @@ -8,17 +8,17 @@ import net.minecraft.world.level.block.entity.BlockEntityTicker import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock -import ru.dbotthepony.mc.otm.block.entity.matter.ItemRepairerBlockEntity +import ru.dbotthepony.mc.otm.block.entity.matter.MatterReconstructorBlockEntity class ItemRepairerBlock : RotatableMatteryBlock(), EntityBlock { override fun newBlockEntity(pPos: BlockPos, pState: BlockState): BlockEntity { - return ItemRepairerBlockEntity(pPos, pState) + return MatterReconstructorBlockEntity(pPos, pState) } override fun getTicker(pLevel: Level, pState: BlockState, pBlockEntityType: BlockEntityType): BlockEntityTicker? { if (pLevel.isClientSide) return null - return BlockEntityTicker { _, _, _, pBlockEntity -> if (pBlockEntity is ItemRepairerBlockEntity) pBlockEntity.tick() } + return BlockEntityTicker { _, _, _, pBlockEntity -> if (pBlockEntity is MatterReconstructorBlockEntity) pBlockEntity.tick() } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/ItemRepairerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt similarity index 83% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/ItemRepairerScreen.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt index 96437f10b..06a2bc1bb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/ItemRepairerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt @@ -9,9 +9,9 @@ import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel -import ru.dbotthepony.mc.otm.menu.matter.ItemRepairerMenu +import ru.dbotthepony.mc.otm.menu.matter.MatterReconstructorMenu -class ItemRepairerScreen(menu: ItemRepairerMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { +class MatterReconstructorScreen(menu: MatterReconstructorMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt index b8b6213ba..4efd5d53c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt @@ -1,6 +1,6 @@ package ru.dbotthepony.mc.otm.config -import ru.dbotthepony.mc.otm.block.entity.matter.ItemRepairerBlockEntity +import ru.dbotthepony.mc.otm.block.entity.matter.MatterReconstructorBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterDecomposerBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterRecyclerBlockEntity @@ -21,7 +21,7 @@ object MachinesConfig : AbstractConfig("machines") { MatterReplicatorBlockEntity.registerConfig(builder) MatterScannerBlockEntity.registerConfig(builder) MatterDecomposerBlockEntity.registerConfig(builder) - ItemRepairerBlockEntity.registerConfig(builder) + MatterReconstructorBlockEntity.registerConfig(builder) } val PLATE_PRESS = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.PLATE_PRESS) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/ItemRepairerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt similarity index 88% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/ItemRepairerMenu.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt index 8d91077de..a742e28e9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/ItemRepairerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt @@ -4,8 +4,7 @@ import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting -import ru.dbotthepony.mc.otm.block.entity.matter.ItemRepairerBlockEntity -import ru.dbotthepony.mc.otm.capability.matter.matter +import ru.dbotthepony.mc.otm.block.entity.matter.MatterReconstructorBlockEntity import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput @@ -14,10 +13,10 @@ import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus -class ItemRepairerMenu( +class MatterReconstructorMenu( containerId: Int, inventory: Inventory, - tile: ItemRepairerBlockEntity? = null + tile: MatterReconstructorBlockEntity? = null ) : MatteryPoweredMenu(MMenus.ITEM_REPAIER, containerId, inventory, tile) { val matterWidget = LevelGaugeWidget(this, tile?.matter) val slot = object : MatterySlot(tile?.repairContainer ?: SimpleContainer(1), 0) { 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 c59564892..d0f4c3e08 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt @@ -57,7 +57,7 @@ object MBlockEntities { val ENERGY_SERVO: BlockEntityType by registry.register(MNames.ENERGY_SERVO) { BlockEntityType.Builder.of(::EnergyServoBlockEntity, MBlocks.ENERGY_SERVO).build(null) } val COBBLESTONE_GENERATOR: BlockEntityType by registry.register(MNames.COBBLESTONE_GENERATOR) { BlockEntityType.Builder.of(::CobblerBlockEntity, MBlocks.COBBLESTONE_GENERATOR).build(null) } val ESSENCE_STORAGE: BlockEntityType by registry.register(MNames.ESSENCE_STORAGE) { BlockEntityType.Builder.of(::EssenceStorageBlockEntity, MBlocks.ESSENCE_STORAGE).build(null) } - val ITEM_REPAIRER: BlockEntityType by registry.register(MNames.ITEM_REPAIRER) { BlockEntityType.Builder.of(::ItemRepairerBlockEntity, MBlocks.ITEM_REPAIRER).build(null) } + val MATTER_RECONSTRUCTOR: BlockEntityType by registry.register(MNames.MATTER_RECONSTRUCTOR) { BlockEntityType.Builder.of(::MatterReconstructorBlockEntity, MBlocks.MATTER_RECONSTRUCTOR).build(null) } val STORAGE_BUS: BlockEntityType by registry.register(MNames.STORAGE_BUS) { BlockEntityType.Builder.of(::StorageBusBlockEntity, MBlocks.STORAGE_BUS).build(null) } val STORAGE_IMPORTER: BlockEntityType by registry.register(MNames.STORAGE_IMPORTER) { BlockEntityType.Builder.of(::StorageImporterBlockEntity, MBlocks.STORAGE_IMPORTER).build(null) } 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 07e803b92..afe8b208c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -6,7 +6,6 @@ import net.minecraft.network.chat.Component import net.minecraft.sounds.SoundEvents import net.minecraft.util.valueproviders.UniformInt import net.minecraft.world.entity.Entity -import net.minecraft.world.entity.EntityType import net.minecraft.world.entity.monster.Zombie import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack @@ -68,7 +67,6 @@ import ru.dbotthepony.mc.otm.block.tech.CobblerBlock import ru.dbotthepony.mc.otm.block.tech.EssenceStorageBlock import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.collect.SupplierList -import java.util.function.Supplier object MBlocks { private val registry = DeferredRegister.create(ForgeRegistries.BLOCKS, OverdriveThatMatters.MOD_ID) @@ -94,7 +92,7 @@ object MBlocks { val ENERGY_SERVO: Block by registry.register(MNames.ENERGY_SERVO) { EnergyServoBlock() } val COBBLESTONE_GENERATOR: Block by registry.register(MNames.COBBLESTONE_GENERATOR) { CobblerBlock() } val ESSENCE_STORAGE: EssenceStorageBlock by registry.register(MNames.ESSENCE_STORAGE) { EssenceStorageBlock() } - val ITEM_REPAIRER: ItemRepairerBlock by registry.register(MNames.ITEM_REPAIRER) { ItemRepairerBlock() } + val MATTER_RECONSTRUCTOR: ItemRepairerBlock by registry.register(MNames.MATTER_RECONSTRUCTOR) { ItemRepairerBlock() } val STORAGE_BUS: Block by registry.register(MNames.STORAGE_BUS) { StorageBusBlock() } val STORAGE_IMPORTER: Block by registry.register(MNames.STORAGE_IMPORTER) { StorageImporterBlock() } 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 11bca8c79..b4fb9c1fd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -109,8 +109,8 @@ object MItems { } } - val ITEM_REPAIRER: BlockItem by registry.register(MNames.ITEM_REPAIRER) { - object : BlockItem(MBlocks.ITEM_REPAIRER, DEFAULT_PROPERTIES) { + val MATTER_RECONSTRUCTOR: BlockItem by registry.register(MNames.MATTER_RECONSTRUCTOR) { + object : BlockItem(MBlocks.MATTER_RECONSTRUCTOR, DEFAULT_PROPERTIES) { override fun appendHoverText(p_40572_: ItemStack, p_40573_: Level?, p_40574_: MutableList, p_40575_: TooltipFlag) { super.appendHoverText(p_40572_, p_40573_, p_40574_, p_40575_) p_40574_.add(TranslatableComponent("$descriptionId.desc").withStyle(ChatFormatting.GRAY)) @@ -124,7 +124,7 @@ object MItems { ::PLATE_PRESS, ::MATTER_RECYCLER, ::STORAGE_BUS, ::STORAGE_IMPORTER, ::STORAGE_EXPORTER, ::DRIVE_VIEWER, ::DRIVE_RACK, ::ITEM_MONITOR, ::STORAGE_CABLE, ::STORAGE_POWER_SUPPLIER, ::ENERGY_SERVO, ::PHANTOM_ATTRACTOR, ::GRAVITATION_STABILIZER, ::COBBLESTONE_GENERATOR, ::ESSENCE_STORAGE, - ::ITEM_REPAIRER + ::MATTER_RECONSTRUCTOR ) val DEBUG_EXPLOSION_SMALL: Item by registry.register(MNames.DEBUG_EXPLOSION_SMALL) { BlockItem(MBlocks.DEBUG_EXPLOSION_SMALL, Item.Properties().stacksTo(64)) } 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 245456f38..3d5791c14 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt @@ -10,7 +10,7 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.client.screen.decorative.CargoCrateScreen import ru.dbotthepony.mc.otm.client.screen.decorative.HoloSignScreen import ru.dbotthepony.mc.otm.client.screen.decorative.MinecartCargoCrateScreen -import ru.dbotthepony.mc.otm.client.screen.matter.ItemRepairerScreen +import ru.dbotthepony.mc.otm.client.screen.matter.MatterReconstructorScreen import ru.dbotthepony.mc.otm.client.screen.matter.MatterBottlerScreen import ru.dbotthepony.mc.otm.client.screen.matter.MatterCapacitorBankScreen import ru.dbotthepony.mc.otm.client.screen.matter.MatterDecomposerScreen @@ -37,7 +37,7 @@ import ru.dbotthepony.mc.otm.client.screen.tech.PlatePressScreen import ru.dbotthepony.mc.otm.menu.decorative.CargoCrateMenu import ru.dbotthepony.mc.otm.menu.decorative.HoloSignMenu import ru.dbotthepony.mc.otm.menu.decorative.MinecartCargoCrateMenu -import ru.dbotthepony.mc.otm.menu.matter.ItemRepairerMenu +import ru.dbotthepony.mc.otm.menu.matter.MatterReconstructorMenu import ru.dbotthepony.mc.otm.menu.matter.MatterBottlerMenu import ru.dbotthepony.mc.otm.menu.matter.MatterCapacitorBankMenu import ru.dbotthepony.mc.otm.menu.matter.MatterDecomposerMenu @@ -87,7 +87,7 @@ object MMenus { val HOLO_SIGN: MenuType by registry.register(MNames.HOLO_SIGN) { MenuType(::HoloSignMenu) } val COBBLESTONE_GENERATOR: MenuType by registry.register(MNames.COBBLESTONE_GENERATOR) { MenuType(::CobblerMenu) } val ESSENCE_STORAGE: MenuType by registry.register(MNames.ESSENCE_STORAGE) { MenuType(::EssenceStorageMenu) } - val ITEM_REPAIER: MenuType by registry.register(MNames.ITEM_REPAIRER) { MenuType(::ItemRepairerMenu) } + val ITEM_REPAIER: MenuType by registry.register(MNames.MATTER_RECONSTRUCTOR) { MenuType(::MatterReconstructorMenu) } val STORAGE_BUS: MenuType<*> by registry.register(MNames.STORAGE_BUS) { MenuType(::StorageBusMenu) } val STORAGE_EXPORTER: MenuType<*> by registry.register(MNames.STORAGE_EXPORTER) { MenuType(::StorageExporterMenu) } @@ -128,7 +128,7 @@ object MMenus { MenuScreens.register(HOLO_SIGN, ::HoloSignScreen) MenuScreens.register(COBBLESTONE_GENERATOR, ::CobblerScreen) MenuScreens.register(ESSENCE_STORAGE, ::EssenceStorageScreen) - MenuScreens.register(ITEM_REPAIER, ::ItemRepairerScreen) + MenuScreens.register(ITEM_REPAIER, ::MatterReconstructorScreen) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index 205d773c2..81bdd5794 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -23,7 +23,7 @@ object MNames { const val MATTER_PANEL = "matter_panel" const val MATTER_REPLICATOR = "matter_replicator" const val MATTER_BOTTLER = "matter_bottler" - const val ITEM_REPAIRER = "item_repairer" + const val MATTER_RECONSTRUCTOR = "item_repairer" const val DRIVE_VIEWER = "drive_viewer" const val DRIVE_RACK = "drive_rack" const val ITEM_MONITOR = "item_monitor" From 65c9a83b81e6d641049f496ea64caa28de32520d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Mar 2023 00:34:32 +0700 Subject: [PATCH 0435/1199] optimize imports --- .../ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt | 9 --------- .../kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt | 2 -- 2 files changed, 11 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index b2c7d1146..4a5546942 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -6,15 +6,6 @@ import net.minecraft.world.level.block.state.properties.DoubleBlockHalf import net.minecraft.world.level.storage.loot.entries.LootItem import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets import net.minecraft.world.level.storage.loot.predicates.ExplosionCondition -import ru.dbotthepony.mc.otm.block.entity.tech.ChemicalGeneratorBlockEntity -import ru.dbotthepony.mc.otm.block.entity.tech.EnergyCounterBlockEntity -import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity.Companion.ENERGY_KEY -import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity.Companion.MATTER_STORAGE_KEY -import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity.Companion.REDSTONE_CONTROL_KEY -import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity -import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity -import ru.dbotthepony.mc.otm.block.entity.storage.AbstractStorageImportExport.Companion.FILTER_KEY -import ru.dbotthepony.mc.otm.block.entity.storage.StoragePowerSupplierBlockEntity import ru.dbotthepony.mc.otm.datagen.modLocation import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MItems diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index f135411d7..dce283293 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -3,11 +3,9 @@ package ru.dbotthepony.mc.otm.datagen.tags import net.minecraft.tags.BlockTags import net.minecraft.tags.ItemTags import net.minecraft.world.effect.MobEffects -import net.minecraft.world.item.BlockItem import net.minecraft.world.item.Items import net.minecraft.world.item.Tiers import net.minecraft.world.level.block.Blocks -import ru.dbotthepony.mc.otm.datagen.recipes.addCraftingTableRecipes import ru.dbotthepony.mc.otm.registry.MBlockTags import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MItemTags From 9adf18cd76961447d3d5f66bdadc5ad9ab132008 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Mar 2023 00:56:11 +0700 Subject: [PATCH 0436/1199] Use hash map for sideless caps --- .../ru/dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 d8d125c92..b3b4f491f 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 @@ -5,7 +5,6 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import it.unimi.dsi.fastutil.longs.Long2ObjectFunction import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.ObjectArraySet -import it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import net.minecraft.core.BlockPos import net.minecraft.core.Direction @@ -93,7 +92,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc val sides: Map = Collections.unmodifiableMap(_sides) private data class SidelessCap(val cap: T, var optional: LazyOptional) - private val sidelessCaps = Reference2ObjectArrayMap, SidelessCap<*>>() + private val sidelessCaps = Reference2ObjectOpenHashMap, SidelessCap<*>>() protected val tickList = TickList() protected val savetables = Savetables() From d21a4653e1c71aa9f2ef4048553c565f4e34c2b0 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Mar 2023 09:09:46 +0700 Subject: [PATCH 0437/1199] Matter reconstructor proper GUI --- .../matter/MatterReconstructorBlockEntity.kt | 26 ++++++++++++--- .../matter/MatterReconstructorScreen.kt | 16 +++++++++- .../screen/panels/PlayerEquipmentPanel.kt | 10 ++++++ .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 32 ++++++++++++++++--- .../menu/matter/MatterReconstructorMenu.kt | 10 ++++++ .../mc/otm/menu/tech/EnergyServoMenu.kt | 2 +- 6 files changed, 84 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt index bd69bd6a2..9f2ff0552 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt @@ -45,8 +45,13 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) private var repairProgress = 0.0 private var failureChance = 0.0 private var lastItem: Item? = null + private var initialDamage = 0.0 - var canNotWork = false + var visualProgress = 0f + private set + + var isUnableToProcess = false + private set val matter = MatterStorageImpl(::setChangedLight, FlowDirection.INPUT, ::CAPACITY) val energy = WorkerEnergyStorage(::setChangedLight, ENERGY_VALUES) @@ -142,11 +147,15 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) if (lastItem != item.item) { lastItem = item.item repairProgress = 0.0 + initialDamage = item.damageValue.toDouble() + visualProgress = 0f } if (item.isEmpty || !item.isRepairable || !item.isDamaged) { matterPerTick = Decimal.ZERO progressPerTick = 0.0 + initialDamage = 0.0 + visualProgress = 0f } else { if (ALLOW_TO_SKIP_ANVIL && !ONLY_ANVIL) { val matter = MatterManager.get(item.item) @@ -182,6 +191,8 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) } else { matterPerTick = Decimal.ZERO progressPerTick = 0.0 + initialDamage = 0.0 + visualProgress = 0f } } } @@ -191,7 +202,7 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) super.tick() if (!redstoneControl.isBlockedByRedstone) { - canNotWork = false + isUnableToProcess = false val item = repairContainer[0] @@ -205,7 +216,7 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) progressPerTick *= (energy.extractEnergy(multEnergy, true) / multEnergy).toDouble() if (progressPerTick <= 0.0) { - canNotWork = true + isUnableToProcess = true return } } @@ -222,13 +233,13 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) val toDrain = matterPerTick * (progressPerTick / this.progressPerTick) val drain = matter.extractMatterInner(toDrain, true) if (!drain.isPositive) { - canNotWork = true + isUnableToProcess = true return } progressPerTick *= (drain / toDrain).toDouble() if (progressPerTick <= 0.0) { - canNotWork = true + isUnableToProcess = true return } @@ -242,6 +253,11 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) item.damageValue = (item.damageValue - repairProgress.toInt()).coerceAtLeast(0) repairProgress %= 1.0 } + + visualProgress = 1f - ((item.damageValue - repairProgress) / initialDamage).toFloat() + } else { + initialDamage = 0.0 + visualProgress = 0f } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt index 06a2bc1bb..3ca95e957 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt @@ -3,12 +3,18 @@ package ru.dbotthepony.mc.otm.client.screen.matter import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.Dock +import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode +import ru.dbotthepony.mc.otm.client.screen.panels.EntityRendererPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.PlayerEquipmentPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls +import ru.dbotthepony.mc.otm.client.screen.panels.makeCuriosPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.menu.matter.MatterReconstructorMenu class MatterReconstructorScreen(menu: MatterReconstructorMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { @@ -20,9 +26,17 @@ class MatterReconstructorScreen(menu: MatterReconstructorMenu, inventory: Invent BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) - SlotPanel(this, frame, menu.slot, 80f, PROGRESS_SLOT_TOP) + SlotPanel(this, frame, menu.slot, 66f, PROGRESS_SLOT_TOP) + ProgressGaugePanel(this, frame, menu.progress, 37f, PROGRESS_ARROW_TOP) makeDeviceControls(this, frame, redstone = menu.redstoneControl, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig) + makeCuriosPanel(this, frame, menu.equipment.curiosSlots) + + PlayerEquipmentPanel(this, frame, armorSlots = menu.equipment.armorSlots).also { + it.leftSided = false + it.dock = Dock.RIGHT + it.dockResize = DockResizeMode.NONE + } return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/PlayerEquipmentPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/PlayerEquipmentPanel.kt index 08bb2fbc0..2560ad982 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/PlayerEquipmentPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/PlayerEquipmentPanel.kt @@ -74,6 +74,16 @@ open class PlayerEquipmentPanel>( } } + var leftSided: Boolean + get() = armorSlotsStrip.dock == Dock.LEFT + set(value) { + if (value) { + armorSlotsStrip.dock = Dock.LEFT + } else { + armorSlotsStrip.dock = Dock.RIGHT + } + } + companion object { val HEIGHT = EntityRendererPanel.ENTITY_RECTANGLE.height val WIDTH = AbstractSlotPanel.SIZE + EntityRendererPanel.ENTITY_RECTANGLE.width diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index fa3232943..4032c8289 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -680,7 +680,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( private var curiosSlots: ImmutableList>? = null private val equipmentSlots = ArrayList() - fun makeArmorSlots(): List> { + fun makeArmorSlots(mapMoveToExternal: Boolean = false): List> { if (armorSlots != null) { return armorSlots!! } @@ -700,23 +700,45 @@ abstract class MatteryMenu @JvmOverloads protected constructor( addSlot(a) if (b != null) addSlot(b) + if (mapMoveToExternal) { + mapQuickMoveToExternal(a) + } + mapQuickMoveToInventory(a) - if (b != null) mapQuickMoveToInventory(b) + + if (b != null) { + if (mapMoveToExternal) { + mapQuickMoveToExternal(b) + } + + mapQuickMoveToInventory(b) + } } } } - fun makeEquipmentSlots(): EquipmentSlots { + fun makeEquipmentSlots(mapMoveToExternal: Boolean = false): EquipmentSlots { return EquipmentSlots( - armorSlots = makeArmorSlots(), + armorSlots = makeArmorSlots(mapMoveToExternal), curiosSlots = curiosSlots ?: ImmutableList.copyOf(ply.curiosSlots).also { for ((a, b) in it) { equipmentSlots.add(a) addSlot(a) if (b != null) addSlot(b) + if (mapMoveToExternal) { + mapQuickMoveToExternal(a) + } + mapQuickMoveToInventory(a) - if (b != null) mapQuickMoveToInventory(b) + + if (b != null) { + if (mapMoveToExternal) { + mapQuickMoveToExternal(b) + } + + mapQuickMoveToInventory(b) + } } }.also { curiosSlots = it } ) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt index a742e28e9..9a296b8cc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt @@ -11,6 +11,7 @@ import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus class MatterReconstructorMenu( @@ -25,6 +26,9 @@ class MatterReconstructorMenu( } } + val equipment = makeEquipmentSlots(mapMoveToExternal = true) + val progress: ProgressGaugeWidget + val redstoneControl = EnumInputWithFeedback(this) val energyConfig = EnergyPlayerInput(this) val itemConfig = ItemHandlerPlayerInput(this) @@ -38,5 +42,11 @@ class MatterReconstructorMenu( itemConfig.configure(tile.itemConfig) energyConfig.configure(tile.energyConfig) } + + if (tile == null) { + progress = ProgressGaugeWidget(this) + } else { + progress = ProgressGaugeWidget(this, tile::visualProgress, tile::isUnableToProcess) + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt index 312d8c029..a21b60f6a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt @@ -31,7 +31,7 @@ class EnergyServoMenu @JvmOverloads constructor( } } - val equipment = makeEquipmentSlots() + val equipment = makeEquipmentSlots(mapMoveToExternal = true) val powerGauge = LevelGaugeWidget(this, tile?.energy) val itemConfig = ItemHandlerPlayerInput(this) From 0902c445f69c5fbe743696f5ff181c5a6ad37b72 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Mar 2023 09:16:11 +0700 Subject: [PATCH 0438/1199] Avoid excessive re-checks at the same tick --- .../block/entity/matter/MatterReconstructorBlockEntity.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt index 9f2ff0552..7fcf7bcf5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt @@ -137,13 +137,18 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) matterNode.discover(this) } + private var changeset = 0 + private fun containerChanged() { matterPerTick = Decimal.ZERO progressPerTick = 0.0 val item = repairContainer[0] + val thisChangeset = ++changeset tickList.once { + if (thisChangeset != changeset) return@once + if (lastItem != item.item) { lastItem = item.item repairProgress = 0.0 From 6cc5659c4335a5d1adafafe63c2c3ddbaf1a9de4 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Mar 2023 11:33:27 +0700 Subject: [PATCH 0439/1199] Make menu widgets be just containers for synchronized fields --- .../widget/HorizontalPowerGaugePanel.kt | 8 +-- .../client/screen/widget/MatterGaugePanel.kt | 14 ++--- .../client/screen/widget/PatternGaugePanel.kt | 6 +- .../client/screen/widget/PowerGaugePanel.kt | 6 +- .../screen/widget/ProgressGaugePanel.kt | 14 ++--- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 31 ---------- .../mc/otm/menu/MatteryPoweredMenu.kt | 2 +- .../mc/otm/menu/matter/MatterBottlerMenu.kt | 20 +++---- .../menu/matter/MatterCapacitorBankMenu.kt | 13 ++-- .../otm/menu/matter/MatterDecomposerMenu.kt | 12 ++-- .../menu/matter/MatterReconstructorMenu.kt | 8 +-- .../mc/otm/menu/matter/MatterRecyclerMenu.kt | 23 +++----- .../otm/menu/matter/MatterReplicatorMenu.kt | 10 +--- .../mc/otm/menu/matter/MatterScannerMenu.kt | 11 ++-- .../mc/otm/menu/matter/PatternStorageMenu.kt | 13 ++-- .../mc/otm/menu/tech/ChemicalGeneratorMenu.kt | 9 ++- .../mc/otm/menu/tech/CobblerMenu.kt | 10 ++-- .../mc/otm/menu/tech/PlatePressMenu.kt | 3 +- .../mc/otm/menu/widget/AbstractWidget.kt | 10 ---- .../mc/otm/menu/widget/LevelGaugeWidget.kt | 59 +++++++++++-------- .../mc/otm/menu/widget/ProgressGaugeWidget.kt | 39 +++++++----- 21 files changed, 136 insertions(+), 185 deletions(-) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/AbstractWidget.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt index 2cf60554e..e04e54281 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt @@ -22,21 +22,21 @@ open class HorizontalPowerGaugePanel( if (height >= 18f) { if (flop) { GAUGE_BACKGROUND_TALL.render(stack, height = height, width = this.width, winding = UVWindingOrder.U1_V0_U0_V1) - val width = this.width * widget.percentage() + val width = this.width * widget.percentage GAUGE_FOREGROUND_TALL.renderPartial(stack, x = this.width - width, height = height, width = width, winding = UVWindingOrder.U1_V0_U0_V1) } else { GAUGE_BACKGROUND_TALL.render(stack, height = height, width = this.width) - val width = this.width * widget.percentage() + val width = this.width * widget.percentage GAUGE_FOREGROUND_TALL.renderPartial(stack, height = height, width = width) } } else { if (flop) { GAUGE_BACKGROUND.render(stack, height = height, width = this.width, winding = UVWindingOrder.U1_V0_U0_V1) - val width = this.width * widget.percentage() + val width = this.width * widget.percentage GAUGE_FOREGROUND.renderPartial(stack, x = this.width - width, height = height, width = width, winding = UVWindingOrder.U1_V0_U0_V1) } else { GAUGE_BACKGROUND.render(stack, height = height, width = this.width) - val width = this.width * widget.percentage() + val width = this.width * widget.percentage GAUGE_FOREGROUND.renderPartial(stack, height = height, width = width) } } 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 2e8eed2b5..64072038c 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 @@ -43,9 +43,9 @@ open class MatterGaugePanel @JvmOverloads constructor( return mutableListOf( TranslatableComponent( "otm.gui.matter.percentage_level", - String.format("%.2f", widget.percentage() * 100.0) + String.format("%.2f", widget.percentage * 100.0) ), - formatMatterLevel(widget.level(), widget.maxLevel(), formatAsReadable = ShiftPressedCond) + formatMatterLevel(widget.level, widget.maxLevel, formatAsReadable = ShiftPressedCond) ) } @@ -54,22 +54,22 @@ open class MatterGaugePanel @JvmOverloads constructor( lastAbsoluteX = absoluteX lastAbsoluteY = absoluteY lastDraw = nanoTime - lastLevel = widget.percentage() + lastLevel = widget.percentage } else { - val diff = ((lastAbsoluteX - absoluteX).pow(2f) + (lastAbsoluteY - absoluteY).pow(2f)).pow(0.5f) / 10f + (lastLevel - widget.percentage()).absoluteValue * 1.5f + val diff = ((lastAbsoluteX - absoluteX).pow(2f) + (lastAbsoluteY - absoluteY).pow(2f)).pow(0.5f) / 10f + (lastLevel - widget.percentage).absoluteValue * 1.5f lastAbsoluteX = absoluteX lastAbsoluteY = absoluteY wavesStrength = (wavesStrength + diff - (nanoTime - lastDraw) / 400_000_000f).coerceAtLeast(0.5f).coerceAtMost(16f) lastDraw = nanoTime - lastLevel = widget.percentage() + lastLevel = widget.percentage } GAUGE_BACKGROUND.render(stack) - val height = this.height * (1f - widget.percentage()) + val height = this.height * (1f - widget.percentage) - if (widget.percentage() > 0.01f) { + if (widget.percentage > 0.01f) { RenderSystem.setShader(GameRenderer::getPositionTexShader) RenderSystem.enableTexture() RenderSystem.enableBlend() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PatternGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PatternGaugePanel.kt index 69ceb56f2..1c7f8d339 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PatternGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PatternGaugePanel.kt @@ -23,15 +23,15 @@ open class PatternGaugePanel @JvmOverloads constructor( return mutableListOf( TranslatableComponent( "otm.gui.pattern.percentage_level", - String.format("%.2f", widget.percentage() * 100.0) + String.format("%.2f", widget.percentage * 100.0) ), - TranslatableComponent("otm.gui.pattern.format", widget.level().toString(0), widget.maxLevel().toString(0)) + TranslatableComponent("otm.gui.pattern.format", widget.level.toString(0), widget.maxLevel.toString(0)) ) } override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { GAUGE_BACKGROUND.render(stack) - val height = this.height * widget.percentage() + val height = this.height * widget.percentage GAUGE_FOREGROUND.renderPartial(stack, y = this.height - height, height = height) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt index 1f248a14c..1f955c3d7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt @@ -25,13 +25,13 @@ open class PowerGaugePanel @JvmOverloads constructor( protected open fun makeTooltip(): MutableList { return mutableListOf( - TranslatableComponent("otm.gui.power.percentage_level", String.format("%.2f", widget.percentage() * 100.0)), - formatPowerLevel(widget.level(), widget.maxLevel(), formatAsReadable = ShiftPressedCond) + TranslatableComponent("otm.gui.power.percentage_level", String.format("%.2f", widget.percentage * 100.0)), + formatPowerLevel(widget.level, widget.maxLevel, formatAsReadable = ShiftPressedCond) ) } override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - val height = this.height * widget.percentage() + val height = this.height * widget.percentage if (width >= 18f) { GAUGE_BACKGROUND_WIDE.render(stack, width = width, height = this.height) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt index 530506aa3..31ffc38ed 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt @@ -28,11 +28,11 @@ open class ProgressGaugePanel @JvmOverloads constructor( protected open fun makeTooltip(): MutableList { val tooltip: MutableList - if (widget.isStuck()) { + if (widget.isStuck) { tooltip = mutableListOf( TranslatableComponent( "otm.gui.progress_widget", - String.format("%.2f", widget.percentage() * 100f) + String.format("%.2f", widget.percentage * 100f) ), TranslatableComponent("otm.gui.progress_widget_stuck").withStyle(ChatFormatting.DARK_RED) ) @@ -40,7 +40,7 @@ open class ProgressGaugePanel @JvmOverloads constructor( tooltip = mutableListOf( TranslatableComponent( "otm.gui.progress_widget", - String.format("%.2f", widget.percentage() * 100f) + String.format("%.2f", widget.percentage * 100f) ) ) } @@ -49,21 +49,21 @@ open class ProgressGaugePanel @JvmOverloads constructor( } override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - if (widget.isStuck() && tickCount % 40 <= 20) { + if (widget.isStuck && tickCount % 40 <= 20) { RenderSystem.setShaderColor(0.75f, 0.4f, 0.4f, 1f) } if (flop) { GAUGE_BACKGROUND.render(stack, height = height, width = this.width, winding = UVWindingOrder.U1_V0_U0_V1) - val width = (this.width * widget.percentage()).roundToInt().toFloat() + val width = (this.width * widget.percentage).roundToInt().toFloat() GAUGE_FOREGROUND.renderPartial(stack, x = this.width - width, height = height, width = width, winding = UVWindingOrder.U1_V0_U0_V1) } else { GAUGE_BACKGROUND.render(stack, height = height, width = this.width) - val width = (this.width * widget.percentage()).roundToInt().toFloat() + val width = (this.width * widget.percentage).roundToInt().toFloat() GAUGE_FOREGROUND.renderPartial(stack, height = height, width = width) } - if (widget.isStuck() && tickCount % 40 <= 20) { + if (widget.isStuck && tickCount % 40 <= 20) { RenderSystem.setShaderColor(1f, 1f, 1f, 1f) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 4032c8289..d2cb0f0a3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -36,7 +36,6 @@ import ru.dbotthepony.mc.otm.core.util.IStreamCodec import ru.dbotthepony.mc.otm.core.util.ItemValueCodec import ru.dbotthepony.mc.otm.core.util.NullValueCodec import ru.dbotthepony.mc.otm.core.util.VarIntValueCodec -import ru.dbotthepony.mc.otm.menu.widget.AbstractWidget import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer import ru.dbotthepony.mc.otm.network.synchronizer.IField import ru.dbotthepony.mc.otm.network.MatteryPacket @@ -74,9 +73,6 @@ abstract class MatteryMenu @JvmOverloads protected constructor( val mSynchronizer = FieldSynchronizer() val ply: Player get() = inventory.player - private val _matteryWidgets = ArrayList() - val matteryWidgets: List = Collections.unmodifiableList(_matteryWidgets) - private val _playerInventorySlots = ArrayList() private val _playerInventorySlots2 = ArrayList() private val _playerHotbarSlots = ArrayList() @@ -223,25 +219,6 @@ abstract class MatteryMenu @JvmOverloads protected constructor( return result } - fun addWidget(widget: AbstractWidget): Int { - val indexOf = _matteryWidgets.indexOf(widget) - - if (indexOf == -1) { - _matteryWidgets.add(widget) - return _matteryWidgets.size - 1 - } - - return indexOf - } - - fun getWidget(index: Int): AbstractWidget? { - if (index !in _matteryWidgets.indices) { - return null - } - - return _matteryWidgets[index] - } - open inner class InventorySlot(container: Container, index: Int, x: Int = 0, y: Int = 0) : UserFilteredSlot(container, index, x, y) { override fun mayPlace(itemStack: ItemStack): Boolean { return !isInventorySlotLocked(index) && super.mayPlace(itemStack) @@ -351,10 +328,6 @@ abstract class MatteryMenu @JvmOverloads protected constructor( } override fun broadcastChanges() { - for (widget in _matteryWidgets) { - widget.updateServer() - } - val payload = mSynchronizer.collectNetworkPayload() if (payload != null) { @@ -375,10 +348,6 @@ abstract class MatteryMenu @JvmOverloads protected constructor( } override fun broadcastFullState() { - for (widget in _matteryWidgets) { - widget.updateServer() - } - mSynchronizer.invalidate() val payload = mSynchronizer.collectNetworkPayload() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt index 844cd97be..95f99d198 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt @@ -18,7 +18,7 @@ abstract class MatteryPoweredMenu protected constructor( ) : MatteryMenu(menuType, containerID, inventory, tile) { val powerWidget = LevelGaugeWidget(this, tile?.matteryEnergy) val batterySlot = BatterySlot(tile?.batteryContainer ?: SimpleContainer(1), 0) - val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java) + val redstone = EnumInputWithFeedback(this) init { if (tile != null) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt index ec591c7c7..dd089b9ed 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt @@ -23,24 +23,18 @@ class MatterBottlerMenu @JvmOverloads constructor( ) : MatteryPoweredMenu( MMenus.MATTER_BOTTLER, p_38852_, inventory, tile ) { - val workFlow: BooleanInputWithFeedback - - val progressWidget: ProgressGaugeWidget - val matterWidget: LevelGaugeWidget - + val workFlow = BooleanInputWithFeedback(this) + val progressWidget = ProgressGaugeWidget(this) + val matterWidget = LevelGaugeWidget(this) val storageSlots: List init { val container = tile?.container ?: SimpleContainer(6) - if (tile == null) { - progressWidget = ProgressGaugeWidget(this) - matterWidget = LevelGaugeWidget(this) - workFlow = BooleanInputWithFeedback(this) - } else { - progressWidget = ProgressGaugeWidget(this) { tile.getWorkProgress() } - matterWidget = LevelGaugeWidget(this, tile.matter) - workFlow = BooleanInputWithFeedback(this, tile::isBottling) + if (tile != null) { + progressWidget.with(tile::getWorkProgress) + matterWidget.with(tile.matter) + workFlow.with(tile::isBottling) } storageSlots = immutableList(6) { index -> diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterCapacitorBankMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterCapacitorBankMenu.kt index 6582c186a..c8ca49197 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterCapacitorBankMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterCapacitorBankMenu.kt @@ -17,18 +17,15 @@ class MatterCapacitorBankMenu @JvmOverloads constructor( ) : MatteryMenu( MMenus.MATTER_CAPACITOR_BANK, p_38852_, inventory, tile ) { - val matterGauge: LevelGaugeWidget - val totalMatterGauge: LevelGaugeWidget + val matterGauge = LevelGaugeWidget(this) + val totalMatterGauge = LevelGaugeWidget(this) val storageSlots: List init { - if (tile == null) { - matterGauge = LevelGaugeWidget(this) - totalMatterGauge = LevelGaugeWidget(this) - } else { - matterGauge = LevelGaugeWidget(this, tile) - totalMatterGauge = LevelGaugeWidget(this, { + if (tile != null) { + matterGauge.with(tile) + totalMatterGauge.with({ tile.matterNode.graph.getMatterStorageLevel() }, { tile.matterNode.graph.getMatterStorageMaxLevel() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt index cbe45dfdc..7050d6813 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt @@ -25,8 +25,8 @@ class MatterDecomposerMenu @JvmOverloads constructor( val input: MatterySlot val outputMain: MachineOutputSlot val outputStacking: MachineOutputSlot - val progressWidget: ProgressGaugeWidget - val matterWidget: LevelGaugeWidget + val progressWidget = ProgressGaugeWidget(this) + val matterWidget = LevelGaugeWidget(this, tile?.getCapability(MatteryCapability.MATTER)?.orNull()) init { val container = tile?.container ?: SimpleContainer(3) @@ -40,12 +40,8 @@ class MatterDecomposerMenu @JvmOverloads constructor( outputMain = MachineOutputSlot(container, 1) outputStacking = MachineOutputSlot(container, 2) - matterWidget = LevelGaugeWidget(this, tile?.getCapability(MatteryCapability.MATTER)?.orNull()) - - if (tile == null) { - progressWidget = ProgressGaugeWidget(this) - } else { - progressWidget = ProgressGaugeWidget(this, tile::workProgress, tile::isUnableToProcess) + if (tile != null) { + progressWidget.with(tile::workProgress, tile::isUnableToProcess) } addStorageSlot(outputMain) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt index 9a296b8cc..c57423d91 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt @@ -27,7 +27,7 @@ class MatterReconstructorMenu( } val equipment = makeEquipmentSlots(mapMoveToExternal = true) - val progress: ProgressGaugeWidget + val progress = ProgressGaugeWidget(this) val redstoneControl = EnumInputWithFeedback(this) val energyConfig = EnergyPlayerInput(this) @@ -43,10 +43,8 @@ class MatterReconstructorMenu( energyConfig.configure(tile.energyConfig) } - if (tile == null) { - progress = ProgressGaugeWidget(this) - } else { - progress = ProgressGaugeWidget(this, tile::visualProgress, tile::isUnableToProcess) + if (tile != null) { + progress.with(tile::visualProgress, tile::isUnableToProcess) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt index b025ddf03..55d216cce 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt @@ -16,23 +16,18 @@ class MatterRecyclerMenu @JvmOverloads constructor( inventory: Inventory, tile: MatterRecyclerBlockEntity? = null ) : MatteryPoweredMenu(MMenus.MATTER_RECYCLER, containerID, inventory, tile) { - val input: MatterySlot - val progress: ProgressGaugeWidget + val input = object : MatterySlot(tile?.container ?: SimpleContainer(1), 0) { + override fun mayPlace(itemStack: ItemStack): Boolean { + return itemStack.item is MatterDustItem && (itemStack.item as MatterDustItem).getMatterValue(itemStack) != null + } + } + + val progress = ProgressGaugeWidget(this) val matter = LevelGaugeWidget(this, tile?.matter) init { - val container = tile?.container ?: SimpleContainer(1) - - input = object : MatterySlot(container, 0) { - override fun mayPlace(itemStack: ItemStack): Boolean { - return itemStack.item is MatterDustItem && (itemStack.item as MatterDustItem).getMatterValue(itemStack) != null - } - } - - if (tile == null) { - progress = ProgressGaugeWidget(this) - } else { - progress = ProgressGaugeWidget(this, tile::workProgress, tile::isUnableToProcess) + if (tile != null) { + progress.with(tile::workProgress, tile::isUnableToProcess) } addStorageSlot(input) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt index 71350a85a..f44597064 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt @@ -18,8 +18,8 @@ class MatterReplicatorMenu @JvmOverloads constructor( ) : MatteryPoweredMenu( MMenus.MATTER_REPLICATOR, p_38852_, inventory, tile ) { - val matter: LevelGaugeWidget - val progress: ProgressGaugeWidget + val matter = LevelGaugeWidget(this, tile?.matter) + val progress = ProgressGaugeWidget(this) val storageSlots: List init { @@ -30,11 +30,7 @@ class MatterReplicatorMenu @JvmOverloads constructor( } if (tile != null) { - matter = LevelGaugeWidget(this, tile.matter) - progress = ProgressGaugeWidget(this, tile::workProgress, tile::isUnableToProcess) - } else { - matter = LevelGaugeWidget(this) - progress = ProgressGaugeWidget(this) + progress.with(tile::workProgress, tile::isUnableToProcess) } addInventorySlots() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt index e218d2630..c8dbf3f0d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt @@ -21,8 +21,8 @@ class MatterScannerMenu @JvmOverloads constructor( MMenus.MATTER_SCANNER, p_38852_, inventory, tile ) { val input: MatterySlot - val progress: ProgressGaugeWidget - val patterns: LevelGaugeWidget + val progress = ProgressGaugeWidget(this) + val patterns = LevelGaugeWidget(this) init { val container = tile?.container ?: SimpleContainer(1) @@ -34,13 +34,10 @@ class MatterScannerMenu @JvmOverloads constructor( addStorageSlot(input) if (tile != null) { - progress = ProgressGaugeWidget(this, tile::workProgress, tile::isUnableToProcess) - patterns = LevelGaugeWidget(this, + progress.with(tile::workProgress, tile::isUnableToProcess) + patterns.with( { Decimal(tile.matterNode.graph.patternCount) }, { Decimal(tile.matterNode.graph.patternCapacity) }) - } else { - progress = ProgressGaugeWidget(this) - patterns = LevelGaugeWidget(this) } addInventorySlots() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt index a5163cd6a..6de88f8b0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt @@ -17,18 +17,15 @@ class PatternStorageMenu @JvmOverloads constructor( ) : MatteryMenu( MMenus.PATTERN_STORAGE, p_38852_, inventory, tile ) { - val storedThis: LevelGaugeWidget - val storedGrid: LevelGaugeWidget + val storedThis = LevelGaugeWidget(this) + val storedGrid = LevelGaugeWidget(this) val storageSlots: List init { - if (tile == null) { - storedThis = LevelGaugeWidget(this) - storedGrid = LevelGaugeWidget(this) - } else { - storedThis = LevelGaugeWidget(this, tile) - storedGrid = LevelGaugeWidget(this, { + if (tile != null) { + storedThis.with(tile) + storedGrid.with({ Decimal(tile.matterNode.graph.patternCount) }, { Decimal(tile.matterNode.graph.patternCapacity) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt index d164355ab..8cf626104 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt @@ -54,14 +54,18 @@ class ChemicalGeneratorMenu @JvmOverloads constructor(id: Int, inv: Inventory, t } } - val progress = ProgressGaugeWidget(this) { 1f - tile!!.workTicks.toFloat() / tile.workTicksTotal } + val progress = ProgressGaugeWidget(this) val energy = LevelGaugeWidget(this, tile?.energy) - var burnTime by mSynchronizer.int() + var burnTime by mSynchronizer.int().property init { addStorageSlot(fuelSlot) addStorageSlot(batterySlot) addStorageSlot(residueSlot) + + if (tile != null) { + progress.with { 1f - tile.workTicks.toFloat() / tile.workTicksTotal } + } } init { @@ -70,7 +74,6 @@ class ChemicalGeneratorMenu @JvmOverloads constructor(id: Int, inv: Inventory, t override fun broadcastChanges() { super.broadcastChanges() - progress.updateServer() burnTime = (tile as ChemicalGeneratorBlockEntity).workTicks } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt index 0602bbf95..6dda03a43 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt @@ -19,15 +19,13 @@ class CobblerMenu @JvmOverloads constructor( ) : MatteryMenu(MMenus.COBBLESTONE_GENERATOR, p_38852_, inventory, tile) { val storageSlots = (tile?.container ?: SimpleContainer(CobblerBlockEntity.CONTAINER_SIZE)).let { c -> immutableList(c.containerSize) { addStorageSlot(MachineOutputSlot(c, it)) } } val redstone = EnumInputWithFeedback(this) - val itemConfig = ItemHandlerPlayerInput(this, false, false) + val itemConfig = ItemHandlerPlayerInput(this) - val progress: ProgressGaugeWidget + val progress = ProgressGaugeWidget(this) init { - if (tile == null) - progress = ProgressGaugeWidget(this) - else { - progress = ProgressGaugeWidget(this, tile::workProgress, tile::isUnableToProcess) + if (tile != null) { + progress.with(tile::workProgress, tile::isUnableToProcess) redstone.with(tile.redstoneControl::redstoneSetting) itemConfig.configure(tile.itemConfig) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt index 512bfae03..8893a870c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt @@ -20,7 +20,7 @@ class PlatePressMenu @JvmOverloads constructor( val inputSlot = MatterySlot(tile?.inputContainer ?: SimpleContainer(1), 0) val outputSlot = MachineOutputSlot(tile?.outputContainer ?: SimpleContainer(1), 0) { tile?.popExperience(ply as ServerPlayer) } - val progressGauge = if (tile != null) ProgressGaugeWidget(this, tile::workProgress, tile::isUnableToProcess) else ProgressGaugeWidget(this) + val progressGauge = ProgressGaugeWidget(this) val itemConfig = ItemHandlerPlayerInput(this, allowPush = true) val energyConfig = EnergyPlayerInput(this, allowPull = true) @@ -31,6 +31,7 @@ class PlatePressMenu @JvmOverloads constructor( addInventorySlots() if (tile != null) { + progressGauge.with(tile::workProgress, tile::isUnableToProcess) itemConfig.configure(tile.itemConfig) energyConfig.configure(tile.energyConfig) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/AbstractWidget.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/AbstractWidget.kt deleted file mode 100644 index cfd9a6147..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/AbstractWidget.kt +++ /dev/null @@ -1,10 +0,0 @@ -package ru.dbotthepony.mc.otm.menu.widget - -import net.minecraft.world.inventory.ContainerData -import ru.dbotthepony.mc.otm.menu.MatteryMenu - -abstract class AbstractWidget(val menu: MatteryMenu,) { - val slotID: Int = menu.addWidget(this) - - abstract fun updateServer() -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/LevelGaugeWidget.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/LevelGaugeWidget.kt index f2ab00129..5b06f9c59 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/LevelGaugeWidget.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/LevelGaugeWidget.kt @@ -4,46 +4,42 @@ import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage import ru.dbotthepony.mc.otm.capability.matter.IPatternStorage import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.util.DecimalValueCodec import ru.dbotthepony.mc.otm.menu.MatteryMenu @Suppress("unused") -class LevelGaugeWidget(menu: MatteryMenu) : AbstractWidget(menu) { +class LevelGaugeWidget(menu: MatteryMenu) { var levelProvider = { Decimal.ONE } var maxLevelProvider = { Decimal.ONE } - var level by menu.mSynchronizer.fraction() - private set - var maxLevel by menu.mSynchronizer.fraction() - private set + val level by menu.mSynchronizer.ComputedField(getter = { levelProvider.invoke() }, codec = DecimalValueCodec) + val maxLevel by menu.mSynchronizer.ComputedField(getter = { maxLevelProvider.invoke() }, codec = DecimalValueCodec) constructor( menu: MatteryMenu, power: IMatteryEnergyStorage? ) : this(menu) { - if (power == null) return - - this.levelProvider = power::batteryLevel - this.maxLevelProvider = power::maxBatteryLevel + if (power != null) { + with(power) + } } constructor( menu: MatteryMenu, matter: IMatterStorage? ) : this(menu) { - if (matter == null) return - - this.levelProvider = matter::storedMatter - this.maxLevelProvider = matter::maxStoredMatter + if (matter != null) { + with(matter) + } } constructor( menu: MatteryMenu, patterns: IPatternStorage? ) : this(menu) { - if (patterns == null) return - - this.levelProvider = { Decimal(patterns.storedPatterns) } - this.maxLevelProvider = { Decimal(patterns.patternCapacity) } + if (patterns != null) { + with(patterns) + } } constructor( @@ -55,12 +51,29 @@ class LevelGaugeWidget(menu: MatteryMenu) : AbstractWidget(menu) { this.maxLevelProvider = maxLevel } - override fun updateServer() { - level = levelProvider.invoke() - maxLevel = maxLevelProvider.invoke() + val percentage: Float get() = level.percentage(maxLevel) + + fun with(level: () -> Decimal, maxLevel: () -> Decimal): LevelGaugeWidget { + this.levelProvider = level + this.maxLevelProvider = maxLevel + return this } - fun level(): Decimal = level - fun maxLevel(): Decimal = maxLevel - fun percentage(): Float = level.percentage(maxLevel) + fun with(patterns: IPatternStorage): LevelGaugeWidget { + this.levelProvider = { Decimal(patterns.storedPatterns) } + this.maxLevelProvider = { Decimal(patterns.patternCapacity) } + return this + } + + fun with(power: IMatteryEnergyStorage): LevelGaugeWidget { + this.levelProvider = power::batteryLevel + this.maxLevelProvider = power::maxBatteryLevel + return this + } + + fun with(matter: IMatterStorage): LevelGaugeWidget { + this.levelProvider = matter::storedMatter + this.maxLevelProvider = matter::maxStoredMatter + return this + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt index 148a968e9..5b6560a2c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt @@ -1,35 +1,42 @@ package ru.dbotthepony.mc.otm.menu.widget +import mekanism.api.functions.FloatSupplier import ru.dbotthepony.mc.otm.menu.MatteryMenu +import java.util.function.BooleanSupplier @Suppress("unused") -class ProgressGaugeWidget(menu: MatteryMenu) : AbstractWidget(menu) { - var progress = {0f} - var stuck = {false} - var progressContainer by menu.mSynchronizer.short() - var stuckContainer by menu.mSynchronizer.bool().property +class ProgressGaugeWidget(menu: MatteryMenu) { + var progressSupplier: FloatSupplier = FloatSupplier { 0f } + var stuckSupplier: BooleanSupplier = BooleanSupplier { false } + + val percentage by menu.mSynchronizer.ComputedFloatField(getter = { progressSupplier.asFloat }) + val isStuck by menu.mSynchronizer.ComputedBooleanField(getter = { stuckSupplier.asBoolean }) constructor( menu: MatteryMenu, - progress: () -> Float + progress: FloatSupplier ) : this(menu) { - this.progress = progress + this.progressSupplier = progress } constructor( menu: MatteryMenu, - progress: () -> Float, - stuck: () -> Boolean, + progress: FloatSupplier, + stuck: BooleanSupplier, ) : this(menu) { - this.progress = progress - this.stuck = stuck + this.progressSupplier = progress + this.stuckSupplier = stuck } - override fun updateServer() { - progressContainer = (Math.max(Math.min(progress.invoke(), 1f), 0f) * 10_000f).toInt().toShort() - stuckContainer = stuck.invoke() + fun with(progress: FloatSupplier): ProgressGaugeWidget { + this.progressSupplier = progress + this.stuckSupplier = BooleanSupplier { false } + return this } - fun isStuck(): Boolean = stuckContainer - fun percentage(): Float = progressContainer / 10_000f + fun with(progress: FloatSupplier, stuck: BooleanSupplier): ProgressGaugeWidget { + this.progressSupplier = progress + this.stuckSupplier = stuck + return this + } } From 2da70e777fdae19f4228cd2ce175de690322a731 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Mar 2023 12:22:42 +0700 Subject: [PATCH 0440/1199] Use type specific methods --- .../mc/otm/block/entity/MatteryDeviceBlockEntity.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index a30caeb8a..21fedbda6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -201,8 +201,8 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo } }) - var automatePull by synchronizer.bool() - var automatePush by synchronizer.bool() + var automatePull by synchronizer.bool().property + var automatePush by synchronizer.bool().property init { savetables.enum(::energyFlow, "energy_${side}_flow", FlowDirection::valueOf) @@ -336,7 +336,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo }) var automatePull by synchronizer.bool(setter = { value, access, _ -> - if (access.read() != value) { + if (access.readBoolean() != value) { access.write(value) if (value) { @@ -344,10 +344,10 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo outerSlotPush = 0 } } - }) + }).property var automatePush by synchronizer.bool(setter = { value, access, _ -> - if (access.read() != value) { + if (access.readBoolean() != value) { access.write(value) if (value) { @@ -355,7 +355,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo outerSlotPush = 0 } } - }) + }).property init { savetables.bool(::automatePull, "itemhandler_${side}_automatePull") From ed04506507962717217a3011c813efbe815d1864 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Mar 2023 20:15:21 +0700 Subject: [PATCH 0441/1199] Add item, energy and redstone configs to rest of machines --- .../block/entity/MatteryDeviceBlockEntity.kt | 32 ++++++++++----- .../matter/MatterDecomposerBlockEntity.kt | 41 ++++++++++--------- .../matter/MatterRecyclerBlockEntity.kt | 26 +++++------- .../matter/MatterReplicatorBlockEntity.kt | 18 ++++---- .../entity/matter/MatterScannerBlockEntity.kt | 17 ++++---- .../matter/PatternStorageBlockEntity.kt | 5 +-- .../entity/tech/AndroidStationBlockEntity.kt | 9 ++-- .../entity/tech/EssenceStorageBlockEntity.kt | 10 +++-- .../screen/decorative/HoloSignScreen.kt | 2 +- .../screen/matter/MatterBottlerScreen.kt | 2 +- .../screen/matter/MatterDecomposerScreen.kt | 2 +- .../matter/MatterReconstructorScreen.kt | 3 +- .../screen/matter/MatterRecyclerScreen.kt | 4 +- .../screen/matter/MatterReplicatorScreen.kt | 4 +- .../screen/matter/MatterScannerScreen.kt | 2 +- .../screen/matter/PatternStorageScreen.kt | 5 ++- .../client/screen/panels/button/Buttons.kt | 4 +- .../client/screen/storage/StorageBusScreen.kt | 2 +- .../screen/storage/StorageExporterScreen.kt | 2 +- .../screen/storage/StorageImporterScreen.kt | 2 +- .../storage/StoragePowerSupplierScreen.kt | 2 +- .../screen/tech/AndroidStationScreen.kt | 2 +- .../client/screen/tech/BatteryBankScreen.kt | 2 +- .../screen/tech/ChemicalGeneratorScreen.kt | 2 +- .../otm/client/screen/tech/CobblerScreen.kt | 2 +- .../client/screen/tech/EnergyCounterScreen.kt | 2 +- .../client/screen/tech/EnergyServoScreen.kt | 2 +- .../screen/tech/EssenceStorageScreen.kt | 3 ++ .../client/screen/tech/PlatePressScreen.kt | 2 +- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 10 +++-- .../mc/otm/menu/MatteryPoweredMenu.kt | 5 +-- .../mc/otm/menu/input/EnergyPlayerInput.kt | 8 +++- .../otm/menu/input/ItemHandlerPlayerInput.kt | 10 ++++- .../otm/menu/matter/MatterDecomposerMenu.kt | 28 ++++++------- .../menu/matter/MatterReconstructorMenu.kt | 11 +---- .../mc/otm/menu/matter/MatterRecyclerMenu.kt | 12 +++--- .../otm/menu/matter/MatterReplicatorMenu.kt | 16 ++++---- .../mc/otm/menu/matter/MatterScannerMenu.kt | 11 ++--- .../mc/otm/menu/matter/PatternStorageMenu.kt | 9 ++-- .../mc/otm/menu/tech/AndroidStationMenu.kt | 2 + .../mc/otm/menu/tech/ChemicalGeneratorMenu.kt | 12 +++--- .../mc/otm/menu/tech/EnergyServoMenu.kt | 10 ++--- .../mc/otm/menu/tech/EssenceStorageMenu.kt | 11 ++++- .../mc/otm/menu/tech/PlatePressMenu.kt | 13 ++---- .../mc/otm/menu/widget/ProgressGaugeWidget.kt | 19 ++++++++- 45 files changed, 217 insertions(+), 181 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index 21fedbda6..c12d6d5b1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -221,25 +221,35 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo } inner class ConfigurableItemHandler( - val input: IItemHandler? = null, - val output: IItemHandler? = null, + input: IItemHandler? = null, + output: IItemHandler? = null, inputOutput: IItemHandler? = null, val battery: IItemHandler? = null, - val frontDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.FRONT), - val backDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.BACK), - val leftDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.LEFT), - val rightDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.RIGHT), - val topDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.TOP), - val bottomDefault: ItemHandlerMode = determineDefaultMode(input, output, battery, RelativeSide.BOTTOM), + val frontDefault: ItemHandlerMode = determineDefaultMode(input, output, inputOutput, battery, RelativeSide.FRONT), + val backDefault: ItemHandlerMode = determineDefaultMode(input, output, inputOutput, battery, RelativeSide.BACK), + val leftDefault: ItemHandlerMode = determineDefaultMode(input, output, inputOutput, battery, RelativeSide.LEFT), + val rightDefault: ItemHandlerMode = determineDefaultMode(input, output, inputOutput, battery, RelativeSide.RIGHT), + val topDefault: ItemHandlerMode = determineDefaultMode(input, output, inputOutput, battery, RelativeSide.TOP), + val bottomDefault: ItemHandlerMode = determineDefaultMode(input, output, inputOutput, battery, RelativeSide.BOTTOM), ) { val sideless: IItemHandler val possibleViews: ImmutableSet val inputOutput: IItemHandler? + val input: IItemHandler? + val output: IItemHandler? init { if ((input != null || output != null) && inputOutput != null) throw IllegalArgumentException("Either specify input or/and output separately, or specify inputOutput") + if (inputOutput != null) { + this.input = inputOutput + this.output = inputOutput + } else { + this.input = input + this.output = output + } + val builder = ImmutableSet.Builder() builder.add(ItemHandlerMode.DISABLED) @@ -430,14 +440,14 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo } companion object { - private fun determineDefaultMode(input: IItemHandler?, output: IItemHandler?, battery: IItemHandler?, side: RelativeSide): ItemHandlerMode { + private fun determineDefaultMode(input: IItemHandler?, output: IItemHandler?, inputOutput: IItemHandler?, battery: IItemHandler?, side: RelativeSide): ItemHandlerMode { if (side == RelativeSide.BACK && battery != null) { return ItemHandlerMode.BATTERY } - if (input == null && output == null) { + if (input == null && output == null && inputOutput == null) { return ItemHandlerMode.DISABLED - } else if (input != null && output != null) { + } else if (input != null && output != null || inputOutput != null) { return when (side) { RelativeSide.FRONT, RelativeSide.BACK -> ItemHandlerMode.DISABLED RelativeSide.RIGHT, RelativeSide.TOP -> ItemHandlerMode.INPUT diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index 60fa7ae59..2fb8ecca8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -118,10 +118,10 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) } val energy = WorkerEnergyStorage(this, ENERGY_VALUES) + val energyConfig = ConfigurableEnergy(energy) init { - exposeEnergyGlobally(energy) - savetable(::energy, ENERGY_KEY) + savetables.stateful(::energy, ENERGY_KEY) } val matter = MatterStorageImpl(::setChangedLight, FlowDirection.OUTPUT, ::CAPACITY) @@ -130,25 +130,30 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) init { exposeGlobally(MatteryCapability.MATTER, matter) exposeGlobally(MatteryCapability.MATTER_NODE, matterNode) - savetable(::matter, MATTER_STORAGE_KEY) + savetables.stateful(::matter, MATTER_STORAGE_KEY) } // вход, выход - val container = MatteryContainer(this::setChangedLight, 3).also(::addDroppableContainer) + val inputContainer = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) + val outputContainer = MatteryContainer(::setChangedLight, 2).also(::addDroppableContainer) - val itemHandler = container.handler(object : HandlerFilter { - override fun canInsert(slot: Int, stack: ItemStack): Boolean { - return slot == INPUT_SLOT && MatterManager.canDecompose(stack) - } + val itemConfig = ConfigurableItemHandler( + input = inputContainer.handler(object : HandlerFilter { + override fun canInsert(slot: Int, stack: ItemStack): Boolean { + return MatterManager.canDecompose(stack) + } - override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { - return slot != INPUT_SLOT - } - }) + override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { + return false + } + }), + + output = outputContainer.handler(HandlerFilter.OnlyOut) + ) init { - exposeItemsGlobally(itemHandler) - savetable(::container, INVENTORY_KEY) + savetables.stateful(::inputContainer) + savetables.stateful(::outputContainer) } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { @@ -157,7 +162,7 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) override fun onJobFinish(job: DecomposerJob): Status { if (job.toDust) { - job.matterValue = moveMatterAsDustIntoContainer(job.matterValue, container, OUTPUT_DUST_MAIN, OUTPUT_DUST_STACKING) + job.matterValue = moveMatterAsDustIntoContainer(job.matterValue, outputContainer, 0, 1) if (!job.matterValue.isZero) { return Status.FAILURE_WAIT_FAST @@ -176,7 +181,7 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) } override fun computeNextJob(): Pair { - val stack = container[INPUT_SLOT] + val stack = inputContainer[0] if (!stack.isEmpty) { val copy = stack.copy() @@ -218,10 +223,6 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) } companion object { - const val INPUT_SLOT = 0 - const val OUTPUT_DUST_MAIN = 1 - const val OUTPUT_DUST_STACKING = 2 - val CAPACITY get() = _CAPACITY.get() val BASE_CONSUMPTION get() = _BASE_CONSUMPTION.get() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index 9db761ccd..6625247d8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -64,18 +64,13 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) } } - val matter = MatterStorageImpl( - this::matterLevelUpdated, - FlowDirection.OUTPUT, - ::CAPACITY - ) - - val container = MatteryContainer(this::itemContainerUpdated, 1).also(::addDroppableContainer) + val matter = MatterStorageImpl(::matterLevelUpdated, FlowDirection.OUTPUT, ::CAPACITY) + val container = MatteryContainer(::itemContainerUpdated, 1).also(::addDroppableContainer) val matterNode = SimpleMatterNode(matter = matter) - val energy = WorkerEnergyStorage(this::powerLevelUpdated, ENERGY_CONFIG) + val energy = WorkerEnergyStorage(::powerLevelUpdated, ENERGY_CONFIG) - private val itemHandler = container.handler(object : HandlerFilter { + val itemConfig = ConfigurableItemHandler(input = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { return stack.item is MatterDustItem } @@ -83,16 +78,17 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { return false } - }) + })) + + val energyConfig = ConfigurableEnergy(energy) init { - exposeItemsGlobally(itemHandler) - exposeEnergyGlobally(energy) exposeGlobally(MatteryCapability.MATTER, matter) exposeGlobally(MatteryCapability.MATTER_NODE, matterNode) - savetable(::energy, ENERGY_KEY) - savetable(::container, INVENTORY_KEY) - savetable(::matter, MATTER_STORAGE_KEY) + + savetables.stateful(::energy, ENERGY_KEY) + savetables.stateful(::container, INVENTORY_KEY) + savetables.stateful(::matter, MATTER_STORAGE_KEY) } override fun setRemoved() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index 1206dc3aa..c85da2531 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -99,10 +99,12 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } - val energy = WorkerEnergyStorage(this::powerLevelUpdated, ENERGY_VALUES) - val matter = MatterStorageImpl(this::matterLevelUpdated, FlowDirection.INPUT, ::MATTER_CAPACITY) - val container = MatteryContainer(this::itemContainerUpdated, 5).also(::addDroppableContainer) - val itemHandler = container.handler(HandlerFilter.OnlyOut) + val energy = WorkerEnergyStorage(::powerLevelUpdated, ENERGY_VALUES) + val matter = MatterStorageImpl(::matterLevelUpdated, FlowDirection.INPUT, ::MATTER_CAPACITY) + val container = MatteryContainer(::itemContainerUpdated, 5).also(::addDroppableContainer) + + val energyConfig = ConfigurableEnergy(energy) + val itemConfig = ConfigurableItemHandler(output = container.handler(HandlerFilter.OnlyOut)) val matterNode = object : MatterNode() { override fun getMatterHandler(): IMatterStorage { @@ -129,14 +131,12 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } init { - exposeEnergyGlobally(energy) - exposeItemsGlobally(itemHandler) exposeGlobally(MatteryCapability.MATTER, matter) exposeGlobally(MatteryCapability.MATTER_NODE, matterNode) - savetable(::energy, ENERGY_KEY) - savetable(::matter, MATTER_STORAGE_KEY) - savetable(::container, INVENTORY_KEY) + savetables.stateful(::energy, ENERGY_KEY) + savetables.stateful(::matter, MATTER_STORAGE_KEY) + savetables.stateful(::container, INVENTORY_KEY) } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt index 93b068c2d..7936b0ffd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt @@ -35,9 +35,10 @@ import kotlin.math.pow class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryWorkerBlockEntity(MBlockEntities.MATTER_SCANNER, p_155229_, p_155230_, ::ItemJob) { - val container = MatteryContainer(this::itemContainerUpdated, 1).also(::addDroppableContainer) - val energy = WorkerEnergyStorage(this::powerLevelUpdated, ENERGY_VALUES) - val itemHandler = container.handler(object : HandlerFilter { + val container = MatteryContainer(::itemContainerUpdated, 1).also(::addDroppableContainer) + val energy = WorkerEnergyStorage(::powerLevelUpdated, ENERGY_VALUES) + + val itemConfig = ConfigurableItemHandler(inputOutput = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { return MatterManager.canDecompose(stack) } @@ -45,7 +46,9 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { return isIdling } - }) + })) + + val energyConfig = ConfigurableEnergy(energy) val matterNode = object : MatterNode() { override fun onPatternAdded(state: IPatternState) { @@ -68,12 +71,10 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } init { - exposeItemsGlobally(itemHandler) - exposeEnergyGlobally(energy) exposeGlobally(MatteryCapability.MATTER_NODE, matterNode) - savetable(::container, INVENTORY_KEY) - savetable(::energy, ENERGY_KEY) + savetables.stateful(::container, INVENTORY_KEY) + savetables.stateful(::energy, ENERGY_KEY) } override fun invalidateCaps() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt index 36c49590d..59230312f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt @@ -76,7 +76,7 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } - private val itemHandler = container.handler { slot: Int, stack: ItemStack -> stack.getCapability(MatteryCapability.PATTERN).isPresent } + val itemConfig = ConfigurableItemHandler(inputOutput = container.handler { _: Int, stack: ItemStack -> stack.getCapability(MatteryCapability.PATTERN).isPresent }) override fun setLevel(level: Level) { super.setLevel(level) @@ -91,9 +91,8 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : init { exposeGlobally(MatteryCapability.PATTERN, this) exposeGlobally(MatteryCapability.MATTER_NODE, matterNode) - exposeItemsGlobally(itemHandler) - savetable(::container, INVENTORY_KEY) + savetables.stateful(::container, INVENTORY_KEY) } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt index 212084307..e892a19e2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt @@ -32,9 +32,7 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return AndroidStationMenu(containerID, inventory, this) } - val energy = object : WorkerEnergyStorage(this@AndroidStationBlockEntity::setChangedLight, - AndroidStationBlockEntity.Companion::CAPACITY, - AndroidStationBlockEntity.Companion::MAX_IO, { null }) { + val energy = object : WorkerEnergyStorage(this@AndroidStationBlockEntity::setChangedLight, ::CAPACITY, ::MAX_IO, { null }) { override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { return super.extractEnergy(howMuch, simulate).also { if (!simulate && this.batteryLevel.isZero) { @@ -59,9 +57,10 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } + val energyConfig = ConfigurableEnergy(energy) + init { - exposeEnergyGlobally(energy) - savetable(::energy, ENERGY_KEY) + savetables.stateful(::energy, ENERGY_KEY) } private var tickedOnce = false diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt index 5413f446a..b255cef0c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt @@ -46,11 +46,13 @@ class EssenceStorageBlockEntity(blockPos: BlockPos, blockState: BlockState) : Ma override fun tick() { super.tick() - val capsule = capsuleContainer[0] + if (!redstoneControl.isBlockedByRedstone) { + val capsule = capsuleContainer[0] - if (!capsule.isEmpty && capsule.item is EssenceCapsuleItem) { - experienceStored += EssenceCapsuleItem.experienceStored(capsule) - capsuleContainer.clearContent() + if (!capsule.isEmpty && capsule.item is EssenceCapsuleItem) { + experienceStored += EssenceCapsuleItem.experienceStored(capsule) + capsuleContainer.clearContent() + } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt index 213dba6a2..217ec4f57 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt @@ -25,7 +25,7 @@ class HoloSignScreen(menu: HoloSignMenu, inventory: Inventory, title: Component) lock.dockMargin = DockProperty(2f, 2f, 2f, 2f) lock.tooltip = TranslatableComponent("otm.gui.lock_holo_screen.tip") - makeDeviceControls(this, frame, redstone = menu.redstone) + makeDeviceControls(this, frame, redstoneConfig = menu.redstone) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt index 713119729..e6bd13407 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt @@ -41,7 +41,7 @@ class MatterBottlerScreen(menu: MatterBottlerMenu, inventory: Inventory, title: ButtonPanel(this, frame, 46f, 69f, 100f, 20f, TranslatableComponent("otm.matter_bottler.switch_mode"), onPress = menu.workFlow::switchValue) } - makeDeviceControls(this, frame, redstone = menu.redstone) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt index ab2c64c78..de53ba607 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt @@ -28,7 +28,7 @@ class MatterDecomposerScreen(p_97741_: MatterDecomposerMenu, p_97742_: Inventory SlotPanel(this, frame, menu.outputMain, 74f, PROGRESS_SLOT_TOP) SlotPanel(this, frame, menu.outputStacking, 56f, PROGRESS_SLOT_TOP) - makeDeviceControls(this, frame, redstone = menu.redstone) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt index 3ca95e957..5a15bdecc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt @@ -5,7 +5,6 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode -import ru.dbotthepony.mc.otm.client.screen.panels.EntityRendererPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.PlayerEquipmentPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls @@ -29,7 +28,7 @@ class MatterReconstructorScreen(menu: MatterReconstructorMenu, inventory: Invent SlotPanel(this, frame, menu.slot, 66f, PROGRESS_SLOT_TOP) ProgressGaugePanel(this, frame, menu.progress, 37f, PROGRESS_ARROW_TOP) - makeDeviceControls(this, frame, redstone = menu.redstoneControl, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig) makeCuriosPanel(this, frame, menu.equipment.curiosSlots) PlayerEquipmentPanel(this, frame, armorSlots = menu.equipment.armorSlots).also { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt index beb48e502..cdb8c55ad 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt @@ -13,7 +13,7 @@ import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.menu.matter.MatterRecyclerMenu class MatterRecyclerScreen(menu: MatterRecyclerMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { - override fun makeMainFrame(): FramePanel> { + override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! val m = PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) @@ -24,7 +24,7 @@ class MatterRecyclerScreen(menu: MatterRecyclerMenu, inventory: Inventory, title ProgressGaugePanel(this, frame, menu.progress, 63f, PROGRESS_ARROW_TOP).flop = true SlotPanel(this, frame, menu.input, 93f, PROGRESS_SLOT_TOP) - makeDeviceControls(this, frame, redstone = menu.redstone) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt index 022b961ae..58af3e175 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt @@ -14,7 +14,7 @@ import ru.dbotthepony.mc.otm.menu.matter.MatterReplicatorMenu class MatterReplicatorScreen(p_97741_: MatterReplicatorMenu, p_97742_: Inventory, p_97743_: Component) : MatteryScreen(p_97741_, p_97742_, p_97743_) { - override fun makeMainFrame(): FramePanel> { + override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! val m = PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) @@ -30,7 +30,7 @@ class MatterReplicatorScreen(p_97741_: MatterReplicatorMenu, p_97742_: Inventory SlotPanel(this, frame, menu.storageSlots[3], 80f, PROGRESS_SLOT_TOP + 22f) SlotPanel(this, frame, menu.storageSlots[4], 80f + 18f, PROGRESS_SLOT_TOP + 22f) - makeDeviceControls(this, frame, redstone = menu.redstone) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterScannerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterScannerScreen.kt index 524284ccc..201f208bb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterScannerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterScannerScreen.kt @@ -25,7 +25,7 @@ class MatterScannerScreen(p_97741_: MatterScannerMenu, p_97742_: Inventory, p_97 ProgressGaugePanel(this, frame, menu.progress, 63f, PROGRESS_ARROW_TOP).flop = true SlotPanel(this, frame, menu.input, 93f, PROGRESS_SLOT_TOP) - makeDeviceControls(this, frame, redstone = menu.redstone) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/PatternStorageScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/PatternStorageScreen.kt index e60cf894e..f6ce0456e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/PatternStorageScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/PatternStorageScreen.kt @@ -5,12 +5,13 @@ import ru.dbotthepony.mc.otm.menu.matter.PatternStorageMenu import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.PatternSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.PatternGaugePanel class PatternStorageScreen(p_97741_: PatternStorageMenu, p_97742_: Inventory, p_97743_: Component) : MatteryScreen(p_97741_, p_97742_, p_97743_) { - override fun makeMainFrame(): FramePanel> { + override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! val m = PatternGaugePanel(this, frame, menu.storedThis, LEFT_MARGIN, GAUGE_TOP_WITHOUT_SLOT) @@ -22,6 +23,8 @@ class PatternStorageScreen(p_97741_: PatternStorageMenu, p_97742_: Inventory, p_ for (i in 4 until 8) PatternSlotPanel(this, frame, menu.storageSlots[i], 62f + (i - 4) * 18, 32f + 18f) + makeDeviceControls(this, frame, itemConfig = menu.itemConfig) + return frame } } 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 ef1e43b1f..e6873d5a4 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 @@ -275,9 +275,9 @@ fun > makeDeviceControls( screen: S, parent: FramePanel, extra: Iterable> = listOf(), - redstone: IPlayerInputWithFeedback? = null, + redstoneConfig: IPlayerInputWithFeedback? = null, itemConfig: ItemHandlerPlayerInput? = null, energyConfig: EnergyPlayerInput? = null, ): DeviceControls { - return DeviceControls(screen, parent, extra = extra, redstoneConfig = redstone, itemConfig = itemConfig, energyConfig = energyConfig) + return DeviceControls(screen, parent, extra = extra, redstoneConfig = redstoneConfig, itemConfig = itemConfig, energyConfig = energyConfig) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt index 8d759e8c3..1b9314e50 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt @@ -29,7 +29,7 @@ class StorageBusScreen(menu: StorageBusMenu, inventory: Inventory, title: Compon CheckBoxLabelInputPanel(this, frame, menu.busFilterState, TranslatableComponent("otm.gui.filter.is_whitelist"), 59f, 78f, width = 170f) - makeDeviceControls(this, frame, redstone = menu.redstone) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt index 720e7f8c6..c896eb6e9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt @@ -29,7 +29,7 @@ class StorageExporterScreen(menu: StorageExporterMenu, inventory: Inventory, tit CheckBoxLabelInputPanel(this, frame, menu.busFilterState, TranslatableComponent("otm.gui.filter.is_whitelist"), 59f, 78f, width = 170f) - makeDeviceControls(this, frame, redstone = menu.redstone) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt index 27c850202..19ea22c86 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt @@ -29,7 +29,7 @@ class StorageImporterScreen(menu: StorageImporterMenu, inventory: Inventory, tit CheckBoxLabelInputPanel(this, frame, menu.busFilterState, TranslatableComponent("otm.gui.filter.is_whitelist"), 59f, 78f, width = 170f) - makeDeviceControls(this, frame, redstone = menu.redstone) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt index 5eda45a80..dd113f6e1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt @@ -67,7 +67,7 @@ class StoragePowerSupplierScreen(menu: StoragePowerSupplierMenu, inventory: Inve } } - makeDeviceControls(this, frame, redstone = menu.redstone) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig) return frame } 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 349007b01..d492f5f75 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 @@ -727,7 +727,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I this.playerStrip = playerStrip - makeDeviceControls(this, frame, redstone = menu.redstone) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BatteryBankScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BatteryBankScreen.kt index df622243a..3555ddb66 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BatteryBankScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BatteryBankScreen.kt @@ -23,7 +23,7 @@ class BatteryBankScreen(menu: BatteryBankMenu, p_97742_: Inventory, p_97743_: Co for (i in 6 .. 11) BatterySlotPanel(this, frame, menu.storageSlots[i], 44f + 18 * (i - 6), 32f + 18f) - makeDeviceControls(this, frame, redstone = menu.redstone, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig) + makeDeviceControls(this, frame, redstoneConfig = menu.redstone, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt index 64de1b85b..8f9f7562a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt @@ -34,7 +34,7 @@ class ChemicalGeneratorScreen(menu: ChemicalGeneratorMenu, inventory: Inventory, SlotPanel(this, frame, menu.residueSlot, 56f, PROGRESS_SLOT_TOP) SlotPanel(this, frame, menu.fuelSlot, 104f, PROGRESS_SLOT_TOP) - makeDeviceControls(this, frame, redstone = menu.redstone, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/CobblerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/CobblerScreen.kt index d50eb7f5a..e067b90ba 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/CobblerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/CobblerScreen.kt @@ -20,7 +20,7 @@ class CobblerScreen(menu: CobblerMenu, inventory: Inventory, title: Component) : for (column in 0 .. 2) SlotPanel(this, frame, menu.storageSlots[row * 3 + column], 80f + column * AbstractSlotPanel.SIZE, 26f + row * AbstractSlotPanel.SIZE) - makeDeviceControls(this, frame, redstone = menu.redstone, itemConfig = menu.itemConfig) + makeDeviceControls(this, frame, redstoneConfig = menu.redstone, itemConfig = menu.itemConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt index ee5cb47e1..08845d991 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt @@ -108,7 +108,7 @@ class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title: limitsTab.onClose!!.run() - makeDeviceControls(this, frame, redstone = menu.redstone) + makeDeviceControls(this, frame, redstoneConfig = menu.redstone) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt index d3a0a114e..c167d665d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt @@ -74,7 +74,7 @@ class EnergyServoScreen(menu: EnergyServoMenu, inventory: Inventory, title: Comp it.dockRight } - makeDeviceControls(this, frame, redstone = menu.redstone, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt index 6b199f79b..0ca7b3434 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt @@ -17,6 +17,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.Label import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeRectangleButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.input.TextInputPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.HorizontalStripPanel @@ -246,6 +247,8 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title set(value) {} } + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, itemConfig = menu.itemConfig) + return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt index 9f9c1382b..45b347412 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt @@ -23,7 +23,7 @@ class PlatePressScreen(menu: PlatePressMenu, inventory: Inventory, title: Compon ProgressGaugePanel(this, frame, menu.progressGauge, 78f, PROGRESS_ARROW_TOP) SlotPanel(this, frame, menu.outputSlot, 104f, PROGRESS_SLOT_TOP) - makeDeviceControls(this, frame, redstone = menu.redstone, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index d2cb0f0a3..e0658604f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -13,7 +13,10 @@ import net.minecraft.server.level.ServerPlayer import net.minecraft.world.Container import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player -import net.minecraft.world.inventory.* +import net.minecraft.world.inventory.AbstractContainerMenu +import net.minecraft.world.inventory.InventoryMenu +import net.minecraft.world.inventory.MenuType +import net.minecraft.world.inventory.Slot import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.enchantment.EnchantmentHelper.hasBindingCurse @@ -36,8 +39,6 @@ import ru.dbotthepony.mc.otm.core.util.IStreamCodec import ru.dbotthepony.mc.otm.core.util.ItemValueCodec import ru.dbotthepony.mc.otm.core.util.NullValueCodec import ru.dbotthepony.mc.otm.core.util.VarIntValueCodec -import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer -import ru.dbotthepony.mc.otm.network.synchronizer.IField import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel import ru.dbotthepony.mc.otm.network.MenuFieldPacket @@ -46,13 +47,14 @@ import ru.dbotthepony.mc.otm.network.SetInventoryFilterPacket import ru.dbotthepony.mc.otm.network.enqueueWork import ru.dbotthepony.mc.otm.network.packetHandled import ru.dbotthepony.mc.otm.network.sender +import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer +import ru.dbotthepony.mc.otm.network.synchronizer.IField import java.io.DataInputStream import java.io.DataOutputStream import java.math.BigDecimal import java.util.* import java.util.function.Predicate import java.util.function.Supplier -import kotlin.collections.ArrayList data class PlayerSlot(val functional: A, val cosmetic: B? = null) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt index 95f99d198..5e924f71f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt @@ -6,7 +6,6 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import net.minecraft.world.SimpleContainer import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting -import ru.dbotthepony.mc.otm.capability.matter.matter import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback @@ -18,11 +17,11 @@ abstract class MatteryPoweredMenu protected constructor( ) : MatteryMenu(menuType, containerID, inventory, tile) { val powerWidget = LevelGaugeWidget(this, tile?.matteryEnergy) val batterySlot = BatterySlot(tile?.batteryContainer ?: SimpleContainer(1), 0) - val redstone = EnumInputWithFeedback(this) + val redstoneConfig = EnumInputWithFeedback(this) init { if (tile != null) { - redstone.with(tile.redstoneControl::redstoneSetting) + redstoneConfig.with(tile.redstoneControl::redstoneSetting) } addSlot(batterySlot) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyPlayerInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyPlayerInput.kt index 2a75d9421..a4166cc53 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyPlayerInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyPlayerInput.kt @@ -9,7 +9,7 @@ import ru.dbotthepony.mc.otm.menu.MatteryMenu /** * [allowPull] and [allowPush] controls whenever player is allowed to change these options */ -class EnergyPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = false, val allowPush: Boolean = false) { +class EnergyPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEntity.ConfigurableEnergy<*>? = null, val allowPull: Boolean = false, val allowPush: Boolean = false) { var possibleModes by menu.mSynchronizer.enum(FlowDirection::class.java) private set @@ -59,4 +59,10 @@ class EnergyPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = false, v pull.withConsumer { v -> pieces.values.forEach { it.pull.input.invoke(v) } } push.withConsumer { v -> pieces.values.forEach { it.push.input.invoke(v) } } } + + init { + if (config != null) { + configure(config) + } + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt index 12d721a50..7df8347ce 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt @@ -8,7 +8,7 @@ import ru.dbotthepony.mc.otm.menu.MatteryMenu /** * [allowPull] and [allowPush] controls whenever player is allowed to change these options */ -class ItemHandlerPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = false, val allowPush: Boolean = false) { +class ItemHandlerPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEntity.ConfigurableItemHandler? = null, val allowPull: Boolean = false, val allowPush: Boolean = false) { private val allowedFlags = MatteryDeviceBlockEntity.ItemHandlerMode.values().map { menu.mSynchronizer.bool() to it } fun isAllowed(value: MatteryDeviceBlockEntity.ItemHandlerMode) = allowedFlags[value.ordinal].first.boolean @@ -48,7 +48,7 @@ class ItemHandlerPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = fal fun configure(config: MatteryDeviceBlockEntity.ConfigurableItemHandler) { for ((f, v) in allowedFlags) { - f.value = v in config.possibleViews + f.boolean = v in config.possibleViews } for ((side, v) in config.pieces) { @@ -62,4 +62,10 @@ class ItemHandlerPlayerInput(val menu: MatteryMenu, val allowPull: Boolean = fal pull.withConsumer { v -> pieces.values.forEach { it.pull.input.invoke(v) } } push.withConsumer { v -> pieces.values.forEach { it.push.input.invoke(v) } } } + + init { + if (config != null) { + configure(config) + } + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt index 7050d6813..48db6ca77 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt @@ -9,12 +9,16 @@ import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import net.minecraft.world.SimpleContainer import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.menu.MachineOutputSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput +import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.registry.MMenus class MatterDecomposerMenu @JvmOverloads constructor( @@ -22,27 +26,23 @@ class MatterDecomposerMenu @JvmOverloads constructor( inventory: Inventory, tile: MatterDecomposerBlockEntity? = null ) : MatteryPoweredMenu(MMenus.MATTER_DECOMPOSER, containerID, inventory, tile) { - val input: MatterySlot + val input = object : MatterySlot(tile?.inputContainer ?: SimpleContainer(1), 0) { + override fun mayPlace(itemStack: ItemStack) = MatterManager.canDecompose(itemStack) + } + val outputMain: MachineOutputSlot val outputStacking: MachineOutputSlot - val progressWidget = ProgressGaugeWidget(this) + val progressWidget = ProgressGaugeWidget(this, tile) val matterWidget = LevelGaugeWidget(this, tile?.getCapability(MatteryCapability.MATTER)?.orNull()) + val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) + val energyConfig = EnergyPlayerInput(this, tile?.energyConfig) init { - val container = tile?.container ?: SimpleContainer(3) - - // Вход - input = object : MatterySlot(container, 0) { - override fun mayPlace(itemStack: ItemStack) = MatterManager.canDecompose(itemStack) - } + val container = tile?.outputContainer ?: SimpleContainer(2) // Выход - outputMain = MachineOutputSlot(container, 1) - outputStacking = MachineOutputSlot(container, 2) - - if (tile != null) { - progressWidget.with(tile::workProgress, tile::isUnableToProcess) - } + outputMain = MachineOutputSlot(container, 0) + outputStacking = MachineOutputSlot(container, 1) addStorageSlot(outputMain) addStorageSlot(outputStacking) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt index c57423d91..ac24ea07b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt @@ -29,20 +29,13 @@ class MatterReconstructorMenu( val equipment = makeEquipmentSlots(mapMoveToExternal = true) val progress = ProgressGaugeWidget(this) - val redstoneControl = EnumInputWithFeedback(this) - val energyConfig = EnergyPlayerInput(this) - val itemConfig = ItemHandlerPlayerInput(this) + val energyConfig = EnergyPlayerInput(this, tile?.energyConfig) + val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) init { addStorageSlot(slot) addInventorySlots() - if (tile != null) { - redstoneControl.with(tile.redstoneControl::redstoneSetting) - itemConfig.configure(tile.itemConfig) - energyConfig.configure(tile.energyConfig) - } - if (tile != null) { progress.with(tile::visualProgress, tile::isUnableToProcess) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt index 55d216cce..99e5da69f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt @@ -3,10 +3,14 @@ package ru.dbotthepony.mc.otm.menu.matter import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.block.entity.matter.MatterRecyclerBlockEntity import ru.dbotthepony.mc.otm.item.MatterDustItem import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput +import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -22,14 +26,12 @@ class MatterRecyclerMenu @JvmOverloads constructor( } } - val progress = ProgressGaugeWidget(this) + val progress = ProgressGaugeWidget(this, tile) val matter = LevelGaugeWidget(this, tile?.matter) + val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) + val energyConfig = EnergyPlayerInput(this, tile?.energyConfig) init { - if (tile != null) { - progress.with(tile::workProgress, tile::isUnableToProcess) - } - addStorageSlot(input) addInventorySlots() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt index f44597064..f0ae25d5a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt @@ -6,21 +6,25 @@ import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import net.minecraft.world.SimpleContainer +import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.menu.MachineOutputSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu +import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput +import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.registry.MMenus class MatterReplicatorMenu @JvmOverloads constructor( p_38852_: Int, inventory: Inventory, tile: MatterReplicatorBlockEntity? = null -) : MatteryPoweredMenu( - MMenus.MATTER_REPLICATOR, p_38852_, inventory, tile -) { +) : MatteryPoweredMenu(MMenus.MATTER_REPLICATOR, p_38852_, inventory, tile) { val matter = LevelGaugeWidget(this, tile?.matter) - val progress = ProgressGaugeWidget(this) + val progress = ProgressGaugeWidget(this, tile) val storageSlots: List + val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) + val energyConfig = EnergyPlayerInput(this, tile?.energyConfig) init { val container = tile?.container ?: SimpleContainer(5) @@ -29,10 +33,6 @@ class MatterReplicatorMenu @JvmOverloads constructor( addStorageSlot(MachineOutputSlot(container, it)) } - if (tile != null) { - progress.with(tile::workProgress, tile::isUnableToProcess) - } - addInventorySlots() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt index c8dbf3f0d..1388816c7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt @@ -11,18 +11,20 @@ import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput +import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.registry.MMenus class MatterScannerMenu @JvmOverloads constructor( p_38852_: Int, inventory: Inventory, tile: MatterScannerBlockEntity? = null -) : MatteryPoweredMenu( - MMenus.MATTER_SCANNER, p_38852_, inventory, tile -) { +) : MatteryPoweredMenu(MMenus.MATTER_SCANNER, p_38852_, inventory, tile) { val input: MatterySlot - val progress = ProgressGaugeWidget(this) + val progress = ProgressGaugeWidget(this, tile) val patterns = LevelGaugeWidget(this) + val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) + val energyConfig = EnergyPlayerInput(this, tile?.energyConfig) init { val container = tile?.container ?: SimpleContainer(1) @@ -34,7 +36,6 @@ class MatterScannerMenu @JvmOverloads constructor( addStorageSlot(input) if (tile != null) { - progress.with(tile::workProgress, tile::isUnableToProcess) patterns.with( { Decimal(tile.matterNode.graph.patternCount) }, { Decimal(tile.matterNode.graph.patternCapacity) }) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt index 6de88f8b0..dfd63e482 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt @@ -7,6 +7,7 @@ import ru.dbotthepony.mc.otm.block.entity.matter.PatternStorageBlockEntity import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.PatternSlot +import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -14,17 +15,15 @@ class PatternStorageMenu @JvmOverloads constructor( p_38852_: Int, inventory: Inventory, tile: PatternStorageBlockEntity? = null -) : MatteryMenu( - MMenus.PATTERN_STORAGE, p_38852_, inventory, tile -) { - val storedThis = LevelGaugeWidget(this) +) : MatteryMenu(MMenus.PATTERN_STORAGE, p_38852_, inventory, tile) { + val storedThis = LevelGaugeWidget(this, tile) val storedGrid = LevelGaugeWidget(this) + val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) val storageSlots: List init { if (tile != null) { - storedThis.with(tile) storedGrid.with({ Decimal(tile.matterNode.graph.patternCount) }, { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt index 219bad732..40c50f401 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt @@ -15,6 +15,7 @@ import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput import ru.dbotthepony.mc.otm.registry.MMenus import kotlin.reflect.KMutableProperty0 @@ -113,6 +114,7 @@ class AndroidStationMenu @JvmOverloads constructor( } val equipment = makeEquipmentSlots() + val energyConfig = EnergyPlayerInput(this, tile?.energyConfig) init { addInventorySlots() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt index 8cf626104..1b0e57152 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt @@ -20,15 +20,13 @@ import ru.dbotthepony.mc.otm.registry.MMenus class ChemicalGeneratorMenu @JvmOverloads constructor(id: Int, inv: Inventory, tile: ChemicalGeneratorBlockEntity? = null) : MatteryMenu(MMenus.CHEMICAL_GENERATOR, id, inv, tile) { - val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java) - val itemConfig = ItemHandlerPlayerInput(this, allowPull = false, allowPush = true) - val energyConfig = EnergyPlayerInput(this, allowPull = false, allowPush = true) + val redstoneConfig = EnumInputWithFeedback(this) + val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig, allowPush = true) + val energyConfig = EnergyPlayerInput(this, tile?.energyConfig, allowPush = true) init { if (tile != null) { - redstone.with(tile.redstoneControl::redstoneSetting) - itemConfig.configure(tile.itemConfig) - energyConfig.configure(tile.energyConfig) + redstoneConfig.with(tile.redstoneControl::redstoneSetting) } } @@ -64,7 +62,7 @@ class ChemicalGeneratorMenu @JvmOverloads constructor(id: Int, inv: Inventory, t addStorageSlot(residueSlot) if (tile != null) { - progress.with { 1f - tile.workTicks.toFloat() / tile.workTicksTotal } + progress.with { if (tile.workTicksTotal == 0) 0f else 1f - tile.workTicks.toFloat() / tile.workTicksTotal } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt index a21b60f6a..10c909a28 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt @@ -34,15 +34,13 @@ class EnergyServoMenu @JvmOverloads constructor( val equipment = makeEquipmentSlots(mapMoveToExternal = true) val powerGauge = LevelGaugeWidget(this, tile?.energy) - val itemConfig = ItemHandlerPlayerInput(this) - val energyConfig = EnergyPlayerInput(this, true, true) - val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java) + val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) + val energyConfig = EnergyPlayerInput(this, tile?.energyConfig, allowPull = true, allowPush = true) + val redstoneConfig = EnumInputWithFeedback(this) init { if (tile != null) { - redstone.with(tile.redstoneControl::redstoneSetting) - itemConfig.configure(tile.itemConfig) - energyConfig.configure(tile.energyConfig) + redstoneConfig.with(tile.redstoneControl::redstoneSetting) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt index f0b88e85a..5b7fe6a2c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt @@ -4,6 +4,7 @@ import net.minecraft.server.level.ServerPlayer import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.block.entity.tech.EssenceStorageBlockEntity import ru.dbotthepony.mc.otm.capability.itemsStream import ru.dbotthepony.mc.otm.capability.matteryPlayer @@ -13,6 +14,8 @@ import ru.dbotthepony.mc.otm.item.EssenceCapsuleItem import ru.dbotthepony.mc.otm.item.EssenceServoItem import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MMenus @@ -21,7 +24,9 @@ class EssenceStorageMenu @JvmOverloads constructor( inventory: Inventory, tile: EssenceStorageBlockEntity? = null ) : MatteryMenu(MMenus.ESSENCE_STORAGE, containerID, inventory, tile) { - val experienceStored by mSynchronizer.ComputedLongField(getter = { tile?.experienceStored ?: 0L }) + val experienceStored by mSynchronizer.ComputedLongField(getter = { tile?.experienceStored ?: 0L }).property + val redstoneConfig = EnumInputWithFeedback(this) + val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) val capsuleSlot = object : MatterySlot(tile?.capsuleContainer ?: SimpleContainer(1), 0) { override fun mayPlace(itemStack: ItemStack): Boolean { @@ -90,6 +95,10 @@ class EssenceStorageMenu @JvmOverloads constructor( dispenseLevels.filter { (tile?.experienceStored ?: experienceStored) > 0L } + if (tile != null) { + redstoneConfig.with(tile.redstoneControl::redstoneSetting) + } + addStorageSlot(capsuleSlot) addStorageSlot(servoSlot) addInventorySlots() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt index 8893a870c..05c51d69e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt @@ -20,20 +20,13 @@ class PlatePressMenu @JvmOverloads constructor( val inputSlot = MatterySlot(tile?.inputContainer ?: SimpleContainer(1), 0) val outputSlot = MachineOutputSlot(tile?.outputContainer ?: SimpleContainer(1), 0) { tile?.popExperience(ply as ServerPlayer) } - val progressGauge = ProgressGaugeWidget(this) - - val itemConfig = ItemHandlerPlayerInput(this, allowPush = true) - val energyConfig = EnergyPlayerInput(this, allowPull = true) + val progressGauge = ProgressGaugeWidget(this, tile) + val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig, allowPush = true) + val energyConfig = EnergyPlayerInput(this, tile?.energyConfig, allowPull = true) init { addStorageSlot(inputSlot) addStorageSlot(outputSlot) addInventorySlots() - - if (tile != null) { - progressGauge.with(tile::workProgress, tile::isUnableToProcess) - itemConfig.configure(tile.itemConfig) - energyConfig.configure(tile.energyConfig) - } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt index 5b6560a2c..7ceb4aa32 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.menu.widget -import mekanism.api.functions.FloatSupplier +import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity +import ru.dbotthepony.mc.otm.core.FloatSupplier import ru.dbotthepony.mc.otm.menu.MatteryMenu import java.util.function.BooleanSupplier @@ -9,7 +10,7 @@ class ProgressGaugeWidget(menu: MatteryMenu) { var progressSupplier: FloatSupplier = FloatSupplier { 0f } var stuckSupplier: BooleanSupplier = BooleanSupplier { false } - val percentage by menu.mSynchronizer.ComputedFloatField(getter = { progressSupplier.asFloat }) + val percentage by menu.mSynchronizer.ComputedFloatField(getter = { progressSupplier.getAsFloat() }) val isStuck by menu.mSynchronizer.ComputedBooleanField(getter = { stuckSupplier.asBoolean }) constructor( @@ -19,6 +20,15 @@ class ProgressGaugeWidget(menu: MatteryMenu) { this.progressSupplier = progress } + constructor( + menu: MatteryMenu, + blockEntity: MatteryWorkerBlockEntity<*>? + ) : this(menu) { + if (blockEntity != null) { + with(blockEntity) + } + } + constructor( menu: MatteryMenu, progress: FloatSupplier, @@ -39,4 +49,9 @@ class ProgressGaugeWidget(menu: MatteryMenu) { this.stuckSupplier = stuck return this } + + fun with(blockEntity: MatteryWorkerBlockEntity<*>): ProgressGaugeWidget { + with(blockEntity::workProgress, blockEntity::isUnableToProcess) + return this + } } From 37400a2d5d2959794ae14fed9a7d9ebd17d3266c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Mar 2023 20:16:39 +0700 Subject: [PATCH 0442/1199] Rename item handler/energy config classes --- .../client/screen/panels/button/Buttons.kt | 20 +++++++++---------- ...yerInput.kt => EnergyConfigPlayerInput.kt} | 10 +++++----- ...layerInput.kt => ItemConfigPlayerInput.kt} | 12 +++++------ .../otm/menu/matter/MatterDecomposerMenu.kt | 12 ++++------- .../menu/matter/MatterReconstructorMenu.kt | 10 ++++------ .../mc/otm/menu/matter/MatterRecyclerMenu.kt | 10 ++++------ .../otm/menu/matter/MatterReplicatorMenu.kt | 10 ++++------ .../mc/otm/menu/matter/MatterScannerMenu.kt | 8 ++++---- .../mc/otm/menu/matter/PatternStorageMenu.kt | 4 ++-- .../mc/otm/menu/tech/AndroidStationMenu.kt | 7 ++----- .../mc/otm/menu/tech/BatteryBankMenu.kt | 12 +++++------ .../mc/otm/menu/tech/ChemicalGeneratorMenu.kt | 8 ++++---- .../mc/otm/menu/tech/CobblerMenu.kt | 6 +++--- .../mc/otm/menu/tech/EnergyServoMenu.kt | 8 ++++---- .../mc/otm/menu/tech/EssenceStorageMenu.kt | 6 ++---- .../mc/otm/menu/tech/PlatePressMenu.kt | 8 ++++---- 16 files changed, 68 insertions(+), 83 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/{EnergyPlayerInput.kt => EnergyConfigPlayerInput.kt} (79%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/{ItemHandlerPlayerInput.kt => ItemConfigPlayerInput.kt} (81%) 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 e6873d5a4..0d9c8f7f2 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 @@ -12,9 +12,9 @@ import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback -import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput +import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.IPlayerInputWithFeedback -import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput +import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import java.util.function.Predicate private fun > makeRedstoneSettingButton( @@ -41,7 +41,7 @@ private fun > makeRedstoneSettingButton( } } -private fun > makeItemModeButton(screen: S, parent: FramePanel, input: ItemHandlerPlayerInput.Piece, side: RelativeSide): LargeEnumRectangleButtonPanel { +private fun > makeItemModeButton(screen: S, parent: FramePanel, input: ItemConfigPlayerInput.Piece, side: RelativeSide): LargeEnumRectangleButtonPanel { val button = LargeEnumRectangleButtonPanel(screen, parent, enum = MatteryDeviceBlockEntity.ItemHandlerMode::class.java, prop = input.input, defaultValue = input.default) for (v in MatteryDeviceBlockEntity.ItemHandlerMode.values()) { @@ -54,7 +54,7 @@ private fun > makeItemModeButton(screen: S, parent: FramePa return button } -private fun > makeEnergyModeButton(screen: S, parent: FramePanel, input: EnergyPlayerInput.Piece, side: RelativeSide): LargeEnumRectangleButtonPanel { +private fun > makeEnergyModeButton(screen: S, parent: FramePanel, input: EnergyConfigPlayerInput.Piece, side: RelativeSide): LargeEnumRectangleButtonPanel { val button = LargeEnumRectangleButtonPanel(screen, parent, enum = FlowDirection::class.java, prop = input.input, defaultValue = input.default) for (v in FlowDirection.values()) { @@ -135,7 +135,7 @@ private fun pullPush(frame: FramePanel<*>, pull: BooleanInputWithFeedback, push: private fun > makeItemHandlerControlPanel( screen: S, - inputs: ItemHandlerPlayerInput + inputs: ItemConfigPlayerInput ): FramePanel { val frame = object : FramePanel(screen, 78f, 80f, TranslatableComponent("otm.gui.sides.item_config")) { override fun tickInner() { @@ -164,7 +164,7 @@ private fun > makeItemHandlerControlPanel( private fun > makeEnergyConfigPanel( screen: S, - inputs: EnergyPlayerInput + inputs: EnergyConfigPlayerInput ): FramePanel { val frame = object : FramePanel(screen, 78f, 80f, TranslatableComponent("otm.gui.sides.energy_config")) { override fun tickInner() { @@ -196,8 +196,8 @@ class DeviceControls>( parent: FramePanel, extra: Iterable> = listOf(), val redstoneConfig: IPlayerInputWithFeedback? = null, - val itemConfig: ItemHandlerPlayerInput? = null, - val energyConfig: EnergyPlayerInput? = null, + val itemConfig: ItemConfigPlayerInput? = null, + val energyConfig: EnergyConfigPlayerInput? = null, ) : EditablePanel(screen, parent, x = parent.width + 3f, height = 0f, width = 0f) { val itemConfigButton: LargeRectangleButtonPanel? val energyConfigButton: LargeRectangleButtonPanel? @@ -276,8 +276,8 @@ fun > makeDeviceControls( parent: FramePanel, extra: Iterable> = listOf(), redstoneConfig: IPlayerInputWithFeedback? = null, - itemConfig: ItemHandlerPlayerInput? = null, - energyConfig: EnergyPlayerInput? = null, + itemConfig: ItemConfigPlayerInput? = null, + energyConfig: EnergyConfigPlayerInput? = null, ): DeviceControls { return DeviceControls(screen, parent, extra = extra, redstoneConfig = redstoneConfig, itemConfig = itemConfig, energyConfig = energyConfig) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyPlayerInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyConfigPlayerInput.kt similarity index 79% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyPlayerInput.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyConfigPlayerInput.kt index a4166cc53..2abbbbf96 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyPlayerInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyConfigPlayerInput.kt @@ -9,7 +9,7 @@ import ru.dbotthepony.mc.otm.menu.MatteryMenu /** * [allowPull] and [allowPush] controls whenever player is allowed to change these options */ -class EnergyPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEntity.ConfigurableEnergy<*>? = null, val allowPull: Boolean = false, val allowPush: Boolean = false) { +class EnergyConfigPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEntity.ConfigurableEnergy<*>? = null, val allowPull: Boolean = false, val allowPush: Boolean = false) { var possibleModes by menu.mSynchronizer.enum(FlowDirection::class.java) private set @@ -25,7 +25,7 @@ class EnergyPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEntity. push.filter { allowPush } } - fun configure(config: MatteryDeviceBlockEntity.ConfigurableEnergy<*>.Piece, parent: MatteryDeviceBlockEntity.ConfigurableEnergy<*>) { + fun with(config: MatteryDeviceBlockEntity.ConfigurableEnergy<*>.Piece, parent: MatteryDeviceBlockEntity.ConfigurableEnergy<*>) { pull.with(config::automatePull) push.with(config::automatePush) input.withSupplier { config.energyFlow }.withConsumer { if (parent.possibleModes.isSupertype(it)) config.energyFlow = it } @@ -45,11 +45,11 @@ class EnergyPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEntity. push.filter { allowPush } } - fun configure(config: MatteryDeviceBlockEntity.ConfigurableEnergy<*>) { + fun with(config: MatteryDeviceBlockEntity.ConfigurableEnergy<*>) { possibleModes = config.possibleModes for ((side, v) in config.pieces) { - pieces[side]!!.configure(v, config) + pieces[side]!!.with(v, config) pieces[side]!!.default = config.defaults[side]!! } @@ -62,7 +62,7 @@ class EnergyPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEntity. init { if (config != null) { - configure(config) + with(config) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemConfigPlayerInput.kt similarity index 81% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemConfigPlayerInput.kt index 7df8347ce..3424eb284 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemHandlerPlayerInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemConfigPlayerInput.kt @@ -8,12 +8,12 @@ import ru.dbotthepony.mc.otm.menu.MatteryMenu /** * [allowPull] and [allowPush] controls whenever player is allowed to change these options */ -class ItemHandlerPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEntity.ConfigurableItemHandler? = null, val allowPull: Boolean = false, val allowPush: Boolean = false) { +class ItemConfigPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEntity.ConfigurableItemHandler? = null, val allowPull: Boolean = false, val allowPush: Boolean = false) { private val allowedFlags = MatteryDeviceBlockEntity.ItemHandlerMode.values().map { menu.mSynchronizer.bool() to it } fun isAllowed(value: MatteryDeviceBlockEntity.ItemHandlerMode) = allowedFlags[value.ordinal].first.boolean inner class Piece(val side: RelativeSide) { - fun isAllowed(value: MatteryDeviceBlockEntity.ItemHandlerMode) = this@ItemHandlerPlayerInput.isAllowed(value) + fun isAllowed(value: MatteryDeviceBlockEntity.ItemHandlerMode) = this@ItemConfigPlayerInput.isAllowed(value) val pull = BooleanInputWithFeedback(menu) val push = BooleanInputWithFeedback(menu) @@ -26,7 +26,7 @@ class ItemHandlerPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEn push.filter { allowPush } } - fun configure(config: MatteryDeviceBlockEntity.ConfigurableItemHandler.Piece) { + fun with(config: MatteryDeviceBlockEntity.ConfigurableItemHandler.Piece) { pull.with(config::automatePull) push.with(config::automatePush) input.withSupplier { config.mode }.withConsumer { if (isAllowed(it)) config.mode = it } @@ -46,13 +46,13 @@ class ItemHandlerPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEn push.filter { allowPush } } - fun configure(config: MatteryDeviceBlockEntity.ConfigurableItemHandler) { + fun with(config: MatteryDeviceBlockEntity.ConfigurableItemHandler) { for ((f, v) in allowedFlags) { f.boolean = v in config.possibleViews } for ((side, v) in config.pieces) { - pieces[side]!!.configure(v) + pieces[side]!!.with(v) pieces[side]!!.default = config.defaults[side]!! } @@ -65,7 +65,7 @@ class ItemHandlerPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEn init { if (config != null) { - configure(config) + with(config) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt index 48db6ca77..be015e85e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt @@ -1,24 +1,20 @@ package ru.dbotthepony.mc.otm.menu.matter -import com.google.common.collect.ImmutableList import kotlin.jvm.JvmOverloads import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.block.entity.matter.MatterDecomposerBlockEntity import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import net.minecraft.world.SimpleContainer -import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack -import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.menu.MachineOutputSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot -import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput -import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback -import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput +import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput +import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import ru.dbotthepony.mc.otm.registry.MMenus class MatterDecomposerMenu @JvmOverloads constructor( @@ -34,8 +30,8 @@ class MatterDecomposerMenu @JvmOverloads constructor( val outputStacking: MachineOutputSlot val progressWidget = ProgressGaugeWidget(this, tile) val matterWidget = LevelGaugeWidget(this, tile?.getCapability(MatteryCapability.MATTER)?.orNull()) - val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) - val energyConfig = EnergyPlayerInput(this, tile?.energyConfig) + val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) + val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) init { val container = tile?.outputContainer ?: SimpleContainer(2) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt index ac24ea07b..180005809 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt @@ -3,13 +3,11 @@ package ru.dbotthepony.mc.otm.menu.matter import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack -import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.block.entity.matter.MatterReconstructorBlockEntity import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot -import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput -import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback -import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput +import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput +import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -29,8 +27,8 @@ class MatterReconstructorMenu( val equipment = makeEquipmentSlots(mapMoveToExternal = true) val progress = ProgressGaugeWidget(this) - val energyConfig = EnergyPlayerInput(this, tile?.energyConfig) - val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) + val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) + val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) init { addStorageSlot(slot) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt index 99e5da69f..c2cb229ac 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt @@ -3,14 +3,12 @@ package ru.dbotthepony.mc.otm.menu.matter import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack -import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.block.entity.matter.MatterRecyclerBlockEntity import ru.dbotthepony.mc.otm.item.MatterDustItem import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot -import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput -import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback -import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput +import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput +import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -28,8 +26,8 @@ class MatterRecyclerMenu @JvmOverloads constructor( val progress = ProgressGaugeWidget(this, tile) val matter = LevelGaugeWidget(this, tile?.matter) - val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) - val energyConfig = EnergyPlayerInput(this, tile?.energyConfig) + val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) + val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) init { addStorageSlot(input) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt index f0ae25d5a..67278d79b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt @@ -6,13 +6,11 @@ import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import net.minecraft.world.SimpleContainer -import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.menu.MachineOutputSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu -import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput -import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback -import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput +import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput +import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import ru.dbotthepony.mc.otm.registry.MMenus class MatterReplicatorMenu @JvmOverloads constructor( @@ -23,8 +21,8 @@ class MatterReplicatorMenu @JvmOverloads constructor( val matter = LevelGaugeWidget(this, tile?.matter) val progress = ProgressGaugeWidget(this, tile) val storageSlots: List - val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) - val energyConfig = EnergyPlayerInput(this, tile?.energyConfig) + val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) + val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) init { val container = tile?.container ?: SimpleContainer(5) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt index 1388816c7..ea94cf99a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt @@ -11,8 +11,8 @@ import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot -import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput -import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput +import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput +import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import ru.dbotthepony.mc.otm.registry.MMenus class MatterScannerMenu @JvmOverloads constructor( @@ -23,8 +23,8 @@ class MatterScannerMenu @JvmOverloads constructor( val input: MatterySlot val progress = ProgressGaugeWidget(this, tile) val patterns = LevelGaugeWidget(this) - val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) - val energyConfig = EnergyPlayerInput(this, tile?.energyConfig) + val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) + val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) init { val container = tile?.container ?: SimpleContainer(1) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt index dfd63e482..0edc9a82f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/PatternStorageMenu.kt @@ -7,7 +7,7 @@ import ru.dbotthepony.mc.otm.block.entity.matter.PatternStorageBlockEntity import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.PatternSlot -import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput +import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -18,7 +18,7 @@ class PatternStorageMenu @JvmOverloads constructor( ) : MatteryMenu(MMenus.PATTERN_STORAGE, p_38852_, inventory, tile) { val storedThis = LevelGaugeWidget(this, tile) val storedGrid = LevelGaugeWidget(this) - val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) + val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) val storageSlots: List diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt index 40c50f401..36fc131b0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt @@ -1,21 +1,18 @@ package ru.dbotthepony.mc.otm.menu.tech -import com.google.common.collect.ImmutableList import net.minecraft.server.level.ServerPlayer 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.inventory.Slot import net.minecraft.world.item.ItemStack import net.minecraftforge.common.capabilities.ForgeCapabilities import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer -import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot -import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput +import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.registry.MMenus import kotlin.reflect.KMutableProperty0 @@ -114,7 +111,7 @@ class AndroidStationMenu @JvmOverloads constructor( } val equipment = makeEquipmentSlots() - val energyConfig = EnergyPlayerInput(this, tile?.energyConfig) + val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) init { addInventorySlots() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt index 8b25a38f7..3b7ae1ab8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt @@ -13,9 +13,9 @@ import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.menu.BatterySlot import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatterySlot -import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput +import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback -import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput +import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import ru.dbotthepony.mc.otm.registry.MMenus class BatteryBankMenu @JvmOverloads constructor( @@ -26,14 +26,14 @@ class BatteryBankMenu @JvmOverloads constructor( val powerLevel: LevelGaugeWidget val storageSlots: List val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java) - val energyConfig = EnergyPlayerInput(this, allowPull = false, allowPush = true) - val itemConfig = ItemHandlerPlayerInput(this, allowPull = false, allowPush = false) + val energyConfig = EnergyConfigPlayerInput(this, allowPull = false, allowPush = true) + val itemConfig = ItemConfigPlayerInput(this, allowPull = false, allowPush = false) init { if (tile != null) { redstone.with(tile.redstoneControl::redstoneSetting) - energyConfig.configure(tile.energyConfig) - itemConfig.configure(tile.itemConfig) + energyConfig.with(tile.energyConfig) + itemConfig.with(tile.itemConfig) } val container: Container = tile?.container ?: SimpleContainer(BatteryBankBlockEntity.CAPACITY) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt index 1b0e57152..1115da4fd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt @@ -10,9 +10,9 @@ import ru.dbotthepony.mc.otm.block.entity.tech.ChemicalGeneratorBlockEntity import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatterySlot -import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput +import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback -import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput +import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -21,8 +21,8 @@ class ChemicalGeneratorMenu @JvmOverloads constructor(id: Int, inv: Inventory, t : MatteryMenu(MMenus.CHEMICAL_GENERATOR, id, inv, tile) { val redstoneConfig = EnumInputWithFeedback(this) - val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig, allowPush = true) - val energyConfig = EnergyPlayerInput(this, tile?.energyConfig, allowPush = true) + val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig, allowPush = true) + val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig, allowPush = true) init { if (tile != null) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt index 6dda03a43..57687cf73 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt @@ -8,7 +8,7 @@ import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.menu.MachineOutputSlot import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback -import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput +import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -19,7 +19,7 @@ class CobblerMenu @JvmOverloads constructor( ) : MatteryMenu(MMenus.COBBLESTONE_GENERATOR, p_38852_, inventory, tile) { val storageSlots = (tile?.container ?: SimpleContainer(CobblerBlockEntity.CONTAINER_SIZE)).let { c -> immutableList(c.containerSize) { addStorageSlot(MachineOutputSlot(c, it)) } } val redstone = EnumInputWithFeedback(this) - val itemConfig = ItemHandlerPlayerInput(this) + val itemConfig = ItemConfigPlayerInput(this) val progress = ProgressGaugeWidget(this) @@ -27,7 +27,7 @@ class CobblerMenu @JvmOverloads constructor( if (tile != null) { progress.with(tile::workProgress, tile::isUnableToProcess) redstone.with(tile.redstoneControl::redstoneSetting) - itemConfig.configure(tile.itemConfig) + itemConfig.with(tile.itemConfig) } addInventorySlots() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt index 10c909a28..902116b03 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt @@ -8,9 +8,9 @@ import ru.dbotthepony.mc.otm.block.entity.tech.EnergyServoBlockEntity import ru.dbotthepony.mc.otm.capability.energy import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatterySlot -import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput +import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback -import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput +import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -34,8 +34,8 @@ class EnergyServoMenu @JvmOverloads constructor( val equipment = makeEquipmentSlots(mapMoveToExternal = true) val powerGauge = LevelGaugeWidget(this, tile?.energy) - val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) - val energyConfig = EnergyPlayerInput(this, tile?.energyConfig, allowPull = true, allowPush = true) + val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) + val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig, allowPull = true, allowPush = true) val redstoneConfig = EnumInputWithFeedback(this) init { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt index 5b7fe6a2c..2c36f97dc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt @@ -6,16 +6,14 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.block.entity.tech.EssenceStorageBlockEntity -import ru.dbotthepony.mc.otm.capability.itemsStream import ru.dbotthepony.mc.otm.capability.matteryPlayer -import ru.dbotthepony.mc.otm.core.util.LongValueCodec import ru.dbotthepony.mc.otm.core.util.getTotalXpRequiredForLevel import ru.dbotthepony.mc.otm.item.EssenceCapsuleItem import ru.dbotthepony.mc.otm.item.EssenceServoItem import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback -import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput +import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MMenus @@ -26,7 +24,7 @@ class EssenceStorageMenu @JvmOverloads constructor( ) : MatteryMenu(MMenus.ESSENCE_STORAGE, containerID, inventory, tile) { val experienceStored by mSynchronizer.ComputedLongField(getter = { tile?.experienceStored ?: 0L }).property val redstoneConfig = EnumInputWithFeedback(this) - val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig) + val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) val capsuleSlot = object : MatterySlot(tile?.capsuleContainer ?: SimpleContainer(1), 0) { override fun mayPlace(itemStack: ItemStack): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt index 05c51d69e..eecbe1063 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt @@ -7,8 +7,8 @@ import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity import ru.dbotthepony.mc.otm.menu.MachineOutputSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot -import ru.dbotthepony.mc.otm.menu.input.EnergyPlayerInput -import ru.dbotthepony.mc.otm.menu.input.ItemHandlerPlayerInput +import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput +import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -21,8 +21,8 @@ class PlatePressMenu @JvmOverloads constructor( val outputSlot = MachineOutputSlot(tile?.outputContainer ?: SimpleContainer(1), 0) { tile?.popExperience(ply as ServerPlayer) } val progressGauge = ProgressGaugeWidget(this, tile) - val itemConfig = ItemHandlerPlayerInput(this, tile?.itemConfig, allowPush = true) - val energyConfig = EnergyPlayerInput(this, tile?.energyConfig, allowPull = true) + val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig, allowPush = true) + val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig, allowPull = true) init { addStorageSlot(inputSlot) From 065dd8bbe61b1adc2e34d0c2c723715b0a0af1d4 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Mar 2023 20:27:48 +0700 Subject: [PATCH 0443/1199] Add item configuration to matter capacitor bank --- .../matter/MatterCapacitorBankBlockEntity.kt | 15 +++++++++++++-- .../screen/matter/MatterCapacitorBankScreen.kt | 3 +++ .../mc/otm/menu/matter/MatterCapacitorBankMenu.kt | 6 +++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt index bc77a87fd..55b269ea3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt @@ -12,6 +12,7 @@ import ru.dbotthepony.mc.otm.block.entity.tech.BatteryBankBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage +import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.math.Decimal @@ -122,17 +123,27 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) val container = object : MatteryContainer(this::setChangedLight, BatteryBankBlockEntity.CAPACITY) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { super.setChanged(slot, new, old) - capacitorStatus[slot].value = new.getCapability(MatteryCapability.MATTER).isPresent + capacitorStatus[slot].boolean = new.getCapability(MatteryCapability.MATTER).isPresent gaugeLevel = (storedMatter / maxStoredMatter).toFloat() } }.also(::addDroppableContainer) + val itemConfig = ConfigurableItemHandler(input = container.handler(object : HandlerFilter { + override fun canInsert(slot: Int, stack: ItemStack): Boolean { + return stack.getCapability(MatteryCapability.MATTER).isPresent + } + + override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { + return false + } + })) + val capacitorStatus = immutableList(BatteryBankBlockEntity.CAPACITY) { synchronizer.bool(false) } init { - savetable(::container, INVENTORY_KEY) + savetables.stateful(::container, INVENTORY_KEY) exposeGlobally(MatteryCapability.MATTER, this) exposeGlobally(MatteryCapability.MATTER_NODE, matterNode) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterCapacitorBankScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterCapacitorBankScreen.kt index f1c7767f3..0cfb538d2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterCapacitorBankScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterCapacitorBankScreen.kt @@ -5,6 +5,7 @@ import ru.dbotthepony.mc.otm.menu.matter.MatterCapacitorBankMenu import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.MatterCapacitorSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel @@ -22,6 +23,8 @@ class MatterCapacitorBankScreen(p_97741_: MatterCapacitorBankMenu, p_97742_: Inv for (i in 6 .. 11) MatterCapacitorSlotPanel(this, frame, menu.storageSlots[i], 44f + 18 * (i - 6), 32f + 18f) + makeDeviceControls(this, frame, itemConfig = menu.itemConfig) + return frame } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterCapacitorBankMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterCapacitorBankMenu.kt index c8ca49197..fe1b4cbf3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterCapacitorBankMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterCapacitorBankMenu.kt @@ -7,6 +7,7 @@ import ru.dbotthepony.mc.otm.block.entity.matter.MatterCapacitorBankBlockEntity import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.menu.MatterContainerInputSlot import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -14,11 +15,10 @@ class MatterCapacitorBankMenu @JvmOverloads constructor( p_38852_: Int, inventory: Inventory, tile: MatterCapacitorBankBlockEntity? = null -) : MatteryMenu( - MMenus.MATTER_CAPACITOR_BANK, p_38852_, inventory, tile -) { +) : MatteryMenu(MMenus.MATTER_CAPACITOR_BANK, p_38852_, inventory, tile) { val matterGauge = LevelGaugeWidget(this) val totalMatterGauge = LevelGaugeWidget(this) + val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) val storageSlots: List From f683f5acf8f30c56e9ae6a96bec76bde74c8ec86 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Mar 2023 20:37:20 +0700 Subject: [PATCH 0444/1199] Allow to extract matter containers from matter capacitor bank --- .../entity/matter/MatterCapacitorBankBlockEntity.kt | 10 ++++++++-- .../mc/otm/block/entity/tech/BatteryBankBlockEntity.kt | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt index 55b269ea3..cc597834f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt @@ -128,13 +128,19 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) } }.also(::addDroppableContainer) - val itemConfig = ConfigurableItemHandler(input = container.handler(object : HandlerFilter { + val itemConfig = ConfigurableItemHandler(inputOutput = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { return stack.getCapability(MatteryCapability.MATTER).isPresent } override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { - return false + stack.getCapability(MatteryCapability.MATTER).ifPresentK { + if (it.storedMatter.isPositive) { + return false + } + } + + return true } })) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index ad1a054a4..dbb5c6cc2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -57,7 +57,7 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte private var lastTickDischarged = false init { - savetable(::container, INVENTORY_KEY) + savetables.stateful(::container, INVENTORY_KEY) savetables.int(::currentChangeSlot) savetables.int(::currentDischangeSlot) savetables.bool(::lastTickCharged) From 2bdefcf3c4facd4eea9127a831cc3365e90881d2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Mar 2023 20:37:43 +0700 Subject: [PATCH 0445/1199] Specify all sides as input/output if inputOutput is present --- .../mc/otm/block/entity/MatteryDeviceBlockEntity.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index c12d6d5b1..74216b68f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -447,7 +447,9 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo if (input == null && output == null && inputOutput == null) { return ItemHandlerMode.DISABLED - } else if (input != null && output != null || inputOutput != null) { + } else if (inputOutput != null) { + return ItemHandlerMode.INPUT_OUTPUT + } else if (input != null && output != null) { return when (side) { RelativeSide.FRONT, RelativeSide.BACK -> ItemHandlerMode.DISABLED RelativeSide.RIGHT, RelativeSide.TOP -> ItemHandlerMode.INPUT From b4aee8424987241f440f07001034a560c608d9ee Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Mar 2023 20:38:55 +0700 Subject: [PATCH 0446/1199] Specify battery bank item handler as inputOutput --- .../otm/block/entity/tech/BatteryBankBlockEntity.kt | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index dbb5c6cc2..064bc1cae 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -39,16 +39,7 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte synchronizer.bool(false) } - val itemConfig = ConfigurableItemHandler( - input = container.handler(HandlerFilter.Dischargeable.and(HandlerFilter.OnlyIn)), - output = container.handler(HandlerFilter.OnlyOut), - frontDefault = ItemHandlerMode.INPUT_OUTPUT, - backDefault = ItemHandlerMode.INPUT_OUTPUT, - leftDefault = ItemHandlerMode.INPUT_OUTPUT, - rightDefault = ItemHandlerMode.INPUT_OUTPUT, - topDefault = ItemHandlerMode.INPUT_OUTPUT, - bottomDefault = ItemHandlerMode.INPUT_OUTPUT, - ) + val itemConfig = ConfigurableItemHandler(inputOutput = container.handler(HandlerFilter.Dischargeable)) private var currentChangeSlot = 0 private var currentDischangeSlot = 0 From 581f337198e5ac85045ba375541a493034f94d80 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Mar 2023 20:51:29 +0700 Subject: [PATCH 0447/1199] Don't use Streams.concat because they don't improve performance here --- src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt | 8 ++++---- .../ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt index 2192faf38..a404652a6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt @@ -209,7 +209,7 @@ fun ICapabilityProvider.getMatteryEnergySided(side: Direction? = null): LazyOpti * Contains all items that player might carry */ fun Player.itemsStream(includeCosmetics: Boolean = true): Stream { - val streams = LinkedList>() + val streams = ArrayList>() streams.add(inventory.stream()) matteryPlayer?.let { @@ -226,7 +226,7 @@ fun Player.itemsStream(includeCosmetics: Boolean = true): Stream streams.add(cosmeticArmorStream()) } - return Streams.concat(*streams.toTypedArray()) + return streams.stream().flatMap { it } } /** @@ -256,7 +256,7 @@ fun Player.allItemsStream(includeCosmetics: Boolean = true): Stream { - val streams = LinkedList>() + val streams = ArrayList>() streams.add(inventory.awareStream()) matteryPlayer?.let { @@ -273,7 +273,7 @@ fun Player.awareItemsStream(includeCosmetics: Boolean = false): Stream { From a1fd94826660daf2412ca7c6a6aed0f2db889492 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 25 Mar 2023 21:20:56 +0700 Subject: [PATCH 0448/1199] Add missing auto align to curios panel in matter reconstructor --- .../mc/otm/client/screen/matter/MatterReconstructorScreen.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt index 5a15bdecc..cbfdf5b89 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt @@ -29,7 +29,7 @@ class MatterReconstructorScreen(menu: MatterReconstructorMenu, inventory: Invent ProgressGaugePanel(this, frame, menu.progress, 37f, PROGRESS_ARROW_TOP) makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig) - makeCuriosPanel(this, frame, menu.equipment.curiosSlots) + makeCuriosPanel(this, frame, menu.equipment.curiosSlots, autoAlign = true) PlayerEquipmentPanel(this, frame, armorSlots = menu.equipment.armorSlots).also { it.leftSided = false From 20f7ef45ede92a8b8fa00126f4fd5dc3e8dff84c Mon Sep 17 00:00:00 2001 From: GearShocky Date: Sat, 25 Mar 2023 23:37:41 +0600 Subject: [PATCH 0449/1199] Matter Reconstructor --- .../ru/dbotthepony/mc/otm/registry/MNames.kt | 2 +- .../models/block/matter_reconstructor.json | 232 ++++++++++++++++++ .../textures/block/matter_reconstructor.png | Bin 0 -> 750 bytes 3 files changed, 233 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/matter_reconstructor.json create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matter_reconstructor.png diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index 81bdd5794..0347f06dd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -23,7 +23,7 @@ object MNames { const val MATTER_PANEL = "matter_panel" const val MATTER_REPLICATOR = "matter_replicator" const val MATTER_BOTTLER = "matter_bottler" - const val MATTER_RECONSTRUCTOR = "item_repairer" + const val MATTER_RECONSTRUCTOR = "matter_reconstructor" const val DRIVE_VIEWER = "drive_viewer" const val DRIVE_RACK = "drive_rack" const val ITEM_MONITOR = "item_monitor" diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/matter_reconstructor.json b/src/main/resources/assets/overdrive_that_matters/models/block/matter_reconstructor.json new file mode 100644 index 000000000..94d03904b --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/matter_reconstructor.json @@ -0,0 +1,232 @@ +{ + "credit": "Made with Blockbench", + "render_type": "cutout", + "textures": { + "0": "overdrive_that_matters:block/matter_reconstructor", + "particle": "overdrive_that_matters:block/matter_reconstructor" + }, + "elements": [ + { + "name": "body", + "from": [0, 4, 0], + "to": [16, 8, 16], + "faces": { + "north": {"uv": [0, 0, 4, 2], "texture": "#0"}, + "east": {"uv": [8, 0, 4, 2], "texture": "#0"}, + "south": {"uv": [8, 0, 12, 2], "texture": "#0"}, + "west": {"uv": [4, 0, 8, 2], "texture": "#0"}, + "up": {"uv": [4, 4, 8, 12], "texture": "#0"}, + "down": {"uv": [4, 4, 8, 12], "rotation": 90, "texture": "#0"} + } + }, + { + "name": "body", + "from": [0, 0, 0], + "to": [16, 4, 11], + "faces": { + "north": {"uv": [0, 2, 4, 4], "texture": "#0"}, + "east": {"uv": [6.75, 2, 4, 4], "texture": "#0"}, + "south": {"uv": [0, 2, 4, 4], "texture": "#0"}, + "west": {"uv": [4, 2, 6.75, 4], "texture": "#0"}, + "down": {"uv": [0, 4, 4, 9.5], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "body", + "from": [13, 8, 0], + "to": [16, 16, 16], + "faces": { + "north": {"uv": [0, 12, 0.75, 16], "rotation": 180, "texture": "#0"}, + "east": {"uv": [0.75, 12, 4.75, 16], "texture": "#0"}, + "south": {"uv": [0, 12, 0.75, 16], "texture": "#0"}, + "west": {"uv": [4.75, 12, 8.75, 16], "texture": "#0"}, + "up": {"uv": [0, 10.5, 4, 12], "rotation": 90, "texture": "#0"} + } + }, + { + "name": "body", + "from": [0, 8, 0], + "to": [3, 16, 16], + "faces": { + "north": {"uv": [0, 12, 0.75, 16], "texture": "#0"}, + "east": {"uv": [4.75, 12, 8.75, 16], "texture": "#0"}, + "south": {"uv": [0, 12, 0.75, 16], "rotation": 180, "texture": "#0"}, + "west": {"uv": [0.75, 12, 4.75, 16], "texture": "#0"}, + "up": {"uv": [0, 10.5, 4, 12], "rotation": 270, "texture": "#0"} + } + }, + { + "name": "chamber glass", + "from": [3, 8, 1], + "to": [13, 15, 15], + "faces": { + "north": {"uv": [8.75, 5.5, 11.25, 9], "texture": "#0"}, + "south": {"uv": [8.75, 5.5, 11.25, 9], "texture": "#0"}, + "up": {"uv": [8.75, 9, 11.25, 16], "texture": "#0"} + } + }, + { + "name": "shields", + "from": [-1, 8, 1], + "to": [0, 15, 15], + "faces": { + "north": {"uv": [11.25, 4, 13, 4.5], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 0, 3.5, 3.5], "texture": "#missing"}, + "south": {"uv": [11.25, 4, 13, 4.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [11.25, 4.5, 13, 11.5], "rotation": 270, "texture": "#0"}, + "up": {"uv": [13, 4.5, 13.25, 11.5], "texture": "#0"}, + "down": {"uv": [13, 4.5, 13.25, 11.5], "texture": "#0"} + } + }, + { + "name": "shields", + "from": [16, 8, 1], + "to": [17, 15, 15], + "faces": { + "north": {"uv": [11.25, 4, 13, 4.5], "rotation": 90, "texture": "#0"}, + "east": {"uv": [11.25, 4.5, 13, 11.5], "rotation": 270, "texture": "#0"}, + "south": {"uv": [11.25, 4, 13, 4.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [0, 0, 3.5, 3.5], "texture": "#missing"}, + "up": {"uv": [13, 4.5, 13.25, 11.5], "texture": "#0"}, + "down": {"uv": [13, 4.5, 13.25, 11.5], "texture": "#0"} + } + }, + { + "name": "item platform", + "from": [4, 8, 4], + "to": [12, 9, 12], + "faces": { + "north": {"uv": [11.25, 11.5, 13.25, 12], "texture": "#0"}, + "east": {"uv": [11.25, 11.5, 13.25, 12], "texture": "#0"}, + "south": {"uv": [11.25, 11.5, 13.25, 12], "texture": "#0"}, + "west": {"uv": [11.25, 11.5, 13.25, 12], "texture": "#0"}, + "up": {"uv": [11.25, 12, 13.25, 16], "texture": "#0"} + } + }, + { + "name": "matter storage", + "from": [14, 0, 11], + "to": [15, 4, 15], + "faces": { + "east": {"uv": [6.75, 2, 7.75, 4], "texture": "#0"}, + "south": {"uv": [11, 2, 11.25, 4], "texture": "#0"}, + "down": {"uv": [11, 2, 11.25, 4], "texture": "#0"} + } + }, + { + "name": "matter storage", + "from": [1, 0, 11], + "to": [3, 4, 15], + "faces": { + "south": {"uv": [7.75, 2, 8.25, 4], "texture": "#0"}, + "west": {"uv": [6.75, 2, 7.75, 4], "texture": "#0"}, + "down": {"uv": [7.75, 2, 8.25, 4], "texture": "#0"} + } + }, + { + "name": "matter glow", + "from": [3, 0, 11], + "to": [14, 4, 15], + "faces": { + "south": {"uv": [8.25, 2, 11, 4], "texture": "#0"}, + "down": {"uv": [8.25, 2, 11, 4], "texture": "#0"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "manipulator", + "from": [6, 6, 10.9], + "to": [7, 11, 11.9], + "rotation": {"angle": 45, "axis": "x", "origin": [6.5, 8.5, 12.4]}, + "faces": { + "north": {"uv": [8, 4.5, 9.25, 5], "rotation": 90, "texture": "#0"}, + "east": {"uv": [8, 4, 9.25, 4.5], "rotation": 90, "texture": "#0"}, + "south": {"uv": [8, 4.5, 9.25, 5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [8, 4, 9.25, 4.5], "rotation": 90, "texture": "#0"} + } + }, + { + "name": "manipulator", + "from": [6, 10, 8.1], + "to": [7, 11, 9.1], + "rotation": {"angle": 45, "axis": "x", "origin": [6.5, 10, 10.4]}, + "faces": { + "north": {"uv": [9.25, 4, 9.5, 4.5], "texture": "#0"}, + "east": {"uv": [9.25, 4, 9.5, 4.5], "texture": "#0"}, + "south": {"uv": [9.25, 4, 9.5, 4.5], "texture": "#0"}, + "west": {"uv": [9.25, 4, 9.5, 4.5], "texture": "#0"} + } + }, + { + "name": "manipulator tip", + "from": [6, 9, 8.1], + "to": [7, 10, 9.1], + "rotation": {"angle": 45, "axis": "x", "origin": [6.5, 10, 10.4]}, + "faces": { + "north": {"uv": [9.25, 4.5, 9.5, 5], "texture": "#0"}, + "east": {"uv": [9.25, 4.5, 9.5, 5], "texture": "#0"}, + "south": {"uv": [9.25, 4.5, 9.5, 5], "texture": "#0"}, + "west": {"uv": [9.25, 4.5, 9.5, 5], "texture": "#0"}, + "down": {"uv": [9.5, 4.5, 9.75, 5], "texture": "#0"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "manipulator", + "from": [5.9, 10.5, 9.4], + "to": [7.1, 12.5, 14.4], + "rotation": {"angle": 0, "axis": "x", "origin": [6.5, 12.5, 13.9]}, + "faces": { + "north": {"uv": [8, 5.5, 8.5, 6.1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [8, 6, 8.5, 8.5], "rotation": 270, "texture": "#0"}, + "south": {"uv": [8, 5.5, 8.5, 6.1], "rotation": 90, "texture": "#0"}, + "west": {"uv": [8, 6, 8.5, 8.5], "rotation": 270, "texture": "#0"}, + "up": {"uv": [8.5, 6, 8.75, 8.5], "texture": "#0"}, + "down": {"uv": [8, 6, 8.25, 8.5], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "emerald lens", + "from": [7, 8, 3], + "to": [9, 10, 5], + "faces": { + "north": {"uv": [8, 10.5, 8.5, 11.5], "texture": "#0"}, + "east": {"uv": [8, 10.5, 8.5, 11.5], "texture": "#0"}, + "south": {"uv": [8, 10.5, 8.5, 11.5], "texture": "#0"}, + "west": {"uv": [8, 10.5, 8.5, 11.5], "texture": "#0"}, + "up": {"uv": [8, 9.5, 8.5, 10.5], "texture": "#0"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 225, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "scale": [0.5, 0.5, 0.5] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/matter_reconstructor.png b/src/main/resources/assets/overdrive_that_matters/textures/block/matter_reconstructor.png new file mode 100644 index 0000000000000000000000000000000000000000..854ab7991021e88da9221aa4eb463d550fe9ad89 GIT binary patch literal 750 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3-p)I`?e@QjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`T?2eVTun_)bDR2)Z3!0>6Z?OI;r|2AgoK3u|Nn=Cgrrrr+`fIgzP`Sw zsL1{QZu4UkwlXmMXJBY=Z&y=O)7I8zn5yacxdmtvtH&QLASGTB*#OnUCE;qXMS?zYUMzRO>)et1x|J5JNWoM##@(<9q6Weh6)Ywxk-nLoPdd%5HE zVrfR@W9yE(eCn1^{B&$Hv)orFRwhv;J{AiWJ{^{2%?vURt}LZWbyg$>fFtu z+^3TxlQQhStxrEzus9r*ib)FZ*(ULH%Axs8rx!8Jtnso; z_P4A&6xe-#O9G$9;suY4Zw4y6y*#$6=-{HQmIlnP6e>Hpi)0MnR_ve7HD~gkWegnG z3pY&=6lv6YG5M*e&Sv2YZM;(!@Xpy7!Swvv$)f9?DXzDZ8l%b_v&t!F+Z%{=&IB{4tc_D`(qrYw)>rWAxT@%WKm>aoH zoDaB``-(-cum8SK*m5h~ozt}zCs@ZBM!GN};sr-EBn8LE& zux?phFoSVlTG(oZZC=WM^gmp4e3mP_C+ncKo#l)44VD#_N4h8Tf0;M=z_tl~+Y4js Z85M-1S@l*pJp`r~22WQ%mvv4FO#uC;KoS4| literal 0 HcmV?d00001 From a7dbae85abac98aa9d99ebbb65cc8c58dd8d874d Mon Sep 17 00:00:00 2001 From: GearShocky Date: Sat, 25 Mar 2023 23:38:20 +0600 Subject: [PATCH 0450/1199] Essence storage funni --- .../models/block/essence_storage.json | 72 ++++++++++++++++--- 1 file changed, 62 insertions(+), 10 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/essence_storage.json b/src/main/resources/assets/overdrive_that_matters/models/block/essence_storage.json index 232c1ec45..9727bad86 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/essence_storage.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/essence_storage.json @@ -1,4 +1,5 @@ { + "credit": "Made with Blockbench", "render_type": "cutout", "texture_size": [32, 64], "textures": { @@ -88,16 +89,6 @@ "west": {"uv": [8, 10.5, 8.5, 11.75], "texture": "#0"} } }, - { - "name": "container", - "from": [1, 5, 1], - "to": [9, 15, 9], - "faces": { - "north": {"uv": [8, 2, 12, 4.5], "texture": "#0"}, - "west": {"uv": [8, 2, 12, 4.5], "texture": "#0"}, - "up": {"uv": [8, 0, 12, 2], "texture": "#0"} - } - }, { "name": "experience", "from": [1.5, 5, 1.5], @@ -110,6 +101,67 @@ "up": {"uv": [9.5, 12.5, 13, 14.25], "texture": "#0"} }, "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "bottle", + "from": [1, 13, 1], + "to": [9, 15, 9], + "faces": { + "north": {"uv": [8, 2, 12, 2.5], "texture": "#0"}, + "west": {"uv": [8, 2, 12, 2.5], "texture": "#0"}, + "up": {"uv": [8, 0, 12, 2], "texture": "#0"}, + "down": {"uv": [8, 0, 12, 2], "texture": "#0"} + } + }, + { + "name": "bottle", + "from": [1, 5, 1], + "to": [9, 6, 9], + "faces": { + "north": {"uv": [8, 4.25, 12, 4.5], "texture": "#0"}, + "west": {"uv": [8, 4.25, 12, 4.5], "texture": "#0"}, + "up": {"uv": [8, 0, 12, 2], "texture": "#0"} + } + }, + { + "name": "bottle", + "from": [1, 6, 1], + "to": [2, 13, 2], + "faces": { + "north": {"uv": [11.5, 2.5, 12, 4.25], "texture": "#0"}, + "east": {"uv": [8, 2.5, 8.5, 4.25], "texture": "#0"}, + "south": {"uv": [11.5, 2.5, 12, 4.25], "texture": "#0"}, + "west": {"uv": [8, 2.5, 8.5, 4.25], "texture": "#0"} + } + }, + { + "name": "bottle", + "from": [8, 6, 8], + "to": [9, 13, 9], + "faces": { + "north": {"uv": [11.5, 2.5, 12, 4.25], "texture": "#0"}, + "west": {"uv": [8, 2.5, 8.5, 4.25], "texture": "#0"} + } + }, + { + "name": "bottle", + "from": [1, 6, 8], + "to": [2, 13, 9], + "faces": { + "north": {"uv": [11.5, 2.5, 12, 4.25], "texture": "#0"}, + "east": {"uv": [8, 2.5, 8.5, 4.25], "texture": "#0"}, + "west": {"uv": [8, 2.5, 8.5, 4.25], "texture": "#0"} + } + }, + { + "name": "bottle", + "from": [8, 6, 1], + "to": [9, 13, 2], + "faces": { + "north": {"uv": [11.5, 2.5, 12, 4.25], "texture": "#0"}, + "south": {"uv": [11.5, 2.5, 12, 4.25], "texture": "#0"}, + "west": {"uv": [8, 2.5, 8.5, 4.25], "texture": "#0"} + } } ], "display": { From 44d4c6bbbe3f362e36c9844259e25feb4a4505ac Mon Sep 17 00:00:00 2001 From: GearShocky Date: Sat, 25 Mar 2023 23:39:12 +0600 Subject: [PATCH 0451/1199] Tritanium bars (pls fix) --- .../dbotthepony/mc/otm/datagen/DecorativeData.kt | 2 ++ .../mc/otm/datagen/blocks/BlockStates.kt | 1 + .../mc/otm/datagen/items/ItemModels.kt | 2 ++ .../textures/block/decorative/tritanium_bars.png | Bin 0 -> 254 bytes 4 files changed, 5 insertions(+) create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_bars.png diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt index 0a40478ab..36667ac77 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt @@ -276,6 +276,8 @@ fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelPr DataGen.pane(glass, textureSide, textureRailing) } + DataGen.pane(MBlocks.TRITANIUM_BARS, ResourceLocation(DataGen.MOD_ID,"block/decorative/tritanium_bars"), ResourceLocation(DataGen.MOD_ID,"block/decorative/tritanium_bars")) + blockStateProvider.block(MBlocks.ENGINE) itemModelProvider.block(MItems.ENGINE) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt index 52135accd..6fb27fc90 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt @@ -87,6 +87,7 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { provider.block(MBlocks.STORAGE_POWER_SUPPLIER) provider.block(MBlocks.MATTER_RECYCLER) + provider.block(MBlocks.MATTER_RECONSTRUCTOR) provider.block(MBlocks.ENERGY_SERVO) provider.block(MBlocks.COBBLESTONE_GENERATOR) provider.block(MBlocks.ESSENCE_STORAGE) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index 8c2d8c79b..b906e6e24 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -25,6 +25,7 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.block(MItems.CARBON_FIBRE_BLOCK) provider.block(MItems.METAL_JUNK) provider.block(MItems.METAL_MESH) + provider.generatedTranslucent(MItems.TRITANIUM_BARS, ResourceLocation(DataGen.MOD_ID, "block/decorative/tritanium_bars")) provider.block(MItems.DEEPSLATE_TRITANIUM_ORE) provider.block(MItems.TRITANIUM_ORE) provider.block(MItems.TRITANIUM_STRIPED_BLOCK) @@ -125,6 +126,7 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.block(MItems.MATTER_DECOMPOSER, "matter_decomposer_working") provider.block(MItems.ENERGY_SERVO, "energy_servo") provider.block(MItems.ESSENCE_STORAGE, "essence_storage") + provider.block(MItems.MATTER_RECONSTRUCTOR, "matter_reconstructor") provider.block(MItems.PLATE_PRESS, "plate_press_idle") provider.block(MItems.STORAGE_POWER_SUPPLIER, "storage_power_supplier") diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_bars.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/tritanium_bars.png new file mode 100644 index 0000000000000000000000000000000000000000..86d2aa5aa1ff81eeed557bab794bf6394319df13 GIT binary patch literal 254 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G|^0G|-ow91yoSt~+Pa(h>7&u!`l3Y%|GtOHVPB|(0{|3QFZ^Zq6Kfg+p* z9+AZi419+{nDKc2iWHz=vZsq*FVdQ&MBb@02|F$xBvhE literal 0 HcmV?d00001 From dd7ec5d83906a1cf3d5d1e4f17e554f292aada81 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sat, 25 Mar 2023 23:05:43 +0300 Subject: [PATCH 0452/1199] CAGO 2 --- .../mc/otm/shapes/BlockShapes.java | 16 +++++++++++++++ ...erBlock.kt => MatterReconstructorBlock.kt} | 20 ++++++++++++++++++- .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 4 ++-- 3 files changed, 37 insertions(+), 3 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/{ItemRepairerBlock.kt => MatterReconstructorBlock.kt} (58%) diff --git a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java index b1f97bd01..d87f1ef00 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java +++ b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java @@ -633,4 +633,20 @@ public class BlockShapes { new SimpleCuboid(0.0625d, 0.3125d, 0.875d, 0.9375d, 0.625d, 0.9375d), new SimpleCuboid(0.0625d, 0.3125d, 0.0625d, 0.5625d, 0.9375d, 0.5625d) ); + + public static final BlockShape MATTER_RECONSTRUCTOR = new BlockShape( + new SimpleCuboid(0d, 0.25d, 0d, 1d, 0.5d, 1d), + new SimpleCuboid(0d, 0d, 0d, 1d, 0.25d, 0.6875d), + new SimpleCuboid(0.8125d, 0.5d, 0d, 1d, 1d, 1d), + new SimpleCuboid(0d, 0.5d, 0d, 0.1875d, 1d, 1d), + new SimpleCuboid(0.1875d, 0.5d, 0.0625d, 0.8125d, 0.9375d, 0.9375d), + new SimpleCuboid(-0.0625d, 0.5d, 0.0625d, 0d, 0.9375d, 0.9375d), + new SimpleCuboid(1d, 0.5d, 0.0625d, 1.0625d, 0.9375d, 0.9375d), + new SimpleCuboid(0.25d, 0.5d, 0.25d, 0.75d, 0.5625d, 0.75d), + new SimpleCuboid(0.875d, 0d, 0.6875d, 0.9375d, 0.25d, 0.9375d), + new SimpleCuboid(0.0625d, 0d, 0.6875d, 0.1875d, 0.25d, 0.9375d), + new SimpleCuboid(0.1875d, 0d, 0.6875d, 0.875d, 0.25d, 0.9375d), + new SimpleCuboid(0.36875d, 0.65625d, 0.5875d, 0.44375d, 0.78125d, 0.9d), + new SimpleCuboid(0.4375d, 0.5d, 0.1875d, 0.5625d, 0.625d, 0.3125d) + ); } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/ItemRepairerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReconstructorBlock.kt similarity index 58% rename from src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/ItemRepairerBlock.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReconstructorBlock.kt index d3fc0928b..d46b0e414 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/ItemRepairerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReconstructorBlock.kt @@ -1,16 +1,22 @@ package ru.dbotthepony.mc.otm.block.matter import net.minecraft.core.BlockPos +import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraft.world.level.block.EntityBlock import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.entity.BlockEntityTicker import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.phys.shapes.CollisionContext +import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.matter.MatterReconstructorBlockEntity +import ru.dbotthepony.mc.otm.block.getShapeForEachState +import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.shapes.BlockShapes -class ItemRepairerBlock : RotatableMatteryBlock(), EntityBlock { +class MatterReconstructorBlock : RotatableMatteryBlock(), EntityBlock { override fun newBlockEntity(pPos: BlockPos, pState: BlockState): BlockEntity { return MatterReconstructorBlockEntity(pPos, pState) } @@ -21,4 +27,16 @@ class ItemRepairerBlock : RotatableMatteryBlock(), EntityBlock { return BlockEntityTicker { _, _, _, pBlockEntity -> if (pBlockEntity is MatterReconstructorBlockEntity) pBlockEntity.tick() } } + + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.MATTER_RECONSTRUCTOR.rotateFromNorth(it[rotationProperty]).computeShape() } + + @Suppress("override_deprecation") + override fun getShape( + state: BlockState, + blockGetter: BlockGetter, + pos: BlockPos, + context: CollisionContext + ): VoxelShape { + return shapes[state]!! + } } 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 afe8b208c..90de2a4e3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -47,7 +47,7 @@ import ru.dbotthepony.mc.otm.block.tech.PlatePressBlock import ru.dbotthepony.mc.otm.block.StorageCableBlock import ru.dbotthepony.mc.otm.block.decorative.EngineBlock import ru.dbotthepony.mc.otm.block.decorative.HoloSignBlock -import ru.dbotthepony.mc.otm.block.matter.ItemRepairerBlock +import ru.dbotthepony.mc.otm.block.matter.MatterReconstructorBlock import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock import ru.dbotthepony.mc.otm.block.matter.MatterCapacitorBankBlock import ru.dbotthepony.mc.otm.block.matter.MatterDecomposerBlock @@ -92,7 +92,7 @@ object MBlocks { val ENERGY_SERVO: Block by registry.register(MNames.ENERGY_SERVO) { EnergyServoBlock() } val COBBLESTONE_GENERATOR: Block by registry.register(MNames.COBBLESTONE_GENERATOR) { CobblerBlock() } val ESSENCE_STORAGE: EssenceStorageBlock by registry.register(MNames.ESSENCE_STORAGE) { EssenceStorageBlock() } - val MATTER_RECONSTRUCTOR: ItemRepairerBlock by registry.register(MNames.MATTER_RECONSTRUCTOR) { ItemRepairerBlock() } + val MATTER_RECONSTRUCTOR: MatterReconstructorBlock by registry.register(MNames.MATTER_RECONSTRUCTOR) { MatterReconstructorBlock() } val STORAGE_BUS: Block by registry.register(MNames.STORAGE_BUS) { StorageBusBlock() } val STORAGE_IMPORTER: Block by registry.register(MNames.STORAGE_IMPORTER) { StorageImporterBlock() } From 7869d686f7b7af9bd5bf9cd66780d12addd5b16c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 26 Mar 2023 15:16:16 +0700 Subject: [PATCH 0453/1199] Fix crash caused by panel removing itself during tick --- .../ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 aacde08a7..1f3960e11 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 @@ -582,9 +582,9 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } override fun containerTick() { - for (panel in panels) { - panel.tick() - } + val copy = ArrayList>(panels.size) + for (panel in panels) copy.add(panel) + for (panel in copy) panel.tick() } companion object { From faf43657fc31d1d821db1f6371ff1e3d0cc7b927 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 26 Mar 2023 15:35:48 +0700 Subject: [PATCH 0454/1199] Androids no longer get hunger from "eating" raw food --- .../otm/capability/MatteryPlayerCapability.kt | 23 +++++++++++++++++++ src/main/resources/coremods/code_injector.js | 22 ++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index fcd6c734b..c11d81a68 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -12,7 +12,10 @@ import net.minecraft.server.level.ServerPlayer import net.minecraft.tags.TagKey import net.minecraft.world.Difficulty import net.minecraft.world.effect.MobEffect +import net.minecraft.world.effect.MobEffectInstance +import net.minecraft.world.effect.MobEffects import net.minecraft.world.entity.Entity +import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.MobSpawnType import net.minecraft.world.entity.boss.wither.WitherBoss import net.minecraft.world.entity.monster.Phantom @@ -1259,6 +1262,26 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } } + /** + * hooked into LivingEntity through coremod script + */ + @JvmStatic + fun addEatEffectHook(iterator: Iterator>, entity: LivingEntity): Iterator> { + if (entity !is Player) { + return iterator + } + + val mattery = entity.matteryPlayer ?: return iterator + + if (mattery.isAndroid) { + return iterator.filter { + it.first.effect != MobEffects.HUNGER + } + } + + return iterator + } + /** * this method is hooked through coremod transformer */ diff --git a/src/main/resources/coremods/code_injector.js b/src/main/resources/coremods/code_injector.js index 040e5eacf..78cb5895f 100644 --- a/src/main/resources/coremods/code_injector.js +++ b/src/main/resources/coremods/code_injector.js @@ -599,6 +599,28 @@ function initializeCoreMod() { return node }), + 'LivingEntity#addEatEffect patch for androids': method('net.minecraft.world.entity.LivingEntity.m_21063_(Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/LivingEntity;)V', function(node) { + for (var i = 0; i < node.instructions.size(); i++) { + var instr = node.instructions.get(i) + + if (instr.getOpcode() == opcodesRemapped.invokeinterface && instr.name == "iterator") { + putInstructions(node, node.instructions.get(i), [ + new VarInsnNode(opcodesRemapped.aload, 0), + new MethodInsnNode( + opcodesRemapped.invokestatic, + 'ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability', + 'addEatEffectHook', + '(Ljava/util/Iterator;Lnet/minecraft/world/entity/LivingEntity;)Ljava/util/Iterator;' + ), + ]) + + return node + } + } + + return node + }), + 'Inventory#dropAll': injectAtTail( 'net.minecraft.world.entity.player.Inventory.m_36071_()V', [ From d373393a5cc19b9572317eb44fcfe079b0d22b4e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 26 Mar 2023 15:42:44 +0700 Subject: [PATCH 0455/1199] use array --- .../ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 1f3960e11..577fdcb88 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 @@ -582,9 +582,9 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } override fun containerTick() { - val copy = ArrayList>(panels.size) - for (panel in panels) copy.add(panel) - for (panel in copy) panel.tick() + val copy = arrayOfNulls>(panels.size) + for ((i, panel) in panels.withIndex()) copy[i] = panel + for (panel in copy) panel!!.tick() } companion object { From cbde740747cf0a6d60488edca4ec954648c0dbf5 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Sun, 26 Mar 2023 16:53:01 +0600 Subject: [PATCH 0456/1199] ACKSHUALLY --- .../models/block/essence_storage.json | 38 ++---------------- .../textures/block/essence_storage.png | Bin 1275 -> 1775 bytes 2 files changed, 3 insertions(+), 35 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/essence_storage.json b/src/main/resources/assets/overdrive_that_matters/models/block/essence_storage.json index 9727bad86..95fef5c70 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/essence_storage.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/essence_storage.json @@ -99,8 +99,7 @@ "south": {"uv": [9, 12, 12.5, 13.5], "texture": "#0"}, "west": {"uv": [11.5, 14.5, 15, 16], "texture": "#0"}, "up": {"uv": [9.5, 12.5, 13, 14.25], "texture": "#0"} - }, - "forge_data": { "block_light": 15, "sky_light": 15 } + } }, { "name": "bottle", @@ -126,41 +125,10 @@ { "name": "bottle", "from": [1, 6, 1], - "to": [2, 13, 2], - "faces": { - "north": {"uv": [11.5, 2.5, 12, 4.25], "texture": "#0"}, - "east": {"uv": [8, 2.5, 8.5, 4.25], "texture": "#0"}, - "south": {"uv": [11.5, 2.5, 12, 4.25], "texture": "#0"}, - "west": {"uv": [8, 2.5, 8.5, 4.25], "texture": "#0"} - } - }, - { - "name": "bottle", - "from": [8, 6, 8], "to": [9, 13, 9], "faces": { - "north": {"uv": [11.5, 2.5, 12, 4.25], "texture": "#0"}, - "west": {"uv": [8, 2.5, 8.5, 4.25], "texture": "#0"} - } - }, - { - "name": "bottle", - "from": [1, 6, 8], - "to": [2, 13, 9], - "faces": { - "north": {"uv": [11.5, 2.5, 12, 4.25], "texture": "#0"}, - "east": {"uv": [8, 2.5, 8.5, 4.25], "texture": "#0"}, - "west": {"uv": [8, 2.5, 8.5, 4.25], "texture": "#0"} - } - }, - { - "name": "bottle", - "from": [8, 6, 1], - "to": [9, 13, 2], - "faces": { - "north": {"uv": [11.5, 2.5, 12, 4.25], "texture": "#0"}, - "south": {"uv": [11.5, 2.5, 12, 4.25], "texture": "#0"}, - "west": {"uv": [8, 2.5, 8.5, 4.25], "texture": "#0"} + "north": {"uv": [8, 2.5, 12, 4.25], "texture": "#0"}, + "west": {"uv": [8, 2.5, 12, 4.25], "texture": "#0"} } } ], diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/essence_storage.png b/src/main/resources/assets/overdrive_that_matters/textures/block/essence_storage.png index f0136b877e34d1fd21a6ec81edce323490c58e7c..bf0d329201779959851ae6129fdde23bf7c78429 100644 GIT binary patch delta 1770 zcmV4Y?o}9M1Vk;RjV*fv&QtMX@7eE>scT!2eboS*MUo>Pp8vf z+g!EW*aGd~^y$+83=aEgP}$WHilt%E*KgbV)N$BjwJ2>Z3eONy`Km6 zYWUU?g;Y=Qz>#wP??!m>u?J(?sUJ^}Fn&YVb$|Bk*%LU=y#pn)yhgZm;!w*nDrnF+ zoi0;M){2ZwyMAc!VB^y-L@ErU znd|(K{h#pMmVQd_oab%e&ifzs`r=`qNThnwp1-2TGz-5%|9=3jcYFuE5rTgl`T~Ft zBkDhslarBV_v7w?FC+UjFYqEzul@s<4wffheqEVQO7EPnJHK|S`w8X!&6+8Z&wuBY z^`Anapsa+1aU^7JC4q(`s9*n)sCVg5jgbda)5mdC{l||Z`#%Z%e*M`;H3wCgOj88v z)qmPWY<%zMPShP{A7HqX zp9W62ithxvfM0<>flMO{gpW=Y<~hu7Kn~~zZU?S%S3C{$x=QDPD_of>aFVs8`JT4? z2k@+e(+BheOArs4E?^2cgRsnyOU?k!0+aNzK%6*s`)|V@;9A5A0c?cNe?XW$i*Q2+ z&<8j`Cl)KPJvX(5E_c#7#DD4+fK#sWE?^}hK)*!<>8-$8Y&sAwY5Q@SKm_6pBC7uY zjskzt&DFqlE}3(5QAW7wZ{QpvXxp}cOe;&>$<6>Jvcz$?NErvX0e~twM1amBg4SLP z0@DZ|-v|r1gF921Kjv%`P+Rp=f9UK!8SRIIHzW{7P zY|m*#>Rp1^nrTE#7_Lm)E|_sA&mi{yS>jaarNT6(tNbEx5*P-qapkJO`NbgcDLv$v zVKw4RxQl<#m}UTxoMQ|`)XVes0+4da?q^B+1QzJzSF-37DIx-}50Qd95Sefm5f??o z!E_VijOb^!eFCc}@;AZ_264XSA66m)?Rh)~QXRITMq6wzu|Nk}}_S=4B~ zqSPx6qHKK_-C`733A(jaI^AI%tw%YhrL(Sg=^wFs&i8)Kz4wQE?)RLV&kgc7q1aOZ zz=Rp#%hQvtm$$KjKC`*l_~I3)1Hd4g;WFL46rxsGm7;*?d1wPfu4@ zR~s7}XJ_Y>l#~M1HEFp@EEa!}rHIdv@%em#K!Au`0zx@LDndR&20|mkX@mp>A;KpJi3sTkMF>p@HxMo(C=t{MB7}H^ zefS|0&A&!yM(9M4Aao(H&^!Pw1JSe&Ar|2TLJ7iQgaU*LgffJS2;m4^q-G<8AUO$v ziPkK%N*ms~V=lh4j^$D1(Mv@vUjIqP zE&d$4;-{0R2vsotyC}+BzF$s?-i!SFJ`MTp<05Bu9@2^V&zRr(~8m# zj@4Dj(kXSfWK>f}Zbo!ZUxj?{CE>OQ410O@m{FO_e|8>mTKMHvTw0QBdEXV4t-wxH*y2c4z5@u2wWTIlizxbv(gvb!Kr{ z8}z&>@##mChu!%NtyPxtf2MkP Date: Sun, 26 Mar 2023 17:05:22 +0600 Subject: [PATCH 0457/1199] Oops --- .../overdrive_that_matters/models/block/essence_storage.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/essence_storage.json b/src/main/resources/assets/overdrive_that_matters/models/block/essence_storage.json index 95fef5c70..b8cd1d055 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/essence_storage.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/essence_storage.json @@ -99,7 +99,8 @@ "south": {"uv": [9, 12, 12.5, 13.5], "texture": "#0"}, "west": {"uv": [11.5, 14.5, 15, 16], "texture": "#0"}, "up": {"uv": [9.5, 12.5, 13, 14.25], "texture": "#0"} - } + }, + "forge_data": { "block_light": 15, "sky_light": 15 } }, { "name": "bottle", From 2752a822251ef586d31ab5e84aea3c478495459e Mon Sep 17 00:00:00 2001 From: GearShocky Date: Sun, 26 Mar 2023 19:18:12 +0600 Subject: [PATCH 0458/1199] Active engine model (WIP) --- .../models/block/engine.json | 5 +- .../models/block/engine_active.json | 303 ++++++++++++++++++ 2 files changed, 307 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/engine_active.json diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/engine.json b/src/main/resources/assets/overdrive_that_matters/models/block/engine.json index d3bc265b0..89cb5ee31 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/engine.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/engine.json @@ -1,5 +1,8 @@ { - "parent": "minecraft:block/cube_all", + "credit": "Made with Blockbench", + "parent": "minecraft:block/cube_all", + "render_type": "cutout", + "texture_size": [16, 32], "textures": { "0": "overdrive_that_matters:block/ship_engine", "particle": "overdrive_that_matters:block/ship_engine" diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/engine_active.json b/src/main/resources/assets/overdrive_that_matters/models/block/engine_active.json new file mode 100644 index 000000000..23a785b34 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/engine_active.json @@ -0,0 +1,303 @@ +{ + "credit": "Made with Blockbench", + "parent": "minecraft:block/cube_all", + "render_type": "cutout", + "texture_size": [16, 32], + "textures": { + "0": "overdrive_that_matters:block/ship_engine", + "particle": "overdrive_that_matters:block/ship_engine" + }, + "elements": [ + { + "name": "frame", + "from": [0, 0, 14], + "to": [16, 16, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [0, 0, 8, 4], "rotation": 180, "texture": "#0"}, + "east": {"uv": [0, 4, 8, 4.5], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 8, 4], "texture": "#0"}, + "west": {"uv": [0, 4, 8, 4.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [0, 4, 8, 4.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [0, 4, 8, 4.5], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [1, 1, 10], + "to": [15, 15, 14], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [0, 5.5, 7, 9], "rotation": 180, "texture": "#0"}, + "east": {"uv": [0, 4.5, 7, 5.5], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 7, 7], "texture": "#missing"}, + "west": {"uv": [0, 4.5, 7, 5.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [0, 4.5, 7, 5.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [0, 4.5, 7, 5.5], "texture": "#0"} + } + }, + { + "name": "funnycone", + "from": [4, 4, 7], + "to": [12, 12, 10], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [0, 0, 4, 4], "rotation": 180, "texture": "#missing"}, + "east": {"uv": [2, 1.75, 6, 3.25], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 4, 4], "texture": "#missing"}, + "west": {"uv": [2, 1.75, 6, 3.25], "rotation": 90, "texture": "#0"}, + "up": {"uv": [2, 1.75, 6, 3.25], "rotation": 180, "texture": "#0"}, + "down": {"uv": [2, 1.75, 6, 3.25], "texture": "#0"} + } + }, + { + "name": "funnycone", + "from": [3, 3, 4], + "to": [13, 13, 7], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [0, 0, 5, 5], "rotation": 180, "texture": "#missing"}, + "east": {"uv": [1.5, 2.25, 6.5, 3.75], "rotation": 270, "texture": "#0"}, + "south": {"uv": [1.5, 0.75, 6.5, 3.25], "texture": "#0"}, + "west": {"uv": [1.5, 2.25, 6.5, 3.75], "rotation": 90, "texture": "#0"}, + "up": {"uv": [1.5, 2.25, 6.5, 3.75], "rotation": 180, "texture": "#0"}, + "down": {"uv": [1.5, 2.25, 6.5, 3.75], "texture": "#0"} + } + }, + { + "name": "funnycone", + "from": [2, 2, 0], + "to": [14, 14, 4], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [6, 9, 12, 12], "rotation": 180, "texture": "#0"}, + "east": {"uv": [1, 2, 7, 4], "rotation": 270, "texture": "#0"}, + "south": {"uv": [1, 0.5, 7, 3.5], "texture": "#0"}, + "west": {"uv": [1, 2, 7, 4], "rotation": 90, "texture": "#0"}, + "up": {"uv": [1, 2, 7, 4], "rotation": 180, "texture": "#0"}, + "down": {"uv": [1, 2, 7, 4], "texture": "#0"} + } + }, + { + "name": "funnycone", + "from": [10, 7, 1], + "to": [13, 9, 10], + "rotation": {"angle": -22.5, "axis": "y", "origin": [12, 8, 9.5]}, + "faces": { + "north": {"uv": [12.5, 2.25, 13.5, 3], "rotation": 270, "texture": "#0"}, + "east": {"uv": [12.5, 0, 13.5, 2.25], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 1.5, 1], "texture": "#missing"}, + "west": {"uv": [0, 0, 1, 4.5], "rotation": 90, "texture": "#missing"}, + "up": {"uv": [13.5, 0, 15, 2.25], "rotation": 180, "texture": "#0"}, + "down": {"uv": [11, 0, 12.5, 2.25], "texture": "#0"} + } + }, + { + "name": "funnycone", + "from": [7, 10, 1], + "to": [9, 13, 10], + "rotation": {"angle": 22.5, "axis": "x", "origin": [8, 12, 9.5]}, + "faces": { + "north": {"uv": [12.5, 2.25, 13.5, 3], "rotation": 180, "texture": "#0"}, + "east": {"uv": [11, 0, 12.5, 2.25], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 1, 1.5], "texture": "#missing"}, + "west": {"uv": [13.5, 0, 15, 2.25], "rotation": 90, "texture": "#0"}, + "up": {"uv": [12.5, 0, 13.5, 2.25], "rotation": 180, "texture": "#0"}, + "down": {"uv": [0, 0, 1, 4.5], "texture": "#missing"} + } + }, + { + "name": "funnycone", + "from": [7, 3, 1], + "to": [9, 6, 10], + "rotation": {"angle": -22.5, "axis": "x", "origin": [8, 4, 9.5]}, + "faces": { + "north": {"uv": [12.5, 2.25, 13.5, 3], "rotation": 180, "texture": "#0"}, + "east": {"uv": [13.5, 0, 15, 2.25], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 1, 1.5], "texture": "#missing"}, + "west": {"uv": [11, 0, 12.5, 2.25], "rotation": 90, "texture": "#0"}, + "up": {"uv": [0, 0, 1, 4.5], "rotation": 180, "texture": "#missing"}, + "down": {"uv": [12.5, 0, 13.5, 2.25], "texture": "#0"} + } + }, + { + "name": "funnycone", + "from": [3, 7, 1], + "to": [6, 9, 10], + "rotation": {"angle": 22.5, "axis": "y", "origin": [4, 8, 9.5]}, + "faces": { + "north": {"uv": [12.5, 2.25, 13.5, 3], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 0, 1, 4.5], "rotation": 270, "texture": "#missing"}, + "south": {"uv": [0, 0, 1.5, 1], "texture": "#missing"}, + "west": {"uv": [12.5, 0, 13.5, 2.25], "rotation": 90, "texture": "#0"}, + "up": {"uv": [11, 0, 12.5, 2.25], "rotation": 180, "texture": "#0"}, + "down": {"uv": [13.5, 0, 15, 2.25], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [0, 14, 9], + "to": [2, 16, 14], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [8, 1.75, 9, 2.25], "texture": "#0"}, + "east": {"uv": [9, 0.5, 8, 1.75], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 1, 1], "texture": "#missing"}, + "west": {"uv": [9, 0.5, 8, 1.75], "rotation": 90, "texture": "#0"}, + "up": {"uv": [8, 0.5, 9, 1.75], "rotation": 180, "texture": "#0"}, + "down": {"uv": [8, 0.5, 9, 1.75], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [1, 14, 4], + "to": [2, 15, 9], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [9, 1.5, 9.5, 1.75], "rotation": 180, "texture": "#0"}, + "east": {"uv": [9, 0.25, 9.5, 1.5], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 0.5, 0.25], "texture": "#missing"}, + "west": {"uv": [9, 0.25, 9.5, 1.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [9, 0.25, 9.5, 1.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [9, 0.25, 9.5, 1.5], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [1, 1, 4], + "to": [2, 2, 9], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [9, 1.5, 9.5, 1.75], "rotation": 180, "texture": "#0"}, + "east": {"uv": [9, 0.25, 9.5, 1.5], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 0.5, 0.25], "texture": "#missing"}, + "west": {"uv": [9, 0.25, 9.5, 1.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [9, 0.25, 9.5, 1.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [9, 0.25, 9.5, 1.5], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [14, 1, 4], + "to": [15, 2, 9], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [9, 1.5, 9.5, 1.75], "rotation": 180, "texture": "#0"}, + "east": {"uv": [9, 0.25, 9.5, 1.5], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 0.5, 0.25], "texture": "#missing"}, + "west": {"uv": [9, 0.25, 9.5, 1.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [9, 0.25, 9.5, 1.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [9, 0.25, 9.5, 1.5], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [14, 14, 4], + "to": [15, 15, 9], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [9, 1.5, 9.5, 1.75], "rotation": 180, "texture": "#0"}, + "east": {"uv": [9, 0.25, 9.5, 1.5], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 0.5, 0.25], "texture": "#missing"}, + "west": {"uv": [9, 0.25, 9.5, 1.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [9, 0.25, 9.5, 1.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [9, 0.25, 9.5, 1.5], "texture": "#0"} + } + }, + { + "from": [14, 2, 7], + "to": [15, 14, 9], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [10.5, 0.25, 11, 3.25], "rotation": 180, "texture": "#0"}, + "east": {"uv": [9.5, 0.25, 10.5, 3.25], "texture": "#0"}, + "south": {"uv": [10.5, 0.25, 11, 3.25], "texture": "#0"}, + "west": {"uv": [9.5, 0.25, 10.5, 3.25], "rotation": 180, "texture": "#0"}, + "up": {"uv": [0, 0, 0.5, 1], "rotation": 180, "texture": "#missing"}, + "down": {"uv": [0, 0, 0.5, 1], "texture": "#missing"} + } + }, + { + "name": "frame", + "from": [1, 2, 7], + "to": [2, 14, 9], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [10.5, 0.25, 11, 3.25], "rotation": 180, "texture": "#0"}, + "east": {"uv": [9.5, 0.25, 10.5, 3.25], "texture": "#0"}, + "south": {"uv": [10.5, 0.25, 11, 3.25], "texture": "#0"}, + "west": {"uv": [9.5, 0.25, 10.5, 3.25], "rotation": 180, "texture": "#0"}, + "up": {"uv": [0, 0, 0.5, 1], "rotation": 180, "texture": "#missing"}, + "down": {"uv": [0, 0, 0.5, 1], "texture": "#missing"} + } + }, + { + "name": "frame", + "from": [2, 14, 7], + "to": [14, 15, 9], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [10.5, 0.25, 11, 3.25], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 0, 0.5, 1], "rotation": 270, "texture": "#missing"}, + "south": {"uv": [10.5, 0.25, 11, 3.25], "rotation": 90, "texture": "#0"}, + "west": {"uv": [0, 0, 0.5, 1], "rotation": 90, "texture": "#missing"}, + "up": {"uv": [9.5, 0.25, 10.5, 3.25], "rotation": 270, "texture": "#0"}, + "down": {"uv": [9.5, 0.25, 10.5, 3.25], "rotation": 90, "texture": "#0"} + } + }, + { + "from": [2, 1, 7], + "to": [14, 2, 9], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [10.5, 0.25, 11, 3.25], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 0, 0.5, 1], "rotation": 270, "texture": "#missing"}, + "south": {"uv": [10.5, 0.25, 11, 3.25], "rotation": 90, "texture": "#0"}, + "west": {"uv": [0, 0, 0.5, 1], "rotation": 90, "texture": "#missing"}, + "up": {"uv": [9.5, 0.25, 10.5, 3.25], "rotation": 270, "texture": "#0"}, + "down": {"uv": [9.5, 0.25, 10.5, 3.25], "rotation": 90, "texture": "#0"} + } + }, + { + "name": "frame", + "from": [14, 14, 9], + "to": [16, 16, 14], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [8, 1.75, 9, 2.25], "rotation": 270, "texture": "#0"}, + "east": {"uv": [8, 0.5, 9, 1.75], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 1, 1], "texture": "#missing"}, + "west": {"uv": [8, 0.5, 9, 1.75], "rotation": 90, "texture": "#0"}, + "up": {"uv": [9, 0.5, 8, 1.75], "rotation": 180, "texture": "#0"}, + "down": {"uv": [9, 0.5, 8, 1.75], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [14, 0, 9], + "to": [16, 2, 14], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [8, 1.75, 9, 2.25], "rotation": 180, "texture": "#0"}, + "east": {"uv": [9, 0.5, 8, 1.75], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 1, 1], "texture": "#missing"}, + "west": {"uv": [9, 0.5, 8, 1.75], "rotation": 90, "texture": "#0"}, + "up": {"uv": [8, 0.5, 9, 1.75], "rotation": 180, "texture": "#0"}, + "down": {"uv": [8, 0.5, 9, 1.75], "texture": "#0"} + } + }, + { + "from": [0, 0, 9], + "to": [2, 2, 14], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [8, 1.75, 9, 2.25], "rotation": 90, "texture": "#0"}, + "east": {"uv": [8, 0.5, 9, 1.75], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 1, 1], "texture": "#missing"}, + "west": {"uv": [8, 0.5, 9, 1.75], "rotation": 90, "texture": "#0"}, + "up": {"uv": [9, 0.5, 8, 1.75], "rotation": 180, "texture": "#0"}, + "down": {"uv": [9, 0.5, 8, 1.75], "texture": "#0"} + } + } + ] +} \ No newline at end of file From 42dcd220430b1b185fac6234b85b6e6d25ccfab2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 27 Mar 2023 18:34:20 +0700 Subject: [PATCH 0459/1199] hmm --- .../otm/block/entity/matter/MatterReconstructorBlockEntity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt index 7fcf7bcf5..c1a99e6cf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt @@ -230,7 +230,7 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) val graph = matterNode.graph as MatterGraph? if (graph != null) { - val toDrain = (matterPerTick * EXTRACT_TICKS.coerceAtMost(item.damageValue)).coerceAtLeast(Decimal.ZERO).coerceAtMost(matter.missingMatter) + val toDrain = (matterPerTick * EXTRACT_TICKS.coerceAtMost(item.damageValue) - matter.storedMatter).coerceAtLeast(Decimal.ZERO).coerceAtMost(matter.missingMatter) matter.receiveMatterInner(graph.extractMatter(toDrain, false), false) } } From 5b0988f08e5ae8d7cdccd8d7f2a628ef249c20dc Mon Sep 17 00:00:00 2001 From: GearShocky Date: Mon, 27 Mar 2023 18:13:46 +0600 Subject: [PATCH 0460/1199] Perish --- .../textures/block/android_station_em.png | Bin 487 -> 0 bytes .../textures/block/batterybank_core_em.png | Bin 166 -> 0 bytes .../textures/block/chemical_generator_em.png | Bin 200 -> 0 bytes .../textures/block/drive_rack_em.png | Bin 195 -> 0 bytes .../textures/block/drive_viewer_em.png | Bin 209 -> 0 bytes .../block/gravitational_stabilizer_em.png | Bin 261 -> 0 bytes .../block/gravitational_stabilizer_idle_em.png | Bin 192 -> 0 bytes .../textures/block/item_monitor_em.png | Bin 216 -> 0 bytes .../textures/block/matter_bottler_em.png | Bin 227 -> 0 bytes .../textures/block/matter_decomposer_em.png | Bin 221 -> 0 bytes .../textures/block/matter_panel_em.png | Bin 216 -> 0 bytes .../textures/block/matter_recycler_em.png | Bin 242 -> 0 bytes .../textures/block/matter_replicator_em.png | Bin 227 -> 0 bytes .../block/matter_replicator_halted_em.png | Bin 213 -> 0 bytes .../block/matter_replicator_offline_em.png | Bin 180 -> 0 bytes .../textures/block/matter_scanner_em.png | Bin 246 -> 0 bytes .../textures/block/matterybank_core_em.png | Bin 169 -> 0 bytes .../textures/block/plate_press_em.png | Bin 195 -> 0 bytes .../textures/block/storage_power_supplier_em.png | Bin 197 -> 0 bytes 19 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/android_station_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/batterybank_core_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/chemical_generator_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/drive_rack_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/drive_viewer_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/gravitational_stabilizer_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/gravitational_stabilizer_idle_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/item_monitor_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matter_bottler_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matter_decomposer_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matter_panel_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matter_recycler_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matter_replicator_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matter_replicator_halted_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matter_replicator_offline_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matter_scanner_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matterybank_core_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/plate_press_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/storage_power_supplier_em.png diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/android_station_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/android_station_em.png deleted file mode 100644 index 2e734afc4fd9c7c71b0f4d0ab1359005636b9392..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 487 zcmVPx#1ZP1_K>z@;j|==^1poj532;bRa{vGizW@LZzX3P}QzQTY0eneBK~!i%?U*}~ z!Y~Ym2`8bX-f~aCUV)>~?#!NG>y%spPC=bA71zk>cciSHI3|8D%mjTi9?LRTB-x6A zjgPL`bSw_|bn7K012Gv|cQ)(q`RGD(%2VjtuMUleUbfsT>*0ONP+!H0q9}@@D2k$_ zQqj-n6U!~NrrKR@r29Y*C1muY@t)caW77YiPsVZ}nw+%){vSZ(CNjH0=i||QEO4Od z#Xil_ST!Lum%=vFpvhhiFaL|C;(h|{^N~dZW$Mi00M0`0mIO0^ht55i#cYzcK%&l# z9%OAn5hR@{X)U=GQRFy1A;nn9$Z-e{z1SO`GoIq;BFNw`i_y?p=b)y5>lhByQc@D3 zJ%%iL0#`98a~&(nt3eeEb#0$^se)2?s>vV@9PDx$e`w5{bM`|*0nj|&AD`4}a~rY( zb$!Ly=F!7MHp=DT?c37&v&n#X%@cy-OemryaFB@lPVFl8obLlmoDhdu<-qF=R#3pP d`ETcP`vVHg@#5aAlA-_r002ovPDHLkV1mYh*@XZA diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/batterybank_core_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/batterybank_core_em.png deleted file mode 100644 index 268923c4edad2fd02a997f4c0e400c6b53ec643d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 166 zcmeAS@N?(olHy`uVBq!ia0vp^3P3Et!3HGD8EPYe6k~CayA#8@b22Z19F}xPUq=Rp zjs4tz5?O(K&H|6fVg?4j10c+pb*+;VC}{2J;uzxLoh-r1%qy|bMB>l>gCFEi9pRQR z4fqNn{1`ISV`@iy0XB4uLSEsD@VqP%zfh#W5tq`Rye~t_A}hmx~Wht-ktuRe0e` z!#hW>u!-whI=rYi;Ngj!>gBH=xVO75_v6p)w>x{Ib{~7bMeO~>s3@k{>brk1&fBb7 kP_b$DKX#yzP%xwM1h@PIDTXaSMUp{6p00i_>zopr07tn%)c^nh diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/drive_rack_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/drive_rack_em.png deleted file mode 100644 index b25583f22bd9859935393a8f416d8f7b228f1b7e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 195 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSK$uZf!>a)(7~$#S7!u+B_JSc-gMom{#iOTIAN{>5eB&31 zve(CYqCB*i#s0A$KCr>Hw!ixF#J20!+!6s6hm%ky9kKy>FVdQ&MBb@0OY(w>i_@% diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/drive_viewer_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/drive_viewer_em.png deleted file mode 100644 index 0ea676437cad35f06d5d2e70ff618fa147c98a34..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 209 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3HE3&8=$zQjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`ISV`@iy0XB4uUY_j)~cCfr4qCE{-7?&TlUtNn{1``2&1HT;2cgHa|Au{{zqeH-JJ6=igc{1yZafL4Lvifq>!nHojn>0B3Nn{1`ISV`@iy0XB_Jc5^1#7ShP%zZf#W5tq`R%2RoDBv7Z5O+RceFEiFz=ZE zdPjrb1G&5fEI|>{0*dcV> z?wFYU7AWZH>Eak-;s3VJkPm3xk%s^FQT!5ljJ@65y+#vmX_P&16HwaD!gBY=1uua) z>lh9yPi?3OFW6--uv1mxNb;TIPUkreavZEbn8T>W&+h%g(a9QUD1)b~pUXO@geCxi CCqerF diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/matter_bottler_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/matter_bottler_em.png deleted file mode 100644 index ab1db4e56584b986ad53fd32021226e08d421591..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 227 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3-p)I`?e@QjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`MFV_7T>sx-`2WCjD+9xS1_t;4yUmYH0LqvbB+3CP_L3mK;QwI2Amz>M z1{C5f@Q5sCVBp&i!i*NI!74yO7f%<*5D)LS=dAe{99Ucf=S%*MH(E4fUXoH}_~OE* zHL`|Bzj7qVG1=P-h^}1AyW-lmZ_U>kEX>o)0~i@50MT0ZGcpqn=|_reeF8F%!PC{x JWt~$(69CbuMHv79 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/matter_decomposer_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/matter_decomposer_em.png deleted file mode 100644 index 8ad97db8e80898e5d500bd2fb9530bf30831eef8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 221 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I3?%1nZ+ru!7>k44ofy`glX(f`u%tWsIx;Y9 z?C1WI$O`0h2Ka=yy8qv8ery7e_y2HU1(0Gc3Gxg6|DWOdDPEvj2F?PH$YKTtzWpG~ zXu%q+0u=P~ba4!caDRKwkc&Z)hxOu&-||uW*tTry=x(x3R`mSX@iUEqfs4UmFTt!Ag2R9yR^A%s7X!t5pj!rP2lKQ>Mz#ey_=E3N)F))78&q Iol`;+029bUeE{L}al6>d5(|L}A90%(U<}hmUvwOdAbg~8-%HZkh=d#Wzp$Pym C)j=u% diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/matter_recycler_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/matter_recycler_em.png deleted file mode 100644 index 6b48c2cb83aa06724c66ab7c6c4b34e65e6611e4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 242 zcmeAS@N?(olHy`uVBq!ia0vp^3P9|@!3-pQ0$S$)DaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(eheq5(c3uK#Z^{D0uNm4V?u1B3hj-R8$80Ak diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/matter_replicator_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/matter_replicator_em.png deleted file mode 100644 index 09c99d763d0c544a593267a517324e41b06d089d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 227 zcmeAS@N?(olHy`uVBq!ia0vp^3P9|@!3-pQ0$S$)DaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(ehe`~f~8uK#Z^{D0tSer$sK|J^{bJx{VX0V&p!Aiv=MK)~>O8(%O`fV03O zvY3H^Z$Ah#TCfJI00n(KT^vI^ypt0Y8D1=EXlxWbb&Tsp5))&CFQc$A50fQx3KN$^ zCFAYgY_Hvsq?eN4gk$% N@O1TaS?83{1OOABKgIw6 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/matter_replicator_halted_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/matter_replicator_halted_em.png deleted file mode 100644 index a83f9bd046d862e762a1f8f640e6d8e06a8096c4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 213 zcmeAS@N?(olHy`uVBq!ia0vp^3P9|@!3HF&`%2dVDaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(eheoCO|{#S9F5`$3q|f;CtLD46Bx;uwx7?gIb zZ-2z#_dqUBVCA={FG`F4?ssO+V!; zzPrTIjeDWI_R4$gc4}#=YKvyYT#}x6@Kj9fmc7wSP2+Q&`F7Ps zw8W#;{oCdXvkNSKd$e?ag7fOiJJ)y^4wx@3+f)CxY31UZGapLsH?Y diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/matterybank_core_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/matterybank_core_em.png deleted file mode 100644 index 9e65bdf498bb663bbb3f000469a5be62620b5b2f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 169 zcmeAS@N?(olHy`uVBq!ia0vp^3P3Et!3HGD8EPYe6k~CayA#8@b22Z19F}xPUq=Rp zjs4tz5?O(K&H|6fVg?4j{UFR}!5XXr6twenaSZYBPL^P0=9O4zA~8dL_6PY>N4Wi> zL>IhR%(6h@$-jE@K)xF%UwBEg_p}|z-~bXGJdJ?{2O1g~8It%kxRoQ#Hv&y!@O1Ta JS?83{1OTgwEpq?> diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/plate_press_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/plate_press_em.png deleted file mode 100644 index 2340c4106a9b650d56009553157a9759e9d9c5c2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 195 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3HE3&8=$zQjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`ISV`@iy0XB4uLSEsD@VqP%y&N#W5tq`Rye~t_A}hmx~9dhOhn}y8h9n zH=mZT&(l4Zsk8A?R26gdl(XL%&fk=_Sd_Eu fKO@jMC`eP-yI)_5A?2I(2at%TtDnm{r-UW|Z7G;uwkXbecq)78&qol`;+09P$PTmS$7 From 51c23b425c5fc559f8c95b5780c1c5faf8d69c34 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Mon, 27 Mar 2023 18:17:14 +0600 Subject: [PATCH 0461/1199] Cargo crates texture update --- .../textures/block/cargo_crates/cargo_crate.png | Bin 417 -> 559 bytes .../block/cargo_crates/cargo_crate_black.png | Bin 417 -> 559 bytes .../block/cargo_crates/cargo_crate_blue.png | Bin 416 -> 559 bytes .../block/cargo_crates/cargo_crate_brown.png | Bin 417 -> 559 bytes .../block/cargo_crates/cargo_crate_cyan.png | Bin 417 -> 559 bytes .../block/cargo_crates/cargo_crate_gray.png | Bin 417 -> 559 bytes .../block/cargo_crates/cargo_crate_green.png | Bin 417 -> 559 bytes .../cargo_crates/cargo_crate_light_blue.png | Bin 417 -> 559 bytes .../cargo_crates/cargo_crate_light_gray.png | Bin 417 -> 559 bytes .../block/cargo_crates/cargo_crate_lime.png | Bin 417 -> 559 bytes .../block/cargo_crates/cargo_crate_magenta.png | Bin 417 -> 559 bytes .../block/cargo_crates/cargo_crate_orange.png | Bin 417 -> 559 bytes .../block/cargo_crates/cargo_crate_pink.png | Bin 417 -> 559 bytes .../block/cargo_crates/cargo_crate_purple.png | Bin 417 -> 559 bytes .../block/cargo_crates/cargo_crate_red.png | Bin 417 -> 559 bytes .../block/cargo_crates/cargo_crate_white.png | Bin 417 -> 559 bytes .../block/cargo_crates/cargo_crate_yellow.png | Bin 417 -> 559 bytes 17 files changed, 0 insertions(+), 0 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate.png index f55a0c4b7739021eb362655bc497e6acd564ecfd..9c627d98a36ff788ceaed8de7759431e2cc8a90a 100644 GIT binary patch delta 504 zcmVb}m3={^X$k6=%=YMu}nCUbkp6P459-~-n z7F{+Gm2wCVT_5BXv~oj4iM%Xwd#8I zBm4^&L3mGq_|PoIK*XM1eP74AUmK|w@D0l3K*I1F|_b6AbkUi+h4>Ggi9eA zIp4Sxl4kkFrLZNuQ9v)zN1q2wPWTt73`U~!w2+Ba%-o0a<1T5B&#Ig?U@ z&|AYqHEKO0P&;*!e4@^l9^neqas^B(z9PherQsp`3vrlP{GU_-gw}ib7pUuYC;(f6 zDL^A3*aowhL_*N-g5b5c1y}eN$h_FK1y}eN;s_Du%@Izxg4|~zCXg!J6)H+?3Tdgm uSq<&pG%MQeU;C`xVYm1vIQ|6T`TPRcH&$Xl+t&yH0000PnMg}?&wf9}uHk+OidY0Ys;>8m4mMWuoW?tKeS3W%DJl__1WwGNU_Nyxvhlzi& zIG41D=lr42gR-K|K;03)wJWq4%hw!k30k2(!BNHHits6)f)(mhmUBKk(ov;U@#bTa z;j5E(1Y&#~?RK7(UOP`ljMqm(BEtWtbklr;oZH;%OiVqSCq6X>h5>`8tDnm{r-UW| D75boB diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_black.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_black.png index 062cb67065f8c47c803550c229409714a767a1d5..351e6d1f97cd80185954894fabb915c92baee1f1 100644 GIT binary patch delta 504 zcmVOVv|#qO0000FbW%=J|NsC0|NsC0|NsC0|Nj8g+?b&N000SaNLh0L z01m$Z01m$aI0aKA0004SNklb}m3={^X$k6=%=YMu}nCUbkp6P459-~-n z7F{+Gm2wCVT_5BXv~oj4iM%Xwd#8I zBm4^&L3mGq_|PoIK*XM1eP74AUmK|w@D0l3K*I1F|_b6AbkUi+h4>Ggi9eA zIp4Sxl4kkFrLZNuQ9v)zN1q2wPWTt73`U~!w2+Ba%-o0a<1T5B&#Ig?U@ z&|AYqHEKO0P&;*!e4@^l9^neqas^B(z9PherQsp`3vrlP{GU_-gw}ib7pUuYC;(f6 zDL^A3*aowhL_*N-g5b5c1y}eN$h_FK1y}eN;s_Du%@Izxg4|~zCXg!J6)H+?3Tdgm uSq<&pG%MQeU;C`xVYm1vIQ|6T`TPRcH&$Xl+t&yH0000mR-Sv|*9(MArHh+a66%>OWGj*X+z9Io{JzGJ&F3N^h1O2*`Gw zGQHS2^yv52gKzFM6qFiVJg{Kdj~V-KH&hv!`z+tF@kI3PJ$YA3SATDJwLMtaXp{HK z(|pEOBLkg?+WW3+n@!IMJ zoJ(57bN*21L0M5}pzes@+7;T2GN>8Mhwc=IvI z@YTsX0x>?0c012Xubn3&#_J;?5#j$+x@o>a&TZ~>CZ?Xv6Q3Fb!+^ol)z4*}Q$iB} DR<)iJ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_blue.png index 9b96f96e71a93ec1541600da3bfb3b22a1d7a7c9..d08bba27ecd61a951a265614316584abaae849d9 100644 GIT binary patch delta 504 zcmVb}m3={^X$k6=%=YMu}nCUbkp6P459-~-n z7F{+Gm2wCVT_5BXv~oj4iM%Xwd#8I zBm4^&L3mGq_|PoIK*XM1eP74AUmK|w@D0l3K*I1F|_b6AbkUi+h4>Ggi9eA zIp4Sxl4kkFrLZNuQ9v)zN1q2wPWTt73`U~!w2+Ba%-o0a<1T5B&#Ig?U@ z&|AYqHEKO0P&;*!e4@^l9^neqas^B(z9PherQsp`3vrlP{GU_-gw}ib7pUuYC;(f6 zDL^A3*aowhL_*N-g5b5c1y}eN$h_FK1y}eN;s_Du%@Izxg4|~zCXg!J6)H+?3Tdgm uSq<&pG%MQeU;C`xVYm1vIQ|6T`TPRcH&$Xl+t&yH0000h34x3 delta 360 zcmZ3_vVeJlW4&B}Pl&6jscAw&LSSHEeSJLx1B05HnwXfFvFU6T)oLKu@|@CEAjMS@ zT^vI^yx&fK$k$}R)8ef?d(VIF z+tK-d8Jh)#g@yl$SfBI0zEweqJD@)IVE)^QGwye-;oaQfet46ZdkAY`>^510D^ZDG z3-VU1`mxtw#$4$MF|s)(1}il6KIcaV_&;lVDQ4car}WHgx7h7f_ByXPkFgfrxiUG= zAUiQ3BB0jZb#1d$n&dN6msc;An733Jt#53b_wdSxr;_tPwlp7+UnS_iR_{gOnMH{_ z=?_;u=8ve#JgtcFFKG=G^{oo4q zV&{U5tUsR^=5MJo(vg~xn2=!eG@qmH(1u+7brVcIS=_%|1_l9xr>mdKI;Vst0C^*s A%>V!Z diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_brown.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_brown.png index 78c9e9e0210dc188fc3658a19e530bdeba3fb466..8142ac08f868ae497db8f35cafe0effd14e030a4 100644 GIT binary patch delta 504 zcmVb}m3={^X$k6=%=YMu}nCUbkp6P459-~-n z7F{+Gm2wCVT_5BXv~oj4iM%Xwd#8I zBm4^&L3mGq_|PoIK*XM1eP74AUmK|w@D0l3K*I1F|_b6AbkUi+h4>Ggi9eA zIp4Sxl4kkFrLZNuQ9v)zN1q2wPWTt73`U~!w2+Ba%-o0a<1T5B&#Ig?U@ z&|AYqHEKO0P&;*!e4@^l9^neqas^B(z9PherQsp`3vrlP{GU_-gw}ib7pUuYC;(f6 zDL^A3*aowhL_*N-g5b5c1y}eN$h_FK1y}eN;s_Du%@Izxg4|~zCXg!J6)H+?3Tdgm uSq<&pG%MQeU;C`xVYm1vIQ|6T`TPRcH&$Xl+t&yH0000)=VeU|Uocq01tp1doitG~Cq+8!)yw8?wr zX+C4Ck%3M`?S0p^&8BCBo@IBuc(KI1rOGItnb-E=l@Cuj&$mThS?u_T{pyOvVd7sb z&Lu74Ie#ehpsc7fPHBf>x+ca8$9lB7DlHV1@dW<($usbW|x-y!n`9 z`0C^xffyf0yPapH*Upm>gTe~DWM4f D-pihP diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_cyan.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_cyan.png index 3b946c37ff42fb8dd27b8f753c86d3953d857554..7d2724f68906839c59e97f09c3193d4417c56d36 100644 GIT binary patch delta 504 zcmVb}m3={^X$k6=%=YMu}nCUbkp6P459-~-n z7F{+Gm2wCVT_5BXv~oj4iM%Xwd#8I zBm4^&L3mGq_|PoIK*XM1eP74AUmK|w@D0l3K*I1F|_b6AbkUi+h4>Ggi9eA zIp4Sxl4kkFrLZNuQ9v)zN1q2wPWTt73`U~!w2+Ba%-o0a<1T5B&#Ig?U@ z&|AYqHEKO0P&;*!e4@^l9^neqas^B(z9PherQsp`3vrlP{GU_-gw}ib7pUuYC;(f6 zDL^A3*aowhL_*N-g5b5c1y}eN$h_FK1y}eN;s_Du%@Izxg4|~zCXg!J6)H+?3Tdgm uSq<&pG%MQeU;C`xVYm1vIQ|6T`TPRcH&$Xl+t&yH0000BINI$zE4_A}j2N$vghYh@PwA%l206F6*O{1lHcxzN3=9JXPgg&ebxsLQ06)8( A_y7O^ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_gray.png index f2f18b4b4d3ccbe6f4d209de36806ee30d53c587..c4fa7b5cf4f8d40b331b96b91f5b03698b0cd0eb 100644 GIT binary patch delta 504 zcmVb}m3={^X$k6=%=YMu}nCUbkp6P459-~-n z7F{+Gm2wCVT_5BXv~oj4iM%Xwd#8I zBm4^&L3mGq_|PoIK*XM1eP74AUmK|w@D0l3K*I1F|_b6AbkUi+h4>Ggi9eA zIp4Sxl4kkFrLZNuQ9v)zN1q2wPWTt73`U~!w2+Ba%-o0a<1T5B&#Ig?U@ z&|AYqHEKO0P&;*!e4@^l9^neqas^B(z9PherQsp`3vrlP{GU_-gw}ib7pUuYC;(f6 zDL^A3*aowhL_*N-g5b5c1y}eN$h_FK1y}eN;s_Du%@Izxg4|~zCXg!J6)H+?3Tdgm uSq<&pG%MQeU;C`xVYm1vIQ|6T`TPRcH&$Xl+t&yH0000PnMg}?&wf9}uHk+OidY0Ys;>8m4mMWuoW?tKeS3W%DJl__1WwGNU_Nyxvhlzi& zIG41D=lr42gR-K|K;03)wJWq4%hw!k30k2(!BNHHits6)f)(mhmUBKk(ov;U@#bTa z;j5E(1Y&#~?RK7(UOP`ljMqm(BEtWtbklr;oZH;%OiVqSCq6X>h5>`8tDnm{r-UW| DUc;W_ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_green.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_green.png index 364f0a6680e29a47eaee8acf1a54ce71a868e20c..8392f07d4aba67cd0fd9b1545c6ed6fff6a03cd6 100644 GIT binary patch delta 504 zcmVb}m3={^X$k6=%=YMu}nCUbkp6P459-~-n z7F{+Gm2wCVT_5BXv~oj4iM%Xwd#8I zBm4^&L3mGq_|PoIK*XM1eP74AUmK|w@D0l3K*I1F|_b6AbkUi+h4>Ggi9eA zIp4Sxl4kkFrLZNuQ9v)zN1q2wPWTt73`U~!w2+Ba%-o0a<1T5B&#Ig?U@ z&|AYqHEKO0P&;*!e4@^l9^neqas^B(z9PherQsp`3vrlP{GU_-gw}ib7pUuYC;(f6 zDL^A3*aowhL_*N-g5b5c1y}eN$h_FK1y}eN;s_Du%@Izxg4|~zCXg!J6)H+?3Tdgm uSq<&pG%MQeU;C`xVYm1vIQ|6T`TPRcH&$Xl+t&yH0000?%=i4H$EOvaves#s-F!3)I z=aLrjoIezLP*&6#s5|1fc7--$`I^HmK`YcJII37&5kBQputI&xa?WQ*I;xZ^-h50l ze0B1UK#Y&0-OjVpYv;*`@%l(eMEL)dZklh9bDMjeiK%Dv#HYr^>bP0l+XkK DKEj>& diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_light_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_light_blue.png index d6fbbea41dc59e9ef5aaa26da2407c1179468e23..90cf6bcc90e732f296f3b0b5144f8061318aa87f 100644 GIT binary patch delta 485 zcmVu4#wA(bEzyJUM3W`|N0000FbW%=J|NsC0|NsC0|NsC0|Nj8g+?b(}eiwfMa7jc# zR7gwhRM~RFAPf`+rO43y|L1mfnCUbkp6P459-~-n7F{+Gm2wCVT_5BXv~oj4iM%Xwd#8IBm4^&L3mGq_|PoIK*XM z1eP74AUmK|w@D0l3K*I1F|_b6AbkUi+h4>Ggi9eAIp4Sxl4kkFrLZNuQ9v)zN1q2w zPWTt73`U~!w2+Ba%-o0a<1T5B&#Ig?U@&|AYqHEKO0P& z)N%z(D!wAbf~Dah{0o>_{GU_-gw}ib7pUuYC;(f6DL^A3*aowhL_*N-g5b5c1y}eN z$h_FK1y}eN;s_Du%@Izxg4|~zCXg!J6)H+?3TdgmSq<&pG%MQeU;C`xVYm1vIQ|6T b`TPRcH&$Xl+t&yH000R9NkvXXu0mjf$fV`) delta 361 zcmZ3_vXFU#W4&B}Pl&6jscAw&LSSHEeSJLx1B05HnwXfF^_JV}lgPnMg}?&wf9}uHk+OidY0Ys;>8m4mMWuoW?tKeS3W%DJl__1WwGNU_Nyxvhlzi& zIG41D=lr42gR-K|K;03)wJWq4%hw!k30k2(!BNHHits6)f)(mhmUBKk(ov;U@#bTa z;j5E(1Y&#~?RK7(UOP`ljMqm(BEtWtbklr;oZH;%OiVqSCq6X>h5>`8tDnm{r-UW| Ddd!~4 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_light_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_light_gray.png index 9d573a1c26a14873ccd00f5f67ed1b59cf9833d9..62e44425351d1f35247499f06d110c5d6ce51894 100644 GIT binary patch delta 504 zcmZ3;yq;x(W4&&GPl&6jscA?^NJ2tFU|^uOwsw7e{r?*b{~vg&si_qe6^V(7H8)rH z^fXsj7c($0JPdaA0aE-WL4LviQ2@i0J2Msnr8o;bB7rLT_Jc5^1#7Sh0|R4$r;B5V zhxgl%n?;8ectqHip1APm|MU8?(ityJl;*w6-YvH{B1bINOmJ$EjQiRMFU71Q{rv}; zKYH9%c=K&)z%R~#wM({5f6lLw*wZ;V<-}O685PrB(;lxk1?%G*VD>w@mSzdCwJI!j=(fUWz z4(D>qY7?x?W3l*#vgl+faDd&=y`QC8L2YrQF=I-0^M+92D6(ue2?+}@k_Vd`% z4XS$r9rQ1{&u91X`ysx9hxysT2`L{l6AEWfxn-VJI(zD`D^c0{UY3)CnlD5jb}`Me zRSvK&om8{v+%&m|Tvv)%eYEx|9cfznQ1K6U;f%;X^FtV0u2lm~dR?Z$5Z$EdpsaX< zZSxElrwi|!9&Fvt8vaB4#GV^lLG&XI!DnX${dP3nNmo>xpmj%7%PW^FbLHMh-naKm sv~RtQ|GnmJ;`Sfv7XMft{`|vq-8?MG{`PeaV4N^`y85}Sb4q9e0Nl~&J^%m! delta 361 zcmZ3_vXFU#W4&B}Pl&6jscAw&LSSHEeSJLx1B05HnwXeaPfv4pb`p@w?p_iBq_|3g z{DS|(0K=v;I_H6+oCO|{#S9F52SAuH>slu#Q1F|li(`m~_uDDC{LKnHE!ozI|Nh(W zk+c2f7CLhO0okro zrWZSh9{t{W@Xeiuf>MKv2No>*F=PMjhAJa-pXEC?o`}A^C+|w>>hJBYwg(FvZSr1u zn$Os3WS|pKd*5|!v*{V3XW1PuUMw+hsWOUZ=Cyrz<-=3X^KFq=7CSy-zq(>^nD`fq zb4iPM&L0XrC@bm=)E)6#yF#0>e9hsOpcU#9991l?2%qvPSfM^;Ip?z@9aTydZ$2g& zzB+kFAjZehZs%F)wew`eczq-!BK&_!H_bQ5xy`-K#MHBS;!|T_7%+Ic`njxgN@xNA DW@w(^ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_lime.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_lime.png index 9f70f39c0fba0fabcea0991081cadcd0bc41d1fc..1f499d89c641afb9e6576fbc27c196e37906d70c 100644 GIT binary patch delta 504 zcmVb}m3={^X$k6=%=YMu}nCUbkp6P459-~-n z7F{+Gm2wCVT_5BXv~oj4iM%Xwd#8I zBm4^&L3mGq_|PoIK*XM1eP74AUmK|w@D0l3K*I1F|_b6AbkUi+h4>Ggi9eA zIp4Sxl4kkFrLZNuQ9v)zN1q2wPWTt73`U~!w2+Ba%-o0a<1T5B&#Ig?U@ z&|AYqHEKO0P&;*!e4@^l9^neqas^B(z9PherQsp`3vrlP{GU_-gw}ib7pUuYC;(f6 zDL^A3*aowhL_*N-g5b5c1y}eN$h_FK1y}eN;s_Du%@Izxg4|~zCXg!J6)H+?3Tdgm uSq<&pG%MQeU;C`xVYm1vIQ|6T`TPRcH&$Xl+t&yH00007qdHS3AL6AjMS@ zmR-Sv|*9(MArHh+a66%>OWGj*X+z9Io{JzGJ&F3N^h1O2*`Gw zGQHS2^yv52gKzFM6qFiVJg{Kdj~V-KH&hv!`z+tF@kI3PJ$YA3SATDJwLMtaXp{HK z(|pEOBLkg?+WW3+n@!IMJ zoJ(57bN*21L0M5}pzes@+7;T2GN>8Mhwc=IvI z@YTsX0x>?0c012Xubn3&#_J;?5#j$+x@o>a&TZ~>CZ?Xv6Q3Fb!+^ol)z4*}Q$iB} DY0;kL diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_magenta.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_magenta.png index 8f016fc6eb085f2859b1e4b08302001d5d00d8ca..25eb700cab5706481e20e710b8ddef7dc539c8a5 100644 GIT binary patch delta 504 zcmVB-6z0000FbW%=J|NsC0|NsC0|NsC0|Nj8g+?b&N000SaNLh0L z01m$Z01m$aI0aKA0004SNklb}m3={^X$k6=%=YMu}nCUbkp6P459-~-n z7F{+Gm2wCVT_5BXv~oj4iM%Xwd#8I zBm4^&L3mGq_|PoIK*XM1eP74AUmK|w@D0l3K*I1F|_b6AbkUi+h4>Ggi9eA zIp4Sxl4kkFrLZNuQ9v)zN1q2wPWTt73`U~!w2+Ba%-o0a<1T5B&#Ig?U@ z&|AYqHEKO0P&;*!e4@^l9^neqas^B(z9PherQsp`3vrlP{GU_-gw}ib7pUuYC;(f6 zDL^A3*aowhL_*N-g5b5c1y}eN$h_FK1y}eN;s_Du%@Izxg4|~zCXg!J6)H+?3Tdgm uSq<&pG%MQeU;C`xVYm1vIQ|6T`TPRcH&$Xl+t&yH0000EamT;r(_>E`PHEPfNCS;=lj) zd*p0?IR>7Yr0TsbUH|CqrwxmQC$iSB*!F08QvZ>Hy=G??$?=|!k_i;OQhKxOKtQ(Z zlB9(;4Bp`g^@;(-Ore$3c^yP?X++-LcYjVGdS@5#GTy83&&tL?$UMw`4> zp5`;Q8X4$B)ZTYp+iZG9=vj8hix*4GTdIuWnR#s=Uit8p^L$(6mBo&a*srcw947w7 z;#|@qp7V!756X%<19eCI)~?WIEMIfDC1{2E1Vb}m3={^X$k6=%=YMu}nCUbkp6P459-~-n z7F{+Gm2wCVT_5BXv~oj4iM%Xwd#8I zBm4^&L3mGq_|PoIK*XM1eP74AUmK|w@D0l3K*I1F|_b6AbkUi+h4>Ggi9eA zIp4Sxl4kkFrLZNuQ9v)zN1q2wPWTt73`U~!w2+Ba%-o0a<1T5B&#Ig?U@ z&|AYqHEKO0P&;*!e4@^l9^neqas^B(z9PherQsp`3vrlP{GU_-gw}ib7pUuYC;(f6 zDL^A3*aowhL_*N-g5b5c1y}eN$h_FK1y}eN;s_Du%@Izxg4|~zCXg!J6)H+?3Tdgm uSq<&pG%MQeU;C`xVYm1vIQ|6T`TPRcH&$Xl+t&yH0000CARyay z%JgFA(4*g555Bq6P*7@c@xX#*KW6N|-B4v@?z4Qy#uL%E_vBqEUH!e?)%IXvqfOo` zPxBdDjSO@mYVW(QZ8kk4^ensM#fv58EmcPG%)GV_uY7pQdA=?3%3{Yy>{nMT4io=k zaV}{Q&-p{42W3T_fx07pYgcG9majS760|~nf}@JX72#7p1uN92Ea!Z7q@zly;?2h- z!&fKo2*mg}+U-0my>_0A7_X0nM1=oO>8AMxIk&mjnV5PuPkd?&3lRnl>h($(1whd0000FbW%=J|NsC0|NsC0|NsC0|Nj8g+?b&N000SaNLh0L z01m$Z01m$aI0aKA0004SNklb}m3={^X$k6=%=YMu}nCUbkp6P459-~-n z7F{+Gm2wCVT_5BXv~oj4iM%Xwd#8I zBm4^&L3mGq_|PoIK*XM1eP74AUmK|w@D0l3K*I1F|_b6AbkUi+h4>Ggi9eA zIp4Sxl4kkFrLZNuQ9v)zN1q2wPWTt73`U~!w2+Ba%-o0a<1T5B&#Ig?U@ z&|AYqHEKO0P&;*!e4@^l9^neqas^B(z9PherQsp`3vrlP{GU_-gw}ib7pUuYC;(f6 zDL^A3*aowhL_*N-g5b5c1y}eN$h_FK1y}eN;s_Du%@Izxg4|~zCXg!J6)H+?3Tdgm uSq<&pG%MQeU;C`xVYm1vIQ|6T`TPRcH&$Xl+t&yH0000fSSo|bIu#DD+o z_sH4)atu5(N!5E>y8hAIPa75qPh_oMvF*|Hr2ZoXd(F-)lH)xcB@-xmrSxXmfq-n+ zDbtIcLyvxMJ^1EMLqVy*#RChL{g|=;c0-ksxzF+)8&5>v-jjEwboKXkSKEVyjW&6& zJk4ipH8RkNsJ-vHw%PQI(6j807cZ8Ww^SL$GxOR$yz=2G=lQnCD~lZ;v0q)WI86MD z#kr(KJm(LE9+VYz2I`LZtzDtbSia_POVA4S363fjSAsV z3}2nRBM{@`Xt(pM^xAncV!S>Q5)uACrJLp(b}m3={^X$k6=%=YMu}nCUbkp6P459-~-n z7F{+Gm2wCVT_5BXv~oj4iM%Xwd#8I zBm4^&L3mGq_|PoIK*XM1eP74AUmK|w@D0l3K*I1F|_b6AbkUi+h4>Ggi9eA zIp4Sxl4kkFrLZNuQ9v)zN1q2wPWTt73`U~!w2+Ba%-o0a<1T5B&#Ig?U@ z&|AYqHEKO0P&;*!e4@^l9^neqas^B(z9PherQsp`3vrlP{GU_-gw}ib7pUuYC;(f6 zDL^A3*aowhL_*N-g5b5c1y}eN$h_FK1y}eN;s_Du%@Izxg4|~zCXg!J6)H+?3Tdgm uSq<&pG%MQeU;C`xVYm1vIQ|6T`TPRcH&$Xl+t&yH0000mR-Sv|*9(MArHh+a66%>OWGj*X+z9Io{JzGJ&F3N^h1O2*`Gw zGQHS2^yv52gKzFM6qFiVJg{Kdj~V-KH&hv!`z+tF@kI3PJ$YA3SATDJwLMtaXp{HK z(|pEOBLkg?+WW3+n@!IMJ zoJ(57bN*21L0M5}pzes@+7;T2GN>8Mhwc=IvI z@YTsX0x>?0c012Xubn3&#_J;?5#j$+x@o>a&TZ~>CZ?Xv6Q3Fb!+^ol)z4*}Q$iB} D+=HJ( diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_red.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_red.png index 21cc02660279da75123c22e7610b8b4927863e76..ac61d4fa4d845c8cad4efb1c82591c8fca40a854 100644 GIT binary patch delta 504 zcmVb}m3={^X$k6=%=YMu}nCUbkp6P459-~-n z7F{+Gm2wCVT_5BXv~oj4iM%Xwd#8I zBm4^&L3mGq_|PoIK*XM1eP74AUmK|w@D0l3K*I1F|_b6AbkUi+h4>Ggi9eA zIp4Sxl4kkFrLZNuQ9v)zN1q2wPWTt73`U~!w2+Ba%-o0a<1T5B&#Ig?U@ z&|AYqHEKO0P&;*!e4@^l9^neqas^B(z9PherQsp`3vrlP{GU_-gw}ib7pUuYC;(f6 zDL^A3*aowhL_*N-g5b5c1y}eN$h_FK1y}eN;s_Du%@Izxg4|~zCXg!J6)H+?3Tdgm uSq<&pG%MQeU;C`xVYm1vIQ|6T`TPRcH&$Xl+t&yH0000PnMg}?&wf9}uHk+OidY0Ys;>8m4mMWuoW?tKeS3W%DJl__1WwGNU_Nyxvhlzi& zIG41D=lr42gR-K|K;03)wJWq4%hw!k30k2(!BNHHits6)f)(mhmUBKk(ov;U@#bTa z;j5E(1Y&#~?RK7(UOP`ljMqm(BEtWtbklr;oZH;%OiVqSCq6X>h5>`8tDnm{r-UW| D2vwhI diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_white.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_white.png index c78517fb862a240132a24bb41b746d6ca43066d5..42c4ce711e8ac21ae02d40425e8a4ddade4f6748 100644 GIT binary patch delta 504 zcmVb}m3={^X$k6=%=YMu}nCUbkp6P459-~-n z7F{+Gm2wCVT_5BXv~oj4iM%Xwd#8I zBm4^&L3mGq_|PoIK*XM1eP74AUmK|w@D0l3K*I1F|_b6AbkUi+h4>Ggi9eA zIp4Sxl4kkFrLZNuQ9v)zN1q2wPWTt73`U~!w2+Ba%-o0a<1T5B&#Ig?U@ z&|AYqHEKO0P&;*!e4@^l9^neqas^B(z9PherQsp`3vrlP{GU_-gw}ib7pUuYC;(f6 zDL^A3*aowhL_*N-g5b5c1y}eN$h_FK1y}eN;s_Du%@Izxg4|~zCXg!J6)H+?3Tdgm uSq<&pG%MQeU;C`xVYm1vIQ|6T`TPRcH&$Xl+t&yH00004nJ@ErhQ#;j|doIt^Eo-U3d9^P-K%lj78VX7cE*@C0?8l7#w;QUA%zc*c*mxrP_MW^erK`WUyV@QsY_!RH z@fnmVl>FVdQ&MBb@ E0O81^JOBUy diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_yellow.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_yellow.png index f36b2ef95a17a675ba6f1c5a7e536fa30133d4b6..869b0ec60720f92a3c65c89b1b3adc2911a951f6 100644 GIT binary patch delta 504 zcmZ3;yq;x(W4&&GPl&6jscA?^NJ2tFU|^uOwsw7e{r?*b{~vg&si_qe6^V(7z1gkw z=eWw<^$H9?@b;7&kmN53@(cct0vN8`nXwQk#aZAHSF+<# z{L$mC!kceX1AcJ^tX;Bg`g4Ab#GcN{8D}O6@(DbX+4`#LoAMuSamNb(h94JnjyW7z z-*PH6f11`0MbkgruP#R)FiiU){;uC)g7CwQ3MYQ5b=S^{TESVk$nuiY-Dy^{j@Cb# zc4+^HOYc7D$FNM3U8rEaAZ)uQPdS&w%=d;{KIkjdGI!sOKO)fLtte@Ee}~AVw4cY8 zZcyD5=%9bmeLlO7-w*K>Jj~AyPDuHfnNT=;$}RJ((%DmgU5U!p_p+QE)O;cOu#0Jy zt#W{M>7<%P=cdU$Z7$!=}6Pkhl+o=3ui?BnIFQ~a;+L@((5t}hUg|u2W7<@ zY@27eI9+((^kD0D*6<(VC-&Uf3Zfrz2tGS2=(nTkPP(Gn1g$%wT3)$anJf23^1i)i rqJ8Ua{O>h)6Sx0RxA@2M@aG?<>*ire_P4KdfMU(l)z4*}Q$iB}y_@Mx delta 361 zcmZ3_vXFU#W4&B}Pl&6jscAw&LSSHEeSJLx1B05HnwXf_pW`ZDH;V(ghsCE~22xxl zL4LviVSr)N8J+V$QO*L7$YKTtz5^i4n02j_6Dau2)5S5w!~5-&T>fSSo|bIu#DD+o z_sH4)atu5(N!5E>y8hAIPa75qPh_oMvF*|Hr2ZoXd(F-)lH)xcB@-xmrSxXmfq-n+ zDbtIcLyvxMJ^1EMLqVy*#RChL{g|=;c0-ksxzF+)8&5>v-jjEwboKXkSKEVyjW&6& zJk4ipH8RkNsJ-vHw%PQI(6j807cZ8Ww^SL$GxOR$yz=2G=lQnCD~lZ;v0q)WI86MD z#kr(KJm(LE9+VYz2I`LZtzDtbSia_POVA4S363fjSAsV z3}2nRBM{@`Xt(pM^xAncV!S>Q5)uACrJLp( Date: Mon, 27 Mar 2023 18:18:05 +0600 Subject: [PATCH 0462/1199] Revert "Perish" This reverts commit 5b0988f08e5ae8d7cdccd8d7f2a628ef249c20dc. --- .../textures/block/android_station_em.png | Bin 0 -> 487 bytes .../textures/block/batterybank_core_em.png | Bin 0 -> 166 bytes .../textures/block/chemical_generator_em.png | Bin 0 -> 200 bytes .../textures/block/drive_rack_em.png | Bin 0 -> 195 bytes .../textures/block/drive_viewer_em.png | Bin 0 -> 209 bytes .../block/gravitational_stabilizer_em.png | Bin 0 -> 261 bytes .../block/gravitational_stabilizer_idle_em.png | Bin 0 -> 192 bytes .../textures/block/item_monitor_em.png | Bin 0 -> 216 bytes .../textures/block/matter_bottler_em.png | Bin 0 -> 227 bytes .../textures/block/matter_decomposer_em.png | Bin 0 -> 221 bytes .../textures/block/matter_panel_em.png | Bin 0 -> 216 bytes .../textures/block/matter_recycler_em.png | Bin 0 -> 242 bytes .../textures/block/matter_replicator_em.png | Bin 0 -> 227 bytes .../block/matter_replicator_halted_em.png | Bin 0 -> 213 bytes .../block/matter_replicator_offline_em.png | Bin 0 -> 180 bytes .../textures/block/matter_scanner_em.png | Bin 0 -> 246 bytes .../textures/block/matterybank_core_em.png | Bin 0 -> 169 bytes .../textures/block/plate_press_em.png | Bin 0 -> 195 bytes .../textures/block/storage_power_supplier_em.png | Bin 0 -> 197 bytes 19 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/android_station_em.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/batterybank_core_em.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/chemical_generator_em.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/drive_rack_em.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/drive_viewer_em.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/gravitational_stabilizer_em.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/gravitational_stabilizer_idle_em.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/item_monitor_em.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matter_bottler_em.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matter_decomposer_em.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matter_panel_em.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matter_recycler_em.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matter_replicator_em.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matter_replicator_halted_em.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matter_replicator_offline_em.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matter_scanner_em.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matterybank_core_em.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/plate_press_em.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/storage_power_supplier_em.png diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/android_station_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/android_station_em.png new file mode 100644 index 0000000000000000000000000000000000000000..2e734afc4fd9c7c71b0f4d0ab1359005636b9392 GIT binary patch literal 487 zcmVPx#1ZP1_K>z@;j|==^1poj532;bRa{vGizW@LZzX3P}QzQTY0eneBK~!i%?U*}~ z!Y~Ym2`8bX-f~aCUV)>~?#!NG>y%spPC=bA71zk>cciSHI3|8D%mjTi9?LRTB-x6A zjgPL`bSw_|bn7K012Gv|cQ)(q`RGD(%2VjtuMUleUbfsT>*0ONP+!H0q9}@@D2k$_ zQqj-n6U!~NrrKR@r29Y*C1muY@t)caW77YiPsVZ}nw+%){vSZ(CNjH0=i||QEO4Od z#Xil_ST!Lum%=vFpvhhiFaL|C;(h|{^N~dZW$Mi00M0`0mIO0^ht55i#cYzcK%&l# z9%OAn5hR@{X)U=GQRFy1A;nn9$Z-e{z1SO`GoIq;BFNw`i_y?p=b)y5>lhByQc@D3 zJ%%iL0#`98a~&(nt3eeEb#0$^se)2?s>vV@9PDx$e`w5{bM`|*0nj|&AD`4}a~rY( zb$!Ly=F!7MHp=DT?c37&v&n#X%@cy-OemryaFB@lPVFl8obLlmoDhdu<-qF=R#3pP d`ETcP`vVHg@#5aAlA-_r002ovPDHLkV1mYh*@XZA literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/batterybank_core_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/batterybank_core_em.png new file mode 100644 index 0000000000000000000000000000000000000000..268923c4edad2fd02a997f4c0e400c6b53ec643d GIT binary patch literal 166 zcmeAS@N?(olHy`uVBq!ia0vp^3P3Et!3HGD8EPYe6k~CayA#8@b22Z19F}xPUq=Rp zjs4tz5?O(K&H|6fVg?4j10c+pb*+;VC}{2J;uzxLoh-r1%qy|bMB>l>gCFEi9pRQR z4fqNn{1`ISV`@iy0XB4uLSEsD@VqP%zfh#W5tq`Rye~t_A}hmx~Wht-ktuRe0e` z!#hW>u!-whI=rYi;Ngj!>gBH=xVO75_v6p)w>x{Ib{~7bMeO~>s3@k{>brk1&fBb7 kP_b$DKX#yzP%xwM1h@PIDTXaSMUp{6p00i_>zopr07tn%)c^nh literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/drive_rack_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/drive_rack_em.png new file mode 100644 index 0000000000000000000000000000000000000000..b25583f22bd9859935393a8f416d8f7b228f1b7e GIT binary patch literal 195 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSK$uZf!>a)(7~$#S7!u+B_JSc-gMom{#iOTIAN{>5eB&31 zve(CYqCB*i#s0A$KCr>Hw!ixF#J20!+!6s6hm%ky9kKy>FVdQ&MBb@0OY(w>i_@% literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/drive_viewer_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/drive_viewer_em.png new file mode 100644 index 0000000000000000000000000000000000000000..0ea676437cad35f06d5d2e70ff618fa147c98a34 GIT binary patch literal 209 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3HE3&8=$zQjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`ISV`@iy0XB4uUY_j)~cCfr4qCE{-7?&TlUtNn{1``2&1HT;2cgHa|Au{{zqeH-JJ6=igc{1yZafL4Lvifq>!nHojn>0B3Nn{1`ISV`@iy0XB_Jc5^1#7ShP%zZf#W5tq`R%2RoDBv7Z5O+RceFEiFz=ZE zdPjrb1G&5fEI|>{0*dcV> z?wFYU7AWZH>Eak-;s3VJkPm3xk%s^FQT!5ljJ@65y+#vmX_P&16HwaD!gBY=1uua) z>lh9yPi?3OFW6--uv1mxNb;TIPUkreavZEbn8T>W&+h%g(a9QUD1)b~pUXO@geCxi CCqerF literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/matter_bottler_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/matter_bottler_em.png new file mode 100644 index 0000000000000000000000000000000000000000..ab1db4e56584b986ad53fd32021226e08d421591 GIT binary patch literal 227 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3-p)I`?e@QjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`MFV_7T>sx-`2WCjD+9xS1_t;4yUmYH0LqvbB+3CP_L3mK;QwI2Amz>M z1{C5f@Q5sCVBp&i!i*NI!74yO7f%<*5D)LS=dAe{99Ucf=S%*MH(E4fUXoH}_~OE* zHL`|Bzj7qVG1=P-h^}1AyW-lmZ_U>kEX>o)0~i@50MT0ZGcpqn=|_reeF8F%!PC{x JWt~$(69CbuMHv79 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/matter_decomposer_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/matter_decomposer_em.png new file mode 100644 index 0000000000000000000000000000000000000000..8ad97db8e80898e5d500bd2fb9530bf30831eef8 GIT binary patch literal 221 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I3?%1nZ+ru!7>k44ofy`glX(f`u%tWsIx;Y9 z?C1WI$O`0h2Ka=yy8qv8ery7e_y2HU1(0Gc3Gxg6|DWOdDPEvj2F?PH$YKTtzWpG~ zXu%q+0u=P~ba4!caDRKwkc&Z)hxOu&-||uW*tTry=x(x3R`mSX@iUEqfs4UmFTt!Ag2R9yR^A%s7X!t5pj!rP2lKQ>Mz#ey_=E3N)F))78&q Iol`;+029bUeE{L}al6>d5(|L}A90%(U<}hmUvwOdAbg~8-%HZkh=d#Wzp$Pym C)j=u% literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/matter_recycler_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/matter_recycler_em.png new file mode 100644 index 0000000000000000000000000000000000000000..6b48c2cb83aa06724c66ab7c6c4b34e65e6611e4 GIT binary patch literal 242 zcmeAS@N?(olHy`uVBq!ia0vp^3P9|@!3-pQ0$S$)DaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(eheq5(c3uK#Z^{D0uNm4V?u1B3hj-R8$80Ak literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/matter_replicator_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/matter_replicator_em.png new file mode 100644 index 0000000000000000000000000000000000000000..09c99d763d0c544a593267a517324e41b06d089d GIT binary patch literal 227 zcmeAS@N?(olHy`uVBq!ia0vp^3P9|@!3-pQ0$S$)DaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(ehe`~f~8uK#Z^{D0tSer$sK|J^{bJx{VX0V&p!Aiv=MK)~>O8(%O`fV03O zvY3H^Z$Ah#TCfJI00n(KT^vI^ypt0Y8D1=EXlxWbb&Tsp5))&CFQc$A50fQx3KN$^ zCFAYgY_Hvsq?eN4gk$% N@O1TaS?83{1OOABKgIw6 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/matter_replicator_halted_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/matter_replicator_halted_em.png new file mode 100644 index 0000000000000000000000000000000000000000..a83f9bd046d862e762a1f8f640e6d8e06a8096c4 GIT binary patch literal 213 zcmeAS@N?(olHy`uVBq!ia0vp^3P9|@!3HF&`%2dVDaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(eheoCO|{#S9F5`$3q|f;CtLD46Bx;uwx7?gIb zZ-2z#_dqUBVCA={FG`F4?ssO+V!; zzPrTIjeDWI_R4$gc4}#=YKvyYT#}x6@Kj9fmc7wSP2+Q&`F7Ps zw8W#;{oCdXvkNSKd$e?ag7fOiJJ)y^4wx@3+f)CxY31UZGapLsH?Y literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/matterybank_core_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/matterybank_core_em.png new file mode 100644 index 0000000000000000000000000000000000000000..9e65bdf498bb663bbb3f000469a5be62620b5b2f GIT binary patch literal 169 zcmeAS@N?(olHy`uVBq!ia0vp^3P3Et!3HGD8EPYe6k~CayA#8@b22Z19F}xPUq=Rp zjs4tz5?O(K&H|6fVg?4j{UFR}!5XXr6twenaSZYBPL^P0=9O4zA~8dL_6PY>N4Wi> zL>IhR%(6h@$-jE@K)xF%UwBEg_p}|z-~bXGJdJ?{2O1g~8It%kxRoQ#Hv&y!@O1Ta JS?83{1OTgwEpq?> literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/plate_press_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/plate_press_em.png new file mode 100644 index 0000000000000000000000000000000000000000..2340c4106a9b650d56009553157a9759e9d9c5c2 GIT binary patch literal 195 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3HE3&8=$zQjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`ISV`@iy0XB4uLSEsD@VqP%y&N#W5tq`Rye~t_A}hmx~9dhOhn}y8h9n zH=mZT&(l4Zsk8A?R26gdl(XL%&fk=_Sd_Eu fKO@jMC`eP-yI)_5A?2I(2at%TtDnm{r-UW|Z7G;uwkXbecq)78&qol`;+09P$PTmS$7 literal 0 HcmV?d00001 From 8928e8e31bf6e8eed9a0128cc4ba3165d1ea5521 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Mon, 27 Mar 2023 18:27:57 +0600 Subject: [PATCH 0463/1199] Perish 2 --- .../textures/block/batterybank_core_em.png | Bin 166 -> 0 bytes .../textures/block/chemical_generator_em.png | Bin 200 -> 0 bytes .../textures/block/drive_rack_em.png | Bin 195 -> 0 bytes .../textures/block/drive_viewer_em.png | Bin 209 -> 0 bytes .../block/gravitational_stabilizer_em.png | Bin 261 -> 0 bytes .../block/gravitational_stabilizer_idle_em.png | Bin 192 -> 0 bytes .../textures/block/item_monitor_em.png | Bin 216 -> 0 bytes .../textures/block/matter_bottler_em.png | Bin 227 -> 0 bytes .../textures/block/matter_decomposer_em.png | Bin 221 -> 0 bytes .../textures/block/matter_panel_em.png | Bin 216 -> 0 bytes .../textures/block/matter_recycler_em.png | Bin 242 -> 0 bytes .../textures/block/matter_replicator_em.png | Bin 227 -> 0 bytes .../block/matter_replicator_halted_em.png | Bin 213 -> 0 bytes .../block/matter_replicator_offline_em.png | Bin 180 -> 0 bytes .../textures/block/matter_scanner_em.png | Bin 246 -> 0 bytes .../textures/block/plate_press_em.png | Bin 195 -> 0 bytes .../textures/block/storage_power_supplier_em.png | Bin 197 -> 0 bytes 17 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/batterybank_core_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/chemical_generator_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/drive_rack_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/drive_viewer_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/gravitational_stabilizer_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/gravitational_stabilizer_idle_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/item_monitor_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matter_bottler_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matter_decomposer_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matter_panel_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matter_recycler_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matter_replicator_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matter_replicator_halted_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matter_replicator_offline_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matter_scanner_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/plate_press_em.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/storage_power_supplier_em.png diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/batterybank_core_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/batterybank_core_em.png deleted file mode 100644 index 268923c4edad2fd02a997f4c0e400c6b53ec643d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 166 zcmeAS@N?(olHy`uVBq!ia0vp^3P3Et!3HGD8EPYe6k~CayA#8@b22Z19F}xPUq=Rp zjs4tz5?O(K&H|6fVg?4j10c+pb*+;VC}{2J;uzxLoh-r1%qy|bMB>l>gCFEi9pRQR z4fqNn{1`ISV`@iy0XB4uLSEsD@VqP%zfh#W5tq`Rye~t_A}hmx~Wht-ktuRe0e` z!#hW>u!-whI=rYi;Ngj!>gBH=xVO75_v6p)w>x{Ib{~7bMeO~>s3@k{>brk1&fBb7 kP_b$DKX#yzP%xwM1h@PIDTXaSMUp{6p00i_>zopr07tn%)c^nh diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/drive_rack_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/drive_rack_em.png deleted file mode 100644 index b25583f22bd9859935393a8f416d8f7b228f1b7e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 195 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSK$uZf!>a)(7~$#S7!u+B_JSc-gMom{#iOTIAN{>5eB&31 zve(CYqCB*i#s0A$KCr>Hw!ixF#J20!+!6s6hm%ky9kKy>FVdQ&MBb@0OY(w>i_@% diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/drive_viewer_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/drive_viewer_em.png deleted file mode 100644 index 0ea676437cad35f06d5d2e70ff618fa147c98a34..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 209 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3HE3&8=$zQjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`ISV`@iy0XB4uUY_j)~cCfr4qCE{-7?&TlUtNn{1``2&1HT;2cgHa|Au{{zqeH-JJ6=igc{1yZafL4Lvifq>!nHojn>0B3Nn{1`ISV`@iy0XB_Jc5^1#7ShP%zZf#W5tq`R%2RoDBv7Z5O+RceFEiFz=ZE zdPjrb1G&5fEI|>{0*dcV> z?wFYU7AWZH>Eak-;s3VJkPm3xk%s^FQT!5ljJ@65y+#vmX_P&16HwaD!gBY=1uua) z>lh9yPi?3OFW6--uv1mxNb;TIPUkreavZEbn8T>W&+h%g(a9QUD1)b~pUXO@geCxi CCqerF diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/matter_bottler_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/matter_bottler_em.png deleted file mode 100644 index ab1db4e56584b986ad53fd32021226e08d421591..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 227 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3-p)I`?e@QjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`MFV_7T>sx-`2WCjD+9xS1_t;4yUmYH0LqvbB+3CP_L3mK;QwI2Amz>M z1{C5f@Q5sCVBp&i!i*NI!74yO7f%<*5D)LS=dAe{99Ucf=S%*MH(E4fUXoH}_~OE* zHL`|Bzj7qVG1=P-h^}1AyW-lmZ_U>kEX>o)0~i@50MT0ZGcpqn=|_reeF8F%!PC{x JWt~$(69CbuMHv79 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/matter_decomposer_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/matter_decomposer_em.png deleted file mode 100644 index 8ad97db8e80898e5d500bd2fb9530bf30831eef8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 221 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I3?%1nZ+ru!7>k44ofy`glX(f`u%tWsIx;Y9 z?C1WI$O`0h2Ka=yy8qv8ery7e_y2HU1(0Gc3Gxg6|DWOdDPEvj2F?PH$YKTtzWpG~ zXu%q+0u=P~ba4!caDRKwkc&Z)hxOu&-||uW*tTry=x(x3R`mSX@iUEqfs4UmFTt!Ag2R9yR^A%s7X!t5pj!rP2lKQ>Mz#ey_=E3N)F))78&q Iol`;+029bUeE{L}al6>d5(|L}A90%(U<}hmUvwOdAbg~8-%HZkh=d#Wzp$Pym C)j=u% diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/matter_recycler_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/matter_recycler_em.png deleted file mode 100644 index 6b48c2cb83aa06724c66ab7c6c4b34e65e6611e4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 242 zcmeAS@N?(olHy`uVBq!ia0vp^3P9|@!3-pQ0$S$)DaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(eheq5(c3uK#Z^{D0uNm4V?u1B3hj-R8$80Ak diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/matter_replicator_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/matter_replicator_em.png deleted file mode 100644 index 09c99d763d0c544a593267a517324e41b06d089d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 227 zcmeAS@N?(olHy`uVBq!ia0vp^3P9|@!3-pQ0$S$)DaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(ehe`~f~8uK#Z^{D0tSer$sK|J^{bJx{VX0V&p!Aiv=MK)~>O8(%O`fV03O zvY3H^Z$Ah#TCfJI00n(KT^vI^ypt0Y8D1=EXlxWbb&Tsp5))&CFQc$A50fQx3KN$^ zCFAYgY_Hvsq?eN4gk$% N@O1TaS?83{1OOABKgIw6 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/matter_replicator_halted_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/matter_replicator_halted_em.png deleted file mode 100644 index a83f9bd046d862e762a1f8f640e6d8e06a8096c4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 213 zcmeAS@N?(olHy`uVBq!ia0vp^3P9|@!3HF&`%2dVDaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(eheoCO|{#S9F5`$3q|f;CtLD46Bx;uwx7?gIb zZ-2z#_dqUBVCA={FG`F4?ssO+V!; zzPrTIjeDWI_R4$gc4}#=YKvyYT#}x6@Kj9fmc7wSP2+Q&`F7Ps zw8W#;{oCdXvkNSKd$e?ag7fOiJJ)y^4wx@3+f)CxY31UZGapLsH?Y diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/plate_press_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/plate_press_em.png deleted file mode 100644 index 2340c4106a9b650d56009553157a9759e9d9c5c2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 195 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3HE3&8=$zQjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`ISV`@iy0XB4uLSEsD@VqP%y&N#W5tq`Rye~t_A}hmx~9dhOhn}y8h9n zH=mZT&(l4Zsk8A?R26gdl(XL%&fk=_Sd_Eu fKO@jMC`eP-yI)_5A?2I(2at%TtDnm{r-UW|Z7G;uwkXbecq)78&qol`;+09P$PTmS$7 From 828b8d103935c67a6408180c60550a953e6c8c98 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Mon, 27 Mar 2023 18:53:55 +0600 Subject: [PATCH 0464/1199] Add a slight animation to Android station's holograms + LET IT GLOW --- .../models/block/android_station_working.json | 43 ++++++++++++++++-- .../textures/block/android_station.png | Bin 1220 -> 544 bytes .../textures/block/android_station_em.png | Bin 487 -> 1036 bytes .../block/android_station_em.png.mcmeta | 7 +++ 4 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/android_station_em.png.mcmeta diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/android_station_working.json b/src/main/resources/assets/overdrive_that_matters/models/block/android_station_working.json index 7a63ccca3..200020ecc 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/android_station_working.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/android_station_working.json @@ -1,6 +1,8 @@ -{ +{ + "credit": "Made with Blockbench", "parent": "block/cube_all", - "render_type": "translucent", + "render_type": "translucent", + "texture_size": [16, 32], "textures": { "0": "overdrive_that_matters:block/android_station", "1": "overdrive_that_matters:block/android_station_em", @@ -127,11 +129,44 @@ } }, { + "name": "hologram", "from": [-1, 10, -1], "to": [17, 10, 17], "faces": { - "up": {"uv": [0, 9.5, 8, 13.5], "texture": "#0"}, - "down": {"uv": [0, 9.5, 8, 13.5], "texture": "#0"} + "up": {"uv": [0, 9.5, 8, 13.5], "texture": "#1"}, + "down": {"uv": [0, 9.5, 8, 13.5], "texture": "#1"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "hologram", + "from": [6, 9.5, 6], + "to": [10, 9.5, 10], + "faces": { + "up": {"uv": [11, 11, 13, 12], "texture": "#1"}, + "down": {"uv": [11, 11, 13, 12], "texture": "#1"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "holotext", + "from": [1, 10.5, 3], + "to": [8, 14.5, 3], + "rotation": {"angle": 22.5, "axis": "x", "origin": [5.5, 13.5, 1]}, + "faces": { + "north": {"uv": [2.5, 7.25, 5.5, 8.25], "texture": "#1"}, + "south": {"uv": [5.5, 7.25, 2.5, 8.25], "texture": "#1"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "holotext", + "from": [8, 5.1, 12], + "to": [15, 9.1, 12], + "rotation": {"angle": -22.5, "axis": "x", "origin": [5.5, 13.5, 1]}, + "faces": { + "north": {"uv": [5.5, 7.25, 2.5, 8.25], "texture": "#1"}, + "south": {"uv": [2.5, 7.25, 5.5, 8.25], "texture": "#1"} }, "forge_data": { "block_light": 15, "sky_light": 15 } } diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/android_station.png b/src/main/resources/assets/overdrive_that_matters/textures/block/android_station.png index eb34ef1546f1d122a34b4201eb0f70e2b22fd797..be4d27d190e6712537f7325913d556a616acb275 100644 GIT binary patch delta 481 zcmX@YxqxMYBnLAC1A|XM>zs*-3aK^$J|V6lAt6OYMPg!N+S=L)2??gAruFspa&mHN zYHD0uT>t<7zkU05T4hUaQ-4TGZft&4dH?LjSu1*1YzG>|xqQ+hASF@~qK^d*iRql!^jsg0gIdl%#hSzk0jB{k_rOf2vUCcdgG;9#gLh z>BlD|@0_;Gepu@BrZ@Hc?NilG8s7`IdnR7~Cv>1de}e*ZoI78Nz`K^1xk2m`vafO4 z?Z5B9cc1%tiKB3Z!j_e%JbqNSnS}FVdQ&MBb@0A-Qe5C8xG delta 1183 zcmV;Q1YrB11jGrD83+ad004WAb*_;iAb$yPNLh0L01m$Z01m$aI0aKA000D8Nkl^yYHCVL5;Zk7aXWH= zK0g^Y0F|MkA*!pZqs7HV7APw#qwVc&&IQzKYHDbHex7=IdYpkLCML8*I9gjuF8+}z|z=3gz)>gp<&kt2P6`G1A$kO872UP*tD1X%#x1eYvmX=%x=t*tqO2LVw< zs;sQcM<7lf_AT++dL{IkSQ{W4P3X-eb!j(dA9Sq^fM-#GZtM|ov+?N?CqH6|fGySr zxDOYT^3!iQ`2k&P18@*U1-h|EU@()7@fnz!`v}DJ4>llil(QhDVa<2^AFxSW1%ZP4%Uvs{M&2A7GBojA)f0%Qfzb@vNs|M>a^ox5_w$p!l* zxYg%401lTQ(Iuj-jr^NI+JB_(CKdyx-@nl{Z`@1irt!k%_zb{1F${QH!T{@Yz#a0i zK-by;uXPPWY$st<_H_vmy?u)SzKmG*fDN%l0N#W}&V_$}69TVOE-3r91cJ2z*ho<$ zfUh9d%g8ShFwpBlYF5{B?AI}XXNZi~AtmjSC+-Y9<^htbvZ)%8SAQI>WMMC|Ki70g zd8XursQQV%djmQ1Wm60^L)ax|2v$Mm0!&FsOQE6#u z!DccykXsf%EYNPFpUBN!yURU9b1Kaw>c=KkTQhPrqKw?ApHitF_47A>q%k;NL>M#( zFaR$i7{&&u!5`?pP=7%8%=Lvd2EspQ5&12(u*Jv{#$ZB!!VO$VqIjS>;cg!k-^MCgCIs@H)FschKL+= z0QNu|mlQC<&k#RDajqkU`FRdm(Ze1XRG#$ezECLL4s{tl!&hKlMt*o*Mg?A>Y}O^$ ziN6e$aE;eva({Q|F+s5;K*#3uJ>Y=Y;G5mrNhPp#2Fs7JCLC{XZ>u)NJ x%XkG(vLHr?!Mdpctj0Kd1{eW{|o>C002ovPDHLkV1f`29##MV diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/android_station_em.png b/src/main/resources/assets/overdrive_that_matters/textures/block/android_station_em.png index 2e734afc4fd9c7c71b0f4d0ab1359005636b9392..253476d7d4b5ec890b7488a4b7dd855abc2e816c 100644 GIT binary patch delta 980 zcmV;_11tRJ1B?ie77GCY2nGNE0Mem!c99`8e*>XOL_t(|UhSMca^o-zg_E2l<<=?p z1j!Y0lx=rrPq1~$Tp>9{YL~9|8eTk@@K7`*Qy@dj()(r<@y8+on2<~Xle-*;-Q6J+ zPvqLxi^l?UEVOQGzWpB8ZmN%b3y1y70Y|82c?f5+9=7X-ycH8d2q8DiJ^siq*I!zB zfBg6p*8$q3{wnA9(9|AG7*E=h`*h-<@lz;&#r;-!{cERT4ye|v;p%Rvk7F-b3u6|PzSmGxf8=x7$GOV_rHc@gj!kU11Td|~w4X!OS1?8C zS8y_Csaaz@*EFF<=rcTnwbUGo@cCFg4m>uvN6;c)+J^CUxjA2Et5fR6`(;_X8UJf0Es*zND~S zZP>-0B4gIy983~V)RQ=HsX)tAYpH+Re_+T85Q<$`#>NCzNG;Ket6PA3!`KU$KfwF} z56mB!dU0J8ymncjbP;0Gv55_r0H*br_H$tVfQuTT&+rV^QgbXq<_|D`fNUELUWc-- z{L~9tk?|(Q1YrJvnTGiTe@ZT-vaK+S#{zRKv~FuMe_&CFuQPvOgD`)fgmvGF2_b}# znBQGgwQ_u?U$z z!2AKSZ8Uft%DVDXFK9)^n-mj(`2%K}t>q7VeEkQIFJlf-aXZ}r0000UX59oj4|bFw6vfGakz_RwUVqfsK!@*>o%p_;l+f zB?B=TT6Z?<@A>FLbIMcb+OH0chhDbaE9>EX%TQm%ilQirq9}@@q*Bq(=M&2Bg!0`2pWMFVB(%;EsfLhhCXGk}NAJ($I8lD0si&W#>qZ9x$vohfN8 zxfN05I6Wc7Sjot72oJs38=f7wpr(N97!K4@QWBv(hAeslS1~Aa z9V^PKK@|*jZJ&0jf>L;@$si6K>~b1^Xv~~*_CrDe&^+EBpVVq|8?pj*eZ|=3(ZfVG z%H`ng+tT{8$$)sx6N2MRD552Bkcj$D?JD-1?*mJm5Qkai!0QcGP{6VIZ|8FR6$1*( V@#5aAlA-_r002ovPDHLkV1jmw&zt}N diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/android_station_em.png.mcmeta b/src/main/resources/assets/overdrive_that_matters/textures/block/android_station_em.png.mcmeta new file mode 100644 index 000000000..fa950acdd --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/textures/block/android_station_em.png.mcmeta @@ -0,0 +1,7 @@ +{ + "animation": { + "frametime": 16, + "width": 32, + "height": 64 + } +} \ No newline at end of file From 7d5a585897b413de31889a9061f134f6ff73c6da Mon Sep 17 00:00:00 2001 From: GearShocky Date: Mon, 27 Mar 2023 18:55:21 +0600 Subject: [PATCH 0465/1199] perish 3 --- .../assets/overdrive_that_matters/optifine/emissive.properties | 1 - 1 file changed, 1 deletion(-) delete mode 100644 src/main/resources/assets/overdrive_that_matters/optifine/emissive.properties diff --git a/src/main/resources/assets/overdrive_that_matters/optifine/emissive.properties b/src/main/resources/assets/overdrive_that_matters/optifine/emissive.properties deleted file mode 100644 index 55ac3b130..000000000 --- a/src/main/resources/assets/overdrive_that_matters/optifine/emissive.properties +++ /dev/null @@ -1 +0,0 @@ -suffix.emissive=_em \ No newline at end of file From 516de507e483f2aa927df3c2716879866851b52b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 2 Apr 2023 14:48:28 +0700 Subject: [PATCH 0466/1199] Fluid capsules test --- .../mc/otm/datagen/lang/English.kt | 53 ++-- .../mc/otm/datagen/lang/Russian.kt | 53 ++-- .../mc/otm/OverdriveThatMatters.java | 8 +- .../ru/dbotthepony/mc/otm/capability/Ext.kt | 127 ++++++++ .../dbotthepony/mc/otm/capability/Helpers.kt | 70 ----- .../dbotthepony/mc/otm/config/ItemsConfig.kt | 4 + .../mc/otm/container/ContainerSpliterator.kt | 8 +- .../ru/dbotthepony/mc/otm/container/Ext.kt | 3 + .../mc/otm/container/FluidHandlerIterator.kt | 25 ++ .../otm/container/FluidHandlerSpliterator.kt | 31 ++ .../mc/otm/core/UnOverengineering.kt | 2 + .../mc/otm/core/collect/SlotIterator.kt | 26 -- .../mc/otm/core/util/Formatting.kt | 3 + .../mc/otm/item/FluidCapsuleItem.kt | 274 ++++++++++++++++++ .../mc/otm/item/PriorityUseItem.kt | 18 ++ .../mc/otm/registry/CreativeTabs.kt | 19 ++ .../ru/dbotthepony/mc/otm/registry/MItems.kt | 2 + 17 files changed, 577 insertions(+), 149 deletions(-) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/capability/Helpers.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/container/FluidHandlerIterator.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/container/FluidHandlerSpliterator.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/SlotIterator.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/item/PriorityUseItem.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index ceebf124c..a7225c4cc 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -261,39 +261,41 @@ private fun misc(provider: MatteryLanguageProvider) { misc("pill.message", "Nothing happened, but you feel... exhausted?.. Maybe get rest.") misc("pill.message_finish", "§kONE OF US ONE OF US ONE OF US") - misc("gui.power.percentage_level", "Energy level: %s%%") - misc("gui.level", "%s / %s") - misc("gui.power.name", "MtJ") + gui("power.percentage_level", "Energy level: %s%%") + gui("level", "%s / %s") + gui("power.name", "MtJ") + gui("fluid.name", "mB") + gui("fluid.level", "%s / %s of %s") - misc("gui.power.burn_time", "Burn time left: %s ticks") + gui("power.burn_time", "Burn time left: %s ticks") - misc("gui.progress_widget", "Progress: %s%%") - misc("gui.progress_widget_stuck", "The machine can not work, check configuration") + gui("progress_widget", "Progress: %s%%") + gui("progress_widget_stuck", "The machine can not work, check configuration") - misc("gui.total_raw", "Total:") + gui("total_raw", "Total:") - misc("gui.matter.percentage_level", "Matter level: %s%%") - misc("gui.matter.format", "Matter: %s") - misc("gui.matter.format_and_complexity", "%s / Complexity: %s") - misc("gui.matter.format_and_complexity2", "%s (%s) / Complexity: %s (%s)") - misc("gui.matter.name", "MtU") + gui("matter.percentage_level", "Matter level: %s%%") + gui("matter.format", "Matter: %s") + gui("matter.format_and_complexity", "%s / Complexity: %s") + gui("matter.format_and_complexity2", "%s (%s) / Complexity: %s (%s)") + gui("matter.name", "MtU") - misc("gui.filter.is_whitelist", "Is Whitelist") - misc("gui.filter.match_nbt", "Match NBT") - misc("gui.filter.match_tag", "Match Tag") + gui("filter.is_whitelist", "Is Whitelist") + gui("filter.match_nbt", "Match NBT") + gui("filter.match_tag", "Match Tag") - misc("gui.android_research", "Research Tree") + gui("android_research", "Research Tree") - misc("gui.pattern.percentage_level", "Fill level: %s%%") - misc("gui.pattern.format", "Stored patterns: %s / %s") + gui("pattern.percentage_level", "Fill level: %s%%") + gui("pattern.format", "Stored patterns: %s / %s") - misc("gui.redstone.ignored", "Redstone mode: Ignored") - misc("gui.redstone.low", "Redstone mode: Low") - misc("gui.redstone.high", "Redstone mode: High") + gui("redstone.ignored", "Redstone mode: Ignored") + gui("redstone.low", "Redstone mode: Low") + gui("redstone.high", "Redstone mode: High") - misc("gui.redstone.ignored.description", "Redstone signal does not affect machine's function") - misc("gui.redstone.low.description", "Machine work if no redstone signal is present") - misc("gui.redstone.high.description", "Machine work only if any redstone signal is present") + gui("redstone.ignored.description", "Redstone signal does not affect machine's function") + gui("redstone.low.description", "Machine work if no redstone signal is present") + gui("redstone.high.description", "Machine work only if any redstone signal is present") misc("3d2d.gravitation_stabilizer.mass", "Singularity mass: %s") misc("3d2d.gravitation_stabilizer.strength", "Gravitation strength: %s") @@ -458,6 +460,9 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.NUTRIENT_PASTE, "Nutrient Paste") + add(MItems.FLUID_CAPSULE, "Fluid Capsule") + add(MItems.FLUID_CAPSULE, "named", "Fluid Capsule (%s)") + add(MItems.BLACK_HOLE_SCANNER, "Singularity Scanner") add(MItems.BLACK_HOLE_SCANNER, "desc", "Scans singularities for their properties") add(MItems.BLACK_HOLE_SCANNER, "desc2", "Hold in hand to determine mass of singularities") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 43a038fa4..72cc33147 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -268,39 +268,41 @@ private fun misc(provider: MatteryLanguageProvider) { misc("pill.message", "Ничего не произошло, но вы чувствуете... себя уставшим?.. Возможно надо отдохнуть.") misc("pill.message_finish", "§kОДИН ИЗ НАС ОДИН ИЗ НАС ОДИН ИЗ НАС ОДИН ИЗ НАС ОДИН ИЗ НАС") - misc("gui.power.percentage_level", "Уровень энергии: %s%%") - misc("gui.level", "%s / %s") - misc("gui.power.name", "МтДж") + gui("power.percentage_level", "Уровень энергии: %s%%") + gui("level", "%s / %s") + gui("power.name", "МтДж") + gui("fluid.name", "мВ") + gui("fluid.level", "%s / %s с %s") - misc("gui.power.burn_time", "Оставшееся время горения: %s тиков") + gui("power.burn_time", "Оставшееся время горения: %s тиков") - misc("gui.progress_widget", "Прогресс: %s%%") - misc("gui.progress_widget_stuck", "Это устройство не может продолжить работу, проверьте конфигурацию") + gui("progress_widget", "Прогресс: %s%%") + gui("progress_widget_stuck", "Это устройство не может продолжить работу, проверьте конфигурацию") - misc("gui.total_raw", "Всего:") + gui("total_raw", "Всего:") - misc("gui.matter.percentage_level", "Уровень материи: %s%%") - misc("gui.matter.format", "Материя: %s") - misc("gui.matter.format_and_complexity", "%s / Сложность: %s") - misc("gui.matter.format_and_complexity2", "%s (%s) / Сложность: %s (%s)") - misc("gui.matter.name", "МтЕд") + gui("matter.percentage_level", "Уровень материи: %s%%") + gui("matter.format", "Материя: %s") + gui("matter.format_and_complexity", "%s / Сложность: %s") + gui("matter.format_and_complexity2", "%s (%s) / Сложность: %s (%s)") + gui("matter.name", "МтЕд") - misc("gui.filter.is_whitelist", "Белый список") - misc("gui.filter.match_nbt", "Сравнивать NBT") - misc("gui.filter.match_tag", "Сравнить Теги") + gui("filter.is_whitelist", "Белый список") + gui("filter.match_nbt", "Сравнивать NBT") + gui("filter.match_tag", "Сравнить Теги") - misc("gui.android_research", "Дерево Исследований") + gui("android_research", "Дерево Исследований") - misc("gui.pattern.percentage_level", "Уровень заполнения: %s%%") - misc("gui.pattern.format", "Хранимые шаблоны: %s / %s") + gui("pattern.percentage_level", "Уровень заполнения: %s%%") + gui("pattern.format", "Хранимые шаблоны: %s / %s") - misc("gui.redstone.ignored", "Режим красного камня: Игнорирование") - misc("gui.redstone.low", "Режим красного камня: Нет сигнала") - misc("gui.redstone.high", "Режим красного камня: Есть сигнал") + gui("redstone.ignored", "Режим красного камня: Игнорирование") + gui("redstone.low", "Режим красного камня: Нет сигнала") + gui("redstone.high", "Режим красного камня: Есть сигнал") - misc("gui.redstone.ignored.description", "Сигнал красного камня не влияет на работу устройства") - misc("gui.redstone.low.description", "Устройство работает если нет сигнала красного камня") - misc("gui.redstone.high.description", "Устройство работает если есть сигнал красного камня") + gui("redstone.ignored.description", "Сигнал красного камня не влияет на работу устройства") + gui("redstone.low.description", "Устройство работает если нет сигнала красного камня") + gui("redstone.high.description", "Устройство работает если есть сигнал красного камня") misc("3d2d.gravitation_stabilizer.mass", "Масса сингулярности: %s") misc("3d2d.gravitation_stabilizer.strength", "Гравитационная сила: %s") @@ -465,6 +467,9 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.NUTRIENT_PASTE, "Питательная паста") + add(MItems.FLUID_CAPSULE, "Жидкостная капсула") + add(MItems.FLUID_CAPSULE, "named", "Жидкостная капсула (%s)") + add(MItems.BLACK_HOLE_SCANNER, "Сканер сингулярностей") add(MItems.BLACK_HOLE_SCANNER, "desc", "Сканирует сингулярности и считывает их свойства") add(MItems.BLACK_HOLE_SCANNER, "desc2", "Держите в любой их рук для считывания массы сингулярностей") diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 517f12683..8f5a5f643 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -15,6 +15,7 @@ import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.NotNull; import ru.dbotthepony.mc.otm.android.AndroidResearchManager; import ru.dbotthepony.mc.otm.android.feature.EnderTeleporterFeature; import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity; @@ -46,6 +47,7 @@ import ru.dbotthepony.mc.otm.config.ServerConfig; import ru.dbotthepony.mc.otm.config.ToolsConfig; import ru.dbotthepony.mc.otm.core.math.Decimal; import ru.dbotthepony.mc.otm.item.ItemTritaniumArmor; +import ru.dbotthepony.mc.otm.item.PriorityUseItemKt; import ru.dbotthepony.mc.otm.item.QuantumBatteryItem; import ru.dbotthepony.mc.otm.item.weapon.AbstractWeaponItem; import ru.dbotthepony.mc.otm.item.PortableCondensationDriveItem; @@ -59,6 +61,7 @@ import top.theillusivec4.curios.api.CuriosApi; import static net.minecraftforge.common.MinecraftForge.EVENT_BUS; import javax.annotation.ParametersAreNonnullByDefault; +import java.util.Objects; // The value here should match an entry in the META-INF/mods.toml file @Mod(OverdriveThatMatters.MOD_ID) @@ -72,8 +75,9 @@ public final class OverdriveThatMatters { public static OverdriveThatMatters INSTANCE; private StorageStackType ITEM_STORAGE; + @NotNull public StorageStackType ITEM_STORAGE() { - return ITEM_STORAGE; + return Objects.requireNonNull(ITEM_STORAGE); } public static ResourceLocation loc(String path) { @@ -183,6 +187,8 @@ public final class OverdriveThatMatters { EVENT_BUS.addListener(EventPriority.NORMAL, MatteryBlockEntity.Companion::playerDisconnected); EVENT_BUS.addListener(EventPriority.LOWEST, MatteryBlockEntity.Companion::postLevelTick); + EVENT_BUS.addListener(EventPriority.NORMAL, PriorityUseItemKt::onItemRightClick); + EVENT_BUS.addListener(EventPriority.LOWEST, KillAsAndroidTrigger.INSTANCE::onKill); EVENT_BUS.addListener(EventPriority.NORMAL, EnderTeleporterFeature.Companion::onEntityDeath); diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt index a404652a6..61a906c2f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt @@ -1,15 +1,23 @@ package ru.dbotthepony.mc.otm.capability import com.google.common.collect.Streams +import earth.terrarium.botarium.common.registry.fluid.FluidSounds +import net.minecraft.ChatFormatting import net.minecraft.core.Direction +import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Player import net.minecraft.world.item.ItemStack import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.capabilities.ICapabilityProvider import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.energy.IEnergyStorage +import net.minecraftforge.fluids.FluidStack +import net.minecraftforge.fluids.capability.IFluidHandler import net.minecraftforge.fml.ModList +import net.minecraftforge.items.IItemHandler +import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage +import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.compat.cos.cosmeticArmorAwareStream import ru.dbotthepony.mc.otm.compat.cos.cosmeticArmorStream import ru.dbotthepony.mc.otm.compat.cos.isCosmeticArmorLoaded @@ -24,10 +32,13 @@ import ru.dbotthepony.mc.otm.core.collect.AwareItemStack import ru.dbotthepony.mc.otm.core.collect.ContainerItemStackEntry import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.orNull +import ru.dbotthepony.mc.otm.core.util.formatFluidLevel import java.util.IdentityHashMap import java.util.LinkedList import java.util.stream.Stream +private val LOGGER = LogManager.getLogger() + val ICapabilityProvider.matteryPlayer: MatteryPlayerCapability? get() = getCapability(MatteryCapability.MATTERY_PLAYER).orNull() /** @@ -297,3 +308,119 @@ fun Player.awareAllItemsStream(includeCosmetics: Boolean = false): Stream { + val getItem = source.extractItem(sourceSlot, Int.MAX_VALUE, true) + + if (getItem.isEmpty) { + return sourceSlot + 1 to destinationSlot + } else { + val leftover = destination.insertItem(destinationSlot, getItem, true) + + if (leftover.count == getItem.count) { + return sourceSlot to destinationSlot + 1 + } else { + val getItem2 = source.extractItem(sourceSlot, getItem.count - leftover.count, true) + + if (getItem2.isEmpty) { + return sourceSlot + 1 to destinationSlot + } else { + val leftover2 = destination.insertItem(destinationSlot, getItem2, true) + + if (leftover2.isEmpty) { + source.extractItem(sourceSlot, getItem2.count, false) + destination.insertItem(destinationSlot, getItem2, false) + + if (getItem2.count == getItem.count) { + return sourceSlot + 1 to destinationSlot + } else { + return sourceSlot to destinationSlot + } + } + } + } + } + + return sourceSlot to destinationSlot +} + +@Suppress("name_shadowing") +internal fun moveEnergy(source: IEnergyStorage, destination: IEnergyStorage, amount: Decimal = Decimal.LONG_MAX_VALUE, simulate: Boolean, ignoreFlowRestrictions: Boolean = false): Decimal { + val extracted = if (ignoreFlowRestrictions && source is IMatteryEnergyStorage) source.extractEnergy(amount, true) else source.extractEnergy(amount, true) + + if (extracted.isPositive) { + val received = destination.receiveEnergy(extracted, true) + + if (received.isPositive) { + val extracted = if (ignoreFlowRestrictions && source is IMatteryEnergyStorage) source.extractEnergy(received, true) else source.extractEnergy(received, true) + + if (extracted.isPositive) { + if (simulate) { + return extracted + } + + val received = destination.receiveEnergy(extracted, false) + return if (ignoreFlowRestrictions && source is IMatteryEnergyStorage) source.extractEnergy(received, false) else source.extractEnergy(received, false) + } + } + } + + return Decimal.ZERO +} + +internal fun fluidLevel(it: IFluidHandler, tooltips: MutableList) { + val fluid = it.getFluidInTank(0) + + if (fluid.isEmpty) { + tooltips.add(formatFluidLevel(0, it.getTankCapacity(0), formatAsReadable = ShiftPressedCond).withStyle(ChatFormatting.GRAY)) + } else { + tooltips.add(formatFluidLevel(fluid.amount, it.getTankCapacity(0), fluid.displayName, formatAsReadable = ShiftPressedCond).withStyle(ChatFormatting.GRAY)) + } +} + +internal fun moveFluid(source: IFluidHandler, sourceTank: Int? = null, destination: IFluidHandler, limit: Int = Int.MAX_VALUE, simulate: Boolean = false, actuallyDrain: Boolean = true): FluidStack { + val drained: FluidStack + + if (sourceTank == null) { + drained = source.drain(limit, IFluidHandler.FluidAction.SIMULATE) + } else { + drained = source.drain(source.getFluidInTank(sourceTank), IFluidHandler.FluidAction.SIMULATE) + } + + if (drained.isEmpty) return FluidStack.EMPTY + + val filled = destination.fill(drained, IFluidHandler.FluidAction.SIMULATE) + if (filled == 0) return FluidStack.EMPTY + + val drained2 = source.drain(FluidStack(drained, filled), IFluidHandler.FluidAction.SIMULATE) + if (drained2.amount != filled) return FluidStack.EMPTY + + val filled2 = destination.fill(drained2, IFluidHandler.FluidAction.SIMULATE) + if (filled2 != drained2.amount) return FluidStack.EMPTY + + if (simulate) return FluidStack(drained2, filled2) + + val drained3: FluidStack + + if (actuallyDrain) { + drained3 = source.drain(FluidStack(drained2, filled2), IFluidHandler.FluidAction.EXECUTE) + + if (drained3.amount != filled2) { + LOGGER.warn("Inconsistency of fluid extraction from $source between simulate and execute modes (simulated $drained2; extracted $drained3); This can lead to duping!!!") + } + } else { + drained3 = drained2 + } + + val filled3 = destination.fill(drained3, IFluidHandler.FluidAction.EXECUTE) + + if (filled3 != drained3.amount) { + LOGGER.warn("Inconsistency of fluid insertion to $destination between simulate and execute modes (simulated $filled2; inserted $filled3); This can lead to duping!!!") + } + + return FluidStack(drained3, filled3) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Helpers.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Helpers.kt deleted file mode 100644 index 1d48ca885..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Helpers.kt +++ /dev/null @@ -1,70 +0,0 @@ -package ru.dbotthepony.mc.otm.capability - -import net.minecraftforge.energy.IEnergyStorage -import net.minecraftforge.items.IItemHandler -import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage -import ru.dbotthepony.mc.otm.core.math.Decimal - -/** - * Attempts to safely exchange/move item between slots of two handlers - * - * @return pair of new (advanced) [sourceSlot] and [destinationSlot] - */ -fun moveBetweenSlots(source: IItemHandler, sourceSlot: Int, destination: IItemHandler, destinationSlot: Int): Pair { - val getItem = source.extractItem(sourceSlot, Int.MAX_VALUE, true) - - if (getItem.isEmpty) { - return sourceSlot + 1 to destinationSlot - } else { - val leftover = destination.insertItem(destinationSlot, getItem, true) - - if (leftover.count == getItem.count) { - return sourceSlot to destinationSlot + 1 - } else { - val getItem2 = source.extractItem(sourceSlot, getItem.count - leftover.count, true) - - if (getItem2.isEmpty) { - return sourceSlot + 1 to destinationSlot - } else { - val leftover2 = destination.insertItem(destinationSlot, getItem2, true) - - if (leftover2.isEmpty) { - source.extractItem(sourceSlot, getItem2.count, false) - destination.insertItem(destinationSlot, getItem2, false) - - if (getItem2.count == getItem.count) { - return sourceSlot + 1 to destinationSlot - } else { - return sourceSlot to destinationSlot - } - } - } - } - } - - return sourceSlot to destinationSlot -} - -@Suppress("name_shadowing") -fun moveEnergy(source: IEnergyStorage, destination: IEnergyStorage, amount: Decimal = Decimal.LONG_MAX_VALUE, simulate: Boolean, ignoreFlowRestrictions: Boolean = false): Decimal { - val extracted = if (ignoreFlowRestrictions && source is IMatteryEnergyStorage) source.extractEnergy(amount, true) else source.extractEnergy(amount, true) - - if (extracted.isPositive) { - val received = destination.receiveEnergy(extracted, true) - - if (received.isPositive) { - val extracted = if (ignoreFlowRestrictions && source is IMatteryEnergyStorage) source.extractEnergy(received, true) else source.extractEnergy(received, true) - - if (extracted.isPositive) { - if (simulate) { - return extracted - } - - val received = destination.receiveEnergy(extracted, false) - return if (ignoreFlowRestrictions && source is IMatteryEnergyStorage) source.extractEnergy(received, false) else source.extractEnergy(received, false) - } - } - } - - return Decimal.ZERO -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt index 53d52e7ff..884a5150b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt @@ -91,6 +91,10 @@ object ItemsConfig : AbstractConfig("items") { } init { + builder.push("PatternDrives") PatternDrives + builder.pop() } + + val FLUID_CAPSULE_CAPACITY: Int by builder.defineInRange("LIQUID_CAPSULE_CAPACITY", 1000, 1, Int.MAX_VALUE) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerSpliterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerSpliterator.kt index 7087d6b7c..6ed9cea8f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerSpliterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerSpliterator.kt @@ -47,7 +47,7 @@ class AwareContainerSpliterator(private val container: Container, offset: Int = } } -fun Container.spliterator() = ContainerSpliterator(this) -fun Container.awareSpliterator() = AwareContainerSpliterator(this) -fun Container.stream(): Stream = StreamSupport.stream(spliterator(), false) -fun Container.awareStream(): Stream = StreamSupport.stream(awareSpliterator(), false) +fun Container.spliterator(offset: Int = 0) = ContainerSpliterator(this, offset) +fun Container.awareSpliterator(offset: Int = 0) = AwareContainerSpliterator(this, offset) +fun Container.stream(offset: Int = 0): Stream = StreamSupport.stream(spliterator(offset), false) +fun Container.awareStream(offset: Int = 0): Stream = StreamSupport.stream(awareSpliterator(offset), false) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt index 6e45cb70b..ace16d30d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt @@ -3,12 +3,15 @@ package ru.dbotthepony.mc.otm.container import net.minecraft.world.Container import net.minecraft.world.item.ItemStack import net.minecraftforge.common.capabilities.Capability +import net.minecraftforge.fluids.capability.IFluidHandler import ru.dbotthepony.mc.otm.core.collect.iterator import ru.dbotthepony.mc.otm.core.collect.nonEmpty operator fun Container.set(index: Int, value: ItemStack) = setItem(index, value) operator fun Container.get(index: Int): ItemStack = getItem(index) +operator fun IFluidHandler.get(index: Int) = getFluidInTank(index) + fun Container.addItem(stack: ItemStack, range: IntRange, simulate: Boolean = false): ItemStack { if (this is MatteryContainer) { return this.addItem(stack, range, simulate) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/FluidHandlerIterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/FluidHandlerIterator.kt new file mode 100644 index 000000000..f837c7265 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/FluidHandlerIterator.kt @@ -0,0 +1,25 @@ +package ru.dbotthepony.mc.otm.container + +import it.unimi.dsi.fastutil.objects.ObjectIterators.AbstractIndexBasedIterator +import net.minecraftforge.fluids.FluidStack +import net.minecraftforge.fluids.capability.IFluidHandler + +class FluidHandlerIterator(private val handler: IFluidHandler, initialPosition: Int = 0) : AbstractIndexBasedIterator(0, initialPosition) { + init { + require(initialPosition in 0 .. handler.tanks) { "Invalid initial position: $initialPosition" } + } + + override fun remove(location: Int) { + throw UnsupportedOperationException() + } + + override fun get(location: Int): FluidStack { + return handler[location] + } + + override fun getMaxPos(): Int { + return handler.tanks + } +} + +fun IFluidHandler.iterator(position: Int = 0) = FluidHandlerIterator(this, position) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/FluidHandlerSpliterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/FluidHandlerSpliterator.kt new file mode 100644 index 000000000..9e8b3b672 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/FluidHandlerSpliterator.kt @@ -0,0 +1,31 @@ +package ru.dbotthepony.mc.otm.container + +import it.unimi.dsi.fastutil.objects.ObjectSpliterator +import it.unimi.dsi.fastutil.objects.ObjectSpliterators.AbstractIndexBasedSpliterator +import net.minecraftforge.fluids.FluidStack +import net.minecraftforge.fluids.capability.IFluidHandler +import java.util.Spliterator +import java.util.stream.Stream +import java.util.stream.StreamSupport + +class FluidHandlerSpliterator(private val handler: IFluidHandler, offset: Int = 0, private val maxPos: Int = handler.tanks) : AbstractIndexBasedSpliterator(offset) { + init { + require(offset in 0 until handler.tanks) { "Invalid offset $offset" } + require(maxPos >= offset && maxPos in 0 until handler.tanks) { "Invalid spliterator configuration: maxPos $maxPos offset $offset max tanks ${handler.tanks}" } + } + + override fun get(location: Int): FluidStack { + return handler[location] + } + + override fun getMaxPos(): Int { + return maxPos + } + + override fun makeForSplit(pos: Int, maxPos: Int): ObjectSpliterator { + return FluidHandlerSpliterator(handler, pos, maxPos) + } +} + +fun IFluidHandler.spliterator(offset: Int = 0): Spliterator = FluidHandlerSpliterator(this, offset) +fun IFluidHandler.stream(offset: Int = 0): Stream = StreamSupport.stream(spliterator(offset), false) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt index c0fbd76df..3ef0503d7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt @@ -14,6 +14,7 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.sounds.SoundEvent import net.minecraft.world.item.Item import net.minecraft.world.level.block.Block +import net.minecraft.world.level.material.Fluid import net.minecraftforge.registries.ForgeRegistries import net.minecraftforge.registries.IForgeRegistry @@ -65,6 +66,7 @@ fun IForgeRegistry.getKeyNullable(value: T): ResourceLocation? { } val Item.registryName get() = ForgeRegistries.ITEMS.getKeyNullable(this) +val Fluid.registryName get() = ForgeRegistries.FLUIDS.getKeyNullable(this) val Block.registryName get() = ForgeRegistries.BLOCKS.getKeyNullable(this) fun FriendlyByteBuf.writeRegistryId(value: Item) = writeRegistryId(ForgeRegistries.ITEMS, value) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/SlotIterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/SlotIterator.kt deleted file mode 100644 index 9db7a4561..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/SlotIterator.kt +++ /dev/null @@ -1,26 +0,0 @@ -package ru.dbotthepony.mc.otm.core.collect - -import net.minecraft.world.inventory.AbstractContainerMenu -import net.minecraft.world.inventory.Slot -import net.minecraft.world.item.ItemStack - -private class SlotIterator(private val parent: Iterator) : MutableIterator { - private var last: Slot? = null - - override fun hasNext(): Boolean { - return parent.hasNext() - } - - override fun next(): ItemStack { - return parent.next().also { last = it }.item - } - - override fun remove() { - val last = last ?: throw IllegalStateException("Never called next()") - last.set(ItemStack.EMPTY) - } -} - -fun AbstractContainerMenu.itemStackIterator() : MutableIterator = SlotIterator(slots.iterator()) -fun Iterable.itemStackIterator() : MutableIterator = SlotIterator(iterator()) -fun Iterator.asItemStackIterator() : MutableIterator = SlotIterator(this) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt index ac8d94713..60b8f775d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt @@ -209,6 +209,7 @@ fun Decimal.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAs } fun Int.formatPower(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.power.name"), decimalPlaces, formatAsReadable = formatAsReadable) +fun Int.formatFluid(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.fluid.name"), decimalPlaces, formatAsReadable = formatAsReadable) fun Decimal.formatPower(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.power.name"), decimalPlaces, formatAsReadable = formatAsReadable) fun Decimal.formatMatter(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.matter.name"), decimalPlaces, formatAsReadable = formatAsReadable) fun Decimal.formatMatterFull(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = TranslatableComponent("otm.gui.matter.format", formatSiComponent(TranslatableComponent("otm.gui.matter.name"), decimalPlaces, formatAsReadable = formatAsReadable)) @@ -219,6 +220,8 @@ fun BigInteger.formatMatterFull(decimalPlaces: Int = 2, formatAsReadable: Boolea fun formatPowerLevel(a: Decimal, b: Decimal, decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = TranslatableComponent("otm.gui.level", a.formatPower(decimalPlaces, formatAsReadable = formatAsReadable), b.formatPower(decimalPlaces, formatAsReadable = formatAsReadable)) fun formatMatterLevel(a: Decimal, b: Decimal, decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = TranslatableComponent("otm.gui.level", a.formatMatter(decimalPlaces, formatAsReadable = formatAsReadable), b.formatMatter(decimalPlaces, formatAsReadable = formatAsReadable)) +fun formatFluidLevel(a: Int, b: Int, decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = TranslatableComponent("otm.gui.level", a.formatFluid(decimalPlaces, formatAsReadable = formatAsReadable), b.formatFluid(decimalPlaces, formatAsReadable = formatAsReadable)) +fun formatFluidLevel(a: Int, b: Int, name: Component, decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = TranslatableComponent("otm.gui.fluid.level", a.formatFluid(decimalPlaces, formatAsReadable = formatAsReadable), b.formatFluid(decimalPlaces, formatAsReadable = formatAsReadable), name) private fun padded(num: Int): String { if (num in 0 .. 9) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt new file mode 100644 index 000000000..6da3b2b88 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt @@ -0,0 +1,274 @@ +package ru.dbotthepony.mc.otm.item + +import net.minecraft.core.BlockPos +import net.minecraft.core.Direction +import net.minecraft.nbt.CompoundTag +import net.minecraft.network.chat.Component +import net.minecraft.server.level.ServerLevel +import net.minecraft.sounds.SoundEvent +import net.minecraft.sounds.SoundEvents +import net.minecraft.sounds.SoundSource +import net.minecraft.world.InteractionResult +import net.minecraft.world.entity.player.Player +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.TooltipFlag +import net.minecraft.world.item.context.UseOnContext +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.Block +import net.minecraft.world.level.block.Blocks +import net.minecraft.world.level.block.LayeredCauldronBlock +import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.level.material.Fluid +import net.minecraft.world.level.material.Fluids +import net.minecraftforge.common.SoundActions +import net.minecraftforge.common.capabilities.ForgeCapabilities +import net.minecraftforge.common.capabilities.ICapabilityProvider +import net.minecraftforge.event.entity.player.PlayerInteractEvent +import net.minecraftforge.fluids.FluidStack +import net.minecraftforge.fluids.capability.IFluidHandler +import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack +import ru.dbotthepony.mc.otm.capability.fluidLevel +import ru.dbotthepony.mc.otm.capability.moveFluid +import ru.dbotthepony.mc.otm.container.get +import ru.dbotthepony.mc.otm.container.stream +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.ifPresentK +import ru.dbotthepony.mc.otm.core.immutableList +import ru.dbotthepony.mc.otm.core.immutableMap +import ru.dbotthepony.mc.otm.core.orNull + +class FluidCapsuleItem(val capacity: () -> Int) : Item(Properties().stacksTo(64)), PriorityUseItem { + private inner class Cap(itemStack: ItemStack) : FluidHandlerItemStack(itemStack, capacity.invoke()) { + override fun fill(resource: FluidStack, doFill: IFluidHandler.FluidAction): Int { + this.capacity = this@FluidCapsuleItem.capacity.invoke() + return super.fill(resource, doFill) + } + + override fun getTankCapacity(tank: Int): Int { + this.capacity = this@FluidCapsuleItem.capacity.invoke() + return super.getTankCapacity(tank) + } + + override fun drain(resource: FluidStack?, action: IFluidHandler.FluidAction?): FluidStack { + this.capacity = this@FluidCapsuleItem.capacity.invoke() + return super.drain(resource, action) + } + + override fun drain(maxDrain: Int, action: IFluidHandler.FluidAction?): FluidStack { + this.capacity = this@FluidCapsuleItem.capacity.invoke() + return super.drain(maxDrain, action) + } + } + + override fun isPriorityConsumer(event: PlayerInteractEvent.RightClickBlock): Boolean { + return canInteract(event.itemStack, event.entity, Context(event.hitVec.blockPos, event.entity.level.getBlockState(event.hitVec.blockPos), event.hitVec.direction)) + } + + override fun useOn(pContext: UseOnContext): InteractionResult { + val context = Context(pContext.clickedPos, pContext.level.getBlockState(pContext.clickedPos), pContext.clickedFace) + + if (canInteract(pContext.itemInHand, pContext.player ?: return InteractionResult.FAIL, context)) + return interact(pContext.itemInHand, pContext.player!!, context) + + return InteractionResult.FAIL + } + + override fun getName(pStack: ItemStack): Component { + pStack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK { + it.getFluidInTank(0).also { + if (!it.isEmpty) { + return TranslatableComponent("$descriptionId.named", it.displayName) + } + } + } + + return super.getName(pStack) + } + + override fun appendHoverText(pStack: ItemStack, pLevel: Level?, pTooltipComponents: MutableList, pIsAdvanced: TooltipFlag) { + super.appendHoverText(pStack, pLevel, pTooltipComponents, pIsAdvanced) + + pStack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK { + fluidLevel(it, pTooltipComponents) + } + } + + override fun initCapabilities(stack: ItemStack, nbt: CompoundTag?): ICapabilityProvider { + return Cap(stack) + } + + interface Interaction { + fun canInteract(item: ItemStack, player: Player, context: Context): Boolean + fun interact(item: ItemStack, player: Player, context: Context): InteractionResult + } + + private object FillCauldron : Interaction { + private data class Mapping(val fluid: Fluid, val blockState: BlockState, val soundEvent: SoundEvent) + + private val mapping = immutableList { + accept(Mapping(Fluids.WATER, Blocks.WATER_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 3), SoundEvents.BUCKET_EMPTY)) + accept(Mapping(Fluids.LAVA, Blocks.LAVA_CAULDRON.defaultBlockState(), SoundEvents.BUCKET_EMPTY_LAVA)) + } + + override fun canInteract(item: ItemStack, player: Player, context: Context): Boolean { + return player.level.getBlockState(context.blockPos).`is`(Blocks.CAULDRON) + } + + override fun interact(item: ItemStack, player: Player, context: Context): InteractionResult { + if (item.isEmpty || !context.blockState.`is`(Blocks.CAULDRON)) return InteractionResult.FAIL + + val targetItem = if (item.count == 1) item else item.copyWithCount(1) + + val cap = targetItem.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).orNull() ?: return InteractionResult.FAIL + + for ((fluid, newState, soundEvent) in mapping) { + val toDrain = FluidStack(fluid, 1000) + val drained = cap.drain(toDrain, IFluidHandler.FluidAction.SIMULATE) + + if (!drained.isEmpty && drained.amount == 1000) { + player.level.playSound(player, context.blockPos, soundEvent, SoundSource.BLOCKS) + val level = player.level as? ServerLevel ?: return InteractionResult.SUCCESS + level.setBlock(context.blockPos, newState, Block.UPDATE_ALL) + cap.drain(toDrain, IFluidHandler.FluidAction.EXECUTE) + + if (item.count != 1 && !player.level.isClientSide) { + item.count-- + + if (!player.inventory.add(targetItem)) { + player.spawnAtLocation(targetItem) + } + } + + return InteractionResult.sidedSuccess(player.level.isClientSide) + } + } + + return InteractionResult.FAIL + } + } + + private object EmptyCauldron : Interaction { + private val mapping = immutableMap { + put(Blocks.WATER_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 3), Fluids.WATER to SoundEvents.BUCKET_FILL) + put(Blocks.LAVA_CAULDRON.defaultBlockState(), Fluids.LAVA to SoundEvents.BUCKET_FILL_LAVA) + } + + override fun canInteract(item: ItemStack, player: Player, context: Context): Boolean { + return player.level.getBlockState(context.blockPos) in mapping + } + + override fun interact(item: ItemStack, player: Player, context: Context): InteractionResult { + if (item.isEmpty) return InteractionResult.FAIL + + val targetItem = if (item.count == 1) item else item.copyWithCount(1) + + val cap = targetItem.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).orNull() ?: return InteractionResult.FAIL + val mapped = mapping[context.blockState] ?: return InteractionResult.FAIL + + val toFill = FluidStack(mapped.first, 1000) + + val fill = cap.fill(toFill, IFluidHandler.FluidAction.SIMULATE) + if (fill != 1000) return InteractionResult.FAIL + + player.level.playSound(player, context.blockPos, mapped.second, SoundSource.BLOCKS) + + val level = player.level as? ServerLevel ?: return InteractionResult.SUCCESS + level.setBlock(context.blockPos, Blocks.CAULDRON.defaultBlockState(), Block.UPDATE_ALL) + cap.fill(toFill, IFluidHandler.FluidAction.EXECUTE) + + if (item.count != 1 && !player.level.isClientSide) { + item.count-- + + if (!player.inventory.add(targetItem)) { + player.spawnAtLocation(targetItem) + } + } + + return InteractionResult.sidedSuccess(player.level.isClientSide) + } + } + + private object FillEmptyCapability : Interaction { + override fun canInteract(item: ItemStack, player: Player, context: Context): Boolean { + val target = player.level.getBlockEntity(context.blockPos)?.getCapability(ForgeCapabilities.FLUID_HANDLER, context.side)?.orNull() ?: return false + val cap = item.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).orNull() ?: return false + return target.stream().anyMatch { !it.isEmpty } || cap.stream().anyMatch { !it.isEmpty } + } + + override fun interact(item: ItemStack, player: Player, context: Context): InteractionResult { + if (item.isEmpty) return InteractionResult.FAIL + + val targetItem = if (item.count == 1) item else item.copyWithCount(1) + + val itemCap = targetItem.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).orNull() ?: return InteractionResult.FAIL + val blockCap = player.level.getBlockEntity(context.blockPos)?.getCapability(ForgeCapabilities.FLUID_HANDLER, context.side)?.orNull() ?: return InteractionResult.FAIL + val fluid = itemCap[0] + + if (fluid.isEmpty || player.isCrouching) { + // заполняем из блока + val moveResult = moveFluid(source = blockCap, destination = itemCap, simulate = player.level.isClientSide) + + if (!moveResult.isEmpty) { + val sound = moveResult.fluid.fluidType.getSound(moveResult, SoundActions.BUCKET_FILL) + + if (sound != null) { + player.level.playSound(player, context.blockPos, sound, SoundSource.BLOCKS) + } + + if (item.count != 1 && !player.level.isClientSide) { + item.count-- + + if (!player.inventory.add(targetItem)) { + player.spawnAtLocation(targetItem) + } + } + + return InteractionResult.sidedSuccess(player.level.isClientSide) + } else { + return InteractionResult.FAIL + } + } else { + val moveResult = moveFluid(source = itemCap, destination = blockCap, simulate = player.level.isClientSide) + + if (!moveResult.isEmpty) { + val sound = moveResult.fluid.fluidType.getSound(moveResult, SoundActions.BUCKET_EMPTY) + + if (sound != null) { + player.level.playSound(player, context.blockPos, sound, SoundSource.BLOCKS) + } + + if (item.count != 1 && !player.level.isClientSide) { + item.count-- + + if (!player.inventory.add(targetItem)) { + player.spawnAtLocation(targetItem) + } + } + + return InteractionResult.sidedSuccess(player.level.isClientSide) + } else { + return InteractionResult.FAIL + } + } + } + } + + data class Context(val blockPos: BlockPos, val blockState: BlockState, val side: Direction) + + companion object : Interaction { + val interactions = immutableList { + accept(FillCauldron) + accept(EmptyCauldron) + accept(FillEmptyCapability) + } + + override fun canInteract(item: ItemStack, player: Player, context: Context): Boolean { + return interactions.any { it.canInteract(item, player, context) } + } + + override fun interact(item: ItemStack, player: Player, context: Context): InteractionResult { + return interactions.firstOrNull { it.canInteract(item, player, context) }?.interact(item, player, context) ?: InteractionResult.PASS + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PriorityUseItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PriorityUseItem.kt new file mode 100644 index 000000000..6f6475e46 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PriorityUseItem.kt @@ -0,0 +1,18 @@ +package ru.dbotthepony.mc.otm.item + +import net.minecraftforge.event.entity.player.PlayerInteractEvent +import net.minecraftforge.eventbus.api.Event + +interface PriorityUseItem { + fun isPriorityConsumer(event: PlayerInteractEvent.RightClickBlock): Boolean +} + +internal fun onItemRightClick(event: PlayerInteractEvent.RightClickBlock) { + val item = event.itemStack.item + + if (!event.itemStack.isEmpty && item is PriorityUseItem) { + if (item.isPriorityConsumer(event)) { + event.useBlock = Event.Result.DENY + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt index 42a065f10..d9ada7784 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt @@ -4,8 +4,15 @@ import net.minecraft.world.item.CreativeModeTab import net.minecraft.world.item.DyeColor import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack +import net.minecraft.world.level.material.FlowingFluid +import net.minecraft.world.level.material.Fluids +import net.minecraftforge.common.capabilities.ForgeCapabilities +import net.minecraftforge.fluids.FluidStack +import net.minecraftforge.fluids.capability.IFluidHandler +import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.capability.matter.matter import ru.dbotthepony.mc.otm.capability.matteryEnergy +import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.registryName private fun CreativeModeTab.Output.accept(values: Collection) { @@ -140,6 +147,18 @@ internal fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { accept(MItems.PATTERN_DRIVE_CREATIVE) accept(MItems.PATTERN_DRIVE_CREATIVE2) + accept(MItems.FLUID_CAPSULE) + + for (fluid in ForgeRegistries.FLUIDS.values) { + if (fluid != Fluids.EMPTY && fluid.isSource(fluid.defaultFluidState())) { + accept(ItemStack(MItems.FLUID_CAPSULE, 1).also { + it.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK { + it.fill(FluidStack(fluid, it.getTankCapacity(0)), IFluidHandler.FluidAction.EXECUTE) + } + }) + } + } + base(MItems.CARGO_CRATE_MINECARTS) accept(MItems.NUTRIENT_PASTE) 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 b4fb9c1fd..19ab301f6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -155,6 +155,8 @@ object MItems { val ESSENCE_CAPSULE: EssenceCapsuleItem by registry.register("essence_capsule") { EssenceCapsuleItem() } val ESSENCE_DRIVE: EssenceCapsuleItem by registry.register("essence_drive") { EssenceCapsuleItem() } + val FLUID_CAPSULE: FluidCapsuleItem by registry.register("fluid_capsule") { FluidCapsuleItem(ItemsConfig::FLUID_CAPSULE_CAPACITY) } + val TRITANIUM_COMPONENT: ForgeTier = ForgeTier( Tiers.IRON.level, 3072, From 82e410ad336dd739203f7e268af379065a511128 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 2 Apr 2023 15:10:13 +0700 Subject: [PATCH 0467/1199] Use onItemUseFirst --- .../mc/otm/OverdriveThatMatters.java | 3 --- .../mc/otm/item/FluidCapsuleItem.kt | 17 ++++++++--------- .../dbotthepony/mc/otm/item/PriorityUseItem.kt | 18 ------------------ 3 files changed, 8 insertions(+), 30 deletions(-) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/item/PriorityUseItem.kt diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 8f5a5f643..20ee86646 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -47,7 +47,6 @@ import ru.dbotthepony.mc.otm.config.ServerConfig; import ru.dbotthepony.mc.otm.config.ToolsConfig; import ru.dbotthepony.mc.otm.core.math.Decimal; import ru.dbotthepony.mc.otm.item.ItemTritaniumArmor; -import ru.dbotthepony.mc.otm.item.PriorityUseItemKt; import ru.dbotthepony.mc.otm.item.QuantumBatteryItem; import ru.dbotthepony.mc.otm.item.weapon.AbstractWeaponItem; import ru.dbotthepony.mc.otm.item.PortableCondensationDriveItem; @@ -187,8 +186,6 @@ public final class OverdriveThatMatters { EVENT_BUS.addListener(EventPriority.NORMAL, MatteryBlockEntity.Companion::playerDisconnected); EVENT_BUS.addListener(EventPriority.LOWEST, MatteryBlockEntity.Companion::postLevelTick); - EVENT_BUS.addListener(EventPriority.NORMAL, PriorityUseItemKt::onItemRightClick); - EVENT_BUS.addListener(EventPriority.LOWEST, KillAsAndroidTrigger.INSTANCE::onKill); EVENT_BUS.addListener(EventPriority.NORMAL, EnderTeleporterFeature.Companion::onEntityDeath); 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 6da3b2b88..52fc46eab 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt @@ -24,7 +24,6 @@ import net.minecraft.world.level.material.Fluids import net.minecraftforge.common.SoundActions import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.capabilities.ICapabilityProvider -import net.minecraftforge.event.entity.player.PlayerInteractEvent import net.minecraftforge.fluids.FluidStack import net.minecraftforge.fluids.capability.IFluidHandler import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack @@ -38,7 +37,7 @@ import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.immutableMap import ru.dbotthepony.mc.otm.core.orNull -class FluidCapsuleItem(val capacity: () -> Int) : Item(Properties().stacksTo(64)), PriorityUseItem { +class FluidCapsuleItem(val capacity: () -> Int) : Item(Properties().stacksTo(64)) { private inner class Cap(itemStack: ItemStack) : FluidHandlerItemStack(itemStack, capacity.invoke()) { override fun fill(resource: FluidStack, doFill: IFluidHandler.FluidAction): Int { this.capacity = this@FluidCapsuleItem.capacity.invoke() @@ -61,17 +60,17 @@ class FluidCapsuleItem(val capacity: () -> Int) : Item(Properties().stacksTo(64) } } - override fun isPriorityConsumer(event: PlayerInteractEvent.RightClickBlock): Boolean { - return canInteract(event.itemStack, event.entity, Context(event.hitVec.blockPos, event.entity.level.getBlockState(event.hitVec.blockPos), event.hitVec.direction)) - } - - override fun useOn(pContext: UseOnContext): InteractionResult { + // TODO: Так как использование предмета заблокировано за player.abilities.canBuild + // капсулу нельзя использовать в режиме приключения + // почему же можно использовать вёдра на котлах? + // ИБО КОТЛЫ ЗАХАРДКОЖЕНЫ НА ВЗАИМОДЕЙСТВИЕ С ВЁДРАМИ + override fun onItemUseFirst(stack: ItemStack, pContext: UseOnContext): InteractionResult { val context = Context(pContext.clickedPos, pContext.level.getBlockState(pContext.clickedPos), pContext.clickedFace) if (canInteract(pContext.itemInHand, pContext.player ?: return InteractionResult.FAIL, context)) return interact(pContext.itemInHand, pContext.player!!, context) - return InteractionResult.FAIL + return super.onItemUseFirst(stack, pContext) } override fun getName(pStack: ItemStack): Component { @@ -140,7 +139,7 @@ class FluidCapsuleItem(val capacity: () -> Int) : Item(Properties().stacksTo(64) } } - return InteractionResult.sidedSuccess(player.level.isClientSide) + return InteractionResult.CONSUME } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PriorityUseItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PriorityUseItem.kt deleted file mode 100644 index 6f6475e46..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PriorityUseItem.kt +++ /dev/null @@ -1,18 +0,0 @@ -package ru.dbotthepony.mc.otm.item - -import net.minecraftforge.event.entity.player.PlayerInteractEvent -import net.minecraftforge.eventbus.api.Event - -interface PriorityUseItem { - fun isPriorityConsumer(event: PlayerInteractEvent.RightClickBlock): Boolean -} - -internal fun onItemRightClick(event: PlayerInteractEvent.RightClickBlock) { - val item = event.itemStack.item - - if (!event.itemStack.isEmpty && item is PriorityUseItem) { - if (item.isPriorityConsumer(event)) { - event.useBlock = Event.Result.DENY - } - } -} From 90f345a2d9c42d270f21833b23191cb606d33f6f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 6 Apr 2023 15:07:11 +0700 Subject: [PATCH 0468/1199] Fluid tanks general improvements to SI prefix formatter networking regarding fluid stacks Own fluid handler implementations --- .../mc/otm/datagen/lang/English.kt | 8 +- .../mc/otm/datagen/lang/Russian.kt | 8 +- .../mc/otm/datagen/loot/LootTablesData.kt | 1 + .../datagen/recipes/CraftingTableRecipes.kt | 16 ++ .../dbotthepony/mc/otm/datagen/tags/Tags.kt | 1 + .../mc/otm/block/decorative/FluidTankBlock.kt | 24 +++ .../block/entity/MatteryWorkerBlockEntity.kt | 3 +- .../entity/decorative/FluidTankBlockEntity.kt | 204 ++++++++++++++++++ .../ru/dbotthepony/mc/otm/capability/Ext.kt | 76 +++++-- .../mc/otm/capability/FlowDirection.kt | 9 +- .../fluid/AbstractMatteryFluidHandler.kt | 102 +++++++++ .../fluid/BlockMatteryFluidHandler.kt | 54 +++++ .../fluid/ItemMatteryFluidHandler.kt | 41 ++++ .../mc/otm/client/render/MatterySprite.kt | 6 + .../screen/decorative/FluidTankScreen.kt | 44 ++++ .../client/screen/panels/util/SpritePanel.kt | 22 ++ .../client/screen/widget/FluidGaugePanel.kt | 106 +++++++++ .../client/screen/widget/MatterGaugePanel.kt | 2 +- .../client/screen/widget/PatternGaugePanel.kt | 2 +- .../screen/widget/ProgressGaugePanel.kt | 2 +- .../dbotthepony/mc/otm/config/ItemsConfig.kt | 3 +- .../mc/otm/container/FluidHandlerIterator.kt | 2 +- .../otm/container/FluidHandlerSpliterator.kt | 3 +- .../mc/otm/container/HandlerFilter.kt | 34 +++ .../mc/otm/container/MatteryContainer.kt | 22 ++ .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 4 + .../dbotthepony/mc/otm/core/math/RGBAColor.kt | 8 + .../mc/otm/core/util/DataStreams.kt | 2 + .../mc/otm/core/util/Formatting.kt | 91 +++----- .../mc/otm/core/util/FriendlyStreams.kt | 37 ++++ .../dbotthepony/mc/otm/core/util/SiPrefix.kt | 148 +++++++++---- .../mc/otm/data/loot/CopyTileNbtFunction.kt | 5 +- .../mc/otm/item/FluidCapsuleItem.kt | 35 +-- .../dbotthepony/mc/otm/item/FluidTankItem.kt | 57 +++++ .../mc/otm/menu/decorative/FluidTankMenu.kt | 59 +++++ .../mc/otm/menu/widget/FluidGaugeWidget.kt | 46 ++++ .../mc/otm/menu/widget/LevelGaugeWidget.kt | 53 ++++- .../mc/otm/menu/widget/ProgressGaugeWidget.kt | 25 ++- .../mc/otm/registry/CreativeTabs.kt | 27 ++- .../mc/otm/registry/MBlockEntities.kt | 2 + .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 2 + .../ru/dbotthepony/mc/otm/registry/MItems.kt | 1 + .../ru/dbotthepony/mc/otm/registry/MMenus.kt | 4 + .../ru/dbotthepony/mc/otm/registry/MNames.kt | 1 + .../textures/gui/widgets/fluid_level.png | Bin 0 -> 617 bytes .../textures/gui/widgets/fluid_level.xcf | Bin 0 -> 2603 bytes 46 files changed, 1211 insertions(+), 191 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/FluidTankBlockEntity.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/AbstractMatteryFluidHandler.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/BlockMatteryFluidHandler.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/ItemMatteryFluidHandler.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/FluidTankScreen.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/SpritePanel.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/FluidGaugePanel.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidTankItem.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/FluidTankMenu.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/FluidGaugeWidget.kt create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/fluid_level.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/fluid_level.xcf diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index a7225c4cc..771ba8869 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -177,6 +177,7 @@ private fun misc(provider: MatteryLanguageProvider) { misc("suffix.merge", "%s %s") + misc("suffix.none", "%s %s") misc("suffix.kilo", "%s k%s") misc("suffix.mega", "%s M%s") misc("suffix.giga", "%s G%s") @@ -264,9 +265,11 @@ private fun misc(provider: MatteryLanguageProvider) { gui("power.percentage_level", "Energy level: %s%%") gui("level", "%s / %s") gui("power.name", "MtJ") - gui("fluid.name", "mB") + gui("fluid.name", "B") gui("fluid.level", "%s / %s of %s") + gui("empty", "Empty") + gui("power.burn_time", "Burn time left: %s ticks") gui("progress_widget", "Progress: %s%%") @@ -370,6 +373,9 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.MATTER_RECONSTRUCTOR, "Matter Reconstructor") add(MBlocks.MATTER_RECONSTRUCTOR, "desc", "Repairs tools using matter") + add(MBlocks.FLUID_TANK, "Fluid Tank") + add(MBlocks.FLUID_TANK, "named", "Fluid Tank (%s)") + add(MBlocks.ENGINE, "Ship Engine") add(MBlocks.HOLO_SIGN, "Holo Sign") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 72cc33147..77ccaab54 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -185,6 +185,7 @@ private fun misc(provider: MatteryLanguageProvider) { misc("suffix.merge", "%s %s") + misc("suffix.none", "%s %s") misc("suffix.kilo", "%s к%s") misc("suffix.mega", "%s М%s") misc("suffix.giga", "%s Г%s") @@ -271,9 +272,11 @@ private fun misc(provider: MatteryLanguageProvider) { gui("power.percentage_level", "Уровень энергии: %s%%") gui("level", "%s / %s") gui("power.name", "МтДж") - gui("fluid.name", "мВ") + gui("fluid.name", "В") gui("fluid.level", "%s / %s с %s") + gui("empty", "Пусто") + gui("power.burn_time", "Оставшееся время горения: %s тиков") gui("progress_widget", "Прогресс: %s%%") @@ -377,6 +380,9 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.MATTER_RECONSTRUCTOR, "Материальный реконструктор") add(MBlocks.MATTER_RECONSTRUCTOR, "desc", "Чинит инструменты используя материю") + add(MBlocks.FLUID_TANK, "Жидкостный бак") + add(MBlocks.FLUID_TANK, "named", "Жидкостный бак (%s)") + add(MBlocks.ENGINE, "Двигатель корабля") add(MBlocks.HOLO_SIGN, "Голографическая табличка") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index 4a5546942..e6217e755 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -129,6 +129,7 @@ fun addLootTables(lootTables: LootTables) { lootTables.tile(MBlocks.COBBLESTONE_GENERATOR) lootTables.tile(MBlocks.ESSENCE_STORAGE) lootTables.tile(MBlocks.MATTER_RECONSTRUCTOR) + lootTables.tile(MBlocks.FLUID_TANK) lootTables.tile(MBlocks.ENERGY_SERVO) lootTables.tile(MBlocks.ENERGY_COUNTER) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index ef76205cf..795954f11 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -308,4 +308,20 @@ fun addCraftingTableRecipes(consumer: Consumer) { .row(MItems.ELECTRIC_PARTS, MItems.MATTER_REPLICATOR, MItems.ELECTRIC_PARTS) .row(MItems.ELECTROMAGNET, MItems.ELECTROMAGNET, MItems.ELECTROMAGNET) .build(consumer) + + MatteryRecipe(MItems.FLUID_CAPSULE, category = RecipeCategory.TOOLS, count = 8) + .row(MItemTags.TRITANIUM_NUGGETS, MItemTags.TRITANIUM_NUGGETS, MItemTags.TRITANIUM_NUGGETS) + .rowB(MItemTags.HARDENED_GLASS_PANES) + .row(MItemTags.TRITANIUM_NUGGETS, MItemTags.TRITANIUM_NUGGETS, MItemTags.TRITANIUM_NUGGETS) + .unlockedBy(MItemTags.HARDENED_GLASS_PANES) + .unlockedBy(MItemTags.TRITANIUM_NUGGETS) + .build(consumer) + + MatteryRecipe(MItems.FLUID_TANK, category = RecipeCategory.DECORATIONS) + .row(MItemTags.TRITANIUM_INGOTS, MItemTags.HARDENED_GLASS_PANES, MItemTags.TRITANIUM_INGOTS) + .rowAC(MItemTags.HARDENED_GLASS_PANES, MItemTags.HARDENED_GLASS_PANES) + .row(MItemTags.TRITANIUM_INGOTS, MItemTags.HARDENED_GLASS_PANES, MItemTags.TRITANIUM_INGOTS) + .unlockedBy(MItemTags.HARDENED_GLASS_PANES) + .unlockedBy(MItemTags.TRITANIUM_INGOTS) + .build(consumer) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index dce283293..6dcc91e5f 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -171,6 +171,7 @@ fun addTags(tagsProvider: TagsProvider) { MBlocks.COBBLESTONE_GENERATOR, MBlocks.ESSENCE_STORAGE, MBlocks.MATTER_RECONSTRUCTOR, + MBlocks.FLUID_TANK, ), Tiers.IRON) tagsProvider.requiresPickaxe(MBlocks.TRITANIUM_ANVIL, Tiers.IRON) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt new file mode 100644 index 000000000..8586e54ab --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt @@ -0,0 +1,24 @@ +package ru.dbotthepony.mc.otm.block.decorative + +import net.minecraft.core.BlockPos +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.EntityBlock +import net.minecraft.world.level.block.entity.BlockEntity +import net.minecraft.world.level.block.entity.BlockEntityTicker +import net.minecraft.world.level.block.entity.BlockEntityType +import net.minecraft.world.level.block.state.BlockState +import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.entity.decorative.FluidTankBlockEntity + +class FluidTankBlock : RotatableMatteryBlock(), EntityBlock { + override fun newBlockEntity(pPos: BlockPos, pState: BlockState): BlockEntity { + return FluidTankBlockEntity(pPos, pState) + } + + override fun getTicker(pLevel: Level, pState: BlockState, pBlockEntityType: BlockEntityType): BlockEntityTicker? { + if (pLevel.isClientSide) + return null + + return BlockEntityTicker { _, _, _, pBlockEntity -> if (pBlockEntity is FluidTankBlockEntity) pBlockEntity.tick() } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt index bb7e717c7..0bf39c687 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt @@ -6,6 +6,7 @@ import net.minecraft.core.BlockPos import net.minecraft.world.level.block.state.BlockState import net.minecraft.nbt.CompoundTag import net.minecraft.network.chat.Component +import net.minecraft.world.item.BlockItem import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.BlockGetter @@ -388,7 +389,7 @@ abstract class MatteryWorkerBlockEntity( fun appendHoverText(itemStack: ItemStack, blockGetter: BlockGetter?, tooltips: MutableList, flag: TooltipFlag) { val tag = itemStack.tag ?: return - val subtag = tag.get("BlockEntityTag") as? CompoundTag + val subtag = tag.get(BlockItem.BLOCK_ENTITY_TAG) as? CompoundTag if (subtag != null) { if (subtag.contains(WORK_TICKS_KEY) && !subtag.contains(JOB_KEY)) { 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 new file mode 100644 index 000000000..1012264a9 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/FluidTankBlockEntity.kt @@ -0,0 +1,204 @@ +package ru.dbotthepony.mc.otm.block.entity.decorative + +import net.minecraft.core.BlockPos +import net.minecraft.server.level.ServerLevel +import net.minecraft.world.entity.item.ItemEntity +import net.minecraft.world.entity.player.Inventory +import net.minecraft.world.entity.player.Player +import net.minecraft.world.inventory.AbstractContainerMenu +import net.minecraft.world.item.ItemStack +import net.minecraft.world.level.block.state.BlockState +import net.minecraftforge.common.capabilities.ForgeCapabilities +import net.minecraftforge.fluids.FluidStack +import net.minecraftforge.fluids.capability.IFluidHandler +import org.apache.logging.log4j.LogManager +import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity +import ru.dbotthepony.mc.otm.capability.CombinedItemHandler +import ru.dbotthepony.mc.otm.capability.fluid.BlockMatteryFluidHandler +import ru.dbotthepony.mc.otm.capability.moveFluid +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.ifPresentK +import ru.dbotthepony.mc.otm.core.isNotEmpty +import ru.dbotthepony.mc.otm.core.orNull +import ru.dbotthepony.mc.otm.core.util.FluidStackValueCodec +import ru.dbotthepony.mc.otm.menu.decorative.FluidTankMenu +import ru.dbotthepony.mc.otm.registry.MBlockEntities + +class FluidTankBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.FLUID_TANK, blockPos, blockState) { + val fluid = BlockMatteryFluidHandler(::onChanged, ItemsConfig::FLUID_TANK_CAPACITY) + var synchronizedFluid by synchronizer.Field(FluidStack.EMPTY!!, FluidStackValueCodec) + private set + + val fillInput = MatteryContainer(::setChangedLight, 1) + val drainInput = MatteryContainer(::setChangedLight, 1) + val output = MatteryContainer(::setChangedLight, 1) + + val itemConfig = ConfigurableItemHandler( + input = CombinedItemHandler( + drainInput.handler(HandlerFilter.DrainableFluidContainers), + fillInput.handler(object : HandlerFilter { + override fun canInsert(slot: Int, stack: ItemStack): Boolean { + if (fluid.isEmpty) + return false + + stack.getCapability(ForgeCapabilities.FLUID_HANDLER).ifPresentK { + if (it.fill(fluid[0], IFluidHandler.FluidAction.SIMULATE) > 0) + return true + } + + stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK { + if (it.fill(fluid[0], IFluidHandler.FluidAction.SIMULATE) > 0) + return true + } + + return false + } + + override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { + return !canInsert(slot, stack) + } + }) + ), + output = output.handler(HandlerFilter.OnlyOut) + ) + + init { + exposeGlobally(ForgeCapabilities.FLUID_HANDLER, fluid) + savetables.stateful(::fluid, FLUID_KEY) + savetables.stateful(::fillInput) + savetables.stateful(::drainInput) + savetables.stateful(::output) + } + + private fun onChanged(new: FluidStack, old: FluidStack) { + synchronizedFluid = new.copy() + setChangedLight() + } + + private fun drainItem() { + val item = drainInput[0] + + if (item.isNotEmpty) { + val target = if (item.count == 1) item else item.copyWithCount(1) + val cap = target.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).orNull() ?: target.getCapability(ForgeCapabilities.FLUID_HANDLER).orNull() + + if (cap == null) { + if (output.consumeItem(item, simulate = false)) { + drainInput.setChanged(0) + } + + return + } + + if (fluid.isNotFull) { + if (item.count == 1) { + val moved0 = moveFluid(source = cap, destination = fluid) + + if (moved0.isNotEmpty) { + drainInput.setChanged(0) + + if (output.consumeItem(item, simulate = false)) { + drainInput.setChanged(0) + } + } + } else { + val moved0 = moveFluid(source = cap, destination = fluid, actuallyFill = false) + + if (moved0.isNotEmpty) { + if (output.consumeItem(target, simulate = true)) { + val target1 = item.copyWithCount(1) + val cap1 = target1.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).orNull() ?: target1.getCapability(ForgeCapabilities.FLUID_HANDLER).orNull() ?: throw ConcurrentModificationException() + + val moved1 = moveFluid(source = cap1, destination = fluid) + + if (moved1 != moved0 || moved1.amount != moved0.amount) { + LOGGER.error("Error moving fluids in Fluid tank at $blockPos: moved $moved0 during simulation from $target, moved $moved1 from $target1 during execution. This is likely a bug in OTM or other mod!") + } else { + item.count-- + drainInput.setChanged(0) + + if (!output.consumeItem(target1, simulate = false)) { + LOGGER.error("Unable to insert $target1 into output slot of Fluid tank at $blockPos, popping item in world instead to avoid item loss! This is likely a bug in OTM or other mod!") + (level as? ServerLevel)?.addFreshEntity(ItemEntity(level!!, blockPos.x.toDouble(), blockPos.y.toDouble(), blockPos.z.toDouble(), target1)) + } + } + } + } + } + } + } + } + + private fun fillItem() { + val item = fillInput[0] + + if (item.isNotEmpty) { + val target = if (item.count == 1) item else item.copyWithCount(1) + val cap = target.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).orNull() ?: target.getCapability(ForgeCapabilities.FLUID_HANDLER).orNull() + + if (cap == null) { + if (output.consumeItem(item, simulate = false)) { + fillInput.setChanged(0) + } + + return + } + + if (fluid.isNotEmpty) { + if (item.count == 1) { + val moved0 = moveFluid(source = fluid, destination = cap) + + if (moved0.isNotEmpty) { + fillInput.setChanged(0) + + if (output.consumeItem(item, simulate = false)) { + fillInput.setChanged(0) + } + } + } else { + val moved0 = moveFluid(source = fluid, destination = cap, actuallyDrain = false) + + if (moved0.isNotEmpty) { + if (output.consumeItem(target, simulate = true)) { + val target1 = item.copyWithCount(1) + val cap1 = target1.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).orNull() ?: target1.getCapability(ForgeCapabilities.FLUID_HANDLER).orNull() ?: throw ConcurrentModificationException() + + val moved1 = moveFluid(source = fluid, destination = cap1) + + if (moved1 != moved0 || moved1.amount != moved0.amount) { + LOGGER.error("Error moving fluids in Fluid tank at $blockPos: moved $moved0 during simulation from $target, moved $moved1 from $target1 during execution. This is likely a bug in OTM or other mod!") + } else { + item.count-- + fillInput.setChanged(0) + + if (!output.consumeItem(target1, simulate = false)) { + LOGGER.error("Unable to insert $target1 into output slot of Fluid tank at $blockPos, popping item in world instead to avoid item loss! This is likely a bug in OTM or other mod!") + (level as? ServerLevel)?.addFreshEntity(ItemEntity(level!!, blockPos.x.toDouble(), blockPos.y.toDouble(), blockPos.z.toDouble(), target1)) + } + } + } + } + } + } + } + } + + override fun tick() { + super.tick() + + drainItem() + fillItem() + } + + override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { + return FluidTankMenu(containerID, inventory, this) + } + + companion object { + const val FLUID_KEY = "fluid" + private val LOGGER = LogManager.getLogger() + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt index 61a906c2f..1f2950ed1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt @@ -27,9 +27,11 @@ import ru.dbotthepony.mc.otm.compat.curios.isCuriosLoaded import ru.dbotthepony.mc.otm.compat.mekanism.getMekanismEnergySided import ru.dbotthepony.mc.otm.compat.mekanism.mekanismEnergy import ru.dbotthepony.mc.otm.container.awareStream +import ru.dbotthepony.mc.otm.container.iterator import ru.dbotthepony.mc.otm.container.stream import ru.dbotthepony.mc.otm.core.collect.AwareItemStack import ru.dbotthepony.mc.otm.core.collect.ContainerItemStackEntry +import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.core.util.formatFluidLevel @@ -44,7 +46,7 @@ val ICapabilityProvider.matteryPlayer: MatteryPlayerCapability? get() = getCapab /** * Does a checked energy receive, calls [IMatteryEnergyStorage.receiveEnergyChecked] if possible */ -internal fun IEnergyStorage.receiveEnergy(amount: Decimal, simulate: Boolean): Decimal { +fun IEnergyStorage.receiveEnergy(amount: Decimal, simulate: Boolean): Decimal { if (this is IMatteryEnergyStorage) return receiveEnergyChecked(amount, simulate) @@ -60,7 +62,7 @@ internal fun IEnergyStorage.receiveEnergy(amount: Decimal, simulate: Boolean): D return Decimal.valueOf(receiveEnergy(amount.toInt(), simulate)) } -internal fun IEnergyStorage.transcieveEnergy(amount: Decimal, isReceiving: Boolean, simulate: Boolean): Decimal { +fun IEnergyStorage.transcieveEnergy(amount: Decimal, isReceiving: Boolean, simulate: Boolean): Decimal { if (isReceiving) return receiveEnergy(amount, simulate) else @@ -70,7 +72,7 @@ internal fun IEnergyStorage.transcieveEnergy(amount: Decimal, isReceiving: Boole /** * Does a checked energy extraction, calls [IMatteryEnergyStorage.extractEnergyChecked] if possible */ -internal fun IEnergyStorage.extractEnergy(amount: Decimal, simulate: Boolean): Decimal { +fun IEnergyStorage.extractEnergy(amount: Decimal, simulate: Boolean): Decimal { if (this is IMatteryEnergyStorage) return extractEnergyChecked(amount, simulate) @@ -313,7 +315,7 @@ fun Player.awareAllItemsStream(includeCosmetics: Boolean = false): Stream { +fun moveBetweenSlots(source: IItemHandler, sourceSlot: Int, destination: IItemHandler, destinationSlot: Int): Pair { val getItem = source.extractItem(sourceSlot, Int.MAX_VALUE, true) if (getItem.isEmpty) { @@ -349,7 +351,7 @@ internal fun moveBetweenSlots(source: IItemHandler, sourceSlot: Int, destination } @Suppress("name_shadowing") -internal fun moveEnergy(source: IEnergyStorage, destination: IEnergyStorage, amount: Decimal = Decimal.LONG_MAX_VALUE, simulate: Boolean, ignoreFlowRestrictions: Boolean = false): Decimal { +fun moveEnergy(source: IEnergyStorage, destination: IEnergyStorage, amount: Decimal = Decimal.LONG_MAX_VALUE, simulate: Boolean, ignoreFlowRestrictions: Boolean = false): Decimal { val extracted = if (ignoreFlowRestrictions && source is IMatteryEnergyStorage) source.extractEnergy(amount, true) else source.extractEnergy(amount, true) if (extracted.isPositive) { @@ -372,25 +374,17 @@ internal fun moveEnergy(source: IEnergyStorage, destination: IEnergyStorage, amo return Decimal.ZERO } -internal fun fluidLevel(it: IFluidHandler, tooltips: MutableList) { - val fluid = it.getFluidInTank(0) +internal fun IFluidHandler.fluidLevel(tooltips: MutableList) { + val fluid = getFluidInTank(0) if (fluid.isEmpty) { - tooltips.add(formatFluidLevel(0, it.getTankCapacity(0), formatAsReadable = ShiftPressedCond).withStyle(ChatFormatting.GRAY)) + tooltips.add(formatFluidLevel(0, getTankCapacity(0), formatAsReadable = ShiftPressedCond).withStyle(ChatFormatting.GRAY)) } else { - tooltips.add(formatFluidLevel(fluid.amount, it.getTankCapacity(0), fluid.displayName, formatAsReadable = ShiftPressedCond).withStyle(ChatFormatting.GRAY)) + tooltips.add(formatFluidLevel(fluid.amount, getTankCapacity(0), fluid.displayName, formatAsReadable = ShiftPressedCond).withStyle(ChatFormatting.GRAY)) } } -internal fun moveFluid(source: IFluidHandler, sourceTank: Int? = null, destination: IFluidHandler, limit: Int = Int.MAX_VALUE, simulate: Boolean = false, actuallyDrain: Boolean = true): FluidStack { - val drained: FluidStack - - if (sourceTank == null) { - drained = source.drain(limit, IFluidHandler.FluidAction.SIMULATE) - } else { - drained = source.drain(source.getFluidInTank(sourceTank), IFluidHandler.FluidAction.SIMULATE) - } - +private fun actuallyMoveFluid(drained: FluidStack, source: IFluidHandler, destination: IFluidHandler, limit: Int, actuallyDrain: Boolean, actuallyFill: Boolean): FluidStack { if (drained.isEmpty) return FluidStack.EMPTY val filled = destination.fill(drained, IFluidHandler.FluidAction.SIMULATE) @@ -402,7 +396,7 @@ internal fun moveFluid(source: IFluidHandler, sourceTank: Int? = null, destinati val filled2 = destination.fill(drained2, IFluidHandler.FluidAction.SIMULATE) if (filled2 != drained2.amount) return FluidStack.EMPTY - if (simulate) return FluidStack(drained2, filled2) + if (!actuallyDrain && !actuallyFill) return FluidStack(drained2, filled2) val drained3: FluidStack @@ -416,11 +410,49 @@ internal fun moveFluid(source: IFluidHandler, sourceTank: Int? = null, destinati drained3 = drained2 } - val filled3 = destination.fill(drained3, IFluidHandler.FluidAction.EXECUTE) + val filled3: Int - if (filled3 != drained3.amount) { - LOGGER.warn("Inconsistency of fluid insertion to $destination between simulate and execute modes (simulated $filled2; inserted $filled3); This can lead to duping!!!") + if (actuallyFill) { + filled3 = destination.fill(drained3, IFluidHandler.FluidAction.EXECUTE) + + if (filled3 != drained3.amount) { + LOGGER.warn("Inconsistency of fluid insertion to $destination between simulate and execute modes (simulated $filled2; inserted $filled3); This can lead to duping!!!") + } + } else { + filled3 = filled2 } return FluidStack(drained3, filled3) } + +fun moveFluid(source: IFluidHandler, sourceTank: Int? = null, destination: IFluidHandler, limit: Int = Int.MAX_VALUE, actuallyDrain: Boolean = true, actuallyFill: Boolean = true): FluidStack { + if (sourceTank == null) { + for (drained in destination.iterator()) { + if (drained.isNotEmpty) { + val moved = actuallyMoveFluid(drained, source, destination, limit, actuallyDrain, actuallyFill) + if (moved.isNotEmpty) return moved + } + } + + for (drained in source.iterator()) { + if (drained.isNotEmpty) { + val moved = actuallyMoveFluid(drained, source, destination, limit, actuallyDrain, actuallyFill) + if (moved.isNotEmpty) return moved + } + } + + return FluidStack.EMPTY + } else { + return actuallyMoveFluid(source.drain(source.getFluidInTank(sourceTank), IFluidHandler.FluidAction.SIMULATE), source, destination, limit, actuallyDrain, actuallyFill) + } +} + +val IFluidHandler.isEmpty: Boolean get() = stream().allMatch { it.isEmpty } +val IFluidHandler.isNotEmpty: Boolean get() = stream().anyMatch { it.isNotEmpty } +val IFluidHandler.isNotFull: Boolean get() { + for ((i, fluid) in iterator().withIndex()) + if (fluid.isEmpty || fluid.amount < getTankCapacity(i)) + return true + + return false +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt index b26b06f06..4e72ceb3a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt @@ -1,10 +1,12 @@ package ru.dbotthepony.mc.otm.capability import com.google.common.collect.ImmutableSet +import net.minecraft.network.chat.Component +import ru.dbotthepony.mc.otm.core.TranslatableComponent import java.util.function.Predicate /** - * Represents possible flow direction, both for matter and for energy + * Represents possible flow direction, be it matter, energy, fluids, etc * * To dynamically get this enum by two booleans (by input and output states), use [FlowDirection.of] * @@ -38,7 +40,7 @@ enum class FlowDirection(val input: Boolean, val output: Boolean, val translatio BI_DIRECTIONAL(true, true, "otm.gui.side_mode.input_output"), /** - * Why would you want to use this + * No flow possible */ NONE(false, false, "otm.gui.side_mode.disabled"); @@ -62,6 +64,9 @@ enum class FlowDirection(val input: Boolean, val output: Boolean, val translatio }.build() } + val translation: Component + get() = TranslatableComponent(translationKey) + /** * Subtype test (returns true if we can assign [t] to this, e.g. we can assign [BI_DIRECTIONAL] to [INPUT]) */ diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/AbstractMatteryFluidHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/AbstractMatteryFluidHandler.kt new file mode 100644 index 000000000..5cb8ac463 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/AbstractMatteryFluidHandler.kt @@ -0,0 +1,102 @@ +package ru.dbotthepony.mc.otm.capability.fluid + +import net.minecraftforge.fluids.FluidStack +import net.minecraftforge.fluids.capability.IFluidHandler +import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.core.isNotEmpty + +abstract class AbstractMatteryFluidHandler : IFluidHandler { + abstract var fluid: FluidStack + abstract val capacity: Int + + val isEmpty: Boolean + get() = fluid.isEmpty + + val isNotEmpty: Boolean + get() = fluid.isNotEmpty + + val isNotFull: Boolean + get() = fluid.isEmpty || fluid.amount < capacity + + open val direction: FlowDirection + get() = FlowDirection.BI_DIRECTIONAL + + final override fun getTanks() = 1 + + final override fun getFluidInTank(tank: Int): FluidStack { + require(tank == 0) { "Invalid tank: $tank" } + return fluid.copy() + } + + final override fun getTankCapacity(tank: Int): Int { + require(tank == 0) { "Invalid tank: $tank" } + return capacity + } + + protected open fun isFluidValid(stack: FluidStack): Boolean { + return true + } + + final override fun isFluidValid(tank: Int, stack: FluidStack): Boolean { + require(tank == 0) { "Invalid tank: $tank" } + return isFluidValid(stack) + } + + final override fun fill(resource: FluidStack, action: IFluidHandler.FluidAction): Int { + if (resource.isEmpty || !isFluidValid(resource) || !direction.input) { + return 0 + } + + val fluid = fluid + + if (fluid.isEmpty || fluid.isFluidEqual(resource)) { + val new = (fluid.amount + resource.amount).coerceAtMost(capacity) + if (new <= fluid.amount) return 0 + + if (action.execute()) { + this.fluid = FluidStack(resource, new) + } + + return new - fluid.amount + } else { + return 0 + } + } + + final override fun drain(resource: FluidStack, action: IFluidHandler.FluidAction): FluidStack { + if (resource.isEmpty || !direction.output) { + return FluidStack.EMPTY + } + + val fluid = fluid + + if (!fluid.isEmpty && fluid.isFluidEqual(resource)) { + return drain(resource.amount, action) + } else { + return FluidStack.EMPTY + } + } + + final override fun drain(maxDrain: Int, action: IFluidHandler.FluidAction): FluidStack { + require(maxDrain >= 0) { "Invalid amount to drain: $maxDrain" } + if (maxDrain == 0 || !direction.output) return FluidStack.EMPTY + + val fluid = fluid + + if (fluid.isEmpty) { + return FluidStack.EMPTY + } else { + val new = (fluid.amount - maxDrain).coerceAtLeast(0) + + if (action.execute()) { + if (new == 0) { + this.fluid = FluidStack.EMPTY + } else { + this.fluid = FluidStack(fluid, new) + } + } + + return FluidStack(fluid, fluid.amount - new) + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/BlockMatteryFluidHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/BlockMatteryFluidHandler.kt new file mode 100644 index 000000000..6d836f859 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/BlockMatteryFluidHandler.kt @@ -0,0 +1,54 @@ +package ru.dbotthepony.mc.otm.capability.fluid + +import net.minecraft.nbt.CompoundTag +import net.minecraft.world.item.BlockItem +import net.minecraft.world.item.ItemStack +import net.minecraftforge.common.util.INBTSerializable +import net.minecraftforge.fluids.FluidStack +import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.core.tagNotNull +import java.util.function.IntSupplier + +/** + * Fluid handler for blocks + */ +class BlockMatteryFluidHandler(val onChanged: (new: FluidStack, old: FluidStack) -> Unit, private val _capacity: IntSupplier) : AbstractMatteryFluidHandler(), INBTSerializable { + override var fluid: FluidStack = FluidStack.EMPTY + set(value) { + val old = field + field = value + onChanged(value, old) + } + + override val capacity: Int + get() = _capacity.asInt + + override fun serializeNBT(): CompoundTag { + return fluid.writeToNBT(CompoundTag()) + } + + override fun deserializeNBT(nbt: CompoundTag?) { + fluid = FluidStack.loadFluidStackFromNBT(nbt) + } + + /** + * Fluid handler for items representing block with [BlockMatteryFluidHandler] + */ + open class Item(itemStack: ItemStack, capacity: IntSupplier, private val nbtName: String) : ItemMatteryFluidHandler(itemStack, capacity) { + override var fluid: FluidStack + get() { + val sub = itemStack.tag?.get(BlockItem.BLOCK_ENTITY_TAG) as? CompoundTag ?: return FluidStack.EMPTY + return FluidStack.loadFluidStackFromNBT(sub[nbtName] as? CompoundTag ?: return FluidStack.EMPTY) + } + set(value) { + var sub = itemStack.tagNotNull.get(BlockItem.BLOCK_ENTITY_TAG) as? CompoundTag + + if (sub == null) { + sub = CompoundTag() + itemStack.tagNotNull[BlockItem.BLOCK_ENTITY_TAG] = sub + } + + sub[nbtName] = value.writeToNBT(CompoundTag()) + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/ItemMatteryFluidHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/ItemMatteryFluidHandler.kt new file mode 100644 index 000000000..6cddb0c21 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/ItemMatteryFluidHandler.kt @@ -0,0 +1,41 @@ +package ru.dbotthepony.mc.otm.capability.fluid + +import net.minecraft.core.Direction +import net.minecraft.nbt.CompoundTag +import net.minecraft.world.item.BlockItem +import net.minecraft.world.item.ItemStack +import net.minecraftforge.common.capabilities.Capability +import net.minecraftforge.common.capabilities.ForgeCapabilities +import net.minecraftforge.common.capabilities.ICapabilityProvider +import net.minecraftforge.common.util.LazyOptional +import net.minecraftforge.fluids.FluidStack +import net.minecraftforge.fluids.capability.IFluidHandlerItem +import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.core.tagNotNull +import java.util.function.IntSupplier + +/** + * Fluid handler for standalone items + */ +open class ItemMatteryFluidHandler(val itemStack: ItemStack, private val _capacity: IntSupplier) : AbstractMatteryFluidHandler(), IFluidHandlerItem, ICapabilityProvider { + private val resolver = LazyOptional.of { this } + + override var fluid: FluidStack + get() { return FluidStack.loadFluidStackFromNBT(itemStack.tag?.get("fluid") as? CompoundTag ?: return FluidStack.EMPTY) } + set(value) { itemStack.tagNotNull["fluid"] = value.writeToNBT(CompoundTag()) } + + final override val capacity: Int + get() = _capacity.asInt + + final override fun getContainer(): ItemStack { + return itemStack + } + + override fun getCapability(cap: Capability, side: Direction?): LazyOptional { + if (cap === ForgeCapabilities.FLUID_HANDLER_ITEM || cap === ForgeCapabilities.FLUID_HANDLER) { + return resolver.cast() + } + + return LazyOptional.empty() + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt index 741654d4a..867b6be9e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt @@ -64,5 +64,11 @@ data class MatterySprite @JvmOverloads constructor( override val type: SpriteType get() = SpriteType.SINGLE + + companion object { + fun single(texture: ResourceLocation, width: Float, height: Float, winding: UVWindingOrder = UVWindingOrder.NORMAL): MatterySprite { + return MatterySprite(texture, 0f, 0f, width, height, width, height, winding) + } + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/FluidTankScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/FluidTankScreen.kt new file mode 100644 index 000000000..4f9f9f00e --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/FluidTankScreen.kt @@ -0,0 +1,44 @@ +package ru.dbotthepony.mc.otm.client.screen.decorative + +import net.minecraft.network.chat.Component +import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.render.UVWindingOrder +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.Dock +import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode +import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.PlayerEquipmentPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls +import ru.dbotthepony.mc.otm.client.screen.panels.makeCuriosPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.SpritePanel +import ru.dbotthepony.mc.otm.client.screen.widget.FluidGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel +import ru.dbotthepony.mc.otm.menu.decorative.FluidTankMenu + +class FluidTankScreen(menu: FluidTankMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { + override fun makeMainFrame(): FramePanel> { + val frame = super.makeMainFrame()!! + + FluidGaugePanel(this, frame, menu.fluid, x = LEFT_MARGIN, y = GAUGE_TOP_WITHOUT_SLOT - 6f) + + val s = SpritePanel(this, frame, ProgressGaugePanel.GAUGE_BACKGROUND, x = 30f, y = 30f) + SpritePanel(this, frame, ProgressGaugePanel.GAUGE_BACKGROUND, x = 30f, y = 55f, winding = UVWindingOrder.FLOP) + + SlotPanel(this, frame, menu.fillInput, x = 30f + s.width + 4f, y = 28f) + SlotPanel(this, frame, menu.drainInput, x = 30f + s.width + 4f, y = 53f) + + SlotPanel(this, frame, menu.output, x = 30f + s.width + 4f + 20f, y = 53f) + + makeDeviceControls(this, frame, itemConfig = menu.itemConfig, redstoneConfig = menu.redstoneConfig) + makeCuriosPanel(this, frame, menu.equipment.curiosSlots, autoAlign = true) + + PlayerEquipmentPanel(this, frame, armorSlots = menu.equipment.armorSlots).also { + it.leftSided = false + it.dock = Dock.RIGHT + it.dockResize = DockResizeMode.NONE + } + + return frame + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/SpritePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/SpritePanel.kt new file mode 100644 index 000000000..c84b5072c --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/SpritePanel.kt @@ -0,0 +1,22 @@ +package ru.dbotthepony.mc.otm.client.screen.panels.util + +import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite +import ru.dbotthepony.mc.otm.client.render.UVWindingOrder +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel + +class SpritePanel( + screen: S, + parent: EditablePanel<*>? = null, + val sprite: AbstractMatterySprite, + x: Float = 0f, + y: Float = 0f, + width: Float = sprite.width, + height: Float = sprite.height, + val winding: UVWindingOrder = sprite.winding +) : EditablePanel(screen, parent, x, y, width, height) { + override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + sprite.render(stack, 0f, 0f, width, height, winding) + } +} 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 new file mode 100644 index 000000000..c6147db1e --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/FluidGaugePanel.kt @@ -0,0 +1,106 @@ +package ru.dbotthepony.mc.otm.client.screen.widget + +import com.mojang.blaze3d.systems.RenderSystem +import com.mojang.blaze3d.vertex.DefaultVertexFormat +import com.mojang.blaze3d.vertex.PoseStack +import com.mojang.blaze3d.vertex.VertexFormat +import net.minecraft.client.gui.screens.Screen +import net.minecraft.client.renderer.GameRenderer +import net.minecraft.network.chat.Component +import net.minecraft.resources.ResourceLocation +import net.minecraft.world.inventory.InventoryMenu +import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions +import org.lwjgl.opengl.GL11 +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.client.ShiftPressedCond +import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.client.render.MatterySprite +import ru.dbotthepony.mc.otm.client.render.tesselator +import ru.dbotthepony.mc.otm.client.render.vertex +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.core.TextComponent +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.isNotEmpty +import ru.dbotthepony.mc.otm.core.math.RGBAColor +import ru.dbotthepony.mc.otm.core.math.linearInterpolation +import ru.dbotthepony.mc.otm.core.util.formatFluidLevel +import ru.dbotthepony.mc.otm.menu.widget.FluidGaugeWidget + +open class FluidGaugePanel( + screen: S, + parent: EditablePanel<*>? = null, + val widget: FluidGaugeWidget, + x: Float = 0f, + y: Float = 0f +) : EditablePanel(screen, parent, x, y, width = GAUGE.width, height = GAUGE.height) { + init { + scissor = true + } + + protected open fun makeTooltip(): MutableList { + return mutableListOf( + if (widget.fluid.isEmpty) TranslatableComponent("otm.gui.empty") else TextComponent(String.format("%s: %.2f%%", widget.fluid.displayName.string, widget.percentage * 100.0)), + formatFluidLevel(if (widget.fluid.isEmpty) 0 else widget.fluid.amount, widget.maxCapacity, formatAsReadable = ShiftPressedCond) + ) + } + + override fun innerRenderTooltips(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + if (isHovered) { + screen.renderComponentTooltip(stack, makeTooltip(), mouseX.toInt(), mouseY.toInt()) + return true + } + + return false + } + + override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + if (widget.percentage > 0.01f && widget.fluid.isNotEmpty) { + val data = IClientFluidTypeExtensions.of(widget.fluid.fluid) + val texture = data.stillTexture!! + val sprite = minecraft.getTextureAtlas(InventoryMenu.BLOCK_ATLAS).apply(texture)!! + val tint = RGBAColor.argb(data.getTintColor(widget.fluid)) + var height = (height * widget.percentage) / 16f + var bottom = this.height + + val matrix = stack.last().pose() + val builder = tesselator.builder + + builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX) + + while (height > 0.01f) { + val thisHeight = height.coerceAtMost(1f) + height -= thisHeight + val actualHeight = thisHeight * 16f + + val interp = linearInterpolation(thisHeight, sprite.v1, sprite.v0) + + builder.vertex(matrix, 0f, bottom, 0f).uv(sprite.u0, sprite.v1).endVertex() + builder.vertex(matrix, width, bottom, 0f).uv(sprite.u1, sprite.v1).endVertex() + builder.vertex(matrix, width, bottom - actualHeight, 0f).uv(sprite.u1, interp).endVertex() + builder.vertex(matrix, 0f, bottom - actualHeight, 0f).uv(sprite.u0, interp).endVertex() + + bottom -= actualHeight + } + + RenderSystem.setShader(GameRenderer::getPositionTexShader) + RenderSystem.enableTexture() + RenderSystem.enableBlend() + RenderSystem.defaultBlendFunc() + RenderSystem.depthFunc(GL11.GL_ALWAYS) + + RenderSystem.setShaderColor(tint.red, tint.green, tint.blue, tint.alpha) + RenderSystem.setShaderTexture(0, sprite.atlasLocation()) + + tesselator.end() + + RenderSystem.setShaderColor(1f, 1f, 1f, 1f) + RenderSystem.depthFunc(GL11.GL_LESS) + } + + GAUGE.render(stack, 0f, 0f, width = width, height = height) + } + + companion object { + val GAUGE = MatterySprite.single(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/fluid_level.png"), 18f, 61f) + } +} 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 64072038c..b6477f102 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 @@ -22,7 +22,7 @@ import kotlin.math.cos import kotlin.math.pow import kotlin.math.sin -open class MatterGaugePanel @JvmOverloads constructor( +open class MatterGaugePanel @JvmOverloads constructor( screen: S, parent: EditablePanel<*>? = null, val widget: LevelGaugeWidget, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PatternGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PatternGaugePanel.kt index 1c7f8d339..1fde122eb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PatternGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PatternGaugePanel.kt @@ -8,7 +8,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget -open class PatternGaugePanel @JvmOverloads constructor( +open class PatternGaugePanel @JvmOverloads constructor( screen: S, parent: EditablePanel<*>? = null, val widget: LevelGaugeWidget, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt index 31ffc38ed..1838bef86 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt @@ -12,7 +12,7 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import kotlin.math.roundToInt -open class ProgressGaugePanel @JvmOverloads constructor( +open class ProgressGaugePanel @JvmOverloads constructor( screen: S, parent: EditablePanel<*>? = null, val widget: ProgressGaugeWidget, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt index 884a5150b..02864211c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt @@ -96,5 +96,6 @@ object ItemsConfig : AbstractConfig("items") { builder.pop() } - val FLUID_CAPSULE_CAPACITY: Int by builder.defineInRange("LIQUID_CAPSULE_CAPACITY", 1000, 1, Int.MAX_VALUE) + val FLUID_CAPSULE_CAPACITY: Int by builder.defineInRange("FLUID_CAPSULE_CAPACITY", 1000, 1, Int.MAX_VALUE) + val FLUID_TANK_CAPACITY: Int by builder.defineInRange("FLUID_TANK_CAPACITY", 32_000, 1, Int.MAX_VALUE) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/FluidHandlerIterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/FluidHandlerIterator.kt index f837c7265..65cfcc2d1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/FluidHandlerIterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/FluidHandlerIterator.kt @@ -6,7 +6,7 @@ import net.minecraftforge.fluids.capability.IFluidHandler class FluidHandlerIterator(private val handler: IFluidHandler, initialPosition: Int = 0) : AbstractIndexBasedIterator(0, initialPosition) { init { - require(initialPosition in 0 .. handler.tanks) { "Invalid initial position: $initialPosition" } + require(initialPosition in 0 until handler.tanks) { "Invalid initial position: $initialPosition" } } override fun remove(location: Int) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/FluidHandlerSpliterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/FluidHandlerSpliterator.kt index 9e8b3b672..89d2c15fa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/FluidHandlerSpliterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/FluidHandlerSpliterator.kt @@ -11,7 +11,8 @@ import java.util.stream.StreamSupport class FluidHandlerSpliterator(private val handler: IFluidHandler, offset: Int = 0, private val maxPos: Int = handler.tanks) : AbstractIndexBasedSpliterator(offset) { init { require(offset in 0 until handler.tanks) { "Invalid offset $offset" } - require(maxPos >= offset && maxPos in 0 until handler.tanks) { "Invalid spliterator configuration: maxPos $maxPos offset $offset max tanks ${handler.tanks}" } + require(offset <= maxPos) { "offset <= maxPos: $offset > $maxPos!" } + require(maxPos >= offset && maxPos in 0 .. handler.tanks) { "Invalid spliterator configuration: maxPos $maxPos offset $offset max tanks ${handler.tanks}" } } override fun get(location: Int): FluidStack { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt index 3dd2450ba..4d62d09c8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt @@ -3,6 +3,8 @@ package ru.dbotthepony.mc.otm.container import net.minecraft.world.item.ItemStack import net.minecraftforge.common.ForgeHooks import net.minecraftforge.common.capabilities.ForgeCapabilities +import ru.dbotthepony.mc.otm.core.ifPresentK +import ru.dbotthepony.mc.otm.core.isNotEmpty interface HandlerFilter { fun canInsert(slot: Int, stack: ItemStack): Boolean { @@ -38,6 +40,38 @@ interface HandlerFilter { } } + object FluidContainers : HandlerFilter { + override fun canInsert(slot: Int, stack: ItemStack): Boolean { + stack.getCapability(ForgeCapabilities.FLUID_HANDLER).ifPresentK { + return it.tanks > 0 + } + + stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK { + return it.tanks > 0 + } + + return false + } + } + + object DrainableFluidContainers : HandlerFilter { + override fun canInsert(slot: Int, stack: ItemStack): Boolean { + stack.getCapability(ForgeCapabilities.FLUID_HANDLER).ifPresentK { + return it.stream().anyMatch { it.isNotEmpty } + } + + stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK { + return it.stream().anyMatch { it.isNotEmpty } + } + + return false + } + + override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { + return !canInsert(slot, stack) + } + } + object OnlyIn : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { return true diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt index 7f445dd50..6b44eee1f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt @@ -250,6 +250,9 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I return getMaxStackSize(slot) } + /** + * @return Leftover [ItemStack] + */ @JvmOverloads fun addItem(stack: ItemStack, range: IntRange, simulate: Boolean = false, onlyIntoExisting: Boolean = false, popTime: Int? = null): ItemStack { if (range.last >= size || range.first < 0) @@ -322,6 +325,25 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I return addItem(stack, 0 until size, simulate, onlyIntoExisting = onlyIntoExisting, popTime = popTime) } + /** + * Unlike [addItem], modifies original [stack] + * + * @return Whenever [stack] was modified + */ + fun consumeItem(stack: ItemStack, simulate: Boolean, onlyIntoExisting: Boolean = false, popTime: Int? = null): Boolean { + val result = addItem(stack, 0 until size, simulate, onlyIntoExisting = onlyIntoExisting, popTime = popTime) + + if (result.count != stack.count) { + if (!simulate) { + stack.count = result.count + } + + return true + } + + return false + } + @JvmOverloads fun fullyAddItem(stack: ItemStack, start: Int = 0, end: Int = size - 1): Boolean { return fullyAddItem(stack, start .. end) 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 181419a23..dfd5c2a12 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -28,6 +28,7 @@ import net.minecraft.world.level.block.state.properties.Property import net.minecraft.world.phys.Vec3 import net.minecraftforge.common.ForgeHooks import net.minecraftforge.common.util.LazyOptional +import net.minecraftforge.fluids.FluidStack import net.minecraftforge.items.IItemHandler import net.minecraftforge.registries.ForgeRegistries import net.minecraftforge.registries.ForgeRegistry @@ -87,6 +88,9 @@ inline fun LazyOptional.ifPresentK(lambda: (T) -> Unit) { val ItemStack.tagNotNull: CompoundTag get() = orCreateTag +val FluidStack.isNotEmpty get() = !isEmpty +val ItemStack.isNotEmpty get() = !isEmpty + inline var Entity.position: Vec3 get() = position() set(value) { setPos(value) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/RGBAColor.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/RGBAColor.kt index 26a611b6b..3b61517be 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/RGBAColor.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/RGBAColor.kt @@ -123,6 +123,14 @@ data class RGBAColor(val red: Float, val green: Float, val blue: Float, val alph val b = (color and 0xFF) / 255f return RGBAColor(r, g, b) } + + fun argb(color: Int): RGBAColor { + val a = (color and -0x1000000 ushr 24) / 255f + val r = (color and 0xFF0000 ushr 16) / 255f + val g = (color and 0xFF00 ushr 8) / 255f + val b = (color and 0xFF) / 255f + return RGBAColor(r, g, b, a) + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt index 4aeb78a21..8dcb64a3b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt @@ -7,6 +7,7 @@ import com.mojang.serialization.DataResult import com.mojang.serialization.DynamicOps import net.minecraft.nbt.NbtAccounter import net.minecraft.world.item.ItemStack +import net.minecraftforge.fluids.FluidStack import ru.dbotthepony.mc.otm.core.immutableMap import ru.dbotthepony.mc.otm.core.math.readDecimal import ru.dbotthepony.mc.otm.core.math.writeDecimal @@ -112,6 +113,7 @@ val LongValueCodec = StreamCodec(DataInputStream::readLong, 8L, DataOutputStream val FloatValueCodec = StreamCodec(DataInputStream::readFloat, 4L, DataOutputStream::writeFloat) { a, b -> a == b } val DoubleValueCodec = StreamCodec(DataInputStream::readDouble, 8L, DataOutputStream::writeDouble) { a, b -> a == b } val ItemStackValueCodec = StreamCodec(DataInputStream::readItem, DataOutputStream::writeItem, ItemStack::copy) { a, b -> a.equals(b, true) } +val FluidStackValueCodec = StreamCodec(DataInputStream::readFluidStack, DataOutputStream::writeFluidStack, FluidStack::copy) { a, b -> a == b && a.amount == b.amount } val ItemValueCodec = StreamCodec(DataInputStream::readItemType, DataOutputStream::writeItemType) { a, b -> a === b } val DecimalValueCodec = StreamCodec(DataInputStream::readDecimal, DataOutputStream::writeDecimal) val BigDecimalValueCodec = StreamCodec(DataInputStream::readBigDecimal, DataOutputStream::writeBigDecimal) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt index 60b8f775d..62e26f071 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt @@ -7,7 +7,6 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.isNegative import ru.dbotthepony.mc.otm.core.math.isZero -import java.math.BigDecimal import java.math.BigInteger import java.util.function.BooleanSupplier import kotlin.math.absoluteValue @@ -61,28 +60,12 @@ fun BigInteger.formatReadableNumber(): String { return String(buffer) } -fun BigDecimal.determineSiPrefix(): SiPrefix? { - if (isZero) return null - val num = this.abs() - - if (num >= BigDecimal.ONE) { - return SiPrefix.MULTIPLIES.lastOrNull { it.decimal <= num } - } else { - return SiPrefix.DECIMALS.lastOrNull { it.decimal >= num } - } -} - -fun BigInteger.determineSiPrefix(): SiPrefix? { - if (isZero) return null - val num = this.abs() - return SiPrefix.MULTIPLIES.lastOrNull { it.integer!! <= num } -} - fun BigInteger.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never): Component { require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } - val prefix = determineSiPrefix() ?: return concat(toString(decimalPlaces), suffix) + val prefix = SiPrefix.determine(this) + if (prefix.isEmpty) return concat(toString(decimalPlaces), suffix) val isNegative = isNegative - val arr = (if (isNegative) -this else this).divideAndRemainder(prefix.integer) + val arr = (if (isNegative) -this else this).divideAndRemainder(prefix.bigInteger) val divided = arr[0].toString() val remainder = arr[1].toString() @@ -116,41 +99,6 @@ fun BigInteger.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, forma return TranslatableComponent(prefix.formatLocaleKey, String(buffer), suffix) } -fun Decimal.determineSiPrefix(): SiPrefix? { - if (isZero) { - return null - } - - val num = this.absoluteValue - - if (num >= Decimal.ONE) { - return SiPrefix.MULTIPLIES.lastOrNull { it.impreciseFraction <= num } - } else { - return SiPrefix.DECIMALS.lastOrNull { it.impreciseFraction >= num } - } -} - -fun Int.determineSiPrefix(): SiPrefix? { - if (this == 0) { - return null - } - - val num = this.absoluteValue - if (num <= 1) return null - return SiPrefix.MULTIPLIES.lastOrNull { it.int != null && it.int <= num } -} - -fun Double.determineSiPrefix(): SiPrefix? { - if (this == 0.0) return null - val num = this.absoluteValue - - if (num >= 1.0) { - return SiPrefix.MULTIPLIES.lastOrNull { it.double <= num } - } else { - return SiPrefix.DECIMALS.lastOrNull { it.double >= num } - } -} - private val never = BooleanSupplier { false } private fun reformat(numbers: String): String { @@ -187,29 +135,46 @@ private fun reformat(numbers: String): String { }) } -fun Int.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never): Component { +fun Long.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never, bias: Int = 0): Component { require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } - if (formatAsReadable.asBoolean) return concat(reformat(toString()), suffix) - val prefix = determineSiPrefix() ?: return concat(toString(), suffix) - return TranslatableComponent(prefix.formatLocaleKey, "%.${decimalPlaces}f".format(this.toFloat() / prefix.int!!.toFloat()), suffix) + if (formatAsReadable.asBoolean) { + if (bias == 0) { + return concat(reformat(toString()), suffix) + } else { + val prefix = SiPrefix.NONE.neighbour(bias) + return TranslatableComponent(prefix.formatLocaleKey, reformat(toString()), suffix) + } + } + + val prefix = SiPrefix.determine(this) + + if (bias == 0) { + return TranslatableComponent(prefix.formatLocaleKey, "%.${decimalPlaces}f".format(this.toDouble() / prefix.long!!.toDouble()), suffix) + } else { + return TranslatableComponent(SiPrefix.determine(this, bias).formatLocaleKey, "%.${decimalPlaces}f".format(this.toDouble() / prefix.long!!.toDouble()), suffix) + } +} + +fun Int.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never, bias: Int = 0): Component { + return toLong().formatSiComponent(suffix, decimalPlaces, formatAsReadable, bias) } fun Double.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never): Component { require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } if (formatAsReadable.asBoolean) return concat(reformat("%.${decimalPlaces}f".format(this)), suffix) - val prefix = determineSiPrefix() ?: return concat("%.${decimalPlaces}f".format(this), suffix) + val prefix = SiPrefix.determine(this) return TranslatableComponent(prefix.formatLocaleKey, "%.${decimalPlaces}f".format(this / prefix.double), suffix) } fun Decimal.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never): Component { require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } if (formatAsReadable.asBoolean) return concat(reformat(toString(decimalPlaces)), suffix) - val prefix = determineSiPrefix() ?: return concat(toString(decimalPlaces), suffix) - return TranslatableComponent(prefix.formatLocaleKey, (this / prefix.impreciseFraction).toString(decimalPlaces), suffix) + val prefix = SiPrefix.determine(this) + return TranslatableComponent(prefix.formatLocaleKey, (this / prefix.decimal).toString(decimalPlaces), suffix) } fun Int.formatPower(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.power.name"), decimalPlaces, formatAsReadable = formatAsReadable) -fun Int.formatFluid(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.fluid.name"), decimalPlaces, formatAsReadable = formatAsReadable) +fun Int.formatFluid(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.fluid.name"), decimalPlaces, formatAsReadable = formatAsReadable, bias = -1) fun Decimal.formatPower(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.power.name"), decimalPlaces, formatAsReadable = formatAsReadable) fun Decimal.formatMatter(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.matter.name"), decimalPlaces, formatAsReadable = formatAsReadable) fun Decimal.formatMatterFull(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = TranslatableComponent("otm.gui.matter.format", formatSiComponent(TranslatableComponent("otm.gui.matter.name"), decimalPlaces, formatAsReadable = formatAsReadable)) 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 05f07044d..ef31ac554 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 @@ -17,6 +17,8 @@ import net.minecraft.network.FriendlyByteBuf import net.minecraft.network.chat.Component import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack +import net.minecraft.world.level.material.Fluid +import net.minecraftforge.fluids.FluidStack import net.minecraftforge.registries.ForgeRegistries import net.minecraftforge.registries.ForgeRegistry import java.io.* @@ -87,6 +89,41 @@ fun InputStream.readItem(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 return itemStack } +fun OutputStream.writeFluidStack(value: FluidStack) { + if (value.isEmpty) { + write(0) + } else { + write(1) + + val id = (ForgeRegistries.FLUIDS as ForgeRegistry).getID(value.fluid) + writeVarIntLE(id) + writeInt(value.amount) + + if (value.hasTag()) { + write(1) + writeNbt(value.tag!!) + } else { + write(0) + } + } +} + +fun InputStream.readFluidStack(sizeLimit: NbtAccounter = NbtAccounter(1L shl 14 /* 16 KiB */)): FluidStack { + if (read() == 0) { + return FluidStack.EMPTY + } else { + val id = readVarIntLE() + val fluid = (ForgeRegistries.FLUIDS as ForgeRegistry).getValue(id) ?: return FluidStack.EMPTY + val amount = readInt() + + if (read() > 0) { + return FluidStack(fluid, amount, readNbt(sizeLimit)) + } else { + return FluidStack(fluid, amount) + } + } +} + fun OutputStream.writeBigDecimal(value: BigDecimal) { writeInt(value.scale()) val bytes = value.unscaledValue().toByteArray() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/SiPrefix.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/SiPrefix.kt index 7c227a279..c044c136f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/SiPrefix.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/SiPrefix.kt @@ -2,43 +2,53 @@ package ru.dbotthepony.mc.otm.core.util import com.google.common.collect.ImmutableList import ru.dbotthepony.mc.otm.core.math.Decimal -import java.math.BigDecimal +import ru.dbotthepony.mc.otm.core.math.isZero import java.math.BigInteger +import kotlin.math.absoluteValue -enum class SiPrefix( - val power: Int, - fractional: Boolean, - val symbol: Char, -) { - // multiplies - KILO (3, false, 'k'), - MEGA (6, false, 'M'), - GIGA (9, false, 'G'), - TERA (12, false, 'T'), - PETA (15, false, 'P'), - EXA (18, false, 'E'), - ZETTA(21, false, 'Z'), - YOTTA(24, false, 'Y'), +enum class SiPrefix(val power: Int, val symbol: String) { + YOCTO(-8, "y"), + ZEPTO(-7, "z"), + ATTO (-6, "a"), + FEMTO(-5, "f"), + PICO (-4, "p"), + NANO (-3, "n"), + MICRO(-2, "μ"), + MILLI(-1, "m"), - // decimals - // DECI (1, true, 'd'), - // CENTI(2, true, 'c'), - MILLI(3, true, 'm'), - MICRO(6, true, 'μ'), - NANO (9, true, 'n'), - PICO (12, true, 'p'), - FEMTO(15, true, 'f'), - ATTO (18, true, 'a'), - ZEPTO(21, true, 'z'), - YOCTO(24, true, 'y'); + NONE(0, "") { + override val isEmpty: Boolean + get() = true + }, + + KILO (1, "k"), + MEGA (2, "M"), + GIGA (3, "G"), + TERA (4, "T"), + PETA (5, "P"), + EXA (6, "E"), + ZETTA(7, "Z"), + YOTTA(8, "Y"); + + open val isEmpty: Boolean get() = false val formatLocaleKey = "otm.suffix.${name.lowercase()}".intern() val rawLocaleKey = "otm.suffix_raw.${name.lowercase()}".intern() - val string = if (fractional) "0." + "0".repeat(power - 1) + "1" else "1" + "0".repeat(power) + val string: String + + init { + if (power == 0) { + string = "1" + } else if (power < 0) { + string = "0." + "0".repeat(power.absoluteValue * 3 - 1) + "1" + } else { + string = "1" + "0".repeat(power.absoluteValue * 3) + } + } fun paddedIndex(input: String, index: Int): Char { - val finalIndex = input.length - power + index + val finalIndex = input.length - power.absoluteValue * 3 + index if (finalIndex >= 0) { return input[finalIndex] @@ -47,17 +57,35 @@ enum class SiPrefix( return '0' } - val decimal = BigDecimal(string) - val impreciseFraction = Decimal(string) - val integer = if (!fractional) BigInteger(string) else null + val decimal = Decimal(string) + val bigInteger = if (power >= 0) BigInteger(string) else null - val long = if (!fractional) string.toLongOrNull() else null - val int = if (!fractional) string.toIntOrNull() else null + val long = if (power >= 0) string.toLongOrNull() else null val double = string.toDouble() + fun neighbour(bias: Int): SiPrefix { + if (bias == 0) { + return this + } else { + val new = ordinal + bias + + if (new < 0) { + return YOCTO + } else if (new >= VALUES.size) { + return YOTTA + } else { + return VALUES[new] + } + } + } + companion object { @JvmField - val MULTIPLIES: List = ImmutableList.builder() + val VALUES: ImmutableList = ImmutableList.copyOf(values()) + + @JvmField + val MULTIPLIES: ImmutableList = ImmutableList.builder() + .add(NONE) .add(KILO) .add(MEGA) .add(GIGA) @@ -69,9 +97,8 @@ enum class SiPrefix( .build() @JvmField - val DECIMALS: List = ImmutableList.builder() - //.add(DECI) - //.add(CENTI) + val DECIMALS: ImmutableList = ImmutableList.builder() + .add(NONE) .add(MILLI) .add(MICRO) .add(NANO) @@ -82,13 +109,46 @@ enum class SiPrefix( .add(YOCTO) .build() - @JvmField - val DECIMALS_IMPRECISE: List = ImmutableList.builder() - //.add(DECI) - //.add(CENTI) - .add(MILLI) - .add(MICRO) - .build() + fun determine(value: Int, bias: Int = 0): SiPrefix { + return determine(value.toLong(), bias) + } + + fun determine(value: Long, bias: Int = 0): SiPrefix { + val num = value.absoluteValue + if (num <= 1L) return NONE + return MULTIPLIES.last { it.long != null && it.long <= num }.neighbour(bias) + } + + fun determine(value: Decimal, bias: Int = 0): SiPrefix { + if (value.isZero) { + return NONE + } + + val num = value.absoluteValue + + if (num >= Decimal.ONE) { + return (MULTIPLIES.lastOrNull { it.decimal <= num } ?: NONE).neighbour(bias) + } else { + return (DECIMALS.lastOrNull { it.decimal >= num } ?: NONE).neighbour(bias) + } + } + + fun determine(value: Double, bias: Int = 0): SiPrefix { + if (value == 0.0) return NONE + val num = value.absoluteValue + + if (num >= 1.0) { + return (MULTIPLIES.lastOrNull { it.double <= num } ?: NONE).neighbour(bias) + } else { + return (DECIMALS.lastOrNull { it.double >= num } ?: NONE).neighbour(bias) + } + } + + fun determine(value: BigInteger, bias: Int = 0): SiPrefix { + if (value.isZero) return NONE + val num = value.abs() + return (MULTIPLIES.lastOrNull { it.bigInteger!! <= num } ?: NONE).neighbour(bias) + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt index 8b84bc86e..d607e1ec4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt @@ -7,6 +7,7 @@ import com.google.gson.JsonObject import com.google.gson.JsonPrimitive import com.google.gson.JsonSerializationContext import net.minecraft.nbt.CompoundTag +import net.minecraft.world.item.BlockItem import net.minecraft.world.item.ItemStack import net.minecraft.world.level.storage.loot.LootContext import net.minecraft.world.level.storage.loot.Serializer @@ -31,7 +32,7 @@ class CopyTileNbtFunction(filter: Stream = Stream.empty()) : LootIte override fun apply(t: ItemStack, u: LootContext): ItemStack { val blockEntity = u.getParamOrNull(LootContextParams.BLOCK_ENTITY) ?: return t - val result = t.tagNotNull["BlockEntityTag"] as? CompoundTag + val result = t.tagNotNull[BlockItem.BLOCK_ENTITY_TAG] as? CompoundTag val data = blockEntity.saveWithoutMetadata() @@ -40,7 +41,7 @@ class CopyTileNbtFunction(filter: Stream = Stream.empty()) : LootIte } if (result == null) { - t.tagNotNull["BlockEntityTag"] = data + t.tagNotNull[BlockItem.BLOCK_ENTITY_TAG] = data } else { for (k in data.allKeys) { result[k] = data[k]!! 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 52fc46eab..755654e6e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt @@ -26,7 +26,7 @@ import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.capabilities.ICapabilityProvider import net.minecraftforge.fluids.FluidStack import net.minecraftforge.fluids.capability.IFluidHandler -import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack +import ru.dbotthepony.mc.otm.capability.fluid.ItemMatteryFluidHandler import ru.dbotthepony.mc.otm.capability.fluidLevel import ru.dbotthepony.mc.otm.capability.moveFluid import ru.dbotthepony.mc.otm.container.get @@ -36,30 +36,9 @@ import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.immutableMap import ru.dbotthepony.mc.otm.core.orNull +import java.util.function.IntSupplier -class FluidCapsuleItem(val capacity: () -> Int) : Item(Properties().stacksTo(64)) { - private inner class Cap(itemStack: ItemStack) : FluidHandlerItemStack(itemStack, capacity.invoke()) { - override fun fill(resource: FluidStack, doFill: IFluidHandler.FluidAction): Int { - this.capacity = this@FluidCapsuleItem.capacity.invoke() - return super.fill(resource, doFill) - } - - override fun getTankCapacity(tank: Int): Int { - this.capacity = this@FluidCapsuleItem.capacity.invoke() - return super.getTankCapacity(tank) - } - - override fun drain(resource: FluidStack?, action: IFluidHandler.FluidAction?): FluidStack { - this.capacity = this@FluidCapsuleItem.capacity.invoke() - return super.drain(resource, action) - } - - override fun drain(maxDrain: Int, action: IFluidHandler.FluidAction?): FluidStack { - this.capacity = this@FluidCapsuleItem.capacity.invoke() - return super.drain(maxDrain, action) - } - } - +class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(64)) { // TODO: Так как использование предмета заблокировано за player.abilities.canBuild // капсулу нельзя использовать в режиме приключения // почему же можно использовать вёдра на котлах? @@ -89,12 +68,12 @@ class FluidCapsuleItem(val capacity: () -> Int) : Item(Properties().stacksTo(64) super.appendHoverText(pStack, pLevel, pTooltipComponents, pIsAdvanced) pStack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK { - fluidLevel(it, pTooltipComponents) + it.fluidLevel(pTooltipComponents) } } override fun initCapabilities(stack: ItemStack, nbt: CompoundTag?): ICapabilityProvider { - return Cap(stack) + return ItemMatteryFluidHandler(stack, capacity) } interface Interaction { @@ -206,7 +185,7 @@ class FluidCapsuleItem(val capacity: () -> Int) : Item(Properties().stacksTo(64) if (fluid.isEmpty || player.isCrouching) { // заполняем из блока - val moveResult = moveFluid(source = blockCap, destination = itemCap, simulate = player.level.isClientSide) + val moveResult = moveFluid(source = blockCap, destination = itemCap, actuallyDrain = !player.level.isClientSide, actuallyFill = !player.level.isClientSide) if (!moveResult.isEmpty) { val sound = moveResult.fluid.fluidType.getSound(moveResult, SoundActions.BUCKET_FILL) @@ -228,7 +207,7 @@ class FluidCapsuleItem(val capacity: () -> Int) : Item(Properties().stacksTo(64) return InteractionResult.FAIL } } else { - val moveResult = moveFluid(source = itemCap, destination = blockCap, simulate = player.level.isClientSide) + val moveResult = moveFluid(source = itemCap, destination = blockCap, actuallyDrain = !player.level.isClientSide, actuallyFill = !player.level.isClientSide) if (!moveResult.isEmpty) { val sound = moveResult.fluid.fluidType.getSound(moveResult, SoundActions.BUCKET_EMPTY) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidTankItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidTankItem.kt new file mode 100644 index 000000000..582c14b2a --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidTankItem.kt @@ -0,0 +1,57 @@ +package ru.dbotthepony.mc.otm.item + +import net.minecraft.nbt.CompoundTag +import net.minecraft.network.chat.Component +import net.minecraft.world.InteractionResult +import net.minecraft.world.item.BlockItem +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.TooltipFlag +import net.minecraft.world.item.context.UseOnContext +import net.minecraft.world.level.Level +import net.minecraftforge.common.capabilities.ForgeCapabilities +import net.minecraftforge.common.capabilities.ICapabilityProvider +import ru.dbotthepony.mc.otm.block.decorative.FluidTankBlock +import ru.dbotthepony.mc.otm.block.entity.decorative.FluidTankBlockEntity +import ru.dbotthepony.mc.otm.capability.fluid.BlockMatteryFluidHandler +import ru.dbotthepony.mc.otm.capability.fluidLevel +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.ifPresentK +import java.util.function.IntSupplier + +class FluidTankItem(block: FluidTankBlock, properties: Properties, val capacity: IntSupplier) : BlockItem(block, properties) { + override fun initCapabilities(stack: ItemStack, nbt: CompoundTag?): ICapabilityProvider { + return BlockMatteryFluidHandler.Item(stack, capacity, FluidTankBlockEntity.FLUID_KEY) + } + + override fun onItemUseFirst(stack: ItemStack, pContext: UseOnContext): InteractionResult { + if (pContext.player?.isCrouching == true) + return InteractionResult.PASS + + val context = FluidCapsuleItem.Context(pContext.clickedPos, pContext.level.getBlockState(pContext.clickedPos), pContext.clickedFace) + + if (FluidCapsuleItem.canInteract(pContext.itemInHand, pContext.player ?: return InteractionResult.FAIL, context)) + return FluidCapsuleItem.interact(pContext.itemInHand, pContext.player!!, context) + + return super.onItemUseFirst(stack, pContext) + } + + override fun getName(pStack: ItemStack): Component { + pStack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK { + it.getFluidInTank(0).also { + if (!it.isEmpty) { + return TranslatableComponent("$descriptionId.named", it.displayName) + } + } + } + + return super.getName(pStack) + } + + override fun appendHoverText(pStack: ItemStack, pLevel: Level?, pTooltip: MutableList, pFlag: TooltipFlag) { + super.appendHoverText(pStack, pLevel, pTooltip, pFlag) + + pStack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK { + it.fluidLevel(pTooltip) + } + } +} 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 new file mode 100644 index 000000000..db985d43c --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/FluidTankMenu.kt @@ -0,0 +1,59 @@ +package ru.dbotthepony.mc.otm.menu.decorative + +import net.minecraft.world.SimpleContainer +import net.minecraft.world.entity.player.Inventory +import net.minecraft.world.item.ItemStack +import net.minecraftforge.common.capabilities.ForgeCapabilities +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.capability.isNotFull +import ru.dbotthepony.mc.otm.menu.MachineOutputSlot +import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput +import ru.dbotthepony.mc.otm.menu.widget.FluidGaugeWidget +import ru.dbotthepony.mc.otm.registry.MMenus + +class FluidTankMenu(containerId: Int, inventory: Inventory, tile: FluidTankBlockEntity? = null) : MatteryMenu(MMenus.FLUID_TANK, containerId, inventory, tile) { + val fluid = FluidGaugeWidget(mSynchronizer, tile?.fluid) + val equipment = makeEquipmentSlots(true) + val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) + val redstoneConfig = EnumInputWithFeedback(this) + + val drainInput = object : MatterySlot(tile?.drainInput ?: SimpleContainer(1), 0) { + override fun mayPlace(itemStack: ItemStack): Boolean { + return super.mayPlace(itemStack) && itemStack.getCapability(ForgeCapabilities.FLUID_HANDLER) + .map { it.isNotEmpty } + .orElse(itemStack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM) + .map { it.isNotEmpty } + .orElse(false)) + } + } + + val fillInput = object : MatterySlot(tile?.fillInput ?: SimpleContainer(1), 0) { + override fun mayPlace(itemStack: ItemStack): Boolean { + return super.mayPlace(itemStack) && itemStack.getCapability(ForgeCapabilities.FLUID_HANDLER) + .map { it.fill(fluid.fluid, IFluidHandler.FluidAction.SIMULATE) > 0 } + .orElse(itemStack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM) + .map { it.fill(fluid.fluid, IFluidHandler.FluidAction.SIMULATE) > 0 } + .orElse(false)) + } + } + + val output = MachineOutputSlot(tile?.output ?: SimpleContainer(1), 0) + + init { + // сначала слот на заполнение из бака + addStorageSlot(fillInput) + addStorageSlot(drainInput) + addStorageSlot(output) + addInventorySlots() + + if (tile != null) { + redstoneConfig.with(tile.redstoneControl::redstoneSetting) + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/FluidGaugeWidget.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/FluidGaugeWidget.kt new file mode 100644 index 000000000..ca7d3b7cd --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/FluidGaugeWidget.kt @@ -0,0 +1,46 @@ +package ru.dbotthepony.mc.otm.menu.widget + +import net.minecraftforge.fluids.FluidStack +import net.minecraftforge.fluids.capability.IFluidHandler +import ru.dbotthepony.mc.otm.container.get +import ru.dbotthepony.mc.otm.core.util.FluidStackValueCodec +import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer +import java.util.function.IntSupplier +import java.util.function.Supplier + +class FluidGaugeWidget(synchronizer: FieldSynchronizer) { + constructor(menu: MatteryMenu) : this(menu.mSynchronizer) + + var maxCapacitySupplier = IntSupplier { 0 } + var fluidSupplier = Supplier { FluidStack.EMPTY!! } + + val maxCapacity by synchronizer.ComputedIntField({ maxCapacitySupplier.asInt }) + val fluid by synchronizer.ComputedField({ fluidSupplier.get() }, FluidStackValueCodec) + + val percentage: Float get() { + if (maxCapacity <= 0 || fluid.isEmpty) { + return 0f + } + + return (fluid.amount.toFloat() / maxCapacity.toFloat()).coerceIn(0f, 1f) + } + + constructor(synchronizer: FieldSynchronizer, fluid: IFluidHandler?, tank: Int = 0) : this(synchronizer) { + if (fluid != null) { + with(fluid, tank) + } + } + + constructor(menu: MatteryMenu, fluid: IFluidHandler?, tank: Int = 0) : this(menu) { + if (fluid != null) { + with(fluid, tank) + } + } + + fun with(fluid: IFluidHandler, tank: Int = 0): FluidGaugeWidget { + maxCapacitySupplier = IntSupplier { fluid.getTankCapacity(tank) } + fluidSupplier = Supplier { fluid[tank] } + return this + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/LevelGaugeWidget.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/LevelGaugeWidget.kt index 5b06f9c59..eddd1a7ba 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/LevelGaugeWidget.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/LevelGaugeWidget.kt @@ -6,19 +6,22 @@ import ru.dbotthepony.mc.otm.capability.matter.IPatternStorage import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.util.DecimalValueCodec import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer @Suppress("unused") -class LevelGaugeWidget(menu: MatteryMenu) { +class LevelGaugeWidget(synchronizer: FieldSynchronizer) { + constructor(menu: MatteryMenu) : this(menu.mSynchronizer) + var levelProvider = { Decimal.ONE } var maxLevelProvider = { Decimal.ONE } - val level by menu.mSynchronizer.ComputedField(getter = { levelProvider.invoke() }, codec = DecimalValueCodec) - val maxLevel by menu.mSynchronizer.ComputedField(getter = { maxLevelProvider.invoke() }, codec = DecimalValueCodec) + val level by synchronizer.ComputedField(getter = { levelProvider.invoke() }, codec = DecimalValueCodec) + val maxLevel by synchronizer.ComputedField(getter = { maxLevelProvider.invoke() }, codec = DecimalValueCodec) constructor( menu: MatteryMenu, power: IMatteryEnergyStorage? - ) : this(menu) { + ) : this(menu.mSynchronizer) { if (power != null) { with(power) } @@ -27,7 +30,7 @@ class LevelGaugeWidget(menu: MatteryMenu) { constructor( menu: MatteryMenu, matter: IMatterStorage? - ) : this(menu) { + ) : this(menu.mSynchronizer) { if (matter != null) { with(matter) } @@ -36,7 +39,7 @@ class LevelGaugeWidget(menu: MatteryMenu) { constructor( menu: MatteryMenu, patterns: IPatternStorage? - ) : this(menu) { + ) : this(menu.mSynchronizer) { if (patterns != null) { with(patterns) } @@ -46,7 +49,43 @@ class LevelGaugeWidget(menu: MatteryMenu) { menu: MatteryMenu, level: () -> Decimal, maxLevel: () -> Decimal, - ) : this(menu) { + ) : this(menu.mSynchronizer) { + this.levelProvider = level + this.maxLevelProvider = maxLevel + } + + constructor( + synchronizer: FieldSynchronizer, + power: IMatteryEnergyStorage? + ) : this(synchronizer) { + if (power != null) { + with(power) + } + } + + constructor( + synchronizer: FieldSynchronizer, + matter: IMatterStorage? + ) : this(synchronizer) { + if (matter != null) { + with(matter) + } + } + + constructor( + synchronizer: FieldSynchronizer, + patterns: IPatternStorage? + ) : this(synchronizer) { + if (patterns != null) { + with(patterns) + } + } + + constructor( + synchronizer: FieldSynchronizer, + level: () -> Decimal, + maxLevel: () -> Decimal, + ) : this(synchronizer) { this.levelProvider = level this.maxLevelProvider = maxLevel } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt index 7ceb4aa32..d182f7971 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt @@ -3,15 +3,18 @@ package ru.dbotthepony.mc.otm.menu.widget import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.core.FloatSupplier import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer import java.util.function.BooleanSupplier @Suppress("unused") -class ProgressGaugeWidget(menu: MatteryMenu) { +class ProgressGaugeWidget(synchronizer: FieldSynchronizer) { + constructor(menu: MatteryMenu) : this(menu.mSynchronizer) + var progressSupplier: FloatSupplier = FloatSupplier { 0f } var stuckSupplier: BooleanSupplier = BooleanSupplier { false } - val percentage by menu.mSynchronizer.ComputedFloatField(getter = { progressSupplier.getAsFloat() }) - val isStuck by menu.mSynchronizer.ComputedBooleanField(getter = { stuckSupplier.asBoolean }) + val percentage by synchronizer.ComputedFloatField(getter = { progressSupplier.getAsFloat() }) + val isStuck by synchronizer.ComputedBooleanField(getter = { stuckSupplier.asBoolean }) constructor( menu: MatteryMenu, @@ -29,6 +32,22 @@ class ProgressGaugeWidget(menu: MatteryMenu) { } } + constructor( + synchronizer: FieldSynchronizer, + progress: FloatSupplier + ) : this(synchronizer) { + this.progressSupplier = progress + } + + constructor( + synchronizer: FieldSynchronizer, + blockEntity: MatteryWorkerBlockEntity<*>? + ) : this(synchronizer) { + if (blockEntity != null) { + with(blockEntity) + } + } + constructor( menu: MatteryMenu, progress: FloatSupplier, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt index d9ada7784..ea350bfa5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt @@ -104,6 +104,20 @@ private fun CreativeModeTab.Output.mattery(values: Iterable) { } } +private fun CreativeModeTab.Output.fluids(value: Item) { + accept(value) + + for (fluid in ForgeRegistries.FLUIDS.values) { + if (fluid != Fluids.EMPTY && fluid.isSource(fluid.defaultFluidState())) { + accept(ItemStack(value, 1).also { + it.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK { + it.fill(FluidStack(fluid, it.getTankCapacity(0)), IFluidHandler.FluidAction.EXECUTE) + } + }) + } + } +} + internal fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { with(consumer) { accept(MItems.MACHINES) @@ -147,17 +161,8 @@ internal fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { accept(MItems.PATTERN_DRIVE_CREATIVE) accept(MItems.PATTERN_DRIVE_CREATIVE2) - accept(MItems.FLUID_CAPSULE) - - for (fluid in ForgeRegistries.FLUIDS.values) { - if (fluid != Fluids.EMPTY && fluid.isSource(fluid.defaultFluidState())) { - accept(ItemStack(MItems.FLUID_CAPSULE, 1).also { - it.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK { - it.fill(FluidStack(fluid, it.getTankCapacity(0)), IFluidHandler.FluidAction.EXECUTE) - } - }) - } - } + fluids(MItems.FLUID_CAPSULE) + fluids(MItems.FLUID_TANK) base(MItems.CARGO_CRATE_MINECARTS) 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 d0f4c3e08..397b88194 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt @@ -13,6 +13,7 @@ import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity import ru.dbotthepony.mc.otm.block.entity.blackhole.BlockEntityExplosionDebugger import ru.dbotthepony.mc.otm.block.entity.blackhole.BlockEntitySphereDebugger import ru.dbotthepony.mc.otm.block.entity.decorative.CargoCrateBlockEntity +import ru.dbotthepony.mc.otm.block.entity.decorative.FluidTankBlockEntity import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.* import ru.dbotthepony.mc.otm.block.entity.storage.* @@ -58,6 +59,7 @@ object MBlockEntities { val COBBLESTONE_GENERATOR: BlockEntityType by registry.register(MNames.COBBLESTONE_GENERATOR) { BlockEntityType.Builder.of(::CobblerBlockEntity, MBlocks.COBBLESTONE_GENERATOR).build(null) } val ESSENCE_STORAGE: BlockEntityType by registry.register(MNames.ESSENCE_STORAGE) { BlockEntityType.Builder.of(::EssenceStorageBlockEntity, MBlocks.ESSENCE_STORAGE).build(null) } val MATTER_RECONSTRUCTOR: BlockEntityType by registry.register(MNames.MATTER_RECONSTRUCTOR) { BlockEntityType.Builder.of(::MatterReconstructorBlockEntity, MBlocks.MATTER_RECONSTRUCTOR).build(null) } + val FLUID_TANK: BlockEntityType by registry.register(MNames.FLUID_TANK) { BlockEntityType.Builder.of(::FluidTankBlockEntity, MBlocks.FLUID_TANK).build(null) } val STORAGE_BUS: BlockEntityType by registry.register(MNames.STORAGE_BUS) { BlockEntityType.Builder.of(::StorageBusBlockEntity, MBlocks.STORAGE_BUS).build(null) } val STORAGE_IMPORTER: BlockEntityType by registry.register(MNames.STORAGE_IMPORTER) { BlockEntityType.Builder.of(::StorageImporterBlockEntity, MBlocks.STORAGE_IMPORTER).build(null) } 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 90de2a4e3..55ecb67b2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -46,6 +46,7 @@ import ru.dbotthepony.mc.otm.block.tech.PhantomAttractorBlock import ru.dbotthepony.mc.otm.block.tech.PlatePressBlock import ru.dbotthepony.mc.otm.block.StorageCableBlock import ru.dbotthepony.mc.otm.block.decorative.EngineBlock +import ru.dbotthepony.mc.otm.block.decorative.FluidTankBlock import ru.dbotthepony.mc.otm.block.decorative.HoloSignBlock import ru.dbotthepony.mc.otm.block.matter.MatterReconstructorBlock import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock @@ -112,6 +113,7 @@ object MBlocks { val GRAVITATION_STABILIZER_LENS: Block by registry.register(MNames.GRAVITATION_STABILIZER_LENS) { BlockGravitationStabilizerLens() } val PHANTOM_ATTRACTOR: Block by registry.register(MNames.PHANTOM_ATTRACTOR) { PhantomAttractorBlock() } + val FLUID_TANK: FluidTankBlock by registry.register(MNames.FLUID_TANK) { FluidTankBlock() } val TRITANIUM_ORE: Block by registry.register(MNames.TRITANIUM_ORE) { DropExperienceBlock( BlockBehaviour.Properties.of(Material.STONE) 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 19ab301f6..472f4078e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -156,6 +156,7 @@ object MItems { val ESSENCE_DRIVE: EssenceCapsuleItem by registry.register("essence_drive") { EssenceCapsuleItem() } val FLUID_CAPSULE: FluidCapsuleItem by registry.register("fluid_capsule") { FluidCapsuleItem(ItemsConfig::FLUID_CAPSULE_CAPACITY) } + val FLUID_TANK: FluidTankItem by registry.register(MNames.FLUID_TANK) { FluidTankItem(MBlocks.FLUID_TANK, Item.Properties().stacksTo(1), ItemsConfig::FLUID_TANK_CAPACITY) } val TRITANIUM_COMPONENT: ForgeTier = ForgeTier( Tiers.IRON.level, 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 3d5791c14..a5ab542cd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt @@ -8,6 +8,7 @@ import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.client.screen.decorative.CargoCrateScreen +import ru.dbotthepony.mc.otm.client.screen.decorative.FluidTankScreen import ru.dbotthepony.mc.otm.client.screen.decorative.HoloSignScreen import ru.dbotthepony.mc.otm.client.screen.decorative.MinecartCargoCrateScreen import ru.dbotthepony.mc.otm.client.screen.matter.MatterReconstructorScreen @@ -35,6 +36,7 @@ import ru.dbotthepony.mc.otm.client.screen.tech.EnergyServoScreen import ru.dbotthepony.mc.otm.client.screen.tech.EssenceStorageScreen import ru.dbotthepony.mc.otm.client.screen.tech.PlatePressScreen import ru.dbotthepony.mc.otm.menu.decorative.CargoCrateMenu +import ru.dbotthepony.mc.otm.menu.decorative.FluidTankMenu import ru.dbotthepony.mc.otm.menu.decorative.HoloSignMenu import ru.dbotthepony.mc.otm.menu.decorative.MinecartCargoCrateMenu import ru.dbotthepony.mc.otm.menu.matter.MatterReconstructorMenu @@ -88,6 +90,7 @@ object MMenus { val COBBLESTONE_GENERATOR: MenuType by registry.register(MNames.COBBLESTONE_GENERATOR) { MenuType(::CobblerMenu) } val ESSENCE_STORAGE: MenuType by registry.register(MNames.ESSENCE_STORAGE) { MenuType(::EssenceStorageMenu) } val ITEM_REPAIER: MenuType by registry.register(MNames.MATTER_RECONSTRUCTOR) { MenuType(::MatterReconstructorMenu) } + val FLUID_TANK: MenuType by registry.register(MNames.FLUID_TANK) { MenuType(::FluidTankMenu) } val STORAGE_BUS: MenuType<*> by registry.register(MNames.STORAGE_BUS) { MenuType(::StorageBusMenu) } val STORAGE_EXPORTER: MenuType<*> by registry.register(MNames.STORAGE_EXPORTER) { MenuType(::StorageExporterMenu) } @@ -129,6 +132,7 @@ object MMenus { MenuScreens.register(COBBLESTONE_GENERATOR, ::CobblerScreen) MenuScreens.register(ESSENCE_STORAGE, ::EssenceStorageScreen) MenuScreens.register(ITEM_REPAIER, ::MatterReconstructorScreen) + MenuScreens.register(FLUID_TANK, ::FluidTankScreen) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index 0347f06dd..e56fb83b6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -11,6 +11,7 @@ object MNames { const val METAL_BEAM = "metal_beam" const val ENGINE = "engine" const val HOLO_SIGN = "holo_sign" + const val FLUID_TANK = "fluid_tank" // blocks const val ANDROID_STATION = "android_station" diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/fluid_level.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/fluid_level.png new file mode 100644 index 0000000000000000000000000000000000000000..509d6d5f43181eeac9a4a65963f6107537097815 GIT binary patch literal 617 zcmV-v0+#)WP)EX>4Tx04R}tkv&MmKpe$iQ>7x64t9_tlA$`;MMVS`sbUc*FAiEy^HZI?{j~S0i|Fvz$X&VG2O6;H;AV< zEuHf|ahR1Qh4`F!+@K2*KXP4m`HgeQVS#6cjcj_JI7}>-x>)XFRyI`PDdMQ2YLqYJ zTvj-5aaOB!*1jiyVX&aBWVlXq7zr#Pi4;W0sH1`^EW~KlNHLM7{kVre;`meKlF3y8 zBgX=2P$4;f@IUz7ty!F$aFc>@p!dbLKSqJTF3@V&_V=-Ew@v{6GjOGK{Iw=9^GSN6 zqeYK^&^B;!-O=Pd;Bp5TdeS9BawI=Zp;!do&*+=-z~C*=zvlMV-pAmKj!>+bE}GwuF<00&`m;!q_}yZ`_I24YJ`L;(K){{a7>y{D4^000SaNLh0L z01m?d01m?e$8V@)00007bV*G`2j>I@3JNK(0U}rc003o4L_t(o!|j+c3V<*W1a~FR zw)Ed?Ay)_%!d;;-sZtFSGM6Hj6b-B;NlDy+*v{$#YQJ?rNnEGF=#NHzDEoNH*>83i z_(NrDXlPSIOGlK=n~f1=Q#MAF&8=ZX*>ptNBYz_&?D5cI;&+ET00000NkvXXu0mjf D_eu@r literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/fluid_level.xcf b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/fluid_level.xcf new file mode 100644 index 0000000000000000000000000000000000000000..46606d3f70653e6e8a4356e506c410698f995101 GIT binary patch literal 2603 zcmeHJJ!{)Q7(U6O{%DO`JMC2HId#Ap1XlMF2!Sm91=(!JRs{aSa*930q%9P>bn4or zV<4-SBx|My&?- zyDe{jGgEH5^=_-%=jBk?eYaNSmGE&k;jYbbJ3M^IJ@k9ky4P{JQ-L;`(WGJ@cDw=i zI`xBwPj7UaO}{bVVZ6p8IvY%D)|#;!DT%L|QBf+~9zZ!}r{AZ?({V7FehVfP@C=}0 z37|-PYm6QR1;|b>r6q@8>l%Nn@r=f~#-D5ag~qcQ&wskH2#L<5UfNT zF|^kA8dn>hfK6-WCrwdBpmEX6UL+I4NQS+NA^%V5|DgOw)|e^mFhdk23d|JgFXo;8 zP7n2wLiNv3A~kc5OPgFHUgY2?ei zn-c?*brsoDzm-4Fa>7_43NhwVF-k6SeN?iijF(%1IQynzlw9y0iyS^Qt3zRhbKRF0 sZmKz_JF0P3BtqYO87C%>+xXv;6X(r1F-sqP1$&ei_^#4#Nq9}&0;>%wMF0Q* literal 0 HcmV?d00001 From 7ce73bdb520f6316cfce658304783d3a603d0ac2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 6 Apr 2023 15:13:32 +0700 Subject: [PATCH 0469/1199] Make fluid tanks drop item contents when broken --- .../mc/otm/block/entity/decorative/FluidTankBlockEntity.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 1012264a9..ea6cdad3f 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 @@ -32,9 +32,9 @@ class FluidTankBlockEntity(blockPos: BlockPos, blockState: BlockState) : Mattery var synchronizedFluid by synchronizer.Field(FluidStack.EMPTY!!, FluidStackValueCodec) private set - val fillInput = MatteryContainer(::setChangedLight, 1) - val drainInput = MatteryContainer(::setChangedLight, 1) - val output = MatteryContainer(::setChangedLight, 1) + val fillInput = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) + val drainInput = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) + val output = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) val itemConfig = ConfigurableItemHandler( input = CombinedItemHandler( From 509630ca35a56118bae522a9a035237cfcc81244 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 6 Apr 2023 15:16:39 +0700 Subject: [PATCH 0470/1199] More lenient "fill" checks --- .../entity/decorative/FluidTankBlockEntity.kt | 11 ++++++++++- .../mc/otm/menu/decorative/FluidTankMenu.kt | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) 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 ea6cdad3f..39d62c563 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 @@ -41,8 +41,17 @@ class FluidTankBlockEntity(blockPos: BlockPos, blockState: BlockState) : Mattery drainInput.handler(HandlerFilter.DrainableFluidContainers), fillInput.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { - if (fluid.isEmpty) + if (fluid.isEmpty) { + stack.getCapability(ForgeCapabilities.FLUID_HANDLER).ifPresentK { + if (it.tanks > 0) return true + } + + stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK { + if (it.tanks > 0) return true + } + return false + } stack.getCapability(ForgeCapabilities.FLUID_HANDLER).ifPresentK { if (it.fill(fluid[0], IFluidHandler.FluidAction.SIMULATE) > 0) 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 db985d43c..2b746de00 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 @@ -36,9 +36,19 @@ class FluidTankMenu(containerId: Int, inventory: Inventory, tile: FluidTankBlock val fillInput = object : MatterySlot(tile?.fillInput ?: SimpleContainer(1), 0) { override fun mayPlace(itemStack: ItemStack): Boolean { return super.mayPlace(itemStack) && itemStack.getCapability(ForgeCapabilities.FLUID_HANDLER) - .map { it.fill(fluid.fluid, IFluidHandler.FluidAction.SIMULATE) > 0 } + .map { + if (fluid.fluid.isEmpty) + it.tanks > 0 + else + it.fill(fluid.fluid, IFluidHandler.FluidAction.SIMULATE) > 0 + } .orElse(itemStack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM) - .map { it.fill(fluid.fluid, IFluidHandler.FluidAction.SIMULATE) > 0 } + .map { + if (fluid.fluid.isEmpty) + it.tanks > 0 + else + it.fill(fluid.fluid, IFluidHandler.FluidAction.SIMULATE) > 0 + } .orElse(false)) } } From 0eb9d99e3b17be247cc7f81bf10a552745521970 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Fri, 7 Apr 2023 18:12:02 +0600 Subject: [PATCH 0471/1199] Mesh and Reinforced Tritanium textures --- .../textures/item/component/metal_mesh.png | Bin 0 -> 266 bytes .../item/component/reinforced_tritanium_plate.png | Bin 0 -> 275 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/component/metal_mesh.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/component/reinforced_tritanium_plate.png diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/component/metal_mesh.png b/src/main/resources/assets/overdrive_that_matters/textures/item/component/metal_mesh.png new file mode 100644 index 0000000000000000000000000000000000000000..557cddc74becd0244bd8aae4a6385c3104a98c95 GIT binary patch literal 266 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G|^0G|+7F)=YYIXP`@?Sg`Wz`#JD@Yic|{D2f&NswRge-L2Uyno4lpa^Gy zM`SSr1K%MKW)#)%Y5)r6d%8G=Xat+~ck(hQ@*Mv4ZoiQqL&(BoGvvf~OGnMj;@rLE z>dYzrjDE7>tWMj4G9SMaZ3{bbSjFYMP0GTpq8&{hFFaY&UveZbWGFqq?|_uO_vc*| z?2(>L`&Ruwv2e|5b*Vte^_2H{*Lk()pN90pp=;OXk;vd$@?2>@r@ BS=#^r literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/component/reinforced_tritanium_plate.png b/src/main/resources/assets/overdrive_that_matters/textures/item/component/reinforced_tritanium_plate.png new file mode 100644 index 0000000000000000000000000000000000000000..0733e07da4272fa7910b799b9be6b4bdafc9b921 GIT binary patch literal 275 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}H0G|+78xQ}vyU+N=rsp>GH_loSn_s1^tt}@fCnhEaRB}M>cMOo?Dhcun z{tp8To6hK*2a0kQctjR6F!1dMVMYtqU=^TXhNp{Th(>U1A2-(l1s>e4oku80Vvw(Ioc)I$ztaD0e F0sw|TTipNv literal 0 HcmV?d00001 From cc1b944ebabdbc01706d5bbc0f805ddf453a8151 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Fri, 7 Apr 2023 18:48:14 +0600 Subject: [PATCH 0472/1199] Fluid tank and capsule --- .../models/block/fluid_tank.json | 84 ++++++++++++++++++ .../textures/block/fluid_tank.png | Bin 0 -> 469 bytes .../textures/item/fluid_capsule.png | Bin 0 -> 260 bytes .../item/fluid_capsule_liquid_mask.png | Bin 0 -> 152 bytes 4 files changed, 84 insertions(+) create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/fluid_tank.json create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/fluid_tank.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/fluid_capsule.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/fluid_capsule_liquid_mask.png diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/fluid_tank.json b/src/main/resources/assets/overdrive_that_matters/models/block/fluid_tank.json new file mode 100644 index 000000000..8c062d281 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/fluid_tank.json @@ -0,0 +1,84 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [32, 32], + "textures": { + "0": "overdrive_that_matters:block/fluid_tank", + "particle": "overdrive_that_matters:block/fluid_tank" + }, + "elements": [ + { + "name": "frame", + "from": [0, 0, 0], + "to": [16, 2, 16], + "faces": { + "north": {"uv": [0, 8, 8, 9], "texture": "#0"}, + "east": {"uv": [0, 14, 8, 15], "texture": "#0"}, + "south": {"uv": [0, 8, 8, 9], "texture": "#0"}, + "west": {"uv": [0, 14, 8, 15], "texture": "#0"}, + "up": {"uv": [8, 0, 16, 8], "texture": "#0"}, + "down": {"uv": [0, 0, 8, 8], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [0, 14, 0], + "to": [16, 16, 16], + "faces": { + "north": {"uv": [0, 8, 8, 9], "rotation": 180, "texture": "#0"}, + "east": {"uv": [0, 14, 8, 15], "rotation": 180, "texture": "#0"}, + "south": {"uv": [0, 8, 8, 9], "rotation": 180, "texture": "#0"}, + "west": {"uv": [0, 14, 8, 15], "rotation": 180, "texture": "#0"}, + "up": {"uv": [0, 0, 8, 8], "texture": "#0"}, + "down": {"uv": [8, 0, 16, 8], "texture": "#0"} + } + }, + { + "name": "thingmajigs", + "from": [0.5, 2, 0.5], + "to": [15.5, 3, 15.5], + "faces": { + "north": {"uv": [0, 15, 7, 15.5], "texture": "#0"}, + "east": {"uv": [0, 15, 7, 15.5], "texture": "#0"}, + "south": {"uv": [0, 15, 7, 15.5], "texture": "#0"}, + "west": {"uv": [0, 15, 7, 15.5], "texture": "#0"} + } + }, + { + "name": "thingmajigs", + "from": [0.5, 13, 0.5], + "to": [15.5, 14, 15.5], + "faces": { + "north": {"uv": [0, 15, 7, 15.5], "texture": "#0"}, + "east": {"uv": [0, 15, 7, 15.5], "texture": "#0"}, + "south": {"uv": [0, 15, 7, 15.5], "texture": "#0"}, + "west": {"uv": [0, 15, 7, 15.5], "texture": "#0"} + } + }, + { + "name": "tank", + "from": [0, 3, 0], + "to": [16, 13, 16], + "faces": { + "north": {"uv": [0, 9, 8, 14], "texture": "#0"}, + "east": {"uv": [0, 9, 8, 14], "texture": "#0"}, + "south": {"uv": [0, 9, 8, 14], "texture": "#0"}, + "west": {"uv": [0, 9, 8, 14], "texture": "#0"}, + "up": {"uv": [8, 0, 16, 8], "texture": "#0"}, + "down": {"uv": [8, 0, 16, 8], "texture": "#0"} + } + }, + { + "name": "tank inside", + "from": [0, 13, 0], + "to": [16, 3, 16], + "faces": { + "north": {"uv": [0, 9, 8, 14], "texture": "#0"}, + "east": {"uv": [0, 9, 8, 14], "texture": "#0"}, + "south": {"uv": [0, 9, 8, 14], "texture": "#0"}, + "west": {"uv": [0, 9, 8, 14], "texture": "#0"}, + "up": {"uv": [8, 0, 16, 8], "texture": "#0"}, + "down": {"uv": [8, 0, 16, 8], "texture": "#0"} + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/fluid_tank.png b/src/main/resources/assets/overdrive_that_matters/textures/block/fluid_tank.png new file mode 100644 index 0000000000000000000000000000000000000000..f68041c2f473cba727a529e9746273905963c033 GIT binary patch literal 469 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyjKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCijS1AIbUO-)ThLP8P}6126o)zs9Aii+y%>(eS*a+~`9|NjqEbx-5v79ho4 z666;Q6oCQ;FMq~QKw-`TkH}&M2EM}}%y>M1MGDYTHBT4E5DWjgleqJa7;vyQT4cWd zEx+S4!}H5!TZ8UfTg1;mclNdRT=)CgKk`U=V! zH4H94yc)Fp7btTSSi0IYXfy3EW#9T#(6J$$#k0KN{#+@ernrVx3$C%Q=wgYIxGC{f z?e^u~svEP8N*(#1b}*o_!sGRe%d>ygtv7jYuA9f7yn~-#2pEhEp00i_>zopr0Mp^T AEdT%j literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/fluid_capsule.png b/src/main/resources/assets/overdrive_that_matters/textures/item/fluid_capsule.png new file mode 100644 index 0000000000000000000000000000000000000000..585679972d6be307830babd4230c230b0cfc1baa GIT binary patch literal 260 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}%0G|+7F)^{gz(6%MH5(6qzu5HLrvAoRE3~z>f%1KO7A*o&oFzei!T+Iv zA=tk{2qakG5n0T@z;_UY8Fx&~ehUlFz(Fl$`<0y1MfrI(LiiUsxkMeHJSU%^( zqJzKAvO4@`+;YuWzg$rZfp2)DJsw*Z6a%)s^=g^LK^qKYk^jDfrv_ rIS1DKW1hwD;paEu&5@n6)7G+|Vr116zQVT(Xc2>_tDnm{r-UW|-|k!h literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/fluid_capsule_liquid_mask.png b/src/main/resources/assets/overdrive_that_matters/textures/item/fluid_capsule_liquid_mask.png new file mode 100644 index 0000000000000000000000000000000000000000..fa83ccdb8be01cf79765485e493df96322b49c3b GIT binary patch literal 152 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBufG}g$wN6f;psuHjV~B-+vIJ`h)Bi?>Q%4wj0;JR(uASjv s2~d-HVA?PtZ4tvJ#l;CTnAq4DGRpaXuRE9-2h_;m>FVdQ&MBb@0Af@qVgLXD literal 0 HcmV?d00001 From 56f3395c478182f5303db6e259a7ee6d026d1302 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Fri, 7 Apr 2023 18:50:14 +0600 Subject: [PATCH 0473/1199] Oops --- .../models/block/fluid_tank.json | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/fluid_tank.json b/src/main/resources/assets/overdrive_that_matters/models/block/fluid_tank.json index 8c062d281..49fdcc466 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/fluid_tank.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/fluid_tank.json @@ -80,5 +80,36 @@ "down": {"uv": [8, 0, 16, 8], "texture": "#0"} } } - ] + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 2], + "translation": [0, 2.75, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 225, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "scale": [0.5, 0.5, 0.5] + } + } } \ No newline at end of file From c3568a7fc1423d0c336d05b6a9b214a797fcecaf Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 7 Apr 2023 19:53:15 +0700 Subject: [PATCH 0474/1199] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=D0=B8=D0=BC?= =?UTF-8?q?=20=D0=B3=D0=B8=D0=B3=D0=B0=D0=BF=D1=80=D0=B8=D0=BA=D0=BE=D0=BB?= =?UTF-8?q?=D1=8B=20=D1=81=20IFluidHandler?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/decorative/FluidTankBlockEntity.kt | 56 +++++++------------ .../fluid/AbstractMatteryFluidHandler.kt | 6 +- .../fluid/ItemMatteryFluidHandler.kt | 22 ++++++++ .../mc/otm/container/MatteryContainer.kt | 5 +- .../mc/otm/menu/decorative/FluidTankMenu.kt | 21 +++---- 5 files changed, 58 insertions(+), 52 deletions(-) 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 39d62c563..5b6bd1f3f 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 @@ -29,7 +29,7 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities class FluidTankBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.FLUID_TANK, blockPos, blockState) { val fluid = BlockMatteryFluidHandler(::onChanged, ItemsConfig::FLUID_TANK_CAPACITY) - var synchronizedFluid by synchronizer.Field(FluidStack.EMPTY!!, FluidStackValueCodec) + var synchronizedFluid by synchronizer.Field(FluidStack.EMPTY, FluidStackValueCodec) private set val fillInput = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) @@ -42,25 +42,15 @@ class FluidTankBlockEntity(blockPos: BlockPos, blockState: BlockState) : Mattery fillInput.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { if (fluid.isEmpty) { - stack.getCapability(ForgeCapabilities.FLUID_HANDLER).ifPresentK { - if (it.tanks > 0) return true - } - stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK { - if (it.tanks > 0) return true + return it.tanks > 0 } return false } - stack.getCapability(ForgeCapabilities.FLUID_HANDLER).ifPresentK { - if (it.fill(fluid[0], IFluidHandler.FluidAction.SIMULATE) > 0) - return true - } - stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK { - if (it.fill(fluid[0], IFluidHandler.FluidAction.SIMULATE) > 0) - return true + return it.fill(fluid[0], IFluidHandler.FluidAction.SIMULATE) > 0 } return false @@ -91,8 +81,7 @@ class FluidTankBlockEntity(blockPos: BlockPos, blockState: BlockState) : Mattery val item = drainInput[0] if (item.isNotEmpty) { - val target = if (item.count == 1) item else item.copyWithCount(1) - val cap = target.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).orNull() ?: target.getCapability(ForgeCapabilities.FLUID_HANDLER).orNull() + val cap = (if (item.count == 1) item else item.copyWithCount(1)).getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).orNull() if (cap == null) { if (output.consumeItem(item, simulate = false)) { @@ -107,9 +96,9 @@ class FluidTankBlockEntity(blockPos: BlockPos, blockState: BlockState) : Mattery val moved0 = moveFluid(source = cap, destination = fluid) if (moved0.isNotEmpty) { - drainInput.setChanged(0) + drainInput[0] = cap.container - if (output.consumeItem(item, simulate = false)) { + if (output.consumeItem(drainInput[0], simulate = false)) { drainInput.setChanged(0) } } @@ -117,21 +106,20 @@ class FluidTankBlockEntity(blockPos: BlockPos, blockState: BlockState) : Mattery val moved0 = moveFluid(source = cap, destination = fluid, actuallyFill = false) if (moved0.isNotEmpty) { - if (output.consumeItem(target, simulate = true)) { - val target1 = item.copyWithCount(1) - val cap1 = target1.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).orNull() ?: target1.getCapability(ForgeCapabilities.FLUID_HANDLER).orNull() ?: throw ConcurrentModificationException() + if (output.consumeItem(cap.container, simulate = true)) { + val cap1 = item.copyWithCount(1).getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).orNull() ?: throw ConcurrentModificationException() val moved1 = moveFluid(source = cap1, destination = fluid) if (moved1 != moved0 || moved1.amount != moved0.amount) { - LOGGER.error("Error moving fluids in Fluid tank at $blockPos: moved $moved0 during simulation from $target, moved $moved1 from $target1 during execution. This is likely a bug in OTM or other mod!") + LOGGER.error("Error moving fluids in Fluid tank at $blockPos: moved $moved0 during simulation from ${cap.container}, moved $moved1 from ${cap1.container} during execution. This is likely a bug in OTM or other mod!") } else { item.count-- drainInput.setChanged(0) - if (!output.consumeItem(target1, simulate = false)) { - LOGGER.error("Unable to insert $target1 into output slot of Fluid tank at $blockPos, popping item in world instead to avoid item loss! This is likely a bug in OTM or other mod!") - (level as? ServerLevel)?.addFreshEntity(ItemEntity(level!!, blockPos.x.toDouble(), blockPos.y.toDouble(), blockPos.z.toDouble(), target1)) + if (!output.consumeItem(cap1.container, simulate = false)) { + LOGGER.error("Unable to insert ${cap1.container} into output slot of Fluid tank at $blockPos, popping item in world instead to avoid item loss! This is likely a bug in OTM or other mod!") + (level as? ServerLevel)?.addFreshEntity(ItemEntity(level!!, blockPos.x.toDouble(), blockPos.y.toDouble(), blockPos.z.toDouble(), cap1.container)) } } } @@ -145,8 +133,7 @@ class FluidTankBlockEntity(blockPos: BlockPos, blockState: BlockState) : Mattery val item = fillInput[0] if (item.isNotEmpty) { - val target = if (item.count == 1) item else item.copyWithCount(1) - val cap = target.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).orNull() ?: target.getCapability(ForgeCapabilities.FLUID_HANDLER).orNull() + val cap = (if (item.count == 1) item else item.copyWithCount(1)).getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).orNull() if (cap == null) { if (output.consumeItem(item, simulate = false)) { @@ -161,9 +148,9 @@ class FluidTankBlockEntity(blockPos: BlockPos, blockState: BlockState) : Mattery val moved0 = moveFluid(source = fluid, destination = cap) if (moved0.isNotEmpty) { - fillInput.setChanged(0) + fillInput[0] = cap.container - if (output.consumeItem(item, simulate = false)) { + if (output.consumeItem(fillInput[0], simulate = false)) { fillInput.setChanged(0) } } @@ -171,21 +158,20 @@ class FluidTankBlockEntity(blockPos: BlockPos, blockState: BlockState) : Mattery val moved0 = moveFluid(source = fluid, destination = cap, actuallyDrain = false) if (moved0.isNotEmpty) { - if (output.consumeItem(target, simulate = true)) { - val target1 = item.copyWithCount(1) - val cap1 = target1.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).orNull() ?: target1.getCapability(ForgeCapabilities.FLUID_HANDLER).orNull() ?: throw ConcurrentModificationException() + if (output.consumeItem(cap.container, simulate = true)) { + val cap1 = item.copyWithCount(1).getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).orNull() ?: throw ConcurrentModificationException() val moved1 = moveFluid(source = fluid, destination = cap1) if (moved1 != moved0 || moved1.amount != moved0.amount) { - LOGGER.error("Error moving fluids in Fluid tank at $blockPos: moved $moved0 during simulation from $target, moved $moved1 from $target1 during execution. This is likely a bug in OTM or other mod!") + LOGGER.error("Error moving fluids in Fluid tank at $blockPos: moved $moved0 during simulation from ${cap.container}, moved $moved1 from ${cap1.container} during execution. This is likely a bug in OTM or other mod!") } else { item.count-- fillInput.setChanged(0) - if (!output.consumeItem(target1, simulate = false)) { - LOGGER.error("Unable to insert $target1 into output slot of Fluid tank at $blockPos, popping item in world instead to avoid item loss! This is likely a bug in OTM or other mod!") - (level as? ServerLevel)?.addFreshEntity(ItemEntity(level!!, blockPos.x.toDouble(), blockPos.y.toDouble(), blockPos.z.toDouble(), target1)) + if (!output.consumeItem(cap1.container, simulate = false)) { + LOGGER.error("Unable to insert ${cap1.container} into output slot of Fluid tank at $blockPos, popping item in world instead to avoid item loss! This is likely a bug in OTM or other mod!") + (level as? ServerLevel)?.addFreshEntity(ItemEntity(level!!, blockPos.x.toDouble(), blockPos.y.toDouble(), blockPos.z.toDouble(), cap1.container)) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/AbstractMatteryFluidHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/AbstractMatteryFluidHandler.kt index 5cb8ac463..4b55a6bf7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/AbstractMatteryFluidHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/AbstractMatteryFluidHandler.kt @@ -42,7 +42,7 @@ abstract class AbstractMatteryFluidHandler : IFluidHandler { return isFluidValid(stack) } - final override fun fill(resource: FluidStack, action: IFluidHandler.FluidAction): Int { + override fun fill(resource: FluidStack, action: IFluidHandler.FluidAction): Int { if (resource.isEmpty || !isFluidValid(resource) || !direction.input) { return 0 } @@ -63,7 +63,7 @@ abstract class AbstractMatteryFluidHandler : IFluidHandler { } } - final override fun drain(resource: FluidStack, action: IFluidHandler.FluidAction): FluidStack { + override fun drain(resource: FluidStack, action: IFluidHandler.FluidAction): FluidStack { if (resource.isEmpty || !direction.output) { return FluidStack.EMPTY } @@ -77,7 +77,7 @@ abstract class AbstractMatteryFluidHandler : IFluidHandler { } } - final override fun drain(maxDrain: Int, action: IFluidHandler.FluidAction): FluidStack { + override fun drain(maxDrain: Int, action: IFluidHandler.FluidAction): FluidStack { require(maxDrain >= 0) { "Invalid amount to drain: $maxDrain" } if (maxDrain == 0 || !direction.output) return FluidStack.EMPTY diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/ItemMatteryFluidHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/ItemMatteryFluidHandler.kt index 6cddb0c21..21c087662 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/ItemMatteryFluidHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/ItemMatteryFluidHandler.kt @@ -9,6 +9,7 @@ import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.capabilities.ICapabilityProvider import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.fluids.FluidStack +import net.minecraftforge.fluids.capability.IFluidHandler import net.minecraftforge.fluids.capability.IFluidHandlerItem import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.tagNotNull @@ -38,4 +39,25 @@ open class ItemMatteryFluidHandler(val itemStack: ItemStack, private val _capaci return LazyOptional.empty() } + + override fun fill(resource: FluidStack, action: IFluidHandler.FluidAction): Int { + if (itemStack.count != 1) + return 0 + + return super.fill(resource, action) + } + + override fun drain(resource: FluidStack, action: IFluidHandler.FluidAction): FluidStack { + if (itemStack.count != 1) + return FluidStack.EMPTY + + return super.drain(resource, action) + } + + override fun drain(maxDrain: Int, action: IFluidHandler.FluidAction): FluidStack { + if (itemStack.count != 1) + return FluidStack.EMPTY + + return super.drain(maxDrain, action) + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt index 6b44eee1f..757662ebd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt @@ -331,6 +331,9 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I * @return Whenever [stack] was modified */ fun consumeItem(stack: ItemStack, simulate: Boolean, onlyIntoExisting: Boolean = false, popTime: Int? = null): Boolean { + if (stack.isEmpty) + return false + val result = addItem(stack, 0 until size, simulate, onlyIntoExisting = onlyIntoExisting, popTime = popTime) if (result.count != stack.count) { @@ -411,7 +414,7 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I val old = slots[slot] slots[slot] = stack - trackedSlots[slot] = stack.copy() + trackedSlots[slot] = if (stack.isEmpty) ItemStack.EMPTY else stack.copy() setChanged(slot, stack, old) } 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 2b746de00..e7e1b4693 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 @@ -25,31 +25,26 @@ class FluidTankMenu(containerId: Int, inventory: Inventory, tile: FluidTankBlock val drainInput = object : MatterySlot(tile?.drainInput ?: SimpleContainer(1), 0) { override fun mayPlace(itemStack: ItemStack): Boolean { - return super.mayPlace(itemStack) && itemStack.getCapability(ForgeCapabilities.FLUID_HANDLER) + return super.mayPlace(itemStack) && + itemStack + .getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM) .map { it.isNotEmpty } - .orElse(itemStack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM) - .map { it.isNotEmpty } - .orElse(false)) + .orElse(false) } } val fillInput = object : MatterySlot(tile?.fillInput ?: SimpleContainer(1), 0) { override fun mayPlace(itemStack: ItemStack): Boolean { - return super.mayPlace(itemStack) && itemStack.getCapability(ForgeCapabilities.FLUID_HANDLER) + return super.mayPlace(itemStack) && + (if (itemStack.count <= 1) itemStack else itemStack.copyWithCount(1)) + .getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM) .map { if (fluid.fluid.isEmpty) it.tanks > 0 else it.fill(fluid.fluid, IFluidHandler.FluidAction.SIMULATE) > 0 } - .orElse(itemStack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM) - .map { - if (fluid.fluid.isEmpty) - it.tanks > 0 - else - it.fill(fluid.fluid, IFluidHandler.FluidAction.SIMULATE) > 0 - } - .orElse(false)) + .orElse(false) } } From 13bfa7f2b21b6262dea03f171510e71a787e23db Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 7 Apr 2023 20:11:34 +0700 Subject: [PATCH 0475/1199] Add datagen for fluid capsule and fluid tank --- .../kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt | 2 ++ .../kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt index 36667ac77..1b0c4dd43 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt @@ -142,6 +142,8 @@ fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelPr blockModelProvider.decorativeGlassAll(MRegistry.INDUSTRIAL_GLASS.allBlocks.values) blockStateProvider.simpleBlockM(MRegistry.INDUSTRIAL_GLASS.allBlocks.values) + blockStateProvider.simpleBlockM(MBlocks.FLUID_TANK) + for ((block, colors) in MRegistry.TRITANIUM_STRIPED_BLOCK.blocksWithColor) { DataGen.decorativeColumn( block, diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index b906e6e24..b33a6a8f8 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -34,7 +34,8 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.block(MItems.ITEM_MONITOR) provider.block(MItems.PHANTOM_ATTRACTOR) provider.block(MItems.HOLO_SIGN) - + provider.generated(MItems.FLUID_CAPSULE) + provider.block(MItems.FLUID_TANK) MRegistry.VENT.allItems.values.forEach(provider::block) MRegistry.VENT_ALTERNATIVE.allItems.values.forEach(provider::block) From 85ed4802f4377e524b10a7adb9193d738c2d1a6c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 7 Apr 2023 20:12:22 +0700 Subject: [PATCH 0476/1199] lol --- .../ru/dbotthepony/mc/otm/core/util/Formatting.kt | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt index 62e26f071..6a7bc0a01 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt @@ -147,30 +147,25 @@ fun Long.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsRea } val prefix = SiPrefix.determine(this) - - if (bias == 0) { - return TranslatableComponent(prefix.formatLocaleKey, "%.${decimalPlaces}f".format(this.toDouble() / prefix.long!!.toDouble()), suffix) - } else { - return TranslatableComponent(SiPrefix.determine(this, bias).formatLocaleKey, "%.${decimalPlaces}f".format(this.toDouble() / prefix.long!!.toDouble()), suffix) - } + return TranslatableComponent(prefix.neighbour(bias).formatLocaleKey, "%.${decimalPlaces}f".format(this.toDouble() / prefix.long!!.toDouble()), suffix) } fun Int.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never, bias: Int = 0): Component { return toLong().formatSiComponent(suffix, decimalPlaces, formatAsReadable, bias) } -fun Double.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never): Component { +fun Double.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never, bias: Int = 0): Component { require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } if (formatAsReadable.asBoolean) return concat(reformat("%.${decimalPlaces}f".format(this)), suffix) val prefix = SiPrefix.determine(this) - return TranslatableComponent(prefix.formatLocaleKey, "%.${decimalPlaces}f".format(this / prefix.double), suffix) + return TranslatableComponent(prefix.neighbour(bias).formatLocaleKey, "%.${decimalPlaces}f".format(this / prefix.double), suffix) } -fun Decimal.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never): Component { +fun Decimal.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never, bias: Int = 0): Component { require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } if (formatAsReadable.asBoolean) return concat(reformat(toString(decimalPlaces)), suffix) val prefix = SiPrefix.determine(this) - return TranslatableComponent(prefix.formatLocaleKey, (this / prefix.decimal).toString(decimalPlaces), suffix) + return TranslatableComponent(prefix.neighbour(bias).formatLocaleKey, (this / prefix.decimal).toString(decimalPlaces), suffix) } fun Int.formatPower(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.power.name"), decimalPlaces, formatAsReadable = formatAsReadable) From d92dde89660987962ca2f82ac4afbdecfa18a729 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 8 Apr 2023 01:40:14 +0700 Subject: [PATCH 0477/1199] Use FluidUtil.interactWithFluidHandler --- .../mc/otm/block/decorative/FluidTankBlock.kt | 14 ++++++++++++++ .../ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt index 8586e54ab..113cb43ae 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt @@ -1,12 +1,17 @@ package ru.dbotthepony.mc.otm.block.decorative import net.minecraft.core.BlockPos +import net.minecraft.world.InteractionHand +import net.minecraft.world.InteractionResult +import net.minecraft.world.entity.player.Player import net.minecraft.world.level.Level import net.minecraft.world.level.block.EntityBlock import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.entity.BlockEntityTicker import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.phys.BlockHitResult +import net.minecraftforge.fluids.FluidUtil import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.decorative.FluidTankBlockEntity @@ -21,4 +26,13 @@ class FluidTankBlock : RotatableMatteryBlock(), EntityBlock { return BlockEntityTicker { _, _, _, pBlockEntity -> if (pBlockEntity is FluidTankBlockEntity) pBlockEntity.tick() } } + + @Suppress("OVERRIDE_DEPRECATION") + override fun use(blockState: BlockState, level: Level, blockPos: BlockPos, ply: Player, hand: InteractionHand, blockHitResult: BlockHitResult): InteractionResult { + if (FluidUtil.interactWithFluidHandler(ply, hand, level, blockPos, blockHitResult.direction)) { + return InteractionResult.sidedSuccess(level.isClientSide) + } + + return super.use(blockState, level, blockPos, ply, hand, blockHitResult) + } } 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 755654e6e..4d9e8af29 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt @@ -183,7 +183,7 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6 val blockCap = player.level.getBlockEntity(context.blockPos)?.getCapability(ForgeCapabilities.FLUID_HANDLER, context.side)?.orNull() ?: return InteractionResult.FAIL val fluid = itemCap[0] - if (fluid.isEmpty || player.isCrouching) { + if (fluid.isEmpty) { // заполняем из блока val moveResult = moveFluid(source = blockCap, destination = itemCap, actuallyDrain = !player.level.isClientSide, actuallyFill = !player.level.isClientSide) @@ -238,7 +238,7 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6 val interactions = immutableList { accept(FillCauldron) accept(EmptyCauldron) - accept(FillEmptyCapability) + // accept(FillEmptyCapability) // блоки из модов это сами контролируют } override fun canInteract(item: ItemStack, player: Player, context: Context): Boolean { From 5e444300a143ee6a396835aecdb04a102439d6a4 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Sat, 8 Apr 2023 20:43:05 +0600 Subject: [PATCH 0478/1199] Fluid tank is now transparent --- .../assets/overdrive_that_matters/models/block/fluid_tank.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/fluid_tank.json b/src/main/resources/assets/overdrive_that_matters/models/block/fluid_tank.json index 49fdcc466..e1b13fc0d 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/fluid_tank.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/fluid_tank.json @@ -1,5 +1,6 @@ { "credit": "Made with Blockbench", + "render_type": "cutout", "texture_size": [32, 32], "textures": { "0": "overdrive_that_matters:block/fluid_tank", From cf5d0455cfbf437b3b0ae7db0e144225be594193 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Mon, 10 Apr 2023 01:22:23 +0600 Subject: [PATCH 0479/1199] a --- .../kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt | 8 ++++++++ .../kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt | 3 +++ .../component/{metal_mesh.png => carbon_mesh.png} | Bin 3 files changed, 11 insertions(+) rename src/main/resources/assets/overdrive_that_matters/textures/item/component/{metal_mesh.png => carbon_mesh.png} (100%) 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 472f4078e..c52a45366 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -345,6 +345,8 @@ object MItems { val BASIC_CONTROL_CIRCUIT: Item by registry.register(MNames.BASIC_CONTROL_CIRCUIT) { Item(DEFAULT_PROPERTIES) } val ADVANCED_CONTROL_CIRCUIT: Item by registry.register(MNames.ADVANCED_CONTROL_CIRCUIT) { Item(DEFAULT_PROPERTIES) } val MATTER_CAPACITOR_PARTS: Item by registry.register(MNames.MATTER_CAPACITOR_PARTS) { Item(DEFAULT_PROPERTIES) } + val CARBON_MESH: Item by registry.register(MNames.CARBON_MESH) { Item(DEFAULT_PROPERTIES) } + val REINFORCED_TRITANIUM_PLATE: Item by registry.register(MNames.REINFORCED_TRITANIUM_PLATE) { Item(DEFAULT_PROPERTIES) } val QUANTUM_TRANSCEIVER: Item by registry.register("quantum_transceiver") { Item(DEFAULT_PROPERTIES) } val ELECTROMAGNET: Item by registry.register("electromagnet") { Item(DEFAULT_PROPERTIES) } @@ -386,6 +388,9 @@ object MItems { ::ELECTROMAGNET, ::MIRROR_COMPOUND, ::MIRROR, + + ::CARBON_MESH, + ::REINFORCED_TRITANIUM_PLATE, ) /** @@ -409,6 +414,9 @@ object MItems { ::ELECTROMAGNET, ::MIRROR_COMPOUND, ::MIRROR, + + ::CARBON_MESH, + ::REINFORCED_TRITANIUM_PLATE, ) val CARGO_CRATE_MINECARTS = registry.allColored(MNames.MINECART_CARGO_CRATE) { color, _ -> MinecartCargoCrateItem(color) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index e56fb83b6..57ab049d9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -153,6 +153,9 @@ object MNames { const val MATTER_IO_PORT = "matter_io_port" const val MATTER_TRANSFORM_MATRIX = "matter_transform_matrix" + const val CARBON_MESH = "carbon_mesh" + const val REINFORCED_TRITANIUM_PLATE = "reinforced_tritanium_plate" + const val ENERGY_BUS = "energy_bus" const val ELECTRIC_PARTS = "electric_parts" diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/component/metal_mesh.png b/src/main/resources/assets/overdrive_that_matters/textures/item/component/carbon_mesh.png similarity index 100% rename from src/main/resources/assets/overdrive_that_matters/textures/item/component/metal_mesh.png rename to src/main/resources/assets/overdrive_that_matters/textures/item/component/carbon_mesh.png From 8093d314d7c9733b24aac01ed56cead5c8855e93 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Mon, 10 Apr 2023 02:28:56 +0600 Subject: [PATCH 0480/1199] b --- .../mc/otm/datagen/lang/English.kt | 4 +++ .../mc/otm/datagen/lang/Russian.kt | 4 +++ .../datagen/recipes/CraftingTableRecipes.kt | 35 +++++++++++-------- .../dbotthepony/mc/otm/datagen/tags/Tags.kt | 2 ++ .../ru/dbotthepony/mc/otm/registry/Tags.kt | 1 + 5 files changed, 32 insertions(+), 14 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 771ba8869..83bbc2a50 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -377,6 +377,7 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.FLUID_TANK, "named", "Fluid Tank (%s)") add(MBlocks.ENGINE, "Ship Engine") + add(MBlocks.ENGINE, "desc", "Unfortunately, it doesn't seem functional anymore.") add(MBlocks.HOLO_SIGN, "Holo Sign") add(MBlocks.TRITANIUM_INGOT_BLOCK, "Tritanium Plating Block") @@ -397,6 +398,7 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.CARBON_FIBRE_BLOCK, "Carbon Fibre Block") add(MBlocks.METAL_JUNK, "Metal Junk Block") + add(MBlocks.METAL_JUNK, "desc", "Useless junk, or is it?") add(MBlocks.METAL_MESH, "Metal Mesh") add(MBlocks.TRITANIUM_STRIPED_BLOCK, "Tritanium Striped Block") @@ -524,6 +526,8 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.MIRROR_COMPOUND, "Mirror Compound") add(MItems.MIRROR, "Mirror") add(MItems.MIRROR, "description", "I can clearly see my own reflection in this mirror") + add(MItems.REINFORCED_TRITANIUM_PLATE, "Reinforced Tritanium Plate") + add(MItems.REINFORCED_TRITANIUM_PLATE, "description", "An armor plate, reinforced to withstand great kinetic forces") add(MItems.GRAVITATIONAL_DISRUPTOR, "Gravitational Disruptor") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 77ccaab54..02c856631 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -384,6 +384,7 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.FLUID_TANK, "named", "Жидкостный бак (%s)") add(MBlocks.ENGINE, "Двигатель корабля") + add(MBlocks.ENGINE, "desc", "К сожалению, он больше не выглядит рабочим.") add(MBlocks.HOLO_SIGN, "Голографическая табличка") add(MBlocks.TRITANIUM_INGOT_BLOCK, "Блок слитков тритана") @@ -405,6 +406,7 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.CARBON_FIBRE_BLOCK, "Блок углеродных трубок") add(MBlocks.METAL_MESH, "Блок металлической сетки") add(MBlocks.METAL_JUNK, "Металлический хлам") + add(MBlocks.METAL_JUNK, "desc", "Бесполезный хлам, или нет?") add(MBlocks.TRITANIUM_STRIPED_BLOCK, "Тритановый блок с полоской") add(MBlocks.TRITANIUM_STRIPED_STAIRS, "Тритановые ступеньки с полоской") @@ -531,6 +533,8 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.MIRROR_COMPOUND, "Набор выплавки зеркала") add(MItems.MIRROR, "Зеркало") add(MItems.MIRROR, "description", "Я могу очень отчётливо видеть своё отражение в этом зеркале") + add(MItems.REINFORCED_TRITANIUM_PLATE, "Укреплённая тритановая пластина") + add(MItems.REINFORCED_TRITANIUM_PLATE, "description", "Бронированная пластина, усиленная что бы выдержать большие кинетические силы") add(MItems.GRAVITATIONAL_DISRUPTOR, "Антигравитационный маяк") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index 795954f11..ef446bcd3 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -169,31 +169,38 @@ fun addCraftingTableRecipes(consumer: Consumer) { .unlockedBy(Tags.Items.GLASS_PANES_COLORLESS) .build(consumer) + MatteryRecipe(MItems.REINFORCED_TRITANIUM_PLATE, category = RecipeCategory.MISC) + .rowB(MItems.CARBON_MESH) + .row(MItems.CARBON_MESH, MItemTags.TRITANIUM_PLATES, MItems.CARBON_MESH) + .rowB(MItems.CARBON_MESH) + .unlockedBy(MItemTags.TRITANIUM_PLATES) + .build(consumer) + // броня MatteryRecipe(MItems.TRITANIUM_HELMET, category = RecipeCategory.COMBAT) - .row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) - .row(MItemTags.TRITANIUM_PLATES, Items.LEATHER_HELMET, MItemTags.TRITANIUM_PLATES) - .unlockedBy(MItemTags.TRITANIUM_PLATES) + .row(MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES) + .row(MItemTags.REINFORCED_TRITANIUM_PLATES, Items.LEATHER_HELMET, MItemTags.REINFORCED_TRITANIUM_PLATES) + .unlockedBy(MItemTags.REINFORCED_TRITANIUM_PLATES) .build(consumer) MatteryRecipe(MItems.TRITANIUM_PANTS, category = RecipeCategory.COMBAT) - .row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) - .row(MItemTags.TRITANIUM_PLATES, Items.LEATHER_LEGGINGS, MItemTags.TRITANIUM_PLATES) - .rowAC(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) - .unlockedBy(MItemTags.TRITANIUM_PLATES) + .row(MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES) + .row(MItemTags.REINFORCED_TRITANIUM_PLATES, Items.LEATHER_LEGGINGS, MItemTags.REINFORCED_TRITANIUM_PLATES) + .rowAC(MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES) + .unlockedBy(MItemTags.REINFORCED_TRITANIUM_PLATES) .build(consumer) MatteryRecipe(MItems.TRITANIUM_CHESTPLATE, category = RecipeCategory.COMBAT) - .row(MItemTags.TRITANIUM_PLATES, Items.LEATHER_CHESTPLATE, MItemTags.TRITANIUM_PLATES) - .row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) - .row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) - .unlockedBy(MItemTags.TRITANIUM_PLATES) + .row(MItemTags.REINFORCED_TRITANIUM_PLATES, Items.LEATHER_CHESTPLATE, MItemTags.REINFORCED_TRITANIUM_PLATES) + .row(MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES) + .row(MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES) + .unlockedBy(MItemTags.REINFORCED_TRITANIUM_PLATES) .build(consumer) MatteryRecipe(MItems.TRITANIUM_BOOTS, category = RecipeCategory.COMBAT) - .row(MItemTags.TRITANIUM_PLATES, Items.LEATHER_BOOTS, MItemTags.TRITANIUM_PLATES) - .row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) - .unlockedBy(MItemTags.TRITANIUM_PLATES) + .row(MItemTags.REINFORCED_TRITANIUM_PLATES, Items.LEATHER_BOOTS, MItemTags.REINFORCED_TRITANIUM_PLATES) + .row(MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES) + .unlockedBy(MItemTags.REINFORCED_TRITANIUM_PLATES) .build(consumer) // простые батарейки diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index 6dcc91e5f..0d51173e7 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -24,6 +24,8 @@ fun addTags(tagsProvider: TagsProvider) { tagsProvider.plates.add("iron", MItems.IRON_PLATE) tagsProvider.plates.add("gold", MItems.GOLD_PLATE) + tagsProvider.items.forge("reinforced_tritanium").add(MItems.REINFORCED_TRITANIUM_PLATE) + tagsProvider.storageBlocksAsItem.add("tritanium", MItems.TRITANIUM_INGOT_BLOCK) tagsProvider.storageBlocksAsBlock.add("tritanium", MBlocks.TRITANIUM_INGOT_BLOCK) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt index 433e40e59..a294d403f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt @@ -17,6 +17,7 @@ object MItemTags { val NUGGETS: TagKey = ItemTags.create(ResourceLocation("forge", "nuggets")) val TRITANIUM_INGOTS_STORAGE: TagKey = ItemTags.create(ResourceLocation("forge", "storage_blocks/tritanium")) val TRITANIUM_PLATES: TagKey = ItemTags.create(ResourceLocation("forge", "plates/tritanium")) + val REINFORCED_TRITANIUM_PLATES: TagKey = ItemTags.create(ResourceLocation("forge", "reinforced_tritanium")) val TRITANIUM_DUSTS: TagKey = ItemTags.create(ResourceLocation("forge", "dusts/tritanium")) val IRON_PLATES: TagKey = ItemTags.create(ResourceLocation("forge", "plates/iron")) val GOLD_PLATES: TagKey = ItemTags.create(ResourceLocation("forge", "plates/gold")) From 9a1323ba46a6e407f0f6e5dac35b632a2e45c040 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Mon, 10 Apr 2023 02:30:46 +0600 Subject: [PATCH 0481/1199] AEUUGHH --- src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 83bbc2a50..be3ad5e5f 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -377,7 +377,7 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.FLUID_TANK, "named", "Fluid Tank (%s)") add(MBlocks.ENGINE, "Ship Engine") - add(MBlocks.ENGINE, "desc", "Unfortunately, it doesn't seem functional anymore.") + add(MBlocks.ENGINE, "desc", "Unfortunately, it doesn't seem to be functional anymore.") add(MBlocks.HOLO_SIGN, "Holo Sign") add(MBlocks.TRITANIUM_INGOT_BLOCK, "Tritanium Plating Block") From 0bbe07f92188c5ee3183b55c70cfa87b6295ed6a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 10 Apr 2023 19:26:24 +0700 Subject: [PATCH 0482/1199] Fix non stackable items not getting moved to filtered slots first --- .../otm/capability/MatteryPlayerCapability.kt | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index c11d81a68..69900a176 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -1000,8 +1000,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial val exoPackContainer = exoPackContainer if (!stack.isStackable) { + // двигаем в отфильтрованные слоты for (i in items.indices) { - if (items[i].isEmpty && (regularSlotFilters[i].value === null || regularSlotFilters[i].value === stack.item)) { + if (items[i].isEmpty && regularSlotFilters[i].value === stack.item) { items[i] = stack.copy() items[i].popTime = 5 stack.count = 0 @@ -1010,7 +1011,26 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } for (i in 0 until exoPackContainer.containerSize) { - if (exoPackContainer[i].isEmpty && exoPackContainer.testSlotFilter(i, stack)) { + if (exoPackContainer[i].isEmpty && exoPackContainer.hasSlotFilter(i) && exoPackContainer.testSlotFilter(i, stack)) { + exoPackContainer[i] = stack.copy() + exoPackContainer[i].popTime = 5 + stack.count = 0 + return true + } + } + + // двигаем в обычные слоты + for (i in items.indices) { + if (items[i].isEmpty && regularSlotFilters[i].value === null) { + items[i] = stack.copy() + items[i].popTime = 5 + stack.count = 0 + return true + } + } + + for (i in 0 until exoPackContainer.containerSize) { + if (exoPackContainer[i].isEmpty && !exoPackContainer.hasSlotFilter(i)) { exoPackContainer[i] = stack.copy() exoPackContainer[i].popTime = 5 stack.count = 0 From 3870428f5d03fc78a6de53b8c349ebe4a2ba03a4 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Mon, 10 Apr 2023 16:58:51 +0300 Subject: [PATCH 0483/1199] =?UTF-8?q?=D0=BE=D0=BA=D0=BD=D0=BE=20=D0=B2=20?= =?UTF-8?q?=D0=B5=D0=B2=D1=80=D0=BE=D0=BF=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dbotthepony/mc/otm/shapes/BlockShapes.java | 8 ++++++++ .../mc/otm/block/decorative/FluidTankBlock.kt | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java index d87f1ef00..87609a632 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java +++ b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java @@ -649,4 +649,12 @@ public class BlockShapes { new SimpleCuboid(0.36875d, 0.65625d, 0.5875d, 0.44375d, 0.78125d, 0.9d), new SimpleCuboid(0.4375d, 0.5d, 0.1875d, 0.5625d, 0.625d, 0.3125d) ); + + public static final BlockShape FLUID_TANK = new BlockShape( + new SimpleCuboid(0d, 0d, 0d, 1d, 0.125d, 1d), + new SimpleCuboid(0d, 0.875d, 0d, 1d, 1d, 1d), + new SimpleCuboid(0.03125d, 0.125d, 0.03125d, 0.96875d, 0.1875d, 0.96875d), + new SimpleCuboid(0.03125d, 0.8125d, 0.03125d, 0.96875d, 0.875d, 0.96875d), + new SimpleCuboid(0d, 0.1875d, 0d, 1d, 0.8125d, 1d) + ); } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt index 113cb43ae..37e5483ac 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt @@ -4,6 +4,7 @@ import net.minecraft.core.BlockPos import net.minecraft.world.InteractionHand import net.minecraft.world.InteractionResult import net.minecraft.world.entity.player.Player +import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraft.world.level.block.EntityBlock import net.minecraft.world.level.block.entity.BlockEntity @@ -11,9 +12,14 @@ import net.minecraft.world.level.block.entity.BlockEntityTicker import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.phys.BlockHitResult +import net.minecraft.world.phys.shapes.CollisionContext +import net.minecraft.world.phys.shapes.VoxelShape import net.minecraftforge.fluids.FluidUtil import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.decorative.FluidTankBlockEntity +import ru.dbotthepony.mc.otm.block.getShapeForEachState +import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.shapes.BlockShapes class FluidTankBlock : RotatableMatteryBlock(), EntityBlock { override fun newBlockEntity(pPos: BlockPos, pState: BlockState): BlockEntity { @@ -35,4 +41,16 @@ class FluidTankBlock : RotatableMatteryBlock(), EntityBlock { return super.use(blockState, level, blockPos, ply, hand, blockHitResult) } + + private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.FLUID_TANK.rotateFromNorth(it[rotationProperty]).computeShape() } + + @Suppress("override_deprecation") + override fun getShape( + state: BlockState, + blockGetter: BlockGetter, + pos: BlockPos, + context: CollisionContext + ): VoxelShape { + return shapes[state]!! + } } From fc27199ce287ea56f4272e2067c53c63b0d4148c Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Mon, 10 Apr 2023 17:08:29 +0300 Subject: [PATCH 0484/1199] =?UTF-8?q?=D0=B0=20=D0=B3=D0=B4=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/block/decorative/EngineBlock.kt | 15 +++++++++++++++ .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 12 +++++++++++- .../ru/dbotthepony/mc/otm/registry/MItems.kt | 13 ++++++++++++- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt index 79e7deaf1..818e78ef5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt @@ -1,18 +1,33 @@ package ru.dbotthepony.mc.otm.block.decorative +import net.minecraft.ChatFormatting import net.minecraft.core.BlockPos +import net.minecraft.network.chat.Component import net.minecraft.world.item.DyeColor +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.material.Material import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.shapes.BlockShapes class EngineBlock : RotatableMatteryBlock(Properties.of(Material.METAL, DyeColor.ORANGE).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) { + override fun appendHoverText( + p_49816_: ItemStack, + p_49817_: BlockGetter?, + p_49818_: MutableList, + p_49819_: TooltipFlag + ) { + super.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) + p_49818_.add(TranslatableComponent("$descriptionId.desc").withStyle(ChatFormatting.DARK_GRAY)) + } + override fun rotationFreedom(): BlockRotationFreedom { return BlockRotationFreedom.TWO } 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 55ecb67b2..166e058a3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -127,7 +127,17 @@ object MBlocks { } val METAL_JUNK: Block by registry.register(MNames.METAL_JUNK) { - Block(BlockBehaviour.Properties.of(Material.HEAVY_METAL, MaterialColor.COLOR_GRAY).sound(SoundType.NETHERITE_BLOCK).explosionResistance(45f).destroyTime(3f).requiresCorrectToolForDrops()) + object : Block(BlockBehaviour.Properties.of(Material.HEAVY_METAL, MaterialColor.COLOR_GRAY).sound(SoundType.NETHERITE_BLOCK).explosionResistance(45f).destroyTime(3f).requiresCorrectToolForDrops()) { + override fun appendHoverText( + p_49816_: ItemStack, + p_49817_: BlockGetter?, + p_49818_: MutableList, + p_49819_: TooltipFlag + ) { + super.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) + p_49818_.add(TranslatableComponent("$descriptionId.desc").withStyle(ChatFormatting.DARK_GRAY)) + } + } } val METAL_MESH: Block by registry.register(MNames.METAL_MESH) { 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 c52a45366..d9853eece 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -8,6 +8,7 @@ import net.minecraft.world.entity.EquipmentSlot import net.minecraft.world.food.FoodProperties import net.minecraft.world.item.* import net.minecraft.world.item.crafting.Ingredient +import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraftforge.common.ForgeTier import net.minecraftforge.common.TierSortingRegistry @@ -346,7 +347,17 @@ object MItems { val ADVANCED_CONTROL_CIRCUIT: Item by registry.register(MNames.ADVANCED_CONTROL_CIRCUIT) { Item(DEFAULT_PROPERTIES) } val MATTER_CAPACITOR_PARTS: Item by registry.register(MNames.MATTER_CAPACITOR_PARTS) { Item(DEFAULT_PROPERTIES) } val CARBON_MESH: Item by registry.register(MNames.CARBON_MESH) { Item(DEFAULT_PROPERTIES) } - val REINFORCED_TRITANIUM_PLATE: Item by registry.register(MNames.REINFORCED_TRITANIUM_PLATE) { Item(DEFAULT_PROPERTIES) } + val REINFORCED_TRITANIUM_PLATE: Item by registry.register(MNames.REINFORCED_TRITANIUM_PLATE) { object : Item(DEFAULT_PROPERTIES) { + override fun appendHoverText( + p_41421_: ItemStack, + p_41422_: Level?, + p_41423_: MutableList, + p_41424_: TooltipFlag + ) { + super.appendHoverText(p_41421_, p_41422_, p_41423_, p_41424_) + p_41423_.add(TranslatableComponent("$descriptionId.description").withStyle(ChatFormatting.DARK_GRAY)) + } + } } val QUANTUM_TRANSCEIVER: Item by registry.register("quantum_transceiver") { Item(DEFAULT_PROPERTIES) } val ELECTROMAGNET: Item by registry.register("electromagnet") { Item(DEFAULT_PROPERTIES) } From 6a9df1d79b36b57ab37121bc971aef1f8fb07575 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Tue, 11 Apr 2023 04:06:53 +0600 Subject: [PATCH 0485/1199] Liquid running gif --- .../overdrive_that_matters/models/block/fluid_tank.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/fluid_tank.json b/src/main/resources/assets/overdrive_that_matters/models/block/fluid_tank.json index e1b13fc0d..a5d92e79e 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/fluid_tank.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/fluid_tank.json @@ -70,8 +70,8 @@ }, { "name": "tank inside", - "from": [0, 13, 0], - "to": [16, 3, 16], + "from": [0.1, 13, 0.1], + "to": [15.9, 3, 15.9], "faces": { "north": {"uv": [0, 9, 8, 14], "texture": "#0"}, "east": {"uv": [0, 9, 8, 14], "texture": "#0"}, From 89847ac34a6a200e80bbf2da97056ac2209152e2 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Tue, 11 Apr 2023 04:19:29 +0600 Subject: [PATCH 0486/1199] texture stuff --- .../component/reinforced_tritanium_plate.png | Bin 275 -> 275 bytes .../textures/item/tritanium_axe.png | Bin 259 -> 261 bytes .../textures/item/tritanium_pickaxe.png | Bin 259 -> 259 bytes .../textures/item/tritanium_shears.png | Bin 259 -> 258 bytes .../textures/item/tritanium_shovel.png | Bin 248 -> 249 bytes .../textures/item/tritanium_sword.png | Bin 272 -> 273 bytes 6 files changed, 0 insertions(+), 0 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/component/reinforced_tritanium_plate.png b/src/main/resources/assets/overdrive_that_matters/textures/item/component/reinforced_tritanium_plate.png index 0733e07da4272fa7910b799b9be6b4bdafc9b921..8d63c341a6d160a306c94f325e21bf6006c98f28 100644 GIT binary patch delta 123 zcmV->0EGXO0+RxepL9VEz#s?&w;&+@|8Q5JZPH0hoN*5#e|!ObeFAV@b)QTXT}SFr z^>7NPYn2ifz*J>i)Brb@!AyW~nPPNt#I7P#6Zb&I*^KUB$l8qdKe!>K9k|)CODAyC d&!odk<_!qD1`U(>=OzFE002ovPDHLkV1l|GHI@JX delta 123 zcmV->0EGXO0+RxepL7cfz#t4mv)2CZf8nKC87v~?Jz5d<%O`N^6~OcCKAI@H8ule> zrwxc}ZDeQwQ{%mXD0vv0JEH+L6K`Bc)|bx z4#EKyC`y0;0034=L_t(2Q&r4c7QiqB1W=Dk)czM-5)t(^?l{2Cz>Woge*h#}IRTKl zgZKQfjDk5SL<@q%WnM5D${plYzw(ga{SFCt-w^j_0$RVI_Y1V|`LxFD14=^(i+!nJ QJOBUy07*qoM6N<$f?uaTWdHyG delta 160 zcmV;R0AK%w0)qmOOdoB6kAa$~Nj4Q|P97^OD_w7TC>{%mXD0vv0M}|8*O6-?cEbPw z4#NS*Z>VGd002};L_t(2Q(eqa62LG71W-g&-T%OqkTCVN-Wp)PDS(I<0CDF7fHXSz zPQLHnLh@0fjVlnAIoFZ>+< O0000t^N}ziePwyf+MD559F;nag j^4sbOg!T7cdT_r1_ALjqlXX)H00000NkvXXu0mjfhi5aV delta 129 zcmV-{0Dk|20)qmOiF(5T01m?e$8V@)00013Nklxa=6wfToX(I&BrwG%Tn8D~OOnI9`L5n{cC3}ezG1oMiKEztcIvqRLC)ggL{=pcW| j9zaxIK-hiGM+^5C2*3x??c(Gj00000NkvXXu0mjf2_-be diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_shears.png b/src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_shears.png index da7fb1fea2eda508cdd13d5586492b32c484e21a..e8ac4f699faa63b45337c68fab0b2e11c7aad550 100644 GIT binary patch delta 119 zcmV--0EqvC0)hgNl5kr|L_t(2Q(cV-62Kq`1B2Mg|6g1})Ujqf*d0N{l|ul=Q;V diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_shovel.png b/src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_shovel.png index 5e50c521b392783b2fdea47c0d4f7d92225d61bd..e6f70f10a1f05bbccaa017206331b1dc9d3a51db 100644 GIT binary patch delta 154 zcmV;L0A>I90r>%tNgtiN%z>JyZGw+0D=SGh6^UmjC>{%FP96XN08ykBHj!u{aKZop z4#EKyC`y0;002%&L_t(2Q(enj0)QY0MA5+_V*eXX9_1uo-h;rm`2l7zKm-hsaY%gX zi5>*iC!J{a0=+EygV`Sag5Fk-hS>KctbKygzJNPVYzG?m2liJ7!v?1nvH$=807*qo IM6N<$g8lG1*8l(j delta 153 zcmV;K0A~OB0r&xsNgpdKE1kQ{ZGw-1ny5)O6^UmjC>{%FP96XN0MdINq>*SLZ^Hlp z4#NS*Z>VGd002!%L_t(2Q+>-p7Qi3~LqS9-=KdFML0hAXvhq)!g5!Qcq--FnwGfE5 zssz!E0hYbME|31;X+*zZ-N$1>?DG=Vo?x^O;Lb080v&Jz9?A#trd=jG00000NkvXX Hu0mjf0mwbG diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_sword.png b/src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_sword.png index a157ddda6c5a042b46c361c24d0ada1cefae128a..109c6716541f96591164482fe3d8d90017e6b3c9 100644 GIT binary patch delta 171 zcmV;c095~w0+9lcPalDrsBMCeU2l3xHWg@29*JisC>{%IYij@i0Pu00z>#hvf5HF& z4#EKyC`y0;003S|L_t(2Q%#Qx3P2$U1Xu0*y#IZlmWE5g&X7XT5_qC}Ktx;wNLm%n zQbe$(fEWu~vEw)Shz{d^`HZ0P;}GrfU1~!de8iXx6fxFT<}~)3xxM5J@a5wh+g63@ Z5A5UzrMOTK`2YX_07*qoM6N<$0fG}wM&{%IYij@i0FeH3#*uC#f5QL( z4#NS*Z>VGd003P{L_t(2Q&o>!62Kq`10%j_x&M8O5!B{KcAYQ-^bRaOGDt~ofs}uO ztVb9ZvBxoZ3NA)jOi^)|6=W&Z*+t&GmRc#8qIJPGCfYMpB#d3t#~fsfch?z6d@-sY XNni*np4EsH00000NkvXXu0mjfsct_n From 50b19c3a319711432982ec7ff75a84586cb6522a Mon Sep 17 00:00:00 2001 From: GearShocky Date: Tue, 11 Apr 2023 04:27:11 +0600 Subject: [PATCH 0487/1199] Make shield use reinforced stuff too, also more edits --- .../otm/datagen/recipes/CraftingTableRecipes.kt | 6 +++--- .../component/reinforced_tritanium_plate.png | Bin 275 -> 277 bytes .../textures/item/essence_servo.png | Bin 298 -> 286 bytes 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index ef446bcd3..1c6ce2577 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -276,9 +276,9 @@ fun addCraftingTableRecipes(consumer: Consumer) { .build(consumer) MatteryRecipe(MItems.TRITANIUM_SHIELD, category = RecipeCategory.COMBAT) - .row(MItemTags.TRITANIUM_PLATES, Items.SHIELD, MItemTags.TRITANIUM_PLATES) - .row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) - .rowB(MItemTags.TRITANIUM_PLATES) + .row(MItemTags.REINFORCED_TRITANIUM_PLATES, Items.SHIELD, MItemTags.REINFORCED_TRITANIUM_PLATES) + .row(MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES) + .rowB(MItemTags.REINFORCED_TRITANIUM_PLATES) .build(consumer) ShapelessRecipeBuilder(RecipeCategory.MISC, MItems.TRITANIUM_NUGGET, 9) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/component/reinforced_tritanium_plate.png b/src/main/resources/assets/overdrive_that_matters/textures/item/component/reinforced_tritanium_plate.png index 8d63c341a6d160a306c94f325e21bf6006c98f28..5e41fa12500a60a4ded4fce29bfbe4eecc3432c9 100644 GIT binary patch delta 134 zcmV;10D1qD0+j-gmVatVL_t(2Q(cZx4uCKSLn{mz_rI_mpe8n1#(VSwMD1~4wUW%wE3Ml&%JAY6`N$H?M{T}Fr|?tzTc8QejU)fwzN o*kKA=u(M+qj$o(POp7;}HwHHb3Dm$FfB*mh07*qoM6N<$g0`7AYybcN delta 132 zcmV-~0DJ$H0+RxemVIbRL_t(2Q(cZh4!|G?1h*g{|Nn4Tpl#AgOq_8KB7b}VeSHFO zU3H&K6*Vb diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/essence_servo.png b/src/main/resources/assets/overdrive_that_matters/textures/item/essence_servo.png index 4012c2c65641aba7ea081b581a376018e8fa8cf8..819311060c27afdc0ab6f54d84c8600518d3e942 100644 GIT binary patch delta 131 zcmV-}0DS+d0-gepqI_pbL_t(2Q$3AI0>B^$#Bf0D;{V@U2BcmzF{tcbGV=Tjfu?C8 zFf*Ey1p`Wxm5`^WVN|@917Jfo_*#>k1xyuQTyH?b)P4ODhJ3M45i`k0knh7Op10>t delta 144 zcmV;B0B`@E0;&R#qJMKqL_t(2Q&o=(4!|G?Ls>!H$NQgmrOag`YVw{)qs>*eacfl> zd^59G7$PE#1U(#Z8g)>UTTi1gsS7IIv yaTnJU@_}NB^P=HTR21jMp2Za8Z`q&cya8ip2Q0r4r*8lN00{s|MNUMnLSTXpKRhM? From 607512cf1b0f21892c9997be441fd78862b5b5e0 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Tue, 11 Apr 2023 23:01:57 +0600 Subject: [PATCH 0488/1199] Texture updates --- .../models/block/chemical_generator_idle.json | 52 +++++------------- .../block/chemical_generator_working.json | 52 +++++------------- .../textures/block/chemical_generator.png | Bin 455 -> 678 bytes .../textures/item/component/energy_bus.png | Bin 287 -> 306 bytes .../component/gravitation_field_limiter.png | Bin 240 -> 259 bytes .../component/gravitation_field_sensor.png | Bin 266 -> 277 bytes .../item/component/matter_capacitor_parts.png | Bin 266 -> 282 bytes .../item/component/matter_io_port.png | Bin 258 -> 270 bytes .../component/matter_transform_matrix.png | Bin 278 -> 294 bytes .../textures/item/component/mirror.png | Bin 238 -> 246 bytes .../item/component/mirror_compound.png | Bin 240 -> 245 bytes .../item/component/quantum_transceiver.png | Bin 294 -> 304 bytes .../textures/item/tritanium_sword.png | Bin 273 -> 275 bytes 13 files changed, 30 insertions(+), 74 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/chemical_generator_idle.json b/src/main/resources/assets/overdrive_that_matters/models/block/chemical_generator_idle.json index 1864f2bb0..d29ddb107 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/chemical_generator_idle.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/chemical_generator_idle.json @@ -1,5 +1,7 @@ { + "credit": "Made with Blockbench", "parent": "block/block", + "texture_size": [64, 32], "textures": { "0": "overdrive_that_matters:block/chemical_generator", "particle": "overdrive_that_matters:block/chemical_generator" @@ -21,9 +23,7 @@ "from": [3, 1, 2], "to": [5, 2, 14], "faces": { - "north": {"uv": [0, 0, 0.5, 0.25], "texture": "#missing"}, "east": {"uv": [1, 6, 4, 6.5], "texture": "#0"}, - "south": {"uv": [0, 0, 0.5, 0.25], "texture": "#missing"}, "west": {"uv": [1, 6, 4, 6.5], "texture": "#0"}, "up": {"uv": [1, 6, 4, 7], "rotation": 90, "texture": "#0"}, "down": {"uv": [1, 6, 4, 7], "rotation": 90, "texture": "#0"} @@ -33,9 +33,7 @@ "from": [11, 1, 2], "to": [13, 2, 14], "faces": { - "north": {"uv": [0, 0, 0.5, 0.25], "texture": "#missing"}, "east": {"uv": [1, 6, 4, 6.5], "texture": "#0"}, - "south": {"uv": [0, 0, 0.5, 0.25], "texture": "#missing"}, "west": {"uv": [1, 6, 4, 6.5], "texture": "#0"}, "up": {"uv": [1, 6, 4, 7], "rotation": 90, "texture": "#0"}, "down": {"uv": [1, 6, 4, 7], "rotation": 90, "texture": "#0"} @@ -61,17 +59,14 @@ "east": {"uv": [0.5, 0, 1, 7], "texture": "#0"}, "south": {"uv": [0.5, 0, 0, 7], "texture": "#0"}, "west": {"uv": [0.25, 0, 0.5, 7], "texture": "#0"}, - "up": {"uv": [0.5, 0, 0, 1], "texture": "#0"}, - "down": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"} + "up": {"uv": [0.5, 0, 0, 1], "texture": "#0"} } }, { "from": [14, 14, 2], "to": [16, 16, 14], "faces": { - "north": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"}, "east": {"uv": [0.5, 8, 3.5, 7], "texture": "#0"}, - "south": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"}, "west": {"uv": [0.5, 7, 3.5, 7.5], "texture": "#0"}, "up": {"uv": [4.5, 1, 4, 7], "texture": "#0"}, "down": {"uv": [1, 1, 0.75, 7], "texture": "#0"} @@ -85,8 +80,7 @@ "east": {"uv": [1, 0, 0.5, 7], "texture": "#0"}, "south": {"uv": [0.75, 0, 1, 7], "texture": "#0"}, "west": {"uv": [4.25, 0, 4.5, 7], "texture": "#0"}, - "up": {"uv": [0.5, 0, 0, 1], "texture": "#0"}, - "down": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"} + "up": {"uv": [0.5, 0, 0, 1], "texture": "#0"} } }, { @@ -97,17 +91,14 @@ "east": {"uv": [4.25, 0, 4.5, 7], "texture": "#0"}, "south": {"uv": [0, 0, 0.5, 7], "texture": "#0"}, "west": {"uv": [1, 0, 0.5, 7], "texture": "#0"}, - "up": {"uv": [0, 0, 0.5, 1], "texture": "#0"}, - "down": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"} + "up": {"uv": [0, 0, 0.5, 1], "texture": "#0"} } }, { "from": [0, 14, 2], "to": [2, 16, 14], "faces": { - "north": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"}, "east": {"uv": [0.5, 7, 3.5, 7.5], "texture": "#0"}, - "south": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"}, "west": {"uv": [0.5, 7, 3.5, 8], "rotation": 180, "texture": "#0"}, "up": {"uv": [0, 1, 0.5, 7], "texture": "#0"}, "down": {"uv": [0.75, 1, 1, 7], "texture": "#0"} @@ -118,9 +109,7 @@ "to": [14, 7, 2], "faces": { "north": {"uv": [1, 6, 4, 7], "texture": "#0"}, - "east": {"uv": [0, 0, 0.25, 0.5], "texture": "#missing"}, "south": {"uv": [1, 6, 4, 7], "texture": "#0"}, - "west": {"uv": [0, 0, 0.25, 0.5], "texture": "#missing"}, "up": {"uv": [1, 6, 4, 6.5], "texture": "#0"}, "down": {"uv": [1, 6, 4, 6.5], "texture": "#0"} } @@ -138,25 +127,19 @@ } }, { - "from": [1, 8, 2], - "to": [2, 10, 14], + "from": [1, 10, 2], + "to": [2, 12, 14], "faces": { - "north": {"uv": [0, 0, 0.25, 0.5], "texture": "#missing"}, - "east": {"uv": [0, 0, 3, 0.5], "texture": "#missing"}, - "south": {"uv": [0, 0, 0.25, 0.5], "texture": "#missing"}, "west": {"uv": [1, 6, 4, 7], "texture": "#0"}, "up": {"uv": [1, 6, 4, 6.5], "rotation": 90, "texture": "#0"}, "down": {"uv": [1, 6, 4, 6.5], "rotation": 90, "texture": "#0"} } }, { - "from": [14, 8, 2], - "to": [15, 10, 14], + "from": [14, 10, 2], + "to": [15, 12, 14], "faces": { - "north": {"uv": [0, 0, 0.25, 0.5], "texture": "#missing"}, "east": {"uv": [1, 6, 4, 7], "texture": "#0"}, - "south": {"uv": [0, 0, 0.25, 0.5], "texture": "#missing"}, - "west": {"uv": [0, 0, 3, 0.5], "texture": "#missing"}, "up": {"uv": [1, 6, 4, 6.5], "rotation": 90, "texture": "#0"}, "down": {"uv": [1, 6, 4, 6.5], "rotation": 90, "texture": "#0"} } @@ -169,8 +152,7 @@ "east": {"uv": [4.25, 0, 4.5, 7], "texture": "#0"}, "south": {"uv": [0.75, 0, 1, 7], "texture": "#0"}, "west": {"uv": [0.5, 0, 1, 7], "texture": "#0"}, - "up": {"uv": [0, 0, 0.5, 1], "texture": "#0"}, - "down": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"} + "up": {"uv": [0, 0, 0.5, 1], "texture": "#0"} } }, { @@ -194,7 +176,7 @@ "south": {"uv": [12.5, 3.5, 13, 6.5], "texture": "#0"}, "west": {"uv": [11.75, 3.5, 12.5, 6.5], "texture": "#0"}, "up": {"uv": [11.75, 2.5, 12.5, 3.5], "rotation": 90, "texture": "#0"}, - "down": {"uv": [11.75, 2.5, 12.5, 3.5], "rotation": 90, "texture": "#0"} + "down": {"uv": [12.5, 2.5, 13.25, 3.5], "rotation": 90, "texture": "#0"} } }, { @@ -213,11 +195,9 @@ "from": [3, 4, 11], "to": [7, 8, 13], "faces": { - "north": {"uv": [0, 0, 1, 1], "texture": "#missing"}, "east": {"uv": [2, 4, 2.5, 6], "texture": "#0"}, "south": {"uv": [1, 4, 2, 6], "texture": "#0"}, "west": {"uv": [2, 4, 2.5, 6], "texture": "#0"}, - "up": {"uv": [0, 0, 1, 0.5], "texture": "#missing"}, "down": {"uv": [2, 4, 2.5, 6], "rotation": 90, "texture": "#0"} } }, @@ -237,12 +217,10 @@ "from": [2, 3, 9], "to": [14, 8, 11], "faces": { - "north": {"uv": [8.75, 0.5, 11, 6.25], "texture": "#0"}, - "east": {"uv": [8.75, 0.5, 11.25, 6.25], "texture": "#0"}, - "south": {"uv": [9, 1, 11, 5.75], "texture": "#0"}, - "west": {"uv": [9, 0.5, 11, 5.75], "texture": "#0"}, - "up": {"uv": [9, 6, 11, 0.5], "texture": "#0"}, - "down": {"uv": [8.75, 0.5, 11.25, 6.5], "texture": "#0"} + "east": {"uv": [14.25, 11.75, 16, 16], "texture": "#0"}, + "south": {"uv": [14, 11.25, 16, 16], "texture": "#0"}, + "west": {"uv": [14.5, 11.75, 16, 16], "texture": "#0"}, + "down": {"uv": [14.25, 11.5, 16, 16], "texture": "#0"} } }, { diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/chemical_generator_working.json b/src/main/resources/assets/overdrive_that_matters/models/block/chemical_generator_working.json index 12bc4e40d..c7d8ecce1 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/chemical_generator_working.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/chemical_generator_working.json @@ -1,5 +1,7 @@ { + "credit": "Made with Blockbench", "parent": "block/block", + "texture_size": [64, 32], "textures": { "0": "overdrive_that_matters:block/chemical_generator", "particle": "overdrive_that_matters:block/chemical_generator" @@ -21,9 +23,7 @@ "from": [3, 1, 2], "to": [5, 2, 14], "faces": { - "north": {"uv": [0, 0, 0.5, 0.25], "texture": "#missing"}, "east": {"uv": [1, 6, 4, 6.5], "texture": "#0"}, - "south": {"uv": [0, 0, 0.5, 0.25], "texture": "#missing"}, "west": {"uv": [1, 6, 4, 6.5], "texture": "#0"}, "up": {"uv": [1, 6, 4, 7], "rotation": 90, "texture": "#0"}, "down": {"uv": [1, 6, 4, 7], "rotation": 90, "texture": "#0"} @@ -33,9 +33,7 @@ "from": [11, 1, 2], "to": [13, 2, 14], "faces": { - "north": {"uv": [0, 0, 0.5, 0.25], "texture": "#missing"}, "east": {"uv": [1, 6, 4, 6.5], "texture": "#0"}, - "south": {"uv": [0, 0, 0.5, 0.25], "texture": "#missing"}, "west": {"uv": [1, 6, 4, 6.5], "texture": "#0"}, "up": {"uv": [1, 6, 4, 7], "rotation": 90, "texture": "#0"}, "down": {"uv": [1, 6, 4, 7], "rotation": 90, "texture": "#0"} @@ -61,17 +59,14 @@ "east": {"uv": [0.5, 0, 1, 7], "texture": "#0"}, "south": {"uv": [0.5, 0, 0, 7], "texture": "#0"}, "west": {"uv": [0.25, 0, 0.5, 7], "texture": "#0"}, - "up": {"uv": [0.5, 0, 0, 1], "texture": "#0"}, - "down": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"} + "up": {"uv": [0.5, 0, 0, 1], "texture": "#0"} } }, { "from": [14, 14, 2], "to": [16, 16, 14], "faces": { - "north": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"}, "east": {"uv": [0.5, 8, 3.5, 7], "texture": "#0"}, - "south": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"}, "west": {"uv": [0.5, 7, 3.5, 7.5], "texture": "#0"}, "up": {"uv": [4.5, 1, 4, 7], "texture": "#0"}, "down": {"uv": [1, 1, 0.75, 7], "texture": "#0"} @@ -85,8 +80,7 @@ "east": {"uv": [1, 0, 0.5, 7], "texture": "#0"}, "south": {"uv": [0.75, 0, 1, 7], "texture": "#0"}, "west": {"uv": [4.25, 0, 4.5, 7], "texture": "#0"}, - "up": {"uv": [0.5, 0, 0, 1], "texture": "#0"}, - "down": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"} + "up": {"uv": [0.5, 0, 0, 1], "texture": "#0"} } }, { @@ -97,17 +91,14 @@ "east": {"uv": [4.25, 0, 4.5, 7], "texture": "#0"}, "south": {"uv": [0, 0, 0.5, 7], "texture": "#0"}, "west": {"uv": [1, 0, 0.5, 7], "texture": "#0"}, - "up": {"uv": [0, 0, 0.5, 1], "texture": "#0"}, - "down": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"} + "up": {"uv": [0, 0, 0.5, 1], "texture": "#0"} } }, { "from": [0, 14, 2], "to": [2, 16, 14], "faces": { - "north": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"}, "east": {"uv": [0.5, 7, 3.5, 7.5], "texture": "#0"}, - "south": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"}, "west": {"uv": [0.5, 7, 3.5, 8], "rotation": 180, "texture": "#0"}, "up": {"uv": [0, 1, 0.5, 7], "texture": "#0"}, "down": {"uv": [0.75, 1, 1, 7], "texture": "#0"} @@ -118,9 +109,7 @@ "to": [14, 7, 2], "faces": { "north": {"uv": [1, 6, 4, 7], "texture": "#0"}, - "east": {"uv": [0, 0, 0.25, 0.5], "texture": "#missing"}, "south": {"uv": [1, 6, 4, 7], "texture": "#0"}, - "west": {"uv": [0, 0, 0.25, 0.5], "texture": "#missing"}, "up": {"uv": [1, 6, 4, 6.5], "texture": "#0"}, "down": {"uv": [1, 6, 4, 6.5], "texture": "#0"} } @@ -138,25 +127,19 @@ } }, { - "from": [1, 8, 2], - "to": [2, 10, 14], + "from": [1, 10, 2], + "to": [2, 12, 14], "faces": { - "north": {"uv": [0, 0, 0.25, 0.5], "texture": "#missing"}, - "east": {"uv": [0, 0, 3, 0.5], "texture": "#missing"}, - "south": {"uv": [0, 0, 0.25, 0.5], "texture": "#missing"}, "west": {"uv": [1, 6, 4, 7], "texture": "#0"}, "up": {"uv": [1, 6, 4, 6.5], "rotation": 90, "texture": "#0"}, "down": {"uv": [1, 6, 4, 6.5], "rotation": 90, "texture": "#0"} } }, { - "from": [14, 8, 2], - "to": [15, 10, 14], + "from": [14, 10, 2], + "to": [15, 12, 14], "faces": { - "north": {"uv": [0, 0, 0.25, 0.5], "texture": "#missing"}, "east": {"uv": [1, 6, 4, 7], "texture": "#0"}, - "south": {"uv": [0, 0, 0.25, 0.5], "texture": "#missing"}, - "west": {"uv": [0, 0, 3, 0.5], "texture": "#missing"}, "up": {"uv": [1, 6, 4, 6.5], "rotation": 90, "texture": "#0"}, "down": {"uv": [1, 6, 4, 6.5], "rotation": 90, "texture": "#0"} } @@ -169,8 +152,7 @@ "east": {"uv": [4.25, 0, 4.5, 7], "texture": "#0"}, "south": {"uv": [0.75, 0, 1, 7], "texture": "#0"}, "west": {"uv": [0.5, 0, 1, 7], "texture": "#0"}, - "up": {"uv": [0, 0, 0.5, 1], "texture": "#0"}, - "down": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"} + "up": {"uv": [0, 0, 0.5, 1], "texture": "#0"} } }, { @@ -194,7 +176,7 @@ "south": {"uv": [12.5, 3.5, 13, 6.5], "texture": "#0"}, "west": {"uv": [11.75, 3.5, 12.5, 6.5], "texture": "#0"}, "up": {"uv": [11.75, 2.5, 12.5, 3.5], "rotation": 90, "texture": "#0"}, - "down": {"uv": [11.75, 2.5, 12.5, 3.5], "rotation": 90, "texture": "#0"} + "down": {"uv": [12.5, 2.5, 13.25, 3.5], "rotation": 90, "texture": "#0"} } }, { @@ -213,11 +195,9 @@ "from": [3, 4, 11], "to": [7, 8, 13], "faces": { - "north": {"uv": [0, 0, 1, 1], "texture": "#missing"}, "east": {"uv": [2, 4, 2.5, 6], "texture": "#0"}, "south": {"uv": [1, 4, 2, 6], "texture": "#0"}, "west": {"uv": [2, 4, 2.5, 6], "texture": "#0"}, - "up": {"uv": [0, 0, 1, 0.5], "texture": "#missing"}, "down": {"uv": [2, 4, 2.5, 6], "rotation": 90, "texture": "#0"} } }, @@ -237,12 +217,10 @@ "from": [2, 3, 9], "to": [14, 8, 11], "faces": { - "north": {"uv": [8.75, 0.5, 11, 6.25], "texture": "#0"}, - "east": {"uv": [8.75, 0.5, 11.25, 6.25], "texture": "#0"}, - "south": {"uv": [9, 1, 11, 5.75], "texture": "#0"}, - "west": {"uv": [9, 0.5, 11, 5.75], "texture": "#0"}, - "up": {"uv": [9, 6, 11, 0.5], "texture": "#0"}, - "down": {"uv": [8.75, 0.5, 11.25, 6.5], "texture": "#0"} + "east": {"uv": [14.25, 11.75, 16, 16], "texture": "#0"}, + "south": {"uv": [14, 11.25, 16, 16], "texture": "#0"}, + "west": {"uv": [14.5, 11.75, 16, 16], "texture": "#0"}, + "down": {"uv": [14.25, 11.5, 16, 16], "texture": "#0"} } }, { diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/chemical_generator.png b/src/main/resources/assets/overdrive_that_matters/textures/block/chemical_generator.png index 3f3dfc4f2efe2119fe2e0a9266c2f5b0caef92ae..3d787c187b666764ff9e70578a69203a1d3fcf9a 100644 GIT binary patch delta 624 zcmV-$0+0R21EvL#L4Q9`OjJcRH8oUJRR7oj|KLd$78bPt0RI30w?00HEiGnwgkWG` zZGw+~e}7gT9V;s@uS);`02OpnPE-H?|NsC0|NsC0 z|NsC0|NsC0|Nj6h*?sB&000SaNLh0L01mi++??#)fA*2mf%cVC-^pj9M^tk$d505;prM$#A9?FL@P{stSH zV}i6=uh%ZvZYP28S|G@p^)`d7_Lz}D#1h8L2*EXjUkgeqOxmcbHAe|oB9?I43}jHa zrlH_X2AGl3Wq(C5%YXvU;Bb%wKr2tn2#Tay znHMt%LFA84#F8%=hI;`@s7_C)bX;*R2Qx5uvp`#qn= zr|JU9x#Uuc-Lmbm3pf$n3n=zawNo&TI$p4@y$mB3_7@4MAgFsj9es8J7gVjrSS`51 z(PUICZ10Q8B%r|rQ5vD3hJc`}0)=*qW5zCs2$XZ}M+pytHp0>EOL9Deou|P5&}|FR zp#UX}5owP6rxJYm=M20I7d+iW8(M}O(-E*a#3`7%dE%5*U>t>rmtDu1Tpobal^?$etqlk($ZPRq1ANpQ& z1|l6F!*(*ZS7QQg+P1arei(++f}jC{H9>H}3U4~RQ{jR&!6ku@=cpRr5-4~fzzH5* z*c12#PzxaB(FF;3e4GTF_X zGeIuFxRk*D4}S^8oXcMmJU|~PzPVfoHh|SOl0ZTMrWBx64t~~0q?|F2pnq|JL+j~_ z1kSd=sxU!k6*1{9n*wyyntDA!5~Q9xew^6MTe#PQRKgST{k&~4m{&t6y9vJ>Z0K6mpTicN^dVcB2nI4WxAyFkJRpuDmy>SeY&FanC0}JjUL(e mQ;sD(`NIBwe)XiEjFT3#tzfmgl?rqkCxfS}pUXO@geCw?a$H6L delta 192 zcmdnQG@ogLBdb<`Pl)S8Pp$eq1wB6o1_r*8Aiv=M$biB1z?~C78O{Qa$YP*^{UFR} z!5XXr6io4SaSYK2&h5X=b-;kb`SGi5_x}99ADh!U_0s2Q&J#FpTX6p2xSZ-CrLvK` zN?B=Q^uqq`={qVkiaH)C1&4HLthkafWs~WRk2VIBkg z;eIxux%Tq$4+18ixQm!}yF1T_Ht=@tQq=34zSiZVe#q4;P0DGDE+y%)Y}w$=bGfs@ tc;j{t|2bPT`oK8B(NrS9C&V={FtEP9UQA4^prAlaP0iHQ^#21-1_p+RsD=O_#ZeOE7yKUr z816Oijht8~k>u;?;uxY4T-)y{bU=ZFCDF&||Np`XZx^UFx3AOFaoFLaG3|+G*ecbK zhe-_!Y?lj6%r7kUx+A%zVolwV8~dM#gt+&cT6K1A+;zFg?kAIQ3G?HN>VBJmwlR3R L`njxgN@xNARjopQ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/component/gravitation_field_sensor.png b/src/main/resources/assets/overdrive_that_matters/textures/item/component/gravitation_field_sensor.png index 6e11df443b537e3bf57752bd6fe1603eb871b658..a887f70407ec30ce61d30bae1a1c0db8eea92c83 100644 GIT binary patch delta 159 zcmV;Q0AT-$0+j-gQW>=X0RI309v&VwH8o&hU?wIe00010h4W#NYcG3dNklLX)iX(a% z15gjO#O(Cv0694$AtQA6o(UP@a|%yVi_}ShC=aEWhzeZzhX;v^wO&j81P7h!5WgNA5Rr^adrlDvEFb0000ZmV`IsF!4l6iB@A%(1djo%NXnn6vcTexk+58V!B)U307Q`(HQZn8okT0ZtM#-K- zv_0TqhG?z0i+gcv-=}{{59_s`q^EX2?^<24Zq1H`7V(Q}HP~wN9tpYbTD_WYp?=(% b8bw7{x3P2?fR%bwX{Y(Tuk+w|B{U?6RU-FXQ`Gv bVySLPVST7gg6XF^e7+7ClUrt!-**>i&PXnwpyVu?Y+e42y67@B>m@ zB|(0{|6zb((;1!fKvB*DkH}&M2EP3u%xJ+HtO68F_H=O!(FiW>_vAZZz`-octorBw zVbhdA(Uo=)DKnTe3soJhZ!S3Rz}4aRicyJW)wSJ*vSAJ!3Fm_kT>c<)JmK~Hh0`B) z895m6-fz=C%$R;7^@G$C&&`}lJE9Z*s>bi;t`YjkG%1`_bT;Qtkkc4EUHx3vIVCg! E0JS|(QUCw| delta 180 zcmeBUYGRt;Xek}w6XF^e7+7ClUri&PX`LPKM3=Fq-PQMMLI7@>3 zg8xGSL$H5^(8M~4f@n_{#}JL+sr`n02Mjovn;TpH@88ijVa2O3{%IC@4TAGkB+S`Q z@NH?B6}!MI;hEAojy(-R2cGLB>*_=6Am{2nh3O z)&A|8dPqEJ(NzhNg95o*%9br~7N4wEt6-GqmGJ9cdUaESYub|epUl)2_uh(IK2Px1 z{H2qEYgF$pW0P!Q?3n4Ycge-Y-+ykHS)!|2x@FQu{rsJQ^S{3T%XrL{)yKo}Ew2aA OZ492SelF{r5}E*@*k0QJ delta 221 zcmZ3+G>vJ3W4&B}Pl#(^U|@ZHeL_Nln3$NFnwqJpsr&!k1qB7>$0jf^F!<$FzXMWS zB|(0{|6zb((;1!fKvB*DkH}&M2EP3u%xJ+HtO69w_H=O!(Fl(1XXIi~e@2sv(W@3P{= z%Q?^NA6a_-lKrToaf9)|d9`Cade=hDt1tTn@74}{ky^j*(&xWh?J5me4$Oa=b_-}P NgQu&X%Q~loCIAa7SNZ?| diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/component/mirror.png b/src/main/resources/assets/overdrive_that_matters/textures/item/component/mirror.png index f3175d283971fcc9e057cafffc98fb3ea59c238c..66386cc52a1977f79ce2834ec136676e7044f0e9 100644 GIT binary patch delta 168 zcmV;Z09XI+0rmlqK`|9jOjJb{78WZjD<&o;H8nN=|Np3{r~m)}BxN|J00007bW%=J z|NsC0|Nj6QO9MucZWwG=NklOUcW4%y-Pl&6Sn3$=l>Hq)#SFBi}rl!Wgz|i$4_%D!RD+%%o28#dx&#-y_ zlKnst&H|6fVg?32Ae(PLqXlcQ3Q#cE)5S4FBe=BRQ|N#K&tWFNfB&D}O3`c&6L*^> zz$TpNSn+3rp3xgeMF|Fvg9~g|$1YU6RNR!f=WvA{YyR=FSCwY6Czjg93GY&pn0uZmWxfm3An3HSn{68`K%7R0Dza}nh6ibqwbAd_vtIn_H=h5~4M{AaAzsxz9Vp^$wYUv?e7qt~rMS56&1YQ4o@-5Q=_A7qOk>BiB RCjf0_@O1TaS?83{1OOD#LAU?_ delta 183 zcmey$_NG!^|s(HGvdcNswRge-L2Uyno4l zpa^GyM`SSr10Rshx1Z61HCP2G80zWb7@`qe+8@YwK!L+~=Ct4OmAWO;^6ylSeObDw z?S#jnx9!;%l4kBznUo~Wb#~&0YUxu^SvKyccntzC@mhRVk*LnFj_(#b!u!FKhp9)T fS%`h#d-prbk1(%_H`173oOxK`TI5A z)YO#C(vVqAfq{V`aC+rrASF-|!qtbRYmZyg9uCMoQ%stL>d!j;Bsx^npry_&1rxMTqV@duQ it~2AjUd(!_$E@53*{6I^i!cP*%;4$j=d#Wzp$Py``eNMx delta 237 zcmdnMw2WzjW4&&GPl&6Sm{?$7V10ePnwr{%RAEz7)1EJnbk1(%_H`173oOxK`TI4V z&C-xrO@V=dLEPnXHIU*j3Gxg6j{+F3+?lZuD8*Ue5n0T@z_%ZS87)|YRe*x&o-U3d z8o{~#Z-p8Zc$Bur)b0KM_*mKPObSY3X<}HDUJE!}I=Xy8Q@WGvmBojDF8Y ZhC|8h+@VXax&rNF@O1TaS?83{1OVBmU_k%? diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_sword.png b/src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_sword.png index 109c6716541f96591164482fe3d8d90017e6b3c9..5f9c6adef602ababcd42f72aebae6f7c5e1db0b4 100644 GIT binary patch delta 138 zcmV;50CoS70+Rxek$=Dd01m(bYSxJf0001BNklyp!EvQsB znlKX}0ak*@sUsjFE&?Q41xQtjaBkjUDIm_mUigcjyhOw0H3G%YM_k@ZeTWY)(FX%X s^k*7#8oy@DC~^jPvw6q2Rblo4^>7EW1J?*x00000NkvXXt^-0~g32v48vp|9DKx>3=}ce qR^~MJo4LK@4DjXS8{1Ze>JRMX2c@`B5cvQA002ovPDHLkU;%=p6grdu From ff4c24d5f6dcc971b91ecb829db408d813f38964 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 13 Apr 2023 19:23:06 +0700 Subject: [PATCH 0489/1199] Fix EMP damage not being actually dealt --- src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt index 263d542e2..dad722917 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt @@ -115,6 +115,7 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani if (attacker is Player && attacker.isCreative) { victim.matteryPlayer?.let { if (it.isAndroid) { + victim.invulnerableTime = 0 victim.hurt(EMPDamageSource(attacker), 8f) } } From f0076aca99366898a591b767438ef8ffcfa93913 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 13 Apr 2023 19:23:25 +0700 Subject: [PATCH 0490/1199] Fix EMP damage missing itemstack --- src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt index dad722917..49dc70d01 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt @@ -116,7 +116,7 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani victim.matteryPlayer?.let { if (it.isAndroid) { victim.invulnerableTime = 0 - victim.hurt(EMPDamageSource(attacker), 8f) + victim.hurt(EMPDamageSource(attacker, itemStack), 8f) } } From 8760fc3ec05d39f7cd3521dfc65babcb998c187a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 13 Apr 2023 21:07:29 +0700 Subject: [PATCH 0491/1199] Explosive Hammer --- .../datagen/advancements/AdvancementData.kt | 16 +- .../mc/otm/datagen/lang/English.kt | 11 + .../mc/otm/datagen/lang/Russian.kt | 11 + .../datagen/recipes/CraftingTableRecipes.kt | 10 + .../mc/otm/OverdriveThatMatters.java | 3 + .../dbotthepony/mc/otm/registry/MRecipes.java | 4 + .../otm/android/feature/ShockwaveFeature.kt | 4 +- .../mc/otm/block/entity/MatteryBlockEntity.kt | 35 +++ .../entity/blackhole/BlackHoleBlockEntity.kt | 31 +-- .../dbotthepony/mc/otm/config/ItemsConfig.kt | 72 ++++++ .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 8 + .../mc/otm/item/ExplosiveHammerItem.kt | 210 ++++++++++++++++++ .../recipe/ExplosiveHammerPrimingRecipe.kt | 109 +++++++++ .../mc/otm/registry/CreativeTabs.kt | 3 + .../mc/otm/registry/DamageSources.kt | 6 + .../ru/dbotthepony/mc/otm/registry/MItems.kt | 2 + .../dbotthepony/mc/otm/registry/MRegistry.kt | 5 + .../mc/otm/triggers/HurtTrigger.kt | 61 +++++ .../mc/otm/triggers/NailedEntityTrigger.kt | 8 + .../otm/triggers/ShockwaveDamageMobTrigger.kt | 59 +---- 20 files changed, 587 insertions(+), 81 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/item/ExplosiveHammerItem.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/recipe/ExplosiveHammerPrimingRecipe.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/triggers/HurtTrigger.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NailedEntityTrigger.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt index f63082661..ddee26360 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt @@ -8,7 +8,6 @@ import net.minecraft.advancements.critereon.InventoryChangeTrigger import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack import net.minecraftforge.common.data.ExistingFileHelper -import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.datagen.lang.MatteryLanguageProvider import ru.dbotthepony.mc.otm.datagen.modLocation @@ -16,6 +15,7 @@ import ru.dbotthepony.mc.otm.registry.MItemTags import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRegistry import ru.dbotthepony.mc.otm.triggers.BlackHoleTrigger +import ru.dbotthepony.mc.otm.triggers.NailedEntityTrigger import java.util.function.Consumer fun addAdvancements(serializer: Consumer, existingFileHelper: ExistingFileHelper, lang: MatteryLanguageProvider) { @@ -553,4 +553,18 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .addCriterion("essence1", criterion(MItems.ESSENCE_CAPSULE)) .addCriterion("essence2", criterion(MItems.ESSENCE_DRIVE)) .save(serializer, modLocation("regular/essence_capsule"), existingFileHelper) + + AdvancementBuilder() + .parent(root) + .display( + itemStack = ItemStack(MItems.EXPLOSIVE_HAMMER).also { MItems.EXPLOSIVE_HAMMER.prime(it) }, + title = translation.add("explosive_hammer", "I Did It Like This") { + russian("Я сделал это вот так") + }, + description = translation.add("explosive_hammer.desc", "Nail down something (or someone)") { + russian("Пригвоздите что-либо (или кого-либо)") + } + ) + .addCriterion("damage", NailedEntityTrigger.Instance()) + .save(serializer, modLocation("regular/explosive_hammer"), existingFileHelper) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index be3ad5e5f..a577a70d2 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -348,6 +348,11 @@ private fun death(provider: MatteryLanguageProvider) { death("otm_emp.player", "%2\$s blew fuzes of %1\$s") death("otm_emp.player.item", "%2\$s blew fuzes of %1\$s using %3\$s") + death(MRegistry.DAMAGE_EXPLOSIVE_HAMMER_NAME, "%1\$s's fun time with hammer is over") + death(MRegistry.DAMAGE_HAMMER_NAIL_NAME, "%1\$s got nailed") + death(MRegistry.DAMAGE_HAMMER_NAIL_NAME + ".player", "%1\$s got nailed by %\$2") + death(MRegistry.DAMAGE_HAMMER_NAIL_NAME + ".player.item", "%1\$s got nailed by %2\$s using %3\$s") + death(MRegistry.DAMAGE_EXOPACK_PROBE_ID, "%1\$s couldn't handle spinal surgery") death("${MRegistry.DAMAGE_EXOPACK_PROBE_ID}.player", "%1\$s couldn't handle spinal surgery whilst fighting %2\$s") } @@ -447,6 +452,12 @@ private fun blocks(provider: MatteryLanguageProvider) { private fun items(provider: MatteryLanguageProvider) { with(provider.english) { + add(MItems.EXPLOSIVE_HAMMER, "Explosive Hammer") + add(MItems.EXPLOSIVE_HAMMER, "desc", "For those who feel bored") + add(MItems.EXPLOSIVE_HAMMER, "primed", "Primed!") + add(MItems.EXPLOSIVE_HAMMER, "not_primed0", "Not primed") + add(MItems.EXPLOSIVE_HAMMER, "not_primed1", "Prime at crafting table with little of gunpowder and nugget payload") + add(MItems.EXOPACK_PROBE, "Exopack Probe") add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_CREATIVE, "Creative Exopack Inventory Upgrade") add(MItems.ExopackUpgrades.CRAFTING_UPGRADE, "Exopack Crafting Upgrade") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 02c856631..1e8345a1e 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -355,6 +355,11 @@ private fun death(provider: MatteryLanguageProvider) { death("otm_emp.player", "%2\$s выбил все предохранители %1\$s") death("otm_emp.player.item", "%2\$s выбил все предохранители %1\$s используя %3\$s") + death(MRegistry.DAMAGE_EXPLOSIVE_HAMMER_NAME, "Время развлечений у %1\$s с молотком подошло к концу") + death(MRegistry.DAMAGE_HAMMER_NAIL_NAME, "%1\$s был пригвождён") + death(MRegistry.DAMAGE_HAMMER_NAIL_NAME + ".player", "%1\$s был пригвождён %2\$s") + death(MRegistry.DAMAGE_HAMMER_NAIL_NAME + ".player.item", "%1\$s был пригвождён %2\$s используя %3\$s") + death(MRegistry.DAMAGE_EXOPACK_PROBE_ID, "%1\$s не выдержал спинную хирургию") death("${MRegistry.DAMAGE_EXOPACK_PROBE_ID}.player", "%1\$s не выдержал спинную хирургию пока сражался с %2\$s") } @@ -454,6 +459,12 @@ private fun blocks(provider: MatteryLanguageProvider) { private fun items(provider: MatteryLanguageProvider) { with(provider.russian) { + add(MItems.EXPLOSIVE_HAMMER, "Молоток-убийца") + add(MItems.EXPLOSIVE_HAMMER, "desc", "Для тех, кому стало скучно") + add(MItems.EXPLOSIVE_HAMMER, "primed", "Заряжен!") + add(MItems.EXPLOSIVE_HAMMER, "not_primed0", "Не заряжен") + add(MItems.EXPLOSIVE_HAMMER, "not_primed1", "Для зарядки добавьте немного пороха и наконечник-самородок") + add(MItems.EXOPACK_PROBE, "Маяк экзопака") add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_CREATIVE, "Творческое обновление инвентаря экзопака") add(MItems.ExopackUpgrades.CRAFTING_UPGRADE, "Обновление сетки крафта экзопака") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index 1c6ce2577..5369c5c2a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -15,6 +15,7 @@ import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRegistry import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.datagen.modLocation +import ru.dbotthepony.mc.otm.recipe.ExplosiveHammerPrimingRecipe import ru.dbotthepony.mc.otm.recipe.UpgradeRecipe import java.util.function.Consumer @@ -331,4 +332,13 @@ fun addCraftingTableRecipes(consumer: Consumer) { .unlockedBy(MItemTags.HARDENED_GLASS_PANES) .unlockedBy(MItemTags.TRITANIUM_INGOTS) .build(consumer) + + consumer.accept(ExplosiveHammerPrimingRecipe(modLocation("hammer_priming"), Ingredient.of(Tags.Items.NUGGETS_IRON)).finishedRecipe) + + MatteryRecipe(MItems.EXPLOSIVE_HAMMER, category = RecipeCategory.COMBAT) + .rowB(Tags.Items.INGOTS_IRON) + .rowAB(Tags.Items.INGOTS_IRON, Tags.Items.RODS_WOODEN) + .rowB(Tags.Items.RODS_WOODEN) + .unlockedBy(Items.FLINT_AND_STEEL) + .build(consumer) } diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 20ee86646..7d2d1603b 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -46,6 +46,7 @@ import ru.dbotthepony.mc.otm.config.ServerCompatConfig; import ru.dbotthepony.mc.otm.config.ServerConfig; import ru.dbotthepony.mc.otm.config.ToolsConfig; import ru.dbotthepony.mc.otm.core.math.Decimal; +import ru.dbotthepony.mc.otm.item.ExplosiveHammerItem; import ru.dbotthepony.mc.otm.item.ItemTritaniumArmor; import ru.dbotthepony.mc.otm.item.QuantumBatteryItem; import ru.dbotthepony.mc.otm.item.weapon.AbstractWeaponItem; @@ -191,6 +192,8 @@ public final class OverdriveThatMatters { EVENT_BUS.addListener(EventPriority.NORMAL, EnderTeleporterFeature.Companion::onEntityDeath); EVENT_BUS.addListener(EventPriority.HIGH, ItemTritaniumArmor.Companion::onHurt); + EVENT_BUS.addListener(EventPriority.NORMAL, ExplosiveHammerItem.Companion::onLeftClickBlock); + MatteryPlayerNetworkChannel.INSTANCE.register(); MenuNetworkChannel.INSTANCE.register(); WeaponNetworkChannel.INSTANCE.register(); diff --git a/src/main/java/ru/dbotthepony/mc/otm/registry/MRecipes.java b/src/main/java/ru/dbotthepony/mc/otm/registry/MRecipes.java index f7a72fec6..9652761e5 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/registry/MRecipes.java +++ b/src/main/java/ru/dbotthepony/mc/otm/registry/MRecipes.java @@ -9,6 +9,7 @@ import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import ru.dbotthepony.mc.otm.OverdriveThatMatters; import ru.dbotthepony.mc.otm.recipe.EnergyContainerRecipe; +import ru.dbotthepony.mc.otm.recipe.ExplosiveHammerPrimingRecipe; import ru.dbotthepony.mc.otm.recipe.PlatePressRecipe; import ru.dbotthepony.mc.otm.recipe.PlatePressRecipeFactory; import ru.dbotthepony.mc.otm.recipe.UpgradeRecipe; @@ -30,6 +31,7 @@ public class MRecipes { public static final MatteryRecipeType PLATE_PRESS = new MatteryRecipeType<>(OverdriveThatMatters.loc(MNames.PLATE_PRESS)); public static final MatteryRecipeType ENERGY_CONTAINER = new MatteryRecipeType<>(OverdriveThatMatters.loc("energy_container")); public static final MatteryRecipeType UPGRADE = new MatteryRecipeType<>(OverdriveThatMatters.loc("upgrade")); + public static final MatteryRecipeType HAMMER_PRIMING = new MatteryRecipeType<>(OverdriveThatMatters.loc("hammer_priming")); private static final DeferredRegister> serializerRegistry = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, OverdriveThatMatters.MOD_ID); private static final DeferredRegister> typeRegistry = DeferredRegister.create(ForgeRegistries.RECIPE_TYPES, OverdriveThatMatters.MOD_ID); @@ -38,10 +40,12 @@ public class MRecipes { serializerRegistry.register(MNames.PLATE_PRESS, () -> PlatePressRecipeFactory.INSTANCE); serializerRegistry.register(ENERGY_CONTAINER.name.getPath(), () -> EnergyContainerRecipe.Companion); serializerRegistry.register(UPGRADE.name.getPath(), () -> UpgradeRecipe.Companion); + serializerRegistry.register(HAMMER_PRIMING.name.getPath(), () -> ExplosiveHammerPrimingRecipe.Companion); typeRegistry.register(MNames.PLATE_PRESS, () -> PLATE_PRESS); typeRegistry.register(ENERGY_CONTAINER.name.getPath(), () -> ENERGY_CONTAINER); typeRegistry.register(UPGRADE.name.getPath(), () -> UPGRADE); + typeRegistry.register(HAMMER_PRIMING.name.getPath(), () -> HAMMER_PRIMING); } public static void register(IEventBus bus) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt index 70b6605e9..15b574090 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt @@ -140,7 +140,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF entity.deltaMovement += (entity.position - ply.position).normalize() * (multiplier * 3.0) if (ply is ServerPlayer) { - ShockwaveDamageMobTrigger.trigger(ply as ServerPlayer, entity, source, damage) + ShockwaveDamageMobTrigger.trigger(ply as ServerPlayer, entity, damage, source) } } @@ -156,7 +156,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF entity.deltaMovement += (entity.position - ply.position).normalize() * (multiplier * 3.0) if (ply is ServerPlayer) { - ShockwaveDamageMobTrigger.trigger(ply as ServerPlayer, entity, source, damage) + ShockwaveDamageMobTrigger.trigger(ply as ServerPlayer, entity, damage, source) } } else { entity.deltaMovement += (entity.position - ply.position).normalize() * (multiplier * 6.0) 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 b3b4f491f..1d3ef857c 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 @@ -23,6 +23,8 @@ import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.level.chunk.LevelChunk +import net.minecraft.world.phys.Vec3 import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.INBTSerializable @@ -59,6 +61,7 @@ import ru.dbotthepony.mc.otm.onceServer import java.lang.ref.WeakReference import java.util.* import java.util.function.Supplier +import java.util.stream.Stream import kotlin.properties.ReadWriteProperty import kotlin.reflect.KProperty import kotlin.reflect.KProperty0 @@ -730,6 +733,38 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc private val vec2Dir = Int2ObjectOpenHashMap() + /** + * Returns stream of players watching (tracking) specified [chunkPos] in [level] + */ + fun watchingPlayers(chunkPos: Long, level: Level): Stream { + if (level !is ServerLevel) + return Stream.empty() + + val subs = playerMap[level] ?: return Stream.empty() + val chunk = subs[chunkPos] ?: return Stream.empty() + return chunk.players.stream() + } + + /** + * Returns stream of players watching (tracking) specified [chunkPos] in [level] + */ + fun watchingPlayers(chunkPos: ChunkPos, level: Level) = watchingPlayers(chunkPos.toLong(), level) + + /** + * Returns stream of players watching (tracking) specified [blockPos] in [level] + */ + fun watchingPlayers(blockPos: BlockPos, level: Level) = watchingPlayers(ChunkPos(blockPos), level) + + /** + * Returns stream of players watching (tracking) specified [blockPos] in [level] + */ + fun watchingPlayers(blockPos: Vec3, level: Level) = watchingPlayers(ChunkPos.asLong(SectionPos.blockToSectionCoord(blockPos.x), SectionPos.blockToSectionCoord(blockPos.z)), level) + + /** + * Returns stream of players watching (tracking) specified [chunk] + */ + fun watchingPlayers(chunk: LevelChunk) = watchingPlayers(chunk.pos, chunk.level) + private fun vecKey(value: Vec3i): Int { if (value.x !in -1 .. 1) return -1 if (value.y !in -1 .. 1) return -1 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 e95438428..4f04495ea 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 @@ -21,6 +21,8 @@ import ru.dbotthepony.mc.otm.block.BlackHoleBlock import ru.dbotthepony.mc.otm.block.entity.tech.GravitationStabilizerBlockEntity import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.block.entity.blackhole.ExplosionQueue.Companion.queueForLevel +import ru.dbotthepony.mc.otm.core.getExplosionResistance +import ru.dbotthepony.mc.otm.core.gracefulBlockBreak import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -101,7 +103,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery if (setByRemote) { updateMass() } - }) + }).property fun stabilizerAttached(stabilizer: GravitationStabilizerBlockEntity) { if (stabilizer in stabilizers) @@ -162,10 +164,10 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery nbt["spin_direction"] = spinDirection } - override fun load(tag: CompoundTag) { - super.load(tag) - mass = tag.map("mass", Decimal::deserializeNBT) ?: BASELINE_MASS - spinDirection = tag.getBoolean("spin_direction") + override fun load(nbt: CompoundTag) { + super.load(nbt) + mass = nbt.map("mass", Decimal::deserializeNBT) ?: BASELINE_MASS + spinDirection = nbt.getBoolean("spin_direction") } var affectedBounds = BoundingBox(0, 0, 0, 1, 1, 1) @@ -176,7 +178,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery private fun setDeltaMovement(living: Entity, center: Vec3, distance: Double, weaker: Boolean) { //final double mult = Math.min(2, (30 * this.gravitation_strength) / Math.max(1, Math.pow(distance, 2))); // Сила притяжения - val mult = Math.pow((1 - distance / (30 * gravitationStrength)).coerceAtLeast(0.0), 2.0) * gravitationStrength / 8 + val mult = (1 - distance / (30 * gravitationStrength)).coerceAtLeast(0.0).pow(2.0) * gravitationStrength / 8 // Притяжение к ядру val delta = living.position().vectorTo(center).normalize() @@ -291,18 +293,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery if (!getBlock.isAir && getBlock.block !is BlackHoleBlock) { val speed = getBlock.getDestroySpeed(level, pos) - val eResist = try { - getBlock.getExplosionResistance(level, pos, null) - } catch (err: NullPointerException) { - getBlock.block.explosionResistance - // Потому что возможно какой-либо мод не ожидает что Explosion == null - // особенно учитывая что интерфейс IForgeBlock не имеет @ParamsAreNonnullByDefault - // и аргумент не помечен как @Nullable - // тем самым имеет тип Explosion! который указывается как Explosion? .. Explosion!! - } catch (err: IllegalArgumentException) { - getBlock.block.explosionResistance - } - + val eResist = getBlock.getExplosionResistance(level, pos) var strengthLinear = sqrt(blockPos.distSqr(pos)) if (strengthLinear < gravitationStrength) { @@ -310,9 +301,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery } if (speed >= 0f && (speed * 2f).coerceAtLeast(eResist / 3f) < gravitationStrength * (12.0 / strengthLinear)) { - Block.dropResources(getBlock, level, pos, level.getBlockEntity(pos)) - getBlock.block.destroy(level, pos, getBlock) - level.setBlock(pos, getBlock.fluidState.createLegacyBlock(), Block.UPDATE_ALL) + level.gracefulBlockBreak(pos, getBlock) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt index 02864211c..153753a22 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt @@ -98,4 +98,76 @@ object ItemsConfig : AbstractConfig("items") { val FLUID_CAPSULE_CAPACITY: Int by builder.defineInRange("FLUID_CAPSULE_CAPACITY", 1000, 1, Int.MAX_VALUE) val FLUID_TANK_CAPACITY: Int by builder.defineInRange("FLUID_TANK_CAPACITY", 32_000, 1, Int.MAX_VALUE) + + object ExplosiveHammer { + val MAX_TRAVEL: Double by builder + .comment("Max distance, in blocks, the nail can travel", "This also dictates potential max damage nail can deal (controlled by TRAVEL_DAMAGE_MULT)") + .comment("The nail penetrate through blocks and entities, losing power in process") + .comment("The nail can not travel into unloaded chunks and will stop immediately if it does so") + .comment("The nail travels its entire path instantaneously") + .defineInRange("MAX_TRAVEL", 48.0, 0.0, Double.MAX_VALUE) + + val TRAVEL_EXPLOSION_RESIST_MULT: Double by builder + .comment("Multiplier of explosion resistance of blocks on nail path") + .comment("If explosion resistance multiplied by this is bigger than nail current force (base of MAX_TRAVEL)") + .comment("then nail movement halts, otherwise nail force is reduced by explosion resistance multiplied by this") + .comment("and block is broken (if DAMAGE_BLOCKS is true, otherwise it only acts as stopping power)") + .comment("---") + .comment("Values over 1 will make blocks more resistant to be penetrated through (and broken)") + .comment("Values below 1 will make blocks less resistant to be penetrated though (and broken)") + .comment("Value of 0 means no matter how strong block resistance is, it will be broken by nail", "(this includes bedrock!!!)") + .comment("---") + .defineInRange("TRAVEL_EXPLOSION_RESIST_MULT", 1.75, 0.0, Double.MAX_VALUE) + + val TRAVEL_DAMAGE_MULT: Double by builder + .comment("Multiplier of current nail force (base of MAX_TRAVEL) for damage values") + .comment("That is, any being on path of nail will get damaged by nail power multiplied by this") + .defineInRange("TRAVEL_DAMAGE_MULT", 0.6, 0.0, Double.MAX_VALUE) + + val TRAVEL_MAX_HEALTH_MULT: Double by builder + .comment("Multiplier of being's max health in nail path subtracted from nail force when penetrating through") + .defineInRange("TRAVEL_MAX_HEALTH_MULT", 0.4, 0.0, Double.MAX_VALUE) + + val DAMAGE_BLOCKS: Boolean by builder + .comment("Should hammer (**not** explosion) damage blocks", "Blocks damaged this way will always be dropped") + .define("DAMAGE_BLOCKS", true) + + val EXPLOSION_DAMAGE_BLOCKS: Boolean by builder + .comment("Should hammer **explosion** damage blocks") + .define("EXPLOSION_DAMAGE_BLOCKS", false) + + val FLY_OFF_CHANCE: Double by builder + .comment("Chance that hammer will fly off hands of attacker upon impact") + .defineInRange("FLY_OFF_CHANCE", 0.6, 0.0, 1.0) + + val SELF_HARM_CHANCE: Double by builder + .comment("When hammer DOES NOT fly off hands, what is chance of it damaging the user?", "(this does not account for damage because of hitting things close)", "(idiot)") + .defineInRange("SELF_HARM_CHANCE", 0.4, 0.0, 1.0) + + val SELF_HARM_MIN_DAMAGE: Double by builder + .comment("When hammer DOES NOT fly off hands, what is minimal damage it deals to the user (in half of hearts)?") + .defineInRange("SELF_HARM_MIN_DAMAGE", 2.0, 0.0, Double.MAX_VALUE) + + val SELF_HARM_MAX_DAMAGE: Double by builder + .comment("When hammer DOES NOT fly off hands, what is maximal damage it deals to the user (in half of hearts)?") + .defineInRange("SELF_HARM_MAX_DAMAGE", 10.0, 0.0, Double.MAX_VALUE) + + val FLY_OFF_DAMAGE_CHANCE: Double by builder + .comment("When hammer flies off hands, what is chance of it damaging the user?") + .defineInRange("FLY_OFF_DAMAGE_CHANCE", 0.8, 0.0, 1.0) + + val FLY_OFF_MIN_DAMAGE: Double by builder + .comment("When hammer flies off hands, what is minimal damage it deals to the user (in half of hearts)?") + .defineInRange("FLY_OFF_MIN_DAMAGE", 4.0, 0.0, Double.MAX_VALUE) + + val FLY_OFF_MAX_DAMAGE: Double by builder + .comment("When hammer flies off hands, what is maximal damage it deals to the user (in half of hearts)?") + .defineInRange("FLY_OFF_MAX_DAMAGE", 25.0, 0.0, Double.MAX_VALUE) + } + + init { + builder.push("ExplosiveHammer") + ExplosiveHammer + builder.pop() + } } 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 dfd5c2a12..1ebb97476 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -22,6 +22,8 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.level.BlockGetter +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateHolder import net.minecraft.world.level.block.state.properties.Property @@ -220,6 +222,12 @@ fun BlockState.getExplosionResistance(level: BlockGetter, pos: BlockPos): Float } } +fun Level.gracefulBlockBreak(blockPos: BlockPos, block: BlockState = getBlockState(blockPos)) { + Block.dropResources(block, this, blockPos, getBlockEntity(blockPos)) + block.block.destroy(this, blockPos, block) + setBlock(blockPos, block.fluidState.createLegacyBlock(), Block.UPDATE_ALL) +} + fun MutableCollection.addAll(elements: Iterator) { for (item in elements) { add(item) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ExplosiveHammerItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ExplosiveHammerItem.kt new file mode 100644 index 000000000..b6962151b --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ExplosiveHammerItem.kt @@ -0,0 +1,210 @@ +package ru.dbotthepony.mc.otm.item + +import it.unimi.dsi.fastutil.objects.ObjectArraySet +import net.minecraft.ChatFormatting +import net.minecraft.core.BlockPos +import net.minecraft.network.chat.Component +import net.minecraft.network.protocol.game.ClientboundExplodePacket +import net.minecraft.server.level.ServerLevel +import net.minecraft.server.level.ServerPlayer +import net.minecraft.world.InteractionHand +import net.minecraft.world.damagesource.DamageSource +import net.minecraft.world.entity.LivingEntity +import net.minecraft.world.entity.item.ItemEntity +import net.minecraft.world.entity.player.Player +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.TooltipFlag +import net.minecraft.world.level.Explosion +import net.minecraft.world.level.Level +import net.minecraft.world.phys.AABB +import net.minecraft.world.phys.Vec3 +import net.minecraftforge.common.MinecraftForge +import net.minecraftforge.event.entity.player.PlayerInteractEvent +import net.minecraftforge.event.level.BlockEvent +import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity +import ru.dbotthepony.mc.otm.config.ItemsConfig +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.getExplosionResistance +import ru.dbotthepony.mc.otm.core.gracefulBlockBreak +import ru.dbotthepony.mc.otm.core.math.component1 +import ru.dbotthepony.mc.otm.core.math.component2 +import ru.dbotthepony.mc.otm.core.math.component3 +import ru.dbotthepony.mc.otm.core.math.plus +import ru.dbotthepony.mc.otm.core.math.times +import ru.dbotthepony.mc.otm.core.math.toDoubleVector +import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.core.position +import ru.dbotthepony.mc.otm.core.tagNotNull +import ru.dbotthepony.mc.otm.registry.HammerNailDamageSource +import ru.dbotthepony.mc.otm.registry.MRegistry +import ru.dbotthepony.mc.otm.triggers.NailedEntityTrigger + +class ExplosiveHammerItem(durability: Int = 64) : Item(Properties().stacksTo(1).fireResistant().durability(durability)) { + override fun canBeHurtBy(pDamageSource: DamageSource): Boolean { + return super.canBeHurtBy(pDamageSource) && !pDamageSource.isExplosion + } + + fun isPrimed(itemStack: ItemStack): Boolean { + return itemStack.tag?.getBoolean("primed") ?: false + } + + fun prime(itemStack: ItemStack) { + itemStack.tagNotNull["primed"] = true + } + + fun unprime(itemStack: ItemStack) { + if (isPrimed(itemStack)) + itemStack.tagNotNull["primed"] = false + } + + private val aabb = AABB(-0.1, -0.1, -0.1, 0.1, 0.1, 0.1) + + fun attackAt(itemStack: ItemStack, attacker: LivingEntity, pos: Vec3, aim: Vec3, hand: InteractionHand) { + if (!isPrimed(itemStack) || attacker.level.isClientSide) + return + + val (ex, ey, ez) = pos + + // взрыв в месте удара молотком + val exp = Explosion(attacker.level, attacker, ex, ey, ez, 1f, false, if (ItemsConfig.ExplosiveHammer.EXPLOSION_DAMAGE_BLOCKS) Explosion.BlockInteraction.DESTROY_WITH_DECAY else Explosion.BlockInteraction.KEEP) + exp.explode() + exp.finalizeExplosion(true) + + if (!ItemsConfig.ExplosiveHammer.EXPLOSION_DAMAGE_BLOCKS) + exp.clearToBlow() + + val level = attacker.level as ServerLevel + + val hitEntities = ObjectArraySet() + hitEntities.add(attacker) + var canTravel = ItemsConfig.ExplosiveHammer.MAX_TRAVEL + var rayPos = pos + var lastBlockPos: BlockPos? = null + + // "полёт" гвоздя + // так как у меня алгоритм "своеобразный", я изобрету велосипед ибо я такой нехороший и непослушный + // Трассировка луча используя наивный метод + while (canTravel > 0.0) { + val blockPos = BlockPos(rayPos) + + if (blockPos != lastBlockPos) { + if (!level.hasChunkAt(blockPos)) break + + val block = level.getBlockState(blockPos) + + if (!block.isAir) { + val resist = block.getExplosionResistance(level, blockPos) * ItemsConfig.ExplosiveHammer.TRAVEL_EXPLOSION_RESIST_MULT + + if (resist >= 0.0) { + if (resist <= canTravel) { + canTravel -= resist + val cond = ItemsConfig.ExplosiveHammer.DAMAGE_BLOCKS && + (attacker !is Player || level.mayInteract(attacker, blockPos) && !MinecraftForge.EVENT_BUS.post(BlockEvent.BreakEvent(level, blockPos, block, attacker))) + + if (cond) { + level.gracefulBlockBreak(blockPos, block) + } + } else { + break + } + } + } + + lastBlockPos = blockPos + } + + val rayBox = aabb.move(rayPos) + val entities = level.getEntities(null, rayBox) { it is LivingEntity && it.isAlive && !it.isSpectator && hitEntities.add(it) } as List + val damageSource = HammerNailDamageSource(attacker, itemStack) + + for (it in entities) { + val damage = canTravel * ItemsConfig.ExplosiveHammer.TRAVEL_DAMAGE_MULT + canTravel -= it.maxHealth * ItemsConfig.ExplosiveHammer.TRAVEL_MAX_HEALTH_MULT + + it.hurt(damageSource, damage.toFloat()) + + if (attacker is ServerPlayer) { + NailedEntityTrigger.trigger(attacker, it, damage.toFloat(), damageSource) + } + } + + val delta = canTravel.coerceAtMost(0.25) + canTravel -= delta + rayPos += aim * delta + } + + MatteryBlockEntity.watchingPlayers(pos, attacker.level) + .filter { it.position.distanceTo(pos) <= 64.0 } + .forEach { + it.connection.send(ClientboundExplodePacket(ex, ey, ez, 1f, exp.toBlow, exp.hitPlayers[it])) + } + + if (attacker !is Player || !attacker.isCreative) { + unprime(itemStack) + + itemStack.hurtAndBreak(1, attacker) { + it.broadcastBreakEvent(hand) + } + + if (!itemStack.isEmpty && attacker.random.nextDouble() <= ItemsConfig.ExplosiveHammer.FLY_OFF_CHANCE) { + attacker.setItemInHand(hand, ItemStack.EMPTY) + + val (x, y, z) = attacker.position + val entity = ItemEntity(attacker.level, x, y, z, itemStack) + + val (xv, yv, zv) = attacker.getViewVector(0f) + + entity.deltaMovement = Vec3( + attacker.random.nextDouble() * xv * -0.5, + attacker.random.nextDouble() * yv * -0.5, + (attacker.random.nextDouble() + 0.65) * zv * -2.0, + ) + + attacker.level.addFreshEntity(entity) + + if (attacker.random.nextDouble() <= ItemsConfig.ExplosiveHammer.FLY_OFF_DAMAGE_CHANCE) { + attacker.invulnerableTime = 0 + val dmg = ItemsConfig.ExplosiveHammer.FLY_OFF_MIN_DAMAGE + attacker.random.nextDouble() * (ItemsConfig.ExplosiveHammer.FLY_OFF_MAX_DAMAGE - ItemsConfig.ExplosiveHammer.FLY_OFF_MIN_DAMAGE) + attacker.hurt(MRegistry.DAMAGE_EXPLOSIVE_HAMMER, dmg.toFloat()) + } + } else if (attacker.random.nextDouble() <= ItemsConfig.ExplosiveHammer.SELF_HARM_CHANCE) { + attacker.invulnerableTime = 0 + val dmg = ItemsConfig.ExplosiveHammer.SELF_HARM_MIN_DAMAGE + attacker.random.nextDouble() * (ItemsConfig.ExplosiveHammer.SELF_HARM_MAX_DAMAGE - ItemsConfig.ExplosiveHammer.SELF_HARM_MIN_DAMAGE) + attacker.hurt(MRegistry.DAMAGE_EXPLOSIVE_HAMMER, dmg.toFloat()) + } + } + } + + override fun hurtEnemy(pStack: ItemStack, pTarget: LivingEntity, pAttacker: LivingEntity): Boolean { + val aim = pAttacker.getViewVector(0f) + val pos = pAttacker.eyePosition + aim * pTarget.position.distanceTo(pAttacker.position) + attackAt(pStack, pAttacker, pos, aim, InteractionHand.MAIN_HAND) + return true + } + + override fun appendHoverText(pStack: ItemStack, pLevel: Level?, pTooltipComponents: MutableList, pIsAdvanced: TooltipFlag) { + super.appendHoverText(pStack, pLevel, pTooltipComponents, pIsAdvanced) + + pTooltipComponents.add(TranslatableComponent("$descriptionId.desc").withStyle(ChatFormatting.DARK_GRAY)) + + if (isPrimed(pStack)) { + pTooltipComponents.add(TranslatableComponent("$descriptionId.primed").withStyle(ChatFormatting.GRAY)) + } else { + pTooltipComponents.add(TranslatableComponent("$descriptionId.not_primed0").withStyle(ChatFormatting.GRAY)) + pTooltipComponents.add(TranslatableComponent("$descriptionId.not_primed1").withStyle(ChatFormatting.GRAY)) + } + } + + companion object { + fun onLeftClickBlock(event: PlayerInteractEvent.LeftClickBlock) { + val item = event.itemStack.item + + if (item is ExplosiveHammerItem) { + val (x, y, z) = event.pos + item.attackAt(event.itemStack, event.entity, Vec3(x + 0.5, y + 0.5, z + 0.5), event.face?.opposite?.normal?.toDoubleVector() ?: event.entity.getViewVector(0f), event.hand) + event.isCanceled = true + } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/ExplosiveHammerPrimingRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/ExplosiveHammerPrimingRecipe.kt new file mode 100644 index 000000000..925c5f3f1 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/ExplosiveHammerPrimingRecipe.kt @@ -0,0 +1,109 @@ +package ru.dbotthepony.mc.otm.recipe + +import com.google.gson.JsonObject +import com.google.gson.JsonSyntaxException +import net.minecraft.core.NonNullList +import net.minecraft.data.recipes.FinishedRecipe +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 +import net.minecraft.world.level.Level +import net.minecraftforge.common.Tags +import ru.dbotthepony.mc.otm.container.stream +import ru.dbotthepony.mc.otm.core.isActuallyEmpty +import ru.dbotthepony.mc.otm.core.isNotEmpty +import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.item.ExplosiveHammerItem +import ru.dbotthepony.mc.otm.registry.MItems + +class ExplosiveHammerPrimingRecipe(private val _id: ResourceLocation, val payload: Ingredient) : CraftingRecipe { + override fun isIncomplete(): Boolean { + return payload.isActuallyEmpty + } + + override fun getId(): ResourceLocation { + return _id + } + + override fun isSpecial(): Boolean { + return true + } + + override fun matches(pContainer: CraftingContainer, pLevel: Level): Boolean { + val result = pContainer.stream().filter { it.isNotEmpty }.toList() + if (result.size != 3) return false + return result.any { it.item is ExplosiveHammerItem } && + result.any { it.`is`(Tags.Items.GUNPOWDER) } && + result.any { payload.test(it) } + } + + override fun assemble(pContainer: CraftingContainer): ItemStack { + val hammer = pContainer.stream().filter { it.isNotEmpty && it.item is ExplosiveHammerItem }.findAny() + if (hammer.isEmpty) return ItemStack.EMPTY + + return hammer.orElseThrow().copyWithCount(1).also { + (it.item as ExplosiveHammerItem).prime(it) + } + } + + override fun canCraftInDimensions(pWidth: Int, pHeight: Int): Boolean { + return pWidth * pHeight >= 3 + } + + override fun getResultItem(): ItemStack { + return ItemStack.EMPTY + } + + override fun getSerializer(): RecipeSerializer<*> { + return Companion + } + + 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) + } + + val finishedRecipe = object : FinishedRecipe { + override fun serializeRecipeData(pJson: JsonObject) { + pJson["payload"] = payload.toJson() + } + + override fun getId(): ResourceLocation { + return _id + } + + override fun getType(): RecipeSerializer<*> { + return Companion + } + + override fun serializeAdvancement(): JsonObject? { + return null + } + + override fun getAdvancementId(): ResourceLocation? { + return null + } + } + + companion object : RecipeSerializer { + override fun fromJson(pRecipeId: ResourceLocation, pSerializedRecipe: JsonObject): ExplosiveHammerPrimingRecipe { + return ExplosiveHammerPrimingRecipe(pRecipeId, Ingredient.fromJson(pSerializedRecipe["payload"] ?: throw JsonSyntaxException("Missing `payload` from hammer priming recipe in $pRecipeId"))) + } + + override fun fromNetwork(pRecipeId: ResourceLocation, pBuffer: FriendlyByteBuf): ExplosiveHammerPrimingRecipe { + return ExplosiveHammerPrimingRecipe(pRecipeId, Ingredient.fromNetwork(pBuffer)) + } + + override fun toNetwork(pBuffer: FriendlyByteBuf, pRecipe: ExplosiveHammerPrimingRecipe) { + pRecipe.payload.toNetwork(pBuffer) + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt index ea350bfa5..f97a70b1c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt @@ -146,6 +146,9 @@ internal fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { energized(MItems.ENERGY_SWORD) energized(MItems.PLASMA_RIFLE) + accept(MItems.EXPLOSIVE_HAMMER) + accept(ItemStack(MItems.EXPLOSIVE_HAMMER).also { MItems.EXPLOSIVE_HAMMER.prime(it) }) + accept(MItems.BLACK_HOLE_SCANNER) accept(MItems.GRAVITATION_FIELD_LIMITER) accept(MItems.GRAVITATION_FIELD_SENSOR) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/DamageSources.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/DamageSources.kt index 64b91e687..356944726 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/DamageSources.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/DamageSources.kt @@ -184,3 +184,9 @@ class PlasmaDamageSource(entity: Entity? = null, inflictor: ItemStack? = null) : return false } } + +class HammerNailDamageSource(entity: Entity? = null, inflictor: ItemStack? = null) : MatteryDamageSource(MRegistry.DAMAGE_HAMMER_NAIL_NAME, entity, inflictor) { + override fun scalesWithDifficulty(): Boolean { + return false + } +} 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 d9853eece..307590f22 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -215,6 +215,8 @@ object MItems { ::TRITANIUM_BOOTS ) + val EXPLOSIVE_HAMMER: ExplosiveHammerItem by registry.register("explosive_hammer") { ExplosiveHammerItem() } + val ENERGY_SWORD: Item by registry.register(MNames.ENERGY_SWORD) { EnergySwordItem() } val PLASMA_RIFLE: Item by registry.register(MNames.PLASMA_RIFLE) { PlasmaRifleItem() } 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 002eb701a..7e7eae7b2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -44,6 +44,7 @@ import ru.dbotthepony.mc.otm.triggers.BecomeHumaneTrigger import ru.dbotthepony.mc.otm.triggers.BlackHoleTrigger import ru.dbotthepony.mc.otm.triggers.EnderTeleporterFallDeathTrigger import ru.dbotthepony.mc.otm.triggers.FallDampenersSaveTrigger +import ru.dbotthepony.mc.otm.triggers.NailedEntityTrigger import ru.dbotthepony.mc.otm.triggers.NanobotsArmorTrigger import ru.dbotthepony.mc.otm.triggers.ShockwaveDamageMobTrigger import ru.dbotthepony.mc.otm.triggers.ShockwaveTrigger @@ -195,6 +196,8 @@ object MRegistry { const val DAMAGE_SHOCKWAVE_NAME = "otm_shockwave" const val DAMAGE_PLASMA_NAME = "otm_plasma" const val DAMAGE_COSMIC_RAYS_NAME = "otm_cosmic_rays" + const val DAMAGE_EXPLOSIVE_HAMMER_NAME = "otm_explosive_hammer" + const val DAMAGE_HAMMER_NAIL_NAME = "otm_hammer_nail" val DAMAGE_EXOPACK_PROBE = ImmutableDamageSource(DamageSource(DAMAGE_EXOPACK_PROBE_ID).bypassArmor().bypassMagic()) @@ -203,6 +206,7 @@ object MRegistry { val DAMAGE_EVENT_HORIZON = ImmutableDamageSource(DamageSource(DAMAGE_EVENT_HORIZON_ID).bypassMagic().bypassArmor()) val DAMAGE_HAWKING_RADIATION = ImmutableDamageSource(DamageSource(DAMAGE_HAWKING_RADIATION_ID)) val DAMAGE_COSMIC_RAYS = ImmutableDamageSource(DamageSource(DAMAGE_COSMIC_RAYS_NAME).bypassArmor().bypassMagic()) + val DAMAGE_EXPLOSIVE_HAMMER = ImmutableDamageSource(DamageSource(DAMAGE_EXPLOSIVE_HAMMER_NAME)) val DAMAGE_EMP: DamageSource = ImmutableDamageSource(EMPDamageSource()) @@ -270,6 +274,7 @@ object MRegistry { CriteriaTriggers.register(EnderTeleporterFallDeathTrigger) CriteriaTriggers.register(KillAsAndroidTrigger) CriteriaTriggers.register(AndroidTravelUnderwater) + CriteriaTriggers.register(NailedEntityTrigger) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/HurtTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/HurtTrigger.kt new file mode 100644 index 000000000..73705d8fd --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/HurtTrigger.kt @@ -0,0 +1,61 @@ +package ru.dbotthepony.mc.otm.triggers + +import com.google.gson.JsonObject +import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance +import net.minecraft.advancements.critereon.DamagePredicate +import net.minecraft.advancements.critereon.DamageSourcePredicate +import net.minecraft.advancements.critereon.DeserializationContext +import net.minecraft.advancements.critereon.EntityPredicate +import net.minecraft.advancements.critereon.MinMaxBounds +import net.minecraft.advancements.critereon.SerializationContext +import net.minecraft.advancements.critereon.SimpleCriterionTrigger +import net.minecraft.resources.ResourceLocation +import net.minecraft.server.level.ServerPlayer +import net.minecraft.world.damagesource.DamageSource +import net.minecraft.world.entity.LivingEntity +import ru.dbotthepony.mc.otm.core.set + +abstract class HurtTrigger : SimpleCriterionTrigger() { + abstract val ID: ResourceLocation + + override fun getId(): ResourceLocation { + return ID + } + + override fun createInstance( + p_66248_: JsonObject, + p_66249_: EntityPredicate.Composite, + p_66250_: DeserializationContext + ): Instance { + return Instance( + EntityPredicate.Composite.fromJson(p_66248_, "entity_predicate", p_66250_), + (p_66248_["damage"] as? JsonObject)?.let(DamagePredicate::fromJson) ?: DamagePredicate.ANY + ) + } + + fun trigger(player: ServerPlayer, entity: LivingEntity, damage: Float, damageSource: DamageSource) { + val context = EntityPredicate.createContext(player, entity) + + trigger(player) { + it.predicate.matches(context) && it.damagePredicate.matches(player, damageSource, damage, damage, false) + } + } + + inner class Instance( + val predicate: EntityPredicate.Composite = EntityPredicate.Composite.ANY, + val damagePredicate: DamagePredicate = DamagePredicate( + MinMaxBounds.Doubles.atLeast(1.0), + MinMaxBounds.Doubles.atLeast(1.0), + EntityPredicate.ANY, + null, + DamageSourcePredicate.ANY + ) + ) : AbstractCriterionTriggerInstance(ID, EntityPredicate.Composite.ANY) { + override fun serializeToJson(pConditions: SerializationContext): JsonObject { + return super.serializeToJson(pConditions).also { + it["entity_predicate"] = predicate.toJson(pConditions) + it["damage"] = damagePredicate.serializeToJson() + } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NailedEntityTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NailedEntityTrigger.kt new file mode 100644 index 000000000..dfe36bca3 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NailedEntityTrigger.kt @@ -0,0 +1,8 @@ +package ru.dbotthepony.mc.otm.triggers + +import net.minecraft.resources.ResourceLocation +import ru.dbotthepony.mc.otm.OverdriveThatMatters + +object NailedEntityTrigger : HurtTrigger() { + override val ID = ResourceLocation(OverdriveThatMatters.MOD_ID, "hammer_nail_damage") +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ShockwaveDamageMobTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ShockwaveDamageMobTrigger.kt index e50e2a58c..55808cc84 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ShockwaveDamageMobTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ShockwaveDamageMobTrigger.kt @@ -1,63 +1,8 @@ package ru.dbotthepony.mc.otm.triggers -import com.google.gson.JsonObject -import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance -import net.minecraft.advancements.critereon.DamagePredicate -import net.minecraft.advancements.critereon.DamageSourcePredicate -import net.minecraft.advancements.critereon.DeserializationContext -import net.minecraft.advancements.critereon.EntityPredicate -import net.minecraft.advancements.critereon.MinMaxBounds -import net.minecraft.advancements.critereon.SerializationContext -import net.minecraft.advancements.critereon.SimpleCriterionTrigger import net.minecraft.resources.ResourceLocation -import net.minecraft.server.level.ServerPlayer -import net.minecraft.world.damagesource.DamageSource -import net.minecraft.world.entity.Entity import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.core.set -object ShockwaveDamageMobTrigger: SimpleCriterionTrigger() { - val ID = ResourceLocation(OverdriveThatMatters.MOD_ID, "shockwave_damage_mob") - - override fun getId(): ResourceLocation { - return ID - } - - override fun createInstance( - p_66248_: JsonObject, - p_66249_: EntityPredicate.Composite, - p_66250_: DeserializationContext - ): Instance { - return Instance( - EntityPredicate.Composite.fromJson(p_66248_, "entity_predicate", p_66250_), - (p_66248_["damage"] as? JsonObject)?.let(DamagePredicate::fromJson) ?: DamagePredicate.ANY - ) - } - - fun trigger(player: ServerPlayer, entity: Entity, damageSource: DamageSource, damage: Float) { - val context = EntityPredicate.createContext(player, entity) - - trigger(player) { - it.predicate.matches(context) && it.damagePredicate.matches(player, damageSource, damage, damage, false) - } - } - - class Instance( - val predicate: EntityPredicate.Composite = EntityPredicate.Composite.ANY, - val damagePredicate: DamagePredicate = DamagePredicate( - MinMaxBounds.Doubles.atLeast(1.0), - MinMaxBounds.Doubles.atLeast(1.0), - EntityPredicate.ANY, - null, - DamageSourcePredicate.ANY - ) - ) : AbstractCriterionTriggerInstance(ID, EntityPredicate.Composite.ANY) { - override fun serializeToJson(p_16979_: SerializationContext): JsonObject { - return super.serializeToJson(p_16979_).also { - it["entity_predicate"] = predicate.toJson(p_16979_) - it["damage"] = damagePredicate.serializeToJson() - } - } - } +object ShockwaveDamageMobTrigger : HurtTrigger() { + override val ID = ResourceLocation(OverdriveThatMatters.MOD_ID, "shockwave_damage_mob") } From 951df4a7d1474a6d33cec0cdb2b531aed935f554 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Thu, 13 Apr 2023 21:06:39 +0600 Subject: [PATCH 0492/1199] explosive hammer model --- .../models/item/explosive_hammer.json | 22 ++ .../item/explosive_hammer_inventory.json | 6 + .../models/item/explosive_hammer_primed.json | 277 ++++++++++++++++++ .../item/explosive_hammer_unprimed.json | 277 ++++++++++++++++++ .../models/item/hammer.json | 277 ++++++++++++++++++ .../textures/item/explosive_hammer_item.png | Bin 0 -> 301 bytes .../textures/item/hammer.png | Bin 0 -> 448 bytes 7 files changed, 859 insertions(+) create mode 100644 src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_inventory.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_primed.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_unprimed.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/item/hammer.json create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/explosive_hammer_item.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/hammer.png diff --git a/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer.json b/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer.json new file mode 100644 index 000000000..07d693f16 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer.json @@ -0,0 +1,22 @@ +{ + "loader": "forge:separate_transforms", + "gui_light": "front", + "base": + { + "parent": "overdrive_that_matters:item/explosive_hammer_unprimed" + }, + "perspectives": { + "gui": { + "parent": "overdrive_that_matters:item/explosive_hammer_inventory" + }, + "fixed": { + "parent": "overdrive_that_matters:item/explosive_hammer_inventory" + }, + "ground": { + "parent": "overdrive_that_matters:item/explosive_hammer_inventory" + } + }, + "overrides": [ + { "predicate": { "overdrive_that_matters:is_primed": 1.0 }, "model": "overdrive_that_matters:item/explosive_hammer_primed" } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_inventory.json b/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_inventory.json new file mode 100644 index 000000000..1d7322469 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_inventory.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "overdrive_that_matters:item/explosive_hammer_item" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_primed.json b/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_primed.json new file mode 100644 index 000000000..dcf1e2b51 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_primed.json @@ -0,0 +1,277 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [32, 32], + "textures": { + "0": "overdrive_that_matters:item/hammer", + "particle": "overdrive_that_matters:item/hammer" + }, + "elements": [ + { + "from": [7, 0, 7], + "to": [9, 2, 9], + "faces": { + "north": {"uv": [2, 10, 3, 11], "texture": "#0"}, + "east": {"uv": [2, 10, 3, 11], "texture": "#0"}, + "south": {"uv": [2, 10, 3, 11], "texture": "#0"}, + "west": {"uv": [2, 10, 3, 11], "texture": "#0"}, + "up": {"uv": [4, 10, 5, 11], "texture": "#0"}, + "down": {"uv": [3, 10, 4, 11], "texture": "#0"} + } + }, + { + "from": [7, 14, 7], + "to": [9, 20, 9], + "faces": { + "north": {"uv": [9.5, 3, 10.5, 6], "texture": "#0"}, + "east": {"uv": [11.5, 3, 10.5, 6], "texture": "#0"}, + "south": {"uv": [11.5, 3, 12.5, 6], "texture": "#0"}, + "west": {"uv": [10.5, 3, 11.5, 6], "texture": "#0"}, + "down": {"uv": [4.75, 6, 5.25, 7], "texture": "#0"} + } + }, + { + "from": [7, 20, 1], + "to": [9, 23, 13], + "faces": { + "north": {"uv": [8, 7, 9.5, 10], "texture": "#0"}, + "east": {"uv": [11.5, 0, 5.5, 1.5], "texture": "#0"}, + "south": {"uv": [13, 1, 14, 2.5], "texture": "#0"}, + "west": {"uv": [5.5, 0, 11.5, 1.5], "texture": "#0"}, + "up": {"uv": [0, 12, 6, 13], "rotation": 90, "texture": "#0"}, + "down": {"uv": [7, 1.5, 13, 2.5], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [7.5, 2, 7.5], + "to": [8.5, 14, 8.5], + "faces": { + "north": {"uv": [0, 6.5, 6, 7], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 6.5, 6, 7], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 6.5, 6, 7], "rotation": 90, "texture": "#0"}, + "west": {"uv": [0, 6.5, 6, 7], "rotation": 90, "texture": "#0"} + } + }, + { + "from": [7.5, 8, 9.5], + "to": [8.5, 20, 10.5], + "faces": { + "north": {"uv": [0, 11.5, 6, 12], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 11.5, 6, 12], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 11.5, 6, 12], "rotation": 90, "texture": "#0"}, + "west": {"uv": [0, 11.5, 6, 12], "rotation": 90, "texture": "#0"}, + "down": {"uv": [6, 11.5, 6.5, 12], "texture": "#0"} + } + }, + { + "from": [7.5, 12, 8.5], + "to": [8.5, 13, 9.5], + "faces": { + "east": {"uv": [2.5, 3.5, 3, 4], "texture": "#0"}, + "west": {"uv": [2.5, 3, 3, 3.5], "texture": "#0"}, + "up": {"uv": [2, 3, 2.5, 3.5], "texture": "#0"}, + "down": {"uv": [2, 3.5, 2.5, 4], "texture": "#0"} + } + }, + { + "from": [6, 18, 0], + "to": [10, 21, 3], + "faces": { + "north": {"uv": [0, 8.5, 2, 10], "texture": "#0"}, + "east": {"uv": [3.5, 8.5, 2, 10], "texture": "#0"}, + "south": {"uv": [2, 7, 4, 8.5], "texture": "#0"}, + "west": {"uv": [2, 8.5, 3.5, 10], "texture": "#0"}, + "up": {"uv": [0, 7, 2, 8.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [0, 10, 2, 11.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [6, 22, 0], + "to": [10, 25, 3], + "faces": { + "north": {"uv": [0, 1.5, 2, 3], "texture": "#0"}, + "east": {"uv": [3.5, 1.5, 2, 3], "texture": "#0"}, + "south": {"uv": [2, 0, 4, 1.5], "texture": "#0"}, + "west": {"uv": [2, 1.5, 3.5, 3], "texture": "#0"}, + "up": {"uv": [0, 0, 2, 1.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [0, 3, 2, 4.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [6.5, 22, 6], + "to": [9.5, 24, 10], + "faces": { + "east": {"uv": [7.5, 4.5, 5.5, 5.5], "texture": "#0"}, + "south": {"uv": [7.5, 4.5, 9, 5.5], "texture": "#0"}, + "west": {"uv": [5.5, 4.5, 7.5, 5.5], "texture": "#0"}, + "up": {"uv": [5.5, 3, 7.5, 4.5], "rotation": 90, "texture": "#0"}, + "down": {"uv": [7.5, 3, 9.5, 4.5], "texture": "#0"} + } + }, + { + "from": [7.1, 13.6, 9.1], + "to": [8.9, 19.6, 10.9], + "faces": { + "north": {"uv": [0, 5.05, 3, 5.95], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 5.05, 3, 5.95], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 5.05, 3, 5.95], "rotation": 90, "texture": "#0"}, + "west": {"uv": [0, 5.05, 3, 5.95], "rotation": 90, "texture": "#0"}, + "up": {"uv": [3.025, 5.05, 3.975, 5.95], "texture": "#0"}, + "down": {"uv": [3.025, 5.05, 3.975, 5.95], "texture": "#0"} + } + }, + { + "from": [7, 16, 9], + "to": [7, 17, 11], + "faces": { + "east": {"uv": [2, 4, 3, 4.5], "texture": "#0"}, + "west": {"uv": [2, 4, 3, 4.5], "texture": "#0"} + } + }, + { + "from": [7, 18, 9], + "to": [7, 19, 11], + "faces": { + "east": {"uv": [2, 4, 3, 4.5], "texture": "#0"}, + "west": {"uv": [2, 4, 3, 4.5], "texture": "#0"} + } + }, + { + "from": [9, 16, 9], + "to": [9, 17, 11], + "faces": { + "east": {"uv": [2, 4, 3, 4.5], "texture": "#0"}, + "west": {"uv": [2, 4, 3, 4.5], "texture": "#0"} + } + }, + { + "from": [9, 18, 9], + "to": [9, 19, 11], + "faces": { + "east": {"uv": [2, 4, 3, 4.5], "texture": "#0"}, + "west": {"uv": [2, 4, 3, 4.5], "texture": "#0"} + } + }, + { + "from": [10, 21.1, 5], + "to": [10, 22.1, 14], + "faces": { + "east": {"uv": [9, 5.5, 4.5, 6], "texture": "#0"}, + "west": {"uv": [4.5, 5.5, 9, 6], "texture": "#0"} + } + }, + { + "from": [6, 21.1, 5], + "to": [6, 22.1, 14], + "faces": { + "east": {"uv": [9, 5.5, 4.5, 6], "texture": "#0"}, + "west": {"uv": [4.5, 5.5, 9, 6], "texture": "#0"} + } + }, + { + "from": [6, 21.1, 14], + "to": [10, 22.1, 14], + "faces": { + "north": {"uv": [0, 4.5, 2, 5], "texture": "#0"}, + "south": {"uv": [0, 4.5, 2, 5], "texture": "#0"} + } + }, + { + "from": [7, 18, 11], + "to": [9, 19, 11], + "faces": { + "north": {"uv": [2, 4, 3, 4.5], "texture": "#0"}, + "south": {"uv": [2, 4, 3, 4.5], "texture": "#0"} + } + }, + { + "from": [7, 16, 11], + "to": [9, 17, 11], + "faces": { + "north": {"uv": [2, 4, 3, 4.5], "texture": "#0"}, + "south": {"uv": [2, 4, 3, 4.5], "texture": "#0"} + } + }, + { + "from": [6, 25.1, 4], + "to": [10, 25.1, 5], + "faces": { + "up": {"uv": [0, 6, 2, 6.5], "texture": "#0"}, + "down": {"uv": [0, 6, 2, 6.5], "texture": "#0"} + } + }, + { + "from": [6, 21.1, 4], + "to": [6, 25.1, 5], + "faces": { + "east": {"uv": [4, 4.5, 4.5, 6.5], "texture": "#0"}, + "west": {"uv": [4, 4.5, 4.5, 6.5], "texture": "#0"} + } + }, + { + "from": [10, 21.1, 4], + "to": [10, 25.1, 5], + "faces": { + "east": {"uv": [4, 4.5, 4.5, 6.5], "texture": "#0"}, + "west": {"uv": [4, 4.5, 4.5, 6.5], "texture": "#0"} + } + }, + { + "from": [7, 17, 2], + "to": [9, 19, 6], + "faces": { + "north": {"uv": [0, 13, 1, 14], "texture": "#0"}, + "east": {"uv": [1, 14, 3, 15], "texture": "#0"}, + "south": {"uv": [3, 13, 4, 14], "texture": "#0"}, + "west": {"uv": [3, 13, 1, 14], "texture": "#0"}, + "down": {"uv": [1, 14, 3, 15], "rotation": 90, "texture": "#0"} + } + }, + { + "from": [6.5, 22, 3], + "to": [9.5, 25, 6], + "faces": { + "north": {"uv": [5.5, 1.5, 7, 3], "texture": "#0"}, + "east": {"uv": [5.5, 1.5, 4, 3], "texture": "#0"}, + "south": {"uv": [5.5, 1.5, 7, 3], "texture": "#0"}, + "west": {"uv": [4, 1.5, 5.5, 3], "texture": "#0"}, + "up": {"uv": [4, 0, 5.5, 1.5], "texture": "#0"}, + "down": {"uv": [4, 3, 5.5, 4.5], "texture": "#0"} + } + }, + { + "from": [6.5, 18, 3], + "to": [9.5, 21, 7], + "faces": { + "north": {"uv": [4.5, 7, 6, 8.5], "texture": "#0"}, + "east": {"uv": [5.5, 8.5, 3.5, 10], "texture": "#0"}, + "south": {"uv": [4.5, 7, 6, 8.5], "texture": "#0"}, + "west": {"uv": [3.5, 8.5, 5.5, 10], "texture": "#0"}, + "up": {"uv": [4, 7, 6, 8.5], "rotation": 270, "texture": "#0"}, + "down": {"uv": [5.5, 8.5, 7.5, 10], "rotation": 270, "texture": "#0"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [0, 0, -1], + "translation": [0, 0.5, 0] + }, + "thirdperson_lefthand": { + "translation": [0, 0.5, 0] + }, + "ground": { + "rotation": [29, 0, 0], + "translation": [0, 2, -0.75], + "scale": [0.5, 0.5, 0.5] + }, + "gui": { + "rotation": [-17, 143, 39], + "translation": [-2, -3.25, 0], + "scale": [0.76, 0.76, 0.76] + }, + "fixed": { + "rotation": [0, 90, 0], + "translation": [0, -4, 0] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_unprimed.json b/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_unprimed.json new file mode 100644 index 000000000..5d00f54fc --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_unprimed.json @@ -0,0 +1,277 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [32, 32], + "textures": { + "0": "overdrive_that_matters:item/hammer", + "particle": "overdrive_that_matters:item/hammer" + }, + "elements": [ + { + "from": [7, 0, 7], + "to": [9, 2, 9], + "faces": { + "north": {"uv": [2, 10, 3, 11], "texture": "#0"}, + "east": {"uv": [2, 10, 3, 11], "texture": "#0"}, + "south": {"uv": [2, 10, 3, 11], "texture": "#0"}, + "west": {"uv": [2, 10, 3, 11], "texture": "#0"}, + "up": {"uv": [4, 10, 5, 11], "texture": "#0"}, + "down": {"uv": [3, 10, 4, 11], "texture": "#0"} + } + }, + { + "from": [7, 14, 7], + "to": [9, 20, 9], + "faces": { + "north": {"uv": [9.5, 3, 10.5, 6], "texture": "#0"}, + "east": {"uv": [11.5, 3, 10.5, 6], "texture": "#0"}, + "south": {"uv": [11.5, 3, 12.5, 6], "texture": "#0"}, + "west": {"uv": [10.5, 3, 11.5, 6], "texture": "#0"}, + "down": {"uv": [4.75, 6, 5.25, 7], "texture": "#0"} + } + }, + { + "from": [7, 20, 1], + "to": [9, 23, 13], + "faces": { + "north": {"uv": [8, 7, 9.5, 10], "texture": "#0"}, + "east": {"uv": [11.5, 0, 5.5, 1.5], "texture": "#0"}, + "south": {"uv": [13, 1, 14, 2.5], "texture": "#0"}, + "west": {"uv": [5.5, 0, 11.5, 1.5], "texture": "#0"}, + "up": {"uv": [0, 12, 6, 13], "rotation": 90, "texture": "#0"}, + "down": {"uv": [7, 1.5, 13, 2.5], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [7.5, 2, 7.5], + "to": [8.5, 14, 8.5], + "faces": { + "north": {"uv": [0, 6.5, 6, 7], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 6.5, 6, 7], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 6.5, 6, 7], "rotation": 90, "texture": "#0"}, + "west": {"uv": [0, 6.5, 6, 7], "rotation": 90, "texture": "#0"} + } + }, + { + "from": [7.5, 8, 9.5], + "to": [8.5, 20, 10.5], + "faces": { + "north": {"uv": [0, 11.5, 6, 12], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 11.5, 6, 12], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 11.5, 6, 12], "rotation": 90, "texture": "#0"}, + "west": {"uv": [0, 11.5, 6, 12], "rotation": 90, "texture": "#0"}, + "down": {"uv": [6, 11.5, 6.5, 12], "texture": "#0"} + } + }, + { + "from": [7.5, 12, 8.5], + "to": [8.5, 13, 9.5], + "faces": { + "east": {"uv": [2.5, 3.5, 3, 4], "texture": "#0"}, + "west": {"uv": [2.5, 3, 3, 3.5], "texture": "#0"}, + "up": {"uv": [2, 3, 2.5, 3.5], "texture": "#0"}, + "down": {"uv": [2, 3.5, 2.5, 4], "texture": "#0"} + } + }, + { + "from": [6, 17.1, 0], + "to": [10, 20.1, 3], + "faces": { + "north": {"uv": [0, 8.5, 2, 10], "texture": "#0"}, + "east": {"uv": [3.5, 8.5, 2, 10], "texture": "#0"}, + "south": {"uv": [2, 7, 4, 8.5], "texture": "#0"}, + "west": {"uv": [2, 8.5, 3.5, 10], "texture": "#0"}, + "up": {"uv": [0, 7, 2, 8.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [0, 10, 2, 11.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [6, 23, 0], + "to": [10, 26, 3], + "faces": { + "north": {"uv": [0, 1.5, 2, 3], "texture": "#0"}, + "east": {"uv": [3.5, 1.5, 2, 3], "texture": "#0"}, + "south": {"uv": [2, 0, 4, 1.5], "texture": "#0"}, + "west": {"uv": [2, 1.5, 3.5, 3], "texture": "#0"}, + "up": {"uv": [0, 0, 2, 1.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [0, 3, 2, 4.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [6.5, 22, 6], + "to": [9.5, 24, 10], + "faces": { + "east": {"uv": [7.5, 4.5, 5.5, 5.5], "texture": "#0"}, + "south": {"uv": [7.5, 4.5, 9, 5.5], "texture": "#0"}, + "west": {"uv": [5.5, 4.5, 7.5, 5.5], "texture": "#0"}, + "up": {"uv": [5.5, 3, 7.5, 4.5], "rotation": 90, "texture": "#0"}, + "down": {"uv": [7.5, 3, 9.5, 4.5], "texture": "#0"} + } + }, + { + "from": [7.1, 13.6, 9.1], + "to": [8.9, 19.6, 10.9], + "faces": { + "north": {"uv": [0, 5.05, 3, 5.95], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 5.05, 3, 5.95], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 5.05, 3, 5.95], "rotation": 90, "texture": "#0"}, + "west": {"uv": [0, 5.05, 3, 5.95], "rotation": 90, "texture": "#0"}, + "up": {"uv": [3.025, 5.05, 3.975, 5.95], "texture": "#0"}, + "down": {"uv": [3.025, 5.05, 3.975, 5.95], "texture": "#0"} + } + }, + { + "from": [7, 16, 9], + "to": [7, 17, 11], + "faces": { + "east": {"uv": [2, 4, 3, 4.5], "texture": "#0"}, + "west": {"uv": [2, 4, 3, 4.5], "texture": "#0"} + } + }, + { + "from": [7, 18, 9], + "to": [7, 19, 11], + "faces": { + "east": {"uv": [2, 4, 3, 4.5], "texture": "#0"}, + "west": {"uv": [2, 4, 3, 4.5], "texture": "#0"} + } + }, + { + "from": [9, 16, 9], + "to": [9, 17, 11], + "faces": { + "east": {"uv": [2, 4, 3, 4.5], "texture": "#0"}, + "west": {"uv": [2, 4, 3, 4.5], "texture": "#0"} + } + }, + { + "from": [9, 18, 9], + "to": [9, 19, 11], + "faces": { + "east": {"uv": [2, 4, 3, 4.5], "texture": "#0"}, + "west": {"uv": [2, 4, 3, 4.5], "texture": "#0"} + } + }, + { + "from": [10, 21.1, 5], + "to": [10, 22.1, 14], + "faces": { + "east": {"uv": [9, 5.5, 4.5, 6], "texture": "#0"}, + "west": {"uv": [4.5, 5.5, 9, 6], "texture": "#0"} + } + }, + { + "from": [6, 21.1, 5], + "to": [6, 22.1, 14], + "faces": { + "east": {"uv": [9, 5.5, 4.5, 6], "texture": "#0"}, + "west": {"uv": [4.5, 5.5, 9, 6], "texture": "#0"} + } + }, + { + "from": [6, 21.1, 14], + "to": [10, 22.1, 14], + "faces": { + "north": {"uv": [0, 4.5, 2, 5], "texture": "#0"}, + "south": {"uv": [0, 4.5, 2, 5], "texture": "#0"} + } + }, + { + "from": [7, 18, 11], + "to": [9, 19, 11], + "faces": { + "north": {"uv": [2, 4, 3, 4.5], "texture": "#0"}, + "south": {"uv": [2, 4, 3, 4.5], "texture": "#0"} + } + }, + { + "from": [7, 16, 11], + "to": [9, 17, 11], + "faces": { + "north": {"uv": [2, 4, 3, 4.5], "texture": "#0"}, + "south": {"uv": [2, 4, 3, 4.5], "texture": "#0"} + } + }, + { + "from": [6, 25.1, 4], + "to": [10, 25.1, 5], + "faces": { + "up": {"uv": [0, 6, 2, 6.5], "texture": "#0"}, + "down": {"uv": [0, 6, 2, 6.5], "texture": "#0"} + } + }, + { + "from": [6, 21.1, 4], + "to": [6, 25.1, 5], + "faces": { + "east": {"uv": [4, 4.5, 4.5, 6.5], "texture": "#0"}, + "west": {"uv": [4, 4.5, 4.5, 6.5], "texture": "#0"} + } + }, + { + "from": [10, 21.1, 4], + "to": [10, 25.1, 5], + "faces": { + "east": {"uv": [4, 4.5, 4.5, 6.5], "texture": "#0"}, + "west": {"uv": [4, 4.5, 4.5, 6.5], "texture": "#0"} + } + }, + { + "from": [7, 17, 2], + "to": [9, 19, 6], + "faces": { + "north": {"uv": [0, 13, 1, 14], "texture": "#0"}, + "east": {"uv": [1, 14, 3, 15], "texture": "#0"}, + "south": {"uv": [3, 13, 4, 14], "texture": "#0"}, + "west": {"uv": [3, 13, 1, 14], "texture": "#0"}, + "down": {"uv": [1, 14, 3, 15], "rotation": 90, "texture": "#0"} + } + }, + { + "from": [6.5, 22, 3], + "to": [9.5, 25, 6], + "faces": { + "north": {"uv": [5.5, 1.5, 7, 3], "texture": "#0"}, + "east": {"uv": [5.5, 1.5, 4, 3], "texture": "#0"}, + "south": {"uv": [5.5, 1.5, 7, 3], "texture": "#0"}, + "west": {"uv": [4, 1.5, 5.5, 3], "texture": "#0"}, + "up": {"uv": [4, 0, 5.5, 1.5], "texture": "#0"}, + "down": {"uv": [4, 3, 5.5, 4.5], "texture": "#0"} + } + }, + { + "from": [6.5, 18, 3], + "to": [9.5, 21, 7], + "faces": { + "north": {"uv": [4.5, 7, 6, 8.5], "texture": "#0"}, + "east": {"uv": [5.5, 8.5, 3.5, 10], "texture": "#0"}, + "south": {"uv": [4.5, 7, 6, 8.5], "texture": "#0"}, + "west": {"uv": [3.5, 8.5, 5.5, 10], "texture": "#0"}, + "up": {"uv": [4, 7, 6, 8.5], "rotation": 270, "texture": "#0"}, + "down": {"uv": [5.5, 8.5, 7.5, 10], "rotation": 270, "texture": "#0"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [0, 0, -1], + "translation": [0, 0.5, 0] + }, + "thirdperson_lefthand": { + "translation": [0, 0.5, 0] + }, + "ground": { + "rotation": [29, 0, 0], + "translation": [0, 2, -0.75], + "scale": [0.5, 0.5, 0.5] + }, + "gui": { + "rotation": [-17, 143, 39], + "translation": [-2, -3.25, 0], + "scale": [0.76, 0.76, 0.76] + }, + "fixed": { + "rotation": [0, 90, 0], + "translation": [0, -4, 0] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/item/hammer.json b/src/main/resources/assets/overdrive_that_matters/models/item/hammer.json new file mode 100644 index 000000000..5d00f54fc --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/item/hammer.json @@ -0,0 +1,277 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [32, 32], + "textures": { + "0": "overdrive_that_matters:item/hammer", + "particle": "overdrive_that_matters:item/hammer" + }, + "elements": [ + { + "from": [7, 0, 7], + "to": [9, 2, 9], + "faces": { + "north": {"uv": [2, 10, 3, 11], "texture": "#0"}, + "east": {"uv": [2, 10, 3, 11], "texture": "#0"}, + "south": {"uv": [2, 10, 3, 11], "texture": "#0"}, + "west": {"uv": [2, 10, 3, 11], "texture": "#0"}, + "up": {"uv": [4, 10, 5, 11], "texture": "#0"}, + "down": {"uv": [3, 10, 4, 11], "texture": "#0"} + } + }, + { + "from": [7, 14, 7], + "to": [9, 20, 9], + "faces": { + "north": {"uv": [9.5, 3, 10.5, 6], "texture": "#0"}, + "east": {"uv": [11.5, 3, 10.5, 6], "texture": "#0"}, + "south": {"uv": [11.5, 3, 12.5, 6], "texture": "#0"}, + "west": {"uv": [10.5, 3, 11.5, 6], "texture": "#0"}, + "down": {"uv": [4.75, 6, 5.25, 7], "texture": "#0"} + } + }, + { + "from": [7, 20, 1], + "to": [9, 23, 13], + "faces": { + "north": {"uv": [8, 7, 9.5, 10], "texture": "#0"}, + "east": {"uv": [11.5, 0, 5.5, 1.5], "texture": "#0"}, + "south": {"uv": [13, 1, 14, 2.5], "texture": "#0"}, + "west": {"uv": [5.5, 0, 11.5, 1.5], "texture": "#0"}, + "up": {"uv": [0, 12, 6, 13], "rotation": 90, "texture": "#0"}, + "down": {"uv": [7, 1.5, 13, 2.5], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [7.5, 2, 7.5], + "to": [8.5, 14, 8.5], + "faces": { + "north": {"uv": [0, 6.5, 6, 7], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 6.5, 6, 7], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 6.5, 6, 7], "rotation": 90, "texture": "#0"}, + "west": {"uv": [0, 6.5, 6, 7], "rotation": 90, "texture": "#0"} + } + }, + { + "from": [7.5, 8, 9.5], + "to": [8.5, 20, 10.5], + "faces": { + "north": {"uv": [0, 11.5, 6, 12], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 11.5, 6, 12], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 11.5, 6, 12], "rotation": 90, "texture": "#0"}, + "west": {"uv": [0, 11.5, 6, 12], "rotation": 90, "texture": "#0"}, + "down": {"uv": [6, 11.5, 6.5, 12], "texture": "#0"} + } + }, + { + "from": [7.5, 12, 8.5], + "to": [8.5, 13, 9.5], + "faces": { + "east": {"uv": [2.5, 3.5, 3, 4], "texture": "#0"}, + "west": {"uv": [2.5, 3, 3, 3.5], "texture": "#0"}, + "up": {"uv": [2, 3, 2.5, 3.5], "texture": "#0"}, + "down": {"uv": [2, 3.5, 2.5, 4], "texture": "#0"} + } + }, + { + "from": [6, 17.1, 0], + "to": [10, 20.1, 3], + "faces": { + "north": {"uv": [0, 8.5, 2, 10], "texture": "#0"}, + "east": {"uv": [3.5, 8.5, 2, 10], "texture": "#0"}, + "south": {"uv": [2, 7, 4, 8.5], "texture": "#0"}, + "west": {"uv": [2, 8.5, 3.5, 10], "texture": "#0"}, + "up": {"uv": [0, 7, 2, 8.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [0, 10, 2, 11.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [6, 23, 0], + "to": [10, 26, 3], + "faces": { + "north": {"uv": [0, 1.5, 2, 3], "texture": "#0"}, + "east": {"uv": [3.5, 1.5, 2, 3], "texture": "#0"}, + "south": {"uv": [2, 0, 4, 1.5], "texture": "#0"}, + "west": {"uv": [2, 1.5, 3.5, 3], "texture": "#0"}, + "up": {"uv": [0, 0, 2, 1.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [0, 3, 2, 4.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [6.5, 22, 6], + "to": [9.5, 24, 10], + "faces": { + "east": {"uv": [7.5, 4.5, 5.5, 5.5], "texture": "#0"}, + "south": {"uv": [7.5, 4.5, 9, 5.5], "texture": "#0"}, + "west": {"uv": [5.5, 4.5, 7.5, 5.5], "texture": "#0"}, + "up": {"uv": [5.5, 3, 7.5, 4.5], "rotation": 90, "texture": "#0"}, + "down": {"uv": [7.5, 3, 9.5, 4.5], "texture": "#0"} + } + }, + { + "from": [7.1, 13.6, 9.1], + "to": [8.9, 19.6, 10.9], + "faces": { + "north": {"uv": [0, 5.05, 3, 5.95], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 5.05, 3, 5.95], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 5.05, 3, 5.95], "rotation": 90, "texture": "#0"}, + "west": {"uv": [0, 5.05, 3, 5.95], "rotation": 90, "texture": "#0"}, + "up": {"uv": [3.025, 5.05, 3.975, 5.95], "texture": "#0"}, + "down": {"uv": [3.025, 5.05, 3.975, 5.95], "texture": "#0"} + } + }, + { + "from": [7, 16, 9], + "to": [7, 17, 11], + "faces": { + "east": {"uv": [2, 4, 3, 4.5], "texture": "#0"}, + "west": {"uv": [2, 4, 3, 4.5], "texture": "#0"} + } + }, + { + "from": [7, 18, 9], + "to": [7, 19, 11], + "faces": { + "east": {"uv": [2, 4, 3, 4.5], "texture": "#0"}, + "west": {"uv": [2, 4, 3, 4.5], "texture": "#0"} + } + }, + { + "from": [9, 16, 9], + "to": [9, 17, 11], + "faces": { + "east": {"uv": [2, 4, 3, 4.5], "texture": "#0"}, + "west": {"uv": [2, 4, 3, 4.5], "texture": "#0"} + } + }, + { + "from": [9, 18, 9], + "to": [9, 19, 11], + "faces": { + "east": {"uv": [2, 4, 3, 4.5], "texture": "#0"}, + "west": {"uv": [2, 4, 3, 4.5], "texture": "#0"} + } + }, + { + "from": [10, 21.1, 5], + "to": [10, 22.1, 14], + "faces": { + "east": {"uv": [9, 5.5, 4.5, 6], "texture": "#0"}, + "west": {"uv": [4.5, 5.5, 9, 6], "texture": "#0"} + } + }, + { + "from": [6, 21.1, 5], + "to": [6, 22.1, 14], + "faces": { + "east": {"uv": [9, 5.5, 4.5, 6], "texture": "#0"}, + "west": {"uv": [4.5, 5.5, 9, 6], "texture": "#0"} + } + }, + { + "from": [6, 21.1, 14], + "to": [10, 22.1, 14], + "faces": { + "north": {"uv": [0, 4.5, 2, 5], "texture": "#0"}, + "south": {"uv": [0, 4.5, 2, 5], "texture": "#0"} + } + }, + { + "from": [7, 18, 11], + "to": [9, 19, 11], + "faces": { + "north": {"uv": [2, 4, 3, 4.5], "texture": "#0"}, + "south": {"uv": [2, 4, 3, 4.5], "texture": "#0"} + } + }, + { + "from": [7, 16, 11], + "to": [9, 17, 11], + "faces": { + "north": {"uv": [2, 4, 3, 4.5], "texture": "#0"}, + "south": {"uv": [2, 4, 3, 4.5], "texture": "#0"} + } + }, + { + "from": [6, 25.1, 4], + "to": [10, 25.1, 5], + "faces": { + "up": {"uv": [0, 6, 2, 6.5], "texture": "#0"}, + "down": {"uv": [0, 6, 2, 6.5], "texture": "#0"} + } + }, + { + "from": [6, 21.1, 4], + "to": [6, 25.1, 5], + "faces": { + "east": {"uv": [4, 4.5, 4.5, 6.5], "texture": "#0"}, + "west": {"uv": [4, 4.5, 4.5, 6.5], "texture": "#0"} + } + }, + { + "from": [10, 21.1, 4], + "to": [10, 25.1, 5], + "faces": { + "east": {"uv": [4, 4.5, 4.5, 6.5], "texture": "#0"}, + "west": {"uv": [4, 4.5, 4.5, 6.5], "texture": "#0"} + } + }, + { + "from": [7, 17, 2], + "to": [9, 19, 6], + "faces": { + "north": {"uv": [0, 13, 1, 14], "texture": "#0"}, + "east": {"uv": [1, 14, 3, 15], "texture": "#0"}, + "south": {"uv": [3, 13, 4, 14], "texture": "#0"}, + "west": {"uv": [3, 13, 1, 14], "texture": "#0"}, + "down": {"uv": [1, 14, 3, 15], "rotation": 90, "texture": "#0"} + } + }, + { + "from": [6.5, 22, 3], + "to": [9.5, 25, 6], + "faces": { + "north": {"uv": [5.5, 1.5, 7, 3], "texture": "#0"}, + "east": {"uv": [5.5, 1.5, 4, 3], "texture": "#0"}, + "south": {"uv": [5.5, 1.5, 7, 3], "texture": "#0"}, + "west": {"uv": [4, 1.5, 5.5, 3], "texture": "#0"}, + "up": {"uv": [4, 0, 5.5, 1.5], "texture": "#0"}, + "down": {"uv": [4, 3, 5.5, 4.5], "texture": "#0"} + } + }, + { + "from": [6.5, 18, 3], + "to": [9.5, 21, 7], + "faces": { + "north": {"uv": [4.5, 7, 6, 8.5], "texture": "#0"}, + "east": {"uv": [5.5, 8.5, 3.5, 10], "texture": "#0"}, + "south": {"uv": [4.5, 7, 6, 8.5], "texture": "#0"}, + "west": {"uv": [3.5, 8.5, 5.5, 10], "texture": "#0"}, + "up": {"uv": [4, 7, 6, 8.5], "rotation": 270, "texture": "#0"}, + "down": {"uv": [5.5, 8.5, 7.5, 10], "rotation": 270, "texture": "#0"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [0, 0, -1], + "translation": [0, 0.5, 0] + }, + "thirdperson_lefthand": { + "translation": [0, 0.5, 0] + }, + "ground": { + "rotation": [29, 0, 0], + "translation": [0, 2, -0.75], + "scale": [0.5, 0.5, 0.5] + }, + "gui": { + "rotation": [-17, 143, 39], + "translation": [-2, -3.25, 0], + "scale": [0.76, 0.76, 0.76] + }, + "fixed": { + "rotation": [0, 90, 0], + "translation": [0, -4, 0] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/explosive_hammer_item.png b/src/main/resources/assets/overdrive_that_matters/textures/item/explosive_hammer_item.png new file mode 100644 index 0000000000000000000000000000000000000000..4da2c27a03220afe251b09a050e805347496bcb6 GIT binary patch literal 301 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}r0G|-oGiT2H|Np?Amp8 z=b4%Ub=1v%RSu;1OM?7@fx3_Y!<9QT76PR>3p^r=85sBufiR<}hF1enFwfJ)F+?NS z^<1>jQ3Vd>fEt&TZ&UxD-YdB9sHD2(uf~WT7q1CHuQ=;I@7;3kBh&qhZS|frc%8qp z&bCs2%Dg&s{pw($9NrhxSiVVjH8xx=v}c>g{N_`I)drFMFZkX}t3CYgen;W)6LyED eD!nuO&Ajq6x5}y`#acj{89ZJ6T-G@yGywo3Pjhkr literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/hammer.png b/src/main/resources/assets/overdrive_that_matters/textures/item/hammer.png new file mode 100644 index 0000000000000000000000000000000000000000..d4277032f19add4ac08f1ac78b4e23d9a45f5291 GIT binary patch literal 448 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyjKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCikd1AIbUXLdOs+Y%lU5~8iG{r~^}_wV1Enwl0B6>Yb(n`dfzW1q$U`%X8C zRQ|VX19d1`=062e{3Stt!9c}GfZ@uW84H0@oCO|{#S9F5he4R}c>anMpd%PPT^vI! z{Cg*L3pE>Xun3!Up8xaz`8Pg~nkyS)({oxy1$lZU7N1Z^P}q9VWe;bG4R0b#`+^+_ z)3}m(rcPbwCmd8IKFPyNF~p9|K7NHllYNeI#{O?=z8g9?EmsE|2-SGH)Jf2BSJ)hl zhErTRt6DghWX@Z|v2xBe#WMgra-qq$};p8{bDgTp-Li3j6)_MiM zt~DIDzP;`3?{#-8pR{prlbo9#Kj9+l?`!_QcYf$k`0-U-vAF-|&%7q{1rNgc|0wVI d?7ZSD^CEX8{|=3SC}0RNc)I$ztaD0e0syBOxupOA literal 0 HcmV?d00001 From bd357dad5f3c47efd104f8134e1a9a4e05ce6180 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 13 Apr 2023 22:53:54 +0700 Subject: [PATCH 0493/1199] Add is_primed property to hammer --- src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt | 5 +++++ 1 file changed, 5 insertions(+) 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 7e7eae7b2..5071cb617 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -286,6 +286,7 @@ object MRegistry { 0f } } + ItemProperties.register(MItems.ENERGY_SWORD, ResourceLocation(OverdriveThatMatters.MOD_ID, "is_powered")) { stack, _, _, _ -> if ((stack.matteryEnergy?.batteryLevel ?: Decimal.ZERO) >= EnergySwordItem.ENERGY_PER_SWING) { 1f @@ -293,5 +294,9 @@ object MRegistry { 0f } } + + ItemProperties.register(MItems.EXPLOSIVE_HAMMER, ResourceLocation(OverdriveThatMatters.MOD_ID, "is_primed")) { stack, _, _, _ -> + if (MItems.EXPLOSIVE_HAMMER.isPrimed(stack)) 1f else 0f + } } } From 2a910d2f967cabb06f5cec23ea864d6f71ae7fb4 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Thu, 13 Apr 2023 22:28:35 +0600 Subject: [PATCH 0494/1199] OM NOM NOM --- .../models/item/explosive_hammer_unprimed.json | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_unprimed.json b/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_unprimed.json index 5d00f54fc..1d20ae8c5 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_unprimed.json +++ b/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_unprimed.json @@ -258,20 +258,6 @@ }, "thirdperson_lefthand": { "translation": [0, 0.5, 0] - }, - "ground": { - "rotation": [29, 0, 0], - "translation": [0, 2, -0.75], - "scale": [0.5, 0.5, 0.5] - }, - "gui": { - "rotation": [-17, 143, 39], - "translation": [-2, -3.25, 0], - "scale": [0.76, 0.76, 0.76] - }, - "fixed": { - "rotation": [0, 90, 0], - "translation": [0, -4, 0] } } } \ No newline at end of file From 90fa7593f8c48514af3d5435850e20ed8a1447b6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 13 Apr 2023 23:41:57 +0700 Subject: [PATCH 0495/1199] Carbon mesh recipe --- .../mc/otm/datagen/recipes/CraftingTableRecipes.kt | 6 +++--- .../mc/otm/datagen/recipes/MatteryRecipeProvider.kt | 4 ++-- .../dbotthepony/mc/otm/datagen/recipes/PlatePressRecipes.kt | 5 +++++ src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt | 1 + src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt | 1 + 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index 5369c5c2a..a802aa028 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -171,9 +171,9 @@ fun addCraftingTableRecipes(consumer: Consumer) { .build(consumer) MatteryRecipe(MItems.REINFORCED_TRITANIUM_PLATE, category = RecipeCategory.MISC) - .rowB(MItems.CARBON_MESH) - .row(MItems.CARBON_MESH, MItemTags.TRITANIUM_PLATES, MItems.CARBON_MESH) - .rowB(MItems.CARBON_MESH) + .rowB(MItemTags.CARBON_PLATES) + .row(MItemTags.CARBON_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.CARBON_PLATES) + .rowB(MItemTags.CARBON_PLATES) .unlockedBy(MItemTags.TRITANIUM_PLATES) .build(consumer) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt index 9472720e7..2ca4c8940 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt @@ -92,9 +92,9 @@ class MatteryRecipeProvider(generatorIn: DataGenerator) : RecipeProvider(generat } } - fun plate(id: String, ingredient: Ingredient, result: Ingredient, count: Int = 1, workTicks: Int = 200) { + fun plate(id: String, ingredient: Ingredient, result: Ingredient, count: Int = 1, workTicks: Int = 200, experience: FloatProvider = ConstantFloat.ZERO) { exec { it, callback -> - callback.accept(PlatePressFinishedRecipe(PlatePressRecipe(ResourceLocation(DataGen.MOD_ID, "plate_$id"), ingredient, result, count, workTicks))) + callback.accept(PlatePressFinishedRecipe(PlatePressRecipe(ResourceLocation(DataGen.MOD_ID, "plate_$id"), ingredient, result, count, workTicks, experience = experience))) } } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressRecipes.kt index 40dc88454..6843c9c04 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressRecipes.kt @@ -1,6 +1,9 @@ package ru.dbotthepony.mc.otm.datagen.recipes import net.minecraft.util.valueproviders.ConstantFloat +import net.minecraft.world.item.Items +import net.minecraft.world.item.crafting.Ingredient +import ru.dbotthepony.mc.otm.registry.MItemTags fun addPlatePressRecipes(provider: MatteryRecipeProvider) { val baselineMetals = arrayOf("iron" to 0.2f, "silver" to 0.3f, "bronze" to 0.3f, "lead" to 0.3f, "constantan" to 0.4f, "brass" to 0.3f) @@ -18,4 +21,6 @@ fun addPlatePressRecipes(provider: MatteryRecipeProvider) { for ((thing, exp) in hardMetals) { provider.plate(thing, workTicks = 240, experience = ConstantFloat.of(exp)) } + + provider.plate("carbon", result = Ingredient.of(MItemTags.CARBON_PLATES), ingredient = Ingredient.of(Items.COAL), workTicks = 140, experience = ConstantFloat.of(0.3f)) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index 0d51173e7..793ef9842 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -23,6 +23,7 @@ fun addTags(tagsProvider: TagsProvider) { tagsProvider.plates.add("tritanium", MItems.TRITANIUM_PLATE) tagsProvider.plates.add("iron", MItems.IRON_PLATE) tagsProvider.plates.add("gold", MItems.GOLD_PLATE) + tagsProvider.plates.add("carbon", MItems.CARBON_MESH) tagsProvider.items.forge("reinforced_tritanium").add(MItems.REINFORCED_TRITANIUM_PLATE) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt index a294d403f..a7d5a8e79 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt @@ -17,6 +17,7 @@ object MItemTags { val NUGGETS: TagKey = ItemTags.create(ResourceLocation("forge", "nuggets")) val TRITANIUM_INGOTS_STORAGE: TagKey = ItemTags.create(ResourceLocation("forge", "storage_blocks/tritanium")) val TRITANIUM_PLATES: TagKey = ItemTags.create(ResourceLocation("forge", "plates/tritanium")) + val CARBON_PLATES: TagKey = ItemTags.create(ResourceLocation("forge", "plates/carbon")) val REINFORCED_TRITANIUM_PLATES: TagKey = ItemTags.create(ResourceLocation("forge", "reinforced_tritanium")) val TRITANIUM_DUSTS: TagKey = ItemTags.create(ResourceLocation("forge", "dusts/tritanium")) val IRON_PLATES: TagKey = ItemTags.create(ResourceLocation("forge", "plates/iron")) From 130240e02ab70529d2be2fab698722ee35b3ec59 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 14 Apr 2023 12:59:17 +0700 Subject: [PATCH 0496/1199] Tritanium bars, but with proper model --- .../ru/dbotthepony/mc/otm/datagen/DataGen.kt | 80 +++++++++++++++++++ .../mc/otm/datagen/DecorativeData.kt | 2 +- 2 files changed, 81 insertions(+), 1 deletion(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt index f0bbc3120..20938029d 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -219,6 +219,86 @@ object DataGen { } } + private fun MatteryBlockModelProvider.bars(name: String, parent: String, texture: ResourceLocation): ModelFile { + return withExistingParent(name, "block/$parent") + .texture("bars", texture) + .texture("edge", texture) + .texture("particle", texture) + .renderType("cutout_mipped") + } + + @Suppress("LocalVariableName") + fun bars(block: Block, texture: ResourceLocation) { + val name = block.registryName?.path ?: throw IllegalStateException("Invalid state of glass pane $block") + + val cap = "${name}_cap" + val cap_alt = "${name}_cap_alt" + val post = "${name}_post" + val post_ends = "${name}_post_ends" + val side = "${name}_side" + val side_alt = "${name}_side_alt" + + var mdl_cap by Delegates.notNull() + var mdl_cap_alt by Delegates.notNull() + var mdl_post by Delegates.notNull() + var mdl_post_ends by Delegates.notNull() + var mdl_side by Delegates.notNull() + var mdl_side_alt by Delegates.notNull() + + with(blockModelProvider) { + exec { + mdl_cap = bars(cap, "iron_bars_cap", texture) + mdl_cap_alt = bars(cap_alt, "iron_bars_cap_alt", texture) + mdl_post = bars(post, "iron_bars_post", texture) + mdl_post_ends = bars(post_ends, "iron_bars_post_ends", texture) + mdl_side = bars(side, "iron_bars_side", texture) + mdl_side_alt = bars(side_alt, "iron_bars_side_alt", texture) + } + } + + @Suppress("name_shadowing") + blockStateProvider.exec { + with(blockStateProvider.getMultipartBuilder(block)) { + part().modelFile(mdl_post_ends).addModel() + + part().modelFile(mdl_post).addModel() + .condition(IronBarsBlock.EAST, false) + .condition(IronBarsBlock.WEST, false) + .condition(IronBarsBlock.NORTH, false) + .condition(IronBarsBlock.SOUTH, false) + + part().modelFile(mdl_cap).addModel() + .condition(IronBarsBlock.EAST, false) + .condition(IronBarsBlock.WEST, false) + .condition(IronBarsBlock.NORTH, true) + .condition(IronBarsBlock.SOUTH, false) + + part().modelFile(mdl_cap).rotationY(90).addModel() + .condition(IronBarsBlock.EAST, true) + .condition(IronBarsBlock.WEST, false) + .condition(IronBarsBlock.NORTH, false) + .condition(IronBarsBlock.SOUTH, false) + + part().modelFile(mdl_cap_alt).addModel() + .condition(IronBarsBlock.EAST, false) + .condition(IronBarsBlock.WEST, false) + .condition(IronBarsBlock.NORTH, false) + .condition(IronBarsBlock.SOUTH, true) + + part().modelFile(mdl_cap_alt).rotationY(90).addModel() + .condition(IronBarsBlock.EAST, false) + .condition(IronBarsBlock.WEST, true) + .condition(IronBarsBlock.NORTH, false) + .condition(IronBarsBlock.SOUTH, false) + + part().modelFile(mdl_side).addModel().condition(IronBarsBlock.NORTH, true) + part().modelFile(mdl_side).rotationY(90).addModel().condition(IronBarsBlock.EAST, true) + part().modelFile(mdl_side_alt).addModel().condition(IronBarsBlock.SOUTH, true) + part().modelFile(mdl_side_alt).rotationY(90).addModel().condition(IronBarsBlock.WEST, true) + } + } + } + fun door(block: Block, textureTop: ResourceLocation, textureBottom: ResourceLocation) { var doorBottomLeft by Delegates.notNull() var doorBottomLeftOpen by Delegates.notNull() diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt index 1b0c4dd43..bc1ecb353 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt @@ -278,7 +278,7 @@ fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelPr DataGen.pane(glass, textureSide, textureRailing) } - DataGen.pane(MBlocks.TRITANIUM_BARS, ResourceLocation(DataGen.MOD_ID,"block/decorative/tritanium_bars"), ResourceLocation(DataGen.MOD_ID,"block/decorative/tritanium_bars")) + DataGen.bars(MBlocks.TRITANIUM_BARS, ResourceLocation(DataGen.MOD_ID, "block/decorative/tritanium_bars")) blockStateProvider.block(MBlocks.ENGINE) itemModelProvider.block(MItems.ENGINE) From a51398e22053661c4af9043f5a99db42ff9e490f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 14 Apr 2023 13:06:13 +0700 Subject: [PATCH 0497/1199] Fix mattery gui tracking last mattery player state wrong --- src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index 9c2ec1590..d3f648c70 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -204,11 +204,12 @@ object MatteryGUI { if (!ply.isAlive && mattery == null) { mattery = lastState + } else if (ply.isAlive && mattery != null) { + lastState = mattery } if (mattery != null && mattery.isAndroid) { event.isCanceled = true - lastState = mattery if (event.overlay === AIR_LEVEL_ELEMENT) { return @@ -290,11 +291,12 @@ object MatteryGUI { if (!ply.isAlive && mattery == null) { mattery = lastState + } else if (ply.isAlive && mattery != null) { + lastState = mattery } if (mattery != null && mattery.isAndroid) { event.isCanceled = true - lastState = mattery if (!gui.shouldDrawSurvivalElements()) return From addd088cc456689a39f0abfce3a92a11504883d1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 14 Apr 2023 14:58:05 +0700 Subject: [PATCH 0498/1199] Sort matter json namespaces according to mod order --- .../dbotthepony/mc/otm/matter/MatterManager.kt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 662261ad6..065c99865 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -15,6 +15,7 @@ import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream import it.unimi.dsi.fastutil.objects.Object2BooleanFunction import it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap import it.unimi.dsi.fastutil.objects.Object2IntArrayMap +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet import it.unimi.dsi.fastutil.objects.Reference2BooleanFunction import it.unimi.dsi.fastutil.objects.Reference2BooleanOpenHashMap @@ -339,8 +340,21 @@ object MatterManager { val addOrReplace = ArrayList>() val update = ArrayList>() val delete = ArrayList>() + val sortedKeys = ArrayList(map.keys) + val inverse = Object2IntOpenHashMap() + inverse.defaultReturnValue(Int.MAX_VALUE) // выталкиваем неизвестные имена в самый конец + + for ((i, info) in ModList.get().mods.withIndex()) { + inverse[info.namespace] = i + } + + inverse[OverdriveThatMatters.MOD_ID] = -1 // загружаем файлы самого мода всегда раньше, чем всё остальное + + sortedKeys.sortWith { a, b -> inverse.getInt(a.namespace).compareTo(inverse.getInt(b.namespace)) } + + for (key in sortedKeys) { + val json = map[key]!! - for ((key, json) in map) { if (json !is JsonObject) { throw JsonParseException("Matter value $key has invalid type: ${json::class.qualifiedName} ($json)") } From 60ac4d60d2c5a254ed1471c7b26a53958edba2c1 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Fri, 14 Apr 2023 19:19:26 +0600 Subject: [PATCH 0499/1199] did i deadass rollback this --- .../models/item/explosive_hammer_primed.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_primed.json b/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_primed.json index dcf1e2b51..b6341f32d 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_primed.json +++ b/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_primed.json @@ -1,4 +1,8 @@ { + "loader": "forge:separate_transforms", + "gui_light": "front", + "base": + { "credit": "Made with Blockbench", "texture_size": [32, 32], "textures": { @@ -274,4 +278,16 @@ "translation": [0, -4, 0] } } + }, + "perspectives": { + "gui": { + "parent": "overdrive_that_matters:item/explosive_hammer_inventory" + }, + "fixed": { + "parent": "overdrive_that_matters:item/explosive_hammer_inventory" + }, + "ground": { + "parent": "overdrive_that_matters:item/explosive_hammer_inventory" + } + } } \ No newline at end of file From 5df3a06fcbd349a3031e46495deb52b4e47ccf76 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Fri, 14 Apr 2023 19:20:25 +0600 Subject: [PATCH 0500/1199] Perish --- .../models/item/explosive_hammer_primed.json | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_primed.json b/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_primed.json index b6341f32d..2a018a5ee 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_primed.json +++ b/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_primed.json @@ -262,20 +262,6 @@ }, "thirdperson_lefthand": { "translation": [0, 0.5, 0] - }, - "ground": { - "rotation": [29, 0, 0], - "translation": [0, 2, -0.75], - "scale": [0.5, 0.5, 0.5] - }, - "gui": { - "rotation": [-17, 143, 39], - "translation": [-2, -3.25, 0], - "scale": [0.76, 0.76, 0.76] - }, - "fixed": { - "rotation": [0, 90, 0], - "translation": [0, -4, 0] } } }, From 20bbaec62a7989990e143578ff53b554514420c8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 14 Apr 2023 22:45:39 +0700 Subject: [PATCH 0501/1199] Kotlin? Hello? --- .../network/synchronizer/FieldSynchronizer.kt | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt index a4b68d91f..8de4d082e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt @@ -1117,6 +1117,11 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa isClientValue = true observer.accept(newValue) } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun getValue(thisRef: Any?, property: KProperty<*>): Float { + return super.getValue(thisRef, property) + } } /** @@ -1184,6 +1189,11 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa isClientValue = true observer.accept(newValue) } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun getValue(thisRef: Any?, property: KProperty<*>): Double { + return super.getValue(thisRef, property) + } } /** @@ -1237,6 +1247,11 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return getter.asInt } } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun getValue(thisRef: Any?, property: KProperty<*>): Int { + return super.getValue(thisRef, property) + } } /** @@ -1332,6 +1347,11 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return getter.asLong } } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun getValue(thisRef: Any?, property: KProperty<*>): Long { + return super.getValue(thisRef, property) + } } /** @@ -1441,6 +1461,11 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa isClientValue = true observer.accept(newValue) } + + @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) + override fun getValue(thisRef: Any?, property: KProperty<*>): Boolean { + return super.getValue(thisRef, property) + } } /** From 8c32a2cd7a7de292a5ac9da363cd7c2a3cdb9600 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 14 Apr 2023 23:58:17 +0700 Subject: [PATCH 0502/1199] Put constants in decimal cache --- .../kotlin/ru/dbotthepony/mc/otm/core/math/Decimal.kt | 8 ++++++++ 1 file changed, 8 insertions(+) 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 3332158ed..a200f1ff9 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 @@ -746,6 +746,14 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 private val cache = Array(2048) { Decimal(it - 1024, 0.0) } + init { + cache[1024] = ZERO + cache[1025] = ONE + cache[1023] = MINUS_ONE + cache[1026] = TWO + cache[1034] = TEN + } + /** * Returns pooled value if present, otherwise constructs new object */ From 8afa21ae16720d2bcc9d11a27c4f27571b7171b5 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 14 Apr 2023 23:58:38 +0700 Subject: [PATCH 0503/1199] Profiled energy storage! --- .../mc/otm/datagen/lang/English.kt | 1 + .../mc/otm/datagen/lang/Russian.kt | 1 - .../tech/ChemicalGeneratorBlockEntity.kt | 4 +- .../energy/ProfiledEnergyStorage.kt | 169 ++++++++++++++++++ .../screen/tech/ChemicalGeneratorScreen.kt | 7 +- .../client/screen/widget/PowerGaugePanel.kt | 88 ++++++++- .../mc/otm/menu/tech/ChemicalGeneratorMenu.kt | 3 +- .../menu/widget/ProfiledEnergyGaugeWidget.kt | 44 +++++ 8 files changed, 309 insertions(+), 8 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ProfiledEnergyStorage.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProfiledEnergyGaugeWidget.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index a577a70d2..08a15b524 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -264,6 +264,7 @@ private fun misc(provider: MatteryLanguageProvider) { gui("power.percentage_level", "Energy level: %s%%") gui("level", "%s / %s") + gui("diff", "%s (%s / %s)") gui("power.name", "MtJ") gui("fluid.name", "B") gui("fluid.level", "%s / %s of %s") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 1e8345a1e..5b98c30c2 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -270,7 +270,6 @@ private fun misc(provider: MatteryLanguageProvider) { misc("pill.message_finish", "§kОДИН ИЗ НАС ОДИН ИЗ НАС ОДИН ИЗ НАС ОДИН ИЗ НАС ОДИН ИЗ НАС") gui("power.percentage_level", "Уровень энергии: %s%%") - gui("level", "%s / %s") gui("power.name", "МтДж") gui("fluid.name", "В") gui("fluid.level", "%s / %s с %s") 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 e1f8696a2..382295cce 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.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.GeneratorEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.core.* @@ -39,7 +40,7 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe val residueItemHandler = residueContainer.handler(HandlerFilter.OnlyOut) val fuelItemHandler = fuelContainer.handler(HandlerFilter.ChemicalFuel) - val energy = GeneratorEnergyStorage(::setChangedLight, CAPACITY, THROUGHPUT) + val energy = ProfiledEnergyStorage(GeneratorEnergyStorage(::setChangedLight, CAPACITY, THROUGHPUT)) val itemConfig = ConfigurableItemHandler( input = fuelItemHandler, @@ -77,6 +78,7 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe override fun tick() { super.tick() + energy.tick() if (workTicks > 0) { workTicks-- diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ProfiledEnergyStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ProfiledEnergyStorage.kt new file mode 100644 index 000000000..7bb2efad4 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ProfiledEnergyStorage.kt @@ -0,0 +1,169 @@ +package ru.dbotthepony.mc.otm.capability.energy + +import net.minecraft.nbt.CompoundTag +import net.minecraft.nbt.ListTag +import net.minecraft.nbt.NumericTag +import net.minecraft.nbt.Tag +import net.minecraftforge.common.util.INBTSerializable +import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.set +import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.core.util.ITickable +import java.util.* +import kotlin.collections.ArrayList + +class ProfiledEnergyStorage(val parent: E) : IMatteryEnergyStorage, ITickable, INBTSerializable { + override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { + return recordTransfer(parent.extractEnergy(howMuch, simulate), simulate) + } + + override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { + return recordReceive(parent.receiveEnergy(howMuch, simulate), simulate) + } + + override fun extractEnergyChecked(howMuch: Decimal, simulate: Boolean): Decimal { + return recordTransfer(parent.extractEnergyChecked(howMuch, simulate), simulate) + } + + override fun receiveEnergyChecked(howMuch: Decimal, simulate: Boolean): Decimal { + return recordReceive(parent.receiveEnergyChecked(howMuch, simulate), simulate) + } + + override val canSetBatteryLevel: Boolean get() = parent.canSetBatteryLevel + override val missingPower: Decimal get() = parent.missingPower + + override fun drainBattery(): Boolean { + return parent.drainBattery() + } + + override fun fillBattery(): Boolean { + return parent.fillBattery() + } + + override var batteryLevel: Decimal + get() = parent.batteryLevel + set(value) { parent.batteryLevel = value } + override val maxBatteryLevel: Decimal get() = parent.maxBatteryLevel + override val energyFlow: FlowDirection get() = parent.energyFlow + + var lastTickReceive = Decimal.ZERO + private set + + var lastTickTransfer = Decimal.ZERO + private set + + var tick = 0 + private set + + private val historyReceiveInternal = ArrayList() + private val historyTransferInternal = ArrayList() + + val historyReceive: List = Collections.unmodifiableList(historyReceiveInternal) + val historyTransfer: List = Collections.unmodifiableList(historyTransferInternal) + + init { + for (i in 0 until HISTORY_SIZE) { + historyReceiveInternal.add(Decimal.ZERO) + historyTransferInternal.add(Decimal.ZERO) + } + } + + private fun recordTransfer(value: Decimal, simulate: Boolean): Decimal { + if (!simulate) { + lastTickTransfer += value + } + + return value + } + + private fun recordReceive(value: Decimal, simulate: Boolean): Decimal { + if (!simulate) { + lastTickReceive += value + } + + return value + } + + override fun tick() { + tick = (tick + 1) % HISTORY_SIZE + historyReceiveInternal[tick] = lastTickReceive + historyTransferInternal[tick] = lastTickTransfer + + lastTickReceive = Decimal.ZERO + lastTickTransfer = Decimal.ZERO + } + + override fun serializeNBT(): CompoundTag { + val tag: CompoundTag + + if (parent is INBTSerializable<*>) { + tag = (parent as INBTSerializable).serializeNBT() ?: CompoundTag() + } else { + tag = CompoundTag() + } + + tag["historyReceive"] = ListTag().also { + for (value in historyReceiveInternal) { + it.add(value.serializeNBT()) + } + } + + tag["historyTransfer"] = ListTag().also { + for (value in historyTransferInternal) { + it.add(value.serializeNBT()) + } + } + + tag["historyTick"] = tick + tag["lastTickReceive"] = lastTickReceive + tag["lastTickTransfer"] = lastTickTransfer + + return tag + } + + override fun deserializeNBT(nbt: CompoundTag?) { + if (parent is INBTSerializable<*>) { + (parent as INBTSerializable).deserializeNBT(nbt) + } + + if (nbt != null) { + historyReceiveInternal.clear() + historyTransferInternal.clear() + + for (i in 0 until HISTORY_SIZE) { + historyReceiveInternal.add(Decimal.ZERO) + historyTransferInternal.add(Decimal.ZERO) + } + + nbt.map("historyTick") { it: NumericTag -> + tick = it.asInt + } + + nbt.map("lastTickReceive") { it: Tag -> + lastTickReceive = Decimal.deserializeNBT(it) + } + + nbt.map("lastTickTransfer") { it: Tag -> + lastTickReceive = Decimal.deserializeNBT(it) + } + + nbt.map("historyReceive") { it: ListTag -> + for (i in 0 until HISTORY_SIZE.coerceAtMost(it.size)) { + historyReceiveInternal[i] = Decimal.deserializeNBT(it[i]) + } + } + + nbt.map("historyTransfer") { it: ListTag -> + for (i in 0 until HISTORY_SIZE.coerceAtMost(it.size)) { + historyTransferInternal[i] = Decimal.deserializeNBT(it[i]) + } + } + } + } + + companion object { + const val HISTORY_SIZE = 20 + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt index 8f9f7562a..2f84ddd7e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt @@ -9,18 +9,17 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel -import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.menu.tech.ChemicalGeneratorMenu class ChemicalGeneratorScreen(menu: ChemicalGeneratorMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! - WidePowerGaugePanel(this, frame, menu.energy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) + WideProfiledPowerGaugePanel(this, frame, menu.energy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) - val self = this - val progress = object : ProgressGaugePanel(self, frame, menu.progress, 78f, PROGRESS_ARROW_TOP) { + val progress = object : ProgressGaugePanel(this@ChemicalGeneratorScreen, frame, menu.progress, 78f, PROGRESS_ARROW_TOP) { override fun makeTooltip(): MutableList { val list = super.makeTooltip() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt index 1f955c3d7..2ed40ee44 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt @@ -1,16 +1,26 @@ package ru.dbotthepony.mc.otm.client.screen.widget import com.mojang.blaze3d.vertex.PoseStack +import it.unimi.dsi.fastutil.ints.IntArrayList +import net.minecraft.ChatFormatting import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component +import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.client.ShiftPressedCond +import ru.dbotthepony.mc.otm.client.isShiftDown +import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.core.TextComponent +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.stream +import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.core.util.formatPowerLevel import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProfiledEnergyGaugeWidget -open class PowerGaugePanel @JvmOverloads constructor( +open class PowerGaugePanel( screen: S, parent: EditablePanel<*>? = null, val widget: LevelGaugeWidget, @@ -73,6 +83,7 @@ open class PowerGaugePanel @JvmOverloads constructor( /** * Shortcut to [PowerGaugePanel] with doubled width */ +@Suppress("FunctionName") fun WidePowerGaugePanel( screen: S, parent: EditablePanel<*>? = null, @@ -82,3 +93,78 @@ fun WidePowerGaugePanel( width: Float = 18f, height: Float = 48f ) = PowerGaugePanel(screen, parent, widget, x, y, width, height) + +private fun formatLevel(a: Decimal, b: Decimal): Component { + val diff = a - b + + val fa = a.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.DARK_GREEN) + val fb = b.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.DARK_RED) + + if (diff.isZero) { + return TranslatableComponent("otm.gui.diff", diff.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.GRAY), fa, fb) + } else if (diff.isPositive) { + return TranslatableComponent("otm.gui.diff", diff.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.DARK_GREEN), fa, fb) + } else { + return TranslatableComponent("otm.gui.diff", (-diff).formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.DARK_RED), fa, fb) + } +} + +open class ProfiledPowerGaugePanel( + screen: S, + parent: EditablePanel<*>? = null, + val profiledWidget: ProfiledEnergyGaugeWidget, + x: Float = 0f, + y: Float = 0f, + width: Float = GAUGE_BACKGROUND.width, + height: Float = GAUGE_BACKGROUND.height +) : PowerGaugePanel(screen, parent, profiledWidget.gauge, x, y, width, height) { + override fun makeTooltip(): MutableList { + return super.makeTooltip().also { + it.add(TextComponent("")) + + if (minecraft.window.isShiftDown) { + it.add(formatLevel(profiledWidget.lastTickReceive, profiledWidget.lastTickTransfer)) + it.add(TextComponent("---")) + } + + it.add(formatLevel( + profiledWidget.historyReceive + .stream() + .map { it.value } + .reduce(Decimal.ZERO) { a, b -> a + b } + .div(profiledWidget.historyReceive.size), + + profiledWidget.historyTransfer.stream() + .map { it.value } + .reduce(Decimal.ZERO) { a, b -> a + b } + .div(profiledWidget.historyReceive.size), + )) + + if (minecraft.window.isShiftDown && minecraft.options.advancedItemTooltips) { + it.add(TextComponent("---")) + val values = IntArrayList() + + values.addAll(profiledWidget.tick downTo 0) + values.addAll(ProfiledEnergyStorage.HISTORY_SIZE - 1 downTo profiledWidget.tick + 1) + + for (i in values.intIterator()) { + it.add(formatLevel(profiledWidget.historyReceive[i].value, profiledWidget.historyTransfer[i].value)) + } + } + } + } +} + +/** + * Shortcut to [ProfiledPowerGaugePanel] with doubled width + */ +@Suppress("FunctionName") +fun WideProfiledPowerGaugePanel( + screen: S, + parent: EditablePanel<*>? = null, + widget: ProfiledEnergyGaugeWidget, + x: Float = 0f, + y: Float = 0f, + width: Float = 18f, + height: Float = 48f +) = ProfiledPowerGaugePanel(screen, parent, widget, x, y, width, height) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt index 1115da4fd..b4c125658 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt @@ -14,6 +14,7 @@ import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProfiledEnergyGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -53,7 +54,7 @@ class ChemicalGeneratorMenu @JvmOverloads constructor(id: Int, inv: Inventory, t } val progress = ProgressGaugeWidget(this) - val energy = LevelGaugeWidget(this, tile?.energy) + val energy = ProfiledEnergyGaugeWidget(this, tile?.energy) var burnTime by mSynchronizer.int().property init { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProfiledEnergyGaugeWidget.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProfiledEnergyGaugeWidget.kt new file mode 100644 index 000000000..9bcae5438 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProfiledEnergyGaugeWidget.kt @@ -0,0 +1,44 @@ +package ru.dbotthepony.mc.otm.menu.widget + +import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage +import ru.dbotthepony.mc.otm.core.immutableList +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.util.DecimalValueCodec +import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu +import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer + +class ProfiledEnergyGaugeWidget(synchronizer: FieldSynchronizer, val gauge: LevelGaugeWidget = LevelGaugeWidget(synchronizer)) { + var parent: ProfiledEnergyStorage<*>? = null + private set + + val historyReceive = immutableList(ProfiledEnergyStorage.HISTORY_SIZE) { + synchronizer.ComputedField({ parent?.historyReceive?.get(it) ?: Decimal.ZERO }, DecimalValueCodec) + } + + val historyTransfer = immutableList(ProfiledEnergyStorage.HISTORY_SIZE) { + synchronizer.ComputedField({ parent?.historyTransfer?.get(it) ?: Decimal.ZERO }, DecimalValueCodec) + } + + val tick by synchronizer.ComputedIntField({ parent?.tick ?: 0 }).property + val lastTickReceive by synchronizer.ComputedField({ parent?.lastTickReceive ?: Decimal.ZERO }, DecimalValueCodec) + val lastTickTransfer by synchronizer.ComputedField({ parent?.lastTickTransfer ?: Decimal.ZERO }, DecimalValueCodec) + + constructor(synchronizer: FieldSynchronizer, storage: ProfiledEnergyStorage<*>?, gauge: LevelGaugeWidget = LevelGaugeWidget(synchronizer)) : this(synchronizer, gauge = gauge) { + if (storage != null) { + with(storage) + } + } + + constructor(menu: MatteryMenu, storage: ProfiledEnergyStorage<*>?, gauge: LevelGaugeWidget = LevelGaugeWidget(menu)) : this(menu.mSynchronizer, storage, gauge = gauge) + constructor(menu: MatteryMenu, gauge: LevelGaugeWidget = LevelGaugeWidget(menu)) : this(menu.mSynchronizer, gauge = gauge) + + constructor(menu: MatteryPoweredMenu, storage: ProfiledEnergyStorage<*>?) : this(menu.mSynchronizer, storage, menu.powerWidget) + constructor(menu: MatteryPoweredMenu) : this(menu.mSynchronizer, menu.powerWidget) + + fun with(storage: ProfiledEnergyStorage<*>): ProfiledEnergyGaugeWidget { + gauge.with(storage) + parent = storage + return this + } +} From ba326b9fb87d5b750054daeaeb15500785b88fa5 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 15 Apr 2023 14:09:24 +0700 Subject: [PATCH 0504/1199] Add profiled energy storage to most of machines --- .../dbotthepony/mc/otm/GlobalEventHandler.kt | 2 + .../entity/matter/MatterBottlerBlockEntity.kt | 3 +- .../matter/MatterDecomposerBlockEntity.kt | 3 +- .../matter/MatterReconstructorBlockEntity.kt | 3 +- .../matter/MatterRecyclerBlockEntity.kt | 3 +- .../matter/MatterReplicatorBlockEntity.kt | 3 +- .../entity/matter/MatterScannerBlockEntity.kt | 3 +- .../entity/tech/AndroidStationBlockEntity.kt | 5 +- .../entity/tech/BatteryBankBlockEntity.kt | 5 +- .../tech/ChemicalGeneratorBlockEntity.kt | 1 - .../entity/tech/EnergyServoBlockEntity.kt | 5 +- .../entity/tech/PlatePressBlockEntity.kt | 3 +- .../energy/ProfiledEnergyStorage.kt | 148 ++++++++++-------- .../screen/matter/MatterBottlerScreen.kt | 3 +- .../screen/matter/MatterDecomposerScreen.kt | 3 +- .../matter/MatterReconstructorScreen.kt | 3 +- .../screen/matter/MatterRecyclerScreen.kt | 3 +- .../screen/matter/MatterReplicatorScreen.kt | 3 +- .../screen/matter/MatterScannerScreen.kt | 5 +- .../client/screen/storage/DriveRackScreen.kt | 2 +- .../screen/storage/DriveViewerScreen.kt | 2 +- .../screen/storage/ItemMonitorScreen.kt | 2 +- .../client/screen/storage/StorageBusScreen.kt | 2 +- .../screen/storage/StorageExporterScreen.kt | 2 +- .../screen/storage/StorageImporterScreen.kt | 2 +- .../storage/StoragePowerSupplierScreen.kt | 2 +- .../screen/tech/AndroidStationScreen.kt | 11 +- .../client/screen/tech/BatteryBankScreen.kt | 4 +- .../client/screen/tech/EnergyServoScreen.kt | 3 +- .../client/screen/tech/PlatePressScreen.kt | 2 +- .../widget/HorizontalPowerGaugePanel.kt | 78 ++++++--- .../mc/otm/menu/MatteryPoweredMenu.kt | 2 +- .../mc/otm/menu/matter/MatterBottlerMenu.kt | 2 + .../otm/menu/matter/MatterDecomposerMenu.kt | 2 + .../menu/matter/MatterReconstructorMenu.kt | 2 + .../mc/otm/menu/matter/MatterRecyclerMenu.kt | 2 + .../otm/menu/matter/MatterReplicatorMenu.kt | 2 + .../mc/otm/menu/matter/MatterScannerMenu.kt | 2 + .../mc/otm/menu/tech/AndroidStationMenu.kt | 8 +- .../mc/otm/menu/tech/BatteryBankMenu.kt | 4 +- .../mc/otm/menu/tech/EnergyServoMenu.kt | 3 +- .../mc/otm/menu/tech/PlatePressMenu.kt | 2 + .../menu/widget/ProfiledEnergyGaugeWidget.kt | 4 +- 43 files changed, 227 insertions(+), 127 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt index d52964449..8eaa30141 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt @@ -15,6 +15,7 @@ import net.minecraftforge.event.server.ServerStoppedEvent import net.minecraftforge.event.server.ServerStoppingEvent import net.minecraftforge.fml.loading.FMLLoader import org.apache.logging.log4j.LogManager +import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.util.IConditionalTickable import ru.dbotthepony.mc.otm.core.util.ITickable @@ -148,6 +149,7 @@ fun onServerTick(event: ServerTickEvent) { postServerTick.tick() // чтоб не плодить кучу подписчиков, вызовем напрямую отсюда Abstract6Graph.tick() + ProfiledEnergyStorage.onServerPostTick() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index 799e86601..87d3d7b84 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -17,6 +17,7 @@ import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl @@ -37,7 +38,7 @@ import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.MATTER_BOTTLER, p_155229_, p_155230_) { - val energy = WorkerEnergyStorage(this, ENERGY_VALUES) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this, ENERGY_VALUES)) var isBottling: Boolean = true set(value) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index 2fb8ecca8..1a4b1df23 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -13,6 +13,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl +import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl import ru.dbotthepony.mc.otm.config.ConciseBalanceValues @@ -117,7 +118,7 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) } } - val energy = WorkerEnergyStorage(this, ENERGY_VALUES) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this, ENERGY_VALUES)) val energyConfig = ConfigurableEnergy(energy) init { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt index c1a99e6cf..65f5b559b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt @@ -17,6 +17,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl +import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage import ru.dbotthepony.mc.otm.capability.matter.IPatternState @@ -54,7 +55,7 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) private set val matter = MatterStorageImpl(::setChangedLight, FlowDirection.INPUT, ::CAPACITY) - val energy = WorkerEnergyStorage(::setChangedLight, ENERGY_VALUES) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::setChangedLight, ENERGY_VALUES)) val matterNode = object : MatterNode() { override fun getMatterHandler(): IMatterStorage { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index 6625247d8..410079f8e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -16,6 +16,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl @@ -68,7 +69,7 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) val container = MatteryContainer(::itemContainerUpdated, 1).also(::addDroppableContainer) val matterNode = SimpleMatterNode(matter = matter) - val energy = WorkerEnergyStorage(::powerLevelUpdated, ENERGY_CONFIG) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::powerLevelUpdated, ENERGY_CONFIG)) val itemConfig = ConfigurableItemHandler(input = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index c85da2531..494df7e09 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -13,6 +13,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl +import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage import ru.dbotthepony.mc.otm.capability.matter.IPatternState @@ -99,7 +100,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } - val energy = WorkerEnergyStorage(::powerLevelUpdated, ENERGY_VALUES) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::powerLevelUpdated, ENERGY_VALUES)) val matter = MatterStorageImpl(::matterLevelUpdated, FlowDirection.INPUT, ::MATTER_CAPACITY) val container = MatteryContainer(::itemContainerUpdated, 5).also(::addDroppableContainer) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt index 7936b0ffd..fff551547 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt @@ -13,6 +13,7 @@ import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.IPatternState import ru.dbotthepony.mc.otm.capability.matter.PatternState @@ -36,7 +37,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryWorkerBlockEntity(MBlockEntities.MATTER_SCANNER, p_155229_, p_155230_, ::ItemJob) { val container = MatteryContainer(::itemContainerUpdated, 1).also(::addDroppableContainer) - val energy = WorkerEnergyStorage(::powerLevelUpdated, ENERGY_VALUES) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::powerLevelUpdated, ENERGY_VALUES)) val itemConfig = ConfigurableItemHandler(inputOutput = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt index e892a19e2..a7550f5ac 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt @@ -13,6 +13,7 @@ import net.minecraftforge.common.ForgeConfigSpec import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.moveEnergy import ru.dbotthepony.mc.otm.core.math.Decimal @@ -32,7 +33,7 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return AndroidStationMenu(containerID, inventory, this) } - val energy = object : WorkerEnergyStorage(this@AndroidStationBlockEntity::setChangedLight, ::CAPACITY, ::MAX_IO, { null }) { + val energy: ProfiledEnergyStorage = ProfiledEnergyStorage(object : WorkerEnergyStorage(this@AndroidStationBlockEntity::setChangedLight, ::CAPACITY, ::MAX_IO, { null }) { override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { return super.extractEnergy(howMuch, simulate).also { if (!simulate && this.batteryLevel.isZero) { @@ -55,7 +56,7 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } } - } + }) val energyConfig = ConfigurableEnergy(energy) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index 064bc1cae..9aa980d64 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -11,6 +11,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.energy import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energyStoredMattery import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.capability.maxEnergyStoredMattery @@ -21,6 +22,7 @@ import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.menu.tech.BatteryBankMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities +import java.util.function.Supplier class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.BATTERY_BANK, p_155229_, p_155230_), IMatteryEnergyStorage { var gaugeLevel by synchronizer.float().property @@ -168,7 +170,7 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte } val energyConfig = ConfigurableEnergy( - this, + ProfiledEnergyStorage(this), frontDefault = FlowDirection.OUTPUT, backDefault = FlowDirection.INPUT, leftDefault = FlowDirection.INPUT, @@ -179,6 +181,7 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte init { energyConfig.front.automatePush = true + savetables.stateful(Supplier { energyConfig.capability.savedata }, "energyUsageHistory") } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { 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 382295cce..2bf45d05b 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 @@ -78,7 +78,6 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe override fun tick() { super.tick() - energy.tick() if (workTicks > 0) { workTicks-- diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt index a179552fd..e50396454 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt @@ -11,6 +11,7 @@ import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.canSetBatteryMattery import ru.dbotthepony.mc.otm.capability.energy +import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energyStoredMattery import ru.dbotthepony.mc.otm.capability.extractEnergy import ru.dbotthepony.mc.otm.capability.maxEnergyStoredMattery @@ -25,7 +26,7 @@ class EnergyServoBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte val discharge = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) val charge = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) - val energy = object : IMatteryEnergyStorage { + val energy: ProfiledEnergyStorage = ProfiledEnergyStorage(object : IMatteryEnergyStorage { override val energyFlow: FlowDirection get() { val discharge = discharge[0].energy val charge = charge[0].energy @@ -58,7 +59,7 @@ class EnergyServoBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte override val maxBatteryLevel: Decimal get() = charge[0].energy?.maxEnergyStoredMattery ?: discharge[0].energy?.maxEnergyStoredMattery ?: Decimal.ZERO - } + }) val energyConfig = ConfigurableEnergy(energy, possibleModes = FlowDirection.BI_DIRECTIONAL) val itemConfig = ConfigurableItemHandler( 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 9d93cff3f..d3bf3ac99 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 @@ -10,6 +10,7 @@ import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.level.block.state.BlockState import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity +import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.MatteryContainer @@ -23,7 +24,7 @@ class PlatePressBlockEntity( p_155229_: BlockPos, p_155230_: BlockState ) : MatteryWorkerBlockEntity(MBlockEntities.PLATE_PRESS, p_155229_, p_155230_, ::ItemJob) { - val energy = WorkerEnergyStorage(this::setChangedLight, MachinesConfig.PLATE_PRESS) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::setChangedLight, MachinesConfig.PLATE_PRESS)) val inputContainer = MatteryContainer(this::itemContainerUpdated, 1).also(::addDroppableContainer) val outputContainer = MatteryContainer(this::itemContainerUpdated, 1).also(::addDroppableContainer) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ProfiledEnergyStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ProfiledEnergyStorage.kt index 7bb2efad4..a176e5d65 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ProfiledEnergyStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ProfiledEnergyStorage.kt @@ -6,15 +6,20 @@ import net.minecraft.nbt.NumericTag import net.minecraft.nbt.Tag import net.minecraftforge.common.util.INBTSerializable import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.core.forValidRefs import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.set import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.core.util.ITickable +import java.lang.ref.WeakReference import java.util.* import kotlin.collections.ArrayList -class ProfiledEnergyStorage(val parent: E) : IMatteryEnergyStorage, ITickable, INBTSerializable { +class ProfiledEnergyStorage(val parent: E) : IMatteryEnergyStorage, INBTSerializable { + init { + storages.add(WeakReference(this)) + } + override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { return recordTransfer(parent.extractEnergy(howMuch, simulate), simulate) } @@ -45,24 +50,28 @@ class ProfiledEnergyStorage(val parent: E) : IMattery override var batteryLevel: Decimal get() = parent.batteryLevel set(value) { parent.batteryLevel = value } + override val maxBatteryLevel: Decimal get() = parent.maxBatteryLevel override val energyFlow: FlowDirection get() = parent.energyFlow - var lastTickReceive = Decimal.ZERO - private set - - var lastTickTransfer = Decimal.ZERO - private set - - var tick = 0 - private set - - private val historyReceiveInternal = ArrayList() - private val historyTransferInternal = ArrayList() + private val historyReceiveInternal = ArrayList(HISTORY_SIZE) + private val historyTransferInternal = ArrayList(HISTORY_SIZE) val historyReceive: List = Collections.unmodifiableList(historyReceiveInternal) val historyTransfer: List = Collections.unmodifiableList(historyTransferInternal) + val lastTickReceive + get() = historyReceiveInternal[tick] + + val lastTickTransfer + get() = historyTransferInternal[tick] + + private var thisTickReceive = Decimal.ZERO + private var thisTickTransfer = Decimal.ZERO + + var tick = 0 + private set + init { for (i in 0 until HISTORY_SIZE) { historyReceiveInternal.add(Decimal.ZERO) @@ -72,7 +81,7 @@ class ProfiledEnergyStorage(val parent: E) : IMattery private fun recordTransfer(value: Decimal, simulate: Boolean): Decimal { if (!simulate) { - lastTickTransfer += value + thisTickTransfer += value } return value @@ -80,75 +89,57 @@ class ProfiledEnergyStorage(val parent: E) : IMattery private fun recordReceive(value: Decimal, simulate: Boolean): Decimal { if (!simulate) { - lastTickReceive += value + thisTickReceive += value } return value } - override fun tick() { + private fun tick() { tick = (tick + 1) % HISTORY_SIZE - historyReceiveInternal[tick] = lastTickReceive - historyTransferInternal[tick] = lastTickTransfer - lastTickReceive = Decimal.ZERO - lastTickTransfer = Decimal.ZERO + historyReceiveInternal[tick] = thisTickReceive + historyTransferInternal[tick] = thisTickTransfer + + thisTickReceive = Decimal.ZERO + thisTickTransfer = Decimal.ZERO } - override fun serializeNBT(): CompoundTag { - val tag: CompoundTag + val savedata: INBTSerializable = object : INBTSerializable { + override fun serializeNBT(): CompoundTag { + return CompoundTag().also { tag -> + tag["historyReceive"] = ListTag().also { + for (value in historyReceiveInternal) { + it.add(value.serializeNBT()) + } + } - if (parent is INBTSerializable<*>) { - tag = (parent as INBTSerializable).serializeNBT() ?: CompoundTag() - } else { - tag = CompoundTag() - } + tag["historyTransfer"] = ListTag().also { + for (value in historyTransferInternal) { + it.add(value.serializeNBT()) + } + } - tag["historyReceive"] = ListTag().also { - for (value in historyReceiveInternal) { - it.add(value.serializeNBT()) + tag["historyTick"] = tick } } - tag["historyTransfer"] = ListTag().also { - for (value in historyTransferInternal) { - it.add(value.serializeNBT()) - } - } - - tag["historyTick"] = tick - tag["lastTickReceive"] = lastTickReceive - tag["lastTickTransfer"] = lastTickTransfer - - return tag - } - - override fun deserializeNBT(nbt: CompoundTag?) { - if (parent is INBTSerializable<*>) { - (parent as INBTSerializable).deserializeNBT(nbt) - } - - if (nbt != null) { - historyReceiveInternal.clear() - historyTransferInternal.clear() + override fun deserializeNBT(nbt: CompoundTag?) { + tick = 0 + thisTickReceive = Decimal.ZERO + thisTickTransfer = Decimal.ZERO for (i in 0 until HISTORY_SIZE) { - historyReceiveInternal.add(Decimal.ZERO) - historyTransferInternal.add(Decimal.ZERO) + historyReceiveInternal[i] = Decimal.ZERO + historyTransferInternal[i] = Decimal.ZERO } + nbt ?: return + nbt.map("historyTick") { it: NumericTag -> tick = it.asInt } - nbt.map("lastTickReceive") { it: Tag -> - lastTickReceive = Decimal.deserializeNBT(it) - } - - nbt.map("lastTickTransfer") { it: Tag -> - lastTickReceive = Decimal.deserializeNBT(it) - } - nbt.map("historyReceive") { it: ListTag -> for (i in 0 until HISTORY_SIZE.coerceAtMost(it.size)) { historyReceiveInternal[i] = Decimal.deserializeNBT(it[i]) @@ -163,7 +154,42 @@ class ProfiledEnergyStorage(val parent: E) : IMattery } } + override fun serializeNBT(): CompoundTag { + val tag: CompoundTag + + if (parent is INBTSerializable<*>) { + tag = (parent as INBTSerializable).serializeNBT() ?: CompoundTag() + } else { + tag = CompoundTag() + } + + val tag2 = savedata.serializeNBT()!! + + for (k in tag2.allKeys) { + tag[k] = tag2[k]!! + } + + return tag + } + + override fun deserializeNBT(nbt: CompoundTag?) { + if (parent is INBTSerializable<*>) { + (parent as INBTSerializable).deserializeNBT(nbt) + } + + savedata.deserializeNBT(nbt) + } + companion object { const val HISTORY_SIZE = 20 + private val storages = ArrayList>>() + + // после раздумий, наиболее корректное место для обновления состояния профилированных + // хранилищ энергии будет после всех остальных хуков на тики после тика сервера + // разумеется, такое решение может несколько снизить производительность сервера, + // но ничего страшного произойти не должно + internal fun onServerPostTick() { + storages.forValidRefs { it.tick() } + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt index e6bd13407..def4b18a2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt @@ -11,6 +11,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.MatterCapacitorSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.ProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.menu.matter.MatterBottlerMenu @@ -22,7 +23,7 @@ class MatterBottlerScreen(menu: MatterBottlerMenu, inventory: Inventory, title: override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! - val p = PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) + val p = ProfiledPowerGaugePanel(this, frame, menu.profiledEnergy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) MatterGaugePanel(this, frame, menu.matterWidget, LEFT_MARGIN + p.width, GAUGE_TOP_WITH_SLOT) BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt index de53ba607..81a6488d0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt @@ -10,6 +10,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.ProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel class MatterDecomposerScreen(p_97741_: MatterDecomposerMenu, p_97742_: Inventory, p_97743_: Component) : @@ -18,7 +19,7 @@ class MatterDecomposerScreen(p_97741_: MatterDecomposerMenu, p_97742_: Inventory override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! - val m = PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) + val m = ProfiledPowerGaugePanel(this, frame, menu.profiledEnergy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) MatterGaugePanel(this, frame, menu.matterWidget, LEFT_MARGIN + m.width, GAUGE_TOP_WITH_SLOT) BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt index cbfdf5b89..29c2c6163 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt @@ -13,6 +13,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.ProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.menu.matter.MatterReconstructorMenu @@ -20,7 +21,7 @@ class MatterReconstructorScreen(menu: MatterReconstructorMenu, inventory: Invent override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! - val p = PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) + val p = ProfiledPowerGaugePanel(this, frame, menu.profiledEnergy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) MatterGaugePanel(this, frame, menu.matterWidget, LEFT_MARGIN + p.width, GAUGE_TOP_WITH_SLOT) BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt index cdb8c55ad..3763dee00 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt @@ -9,6 +9,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.ProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.menu.matter.MatterRecyclerMenu @@ -16,7 +17,7 @@ class MatterRecyclerScreen(menu: MatterRecyclerMenu, inventory: Inventory, title override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! - val m = PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) + val m = ProfiledPowerGaugePanel(this, frame, menu.profiledEnergy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) MatterGaugePanel(this, frame, menu.matter, LEFT_MARGIN + m.width, GAUGE_TOP_WITH_SLOT) BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt index 58af3e175..a74d83ae8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt @@ -9,6 +9,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.ProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.menu.matter.MatterReplicatorMenu @@ -17,7 +18,7 @@ class MatterReplicatorScreen(p_97741_: MatterReplicatorMenu, p_97742_: Inventory override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! - val m = PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) + val m = ProfiledPowerGaugePanel(this, frame, menu.profiledEnergy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) MatterGaugePanel(this, frame, menu.matter, LEFT_MARGIN + m.width, GAUGE_TOP_WITH_SLOT) BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterScannerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterScannerScreen.kt index 201f208bb..3af6b5302 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterScannerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterScannerScreen.kt @@ -10,14 +10,15 @@ import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.PatternGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.ProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel class MatterScannerScreen(p_97741_: MatterScannerMenu, p_97742_: Inventory, p_97743_: Component) : MatteryScreen(p_97741_, p_97742_, p_97743_) { - override fun makeMainFrame(): FramePanel> { + override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! - val m = PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) + val m = ProfiledPowerGaugePanel(this, frame, menu.profiledEnergy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) PatternGaugePanel(this, frame, menu.patterns, LEFT_MARGIN + m.width, GAUGE_TOP_WITH_SLOT) BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/DriveRackScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/DriveRackScreen.kt index 237e9c72e..171e9725c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/DriveRackScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/DriveRackScreen.kt @@ -15,7 +15,7 @@ class DriveRackScreen(menu: DriveRackMenu, inventory: Inventory, title: Componen override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! - WidePowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) + WidePowerGaugePanel(this, frame, menu.energyWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) SlotPanel(this, frame, menu.storageSlots[0], 71f, 32f) 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 ca4ec029c..f7ba4e1c8 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 @@ -50,7 +50,7 @@ class DriveViewerScreen(menu: DriveViewerMenu, inventory: Inventory, title: Comp } }) - views.add(PowerGaugePanel(this, frame, menu.powerWidget, 8f, 16f)) + views.add(PowerGaugePanel(this, frame, menu.energyWidget, 8f, 16f)) views.add(BatterySlotPanel(this, frame, menu.batterySlot, 8f, 67f)) views.add(SlotPanel(this, frame, menu.driveSlot, 8f, 85f)) 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 902b1e211..b920f15a4 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 @@ -205,7 +205,7 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp leftStrip.height += it.height } - WidePowerGaugePanel(this, leftStrip, menu.powerWidget).also { + WidePowerGaugePanel(this, leftStrip, menu.energyWidget).also { it.dock = Dock.FILL it.dockResize = DockResizeMode.NONE leftStrip.height += it.height diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt index 1b9314e50..71e3497d2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt @@ -18,7 +18,7 @@ class StorageBusScreen(menu: StorageBusMenu, inventory: Inventory, title: Compon override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! - WidePowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) + WidePowerGaugePanel(this, frame, menu.energyWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) for (row in 0 .. 2) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt index c896eb6e9..8299b3879 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt @@ -18,7 +18,7 @@ class StorageExporterScreen(menu: StorageExporterMenu, inventory: Inventory, tit override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! - WidePowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) + WidePowerGaugePanel(this, frame, menu.energyWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) for (row in 0 .. 2) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt index 19ea22c86..97ad88d5e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt @@ -18,7 +18,7 @@ class StorageImporterScreen(menu: StorageImporterMenu, inventory: Inventory, tit override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! - WidePowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) + WidePowerGaugePanel(this, frame, menu.energyWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) for (row in 0 .. 2) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt index dd113f6e1..69a5f9cf3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt @@ -18,7 +18,7 @@ class StoragePowerSupplierScreen(menu: StoragePowerSupplierMenu, inventory: Inve override fun makeMainFrame(): FramePanel> { val frame = FramePanel(this, width = 200f, height = 60f, title) - HorizontalPowerGaugePanel(this, frame, menu.powerWidget).also { + HorizontalPowerGaugePanel(this, frame, menu.energyWidget).also { it.dock = Dock.BOTTOM it.dockResize = DockResizeMode.NONE } 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 d492f5f75..51d1fc00c 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 @@ -35,6 +35,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.EquipmentBatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.DraggableCanvasPanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.menu.tech.AndroidStationMenu @@ -421,7 +422,7 @@ private class AndroidResearchButton( override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { if (button == InputConstants.MOUSE_BUTTON_LEFT && minecraft.player?.isSpectator != true) { - if (node.canResearch && !node.isResearched && (parent?.screen as AndroidStationScreen).menu.powerWidget.level >= AndroidStationBlockEntity.ENERGY_PER_RESEARCH) { + if (node.canResearch && !node.isResearched && (parent?.screen as AndroidStationScreen).menu.energyWidget.level >= AndroidStationBlockEntity.ENERGY_PER_RESEARCH) { if (node.type.flatBlocking.isNotEmpty()) { queryUser( TranslatableComponent("otm.android_station.research.confirm", node.type.displayName), @@ -448,7 +449,7 @@ private class AndroidResearchButton( if (isHovered) { val list = ArrayList().also { it.addAll(node.screenTooltipLines) } - val enoughPower = (parent?.screen as AndroidStationScreen).menu.powerWidget.level >= AndroidStationBlockEntity.ENERGY_PER_RESEARCH + val enoughPower = (parent?.screen as AndroidStationScreen).menu.energyWidget.level >= AndroidStationBlockEntity.ENERGY_PER_RESEARCH if (node.isResearched) { list.add(TranslatableComponent("otm.android_station.research.researched").withStyle(ChatFormatting.DARK_AQUA)) @@ -680,10 +681,10 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I } override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - if (menu.powerWidget.level >= AndroidStationBlockEntity.ENERGY_PER_RESEARCH) { + if (menu.energyWidget.level >= AndroidStationBlockEntity.ENERGY_PER_RESEARCH) { text = POWER_OK color = RGBAColor.LIGHT_GREEN - } else if (menu.powerWidget.level >= AndroidStationBlockEntity.ENERGY_PER_OPERATION) { + } else if (menu.energyWidget.level >= AndroidStationBlockEntity.ENERGY_PER_OPERATION) { text = LOW_POWER_1 color = RGBAColor.DARK_RED } else { @@ -700,7 +701,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I stripLeft.dock = Dock.LEFT stripLeft.dockRight = 3f - WidePowerGaugePanel(this, stripLeft, menu.powerWidget).also { + WideProfiledPowerGaugePanel(this, stripLeft, menu.profiledEnergy).also { it.dock = Dock.TOP } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BatteryBankScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BatteryBankScreen.kt index 3555ddb66..6b8035b4b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BatteryBankScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BatteryBankScreen.kt @@ -7,7 +7,7 @@ import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls -import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel class BatteryBankScreen(menu: BatteryBankMenu, p_97742_: Inventory, p_97743_: Component) : MatteryScreen(menu, p_97742_, p_97743_) { @@ -15,7 +15,7 @@ class BatteryBankScreen(menu: BatteryBankMenu, p_97742_: Inventory, p_97743_: Co override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! - WidePowerGaugePanel(this, frame, menu.powerLevel, LEFT_MARGIN, GAUGE_TOP_WITHOUT_SLOT) + WideProfiledPowerGaugePanel(this, frame, menu.powerLevel, LEFT_MARGIN, GAUGE_TOP_WITHOUT_SLOT) for (i in 0 .. 5) BatterySlotPanel(this, frame, menu.storageSlots[i], 44f + 18 * i, 32f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt index c167d665d..52fa32c17 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt @@ -16,6 +16,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.makeCuriosPanel import ru.dbotthepony.mc.otm.client.screen.widget.HorizontalPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalPowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.menu.tech.EnergyServoMenu class EnergyServoScreen(menu: EnergyServoMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { @@ -51,7 +52,7 @@ class EnergyServoScreen(menu: EnergyServoMenu, inventory: Inventory, title: Comp } } - TallHorizontalPowerGaugePanel(this, strip, menu.powerGauge).also { + TallHorizontalProfiledPowerGaugePanel(this, strip, menu.powerGauge).also { it.dock = Dock.LEFT it.dockRight = 2f } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt index 45b347412..8decb70d3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt @@ -16,7 +16,7 @@ class PlatePressScreen(menu: PlatePressMenu, inventory: Inventory, title: Compon override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! - WidePowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) + WidePowerGaugePanel(this, frame, menu.energyWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) SlotPanel(this, frame, menu.inputSlot, 56f, PROGRESS_SLOT_TOP) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt index e04e54281..1a4df3e36 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt @@ -6,6 +6,31 @@ import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProfiledEnergyGaugeWidget + +private fun PowerGaugePanel<*>.doRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float, flop: Boolean) { + if (height >= 18f) { + if (flop) { + HorizontalPowerGaugePanel.GAUGE_BACKGROUND_TALL.render(stack, height = height, width = this.width, winding = UVWindingOrder.U1_V0_U0_V1) + val width = this.width * widget.percentage + HorizontalPowerGaugePanel.GAUGE_FOREGROUND_TALL.renderPartial(stack, x = this.width - width, height = height, width = width, winding = UVWindingOrder.U1_V0_U0_V1) + } else { + HorizontalPowerGaugePanel.GAUGE_BACKGROUND_TALL.render(stack, height = height, width = this.width) + val width = this.width * widget.percentage + HorizontalPowerGaugePanel.GAUGE_FOREGROUND_TALL.renderPartial(stack, height = height, width = width) + } + } else { + if (flop) { + HorizontalPowerGaugePanel.GAUGE_BACKGROUND.render(stack, height = height, width = this.width, winding = UVWindingOrder.U1_V0_U0_V1) + val width = this.width * widget.percentage + HorizontalPowerGaugePanel.GAUGE_FOREGROUND.renderPartial(stack, x = this.width - width, height = height, width = width, winding = UVWindingOrder.U1_V0_U0_V1) + } else { + HorizontalPowerGaugePanel.GAUGE_BACKGROUND.render(stack, height = height, width = this.width) + val width = this.width * widget.percentage + HorizontalPowerGaugePanel.GAUGE_FOREGROUND.renderPartial(stack, height = height, width = width) + } + } +} open class HorizontalPowerGaugePanel( screen: S, @@ -19,27 +44,7 @@ open class HorizontalPowerGaugePanel( var flop = false override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - if (height >= 18f) { - if (flop) { - GAUGE_BACKGROUND_TALL.render(stack, height = height, width = this.width, winding = UVWindingOrder.U1_V0_U0_V1) - val width = this.width * widget.percentage - GAUGE_FOREGROUND_TALL.renderPartial(stack, x = this.width - width, height = height, width = width, winding = UVWindingOrder.U1_V0_U0_V1) - } else { - GAUGE_BACKGROUND_TALL.render(stack, height = height, width = this.width) - val width = this.width * widget.percentage - GAUGE_FOREGROUND_TALL.renderPartial(stack, height = height, width = width) - } - } else { - if (flop) { - GAUGE_BACKGROUND.render(stack, height = height, width = this.width, winding = UVWindingOrder.U1_V0_U0_V1) - val width = this.width * widget.percentage - GAUGE_FOREGROUND.renderPartial(stack, x = this.width - width, height = height, width = width, winding = UVWindingOrder.U1_V0_U0_V1) - } else { - GAUGE_BACKGROUND.render(stack, height = height, width = this.width) - val width = this.width * widget.percentage - GAUGE_FOREGROUND.renderPartial(stack, height = height, width = width) - } - } + doRender(stack, mouseX, mouseY, partialTick, flop) } companion object { @@ -54,6 +59,7 @@ open class HorizontalPowerGaugePanel( /** * Shortcut to [HorizontalPowerGaugePanel] with doubled height */ +@Suppress("FunctionName") fun TallHorizontalPowerGaugePanel( screen: S, parent: EditablePanel<*>? = null, @@ -63,3 +69,33 @@ fun TallHorizontalPowerGaugePanel( width: Float = HorizontalPowerGaugePanel.GAUGE_BACKGROUND_TALL.width, height: Float = HorizontalPowerGaugePanel.GAUGE_BACKGROUND_TALL.height ) = HorizontalPowerGaugePanel(screen, parent, widget, x, y, width, height) + +open class HorizontalProfiledPowerGaugePanel( + screen: S, + parent: EditablePanel<*>? = null, + widget: ProfiledEnergyGaugeWidget, + x: Float = 0f, + y: Float = 0f, + width: Float = HorizontalPowerGaugePanel.GAUGE_BACKGROUND.width, + height: Float = HorizontalPowerGaugePanel.GAUGE_BACKGROUND.height +) : ProfiledPowerGaugePanel(screen, parent, widget, x, y, width, height) { + var flop = false + + override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + doRender(stack, mouseX, mouseY, partialTick, flop) + } +} + +/** + * Shortcut to [HorizontalProfiledPowerGaugePanel] with doubled height + */ +@Suppress("FunctionName") +fun TallHorizontalProfiledPowerGaugePanel( + screen: S, + parent: EditablePanel<*>? = null, + widget: ProfiledEnergyGaugeWidget, + x: Float = 0f, + y: Float = 0f, + width: Float = HorizontalPowerGaugePanel.GAUGE_BACKGROUND_TALL.width, + height: Float = HorizontalPowerGaugePanel.GAUGE_BACKGROUND_TALL.height +) = HorizontalProfiledPowerGaugePanel(screen, parent, widget, x, y, width, height) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt index 5e924f71f..a9b5cec8a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt @@ -15,7 +15,7 @@ abstract class MatteryPoweredMenu protected constructor( inventory: Inventory, tile: MatteryPoweredBlockEntity? = null ) : MatteryMenu(menuType, containerID, inventory, tile) { - val powerWidget = LevelGaugeWidget(this, tile?.matteryEnergy) + val energyWidget = LevelGaugeWidget(this, tile?.matteryEnergy) val batterySlot = BatterySlot(tile?.batteryContainer ?: SimpleContainer(1), 0) val redstoneConfig = EnumInputWithFeedback(this) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt index dd089b9ed..492ba1891 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt @@ -14,6 +14,7 @@ import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.widget.ProfiledEnergyGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus class MatterBottlerMenu @JvmOverloads constructor( @@ -27,6 +28,7 @@ class MatterBottlerMenu @JvmOverloads constructor( val progressWidget = ProgressGaugeWidget(this) val matterWidget = LevelGaugeWidget(this) val storageSlots: List + val profiledEnergy = ProfiledEnergyGaugeWidget(this, tile?.energy, energyWidget) init { val container = tile?.container ?: SimpleContainer(6) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt index be015e85e..3a2084fff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt @@ -15,6 +15,7 @@ import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput +import ru.dbotthepony.mc.otm.menu.widget.ProfiledEnergyGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus class MatterDecomposerMenu @JvmOverloads constructor( @@ -32,6 +33,7 @@ class MatterDecomposerMenu @JvmOverloads constructor( val matterWidget = LevelGaugeWidget(this, tile?.getCapability(MatteryCapability.MATTER)?.orNull()) val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) + val profiledEnergy = ProfiledEnergyGaugeWidget(this, tile?.energy, energyWidget) init { val container = tile?.outputContainer ?: SimpleContainer(2) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt index 180005809..96e7bb91c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt @@ -9,6 +9,7 @@ import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProfiledEnergyGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -29,6 +30,7 @@ class MatterReconstructorMenu( val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) + val profiledEnergy = ProfiledEnergyGaugeWidget(this, tile?.energy, energyWidget) init { addStorageSlot(slot) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt index c2cb229ac..a999638b2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt @@ -10,6 +10,7 @@ import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProfiledEnergyGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -28,6 +29,7 @@ class MatterRecyclerMenu @JvmOverloads constructor( val matter = LevelGaugeWidget(this, tile?.matter) val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) + val profiledEnergy = ProfiledEnergyGaugeWidget(this, tile?.energy, energyWidget) init { addStorageSlot(input) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt index 67278d79b..09ca29654 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt @@ -11,6 +11,7 @@ import ru.dbotthepony.mc.otm.menu.MachineOutputSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput +import ru.dbotthepony.mc.otm.menu.widget.ProfiledEnergyGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus class MatterReplicatorMenu @JvmOverloads constructor( @@ -23,6 +24,7 @@ class MatterReplicatorMenu @JvmOverloads constructor( val storageSlots: List val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) + val profiledEnergy = ProfiledEnergyGaugeWidget(this, tile?.energy, energyWidget) init { val container = tile?.container ?: SimpleContainer(5) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt index ea94cf99a..f07f1d3e3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt @@ -13,6 +13,7 @@ import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput +import ru.dbotthepony.mc.otm.menu.widget.ProfiledEnergyGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus class MatterScannerMenu @JvmOverloads constructor( @@ -25,6 +26,7 @@ class MatterScannerMenu @JvmOverloads constructor( val patterns = LevelGaugeWidget(this) val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) + val profiledEnergy = ProfiledEnergyGaugeWidget(this, tile?.energy, energyWidget) init { val container = tile?.container ?: SimpleContainer(1) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt index 36fc131b0..a96447a9b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt @@ -13,6 +13,7 @@ import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput +import ru.dbotthepony.mc.otm.menu.widget.ProfiledEnergyGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus import kotlin.reflect.KMutableProperty0 @@ -51,7 +52,7 @@ class AndroidStationMenu @JvmOverloads constructor( } override fun removeItem(p_18942_: Int, p_18943_: Int): ItemStack { - if (p_18942_ != 0 || powerWidget.level < AndroidStationBlockEntity.ENERGY_PER_OPERATION || item.isEmpty) + if (p_18942_ != 0 || energyWidget.level < AndroidStationBlockEntity.ENERGY_PER_OPERATION || item.isEmpty) return ItemStack.EMPTY (tile as AndroidStationBlockEntity).energy.extractEnergy(AndroidStationBlockEntity.ENERGY_PER_OPERATION, false) @@ -94,7 +95,7 @@ class AndroidStationMenu @JvmOverloads constructor( return super.mayPickup(player) && tile.energy.batteryLevel >= AndroidStationBlockEntity.ENERGY_PER_OPERATION } - return super.mayPickup(player) && powerWidget.level >= AndroidStationBlockEntity.ENERGY_PER_OPERATION + return super.mayPickup(player) && energyWidget.level >= AndroidStationBlockEntity.ENERGY_PER_OPERATION } override fun mayPlace(itemStack: ItemStack): Boolean { @@ -102,7 +103,7 @@ class AndroidStationMenu @JvmOverloads constructor( return tile.energy.batteryLevel >= AndroidStationBlockEntity.ENERGY_PER_OPERATION && condition.invoke(itemStack) } - return powerWidget.level >= AndroidStationBlockEntity.ENERGY_PER_OPERATION && condition.invoke(itemStack) + return energyWidget.level >= AndroidStationBlockEntity.ENERGY_PER_OPERATION && condition.invoke(itemStack) } } @@ -112,6 +113,7 @@ class AndroidStationMenu @JvmOverloads constructor( val equipment = makeEquipmentSlots() val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) + val profiledEnergy = ProfiledEnergyGaugeWidget(this, tile?.energy, energyWidget) init { addInventorySlots() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt index 3b7ae1ab8..4483e591d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt @@ -16,6 +16,7 @@ import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput +import ru.dbotthepony.mc.otm.menu.widget.ProfiledEnergyGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus class BatteryBankMenu @JvmOverloads constructor( @@ -23,7 +24,7 @@ class BatteryBankMenu @JvmOverloads constructor( inventory: Inventory, tile: BatteryBankBlockEntity? = null, ) : MatteryMenu(MMenus.BATTERY_BANK, p_38852_, inventory, tile) { - val powerLevel: LevelGaugeWidget + val powerLevel = ProfiledEnergyGaugeWidget(this, tile?.energyConfig?.capability) val storageSlots: List val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java) val energyConfig = EnergyConfigPlayerInput(this, allowPull = false, allowPush = true) @@ -37,7 +38,6 @@ class BatteryBankMenu @JvmOverloads constructor( } val container: Container = tile?.container ?: SimpleContainer(BatteryBankBlockEntity.CAPACITY) - powerLevel = LevelGaugeWidget(this, tile?.getCapability(MatteryCapability.ENERGY)?.orNull()) storageSlots = immutableList(BatteryBankBlockEntity.CAPACITY) { addStorageSlot(BatterySlot(container, it)) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt index 902116b03..cb8ce6b39 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt @@ -12,6 +12,7 @@ import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProfiledEnergyGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus class EnergyServoMenu @JvmOverloads constructor( @@ -33,7 +34,7 @@ class EnergyServoMenu @JvmOverloads constructor( val equipment = makeEquipmentSlots(mapMoveToExternal = true) - val powerGauge = LevelGaugeWidget(this, tile?.energy) + val powerGauge = ProfiledEnergyGaugeWidget(this, tile?.energy) val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig, allowPull = true, allowPush = true) val redstoneConfig = EnumInputWithFeedback(this) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt index eecbe1063..63bdd4b0f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt @@ -9,6 +9,7 @@ import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput +import ru.dbotthepony.mc.otm.menu.widget.ProfiledEnergyGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -23,6 +24,7 @@ class PlatePressMenu @JvmOverloads constructor( val progressGauge = ProgressGaugeWidget(this, tile) val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig, allowPush = true) val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig, allowPull = true) + val profiledEnergy = ProfiledEnergyGaugeWidget(this, tile?.energy, energyWidget) init { addStorageSlot(inputSlot) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProfiledEnergyGaugeWidget.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProfiledEnergyGaugeWidget.kt index 9bcae5438..1a63d3dd7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProfiledEnergyGaugeWidget.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProfiledEnergyGaugeWidget.kt @@ -33,8 +33,8 @@ class ProfiledEnergyGaugeWidget(synchronizer: FieldSynchronizer, val gauge: Leve constructor(menu: MatteryMenu, storage: ProfiledEnergyStorage<*>?, gauge: LevelGaugeWidget = LevelGaugeWidget(menu)) : this(menu.mSynchronizer, storage, gauge = gauge) constructor(menu: MatteryMenu, gauge: LevelGaugeWidget = LevelGaugeWidget(menu)) : this(menu.mSynchronizer, gauge = gauge) - constructor(menu: MatteryPoweredMenu, storage: ProfiledEnergyStorage<*>?) : this(menu.mSynchronizer, storage, menu.powerWidget) - constructor(menu: MatteryPoweredMenu) : this(menu.mSynchronizer, menu.powerWidget) + constructor(menu: MatteryPoweredMenu, storage: ProfiledEnergyStorage<*>?) : this(menu.mSynchronizer, storage, menu.energyWidget) + constructor(menu: MatteryPoweredMenu) : this(menu.mSynchronizer, menu.energyWidget) fun with(storage: ProfiledEnergyStorage<*>): ProfiledEnergyGaugeWidget { gauge.with(storage) From 1828704859347de1494647af003fbc2dbe259b3d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 15 Apr 2023 15:41:05 +0700 Subject: [PATCH 0505/1199] Remove storage blocks from machines list --- src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 307590f22..3b66c1239 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -122,8 +122,10 @@ object MItems { val MACHINES = SupplierList( ::ANDROID_STATION, ::BATTERY_BANK, ::MATTER_DECOMPOSER, ::MATTER_CAPACITOR_BANK, ::MATTER_CABLE, ::PATTERN_STORAGE, ::MATTER_SCANNER, ::MATTER_PANEL, ::MATTER_REPLICATOR, ::MATTER_BOTTLER, ::ENERGY_COUNTER, ::CHEMICAL_GENERATOR, - ::PLATE_PRESS, ::MATTER_RECYCLER, ::STORAGE_BUS, ::STORAGE_IMPORTER, ::STORAGE_EXPORTER, ::DRIVE_VIEWER, - ::DRIVE_RACK, ::ITEM_MONITOR, ::STORAGE_CABLE, ::STORAGE_POWER_SUPPLIER, ::ENERGY_SERVO, + ::PLATE_PRESS, ::MATTER_RECYCLER, + // ::STORAGE_BUS, ::STORAGE_IMPORTER, ::STORAGE_EXPORTER, ::DRIVE_VIEWER, + // ::DRIVE_RACK, ::ITEM_MONITOR, ::STORAGE_CABLE, ::STORAGE_POWER_SUPPLIER, + ::ENERGY_SERVO, ::PHANTOM_ATTRACTOR, ::GRAVITATION_STABILIZER, ::COBBLESTONE_GENERATOR, ::ESSENCE_STORAGE, ::MATTER_RECONSTRUCTOR ) From 8d63488d7286759c51f77d331bee3e3444f55009 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 15 Apr 2023 23:46:47 +0700 Subject: [PATCH 0506/1199] oh my god are you serious? --- .../mc/otm/block/entity/tech/BatteryBankBlockEntity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index 9aa980d64..bb98310ec 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -65,7 +65,7 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte var remaining = howMuch var currentSlot = if (isReceiving) currentChangeSlot else currentDischangeSlot - for (i in 0 until container.containerSize - 1) { + for (i in 0 until container.containerSize) { val item = container[currentSlot] if (!item.isEmpty) { From b7434d632c40480c513a8a24d170f7fb4502e269 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 16 Apr 2023 00:09:16 +0700 Subject: [PATCH 0507/1199] Try to move as much as possible energy between energy storages --- src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt index 1f2950ed1..124338e45 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt @@ -351,7 +351,7 @@ fun moveBetweenSlots(source: IItemHandler, sourceSlot: Int, destination: IItemHa } @Suppress("name_shadowing") -fun moveEnergy(source: IEnergyStorage, destination: IEnergyStorage, amount: Decimal = Decimal.LONG_MAX_VALUE, simulate: Boolean, ignoreFlowRestrictions: Boolean = false): Decimal { +fun moveEnergy(source: IEnergyStorage, destination: IEnergyStorage, amount: Decimal = Decimal.LONG_MAX_VALUE.coerceAtLeast(source.energyStoredMattery), simulate: Boolean, ignoreFlowRestrictions: Boolean = false): Decimal { val extracted = if (ignoreFlowRestrictions && source is IMatteryEnergyStorage) source.extractEnergy(amount, true) else source.extractEnergy(amount, true) if (extracted.isPositive) { From e2a300259c20b5df33a6e3945dfd390ff57fa22a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 16 Apr 2023 10:05:46 +0700 Subject: [PATCH 0508/1199] Swap execution order in moveEnergy --- src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt index 124338e45..414a3fbcc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt @@ -365,8 +365,8 @@ fun moveEnergy(source: IEnergyStorage, destination: IEnergyStorage, amount: Deci return extracted } - val received = destination.receiveEnergy(extracted, false) - return if (ignoreFlowRestrictions && source is IMatteryEnergyStorage) source.extractEnergy(received, false) else source.extractEnergy(received, false) + val extracted = if (ignoreFlowRestrictions && source is IMatteryEnergyStorage) source.extractEnergy(received, false) else source.extractEnergy(received, false) + return destination.receiveEnergy(extracted, false) } } } From 3976c6da568e5cedbac76236de0e7aa0cba8793b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 16 Apr 2023 10:11:32 +0700 Subject: [PATCH 0509/1199] Make tritanium armor absorb 3/4 of cosmir radiation --- .../ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt | 2 +- .../kotlin/ru/dbotthepony/mc/otm/config/ServerCompatConfig.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt index 214e15b9d..158356b3e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt @@ -46,7 +46,7 @@ fun onMatteryTick(event: MatteryPlayerCapability.PostTick) { val rand = event.level.random val noSpacesuits = event.player.armorSlots.count { it.item !is SpaceSuit } - val yesTritanium = if (!ServerCompatConfig.AdAstra.TRITANIUM_ARMOR_PROTECTS_AGAINST_COSMIC_RAYS) 0.0 else event.player.armorSlots.count { it.item in MItems.TRITANIUM_ARMOR } * 0.5 + val yesTritanium = if (!ServerCompatConfig.AdAstra.TRITANIUM_ARMOR_PROTECTS_AGAINST_COSMIC_RAYS) 0.0 else event.player.armorSlots.count { it.item in MItems.TRITANIUM_ARMOR } * 0.75 if (rand.nextDouble() <= (noSpacesuits - yesTritanium) * ServerCompatConfig.AdAstra.ANDROID_COSMIC_RAYS_CHANCE) { event.player.hurt(MRegistry.DAMAGE_COSMIC_RAYS, 1f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerCompatConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerCompatConfig.kt index ab60743e0..268657160 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerCompatConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerCompatConfig.kt @@ -26,7 +26,7 @@ object ServerCompatConfig : AbstractConfig("compat-server") { .defineInRange("ANDROID_COSMIC_RAYS_CHANCE", 0.015, 0.0, 1.0) val TRITANIUM_ARMOR_PROTECTS_AGAINST_COSMIC_RAYS: Boolean by builder - .comment("Should androids get half protection from cosmic rays per piece of tritanium armor") + .comment("Should androids get 3/4th protection from cosmic rays per piece of tritanium armor") .define("TRITANIUM_ARMOR_PROTECTS_AGAINST_COSMIC_RAYS", true) init { From c5d9ba34dd22a0d190eea387394d7551bafd1c33 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 16 Apr 2023 12:43:20 +0700 Subject: [PATCH 0510/1199] Simple Tritanium Armor, some balancing to regular tritanium armor --- .../datagen/advancements/AdvancementData.kt | 22 ++++++++- .../mc/otm/datagen/lang/English.kt | 5 +++ .../mc/otm/datagen/lang/Russian.kt | 5 +++ .../datagen/recipes/CraftingTableRecipes.kt | 27 +++++++++++ .../dbotthepony/mc/otm/datagen/tags/Tags.kt | 5 +++ .../mc/otm/OverdriveThatMatters.java | 4 +- .../mc/otm/compat/adastra/AdAstraCompat.kt | 4 +- .../mc/otm/item/SimpleTritaniumArmorItem.kt | 45 +++++++++++++++++++ .../mc/otm/item/TritaniumArmorItem.kt | 23 +++++----- .../mc/otm/registry/CreativeTabs.kt | 1 + .../ru/dbotthepony/mc/otm/registry/MItems.kt | 21 ++++++--- .../ru/dbotthepony/mc/otm/registry/MNames.kt | 5 +++ 12 files changed, 145 insertions(+), 22 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/item/SimpleTritaniumArmorItem.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt index ddee26360..732c9cac5 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt @@ -281,8 +281,8 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist title = translation.add("armor", "Composite Armor") { russian("Композитная броня") }, - description = translation.add("armor.desc", "Bend some Tritanium Plates into simple yet sturdy armor") { - russian("Согните немного тритановых пластин в простую, но прочную, броню") + description = translation.add("armor.desc", "Bend some Tritanium Plates and Carbon Mesh into incredibly sturdy armor") { + russian("Согните немного тритановых пластин вместе с углеродной сеткой в невероятно прочную броню") } ) .requirements(RequirementsStrategy.OR) @@ -292,6 +292,24 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .addCriterion("has_item3", criterion(MItems.TRITANIUM_BOOTS)) .save(serializer, modLocation("regular/armor"), existingFileHelper) + AdvancementBuilder() + .parent(ingot) + .display( + itemStack = ItemStack(MItems.SIMPLE_TRITANIUM_CHESTPLATE), + title = translation.add("simple_armor", "Sturdy Armor") { + russian("Прочная броня") + }, + description = translation.add("simple_armor.desc", "Put togeher Simple Tritanium Armor from Tritanium Ingots, simple and effective") { + russian("Создайте простую тритановую броню из слитков, просто и эффективно") + } + ) + .requirements(RequirementsStrategy.OR) + .addCriterion("has_item0", criterion(MItems.SIMPLE_TRITANIUM_HELMET)) + .addCriterion("has_item1", criterion(MItems.SIMPLE_TRITANIUM_CHESTPLATE)) + .addCriterion("has_item2", criterion(MItems.SIMPLE_TRITANIUM_PANTS)) + .addCriterion("has_item3", criterion(MItems.SIMPLE_TRITANIUM_BOOTS)) + .save(serializer, modLocation("regular/simple_armor"), existingFileHelper) + val glass = AdvancementBuilder() .parent(plate) .display( diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 08a15b524..389a15b72 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -515,6 +515,11 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.TRITANIUM_PANTS, "Tritanium Leggings") add(MItems.TRITANIUM_BOOTS, "Tritanium Boots") + add(MItems.SIMPLE_TRITANIUM_HELMET, "Simple Tritanium Helmet") + add(MItems.SIMPLE_TRITANIUM_CHESTPLATE, "Simple Tritanium Chestplate") + add(MItems.SIMPLE_TRITANIUM_PANTS, "Simple Tritanium Leggings") + add(MItems.SIMPLE_TRITANIUM_BOOTS, "Simple Tritanium Boots") + add(MItems.TRITANIUM_DUST, "Tritanium Dust") add(MItems.TRITANIUM_INGOT, "Tritanium Ingot") add(MItems.TRITANIUM_NUGGET, "Tritanium Nugget") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 5b98c30c2..aad518d9f 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -520,6 +520,11 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.TRITANIUM_PANTS, "Тритановые поножи") add(MItems.TRITANIUM_BOOTS, "Тритановые ботинки") + add(MItems.SIMPLE_TRITANIUM_HELMET, "Простой тритановый шлем") + add(MItems.SIMPLE_TRITANIUM_CHESTPLATE, "Простой тритановый нагрудник") + add(MItems.SIMPLE_TRITANIUM_PANTS, "Простые тритановые поножи") + add(MItems.SIMPLE_TRITANIUM_BOOTS, "Простые тритановые ботинки") + add(MItems.TRITANIUM_DUST, "Тритановая пыль") add(MItems.TRITANIUM_INGOT, "Тритановый слиток") add(MItems.TRITANIUM_NUGGET, "Тритановый самородок") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index a802aa028..7127cdce5 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -204,6 +204,33 @@ fun addCraftingTableRecipes(consumer: Consumer) { .unlockedBy(MItemTags.REINFORCED_TRITANIUM_PLATES) .build(consumer) + // простая броня + MatteryRecipe(MItems.SIMPLE_TRITANIUM_HELMET, category = RecipeCategory.COMBAT) + .row(MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS) + .rowAC(MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS) + .unlockedBy(MItemTags.TRITANIUM_INGOTS) + .build(consumer) + + MatteryRecipe(MItems.SIMPLE_TRITANIUM_PANTS, category = RecipeCategory.COMBAT) + .row(MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS) + .rowAC(MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS) + .rowAC(MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS) + .unlockedBy(MItemTags.TRITANIUM_INGOTS) + .build(consumer) + + MatteryRecipe(MItems.SIMPLE_TRITANIUM_CHESTPLATE, category = RecipeCategory.COMBAT) + .rowAC(MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS) + .row(MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS) + .row(MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS) + .unlockedBy(MItemTags.TRITANIUM_INGOTS) + .build(consumer) + + MatteryRecipe(MItems.SIMPLE_TRITANIUM_BOOTS, category = RecipeCategory.COMBAT) + .rowAC(MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS) + .row(MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS) + .unlockedBy(MItemTags.TRITANIUM_INGOTS) + .build(consumer) + // простые батарейки MatteryRecipe(MItems.BATTERY_CRUDE, category = RecipeCategory.MISC) .rowB(Tags.Items.DUSTS_REDSTONE) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index 793ef9842..096f58816 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -99,6 +99,11 @@ fun addTags(tagsProvider: TagsProvider) { .add("chestplates", MItems.TRITANIUM_CHESTPLATE) .add("leggings", MItems.TRITANIUM_PANTS) .add("boots", MItems.TRITANIUM_BOOTS) + .add("helmets", MItems.SIMPLE_TRITANIUM_HELMET) + .add("chestplates", MItems.SIMPLE_TRITANIUM_CHESTPLATE) + .add("leggings", MItems.SIMPLE_TRITANIUM_PANTS) + .add("boots", MItems.SIMPLE_TRITANIUM_BOOTS) + tagsProvider.items.forge("tools") .add("swords", MItems.TRITANIUM_SWORD) .add("axes", MItems.TRITANIUM_AXE) diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 7d2d1603b..475b57574 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -47,7 +47,7 @@ import ru.dbotthepony.mc.otm.config.ServerConfig; import ru.dbotthepony.mc.otm.config.ToolsConfig; import ru.dbotthepony.mc.otm.core.math.Decimal; import ru.dbotthepony.mc.otm.item.ExplosiveHammerItem; -import ru.dbotthepony.mc.otm.item.ItemTritaniumArmor; +import ru.dbotthepony.mc.otm.item.TritaniumArmorItem; import ru.dbotthepony.mc.otm.item.QuantumBatteryItem; import ru.dbotthepony.mc.otm.item.weapon.AbstractWeaponItem; import ru.dbotthepony.mc.otm.item.PortableCondensationDriveItem; @@ -190,7 +190,7 @@ public final class OverdriveThatMatters { EVENT_BUS.addListener(EventPriority.LOWEST, KillAsAndroidTrigger.INSTANCE::onKill); EVENT_BUS.addListener(EventPriority.NORMAL, EnderTeleporterFeature.Companion::onEntityDeath); - EVENT_BUS.addListener(EventPriority.HIGH, ItemTritaniumArmor.Companion::onHurt); + EVENT_BUS.addListener(EventPriority.HIGH, TritaniumArmorItem.Companion::onHurt); EVENT_BUS.addListener(EventPriority.NORMAL, ExplosiveHammerItem.Companion::onLeftClickBlock); diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt index 158356b3e..71c1ce3bb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt @@ -46,7 +46,9 @@ fun onMatteryTick(event: MatteryPlayerCapability.PostTick) { val rand = event.level.random val noSpacesuits = event.player.armorSlots.count { it.item !is SpaceSuit } - val yesTritanium = if (!ServerCompatConfig.AdAstra.TRITANIUM_ARMOR_PROTECTS_AGAINST_COSMIC_RAYS) 0.0 else event.player.armorSlots.count { it.item in MItems.TRITANIUM_ARMOR } * 0.75 + val yesTritanium0 = if (!ServerCompatConfig.AdAstra.TRITANIUM_ARMOR_PROTECTS_AGAINST_COSMIC_RAYS) 0.0 else event.player.armorSlots.count { it.item in MItems.TRITANIUM_ARMOR } * 0.75 + val yesTritanium1 = if (!ServerCompatConfig.AdAstra.TRITANIUM_ARMOR_PROTECTS_AGAINST_COSMIC_RAYS) 0.0 else event.player.armorSlots.count { it.item in MItems.SIMPLE_TRITANIUM_ARMOR } * 0.2 + val yesTritanium = yesTritanium0 + yesTritanium1 if (rand.nextDouble() <= (noSpacesuits - yesTritanium) * ServerCompatConfig.AdAstra.ANDROID_COSMIC_RAYS_CHANCE) { event.player.hurt(MRegistry.DAMAGE_COSMIC_RAYS, 1f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/SimpleTritaniumArmorItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/SimpleTritaniumArmorItem.kt new file mode 100644 index 000000000..6dbeacff7 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/SimpleTritaniumArmorItem.kt @@ -0,0 +1,45 @@ +package ru.dbotthepony.mc.otm.item + +import net.minecraft.sounds.SoundEvent +import net.minecraft.sounds.SoundEvents +import net.minecraft.world.entity.EquipmentSlot +import net.minecraft.world.item.ArmorItem +import net.minecraft.world.item.ArmorMaterial +import net.minecraft.world.item.crafting.Ingredient +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.registry.MItemTags + +private object SimpleTritaniumArmorMaterial : ArmorMaterial { + override fun getDurabilityForSlot(p_40410_: EquipmentSlot): Int { + return when (p_40410_) { + EquipmentSlot.HEAD -> 380 + EquipmentSlot.CHEST -> 590 + EquipmentSlot.LEGS -> 500 + EquipmentSlot.FEET -> 420 + else -> throw IllegalArgumentException("yo dude what the fuck $p_40410_") + } + } + + override fun getDefenseForSlot(p_40411_: EquipmentSlot): Int { + return when (p_40411_) { + EquipmentSlot.FEET -> 2 + EquipmentSlot.LEGS -> 6 + EquipmentSlot.CHEST -> 7 + EquipmentSlot.HEAD -> 2 + else -> throw IllegalArgumentException("yo dude what the fuck $p_40411_") + } + } + + override fun getEnchantmentValue() = 9 + override fun getEquipSound(): SoundEvent = SoundEvents.ARMOR_EQUIP_IRON + override fun getRepairIngredient(): Ingredient = Ingredient.of(MItemTags.TRITANIUM_INGOTS) + + const val ID = "${OverdriveThatMatters.MOD_ID}:simple_tritanium_armor" + + override fun getName(): String = ID + override fun getToughness() = 0.3f + override fun getKnockbackResistance() = 0f +} + +class SimpleTritaniumArmorItem(slot: EquipmentSlot) : ArmorItem(SimpleTritaniumArmorMaterial, slot, Properties().stacksTo(1)) { +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/TritaniumArmorItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/TritaniumArmorItem.kt index 6c4c5e1bd..5cab53c53 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/TritaniumArmorItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/TritaniumArmorItem.kt @@ -14,7 +14,6 @@ import net.minecraft.world.item.Rarity import net.minecraft.world.item.crafting.Ingredient import net.minecraftforge.client.extensions.common.IClientItemExtensions import net.minecraftforge.event.entity.living.LivingAttackEvent -import net.minecraftforge.event.entity.living.LivingHurtEvent import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.client.model.TritaniumArmorModel import ru.dbotthepony.mc.otm.registry.MItemTags @@ -24,33 +23,33 @@ import java.util.function.Consumer private object TritaniumArmorMaterial : ArmorMaterial { override fun getDurabilityForSlot(p_40410_: EquipmentSlot): Int { return when (p_40410_) { - EquipmentSlot.FEET -> 470 - EquipmentSlot.LEGS -> 540 - EquipmentSlot.CHEST -> 820 EquipmentSlot.HEAD -> 520 - else -> throw IllegalArgumentException("yo dude what the fuck") + EquipmentSlot.CHEST -> 920 + EquipmentSlot.LEGS -> 650 + EquipmentSlot.FEET -> 540 + else -> throw IllegalArgumentException("yo dude what the fuck $p_40410_") } } override fun getDefenseForSlot(p_40411_: EquipmentSlot): Int { return when (p_40411_) { + EquipmentSlot.HEAD -> 4 + EquipmentSlot.CHEST -> 9 + EquipmentSlot.LEGS -> 7 EquipmentSlot.FEET -> 3 - EquipmentSlot.LEGS -> 6 - EquipmentSlot.CHEST -> 8 - EquipmentSlot.HEAD -> 3 - else -> throw IllegalArgumentException("yo dude what the fuck") + else -> throw IllegalArgumentException("yo dude what the fuck $p_40411_") } } override fun getEnchantmentValue() = 9 override fun getEquipSound(): SoundEvent = SoundEvents.ARMOR_EQUIP_IRON - override fun getRepairIngredient(): Ingredient = Ingredient.of(MItemTags.TRITANIUM_INGOTS) + override fun getRepairIngredient(): Ingredient = Ingredient.of(MItemTags.REINFORCED_TRITANIUM_PLATES) const val ID = "${OverdriveThatMatters.MOD_ID}:tritanium_armor" override fun getName(): String = ID override fun getToughness() = 1f - override fun getKnockbackResistance() = 0.05f + override fun getKnockbackResistance() = 0.08f } private object TritaniumArmorRenderProperties : IClientItemExtensions { @@ -68,7 +67,7 @@ private object TritaniumArmorRenderProperties : IClientItemExtensions { } } -class ItemTritaniumArmor(slot: EquipmentSlot) : ArmorItem(TritaniumArmorMaterial, slot, Properties().stacksTo(1).rarity(Rarity.RARE)) { +class TritaniumArmorItem(slot: EquipmentSlot) : ArmorItem(TritaniumArmorMaterial, slot, Properties().stacksTo(1).rarity(Rarity.RARE)) { override fun initializeClient(consumer: Consumer) { super.initializeClient(consumer) consumer.accept(TritaniumArmorRenderProperties) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt index f97a70b1c..b82dc5292 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt @@ -141,6 +141,7 @@ internal fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { accept(MItems.TRITANIUM_INGOT_BLOCK) accept(MItems.TRITANIUM_TOOLS) + accept(MItems.SIMPLE_TRITANIUM_ARMOR) accept(MItems.TRITANIUM_ARMOR) energized(MItems.ENERGY_SWORD) 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 3b66c1239..c90fb40e2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -8,7 +8,6 @@ import net.minecraft.world.entity.EquipmentSlot import net.minecraft.world.food.FoodProperties import net.minecraft.world.item.* import net.minecraft.world.item.crafting.Ingredient -import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraftforge.common.ForgeTier import net.minecraftforge.common.TierSortingRegistry @@ -205,10 +204,15 @@ object MItems { ::TRITANIUM_SHIELD, ) - val TRITANIUM_HELMET: ItemTritaniumArmor by registry.register(MNames.TRITANIUM_HELMET) { ItemTritaniumArmor(EquipmentSlot.HEAD) } - val TRITANIUM_CHESTPLATE: ItemTritaniumArmor by registry.register(MNames.TRITANIUM_CHESTPLATE) { ItemTritaniumArmor(EquipmentSlot.CHEST) } - val TRITANIUM_PANTS: ItemTritaniumArmor by registry.register(MNames.TRITANIUM_PANTS) { ItemTritaniumArmor(EquipmentSlot.LEGS) } - val TRITANIUM_BOOTS: ItemTritaniumArmor by registry.register(MNames.TRITANIUM_BOOTS) { ItemTritaniumArmor(EquipmentSlot.FEET) } + val TRITANIUM_HELMET: TritaniumArmorItem by registry.register(MNames.TRITANIUM_HELMET) { TritaniumArmorItem(EquipmentSlot.HEAD) } + val TRITANIUM_CHESTPLATE: TritaniumArmorItem by registry.register(MNames.TRITANIUM_CHESTPLATE) { TritaniumArmorItem(EquipmentSlot.CHEST) } + val TRITANIUM_PANTS: TritaniumArmorItem by registry.register(MNames.TRITANIUM_PANTS) { TritaniumArmorItem(EquipmentSlot.LEGS) } + val TRITANIUM_BOOTS: TritaniumArmorItem by registry.register(MNames.TRITANIUM_BOOTS) { TritaniumArmorItem(EquipmentSlot.FEET) } + + val SIMPLE_TRITANIUM_HELMET: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_HELMET) { SimpleTritaniumArmorItem(EquipmentSlot.HEAD) } + val SIMPLE_TRITANIUM_CHESTPLATE: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_CHESTPLATE) { SimpleTritaniumArmorItem(EquipmentSlot.CHEST) } + val SIMPLE_TRITANIUM_PANTS: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_PANTS) { SimpleTritaniumArmorItem(EquipmentSlot.LEGS) } + val SIMPLE_TRITANIUM_BOOTS: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_BOOTS) { SimpleTritaniumArmorItem(EquipmentSlot.FEET) } val TRITANIUM_ARMOR = SupplierList( ::TRITANIUM_HELMET, @@ -217,6 +221,13 @@ object MItems { ::TRITANIUM_BOOTS ) + val SIMPLE_TRITANIUM_ARMOR = SupplierList( + ::SIMPLE_TRITANIUM_HELMET, + ::SIMPLE_TRITANIUM_CHESTPLATE, + ::SIMPLE_TRITANIUM_PANTS, + ::SIMPLE_TRITANIUM_BOOTS + ) + val EXPLOSIVE_HAMMER: ExplosiveHammerItem by registry.register("explosive_hammer") { ExplosiveHammerItem() } val ENERGY_SWORD: Item by registry.register(MNames.ENERGY_SWORD) { EnergySwordItem() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index 57ab049d9..2f36a7932 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -130,6 +130,11 @@ object MNames { const val TRITANIUM_PANTS = "tritanium_pants" const val TRITANIUM_BOOTS = "tritanium_boots" + const val SIMPLE_TRITANIUM_HELMET = "simple_tritanium_helmet" + const val SIMPLE_TRITANIUM_CHESTPLATE = "simple_tritanium_chestplate" + const val SIMPLE_TRITANIUM_PANTS = "simple_tritanium_pants" + const val SIMPLE_TRITANIUM_BOOTS = "simple_tritanium_boots" + // tools const val TRITANIUM_SWORD = "tritanium_sword" const val TRITANIUM_AXE = "tritanium_axe" From cdd6ef9eb312a138e6e3dfbf5ec005fe97e9a672 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 16 Apr 2023 19:10:27 +0700 Subject: [PATCH 0511/1199] Sort item classes to subpackages, correct some code --- .../mc/otm/OverdriveThatMatters.java | 4 +-- .../matter/MatterDecomposerBlockEntity.kt | 2 +- .../matter/MatterRecyclerBlockEntity.kt | 5 +--- .../item/ProceduralExoPackSlotUpgradeItem.kt | 1 + .../mc/otm/item/SingleUseBatteryItem.kt | 15 ++--------- .../AbstractExoPackSlotUpgradeItem.kt | 3 +-- .../ExoPackCraftingUpgradeItem.kt | 2 +- .../item/{ => exopack}/ExoPackProbeItem.kt | 2 +- .../{ => exopack}/ExoPackSlotUpgradeItem.kt | 2 +- .../item/{ => matter}/CreativePatternItem.kt | 3 +-- .../item/{ => matter}/MatterCapacitorItem.kt | 2 +- .../otm/item/{ => matter}/MatterDustItem.kt | 3 +-- .../item/{ => matter}/PatternStorageItem.kt | 2 +- .../mc/otm/item/{ => tool}/EnergySwordItem.kt | 27 ++++++++++--------- .../item/{ => tool}/ExplosiveHammerItem.kt | 2 +- .../mc/otm/item/{ => tool}/MatteryAxeItem.kt | 2 +- .../PortableGravitationStabilizerItem.kt | 4 +-- .../{ => tool}/SimpleTritaniumArmorItem.kt | 2 +- .../otm/item/{ => tool}/TritaniumArmorItem.kt | 2 +- .../mc/otm/menu/matter/MatterRecyclerMenu.kt | 2 +- .../recipe/ExplosiveHammerPrimingRecipe.kt | 2 +- .../ru/dbotthepony/mc/otm/registry/MItems.kt | 17 ++++++++++-- src/main/resources/coremods/code_injector.js | 2 +- 23 files changed, 53 insertions(+), 55 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/item/{ => exopack}/AbstractExoPackSlotUpgradeItem.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/item/{ => exopack}/ExoPackCraftingUpgradeItem.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/item/{ => exopack}/ExoPackProbeItem.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/item/{ => exopack}/ExoPackSlotUpgradeItem.kt (97%) rename src/main/kotlin/ru/dbotthepony/mc/otm/item/{ => matter}/CreativePatternItem.kt (96%) rename src/main/kotlin/ru/dbotthepony/mc/otm/item/{ => matter}/MatterCapacitorItem.kt (99%) rename src/main/kotlin/ru/dbotthepony/mc/otm/item/{ => matter}/MatterDustItem.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/item/{ => matter}/PatternStorageItem.kt (99%) rename src/main/kotlin/ru/dbotthepony/mc/otm/item/{ => tool}/EnergySwordItem.kt (96%) rename src/main/kotlin/ru/dbotthepony/mc/otm/item/{ => tool}/ExplosiveHammerItem.kt (99%) rename src/main/kotlin/ru/dbotthepony/mc/otm/item/{ => tool}/MatteryAxeItem.kt (94%) rename src/main/kotlin/ru/dbotthepony/mc/otm/item/{ => tool}/PortableGravitationStabilizerItem.kt (95%) rename src/main/kotlin/ru/dbotthepony/mc/otm/item/{ => tool}/SimpleTritaniumArmorItem.kt (97%) rename src/main/kotlin/ru/dbotthepony/mc/otm/item/{ => tool}/TritaniumArmorItem.kt (98%) diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 475b57574..d84af44df 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -46,8 +46,8 @@ import ru.dbotthepony.mc.otm.config.ServerCompatConfig; import ru.dbotthepony.mc.otm.config.ServerConfig; import ru.dbotthepony.mc.otm.config.ToolsConfig; import ru.dbotthepony.mc.otm.core.math.Decimal; -import ru.dbotthepony.mc.otm.item.ExplosiveHammerItem; -import ru.dbotthepony.mc.otm.item.TritaniumArmorItem; +import ru.dbotthepony.mc.otm.item.tool.ExplosiveHammerItem; +import ru.dbotthepony.mc.otm.item.tool.TritaniumArmorItem; import ru.dbotthepony.mc.otm.item.QuantumBatteryItem; import ru.dbotthepony.mc.otm.item.weapon.AbstractWeaponItem; import ru.dbotthepony.mc.otm.item.PortableCondensationDriveItem; diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index 1a4b1df23..359024ca2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -28,7 +28,7 @@ import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.graph.matter.MatterGraph import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode -import ru.dbotthepony.mc.otm.item.MatterDustItem +import ru.dbotthepony.mc.otm.item.matter.MatterDustItem import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.menu.matter.MatterDecomposerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index 410079f8e..6bae9450c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.block.entity.matter import net.minecraft.core.BlockPos import net.minecraft.nbt.CompoundTag -import net.minecraft.server.level.ServerLevel import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu @@ -18,14 +17,12 @@ import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage -import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.matter.MatterGraph -import ru.dbotthepony.mc.otm.item.MatterDustItem +import ru.dbotthepony.mc.otm.item.matter.MatterDustItem import ru.dbotthepony.mc.otm.menu.matter.MatterRecyclerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralExoPackSlotUpgradeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralExoPackSlotUpgradeItem.kt index 9864f1be7..23432ea05 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralExoPackSlotUpgradeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralExoPackSlotUpgradeItem.kt @@ -12,6 +12,7 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.tagNotNull import ru.dbotthepony.mc.otm.data.loot.IRandomizableItem +import ru.dbotthepony.mc.otm.item.exopack.AbstractExoPackSlotUpgradeItem import java.util.* @Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") // .tab(null) is a legal statement because tab field itself is nullable diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt index 336e24038..7c516755c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/SingleUseBatteryItem.kt @@ -38,7 +38,7 @@ open class SingleUseBatteryItem( p_41424_: TooltipFlag ) { super.appendHoverText(itemStack, p_41422_, list, p_41424_) - list.add(SINGLE_USE) + list.add(TranslatableComponent("otm.battery.single_use").withStyle(ChatFormatting.GRAY)) ItemEnergyStorageImpl.appendHoverText(itemStack, list) } @@ -57,10 +57,6 @@ open class SingleUseBatteryItem( override fun getBarColor(p_150901_: ItemStack): Int { return p_150901_.matteryEnergy?.getBarColor() ?: super.getBarColor(p_150901_) } - - companion object { - private val SINGLE_USE = TranslatableComponent("otm.battery.single_use").withStyle(ChatFormatting.GRAY) - } } class ZPMItem : SingleUseBatteryItem(ItemsConfig.Batteries.ZPM, Properties().stacksTo(1).rarity(Rarity.EPIC)) { @@ -71,13 +67,6 @@ class ZPMItem : SingleUseBatteryItem(ItemsConfig.Batteries.ZPM, Properties().sta p_41424_: TooltipFlag ) { super.appendHoverText(itemStack, p_41422_, list, p_41424_) - list.add(DESCRIPTION) - } - - companion object { - val MAX_STORAGE = Decimal(200_000_000_000_000L) - val THROUGHPUT = Decimal(200_000_000L) - - private val DESCRIPTION = TranslatableComponent("item.${OverdriveThatMatters.MOD_ID}.zpm_battery.description").withStyle(ChatFormatting.DARK_GRAY) + list.add(TranslatableComponent("$descriptionId.description").withStyle(ChatFormatting.DARK_GRAY)) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/AbstractExoPackSlotUpgradeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/AbstractExoPackSlotUpgradeItem.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/item/AbstractExoPackSlotUpgradeItem.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/AbstractExoPackSlotUpgradeItem.kt index 2fc022a71..e4dd48ac0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/AbstractExoPackSlotUpgradeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/AbstractExoPackSlotUpgradeItem.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.item +package ru.dbotthepony.mc.otm.item.exopack import net.minecraft.ChatFormatting import net.minecraft.network.chat.Component @@ -14,7 +14,6 @@ import net.minecraft.world.item.Rarity import net.minecraft.world.item.TooltipFlag import net.minecraft.world.item.UseAnim import net.minecraft.world.level.Level -import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ExoPackCraftingUpgradeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExoPackCraftingUpgradeItem.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/item/ExoPackCraftingUpgradeItem.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExoPackCraftingUpgradeItem.kt index b753f7291..86f904785 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ExoPackCraftingUpgradeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExoPackCraftingUpgradeItem.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.item +package ru.dbotthepony.mc.otm.item.exopack import net.minecraft.ChatFormatting import net.minecraft.network.chat.Component diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ExoPackProbeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExoPackProbeItem.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/item/ExoPackProbeItem.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExoPackProbeItem.kt index 12bfbaf5f..afa6cb200 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ExoPackProbeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExoPackProbeItem.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.item +package ru.dbotthepony.mc.otm.item.exopack import net.minecraft.ChatFormatting import net.minecraft.network.chat.Component diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ExoPackSlotUpgradeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExoPackSlotUpgradeItem.kt similarity index 97% rename from src/main/kotlin/ru/dbotthepony/mc/otm/item/ExoPackSlotUpgradeItem.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExoPackSlotUpgradeItem.kt index 76f14b5a9..d029c75fe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ExoPackSlotUpgradeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExoPackSlotUpgradeItem.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.item +package ru.dbotthepony.mc.otm.item.exopack import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Rarity diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/CreativePatternItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/CreativePatternItem.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/mc/otm/item/CreativePatternItem.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/CreativePatternItem.kt index 195e20896..8dd5a4659 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/CreativePatternItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/CreativePatternItem.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.item +package ru.dbotthepony.mc.otm.item.matter import net.minecraft.ChatFormatting import net.minecraft.core.Direction @@ -13,7 +13,6 @@ import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ICapabilityProvider import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.registries.ForgeRegistries -import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.matter.IPatternState import ru.dbotthepony.mc.otm.capability.matter.IPatternStorage diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/MatterCapacitorItem.kt similarity index 99% rename from src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/MatterCapacitorItem.kt index 465ee309a..c2ef417ad 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterCapacitorItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/MatterCapacitorItem.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.item +package ru.dbotthepony.mc.otm.item.matter import net.minecraft.ChatFormatting import net.minecraft.MethodsReturnNonnullByDefault diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/MatterDustItem.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/MatterDustItem.kt index 06b29621e..ccc0b3735 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatterDustItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/MatterDustItem.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.item +package ru.dbotthepony.mc.otm.item.matter import net.minecraft.ChatFormatting import net.minecraft.network.chat.Component @@ -11,7 +11,6 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.Level import ru.dbotthepony.mc.otm.config.ItemsConfig -import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.matter.IMatterItem diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PatternStorageItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/PatternStorageItem.kt similarity index 99% rename from src/main/kotlin/ru/dbotthepony/mc/otm/item/PatternStorageItem.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/PatternStorageItem.kt index db5c2a7d5..0f91e014e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PatternStorageItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/PatternStorageItem.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.item +package ru.dbotthepony.mc.otm.item.matter import net.minecraft.world.item.ItemStack import net.minecraft.nbt.CompoundTag diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/EnergySwordItem.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/EnergySwordItem.kt index 49dc70d01..2a4464e49 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EnergySwordItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/EnergySwordItem.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.item +package ru.dbotthepony.mc.otm.item.tool import com.google.common.collect.ImmutableMultimap import com.google.common.collect.Multimap @@ -45,18 +45,6 @@ import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.registry.EMPDamageSource import ru.dbotthepony.mc.otm.core.util.WriteOnce -/** - * This is called from [net.minecraft.world.item.enchantment.EnchantmentHelper.getSweepingDamageRatio] - * by coremod patch - */ -fun getSweepingDamageRatioHook(ply: LivingEntity): Float? { - if (ply.mainHandItem.item is EnergySwordItem && ply.mainHandItem.matteryEnergy?.extractEnergyExact(EnergySwordItem.ENERGY_PER_SWING, true) == true) { - return 1f - } - - return null -} - class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vanishable { val chargedAttributes: Multimap val dischargedAttributes: Multimap @@ -257,6 +245,19 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani builder.pop() } + /** + * This is called from [net.minecraft.world.item.enchantment.EnchantmentHelper.getSweepingDamageRatio] + * by coremod patch + */ + @JvmStatic + fun getSweepingDamageRatioHook(ply: LivingEntity): Float? { + if (ply.mainHandItem.item is EnergySwordItem && ply.mainHandItem.matteryEnergy?.extractEnergyExact(ENERGY_PER_SWING, true) == true) { + return 1f + } + + return null + } + private val DESCRIPTION = TranslatableComponent("item.overdrive_that_matters.energy_sword.desc").withStyle(ChatFormatting.DARK_GRAY) private val DESCRIPTION2 = TranslatableComponent("item.overdrive_that_matters.energy_sword.desc2").withStyle(ChatFormatting.DARK_GRAY) private val DESCRIPTION3 = TranslatableComponent("item.overdrive_that_matters.energy_sword.desc3").withStyle(ChatFormatting.DARK_GRAY) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ExplosiveHammerItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/ExplosiveHammerItem.kt similarity index 99% rename from src/main/kotlin/ru/dbotthepony/mc/otm/item/ExplosiveHammerItem.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/ExplosiveHammerItem.kt index b6962151b..fe9502518 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ExplosiveHammerItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/ExplosiveHammerItem.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.item +package ru.dbotthepony.mc.otm.item.tool import it.unimi.dsi.fastutil.objects.ObjectArraySet import net.minecraft.ChatFormatting diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatteryAxeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/MatteryAxeItem.kt similarity index 94% rename from src/main/kotlin/ru/dbotthepony/mc/otm/item/MatteryAxeItem.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/MatteryAxeItem.kt index 2de16d329..4ca35f083 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MatteryAxeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/MatteryAxeItem.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.item +package ru.dbotthepony.mc.otm.item.tool import net.minecraft.world.item.AxeItem import net.minecraft.world.item.ItemStack diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableGravitationStabilizerItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/PortableGravitationStabilizerItem.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableGravitationStabilizerItem.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/PortableGravitationStabilizerItem.kt index c09244d5e..4185f2dde 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableGravitationStabilizerItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/PortableGravitationStabilizerItem.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.item +package ru.dbotthepony.mc.otm.item.tool import net.minecraft.ChatFormatting import net.minecraft.client.model.HumanoidModel @@ -41,7 +41,7 @@ private object GravitationStabilizerArmorRenderProperties : IClientItemExtension } } -class ItemPortableGravitationStabilizer : ArmorItem(GravitationStabilizerArmorMaterial, EquipmentSlot.CHEST, Properties().stacksTo(1).rarity(Rarity.RARE)) { +class PortableGravitationStabilizerItem : ArmorItem(GravitationStabilizerArmorMaterial, EquipmentSlot.CHEST, Properties().stacksTo(1).rarity(Rarity.RARE)) { override fun initializeClient(consumer: Consumer) { super.initializeClient(consumer) consumer.accept(GravitationStabilizerArmorRenderProperties) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/SimpleTritaniumArmorItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/SimpleTritaniumArmorItem.kt similarity index 97% rename from src/main/kotlin/ru/dbotthepony/mc/otm/item/SimpleTritaniumArmorItem.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/SimpleTritaniumArmorItem.kt index 6dbeacff7..1745174ba 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/SimpleTritaniumArmorItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/SimpleTritaniumArmorItem.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.item +package ru.dbotthepony.mc.otm.item.tool import net.minecraft.sounds.SoundEvent import net.minecraft.sounds.SoundEvents diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/TritaniumArmorItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/TritaniumArmorItem.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/item/TritaniumArmorItem.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/TritaniumArmorItem.kt index 5cab53c53..102db11db 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/TritaniumArmorItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/TritaniumArmorItem.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.item +package ru.dbotthepony.mc.otm.item.tool import net.minecraft.client.model.HumanoidModel import net.minecraft.sounds.SoundEvent diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt index a999638b2..373719f59 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt @@ -4,7 +4,7 @@ import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.block.entity.matter.MatterRecyclerBlockEntity -import ru.dbotthepony.mc.otm.item.MatterDustItem +import ru.dbotthepony.mc.otm.item.matter.MatterDustItem import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput 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 925c5f3f1..db921ef0e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/ExplosiveHammerPrimingRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/ExplosiveHammerPrimingRecipe.kt @@ -18,7 +18,7 @@ import ru.dbotthepony.mc.otm.container.stream import ru.dbotthepony.mc.otm.core.isActuallyEmpty import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.core.set -import ru.dbotthepony.mc.otm.item.ExplosiveHammerItem +import ru.dbotthepony.mc.otm.item.tool.ExplosiveHammerItem import ru.dbotthepony.mc.otm.registry.MItems class ExplosiveHammerPrimingRecipe(private val _id: ResourceLocation, val payload: Ingredient) : CraftingRecipe { 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 c90fb40e2..dbc747d96 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -19,6 +19,19 @@ import ru.dbotthepony.mc.otm.config.ItemsConfig import ru.dbotthepony.mc.otm.core.collect.SupplierList import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.item.* +import ru.dbotthepony.mc.otm.item.exopack.ExoPackCraftingUpgradeItem +import ru.dbotthepony.mc.otm.item.exopack.ExoPackProbeItem +import ru.dbotthepony.mc.otm.item.exopack.ExoPackSlotUpgradeItem +import ru.dbotthepony.mc.otm.item.matter.CreativePatternItem +import ru.dbotthepony.mc.otm.item.matter.MatterCapacitorItem +import ru.dbotthepony.mc.otm.item.matter.MatterDustItem +import ru.dbotthepony.mc.otm.item.matter.PatternStorageItem +import ru.dbotthepony.mc.otm.item.tool.EnergySwordItem +import ru.dbotthepony.mc.otm.item.tool.ExplosiveHammerItem +import ru.dbotthepony.mc.otm.item.tool.MatteryAxeItem +import ru.dbotthepony.mc.otm.item.tool.PortableGravitationStabilizerItem +import ru.dbotthepony.mc.otm.item.tool.SimpleTritaniumArmorItem +import ru.dbotthepony.mc.otm.item.tool.TritaniumArmorItem import ru.dbotthepony.mc.otm.item.weapon.PlasmaRifleItem object MItems { @@ -190,7 +203,7 @@ object MItems { val TRITANIUM_SHIELD: ShieldItem by registry.register(MNames.TRITANIUM_SHIELD) { object : ShieldItem(Properties().durability(2048)) { override fun isValidRepairItem(pToRepair: ItemStack, pRepair: ItemStack): Boolean { - return pRepair.`is`(MItemTags.TRITANIUM_INGOTS) + return pRepair.`is`(MItemTags.REINFORCED_TRITANIUM_PLATES) } } } @@ -250,7 +263,7 @@ object MItems { val GRAVITATION_FIELD_LIMITER: Item by registry.register(MNames.GRAVITATION_FIELD_LIMITER) { Item(DEFAULT_PROPERTIES) } val GRAVITATION_FIELD_SENSOR: Item by registry.register(MNames.GRAVITATION_FIELD_SENSOR) { Item(DEFAULT_PROPERTIES) } - val PORTABLE_GRAVITATION_STABILIZER: Item by registry.register(MNames.PORTABLE_GRAVITATION_STABILIZER) { ItemPortableGravitationStabilizer() } + val PORTABLE_GRAVITATION_STABILIZER: Item by registry.register(MNames.PORTABLE_GRAVITATION_STABILIZER) { PortableGravitationStabilizerItem() } val BLACK_HOLE: Item by registry.register(MNames.BLACK_HOLE) { BlockItem(MBlocks.BLACK_HOLE, DEFAULT_PROPERTIES) } diff --git a/src/main/resources/coremods/code_injector.js b/src/main/resources/coremods/code_injector.js index 78cb5895f..a57584172 100644 --- a/src/main/resources/coremods/code_injector.js +++ b/src/main/resources/coremods/code_injector.js @@ -894,7 +894,7 @@ function initializeCoreMod() { var next = new MethodInsnNode( opcodesRemapped.invokestatic, - 'ru/dbotthepony/mc/otm/item/EnergySwordItemKt', + 'ru/dbotthepony/mc/otm/item/tool/EnergySwordItem', 'getSweepingDamageRatioHook', '(Lnet/minecraft/world/entity/LivingEntity;)Ljava/lang/Float;', false From 2ba1edf88d971b1fd45da5a8c82a45d609a1294f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 16 Apr 2023 19:15:04 +0700 Subject: [PATCH 0512/1199] Fix imports --- .../ru/dbotthepony/mc/otm/config/ServerConfig.kt | 16 ---------------- .../ru/dbotthepony/mc/otm/config/ToolsConfig.kt | 2 +- .../ru/dbotthepony/mc/otm/registry/MRegistry.kt | 2 +- 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt index 686a85282..f9d230094 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt @@ -1,21 +1,5 @@ package ru.dbotthepony.mc.otm.config -import net.minecraftforge.common.ForgeConfigSpec -import net.minecraftforge.fml.ModLoadingContext -import net.minecraftforge.fml.config.ModConfig -import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity -import ru.dbotthepony.mc.otm.block.entity.tech.ChemicalGeneratorBlockEntity -import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity -import ru.dbotthepony.mc.otm.block.entity.matter.MatterDecomposerBlockEntity -import ru.dbotthepony.mc.otm.block.entity.matter.MatterRecyclerBlockEntity -import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity -import ru.dbotthepony.mc.otm.block.entity.matter.MatterScannerBlockEntity -import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl -import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.math.defineDecimal -import ru.dbotthepony.mc.otm.item.EnergySwordItem -import ru.dbotthepony.mc.otm.registry.MNames - object ServerConfig : AbstractConfig("misc") { val LABORATORY_LAMP_LIGHT_LENGTH: Int by builder.comment("In blocks").defineInRange("LABORATORY_LAMP_LIGHT_LENGTH", 6, 1, 128) val INFINITE_EXOSUIT_UPGRADES: Boolean by builder.comment("Allows to apply the same upgrade over and over again.", "Obviously completely breaks balance.").define("INFINITE_EXOSUIT_UPGRADES", false) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ToolsConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ToolsConfig.kt index 400405afb..4a23f9c26 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ToolsConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ToolsConfig.kt @@ -1,6 +1,6 @@ package ru.dbotthepony.mc.otm.config -import ru.dbotthepony.mc.otm.item.EnergySwordItem +import ru.dbotthepony.mc.otm.item.tool.EnergySwordItem object ToolsConfig : AbstractConfig("tools") { val AXES_BREAK_LEAVES_INSTANTLY: Boolean by builder.define("AXES_BREAK_LEAVES_INSTANTLY", true) 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 5071cb617..50af44563 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -28,7 +28,7 @@ import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock import ru.dbotthepony.mc.otm.block.decorative.TritaniumPressurePlate import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.item.EnergySwordItem +import ru.dbotthepony.mc.otm.item.tool.EnergySwordItem import ru.dbotthepony.mc.otm.registry.objects.ColoredDecorativeBlock import ru.dbotthepony.mc.otm.registry.objects.CrateProperties import ru.dbotthepony.mc.otm.registry.objects.DecorativeBlock From 85aa5e7ce93210e2da5c58f3991fba6b0d0dc1f0 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 16 Apr 2023 19:30:52 +0700 Subject: [PATCH 0513/1199] hmm --- .../java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java | 2 +- .../kotlin/ru/dbotthepony/mc/otm/config/ToolsConfig.kt | 2 +- .../{tool => armor}/PortableGravitationStabilizerItem.kt | 2 +- .../otm/item/{tool => armor}/SimpleTritaniumArmorItem.kt | 2 +- .../mc/otm/item/{tool => armor}/TritaniumArmorItem.kt | 2 +- .../mc/otm/item/{tool => weapon}/EnergySwordItem.kt | 2 +- src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt | 8 ++++---- .../kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/item/{tool => armor}/PortableGravitationStabilizerItem.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/item/{tool => armor}/SimpleTritaniumArmorItem.kt (97%) rename src/main/kotlin/ru/dbotthepony/mc/otm/item/{tool => armor}/TritaniumArmorItem.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/item/{tool => weapon}/EnergySwordItem.kt (99%) diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index d84af44df..1eaa1daa5 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -47,7 +47,7 @@ import ru.dbotthepony.mc.otm.config.ServerConfig; import ru.dbotthepony.mc.otm.config.ToolsConfig; import ru.dbotthepony.mc.otm.core.math.Decimal; import ru.dbotthepony.mc.otm.item.tool.ExplosiveHammerItem; -import ru.dbotthepony.mc.otm.item.tool.TritaniumArmorItem; +import ru.dbotthepony.mc.otm.item.armor.TritaniumArmorItem; import ru.dbotthepony.mc.otm.item.QuantumBatteryItem; import ru.dbotthepony.mc.otm.item.weapon.AbstractWeaponItem; import ru.dbotthepony.mc.otm.item.PortableCondensationDriveItem; diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ToolsConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ToolsConfig.kt index 4a23f9c26..cc4e41e41 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ToolsConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ToolsConfig.kt @@ -1,6 +1,6 @@ package ru.dbotthepony.mc.otm.config -import ru.dbotthepony.mc.otm.item.tool.EnergySwordItem +import ru.dbotthepony.mc.otm.item.weapon.EnergySwordItem object ToolsConfig : AbstractConfig("tools") { val AXES_BREAK_LEAVES_INSTANTLY: Boolean by builder.define("AXES_BREAK_LEAVES_INSTANTLY", true) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/PortableGravitationStabilizerItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/PortableGravitationStabilizerItem.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/PortableGravitationStabilizerItem.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/PortableGravitationStabilizerItem.kt index 4185f2dde..2bf541b69 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/PortableGravitationStabilizerItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/PortableGravitationStabilizerItem.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.item.tool +package ru.dbotthepony.mc.otm.item.armor import net.minecraft.ChatFormatting import net.minecraft.client.model.HumanoidModel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/SimpleTritaniumArmorItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/SimpleTritaniumArmorItem.kt similarity index 97% rename from src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/SimpleTritaniumArmorItem.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/SimpleTritaniumArmorItem.kt index 1745174ba..55988f2e4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/SimpleTritaniumArmorItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/SimpleTritaniumArmorItem.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.item.tool +package ru.dbotthepony.mc.otm.item.armor import net.minecraft.sounds.SoundEvent import net.minecraft.sounds.SoundEvents diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/TritaniumArmorItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/TritaniumArmorItem.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/TritaniumArmorItem.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/TritaniumArmorItem.kt index 102db11db..0c2c8b954 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/TritaniumArmorItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/TritaniumArmorItem.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.item.tool +package ru.dbotthepony.mc.otm.item.armor import net.minecraft.client.model.HumanoidModel import net.minecraft.sounds.SoundEvent diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/EnergySwordItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt similarity index 99% rename from src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/EnergySwordItem.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt index 2a4464e49..e79e22482 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/EnergySwordItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.item.tool +package ru.dbotthepony.mc.otm.item.weapon import com.google.common.collect.ImmutableMultimap import com.google.common.collect.Multimap 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 dbc747d96..2909e31f5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -26,12 +26,12 @@ import ru.dbotthepony.mc.otm.item.matter.CreativePatternItem import ru.dbotthepony.mc.otm.item.matter.MatterCapacitorItem import ru.dbotthepony.mc.otm.item.matter.MatterDustItem import ru.dbotthepony.mc.otm.item.matter.PatternStorageItem -import ru.dbotthepony.mc.otm.item.tool.EnergySwordItem +import ru.dbotthepony.mc.otm.item.weapon.EnergySwordItem import ru.dbotthepony.mc.otm.item.tool.ExplosiveHammerItem import ru.dbotthepony.mc.otm.item.tool.MatteryAxeItem -import ru.dbotthepony.mc.otm.item.tool.PortableGravitationStabilizerItem -import ru.dbotthepony.mc.otm.item.tool.SimpleTritaniumArmorItem -import ru.dbotthepony.mc.otm.item.tool.TritaniumArmorItem +import ru.dbotthepony.mc.otm.item.armor.PortableGravitationStabilizerItem +import ru.dbotthepony.mc.otm.item.armor.SimpleTritaniumArmorItem +import ru.dbotthepony.mc.otm.item.armor.TritaniumArmorItem import ru.dbotthepony.mc.otm.item.weapon.PlasmaRifleItem object MItems { 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 50af44563..67addb73f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -28,7 +28,7 @@ import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock import ru.dbotthepony.mc.otm.block.decorative.TritaniumPressurePlate import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.item.tool.EnergySwordItem +import ru.dbotthepony.mc.otm.item.weapon.EnergySwordItem import ru.dbotthepony.mc.otm.registry.objects.ColoredDecorativeBlock import ru.dbotthepony.mc.otm.registry.objects.CrateProperties import ru.dbotthepony.mc.otm.registry.objects.DecorativeBlock From d3f97bfaa37b14fd0d15340c8e499be031edaa85 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 16 Apr 2023 21:18:37 +0700 Subject: [PATCH 0514/1199] Move procedural exopack slot upgrade to proper subpackage --- .../otm/item/{ => exopack}/ProceduralExoPackSlotUpgradeItem.kt | 3 +-- src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/item/{ => exopack}/ProceduralExoPackSlotUpgradeItem.kt (96%) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralExoPackSlotUpgradeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ProceduralExoPackSlotUpgradeItem.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralExoPackSlotUpgradeItem.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ProceduralExoPackSlotUpgradeItem.kt index 23432ea05..b66a98e7c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralExoPackSlotUpgradeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ProceduralExoPackSlotUpgradeItem.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.item +package ru.dbotthepony.mc.otm.item.exopack import net.minecraft.ChatFormatting import net.minecraft.network.chat.Component @@ -12,7 +12,6 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.tagNotNull import ru.dbotthepony.mc.otm.data.loot.IRandomizableItem -import ru.dbotthepony.mc.otm.item.exopack.AbstractExoPackSlotUpgradeItem import java.util.* @Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") // .tab(null) is a legal statement because tab field itself is nullable 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 2909e31f5..218a1fba1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -32,6 +32,7 @@ import ru.dbotthepony.mc.otm.item.tool.MatteryAxeItem import ru.dbotthepony.mc.otm.item.armor.PortableGravitationStabilizerItem import ru.dbotthepony.mc.otm.item.armor.SimpleTritaniumArmorItem import ru.dbotthepony.mc.otm.item.armor.TritaniumArmorItem +import ru.dbotthepony.mc.otm.item.exopack.ProceduralExoPackSlotUpgradeItem import ru.dbotthepony.mc.otm.item.weapon.PlasmaRifleItem object MItems { From 8f8f7db0a8b370d64c9a25058c7532b38f8c62c6 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Mon, 17 Apr 2023 01:47:37 +0600 Subject: [PATCH 0515/1199] Simple tritanium armor textures I am too afraid to touch things in it to add a SIMPLE 2D LAYER ARMOR so i'll leave actually adding it --- .../models/armor/tritanium_simple_layer_1.png | Bin 0 -> 586 bytes .../models/armor/tritanium_simple_layer_2.png | Bin 0 -> 352 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/models/armor/tritanium_simple_layer_1.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/models/armor/tritanium_simple_layer_2.png diff --git a/src/main/resources/assets/overdrive_that_matters/textures/models/armor/tritanium_simple_layer_1.png b/src/main/resources/assets/overdrive_that_matters/textures/models/armor/tritanium_simple_layer_1.png new file mode 100644 index 0000000000000000000000000000000000000000..b16dd66b072b9b452a6176eefd5f8a44b293ac91 GIT binary patch literal 586 zcmV-Q0=4~#P)Px#1ZP1_K>z@;j|==^1poj57*I@9MO|-tRAg<9sJDTdsCSQ>W_g5df{y?I0Qs?@ zegFUf2y{|TQ~&?}|NsC00N#VWSpWb432;bRa{vGi!vFvd!vV){sAK>D0jEhsK~zXf zt(Ae2!ypJmQPKSWANMW6q%*0POnb~Ft~p$B0c%^Dm14##r;qIKY~ z2ZGW@?|uA6;O^gRP+SD<`v}Z^cxyjoA@i8i#}>KgVVo2>CQQGjnN_my!%B71*ozIO zt@6D#;H@SW=^Kqri?h7UxmD=;69U{K=xwW=WGH+XAfhZ7({E`yX*fa9MIbB^h&j@I zT9*!?BuC2W(r$OSv;QNI_6e6J!4e*J5YP(u1obNF@qu!>B_OqH0!f~5X%xx&2-8#- z7GI+qPOPlXhd+IlT?wk2>8OPpfj^?1<*c4Mk zi6rp;&v;`8$esyS5%bdJLRBh)9V>tyF`n9=DVInR?NAqibau`iViiU6*AEUMqO{|z z-Gmj!)Ic}_SpVPSkeQw+K Y0%4>plL~sk>Hq)$07*qoM6N<$f~Uj-vH$=8 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/models/armor/tritanium_simple_layer_2.png b/src/main/resources/assets/overdrive_that_matters/textures/models/armor/tritanium_simple_layer_2.png new file mode 100644 index 0000000000000000000000000000000000000000..ced36769abb0ccb8c1bd8e4cdb01439ab3d3c6f3 GIT binary patch literal 352 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3-p)I`?e@QjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`MFV_7Tx0XALQ-;jS8OlupPk#(-#BXpP$t2ey&6cdmjw9*{|5sGDQ{*s zpb%$)M`SSr1K(i~W;~w1A_XXT(9^{+#KZgTM`8$ z>@nc)>8PoZS~E-Jq87s@hJ;ivb`jRspD$k$o3r#ZSL3fgTeLjCH*j$jJrsFj_cL|b zo(l_1ZNFUQJ@{+QcfZF`m-~zjLc-@nG(WsnXSYH2^W>nEQ|9y7r_8Q6bTMdR-;PHg o#j5JP|GRp>%lf#W>Gdy$^v&8V9(xnk13kmw>FVdQ&MBb@0Gn@$qyPW_ literal 0 HcmV?d00001 From 17abc2e29b08ffa31efd726369d2c3150e481a33 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Mon, 17 Apr 2023 02:37:05 +0600 Subject: [PATCH 0516/1199] Item textures for simple trarmor --- .../textures/item/simple_tritanium_boots.png | Bin 0 -> 232 bytes .../textures/item/simple_tritanium_chestplate.png | Bin 0 -> 258 bytes .../textures/item/simple_tritanium_helmet.png | Bin 0 -> 228 bytes .../textures/item/simple_tritanium_pants.png | Bin 0 -> 237 bytes 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/simple_tritanium_boots.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/simple_tritanium_chestplate.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/simple_tritanium_helmet.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/simple_tritanium_pants.png diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/simple_tritanium_boots.png b/src/main/resources/assets/overdrive_that_matters/textures/item/simple_tritanium_boots.png new file mode 100644 index 0000000000000000000000000000000000000000..d8d29497d3432f1bf27945cedc524bbf3ac20297 GIT binary patch literal 232 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}f0G|+78xQ}vyU#SvTA{72o!itOn_mT#31HI-2U6@ML4Lvi!GJ-^o7oL0 z#981GSPmZx<@4T?yz;RKA~;T z_+a(rhQxh&&7wE%Ea=*~@D*brL$u?U)x2B9oC<{RgtDw#xq)Nd9)-`$9e-I)Y>1yW Q6=*1fr>mdKI;Vst0B4*^)Bpeg literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/simple_tritanium_chestplate.png b/src/main/resources/assets/overdrive_that_matters/textures/item/simple_tritanium_chestplate.png new file mode 100644 index 0000000000000000000000000000000000000000..f31b9ba6a4182f2183c71ce96cb98725c48060aa GIT binary patch literal 258 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}f0G|+78xQ}vyU#SvT9Mn-ADdsLt*s4|S$3d%J&NS%G}f0G|+78xQ~3{Holher;{-##t-o?mh#QIi5d#2asYf3Gxg64+acU-pp=5 zAwpF_ Nc)I$ztaD0e0szT3PIdqQ literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/simple_tritanium_pants.png b/src/main/resources/assets/overdrive_that_matters/textures/item/simple_tritanium_pants.png new file mode 100644 index 0000000000000000000000000000000000000000..be736f3a4196ea6229391ef8b0ff9d74fb5a9ec0 GIT binary patch literal 237 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}f0G|+78xMbNZSBTcE9UM#liSoEn_mT#QJm(w0Z6fz1o;L32LlEvZ)P{3 z5NCl$WHAE+-(e7DJf6QI1t{p}>Ealo5uAH2kney32XjEzfxrDW8pgq!>P)^KTPSf@B!h6(i=wD$?5I&&1TiR$hXE>XSO+*1p VcGj9NIY5&cJYD@<);T3K0RY!NNz4EM literal 0 HcmV?d00001 From 7eaf1808279e4e46a76d42641da5a51fb060dabd Mon Sep 17 00:00:00 2001 From: GearShocky Date: Mon, 17 Apr 2023 02:37:48 +0600 Subject: [PATCH 0517/1199] make --- .../kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index b33a6a8f8..17f3f29e0 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -90,6 +90,7 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.handheld(MItems.TRITANIUM_TOOLS.filter { it != MItems.TRITANIUM_SHIELD }) provider.generated(MItems.TRITANIUM_ARMOR) + provider.generated(MItems.SIMPLE_TRITANIUM_ARMOR) provider.generatedTiered(MItems.BATTERIES, "battery_tier") provider.generated(MItems.BATTERY_CREATIVE) From 70f38c7e54719eba9ef925c63271987375502725 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Mon, 17 Apr 2023 02:40:21 +0600 Subject: [PATCH 0518/1199] Remove unnecessary "thrusters" on tritanium armor --- .../dbotthepony/mc/otm/client/model/TritaniumArmorModel.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/client/model/TritaniumArmorModel.java b/src/main/java/ru/dbotthepony/mc/otm/client/model/TritaniumArmorModel.java index af48f51ed..028b769e0 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/client/model/TritaniumArmorModel.java +++ b/src/main/java/ru/dbotthepony/mc/otm/client/model/TritaniumArmorModel.java @@ -69,9 +69,6 @@ public class TritaniumArmorModel { PartDefinition chestplateslope_r1 = body.addOrReplaceChild("chestplateslope_r1", CubeListBuilder.create().texOffs(44, 41).addBox(-4.0F, 0.5F, 0.4F, 8.0F, 4.0F, 2.0F, new CubeDeformation(0.39F)), PartPose.offsetAndRotation(0.0F, 6.4F, -6.2F, 1.2217F, 0.0F, 0.0F)); - PartDefinition thruster_r1 = body.addOrReplaceChild("thruster_r1", CubeListBuilder.create().texOffs(24, 0).addBox(-5.0F, 1.0F, 3.6F, 2.0F, 5.0F, 3.0F, new CubeDeformation(0.4F)) - .texOffs(24, 0).addBox(3.0F, 1.0F, 3.6F, 2.0F, 5.0F, 3.0F, new CubeDeformation(0.4F)), PartPose.offsetAndRotation(0.0F, 0.0F, 0.0F, 0.3927F, 0.0F, 0.0F)); - PartDefinition right_arm = partdefinition.addOrReplaceChild("right_arm", CubeListBuilder.create().texOffs(24, 32).addBox(-3.0F, -2.0F, -2.0F, 4.0F, 12.0F, 4.0F, new CubeDeformation(0.3F)) .texOffs(42, 56).addBox(-4.0F, -3.0F, -2.0F, 4.0F, 4.0F, 4.0F, new CubeDeformation(0.4F)), PartPose.offset(-5.0F, 2.0F, 0.0F)); From 232eeec9be3f1598d7135ca9c17e40fd30ea2df0 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 18 Apr 2023 10:28:29 +0700 Subject: [PATCH 0519/1199] =?UTF-8?q?=D0=92=D0=BE=D1=82=20=D0=B3=D0=B8?= =?UTF-8?q?=D1=80=D1=88=D0=BE=D0=BA=20=D1=82=D0=B2=D0=BE=D1=8F=20=D0=B1?= =?UTF-8?q?=D1=80=D0=BE=D0=BD=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/item/armor/SimpleTritaniumArmorItem.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/SimpleTritaniumArmorItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/SimpleTritaniumArmorItem.kt index 55988f2e4..1a80ef610 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/SimpleTritaniumArmorItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/SimpleTritaniumArmorItem.kt @@ -2,9 +2,11 @@ package ru.dbotthepony.mc.otm.item.armor import net.minecraft.sounds.SoundEvent import net.minecraft.sounds.SoundEvents +import net.minecraft.world.entity.Entity import net.minecraft.world.entity.EquipmentSlot import net.minecraft.world.item.ArmorItem import net.minecraft.world.item.ArmorMaterial +import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Ingredient import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.registry.MItemTags @@ -42,4 +44,14 @@ private object SimpleTritaniumArmorMaterial : ArmorMaterial { } class SimpleTritaniumArmorItem(slot: EquipmentSlot) : ArmorItem(SimpleTritaniumArmorMaterial, slot, Properties().stacksTo(1)) { + override fun getArmorTexture(stack: ItemStack, entity: Entity?, slot: EquipmentSlot, type: String?): String? { + if (type != "overlay" || slot == EquipmentSlot.FEET) + return when (slot) { + EquipmentSlot.LEGS -> "${OverdriveThatMatters.MOD_ID}:textures/models/armor/tritanium_simple_layer_2.png" + EquipmentSlot.FEET, EquipmentSlot.CHEST, EquipmentSlot.HEAD -> "${OverdriveThatMatters.MOD_ID}:textures/models/armor/tritanium_simple_layer_1.png" + else -> throw IllegalArgumentException("Invalid slot $slot") + } + + return null + } } From d151ba46fbc40856ec7cb9bed2703d86a1981808 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 24 Apr 2023 16:29:11 +0700 Subject: [PATCH 0520/1199] Small adjustments --- .../energy/ItemEnergyStorageImpl.kt | 47 ++++++++++--------- .../ru/dbotthepony/mc/otm/item/BatteryItem.kt | 4 +- .../ProceduralExoPackSlotUpgradeItem.kt | 4 +- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt index 3a4708335..b658152fe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt @@ -19,35 +19,21 @@ import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.tagNotNull -sealed class ItemEnergyStorageImpl( - final override val energyFlow: FlowDirection, - protected val itemStack: ItemStack, - maxBatteryLevel: Decimal, - maxInput: Decimal?, - maxOutput: Decimal?, - val initialBatteryLevel: Decimal = Decimal.ZERO -) : IMatteryEnergyStorage, ICapabilityProvider, IEnergyStorageImpl { - final override var maxInput: Decimal? = maxInput - protected set - - final override var maxOutput: Decimal? = maxOutput - protected set - +abstract class ItemEnergyStorageImpl(val itemStack: ItemStack) : IMatteryEnergyStorage, ICapabilityProvider, IEnergyStorageImpl { private val resolver = LazyOptional.of { this } private val resolverMekanism = if (isMekanismLoaded) LazyOptional.of { Mattery2MekanismEnergyWrapper(this) } else null override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - if (cap == ForgeCapabilities.ENERGY || cap == MatteryCapability.ENERGY) { + if (cap === ForgeCapabilities.ENERGY || cap === MatteryCapability.ENERGY) { return resolver.cast() - } else if (cap == MatteryCapability.MEKANISM_ENERGY) { + } else if (cap === MatteryCapability.MEKANISM_ENERGY) { return resolverMekanism?.cast() ?: LazyOptional.empty() } return LazyOptional.empty() } - override var maxBatteryLevel: Decimal = maxBatteryLevel - protected set + abstract val initialBatteryLevel: Decimal override var batteryLevel: Decimal get() = itemStack.tag?.map(ENERGY_KEY, Decimal.Companion::deserializeNBT) ?: initialBatteryLevel @@ -128,13 +114,31 @@ sealed class ItemEnergyStorageImpl( } } +abstract class SimpleEnergyItem( + override val energyFlow: FlowDirection, + stack: ItemStack, + maxBatteryLevel: Decimal, + maxInput: Decimal?, + maxOutput: Decimal?, + override val initialBatteryLevel: Decimal +) : ItemEnergyStorageImpl(stack) { + override var maxInput: Decimal? = maxInput + protected set + + override var maxOutput: Decimal? = maxOutput + protected set + + override var maxBatteryLevel: Decimal = maxBatteryLevel + protected set +} + open class EnergyConsumerItem( stack: ItemStack, maxBatteryLevel: Decimal, maxInput: Decimal? = null, maxOutput: Decimal? = maxInput, initialBatteryLevel: Decimal = Decimal.ZERO -) : ItemEnergyStorageImpl(FlowDirection.INPUT, stack, maxBatteryLevel, maxInput, maxOutput, initialBatteryLevel) +) : SimpleEnergyItem(FlowDirection.INPUT, stack, maxBatteryLevel, maxInput, maxOutput, initialBatteryLevel) open class EnergyProducerItem( stack: ItemStack, @@ -142,7 +146,7 @@ open class EnergyProducerItem( maxInput: Decimal? = null, maxOutput: Decimal? = maxInput, initialBatteryLevel: Decimal = Decimal.ZERO -) : ItemEnergyStorageImpl(FlowDirection.OUTPUT, stack, maxBatteryLevel, maxInput, maxOutput, initialBatteryLevel) +) : SimpleEnergyItem(FlowDirection.OUTPUT, stack, maxBatteryLevel, maxInput, maxOutput, initialBatteryLevel) open class EnergyCapacitorItem( stack: ItemStack, @@ -150,4 +154,5 @@ open class EnergyCapacitorItem( maxInput: Decimal? = null, maxOutput: Decimal? = maxInput, initialBatteryLevel: Decimal = Decimal.ZERO -) : ItemEnergyStorageImpl(FlowDirection.BI_DIRECTIONAL, stack, maxBatteryLevel, maxInput, maxOutput, initialBatteryLevel) +) : SimpleEnergyItem(FlowDirection.BI_DIRECTIONAL, stack, maxBatteryLevel, maxInput, maxOutput, initialBatteryLevel) + diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt index 19710415f..f983a909b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt @@ -168,9 +168,7 @@ class CrudeBatteryItem : BatteryItem(ItemsConfig.Batteries.CRUDE) { ) { super.appendHoverText(stack, p_41422_, p_41423_, p_41424_) - val isAndroid = runIfClient(false) { - return@runIfClient minecraft.player?.matteryPlayer?.isAndroid ?: false - } + val isAndroid = runIfClient(false) { minecraft.player?.matteryPlayer?.isAndroid ?: false } if (isAndroid) { p_41423_.add(TranslatableComponent("otm.gui.crude_battery.replace_in_world").withStyle(ChatFormatting.GRAY)) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ProceduralExoPackSlotUpgradeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ProceduralExoPackSlotUpgradeItem.kt index b66a98e7c..c4b7d8915 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ProceduralExoPackSlotUpgradeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ProceduralExoPackSlotUpgradeItem.kt @@ -14,9 +14,7 @@ import ru.dbotthepony.mc.otm.core.tagNotNull import ru.dbotthepony.mc.otm.data.loot.IRandomizableItem import java.util.* -@Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") // .tab(null) is a legal statement because tab field itself is nullable -class ProceduralExoPackSlotUpgradeItem : AbstractExoPackSlotUpgradeItem(defaultProperties()), - IRandomizableItem { +class ProceduralExoPackSlotUpgradeItem : AbstractExoPackSlotUpgradeItem(defaultProperties()), IRandomizableItem { override fun getRarity(itemStack: ItemStack): Rarity { return when (slotCount(itemStack)) { in 0 .. 9 -> Rarity.COMMON From 3722d896f6db07aac45beebc792bde61a3fb7ff1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 24 Apr 2023 16:50:01 +0700 Subject: [PATCH 0521/1199] Bump to minecraft 1.19.4 --- build.gradle.kts | 17 ++++++++++------- gradle.properties | 37 ++++++++++++++++--------------------- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index f4dbd601b..077846911 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,7 +12,7 @@ val forge_version: String by project val mod_id: String by project val handle_deps: String by project val use_commit_hash_in_version: String by project -val handleDeps = handle_deps == "true" +val handleDeps = handle_deps.toBoolean() plugins { java @@ -150,7 +150,6 @@ dependencies { val kotlin_coroutines_version: String by project val kotlin_serialization_version: String by project val mixin_version: String by project - val koremods_modlauncher_version: String by project minecraft("net.minecraftforge:forge:$mc_version-$forge_version") testImplementation("org.junit.jupiter:junit-jupiter:${jupiter_version}") @@ -179,10 +178,7 @@ dependencies { val cosmetic_armor_reworked_id: String by project val jade_id: String by project val configured_id: String by project - val worldedit_fileid: String by project - val more_overlays_version: String by project val curios_version: String by project - val deps_mc_version: String by project val jei_mc_version: String by project val curios_mc_version: String by project val ad_astra_id: String by project @@ -205,7 +201,7 @@ dependencies { // runtimeOnly(fg.deobf("curse.maven:worldedit-225608:${worldedit_fileid}")) // runtimeOnly(fg.deobf("at.ridgo8.moreoverlays:MoreOverlays-updated:${more_overlays_version}")) - compileOnly(fg.deobf("mekanism:Mekanism:${deps_mc_version}-${mekanism_version}:all")) + compileOnly(fg.deobf("mekanism:Mekanism:${mekanism_version}:all")) // runtimeOnly(fg.deobf("curse.maven:cyclops-core-232758:4392602")) // runtimeOnly(fg.deobf("curse.maven:integrated-dynamics-236307:4391535")) @@ -222,7 +218,14 @@ configurations { } minecraft { - mappings("parchment", parchment_version) + val use_parchment: String by project + + if (use_parchment.toBoolean()) { + mappings("parchment", parchment_version) + } else { + mappings("official", mc_version) + } + accessTransformer(file("src/main/resources/META-INF/accesstransformer.cfg")) runs { diff --git a/gradle.properties b/gradle.properties index da9732d31..12fe55182 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,34 +6,29 @@ kotlin.stdlib.default.dependency=false org.gradle.vfs.watch=true mod_id=overdrive_that_matters -mod_version=1.1 +mod_version=1.2 use_commit_hash_in_version=true -koremods_modlauncher_version=0.5.7 -koremods_script_version=0.5.0 +mc_version=1.19.4 +use_parchment=false +parchment_version=2023.03.12-1.19.3 +jei_mc_version=1.19.4 +curios_mc_version=1.19.4 -mc_version=1.19.3 -parchment_version=2022.12.18-1.19.3 -jei_mc_version=1.19.3 -deps_mc_version=1.19.2 -curios_mc_version=1.19.3 - -forge_gradle_version=5.1.27 -forge_version=44.1.5 +forge_gradle_version=5.1.+ +forge_version=45.0.47 mixingradle_version=0.7.32 mixin_version=0.8.5 -jei_version=12.0.2.2 -jupiter_version=5.8.2 -mekanism_version=10.3.5.homebaked -curios_version=5.1.4.0 -cosmetic_armor_reworked_id=4145717 -ad_astra_id=4390126 -jade_id=4330163 -configured_id=4166861 -worldedit_fileid=3922622 -more_overlays_version=1.21.3-mc1.19 +jei_version=13.1.0.6 +jupiter_version=5.9.2 +mekanism_version=1.19.2-10.3.5.homebaked +curios_version=5.1.5.1 +cosmetic_armor_reworked_id=4439659 +ad_astra_id=4452010 +jade_id=4439089 +configured_id=4462894 kotlin_for_forge_version=3.1.0 kotlin_version=1.8.0 From e60dda48104b7cde8b17910458755c1c97c336e8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 26 Apr 2023 07:41:32 +0700 Subject: [PATCH 0522/1199] Update tags datagen --- .../dbotthepony/mc/otm/datagen/tags/Tags.kt | 42 +-- .../mc/otm/datagen/tags/TagsProvider.kt | 287 +++++++++--------- 2 files changed, 160 insertions(+), 169 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index 096f58816..71cd971b5 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -47,10 +47,10 @@ fun addTags(tagsProvider: TagsProvider) { MBlocks.STORAGE_CABLE ) - tagsProvider.items.appender(MItemTags.CRAFTING_TABLES).add(Items.CRAFTING_TABLE) - tagsProvider.blocks.appender(MBlockTags.CRAFTING_TABLES).add(Blocks.CRAFTING_TABLE) + tagsProvider.items.Appender(MItemTags.CRAFTING_TABLES).add(Items.CRAFTING_TABLE) + tagsProvider.blocks.Appender(MBlockTags.CRAFTING_TABLES).add(Blocks.CRAFTING_TABLE) - tagsProvider.items.appender(MItemTags.MINECART_CARGO_CRATES).add(MItems.CARGO_CRATE_MINECARTS.values) + tagsProvider.items.Appender(MItemTags.MINECART_CARGO_CRATES).add(MItems.CARGO_CRATE_MINECARTS.values) tagsProvider.items.forge("hardened_glass").add(MRegistry.INDUSTRIAL_GLASS.allItems.values) tagsProvider.items.forge("hardened_glass/colorless").add(MRegistry.INDUSTRIAL_GLASS.item) @@ -74,25 +74,25 @@ fun addTags(tagsProvider: TagsProvider) { MRegistry.INDUSTRIAL_GLASS.forEachBlock { s, _, block -> tagsProvider.blocks.forge("hardened_glass/$s").add(block) } MRegistry.INDUSTRIAL_GLASS_PANE.forEachBlock { s, _, block -> tagsProvider.blocks.forge("hardened_glass_panes/$s").add(block) } - tagsProvider.items.appender(MItemTags.INDUSTRIAL_GLASS).add(MRegistry.INDUSTRIAL_GLASS.allItems.values) - tagsProvider.blocks.appender(MBlockTags.INDUSTRIAL_GLASS).add(MRegistry.INDUSTRIAL_GLASS.allBlocks.values) - tagsProvider.blocks.appender(MBlockTags.CARGO_CRATES).add(MRegistry.CARGO_CRATES.allBlocks.values) + tagsProvider.items.Appender(MItemTags.INDUSTRIAL_GLASS).add(MRegistry.INDUSTRIAL_GLASS.allItems.values) + tagsProvider.blocks.Appender(MBlockTags.INDUSTRIAL_GLASS).add(MRegistry.INDUSTRIAL_GLASS.allBlocks.values) + tagsProvider.blocks.Appender(MBlockTags.CARGO_CRATES).add(MRegistry.CARGO_CRATES.allBlocks.values) - tagsProvider.items.appender(ItemTags.DOORS).add(MItems.TRITANIUM_DOOR.values) - tagsProvider.blocks.appender(BlockTags.DOORS).add(MBlocks.TRITANIUM_DOOR.values) + tagsProvider.items.Appender(ItemTags.DOORS).add(MItems.TRITANIUM_DOOR.values) + tagsProvider.blocks.Appender(BlockTags.DOORS).add(MBlocks.TRITANIUM_DOOR.values) - tagsProvider.items.appender(ItemTags.TRAPDOORS).add(MItems.TRITANIUM_TRAPDOOR.values) - tagsProvider.blocks.appender(BlockTags.TRAPDOORS).add(MBlocks.TRITANIUM_TRAPDOOR.values) + tagsProvider.items.Appender(ItemTags.TRAPDOORS).add(MItems.TRITANIUM_TRAPDOOR.values) + tagsProvider.blocks.Appender(BlockTags.TRAPDOORS).add(MBlocks.TRITANIUM_TRAPDOOR.values) - tagsProvider.blocks.appender(BlockTags.PRESSURE_PLATES).add(MRegistry.TRITANIUM_PRESSURE_PLATE.allBlocks.values) + tagsProvider.blocks.Appender(BlockTags.PRESSURE_PLATES).add(MRegistry.TRITANIUM_PRESSURE_PLATE.allBlocks.values) - tagsProvider.items.appender(MItemTags.MACHINES).add(MItems.MACHINES) - tagsProvider.blocks.appender(MBlockTags.MACHINES).add(MItems.MACHINES.stream().map { it!!.block }) + tagsProvider.items.Appender(MItemTags.MACHINES).add(MItems.MACHINES) + tagsProvider.blocks.Appender(MBlockTags.MACHINES).add(MItems.MACHINES.stream().map { it!!.block }) - tagsProvider.blocks.appender(BlockTags.ANVIL).add(MBlocks.TRITANIUM_ANVIL) + tagsProvider.blocks.Appender(BlockTags.ANVIL).add(MBlocks.TRITANIUM_ANVIL) - tagsProvider.items.appender(MItemTags.TRITANIUM_NUGGETS).add(MItems.TRITANIUM_NUGGET) - tagsProvider.items.appender(MItemTags.NUGGETS).add(MItems.TRITANIUM_NUGGET) + tagsProvider.items.Appender(MItemTags.TRITANIUM_NUGGETS).add(MItems.TRITANIUM_NUGGET) + tagsProvider.items.Appender(MItemTags.NUGGETS).add(MItems.TRITANIUM_NUGGET) tagsProvider.items.forge("armors") .add("helmets", MItems.TRITANIUM_HELMET) @@ -113,30 +113,30 @@ fun addTags(tagsProvider: TagsProvider) { .add("shields", MItems.TRITANIUM_SHIELD) tagsProvider.items.forge("shears").add(MItems.TRITANIUM_SHEARS) - tagsProvider.blocks.appender(BlockTags.STAIRS) + tagsProvider.blocks.Appender(BlockTags.STAIRS) .add(MRegistry.FLOOR_TILES_STAIRS.blocks.values) .add(MRegistry.TRITANIUM_STAIRS.allBlocks.values) .add(MRegistry.TRITANIUM_STRIPED_STAIRS.flatBlocks) .add(MBlocks.TRITANIUM_STRIPED_STAIRS) - tagsProvider.blocks.appender(BlockTags.SLABS) + tagsProvider.blocks.Appender(BlockTags.SLABS) .add(MRegistry.TRITANIUM_SLAB.allBlocks.values) .add(MRegistry.TRITANIUM_STRIPED_SLAB.flatBlocks) .add(MRegistry.FLOOR_TILES_SLAB.blocks.values) .add(MBlocks.TRITANIUM_STRIPED_SLAB) - tagsProvider.blocks.appender(BlockTags.WALLS) + tagsProvider.blocks.Appender(BlockTags.WALLS) .add(MRegistry.TRITANIUM_WALL.allBlocks.values) .add(MRegistry.TRITANIUM_STRIPED_WALL.flatBlocks) .add(MBlocks.TRITANIUM_STRIPED_WALL) - tagsProvider.items.appender(ItemTags.SLABS) + tagsProvider.items.Appender(ItemTags.SLABS) .add(MRegistry.TRITANIUM_SLAB.allItems.values) .add(MRegistry.TRITANIUM_STRIPED_SLAB.flatItems) .add(MRegistry.FLOOR_TILES_SLAB.items.values) .add(MItems.TRITANIUM_STRIPED_SLAB) - tagsProvider.items.appender(ItemTags.WALLS) + tagsProvider.items.Appender(ItemTags.WALLS) .add(MRegistry.TRITANIUM_WALL.allItems.values) .add(MRegistry.TRITANIUM_STRIPED_WALL.flatItems) .add(MItems.TRITANIUM_STRIPED_WALL) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt index 67bbdcb67..370522b10 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt @@ -22,62 +22,110 @@ import ru.dbotthepony.mc.otm.datagen.DataGen import java.util.stream.Stream import net.minecraft.data.tags.TagsProvider as MinecraftTagsProvider -interface MTagAppender { - fun add(value: T): MTagAppender - fun addSafe(value: T): Boolean - fun add(vararg values: T): MTagAppender - fun addSafe(vararg values: T): Boolean { - var any = false - for (value in values) any = addSafe(value) - return any - } - - fun add(values: Collection): MTagAppender - fun add(values: Stream): MTagAppender = add(values.toList()) - - fun addSafe(values: Collection): Boolean { - var any = false - for (value in values) any = addSafe(value) - return any - } -} - -interface ForgeTagAppender : MTagAppender { - fun add(key: String, value: T): ForgeTagAppender - fun addSafe(key: String, value: T): Boolean - fun add(key: String, vararg values: T): ForgeTagAppender - fun addSafe(key: String, vararg values: T): Boolean { - var any = false - for (value in values) any = addSafe(key, value) - return any - } - - fun add(key: String, values: Collection): ForgeTagAppender - - fun addSafe(key: String, values: Collection): Boolean { - var any = false - for (value in values) any = addSafe(key, value) - return any - } -} - -private fun vanillaLookup(key: ResourceKey>): (T) -> ResourceLocation? { +private fun vanillaLookup(key: ResourceKey>): (T) -> ResourceLocation { val registry by lazy { (BuiltInRegistries.REGISTRY.get(key.location()) ?: throw NoSuchElementException("No such registry $key")) as Registry } - return { registry.getKey(it) } + return { registry.getKey(it) ?: throw NoSuchElementException("Registry $key does not contain $it") } } -class TagsProvider( - private val event: GatherDataEvent -) { - inner class Delegate private constructor(key: ResourceKey>, val lookup: (T) -> ResourceLocation?) : MinecraftTagsProvider(event.generator.packOutput, key, event.lookupProvider, DataGen.MOD_ID, event.existingFileHelper) { - constructor(registry: IForgeRegistry) : this(registry.registryKey, registry::getKey) +class TagsProvider(private val event: GatherDataEvent) { + inner class Delegate private constructor(key: ResourceKey>, val lookup: (T) -> ResourceLocation) : MinecraftTagsProvider(event.generator.packOutput, key, event.lookupProvider, DataGen.MOD_ID, event.existingFileHelper) { + constructor(registry: IForgeRegistry) : this(registry.registryKey, { registry.getKey(it) ?: throw NoSuchElementException("Registry $registry does not contain $it") }) constructor(key: ResourceKey>) : this(key, vanillaLookup(key)) init { - event.generator.addProvider(true, this) + if (isRegistered) + event.generator.addProvider(event.includeServer(), this) + else + delegates.add(this) } - private val tags = HashMap, ObjectArraySet>() + private val tags = HashMap, ObjectArraySet>() + private val rigidTags = HashMap, ObjectArraySet>>() + private val tagInTag = HashMap, ObjectArraySet>>() + + inner class Appender(val tag: TagKey) { + constructor(tag: ResourceLocation) : this(TagKey.create(registryKey, tag)) + + private val locations by lazy { tags.computeIfAbsent(tag) { ObjectArraySet() } } + private val rigidLocations by lazy { rigidTags.computeIfAbsent(tag) { ObjectArraySet() } } + private val tagsInTags by lazy { tagInTag.computeIfAbsent(tag) { ObjectArraySet() } } + + fun add(value: ResourceLocation): Appender { + if (!locations.add(value)) { + throw IllegalStateException("Tag $tag of registry $registryKey already contains $value") + } + + return this + } + + fun add(value: ResourceKey): Appender { + require(value.registry() == registryKey) { "Invalid registry in provided ResourceKey: ${value.registry()} (this tag appender is for $registryKey)" } + + if (!rigidLocations.add(value)) { + throw IllegalStateException("Tag $tag of registry $registryKey already contains $value") + } + + return this + } + + fun add(value: TagKey): Appender { + require(value.registry() == registryKey) { "Invalid registry in provided ResourceKey: ${value.registry()} (this tag appender is for $registryKey)" } + + if (!tagsInTags.add(value)) { + throw IllegalStateException("Tag $tag of registry $registryKey already contains $value") + } + + return this + } + + fun add(value: T): Appender { + return add(ResourceKey.create(registryKey, lookup.invoke(value))) + } + + fun add(values: Collection): Appender { + for (value in values) add(value) + return this + } + + fun add(vararg values: T): Appender { + for (value in values) add(value) + return this + } + + fun add(vararg values: ResourceKey): Appender { + for (value in values) add(value) + return this + } + + fun add(vararg values: TagKey): Appender { + for (value in values) add(value) + return this + } + + fun add(vararg values: ResourceLocation): Appender { + for (value in values) add(value) + return this + } + + fun add(values: Stream): Appender { + values.forEach { add(it) } + return this + } + + fun leaf(name: String) = Appender(TagKey.create(tag.registry, ResourceLocation(tag.location.namespace, tag.location.path + "/$name"))) + + fun add(leaf: String, value: T) = also { leaf(leaf).add(value) } + fun add(leaf: String, value: TagKey) = also { leaf(leaf).add(value) } + fun add(leaf: String, vararg value: T) = also { leaf(leaf).add(*value) } + fun add(leaf: String, vararg value: TagKey) = also { leaf(leaf).add(*value) } + fun add(leaf: String, value: Stream) = also { leaf(leaf).add(value) } + fun add(leaf: String, value: ResourceKey) = also { leaf(leaf).add(value) } + fun add(leaf: String, vararg value: ResourceKey) = also { leaf(leaf).add(*value) } + fun add(leaf: String, value: ResourceLocation) = also { leaf(leaf).add(value) } + fun add(leaf: String, vararg value: ResourceLocation) = also { leaf(leaf).add(*value) } + } + + fun forge(path: String) = Appender(ResourceLocation("forge", path)) override fun addTags(provider: HolderLookup.Provider) { if (tags.isEmpty()) { @@ -85,121 +133,64 @@ class TagsProvider( } for ((tag, values) in tags) { - tag(tag).also { - for (value in values) { - it.add(ResourceKey.create(registryKey, lookup(value) ?: throw NoSuchElementException("$value is missing from $registryKey"))) - } + val appender = tag(tag) + + for (value in values) { + appender.addOptional(value) + } + } + + for ((tag, values) in rigidTags) { + val appender = tag(tag) + + for (value in values) { + appender.add(value) + } + } + + for ((tag, values) in tagInTag) { + val appender = tag(tag) + + for (value in values) { + appender.addTag(value) } } } + } - fun getSet(tag: TagKey): MutableSet { - return tags.computeIfAbsent(tag) { ObjectArraySet() } - } + private val delegates = ArrayList>() + private var isRegistered = false - fun getSet(location: ResourceLocation) = getSet(TagKey.create(registryKey, location)) + fun register() { + if (!isRegistered) { + isRegistered = true - fun appender(tag: TagKey, message: ((T) -> Any) = { "$it is already in $tag" }): MTagAppender { - val list = getSet(tag) - - return object : MTagAppender { - override fun add(value: T): MTagAppender { - if (!list.add(value)) { - throw IllegalStateException(message.invoke(value).toString()) - } - - return this - } - - override fun add(values: Collection): MTagAppender { - for (value in values) add(value) - return this - } - - override fun addSafe(value: T): Boolean { - return list.add(value) - } - - override fun add(vararg values: T): MTagAppender { - values.forEach(this::add) - return this - } + for (value in delegates) { + event.generator.addProvider(event.includeServer(), value) } - } - fun forge(path: String): ForgeTagAppender { - val parent by lazy { appender(ResourceLocation("forge", path)) } - - return object : ForgeTagAppender { - override fun add(key: String, value: T): ForgeTagAppender { - val tag = TagKey.create(registryKey, ResourceLocation("forge", "$path/$key")) - - if (!getSet(tag).add(value)) { - throw IllegalStateException("$value is already in $tag") - } - - return this - } - - override fun addSafe(key: String, value: T): Boolean { - val tag = TagKey.create(registryKey, ResourceLocation("forge", "$path/$key")) - return getSet(tag).add(value) - } - - override fun add(key: String, vararg values: T): ForgeTagAppender { - for (value in values) add(key, value) - return this - } - - override fun add(key: String, values: Collection): ForgeTagAppender { - for (value in values) add(key, value) - return this - } - - override fun add(value: T): MTagAppender { - return parent.add(value) - } - - override fun addSafe(value: T): Boolean { - return parent.addSafe(value) - } - - override fun add(vararg values: T): MTagAppender { - return parent.add(*values) - } - - override fun add(values: Collection): MTagAppender { - return parent.add(values) - } - } - } - - fun appender(location: ResourceLocation): MTagAppender { - return appender(TagKey.create(registryKey, location)) - } - - fun appender(location: ResourceLocation, message: (T) -> Any): MTagAppender { - return appender(TagKey.create(registryKey, location), message) + delegates.clear() } } val blocks = Delegate(ForgeRegistries.BLOCKS) val items = Delegate(ForgeRegistries.ITEMS) val mobEffects = Delegate(ForgeRegistries.MOB_EFFECTS) + val damageTypes = Delegate(Registries.DAMAGE_TYPE) - val androidImmuneEffects = mobEffects.appender(MatteryPlayerCapability.ANDROID_IMMUNE_EFFECTS) + val androidImmuneEffects = mobEffects.Appender(MatteryPlayerCapability.ANDROID_IMMUNE_EFFECTS) - val requiresShovel = blocks.appender(BlockTags.MINEABLE_WITH_SHOVEL) - val requiresAxe = blocks.appender(BlockTags.MINEABLE_WITH_AXE) - val requiresHoe = blocks.appender(BlockTags.MINEABLE_WITH_HOE) - val requiresPickaxe = blocks.appender(BlockTags.MINEABLE_WITH_PICKAXE) + val requiresShovel = blocks.Appender(BlockTags.MINEABLE_WITH_SHOVEL) + val requiresAxe = blocks.Appender(BlockTags.MINEABLE_WITH_AXE) + val requiresHoe = blocks.Appender(BlockTags.MINEABLE_WITH_HOE) + val requiresPickaxe = blocks.Appender(BlockTags.MINEABLE_WITH_PICKAXE) - val requiresStoneTool = blocks.appender(BlockTags.NEEDS_STONE_TOOL) - val requiresIronTool = blocks.appender(BlockTags.NEEDS_IRON_TOOL) - val requiresDiamondTool = blocks.appender(BlockTags.NEEDS_DIAMOND_TOOL) + val requiresStoneTool = blocks.Appender(BlockTags.NEEDS_STONE_TOOL) + val requiresIronTool = blocks.Appender(BlockTags.NEEDS_IRON_TOOL) + val requiresDiamondTool = blocks.Appender(BlockTags.NEEDS_DIAMOND_TOOL) - val witherImmune = blocks.appender(BlockTags.WITHER_IMMUNE) - val dragonImmune = blocks.appender(BlockTags.DRAGON_IMMUNE) + val witherImmune = blocks.Appender(BlockTags.WITHER_IMMUNE) + val dragonImmune = blocks.Appender(BlockTags.DRAGON_IMMUNE) fun stoneOre(key: String, block: Block): TagsProvider { ore(key, block) @@ -233,9 +224,9 @@ class TagsProvider( val b = TagKey.create(Registries.BLOCK, forgeKey) val i = TagKey.create(Registries.ITEM, forgeKey) - items.getSet(i).add(block.asItem()) + items.Appender(i).add(block.asItem()) itemOres.add(block.asItem()) - blocks.getSet(b).add(block) + blocks.Appender(b).add(block) blockOres.add(block) return this @@ -286,7 +277,7 @@ class TagsProvider( // val itemOreRatesDense = items.forge("ore_rates/dense") val gameEvents = Delegate(Registries.GAME_EVENT) - val vibrations = gameEvents.appender(GameEventTags.VIBRATIONS) + val vibrations = gameEvents.Appender(GameEventTags.VIBRATIONS) fun requiresPickaxe(block: Block, tier: Tier? = null): TagsProvider { requiresPickaxe.add(block) From 7e9d5ddbf845b3cdbf362ebd681f26177f1c53e0 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 26 Apr 2023 08:21:31 +0700 Subject: [PATCH 0523/1199] Make it compile against 1.19.4 --- .../dbotthepony/mc/otm/datagen/DamageTypes.kt | 58 ++++ .../ru/dbotthepony/mc/otm/datagen/DataGen.kt | 4 + .../mc/otm/datagen/lang/English.kt | 12 +- .../mc/otm/datagen/lang/Russian.kt | 12 +- .../mc/otm/android/AndroidFeatureType.kt | 2 +- .../mc/otm/android/AndroidResearchType.kt | 2 +- .../android/feature/EnderTeleporterFeature.kt | 1 + .../android/feature/FallDampenersFeature.kt | 1 + .../otm/android/feature/ItemMagnetFeature.kt | 4 +- .../android/feature/NanobotsArmorFeature.kt | 1 + .../otm/android/feature/ShockwaveFeature.kt | 8 +- .../decorative/TritaniumPressurePlate.kt | 11 +- .../entity/blackhole/BlackHoleBlockEntity.kt | 9 +- .../blackhole/ExplosionDebuggerBlockEntity.kt | 2 +- .../otm/block/entity/blackhole/Explosions.kt | 6 +- .../entity/storage/ItemMonitorBlockEntity.kt | 8 +- .../entity/tech/PlatePressBlockEntity.kt | 6 +- .../otm/block/tech/PhantomAttractorBlock.kt | 8 +- .../otm/capability/MatteryPlayerCapability.kt | 12 +- .../dbotthepony/mc/otm/client/render/Ext.kt | 76 +++--- .../mc/otm/client/render/GlitchRenderer.kt | 1 - .../mc/otm/client/render/RenderHelper.kt | 5 - .../render/blockentity/BlackHoleRenderer.kt | 1 - .../blockentity/MatterReplicatorRenderer.kt | 3 +- .../mc/otm/client/screen/MatteryScreen.kt | 31 +-- .../otm/client/screen/panels/EditablePanel.kt | 123 +++++++-- .../screen/panels/EntityRendererPanel.kt | 9 +- .../otm/client/screen/panels/Panel2Widget.kt | 13 +- .../screen/panels/input/EditBoxPanel.kt | 6 +- .../screen/panels/input/TextInputPanel.kt | 2 - .../screen/panels/slot/AbstractSlotPanel.kt | 2 +- .../panels/slot/UserFilteredSlotPanel.kt | 2 +- .../screen/tech/AndroidStationScreen.kt | 30 +-- .../client/screen/widget/FluidGaugePanel.kt | 1 - .../client/screen/widget/MatterGaugePanel.kt | 1 - .../mc/otm/compat/adastra/AdAstraCompat.kt | 11 +- .../mc/otm/compat/jei/JEIPlugin.kt | 26 +- .../mc/otm/core/UnOverengineering.kt | 21 +- .../mc/otm/core/util/DataStreams.kt | 4 +- .../dbotthepony/mc/otm/data/ItemStackCodec.kt | 4 +- .../mc/otm/data/loot/LootPoolAppender.kt | 4 +- .../mc/otm/entity/PlasmaProjectile.kt | 6 +- .../ru/dbotthepony/mc/otm/item/BatteryItem.kt | 4 +- .../otm/item/PortableCondensationDriveItem.kt | 2 +- .../PortableGravitationStabilizerItem.kt | 6 +- .../item/armor/SimpleTritaniumArmorItem.kt | 22 +- .../mc/otm/item/armor/TritaniumArmorItem.kt | 27 +- .../exopack/AbstractExoPackSlotUpgradeItem.kt | 2 + .../mc/otm/item/exopack/ExoPackProbeItem.kt | 7 +- .../mc/otm/item/tool/ExplosiveHammerItem.kt | 15 +- .../mc/otm/item/weapon/AbstractWeaponItem.kt | 3 +- .../mc/otm/item/weapon/EnergySwordItem.kt | 8 +- .../mc/otm/matter/MatterManager.kt | 6 +- .../mc/otm/recipe/EnergyContainerRecipe.kt | 74 ++++-- .../recipe/ExplosiveHammerPrimingRecipe.kt | 5 +- .../mc/otm/recipe/PlatePressRecipe.kt | 5 +- .../mc/otm/recipe/UpgradeRecipe.kt | 78 +++++- .../mc/otm/registry/CreativeTabs.kt | 248 ------------------ .../mc/otm/registry/DamageSources.kt | 192 -------------- .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 5 +- .../mc/otm/registry/MCreativeTabs.kt | 247 ++++++++++++++++- .../mc/otm/registry/MDamageTypes.kt | 23 ++ .../ru/dbotthepony/mc/otm/registry/MItems.kt | 16 +- .../ru/dbotthepony/mc/otm/registry/MMenus.kt | 103 ++++---- .../dbotthepony/mc/otm/registry/MRegistry.kt | 43 --- .../mc/otm/registry/MatteryDamageSource.kt | 35 +++ .../otm/registry/objects/CrateProperties.kt | 18 -- .../resources/META-INF/accesstransformer.cfg | 2 +- 68 files changed, 899 insertions(+), 846 deletions(-) create mode 100644 src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DamageTypes.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/registry/DamageSources.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/registry/MDamageTypes.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/registry/MatteryDamageSource.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/CrateProperties.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DamageTypes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DamageTypes.kt new file mode 100644 index 000000000..8411480d5 --- /dev/null +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DamageTypes.kt @@ -0,0 +1,58 @@ +package ru.dbotthepony.mc.otm.datagen + +import net.minecraft.core.RegistrySetBuilder +import net.minecraft.core.registries.Registries +import net.minecraft.data.worldgen.BootstapContext +import net.minecraft.tags.DamageTypeTags +import net.minecraft.world.damagesource.DamageScaling +import net.minecraft.world.damagesource.DamageType +import net.minecraftforge.common.data.DatapackBuiltinEntriesProvider +import net.minecraftforge.data.event.GatherDataEvent +import ru.dbotthepony.mc.otm.datagen.tags.TagsProvider +import ru.dbotthepony.mc.otm.registry.MDamageTypes + +private fun damageTypes(context: BootstapContext) { + context.register(MDamageTypes.EXOPACK_PROBE, DamageType("otm_exopack_probe", DamageScaling.NEVER, 4.0f)) + context.register(MDamageTypes.BECOME_ANDROID, DamageType("otm_become_android", DamageScaling.NEVER, 0f)) + context.register(MDamageTypes.BECOME_HUMANE, DamageType("otm_become_humane", DamageScaling.NEVER, 0f)) + context.register(MDamageTypes.EVENT_HORIZON, DamageType("otm_event_horizon", DamageScaling.NEVER, 0f)) + context.register(MDamageTypes.HAWKING_RADIATION, DamageType("otm_hawking_radiation", DamageScaling.NEVER, 0f)) + context.register(MDamageTypes.EMP, DamageType("otm_emp", DamageScaling.NEVER, 0f)) + context.register(MDamageTypes.SHOCKWAVE, DamageType("otm_shockwave", DamageScaling.NEVER, 0f)) + context.register(MDamageTypes.PLASMA, DamageType("otm_plasma", DamageScaling.NEVER, 0f)) + context.register(MDamageTypes.COSMIC_RAYS, DamageType("otm_cosmic_rays", DamageScaling.NEVER, 0f)) + context.register(MDamageTypes.EXPLOSIVE_HAMMER, DamageType("otm_explosive_hammer", DamageScaling.NEVER, 0.1f)) + context.register(MDamageTypes.HAMMER_NAIL, DamageType("otm_hammer_nail", DamageScaling.NEVER, 0.1f)) +} + +fun registerDamageTypes(event: GatherDataEvent) { + val set = RegistrySetBuilder() + .add(Registries.DAMAGE_TYPE, ::damageTypes) + + event.generator.addProvider(event.includeServer(), DatapackBuiltinEntriesProvider(event.generator.packOutput, event.lookupProvider, set, setOf(DataGen.MOD_ID))) +} + +fun registerDamageTypeTags(provider: TagsProvider.Delegate) { + val ignoreArmor = provider.Appender(DamageTypeTags.BYPASSES_ARMOR) + val ignoreMagic = provider.Appender(DamageTypeTags.BYPASSES_ENCHANTMENTS) + val ignoreInvl = provider.Appender(DamageTypeTags.BYPASSES_INVULNERABILITY) + + ignoreArmor + .add(MDamageTypes.EXOPACK_PROBE) + .add(MDamageTypes.BECOME_ANDROID) + .add(MDamageTypes.BECOME_HUMANE) + .add(MDamageTypes.EVENT_HORIZON) + .add(MDamageTypes.EMP) + .add(MDamageTypes.SHOCKWAVE) + .add(MDamageTypes.COSMIC_RAYS) + + ignoreMagic + .add(MDamageTypes.EXOPACK_PROBE) + .add(MDamageTypes.BECOME_ANDROID) + .add(MDamageTypes.BECOME_HUMANE) + .add(MDamageTypes.COSMIC_RAYS) + + ignoreInvl + .add(MDamageTypes.BECOME_HUMANE) + .add(MDamageTypes.BECOME_ANDROID) +} diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt index 20938029d..0a50c2278 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -525,6 +525,8 @@ object DataGen { event.generator.addProvider(event.includeServer(), matterData) registerOreGen(event) + registerDamageTypes(event) + registerDamageTypeTags(tagsProvider.damageTypes) AddEnglishLanguage(languageProvider) AddRussianLanguage(languageProvider) @@ -564,5 +566,7 @@ object DataGen { languageProvider.registerProviders() addMatterData(matterData) + + tagsProvider.register() } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 389a15b72..23059d825 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -349,13 +349,13 @@ private fun death(provider: MatteryLanguageProvider) { death("otm_emp.player", "%2\$s blew fuzes of %1\$s") death("otm_emp.player.item", "%2\$s blew fuzes of %1\$s using %3\$s") - death(MRegistry.DAMAGE_EXPLOSIVE_HAMMER_NAME, "%1\$s's fun time with hammer is over") - death(MRegistry.DAMAGE_HAMMER_NAIL_NAME, "%1\$s got nailed") - death(MRegistry.DAMAGE_HAMMER_NAIL_NAME + ".player", "%1\$s got nailed by %\$2") - death(MRegistry.DAMAGE_HAMMER_NAIL_NAME + ".player.item", "%1\$s got nailed by %2\$s using %3\$s") + death("otm_explosive_hammer", "%1\$s's fun time with hammer is over") + death("otm_hammer_nail", "%1\$s got nailed") + death("otm_hammer_nail" + ".player", "%1\$s got nailed by %\$2") + death("otm_hammer_nail" + ".player.item", "%1\$s got nailed by %2\$s using %3\$s") - death(MRegistry.DAMAGE_EXOPACK_PROBE_ID, "%1\$s couldn't handle spinal surgery") - death("${MRegistry.DAMAGE_EXOPACK_PROBE_ID}.player", "%1\$s couldn't handle spinal surgery whilst fighting %2\$s") + death("otm_exopack_probe", "%1\$s couldn't handle spinal surgery") + death("otm_exopack_probe.player", "%1\$s couldn't handle spinal surgery whilst fighting %2\$s") } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index aad518d9f..4e5260406 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -354,13 +354,13 @@ private fun death(provider: MatteryLanguageProvider) { death("otm_emp.player", "%2\$s выбил все предохранители %1\$s") death("otm_emp.player.item", "%2\$s выбил все предохранители %1\$s используя %3\$s") - death(MRegistry.DAMAGE_EXPLOSIVE_HAMMER_NAME, "Время развлечений у %1\$s с молотком подошло к концу") - death(MRegistry.DAMAGE_HAMMER_NAIL_NAME, "%1\$s был пригвождён") - death(MRegistry.DAMAGE_HAMMER_NAIL_NAME + ".player", "%1\$s был пригвождён %2\$s") - death(MRegistry.DAMAGE_HAMMER_NAIL_NAME + ".player.item", "%1\$s был пригвождён %2\$s используя %3\$s") + death("otm_explosive_hammer", "Время развлечений у %1\$s с молотком подошло к концу") + death("otm_hammer_nail", "%1\$s был пригвождён") + death("otm_hammer_nail" + ".player", "%1\$s был пригвождён %2\$s") + death("otm_hammer_nail" + ".player.item", "%1\$s был пригвождён %2\$s используя %3\$s") - death(MRegistry.DAMAGE_EXOPACK_PROBE_ID, "%1\$s не выдержал спинную хирургию") - death("${MRegistry.DAMAGE_EXOPACK_PROBE_ID}.player", "%1\$s не выдержал спинную хирургию пока сражался с %2\$s") + death("otm_exopack_probe", "%1\$s не выдержал спинную хирургию") + death("otm_exopack_probe.player", "%1\$s не выдержал спинную хирургию пока сражался с %2\$s") } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeatureType.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeatureType.kt index 1203326ed..4a3da406a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeatureType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeatureType.kt @@ -30,7 +30,7 @@ open class AndroidFeatureType { } open val displayContents: ComponentContents by lazy { - TranslatableContents(displayId) + TranslatableContents(displayId, null, arrayOf()) } open val displayName: Component by lazy { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt index 2386bb3bc..bf8003e45 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt @@ -460,7 +460,7 @@ class AndroidResearchType( } val displayContents: ComponentContents by lazy { - TranslatableContents(displayId) + TranslatableContents(displayId, null, arrayOf()) } val displayName: Component get() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt index 437045998..69cc9f4ab 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt @@ -45,6 +45,7 @@ import ru.dbotthepony.mc.otm.core.math.component3 import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.core.genericPositions import ru.dbotthepony.mc.otm.core.holder +import ru.dbotthepony.mc.otm.core.isFall import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.core.math.rotateXDegrees import ru.dbotthepony.mc.otm.core.math.rotateYDegrees diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt index 96e3180c2..5cc0c71e7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt @@ -11,6 +11,7 @@ import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.isFall import ru.dbotthepony.mc.otm.registry.AndroidFeatures import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.triggers.FallDampenersSaveTrigger diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt index 0d32d25b3..82ecd7917 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt @@ -70,7 +70,7 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable private data class ItemPos(var position: Vector, var ticksSinceActivity: Int) private val rememberPositions = WeakHashMap() - private val serverPredicate = Predicate { it is ItemEntity && !it.hasPickUpDelay() && (it.owner == null || it.owner != ply.uuid || it.lifespan - it.age <= 200) } + private val serverPredicate = Predicate { it is ItemEntity && !it.hasPickUpDelay() && (it.owner == null || it.owner != ply || it.lifespan - it.age <= 200) } private val clientPredicate = Predicate { it is ItemEntity && (datatable[it] ?: SharedItemEntityData.EMPTY).let { !it.hasPickupDelay && (it.owner == null || it.owner != ply.uuid || it.lifespan - it.age <= 200) } } private fun doTick(server: Boolean) { @@ -88,7 +88,7 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable ent as ItemEntity if (server) { - WorldNetworkChannel.send(ply, ItemEntityDataPacket(ent.id, ent.owner, ent.age, ent.lifespan, ent.hasPickUpDelay())) + WorldNetworkChannel.send(ply, ItemEntityDataPacket(ent.id, ent.owner?.uuid, ent.age, ent.lifespan, ent.hasPickUpDelay())) if (!serverPredicate.test(ent)) { continue diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt index 268f86caf..b9a17f54a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt @@ -9,6 +9,7 @@ import ru.dbotthepony.mc.otm.android.AndroidFeature import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact +import ru.dbotthepony.mc.otm.core.isBypassArmor import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.registry.AndroidFeatures import ru.dbotthepony.mc.otm.registry.StatNames diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt index 15b574090..763f54b80 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt @@ -32,6 +32,7 @@ import ru.dbotthepony.mc.otm.core.math.times import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.ShiftPressedCond +import ru.dbotthepony.mc.otm.core.damageType import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.ShockwaveEffectPacket import ru.dbotthepony.mc.otm.network.enqueueWork @@ -39,9 +40,10 @@ import ru.dbotthepony.mc.otm.network.packetHandled import ru.dbotthepony.mc.otm.network.sender import ru.dbotthepony.mc.otm.onceServer import ru.dbotthepony.mc.otm.registry.AndroidFeatures +import ru.dbotthepony.mc.otm.registry.MDamageTypes import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.registry.MSoundEvents -import ru.dbotthepony.mc.otm.registry.ShockwaveDamageSource +import ru.dbotthepony.mc.otm.registry.MatteryDamageSource import ru.dbotthepony.mc.otm.triggers.ShockwaveDamageMobTrigger import ru.dbotthepony.mc.otm.triggers.ShockwaveTrigger import java.util.function.Supplier @@ -134,7 +136,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF seen.add(entity) val multiplier = (1.0 - distanceMultiplier).pow(0.5) - val source = ShockwaveDamageSource(ply) + val source = MatteryDamageSource(ply.level.registryAccess().damageType(MDamageTypes.SHOCKWAVE), ply) val damage = multiplier.toFloat() * AndroidConfig.Shockwave.DAMAGE.toFloat() * AndroidConfig.Shockwave.WARDEN_DAMAGE_MULT.toFloat() entity.hurt(source, damage) entity.deltaMovement += (entity.position - ply.position).normalize() * (multiplier * 3.0) @@ -150,7 +152,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF // don't hurt items, arrows, etc etc if (entity is LivingEntity) { - val source = ShockwaveDamageSource(ply) + val source = MatteryDamageSource(ply.level.registryAccess().damageType(MDamageTypes.SHOCKWAVE), ply) val damage = multiplier.toFloat() * AndroidConfig.Shockwave.DAMAGE.toFloat() entity.hurt(source, damage) entity.deltaMovement += (entity.position - ply.position).normalize() * (multiplier * 3.0) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt index 5d4b53a36..2a8fd2044 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt @@ -16,12 +16,13 @@ import net.minecraft.world.level.block.BasePressurePlateBlock import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition +import net.minecraft.world.level.block.state.properties.BlockSetType import net.minecraft.world.level.block.state.properties.BlockStateProperties import net.minecraft.world.level.material.Material import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.get -class TritaniumPressurePlate(color: DyeColor?) : BasePressurePlateBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops()) { +class TritaniumPressurePlate(color: DyeColor?) : BasePressurePlateBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), BlockSetType.IRON) { override fun appendHoverText( p_49816_: ItemStack, p_49817_: BlockGetter?, @@ -42,14 +43,6 @@ class TritaniumPressurePlate(color: DyeColor?) : BasePressurePlateBlock(Properti p_49915_.add(BlockStateProperties.POWERED) } - override fun playOnSound(level: LevelAccessor, pos: BlockPos) { - level.playSound(null, pos, SoundEvents.METAL_PRESSURE_PLATE_CLICK_ON, SoundSource.BLOCKS, 0.3f, 0.9f) - } - - override fun playOffSound(level: LevelAccessor, pos: BlockPos) { - level.playSound(null, pos, SoundEvents.METAL_PRESSURE_PLATE_CLICK_OFF, SoundSource.BLOCKS, 0.3f, 0.9f) - } - override fun getSignalStrength(level: Level, pos: BlockPos): Int { if (level.getEntitiesOfClass(ServerPlayer::class.java, TOUCH_AABB.move(pos)).isNotEmpty()) { return 15 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 4f04495ea..55697319c 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 @@ -21,6 +21,7 @@ import ru.dbotthepony.mc.otm.block.BlackHoleBlock import ru.dbotthepony.mc.otm.block.entity.tech.GravitationStabilizerBlockEntity import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.block.entity.blackhole.ExplosionQueue.Companion.queueForLevel +import ru.dbotthepony.mc.otm.core.damageType import ru.dbotthepony.mc.otm.core.getExplosionResistance import ru.dbotthepony.mc.otm.core.gracefulBlockBreak import ru.dbotthepony.mc.otm.core.math.Decimal @@ -32,6 +33,8 @@ import ru.dbotthepony.mc.otm.core.math.getSphericalBlockPositions import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.matter.MatterManager +import ru.dbotthepony.mc.otm.registry.MDamageTypes +import ru.dbotthepony.mc.otm.registry.MatteryDamageSource import ru.dbotthepony.mc.otm.triggers.BlackHoleTrigger import java.util.LinkedList import kotlin.math.pow @@ -146,7 +149,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery } else { level.explode( null, - MRegistry.DAMAGE_HAWKING_RADIATION, + MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.HAWKING_RADIATION)), null, blockPos.x + 0.5, blockPos.y + 0.5, @@ -241,7 +244,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery } if (distance < gravitationStrength + 1) { - living.hurt(MRegistry.DAMAGE_EVENT_HORIZON, (gravitationStrength / distance).toFloat()) + living.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EVENT_HORIZON)), (gravitationStrength / distance).toFloat()) } } @@ -250,7 +253,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery setDeltaMovement(item, center, distance, false) if (distance < gravitationStrength + 1) { - if (item.hurt(MRegistry.DAMAGE_EVENT_HORIZON, (gravitationStrength / distance).toFloat()) && item.isRemoved) { + if (item.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EVENT_HORIZON)), (gravitationStrength / distance).toFloat()) && item.isRemoved) { if (item.item.item === MItems.GRAVITATIONAL_DISRUPTOR) { collapse() } else { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/ExplosionDebuggerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/ExplosionDebuggerBlockEntity.kt index 55d4378a4..cb821cc50 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/ExplosionDebuggerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/ExplosionDebuggerBlockEntity.kt @@ -42,7 +42,7 @@ class BlockEntitySphereDebugger(p_155229_: BlockPos, p_155230_: BlockState) : Bl for (normal in ExplosionRayHive.evenlyDistributedPoints(400)) { val multiplied = normal * 20.0 - level!!.setBlock(blockPos + BlockPos(multiplied.x, multiplied.y, multiplied.z), Blocks.COAL_BLOCK.defaultBlockState(), Block.UPDATE_ALL) + level!!.setBlock(blockPos + BlockPos(multiplied.x.toInt(), multiplied.y.toInt(), multiplied.z.toInt()), Blocks.COAL_BLOCK.defaultBlockState(), Block.UPDATE_ALL) } } } 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 9de142daf..cbb834cf4 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 @@ -30,7 +30,9 @@ import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.core.math.rotateAroundAxis import ru.dbotthepony.mc.otm.core.math.up import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.registry.MDamageTypes import ru.dbotthepony.mc.otm.registry.MRegistry +import ru.dbotthepony.mc.otm.registry.MatteryDamageSource import java.util.* import kotlin.collections.ArrayList import kotlin.collections.HashMap @@ -536,7 +538,7 @@ private data class QueuedExplosion(val x: Double, val y: Double, val z: Double, fun explode(level: Level) { level.explode( null, - MRegistry.DAMAGE_HAWKING_RADIATION, + MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.HAWKING_RADIATION)), BlackHoleExplosionDamageCalculator, x, y, @@ -601,7 +603,7 @@ class ExplosionQueue(private val level: ServerLevel) : SavedData() { } fun explode(x: Double, y: Double, z: Double, radius: Float) { - if (level.isOutsideBuildHeight(BlockPos(x, y + 24, z)) || level.isOutsideBuildHeight(BlockPos(x, y - 24, z))) + if (level.isOutsideBuildHeight(BlockPos(x.toInt(), y.toInt() + 24, z.toInt())) || level.isOutsideBuildHeight(BlockPos(x.toInt(), y.toInt() - 24, z.toInt()))) return explosions.add(QueuedExplosion(x, y, z, radius)) 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 b24bde36f..1bb496c93 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 @@ -307,7 +307,7 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : override fun getItem(p_18941_: Int): ItemStack { require(p_18941_ == 0) { "Invalid slot ID: $p_18941_" } - return craftingRecipe?.resultItem?.copy() ?: ItemStack.EMPTY + return craftingRecipe?.getResultItem(level?.registryAccess() ?: return ItemStack.EMPTY)?.copy() ?: ItemStack.EMPTY } override fun removeItem(index: Int, amount: Int): ItemStack { @@ -316,7 +316,7 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val craftingRecipe = craftingRecipe val craftingPlayer = craftingPlayer - if (craftingRecipe == null || craftingPlayer == null || craftingRecipe.resultItem.count != amount) { + if (craftingRecipe == null || craftingPlayer == null || craftingRecipe.getResultItem(level?.registryAccess() ?: return ItemStack.EMPTY).count != amount) { return ItemStack.EMPTY } @@ -430,7 +430,7 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : scanCraftingGrid() } - return craftingRecipe.resultItem.copy() + return craftingRecipe.getResultItem(level?.registryAccess() ?: return ItemStack.EMPTY).copy() } override fun removeItemNoUpdate(p_18951_: Int): ItemStack { @@ -438,7 +438,7 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } override fun setItem(p_18944_: Int, p_18945_: ItemStack) { - if ((craftingRecipe != null && !craftingRecipe!!.resultItem.isEmpty) || !p_18945_.isEmpty) { + if ((craftingRecipe != null && !craftingRecipe!!.let { it.getResultItem(level?.registryAccess() ?: return@let ItemStack.EMPTY) }.isEmpty) || !p_18945_.isEmpty) { throw RuntimeException("BUG-DETECT: Tried to set crafting result slot item to something, and either we have crafting recipe which have valid result, or we are trying to set slot to non empty item: $p_18945_") } } 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 d3bf3ac99..5ebf5674d 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 @@ -72,10 +72,12 @@ class PlatePressBlockEntity( return null to IdleReason.POWER } - val recipe = level?.recipeManager?.getRecipeFor(MRecipes.PLATE_PRESS, inputContainer, level!!)?.orElse(null) ?: return null to IdleReason.ITEM + val level = level ?: return null to null + + val recipe = level.recipeManager.getRecipeFor(MRecipes.PLATE_PRESS, inputContainer, level).orElse(null) ?: return null to IdleReason.ITEM inputContainer[0].shrink(1) inputContainer.setChanged(0) - return ItemJob(recipe.resultItem, recipe.workTime.toDouble(), BASELINE_CONSUMPTION, experience = recipe.experience.sample(level!!.random)) to null + return ItemJob(recipe.getResultItem(level.registryAccess()), recipe.workTime.toDouble(), BASELINE_CONSUMPTION, experience = recipe.experience.sample(level.random)) to null } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt index 694654e12..415b7bc07 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt @@ -25,6 +25,7 @@ import net.minecraft.world.phys.AABB import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import net.minecraftforge.common.ForgeHooks +import net.minecraftforge.event.ForgeEventFactory import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get @@ -63,12 +64,7 @@ class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of(Material.METAL ) { val phantom = EntityType.PHANTOM.create(level) ?: continue phantom.moveTo(spawnPos, 0.0f, 0.0f) - - if (ForgeHooks.canEntitySpawn(phantom, level, spawnPos.x.toDouble(), spawnPos.y.toDouble(), spawnPos.z.toDouble(), null, MobSpawnType.SPAWNER) == -1) { - continue - } - - groupData = phantom.finalizeSpawn(level, level.getCurrentDifficultyAt(spawnPos), MobSpawnType.SPAWNER, groupData, null) + groupData = ForgeEventFactory.onFinalizeSpawn(phantom, level, level.getCurrentDifficultyAt(spawnPos), MobSpawnType.SPAWNER, groupData, null) level.addFreshEntityWithPassengers(phantom) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 69900a176..1f212a4a7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -38,7 +38,6 @@ import net.minecraftforge.event.TickEvent import net.minecraftforge.event.TickEvent.PlayerTickEvent import net.minecraftforge.event.entity.living.LivingDeathEvent import net.minecraftforge.event.entity.living.LivingHurtEvent -import net.minecraftforge.event.entity.living.LivingSpawnEvent import net.minecraftforge.event.entity.living.MobEffectEvent import net.minecraftforge.event.entity.player.PlayerEvent import net.minecraftforge.eventbus.api.Event @@ -59,7 +58,6 @@ import ru.dbotthepony.mc.otm.container.stream import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.collect.UUIDIntModifiersMap import ru.dbotthepony.mc.otm.core.collect.filter -import ru.dbotthepony.mc.otm.core.collect.nonEmpty import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.minus import ru.dbotthepony.mc.otm.core.nbt.getCompoundList @@ -74,7 +72,9 @@ import ru.dbotthepony.mc.otm.menu.ExoPackInventoryMenu import ru.dbotthepony.mc.otm.network.* import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer import ru.dbotthepony.mc.otm.registry.AndroidFeatures +import ru.dbotthepony.mc.otm.registry.MDamageTypes import ru.dbotthepony.mc.otm.registry.MRegistry +import ru.dbotthepony.mc.otm.registry.MatteryDamageSource import ru.dbotthepony.mc.otm.triggers.AndroidResearchTrigger import ru.dbotthepony.mc.otm.triggers.AndroidTravelUnderwater import ru.dbotthepony.mc.otm.triggers.BecomeAndroidDeathTrigger @@ -418,7 +418,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial if (isAndroid) return becomeAndroid() - ply.hurt(MRegistry.DAMAGE_BECOME_ANDROID, ply.maxHealth * 2) + + if (!ply.abilities.invulnerable) + ply.hurt(MatteryDamageSource(ply.level.registryAccess().damageType(MDamageTypes.BECOME_ANDROID)), ply.maxHealth * 2) } /** @@ -476,7 +478,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial if (!isAndroid) return becomeHumane() - ply.hurt(MRegistry.DAMAGE_BECOME_HUMANE, ply.maxHealth * 2) + + if (!ply.abilities.invulnerable) + ply.hurt(MatteryDamageSource(ply.level.registryAccess().damageType(MDamageTypes.BECOME_HUMANE)), ply.maxHealth * 2) } /** diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt index 9edcc8c87..3b0ba43cb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt @@ -89,7 +89,7 @@ private fun Font.drawScaledDuckTyped(poseStack: PoseStack, text: Any, scale: Flo return size } -private fun Font.drawScaledDuckTyped(poseStack: PoseStack, buffer: MultiBufferSource, text: Any, scale: Float, x: Float, y: Float, color: Int, drawShadow: Boolean = false, seeThrough: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0): Int { +private fun Font.drawScaledDuckTyped(poseStack: PoseStack, buffer: MultiBufferSource, text: Any, scale: Float, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0): Int { val translation = poseStack.translation() poseStack.pushPose() @@ -97,7 +97,7 @@ private fun Font.drawScaledDuckTyped(poseStack: PoseStack, buffer: MultiBufferSo poseStack.scale(scale, scale, scale) val inv = 1f / scale poseStack.translate(translation * inv) - val size = drawDuckTyped(poseStack, buffer, text, x * inv, y * inv, color, drawShadow, seeThrough, packedLightCoords, effectColor) + val size = drawDuckTyped(poseStack, buffer, text, x * inv, y * inv, color, drawShadow, displayMode, packedLightCoords, effectColor) poseStack.popPose() return size @@ -120,7 +120,7 @@ private fun Font.drawDuckTyped( y: Float, color: Int, drawShadow: Boolean = false, - seeThrough: Boolean = false, + displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0 ): Int { @@ -129,9 +129,9 @@ private fun Font.drawDuckTyped( } val result = when (text) { - is Component -> drawInBatch(text, x, y, color, drawShadow, poseStack.last().pose(), buffer, seeThrough, effectColor, packedLightCoords) - is String -> drawInBatch(text, x, y, color, drawShadow, poseStack.last().pose(), buffer, seeThrough, effectColor, packedLightCoords) - is FormattedCharSequence -> drawInBatch(text, x, y, color, drawShadow, poseStack.last().pose(), buffer, seeThrough, effectColor, packedLightCoords) + is Component -> drawInBatch(text, x, y, color, drawShadow, poseStack.last().pose(), buffer, displayMode, effectColor, packedLightCoords) + is String -> drawInBatch(text, x, y, color, drawShadow, poseStack.last().pose(), buffer, displayMode, effectColor, packedLightCoords) + is FormattedCharSequence -> drawInBatch(text, x, y, color, drawShadow, poseStack.last().pose(), buffer, displayMode, effectColor, packedLightCoords) else -> throw ClassCastException(text::class.qualifiedName) } @@ -176,22 +176,22 @@ private fun Font.drawAlignedDuckTyped( y: Float, color: Int, drawShadow: Boolean = false, - seeThrough: Boolean = false, + displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0 ): Int { return when (align) { - TextAlign.TOP_LEFT -> drawDuckTyped(poseStack, buffer, text, x, y, color, drawShadow, seeThrough, packedLightCoords, effectColor) - TextAlign.TOP_CENTER -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text) / 2f).roundToInt().toFloat(), y, color, drawShadow, seeThrough, packedLightCoords, effectColor) - TextAlign.TOP_RIGHT -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text)).roundToInt().toFloat(), y, color, drawShadow, seeThrough, packedLightCoords, effectColor) + TextAlign.TOP_LEFT -> drawDuckTyped(poseStack, buffer, text, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.TOP_CENTER -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text) / 2f).roundToInt().toFloat(), y, color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.TOP_RIGHT -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text)).roundToInt().toFloat(), y, color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.CENTER_LEFT -> drawDuckTyped(poseStack, buffer, text, x, (y - lineHeight / 2f).roundToInt().toFloat(), color, drawShadow, seeThrough, packedLightCoords, effectColor) - TextAlign.CENTER_CENTER -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text) / 2f).roundToInt().toFloat(), (y - lineHeight / 2f).roundToInt().toFloat(), color, drawShadow, seeThrough, packedLightCoords, effectColor) - TextAlign.CENTER_RIGHT -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text)).roundToInt().toFloat(), (y - lineHeight / 2f).roundToInt().toFloat(), color, drawShadow, seeThrough, packedLightCoords, effectColor) + TextAlign.CENTER_LEFT -> drawDuckTyped(poseStack, buffer, text, x, (y - lineHeight / 2f).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.CENTER_CENTER -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text) / 2f).roundToInt().toFloat(), (y - lineHeight / 2f).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.CENTER_RIGHT -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text)).roundToInt().toFloat(), (y - lineHeight / 2f).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.BOTTOM_LEFT -> drawDuckTyped(poseStack, buffer, text, x, (y - lineHeight).roundToInt().toFloat(), color, drawShadow, seeThrough, packedLightCoords, effectColor) - TextAlign.BOTTOM_CENTER -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text) / 2f).roundToInt().toFloat(), (y - lineHeight).roundToInt().toFloat(), color, drawShadow, seeThrough, packedLightCoords, effectColor) - TextAlign.BOTTOM_RIGHT -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text)).roundToInt().toFloat(), (y - lineHeight).roundToInt().toFloat(), color, drawShadow, seeThrough, packedLightCoords, effectColor) + TextAlign.BOTTOM_LEFT -> drawDuckTyped(poseStack, buffer, text, x, (y - lineHeight).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.BOTTOM_CENTER -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text) / 2f).roundToInt().toFloat(), (y - lineHeight).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.BOTTOM_RIGHT -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text)).roundToInt().toFloat(), (y - lineHeight).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor) } } @@ -221,22 +221,22 @@ private fun Font.drawScaledAlignedDuckTyped( y: Float, color: Int, drawShadow: Boolean = false, - seeThrough: Boolean = false, + displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0 ): Int { return when (align) { - TextAlign.TOP_LEFT -> drawScaledDuckTyped(poseStack, buffer, text, scale, x, y, color, drawShadow, seeThrough, packedLightCoords, effectColor) - TextAlign.TOP_CENTER -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale / 2f).roundToInt().toFloat(), y, color, drawShadow, seeThrough, packedLightCoords, effectColor) - TextAlign.TOP_RIGHT -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale).roundToInt().toFloat(), y, color, drawShadow, seeThrough, packedLightCoords, effectColor) + TextAlign.TOP_LEFT -> drawScaledDuckTyped(poseStack, buffer, text, scale, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.TOP_CENTER -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale / 2f).roundToInt().toFloat(), y, color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.TOP_RIGHT -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale).roundToInt().toFloat(), y, color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.CENTER_LEFT -> drawScaledDuckTyped(poseStack, buffer, text, scale, x, (y - lineHeight / 2f * scale).roundToInt().toFloat(), color, drawShadow, seeThrough, packedLightCoords, effectColor) - TextAlign.CENTER_CENTER -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale / 2f).roundToInt().toFloat(), (y - lineHeight * scale / 2f).roundToInt().toFloat(), color, drawShadow, seeThrough, packedLightCoords, effectColor) - TextAlign.CENTER_RIGHT -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale).roundToInt().toFloat(), (y - lineHeight * scale / 2f).roundToInt().toFloat(), color, drawShadow, seeThrough, packedLightCoords, effectColor) + TextAlign.CENTER_LEFT -> drawScaledDuckTyped(poseStack, buffer, text, scale, x, (y - lineHeight / 2f * scale).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.CENTER_CENTER -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale / 2f).roundToInt().toFloat(), (y - lineHeight * scale / 2f).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.CENTER_RIGHT -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale).roundToInt().toFloat(), (y - lineHeight * scale / 2f).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.BOTTOM_LEFT -> drawScaledDuckTyped(poseStack, buffer, text, scale, x, (y - lineHeight * scale).roundToInt().toFloat(), color, drawShadow, seeThrough, packedLightCoords, effectColor) - TextAlign.BOTTOM_CENTER -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale / 2f).roundToInt().toFloat(), (y - lineHeight * scale).roundToInt().toFloat(), color, drawShadow, seeThrough, packedLightCoords, effectColor) - TextAlign.BOTTOM_RIGHT -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale).roundToInt().toFloat(), (y - lineHeight * scale).roundToInt().toFloat(), color, drawShadow, seeThrough, packedLightCoords, effectColor) + TextAlign.BOTTOM_LEFT -> drawScaledDuckTyped(poseStack, buffer, text, scale, x, (y - lineHeight * scale).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.BOTTOM_CENTER -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale / 2f).roundToInt().toFloat(), (y - lineHeight * scale).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.BOTTOM_RIGHT -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale).roundToInt().toFloat(), (y - lineHeight * scale).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor) } } @@ -256,18 +256,18 @@ fun Font.drawScaledAligned(poseStack: PoseStack, text: String, scale: Float, ali fun Font.drawScaledAligned(poseStack: PoseStack, text: Component, scale: Float, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(poseStack, text, scale, align, x, y, color.toInt()) fun Font.drawScaledAligned(poseStack: PoseStack, text: FormattedCharSequence, scale: Float, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(poseStack, text, scale, align, x, y, color.toInt()) -fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, seeThrough: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAlignedDuckTyped(poseStack, buffer, text, align, x, y, color, drawShadow, seeThrough, packedLightCoords, effectColor) -fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, seeThrough: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAlignedDuckTyped(poseStack, buffer, text, align, x, y, color, drawShadow, seeThrough, packedLightCoords, effectColor) -fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, seeThrough: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAlignedDuckTyped(poseStack, buffer, text, align, x, y, color, drawShadow, seeThrough, packedLightCoords, effectColor) +fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAlignedDuckTyped(poseStack, buffer, text, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) +fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAlignedDuckTyped(poseStack, buffer, text, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) +fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAlignedDuckTyped(poseStack, buffer, text, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, align: TextAlign, x: Float, y: Float, color: RGBAColor, drawShadow: Boolean = false, seeThrough: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAligned(poseStack, buffer, text, align, x, y, color.toInt(), drawShadow, seeThrough, packedLightCoords, effectColor) -fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, align: TextAlign, x: Float, y: Float, color: RGBAColor, drawShadow: Boolean = false, seeThrough: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAligned(poseStack, buffer, text, align, x, y, color.toInt(), drawShadow, seeThrough, packedLightCoords, effectColor) -fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, align: TextAlign, x: Float, y: Float, color: RGBAColor, drawShadow: Boolean = false, seeThrough: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAligned(poseStack, buffer, text, align, x, y, color.toInt(), drawShadow, seeThrough, packedLightCoords, effectColor) +fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, align: TextAlign, x: Float, y: Float, color: RGBAColor, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAligned(poseStack, buffer, text, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) +fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, align: TextAlign, x: Float, y: Float, color: RGBAColor, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAligned(poseStack, buffer, text, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) +fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, align: TextAlign, x: Float, y: Float, color: RGBAColor, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAligned(poseStack, buffer, text, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, scale: Float, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, seeThrough: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0,) = drawScaledAlignedDuckTyped(poseStack, buffer, text, scale, align, x, y, color, drawShadow, seeThrough, packedLightCoords, effectColor) -fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, scale: Float, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, seeThrough: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0,) = drawScaledAlignedDuckTyped(poseStack, buffer, text, scale, align, x, y, color, drawShadow, seeThrough, packedLightCoords, effectColor) -fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, scale: Float, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, seeThrough: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0,) = drawScaledAlignedDuckTyped(poseStack, buffer, text, scale, align, x, y, color, drawShadow, seeThrough, packedLightCoords, effectColor) +fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, scale: Float, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0,) = drawScaledAlignedDuckTyped(poseStack, buffer, text, scale, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) +fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, scale: Float, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0,) = drawScaledAlignedDuckTyped(poseStack, buffer, text, scale, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) +fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, scale: Float, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0,) = drawScaledAlignedDuckTyped(poseStack, buffer, text, scale, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, scale: Float, align: TextAlign, x: Float, y: Float, drawShadow: Boolean = false, seeThrough: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toInt(), drawShadow, seeThrough, packedLightCoords, effectColor) -fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, scale: Float, align: TextAlign, x: Float, y: Float, drawShadow: Boolean = false, seeThrough: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toInt(), drawShadow, seeThrough, packedLightCoords, effectColor) -fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, scale: Float, align: TextAlign, x: Float, y: Float, drawShadow: Boolean = false, seeThrough: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toInt(), drawShadow, seeThrough, packedLightCoords, effectColor) +fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, scale: Float, align: TextAlign, x: Float, y: Float, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) +fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, scale: Float, align: TextAlign, x: Float, y: Float, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) +fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, scale: Float, align: TextAlign, x: Float, y: Float, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GlitchRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GlitchRenderer.kt index f1a970036..f2ae895c7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GlitchRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GlitchRenderer.kt @@ -212,7 +212,6 @@ object GlitchRenderer { RenderSystem.disableCull() RenderSystem.disableDepthTest() RenderSystem.enableBlend() - RenderSystem.enableTexture() if (glitchBuffer.width != minecraft.window.width || glitchBuffer.height != minecraft.window.height) { glitchBuffer.resize(minecraft.window.width, minecraft.window.height, Minecraft.ON_OSX) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt index 38327e737..5cf4f4db5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt @@ -53,7 +53,6 @@ fun drawTexturedRect( v1: Float = 1f ) { RenderSystem.setShader(GameRenderer::getPositionTexShader) - RenderSystem.enableTexture() RenderSystem.enableBlend() RenderSystem.defaultBlendFunc() @@ -314,7 +313,6 @@ fun drawRect( height: Float, color: RGBAColor = drawColor ) { - RenderSystem.disableTexture() RenderSystem.enableBlend() RenderSystem.defaultBlendFunc() RenderSystem.setShader(GameRenderer::getPositionColorShader) @@ -333,7 +331,6 @@ fun drawRect( builder.vertex(matrix, x, y, zLevel).color(color).endVertex() tess.end() - RenderSystem.enableTexture() } fun drawRect( @@ -362,7 +359,6 @@ fun drawLine( width: Float, color: RGBAColor = drawColor ) { - RenderSystem.disableTexture() RenderSystem.enableBlend() RenderSystem.defaultBlendFunc() RenderSystem.setShader(GameRenderer::getPositionColorShader) @@ -412,7 +408,6 @@ fun drawLine( zLevel).color(color).endVertex() tess.end() - RenderSystem.enableTexture() } fun drawLine( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt index 712ff7eaa..09da620e7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt @@ -119,7 +119,6 @@ class BlackHoleRenderer(private val context: BlockEntityRendererProvider.Context colorSphere(poseStack, size.toFloat()) RenderSystem.enableCull() - RenderSystem.enableTexture() poseStack.popPose() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReplicatorRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReplicatorRenderer.kt index 73bc49d0d..2f4a080ce 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReplicatorRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReplicatorRenderer.kt @@ -9,6 +9,7 @@ import net.minecraft.client.renderer.block.model.ItemTransforms import net.minecraft.client.renderer.blockentity.BlockEntityRenderer import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider import net.minecraft.core.particles.DustParticleOptions +import net.minecraft.world.item.ItemDisplayContext import net.minecraft.world.level.levelgen.XoroshiroRandomSource import org.joml.Vector3f import org.lwjgl.opengl.GL14.glBlendColor @@ -79,7 +80,7 @@ class MatterReplicatorRenderer(private val context: BlockEntityRendererProvider. context.itemRenderer.render( item, - ItemTransforms.TransformType.NONE, + ItemDisplayContext.NONE, false, pose, source, 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 577fdcb88..41b336d2d 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 @@ -20,12 +20,16 @@ import org.lwjgl.opengl.GL11 import org.lwjgl.opengl.GL13 import ru.dbotthepony.mc.otm.config.ClientConfig import ru.dbotthepony.mc.otm.client.moveMousePosScaled +import ru.dbotthepony.mc.otm.client.render.translation import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.UserFilteredSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.HeightControls import ru.dbotthepony.mc.otm.client.screen.panels.util.ScrollBarConstants +import ru.dbotthepony.mc.otm.core.math.component1 +import ru.dbotthepony.mc.otm.core.math.component2 +import ru.dbotthepony.mc.otm.core.math.component3 import ru.dbotthepony.mc.otm.core.math.integerDivisionDown import ru.dbotthepony.mc.otm.menu.MatteryMenu import java.util.Collections @@ -62,37 +66,23 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit val quickCraftingType get() = quickCraftingType val isQuickCrafting get() = isQuickCrafting - fun renderItemStack(absoluteX: Float, absoluteY: Float, itemstack: ItemStack, countOverride: String? = null) { + fun renderItemStack(poseStack: PoseStack, itemstack: ItemStack, countOverride: String? = null) { if (!itemstack.isEmpty) { RenderSystem.enableDepthTest() - val systemPoseStack = RenderSystem.getModelViewStack() - - systemPoseStack.pushPose() - systemPoseStack.translate(absoluteX + 1f, absoluteY + 1f, 0f) - RenderSystem.applyModelViewMatrix() - RenderSystem.depthFunc(GL11.GL_LESS) - - // Thanks Mojang - // Very cool - // (for int x, int y, which are then cast into doubles anyway) - itemRenderer.blitOffset = 1f // Z pos + val (x, y) = poseStack.translation() itemRenderer.renderAndDecorateItem( + poseStack, requireNotNull(ru.dbotthepony.mc.otm.client.minecraft.player) { "yo, dude, what the fuck" }, itemstack, 0, 0, - (absoluteX + absoluteY * 1000f).toInt() + (x + y * ru.dbotthepony.mc.otm.client.minecraft.window.guiScaledWidth).toInt() ) RenderSystem.depthFunc(GL11.GL_ALWAYS) - itemRenderer.renderGuiItemDecorations(font, itemstack, 0, 0, countOverride) - itemRenderer.blitOffset = 0f - - // too big accumulations can lead to Z near clipping issues - systemPoseStack.popPose() - RenderSystem.applyModelViewMatrix() + itemRenderer.renderGuiItemDecorations(poseStack, font, itemstack, 0, 0, countOverride) } } @@ -520,7 +510,6 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit RenderSystem.defaultBlendFunc() RenderSystem.enableBlend() RenderSystem.enableDepthTest() - RenderSystem.enableTexture() RenderSystem.activeTexture(GL13.GL_TEXTURE0) for (i in panels.indices.reversed()) { @@ -559,7 +548,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } @Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") - renderFloatingItem(itemstack, mouseX - 8, mouseY - i2, overrideCount) + renderFloatingItem(poseStack, itemstack, mouseX - 8, mouseY - i2, overrideCount) } RenderSystem.disableDepthTest() 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 abb29655d..2fd4d6839 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 @@ -4,8 +4,11 @@ import com.google.common.collect.ImmutableList import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack import it.unimi.dsi.fastutil.objects.ReferenceArraySet +import net.minecraft.client.gui.ComponentPath import net.minecraft.client.gui.Font import net.minecraft.client.gui.components.events.GuiEventListener +import net.minecraft.client.gui.navigation.FocusNavigationEvent +import net.minecraft.client.gui.navigation.ScreenRectangle import net.minecraft.client.gui.screens.Screen import net.minecraft.client.renderer.Rect2i import net.minecraft.network.chat.Component @@ -68,7 +71,73 @@ open class EditablePanel @JvmOverloads constructor( width: Float = 10f, height: Float = 10f, -) : GuiEventListener { +) { + // layout engine does not support navigation using keyboard + // fuck off + val listener: GuiEventListener = object : GuiEventListener { + override fun setFocused(p_265728_: Boolean) { + if (p_265728_) { + if (isVisible()) + requestFocus() + } else { + killFocus() + } + } + + override fun isFocused(): Boolean { + return isEverFocused() + } + + override fun mouseMoved(p_94758_: Double, p_94759_: Double) { + this@EditablePanel.mouseMoved(p_94758_, p_94759_) + } + + override fun mouseClicked(p_94737_: Double, p_94738_: Double, p_94739_: Int): Boolean { + return this@EditablePanel.mouseClicked(p_94737_, p_94738_, p_94739_) + } + + override fun mouseReleased(p_94753_: Double, p_94754_: Double, p_94755_: Int): Boolean { + return this@EditablePanel.mouseReleased(p_94753_, p_94754_, p_94755_) + } + + override fun mouseDragged(p_94740_: Double, p_94741_: Double, p_94742_: Int, p_94743_: Double, p_94744_: Double): Boolean { + return this@EditablePanel.mouseDragged(p_94740_, p_94741_, p_94742_, p_94743_, p_94744_) + } + + override fun mouseScrolled(p_94734_: Double, p_94735_: Double, p_94736_: Double): Boolean { + return this@EditablePanel.mouseScrolled(p_94734_, p_94735_, p_94736_) + } + + override fun keyPressed(p_94745_: Int, p_94746_: Int, p_94747_: Int): Boolean { + return this@EditablePanel.keyPressed(p_94745_, p_94746_, p_94747_) + } + + override fun keyReleased(p_94750_: Int, p_94751_: Int, p_94752_: Int): Boolean { + return this@EditablePanel.keyReleased(p_94750_, p_94751_, p_94752_) + } + + override fun charTyped(p_94732_: Char, p_94733_: Int): Boolean { + return this@EditablePanel.charTyped(p_94732_, p_94733_) + } + + override fun nextFocusPath(p_265234_: FocusNavigationEvent): ComponentPath? { + return null + } + + override fun isMouseOver(p_94748_: Double, p_94749_: Double): Boolean { + return this@EditablePanel.isMouseOver(p_94748_, p_94749_) + } + + override fun getCurrentFocusPath(): ComponentPath? { + return null + } + + override fun getRectangle(): ScreenRectangle { + val rect = calculateAbsoluteRectangle() + return ScreenRectangle(rect.x.toInt(), rect.y.toInt(), rect.width.toInt(), rect.height.toInt()) + } + } + var parent: EditablePanel<*>? = null set(value) { if (field === value) @@ -808,27 +877,31 @@ open class EditablePanel @JvmOverloads constructor( return false to null } - fun findItemStack(mouseX: Float, mouseY: Float, ignoreMouseInputLock: Boolean = false): Pair { + fun findItemStack(mouseX: Float, mouseY: Float, ignoreMouseInputLock: Boolean = false): Pair?, ItemStack> { if (!isVisible()) { - return false to ItemStack.EMPTY + return null to ItemStack.EMPTY } if (!acceptMouseInput && !ignoreMouseInputLock) { - return (mouseX >= absoluteX && - mouseX <= absoluteX + width && - mouseY >= absoluteY && - mouseY <= absoluteY + height) to ItemStack.EMPTY + if (mouseX >= absoluteX && + mouseX <= absoluteX + width && + mouseY >= absoluteY && + mouseY <= absoluteY + height) { + return this to ItemStack.EMPTY + } else { + return null to ItemStack.EMPTY + } } if (grabMouseInput && this is IItemStackPanel) { - return true to this.itemStack + return this to this.itemStack } for (child in visibleChildrenInternal) { - val (status, itemStack) = child.findItemStack(mouseX, mouseY, ignoreMouseInputLock) + val status = child.findItemStack(mouseX, mouseY, ignoreMouseInputLock) - if (status) { - return true to itemStack + if (status.first != null) { + return status } } @@ -839,13 +912,13 @@ open class EditablePanel @JvmOverloads constructor( mouseY <= absoluteY + height ) { if (this is IItemStackPanel) { - return true to this.itemStack + return this to this.itemStack } - return true to ItemStack.EMPTY + return this to ItemStack.EMPTY } - return false to ItemStack.EMPTY + return null to ItemStack.EMPTY } fun renderTooltips(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { @@ -1296,7 +1369,7 @@ open class EditablePanel @JvmOverloads constructor( return false } - override fun mouseMoved(x: Double, y: Double) { + open fun mouseMoved(x: Double, y: Double) { } @@ -1317,7 +1390,7 @@ open class EditablePanel @JvmOverloads constructor( y in pos.y .. pos2.y } - final override fun mouseClicked(x: Double, y: Double, button: Int): Boolean { + fun mouseClicked(x: Double, y: Double, button: Int): Boolean { if (!isVisible() || !acceptMouseInput) return false if (flashAnyBlocker()) return true @@ -1368,7 +1441,7 @@ open class EditablePanel @JvmOverloads constructor( return true } - final override fun mouseReleased(x: Double, y: Double, button: Int): Boolean { + fun mouseReleased(x: Double, y: Double, button: Int): Boolean { if (!isVisible() || !acceptMouseInput) return false if (flashAnyBlocker(false)) return true if (grabMouseInput) return mouseReleasedInner(x, y, button) @@ -1408,7 +1481,7 @@ open class EditablePanel @JvmOverloads constructor( return true } - final override fun mouseDragged(x: Double, y: Double, button: Int, xDelta: Double, yDelta: Double): Boolean { + fun mouseDragged(x: Double, y: Double, button: Int, xDelta: Double, yDelta: Double): Boolean { if (!isVisible() || !acceptMouseInput) return false if (flashAnyBlocker(false)) return true if (grabMouseInput) return mouseDraggedInner(x, y, button, xDelta, yDelta) @@ -1448,7 +1521,7 @@ open class EditablePanel @JvmOverloads constructor( return true } - final override fun mouseScrolled(x: Double, y: Double, scroll: Double): Boolean { + fun mouseScrolled(x: Double, y: Double, scroll: Double): Boolean { if (!isVisible() || !acceptMouseInput) return false if (flashAnyBlocker(true)) { @@ -1492,7 +1565,7 @@ open class EditablePanel @JvmOverloads constructor( return false } - final override fun keyPressed(key: Int, scancode: Int, mods: Int): Boolean { + fun keyPressed(key: Int, scancode: Int, mods: Int): Boolean { if (!isVisible() || !acceptKeyboardInput) return false if (!isEverFocused()) return false if (flashAnyBlocker(true)) return true @@ -1512,7 +1585,7 @@ open class EditablePanel @JvmOverloads constructor( return false } - final override fun keyReleased(key: Int, scancode: Int, mods: Int): Boolean { + fun keyReleased(key: Int, scancode: Int, mods: Int): Boolean { if (!isVisible() || !acceptKeyboardInput) return false if (!isEverFocused()) return false if (flashAnyBlocker(false)) return true @@ -1532,7 +1605,7 @@ open class EditablePanel @JvmOverloads constructor( return false } - final override fun charTyped(codepoint: Char, mods: Int): Boolean { + fun charTyped(codepoint: Char, mods: Int): Boolean { if (!isVisible() || !acceptKeyboardInput) return false if (!isEverFocused()) return false if (flashAnyBlocker(false)) return true @@ -1548,11 +1621,7 @@ open class EditablePanel @JvmOverloads constructor( return true } - override fun changeFocus(state: Boolean): Boolean { - return if (!isVisible()) false else super.changeFocus(state) - } - - final override fun isMouseOver(x: Double, y: Double): Boolean { // called to check whenever we are hovering at this + fun isMouseOver(x: Double, y: Double): Boolean { // called to check whenever we are hovering at this if (!isVisible() || !acceptMouseInput) return false if (isGrabbingMouseInput()) return true diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt index 656606aee..b25b00b2d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt @@ -94,14 +94,15 @@ class EntityRendererPanel @JvmOverloads constructor( return } - val renderX = absoluteX.toInt() + width.toInt() / 2 - val renderY = absoluteY.toInt() + (height * 0.9f).toInt() + val renderX = width.toInt() / 2 + val renderY = (height * 0.9f).toInt() - InventoryScreen.renderEntityInInventory( + InventoryScreen.renderEntityInInventoryFollowsMouse( + stack, renderX, renderY, renderScale, - renderX - mouseX, + absoluteX.toInt() + renderX - mouseX, absoluteY + height * 0.15f - mouseY, entity ) 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 5bf81201a..778b52fe1 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 @@ -62,11 +62,16 @@ class Panel2Widget>( return panel.charTyped(p_94732_, p_94733_) } - override fun changeFocus(p_94756_: Boolean): Boolean { - return false - } - override fun isMouseOver(p_94748_: Double, p_94749_: Double): Boolean { return panel.isMouseOver(p_94748_, p_94749_) } + + override fun setFocused(p_265728_: Boolean) { + // no op + } + + override fun isFocused(): Boolean { + // ага, щас + return false + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/EditBoxPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/EditBoxPanel.kt index 7266ec218..1a6823caf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/EditBoxPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/EditBoxPanel.kt @@ -39,11 +39,11 @@ open class EditBoxPanel( } override fun configureNew(widget: EditBox, recreation: Boolean) { - widget.setFocus(isFocusedThis) + widget.isFocused = isFocusedThis } override fun onFocusChanged() { - widget?.setFocus(isFocusedThis) + widget?.isFocused = isFocusedThis } override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { @@ -54,7 +54,7 @@ open class EditBoxPanel( override fun keyPressedInternal(key: Int, scancode: Int, mods: Int): Boolean { if (key == InputConstants.KEY_ESCAPE && widget?.isActive == true) { - widget?.setFocus(false) + widget?.isFocused = false return true } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt index d6d118db5..f952c9ae9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt @@ -1151,7 +1151,6 @@ open class TextInputPanel( RenderSystem.setShader(GameRenderer::getPositionShader) RenderSystem.setShaderColor(cursorColor.red, cursorColor.green, cursorColor.blue, 0.4f) - RenderSystem.disableTexture() //RenderSystem.enableColorLogicOp() //RenderSystem.logicOp(GlStateManager.LogicOp.NOR) RenderSystem.disableDepthTest() @@ -1170,7 +1169,6 @@ open class TextInputPanel( RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f) //RenderSystem.disableColorLogicOp() - RenderSystem.enableTexture() RenderSystem.enableDepthTest() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt index 9c5b1516f..fd2a201db 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt @@ -29,7 +29,7 @@ abstract class AbstractSlotPanel> @JvmOverloads constru RenderSystem.setShader(GameRenderer::getPositionTexShader) if (!itemstack.isEmpty) { - screen.renderItemStack(absoluteX, absoluteY, itemstack, countOverride) + screen.renderItemStack(stack, itemstack, countOverride) clearDepth(stack) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt index 97772a9bc..d9819d6ba 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt @@ -42,7 +42,7 @@ abstract class UserFilteredSlotPanel, out T : Slot>( if (slotFilter !== Items.AIR) { val itemStack = ItemStack(slotFilter!!, 1) - screen.renderItemStack(absoluteX, absoluteY, itemStack, null) + screen.renderItemStack(stack, itemStack, null) clearDepth(stack) drawColor = SLOT_FILTER_COLOR 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 51d1fc00c..1c20dd255 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 @@ -318,33 +318,11 @@ private class AndroidResearchButton( icon.render(stack, 0f, 0f, width, height) } else if (itemIcon != null) { val itemstack = ItemStack(itemIcon, 1) - val systemPoseStack = RenderSystem.getModelViewStack() - systemPoseStack.pushPose() - systemPoseStack.translate((absoluteX + 1f).toDouble(), (absoluteY + 1f).toDouble(), 0.0) - RenderSystem.applyModelViewMatrix() - RenderSystem.depthFunc(GL11.GL_LESS) - - // Thanks Mojang - // Very cool - // (for int x, int y, which are then cast into doubles anyway) - screen.itemRenderer.blitOffset = 1f // Z pos - - screen.itemRenderer.renderAndDecorateItem( - requireNotNull(minecraft.player) { "yo, dude, what the fuck" }, - itemstack, - 0, - 0, - (absoluteX + absoluteY * 1000f).toInt() - ) - - RenderSystem.depthFunc(GL11.GL_ALWAYS) - screen.itemRenderer.renderGuiItemDecorations(screen.font, itemstack, 0, 0, null) - screen.itemRenderer.blitOffset = 0f - - // too big accumulations can lead to Z near clipping issues - systemPoseStack.popPose() - RenderSystem.applyModelViewMatrix() + stack.pushPose() + stack.translate(1f, 1f, 0f) + screen.renderItemStack(stack, itemstack) + stack.popPose() clearDepth(stack) } else { 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 c6147db1e..e4784afed 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 @@ -83,7 +83,6 @@ open class FluidGaugePanel( } RenderSystem.setShader(GameRenderer::getPositionTexShader) - RenderSystem.enableTexture() RenderSystem.enableBlend() RenderSystem.defaultBlendFunc() RenderSystem.depthFunc(GL11.GL_ALWAYS) 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 b6477f102..74d3ede9a 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 @@ -71,7 +71,6 @@ open class MatterGaugePanel @JvmOverloads constructor( if (widget.percentage > 0.01f) { RenderSystem.setShader(GameRenderer::getPositionTexShader) - RenderSystem.enableTexture() RenderSystem.enableBlend() RenderSystem.defaultBlendFunc() RenderSystem.depthFunc(GL11.GL_ALWAYS) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt index 71c1ce3bb..b29c3359e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt @@ -4,16 +4,17 @@ import earth.terrarium.ad_astra.AdAstra import earth.terrarium.ad_astra.common.data.Planet import earth.terrarium.ad_astra.common.data.PlanetData import earth.terrarium.ad_astra.common.item.armor.SpaceSuit -import earth.terrarium.ad_astra.common.registry.ModDamageSource -import earth.terrarium.ad_astra.common.util.ModUtils +import earth.terrarium.ad_astra.common.registry.ModDamageSources import net.minecraft.world.entity.player.Player import net.minecraftforge.event.entity.living.LivingHurtEvent import net.minecraftforge.fml.ModList import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.config.ServerCompatConfig +import ru.dbotthepony.mc.otm.core.damageType +import ru.dbotthepony.mc.otm.registry.MDamageTypes import ru.dbotthepony.mc.otm.registry.MItems -import ru.dbotthepony.mc.otm.registry.MRegistry +import ru.dbotthepony.mc.otm.registry.MatteryDamageSource val isAdAstraLoaded by lazy { ModList.get().isLoaded(AdAstra.MOD_ID) @@ -27,7 +28,7 @@ fun onDamageEvent(event: LivingHurtEvent) { if (ServerCompatConfig.AdAstra.ANDROIDS_DO_NOT_NEED_OXYGEN) { if (ply.matteryPlayer?.isAndroid != true) return - if (event.source === ModDamageSource.OXYGEN) { + if (event.source.`is`(ModDamageSources.OXYGEN)) { event.amount = 0f event.isCanceled = true } @@ -51,7 +52,7 @@ fun onMatteryTick(event: MatteryPlayerCapability.PostTick) { val yesTritanium = yesTritanium0 + yesTritanium1 if (rand.nextDouble() <= (noSpacesuits - yesTritanium) * ServerCompatConfig.AdAstra.ANDROID_COSMIC_RAYS_CHANCE) { - event.player.hurt(MRegistry.DAMAGE_COSMIC_RAYS, 1f) + event.player.hurt(MatteryDamageSource(event.level.registryAccess().damageType(MDamageTypes.COSMIC_RAYS)), 1f) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt index 763dd099d..39e0a3e06 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt @@ -5,10 +5,12 @@ import it.unimi.dsi.fastutil.ints.IntArraySet import mezz.jei.api.IModPlugin import mezz.jei.api.JeiPlugin import mezz.jei.api.constants.RecipeTypes +import mezz.jei.api.constants.VanillaTypes import mezz.jei.api.gui.handlers.IGuiContainerHandler import mezz.jei.api.gui.ingredient.IRecipeSlotView import mezz.jei.api.gui.ingredient.IRecipeSlotsView import mezz.jei.api.helpers.IJeiHelpers +import mezz.jei.api.ingredients.ITypedIngredient import mezz.jei.api.recipe.RecipeIngredientRole import mezz.jei.api.recipe.transfer.IRecipeTransferError import mezz.jei.api.recipe.transfer.IRecipeTransferHandler @@ -18,6 +20,7 @@ import mezz.jei.api.registration.IRecipeCatalystRegistration import mezz.jei.api.registration.IRecipeCategoryRegistration import mezz.jei.api.registration.IRecipeRegistration import mezz.jei.api.registration.IRecipeTransferRegistration +import mezz.jei.api.runtime.IClickableIngredient import net.minecraft.client.renderer.Rect2i import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.player.Player @@ -36,6 +39,7 @@ import ru.dbotthepony.mc.otm.registry.MRecipes import java.util.* import java.util.stream.Collectors import kotlin.collections.ArrayList +import kotlin.jvm.optionals.getOrNull import kotlin.properties.Delegates var isJeiLoaded = false @@ -226,12 +230,28 @@ class JEIPlugin : IModPlugin { .collect(Collectors.toList()) } - override fun getIngredientUnderMouse( + override fun getClickableIngredientUnderMouse( containerScreen: MatteryScreen<*>, mouseX: Double, mouseY: Double - ): Any? { - return containerScreen.panelsView.stream().map { it.findItemStack(mouseX.toFloat(), mouseY.toFloat(), ignoreMouseInputLock = true) }.filter { it.first }.findAny().orElse(null)?.second + ): Optional> { + return containerScreen.panelsView + .stream() + .map { it.findItemStack(mouseX.toFloat(), mouseY.toFloat(), ignoreMouseInputLock = true) } + .filter { it.first != null } + .findAny() + .flatMap { a -> helpers.ingredientManager.createTypedIngredient(VanillaTypes.ITEM_STACK, a.second).map { a.first to it } } + .map { + object : IClickableIngredient { + override fun getTypedIngredient(): ITypedIngredient { + return it.second + } + + override fun getArea(): Rect2i { + return it.first!!.calculateAbsoluteRectangle().toIntRect() + } + } + } } }) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt index 3ef0503d7..e3130551a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt @@ -4,17 +4,26 @@ import com.google.gson.JsonElement import com.google.gson.JsonSyntaxException import com.mojang.serialization.Codec import com.mojang.serialization.JsonOps +import net.minecraft.core.BlockPos +import net.minecraft.core.Holder +import net.minecraft.core.RegistryAccess +import net.minecraft.core.registries.Registries import net.minecraft.nbt.NbtOps import net.minecraft.nbt.Tag import net.minecraft.network.FriendlyByteBuf import net.minecraft.network.chat.MutableComponent import net.minecraft.network.chat.contents.LiteralContents import net.minecraft.network.chat.contents.TranslatableContents +import net.minecraft.resources.ResourceKey import net.minecraft.resources.ResourceLocation import net.minecraft.sounds.SoundEvent +import net.minecraft.tags.DamageTypeTags +import net.minecraft.world.damagesource.DamageSource +import net.minecraft.world.damagesource.DamageType import net.minecraft.world.item.Item import net.minecraft.world.level.block.Block import net.minecraft.world.level.material.Fluid +import net.minecraft.world.phys.Vec3 import net.minecraftforge.registries.ForgeRegistries import net.minecraftforge.registries.IForgeRegistry @@ -52,7 +61,7 @@ fun Codec.toNbtStrict(value: V): Tag { } // 1.19 being 1.19 -fun TranslatableComponent(key: String, vararg values: Any): MutableComponent = MutableComponent.create(TranslatableContents(key, *values)) +fun TranslatableComponent(key: String, vararg values: Any): MutableComponent = MutableComponent.create(TranslatableContents(key, null, values)) fun TextComponent(value: String): MutableComponent = MutableComponent.create(LiteralContents(value)) fun IForgeRegistry.getKeyNullable(value: T): ResourceLocation? { @@ -73,3 +82,13 @@ fun FriendlyByteBuf.writeRegistryId(value: Item) = writeRegistryId(ForgeRegistri // 1.19.3 lol inline val SoundEvent.holder get() = ForgeRegistries.SOUND_EVENTS.getHolder(this).orElse(null) ?: throw NoSuchElementException("$this is missing from ${ForgeRegistries.SOUND_EVENTS}") + +// 1.19.4 :thonkang: +inline val DamageSource.isFall get() = `is`(DamageTypeTags.IS_FALL) +inline val DamageSource.isBypassArmor get() = `is`(DamageTypeTags.BYPASSES_ARMOR) +inline val DamageSource.isExplosion get() = `is`(DamageTypeTags.IS_EXPLOSION) +inline val DamageSource.isFire get() = `is`(DamageTypeTags.IS_FIRE) + +fun RegistryAccess.damageType(key: ResourceKey): Holder { + return registryOrThrow(Registries.DAMAGE_TYPE).getHolderOrThrow(key) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt index 8dcb64a3b..c0a32fee9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt @@ -157,11 +157,11 @@ class EnumValueCodec>(clazz: Class) : IStreamCodec, Codec< override fun decode(ops: DynamicOps, input: T): DataResult> { if (ops.compressMaps()) { return ops.getNumberValue(input) - .flatMap { values.getOrNull(it.toInt())?.let { DataResult.success(Pair(it, ops.empty())) } ?: DataResult.error("No such enum with ordinal index $it") } + .flatMap { values.getOrNull(it.toInt())?.let { DataResult.success(Pair(it, ops.empty())) } ?: DataResult.error { "No such enum with ordinal index $it" } } } return ops.getStringValue(input) - .flatMap { valuesMap[it]?.let { DataResult.success(Pair(it, ops.empty())) } ?: DataResult.error("No such enum value $it") } + .flatMap { valuesMap[it]?.let { DataResult.success(Pair(it, ops.empty())) } ?: DataResult.error { "No such enum value $it" } } } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/ItemStackCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/ItemStackCodec.kt index da27c1d3f..ec085f7f9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/ItemStackCodec.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/ItemStackCodec.kt @@ -41,10 +41,10 @@ object ItemStackCodec : Codec, TypeAdapter(), JsonSerializ override fun decode(ops: DynamicOps, input: T): DataResult> { return ops.getMap(input).flatMap { val item = it["id"]?.let { ForgeRegistries.ITEMS.codec.decode(ops, it) }?.result()?.orElse(null)?.first - val count = it["count"]?.let(ops::getNumberValue)?.result()?.orElse(null)?.toInt() ?: return@flatMap DataResult.error("Invalid item count") + val count = it["count"]?.let(ops::getNumberValue)?.result()?.orElse(null)?.toInt() ?: return@flatMap DataResult.error { "Invalid item count" } if (item == null || item == Items.AIR) { - return@flatMap DataResult.error("Unknown item type $item") + return@flatMap DataResult.error { "Unknown item type $item" } } DataResult.success(ItemStack(item, count)) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt index 487b6d274..1b473af22 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt @@ -69,7 +69,7 @@ class LootPoolAppender(conditions: Array, pools: Stream, pools: Stream, level) { var inflictor: ItemStack? = null @@ -36,7 +38,7 @@ class PlasmaProjectile(level: Level) : Projectile(MEntityTypes.PLASMA as EntityT super.onHitEntity(p_37259_) if (!level.isClientSide) { - p_37259_.entity.hurt(PlasmaDamageSource(owner, inflictor), damage) + p_37259_.entity.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.PLASMA), owner, inflictor), damage) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt index f983a909b..5d8a0b7c8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt @@ -24,7 +24,9 @@ import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.config.ItemsConfig import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.registry.MDamageTypes import ru.dbotthepony.mc.otm.registry.MRegistry +import ru.dbotthepony.mc.otm.registry.MatteryDamageSource import ru.dbotthepony.mc.otm.runIfClient import kotlin.math.roundToInt @@ -212,7 +214,7 @@ class CrudeBatteryItem : BatteryItem(ItemsConfig.Batteries.CRUDE) { mattery.androidEnergy.item = copyStack val extraDamageMult = level.random.nextFloat() - player.hurt(MRegistry.DAMAGE_EMP, 1.5f + extraDamageMult * 3.5f) + player.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EMP), inflictor = itemStack), 1.5f + extraDamageMult * 3.5f) val debuffDuration = 100 + (100 * (1f - extraDamageMult)).roundToInt() player.addEffect(MobEffectInstance(MobEffects.BLINDNESS, debuffDuration), player) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableCondensationDriveItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableCondensationDriveItem.kt index fe5d55909..4a4823dfe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableCondensationDriveItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableCondensationDriveItem.kt @@ -98,7 +98,7 @@ class PortableCondensationDriveItem(capacity: Int) : const val FILTER_PATH = "filter" fun onPickupEvent(event: EntityItemPickupEvent) { - if (event.item.owner != null && event.item.owner != event.entity.uuid && event.item.age < 200 || event.item.item.isEmpty) { + if (event.item.owner != null && event.item.owner != event.entity && event.item.age < 200 || event.item.item.isEmpty) { return } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/PortableGravitationStabilizerItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/PortableGravitationStabilizerItem.kt index 2bf541b69..39eff1c51 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/PortableGravitationStabilizerItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/PortableGravitationStabilizerItem.kt @@ -17,8 +17,8 @@ import ru.dbotthepony.mc.otm.client.model.GravitationStabilizerModel import java.util.function.Consumer private object GravitationStabilizerArmorMaterial : ArmorMaterial { - override fun getDurabilityForSlot(p_40410_: EquipmentSlot) = 0 - override fun getDefenseForSlot(p_40411_: EquipmentSlot) = 3 + override fun getDurabilityForType(p_40410_: ArmorItem.Type) = 0 + override fun getDefenseForType(p_40411_: ArmorItem.Type) = 3 override fun getEnchantmentValue() = 0 override fun getEquipSound(): SoundEvent = SoundEvents.ARMOR_EQUIP_GENERIC override fun getRepairIngredient(): Ingredient = Ingredient.EMPTY @@ -41,7 +41,7 @@ private object GravitationStabilizerArmorRenderProperties : IClientItemExtension } } -class PortableGravitationStabilizerItem : ArmorItem(GravitationStabilizerArmorMaterial, EquipmentSlot.CHEST, Properties().stacksTo(1).rarity(Rarity.RARE)) { +class PortableGravitationStabilizerItem : ArmorItem(GravitationStabilizerArmorMaterial, Type.CHESTPLATE, Properties().stacksTo(1).rarity(Rarity.RARE)) { override fun initializeClient(consumer: Consumer) { super.initializeClient(consumer) consumer.accept(GravitationStabilizerArmorRenderProperties) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/SimpleTritaniumArmorItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/SimpleTritaniumArmorItem.kt index 1a80ef610..4441e7237 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/SimpleTritaniumArmorItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/SimpleTritaniumArmorItem.kt @@ -12,22 +12,22 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.registry.MItemTags private object SimpleTritaniumArmorMaterial : ArmorMaterial { - override fun getDurabilityForSlot(p_40410_: EquipmentSlot): Int { + override fun getDurabilityForType(p_40410_: ArmorItem.Type): Int { return when (p_40410_) { - EquipmentSlot.HEAD -> 380 - EquipmentSlot.CHEST -> 590 - EquipmentSlot.LEGS -> 500 - EquipmentSlot.FEET -> 420 + ArmorItem.Type.HELMET -> 380 + ArmorItem.Type.CHESTPLATE -> 590 + ArmorItem.Type.LEGGINGS -> 500 + ArmorItem.Type.BOOTS -> 420 else -> throw IllegalArgumentException("yo dude what the fuck $p_40410_") } } - override fun getDefenseForSlot(p_40411_: EquipmentSlot): Int { + override fun getDefenseForType(p_40411_: ArmorItem.Type): Int { return when (p_40411_) { - EquipmentSlot.FEET -> 2 - EquipmentSlot.LEGS -> 6 - EquipmentSlot.CHEST -> 7 - EquipmentSlot.HEAD -> 2 + ArmorItem.Type.HELMET -> 2 + ArmorItem.Type.CHESTPLATE -> 6 + ArmorItem.Type.LEGGINGS -> 7 + ArmorItem.Type.BOOTS -> 2 else -> throw IllegalArgumentException("yo dude what the fuck $p_40411_") } } @@ -43,7 +43,7 @@ private object SimpleTritaniumArmorMaterial : ArmorMaterial { override fun getKnockbackResistance() = 0f } -class SimpleTritaniumArmorItem(slot: EquipmentSlot) : ArmorItem(SimpleTritaniumArmorMaterial, slot, Properties().stacksTo(1)) { +class SimpleTritaniumArmorItem(slot: Type) : ArmorItem(SimpleTritaniumArmorMaterial, slot, Properties().stacksTo(1)) { override fun getArmorTexture(stack: ItemStack, entity: Entity?, slot: EquipmentSlot, type: String?): String? { if (type != "overlay" || slot == EquipmentSlot.FEET) return when (slot) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/TritaniumArmorItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/TritaniumArmorItem.kt index 0c2c8b954..a90d73674 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/TritaniumArmorItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/TritaniumArmorItem.kt @@ -4,6 +4,7 @@ import net.minecraft.client.model.HumanoidModel import net.minecraft.sounds.SoundEvent import net.minecraft.sounds.SoundEvents import net.minecraft.world.damagesource.DamageSource +import net.minecraft.world.damagesource.DamageTypes import net.minecraft.world.entity.Entity import net.minecraft.world.entity.EquipmentSlot import net.minecraft.world.entity.LivingEntity @@ -21,23 +22,21 @@ import ru.dbotthepony.mc.otm.registry.MItems import java.util.function.Consumer private object TritaniumArmorMaterial : ArmorMaterial { - override fun getDurabilityForSlot(p_40410_: EquipmentSlot): Int { + override fun getDurabilityForType(p_40410_: ArmorItem.Type): Int { return when (p_40410_) { - EquipmentSlot.HEAD -> 520 - EquipmentSlot.CHEST -> 920 - EquipmentSlot.LEGS -> 650 - EquipmentSlot.FEET -> 540 - else -> throw IllegalArgumentException("yo dude what the fuck $p_40410_") + ArmorItem.Type.HELMET -> 520 + ArmorItem.Type.CHESTPLATE -> 920 + ArmorItem.Type.LEGGINGS -> 650 + ArmorItem.Type.BOOTS -> 540 } } - override fun getDefenseForSlot(p_40411_: EquipmentSlot): Int { + override fun getDefenseForType(p_40411_: ArmorItem.Type): Int { return when (p_40411_) { - EquipmentSlot.HEAD -> 4 - EquipmentSlot.CHEST -> 9 - EquipmentSlot.LEGS -> 7 - EquipmentSlot.FEET -> 3 - else -> throw IllegalArgumentException("yo dude what the fuck $p_40411_") + ArmorItem.Type.HELMET -> 4 + ArmorItem.Type.CHESTPLATE -> 9 + ArmorItem.Type.LEGGINGS -> 7 + ArmorItem.Type.BOOTS -> 3 } } @@ -67,7 +66,7 @@ private object TritaniumArmorRenderProperties : IClientItemExtensions { } } -class TritaniumArmorItem(slot: EquipmentSlot) : ArmorItem(TritaniumArmorMaterial, slot, Properties().stacksTo(1).rarity(Rarity.RARE)) { +class TritaniumArmorItem(slot: Type) : ArmorItem(TritaniumArmorMaterial, slot, Properties().stacksTo(1).rarity(Rarity.RARE)) { override fun initializeClient(consumer: Consumer) { super.initializeClient(consumer) consumer.accept(TritaniumArmorRenderProperties) @@ -81,7 +80,7 @@ class TritaniumArmorItem(slot: EquipmentSlot) : ArmorItem(TritaniumArmorMaterial const val TEXTURE_LOCATION = "${OverdriveThatMatters.MOD_ID}:textures/models/armor/tritanium_armor.png" fun onHurt(event: LivingAttackEvent) { - if (event.source === DamageSource.SWEET_BERRY_BUSH || event.source.msgId == "sweetBerryBush") { + if (event.source.typeHolder().`is`(DamageTypes.SWEET_BERRY_BUSH) || event.source.msgId == "sweetBerryBush") { if ( event.entity.getItemBySlot(EquipmentSlot.FEET).let { !it.isEmpty && it.item == MItems.TRITANIUM_BOOTS } && event.entity.getItemBySlot(EquipmentSlot.LEGS).let { !it.isEmpty && it.item == MItems.TRITANIUM_PANTS } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/AbstractExoPackSlotUpgradeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/AbstractExoPackSlotUpgradeItem.kt index e4dd48ac0..d2dbcb804 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/AbstractExoPackSlotUpgradeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/AbstractExoPackSlotUpgradeItem.kt @@ -18,6 +18,8 @@ import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.isExplosion +import ru.dbotthepony.mc.otm.core.isFire import ru.dbotthepony.mc.otm.runIfClient import java.util.UUID diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExoPackProbeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExoPackProbeItem.kt index afa6cb200..0b76063f1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExoPackProbeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExoPackProbeItem.kt @@ -14,7 +14,10 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.onceServer import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.core.damageType +import ru.dbotthepony.mc.otm.registry.MDamageTypes import ru.dbotthepony.mc.otm.registry.MRegistry +import ru.dbotthepony.mc.otm.registry.MatteryDamageSource import ru.dbotthepony.mc.otm.runIfClient class ExoPackProbeItem : Item(Properties().stacksTo(1).rarity(Rarity.EPIC)) { @@ -55,6 +58,8 @@ class ExoPackProbeItem : Item(Properties().stacksTo(1).rarity(Rarity.EPIC)) { return super.finishUsingItem(itemStack, level, player) } + val copy = itemStack.copy() + if (!player.abilities.instabuild) itemStack.shrink(1) @@ -63,7 +68,7 @@ class ExoPackProbeItem : Item(Properties().stacksTo(1).rarity(Rarity.EPIC)) { player.displayClientMessage(TranslatableComponent("otm.exopack.granted1").withStyle(ChatFormatting.GRAY), false) player.displayClientMessage(TranslatableComponent("otm.exopack.granted2").withStyle(ChatFormatting.GRAY), false) - player.hurt(MRegistry.DAMAGE_EXOPACK_PROBE, 10f) + player.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EXOPACK_PROBE), inflictor = copy), 10f) for (i in 3 .. 7) { onceServer((i - 1) * 100) { 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 fe9502518..57d981eb9 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 @@ -25,8 +25,10 @@ import net.minecraftforge.event.level.BlockEvent import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.config.ItemsConfig import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.damageType import ru.dbotthepony.mc.otm.core.getExplosionResistance import ru.dbotthepony.mc.otm.core.gracefulBlockBreak +import ru.dbotthepony.mc.otm.core.isExplosion import ru.dbotthepony.mc.otm.core.math.component1 import ru.dbotthepony.mc.otm.core.math.component2 import ru.dbotthepony.mc.otm.core.math.component3 @@ -36,8 +38,9 @@ import ru.dbotthepony.mc.otm.core.math.toDoubleVector import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.position import ru.dbotthepony.mc.otm.core.tagNotNull -import ru.dbotthepony.mc.otm.registry.HammerNailDamageSource +import ru.dbotthepony.mc.otm.registry.MDamageTypes import ru.dbotthepony.mc.otm.registry.MRegistry +import ru.dbotthepony.mc.otm.registry.MatteryDamageSource import ru.dbotthepony.mc.otm.triggers.NailedEntityTrigger class ExplosiveHammerItem(durability: Int = 64) : Item(Properties().stacksTo(1).fireResistant().durability(durability)) { @@ -86,7 +89,7 @@ class ExplosiveHammerItem(durability: Int = 64) : Item(Properties().stacksTo(1). // так как у меня алгоритм "своеобразный", я изобрету велосипед ибо я такой нехороший и непослушный // Трассировка луча используя наивный метод while (canTravel > 0.0) { - val blockPos = BlockPos(rayPos) + val blockPos = BlockPos.containing(rayPos) if (blockPos != lastBlockPos) { if (!level.hasChunkAt(blockPos)) break @@ -116,7 +119,7 @@ class ExplosiveHammerItem(durability: Int = 64) : Item(Properties().stacksTo(1). val rayBox = aabb.move(rayPos) val entities = level.getEntities(null, rayBox) { it is LivingEntity && it.isAlive && !it.isSpectator && hitEntities.add(it) } as List - val damageSource = HammerNailDamageSource(attacker, itemStack) + val damageSource = MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.HAMMER_NAIL), attacker, itemStack) for (it in entities) { val damage = canTravel * ItemsConfig.ExplosiveHammer.TRAVEL_DAMAGE_MULT @@ -143,6 +146,8 @@ class ExplosiveHammerItem(durability: Int = 64) : Item(Properties().stacksTo(1). if (attacker !is Player || !attacker.isCreative) { unprime(itemStack) + val copy = itemStack.copy() + itemStack.hurtAndBreak(1, attacker) { it.broadcastBreakEvent(hand) } @@ -166,12 +171,12 @@ class ExplosiveHammerItem(durability: Int = 64) : Item(Properties().stacksTo(1). if (attacker.random.nextDouble() <= ItemsConfig.ExplosiveHammer.FLY_OFF_DAMAGE_CHANCE) { attacker.invulnerableTime = 0 val dmg = ItemsConfig.ExplosiveHammer.FLY_OFF_MIN_DAMAGE + attacker.random.nextDouble() * (ItemsConfig.ExplosiveHammer.FLY_OFF_MAX_DAMAGE - ItemsConfig.ExplosiveHammer.FLY_OFF_MIN_DAMAGE) - attacker.hurt(MRegistry.DAMAGE_EXPLOSIVE_HAMMER, dmg.toFloat()) + attacker.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EXPLOSIVE_HAMMER), inflictor = copy), dmg.toFloat()) } } else if (attacker.random.nextDouble() <= ItemsConfig.ExplosiveHammer.SELF_HARM_CHANCE) { attacker.invulnerableTime = 0 val dmg = ItemsConfig.ExplosiveHammer.SELF_HARM_MIN_DAMAGE + attacker.random.nextDouble() * (ItemsConfig.ExplosiveHammer.SELF_HARM_MAX_DAMAGE - ItemsConfig.ExplosiveHammer.SELF_HARM_MIN_DAMAGE) - attacker.hurt(MRegistry.DAMAGE_EXPLOSIVE_HAMMER, dmg.toFloat()) + attacker.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EXPLOSIVE_HAMMER), inflictor = copy), dmg.toFloat()) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt index fcd607fc7..953b3391d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt @@ -10,6 +10,7 @@ import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.Entity import net.minecraft.world.entity.player.Player import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemDisplayContext import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Rarity import net.minecraft.world.level.block.state.BlockState @@ -438,7 +439,7 @@ abstract class AbstractWeaponItem(val tables: KClass, pr itemInHandRenderer.renderItem( player, stack, - ItemTransforms.TransformType.FIRST_PERSON_RIGHT_HAND, + ItemDisplayContext.FIRST_PERSON_RIGHT_HAND, false, pose, event.multiBufferSource, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt index e79e22482..a28415a6d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt @@ -38,12 +38,14 @@ import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.damageType import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.math.nextVariance import ru.dbotthepony.mc.otm.core.orNull -import ru.dbotthepony.mc.otm.registry.EMPDamageSource import ru.dbotthepony.mc.otm.core.util.WriteOnce +import ru.dbotthepony.mc.otm.registry.MDamageTypes +import ru.dbotthepony.mc.otm.registry.MatteryDamageSource class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vanishable { val chargedAttributes: Multimap @@ -104,7 +106,7 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani victim.matteryPlayer?.let { if (it.isAndroid) { victim.invulnerableTime = 0 - victim.hurt(EMPDamageSource(attacker, itemStack), 8f) + victim.hurt(MatteryDamageSource(attacker.level.registryAccess().damageType(MDamageTypes.EMP), attacker, itemStack), 8f) } } @@ -117,7 +119,7 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani victim.matteryPlayer?.let { if (it.isAndroid && it.androidEnergy.extractEnergyExact(ENERGY_ZAP, false)) { it.androidEnergy.extractEnergy(attacker.level.random.nextVariance(ENERGY_ZAP_VARIANCE), false) - victim.hurt(EMPDamageSource(attacker), 8f) + victim.hurt(MatteryDamageSource(attacker.level.registryAccess().damageType(MDamageTypes.EMP), attacker, itemStack), 8f) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 065c99865..6cef60235 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -516,7 +516,7 @@ object MatterManager { it.ingredients.stream() .filter { !it.isActuallyEmpty } .map { it.items.stream().map(::RecipeEntry) }, - ImmutableStack(it.resultItem), + ImmutableStack(it.getResultItem(server.registryAccess())), isCritical = isCritical, name = it.id, allowBacktrack = allowBacktrack @@ -584,7 +584,7 @@ object MatterManager { for (item in it.ingredients[c].items) { container[c] = item - if (!it.assemble(container).isEmpty) { + if (!it.assemble(container, server.registryAccess()).isEmpty) { val residue = it.getRemainingItems(container) val thisResidue = residue[c] @@ -602,7 +602,7 @@ object MatterManager { ResolvedRecipe( realIngredients.stream().map { it.stream() }, - ImmutableStack(it.resultItem), + ImmutableStack(it.getResultItem(server.registryAccess())), isCritical = isCritical, name = it.id, allowBacktrack = allowBacktrack 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 253ac43b1..e9a7ca4dc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/EnergyContainerRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/EnergyContainerRecipe.kt @@ -2,33 +2,75 @@ package ru.dbotthepony.mc.otm.recipe import com.google.gson.JsonObject 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 +import net.minecraft.world.item.crafting.RecipeType import net.minecraft.world.item.crafting.ShapedRecipe import net.minecraft.world.level.Level +import net.minecraftforge.common.crafting.IShapedRecipe import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.container.iterator import ru.dbotthepony.mc.otm.container.stream import ru.dbotthepony.mc.otm.core.filterNotNull -class EnergyContainerRecipe( - id: ResourceLocation, - group: String, - category: CraftingBookCategory, - width: Int, - height: Int, - ingredients: NonNullList, - result: ItemStack, -) : ShapedRecipe(id, group, category, width, height, ingredients, result) { - constructor(parent: ShapedRecipe) : this(parent.id, parent.group, parent.category(), parent.width, parent.height, parent.ingredients, parent.resultItem) +class EnergyContainerRecipe(val parent: ShapedRecipe) : CraftingRecipe, IShapedRecipe by parent { + override fun canCraftInDimensions(p_43999_: Int, p_44000_: Int): Boolean { + return parent.canCraftInDimensions(p_43999_, p_44000_) + } - override fun assemble(container: CraftingContainer): ItemStack { - val itemStack = super.assemble(container) + override fun getResultItem(p_267052_: RegistryAccess): ItemStack { + return parent.getResultItem(p_267052_) + } + + override fun getId(): ResourceLocation { + return parent.id + } + + override fun category(): CraftingBookCategory { + return parent.category() + } + + override fun getRemainingItems(p_44004_: CraftingContainer): NonNullList { + return parent.getRemainingItems(p_44004_) + } + + override fun getIngredients(): NonNullList { + return parent.ingredients + } + + override fun isSpecial(): Boolean { + return parent.isSpecial + } + + override fun showNotification(): Boolean { + return parent.showNotification() + } + + override fun getGroup(): String { + return parent.group + } + + override fun getToastSymbol(): ItemStack { + return parent.toastSymbol + } + + override fun isIncomplete(): Boolean { + return parent.isIncomplete + } + + override fun getType(): RecipeType<*> { + return parent.type + } + + override fun assemble(container: CraftingContainer, registryAccess: RegistryAccess): ItemStack { + val itemStack = parent.assemble(container, registryAccess) val battery = container.stream() .filter { !it.isEmpty } @@ -54,7 +96,7 @@ class EnergyContainerRecipe( } override fun matches(container: CraftingContainer, level: Level): Boolean { - return super.matches(container, level) && !container.stream().anyMatch { it.isDamaged } + return parent.matches(container, level) && !container.stream().anyMatch { it.isDamaged } } override fun getSerializer(): RecipeSerializer { @@ -63,15 +105,15 @@ class EnergyContainerRecipe( companion object : RecipeSerializer { override fun fromJson(id: ResourceLocation, data: JsonObject): EnergyContainerRecipe { - return EnergyContainerRecipe(Serializer.SHAPED_RECIPE.fromJson(id, data)) + return EnergyContainerRecipe(ShapedRecipe.Serializer.SHAPED_RECIPE.fromJson(id, data)) } override fun fromNetwork(id: ResourceLocation, data: FriendlyByteBuf): EnergyContainerRecipe? { - return Serializer.SHAPED_RECIPE.fromNetwork(id, data)?.let(::EnergyContainerRecipe) + return ShapedRecipe.Serializer.SHAPED_RECIPE.fromNetwork(id, data)?.let(::EnergyContainerRecipe) } override fun toNetwork(buff: FriendlyByteBuf, value: EnergyContainerRecipe) { - Serializer.SHAPED_RECIPE.toNetwork(buff, value) + ShapedRecipe.Serializer.SHAPED_RECIPE.toNetwork(buff, value.parent) } } } 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 db921ef0e..3cf34752d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/ExplosiveHammerPrimingRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/ExplosiveHammerPrimingRecipe.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.recipe import com.google.gson.JsonObject import com.google.gson.JsonSyntaxException import net.minecraft.core.NonNullList +import net.minecraft.core.RegistryAccess import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation @@ -42,7 +43,7 @@ class ExplosiveHammerPrimingRecipe(private val _id: ResourceLocation, val payloa result.any { payload.test(it) } } - override fun assemble(pContainer: CraftingContainer): ItemStack { + override fun assemble(pContainer: CraftingContainer, registry: RegistryAccess): ItemStack { val hammer = pContainer.stream().filter { it.isNotEmpty && it.item is ExplosiveHammerItem }.findAny() if (hammer.isEmpty) return ItemStack.EMPTY @@ -55,7 +56,7 @@ class ExplosiveHammerPrimingRecipe(private val _id: ResourceLocation, val payloa return pWidth * pHeight >= 3 } - override fun getResultItem(): ItemStack { + override fun getResultItem(registry: RegistryAccess): ItemStack { return ItemStack.EMPTY } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt index 013e9d8a8..246995f21 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.recipe import com.google.gson.JsonObject import com.google.gson.JsonPrimitive import net.minecraft.core.NonNullList +import net.minecraft.core.RegistryAccess import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation import net.minecraft.util.valueproviders.ConstantFloat @@ -62,9 +63,9 @@ class PlatePressRecipe( return input.isActuallyEmpty || output.isActuallyEmpty } - override fun assemble(p_44001_: Container): ItemStack = outputStack.copy() + override fun assemble(p_44001_: Container, registry: RegistryAccess): ItemStack = outputStack.copy() override fun canCraftInDimensions(p_43999_: Int, p_44000_: Int) = true - override fun getResultItem(): ItemStack = outputStack + override fun getResultItem(registry: RegistryAccess): ItemStack = outputStack override fun getId() = id 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 08d766c8a..224186c4e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt @@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableList import com.google.gson.JsonObject import com.google.gson.JsonPrimitive import net.minecraft.core.NonNullList +import net.minecraft.core.RegistryAccess import net.minecraft.nbt.CompoundTag import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation @@ -11,9 +12,14 @@ import net.minecraft.util.GsonHelper 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.Recipe import net.minecraft.world.item.crafting.RecipeSerializer +import net.minecraft.world.item.crafting.RecipeType import net.minecraft.world.item.crafting.ShapedRecipe +import net.minecraft.world.level.Level +import net.minecraftforge.common.crafting.IShapedRecipe import ru.dbotthepony.mc.otm.container.stream import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.registryName @@ -25,17 +31,61 @@ import ru.dbotthepony.mc.otm.core.collect.stream import java.util.stream.Stream class UpgradeRecipe( - id: ResourceLocation, - group: String, - category: CraftingBookCategory, - width: Int, - height: Int, - ingredients: NonNullList, - result: ItemStack, + val parent: ShapedRecipe, copyPaths: Stream, val source: ResourceLocation, -) : ShapedRecipe(id, group, category, width, height, ingredients, result) { - constructor(parent: ShapedRecipe, copyPaths: Stream, source: ResourceLocation) : this(parent.id, parent.group, parent.category(), parent.width, parent.height, parent.ingredients, parent.resultItem, copyPaths, source) +) : CraftingRecipe, IShapedRecipe by parent { + override fun matches(p_44002_: CraftingContainer, p_44003_: Level): Boolean { + return parent.matches(p_44002_, p_44003_) + } + + override fun canCraftInDimensions(p_43999_: Int, p_44000_: Int): Boolean { + return parent.canCraftInDimensions(p_43999_, p_44000_) + } + + override fun getResultItem(p_267052_: RegistryAccess): ItemStack { + return parent.getResultItem(p_267052_) + } + + override fun getRemainingItems(p_44004_: CraftingContainer): NonNullList { + return parent.getRemainingItems(p_44004_) + } + + override fun getIngredients(): NonNullList { + return parent.ingredients + } + + override fun isSpecial(): Boolean { + return parent.isSpecial + } + + override fun showNotification(): Boolean { + return parent.showNotification() + } + + override fun getGroup(): String { + return parent.group + } + + override fun getToastSymbol(): ItemStack { + return parent.toastSymbol + } + + override fun getId(): ResourceLocation { + return parent.id + } + + override fun isIncomplete(): Boolean { + return parent.isIncomplete + } + + override fun getType(): RecipeType<*> { + return parent.type + } + + override fun category(): CraftingBookCategory { + return parent.category() + } enum class OpType { DIRECT { @@ -147,8 +197,8 @@ class UpgradeRecipe( val copyPaths: ImmutableList = copyPaths.collect(ImmutableList.toImmutableList()) - override fun assemble(pInv: CraftingContainer): ItemStack { - val result = super.assemble(pInv) + override fun assemble(pInv: CraftingContainer, registryAccess: RegistryAccess): ItemStack { + val result = parent.assemble(pInv, registryAccess) if (result.isEmpty) { return result @@ -180,14 +230,14 @@ class UpgradeRecipe( override fun fromJson(id: ResourceLocation, data: JsonObject): UpgradeRecipe { return UpgradeRecipe( - Serializer.SHAPED_RECIPE.fromJson(id, data), + ShapedRecipe.Serializer.SHAPED_RECIPE.fromJson(id, data), GsonHelper.getAsJsonArray(data, "copyPaths").stream().map { deserializeOp(it as JsonObject) }, ResourceLocation(GsonHelper.getAsString(data, "source")) ) } override fun fromNetwork(id: ResourceLocation, buff: FriendlyByteBuf): UpgradeRecipe? { - val recipe = Serializer.SHAPED_RECIPE.fromNetwork(id, buff) ?: return null + val recipe = ShapedRecipe.Serializer.SHAPED_RECIPE.fromNetwork(id, buff) ?: return null return UpgradeRecipe( recipe, @@ -197,7 +247,7 @@ class UpgradeRecipe( } override fun toNetwork(buff: FriendlyByteBuf, value: UpgradeRecipe) { - Serializer.SHAPED_RECIPE.toNetwork(buff, value) + ShapedRecipe.Serializer.SHAPED_RECIPE.toNetwork(buff, value.parent) buff.writeCollection(value.copyPaths) { it, v -> it.writeJson(v.serialize()) } buff.writeResourceLocation(value.source) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt deleted file mode 100644 index b82dc5292..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/CreativeTabs.kt +++ /dev/null @@ -1,248 +0,0 @@ -package ru.dbotthepony.mc.otm.registry - -import net.minecraft.world.item.CreativeModeTab -import net.minecraft.world.item.DyeColor -import net.minecraft.world.item.Item -import net.minecraft.world.item.ItemStack -import net.minecraft.world.level.material.FlowingFluid -import net.minecraft.world.level.material.Fluids -import net.minecraftforge.common.capabilities.ForgeCapabilities -import net.minecraftforge.fluids.FluidStack -import net.minecraftforge.fluids.capability.IFluidHandler -import net.minecraftforge.registries.ForgeRegistries -import ru.dbotthepony.mc.otm.capability.matter.matter -import ru.dbotthepony.mc.otm.capability.matteryEnergy -import ru.dbotthepony.mc.otm.core.ifPresentK -import ru.dbotthepony.mc.otm.core.registryName - -private fun CreativeModeTab.Output.accept(values: Collection) { - for (item in values) { - accept(item) - } -} - -private fun CreativeModeTab.Output.base(values: Map) { - accept(values[null]!!) -} - -private val colorOrder = listOf( - null, - DyeColor.WHITE, - DyeColor.ORANGE, - DyeColor.MAGENTA, - DyeColor.LIGHT_BLUE, - DyeColor.YELLOW, - DyeColor.LIME, - DyeColor.PINK, - DyeColor.GRAY, - DyeColor.LIGHT_GRAY, - DyeColor.CYAN, - DyeColor.PURPLE, - DyeColor.BLUE, - DyeColor.BROWN, - DyeColor.GREEN, - DyeColor.RED, - DyeColor.BLACK, -) - -private fun CreativeModeTab.Output.colored(values: Map) { - accept(values[DyeColor.WHITE]!!) - accept(values[DyeColor.ORANGE]!!) - accept(values[DyeColor.MAGENTA]!!) - accept(values[DyeColor.LIGHT_BLUE]!!) - accept(values[DyeColor.YELLOW]!!) - accept(values[DyeColor.LIME]!!) - accept(values[DyeColor.PINK]!!) - accept(values[DyeColor.GRAY]!!) - accept(values[DyeColor.LIGHT_GRAY]!!) - accept(values[DyeColor.CYAN]!!) - accept(values[DyeColor.PURPLE]!!) - accept(values[DyeColor.BLUE]!!) - accept(values[DyeColor.BROWN]!!) - accept(values[DyeColor.GREEN]!!) - accept(values[DyeColor.RED]!!) - accept(values[DyeColor.BLACK]!!) -} - -private fun CreativeModeTab.Output.all(values: Map) { - base(values) - colored(values) -} - -private fun CreativeModeTab.Output.energized(value: Item) { - accept(value) - - val stack = ItemStack(value, 1) - val energy = stack.matteryEnergy ?: throw IllegalArgumentException("${value.registryName} does not implement mattery energy capability") - energy.fillBattery() - - if (ItemStack(value, 1).matteryEnergy!!.batteryLevel != energy.batteryLevel) - accept(stack) -} - -private fun CreativeModeTab.Output.energized(values: Iterable) { - for (value in values) { - energized(value) - } -} - -private fun CreativeModeTab.Output.mattery(value: Item) { - accept(value) - - val stack = ItemStack(value, 1) - val matter = stack.matter ?: throw IllegalArgumentException("${value.registryName} does not implement matter capability") - - matter.fillMatter() - - if (ItemStack(value, 1).matter!!.storedMatter != matter.storedMatter) - accept(stack) -} - -private fun CreativeModeTab.Output.mattery(values: Iterable) { - for (value in values) { - mattery(value) - } -} - -private fun CreativeModeTab.Output.fluids(value: Item) { - accept(value) - - for (fluid in ForgeRegistries.FLUIDS.values) { - if (fluid != Fluids.EMPTY && fluid.isSource(fluid.defaultFluidState())) { - accept(ItemStack(value, 1).also { - it.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK { - it.fill(FluidStack(fluid, it.getTankCapacity(0)), IFluidHandler.FluidAction.EXECUTE) - } - }) - } - } -} - -internal fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { - with(consumer) { - accept(MItems.MACHINES) - - accept(MRegistry.CARGO_CRATES.item) - accept(MItems.HOLO_SIGN) - - base(MItems.TRITANIUM_DOOR) - base(MItems.TRITANIUM_TRAPDOOR) - accept(MRegistry.TRITANIUM_PRESSURE_PLATE.item) - accept(MItems.TRITANIUM_ANVIL[0]) - - // accept(MItems.MATTER_DUST) - - accept(MItems.TRITANIUM_ORE) - accept(MItems.DEEPSLATE_TRITANIUM_ORE) - accept(MItems.TRITANIUM_ORE_CLUMP) - accept(MItems.TRITANIUM_DUST) - accept(MItems.TRITANIUM_NUGGET) - accept(MItems.TRITANIUM_INGOT) - accept(MItems.TRITANIUM_INGOT_BLOCK) - - accept(MItems.TRITANIUM_TOOLS) - accept(MItems.SIMPLE_TRITANIUM_ARMOR) - accept(MItems.TRITANIUM_ARMOR) - - energized(MItems.ENERGY_SWORD) - energized(MItems.PLASMA_RIFLE) - - accept(MItems.EXPLOSIVE_HAMMER) - accept(ItemStack(MItems.EXPLOSIVE_HAMMER).also { MItems.EXPLOSIVE_HAMMER.prime(it) }) - - accept(MItems.BLACK_HOLE_SCANNER) - accept(MItems.GRAVITATION_FIELD_LIMITER) - accept(MItems.GRAVITATION_FIELD_SENSOR) - accept(MItems.PORTABLE_GRAVITATION_STABILIZER) - accept(MItems.BLACK_HOLE) - accept(MItems.GRAVITATIONAL_DISRUPTOR) - - accept(MItems.ESSENCE_SERVO) - - energized(MItems.ALL_BATTERIES) - mattery(MItems.MATTER_CAPACITORS) - accept(MItems.PATTERN_DRIVE_NORMAL) - accept(MItems.PATTERN_DRIVE_CREATIVE) - accept(MItems.PATTERN_DRIVE_CREATIVE2) - - fluids(MItems.FLUID_CAPSULE) - fluids(MItems.FLUID_TANK) - - base(MItems.CARGO_CRATE_MINECARTS) - - accept(MItems.NUTRIENT_PASTE) - - // exo - accept(MItems.EXOPACK_PROBE) - accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_CREATIVE) - accept(MItems.ExopackUpgrades.CRAFTING_UPGRADE) - - accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_BIG) - accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_HUGE) - accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_WITHER) - accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_ENDER_DRAGON) - - accept(MItems.ExopackUpgrades.INVENTORY_UPGRADES) - // /exo - - accept(MItems.PILLS) - - accept(MItems.COMPONENTS) - } -} - -internal fun addDecorativeTabItems(consumer: CreativeModeTab.Output) { - with(consumer) { - accept(MItems.LABORATORY_LAMP) - accept(MItems.LABORATORY_LAMP_INVERTED) - accept(MItems.DANGER_STRIPE_BLOCK) - accept(MItems.METAL_BEAM) - accept(MItems.ENGINE) - - accept(MItems.TRITANIUM_STRIPED_BLOCK) - accept(MItems.TRITANIUM_STRIPED_STAIRS) - accept(MItems.TRITANIUM_STRIPED_SLAB) - accept(MItems.TRITANIUM_STRIPED_WALL) - accept(MItems.CARBON_FIBRE_BLOCK) - accept(MItems.METAL_JUNK) - accept(MItems.METAL_MESH) - - accept(MItems.TRITANIUM_BARS) - - colored(MItems.TRITANIUM_DOOR) - colored(MItems.TRITANIUM_TRAPDOOR) - accept(MRegistry.TRITANIUM_PRESSURE_PLATE.items.values) - - for (i in 0 until MItems.TRITANIUM_ANVIL.size) - accept(MItems.TRITANIUM_ANVIL[i]) - - colored(MRegistry.CARGO_CRATES.items) - - colored(MItems.CARGO_CRATE_MINECARTS) - - all(MRegistry.DECORATIVE_CRATE.allItems) - - for (color in colorOrder) { - accept(MRegistry.TRITANIUM_BLOCK.allItems[color]!!) - accept(MRegistry.TRITANIUM_STAIRS.allItems[color]!!) - accept(MRegistry.TRITANIUM_SLAB.allItems[color]!!) - accept(MRegistry.TRITANIUM_WALL.allItems[color]!!) - } - - all(MRegistry.INDUSTRIAL_GLASS.allItems) - all(MRegistry.INDUSTRIAL_GLASS_PANE.allItems) - - colored(MRegistry.UNREFINED_FLOOR_TILES.items) - colored(MRegistry.FLOOR_TILES.items) - colored(MRegistry.FLOOR_TILES_STAIRS.items) - colored(MRegistry.FLOOR_TILES_SLAB.items) - - all(MRegistry.VENT.allItems) - all(MRegistry.VENT_ALTERNATIVE.allItems) - - accept(MRegistry.TRITANIUM_STRIPED_BLOCK.flatItems) - accept(MRegistry.TRITANIUM_STRIPED_STAIRS.flatItems) - accept(MRegistry.TRITANIUM_STRIPED_SLAB.flatItems) - accept(MRegistry.TRITANIUM_STRIPED_WALL.flatItems) - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/DamageSources.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/DamageSources.kt deleted file mode 100644 index 356944726..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/DamageSources.kt +++ /dev/null @@ -1,192 +0,0 @@ -package ru.dbotthepony.mc.otm.registry - -import net.minecraft.network.chat.Component -import net.minecraft.world.damagesource.DamageSource -import net.minecraft.world.entity.Entity -import net.minecraft.world.entity.LivingEntity -import net.minecraft.world.item.ItemStack -import net.minecraft.world.phys.Vec3 -import ru.dbotthepony.mc.otm.core.TranslatableComponent - -class ImmutableDamageSource(private val parent: DamageSource) : DamageSource(parent.msgId) { - override fun equals(other: Any?): Boolean { - return parent == other - } - - override fun hashCode(): Int { - return parent.hashCode() - } - - override fun toString(): String { - return parent.toString() - } - - override fun isProjectile(): Boolean { - return parent.isProjectile - } - - override fun setProjectile(): DamageSource { - throw UnsupportedOperationException() - } - - override fun isExplosion(): Boolean { - return parent.isExplosion - } - - override fun setExplosion(): DamageSource { - throw UnsupportedOperationException() - } - - override fun isBypassArmor(): Boolean { - return parent.isBypassArmor - } - - override fun isDamageHelmet(): Boolean { - return parent.isDamageHelmet - } - - override fun getFoodExhaustion(): Float { - return parent.foodExhaustion - } - - override fun isBypassInvul(): Boolean { - return parent.isBypassInvul - } - - override fun isBypassMagic(): Boolean { - return parent.isBypassMagic - } - - override fun getDirectEntity(): Entity? { - return parent.directEntity - } - - override fun getEntity(): Entity? { - return parent.entity - } - - override fun bypassArmor(): DamageSource { - throw UnsupportedOperationException() - } - - override fun damageHelmet(): DamageSource { - throw UnsupportedOperationException() - } - - override fun bypassInvul(): DamageSource { - throw UnsupportedOperationException() - } - - override fun bypassMagic(): DamageSource { - throw UnsupportedOperationException() - } - - override fun setIsFire(): DamageSource { - throw UnsupportedOperationException() - } - - override fun setNoAggro(): DamageSource { - throw UnsupportedOperationException() - } - - override fun getLocalizedDeathMessage(p_19343_: LivingEntity): Component { - return super.getLocalizedDeathMessage(p_19343_) - } - - override fun isFire(): Boolean { - return parent.isFire - } - - override fun isNoAggro(): Boolean { - return parent.isNoAggro - } - - override fun getMsgId(): String { - return parent.getMsgId() - } - - override fun setScalesWithDifficulty(): DamageSource { - throw UnsupportedOperationException() - } - - override fun scalesWithDifficulty(): Boolean { - return parent.scalesWithDifficulty() - } - - override fun isMagic(): Boolean { - return parent.isMagic - } - - override fun setMagic(): DamageSource { - throw UnsupportedOperationException() - } - - override fun isFall(): Boolean { - return parent.isFall - } - - override fun setIsFall(): DamageSource { - throw UnsupportedOperationException() - } - - override fun isCreativePlayer(): Boolean { - return parent.isCreativePlayer - } - - override fun getSourcePosition(): Vec3? { - return parent.sourcePosition - } -} - -abstract class MatteryDamageSource(name: String, private val entity: Entity? = null, val inflictor: ItemStack? = null) : DamageSource(name) { - override fun getLocalizedDeathMessage(victim: LivingEntity): Component { - val itemStack = inflictor ?: (entity as LivingEntity?)?.mainHandItem ?: ItemStack.EMPTY - - if (!itemStack.isEmpty && itemStack.hasCustomHoverName()) { - return TranslatableComponent("death.attack.$msgId.player.item", victim.displayName, entity!!.displayName, itemStack.displayName) - } - - if (entity != null) { - return TranslatableComponent("death.attack.$msgId.player", victim.displayName, entity.displayName) - } - - return TranslatableComponent("death.attack.$msgId", victim.displayName) - } - - final override fun getEntity(): Entity? { - return entity - } -} - -class EMPDamageSource(entity: Entity? = null, inflictor: ItemStack? = null) : MatteryDamageSource(MRegistry.DAMAGE_EMP_NAME, entity, inflictor) { - init { - bypassArmor() - bypassMagic() - } - - override fun scalesWithDifficulty(): Boolean { - return false - } -} - -class ShockwaveDamageSource(entity: Entity? = null, inflictor: ItemStack? = null) : MatteryDamageSource(MRegistry.DAMAGE_SHOCKWAVE_NAME, entity, inflictor) { - init { - bypassArmor() - } - - override fun scalesWithDifficulty(): Boolean { - return false - } -} - -class PlasmaDamageSource(entity: Entity? = null, inflictor: ItemStack? = null) : MatteryDamageSource(MRegistry.DAMAGE_PLASMA_NAME, entity, inflictor) { - override fun scalesWithDifficulty(): Boolean { - return false - } -} - -class HammerNailDamageSource(entity: Entity? = null, inflictor: ItemStack? = null) : MatteryDamageSource(MRegistry.DAMAGE_HAMMER_NAIL_NAME, entity, inflictor) { - override fun scalesWithDifficulty(): Boolean { - return false - } -} 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 166e058a3..c7ccab195 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -23,6 +23,7 @@ import net.minecraft.world.level.block.TrapDoorBlock import net.minecraft.world.level.block.WallBlock import net.minecraft.world.level.block.state.BlockBehaviour import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.level.block.state.properties.BlockSetType import net.minecraft.world.level.material.Material import net.minecraft.world.level.material.MaterialColor import net.minecraftforge.eventbus.api.IEventBus @@ -190,7 +191,7 @@ object MBlocks { } val TRITANIUM_DOOR = registry.allColored(MNames.TRITANIUM_DOOR) { color, _ -> - object : DoorBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), SoundEvents.IRON_DOOR_CLOSE, SoundEvents.IRON_DOOR_OPEN) { + object : DoorBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), BlockSetType.IRON) { override fun appendHoverText( p_49816_: ItemStack, p_49817_: BlockGetter?, @@ -218,7 +219,7 @@ object MBlocks { } val TRITANIUM_TRAPDOOR = registry.allColored(MNames.TRITANIUM_TRAPDOOR) { color, _ -> - object : TrapDoorBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), SoundEvents.IRON_DOOR_CLOSE, SoundEvents.IRON_DOOR_OPEN) { + object : TrapDoorBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), BlockSetType.IRON) { override fun appendHoverText( p_49816_: ItemStack, p_49817_: BlockGetter?, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt index a8139397e..b9732918e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt @@ -2,14 +2,257 @@ package ru.dbotthepony.mc.otm.registry import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.CreativeModeTab +import net.minecraft.world.item.DyeColor +import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack +import net.minecraft.world.level.material.Fluids +import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.event.CreativeModeTabEvent +import net.minecraftforge.fluids.FluidStack +import net.minecraftforge.fluids.capability.IFluidHandler +import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.capability.matter.matter +import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.core.util.CreativeMenuComparator import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.ifPresentK +import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.registry.MItems.BATTERY_CREATIVE +private fun CreativeModeTab.Output.accept(values: Collection) { + for (item in values) { + accept(item) + } +} + +private fun CreativeModeTab.Output.base(values: Map) { + accept(values[null]!!) +} + +private val colorOrder = listOf( + null, + DyeColor.WHITE, + DyeColor.ORANGE, + DyeColor.MAGENTA, + DyeColor.LIGHT_BLUE, + DyeColor.YELLOW, + DyeColor.LIME, + DyeColor.PINK, + DyeColor.GRAY, + DyeColor.LIGHT_GRAY, + DyeColor.CYAN, + DyeColor.PURPLE, + DyeColor.BLUE, + DyeColor.BROWN, + DyeColor.GREEN, + DyeColor.RED, + DyeColor.BLACK, +) + +private fun CreativeModeTab.Output.colored(values: Map) { + accept(values[DyeColor.WHITE]!!) + accept(values[DyeColor.ORANGE]!!) + accept(values[DyeColor.MAGENTA]!!) + accept(values[DyeColor.LIGHT_BLUE]!!) + accept(values[DyeColor.YELLOW]!!) + accept(values[DyeColor.LIME]!!) + accept(values[DyeColor.PINK]!!) + accept(values[DyeColor.GRAY]!!) + accept(values[DyeColor.LIGHT_GRAY]!!) + accept(values[DyeColor.CYAN]!!) + accept(values[DyeColor.PURPLE]!!) + accept(values[DyeColor.BLUE]!!) + accept(values[DyeColor.BROWN]!!) + accept(values[DyeColor.GREEN]!!) + accept(values[DyeColor.RED]!!) + accept(values[DyeColor.BLACK]!!) +} + +private fun CreativeModeTab.Output.all(values: Map) { + base(values) + colored(values) +} + +private fun CreativeModeTab.Output.energized(value: Item) { + accept(value) + + val stack = ItemStack(value, 1) + val energy = stack.matteryEnergy ?: throw IllegalArgumentException("${value.registryName} does not implement mattery energy capability") + energy.fillBattery() + + if (ItemStack(value, 1).matteryEnergy!!.batteryLevel != energy.batteryLevel) + accept(stack) +} + +private fun CreativeModeTab.Output.energized(values: Iterable) { + for (value in values) { + energized(value) + } +} + +private fun CreativeModeTab.Output.mattery(value: Item) { + accept(value) + + val stack = ItemStack(value, 1) + val matter = stack.matter ?: throw IllegalArgumentException("${value.registryName} does not implement matter capability") + + matter.fillMatter() + + if (ItemStack(value, 1).matter!!.storedMatter != matter.storedMatter) + accept(stack) +} + +private fun CreativeModeTab.Output.mattery(values: Iterable) { + for (value in values) { + mattery(value) + } +} + +private fun CreativeModeTab.Output.fluids(value: Item) { + accept(value) + + for (fluid in ForgeRegistries.FLUIDS.values) { + if (fluid != Fluids.EMPTY && fluid.isSource(fluid.defaultFluidState())) { + accept(ItemStack(value, 1).also { + it.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK { + it.fill(FluidStack(fluid, it.getTankCapacity(0)), IFluidHandler.FluidAction.EXECUTE) + } + }) + } + } +} + +private fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { + with(consumer) { + accept(MItems.MACHINES) + + accept(MRegistry.CARGO_CRATES.item) + accept(MItems.HOLO_SIGN) + + base(MItems.TRITANIUM_DOOR) + base(MItems.TRITANIUM_TRAPDOOR) + accept(MRegistry.TRITANIUM_PRESSURE_PLATE.item) + accept(MItems.TRITANIUM_ANVIL[0]) + + // accept(MItems.MATTER_DUST) + + accept(MItems.TRITANIUM_ORE) + accept(MItems.DEEPSLATE_TRITANIUM_ORE) + accept(MItems.TRITANIUM_ORE_CLUMP) + accept(MItems.TRITANIUM_DUST) + accept(MItems.TRITANIUM_NUGGET) + accept(MItems.TRITANIUM_INGOT) + accept(MItems.TRITANIUM_INGOT_BLOCK) + + accept(MItems.TRITANIUM_TOOLS) + accept(MItems.SIMPLE_TRITANIUM_ARMOR) + accept(MItems.TRITANIUM_ARMOR) + + energized(MItems.ENERGY_SWORD) + energized(MItems.PLASMA_RIFLE) + + accept(MItems.EXPLOSIVE_HAMMER) + accept(ItemStack(MItems.EXPLOSIVE_HAMMER).also { MItems.EXPLOSIVE_HAMMER.prime(it) }) + + accept(MItems.BLACK_HOLE_SCANNER) + accept(MItems.GRAVITATION_FIELD_LIMITER) + accept(MItems.GRAVITATION_FIELD_SENSOR) + accept(MItems.PORTABLE_GRAVITATION_STABILIZER) + accept(MItems.BLACK_HOLE) + accept(MItems.GRAVITATIONAL_DISRUPTOR) + + accept(MItems.ESSENCE_SERVO) + + energized(MItems.ALL_BATTERIES) + mattery(MItems.MATTER_CAPACITORS) + accept(MItems.PATTERN_DRIVE_NORMAL) + accept(MItems.PATTERN_DRIVE_CREATIVE) + accept(MItems.PATTERN_DRIVE_CREATIVE2) + + fluids(MItems.FLUID_CAPSULE) + fluids(MItems.FLUID_TANK) + + base(MItems.CARGO_CRATE_MINECARTS) + + accept(MItems.NUTRIENT_PASTE) + + // exo + accept(MItems.EXOPACK_PROBE) + accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_CREATIVE) + accept(MItems.ExopackUpgrades.CRAFTING_UPGRADE) + + accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_BIG) + accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_HUGE) + accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_WITHER) + accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_ENDER_DRAGON) + + accept(MItems.ExopackUpgrades.INVENTORY_UPGRADES) + // /exo + + accept(MItems.PILLS) + + accept(MItems.COMPONENTS) + } +} + +private fun addDecorativeTabItems(consumer: CreativeModeTab.Output) { + with(consumer) { + accept(MItems.LABORATORY_LAMP) + accept(MItems.LABORATORY_LAMP_INVERTED) + accept(MItems.DANGER_STRIPE_BLOCK) + accept(MItems.METAL_BEAM) + accept(MItems.ENGINE) + + accept(MItems.TRITANIUM_STRIPED_BLOCK) + accept(MItems.TRITANIUM_STRIPED_STAIRS) + accept(MItems.TRITANIUM_STRIPED_SLAB) + accept(MItems.TRITANIUM_STRIPED_WALL) + accept(MItems.CARBON_FIBRE_BLOCK) + accept(MItems.METAL_JUNK) + accept(MItems.METAL_MESH) + + accept(MItems.TRITANIUM_BARS) + + colored(MItems.TRITANIUM_DOOR) + colored(MItems.TRITANIUM_TRAPDOOR) + accept(MRegistry.TRITANIUM_PRESSURE_PLATE.items.values) + + for (i in 0 until MItems.TRITANIUM_ANVIL.size) + accept(MItems.TRITANIUM_ANVIL[i]) + + colored(MRegistry.CARGO_CRATES.items) + + colored(MItems.CARGO_CRATE_MINECARTS) + + all(MRegistry.DECORATIVE_CRATE.allItems) + + for (color in colorOrder) { + accept(MRegistry.TRITANIUM_BLOCK.allItems[color]!!) + accept(MRegistry.TRITANIUM_STAIRS.allItems[color]!!) + accept(MRegistry.TRITANIUM_SLAB.allItems[color]!!) + accept(MRegistry.TRITANIUM_WALL.allItems[color]!!) + } + + all(MRegistry.INDUSTRIAL_GLASS.allItems) + all(MRegistry.INDUSTRIAL_GLASS_PANE.allItems) + + colored(MRegistry.UNREFINED_FLOOR_TILES.items) + colored(MRegistry.FLOOR_TILES.items) + colored(MRegistry.FLOOR_TILES_STAIRS.items) + colored(MRegistry.FLOOR_TILES_SLAB.items) + + all(MRegistry.VENT.allItems) + all(MRegistry.VENT_ALTERNATIVE.allItems) + + accept(MRegistry.TRITANIUM_STRIPED_BLOCK.flatItems) + accept(MRegistry.TRITANIUM_STRIPED_STAIRS.flatItems) + accept(MRegistry.TRITANIUM_STRIPED_SLAB.flatItems) + accept(MRegistry.TRITANIUM_STRIPED_WALL.flatItems) + } +} + object MCreativeTabs { var MAIN by WriteOnce() private set @@ -23,7 +266,7 @@ object MCreativeTabs { it.icon { ItemStack(BATTERY_CREATIVE, 1) } it.title(TranslatableComponent("itemGroup.otm")) - it.displayItems { features, consumer, flag -> + it.displayItems { _, consumer -> addMainCreativeTabItems(consumer) } } @@ -32,7 +275,7 @@ object MCreativeTabs { it.icon { ItemStack(MRegistry.VENT.item, 1) } it.title(TranslatableComponent("itemGroup.otm_decorative")) - it.displayItems { features, consumer, flag -> + it.displayItems { _, consumer -> addDecorativeTabItems(consumer) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MDamageTypes.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MDamageTypes.kt new file mode 100644 index 000000000..f4f3b8e8d --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MDamageTypes.kt @@ -0,0 +1,23 @@ +package ru.dbotthepony.mc.otm.registry + +import net.minecraft.core.registries.Registries +import net.minecraft.resources.ResourceKey +import net.minecraft.resources.ResourceLocation +import net.minecraft.world.damagesource.DamageType +import ru.dbotthepony.mc.otm.OverdriveThatMatters + +object MDamageTypes { + private fun register(name: String): ResourceKey = ResourceKey.create(Registries.DAMAGE_TYPE, ResourceLocation(OverdriveThatMatters.MOD_ID, name)) + + val BECOME_ANDROID = register("become_android") + val BECOME_HUMANE = register("become_humane") + val EVENT_HORIZON = register("event_horizon") + val HAWKING_RADIATION = register("hawking_radiation") + val EXOPACK_PROBE = register("exopack_probe") + val EMP = register("emp") + val SHOCKWAVE = register("shockwave") + val PLASMA = register("plasma") + val COSMIC_RAYS = register("cosmic_rays") + val EXPLOSIVE_HAMMER = register("explosive_hammer") + val HAMMER_NAIL = register("hammer_nail") +} 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 218a1fba1..e9a81c914 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -218,15 +218,15 @@ object MItems { ::TRITANIUM_SHIELD, ) - val TRITANIUM_HELMET: TritaniumArmorItem by registry.register(MNames.TRITANIUM_HELMET) { TritaniumArmorItem(EquipmentSlot.HEAD) } - val TRITANIUM_CHESTPLATE: TritaniumArmorItem by registry.register(MNames.TRITANIUM_CHESTPLATE) { TritaniumArmorItem(EquipmentSlot.CHEST) } - val TRITANIUM_PANTS: TritaniumArmorItem by registry.register(MNames.TRITANIUM_PANTS) { TritaniumArmorItem(EquipmentSlot.LEGS) } - val TRITANIUM_BOOTS: TritaniumArmorItem by registry.register(MNames.TRITANIUM_BOOTS) { TritaniumArmorItem(EquipmentSlot.FEET) } + val TRITANIUM_HELMET: TritaniumArmorItem by registry.register(MNames.TRITANIUM_HELMET) { TritaniumArmorItem(ArmorItem.Type.HELMET) } + val TRITANIUM_CHESTPLATE: TritaniumArmorItem by registry.register(MNames.TRITANIUM_CHESTPLATE) { TritaniumArmorItem(ArmorItem.Type.CHESTPLATE) } + val TRITANIUM_PANTS: TritaniumArmorItem by registry.register(MNames.TRITANIUM_PANTS) { TritaniumArmorItem(ArmorItem.Type.LEGGINGS) } + val TRITANIUM_BOOTS: TritaniumArmorItem by registry.register(MNames.TRITANIUM_BOOTS) { TritaniumArmorItem(ArmorItem.Type.BOOTS) } - val SIMPLE_TRITANIUM_HELMET: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_HELMET) { SimpleTritaniumArmorItem(EquipmentSlot.HEAD) } - val SIMPLE_TRITANIUM_CHESTPLATE: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_CHESTPLATE) { SimpleTritaniumArmorItem(EquipmentSlot.CHEST) } - val SIMPLE_TRITANIUM_PANTS: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_PANTS) { SimpleTritaniumArmorItem(EquipmentSlot.LEGS) } - val SIMPLE_TRITANIUM_BOOTS: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_BOOTS) { SimpleTritaniumArmorItem(EquipmentSlot.FEET) } + val SIMPLE_TRITANIUM_HELMET: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_HELMET) { SimpleTritaniumArmorItem(ArmorItem.Type.HELMET) } + val SIMPLE_TRITANIUM_CHESTPLATE: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_CHESTPLATE) { SimpleTritaniumArmorItem(ArmorItem.Type.CHESTPLATE) } + val SIMPLE_TRITANIUM_PANTS: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_PANTS) { SimpleTritaniumArmorItem(ArmorItem.Type.LEGGINGS) } + val SIMPLE_TRITANIUM_BOOTS: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_BOOTS) { SimpleTritaniumArmorItem(ArmorItem.Type.BOOTS) } val TRITANIUM_ARMOR = SupplierList( ::TRITANIUM_HELMET, 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 a5ab542cd..adc1016b4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt @@ -1,6 +1,7 @@ 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 @@ -67,35 +68,35 @@ import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu object MMenus { private val registry = DeferredRegister.create(ForgeRegistries.MENU_TYPES, OverdriveThatMatters.MOD_ID) - val ANDROID_STATION: MenuType<*> by registry.register(MNames.ANDROID_STATION) { MenuType(::AndroidStationMenu) } - val BATTERY_BANK: MenuType<*> by registry.register(MNames.BATTERY_BANK) { MenuType(::BatteryBankMenu) } - val MATTER_DECOMPOSER: MenuType<*> by registry.register(MNames.MATTER_DECOMPOSER) { MenuType(::MatterDecomposerMenu) } - val MATTER_CAPACITOR_BANK: MenuType<*> by registry.register(MNames.MATTER_CAPACITOR_BANK) { MenuType(::MatterCapacitorBankMenu) } - val PATTERN_STORAGE: MenuType<*> by registry.register(MNames.PATTERN_STORAGE) { MenuType(::PatternStorageMenu) } - val MATTER_SCANNER: MenuType<*> by registry.register(MNames.MATTER_SCANNER) { MenuType(::MatterScannerMenu) } - val MATTER_PANEL: MenuType<*> by registry.register(MNames.MATTER_PANEL) { MenuType(::MatterPanelMenu) } - val MATTER_REPLICATOR: MenuType<*> by registry.register(MNames.MATTER_REPLICATOR) { MenuType(::MatterReplicatorMenu) } - val MATTER_BOTTLER: MenuType<*> by registry.register(MNames.MATTER_BOTTLER) { MenuType(::MatterBottlerMenu) } - val DRIVE_VIEWER: MenuType<*> by registry.register(MNames.DRIVE_VIEWER) { MenuType(::DriveViewerMenu) } - val CARGO_CRATE: MenuType<*> by registry.register(MNames.CARGO_CRATE) { MenuType(::CargoCrateMenu) } - val MINECART_CARGO_CRATE: MenuType<*> by registry.register(MNames.MINECART_CARGO_CRATE) { MenuType(::MinecartCargoCrateMenu) } - val DRIVE_RACK: MenuType<*> by registry.register(MNames.DRIVE_RACK) { MenuType(::DriveRackMenu) } - val ITEM_MONITOR: MenuType<*> by registry.register(MNames.ITEM_MONITOR) { MenuType(::ItemMonitorMenu) } - val ENERGY_COUNTER: MenuType<*> by registry.register(MNames.ENERGY_COUNTER) { MenuType(::EnergyCounterMenu) } - val CHEMICAL_GENERATOR: MenuType<*> by registry.register(MNames.CHEMICAL_GENERATOR) { MenuType(::ChemicalGeneratorMenu) } - val PLATE_PRESS: MenuType<*> by registry.register(MNames.PLATE_PRESS) { MenuType(::PlatePressMenu) } - val MATTER_RECYCLER: MenuType<*> by registry.register(MNames.MATTER_RECYCLER) { MenuType(::MatterRecyclerMenu) } - val ENERGY_SERVO: MenuType<*> by registry.register(MNames.ENERGY_SERVO) { MenuType(::EnergyServoMenu) } - val HOLO_SIGN: MenuType by registry.register(MNames.HOLO_SIGN) { MenuType(::HoloSignMenu) } - val COBBLESTONE_GENERATOR: MenuType by registry.register(MNames.COBBLESTONE_GENERATOR) { MenuType(::CobblerMenu) } - val ESSENCE_STORAGE: MenuType by registry.register(MNames.ESSENCE_STORAGE) { MenuType(::EssenceStorageMenu) } - val ITEM_REPAIER: MenuType by registry.register(MNames.MATTER_RECONSTRUCTOR) { MenuType(::MatterReconstructorMenu) } - val FLUID_TANK: MenuType by registry.register(MNames.FLUID_TANK) { MenuType(::FluidTankMenu) } + val ANDROID_STATION: MenuType by registry.register(MNames.ANDROID_STATION) { MenuType(::AndroidStationMenu, FeatureFlags.VANILLA_SET) } + val BATTERY_BANK: MenuType by registry.register(MNames.BATTERY_BANK) { MenuType(::BatteryBankMenu, FeatureFlags.VANILLA_SET) } + val MATTER_DECOMPOSER: MenuType by registry.register(MNames.MATTER_DECOMPOSER) { MenuType(::MatterDecomposerMenu, FeatureFlags.VANILLA_SET) } + val MATTER_CAPACITOR_BANK: MenuType by registry.register(MNames.MATTER_CAPACITOR_BANK) { MenuType(::MatterCapacitorBankMenu, FeatureFlags.VANILLA_SET) } + val PATTERN_STORAGE: MenuType by registry.register(MNames.PATTERN_STORAGE) { MenuType(::PatternStorageMenu, FeatureFlags.VANILLA_SET) } + val MATTER_SCANNER: MenuType by registry.register(MNames.MATTER_SCANNER) { MenuType(::MatterScannerMenu, FeatureFlags.VANILLA_SET) } + val MATTER_PANEL: MenuType by registry.register(MNames.MATTER_PANEL) { MenuType(::MatterPanelMenu, FeatureFlags.VANILLA_SET) } + val MATTER_REPLICATOR: MenuType by registry.register(MNames.MATTER_REPLICATOR) { MenuType(::MatterReplicatorMenu, FeatureFlags.VANILLA_SET) } + val MATTER_BOTTLER: MenuType by registry.register(MNames.MATTER_BOTTLER) { MenuType(::MatterBottlerMenu, FeatureFlags.VANILLA_SET) } + val DRIVE_VIEWER: MenuType by registry.register(MNames.DRIVE_VIEWER) { MenuType(::DriveViewerMenu, FeatureFlags.VANILLA_SET) } + val CARGO_CRATE: MenuType by registry.register(MNames.CARGO_CRATE) { MenuType(::CargoCrateMenu, FeatureFlags.VANILLA_SET) } + val MINECART_CARGO_CRATE: MenuType by registry.register(MNames.MINECART_CARGO_CRATE) { MenuType(::MinecartCargoCrateMenu, FeatureFlags.VANILLA_SET) } + val DRIVE_RACK: MenuType by registry.register(MNames.DRIVE_RACK) { MenuType(::DriveRackMenu, FeatureFlags.VANILLA_SET) } + val ITEM_MONITOR: MenuType by registry.register(MNames.ITEM_MONITOR) { MenuType(::ItemMonitorMenu, FeatureFlags.VANILLA_SET) } + val ENERGY_COUNTER: MenuType by registry.register(MNames.ENERGY_COUNTER) { MenuType(::EnergyCounterMenu, FeatureFlags.VANILLA_SET) } + val CHEMICAL_GENERATOR: MenuType by registry.register(MNames.CHEMICAL_GENERATOR) { MenuType(::ChemicalGeneratorMenu, FeatureFlags.VANILLA_SET) } + val PLATE_PRESS: MenuType by registry.register(MNames.PLATE_PRESS) { MenuType(::PlatePressMenu, FeatureFlags.VANILLA_SET) } + val MATTER_RECYCLER: MenuType by registry.register(MNames.MATTER_RECYCLER) { MenuType(::MatterRecyclerMenu, FeatureFlags.VANILLA_SET) } + val ENERGY_SERVO: MenuType by registry.register(MNames.ENERGY_SERVO) { MenuType(::EnergyServoMenu, FeatureFlags.VANILLA_SET) } + val HOLO_SIGN: MenuType by registry.register(MNames.HOLO_SIGN) { MenuType(::HoloSignMenu, FeatureFlags.VANILLA_SET) } + val COBBLESTONE_GENERATOR: MenuType by registry.register(MNames.COBBLESTONE_GENERATOR) { MenuType(::CobblerMenu, FeatureFlags.VANILLA_SET) } + val ESSENCE_STORAGE: MenuType by registry.register(MNames.ESSENCE_STORAGE) { MenuType(::EssenceStorageMenu, FeatureFlags.VANILLA_SET) } + val ITEM_REPAIER: MenuType by registry.register(MNames.MATTER_RECONSTRUCTOR) { MenuType(::MatterReconstructorMenu, FeatureFlags.VANILLA_SET) } + val FLUID_TANK: MenuType by registry.register(MNames.FLUID_TANK) { MenuType(::FluidTankMenu, FeatureFlags.VANILLA_SET) } - val STORAGE_BUS: MenuType<*> by registry.register(MNames.STORAGE_BUS) { MenuType(::StorageBusMenu) } - val STORAGE_EXPORTER: MenuType<*> by registry.register(MNames.STORAGE_EXPORTER) { MenuType(::StorageExporterMenu) } - val STORAGE_IMPORTER: MenuType<*> by registry.register(MNames.STORAGE_IMPORTER) { MenuType(::StorageImporterMenu) } - val STORAGE_POWER_SUPPLIER: MenuType<*> by registry.register(MNames.STORAGE_POWER_SUPPLIER) { MenuType(::StoragePowerSupplierMenu) } + val STORAGE_BUS: MenuType by registry.register(MNames.STORAGE_BUS) { MenuType(::StorageBusMenu, FeatureFlags.VANILLA_SET) } + val STORAGE_EXPORTER: MenuType by registry.register(MNames.STORAGE_EXPORTER) { MenuType(::StorageExporterMenu, FeatureFlags.VANILLA_SET) } + val STORAGE_IMPORTER: MenuType by registry.register(MNames.STORAGE_IMPORTER) { MenuType(::StorageImporterMenu, FeatureFlags.VANILLA_SET) } + val STORAGE_POWER_SUPPLIER: MenuType by registry.register(MNames.STORAGE_POWER_SUPPLIER) { MenuType(::StoragePowerSupplierMenu, FeatureFlags.VANILLA_SET) } internal fun register(bus: IEventBus) { registry.register(bus) @@ -105,29 +106,29 @@ object MMenus { @Suppress("unchecked_cast") private fun registerClient(event: FMLClientSetupEvent) { event.enqueueWork { - MenuScreens.register(ANDROID_STATION as MenuType, ::AndroidStationScreen) - MenuScreens.register(BATTERY_BANK as MenuType, ::BatteryBankScreen) - MenuScreens.register(MATTER_DECOMPOSER as MenuType, ::MatterDecomposerScreen) - MenuScreens.register(MATTER_CAPACITOR_BANK as MenuType, ::MatterCapacitorBankScreen) - MenuScreens.register(PATTERN_STORAGE as MenuType, ::PatternStorageScreen) - MenuScreens.register(MATTER_SCANNER as MenuType, ::MatterScannerScreen) - MenuScreens.register(MATTER_PANEL as MenuType, ::MatterPanelScreen) - MenuScreens.register(MATTER_REPLICATOR as MenuType, ::MatterReplicatorScreen) - MenuScreens.register(MATTER_BOTTLER as MenuType, ::MatterBottlerScreen) - MenuScreens.register(DRIVE_VIEWER as MenuType, ::DriveViewerScreen) - MenuScreens.register(CARGO_CRATE as MenuType, ::CargoCrateScreen) - MenuScreens.register(MINECART_CARGO_CRATE as MenuType, ::MinecartCargoCrateScreen) - MenuScreens.register(DRIVE_RACK as MenuType, ::DriveRackScreen) - MenuScreens.register(ITEM_MONITOR as MenuType, ::ItemMonitorScreen) - MenuScreens.register(ENERGY_COUNTER as MenuType, ::EnergyCounterScreen) - MenuScreens.register(CHEMICAL_GENERATOR as MenuType, ::ChemicalGeneratorScreen) - MenuScreens.register(PLATE_PRESS as MenuType, ::PlatePressScreen) - MenuScreens.register(MATTER_RECYCLER as MenuType, ::MatterRecyclerScreen) - MenuScreens.register(STORAGE_BUS as MenuType, ::StorageBusScreen) - MenuScreens.register(STORAGE_EXPORTER as MenuType, ::StorageExporterScreen) - MenuScreens.register(STORAGE_IMPORTER as MenuType, ::StorageImporterScreen) - MenuScreens.register(STORAGE_POWER_SUPPLIER as MenuType, ::StoragePowerSupplierScreen) - MenuScreens.register(ENERGY_SERVO as MenuType, ::EnergyServoScreen) + MenuScreens.register(ANDROID_STATION, ::AndroidStationScreen) + MenuScreens.register(BATTERY_BANK, ::BatteryBankScreen) + MenuScreens.register(MATTER_DECOMPOSER, ::MatterDecomposerScreen) + MenuScreens.register(MATTER_CAPACITOR_BANK, ::MatterCapacitorBankScreen) + MenuScreens.register(PATTERN_STORAGE, ::PatternStorageScreen) + MenuScreens.register(MATTER_SCANNER, ::MatterScannerScreen) + MenuScreens.register(MATTER_PANEL, ::MatterPanelScreen) + MenuScreens.register(MATTER_REPLICATOR, ::MatterReplicatorScreen) + MenuScreens.register(MATTER_BOTTLER, ::MatterBottlerScreen) + MenuScreens.register(DRIVE_VIEWER, ::DriveViewerScreen) + MenuScreens.register(CARGO_CRATE, ::CargoCrateScreen) + MenuScreens.register(MINECART_CARGO_CRATE, ::MinecartCargoCrateScreen) + MenuScreens.register(DRIVE_RACK, ::DriveRackScreen) + MenuScreens.register(ITEM_MONITOR, ::ItemMonitorScreen) + MenuScreens.register(ENERGY_COUNTER, ::EnergyCounterScreen) + MenuScreens.register(CHEMICAL_GENERATOR, ::ChemicalGeneratorScreen) + MenuScreens.register(PLATE_PRESS, ::PlatePressScreen) + MenuScreens.register(MATTER_RECYCLER, ::MatterRecyclerScreen) + MenuScreens.register(STORAGE_BUS, ::StorageBusScreen) + MenuScreens.register(STORAGE_EXPORTER, ::StorageExporterScreen) + MenuScreens.register(STORAGE_IMPORTER, ::StorageImporterScreen) + MenuScreens.register(STORAGE_POWER_SUPPLIER, ::StoragePowerSupplierScreen) + MenuScreens.register(ENERGY_SERVO, ::EnergyServoScreen) MenuScreens.register(HOLO_SIGN, ::HoloSignScreen) MenuScreens.register(COBBLESTONE_GENERATOR, ::CobblerScreen) MenuScreens.register(ESSENCE_STORAGE, ::EssenceStorageScreen) 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 67addb73f..906d056d7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -4,7 +4,6 @@ import net.minecraft.advancements.CriteriaTriggers import net.minecraft.client.renderer.item.ItemProperties import net.minecraft.core.BlockPos import net.minecraft.resources.ResourceLocation -import net.minecraft.world.damagesource.DamageSource import net.minecraft.world.entity.EntityType import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.block.* @@ -30,7 +29,6 @@ import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.item.weapon.EnergySwordItem import ru.dbotthepony.mc.otm.registry.objects.ColoredDecorativeBlock -import ru.dbotthepony.mc.otm.registry.objects.CrateProperties import ru.dbotthepony.mc.otm.registry.objects.DecorativeBlock import ru.dbotthepony.mc.otm.registry.objects.StripedColoredDecorativeBlock import ru.dbotthepony.mc.otm.triggers.AndroidBatteryTrigger @@ -169,47 +167,6 @@ object MRegistry { return@DecorativeBlock IronBarsBlock(properties) } - val CRATE_RED = CrateProperties(MaterialColor.COLOR_RED, "crate_red") - val CRATE_BLUE = CrateProperties(MaterialColor.COLOR_BLUE, "crate_blue") - val CRATE_YELLOW = CrateProperties(MaterialColor.COLOR_YELLOW, "crate_yellow") - val CRATE_GREEN = CrateProperties(MaterialColor.COLOR_GREEN, "crate_green") - val CRATE_BLACK = CrateProperties(MaterialColor.COLOR_BLACK, "crate_black") - val CRATE_PINK = CrateProperties(MaterialColor.COLOR_PINK, "crate_pink") - val CRATE_PURPLE = CrateProperties(MaterialColor.COLOR_PURPLE, "crate_purple") - - val CRATE_LIST = listOf( - CRATE_RED, - CRATE_BLUE, - CRATE_YELLOW, - CRATE_GREEN, - CRATE_BLACK, - CRATE_PINK, - CRATE_PURPLE, - ) - - const val DAMAGE_BECOME_ANDROID_ID = "otm_become_android" - const val DAMAGE_BECOME_HUMANE_ID = "otm_become_humane" - const val DAMAGE_EVENT_HORIZON_ID = "otm_event_horizon" - const val DAMAGE_HAWKING_RADIATION_ID = "otm_hawking_radiation" - const val DAMAGE_EXOPACK_PROBE_ID = "otm_exopack_probe" - const val DAMAGE_EMP_NAME = "otm_emp" - const val DAMAGE_SHOCKWAVE_NAME = "otm_shockwave" - const val DAMAGE_PLASMA_NAME = "otm_plasma" - const val DAMAGE_COSMIC_RAYS_NAME = "otm_cosmic_rays" - const val DAMAGE_EXPLOSIVE_HAMMER_NAME = "otm_explosive_hammer" - const val DAMAGE_HAMMER_NAIL_NAME = "otm_hammer_nail" - - val DAMAGE_EXOPACK_PROBE = ImmutableDamageSource(DamageSource(DAMAGE_EXOPACK_PROBE_ID).bypassArmor().bypassMagic()) - - val DAMAGE_BECOME_ANDROID = ImmutableDamageSource(DamageSource(DAMAGE_BECOME_ANDROID_ID).bypassArmor().bypassInvul().bypassMagic()) - val DAMAGE_BECOME_HUMANE = ImmutableDamageSource(DamageSource(DAMAGE_BECOME_HUMANE_ID).bypassArmor().bypassInvul().bypassMagic()) - val DAMAGE_EVENT_HORIZON = ImmutableDamageSource(DamageSource(DAMAGE_EVENT_HORIZON_ID).bypassMagic().bypassArmor()) - val DAMAGE_HAWKING_RADIATION = ImmutableDamageSource(DamageSource(DAMAGE_HAWKING_RADIATION_ID)) - val DAMAGE_COSMIC_RAYS = ImmutableDamageSource(DamageSource(DAMAGE_COSMIC_RAYS_NAME).bypassArmor().bypassMagic()) - val DAMAGE_EXPLOSIVE_HAMMER = ImmutableDamageSource(DamageSource(DAMAGE_EXPLOSIVE_HAMMER_NAME)) - - val DAMAGE_EMP: DamageSource = ImmutableDamageSource(EMPDamageSource()) - val TRITANIUM_STRIPED_BLOCK = StripedColoredDecorativeBlock(MNames.TRITANIUM_STRIPED_BLOCK, { colorA, _ -> Block(BlockBehaviour.Properties.of(Material.METAL, colorA.materialColor) .sound(SoundType.BASALT) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MatteryDamageSource.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MatteryDamageSource.kt new file mode 100644 index 000000000..697463316 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MatteryDamageSource.kt @@ -0,0 +1,35 @@ +package ru.dbotthepony.mc.otm.registry + +import net.minecraft.core.Holder +import net.minecraft.network.chat.Component +import net.minecraft.world.damagesource.DamageSource +import net.minecraft.world.damagesource.DamageType +import net.minecraft.world.entity.Entity +import net.minecraft.world.entity.LivingEntity +import net.minecraft.world.item.ItemStack +import net.minecraft.world.phys.Vec3 +import ru.dbotthepony.mc.otm.core.TranslatableComponent + +class MatteryDamageSource( + type: Holder, + entity: Entity? = null, + inflictor: ItemStack? = null, + entityInflictor: Entity? = null, + pos: Vec3? = null +) : DamageSource(type, entity, entityInflictor, pos) { + val inflictor = inflictor?.copy() + + override fun getLocalizedDeathMessage(victim: LivingEntity): Component { + val itemStack = inflictor ?: (entity as? LivingEntity)?.mainHandItem ?: ItemStack.EMPTY + + if (!itemStack.isEmpty && itemStack.hasCustomHoverName()) { + return TranslatableComponent("death.attack.$msgId.player.item", victim.displayName, entity!!.displayName, itemStack.displayName) + } + + if (entity != null) { + return TranslatableComponent("death.attack.$msgId.player", victim.displayName, entity!!.displayName) + } + + return TranslatableComponent("death.attack.$msgId", victim.displayName) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/CrateProperties.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/CrateProperties.kt deleted file mode 100644 index f909fb76e..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/objects/CrateProperties.kt +++ /dev/null @@ -1,18 +0,0 @@ -package ru.dbotthepony.mc.otm.registry.objects - -import net.minecraft.world.level.block.Block -import net.minecraft.world.level.block.SoundType -import net.minecraft.world.level.block.state.BlockBehaviour -import net.minecraft.world.level.material.Material -import net.minecraft.world.level.material.MaterialColor - -class CrateProperties(val color: MaterialColor, val name: String) { - fun makeBlock(): Block { - return Block( - BlockBehaviour.Properties.of(Material.METAL, color) - .sound(SoundType.METAL) - .requiresCorrectToolForDrops() - .strength(5.0F, 6.0F) - ) - } -} \ No newline at end of file diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 4c3be4b7f..f2003389b 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -46,7 +46,7 @@ public net.minecraft.server.level.ServerPlayer f_143380_ # containerListener protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_97762_(I)V # checkHotbarMouseClicked protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_97818_()V # recalculateQuickCraftRemaining protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_97744_(DD)Lnet/minecraft/world/inventory/Slot; # findSlot -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_97782_(Lnet/minecraft/world/item/ItemStack;IILjava/lang/String;)V # renderFloatingItem +protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_274323_(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/world/item/ItemStack;IILjava/lang/String;)V # renderFloatingItem protected net.minecraft.client.resources.TextureAtlasHolder f_118884_ # textureAtlas From 8661d95bdb8dde074c784fcb901094c413784288 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Wed, 26 Apr 2023 06:40:17 +0300 Subject: [PATCH 0524/1199] =?UTF-8?q?=D0=BF=D0=BE=D0=BC=D0=BE=D0=B3=D0=B8?= =?UTF-8?q?=D1=82=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/dbotthepony/mc/otm/datagen/DamageTypes.kt | 9 +-------- .../kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt | 13 +++++++++++-- .../kotlin/ru/dbotthepony/mc/otm/datagen/OreGen.kt | 12 ++---------- .../dbotthepony/mc/otm/datagen/tags/TagsProvider.kt | 8 ++++---- 4 files changed, 18 insertions(+), 24 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DamageTypes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DamageTypes.kt index 8411480d5..40bcca1c9 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DamageTypes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DamageTypes.kt @@ -11,7 +11,7 @@ import net.minecraftforge.data.event.GatherDataEvent import ru.dbotthepony.mc.otm.datagen.tags.TagsProvider import ru.dbotthepony.mc.otm.registry.MDamageTypes -private fun damageTypes(context: BootstapContext) { +fun registerDamageTypes(context: BootstapContext) { context.register(MDamageTypes.EXOPACK_PROBE, DamageType("otm_exopack_probe", DamageScaling.NEVER, 4.0f)) context.register(MDamageTypes.BECOME_ANDROID, DamageType("otm_become_android", DamageScaling.NEVER, 0f)) context.register(MDamageTypes.BECOME_HUMANE, DamageType("otm_become_humane", DamageScaling.NEVER, 0f)) @@ -25,13 +25,6 @@ private fun damageTypes(context: BootstapContext) { context.register(MDamageTypes.HAMMER_NAIL, DamageType("otm_hammer_nail", DamageScaling.NEVER, 0.1f)) } -fun registerDamageTypes(event: GatherDataEvent) { - val set = RegistrySetBuilder() - .add(Registries.DAMAGE_TYPE, ::damageTypes) - - event.generator.addProvider(event.includeServer(), DatapackBuiltinEntriesProvider(event.generator.packOutput, event.lookupProvider, set, setOf(DataGen.MOD_ID))) -} - fun registerDamageTypeTags(provider: TagsProvider.Delegate) { val ignoreArmor = provider.Appender(DamageTypeTags.BYPASSES_ARMOR) val ignoreMagic = provider.Appender(DamageTypeTags.BYPASSES_ENCHANTMENTS) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt index 0a50c2278..0be49080a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -1,5 +1,7 @@ package ru.dbotthepony.mc.otm.datagen +import net.minecraft.core.RegistrySetBuilder +import net.minecraft.core.registries.Registries import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.DyeColor import net.minecraft.world.level.block.Block @@ -13,6 +15,7 @@ import net.minecraft.world.level.block.state.properties.DoorHingeSide import net.minecraft.world.level.block.state.properties.DoubleBlockHalf import net.minecraft.world.level.block.state.properties.Half import net.minecraftforge.client.model.generators.ModelFile +import net.minecraftforge.common.data.DatapackBuiltinEntriesProvider import net.minecraftforge.common.data.ForgeAdvancementProvider import net.minecraftforge.eventbus.api.SubscribeEvent import net.minecraftforge.fml.common.Mod @@ -524,8 +527,14 @@ object DataGen { event.generator.addProvider(event.includeServer(), advancementProvider) event.generator.addProvider(event.includeServer(), matterData) - registerOreGen(event) - registerDamageTypes(event) + val registrySetBuilder = RegistrySetBuilder() + val set = registrySetBuilder + .add(Registries.DAMAGE_TYPE, ::registerDamageTypes) + .add(Registries.CONFIGURED_FEATURE, ::registerConfiguredFeatures) + .add(Registries.PLACED_FEATURE, ::registerPlacedFeatures) + + event.generator.addProvider(event.includeServer(), DatapackBuiltinEntriesProvider(event.generator.packOutput, event.lookupProvider, set, setOf(MOD_ID))) + registerDamageTypeTags(tagsProvider.damageTypes) AddEnglishLanguage(languageProvider) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/OreGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/OreGen.kt index a52d3dbb6..2e7de16ef 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/OreGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/OreGen.kt @@ -20,7 +20,7 @@ import ru.dbotthepony.mc.otm.registry.MBlocks private val oreKey by lazy { ResourceKey.create(Registries.CONFIGURED_FEATURE, modLocation("tritanium_ore")) } -private fun configuredFeatures(context: BootstapContext>) { +fun registerConfiguredFeatures(context: BootstapContext>) { val stone = TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES) val deepslate = TagMatchTest(BlockTags.DEEPSLATE_ORE_REPLACEABLES) @@ -32,7 +32,7 @@ private fun configuredFeatures(context: BootstapContext> context.register(oreKey, ConfiguredFeature(Feature.ORE, OreConfiguration(target, 9))) } -private fun placedFeatures(context: BootstapContext) { +fun registerPlacedFeatures(context: BootstapContext) { fun location(name: String) = ResourceKey.create(Registries.PLACED_FEATURE, modLocation(name)) val configured = context.lookup(Registries.CONFIGURED_FEATURE) @@ -56,11 +56,3 @@ private fun placedFeatures(context: BootstapContext) { ) )) } - -fun registerOreGen(event: GatherDataEvent) { - val set = RegistrySetBuilder() - .add(Registries.CONFIGURED_FEATURE, ::configuredFeatures) - .add(Registries.PLACED_FEATURE, ::placedFeatures) - - event.generator.addProvider(event.includeServer(), DatapackBuiltinEntriesProvider(event.generator.packOutput, event.lookupProvider, set, setOf(DataGen.MOD_ID))) -} diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt index 370522b10..a6f5ad5f6 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt @@ -59,20 +59,20 @@ class TagsProvider(private val event: GatherDataEvent) { } fun add(value: ResourceKey): Appender { - require(value.registry() == registryKey) { "Invalid registry in provided ResourceKey: ${value.registry()} (this tag appender is for $registryKey)" } + require(value.registry() == registryKey.location()) { "Invalid registry in provided ResourceKey: ${value.registry()} (this tag appender is for $registryKey)" } if (!rigidLocations.add(value)) { - throw IllegalStateException("Tag $tag of registry $registryKey already contains $value") + throw IllegalStateException("Tag $tag of registry ${registryKey.location()} already contains $value") } return this } fun add(value: TagKey): Appender { - require(value.registry() == registryKey) { "Invalid registry in provided ResourceKey: ${value.registry()} (this tag appender is for $registryKey)" } + require(value.registry() == registryKey.location()) { "Invalid registry in provided ResourceKey: ${value.registry()} (this tag appender is for $registryKey)" } if (!tagsInTags.add(value)) { - throw IllegalStateException("Tag $tag of registry $registryKey already contains $value") + throw IllegalStateException("Tag $tag of registry ${registryKey.location()} already contains $value") } return this From ee2bb3d24e43368346cbae4b3f52d588bc892cba Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Wed, 26 Apr 2023 06:46:25 +0300 Subject: [PATCH 0525/1199] =?UTF-8?q?=D0=BB=D0=B0=D0=B4=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 077846911..54188a8b6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -188,7 +188,7 @@ dependencies { compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-common-api:${jei_version}")) compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge-api:${jei_version}")) - runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}")) +// runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}")) runtimeOnly(fg.deobf("curse.maven:jade-324717:${jade_id}")) runtimeOnly(fg.deobf("curse.maven:configured-457570:${configured_id}")) From 37a91c525ec139aefedf2cdec94a0dd54ecb2f45 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 26 Apr 2023 16:54:46 +0700 Subject: [PATCH 0526/1199] Fix some issues regarding datagen --- .../ru/dbotthepony/mc/otm/datagen/DataGen.kt | 3 +- .../mc/otm/datagen/tags/TagsProvider.kt | 32 +++++++------------ 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt index 0be49080a..81e3b1bdd 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -528,12 +528,11 @@ object DataGen { event.generator.addProvider(event.includeServer(), matterData) val registrySetBuilder = RegistrySetBuilder() - val set = registrySetBuilder .add(Registries.DAMAGE_TYPE, ::registerDamageTypes) .add(Registries.CONFIGURED_FEATURE, ::registerConfiguredFeatures) .add(Registries.PLACED_FEATURE, ::registerPlacedFeatures) - event.generator.addProvider(event.includeServer(), DatapackBuiltinEntriesProvider(event.generator.packOutput, event.lookupProvider, set, setOf(MOD_ID))) + event.generator.addProvider(event.includeServer(), DatapackBuiltinEntriesProvider(event.generator.packOutput, event.lookupProvider, registrySetBuilder, setOf(MOD_ID))) registerDamageTypeTags(tagsProvider.damageTypes) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt index a6f5ad5f6..671566490 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt @@ -46,35 +46,29 @@ class TagsProvider(private val event: GatherDataEvent) { inner class Appender(val tag: TagKey) { constructor(tag: ResourceLocation) : this(TagKey.create(registryKey, tag)) + init { + require(tag.registry == registryKey) { "Trying to create appender for $tag inside registry $registryKey" } + } + private val locations by lazy { tags.computeIfAbsent(tag) { ObjectArraySet() } } private val rigidLocations by lazy { rigidTags.computeIfAbsent(tag) { ObjectArraySet() } } private val tagsInTags by lazy { tagInTag.computeIfAbsent(tag) { ObjectArraySet() } } fun add(value: ResourceLocation): Appender { - if (!locations.add(value)) { - throw IllegalStateException("Tag $tag of registry $registryKey already contains $value") - } - + check(locations.add(value)) { "Tag ${tag.location} of registry ${registryKey.location()} already contains $value" } return this } fun add(value: ResourceKey): Appender { - require(value.registry() == registryKey.location()) { "Invalid registry in provided ResourceKey: ${value.registry()} (this tag appender is for $registryKey)" } - - if (!rigidLocations.add(value)) { - throw IllegalStateException("Tag $tag of registry ${registryKey.location()} already contains $value") - } - - return this + require(value.registry() == registryKey.location()) { "Invalid registry in provided ResourceKey: ${value.registry()} (this tag appender is for ${registryKey.location()})" } + // check(rigidLocations.add(value)) { "Tag ${tag.location} of registry ${registryKey.location()} already contains $value" } + // return this + return add(value.location()) } fun add(value: TagKey): Appender { - require(value.registry() == registryKey.location()) { "Invalid registry in provided ResourceKey: ${value.registry()} (this tag appender is for $registryKey)" } - - if (!tagsInTags.add(value)) { - throw IllegalStateException("Tag $tag of registry ${registryKey.location()} already contains $value") - } - + require(value.registry() == registryKey) { "Invalid registry in provided ResourceKey: ${value.registry().location()} (this tag appender is for ${registryKey.location()})" } + check(tagsInTags.add(value)) { "Tag ${tag.location} of registry ${registryKey.location()} already contains $value" } return this } @@ -128,10 +122,6 @@ class TagsProvider(private val event: GatherDataEvent) { fun forge(path: String) = Appender(ResourceLocation("forge", path)) override fun addTags(provider: HolderLookup.Provider) { - if (tags.isEmpty()) { - return - } - for ((tag, values) in tags) { val appender = tag(tag) From 3e36725f9e7b11aa94e7d3ac1c82a0750cc142b3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 26 Apr 2023 17:29:37 +0700 Subject: [PATCH 0527/1199] Move explosive hammer config to appropriate place --- .../dbotthepony/mc/otm/config/ItemsConfig.kt | 72 ------------------- .../dbotthepony/mc/otm/config/ToolsConfig.kt | 72 +++++++++++++++++++ .../mc/otm/item/tool/ExplosiveHammerItem.kt | 25 +++---- 3 files changed, 85 insertions(+), 84 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt index 153753a22..02864211c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt @@ -98,76 +98,4 @@ object ItemsConfig : AbstractConfig("items") { val FLUID_CAPSULE_CAPACITY: Int by builder.defineInRange("FLUID_CAPSULE_CAPACITY", 1000, 1, Int.MAX_VALUE) val FLUID_TANK_CAPACITY: Int by builder.defineInRange("FLUID_TANK_CAPACITY", 32_000, 1, Int.MAX_VALUE) - - object ExplosiveHammer { - val MAX_TRAVEL: Double by builder - .comment("Max distance, in blocks, the nail can travel", "This also dictates potential max damage nail can deal (controlled by TRAVEL_DAMAGE_MULT)") - .comment("The nail penetrate through blocks and entities, losing power in process") - .comment("The nail can not travel into unloaded chunks and will stop immediately if it does so") - .comment("The nail travels its entire path instantaneously") - .defineInRange("MAX_TRAVEL", 48.0, 0.0, Double.MAX_VALUE) - - val TRAVEL_EXPLOSION_RESIST_MULT: Double by builder - .comment("Multiplier of explosion resistance of blocks on nail path") - .comment("If explosion resistance multiplied by this is bigger than nail current force (base of MAX_TRAVEL)") - .comment("then nail movement halts, otherwise nail force is reduced by explosion resistance multiplied by this") - .comment("and block is broken (if DAMAGE_BLOCKS is true, otherwise it only acts as stopping power)") - .comment("---") - .comment("Values over 1 will make blocks more resistant to be penetrated through (and broken)") - .comment("Values below 1 will make blocks less resistant to be penetrated though (and broken)") - .comment("Value of 0 means no matter how strong block resistance is, it will be broken by nail", "(this includes bedrock!!!)") - .comment("---") - .defineInRange("TRAVEL_EXPLOSION_RESIST_MULT", 1.75, 0.0, Double.MAX_VALUE) - - val TRAVEL_DAMAGE_MULT: Double by builder - .comment("Multiplier of current nail force (base of MAX_TRAVEL) for damage values") - .comment("That is, any being on path of nail will get damaged by nail power multiplied by this") - .defineInRange("TRAVEL_DAMAGE_MULT", 0.6, 0.0, Double.MAX_VALUE) - - val TRAVEL_MAX_HEALTH_MULT: Double by builder - .comment("Multiplier of being's max health in nail path subtracted from nail force when penetrating through") - .defineInRange("TRAVEL_MAX_HEALTH_MULT", 0.4, 0.0, Double.MAX_VALUE) - - val DAMAGE_BLOCKS: Boolean by builder - .comment("Should hammer (**not** explosion) damage blocks", "Blocks damaged this way will always be dropped") - .define("DAMAGE_BLOCKS", true) - - val EXPLOSION_DAMAGE_BLOCKS: Boolean by builder - .comment("Should hammer **explosion** damage blocks") - .define("EXPLOSION_DAMAGE_BLOCKS", false) - - val FLY_OFF_CHANCE: Double by builder - .comment("Chance that hammer will fly off hands of attacker upon impact") - .defineInRange("FLY_OFF_CHANCE", 0.6, 0.0, 1.0) - - val SELF_HARM_CHANCE: Double by builder - .comment("When hammer DOES NOT fly off hands, what is chance of it damaging the user?", "(this does not account for damage because of hitting things close)", "(idiot)") - .defineInRange("SELF_HARM_CHANCE", 0.4, 0.0, 1.0) - - val SELF_HARM_MIN_DAMAGE: Double by builder - .comment("When hammer DOES NOT fly off hands, what is minimal damage it deals to the user (in half of hearts)?") - .defineInRange("SELF_HARM_MIN_DAMAGE", 2.0, 0.0, Double.MAX_VALUE) - - val SELF_HARM_MAX_DAMAGE: Double by builder - .comment("When hammer DOES NOT fly off hands, what is maximal damage it deals to the user (in half of hearts)?") - .defineInRange("SELF_HARM_MAX_DAMAGE", 10.0, 0.0, Double.MAX_VALUE) - - val FLY_OFF_DAMAGE_CHANCE: Double by builder - .comment("When hammer flies off hands, what is chance of it damaging the user?") - .defineInRange("FLY_OFF_DAMAGE_CHANCE", 0.8, 0.0, 1.0) - - val FLY_OFF_MIN_DAMAGE: Double by builder - .comment("When hammer flies off hands, what is minimal damage it deals to the user (in half of hearts)?") - .defineInRange("FLY_OFF_MIN_DAMAGE", 4.0, 0.0, Double.MAX_VALUE) - - val FLY_OFF_MAX_DAMAGE: Double by builder - .comment("When hammer flies off hands, what is maximal damage it deals to the user (in half of hearts)?") - .defineInRange("FLY_OFF_MAX_DAMAGE", 25.0, 0.0, Double.MAX_VALUE) - } - - init { - builder.push("ExplosiveHammer") - ExplosiveHammer - builder.pop() - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ToolsConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ToolsConfig.kt index cc4e41e41..cf0f347a4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ToolsConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ToolsConfig.kt @@ -8,4 +8,76 @@ object ToolsConfig : AbstractConfig("tools") { init { EnergySwordItem.registerConfig(builder) } + + object ExplosiveHammer { + val MAX_TRAVEL: Double by builder + .comment("Max distance, in blocks, the nail can travel", "This also dictates potential max damage nail can deal (controlled by TRAVEL_DAMAGE_MULT)") + .comment("The nail penetrate through blocks and entities, losing power in process") + .comment("The nail can not travel into unloaded chunks and will stop immediately if it does so") + .comment("The nail travels its entire path instantaneously") + .defineInRange("MAX_TRAVEL", 48.0, 0.0, Double.MAX_VALUE) + + val TRAVEL_EXPLOSION_RESIST_MULT: Double by builder + .comment("Multiplier of explosion resistance of blocks on nail path") + .comment("If explosion resistance multiplied by this is bigger than nail current force (base of MAX_TRAVEL)") + .comment("then nail movement halts, otherwise nail force is reduced by explosion resistance multiplied by this") + .comment("and block is broken (if DAMAGE_BLOCKS is true, otherwise it only acts as stopping power)") + .comment("---") + .comment("Values over 1 will make blocks more resistant to be penetrated through (and broken)") + .comment("Values below 1 will make blocks less resistant to be penetrated though (and broken)") + .comment("Value of 0 means no matter how strong block resistance is, it will be broken by nail", "(this includes bedrock!!!)") + .comment("---") + .defineInRange("TRAVEL_EXPLOSION_RESIST_MULT", 1.75, 0.0, Double.MAX_VALUE) + + val TRAVEL_DAMAGE_MULT: Double by builder + .comment("Multiplier of current nail force (base of MAX_TRAVEL) for damage values") + .comment("That is, any being on path of nail will get damaged by nail power multiplied by this") + .defineInRange("TRAVEL_DAMAGE_MULT", 0.6, 0.0, Double.MAX_VALUE) + + val TRAVEL_MAX_HEALTH_MULT: Double by builder + .comment("Multiplier of being's max health in nail path subtracted from nail force when penetrating through") + .defineInRange("TRAVEL_MAX_HEALTH_MULT", 0.4, 0.0, Double.MAX_VALUE) + + val DAMAGE_BLOCKS: Boolean by builder + .comment("Should hammer (**not** explosion) damage blocks", "Blocks damaged this way will always be dropped") + .define("DAMAGE_BLOCKS", true) + + val EXPLOSION_DAMAGE_BLOCKS: Boolean by builder + .comment("Should hammer **explosion** damage blocks") + .define("EXPLOSION_DAMAGE_BLOCKS", false) + + val FLY_OFF_CHANCE: Double by builder + .comment("Chance that hammer will fly off hands of attacker upon impact") + .defineInRange("FLY_OFF_CHANCE", 0.6, 0.0, 1.0) + + val SELF_HARM_CHANCE: Double by builder + .comment("When hammer DOES NOT fly off hands, what is chance of it damaging the user?", "(this does not account for damage because of hitting things close)", "(idiot)") + .defineInRange("SELF_HARM_CHANCE", 0.4, 0.0, 1.0) + + val SELF_HARM_MIN_DAMAGE: Double by builder + .comment("When hammer DOES NOT fly off hands, what is minimal damage it deals to the user (in half of hearts)?") + .defineInRange("SELF_HARM_MIN_DAMAGE", 2.0, 0.0, Double.MAX_VALUE) + + val SELF_HARM_MAX_DAMAGE: Double by builder + .comment("When hammer DOES NOT fly off hands, what is maximal damage it deals to the user (in half of hearts)?") + .defineInRange("SELF_HARM_MAX_DAMAGE", 10.0, 0.0, Double.MAX_VALUE) + + val FLY_OFF_DAMAGE_CHANCE: Double by builder + .comment("When hammer flies off hands, what is chance of it damaging the user?") + .defineInRange("FLY_OFF_DAMAGE_CHANCE", 0.8, 0.0, 1.0) + + val FLY_OFF_MIN_DAMAGE: Double by builder + .comment("When hammer flies off hands, what is minimal damage it deals to the user (in half of hearts)?") + .defineInRange("FLY_OFF_MIN_DAMAGE", 4.0, 0.0, Double.MAX_VALUE) + + val FLY_OFF_MAX_DAMAGE: Double by builder + .comment("When hammer flies off hands, what is maximal damage it deals to the user (in half of hearts)?") + .defineInRange("FLY_OFF_MAX_DAMAGE", 25.0, 0.0, Double.MAX_VALUE) + } + + init { + builder.push("ExplosiveHammer") + ExplosiveHammer + builder.pop() + } } 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 57d981eb9..339df1e15 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 @@ -24,6 +24,7 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent import net.minecraftforge.event.level.BlockEvent import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.config.ItemsConfig +import ru.dbotthepony.mc.otm.config.ToolsConfig import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.damageType import ru.dbotthepony.mc.otm.core.getExplosionResistance @@ -70,18 +71,18 @@ class ExplosiveHammerItem(durability: Int = 64) : Item(Properties().stacksTo(1). val (ex, ey, ez) = pos // взрыв в месте удара молотком - val exp = Explosion(attacker.level, attacker, ex, ey, ez, 1f, false, if (ItemsConfig.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_WITH_DECAY else Explosion.BlockInteraction.KEEP) exp.explode() exp.finalizeExplosion(true) - if (!ItemsConfig.ExplosiveHammer.EXPLOSION_DAMAGE_BLOCKS) + if (!ToolsConfig.ExplosiveHammer.EXPLOSION_DAMAGE_BLOCKS) exp.clearToBlow() val level = attacker.level as ServerLevel val hitEntities = ObjectArraySet() hitEntities.add(attacker) - var canTravel = ItemsConfig.ExplosiveHammer.MAX_TRAVEL + var canTravel = ToolsConfig.ExplosiveHammer.MAX_TRAVEL var rayPos = pos var lastBlockPos: BlockPos? = null @@ -97,12 +98,12 @@ class ExplosiveHammerItem(durability: Int = 64) : Item(Properties().stacksTo(1). val block = level.getBlockState(blockPos) if (!block.isAir) { - val resist = block.getExplosionResistance(level, blockPos) * ItemsConfig.ExplosiveHammer.TRAVEL_EXPLOSION_RESIST_MULT + val resist = block.getExplosionResistance(level, blockPos) * ToolsConfig.ExplosiveHammer.TRAVEL_EXPLOSION_RESIST_MULT if (resist >= 0.0) { if (resist <= canTravel) { canTravel -= resist - val cond = ItemsConfig.ExplosiveHammer.DAMAGE_BLOCKS && + val cond = ToolsConfig.ExplosiveHammer.DAMAGE_BLOCKS && (attacker !is Player || level.mayInteract(attacker, blockPos) && !MinecraftForge.EVENT_BUS.post(BlockEvent.BreakEvent(level, blockPos, block, attacker))) if (cond) { @@ -122,8 +123,8 @@ class ExplosiveHammerItem(durability: Int = 64) : Item(Properties().stacksTo(1). val damageSource = MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.HAMMER_NAIL), attacker, itemStack) for (it in entities) { - val damage = canTravel * ItemsConfig.ExplosiveHammer.TRAVEL_DAMAGE_MULT - canTravel -= it.maxHealth * ItemsConfig.ExplosiveHammer.TRAVEL_MAX_HEALTH_MULT + val damage = canTravel * ToolsConfig.ExplosiveHammer.TRAVEL_DAMAGE_MULT + canTravel -= it.maxHealth * ToolsConfig.ExplosiveHammer.TRAVEL_MAX_HEALTH_MULT it.hurt(damageSource, damage.toFloat()) @@ -152,7 +153,7 @@ class ExplosiveHammerItem(durability: Int = 64) : Item(Properties().stacksTo(1). it.broadcastBreakEvent(hand) } - if (!itemStack.isEmpty && attacker.random.nextDouble() <= ItemsConfig.ExplosiveHammer.FLY_OFF_CHANCE) { + if (!itemStack.isEmpty && attacker.random.nextDouble() <= ToolsConfig.ExplosiveHammer.FLY_OFF_CHANCE) { attacker.setItemInHand(hand, ItemStack.EMPTY) val (x, y, z) = attacker.position @@ -168,14 +169,14 @@ class ExplosiveHammerItem(durability: Int = 64) : Item(Properties().stacksTo(1). attacker.level.addFreshEntity(entity) - if (attacker.random.nextDouble() <= ItemsConfig.ExplosiveHammer.FLY_OFF_DAMAGE_CHANCE) { + if (attacker.random.nextDouble() <= ToolsConfig.ExplosiveHammer.FLY_OFF_DAMAGE_CHANCE) { attacker.invulnerableTime = 0 - val dmg = ItemsConfig.ExplosiveHammer.FLY_OFF_MIN_DAMAGE + attacker.random.nextDouble() * (ItemsConfig.ExplosiveHammer.FLY_OFF_MAX_DAMAGE - ItemsConfig.ExplosiveHammer.FLY_OFF_MIN_DAMAGE) + val dmg = ToolsConfig.ExplosiveHammer.FLY_OFF_MIN_DAMAGE + attacker.random.nextDouble() * (ToolsConfig.ExplosiveHammer.FLY_OFF_MAX_DAMAGE - ToolsConfig.ExplosiveHammer.FLY_OFF_MIN_DAMAGE) attacker.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EXPLOSIVE_HAMMER), inflictor = copy), dmg.toFloat()) } - } else if (attacker.random.nextDouble() <= ItemsConfig.ExplosiveHammer.SELF_HARM_CHANCE) { + } else if (attacker.random.nextDouble() <= ToolsConfig.ExplosiveHammer.SELF_HARM_CHANCE) { attacker.invulnerableTime = 0 - val dmg = ItemsConfig.ExplosiveHammer.SELF_HARM_MIN_DAMAGE + attacker.random.nextDouble() * (ItemsConfig.ExplosiveHammer.SELF_HARM_MAX_DAMAGE - ItemsConfig.ExplosiveHammer.SELF_HARM_MIN_DAMAGE) + val dmg = ToolsConfig.ExplosiveHammer.SELF_HARM_MIN_DAMAGE + attacker.random.nextDouble() * (ToolsConfig.ExplosiveHammer.SELF_HARM_MAX_DAMAGE - ToolsConfig.ExplosiveHammer.SELF_HARM_MIN_DAMAGE) attacker.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EXPLOSIVE_HAMMER), inflictor = copy), dmg.toFloat()) } } From 2feb540076116650a128bb7848fa26a3a54417f7 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 26 Apr 2023 17:31:17 +0700 Subject: [PATCH 0528/1199] Rebalance explosive hammer config values to make it more practical --- .../ru/dbotthepony/mc/otm/config/ToolsConfig.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ToolsConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ToolsConfig.kt index cf0f347a4..f6aadb631 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ToolsConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ToolsConfig.kt @@ -15,7 +15,7 @@ object ToolsConfig : AbstractConfig("tools") { .comment("The nail penetrate through blocks and entities, losing power in process") .comment("The nail can not travel into unloaded chunks and will stop immediately if it does so") .comment("The nail travels its entire path instantaneously") - .defineInRange("MAX_TRAVEL", 48.0, 0.0, Double.MAX_VALUE) + .defineInRange("MAX_TRAVEL", 64.0, 0.0, Double.MAX_VALUE) val TRAVEL_EXPLOSION_RESIST_MULT: Double by builder .comment("Multiplier of explosion resistance of blocks on nail path") @@ -32,11 +32,11 @@ object ToolsConfig : AbstractConfig("tools") { val TRAVEL_DAMAGE_MULT: Double by builder .comment("Multiplier of current nail force (base of MAX_TRAVEL) for damage values") .comment("That is, any being on path of nail will get damaged by nail power multiplied by this") - .defineInRange("TRAVEL_DAMAGE_MULT", 0.6, 0.0, Double.MAX_VALUE) + .defineInRange("TRAVEL_DAMAGE_MULT", 0.5, 0.0, Double.MAX_VALUE) val TRAVEL_MAX_HEALTH_MULT: Double by builder .comment("Multiplier of being's max health in nail path subtracted from nail force when penetrating through") - .defineInRange("TRAVEL_MAX_HEALTH_MULT", 0.4, 0.0, Double.MAX_VALUE) + .defineInRange("TRAVEL_MAX_HEALTH_MULT", 0.5, 0.0, Double.MAX_VALUE) val DAMAGE_BLOCKS: Boolean by builder .comment("Should hammer (**not** explosion) damage blocks", "Blocks damaged this way will always be dropped") @@ -48,11 +48,11 @@ object ToolsConfig : AbstractConfig("tools") { val FLY_OFF_CHANCE: Double by builder .comment("Chance that hammer will fly off hands of attacker upon impact") - .defineInRange("FLY_OFF_CHANCE", 0.6, 0.0, 1.0) + .defineInRange("FLY_OFF_CHANCE", 0.4, 0.0, 1.0) val SELF_HARM_CHANCE: Double by builder .comment("When hammer DOES NOT fly off hands, what is chance of it damaging the user?", "(this does not account for damage because of hitting things close)", "(idiot)") - .defineInRange("SELF_HARM_CHANCE", 0.4, 0.0, 1.0) + .defineInRange("SELF_HARM_CHANCE", 0.25, 0.0, 1.0) val SELF_HARM_MIN_DAMAGE: Double by builder .comment("When hammer DOES NOT fly off hands, what is minimal damage it deals to the user (in half of hearts)?") @@ -64,7 +64,7 @@ object ToolsConfig : AbstractConfig("tools") { val FLY_OFF_DAMAGE_CHANCE: Double by builder .comment("When hammer flies off hands, what is chance of it damaging the user?") - .defineInRange("FLY_OFF_DAMAGE_CHANCE", 0.8, 0.0, 1.0) + .defineInRange("FLY_OFF_DAMAGE_CHANCE", 0.4, 0.0, 1.0) val FLY_OFF_MIN_DAMAGE: Double by builder .comment("When hammer flies off hands, what is minimal damage it deals to the user (in half of hearts)?") @@ -72,7 +72,7 @@ object ToolsConfig : AbstractConfig("tools") { val FLY_OFF_MAX_DAMAGE: Double by builder .comment("When hammer flies off hands, what is maximal damage it deals to the user (in half of hearts)?") - .defineInRange("FLY_OFF_MAX_DAMAGE", 25.0, 0.0, Double.MAX_VALUE) + .defineInRange("FLY_OFF_MAX_DAMAGE", 20.0, 0.0, Double.MAX_VALUE) } init { From d0ffa8564707092a312e945dab32fe0dcb30d501 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 26 Apr 2023 17:50:17 +0700 Subject: [PATCH 0529/1199] Make hammer deal actual damage when attacking mobs and make it not spammable --- .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 7 ++++ .../mc/otm/item/tool/ExplosiveHammerItem.kt | 32 +++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) 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 1ebb97476..efbf72a36 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -5,6 +5,7 @@ package ru.dbotthepony.mc.otm.core import com.google.common.collect.ImmutableList import com.google.common.collect.ImmutableMap +import com.google.common.collect.ImmutableMultimap import com.google.common.collect.ImmutableSet import com.google.gson.JsonElement import com.google.gson.JsonObject @@ -151,6 +152,12 @@ inline fun immutableMap(initializer: ImmutableMap.Builder immutableMultimap(initializer: ImmutableMultimap.Builder.() -> Unit): ImmutableMultimap { + val builder = ImmutableMultimap.Builder() + initializer.invoke(builder) + return builder.build() +} + inline fun immutableSet(initializer: Consumer.() -> Unit): ImmutableSet { val builder = ImmutableSet.Builder() initializer.invoke(builder::add) 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 339df1e15..6ae6658f0 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 @@ -1,5 +1,7 @@ package ru.dbotthepony.mc.otm.item.tool +import com.google.common.collect.ImmutableMultimap +import com.google.common.collect.Multimap import it.unimi.dsi.fastutil.objects.ObjectArraySet import net.minecraft.ChatFormatting import net.minecraft.core.BlockPos @@ -9,7 +11,11 @@ import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerPlayer import net.minecraft.world.InteractionHand import net.minecraft.world.damagesource.DamageSource +import net.minecraft.world.entity.EquipmentSlot import net.minecraft.world.entity.LivingEntity +import net.minecraft.world.entity.ai.attributes.Attribute +import net.minecraft.world.entity.ai.attributes.AttributeModifier +import net.minecraft.world.entity.ai.attributes.Attributes import net.minecraft.world.entity.item.ItemEntity import net.minecraft.world.entity.player.Player import net.minecraft.world.item.Item @@ -23,12 +29,15 @@ import net.minecraftforge.common.MinecraftForge import net.minecraftforge.event.entity.player.PlayerInteractEvent import net.minecraftforge.event.level.BlockEvent import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity +import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.config.ItemsConfig import ru.dbotthepony.mc.otm.config.ToolsConfig import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.damageType import ru.dbotthepony.mc.otm.core.getExplosionResistance import ru.dbotthepony.mc.otm.core.gracefulBlockBreak +import ru.dbotthepony.mc.otm.core.immutableMap +import ru.dbotthepony.mc.otm.core.immutableMultimap import ru.dbotthepony.mc.otm.core.isExplosion import ru.dbotthepony.mc.otm.core.math.component1 import ru.dbotthepony.mc.otm.core.math.component2 @@ -39,12 +48,13 @@ import ru.dbotthepony.mc.otm.core.math.toDoubleVector import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.position import ru.dbotthepony.mc.otm.core.tagNotNull +import ru.dbotthepony.mc.otm.item.weapon.EnergySwordItem import ru.dbotthepony.mc.otm.registry.MDamageTypes import ru.dbotthepony.mc.otm.registry.MRegistry import ru.dbotthepony.mc.otm.registry.MatteryDamageSource import ru.dbotthepony.mc.otm.triggers.NailedEntityTrigger -class ExplosiveHammerItem(durability: Int = 64) : Item(Properties().stacksTo(1).fireResistant().durability(durability)) { +class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1).fireResistant().durability(durability)) { override fun canBeHurtBy(pDamageSource: DamageSource): Boolean { return super.canBeHurtBy(pDamageSource) && !pDamageSource.isExplosion } @@ -64,8 +74,24 @@ class ExplosiveHammerItem(durability: Int = 64) : Item(Properties().stacksTo(1). private val aabb = AABB(-0.1, -0.1, -0.1, 0.1, 0.1, 0.1) + val attributes = immutableMultimap { + put(Attributes.ATTACK_DAMAGE, AttributeModifier(BASE_ATTACK_DAMAGE_UUID, "Weapon modifier", 3.0, AttributeModifier.Operation.ADDITION)) + put(Attributes.ATTACK_SPEED, AttributeModifier(BASE_ATTACK_SPEED_UUID, "Weapon modifier", -3.4, AttributeModifier.Operation.ADDITION)) + } + + override fun getAttributeModifiers( + slot: EquipmentSlot, + itemStack: ItemStack + ): Multimap { + if (slot != EquipmentSlot.MAINHAND) { + return ImmutableMultimap.of() + } + + return attributes + } + fun attackAt(itemStack: ItemStack, attacker: LivingEntity, pos: Vec3, aim: Vec3, hand: InteractionHand) { - if (!isPrimed(itemStack) || attacker.level.isClientSide) + if (!isPrimed(itemStack) || attacker.level.isClientSide || attacker is Player && attacker.getAttackStrengthScale(0.4f) < 0.98f) return val (ex, ey, ez) = pos @@ -149,7 +175,7 @@ class ExplosiveHammerItem(durability: Int = 64) : Item(Properties().stacksTo(1). val copy = itemStack.copy() - itemStack.hurtAndBreak(1, attacker) { + itemStack.hurtAndBreak(level.random.nextInt(1, 20), attacker) { it.broadcastBreakEvent(hand) } From acf5ce9fbcf522c3dc50d4e7308377adbcc0b193 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Fri, 5 May 2023 17:11:55 +0300 Subject: [PATCH 0530/1199] =?UTF-8?q?=D0=A3=D0=92=D0=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/coremods/code_injector.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/coremods/code_injector.js b/src/main/resources/coremods/code_injector.js index a57584172..df7826548 100644 --- a/src/main/resources/coremods/code_injector.js +++ b/src/main/resources/coremods/code_injector.js @@ -894,7 +894,7 @@ function initializeCoreMod() { var next = new MethodInsnNode( opcodesRemapped.invokestatic, - 'ru/dbotthepony/mc/otm/item/tool/EnergySwordItem', + 'ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem', 'getSweepingDamageRatioHook', '(Lnet/minecraft/world/entity/LivingEntity;)Ljava/lang/Float;', false From 82448924bef9d881f2696a936a5776a3700a416e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 6 May 2023 13:18:07 +0700 Subject: [PATCH 0531/1199] e --- .../ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 1f212a4a7..f107f9435 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -97,7 +97,6 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial data class PreTick(val capability: MatteryPlayerCapability) : Event() { override fun isCancelable() = true override fun hasResult() = false - override fun setResult(value: Result) {} val player get() = capability.ply val level: Level get() = capability.ply.level @@ -109,7 +108,6 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial data class PostTick(val capability: MatteryPlayerCapability) : Event() { override fun isCancelable() = false override fun hasResult() = false - override fun setResult(value: Result) {} val player get() = capability.ply val level: Level get() = capability.ply.level From 1a7f88211b936ccd8bfaf38c525a666b9ebe4191 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 6 May 2023 13:18:36 +0700 Subject: [PATCH 0532/1199] Allow setting energy of itemenergystorageimpl --- .../mc/otm/capability/energy/ItemEnergyStorageImpl.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt index b658152fe..8c98543ae 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt @@ -37,9 +37,7 @@ abstract class ItemEnergyStorageImpl(val itemStack: ItemStack) : IMatteryEnergyS override var batteryLevel: Decimal get() = itemStack.tag?.map(ENERGY_KEY, Decimal.Companion::deserializeNBT) ?: initialBatteryLevel - set(value) { - itemStack.tagNotNull[ENERGY_KEY] = value.serializeNBT() - } + set(value) { itemStack.tagNotNull[ENERGY_KEY] = value.serializeNBT() } override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { if (!howMuch.isPositive || itemStack.count != 1) From 738479b6eef28bc7a3c4373a46d02dad53e06023 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 6 May 2023 19:55:02 +0700 Subject: [PATCH 0533/1199] Procedural batteries in dungeons! --- .../mc/otm/datagen/lang/English.kt | 3 + .../mc/otm/datagen/lang/Russian.kt | 3 + .../ru/dbotthepony/mc/otm/datagen/loot/DSL.kt | 1 + .../mc/otm/datagen/loot/LootModifiersData.kt | 23 +++- .../mc/otm/data/Codec2Serializer.kt | 21 +++ .../dbotthepony/mc/otm/data/DecimalCodec.kt | 23 ++++ .../mc/otm/data/DecimalProvider.kt | 117 ++++++++++++++++ .../mc/otm/item/ProceduralBatteryItem.kt | 126 ++++++++++++++++++ .../mc/otm/registry/MItemFunctionTypes.kt | 3 +- .../ru/dbotthepony/mc/otm/registry/MItems.kt | 9 +- .../ru/dbotthepony/mc/otm/registry/MNames.kt | 1 + .../dbotthepony/mc/otm/registry/MRegistry.kt | 3 + 12 files changed, 321 insertions(+), 12 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalProvider.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralBatteryItem.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 23059d825..ac35140e7 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -453,6 +453,9 @@ private fun blocks(provider: MatteryLanguageProvider) { private fun items(provider: MatteryLanguageProvider) { with(provider.english) { + add(MItems.PROCEDURAL_BATTERY, "Mythical Battery") + add(MItems.PROCEDURAL_BATTERY, "desc", "These batteries are found in dungeons with randomized stats") + add(MItems.EXPLOSIVE_HAMMER, "Explosive Hammer") add(MItems.EXPLOSIVE_HAMMER, "desc", "For those who feel bored") add(MItems.EXPLOSIVE_HAMMER, "primed", "Primed!") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 4e5260406..dd46dbd90 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -458,6 +458,9 @@ private fun blocks(provider: MatteryLanguageProvider) { private fun items(provider: MatteryLanguageProvider) { with(provider.russian) { + add(MItems.PROCEDURAL_BATTERY, "Загадочный аккумулятор") + add(MItems.PROCEDURAL_BATTERY, "desc", "Данные аккумуляторы можно найти в подземельях, со случайными характеристиками") + add(MItems.EXPLOSIVE_HAMMER, "Молоток-убийца") add(MItems.EXPLOSIVE_HAMMER, "desc", "Для тех, кому стало скучно") add(MItems.EXPLOSIVE_HAMMER, "primed", "Заряжен!") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/DSL.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/DSL.kt index 4ca29433b..b62d7f57e 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/DSL.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/DSL.kt @@ -28,6 +28,7 @@ inline fun LootTable.Builder.singleItem(item: ItemLike, configurator: LootPoolSi inline fun lootPool(configurator: LootPool.Builder.() -> Unit): LootPool = LootPool.lootPool().also(configurator).build() inline fun singleItem(item: ItemLike, configurator: LootPoolSingletonContainer.Builder<*>.() -> Unit): LootPool = lootPool { item(item, configurator) } + fun singleRandomizedItem(item: ItemLike, rarity: Rarity = Rarity.COMMON, chance: Double? = null): LootPool { return lootPool { item(item) { diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootModifiersData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootModifiersData.kt index 61e301237..6b3002281 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootModifiersData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootModifiersData.kt @@ -7,12 +7,15 @@ import net.minecraft.world.item.Rarity import net.minecraft.world.level.storage.loot.BuiltInLootTables import net.minecraft.world.level.storage.loot.predicates.LootItemCondition import net.minecraftforge.common.loot.LootTableIdCondition +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.data.UniformDecimal import ru.dbotthepony.mc.otm.data.condition.ChanceWithPlaytimeCondition import ru.dbotthepony.mc.otm.data.condition.HasExoPackCondition import ru.dbotthepony.mc.otm.data.condition.ItemInInventoryCondition import ru.dbotthepony.mc.otm.data.condition.KilledByRealPlayerOrIndirectly import ru.dbotthepony.mc.otm.data.loot.LootPoolAppender import ru.dbotthepony.mc.otm.data.loot.RandomizerFunction +import ru.dbotthepony.mc.otm.item.ProceduralBatteryItem import ru.dbotthepony.mc.otm.registry.MItems @Suppress("FunctionName") @@ -25,7 +28,7 @@ fun LootTableIdCondition(location: ResourceLocation): LootItemCondition { return LootTableIdCondition.Builder(location).build() } -private fun exosuitModifiers(it: LootModifiers) { +fun addLootModifiers(it: LootModifiers) { it.add("dungeon_exosuit", LootPoolAppender( arrayOf(LootTableIdCondition(BuiltInLootTables.SIMPLE_DUNGEON)), @@ -40,10 +43,20 @@ private fun exosuitModifiers(it: LootModifiers) { }, )) - it.add("mineshaft_exosuit", LootPoolAppender( + it.add("mineshaft_additions", LootPoolAppender( arrayOf(LootTableIdCondition(BuiltInLootTables.ABANDONED_MINESHAFT)), singleRandomizedItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, chance = 0.1), - singleRandomizedItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, chance = 0.1, rarity = Rarity.UNCOMMON) + singleRandomizedItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, chance = 0.1, rarity = Rarity.UNCOMMON), + + singleItem(MItems.PROCEDURAL_BATTERY) { + chanceCondition(0.15) + + apply(ProceduralBatteryItem.Randomizer( + maxBatteryLevel = UniformDecimal(Decimal(8_000_000), Decimal(40_000_000)), + batteryLevel = UniformDecimal(Decimal(0), Decimal(20_000_000)), + maxInput = UniformDecimal(Decimal(700), Decimal(4_000)), + )) + } )) it.add("desert_pyramid_exosuit", LootPoolAppender( @@ -64,10 +77,6 @@ private fun exosuitModifiers(it: LootModifiers) { singleRandomizedItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, chance = 0.2, rarity = Rarity.RARE), singleRandomizedItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, chance = 0.15, rarity = Rarity.EPIC), )) -} - -fun addLootModifiers(it: LootModifiers) { - exosuitModifiers(it) it.add("dungeon_pill", PlainLootAppender( arrayOf(LootTableIdCondition(BuiltInLootTables.SIMPLE_DUNGEON)), diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt new file mode 100644 index 000000000..d6bc931c5 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt @@ -0,0 +1,21 @@ +package ru.dbotthepony.mc.otm.data + +import com.google.gson.JsonDeserializationContext +import com.google.gson.JsonObject +import com.google.gson.JsonSerializationContext +import com.google.gson.JsonSyntaxException +import com.mojang.serialization.Codec +import net.minecraft.world.level.storage.loot.Serializer +import ru.dbotthepony.mc.otm.core.fromJsonStrict +import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.toJsonStrict + +class Codec2Serializer(val codec: Codec) : Serializer { + override fun serialize(p_79325_: JsonObject, p_79326_: T, p_79327_: JsonSerializationContext) { + p_79325_["value"] = codec.toJsonStrict(p_79326_) + } + + override fun deserialize(p_79323_: JsonObject, p_79324_: JsonDeserializationContext): T { + return codec.fromJsonStrict(p_79323_["value"] ?: throw JsonSyntaxException("Missing 'value' element")) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt new file mode 100644 index 000000000..4b600cb78 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt @@ -0,0 +1,23 @@ +package ru.dbotthepony.mc.otm.data + +import com.mojang.datafixers.util.Pair +import com.mojang.serialization.Codec +import com.mojang.serialization.DataResult +import com.mojang.serialization.DynamicOps +import ru.dbotthepony.mc.otm.core.math.Decimal + +object DecimalCodec : Codec { + override fun encode(input: Decimal, ops: DynamicOps, prefix: T): DataResult { + return DataResult.success(ops.createString(input.toString())) + } + + override fun decode(ops: DynamicOps, input: T): DataResult> { + return ops.getStringValue(input).flatMap { + try { + DataResult.success(Pair(Decimal(it), ops.empty())) + } catch (err: NumberFormatException) { + DataResult.error { "Not a number: $it" } + } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalProvider.kt new file mode 100644 index 000000000..172e6b07e --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalProvider.kt @@ -0,0 +1,117 @@ +package ru.dbotthepony.mc.otm.data + +import com.mojang.datafixers.util.Either +import com.mojang.serialization.Codec +import com.mojang.serialization.codecs.RecordCodecBuilder +import net.minecraft.resources.ResourceLocation +import net.minecraft.util.RandomSource +import net.minecraftforge.eventbus.api.IEventBus +import net.minecraftforge.registries.DeferredRegister +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.nextDecimal +import ru.dbotthepony.mc.otm.registry.RegistryDelegate + +fun interface SampledDecimal { + fun sample(source: RandomSource): Decimal +} + +abstract class DecimalProvider : SampledDecimal { + interface Type { + val codec: Codec + } + + abstract val minValue: Decimal + abstract val maxValue: Decimal + abstract val type: Type<*> + + companion object { + private val registryHolder = RegistryDelegate>("decimal_provider_type") { + setDefaultKey(ResourceLocation(OverdriveThatMatters.MOD_ID, "zero")) + } + + val CODEC: Codec by lazy { + Codec + .either(DecimalCodec, registry.codec.dispatch({ it.type }, { it.codec })) + .xmap( + { c -> c.map(::ConstantDecimal, { it }) }, + { if (it.type === ConstantDecimal.Companion) Either.left(it.minValue) else Either.right(it) } + ) + } + + val registry by registryHolder + val registryKey get() = registryHolder.key + + private val registror = DeferredRegister.create(registryKey, OverdriveThatMatters.MOD_ID) + + init { + registror.register("zero") { ConstantDecimal.Zero } + registror.register("constant") { ConstantDecimal.Companion } + registror.register("uniform") { UniformDecimal.Companion } + } + + internal fun register(bus: IEventBus) { + bus.addListener(registryHolder::build) + registror.register(bus) + } + } +} + +class ConstantDecimal(val value: Decimal) : DecimalProvider() { + object Zero : DecimalProvider(), Type { + override fun sample(source: RandomSource): Decimal { + return Decimal.ZERO + } + + override val codec: Codec = Codec.unit(this) + + override val minValue: Decimal + get() = Decimal.ZERO + override val maxValue: Decimal + get() = Decimal.ZERO + override val type: Type<*> + get() = this + } + + override fun sample(source: RandomSource): Decimal { + return value + } + + override val minValue: Decimal + get() = value + override val maxValue: Decimal + get() = value + override val type: Type<*> + get() = Companion + + companion object : Type { + override val codec: Codec = RecordCodecBuilder.create { + it.group(DecimalCodec.fieldOf("value").forGetter(ConstantDecimal::value)).apply(it, ::ConstantDecimal) + } + } +} + +class UniformDecimal(override val minValue: Decimal, override val maxValue: Decimal, val round: Boolean = true) : DecimalProvider() { + constructor(range: ClosedRange, round: Boolean = true) : this(range.start, range.endInclusive, round) + + init { + require(minValue <= maxValue) { "Invalid range provided: $minValue .. $maxValue" } + } + + override fun sample(source: RandomSource): Decimal { + return source.nextDecimal(minValue, maxValue, round = round) + } + + override val type: Type<*> + get() = Companion + + companion object : Type { + override val codec: Codec = RecordCodecBuilder.create { + it.group( + DecimalCodec.fieldOf("minValue").forGetter(UniformDecimal::minValue), + DecimalCodec.fieldOf("maxValue").forGetter(UniformDecimal::maxValue), + Codec.BOOL.optionalFieldOf("round", true).forGetter(UniformDecimal::round) + ).apply(it, ::UniformDecimal) + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralBatteryItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralBatteryItem.kt new file mode 100644 index 000000000..42c68d400 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralBatteryItem.kt @@ -0,0 +1,126 @@ +package ru.dbotthepony.mc.otm.item + +import com.mojang.serialization.codecs.RecordCodecBuilder +import net.minecraft.ChatFormatting +import net.minecraft.nbt.CompoundTag +import net.minecraft.network.chat.Component +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.TooltipFlag +import net.minecraft.world.level.Level +import net.minecraft.world.level.storage.loot.LootContext +import net.minecraft.world.level.storage.loot.functions.LootItemFunction +import net.minecraft.world.level.storage.loot.functions.LootItemFunctionType +import net.minecraftforge.common.capabilities.ICapabilityProvider +import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.capability.energy.ItemEnergyStorageImpl +import ru.dbotthepony.mc.otm.capability.energy.batteryLevel +import ru.dbotthepony.mc.otm.capability.matteryEnergy +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.set +import ru.dbotthepony.mc.otm.core.nbt.mapPresent +import ru.dbotthepony.mc.otm.core.tagNotNull +import ru.dbotthepony.mc.otm.data.Codec2Serializer +import ru.dbotthepony.mc.otm.data.DecimalProvider +import ru.dbotthepony.mc.otm.registry.MItemFunctionTypes +import java.util.Optional + +class ProceduralBatteryItem : Item(Properties().stacksTo(1)) { + class Cap(stack: ItemStack) : ItemEnergyStorageImpl(stack) { + override var maxInput: Decimal + get() = itemStack.tag?.mapPresent("maxInput", Decimal.Companion::deserializeNBT) ?: Decimal.ZERO + set(value) { itemStack.tagNotNull["maxInput"] = value } + + override var maxOutput: Decimal + get() = itemStack.tag?.mapPresent("maxOutput", Decimal.Companion::deserializeNBT) ?: Decimal.ZERO + set(value) { itemStack.tagNotNull["maxOutput"] = value } + + override var maxBatteryLevel: Decimal + get() = itemStack.tag?.mapPresent("maxBatteryLevel", Decimal.Companion::deserializeNBT) ?: Decimal.ZERO + set(value) { itemStack.tagNotNull["maxBatteryLevel"] = value } + + override val energyFlow: FlowDirection + get() = FlowDirection.BI_DIRECTIONAL + + override val initialBatteryLevel: Decimal + get() = maxBatteryLevel + } + + override fun appendHoverText(p_41421_: ItemStack, p_41422_: Level?, p_41423_: MutableList, p_41424_: TooltipFlag) { + super.appendHoverText(p_41421_, p_41422_, p_41423_, p_41424_) + + val energy = p_41421_.matteryEnergy + + if (energy is Cap) { + if (energy.maxInput.isZero && energy.maxOutput.isZero && energy.maxBatteryLevel.isZero) { + p_41423_.add(TranslatableComponent("$descriptionId.desc").withStyle(ChatFormatting.GRAY)) + } else { + batteryLevel(energy, p_41423_) + } + } + } + + data class Randomizer( + val maxBatteryLevel: DecimalProvider, + val batteryLevel: Optional, + val maxInput: DecimalProvider, + val maxOutput: Optional + ) : LootItemFunction, LootItemFunction.Builder { + constructor( + maxBatteryLevel: DecimalProvider, + batteryLevel: DecimalProvider? = null, + maxInput: DecimalProvider, + maxOutput: DecimalProvider? = null + ) : this(maxBatteryLevel, Optional.ofNullable(batteryLevel), maxInput, Optional.ofNullable(maxOutput)) + + override fun apply(t: ItemStack, u: LootContext): ItemStack { + val data = Cap(t) + + if (maxOutput.isPresent) { + data.maxInput = maxInput.sample(u.random) + data.maxOutput = maxOutput.get().sample(u.random) + } else { + data.maxInput = maxInput.sample(u.random) + data.maxOutput = data.maxInput + } + + data.maxBatteryLevel = maxBatteryLevel.sample(u.random) + + if (batteryLevel.isPresent) { + data.batteryLevel = batteryLevel.get().sample(u.random).coerceAtMost(data.maxBatteryLevel) + } else { + data.batteryLevel = data.maxBatteryLevel + } + + return t + } + + override fun getType(): LootItemFunctionType { + return MItemFunctionTypes.PROCEDURAL_BATTERY + } + + override fun build(): LootItemFunction { + return this + } + + companion object { + val SERIALIZER by lazy { + Codec2Serializer( + RecordCodecBuilder.create { + it.group( + DecimalProvider.CODEC.fieldOf("maxBatteryLevel").forGetter(Randomizer::maxBatteryLevel), + DecimalProvider.CODEC.optionalFieldOf("batteryLevel").forGetter(Randomizer::batteryLevel), + DecimalProvider.CODEC.fieldOf("maxInput").forGetter(Randomizer::maxInput), + DecimalProvider.CODEC.optionalFieldOf("maxOutput").forGetter(Randomizer::maxOutput), + ).apply(it, ::Randomizer) + } + ) + } + } + } + + override fun initCapabilities(stack: ItemStack, nbt: CompoundTag?): ICapabilityProvider { + return Cap(stack) + } +} 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 2e5645ad5..d30b97e29 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,5 @@ package ru.dbotthepony.mc.otm.registry -import net.minecraft.core.Registry import net.minecraft.core.registries.Registries import net.minecraft.world.level.storage.loot.functions.LootItemFunctionType import net.minecraftforge.eventbus.api.IEventBus @@ -8,12 +7,14 @@ import net.minecraftforge.registries.DeferredRegister import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.data.loot.CopyTileNbtFunction import ru.dbotthepony.mc.otm.data.loot.RandomizerFunction +import ru.dbotthepony.mc.otm.item.ProceduralBatteryItem object MItemFunctionTypes { private val registry = DeferredRegister.create(Registries.LOOT_FUNCTION_TYPE, OverdriveThatMatters.MOD_ID) val RANDOMIZER: LootItemFunctionType by registry.register("randomizer") { LootItemFunctionType(RandomizerFunction.Companion) } val COPY_TILE_NBT: LootItemFunctionType by registry.register("copy_tile_nbt") { LootItemFunctionType(CopyTileNbtFunction.Companion) } + val PROCEDURAL_BATTERY: LootItemFunctionType by registry.register(MNames.PROCEDURAL_BATTERY) { LootItemFunctionType(ProceduralBatteryItem.Randomizer.SERIALIZER) } internal fun register(bus: IEventBus) { registry.register(bus) 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 e9a81c914..f24e37f4d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -289,10 +289,11 @@ object MItems { val BATTERY_CAPACITOR: Item by registry.register(MNames.BATTERY_CAPACITOR) { BatteryItem(ItemsConfig.Batteries.CAPACITOR) } val BATTERY_CREATIVE: Item by registry.register(MNames.BATTERY_CREATIVE) { BatteryItem() } - val QUANTUM_BATTERY: Item by registry.register(MNames.QUANTUM_BATTERY) { QuantumBatteryItem(MNames.QUANTUM_BATTERY, ItemsConfig.Batteries.QUANTUM_BATTERY) } - val QUANTUM_CAPACITOR: Item by registry.register(MNames.QUANTUM_CAPACITOR) { QuantumBatteryItem(MNames.QUANTUM_CAPACITOR, ItemsConfig.Batteries.QUANTUM_CAPACITOR) } - val QUANTUM_BATTERY_CREATIVE: Item by registry.register(MNames.QUANTUM_BATTERY_CREATIVE) { QuantumBatteryItem(MNames.QUANTUM_BATTERY_CREATIVE) } - val ZPM_BATTERY: Item by registry.register(MNames.ZPM_BATTERY) { ZPMItem() } + val QUANTUM_BATTERY: QuantumBatteryItem by registry.register(MNames.QUANTUM_BATTERY) { QuantumBatteryItem(MNames.QUANTUM_BATTERY, ItemsConfig.Batteries.QUANTUM_BATTERY) } + val QUANTUM_CAPACITOR: QuantumBatteryItem by registry.register(MNames.QUANTUM_CAPACITOR) { QuantumBatteryItem(MNames.QUANTUM_CAPACITOR, ItemsConfig.Batteries.QUANTUM_CAPACITOR) } + val QUANTUM_BATTERY_CREATIVE: QuantumBatteryItem by registry.register(MNames.QUANTUM_BATTERY_CREATIVE) { QuantumBatteryItem(MNames.QUANTUM_BATTERY_CREATIVE) } + val ZPM_BATTERY: ZPMItem by registry.register(MNames.ZPM_BATTERY) { ZPMItem() } + val PROCEDURAL_BATTERY: ProceduralBatteryItem by registry.register(MNames.PROCEDURAL_BATTERY) { ProceduralBatteryItem() } val BATTERIES = SupplierList( ::BATTERY_CRUDE, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index 2f36a7932..1f8e0b1ac 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -111,6 +111,7 @@ object MNames { const val PATTERN_DRIVE_CREATIVE2 = "pattern_drive_creative2" const val ZPM_BATTERY = "zpm_battery" + const val PROCEDURAL_BATTERY = "procedural_battery" const val NUTRIENT_PASTE = "nutrient_paste" 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 906d056d7..6444c44eb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -27,6 +27,7 @@ import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock import ru.dbotthepony.mc.otm.block.decorative.TritaniumPressurePlate import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.data.DecimalProvider import ru.dbotthepony.mc.otm.item.weapon.EnergySwordItem import ru.dbotthepony.mc.otm.registry.objects.ColoredDecorativeBlock import ru.dbotthepony.mc.otm.registry.objects.DecorativeBlock @@ -193,6 +194,8 @@ object MRegistry { bus.addListener(this::initializeCommon) bus.addListener(MStats::registerVanilla) + DecimalProvider.register(bus) + MBlocks.register(bus) MBlockEntities.register(bus) MEntityTypes.register(bus) From f26f5a51bb6d69ec81603b9120f87202ff9354e0 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 6 May 2023 20:06:10 +0700 Subject: [PATCH 0534/1199] "fix" one pixel item offset --- .../ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 41b336d2d..cf7b1255b 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 @@ -76,8 +76,8 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit poseStack, requireNotNull(ru.dbotthepony.mc.otm.client.minecraft.player) { "yo, dude, what the fuck" }, itemstack, - 0, - 0, + 1, + 1, (x + y * ru.dbotthepony.mc.otm.client.minecraft.window.guiScaledWidth).toInt() ) From c9fa920a82a73048441831b530eafec02bc41f72 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 6 May 2023 20:20:24 +0700 Subject: [PATCH 0535/1199] Move energy sword sweep patch to mixin --- .../mc/otm/mixin/EnchantmentHelperMixin.java | 24 ++++++ .../mc/otm/item/weapon/EnergySwordItem.kt | 4 - src/main/resources/coremods/code_injector.js | 74 ------------------- .../overdrive_that_matters.mixins.json | 1 + 4 files changed, 25 insertions(+), 78 deletions(-) create mode 100644 src/main/java/ru/dbotthepony/mc/otm/mixin/EnchantmentHelperMixin.java diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/EnchantmentHelperMixin.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/EnchantmentHelperMixin.java new file mode 100644 index 000000000..86f576290 --- /dev/null +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/EnchantmentHelperMixin.java @@ -0,0 +1,24 @@ +package ru.dbotthepony.mc.otm.mixin; + +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import ru.dbotthepony.mc.otm.item.weapon.EnergySwordItem; + +@Mixin(EnchantmentHelper.class) +public class EnchantmentHelperMixin { + @Inject( + method = "getSweepingDamageRatio(Lnet/minecraft/world/entity/LivingEntity;)F", + at = @At("HEAD"), + cancellable = true) + private static void getSweepingDamageRatio(LivingEntity p_44822_, CallbackInfoReturnable info) { + var result = EnergySwordItem.getSweepingDamageRatioHook(p_44822_); + + if (result != null) { + info.setReturnValue(result); + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt index a28415a6d..bb16bc0cf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt @@ -247,10 +247,6 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani builder.pop() } - /** - * This is called from [net.minecraft.world.item.enchantment.EnchantmentHelper.getSweepingDamageRatio] - * by coremod patch - */ @JvmStatic fun getSweepingDamageRatioHook(ply: LivingEntity): Float? { if (ply.mainHandItem.item is EnergySwordItem && ply.mainHandItem.matteryEnergy?.extractEnergyExact(ENERGY_PER_SWING, true) == true) { diff --git a/src/main/resources/coremods/code_injector.js b/src/main/resources/coremods/code_injector.js index df7826548..024edf0de 100644 --- a/src/main/resources/coremods/code_injector.js +++ b/src/main/resources/coremods/code_injector.js @@ -862,80 +862,6 @@ function initializeCoreMod() { } } - return node - } - }, - - 'EnchantmentHelper#getSweepingDamageRatio patch for energy sword': { - 'target': { - 'type': 'METHOD', - 'class': 'net.minecraft.world.item.enchantment.EnchantmentHelper', - 'methodName': ASMAPI.mapMethod('m_44821_'), // getSweepingDamageRatio - 'methodDesc': '(Lnet/minecraft/world/entity/LivingEntity;)F' - }, - - 'transformer': function(node) { - // 0: getstatic #237 // Field net/minecraft/world/item/enchantment/Enchantments.SWEEPING_EDGE:Lnet/minecraft/world/item/enchantment/Enchantment; - // 3: aload_0 - // 4: invokestatic #243 // Method getEnchantmentLevel:(Lnet/minecraft/world/item/enchantment/Enchantment;Lnet/minecraft/world/entity/LivingEntity;)I - // 7: istore_1 - // 8: iload_1 - // 9: ifle 19 - // 12: iload_1 - // 13: invokestatic #246 // Method net/minecraft/world/item/enchantment/SweepingEdgeEnchantment.getSweepingDamageRatio:(I)F - // 16: goto 20 - // 19: fconst_0 - // 20: freturn - - var instructions = node.instructions - - var last = new VarInsnNode(opcodesRemapped.aload, 0) - instructions.insert(last) // load player onto stack - - var next = new MethodInsnNode( - opcodesRemapped.invokestatic, - 'ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem', - 'getSweepingDamageRatioHook', - '(Lnet/minecraft/world/entity/LivingEntity;)Ljava/lang/Float;', - false - ) // call hook - - instructions.insert(last, next) - last = next - - var label = new Label() - var labelNode = new LabelNode(label) - - // add label to jump to if our hook returns null - instructions.insert(last, labelNode) - - // duplicate our value, so `ifnull` can safely pop it from stack - next = new InsnNode(opcodesRemapped.dup) - instructions.insert(last, next) - last = next - - // jump to original code if we returned null - next = new JumpInsnNode(opcodesRemapped.ifnull, labelNode) - instructions.insert(last, next) - last = next - - // unbox float - next = new MethodInsnNode( - opcodesRemapped.invokevirtual, - 'java/lang/Float', - 'floatValue', - '()F', - false - ) - - instructions.insert(last, next) - last = next - - // return float - next = new InsnNode(opcodesRemapped.freturn) - instructions.insert(last, next) - last = next - return node } } diff --git a/src/main/resources/overdrive_that_matters.mixins.json b/src/main/resources/overdrive_that_matters.mixins.json index cbdb3b6c4..0e6d46af9 100644 --- a/src/main/resources/overdrive_that_matters.mixins.json +++ b/src/main/resources/overdrive_that_matters.mixins.json @@ -6,6 +6,7 @@ "minVersion": "0.8", "refmap": "overdrive_that_matters.refmap.json", "mixins": [ + "EnchantmentHelperMixin", "MixinPatchProjectileFinder", "MixinLivingEntity", "MixinAnvilBlock", From a4888c198201884da706495d70f53c2b49696965 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sun, 7 May 2023 02:08:53 +0300 Subject: [PATCH 0536/1199] =?UTF-8?q?DBotThePony=20=E2=80=94=20=D0=92?= =?UTF-8?q?=D1=87=D0=B5=D1=80=D0=B0,=20=D0=B2=2016:20=20:umer:=20=D0=92?= =?UTF-8?q?=D0=BE=D0=BF=D1=80=D0=BE=D1=81=20=D1=82=D0=BE=D0=BB=D1=8C=D0=BA?= =?UTF-8?q?=D0=BE=20=D0=B2=20=D1=82=D0=BE=D0=BC,=20=D0=B0=20=D0=BF=D0=BE?= =?UTF-8?q?=D1=87=D0=B5=D0=BC=D1=83=20=D0=BD=D0=B5=20=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D0=BC=D0=B5=D1=81=D1=82=D0=B8=D1=82=D1=8C=20=D1=82=D0=B8?= =?UTF-8?q?=D0=BF=D0=B8=D1=87=D0=BD=D1=8B=D0=B5=20=D0=BF=D0=B0=D1=82=D1=87?= =?UTF-8?q?=D0=B8=20=D0=B2=20mixin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ---------- ну и починил /clear для экзокостюма --- .../mc/otm/mixin/MixinGameRenderer.java | 22 ++++++ .../mc/otm/mixin/MixinInventory.java | 38 +++++++++++ .../dbotthepony/mc/otm/mixin/MixinPlayer.java | 19 ++++++ src/main/resources/coremods/code_injector.js | 67 ------------------- .../overdrive_that_matters.mixins.json | 6 +- 5 files changed, 84 insertions(+), 68 deletions(-) create mode 100644 src/main/java/ru/dbotthepony/mc/otm/mixin/MixinGameRenderer.java create mode 100644 src/main/java/ru/dbotthepony/mc/otm/mixin/MixinPlayer.java diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinGameRenderer.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinGameRenderer.java new file mode 100644 index 000000000..02c823a2d --- /dev/null +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinGameRenderer.java @@ -0,0 +1,22 @@ +package ru.dbotthepony.mc.otm.mixin; + +import net.minecraft.client.renderer.GameRenderer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import ru.dbotthepony.mc.otm.client.render.GlitchRenderer; + +@Mixin(GameRenderer.class) +public class MixinGameRenderer { + @Inject( + method = "render(FJZ)V", + at = @At( + value = "INVOKE", + target = "Lcom/mojang/blaze3d/pipeline/RenderTarget;bindWrite(Z)V" + ) + ) + private void render(float p_109094_, long p_109095_, boolean p_109096_, CallbackInfo ci) { + GlitchRenderer.render(); + } +} diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinInventory.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinInventory.java index a8f494406..981e1f8cd 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinInventory.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinInventory.java @@ -3,6 +3,8 @@ package ru.dbotthepony.mc.otm.mixin; import net.minecraft.CrashReport; import net.minecraft.CrashReportCategory; import net.minecraft.ReportedException; +import net.minecraft.world.Container; +import net.minecraft.world.ContainerHelper; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; @@ -12,8 +14,12 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import ru.dbotthepony.mc.otm.capability.MatteryCapability; +import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability; + +import java.util.function.Predicate; @Mixin(Inventory.class) public class MixinInventory { @@ -46,4 +52,36 @@ public class MixinInventory { }); } } + + @Inject( + method = "dropAll()V", + at = @At("TAIL") + ) + private void dropAll(CallbackInfo ci) { + MatteryPlayerCapability.inventoryDropAll((Inventory)(Object)this); + } + + @Inject( + method = "clearContent()V", + at = @At("TAIL") + ) + private void clearContent(CallbackInfo ci) { + MatteryPlayerCapability.inventoryClearContent((Inventory)(Object)this); + } + + @Inject( + method = "clearOrCountMatchingItems(Ljava/util/function/Predicate;ILnet/minecraft/world/Container;)I", + at = @At("RETURN"), + cancellable = true + ) + private void clearOrCountMatchingItems(Predicate predicate, int count, Container container, CallbackInfoReturnable cir) { + player.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresent(it -> { + if (!it.getHasExoPack()) return; + + int i = cir.getReturnValue(); + i += ContainerHelper.clearOrCountMatchingItems(it.getExoPackContainer(), predicate, count - i, count == 0); + + cir.setReturnValue(i); + }); + } } diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinPlayer.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinPlayer.java new file mode 100644 index 000000000..1e112bcde --- /dev/null +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinPlayer.java @@ -0,0 +1,19 @@ +package ru.dbotthepony.mc.otm.mixin; + +import net.minecraft.world.entity.player.Player; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability; + +@Mixin(Player.class) +public class MixinPlayer { + @Inject( + method = "destroyVanishingCursedItems()V", + at = @At("TAIL") + ) + private void destroyVanishingCursedItems(CallbackInfo ci) { + MatteryPlayerCapability.playerDestroyVanishingCursedItems((Player)(Object)this); + } +} diff --git a/src/main/resources/coremods/code_injector.js b/src/main/resources/coremods/code_injector.js index 024edf0de..77b59d722 100644 --- a/src/main/resources/coremods/code_injector.js +++ b/src/main/resources/coremods/code_injector.js @@ -621,30 +621,6 @@ function initializeCoreMod() { return node }), - 'Inventory#dropAll': injectAtTail( - 'net.minecraft.world.entity.player.Inventory.m_36071_()V', - [ - new VarInsnNode(opcodesRemapped.aload, 0), - new MethodInsnNode(opcodesRemapped.invokestatic, 'ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability', 'inventoryDropAll', '(Lnet/minecraft/world/entity/player/Inventory;)V', false) - ] - ), - - 'Inventory#clearContent': injectAtTail( - 'net.minecraft.world.entity.player.Inventory.m_6211_()V', - [ - new VarInsnNode(opcodesRemapped.aload, 0), - new MethodInsnNode(opcodesRemapped.invokestatic, 'ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability', 'inventoryClearContent', '(Lnet/minecraft/world/entity/player/Inventory;)V', false) - ] - ), - - 'Player#destroyVanishingCursedItems': injectAtTail( - 'net.minecraft.world.entity.player.Player.m_36345_()V', - [ - new VarInsnNode(opcodesRemapped.aload, 0), - new MethodInsnNode(opcodesRemapped.invokestatic, 'ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability', 'playerDestroyVanishingCursedItems', '(Lnet/minecraft/world/entity/player/Player;)V', false) - ] - ), - 'blend func lock 1': { 'target': { 'type': 'METHOD', @@ -773,49 +749,6 @@ function initializeCoreMod() { return node }), - 'GameRenderer#render hook': { - 'target': { - 'type': 'METHOD', - 'class': 'net.minecraft.client.renderer.GameRenderer', - 'methodName': ASMAPI.mapMethod('m_109093_'), // render - 'methodDesc': '(FJZ)V' - }, - - 'transformer': function(node) { - // 288: invokevirtual #3558 // Method net/minecraft/client/renderer/PostChain.process:(F)V - // 291: aload_0 - // 292: getfield #2773 // Field minecraft:Lnet/minecraft/client/Minecraft; - // 295: invokevirtual #2818 // Method net/minecraft/client/Minecraft.getMainRenderTarget:()Lcom/mojang/blaze3d/pipeline/RenderTarget; - // 298: iconst_1 - // 299: invokevirtual #3561 // Method com/mojang/blaze3d/pipeline/RenderTarget.bindWrite:(Z)V - // <-- our target - // 302: aload_0 - // 303: getfield #2773 // Field minecraft:Lnet/minecraft/client/Minecraft; - // 306: invokevirtual #2821 // Method net/minecraft/client/Minecraft.getWindow:()Lcom/mojang/blaze3d/platform/Window; - // 309: astore 7 - - var ourmethod = ASMAPI.mapMethod('m_83947_') // bindWrite - - for (var i = 0; i < node.instructions.size(); i++) { - var instruction = node.instructions.get(i) - - if (instruction.getOpcode() == opcodesRemapped.invokevirtual && instruction.name == ourmethod && instruction.desc == '(Z)V') { - node.instructions.insert(instruction, new MethodInsnNode( - opcodesRemapped.invokestatic, - 'ru/dbotthepony/mc/otm/client/render/GlitchRenderer', - 'render', - '()V', - false - )) - - break - } - } - - return node - } - }, - 'LevelRenderer DynamicBufferSource callback': { 'target': { 'type': 'METHOD', diff --git a/src/main/resources/overdrive_that_matters.mixins.json b/src/main/resources/overdrive_that_matters.mixins.json index 0e6d46af9..42c121a52 100644 --- a/src/main/resources/overdrive_that_matters.mixins.json +++ b/src/main/resources/overdrive_that_matters.mixins.json @@ -11,6 +11,10 @@ "MixinLivingEntity", "MixinAnvilBlock", "MixinInventory", - "MixinAbstractHurtingProjectile" + "MixinAbstractHurtingProjectile", + "MixinPlayer" + ], + "client": [ + "MixinGameRenderer" ] } From 0eecda4b3f7be4822b2cf86102b926d8b4ea4921 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sun, 7 May 2023 16:02:28 +0300 Subject: [PATCH 0537/1199] =?UTF-8?q?=D0=B7=D0=B0=D0=B1=D1=8B=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NOTICE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NOTICE.md b/NOTICE.md index c1b372998..4cbfe4855 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -1,4 +1,4 @@ ### Licensing exclusions/External copyrighted material -Shockwave landing sound: [ULTRAKILL Game](https://store.steampowered.com/app/1229490/), ARR, got permission to use in mod +Shockwave landing and projectile punch sounds: [ULTRAKILL Game](https://store.steampowered.com/app/1229490/), ARR, got permission to use in mod From 325d1f57867554c85ce73019790acfac9d97db67 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sun, 7 May 2023 16:33:13 +0300 Subject: [PATCH 0538/1199] =?UTF-8?q?=D1=80=D0=B5=D1=86=D0=B5=D0=BF=D1=82?= =?UTF-8?q?=D1=8B=20#254?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/datagen/recipes/CraftingTableRecipes.kt | 12 ++++++++++++ .../mc/otm/datagen/recipes/DecorativesRecipes.kt | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index 7127cdce5..922c2e42a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -177,6 +177,18 @@ fun addCraftingTableRecipes(consumer: Consumer) { .unlockedBy(MItemTags.TRITANIUM_PLATES) .build(consumer) + MatteryRecipe(MItems.CARBON_FIBRE_BLOCK, category = RecipeCategory.BUILDING_BLOCKS) + .rowAB(MItemTags.CARBON_PLATES, MItemTags.CARBON_PLATES) + .rowAB(MItemTags.CARBON_PLATES, MItemTags.CARBON_PLATES) + .unlockedBy(MItemTags.CARBON_PLATES) + .build(consumer) + + ShapelessRecipeBuilder(RecipeCategory.MISC, MItems.CARBON_MESH, 4) + .requires(Ingredient.of(MItems.CARBON_FIBRE_BLOCK)) + .unlockedBy(MItemTags.CARBON_PLATES) + .unlockedBy(MItems.CARBON_FIBRE_BLOCK) + .save(consumer, modLocation("carbon_mesh_from_block")) + // броня MatteryRecipe(MItems.TRITANIUM_HELMET, category = RecipeCategory.COMBAT) .row(MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt index 5a93ca0ec..45706fbfc 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt @@ -345,6 +345,14 @@ fun addDecorativesRecipes(provider: MatteryRecipeProvider, consumer: Consumer Date: Sun, 7 May 2023 16:51:55 +0300 Subject: [PATCH 0539/1199] carbon mesh and plasma repeater stored energy lang --- .../ru/dbotthepony/mc/otm/datagen/lang/English.kt | 1 + .../ru/dbotthepony/mc/otm/datagen/lang/Russian.kt | 1 + .../mc/otm/item/weapon/PlasmaWeaponItem.kt | 11 ++--------- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index ac35140e7..fd1b25172 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -548,6 +548,7 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.MIRROR, "description", "I can clearly see my own reflection in this mirror") add(MItems.REINFORCED_TRITANIUM_PLATE, "Reinforced Tritanium Plate") add(MItems.REINFORCED_TRITANIUM_PLATE, "description", "An armor plate, reinforced to withstand great kinetic forces") + add(MItems.CARBON_MESH, "Carbon Mesh") add(MItems.GRAVITATIONAL_DISRUPTOR, "Gravitational Disruptor") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index dd46dbd90..304a43b57 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -553,6 +553,7 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.MIRROR, "description", "Я могу очень отчётливо видеть своё отражение в этом зеркале") add(MItems.REINFORCED_TRITANIUM_PLATE, "Укреплённая тритановая пластина") add(MItems.REINFORCED_TRITANIUM_PLATE, "description", "Бронированная пластина, усиленная что бы выдержать большие кинетические силы") + add(MItems.CARBON_MESH, "Углеродная сетка") add(MItems.GRAVITATIONAL_DISRUPTOR, "Антигравитационный маяк") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt index e33c8662d..71eccdb0e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt @@ -18,6 +18,7 @@ import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.* import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.ItemEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.energy.getBarColor import ru.dbotthepony.mc.otm.capability.energy.getBarWidth import ru.dbotthepony.mc.otm.core.* @@ -181,15 +182,7 @@ abstract class PlasmaWeaponItem(tables: KClass, pr ) { super.appendHoverText(itemStack, p_41422_, p_41423_, p_41424_) - itemStack.getCapability(MatteryCapability.ENERGY).ifPresentK { - p_41423_.add( - TranslatableComponent( - "otm.item.power.normal.storage", - it.batteryLevel.formatPower(), - it.maxBatteryLevel.formatPower() - ).withStyle(ChatFormatting.GRAY) - ) - } + ItemEnergyStorageImpl.appendHoverText(itemStack, p_41423_) } fun energyData(itemStack: ItemStack) = itemStack.matteryEnergy as PlasmaWeaponEnergy From 0098302f398beccda4cc2d953ddecec4518f7699 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sun, 7 May 2023 16:54:28 +0300 Subject: [PATCH 0540/1199] =?UTF-8?q?YuRaNnNzZZ=20=E2=80=94=20=D0=92=D1=87?= =?UTF-8?q?=D0=B5=D1=80=D0=B0,=20=D0=B2=2015:08=20=D0=B1=D0=BE=D1=82=D0=B8?= =?UTF-8?q?=D0=BD=D0=BA=D0=B8=20=D0=BF=D1=80=D0=B8=D0=B2=D0=B0=D1=80=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=B4=D1=80=D1=83=D0=B3=20=D0=BA=20=D0=B4=D1=80?= =?UTF-8?q?=D1=83=D0=B3=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/datagen/recipes/CraftingTableRecipes.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index 922c2e42a..16c140657 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -212,7 +212,7 @@ fun addCraftingTableRecipes(consumer: Consumer) { MatteryRecipe(MItems.TRITANIUM_BOOTS, category = RecipeCategory.COMBAT) .row(MItemTags.REINFORCED_TRITANIUM_PLATES, Items.LEATHER_BOOTS, MItemTags.REINFORCED_TRITANIUM_PLATES) - .row(MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES) + .rowAC(MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES) .unlockedBy(MItemTags.REINFORCED_TRITANIUM_PLATES) .build(consumer) @@ -239,7 +239,7 @@ fun addCraftingTableRecipes(consumer: Consumer) { MatteryRecipe(MItems.SIMPLE_TRITANIUM_BOOTS, category = RecipeCategory.COMBAT) .rowAC(MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS) - .row(MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS) + .rowAC(MItemTags.TRITANIUM_INGOTS, MItemTags.TRITANIUM_INGOTS) .unlockedBy(MItemTags.TRITANIUM_INGOTS) .build(consumer) From be43c59a2d8c6378b2344702e4aef1bacdc3ddfe Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sun, 7 May 2023 17:09:58 +0300 Subject: [PATCH 0541/1199] bytecode moment (fix #249) --- .../mc/otm/mixin/MixinMinecraft.java | 29 ++++++++ src/main/resources/coremods/code_injector.js | 68 ------------------- .../overdrive_that_matters.mixins.json | 3 +- 3 files changed, 31 insertions(+), 69 deletions(-) create mode 100644 src/main/java/ru/dbotthepony/mc/otm/mixin/MixinMinecraft.java diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinMinecraft.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinMinecraft.java new file mode 100644 index 000000000..bbf7892bd --- /dev/null +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinMinecraft.java @@ -0,0 +1,29 @@ +package ru.dbotthepony.mc.otm.mixin; + +import net.minecraft.client.Minecraft; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability; + +@Mixin(Minecraft.class) +public class MixinMinecraft { + @Redirect( + method = "pickBlock()V", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/player/Inventory;findSlotMatchingItem(Lnet/minecraft/world/item/ItemStack;)I" + ) + ) + private int pickBlock(Inventory inventory, ItemStack itemStack) { + int i = inventory.findSlotMatchingItem(itemStack); + + MatteryPlayerCapability.pickBlockHook(i, itemStack); + + return i; + } +} diff --git a/src/main/resources/coremods/code_injector.js b/src/main/resources/coremods/code_injector.js index 77b59d722..e1c5310d5 100644 --- a/src/main/resources/coremods/code_injector.js +++ b/src/main/resources/coremods/code_injector.js @@ -681,74 +681,6 @@ function initializeCoreMod() { 'transformer': patchBlendFunc }, - 'Minecraft#pickBlock patch for exosuit': - method('net.minecraft.client.Minecraft.m_91280_()V', function(node) { - // 275: invokevirtual #7672 // Method net/minecraft/world/entity/Entity.getType:()Lnet/minecraft/world/entity/EntityType; - // 278: invokevirtual #7667 // Method net/minecraft/core/DefaultedRegistry.getKey:(Ljava/lang/Object;)Lnet/minecraft/resources/ResourceLocation; - // 281: invokevirtual #4475 // Method net/minecraft/resources/ResourceLocation.toString:()Ljava/lang/String; - // 284: astore 5 - // 286: getstatic #5986 // Field LOGGER:Lorg/slf4j/Logger; - // 289: ldc_w #4484 // String Picking on: [{}] {} gave null item - // 292: aload_3 - // 293: aload 5 - // 295: invokeinterface #3145, 4 // InterfaceMethod org/slf4j/Logger.warn:(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V - // 300: goto 405 - // 303: aload_0 - // 304: getfield #6654 // Field player:Lnet/minecraft/client/player/LocalPlayer; - // 307: invokevirtual #7409 // Method net/minecraft/client/player/LocalPlayer.getInventory:()Lnet/minecraft/world/entity/player/Inventory; - // 310: astore 5 - // 312: aload_2 - // 313: ifnull 324 - // 316: aload_0 - // 317: aload 4 - // 319: aload_2 - // 320: invokevirtual #7675 // Method addCustomNbtData:(Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/level/block/entity/BlockEntity;)Lnet/minecraft/world/item/ItemStack; - // 323: pop - // 324: aload 5 - // 326: aload 4 - // 328: invokevirtual #7678 // Method net/minecraft/world/entity/player/Inventory.findSlotMatchingItem:(Lnet/minecraft/world/item/ItemStack;)I - // 331: istore 6 - // <-- Our target - // 333: iload_1 - // 334: ifeq 372 - // 337: aload 5 - // 339: aload 4 - // 341: invokevirtual #7681 // Method net/minecraft/world/entity/player/Inventory.setPickedItem:(Lnet/minecraft/world/item/ItemStack;)V - // 344: aload_0 - - for (var i = 0; i < node.instructions.size(); i++) { - var determinedOffset = test([ - opcodesRemapped.aload, - opcodesRemapped.getfield, - opcodesRemapped.invokevirtual, - opcodesRemapped.astore, - opcodesRemapped.aload, - opcodesRemapped.ifnull, - opcodesRemapped.aload, - opcodesRemapped.aload, - opcodesRemapped.aload, - opcodesRemapped.invokevirtual, - opcodesRemapped.pop, - opcodesRemapped.aload, - opcodesRemapped.aload, - opcodesRemapped.invokevirtual, - opcodesRemapped.istore, - ], node.instructions, i) - - if (determinedOffset != -1) { - putInstructions(node, node.instructions.get(determinedOffset), [ - new VarInsnNode(opcodesRemapped.iload, backtrack(node.instructions, determinedOffset, opcodesRemapped.istore, 0)['var']), - new VarInsnNode(opcodesRemapped.aload, backtrack(node.instructions, determinedOffset, opcodesRemapped.aload, 0)['var']), - new MethodInsnNode(opcodesRemapped.invokestatic, 'ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability', 'pickBlockHook', '(ILnet/minecraft/world/item/ItemStack;)V', false) - ]) - - break - } - } - - return node - }), - 'LevelRenderer DynamicBufferSource callback': { 'target': { 'type': 'METHOD', diff --git a/src/main/resources/overdrive_that_matters.mixins.json b/src/main/resources/overdrive_that_matters.mixins.json index 42c121a52..626eb012c 100644 --- a/src/main/resources/overdrive_that_matters.mixins.json +++ b/src/main/resources/overdrive_that_matters.mixins.json @@ -15,6 +15,7 @@ "MixinPlayer" ], "client": [ - "MixinGameRenderer" + "MixinGameRenderer", + "MixinMinecraft" ] } From 2ca00563e82ddd84dc65a011f5a9768e96199bfe Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 8 May 2023 00:09:49 +0700 Subject: [PATCH 0542/1199] Codec2Serializer.embed --- .../mc/otm/data/Codec2Serializer.kt | 20 ++++++- .../condition/ChanceWithPlaytimeCondition.kt | 44 +++++---------- .../condition/ItemInInventoryCondition.kt | 55 +++++-------------- .../mc/otm/registry/MLootItemConditions.kt | 4 +- 4 files changed, 47 insertions(+), 76 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt index d6bc931c5..dec230f36 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt @@ -10,9 +10,25 @@ import ru.dbotthepony.mc.otm.core.fromJsonStrict import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.core.toJsonStrict -class Codec2Serializer(val codec: Codec) : Serializer { +class Codec2Serializer(val codec: Codec, val embed: Boolean = true) : Serializer { override fun serialize(p_79325_: JsonObject, p_79326_: T, p_79327_: JsonSerializationContext) { - p_79325_["value"] = codec.toJsonStrict(p_79326_) + if (embed) { + val json = codec.toJsonStrict(p_79326_) + + if (json !is JsonObject) { + throw RuntimeException("It was specified to embed result from codec into target json, but codec returned ${json::class.qualifiedName}, while was expecting JsonObject") + } + + for ((k, v) in json.entrySet()) { + if (p_79325_.has(k)) { + throw RuntimeException("Codec returned object with '$k' as member, which is not allowed (it was written by upstream code into provided JsonObject)") + } + + p_79325_[k] = v + } + } else { + p_79325_["value"] = codec.toJsonStrict(p_79326_) + } } override fun deserialize(p_79323_: JsonObject, p_79324_: JsonDeserializationContext): T { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceWithPlaytimeCondition.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceWithPlaytimeCondition.kt index ba23eea7d..2a2b19d08 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceWithPlaytimeCondition.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceWithPlaytimeCondition.kt @@ -1,17 +1,13 @@ package ru.dbotthepony.mc.otm.data.condition -import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonObject -import com.google.gson.JsonPrimitive -import com.google.gson.JsonSerializationContext +import com.mojang.serialization.Codec +import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.world.level.storage.loot.LootContext -import net.minecraft.world.level.storage.loot.Serializer import net.minecraft.world.level.storage.loot.parameters.LootContextParams import net.minecraft.world.level.storage.loot.predicates.LootItemCondition import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType import ru.dbotthepony.mc.otm.capability.matteryPlayer -import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.data.Codec2Serializer import ru.dbotthepony.mc.otm.data.get import ru.dbotthepony.mc.otm.registry.MLootItemConditions @@ -52,28 +48,16 @@ data class ChanceWithPlaytimeCondition( return this } - companion object : Serializer { - override fun serialize( - p_79325_: JsonObject, - p_79326_: ChanceWithPlaytimeCondition, - p_79327_: JsonSerializationContext - ) { - p_79325_["minPlaytime"] = JsonPrimitive(p_79326_.minPlaytime) - p_79325_["maxPlaytime"] = JsonPrimitive(p_79326_.maxPlaytime) - p_79325_["minProbability"] = JsonPrimitive(p_79326_.minProbability) - p_79325_["maxProbability"] = JsonPrimitive(p_79326_.maxProbability) - } - - override fun deserialize( - p_79323_: JsonObject, - p_79324_: JsonDeserializationContext - ): ChanceWithPlaytimeCondition { - return ChanceWithPlaytimeCondition( - minPlaytime = p_79323_["minPlaytime"].asInt, - maxPlaytime = p_79323_["maxPlaytime"].asInt, - minProbability = p_79323_["minProbability"].asDouble, - maxProbability = p_79323_["maxProbability"].asDouble, - ) - } + companion object { + val SERIALIZER = Codec2Serializer( + RecordCodecBuilder.create { + it.group( + Codec.INT.optionalFieldOf("minPlaytime", 0).forGetter(ChanceWithPlaytimeCondition::minPlaytime), + Codec.INT.fieldOf("maxPlaytime").forGetter(ChanceWithPlaytimeCondition::maxPlaytime), + Codec.DOUBLE.fieldOf("minProbability").forGetter(ChanceWithPlaytimeCondition::minProbability), + Codec.DOUBLE.fieldOf("maxProbability").forGetter(ChanceWithPlaytimeCondition::maxProbability), + ).apply(it, ::ChanceWithPlaytimeCondition) + } + ) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ItemInInventoryCondition.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ItemInInventoryCondition.kt index 353f5a8c0..d4f088d3c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ItemInInventoryCondition.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ItemInInventoryCondition.kt @@ -1,23 +1,14 @@ package ru.dbotthepony.mc.otm.data.condition -import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonObject -import com.google.gson.JsonPrimitive -import com.google.gson.JsonSerializationContext -import com.google.gson.JsonSyntaxException -import net.minecraft.resources.ResourceLocation +import com.mojang.serialization.Codec +import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.Items import net.minecraft.world.level.storage.loot.LootContext -import net.minecraft.world.level.storage.loot.Serializer import net.minecraft.world.level.storage.loot.parameters.LootContextParams import net.minecraft.world.level.storage.loot.predicates.LootItemCondition import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType -import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.capability.itemsStream -import ru.dbotthepony.mc.otm.core.registryName -import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.data.Codec2Serializer import ru.dbotthepony.mc.otm.data.get import ru.dbotthepony.mc.otm.registry.MLootItemConditions @@ -65,36 +56,16 @@ data class ItemInInventoryCondition( return this } - companion object : Serializer { - override fun serialize( - p_79325_: JsonObject, - p_79326_: ItemInInventoryCondition, - p_79327_: JsonSerializationContext - ) { - p_79325_["item"] = JsonPrimitive(p_79326_.item.item.registryName!!.toString()) - p_79325_["itemCount"] = JsonPrimitive(p_79326_.item.count) - p_79325_["matchDamage"] = JsonPrimitive(p_79326_.matchDamage) - p_79325_["matchNBT"] = JsonPrimitive(p_79326_.matchNBT) - p_79325_["matchCosmetics"] = JsonPrimitive(p_79326_.matchCosmetics) - } - - override fun deserialize(p_79323_: JsonObject, p_79324_: JsonDeserializationContext): ItemInInventoryCondition { - val item = p_79323_["item"]?.asString ?: throw JsonSyntaxException("Missing item") - val itemCount = p_79323_["itemCount"]?.asInt ?: throw JsonSyntaxException("Missing itemCount") - val matchDamage = p_79323_["matchDamage"]?.asBoolean ?: false - val matchNBT = p_79323_["matchNBT"]?.asBoolean ?: false - val matchCosmetics = p_79323_["matchCosmetics"]?.asBoolean ?: true - - val getItem = ForgeRegistries.ITEMS.getValue(ResourceLocation(item)) - - if (getItem == null || getItem == Items.AIR) { - throw JsonSyntaxException("Invalid item $item") + companion object { + val SERIALIZER = Codec2Serializer( + RecordCodecBuilder.create { + it.group( + ItemStack.CODEC.fieldOf("item").forGetter(ItemInInventoryCondition::item), + Codec.BOOL.optionalFieldOf("matchDamage", false).forGetter(ItemInInventoryCondition::matchDamage), + Codec.BOOL.optionalFieldOf("matchNBT", false).forGetter(ItemInInventoryCondition::matchNBT), + Codec.BOOL.optionalFieldOf("matchCosmetics", false).forGetter(ItemInInventoryCondition::matchCosmetics), + ).apply(it, ::ItemInInventoryCondition) } - - return ItemInInventoryCondition( - ItemStack(getItem, itemCount), - matchDamage, matchNBT - ) - } + ) } } 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 9149e0b10..c74c21fa6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MLootItemConditions.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MLootItemConditions.kt @@ -17,8 +17,8 @@ object MLootItemConditions { private val registry = DeferredRegister.create(Registries.LOOT_CONDITION_TYPE, OverdriveThatMatters.MOD_ID) val HAS_EXOPACK: LootItemConditionType by registry.register("has_exopack") { LootItemConditionType(HasExoPackCondition) } - val CHANCE_WITH_PLAYTIME: LootItemConditionType by registry.register("chance_with_playtime") { LootItemConditionType(ChanceWithPlaytimeCondition) } - val ITEM_IN_INVENTORY: LootItemConditionType by registry.register("item_in_inventory") { LootItemConditionType(ItemInInventoryCondition) } + val CHANCE_WITH_PLAYTIME: LootItemConditionType by registry.register("chance_with_playtime") { LootItemConditionType(ChanceWithPlaytimeCondition.SERIALIZER) } + val ITEM_IN_INVENTORY: LootItemConditionType by registry.register("item_in_inventory") { LootItemConditionType(ItemInInventoryCondition.SERIALIZER) } val KILLED_BY_REAL_PLAYER: LootItemConditionType by registry.register("killed_by_real_player") { LootItemConditionType(KilledByRealPlayer) } val KILLED_BY_REAL_PLAYER_OR_INDIRECTLY: LootItemConditionType by registry.register("killed_by_real_player_or_indirectly") { LootItemConditionType(KilledByRealPlayerOrIndirectly) } val CHANCE: LootItemConditionType by registry.register("chance") { LootItemConditionType(ChanceCondition.Companion) } From 73e082aeeadc040f05d5a98a4f609901dc4a7d6a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 8 May 2023 00:10:10 +0700 Subject: [PATCH 0543/1199] ItemStack already has codec --- .../dbotthepony/mc/otm/data/ItemStackCodec.kt | 114 ------------------ 1 file changed, 114 deletions(-) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/ItemStackCodec.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/ItemStackCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/ItemStackCodec.kt deleted file mode 100644 index ec085f7f9..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/ItemStackCodec.kt +++ /dev/null @@ -1,114 +0,0 @@ -package ru.dbotthepony.mc.otm.data - -import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonDeserializer -import com.google.gson.JsonElement -import com.google.gson.JsonObject -import com.google.gson.JsonPrimitive -import com.google.gson.JsonSerializationContext -import com.google.gson.JsonSerializer -import com.google.gson.JsonSyntaxException -import com.google.gson.TypeAdapter -import com.google.gson.stream.JsonReader -import com.google.gson.stream.JsonToken -import com.google.gson.stream.JsonWriter -import com.mojang.datafixers.util.Pair -import com.mojang.serialization.Codec -import com.mojang.serialization.DataResult -import com.mojang.serialization.DynamicOps -import com.mojang.serialization.codecs.ListCodec -import net.minecraft.resources.ResourceLocation -import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.Items -import net.minecraftforge.registries.ForgeRegistries -import ru.dbotthepony.mc.otm.core.registryName -import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.core.set -import java.lang.reflect.Type - -object ItemStackCodec : Codec, TypeAdapter(), JsonSerializer, JsonDeserializer { - override fun encode(input: ItemStack, ops: DynamicOps, prefix: T): DataResult { - require(prefix == ops.empty()) { "Non-empty prefix: $prefix" } - - return ForgeRegistries.ITEMS.codec.encode(input.item, ops, ops.empty()).flatMap { - DataResult.success(ops.createMap(linkedMapOf( - ops.createString("id") to it, - ops.createString("count") to ops.createInt(input.count) - ))) - } - } - - override fun decode(ops: DynamicOps, input: T): DataResult> { - return ops.getMap(input).flatMap { - val item = it["id"]?.let { ForgeRegistries.ITEMS.codec.decode(ops, it) }?.result()?.orElse(null)?.first - val count = it["count"]?.let(ops::getNumberValue)?.result()?.orElse(null)?.toInt() ?: return@flatMap DataResult.error { "Invalid item count" } - - if (item == null || item == Items.AIR) { - return@flatMap DataResult.error { "Unknown item type $item" } - } - - DataResult.success(ItemStack(item, count)) - }.map { Pair.of(it, ops.empty()) } - } - - val LIST = ListCodec(this) - - override fun write(out: JsonWriter, value: ItemStack) { - out.beginObject() - - out.name("id") - out.value(value.item.registryName!!.toString()) - - out.name("count") - out.value(value.count) - - out.endObject() - } - - override fun read(reader: JsonReader): ItemStack { - reader.beginObject() - - var id: String? = null - var count: Int? = null - - while (reader.peek() != JsonToken.END_OBJECT) { - when (val it = reader.nextName()) { - "id" -> id = reader.nextString() - "count" -> count = reader.nextInt() - else -> throw JsonSyntaxException("Unknown json key $it") - } - } - - reader.endObject() - - val item = ForgeRegistries.ITEMS.getValue(ResourceLocation(id ?: return ItemStack.EMPTY)) ?: return ItemStack.EMPTY - - return ItemStack(item, count ?: 1) - } - - override fun serialize(src: ItemStack, typeOfSrc: Type, context: JsonSerializationContext): JsonElement { - return serialize(src) - } - - fun serialize(src: ItemStack): JsonElement { - return JsonObject().also { - it["id"] = JsonPrimitive(src.item.registryName!!.toString()) - it["count"] = JsonPrimitive(src.count) - } - } - - override fun deserialize(json: JsonElement, typeOfT: Type, context: JsonDeserializationContext): ItemStack { - return deserialize(json) - } - - fun deserialize(json: JsonElement): ItemStack { - if (json !is JsonObject) { - throw JsonSyntaxException("ItemStack json element must be JsonObject, ${json::class.qualifiedName} given") - } - - val item = ForgeRegistries.ITEMS.getValue(ResourceLocation(json["id"]?.asString ?: return ItemStack.EMPTY)) ?: return ItemStack.EMPTY - val count = json["count"]?.asInt ?: 1 - - return ItemStack(item, count) - } -} From d5bbd717b600bd70cca03ef138d3a887831808c5 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 8 May 2023 09:22:15 +0700 Subject: [PATCH 0544/1199] oops --- .../kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt index dec230f36..f42659e5e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt @@ -32,6 +32,10 @@ class Codec2Serializer(val codec: Codec, val embed: Boolean = true) } override fun deserialize(p_79323_: JsonObject, p_79324_: JsonDeserializationContext): T { - return codec.fromJsonStrict(p_79323_["value"] ?: throw JsonSyntaxException("Missing 'value' element")) + if (embed) { + return codec.fromJsonStrict(p_79323_) + } else { + return codec.fromJsonStrict(p_79323_["value"] ?: throw JsonSyntaxException("Missing 'value' element")) + } } } From f71bed5daee4352055c80d7231affdf4c4d04bbf Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 8 May 2023 09:38:57 +0700 Subject: [PATCH 0545/1199] Use prefix to merge result from codec with result json --- .../dbotthepony/mc/otm/core/UnOverengineering.kt | 16 ++++++++-------- .../dbotthepony/mc/otm/data/Codec2Serializer.kt | 16 ++++++---------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt index e3130551a..354dd0ee5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt @@ -36,12 +36,12 @@ fun Codec.fromJsonStrict(value: JsonElement): V { return decode(JsonOps.INSTANCE, value).get().map({ left -> left.first }, { throw JsonSyntaxException("Error decoding element: ${it.message()}") }) } -fun Codec.toJson(value: V): JsonElement? { - return encode(value, JsonOps.INSTANCE, JsonOps.INSTANCE.empty()).get().map({ it }, { null }) +fun Codec.toJson(value: V, prefix: JsonElement = JsonOps.INSTANCE.empty()): JsonElement? { + return encode(value, JsonOps.INSTANCE, prefix).get().map({ it }, { null }) } -fun Codec.toJsonStrict(value: V): JsonElement { - return encode(value, JsonOps.INSTANCE, JsonOps.INSTANCE.empty()).get().map({ it }, { throw RuntimeException("Error encoding element: ${it.message()}") }) +fun Codec.toJsonStrict(value: V, prefix: JsonElement = JsonOps.INSTANCE.empty()): JsonElement { + return encode(value, JsonOps.INSTANCE, prefix).get().map({ it }, { throw RuntimeException("Error encoding element: ${it.message()}") }) } fun Codec.fromNbt(value: Tag): V? { @@ -52,12 +52,12 @@ fun Codec.fromNbtStrict(value: Tag): V { return decode(NbtOps.INSTANCE, value).get().map({ left -> left.first }, { throw RuntimeException("Error decoding element: ${it.message()}") }) } -fun Codec.toNbt(value: V): Tag? { - return encode(value, NbtOps.INSTANCE, NbtOps.INSTANCE.empty()).get().map({ it }, { null }) +fun Codec.toNbt(value: V, prefix: Tag = NbtOps.INSTANCE.empty()): Tag? { + return encode(value, NbtOps.INSTANCE, prefix).get().map({ it }, { null }) } -fun Codec.toNbtStrict(value: V): Tag { - return encode(value, NbtOps.INSTANCE, NbtOps.INSTANCE.empty()).get().map({ it }, { throw RuntimeException("Error encoding element: ${it.message()}") }) +fun Codec.toNbtStrict(value: V, prefix: Tag = NbtOps.INSTANCE.empty()): Tag { + return encode(value, NbtOps.INSTANCE, prefix).get().map({ it }, { throw RuntimeException("Error encoding element: ${it.message()}") }) } // 1.19 being 1.19 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt index f42659e5e..6d026f219 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt @@ -13,19 +13,15 @@ import ru.dbotthepony.mc.otm.core.toJsonStrict class Codec2Serializer(val codec: Codec, val embed: Boolean = true) : Serializer { override fun serialize(p_79325_: JsonObject, p_79326_: T, p_79327_: JsonSerializationContext) { if (embed) { - val json = codec.toJsonStrict(p_79326_) + val result = codec.toJsonStrict(p_79326_, p_79325_) - if (json !is JsonObject) { - throw RuntimeException("It was specified to embed result from codec into target json, but codec returned ${json::class.qualifiedName}, while was expecting JsonObject") + if (result !is JsonObject) { + throw RuntimeException("Expected JsonObject from codec, got ${result::class.qualifiedName}") } - for ((k, v) in json.entrySet()) { - if (p_79325_.has(k)) { - throw RuntimeException("Codec returned object with '$k' as member, which is not allowed (it was written by upstream code into provided JsonObject)") - } - - p_79325_[k] = v - } + val keys = ArrayList(p_79325_.keySet()) + for (k in keys) p_79325_.remove(k) + for ((k, v) in result.entrySet()) p_79325_[k] = v } else { p_79325_["value"] = codec.toJsonStrict(p_79326_) } From 8d96615ddd50f01cfd1f85d1d66c8724d47f1de2 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Mon, 8 May 2023 16:20:41 +0300 Subject: [PATCH 0546/1199] fix smelting/blasting recipe locations and move direct ResourceLocation calls to modLocation for datagen --- .../mc/otm/datagen/DecorativeData.kt | 18 +++++----- .../mc/otm/datagen/blocks/Banks.kt | 4 +-- .../mc/otm/datagen/blocks/BlockStates.kt | 29 +++++++-------- .../otm/datagen/blocks/ComplexBlockStates.kt | 35 +++++++++---------- .../blocks/MatteryBlockStateProvider.kt | 4 +-- .../mc/otm/datagen/items/ItemModels.kt | 13 +++---- .../datagen/items/MatteryItemModelProvider.kt | 31 ++++++++-------- .../datagen/models/MatteryModelProvider.kt | 25 ++++++------- .../mc/otm/datagen/recipes/BlastingRecipes.kt | 4 +-- .../otm/datagen/recipes/DecorativesRecipes.kt | 6 +--- .../mc/otm/datagen/recipes/MatteryRecipe.kt | 3 +- .../datagen/recipes/MatteryRecipeProvider.kt | 6 ++-- .../mc/otm/datagen/recipes/OreRecipes.kt | 15 ++++---- 13 files changed, 88 insertions(+), 105 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt index bc1ecb353..0a921075f 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.datagen -import net.minecraft.resources.ResourceLocation import net.minecraft.world.level.block.AnvilBlock import net.minecraft.world.level.block.SlabBlock import net.minecraft.world.level.block.StairBlock @@ -9,7 +8,6 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties import net.minecraftforge.client.model.generators.BlockModelBuilder import net.minecraftforge.client.model.generators.ConfiguredModel import net.minecraftforge.client.model.generators.ModelFile -import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.math.xRotationBlockstateNorth @@ -200,13 +198,13 @@ fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelPr var labLampOff: BlockModelBuilder? = null blockModelProvider.exec { - val top = ResourceLocation(DataGen.MOD_ID, "block/decorative/metal_beam_top") + val top = modLocation("block/decorative/metal_beam_top") labLampOn = it.cube( MBlocks.LABORATORY_LAMP.registryName!!.path, top, top, - ResourceLocation(DataGen.MOD_ID, "block/decorative/laboratory_lamp_front"), + modLocation("block/decorative/laboratory_lamp_front"), top, top, top, @@ -216,7 +214,7 @@ fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelPr MBlocks.LABORATORY_LAMP.registryName!!.path + "_unlit", top, top, - ResourceLocation(DataGen.MOD_ID, "block/decorative/laboratory_lamp_front_off"), + modLocation("block/decorative/laboratory_lamp_front_off"), top, top, top, @@ -248,11 +246,11 @@ fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelPr blockModelProvider.exec { for (crate in MRegistry.CARGO_CRATES.blocks.values) { - it.withExistingParent("${crate.registryName!!.path}_closed", ResourceLocation(OverdriveThatMatters.MOD_ID, "${MNames.CARGO_CRATE}_closed")) + it.withExistingParent("${crate.registryName!!.path}_closed", modLocation("${MNames.CARGO_CRATE}_closed")) .texture("texture", "block/cargo_crates/${crate.registryName!!.path}") .texture("particle", "block/cargo_crates/${crate.registryName!!.path}") - it.withExistingParent("${crate.registryName!!.path}_open", ResourceLocation(OverdriveThatMatters.MOD_ID, "${MNames.CARGO_CRATE}_open")) + it.withExistingParent("${crate.registryName!!.path}_open", modLocation("${MNames.CARGO_CRATE}_open")) .texture("texture", "block/cargo_crates/${crate.registryName!!.path}") .texture("particle", "block/cargo_crates/${crate.registryName!!.path}") } @@ -273,12 +271,12 @@ fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelPr for ((color, glass) in MRegistry.INDUSTRIAL_GLASS_PANE.allBlocks) { val name = MRegistry.INDUSTRIAL_GLASS.allBlocks[color]!!.registryName!!.path - val textureSide = ResourceLocation(DataGen.MOD_ID, "block/decorative/$name") - val textureRailing = ResourceLocation(DataGen.MOD_ID, "block/decorative/industrial_glass_frame") + val textureSide = modLocation("block/decorative/$name") + val textureRailing = modLocation("block/decorative/industrial_glass_frame") DataGen.pane(glass, textureSide, textureRailing) } - DataGen.bars(MBlocks.TRITANIUM_BARS, ResourceLocation(DataGen.MOD_ID, "block/decorative/tritanium_bars")) + DataGen.bars(MBlocks.TRITANIUM_BARS, modLocation("block/decorative/tritanium_bars")) blockStateProvider.block(MBlocks.ENGINE) itemModelProvider.block(MItems.ENGINE) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt index 20884bc5d..66444f883 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.datagen.blocks -import net.minecraft.resources.ResourceLocation import net.minecraft.world.level.block.Block import net.minecraftforge.client.model.generators.BlockStateProvider import net.minecraftforge.client.model.generators.ConfiguredModel @@ -9,6 +8,7 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.math.yRotationBlockstateNorth import ru.dbotthepony.mc.otm.datagen.DataGen +import ru.dbotthepony.mc.otm.datagen.modLocation import ru.dbotthepony.mc.otm.registry.MBlocks private fun nothingOrNumber(input: Int): String { @@ -27,7 +27,7 @@ open class BatteryBankProvider(event: GatherDataEvent) : BlockStateProvider(even with(getVariantBuilder(registry)) { forAllStates { ConfiguredModel.builder() - .modelFile(models().getExistingFile(ResourceLocation("overdrive_that_matters:block/$block"))) + .modelFile(models().getExistingFile(modLocation("block/$block"))) .rotationY(it[BlockRotationFreedom.ONE.property].front.yRotationBlockstateNorth()) .build() } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt index 6fb27fc90..f985ac4e1 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt @@ -1,10 +1,8 @@ package ru.dbotthepony.mc.otm.datagen.blocks -import net.minecraft.resources.ResourceLocation import net.minecraft.world.level.block.state.properties.BlockStateProperties import net.minecraft.world.level.block.state.properties.DoubleBlockHalf import net.minecraftforge.client.model.generators.ConfiguredModel -import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.block.CableBlock import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock import ru.dbotthepony.mc.otm.block.entity.WorkerState @@ -50,7 +48,7 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { with(provider.getMultipartBuilder(MBlocks.MATTER_BOTTLER)) { for (dir in BlockRotationFreedom.ONE.possibleValues) { for (enum in WorkerState.SEMI_WORKER_STATE.possibleValues) { - part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_bottler_${enum.name.lowercase()}"))) + part().modelFile(provider.models().getExistingFile(modLocation("matter_bottler_${enum.name.lowercase()}"))) .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() .condition(BlockRotationFreedom.ONE.property, dir) @@ -61,14 +59,14 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { for (dir in BlockRotationFreedom.ONE.possibleValues) { for (enum in MatterBottlerBlock.SLOT_PROPERTIES) { - part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_bottler_${enum.name}_open"))) + part().modelFile(provider.models().getExistingFile(modLocation("matter_bottler_${enum.name}_open"))) .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() .condition(BlockRotationFreedom.ONE.property, dir) .condition(enum, false) .end() - part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_bottler_${enum.name}_closed"))) + part().modelFile(provider.models().getExistingFile(modLocation("matter_bottler_${enum.name}_closed"))) .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() .condition(BlockRotationFreedom.ONE.property, dir) @@ -98,8 +96,7 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { return@forAllStates arrayOf( ConfiguredModel.builder() .modelFile(provider.models().getExistingFile( - ResourceLocation( - OverdriveThatMatters.MOD_ID, "${crate.registryName!!.path}_${if (it.getValue( + modLocation("${crate.registryName!!.path}_${if (it.getValue( CargoCrateBlock.IS_OPEN)) "open" else "closed"}") )) .rotationY(it.getValue(BlockRotationFreedom.ONE.property).front.yRotationBlockstateNorth()) @@ -110,14 +107,14 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { with(provider.getMultipartBuilder(MBlocks.STORAGE_BUS)) { for (dir in BlockRotationFreedom.TWO.possibleValues) { - part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_bus"))) + part().modelFile(provider.models().getExistingFile(modLocation("storage_bus"))) .rotationX(dir.front.xRotationBlockstateNorth()) .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() .condition(BlockRotationFreedom.TWO.property, dir) .end() - part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_connection"))) + part().modelFile(provider.models().getExistingFile(modLocation("storage_cable_connection"))) .rotationX(dir.front.xRotationBlockstateSouth()) .rotationY(dir.front.yRotationBlockstateSouth()) .addModel() @@ -125,20 +122,20 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { .end() } - part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_core"))) + part().modelFile(provider.models().getExistingFile(modLocation("storage_cable_core"))) .addModel().end() } with(provider.getMultipartBuilder(MBlocks.STORAGE_IMPORTER)) { for (dir in BlockRotationFreedom.TWO.possibleValues) { - part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_importer"))) + part().modelFile(provider.models().getExistingFile(modLocation("storage_importer"))) .rotationX(dir.front.xRotationBlockstateNorth()) .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() .condition(BlockRotationFreedom.TWO.property, dir) .end() - part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_connection"))) + part().modelFile(provider.models().getExistingFile(modLocation("storage_cable_connection"))) .rotationX(dir.front.xRotationBlockstateSouth()) .rotationY(dir.front.yRotationBlockstateSouth()) .addModel() @@ -146,20 +143,20 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { .end() } - part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_core"))) + part().modelFile(provider.models().getExistingFile(modLocation("storage_cable_core"))) .addModel().end() } with(provider.getMultipartBuilder(MBlocks.STORAGE_EXPORTER)) { for (dir in BlockRotationFreedom.TWO.possibleValues) { - part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_exporter"))) + part().modelFile(provider.models().getExistingFile(modLocation("storage_exporter"))) .rotationX(dir.front.xRotationBlockstateNorth()) .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() .condition(BlockRotationFreedom.TWO.property, dir) .end() - part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_connection"))) + part().modelFile(provider.models().getExistingFile(modLocation("storage_cable_connection"))) .rotationX(dir.front.xRotationBlockstateSouth()) .rotationY(dir.front.yRotationBlockstateSouth()) .addModel() @@ -167,7 +164,7 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { .end() } - part().modelFile(provider.models().getExistingFile(ResourceLocation(OverdriveThatMatters.MOD_ID, "storage_cable_core"))) + part().modelFile(provider.models().getExistingFile(modLocation("storage_cable_core"))) .addModel().end() } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt index 16711d918..73ee45bf9 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt @@ -1,21 +1,20 @@ package ru.dbotthepony.mc.otm.datagen.blocks import net.minecraft.core.Direction -import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.block.tech.EnergyCounterBlock import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.matter.PatternStorageBlock import ru.dbotthepony.mc.otm.block.storage.DriveViewerBlock import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.math.yRotationBlockstateNorth -import ru.dbotthepony.mc.otm.datagen.DataGen.MOD_ID +import ru.dbotthepony.mc.otm.datagen.modLocation import ru.dbotthepony.mc.otm.registry.MBlocks fun addComplexBlockStates(provider: MatteryBlockStateProvider) { with(provider.getMultipartBuilder(MBlocks.DRIVE_VIEWER)) { for (facing in BlockRotationFreedom.ONE.possibleValues) { part() - .modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/drive_viewer_drive_part"))) + .modelFile(provider.models().getExistingFile(modLocation("block/drive_viewer_drive_part"))) .rotationY(facing.front.yRotationBlockstateNorth()) .addModel() .condition(BlockRotationFreedom.ONE.property, facing) @@ -23,7 +22,7 @@ fun addComplexBlockStates(provider: MatteryBlockStateProvider) { for (workState in WorkerState.SEMI_WORKER_STATE.possibleValues) { part() - .modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/drive_viewer_${workState.name.lowercase()}"))) + .modelFile(provider.models().getExistingFile(modLocation("block/drive_viewer_${workState.name.lowercase()}"))) .rotationY(facing.front.yRotationBlockstateNorth()) .addModel() .condition(WorkerState.SEMI_WORKER_STATE, workState) @@ -35,14 +34,14 @@ fun addComplexBlockStates(provider: MatteryBlockStateProvider) { with(provider.getMultipartBuilder(MBlocks.PATTERN_STORAGE)) { for (facing in BlockRotationFreedom.ONE.possibleValues) { part() - .modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/pattern_storage"))) + .modelFile(provider.models().getExistingFile(modLocation("block/pattern_storage"))) .rotationY(facing.front.yRotationBlockstateNorth()) .addModel() .condition(BlockRotationFreedom.ONE.property, facing) for (i in 0 .. 7) { part() - .modelFile(provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/pattern/model$i"))) + .modelFile(provider.models().getExistingFile(modLocation("block/pattern/model$i"))) .rotationY(facing.front.yRotationBlockstateNorth()) .addModel() .condition(BlockRotationFreedom.ONE.property, facing) @@ -53,20 +52,20 @@ fun addComplexBlockStates(provider: MatteryBlockStateProvider) { with(provider.getMultipartBuilder(MBlocks.ENERGY_COUNTER)) { // даваааййй - val up = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_up")) - val down = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_down")) - val west = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_west")) - val east = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_east")) + val up = provider.models().getExistingFile(modLocation("block/energy_counter_up")) + val down = provider.models().getExistingFile(modLocation("block/energy_counter_down")) + val west = provider.models().getExistingFile(modLocation("block/energy_counter_west")) + val east = provider.models().getExistingFile(modLocation("block/energy_counter_east")) // ДАААА ДАВАЙЙ ДАААВАААЙЙЙЙЙЙ - val north = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_north")) - val northDown = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_north_down")) - val northEast = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_north_east")) - val northWest = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_north_west")) - val south = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_south")) - val southDown = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_south_down")) - val southEast = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_south_east")) - val southWest = provider.models().getExistingFile(ResourceLocation(MOD_ID, "block/energy_counter_south_west")) + val north = provider.models().getExistingFile(modLocation("block/energy_counter_north")) + val northDown = provider.models().getExistingFile(modLocation("block/energy_counter_north_down")) + val northEast = provider.models().getExistingFile(modLocation("block/energy_counter_north_east")) + val northWest = provider.models().getExistingFile(modLocation("block/energy_counter_north_west")) + val south = provider.models().getExistingFile(modLocation("block/energy_counter_south")) + val southDown = provider.models().getExistingFile(modLocation("block/energy_counter_south_down")) + val southEast = provider.models().getExistingFile(modLocation("block/energy_counter_south_east")) + val southWest = provider.models().getExistingFile(modLocation("block/energy_counter_south_west")) for (dir in arrayOf(Direction.EAST, Direction.WEST, Direction.SOUTH, Direction.NORTH)) { part().modelFile(down).rotationY(dir.yRotationBlockstateNorth()).addModel().condition(EnergyCounterBlock.INPUT_DIRECTION, Direction.UP).condition(EnergyCounterBlock.IF_DIRECTION, dir) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt index 90babe7c9..b9b99e438 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.datagen.blocks -import net.minecraft.resources.ResourceLocation import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.client.model.generators.BlockStateProvider @@ -13,6 +12,7 @@ import ru.dbotthepony.mc.otm.core.math.xRotationBlockstateNorth import ru.dbotthepony.mc.otm.core.math.yRotationBlockstateNorth import ru.dbotthepony.mc.otm.datagen.DataGen import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.datagen.modLocation import java.util.LinkedList typealias BlockStateTransform = (state: BlockState, builder: ConfiguredModel.Builder<*>, path: String) -> String? @@ -60,7 +60,7 @@ class MatteryBlockStateProvider(event: GatherDataEvent) : BlockStateProvider(eve var modelPath = initialTransform(it, "block/${block.registryName!!.path}", builder) modelPath = func(it, builder, modelPath) ?: modelPath - builder.modelFile(models().getExistingFile(ResourceLocation(DataGen.MOD_ID, modelPath))) + builder.modelFile(models().getExistingFile(modLocation(modelPath))) return@forAllStates builder.build() } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index 17f3f29e0..69ab5482e 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -1,11 +1,8 @@ package ru.dbotthepony.mc.otm.datagen.items -import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.DyeColor import ru.dbotthepony.mc.otm.core.registryName -import ru.dbotthepony.mc.otm.datagen.DataGen import ru.dbotthepony.mc.otm.datagen.modLocation -import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRegistry @@ -25,7 +22,7 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.block(MItems.CARBON_FIBRE_BLOCK) provider.block(MItems.METAL_JUNK) provider.block(MItems.METAL_MESH) - provider.generatedTranslucent(MItems.TRITANIUM_BARS, ResourceLocation(DataGen.MOD_ID, "block/decorative/tritanium_bars")) + provider.generatedTranslucent(MItems.TRITANIUM_BARS, modLocation("block/decorative/tritanium_bars")) provider.block(MItems.DEEPSLATE_TRITANIUM_ORE) provider.block(MItems.TRITANIUM_ORE) provider.block(MItems.TRITANIUM_STRIPED_BLOCK) @@ -47,7 +44,7 @@ fun addItemModels(provider: MatteryItemModelProvider) { } for ((color, glass) in MRegistry.INDUSTRIAL_GLASS_PANE.allItems) { - provider.generatedTranslucent(glass, ResourceLocation(DataGen.MOD_ID, "block/decorative/${MRegistry.INDUSTRIAL_GLASS.allItems[color]!!.registryName!!.path}")) + provider.generatedTranslucent(glass, modLocation("block/decorative/${MRegistry.INDUSTRIAL_GLASS.allItems[color]!!.registryName!!.path}")) } provider.blocks(MRegistry.DECORATIVE_CRATE.allItems.values) @@ -95,9 +92,9 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.generatedTiered(MItems.BATTERIES, "battery_tier") provider.generated(MItems.BATTERY_CREATIVE) - provider.generated(MItems.MATTER_CAPACITOR_BASIC, ResourceLocation(DataGen.MOD_ID, "item/matter_capacitor_tier1")) - provider.generated(MItems.MATTER_CAPACITOR_NORMAL, ResourceLocation(DataGen.MOD_ID, "item/matter_capacitor_tier2")) - provider.generated(MItems.MATTER_CAPACITOR_DENSE, ResourceLocation(DataGen.MOD_ID, "item/matter_capacitor_tier3")) + provider.generated(MItems.MATTER_CAPACITOR_BASIC, modLocation("item/matter_capacitor_tier1")) + provider.generated(MItems.MATTER_CAPACITOR_NORMAL, modLocation("item/matter_capacitor_tier2")) + provider.generated(MItems.MATTER_CAPACITOR_DENSE, modLocation("item/matter_capacitor_tier3")) provider.generated(MItems.MATTER_CAPACITOR_CREATIVE) provider.generated(MItems.QUANTUM_BATTERY) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt index 75e41c5d2..643c6e77b 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt @@ -7,6 +7,7 @@ import net.minecraftforge.data.event.GatherDataEvent import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.datagen.DataGen import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.datagen.modLocation import java.util.LinkedList class MatteryItemModelProvider(event: GatherDataEvent) : ItemModelProvider(event.generator.packOutput, DataGen.MOD_ID, event.existingFileHelper) { @@ -23,8 +24,8 @@ class MatteryItemModelProvider(event: GatherDataEvent) : ItemModelProvider(event } } - fun block(item: Item) = exec { withExistingParent(item.registryName!!.path, ResourceLocation(DataGen.MOD_ID, "block/${item.registryName!!.path}")) } - fun block(item: Item, path: String) = exec { withExistingParent(item.registryName!!.path, ResourceLocation(DataGen.MOD_ID, "block/$path")) } + fun block(item: Item) = exec { withExistingParent(item.registryName!!.path, modLocation("block/${item.registryName!!.path}")) } + fun block(item: Item, path: String) = exec { withExistingParent(item.registryName!!.path, modLocation("block/$path")) } fun blocks(vararg items: Item) = items.forEach(this::block) fun blocks(items: Collection) = items.forEach(this::block) @@ -40,18 +41,18 @@ class MatteryItemModelProvider(event: GatherDataEvent) : ItemModelProvider(event withExistingParent(item.registryName!!.path, HANDHELD).texture("layer0", texture) } - fun generated(item: Item) = generated(item, ResourceLocation(DataGen.MOD_ID, "item/${item.registryName!!.path}")) - fun generated(vararg items: Item) = items.forEach { generated(it, ResourceLocation(DataGen.MOD_ID, "item/${it.registryName!!.path}")) } - fun KOT(vararg items: Item) = items.forEach { generated(it, ResourceLocation(DataGen.MOD_ID, "block/ph_kitty")) } - fun generated(items: Collection) = items.forEach { generated(it, ResourceLocation(DataGen.MOD_ID, "item/${it.registryName!!.path}")) } - fun generatedBlock(vararg items: Item) = items.forEach { generated(it, ResourceLocation(DataGen.MOD_ID, "block/${it.registryName!!.path}")) } - fun generatedBlockDecorative(vararg items: Item) = items.forEach { generated(it, ResourceLocation(DataGen.MOD_ID, "block/decorative/${it.registryName!!.path}")) } - fun handheld(vararg items: Item) = items.forEach { handheld(it, ResourceLocation(DataGen.MOD_ID, "item/${it.registryName!!.path}")) } - fun handheld(items: Collection) = items.forEach { handheld(it, ResourceLocation(DataGen.MOD_ID, "item/${it.registryName!!.path}")) } + fun generated(item: Item) = generated(item, modLocation("item/${item.registryName!!.path}")) + fun generated(vararg items: Item) = items.forEach { generated(it, modLocation("item/${it.registryName!!.path}")) } + fun KOT(vararg items: Item) = items.forEach { generated(it, modLocation("block/ph_kitty")) } + fun generated(items: Collection) = items.forEach { generated(it, modLocation("item/${it.registryName!!.path}")) } + fun generatedBlock(vararg items: Item) = items.forEach { generated(it, modLocation("block/${it.registryName!!.path}")) } + fun generatedBlockDecorative(vararg items: Item) = items.forEach { generated(it, modLocation("block/decorative/${it.registryName!!.path}")) } + fun handheld(vararg items: Item) = items.forEach { handheld(it, modLocation("item/${it.registryName!!.path}")) } + fun handheld(items: Collection) = items.forEach { handheld(it, modLocation("item/${it.registryName!!.path}")) } - fun generated(item: Item, prefix: String) = generated(item, ResourceLocation(DataGen.MOD_ID, "item/${prefix}${item.registryName!!.path}")) - fun generatedStrict(item: Item, path: String) = generated(item, ResourceLocation(DataGen.MOD_ID, "item/$path")) - fun handheld(item: Item, prefix: String) = handheld(item, ResourceLocation(DataGen.MOD_ID, "item/${prefix}${item.registryName!!.path}")) + fun generated(item: Item, prefix: String) = generated(item, modLocation("item/${prefix}${item.registryName!!.path}")) + fun generatedStrict(item: Item, path: String) = generated(item, modLocation("item/$path")) + fun handheld(item: Item, prefix: String) = handheld(item, modLocation("item/${prefix}${item.registryName!!.path}")) fun component(item: Item) = generated(item, "component/") fun components(vararg items: Item) = items.forEach(this::component) @@ -63,7 +64,7 @@ class MatteryItemModelProvider(event: GatherDataEvent) : ItemModelProvider(event var i = 0 for (item in items) { - generated(item, ResourceLocation(DataGen.MOD_ID, "item/$prefix$i")) + generated(item, modLocation("item/$prefix$i")) i++ } } @@ -72,7 +73,7 @@ class MatteryItemModelProvider(event: GatherDataEvent) : ItemModelProvider(event var i = 0 for (item in items) { - generated(item, ResourceLocation(DataGen.MOD_ID, "item/$prefix$i")) + generated(item, modLocation("item/$prefix$i")) i++ } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelProvider.kt index cec8563c5..f2cdb8a5e 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/models/MatteryModelProvider.kt @@ -1,16 +1,11 @@ package ru.dbotthepony.mc.otm.datagen.models -import com.google.gson.JsonObject -import com.google.gson.JsonParser -import net.minecraft.resources.ResourceLocation -import net.minecraft.server.packs.PackType import net.minecraft.world.level.block.Block -import net.minecraft.world.level.block.DoorBlock import net.minecraftforge.client.model.generators.BlockModelProvider -import net.minecraftforge.client.model.generators.ModelProvider import net.minecraftforge.data.event.GatherDataEvent import ru.dbotthepony.mc.otm.datagen.DataGen import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.datagen.modLocation import java.util.LinkedList class MatteryBlockModelProvider(event: GatherDataEvent) : BlockModelProvider(event.generator.packOutput, DataGen.MOD_ID, event.existingFileHelper) { @@ -33,7 +28,7 @@ class MatteryBlockModelProvider(event: GatherDataEvent) : BlockModelProvider(eve fun decorativeGlassAll(blocks: Collection) { for (block in blocks) { exec { - cubeAll(block.registryName!!.path, ResourceLocation(DataGen.MOD_ID, "block/decorative/${block.registryName!!.path}")).renderType("translucent") + cubeAll(block.registryName!!.path, modLocation("block/decorative/${block.registryName!!.path}")).renderType("translucent") } } } @@ -41,7 +36,7 @@ class MatteryBlockModelProvider(event: GatherDataEvent) : BlockModelProvider(eve fun decorativeGlassAll(vararg blocks: Block) { for (block in blocks) { exec { - cubeAll(block.registryName!!.path, ResourceLocation(DataGen.MOD_ID, "block/decorative/${block.registryName!!.path}")).renderType("translucent") + cubeAll(block.registryName!!.path, modLocation("block/decorative/${block.registryName!!.path}")).renderType("translucent") } } } @@ -49,7 +44,7 @@ class MatteryBlockModelProvider(event: GatherDataEvent) : BlockModelProvider(eve fun decorativeCubeAll(vararg blocks: Block) { for (block in blocks) { exec { - cubeAll(block.registryName!!.path, ResourceLocation(DataGen.MOD_ID, "block/decorative/${block.registryName!!.path}")) + cubeAll(block.registryName!!.path, modLocation("block/decorative/${block.registryName!!.path}")) } } } @@ -57,7 +52,7 @@ class MatteryBlockModelProvider(event: GatherDataEvent) : BlockModelProvider(eve fun decorativeCubeAll(subdir: String, vararg blocks: Block) { for (block in blocks) { exec { - cubeAll(block.registryName!!.path, ResourceLocation(DataGen.MOD_ID, "block/decorative/${subdir}/${block.registryName!!.path}")) + cubeAll(block.registryName!!.path, modLocation("block/decorative/${subdir}/${block.registryName!!.path}")) } } } @@ -65,7 +60,7 @@ class MatteryBlockModelProvider(event: GatherDataEvent) : BlockModelProvider(eve fun decorativeCubeAll(subdir: String, suffix: String, vararg blocks: Block) { for (block in blocks) { exec { - cubeAll(block.registryName!!.path, ResourceLocation(DataGen.MOD_ID, "block/decorative/${subdir}/${block.registryName!!.path}$suffix")) + cubeAll(block.registryName!!.path, modLocation("block/decorative/${subdir}/${block.registryName!!.path}$suffix")) } } } @@ -73,20 +68,20 @@ class MatteryBlockModelProvider(event: GatherDataEvent) : BlockModelProvider(eve fun decorativeCubeAll(blocks: Collection) { for (block in blocks) { exec { - cubeAll(block.registryName!!.path, ResourceLocation(DataGen.MOD_ID, "block/decorative/${block.registryName!!.path}")) + cubeAll(block.registryName!!.path, modLocation("block/decorative/${block.registryName!!.path}")) } } } fun decorativeCubeAll(block: Block, texture: String) { exec { - cubeAll(block.registryName!!.path, ResourceLocation(DataGen.MOD_ID, "block/decorative/$texture")) + cubeAll(block.registryName!!.path, modLocation("block/decorative/$texture")) } } fun column(block: Block, end: String, side: String) { exec { - cubeColumn(block.registryName!!.path, ResourceLocation(DataGen.MOD_ID, end), ResourceLocation(DataGen.MOD_ID, side)) + cubeColumn(block.registryName!!.path, modLocation(end), modLocation(side)) } } @@ -97,7 +92,7 @@ class MatteryBlockModelProvider(event: GatherDataEvent) : BlockModelProvider(eve fun resourceCubeAll(vararg blocks: Block) { for (block in blocks) { exec { - cubeAll(block.registryName!!.path, ResourceLocation(DataGen.MOD_ID, "block/resource/${block.registryName!!.path}")) + cubeAll(block.registryName!!.path, modLocation("block/resource/${block.registryName!!.path}")) } } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt index 1ffe1f3d2..30479a59e 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt @@ -22,13 +22,13 @@ fun addBlastingRecipes(consumer: Consumer) { RecipeCategory.MISC, MItems.TRITANIUM_NUGGET, 0f, 200 - ).unlockedBy(MItems.TRITANIUM_NUGGET).save(consumer, modLocation("cooking/nugget_from_${tool.registryName!!.path}")) + ).unlockedBy(MItems.TRITANIUM_NUGGET).save(consumer, modLocation("smelting/tritanium_nugget_from_${tool.registryName!!.path}")) SimpleCookingRecipeBuilder.blasting( Ingredient.of(tool), RecipeCategory.MISC, MItems.TRITANIUM_NUGGET, 0f, 100 - ).unlockedBy(MItems.TRITANIUM_NUGGET).save(consumer, modLocation("blasting/nugget_from_${tool.registryName!!.path}")) + ).unlockedBy(MItems.TRITANIUM_NUGGET).save(consumer, modLocation("blasting/tritanium_nugget_from_${tool.registryName!!.path}")) } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt index 45706fbfc..f126765f7 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt @@ -1,17 +1,13 @@ package ru.dbotthepony.mc.otm.datagen.recipes import net.minecraft.data.recipes.* -import net.minecraft.resources.ResourceLocation -import net.minecraft.tags.ItemTags import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.level.ItemLike import net.minecraftforge.common.Tags -import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.core.registryName -import ru.dbotthepony.mc.otm.datagen.DataGen import ru.dbotthepony.mc.otm.datagen.modLocation import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MItemTags @@ -47,7 +43,7 @@ private fun cut(base: ItemLike, result: ItemLike, amount: Int, consumer: Consume SingleItemRecipeBuilder .stonecutting(Ingredient.of(base), RecipeCategory.BUILDING_BLOCKS, result, amount) .unlockedBy(base) - .save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "stonecutting/${result.asItem().registryName!!.path}_from_${base.asItem().registryName!!.path}")) + .save(consumer, modLocation("stonecutting/${result.asItem().registryName!!.path}_from_${base.asItem().registryName!!.path}")) } private fun stairsWithCut(base: ItemLike, result: ItemLike, consumer: Consumer) { diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt index a5deb984e..df82b17aa 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt @@ -16,6 +16,7 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.core.collect.JsonArrayCollector import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.datagen.modLocation import ru.dbotthepony.mc.otm.recipe.EnergyContainerRecipe import ru.dbotthepony.mc.otm.recipe.UpgradeRecipe import java.util.function.Consumer @@ -189,7 +190,7 @@ class MatteryRecipe(val result: ItemLike, val count: Int = 1, val category: Reci val builder = buildRegular() if (name != null) { - builder.save(filter(consumer), ResourceLocation(OverdriveThatMatters.MOD_ID, + builder.save(filter(consumer), modLocation( if (result.asItem().registryName!!.namespace == OverdriveThatMatters.MOD_ID) "${result.asItem().registryName!!.path}_$name" else diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt index 2ca4c8940..c034f6803 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt @@ -16,7 +16,7 @@ import net.minecraft.world.item.Item import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.level.ItemLike import ru.dbotthepony.mc.otm.core.registryName -import ru.dbotthepony.mc.otm.datagen.DataGen +import ru.dbotthepony.mc.otm.datagen.modLocation import ru.dbotthepony.mc.otm.recipe.PlatePressRecipe import java.util.LinkedList import java.util.function.Consumer @@ -82,7 +82,7 @@ class MatteryRecipeProvider(generatorIn: DataGenerator) : RecipeProvider(generat fun plate(id: String, count: Int = 1, workTicks: Int = 200, experience: FloatProvider = ConstantFloat.ZERO) { exec { _, consumer -> consumer.accept(PlatePressShallowFinishedRecipe( - ResourceLocation(DataGen.MOD_ID, "plates/$id"), + modLocation("plates/$id"), ResourceLocation("forge", "ingots/$id"), ResourceLocation("forge", "plates/$id"), count, @@ -94,7 +94,7 @@ class MatteryRecipeProvider(generatorIn: DataGenerator) : RecipeProvider(generat fun plate(id: String, ingredient: Ingredient, result: Ingredient, count: Int = 1, workTicks: Int = 200, experience: FloatProvider = ConstantFloat.ZERO) { exec { it, callback -> - callback.accept(PlatePressFinishedRecipe(PlatePressRecipe(ResourceLocation(DataGen.MOD_ID, "plate_$id"), ingredient, result, count, workTicks, experience = experience))) + callback.accept(PlatePressFinishedRecipe(PlatePressRecipe(modLocation("plate_$id"), ingredient, result, count, workTicks, experience = experience))) } } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/OreRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/OreRecipes.kt index f3a50e642..977a208a3 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/OreRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/OreRecipes.kt @@ -3,20 +3,19 @@ package ru.dbotthepony.mc.otm.datagen.recipes import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.data.recipes.RecipeCategory import net.minecraft.data.recipes.SimpleCookingRecipeBuilder -import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.crafting.Ingredient -import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.datagen.modLocation import ru.dbotthepony.mc.otm.registry.MItemTags import ru.dbotthepony.mc.otm.registry.MItems import java.util.function.Consumer fun addOreSmeltingRecipes(consumer: Consumer) { - SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_ORES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 100).unlockedBy(MItemTags.TRITANIUM_ORES).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "smelting/tritanium_ingot_from_ore_block")) - SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_ORES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 200).unlockedBy(MItemTags.TRITANIUM_ORES).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "blasting/tritanium_ingot_from_ore_block")) + SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_ORES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 200).unlockedBy(MItemTags.TRITANIUM_ORES).save(consumer, modLocation("smelting/tritanium_ingot_from_ore_block")) + SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_ORES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 100).unlockedBy(MItemTags.TRITANIUM_ORES).save(consumer, modLocation("blasting/tritanium_ingot_from_ore_block")) - SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_ORE_CLUMPS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 100).unlockedBy(MItemTags.TRITANIUM_ORE_CLUMPS).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "smelting/tritanium_ingot_from_raw_ore")) - SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_ORE_CLUMPS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 200).unlockedBy(MItemTags.TRITANIUM_ORE_CLUMPS).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "blasting/tritanium_ingot_from_raw_ore")) + SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_ORE_CLUMPS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 200).unlockedBy(MItemTags.TRITANIUM_ORE_CLUMPS).save(consumer, modLocation("smelting/tritanium_ingot_from_raw_ore")) + SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_ORE_CLUMPS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 100).unlockedBy(MItemTags.TRITANIUM_ORE_CLUMPS).save(consumer, modLocation("blasting/tritanium_ingot_from_raw_ore")) - SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_DUSTS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 100).unlockedBy(MItemTags.TRITANIUM_DUSTS).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "smelting/tritanium_ingot_from_dust")) - SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_DUSTS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 200).unlockedBy(MItemTags.TRITANIUM_DUSTS).save(consumer, ResourceLocation(OverdriveThatMatters.MOD_ID, "blasting/tritanium_ingot_from_dust")) + SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_DUSTS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 200).unlockedBy(MItemTags.TRITANIUM_DUSTS).save(consumer, modLocation("smelting/tritanium_ingot_from_dust")) + SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_DUSTS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 100).unlockedBy(MItemTags.TRITANIUM_DUSTS).save(consumer, modLocation("blasting/tritanium_ingot_from_dust")) } From 61d4bf57a62fa76c95fbe4567c4e0525ee8a35b3 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Tue, 9 May 2023 05:07:46 +0600 Subject: [PATCH 0547/1199] Added a tiny piece of metal to primed hammer --- .../models/item/explosive_hammer_primed.json | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_primed.json b/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_primed.json index 2a018a5ee..426e784cd 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_primed.json +++ b/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_primed.json @@ -253,6 +253,17 @@ "up": {"uv": [4, 7, 6, 8.5], "rotation": 270, "texture": "#0"}, "down": {"uv": [5.5, 8.5, 7.5, 10], "rotation": 270, "texture": "#0"} } + }, + { + "from": [7.5, 21, -2], + "to": [8.5, 22, 1], + "faces": { + "north": {"uv": [4, 4.5, 4.5, 5], "texture": "#0"}, + "east": {"uv": [4, 4.5, 4.5, 6], "rotation": 90, "texture": "#0"}, + "west": {"uv": [4, 4.5, 4.5, 6], "rotation": 270, "texture": "#0"}, + "up": {"uv": [4, 4.5, 4.5, 6], "texture": "#0"}, + "down": {"uv": [4, 4.5, 4.5, 6], "rotation": 180, "texture": "#0"} + } } ], "display": { From f177e796d760dcc5253ee03a5050ba8389da3462 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Tue, 9 May 2023 03:43:46 +0300 Subject: [PATCH 0548/1199] offset itemstack decorations as well --- .../ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 cf7b1255b..40b85dfd8 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 @@ -82,7 +82,14 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit ) RenderSystem.depthFunc(GL11.GL_ALWAYS) - itemRenderer.renderGuiItemDecorations(poseStack, font, itemstack, 0, 0, countOverride) + itemRenderer.renderGuiItemDecorations( + poseStack, + font, + itemstack, + 1, + 1, + countOverride + ) } } From eabbd040d2e11f8c4e27afc7e218cc5ae6abc1f6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 9 May 2023 10:24:59 +0700 Subject: [PATCH 0549/1199] Get rid of IRandomizableItem, add proper data driven exopack slot upgrades --- .../ru/dbotthepony/mc/otm/datagen/loot/DSL.kt | 14 ---- .../mc/otm/datagen/loot/LootModifiersData.kt | 63 +++++++++++--- .../kotlin/ru/dbotthepony/mc/otm/data/Ext.kt | 13 +++ .../mc/otm/data/loot/IRandomizableItem.kt | 11 --- .../mc/otm/data/loot/RandomizerFunction.kt | 82 ------------------- .../ProceduralExoPackSlotUpgradeItem.kt | 67 ++++++++------- .../mc/otm/registry/MItemFunctionTypes.kt | 4 +- 7 files changed, 97 insertions(+), 157 deletions(-) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/IRandomizableItem.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/RandomizerFunction.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/DSL.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/DSL.kt index b62d7f57e..ecacac754 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/DSL.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/DSL.kt @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.datagen.loot import net.minecraft.advancements.critereon.StatePropertiesPredicate import net.minecraft.util.StringRepresentable -import net.minecraft.world.item.Rarity import net.minecraft.world.level.ItemLike import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.properties.Property @@ -17,7 +16,6 @@ import net.minecraft.world.level.storage.loot.predicates.LootItemCondition import net.minecraft.world.level.storage.loot.providers.number.ConstantValue import net.minecraft.world.level.storage.loot.providers.number.UniformGenerator import ru.dbotthepony.mc.otm.data.condition.ChanceCondition -import ru.dbotthepony.mc.otm.data.loot.RandomizerFunction inline fun LootTable.Builder.lootPool(configurator: LootPool.Builder.() -> Unit): LootTable.Builder = withPool(LootPool.lootPool().also(configurator)) inline fun LootTable.Builder.singleItem(item: ItemLike, configurator: LootPoolSingletonContainer.Builder<*>.() -> Unit): LootTable.Builder { @@ -29,18 +27,6 @@ inline fun LootTable.Builder.singleItem(item: ItemLike, configurator: LootPoolSi inline fun lootPool(configurator: LootPool.Builder.() -> Unit): LootPool = LootPool.lootPool().also(configurator).build() inline fun singleItem(item: ItemLike, configurator: LootPoolSingletonContainer.Builder<*>.() -> Unit): LootPool = lootPool { item(item, configurator) } -fun singleRandomizedItem(item: ItemLike, rarity: Rarity = Rarity.COMMON, chance: Double? = null): LootPool { - return lootPool { - item(item) { - apply(RandomizerFunction.valueOf(rarity)) - - if (chance != null) { - chanceCondition(chance) - } - } - } -} - inline fun LootPool.Builder.item(item: ItemLike, configurator: LootPoolSingletonContainer.Builder<*>.() -> Unit) { add(LootItem.lootTableItem(item).also(configurator)) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootModifiersData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootModifiersData.kt index 6b3002281..cd236189d 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootModifiersData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootModifiersData.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.datagen.loot import net.minecraft.resources.ResourceLocation +import net.minecraft.util.valueproviders.UniformInt import net.minecraft.world.entity.EntityType import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Rarity @@ -14,8 +15,8 @@ import ru.dbotthepony.mc.otm.data.condition.HasExoPackCondition import ru.dbotthepony.mc.otm.data.condition.ItemInInventoryCondition import ru.dbotthepony.mc.otm.data.condition.KilledByRealPlayerOrIndirectly import ru.dbotthepony.mc.otm.data.loot.LootPoolAppender -import ru.dbotthepony.mc.otm.data.loot.RandomizerFunction import ru.dbotthepony.mc.otm.item.ProceduralBatteryItem +import ru.dbotthepony.mc.otm.item.exopack.ProceduralExoPackSlotUpgradeItem import ru.dbotthepony.mc.otm.registry.MItems @Suppress("FunctionName") @@ -29,24 +30,32 @@ fun LootTableIdCondition(location: ResourceLocation): LootItemCondition { } fun addLootModifiers(it: LootModifiers) { - it.add("dungeon_exosuit", LootPoolAppender( + it.add("dungeon_exopack", LootPoolAppender( arrayOf(LootTableIdCondition(BuiltInLootTables.SIMPLE_DUNGEON)), singleItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL) { chanceCondition(0.2) - apply(RandomizerFunction.COMMON) + apply(ProceduralExoPackSlotUpgradeItem.Randomizer(UniformInt.of(6, 9))) }, singleItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL) { chanceCondition(0.05) - apply(RandomizerFunction.UNCOMMON) + apply(ProceduralExoPackSlotUpgradeItem.Randomizer(UniformInt.of(9, 18))) }, )) it.add("mineshaft_additions", LootPoolAppender( arrayOf(LootTableIdCondition(BuiltInLootTables.ABANDONED_MINESHAFT)), - singleRandomizedItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, chance = 0.1), - singleRandomizedItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, chance = 0.1, rarity = Rarity.UNCOMMON), + + singleItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL) { + chanceCondition(0.1) + apply(ProceduralExoPackSlotUpgradeItem.Randomizer(UniformInt.of(4, 8))) + }, + + singleItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL) { + chanceCondition(0.1) + apply(ProceduralExoPackSlotUpgradeItem.Randomizer(UniformInt.of(4, 10))) + }, singleItem(MItems.PROCEDURAL_BATTERY) { chanceCondition(0.15) @@ -61,21 +70,49 @@ fun addLootModifiers(it: LootModifiers) { it.add("desert_pyramid_exosuit", LootPoolAppender( arrayOf(LootTableIdCondition(BuiltInLootTables.DESERT_PYRAMID)), - singleRandomizedItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, chance = 0.15, rarity = Rarity.UNCOMMON), - singleRandomizedItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, chance = 0.25, rarity = Rarity.COMMON) + + singleItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL) { + chanceCondition(0.1) + apply(ProceduralExoPackSlotUpgradeItem.Randomizer(UniformInt.of(12, 18))) + }, + + singleItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL) { + chanceCondition(0.25) + apply(ProceduralExoPackSlotUpgradeItem.Randomizer(UniformInt.of(4, 9))) + }, )) it.add("jungle_temple_exosuit", LootPoolAppender( arrayOf(LootTableIdCondition(BuiltInLootTables.JUNGLE_TEMPLE)), - singleRandomizedItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, chance = 0.15, rarity = Rarity.UNCOMMON), - singleRandomizedItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, chance = 0.35, rarity = Rarity.RARE) + + singleItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL) { + chanceCondition(0.15) + apply(ProceduralExoPackSlotUpgradeItem.Randomizer(UniformInt.of(9, 18))) + }, + + singleItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL) { + chanceCondition(0.35) + apply(ProceduralExoPackSlotUpgradeItem.Randomizer(UniformInt.of(16, 28), UniformInt.of(2, 6))) + }, )) it.add("end_city_exosuit", LootPoolAppender( arrayOf(LootTableIdCondition(BuiltInLootTables.END_CITY_TREASURE)), - singleRandomizedItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, chance = 0.4, rarity = Rarity.UNCOMMON), - singleRandomizedItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, chance = 0.2, rarity = Rarity.RARE), - singleRandomizedItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, chance = 0.15, rarity = Rarity.EPIC), + + singleItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL) { + chanceCondition(0.4) + apply(ProceduralExoPackSlotUpgradeItem.Randomizer(UniformInt.of(9, 18))) + }, + + singleItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL) { + chanceCondition(0.2) + apply(ProceduralExoPackSlotUpgradeItem.Randomizer(UniformInt.of(14, 27), UniformInt.of(2, 6))) + }, + + singleItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL) { + chanceCondition(0.1) + apply(ProceduralExoPackSlotUpgradeItem.Randomizer(UniformInt.of(27, 56), UniformInt.of(2, 6))) + }, )) it.add("dungeon_pill", PlainLootAppender( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Ext.kt index bd3f096c1..6cf8c6434 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Ext.kt @@ -1,8 +1,10 @@ package ru.dbotthepony.mc.otm.data import com.mojang.serialization.DataResult +import net.minecraft.world.entity.player.Player import net.minecraft.world.level.storage.loot.LootContext import net.minecraft.world.level.storage.loot.parameters.LootContextParam +import net.minecraft.world.level.storage.loot.parameters.LootContextParams operator fun LootContext.get(param: LootContextParam): T? { return getParamOrNull(param) @@ -11,3 +13,14 @@ operator fun LootContext.get(param: LootContextParam): T? { fun DataResult.getOrNull(): T? { return get().left().orElse(null) } + +fun LootContext.findPlayer(): Player? { + return getParamOrNull(LootContextParams.DIRECT_KILLER_ENTITY).let { + if (it != null) + it as? Player + else + getParamOrNull(LootContextParams.KILLER_ENTITY).let { + if (it != null) it as? Player else getParamOrNull(LootContextParams.THIS_ENTITY) as? Player + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/IRandomizableItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/IRandomizableItem.kt deleted file mode 100644 index b649659ac..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/IRandomizableItem.kt +++ /dev/null @@ -1,11 +0,0 @@ -package ru.dbotthepony.mc.otm.data.loot - -import net.minecraft.util.RandomSource -import net.minecraft.world.entity.player.Player -import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.Rarity -import net.minecraft.world.level.ItemLike - -interface IRandomizableItem { - fun randomize(itemStack: ItemStack, random: RandomSource, ply: Player?, rarity: Rarity = Rarity.COMMON) -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/RandomizerFunction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/RandomizerFunction.kt deleted file mode 100644 index 822fdee36..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/RandomizerFunction.kt +++ /dev/null @@ -1,82 +0,0 @@ -package ru.dbotthepony.mc.otm.data.loot - -import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonObject -import com.google.gson.JsonPrimitive -import com.google.gson.JsonSerializationContext -import com.google.gson.JsonSyntaxException -import net.minecraft.world.entity.player.Player -import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.Rarity -import net.minecraft.world.level.storage.loot.LootContext -import net.minecraft.world.level.storage.loot.Serializer -import net.minecraft.world.level.storage.loot.functions.LootItemFunction -import net.minecraft.world.level.storage.loot.functions.LootItemFunctionType -import net.minecraft.world.level.storage.loot.parameters.LootContextParams -import org.apache.logging.log4j.LogManager -import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.core.set -import ru.dbotthepony.mc.otm.registry.MItemFunctionTypes - -enum class RandomizerFunction(val rarity: Rarity) : LootItemFunction, LootItemFunction.Builder { - COMMON(Rarity.COMMON), - UNCOMMON(Rarity.UNCOMMON), - RARE(Rarity.RARE), - EPIC(Rarity.EPIC); - - override fun apply(itemStack: ItemStack, context: LootContext): ItemStack { - val randomizer = itemStack.item as? IRandomizableItem - - if (randomizer == null) { - LOGGER.error("${itemStack.item} does not implement ${IRandomizableItem::class.qualifiedName}! Can not randomize $itemStack!") - return itemStack - } - - val random = context.random - - val player = - context.getParamOrNull(LootContextParams.DIRECT_KILLER_ENTITY).let { - if (it != null) - it as? Player - else - context.getParamOrNull(LootContextParams.KILLER_ENTITY).let { - if (it != null) - it as? Player - else - context.getParamOrNull(LootContextParams.THIS_ENTITY) as? Player - } - } - - randomizer.randomize(itemStack, random, player, rarity) - return itemStack - } - - override fun getType(): LootItemFunctionType { - return MItemFunctionTypes.RANDOMIZER - } - - override fun build(): LootItemFunction { - return this - } - - companion object : Serializer { - fun valueOf(rarity: Rarity): RandomizerFunction { - return when(rarity) { - Rarity.COMMON -> COMMON - Rarity.UNCOMMON -> UNCOMMON - Rarity.RARE -> RARE - Rarity.EPIC -> EPIC - } - } - - override fun serialize(p_79325_: JsonObject, p_79326_: RandomizerFunction, p_79327_: JsonSerializationContext) { - p_79325_["rarity"] = JsonPrimitive(p_79326_.rarity.name) - } - - override fun deserialize(p_79323_: JsonObject, p_79324_: JsonDeserializationContext): RandomizerFunction { - return valueOf(Rarity.valueOf(p_79323_["rarity"]?.asString ?: throw JsonSyntaxException("Invalid rarity json element"))) - } - - private val LOGGER = LogManager.getLogger() - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ProceduralExoPackSlotUpgradeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ProceduralExoPackSlotUpgradeItem.kt index c4b7d8915..940e4d8b1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ProceduralExoPackSlotUpgradeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ProceduralExoPackSlotUpgradeItem.kt @@ -1,27 +1,48 @@ package ru.dbotthepony.mc.otm.item.exopack +import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.ChatFormatting import net.minecraft.network.chat.Component -import net.minecraft.util.RandomSource -import net.minecraft.world.entity.player.Player +import net.minecraft.util.valueproviders.ConstantInt +import net.minecraft.util.valueproviders.IntProvider import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Rarity import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.Level +import net.minecraft.world.level.storage.loot.LootContext +import net.minecraft.world.level.storage.loot.functions.LootItemFunction +import net.minecraft.world.level.storage.loot.functions.LootItemFunctionType import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.tagNotNull -import ru.dbotthepony.mc.otm.data.loot.IRandomizableItem +import ru.dbotthepony.mc.otm.data.Codec2Serializer +import ru.dbotthepony.mc.otm.registry.MItemFunctionTypes import java.util.* -class ProceduralExoPackSlotUpgradeItem : AbstractExoPackSlotUpgradeItem(defaultProperties()), IRandomizableItem { - override fun getRarity(itemStack: ItemStack): Rarity { - return when (slotCount(itemStack)) { - in 0 .. 9 -> Rarity.COMMON - in 10 .. 18 -> Rarity.UNCOMMON - in 19 .. 27 -> Rarity.RARE - in 28 .. 36 -> Rarity.EPIC - else -> Rarity.EPIC +class ProceduralExoPackSlotUpgradeItem : AbstractExoPackSlotUpgradeItem(defaultProperties()) { + class Randomizer(val slots: IntProvider, val luckBias: IntProvider = ConstantInt.ZERO) : LootItemFunction, LootItemFunction.Builder { + override fun apply(t: ItemStack, u: LootContext): ItemStack { + t.tagNotNull[SLOT_COUNT_KEY] = slots.sample(u.random) + (luckBias.sample(u.random) * u.luck / 1024f).coerceAtLeast(0f).toInt() + return t + } + + override fun getType(): LootItemFunctionType { + return MItemFunctionTypes.PROCEDURAL_EXOPACK_UPGRADE + } + + override fun build(): LootItemFunction { + return this + } + + companion object { + val SERIALIZER = Codec2Serializer( + RecordCodecBuilder.create { + it.group( + IntProvider.CODEC.fieldOf("slots").forGetter(Randomizer::slots), + IntProvider.CODEC.optionalFieldOf("luck_bias", ConstantInt.ZERO).forGetter(Randomizer::luckBias), + ).apply(it, ::Randomizer) + } + ) } } @@ -50,30 +71,6 @@ class ProceduralExoPackSlotUpgradeItem : AbstractExoPackSlotUpgradeItem(defaultP } } - override fun randomize(itemStack: ItemStack, random: RandomSource, ply: Player?, rarity: Rarity) { - var amount = random.nextIntBetweenInclusive(6, 9) - val luck = (ply?.luck ?: 0f) * 0.3f - val finalLuck = (0.5f - (luck / 512f).coerceAtLeast(-0.3f).coerceAtMost(0.3f)) - - if (random.nextFloat() >= finalLuck && rarity.ordinal >= Rarity.UNCOMMON.ordinal) { - amount += random.nextIntBetweenInclusive(4, 9) - - if (random.nextFloat() >= finalLuck && rarity.ordinal >= Rarity.RARE.ordinal) { - amount += random.nextIntBetweenInclusive(6, 9) - - if (random.nextFloat() >= finalLuck && rarity.ordinal >= Rarity.EPIC.ordinal) { - amount += random.nextIntBetweenInclusive(8, 12) - - if (random.nextFloat() >= finalLuck) { - amount += random.nextIntBetweenInclusive(14, 18) - } - } - } - } - - itemStack.tagNotNull[SLOT_COUNT_KEY] = amount - } - companion object { const val SLOT_COUNT_KEY = "slotCount" const val UUID_KEY = "uuid" 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 d30b97e29..f8005cdad 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItemFunctionTypes.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItemFunctionTypes.kt @@ -6,15 +6,15 @@ import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.registries.DeferredRegister import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.data.loot.CopyTileNbtFunction -import ru.dbotthepony.mc.otm.data.loot.RandomizerFunction 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) - val RANDOMIZER: LootItemFunctionType by registry.register("randomizer") { LootItemFunctionType(RandomizerFunction.Companion) } val COPY_TILE_NBT: LootItemFunctionType by registry.register("copy_tile_nbt") { LootItemFunctionType(CopyTileNbtFunction.Companion) } val PROCEDURAL_BATTERY: LootItemFunctionType by registry.register(MNames.PROCEDURAL_BATTERY) { LootItemFunctionType(ProceduralBatteryItem.Randomizer.SERIALIZER) } + val PROCEDURAL_EXOPACK_UPGRADE: LootItemFunctionType by registry.register("exopack_upgrade") { LootItemFunctionType(ProceduralExoPackSlotUpgradeItem.Randomizer.SERIALIZER) } internal fun register(bus: IEventBus) { registry.register(bus) From 009b8943742e89113f161bed5a2682e36beb6ab8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 9 May 2023 10:27:30 +0700 Subject: [PATCH 0550/1199] Move ChanceCondition to codec --- .../mc/otm/data/condition/ChanceCondition.kt | 21 +++++-------------- .../mc/otm/registry/MLootItemConditions.kt | 2 +- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceCondition.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceCondition.kt index 74eb3c34b..232f88261 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceCondition.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceCondition.kt @@ -1,16 +1,11 @@ package ru.dbotthepony.mc.otm.data.condition -import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonObject -import com.google.gson.JsonPrimitive -import com.google.gson.JsonSerializationContext -import com.google.gson.JsonSyntaxException +import com.mojang.serialization.Codec +import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.world.level.storage.loot.LootContext -import net.minecraft.world.level.storage.loot.Serializer import net.minecraft.world.level.storage.loot.predicates.LootItemCondition import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType -import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.data.Codec2Serializer import ru.dbotthepony.mc.otm.registry.MLootItemConditions /** @@ -33,13 +28,7 @@ data class ChanceCondition(val chance: Double) : LootItemCondition, LootItemCond return this } - companion object : Serializer { - override fun serialize(p_79325_: JsonObject, p_79326_: ChanceCondition, p_79327_: JsonSerializationContext) { - p_79325_["chance"] = JsonPrimitive(p_79326_.chance) - } - - override fun deserialize(p_79323_: JsonObject, p_79324_: JsonDeserializationContext): ChanceCondition { - return ChanceCondition(p_79323_["chance"]?.asDouble ?: throw JsonSyntaxException("Invalid chance json element")) - } + companion object { + val SERIALIZER = Codec2Serializer(RecordCodecBuilder.create { it.group(Codec.DOUBLE.fieldOf("chance").forGetter(ChanceCondition::chance)).apply(it, ::ChanceCondition) }) } } 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 c74c21fa6..9aac91ee7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MLootItemConditions.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MLootItemConditions.kt @@ -21,7 +21,7 @@ object MLootItemConditions { val ITEM_IN_INVENTORY: LootItemConditionType by registry.register("item_in_inventory") { LootItemConditionType(ItemInInventoryCondition.SERIALIZER) } val KILLED_BY_REAL_PLAYER: LootItemConditionType by registry.register("killed_by_real_player") { LootItemConditionType(KilledByRealPlayer) } val KILLED_BY_REAL_PLAYER_OR_INDIRECTLY: LootItemConditionType by registry.register("killed_by_real_player_or_indirectly") { LootItemConditionType(KilledByRealPlayerOrIndirectly) } - val CHANCE: LootItemConditionType by registry.register("chance") { LootItemConditionType(ChanceCondition.Companion) } + val CHANCE: LootItemConditionType by registry.register("chance") { LootItemConditionType(ChanceCondition.SERIALIZER) } internal fun register(bus: IEventBus) { registry.register(bus) From f0fd5484caa8d6da00d0ef24eefb18bd85571f9d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 9 May 2023 10:29:17 +0700 Subject: [PATCH 0551/1199] Add codec level range check in ChanceCondition --- .../ru/dbotthepony/mc/otm/data/condition/ChanceCondition.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceCondition.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceCondition.kt index 232f88261..4380d963a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceCondition.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceCondition.kt @@ -29,6 +29,6 @@ data class ChanceCondition(val chance: Double) : LootItemCondition, LootItemCond } companion object { - val SERIALIZER = Codec2Serializer(RecordCodecBuilder.create { it.group(Codec.DOUBLE.fieldOf("chance").forGetter(ChanceCondition::chance)).apply(it, ::ChanceCondition) }) + val SERIALIZER = Codec2Serializer(RecordCodecBuilder.create { it.group(Codec.doubleRange(0.0, 1.0).fieldOf("chance").forGetter(ChanceCondition::chance)).apply(it, ::ChanceCondition) }) } } From 431f3e11b87ba8c052b440c880c323e07d7060a7 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 9 May 2023 10:59:35 +0700 Subject: [PATCH 0552/1199] Remove text position rounding (oh no) --- .../dbotthepony/mc/otm/client/render/Ext.kt | 64 +++++++++---------- .../client/screen/panels/EffectListPanel.kt | 2 +- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt index 3b0ba43cb..aaec7ab29 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt @@ -154,16 +154,16 @@ private fun Font.widthDuckTyped(text: Any): Int { private fun Font.drawAlignedDuckTyped(poseStack: PoseStack, text: Any, align: TextAlign, x: Float, y: Float, color: Int): Int { return when (align) { TextAlign.TOP_LEFT -> drawDuckTyped(poseStack, text, x, y, color) - TextAlign.TOP_CENTER -> drawDuckTyped(poseStack, text, (x - widthDuckTyped(text) / 2f).roundToInt().toFloat(), y, color) - TextAlign.TOP_RIGHT -> drawDuckTyped(poseStack, text, (x - widthDuckTyped(text)).roundToInt().toFloat(), y, color) + TextAlign.TOP_CENTER -> drawDuckTyped(poseStack, text, (x - widthDuckTyped(text) / 2f), y, color) + TextAlign.TOP_RIGHT -> drawDuckTyped(poseStack, text, (x - widthDuckTyped(text)), y, color) - TextAlign.CENTER_LEFT -> drawDuckTyped(poseStack, text, x, (y - lineHeight / 2f).roundToInt().toFloat(), color) - TextAlign.CENTER_CENTER -> drawDuckTyped(poseStack, text, (x - widthDuckTyped(text) / 2f).roundToInt().toFloat(), (y - lineHeight / 2f).roundToInt().toFloat(), color) - TextAlign.CENTER_RIGHT -> drawDuckTyped(poseStack, text, (x - widthDuckTyped(text)).roundToInt().toFloat(), (y - lineHeight / 2f).roundToInt().toFloat(), color) + TextAlign.CENTER_LEFT -> drawDuckTyped(poseStack, text, x, (y - lineHeight / 2f), color) + TextAlign.CENTER_CENTER -> drawDuckTyped(poseStack, text, (x - widthDuckTyped(text) / 2f), (y - lineHeight / 2f), color) + TextAlign.CENTER_RIGHT -> drawDuckTyped(poseStack, text, (x - widthDuckTyped(text)), (y - lineHeight / 2f), color) - TextAlign.BOTTOM_LEFT -> drawDuckTyped(poseStack, text, x, (y - lineHeight).roundToInt().toFloat(), color) - TextAlign.BOTTOM_CENTER -> drawDuckTyped(poseStack, text, (x - widthDuckTyped(text) / 2f).roundToInt().toFloat(), (y - lineHeight).roundToInt().toFloat(), color) - TextAlign.BOTTOM_RIGHT -> drawDuckTyped(poseStack, text, (x - widthDuckTyped(text)).roundToInt().toFloat(), (y - lineHeight).roundToInt().toFloat(), color) + TextAlign.BOTTOM_LEFT -> drawDuckTyped(poseStack, text, x, (y - lineHeight), color) + TextAlign.BOTTOM_CENTER -> drawDuckTyped(poseStack, text, (x - widthDuckTyped(text) / 2f), (y - lineHeight), color) + TextAlign.BOTTOM_RIGHT -> drawDuckTyped(poseStack, text, (x - widthDuckTyped(text)), (y - lineHeight), color) } } @@ -182,32 +182,32 @@ private fun Font.drawAlignedDuckTyped( ): Int { return when (align) { TextAlign.TOP_LEFT -> drawDuckTyped(poseStack, buffer, text, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.TOP_CENTER -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text) / 2f).roundToInt().toFloat(), y, color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.TOP_RIGHT -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text)).roundToInt().toFloat(), y, color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.TOP_CENTER -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text) / 2f), y, color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.TOP_RIGHT -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text)), y, color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.CENTER_LEFT -> drawDuckTyped(poseStack, buffer, text, x, (y - lineHeight / 2f).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.CENTER_CENTER -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text) / 2f).roundToInt().toFloat(), (y - lineHeight / 2f).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.CENTER_RIGHT -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text)).roundToInt().toFloat(), (y - lineHeight / 2f).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.CENTER_LEFT -> drawDuckTyped(poseStack, buffer, text, x, (y - lineHeight / 2f), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.CENTER_CENTER -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text) / 2f), (y - lineHeight / 2f), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.CENTER_RIGHT -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text)), (y - lineHeight / 2f), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.BOTTOM_LEFT -> drawDuckTyped(poseStack, buffer, text, x, (y - lineHeight).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.BOTTOM_CENTER -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text) / 2f).roundToInt().toFloat(), (y - lineHeight).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.BOTTOM_RIGHT -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text)).roundToInt().toFloat(), (y - lineHeight).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.BOTTOM_LEFT -> drawDuckTyped(poseStack, buffer, text, x, (y - lineHeight), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.BOTTOM_CENTER -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text) / 2f), (y - lineHeight), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.BOTTOM_RIGHT -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text)), (y - lineHeight), color, drawShadow, displayMode, packedLightCoords, effectColor) } } private fun Font.drawScaledAlignedDuckTyped(poseStack: PoseStack, text: Any, scale: Float, align: TextAlign, x: Float, y: Float, color: Int): Int { return when (align) { TextAlign.TOP_LEFT -> drawScaledDuckTyped(poseStack, text, scale, x, y, color) - TextAlign.TOP_CENTER -> drawScaledDuckTyped(poseStack, text, scale, (x - widthDuckTyped(text) * scale / 2f).roundToInt().toFloat(), y, color) - TextAlign.TOP_RIGHT -> drawScaledDuckTyped(poseStack, text, scale, (x - widthDuckTyped(text) * scale).roundToInt().toFloat(), y, color) + TextAlign.TOP_CENTER -> drawScaledDuckTyped(poseStack, text, scale, (x - widthDuckTyped(text) * scale / 2f), y, color) + TextAlign.TOP_RIGHT -> drawScaledDuckTyped(poseStack, text, scale, (x - widthDuckTyped(text) * scale), y, color) - TextAlign.CENTER_LEFT -> drawScaledDuckTyped(poseStack, text, scale, x, (y - lineHeight / 2f * scale).roundToInt().toFloat(), color) - TextAlign.CENTER_CENTER -> drawScaledDuckTyped(poseStack, text, scale, (x - widthDuckTyped(text) * scale / 2f).roundToInt().toFloat(), (y - lineHeight * scale / 2f).roundToInt().toFloat(), color) - TextAlign.CENTER_RIGHT -> drawScaledDuckTyped(poseStack, text, scale, (x - widthDuckTyped(text) * scale).roundToInt().toFloat(), (y - lineHeight * scale / 2f).roundToInt().toFloat(), color) + TextAlign.CENTER_LEFT -> drawScaledDuckTyped(poseStack, text, scale, x, (y - lineHeight / 2f * scale), color) + TextAlign.CENTER_CENTER -> drawScaledDuckTyped(poseStack, text, scale, (x - widthDuckTyped(text) * scale / 2f), (y - lineHeight * scale / 2f), color) + TextAlign.CENTER_RIGHT -> drawScaledDuckTyped(poseStack, text, scale, (x - widthDuckTyped(text) * scale), (y - lineHeight * scale / 2f), color) - TextAlign.BOTTOM_LEFT -> drawScaledDuckTyped(poseStack, text, scale, x, (y - lineHeight * scale).roundToInt().toFloat(), color) - TextAlign.BOTTOM_CENTER -> drawScaledDuckTyped(poseStack, text, scale, (x - widthDuckTyped(text) * scale / 2f).roundToInt().toFloat(), (y - lineHeight * scale).roundToInt().toFloat(), color) - TextAlign.BOTTOM_RIGHT -> drawScaledDuckTyped(poseStack, text, scale, (x - widthDuckTyped(text) * scale).roundToInt().toFloat(), (y - lineHeight * scale).roundToInt().toFloat(), color) + TextAlign.BOTTOM_LEFT -> drawScaledDuckTyped(poseStack, text, scale, x, (y - lineHeight * scale), color) + TextAlign.BOTTOM_CENTER -> drawScaledDuckTyped(poseStack, text, scale, (x - widthDuckTyped(text) * scale / 2f), (y - lineHeight * scale), color) + TextAlign.BOTTOM_RIGHT -> drawScaledDuckTyped(poseStack, text, scale, (x - widthDuckTyped(text) * scale), (y - lineHeight * scale), color) } } @@ -227,16 +227,16 @@ private fun Font.drawScaledAlignedDuckTyped( ): Int { return when (align) { TextAlign.TOP_LEFT -> drawScaledDuckTyped(poseStack, buffer, text, scale, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.TOP_CENTER -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale / 2f).roundToInt().toFloat(), y, color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.TOP_RIGHT -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale).roundToInt().toFloat(), y, color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.TOP_CENTER -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale / 2f), y, color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.TOP_RIGHT -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale), y, color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.CENTER_LEFT -> drawScaledDuckTyped(poseStack, buffer, text, scale, x, (y - lineHeight / 2f * scale).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.CENTER_CENTER -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale / 2f).roundToInt().toFloat(), (y - lineHeight * scale / 2f).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.CENTER_RIGHT -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale).roundToInt().toFloat(), (y - lineHeight * scale / 2f).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.CENTER_LEFT -> drawScaledDuckTyped(poseStack, buffer, text, scale, x, (y - lineHeight / 2f * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.CENTER_CENTER -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale / 2f), (y - lineHeight * scale / 2f), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.CENTER_RIGHT -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale), (y - lineHeight * scale / 2f), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.BOTTOM_LEFT -> drawScaledDuckTyped(poseStack, buffer, text, scale, x, (y - lineHeight * scale).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.BOTTOM_CENTER -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale / 2f).roundToInt().toFloat(), (y - lineHeight * scale).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.BOTTOM_RIGHT -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale).roundToInt().toFloat(), (y - lineHeight * scale).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.BOTTOM_LEFT -> drawScaledDuckTyped(poseStack, buffer, text, scale, x, (y - lineHeight * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.BOTTOM_CENTER -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale / 2f), (y - lineHeight * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.BOTTOM_RIGHT -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale), (y - lineHeight * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt index 5aec68c76..7bd50c44a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt @@ -117,7 +117,7 @@ open class EffectListPanel @JvmOverloads constructor( minecraft.mobEffectTextures.get(effect.effect).render(stack, x = 3f, y = 3f, width = width - 6f, height = height - 6f) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) - font.drawScaledAligned(stack, formatTickDuration(effect.duration), 0.75f, TextAlign.CENTER_CENTER, width / 2f + 0.5f, height / 2f, RGBAColor.WHITE) + font.drawScaledAligned(stack, formatTickDuration(effect.duration), 0.75f, TextAlign.CENTER_CENTER, width / 2f - 1f, height / 2f, RGBAColor.WHITE) } override fun innerRenderTooltips(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { From 6b3756a9ded457a2f68fadb787c295aba94823e4 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 9 May 2023 11:20:49 +0700 Subject: [PATCH 0553/1199] :upside_down: --- .../dbotthepony/mc/otm/registry/MRegistry.kt | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) 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 6444c44eb..c3a5808f4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -239,24 +239,26 @@ object MRegistry { } private fun initializeClient(event: FMLClientSetupEvent) { - ItemProperties.register(MItems.TRITANIUM_SHIELD, ResourceLocation(OverdriveThatMatters.MOD_ID, "blocking")) { stack, level, entity, _ -> - if (entity?.isUsingItem == true && entity.useItem == stack) { - 1f - } else { - 0f + event.enqueueWork { + ItemProperties.register(MItems.TRITANIUM_SHIELD, ResourceLocation(OverdriveThatMatters.MOD_ID, "blocking")) { stack, level, entity, _ -> + if (entity?.isUsingItem == true && entity.useItem == stack) { + 1f + } else { + 0f + } } - } - ItemProperties.register(MItems.ENERGY_SWORD, ResourceLocation(OverdriveThatMatters.MOD_ID, "is_powered")) { stack, _, _, _ -> - if ((stack.matteryEnergy?.batteryLevel ?: Decimal.ZERO) >= EnergySwordItem.ENERGY_PER_SWING) { - 1f - } else { - 0f + ItemProperties.register(MItems.ENERGY_SWORD, ResourceLocation(OverdriveThatMatters.MOD_ID, "is_powered")) { stack, _, _, _ -> + if ((stack.matteryEnergy?.batteryLevel ?: Decimal.ZERO) >= EnergySwordItem.ENERGY_PER_SWING) { + 1f + } else { + 0f + } } - } - ItemProperties.register(MItems.EXPLOSIVE_HAMMER, ResourceLocation(OverdriveThatMatters.MOD_ID, "is_primed")) { stack, _, _, _ -> - if (MItems.EXPLOSIVE_HAMMER.isPrimed(stack)) 1f else 0f + ItemProperties.register(MItems.EXPLOSIVE_HAMMER, ResourceLocation(OverdriveThatMatters.MOD_ID, "is_primed")) { stack, _, _, _ -> + if (MItems.EXPLOSIVE_HAMMER.isPrimed(stack)) 1f else 0f + } } } } From 24df358add22584ed044fd2eeb738e5ae04682ca Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Thu, 11 May 2023 02:24:03 +0300 Subject: [PATCH 0554/1199] Condition 'components != null' is always 'true' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit УВЫ БЛЯТЬ НЕ ТРУ --- .../ru/dbotthepony/mc/otm/graph/storage/StorageNode.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNode.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNode.kt index a5b57a4b5..c2b1c3e53 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNode.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNode.kt @@ -37,9 +37,10 @@ open class StorageNode(private val energyDemander: IMatteryEnergyStorage? = null return } - for (component in components) { - to.add(component) - } + if (components != null) + for (component in components) { + to.add(component) + } } /** From 52b7e2b80e0e7318916886c05eb2ec3a0d069393 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 11 May 2023 12:41:23 +0700 Subject: [PATCH 0555/1199] this is not functional atm, so lets disable this completely --- .../ru/dbotthepony/mc/otm/graph/storage/StorageGraph.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageGraph.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageGraph.kt index 4e06a4d53..b85b66ea0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageGraph.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageGraph.kt @@ -46,11 +46,11 @@ class StorageGraph : Abstract6Graph() { } override fun onNodeAdded(node: StorageNode) { - node.attachComponents(this) + //node.attachComponents(this) } override fun onNodeRemoved(node: StorageNode) { - node.removeComponents(this) + //node.removeComponents(this) } } From 5076a9f6e28bbe2e7d1f91394791a65ea6427654 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 11 May 2023 12:45:55 +0700 Subject: [PATCH 0556/1199] why did i do this --- .../java/ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java index 338337d93..b9a744c07 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java @@ -63,7 +63,7 @@ public class MixinLivingEntity { max = 0.8; } - totalExperience *= new Random().nextDouble(min, max); + totalExperience *= min + player.getRandom().nextDouble() * (max - min); } if (totalExperience >= Integer.MAX_VALUE) { From 205c45e25d0c6c6b50321a0364924f3ec1226088 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Fri, 12 May 2023 16:59:05 +0300 Subject: [PATCH 0557/1199] :downs: Revert ":upside_down:" This reverts commit 6b3756a9ded457a2f68fadb787c295aba94823e4. --- .../dbotthepony/mc/otm/registry/MRegistry.kt | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) 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 c3a5808f4..6444c44eb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -239,26 +239,24 @@ object MRegistry { } private fun initializeClient(event: FMLClientSetupEvent) { - event.enqueueWork { - ItemProperties.register(MItems.TRITANIUM_SHIELD, ResourceLocation(OverdriveThatMatters.MOD_ID, "blocking")) { stack, level, entity, _ -> - if (entity?.isUsingItem == true && entity.useItem == stack) { - 1f - } else { - 0f - } + ItemProperties.register(MItems.TRITANIUM_SHIELD, ResourceLocation(OverdriveThatMatters.MOD_ID, "blocking")) { stack, level, entity, _ -> + if (entity?.isUsingItem == true && entity.useItem == stack) { + 1f + } else { + 0f } + } - ItemProperties.register(MItems.ENERGY_SWORD, ResourceLocation(OverdriveThatMatters.MOD_ID, "is_powered")) { stack, _, _, _ -> - if ((stack.matteryEnergy?.batteryLevel ?: Decimal.ZERO) >= EnergySwordItem.ENERGY_PER_SWING) { - 1f - } else { - 0f - } + ItemProperties.register(MItems.ENERGY_SWORD, ResourceLocation(OverdriveThatMatters.MOD_ID, "is_powered")) { stack, _, _, _ -> + if ((stack.matteryEnergy?.batteryLevel ?: Decimal.ZERO) >= EnergySwordItem.ENERGY_PER_SWING) { + 1f + } else { + 0f } + } - ItemProperties.register(MItems.EXPLOSIVE_HAMMER, ResourceLocation(OverdriveThatMatters.MOD_ID, "is_primed")) { stack, _, _, _ -> - if (MItems.EXPLOSIVE_HAMMER.isPrimed(stack)) 1f else 0f - } + ItemProperties.register(MItems.EXPLOSIVE_HAMMER, ResourceLocation(OverdriveThatMatters.MOD_ID, "is_primed")) { stack, _, _, _ -> + if (MItems.EXPLOSIVE_HAMMER.isPrimed(stack)) 1f else 0f } } } From fd236d8a53d0a43d8997ee2ebc85ab09ff315f57 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Fri, 12 May 2023 18:10:59 +0300 Subject: [PATCH 0558/1199] Revert ":downs:" This reverts commit 205c45e25d0c6c6b50321a0364924f3ec1226088. --- .../dbotthepony/mc/otm/registry/MRegistry.kt | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) 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 6444c44eb..c3a5808f4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -239,24 +239,26 @@ object MRegistry { } private fun initializeClient(event: FMLClientSetupEvent) { - ItemProperties.register(MItems.TRITANIUM_SHIELD, ResourceLocation(OverdriveThatMatters.MOD_ID, "blocking")) { stack, level, entity, _ -> - if (entity?.isUsingItem == true && entity.useItem == stack) { - 1f - } else { - 0f + event.enqueueWork { + ItemProperties.register(MItems.TRITANIUM_SHIELD, ResourceLocation(OverdriveThatMatters.MOD_ID, "blocking")) { stack, level, entity, _ -> + if (entity?.isUsingItem == true && entity.useItem == stack) { + 1f + } else { + 0f + } } - } - ItemProperties.register(MItems.ENERGY_SWORD, ResourceLocation(OverdriveThatMatters.MOD_ID, "is_powered")) { stack, _, _, _ -> - if ((stack.matteryEnergy?.batteryLevel ?: Decimal.ZERO) >= EnergySwordItem.ENERGY_PER_SWING) { - 1f - } else { - 0f + ItemProperties.register(MItems.ENERGY_SWORD, ResourceLocation(OverdriveThatMatters.MOD_ID, "is_powered")) { stack, _, _, _ -> + if ((stack.matteryEnergy?.batteryLevel ?: Decimal.ZERO) >= EnergySwordItem.ENERGY_PER_SWING) { + 1f + } else { + 0f + } } - } - ItemProperties.register(MItems.EXPLOSIVE_HAMMER, ResourceLocation(OverdriveThatMatters.MOD_ID, "is_primed")) { stack, _, _, _ -> - if (MItems.EXPLOSIVE_HAMMER.isPrimed(stack)) 1f else 0f + ItemProperties.register(MItems.EXPLOSIVE_HAMMER, ResourceLocation(OverdriveThatMatters.MOD_ID, "is_primed")) { stack, _, _, _ -> + if (MItems.EXPLOSIVE_HAMMER.isPrimed(stack)) 1f else 0f + } } } } From 1967b2869a72f27eb9ae0ea2583592341030ec9d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 15 May 2023 08:10:06 +0700 Subject: [PATCH 0559/1199] Update fluid handler conditions --- .../entity/decorative/FluidTankBlockEntity.kt | 12 ++--------- .../mc/otm/container/HandlerFilter.kt | 20 ++----------------- 2 files changed, 4 insertions(+), 28 deletions(-) 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 5b6bd1f3f..eaff686e9 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 @@ -42,18 +42,10 @@ class FluidTankBlockEntity(blockPos: BlockPos, blockState: BlockState) : Mattery fillInput.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { if (fluid.isEmpty) { - stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK { - return it.tanks > 0 - } - - return false + return stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).map { it.tanks > 0 }.orElse(false) } - stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK { - return it.fill(fluid[0], IFluidHandler.FluidAction.SIMULATE) > 0 - } - - return false + return stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).map { it.fill(fluid[0], IFluidHandler.FluidAction.SIMULATE) > 0 }.orElse(false) } override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt index 4d62d09c8..c36c8af12 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt @@ -42,29 +42,13 @@ interface HandlerFilter { object FluidContainers : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { - stack.getCapability(ForgeCapabilities.FLUID_HANDLER).ifPresentK { - return it.tanks > 0 - } - - stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK { - return it.tanks > 0 - } - - return false + return stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).map { it.tanks > 0 }.orElse(false) } } object DrainableFluidContainers : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { - stack.getCapability(ForgeCapabilities.FLUID_HANDLER).ifPresentK { - return it.stream().anyMatch { it.isNotEmpty } - } - - stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK { - return it.stream().anyMatch { it.isNotEmpty } - } - - return false + return stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).map { it.stream().anyMatch { it.isNotEmpty } }.orElse(false) } override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { From 18ac57a63236639cca2d381e43c51eb9a11ea895 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 15 May 2023 08:11:22 +0700 Subject: [PATCH 0560/1199] =?UTF-8?q?YuRaNnNzZZ=20=E2=80=94=20=D0=A1=D0=B5?= =?UTF-8?q?=D0=B3=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=207:02=20=D0=97=D0=90?= =?UTF-8?q?=D0=A2=D0=9E=20=D0=A2=D0=A0=D0=A3=D0=91=D0=9E=D0=99=20=D0=AF=20?= =?UTF-8?q?=D0=A2=D0=A3=D0=94=D0=90=20=D0=A1=D0=9E=D0=92=D0=90=D0=A2=D0=AC?= =?UTF-8?q?=20=D0=9D=D0=95=20=D0=9C=D0=9E=D0=93=D0=A3=20=D0=9D=D0=98=D0=A7?= =?UTF-8?q?=D0=95=D0=93=D0=9E=20=D0=B0=20=D1=82=D0=BE=D1=87=D0=BD=D0=B5?= =?UTF-8?q?=D0=B5=20=D0=BD=D0=B5=20=D0=BC=D0=BE=D0=B3=D1=83=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=B3=D0=B4=D0=B0=20=D1=82=D0=B0=D0=BC=20=D0=B5=D1=81=D1=82?= =?UTF-8?q?=D1=8C=20=D0=B6=D0=B8=D0=B4=D0=BA=D0=BE=D1=81=D1=82=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/block/entity/decorative/FluidTankBlockEntity.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 eaff686e9..ed07a882d 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 @@ -45,7 +45,10 @@ class FluidTankBlockEntity(blockPos: BlockPos, blockState: BlockState) : Mattery return stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).map { it.tanks > 0 }.orElse(false) } - return stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).map { it.fill(fluid[0], IFluidHandler.FluidAction.SIMULATE) > 0 }.orElse(false) + return stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).map { + it.fill(fluid[0], IFluidHandler.FluidAction.SIMULATE) > 0 || + it.drain(fluid[0], IFluidHandler.FluidAction.SIMULATE).isNotEmpty + }.orElse(false) } override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { From 3d4c5855c48060c6fe9b3684fbe4ff87656a9a46 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 15 May 2023 08:13:56 +0700 Subject: [PATCH 0561/1199] wait, no --- .../block/entity/decorative/FluidTankBlockEntity.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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 ed07a882d..f10dc1c0a 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 @@ -45,10 +45,7 @@ class FluidTankBlockEntity(blockPos: BlockPos, blockState: BlockState) : Mattery return stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).map { it.tanks > 0 }.orElse(false) } - return stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).map { - it.fill(fluid[0], IFluidHandler.FluidAction.SIMULATE) > 0 || - it.drain(fluid[0], IFluidHandler.FluidAction.SIMULATE).isNotEmpty - }.orElse(false) + return stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).map { it.fill(fluid[0], IFluidHandler.FluidAction.SIMULATE) > 0 }.orElse(false) } override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { @@ -56,7 +53,13 @@ class FluidTankBlockEntity(blockPos: BlockPos, blockState: BlockState) : Mattery } }) ), - output = output.handler(HandlerFilter.OnlyOut) + output = output.handler(HandlerFilter.OnlyOut), + frontDefault = ItemHandlerMode.INPUT_OUTPUT, + backDefault = ItemHandlerMode.INPUT_OUTPUT, + leftDefault = ItemHandlerMode.INPUT_OUTPUT, + rightDefault = ItemHandlerMode.INPUT_OUTPUT, + topDefault = ItemHandlerMode.INPUT_OUTPUT, + bottomDefault = ItemHandlerMode.INPUT_OUTPUT, ) init { From 367a3ea98e1a3608d57cae4a6f0a7bcfcbad8368 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 26 May 2023 23:49:51 +0700 Subject: [PATCH 0562/1199] Split saveAdditional into saveLevel and saveShared --- .../mc/otm/block/entity/MatteryBlockEntity.kt | 29 +++++++++++++++++-- .../block/entity/MatteryDeviceBlockEntity.kt | 5 ++-- .../block/entity/MatteryPoweredBlockEntity.kt | 2 +- .../block/entity/MatteryWorkerBlockEntity.kt | 4 +-- .../entity/blackhole/BlackHoleBlockEntity.kt | 4 +-- .../decorative/CargoCrateBlockEntity.kt | 6 ++-- .../entity/decorative/HoloSignBlockEntity.kt | 2 +- .../entity/matter/MatterBottlerBlockEntity.kt | 5 ---- .../entity/matter/MatterPanelBlockEntity.kt | 4 +-- .../entity/storage/ItemMonitorBlockEntity.kt | 6 ++-- .../entity/tech/EnergyCounterBlockEntity.kt | 10 ++++--- .../mc/otm/core/util/Savetables.kt | 2 +- .../mc/otm/data/Codec2Serializer.kt | 18 ++++++------ 13 files changed, 60 insertions(+), 37 deletions(-) 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 1d3ef857c..2cdd698da 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 @@ -67,7 +67,7 @@ import kotlin.reflect.KProperty import kotlin.reflect.KProperty0 /** - * Absolute barebone block entity class in Overdrive that Matters, providing bare minimum functionality + * Absolute barebone (lol) block entity class in Overdrive that Matters, providing bare minimum (lulmao, minecraft engine) functionality */ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: BlockPos, p_155230_: BlockState) : BlockEntity(p_155228_, p_155229_, p_155230_) { private var isSynchronizing = false @@ -97,8 +97,17 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc private data class SidelessCap(val cap: T, var optional: LazyOptional) private val sidelessCaps = Reference2ObjectOpenHashMap, SidelessCap<*>>() protected val tickList = TickList() + + /** + * Shared savetables, written both to level storage and to item tag + */ protected val savetables = Savetables() + /** + * Level-only savetables, written only to level storage + */ + protected val savetablesLevel = Savetables() + open fun tick() { tickList.tick() } @@ -401,14 +410,30 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc savetables.stateful(property, name, T::class.java) } - override fun saveAdditional(nbt: CompoundTag) { + final override fun saveAdditional(nbt: CompoundTag) { super.saveAdditional(nbt) + saveShared(nbt) + saveLevel(nbt) + } + + /** + * Saved both to item dropped, and to level storage + */ + open fun saveShared(nbt: CompoundTag) { savetables.serializeNBT(nbt) } + /** + * Only saved to level storage, discarded when dropped as item + */ + open fun saveLevel(nbt: CompoundTag) { + savetablesLevel.serializeNBT(nbt) + } + override fun load(nbt: CompoundTag) { super.load(nbt) savetables.deserializeNBT(nbt) + savetablesLevel.deserializeNBT(nbt) } @Suppress("OVERRIDE_DEPRECATION") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index 74216b68f..dcef9b156 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -62,8 +62,9 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo protected open fun redstoneStatusUpdated(newBlocked: Boolean, oldBlocked: Boolean) {} - override fun saveAdditional(nbt: CompoundTag) { - super.saveAdditional(nbt) + override fun saveShared(nbt: CompoundTag) { + super.saveShared(nbt) + if (customDisplayName != null) nbt.putJson("Name", Component.Serializer.toJsonTree(customDisplayName!!)) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt index 9a7390335..a563312ce 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt @@ -25,7 +25,7 @@ abstract class MatteryPoweredBlockEntity(p_155228_: BlockEntityType<*>, p_155229 val batteryItemHandler = batteryContainer.handler(HandlerFilter.Dischargeable) init { - savetable(::batteryContainer, BATTERY_KEY) + savetables.stateful(::batteryContainer, BATTERY_KEY) } override fun tick() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt index 0bf39c687..b19fee0c5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt @@ -156,8 +156,8 @@ abstract class MatteryWorkerBlockEntity( return (workTicks / currentJob.ticks).coerceAtMost(1.0).toFloat() } - override fun saveAdditional(nbt: CompoundTag) { - super.saveAdditional(nbt) + override fun saveShared(nbt: CompoundTag) { + super.saveShared(nbt) nbt[WORK_TICKS_KEY] = workTicks currentJob?.let { nbt[JOB_KEY] = it.serializeNBT() } } 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 55697319c..41e9360d7 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 @@ -161,8 +161,8 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery } } - public override fun saveAdditional(nbt: CompoundTag) { - super.saveAdditional(nbt) + override fun saveLevel(nbt: CompoundTag) { + super.saveLevel(nbt) nbt["mass"] = mass.serializeNBT() nbt["spin_direction"] = spinDirection } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt index e1bf6e0e6..25fc2140c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt @@ -84,11 +84,11 @@ class CargoCrateBlockEntity( init { exposeItemsGlobally(handler) - savetable(::container, INVENTORY_KEY) + savetablesLevel.stateful(::container, INVENTORY_KEY) } - override fun saveAdditional(nbt: CompoundTag) { - super.saveAdditional(nbt) + override fun saveLevel(nbt: CompoundTag) { + super.saveLevel(nbt) lootTable?.let { nbt[LOOT_TABLE_KEY] = it.toString() } lootTableSeed?.let { nbt[LOOT_TABLE_SEED_KEY] = it } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt index e6eecaf09..3e2884aa4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/HoloSignBlockEntity.kt @@ -29,7 +29,7 @@ class HoloSignBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryB init { savetables.string(::signText) - savetables.bool(::isLocked) + savetablesLevel.bool(::isLocked) savetables.stateful(::redstoneControl) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index 87d3d7b84..812c7045d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -46,11 +46,6 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : this.setChangedLight() } - fun switchWorkFlow() { - isBottling = !isBottling - updateBlockState() - } - private fun updateBlockState() { val level = level as? ServerLevel ?: return diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt index 76284295d..b51146f0e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt @@ -140,8 +140,8 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return true } - override fun saveAdditional(nbt: CompoundTag) { - super.saveAdditional(nbt) + override fun saveShared(nbt: CompoundTag) { + super.saveShared(nbt) val list = ListTag() 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 1bb496c93..73247f2d3 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 @@ -222,7 +222,7 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : if (!inProcessOfCraft) scanCraftingGrid() } - } + }.also(::addDroppableContainer) private var inProcessOfCraft = false @@ -448,8 +448,8 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val craftingResultContainer = CraftingResultContainer() - override fun saveAdditional(nbt: CompoundTag) { - super.saveAdditional(nbt) + override fun saveLevel(nbt: CompoundTag) { + super.saveLevel(nbt) nbt.put("player_settings", CompoundTag().also { for ((key, value) in this.settings) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt index 189ac1b99..967565860 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt @@ -81,18 +81,20 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat return value } - override fun saveAdditional(nbt: CompoundTag) { - super.saveAdditional(nbt) + override fun saveShared(nbt: CompoundTag) { + super.saveShared(nbt) nbt[PASSED_ENERGY_KEY] = passed.serializeNBT() + ioLimit?.let { nbt[IO_LIMIT_KEY] = it.serializeNBT() } + } + override fun saveLevel(nbt: CompoundTag) { + super.saveLevel(nbt) val list = ListTag() nbt[POWER_HISTORY_KEY] = list nbt[POWER_HISTORY_POINTER_KEY] = historyTick for (num in history) list.add(num.serializeNBT()) - - ioLimit?.let { nbt[IO_LIMIT_KEY] = it.serializeNBT() } } override fun load(nbt: CompoundTag) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt index acc1b2845..670a2a580 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt @@ -22,7 +22,7 @@ import kotlin.reflect.KMutableProperty0 import kotlin.reflect.KProperty0 /** - * Utility class to manage list of composited properties in other classes to be (de)serialized in NBT tags + * Utility class to manage serialization and deserialization of properties */ class Savetables : INBTSerializable { private val entries = ArrayList>() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt index 6d026f219..10d9550bd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt @@ -11,27 +11,27 @@ import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.core.toJsonStrict class Codec2Serializer(val codec: Codec, val embed: Boolean = true) : Serializer { - override fun serialize(p_79325_: JsonObject, p_79326_: T, p_79327_: JsonSerializationContext) { + override fun serialize(data: JsonObject, value: T, context: JsonSerializationContext) { if (embed) { - val result = codec.toJsonStrict(p_79326_, p_79325_) + val result = codec.toJsonStrict(value, data) if (result !is JsonObject) { throw RuntimeException("Expected JsonObject from codec, got ${result::class.qualifiedName}") } - val keys = ArrayList(p_79325_.keySet()) - for (k in keys) p_79325_.remove(k) - for ((k, v) in result.entrySet()) p_79325_[k] = v + val keys = ArrayList(data.keySet()) + for (k in keys) data.remove(k) + for ((k, v) in result.entrySet()) data[k] = v } else { - p_79325_["value"] = codec.toJsonStrict(p_79326_) + data["value"] = codec.toJsonStrict(value) } } - override fun deserialize(p_79323_: JsonObject, p_79324_: JsonDeserializationContext): T { + override fun deserialize(data: JsonObject, context: JsonDeserializationContext): T { if (embed) { - return codec.fromJsonStrict(p_79323_) + return codec.fromJsonStrict(data) } else { - return codec.fromJsonStrict(p_79323_["value"] ?: throw JsonSyntaxException("Missing 'value' element")) + return codec.fromJsonStrict(data["value"] ?: throw JsonSyntaxException("Missing 'value' element")) } } } From 2f2343f0baa8d2fa2a1374a6a7eeb6db9d3c9f71 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 26 May 2023 23:50:49 +0700 Subject: [PATCH 0563/1199] bump JEI version --- build.gradle.kts | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 54188a8b6..077846911 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -188,7 +188,7 @@ dependencies { compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-common-api:${jei_version}")) compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge-api:${jei_version}")) -// runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}")) + runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}")) runtimeOnly(fg.deobf("curse.maven:jade-324717:${jade_id}")) runtimeOnly(fg.deobf("curse.maven:configured-457570:${configured_id}")) diff --git a/gradle.properties b/gradle.properties index 12fe55182..bc19199ab 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,7 +21,7 @@ forge_version=45.0.47 mixingradle_version=0.7.32 mixin_version=0.8.5 -jei_version=13.1.0.6 +jei_version=13.1.0.11 jupiter_version=5.9.2 mekanism_version=1.19.2-10.3.5.homebaked curios_version=5.1.5.1 From 3c25353367eb7cbc470a6c518a14e48e1d66fd14 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 27 May 2023 00:03:48 +0700 Subject: [PATCH 0564/1199] Update pill advancement description --- .../mc/otm/datagen/advancements/AdvancementData.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt index 732c9cac5..3898e9ce8 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt @@ -524,8 +524,8 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist title = translation.add("pill", "Side Colored Mystery") { russian("Мистика с цветными краями") }, - description = translation.add("pill.desc", "Find some of those mysterious pills. Consult with Cleric before trying to ingest them.") { - russian("Найдите одну из этих ваших мистических пилюль. Проконсультируйтесь с клериком перед употреблением.") + description = translation.add("pill.desc", "Find some of those mysterious pills") { + russian("Найдите одну из этих ваших мистических пилюль") }, ) .requirements(RequirementsStrategy.OR) From bb2f5ccaacae4a438e07f8fb116635ea0be8a1b7 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 27 May 2023 00:07:26 +0700 Subject: [PATCH 0565/1199] add creative tab themselves after list --- src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt index b9732918e..1ee0fa894 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt @@ -271,7 +271,7 @@ object MCreativeTabs { } } - DECORATIVE = event.registerCreativeModeTab(ResourceLocation(OverdriveThatMatters.MOD_ID, "decorative")) { + DECORATIVE = event.registerCreativeModeTab(ResourceLocation(OverdriveThatMatters.MOD_ID, "decorative"), listOf(), listOf(MAIN)) { it.icon { ItemStack(MRegistry.VENT.item, 1) } it.title(TranslatableComponent("itemGroup.otm_decorative")) From e82d7b74a7916d8c8f8efcf567428520a3006dc6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 28 May 2023 15:48:04 +0700 Subject: [PATCH 0566/1199] Gravity -> Spacetime, in locale, where applicable --- .../mc/otm/datagen/lang/English.kt | 22 +++++++++---------- .../mc/otm/datagen/lang/Russian.kt | 22 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index fd1b25172..1817ae2ee 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -173,7 +173,7 @@ private fun misc(provider: MatteryLanguageProvider) { misc("iteration", "Iteration %s") misc("death_reason", "Decommissioned!") - misc("item.blackhole_immunity", "Negates gravitational effects of singularities") + misc("item.blackhole_immunity", "Negates spacetime dilating effect of singularities") misc("suffix.merge", "%s %s") @@ -372,7 +372,7 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.MATTER_REPLICATOR, "Matter Replicator") add(MBlocks.MATTER_BOTTLER, "Matter Bottler") add(MBlocks.DRIVE_VIEWER, "Drive Viewer") - add(MBlocks.BLACK_HOLE, "Local Anomalous Singular Gravitation Field") + add(MBlocks.BLACK_HOLE, "Local Anomalous Spacetime Dilation Singular Point") add(MBlocks.COBBLESTONE_GENERATOR, "Cobblestone Generator") add(MBlocks.ESSENCE_STORAGE, "Essence Storage") add(MBlocks.ESSENCE_STORAGE, "desc", "Allows to store and retrieve experience levels") @@ -421,11 +421,11 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.STORAGE_IMPORTER, "Storage Importer") add(MBlocks.STORAGE_EXPORTER, "Storage Exporter") - add(MBlocks.GRAVITATION_STABILIZER, "Space-Time Equalizer") - add(MBlocks.GRAVITATION_STABILIZER_LENS, "Space-Time Equalizer Lens") - add(MBlocks.GRAVITATION_STABILIZER, "desc", "Reduces gravitation effects of singularities") + add(MBlocks.GRAVITATION_STABILIZER, "Spacetime Normalizer") + add(MBlocks.GRAVITATION_STABILIZER_LENS, "Spacetime Normalizer Lens") + add(MBlocks.GRAVITATION_STABILIZER, "desc", "Reduces spacetime distortion effects of singularities") add(MBlocks.GRAVITATION_STABILIZER, "desc2", "Keep in mind the effect of multiple stabilizers produce exponentially increasing result") - add(MBlocks.GRAVITATION_STABILIZER, "desc3", "Too weak gravitation field will cause singularity to melt and evaporate away very fast") + add(MBlocks.GRAVITATION_STABILIZER, "desc3", "Too weak gravitation field will cause singularity to 'evaporate' really fast!") add(MBlocks.PHANTOM_ATTRACTOR, "Phantom Attractor") add(MBlocks.PHANTOM_ATTRACTOR, "desc", "Attracts Phantoms when it is night time") @@ -490,9 +490,9 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.BLACK_HOLE_SCANNER, "desc", "Scans singularities for their properties") add(MItems.BLACK_HOLE_SCANNER, "desc2", "Hold in hand to determine mass of singularities") - add(MItems.GRAVITATION_FIELD_LIMITER, "Gravitation Field Limiter") - add(MItems.GRAVITATION_FIELD_SENSOR, "Gravitation Field Sensor") - add(MItems.PORTABLE_GRAVITATION_STABILIZER, "Portable Space-Time Equalizer") + add(MItems.GRAVITATION_FIELD_LIMITER, "Spacetime Distortion Limiter") + add(MItems.GRAVITATION_FIELD_SENSOR, "Spacetime Sensor") + add(MItems.PORTABLE_GRAVITATION_STABILIZER, "Portable Spacetime Normalizer") add(MItems.BATTERY_CRUDE, "Crude Battery") add(MItems.BATTERY_BASIC, "Basic Battery") @@ -550,9 +550,9 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.REINFORCED_TRITANIUM_PLATE, "description", "An armor plate, reinforced to withstand great kinetic forces") add(MItems.CARBON_MESH, "Carbon Mesh") - add(MItems.GRAVITATIONAL_DISRUPTOR, "Gravitational Disruptor") + add(MItems.GRAVITATIONAL_DISRUPTOR, "Spacetime Equalizer") - add(MItems.GRAVITATIONAL_DISRUPTOR, "description", "Once within close proximity of supermassive body, suppresses any gravity in it's radius") + add(MItems.GRAVITATIONAL_DISRUPTOR, "description", "Once within close proximity of massive spacetime dilation anomaly, equalizes spacetime in it's radius") add(MItems.GRAVITATIONAL_DISRUPTOR, "description2", "Allows collapse of singularities") add(MItems.GRAVITATIONAL_DISRUPTOR, "description3", "Doesn't destroy any of mass singularity had acquired, which result in violent explosion of matter!") add(MItems.GRAVITATIONAL_DISRUPTOR, "description4", "The explosion %s be contained by %s. Do not even attempt to contain it.") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 304a43b57..1b957ba61 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -181,7 +181,7 @@ private fun misc(provider: MatteryLanguageProvider) { misc("iteration", "Итерация %s") misc("death_reason", "Списан!") - misc("item.blackhole_immunity", "Нейтрализует гравитационные эффекты сингулярностей") + misc("item.blackhole_immunity", "Нейтрализует искажение пространства-времени сингулярностями") misc("suffix.merge", "%s %s") @@ -377,7 +377,7 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.MATTER_REPLICATOR, "Репликатор материи") add(MBlocks.MATTER_BOTTLER, "Бутилировщик материи") add(MBlocks.DRIVE_VIEWER, "Просмотрщик дисков конденсации") - add(MBlocks.BLACK_HOLE, "Локализированное аномальное сингулярное гравитационное поле") + add(MBlocks.BLACK_HOLE, "Локализированная сингулярная точка аномального искажения пространства-времени") add(MBlocks.COBBLESTONE_GENERATOR, "Генератор булыжника") add(MBlocks.ESSENCE_STORAGE, "Хранилище эссенции") add(MBlocks.ESSENCE_STORAGE, "desc", "Позволяет хранить очки опыта") @@ -428,9 +428,9 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.GRAVITATION_STABILIZER, "Стабилизатор пространства-времени") add(MBlocks.GRAVITATION_STABILIZER_LENS, "Линза стабилизатора пространства-времени") - add(MBlocks.GRAVITATION_STABILIZER, "Desc", "уменьшает гравитационное влияние сингулярностей") - add(MBlocks.GRAVITATION_STABILIZER, "Desc2", "имейте ввиду, что несколько стабилизаторов создают экспоненциальный эффект") - add(MBlocks.GRAVITATION_STABILIZER, "Desc3", "слишком слабое гравитационное поле сингулярности приведёт к быстрому испарению последней") + add(MBlocks.GRAVITATION_STABILIZER, "Desc", "Уменьшает искажение пространства-времени сингулярностей") + add(MBlocks.GRAVITATION_STABILIZER, "Desc2", "Имейте ввиду, что несколько стабилизаторов создают экспоненциальный эффект") + add(MBlocks.GRAVITATION_STABILIZER, "Desc3", "Слишком слабое искажение пространства-времени приведёт к быстрому 'испарению' сингулярности!") add(MBlocks.PHANTOM_ATTRACTOR, "Приманщик фантомов") add(MBlocks.PHANTOM_ATTRACTOR, "Desc", "приманивает фантомов в ночное время") @@ -491,12 +491,12 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.FLUID_CAPSULE, "Жидкостная капсула") add(MItems.FLUID_CAPSULE, "named", "Жидкостная капсула (%s)") - add(MItems.BLACK_HOLE_SCANNER, "Сканер сингулярностей") + add(MItems.BLACK_HOLE_SCANNER, "Сканер ёярностей") add(MItems.BLACK_HOLE_SCANNER, "desc", "Сканирует сингулярности и считывает их свойства") add(MItems.BLACK_HOLE_SCANNER, "desc2", "Держите в любой их рук для считывания массы сингулярностей") - add(MItems.GRAVITATION_FIELD_LIMITER, "Ограничитель гравитационного поля") - add(MItems.GRAVITATION_FIELD_SENSOR, "Сенсор гравитационного искажения") + add(MItems.GRAVITATION_FIELD_LIMITER, "Ограничитель искажения пространства-времени") + add(MItems.GRAVITATION_FIELD_SENSOR, "Сенсор искажения пространства-времени") add(MItems.PORTABLE_GRAVITATION_STABILIZER, "Портативный стабилизатор пространства-времени") add(MItems.BATTERY_CRUDE, "Самобытный аккумулятор") @@ -555,10 +555,10 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.REINFORCED_TRITANIUM_PLATE, "description", "Бронированная пластина, усиленная что бы выдержать большие кинетические силы") add(MItems.CARBON_MESH, "Углеродная сетка") - add(MItems.GRAVITATIONAL_DISRUPTOR, "Антигравитационный маяк") + add(MItems.GRAVITATIONAL_DISRUPTOR, "Маяк уравнения пространства-времени") - add(MItems.GRAVITATIONAL_DISRUPTOR, "description", "Будучи находясь около сверхмассивного тела, создаёт противоположное искажение пространства-времени") - add(MItems.GRAVITATIONAL_DISRUPTOR, "description2", "Позволяет уничтожать сингулярности") + add(MItems.GRAVITATIONAL_DISRUPTOR, "description", "Будучи находясь около точки искажения пространства-времени, создаёт противоположное искажение пространства-времени") + add(MItems.GRAVITATIONAL_DISRUPTOR, "description2", "Позволяет 'уничтожать' сингулярности") add(MItems.GRAVITATIONAL_DISRUPTOR, "description3", "Никак не влияет на материю, которую накопила сингулярность, что вызывает неописуемо сильный взрыв материи!") add(MItems.GRAVITATIONAL_DISRUPTOR, "description4", "Взрыв %s сдержан %s. Даже не пытайтесь его сдержать.") add(MItems.GRAVITATIONAL_DISRUPTOR, "description4_clarification", "не может быть") From e373512a61c0ec3212da5ce3917b1375ec6b5897 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 30 May 2023 09:50:23 +0700 Subject: [PATCH 0567/1199] i would like to introduce you to `saveShared` --- .../mc/otm/data/loot/CopyTileNbtFunction.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt index d607e1ec4..4858c7cf3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt @@ -14,6 +14,7 @@ import net.minecraft.world.level.storage.loot.Serializer import net.minecraft.world.level.storage.loot.functions.LootItemFunction import net.minecraft.world.level.storage.loot.functions.LootItemFunctionType import net.minecraft.world.level.storage.loot.parameters.LootContextParams +import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.core.stream @@ -34,7 +35,14 @@ class CopyTileNbtFunction(filter: Stream = Stream.empty()) : LootIte val blockEntity = u.getParamOrNull(LootContextParams.BLOCK_ENTITY) ?: return t val result = t.tagNotNull[BlockItem.BLOCK_ENTITY_TAG] as? CompoundTag - val data = blockEntity.saveWithoutMetadata() + val data: CompoundTag + + if (blockEntity is MatteryBlockEntity) { + data = CompoundTag() + blockEntity.saveShared(data) + } else { + data = blockEntity.saveWithoutMetadata() + } for (k in filter) { data.remove(k) From 068e6ba3f9ea9c286dd676283b945c369503d6be Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 31 May 2023 14:09:12 +0700 Subject: [PATCH 0568/1199] Configurable Fluid Handler --- .../mc/otm/datagen/lang/English.kt | 1 + .../mc/otm/datagen/lang/Russian.kt | 1 + .../block/entity/MatteryDeviceBlockEntity.kt | 220 ++++++++++++++++-- .../entity/decorative/FluidTankBlockEntity.kt | 3 +- .../mc/otm/client/render/Widgets18.kt | 1 + .../screen/decorative/FluidTankScreen.kt | 2 +- .../client/screen/panels/button/Buttons.kt | 66 +++++- .../mc/otm/core/util/Savetables.kt | 2 +- .../mc/otm/menu/decorative/FluidTankMenu.kt | 2 + .../otm/menu/input/FluidConfigPlayerInput.kt | 68 ++++++ .../textures/gui/widgets/side_controls.png | Bin 2020 -> 2050 bytes .../textures/gui/widgets/side_controls.xcf | Bin 36864 -> 37629 bytes 12 files changed, 338 insertions(+), 28 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/FluidConfigPlayerInput.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 1817ae2ee..2f178dfb4 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -659,6 +659,7 @@ private fun gui(provider: MatteryLanguageProvider) { gui("sides.item_config", "Item Configuration") gui("sides.energy_config", "Energy Configuration") + gui("sides.fluid_config", "Fluid Configuration") gui("sides.top", "Top") gui("sides.bottom", "Bottom") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 1b957ba61..c450a4a45 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -664,6 +664,7 @@ private fun gui(provider: MatteryLanguageProvider) { gui("sides.item_config", "Настройка предметов") gui("sides.energy_config", "Настройка энергии") + gui("sides.fluid_config", "Настройка жидкости") gui("sides.top", "Верхняя сторона") gui("sides.bottom", "Нижняя сторона") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index dcef9b156..44ed68d03 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -13,6 +13,8 @@ import net.minecraft.network.chat.Component import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraftforge.common.capabilities.ForgeCapabilities +import net.minecraftforge.fluids.FluidStack +import net.minecraftforge.fluids.capability.IFluidHandler import net.minecraftforge.items.IItemHandler import ru.dbotthepony.mc.otm.capability.CombinedItemHandler import ru.dbotthepony.mc.otm.capability.EmptyItemHandler @@ -21,6 +23,7 @@ import ru.dbotthepony.mc.otm.capability.UnmodifiableItemHandler import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.moveBetweenSlots import ru.dbotthepony.mc.otm.capability.moveEnergy +import ru.dbotthepony.mc.otm.capability.moveFluid import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.getValue import ru.dbotthepony.mc.otm.core.ifPresentK @@ -84,6 +87,153 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo } } + inner class ConfigurableFluidHandler( + val capability: T, + + val possibleModes: FlowDirection = FlowDirection.BI_DIRECTIONAL, + + val frontDefault: FlowDirection = possibleModes, + val backDefault: FlowDirection = possibleModes, + val leftDefault: FlowDirection = possibleModes, + val rightDefault: FlowDirection = possibleModes, + val topDefault: FlowDirection = possibleModes, + val bottomDefault: FlowDirection = possibleModes, + ) { + init { + exposeSideless(ForgeCapabilities.FLUID_HANDLER, capability) + } + + val front = Piece(RelativeSide.FRONT).also { it.flow = frontDefault } + val back = Piece(RelativeSide.BACK).also { it.flow = backDefault } + val left = Piece(RelativeSide.LEFT).also { it.flow = leftDefault } + val right = Piece(RelativeSide.RIGHT).also { it.flow = rightDefault } + val top = Piece(RelativeSide.TOP).also { it.flow = topDefault } + val bottom = Piece(RelativeSide.BOTTOM).also { it.flow = bottomDefault } + + val pieces = immutableMap { + put(RelativeSide.FRONT, front) + put(RelativeSide.BACK, back) + put(RelativeSide.LEFT, left) + put(RelativeSide.RIGHT, right) + put(RelativeSide.TOP, top) + put(RelativeSide.BOTTOM, bottom) + } + + val defaults = immutableMap { + put(RelativeSide.FRONT, frontDefault) + put(RelativeSide.BACK, backDefault) + put(RelativeSide.LEFT, leftDefault) + put(RelativeSide.RIGHT, rightDefault) + put(RelativeSide.TOP, topDefault) + put(RelativeSide.BOTTOM, bottomDefault) + } + + inner class Piece(val side: RelativeSide) : IFluidHandler, ITickable { + init { + tickList.always(this) + + // https://tenor.com/view/simp-metal-gear-liquid-snake-running-gif-16717852 + savetables.enum(::flow, "fluid_${side}_flow", FlowDirection::valueOf) + savetables.bool(::automatePull, "fluid_${side}_pull") + savetables.bool(::automatePush, "fluid_${side}_push") + } + + private val controller = sides[side]!!.Cap(ForgeCapabilities.FLUID_HANDLER, this) + private val neighbour by sides[side]!!.track(ForgeCapabilities.FLUID_HANDLER) + + var flow by synchronizer.enum(possibleModes, setter = { value, access, setByRemote -> + require(possibleModes.isSupertype(value)) { "Energy mode $value is not allowed (allowed modes: ${possibleModes.family})" } + + if (access.read() != value) { + access.write(value) + + if (value == FlowDirection.NONE) { + controller.close() + } else { + controller.close() + controller.expose() + } + } + }) + + // var automatePull by synchronizer.bool().property + var automatePull = false + // var automatePush by synchronizer.bool().property + var automatePush = false + + override fun tick() { + if (flow == FlowDirection.NONE || !automatePull && !automatePush || redstoneControl.isBlockedByRedstone) + return + + neighbour.ifPresentK { + if (flow.input && automatePull) { + moveFluid(source = it, destination = capability) + } + + if (flow.output && automatePush) { + moveFluid(source = capability, destination = it) + } + } + } + + override fun getTanks(): Int { + if (flow == FlowDirection.NONE) { + return 0 + } else { + return capability.getTanks() + } + } + + override fun getFluidInTank(tank: Int): FluidStack { + if (flow == FlowDirection.NONE) { + return FluidStack.EMPTY + } else { + return capability.getFluidInTank(tank) + } + } + + override fun getTankCapacity(tank: Int): Int { + if (flow == FlowDirection.NONE) { + return 0 + } else { + return capability.getTankCapacity(tank) + } + } + + override fun isFluidValid(tank: Int, stack: FluidStack): Boolean { + if (flow.input) { + return capability.isFluidValid(tank, stack) + } else { + return false + } + } + + override fun fill(resource: FluidStack, action: IFluidHandler.FluidAction): Int { + if (flow.input) { + return capability.fill(resource, action) + } else { + return 0 + } + } + + override fun drain(resource: FluidStack, action: IFluidHandler.FluidAction): FluidStack { + if (flow.output) { + return capability.drain(resource, action) + } else { + return FluidStack.EMPTY + } + } + + override fun drain(maxDrain: Int, action: IFluidHandler.FluidAction): FluidStack { + if (flow.output) { + return capability.drain(maxDrain, action) + } else { + return FluidStack.EMPTY + } + } + } + } + inner class ConfigurableEnergy( val capability: T, @@ -129,6 +279,25 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo private val capControllers = exposeEnergy(side, this@Piece) private val neighbour by sides[side]!!.track(ForgeCapabilities.ENERGY) + override var batteryLevel: Decimal by capability::batteryLevel + override val maxBatteryLevel: Decimal by capability::maxBatteryLevel + override val missingPower: Decimal by capability::missingPower + + override val canSetBatteryLevel: Boolean by capability::canSetBatteryLevel + + // var automatePull by synchronizer.bool().property + var automatePull = false + // var automatePush by synchronizer.bool().property + var automatePush = false + + init { + tickList.always(this) + + savetables.enum(::energyFlow, "energy_${side}_flow", FlowDirection::valueOf) + savetables.bool(::automatePull, "energy_${side}_pull") + savetables.bool(::automatePush, "energy_${side}_push") + } + override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { return capability.extractEnergy(howMuch, simulate) } @@ -151,12 +320,6 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo return Decimal.ZERO } - override var batteryLevel: Decimal by capability::batteryLevel - override val maxBatteryLevel: Decimal by capability::maxBatteryLevel - override val missingPower: Decimal by capability::missingPower - - override val canSetBatteryLevel: Boolean by capability::canSetBatteryLevel - override fun drainBattery(): Boolean { return capability.drainBattery() } @@ -180,10 +343,6 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo } } - init { - tickList.always(this) - } - override var energyFlow by synchronizer.enum(possibleModes, setter = { value, access, setByRemote -> require(possibleModes.isSupertype(value)) { "Energy mode $value is not allowed (allowed modes: ${possibleModes.family})" } @@ -201,15 +360,6 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo } } }) - - var automatePull by synchronizer.bool().property - var automatePush by synchronizer.bool().property - - init { - savetables.enum(::energyFlow, "energy_${side}_flow", FlowDirection::valueOf) - savetables.bool(::automatePull, "energy_${side}_pull") - savetables.bool(::automatePush, "energy_${side}_push") - } } } @@ -311,9 +461,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo put(RelativeSide.BOTTOM, bottomDefault) } - inner class Piece( - val side: RelativeSide, - ) : IItemHandler, ITickable { + inner class Piece(val side: RelativeSide) : IItemHandler, ITickable { private var currentHandler: IItemHandler = EmptyItemHandler private val capController = sides[side]!!.Cap(ForgeCapabilities.ITEM_HANDLER, this) private val neighbour by sides[side]!!.track(ForgeCapabilities.ITEM_HANDLER) @@ -346,7 +494,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo } }) - var automatePull by synchronizer.bool(setter = { value, access, _ -> + /*var automatePull by synchronizer.bool(setter = { value, access, _ -> if (access.readBoolean() != value) { access.write(value) @@ -366,7 +514,31 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo outerSlotPush = 0 } } - }).property + }).property*/ + + var automatePull = false + set(value) { + if (field != value) { + field = value + + if (value) { + innerSlotPush = 0 + outerSlotPush = 0 + } + } + } + + var automatePush = false + set(value) { + if (field != value) { + field = value + + if (value) { + innerSlotPush = 0 + outerSlotPush = 0 + } + } + } init { savetables.bool(::automatePull, "itemhandler_${side}_automatePull") 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 f10dc1c0a..5b184133e 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 @@ -62,8 +62,9 @@ class FluidTankBlockEntity(blockPos: BlockPos, blockState: BlockState) : Mattery bottomDefault = ItemHandlerMode.INPUT_OUTPUT, ) + val fluidConfig = ConfigurableFluidHandler(fluid) + init { - exposeGlobally(ForgeCapabilities.FLUID_HANDLER, fluid) savetables.stateful(::fluid, FLUID_KEY) savetables.stateful(::fillInput) savetables.stateful(::drainInput) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt index 75194029f..a34697f1c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt @@ -106,6 +106,7 @@ object Widgets18 { val BATTERY_ONLY = controlsGrid.next() val ITEMS_CONFIGURATION = controlsGrid.next() val ENERGY_CONFIGURATION = controlsGrid.next() + val FLUID_CONFIGURATION = controlsGrid.next() val LEFT_CONTROLS_ITEMS = controls2(LEFT_CONTROLS) val RIGHT_CONTROLS_ITEMS = controls2(RIGHT_CONTROLS) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/FluidTankScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/FluidTankScreen.kt index 4f9f9f00e..9edcc6387 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/FluidTankScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/FluidTankScreen.kt @@ -30,7 +30,7 @@ class FluidTankScreen(menu: FluidTankMenu, inventory: Inventory, title: Componen SlotPanel(this, frame, menu.output, x = 30f + s.width + 4f + 20f, y = 53f) - makeDeviceControls(this, frame, itemConfig = menu.itemConfig, redstoneConfig = menu.redstoneConfig) + makeDeviceControls(this, frame, itemConfig = menu.itemConfig, redstoneConfig = menu.redstoneConfig, fluidConfig = menu.fluidConfig) makeCuriosPanel(this, frame, menu.equipment.curiosSlots, autoAlign = true) PlayerEquipmentPanel(this, frame, armorSlots = menu.equipment.armorSlots).also { 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 0d9c8f7f2..d89dbc847 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 @@ -13,6 +13,7 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput +import ru.dbotthepony.mc.otm.menu.input.FluidConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.IPlayerInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import java.util.function.Predicate @@ -66,6 +67,18 @@ private fun > makeEnergyModeButton(screen: S, parent: Frame return button } +private fun > makeFluidModeButton(screen: S, parent: FramePanel, input: FluidConfigPlayerInput.Piece, side: RelativeSide): LargeEnumRectangleButtonPanel { + val button = LargeEnumRectangleButtonPanel(screen, parent, enum = FlowDirection::class.java, prop = input.input, defaultValue = input.default) + + for (v in FlowDirection.values()) { + button.add(v, skinElement = Widgets18.CONTROLS[side]!![v]!!, tooltip = TranslatableComponent(v.translationKey)) + } + + button.finish() + + return button +} + private fun moveButtons( front: EditablePanel<*>, back: EditablePanel<*>, @@ -191,6 +204,35 @@ private fun > makeEnergyConfigPanel( return frame } +private fun > makeFluidConfigPanel( + screen: S, + inputs: FluidConfigPlayerInput +): FramePanel { + val frame = object : FramePanel(screen, 78f, 80f, TranslatableComponent("otm.gui.sides.fluid_config")) { + override fun tickInner() { + super.tickInner() + + if (!isEverFocused()) { + remove() + } + } + } + + val front = makeFluidModeButton(screen, frame, inputs.pieces[RelativeSide.FRONT]!!, RelativeSide.FRONT).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } + val back = makeFluidModeButton(screen, frame, inputs.pieces[RelativeSide.BACK]!!, RelativeSide.BACK).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } + val left = makeFluidModeButton(screen, frame, inputs.pieces[RelativeSide.LEFT]!!, RelativeSide.LEFT).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } + val right = makeFluidModeButton(screen, frame, inputs.pieces[RelativeSide.RIGHT]!!, RelativeSide.RIGHT).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } + val top = makeFluidModeButton(screen, frame, inputs.pieces[RelativeSide.TOP]!!, RelativeSide.TOP).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } + val bottom = makeFluidModeButton(screen, frame, inputs.pieces[RelativeSide.BOTTOM]!!, RelativeSide.BOTTOM).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } + + pullPush(frame, inputs.pull, inputs.push) + moveButtons(front, back, left, right, top, bottom) + screen.addPanel(frame) + frame.requestFocus() + + return frame +} + class DeviceControls>( screen: S, parent: FramePanel, @@ -198,9 +240,11 @@ class DeviceControls>( val redstoneConfig: IPlayerInputWithFeedback? = null, val itemConfig: ItemConfigPlayerInput? = null, val energyConfig: EnergyConfigPlayerInput? = null, + val fluidConfig: FluidConfigPlayerInput? = null, ) : EditablePanel(screen, parent, x = parent.width + 3f, height = 0f, width = 0f) { val itemConfigButton: LargeRectangleButtonPanel? val energyConfigButton: LargeRectangleButtonPanel? + val fluidConfigButton: LargeRectangleButtonPanel? val redstoneControlsButton: LargeEnumRectangleButtonPanel? private var nextY = 0f @@ -262,6 +306,25 @@ class DeviceControls>( } else { energyConfigButton = null } + + if (fluidConfig != null) { + fluidConfigButton = addButton(object : LargeRectangleButtonPanel(screen, this@DeviceControls, y = nextY, skinElement = Widgets18.FLUID_CONFIGURATION) { + init { + tooltip = TranslatableComponent("otm.gui.sides.fluid_config") + } + + override fun onClick(mouseButton: Int) { + if (mouseButton == InputConstants.MOUSE_BUTTON_LEFT) { + val frame = makeFluidConfigPanel(screen, fluidConfig) + + frame.x = absoluteX + width / 2f - frame.width / 2f + frame.y = absoluteY + height + 8f + } + } + }) + } else { + fluidConfigButton = null + } } override fun tickInner() { @@ -278,6 +341,7 @@ fun > makeDeviceControls( redstoneConfig: IPlayerInputWithFeedback? = null, itemConfig: ItemConfigPlayerInput? = null, energyConfig: EnergyConfigPlayerInput? = null, + fluidConfig: FluidConfigPlayerInput? = null, ): DeviceControls { - return DeviceControls(screen, parent, extra = extra, redstoneConfig = redstoneConfig, itemConfig = itemConfig, energyConfig = energyConfig) + return DeviceControls(screen, parent, extra = extra, redstoneConfig = redstoneConfig, itemConfig = itemConfig, energyConfig = energyConfig, fluidConfig = fluidConfig) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt index 670a2a580..ce92d4f66 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt @@ -27,7 +27,7 @@ import kotlin.reflect.KProperty0 class Savetables : INBTSerializable { private val entries = ArrayList>() - interface Entry : INBTSerializable { + sealed interface Entry : INBTSerializable { val name: String val type: Class fun validate() 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 e7e1b4693..cce696644 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 @@ -13,6 +13,7 @@ import ru.dbotthepony.mc.otm.menu.MachineOutputSlot import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.FluidConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import ru.dbotthepony.mc.otm.menu.widget.FluidGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -22,6 +23,7 @@ class FluidTankMenu(containerId: Int, inventory: Inventory, tile: FluidTankBlock val equipment = makeEquipmentSlots(true) val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) val redstoneConfig = EnumInputWithFeedback(this) + val fluidConfig = FluidConfigPlayerInput(this, tile?.fluidConfig) val drainInput = object : MatterySlot(tile?.drainInput ?: SimpleContainer(1), 0) { override fun mayPlace(itemStack: ItemStack): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/FluidConfigPlayerInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/FluidConfigPlayerInput.kt new file mode 100644 index 000000000..aa0afad4e --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/FluidConfigPlayerInput.kt @@ -0,0 +1,68 @@ +package ru.dbotthepony.mc.otm.menu.input + +import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity +import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.core.immutableMap +import ru.dbotthepony.mc.otm.core.math.RelativeSide +import ru.dbotthepony.mc.otm.menu.MatteryMenu + +/** + * [allowPull] and [allowPush] controls whenever player is allowed to change these options + */ +class FluidConfigPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEntity.ConfigurableFluidHandler<*>? = null, val allowPull: Boolean = false, val allowPush: Boolean = false) { + var possibleModes by menu.mSynchronizer.enum(FlowDirection::class.java) + private set + + inner class Piece(val side: RelativeSide) { + val pull = BooleanInputWithFeedback(menu) + val push = BooleanInputWithFeedback(menu) + val input = EnumInputWithFeedback(menu) + + var default by menu.mSynchronizer.enum(FlowDirection.NONE) + + init { + pull.filter { allowPull } + push.filter { allowPush } + } + + fun with(config: MatteryDeviceBlockEntity.ConfigurableFluidHandler<*>.Piece, parent: MatteryDeviceBlockEntity.ConfigurableFluidHandler<*>) { + pull.with(config::automatePull) + push.with(config::automatePush) + input.withSupplier { config.flow }.withConsumer { if (parent.possibleModes.isSupertype(it)) config.flow = it } + } + } + + val pieces = immutableMap { for (side in RelativeSide.values()) put(side, Piece(side)) } + + // TODO + val pull = BooleanInputWithFeedback(menu) + + // TODO + val push = BooleanInputWithFeedback(menu) + + init { + pull.filter { allowPull } + push.filter { allowPush } + } + + fun with(config: MatteryDeviceBlockEntity.ConfigurableFluidHandler<*>) { + possibleModes = config.possibleModes + + for ((side, v) in config.pieces) { + pieces[side]!!.with(v, config) + pieces[side]!!.default = config.defaults[side]!! + } + + pull.withSupplier { pieces.values.all { it.pull.value } } + push.withSupplier { pieces.values.all { it.push.value } } + + pull.withConsumer { v -> pieces.values.forEach { it.pull.input.invoke(v) } } + push.withConsumer { v -> pieces.values.forEach { it.push.input.invoke(v) } } + } + + init { + if (config != null) { + with(config) + } + } +} diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.png index 30dfc45a74927934ac1da9d45c7a56a12abc9060..b9553b67fcfaa477c3745da08c68d80db3bd8028 100644 GIT binary patch delta 2011 zcmV<12PF994}uVoJ%3OXg-=sUMJf(<5E0B!o!Ui397`38V4<`XT6Hja=^r#{NK#xJ z1=oUuKZ{id7iV1^Tm?b!2gKFINzp}0ye}!Vi1ESYeVq5s;lBF-p;cq5*%t>?%`!5{ zgqSa^iosU|FisUkP-3Q@$}Z;MxxVh<!Trs)CVY z0d=U596$IU{C}RUS(=`5lR^m~@M7B^6F_hmXg6*9``EVICxHJMxYD}*dJCBQB)!?y zB1gc`HgIv>)#N?kat9cB(j`N3BtMlK2lJGX!DbmsR1p>J}z3x9pf00006VoOIv0Du1g{{a7>y{D4^000SaNLh0L z01m?d01m?e$8V@)00007bV*G`2j>MJ1vUm@yT6D400sX^L_t(|+U;F2Yuri@o;~y< z(xeEa2)-tTn+Go3xj76zQayP8z;SbxaUD{*x#S-NQUx2rHSP^*T%>VG5pdxq|6*T} zT)bAaJAdEIu5>zSJ}@?3-Dsr!G_$kwp(8RF42Is~)dx?nK6twk0bWn1><#%co3Y0% zRy)2ce-LQ=nE=Q5-#=OSaX$4w&hszy#o?)cad?_-=k)N2KRtZn+aynlL_;7CN+2ph zo~FMyg^)NB5=kS^KdY4+GI@xI9FW315z(jroPWzDPl)G>Tc?dcL`2^|zje9f3Gw#x zPnSDc|2}*6=kJeqcSJ<=?)LF@YA5S__RW5eOxS zG!khe5K53#BnqGU@JU9}R_v*-M;2`gt49`X3d`{)N}x4~Y!Ury(!z=RGMoAJk0iA$ zR)0G_l|E2Ab$_($8_u8DSSO3vbQUuYK z^HyzjP=(baQ4V=>B2X+6<&Z~{!jNifY=0?if~KlXM4nW%={oXAOZA*dZ^KTh^1OJN zKPDgz(o*e(KC~&?uwyV73KDZ zNJxkr;)jH2%T9$bJiIv}d73_hI?MHF(3{8gj7s@~tO>{Xa81w!Vg1QMCb*Qa3Q0p< z3agAf2?7~;bmS>fP;5Pcj69pGMt`>z6<3OWyt_*hf>Yd~)f87fq16XJEbYFiCE#o{!Ho-r&LZK8i|_jPtG-l{^a-;`p^e|3zhIk@pEj7#0lbP z(>A{51(H(Xx@N2`f28E$dWe0$Uer$V1pzs)aSKlrldDQaW3h&-R5TWAxRz>jUNaHGk>#$=8xcLn2NQm(#M)lIZ$q*S&e8a|6?Zv` z#PBog2H!Tk>raBOH*fsQ-7_a0OGTFXd`?6}7Z(>BArG3u*fmgW!Hke+Eclh4&ctJV zjyz$Cl8jeU^5iUtORPaktgYJgM_X0R=kvx0z^#GmYbXH1Aj zAWl>^#z^$_=FM+{T@n5HyN-vk<9qzP`}_M@sb^CQYF3e$Qrw}F#y#06iJI*^R^^p= zd1u$@Y@4gGq$1H2clh28xAu&@=q!%;r9AEeF@%1jsv%Js!IeL}6$$tQ!NIb`M!y?`wp4qf? z&ilk+R+1FrbK)_BE=c^yb=l=N&P9g>o*6bWsd?fsu~_V2xr15BP>H9BBZ{g~zL0fU z;k?CJt<+fSp8SQOytb0&I?Z9kv4jMY5Fw+6GAghTrBx%vM2hxf9{wT6pCp$|t}+-o z7Epx>$?=2#!GG^=&BD~An-q!x-7mKNF#-g3fo9#dzmILZc>?&Kfh(=;uQq_$Ptxmc zEpi0(Z37qAZB5<-E_Z;zCtWfmNAlAY3I*W(jJ_!c^xpzKYi@6?eVjf38R}~J1~@nb zMvIia?(yzmXK(+WY4!I5cXx8B@Nu&i00006VoOIv0Do=(ZUAmK0@x-1000SaNLh0L z01m?d01m?e$8V@)00007bV*G`2j>D62?HZs32bQq00rSmL_t(|+U;FEYaB@stzPy= zIB{UOz-SW(N)8k#Q?dxOI6An0AS>BOC^n9iNd5-~M~4Jv6XgOY3Y@IDz@R|M{foKa zyjJhrbbr^Y>Ym>Ds0WJ{&1`K=_nYdfuE#8q!C)|S7H>aQ^!8I_1L5J_Y{m}A*ZG`1 zXSv#|O8J98Y_2V-ALSG-BSFexHlkJ=zzo^cSUsP?9Cq|+nkOw6Y zyzJ=>Z#Q#EJhG*IiG?U zLA2$(Ra*tBuzDm)Ax}yK3Pqw6@@SSYq<`8P+Y&ZGm#SSvo>;Ug9eJdsddj4?VJBC4 zp1sT;6OaaJuJ%F~+7xZrF&GR6gTY`JB{s<&l2DdN%65@#hWbzb|4~I^)Aw@yE%bb@ zzlEM3v!m*TA&R@9lPKmx%J}$pQm)ItmXzz_?1%~E@5CbeA!8s>sLdfApHNiGaeob( z>q6{^I>=*G+{GsPdcAgBk1Vzkxbf|B{@roc8?)p4!(DIex_p07J5x>Mu^!O>Csw*s z9V3WOh!o=cglNmo6k)hOI6irrK7%^T^=Qz+<9bH9{6TWUG2UDgG$E|tS;z$E5>_G0 zP)T8xktaeRBaeFs)e~Axaf&;w9U~7z zAgi{ps2aMt(4?Q+TR|fsw`Ww!AJ@j3-WN5U6kIimk|`7gH@=~ELeYKmIkb%D{E69_ zv{6kAQAH=&%Fy_u@v-TNnD zhbivT#w|r`m&>0LcA~wo&?HNr0hmka*9Cn<^hsY;kxEnTmDGN!}Some!Zxj=mP>$9^>YJQAn;T6^(@&u2RuhsNtHc&5^np zo5P<{b|%unu?DM+kBC4<9)B!h){M{KpHy#(JDfby@frM+>P<9dhDKT~em%B6hkih?fHjwv>`;bIAMU1?Vbs=TW!?WA_#L;aE3$(0ih z=}GmFA~BcptqTe|t(~0JXfDB47esroA~Bcpt!oN8)J|^2=8#BaFn<^f27|#c>M}l5 zHixPbE}`sGSGg3<&dyXDepgplPV+s|&q*5k*P{|NOS2 z&lZ6=Mcnmz?X=|4kbj6%#HF+>v?RJe*>`W?p}kN?tsIf31bMay#66=A-NyGnvuW`4 z;aPtYe0z9bz1hET(qpm6vREvLi0J0#rZ?mvQYaFwJ0D-3xTR|-ktdi$bL2@$h;!s1 zIdZEu{n1uci^Za`YT|OB`ti{DZ4pbQNbK5gS#`~yF(DX%IDb*u7$ecQhxb1Tc1QH< zeI3uoPM`4aJv=;A`5uZarIs~Tkr-3lp_9hl*(iyc?QE;^ay-1V^m5kcoG7YDG{qgB zAfx+3LrbWq(rQbhfqodpZk-2cX0bqeSCRGr%y*z|2szVY!PTzze?OE zVb$|S;syDC4>oR(Dk+I_w;Og<%1?dLAPv&7k|%~;^t+@O_qse7G8_sqO=J<)a2% z{6M9s5Y85pIvLZcPMO+tQr}Kfr%BUJJ4M@Rout!*OwySoO={B2IHsnKNr2aL&s{9$ zzsxi{bNIb;e!q7~Vhw8T^)-98`s#s#fa*5vU5`Eng zH}8`8*aeAgzm@2}C~;dX@Ai1<2bv^yJ}+_i7ldJD&uSUy>66&^n#8bQ;{IPtJY<)6 z_+g1h2PJ;*4T;A-ka*%>631c6SHPKe(i+C-a`>dU zBK#&kE%;d8Uf|5a)QKd^UBD;nO0X-C5gjUmT4M}O8-6syTF{=ompdC~1ClGxC!F^rEr<1Lzt;3A*n zwu9i$x{KRR!}?kmx4mf0Sl(yc{wzi97ev%qW!ridsWQAmY1lGigEXpRT6Qt)lGslYy+EVfc%y*!cX;6%01GBQUkt$J39JGW`rG(_b>Y zu2&co7DeF4X+EC0h1kq~VlyMgz3DCvn~Njh%&G=grpmKNNs)by6xqKsc9$$-(7DtB zMa~DL$eA_1pXKK~e+w-@{vmneZU-$u{u${OZiLF5G?%#4I}~~Gd@4zq z34}rc2k1F91%gV&8|8G@u^UCP1vkQicW;K`P+^C6a+b0LV7VE1iaEJU3geZ;P(1Ap zLuCT)lo3XXbO z;kxz>BdxHK!Md6VeCYOZPZcRWkCM_8Gy>X73?8YAz{^EGUUDa~CHE0qvI_I08IOAA z82DF3;5Ys_xK`ZA%W6qg)<&wb9^BR(2B+4{D=OjJr7AD)Csp~=q$+>GI9J-r`3jXb zc15XN(dx^zu`6OfAXZ*6)|UUu20z#sfoH3HyyiOPs8un?5>{a3uJmwtcXI^ZukrEv zZxLC)i3-%~#uK$y8GQIy1U|0w@zpiNu5KlEb+^$~{|SSCw~4P)9DKH_kvBGyqH#MZ z8pHBScVdkL?)A^BDxtGMlAVj7<} z<6OC&5$JF6@%GnwVnH?69)nB;*e?^1&X;G&oL~27h9l9jIc+ude~<4g2_k zKNEl8BjOJ-Vzrh`A?E;=&;I%Pmyf+MUo9)hM91t@z2B87$5mNF(aQ5b1cuzcsT69rwnrw|NwHlW_pz)zC8e_XPu6|nM z+OrxT{jJ8wey?#urf^R{zuvM!CyPy+Zy+UH11!c z@xXqKqkq?UIP*yz`9!}yb`#%*Vmur0E?*@Bgx zwClq^6fByTcJry)T@(?dok$4v>=qbz&KZihl`vd4A1e#nloOkrq{vB%oY)W(HaW3H z3JBHSOp%imIUx;fa*?9NNKR7Z#3m=CkP}kUwuz}ia$@_?S42*1a$=K{SdexiCDgM` zPGW{4Zlw&{&d2VeoD++jSd*MsIVTo5vA*WS$~dvei8aXyDay&UBJJec#sBBT`d=rO zaw5lz|1E?EukS{TL>wqK`H+j}@X;4P_{w+$NWQcW@!k>#BC}bJG_o97h2xPHd81@N z1Uz)!pca=hqYji999t6Q*pfPVG|IK&eJAmOS?v(Lm-T2n>(R$?Y&4B-{WLs3JD=Wi ztR695?m*d799DLK!^&QiUzB$PlpAX9g5`7dm{k_g%VITn`2Sc|9TPM>kd;CU$G z83UTFDaK7Vk#OA*{%&s5cW={NglJw0X?lR?OHEHM$wLVq8o6}Bt7+Q0Y8xQRR5|C; zG?{cN*#IA|m{+<|mGzRWLMe>KSB081=D~#06#97F1@ZoG;M2@g9_7>3!C%g6re1iW zs284Ch*2+gDrMUt^j0+0+@|xSUQ*PHO})^Bs`<+$d1#zHG_>gyxl*)=+bU*yY2(A^ zE0ky3CeO4)iagVxQ<<1aZxu`_O(A)viy?^je*>Rpp7JQ4E*bu-BJ0_j?AfxE=f#yx zLmAK3B+r)iOi4M<7P(TiDy+8j`CDX?-jF_jbvLsC>Vl{MKP`1ZAm&qDvHZ0TRWj-L zNoBA;(;VF(b=PvuS(Eu(bCgQW$=UNu0f(n0@x0~0e4A%<{xY7?`CYiAX1d&FPY4{J zp2UfT4%kf`VXx;1`xzC1+w2PYYSnWB6QxOfquPP02uD@j$5B;na!E}D@a3{3R)@Tp zp3{g6>cUXd%274l997ewxj6UW`?GU_g_$29eHjd+c8GIo$2q4~%2ylK12h!zEox}c zVT&$gZ&5?$=cMtnY`_0a6Cbpa_~RxA7JtcQmK1TBC6=7kTm`stVG=L3IMBR^)#grC zn|H{~t=9xrR44J{We&8qu-dwT)z;n8U4C8Q>e?h-b1znRG#2j2y4AS+VNO`Sg%g$! z=e{70#PacYeKxNh+75AG+s`<#?W}yg<1YXmC%CzeGrHR9$Ft3KWPVFm4Pg8I3-Gm- zdGf}JpP1-tN}}EAz?xAmx8@Ztx8_ZGx|5phXh~x4ItM!c#A@edR=)@GKkKN;Rm+mt z-{ru%cUfI`oz?XLd8g~T5I+30`$OpZ2Wwq7S=&&Y>nGZik3Wp*vs<{L5pVZ|VPgpg zZ>;CwjUBRi6ZN#|9`0$=cXUr%TCzQD+N_zUPRU1~oSBCw*CsKv-GQx7a+$3oTxRPj zd18B$5GH@2Z;m_Q{)Tn;BJ1v#@=Cl;;KXA|l)Vnb!>q<_R^vQiH#eFYjF}@WRtc>>GAqNdKuB(tm39 zdgWKcH3Db#Ch@Hi2Zm>G?r;O=4nHiH9;g$-PbYK|!=vpm@&xN6`&l0umt&)40)Men zA5VC+vCywgWuFhe#0dxA;Dm!0@T=jd{O93M1swW-l|#2!IXqPcj-D6r`~mD%Ip!t(FG|6eKA!)E{h From 5f514a85abb97be80bca2ef976525154a76a1f2c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 1 Jun 2023 19:52:43 +0700 Subject: [PATCH 0569/1199] remove unused code --- .../mc/otm/client/render/GlitchRenderer.kt | 49 ------------------- 1 file changed, 49 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GlitchRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GlitchRenderer.kt index f2ae895c7..3de0eb99b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GlitchRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GlitchRenderer.kt @@ -24,47 +24,6 @@ import kotlin.math.absoluteValue @Suppress("SameParameterValue") object GlitchRenderer { - private abstract class VideoGlitchType { - abstract fun upload(builder: BufferBuilder, x: Double, y: Double, width: Double, height: Double, u0: Float, v0: Float, u1: Float, v1: Float) - - protected fun uploadVertices(faces: Int, builder: BufferBuilder, x: Double, y: Double, width: Double, height: Double, u0: Float, v0: Float, u1: Float, v1: Float, red: Int, green: Int, blue: Int, alpha: Int) { - if (faces and BOTTOM_LEFT != 0) { - builder.vertex(x, y + height, 0.0).uv(u0, v1).color(red, green, blue, alpha).endVertex() - } - - if (faces and BOTTOM_RIGHT != 0) { - builder.vertex(x + width, y + height, 0.0).uv(u1, v1).color(red, green, blue, alpha).endVertex() - } - - if (faces and TOP_RIGHT != 0) { - builder.vertex(x + width, y, 0.0).uv(u1, v0).color(red, green, blue, alpha).endVertex() - } - - if (faces and TOP_LEFT != 0) { - builder.vertex(x, y, 0.0).uv(u0, v0).color(red, green, blue, alpha).endVertex() - } - } - - protected fun uploadQuad(builder: BufferBuilder, x: Double, y: Double, width: Double, height: Double, u0: Float, v0: Float, u1: Float, v1: Float, red: Int, green: Int, blue: Int, alpha: Int) { - uploadVertices(TOP_LEFT or TOP_RIGHT or BOTTOM_RIGHT, builder, x, y, width, height, u0, v0, u1, v1, red, green, blue, alpha) - uploadVertices(TOP_LEFT or BOTTOM_RIGHT or BOTTOM_LEFT, builder, x, y, width, height, u0, v0, u1, v1, red, green, blue, alpha) - } - - companion object { - const val TOP_LEFT = 1 - const val TOP_RIGHT = 2 - const val BOTTOM_LEFT = 4 - const val BOTTOM_RIGHT = 8 - - val vertices = intArrayOf( - TOP_LEFT, - TOP_RIGHT, - BOTTOM_LEFT, - BOTTOM_RIGHT, - ) - } - } - private val random = XoroshiroRandomSource(System.nanoTime(), System.currentTimeMillis()) var redShiftX = 0.0 @@ -86,14 +45,6 @@ object GlitchRenderer { var nextGlitch = 0L private set - var lastEncodingGlitch = System.nanoTime() - private set - - var nextEncodingGlitch = 0L - private set - - - private val glitchBuffer by lazy(LazyThreadSafetyMode.NONE) { MainTarget(minecraft.window.width, minecraft.window.height) } From 76603cd6645634a377d5787af35f18fe77629735 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 7 Jun 2023 15:06:44 +0700 Subject: [PATCH 0570/1199] These are now patched into tooltip methods themselves --- .../mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt index fd2a201db..305536dd5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt @@ -58,11 +58,8 @@ abstract class AbstractSlotPanel> @JvmOverloads constru val itemstack = itemStack if (!itemstack.isEmpty) { - // val font = RenderProperties.get(itemstack).getFont(itemstack) val font = IClientItemExtensions.of(itemstack).getFont(itemstack, IClientItemExtensions.FontContext.TOOLTIP) - // TODO: WHERE???????????? - // GuiUtils.preItemToolTip(itemstack); screen.renderComponentTooltip( stack, getItemStackTooltip(itemstack), @@ -71,7 +68,6 @@ abstract class AbstractSlotPanel> @JvmOverloads constru font ?: screen.font, itemstack ) - // GuiUtils.postItemToolTip(); return true } From 30397f81979d2946c1520f5a7f77e58ba1a66652 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 7 Jun 2023 15:07:31 +0700 Subject: [PATCH 0571/1199] e --- .../ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 40b85dfd8..a6f7e640b 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 @@ -558,8 +558,6 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit renderFloatingItem(poseStack, itemstack, mouseX - 8, mouseY - i2, overrideCount) } - RenderSystem.disableDepthTest() - if (menu.carried.isEmpty) { val hoveredSlot = hoveredSlot @@ -567,14 +565,16 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit this.renderTooltip(poseStack, hoveredSlot.item, mouseX, mouseY) } else { for (panel in panels) { + RenderSystem.disableDepthTest() + if (panel.renderTooltips(poseStack, mouseXf, mouseYf, partialTick)) { break } } + + RenderSystem.enableDepthTest() } } - - RenderSystem.enableDepthTest() } override fun containerTick() { From c42961f68ea008142b92387fb9f0e607bee3e937 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 7 Jun 2023 15:37:05 +0700 Subject: [PATCH 0572/1199] useless --- .../ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 a6f7e640b..6c362df62 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 @@ -13,6 +13,7 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.inventory.Slot import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack +import net.minecraftforge.client.ForgeHooksClient import net.minecraftforge.client.event.ContainerScreenEvent.Render.Background import net.minecraftforge.client.event.ContainerScreenEvent.Render.Foreground import net.minecraftforge.common.MinecraftForge @@ -20,6 +21,7 @@ import org.lwjgl.opengl.GL11 import org.lwjgl.opengl.GL13 import ru.dbotthepony.mc.otm.config.ClientConfig import ru.dbotthepony.mc.otm.client.moveMousePosScaled +import ru.dbotthepony.mc.otm.client.render.clearDepth import ru.dbotthepony.mc.otm.client.render.translation import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel @@ -517,7 +519,6 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit RenderSystem.defaultBlendFunc() RenderSystem.enableBlend() RenderSystem.enableDepthTest() - RenderSystem.activeTexture(GL13.GL_TEXTURE0) for (i in panels.indices.reversed()) { val panel = panels[i] From 9f3a2c821abb6ddb1f816d350c5eb5bd18c115a2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 8 Jun 2023 11:04:21 +0700 Subject: [PATCH 0573/1199] Bump to minecraft 1.20 --- build.gradle.kts | 12 +++++------- gradle.properties | 8 ++++---- gradle/wrapper/gradle-wrapper.jar | Bin 59536 -> 61574 bytes gradle/wrapper/gradle-wrapper.properties | 3 ++- settings.gradle.kts | 12 ++++++++++++ 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 077846911..2076e4873 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -183,15 +183,15 @@ dependencies { val curios_mc_version: String by project val ad_astra_id: String by project - implementation(fg.deobf("top.theillusivec4.curios:curios-forge:${curios_mc_version}-${curios_version}")) - implementation(fg.deobf("curse.maven:cosmetic-armor-reworked-237307:$cosmetic_armor_reworked_id")) + compileOnly(fg.deobf("top.theillusivec4.curios:curios-forge:${curios_mc_version}-${curios_version}")) + compileOnly(fg.deobf("curse.maven:cosmetic-armor-reworked-237307:$cosmetic_armor_reworked_id")) compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-common-api:${jei_version}")) compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge-api:${jei_version}")) - runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}")) + //runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}")) - runtimeOnly(fg.deobf("curse.maven:jade-324717:${jade_id}")) - runtimeOnly(fg.deobf("curse.maven:configured-457570:${configured_id}")) + //runtimeOnly(fg.deobf("curse.maven:jade-324717:${jade_id}")) + //runtimeOnly(fg.deobf("curse.maven:configured-457570:${configured_id}")) compileOnly(fg.deobf("curse.maven:ad-astra-635042:${ad_astra_id}")) compileOnly(fg.deobf("curse.maven:resourceful-lib-570073:4378849")) @@ -275,8 +275,6 @@ minecraft { sources(sourceSets["main"], sourceSets["data"]) } } - - forceExit(false) } } } diff --git a/gradle.properties b/gradle.properties index bc19199ab..879ac047b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,18 +6,18 @@ kotlin.stdlib.default.dependency=false org.gradle.vfs.watch=true mod_id=overdrive_that_matters -mod_version=1.2 +mod_version=1.3 use_commit_hash_in_version=true -mc_version=1.19.4 +mc_version=1.20 use_parchment=false parchment_version=2023.03.12-1.19.3 jei_mc_version=1.19.4 curios_mc_version=1.19.4 -forge_gradle_version=5.1.+ -forge_version=45.0.47 +forge_gradle_version=[6.0,6.2) +forge_version=46.0.1 mixingradle_version=0.7.32 mixin_version=0.8.5 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180f2ae8848c63b8b4dea2cb829da983f2fa..943f0cbfa754578e88a3dae77fce6e3dea56edbf 100644 GIT binary patch delta 36900 zcmaI7V{m3&)UKP3ZQHh;j&0kvlMbHPwrx94Y}@X*V>{_2yT4s~SDp9Nsq=5uTw|_Z z*SyDA;~q0%0W54Etby(aY}o0VClxFRhyhkI3lkf_7jK2&%Ygpl=wU>3Rs~ZgXSj(C z9wu-Y1}5%m9g+euEqOU4N$)b6f%GhAiAKT7S{5tUZQ+O8qA*vXC@1j8=Hd@~>p~x- z&X>HDXCKd|8s~KfK;O~X@9)nS-#H{9?;Af5&gdstgNg%}?GllZ=%ag+j&895S#>oj zCkO*T+1@d%!}B4Af42&#LFvJYS1eKc>zxiny{a-5%Ej$3?^j5S_5)6c_G+!8pxufC zd9P-(56q5kbw)>3XQ7K853PQh24-~p}L;HQuyEO+s)M^Gk)Y#4fr1I*ySS6Z>g^ z3j2|yAwKXw?b#D4wNzK4zxeH;LuAJJct5s&k>(Qc2tH}2R3kpSJ)aaz!4*)5Vepww zWc0`u&~Lj*^{+V~D(lFTr?Eemqm3a{8wwF}l_dQsAQURmW$Bm$^?R10r)Xd_(HUYG zN)trq(ix@qb6alE>CCw@_H0*-r?5@|Fbx<6itm$^Qt~aj+h+Vd7l?ycraz%`lP%aB ziO6K|F?9|uUnx$T5aqKdAs74ED7SPSfzocG)~*66q;Yb=gB{=6k{ub6ho3Y`=;SnB z;W96mM@c5#(3(N~i_;u05{yUL8-BBVd|Z@8@(TO#gk&+1Ek#oDaZ?RNw{yG|z+^vm zz_8?GT|RX|oO;EH*3wMsfQTe(p6)G9a)6&yM+tYvZwg;#pZsdueT#%;G9gwXq%a(| zl*TBJYLyjOBS4he@nGA-CofFCVpGz!${(Qa{d?g*Yt zftsoLCHu-*AoZMC;gVx%qEKPVg@Ca2X(0LIQMr5^-B;1b)$5s^R@wa}C&FS9hr_0< zR(PnkT$}=;M;g}bw|7HERCSm?{<0JLnk{!U8*bbod@i#tj?Jr}|IcqMfaed&D?MHW zQQ>7BEPK-|c&@kx4femtLMpewFrq`MVIB%4e_8@IyFi9-$z0o48vnBWlh@E7Lz`C& z{~7u$g;@syjzMCZR|Nm+Jx^T!cp)q9$P*jxSQZ3le#HSIj=wN~)myB;srp0eMln_T z6?=}jUvU5_s4rEcO3k}*z#DQrR;TOvZGc03OR0)P5RI8M<#*B)8fYxxxX(I`Dks;X z_q5?sAs zMlaiDTP-1_XRMwL(q5h(W2yvr9HmtlnR);!9>U%TyViU)t#_5B#W0DnP!P#s!my-T zqbgQRIf%MWo*YUK2vXE8RIy;gJ8p^LU$c6POWt88``5^mIqohk~I!a zv-T{zI?eSLajm^r3>inooK|w$a_2H9J=;|sziKGRQ&FC5CWUF*#N6?n4rD-}S>Eg!tFkOpE7otS)$s3hyim=Ldy&-I$%Yra=M3xIOG{Jc zr8d_wbB301%Zy*8ILfeRiGfeQUIh2N3|41xAR|uvQ%?AIGUkdX*Ymgh z54d1)Igp9~)o7-h8AAH#6DzJ}UPh+srx=B^tGe~_(uwPoOov8sptn}$Rx@&$Ox^8H z!MND`vATA1%mR>+iCrV=b!*TSrj2TDv?Fnmj$=uw{JX1c$tt@zIC9gt)3Inpb+Q~= zh0Y@1o@R7|g+n0^b;v#5cc24{OYlnusF0tun^X?qHRYl#m%6UY?tK9vA zvtPnt7tgpi=qBIQ{v=D|p=4@{^E7)c3MLDCNMKPYec~o)VJ6zmZRE?UqXgYj7O~uG z^YQwQfQr>T!u&NaBfm|PW%g%cDoE8%t<-Ma$wIkMS{3sTS+aWpx=g7(+XtaLt9nqB zrLi<%uH29tuKZ6?`Ka5N0@G{F134GZ+6+RnA|Y+wCs~N*%N4CxyoB6?*{>AMy4w}` z@CMj>CaC}<;Y&#-a6~6AB=v2>)b=&t&D7SK6Vc4p+Tfg{AO(<+v?R1IsPA~@FvGJw z*d@a@6bydfT8{(k2N*D`FO@sUHbUIw4kQ(jrMPa2Mjc&~AK*xoe*c+VfsGx$cnzHQb4bSL2wJvVg>oYR*?s}CgoHMPLwA`Km%5LJm4a&OZ3QL*-+4G0t%;_ zS|DOILXL@I?hGl*3JvMq)Uq;%_B{$ipS*Qkn~F!-P^6Afg;Qf!n-zi$tpUjh9TEgk z$Em>`JJ(>S;8ZLM+$-RWUzFrR!@<;W=Y3ASjLR1`U zRnQ{ZU%JK?(2oo+c(5g;5Ez&I&5{C8{!I?aB34uFL`IQg#2z;=$Si?P0|qnfM1VdS zb6@5YL(+>w;EPEyeuX)yIA~VlFjk5^LQ^)aZ$<1LmDozK0cxH1z>q2*h5eR(*B8Pj6nS=K`)S3FLEV-S*4c;F0<9nRRu$YqiDCFaTc zU2LxT3wJJWeBb8}%B59!#)-W}_%?lSsy~vH3%oytE`j-^9*~SvMr-z3q=A7uy$?X& zf*Ky)z&7X0jy`YDtCs@NJw0+j_3CeDw_I25HR6CPV2t!asKPJV^R_r+u&LUxP)wtR zmFA-~HswLN)Ts=7{YPysG?DY))3+-L*En93o=+v+Kjw;_cUsONDZ!zzk{1O05Wm+3 z*2;}O&??lNOe-V{mDB}Gn<0_7H$ZCa5dWoq#}QCT(~h%=J=n@;@VXR52l^?vcj%GP zh7{kjosPu`1x+iQVU?(TJ^?xlT@AS>a?&FMQRTyRO?(2jczyS@T%&!d8mzxqO0r&;UjTNkbB)J1%*iB$McM0+stU%2(C}f0}_{G?dWaCGjmX7PnOq1 zdRr-MGfS#yqMH&mW5BiJE3#|^%`(niIKQ_BQ7xk`QFp50^I!yunb~0m24`10O=`w3 zc#^=Ae(B8CPKMDwLljERn*+I@7u8~-_2TPH`L# z=1~{&_1Fg{r>4*vu5rRTtDZ3}td&uZ)(p*OD4xfn01zzS+v3c_N~GkBgN$cm$Y%H} z1sPjxf=IxdrC~^)&Pvq1^e`~xXM2! zYU)LU02y$#S?v+CQ~GP{$|nR0d%`>hOlNwPU0Rr{E9ss;_>+ymGd10ASM{eJn+1RF zT}SD!JV-q&r|%0BQcGcRzR&sW)3v$3{tIN=O!JC~9!o8rOP6q=LW3BvlF$48 ziauC6R(9yToYA82viRfL#)tA@_TW;@)DcknleX^H4y+0kpRm zT&&(g50ZC+K(O0ZX6thiJEA8asDxF-J$*PytBYttTHI&)rXY!*0gdA9%@i#Sme5TY z(K6#6E@I~B?eoIu!{?l}dgxBz!rLS{3Q4PhpCSpxt4z#Yux6?y7~I=Yc?6P%bOq~j zI*D}tM^VMu{h6(>+IP|F8QYN`u{ziSK)DC*4*L>I4LoUwdEX_n{knkLwS`D-NRr>0 z&g8^|y3R$61{TgSK6)9&JZFhtApbp$KzF13WaC(QKwAZ|peA@Aol`&*>8RK(2|0%R zyo9nL{gtv}osWeNwLf@YG!wb9H2WRcYhg_DT60dzQGW(y7h7|4U*<;c*4N*sE2sdR zZRP^g;h(t0JLIuv)VNY6gZ)yUD)2d)p?eFznY8$~EZMYTiu%DF*7UeVQPV}h zF*|ls`|a+{u;cd>D@%~dRZBn~-Ac+m&Vg>P=3VY8+$<7Zi7p<~Nq zR^M^jl=zI!T`8H(gK0H945KY=N1J#Up`sWvfY$>1SGEfqEyKIokPVbexYnI`OXJF$ zkMS3dBE8RnB1dK)tJbNSu5Y&$IYBy38luzK-TGMpQcEojhte7Xff-zI50I2qM(i2F2)9DdagoKYlK zz%x8sxFf>5@1bI$-n*}N>o3o#^zP{$d7pf& zf*4SNbn9QDXDCVn;wo6|E0$(wBv*pgxHCA(S3lXJ4HMQW)rU}U7?F zxI}V}W~d>wx97Ozh+^glLBo{*j$o`=hK;idHhi4CG!_fG89V-Ew-^^hhMOWUdu-2< zd(t0O>8BgZ1N<2Xi1G3>r1@d)nBD*K3PsmP{s{&G;tmG_!k=7FNuKO+fCm`SxKP>B zK>mtj;Etn5J%mKvT;yE_zl8vk?q3f9hwea!Dt8yLUCgFO*BnS=YuY}-c!&0jb}J)D zV(s~BTYfVyXK<9y&hpVuS= zc!!wNsFjPgspRhCIw6}w^RvLX#?KnhpM(hB`U3x zg*!~MI$JfAFWhsN7xRdV^%0aygs+rZ;dpWzncKOTAa`0Xq7m(z zS_LwFYW$1KXsfgpFzlw7r#2KOQn(%ww?YQ$bT(GWx*gx2Bsny3J z!6UUPr8>TIGiK`%2m`PSS3Pd36m#OIl#SN?$h?mU25XXidM(*ZGBAelMO)H+;9Uw= z8`vjt5)+09c$b2FAWm3{jId9*ui3~Ihbw`9e-2;@?!T%Dqin&WFbQJt4_m@V=j9P* zbXi|lvH3x49-&)RB5c* zheg*i@5p((w*%DOB8-%Yv2P#-IHB%v>`Y&_9BR4)7ngJze2&>4c~NOkQnJ)jt+X$L z9`^6#2vV*K89hV$gu10|zu~;nKfa?ohox&sMS7NyTlMJCQAe^h{9nZwpoX?uy5xO? zW@PBU$b1{UOpv~AtZ#<+*z+(g?Fjwseh8lsxs5iozi*#gI!;qXBt)G~j z9v5n^MQKOT?2!Dj8;SOO0>6f3orwHJiOFK6`b<|b^4}5n{l-VQ?SoksHS=yv3$O(l zK4aL#0Zq4{g#z$jo$*dAJfuB~zb-n^5(3@{JHT~GGc;Ky(^y99NCxW2rZg%U^gIg; zJ%kBn@NxZn`e|BO6V4* z39i>kJU<7SyAHVHI%uKdcv|~U@W=4e@t=p!S?jnBEq^yQ2E14shzIlXKC?om(H84vN=o^2NtMBm7J~D=rmbm*NWjSVJeDEz-N5UmBk5`GjywWp zZ6s1IpXkUutr~lnCT>!2PPR9DIkuVbt|MCCR|#D(rD%~B zubEU^cc78hxs+x%Vg6$X@16i4ob@ek?PQijQzieZfi>E5NEg`76N6^2(v~ar1-yk2 z{{lAO$SjM{aof;NApyxnbEZnRO}8?!fT!U_<`21g+Y&qC_&99r6|*kDkDETgh-Blb z?9T7UIB}thISUzkw0O~5y~+>wtL{7Fc;gSldH8639yf31)qi4|Wq~g>_I0dfs^OGe z!K&|A^L|jeya>y7<>8(f3SXza9%^rl#3_31Neefn#Uk7*_^}IkM)e_&Fg~Ughu3}B zG0}?Kod{eb?94;$6dD4YV>n9mC5+Hy8M_h+bQmvUNvJ>0P#9a~pPDU9l#NrDP39Z> z7R3hA*IMVAod6Yl=s=BNyrblFv9ahxsA&Gst+0`2T@WSesGH1hRhw z#t7Smp){oxPiCm!XedMT9Xls`K+YKLV>+PC>98;G(5Lw*eBS5`f9B8Y2br|#y@jcz z`ddmVevy*mwN3@%YsE|Fsj!mu|5S)>5)wx;dbtMZ6Z1juCz$0kMS5-C{B5qnD{7ViiFNTv<&?w+5J7 zOvuImg^_o-ySHEQGAp-85!m8;Kjq_i-SzRFWcdAdj|VdIswTnUkggogN4`x{jEyG? zQ*_r9na<4wW8fySLr;PuoDVKKN@|y=99HWqBR+2kiH1prFkUgL{}*5_>twEG!W=|` z!(x}*NZ|P}Bf#p=-xK3y2>!x$6v(pYq)(6dQWk)$ZWSp%-^30dq``oVSfEWcTXE)1aMtpTQ;FW3e5ffMASm16(q#bJ}PAM2+l8m-{ z*nkDPH}ha-U3r{s>8XetSzpDN&nlc>|Er_gOMq?H8gtx5_)=$=rKn8D)UFKeitTF< zrA6>w`_sOEN&t!qEx|Pjw>cpv6y3zP58py3u%=88_f1w?Dh6qHi_=ps1{zKT3c+AJ z-CHtS&YwELV7i&XOXFt+doDFc=HdO@cjpeR_V#?~+=e|BdnS5C#8DCu@>*3!I9V9< zW8$!NLpp)$6Dt$s16B6U0ukr;dz~cWFIBq~D_Il@v4E@wH%Sf#P50K?&Z#GHc^JwQ5QyPaJatDTEbA97~OHLu)q6tU>srf)aJKx!w!`g-`+$hp=yl`47e};Vme|`Otn|zcuTh4TQZ6IKVT7?o{08_qzzuC#0N+` zUL{|(2B|=83J;W>uqDA61!wZ8=lN%B^2FGwkZO!2?1c;bDLELF1bQ^Y?Y+7uH}!W` z^`^=K4S@v^Hf0N&e`kde(pQ;BIt`1ze5~`Nn*fETHo^-|6KuqPj||YZ}sKX zV?ZxRbyMRcdpZnDH1-C5U5;4JguMyzlQm)=l~l=@z2)laaTx@kKq5APotoUE)xH#J z6)(ramD2fUHPdL793*l5S06`4Z3{&?tnR3xfYKS3B*A9}jW9$!H?R6_%7X{4+i!*D z*)40tp!3LCaUi_0jXN?z7Y6AEkZ^eIVyo1w;KO5iZg~7 zHCM5Jk&G}NQwK`~bXb=f#j!xIJJ#ETt7@1qhw9lR(hEuxbrv?Ct!{87z|%xN)YC*i zx*N?__cB*&7kQ_BKkH|g0C{L*XHjv2;aHF<^+m0ch@q*5qw}L{NLOF~Wij{R7GRxv zl5Ne^rT$D06;D(gWfiTsBRtZy(NY}48_YzA+&O?{^mT^%=g%f;Ze*H{?}d8=k;bAO*Q1?nvfP#$3|aI1lz{jcLWDIa9v7R}*UUhVLB> z?TDq)NCcJE9S%g0rVmhrf>=Nw6kt8m!lpu=;6aU-%{(-cj)pA`DiK5kE7&tX-cAxk zV7ZG}Y!Ot|OEx!qA%%(cHP{?eqT&8(26rmJ5#`!FG&0ynY|*(Kz?poEylYbT zipX*&ApQikP2)eD@Cw5>GKY=XH&1uQkIwKs&xAMXwn91ntk9#gnYz6e93PIWrmt>FDJ!k43qNZXPf6WzmzXnJHc=iBBr{8^QV3P3jBjzp1TS;KxA;CN~^( z+=W87)Xjkhvi+QF4Lx^aaWOqm(0Y9CO0GFZR8z&yMefP`|0m~2!!3xZ8Lm2Rvv@2r^&{YhR@ zw^UuX9c)b@B%u83iCNC~IC#%5yDEAF)=sG2Ixi3%m!~JwM$*P5x2h-9J*IpQSa~@J zrrr`+ovQAga*z#m7tsT{r|u?Zhxkhp{;cu*=@#(3`WZu}iQhp)>uS`C#CQB#V0r*V zTe2;aKaHbKz)(xpB<;4XJks+e6S0l-xv_|GDdg@Di2SHte&&#+NZ(2^BxzTs#s&{h zT+P^yaLR3Ngh&SYr_pGSlo1CA2wot^gmLX*Kry~2|D>4C=?)BOyuKoq!#CwNE>=xz z@B8_S`HEpn&6xHL%`uv=rD%h>RB_zhRU&TJz}mn5F1e&^ASo;(3ppRY={cnp``a?A zC0wiV5$%pZ!_*FuGrqYzT=2e770vS1j+=c~|zjkE7i4Y4E(NTKXd-je8>=6q<+#B7yc*NLp6Yi7`s>jG~xBpI-ljN3WLT@-~ z1>TEAk)dHU%i@jw-oY^D2AAb|%)}JjA7Bt{nKOF_Hp_!A9$XYm%X^ ztmK?aV&I-7@30n?X3rXfNuWHp0#VN~t=DRNoaeHi)w&{-K@k@5vgoq(MtF*-_fe2= zYChH0%?FP}6|_HapKK0kzEY{&1ar1-#X(o*HA;tY509Qp>zLBfP;v#}!^mV5J)dZ^ z>BgG%+gA^6~) zZIvs|p~pM!mkV)(Wj^@{;btztU>>X7r>wpDwmCLZ-ovAvPh4@D&-`&>!9aQ4ozB$& zp5iU5W6N}(oJL1>m258VY_?OHJtQ4roUQ9xnhBhaxRO?2T*pfCJ;?Y5nAyb%ZmWeQdtfRjFHZ{sZX3=>dcPZA7K6U&rrSMJ3 z23`Lst@rcgM;A*bOBZ7^yX5>5bBMmNiu{;nn9^8K@J#x?!{n@TH!x&BoMx1Y zpdS!C^i-FX$r+VWfUDF)D_ay~adG-ZLIz0`K#)}p3kzvR0rp=Om7M8tl78YAV0KgX{bGW4+cEG<+t|p2oXOxm#xNQfN z8f%1y6(O6G{7C}RnVfKJuiXZaj0W?HdU$68{-jOybhcswAmTI)jig>@#_t4FFbU=& z)3D3#bDeYZ26=;Z?rb?le{I}drsj^85p*AB*D=t(sbAMU^rLueRZ8e8j2qQV1~Fi> z8hYmusOb@gaqj3$`75=b|ETY1Q+Fq*KH$RLu8u@?^hVwkzBUu&NT}LcfTObO{CffG zsFXYPCekhefLbLr_#$o*i+-Y*PU)i`#x}$R}_=G*KKA8Od zg?&d1E5yBkIi!?6gDJR}d@@sZwG!db9)PIXWr=&{#YBo-o^KfC-w7L=Y$2_q5tA_s zd_)K$q}9eV8#$HB4v)xO`cRrV5M0lbBS^BQ?N_Uyj}uJ$8D))4`RzrAKn8@Bl20*K zK?_9(EL!7Tu@<%jia$Ut+x-QJbj1FEus=kWHhxabUvLKbdZYo9sf_2ZyUzTtQ`H9634fzfh{>IZs*n7#nJFjd~cRk}k{P;z%|sOnYp)rqs0 zMntK7EEh?ZW;Dj{ezME8Ko#w`;YZB7WQfu8Cl3?Ixic3l%&`v9SfHWm2pdd-N*w#6 z>pThQ1uF0rDpJ1vzbcK8Z)NAyf7p9L{2y_q0+dc+(u%0J1ZfqPj;s8HrXflA*Q%+? zSWY;#r_OEyUMB4@+!+QYb20UJ1&W~+YkpIj`Znt-)9V}-KKM^_-T2*HO#8n*e~|@< z*PKcjON29GAwVEB^Quix92bUpcgU|UHxv~9a~In6`L>OeU`GfbThFhw;fLI}TJzeF z0G!n|WK%ep~kHJws&s(en>DFZ0)ld zbX&L4=&DqT55oSDXVOUIOCNtJ?&o_+z|RdgGV~cu#bIU7P1)FXPox?Pt^Wzf#Uyju zHJ-wt;Q{pYCwybEi&h!8>!GxjB3=MYmJsd7{?h#Zb#sZQCgbR3-)Ak*c5Jng=kai# z@B_>mOjhgPQ7~?18moe?$->ieFbaQeT=5~Jd?z*=lLj*#XEpObnQ3^>$2tY5G-}a@ zEmSX?WSoC1&Qmzkw_{vO&V@N_n)R`16?m2h8z&f4!ZL=IT1Aj1)01Uq2tWZO5y$=s zaORP;**KR8NS$#Cee%5<5+F>(+o;+NQrr(r-VaWFBjbZZN76SSb_b1o zc^0aIX`Kg^LWGJ>O)L_3w-hi3`3e%|1sEYkdcfy++pC_P2+`cQV&+tAkLXej;;z$0P<*&mKBafg$S*@#Iivr!)FZxfykAAa& zl+J;luT&!5ym{m^r_*pS9j1jMnop!C&aB@CGMetbC}E6!cJ5#tE)p{Eerq_dc}p;( zrX=B=qAHr%w2o-7rgx<`E+s|9@rhVcgE~DvjDj#@ST0A8q{kD=UCuJ&zxFA}DVC+G za|Tc}KzT+i3WcdDzc_ZvU9+aGyS#D$I1Z}`a7V_(Oe4LSTyu*)ut(@ewfH*g6qn0b z5B!c7#hijdWXoSr@(n%%p}4>se!uezwv4nqN+dY#Aawu%=d-Rn+zkJ-QcHv4x~>H$ z;nl83-22HjF)2QMpNEM1ozq$th2#KRj5s^@lA)tHO0f36Asv{XHuEFwPv8h3aVTxQ z%oEW6IvV#QJ0B;vgw^Hp1Px?Mz2A(2dQ^;}4MsY<8eV>fzO;Af@2_ABvNCN&Vi@_$ zRA;E+5L+M~+U^kL3Cv6VGRI-YP4;A4S&FiV_IwHwRVdRsZgQhV)RgM4Ma^G}ULm!> z8q`CgL(VPvlGhnd4Y_Q(w#EU{=fE(mCcuyXqOz6x9k}xk63wR%n2?k=jbfx8KC{_QVW? z2ys94)HvxzFg3~`E+&TzC@%OAsX|h=**G(r1*OP#MUZ>t$ZBnnJ56m_n+*g-@o>wMN)L+r|C7%OU{k&i7w!T&(lEg>(Lm5?YI)Z zMu*56HN&c15ADmoxo6=V1AoJDxTx;8r_dWba= z34d+4zF0+J$*d`EgH=4aGD~iWMN?r-nPLgUypU3y7jqF-rKVVCMolJ?vXnQCHq3E? zygp@tR;A8@wwqP-$|X$GqUu>re>O?GO0#leqeF|PxrbFUnRX?&+9UTQ^-bmx!a%#? zHr;DWVKXE_Vk>kZU zv>7s5$dTD>2U*zg;YNegvp*xjy`Rq?-EF}S83Bmx;bgi)&qtF#*)1e44g-Oe6BOHb zLCMn`&=S1x^%&^OkftmS_H!DNy0tXtDm$oL#m`o9$?ic5tK&QaR`dqD8&VydP=hmO z4eNH1Vl)1SSv86{1;1>GZ7eRkgcGt^oM^b@+S81dqf)DFG?wjas_XRIoXwxA)TbD$ z&;YM#{~CaV6{j&!q8Q4}E87~4tjOhR`yD|jD7xz-`qG4CixswD1SJ!dNNr(YceB(S zdTBg-bN&brgS8l(!5vd%3#(D9Rs}p}8tkD#7%)3&P(x)5m)j6WJgmsD;%%#t?U^$$ zt}rR)lG=wjUkB3_m9)G?t6Pgk^z+!P)&Q}&ZX<4NL*j8pdJ{Kbnpl=Rg^*{}#rC$9 zgeHxM@YlVRDsc-hGD6kMZ~@(KO!AY7e3CkQJJ^eBC4qsB&hMFE~sc=K_u%p7dodffBw1U*#b6=_ylpuw)MUa&2g24IPnQkKD+p8Kjt| zBrA0e{WbCdZ9sUUwkn@$zfRSJdC;+_fgm}R!nrJph!|;r$;y6jNTv>VK%(mFIc71& zbYEKGXaibyqWmY@Tk{fC;#Flu0igd4Olz3+NBQp<*MZDTvWGBG8rigCLOH%o>>M6OIYwohsAYg2z8B&M~f7N=iLOPie+-I#!D&YrLJ#*|r zk`%QWr}mFM^d&^%W6EKt!Jense)RQoMqrAg_=q!e_ky9mt-vXrEWn`?scHMlBa@%fis_I33 zTO#Cq>!AB*P3)GH3GO0kE#&p6ALzGH1785t(r5xFj0@C83E@@HBtSSGZ|q#57SXzC zBcVYI{w#qZOiY|a25^Fdny!G``ENdD%DlS3Zk}KXPO%lG*^rJ-*YoTz0!5gcbUBIU zcxsp)g(jX$tR0mbI%5n51@)hFEWCS&4h~-C>z+e9XP2#9L=w6n0&{JJOi_tKFjBOmkydTxF?{=r~Z0SZ zQ!+?)lb|XW*a39dgeKjifBjqg6C6^fO>>mhlO5^a!?k@%Fm%OcR)0o}*qm6=$;a85F~$*LPd>M4+h=KK^p< zUTLr~iZCJ`#!sTSSP?A25d9$@jEe9}IiHO>I(cU!JV|?&>({{a8~_Oyc02#bw!fyZ z@HrqJOcWp<_mvL~UYdVG%AR6M@$eurF>ywq!qkU^T{D$%{9=rQK{Mr0e$Ev<4Z5_S zNnwMk`o5QFbqF(j*?kTXXP`Tk>0tE2420%Wbv=sgM}= zFD&odG<``_Nk$!;UUlNa@pUE;@K9l8cg(6Zp^76 zHSY4thE?HEz;V#!D}=e137fguh3sSu$@cn(U(I~bzJ+UcXJ=Q1O00`zY_m-#grEj4 zEGB@jzU304JM9hH$ewewKoi}a*G)7>aprL9L{@#&E63^!f5;GKKdIcz3u zIX?;8Hm+myU<%}TY{&)aehJtE{bUL5REqCLEv$}$XOuvB|LmWM={@UM30}Tc@D;(g zGwu3b=?d;_K`#|5(k3D+azz2#*`b*#(L%u7Pt3A#1qc<-_e7jCTL6jjvyRPZR?)zb zWgFrXi*Z})op{VWcX)K(M?p| z^}a9&&u8|iSNZT&G=-;Z1>0&GKleLMJk=huD4Vlz{zHe^OpLbVZE?7JHGRxRVhX@R zX#DjtFQ~S{-S678C8X4#M?IY@6Nj@YeQh)P53f_5{5@XcsQhQG$hZ}!=|IIsPG@-~ z_{~ws>hNg`<7R&15+VS9kG-XsFaWQ-qAIYaR{NtS)$_Kp8Ny;9bOV?yFjO|C|BAb1>)p63 z4?AKjs4JeWs^@~NgVY^gp5av^K1B~{YF7jfwz3uM!~O04tZ#R7eB-b!IWW%tVX4NF zZl~8XZhad1Tj?)(6C#PG6UgWf`0A^X+pq%_o&XegitvOnypX9A-jKwgoqIsk`7vDH zPz9}L=G;#3Lf5f!K3`t}l&J?TXKzH~Uzk?{5_k9H9xWw9crd@!v&1VY zsOuRn#7S^4j73)ETazCqI7bwNo$t{cZ&ry=x*Xgs76A|6USJp|n$Y_yB zDC2KGY3x!h=P8)>V7&ntYvVVK`hxw4Z_sN~Bp#BR6^2R37pGT z1Dj`(PM$x)t^Bc$%_kZgDbs?_&wIue+uUzpy}>uET;=1A)F*)A>Ata~GY4hAc!A?U z?{U63R0JMe536-g^k(*$`+N?+OJ(#XPk0Vrn^Rty$T*_`6p2GBZiWkJ{>w7+4g|H2 z4M328#NL_h?{$DR4^iA=7M|n{ahQctX<$tp*M$UZN+xz_oI{cx8*`dJ7 zuF=LPSVu%73wwaH{>HwHrblU4zy99llp3ScT+Mw7rR)7PJ^rA!wpR1f3=q)%h-?9K zK52(MxZVT~sZMJ~do{4JL-m{KI{J9x5!DKd$(}V4$Q5i);pa(WYKq|3lh&(wpC>*+ zMJlvE1NX)k5PT%eqpH=J7er0}#EOfJJqW;C+V(XcP_4kkIdOF!3{~9L+ z48Ix^+H}>9X`82&#cyS?k1$qbwT4ZbD>dvelVc$YL!v08DPS3-|GFX_@L!9d*r0D=CD`8m24nd4 zMFjft2!0|nj%z%!`PTgn`g{CLS1g*#*(w8|sFV~Bqc{^=k(H{#0Ah@*tQgwCd0N@ON!OYy9LF`#s=)zI0>F&P85;TXwk#VAWS+GnLle5w zSz<>g3hqrf#qGfiyY=*_G1~|k*h-g(AA+NbC~N@AVhf6A6qXmVY2Temx2|X$S0UFw z%*D3^qpS5e`ZtH#e-p_hv3bYtz!vUA56&MBhN4*snI=g8YNZ{TYX{~dPZ=Z_gk$3Z?0ZR{D-aliB#|SEnR`T;N3$!}02ZQ(F`K#y94FLke@r>i04JrfBacpWL!tC&p$j#%e~c zG0Oa(wM# zM(Mn!CQ&`w@usAmfZg29h)&o{r_NeX64w5N5WxG6q(-s6n3+LYQoV!fQdogT)Mf~f zrQ*(MSoLcIu2Zpl1bcHm-1-=no;nuG(Rr?&=9Dia+wfu8KmGNY@a~FBD`eM%#b5IC zn=aI`v<7i^08qgeb@EmZ1l73Fe^)VHH>vwnl#LfZYM}d!X*vZ=X-Kmm)|p~g8rR~7 zTHpjqRDXxKte4N;M7->5uZ?~X`;`Oeoq;87kGDaWGMa(5g9dgC3{EpOF1o}w3Ms0+ z270RrL{cUBU0=kwNClDNSwY!Lm!3n$dY&svjk#S0d>tPZn?&G%Bdtl_HV)BD3T&C$JTZ)yChEr+){ zP!q~(%s;6J22$ep1;aq;vT%}A@4H_e%j*18G#k|8R4HfuOLp~*H8ydsM!zd^J6-{I z0L19#cSH6Ztna?VS=NwT9B)9MqJAc(Hd_EwUk?-sA$*+!uqnSkia#g=*o}g> z+r%Me7rkks(=8I_1ku94GwiBA%18pKMzhP#Af0}Seaw|!n{!*P9TQbotzCQLm5EQN z>{zN@{lSM;n`U!Q*p-J1;p{VH`75=x^d=n#jJ1K1%%tgPj|GD0Xz zq9fV3Ma?HtM@!DivcDoBi|RXcCu&(8=pz_F%Qq#Kd@NT0|MtB&yqr?e&x3@7k^qX=q=oz=wvkChK5$_^jhq9 zhI+$s(bJ#2(25kdPfP>T<$A@3xOU9Xu;*O>W zPlGz<+y;?kBjzc;6Cx`rv_6DV)$7dgS>VSX3u8DBYT4@c~$tokVRZKT>AAJcn zM`3)eO!3jw64$ia2bI*ky%;JvZAew%gfzr@2z=cx-FW{@F2|Z2yJ)(40FvA_tyb$4 zHp-iN;@m7h0Wd7=&Re6T*H*wT&g*@8FgUyIHK5&0SUQ1)UCLemXi3}48~TLSgCCyk zrp@aYZmn?H^Jl<7jH)47mR8%{zw5cawx$r(oP>dTGqsxPPP=R8-^vbHS!I{bImH+d8&wJ9%Q;wmq?JKe27wwv&l7u{E(hv31^a>U`O|>aMzfL3gd{Uh8TtBa3!a zM{Iu}AI>-WSaizNSJ-FtewydP57^1>j^mNBnaaxoQn&p9y9&-_w4i7^xOT?7NKl?lKxm79T1T;#zGve! z^z&y}PFN96@n!`suxGzHHb%{=V`PLBTAb6YsDu-M5z|b*X1U-HtKvIeCp^%4PTA_v zr^@B{_qoGaW6!xov5Prol9ez6kdqH&(Vd~>o$?gruojX(F}osv#OuA9XCm{BA{HQ6 z7I#HXLktMs2!{a#?(wMAlBNdNxg}5ft0q4}Erg)PFo+~m7-_8kEk4%&n`n!qprR3_ zRKcyO67pN^HTAedB<#V{RM6J$?2A+0nwfZkx z)#H~>#TqYNMDy~b^!AI9>aavY_!YH!u%px+~ zAR_r);-C5#UfvaZNPmjHSuC39+iWbb>#uq)ntooMYNm#v%L5gx`qHNM^>O%V(&=$_ z)SkW9)C`tI#lQ5oYR4|5rnABn0GHiGa>kIEA)V)lr~lGU5$|u7S!kwV34&t z#Znst?`+H+{F>XL5Ihe`v2bcY2LZjt7?Bt^Q*1(5Xcp&jtGCX0X8@7GN*e>1pKz{? zTsY$-TL0JWaic5zP>F zBpD0yg8$LFD8iM^) zk-SPvJ|)^m$UbXDe<1>130Xcxq=9HeXVixa5li>o3bOiCmS8->t{1==s+|s)1#Fxf z`>r33c=P^?sE%sIN{nLrVKP2=8#A#L4aVF0&5hX+277!PfIi#w^-B=A(-v7xyZMmjc^*yX$#oLqK zZ9ANck>T6&l`fxVTgmj2FMyTGi}%N@9p_{)5@W~|eKY+}O(1Eb@~8MeO%U*3OJV&~O!Y|BfsbcWre3Qam04<^Ox8b7rmU*W?BC?5tQ&Maqv&(zE=o#*zFyM3A~aLQx(BIxtIGzX$s zVzx&kS;C&nIUnJf=0g?za@(IQ$b3sWi-$AZ35<7zDuzQDl|s$cdI)pS9|?_@L&YG= zTz1|NMy|(^-ZMSEMkmyA*Ec=8U#qiWonuyZ>vO5Uib@8!;^$YYmuBR+aS?1{mN|pv zw-8JT%`sus&h{q!ics^;33&wOgzyRooPenPBHseN0(uMGO0M=K4B# zfGQ7bWrup@w+0D8zuXDVG3`|9WQUIU2=lfs0}uW&$pO=+x%3;BTP?egh9}g!y|nxQ zF7c19A0dClYKuSr+0{^h;p=f9Z}r~jC}s(xg1yzB|3z2;`K_IX0kqq}KEYNiMmwrL zR11gCd%Misw-RpfU}^|g2}g%6#Etdt0G?#sN0(*BU)z~$KoK{Kq`9iHM72 zx#?+K`4Y8`;N;NJ+f!qAkK#UXrFMqzBWj;wJTv=9yxWXYj<=2W?S}YbPJurHi zQ($FF9S}jGm#Ch5G_{9=G&4K1rES6e)EtmgOi_(}8r`}~fLVtU&2@>eeNlYH>3oCK z-!_xrX%uzAB(J7fGqJ$WVfFlaX$_^-S(u6ywL|Ek8l5*sT z8D9aA(LyK~&|Ms@$?%C~OSUB8zJuyoz!y2nEHMk4VjBmJdxc06{ee>417r_Zx8M_f zQv&2&0cujOd<5@MSTY9gXQR_E^F$=~C=15`95Ht{YHmdLk$@3n#NUOMK$};s*lX~Z zj-hg?05PqDKaXM*=@C*FUgq$9FSP4gH_)(EMoJ6Vkgs{7exk&Q6_1EM;VrM=HLvKN zx7hNZad6+T$rH*0HD{xnW|(A;fL<{)@*L+A~DI2+a&j9;VV7>2~< zOwYgnm%NW?RDa+8Z;c&Dn}UQ!4V=-1_4~gI?EYyNM=CB-ToUF;W;(fN7&0R;6*M#$ zvq5<4o!#$u zL;H83)18fEmc^I%kG9Y0u2a8LzSGT&l-IvE1-?m<>GyN@RiOc=MG0pwK%(g}7UrlR z%-M&;96}o7L1r8apQ&v zS?_M`X_R4kkwW!jor7h&G=I3cyLo=WiDB0_Gi1V3Z<9=>`A-w>Q89bJ>Y)nS-T|=~ z@1h8-J2K?H;h0g6ESyOVVEyg9o<40j9gBKQkt9MJkx!1&%PpEAT{s(tVflR)k?!o2 z0mU~aI_52$;dv3)8$;S9zy4g!NYM&dv+h1r*xa)+IiI?ql;2upk;*aEok5LD%PUqS zz8;1l^|}F5xF(Ao%CIC$YgCZ|0wJ6yU9ZfstHAOwKs1ms4V(xMc;b-etG-ivj|D2A zWYxMR_SLI#Y)|w~S9~nxto669sc=HX zbX$_ZzOwkuE=C*zP%=)t7J$QsNW$t3`nShXVT*uu$f8k+iyTDp@_c=Lp{vaFBc^0&k4p3rk*Y7Zi_uzwrjSgca zMtjp&+ZrhxKyKW{K)&dq@Gfe!?G-`-PBLfo;s&_z5DRcM(+!N~fXTq|3O~PQbs=qA-pTg2l^u+d z%ds=eY1sNyehE&1F?Kp*1nt?h_p`OIU`aFI@{{AP0W(he39BQ}N&Fxr(_Nn9C@|Fv zF2CjVJpZj*KW06pkPfYefvVkXhPmEzhB0ZpvW78P+6b`(DXmx4XD$i@yG6uVoa7U_hH3k2Py`({xw)s6nAe(f(@W-J| zz@YAV6gVhtFUM>qy-n`}{EY%a%Z!g{Uc4KbHQ4Cysq(A?;rg&6Xew@Z;N+ZaVY|*= zY%CB8ewT@Az-G0c2It&IF33z$Exgk%iGnm9(StB(7KF?4q@06F#2&%w!1|s-vJ<$R z#XzNy)JYP=0BaD~u#sigQN$gNdTInmz#5sK4BSByfA_#G&)Zj<2A?Bk3$T_QnC;|2 z<0|qNBOdcGWX_efUbjcIbf9DLA2^E&r#fq>Gu)@g=vUoWqV-D~(xUfMfaCeY?ig%5 zNlo{2#2{?+Ykm2};*J1&Ep^Bz&WB;0YXN=I6)&JUITYUOUDcL5p;6b?izK++B7%r5 z9mr&h^fGbKR>>e`KebYXfs9w~PV?6xQw%lJOA*R&83!gvx2_G^Zzl1NjQ*&uWXlIJ zA5d%t%)`R6RVN`l7|hlJO0zti;vgD9yyKBh-oiXL(LgU}D{!LToK9roJSM_z=}gA@ zV0mkG5=+m9kztd>9U`MRFOYqw_R@@-88|~TY&n;wx0Y%6<;}H~Vhw9l)<<3|O$g znOS~HbBeb++hP5w^R9fzH*%%;O@OyRJ2HQ!`5r6TvCxLMt;lTth4BYout)}a_|rR1 zP|nlJjcdDbp~VeGki#sSoP(U~1 zzvfGSEi^1h$ayZla(pu`eFFiu-MqSdt8cz0qRmg++c}@ChaW9!{X)T1I}H&3h$C+b&J+B z&WGhay#y)vpbmts^9+1um2a^f=rUg9gc(vaIvdu9{ z=g~Ari+YZ*_9#%du+x0Tj|uG&ivk6<0W0(z->5&_@J!xrKJh+-N7(ay9KI1^9DKq1 z-`Q>5RXJWR>^gJg=ceSH1FhP&;-(b&yx3;%21tElpT5B-^B5lRW1stx=Lw@yl4K-H zH_&#(_w~Tx6OXfPTcCLo9$$?1c^Nx?=R`f{P#LiJu7|AN{H=1s9vgkea6`f*yNy6m zELFO8tlEHRx_O|Rftnf+yTTazHib2IaSS}hRg2p_EFj}MmiDQ$RqH#OP&*!>JX=+E zhHHTXEmdmJGX}fFret#wSWMoxwfs%78tQ;lJ+%#EPSxrJ1@y5{w3>3s`&VRTmheQ7 zm(`N@=UL#bJ3J63M84cI!+dq8*0Pa~cm)*vOH>96OZZ8rI+@#sxvX%J;j#2UyoI-P zoHw?w+>h2y0-i8E=E{R&#ky4YXy`dpzp?LN@i=(bZ>Ps)txu1NjX9j_ZqK;J7FkwVRy|k|*99~?Y z`*dy80oA`CJ_$tFQGtxLJfj|?%k{~!rK(wP%(jJ&e^AP#2mSmhEOc8GXcC^~u~)IG z&bB&9qn$v@0V@7Z+WqyCihnp!(NDz!v+(tZ6+efxni(EuvIZgq!%Q;IG-q zqF8&i9!)wS_%M!tY{yK|t}-+MVeB2X)^xwo4U+^n6ZT(3n^9s0^N~ZpVA-p-|=@^inh<~GA#G0Fb6cqg`G}K)*o{T5?_kIK6JI}m$v_ol&8oO4P_zX{TbEI^ zP4gy_X(a!@XOe=(Mp}U0!7ra+gbWnl2qGN(SI*+{5}&-NnMCpgbIjJJMM#>k=g30^ zDbJL&s-oi`3YUeZ9y-BZu65hbFPz;5@(6>;XEhacr$vW+pjdI#rGBriL|0cF)|$5S?ZhrZRY7Vy{kdqRI7&X0dtGtm6}Z)oRm-4;l8Ds`lB z1{;=7P~qZ2_n6wIDqX_QLr64UbcGnv7W5MkBQOQpPgUnUuZmy*Y1;{C(bD+H71WwI zFxkY4N6=#*ys|B0K*aJKZ-tf_Feu|x0wGE^{ za6HB=IjXDV7hj^UMqY@8D*!&A%+%g?A)#u;s#rUkuh7i!inq{PbR#Dr|8ZT+Wh(ZI z1r+upwLB#jrdiBGjm$~v%G;|eT(?4SqN&z(RF;+MW+&TN%T|}sR;8Dh>e|RrS`1xo z;obvgl5Z|wz0;94M2z-Y2WT6-(${?#QL}TPndp;hQjRZh6!1&D`+%7IvJc29LIBMq zvwi(+IZ(P1qKSTq#x08<=kru=S9oc!%gVY%A{T9{D%p8jSYCIzFy$TV^U4-RLFD+w zn77r`QwzNhX2Pbr7lOF`qlaW1HJk_R3Xg`iqZN?BZle86?}o%OyRW zEc|gt<9{tSk0Td&`c-N?)$%jzYaJhoOAjaF;6Z6r1}Rm!15{WMTw!4o5~)Fo-HoU_ z-&ujRx$TNix^SgDySgxKt>YCrB`EyID}h2#B6*Zab@La310Ghd_ma8AO#8-ulwSnj zZ<5BIUzZE;5*FP#&vkvaG!H~2tU$Jkd%gFw`T!S{2mp9?Vh1R?kv;~X`YAwb63>)? znkAD~i^l250{N2CJV<@SZeNTq!pqthV6F>e_QO<+Mykoxd5^JzHJaZeQZ zhJkUxQe7WRdWlz!MRJxF0W`KL@`p~)x5J(z5M;XocV_|rgnnd1%sW+|yq!Q`G&7GP zY07mPEwX@!LGr!_kNsDN#hMPL7#l zlc=pE5aWH28%^Dr5#obbnK@SMPeMr&YC`p^e?y)lV?@3LQVmf_yWw)b$Jl&Of#Rp# z&|KH+IbPYoU^~mj`IAFEK^Z{Gyzpb8*3I%bzXzl%M=>mC%Q2%)jr6JJ(KPB8q85*d zB`H_bk5V~4&VPE&gUAO>5~Zr82#kI9vNGHonE(8&8C(Hj-eU@GWQ@M~+4I^wF?8-BT6Km@x@%lir9`u3T}u<#oKmr!E| z2--yCX0m;Giv$T$>#E8290L1S=M=3CD`(J9s?1X>SX6lZ4GocaWFnHAC)t1T^hkf* zUD3KeM&diP@80N9p%T&fLe$oqvOhhZt`JxBO+^LSf?Q@z_`9Vr$Q6~<0L2-m>O(g4 zOan%-sNta~Xk*}&{@r#)usawmHs1u<1GjQ|b56{BDO&snX)z?_ zAankXRi*W~FHQC%{R2T17EVv=NN_~B7>6qS8-oRfDB^`%jRb@OLn=Vxce}tFY;7n@ zj#*voq%N#N>y$Y|*HtC2U!S=)^IxgQ0-7$v2yiqNXRM zwteC_-%jMY93pATf5JRZt)5Ay&cMar+UEM%P_tH6YH%!8xM83G_bjXj(q~&xt5EB% z3%t+9ys%^4AWWnRiJ*K6xjY*LNS|#O;pS)*K=AB^uJVW_JHF`#iYDK!(>=WUhh6%c zX>sTwaqCCJrW6nIY`0WWbIIb}bAzF+1oH!VTEEkh=Zo6npGn$x%=adz9iX3#tW4ZG zd<(6Uxn#z9!I5&G|DBlUn~4sC6q09u=rux4?hdLGj!_7Cw~W?;w)!zdM>lGL9?iJ}t$XPovsz-)cS-!LHv0ZC zb4AsYLrHn^FyZ^K^RfN==H_K5|Kmms8C*LII4c6rK%~mwn+cs0!Hx`!kJU7zAV@+T zY78x5H8b;aj{WU`xKGLdJJr*0Ydv@5KHQ6gH)}c2!V)JwlsWfdsGezcK zvNM+<{?KLS;}dCbka?fVSkA4*j<+1;zd^mMTl-!=UrG}%Dar#cYGiWKt*OnI2`}s& zKuJNJ^nn0>uh!6qs230jLkzPYLh2_ii7q$|O>AsUP2s0Lrn|+I5<#4D>kLax=_gwF z9%;kCQJZOVwWh{(5l+S2;i@c9Ea^@^d5H*?CXc?hq}byCKRwrA*C%v%mfkhaNtGo( z6ZP->A4&OCCWA#*#FO}#W|pFnPK7yjF|1x3zOLK4rW)-`{Id_xRgaYRE<$eQ5uvhX zwf1^~0@8-xJluw=SU}u}Dw6aJ;q1JO9ug~KY0 zc4j+Rx)`6g89&yl&N%L(+7`jSN#4N90mygg2v-%B)UllG#o_hk%4qb{}DFugg+wjSK#BF}Y6uqK(T} z?kzHTS{^k4!@fD4XcX#W(^8wah zxhMD99Ne&1gVtZZcgbC`hyPk0Duv+(pFsD@Nk!o&HRyRK5G1T7+eQevJC6LPk{?9c zQ-J=nD3qA?mBsZ7LMZK)4N_>F2_tu$3G)*!f%X;15m2(%QTyX5jbibaL(DZZ?^X)6 z6IQe1C)xidS(*m&S%Nxg6*Wvr#c_5a;M1(O#!UP zK|w*!f?nnepYPN2Q*1CL6QwdI+R$^%?Xi@THq}&u@#=_#DZffv#+TLtqCOXu9c<0O zBsjTGdF-y+Z@mK*MKeXymw+sY=m5iC_W;0f&xoJ>Z_(Nj$u*A&fs%=i& zXib;4XQuQ`Jk*=)+;=g|>19uWnY|Fm@!=U93(mB|GesI4Wr=-T+cXbcT)0}e zk9@N7!pP7X;)b3=9w&;zB8_zwDYIgysR+6MlJV2JZgTIABOgT$H7|24>D8+#;3xzh zyKY%iqA_a64CM6~S%7)I77x*&ho@z-+9T$)J3p7ZAAvXTlleQ)85O-Aovu)#(nBFp zlZv+~J@s!EXPC?AV2Qe2x8xWM@qgW+EK=kDvM;^m-$jX%#8X}}_^WbZAFz~n4^?Xl zj%R5)@O^*Xqwo3nF0=1jxhKO#Xm|5ZH%Ot*~o~Quw z_cI`0zS0)qV;eDMqE&yp@f(f!aI}g#JA3@l8p?CR&@Kv6EZIB?Qasr@Gt@Z{w77Nv z-U{;yNYdDIL049ee>V>Tr3Z~994}6y+LfVe( zL~*qRBcjeUeu*d3^?P%t9mHjZr3zcH#b1=(bHZuj@nb&CSkplmQTCO5-ncOKUr7>~ zXO}(#MI0}p_XUBw9Z{>_&I}hoUH;%ATm@}@Ytb5^tGOt&!%kKyT~|z0b_-_?RCARZ zLcxg9h%d{=k%-3K6b}W*odahEdv~P*`guGU=-EBpAXK}9hD!(mCb7CfG)h!eG^FI5 zd=4Io{XOpVr+hC9GHRYg2{EiG9pbO0{pc-`u!{CO2&6VBS#c?uQcF@Ge1pz8z`x7f zHE9T}UBeEQwl^S|gy7HSeu)=DMQEd|gKT=|>Z0d0x2Brl>e0Q*+NDE2Z%mv2r~4?* zs)BH22pO&FW692q$)y8BkuyA5=q{G1BlUhq1an)0@}`oN?EEaV#~%0orHAOc%vR{q z*;tAA6OP9cdMCD$ae+24Qm~2WV^os>Wz#8!J5r1cHjce&Nb+|lF^e;j^Bs&p-JGc~ zKav4|l*k}_e7EyWNLxyMK5|AW7)i^q2!*m2O?(+3 zqby+A^sT-jtH~dn3!P$OMc{Pqj?n#pg7Crsn{p4bJZ}i!``h8~b}(@ZpyEJ+ZW^DyE{7Z#gl4O)5m zjbk$DMFbl+chBv*PFd^V$J6J}hZ+3qBvi5k!tI_S>L$TzcJ^*G+St!ob6TYl)tfN? z;`rk9+C7v-`K&b^3?Dx02XH;WA*noz_@;rr@7b?!{e&;*zzHX(n!PtW~ul z&|=dUNrRvwc>mRXpQk5&-8k|D{su?2jk5!p^G#(vbx?!4tIQ>Il)tb9 znC3VL0&yIpl}_;L7*w91$b^Glb%SBKJYJjTcuN?=rjSt#n#loPeNN^GB|4QV6#|9A z))*lnJ%TH?o7n-B!{luw>GsRBh3~I*pndrHkLfbiN>UjYod}a51nzmD1+I0(7{u`r zlA9>4UXUc)z-!bi7JWd-w@wwKTI>{`9hR1r15}NZ1`EQ*5she490`UZDi{~)hLQAo zF@x+OMp^;QY=JO+x+2Qg;;>mIgf=Xmo^UY0Bv}V83(+id3?Mv1kz18z$0;fV^tm_A z!e*cJtvb-M`dwsOP$-dbF6uU5Yd&C02k~DDA0g?;H9dbopc?PCHW8bAv+1xXzXd!O z=bs!>6tU4sZ00nAP~*Y@frV6L2{yXW)wS2JPr{^!5n9UpOZ(@-%sgtOXPyQVQ0umj z#|bhR`~OAdK?1RqGv8gu00994KtM=RP(+H`^)6R6>^1s-x*RQ7 zWr)DO1*QM_-!NK!6}Zmzcz=fY-cT3weAX9u+-qCImEls)cv({&mB31~sTfkfRfSU9 z@{dXYKVzUjk4~#tJ(Jl*gbJoBq+P2EDx8xF>QB!Xr{_D@l}x+DS2Jw%PYzv#wr4Q$ z<{p>C>mQc{_~j%mrj`i2vup17g&@6~3r-)vgjQ}vy$vX4OsqwR&q%c1yrRY`CLUFV z{F5^#_Qw760bedcYqxO3Ym?KmN#AZdos&wy!>-x!nld4=Lmwf)5eFXEt2N8Iu~QxU zWhsx^S#3sLoZt=#IX=fu>74~JaBEzFwQ*Ew%DaZW;C2b#FMZ6?)-Rqv|FVK@{dUR5 zVYPEq$u{iW#^I@nmdSoGl-=QFN%G%3_toixR}MR>kbQbmWkLJB8S!{&f*kt2D|G?z z<}kD%#qQWOx+6xG&u@#;zXQfCXpHY`nN;(7PYJ1{<4tW*zw)l)3*&h1^^I(YQps}i zB8H=1{BZ7_mKGn)uj;B>p1prd=_Znix70hLVg6M%uEAvS(nMw|Qrw1jI^F()!-C3& zOp?`_DhrI>MoZJNcGqb(x_b=q@-iLhxTW0DzMt#9g0IPfxm;jr$3;gjS=-mVARB6W ztsy^bdmzeWVb4lNyELxF=1qS0?7=q3UL}}s)nKQDQ-|8(A~ke&#g3l#WP`@%Uw22? zB)w&2o_*2U=pf-^*y)C+Da9ck%PAFlPpgQ(dR#wP9%Z2=N0El$$fXrdZs87;i^-C& zXE6y+u3L-}y;k80%=MJv#%fPz%`^BU_3`hd8prA}Lr>|U+Oc7ct3@844p(p8khf!I zrX`B(z)4b&BxATa7wK3*4L_ygb7}WSJpTf~E;UYL?w5|XuB(L1cpyi#hi$6C4#SO` zYEZT>4d2N&MRgWadgfOhb;v4S%whUtMwPiTS75Z!$IWInA)SZHK%ixRWree_0x^?4tck^;}2eX5ll} zQ$3s;24vdFNEq!91S!!HNtcb#`rsV65H_yl+SsCNpV%AB9$hf^FcSg89XBzCduf8r zq7_K2+e^`mYkFJ|=V7htVLEbT;9K?W!9s=@*1EMVC&8$fB4t}SJcmER&6$rwdI6wI zp`@w+t>nlOd_al$CSHl!zWkvr`**OUFZ(yyQs=b=+16^F?cmcLccS|kNnHfpbz}y+ zV#VD(^0}rdw)0xQx65Nxyo*)MydMApuvD4itFO5-(yK$pMmDYQ5qC z>YI+^l$RA5o+1+kGO}l6qs*?<$W6-U5He|J;D}e}!K$EJcbA$rT4U13njeXmUWV04 zE*(&~v=J+wZ#wNB)meIcT;()U9*UkehG0O#b`t2MofG%By7p%!z8goIN;Qw!=U?(Z zXQIu)LM5u$=Q&UtL#ebx@zBKd?u#VPLds9n#p!FWEHr*k{0WtXAA}6?Sr9T{ntB zlb-DYLh__hEgQ+wY$KAZh& zt&aS4yp;Kg{@0JZhqpmXX%=86H-Ppe3S$=9LlRDkaf6p$%&H$n*X1D8<+2f>4syKQ zecCRqs12xWrI8C$2l&dto;YDkFnx%!xah6#`qIaO&!|S16m{T6l1s@JxC~txbpV#| zk}fu78*-_opFd&<)Ghrw*T^F(gm!-i?<-v*^%1X_TP))>kk2?ud zS>ABr25C^WWbW2A_G`(T>sQ0W+8b1yW9omVy?$VpN{_*i_DXgI#L9*`=02#eRg;M=HgS}J9^gh_9dw?cM2yCSonba zrkM9~Z@{}d^CI1%bV}4Oa%$+4biTEe);qYRO3qzE!$ZD~$CWauy#-f%&=%{&U^UX+ z!~hIB60(p$6*T*D_k~Bi{0173X#Ld0fwhJUOPakRaMlQ)3YkVBx# zg5knbl=(sY@Tiu8tx-ohlpN;g$h{F79#p!7C8)Le%inWP^DOB~p4DHV-J z%iRm{p|f<1+6U9e;@N};bY3A^C8fb2H*J%lU4r)6`S8^JoA7txgYiV(VZ=#hE3B;TL6vk(G(qY_W z!POO0YKZ-vI1SC)sYD#G;emLBMVFt4Ej(J~FvIPe{CDkLfm=Y>Pwm66S71Ztj`3Os z@9#@NqkqMB9WAzSs(>z(#CrZ*|UuT27M@1;t zZUYh8EeBojHewBZ)>j|%p+X5BY%J3l!Ume)@n*gy9%`4o$E1H2a8OZo{WZ-OPrsI5 zn;3l+TqmR$*P(Q;JJVe2Df%Se2%sR- zpqj9(xHtFlijQ#C#2pH2HE!G7y`#4H%Xsw=0o=d(?;->v=_AAEo%HI?v2MZNOLFm)M@RZds19xmfL+ z*|#nYtu=Hgcjw7Gy&}%1%S2>>v$8wAJ2R~+M-kNn21-)ocgfmrC-ArQ-Xh%l!S}+Nf=QLbte! zep3kGSahTxx~WCY-IbL{MyGt_qY%(_XX3GeEA)%;x8`3hU0@05AgN7g3Oy?a+V;Hg`*-ss>O+;-AIeMN=up-v9_UVbSd##|#j*F#DP!Td`gd@>xDb?WLvhVQ0Fq+?C?warby;8PufI~? z<-x`!=fDNS#g~QK#b*D~wDcQtN9$2Rye2K@SN^|IM-qJaeDu}~GeHQh)^sx^YSw}V zA^$P=sr-ZbrAzb0sWg?yH1d7Wy7Y0r&gI)2GCJvUs`81g$EIuze3XV*Y#w3&Y`S0VSRR_xr|q6*|QwRQZgI{ z9k@Jpq6J>dJD&D?SWbqg-67GR)r=H~73}CP%VZGiA^$CuoJsX3R?O#lvMJQVc==e} zg8@B@KFY}*)1dk5MQM1<=aMq$eXK5s7R3y`VZ4yjU*=^)`#4Wc#G3axQ-1-lGwk7V)I^lqBYBxsT0Kx2?zkRV8*_ar!tkJt z=|F*IsI*-eOxopCqFj4awt>@kgXY2S9RTy((EO7v<|`_58AtjJm`_I6+hS}M8iGyn z_x{c}*|HIA!gjiYJ7I&`Xc=AMJrz_UQUMCj9}(ZFV$nfn92bZ(o6+ZX!;3inf}!|B zw;Xg|HrIE>_rr^k*9sr|x^slE$-fv|GTpFfHzJBNIzcBecC?-;DJCA5;0Tmo0D zDkKj%y8mPQYnS+kI@VXwb6ni{3zyv0t0eB0oa3$Z$_+zzHe)BYf*-?J`G|k3dd)8> zI|o`Y-!iusuKN?Gv3E`4zo?xD(Dk6R9skkdGOaebO}zw}nI;!jpYJW8BOWZ)3Bj5e zx#CMhIEXnU~ZtFn%w%zMBj{~So6hLKHD34vBImBB6|rr=k_Ov9TDKb zjHv8x?aep|-NHo6bZw~E7&z;lfqdX7)6_9d!3T%O%i+h2Qy8eO#Jzu97y_0DR%Boi zZskbi)tz4_p5?G3RN}xVz)_VC7q~7k757;4Jkcm*1b>l{oR8B5A(n(aqU2MYFPpVB z6h&y5q*B8!@;^PIV@`WkEl>P_59)go7fUVT5s5G*^>im-k*|s-$5wkRp}EQ76+Ugj zIq!eLU!gEOZb?$hz0Nd=-2hv+OEaKb!CToAt`hn51=q`0DETbq)jvAF-4q1sk#2!_$hgUltLx=?;T2fk9Gvi^`h@3j zR&uPc^HEtoq0tCt$W$3NxBs3N*XP!q*QZ75Oa8EYU7qIO+Fg|}YnA-+Zm7E?he&Gn z(AN0GyFR}uX2}`m7h&ZmOt0-I_21pyb+NddB+Stfe7xs*vz#j`{sX^tCE}YRD%^E4 zBDjOl`FAUNnt63d#O!&I>x*cPXld<~b;(78#6_cVXV_SgKgMbR!m}^f z>2Zqo9XrXZ8r%X~!OMUxcEMkb4&r zAnz}M7jly&d4ZP}*|0Wqm5KCVeU^iDA?5RPpo+xYb z6%IN{rz>_6!{12CoCs)<+eX?XBJ8i zR`WZ_Fx(qnx%dyy(NMo?28O; z-Z+y)dMKc{Y(WBe0QS2<<+6vl>x$12LGh3Av;PrYZn-p;M6MM4hQ!pmLfci5##IU6 zs)BR1Xu&DENU7-N0JSwmYN5iL{aO^r^Ip>_oaH0nWGEizG-=y7Cz?v!P{V5jfANQF z4-avR%xP{HbGBg?@5|<0>Rq}g`@701KjGl;*CWuelQ!k)D(`1d(OH4R8inw#Y+>_e zi7c*o;0cv^4iPe|)so#OLYe%rSM2Slj9-JoEFm(^=!Nl%%U^sek|oG`!HP?^E1Y%R z!(|EVWzAaLJB)6RaozREJGc*39Tlm~n943AQZ} zxZ&%U!!a$wR#p0hG)dkF;NeG9AwCww8KmbS#%b09Y%L|}A!8ti-} zaK3ggH3Jg7HK+O&nyt|aYOmF+`N0s&Y~xbzzzLFjnPtxjQ=jm(yg5^D=vb+kTl=j>XHlhNK5n z2XGxTQ^(Nk(5Yn1$99jxX4jp^;DLcclXrG#h1(96y*!pJr@c3V8%vLKyT5*e8bLmb zqJ&d}@gokjki-s!gXDm&7f+qCn^~`8?Lp4)v0p7FqLVNQ2L);`F>Edas{wj!ZeS&4 zuE#B8m(>8`w3r+Svb-mQQB~NHt^DxfwPU!|N8ZgB#iltJ3ce0H%gM>VK4mKuBz_Bw z`qbSnzEXE1a>Ji)l^hx+=IA66VBY|RwJV08LAR64Kqkv&Wei5^?(SV1O^pZTDoz5D zLv?Ec`f|yFK7|7RavcaDE9G$Ql)G9Lhx*&1IwPaHTENXoZV_<#0-#nD_=>dOZFAaF zPo6y6h>h01UT)Rh6VW_|OaJ1JuH~`qiQVBfGvVgQH21epcy)N2(9(ymoY~oca|Kpis{4TTYxkX}3){rPMoy_j)Au0Fk}LiD`tK{%8G41l z!}o9ErvR}jd*hiP#QCVAKQO!%PM&!FmW^cH`A+y2Ea;{A53?yOOMep|!ABg|!UHT_ z%fq>&Z6dvcusl7km06wysty^a|6TcdtUeojF$w}dFcrb-B#B8p z33}B=f#s0%7e1>!8^mRd90+D`6`>IP@2@SiXhW7B0@pbRj%_5l)KC2IOGL#o1Lw%` z7fvSn1I{QN2sz;*lKw^lie-k)(IrSii!6Q;455=K!1zZ@P&yIPJ1(2cUwDi^QHp!O zFmb;D;SZM}wizbTOQ5{F{|KWrE=QUm$s=+IQSXV>>i?`G5s(h;T<=X-5Rh6-5D=RG zUq8?(3Jxg$aaA#nF@F@Ab2boCj5sM!V7g6G%{@t@RZvilVaz$ST433YauhjJ%*P9tfk zK~UTVHD+vRo2UoD@7{c&h}XTZPj7IwU7VpDFF&@M-Y`o?#C>~y!GVH~h+8D0-H9V; zZx8NJ&%0L?;11!CuNVLSY3t16q3RkqJ|?nOV;e?SmN7JzELqA{$U2m*tn(=QzLYGX zX+(N5QC-=xuaPZ-NGODalET;-G+EL-l~Ufk*F0@{-}Cv*=PdVowtLV0W9~io_iN3L z(+iVNTydGm*NiyQ@m23L>`pLAEm6ic7JK4cx`$NQ>LbJ+w~GY#)M-7XJ=CB}PgvbF zD^Bh>sGV?l%+8YiP)aY%Qupb+t9QNieMc<@i@oj9wD<2>^#MyorDx1al}A;YbeWKy5iM_g|DkJ`>%5{()W ztgM<67>~4rMx0%{Y9QGQh0$;`K*ejnhC2xoxOTIr zE>n|L)B8t1+1e-c)dqxim_-+#^r}1M{>Ge|>UBNi*2kJA0;P)PWB*km_{h^o**ou^ zsm$8btMa+AGb)RuvQw2QRW-Ue!jRmkq)wiTSytqmv0H;@Dp=vGF**qW8i#mqK`+t< zWTVK}i!*j(6$o89ZbtQ@_j|any;@#<^i6_QA^=$yjJ3vGv9uPIr&_t@75e1EUjQ{q z!J;nS`B7OlY$&_#Ap9-a5gh|5azpg8Z{^q*B{tYRd zD?aRkDFrotu<`BswHuCcX(V~Se6Nv$?BvD4;eEZ;&?}C1Y>pk()h|Dh%d$046jP&} zd6@mZLFBt<7RcsO^9w*-`Md;0Gj8nl_KV)sYMSp{^4gm__xT$u4PBC6X}|6h@Uj*e z;7B8zl~Y);4YI~wM_YXQa6LPn4vOJg3J>E?Cgp?}vAuNWhjkA^E}B6^A@yk{->SjMlvizuS|jYZcY{TyXS6c6|_`N|D0iu4K=6SU=P*Pu6_!MAp?HR-mCpfA#Z$F(s+k zHk&Fb0-?e=BZ|(6T*s}OJgy91-Ayu2*)6yD5QQY%y3!alN^w0sDmUIeG4_wL8Itb6 z-_o{ne4V%-6VHtzSktA}?K+&S*ZB!nbZE~}$D!lvoE{RsG(~itw0Hzpgm^V>@^yis zc5(4lMLm(Lf_6@geUdzGed3iNB~f+`ql-ZV%lu=Z@@HrdW8B^b`M2@}RI*M-cXuZT z{=H&mHyC>R>j}d(2egu=eDX_XZ<=$~OW%!-ndO0_{GZjTBwHZ6t@(MG%F;`oYxpOQ zSNR2mim^8%U)or^Oe8k&MDw0gtt2<*MBlSLaHKmMEO=fbY|zJDJln(>H*=wp&!hiv z5+SSFgy*l~B)_g_Ma+4|s|HJNc1J2|#VmRo>q=|ozGt!S9D;n`tLp|_;^mWH@K%>} zWu4|xH)Ayley*yIQL%33T+mmE40HHqorHuW$KX>UCLS@#B=-!bIe*OiO^)b>u;A5FUzxo?HC!@vPnv0m4=6-T>(jY$TEZ?c- zaL+ySPYp@I!u__#2rHI?qJ28{e!4q)FC?Rk^!DEtx)OV*m^)P`&{Ifd;94R_z2Aqk z1i=(%ji}?V5m}fVA4O|sAWqiv?_oaOPcDzRyyIF;rWAWnr3r;c4`&*TL*E6-q*%zg zz8qj{XGarHl)dXRsdryOJg}765&TI*w-69!d)`+vth~S;wvWjv5ZH0IJt)S7PW2># zs&Vg5Y6ijIJ9l1Ix>|%)j`s@F-eqO0K)9NWl?`4+9*ih=4!BDW%_WC&hwoL2jnC}G z^vz?U@Ags}Us4)Pm*mc_=JicfdtLLGiMv~6Snu9IO+V1+zNUO4BQnPK%9I!&1_~GZ z>THXu6y+SH?fPia({^+A%g&km=`+n7DK08=gDQL^mDG0orA~FAy*4IDE4Qq(jZmNP z?P365ABnrW&9j3{2c{RS1Ut?!DY~%YoIBF2FplG-(qguP^l0gPlcJVYWl7Hz5v31v z*BoN(^j&rztZjV1__D*^b_Z;J076Jr z!?xlt9mg1D17rC?N#-|P$z87Gql7!K9J6xnI_-s?*3yZB_q* zj}SE3mH1TO+{gHYmBriGr0N_yx!Ce7*BET(El)=y7a1aX4|ndUv)cRc4kF=HLAXL7 zS?!1!AfAv&!UK7xW)|bdU;3$?<WNZas@@+6uTG=e2qc>=e`PYj*jdmEs9{p4>F}mh@nn}D?EB(S+oig zq?=b0d#zNsAV%bc|1pFIn!dEAe1|7Bv_4ghNA3O4FAZwAx1JBPzyi zjK2(1(HMVfA^*#iRe2uHpW{CM^xlVNb4yy5(Jxju3WFBTTWryoaeWNpB~+zEhe zI*4KdF42ZUr8r=)zXV_~X-ItRM<^f)Gl4;}yTPduF<`V~UywX>WIyyn{~(~afJov5 zBPWi**Ezx7iQ{m6E>L1p10Ku;o|?qNH+Di13ZzUPg;(){xg`MjfFJ-mPD#TJ_!(Ir z8aKExxf8q`jo|vxY5}nb$vF6RN)^5YKuI*XahVmwPa~LVpS@bZplKw0NSIMxHZ2Wo zy0qs(ZUT~!P|D`;euM&Igct)#xXJ^@jUj+7_SiotC@vuSOEAEY85w|KjSIE50;xF} zY=Iu{Wk6FiDgeXabW^L18wS(b0tL%}iqvDk7Mr*&K%Nq#l@_WD^QQe4_?C)<=cqts zSjc-z68O{X=ttcGV&MTWXx8{&lcVNYB)nFGQE6jV3}DzCL1V6C`ST1^YeA3-WA?xN zWd0m;*o}mX7qQS~aZZMFFVBWNB0L|x-aJoLDJbr#3@XMXy zU)8!_W0f(6AaU^1yaK$>0VF;X2XU_z;G-^3avya05n$tMA^3(nIP}^bKHv!+qG>T! z!QnwJ@l8R!e**%xtW)Iuo8QxSdA-e*%aGUmg$@26?5EhCIgSa=w+&k0Y|sM(m=5eu zvAyrzLCav5&;R!JvzaZ@dz)tzlwtaP(f0d;#32XxP#_dxLDpdfxK0Rk`|yK-6gKe0 zupqESBkV_~P+UNi2>l6`uuFoy!w6uD`p*`)HsU9&xf2D-QxL!}eGwQ;YztgM_zoX{ zKfdv^UIRN464;i8*Mf{90!9?n9+8GWNQbiWVA==*`ZDA9sa?oqa9RgCQWg0XFHff%59CjAh5zR|&066m+{l``Lbm0wQbicUTBq8bttGcD?h``a_(MU|_#sz`#V)mi$T5NH3^>3e7!r0!_>>r|)?YmKbU>w3vD# z+xXyAnhfx^_WGpw_;OU35_JnyJxJTkechWP|00E6er64vrLE!^^HGR-RtB!-d{KP) zE#nm|yGjW@qX&7w^AM#?_i#V&xDVX)onHQ?0f0}~A%>SJ323qi_ zUW`-V&I%*7n^c=Qw>x~9I^J|gWMN33y3~i?&6N0$Ie8MCEi*wjr_1;druf($Jr;<= z16yD)wdSS&GJ39dF)J&gh>q4ev!sNPP!$wn!qc%a!REZ?DPT14#~;gBqYkPMA67ep z*yw3I_G+zm+dteG-Dzm(J{(y0y4n{QJ^l%NgDga7b&Q1?>_7`p0TwOdTad> zD$c+J)ihS1d%b-R1hNq_ZfQndv$=+CHwdaxP-5bc^V}|R)VV?sQ zG`MpON9^Y5sB&G@uWp8}YHprga>ERzXU9BnKh^Ve94m5f(oQ#Xr}q_owr7v3CY-az z+)VtLTWqS*nAQmYq*{+?7}0yH??dfumg4P|baz-_|G*zVa+qfC&9GJh*E<{0L~!JB zC?O)kPApy>p+iKk6NR|Z$(C9kfy)Ql&w6~(s^>nu&_xXUom17|NQJ zC!W#J`GShp z{)gR21Y#3FrI5xcJFz4~Y=Mo`#nr7e&&QLS!6V0^xW_}UrI5erSoP7xqV8g1sghvh zN-O20s{OXLL^}_k7@xYAN6%4T*3|WEN+;B5BHDZl~&} z^&cC!{>r83p4b2)mRfEWLm}E^u?J%nc?d{&FfdqHu>Up+SYc?xc1hZlzbNqAU0o9M z-<9H-q7yggm|Trc4LY0bHl^f8v1D<1vB{h1U~xP6c3#2b!QWjUck^@MBM!dY(m5WX zb3~Lmo?t$q7wwmQjM2^Q_O$W>O#bt0-o8Qir~EzMzUSqKq9AA&d@2ZOHv9@udx%hf z-A@kH{;21S$B+;d*YzRX2~QxO164DaRw#DAKbOVhkeu4XAhsBFxIA$d+RtTN1e}Dy zx#+CB_7Gn@YtTtE%{MZn^diIEQaRlrXZu#7g8au$c^~LkBW(i4ZT_*&mv7{-hO~uW z44Hw8d}>LR4X<18({b)2_E@eWLrkeXyuYkZ<_bZaDHizEyx;YY`4}K~keO(YJ>td> z@uT)orpYAEP7|Ga@BHk@2nN#|(0yyO7y$WIR0_^|;wn|HjQ1Vbr?{6FZIeh4n_(S$ zTkBJy{rWXRcX|@I=r#ixi#p}4xM39y{W4x#{$lLWwoi|@P{UI!37}Y22a*ZO}b((VF*`8paErO^WCTp%N z<>FN$pHBV+K8IX9p2Is6LJ}3&!_{Kncsy70KWeG#EZUoORe|!(^O}=NJ6_7o(DDOH zW9Ug28!xAm3HH&NtiRisRH{FCw96|_s%;`v`gN_(v~VoDV*I^t8ytiBA>=gx)7(}) z#l({u(KeWVjO}at0n5{~plTc`GD0_w)GhzVT^sy{s_Vj=YfjDjaXQU}RPuvdqJ{e3 z8I^kn%`FmyFMyM&p$|qO&G&Otxe9IgpO5e1ZE7+srpdb?A-_6Zfkr1ZSu&eHYN|AY zN?Uj%RL;~%!Irg)-2wts;VR0l=}%^XN{`mw$X-V^kqOIMPR zw+INRO)}`8{ZJkr@DrAif%1aH-(HSr54jVK%aMrk0PF9En zH%MNT!mPugh>L{*x{ijH)TKet#zMAshp#goVhm!_p0~i|d=b zKX7*^*a-1xuCQu`L9M{HiekBiSQ0yn`J$*EPfRJ5xty~Qm)yRw2Dbcz`oGhg0uX|1lABxTc^AgGQH#C~UWis6c^j@uoY% z5%W9q98fvVAT}DuiIJ>>vg{baVd$R_*It34ZyL{HL7T6j=ZXD zKGVCZcj{bZlHWA0wSDWvXs~uqKy|(%$5&z#$PrDdK2o&w5ts!UVaKN#7Ztt9Z`11g}{ zcd{hS(ApwuI{YHb3KQC~^mFnZ@0!Up62{`MAJ3d9HmhzD@kf^LL)2q)w%}XS*^~qS%%ns#qGIN=NbuLV#TR|pEGSRY(K;zUkUVM%e zd!=*>X#socMI;hG0N&8IDlSeAmvLz`KGE`M(?pj3nCq&ZQ1SginfsILm|eS zH@kIU+X7XJ-5G53@UV6*F_ZZ1hYCDC`*%TSH$F^~9sBIS6jh4C@9r~Uiy^MeGcH4g z?Kv`etoI%EL8;x-skig=DTOOurPqz}J`I$goshX~=SFDnq6`?7Z3u|C3if z-*`tqVlp!`ZkoQHn$!ajh*^DsADebD$yGPh2$f#y#BXWtF865&F`QwbsdD4=7O=$n zT=AhV>SpHUA$I}?!opy)s2EuKlWR(B{ASlW&pm68z_fhD?mXOEG`|*EE z8mqiOCkRh)+dW$P$&~q@%j&Djt3?&!hj6mpwNG&0&BO1N-jNMx9wt3F;sc>59P`X- zMVw!hBqY&r#{O5n=Rzd$eb<>an8LGvr?NvZ^y% z6U#A93?#Ue|GpZ|F98zK1+GjremNb1@6@cz z7V_ywkBWBAo1>I1)h&AV6h5MC_rVk-cUbkht>BYOwEBVkIp>4fUpez)BPtm14(Z#fEq|jjBK#7&zc4OF1<&#B8gHm3f~};t!6o*nbFq z3B@xY|0V_RD$!hrO8|zNzpW823?jnPp~tz8_>(T?O9T2ahz_ zec%rwzyE!9tR9p&hZzsOlF1 z1;Kz9-<+FbPv@}5xU;}3FJtCpVG#x&Lh&khYWz)?k-B@_E&+TC4M`La=?JOu`Rm%N zWamCs)eN`k)X;cwYcN9j3Anl}F&B`^p`!WCf8FIki?6h*HvytD0Nr8Ike3=J;yH0A zV+P5P8*ixF?qoy>YJQ-LAN{~DK=$ur#VVcTvGbd-zd_7Jt+|elsV|mkHc`5t%(NembP<$4=Gb1pKp5sg^O!rh**7qbcT&jeu;haDMQQE7iCS#+w6MCo znvrj`4uwQG2YaQluyN&~X;}bvxNl1qvXbgMzX+CEYX(pFTdGn=f=F(%kpGOi*`XBK zc873Gx75)Ar>HH*zo-dBMAQTdDZ{X3A31^gaSO!Ki^V@NR(plHRkt{Br8OU19Oh(M zbQK+PpsuC;XfnHm&>(36OT8cS)qs~W&NXI_mHZZ}=6c+9WVw(4{T?72(>Ai}A$JRO zDcD>=fBm(wgNJSH+;pO2NE^Jh7-*qv*$nj(^}JQKZX?NOO$Cc)aypmxVd)EDb$DtC zuuS3NuWXpkV!wJ7{5N`H5-;Om9KiD7ZHs1pnT^Na1IdWE?zfaaIK}8Cb~jrrx#q|L zQYtpP=ej12rIGe@j|H?Ok^hxMJ5@eZCnB2lh6o&0>7Sv#b)l=m1?FQfIX=ehys%Cb z%@F|bhsvi3!eMvT2opkg8j^c7Ms@f8eV^lD>Ops2(Eom?{v%#l8q6Aqev&V~B<1G4 zV`{27?tR11a0?|gKMIgy--}ugV_BBujMG~EJX_Pbd;}Au{Ril2Fn3vRV!)?Q6{-w} zbokVSg(mz8Y0>HN%{PEBKf11;PIgPxsBG*_)0jaWfF?p&l|Q;_Y!H^kKLqJTE-+Sd z_)HK{&Ep6ArOptwU!9HRY?&vYr{`*=yu7dJshy+i$z`oj+m$-mW$M8+zpLp<8J9Gb z!Z4lLKY9je{sD@eWgY~`snUNL>_KL6d83>Vj~fv10*XQriS&=ZAR9=l#FF$WBKkGR z`%>T->GNH5Fkb%2&*=*Ji23cy&a(0(APAAx*5Q@K=58Ho=&A$x0bD_+uDOPX-b6Hw zcvZX*9iHZ#&petTj)g8s;>2$OGE{aUaE--kz35JQ(tvw47OidBaeJX%jUj&V_!h-! zXK()YA4(-Ti<@YVyfZi$K1=1|Nvip>%@6NkTIP4gy^%%r$Mytj2z$uI*j($Fzz5~j zLCD6s^fD+nkKCC_TaXA+;c%SN5^owz4i)!xv1EHnZH+p;qht4o)|=}2d8(w5%An$; z!^7V+aiEd0X?E!Vv7oO(3YVT0&P3h?<+2^`lZlrHGxP=TEfMM9W~EKX*T89_9p+QP zi(`^lNA;t{5zE^>t?mi3AgkmdZ|Bfsc!-AyZ)ie((nhyyub||=OOdNL=pJ7SYQ|EG z-Gj@b#{+M0^OcPJbLAYims2u9t!>FA*z~=|4DbNqE1&B*pKq}b&Nf-u91rELq(<4E z!s%s{#9ddly6Oq;_xZ%H=hxmZFbUQ-{ng5tcGlJ0B-G>A^IH@zH=S{RDTJ{JDaW&) z-4CzTTdM7+IalL;(k613=lJR2aUiOo`IgJ!k+bKSt1-wRp0!a_S@?$7L0FMUE$P6c z1Za~xY`p4m{G?v!+TBPriv0eP!PfgnL*3VvEEe^EMffiwqfp##<#UL7Ko9y;V3GA~ z6I3t^s?SIPRXfsIFTTOHE!&lZ$Tj#$W0__-MYcD@Mi}fB>tAq32+sH%G!=4ANaLLL zET>Z1Rx844r6FtCF@yzNC4)x33V)^-;^poN@n4;5>qz6Wk zH1`8L-x!w%1NV|+Kl-MY$%&AOITrdB?mFEsUPT(%SA;$T`Nfbb%-k^>LP3H z@V%U>P^u|el)68Y zHRfPclv6g}53DhQBoxm_l%H|`5&{>5RZI{AyIXAV1*s)OB6zz7$&OAi$H?VN{1su6 zPr@WsK{-K`uNUXf`=|^z-7%g}b@F330#|bnnE9k?7V=0>XBUmaVXfyEO%Y0XTW?^t z?4+G!q<;dmt;?*z*wod9rM4S>iSlL71;;^=s^IR>E)ZYtM`%5OC4q@}^8$a)EdDx9 zQ#EE99N3izLyE{XzoEZT_LePFIFo^G)rUQO+(X&&3Xp*n~#pW5rDe*%X$V{*^!4s3IYyJvIFM!qv zl}{<`8bba7n}-Iuz{K;XL1t^jXk!TcVfb$HktTU5c<5dIF~4|D8vVuH#|83xr%hMs z?g!K-mER8;P9UOiXeuSYAxWn1ATmaNOZlv+q^#M6DMP`;KPsFJ{0yifhkjB36I>vK zgOnXlEh0PBk-^ST=V?>an#`_GY?jC(oM;=p?p^g@zCRNq5UqA|#8SkQ`>7Ah2iv!F1;=MSG_PjzE9Z@Ihk0{-CiM3(Nu|DR6MCsw1By)R$53g5 z#m^3N8fF;Z*7_=Hr-Ay~0=H~>f#@9mXu`@iaSds<-7JE>BOk!&@`3ImsZR_dc8>^O#aza>KF7OPJNFbBpU5oQa=xTw~Kg5qa`qDG5KVr;V zvd%Jb9y*iFOlpZgKfPB*<5G718R?Z1^ZpIAO_{Z2_zdgE^i*AjF25CL9Z}K~{}*1^ zCsqMe0xd+_(M{1ZzNNAeJE`5AH)e;WKn6k9(%|&do@&8Z!h$Rb##hJ^Z*>6ow|j)U zA9#dDd~zs#@&LmBlBTqe3;edj)H--16}R4;Iyf*eCTuV;`u}_=>@=ls_<#@QB-R&9 zL3`C&sat6bd66W447mcE&Il?Q9AyBh2)e{RSX_H5^0m|WE-{tTfk#!UR4h>y4vj0k zQhr)9_?VKn-_6?jkF*1xSLhm(1RfBp}!&W62uV{8+sIp^h(gXNbNw;NmE8IFLE*VeMV&tjeq3Dx7ySe(L!VuACxIEUqWVk3Eo5-ULbj0C!@Z#i2M1Uf$(|=WR$t2vLIm$kD|q+s&H&prb@UFUX*7CDW3j4iT&QwM;?T)`FVr zAoBOGzNR$$P+F!LGOwb9?YEqG^CLJb%N?gSu38#&M_^*#ivy3uri&3KI_G!iE?|}= zbU-;6+JsP#q)4<2uHL0&zxvm##w$;@ZqMZ*KxtT1p9zbdL_nfFr|M8uon)yQto?rO22a!{f)QsCJr5#CP%*YhG?2B^GG|4jGNjDN`v7jb<+0c*G1csqlK zwUNL+{l(bT9D;p}i0(oraA54VH;5(B2om-Y8wR-eC^6Z@F(gN-qRkZ3U1Fg&cts`b z*lC`q4!tO?EU@W}U$|818*Y(Sd=#ro6-?yoh?DZXT!xC%*dkefu`K?Ey@N;2)nZKm zWRszUd2Di8OoaVc*#u1?vse@vjSJGE3?~x_K0B#7+0<(pv?U^_=_NDB!E>vj)oY&K zU<@$YTr|;9pg8fll%FS* z$9!@7sPV^BRX#m>)njt7dzagyjHD$1?aH5uljSyD(qHcS2YT=QyB^FtnBIS z+4=Gab_OLJtsgl24Zgj*K2Hnvj!Ld3CB*EPmtJhnrG}VZ>Quikp*j`I=&fZMh8%)GX+z@gc?v?uzt*1tXSgn`q$APMC@hR2J&L~=;A9-S{ zu^m}+$E(|N8uZjPO2?jtRjc2DxbJn+dFMiif2iY?SD)JZ_Vr=umGD0aP)kBD-rW3f^0sdjmVw3&&0ZM#eGu|RmLzDDl6TbtXzLw3HSusL zciNsdFQ=E1jh=(|Ff00G&nqm4h|wo>&OesTO>4-`+=xM~Wp+0sD0)yT$H7fnvAm^c z2&}ecDki1fAmA4U#rPX;dmRbPj8yuP^N!3aotbk*sipoyd_rVJ1_S7Ch zq&?lb`Bkcx<$~;yrMIzcFJ7*+yMl?S1FE!&1Ng@9Ul3da2lBL64Djim&#&Nm-tZji zv_+KKGHw-=B)HO8-q5+R_OZvifAEdP;oEZMCRqDqYgA>J@Fod?);UE}BX}+@gPgsi z(^y~)7klb_q;e(0T<2%`dNtBv^;I1mQPe(eHyJA7c*0@z1;qm`c9PjNPo~;>D`uv$ z-vGw9#926x=z;YzLIzeGh8EbmX5zZ#5H83^YO|Kan*tk+Gb^Xvt4 z24bnYu-)i5RAdm~MH7(qYQ(1?A@7PN{lXQ7Ph4I;N?Tg^UUG=r^K?M@#wPMJ$<4_m z8I7&m9d=Zux-P?edKB@Pcgus2hW1LpF^+s9dW=XAoOP`aBHxf}FL#{9C0}ZVCoTd@Qscs~AwyA% zj&Wsh+!?kwBXwGNf{ttoeNW{X*X8mqw2FmmwEy6nZHiFf@%~%$Q5Wi56q=A!rZG%3 ztP~-q`HHQ`zjJB<1wmjj4Q z3n`=rbbJFay|Mm%wN5goeOplx!?DTJb8u$?(T9(UiLp7Nlahr)mKR(i=aIE>TwF4S z_^CKHNdLIV@GH`htoY?1wmk7JV*kT=S*t->@Pgz?T{6(wihJ`nBOP1O;@5)r=kEK! z^Sk20=V?jQxB3y`6H^FAr_`PPWP-drOzy;Z0K1%uFa>QSI=qbCqTJUlUb-vlmi*dy zj)4VqQn5pLdV-7x*RLSOZL~07@Zf@DG+fqa*^l02ma0ALgLDlC>QH#=MKxM%-6cIt z@WE*6?;(6XU{ZL|DjaAaRPFyk$krd0w~TsycKg7+8uxi5b#w7y zv!6u5nO68I0n|(mb!Aol_utq$>3N%PCR@u)Z5!V!vlZrJ9=*CSRxK5QljrMW@Ww{TK8JD2=pW2QKzZJL;Ipv&^+&dW*v}{*1 zSUzz-yK%XYM+8n8D!*HqqTM4Lc_-gI;eE7Rm!`_Tsd3LA9k5(^){8_@3QECWKC&h zCr@|mbxH@a?XoFck%y&nlL4g-@8)YcrGgjwG#%lq86u8o*|@sgwzrco{#xoL?kwCI z@w!7&z(9>{i$)%o8Ga@{#l*J}JvqVh4lHv;*LsU6F9{CVB##$(Wxgwd6y#E>Va-_arru~T^%DM0)SC}t=>%lJyH+;qKTSZHpLz?X%Wvr?H)0zy>%QPY(d&NOjBWY* z!SAuVhR-(dr(=O^vNf2cG^gWs?zx2CbWD9?xS(57MrT>>X}N(zZg#v#+wXXMt=Qt9 zHN4_l3L{lm0?}+x+pcM$iofbj5V#jd6W}||@3)SEPS0ppm=N{>keQg`9{PIR zX1NU};MSM|;cb{3)b={V);NP^*yVIJKQcQEp4>zcN3-h5moc59y zDtyQyVE~>TUaiI8I997TTcecMbun!xS8O*~s>BHw-pj>hnZrc+w<%zM5Of1yI8r{e zVteCRr6{dzqb|0o?GavZd34-H#bC=a5kHjC7Am#>CazJJfzyI7G`A{8PJt{x3jN3JZT(?OwH)DNXS<$3g9xJJe}mS&YG!ux)&++&B|Sh zZF711Zn8<8kus5sZs|RthJ7-I>&ECTyT6sIW;xg$lyy@+(I@lrbzH;*JYR>8NWmfpc zndd}Z7MjyZm(}f5ZF+q{wZti%EWL7arC9&9TkrQ>$VDJ)sSZaLQ%kjm2Kly>;%o5!S(7tXZ-*hlmEM zS!2UZ$Ey_eXDc0Z`)sdxqa6BW3i7;kXuosy_fDBd41q|)X`ku#o^>8u8RcdJq8t6a z+TyaUg^0!8G(dH=(|e0p5~V4TKQ*$v((Us0Jo@s#aW{WUaAz|q_IPF1B>Lg^A8DTP zUzrcz@B=z6pQ(POCcVhh`SL;$=nPN%d&j$qErsw*W#m$V(-JZ)Klvj$K+(@oB~JjN z(pb$>LYNYQWT1bcgH#!$+FlKtx;j@pdU|AZ^Y`Ok<}OVN;=c_zaH?7cn;}&N3=KbV zB@9P#Xa3+%?$;r_PwqD%z)YZ4Bfw0e))PcMf&r?TAS=7DF_ii-rk`5N__87}yg?IZJ;Aw%*omusSz3X32H#`< z{>9TsEX~1&Wbq@2qjvGN9)-kCB9|~+t69|%`^3Tvj|s9ZqG`VulKH~8egD3?BOGFB zI15O#3Dm*ORw>xrMSbe3nt^Lu$ucyNhfW|iQkNpu{+PGd3HSv-FW!+|K9?JAXSMl& zGwAL7K80_G90}p*Rx-iN^Y!>qd}>)urBhxWnI0bIp|F@+U+Url-VsRi#h;TwI91FX z=C>{_yyYNqPwc@N|ypzNQ7+oK4-KMcR&hx<(fw^s%CI|+S&gknxmwmJy^$_&m4`vP!{ z`xS}YLS%SA>JT^Ls_>R& z%Kd~Is;s8;H`Pmcx^dD7A4+y5=rP6do0KQ^JJ*5h<7(qjba$4Uz3?3|&htK)?&aue zDLTuLXsR1AQsWVrEd*xi^OF;Way8Jtg7^ylBnvBh76grOvM1xkD>kwZ#h8hjf$9(4 z5JkoLi2(DJ0IMoW@m&~>PopJch55RIh};Q3)QuBoRXRgnAgz$`ymDjs0l4EXRP8~V4a&p%-U<(H-UIN=o?l>H4#tha`*Nd``l?S%`?`+yAIv< zaD+y^u1o!Dbe?OqOh(@J?^e}8x@1(_ie-FTNO9jAbD3+d?!f+8<Idi}L_YObnei1w_ z%6Vp(8SI*>cT2f*=tNw^nod!}pxrxwnN~)jcE?OXi;oCds^ZgBf9M3g66ysV6E3qj zD&)!q&x@J6%QPdZIT(>~gdnbFfBUI0l9M}aMezuf(U4^NDwXwT%>fZl1iepidXMqU z5`Fzvef`wpw~U|W(ec9OY3A8wwci%uec4)x_%AMae~-tQ8o9{?;2_|PSycWDLBh6n zbq?m?%YO;-pX5Kdi8i2CqQ5iqZ|fVsWOr>|I}$|{%&36z zumlqfOq>Y}jP(D3&aWB*fSe35j{<#4?pKybi!3ZUVhDOBwBBDTUs)-uhk1guB}sj( ztj_iIl~_ZEhK$ZqtPDs+$%Zw(u5~A`wXMKaCu1Cay*J_Kc?Ife@u9s*mYw(AAE$-> zng4j7`}vhWpNGvQ+Oz-Rm;W%JoY!4ZNU7Axt%PT zu12AZaBQ105f_GeaxQ8#A|Lj1X!gjnhm)aPmp3u-t`=;=u3xWm1M-~cgBs6(VE>^U za8JJI78*igZ&NCF1~5ndiqeA~Ao@k$s1vxMZJ~^dUEPzlO!*O=QY$5M=SQsL7z5>l zyJlqSCbl_uiT8=V?b1OwBdG~?$+j`b2%r4MA5=W-nmvpV?G0vuUy&NnF{hBpi+GoE zLUD=e_mFE-Gv|=m?vX#dCVh61$dwOmSC@K%wB=StanX3o1~?hQ2u~$~(?kc-8^n}a znCL4Y0&*UIkgF6;e2V@-t9!cLb$#RxisHQa`C=#oFn@|WNO1ig7~28fVv91F90U3i)`7JUGYECJD=%M|GT{tFB=nuk}v)Yc{Fy)-)hPJ zSz^B@r;(q3Ao6h-d6v_`-H_6fqrq*>q-u4v#4zQ$-SSt8M1W_{;iF8clmmI=*;J7= zy|AO!5>Sn?t)KGL-tXL1s(?ZGH~sn0`}B2$;x{UTC+ zt$l}NA}#3lr>v1uHcMNV@!n}(#r|&W1Hc=Z*MBQ6SLka&`PDWatgpa;En7hejv7|h zBf1Pee9*qr4ME@LUT5pUH_d73O}*lU++=t07mmT|S10+cRLaK?&1RxRq4gY-me`70 zARoFXk8A3AeG4SJc_M7od{4Du!NZ{5GUjBa79U*MXd!F^JL;c=^XKhSIfI_>k1{fDe49P5NnAuUZ98$_|~)A3~OZ$+4;WtuH=92N+& z=4k85L+euotP<`#=H@EAlF(`5!D^_f`%#skcLZU;$U1R^h_c2dF=x8)39~_Wa?SSNfH~sIe?@qW#m*(1apk%K zjN@u4BcJIDa-d%M#_kz*J?j6AdET;*1BO}q*Bajfc1cU$22`Up>k<2nTi_t0^@XXb z!ZK z9IYToj^*N!N3dj7)1yP_rh>r}zgV=O@f5}Ukb~aSa#@kjP=4dQJ*jc|g@W(qH0jR= z+koyN#JyYG0?DcJ*@x^GBmlp-A^J{k`b1aYe5@=U5rC9JsmJ|OvrKR0l_P+FUGmGp z2sI4C<9PA@iVsM~RtXs~-viWKR2DoC*fVo@Ly1PW@l43U119 za+rmTrwJCCSVkV?)gML+;5e`nX)al347Q`kMy2{mEU*`j!jFca0MNwTH=<4q5Oevz z=FO-!fh`iF^s)=%;1vsrJu_wQ_OGJD1W~ zN89e%V0ZpSx`eC=U>nRyJ2!ioV(;tx_ z0k81pZJ1R!za3r2<~gcFdhqgCq@53987jvYmy^*_ohLPPD^mxB`6ivpbTrf^M*!BN z=8AoG)KH5Y`u&#{A620XeK%C84$mMxa#?j9QdXth;bu5KkojM1Cm)p0!p}Z#*>Dg4 zEBrzug2zhibn?XtQ*!iWD>rdFB|C?~i1KV8R?Up(eO)(mnT1a0bn;xXplHA8{G(hT zkO;ZFNJas2o8nG^5FxBeg)hJU5 zEU4C>cM8)D;O#HqEf}0$L@0BXeYirCJD!m&7^J|yixs4r8OWm|(0w}p5G2d{e9I`B zU^)8;{0dnRPT$dG|2}Dq%oU`2T6DMQ`2|%rvFcY)s&;A&+%k?P$0fU+p6|E5MhrnkB+8-t^Z@8R=|5C?~e)EG#;i8W+j@g8fF(0~euF=cv=^V^W&#KQG0XSUR+2V`9#FIs=@+d$Q)hv!-E&TO=#7`J6Ht%F(OG+}j$F`W7qLATqzZ7@_2+NT$sK#QX;( zEre^&v(sKXE#Q4BeXBZ-|1i>=hG&LJGNX2NodosFbjTW*#1ub$ofrDG~tPY zgl6;Pc+Ce_nfG(ea%MRB!qBLiaZjJZd71hNw?+|e)*(KZtsAO^mD%ZOGiPJ@Ynlob z>BQ}t=(9y|Vcy3ESJ#|*(C*$7Aab4bVuyYAbM4ReK)$MQBfnRT-c`)PSjF;TD1KH+ z+2P&qkzpp)7))wZ{p|1{dTSH$7yN;8^?v6C#pAQQ*nnF;5=#c(iItG2pp2Xv6h5J? zK}^Hm^fH{{U|4Yf< z;)h-X|1)jsc=#;pY!nyGHc>5^^UiJNoFvpUU}2G+fA zY{^l57)_9>phz1^s?kMORPsMi?Ki%@b$$s@rzl_5`l;?U%TrW8FzHklk#;UIrGIIB ze_h5|rG;P%;nDcK%E^3`*X|O0a*gw|<(I_1 zjZ81K4b{;riuTQeIVA3RX%n;J6*G+NP{(>1U(Pf`GU1F{C0DOH%S(-zJf0BYpA4GvS;qPdnqm+)!s=OYv@ zzG*}X%SwUVQ=mumb?6+EhtO{%W~0l2%mIn#;G$qpI$N5d^`>Q`1Ub%L?Xq{BviBIH zvds%FKJ*tB#fd&CQz4}XPCK83i6oa}FeIyDUvPmyasWyIIJ2(_3O?Z=DyEaP+>NU4 zpI2Y=OQ%m%I~L5Y5j*L@QeP{p55nqkht*P@_W*T zFw_Yik*HK3(=M~v7;f$-1O<0>^4~*2nIth`l4|WGK>L>Ryo$^^3ffPhLdG}Mg-J!( zSkp96hf4K}8~4Qig-0;OJs>0&lpx*?ud2;pYy0<`UYL_2Lc5U~(}Fk6rBV zhA}gqs#G-b&-zUF^jGk=Pr1iQ7l(ZB;Qpwn>hgxxv-vQMt{DBu>Vf%xs9f#7vFpPZ zk_orG27?2h$qU~1FVIJ>N5z#8?LpDsJCT;50LS}X0hv7LnhI>+Kn{l=P~RU>mh`vm zAe2>PWf->pjLFe1@rg9>r;v<~ZR;VgC`4T$3mla5$T<`J4_Dt5omtc^n~rVUwr$(C z)3Kc|wr$(CZL_0}(XpMIbH*L#-v7L>v7hE%HCN4=Rr%~#>ty)Q2i5bTmK>bDHK&&# zE(QIF+dz7(f*1s$>?4r%)>d8T_QJ@HhV4IeYM zOVDU~aP_BtoV2C2hOex@53IlsSTBcJf1hamKX7Mb?EmU|;P-!`tNTfKvO=|A4O>0n z9+SRE3w`st{VUMQ@5J?{FQ|F2RrGGy1$)qY!}oFKvoy%RHn9=leFy#&4ESuo1;S1C!d=IqLgWna1UnCfn3qH zeN$qFRONo5TnwPuRk2hEtJ5Gy3@N}gPJWs~eae1_V53PV0<1zs2KUu#{l$WQ43o)_ zVGSLki!mb0BqKt_U=p8Xz$X9*%eZVtB+p1@2Mp&xazB4*(JpFFDZ##9(!}Vw1cfq4 zlIok`9YWG@i7`%6DVS&RfOz_(^m9JRgPhZII4cAKUPlzS%Oq(MLWBaK#)dTd;SPHt z_9&Ybj6st3`D>8j=c7bTn0)aEYV+@4(kBel^S(h@fJnuoyXgrazY*|)!HEY^_pJ<+oq#-vC;*ov@jjQC3BDw zoOHe^=N&fMR}{4BOgw;xqSd4bFfYJz5{z2{JhnK&sSHAwQhzYrdbAU_6kPdRZSIkP z_ZHfp181Ym{iRxkjN0wSIiCEUGjjq(F-EqygO}=BmSN^hJMzyFeTg;I#akrzQV#Yc zh-B(~pPHVlrj?$9?(e+!I29%Y7(OZ>gAWQ47ZUXeq(U{-{R;p*tj4Tg%Lpu)@H$bz zCN2^y=NwZTIsI_t)&v(-Kdc7#&vm0;?vn`E*7^q@FoYe&cj2maA<#3z|73x_W{#X_ zfM$JFl@ok0XLaP>3``IMV&~HxHXE-%q%V?(yUH>jbYmFb(f7O&2Ecu6zCnrg9)la6X06HGjjM zAcmlx2l-`NmGM`1|C9Vinvegc+>;Eiu#=X&QIfK*V4Dd0IuM~N`6>|Vf2el>h@@)= zti&5^KunUY0*Vmgm_@25>Otp zd%PK7%nIYYWKHD*iQsdXm=Li99`Z#foVIBL0L9C2z;UWI#Ol*3_$tfxBiq#`Y@?Dw zRF_;;EL$7ZbI-{DQIN2ErQbNsJ^t0Xd{VM!3u6C3uEvJhQ_>uOewYFRwL9@-js4)e3o4G$RA5pFE zfC(!%UU}N^EW1AgZzV|<(q^w0Rt9$1^mt@QoT)~i!{ZvD4X)3cUk52yk+HB28!7w+79`(@vPSv<@9kn##{YP9ap zn*p3bB#9GWM5Xfmszx|ALSn-nd+`ZGep8n?_^pBaW=SmW8;t%|eZ#ePKZqfm2P}Rf z!4p`eH_h_EF_YInZSzevJZZ{HxhB+^F~<{^w1|7%Cu`4{$)# z4Z}Ib5^ozONB63POBWFQcH^g|2gTSAaK5$0#Mno>xGJ)9enWkLLFJp4&p(#uEWmV) zfI?m9nIA=2cSIv450a%8x*Fs|lavLgDjL1`C5#|~qd+ahie)Me%KUhx1l z0Ub|8Hl7d5Tn9>3Ap~v~FSbnks0cIx72k+VN)*Ja5t#lvJ{Yz!GP4Dr(DN5_4XD&4 zp&HpZ2%Drb_=ez27Cs@^FJ_eA=HI{mfA(GoNaCX$0qsYnjQd02Q~noupLhe2WV(b1 zcm|-HV14J(y&fKDGK1T|B8~dT+rWZC(iE?!@2`rq*n|_+aLHJ_3$9X?q5MV7Tv&7| zrm@Y8zjB$+NJqE9<|sh<<8s~eZgIHuS3;r0VH&nI0&A?yZr?!?oBJvi>>Lx~&^twDgWhr$a;3{wcX z!JW%H-eY0r#~D1)41k&b@&t1~fT`Zc@O&iG_vH$%tACqg8G>Oh_4Lb~P#A9qlpFH& zP9D}#Ngf~v>8mpaX@P0nJR<5R&)4_yaB99MV zYP%_sDAI$RigzX-O$zZ2(MgR2;7f+)B(uoi+HQp7V=$^H@)}@gzKq!Cs_4rfcI_XJ z|AN7lAF?^&b6hT-zDQ@HHxh}nifN0}(dI5{%WG`L-L@9En9d0-Gqh?oGCxz^PPa

yHlr~Qj z%`kgh<2P>C>fTYE?E#Zh!{+2Qw=75K)1B;8ZJ3zCdDjI$qG`W%*$ojvA?sB=lZvgK zCFeTxA=XpCI{8fHWVEwdoN>)8KI3>wS1$ku!D@vDi!H##`d8bvA;7sf3*MOzNT&#^ z6;g_U-7z1Ji^{Am0x$ju^_X3VOn#pQQ_u;Ery^^ukw>}3FKln<4!Fg-PrZajr)_E1<>}I=v!q+(^ic#+0V+3yx3Z0nrya_ z9ic5(Ikj|7NP?0XaV4ST+E6HsCdv`M=q3j>e)^RmxA|<+tdj)5`<9`iZFSU6^%l5* zuUeaN*&D0)#-8)Fe8S>ey88ImsV>hoi8l7tzto01!b%xWUi?smIhTFWrN(* z72BPsG2KQLsTev>OM7u4F?%B<)XaC6+c>m+gLJt14bLXKdsoBql`8Ch7U`e5&WtBI z{7_XNoZW&^y+%(!etb)eRFCFwWNp11VzQfYOez$uKK4HTM0Tqzw##t8%t{NA6gj9W zKr&BClpUjOKiNRO!TZ#1dGtT= zB`TCkrZO!<(Z~t%LVQWIwqm8~$~fG4edEMFghmK%DbN7NvY2B^SOBG4jSsoeU9}I8 z@8tTrx#)0!Xk0e)MZ`Fi?_`7re_2^HlZb*ubafpShf`3ZQHVytq3Y_Yy!VIl$x_mk z4=1NlMp^cA)$r!Ekfy3uHS+39uf5rJpqII8@)&kPvu8s|XKlfWi*nPacSu_ocf{qc z+xaIq-h_5~osS{9#FPQ&ab=Z9DCd27WKnP7`JEqNIt4Mih~u8SY>LJssztE)gH8&1 zo7?yh*HL<>%aIbkUB;2UVY6-5xHtskHxzkB=KL#I`rI|7FOR8h83?)nmh`T}qu5h% zQWjOGpb_k!((<5@6aw=PODD3#6s27RkYmVFX7bHtkAD_PHnK>4bo@4=f40un2ISaZ zT*dnU7O4-Dn}eO`yK#}wA`O{eMAJn8;TFq&{Vj>EwfS1;EX%&RCIj(z_&GnYOCG*= zwdURH4UVPWsV0Lc#x`s1unv=`3@^@^dnq>ruZX5Nx190n~xHjIs1bmta%p3XQ;HW;dWus-?1PTxQh) zTo&#LVZXaVb-7~QO>QaTsjo9s|JE5c@9J1V{ndcBAc|v8VreFNW38yh^~0^ z0b;Cn#MZ0x-y<`c!rvJ&GLS)L$Mi~j!FC?X^IYlY~!7^!u=K`S0asx?9WJ`VOnME#>b-Xb@JrQG- zr5(}9i1&C=%^H_Ir3HO~9k{JaV}g?f_~p{Avg8mkb53wO!3WfW>>Wz1=%~{p^gcbW zKS!c|wH)MPm1XM06~_X-U>V7%5x}_>GOUo5M0~&DJ&YVY1tkdWOzZo_G^87HWV^JUE$HO3acF-XQ z+MH^-f^k$^xO}KuQ=&*qC}otWrr=C6BX_8~NKU4eX}OjoV4!&HCUn?2Bv4W`bMK@xJVgK%Up<|o zBI0#8S^-@%7*f5za7q*^w2;)zZmZru;SI7)F(0tJL5+UVAZg=|vfGSk$631oW1Ut^ z1_L6E*=(dzpt-5w0=T$QdW{hNfA|H7-D2&%m-u0XU)OVLJ&a5?T|?A!4O2Ucm%5Q9Qea6=O|vm?(voLlGudNwwm}k{+C`LbTmF=T z5rS3bW*+k13AaxniDC5b;o$6Rk=33KK+@qxqhe|?zt%m1$`}STyM7B z21-TZyt3Ga)$UF!(yzp{>Eps~TVLqdG1#n=M6lV0(P~-8o`^^y@=&2rLAn#nVm05f zaY~j-$-G$RtY3~A{LO&9Km@;LC*E5l@FrYm{^ zKJAg#f$PL%jYUBr)Hir5sGn@)={bU`+9f(d)>5!kp?iSJ25sX;KKaYZP$%Zn-;o1N z7;s0u&geOrpsh$p8QBw*A;N~N(pucAB1R7zW}POLuaIgf<@Ep*VCs`>W9Elsw`f%_ zk%{y$3mGxospU5L;HOsQI<7D$T3hZG^lM=`-#YbXg4t(pVt@h&J$w7NE7M+6eqof~ zDc!?A3%@=~jpoWA85f3mg#AW=s7u-qAf1MCP+JNKRdNTIZBe0WyQN97 zUtvi7c!Os|Rv_yPpq#vZ0UJ7`S;RH{d+HAtoL+JM#w^-owJ!-YvHZXmtJIbw4C+Kq z6jyD#gP8qhnPn5UEPPGeQcgj~S$0tFV8ML>^23b4x4n@>@VD!cNUpccQAU3*2Z3j# z+8+KxiX;S7f+bp%6hkBjXf7w@*8mNmaqy2M9u>VIB1Myn7xyq~Y_{O)xyraKctQH0 z?~NBFTNp<88^%1VKj*ZV2x5|XF*`l`Wp3_n_kO?DMgU~)xal9O1Y#BKn#5XLWJwqy z1)@^#BKt4hXk4}1D<|sr1QPp@;zSZ#6}jh1OHJfIO@$7d^_3D|Kpt4=GM)tImtJT> zgU9nNvxw6~6*6xbEY0SloDTm%7QL2yayPX5lwXp9tK%8JqSy63_6^)TkzL%3o} zc-?8@C?-^{(v{JP)I2^IH}&v*o5VO0I(I^@-Yw_!g*V8!%n(y&3r z_V%_g!9~|ZlYbCz%)}y)f8MQhMNp5!Cz%d*w6cwk=1D~2aYQg{F1eC13byfgd#)G< zEZz@&Y;tD3-*U4P0k6T~v7Q*oRCZvF-o`k`=vfVJn$9^3*kGB)?_)c?j}cG{U1-JO zyXb{>^n)efW_trzrdtwxS$Enxp4}g3lKV;0=o9npPXnMaaz zS3vrg8MfvefljB-XdU2Mwob`m%S_oOr_#1o`Mak!=}#fUxQB)as+A^>;-#>>1uZN{ zs+NoDCKaz6?9|~)u+hAZckk&uk&aH%tHgQR@6yW56xoFaxTeH^$+E8^*Y$Fkft7kl z%dYE1_7)v)qKR!c@RmB3o914w-S!^!A(g^QV@ex`XOM%CEv*1&3EvAp-B{wGS)2)) zZ$$I$Eg0S$q@ileW6b@YEtB{t^`TWt3sGTs_fuJzE41v9@Ia&Nz4ozqe)O{aJ72J@ zm*fK$Fftpa;g1*98=yQE+E=em`>XU-lqMPTT)qp*0j_8$RRbnc1owJl4Q#e;ms)|9 z2Xp*v>&$32XHtM3SxouMyghcezJH^W zIFx)fU|kyWBy}VOPVyC6DiNtA^qd5^Gs}Kw_~%XPBTWhcgNxh|b%gvDyoL;<3B$x=6@kASCN-9KVH$I;`3F?2+8j2rri z(6i_VCTT$HUTt}5V)PzJw!QWz46ZM0m3O@K1nQ>PuK2zLXl{|fBZ~(R1Ja~4$>MeT z<1j_9gbRWbmDHv~;6sXqHzuW+f^^@$Dpfi?zl1495W^E9U5P}ohPFMQGYGQcE=ii9 z3@A&KQtA+QYNI!E`@msN(Ts%37irtKZTr zcJTpy2?z06PMxVAXO3&Mf1AB7r-nWAqw+m_f4q$87#k) z6Tfl)mrG?cb(OZ<57m7A<6|wJWQ2y7gn$o`q&}>ndr&jcYTajGI zj0#HtKCeFWyGdRW7oOQvZGo{jZXxQ&+2l}zNDl}h z=t}ue@=MPpb{@pAWEi|wV4WvV&8J?AmmZU5HU=+xOOGY<1pbx} z<^0(d?6zBR10*GO%Q5$>S+2rI2J^wUt>>@A*qFCEfJ}2ls=3dj_0{^nwx!g~K>=6e zWs{OwSijrMBXLn3CI+x|A^tf)mF!mF${J6CzrURVzBimNA_xbU#eUqPinfVmORr4< z6qZjPf-*~ajJ^X|Obn(UuyUH1Vsm!uA0dut0B0@DQ3`%8A15y4G2KhPYWMC2#X~mx z#0Ri6&uda3+5G8*=n$(0bC*;TPqRnRjLVL;@fo}<->3AZjPwc{#0NA_Zn1#gfdT?1 zYq|6&GN6#^?(de2X<@tA7p;Uq8)zO)QmpB(~UT3Tfd@q&lr&dVTkzz z{ZB;lxlo>+|5+^{M*;%k`=7#_J-|(xqrn4IH;dJv)6m0C#KRY}xSB5p;#_rwM@lL= zh&W>KDp&vY+CumaJ$d2q;5_ePNh-Dlwt78Gd*0b{e|{tbeB3{_0cqccM0;(K75#FT zX_pYEVoyd9Juo9-aMVZcK8@~_5@rtk1r-`CwoY3Ftn-o_X;=?TPAiU`s1)V>x|9m| zJ6S&J07}AayiRR`b9IpQZnhN-fq6RsiEljq1icj)=IJRqSmg7GX&|5y}w+=U&V@wtyFqN1aaCU{7LusiK zW&i=rjQYp@D^Cq?RoSYwvC+DTy}G4Xk7Q-hjFWylUpaoSYI z&>g2q$0|K^liVTSFI1oAs$xGjBjXm%7q|ePMrbu>gp%)UAg0r|s+CDBzLFk5Q(N-J zy7~7S2-67y)=BLVdkLG#w}#yF`)(f^m7HvDB6Y)#VkxNe3|dzw?|LURBb2?+>{ack z2_;=D{FZL}kD}qWO>BsH7vGzDnktf}wtz`SQ&OjQ(D5NHRgHc75KAm&m@>C_#k369 zr0x{n{AG(!1*M2SCrh5^SrP`|l8}b9o6smM7z51j{rg1M@xn}BKh;KWa*A1B+f!?H z3c7a4%7HNKS=)-I*1+DuudI|%wbe1=enkeFe#8vA&{BOq zumn1_KyAQDxA3ocHBxwvc8)A^^&jlDpmKVI+AL+4x;H)L8lC;+3Md(XyXumYn#N{f zRc3{GVq1o`3ccr=-B$IOR8!h5bXA+oK-D^3edD(3;{cJnPO2>40T8N<7LCF zs1n%wZE0{DYIlq~YIhW18yfyEAK0}s>7ULesZzTTQ zL)SiCRG&fkZ`3@g7hOR*bzW%rz54zVi**z*?J}*Ir0`=@f3}%&I!M;p;!?2RWown? za3_`3ODncBEjHLMBQVXxSlInzu|fR_mI&{&##0LDGGk*r#K%Sd|{b3l))N z*=_TwbRdE(IpOQ@+~lpdpG>Wq<*VPp65tkF~I&r-rK2T ze5ag!qh}8VOin*$e^_&;jf^U(1-cGfUJ>nUo@*(I?D%_NBytL7_Qh#CBHHeYxJ1VB z!c_X6X~B5aL$4*-Rh{7qPk_Ok`G9bP*m8LM0g;i+WeshTV9FzlOLAt6)EZOVp3~<) znKvafZ+hK#R*e!-9Kpyn9I-%!)W6(=PVs+mfhukREY3zkiSP#aM4|Iwq{zWo? z0G6k3dANxSFaY?z+n~iS%bwiJ$r`A-Gzx)ix%%4&SZv@u zSypcZ;O=uCN7^Hz?5d~&`uX-HqQmp*Wj>;nZee;7{e~QGdHj$8e>EHj?=_Nr8l&!7 zv-Wi(4-Pxp`p?RpP;55My%=Db{8vl<4f3S}05C@QxVym#Eh&uM|jG8R1P&8hDniW$T*;Zu{xc3 zg>KJNcpGE?u=FB~95RgI2PBYuyVW}VO9p%@@hW@M+3%#`GOw@C4$Sy#66>)wuJNE8PNQ{8S^7ddoadRBf)RbmxSCU3#$; zL%W1hV++9DCkw-t9(zPhA#qdLE{AB+OytP@kbEeg1fFoUi?CDh{h!|?5>4znLJBwI zF2uIeHQuqIe=`ZUEPe#{O72X}2-Db2XmcNX2v)s5HwoM_HY^SD?19gsGd7>pZ){Sl@N%ey z2}Uag$*6e%_1qKU1co1Rr^xT%X`y4KyRAVWZ-gAF?1H9+eq0NwKn5z>qFt`&koghB zACn50u5e%Ld)7{b*6o3XKe%uwjsqw2slnM6sCmr&hF=hcU6_=z*TV09kk1oiX23)2 zc8tSRQWR9ecV^LHf4z+YrNByY55fxac${Qg3ntuRv2@{-&X)UuTqL20#s4a*|;( zJ%Z5~fu6ss4Wcblpc3Z1{4f4X6;y`5@~5JQe=7R_b#J?DWQ4_z`|YI3?7EX=#Z+?J zGJgcAdK{?G#Lx-|!NjQTamJEJ+35hoJ)Fqn74wYL?rW-E(G}w+x*@SpU`f=dvNV+C z;U?-rN&~K;!F#M(TeT^)o2KKbxJnGmV0CQMfeZD}3LOqJf6fV}kwuohtvWg~@K51& z-}B>7&8Awrd0-Ll2W|{sZ=pp@S1ObmrOwtZ*{VuCMyufNV3To!IH+|s7oPw*NE!4Z zZxgK+Tu+nm7`@sX2lyi`uAA&5zk|AJrP@RKX`OpAPW4pezFL1Ll6CvS4k`9NMD`tr zfVce%X{4a->Sg`PCYl!0Bi}+RPUUS!v~mm5J%!8!+IRCnLVHkd=L(X>_i zr5n|!=~Ql;r*q?<`1OsIi)Z$ayB#HT){Ow~FoI+rWG1hRdy-MQ9u2Op9jyUPJ0)&TwKk0O zi3M{d;slF`;72|n70KBicfm*nMA$$>SdG%bkV~116mA19PiREGP8fR%Ut058kxjI! z?17|HM&UkIkqcPbb0C*F%aBMXV6gAgQKmAgs(CMg<6$Dblp_Ooc)SZDxs>$#$Rk+v zBnS5w`E@bW=XprvmHYth4Gz&=q8VnWjIkY(j) z5s~e}I`5PxXyKwbRBC<54Yx%SPKhdcE7DU>cI3kJSQ@0)?*%5YaLyVQQl}!lsP+Fv zdZm;7o$mT6(#oGA<@lMF*gIJ;SU4G(+9cVcA^rC|cb5%3>6}vn?0dA_Af}0(D+U=zJF5eN_v=l|T*|8?+ZR8$Ems##)6X*iD%+gdgnlAIF!TchtaXlfs{i_e@McHfOjwmNinCu7t7Z0Gk%BiJKKQgc61+ zZP0d)r*5w{)EgEGe-*QFYV(7njrVG;x&^@L^7#i?L}5OByT5Fv@L$(0@{nrpcHOqJ zriCJn(25bJrkk&YSy}H{u>DKvNw{plOphymr?5TNipNw8X0%#HJ(S2f%&z-jR3q_sNTq1s%7&0Gt$P|xgVrQ~g9SOUti{HV&WvrH5L=c3Rtfw~*+qmFb27ivH= zfbRGyOrx9V%(8thJ~HUIAru0ZVNTWE-Op?T=V+-K(TwOA)5#*jN|Aa8wXINSK$E(I1wHAqAG!Fu~{$uvNxWtKljP z5?62fmwOZwlgnTrJ#-AV#QD~I`~xs#u)XDW@sfNtZe8e&a8`RF_WnqDY=qn6d_Wgk z0G~wHT}Cs912@ym)IT$|yg_Ag7>F;HJ!Am4-%F%0^`ylpiJi2iyuu z8)907bo$J<+}x4CMj;e_f)UN|!7DvbKUFZZ0+amRg9VnP9dh zQ4CL;xtnjE1abNr*g!DP4xfPhn_&Zs4r0E~_~A7FdU=3;go3mTKVXD)V#sp8)kC+W z58UjoMx210{7Nj!U#!YOHWPx;Ew0L%7>go4QLZ?;{6n0^Bjv6Vcq5x0UwDHDFLsxC z%cc{TLv%>AiU`|oGBjKdK8Z`xRJlE*g56y8%ueEz#2f`#TS$KrSp3Kb75foSH&C9X zz<~S_<3Ae}3n9nG~F~j_GCFNUAKv= z)R(&ciL5mJZo$Hcg(^T2Q}0GCC3?;6yr;l%)^qQ(t9hS~_cu~MvAWBHiFg=22AtQ1ul!T8?^=_u=ziBoscx#)IMjB~#4BzI$`c&p8+uK#8UVZD_*3W#jboPlb6h zN7^2BPwblV4VBZPb1dZU9KNJ0D&*hqAj=pRz!Ag+ zNw(C5qA_D)rklIcI_7xQNQG=P+^??H*L`iuCq74zV7ca{6U&+O_iDwMCjti*v~zTjmCt7 z;=T8z7`&v$Su@8#n{c9a2Y=5cUG2S^{;fnX{_9){ScC~36hNO`x@ENzFVmN#?8cyW zQ4>H$qKLXKc2QfyFgm@Pa$`_5v8Wy%ch4!f=Gr!7Msh0VA$5IJ^$b(Y3}*mIBSFLS zjqVmiUd8EQxs~GVjW;PHpi+qCnL!cWfngxTDj3y1f{m?59!JdzAuq^&(QwI|wqh>3 z+;=nwv}=hF#fJrSBffj>@XB0M#Z!&ra5dJ;tXt6@d#)}>*!uWMmwzK<8a@X(v$^bg zy)AQ?GuraWA)()aR^3wDT(#+-Yl~eJ*cj#2w@usd{^`5Kg`3?n66MtNyA1xbzgNpD z6B}re9&YJT*|&2}4Bj-^rw;$tXn2a|?+`=+2%~G5x%%?Ijllz97jWj5B12tgAO~u# z@}H1ajE$hSK}m$yz{>1YoA3#HeZ-#8mTgK9M9y6A3SmP;sXdUF^})!>rr7FIU5hm7 zt)tnLrYZ_a!xO;h%2O!I2=@DFp;VjC40lxxizzsa(#PG{G!Ibh!; zqJv{N`rq0JhZ#+{?H^>e{z+vN_#b3u6xV=C!7+g0u-iIiXo?rF0ER;>;)6i{323sR z`e7me??G??y@`#HvvZD?m7(rP!k2Vr28WkdtJy{)pP|hj$iGyk*7_qAejqFv_SA+1 zglSE$L~;DN@C>9@PT}@Jq*%mQLlocu!!Xdm4pW$b4Y~F~=&&MRx^vHCHv)m9-UxIy~ONLQl-w}Z^G5B}mm}VmcJ(Ck040Km z^ais%LteX4umg2>GT{YD6=L+rW`?M%Q|Qsa2us-{*T9LXK*uJ2WDb&BMPiqT3^`H& zWqrre>nw&Wr$8eg@-|ij#u})JBg<+sB)P2Is`Hq$LVc?c;~%p(U?C+DO8k@6r{8+j z+uDV6uC`Dt=5wQLR_M_!=CjZv`w^vAw#(KMjEmC0WM*0|r>8U5Oid<#x$*=tv6$@2 z1%5jW}YtyNbUY`3>G)EbTas9|0It=4F6QbJar!|EefU&#j#t}r!iZ>jZ= zr{}9Dyap;M>1>qnNnsT&mg5BK6;D`0w@3s=Tw&7bCUkW6e__Fk|EaS5b*~|2a=CKZ zU}(KwZ3h)riMOd9LR?yN@gbJX#f=Fs;m#iHmQfSi1v>f0wCXeJ>1a01iiXDo__uba z$lFe5vl!6}Rv<~)AQ`WtJn8&E8`YXA4Y*of?=i{3(kX)k3#lrk8@PEhq%HR2Ny-(K z2v02Y3F&NYs;F+0i2=1pwZXQrw`v8As$r9ZCp&C|{V3+5Hx8GgacfDRnBO2y*GUvt zo4Z$zM6l->QeMBUHhhW~m&ZW`oFwnFkkmxm;>+>{5oSiS9w}lxl9A5a6fRBRxIWFo zQA3$*%Nn7&n9*E25!->EqZcK)s)=N!S*^EE`=6dkgNI~|=?UwC-9SQHZ_J|BYqE7H z*8g6=7~&qD0HG2NcL1i;$H0P3Wcx;LM@guRi?26LU(rqi&WfNkVplloB-B;0}m<}+~i=cE-p+n|TXh3#Mm%z&Ug}vODE}%L+ zHA%v#J6ch<%NeHE11u3)70N?xHC;7wc(cJmICL%Q%Wk&kfpgt}00>ZeN|ju#3%dku z+)^b2o)VRe3J4wTX%C-2*%>TgOERJ20m}LdTwUhy4zp_67O-K?idqS%ObQV<41`&} zS^wk~t~6n+NkYaCz@;jconW^jbzryrap1P9#dilTMau)|W}!xT+GEJ+LYpJ4{(847 zDDt9Sz$XqgGZo7L{&WPnl!vzI&cv_9Si6?B^RR8$Nou-bA}5p+={YeWk-gu*MnDZQ zmNhQM2fM&fhix(S+^FK{39r{wZ@KIZ(jA3fB)1cF6_3Ts95IW~r_n&-kwqPpz>f@8 zGK=&QX;2s1V>_kj%6T-et~6?o*tUnLMYCvhlvGAL=7H-1CeCfdXwhS^oMM!{KK?dC zhUln`LSA;N*RmYyIQ0;5P)cl3YG67g`E15#9sL%u8@LSJqHe>w!y}`9-vS?LBx;*- z*V63hFOH1CV4ii=n`ZT_4O|M-LWkp}NVdLKoXH8@B6FvRaj9o%+_rHAj??0j-P?%6 z6zQdSHceLsU_|{y%rLW%Qb)pd2LTvO+jJTHiM$W>MS2;YEuHcLIF2AfxAI1EfvrXG z759!a@bmB|!ntvN!M*-$(TxY)AwFl=;Vr~rirwxTj~I>*QICvvnB3Uu zz$*=u8cEZ}iVyOQ&@D(3V@4`2)W#YH9}f%DjnLuoHlT-UX5UskHFnmpRQ56(UJk7t zI{qZ#(uk3#+UWbd9@kEt4<>t$lrEP${Y!0B7RimLI9nz%i6DDUB#H?2;h)1%9*)po z9Exy%c5gLYT?6F6LIf+^i085J(&9as64>!u2yB6&8Ju`B6UF6Bo&wGF_-Ana67(axgbJ{ET9OESa1Ez60$&?0iMij*+#C10&6I)I}3q1;r1d zu9|;A)$%Lm^!lu$UD#FRTYK%NaYuQ$|Dgo_ zfLdnPa?l@SBPjqI8Khh;GnwiLc$fLI2rNys8Yo1V~= zm0iOL`g%uq1{UvSgQfdgX#AftM!tV5X~1X}ETQthDTtc{Nj(2)S@YYeW55Hz8X5Uq zu;aa~;$|fc-n&BX)|^;&kYUIK{9G$2zH~8?!p=Z<-I~UP4--J5;DnA~>moS-o!j=l zw)K`DTYf#CaD!t%AVJ?XZclSMwbJeQZ3qMk?OJ$-H!bwMKH{+IQOc@4jdEq;cEfi$IlJ9ddzYtFQGcWZ83btpIhaB}+pK_;p}IEa8uR zIf`GqJJk^O`TRP@!HZTjzr|r`%s=Asmaw*k(9>~Yb@)JJ-~crGE86mOZ2Y(pn#*4) z=E#@wFU%my&4W?1VOw{tct~L1V7j)wS^s8KL)TG*e_MSy#(`T=KEXj2+P~mYUnhbx zkRDDe4tZj;ewqCwZ>EM-0LIPZJ}R=Ve4rG%kXpY^eLY5!wGX=)5>+Hx4f;Ir$5F@l zK3|HgMUqwIh)bo|zgzBNRGgbPWtXJ9;blHb;zw5HYau^@(tApI?*LlT%15dukY4`j z@q(^VDlL8s2^pU5qw(4mTIrdB?#f02GE`M<&DAI;G2NXg=oN)(z$3&*Px)5Npud0> zz1o1>@6O5vog|IqGF|mg!sA8iFJ(8hwet*OSBc_WWUUns+uRGDuYG>nQu@T&+NNHF zrLaXAq_fq88JjJ48*?)T`MPy`vGB+;3Z;Q3URgtASuvFJdUzT~{>?{7W02MZ;D>xH z4P%leLlhHR7W`3k0B;P;?b>>z!2xl%%;a-DTwW2_*a9_);iO0N1eIl)v5O=X_mQkk z8hNl8ikl=w;bI7V2QbEzT=<0k@R8D&A2`nu*TeW!yXwv`$DxQW6`-H(4y!gv;J}M3 z6vx>qJ(c>2V8rtLXb8bUV6%%6>qi!f%NMP*nk_y9>z&dGSa-p8&kBUNMRbWUVe%7= z<^A0dpR1H;fQib!W)>! z$Wb=={zAnzGh#B~(pK&_x^R%KtOAcavllH4T{C?T>ooObQ7~Vl`qj#cx`@jX zOjAp28XwL>xi61_q`}0V+aMO6_TwY9S$%U1WX_h%p^jg9d${Tm)h(6_kufQ@qt((I zX)2$a5X3({I}mE!6aBuc_Fxp7->?Wy6kX@SST0TkP!VI8-E#j3Y7EfK9aI7S+@m;_ z+pm~0H5h8=j63NLIO$EWD1FG0o1rL}=bE{HS(AZ%pyX50?8JhgqkUvSdAp&dlg};S zTbjdi4OQ9WnpJ$TI$gfW4n5g`-o6DZ#Zzi}M=&AIfZqe#B`lL%j&V}@{7?#esBh~7b9gkx}G zi}TJ2Orz~&E8dvGy>TQM5|)hV(hW}oLRW()lAf>WPZ>w&Ft)5b6QND{-3VSJsPS!4&eILoa8y> zF^rq?+#14qbZA2ADAAf^IW3_{LsA(@Lzd}wiX4wxztrw}ZSCx8dXP{#r@BOmN>tl( zjWJ9zCMIpt1N)mB+Pn9k-}n2Q&-Z)popbN~4c*<4qQA*Qwdpx=`=ar`MyjA)=TPVj(d-n08Z;$`OZaF0^yEZ&JDd+g%Zn=l$&+uh@K{Pw$6<)HL^Gt>_MJCo8fd|H80eCo5~iE+~0ScyWCJ* z!+v&WM_=34an9!x+DU;UjWraLi%E)4b$r$(3B9xtb^*Gg1;hEmqH>TE>f%mBYQN8g`;?eizdzJqapW8M zn0Iws_;WqzB4Jj?b(+qAo&8K$EMY)B#cE(R6LzE-A<+;D6;2>e6ILnQu+*CHdRJ6^ z`4q*gd{CBZ>JZ`lIfyrh3kTe=(gWvToJ1L^3-n+?Av^HRxS#0CfiG z7-h-VX;gjV!M>BQE({xF0p~DMEgD=3B%4UFzQG3S4za+E$VpWfh7UObtr${Ow$6vd z5FPuv)&klHyc#S}u`o*OI)yRX^@W)|+c$+5oxCRj@}&%Hx;+cARurBufTy)> zpjj6Svp-T84nJaaovD+G@cP5(M=RLg&A`+>VFBnNB2X7Tdx}7# z2tS)mLPumYXeYD5)ZHzoPzco)J#8)&kdrqFT4H2N0rHltjfz?*(8{AEq>|au$ns*i zu*V4ed<;$cL17Oaqm+J9EZ3eOE!%qRX=Kd|oIsX)O36u&UOS9Zc0jRAItd%x7ejHc zE%yJk?-VD(Q$z^zAg_Uv=A9zYD8dhy!w&W`Nc7TaWRe$_$&J7vG3j2N+m*|WX=I+P z;H443&rQzTVq{hV{b^UwyX;Ky$gd=C;Ki!BYOfe2KurOgsz}gjwK)k=0@M_6yas`m zFtN`GY;1;#@I~-W9}DpABheC?zFG>hAHbkjF(Bd*L>*Sf>jP*g1+M;bxN7*L*VE~- GTKgBj+ffbx diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e750102e0..37aef8d3f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle.kts b/settings.gradle.kts index c424d90e3..caa828904 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,6 +1,16 @@ println("Running with Java ${System.getProperty("java.version")} on JVM: ${System.getProperty("java.vendor")} ${System.getProperty("java.vm.version")} (Architecture: ${System.getProperty("os.arch")})") +pluginManagement { + repositories { + gradlePluginPortal() + } +} + +plugins { + id("org.gradle.toolchains.foojay-resolver-convention").version("0.5.0") +} + buildscript { repositories { // These repositories are only for Gradle plugins, put any other repositories in the repository block further below @@ -45,5 +55,7 @@ buildscript { classpath("org.spongepowered:mixingradle:${mixingradle_version}") classpath(group = "org.parchmentmc", name = "librarian", version = "1.+") + + classpath(group = "org.gradle.toolchains", name = "foojay-resolver", version = "0.5.0") } } From 817630cb79179ae7bea3e67727e5d147c7a1f5c6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 8 Jun 2023 11:07:00 +0700 Subject: [PATCH 0574/1199] Update mods.toml to reflect new mc version --- src/main/resources/META-INF/mods.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index bcedd782e..b7f98f00f 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -6,7 +6,7 @@ # The name of the mod loader type to load - for regular FML @Mod mods it should be javafml modLoader="javafml" #mandatory # A version range to match for said mod loader - for regular FML @Mod it will be the forge version -loaderVersion="[43,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. +loaderVersion="[46,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. # The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties. # Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here. license="2 Clause BSD" @@ -43,7 +43,7 @@ Matter. Energy. Combined. # Does this dependency have to exist - if not, ordering below must be specified mandatory=true #mandatory # The version range of the dependency - versionRange="[43.1.32,)" #mandatory + versionRange="[46.0.1,)" #mandatory # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory ordering="NONE" # Side this dependency is applied on - BOTH, CLIENT or SERVER @@ -53,6 +53,6 @@ Matter. Energy. Combined. modId="minecraft" mandatory=true # This version range declares a minimum of the current minecraft version up to but not including the next major version - versionRange="[1.19.2,1.20)" + versionRange="[1.20,1.21)" ordering="NONE" side="BOTH" From 8a0cfaa90d56d063280c3037c98f8cb80fe2a007 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 8 Jun 2023 13:51:04 +0700 Subject: [PATCH 0575/1199] Some 1.20 portings --- .../otm/client/render/DynamicBufferSource.kt | 22 ++++---- .../dbotthepony/mc/otm/client/render/Ext.kt | 53 ++++++++++++++++--- .../otm/client/screen/panels/EditablePanel.kt | 31 +++++------ .../screen/panels/EntityRendererPanel.kt | 9 ++-- .../mc/otm/client/screen/panels/FramePanel.kt | 10 ++-- .../mc/otm/client/screen/panels/Label.kt | 42 +++++++-------- .../otm/client/screen/panels/Panel2Widget.kt | 8 +-- 7 files changed, 108 insertions(+), 67 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt index 0e0cfcf88..d8b1c49c4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.client.render import com.google.common.collect.ImmutableList import com.mojang.blaze3d.vertex.BufferBuilder import com.mojang.blaze3d.vertex.VertexConsumer +import com.mojang.blaze3d.vertex.VertexSorting import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.ReferenceArraySet import net.minecraft.client.renderer.MultiBufferSource @@ -62,7 +63,7 @@ private fun equals(existing: ImmutableList?, types: ImmutableList= 0) { "Invalid minimal buffer size $minimalInitialBufferSize" } require(maximalInitialBufferSize >= minimalInitialBufferSize) { "Maximal buffer size $maximalInitialBufferSize must be greater or equal to minimal buffer size $minimalInitialBufferSize" } @@ -142,13 +143,6 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit it.add(next) next = State(RenderType.waterMask(), ImmutableList.of(next.type), true, false) it.add(next) - - // TODO - // it.add(State(AtlasMatterySprite.renderTypeDepth, ImmutableList.of(RenderType.waterMask()), true)) - // TODO - // it.add(State(AtlasMatterySprite.renderTypeNoDepth, ImmutableList.of(RenderType.waterMask()), true)) - // TODO - // it.add(State(AtlasMatterySprite.renderTypeWorld, ImmutableList.of(Sheets.signSheet()), true)) } private fun determineHeight(input: State, seen: MutableSet) { @@ -356,7 +350,7 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit for (state in bufferList) { if (state.dirty) { state.dirty = false - state.type.end(state.builder, 0, 0, 0) + state.type.end(state.builder, vertexSorting) } } } @@ -366,7 +360,7 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit if (state.dirty) { state.dirty = false - type.end(state.builder, 0, 0, 0) + type.end(state.builder, vertexSorting) } } @@ -375,7 +369,7 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit if (state.dirty) { state.dirty = false - type.end(state.builder, 0, 0, 0) + type.end(state.builder, vertexSorting) } for (ustate in state.dependants) { @@ -386,7 +380,7 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit private fun endBatchChain(state: State) { if (state.dirty) { state.dirty = false - state.type.end(state.builder, 0, 0, 0) + state.type.end(state.builder, vertexSorting) } for (ustate in state.dependants) { @@ -395,7 +389,9 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit } companion object { - val GUI = DynamicBufferSource(maximalInitialBufferSize = 2 shl 8) + @JvmField + val GUI = DynamicBufferSource(maximalInitialBufferSize = 2 shl 8, vertexSorting = VertexSorting.ORTHOGRAPHIC_Z) + @JvmField val WORLD = DynamicBufferSource(minimalInitialBufferSize = 2 shl 12) /** diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt index aaec7ab29..712269a62 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt @@ -4,6 +4,7 @@ import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.Tesselator import com.mojang.blaze3d.vertex.VertexConsumer import net.minecraft.client.gui.Font +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.core.Vec3i import net.minecraft.network.chat.Component @@ -104,12 +105,7 @@ private fun Font.drawScaledDuckTyped(poseStack: PoseStack, buffer: MultiBufferSo } private fun Font.drawDuckTyped(poseStack: PoseStack, text: Any, x: Float, y: Float, color: Int): Int { - return when (text) { - is Component -> draw(poseStack, text, x, y, color) - is String -> draw(poseStack, text, x, y, color) - is FormattedCharSequence -> draw(poseStack, text, x, y, color) - else -> throw ClassCastException(text::class.qualifiedName) - } + return drawDuckTyped(poseStack, DynamicBufferSource.GUI, text, x, y, color) } private fun Font.drawDuckTyped( @@ -240,6 +236,35 @@ private fun Font.drawScaledAlignedDuckTyped( } } +private fun GuiGraphics.drawScaledAlignedDuckTyped( + poseStack: PoseStack, + buffer: MultiBufferSource, + text: Any, + scale: Float, + align: TextAlign, + x: Float, + y: Float, + color: Int, + drawShadow: Boolean = false, + displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, + packedLightCoords: Int = 15728880, + effectColor: Int = 0 +): Int { + return when (align) { + TextAlign.TOP_LEFT -> drawScaledDuckTyped(poseStack, buffer, text, scale, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.TOP_CENTER -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale / 2f), y, color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.TOP_RIGHT -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale), y, color, drawShadow, displayMode, packedLightCoords, effectColor) + + TextAlign.CENTER_LEFT -> drawScaledDuckTyped(poseStack, buffer, text, scale, x, (y - lineHeight / 2f * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.CENTER_CENTER -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale / 2f), (y - lineHeight * scale / 2f), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.CENTER_RIGHT -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale), (y - lineHeight * scale / 2f), color, drawShadow, displayMode, packedLightCoords, effectColor) + + TextAlign.BOTTOM_LEFT -> drawScaledDuckTyped(poseStack, buffer, text, scale, x, (y - lineHeight * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.BOTTOM_CENTER -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale / 2f), (y - lineHeight * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.BOTTOM_RIGHT -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale), (y - lineHeight * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) + } +} + fun Font.drawAligned(poseStack: PoseStack, text: String, align: TextAlign, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(poseStack, text, align, x, y, color) fun Font.drawAligned(poseStack: PoseStack, text: Component, align: TextAlign, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(poseStack, text, align, x, y, color) fun Font.drawAligned(poseStack: PoseStack, text: FormattedCharSequence, align: TextAlign, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(poseStack, text, align, x, y, color) @@ -271,3 +296,19 @@ fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, scale: Float, align: TextAlign, x: Float, y: Float, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, scale: Float, align: TextAlign, x: Float, y: Float, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, scale: Float, align: TextAlign, x: Float, y: Float, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) + +fun GuiGraphics.drawAligned(font: Font, text: String, align: TextAlign, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(poseStack, text, align, x, y, color) +fun GuiGraphics.drawAligned(font: Font, text: Component, align: TextAlign, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(poseStack, text, align, x, y, color) +fun GuiGraphics.drawAligned(font: Font, text: FormattedCharSequence, align: TextAlign, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(poseStack, text, align, x, y, color) + +fun GuiGraphics.drawAligned(font: Font, text: String, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawAligned(poseStack, text, align, x, y, color.toInt()) +fun GuiGraphics.drawAligned(font: Font, text: Component, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawAligned(poseStack, text, align, x, y, color.toInt()) +fun GuiGraphics.drawAligned(font: Font, text: FormattedCharSequence, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawAligned(poseStack, text, align, x, y, color.toInt()) + +fun GuiGraphics.drawScaledAligned(font: Font, text: String, scale: Float, align: TextAlign, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(poseStack, text, scale, align, x, y, color) +fun GuiGraphics.drawScaledAligned(font: Font, text: Component, scale: Float, align: TextAlign, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(poseStack, text, scale, align, x, y, color) +fun GuiGraphics.drawScaledAligned(font: Font, text: FormattedCharSequence, scale: Float, align: TextAlign, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(poseStack, text, scale, align, x, y, color) + +fun GuiGraphics.drawScaledAligned(font: Font, text: String, scale: Float, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(poseStack, text, scale, align, x, y, color.toInt()) +fun GuiGraphics.drawScaledAligned(font: Font, text: Component, scale: Float, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(poseStack, text, scale, align, x, y, color.toInt()) +fun GuiGraphics.drawScaledAligned(font: Font, text: FormattedCharSequence, scale: Float, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(poseStack, text, scale, align, x, y, color.toInt()) 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 2fd4d6839..abd5f9717 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 @@ -6,6 +6,7 @@ import com.mojang.blaze3d.vertex.PoseStack import it.unimi.dsi.fastutil.objects.ReferenceArraySet import net.minecraft.client.gui.ComponentPath import net.minecraft.client.gui.Font +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.components.events.GuiEventListener import net.minecraft.client.gui.navigation.FocusNavigationEvent import net.minecraft.client.gui.navigation.ScreenRectangle @@ -697,8 +698,8 @@ open class EditablePanel @JvmOverloads constructor( } } - protected open fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {} - protected open fun innerRenderTooltips(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + protected open fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {} + protected open fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { return false } @@ -742,11 +743,13 @@ open class EditablePanel @JvmOverloads constructor( } } - fun render(poseStack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + fun render(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (!isVisible()) { return } + val poseStack = graphics.pose() + performLayoutIfNeeded() val parent = this.parent @@ -789,7 +792,7 @@ open class EditablePanel @JvmOverloads constructor( poseStack.pushPose() poseStack.translate(absoluteX.toDouble(), absoluteY.toDouble(), 10.0) RenderSystem.setShaderColor(1f, 1f, 1f, if (isFlashFrameRecursive) 0.5f else 1f) - innerRender(poseStack, mouseX, mouseY, partialTick) + innerRender(graphics, mouseX, mouseY, partialTick) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) poseStack.popPose() } @@ -798,7 +801,7 @@ open class EditablePanel @JvmOverloads constructor( child.absoluteX = absoluteX + child.x + xOffset child.absoluteY = absoluteY + child.y + yOffset - child.render(poseStack, mouseX, mouseY, partialTick) + child.render(graphics, mouseX, mouseY, partialTick) } if (scissor) { @@ -921,7 +924,7 @@ open class EditablePanel @JvmOverloads constructor( return null to ItemStack.EMPTY } - fun renderTooltips(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + fun renderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { if (!isVisible()) { return false } @@ -933,12 +936,12 @@ open class EditablePanel @JvmOverloads constructor( } for (child in visibleChildrenInternal) { - if (child.renderTooltips(stack, mouseX, mouseY, partialTick)) { + if (child.renderTooltips(graphics, mouseX, mouseY, partialTick)) { return true } } - if (innerRenderTooltips(stack, mouseX, mouseY, partialTick)) { + if (innerRenderTooltips(graphics, mouseX, mouseY, partialTick)) { return true } @@ -947,22 +950,20 @@ open class EditablePanel @JvmOverloads constructor( val tooltipList = tooltipList if (tooltip != null) { - screen.renderComponentTooltip( - stack, + graphics.renderComponentTooltip( + font, listOf(tooltip), mouseX.toInt(), - mouseY.toInt(), - font + mouseY.toInt() ) return true } else if (tooltipList != null) { - screen.renderComponentTooltip( - stack, + graphics.renderComponentTooltip( + font, tooltipList, mouseX.toInt(), mouseY.toInt(), - font ) return true diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt index b25b00b2d..f28649596 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen import net.minecraft.client.gui.screens.inventory.InventoryScreen @@ -89,7 +90,7 @@ class EntityRendererPanel @JvmOverloads constructor( } } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (entity.isDeadOrDying) { return } @@ -98,7 +99,7 @@ class EntityRendererPanel @JvmOverloads constructor( val renderY = (height * 0.9f).toInt() InventoryScreen.renderEntityInInventoryFollowsMouse( - stack, + graphics, renderX, renderY, renderScale, @@ -123,8 +124,8 @@ class EntityRendererPanel @JvmOverloads constructor( } } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - ExoPackInventoryScreen.ENTITY_RECTANGLE.render(stack) + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + ExoPackInventoryScreen.ENTITY_RECTANGLE.render(graphics.pose()) } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index 52d3bd56a..7d87a340b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.narration.NarratableEntry import net.minecraft.client.gui.narration.NarratableEntry.NarrationPriority import net.minecraft.client.gui.narration.NarrationElementOutput @@ -50,7 +51,8 @@ open class FramePanel( } } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + val stack = graphics.pose() val width: Float val height: Float @@ -194,13 +196,13 @@ open class FramePanel( return super.keyPressedInternal(key, scancode, mods) } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - RECTANGLE.render(stack, width = width, height = height) + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + RECTANGLE.render(graphics.pose(), width = width, height = height) // title val title = title ?: return RenderSystem.depthFunc(GL30.GL_ALWAYS) - font.draw(stack, title, 8f, 5f, 4210752) + font.drawAligned(graphics.pose(), title, TextAlign.TOP_LEFT, 8f, 5f, 4210752) RenderSystem.depthFunc(GL30.GL_ALWAYS) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt index 056cb7d36..cb899da0c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt @@ -1,6 +1,6 @@ package ru.dbotthepony.mc.otm.client.screen.panels -import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.client.render.TextAlign @@ -31,33 +31,33 @@ open class Label @JvmOverloads constructor( var color = RGBAColor.SLATE_GRAY var align = TextAlign.TOP_LEFT - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - clearDepth(stack) + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + clearDepth(graphics.pose()) if (shadow) { when (align) { - TextAlign.TOP_LEFT -> font.drawAligned(stack, text, align, shadowX, shadowY, shadowColor.toInt()) - TextAlign.TOP_CENTER -> font.drawAligned(stack, text, align, shadowX + width / 2f, shadowY, shadowColor.toInt()) - TextAlign.TOP_RIGHT -> font.drawAligned(stack, text, align, shadowX + width, shadowY, shadowColor.toInt()) - TextAlign.CENTER_LEFT -> font.drawAligned(stack, text, align, shadowX, height / 2f + shadowY, shadowColor.toInt()) - TextAlign.CENTER_CENTER -> font.drawAligned(stack, text, align, shadowX + width / 2f, height / 2f + shadowY, shadowColor.toInt()) - TextAlign.CENTER_RIGHT -> font.drawAligned(stack, text, align, shadowX + width, height / 2f + shadowY, shadowColor.toInt()) - TextAlign.BOTTOM_LEFT -> font.drawAligned(stack, text, align, shadowX, height + shadowY, shadowColor.toInt()) - TextAlign.BOTTOM_CENTER -> font.drawAligned(stack, text, align, shadowX + width / 2f, height + shadowY, shadowColor.toInt()) - TextAlign.BOTTOM_RIGHT -> font.drawAligned(stack, text, align, shadowX + width, height + shadowY, shadowColor.toInt()) + TextAlign.TOP_LEFT -> font.drawAligned(graphics.pose(), text, align, shadowX, shadowY, shadowColor.toInt()) + TextAlign.TOP_CENTER -> font.drawAligned(graphics.pose(), text, align, shadowX + width / 2f, shadowY, shadowColor.toInt()) + TextAlign.TOP_RIGHT -> font.drawAligned(graphics.pose(), text, align, shadowX + width, shadowY, shadowColor.toInt()) + TextAlign.CENTER_LEFT -> font.drawAligned(graphics.pose(), text, align, shadowX, height / 2f + shadowY, shadowColor.toInt()) + TextAlign.CENTER_CENTER -> font.drawAligned(graphics.pose(), text, align, shadowX + width / 2f, height / 2f + shadowY, shadowColor.toInt()) + TextAlign.CENTER_RIGHT -> font.drawAligned(graphics.pose(), text, align, shadowX + width, height / 2f + shadowY, shadowColor.toInt()) + TextAlign.BOTTOM_LEFT -> font.drawAligned(graphics.pose(), text, align, shadowX, height + shadowY, shadowColor.toInt()) + TextAlign.BOTTOM_CENTER -> font.drawAligned(graphics.pose(), text, align, shadowX + width / 2f, height + shadowY, shadowColor.toInt()) + TextAlign.BOTTOM_RIGHT -> font.drawAligned(graphics.pose(), text, align, shadowX + width, height + shadowY, shadowColor.toInt()) } } when (align) { - TextAlign.TOP_LEFT -> font.drawAligned(stack, text, align, 0f, 0f, color.toInt()) - TextAlign.TOP_CENTER -> font.drawAligned(stack, text, align, width / 2f, 0f, color.toInt()) - TextAlign.TOP_RIGHT -> font.drawAligned(stack, text, align, width - (if (shadow) shadowX else 0f), 0f, color.toInt()) - TextAlign.CENTER_LEFT -> font.drawAligned(stack, text, align, 0f, height / 2f, color.toInt()) - TextAlign.CENTER_CENTER -> font.drawAligned(stack, text, align, width / 2f, height / 2f, color.toInt()) - TextAlign.CENTER_RIGHT -> font.drawAligned(stack, text, align, width - (if (shadow) shadowX else 0f), height / 2f, color.toInt()) - TextAlign.BOTTOM_LEFT -> font.drawAligned(stack, text, align, 0f, height, color.toInt()) - TextAlign.BOTTOM_CENTER -> font.drawAligned(stack, text, align, width / 2f, height, color.toInt()) - TextAlign.BOTTOM_RIGHT -> font.drawAligned(stack, text, align, width - (if (shadow) shadowX else 0f), height, color.toInt()) + TextAlign.TOP_LEFT -> font.drawAligned(graphics.pose(), text, align, 0f, 0f, color.toInt()) + TextAlign.TOP_CENTER -> font.drawAligned(graphics.pose(), text, align, width / 2f, 0f, color.toInt()) + TextAlign.TOP_RIGHT -> font.drawAligned(graphics.pose(), text, align, width - (if (shadow) shadowX else 0f), 0f, color.toInt()) + TextAlign.CENTER_LEFT -> font.drawAligned(graphics.pose(), text, align, 0f, height / 2f, color.toInt()) + TextAlign.CENTER_CENTER -> font.drawAligned(graphics.pose(), text, align, width / 2f, height / 2f, color.toInt()) + TextAlign.CENTER_RIGHT -> font.drawAligned(graphics.pose(), text, align, width - (if (shadow) shadowX else 0f), height / 2f, color.toInt()) + TextAlign.BOTTOM_LEFT -> font.drawAligned(graphics.pose(), text, align, 0f, height, color.toInt()) + TextAlign.BOTTOM_CENTER -> font.drawAligned(graphics.pose(), text, align, width / 2f, height, color.toInt()) + TextAlign.BOTTOM_RIGHT -> font.drawAligned(graphics.pose(), text, align, width - (if (shadow) shadowX else 0f), height, color.toInt()) } } 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 778b52fe1..7610be9bd 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 @@ -1,6 +1,6 @@ package ru.dbotthepony.mc.otm.client.screen.panels -import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.components.Renderable import net.minecraft.client.gui.components.events.GuiEventListener import net.minecraft.client.gui.screens.Screen @@ -13,15 +13,15 @@ class Panel2Widget>( require(panel.parent == null) { "Widget wrapped panels can't have a parent ($panel has parent ${panel.parent})" } } - override fun render(poseStack: PoseStack, mouseX: Int, mouseY: Int, partialTick: Float) { + override fun render(graphics: GuiGraphics, mouseX: Int, mouseY: Int, partialTick: Float) { panel.tick() val xFloat = mouseX.toFloat() val yFloat = mouseY.toFloat() panel.tickHover(xFloat, yFloat) - panel.render(poseStack, xFloat, yFloat, partialTick) - panel.renderTooltips(poseStack, xFloat, yFloat, partialTick) + panel.render(graphics, xFloat, yFloat, partialTick) + panel.renderTooltips(graphics, xFloat, yFloat, partialTick) } override fun mouseMoved(mouseX: Double, mouseY: Double) { From 16b28a1d2d5f7618fb68d39ae2a36f16abb42da9 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Thu, 8 Jun 2023 15:41:18 +0300 Subject: [PATCH 0576/1199] most *compile* errors resolved for 1.20 only damage triggers remain and whatever font funcs in Ext.kt --- .../otm/android/AndroidSwitchableFeature.kt | 3 +- .../android/feature/EnderTeleporterFeature.kt | 37 ++++---- .../android/feature/ExtendedReachFeature.kt | 8 +- .../otm/android/feature/ItemMagnetFeature.kt | 9 +- .../otm/android/feature/JumpBoostFeature.kt | 11 +-- .../otm/android/feature/NightVisionFeature.kt | 5 +- .../feature/PhantomAttractorFeature.kt | 5 +- .../otm/android/feature/ShockwaveFeature.kt | 31 +++---- .../otm/android/feature/StepAssistFeature.kt | 5 +- .../mc/otm/block/BlackHoleBlock.kt | 8 +- .../ru/dbotthepony/mc/otm/block/Cables.kt | 8 +- .../mc/otm/block/ExplosionDebuggerBlock.kt | 6 +- .../dbotthepony/mc/otm/block/MatteryBlock.kt | 5 +- .../otm/block/decorative/CargoCrateBlock.kt | 6 +- .../mc/otm/block/decorative/EngineBlock.kt | 5 +- .../mc/otm/block/decorative/LaboratoryLamp.kt | 11 +-- .../decorative/TritaniumPressurePlate.kt | 4 +- .../decorative/CargoCrateBlockEntity.kt | 10 +-- .../entity/storage/ItemMonitorBlockEntity.kt | 3 +- .../entity/tech/PlatePressBlockEntity.kt | 2 +- .../mc/otm/block/tech/EnergyServoBlock.kt | 6 +- .../block/tech/GravitationStabilizerBlock.kt | 14 +-- .../otm/block/tech/PhantomAttractorBlock.kt | 6 +- .../otm/capability/MatteryPlayerCapability.kt | 30 +++---- .../mc/otm/client/AndroidAbilityKeyMapping.kt | 6 +- .../mc/otm/client/AndroidMenuKeyMapping.kt | 27 +++--- .../mc/otm/client/ClientEventHandler.kt | 2 +- .../dbotthepony/mc/otm/client/MatteryGUI.kt | 38 +++----- .../client/render/AbstractMatterySprite.kt | 90 +++++++++++++++++-- .../mc/otm/client/render/GlitchRenderer.kt | 9 +- .../mc/otm/client/render/RenderHelper.kt | 64 +++++++++++++ .../render/StretchingRectangleElement.kt | 10 +++ .../client/screen/ExoPackInventoryScreen.kt | 5 +- .../mc/otm/client/screen/MatteryScreen.kt | 34 ++++--- .../otm/client/screen/panels/EditablePanel.kt | 4 +- .../client/screen/panels/EffectListPanel.kt | 23 ++--- .../screen/panels/EntityRendererPanel.kt | 2 +- .../mc/otm/client/screen/panels/FramePanel.kt | 26 +++--- .../mc/otm/client/screen/panels/Label.kt | 20 ++--- .../otm/client/screen/panels/Widget2Panel.kt | 5 +- .../button/BooleanRectangleButtonPanel.kt | 15 ++-- .../screen/panels/button/ButtonPanel.kt | 17 ++-- .../screen/panels/button/CheckBoxPanel.kt | 23 ++--- .../panels/button/EnumRectangleButtonPanel.kt | 15 ++-- .../button/LargeRectangleButtonPanel.kt | 9 +- .../panels/button/RectangleButtonPanel.kt | 15 ++-- .../button/SmallRectangleButtonPanel.kt | 9 +- .../screen/panels/input/TextInputPanel.kt | 42 ++++----- .../screen/panels/slot/AbstractSlotPanel.kt | 31 +++---- .../client/screen/panels/slot/SlotPanel.kt | 21 +++-- .../panels/slot/UserFilteredSlotPanel.kt | 27 +++--- .../panels/util/AnalogScrollBarPanel.kt | 33 +++---- .../screen/panels/util/BackgroundPanel.kt | 5 +- .../panels/util/DiscreteScrollBarPanel.kt | 33 +++---- .../client/screen/panels/util/SpritePanel.kt | 5 +- .../screen/storage/DriveViewerScreen.kt | 7 +- .../screen/storage/ItemMonitorScreen.kt | 16 ++-- .../screen/tech/AndroidStationScreen.kt | 38 ++++---- .../client/screen/tech/EnergyServoScreen.kt | 9 +- .../screen/tech/EssenceStorageScreen.kt | 7 +- .../client/screen/widget/FluidGaugePanel.kt | 11 +-- .../widget/HorizontalPowerGaugePanel.kt | 27 +++--- .../client/screen/widget/MatterGaugePanel.kt | 11 +-- .../client/screen/widget/PatternGaugePanel.kt | 11 +-- .../client/screen/widget/PowerGaugePanel.kt | 15 ++-- .../screen/widget/ProgressGaugePanel.kt | 15 ++-- .../mc/otm/compat/cos/CosmeticArmorCompat.kt | 13 +-- .../mc/otm/entity/MinecartCargoCrate.kt | 6 +- .../mc/otm/entity/PlasmaProjectile.kt | 18 ++-- .../mc/otm/item/EssenceServoItem.kt | 4 +- .../mc/otm/item/FluidCapsuleItem.kt | 38 ++++---- .../mc/otm/item/matter/MatterDustItem.kt | 6 +- .../mc/otm/item/tool/ExplosiveHammerItem.kt | 12 +-- .../mc/otm/item/tool/MatteryAxeItem.kt | 4 +- .../mc/otm/item/weapon/AbstractWeaponItem.kt | 4 +- .../mc/otm/item/weapon/EnergySwordItem.kt | 35 +++----- .../mc/otm/item/weapon/PlasmaRifleItem.kt | 8 +- .../mc/otm/item/weapon/PlasmaWeaponItem.kt | 2 +- .../mc/otm/item/weapon/VelocityCalculation.kt | 2 +- .../mc/otm/matter/MatterManager.kt | 7 +- .../mc/otm/menu/ExoPackInventoryMenu.kt | 8 +- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 2 +- .../mc/otm/menu/matter/MatterPanelMenu.kt | 2 +- .../mc/otm/network/WorldNetworkChannel.kt | 2 +- .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 71 +++++++++------ .../mc/otm/registry/MCreativeTabs.kt | 45 +++++----- .../dbotthepony/mc/otm/registry/MRegistry.kt | 33 ++++--- .../mc/otm/triggers/AndroidBatteryTrigger.kt | 11 +-- .../mc/otm/triggers/AndroidResearchTrigger.kt | 10 +-- .../mc/otm/triggers/AndroidStatusTriggers.kt | 21 ++--- .../otm/triggers/AndroidTravelUnderwater.kt | 10 +-- .../mc/otm/triggers/BlackHoleTrigger.kt | 6 +- .../EnderTeleporterFallDeathTrigger.kt | 6 +- .../otm/triggers/FallDampenersSaveTrigger.kt | 6 +- .../mc/otm/triggers/NanobotsArmorTrigger.kt | 10 +-- .../mc/otm/triggers/ShockwaveTrigger.kt | 6 +- .../resources/META-INF/accesstransformer.cfg | 2 +- 97 files changed, 820 insertions(+), 660 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt index 8b1651eba..bc52c0b0e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.android import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.gui.GuiGraphics import net.minecraft.nbt.CompoundTag import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.core.nbt.set @@ -39,7 +40,7 @@ abstract class AndroidSwitchableFeature(type: AndroidFeatureType<*>, android: Ma // TODO: PoseStack is stripped from server dist // but it doesn't seem to cause issues? - abstract fun renderIcon(stack: PoseStack, x: Float, y: Float, width: Float, height: Float) + abstract fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float) override fun serializeNBT(): CompoundTag { return super.serializeNBT().also { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt index 69cc9f4ab..b8a30b8f5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt @@ -4,6 +4,7 @@ import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.ChatFormatting import net.minecraft.client.Camera +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.renderer.LevelRenderer import net.minecraft.core.BlockPos import net.minecraft.core.Direction @@ -74,29 +75,29 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv } private fun canSupportPlayer(blockPos: BlockPos): Boolean { - val state = ply.level.getBlockState(blockPos) + val state = ply.level().getBlockState(blockPos) if (state.`is`(BlockTags.CLIMBABLE)) { return true // ladders can always support player } - val shape = state.getCollisionShape(ply.level, blockPos, CollisionContext.of(ply)) + val shape = state.getCollisionShape(ply.level(), blockPos, CollisionContext.of(ply)) return Shapes.joinIsNotEmpty(shape, SHAPE_CHECK_SUPPORT_PLAYER, BooleanOp.AND) } private fun isWall(blockPos: BlockPos): Boolean { - val shape = ply.level.getBlockState(blockPos).getCollisionShape(ply.level, blockPos, CollisionContext.of(ply)) + val shape = ply.level().getBlockState(blockPos).getCollisionShape(ply.level(), blockPos, CollisionContext.of(ply)) return Shapes.joinIsNotEmpty(shape, SHAPE_CHECK_NOT_FENCE, BooleanOp.AND) } private fun isAirGap(blockPos: BlockPos): Boolean { - val state = ply.level.getBlockState(blockPos) + val state = ply.level().getBlockState(blockPos) if (state.isAir) { return true } - val shape = state.getCollisionShape(ply.level, blockPos, CollisionContext.of(ply)) + val shape = state.getCollisionShape(ply.level(), blockPos, CollisionContext.of(ply)) return shape.isEmpty || !Shapes.joinIsNotEmpty(shape, SHAPE_CHECK_SUPPORT_PLAYER, BooleanOp.AND) } @@ -143,7 +144,7 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv val headPosition = ply.eyePosition val aimVector = ply.getViewVector(1f) - val result = ply.level.clip(ClipContext( + val result = ply.level().clip(ClipContext( headPosition, headPosition + aimVector * (AndroidConfig.EnderTeleporter.MAX_DISTANCE * 2.0), ClipContext.Block.COLLIDER, @@ -202,14 +203,14 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv val searchDirection: IntProgression if (ply.isShiftKeyDown) { - searchDirection = -1 downTo ply.level.minBuildHeight - ply.level.maxBuildHeight + searchDirection = -1 downTo ply.level().minBuildHeight - ply.level().maxBuildHeight } else { - searchDirection = (if (ply.level.getBlockState(result.blockPos).`is`(BlockTags.CLIMBABLE)) -1 else 0) .. ply.level.maxBuildHeight - ply.level.minBuildHeight + searchDirection = (if (ply.level().getBlockState(result.blockPos).`is`(BlockTags.CLIMBABLE)) -1 else 0) .. ply.level().maxBuildHeight - ply.level().minBuildHeight } for (y in searchDirection) { val pos = BlockPos(result.blockPos.x, result.blockPos.y + y + 1, result.blockPos.z) - val state = ply.level.getBlockState(pos) + val state = ply.level().getBlockState(pos) if (state.`is`(Blocks.BEDROCK)) { // Can't phase through bedrock @@ -261,9 +262,9 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv phasedBlocks = 0 phasedBlocksList.clear() - for (y in 0 downTo ply.level.maxBuildHeight - ply.level.minBuildHeight) { + for (y in 0 downTo ply.level().maxBuildHeight - ply.level().minBuildHeight) { val pos = BlockPos(result.blockPos.x, result.blockPos.y + y, result.blockPos.z) - val state = ply.level.getBlockState(pos) + val state = ply.level().getBlockState(pos) if (state.`is`(Blocks.BEDROCK)) { // Can't phase through bedrock @@ -305,7 +306,7 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv val event = ForgeEventFactory.onEnderTeleport(ply, blockPos.x + 0.5, blockPos.y.toDouble(), blockPos.z + 0.5) if (event.isCanceled) { - (ply as ServerPlayer).connection.send(ClientboundSoundEntityPacket(SoundEvents.ITEM_BREAK.holder, SoundSource.PLAYERS, ply, 0.3f, 0.5f, ply.level.random.nextLong())) + (ply as ServerPlayer).connection.send(ClientboundSoundEntityPacket(SoundEvents.ITEM_BREAK.holder, SoundSource.PLAYERS, ply, 0.3f, 0.5f, ply.level().random.nextLong())) return false } @@ -313,9 +314,9 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv lastTeleport = ply.server!!.tickCount android.androidEnergy.extractEnergy(AndroidConfig.EnderTeleporter.ENERGY_COST, false) - ply.level.playSound(null, ply, SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 0.3f, 0.8f + ply.level.random.nextFloat() * 0.4f) + ply.level().playSound(null, ply, SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 0.3f, 0.8f + ply.level().random.nextFloat() * 0.4f) ply.teleportTo(event.targetX, event.targetY, event.targetZ) - ply.level.playSound(null, ply, SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 1f, 0.8f + ply.level.random.nextFloat() * 0.4f) + ply.level().playSound(null, ply, SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 1f, 0.8f + ply.level().random.nextFloat() * 0.4f) ply.deltaMovement = Vector(0.0, 0.0, 0.0) ply.resetFallDistance() @@ -355,8 +356,8 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv val builder = source.getBuffer(linesIgnoreZRenderType) for (blockPos in phasedBlocks) { - val blockState = ply.level.getBlockState(blockPos) - val shape = blockState.getShape(ply.level, blockPos, collisionContext) + val blockState = ply.level().getBlockState(blockPos) + val shape = blockState.getShape(ply.level(), blockPos, collisionContext) LevelRenderer.renderShape( poseStack, @@ -376,12 +377,12 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv } } - override fun renderIcon(stack: PoseStack, x: Float, y: Float, width: Float, height: Float) { + override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float) { if (cooldown > 0) { RenderSystem.setShaderColor(1f, 0.4f, 0.4f, 1f) } - ResearchIcons.ICON_ENDER_TELEPORT.render(stack, x, y, width, height) + ResearchIcons.ICON_ENDER_TELEPORT.render(graphics, x, y, width, height) if (cooldown > 0) { RenderSystem.setShaderColor(1f, 1f, 1f, 1f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ExtendedReachFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ExtendedReachFeature.kt index 7a7b62b84..270e08963 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ExtendedReachFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ExtendedReachFeature.kt @@ -9,20 +9,20 @@ import java.util.* class ExtendedReachFeature(android: MatteryPlayerCapability) : AndroidFeature(AndroidFeatures.EXTENDED_REACH, android) { override fun applyModifiers() { - if (!ForgeMod.REACH_DISTANCE.isPresent) + if (!ForgeMod.BLOCK_REACH.isPresent) return - val reach = ply.getAttribute(ForgeMod.REACH_DISTANCE.get()) ?: return + val reach = ply.getAttribute(ForgeMod.BLOCK_REACH.get()) ?: return reach.removePermanentModifier(MODIFIER_ID) reach.addPermanentModifier(AttributeModifier(MODIFIER_ID, type.displayName.toString(), level + 1.0, AttributeModifier.Operation.ADDITION)) } override fun removeModifiers() { - if (!ForgeMod.REACH_DISTANCE.isPresent) + if (!ForgeMod.BLOCK_REACH.isPresent) return - ply.getAttribute(ForgeMod.REACH_DISTANCE.get())?.removePermanentModifier(MODIFIER_ID) + ply.getAttribute(ForgeMod.BLOCK_REACH.get())?.removePermanentModifier(MODIFIER_ID) } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt index 82ecd7917..4c7160245 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.android.feature import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.ChatFormatting +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation @@ -54,7 +55,7 @@ class ItemEntityDataPacket(val itemUUID: Int, val owner: UUID? = null, val age: override fun play(context: Supplier) { context.packetHandled = true - val level = minecraft.player?.level as ClientLevel? ?: return + val level = minecraft.player?.level() as ClientLevel? ?: return val entity = level.getEntity(itemUUID) as ItemEntity? ?: return datatable[entity] = SharedItemEntityData(owner, age, lifespan, hasPickupDelay) } @@ -78,7 +79,7 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable return } - val entities = ply.level.getEntitiesInEllipsoid( + val entities = ply.level().getEntitiesInEllipsoid( ply.position, Vector(AndroidConfig.Magnet.RADIUS_HORIZONTAL, AndroidConfig.Magnet.RADIUS_VERTICAL, AndroidConfig.Magnet.RADIUS_HORIZONTAL), if (server) Predicate { it is ItemEntity } else clientPredicate @@ -128,8 +129,8 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable } } - override fun renderIcon(stack: PoseStack, x: Float, y: Float, width: Float, height: Float) { - ResearchIcons.ICON_ITEM_MAGNET.render(stack, x, y, width, height) + override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float) { + ResearchIcons.ICON_ITEM_MAGNET.render(graphics, x, y, width, height) } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt index b8b727dca..555bd86e6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.android.feature import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.ChatFormatting +import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer @@ -51,7 +52,7 @@ object TriggerJumpBoostPacket : MatteryPacket { feature.putOnCooldown() context.sender?.let { - it.level.playSound( + it.level().playSound( it, it, MSoundEvents.ANDROID_JUMP_BOOST, @@ -89,14 +90,14 @@ class JumpBoostFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF } val old = lastGround - lastGround = ply.isOnGround + lastGround = ply.onGround() if (isActive && cooldown <= 0 && old != lastGround && !lastGround && isJumping && isShifting && ply.xRot <= ClientConfig.JUMP_BOOST_LOOK_ANGLE && android.androidEnergy.extractEnergyExact(AndroidConfig.JumpBoost.ENERGY_COST, true)) { ply.deltaMovement += Vector(0.0, AndroidConfig.JumpBoost.POWER * (level + 1) / 20.0, 0.0) putOnCooldown() MatteryPlayerNetworkChannel.sendToServer(TriggerJumpBoostPacket) - ply.level.playSound( + ply.level().playSound( ply, ply, MSoundEvents.ANDROID_JUMP_BOOST, @@ -113,12 +114,12 @@ class JumpBoostFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF } } - override fun renderIcon(stack: PoseStack, x: Float, y: Float, width: Float, height: Float) { + override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float) { if (cooldown > 0) { RenderSystem.setShaderColor(1f, 0.4f, 0.4f, 1f) } - ResearchIcons.ICON_JUMP_BOOST.render(stack, x, y, width, height) + ResearchIcons.ICON_JUMP_BOOST.render(graphics, x, y, width, height) if (cooldown > 0) { RenderSystem.setShaderColor(1f, 1f, 1f, 1f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt index d5d9a2d89..01f5dc6ea 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.android.feature import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.gui.GuiGraphics import net.minecraft.world.effect.MobEffectInstance import net.minecraft.world.effect.MobEffects import ru.dbotthepony.mc.otm.config.ServerConfig @@ -33,7 +34,7 @@ class NightVisionFeature(android: MatteryPlayerCapability) : AndroidSwitchableFe } } - override fun renderIcon(stack: PoseStack, x: Float, y: Float, width: Float, height: Float) { - ResearchIcons.ICON_NIGHT_VISION.render(stack, x, y, width, height) + override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float) { + ResearchIcons.ICON_NIGHT_VISION.render(graphics, x, y, width, height) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/PhantomAttractorFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/PhantomAttractorFeature.kt index 14f8580d3..b8dd02dd1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/PhantomAttractorFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/PhantomAttractorFeature.kt @@ -1,13 +1,14 @@ package ru.dbotthepony.mc.otm.android.feature import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.gui.GuiGraphics import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.registry.AndroidFeatures class PhantomAttractorFeature(android: MatteryPlayerCapability) : AndroidSwitchableFeature(AndroidFeatures.PHANTOM_ATTRACTOR, android) { - override fun renderIcon(stack: PoseStack, x: Float, y: Float, width: Float, height: Float) { - ResearchIcons.ICON_PHANTOM_ATTRACTOR.render(stack, x, y, width, height) + override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float) { + ResearchIcons.ICON_PHANTOM_ATTRACTOR.render(graphics, x, y, width, height) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt index 763f54b80..cc415b297 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt @@ -4,6 +4,7 @@ import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack import it.unimi.dsi.fastutil.objects.ReferenceArraySet import net.minecraft.ChatFormatting +import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer @@ -107,7 +108,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF ShockwaveTrigger.trigger(ply as ServerPlayer) MatteryPlayerNetworkChannel.sendTrackingAndSelf(ply, ShockwaveEffectPacket(ply.position)) - ply.level.playSound( + ply.level().playSound( null, ply, MSoundEvents.ANDROID_SHOCKWAVE, @@ -118,13 +119,13 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF } // TODO: raycasting - val entities = ply.level.getEntitiesInEllipsoid( + val entities = ply.level().getEntitiesInEllipsoid( ply.position, Vector(AndroidConfig.Shockwave.RADIUS_HORIZONTAL, AndroidConfig.Shockwave.RADIUS_VERTICAL, AndroidConfig.Shockwave.RADIUS_HORIZONTAL), except = ply, ) { (it !is LivingEntity || !it.isSpectator && it.isAlive) } - val wardens = ply.level.getEntitiesInEllipsoid( + val wardens = ply.level().getEntitiesInEllipsoid( Warden::class.java, ply.position, Vector(AndroidConfig.Shockwave.RADIUS_HORIZONTAL_WARDEN, AndroidConfig.Shockwave.RADIUS_VERTICAL_WARDEN, AndroidConfig.Shockwave.RADIUS_HORIZONTAL_WARDEN), @@ -136,7 +137,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF seen.add(entity) val multiplier = (1.0 - distanceMultiplier).pow(0.5) - val source = MatteryDamageSource(ply.level.registryAccess().damageType(MDamageTypes.SHOCKWAVE), ply) + val source = MatteryDamageSource(ply.level().registryAccess().damageType(MDamageTypes.SHOCKWAVE), ply) val damage = multiplier.toFloat() * AndroidConfig.Shockwave.DAMAGE.toFloat() * AndroidConfig.Shockwave.WARDEN_DAMAGE_MULT.toFloat() entity.hurt(source, damage) entity.deltaMovement += (entity.position - ply.position).normalize() * (multiplier * 3.0) @@ -152,7 +153,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF // don't hurt items, arrows, etc etc if (entity is LivingEntity) { - val source = MatteryDamageSource(ply.level.registryAccess().damageType(MDamageTypes.SHOCKWAVE), ply) + val source = MatteryDamageSource(ply.level().registryAccess().damageType(MDamageTypes.SHOCKWAVE), ply) val damage = multiplier.toFloat() * AndroidConfig.Shockwave.DAMAGE.toFloat() entity.hurt(source, damage) entity.deltaMovement += (entity.position - ply.position).normalize() * (multiplier * 3.0) @@ -172,21 +173,21 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF for (blockPos in getEllipsoidBlockPositions(AndroidConfig.Shockwave.RADIUS_HORIZONTAL.roundToInt(), AndroidConfig.Shockwave.RADIUS_VERTICAL.roundToInt(), AndroidConfig.Shockwave.RADIUS_HORIZONTAL.roundToInt())) { val newBlockPos = blockPos + rounded - val blockState = ply.level.getBlockState(newBlockPos) + val blockState = ply.level().getBlockState(newBlockPos) - if (!blockState.isAir && blockState.getExplosionResistance(ply.level, newBlockPos) <= 0f && ply.level.getBlockEntity(newBlockPos) == null && blockState.block.defaultDestroyTime() >= 0f) { - // Block.dropResources(blockState, ply.level, newBlockPos) - // blockState.block.destroy(ply.level, newBlockPos, blockState) - // ply.level.setBlock(newBlockPos, blockState.fluidState.createLegacyBlock(), Block.UPDATE_ALL) + if (!blockState.isAir && blockState.getExplosionResistance(ply.level(), newBlockPos) <= 0f && ply.level().getBlockEntity(newBlockPos) == null && blockState.block.defaultDestroyTime() >= 0f) { + // Block.dropResources(blockState, ply.level(), newBlockPos) + // blockState.block.destroy(ply.level(), newBlockPos, blockState) + // ply.level().setBlock(newBlockPos, blockState.fluidState.createLegacyBlock(), Block.UPDATE_ALL) - ply.level.destroyBlock(newBlockPos, true) + ply.level().destroyBlock(newBlockPos, true) } } } } private fun ticker(isClient: Boolean) { - if (!ply.isOnGround || ply.isSpectator) { + if (!ply.onGround() || ply.isSpectator) { airTicks = (airTicks + 1).coerceAtMost(3) } else { airTicks = (airTicks - 1).coerceAtLeast(0) @@ -206,7 +207,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF creativeFlightTicks == 0 ) { val old = wasMidair - wasMidair = !ply.isOnGround + wasMidair = !ply.onGround() if (wasMidair) { highestSpeed = (-ply.deltaMovement.y).coerceAtLeast(highestSpeed) @@ -239,12 +240,12 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF ticker(false) } - override fun renderIcon(stack: PoseStack, x: Float, y: Float, width: Float, height: Float) { + override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float) { if (isOnCooldown) { RenderSystem.setShaderColor(1f, 0.4f, 0.4f, 1f) } - ResearchIcons.ICON_SHOCKWAVE.render(stack, x, y, width, height) + ResearchIcons.ICON_SHOCKWAVE.render(graphics, x, y, width, height) if (isOnCooldown) { RenderSystem.setShaderColor(1f, 1f, 1f, 1f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/StepAssistFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/StepAssistFeature.kt index 321d70369..81f3be363 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/StepAssistFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/StepAssistFeature.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.android.feature import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.gui.GuiGraphics import net.minecraft.world.entity.ai.attributes.AttributeModifier import net.minecraftforge.common.ForgeMod import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature @@ -53,8 +54,8 @@ class StepAssistFeature(android: MatteryPlayerCapability) : AndroidSwitchableFea sharedTick() } - override fun renderIcon(stack: PoseStack, x: Float, y: Float, width: Float, height: Float) { - ResearchIcons.ICON_STEP_ASSIST.render(stack, x, y, width, height) + override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float) { + ResearchIcons.ICON_STEP_ASSIST.render(graphics, x, y, width, height) } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/BlackHoleBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/BlackHoleBlock.kt index 41f64a70a..99916f8f4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/BlackHoleBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/BlackHoleBlock.kt @@ -5,11 +5,13 @@ import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.EntityBlock +import net.minecraft.world.level.block.SoundType import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.entity.BlockEntityTicker import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState -import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity @@ -17,7 +19,7 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes class BlackHoleBlock : - Block(Properties.of(Material.STONE).strength(-1f, 7200000.0f)), EntityBlock { + Block(Properties.of().mapColor(MapColor.COLOR_BLACK).noCollission().pushReaction(PushReaction.BLOCK).sound(SoundType.STONE).strength(-1f, 7200000.0f)), EntityBlock { override fun getShape( p_60555_: BlockState, p_60556_: BlockGetter, @@ -48,4 +50,4 @@ class BlackHoleBlock : companion object { private val SHAPE = BlockShapes.BLACK_HOLE.computeShape() } -} \ No newline at end of file +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt index ad9f67f30..97a7f8a71 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt @@ -8,12 +8,12 @@ import net.minecraft.core.Direction import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.EntityBlock +import net.minecraft.world.level.block.SoundType import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.level.block.state.properties.BooleanProperty -import net.minecraft.world.level.material.Material -import net.minecraft.world.level.material.MaterialColor +import net.minecraft.world.level.material.MapColor import net.minecraft.world.phys.shapes.BooleanOp import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.Shapes @@ -70,7 +70,7 @@ abstract class CableBlock(properties: Properties) : Block(properties) { } class MatterCableBlock : CableBlock( - Properties.of(Material.STONE, MaterialColor.METAL).requiresCorrectToolForDrops().strength(1.0f, 6.0f)), + Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock { private val CORE_SHAPE: VoxelShape = Shapes.box( 0.5 - 0.15, @@ -188,7 +188,7 @@ class MatterCableBlock : CableBlock( } class StorageCableBlock : CableBlock( - Properties.of(Material.STONE, MaterialColor.METAL).requiresCorrectToolForDrops().strength(1.0f, 6.0f)), + Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock { companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/ExplosionDebuggerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/ExplosionDebuggerBlock.kt index 82e58bbe2..2643ffc89 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/ExplosionDebuggerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/ExplosionDebuggerBlock.kt @@ -4,16 +4,16 @@ import net.minecraft.core.BlockPos import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.EntityBlock +import net.minecraft.world.level.block.SoundType import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.entity.BlockEntityTicker import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState -import net.minecraft.world.level.material.Material import ru.dbotthepony.mc.otm.block.entity.blackhole.BlockEntityExplosionDebugger import ru.dbotthepony.mc.otm.block.entity.blackhole.BlockEntitySphereDebugger import ru.dbotthepony.mc.otm.registry.MBlockEntities -class BlockExplosionDebugger : Block(Properties.of(Material.STONE)), EntityBlock { +class BlockExplosionDebugger : Block(Properties.of().sound(SoundType.STONE)), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return BlockEntityExplosionDebugger(p_153215_, p_153216_) } @@ -31,7 +31,7 @@ class BlockExplosionDebugger : Block(Properties.of(Material.STONE)), EntityBlock } } -class BlockSphereDebugger : Block(Properties.of(Material.STONE)), EntityBlock { +class BlockSphereDebugger : Block(Properties.of()), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return BlockEntitySphereDebugger(p_153215_, p_153216_) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt index b7f082f90..cb57cc668 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt @@ -19,8 +19,7 @@ import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.EntityBlock import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.properties.Property -import net.minecraft.world.level.material.Material -import net.minecraft.world.level.material.MaterialColor +import net.minecraft.world.level.material.MapColor import net.minecraft.world.phys.BlockHitResult import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.SERVER_IS_LIVE @@ -225,7 +224,7 @@ abstract class MatteryBlock @JvmOverloads constructor( } companion object { - val DEFAULT_PROPERTIES: Properties = Properties.of(Material.STONE, MaterialColor.METAL).requiresCorrectToolForDrops().destroyTime(1.5f).explosionResistance(25.0f) + val DEFAULT_PROPERTIES: Properties = Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().destroyTime(1.5f).explosionResistance(25.0f) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/CargoCrateBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/CargoCrateBlock.kt index 19fcb775e..09826b342 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/CargoCrateBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/CargoCrateBlock.kt @@ -8,12 +8,12 @@ import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.EntityBlock +import net.minecraft.world.level.block.SoundType import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.level.block.state.properties.BooleanProperty -import net.minecraft.world.level.material.Material -import net.minecraft.world.level.material.MaterialColor +import net.minecraft.world.level.material.MapColor import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.Shapes import net.minecraft.world.phys.shapes.VoxelShape @@ -23,7 +23,7 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.shapes.BlockShapes class CargoCrateBlock(val color: DyeColor?) : RotatableMatteryBlock( - Properties.of(Material.STONE, color?.materialColor ?: MaterialColor.COLOR_BLUE).requiresCorrectToolForDrops().strength(1.5f, 30.0f) + Properties.of().mapColor(color?.mapColor ?: MapColor.COLOR_BLUE).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.5f, 30.0f) ), EntityBlock { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return CargoCrateBlockEntity(blockPos, blockState) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt index 818e78ef5..72f738fbc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt @@ -7,8 +7,9 @@ import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.BlockGetter +import net.minecraft.world.level.block.SoundType import net.minecraft.world.level.block.state.BlockState -import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.MapColor import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock @@ -17,7 +18,7 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.shapes.BlockShapes -class EngineBlock : RotatableMatteryBlock(Properties.of(Material.METAL, DyeColor.ORANGE).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) { +class EngineBlock : RotatableMatteryBlock(Properties.of().mapColor(MapColor.COLOR_ORANGE).sound(SoundType.METAL).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) { override fun appendHoverText( p_49816_: ItemStack, p_49817_: BlockGetter?, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt index f4dc91b9e..b0e04d1fd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt @@ -9,14 +9,11 @@ import net.minecraft.world.item.TooltipFlag import net.minecraft.world.item.context.BlockPlaceContext import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level -import net.minecraft.world.level.block.Block -import net.minecraft.world.level.block.Blocks -import net.minecraft.world.level.block.RenderShape -import net.minecraft.world.level.block.Rotation +import net.minecraft.world.level.block.* import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.level.block.state.properties.BlockStateProperties -import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.MapColor import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.Shapes import net.minecraft.world.phys.shapes.VoxelShape @@ -32,7 +29,7 @@ import ru.dbotthepony.mc.otm.registry.MBlocks private val FACING_FULL = BlockRotationFreedom.TWO.property -class LaboratoryLampLight : Block(Properties.of(Material.AIR).strength(-1.0F, 3600000.8F).noLootTable().noOcclusion().lightLevel { 15 }) { +class LaboratoryLampLight : Block(Properties.of().strength(-1.0F, 3600000.8F).noCollission().noLootTable().replaceable().lightLevel { 15 }) { override fun createBlockStateDefinition(builder: StateDefinition.Builder) { super.createBlockStateDefinition(builder) builder.add(FACING_FULL) @@ -106,7 +103,7 @@ class LaboratoryLampLight : Block(Properties.of(Material.AIR).strength(-1.0F, 36 } } -class LaboratoryLamp(val invertRedstone: Boolean) : Block(Properties.of(Material.METAL).explosionResistance(12f).destroyTime(2f).requiresCorrectToolForDrops()) { +class LaboratoryLamp(val invertRedstone: Boolean) : Block(Properties.of().mapColor(MapColor.METAL).sound(SoundType.METAL).explosionResistance(12f).destroyTime(2f).requiresCorrectToolForDrops()) { init { registerDefaultState(stateDefinition.any().setValue(BlockStateProperties.LIT, !invertRedstone)) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt index 2a8fd2044..2f02e1a24 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt @@ -14,15 +14,15 @@ import net.minecraft.world.level.Level import net.minecraft.world.level.LevelAccessor import net.minecraft.world.level.block.BasePressurePlateBlock import net.minecraft.world.level.block.Block +import net.minecraft.world.level.block.SoundType import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.level.block.state.properties.BlockSetType import net.minecraft.world.level.block.state.properties.BlockStateProperties -import net.minecraft.world.level.material.Material import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.get -class TritaniumPressurePlate(color: DyeColor?) : BasePressurePlateBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), BlockSetType.IRON) { +class TritaniumPressurePlate(color: DyeColor?) : BasePressurePlateBlock(Properties.of().mapColor(color ?: DyeColor.LIGHT_BLUE).sound(SoundType.METAL).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), BlockSetType.IRON) { override fun appendHoverText( p_49816_: ItemStack, p_49817_: BlockGetter?, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt index 25fc2140c..35b893734 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt @@ -21,6 +21,7 @@ import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.gameevent.GameEvent import net.minecraft.world.level.storage.loot.LootContext +import net.minecraft.world.level.storage.loot.LootParams import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets import net.minecraft.world.level.storage.loot.parameters.LootContextParams import net.minecraft.world.phys.Vec3 @@ -104,7 +105,7 @@ class CargoCrateBlockEntity( val lootTableSeed = lootTableSeed ?: 0L val server = level?.server ?: return - val loot = server.lootTables.get(lootTable) + val loot = server.lootData.getLootTable(lootTable) if (ply is ServerPlayer) { CriteriaTriggers.GENERATE_LOOT.trigger(ply, lootTable) @@ -113,16 +114,15 @@ class CargoCrateBlockEntity( this.lootTable = null this.lootTableSeed = null - val context = LootContext.Builder(level as ServerLevel) + val params = LootParams.Builder(level as ServerLevel) .withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(this.worldPosition)) - .withOptionalRandomSeed(lootTableSeed) if (ply != null) { - context.withLuck(ply.luck).withParameter(LootContextParams.THIS_ENTITY, ply) + params.withLuck(ply.luck).withParameter(LootContextParams.THIS_ENTITY, ply) } Containers.dropContents(level as ServerLevel, blockPos, container) - loot.fill(container, context.create(LootContextParamSets.CHEST)) + loot.fill(container, params.create(LootContextParamSets.CHEST), lootTableSeed) } override val defaultDisplayName: Component 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 73247f2d3..e8b9d2813 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 @@ -13,6 +13,7 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.inventory.CraftingContainer +import net.minecraft.world.inventory.TransientCraftingContainer import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.CraftingRecipe import net.minecraft.world.item.crafting.RecipeType @@ -266,7 +267,7 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } - private val craftingGridDummy = CraftingContainer(craftingMenu, 3, 3) + private val craftingGridDummy = TransientCraftingContainer(craftingMenu, 3, 3) override val storageType: StorageStackType get() = ITEM_STORAGE 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 5ebf5674d..9aadfd64f 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 @@ -35,7 +35,7 @@ class PlatePressBlockEntity( if (whole > 0) { experience -= whole - ExperienceOrb.award(player.level as ServerLevel, player.position(), whole) + ExperienceOrb.award(player.level() as ServerLevel, player.position(), whole) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt index b05ae629c..3b23d5079 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt @@ -5,12 +5,12 @@ import net.minecraft.core.Direction import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraft.world.level.block.EntityBlock +import net.minecraft.world.level.block.SoundType import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.entity.BlockEntityTicker import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState -import net.minecraft.world.level.material.Material -import net.minecraft.world.level.material.MaterialColor +import net.minecraft.world.level.material.MapColor import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock @@ -21,7 +21,7 @@ import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes -class EnergyServoBlock : RotatableMatteryBlock(Properties.of(Material.METAL, MaterialColor.COLOR_BLUE).explosionResistance(12f).destroyTime(2f).requiresCorrectToolForDrops()), EntityBlock { +class EnergyServoBlock : RotatableMatteryBlock(Properties.of().mapColor(MapColor.COLOR_BLUE).sound(SoundType.METAL).explosionResistance(12f).destroyTime(2f).requiresCorrectToolForDrops()), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return EnergyServoBlockEntity(p_153215_, p_153216_) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt index 1bfd53e17..e78fc081e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt @@ -11,14 +11,14 @@ import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.EntityBlock +import net.minecraft.world.level.block.SoundType import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.entity.BlockEntityTicker import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockBehaviour import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition -import net.minecraft.world.level.material.Material -import net.minecraft.world.level.material.MaterialColor +import net.minecraft.world.level.material.MapColor import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape @@ -36,7 +36,7 @@ import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.shapes.BlockShapes import kotlin.math.PI -private val props = BlockBehaviour.Properties.of(Material.STONE, MaterialColor.COLOR_BLUE).requiresCorrectToolForDrops().strength(3f, 600.0f) +private val props = BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BLUE).sound(SoundType.METAL).pushReaction(PushReaction.BLOCK).requiresCorrectToolForDrops().strength(3f, 600.0f) class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { @@ -111,10 +111,6 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock { } } - override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { - return PushReaction.BLOCK - } - override fun neighborChanged( state: BlockState, level: Level, @@ -174,10 +170,6 @@ class BlockGravitationStabilizerLens : RotatableMatteryBlock(props) { builder.add(WorkerState.SEMI_WORKER_STATE) } - override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { - return PushReaction.BLOCK - } - override fun neighborChanged( state: BlockState, level: Level, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt index 415b7bc07..e8e620148 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt @@ -15,12 +15,12 @@ import net.minecraft.world.level.Level import net.minecraft.world.level.NaturalSpawner import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.Blocks +import net.minecraft.world.level.block.SoundType import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.level.block.state.properties.BlockStateProperties import net.minecraft.world.level.block.state.properties.DoubleBlockHalf -import net.minecraft.world.level.material.Material -import net.minecraft.world.level.material.MaterialColor +import net.minecraft.world.level.material.MapColor import net.minecraft.world.phys.AABB import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape @@ -37,7 +37,7 @@ import ru.dbotthepony.mc.otm.once import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.shapes.BlockShapes -class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of(Material.METAL, MaterialColor.COLOR_BLUE).destroyTime(3f).explosionResistance(12f).randomTicks()) { +class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of().mapColor(MapColor.COLOR_BLUE).sound(SoundType.METAL).destroyTime(3f).explosionResistance(12f).randomTicks()) { @Suppress("OVERRIDE_DEPRECATION") override fun randomTick( blockState: BlockState, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index f107f9435..af3645ec9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -99,7 +99,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial override fun hasResult() = false val player get() = capability.ply - val level: Level get() = capability.ply.level + val level: Level get() = capability.ply.level() } /** @@ -110,7 +110,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial override fun hasResult() = false val player get() = capability.ply - val level: Level get() = capability.ply.level + val level: Level get() = capability.ply.level() } /** @@ -123,7 +123,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial override fun setResult(value: Result) {} val player get() = capability.ply - val level: Level get() = capability.ply.level + val level: Level get() = capability.ply.level() } private inner class PlayerMatteryContainer(size: Int) : MatteryContainer(size) { @@ -418,7 +418,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial becomeAndroid() if (!ply.abilities.invulnerable) - ply.hurt(MatteryDamageSource(ply.level.registryAccess().damageType(MDamageTypes.BECOME_ANDROID)), ply.maxHealth * 2) + ply.hurt(MatteryDamageSource(ply.level().registryAccess().damageType(MDamageTypes.BECOME_ANDROID)), ply.maxHealth * 2) } /** @@ -478,7 +478,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial becomeHumane() if (!ply.abilities.invulnerable) - ply.hurt(MatteryDamageSource(ply.level.registryAccess().damageType(MDamageTypes.BECOME_HUMANE)), ply.maxHealth * 2) + ply.hurt(MatteryDamageSource(ply.level().registryAccess().damageType(MDamageTypes.BECOME_HUMANE)), ply.maxHealth * 2) } /** @@ -539,7 +539,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial if (featureMap.containsKey(feature.type)) return false featureMap[feature.type] = feature - if (!ply.level.isClientSide) { + if (!ply.level().isClientSide) { queuedTicks.add(feature::applyModifiers) } @@ -567,7 +567,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial featureMap[feature] = factory - if (!ply.level.isClientSide && isAndroid) { + if (!ply.level().isClientSide && isAndroid) { queuedTicks.add(factory::applyModifiers) } @@ -592,7 +592,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial val removed = featureMap.remove(feature) if (removed != null) { - if (!ply.level.isClientSide && isAndroid) { + if (!ply.level().isClientSide && isAndroid) { queuedTicks.add(removed::removeModifiers) } @@ -732,7 +732,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial instance.deserializeNBT(featureTag) addFeature(instance) - if (!ply.level.isClientSide) { + if (!ply.level().isClientSide) { queuedTicks.add(instance::applyModifiers) } } @@ -786,7 +786,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial if (hasExoPack) { for ((i, stack) in exoPackContainer.withIndex()) { if (!stack.isEmpty) { - stack.inventoryTick(ply.level, ply, i + 41, false) + stack.inventoryTick(ply.level(), ply, i + 41, false) } } } @@ -852,8 +852,8 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial ply.isSwimming = false if (ply is ServerPlayer) { - if (ply.level.dimension().location() != lastDimension) { - lastDimension = ply.level.dimension().location() + if (ply.level().dimension().location() != lastDimension) { + lastDimension = ply.level().dimension().location() wasInLiquid = false lastOutsideLiquid = ply.position } @@ -889,7 +889,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial androidEnergy.receiveEnergy(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false) stats.foodLevel = stats.foodLevel - 1 } - } else if (ply.level.server?.worldData?.difficulty != Difficulty.PEACEFUL) { + } else if (ply.level().server?.worldData?.difficulty != Difficulty.PEACEFUL) { stats.foodLevel = stats.foodLevel.coerceAtMost(18) } @@ -1160,13 +1160,13 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial val ent = event.player if (event.phase == TickEvent.Phase.START) { - if (!ent.level.isClientSide) { + if (!ent.level().isClientSide) { ent.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresentK { it.preTick() } } } else { - if (ent.level.isClientSide) { + if (ent.level().isClientSide) { ent.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresentK { it.tickClient() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt index cde8acdc9..41b816802 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt @@ -60,7 +60,7 @@ object AndroidAbilityKeyMapping : KeyMapping("key.otm.android_ability", KeyConfl RGBAColor.WHITE.setSystemColor() - feature.renderIcon(event.poseStack, x, y, iconSize, iconSize) + feature.renderIcon(event.guiGraphics, x, y, iconSize, iconSize) if (feature.isOnCooldown) { RGBAColor.WHITE.setSystemColor() @@ -71,13 +71,13 @@ object AndroidAbilityKeyMapping : KeyMapping("key.otm.android_ability", KeyConfl RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f) val nodrawpixels = (iconSize * (1 - cooldownPct)).roundToInt().toFloat() - drawRect(event.poseStack, x, y + nodrawpixels, iconSize, iconSize - nodrawpixels) + drawRect(event.guiGraphics, x, y + nodrawpixels, iconSize, iconSize - nodrawpixels) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) } - Widgets18.COOLDOWN.render(event.poseStack, x, y + iconSize, iconSize, iconSize) + Widgets18.COOLDOWN.render(event.guiGraphics, x, y + iconSize, iconSize, iconSize) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt index 277289b7c..3aac27d2d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt @@ -157,7 +157,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon val size = minecraft.window.guiScaledHeight.coerceAtMost(minecraft.window.guiScaledWidth).toFloat() * 0.35f drawArc( - event.poseStack, + event.guiGraphics, minecraft.window.guiScaledWidth / 2f, minecraft.window.guiScaledHeight / 2f, size, @@ -227,7 +227,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon RenderSystem.setShaderColor(85 / 255f, 197 / 255f, 255 / 255f, 0.3f * lastSelectProgressGlobal) drawArc( - event.poseStack, + event.guiGraphics, minecraft.window.guiScaledWidth / 2f, minecraft.window.guiScaledHeight / 2f, ru.dbotthepony.mc.otm.core.math.linearInterpolation(lastSelectProgressGlobal, size, size * 1.2f), @@ -242,8 +242,9 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon val iconSize = size * 0.25f - event.poseStack.pushPose() - event.poseStack.translate(minecraft.window.guiScaledWidth.toDouble() / 2f, minecraft.window.guiScaledHeight.toDouble() / 2f, 0.0) + val poseStack = event.guiGraphics.pose() + poseStack.pushPose() + poseStack.translate(minecraft.window.guiScaledWidth.toDouble() / 2f, minecraft.window.guiScaledHeight.toDouble() / 2f, 0.0) for ((index, feature) in features.withIndex()) { var sin = sin((index + 0.5) * degreePerSlice).toFloat() @@ -255,20 +256,20 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon } val shift = size * 0.6f - feature.renderIcon(event.poseStack, -iconSize / 2f + shift * cos, -shift * sin - iconSize / 2f, iconSize, iconSize) - minecraft.font.drawAligned(event.poseStack, feature.type.displayName, TextAlign.CENTER_CENTER, shift * cos + 1f, -shift * sin - iconSize / 1.5f + 1f, 0) - minecraft.font.drawAligned(event.poseStack, feature.type.displayName, TextAlign.CENTER_CENTER, shift * cos, -shift * sin - iconSize / 1.5f, if (feature.isActive) RGBAColor.DARK_GREEN else RGBAColor.DARK_RED) + feature.renderIcon(event.guiGraphics, -iconSize / 2f + shift * cos, -shift * sin - iconSize / 2f, iconSize, iconSize) + event.guiGraphics.drawAligned(minecraft.font, feature.type.displayName, TextAlign.CENTER_CENTER, shift * cos + 1f, -shift * sin - iconSize / 1.5f + 1f, 0) + event.guiGraphics.drawAligned(minecraft.font, feature.type.displayName, TextAlign.CENTER_CENTER, shift * cos, -shift * sin - iconSize / 1.5f, if (feature.isActive) RGBAColor.DARK_GREEN else RGBAColor.DARK_RED) if (feature.isOnCooldown && feature.cooldownPercent > 0.0f) { RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f) - drawArc(event.poseStack, shift * cos, -shift * sin, iconSize / 2f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * feature.cooldownPercent.toDouble()) + drawArc(event.guiGraphics, shift * cos, -shift * sin, iconSize / 2f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * feature.cooldownPercent.toDouble()) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) - minecraft.font.drawAligned(event.poseStack, formatTickDuration(feature.cooldown), TextAlign.CENTER_CENTER, shift * cos, -shift * sin + iconSize / 1.5f, RGBAColor.WHITE) + event.guiGraphics.drawAligned(minecraft.font, formatTickDuration(feature.cooldown), TextAlign.CENTER_CENTER, shift * cos, -shift * sin + iconSize / 1.5f, RGBAColor.WHITE) } } - event.poseStack.popPose() + poseStack.popPose() } private fun renderRegular(event: RenderGuiEvent.Post) { @@ -295,13 +296,13 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon var x = minecraft.window.guiScaledWidth * 0.5f - (features.size.toFloat() * COOLDOWN_ICON_SIZE / 2f + (features.size - 1).toFloat() * (COOLDOWN_ICON_MARGIN / 2f)) for (feature in features) { - feature.renderIcon(event.poseStack, x, y, COOLDOWN_ICON_SIZE, COOLDOWN_ICON_SIZE) + feature.renderIcon(event.guiGraphics, x, y, COOLDOWN_ICON_SIZE, COOLDOWN_ICON_SIZE) RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f) - drawArc(event.poseStack, x, y, COOLDOWN_ICON_SIZE / 2f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * feature.cooldownPercent, alignAtCenter = false) + drawArc(event.guiGraphics, x, y, COOLDOWN_ICON_SIZE / 2f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * feature.cooldownPercent, alignAtCenter = false) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) - font.drawAligned(event.poseStack, formatTickDuration(feature.cooldown), TextAlign.TOP_CENTER, x + COOLDOWN_ICON_SIZE / 2f, y + COOLDOWN_ICON_SIZE + 1f, RGBAColor.WHITE) + event.guiGraphics.drawAligned(font, formatTickDuration(feature.cooldown), TextAlign.TOP_CENTER, x + COOLDOWN_ICON_SIZE / 2f, y + COOLDOWN_ICON_SIZE + 1f, RGBAColor.WHITE) x += COOLDOWN_ICON_SIZE + COOLDOWN_ICON_MARGIN } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt index cddf388fb..b8e68d950 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt @@ -53,7 +53,7 @@ fun onMovementInputUpdate(event: MovementInputUpdateEvent) { cap.lastJumpTicks = 14 } else { if (ply.isInWater) { - if (ply.isOnGround) { + if (ply.onGround()) { cap.lastJumpTicks = 14 } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index d3f648c70..59b24daf3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -132,7 +132,7 @@ object MatteryGUI { return } - val stack = event.poseStack + val stack = event.guiGraphics.pose() val window = event.window stack.pushPose() @@ -156,7 +156,7 @@ object MatteryGUI { pushScissorRect(0, (scissorBase + scissorHeight * (1f - progress)).toInt(), window.width, (scissorHeight * progress * 2f).toInt()) setDrawColor(RGBAColor(1f, 1f, 1f, 0.4f)) - drawRect(stack, 0f, y - 12f, window.guiScaledWidth.toFloat(), 24f + (deathLog.size - 2f).coerceAtLeast(0f) * minecraft.font.lineHeight * modifyScale * 0.175f) + drawRect(event.guiGraphics, 0f, y - 12f, window.guiScaledWidth.toFloat(), 24f + (deathLog.size - 2f).coerceAtLeast(0f) * minecraft.font.lineHeight * modifyScale * 0.175f) val text = TranslatableComponent("otm.iteration", iteration) @@ -240,22 +240,17 @@ object MatteryGUI { val leftPadding = ceil(level * 80f - 0.5f) if (ply.hasEffect(MobEffects.HUNGER)) { - CHARGE_HUNGER_BG.render(event.poseStack, left.toFloat(), top.toFloat()) - CHARGE_HUNGER.renderPartial(event.poseStack, left.toFloat() - leftPadding + 80f, top.toFloat(), width = leftPadding) + CHARGE_HUNGER_BG.render(event.guiGraphics, left.toFloat(), top.toFloat()) + CHARGE_HUNGER.renderPartial(event.guiGraphics, left.toFloat() - leftPadding + 80f, top.toFloat(), width = leftPadding) } else { - CHARGE_BG.render(event.poseStack, left.toFloat(), top.toFloat()) - CHARGE.renderPartial(event.poseStack, left.toFloat() - leftPadding + 80f, top.toFloat(), width = leftPadding) + CHARGE_BG.render(event.guiGraphics, left.toFloat(), top.toFloat()) + CHARGE.renderPartial(event.guiGraphics, left.toFloat() - leftPadding + 80f, top.toFloat(), width = leftPadding) } val formattedPower = mattery.androidEnergy.batteryLevel.formatPower() - event.poseStack.pushPose() - event.poseStack.scale(0.5f, 0.5f, 0.5f) - - minecraft.font.drawAligned(event.poseStack, formattedPower, TextAlign.CENTER_LEFT, (left + 83f) * 2f, (top + 5.5f) * 2f, RGBAColor.BLACK.toInt()) - minecraft.font.drawAligned(event.poseStack, formattedPower, TextAlign.CENTER_LEFT, (left + 82f) * 2f, (top + 4.5f) * 2f, RGBAColor.YELLOW.toInt()) - - event.poseStack.popPose() + event.guiGraphics.drawScaledAligned(minecraft.font, formattedPower, 0.5f, TextAlign.CENTER_LEFT, (left + 83f) * 2f, (top + 5.5f) * 2f, RGBAColor.BLACK.toInt()) + event.guiGraphics.drawScaledAligned(minecraft.font, formattedPower, 0.5f, TextAlign.CENTER_LEFT, (left + 82f) * 2f, (top + 4.5f) * 2f, RGBAColor.YELLOW.toInt()) } } @@ -312,31 +307,26 @@ object MatteryGUI { val top: Int = height - gui.leftHeight gui.leftHeight += 10 - HEALTH_BG.render(event.poseStack, left.toFloat(), top.toFloat()) + HEALTH_BG.render(event.guiGraphics, left.toFloat(), top.toFloat()) if (mattery.hasFeature(AndroidFeatures.NANOBOTS_ARMOR)) { val featArmor = mattery.getFeature(AndroidFeatures.NANOBOTS_ARMOR) as NanobotsArmorFeature val levelArmor: Float = (featArmor.layers.toFloat() / (featArmor.strength + 1).toFloat()).coerceIn(0.0f .. 1.0f) - HEALTH_BG_NANOBOTS.renderPartial(event.poseStack, left.toFloat(), top.toFloat(), width = ceil(levelArmor * 81f)) + HEALTH_BG_NANOBOTS.renderPartial(event.guiGraphics, left.toFloat(), top.toFloat(), width = ceil(levelArmor * 81f)) } - getSpriteForPlayer(ply).renderPartial(event.poseStack, left.toFloat(), top.toFloat(), width = ceil(level * 80f - 0.5f)) + getSpriteForPlayer(ply).renderPartial(event.guiGraphics, left.toFloat(), top.toFloat(), width = ceil(level * 80f - 0.5f)) if (levelAbsorb > 0) { - HEALTH_ABSORB.renderPartial(event.poseStack, left.toFloat(), top.toFloat(), width = ceil(levelAbsorb * 80f - 0.5f)) + HEALTH_ABSORB.renderPartial(event.guiGraphics, left.toFloat(), top.toFloat(), width = ceil(levelAbsorb * 80f - 0.5f)) } var formattedHealth = "%d/%d".format(ply.health.toInt(), ply.maxHealth.toInt()) if (ply.absorptionAmount > 0) formattedHealth = "%d+%d/%d".format(ply.health.toInt(), ply.absorptionAmount.toInt(), ply.maxHealth.toInt()) - event.poseStack.pushPose() - event.poseStack.scale(0.5f, 0.5f, 0.5f) - - minecraft.font.drawAligned(event.poseStack, formattedHealth, TextAlign.CENTER_RIGHT, (left - 1f) * 2f, (top + 5.5f) * 2f, RGBAColor.BLACK.toInt()) - minecraft.font.drawAligned(event.poseStack, formattedHealth, TextAlign.CENTER_RIGHT, (left - 2f) * 2f, (top + 4.5f) * 2f, getHealthColorForPlayer(ply)) - - event.poseStack.popPose() + event.guiGraphics.drawScaledAligned(minecraft.font, formattedHealth, 0.5f, TextAlign.CENTER_RIGHT, (left - 1f) * 2f, (top + 5.5f) * 2f, RGBAColor.BLACK.toInt()) + event.guiGraphics.drawScaledAligned(minecraft.font, formattedHealth, 0.5f, TextAlign.CENTER_RIGHT, (left - 2f) * 2f, (top + 4.5f) * 2f, getHealthColorForPlayer(ply)) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt index d8389b1bf..e82597258 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt @@ -6,6 +6,7 @@ import com.mojang.blaze3d.vertex.DefaultVertexFormat import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.VertexConsumer import com.mojang.blaze3d.vertex.VertexFormat +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.renderer.GameRenderer import net.minecraft.client.renderer.RenderStateShard import net.minecraft.client.renderer.RenderType @@ -52,12 +53,12 @@ sealed class AbstractMatterySprite { * See [ru.dbotthepony.mc.otm.client.render.clearDepth] */ fun clearDepth( - stack: PoseStack, + graphics: GuiGraphics, x: Float = 0f, y: Float = 0f, width: Float = this.width, height: Float = this.height, - ) = ru.dbotthepony.mc.otm.client.render.clearDepth(stack, x, y, width, height) + ) = ru.dbotthepony.mc.otm.client.render.clearDepth(graphics, x, y, width, height) @JvmOverloads fun render( @@ -75,6 +76,18 @@ sealed class AbstractMatterySprite { renderRaw(stack, x, y, width, height, winding) } + @JvmOverloads + fun render( + graphics: GuiGraphics, + x: Float = 0f, + y: Float = 0f, + width: Float = this.width, + height: Float = this.height, + winding: UVWindingOrder = this.winding + ) { + render(graphics.pose(), x, y, width, height, winding) + } + @JvmOverloads fun render( stack: PoseStack, @@ -101,6 +114,16 @@ sealed class AbstractMatterySprite { renderRawPartial(stack, x, y, width, height, winding) } + @JvmOverloads + fun renderPartial( + graphics: GuiGraphics, + x: Float = 0f, + y: Float = 0f, + width: Float = this.width, + height: Float = this.height, + winding: UVWindingOrder = this.winding + ) = renderPartial(graphics.pose(), x, y, width, height, winding) + @JvmOverloads fun renderPartial( stack: PoseStack, @@ -111,6 +134,16 @@ sealed class AbstractMatterySprite { winding: UVWindingOrder = this.winding ) = renderPartial(stack, x.toFloat(), y.toFloat(), width.toFloat(), height.toFloat(), winding) + @JvmOverloads + fun renderPartial( + graphics: GuiGraphics, + x: Double, + y: Double = 0.0, + width: Double = this.width.toDouble(), + height: Double = this.height.toDouble(), + winding: UVWindingOrder = this.winding + ) = renderPartial(graphics.pose(), x, y, width, height, winding) + @JvmOverloads fun renderWidth( stack: PoseStack, @@ -118,9 +151,16 @@ sealed class AbstractMatterySprite { y: Float = 0f, width: Float = this.width, winding: UVWindingOrder = this.winding - ) { - render(stack, x, y, width = width, winding = winding) - } + ) = render(stack, x, y, width = width, winding = winding) + + @JvmOverloads + fun renderWidth( + graphics: GuiGraphics, + x: Float = 0f, + y: Float = 0f, + width: Float = this.width, + winding: UVWindingOrder = this.winding + ) = renderWidth(graphics.pose(), x, y, width, winding) @JvmOverloads fun renderWidth( @@ -131,6 +171,15 @@ sealed class AbstractMatterySprite { winding: UVWindingOrder = this.winding ) = renderWidth(stack, x.toFloat(), y.toFloat(), width.toFloat(), winding) + @JvmOverloads + fun renderWidth( + graphics: GuiGraphics, + x: Double, + y: Double = 0.0, + width: Double = this.width.toDouble(), + winding: UVWindingOrder = this.winding + ) = renderWidth(graphics.pose(), x, y, width, winding) + @JvmOverloads fun renderHeight( stack: PoseStack, @@ -138,9 +187,16 @@ sealed class AbstractMatterySprite { y: Float = 0f, height: Float = this.height, winding: UVWindingOrder = this.winding - ) { - render(stack, x, y, height = height, winding = winding) - } + ) = render(stack, x, y, height = height, winding = winding) + + @JvmOverloads + fun renderHeight( + graphics: GuiGraphics, + x: Float = 0f, + y: Float = 0f, + height: Float = this.height, + winding: UVWindingOrder = this.winding + ) = renderHeight(graphics.pose(), x, y, height, winding) @JvmOverloads fun renderHeight( @@ -151,6 +207,14 @@ sealed class AbstractMatterySprite { winding: UVWindingOrder = this.winding ) = renderHeight(stack, x.toFloat(), y.toFloat(), height.toFloat(), winding) + @JvmOverloads + fun renderHeight( + graphics: GuiGraphics, + x: Double, + y: Double = 0.0, + height: Double = this.height.toDouble(), + winding: UVWindingOrder = this.winding + ) = renderHeight(graphics.pose(), x, y, height, winding) @JvmOverloads fun renderRaw( @@ -183,6 +247,16 @@ sealed class AbstractMatterySprite { winding: UVWindingOrder = this.winding ) = renderRaw(stack, x.toFloat(), y.toFloat(), width.toFloat(), height.toFloat(), winding) + @JvmOverloads + fun renderRaw( + graphics: GuiGraphics, + x: Double, + y: Double = 0.0, + width: Double = this.width.toDouble(), + height: Double = this.height.toDouble(), + winding: UVWindingOrder = this.winding + ) = renderRaw(graphics.pose(), x, y, width, height, winding) + @JvmOverloads fun renderRawPartial( stack: PoseStack, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GlitchRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GlitchRenderer.kt index 3de0eb99b..9a3fcf2cb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GlitchRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GlitchRenderer.kt @@ -4,10 +4,7 @@ import com.mojang.blaze3d.pipeline.MainTarget import com.mojang.blaze3d.platform.GlConst import com.mojang.blaze3d.platform.GlStateManager import com.mojang.blaze3d.systems.RenderSystem -import com.mojang.blaze3d.vertex.BufferBuilder -import com.mojang.blaze3d.vertex.BufferUploader -import com.mojang.blaze3d.vertex.DefaultVertexFormat -import com.mojang.blaze3d.vertex.VertexFormat +import com.mojang.blaze3d.vertex.* import net.minecraft.client.Minecraft import net.minecraft.client.renderer.FogRenderer import net.minecraft.client.renderer.GameRenderer @@ -151,7 +148,7 @@ object GlitchRenderer { val glitchBuffer = glitchBuffer val projection = RenderSystem.getProjectionMatrix() - RenderSystem.setProjectionMatrix(Matrix4f()) + RenderSystem.setProjectionMatrix(Matrix4f(), VertexSorting.ORTHOGRAPHIC_Z) RenderSystem.getModelViewStack().also { it.pushPose() @@ -247,7 +244,7 @@ object GlitchRenderer { RenderSystem.setShaderTexture(0, glitchBuffer.colorTextureId) draw(0.0, 0.0) - RenderSystem.setProjectionMatrix(projection) + RenderSystem.setProjectionMatrix(projection, VertexSorting.DISTANCE_TO_ORIGIN) RenderSystem.getModelViewStack().popPose() RenderSystem.applyModelViewMatrix() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt index 5cf4f4db5..44cd9fcbb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.client.render import com.mojang.blaze3d.platform.GlStateManager import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.* +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.renderer.GameRenderer import net.minecraft.client.renderer.RenderStateShard import net.minecraft.client.renderer.RenderStateShard.LineStateShard @@ -88,6 +89,15 @@ fun drawTexturedRect( uv: IUVCoords ) = drawTexturedRect(stack.last().pose(), x, y, width, height, uv.u0, uv.v0, uv.u1, uv.v1) +fun drawTexturedRect( + graphics: GuiGraphics, + x: Float, + y: Float, + width: Float, + height: Float, + uv: IUVCoords +) = drawTexturedRect(graphics.pose(), x, y, width, height, uv) + fun drawTexturedRect( stack: PoseStack, x: Float, @@ -100,6 +110,18 @@ fun drawTexturedRect( v1: Float ) = drawTexturedRect(stack.last().pose(), x, y, width, height, u0, v0, u1, v1) +fun drawTexturedRect( + graphics: GuiGraphics, + x: Float, + y: Float, + width: Float, + height: Float, + u0: Float, + v0: Float, + u1: Float, + v1: Float +) = drawTexturedRect(graphics.pose(), x, y, width, height, u0, v0, u1, v1) + fun drawTexturedRect( x: Float, y: Float, @@ -342,6 +364,15 @@ fun drawRect( color: RGBAColor = drawColor ) = drawRect(pose.last().pose(), x, y, width, height, color = color) +fun drawRect( + graphics: GuiGraphics, + x: Float, + y: Float, + width: Float, + height: Float, + color: RGBAColor = drawColor +) = drawRect(graphics.pose(), x, y, width, height, color = color) + fun drawRect( x: Float, y: Float, @@ -420,6 +451,16 @@ fun drawLine( color: RGBAColor = drawColor ) = drawLine(pose.last().pose(), startX, startY, endX, endY, width, color = color) +fun drawLine( + graphics: GuiGraphics, + startX: Float, + startY: Float, + endX: Float, + endY: Float, + width: Float, + color: RGBAColor = drawColor +) = drawLine(graphics.pose(), startX, startY, endX, endY, width, color = color) + fun drawLine( startX: Float, startY: Float, @@ -527,6 +568,15 @@ fun TextureAtlasSprite.render( } } +fun TextureAtlasSprite.render( + graphics: GuiGraphics, + x: Float = 0f, + y: Float = 0f, + width: Float, + height: Float, + winding: UVWindingOrder = UVWindingOrder.NORMAL +) = render(graphics.pose(), x, y, width, height, winding) + fun determineTooltipPosition(x: Float, y: Float, width: Float, height: Float): Pair { val windowWidth = minecraft.window.guiScaledWidth.toFloat() val windowHeight = minecraft.window.guiScaledHeight.toFloat() @@ -584,6 +634,9 @@ fun clearDepth(stack: PoseStack, x: Float, y: Float, width: Float, height: Float } } +@JvmOverloads +fun clearDepth(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, depth: Float = -500f) = ru.dbotthepony.mc.otm.client.render.clearDepth(graphics.pose(), x, y, width, height, depth) + fun drawArc( stack: PoseStack, x: Float, @@ -596,6 +649,17 @@ fun drawArc( alignAtCenter: Boolean = true ) = drawArc(stack.last().pose(), x, y, outerRadius, innerRadius, startDegree, endDegree, steps, alignAtCenter) +fun drawArc( + graphics: GuiGraphics, + x: Float, + y: Float, + outerRadius: Float, + innerRadius: Float = 0f, + startDegree: Double = 0.0, + endDegree: Double = PI * 2.0, + steps: Int = (outerRadius * (endDegree - startDegree) * 4.0).roundToInt().coerceAtLeast(12), + alignAtCenter: Boolean = true +) = drawArc(graphics.pose(), x, y, outerRadius, innerRadius, startDegree, endDegree, steps, alignAtCenter) fun uploadArc( matrix: Matrix4f, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/StretchingRectangleElement.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/StretchingRectangleElement.kt index 971011285..57e2835e6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/StretchingRectangleElement.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/StretchingRectangleElement.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.client.render import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.gui.GuiGraphics import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty @@ -43,6 +44,15 @@ data class StretchingRectangleElement( bottomRight.render(stack, x + width - bottomRight.width, y + height - bottomLeft.height) } + @JvmOverloads + fun render( + graphics: GuiGraphics, + x: Float = 0f, + y: Float = 0f, + width: Float, + height: Float, + ) = render(graphics.pose(), x, y, width, height) + companion object { fun square( texture: ResourceLocation, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt index c47c6e232..43447b8da 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.inventory.InventoryScreen import ru.dbotthepony.mc.otm.client.mousePos import ru.dbotthepony.mc.otm.client.moveMousePosScaled @@ -139,8 +140,8 @@ class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen(menu: T, inventory: Inventory, tit var mainFrame: FramePanel>? = null private var madeMainFrame = false - var itemRenderer: ItemRenderer - get() = itemRenderer - set(itemRenderer) { super.itemRenderer = itemRenderer } var font: Font get() = font set(font) { super.font = font } @@ -68,14 +66,13 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit val quickCraftingType get() = quickCraftingType val isQuickCrafting get() = isQuickCrafting - fun renderItemStack(poseStack: PoseStack, itemstack: ItemStack, countOverride: String? = null) { + fun renderItemStack(graphics: GuiGraphics, itemstack: ItemStack, countOverride: String? = null) { if (!itemstack.isEmpty) { RenderSystem.enableDepthTest() - val (x, y) = poseStack.translation() + val (x, y) = graphics.pose().translation() - itemRenderer.renderAndDecorateItem( - poseStack, + graphics.renderItem( requireNotNull(ru.dbotthepony.mc.otm.client.minecraft.player) { "yo, dude, what the fuck" }, itemstack, 1, @@ -84,8 +81,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit ) RenderSystem.depthFunc(GL11.GL_ALWAYS) - itemRenderer.renderGuiItemDecorations( - poseStack, + graphics.renderItemDecorations( font, itemstack, 1, @@ -465,7 +461,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit return super.keyPressed(key, scancode, mods) } - override fun renderBg(p_97787_: PoseStack, p_97788_: Float, p_97789_: Int, p_97790_: Int) {} + override fun renderBg(p_283065_: GuiGraphics, p_97788_: Float, p_97789_: Int, p_97790_: Int) {} var returnSlot: Slot? = null @@ -498,12 +494,12 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit return false } - override fun render(poseStack: PoseStack, mouseX: Int, mouseY: Int, partialTick: Float) { + override fun render(graphics: GuiGraphics, mouseX: Int, mouseY: Int, partialTick: Float) { val mouseXf = mouseX.toFloat() val mouseYf = mouseY.toFloat() // dark background - this.renderBackground(poseStack) + this.renderBackground(graphics) hoveredSlot = null var hovered = false @@ -524,21 +520,21 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit val panel = panels[i] RenderSystem.depthFunc(GL11.GL_ALWAYS) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) - panel.render(poseStack, mouseXf, mouseYf, partialTick) + panel.render(graphics, mouseXf, mouseYf, partialTick) } RenderSystem.depthFunc(GL11.GL_LESS) - MinecraftForge.EVENT_BUS.post(Background(this, poseStack, mouseX, mouseY)) + MinecraftForge.EVENT_BUS.post(Background(this, graphics, mouseX, mouseY)) RenderSystem.disableDepthTest() // Screen.super.render for (widget in renderables) { - widget.render(poseStack, mouseX, mouseY, partialTick) + widget.render(graphics, mouseX, mouseY, partialTick) } // /Screen.super.render RenderSystem.disableDepthTest() - MinecraftForge.EVENT_BUS.post(Foreground(this, poseStack, mouseX, mouseY)) + MinecraftForge.EVENT_BUS.post(Foreground(this, graphics, mouseX, mouseY)) var itemstack = if (draggingItem.isEmpty) menu.carried else draggingItem @@ -556,19 +552,19 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } @Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") - renderFloatingItem(poseStack, itemstack, mouseX - 8, mouseY - i2, overrideCount) + renderFloatingItem(graphics, itemstack, mouseX - 8, mouseY - i2, overrideCount) } if (menu.carried.isEmpty) { val hoveredSlot = hoveredSlot if (hoveredSlot != null && hoveredSlot.hasItem()) { - this.renderTooltip(poseStack, hoveredSlot.item, mouseX, mouseY) + this.renderTooltip(graphics, mouseX, mouseY) } else { for (panel in panels) { RenderSystem.disableDepthTest() - if (panel.renderTooltips(poseStack, mouseXf, mouseYf, partialTick)) { + if (panel.renderTooltips(graphics, mouseXf, mouseYf, partialTick)) { break } } 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 abd5f9717..c322ffbc0 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 @@ -788,7 +788,7 @@ open class EditablePanel @JvmOverloads constructor( if (currentScissorRect == null || currentScissorRect.crossScaled(absoluteX, absoluteY, width, height)) { // do not render if we are getting cut off by screen scissor - clearDepth(poseStack, absoluteX, absoluteY, width, height) + clearDepth(graphics, absoluteX, absoluteY, width, height) poseStack.pushPose() poseStack.translate(absoluteX.toDouble(), absoluteY.toDouble(), 10.0) RenderSystem.setShaderColor(1f, 1f, 1f, if (isFlashFrameRecursive) 0.5f else 1f) @@ -1708,7 +1708,7 @@ open class EditablePanel @JvmOverloads constructor( /** * See [ru.dbotthepony.mc.otm.client.render.clearDepth] */ - fun clearDepth(stack: PoseStack, x: Float = 0f, y: Float = 0f, width: Float = this.width, height: Float = this.height) = ru.dbotthepony.mc.otm.client.render.clearDepth(stack, x, y, width, height) + fun clearDepth(graphics: GuiGraphics, x: Float = 0f, y: Float = 0f, width: Float = this.width, height: Float = this.height) = ru.dbotthepony.mc.otm.client.render.clearDepth(graphics, x, y, width, height) fun queryUser(title: Component, text: Component, onConfirm: Runnable, onCancel: Runnable? = null): QueryUserPanel { return QueryUserPanel(screen, title, listOf(text), onConfirm, onCancel).also { blockingWindow = it } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt index 7bd50c44a..bd84d5141 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt @@ -4,6 +4,7 @@ import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap import it.unimi.dsi.fastutil.objects.Object2ObjectFunction +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen import net.minecraft.world.effect.MobEffect @@ -109,29 +110,29 @@ open class EffectListPanel @JvmOverloads constructor( } } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - clearDepth(stack) - SQUARE_THIN.render(stack, width = width, height = height) + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + clearDepth(graphics) + SQUARE_THIN.render(graphics, width = width, height = height) RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f) - minecraft.mobEffectTextures.get(effect.effect).render(stack, x = 3f, y = 3f, width = width - 6f, height = height - 6f) + minecraft.mobEffectTextures.get(effect.effect).render(graphics, x = 3f, y = 3f, width = width - 6f, height = height - 6f) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) - font.drawScaledAligned(stack, formatTickDuration(effect.duration), 0.75f, TextAlign.CENTER_CENTER, width / 2f - 1f, height / 2f, RGBAColor.WHITE) + graphics.drawScaledAligned(font, formatTickDuration(effect.duration), 0.75f, TextAlign.CENTER_CENTER, width / 2f - 1f, height / 2f, RGBAColor.WHITE) } - override fun innerRenderTooltips(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { if (isHovered) { val (x, y) = determineTooltipPosition(mouseX + 4f, mouseY - 12f, BAR.width, BAR.height) - BAR.clearDepth(stack, x, y) - BAR.render(stack, x, y) + BAR.clearDepth(graphics, x, y) + BAR.render(graphics, x, y) val renderWidth = 18f val renderHeight = 18f minecraft.mobEffectTextures.get(effect.effect).render( - stack, + graphics.pose(), x = x + 8f, y = y + BAR.height / 2f - renderHeight / 2f, width = renderWidth, @@ -145,8 +146,8 @@ open class EffectListPanel @JvmOverloads constructor( name.append(" ${effect.amplifier + 1}") } - font.drawAligned(stack, name, TextAlign.TOP_LEFT, x + renderWidth + 12f, y + 7f, RGBAColor.WHITE) - font.drawAligned(stack, formatTickDuration(effect.duration, true), TextAlign.TOP_LEFT, x + renderWidth + 12f, y + 7f + font.lineHeight + 2f, 8355711) + graphics.drawAligned(font, name, TextAlign.TOP_LEFT, x + renderWidth + 12f, y + 7f, RGBAColor.WHITE) + graphics.drawAligned(font, formatTickDuration(effect.duration, true), TextAlign.TOP_LEFT, x + renderWidth + 12f, y + 7f + font.lineHeight + 2f, 8355711) } return isHovered diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt index f28649596..06734b95c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt @@ -125,7 +125,7 @@ class EntityRendererPanel @JvmOverloads constructor( } override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { - ExoPackInventoryScreen.ENTITY_RECTANGLE.render(graphics.pose()) + ExoPackInventoryScreen.ENTITY_RECTANGLE.render(graphics) } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index 7d87a340b..d1f9e24cb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -59,37 +59,37 @@ open class FramePanel( if (isActive) { width = TAB_WIDTH_ACTIVE height = TAB_HEIGHT_ACTIVE - RECTANGLE.middle.render(stack, 2f, 2f, width - 4, height - 2) + RECTANGLE.middle.render(graphics, 2f, 2f, width - 4, height - 2) } else { width = TAB_WIDTH height = TAB_HEIGHT - TAB_BACKGROUND.render(stack, 2f, 2f, width - 4, height - 2) + TAB_BACKGROUND.render(graphics, 2f, 2f, width - 4, height - 2) } - RECTANGLE.top.renderWidth(stack, 3f, 0f, width - 6) - RECTANGLE.left.renderHeight(stack, 0f, 3f, (height - if (isActive) if (initial) 2 else 4 else 3)) + RECTANGLE.top.renderWidth(graphics, 3f, 0f, width - 6) + RECTANGLE.left.renderHeight(graphics, 0f, 3f, (height - if (isActive) if (initial) 2 else 4 else 3)) - RECTANGLE.right.renderHeight(stack, width - RECTANGLE.right.width, 3f, (height - if (isActive) 4 else 3)) + RECTANGLE.right.renderHeight(graphics, width - RECTANGLE.right.width, 3f, (height - if (isActive) 4 else 3)) - RECTANGLE.topLeft.render(stack, 0f, 0f) - RECTANGLE.topRight.render(stack, width - RECTANGLE.topRight.width, 0f) + RECTANGLE.topLeft.render(graphics, 0f, 0f) + RECTANGLE.topRight.render(graphics, width - RECTANGLE.topRight.width, 0f) if (isActive) { if (!initial) { - TAB_LEFT_CONNECTION.render(stack, 0f, height - TAB_LEFT_CONNECTION.height - 1) + TAB_LEFT_CONNECTION.render(graphics, 0f, height - TAB_LEFT_CONNECTION.height - 1) } TAB_RIGHT_CONNECTION.render( - stack, + graphics, width - TAB_RIGHT_CONNECTION.width, height - TAB_LEFT_CONNECTION.height - 1 ) val skinActive = activeIcon ?: return - skinActive.render(stack, TAB_WIDTH_ACTIVE / 2f - skinActive.width / 2f, TAB_HEIGHT_ACTIVE / 2f - skinActive.height / 2f) + skinActive.render(graphics, TAB_WIDTH_ACTIVE / 2f - skinActive.width / 2f, TAB_HEIGHT_ACTIVE / 2f - skinActive.height / 2f) } else { val skinInactive = inactiveIcon ?: return - skinInactive.render(stack, width / 2f - skinInactive.width / 2f, TAB_HEIGHT_ACTIVE / 2f - skinInactive.height / 2f) + skinInactive.render(graphics, width / 2f - skinInactive.width / 2f, TAB_HEIGHT_ACTIVE / 2f - skinInactive.height / 2f) } } @@ -197,12 +197,12 @@ open class FramePanel( } override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { - RECTANGLE.render(graphics.pose(), width = width, height = height) + RECTANGLE.render(graphics, width = width, height = height) // title val title = title ?: return RenderSystem.depthFunc(GL30.GL_ALWAYS) - font.drawAligned(graphics.pose(), title, TextAlign.TOP_LEFT, 8f, 5f, 4210752) + graphics.drawAligned(font, title, TextAlign.TOP_LEFT, 8f, 5f, 4210752) RenderSystem.depthFunc(GL30.GL_ALWAYS) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt index cb899da0c..a67574e2d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt @@ -32,19 +32,19 @@ open class Label @JvmOverloads constructor( var align = TextAlign.TOP_LEFT override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { - clearDepth(graphics.pose()) + clearDepth(graphics) if (shadow) { when (align) { - TextAlign.TOP_LEFT -> font.drawAligned(graphics.pose(), text, align, shadowX, shadowY, shadowColor.toInt()) - TextAlign.TOP_CENTER -> font.drawAligned(graphics.pose(), text, align, shadowX + width / 2f, shadowY, shadowColor.toInt()) - TextAlign.TOP_RIGHT -> font.drawAligned(graphics.pose(), text, align, shadowX + width, shadowY, shadowColor.toInt()) - TextAlign.CENTER_LEFT -> font.drawAligned(graphics.pose(), text, align, shadowX, height / 2f + shadowY, shadowColor.toInt()) - TextAlign.CENTER_CENTER -> font.drawAligned(graphics.pose(), text, align, shadowX + width / 2f, height / 2f + shadowY, shadowColor.toInt()) - TextAlign.CENTER_RIGHT -> font.drawAligned(graphics.pose(), text, align, shadowX + width, height / 2f + shadowY, shadowColor.toInt()) - TextAlign.BOTTOM_LEFT -> font.drawAligned(graphics.pose(), text, align, shadowX, height + shadowY, shadowColor.toInt()) - TextAlign.BOTTOM_CENTER -> font.drawAligned(graphics.pose(), text, align, shadowX + width / 2f, height + shadowY, shadowColor.toInt()) - TextAlign.BOTTOM_RIGHT -> font.drawAligned(graphics.pose(), text, align, shadowX + width, height + shadowY, shadowColor.toInt()) + TextAlign.TOP_LEFT -> graphics.drawAligned(font, text, align, shadowX, shadowY, shadowColor.toInt()) + TextAlign.TOP_CENTER -> graphics.drawAligned(font, text, align, shadowX + width / 2f, shadowY, shadowColor.toInt()) + TextAlign.TOP_RIGHT -> graphics.drawAligned(font, text, align, shadowX + width, shadowY, shadowColor.toInt()) + TextAlign.CENTER_LEFT -> graphics.drawAligned(font, text, align, shadowX, height / 2f + shadowY, shadowColor.toInt()) + TextAlign.CENTER_CENTER -> graphics.drawAligned(font, text, align, shadowX + width / 2f, height / 2f + shadowY, shadowColor.toInt()) + TextAlign.CENTER_RIGHT -> graphics.drawAligned(font, text, align, shadowX + width, height / 2f + shadowY, shadowColor.toInt()) + TextAlign.BOTTOM_LEFT -> graphics.drawAligned(font, text, align, shadowX, height + shadowY, shadowColor.toInt()) + TextAlign.BOTTOM_CENTER -> graphics.drawAligned(font, text, align, shadowX + width / 2f, height + shadowY, shadowColor.toInt()) + TextAlign.BOTTOM_RIGHT -> graphics.drawAligned(font, text, align, shadowX + width, height + shadowY, shadowColor.toInt()) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Widget2Panel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Widget2Panel.kt index c20095400..0b25469ee 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Widget2Panel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Widget2Panel.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.components.AbstractWidget import net.minecraft.client.gui.screens.Screen import org.lwjgl.opengl.GL11 @@ -89,9 +90,9 @@ abstract class Widget2Panel( return instance } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { RenderSystem.depthFunc(GL11.GL_ALWAYS) - getOrCreateWidget().render(stack, mouseX.toInt(), mouseY.toInt(), partialTick) + getOrCreateWidget().render(graphics, mouseX.toInt(), mouseY.toInt(), partialTick) RenderSystem.depthFunc(GL11.GL_ALWAYS) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt index 2afbdf2fd..d2a2ceb29 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.ChatFormatting +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.client.minecraft @@ -32,7 +33,7 @@ abstract class BooleanRectangleButtonPanel( onChange?.invoke(newValue) } - override fun innerRenderTooltips(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { if (isHovered) { val tooltipActive = tooltipActive val tooltipInactive = tooltipInactive @@ -62,11 +63,11 @@ abstract class BooleanRectangleButtonPanel( tooltips.add(tooltipInactive.copy().withStyle(if (!prop.get()) ChatFormatting.WHITE else ChatFormatting.GRAY)) } - screen.renderComponentTooltip(stack, tooltips, mouseX.toInt(), mouseY.toInt(), font) + graphics.renderComponentTooltip(font, tooltips, mouseX.toInt(), mouseY.toInt()) } } - return super.innerRenderTooltips(stack, mouseX, mouseY, partialTick) + return super.innerRenderTooltips(graphics, mouseX, mouseY, partialTick) } override var isDisabled: Boolean @@ -79,13 +80,13 @@ abstract class BooleanRectangleButtonPanel( } set(value) { super.isDisabled = value } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - super.innerRender(stack, mouseX, mouseY, partialTick) + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + super.innerRender(graphics, mouseX, mouseY, partialTick) if (prop.value) { - skinElementActive?.render(stack, width = width, height = height) + skinElementActive?.render(graphics, width = width, height = height) } else { - skinElementInactive?.render(stack, width = width, height = height) + skinElementInactive?.render(graphics, width = width, height = height) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt index ac07c680c..43d4485e0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.client.playGuiClickSound @@ -40,21 +41,21 @@ open class ButtonPanel( onPress?.accept(mouseButton) } - protected fun renderStretchableBackground(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + protected fun renderStretchableBackground(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (isDisabled) { - Widgets18.BUTTON_DISABLED_STRETCHABLE.render(stack, width = width, height = height) + Widgets18.BUTTON_DISABLED_STRETCHABLE.render(graphics, width = width, height = height) } else if (isPressed) { - Widgets18.BUTTON_PRESSED_STRETCHABLE.render(stack, width = width, height = height) + Widgets18.BUTTON_PRESSED_STRETCHABLE.render(graphics, width = width, height = height) } else if (isHovered) { - Widgets18.BUTTON_HOVERED_STRETCHABLE.render(stack, width = width, height = height) + Widgets18.BUTTON_HOVERED_STRETCHABLE.render(graphics, width = width, height = height) } else { - Widgets18.BUTTON_IDLE_STRETCHABLE.render(stack, width = width, height = height) + Widgets18.BUTTON_IDLE_STRETCHABLE.render(graphics, width = width, height = height) } } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - renderStretchableBackground(stack, mouseX, mouseY, partialTick) - font.drawAligned(stack, label, TextAlign.CENTER_CENTER, width / 2f, height / 2f, textColor.toInt()) + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + renderStretchableBackground(graphics, mouseX, mouseY, partialTick) + graphics.drawAligned(font, label, TextAlign.CENTER_CENTER, width / 2f, height / 2f, textColor.toInt()) } override fun sizeToContents() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt index a0281a043..8cb9bc42b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.vertex.PoseStack import it.unimi.dsi.fastutil.booleans.BooleanConsumer +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite @@ -30,38 +31,38 @@ open class CheckBoxPanel @JvmOverloads constructor( open val DISABLED_UNCHECKED: AbstractMatterySprite = Companion.DISABLED_UNCHECKED open val DISABLED_CHECKED: AbstractMatterySprite = Companion.DISABLED_CHECKED - protected fun renderCheckboxBackground(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + protected fun renderCheckboxBackground(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (isDisabled) { if (isChecked) { - DISABLED_CHECKED.render(stack, width = width, height = height) + DISABLED_CHECKED.render(graphics, width = width, height = height) } else { - DISABLED_UNCHECKED.render(stack, width = width, height = height) + DISABLED_UNCHECKED.render(graphics, width = width, height = height) } } else { if (isPressed) { if (isChecked) { - PRESSED_CHECKED.render(stack, width = width, height = height) + PRESSED_CHECKED.render(graphics, width = width, height = height) } else { - PRESSED_UNCHECKED.render(stack, width = width, height = height) + PRESSED_UNCHECKED.render(graphics, width = width, height = height) } } else if (isHovered) { if (isChecked) { - HOVERED_CHECKED.render(stack, width = width, height = height) + HOVERED_CHECKED.render(graphics, width = width, height = height) } else { - HOVERED_UNCHECKED.render(stack, width = width, height = height) + HOVERED_UNCHECKED.render(graphics, width = width, height = height) } } else { if (isChecked) { - IDLE_CHECKED.render(stack, width = width, height = height) + IDLE_CHECKED.render(graphics, width = width, height = height) } else { - IDLE_UNCHECKED.render(stack, width = width, height = height) + IDLE_UNCHECKED.render(graphics, width = width, height = height) } } } } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - renderCheckboxBackground(stack, mouseX, mouseY, partialTick) + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + renderCheckboxBackground(graphics, mouseX, mouseY, partialTick) } override fun onClick(mouseButton: Int) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt index 894809386..83be28cdd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.ChatFormatting +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.client.minecraft @@ -74,11 +75,11 @@ abstract class EnumRectangleButtonPanel>( return this } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { check(!isBuilding) { "Still building this button!" } - super.innerRender(stack, mouseX, mouseY, partialTick) + super.innerRender(graphics, mouseX, mouseY, partialTick) val entry = enumMapping[prop.get()] ?: return - entry.skinElement?.render(stack, 0f, 0f, width, height, entry.winding) + entry.skinElement?.render(graphics, 0f, 0f, width, height, entry.winding) } override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { @@ -148,13 +149,13 @@ abstract class EnumRectangleButtonPanel>( } } - override fun innerRenderTooltips(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { if (!isHovered && !isGrabbingMouseInput()) { - return super.innerRenderTooltips(stack, mouseX, mouseY, partialTick) + return super.innerRenderTooltips(graphics, mouseX, mouseY, partialTick) } if (tooltip == null && tooltipList == null && enumMapping.entries.none { predicate.test(it.key) && it.value.tooltip != null }) { - return super.innerRenderTooltips(stack, mouseX, mouseY, partialTick) + return super.innerRenderTooltips(graphics, mouseX, mouseY, partialTick) } val listing = ArrayList() @@ -175,7 +176,7 @@ abstract class EnumRectangleButtonPanel>( } } - screen.renderComponentTooltip(stack, listing, mouseX.toInt(), mouseY.toInt(), font) + graphics.renderComponentTooltip(font, listing, mouseX.toInt(), mouseY.toInt()) return true } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt index ab8f0f553..f7a11ca8a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.UVWindingOrder @@ -23,13 +24,13 @@ open class LargeRectangleButtonPanel( final override val PRESSED = Widgets18.BUTTON_PRESSED final override val DISABLED = Widgets18.BUTTON_DISABLED - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - super.innerRender(stack, mouseX, mouseY, partialTick) + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + super.innerRender(graphics, mouseX, mouseY, partialTick) if (skinElementWinding != null) { - skinElement?.render(stack, width = width, height = height, winding = skinElementWinding) + skinElement?.render(graphics, width = width, height = height, winding = skinElementWinding) } else { - skinElement?.render(stack, width = width, height = height) + skinElement?.render(graphics, width = width, height = height) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/RectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/RectangleButtonPanel.kt index 6a72b0dc7..980beb7be 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/RectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/RectangleButtonPanel.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite @@ -27,19 +28,19 @@ abstract class RectangleButtonPanel( onPress?.accept(mouseButton) } - protected fun renderSquareButton(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + protected fun renderSquareButton(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (isDisabled) { - DISABLED.render(stack, 0f, 0f, width, height) + DISABLED.render(graphics, 0f, 0f, width, height) } else if (isPressed) { - PRESSED.render(stack, 0f, 0f, width, height) + PRESSED.render(graphics, 0f, 0f, width, height) } else if (isHovered) { - HOVERED.render(stack, 0f, 0f, width, height) + HOVERED.render(graphics, 0f, 0f, width, height) } else { - IDLE.render(stack, 0f, 0f, width, height) + IDLE.render(graphics, 0f, 0f, width, height) } } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - renderSquareButton(stack, mouseX, mouseY, partialTick) + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + renderSquareButton(graphics, mouseX, mouseY, partialTick) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallRectangleButtonPanel.kt index 42d9addca..2bb972a17 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallRectangleButtonPanel.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.render.MatterySprite import ru.dbotthepony.mc.otm.client.render.UVWindingOrder @@ -23,13 +24,13 @@ open class SmallRectangleButtonPanel( final override val PRESSED = Widgets8.BUTTON_PRESSED final override val DISABLED = Widgets8.BUTTON_DISABLED - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - super.innerRender(stack, mouseX, mouseY, partialTick) + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + super.innerRender(graphics, mouseX, mouseY, partialTick) if (skinElementWinding != null) { - skinElement?.render(stack, width = width, height = height, winding = skinElementWinding) + skinElement?.render(graphics, width = width, height = height, winding = skinElementWinding) } else { - skinElement?.render(stack, width = width, height = height) + skinElement?.render(graphics, width = width, height = height) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt index f952c9ae9..234446ab2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt @@ -10,6 +10,7 @@ import it.unimi.dsi.fastutil.chars.Char2IntOpenHashMap import it.unimi.dsi.fastutil.chars.CharOpenHashSet import it.unimi.dsi.fastutil.ints.Int2ObjectAVLTreeMap import it.unimi.dsi.fastutil.ints.Int2ObjectMap +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.client.renderer.GameRenderer import net.minecraft.network.chat.Component @@ -1071,9 +1072,9 @@ open class TextInputPanel( return accumulate } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (!backgroundColor.isFullyTransparent) - drawRect(stack, 0f, 0f, width, height, backgroundColor) + drawRect(graphics, 0f, 0f, width, height, backgroundColor) var topPadding = dockPadding.top @@ -1107,15 +1108,16 @@ open class TextInputPanel( scrollPixels = 0f } + val stack = graphics.pose() + stack.pushPose() stack.translate(-scrollPixels, 0f, 0f) var y = topPadding if (lines.isEmpty() || lines.size == 1 && lines[0] == "") { - font.drawAligned( - poseStack = stack, - buffer = BUFFER, + graphics.drawAligned( + font = font, text = placeholder, align = TextAlign.TOP_LEFT, x = dockPadding.left, @@ -1128,9 +1130,8 @@ open class TextInputPanel( val line = lines[i] val selection = selections[i] - font.drawAligned( - poseStack = stack, - buffer = BUFFER, + graphics.drawAligned( + font = font, text = line, align = TextAlign.TOP_LEFT, x = dockPadding.left, @@ -1182,9 +1183,8 @@ open class TextInputPanel( val activeLine = this[cursorLine] if (activeLine == null || cursorRow >= activeLine.length) { - font.drawAligned( - poseStack = stack, - buffer = BUFFER, + graphics.drawAligned( + font = font, text = "_", align = TextAlign.TOP_LEFT, x = dockPadding.left + (if (activeLine == null) 0f else font.width(activeLine).toFloat()), @@ -1192,9 +1192,8 @@ open class TextInputPanel( color = cursorColor ) } else { - font.drawAligned( - poseStack = stack, - buffer = BUFFER, + graphics.drawAligned( + font = font, text = "|", align = TextAlign.TOP_LEFT, x = dockPadding.left + font.width(activeLine.substring(0, cursorRow)).toFloat() - 1f, @@ -1207,9 +1206,8 @@ open class TextInputPanel( stack.popPose() if (debugDraw) { - font.drawAligned( - poseStack = stack, - buffer = BUFFER, + graphics.drawAligned( + font = font, text = cursorLine.toString(), align = TextAlign.TOP_RIGHT, x = width, @@ -1217,9 +1215,8 @@ open class TextInputPanel( color = cursorColor ) - font.drawAligned( - poseStack = stack, - buffer = BUFFER, + graphics.drawAligned( + font = font, text = cursorRow.toString(), align = TextAlign.TOP_RIGHT, x = width - dockPadding.right, @@ -1227,9 +1224,8 @@ open class TextInputPanel( color = cursorColor ) - font.drawAligned( - poseStack = stack, - buffer = BUFFER, + graphics.drawAligned( + font = font, text = lines.size.toString(), align = TextAlign.TOP_RIGHT, x = width - dockPadding.right, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt index 305536dd5..e90c7aef0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt @@ -2,6 +2,8 @@ package ru.dbotthepony.mc.otm.client.screen.panels.slot import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.gui.GuiGraphics +import net.minecraft.client.gui.screens.Screen.getTooltipFromItem import net.minecraft.client.renderer.GameRenderer import net.minecraft.network.chat.Component import net.minecraft.world.item.ItemStack @@ -21,51 +23,50 @@ abstract class AbstractSlotPanel> @JvmOverloads constru height: Float = SIZE, open val noItemIcon: MatterySprite? = null ) : EditablePanel(screen, parent, x, y, width, height), IItemStackPanel { - protected open fun renderSlotBackground(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - SLOT_BACKGROUND.render(stack, width = width, height = height) + protected open fun renderSlotBackground(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + SLOT_BACKGROUND.render(graphics, width = width, height = height) } - protected open fun renderRegular(stack: PoseStack, itemstack: ItemStack, countOverride: String? = null) { + protected open fun renderRegular(graphics: GuiGraphics, itemstack: ItemStack, countOverride: String? = null) { RenderSystem.setShader(GameRenderer::getPositionTexShader) if (!itemstack.isEmpty) { - screen.renderItemStack(stack, itemstack, countOverride) - clearDepth(stack) + screen.renderItemStack(graphics, itemstack, countOverride) + clearDepth(graphics) } if (isHovered) { drawColor = SLOT_HIGHLIGHT - drawRect(stack, 1f, 1f, width - 1, height - 1) + drawRect(graphics, 1f, 1f, width - 1, height - 1) } } protected open fun getItemStackTooltip(stack: ItemStack): List { - return screen.getTooltipFromItem(stack) + return getTooltipFromItem(ru.dbotthepony.mc.otm.client.minecraft, stack) } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - renderSlotBackground(stack, mouseX, mouseY, partialTick) + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + renderSlotBackground(graphics, mouseX, mouseY, partialTick) val itemStack = itemStack - renderRegular(stack, itemStack) + renderRegular(graphics, itemStack) if (itemStack.isEmpty) { - noItemIcon?.render(stack, width = width, height = height) + noItemIcon?.render(graphics, width = width, height = height) } } - override fun innerRenderTooltips(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { if (isHovered) { val itemstack = itemStack if (!itemstack.isEmpty) { val font = IClientItemExtensions.of(itemstack).getFont(itemstack, IClientItemExtensions.FontContext.TOOLTIP) - screen.renderComponentTooltip( - stack, + graphics.renderComponentTooltip( + font ?: screen.font, getItemStackTooltip(itemstack), mouseX.toInt(), mouseY.toInt(), - font ?: screen.font, itemstack ) 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 05b1efef6..ab5ca2056 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 @@ -5,7 +5,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.slot import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.ChatFormatting -import net.minecraft.client.gui.GuiComponent +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.renderer.GameRenderer import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.inventory.Slot @@ -56,10 +56,10 @@ open class SlotPanel, out T : Slot> @JvmOverloads const } } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { slot.x = absoluteX.roundToInt() - screen.guiLeft slot.y = absoluteY.roundToInt() - screen.guiTop - renderSlotBackground(stack, mouseX, mouseY, partialTick) + renderSlotBackground(graphics, mouseX, mouseY, partialTick) var itemstack = slot.item val carried = screen.menu.carried @@ -75,11 +75,10 @@ open class SlotPanel, out T : Slot> @JvmOverloads const itemstack = carried.copy() dragHit = true - AbstractContainerMenu.getQuickCraftSlotCount( + AbstractContainerMenu.getQuickCraftPlaceCount( screen.quickCraftSlots, screen.quickCraftingType, - itemstack, - if (slot.item.isEmpty) 0 else slot.item.count + itemstack ) val k = Math.min(itemstack.maxStackSize, slot.getMaxStackSize(itemstack)) @@ -97,7 +96,7 @@ open class SlotPanel, out T : Slot> @JvmOverloads const if (dragHit) { setDrawColor(SLOT_HIGHLIGHT_DRAG) - drawRect(stack, 1f, 1f, width - 1, height - 1) + drawRect(graphics, 1f, 1f, width - 1, height - 1) } if (itemstack.isEmpty) { @@ -106,20 +105,20 @@ 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()) - GuiComponent.blit(stack, 1, 1, 0, 16, 16, texture) + graphics.blit(1, 1, 0, 16, 16, texture) } else { - noItemIcon?.render(stack, width = width, height = height) + noItemIcon?.render(graphics, width = width, height = height) } } - renderRegular(stack, itemstack, countOverride) + renderRegular(graphics, itemstack, countOverride) if (isHovered) { screen.hoveredSlot = slot } } - override fun innerRenderTooltips(@Nonnull stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun innerRenderTooltips(@Nonnull graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { // no op, screen does it for us (completely) return false } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt index d9819d6ba..d38a4f77e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.slot import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.ChatFormatting +import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component import net.minecraft.world.inventory.Slot import net.minecraft.world.item.Item @@ -35,31 +36,31 @@ abstract class UserFilteredSlotPanel, out T : Slot>( ) : SlotPanel(screen, parent, slot, x, y, width, height, noItemIcon) { abstract var slotFilter: Item? - override fun renderSlotBackground(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - super.renderSlotBackground(stack, mouseX, mouseY, partialTick) + override fun renderSlotBackground(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + super.renderSlotBackground(graphics, mouseX, mouseY, partialTick) if (slotFilter != null) { if (slotFilter !== Items.AIR) { val itemStack = ItemStack(slotFilter!!, 1) - screen.renderItemStack(stack, itemStack, null) - clearDepth(stack) + screen.renderItemStack(graphics, itemStack, null) + clearDepth(graphics) drawColor = SLOT_FILTER_COLOR } else { drawColor = SLOT_BLOCK_COLOR } - drawRect(stack, 0f, 0f, width, height) + drawRect(graphics, 0f, 0f, width, height) } } - override fun innerRenderTooltips(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { if (isHovered && slotFilter != null && slotFilter !== Items.AIR && itemStack.isEmpty) { val itemstack = ItemStack(slotFilter!!, 1) - screen.renderComponentTooltip( - stack, + graphics.renderComponentTooltip( + IClientItemExtensions.of(itemstack).getFont(itemstack, IClientItemExtensions.FontContext.TOOLTIP) ?: font, getItemStackTooltip(itemstack).toMutableList().also { it.add(0, TranslatableComponent("otm.gui.slot_filter.filtered").withStyle(ChatFormatting.GRAY)) it.add(1, TranslatableComponent("otm.gui.slot_filter.hint").withStyle(ChatFormatting.GRAY)) @@ -67,23 +68,21 @@ abstract class UserFilteredSlotPanel, out T : Slot>( }, mouseX.toInt(), mouseY.toInt(), - IClientItemExtensions.of(itemstack).getFont(itemstack, IClientItemExtensions.FontContext.TOOLTIP) ?: screen.font, itemstack ) } else if (isHovered && slotFilter === Items.AIR && itemStack.isEmpty) { - screen.renderComponentTooltip( - stack, + graphics.renderComponentTooltip( + font, ArrayList().also { it.add(TranslatableComponent("otm.gui.slot_filter.forbidden").withStyle(ChatFormatting.GRAY)) it.add(TranslatableComponent("otm.gui.slot_filter.hint").withStyle(ChatFormatting.GRAY)) }, mouseX.toInt(), - mouseY.toInt(), - screen.font + mouseY.toInt() ) } - return super.innerRenderTooltips(stack, mouseX, mouseY, partialTick) + return super.innerRenderTooltips(graphics, mouseX, mouseY, partialTick) } override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/AnalogScrollBarPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/AnalogScrollBarPanel.kt index 549d7841d..3338d0506 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/AnalogScrollBarPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/AnalogScrollBarPanel.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.util import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel @@ -26,26 +27,26 @@ open class AnalogScrollBarPanel( var isScrolling = false private set - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (this@AnalogScrollBarPanel.width == ScrollBarConstants.SLIM_WIDTH) { if (isScrolling) { - ScrollBarConstants.SLIM_BUTTON_PRESS.render(stack, width = width, height = height) + ScrollBarConstants.SLIM_BUTTON_PRESS.render(graphics, width = width, height = height) } else if (maxScroll.invoke(this@AnalogScrollBarPanel) <= 0) { - ScrollBarConstants.SLIM_BUTTON_DISABLED.render(stack, width = width, height = height) + ScrollBarConstants.SLIM_BUTTON_DISABLED.render(graphics, width = width, height = height) } else if (isHovered) { - ScrollBarConstants.SLIM_BUTTON_HOVER.render(stack, width = width, height = height) + ScrollBarConstants.SLIM_BUTTON_HOVER.render(graphics, width = width, height = height) } else { - ScrollBarConstants.SLIM_BUTTON.render(stack, width = width, height = height) + ScrollBarConstants.SLIM_BUTTON.render(graphics, width = width, height = height) } } else { if (isScrolling) { - ScrollBarConstants.BUTTON_PRESS.render(stack, width = width, height = height) + ScrollBarConstants.BUTTON_PRESS.render(graphics, width = width, height = height) } else if (maxScroll.invoke(this@AnalogScrollBarPanel) <= 0) { - ScrollBarConstants.BUTTON_DISABLED.render(stack, width = width, height = height) + ScrollBarConstants.BUTTON_DISABLED.render(graphics, width = width, height = height) } else if (isHovered) { - ScrollBarConstants.BUTTON_HOVER.render(stack, width = width, height = height) + ScrollBarConstants.BUTTON_HOVER.render(graphics, width = width, height = height) } else { - ScrollBarConstants.BUTTON.render(stack, width = width, height = height) + ScrollBarConstants.BUTTON.render(graphics, width = width, height = height) } } } @@ -98,15 +99,15 @@ open class AnalogScrollBarPanel( private var lastRender = milliTimeD - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (width == ScrollBarConstants.SLIM_WIDTH) { - ScrollBarConstants.SLIM_BODY.render(stack, y = 2f, height = height - 4f) - ScrollBarConstants.SLIM_TOP.render(stack) - ScrollBarConstants.SLIM_BOTTOM.render(stack, y = height - 2f) + ScrollBarConstants.SLIM_BODY.render(graphics, y = 2f, height = height - 4f) + ScrollBarConstants.SLIM_TOP.render(graphics) + ScrollBarConstants.SLIM_BOTTOM.render(graphics, y = height - 2f) } else { - ScrollBarConstants.BODY.render(stack, y = 2f, height = height - 4f) - ScrollBarConstants.TOP.render(stack) - ScrollBarConstants.BOTTOM.render(stack, y = height - 2f) + ScrollBarConstants.BODY.render(graphics, y = 2f, height = height - 4f) + ScrollBarConstants.TOP.render(graphics) + ScrollBarConstants.BOTTOM.render(graphics, y = height - 2f) } val time = milliTimeD diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/BackgroundPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/BackgroundPanel.kt index 9c95e6a1b..e36c41bf6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/BackgroundPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/BackgroundPanel.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.util import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.render.StretchingRectangleElement import ru.dbotthepony.mc.otm.client.render.WidgetLocation @@ -19,8 +20,8 @@ open class BackgroundPanel( dockPadding = DockProperty(3f, 3f, 3f, 3f) } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - RECTANGLE.render(stack, width = width, height = height) + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + RECTANGLE.render(graphics, width = width, height = height) } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/DiscreteScrollBarPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/DiscreteScrollBarPanel.kt index 43c06c6aa..c5944e053 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/DiscreteScrollBarPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/DiscreteScrollBarPanel.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.util import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import kotlin.math.roundToInt @@ -20,26 +21,26 @@ open class DiscreteScrollBarPanel( var isScrolling = false private set - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (this@DiscreteScrollBarPanel.width == ScrollBarConstants.SLIM_WIDTH) { if (isScrolling) { - ScrollBarConstants.SLIM_BUTTON_PRESS.render(stack, width = width, height = height) + ScrollBarConstants.SLIM_BUTTON_PRESS.render(graphics, width = width, height = height) } else if (maxScroll.invoke(this@DiscreteScrollBarPanel) <= 0) { - ScrollBarConstants.SLIM_BUTTON_DISABLED.render(stack, width = width, height = height) + ScrollBarConstants.SLIM_BUTTON_DISABLED.render(graphics, width = width, height = height) } else if (isHovered) { - ScrollBarConstants.SLIM_BUTTON_HOVER.render(stack, width = width, height = height) + ScrollBarConstants.SLIM_BUTTON_HOVER.render(graphics, width = width, height = height) } else { - ScrollBarConstants.SLIM_BUTTON.render(stack, width = width, height = height) + ScrollBarConstants.SLIM_BUTTON.render(graphics, width = width, height = height) } } else { if (isScrolling) { - ScrollBarConstants.BUTTON_PRESS.render(stack, width = width, height = height) + ScrollBarConstants.BUTTON_PRESS.render(graphics, width = width, height = height) } else if (maxScroll.invoke(this@DiscreteScrollBarPanel) <= 0) { - ScrollBarConstants.BUTTON_DISABLED.render(stack, width = width, height = height) + ScrollBarConstants.BUTTON_DISABLED.render(graphics, width = width, height = height) } else if (isHovered) { - ScrollBarConstants.BUTTON_HOVER.render(stack, width = width, height = height) + ScrollBarConstants.BUTTON_HOVER.render(graphics, width = width, height = height) } else { - ScrollBarConstants.BUTTON.render(stack, width = width, height = height) + ScrollBarConstants.BUTTON.render(graphics, width = width, height = height) } } } @@ -90,15 +91,15 @@ open class DiscreteScrollBarPanel( val scrollButton = Button() - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (width == ScrollBarConstants.SLIM_WIDTH) { - ScrollBarConstants.SLIM_BODY.render(stack, y = 2f, height = height - 4f) - ScrollBarConstants.SLIM_TOP.render(stack) - ScrollBarConstants.SLIM_BOTTOM.render(stack, y = height - 2f) + ScrollBarConstants.SLIM_BODY.render(graphics, y = 2f, height = height - 4f) + ScrollBarConstants.SLIM_TOP.render(graphics) + ScrollBarConstants.SLIM_BOTTOM.render(graphics, y = height - 2f) } else { - ScrollBarConstants.BODY.render(stack, y = 2f, height = height - 4f) - ScrollBarConstants.TOP.render(stack) - ScrollBarConstants.BOTTOM.render(stack, y = height - 2f) + ScrollBarConstants.BODY.render(graphics, y = 2f, height = height - 4f) + ScrollBarConstants.TOP.render(graphics) + ScrollBarConstants.BOTTOM.render(graphics, y = height - 2f) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/SpritePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/SpritePanel.kt index c84b5072c..b461a0e4b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/SpritePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/SpritePanel.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.util import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.UVWindingOrder @@ -16,7 +17,7 @@ class SpritePanel( height: Float = sprite.height, val winding: UVWindingOrder = sprite.winding ) : EditablePanel(screen, parent, x, y, width, height) { - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - sprite.render(stack, 0f, 0f, width, height, winding) + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + sprite.render(graphics, 0f, 0f, width, height, winding) } } 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 f7ba4e1c8..4f34c313b 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 @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.storage import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack @@ -78,9 +79,9 @@ class DriveViewerScreen(menu: DriveViewerMenu, inventory: Inventory, title: Comp return true } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - renderSlotBackground(stack, mouseX, mouseY, partialTick) - renderRegular(stack, itemStack, "") + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + renderSlotBackground(graphics, mouseX, mouseY, partialTick) + renderRegular(graphics, itemStack, "") } override fun getItemStackTooltip(stack: ItemStack): List { 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 b920f15a4..e66f2b2fd 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 @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.storage import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.ChatFormatting +import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack @@ -81,12 +82,13 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp return true } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - renderSlotBackground(stack, mouseX, mouseY, partialTick) + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + renderSlotBackground(graphics, mouseX, mouseY, partialTick) val itemstack = menu.networkedItemView.sortedView.getOrNull(index)?.stack ?: ITEM_STORAGE.empty + val stack = graphics.pose() - renderRegular(stack, itemstack.stack, "") + renderRegular(graphics, itemstack.stack, "") if (!itemstack.isEmpty) { stack.pushPose() @@ -100,8 +102,8 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp RenderSystem.depthFunc(GL11.GL_ALWAYS) - font.draw(stack, text, 1f, 1f, 0x0) - font.draw(stack, text, 0f, 0f, 16777215) + graphics.drawString(font, text, 1, 1, 0x0) + graphics.drawString(font, text, 0, 0, 16777215) stack.popPose() } @@ -125,8 +127,8 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp } val arrowAndButtons = object : EditablePanel(this@ItemMonitorScreen, bottomPanel, width = ProgressGaugePanel.GAUGE_BACKGROUND.width) { - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - ProgressGaugePanel.GAUGE_BACKGROUND.render(stack, y = height / 2f - ProgressGaugePanel.GAUGE_BACKGROUND.height / 2f) + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + ProgressGaugePanel.GAUGE_BACKGROUND.render(graphics, y = height / 2f - ProgressGaugePanel.GAUGE_BACKGROUND.height / 2f) } } 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 1c20dd255..81188a326 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 @@ -8,6 +8,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectFunction import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import net.minecraft.ChatFormatting import net.minecraft.client.Minecraft +import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack @@ -290,7 +291,7 @@ private class AndroidResearchButton( } } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { val hovered = screen.hoveredResearch val isBlockedByHovered = hovered != null && node.type in hovered.type.allBlocking @@ -298,7 +299,7 @@ private class AndroidResearchButton( if (isBlockedByHovered) { AndroidStationScreen.CAN_NOT_BE_RESEARCHED.setSystemColor() - drawRect(stack, 0f, 0f, width, height) + drawRect(graphics, 0f, 0f, width, height) } if (node.isResearched) { @@ -315,34 +316,35 @@ private class AndroidResearchButton( val itemIcon = node.type.itemIcon if (icon != null) { - icon.render(stack, 0f, 0f, width, height) + icon.render(graphics, 0f, 0f, width, height) } else if (itemIcon != null) { val itemstack = ItemStack(itemIcon, 1) + val stack = graphics.pose() stack.pushPose() stack.translate(1f, 1f, 0f) - screen.renderItemStack(stack, itemstack) + screen.renderItemStack(graphics, itemstack) stack.popPose() - clearDepth(stack) + clearDepth(graphics) } else { - drawRect(stack, 0f, 0f, width, height) + drawRect(graphics, 0f, 0f, width, height) } if (isBlockedByHovered) { RGBAColor.RED.setSystemColor() - Widgets18.CROSS.render(stack) + Widgets18.CROSS.render(graphics) } else if (node.isAnyBlockerResearched) { RGBAColor.RED.setSystemColor() - Widgets18.FORWARD_SLASH.render(stack) + Widgets18.FORWARD_SLASH.render(graphics) } val text = node.type.iconText if (text != null) { - font.drawShadow(stack, text, width - font.width(text), height - font.lineHeight, -0x1) + graphics.drawString(font, text.visualOrderText, width - font.width(text), height - font.lineHeight, -0x1, true) } drawColor = RGBAColor.WHITE @@ -353,7 +355,7 @@ private class AndroidResearchButton( val (x1, y1) = pos1 val (x2, y2) = pos2 - drawLine(stack, x1, y1, x2, y2, 0.5f) + drawLine(graphics, x1, y1, x2, y2, 0.5f) } hovered ?: return @@ -367,7 +369,7 @@ private class AndroidResearchButton( val (x1, y1) = pos1 val (x2, y2) = pos2 - drawLine(stack, x1, y1, x2, y2, 0.5f) + drawLine(graphics, x1, y1, x2, y2, 0.5f) } } @@ -392,7 +394,7 @@ private class AndroidResearchButton( val (x1, y1) = pos1 val (x2, y2) = pos2 - drawLine(stack, x1, y1, x2, y2, 0.5f) + drawLine(graphics, x1, y1, x2, y2, 0.5f) } } } @@ -423,7 +425,7 @@ private class AndroidResearchButton( return true } - override fun innerRenderTooltips(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { if (isHovered) { val list = ArrayList().also { it.addAll(node.screenTooltipLines) } @@ -445,7 +447,7 @@ private class AndroidResearchButton( } } - screen.renderComponentTooltip(stack, list, mouseX.toInt(), mouseY.toInt()) + graphics.renderComponentTooltip(font, list, mouseX.toInt(), mouseY.toInt()) } return isHovered @@ -516,9 +518,9 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I private var scroller: PreviewScrollers = PreviewScrollers.values().let { it[random.nextInt(it.size)] } private var firstTick = false - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { drawColor = RGBAColor.BLACK - drawRect(stack, 0f, 0f, width, height) + drawRect(graphics, 0f, 0f, width, height) } override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { @@ -658,7 +660,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I align = TextAlign.TOP_RIGHT } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (menu.energyWidget.level >= AndroidStationBlockEntity.ENERGY_PER_RESEARCH) { text = POWER_OK color = RGBAColor.LIGHT_GREEN @@ -670,7 +672,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I color = RGBAColor.RED } - super.innerRender(stack, mouseX, mouseY, partialTick) + super.innerRender(graphics, mouseX, mouseY, partialTick) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt index 52fa32c17..7729e32b3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.tech import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen @@ -47,8 +48,8 @@ class EnergyServoScreen(menu: EnergyServoMenu, inventory: Inventory, title: Comp width = ProgressGaugePanel.GAUGE_BACKGROUND.width } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - ProgressGaugePanel.GAUGE_BACKGROUND.render(stack) + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + ProgressGaugePanel.GAUGE_BACKGROUND.render(graphics) } } @@ -65,8 +66,8 @@ class EnergyServoScreen(menu: EnergyServoMenu, inventory: Inventory, title: Comp width = ProgressGaugePanel.GAUGE_BACKGROUND.width } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - ProgressGaugePanel.GAUGE_BACKGROUND.render(stack) + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + ProgressGaugePanel.GAUGE_BACKGROUND.render(graphics) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt index 0ca7b3434..f8e45312c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.tech import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.ChatFormatting +import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.player.Inventory @@ -52,11 +53,11 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title dockMargin = DockProperty(bottom = 3f) } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - BAR_BACKGROUND.render(stack, width = width, height = height) + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + BAR_BACKGROUND.render(graphics, width = width, height = height) val level = getLevelFromXp(menu.experienceStored) val progress = (menu.experienceStored - getTotalXpRequiredForLevel(level)).toDouble() / getXpRequiredForLevelUp(level).toDouble() - BAR_FOREGROUND.renderPartial(stack, width = width * progress.toFloat(), height = height) + BAR_FOREGROUND.renderPartial(graphics, width = width * progress.toFloat(), height = height) } } 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 e4784afed..ca6bfd7b7 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 @@ -4,6 +4,7 @@ import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.DefaultVertexFormat import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.VertexFormat +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.client.renderer.GameRenderer import net.minecraft.network.chat.Component @@ -44,16 +45,16 @@ open class FluidGaugePanel( ) } - override fun innerRenderTooltips(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { if (isHovered) { - screen.renderComponentTooltip(stack, makeTooltip(), mouseX.toInt(), mouseY.toInt()) + graphics.renderComponentTooltip(font, makeTooltip(), mouseX.toInt(), mouseY.toInt()) return true } return false } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (widget.percentage > 0.01f && widget.fluid.isNotEmpty) { val data = IClientFluidTypeExtensions.of(widget.fluid.fluid) val texture = data.stillTexture!! @@ -62,7 +63,7 @@ open class FluidGaugePanel( var height = (height * widget.percentage) / 16f var bottom = this.height - val matrix = stack.last().pose() + val matrix = graphics.pose().last().pose() val builder = tesselator.builder builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX) @@ -96,7 +97,7 @@ open class FluidGaugePanel( RenderSystem.depthFunc(GL11.GL_LESS) } - GAUGE.render(stack, 0f, 0f, width = width, height = height) + GAUGE.render(graphics, 0f, 0f, width = width, height = height) } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt index 1a4df3e36..552a48882 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.widget import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.WidgetLocation @@ -8,26 +9,26 @@ import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProfiledEnergyGaugeWidget -private fun PowerGaugePanel<*>.doRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float, flop: Boolean) { +private fun PowerGaugePanel<*>.doRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float, flop: Boolean) { if (height >= 18f) { if (flop) { - HorizontalPowerGaugePanel.GAUGE_BACKGROUND_TALL.render(stack, height = height, width = this.width, winding = UVWindingOrder.U1_V0_U0_V1) + HorizontalPowerGaugePanel.GAUGE_BACKGROUND_TALL.render(graphics, height = height, width = this.width, winding = UVWindingOrder.U1_V0_U0_V1) val width = this.width * widget.percentage - HorizontalPowerGaugePanel.GAUGE_FOREGROUND_TALL.renderPartial(stack, x = this.width - width, height = height, width = width, winding = UVWindingOrder.U1_V0_U0_V1) + HorizontalPowerGaugePanel.GAUGE_FOREGROUND_TALL.renderPartial(graphics, x = this.width - width, height = height, width = width, winding = UVWindingOrder.U1_V0_U0_V1) } else { - HorizontalPowerGaugePanel.GAUGE_BACKGROUND_TALL.render(stack, height = height, width = this.width) + HorizontalPowerGaugePanel.GAUGE_BACKGROUND_TALL.render(graphics, height = height, width = this.width) val width = this.width * widget.percentage - HorizontalPowerGaugePanel.GAUGE_FOREGROUND_TALL.renderPartial(stack, height = height, width = width) + HorizontalPowerGaugePanel.GAUGE_FOREGROUND_TALL.renderPartial(graphics, height = height, width = width) } } else { if (flop) { - HorizontalPowerGaugePanel.GAUGE_BACKGROUND.render(stack, height = height, width = this.width, winding = UVWindingOrder.U1_V0_U0_V1) + HorizontalPowerGaugePanel.GAUGE_BACKGROUND.render(graphics, height = height, width = this.width, winding = UVWindingOrder.U1_V0_U0_V1) val width = this.width * widget.percentage - HorizontalPowerGaugePanel.GAUGE_FOREGROUND.renderPartial(stack, x = this.width - width, height = height, width = width, winding = UVWindingOrder.U1_V0_U0_V1) + HorizontalPowerGaugePanel.GAUGE_FOREGROUND.renderPartial(graphics, x = this.width - width, height = height, width = width, winding = UVWindingOrder.U1_V0_U0_V1) } else { - HorizontalPowerGaugePanel.GAUGE_BACKGROUND.render(stack, height = height, width = this.width) + HorizontalPowerGaugePanel.GAUGE_BACKGROUND.render(graphics, height = height, width = this.width) val width = this.width * widget.percentage - HorizontalPowerGaugePanel.GAUGE_FOREGROUND.renderPartial(stack, height = height, width = width) + HorizontalPowerGaugePanel.GAUGE_FOREGROUND.renderPartial(graphics, height = height, width = width) } } } @@ -43,8 +44,8 @@ open class HorizontalPowerGaugePanel( ) : PowerGaugePanel(screen, parent, widget, x, y, width, height) { var flop = false - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - doRender(stack, mouseX, mouseY, partialTick, flop) + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + doRender(graphics, mouseX, mouseY, partialTick, flop) } companion object { @@ -81,8 +82,8 @@ open class HorizontalProfiledPowerGaugePanel( ) : ProfiledPowerGaugePanel(screen, parent, widget, x, y, width, height) { var flop = false - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - doRender(stack, mouseX, mouseY, partialTick, flop) + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + doRender(graphics, mouseX, mouseY, partialTick, flop) } } 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 74d3ede9a..609490059 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 @@ -5,6 +5,7 @@ import com.mojang.blaze3d.vertex.BufferUploader import com.mojang.blaze3d.vertex.DefaultVertexFormat import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.VertexFormat +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.client.renderer.GameRenderer import net.minecraft.network.chat.Component @@ -49,7 +50,7 @@ open class MatterGaugePanel @JvmOverloads constructor( ) } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (lastAbsoluteX == 0f && lastAbsoluteY == 0f) { lastAbsoluteX = absoluteX lastAbsoluteY = absoluteY @@ -66,7 +67,7 @@ open class MatterGaugePanel @JvmOverloads constructor( lastLevel = widget.percentage } - GAUGE_BACKGROUND.render(stack) + GAUGE_BACKGROUND.render(graphics) val height = this.height * (1f - widget.percentage) if (widget.percentage > 0.01f) { @@ -81,7 +82,7 @@ open class MatterGaugePanel @JvmOverloads constructor( val u1 = GAUGE_FOREGROUND.u1 val v1 = GAUGE_FOREGROUND.v1 - val matrix = stack.last().pose() + val matrix = graphics.pose().last().pose() val builder = tesselator.builder builder.begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_TEX) @@ -106,9 +107,9 @@ open class MatterGaugePanel @JvmOverloads constructor( } } - override fun innerRenderTooltips(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { if (isHovered) { - screen.renderComponentTooltip(stack, makeTooltip(), mouseX.toInt(), mouseY.toInt()) + graphics.renderComponentTooltip(font, makeTooltip(), mouseX.toInt(), mouseY.toInt()) return true } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PatternGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PatternGaugePanel.kt index 1fde122eb..de68b55bf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PatternGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PatternGaugePanel.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.widget import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.client.render.WidgetLocation @@ -29,15 +30,15 @@ open class PatternGaugePanel @JvmOverloads constructor( ) } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - GAUGE_BACKGROUND.render(stack) + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + GAUGE_BACKGROUND.render(graphics) val height = this.height * widget.percentage - GAUGE_FOREGROUND.renderPartial(stack, y = this.height - height, height = height) + GAUGE_FOREGROUND.renderPartial(graphics, y = this.height - height, height = height) } - override fun innerRenderTooltips(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { if (isHovered) { - screen.renderComponentTooltip(stack, makeTooltip(), mouseX.toInt(), mouseY.toInt()) + graphics.renderComponentTooltip(font, makeTooltip(), mouseX.toInt(), mouseY.toInt()) return true } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt index 2ed40ee44..285d3112e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.widget import com.mojang.blaze3d.vertex.PoseStack import it.unimi.dsi.fastutil.ints.IntArrayList import net.minecraft.ChatFormatting +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage @@ -40,21 +41,21 @@ open class PowerGaugePanel( ) } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { val height = this.height * widget.percentage if (width >= 18f) { - GAUGE_BACKGROUND_WIDE.render(stack, width = width, height = this.height) + GAUGE_BACKGROUND_WIDE.render(graphics, width = width, height = this.height) GAUGE_FOREGROUND_WIDE.renderPartial( - stack, + graphics, y = this.height - height, height = height, width = width, winding = UVWindingOrder.U0_V1_U1_V0) } else { - GAUGE_BACKGROUND.render(stack, width = width, height = this.height) + GAUGE_BACKGROUND.render(graphics, width = width, height = this.height) GAUGE_FOREGROUND.renderPartial( - stack, + graphics, y = this.height - height, height = height, width = width, @@ -62,9 +63,9 @@ open class PowerGaugePanel( } } - override fun innerRenderTooltips(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { if (isHovered) { - screen.renderComponentTooltip(stack, makeTooltip(), mouseX.toInt(), mouseY.toInt()) + graphics.renderComponentTooltip(font, makeTooltip(), mouseX.toInt(), mouseY.toInt()) return true } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt index 1838bef86..eb1b4db49 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.widget import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.ChatFormatting +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.client.render.UVWindingOrder @@ -48,19 +49,19 @@ open class ProgressGaugePanel @JvmOverloads constructor( return tooltip } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (widget.isStuck && tickCount % 40 <= 20) { RenderSystem.setShaderColor(0.75f, 0.4f, 0.4f, 1f) } if (flop) { - GAUGE_BACKGROUND.render(stack, height = height, width = this.width, winding = UVWindingOrder.U1_V0_U0_V1) + GAUGE_BACKGROUND.render(graphics, height = height, width = this.width, winding = UVWindingOrder.U1_V0_U0_V1) val width = (this.width * widget.percentage).roundToInt().toFloat() - GAUGE_FOREGROUND.renderPartial(stack, x = this.width - width, height = height, width = width, winding = UVWindingOrder.U1_V0_U0_V1) + GAUGE_FOREGROUND.renderPartial(graphics, x = this.width - width, height = height, width = width, winding = UVWindingOrder.U1_V0_U0_V1) } else { - GAUGE_BACKGROUND.render(stack, height = height, width = this.width) + GAUGE_BACKGROUND.render(graphics, height = height, width = this.width) val width = (this.width * widget.percentage).roundToInt().toFloat() - GAUGE_FOREGROUND.renderPartial(stack, height = height, width = width) + GAUGE_FOREGROUND.renderPartial(graphics, height = height, width = width) } if (widget.isStuck && tickCount % 40 <= 20) { @@ -68,9 +69,9 @@ open class ProgressGaugePanel @JvmOverloads constructor( } } - override fun innerRenderTooltips(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { if (isHovered) { - screen.renderComponentTooltip(stack, makeTooltip(), mouseX.toInt(), mouseY.toInt()) + graphics.renderComponentTooltip(font, makeTooltip(), mouseX.toInt(), mouseY.toInt()) return true } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt index 54399f9ed..2eb86f7d1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt @@ -6,6 +6,7 @@ import lain.mods.cos.impl.ModObjects import lain.mods.cos.impl.client.PlayerRenderHandler import lain.mods.cos.impl.client.gui.GuiCosArmorInventory import lain.mods.cos.impl.network.packet.PacketSetSkinArmor +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer @@ -174,13 +175,13 @@ class CosmeticToggleButton( } } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { val inv = ModObjects.invMan.getCosArmorInventoryClient(minecraft.player?.uuid ?: throw ConcurrentModificationException()) if (inv.isSkinArmor(index)) { - BUTTON_ACTIVE.render(stack, width = width, height = height) + BUTTON_ACTIVE.render(graphics, width = width, height = height) } else { - BUTTON_INACTIVE.render(stack, width = width, height = height) + BUTTON_INACTIVE.render(graphics, width = width, height = height) } } @@ -213,11 +214,11 @@ class CosmeticToggleRenderButton( } } - override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (PlayerRenderHandler.Disabled) { - BUTTON_ACTIVE.render(stack, width = width, height = height) + BUTTON_ACTIVE.render(graphics, width = width, height = height) } else { - BUTTON_INACTIVE.render(stack, width = width, height = height) + BUTTON_INACTIVE.render(graphics, width = width, height = height) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/MinecartCargoCrate.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/MinecartCargoCrate.kt index d1a2e24f5..4ef8947d7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/MinecartCargoCrate.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/MinecartCargoCrate.kt @@ -87,8 +87,8 @@ class MinecartCargoCrate( if (interactingPlayers++ == 0) { if (!isRemoved) { - level.playSound(null, this, MSoundEvents.CARGO_CRATE_OPEN, SoundSource.BLOCKS, 1f, 0.8f + level.random.nextFloat() * 0.2f) - level.gameEvent(GameEvent.CONTAINER_OPEN, position, GameEvent.Context.of(this)) + level().playSound(null, this, MSoundEvents.CARGO_CRATE_OPEN, SoundSource.BLOCKS, 1f, 0.8f + level().random.nextFloat() * 0.2f) + level().gameEvent(GameEvent.CONTAINER_OPEN, position, GameEvent.Context.of(this)) } } } @@ -99,7 +99,7 @@ class MinecartCargoCrate( if (--interactingPlayers == 0) { if (!isRemoved) { - level.gameEvent(GameEvent.CONTAINER_CLOSE, position, GameEvent.Context.of(this)) + level().gameEvent(GameEvent.CONTAINER_CLOSE, position, GameEvent.Context.of(this)) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/PlasmaProjectile.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/PlasmaProjectile.kt index 0e3179247..405a5f41f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/PlasmaProjectile.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/PlasmaProjectile.kt @@ -29,7 +29,7 @@ class PlasmaProjectile(level: Level) : Projectile(MEntityTypes.PLASMA as EntityT override fun onHit(p_37260_: HitResult) { super.onHit(p_37260_) - if (!level.isClientSide) { + if (!level().isClientSide) { discard() } } @@ -37,8 +37,8 @@ class PlasmaProjectile(level: Level) : Projectile(MEntityTypes.PLASMA as EntityT override fun onHitEntity(p_37259_: EntityHitResult) { super.onHitEntity(p_37259_) - if (!level.isClientSide) { - p_37259_.entity.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.PLASMA), owner, inflictor), damage) + if (!level().isClientSide) { + p_37259_.entity.hurt(MatteryDamageSource(level().registryAccess().damageType(MDamageTypes.PLASMA), owner, inflictor), damage) } } @@ -54,17 +54,17 @@ class PlasmaProjectile(level: Level) : Projectile(MEntityTypes.PLASMA as EntityT super.tick() - val trace = ProjectileUtil.getHitResult(this, this::canHitEntity) + val trace = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity) if (trace.type == HitResult.Type.BLOCK) { val pos = (trace as BlockHitResult).blockPos - val state = level.getBlockState(pos) + val state = level().getBlockState(pos) if (state.`is`(Blocks.NETHER_PORTAL) || state.`is`(Blocks.END_GATEWAY)) { onHitBlock(trace) // don't teleport plasma projectile - if (!level.isClientSide) + if (!level().isClientSide) discard() return @@ -85,7 +85,7 @@ class PlasmaProjectile(level: Level) : Projectile(MEntityTypes.PLASMA as EntityT // extinguish for (i in 0 .. 4) { - level.addParticle( + level().addParticle( ParticleTypes.BUBBLE, x - deltaMovement.x * 0.25, y - deltaMovement.y * 0.25, @@ -96,9 +96,9 @@ class PlasmaProjectile(level: Level) : Projectile(MEntityTypes.PLASMA as EntityT ) } - if (!level.isClientSide) { + if (!level().isClientSide) { discard() - level.levelEvent(LevelEvent.LAVA_FIZZ, blockPosition(), 0) + level().levelEvent(LevelEvent.LAVA_FIZZ, blockPosition(), 0) } return diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EssenceServoItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EssenceServoItem.kt index f6417fdc8..320bcfbcd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EssenceServoItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EssenceServoItem.kt @@ -22,11 +22,11 @@ class EssenceServoItem : Item(Properties().stacksTo(64)) { } fun useServo(player: Player, pos: BlockPos): InteractionResult { - val block = player.level.getBlockEntity(pos) ?: return InteractionResult.FAIL + val block = player.level().getBlockEntity(pos) ?: return InteractionResult.FAIL // TODO: опыт как жидкость if (block is EssenceStorageBlockEntity) { - if (player.level.isClientSide) return InteractionResult.SUCCESS + if (player.level().isClientSide) return InteractionResult.SUCCESS if (player !is ServerPlayer) return InteractionResult.FAIL if (player.isCrouching) { // выгружаем в блок 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 4d9e8af29..533a6c29a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt @@ -90,7 +90,7 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6 } override fun canInteract(item: ItemStack, player: Player, context: Context): Boolean { - return player.level.getBlockState(context.blockPos).`is`(Blocks.CAULDRON) + return player.level().getBlockState(context.blockPos).`is`(Blocks.CAULDRON) } override fun interact(item: ItemStack, player: Player, context: Context): InteractionResult { @@ -105,12 +105,12 @@ 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) - val level = player.level as? ServerLevel ?: return InteractionResult.SUCCESS + player.level().playSound(player, context.blockPos, soundEvent, SoundSource.BLOCKS) + val level = player.level() as? ServerLevel ?: return InteractionResult.SUCCESS level.setBlock(context.blockPos, newState, Block.UPDATE_ALL) cap.drain(toDrain, IFluidHandler.FluidAction.EXECUTE) - if (item.count != 1 && !player.level.isClientSide) { + if (item.count != 1 && !player.level().isClientSide) { item.count-- if (!player.inventory.add(targetItem)) { @@ -133,7 +133,7 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6 } override fun canInteract(item: ItemStack, player: Player, context: Context): Boolean { - return player.level.getBlockState(context.blockPos) in mapping + return player.level().getBlockState(context.blockPos) in mapping } override fun interact(item: ItemStack, player: Player, context: Context): InteractionResult { @@ -149,13 +149,13 @@ 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) - val level = player.level as? ServerLevel ?: return InteractionResult.SUCCESS + val level = player.level() as? ServerLevel ?: return InteractionResult.SUCCESS level.setBlock(context.blockPos, Blocks.CAULDRON.defaultBlockState(), Block.UPDATE_ALL) cap.fill(toFill, IFluidHandler.FluidAction.EXECUTE) - if (item.count != 1 && !player.level.isClientSide) { + if (item.count != 1 && !player.level().isClientSide) { item.count-- if (!player.inventory.add(targetItem)) { @@ -163,13 +163,13 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6 } } - return InteractionResult.sidedSuccess(player.level.isClientSide) + return InteractionResult.sidedSuccess(player.level().isClientSide) } } private object FillEmptyCapability : Interaction { override fun canInteract(item: ItemStack, player: Player, context: Context): Boolean { - val target = player.level.getBlockEntity(context.blockPos)?.getCapability(ForgeCapabilities.FLUID_HANDLER, context.side)?.orNull() ?: return false + val target = player.level().getBlockEntity(context.blockPos)?.getCapability(ForgeCapabilities.FLUID_HANDLER, context.side)?.orNull() ?: return false val cap = item.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).orNull() ?: return false return target.stream().anyMatch { !it.isEmpty } || cap.stream().anyMatch { !it.isEmpty } } @@ -180,21 +180,21 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6 val targetItem = if (item.count == 1) item else item.copyWithCount(1) val itemCap = targetItem.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).orNull() ?: return InteractionResult.FAIL - val blockCap = player.level.getBlockEntity(context.blockPos)?.getCapability(ForgeCapabilities.FLUID_HANDLER, context.side)?.orNull() ?: return InteractionResult.FAIL + val blockCap = player.level().getBlockEntity(context.blockPos)?.getCapability(ForgeCapabilities.FLUID_HANDLER, context.side)?.orNull() ?: return InteractionResult.FAIL val fluid = itemCap[0] if (fluid.isEmpty) { // заполняем из блока - val moveResult = moveFluid(source = blockCap, destination = itemCap, actuallyDrain = !player.level.isClientSide, actuallyFill = !player.level.isClientSide) + val moveResult = moveFluid(source = blockCap, destination = itemCap, actuallyDrain = !player.level().isClientSide, actuallyFill = !player.level().isClientSide) if (!moveResult.isEmpty) { 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) } - if (item.count != 1 && !player.level.isClientSide) { + if (item.count != 1 && !player.level().isClientSide) { item.count-- if (!player.inventory.add(targetItem)) { @@ -202,21 +202,21 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6 } } - return InteractionResult.sidedSuccess(player.level.isClientSide) + return InteractionResult.sidedSuccess(player.level().isClientSide) } else { return InteractionResult.FAIL } } else { - val moveResult = moveFluid(source = itemCap, destination = blockCap, actuallyDrain = !player.level.isClientSide, actuallyFill = !player.level.isClientSide) + val moveResult = moveFluid(source = itemCap, destination = blockCap, actuallyDrain = !player.level().isClientSide, actuallyFill = !player.level().isClientSide) if (!moveResult.isEmpty) { 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) } - if (item.count != 1 && !player.level.isClientSide) { + if (item.count != 1 && !player.level().isClientSide) { item.count-- if (!player.inventory.add(targetItem)) { @@ -224,7 +224,7 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6 } } - return InteractionResult.sidedSuccess(player.level.isClientSide) + return InteractionResult.sidedSuccess(player.level().isClientSide) } else { return InteractionResult.FAIL } 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 ccc0b3735..f70db8db5 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 @@ -90,7 +90,7 @@ class MatterDustItem : Item(Properties().stacksTo(64)), IMatterItem { val matterHalf = getMatterValue(pStack)?.matter?.div(2) ?: return true val halfStack = pStack.copyWithCount(1) - matter(halfStack, -addMatterValue(pStack, -matterHalf, pPlayer.level.isClientSide())) + matter(halfStack, -addMatterValue(pStack, -matterHalf, pPlayer.level().isClientSide())) pSlot.set(halfStack) if (getMatterValue(pStack)?.matter!! <= Decimal.ZERO) { @@ -120,13 +120,13 @@ class MatterDustItem : Item(Properties().stacksTo(64)), IMatterItem { val matterHalf = getMatterValue(pStack)?.matter?.div(2) ?: return true val halfStack = pStack.copyWithCount(1) - matter(halfStack, -addMatterValue(pStack, -matterHalf, pPlayer.level.isClientSide())) + matter(halfStack, -addMatterValue(pStack, -matterHalf, pPlayer.level().isClientSide())) pAccess.set(halfStack) return true } else if (pOther.item is MatterDustItem && pOther.count == 1) { val matterOther = getMatterValue(pOther)?.matter ?: return true - val diff = addMatterValue(pStack, matterOther, pPlayer.level.isClientSide()) + val diff = addMatterValue(pStack, matterOther, pPlayer.level().isClientSide()) if (matterOther - diff <= Decimal.ZERO) { pOther.shrink(1) 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 6ae6658f0..1d1950099 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 @@ -91,20 +91,20 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1) } fun attackAt(itemStack: ItemStack, attacker: LivingEntity, pos: Vec3, aim: Vec3, hand: InteractionHand) { - if (!isPrimed(itemStack) || attacker.level.isClientSide || attacker is Player && attacker.getAttackStrengthScale(0.4f) < 0.98f) + if (!isPrimed(itemStack) || attacker.level().isClientSide || attacker is Player && attacker.getAttackStrengthScale(0.4f) < 0.98f) return 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_WITH_DECAY else Explosion.BlockInteraction.KEEP) exp.explode() exp.finalizeExplosion(true) if (!ToolsConfig.ExplosiveHammer.EXPLOSION_DAMAGE_BLOCKS) exp.clearToBlow() - val level = attacker.level as ServerLevel + val level = attacker.level() as ServerLevel val hitEntities = ObjectArraySet() hitEntities.add(attacker) @@ -164,7 +164,7 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1) rayPos += aim * delta } - MatteryBlockEntity.watchingPlayers(pos, attacker.level) + MatteryBlockEntity.watchingPlayers(pos, level) .filter { it.position.distanceTo(pos) <= 64.0 } .forEach { it.connection.send(ClientboundExplodePacket(ex, ey, ez, 1f, exp.toBlow, exp.hitPlayers[it])) @@ -183,7 +183,7 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1) attacker.setItemInHand(hand, ItemStack.EMPTY) val (x, y, z) = attacker.position - val entity = ItemEntity(attacker.level, x, y, z, itemStack) + val entity = ItemEntity(level, x, y, z, itemStack) val (xv, yv, zv) = attacker.getViewVector(0f) @@ -193,7 +193,7 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1) (attacker.random.nextDouble() + 0.65) * zv * -2.0, ) - attacker.level.addFreshEntity(entity) + level.addFreshEntity(entity) if (attacker.random.nextDouble() <= ToolsConfig.ExplosiveHammer.FLY_OFF_DAMAGE_CHANCE) { attacker.invulnerableTime = 0 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/MatteryAxeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/MatteryAxeItem.kt index 4ca35f083..fcb65eaf3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/MatteryAxeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/MatteryAxeItem.kt @@ -1,15 +1,15 @@ package ru.dbotthepony.mc.otm.item.tool +import net.minecraft.tags.BlockTags import net.minecraft.world.item.AxeItem import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Tier import net.minecraft.world.level.block.state.BlockState -import net.minecraft.world.level.material.Material import ru.dbotthepony.mc.otm.config.ToolsConfig class MatteryAxeItem(pTier: Tier, pAttackDamageModifier: Float, pAttackSpeedModifier: Float, pProperties: Properties) : AxeItem(pTier, pAttackDamageModifier, pAttackSpeedModifier, pProperties) { override fun getDestroySpeed(pStack: ItemStack, pState: BlockState): Float { - if (pState.material == Material.LEAVES && ToolsConfig.AXES_BREAK_LEAVES_INSTANTLY) + if (pState.`is`(BlockTags.LEAVES) && ToolsConfig.AXES_BREAK_LEAVES_INSTANTLY) return 64f return super.getDestroySpeed(pStack, pState) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt index 953b3391d..7c67f68e7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt @@ -24,6 +24,8 @@ import net.minecraftforge.network.NetworkEvent import ru.dbotthepony.mc.otm.* import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.client.font +import ru.dbotthepony.mc.otm.client.render.TextAlign +import ru.dbotthepony.mc.otm.client.render.drawAligned import ru.dbotthepony.mc.otm.client.render.drawRect import ru.dbotthepony.mc.otm.client.render.setDrawColor import ru.dbotthepony.mc.otm.core.* @@ -466,7 +468,7 @@ abstract class AbstractWeaponItem(val tables: KClass, pr pose.translate(0.0, 0.0, -1.0) pose.scale(0.7f, 0.7f, 0.7f) val text = it.batteryLevel.formatPower() - font.draw(pose, text, 2f, 2f, RGBAColor.WHITE.toInt()) + font.drawAligned(pose, text, TextAlign.TOP_LEFT, 2f, 2f, RGBAColor.WHITE.toInt()) pose.popPose() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt index bb16bc0cf..73f2ae4ca 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt @@ -6,6 +6,7 @@ import net.minecraft.ChatFormatting import net.minecraft.core.BlockPos import net.minecraft.nbt.CompoundTag import net.minecraft.network.chat.Component +import net.minecraft.tags.BlockTags import net.minecraft.world.entity.EquipmentSlot import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.ai.attributes.Attribute @@ -22,7 +23,6 @@ import net.minecraft.world.item.enchantment.EnchantmentCategory import net.minecraft.world.level.Level import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.state.BlockState -import net.minecraft.world.level.material.Material import net.minecraftforge.common.ForgeConfigSpec import net.minecraftforge.common.ToolAction import net.minecraftforge.common.ToolActions @@ -83,17 +83,11 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani val energy = itemStack.getCapability(MatteryCapability.ENERGY).orNull() ?: return 1f if (blockState.`is`(Blocks.COBWEB)) { - if (energy.batteryLevel < COBWEB_POWER_COST) { - return 2f - } else { - return 25f - } - } - - return when (blockState.material) { - Material.PLANT, Material.REPLACEABLE_PLANT, Material.VEGETABLE -> if (energy.batteryLevel < PLANT_POWER_COST) 1.5f else 4f - Material.LEAVES -> if (energy.batteryLevel < PLANT_POWER_COST) 1.5f else 8f - else -> 1f + return if (energy.batteryLevel < COBWEB_POWER_COST) 2f else 25f + } else if (blockState.`is`(BlockTags.SWORD_EFFICIENT)) { + return if (energy.batteryLevel < PLANT_POWER_COST) 1.5f else 8f + } else { + return 1f } } @@ -106,7 +100,7 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani victim.matteryPlayer?.let { if (it.isAndroid) { victim.invulnerableTime = 0 - victim.hurt(MatteryDamageSource(attacker.level.registryAccess().damageType(MDamageTypes.EMP), attacker, itemStack), 8f) + victim.hurt(MatteryDamageSource(attacker.level().registryAccess().damageType(MDamageTypes.EMP), attacker, itemStack), 8f) } } @@ -115,11 +109,11 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani itemStack.getCapability(MatteryCapability.ENERGY).ifPresentK { if (it.extractEnergyExact(ENERGY_PER_SWING, false)) { - it.extractEnergy(attacker.level.random.nextVariance(ENERGY_PER_SWING_VARIANCE), false) + it.extractEnergy(attacker.level().random.nextVariance(ENERGY_PER_SWING_VARIANCE), false) victim.matteryPlayer?.let { if (it.isAndroid && it.androidEnergy.extractEnergyExact(ENERGY_ZAP, false)) { - it.androidEnergy.extractEnergy(attacker.level.random.nextVariance(ENERGY_ZAP_VARIANCE), false) - victim.hurt(MatteryDamageSource(attacker.level.registryAccess().damageType(MDamageTypes.EMP), attacker, itemStack), 8f) + it.androidEnergy.extractEnergy(attacker.level().random.nextVariance(ENERGY_ZAP_VARIANCE), false) + victim.hurt(MatteryDamageSource(attacker.level().registryAccess().damageType(MDamageTypes.EMP), attacker, itemStack), 8f) } } } @@ -166,15 +160,14 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani if (blockState.getDestroySpeed(p_41417_, p_41419_) != 0f && (user !is Player || !user.isCreative)) { val energy = itemStack.matteryEnergy - when (blockState.material) { - Material.PLANT, Material.REPLACEABLE_PLANT, Material.VEGETABLE, Material.LEAVES -> - if (energy?.extractEnergyExact(PLANT_POWER_COST, false) == true) - energy.extractEnergyExact(user.level.random.nextVariance(PLANT_POWER_COST_VARIANCE), false) + if (blockState.`is`(BlockTags.SWORD_EFFICIENT)) { + if (energy?.extractEnergyExact(PLANT_POWER_COST, false) == true) + energy.extractEnergyExact(user.level().random.nextVariance(PLANT_POWER_COST_VARIANCE), false) } if (blockState.`is`(Blocks.COBWEB)) { if (energy?.extractEnergyExact(COBWEB_POWER_COST, false) == true) - energy.extractEnergyExact(user.level.random.nextVariance(COBWEB_POWER_COST_VARIANCE), false) + energy.extractEnergyExact(user.level().random.nextVariance(COBWEB_POWER_COST_VARIANCE), false) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaRifleItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaRifleItem.kt index 053b96d5e..afdbc7a1d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaRifleItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaRifleItem.kt @@ -25,8 +25,8 @@ class PlasmaRifleItem : PlasmaWeaponItem(PlasmaWeaponData get() = Angle(-0.02, 0.0, 0.0) override fun primaryFire(itemStack: ItemStack, player: Player, dt: PlasmaWeaponDataTable): Boolean { - if (!player.level.isClientSide) { - val arrow = PlasmaProjectile(player.level) + if (!player.level().isClientSide) { + val arrow = PlasmaProjectile(player.level()) arrow.position = player.eyePosition val calc = VelocityCalculation(player, force = 4.0, deviation = 0.3) @@ -34,14 +34,14 @@ class PlasmaRifleItem : PlasmaWeaponItem(PlasmaWeaponData arrow.owner = player - player.level.addFreshEntity(arrow) + player.level().addFreshEntity(arrow) } else { dt.doFireAnim(deviation = rotFireAnimDeviation) } receiveHeat(itemStack, player, 10.0, dt) - player.level.playSound( + player.level().playSound( player, player, MSoundEvents.RIFLE_SHOT, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt index 71eccdb0e..54e499f64 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt @@ -280,7 +280,7 @@ abstract class PlasmaWeaponItem(tables: KClass, pr dt.heatCooldown = overheatCooldown if (!before) { - player.level.playSound(player, player, MSoundEvents.PLASMA_WEAPON_OVERHEAT, SoundSource.PLAYERS, 1f, 1f) + player.level().playSound(player, player, MSoundEvents.PLASMA_WEAPON_OVERHEAT, SoundSource.PLAYERS, 1f, 1f) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/VelocityCalculation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/VelocityCalculation.kt index a3d95a956..a63d7e5be 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/VelocityCalculation.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/VelocityCalculation.kt @@ -90,7 +90,7 @@ class VelocityCalculation( if (owner != null) { val ownerVel = owner.deltaMovement - if (owner.isOnGround) { + if (owner.onGround()) { velocity += ownerVel } else { velocity += Vec3(ownerVel.x, 0.0, ownerVel.z) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 6cef60235..b8c45fff2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -40,6 +40,7 @@ import net.minecraft.world.Container import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.inventory.CraftingContainer +import net.minecraft.world.inventory.TransientCraftingContainer import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Recipe @@ -556,7 +557,7 @@ object MatterManager { height = 1 } - val container = CraftingContainer(object : AbstractContainerMenu(null, 0) { + val container = TransientCraftingContainer(object : AbstractContainerMenu(null, 0) { override fun quickMoveStack(pPlayer: Player, pIndex: Int): ItemStack { return ItemStack.EMPTY } @@ -1555,7 +1556,7 @@ object MatterManager { val targetFile = File(MINECRAFT_SERVER.serverDirectory, "otm/registry_dumps/${filter.name.lowercase()}_${System.currentTimeMillis() / 1_000L}.csv") File(MINECRAFT_SERVER.serverDirectory, "otm/registry_dumps").mkdirs() - stack.source.sendSuccess(TranslatableComponent("otm.dumping_matter_registry", targetFile.absolutePath), false) + stack.source.sendSuccess({ TranslatableComponent("otm.dumping_matter_registry", targetFile.absolutePath) }, false) val writer = targetFile.bufferedWriter(Charsets.UTF_8) @@ -1601,7 +1602,7 @@ object MatterManager { writer.close() - stack.source.sendSuccess(TranslatableComponent("otm.dumped_matter_registry", targetFile.absolutePath), true) + stack.source.sendSuccess({ TranslatableComponent("otm.dumped_matter_registry", targetFile.absolutePath) }, true) return 0 } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt index 9c70413a4..8e3c13dc0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt @@ -23,9 +23,9 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen init { if (capability.isExoPackCraftingUpgraded) { - craftingGrid = CraftingContainer(this, 3, 3) + craftingGrid = TransientCraftingContainer(this, 3, 3) } else { - craftingGrid = CraftingContainer(this, 2, 2) + craftingGrid = TransientCraftingContainer(this, 2, 2) } val builder = ImmutableList.builder() @@ -111,7 +111,7 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen super.slotsChanged(container) if (container == craftingGrid) { - CraftingMenu.slotChangedCraftingGrid(this, capability.ply.level, capability.ply, craftingGrid, craftingResultContainer) + CraftingMenu.slotChangedCraftingGrid(this, capability.ply.level(), capability.ply, craftingGrid, craftingResultContainer) } } @@ -135,7 +135,7 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen craftingResultContainer.clearContent() - if (!player.level.isClientSide) { + if (!player.level().isClientSide) { val iterator = craftingGrid.iterator() for (itemStack in iterator) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index e0658604f..bc92c1a77 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -373,7 +373,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( override fun stillValid(player: Player): Boolean { if (tile == null) return true - if (player.level.getBlockEntity(tile.blockPos) !== tile) { + if (player.level().getBlockEntity(tile.blockPos) !== tile) { return false } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt index 41a482a87..fda96b746 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt @@ -349,7 +349,7 @@ class MatterPanelMenu @JvmOverloads constructor( } fun fullPatternBroadcast() { - if (inventory.player.level.isClientSide) { + if (inventory.player.level().isClientSide) { initialSend = true return } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt index c500243d1..a0ef27a75 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt @@ -24,7 +24,7 @@ class BlockEntitySyncPacket(val position: BlockPos, val buffer: ByteArray, val v } private fun execute() { - val level = minecraft.player?.level + val level = minecraft.player?.level() if (level == null) { LOGGER.error("Received BlockEntitySyncPacket before we are in valid level.") 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 c7ccab195..70fac7edc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -6,26 +6,19 @@ import net.minecraft.network.chat.Component import net.minecraft.sounds.SoundEvents import net.minecraft.util.valueproviders.UniformInt import net.minecraft.world.entity.Entity +import net.minecraft.world.entity.EntityType import net.minecraft.world.entity.monster.Zombie import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.BlockGetter -import net.minecraft.world.level.block.AnvilBlock -import net.minecraft.world.level.block.Block -import net.minecraft.world.level.block.DoorBlock -import net.minecraft.world.level.block.DropExperienceBlock -import net.minecraft.world.level.block.IronBarsBlock -import net.minecraft.world.level.block.SlabBlock -import net.minecraft.world.level.block.SoundType -import net.minecraft.world.level.block.StairBlock -import net.minecraft.world.level.block.TrapDoorBlock -import net.minecraft.world.level.block.WallBlock +import net.minecraft.world.level.block.* import net.minecraft.world.level.block.state.BlockBehaviour import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.properties.BlockSetType -import net.minecraft.world.level.material.Material -import net.minecraft.world.level.material.MaterialColor +import net.minecraft.world.level.block.state.properties.NoteBlockInstrument +import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.PushReaction import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.ForgeRegistries @@ -117,18 +110,19 @@ object MBlocks { val FLUID_TANK: FluidTankBlock by registry.register(MNames.FLUID_TANK) { FluidTankBlock() } val TRITANIUM_ORE: Block by registry.register(MNames.TRITANIUM_ORE) { DropExperienceBlock( - BlockBehaviour.Properties.of(Material.STONE) + BlockBehaviour.Properties.of() + .mapColor(MapColor.STONE) .strength(3.25f, 6.0f) .requiresCorrectToolForDrops(), UniformInt.of(0, 3) ) } val TRITANIUM_INGOT_BLOCK: Block by registry.register(MNames.TRITANIUM_INGOT_BLOCK) { - Block(BlockBehaviour.Properties.of(Material.METAL, MaterialColor.COLOR_BLUE).explosionResistance(400f).destroyTime(3f).requiresCorrectToolForDrops()) + Block(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BLUE).sound(SoundType.METAL).explosionResistance(400f).destroyTime(3f).requiresCorrectToolForDrops()) } val METAL_JUNK: Block by registry.register(MNames.METAL_JUNK) { - object : Block(BlockBehaviour.Properties.of(Material.HEAVY_METAL, MaterialColor.COLOR_GRAY).sound(SoundType.NETHERITE_BLOCK).explosionResistance(45f).destroyTime(3f).requiresCorrectToolForDrops()) { + object : Block(BlockBehaviour.Properties.of().sound(SoundType.NETHERITE_BLOCK).mapColor(MapColor.COLOR_GRAY).explosionResistance(45f).destroyTime(3f).requiresCorrectToolForDrops()) { override fun appendHoverText( p_49816_: ItemStack, p_49817_: BlockGetter?, @@ -142,32 +136,35 @@ object MBlocks { } val METAL_MESH: Block by registry.register(MNames.METAL_MESH) { - Block(BlockBehaviour.Properties.of(Material.GLASS, MaterialColor.COLOR_GRAY) + Block(BlockBehaviour.Properties.of() + .mapColor(MapColor.COLOR_GRAY) .noOcclusion() .sound(SoundType.COPPER).explosionResistance(30f) .destroyTime(2f).requiresCorrectToolForDrops()) } val TRITANIUM_BARS: IronBarsBlock by registry.register(MNames.TRITANIUM_BARS) { - IronBarsBlock(BlockBehaviour.Properties.of(Material.METAL, MaterialColor.COLOR_BLUE).explosionResistance(45f).destroyTime(2.5f).requiresCorrectToolForDrops()) + IronBarsBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_LIGHT_BLUE).sound(SoundType.METAL).explosionResistance(45f).destroyTime(2.5f).requiresCorrectToolForDrops()) } val DEEPSLATE_TRITANIUM_ORE: Block by registry.register(MNames.DEEPSLATE_TRITANIUM_ORE) { DropExperienceBlock( - BlockBehaviour.Properties.of(Material.STONE) + BlockBehaviour.Properties.of() + .mapColor(MapColor.DEEPSLATE) + .sound(SoundType.DEEPSLATE) .strength(4.75f, 6.5f) .requiresCorrectToolForDrops().sound(SoundType.DEEPSLATE), UniformInt.of(0, 3) ) } val TRITANIUM_RAW_BLOCK: Block by registry.register(MNames.TRITANIUM_RAW_BLOCK) { Block( - BlockBehaviour.Properties.of(Material.STONE).strength(8.0f, 10f).requiresCorrectToolForDrops() + BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_LIGHT_BLUE).instrument(NoteBlockInstrument.BASEDRUM).strength(8.0f, 10f).requiresCorrectToolForDrops() ) } val LABORATORY_LAMP: Block by registry.register(MNames.LABORATORY_LAMP) { LaboratoryLamp(false) } val LABORATORY_LAMP_INVERTED: Block by registry.register(MNames.LABORATORY_LAMP_INVERTED) { LaboratoryLamp(true) } val LABORATORY_LAMP_LIGHT: Block by registry.register(MNames.LABORATORY_LAMP_LIGHT) { LaboratoryLampLight() } - val DANGER_STRIPE_BLOCK: Block by registry.register(MNames.DANGER_STRIPE_BLOCK) { Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.GRAY).explosionResistance(6f).destroyTime(1.5f).requiresCorrectToolForDrops()) } - val METAL_BEAM: Block by registry.register(MNames.METAL_BEAM) { Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.GRAY).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) } + val DANGER_STRIPE_BLOCK: Block by registry.register(MNames.DANGER_STRIPE_BLOCK) { Block(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_GRAY).explosionResistance(6f).destroyTime(1.5f).requiresCorrectToolForDrops()) } + val METAL_BEAM: Block by registry.register(MNames.METAL_BEAM) { Block(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_GRAY).sound(SoundType.METAL).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) } val ENGINE: Block by registry.register(MNames.ENGINE) { EngineBlock() } val HOLO_SIGN: Block by registry.register(MNames.HOLO_SIGN) { HoloSignBlock() } @@ -179,9 +176,12 @@ object MBlocks { val anvils = ArrayList<() -> Block>() for (i in 0 until TRITANIUM_ANVIL_VARIANTS) { - val props = BlockBehaviour.Properties.of(Material.METAL, DyeColor.LIGHT_BLUE) + val props = BlockBehaviour.Properties.of() + .mapColor(MapColor.COLOR_LIGHT_BLUE) + .sound(SoundType.ANVIL) .destroyTime(2.5f - i * 0.15f) .explosionResistance(1200f - i * 80f) + .pushReaction(PushReaction.BLOCK) .requiresCorrectToolForDrops() anvils.add(registry.register(MNames.TRITANIUM_ANVIL + i) { AnvilBlock(props) }::get) @@ -191,7 +191,16 @@ object MBlocks { } val TRITANIUM_DOOR = registry.allColored(MNames.TRITANIUM_DOOR) { color, _ -> - object : DoorBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), BlockSetType.IRON) { + object : DoorBlock( + Properties.of() + .mapColor(color ?: DyeColor.LIGHT_BLUE) + .explosionResistance(80f) + .noOcclusion() + .destroyTime(3f) + .pushReaction(PushReaction.DESTROY) + .requiresCorrectToolForDrops(), + BlockSetType.IRON + ) { override fun appendHoverText( p_49816_: ItemStack, p_49817_: BlockGetter?, @@ -219,7 +228,15 @@ object MBlocks { } val TRITANIUM_TRAPDOOR = registry.allColored(MNames.TRITANIUM_TRAPDOOR) { color, _ -> - object : TrapDoorBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), BlockSetType.IRON) { + object : TrapDoorBlock( + Properties.of() + .mapColor(color ?: DyeColor.LIGHT_BLUE) + .explosionResistance(80f) + .noOcclusion().destroyTime(3f) + .requiresCorrectToolForDrops() + .isValidSpawn { _: BlockState, _: BlockGetter, _: BlockPos, _: EntityType<*>? -> false }, + BlockSetType.IRON + ) { override fun appendHoverText( p_49816_: ItemStack, p_49817_: BlockGetter?, @@ -256,7 +273,8 @@ object MBlocks { } val TRITANIUM_STRIPED_BLOCK: Block by registry.register(MNames.TRITANIUM_STRIPED_BLOCK) { Block( - BlockBehaviour.Properties.of(Material.METAL, MaterialColor.COLOR_LIGHT_BLUE) + BlockBehaviour.Properties.of() + .mapColor(MapColor.COLOR_LIGHT_BLUE) .sound(SoundType.BASALT) .requiresCorrectToolForDrops() .explosionResistance(80f) @@ -277,7 +295,8 @@ object MBlocks { } val CARBON_FIBRE_BLOCK: Block by registry.register(MNames.CARBON_FIBRE_BLOCK) { Block( - BlockBehaviour.Properties.of(Material.METAL, MaterialColor.COLOR_LIGHT_BLUE) + BlockBehaviour.Properties.of() + .mapColor(MapColor.COLOR_GRAY) .sound(SoundType.BASALT) .requiresCorrectToolForDrops() .explosionResistance(40f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt index 1ee0fa894..c701193b9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt @@ -1,15 +1,16 @@ package ru.dbotthepony.mc.otm.registry -import net.minecraft.resources.ResourceLocation +import net.minecraft.core.registries.Registries import net.minecraft.world.item.CreativeModeTab import net.minecraft.world.item.DyeColor import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.level.material.Fluids import net.minecraftforge.common.capabilities.ForgeCapabilities -import net.minecraftforge.event.CreativeModeTabEvent +import net.minecraftforge.event.BuildCreativeModeTabContentsEvent import net.minecraftforge.fluids.FluidStack import net.minecraftforge.fluids.capability.IFluidHandler +import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.capability.matter.matter @@ -18,7 +19,6 @@ import ru.dbotthepony.mc.otm.core.util.CreativeMenuComparator import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.registryName -import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.registry.MItems.BATTERY_CREATIVE private fun CreativeModeTab.Output.accept(values: Collection) { @@ -254,30 +254,29 @@ private fun addDecorativeTabItems(consumer: CreativeModeTab.Output) { } object MCreativeTabs { - var MAIN by WriteOnce() - private set - var DECORATIVE by WriteOnce() - private set + private val registry = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, OverdriveThatMatters.MOD_ID) - fun register(event: CreativeModeTabEvent.Register) { + val MAIN: CreativeModeTab by registry.register("main") { + CreativeModeTab.builder() + .title(TranslatableComponent("itemGroup.otm")) + .icon { ItemStack(BATTERY_CREATIVE, 1) } + .build() + } + val DECORATIVE: CreativeModeTab by registry.register("decorative") { + CreativeModeTab.builder() + .title(TranslatableComponent("itemGroup.otm_decorative")) + .icon { ItemStack(MRegistry.VENT.item, 1) } + .build() + } + + fun register(event: BuildCreativeModeTabContentsEvent) { CreativeMenuComparator.invalidate() - MAIN = event.registerCreativeModeTab(ResourceLocation(OverdriveThatMatters.MOD_ID, "main")) { - it.icon { ItemStack(BATTERY_CREATIVE, 1) } - it.title(TranslatableComponent("itemGroup.otm")) - - it.displayItems { _, consumer -> - addMainCreativeTabItems(consumer) - } + if (event.tab == MAIN) { + addMainCreativeTabItems(event) } - - DECORATIVE = event.registerCreativeModeTab(ResourceLocation(OverdriveThatMatters.MOD_ID, "decorative"), listOf(), listOf(MAIN)) { - it.icon { ItemStack(MRegistry.VENT.item, 1) } - it.title(TranslatableComponent("itemGroup.otm_decorative")) - - it.displayItems { _, consumer -> - addDecorativeTabItems(consumer) - } + if (event.tab == DECORATIVE) { + addDecorativeTabItems(event) } } } 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 c3a5808f4..14eb680cf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -9,8 +9,8 @@ import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.block.* import net.minecraft.world.level.block.state.BlockBehaviour import net.minecraft.world.level.block.state.BlockState -import net.minecraft.world.level.material.Material -import net.minecraft.world.level.material.MaterialColor +import net.minecraft.world.level.block.state.properties.NoteBlockInstrument +import net.minecraft.world.level.material.MapColor import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent @@ -61,7 +61,8 @@ object MRegistry { val CARGO_CRATES = DecorativeBlock(MNames.CARGO_CRATE, ::CargoCrateBlock) val DECORATIVE_CRATE = DecorativeBlock.simple(MNames.DECORATIVE_CRATE) { - BlockBehaviour.Properties.of(Material.METAL, it?.materialColor ?: MaterialColor.SNOW) + BlockBehaviour.Properties.of() + .mapColor(it?.mapColor ?: MapColor.SNOW) .sound(SoundType.METAL) .requiresCorrectToolForDrops() .explosionResistance(10f) @@ -69,7 +70,8 @@ object MRegistry { } val TRITANIUM_BLOCK = DecorativeBlock.simple(MNames.TRITANIUM_BLOCK) { - BlockBehaviour.Properties.of(Material.METAL, it?.materialColor ?: MaterialColor.COLOR_LIGHT_BLUE) + BlockBehaviour.Properties.of() + .mapColor(it?.mapColor ?: MapColor.COLOR_LIGHT_BLUE) .sound(SoundType.BASALT) .requiresCorrectToolForDrops() .explosionResistance(80f) @@ -94,7 +96,8 @@ object MRegistry { val TRITANIUM_PRESSURE_PLATE = DecorativeBlock(MNames.TRITANIUM_PRESSURE_PLATE, ::TritaniumPressurePlate) val VENT = DecorativeBlock.simple(MNames.VENT) { - BlockBehaviour.Properties.of(Material.METAL, it?.materialColor ?: MaterialColor.COLOR_LIGHT_BLUE) + BlockBehaviour.Properties.of() + .mapColor(it?.mapColor ?: MapColor.COLOR_LIGHT_BLUE) .sound(SoundType.BASALT) .requiresCorrectToolForDrops() .explosionResistance(20f) @@ -102,7 +105,8 @@ object MRegistry { } val VENT_ALTERNATIVE = DecorativeBlock.simple(MNames.VENT_ALTERNATIVE) { - BlockBehaviour.Properties.of(Material.METAL, it?.materialColor ?: MaterialColor.COLOR_LIGHT_BLUE) + BlockBehaviour.Properties.of() + .mapColor(it?.mapColor ?: MapColor.COLOR_LIGHT_BLUE) .sound(SoundType.BASALT) .requiresCorrectToolForDrops() .explosionResistance(20f) @@ -110,7 +114,8 @@ object MRegistry { } val FLOOR_TILES = ColoredDecorativeBlock.simple(MNames.FLOOR_TILES) { - BlockBehaviour.Properties.of(Material.STONE, it.materialColor) + BlockBehaviour.Properties.of() + .mapColor(it.mapColor) .sound(SoundType.STONE) .requiresCorrectToolForDrops() .strength(1.5f, 6f) @@ -128,14 +133,17 @@ object MRegistry { } val UNREFINED_FLOOR_TILES = ColoredDecorativeBlock.simple(MNames.UNREFINED_FLOOR_TILES) { - BlockBehaviour.Properties.of(Material.CLAY, it.materialColor) + BlockBehaviour.Properties.of() + .mapColor(it.mapColor) .sound(SoundType.GRAVEL) .strength(1f, 2f) } val INDUSTRIAL_GLASS = DecorativeBlock(MNames.INDUSTRIAL_GLASS) { color -> val properties = - BlockBehaviour.Properties.of(Material.GLASS, if (color != null) color.materialColor else MaterialColor.NONE) + BlockBehaviour.Properties.of() + .mapColor(if (color != null) color.mapColor else MapColor.NONE) + .instrument(NoteBlockInstrument.HAT) .destroyTime(1.5f) .explosionResistance(40f) .requiresCorrectToolForDrops() @@ -155,7 +163,9 @@ object MRegistry { val INDUSTRIAL_GLASS_PANE = DecorativeBlock(MNames.INDUSTRIAL_GLASS_PANE) { color -> val properties = - BlockBehaviour.Properties.of(Material.GLASS, if (color != null) color.materialColor else MaterialColor.NONE) + BlockBehaviour.Properties.of() + .mapColor(if (color != null) color.mapColor else MapColor.NONE) + .instrument(NoteBlockInstrument.HAT) .strength(1.25f, 5.0f) .requiresCorrectToolForDrops() .sound(SoundType.GLASS) @@ -169,7 +179,8 @@ object MRegistry { } val TRITANIUM_STRIPED_BLOCK = StripedColoredDecorativeBlock(MNames.TRITANIUM_STRIPED_BLOCK, { colorA, _ -> - Block(BlockBehaviour.Properties.of(Material.METAL, colorA.materialColor) + Block(BlockBehaviour.Properties.of() + .mapColor(colorA.mapColor) .sound(SoundType.BASALT) .requiresCorrectToolForDrops() .explosionResistance(80f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidBatteryTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidBatteryTrigger.kt index 86af33853..4a7a4a26c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidBatteryTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidBatteryTrigger.kt @@ -1,12 +1,7 @@ package ru.dbotthepony.mc.otm.triggers import com.google.gson.JsonObject -import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance -import net.minecraft.advancements.critereon.DeserializationContext -import net.minecraft.advancements.critereon.EntityPredicate.Composite -import net.minecraft.advancements.critereon.ItemPredicate -import net.minecraft.advancements.critereon.SerializationContext -import net.minecraft.advancements.critereon.SimpleCriterionTrigger +import net.minecraft.advancements.critereon.* import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import net.minecraft.world.item.ItemStack @@ -23,7 +18,7 @@ object AndroidBatteryTrigger : SimpleCriterionTrigger { + class Instance(val research: ResourceLocation?) : AbstractCriterionTriggerInstance(ID, ContextAwarePredicate.ANY), Predicate { constructor(research: AndroidResearchType) : this(research.id) override fun test(t: AndroidResearchType): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidStatusTriggers.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidStatusTriggers.kt index 28f186619..7efbf0e6d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidStatusTriggers.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidStatusTriggers.kt @@ -1,10 +1,7 @@ package ru.dbotthepony.mc.otm.triggers import com.google.gson.JsonObject -import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance -import net.minecraft.advancements.critereon.DeserializationContext -import net.minecraft.advancements.critereon.EntityPredicate -import net.minecraft.advancements.critereon.SimpleCriterionTrigger +import net.minecraft.advancements.critereon.* import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import ru.dbotthepony.mc.otm.OverdriveThatMatters @@ -18,7 +15,7 @@ object BecomeAndroidTrigger : SimpleCriterionTrigger() { @@ -40,7 +37,7 @@ object BecomeAndroidSleepTrigger : SimpleCriterionTrigger() { @@ -62,7 +59,7 @@ object BecomeAndroidDeathTrigger : SimpleCriterionTrigger() { @@ -84,7 +81,7 @@ object BecomeHumaneTrigger : SimpleCriterionTrigger() { override fun createInstance( p_66248_: JsonObject, - p_66249_: Composite, + p_286603_: ContextAwarePredicate, p_66250_: DeserializationContext ): Instance { return Instance @@ -28,5 +28,5 @@ object BlackHoleTrigger : SimpleCriterionTrigger() { trigger(player) { true } } - object Instance : AbstractCriterionTriggerInstance(ID, Composite.ANY) + object Instance : AbstractCriterionTriggerInstance(ID, ContextAwarePredicate.ANY) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/EnderTeleporterFallDeathTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/EnderTeleporterFallDeathTrigger.kt index 8d85a8313..4db93ebed 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/EnderTeleporterFallDeathTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/EnderTeleporterFallDeathTrigger.kt @@ -2,8 +2,8 @@ package ru.dbotthepony.mc.otm.triggers import com.google.gson.JsonObject import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance +import net.minecraft.advancements.critereon.ContextAwarePredicate import net.minecraft.advancements.critereon.DeserializationContext -import net.minecraft.advancements.critereon.EntityPredicate.Composite import net.minecraft.advancements.critereon.SimpleCriterionTrigger import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer @@ -18,7 +18,7 @@ object EnderTeleporterFallDeathTrigger : SimpleCriterionTrigger() { override fun createInstance( p_66248_: JsonObject, - p_66249_: Composite, + p_286603_: ContextAwarePredicate, p_66250_: DeserializationContext ): Instance { return Instance @@ -28,5 +28,5 @@ object ShockwaveTrigger : SimpleCriterionTrigger() { trigger(player) { true } } - object Instance : AbstractCriterionTriggerInstance(ID, Composite.ANY) + object Instance : AbstractCriterionTriggerInstance(ID, ContextAwarePredicate.ANY) } diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index f2003389b..94ab2eea8 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -46,7 +46,7 @@ public net.minecraft.server.level.ServerPlayer f_143380_ # containerListener protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_97762_(I)V # checkHotbarMouseClicked protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_97818_()V # recalculateQuickCraftRemaining protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_97744_(DD)Lnet/minecraft/world/inventory/Slot; # findSlot -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_274323_(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/world/item/ItemStack;IILjava/lang/String;)V # renderFloatingItem +protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_280211_(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/world/item/ItemStack;IILjava/lang/String;)V # renderFloatingItem protected net.minecraft.client.resources.TextureAtlasHolder f_118884_ # textureAtlas From b7a8f6db144a8e36cbe85f8965e74f2330a50437 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Fri, 9 Jun 2023 08:41:27 +0300 Subject: [PATCH 0577/1199] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B5=D0=B9=D1=82?= =?UTF-8?q?=D0=B5=20=D0=B2=D1=8B=D0=B6=D0=B8=D0=B2=D1=88=D0=B8=D1=85=20(?= =?UTF-8?q?=D1=82=D1=80=D0=B8=D0=B3=D0=B3=D0=B5=D1=80=D1=8B)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dbotthepony/mc/otm/triggers/HurtTrigger.kt | 17 +++++------------ .../mc/otm/triggers/KillAsAndroidTrigger.kt | 16 ++++++---------- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/HurtTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/HurtTrigger.kt index 73705d8fd..e3b797aaa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/HurtTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/HurtTrigger.kt @@ -1,14 +1,7 @@ package ru.dbotthepony.mc.otm.triggers import com.google.gson.JsonObject -import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance -import net.minecraft.advancements.critereon.DamagePredicate -import net.minecraft.advancements.critereon.DamageSourcePredicate -import net.minecraft.advancements.critereon.DeserializationContext -import net.minecraft.advancements.critereon.EntityPredicate -import net.minecraft.advancements.critereon.MinMaxBounds -import net.minecraft.advancements.critereon.SerializationContext -import net.minecraft.advancements.critereon.SimpleCriterionTrigger +import net.minecraft.advancements.critereon.* import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import net.minecraft.world.damagesource.DamageSource @@ -24,11 +17,11 @@ abstract class HurtTrigger : SimpleCriterionTrigger() { override fun createInstance( p_66248_: JsonObject, - p_66249_: EntityPredicate.Composite, + p_286603_: ContextAwarePredicate, p_66250_: DeserializationContext ): Instance { return Instance( - EntityPredicate.Composite.fromJson(p_66248_, "entity_predicate", p_66250_), + EntityPredicate.fromJson(p_66248_, "entity_predicate", p_66250_), (p_66248_["damage"] as? JsonObject)?.let(DamagePredicate::fromJson) ?: DamagePredicate.ANY ) } @@ -42,7 +35,7 @@ abstract class HurtTrigger : SimpleCriterionTrigger() { } inner class Instance( - val predicate: EntityPredicate.Composite = EntityPredicate.Composite.ANY, + val predicate: ContextAwarePredicate = ContextAwarePredicate.ANY, val damagePredicate: DamagePredicate = DamagePredicate( MinMaxBounds.Doubles.atLeast(1.0), MinMaxBounds.Doubles.atLeast(1.0), @@ -50,7 +43,7 @@ abstract class HurtTrigger : SimpleCriterionTrigger() { null, DamageSourcePredicate.ANY ) - ) : AbstractCriterionTriggerInstance(ID, EntityPredicate.Composite.ANY) { + ) : AbstractCriterionTriggerInstance(ID, ContextAwarePredicate.ANY) { override fun serializeToJson(pConditions: SerializationContext): JsonObject { return super.serializeToJson(pConditions).also { it["entity_predicate"] = predicate.toJson(pConditions) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/KillAsAndroidTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/KillAsAndroidTrigger.kt index 2d783b159..a2041e68a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/KillAsAndroidTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/KillAsAndroidTrigger.kt @@ -4,11 +4,7 @@ import com.google.common.collect.ImmutableList import com.google.gson.JsonArray import com.google.gson.JsonObject import com.google.gson.JsonSyntaxException -import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance -import net.minecraft.advancements.critereon.DeserializationContext -import net.minecraft.advancements.critereon.EntityPredicate -import net.minecraft.advancements.critereon.SerializationContext -import net.minecraft.advancements.critereon.SimpleCriterionTrigger +import net.minecraft.advancements.critereon.* import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.monster.ElderGuardian @@ -29,9 +25,9 @@ object KillAsAndroidTrigger : SimpleCriterionTrigger Date: Fri, 9 Jun 2023 12:43:08 +0700 Subject: [PATCH 0578/1199] Make font helper functions compile --- .../dbotthepony/mc/otm/client/render/Ext.kt | 79 +++++++++++++------ 1 file changed, 55 insertions(+), 24 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt index 712269a62..b68e339f9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt @@ -3,6 +3,7 @@ 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.blaze3d.vertex.VertexSorting import net.minecraft.client.gui.Font import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.renderer.MultiBufferSource @@ -104,8 +105,12 @@ private fun Font.drawScaledDuckTyped(poseStack: PoseStack, buffer: MultiBufferSo return size } +private val buffer = DynamicBufferSource(vertexSorting = VertexSorting.ORTHOGRAPHIC_Z) + private fun Font.drawDuckTyped(poseStack: PoseStack, text: Any, x: Float, y: Float, color: Int): Int { - return drawDuckTyped(poseStack, DynamicBufferSource.GUI, text, x, y, color) + val width = drawDuckTyped(poseStack, buffer, text, x, y, color) + buffer.endBatch() + return width } private fun Font.drawDuckTyped( @@ -191,6 +196,33 @@ private fun Font.drawAlignedDuckTyped( } } +private fun GuiGraphics.drawAlignedDuckTyped( + font: Font, + text: Any, + align: TextAlign, + x: Float, + y: Float, + color: Int, + drawShadow: Boolean = false, + displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, + packedLightCoords: Int = 15728880, + effectColor: Int = 0 +): Int { + return when (align) { + TextAlign.TOP_LEFT -> font.drawDuckTyped(pose(), bufferSource(), text, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.TOP_CENTER -> font.drawDuckTyped(pose(), bufferSource(), text, (x - font.widthDuckTyped(text) / 2f), y, color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.TOP_RIGHT -> font.drawDuckTyped(pose(), bufferSource(), text, (x - font.widthDuckTyped(text)), y, color, drawShadow, displayMode, packedLightCoords, effectColor) + + TextAlign.CENTER_LEFT -> font.drawDuckTyped(pose(), bufferSource(), text, x, (y - font.lineHeight / 2f), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.CENTER_CENTER -> font.drawDuckTyped(pose(), bufferSource(), text, (x - font.widthDuckTyped(text) / 2f), (y - font.lineHeight / 2f), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.CENTER_RIGHT -> font.drawDuckTyped(pose(), bufferSource(), text, (x - font.widthDuckTyped(text)), (y - font.lineHeight / 2f), color, drawShadow, displayMode, packedLightCoords, effectColor) + + TextAlign.BOTTOM_LEFT -> font.drawDuckTyped(pose(), bufferSource(), text, x, (y - font.lineHeight), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.BOTTOM_CENTER -> font.drawDuckTyped(pose(), bufferSource(), text, (x - font.widthDuckTyped(text) / 2f), (y - font.lineHeight), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.BOTTOM_RIGHT -> font.drawDuckTyped(pose(), bufferSource(), text, (x - font.widthDuckTyped(text)), (y - font.lineHeight), color, drawShadow, displayMode, packedLightCoords, effectColor) + } +} + private fun Font.drawScaledAlignedDuckTyped(poseStack: PoseStack, text: Any, scale: Float, align: TextAlign, x: Float, y: Float, color: Int): Int { return when (align) { TextAlign.TOP_LEFT -> drawScaledDuckTyped(poseStack, text, scale, x, y, color) @@ -237,8 +269,7 @@ private fun Font.drawScaledAlignedDuckTyped( } private fun GuiGraphics.drawScaledAlignedDuckTyped( - poseStack: PoseStack, - buffer: MultiBufferSource, + font: Font, text: Any, scale: Float, align: TextAlign, @@ -251,17 +282,17 @@ private fun GuiGraphics.drawScaledAlignedDuckTyped( effectColor: Int = 0 ): Int { return when (align) { - TextAlign.TOP_LEFT -> drawScaledDuckTyped(poseStack, buffer, text, scale, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.TOP_CENTER -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale / 2f), y, color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.TOP_RIGHT -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale), y, color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.TOP_LEFT -> font.drawScaledDuckTyped(pose(), bufferSource(), text, scale, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.TOP_CENTER -> font.drawScaledDuckTyped(pose(), bufferSource(), text, scale, (x - font.widthDuckTyped(text) * scale / 2f), y, color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.TOP_RIGHT -> font.drawScaledDuckTyped(pose(), bufferSource(), text, scale, (x - font.widthDuckTyped(text) * scale), y, color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.CENTER_LEFT -> drawScaledDuckTyped(poseStack, buffer, text, scale, x, (y - lineHeight / 2f * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.CENTER_CENTER -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale / 2f), (y - lineHeight * scale / 2f), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.CENTER_RIGHT -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale), (y - lineHeight * scale / 2f), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.CENTER_LEFT -> font.drawScaledDuckTyped(pose(), bufferSource(), text, scale, x, (y - font.lineHeight / 2f * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.CENTER_CENTER -> font.drawScaledDuckTyped(pose(), bufferSource(), text, scale, (x - font.widthDuckTyped(text) * scale / 2f), (y - font.lineHeight * scale / 2f), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.CENTER_RIGHT -> font.drawScaledDuckTyped(pose(), bufferSource(), text, scale, (x - font.widthDuckTyped(text) * scale), (y - font.lineHeight * scale / 2f), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.BOTTOM_LEFT -> drawScaledDuckTyped(poseStack, buffer, text, scale, x, (y - lineHeight * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.BOTTOM_CENTER -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale / 2f), (y - lineHeight * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.BOTTOM_RIGHT -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale), (y - lineHeight * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.BOTTOM_LEFT -> font.drawScaledDuckTyped(pose(), bufferSource(), text, scale, x, (y - font.lineHeight * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.BOTTOM_CENTER -> font.drawScaledDuckTyped(pose(), bufferSource(), text, scale, (x - font.widthDuckTyped(text) * scale / 2f), (y - font.lineHeight * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) + TextAlign.BOTTOM_RIGHT -> font.drawScaledDuckTyped(pose(), bufferSource(), text, scale, (x - font.widthDuckTyped(text) * scale), (y - font.lineHeight * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) } } @@ -297,18 +328,18 @@ fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, scale: Float, align: TextAlign, x: Float, y: Float, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, scale: Float, align: TextAlign, x: Float, y: Float, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) -fun GuiGraphics.drawAligned(font: Font, text: String, align: TextAlign, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(poseStack, text, align, x, y, color) -fun GuiGraphics.drawAligned(font: Font, text: Component, align: TextAlign, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(poseStack, text, align, x, y, color) -fun GuiGraphics.drawAligned(font: Font, text: FormattedCharSequence, align: TextAlign, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(poseStack, text, align, x, y, color) +fun GuiGraphics.drawAligned(font: Font, text: String, align: TextAlign, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(font, text, align, x, y, color) +fun GuiGraphics.drawAligned(font: Font, text: Component, align: TextAlign, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(font, text, align, x, y, color) +fun GuiGraphics.drawAligned(font: Font, text: FormattedCharSequence, align: TextAlign, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(font, text, align, x, y, color) -fun GuiGraphics.drawAligned(font: Font, text: String, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawAligned(poseStack, text, align, x, y, color.toInt()) -fun GuiGraphics.drawAligned(font: Font, text: Component, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawAligned(poseStack, text, align, x, y, color.toInt()) -fun GuiGraphics.drawAligned(font: Font, text: FormattedCharSequence, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawAligned(poseStack, text, align, x, y, color.toInt()) +fun GuiGraphics.drawAligned(font: Font, text: String, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawAligned(font, text, align, x, y, color.toInt()) +fun GuiGraphics.drawAligned(font: Font, text: Component, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawAligned(font, text, align, x, y, color.toInt()) +fun GuiGraphics.drawAligned(font: Font, text: FormattedCharSequence, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawAligned(font, text, align, x, y, color.toInt()) -fun GuiGraphics.drawScaledAligned(font: Font, text: String, scale: Float, align: TextAlign, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(poseStack, text, scale, align, x, y, color) -fun GuiGraphics.drawScaledAligned(font: Font, text: Component, scale: Float, align: TextAlign, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(poseStack, text, scale, align, x, y, color) -fun GuiGraphics.drawScaledAligned(font: Font, text: FormattedCharSequence, scale: Float, align: TextAlign, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(poseStack, text, scale, align, x, y, color) +fun GuiGraphics.drawScaledAligned(font: Font, text: String, scale: Float, align: TextAlign, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(font, text, scale, align, x, y, color) +fun GuiGraphics.drawScaledAligned(font: Font, text: Component, scale: Float, align: TextAlign, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(font, text, scale, align, x, y, color) +fun GuiGraphics.drawScaledAligned(font: Font, text: FormattedCharSequence, scale: Float, align: TextAlign, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(font, text, scale, align, x, y, color) -fun GuiGraphics.drawScaledAligned(font: Font, text: String, scale: Float, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(poseStack, text, scale, align, x, y, color.toInt()) -fun GuiGraphics.drawScaledAligned(font: Font, text: Component, scale: Float, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(poseStack, text, scale, align, x, y, color.toInt()) -fun GuiGraphics.drawScaledAligned(font: Font, text: FormattedCharSequence, scale: Float, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(poseStack, text, scale, align, x, y, color.toInt()) +fun GuiGraphics.drawScaledAligned(font: Font, text: String, scale: Float, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(font, text, scale, align, x, y, color.toInt()) +fun GuiGraphics.drawScaledAligned(font: Font, text: Component, scale: Float, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(font, text, scale, align, x, y, color.toInt()) +fun GuiGraphics.drawScaledAligned(font: Font, text: FormattedCharSequence, scale: Float, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(font, text, scale, align, x, y, color.toInt()) From 8262a60e10879ba8f269f633e0015f6321c27ab9 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 9 Jun 2023 12:51:49 +0700 Subject: [PATCH 0579/1199] Add update level() accessor in mixin --- .../mc/otm/mixin/MixinAbstractHurtingProjectile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinAbstractHurtingProjectile.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinAbstractHurtingProjectile.java index aa61faf9a..561b2a736 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinAbstractHurtingProjectile.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinAbstractHurtingProjectile.java @@ -29,7 +29,7 @@ public class MixinAbstractHurtingProjectile { AbstractHurtingProjectile proj = (AbstractHurtingProjectile)(Object)this; if (cap.isAndroid() && proj.getOwner() != entity) { - entity.level.playSound(entity, proj.blockPosition(), MSoundEvents.INSTANCE.getANDROID_PROJ_PARRY(), SoundSource.PLAYERS, 1.0f, 0.95f + entity.level.random.nextFloat() * 0.1f); + entity.level().playSound(entity, proj.blockPosition(), MSoundEvents.INSTANCE.getANDROID_PROJ_PARRY(), SoundSource.PLAYERS, 1.0f, 0.95f + entity.level().random.nextFloat() * 0.1f); } }); } From e4a4c8f407ca0643ceb27479ee7d66723817a183 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 9 Jun 2023 14:19:33 +0700 Subject: [PATCH 0580/1199] Bump mixingradle to 0.7.33 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 879ac047b..e44ede451 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,7 +18,7 @@ curios_mc_version=1.19.4 forge_gradle_version=[6.0,6.2) forge_version=46.0.1 -mixingradle_version=0.7.32 +mixingradle_version=0.7.33 mixin_version=0.8.5 jei_version=13.1.0.11 From 3fca6e069497dc96aba4f9f93f20b665546ec79a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 9 Jun 2023 14:22:50 +0700 Subject: [PATCH 0581/1199] Make mod compile --- .../ru/dbotthepony/mc/otm/datagen/advancements/Helpers.kt | 3 ++- .../mc/otm/datagen/recipes/MatteryRecipeProvider.kt | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/Helpers.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/Helpers.kt index 4a5289f30..7ff42e320 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/Helpers.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/Helpers.kt @@ -4,6 +4,7 @@ import net.minecraft.advancements.Advancement import net.minecraft.advancements.CriterionTriggerInstance import net.minecraft.advancements.DisplayInfo import net.minecraft.advancements.FrameType +import net.minecraft.advancements.critereon.ContextAwarePredicate import net.minecraft.advancements.critereon.EntityPredicate import net.minecraft.advancements.critereon.InventoryChangeTrigger import net.minecraft.advancements.critereon.ItemPredicate @@ -68,4 +69,4 @@ fun criterion(item: ItemLike): CriterionTriggerInstance { return InventoryChangeTrigger.TriggerInstance.hasItems(predicate(item)) } -fun EntityPredicate.wrap(): EntityPredicate.Composite = EntityPredicate.Composite.wrap(this) +fun EntityPredicate.wrap(): ContextAwarePredicate = EntityPredicate.wrap(this) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt index c034f6803..945763b6f 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.datagen.recipes +import net.minecraft.advancements.critereon.ContextAwarePredicate import net.minecraft.advancements.critereon.EntityPredicate import net.minecraft.advancements.critereon.InventoryChangeTrigger import net.minecraft.advancements.critereon.ItemPredicate @@ -38,7 +39,7 @@ fun has(p_125976_: TagKey): InventoryChangeTrigger.TriggerInstance { fun inventoryTrigger(vararg p_126012_: ItemPredicate): InventoryChangeTrigger.TriggerInstance { return InventoryChangeTrigger.TriggerInstance( - EntityPredicate.Composite.ANY, + ContextAwarePredicate.ANY, MinMaxBounds.Ints.ANY, MinMaxBounds.Ints.ANY, MinMaxBounds.Ints.ANY, From 926b9a2a1708c1b572fd7c223df6a955608bc3da Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 9 Jun 2023 14:28:53 +0700 Subject: [PATCH 0582/1199] Forge seemingly removed its lootpool deserializer patches --- .../mc/otm/data/loot/LootPoolAppender.kt | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt index 1b473af22..9f1ff7ec8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt @@ -43,35 +43,14 @@ class LootPoolAppender(conditions: Array, pools: Stream> - private val forgeHooksLootContext by lazy { - val field = ForgeHooks::class.java.getDeclaredField("lootContext") - field.isAccessible = true - field - } - - private val lootTableContextConstructor by lazy { - val clazz = ForgeHooks::class.java.declaredClasses.firstOrNull { it.name.contains("LootTableContext") } ?: throw NoSuchElementException("Unable to find ForgeHooks\$LootTableContext!") - val constructor = clazz.getDeclaredConstructor(ResourceLocation::class.java, Boolean::class.java) - constructor.isAccessible = true - constructor - } - init { val serializer = Deserializers.createLootTableSerializer().create() - val notExistingLocation = ResourceLocation("null", "null") lootPoolCodec = Codec.list(Codec.PASSTHROUGH.flatXmap({ - val dequeueHolder = forgeHooksLootContext.get(null) as ThreadLocal> - val deque = dequeueHolder.get() ?: java.util.ArrayDeque() - dequeueHolder.set(deque) - try { - deque.push(lootTableContextConstructor.newInstance(notExistingLocation, true)) DataResult.success(serializer.fromJson(it.convert(JsonOps.INSTANCE).value, LootPool::class.java)) } catch(err: JsonSyntaxException) { DataResult.error { err.message } - } finally { - deque.pop() } }, { try { From cc9f87b352203a90cf9dfe2ba4e32ffe8f07358b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 9 Jun 2023 14:39:11 +0700 Subject: [PATCH 0583/1199] Register creative tab registrar --- .../dbotthepony/mc/otm/registry/MCreativeTabs.kt | 14 +++++++++----- .../ru/dbotthepony/mc/otm/registry/MRegistry.kt | 2 ++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt index c701193b9..fd2df678e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt @@ -8,6 +8,7 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.level.material.Fluids import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.event.BuildCreativeModeTabContentsEvent +import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.fluids.FluidStack import net.minecraftforge.fluids.capability.IFluidHandler import net.minecraftforge.registries.DeferredRegister @@ -262,6 +263,7 @@ object MCreativeTabs { .icon { ItemStack(BATTERY_CREATIVE, 1) } .build() } + val DECORATIVE: CreativeModeTab by registry.register("decorative") { CreativeModeTab.builder() .title(TranslatableComponent("itemGroup.otm_decorative")) @@ -269,14 +271,16 @@ object MCreativeTabs { .build() } + internal fun initialize(bus: IEventBus) { + registry.register(bus) + } + fun register(event: BuildCreativeModeTabContentsEvent) { CreativeMenuComparator.invalidate() - if (event.tab == MAIN) { - addMainCreativeTabItems(event) - } - if (event.tab == DECORATIVE) { - addDecorativeTabItems(event) + when (event.tab) { + MAIN -> addMainCreativeTabItems(event) + DECORATIVE -> addDecorativeTabItems(event) } } } 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 14eb680cf..1acaf7a3b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -205,6 +205,8 @@ object MRegistry { bus.addListener(this::initializeCommon) bus.addListener(MStats::registerVanilla) + MCreativeTabs.initialize(bus) + DecimalProvider.register(bus) MBlocks.register(bus) From 431326de4bb6f572ff2170638cfe35b01245aa0d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 9 Jun 2023 14:51:27 +0700 Subject: [PATCH 0584/1199] Render baked text immediately when rendering inside GUI --- .../ru/dbotthepony/mc/otm/client/render/Ext.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt index b68e339f9..4cc6ba666 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt @@ -208,7 +208,7 @@ private fun GuiGraphics.drawAlignedDuckTyped( packedLightCoords: Int = 15728880, effectColor: Int = 0 ): Int { - return when (align) { + val width = when (align) { TextAlign.TOP_LEFT -> font.drawDuckTyped(pose(), bufferSource(), text, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) TextAlign.TOP_CENTER -> font.drawDuckTyped(pose(), bufferSource(), text, (x - font.widthDuckTyped(text) / 2f), y, color, drawShadow, displayMode, packedLightCoords, effectColor) TextAlign.TOP_RIGHT -> font.drawDuckTyped(pose(), bufferSource(), text, (x - font.widthDuckTyped(text)), y, color, drawShadow, displayMode, packedLightCoords, effectColor) @@ -221,6 +221,10 @@ private fun GuiGraphics.drawAlignedDuckTyped( TextAlign.BOTTOM_CENTER -> font.drawDuckTyped(pose(), bufferSource(), text, (x - font.widthDuckTyped(text) / 2f), (y - font.lineHeight), color, drawShadow, displayMode, packedLightCoords, effectColor) TextAlign.BOTTOM_RIGHT -> font.drawDuckTyped(pose(), bufferSource(), text, (x - font.widthDuckTyped(text)), (y - font.lineHeight), color, drawShadow, displayMode, packedLightCoords, effectColor) } + + flush() + + return width } private fun Font.drawScaledAlignedDuckTyped(poseStack: PoseStack, text: Any, scale: Float, align: TextAlign, x: Float, y: Float, color: Int): Int { @@ -281,7 +285,7 @@ private fun GuiGraphics.drawScaledAlignedDuckTyped( packedLightCoords: Int = 15728880, effectColor: Int = 0 ): Int { - return when (align) { + val width = when (align) { TextAlign.TOP_LEFT -> font.drawScaledDuckTyped(pose(), bufferSource(), text, scale, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) TextAlign.TOP_CENTER -> font.drawScaledDuckTyped(pose(), bufferSource(), text, scale, (x - font.widthDuckTyped(text) * scale / 2f), y, color, drawShadow, displayMode, packedLightCoords, effectColor) TextAlign.TOP_RIGHT -> font.drawScaledDuckTyped(pose(), bufferSource(), text, scale, (x - font.widthDuckTyped(text) * scale), y, color, drawShadow, displayMode, packedLightCoords, effectColor) @@ -294,6 +298,10 @@ private fun GuiGraphics.drawScaledAlignedDuckTyped( TextAlign.BOTTOM_CENTER -> font.drawScaledDuckTyped(pose(), bufferSource(), text, scale, (x - font.widthDuckTyped(text) * scale / 2f), (y - font.lineHeight * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) TextAlign.BOTTOM_RIGHT -> font.drawScaledDuckTyped(pose(), bufferSource(), text, scale, (x - font.widthDuckTyped(text) * scale), (y - font.lineHeight * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) } + + flush() + + return width } fun Font.drawAligned(poseStack: PoseStack, text: String, align: TextAlign, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(poseStack, text, align, x, y, color) From b31bbf151c54dea2a432e0f7334aac8c27bbc6aa Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 9 Jun 2023 14:59:29 +0700 Subject: [PATCH 0585/1199] Fix text selection in text input panel --- .../mc/otm/client/screen/panels/input/TextInputPanel.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt index 234446ab2..7fccf017b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt @@ -1156,6 +1156,7 @@ open class TextInputPanel( //RenderSystem.logicOp(GlStateManager.LogicOp.NOR) RenderSystem.disableDepthTest() RenderSystem.defaultBlendFunc() + RenderSystem.enableBlend() val builder = tesselator.builder From b757d529d9186a2b6ba183b911d8a357f698ba37 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Fri, 9 Jun 2023 11:50:21 +0300 Subject: [PATCH 0586/1199] bump forge + jei versions --- gradle.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index e44ede451..9b6ca5a1a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,15 +13,15 @@ use_commit_hash_in_version=true mc_version=1.20 use_parchment=false parchment_version=2023.03.12-1.19.3 -jei_mc_version=1.19.4 +jei_mc_version=1.20 curios_mc_version=1.19.4 forge_gradle_version=[6.0,6.2) -forge_version=46.0.1 +forge_version=46.0.2 mixingradle_version=0.7.33 mixin_version=0.8.5 -jei_version=13.1.0.11 +jei_version=14.0.0.4 jupiter_version=5.9.2 mekanism_version=1.19.2-10.3.5.homebaked curios_version=5.1.5.1 From 660fe93297561280d9426c52dfdf192edf515583 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Fri, 9 Jun 2023 12:26:24 +0300 Subject: [PATCH 0587/1199] update JEI plugin + added back to runtime --- build.gradle.kts | 2 +- .../otm/compat/jei/PlatePressRecipeCategory.kt | 18 +++++++++--------- .../mc/otm/compat/jei/SkinDrawable.kt | 6 +++--- .../mc/otm/compat/jei/StretchingDrawable.kt | 6 +++--- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 2076e4873..7eef78589 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -188,7 +188,7 @@ dependencies { compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-common-api:${jei_version}")) compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge-api:${jei_version}")) - //runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}")) + runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}")) //runtimeOnly(fg.deobf("curse.maven:jade-324717:${jade_id}")) //runtimeOnly(fg.deobf("curse.maven:configured-457570:${configured_id}")) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt index 61e9cb38c..2e46da76f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.compat.jei -import com.mojang.blaze3d.vertex.PoseStack import mezz.jei.api.gui.builder.IRecipeLayoutBuilder import mezz.jei.api.gui.drawable.IDrawable import mezz.jei.api.gui.ingredient.IRecipeSlotsView @@ -8,6 +7,7 @@ import mezz.jei.api.recipe.IFocusGroup import mezz.jei.api.recipe.RecipeIngredientRole import mezz.jei.api.recipe.RecipeType import mezz.jei.api.recipe.category.IRecipeCategory +import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.ItemStack @@ -45,19 +45,19 @@ object PlatePressRecipeCategory : IRecipeCategory, IDrawable { return MItems.PLATE_PRESS.description } - override fun draw(poseStack: PoseStack, xOffset: Int, yOffset: Int) { + override fun draw(graphics: GuiGraphics, xOffset: Int, yOffset: Int) { @Suppress("name_shadowing") val xOffset = xOffset.toFloat() @Suppress("name_shadowing") val yOffset = yOffset.toFloat() - AbstractSlotPanel.SLOT_BACKGROUND.render(poseStack, X_INPUT + xOffset, Y_INPUT + yOffset) - AbstractSlotPanel.SLOT_BACKGROUND.render(poseStack, X_OUTPUT + xOffset, Y_OUTPUT + yOffset) - ProgressGaugePanel.GAUGE_BACKGROUND.render(poseStack, X_ARROW + xOffset, Y_ARROW + yOffset) + AbstractSlotPanel.SLOT_BACKGROUND.render(graphics, X_INPUT + xOffset, Y_INPUT + yOffset) + AbstractSlotPanel.SLOT_BACKGROUND.render(graphics, X_OUTPUT + xOffset, Y_OUTPUT + yOffset) + ProgressGaugePanel.GAUGE_BACKGROUND.render(graphics, X_ARROW + xOffset, Y_ARROW + yOffset) ProgressGaugePanel.GAUGE_FOREGROUND.renderPartial( - poseStack, + graphics, X_ARROW + xOffset, Y_ARROW + yOffset, width = (((System.currentTimeMillis() % 4000L) / 4000f) * ProgressGaugePanel.GAUGE_FOREGROUND.width).roundToInt().toFloat()) @@ -66,16 +66,16 @@ object PlatePressRecipeCategory : IRecipeCategory, IDrawable { override fun draw( recipe: PlatePressRecipe, recipeSlotsView: IRecipeSlotsView, - stack: PoseStack, + graphics: GuiGraphics, mouseX: Double, mouseY: Double ) { - minecraft.font.drawAligned(stack, TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), TextAlign.TOP_CENTER, 40f, 30f, RGBAColor.BLACK) + graphics.drawAligned(minecraft.font, TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), TextAlign.TOP_CENTER, 40f, 30f, RGBAColor.BLACK) val average = recipe.experience.toString() if (average != "0.0") { - minecraft.font.drawAligned(stack, TranslatableComponent("gui.jei.category.smelting.experience", average), TextAlign.TOP_CENTER, 40f, 1f, RGBAColor.BLACK) + graphics.drawAligned(minecraft.font, TranslatableComponent("gui.jei.category.smelting.experience", average), TextAlign.TOP_CENTER, 40f, 1f, RGBAColor.BLACK) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/SkinDrawable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/SkinDrawable.kt index b6d66e1f8..ff81b073e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/SkinDrawable.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/SkinDrawable.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.mc.otm.compat.jei -import com.mojang.blaze3d.vertex.PoseStack import mezz.jei.api.gui.drawable.IDrawable +import net.minecraft.client.gui.GuiGraphics import ru.dbotthepony.mc.otm.client.render.MatterySprite class SkinDrawable(val element: MatterySprite) : IDrawable { @@ -13,7 +13,7 @@ class SkinDrawable(val element: MatterySprite) : IDrawable { return element.height.toInt() } - override fun draw(poseStack: PoseStack, xOffset: Int, yOffset: Int) { - element.render(poseStack, xOffset.toFloat(), yOffset.toFloat()) + override fun draw(graphics: GuiGraphics, xOffset: Int, yOffset: Int) { + element.render(graphics, xOffset.toFloat(), yOffset.toFloat()) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/StretchingDrawable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/StretchingDrawable.kt index da3566a38..7d47e2454 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/StretchingDrawable.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/StretchingDrawable.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.mc.otm.compat.jei -import com.mojang.blaze3d.vertex.PoseStack import mezz.jei.api.gui.drawable.IDrawable +import net.minecraft.client.gui.GuiGraphics import ru.dbotthepony.mc.otm.client.render.StretchingRectangleElement class StretchingDrawable(val element: StretchingRectangleElement, val rectWidth: Int, val rectHeight: Int) : IDrawable { @@ -13,7 +13,7 @@ class StretchingDrawable(val element: StretchingRectangleElement, val rectWidth: return rectHeight } - override fun draw(poseStack: PoseStack, xOffset: Int, yOffset: Int) { - element.render(poseStack, xOffset.toFloat(), yOffset.toFloat(), rectWidth.toFloat(), rectHeight.toFloat()) + override fun draw(graphics: GuiGraphics, xOffset: Int, yOffset: Int) { + element.render(graphics, xOffset.toFloat(), yOffset.toFloat(), rectWidth.toFloat(), rectHeight.toFloat()) } } From 47528897fc610bb4084a6f9a13ded6d080d5b4c9 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Fri, 9 Jun 2023 14:00:21 +0300 Subject: [PATCH 0588/1199] bump more deps --- build.gradle.kts | 6 +++--- gradle.properties | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 7eef78589..f5cf9ff53 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -190,12 +190,12 @@ dependencies { compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge-api:${jei_version}")) runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}")) - //runtimeOnly(fg.deobf("curse.maven:jade-324717:${jade_id}")) + runtimeOnly(fg.deobf("curse.maven:jade-324717:${jade_id}")) //runtimeOnly(fg.deobf("curse.maven:configured-457570:${configured_id}")) compileOnly(fg.deobf("curse.maven:ad-astra-635042:${ad_astra_id}")) - compileOnly(fg.deobf("curse.maven:resourceful-lib-570073:4378849")) - compileOnly(fg.deobf("curse.maven:resourceful-config-714059:4394154")) + compileOnly(fg.deobf("curse.maven:resourceful-lib-570073:4574449")) + compileOnly(fg.deobf("curse.maven:resourceful-config-714059:4444198")) compileOnly(fg.deobf("curse.maven:botarium-704113:4416456")) // runtimeOnly(fg.deobf("curse.maven:worldedit-225608:${worldedit_fileid}")) diff --git a/gradle.properties b/gradle.properties index 9b6ca5a1a..0c5748c2d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -25,9 +25,9 @@ jei_version=14.0.0.4 jupiter_version=5.9.2 mekanism_version=1.19.2-10.3.5.homebaked curios_version=5.1.5.1 -cosmetic_armor_reworked_id=4439659 +cosmetic_armor_reworked_id=4575609 ad_astra_id=4452010 -jade_id=4439089 +jade_id=4573193 configured_id=4462894 kotlin_for_forge_version=3.1.0 From e660810c735d45864e9d1168c7b39869e6e6bb6c Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Fri, 9 Jun 2023 14:02:19 +0300 Subject: [PATCH 0589/1199] move tools tags to vanilla from forge --- .../ru/dbotthepony/mc/otm/datagen/tags/Tags.kt | 13 ++++++------- .../dbotthepony/mc/otm/datagen/tags/TagsProvider.kt | 1 + 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index 71cd971b5..e6746402c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -104,14 +104,13 @@ fun addTags(tagsProvider: TagsProvider) { .add("leggings", MItems.SIMPLE_TRITANIUM_PANTS) .add("boots", MItems.SIMPLE_TRITANIUM_BOOTS) - tagsProvider.items.forge("tools") - .add("swords", MItems.TRITANIUM_SWORD) - .add("axes", MItems.TRITANIUM_AXE) - .add("pickaxes", MItems.TRITANIUM_PICKAXE) - .add("shovels", MItems.TRITANIUM_SHOVEL) - .add("hoes", MItems.TRITANIUM_HOE) - .add("shields", MItems.TRITANIUM_SHIELD) + tagsProvider.items.minecraft("swords").add(MItems.TRITANIUM_SWORD) + tagsProvider.items.minecraft("axes").add(MItems.TRITANIUM_AXE) + tagsProvider.items.minecraft("pickaxes").add(MItems.TRITANIUM_PICKAXE) + tagsProvider.items.minecraft("shovels").add(MItems.TRITANIUM_SHOVEL) + tagsProvider.items.minecraft("hoes").add(MItems.TRITANIUM_HOE) tagsProvider.items.forge("shears").add(MItems.TRITANIUM_SHEARS) + tagsProvider.items.forge("shields").add(MItems.TRITANIUM_SHIELD) tagsProvider.blocks.Appender(BlockTags.STAIRS) .add(MRegistry.FLOOR_TILES_STAIRS.blocks.values) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt index 671566490..a09ae7255 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt @@ -120,6 +120,7 @@ class TagsProvider(private val event: GatherDataEvent) { } fun forge(path: String) = Appender(ResourceLocation("forge", path)) + fun minecraft(path: String) = Appender(ResourceLocation("minecraft", path)) override fun addTags(provider: HolderLookup.Provider) { for ((tag, values) in tags) { From 67aec1a731beca31f3f20199b7b2a29a84e2ad4f Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Fri, 9 Jun 2023 14:38:56 +0300 Subject: [PATCH 0590/1199] fixed mixin warnings --- .../java/ru/dbotthepony/mc/otm/mixin/MixinInventory.java | 5 ++++- .../java/ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java | 5 ++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinInventory.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinInventory.java index 981e1f8cd..b2104d243 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinInventory.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinInventory.java @@ -10,6 +10,7 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraftforge.registries.ForgeRegistries; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -23,7 +24,9 @@ import java.util.function.Predicate; @Mixin(Inventory.class) public class MixinInventory { - @Shadow Player player; + @Final + @Shadow + public Player player; @Inject( method = "add(ILnet/minecraft/world/item/ItemStack;)Z", diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java index b9a744c07..0ea0fe3f3 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java @@ -15,8 +15,6 @@ import ru.dbotthepony.mc.otm.config.ServerConfig; import ru.dbotthepony.mc.otm.core.util.ExperienceUtilsKt; import ru.dbotthepony.mc.otm.registry.MItems; -import java.util.Random; - @SuppressWarnings("ConstantConditions") @Mixin(LivingEntity.class) public class MixinLivingEntity { @@ -38,7 +36,8 @@ public class MixinLivingEntity { } } - @Shadow Player lastHurtByPlayer; + @Shadow + protected Player lastHurtByPlayer; @Inject( method = "dropExperience()V", From 9b5871a320c693e3b492d0b7eabbd5bf88667ac4 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 9 Jun 2023 19:22:47 +0700 Subject: [PATCH 0591/1199] i world like my text be not outside my screen thanks --- .../kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index 59b24daf3..6e9372b08 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -249,8 +249,8 @@ object MatteryGUI { val formattedPower = mattery.androidEnergy.batteryLevel.formatPower() - event.guiGraphics.drawScaledAligned(minecraft.font, formattedPower, 0.5f, TextAlign.CENTER_LEFT, (left + 83f) * 2f, (top + 5.5f) * 2f, RGBAColor.BLACK.toInt()) - event.guiGraphics.drawScaledAligned(minecraft.font, formattedPower, 0.5f, TextAlign.CENTER_LEFT, (left + 82f) * 2f, (top + 4.5f) * 2f, RGBAColor.YELLOW.toInt()) + event.guiGraphics.drawScaledAligned(gui.font, formattedPower, 0.5f, TextAlign.CENTER_LEFT, left + 83f, top + 4f, RGBAColor.BLACK.toInt()) + event.guiGraphics.drawScaledAligned(gui.font, formattedPower, 0.5f, TextAlign.CENTER_LEFT, left + 82f, top + 3f, RGBAColor.YELLOW.toInt()) } } @@ -325,8 +325,8 @@ object MatteryGUI { if (ply.absorptionAmount > 0) formattedHealth = "%d+%d/%d".format(ply.health.toInt(), ply.absorptionAmount.toInt(), ply.maxHealth.toInt()) - event.guiGraphics.drawScaledAligned(minecraft.font, formattedHealth, 0.5f, TextAlign.CENTER_RIGHT, (left - 1f) * 2f, (top + 5.5f) * 2f, RGBAColor.BLACK.toInt()) - event.guiGraphics.drawScaledAligned(minecraft.font, formattedHealth, 0.5f, TextAlign.CENTER_RIGHT, (left - 2f) * 2f, (top + 4.5f) * 2f, getHealthColorForPlayer(ply)) + event.guiGraphics.drawScaledAligned(minecraft.font, formattedHealth, 0.5f, TextAlign.CENTER_RIGHT, left - 4f, top + 4f, RGBAColor.BLACK.toInt()) + event.guiGraphics.drawScaledAligned(minecraft.font, formattedHealth, 0.5f, TextAlign.CENTER_RIGHT, left - 5f, top + 3f, getHealthColorForPlayer(ply)) } } From d77f735fa87b41f4574196eb65e34313a7264b3e Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Fri, 9 Jun 2023 19:01:29 +0300 Subject: [PATCH 0592/1199] redone tritanium recycle recipes, added simple armor recycling, removed shield from tools group --- .../mc/otm/datagen/items/ItemModels.kt | 2 +- .../mc/otm/datagen/recipes/BlastingRecipes.kt | 48 ++++++++++++------- .../mc/otm/registry/MCreativeTabs.kt | 1 + .../ru/dbotthepony/mc/otm/registry/MItems.kt | 1 - 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index 69ab5482e..874a4d749 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -85,7 +85,7 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.generated(MItems.EXOPACK_PROBE) - provider.handheld(MItems.TRITANIUM_TOOLS.filter { it != MItems.TRITANIUM_SHIELD }) + provider.handheld(MItems.TRITANIUM_TOOLS) provider.generated(MItems.TRITANIUM_ARMOR) provider.generated(MItems.SIMPLE_TRITANIUM_ARMOR) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt index 30479a59e..db672b619 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt @@ -1,34 +1,50 @@ package ru.dbotthepony.mc.otm.datagen.recipes +import com.google.common.collect.Lists import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.data.recipes.RecipeCategory import net.minecraft.data.recipes.SimpleCookingRecipeBuilder +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Ingredient -import ru.dbotthepony.mc.otm.core.registryName +import net.minecraft.world.level.ItemLike import ru.dbotthepony.mc.otm.datagen.modLocation import ru.dbotthepony.mc.otm.registry.MItemTags import ru.dbotthepony.mc.otm.registry.MItems +import java.util.* import java.util.function.Consumer +private fun Consumer.addRecyclingRecipe(inputs: Collection, result: Item, name: String) { + val inputStacks: LinkedList = Lists.newLinkedList() + inputs.forEach { inputStacks.add(ItemStack(it)) } + + val smelting = SimpleCookingRecipeBuilder.smelting( + Ingredient.of(inputStacks.stream()), + RecipeCategory.MISC, + result, + 0f, + 200 + ) + inputs.forEach { smelting.unlockedBy(it) } + smelting.save(this, modLocation("smelting/${name}")) + + val blasting = SimpleCookingRecipeBuilder.blasting( + Ingredient.of(inputStacks.stream()), + RecipeCategory.MISC, + result, + 0f, + 100 + ) + inputs.forEach { blasting.unlockedBy(it) } + blasting.save(this, modLocation("blasting/${name}")) +} + fun addBlastingRecipes(consumer: Consumer) { SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItems.MIRROR_COMPOUND), RecipeCategory.MISC, MItems.MIRROR, 0.1f, 100).unlockedBy(MItems.MIRROR_COMPOUND).save(consumer) SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_PLATES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 100).unlockedBy(MItemTags.TRITANIUM_PLATES).save(consumer, modLocation("tritanium_ingot_from_plates")) SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_PLATES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 50).unlockedBy(MItemTags.TRITANIUM_PLATES).save(consumer, modLocation("tritanium_ingot_from_plates_blasting")) - for (tool in MItems.TRITANIUM_TOOLS) { - SimpleCookingRecipeBuilder.smelting( - Ingredient.of(tool), - RecipeCategory.MISC, - MItems.TRITANIUM_NUGGET, - 0f, 200 - ).unlockedBy(MItems.TRITANIUM_NUGGET).save(consumer, modLocation("smelting/tritanium_nugget_from_${tool.registryName!!.path}")) - - SimpleCookingRecipeBuilder.blasting( - Ingredient.of(tool), - RecipeCategory.MISC, - MItems.TRITANIUM_NUGGET, - 0f, 100 - ).unlockedBy(MItems.TRITANIUM_NUGGET).save(consumer, modLocation("blasting/tritanium_nugget_from_${tool.registryName!!.path}")) - } + consumer.addRecyclingRecipe(MItems.TRITANIUM_TOOLS, MItems.TRITANIUM_NUGGET, "tritanium_nugget_from_tools") + consumer.addRecyclingRecipe(MItems.SIMPLE_TRITANIUM_ARMOR, MItems.TRITANIUM_NUGGET, "tritanium_nugger_from_armor") } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt index fd2df678e..26cd6e470 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt @@ -148,6 +148,7 @@ private fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { accept(MItems.TRITANIUM_INGOT_BLOCK) accept(MItems.TRITANIUM_TOOLS) + accept(MItems.TRITANIUM_SHIELD) accept(MItems.SIMPLE_TRITANIUM_ARMOR) accept(MItems.TRITANIUM_ARMOR) 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 f24e37f4d..5e916a1ef 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -215,7 +215,6 @@ object MItems { ::TRITANIUM_PICKAXE, ::TRITANIUM_HOE, ::TRITANIUM_SHEARS, - ::TRITANIUM_SHIELD, ) val TRITANIUM_HELMET: TritaniumArmorItem by registry.register(MNames.TRITANIUM_HELMET) { TritaniumArmorItem(ArmorItem.Type.HELMET) } From d1e94f4154d349616338ff807f3372e10265cbfb Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 10 Jun 2023 01:37:28 +0700 Subject: [PATCH 0593/1199] =?UTF-8?q?YuRaNnNzZZ=20=E2=80=94=20=D0=A1=D0=B5?= =?UTF-8?q?=D0=B3=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=201:37=20=D0=9D=D0=A3?= =?UTF-8?q?=20=D0=9D=D0=95=20=D0=A3=D0=9C=D0=95=D0=AE=20=D0=AF=20=D0=92=20?= =?UTF-8?q?=D0=9A=D0=9E=D0=A2=D0=9B=D0=98=D0=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/datagen/recipes/BlastingRecipes.kt | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt index db672b619..9ebe10482 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt @@ -15,28 +15,17 @@ import java.util.* import java.util.function.Consumer private fun Consumer.addRecyclingRecipe(inputs: Collection, result: Item, name: String) { - val inputStacks: LinkedList = Lists.newLinkedList() - inputs.forEach { inputStacks.add(ItemStack(it)) } + val inputStacks = inputs.map(::ItemStack) - val smelting = SimpleCookingRecipeBuilder.smelting( + SimpleCookingRecipeBuilder.smelting( Ingredient.of(inputStacks.stream()), - RecipeCategory.MISC, - result, - 0f, - 200 - ) - inputs.forEach { smelting.unlockedBy(it) } - smelting.save(this, modLocation("smelting/${name}")) + RecipeCategory.MISC, result, 0f, 200 + ).also { r -> inputs.forEach { r.unlockedBy(it) } }.save(this, modLocation("smelting/${name}")) - val blasting = SimpleCookingRecipeBuilder.blasting( + SimpleCookingRecipeBuilder.blasting( Ingredient.of(inputStacks.stream()), - RecipeCategory.MISC, - result, - 0f, - 100 - ) - inputs.forEach { blasting.unlockedBy(it) } - blasting.save(this, modLocation("blasting/${name}")) + RecipeCategory.MISC, result, 0f, 100 + ).also { r -> inputs.forEach { r.unlockedBy(it) } }.save(this, modLocation("blasting/${name}")) } fun addBlastingRecipes(consumer: Consumer) { From 6181da4ba5f69839004f747e56d98a1c88400538 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 10 Jun 2023 12:43:14 +0700 Subject: [PATCH 0594/1199] Bump forge to 46.0.10 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 0c5748c2d..b7e9b5575 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,7 +17,7 @@ jei_mc_version=1.20 curios_mc_version=1.19.4 forge_gradle_version=[6.0,6.2) -forge_version=46.0.2 +forge_version=46.0.10 mixingradle_version=0.7.33 mixin_version=0.8.5 From 0db20bc389af26823b5f384c8f5280c7458e09c8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 10 Jun 2023 13:08:12 +0700 Subject: [PATCH 0595/1199] Add missing profiled gauge panel to plate press screen --- .../dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt index 8decb70d3..d937ce9fd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt @@ -9,6 +9,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu class PlatePressScreen(menu: PlatePressMenu, inventory: Inventory, title: Component) : @@ -16,7 +17,7 @@ class PlatePressScreen(menu: PlatePressMenu, inventory: Inventory, title: Compon override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! - WidePowerGaugePanel(this, frame, menu.energyWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) + WideProfiledPowerGaugePanel(this, frame, menu.profiledEnergy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) SlotPanel(this, frame, menu.inputSlot, 56f, PROGRESS_SLOT_TOP) From 87e2c8d1d8d523e36512f96d542947f516ad5684 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 10 Jun 2023 20:18:21 +0700 Subject: [PATCH 0596/1199] Update matter interface to match energy one, add profiled matter storage Add weighted average to profiled storage to make "transferred last second" display less stiff --- .../dbotthepony/mc/otm/GlobalEventHandler.kt | 3 +- .../entity/matter/MatterBottlerBlockEntity.kt | 13 +- .../matter/MatterCapacitorBankBlockEntity.kt | 4 +- .../matter/MatterDecomposerBlockEntity.kt | 9 +- .../matter/MatterReconstructorBlockEntity.kt | 9 +- .../matter/MatterRecyclerBlockEntity.kt | 9 +- .../matter/MatterReplicatorBlockEntity.kt | 15 +- .../otm/capability/AbstractProfiledStorage.kt | 206 ++++++++++++++++++ .../energy/ProfiledEnergyStorage.kt | 158 +------------- .../otm/capability/matter/IMatterStorage.kt | 37 +++- .../capability/matter/MatterStorageImpl.kt | 14 -- .../matter/ProfiledMatterStorage.kt | 45 ++++ .../screen/matter/MatterBottlerScreen.kt | 3 +- .../screen/matter/MatterDecomposerScreen.kt | 3 +- .../matter/MatterReconstructorScreen.kt | 3 +- .../screen/matter/MatterRecyclerScreen.kt | 3 +- .../screen/matter/MatterReplicatorScreen.kt | 3 +- .../widget/HorizontalPowerGaugePanel.kt | 7 +- .../client/screen/widget/MatterGaugePanel.kt | 62 ++++++ .../client/screen/widget/PowerGaugePanel.kt | 22 +- .../mc/otm/graph/matter/MatterGraph.kt | 6 +- .../mc/otm/menu/matter/MatterBottlerMenu.kt | 8 +- .../otm/menu/matter/MatterDecomposerMenu.kt | 6 +- .../menu/matter/MatterReconstructorMenu.kt | 6 +- .../mc/otm/menu/matter/MatterRecyclerMenu.kt | 6 +- .../otm/menu/matter/MatterReplicatorMenu.kt | 6 +- .../mc/otm/menu/matter/MatterScannerMenu.kt | 4 +- .../mc/otm/menu/tech/AndroidStationMenu.kt | 4 +- .../mc/otm/menu/tech/BatteryBankMenu.kt | 7 +- .../mc/otm/menu/tech/ChemicalGeneratorMenu.kt | 5 +- .../mc/otm/menu/tech/EnergyServoMenu.kt | 5 +- .../mc/otm/menu/tech/PlatePressMenu.kt | 4 +- .../menu/widget/ProfiledEnergyGaugeWidget.kt | 44 ---- .../menu/widget/ProfiledLevelGaugeWidget.kt | 62 ++++++ 34 files changed, 495 insertions(+), 306 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/capability/AbstractProfiledStorage.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/ProfiledMatterStorage.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProfiledEnergyGaugeWidget.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProfiledLevelGaugeWidget.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt index 8eaa30141..c290f27f9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt @@ -15,6 +15,7 @@ import net.minecraftforge.event.server.ServerStoppedEvent import net.minecraftforge.event.server.ServerStoppingEvent import net.minecraftforge.fml.loading.FMLLoader import org.apache.logging.log4j.LogManager +import ru.dbotthepony.mc.otm.capability.AbstractProfiledStorage import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.util.IConditionalTickable @@ -149,7 +150,7 @@ fun onServerTick(event: ServerTickEvent) { postServerTick.tick() // чтоб не плодить кучу подписчиков, вызовем напрямую отсюда Abstract6Graph.tick() - ProfiledEnergyStorage.onServerPostTick() + AbstractProfiledStorage.onServerPostTick() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index 812c7045d..0cb9a6b8f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -21,6 +21,7 @@ import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl +import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.graph.matter.MatterGraph @@ -99,11 +100,11 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } }) - val matter: MatterStorageImpl = object : MatterStorageImpl(this::setChangedLight, FlowDirection.BI_DIRECTIONAL, ::CAPACITY) { + val matter: ProfiledMatterStorage = ProfiledMatterStorage(object : MatterStorageImpl(this::setChangedLight, FlowDirection.BI_DIRECTIONAL, ::CAPACITY) { override val matterFlow: FlowDirection get() { return if (this@MatterBottlerBlockEntity.isBottling) FlowDirection.INPUT else FlowDirection.OUTPUT } - } + }) val matterNode = SimpleMatterNode(matter = matter) @@ -232,7 +233,7 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : energy.extractEnergy(ENERGY_CONSUMPTION * matter / MATTER_EXCHANGE_RATE, false) capability.receiveMatter(matter, false) - this.matter.extractMatterInner(matter, false) + this.matter.extractMatter(matter, false) if (capability.missingMatter.isZero) { for (i in 3..5) { @@ -256,7 +257,7 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : this.energy.extractEnergy(ENERGY_CONSUMPTION * matter / MATTER_EXCHANGE_RATE,false) capability.extractMatter(matter, false) - this.matter.receiveMatterInner(matter, false) + this.matter.receiveMatter(matter, false) if (capability.storedMatter.isZero) { for (i in 2 downTo 0) { @@ -275,9 +276,9 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } if (!isBottling && !matter.storedMatter.isZero && graph != null) { - val diff = matter.extractMatterInner(matter.storedMatter, true) + val diff = matter.extractMatter(matter.storedMatter, true) val diff2 = graph.receiveMatter(diff, true) - matter.extractMatterInner(diff2, false) + matter.extractMatter(diff2, false) graph.receiveMatter(diff2, false) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt index cc597834f..ba365952a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt @@ -70,7 +70,7 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) for (stack in container) { if (!stack.isEmpty) { stack.getCapability(MatteryCapability.MATTER).ifPresent { - val diff = it.receiveMatter(howMuch, simulate) + val diff = it.receiveMatterChecked(howMuch, simulate) summ += diff howMuch -= diff } @@ -99,7 +99,7 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) for (stack in container) { if (!stack.isEmpty) { stack.getCapability(MatteryCapability.MATTER).ifPresent { - val diff = it.extractMatter(howMuch, simulate) + val diff = it.extractMatterChecked(howMuch, simulate) summ += diff howMuch -= diff } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index 359024ca2..987166ca1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -16,6 +16,7 @@ import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl +import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer @@ -125,7 +126,7 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) savetables.stateful(::energy, ENERGY_KEY) } - val matter = MatterStorageImpl(::setChangedLight, FlowDirection.OUTPUT, ::CAPACITY) + val matter = ProfiledMatterStorage(MatterStorageImpl(::setChangedLight, FlowDirection.OUTPUT, ::CAPACITY)) val matterNode = SimpleMatterNode(matter = matter) init { @@ -172,7 +173,7 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) return Status.SUCCESS } - job.matterValue -= matter.receiveMatterInner(job.matterValue, false) + job.matterValue -= matter.receiveMatter(job.matterValue, false) if (job.matterValue.isPositive) { return Status.FAILURE_MATTER @@ -215,10 +216,10 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) val grid = matterNode.graph as MatterGraph? ?: return if (!matter.storedMatter.isZero) { - val diff = matter.extractMatterInner(matter.storedMatter, true) + val diff = matter.extractMatter(matter.storedMatter, true) val diff2 = grid.receiveMatter(diff, true) - matter.extractMatterInner(diff2, false) + matter.extractMatter(diff2, false) grid.receiveMatter(diff2, false) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt index 65f5b559b..6f09ba35c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt @@ -22,6 +22,7 @@ import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage import ru.dbotthepony.mc.otm.capability.matter.IPatternState import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl +import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer @@ -54,7 +55,7 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) var isUnableToProcess = false private set - val matter = MatterStorageImpl(::setChangedLight, FlowDirection.INPUT, ::CAPACITY) + val matter = ProfiledMatterStorage(MatterStorageImpl(::setChangedLight, FlowDirection.INPUT, ::CAPACITY)) val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::setChangedLight, ENERGY_VALUES)) val matterNode = object : MatterNode() { @@ -232,12 +233,12 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) if (graph != null) { val toDrain = (matterPerTick * EXTRACT_TICKS.coerceAtMost(item.damageValue) - matter.storedMatter).coerceAtLeast(Decimal.ZERO).coerceAtMost(matter.missingMatter) - matter.receiveMatterInner(graph.extractMatter(toDrain, false), false) + matter.receiveMatter(graph.extractMatter(toDrain, false), false) } } val toDrain = matterPerTick * (progressPerTick / this.progressPerTick) - val drain = matter.extractMatterInner(toDrain, true) + val drain = matter.extractMatter(toDrain, true) if (!drain.isPositive) { isUnableToProcess = true return @@ -253,7 +254,7 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) repairProgress += progressPerTick energy.extractEnergy(ENERGY_CONSUMPTION * (progressPerTick / this.progressPerTick), false) - matter.extractMatterInner(matterPerTick * (progressPerTick / this.progressPerTick), false) + matter.extractMatter(matterPerTick * (progressPerTick / this.progressPerTick), false) if (repairProgress >= 1.0) { item.damageValue = (item.damageValue - repairProgress.toInt()).coerceAtLeast(0) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index 6bae9450c..46d3dddec 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -18,6 +18,7 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl +import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.core.math.Decimal @@ -62,7 +63,7 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) } } - val matter = MatterStorageImpl(::matterLevelUpdated, FlowDirection.OUTPUT, ::CAPACITY) + val matter = ProfiledMatterStorage(MatterStorageImpl(::matterLevelUpdated, FlowDirection.OUTPUT, ::CAPACITY)) val container = MatteryContainer(::itemContainerUpdated, 1).also(::addDroppableContainer) val matterNode = SimpleMatterNode(matter = matter) @@ -130,12 +131,12 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) if (receive.isZero) return Status.SUCCESS - val received = matter.receiveMatterInner(receive, true) + val received = matter.receiveMatter(receive, true) if (receive != received) return Status.FAILURE_MATTER - matter.receiveMatterInner(receive, false) + matter.receiveMatter(receive, false) job.totalMatter -= received return Status.SUCCESS } @@ -147,7 +148,7 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) val received = graph.receiveMatter(matter.storedMatter, false) if (!received.isZero) { - matter.extractMatterInner(received, false) + matter.extractMatter(received, false) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index 494df7e09..354ea52ba 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -20,6 +20,7 @@ import ru.dbotthepony.mc.otm.capability.matter.IPatternState import ru.dbotthepony.mc.otm.capability.matter.IReplicationTask import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl import ru.dbotthepony.mc.otm.capability.matter.PatternState +import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage import ru.dbotthepony.mc.otm.capability.matter.ReplicationTask import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.container.HandlerFilter @@ -101,7 +102,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::powerLevelUpdated, ENERGY_VALUES)) - val matter = MatterStorageImpl(::matterLevelUpdated, FlowDirection.INPUT, ::MATTER_CAPACITY) + val matter = ProfiledMatterStorage(MatterStorageImpl(::matterLevelUpdated, FlowDirection.INPUT, ::MATTER_CAPACITY)) val container = MatteryContainer(::itemContainerUpdated, 5).also(::addDroppableContainer) val energyConfig = ConfigurableEnergy(energy) @@ -217,12 +218,12 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : override fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: ReplicatorJob): Status { val drainPerTick = job.matterPerTick * ticksAdvanced - if (matter.extractMatterInner(drainPerTick, true) < drainPerTick) { + if (matter.extractMatter(drainPerTick, true) < drainPerTick) { // в машине недостаточно материи if (drainPerTick > matter.maxStoredMatter) { // в тик требуется больше материи, чем её может хранить репликатор - val toExtract = drainPerTick - matter.extractMatterInner(drainPerTick, true) + val toExtract = drainPerTick - matter.extractMatter(drainPerTick, true) val drain = matterNode.graph.extractMatter(toExtract, true) if (drain != toExtract) { @@ -231,7 +232,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } // достаточно материи в сети + внутри машины - matter.extractMatterInner(drainPerTick, false) + matter.extractMatter(drainPerTick, false) matterNode.graph.extractMatter(drain, false) return Status.SUCCESS } else { @@ -250,8 +251,8 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : matter.receiveMatter(drain, false) // получили материю, проверяем возможность работы - if (matter.extractMatterInner(drainPerTick, true) >= drainPerTick) { - matter.extractMatterInner(drainPerTick, false) + if (matter.extractMatter(drainPerTick, true) >= drainPerTick) { + matter.extractMatter(drainPerTick, false) return Status.SUCCESS } else { // :( @@ -261,7 +262,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } // в машине достаточно материи - matter.extractMatterInner(drainPerTick, false) + matter.extractMatter(drainPerTick, false) visualProgress = workProgress return Status.SUCCESS } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/AbstractProfiledStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/AbstractProfiledStorage.kt new file mode 100644 index 000000000..f1c86aa18 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/AbstractProfiledStorage.kt @@ -0,0 +1,206 @@ +package ru.dbotthepony.mc.otm.capability + +import com.google.common.collect.ImmutableList +import net.minecraft.nbt.CompoundTag +import net.minecraft.nbt.ListTag +import net.minecraft.nbt.NumericTag +import net.minecraftforge.common.util.INBTSerializable +import ru.dbotthepony.mc.otm.core.forValidRefs +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.nbt.set +import java.lang.ref.WeakReference +import java.util.* +import kotlin.collections.ArrayList + +abstract class AbstractProfiledStorage(val parent: P) : INBTSerializable { + init { + storages.add(WeakReference(this)) + } + + private val historyReceiveInternal = ArrayList(HISTORY_SIZE) + private val historyTransferInternal = ArrayList(HISTORY_SIZE) + + val historyReceive: List = Collections.unmodifiableList(historyReceiveInternal) + val historyTransfer: List = Collections.unmodifiableList(historyTransferInternal) + + val lastTickReceive + get() = historyReceiveInternal[tick] + + val lastTickTransfer + get() = historyTransferInternal[tick] + + private var thisTickReceive = Decimal.ZERO + private var thisTickTransfer = Decimal.ZERO + + var tick = 0 + private set + + init { + for (i in 0 until HISTORY_SIZE) { + historyReceiveInternal.add(Decimal.ZERO) + historyTransferInternal.add(Decimal.ZERO) + } + } + + protected fun recordTransfer(value: Decimal, simulate: Boolean): Decimal { + if (!simulate) { + thisTickTransfer += value + } + + return value + } + + protected fun recordReceive(value: Decimal, simulate: Boolean): Decimal { + if (!simulate) { + thisTickReceive += value + } + + return value + } + + private fun tick() { + tick = (tick + 1) % HISTORY_SIZE + + historyReceiveInternal[tick] = thisTickReceive + historyTransferInternal[tick] = thisTickTransfer + + thisTickReceive = Decimal.ZERO + thisTickTransfer = Decimal.ZERO + } + + val savedata: INBTSerializable = object : INBTSerializable { + override fun serializeNBT(): CompoundTag { + return CompoundTag().also { tag -> + tag["historyReceive"] = ListTag().also { + for (value in historyReceiveInternal) { + it.add(value.serializeNBT()) + } + } + + tag["historyTransfer"] = ListTag().also { + for (value in historyTransferInternal) { + it.add(value.serializeNBT()) + } + } + + tag["historyTick"] = tick + } + } + + override fun deserializeNBT(nbt: CompoundTag?) { + tick = 0 + thisTickReceive = Decimal.ZERO + thisTickTransfer = Decimal.ZERO + + for (i in 0 until HISTORY_SIZE) { + historyReceiveInternal[i] = Decimal.ZERO + historyTransferInternal[i] = Decimal.ZERO + } + + nbt ?: return + + nbt.map("historyTick") { it: NumericTag -> + tick = it.asInt + } + + nbt.map("historyReceive") { it: ListTag -> + for (i in 0 until HISTORY_SIZE.coerceAtMost(it.size)) { + historyReceiveInternal[i] = Decimal.deserializeNBT(it[i]) + } + } + + nbt.map("historyTransfer") { it: ListTag -> + for (i in 0 until HISTORY_SIZE.coerceAtMost(it.size)) { + historyTransferInternal[i] = Decimal.deserializeNBT(it[i]) + } + } + } + } + + override fun serializeNBT(): CompoundTag { + val tag: CompoundTag + + if (parent is INBTSerializable<*>) { + tag = (parent as INBTSerializable).serializeNBT() ?: CompoundTag() + } else { + tag = CompoundTag() + } + + val tag2 = savedata.serializeNBT()!! + + for (k in tag2.allKeys) { + tag[k] = tag2[k]!! + } + + return tag + } + + val weightedTransfer: Decimal get() { + return calcWeightedAverage(historyTransfer, tick) + } + + val weightedReceive: Decimal get() { + return calcWeightedAverage(historyReceive, tick) + } + + override fun deserializeNBT(nbt: CompoundTag?) { + if (parent is INBTSerializable<*>) { + (parent as INBTSerializable).deserializeNBT(nbt) + } + + savedata.deserializeNBT(nbt) + } + + companion object { + const val HISTORY_SIZE = 20 + private val storages = ArrayList>>() + + val HISTORY_WEIGHTERS: ImmutableList = ImmutableList.of( + Decimal("0.313335967"), + Decimal("0.146176397"), + Decimal("0.09357867"), + Decimal("0.068193701"), + Decimal("0.053351084"), + Decimal("0.043655993"), + Decimal("0.036847023"), + Decimal("0.031813486"), + Decimal("0.027947534"), + Decimal("0.024889161"), + Decimal("0.02241188"), + Decimal("0.020366241"), + Decimal("0.018649731"), + Decimal("0.017189744"), + Decimal("0.015933452"), + Decimal("0.014841516"), + Decimal("0.013884059"), + Decimal("0.013037985"), + Decimal("0.012285173"), + Decimal("0.011611204"), + ) + + fun calcWeightedAverage(inputs: List, pointer: Int): Decimal { + require(inputs.size == HISTORY_WEIGHTERS.size) { "Expected list of size ${HISTORY_WEIGHTERS.size}, got ${inputs.size}" } + require(pointer in 0 until HISTORY_WEIGHTERS.size) { "Invalid pointer position: $pointer" } + + var result = Decimal.ZERO + var i = 0 + + for (i2 in pointer downTo 0) + result += inputs[i2] * HISTORY_WEIGHTERS[i++] + + for (i2 in HISTORY_WEIGHTERS.size - 1 downTo pointer + 1) + result += inputs[i2] * HISTORY_WEIGHTERS[i++] + + return result + } + + // после раздумий, наиболее корректное место для обновления состояния профилированных + // хранилищ энергии и материи будет после всех остальных хуков на тики после тика сервера + // разумеется, такое решение может несколько снизить производительность сервера, + // но ничего страшного произойти не должно + internal fun onServerPostTick() { + storages.forValidRefs { it.tick() } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ProfiledEnergyStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ProfiledEnergyStorage.kt index a176e5d65..3cb14c888 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ProfiledEnergyStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ProfiledEnergyStorage.kt @@ -1,25 +1,10 @@ package ru.dbotthepony.mc.otm.capability.energy -import net.minecraft.nbt.CompoundTag -import net.minecraft.nbt.ListTag -import net.minecraft.nbt.NumericTag -import net.minecraft.nbt.Tag -import net.minecraftforge.common.util.INBTSerializable +import ru.dbotthepony.mc.otm.capability.AbstractProfiledStorage import ru.dbotthepony.mc.otm.capability.FlowDirection -import ru.dbotthepony.mc.otm.core.forValidRefs import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.math.set -import ru.dbotthepony.mc.otm.core.nbt.map -import ru.dbotthepony.mc.otm.core.nbt.set -import java.lang.ref.WeakReference -import java.util.* -import kotlin.collections.ArrayList - -class ProfiledEnergyStorage(val parent: E) : IMatteryEnergyStorage, INBTSerializable { - init { - storages.add(WeakReference(this)) - } +class ProfiledEnergyStorage(parent: E) : AbstractProfiledStorage(parent), IMatteryEnergyStorage { override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { return recordTransfer(parent.extractEnergy(howMuch, simulate), simulate) } @@ -53,143 +38,4 @@ class ProfiledEnergyStorage(val parent: E) : IMattery override val maxBatteryLevel: Decimal get() = parent.maxBatteryLevel override val energyFlow: FlowDirection get() = parent.energyFlow - - private val historyReceiveInternal = ArrayList(HISTORY_SIZE) - private val historyTransferInternal = ArrayList(HISTORY_SIZE) - - val historyReceive: List = Collections.unmodifiableList(historyReceiveInternal) - val historyTransfer: List = Collections.unmodifiableList(historyTransferInternal) - - val lastTickReceive - get() = historyReceiveInternal[tick] - - val lastTickTransfer - get() = historyTransferInternal[tick] - - private var thisTickReceive = Decimal.ZERO - private var thisTickTransfer = Decimal.ZERO - - var tick = 0 - private set - - init { - for (i in 0 until HISTORY_SIZE) { - historyReceiveInternal.add(Decimal.ZERO) - historyTransferInternal.add(Decimal.ZERO) - } - } - - private fun recordTransfer(value: Decimal, simulate: Boolean): Decimal { - if (!simulate) { - thisTickTransfer += value - } - - return value - } - - private fun recordReceive(value: Decimal, simulate: Boolean): Decimal { - if (!simulate) { - thisTickReceive += value - } - - return value - } - - private fun tick() { - tick = (tick + 1) % HISTORY_SIZE - - historyReceiveInternal[tick] = thisTickReceive - historyTransferInternal[tick] = thisTickTransfer - - thisTickReceive = Decimal.ZERO - thisTickTransfer = Decimal.ZERO - } - - val savedata: INBTSerializable = object : INBTSerializable { - override fun serializeNBT(): CompoundTag { - return CompoundTag().also { tag -> - tag["historyReceive"] = ListTag().also { - for (value in historyReceiveInternal) { - it.add(value.serializeNBT()) - } - } - - tag["historyTransfer"] = ListTag().also { - for (value in historyTransferInternal) { - it.add(value.serializeNBT()) - } - } - - tag["historyTick"] = tick - } - } - - override fun deserializeNBT(nbt: CompoundTag?) { - tick = 0 - thisTickReceive = Decimal.ZERO - thisTickTransfer = Decimal.ZERO - - for (i in 0 until HISTORY_SIZE) { - historyReceiveInternal[i] = Decimal.ZERO - historyTransferInternal[i] = Decimal.ZERO - } - - nbt ?: return - - nbt.map("historyTick") { it: NumericTag -> - tick = it.asInt - } - - nbt.map("historyReceive") { it: ListTag -> - for (i in 0 until HISTORY_SIZE.coerceAtMost(it.size)) { - historyReceiveInternal[i] = Decimal.deserializeNBT(it[i]) - } - } - - nbt.map("historyTransfer") { it: ListTag -> - for (i in 0 until HISTORY_SIZE.coerceAtMost(it.size)) { - historyTransferInternal[i] = Decimal.deserializeNBT(it[i]) - } - } - } - } - - override fun serializeNBT(): CompoundTag { - val tag: CompoundTag - - if (parent is INBTSerializable<*>) { - tag = (parent as INBTSerializable).serializeNBT() ?: CompoundTag() - } else { - tag = CompoundTag() - } - - val tag2 = savedata.serializeNBT()!! - - for (k in tag2.allKeys) { - tag[k] = tag2[k]!! - } - - return tag - } - - override fun deserializeNBT(nbt: CompoundTag?) { - if (parent is INBTSerializable<*>) { - (parent as INBTSerializable).deserializeNBT(nbt) - } - - savedata.deserializeNBT(nbt) - } - - companion object { - const val HISTORY_SIZE = 20 - private val storages = ArrayList>>() - - // после раздумий, наиболее корректное место для обновления состояния профилированных - // хранилищ энергии будет после всех остальных хуков на тики после тика сервера - // разумеется, такое решение может несколько снизить производительность сервера, - // но ничего страшного произойти не должно - internal fun onServerPostTick() { - storages.forValidRefs { it.tick() } - } - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterStorage.kt index c8544371f..7c75ad595 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterStorage.kt @@ -6,10 +6,13 @@ import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.orNull +import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import kotlin.math.roundToInt /** * Matter interface in Overdrive That Matters + * + * Contracts of this interface follow the ones of [IMatteryEnergyStorage] */ interface IMatterStorage { /** @@ -37,7 +40,7 @@ interface IMatterStorage { val maxStoredMatter: Decimal /** - * Empties matter stored of this matter storage + * Empties matter stored of this matter storage, if possible * * @throws [UnsupportedOperationException] * @see storedMatter @@ -47,7 +50,7 @@ interface IMatterStorage { } /** - * Fully fills matter stored in this matter storage + * Fully fills matter stored, if possible * * @throws [UnsupportedOperationException] * @see storedMatter @@ -57,19 +60,45 @@ interface IMatterStorage { } /** - * Fill matter into this object + * Fill matter into this object, ignoring [matterFlow] * * @return matter accepted */ fun receiveMatter(howMuch: Decimal, simulate: Boolean): Decimal /** - * Extract matter from this matter storage + * Extract matter from this matter storage, ignoring [matterFlow] * * @return matter extracted */ fun extractMatter(howMuch: Decimal, simulate: Boolean): Decimal + /** + * Fill matter into this object, accounting for [matterFlow] + * + * @return matter accepted + */ + fun receiveMatterChecked(howMuch: Decimal, simulate: Boolean): Decimal { + if (matterFlow.input) { + return receiveMatter(howMuch, simulate) + } + + return Decimal.ZERO + } + + /** + * Extract matter from this matter storage, accounting for [matterFlow] + * + * @return matter extracted + */ + fun extractMatterChecked(howMuch: Decimal, simulate: Boolean): Decimal { + if (matterFlow.output) { + return extractMatter(howMuch, simulate) + } + + return Decimal.ZERO + } + /** * How much matter (estimated) is missing in this matter storage. Why estimated? Because some objects can be bottomless. * diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt index ee47b32fe..72daab76b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt @@ -63,13 +63,6 @@ open class MatterStorageImpl @JvmOverloads constructor( } override fun receiveMatter(howMuch: Decimal, simulate: Boolean): Decimal { - if (!canReceiveMatter) - return Decimal.ZERO - - return receiveMatterInner(howMuch, simulate) - } - - fun receiveMatterInner(howMuch: Decimal, simulate: Boolean): Decimal { val new: Decimal if (maxReceive == null) { @@ -89,13 +82,6 @@ open class MatterStorageImpl @JvmOverloads constructor( } override fun extractMatter(howMuch: Decimal, simulate: Boolean): Decimal { - if (canExtractMatter) - return Decimal.ZERO - - return extractMatterInner(howMuch, simulate) - } - - fun extractMatterInner(howMuch: Decimal, simulate: Boolean): Decimal { val new: Decimal if (maxExtract == null) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/ProfiledMatterStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/ProfiledMatterStorage.kt new file mode 100644 index 000000000..b3ebe61f0 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/ProfiledMatterStorage.kt @@ -0,0 +1,45 @@ +package ru.dbotthepony.mc.otm.capability.matter + +import ru.dbotthepony.mc.otm.capability.AbstractProfiledStorage +import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.core.math.Decimal + +class ProfiledMatterStorage(parent: M) : AbstractProfiledStorage(parent), IMatterStorage { + override var storedMatter by parent::storedMatter + + override val maxStoredMatter: Decimal + get() = parent.maxStoredMatter + + override fun receiveMatter(howMuch: Decimal, simulate: Boolean): Decimal { + return recordReceive(parent.receiveMatter(howMuch, simulate), simulate) + } + + override fun extractMatter(howMuch: Decimal, simulate: Boolean): Decimal { + return recordTransfer(parent.extractMatter(howMuch, simulate), simulate) + } + + override fun receiveMatterChecked(howMuch: Decimal, simulate: Boolean): Decimal { + return recordReceive(parent.receiveMatterChecked(howMuch, simulate), simulate) + } + + override fun extractMatterChecked(howMuch: Decimal, simulate: Boolean): Decimal { + return recordTransfer(parent.extractMatterChecked(howMuch, simulate), simulate) + } + + override val matterFlow: FlowDirection + get() = parent.matterFlow + + override val canSetMatterLevel: Boolean + get() = parent.canSetMatterLevel + + override fun drainMatter() { + parent.drainMatter() + } + + override fun fillMatter() { + parent.fillMatter() + } + + override val missingMatter: Decimal + get() = parent.missingMatter +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt index def4b18a2..f18d7725c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt @@ -11,6 +11,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.MatterCapacitorSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.ProfiledMatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.menu.matter.MatterBottlerMenu @@ -24,7 +25,7 @@ class MatterBottlerScreen(menu: MatterBottlerMenu, inventory: Inventory, title: val frame = super.makeMainFrame()!! val p = ProfiledPowerGaugePanel(this, frame, menu.profiledEnergy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) - MatterGaugePanel(this, frame, menu.matterWidget, LEFT_MARGIN + p.width, GAUGE_TOP_WITH_SLOT) + ProfiledMatterGaugePanel(this, frame, menu.matterWidget, LEFT_MARGIN + p.width, GAUGE_TOP_WITH_SLOT) BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt index 81a6488d0..f399232ac 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt @@ -10,6 +10,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.ProfiledMatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel @@ -20,7 +21,7 @@ class MatterDecomposerScreen(p_97741_: MatterDecomposerMenu, p_97742_: Inventory val frame = super.makeMainFrame()!! val m = ProfiledPowerGaugePanel(this, frame, menu.profiledEnergy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) - MatterGaugePanel(this, frame, menu.matterWidget, LEFT_MARGIN + m.width, GAUGE_TOP_WITH_SLOT) + ProfiledMatterGaugePanel(this, frame, menu.matterWidget, LEFT_MARGIN + m.width, GAUGE_TOP_WITH_SLOT) BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt index 29c2c6163..d87f67aec 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt @@ -13,6 +13,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.ProfiledMatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.menu.matter.MatterReconstructorMenu @@ -22,7 +23,7 @@ class MatterReconstructorScreen(menu: MatterReconstructorMenu, inventory: Invent val frame = super.makeMainFrame()!! val p = ProfiledPowerGaugePanel(this, frame, menu.profiledEnergy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) - MatterGaugePanel(this, frame, menu.matterWidget, LEFT_MARGIN + p.width, GAUGE_TOP_WITH_SLOT) + ProfiledMatterGaugePanel(this, frame, menu.matterWidget, LEFT_MARGIN + p.width, GAUGE_TOP_WITH_SLOT) BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt index 3763dee00..a48875e3a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt @@ -9,6 +9,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.ProfiledMatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.menu.matter.MatterRecyclerMenu @@ -18,7 +19,7 @@ class MatterRecyclerScreen(menu: MatterRecyclerMenu, inventory: Inventory, title val frame = super.makeMainFrame()!! val m = ProfiledPowerGaugePanel(this, frame, menu.profiledEnergy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) - MatterGaugePanel(this, frame, menu.matter, LEFT_MARGIN + m.width, GAUGE_TOP_WITH_SLOT) + ProfiledMatterGaugePanel(this, frame, menu.matter, LEFT_MARGIN + m.width, GAUGE_TOP_WITH_SLOT) BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt index a74d83ae8..2bec6d949 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt @@ -9,6 +9,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.ProfiledMatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.menu.matter.MatterReplicatorMenu @@ -19,7 +20,7 @@ class MatterReplicatorScreen(p_97741_: MatterReplicatorMenu, p_97742_: Inventory val frame = super.makeMainFrame()!! val m = ProfiledPowerGaugePanel(this, frame, menu.profiledEnergy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) - MatterGaugePanel(this, frame, menu.matter, LEFT_MARGIN + m.width, GAUGE_TOP_WITH_SLOT) + ProfiledMatterGaugePanel(this, frame, menu.matter, LEFT_MARGIN + m.width, GAUGE_TOP_WITH_SLOT) BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt index 552a48882..6664b16c3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt @@ -1,13 +1,12 @@ package ru.dbotthepony.mc.otm.client.screen.widget -import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget -import ru.dbotthepony.mc.otm.menu.widget.ProfiledEnergyGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget private fun PowerGaugePanel<*>.doRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float, flop: Boolean) { if (height >= 18f) { @@ -74,7 +73,7 @@ fun TallHorizontalPowerGaugePanel( open class HorizontalProfiledPowerGaugePanel( screen: S, parent: EditablePanel<*>? = null, - widget: ProfiledEnergyGaugeWidget, + widget: ProfiledLevelGaugeWidget<*>, x: Float = 0f, y: Float = 0f, width: Float = HorizontalPowerGaugePanel.GAUGE_BACKGROUND.width, @@ -94,7 +93,7 @@ open class HorizontalProfiledPowerGaugePanel( fun TallHorizontalProfiledPowerGaugePanel( screen: S, parent: EditablePanel<*>? = null, - widget: ProfiledEnergyGaugeWidget, + widget: ProfiledLevelGaugeWidget<*>, x: Float = 0f, y: Float = 0f, width: Float = HorizontalPowerGaugePanel.GAUGE_BACKGROUND_TALL.width, 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 609490059..ec764b57e 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 @@ -5,18 +5,29 @@ import com.mojang.blaze3d.vertex.BufferUploader import com.mojang.blaze3d.vertex.DefaultVertexFormat import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.VertexFormat +import it.unimi.dsi.fastutil.ints.IntArrayList +import net.minecraft.ChatFormatting import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.client.renderer.GameRenderer import net.minecraft.network.chat.Component import org.lwjgl.opengl.GL11 +import ru.dbotthepony.mc.otm.capability.AbstractProfiledStorage +import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage import ru.dbotthepony.mc.otm.client.ShiftPressedCond +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.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.util.formatMatter import ru.dbotthepony.mc.otm.core.util.formatMatterLevel +import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.nanoTime import kotlin.math.absoluteValue import kotlin.math.cos @@ -121,3 +132,54 @@ open class MatterGaugePanel @JvmOverloads constructor( val GAUGE_FOREGROUND = WidgetLocation.VERTICAL_GAUGES.sprite(x = 27f, width = 9f) } } + +private fun formatLevel(a: Decimal, b: Decimal): Component { + val diff = a - b + + val fa = a.formatMatter(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.DARK_GREEN) + val fb = b.formatMatter(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.DARK_RED) + + if (diff.isZero) { + return TranslatableComponent("otm.gui.diff", diff.formatMatter(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.GRAY), fa, fb) + } else if (diff.isPositive) { + return TranslatableComponent("otm.gui.diff", diff.formatMatter(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.DARK_GREEN), fa, fb) + } else { + return TranslatableComponent("otm.gui.diff", (-diff).formatMatter(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.DARK_RED), fa, fb) + } +} + +open class ProfiledMatterGaugePanel( + screen: S, + parent: EditablePanel<*>? = null, + val profiledWidget: ProfiledLevelGaugeWidget<*>, + x: Float = 0f, + y: Float = 0f +): MatterGaugePanel(screen, parent, profiledWidget.gauge, x, y) { + override fun makeTooltip(): MutableList { + return super.makeTooltip().also { + it.add(TextComponent("")) + + if (minecraft.window.isShiftDown) { + it.add(formatLevel(profiledWidget.lastTickReceive, profiledWidget.lastTickTransfer)) + it.add(TextComponent("---")) + } + + it.add(formatLevel( + profiledWidget.weightedReceive, + profiledWidget.weightedTransfer, + )) + + if (minecraft.window.isShiftDown && minecraft.options.advancedItemTooltips) { + it.add(TextComponent("---")) + val values = IntArrayList() + + values.addAll(profiledWidget.tick downTo 0) + values.addAll(AbstractProfiledStorage.HISTORY_SIZE - 1 downTo profiledWidget.tick + 1) + + for (i in values.intIterator()) { + it.add(formatLevel(profiledWidget.historyReceive[i].value, profiledWidget.historyTransfer[i].value)) + } + } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt index 285d3112e..4af6f338f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt @@ -1,11 +1,11 @@ package ru.dbotthepony.mc.otm.client.screen.widget -import com.mojang.blaze3d.vertex.PoseStack import it.unimi.dsi.fastutil.ints.IntArrayList import net.minecraft.ChatFormatting import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component +import ru.dbotthepony.mc.otm.capability.AbstractProfiledStorage import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.isShiftDown @@ -19,7 +19,7 @@ import ru.dbotthepony.mc.otm.core.stream import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.core.util.formatPowerLevel import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget -import ru.dbotthepony.mc.otm.menu.widget.ProfiledEnergyGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget open class PowerGaugePanel( screen: S, @@ -113,7 +113,7 @@ private fun formatLevel(a: Decimal, b: Decimal): Component { open class ProfiledPowerGaugePanel( screen: S, parent: EditablePanel<*>? = null, - val profiledWidget: ProfiledEnergyGaugeWidget, + val profiledWidget: ProfiledLevelGaugeWidget<*>, x: Float = 0f, y: Float = 0f, width: Float = GAUGE_BACKGROUND.width, @@ -129,16 +129,8 @@ open class ProfiledPowerGaugePanel( } it.add(formatLevel( - profiledWidget.historyReceive - .stream() - .map { it.value } - .reduce(Decimal.ZERO) { a, b -> a + b } - .div(profiledWidget.historyReceive.size), - - profiledWidget.historyTransfer.stream() - .map { it.value } - .reduce(Decimal.ZERO) { a, b -> a + b } - .div(profiledWidget.historyReceive.size), + profiledWidget.weightedReceive, + profiledWidget.weightedTransfer, )) if (minecraft.window.isShiftDown && minecraft.options.advancedItemTooltips) { @@ -146,7 +138,7 @@ open class ProfiledPowerGaugePanel( val values = IntArrayList() values.addAll(profiledWidget.tick downTo 0) - values.addAll(ProfiledEnergyStorage.HISTORY_SIZE - 1 downTo profiledWidget.tick + 1) + values.addAll(AbstractProfiledStorage.HISTORY_SIZE - 1 downTo profiledWidget.tick + 1) for (i in values.intIterator()) { it.add(formatLevel(profiledWidget.historyReceive[i].value, profiledWidget.historyTransfer[i].value)) @@ -163,7 +155,7 @@ open class ProfiledPowerGaugePanel( fun WideProfiledPowerGaugePanel( screen: S, parent: EditablePanel<*>? = null, - widget: ProfiledEnergyGaugeWidget, + widget: ProfiledLevelGaugeWidget<*>, x: Float = 0f, y: Float = 0f, width: Float = 18f, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterGraph.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterGraph.kt index b0e0e2a10..86f0e6b26 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterGraph.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterGraph.kt @@ -110,7 +110,7 @@ class MatterGraph : Abstract6Graph(), IMatterGraphListe val matter = node.getMatterHandler() if (matter != null) { - val value = matter.extractMatter(howMuch, simulate) + val value = matter.extractMatterChecked(howMuch, simulate) howMuch -= value extracted += value @@ -134,7 +134,7 @@ class MatterGraph : Abstract6Graph(), IMatterGraphListe val matter = node.getMatterHandler() if (matter != null && matter.matterFlow == FlowDirection.BI_DIRECTIONAL) { - val value = matter.receiveMatter(howMuch, simulate) + val value = matter.receiveMatterChecked(howMuch, simulate) howMuch -= value received += value @@ -158,7 +158,7 @@ class MatterGraph : Abstract6Graph(), IMatterGraphListe val matter = node.getMatterHandler() if (matter != null && matter.matterFlow != FlowDirection.OUTPUT) { - val value = matter.receiveMatter(howMuch, simulate) + val value = matter.receiveMatterChecked(howMuch, simulate) howMuch -= value received += value diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt index 492ba1891..cc50fadfc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt @@ -6,6 +6,7 @@ import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage import ru.dbotthepony.mc.otm.capability.matter.canExtractMatter import ru.dbotthepony.mc.otm.capability.matter.canReceiveMatter import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback @@ -14,7 +15,7 @@ import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot -import ru.dbotthepony.mc.otm.menu.widget.ProfiledEnergyGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus class MatterBottlerMenu @JvmOverloads constructor( @@ -26,16 +27,15 @@ class MatterBottlerMenu @JvmOverloads constructor( ) { val workFlow = BooleanInputWithFeedback(this) val progressWidget = ProgressGaugeWidget(this) - val matterWidget = LevelGaugeWidget(this) + val matterWidget = ProfiledLevelGaugeWidget(this, tile?.matter, LevelGaugeWidget(this, tile?.matter)) val storageSlots: List - val profiledEnergy = ProfiledEnergyGaugeWidget(this, tile?.energy, energyWidget) + val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) init { val container = tile?.container ?: SimpleContainer(6) if (tile != null) { progressWidget.with(tile::getWorkProgress) - matterWidget.with(tile.matter) workFlow.with(tile::isBottling) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt index 3a2084fff..f4dbfcdfe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt @@ -15,7 +15,7 @@ import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput -import ru.dbotthepony.mc.otm.menu.widget.ProfiledEnergyGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus class MatterDecomposerMenu @JvmOverloads constructor( @@ -30,10 +30,10 @@ class MatterDecomposerMenu @JvmOverloads constructor( val outputMain: MachineOutputSlot val outputStacking: MachineOutputSlot val progressWidget = ProgressGaugeWidget(this, tile) - val matterWidget = LevelGaugeWidget(this, tile?.getCapability(MatteryCapability.MATTER)?.orNull()) + val matterWidget = ProfiledLevelGaugeWidget(this, tile?.matter, LevelGaugeWidget(this, tile?.matter)) val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) - val profiledEnergy = ProfiledEnergyGaugeWidget(this, tile?.energy, energyWidget) + val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) init { val container = tile?.outputContainer ?: SimpleContainer(2) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt index 96e7bb91c..8527bf717 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt @@ -9,7 +9,7 @@ import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget -import ru.dbotthepony.mc.otm.menu.widget.ProfiledEnergyGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -18,7 +18,7 @@ class MatterReconstructorMenu( inventory: Inventory, tile: MatterReconstructorBlockEntity? = null ) : MatteryPoweredMenu(MMenus.ITEM_REPAIER, containerId, inventory, tile) { - val matterWidget = LevelGaugeWidget(this, tile?.matter) + val matterWidget = ProfiledLevelGaugeWidget(this, tile?.matter, LevelGaugeWidget(this, tile?.matter)) val slot = object : MatterySlot(tile?.repairContainer ?: SimpleContainer(1), 0) { override fun mayPlace(itemStack: ItemStack): Boolean { return itemStack.isRepairable && itemStack.isDamaged && super.mayPlace(itemStack) @@ -30,7 +30,7 @@ class MatterReconstructorMenu( val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) - val profiledEnergy = ProfiledEnergyGaugeWidget(this, tile?.energy, energyWidget) + val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) init { addStorageSlot(slot) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt index 373719f59..0441c860d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt @@ -10,7 +10,7 @@ import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget -import ru.dbotthepony.mc.otm.menu.widget.ProfiledEnergyGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -26,10 +26,10 @@ class MatterRecyclerMenu @JvmOverloads constructor( } val progress = ProgressGaugeWidget(this, tile) - val matter = LevelGaugeWidget(this, tile?.matter) + val matter = ProfiledLevelGaugeWidget(this, tile?.matter, LevelGaugeWidget(this, tile?.matter)) val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) - val profiledEnergy = ProfiledEnergyGaugeWidget(this, tile?.energy, energyWidget) + val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) init { addStorageSlot(input) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt index 09ca29654..949333bbb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt @@ -11,7 +11,7 @@ import ru.dbotthepony.mc.otm.menu.MachineOutputSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput -import ru.dbotthepony.mc.otm.menu.widget.ProfiledEnergyGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus class MatterReplicatorMenu @JvmOverloads constructor( @@ -19,12 +19,12 @@ class MatterReplicatorMenu @JvmOverloads constructor( inventory: Inventory, tile: MatterReplicatorBlockEntity? = null ) : MatteryPoweredMenu(MMenus.MATTER_REPLICATOR, p_38852_, inventory, tile) { - val matter = LevelGaugeWidget(this, tile?.matter) + val matter = ProfiledLevelGaugeWidget(this, tile?.matter, LevelGaugeWidget(this, tile?.matter)) val progress = ProgressGaugeWidget(this, tile) val storageSlots: List val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) - val profiledEnergy = ProfiledEnergyGaugeWidget(this, tile?.energy, energyWidget) + val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) init { val container = tile?.container ?: SimpleContainer(5) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt index f07f1d3e3..2482505d6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt @@ -13,7 +13,7 @@ import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput -import ru.dbotthepony.mc.otm.menu.widget.ProfiledEnergyGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus class MatterScannerMenu @JvmOverloads constructor( @@ -26,7 +26,7 @@ class MatterScannerMenu @JvmOverloads constructor( val patterns = LevelGaugeWidget(this) val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) - val profiledEnergy = ProfiledEnergyGaugeWidget(this, tile?.energy, energyWidget) + val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) init { val container = tile?.container ?: SimpleContainer(1) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt index a96447a9b..e3203da1d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt @@ -13,7 +13,7 @@ import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput -import ru.dbotthepony.mc.otm.menu.widget.ProfiledEnergyGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus import kotlin.reflect.KMutableProperty0 @@ -113,7 +113,7 @@ class AndroidStationMenu @JvmOverloads constructor( val equipment = makeEquipmentSlots() val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) - val profiledEnergy = ProfiledEnergyGaugeWidget(this, tile?.energy, energyWidget) + val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) init { addInventorySlots() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt index 4483e591d..a9d284f09 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt @@ -7,16 +7,13 @@ import ru.dbotthepony.mc.otm.block.entity.tech.BatteryBankBlockEntity import net.minecraft.world.SimpleContainer import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.core.immutableList -import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget -import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.menu.BatterySlot import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput -import ru.dbotthepony.mc.otm.menu.widget.ProfiledEnergyGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus class BatteryBankMenu @JvmOverloads constructor( @@ -24,7 +21,7 @@ class BatteryBankMenu @JvmOverloads constructor( inventory: Inventory, tile: BatteryBankBlockEntity? = null, ) : MatteryMenu(MMenus.BATTERY_BANK, p_38852_, inventory, tile) { - val powerLevel = ProfiledEnergyGaugeWidget(this, tile?.energyConfig?.capability) + val powerLevel = ProfiledLevelGaugeWidget(this, tile?.energyConfig?.capability) val storageSlots: List val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java) val energyConfig = EnergyConfigPlayerInput(this, allowPull = false, allowPush = true) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt index b4c125658..5239bc527 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/ChemicalGeneratorMenu.kt @@ -13,8 +13,7 @@ import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput -import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget -import ru.dbotthepony.mc.otm.menu.widget.ProfiledEnergyGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -54,7 +53,7 @@ class ChemicalGeneratorMenu @JvmOverloads constructor(id: Int, inv: Inventory, t } val progress = ProgressGaugeWidget(this) - val energy = ProfiledEnergyGaugeWidget(this, tile?.energy) + val energy = ProfiledLevelGaugeWidget(this, tile?.energy) var burnTime by mSynchronizer.int().property init { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt index cb8ce6b39..e336e01c9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt @@ -11,8 +11,7 @@ import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput -import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget -import ru.dbotthepony.mc.otm.menu.widget.ProfiledEnergyGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus class EnergyServoMenu @JvmOverloads constructor( @@ -34,7 +33,7 @@ class EnergyServoMenu @JvmOverloads constructor( val equipment = makeEquipmentSlots(mapMoveToExternal = true) - val powerGauge = ProfiledEnergyGaugeWidget(this, tile?.energy) + val powerGauge = ProfiledLevelGaugeWidget(this, tile?.energy) val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig, allowPull = true, allowPush = true) val redstoneConfig = EnumInputWithFeedback(this) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt index 63bdd4b0f..0f33d9ed6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt @@ -9,7 +9,7 @@ import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput -import ru.dbotthepony.mc.otm.menu.widget.ProfiledEnergyGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -24,7 +24,7 @@ class PlatePressMenu @JvmOverloads constructor( val progressGauge = ProgressGaugeWidget(this, tile) val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig, allowPush = true) val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig, allowPull = true) - val profiledEnergy = ProfiledEnergyGaugeWidget(this, tile?.energy, energyWidget) + val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) init { addStorageSlot(inputSlot) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProfiledEnergyGaugeWidget.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProfiledEnergyGaugeWidget.kt deleted file mode 100644 index 1a63d3dd7..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProfiledEnergyGaugeWidget.kt +++ /dev/null @@ -1,44 +0,0 @@ -package ru.dbotthepony.mc.otm.menu.widget - -import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage -import ru.dbotthepony.mc.otm.core.immutableList -import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.util.DecimalValueCodec -import ru.dbotthepony.mc.otm.menu.MatteryMenu -import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu -import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer - -class ProfiledEnergyGaugeWidget(synchronizer: FieldSynchronizer, val gauge: LevelGaugeWidget = LevelGaugeWidget(synchronizer)) { - var parent: ProfiledEnergyStorage<*>? = null - private set - - val historyReceive = immutableList(ProfiledEnergyStorage.HISTORY_SIZE) { - synchronizer.ComputedField({ parent?.historyReceive?.get(it) ?: Decimal.ZERO }, DecimalValueCodec) - } - - val historyTransfer = immutableList(ProfiledEnergyStorage.HISTORY_SIZE) { - synchronizer.ComputedField({ parent?.historyTransfer?.get(it) ?: Decimal.ZERO }, DecimalValueCodec) - } - - val tick by synchronizer.ComputedIntField({ parent?.tick ?: 0 }).property - val lastTickReceive by synchronizer.ComputedField({ parent?.lastTickReceive ?: Decimal.ZERO }, DecimalValueCodec) - val lastTickTransfer by synchronizer.ComputedField({ parent?.lastTickTransfer ?: Decimal.ZERO }, DecimalValueCodec) - - constructor(synchronizer: FieldSynchronizer, storage: ProfiledEnergyStorage<*>?, gauge: LevelGaugeWidget = LevelGaugeWidget(synchronizer)) : this(synchronizer, gauge = gauge) { - if (storage != null) { - with(storage) - } - } - - constructor(menu: MatteryMenu, storage: ProfiledEnergyStorage<*>?, gauge: LevelGaugeWidget = LevelGaugeWidget(menu)) : this(menu.mSynchronizer, storage, gauge = gauge) - constructor(menu: MatteryMenu, gauge: LevelGaugeWidget = LevelGaugeWidget(menu)) : this(menu.mSynchronizer, gauge = gauge) - - constructor(menu: MatteryPoweredMenu, storage: ProfiledEnergyStorage<*>?) : this(menu.mSynchronizer, storage, menu.energyWidget) - constructor(menu: MatteryPoweredMenu) : this(menu.mSynchronizer, menu.energyWidget) - - fun with(storage: ProfiledEnergyStorage<*>): ProfiledEnergyGaugeWidget { - gauge.with(storage) - parent = storage - return this - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProfiledLevelGaugeWidget.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProfiledLevelGaugeWidget.kt new file mode 100644 index 000000000..486168417 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProfiledLevelGaugeWidget.kt @@ -0,0 +1,62 @@ +package ru.dbotthepony.mc.otm.menu.widget + +import ru.dbotthepony.mc.otm.capability.AbstractProfiledStorage +import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage +import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage +import ru.dbotthepony.mc.otm.core.collect.SupplierList +import ru.dbotthepony.mc.otm.core.immutableList +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.util.DecimalValueCodec +import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu +import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer + +class ProfiledLevelGaugeWidget

>(synchronizer: FieldSynchronizer, val gauge: LevelGaugeWidget = LevelGaugeWidget(synchronizer)) { + var parent: P? = null + private set + + val historyReceive = immutableList(AbstractProfiledStorage.HISTORY_SIZE) { + synchronizer.ComputedField({ parent?.historyReceive?.get(it) ?: Decimal.ZERO }, DecimalValueCodec) + } + + val historyTransfer = immutableList(AbstractProfiledStorage.HISTORY_SIZE) { + synchronizer.ComputedField({ parent?.historyTransfer?.get(it) ?: Decimal.ZERO }, DecimalValueCodec) + } + + val directHistoryReceive = SupplierList(historyReceive) + val directHistoryTransfer = SupplierList(historyTransfer) + + val tick by synchronizer.ComputedIntField({ parent?.tick ?: 0 }).property + val lastTickReceive by synchronizer.ComputedField({ parent?.lastTickReceive ?: Decimal.ZERO }, DecimalValueCodec) + val lastTickTransfer by synchronizer.ComputedField({ parent?.lastTickTransfer ?: Decimal.ZERO }, DecimalValueCodec) + + constructor(synchronizer: FieldSynchronizer, storage: P?, gauge: LevelGaugeWidget = LevelGaugeWidget(synchronizer)) : this(synchronizer, gauge = gauge) { + if (storage != null) { + with(storage) + } + } + + constructor(menu: MatteryMenu, storage: P?, gauge: LevelGaugeWidget = LevelGaugeWidget(menu)) : this(menu.mSynchronizer, storage, gauge = gauge) + constructor(menu: MatteryMenu, gauge: LevelGaugeWidget = LevelGaugeWidget(menu)) : this(menu.mSynchronizer, gauge = gauge) + + constructor(menu: MatteryPoweredMenu, storage: P?) : this(menu.mSynchronizer, storage, menu.energyWidget) + constructor(menu: MatteryPoweredMenu) : this(menu.mSynchronizer, menu.energyWidget) + + fun with(storage: P): ProfiledLevelGaugeWidget

{ + if (storage is IMatterStorage) + gauge.with(storage) + else if (storage is IMatteryEnergyStorage) + gauge.with(storage) + + parent = storage + return this + } + + val weightedTransfer: Decimal get() { + return AbstractProfiledStorage.calcWeightedAverage(directHistoryTransfer, tick) + } + + val weightedReceive: Decimal get() { + return AbstractProfiledStorage.calcWeightedAverage(directHistoryReceive, tick) + } +} From 20acf14beeac2f8d2729384c0d837f892a3a5534 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sat, 10 Jun 2023 17:49:44 +0300 Subject: [PATCH 0597/1199] matter reconstructor item render --- .../matter/MatterReconstructorBlockEntity.kt | 10 ++++- .../MatterReconstructorRenderer.kt | 44 +++++++++++++++++++ .../mc/otm/registry/MBlockEntities.kt | 9 +--- 3 files changed, 55 insertions(+), 8 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReconstructorRenderer.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt index 6f09ba35c..36a157be9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt @@ -49,7 +49,10 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) private var lastItem: Item? = null private var initialDamage = 0.0 - var visualProgress = 0f + var visualItemStack by synchronizer.item(observe = false) + private set + + var visualProgress by synchronizer.float().property private set var isUnableToProcess = false @@ -155,6 +158,7 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) lastItem = item.item repairProgress = 0.0 initialDamage = item.damageValue.toDouble() + visualItemStack = item visualProgress = 0f } @@ -162,6 +166,7 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) matterPerTick = Decimal.ZERO progressPerTick = 0.0 initialDamage = 0.0 + visualItemStack = item visualProgress = 0f } else { if (ALLOW_TO_SKIP_ANVIL && !ONLY_ANVIL) { @@ -199,6 +204,7 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) matterPerTick = Decimal.ZERO progressPerTick = 0.0 initialDamage = 0.0 + visualItemStack = item visualProgress = 0f } } @@ -261,9 +267,11 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) repairProgress %= 1.0 } + visualItemStack = item visualProgress = 1f - ((item.damageValue - repairProgress) / initialDamage).toFloat() } else { initialDamage = 0.0 + visualItemStack = item visualProgress = 0f } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReconstructorRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReconstructorRenderer.kt new file mode 100644 index 000000000..5b7fccff5 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReconstructorRenderer.kt @@ -0,0 +1,44 @@ +package ru.dbotthepony.mc.otm.client.render.blockentity + +import com.mojang.blaze3d.vertex.PoseStack +import com.mojang.math.Axis +import net.minecraft.client.renderer.MultiBufferSource +import net.minecraft.client.renderer.blockentity.BlockEntityRenderer +import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider +import net.minecraft.world.item.ItemDisplayContext +import ru.dbotthepony.mc.otm.block.entity.matter.MatterReconstructorBlockEntity +import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource + +class MatterReconstructorRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer { + companion object { + private val source = DynamicBufferSource(maximalInitialBufferSize = 2 shl 10) + } + + override fun render( + tile: MatterReconstructorBlockEntity, + partialTick: Float, + pose: PoseStack, + bufferSource: MultiBufferSource, + packedLight: Int, + packedOverlay: Int + ) { + val item = tile.visualItemStack + + if (item.isEmpty) { + return + } + + pose.pushPose() + + pose.translate(0.5, 0.6, 0.5) + pose.scale(0.5f, 0.5f, 0.5f) + + pose.mulPose(Axis.XP.rotationDegrees(90f)) + pose.mulPose(Axis.ZP.rotationDegrees(tile.blockRotation.front.toYRot() + 180f)) + + context.itemRenderer.renderStatic(item, ItemDisplayContext.FIXED, packedLight, packedOverlay, pose, source, tile.level, tile.blockPos.asLong().toInt()) + source.endBatch() + + pose.popPose() + } +} 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 397b88194..2f33fe80f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt @@ -22,13 +22,7 @@ import ru.dbotthepony.mc.otm.block.entity.tech.BatteryBankBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.EnergyServoBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.GravitationStabilizerBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity -import ru.dbotthepony.mc.otm.client.render.blockentity.BatteryBankRenderer -import ru.dbotthepony.mc.otm.client.render.blockentity.BlackHoleRenderer -import ru.dbotthepony.mc.otm.client.render.blockentity.EnergyCounterRenderer -import ru.dbotthepony.mc.otm.client.render.blockentity.GravitationStabilizerRenderer -import ru.dbotthepony.mc.otm.client.render.blockentity.HoloSignRenderer -import ru.dbotthepony.mc.otm.client.render.blockentity.MatterBatteryBankRenderer -import ru.dbotthepony.mc.otm.client.render.blockentity.MatterReplicatorRenderer +import ru.dbotthepony.mc.otm.client.render.blockentity.* @Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") // Type<*> is unused in BlockEntityType.Builder object MBlockEntities { @@ -84,6 +78,7 @@ object MBlockEntities { BlockEntityRenderers.register(ENERGY_COUNTER, ::EnergyCounterRenderer) BlockEntityRenderers.register(BATTERY_BANK, ::BatteryBankRenderer) BlockEntityRenderers.register(MATTER_CAPACITOR_BANK, ::MatterBatteryBankRenderer) + BlockEntityRenderers.register(MATTER_RECONSTRUCTOR, ::MatterReconstructorRenderer) BlockEntityRenderers.register(MATTER_REPLICATOR, ::MatterReplicatorRenderer) BlockEntityRenderers.register(HOLO_SIGN, ::HoloSignRenderer) } From 0a01a4f133c766c4c576b53953ca1323b7d2f59c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 11 Jun 2023 18:11:55 +0700 Subject: [PATCH 0598/1199] Jokerge --- .../otm/block/entity/matter/MatterReconstructorBlockEntity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt index 36a157be9..0fcff8458 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt @@ -52,7 +52,7 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) var visualItemStack by synchronizer.item(observe = false) private set - var visualProgress by synchronizer.float().property + var visualProgress = 0f private set var isUnableToProcess = false From 56771dcd32f465b45c7bd7741ec66c273df64e3b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 11 Jun 2023 18:24:24 +0700 Subject: [PATCH 0599/1199] =?UTF-8?q?YuRaNnNzZZ=20=E2=80=94=20=D0=A1=D0=B5?= =?UTF-8?q?=D0=B3=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=2018:13=20:WiseTree:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../render/blockentity/MatterReconstructorRenderer.kt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReconstructorRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReconstructorRenderer.kt index 5b7fccff5..1d252f645 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReconstructorRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReconstructorRenderer.kt @@ -10,10 +10,6 @@ import ru.dbotthepony.mc.otm.block.entity.matter.MatterReconstructorBlockEntity import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource class MatterReconstructorRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer { - companion object { - private val source = DynamicBufferSource(maximalInitialBufferSize = 2 shl 10) - } - override fun render( tile: MatterReconstructorBlockEntity, partialTick: Float, @@ -34,10 +30,9 @@ class MatterReconstructorRenderer(private val context: BlockEntityRendererProvid pose.scale(0.5f, 0.5f, 0.5f) pose.mulPose(Axis.XP.rotationDegrees(90f)) - pose.mulPose(Axis.ZP.rotationDegrees(tile.blockRotation.front.toYRot() + 180f)) + pose.mulPose(Axis.ZP.rotationDegrees(tile.blockRotation.back.toYRot())) - context.itemRenderer.renderStatic(item, ItemDisplayContext.FIXED, packedLight, packedOverlay, pose, source, tile.level, tile.blockPos.asLong().toInt()) - source.endBatch() + context.itemRenderer.renderStatic(item, ItemDisplayContext.FIXED, packedLight, packedOverlay, pose, DynamicBufferSource.WORLD, tile.level, tile.blockPos.asLong().toInt()) pose.popPose() } From 90cb7022547e6ec13ba8b903c2422892a686d69b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 11 Jun 2023 18:43:30 +0700 Subject: [PATCH 0600/1199] Bump JEI to 14.0.0.5 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index b7e9b5575..e2bdafe25 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,7 +21,7 @@ forge_version=46.0.10 mixingradle_version=0.7.33 mixin_version=0.8.5 -jei_version=14.0.0.4 +jei_version=14.0.0.5 jupiter_version=5.9.2 mekanism_version=1.19.2-10.3.5.homebaked curios_version=5.1.5.1 From 7ffebff8f1244a2951c487c8e3569600f99a899c Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Mon, 12 Jun 2023 11:07:32 +0300 Subject: [PATCH 0601/1199] bump curios version --- build.gradle.kts | 2 +- gradle.properties | 4 ++-- .../ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index f5cf9ff53..01a4cdec3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -183,7 +183,7 @@ dependencies { val curios_mc_version: String by project val ad_astra_id: String by project - compileOnly(fg.deobf("top.theillusivec4.curios:curios-forge:${curios_mc_version}-${curios_version}")) + compileOnly(fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}+${curios_mc_version}")) compileOnly(fg.deobf("curse.maven:cosmetic-armor-reworked-237307:$cosmetic_armor_reworked_id")) compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-common-api:${jei_version}")) diff --git a/gradle.properties b/gradle.properties index e2bdafe25..ddc27cb58 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,7 +14,7 @@ mc_version=1.20 use_parchment=false parchment_version=2023.03.12-1.19.3 jei_mc_version=1.20 -curios_mc_version=1.19.4 +curios_mc_version=1.20 forge_gradle_version=[6.0,6.2) forge_version=46.0.10 @@ -24,7 +24,7 @@ mixin_version=0.8.5 jei_version=14.0.0.5 jupiter_version=5.9.2 mekanism_version=1.19.2-10.3.5.homebaked -curios_version=5.1.5.1 +curios_version=5.2.0-beta.2 cosmetic_armor_reworked_id=4575609 ad_astra_id=4452010 jade_id=4573193 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt index 8b19adef7..9c435a6e1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt @@ -47,7 +47,7 @@ private fun Player.getCuriosSlotsImpl(): List> { val stacks = curio.stacks for (slot in 0 until stacks.slots) { - val regular = CurioSlot(this, stacks, slot, identifier, 0, 0, curio.renders) + val regular = CurioSlot(this, stacks, slot, identifier, 0, 0, curio.renders, curio.canToggleRendering()) if (curio.hasCosmetic()) { val cosmetic = CosmeticCurioSlot(this, curio.cosmeticStacks, slot, identifier, 0, 0) From 320bbaaf1dd6c7228f5e0277d31abf8fe108dc7e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 13 Jun 2023 20:58:11 +0700 Subject: [PATCH 0602/1199] Bump to Minecraft 1.20.1 --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index ddc27cb58..ed573d7c8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,14 +10,14 @@ mod_version=1.3 use_commit_hash_in_version=true -mc_version=1.20 +mc_version=1.20.1 use_parchment=false parchment_version=2023.03.12-1.19.3 jei_mc_version=1.20 curios_mc_version=1.20 forge_gradle_version=[6.0,6.2) -forge_version=46.0.10 +forge_version=47.0.1 mixingradle_version=0.7.33 mixin_version=0.8.5 From 1acb78cc154ca1b3d4e0201b3f5a94606af90bdb Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 13 Jun 2023 20:58:43 +0700 Subject: [PATCH 0603/1199] I AM ONCE AGAIN `disabling runtime dependencies` --- build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 01a4cdec3..538d65843 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -188,9 +188,9 @@ dependencies { compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-common-api:${jei_version}")) compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge-api:${jei_version}")) - runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}")) + //runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}")) - runtimeOnly(fg.deobf("curse.maven:jade-324717:${jade_id}")) + //runtimeOnly(fg.deobf("curse.maven:jade-324717:${jade_id}")) //runtimeOnly(fg.deobf("curse.maven:configured-457570:${configured_id}")) compileOnly(fg.deobf("curse.maven:ad-astra-635042:${ad_astra_id}")) From a040e4cc63bb7a60b7c382206303ae6e1866f9ac Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 13 Jun 2023 22:20:13 +0700 Subject: [PATCH 0604/1199] Bump dependencies in mods.toml --- src/main/resources/META-INF/mods.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index b7f98f00f..a3199ff6b 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -6,7 +6,7 @@ # The name of the mod loader type to load - for regular FML @Mod mods it should be javafml modLoader="javafml" #mandatory # A version range to match for said mod loader - for regular FML @Mod it will be the forge version -loaderVersion="[46,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. +loaderVersion="[47,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. # The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties. # Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here. license="2 Clause BSD" @@ -43,7 +43,7 @@ Matter. Energy. Combined. # Does this dependency have to exist - if not, ordering below must be specified mandatory=true #mandatory # The version range of the dependency - versionRange="[46.0.1,)" #mandatory + versionRange="[47.0.1,)" #mandatory # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory ordering="NONE" # Side this dependency is applied on - BOTH, CLIENT or SERVER @@ -53,6 +53,6 @@ Matter. Energy. Combined. modId="minecraft" mandatory=true # This version range declares a minimum of the current minecraft version up to but not including the next major version - versionRange="[1.20,1.21)" + versionRange="[1.20.1,1.21)" ordering="NONE" side="BOTH" From afe46b0bd940d97f1a075cee38c73b498be94ffe Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 15 Jun 2023 15:32:52 +0700 Subject: [PATCH 0605/1199] Separate job loop logic from Worker Block Entity into own class --- .../mc/otm/datagen/loot/LootTables.kt | 21 - .../dbotthepony/mc/otm/block/entity/Jobs.kt | 367 +++++++++++++++++ .../block/entity/MatteryWorkerBlockEntity.kt | 377 +++--------------- .../matter/MatterDecomposerBlockEntity.kt | 27 +- .../matter/MatterRecyclerBlockEntity.kt | 30 +- .../matter/MatterReplicatorBlockEntity.kt | 58 ++- .../entity/matter/MatterScannerBlockEntity.kt | 40 +- .../block/entity/tech/CobblerBlockEntity.kt | 15 +- .../entity/tech/PlatePressBlockEntity.kt | 25 +- .../mc/otm/menu/tech/CobblerMenu.kt | 2 +- .../mc/otm/menu/widget/ProgressGaugeWidget.kt | 2 +- 11 files changed, 516 insertions(+), 448 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt index a69526acc..e7c9a96e5 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTables.kt @@ -36,27 +36,6 @@ fun TileNbtCopy(source: String, strategy: CopyNbtFunction.MergeStrategy = CopyNb return NbtCopy(source, "BlockEntityTag.$source", strategy) } -private val basicTags = arrayOf( - TileNbtCopy(MatteryBlockEntity.REDSTONE_CONTROL_KEY), -) - -private val poweredTags = arrayOf( - *basicTags, - TileNbtCopy(MatteryBlockEntity.ENERGY_KEY), - TileNbtCopy(MatteryBlockEntity.BATTERY_KEY), -) - -private val workerTags = arrayOf( - *poweredTags, - TileNbtCopy(MatteryWorkerBlockEntity.JOB_KEY), - TileNbtCopy(MatteryWorkerBlockEntity.WORK_TICKS_KEY), -) - -private val poweredMatterWorker = arrayOf( - *workerTags, - TileNbtCopy(MatteryBlockEntity.MATTER_STORAGE_KEY), -) - class LootTables(generator: DataGenerator) : LootTableProvider(generator.packOutput, setOf() /* because we don't fucking validate you fuck */, listOf() /* because we attach everything after class is constructed duh */) { private val providersTable = Reference2ObjectArrayMap LootTable.Builder>>() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt new file mode 100644 index 000000000..7290b7514 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt @@ -0,0 +1,367 @@ +package ru.dbotthepony.mc.otm.block.entity + +import net.minecraft.nbt.CompoundTag +import net.minecraft.world.item.ItemStack +import net.minecraftforge.common.util.INBTSerializable +import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.getDecimal +import ru.dbotthepony.mc.otm.core.math.set +import ru.dbotthepony.mc.otm.core.math.weakEqualDoubles +import ru.dbotthepony.mc.otm.core.math.weakGreaterThan +import ru.dbotthepony.mc.otm.core.math.weakLessThan +import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.nbt.set + +private fun isReason(status: Any?, reason: Any) = status == null || status == reason + +interface IMachineJob { + val ticks: Double + val powerUsage: Decimal + val experience: Float get() = 0f + + fun serializeNBT(): CompoundTag +} + +open class MachineJob : IMachineJob { + final override val ticks: Double + final override val powerUsage: Decimal + final override val experience: Float + + constructor( + ticks: Double, + powerUsage: Decimal = Decimal.ZERO, + experience: Float = 0f, + ) { + this.ticks = ticks + this.powerUsage = powerUsage + this.experience = experience + } + + constructor( + tag: CompoundTag + ) : this(tag.getDouble("Ticks"), tag.getDecimal("EnergyUsage"), tag.getFloat("Experience")) + + override fun serializeNBT(): CompoundTag { + return CompoundTag().also { + it["Ticks"] = ticks + it["EnergyUsage"] = powerUsage + it["Experience"] = experience + } + } +} + +open class MachineItemJob : MachineJob { + val itemStack: ItemStack + + constructor( + itemStack: ItemStack, + ticks: Double, + power: Decimal = Decimal.ZERO, + experience: Float = 0f, + ) : super(ticks, power, experience) { + this.itemStack = itemStack + } + + constructor( + tag: CompoundTag + ) : super(tag) { + this.itemStack = (tag["Item"] as? CompoundTag)?.let { ItemStack.of(it) } ?: ItemStack.EMPTY + } + + override fun serializeNBT(): CompoundTag { + return super.serializeNBT().also { + it["Item"] = itemStack.serializeNBT() + } + } +} + +data class JobStatus( + val success: Boolean, + val throttleTicks: Int = 0, + val idleReason: MachineJobEventLoop.IdleReason? = null, + val newDrainedPower: Decimal? = null +) { + init { + require(throttleTicks >= 0) { "Negative amount of ticks to throttle: $throttleTicks" } + } + + companion object { + val SUCCESS = JobStatus(true) + val FAILURE = JobStatus(false) + val FAILURE_ITEM = JobStatus(false, 20, MachineJobEventLoop.IdleReason.ITEM) + val FAILURE_MATTER = JobStatus(false, 20, MachineJobEventLoop.IdleReason.MATTER) + val FAILURE_WAIT = JobStatus(false, 100) + val FAILURE_WAIT_FAST = JobStatus(false, 20) + } +} + +data class JobState(val job: JobType? = null, val idleReason: Any? = null, val throttleTicks: Int = 0) { + init { + require(throttleTicks >= 0) { "Negative amount of ticks to throttle: $throttleTicks" } + } + + companion object { + fun success(job: JobType): JobState { + return JobState(job, null) + } + + fun failure(reason: Any?): JobState { + return JobState(null, reason) + } + + private val empty = JobState(null, null) + private val noItem = JobState(null, MachineJobEventLoop.IdleReason.ITEM) + private val noEnergy = JobState(null, MachineJobEventLoop.IdleReason.POWER) + private val noPattern = JobState(null, MachineJobEventLoop.IdleReason.PATTERN) + private val noMatter = JobState(null, MachineJobEventLoop.IdleReason.MATTER) + private val observe = JobState(null, MachineJobEventLoop.IdleReason.OBSERVING) + + @Suppress("unchecked_cast") + fun failure(): JobState { + return empty as JobState + } + + @Suppress("unchecked_cast") + fun noItem(): JobState { + return noItem as JobState + } + + @Suppress("unchecked_cast") + fun noEnergy(): JobState { + return noEnergy as JobState + } + + @Suppress("unchecked_cast") + fun noMatter(): JobState { + return noMatter as JobState + } + + @Suppress("unchecked_cast") + fun noPattern(): JobState { + return noPattern as JobState + } + + @Suppress("unchecked_cast") + fun observe(): JobState { + return observe as JobState + } + } +} + +abstract class MachineJobEventLoop : INBTSerializable { + protected abstract val energy: IMatteryEnergyStorage? + protected abstract val isBlockedByRedstone: Boolean + protected abstract fun deserializeJob(nbt: CompoundTag): JobType? + + var currentJob: JobType? = null + set(value) { + if (field != value) { + val old = field + field = value + jobUpdated(value, old) + } + } + + var workTicks = 0.0 + protected set + var throttleTicks = 0 + protected set + var idleTicksAnim = 0 + private set + var workingTicksAnim = 0 + private set + var errorTicksAnim = 0 + private set + + /** + * Can be whatever you want, but [IdleReason] certainly contains all cases + */ + var idleReason: Any? = null + protected set + + open var isIdling = false + + open fun notify(event: Any) { + if (isReason(idleReason, event)) { + isIdling = false + throttleTicks = 0 + } + } + + val isUnableToProcess: Boolean + get() = throttleTicks > 0 + + val workProgress: Float + get() { + val currentJob = currentJob ?: return 0.0f + return (workTicks / currentJob.ticks).coerceAtMost(1.0).toFloat() + } + + enum class IdleReason { + ITEM, + POWER, + MATTER, + PATTERN, + OBSERVING + } + + override fun serializeNBT(): CompoundTag { + return CompoundTag().also { nbt -> + nbt["WorkTicks"] = workTicks + currentJob?.let { nbt["Job"] = it.serializeNBT() } + } + } + + override fun deserializeNBT(nbt: CompoundTag?) { + nbt ?: return + + workTicks = nbt.getDouble("WorkTicks") + currentJob = nbt.map("Job", ::deserializeJob) + + if (currentJob == null) + workTicks = 0.0 + } + + protected abstract fun jobUpdated(new: JobType?, old: JobType?) + + /** + * Called whenever reaching desired amount of ticks at job + */ + protected abstract fun onJobFinish(job: JobType): JobStatus + + /** + * Called when there is nothing to do and we are not idling + */ + protected abstract fun computeNextJob(): JobState + + protected open fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: JobType): JobStatus { + return JobStatus.SUCCESS + } + + /** + * Advances job loop by specified [ticks]. If machine is speed up by upgrades, + * [ticks] should reflect this, same as slowdown. + */ + fun think(ticks: Double = 1.0) { + if (throttleTicks > 0) { + workingTicksAnim = 0 + idleTicksAnim = 0 + throttleTicks-- + errorTicksAnim++ + + if (throttleTicks > 0) + return + else + isIdling = false + } + + if (isIdling) { + workingTicksAnim = 0 + errorTicksAnim = 0 + idleTicksAnim++ + return + } + + var availableTicks = ticks + val energy = energy + + while (!isIdling && weakGreaterThan(availableTicks, 0.0) && throttleTicks <= 0) { + if (isBlockedByRedstone) { + isIdling = true + break + } + + var currentJob = currentJob + + if (currentJob == null) { + val (job, reason, throttleTicks) = computeNextJob() + + if (job == null) { + this.throttleTicks = throttleTicks + this.idleReason = reason + this.isIdling = reason != null + workingTicksAnim = 0 + break + } + + this.currentJob = job + currentJob = job + } + + if (!currentJob.powerUsage.isZero && (energy == null || energy.batteryLevel.isZero)) { + idleReason = IdleReason.POWER + isIdling = true + idleTicksAnim++ + break + } + + idleTicksAnim = 0 + + if (weakLessThan(workTicks, currentJob.ticks)) { + val ticksLeft = currentJob.ticks - workTicks + val ticksAdvanced: Double + + var requiredPower: Decimal? = null + var extractedPower: Decimal? = null + + if (currentJob.powerUsage.isZero) { + ticksAdvanced = availableTicks.coerceAtMost(ticksLeft) + } else { + requiredPower = currentJob.powerUsage * ticksLeft.coerceAtMost(availableTicks) + extractedPower = energy!!.extractEnergy(requiredPower, true) + ticksAdvanced = (extractedPower / requiredPower).toDouble().coerceAtMost(ticksLeft).coerceAtMost(availableTicks) + } + + if (weakEqualDoubles(ticksAdvanced, 0.0)) { + break + } + + val status = onWorkTick(requiredPower ?: Decimal.ZERO, extractedPower ?: Decimal.ZERO, ticksAdvanced, currentJob) + + if (!status.success) { + throttleTicks += status.throttleTicks + + if (status.idleReason != null) { + idleReason = status.idleReason + isIdling = true + } + + break + } + + workingTicksAnim++ + errorTicksAnim = 0 + + workTicks += ticksAdvanced + availableTicks -= ticksAdvanced + + extractedPower = status.newDrainedPower ?: extractedPower + + if (extractedPower != null) { + energy!!.extractEnergy(extractedPower, false) + } + + continue + } + + val status = onJobFinish(currentJob) + + if (status.success) { + this.currentJob = null + workTicks = 0.0 + errorTicksAnim = 0 + } else { + throttleTicks += status.throttleTicks + + if (status.idleReason != null) { + idleReason = status.idleReason + isIdling = true + } + + errorTicksAnim++ + break + } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt index b19fee0c5..7581446f1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt @@ -1,406 +1,123 @@ package ru.dbotthepony.mc.otm.block.entity -import net.minecraft.ChatFormatting -import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.core.BlockPos -import net.minecraft.world.level.block.state.BlockState import net.minecraft.nbt.CompoundTag import net.minecraft.network.chat.Component -import net.minecraft.world.item.BlockItem import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.block.Block +import net.minecraft.world.level.block.entity.BlockEntityType +import net.minecraft.world.level.block.state.BlockState +import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matteryEnergy -import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.math.getDecimal -import ru.dbotthepony.mc.otm.core.math.set -import ru.dbotthepony.mc.otm.core.math.weakEqualDoubles -import ru.dbotthepony.mc.otm.core.math.weakGreaterThan -import ru.dbotthepony.mc.otm.core.math.weakLessThan import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set -private fun isReason(status: Any?, reason: Any) = status == null || status == reason - -abstract class MatteryWorkerBlockEntity( +/** + * Simple machine, which can work on only one job at time. + * + * From technical point, this is a specialized use case of [MachineJobEventLoop]. + */ +abstract class MatteryWorkerBlockEntity( type: BlockEntityType<*>, blockPos: BlockPos, blockState: BlockState, val jobDeserializer: (tag: CompoundTag) -> JobType? ) : MatteryPoweredBlockEntity(type, blockPos, blockState) { - open class Job { - open val ticks: Double - open val powerUsage: Decimal - open val experience: Float + val jobs = object : MachineJobEventLoop() { + override val energy: IMatteryEnergyStorage? + get() = matteryEnergy + override val isBlockedByRedstone: Boolean + get() = redstoneControl.isBlockedByRedstone - constructor( - ticks: Double, - powerUsage: Decimal = Decimal.ZERO, - experience: Float = 0f, - ) { - this.ticks = ticks - this.powerUsage = powerUsage - this.experience = experience + override fun deserializeJob(nbt: CompoundTag): JobType? { + return jobDeserializer.invoke(nbt) } - constructor( - tag: CompoundTag - ) : this(tag.getDouble(TICKS_KEY), tag.getDecimal(POWER_KEY), tag.getFloat(EXPERIENCE_KEY)) - - open fun serializeNBT(): CompoundTag { - return CompoundTag().also { - it[TICKS_KEY] = ticks - it[POWER_KEY] = powerUsage - it[EXPERIENCE_KEY] = experience - } + override fun onJobFinish(job: JobType): JobStatus { + return this@MatteryWorkerBlockEntity.onJobFinish(job) } - companion object { - const val TICKS_KEY = "ticks" - const val POWER_KEY = "power" - const val EXPERIENCE_KEY = "power" + override fun computeNextJob(): JobState { + return this@MatteryWorkerBlockEntity.computeNextJob() + } + + override fun jobUpdated(new: JobType?, old: JobType?) { + this@MatteryWorkerBlockEntity.jobUpdated(new, old) + } + + override fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: JobType): JobStatus { + return this@MatteryWorkerBlockEntity.onWorkTick(requiredPower, extractedPower, ticksAdvanced, job) } } - @Suppress("LeakingThis") - open class ItemJob : Job { - open val itemStack: ItemStack + protected open fun jobUpdated(new: JobType?, old: JobType?) {} + protected abstract fun onJobFinish(job: JobType): JobStatus + protected abstract fun computeNextJob(): JobState - constructor( - itemStack: ItemStack, - ticks: Double, - power: Decimal = Decimal.ZERO, - experience: Float = 0f, - ) : super(ticks, power, experience) { - this.itemStack = itemStack - } - - constructor( - tag: CompoundTag - ) : super(tag) { - this.itemStack = (tag["item"] as? CompoundTag)?.let { ItemStack.of(it) } ?: ItemStack.EMPTY - } - - override fun serializeNBT(): CompoundTag { - return super.serializeNBT().also { - it[ITEM_KEY] = itemStack.serializeNBT() - } - } - - companion object { - const val ITEM_KEY = "item" - } + protected open fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: JobType): JobStatus { + return JobStatus.SUCCESS } - enum class IdleReason { - ITEM, - POWER, - MATTER, - - /** - * Observing external factor, such as waiting for matter/item network tasks - */ - OBSERVING - } - - data class Status( - val success: Boolean, - val throttleTicks: Int = 0, - val idleReason: IdleReason? = null, - val newDrainedPower: Decimal? = null - ) { - companion object { - val SUCCESS = Status(true) - val FAILURE = Status(false) - val FAILURE_ITEM = Status(false, 20, IdleReason.ITEM) - val FAILURE_MATTER = Status(false, 20, IdleReason.MATTER) - val FAILURE_WAIT = Status(false, 100) - val FAILURE_WAIT_FAST = Status(false, 20) - } - } - - var workTicks = 0.0 - protected set - - var throttleTicks = 0 - protected set - - protected open fun jobUpdated(oldJob: JobType?, newJob: JobType?) {} - - var currentJob: JobType? = null - protected set(value) { - if (field != value) { - val old = field - field = value - jobUpdated(old, value) - } - } - - /** - * Can be whatever you want, but [IdleReason] certainly contains all cases - */ - var idleReason: Any? = null - private set - - var isIdling = false - protected set - - val isUnableToProcess: Boolean get() = throttleTicks > 0 - - val workProgress: Float - get() { - val currentJob = currentJob ?: return 0.0f - return (workTicks / currentJob.ticks).coerceAtMost(1.0).toFloat() - } - override fun saveShared(nbt: CompoundTag) { super.saveShared(nbt) - nbt[WORK_TICKS_KEY] = workTicks - currentJob?.let { nbt[JOB_KEY] = it.serializeNBT() } + nbt["JobLoop"] = jobs.serializeNBT() } override fun load(nbt: CompoundTag) { super.load(nbt) - - workTicks = nbt.getDouble(WORK_TICKS_KEY) - currentJob = nbt.map(JOB_KEY, jobDeserializer::invoke) - - if (currentJob == null) - workTicks = 0.0 + nbt.map("JobLoop", jobs::deserializeNBT) } override fun setChanged() { super.setChanged() - isIdling = false + jobs.isIdling = false } override fun setChangedLight() { super.setChangedLight() - isIdling = false + jobs.isIdling = false } protected fun powerLevelUpdated() { super.setChangedLight() - - if (isReason(idleReason, IdleReason.POWER)) { - isIdling = false - throttleTicks = 0 - } + jobs.notify(MachineJobEventLoop.IdleReason.POWER) } protected fun itemContainerUpdated() { super.setChanged() - - if (isReason(idleReason, IdleReason.ITEM)) { - isIdling = false - throttleTicks = 0 - } + jobs.notify(MachineJobEventLoop.IdleReason.ITEM) } protected fun matterLevelUpdated() { super.setChangedLight() - - if (isReason(idleReason, IdleReason.MATTER)) { - isIdling = false - throttleTicks = 0 - } + jobs.notify(MachineJobEventLoop.IdleReason.MATTER) } - /** - * Called whenever reaching desired amount of ticks at job - */ - protected abstract fun onJobFinish(job: JobType): Status - - /** - * [Pair.second] is reason why job can't be performed - * - * If not null, it is written to [idleReason] - */ - protected abstract fun computeNextJob(): Pair - - protected open fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: JobType): Status { - return Status.SUCCESS - } - - private var idleTicksAnim = 0 - private var workingTicksAnim = 0 - private var errorTicksAnim = 0 - override fun redstoneStatusUpdated(newBlocked: Boolean, oldBlocked: Boolean) { super.redstoneStatusUpdated(newBlocked, oldBlocked) - isIdling = newBlocked + jobs.isIdling = newBlocked } override fun tick() { super.tick() + jobs.think() - if (errorTicksAnim > 20 && blockState.hasProperty(WorkerState.WORKER_STATE) && blockState.getValue(WorkerState.WORKER_STATE) != WorkerState.ERROR) { + if (jobs.errorTicksAnim > 20 && blockState.hasProperty(WorkerState.WORKER_STATE) && blockState.getValue(WorkerState.WORKER_STATE) != WorkerState.ERROR) { level?.setBlock(blockPos, blockState.setValue(WorkerState.WORKER_STATE, WorkerState.ERROR), Block.UPDATE_CLIENTS) - } - - if (throttleTicks > 0) { - workingTicksAnim = 0 - idleTicksAnim = 0 - throttleTicks-- - errorTicksAnim++ - - if (throttleTicks > 0) - return - else - isIdling = false - } - - if (isIdling) { - workingTicksAnim = 0 - errorTicksAnim = 0 - idleTicksAnim++ - - if (idleTicksAnim > 20 && blockState.hasProperty(WorkerState.WORKER_STATE) && blockState.getValue(WorkerState.WORKER_STATE) != WorkerState.IDLE) { - level?.setBlock(blockPos, blockState.setValue(WorkerState.WORKER_STATE, WorkerState.IDLE), Block.UPDATE_CLIENTS) - } - - return - } - - var availableTicks = 1.0 - val energy = matteryEnergy - - while (!isIdling && weakGreaterThan(availableTicks, 0.0) && throttleTicks <= 0) { - if (redstoneControl.isBlockedByRedstone) { - isIdling = true - break - } - - var currentJob = currentJob - - if (currentJob == null) { - val (job, reason) = computeNextJob() - - if (job == null) { - idleReason = reason - isIdling = reason != null - workingTicksAnim = 0 - break - } - - this.currentJob = job - currentJob = job - } - - if (!currentJob.powerUsage.isZero && (energy == null || energy.batteryLevel.isZero)) { - idleReason = IdleReason.POWER - isIdling = true - idleTicksAnim++ - - if (idleTicksAnim > 20 && blockState.hasProperty(WorkerState.WORKER_STATE) && blockState.getValue( - WorkerState.WORKER_STATE - ) != WorkerState.IDLE - ) { - level?.setBlock(blockPos, blockState.setValue(WorkerState.WORKER_STATE, WorkerState.IDLE), Block.UPDATE_CLIENTS) - } - - break - } - - idleTicksAnim = 0 - - if (weakLessThan(workTicks, currentJob.ticks)) { - val ticksLeft = currentJob.ticks - workTicks - val ticksAdvanced: Double - - var requiredPower: Decimal? = null - var extractedPower: Decimal? = null - - if (currentJob.powerUsage.isZero) { - ticksAdvanced = availableTicks.coerceAtMost(ticksLeft) - } else { - requiredPower = currentJob.powerUsage * ticksLeft.coerceAtMost(availableTicks) - extractedPower = energy!!.extractEnergy(requiredPower, true) - ticksAdvanced = (extractedPower / requiredPower).toDouble().coerceAtMost(ticksLeft).coerceAtMost(availableTicks) - } - - if (weakEqualDoubles(ticksAdvanced, 0.0)) { - break - } - - val status = onWorkTick(requiredPower ?: Decimal.ZERO, extractedPower ?: Decimal.ZERO, ticksAdvanced, currentJob) - - if (!status.success) { - throttleTicks += status.throttleTicks - - if (status.idleReason != null) { - idleReason = status.idleReason - isIdling = true - } - - break - } - - workingTicksAnim++ - errorTicksAnim = 0 - - workTicks += ticksAdvanced - availableTicks -= ticksAdvanced - - extractedPower = status.newDrainedPower ?: extractedPower - - if (extractedPower != null) { - energy!!.extractEnergy(extractedPower, false) - } - - continue - } - - val status = onJobFinish(currentJob) - - if (status.success) { - this.currentJob = null - workTicks = 0.0 - errorTicksAnim = 0 - } else { - throttleTicks += status.throttleTicks - - if (status.idleReason != null) { - idleReason = status.idleReason - isIdling = true - } - - errorTicksAnim++ - break - } - } - - if (workingTicksAnim > 20 && - errorTicksAnim == 0 && - blockState.hasProperty(WorkerState.WORKER_STATE) && - blockState.getValue(WorkerState.WORKER_STATE) != WorkerState.WORKING - ) { + } else if (jobs.workingTicksAnim > 20 && blockState.hasProperty(WorkerState.WORKER_STATE) && blockState.getValue(WorkerState.WORKER_STATE) != WorkerState.WORKING) { level?.setBlock(blockPos, blockState.setValue(WorkerState.WORKER_STATE, WorkerState.WORKING), Block.UPDATE_CLIENTS) + } else if (jobs.idleTicksAnim > 20 && blockState.hasProperty(WorkerState.WORKER_STATE) && blockState.getValue(WorkerState.WORKER_STATE) != WorkerState.IDLE) { + level?.setBlock(blockPos, blockState.setValue(WorkerState.WORKER_STATE, WorkerState.IDLE), Block.UPDATE_CLIENTS) } } companion object { - const val WORK_TICKS_KEY = "workTicks" - const val JOB_KEY = "job" - fun appendHoverText(itemStack: ItemStack, blockGetter: BlockGetter?, tooltips: MutableList, flag: TooltipFlag) { - val tag = itemStack.tag ?: return - - val subtag = tag.get(BlockItem.BLOCK_ENTITY_TAG) as? CompoundTag - - if (subtag != null) { - if (subtag.contains(WORK_TICKS_KEY) && !subtag.contains(JOB_KEY)) { - if (subtag.getDouble(WORK_TICKS_KEY) != 0.0) - tooltips.add(TranslatableComponent("otm.item.worker.work_ticks_mono", "%.1f".format(subtag.getDouble(WORK_TICKS_KEY))).withStyle(ChatFormatting.GRAY)) - } else if (subtag.contains(WORK_TICKS_KEY) && tag.contains(JOB_KEY)) { - tooltips.add(TranslatableComponent("otm.item.worker.work_ticks", - "%.1f".format(subtag.getDouble(WORK_TICKS_KEY)), - "%.1f".format(Job(subtag.getCompound(JOB_KEY)).ticks)).withStyle(ChatFormatting.GRAY)) - } - } + itemStack.tag ?: return WorkerEnergyStorage.appendHoverText(itemStack, blockGetter, tooltips, flag) MatteryPoweredBlockEntity.appendHoverText(itemStack, blockGetter, tooltips, flag) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index 987166ca1..0e85df578 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -9,6 +9,9 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeConfigSpec +import ru.dbotthepony.mc.otm.block.entity.JobState +import ru.dbotthepony.mc.otm.block.entity.JobStatus +import ru.dbotthepony.mc.otm.block.entity.MachineJob import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability @@ -92,7 +95,7 @@ fun moveMatterAsDustIntoContainer(_matterValue: Decimal, container: MatteryConta class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) : MatteryWorkerBlockEntity(MBlockEntities.MATTER_DECOMPOSER, pos, state, ::DecomposerJob) { - class DecomposerJob : Job { + class DecomposerJob : MachineJob { val toDust: Boolean var matterValue: Decimal @@ -162,27 +165,25 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) return MatterDecomposerMenu(containerID, inventory, this) } - override fun onJobFinish(job: DecomposerJob): Status { + override fun onJobFinish(job: DecomposerJob): JobStatus { if (job.toDust) { job.matterValue = moveMatterAsDustIntoContainer(job.matterValue, outputContainer, 0, 1) - if (!job.matterValue.isZero) { - return Status.FAILURE_WAIT_FAST - } + if (!job.matterValue.isZero) + return JobStatus.FAILURE_WAIT_FAST - return Status.SUCCESS + return JobStatus.SUCCESS } job.matterValue -= matter.receiveMatter(job.matterValue, false) - if (job.matterValue.isPositive) { - return Status.FAILURE_MATTER - } + if (job.matterValue.isPositive) + return JobStatus.FAILURE_MATTER - return Status.SUCCESS + return JobStatus.SUCCESS } - override fun computeNextJob(): Pair { + override fun computeNextJob(): JobState { val stack = inputContainer[0] if (!stack.isEmpty) { @@ -193,11 +194,11 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) val matter = MatterManager.get(copy) stack.count-- - return DecomposerJob((level?.random?.nextDouble() ?: 1.0) <= 0.2, matter.matter, matter.complexity) to null + return JobState.success(DecomposerJob((level?.random?.nextDouble() ?: 1.0) <= 0.2, matter.matter, matter.complexity)) } } - return null to IdleReason.ITEM + return JobState.noItem() } override fun setRemoved() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index 46d3dddec..06c9b7b70 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -10,6 +10,9 @@ import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeConfigSpec import net.minecraftforge.common.ForgeConfigSpec.ConfigValue +import ru.dbotthepony.mc.otm.block.entity.JobState +import ru.dbotthepony.mc.otm.block.entity.JobStatus +import ru.dbotthepony.mc.otm.block.entity.MachineJob import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection @@ -37,7 +40,7 @@ import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryWorkerBlockEntity(MBlockEntities.MATTER_RECYCLER, blockPos, blockState, ::RecyclerJob) { - class RecyclerJob : Job { + class RecyclerJob : MachineJob { var totalMatter: Decimal constructor( @@ -104,41 +107,40 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) return MatterRecyclerMenu(containerID, inventory, this) } - override fun onJobFinish(job: RecyclerJob): Status { + override fun onJobFinish(job: RecyclerJob): JobStatus { // вся логика в onWorkTick - return Status.SUCCESS + return JobStatus.SUCCESS } - override fun computeNextJob(): Pair { + override fun computeNextJob(): JobState { if (matter.missingMatter.isZero) - return null to IdleReason.ITEM + return JobState.noMatter() val stack = container[0] - if (stack.isEmpty || stack.item !is MatterDustItem) { - return null to IdleReason.ITEM - } + if (stack.isEmpty || stack.item !is MatterDustItem) + return JobState.noItem() - val dustMatter = (stack.item as MatterDustItem).getMatterValue(stack.copy().also { it.count = 1 }) ?: return null to IdleReason.ITEM + val dustMatter = (stack.item as MatterDustItem).getMatterValue(stack.copy().also { it.count = 1 }) ?: return JobState.noItem() stack.shrink(1) container.setChanged(0) - return RecyclerJob(dustMatter.matter.toDouble() * TICKS_PER_MATTER, POWER_CONSUMPTION, dustMatter.matter * (0.4 + level!!.random.nextDouble() * 0.6)) to null + return JobState.success(RecyclerJob(dustMatter.matter.toDouble() * TICKS_PER_MATTER, POWER_CONSUMPTION, dustMatter.matter * (0.4 + level!!.random.nextDouble() * 0.6))) } - override fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: RecyclerJob): Status { + override fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: RecyclerJob): JobStatus { val receive = job.totalMatter / job.ticks if (receive.isZero) - return Status.SUCCESS + return JobStatus.SUCCESS val received = matter.receiveMatter(receive, true) if (receive != received) - return Status.FAILURE_MATTER + return JobStatus.FAILURE_MATTER matter.receiveMatter(receive, false) job.totalMatter -= received - return Status.SUCCESS + return JobStatus.SUCCESS } override fun tick() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index 354ea52ba..c30e5849a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -9,6 +9,10 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeConfigSpec +import ru.dbotthepony.mc.otm.block.entity.JobState +import ru.dbotthepony.mc.otm.block.entity.JobStatus +import ru.dbotthepony.mc.otm.block.entity.MachineItemJob +import ru.dbotthepony.mc.otm.block.entity.MachineJobEventLoop import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability @@ -48,7 +52,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } }) { - class ReplicatorJob : ItemJob { + class ReplicatorJob : MachineItemJob { val matterPerTick: Decimal val task: ReplicationTask var matterValue: Decimal @@ -114,21 +118,15 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } override fun onMatterTaskCreated(task: IReplicationTask<*>) { - if (idleReason == IdleReason.OBSERVING) { - isIdling = false - } + jobs.notify(MachineJobEventLoop.IdleReason.OBSERVING) } override fun > onMatterTaskUpdated(newState: T, oldState: T) { - if (idleReason == IdleReason.OBSERVING) { - isIdling = false - } + jobs.notify(MachineJobEventLoop.IdleReason.OBSERVING) } override fun onPatternAdded(state: IPatternState) { - if (idleReason == IdleReason.OBSERVING) { - isIdling = false - } + jobs.notify(MachineJobEventLoop.IdleReason.OBSERVING) } } @@ -145,24 +143,24 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return MatterReplicatorMenu(containerID, inventory, this) } - override fun onJobFinish(job: ReplicatorJob): Status { + override fun onJobFinish(job: ReplicatorJob): JobStatus { if (job.asDust) { job.matterValue = moveMatterAsDustIntoContainer(job.matterValue, container, OUTPUT_DUST_MAIN, OUTPUT_DUST_STACKING) if (!job.matterValue.isZero) { - return Status.FAILURE_WAIT + return JobStatus.FAILURE_WAIT } matterNode.graph.notifyTaskCompletion(job.task.id) - return Status.SUCCESS + return JobStatus.SUCCESS } if (!container.fullyAddItem(job.itemStack, FIRST_ACTUAL_OUTPUT_SLOT .. LAST_ACTUAL_OUTPUT_SLOT)) { - return Status.FAILURE_ITEM + return JobStatus.FAILURE_ITEM } matterNode.graph.notifyTaskCompletion(job.task.id) - return Status.SUCCESS + return JobStatus.SUCCESS } override fun setRemoved() { @@ -190,21 +188,21 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : var lastRender = 0L var particleRenderScore = 0L - override fun computeNextJob(): Pair { + override fun computeNextJob(): JobState { if (energy.batteryLevel < BASE_CONSUMPTION) { - return null to IdleReason.POWER + return JobState.noEnergy() } - val allocation = matterNode.graph.allocateTask(simulate = false) ?: return null to IdleReason.OBSERVING + val allocation = matterNode.graph.allocateTask(simulate = false) ?: return JobState.observe() val stack = allocation.task.stack(1) val matter = MatterManager.get(stack) // ???????? - if (!matter.hasMatterValue) return null to null + if (!matter.hasMatterValue) return JobState.failure() val ticks = matter.complexity - return ReplicatorJob( + return JobState.success(ReplicatorJob( itemStack = stack, matterPerTick = matter.matter / ticks, task = allocation.task.asImmutable(), @@ -212,10 +210,10 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : pattern = allocation.pattern?.asImmutable(), asDust = (level?.random?.nextDouble() ?: 1.0) > (allocation.pattern?.researchPercent ?: 2.0), ticks = ticks, - ) to null + )) } - override fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: ReplicatorJob): Status { + override fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: ReplicatorJob): JobStatus { val drainPerTick = job.matterPerTick * ticksAdvanced if (matter.extractMatter(drainPerTick, true) < drainPerTick) { @@ -228,24 +226,24 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : if (drain != toExtract) { // недостаточно материи в сети - return Status.FAILURE_MATTER + return JobStatus.FAILURE_MATTER } // достаточно материи в сети + внутри машины matter.extractMatter(drainPerTick, false) matterNode.graph.extractMatter(drain, false) - return Status.SUCCESS + return JobStatus.SUCCESS } else { // в тик требуется меньше материи, чем её может хранить репликатор // примем из сети недостающее количество бака материи, или 200 тиков репликации, что меньше val drain = matterNode.graph.extractMatter((drainPerTick * DRAIN_MULT) - .coerceAtMost(job.matterPerTick * (job.ticks - workTicks - ticksAdvanced)) + .coerceAtMost(job.matterPerTick * (job.ticks - jobs.workTicks - ticksAdvanced)) .coerceAtLeast(Decimal.ONE) .coerceAtMost(matter.missingMatter), false) if (drain.isZero) { // в сети нет материи - return Status.FAILURE_MATTER + return JobStatus.FAILURE_MATTER } matter.receiveMatter(drain, false) @@ -253,18 +251,18 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : // получили материю, проверяем возможность работы if (matter.extractMatter(drainPerTick, true) >= drainPerTick) { matter.extractMatter(drainPerTick, false) - return Status.SUCCESS + return JobStatus.SUCCESS } else { // :( - return Status.FAILURE_WAIT + return JobStatus.FAILURE_WAIT } } } // в машине достаточно материи matter.extractMatter(drainPerTick, false) - visualProgress = workProgress - return Status.SUCCESS + visualProgress = jobs.workProgress + return JobStatus.SUCCESS } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt index fff551547..e717370dd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt @@ -9,6 +9,10 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeConfigSpec +import ru.dbotthepony.mc.otm.block.entity.JobState +import ru.dbotthepony.mc.otm.block.entity.JobStatus +import ru.dbotthepony.mc.otm.block.entity.MachineItemJob +import ru.dbotthepony.mc.otm.block.entity.MachineJobEventLoop import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl @@ -34,7 +38,7 @@ import java.util.* import kotlin.math.pow class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : - MatteryWorkerBlockEntity(MBlockEntities.MATTER_SCANNER, p_155229_, p_155230_, ::ItemJob) { + MatteryWorkerBlockEntity(MBlockEntities.MATTER_SCANNER, p_155229_, p_155230_, ::MachineItemJob) { val container = MatteryContainer(::itemContainerUpdated, 1).also(::addDroppableContainer) val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::powerLevelUpdated, ENERGY_VALUES)) @@ -45,7 +49,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { - return isIdling + return jobs.isIdling } })) @@ -53,21 +57,15 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val matterNode = object : MatterNode() { override fun onPatternAdded(state: IPatternState) { - if (idleReason == IdleReason.OBSERVING) { - isIdling = false - } + jobs.notify(MachineJobEventLoop.IdleReason.PATTERN) } override fun onPatternRemoved(state: IPatternState) { - if (idleReason == IdleReason.OBSERVING) { - isIdling = false - } + jobs.notify(MachineJobEventLoop.IdleReason.PATTERN) } override fun onPatternUpdated(newState: IPatternState, oldState: IPatternState) { - if (idleReason == IdleReason.OBSERVING) { - isIdling = false - } + jobs.notify(MachineJobEventLoop.IdleReason.PATTERN) } } @@ -92,9 +90,9 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return MatterScannerMenu(containerID, inventory, this) } - override fun onJobFinish(job: ItemJob): Status { + override fun onJobFinish(job: MachineItemJob): JobStatus { val stack = job.itemStack - if (stack.isEmpty || !MatterManager.hasMatterValue(stack)) return Status.SUCCESS + if (stack.isEmpty || !MatterManager.hasMatterValue(stack)) return JobStatus.SUCCESS var findState: IPatternState? = null @@ -116,19 +114,19 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } if (!matterNode.graph.insertPattern(new, onlyUpdate = false, simulate = false).isFailed) { - return Status.SUCCESS + return JobStatus.SUCCESS } else { - return Status.FAILURE_WAIT + return JobStatus.FAILURE_WAIT } } - override fun computeNextJob(): Pair { + override fun computeNextJob(): JobState { if (energy.batteryLevel.isZero) { - return null to IdleReason.POWER + return JobState.noEnergy() } val stack = container.getItem(0) - if (stack.isEmpty || !MatterManager.canDecompose(stack)) return null to IdleReason.ITEM + if (stack.isEmpty || !MatterManager.canDecompose(stack)) return JobState.noItem() var findState: IPatternState? = null @@ -136,7 +134,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : if (state.researchPercent < 1.0) { findState = state } else if (state.researchPercent >= 1.0) { - return null to IdleReason.ITEM + return JobState.noItem() } else if (findState != null && findState.researchPercent < state.researchPercent) { findState = state } @@ -156,10 +154,10 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : stack.shrink(1) container.setChanged() val complexity = MatterManager.get(copy).complexity - return ItemJob(copy, (if (complexity > 1.0) complexity.pow(1.25) else complexity.pow(0.5)), BASE_CONSUMPTION) to null + return JobState.success(MachineItemJob(copy, (if (complexity > 1.0) complexity.pow(1.25) else complexity.pow(0.5)), BASE_CONSUMPTION)) } - return null to IdleReason.ITEM + return JobState.noItem() } override fun setLevel(level: Level) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt index b163f84c3..38753f97a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt @@ -7,6 +7,9 @@ import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.level.block.state.BlockState +import ru.dbotthepony.mc.otm.block.entity.MachineItemJob +import ru.dbotthepony.mc.otm.block.entity.JobState +import ru.dbotthepony.mc.otm.block.entity.JobStatus import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.HandlerFilter @@ -14,7 +17,7 @@ import ru.dbotthepony.mc.otm.menu.tech.CobblerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities class CobblerBlockEntity(blockPos: BlockPos, blockState: BlockState) - : MatteryWorkerBlockEntity(MBlockEntities.COBBLESTONE_GENERATOR, blockPos, blockState, ::ItemJob) { + : MatteryWorkerBlockEntity(MBlockEntities.COBBLESTONE_GENERATOR, blockPos, blockState, ::MachineItemJob) { override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { return CobblerMenu(containerID, inventory, this) } @@ -33,16 +36,16 @@ class CobblerBlockEntity(blockPos: BlockPos, blockState: BlockState) savetable(::container, INVENTORY_KEY) } - override fun onJobFinish(job: ItemJob): Status { + override fun onJobFinish(job: MachineItemJob): JobStatus { if (!container.fullyAddItem(job.itemStack)) { - return Status.FAILURE_ITEM + return JobStatus.FAILURE_ITEM } - return Status.SUCCESS + return JobStatus.SUCCESS } - override fun computeNextJob(): Pair { - return ItemJob(ItemStack(Items.COBBLESTONE), 40.0) to null + override fun computeNextJob(): JobState { + return JobState.success(MachineItemJob(ItemStack(Items.COBBLESTONE), 40.0)) } companion object { 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 9aadfd64f..987b313b7 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 @@ -7,8 +7,11 @@ import net.minecraft.world.entity.ExperienceOrb import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu -import net.minecraft.world.item.ItemStack import net.minecraft.world.level.block.state.BlockState +import ru.dbotthepony.mc.otm.block.entity.JobState +import ru.dbotthepony.mc.otm.block.entity.JobStatus +import ru.dbotthepony.mc.otm.block.entity.MachineItemJob +import ru.dbotthepony.mc.otm.block.entity.MachineJobEventLoop import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage @@ -23,7 +26,7 @@ import ru.dbotthepony.mc.otm.registry.MRecipes class PlatePressBlockEntity( p_155229_: BlockPos, p_155230_: BlockState -) : MatteryWorkerBlockEntity(MBlockEntities.PLATE_PRESS, p_155229_, p_155230_, ::ItemJob) { +) : MatteryWorkerBlockEntity(MBlockEntities.PLATE_PRESS, p_155229_, p_155230_, ::MachineItemJob) { val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::setChangedLight, MachinesConfig.PLATE_PRESS)) val inputContainer = MatteryContainer(this::itemContainerUpdated, 1).also(::addDroppableContainer) val outputContainer = MatteryContainer(this::itemContainerUpdated, 1).also(::addDroppableContainer) @@ -56,28 +59,28 @@ class PlatePressBlockEntity( return PlatePressMenu(containerID, inventory, this) } - override fun onJobFinish(job: ItemJob): Status { + override fun onJobFinish(job: MachineItemJob): JobStatus { if (job.itemStack.isEmpty) - return Status.SUCCESS + return JobStatus.SUCCESS if (!outputContainer.fullyAddItem(job.itemStack)) - return Status.FAILURE_ITEM + return JobStatus.FAILURE_ITEM experience = (experience + job.experience).coerceAtMost(100.0) - return Status.SUCCESS + return JobStatus.SUCCESS } - override fun computeNextJob(): Pair { + override fun computeNextJob(): JobState { if (energy.batteryLevel.isZero) { - return null to IdleReason.POWER + return JobState.noEnergy() } - val level = level ?: return null to null + val level = level ?: return JobState.failure() - val recipe = level.recipeManager.getRecipeFor(MRecipes.PLATE_PRESS, inputContainer, level).orElse(null) ?: return null to IdleReason.ITEM + val recipe = level.recipeManager.getRecipeFor(MRecipes.PLATE_PRESS, inputContainer, level).orElse(null) ?: return JobState.noItem() inputContainer[0].shrink(1) inputContainer.setChanged(0) - return ItemJob(recipe.getResultItem(level.registryAccess()), recipe.workTime.toDouble(), BASELINE_CONSUMPTION, experience = recipe.experience.sample(level.random)) to null + return JobState.success(MachineItemJob(recipe.getResultItem(level.registryAccess()), recipe.workTime.toDouble(), BASELINE_CONSUMPTION, experience = recipe.experience.sample(level.random))) } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt index 57687cf73..d327d267b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt @@ -25,7 +25,7 @@ class CobblerMenu @JvmOverloads constructor( init { if (tile != null) { - progress.with(tile::workProgress, tile::isUnableToProcess) + progress.with(tile.jobs::workProgress, tile.jobs::isUnableToProcess) redstone.with(tile.redstoneControl::redstoneSetting) itemConfig.with(tile.itemConfig) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt index d182f7971..1eeff3911 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt @@ -70,7 +70,7 @@ class ProgressGaugeWidget(synchronizer: FieldSynchronizer) { } fun with(blockEntity: MatteryWorkerBlockEntity<*>): ProgressGaugeWidget { - with(blockEntity::workProgress, blockEntity::isUnableToProcess) + with(blockEntity.jobs::workProgress, blockEntity.jobs::isUnableToProcess) return this } } From 0da6a8bd281862d16a8a7d7b24595d1c0640deb1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 16 Jun 2023 00:18:04 +0700 Subject: [PATCH 0606/1199] Better names for additions --- .../dbotthepony/mc/otm/block/entity/Jobs.kt | 48 +++++++++---------- .../block/entity/MatteryWorkerBlockEntity.kt | 30 ++++++------ .../matter/MatterDecomposerBlockEntity.kt | 8 ++-- .../matter/MatterRecyclerBlockEntity.kt | 12 ++--- .../matter/MatterReplicatorBlockEntity.kt | 22 ++++----- .../entity/matter/MatterScannerBlockEntity.kt | 25 +++++----- .../block/entity/tech/CobblerBlockEntity.kt | 6 +-- .../entity/tech/PlatePressBlockEntity.kt | 13 +++-- .../mc/otm/menu/tech/CobblerMenu.kt | 2 +- .../mc/otm/menu/widget/ProgressGaugeWidget.kt | 2 +- 10 files changed, 82 insertions(+), 86 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt index 7290b7514..3ebeaff46 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt @@ -96,55 +96,55 @@ data class JobStatus( } } -data class JobState(val job: JobType? = null, val idleReason: Any? = null, val throttleTicks: Int = 0) { +data class JobContainer(val job: JobType? = null, val idleReason: Any? = null, val throttleTicks: Int = 0) { init { require(throttleTicks >= 0) { "Negative amount of ticks to throttle: $throttleTicks" } } companion object { - fun success(job: JobType): JobState { - return JobState(job, null) + fun success(job: JobType): JobContainer { + return JobContainer(job, null) } - fun failure(reason: Any?): JobState { - return JobState(null, reason) + fun failure(reason: Any?): JobContainer { + return JobContainer(null, reason) } - private val empty = JobState(null, null) - private val noItem = JobState(null, MachineJobEventLoop.IdleReason.ITEM) - private val noEnergy = JobState(null, MachineJobEventLoop.IdleReason.POWER) - private val noPattern = JobState(null, MachineJobEventLoop.IdleReason.PATTERN) - private val noMatter = JobState(null, MachineJobEventLoop.IdleReason.MATTER) - private val observe = JobState(null, MachineJobEventLoop.IdleReason.OBSERVING) + private val empty = JobContainer(null, null) + private val noItem = JobContainer(null, MachineJobEventLoop.IdleReason.ITEM) + private val noEnergy = JobContainer(null, MachineJobEventLoop.IdleReason.POWER) + private val noPattern = JobContainer(null, MachineJobEventLoop.IdleReason.PATTERN) + private val noMatter = JobContainer(null, MachineJobEventLoop.IdleReason.MATTER) + private val observe = JobContainer(null, MachineJobEventLoop.IdleReason.OBSERVING) @Suppress("unchecked_cast") - fun failure(): JobState { - return empty as JobState + fun failure(): JobContainer { + return empty as JobContainer } @Suppress("unchecked_cast") - fun noItem(): JobState { - return noItem as JobState + fun noItem(): JobContainer { + return noItem as JobContainer } @Suppress("unchecked_cast") - fun noEnergy(): JobState { - return noEnergy as JobState + fun noEnergy(): JobContainer { + return noEnergy as JobContainer } @Suppress("unchecked_cast") - fun noMatter(): JobState { - return noMatter as JobState + fun noMatter(): JobContainer { + return noMatter as JobContainer } @Suppress("unchecked_cast") - fun noPattern(): JobState { - return noPattern as JobState + fun noPattern(): JobContainer { + return noPattern as JobContainer } @Suppress("unchecked_cast") - fun observe(): JobState { - return observe as JobState + fun observe(): JobContainer { + return observe as JobContainer } } } @@ -233,7 +233,7 @@ abstract class MachineJobEventLoop : INBTSerializable + protected abstract fun computeNextJob(): JobContainer protected open fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: JobType): JobStatus { return JobStatus.SUCCESS diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt index 7581446f1..76b08ebb7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt @@ -27,7 +27,7 @@ abstract class MatteryWorkerBlockEntity( blockState: BlockState, val jobDeserializer: (tag: CompoundTag) -> JobType? ) : MatteryPoweredBlockEntity(type, blockPos, blockState) { - val jobs = object : MachineJobEventLoop() { + val jobEventLoop = object : MachineJobEventLoop() { override val energy: IMatteryEnergyStorage? get() = matteryEnergy override val isBlockedByRedstone: Boolean @@ -41,7 +41,7 @@ abstract class MatteryWorkerBlockEntity( return this@MatteryWorkerBlockEntity.onJobFinish(job) } - override fun computeNextJob(): JobState { + override fun computeNextJob(): JobContainer { return this@MatteryWorkerBlockEntity.computeNextJob() } @@ -56,7 +56,7 @@ abstract class MatteryWorkerBlockEntity( protected open fun jobUpdated(new: JobType?, old: JobType?) {} protected abstract fun onJobFinish(job: JobType): JobStatus - protected abstract fun computeNextJob(): JobState + protected abstract fun computeNextJob(): JobContainer protected open fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: JobType): JobStatus { return JobStatus.SUCCESS @@ -64,53 +64,53 @@ abstract class MatteryWorkerBlockEntity( override fun saveShared(nbt: CompoundTag) { super.saveShared(nbt) - nbt["JobLoop"] = jobs.serializeNBT() + nbt["JobLoop"] = jobEventLoop.serializeNBT() } override fun load(nbt: CompoundTag) { super.load(nbt) - nbt.map("JobLoop", jobs::deserializeNBT) + nbt.map("JobLoop", jobEventLoop::deserializeNBT) } override fun setChanged() { super.setChanged() - jobs.isIdling = false + jobEventLoop.isIdling = false } override fun setChangedLight() { super.setChangedLight() - jobs.isIdling = false + jobEventLoop.isIdling = false } protected fun powerLevelUpdated() { super.setChangedLight() - jobs.notify(MachineJobEventLoop.IdleReason.POWER) + jobEventLoop.notify(MachineJobEventLoop.IdleReason.POWER) } protected fun itemContainerUpdated() { super.setChanged() - jobs.notify(MachineJobEventLoop.IdleReason.ITEM) + jobEventLoop.notify(MachineJobEventLoop.IdleReason.ITEM) } protected fun matterLevelUpdated() { super.setChangedLight() - jobs.notify(MachineJobEventLoop.IdleReason.MATTER) + jobEventLoop.notify(MachineJobEventLoop.IdleReason.MATTER) } override fun redstoneStatusUpdated(newBlocked: Boolean, oldBlocked: Boolean) { super.redstoneStatusUpdated(newBlocked, oldBlocked) - jobs.isIdling = newBlocked + jobEventLoop.isIdling = newBlocked } override fun tick() { super.tick() - jobs.think() + jobEventLoop.think() - if (jobs.errorTicksAnim > 20 && blockState.hasProperty(WorkerState.WORKER_STATE) && blockState.getValue(WorkerState.WORKER_STATE) != WorkerState.ERROR) { + if (jobEventLoop.errorTicksAnim > 20 && blockState.hasProperty(WorkerState.WORKER_STATE) && blockState.getValue(WorkerState.WORKER_STATE) != WorkerState.ERROR) { level?.setBlock(blockPos, blockState.setValue(WorkerState.WORKER_STATE, WorkerState.ERROR), Block.UPDATE_CLIENTS) - } else if (jobs.workingTicksAnim > 20 && blockState.hasProperty(WorkerState.WORKER_STATE) && blockState.getValue(WorkerState.WORKER_STATE) != WorkerState.WORKING) { + } else if (jobEventLoop.workingTicksAnim > 20 && blockState.hasProperty(WorkerState.WORKER_STATE) && blockState.getValue(WorkerState.WORKER_STATE) != WorkerState.WORKING) { level?.setBlock(blockPos, blockState.setValue(WorkerState.WORKER_STATE, WorkerState.WORKING), Block.UPDATE_CLIENTS) - } else if (jobs.idleTicksAnim > 20 && blockState.hasProperty(WorkerState.WORKER_STATE) && blockState.getValue(WorkerState.WORKER_STATE) != WorkerState.IDLE) { + } else if (jobEventLoop.idleTicksAnim > 20 && blockState.hasProperty(WorkerState.WORKER_STATE) && blockState.getValue(WorkerState.WORKER_STATE) != WorkerState.IDLE) { level?.setBlock(blockPos, blockState.setValue(WorkerState.WORKER_STATE, WorkerState.IDLE), Block.UPDATE_CLIENTS) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index 0e85df578..a40f508ac 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -9,7 +9,7 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeConfigSpec -import ru.dbotthepony.mc.otm.block.entity.JobState +import ru.dbotthepony.mc.otm.block.entity.JobContainer import ru.dbotthepony.mc.otm.block.entity.JobStatus import ru.dbotthepony.mc.otm.block.entity.MachineJob import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity @@ -183,7 +183,7 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) return JobStatus.SUCCESS } - override fun computeNextJob(): JobState { + override fun computeNextJob(): JobContainer { val stack = inputContainer[0] if (!stack.isEmpty) { @@ -194,11 +194,11 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) val matter = MatterManager.get(copy) stack.count-- - return JobState.success(DecomposerJob((level?.random?.nextDouble() ?: 1.0) <= 0.2, matter.matter, matter.complexity)) + return JobContainer.success(DecomposerJob((level?.random?.nextDouble() ?: 1.0) <= 0.2, matter.matter, matter.complexity)) } } - return JobState.noItem() + return JobContainer.noItem() } override fun setRemoved() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index 06c9b7b70..3aed65360 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -10,7 +10,7 @@ import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeConfigSpec import net.minecraftforge.common.ForgeConfigSpec.ConfigValue -import ru.dbotthepony.mc.otm.block.entity.JobState +import ru.dbotthepony.mc.otm.block.entity.JobContainer import ru.dbotthepony.mc.otm.block.entity.JobStatus import ru.dbotthepony.mc.otm.block.entity.MachineJob import ru.dbotthepony.mc.otm.config.ConciseBalanceValues @@ -112,19 +112,19 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) return JobStatus.SUCCESS } - override fun computeNextJob(): JobState { + override fun computeNextJob(): JobContainer { if (matter.missingMatter.isZero) - return JobState.noMatter() + return JobContainer.noMatter() val stack = container[0] if (stack.isEmpty || stack.item !is MatterDustItem) - return JobState.noItem() + return JobContainer.noItem() - val dustMatter = (stack.item as MatterDustItem).getMatterValue(stack.copy().also { it.count = 1 }) ?: return JobState.noItem() + val dustMatter = (stack.item as MatterDustItem).getMatterValue(stack.copy().also { it.count = 1 }) ?: return JobContainer.noItem() stack.shrink(1) container.setChanged(0) - return JobState.success(RecyclerJob(dustMatter.matter.toDouble() * TICKS_PER_MATTER, POWER_CONSUMPTION, dustMatter.matter * (0.4 + level!!.random.nextDouble() * 0.6))) + return JobContainer.success(RecyclerJob(dustMatter.matter.toDouble() * TICKS_PER_MATTER, POWER_CONSUMPTION, dustMatter.matter * (0.4 + level!!.random.nextDouble() * 0.6))) } override fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: RecyclerJob): JobStatus { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index c30e5849a..aa96bc775 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -9,7 +9,7 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeConfigSpec -import ru.dbotthepony.mc.otm.block.entity.JobState +import ru.dbotthepony.mc.otm.block.entity.JobContainer import ru.dbotthepony.mc.otm.block.entity.JobStatus import ru.dbotthepony.mc.otm.block.entity.MachineItemJob import ru.dbotthepony.mc.otm.block.entity.MachineJobEventLoop @@ -118,15 +118,15 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } override fun onMatterTaskCreated(task: IReplicationTask<*>) { - jobs.notify(MachineJobEventLoop.IdleReason.OBSERVING) + jobEventLoop.notify(MachineJobEventLoop.IdleReason.OBSERVING) } override fun > onMatterTaskUpdated(newState: T, oldState: T) { - jobs.notify(MachineJobEventLoop.IdleReason.OBSERVING) + jobEventLoop.notify(MachineJobEventLoop.IdleReason.OBSERVING) } override fun onPatternAdded(state: IPatternState) { - jobs.notify(MachineJobEventLoop.IdleReason.OBSERVING) + jobEventLoop.notify(MachineJobEventLoop.IdleReason.OBSERVING) } } @@ -188,21 +188,21 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : var lastRender = 0L var particleRenderScore = 0L - override fun computeNextJob(): JobState { + override fun computeNextJob(): JobContainer { if (energy.batteryLevel < BASE_CONSUMPTION) { - return JobState.noEnergy() + return JobContainer.noEnergy() } - val allocation = matterNode.graph.allocateTask(simulate = false) ?: return JobState.observe() + val allocation = matterNode.graph.allocateTask(simulate = false) ?: return JobContainer.observe() val stack = allocation.task.stack(1) val matter = MatterManager.get(stack) // ???????? - if (!matter.hasMatterValue) return JobState.failure() + if (!matter.hasMatterValue) return JobContainer.failure() val ticks = matter.complexity - return JobState.success(ReplicatorJob( + return JobContainer.success(ReplicatorJob( itemStack = stack, matterPerTick = matter.matter / ticks, task = allocation.task.asImmutable(), @@ -237,7 +237,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : // в тик требуется меньше материи, чем её может хранить репликатор // примем из сети недостающее количество бака материи, или 200 тиков репликации, что меньше val drain = matterNode.graph.extractMatter((drainPerTick * DRAIN_MULT) - .coerceAtMost(job.matterPerTick * (job.ticks - jobs.workTicks - ticksAdvanced)) + .coerceAtMost(job.matterPerTick * (job.ticks - jobEventLoop.workTicks - ticksAdvanced)) .coerceAtLeast(Decimal.ONE) .coerceAtMost(matter.missingMatter), false) @@ -261,7 +261,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : // в машине достаточно материи matter.extractMatter(drainPerTick, false) - visualProgress = jobs.workProgress + visualProgress = jobEventLoop.workProgress return JobStatus.SUCCESS } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt index e717370dd..262a58e6b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.block.entity.matter import net.minecraft.core.BlockPos -import net.minecraft.server.level.ServerLevel import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu @@ -9,7 +8,7 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeConfigSpec -import ru.dbotthepony.mc.otm.block.entity.JobState +import ru.dbotthepony.mc.otm.block.entity.JobContainer import ru.dbotthepony.mc.otm.block.entity.JobStatus import ru.dbotthepony.mc.otm.block.entity.MachineItemJob import ru.dbotthepony.mc.otm.block.entity.MachineJobEventLoop @@ -26,8 +25,6 @@ import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal -import ru.dbotthepony.mc.otm.graph.Graph6Node -import ru.dbotthepony.mc.otm.graph.matter.MatterGraph import ru.dbotthepony.mc.otm.menu.matter.MatterScannerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MNames @@ -49,7 +46,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { - return jobs.isIdling + return jobEventLoop.isIdling } })) @@ -57,15 +54,15 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val matterNode = object : MatterNode() { override fun onPatternAdded(state: IPatternState) { - jobs.notify(MachineJobEventLoop.IdleReason.PATTERN) + jobEventLoop.notify(MachineJobEventLoop.IdleReason.PATTERN) } override fun onPatternRemoved(state: IPatternState) { - jobs.notify(MachineJobEventLoop.IdleReason.PATTERN) + jobEventLoop.notify(MachineJobEventLoop.IdleReason.PATTERN) } override fun onPatternUpdated(newState: IPatternState, oldState: IPatternState) { - jobs.notify(MachineJobEventLoop.IdleReason.PATTERN) + jobEventLoop.notify(MachineJobEventLoop.IdleReason.PATTERN) } } @@ -120,13 +117,13 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } - override fun computeNextJob(): JobState { + override fun computeNextJob(): JobContainer { if (energy.batteryLevel.isZero) { - return JobState.noEnergy() + return JobContainer.noEnergy() } val stack = container.getItem(0) - if (stack.isEmpty || !MatterManager.canDecompose(stack)) return JobState.noItem() + if (stack.isEmpty || !MatterManager.canDecompose(stack)) return JobContainer.noItem() var findState: IPatternState? = null @@ -134,7 +131,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : if (state.researchPercent < 1.0) { findState = state } else if (state.researchPercent >= 1.0) { - return JobState.noItem() + return JobContainer.noItem() } else if (findState != null && findState.researchPercent < state.researchPercent) { findState = state } @@ -154,10 +151,10 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : stack.shrink(1) container.setChanged() val complexity = MatterManager.get(copy).complexity - return JobState.success(MachineItemJob(copy, (if (complexity > 1.0) complexity.pow(1.25) else complexity.pow(0.5)), BASE_CONSUMPTION)) + return JobContainer.success(MachineItemJob(copy, (if (complexity > 1.0) complexity.pow(1.25) else complexity.pow(0.5)), BASE_CONSUMPTION)) } - return JobState.noItem() + return JobContainer.noItem() } override fun setLevel(level: Level) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt index 38753f97a..7b7c446e5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt @@ -8,7 +8,7 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.level.block.state.BlockState import ru.dbotthepony.mc.otm.block.entity.MachineItemJob -import ru.dbotthepony.mc.otm.block.entity.JobState +import ru.dbotthepony.mc.otm.block.entity.JobContainer import ru.dbotthepony.mc.otm.block.entity.JobStatus import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.container.MatteryContainer @@ -44,8 +44,8 @@ class CobblerBlockEntity(blockPos: BlockPos, blockState: BlockState) return JobStatus.SUCCESS } - override fun computeNextJob(): JobState { - return JobState.success(MachineItemJob(ItemStack(Items.COBBLESTONE), 40.0)) + override fun computeNextJob(): JobContainer { + return JobContainer.success(MachineItemJob(ItemStack(Items.COBBLESTONE), 40.0)) } companion object { 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 987b313b7..375c2d347 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 @@ -8,10 +8,9 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.level.block.state.BlockState -import ru.dbotthepony.mc.otm.block.entity.JobState +import ru.dbotthepony.mc.otm.block.entity.JobContainer import ru.dbotthepony.mc.otm.block.entity.JobStatus import ru.dbotthepony.mc.otm.block.entity.MachineItemJob -import ru.dbotthepony.mc.otm.block.entity.MachineJobEventLoop import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage @@ -70,17 +69,17 @@ class PlatePressBlockEntity( return JobStatus.SUCCESS } - override fun computeNextJob(): JobState { + override fun computeNextJob(): JobContainer { if (energy.batteryLevel.isZero) { - return JobState.noEnergy() + return JobContainer.noEnergy() } - val level = level ?: return JobState.failure() + val level = level ?: return JobContainer.failure() - val recipe = level.recipeManager.getRecipeFor(MRecipes.PLATE_PRESS, inputContainer, level).orElse(null) ?: return JobState.noItem() + val recipe = level.recipeManager.getRecipeFor(MRecipes.PLATE_PRESS, inputContainer, level).orElse(null) ?: return JobContainer.noItem() inputContainer[0].shrink(1) inputContainer.setChanged(0) - return JobState.success(MachineItemJob(recipe.getResultItem(level.registryAccess()), recipe.workTime.toDouble(), BASELINE_CONSUMPTION, experience = recipe.experience.sample(level.random))) + return JobContainer.success(MachineItemJob(recipe.getResultItem(level.registryAccess()), recipe.workTime.toDouble(), BASELINE_CONSUMPTION, experience = recipe.experience.sample(level.random))) } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt index d327d267b..8490c62af 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt @@ -25,7 +25,7 @@ class CobblerMenu @JvmOverloads constructor( init { if (tile != null) { - progress.with(tile.jobs::workProgress, tile.jobs::isUnableToProcess) + progress.with(tile.jobEventLoop::workProgress, tile.jobEventLoop::isUnableToProcess) redstone.with(tile.redstoneControl::redstoneSetting) itemConfig.with(tile.itemConfig) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt index 1eeff3911..11489492d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt @@ -70,7 +70,7 @@ class ProgressGaugeWidget(synchronizer: FieldSynchronizer) { } fun with(blockEntity: MatteryWorkerBlockEntity<*>): ProgressGaugeWidget { - with(blockEntity.jobs::workProgress, blockEntity.jobs::isUnableToProcess) + with(blockEntity.jobEventLoop::workProgress, blockEntity.jobEventLoop::isUnableToProcess) return this } } From a2dc3c7d97416249848c839c4e0dd5e8c992774f Mon Sep 17 00:00:00 2001 From: GearShocky Date: Fri, 16 Jun 2023 01:23:27 +0600 Subject: [PATCH 0607/1199] Updated redstone signal configuration widgets (?) --- .../textures/gui/widgets/redstone.png | Bin 736 -> 713 bytes .../textures/gui/widgets/redstone.xcf | Bin 2211 -> 4764 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/redstone.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/redstone.png index bf86e17f084afd79ccdec439e3b7f132dd8b60ac..25899a087574c82adaee823065459db4e5ee89c9 100644 GIT binary patch delta 657 zcmV;C0&e}_1<3`F88`y~001YZ-Om630flKpLr_UWLm*IcZ)Rz1WdHyu&y|rqNW)MR zg-=sOkxBf6M;+ajyeQW;Qn&&uu0Maz8s9I@;XvDm0#W5iUCW7;EKB{2(7aY$Y8OWePVcO#qQ zYjblyX0JpZfTo3GChk&8hN~qEYD|o>d!E`3DJ6XJn0p>mT;wJ$F>Y33tW+2`%`2?b zFxK}%hJ)}do+r#nR!;s!Wy(fn8O;-x1cKSa{jK*GXEs$6=U)=t?=uf5HrZr@Tred< r8`jk`Gmq9g2K|gZbVyFvtJeAeSm+4+UDuV$00000NkvXXu0mjfrji^> delta 680 zcmV;Z0$2UX1>gmc88`+2000npE&Tuh0fcEoLr_UWLm+T+Z)Rz1WdHyuk$sUpNW)MR zg-=sOkxB<( zuLxiSVMvfWLS5n{2}!Ab|SlBp3-6HBV5Q@)V(Sbycb#aXM= zSnHnrg`vE@lIA+CVZ^b71d9Yq2yX)y z*KJMN11@)f!6!pDWmgK)5`PK>;QfrgDF+PP0)1=V+*;>2eE>2vtK}Qu;1C!qQueyf zyL&t5_HR#Xem}UQa>E3@&nN%@00v@9M??Vs0RI60puMM)00009a7bBm001r{001r{ z0eGc9b^rhX2XskIMF-~r9uG4m{s4Z=0000PbVXQnLvL+uWo~o;Lw|B*VRU6=Aa`kW zXdp*PO;A^X4i^9b0Jup+K~zY`V_+BsLklp%82|tOC(i&z#zE;Zrr{c6qaLFKnCCY9 zH_vVOKWt-+o}R<&v2`IK|FN-$g6H5x+S=gY|M=u#g(td#;I(T})L=8GOG+2RV23k1 zQTUz5j}tV97yxq*3uR2;)U#(8ip->>NH!RoISg1lM#yZe=1{91tFW^A-*N01BP=Nf zty#lJPCbU6{7z18V5D18q-6z->@j+HiteQ%y*xGAq#A8`jDk@>HUI$rfJ6$Y$Bh{P O00000TsT)3o1VUpdRVy5nYzST;7F{$1At70;t2A*OOL1Jq2DdBc z8BjoZhNx!26L`gvS765;p_G&+y8Qlk<|dP3m8zAhz_rfI`MmecIrl$zl2*HOFTTIN z8GpODv}70`L-S%7KR{QZAmAcp3Az?a(B(B~`W8+i#_Lc7y$ijW@``)|`U5JrSZrav z+vzlS`pCvjduzA3)^BdagLZ!_zWw=^U&&H&uIZZN0tIikB9V9$b)8Vd0yd zc0X?KtZy}Yis)``_L}|J`Dgfqz38l*Gb4DI2>I*DefrnrKJ$HYFRv!|E1xF!tGVQU z;aWiwsd95$?bgY>z8Vf}~eeG3B|L_cHuD8D4FczeWss zekQ}uX83Z3zXGrIK7h2|6r^~~FP)$3nt03L{(gq{n@IaEGs2%Tg0Dh4SNO{W8>;X( zudf`IO>me`DKaOA#vDe7Ib%h`9DHbw4~-0F7$OFkrp%v16jEb8!Z_q7xhM+^X1p!* z*vV!%WuCYg=FqfmuE^wuT25J%P35psgR7B`Bl4*kQ^TP~E}|-dHS(z$8BCSAYUEQR zANpF88uJmxDnH5O;~30%Tj;TqO_h9H40C8&Hy8O-wVbjbpW3C%$C8<)K8~mlyTp>P zr8X%Amikz2buK)cr9PJWNFg=4qr~WB>Vr-OSuFI}$%dFGE=F@uA2%2Eamy(S>Vw^( z&Lgk9-5p$7;OVXWGQbmnGo$cfMtBN%h1(Nss0w$yJ^`MfM0p(mtqC3K1cxBu1rzKc z@@WdboU=R{dhj{pu?L^5wD$~vK%H0*z{puOqW~yN0M^5yRyzf=CG$im&j3--!rOt7 z{2U4e4;XwGZZ%c}kg^0|KdfrCQ@~7q zLVX69mpDHMR6&oYabTr>4xvITPvrOnRw44K1Ezo`%OeLoffbSZi4jI+b?{9AOZ_l= zz)~x>npTu2^#iQBhxU|s>gVQ7fvdww2bVB0ztQfk-Q8|(TtKhBWi&3+@u|aK^rFY- zoF3?W6n{VGjju?0e3m5p;cdtz9oKHq%W=`1jExyj89U}BJkFcrv5~?!amxIa2)vXN z#t?x{0`FTW6CMx~j0+|=j`$w<&(3YBiFO(_VIx|$|Ji{gk($V=^9H@!nke_JR9XYo^@**csiT&JiybD zJP!{3;puEu+c0lK44=1}R^%HYZt<6m440{K`oMmf#_3&}8FOD`1$Y%9ZQNXIf=w<% zuUF$rHdwY?!{w6AEk`yQ$h(X-DFv3+$pEBHQwamP_}4 z>ULfabUrHebN=kv({5M3o?t^&>3ID_m`0;u5ROWN0+4+kuttrb9yUt#0!@1!$WHQq zCUE^Xg0j9$trTcq2DnfCKVd#?n`@5W#;I;TcG~3PZAkNSt98S!G(TQ(X@`_`>m d^bKC4dZ$M9Y2Tt}=>6YzAkY*caG9u9&EHSXR#*T4 delta 206 zcmbQEx>#^R2qX8#P%%cuDGXr190;LVT_7|&7ldYDm~1E@%*hDkv1VkZXH4RpG1-#G zpNVNEP+W?MX)8#Y6)4MecJe-+6O-RE=1hLT?;ywx(+;6og22jI@?gqY+9sFt{e>#` rXJT^z%d^G6q}@64(n?vs%!fiGv%ghC>~uhQofcflv+rflew_ From ab1b752f3c42b241e2950af9133336701a00865e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 16 Jun 2023 09:23:29 +0700 Subject: [PATCH 0608/1199] =?UTF-8?q?=E2=9A=99=20SHOCKY=20=E2=80=94=20?= =?UTF-8?q?=D0=A1=D0=B5=D0=B3=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=201:34=20?= =?UTF-8?q?=D0=BE=20=D0=BD=D0=B8=D0=B5=D0=B5=D0=B5=20=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=B4=D0=B5=D1=80=20=D0=BF=D1=80=D0=B5=D0=B4=D0=BC=D0=B5=D1=82?= =?UTF-8?q?=D0=B0=20=D1=87=D1=82=D0=BE=20=D0=BF=D0=B5=D1=87=D0=B0=D1=82?= =?UTF-8?q?=D0=B0=D0=B5=D1=82=D1=81=D1=8F=20=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=B5=20=D0=BD=D0=B5=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0?= =?UTF-8?q?=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index aa96bc775..a7d1c70b3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -173,8 +173,8 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : matterNode.discover(this) } - override fun jobUpdated(oldJob: ReplicatorJob?, newJob: ReplicatorJob?) { - visualItemStack = newJob?.itemStack ?: ItemStack.EMPTY + override fun jobUpdated(new: ReplicatorJob?, old: ReplicatorJob?) { + visualItemStack = new?.itemStack ?: ItemStack.EMPTY visualProgress = 0f } From 8c06b0e4975b0bf352298c6425c495f5dfd5bb07 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Fri, 16 Jun 2023 17:26:22 +0600 Subject: [PATCH 0609/1199] Matter replicator texture update --- .../block/matter_replicator_working.json | 145 ++++++++++++------ .../sounds/item/rifle_shot.ogg | Bin 7885 -> 15830 bytes .../textures/block/matter_replicator.png | Bin 719 -> 758 bytes .../block/matter_replicator_halted.png | Bin 718 -> 753 bytes .../block/matter_replicator_offline.png | Bin 701 -> 742 bytes 5 files changed, 96 insertions(+), 49 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/matter_replicator_working.json b/src/main/resources/assets/overdrive_that_matters/models/block/matter_replicator_working.json index 4d9184f06..d05bfc446 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/matter_replicator_working.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/matter_replicator_working.json @@ -1,5 +1,7 @@ { + "credit": "Made with Blockbench", "parent": "block/block", + "texture_size": [16, 32], "textures": { "particle": "overdrive_that_matters:block/matter_replicator", "texture": "overdrive_that_matters:block/matter_replicator" @@ -37,11 +39,9 @@ "to": [8, 16, 6], "faces": { "north": {"uv": [4, 13.25, 8, 14.5], "texture": "#texture"}, - "east": {"uv": [0, 0, 5, 5], "texture": "#missing"}, "south": {"uv": [4, 14.5, 8, 15.75], "texture": "#texture"}, "west": {"uv": [8.5, 4, 11, 5.25], "texture": "#texture"}, - "up": {"uv": [4, 12, 8, 13.25], "texture": "#texture"}, - "down": {"uv": [0, 0, 8, 5], "texture": "#missing"} + "up": {"uv": [4, 12, 8, 13.25], "texture": "#texture"} } }, { @@ -53,60 +53,95 @@ "east": {"uv": [5, 4, 8, 5.25], "texture": "#texture"}, "south": {"uv": [0, 12.25, 4, 13.5], "rotation": 180, "texture": "#texture"}, "west": {"uv": [5, 4, 8, 5.25], "texture": "#texture"}, - "up": {"uv": [0, 12, 4, 13.5], "texture": "#texture"}, - "down": {"uv": [0, 0, 8, 6], "texture": "#missing"} + "up": {"uv": [0, 12, 4, 13.5], "texture": "#texture"} + } + }, + { + "name": "canisterlight", + "from": [5, 11, 11], + "to": [14, 15, 15], + "faces": { + "north": {"uv": [11, 12, 15.5, 13], "rotation": 180, "texture": "#texture"}, + "south": {"uv": [11, 12, 15.5, 13], "texture": "#texture"}, + "up": {"uv": [11, 12, 15.5, 13], "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "canister", + "from": [14, 11, 11], + "to": [15, 15, 15], + "faces": { + "north": {"uv": [15.5, 12, 16, 13], "rotation": 180, "texture": "#texture"}, + "east": {"uv": [8, 12, 10, 13], "texture": "#texture"}, + "south": {"uv": [15.5, 12, 16, 13], "texture": "#texture"}, + "up": {"uv": [15.5, 12, 16, 13], "texture": "#texture"} } }, { "name": "canister", "from": [3, 11, 11], - "to": [15, 15, 15], + "to": [5, 15, 15], "faces": { - "north": {"uv": [10, 12, 16, 13], "rotation": 180, "texture": "#texture"}, - "east": {"uv": [8, 12, 10, 13], "texture": "#texture"}, - "south": {"uv": [10, 12, 16, 13], "texture": "#texture"}, + "north": {"uv": [10, 12, 11, 13], "rotation": 180, "texture": "#texture"}, + "south": {"uv": [10, 12, 11, 13], "texture": "#texture"}, "west": {"uv": [8, 12, 10, 13], "texture": "#texture"}, - "up": {"uv": [10, 12, 16, 13], "texture": "#texture"}, - "down": {"uv": [0, 0, 6, 1], "texture": "#missing"} + "up": {"uv": [10, 12, 11, 13], "texture": "#texture"} } }, { "name": "canister", "from": [3, 11, 6], + "to": [5, 15, 10], + "faces": { + "south": {"uv": [10, 12, 11, 13], "texture": "#texture"}, + "west": {"uv": [8, 12, 10, 13], "texture": "#texture"}, + "up": {"uv": [10, 12, 11, 13], "texture": "#texture"}, + "down": {"uv": [0, 0, 6, 1], "texture": "#missing"} + } + }, + { + "name": "canisterlight", + "from": [5, 11, 6], + "to": [14, 15, 10], + "faces": { + "south": {"uv": [11, 12, 15.5, 13], "texture": "#texture"}, + "up": {"uv": [11, 12, 15.5, 13], "texture": "#texture"}, + "down": {"uv": [0, 0, 6, 1], "texture": "#missing"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "canister", + "from": [14, 11, 6], "to": [15, 15, 10], "faces": { - "north": {"uv": [0, 0, 6, 1], "texture": "#missing"}, "east": {"uv": [8, 12, 10, 13], "texture": "#texture"}, - "south": {"uv": [10, 12, 16, 13], "texture": "#texture"}, - "west": {"uv": [8, 12, 10, 13], "texture": "#texture"}, - "up": {"uv": [10, 12, 16, 13], "texture": "#texture"}, + "south": {"uv": [15.5, 12, 16, 13], "texture": "#texture"}, + "up": {"uv": [15.5, 12, 16, 13], "texture": "#texture"}, "down": {"uv": [0, 0, 6, 1], "texture": "#missing"} } }, { "name": "pipe", - "from": [1, 11, 7], + "from": [0, 11, 7], "to": [3, 14, 9], "faces": { "north": {"uv": [0, 14, 1, 14.75], "texture": "#texture"}, - "east": {"uv": [0, 0, 1, 0.75], "texture": "#missing"}, "south": {"uv": [0, 14, 1, 14.75], "texture": "#texture"}, "west": {"uv": [0, 14, 1, 14.75], "texture": "#texture"}, - "up": {"uv": [0, 13.5, 1, 14], "texture": "#texture"}, - "down": {"uv": [0, 0, 1, 0.5], "texture": "#missing"} + "up": {"uv": [0, 13.5, 1, 14], "texture": "#texture"} } }, { "name": "pipe", - "from": [1, 11, 12], + "from": [0, 11, 12], "to": [3, 14, 14], "faces": { - "north": {"uv": [0, 14, 1, 14.75], "texture": "#texture"}, - "east": {"uv": [0, 0, 1, 0.75], "texture": "#missing"}, + "north": {"uv": [1, 14, 0, 14.75], "texture": "#texture"}, "south": {"uv": [0, 14, 1, 14.75], "texture": "#texture"}, "west": {"uv": [0, 14, 1, 14.75], "texture": "#texture"}, - "up": {"uv": [0, 13.5, 1, 14], "texture": "#texture"}, - "down": {"uv": [0, 0, 1, 0.5], "texture": "#missing"} + "up": {"uv": [0, 13.5, 1, 14], "texture": "#texture"} } }, { @@ -162,102 +197,90 @@ } }, { + "name": "body", "from": [1, 0, 0], "to": [15, 1, 16], "faces": { "north": {"uv": [0.5, 3.75, 7.5, 4], "texture": "#texture"}, - "east": {"uv": [0, 0, 8, 0.25], "texture": "#missing"}, "south": {"uv": [8.5, 3.75, 15.5, 4], "texture": "#texture"}, - "west": {"uv": [0, 0, 8, 0.25], "texture": "#missing"}, "up": {"uv": [0.5, 8, 7.5, 12], "rotation": 180, "texture": "#texture"}, "down": {"uv": [8.5, 8, 15.5, 12], "texture": "#texture"} } }, { + "name": "body", "from": [8, 7, 0], "to": [15, 11, 1], "faces": { "north": {"uv": [0.5, 1.25, 4, 2.25], "texture": "#texture"}, - "east": {"uv": [0, 0, 0.5, 0.75], "texture": "#missing"}, "south": {"uv": [0, 0, 3.5, 1], "texture": "#texture"}, "west": {"uv": [3.5, 1.25, 4, 2], "texture": "#texture"}, - "up": {"uv": [0, 0, 3.5, 0.25], "texture": "#missing"}, "down": {"uv": [0.5, 2, 4, 2.25], "texture": "#texture"} } }, { + "name": "body", "from": [1, 9, 0], "to": [8, 11, 1], "faces": { "north": {"uv": [4, 1.25, 7.5, 1.75], "texture": "#texture"}, "east": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"}, "south": {"uv": [4, 1.25, 7, 1.75], "texture": "#texture"}, - "west": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"}, "up": {"uv": [4, 11.75, 7.5, 12], "texture": "#texture"}, "down": {"uv": [1.5, 3.5, 5, 3.75], "texture": "#texture"} } }, { + "name": "body", "from": [1, 1, 0], "to": [2, 9, 1], "faces": { "north": {"uv": [7, 1.75, 7.5, 3.75], "texture": "#texture"}, "east": {"uv": [7, 1.75, 7.5, 3.75], "texture": "#texture"}, - "south": {"uv": [7, 1.75, 7.5, 3.75], "texture": "#texture"}, - "west": {"uv": [0, 0, 0.5, 2], "texture": "#missing"}, - "up": {"uv": [0, 0, 0.5, 0.25], "texture": "#missing"}, - "down": {"uv": [0, 0, 0.5, 0.25], "texture": "#missing"} + "south": {"uv": [7, 1.75, 7.5, 3.75], "texture": "#texture"} } }, { + "name": "body", "from": [14, 1, 0], "to": [15, 7, 1], "faces": { "north": {"uv": [0.5, 2.25, 1, 3.75], "texture": "#texture"}, - "east": {"uv": [0, 0, 0.5, 1.75], "texture": "#missing"}, "south": {"uv": [0.5, 2.25, 1, 3.75], "texture": "#texture"}, - "west": {"uv": [0.5, 2.25, 1, 3.75], "texture": "#texture"}, - "up": {"uv": [0.5, 3.25, 1, 3.5], "texture": "#texture"}, - "down": {"uv": [0, 0, 0.5, 0.25], "texture": "#missing"} + "west": {"uv": [0.5, 2.25, 1, 3.75], "texture": "#texture"} } }, { + "name": "body", "from": [2, 1, 0], "to": [14, 2, 1], "faces": { "north": {"uv": [1, 3.5, 7, 3.75], "texture": "#texture"}, - "east": {"uv": [0, 0, 0.5, 0.25], "texture": "#missing"}, "south": {"uv": [1, 3.5, 7, 3.75], "texture": "#texture"}, - "west": {"uv": [0, 0, 0.5, 0.25], "texture": "#missing"}, - "up": {"uv": [1, 3.5, 7, 3.75], "texture": "#texture"}, - "down": {"uv": [0, 0, 6, 0.25], "texture": "#missing"} + "up": {"uv": [1, 3.5, 7, 3.75], "texture": "#texture"} } }, { + "name": "body", "from": [1, 10, 1], "to": [15, 11, 15], "faces": { - "north": {"uv": [0, 0, 7, 0.25], "texture": "#missing"}, - "east": {"uv": [0, 0, 7, 0.25], "texture": "#missing"}, - "south": {"uv": [0, 0, 7, 0.25], "texture": "#missing"}, - "west": {"uv": [0, 0, 7, 0.25], "texture": "#missing"}, "up": {"uv": [0.5, 8.25, 7.5, 11.75], "rotation": 180, "texture": "#texture"}, "down": {"uv": [8.5, 8.25, 15.5, 11.75], "texture": "#texture"} } }, { + "name": "body", "from": [1, 1, 15], "to": [15, 11, 16], "faces": { "north": {"uv": [8.5, 9, 15.5, 11.5], "texture": "#texture"}, - "east": {"uv": [0, 0, 0.5, 2.5], "texture": "#missing"}, "south": {"uv": [8.5, 1.25, 15.5, 3.75], "texture": "#texture"}, - "west": {"uv": [0, 0, 0.5, 2.5], "texture": "#missing"}, - "up": {"uv": [0.5, 8, 7.5, 8.25], "texture": "#texture"}, - "down": {"uv": [0, 0, 7, 0.25], "texture": "#missing"} + "up": {"uv": [0.5, 8, 7.5, 8.25], "texture": "#texture"} } }, { + "name": "body", "from": [3, 1, 3], "to": [13, 2, 13], "faces": { @@ -268,6 +291,30 @@ "up": {"uv": [10.5, 13, 16, 15.75], "texture": "#texture"}, "down": {"uv": [0, 0, 0.5, 0.25], "texture": "#missing"} } + }, + { + "from": [-2, 10, 7.1], + "to": [0, 14, 8.9], + "rotation": {"angle": 22.5, "axis": "z", "origin": [0, 14, 8]}, + "faces": { + "north": {"uv": [8.5, 13.75, 9.5, 14.75], "texture": "#texture"}, + "south": {"uv": [8.5, 13.75, 9.5, 14.75], "texture": "#texture"}, + "west": {"uv": [8.5, 13.75, 9.5, 14.75], "texture": "#texture"}, + "up": {"uv": [8.5, 13.25, 9.5, 13.75], "texture": "#texture"}, + "down": {"uv": [8.5, 14.75, 9.5, 15.25], "texture": "#texture"} + } + }, + { + "from": [-2, 10, 12.1], + "to": [0, 14, 13.9], + "rotation": {"angle": 22.5, "axis": "z", "origin": [0, 14, 8]}, + "faces": { + "north": {"uv": [8.5, 13.75, 9.5, 14.75], "texture": "#texture"}, + "south": {"uv": [8.5, 13.75, 9.5, 14.75], "texture": "#texture"}, + "west": {"uv": [8.5, 13.75, 9.5, 14.75], "texture": "#texture"}, + "up": {"uv": [8.5, 13.25, 9.5, 13.75], "texture": "#texture"}, + "down": {"uv": [8.5, 14.75, 9.5, 15.25], "texture": "#texture"} + } } ] } \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/sounds/item/rifle_shot.ogg b/src/main/resources/assets/overdrive_that_matters/sounds/item/rifle_shot.ogg index 82f78ecdf958302914d42ad36dc2bb1252adbc2a..7e73c1313d3f47d2f187ce7b0fae607eb8ab2cce 100644 GIT binary patch literal 15830 zcmeHtX;@Rqw&>1C5(bk1F@)g+2oNA>fPjcYhcFmMnGHec1OhUP2oBiV0TKuyARt5r z(J%xV6%cT?!zhyqGKk=S1J2rQw?m({yL}t&bMATP-S6J_efN9+UZqlB)v8sscCDdm z)!KXOjvYY&6!zOpA)&y#j)|wf%*%>nrj($kvsS|4b_*AziXC9tnkS%Vmy_|&*HThn%slj5U7zYrjMlI`fWc62+sJ(;>SIVC=4A)p_VMyPzZnmA+|o`A>m|k2moLKfJd>^Iuh$?sVu9d?yo3guhfR<`4wgP zL&RvA?eISeGDDyX0B}G^MHkgS@l3eBeh1N_C{3|G-p}bISxp+Sv>x66-aI;`vAZ!b z<+`OAN;3=rt{Y&ojm0{FD@ByVIF|?(c?M}C#wU-ZVXT@I*%-SKa*mJP^M)gS&d;0b zi=1CjyC+%dHr+S9d~9b!qfcE%MtryX`ueBG{wmO4)m){{<3s31W=f+mp`(sGa=PITwezh<+ecq!3s;r=u#8Q z(t6Lv*o0H@)xB}8y~*QUwDB&DFDRf?;VVxADB`Oc|BoCSCXe~=Gc#_)3Sfe~yt>Qa z>Mn|VAmwTrP3;SZM*vW!%s|>u8e_|D#?{>$!Mr8iZM4ki+B=_B{}958*a3iPYcRCS zU=-v=pv`oe!?xX3cLyF4Ds@>N;HL8?f zYy0ulYVFN8L73jtV_L&{d=M}GW|dm=Z4Nj#Y_jS}(|H}RmS0wF(Q`id>wJHyMRVk_ z>wW7VfFtr3suRznBf#3<1;^f8L$AR8U459K-1zgv;hJpn!6Iaoj&Y;$5u^0OT1OPN zBbE(Dg+(4-%{l&odKSv`>@O=P1AqwoMT`GYd{O1ETHH`7wHl+InXntDtrTqo*PUN> z3}9U~Y(XuiIe=PR*z@H0?o;d8iOQZiuC=l((92T!)uKS5k_E*sNWCvcl3S5BW_c2{ zihmW{Pm~)t!>NDCH{Kcq;LX51WoHv)zbPa*WZRzPu%j7^XT=fo8TW4;ynn0k+ts=M zu2}!H8~`*L(HEO6i;~%1J(lCgLVp$TKP+dL&ealw(GrSx7sdA`?b^?bt-mm)wA}+3 zzCpSXQ@R<`gqR@5h-rtI>5!P&Ju$a?W5UlK4D0>NV7{8o{aYFTVmT`&VzR#I5xW%r zAC{w_7Cm$-GW9H_gq51_m+#20YOXx~ytxkZZ&XzO^m_f^NPow;c<)~~8TtRE*K!&Eful`p70D!7k!~4rV z5)f!J8|W|_XcH2=>A$uZuy>Z>JIw$YTMhtv0Pwh>aVAp>A62|Q-z5&^IcPAn-TC>k z`t7p3Vp9*#*Tz8;Sa?sxq^DSC<{>x1aCdM)VY`6sV$(YuXuRB{25x&OpjHpix(YGy zg&BCmK+9W6p3{J@4&<8l%HaVf)f9uNy@{#q{4uC2S(E|SjR;{r$ROkc& z@*Xiu$(}zkgwbI?ZQMul(O%*ZHm<5toBoG&fCuc)jD1EMS2d!G8LN(~-N=dmr(+0^ z_k$hBL1gwy$J4%l=r#BtKlx}kqNhX&(2dig_X9%KIVnd;ei z0B|Z5gn|AAyEFy@2xG#Is{uf1%zmT)e477z=)Vz!2&n*&SH~fw8jM4WqQjV_G<9AW z;0xPFV(LIvkfAG2r_V4Ws8JaLGXRSKmQr=bZ!!WNJIR&tbtAiI-qUU+F`yHaZ^8hp zxZ_XvH==L+0Z%|0Y(MKHl)BHMWRb$JAH6WoIUydlyxr?j%Cz#=@1Mb4$ZXB_?>Ph~}3@t6E z)IrQ?hA)VD3sDzW)!5tuo+QjKh_e|Ht0gP27Vva|t{{a(+$xU|#)IQ7oT9;kzqa)h zEiErDoU$GVKnLn}c}y5`X{FUg1ArwJ1R$$W&ZA9TD1F~^KLI+VE)zfk>Vk~#WvkSP z#@Y{J*O| zLvS+ez1vvN6C+Rl>LqLd9Y+$3AVjrD4^4P{)ZW$!~!Kp+fU3U|A@ zv9gR?VAD&iPBI3imI%V4?Y(+H7`T)~n%8*{);UB>EOe(Db0%ehcEdVBV693-AO1*;ZnJ&LJ%aE5)hNgYL{0>C!BkM#Jj?|Z2OT3T zw3#j2eH{TXH#q@JGop)yUI>9-k6vvg{34k1;2jcFz2OxNThXh)2I6i|&B&san^*(t zONR^SUV<{yi~dJPt*A6`3>>l20g^LQ&U_s~UGapyn*Z6MEGrBAG8Xm4MFy{;E1oJI z)ZMZ`aGV&V@zr+*8G-?6eChB4udF&O^w*BEQV>u1R|iN4od2&5kPtY{*AZZ4#RV^4 z!Ck3*DVtYnVDoGFwL=LK0)byaD}=!2U-Nw-R2FFUwFz#&u$A4<)XHYi&;Ha#=oTG2 zALbXE1#f6rwa)H2ZmTS9%+s^o)r0gz(J=3+X57Q^jv>2@d3x1kqb!llVwsh);)t9z zUJu@6O&yG1u*Iwh6CA!GW59%5i6#Rk-(g6S?UcD{U0&YoJ55=F50sCD5^QEIJ$9WRb$c zK8rqQe2)Jd`#JLS*3W65gFbUU`-7$5?`a4vvNi*LAYO~?OWy}sFpxLFe=^@@MdtGa zg4_AV%^BefH$BEjY?8vM^L10t-e)SQI_}xqL#?&pS=78*3#Gx;<1XJoO@>}tmL@a% zcNr`OQXr;C%3<&^)oj8v=m0fN?WE1q9|KjLele9YdNatXm$@F{@yNzR2 z7b=fwes+{M_^f4FV401F$o% z@gCq*a5($IPCyv+I>$o$(@%%GA6zYqwMx6K8GB2~@-H31hsf@n&t1RMz~J(D*}&P( zu!{%k({cuT@bz{-{$6GC`{l=^*;_H+{kbc=?R3-SR}0Ig^~vujjEwwOKE*uJaV|Ss zT3)JjHd$`k6o^^N=Sldly=Kg{#$o|#;5SgtNU3RXyj54|3>031O{8%H&^q;RL!kd7uhSJ>J{pZU|3)co=TJlNuoNSiZD?*pD_Qqm@2Z3v!NFhRNYy$lWX3%Nry=CQ?#! z%T2A30N`(1CX^3K#uR3wch=c;>8QgK1cVW3%oI>@_=I+Tp)I=oEgVL49S%k2KHI6Z zT7pbQDU6MQd)s3oS-aJqclJkK2|QhUAnP5M|1EyhLHM9o_s1=+?uHqam6hltAJ+Ir zWsC%#&nQV=H+7;dzGkSKP!NzxBGYezY}^xM7pW!x_` zrmffcN&zDWp+vF5=lfBs;1$Y4u>hR0EN(H{X`Z6+Moq+!ohk6U<@ zs_jrH1ksx;1$qp*BPklrxr`3>bV<8;ZiPH7LFmYLx7H({!dVw|mBQl$6+`~i?X-s@ zKSy zK-Y5BMx(E?E8Kh7=-3%d-5!k`LgAL#7rOl0S>!BiJ`I5QXRD^6#|p)X(xnn#<27rV zZzp*F@p9r``{l?|ownba8+Pqm-M8q|u{3r7g^W8vhj8R2VI?ufw|AYP5U|CBP!3kr zZz97gb~+1dA?-jD8g_4@5W$)^Tr~{6Z@!)%7uJr^(ypkSzVl$+ox$=gkNe zQq4csT+BA7JKZ9!8+{*IcR!gTIrljEhbDfqC+_FdeR~8$pa9mZ#AkR42~=B z$VaXE!I?vflg;nn%kTAIY?v@In(iE#;;0eP1ktR*RX@(RS6uL&+VFd1V zjjYeFB)8k`z+L_*mAT`?@;f51WV&0HrrU7lNpiz6*z0u4Z5Z*fF16Lf6OzaTf(1!x z+!C1!0q-k}wJqy9Di8#^%88l@O-H;&KEC=T;l$ZEl7LxYTI|B|@A_lwz!q9G7#aO# z3#(=E?)MWdre-|s(RJvnwWct@jhJ&u@~yrxWeAvmx4O}y?ZeC0WC#v^{N*6t)t?MG z@R98Rr~ymYXSybO_m&=H=nV{>?V;d90?XDcHyzVj(&lrrC9lYw;5NQ4OJ;7Aj zH@szYq0a$5+K7poz#`>DLCr$^Df9=znVRKDk8Ng`JCH9Ga<9V8WlX?Nj4;=YG8>7~ ztn5pn2xl<~n4`W<&`$XdSXE8^!#4j3co%Aq{(hG(A6zY`$z-^UDAOKtBs%wOo5A~q$!VBlGj5;?I>BXt3!!_Q;LxJe5g4FFxlqs21(0C4>eII zIj4V5zQ%|m2?OIaP~mWm5k32bow31Qn`iH+@WRv?mO1iuPuCycr2DWjR>Y1tiS;~T zNp&Ob+X4^L)~PqWA2bhlL<6vj!mFm%edkYUt)B-|<5#x?4#{lhir{f9oL-PjmG-!+T+FSc^&+Y9nx1(Uo0~51sZiy5K+< zOzsrIOT9esWi&#Vag;Tble5~mfb+qmo-3PV;bOw0k_z-)wD+N7{@&z(B4xSigc7@X z^yikVp*?=SbV4#q(*eKUkhNs8ZGKVXK#bS}KB$QX<`lZC5se#WFR&4H-12y1iA)tb zl4Tw#>chZ}iETH*Q7YDA@^dh2JgWphph4+{_KA8{Ij+Jqa(#wlPo}W%yWI`5u>dS*mH<0Qp8BH%^nP= zK4J(eAeyg3v`rm?0q}Q=j^Dhvwh-4|@3+zZ%>J`JP$0m~IVm%7*(1RtZ_oP=njiW| zru|*_$df4L)%39VV=jBuUU@7g4IQf3qCbjR=+5qOEl=%X)Igf6v#Moj^|F<>IYTU^oTRcX5y)^PdMOo2!Rzx|~)67H-qZ zkyb`P+z$|dUYgw7zO%jY;boGot^GxYJq!p7BHtSFoRG8z?zn`rGA-#J$b(q>xS2FA z$C@8F6QXH1-4^X_r)pBpwJ{cA#8$o!elzb6c~kC^eCgTIOkyg@a>$?ST9V!v7oOE_ zHgOXm=GeQL>9t|$ZRN-oTcz2HU~FKoe%^ej;>|vp0dvP%p+#4t{gysO@vDYDTl!Mw zWF1*u;!Njpcvg53M$Zc=%gc?&b;!nPKE?fw*xDs&N)$VzsRT)OLu51Rj`sIAu=Zx# zHb!mOeTqY`7~-)vMXq*Ji~nXK>C|$ls_LAl9tswwWqF4uiqA39Bb7|o1eWMGo0ZeQ zf8Y^>qp^`p;rkl?Ef=T0ZBas3(fJn`?}QVXRT%;ZCeR7wtp+uAM>#f-DF{c(G-ucu zABqx}Hs;V^hZf5>n`5BN>P3fpW*CU#69!22P!ZoJhqw0dqdc_j?d<`f3G7&(-6k&- z;TsoP?JsA@(p)Vq-ON`)xu4FvL8-&bMq1ZTa$BdQpQ&$9F$4{u z6Dj*TIG>)Z|kn>55m5EIZ(~qN3mhz4I;;5%wzVTFmv5K5w$_FuEiab2f?=m zdrs8kQxh2`gW+X}iip@)Kv)XAYH?oVMqQfq&@A9v^Emrl)zyhru^JPJ=b>HQc9Og1 zL34d|CtU~bJW3pF)3}|mRJtQ?@8-mPGnes4U!3<}(?c-5-ObyA9Dy7NX)1MB-*MZ} zkx{M%Y**^G6qyYh;tJSICoRsIh1S-|rt55XJLCz{X2v9wuMP=LcA2Gh16{(^W%ZX@ zHH4-vrZgE}Cn|dTQf{BL!$-kZ=%^1v!)S24kV+7E03K4CDy-YO*{8!8Jx{Wio#ak} zcg{j9mO;o22%Ji{7jRxPe51MlxA>D=hOI=$Dh3^$6O#2$b<@pbWB24&LIlN!!t@Su?kB!R z@BUuSSoOkY&STx&54N`tk(}*Xb+2I)8GEN*%vO21e~WxpR51EVr+vKXRCVOSdHf#t ztZgX%uHl-W$q;Yq-sKC$vmHtwX}|PMrgqTy_9vK1MY?;F#l~QReeoq(s6c+jMUGE! zt<-Y-LjV4NiS!*r9e@9PI-pG{?hnhU5%puk$)jW+yok*K7)XJHn|Rf&HfE^Bk?6k& z2c~Av{|Xehi_Z;u3OaPeU7yJ{$pl-;`b*Q8}#F!RMR$Q z5#dN?Rj!G8yb6{_A90BYdVYllY)+iDbvgYv5qu%6wZLfX`*bqowfao8UVw*X^o^^; zo?gO3u_VR-eNu|9T7;`Uo7eANj zmk!o_h_Ep32oCZc(kugX3Z&f_KB^&+cGEh5I=gjIe}%=6zld{;WUSA4Sd9r?0--rn>Im1K=x4maPaIXOcVGn(nr#%K%yEFhD*@*G|ybr`RwgjZ$ZlZ)CT) zc84zZbBdCmRfO0PCAG7ma1R%Wu_KNbu}_lDfg`}z4q2{4sFLBE4MIidUFxu zfJH%SW1Eg}DQ3dmxN913JZ-N#02*<^S>d-vMX48Vl=|Gcmj^GXVvixJu|i#dIbzM} zHONHYxcYAFhq@ELeG~GM(Y3`8)2Ei6bQGt)Q&VHtJ!l(XWSx8s_B${+>=oqA`~)a2 z-X5WJ_BrP6bf6W?wFLUeVq;^G{@7|vYi0M=x%H)_+gcl19R^9I=%U!F^dis9S3a}2 zjA?(^x5gL3SONT6iZaZ#r?JTFqIj3s<+SN4DrPZ--Qs8Ib1^8rNfcssXURoNg=z>q z2Zf3TbW7qikg3B+ACj8~4$XXALFWetgzHp{b@)!`c!%NRO8~ztiI`+>7aLpGYSs6& zKo2+%q-CplLj*Z>JrWyMRFBMh_<9nR4{veaN~YdXN zXU$pak**Qh{D>&SW3e~nwxrnS;zVgBgvyR$R~>tF(C7NE6}Nv}V{mu#fULQ_=62P* zSLpPfxv5VR0sSVoy0evN+IucDmmhLV)B>_v?jaIe|z=axuc}Bfw|e1C!*`~Gip;da2^41 zdJymo%;^>}x*;^?nak2pir#yGTx$>$389cV)a{LGXMdDKx&>(s;YVshMVl9g_@a7X z(PNlpM;t41ZY3;ny9^I&Z#}*vewCbEZj`q>aXHs~VC_5XSgddr(ny-#4!jpOtpV;nuUdZc)RK8{HEu{6E{BYKU3suh3^-d`O}9ZS-Q0=Fp-W5@<8yiD^@t+xMX#Ww}&c_V_gO_|(yPv!5@1 zdhZyTIpUXTz4)^;qK5J-4A`9676g5Va96t=5M8}drTMJ(?2l)zBp(cSXw_lSICyWV zp8sfF53RfJdUuRf*n)t6cVRxJ_xR;G{CNMp{^2_vj@e0r@<#qO=-C^TCsK#STyeyx z;Dkp=ikI|cnFbS6DaGC6b&}LN90TiwgN2~25(h9nZ zb+T>TmBy)F;_VQCQ9S%$hN>J?w+cAbYp84}X)5OG)wFEiQhLnq&bjO+``TfHneM{~ z?N5Q%ky8zjbprT1|FS#2TciUz#lFId1c`#lHXDrcfef44_-t@Jy3VYOHc2pI8pft_ zKP*HGbDaR~;D8@w!8IFg&N>-rk~$ZM!6<-p69iS5eiO>Hgff2cUfTjtfkRRjzgg_`ux)I9W=^TU!D2w0%hiO&&|kE#*$Lr~MLxN0=jNdJY+P$*?c09* zI(h7!j%lX`PECi!ft3bN={C5SuB@W_Qkl2Qic!b(4DggEMrJEY)}{4?*OO z%Af7mIx3F3t8N(oOLQ`+-fyvO%e~!3fRke>VElKB%^KEZc)tmF!?G&2N~c{8QBy}Z zz5N}sFV7WVXLE9U_A9?T90(VJhqwE~NVU%OWXNVu*{GUWai(JVhtg*S@ZVOoT=zLp zzX{bVPVTNxe(4+H8pxQYjr%}}Rc)&;R++t4HY0XycVN8P@4Z0hRUav@;Rup@VsF<| z>Xi@Hs13VB)QCsgh5~%g&n%N>vmMh3-2;*OS4~3&LgOOVwTC2r_3*X~b!|?QXq;nA zg|}idH_j8AmFZCBug^iZ20iJVQeu0%e-<7SEEgazsVcYt-F4k3aJ6mY6s=p6q zp9n7=!9Y0FfvP6;^-~+#9Zfb6MoG*2#@^B1RGce|AT1x`Z!(O@FPA^U8^-pZ$$M+V7pHwP)wr%`}=KFtdk# zyTo9;^sR?+)o;{ME3$PE|JdIxmV_au){f-EPY>Mq?NcUtF$R#xAoJcIEFuwHOzpb6 zc&;r`Kh>X2)&PEbpm?;s)gaWZ5je!r>4ak^UAM6t0`i39CXe(_n-}IhTd%a>OdQ{q zTFOE8_9n;2$5+e^Ul^)V*7y#;u(xN^9Zjd5J0ohQTCQO)4wudLUK@qTH#x3vGK#LG z5Z+x0dmUW3>!``uIBbhC6vOuPkZAM}i7t@VXqX~Ftw_&j7&+p%3A9reB_!(7n25+yBcLq>)$5@)@?TL=PW7=M1VOO9xW__Y++asGK z!FfsN+wV5N8Ps+9dNFj>)s!KRIDl3q*o)EzUg16bMx-*PnQhcY^yMb^7WWm z&@0;pyUSF_rsCy~x|SIbJDy}k<4%wQ^TbQdnzh*=0f{|GaJ+mw^?BQ%3EYQnEr?ad3YRNfNd^=f~bxi5b z!@@?F$O7Gf@(O9P&skY~cDF$`OrIOzFlJY$AfASAq8T$klHk^{kZc6r<(yY5wyuNF zp~p18oD9#SIGjG`%og+C?W;iLDpKJ+WzjHNy7=&~XvfRzI1-|OuMVVf#%duO@ zvsm*PpB<-tW~As5Vwe9pp(<=P#W+)U;8jl_;yFJVO9H0R`U#o7ze`Q;5gOOoHy4Ee z`Nq#Y^01Yr!=^`*+oBD-wEgQtV7&sflmKk&RhZ?wVB_%6A}UMaRsdQ5xsxI@F14ZY zVmcw~Ijetw9|NdonOV0T$qM=sLgmrV2y@qKMV$leyr`)_Y)sb38wKHII`x%O1JyS)3Jji+aKLNePv zIoWn>jJN30GDr1VTM!^lq8~=u&eYSRS$fr7yW(_$DCXj4Qov0hgkgeX&hP*Ja?1Fc zciA0iSto)~6f-O3A@*7#CEV+z08akRY`1XnAJetF6#liE6DD&2t}j_R+*LX;B&MAd z2l9J6U$^lErbqg#D;oKsB&tu08pqzQkWDU`xO%VBEs_RHNWvT1?Ctd6FbOTTr9XZ! z!AI_V?^Hg!}Wa78T=Z83nzvbF` z2z`iGdzB|gr*cY!4P7X_h)$S>DK`IPIYm8ZLf`}QiosI1tmpSZHPY8@wdL4x!(=R!_E}h zkKMC7Y2o6~+8&!?q4Q84P%&l2R_9?^Ie>u`#Y*Yrn}sm;0yr{=y0M34`;;ZYi|JNi zqnO8Rym%IcVb!$}0nsixu@cTEdyu@-RQPkNAq=bt6`idJ5|IgRRwm+3KqIUl8>|z> z(r+abD3@{WvuH&xEQsPStTjWok~;O1SZM~Uw4$^#qKE=w&uq@C4tL4l)JVMUoSvK< z-KmqSQIkV3E^jan#@M`i;`vekFbHaukiGnaBksVi z4U?AK{k_U7E6*2|0E$zG*F_~**&Y}$H@+u(ut1!v^4&^1^S)xZ$!K_C=S9t&Bd@=s zZwu7-`P-dS)K9O9;cmqbL?IZF$1TBnH}$As%bVmJ+xTWNDnPR*L(YisICIozc9dC;SSix?C z9GB7CQHg@ZVt-k2+u8Z*T~(aevtsV;>E5e@yfFoBKd-P70%>yOh?EF*{ZLXlIk@Cz zT_^@+sc4g2(Ez{F!0L8nhcd(=+SF%sjnz-Hqv+90t)wP*?3&?Pkq+C4PlJ+(ZmUGm zkBTRCgmhj2BA|X!HU>kr^^r}~%OxSp8Cl|z&gdMtuw7;KYW4bCUiO+!wX9&!j(zMdI;zB#-8a>H*O#BN!_izNhlS4<%)T*oIO0&*hx;1(fR9Q3 zBlNNI!AUcuuo@4BIV?V#gTFPO*M6paHh2j!+9EilRV!QvDx&vp0d-09lUafnR*!YQ z(D71!uC{&9v~*y?=OP6lUaWU7L}q6Ua^@2Tek(d`KtJSHO7~b&r!iLVZDT8x zw@*+1?m$P1soTw}{oNe9AeZSaTT6aV5-*roW6<}ThX)iZTsOl zrQsmId5t|7EJ6bbk2=ft^-!u3rWNn=Lqj|(YASp+&S=}ev*U_-T5pH8Jw1?j=NWB_ zcW-T0MWAy1F z!PT1T53#ZH$VUhlw`8naXj2aM0)#dVpY&h0DS@a_2K(ubLXl2(p}GtmAn7kjB`##! zag13Q8w+k&^bhIRKjg|>Fx?pPQ!U2>!K^=9@B_t>c=!8(?M64VQG^3OeLH#ITasZ~I z9Ls%dKDl5M&Rp_0@+LZrj0mw>L%boWts)M$mCJGSGuGn>;N&=Le4h!2IX2;PP4dDc zJKP`qp10OaWmovX(V>L!TAugY_#SNy#c0u{g-ZnNozs^zP9NG3Z=V6xI~#D)0n%xQ0XeRl+B#3my%-Rw}vg6>DMD z+HVKW_DD?!LNXrO*&p=;{0-Bo#uTlPh@9Ep>l4J@Zp54ojW*Qckl5JX#%X>V)D;*W6s4c41pu{S?8Q!|nXE(IMAuPqCnNu8y?ztE=HYr{fq3%Xmh8i0Gu zk;u-i^P7J;?=P$;DzTUzxwlDLGpfhVmlJR1;v=Byhlo)EX&WVWRzi18*NHSUp+C+lOe!h=|a8%DWzTwUKia9|-w6nmqDku%N0PIVM8?vajd2?k#7 zy?FfBZ993!n%ROCd zyQ2YrWQj;ONMrJMQxdN2AUwgk=-IApPJqhq&d8N3>+Z3iEzV_pCV+7#P5pLa9pN^C z5SrLFaJK!PVe*S7OB$5}>$t5g9?eaO3#QKocfRk*Z+hmh8!mI{JmRHr!mTBRQ-Q<0 zf*yfJw{TJzzhyANHHi)t$ka_-#=#)ot|xuU*>}Z$EEV(8QopFVQ$jYaaO2=t%XJ|{ zyDd|r#D~hVsqe}Q#1b`4;}IVLoJV>t{h>N51H^Y!afk59~>-GAU) zU)_;V=)?|*$5G^gu;`=b#Xk{gPcIry1ptvT@6z;jAtuc7sc~-+${f%_4>~UHnOUg9 zw!kMQUfBVvMb1!!?^R95CvM*lyt9%!nnuMVbgdn^oX!UZdI{G?7UFj-JeV3z?yfWH zk~W-d+Z5YGNeLZ4Rj}T5x zVh{iwf`C=@K=k9L0`qxhg?H5-JjbRg`N=MR=rUP>P^D={$)?*mB?sJkIQ0&$HfpB> zq&aHf#DGFWH5nNmE7U#Tp-8fl-mR6E=7yxiwYgkJSV3U1`?{XXM>PRAD;)u=0MSQc z$>PT<$_o)}(s%2C$2s+HaX+i%Di=%tz@}F6&Bj7pLy{{FM*p_LtVDBKQf^KV5i}_gAScnZ{D-{+-tw? z%7t4V&xaRpv`0J%T~w<5u<6i&xy!r$?Ehu<6SqcSRymM2W%@A1_dwy0e0YW%;M&Py zYEb>6;d1ndQ@_w`#{(3S-7I0>DMkfRWnQyKIt}<%o?Rv|^XT$&$IjClj1pKhmQmKB zVd~mcDr4lDyfs}|Gd?>=KG%dYhH6MyLJgOuo{sHuJ?binE^JbWkr+G}9sx}CRZweq zcyJlv96TS5;9(v!lTJ3_{%m$p_RY^06lMIoeVNRb$WE zwL(@lUQy9;wxDNcQt9iY60y(9O>@C1^m5 zsE>y|8I5b&GEn|i8c>(=)^&z36wL9&k{R-MR8W7UP`$=lGJd(Olw>`D; zT*~e}kH+sz4<7LWv@2NHFh%k*VrdEHTmY!zDsGpl4J`2sjToQjoRtX+#-diV` tQes`=yLbI?<=4!|5p&X*_5v5AAm6TzA^T-u$2`SE=R7F`SzHBZ{V%!l@V@{6 delta 6449 zcmY*d2UHVX)7}7~gEWzDXhP_bA_0^lyh4x`ia_86Dbi~wib6saqzVC%qO^dNAOz`B zq(nfZ6QrmhDoC+WEGYgP{Qh&kZ_mkOcAmX6bLT#D_a@Zq&(8)}czIa^bijWub-O4Q zn!5iU#Q_n6L8;`l9`_Uy zI0#_Efr71cBI`Irj}HLc*wL);L;`vY{yqymf_Nu_Mj@+;tjCbdq6s4i#^QJ`I8nrU z4E|IkVO0NJQT&9yEC9fIA>hYAR?Wi*;F1BBgQdoE)J*xLO?i#R`8?-%&E|5|o~x-_ z+1NhgwVk!GUF0{jZIL$PH8b0_vBmKk*&er@&NH)Z4j5PSoVT%k$!|N`;>bogd_i5hJRqSj{f z$8Bv}Z0Gj^Z1bX5!fc%{dCq^cb>NS|%q6buN3RHgo^fV#v*93ond*7DHT<=#Pl1nb z*@Kz_*_xW_nwEf?dJ?8=y{4>YgzQyQUpGR2SX=ME38M86YRC#TH43%lx`P^p&6Wo> z9i$O*Lt%aGX3HnGeud4B;F|jSTJjbR?I3MZLN+^8ZdAgbRn~5FRCja)Zgzx>wgiaa z%4;^d<(~C5jF3NVb|^mz7q_wve@Sp&y#&rAz$Nk?=362;K)Z)@Famm*`i>kA5@`p= zH3bTTHp-5??q$skqE`W!Y7MEdrgoDYDBoYVX<%g=?VRiR`i!%~iNM!qGB9)LWi=Ze za?iTKK!_zukVvPBi1VUG1`abkMdC@OgZ{iQ)V2~xZSyMr`IYx#!Og0!Ei63YelAoB90$5$}aiJ|tT7>Op=?1{mGi zPrZ`rO9L5P6p1>6P6q+^fUens>!1FA?ry${6sjAE7G16}7nco2f4|_Eh9pe6 zfxfcQY2Xlye|u$~F9;N%Q=8u}VExtiXB_KjK}?&ej@ZohJv#vC#nS_Ncoxr+iL6|J z*1h`4=rI!?uFz4W9E-syQl>ieq5&LkJF3qt-8_bb!w0EIW@#e7shr}VogW+yPD2sE z0VPN6%V?G|2w~-LU;zxlZl=J%4Tw>YC=fp(P{HTUB|#Jbmxjpa4whE{%V{7d=su<| z3s0~_$-xu3P$tqua8G3w0RTGx34*-{n9<+;#FgER9gzeJvpFrtop2E)QymM|loSrq zfjBto=u3L^0;k7JN~E4Pl?M56g*1@wC=UQzU`AU<8;UfL#RTXHl!JkhUR-XY$aN7l zaE}y8;FO~j#d8`k9|!Yb7Ec&Of`ZEc1h@>COXER7Buvo&H0lEkw84pCG=P9+1pv8V z0AOyg^1#O3E-^Tdv!es9(Y8+%lBtyN51axcWTU}&;H0WU*}?J++R*@l;}#60hrfCR z7sxG&<9QTm(B7|JoJe)6Q=bE=-2A@44+R2#&)WfD3CaXC&bGwCDD>}~%AI!&&!7Bp=uw%$If?FDLtq7Y2BH%3rM38GDG*N`jpot^xzXbT! z`rm1Qv#17NN8EO9X$XpdFf%B?VE^zO-Mah#y`|*4TS0sS-E zVhRm5oq&5C*cFa`V77jW@Mfx8S~FNsut92+TfxfZ)A@&X;5P!5Ey9uWb!3K*G@=O!5Lb=?O zxY4(e7aBc{1qTIY2?!#eHQH~z$SuvvqSzgU=&vK#p=58zO@-DqM~s3e6Bsj~!X>U6 zs|Vo|7y<(&Fu;M5hTaK;69bOnEzfCIcGjl}*eM@+fGc5${dTfFI}dM7Y?+%DVDIEQ z#Dr&0Pk)rkwtl)7>bw*VOMo$mCl5mSvheY|fmh#fShPK1(J~@({yj-S05Jf_=732^ z6d*G=Gmm9)-R92b$>Al?PD;Qs1b+;`OF@&9ldoiy_pj39qzpY0DhA#%NFU)e!OYBj zq%$1pM@KD&TJ(|W=%_`DlQki@D5RpKpoDnR+Sb-oU*AyKalf#nrkq?$u5D~IWTk(; zFA>(b`g$AiyzIakwP?>?b)S^|a+ogqg!j)ahb)fr`*jPWu`@Wm=`XlBAk7XAT{00| z5`{5x&H`!a$r~a)J|2;FImvI{R%M6oRZEDdzB-%vYhh7LT!-cDKjLau!+iICTs61k z46t(DteV&j)BQQ6o~iNEI*PTc_N<|hwpyS0IVk=CS5Z5C0cT!@JfX6EcIG%8LF`#Fx6J0fe1=VWKr{~0+G%T~+D^@w z@v-<5Ly^Tt8GG+`0PjgW%d(+YX^_JZz*mIkRj*biU&<|KgvPBu<0r;jDgwvO7P@dN^H_RJP>tdj zybMe+I9HyS$p{#|S;xkd@p-S}Fwwn_=xEv0B7En<1M8d6t(5C`d^72P<_^3@%S$yQ z?m#7le^8uu#qW-bTieBs4>eV7NF7v@gswk;SpSG$VO%q6Pw`{lc!+?7d!*juNMu}! zQ0Eiq!2|0gO!x$@cB4WTI9HdRNQ6roMXmxvbK6iYw=c1E2gEe|^ z&8O-O`riil65H{-xi1|S0WY4g&uy`ts9iFtA`Nh?m9EGe69~uvLz;#G^3uS zg*&0B$T!lg^x8QdZf}*S=JjRo3#VQX^c7HM$G!V}igAZ+)Z~JSE;P*~!t6$y@Q)N=gQU3!dZfO5P<~9=^#$mq~3YO_`})4T(rK9L4Dc}aSUDVc`i23>cp(D-Vx~ljVbrw1zo+)E0~z!ROlj80Wgmw)2B^yWdpO-0 zQMhJuq+d!>%EB%gr?&d@&89N8iE0KZwB}W$-sUEkI7J<{&y{C!JQqOfA9=#MI$Oy&l zovB3xi#tJsA9*5m{#AtuU$GPd^l%#%L#97&-H2sj{L$bIu{kEd`EL|-$nc$e_DGQ3 z%5TnwpbIRHg8VAxDVH-ZnlJ+1ht`31PufDdVVJOk>CSOnbofDYZR@cMzPfed*aQ=@ zuFyQyVcIz{MOR65i{>>e5Y795B3c>8W2%?qNOMwZ<0u@WCr4`t*}yv#rG<5Cx8W_FnzP zl@q_7hyu$G*T^}V|tSb*$0=bhhh*w7(n0oShAXJht8 z`}DvyR)8t&)8^d|ukLJCuXSqo{E1DwM$%kzOX_Tzt`lDUXe^F;a5kT;_1;Y5EjINt zQcLv*gj7X_VNPgT$qEh^i(G78Z+(E~Wk2hY7 zwP@^^SB-9T5k6IAeO4GPMxMsajWQXXsW*m=}$bpFk>g~GI<^9cXLl*4#`eddZ&#KFo&p)(eim$rBkSMMe!s*6Z| zG*MzKJhY0fSBmL4ZR)9sGpyQ-ex~-)`|ym*lN&5V)ng3jeAAnm#Fn9tabgM+Qo@jT zPw|r4*X`auo)@-l4{`JkE%96GPLhZ`lZct-6$JAlsHQ1N=Tiy!{ z@jtWG&q9oD3+uSd%2B-}R-7WFb=tn%)IIsKiEv)!@RysHrO(=QGVbe3N#FUNljT@z zohW&+RL5Z>7frS-NK5R#HTA1&ca!Yuq!Puh z>N450sP)>DPM$4u{Q$VCpXxz)E@@#;VpLOVTE!-&EhKwR{_DKIJ@3IeG`&56ws2h2 zNSTQ)&aSUEJK@WwNsn7SPfT7MC}^9ai*mNEH1yL)4*U12jCjwQjixT$uUsKae7=JD z6gB!pC*{iNY{e-LQm;1a`qpQ-Oln8n9-gy1zw=}SBM-U1A#7Q>Bed|(>jw5Fv)JEB zr&htg4qqYF!`ZdsR_I<;jRD+Q{jw9+(6)|ODuG~oio5znon;)~d=N z_+~Aag!7y#y%$E|?jCsnYfyY87=6vjbRqD)$g%tU=`cI?_XD{Nua?`KJVJ8^xAJ>^ zFYD-MT)F3ZMG zU4#CZnfxh4iuT+*hb=8;3p-WVj2hS!Rekyr(bw_V=oneD5weq9H7QtR^I1Y`QZjq* z+)VcyIi1R`ESZ)h-L7GZ2dn>#X7y>EjPx~_8RvSbRuh7?4`Ru0q za`TDY{Kmxp+Tx1(8RZA90}HSD>$FzB`}2MiUn#KKN}v82&Y{Z%bPr#g7I@~_NB4L% zv3mr1AMf(R{Q5tQP<-vPZO2E}s}4I_ykCB9eHc40{|wIl_I}-0JrUDpBxe|9k@a(#v@FJWjqW%v`6lC?5OkgE#%Q;r(C+S6^|4%aqNx z{M>xmp>Td>oMwM!f7|L)J?t;j5Dx$O-~8KL8KRtrUNeEW-kvUD3M_gM>Dpa?+B^ zrtAGy7hmr~jXo&dJzP3e?<~CYO!+r5>-myu^^#I<&SPo0?J>`m*~^o^e$dIxxMga# z>13KU-R@bfAq<8`X_DJLn~BxwWS4^Hknf0OXX29*O3fdf{GaZHJRK)>|Bdk1 zI^XsRj|3Yol{4#ZJLKg+x3D^trNxR4)w~)Q)`zC9DA6jQKt9! zUE?Mnyk)QoNY680aCXrUW*beDlge21&X0QgQo+3RLqNg0l7?BV4yyP@`~I;5dpiN= z$~zFCS;OI^fMu2;M;B_G4POd~U2z)Q;p=;`=p%{Sh4e<&u!n>LHlCN%r1_xu*;vyL zdwtp3_x|kRzAB|q6XjR$xSZUckGg_<{K`;?ALM0u>v{zkkdL||&a&mGjD=Quz9smFUX&w}a0000Ik%1I{ z{{Z5@zY+id010qNS#tmY4!-~Z4!;371ydvd00JvXL_t(YOQn^8lIkD~MU%1%T@|SR z|FiGjB(2ao>&(7et%MvPB(#c%imJ%-ot9;R-}FB~GHG;OB>MIB{W}mdWUeI{ipKsU zF+*9`wG;wug<$V7M36-UAB&p%r?G2)0DK4~t4J>Ha;;cFe{TDwCBFk=I7C3#@R?TC z`#8fLb(nynn#LFa$Rm8Fhe);XSwZ~3$oVmdd8mVshn$n`o03FewudT4KFH+gf=0kb zeF8qtAWsV}x}X7|A4{A8D?E1_htF)4){qL^xXq~j>PwhidXwIH!?@#oIAC^v>C$@U z4IS=mLbC$j-_37Bg&V;^tF~h7uByw^Y++VgpO2igl2u-fO}Vx^00& z+tzTFnM70P!6tCb0HAVw2y@hb^9)iCx5EWstXT0R9Y2?H$J0QUX~Cz-@fvIKMA}#v_E}%R z68-@IQS}$#;}Z5#$hqOqW?33yXNY5vc$WdVF%o=k*qr#EO-5262XOFWY}d8&J+cGJ z%Ynt81uTpp13(seRlK7Jm>-YJ0E7@AfEqwu7@PqfB8>A4>@&b8*nw9J=7lC;+(r0b pF;HV3aznZvwKX`Zv5&wo;(7LM1a@Z+a#sCMzo|9v&WYa&iCw0L6Feh5!Hn5p+^cQ~&?} z|NsC0|NsC0|NsC0{{SVenPQQi7=H*!L_t(YOQn^8lItJ{MNxN6w#6p@|F!R4pjKmN zJ3H?rGgY}k1d@tKl9WWwcjTO5H~vRZj1)@?lD@vae;0&@%Dtq57(9O@JZ$^EZyN<1 z1(-i$h#)r++!i&@&&iWP;Exd5Me61zXU7id=k~nPR^JKYaX>-Z!)EL$?SGR8)L{~A zDNQjzAos8tcg!t(R**&nS?>ePLktb%q1IyOCQ>Mv=R*}EAJo)X0;9m5`Xu=1K~5#H z1O@@^*y1X%!t=Dzd^R8Zq1LGV?pwU(gwOTdY|?4d3mDCkfSCIjWDS941ZPYBc?32YJ#>LPSYxmS yFbT#}*aC2S#4zTe9wA8AA{a8+hi18Qp8o)S!b9R#c#Jdv0000UmNy}Zgi-Fg81*10#}v>LY}F^iM+@?>;9?5s2-L&HnP81)wz2t4 zR;d-Gz=LTOC@av4&X8s_(7doD+w-i+ky^kTg6^x5e2X{-LI44R zP=Zh<24@5h5yII5=ZxS6cEU3T(*gsb&m#2C7>K?OxuRSbLRZOSXqqz~k6+bxL=r+F Rank?*002ovPDHLkV1loJ9<2ZX delta 644 zcmV-~0(<@O1d8y3zELRZhs5HL*-slK@6Th5+1hJ+O|=^QGod~h6r*K!EI6V{G2=)1pWw- zCQ>&yISo4`?&GAbz7xdbfP&P*X0(*ru}_DxYrz&tA0Y=1 zWlO{8bT&2xr-z3ok4@-PYd;z2Y_4g_`fP!|sroKO%Z2LhQrtXnLn z2vhLyr&tqpjbTYOi*<4q%duj4xnF-jOS$81pvlO%clrK_YmYb5o^^0eeF<{d2LTkC z{t$fJ!afSM?)bCGc}MIFaSYN0H%5Z{#>3gtQIQnjf}O1fx2pRfNW5H-{awJu4APbk z8{V2!~Rz$6$?VGF?R5yO~=x+5T6i(ts) eIW)_aDPifS5T03eU>nI0n5 z!e<5X10(0hAb-wV2O$qRC)+nAiNI_RRg8R)$8r}F7%eDYYewkvskCn zjw-QOE`KXlJW1!zt=#c6&}CZiY4Y_it`<+Ejdfw4^#v^99{>x-d8cJVY4R8Q5olPjCRQ7|aVzz$&5QEpxYm1|`b{rIN6u^E7BFRGpU(1^3 zr}1JE_!1&bq#o{a8g@wB$4N*1B#7mJg4Duiw3ONs0ex5mM@mZ$5Xd8Z#sjvc&koXw zBabswp4u7>4J2#O+!D>%kjCxR0V+zayTlG!wHG*79VhT(G`mx1bV2$T#+l1@J{cyqCCMkp z*dpmOORv$ek(9NxA^%wPXqpXH%FnTyXNLA*|{-2@*dp$o?!~ zV Date: Fri, 16 Jun 2023 22:13:54 +0600 Subject: [PATCH 0610/1199] Remove some unnecessary faces --- .../block/matter_replicator_working.json | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/matter_replicator_working.json b/src/main/resources/assets/overdrive_that_matters/models/block/matter_replicator_working.json index d05bfc446..9fe9f3dfd 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/matter_replicator_working.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/matter_replicator_working.json @@ -64,8 +64,7 @@ "north": {"uv": [11, 12, 15.5, 13], "rotation": 180, "texture": "#texture"}, "south": {"uv": [11, 12, 15.5, 13], "texture": "#texture"}, "up": {"uv": [11, 12, 15.5, 13], "texture": "#texture"} - }, - "forge_data": { "block_light": 15, "sky_light": 15 } + } }, { "name": "canister", @@ -108,8 +107,7 @@ "south": {"uv": [11, 12, 15.5, 13], "texture": "#texture"}, "up": {"uv": [11, 12, 15.5, 13], "texture": "#texture"}, "down": {"uv": [0, 0, 6, 1], "texture": "#missing"} - }, - "forge_data": { "block_light": 15, "sky_light": 15 } + } }, { "name": "canister", @@ -153,8 +151,7 @@ "east": {"uv": [0, 15.5, 2.5, 15.75], "rotation": 270, "texture": "#texture"}, "south": {"uv": [0, 15.5, 2.5, 15.75], "rotation": 270, "texture": "#texture"}, "west": {"uv": [0, 15.5, 2.5, 15.75], "rotation": 270, "texture": "#texture"}, - "up": {"uv": [2, 15.5, 2.5, 15.75], "texture": "#texture"}, - "down": {"uv": [0, 0, 0, 1], "texture": "#missing"} + "up": {"uv": [2, 15.5, 2.5, 15.75], "texture": "#texture"} } }, { @@ -162,9 +159,7 @@ "from": [0, 15, 6], "to": [0.5, 16, 15], "faces": { - "north": {"uv": [0, 0, 0, 1], "texture": "#missing"}, "east": {"uv": [0, 15.75, 4.5, 16], "texture": "#texture"}, - "south": {"uv": [0, 0, 0, 1], "texture": "#missing"}, "west": {"uv": [0, 15.75, 4.5, 16], "texture": "#texture"}, "up": {"uv": [0, 15.75, 4.5, 16], "rotation": 90, "texture": "#texture"}, "down": {"uv": [0, 15.75, 4.5, 16], "rotation": 90, "texture": "#texture"} @@ -179,8 +174,7 @@ "east": {"uv": [0, 15.5, 2.5, 15.75], "rotation": 270, "texture": "#texture"}, "south": {"uv": [0, 15.5, 2.5, 15.75], "rotation": 270, "texture": "#texture"}, "west": {"uv": [0, 15.5, 2.5, 15.75], "rotation": 270, "texture": "#texture"}, - "up": {"uv": [2, 15.5, 2.5, 15.75], "texture": "#texture"}, - "down": {"uv": [0, 0, 0, 1], "texture": "#missing"} + "up": {"uv": [2, 15.5, 2.5, 15.75], "texture": "#texture"} } }, { @@ -188,9 +182,7 @@ "from": [15.4, 15, 6], "to": [15.9, 16, 15], "faces": { - "north": {"uv": [0, 0, 0, 1], "texture": "#missing"}, "east": {"uv": [0, 15.75, 4.5, 16], "texture": "#texture"}, - "south": {"uv": [0, 0, 0, 1], "texture": "#missing"}, "west": {"uv": [0, 15.75, 4.5, 16], "texture": "#texture"}, "up": {"uv": [0, 15.75, 4.5, 16], "rotation": 90, "texture": "#texture"}, "down": {"uv": [0, 15.75, 4.5, 16], "rotation": 90, "texture": "#texture"} @@ -288,8 +280,7 @@ "east": {"uv": [10.5, 13, 16, 13.25], "texture": "#texture"}, "south": {"uv": [10.5, 13, 16, 13.25], "texture": "#texture"}, "west": {"uv": [10.5, 13, 16, 13.25], "texture": "#texture"}, - "up": {"uv": [10.5, 13, 16, 15.75], "texture": "#texture"}, - "down": {"uv": [0, 0, 0.5, 0.25], "texture": "#missing"} + "up": {"uv": [10.5, 13, 16, 15.75], "texture": "#texture"} } }, { From 9efad96aff88ff27ca9618e5f107f8536fa74de0 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Fri, 16 Jun 2023 22:20:32 +0600 Subject: [PATCH 0611/1199] Sligthly update machine frame --- .../models/item/machine_frame.json | 34 ++++-------------- .../textures/item/component/machine_frame.png | Bin 262 -> 313 bytes 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/models/item/machine_frame.json b/src/main/resources/assets/overdrive_that_matters/models/item/machine_frame.json index 4f1a2d675..00faf3b8e 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/item/machine_frame.json +++ b/src/main/resources/assets/overdrive_that_matters/models/item/machine_frame.json @@ -1,5 +1,7 @@ { + "credit": "Made with Blockbench", "parent": "block/block", + "texture_size": [32, 16], "textures": { "texture": "overdrive_that_matters:item/component/machine_frame" }, @@ -36,9 +38,7 @@ "to": [14, 2, 2], "faces": { "north": {"uv": [1, 14, 7, 16], "texture": "#texture"}, - "east": {"uv": [0, 0, 2, 2], "texture": "#texture"}, "south": {"uv": [9, 0, 15, 2], "texture": "#texture"}, - "west": {"uv": [0, 0, 2, 2], "texture": "#texture"}, "up": {"uv": [9, 0, 15, 2], "texture": "#texture"}, "down": {"uv": [1, 14, 7, 16], "texture": "#texture"} } @@ -49,9 +49,7 @@ "to": [14, 2, 16], "faces": { "north": {"uv": [9, 0, 15, 2], "texture": "#texture"}, - "east": {"uv": [0, 0, 2, 2], "texture": "#texture"}, "south": {"uv": [1, 14, 7, 16], "texture": "#texture"}, - "west": {"uv": [0, 0, 2, 2], "texture": "#texture"}, "up": {"uv": [9, 0, 15, 2], "texture": "#texture"}, "down": {"uv": [1, 0, 7, 2], "texture": "#texture"} } @@ -62,9 +60,7 @@ "to": [14, 16, 2], "faces": { "north": {"uv": [1, 0, 7, 2], "texture": "#texture"}, - "east": {"uv": [0, 0, 2, 2], "texture": "#texture"}, "south": {"uv": [9, 0, 15, 2], "texture": "#texture"}, - "west": {"uv": [0, 0, 2, 2], "texture": "#texture"}, "up": {"uv": [1, 0, 7, 2], "texture": "#texture"}, "down": {"uv": [9, 0, 15, 2], "texture": "#texture"} } @@ -88,9 +84,7 @@ "to": [14, 16, 16], "faces": { "north": {"uv": [9, 0, 15, 2], "texture": "#texture"}, - "east": {"uv": [0, 0, 2, 2], "texture": "#texture"}, "south": {"uv": [1, 0, 7, 2], "texture": "#texture"}, - "west": {"uv": [0, 0, 2, 2], "texture": "#texture"}, "up": {"uv": [1, 14, 7, 16], "texture": "#texture"}, "down": {"uv": [9, 0, 15, 2], "texture": "#texture"} } @@ -116,9 +110,7 @@ "north": {"uv": [9, 0, 15, 2], "rotation": 90, "texture": "#texture"}, "east": {"uv": [0, 2, 1, 14], "texture": "#texture"}, "south": {"uv": [7, 2, 8, 14], "texture": "#texture"}, - "west": {"uv": [9, 0, 15, 2], "rotation": 90, "texture": "#texture"}, - "up": {"uv": [0, 0, 2, 2], "texture": "#texture"}, - "down": {"uv": [0, 0, 2, 2], "texture": "#texture"} + "west": {"uv": [9, 0, 15, 2], "rotation": 90, "texture": "#texture"} } }, { @@ -129,9 +121,7 @@ "north": {"uv": [9, 0, 15, 2], "rotation": 90, "texture": "#texture"}, "east": {"uv": [9, 0, 15, 2], "rotation": 90, "texture": "#texture"}, "south": {"uv": [0, 2, 1, 14], "texture": "#texture"}, - "west": {"uv": [7, 2, 8, 14], "texture": "#texture"}, - "up": {"uv": [0, 0, 2, 2], "texture": "#texture"}, - "down": {"uv": [0, 0, 2, 2], "texture": "#texture"} + "west": {"uv": [7, 2, 8, 14], "texture": "#texture"} } }, { @@ -142,9 +132,7 @@ "north": {"uv": [0, 2, 1, 14], "texture": "#texture"}, "east": {"uv": [7, 2, 8, 14], "texture": "#texture"}, "south": {"uv": [9, 0, 15, 2], "rotation": 90, "texture": "#texture"}, - "west": {"uv": [9, 0, 15, 2], "rotation": 90, "texture": "#texture"}, - "up": {"uv": [0, 0, 2, 2], "texture": "#texture"}, - "down": {"uv": [0, 0, 2, 2], "texture": "#texture"} + "west": {"uv": [9, 0, 15, 2], "rotation": 90, "texture": "#texture"} } }, { @@ -155,9 +143,7 @@ "north": {"uv": [7, 2, 8, 14], "texture": "#texture"}, "east": {"uv": [9, 0, 15, 2], "rotation": 90, "texture": "#texture"}, "south": {"uv": [9, 0, 15, 2], "rotation": 90, "texture": "#texture"}, - "west": {"uv": [0, 2, 1, 14], "texture": "#texture"}, - "up": {"uv": [0, 0, 2, 2], "texture": "#texture"}, - "down": {"uv": [0, 0, 2, 2], "texture": "#texture"} + "west": {"uv": [0, 2, 1, 14], "texture": "#texture"} } }, { @@ -179,7 +165,6 @@ "to": [13, 13, 15], "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, "faces": { - "north": {"uv": [0, 0, 5, 10], "texture": "#missing"}, "east": {"uv": [6, 3, 6.5, 13], "texture": "#texture"}, "south": {"uv": [1.5, 3, 6.5, 13], "texture": "#texture"}, "west": {"uv": [1.5, 3, 2, 13], "texture": "#texture"}, @@ -195,7 +180,6 @@ "faces": { "north": {"uv": [1.5, 3, 6.5, 13], "texture": "#texture"}, "east": {"uv": [1.5, 3, 2, 13], "texture": "#texture"}, - "south": {"uv": [0, 0, 5, 10], "texture": "#missing"}, "west": {"uv": [6, 3, 6.5, 13], "texture": "#texture"}, "up": {"uv": [1.5, 3, 6.5, 4], "texture": "#texture"}, "down": {"uv": [1.5, 3, 6.5, 4], "texture": "#texture"} @@ -210,7 +194,6 @@ "north": {"uv": [6, 3, 6.5, 13], "texture": "#texture"}, "east": {"uv": [1.5, 3, 6.5, 13], "texture": "#texture"}, "south": {"uv": [1.5, 3, 2, 13], "texture": "#texture"}, - "west": {"uv": [0, 0, 5, 10], "texture": "#missing"}, "up": {"uv": [1.5, 3, 6.5, 4], "rotation": 90, "texture": "#texture"}, "down": {"uv": [1.5, 3, 6.5, 4], "rotation": 270, "texture": "#texture"} } @@ -222,7 +205,6 @@ "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [1.5, 3, 2, 13], "texture": "#texture"}, - "east": {"uv": [0, 0, 5, 10], "texture": "#missing"}, "south": {"uv": [6, 3, 6.5, 13], "texture": "#texture"}, "west": {"uv": [1.5, 3, 6.5, 13], "texture": "#texture"}, "up": {"uv": [1.5, 3, 6.5, 4], "rotation": 270, "texture": "#texture"}, @@ -239,7 +221,6 @@ "east": {"uv": [1.5, 3, 6.5, 4], "rotation": 180, "texture": "#texture"}, "south": {"uv": [1.5, 3, 2, 13], "rotation": 90, "texture": "#texture"}, "west": {"uv": [1.5, 3, 6.5, 4], "texture": "#texture"}, - "up": {"uv": [0, 0, 5, 10], "rotation": 90, "texture": "#missing"}, "down": {"uv": [1.5, 3, 6.5, 13], "rotation": 90, "texture": "#texture"} } }, @@ -253,8 +234,7 @@ "east": {"uv": [1.5, 3, 6.5, 4], "texture": "#texture"}, "south": {"uv": [6, 3, 6.5, 13], "rotation": 90, "texture": "#texture"}, "west": {"uv": [1.5, 3, 6.5, 4], "rotation": 180, "texture": "#texture"}, - "up": {"uv": [1.5, 3, 6.5, 13], "rotation": 90, "texture": "#texture"}, - "down": {"uv": [0, 0, 5, 10], "rotation": 90, "texture": "#missing"} + "up": {"uv": [1.5, 3, 6.5, 13], "rotation": 90, "texture": "#texture"} } } ] diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/component/machine_frame.png b/src/main/resources/assets/overdrive_that_matters/textures/item/component/machine_frame.png index e48cdc1ae0f5329621b1b513ad99b55435cda229..defb0539cb7e202ba2590ac68dd7d201e1152689 100644 GIT binary patch delta 256 zcmZo;+Q~G*v0g5~C&bm%)HJQKCAXw~S z1TyXTWNKizi=if^O-Wt5VWx+|2}kD7Y!Qx(TN2v5)J>ngOEmZNGd*dT?PbOJ;P2vH zTP#$nZk&EJX@`uQ`%(FgpW?O${&~c_<}0(=H137ZwrFqzoyOql>gTe~DWM4fq+V&u delta 205 zcmdnV)W$Tyv0gO5C&bm%)HJuLKOrGOOib+m4Tk>@JQ)}mPIwqh22$)LL4Lvi!GJ-^ zo7oL0#981GSu+9(L`F~=!gXY2ug$plE z^k*<&IuK&Ve!rCa(2Vc|J};TZ%Mx=pY+L6RcH>w5SHXf$o5Q&#Ojq8}9#x?n(sbp6 zOGdUp-L4IG(FZeI92B1<-rRe*F!vJEB!?2_t3m9>!eS0{fOax?y85}Sb4q9e00?1C A Date: Sun, 18 Jun 2023 17:43:23 +0700 Subject: [PATCH 0612/1199] Fix matter manager recipe finder creating item stacks with infinite cost --- .../mc/otm/matter/MatterManager.kt | 108 ++++++++++-------- 1 file changed, 60 insertions(+), 48 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index b8c45fff2..95c511b37 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -546,69 +546,76 @@ object MatterManager { } stream.map { - val width: Int - val height: Int + // avoid reality snap when recipe has no output + val resultItem = it.getResultItem(server.registryAccess()) - if (it is IShapedRecipe<*>) { - width = it.recipeWidth - height = it.recipeHeight + if (resultItem.isEmpty) { + null } else { - width = it.ingredients.size - height = 1 - } + val width: Int + val height: Int - val container = TransientCraftingContainer(object : AbstractContainerMenu(null, 0) { - override fun quickMoveStack(pPlayer: Player, pIndex: Int): ItemStack { - return ItemStack.EMPTY + if (it is IShapedRecipe<*>) { + width = it.recipeWidth + height = it.recipeHeight + } else { + width = it.ingredients.size + height = 1 } - override fun stillValid(pPlayer: Player): Boolean { - return false - } - }, width, height) - - val realIngredients = ArrayList>() - - for (c in it.ingredients.indices) { - if (it.ingredients[c].isActuallyEmpty) { - continue - } - - for ((i, ingredient) in it.ingredients.withIndex()) { - if (i != c) { - container[i] = if (ingredient.isActuallyEmpty) ItemStack.EMPTY else ingredient.items.firstOrNull() ?: ItemStack.EMPTY + val container = TransientCraftingContainer(object : AbstractContainerMenu(null, 0) { + override fun quickMoveStack(pPlayer: Player, pIndex: Int): ItemStack { + return ItemStack.EMPTY } - } - val result = ArrayList() + override fun stillValid(pPlayer: Player): Boolean { + return false + } + }, width, height) - for (item in it.ingredients[c].items) { - container[c] = item + val realIngredients = ArrayList>() - if (!it.assemble(container, server.registryAccess()).isEmpty) { - val residue = it.getRemainingItems(container) + for (c in it.ingredients.indices) { + if (it.ingredients[c].isActuallyEmpty) { + continue + } - val thisResidue = residue[c] - - if (thisResidue.isEmpty) { - result.add(RecipeEntry(item)) - } else { - result.add(RecipeEntry(ImmutableStack(item), ImmutableStack(thisResidue))) + for ((i, ingredient) in it.ingredients.withIndex()) { + if (i != c) { + container[i] = if (ingredient.isActuallyEmpty) ItemStack.EMPTY else ingredient.items.firstOrNull() ?: ItemStack.EMPTY } } + + val result = ArrayList() + + for (item in it.ingredients[c].items) { + container[c] = item + + if (!it.assemble(container, server.registryAccess()).isEmpty) { + val residue = it.getRemainingItems(container) + + val thisResidue = residue[c] + + if (thisResidue.isEmpty) { + result.add(RecipeEntry(item)) + } else { + result.add(RecipeEntry(ImmutableStack(item), ImmutableStack(thisResidue))) + } + } + } + + realIngredients.add(result) } - realIngredients.add(result) + ResolvedRecipe( + realIngredients.stream().map { it.stream() }, + ImmutableStack(resultItem), + isCritical = isCritical, + name = it.id, + allowBacktrack = allowBacktrack + ) } - - ResolvedRecipe( - realIngredients.stream().map { it.stream() }, - ImmutableStack(it.getResultItem(server.registryAccess())), - isCritical = isCritical, - name = it.id, - allowBacktrack = allowBacktrack - ) - }.filter { + }.filterNotNull().filter { if (it.inputs.isEmpty()) { LOGGER.warn("${it.formattedName} with output '${it.output.item.registryName}' ended up with no inputs!") false @@ -1388,6 +1395,11 @@ object MatterManager { val item: Item, val multiplier: Double = 1.0 ) { + init { + require(!multiplier.isNaN()) { "Provided stack cost multiplier is NaN" } + require(!multiplier.isInfinite()) { "Provided stack cost multiplier is infinite" } + } + constructor(item: Item, count: Int) : this(item, 1.0 / count.toDouble()) constructor(item: ItemStack) : this(item.item, item.count) } From 48ee669458076392e5bfc990856020aa7b05b9c1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 18 Jun 2023 17:45:48 +0700 Subject: [PATCH 0613/1199] New Decimal class, with fixed point and compile-time precision --- .../mc/otm/compat/mekanism/Conversions.kt | 10 +- .../dbotthepony/mc/otm/core/math/Decimal.kt | 840 ++++++++---------- .../ru/dbotthepony/mc/otm/core/math/Math.kt | 42 +- .../dbotthepony/mc/otm/tests/DecimalTests.kt | 131 ++- 4 files changed, 521 insertions(+), 502 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Conversions.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Conversions.kt index fbf931c09..ac8219067 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Conversions.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Conversions.kt @@ -4,7 +4,7 @@ import mekanism.api.math.FloatingLong import ru.dbotthepony.mc.otm.core.math.Decimal import java.math.BigInteger -private val LONG_OVERFLOW = BigInteger.valueOf(Long.MAX_VALUE) + BigInteger.valueOf(Long.MAX_VALUE) + BigInteger.TWO +private val LONG_OVERFLOW = (BigInteger.valueOf(Long.MAX_VALUE) + BigInteger.valueOf(Long.MAX_VALUE) + BigInteger.TWO) * Decimal.PRECISION_POW_BI private val LONG_OVERFLOW1 = BigInteger.valueOf(Long.MAX_VALUE) + BigInteger.valueOf(Long.MAX_VALUE) + BigInteger.ONE fun Decimal.toFloatingLong(): FloatingLong { @@ -17,14 +17,16 @@ fun Decimal.toFloatingLong(): FloatingLong { return FloatingLong.MAX_VALUE } - return FloatingLong.create(whole.toLong(), (decimal * 10_000.0).toInt().toShort()) + return FloatingLong.create(whole.toLong(), (fractionalFloat * 10_000.0).toInt().toShort()) } fun FloatingLong.toDecimal(): Decimal { + var conv = BigInteger.valueOf(value) * Decimal.PRECISION_POW_BI + BigInteger.valueOf((decimal.toDouble() / 10_000.0 * Decimal.PRECISION_DOUBLE).toLong()) + // Overflow if (value < 0L) { - return Decimal(LONG_OVERFLOW + BigInteger.valueOf(value), decimal / 10_000.0) + conv += LONG_OVERFLOW } - return Decimal(value, decimal / 10_000.0) + return Decimal.raw(conv) } 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 a200f1ff9..835c637c0 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 @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.core.math +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap import net.minecraft.nbt.ByteArrayTag import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.NbtAccounter @@ -9,133 +10,17 @@ import net.minecraft.network.FriendlyByteBuf import net.minecraft.util.RandomSource import net.minecraftforge.common.ForgeConfigSpec import ru.dbotthepony.mc.otm.config.ObservedConfigValue -import ru.dbotthepony.mc.otm.core.util.readDouble import ru.dbotthepony.mc.otm.core.util.readVarIntLE -import ru.dbotthepony.mc.otm.core.util.writeDouble import ru.dbotthepony.mc.otm.core.util.writeVarIntLE import java.io.InputStream import java.io.OutputStream import java.math.BigDecimal import java.math.BigInteger import java.math.MathContext -import kotlin.math.absoluteValue - -//private fun isZero(value: BigInteger) = value == BigInteger.ZERO -private fun isZero(value: BigInteger) = value.signum() == 0 - -private fun unsignedInt(value: Byte): Int { - return value.toInt() and 0xFF -} - -private fun usignedLong(value: Byte): Long { - return value.toLong() and 0xFFL -} - -private fun longToBytesBE(value: Long): ByteArray { - return byteArrayOf( - (value ushr 56).toByte(), - (value ushr 48).toByte(), - (value ushr 40).toByte(), - (value ushr 32).toByte(), - (value ushr 24).toByte(), - (value ushr 16).toByte(), - (value ushr 8).toByte(), - (value).toByte(), - ) -} - -private fun bytesToLongBE(value: ByteArray, from: Int = 0): Long { - return ( - (usignedLong(value[from + 7])) or - (usignedLong(value[from + 6]) shl 8) or - (usignedLong(value[from + 5]) shl 16) or - (usignedLong(value[from + 4]) shl 24) or - (usignedLong(value[from + 3]) shl 32) or - (usignedLong(value[from + 2]) shl 40) or - (usignedLong(value[from + 1]) shl 48) or - (usignedLong(value[from]) shl 56) - ) -} - -private fun bytesToLongBE( - value7: Byte, - value6: Byte, - value5: Byte, - value4: Byte, - value3: Byte, - value2: Byte, - value1: Byte, - value0: Byte, -): Long { - return ( - (usignedLong(value0)) or - (usignedLong(value1) shl 8) or - (usignedLong(value2) shl 16) or - (usignedLong(value3) shl 24) or - (usignedLong(value4) shl 32) or - (usignedLong(value5) shl 40) or - (usignedLong(value6) shl 48) or - (usignedLong(value7) shl 56) - ) -} - -/** - * Constant value which represent edge of meaningful bits. - * - * Equals to 0.000000000001 - */ -const val EPSILON = 0.000000000001 - -private val zeroes = Array(16) { "0".repeat(it).intern() } -private val nums = Array(10) { it.toString()[0] } - -private fun decimals(input: Double, places: Int): String { - if (weakEqualDoubles(input, 0.0)) { - return zeroes.elementAtOrElse(places) { "0".repeat(places) } - } - - val buffer = CharArray(places) - - @Suppress("NAME_SHADOWING") - var input = input.absoluteValue - - for (i in 0 until places) { - input *= 10.0 - buffer[i] = nums[(input % 10.0).toInt()] - } - - return String(buffer) -} - -fun weakEqualDoubles(a: Double, b: Double): Boolean { - if (a == b) - return true - - return (a - b).absoluteValue <= EPSILON -} - -fun weakCompareDoubles(a: Double, b: Double): Int { - if (weakEqualDoubles(a, b)) - return 0 - - if (a > b) - return 1 - - return -1 -} - -fun weakLessThan(a: Double, b: Double) = weakCompareDoubles(a, b) < 0 -fun weakGreaterThan(a: Double, b: Double) = weakCompareDoubles(a, b) > 0 -fun weakLessOrEqual(a: Double, b: Double) = weakCompareDoubles(a, b) <= 0 -fun weakGreaterOrEqual(a: Double, b: Double) = weakCompareDoubles(a, b) >= 0 - -private val PERCENTAGE_CONTEXT = MathContext(6) - -private const val MEANINGFUL_BITS_LONG = 1000000000000000000L -private const val MEANINGFUL_BITS_DOUBLE = MEANINGFUL_BITS_LONG.toDouble() -private val MEANINGFUL_BITS_BI = BigInteger.valueOf(MEANINGFUL_BITS_LONG) +import java.math.RoundingMode private val BI_MINUS_ONE = -BigInteger.ONE +private val PERCENTAGE_CONTEXT = MathContext(6) // 6 ибо это число знаков для вычисления процента fun Decimal(value: Byte) = Decimal.valueOf(value) fun Decimal(value: Short) = Decimal.valueOf(value) @@ -143,198 +28,160 @@ fun Decimal(value: Int) = Decimal.valueOf(value) fun Decimal(value: Long) = Decimal.valueOf(value) /** - * Decimal class for having infinitely precise [whole] part, while having fixed precision [decimal] part. - * - * In essence, this class is pretty much like [BigDecimal], except decimal part of this number is - * not guaranteed to be precise (stored as [Double]). The reason behind creation of this class, however, - * is to allow infinite precision of [whole] part, while leaving [decimal] part to be rounded in inexact operations. - * - * This class is value based, hence it is immutable, and can not be utilized as synchronization lock, and should not be compared - * using identity (`===`) comparison. - * - * **In general, this class is lenient about precision**, to avoid gameplay-wise player frustration, rounding is placed in multiple parts of this class, - * including its constructor (e.g. it is possible to get `Decimal.ZERO == Decimal("0.00000001")`). [EPSILON] is the reference point of precision, - * any value lesser than [EPSILON] is considered zero (including difference between *the value* and (-)1.0). + * Fixed point arbitrary precision Decimal value. Values of this class embed [BigInteger] unscaled value, scale + * is defined at compile time by [PRECISION]. */ -@Suppress("unused") -class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0) : Number(), Comparable, java.io.Serializable { - constructor(whole: Byte, decimal: Double) : this(BigInteger.valueOf(whole.toLong()), decimal) - constructor(whole: Short, decimal: Double) : this(BigInteger.valueOf(whole.toLong()), decimal) - constructor(whole: Int, decimal: Double) : this(BigInteger.valueOf(whole.toLong()), decimal) - constructor(whole: Long, decimal: Double) : this(BigInteger.valueOf(whole), decimal) - constructor(value: BigDecimal) : this(value.toBigInteger(), value.remainder(BigDecimal.ONE).toDouble()) // TODO - constructor(value: Float) : this(BigInteger.valueOf((value - value % 1.0).toLong()), value % 1.0) - constructor(value: Double) : this(BigInteger.valueOf((value - value % 1.0).toLong()), value % 1.0) +class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Number(), Comparable { + constructor(value: BigInteger) : this(value * PRECISION_POW_BI, null) + constructor(value: BigDecimal) : this(value.setScale(PRECISION, RoundingMode.HALF_UP).unscaledValue(), null) + constructor(value: Float) : this(BigDecimal.valueOf(value.toDouble())) + constructor(value: Double) : this(BigDecimal(value)) constructor(value: String) : this(BigDecimal(value)) - /** - * Inexact fractional part of this fraction - */ - val decimal: Double + private var _whole: BigInteger? = null + private var _fractional: BigInteger? = null + + private fun computeWholeFractional(): BigInteger { + val (a, b) = mag.divideAndRemainder(PRECISION_POW_BI) + _whole = a + _fractional = b + return a + } /** - * Exact whole part of this fraction + * Whole part of this Decimal */ - val whole: BigInteger + val whole: BigInteger get() { + return _whole ?: computeWholeFractional() + } - init { - @Suppress("name_shadowing") - var decimal = decimal + /** + * Arbitrary fractional part of this Decimal, as [BigInteger] + * + * Makes sense only when utilized along [PRECISION], [PRECISION_POW], [PRECISION_POW_BI] + */ + val fractional: BigInteger get() { + if (_fractional == null) computeWholeFractional() + return _fractional!! + } - if (decimal < 1.0 && decimal + EPSILON >= 1.0) { - // разница между дробью и 1 крайне мала - decimal = 1.0 - } else if (decimal > -1.0 && decimal - EPSILON <= -1.0) { - // разница между дробью и -1 крайне мала - decimal = -1.0 - } + /** + * *Signed* normalized (-1,1) fractional part of this Decimal, as [Float] + */ + inline val fractionalFloat: Float get() { + return fractional.toFloat() / PRECISION_FLOAT + } - @Suppress("name_shadowing") - var whole = whole + /** + * *Signed* normalized (-1,1) fractional part of this Decimal, as [Double] + */ + inline val fractionalDouble: Double get() { + return fractional.toDouble() / PRECISION_DOUBLE + } - // нормализуем - if (decimal <= -1f || decimal >= 1f) { - val frac = decimal % 1f - whole += BigInteger.valueOf((decimal - frac).toLong()) - decimal = frac - } + override fun compareTo(other: Decimal): Int { + return mag.compareTo(other.mag) + } - // дробная часть равна или очень близка к нулю - if (weakEqualDoubles(decimal, 0.0)) { - this.decimal = 0.0 - this.whole = whole - // целая часть и дробная часть имеют одинаковые знаки - } else if (decimal > 0.0 && whole.signum() >= 0 || decimal < 0.0 && whole.signum() <= 0) { - this.decimal = decimal - this.whole = whole + override fun toByte(): Byte { + return whole.toByte() + } + + override fun toChar(): Char { + return whole.toChar() + } + + override fun toDouble(): Double { + return mag.toDouble() / PRECISION_DOUBLE + } + + override fun toFloat(): Float { + return mag.toFloat() / PRECISION_FLOAT + } + + override fun toInt(): Int { + if (whole > BI_INT_MAX) { + return Int.MAX_VALUE + } else if (whole < BI_INT_MIN) { + return Int.MIN_VALUE } else { - // целая часть и дробная часть имеют разные знаки - - if (decimal > 0.0) { - this.decimal = decimal - 1f - this.whole = whole + BigInteger.ONE - //} else if (double < 0.0 && whole.signum() > 0) { - } else { - this.decimal = decimal + 1f - this.whole = whole - BigInteger.ONE - } - - //throw InternalError("This should never happen, but it happened. Input was: $whole $double") + return whole.toInt() } } - val isNaN get() = decimal.isNaN() + override fun toLong(): Long { + if (whole > BI_LONG_MAX) { + return Long.MAX_VALUE + } else if (whole < BI_LONG_MIN) { + return Long.MIN_VALUE + } else { + return whole.toLong() + } + } - operator fun plus(other: Decimal) = Decimal(whole + other.whole, decimal + other.decimal) - operator fun minus(other: Decimal) = Decimal(whole - other.whole, decimal - other.decimal) + override fun toShort(): Short { + return whole.toShort() + } - operator fun times(other: Decimal): Decimal { - if (other == ONE) + operator fun plus(other: Decimal): Decimal { + if (other.mag.signum() == 0) { return this - else if (other == MINUS_ONE) - return -this - - val a = whole - val c = other.whole - - val bZero = weakEqualDoubles(decimal, 0.0) - val dZero = weakEqualDoubles(other.decimal, 0.0) - - if (bZero && dZero) { - if (isZero(a) || isZero(c)) - return ZERO - - return Decimal(a * c) - } else if (isZero(a) && isZero(c)) { - if (bZero || dZero) - return ZERO - - return Decimal(0, decimal * other.decimal) - } else if (bZero) { - val d = other.decimal * MEANINGFUL_BITS_DOUBLE - val dL = d.toLong() - val adInflated = a * BigInteger.valueOf(dL) - val ad = adInflated.divideAndRemainder(MEANINGFUL_BITS_BI) - - if (isZero(c)) { - return Decimal( - ad[0], - ad[1].toDouble() / MEANINGFUL_BITS_DOUBLE - ) - } - - return Decimal( - a * c + ad[0], - ad[1].toDouble() / MEANINGFUL_BITS_DOUBLE - ) - } else if (dZero) { - val b = decimal * MEANINGFUL_BITS_DOUBLE - val bL = b.toLong() - val bcInflated = c * BigInteger.valueOf(bL) - val bc = bcInflated.divideAndRemainder(MEANINGFUL_BITS_BI) - - if (isZero(a)) { - return Decimal( - bc[0], - bc[1].toDouble() / MEANINGFUL_BITS_DOUBLE - ) - } - - return Decimal( - a * c + bc[0], - bc[1].toDouble() / MEANINGFUL_BITS_DOUBLE - ) } - val b = decimal * MEANINGFUL_BITS_DOUBLE - val d = other.decimal * MEANINGFUL_BITS_DOUBLE + return Decimal(mag + other.mag, null).interned() + } - val bL = b.toLong() - val dL = d.toLong() + operator fun minus(other: Decimal): Decimal { + if (other.mag.signum() == 0) { + return this + } - val bcInflated = c * BigInteger.valueOf(bL) - val adInflated = a * BigInteger.valueOf(dL) + return Decimal(mag - other.mag, null).interned() + } - val bc = bcInflated.divideAndRemainder(MEANINGFUL_BITS_BI) - val ad = adInflated.divideAndRemainder(MEANINGFUL_BITS_BI) + operator fun times(other: Decimal): Decimal { + if (other.mag.signum() == 0) { + return ZERO + } else if (other.mag == BigInteger.ONE) { + return this + } else if (other.mag == BI_MINUS_ONE) { + return Decimal(-mag, null).interned() + } - return Decimal( - a * c + bc[0] + ad[0], - decimal * other.decimal + bc[1].toDouble() / MEANINGFUL_BITS_DOUBLE + ad[1].toDouble() / MEANINGFUL_BITS_DOUBLE - ) + val result = mag * other.mag + val (a, b) = result.divideAndRemainder(PRECISION_POW_BI) + + if (b >= PRECISION_POW_BI_HIGH) { + return Decimal(a + BigInteger.ONE, null).interned() + } else { + return Decimal(a, null).interned() + } } operator fun div(other: Decimal): Decimal { - if (other == ONE) + if (other.mag.signum() == 0) { + throw ArithmeticException("Attempt to divide $this by zero") + } else if (other.mag == BigInteger.ONE) { return this - else if (other == MINUS_ONE) - return -this - - if (isZero && other.isZero) - return NaN - - if (!isZero && other.isZero) - throw ArithmeticException("Divide by zero") - - //if (isZero(whole) && isZero(other.whole)) - // return ImpreciseFraction(BigInteger.ZERO, decimal / other.decimal) - - val a = toBigDecmial() - val b = other.toBigDecmial() - val div = a.divideAndRemainder(b, MathContext(a.precision() + b.precision())) - - val bD = b.toDouble() - - if (bD.isInfinite() || bD == 0.0) { - return Decimal(div[0].toBigInteger()) + } else if (other.mag == BI_MINUS_ONE) { + return Decimal(-mag, null).interned() } - return Decimal(div[0].toBigInteger(), div[1].toDouble() / bD) + return Decimal((mag * PRECISION_POW_BI) / other.mag, null).interned() } + operator fun rem(other: Decimal): Decimal { + return Decimal(mag % other.mag, null) + } + + // Primitive operators operator fun plus(other: Float): Decimal { if (other == 0f) { return this + } else if (other.isNaN()) { + throw ArithmeticException("Attempt to add NaN to $this") + } else if (other.isInfinite()) { + throw ArithmeticException("Attempt to add infinity to $this") } return plus(Decimal(other)) @@ -343,6 +190,10 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 operator fun minus(other: Float): Decimal { if (other == 0f) { return this + } else if (other.isNaN()) { + throw ArithmeticException("Attempt to subtract NaN from $this") + } else if (other.isInfinite()) { + throw ArithmeticException("Attempt to subtract infinity from $this") } return minus(Decimal(other)) @@ -355,6 +206,10 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 return ZERO } else if (other == -1f) { return -this + } else if (other.isNaN()) { + throw ArithmeticException("Attempt to multiply $this by NaN") + } else if (other.isInfinite()) { + throw ArithmeticException("Attempt to multiply $this by infinity") } return times(Decimal(other)) @@ -362,14 +217,15 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 operator fun div(other: Float): Decimal { if (other == 0f) { - if (isZero) - return NaN - else - throw ArithmeticException("Divide by zero") + throw ArithmeticException("Attempt to divide $this by zero") } else if (other == 1f) { return this } else if (other == -1f) { return -this + } else if (other.isNaN()) { + throw ArithmeticException("Attempt to divide $this by NaN") + } else if (other.isInfinite()) { + throw ArithmeticException("Attempt to divide $this by infinity") } return div(Decimal(other)) @@ -378,6 +234,10 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 operator fun plus(other: Double): Decimal { if (other == 0.0) { return this + } else if (other.isNaN()) { + throw ArithmeticException("Attempt to add NaN to $this") + } else if (other.isInfinite()) { + throw ArithmeticException("Attempt to add infinity to $this") } return plus(Decimal(other)) @@ -386,6 +246,10 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 operator fun minus(other: Double): Decimal { if (other == 0.0) { return this + } else if (other.isNaN()) { + throw ArithmeticException("Attempt to subtract NaN from $this") + } else if (other.isInfinite()) { + throw ArithmeticException("Attempt to subtract infinity from $this") } return minus(Decimal(other)) @@ -398,6 +262,10 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 return ZERO } else if (other == -1.0) { return -this + } else if (other.isNaN()) { + throw ArithmeticException("Attempt to multiply $this by NaN") + } else if (other.isInfinite()) { + throw ArithmeticException("Attempt to multiply $this by infinity") } return times(Decimal(other)) @@ -405,14 +273,15 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 operator fun div(other: Double): Decimal { if (other == 0.0) { - if (isZero) - return NaN - else - throw ArithmeticException("Divide by zero") + throw ArithmeticException("Attempt to divide $this by zero") } else if (other == 1.0) { return this } else if (other == -1.0) { return -this + } else if (other.isNaN()) { + throw ArithmeticException("Attempt to divide $this by NaN") + } else if (other.isInfinite()) { + throw ArithmeticException("Attempt to divide $this by infinity") } return div(Decimal(other)) @@ -448,10 +317,7 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 operator fun div(other: Int): Decimal { if (other == 0) { - if (isZero) - return NaN - else - throw ArithmeticException("Divide by zero") + throw ArithmeticException("Attempt to divide $this by zero") } else if (other == 1) { return this } else if (other == -1) { @@ -491,10 +357,7 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 operator fun div(other: Long): Decimal { if (other == 0L) { - if (isZero) - return NaN - else - throw ArithmeticException("Divide by zero") + throw ArithmeticException("Attempt to divide $this by zero") } else if (other == 1L) { return this } else if (other == -1L) { @@ -523,7 +386,7 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 operator fun times(other: BigInteger): Decimal { if (other == BigInteger.ONE) { return this - } else if (other == BigInteger.ZERO) { + } else if (other.signum() == 0) { return ZERO } else if (other == BI_MINUS_ONE) { return -this @@ -534,7 +397,7 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 operator fun div(other: BigInteger): Decimal { if (other == BigInteger.ZERO) { - return NaN + throw ArithmeticException("Attempt to divide $this by zero") } else if (other == BigInteger.ONE) { return this } else if (other == BI_MINUS_ONE) { @@ -543,9 +406,70 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 return div(Decimal(other)) } + // /Primitive operators operator fun unaryMinus(): Decimal { - return Decimal(-whole, -decimal) + if (mag == BigInteger.ZERO) { + return this + } + + return Decimal(-mag, null).interned() + } + + operator fun unaryPlus() = this + + /** + * Sign number of this Decimal, as defined by [BigInteger.signum] + */ + fun signum() = mag.signum() + + /** + * Whenever this Decimal is negative (less than zero) + */ + inline val isNegative get() = signum() < 0 + + /** + * Whenever this Decimal is positive (bigger than zero) + */ + inline val isPositive get() = signum() > 0 + + /** + * Whenever this Decimal is zero + */ + inline val isZero get() = signum() == 0 + + /** + * Alias for [coerceAtLeast] with [ZERO] constant, except this method might + * perform faster. + */ + fun moreThanZero(): Decimal { + if (signum() >= 0) + return this + + return ZERO + } + + /** + * Alias for [coerceAtMost] with [ZERO] constant, except this method might + * perform faster. + */ + fun lessOrZero(): Decimal { + if (signum() <= 0) + return this + + return ZERO + } + + fun toByteArray(): ByteArray { + return mag.toByteArray() + } + + fun serializeNBT(): Tag { + return ByteArrayTag(toByteArray()) + } + + fun write(buff: FriendlyByteBuf) { + buff.writeByteArray(toByteArray()) } val absoluteValue: Decimal @@ -557,156 +481,93 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 } } - override fun equals(other: Any?): Boolean { - if (isNaN) return false - return other === this || other is Decimal && other.whole == whole && weakEqualDoubles(decimal, other.decimal) - } - - override fun hashCode(): Int { - if (isNaN) - return Double.NaN.hashCode() - - return 31 * decimal.hashCode() + whole.hashCode() - } - + /** + * Truncates fractional part of this Decimal + */ fun floor(): Decimal { - if (decimal == 0.0) - return this - return Decimal(whole) } - fun toString(decimals: Int): String { - if (isNaN) - return "NaN" + override fun equals(other: Any?): Boolean { + return this === other || other is Decimal && mag == other.mag + } + override fun hashCode(): Int { + return mag.hashCode() + } + + fun toString(decimals: Int): String { if (decimals == 0) { return whole.toString() - } else if (decimals > 0) { - return "$whole.${decimals(decimal, decimals)}" } - return when (signum()) { - 1, -1 -> "$whole.${decimals(decimal, 11)}" - 0 -> "0.0" - else -> throw IllegalArgumentException("invalid signum") + if (mag.signum() == 0) { + if (decimals < 0) { + return "0.0" + } else { + return "0." + "0".repeat(decimals) + } + } + + var original = mag.toString() + + if (mag.signum() < 0) { + // если у нас отрицательное число - убираем знак минуса + original = original.substring(1) + } + + if (original.length <= PRECISION) { + // если у нас чисто дробное число - дописываем нули в начало + original = "0".repeat(PRECISION - original.length + 1) + original + } + + // теперь у нас беззнаковая строка с нужной длиной + + if (decimals < 0) { + // нам неважно количество знаков после запятой + var result = original.substring(0, original.length - PRECISION) + "." + original.substring(original.length - PRECISION) + + if (mag.signum() < 0) { + result = "-$result" + } + + var pos = result.length - 1 + + while (result[pos] == '0') { + if (result[pos - 1] == '0' || result[pos - 1] != '.') + pos-- + else + break + } + + return result.substring(0, pos + 1) + } else { + // нужно некоторое количество знаков после запятой + val result = original.substring(0, original.length - PRECISION) + "." + var decimalPart = original.substring(original.length - PRECISION) + + if (decimalPart.length < decimals) { + decimalPart += "0".repeat(decimals - decimalPart.length) + } else if (decimalPart.length > decimals) { + decimalPart = decimalPart.substring(0, decimals) + } + + if (mag.signum() < 0) { + return "-$result$decimalPart" + } else { + return "$result$decimalPart" + } } } - override fun toString() = toString(-1) + override fun toString(): String = toString(-1) fun toBigDecmial(): BigDecimal { - return BigDecimal(whole) + BigDecimal(decimal) - } - - private var _signum = Int.MIN_VALUE - - fun signum(): Int { - if (_signum == Int.MIN_VALUE) { - var cmp = whole.signum() - if (cmp == 0) cmp = if (decimal == 0.0) 0 else if (1.0 / decimal > 0.0) 1 else -1 - _signum = cmp - } - - return _signum - } - - override fun compareTo(other: Decimal): Int { - if (isNaN) - return 1 - else if (other.isNaN) - return -1 - - val a = signum() - val b = other.signum() - - if (a < b) - return -1 - else if (a > b) - return 1 - - var cmp = whole.compareTo(other.whole) - if (cmp == 0) cmp = weakCompareDoubles(decimal, other.decimal) - - return cmp - } - - fun toByteArray(): ByteArray { - val whole = whole.toByteArray() - return byteArrayOf(whole.size.toByte(), *whole, *longToBytesBE(decimal.toBits())) - } - - fun serializeNBT(): Tag { - return ByteArrayTag(toByteArray()) - } - - val isZero get() = weakEqualDoubles(decimal, 0.0) && isZero(whole) - val isPositive get() = this > ZERO - val isNegative get() = this < ZERO - - fun moreThanZero(): Decimal { - if (signum() >= 0) - return this - - return ZERO - } - - fun lessOrZero(): Decimal { - if (signum() <= 0) - return this - - return ZERO - } - - override fun toInt(): Int { - if (whole > BI_INT_MAX) { - return Int.MAX_VALUE - } else if (whole < BI_INT_MIN) { - return Int.MIN_VALUE - } - - return whole.toInt() - } - - fun write(buff: FriendlyByteBuf) { - val whole = whole.toByteArray() - buff.writeByteArray(whole) - buff.writeDouble(decimal) - } - - override fun toFloat(): Float { - return whole.toFloat() + decimal.toFloat() - } - - override fun toDouble(): Double { - return whole.toDouble() + decimal - } - - override fun toByte(): Byte { - return toInt().toByte() - } - - override fun toChar(): Char { - return toInt().toChar() - } - - override fun toLong(): Long { - if (whole > BI_LONG_MAX) { - return Long.MAX_VALUE - } else if (whole < BI_LONG_MIN) { - return Long.MIN_VALUE - } - - return whole.toLong() - } - - override fun toShort(): Short { - return toInt().toShort() + return BigDecimal(mag, PRECISION) } fun percentage(divisor: Decimal, zeroing: Boolean = true): Float { if ((isZero || divisor.isZero) && zeroing) return 0f - if (isNaN || divisor.isNaN || divisor.isZero) return Float.NaN if (this >= divisor) return 1f @@ -717,88 +578,100 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 return toBigDecmial().divide(divisor.toBigDecmial(), PERCENTAGE_CONTEXT).toFloat() } - operator fun rem(divisor: Decimal): Decimal { - TODO("Not yet implemented") + private fun interned(): Decimal { + return pool[this] ?: this } + @Suppress("unused") companion object { - @JvmStatic - val serialVersionUID: Long = 287354739494574838L + /** + * Amount of digits after fixed point, in 10 radix + */ + const val PRECISION = 11 - @JvmField val MINUS_ZERO = Decimal(0, -0.0) - @JvmField val ZERO = Decimal(BigInteger.ZERO) - @JvmField val ONE = Decimal(BigInteger.ONE) - @JvmField val MINUS_ONE = Decimal(-BigInteger.ONE) - @JvmField val TWO = Decimal(BigInteger.TWO) - @JvmField val TEN = Decimal(BigInteger.TEN) - - @JvmField val INT_MAX_VALUE = Decimal(BI_INT_MAX) - @JvmField val INT_MIN_VALUE = Decimal(BI_INT_MIN) - @JvmField val LONG_MAX_VALUE = Decimal(BI_LONG_MAX) - @JvmField val LONG_MIN_VALUE = Decimal(BI_LONG_MIN) - - @JvmField val FLOAT_MAX_VALUE = Decimal(BI_FLOAT_MAX) - @JvmField val FLOAT_MIN_VALUE = Decimal(BI_FLOAT_MIN) - @JvmField val DOUBLE_MAX_VALUE = Decimal(BI_DOUBLE_MAX) - @JvmField val DOUBLE_MIN_VALUE = Decimal(BI_DOUBLE_MIN) - - @JvmField val ONE_TENTH = Decimal("0.1") - - private val cache = Array(2048) { Decimal(it - 1024, 0.0) } + /** + * 10 in power of [PRECISION] (10^[PRECISION]), as [Long] + */ + @JvmField + val PRECISION_POW: Long init { - cache[1024] = ZERO - cache[1025] = ONE - cache[1023] = MINUS_ONE - cache[1026] = TWO - cache[1034] = TEN + var i = 10L + for (u in 1 until PRECISION) i *= 10L + PRECISION_POW = i + } + + @JvmField + val PRECISION_DOUBLE = PRECISION_POW.toDouble() + @JvmField + val PRECISION_FLOAT = PRECISION_POW.toFloat() + @JvmField + val PRECISION_INT = PRECISION_POW.toInt() + + @JvmField + val PRECISION_POW_BI: BigInteger = BigInteger.valueOf(PRECISION_POW) + @JvmField + val PRECISION_POW_BI_NEGATIVE: BigInteger = -PRECISION_POW_BI + @JvmField + val PRECISION_POW_BI_HIGH: BigInteger = BigInteger.valueOf(PRECISION_POW / 2) + + private val cache = Array(2048) { Decimal(BigInteger.valueOf(it.toLong() - 1024)) } + private val pool = Object2ObjectOpenHashMap() + + init { + for (value in cache) { + pool[value] = value + } } /** * Returns pooled value if present, otherwise constructs new object */ + @JvmStatic fun valueOf(value: Int): Decimal { if (value in -1024 .. 1023) { return cache[value + 1024] } - return Decimal(value, 0.0) + return Decimal(BigInteger.valueOf(value.toLong())) } /** * Returns pooled value if present, otherwise constructs new object */ + @JvmStatic fun valueOf(value: Long): Decimal { if (value in -1024L .. 1023L) { return cache[value.toInt() + 1024] } - return Decimal(value, 0.0) + return Decimal(BigInteger.valueOf(value)) } /** * Returns pooled value if present, otherwise constructs new object */ + @JvmStatic fun valueOf(value: Short) = valueOf(value.toInt()) /** * Returns pooled value if present, otherwise constructs new object */ + @JvmStatic fun valueOf(value: Byte) = valueOf(value.toInt()) - @JvmField - val NaN = Decimal(0, Double.NaN) + @JvmStatic fun valueOf(value: BigInteger) = Decimal(value).interned() + @JvmStatic fun valueOf(value: BigDecimal) = Decimal(value).interned() + @JvmStatic fun valueOf(value: String) = Decimal(value).interned() + @JvmStatic fun valueOf(value: Float) = Decimal(value).interned() + @JvmStatic fun valueOf(value: Double) = Decimal(value).interned() @JvmStatic fun fromByteArray(input: ByteArray): Decimal { - val size = unsignedInt(input[0]) - - if (size > 0) { - val slice = input.copyOfRange(1, 1 + size) - val bits = bytesToLongBE(input, 1 + size) - return Decimal(BigInteger(slice), Double.fromBits(bits)) + if (input.isEmpty()) { + return ZERO } else { - return Decimal(BigInteger.ZERO, Double.fromBits(bytesToLongBE(input, 1))) + return Decimal(BigInteger(input), null) } } @@ -815,8 +688,34 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 @JvmStatic fun read(buff: FriendlyByteBuf): Decimal { - return Decimal(BigInteger(buff.readByteArray()), buff.readDouble()) + return Decimal(BigInteger(buff.readByteArray())) } + + /** + * Takes in [value] as-is and constructs [Decimal] out of it ([value] is treated as already scaled by [PRECISION]) + */ + @JvmStatic + fun raw(value: BigInteger): Decimal = Decimal(value, null) + + @JvmField val ZERO = valueOf(0) + @JvmField val ONE = valueOf(1) + @JvmField val TWO = valueOf(2) + @JvmField val TEN = valueOf(10) + @JvmField val MINUS_ONE = valueOf(-1) + @JvmField val MINUS_TWO = valueOf(-2) + @JvmField val MINUS_TEN = valueOf(-10) + @JvmField val ONE_TENTH = valueOf("0.1") + @JvmField val MINUS_ONE_TENTH = valueOf("-0.1") + + @JvmField val INT_MAX_VALUE = Decimal(BI_INT_MAX) + @JvmField val INT_MIN_VALUE = Decimal(BI_INT_MIN) + @JvmField val LONG_MAX_VALUE = Decimal(BI_LONG_MAX) + @JvmField val LONG_MIN_VALUE = Decimal(BI_LONG_MIN) + + @JvmField val FLOAT_MAX_VALUE = Decimal(BI_FLOAT_MAX) + @JvmField val FLOAT_MIN_VALUE = Decimal(BI_FLOAT_MIN) + @JvmField val DOUBLE_MAX_VALUE = Decimal(BI_DOUBLE_MAX) + @JvmField val DOUBLE_MIN_VALUE = Decimal(BI_DOUBLE_MIN) } } @@ -826,17 +725,16 @@ fun FriendlyByteBuf.writeDecimal(value: Decimal) = value.write(this) fun InputStream.readDecimal(sizeLimit: NbtAccounter = NbtAccounter(512L)): Decimal { val size = readVarIntLE(sizeLimit) require(size >= 0) { "Negative payload size: $size" } - sizeLimit.accountBytes(size.toLong() + 8L) + sizeLimit.accountBytes(size.toLong()) val bytes = ByteArray(size) read(bytes) - return Decimal(BigInteger(bytes), readDouble()) + return Decimal.fromByteArray(bytes) } fun OutputStream.writeDecimal(value: Decimal) { - val bytes = value.whole.toByteArray() + val bytes = value.toByteArray() writeVarIntLE(bytes.size) write(bytes) - writeDouble(value.decimal) } fun CompoundTag.getDecimal(key: String) = Decimal.deserializeNBT(this[key]) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Math.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Math.kt index 248380d83..21ddabcfc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Math.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Math.kt @@ -2,14 +2,15 @@ package ru.dbotthepony.mc.otm.core.math import java.math.BigDecimal import java.math.BigInteger +import kotlin.math.absoluteValue -inline val BigInteger.isZero get() = this == BigInteger.ZERO -inline val BigInteger.isPositive get() = this > BigInteger.ZERO -inline val BigInteger.isNegative get() = this < BigInteger.ZERO +inline val BigInteger.isZero get() = this.signum() == 0 +inline val BigInteger.isPositive get() = this.signum() > 0 +inline val BigInteger.isNegative get() = this.signum() < 0 -inline val BigDecimal.isZero get() = this == BigDecimal.ZERO -inline val BigDecimal.isPositive get() = this > BigDecimal.ZERO -inline val BigDecimal.isNegative get() = this < BigDecimal.ZERO +inline val BigDecimal.isZero get() = this.signum() == 0 +inline val BigDecimal.isPositive get() = this.signum() > 0 +inline val BigDecimal.isNegative get() = this.signum() < 0 val BI_INT_MAX: BigInteger = BigInteger.valueOf(Int.MAX_VALUE.toLong()) val BI_INT_MIN: BigInteger = BigInteger.valueOf(Int.MIN_VALUE.toLong()) @@ -21,6 +22,35 @@ val BI_FLOAT_MIN: BigInteger = BigDecimal(Float.MIN_VALUE.toString()).toBigInteg val BI_DOUBLE_MAX: BigInteger = BigDecimal(Double.MAX_VALUE.toString()).toBigInteger() val BI_DOUBLE_MIN: BigInteger = BigDecimal(Double.MIN_VALUE.toString()).toBigInteger() +/** + * Constant value which represent edge of meaningful bits. + * + * Equals to 0.000000000001 + */ +const val EPSILON = 0.000000000001 + +fun weakEqualDoubles(a: Double, b: Double): Boolean { + if (a == b) + return true + + return (a - b).absoluteValue <= EPSILON +} + +fun weakCompareDoubles(a: Double, b: Double): Int { + if (weakEqualDoubles(a, b)) + return 0 + + if (a > b) + return 1 + + return -1 +} + +fun weakLessThan(a: Double, b: Double) = weakCompareDoubles(a, b) < 0 +fun weakGreaterThan(a: Double, b: Double) = weakCompareDoubles(a, b) > 0 +fun weakLessOrEqual(a: Double, b: Double) = weakCompareDoubles(a, b) <= 0 +fun weakGreaterOrEqual(a: Double, b: Double) = weakCompareDoubles(a, b) >= 0 + fun BigInteger.toIntSafe(): Int { if (this > BI_INT_MAX) { return Int.MAX_VALUE diff --git a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/DecimalTests.kt b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/DecimalTests.kt index 9f27dde91..366fd3dc3 100644 --- a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/DecimalTests.kt +++ b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/DecimalTests.kt @@ -11,46 +11,135 @@ import java.io.ObjectOutputStream object DecimalTests { @Test - @DisplayName("ImpreciseFraction comparison") + @DisplayName("Decimal comparison") fun comparison() { - check(Decimal(642, 0.43774) > Decimal(641, 0.43774)) { "must be bigger" } - check(Decimal(642, 0.43774) > Decimal(-641, 0.43774)) { "must be bigger" } + check(Decimal(642.43774) > Decimal(641.43774)) { "must be bigger" } + check(Decimal(642.43774) > Decimal(-641.43774)) { "must be bigger" } check(Decimal(0) == Decimal(0)) { "integer notation" } check(Decimal(0.1) > Decimal(0)) { "must be bigger" } check(Decimal(-0.1) < Decimal(0)) { "must be lesser" } - check(Decimal(-1, -0.1) < Decimal(-1)) { "must be lesser" } + check(Decimal(-1.1) < Decimal(-1)) { "must be lesser" } check(Decimal(0.1) == Decimal(0.1)) { "double notation" } check(Decimal("0.1") == Decimal("0.1")) { "string notation" } } @Test - @DisplayName("ImpreciseFraction mathematical operations") + @DisplayName("Decimal mathematical operations") fun math() { - check((Decimal(1) + Decimal(2)) == Decimal(3)) { "1 + 2 != 3" } - check((Decimal(0, 0.5) + Decimal(0, 0.5)) == Decimal(1)) { "0.5 + 0.5 != 1" } - check((Decimal(0, 0.5) + Decimal(0, -0.5)) == Decimal(0)) { "0.5 + -0.5 != 1" } - check((Decimal(0, 0.5) - Decimal(0, -0.5)) == Decimal(1)) { "0.5 - -0.5 != 1" } - check((Decimal(0, 0.3) - Decimal(1, 0.2)) == Decimal(0, -0.9)) { "0.3 - 1.2 != -0.9 ${Decimal(0, -0.9)} ${Decimal(0, 0.3) - Decimal(1, 0.2)}" } - check((Decimal(0, 0.3) * Decimal(0, 0.3)) == Decimal(0, 0.09)) { "0.3 * 0.3 != 0.9 ${Decimal(0, 0.3) * Decimal(0, 0.3)}" } - check((Decimal(2, 0.3) * Decimal(2, 0.3)) == Decimal(5, 0.29)) { "2.3 * 2.3 != 5.29 ${Decimal(2, 0.3) * Decimal(2, 0.3)}" } - check((Decimal(4) / Decimal(2)) == Decimal(2)) { "4 / 2 != 2" } - check((Decimal(6) / Decimal(2)) == Decimal(3)) { "6 / 2 != 2" } - check((Decimal(1) / Decimal(0, 0.25)) == Decimal(4)) { "1 / 0.25 != 4" } + assertEquals(Decimal(3), Decimal(1) + Decimal(2)) + assertEquals(Decimal(5), Decimal(2) + Decimal(3)) + assertEquals(Decimal(-1), Decimal(6) + Decimal(-7)) + assertEquals(Decimal(-1), Decimal(6) - Decimal(7)) + assertEquals(Decimal(2), Decimal(1) * Decimal(2)) + assertEquals(Decimal(4), Decimal(2) * Decimal(2)) + assertEquals(Decimal(16), Decimal(4) * Decimal(4)) + assertEquals(Decimal(100_000), Decimal(100) * Decimal(1_000)) + assertEquals(Decimal(4), Decimal(16) / Decimal(4)) + assertEquals(Decimal(3), Decimal(12) / Decimal(4)) + assertEquals(Decimal(1), Decimal(15) / Decimal(15)) + + assertEquals(Decimal("0.1"), Decimal(1) / Decimal(10)) + assertEquals(Decimal("-0.1"), Decimal(1) / Decimal(-10)) + assertEquals(Decimal("-0.1"), Decimal(-1) / Decimal(10)) + assertEquals(Decimal("0.1"), Decimal(-1) / Decimal(-10)) + assertEquals(Decimal("0.5"), Decimal("0.25") + Decimal("0.25")) + assertEquals(Decimal("0.5"), Decimal("0.25") * Decimal(2)) + assertEquals(Decimal("-0.5"), Decimal("0.25") * Decimal(-2)) + assertEquals(Decimal("-0.5"), Decimal("-0.25") * Decimal(2)) + assertEquals(Decimal("0.3"), Decimal(0.2) + Decimal(0.1)) + assertEquals(Decimal("0.3"), Decimal("0.2") + Decimal("0.1")) } @Test - @DisplayName("ImpreciseFraction store/load") + @DisplayName("Decimal precision test") + fun precisionTest() { + assertEquals(0.0, Decimal(4).fractionalDouble) + assertEquals(0.2, Decimal(4.2).fractionalDouble) + assertEquals(0.2, Decimal("4.2").fractionalDouble) + assertEquals(0.25, Decimal("4.25").fractionalDouble) + assertEquals(-0.25, Decimal("-1.25").fractionalDouble) + assertEquals(-0.2, Decimal("-1.2").fractionalDouble) + assertEquals(0.0, Decimal("-1").fractionalDouble) + + assertEquals(0.0f, Decimal(4).fractionalFloat) + assertEquals(0.2f, Decimal(4.2).fractionalFloat) + assertEquals(0.2f, Decimal("4.2").fractionalFloat) + assertEquals(0.25f, Decimal("4.25").fractionalFloat) + assertEquals(-0.25f, Decimal("-1.25").fractionalFloat) + assertEquals(-0.2f, Decimal("-1.2").fractionalFloat) + assertEquals(0.0f, Decimal("-1").fractionalFloat) + } + + @Test + @DisplayName("Decimal toString() tests") + fun toStringTest() { + assertEquals("0.0", Decimal(0).toString()) + assertEquals("0.0", Decimal("0.000").toString()) + + assertEquals("0.001", Decimal("0.001").toString()) + assertEquals("0.1", Decimal("0.1").toString()) + assertEquals("1.0", Decimal("1.0").toString()) + assertEquals("4.0", Decimal("4.0").toString()) + assertEquals("4.0", Decimal("4.000").toString()) + assertEquals("4.0001", Decimal("4.0001").toString()) + + assertEquals("-0.001", Decimal("-0.001").toString()) + assertEquals("-0.1", Decimal("-0.1").toString()) + assertEquals("-1.0", Decimal("-1.0").toString()) + assertEquals("-4.0", Decimal("-4.0").toString()) + assertEquals("-4.0", Decimal("-4.000").toString()) + assertEquals("-4.0001", Decimal("-4.0001").toString()) + + assertEquals("0.0", Decimal("0.000").toString(1)) + assertEquals("0.00", Decimal("0.000").toString(2)) + assertEquals("0.000", Decimal("0.000").toString(3)) + assertEquals("0.001", Decimal("0.001").toString(3)) + assertEquals("0.00", Decimal("0.001").toString(2)) + assertEquals("0.0", Decimal("0.001").toString(1)) + assertEquals("1.0", Decimal("1.001").toString(1)) + assertEquals("1.1", Decimal("1.101").toString(1)) + assertEquals("1.10", Decimal("1.101").toString(2)) + assertEquals("1.101", Decimal("1.101").toString(3)) + assertEquals("1.1010", Decimal("1.101").toString(4)) + } + + @Test + @DisplayName("Decimal store/load") fun storeLoad() { run { - val f = Decimal(4, 0.28) + val f = Decimal(4.28) val loaded = Decimal.fromByteArray(f.toByteArray()) - check(f == loaded) { "$f != $loaded" } + assertEquals(f, loaded) } run { - val f = Decimal(32748293658335L, 0.3472302174) + val f = Decimal(1) val loaded = Decimal.fromByteArray(f.toByteArray()) - check(f == loaded) { "$f != $loaded" } + assertEquals(f, loaded) + } + + run { + val f = Decimal(0) + val loaded = Decimal.fromByteArray(f.toByteArray()) + assertEquals(f, loaded) + } + + run { + val f = Decimal("23784399123654793927324950293475093257324097021387409873240957021934750934089734095273098475") + val loaded = Decimal.fromByteArray(f.toByteArray()) + assertEquals(f, loaded) + } + + run { + val f = Decimal("23784399123654793927324950293475093257324097021387409873240957021934750934089734095273098475.25") + val loaded = Decimal.fromByteArray(f.toByteArray()) + assertEquals(f, loaded) + } + + run { + val f = Decimal(32748293658335.3472302174) + val loaded = Decimal.fromByteArray(f.toByteArray()) + assertEquals(f, loaded) } } @@ -67,7 +156,7 @@ object DecimalTests { } @Test - @DisplayName("ImpreciseFraction serialization") + @DisplayName("Decimal serialization") fun serialization() { val output = FastByteArrayOutputStream() val outputStream = ObjectOutputStream(output) From f8e9d200949fca57fb09378f4f6db99f873ffd1b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 18 Jun 2023 17:48:51 +0700 Subject: [PATCH 0614/1199] Get rid of Long precision value, since it upper limits possible precision --- .../dbotthepony/mc/otm/core/math/Decimal.kt | 23 ++++--------------- 1 file changed, 4 insertions(+), 19 deletions(-) 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 835c637c0..a82aa0447 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 @@ -589,31 +589,16 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe */ const val PRECISION = 11 - /** - * 10 in power of [PRECISION] (10^[PRECISION]), as [Long] - */ @JvmField - val PRECISION_POW: Long - - init { - var i = 10L - for (u in 1 until PRECISION) i *= 10L - PRECISION_POW = i - } - + val PRECISION_POW_BI: BigInteger = BigInteger("1" + "0".repeat(PRECISION)) @JvmField - val PRECISION_DOUBLE = PRECISION_POW.toDouble() + val PRECISION_DOUBLE = PRECISION_POW_BI.toDouble() @JvmField - val PRECISION_FLOAT = PRECISION_POW.toFloat() - @JvmField - val PRECISION_INT = PRECISION_POW.toInt() - - @JvmField - val PRECISION_POW_BI: BigInteger = BigInteger.valueOf(PRECISION_POW) + val PRECISION_FLOAT = PRECISION_POW_BI.toFloat() @JvmField val PRECISION_POW_BI_NEGATIVE: BigInteger = -PRECISION_POW_BI @JvmField - val PRECISION_POW_BI_HIGH: BigInteger = BigInteger.valueOf(PRECISION_POW / 2) + val PRECISION_POW_BI_HIGH: BigInteger = PRECISION_POW_BI / BigInteger.TWO private val cache = Array(2048) { Decimal(BigInteger.valueOf(it.toLong() - 1024)) } private val pool = Object2ObjectOpenHashMap() From 9276d087dfd873fb27129d479971ecf3e852383b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 18 Jun 2023 17:51:39 +0700 Subject: [PATCH 0615/1199] Greatly increase Decimal cache pool --- .../ru/dbotthepony/mc/otm/core/math/Decimal.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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 a82aa0447..b10e92863 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 @@ -600,7 +600,10 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe @JvmField val PRECISION_POW_BI_HIGH: BigInteger = PRECISION_POW_BI / BigInteger.TWO - private val cache = Array(2048) { Decimal(BigInteger.valueOf(it.toLong() - 1024)) } + private const val cacheSize = 16384 + private const val cacheSizeL = cacheSize.toLong() + + private val cache = Array(cacheSize) { Decimal(BigInteger.valueOf(it.toLong() - cacheSize / 2)) } private val pool = Object2ObjectOpenHashMap() init { @@ -614,8 +617,8 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe */ @JvmStatic fun valueOf(value: Int): Decimal { - if (value in -1024 .. 1023) { - return cache[value + 1024] + if (value in (cacheSize / -2) until cacheSize / 2) { + return cache[value + cacheSize / 2] } return Decimal(BigInteger.valueOf(value.toLong())) @@ -626,8 +629,8 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe */ @JvmStatic fun valueOf(value: Long): Decimal { - if (value in -1024L .. 1023L) { - return cache[value.toInt() + 1024] + if (value in (cacheSizeL / -2L) until cacheSizeL / 2L) { + return cache[value.toInt() + cacheSize / 2] } return Decimal(BigInteger.valueOf(value)) From 849563e7eb542920607d562621a918a4b2f4523a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 18 Jun 2023 18:15:08 +0700 Subject: [PATCH 0616/1199] Remove Decimal interning --- .../dbotthepony/mc/otm/core/math/Decimal.kt | 37 +++++++------------ 1 file changed, 13 insertions(+), 24 deletions(-) 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 b10e92863..267509fb1 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 @@ -128,7 +128,7 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe return this } - return Decimal(mag + other.mag, null).interned() + return Decimal(mag + other.mag, null) } operator fun minus(other: Decimal): Decimal { @@ -136,7 +136,7 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe return this } - return Decimal(mag - other.mag, null).interned() + return Decimal(mag - other.mag, null) } operator fun times(other: Decimal): Decimal { @@ -145,16 +145,16 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe } else if (other.mag == BigInteger.ONE) { return this } else if (other.mag == BI_MINUS_ONE) { - return Decimal(-mag, null).interned() + return Decimal(-mag, null) } val result = mag * other.mag val (a, b) = result.divideAndRemainder(PRECISION_POW_BI) if (b >= PRECISION_POW_BI_HIGH) { - return Decimal(a + BigInteger.ONE, null).interned() + return Decimal(a + BigInteger.ONE, null) } else { - return Decimal(a, null).interned() + return Decimal(a, null) } } @@ -164,10 +164,10 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe } else if (other.mag == BigInteger.ONE) { return this } else if (other.mag == BI_MINUS_ONE) { - return Decimal(-mag, null).interned() + return Decimal(-mag, null) } - return Decimal((mag * PRECISION_POW_BI) / other.mag, null).interned() + return Decimal((mag * PRECISION_POW_BI) / other.mag, null) } operator fun rem(other: Decimal): Decimal { @@ -413,7 +413,7 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe return this } - return Decimal(-mag, null).interned() + return Decimal(-mag, null) } operator fun unaryPlus() = this @@ -578,10 +578,6 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe return toBigDecmial().divide(divisor.toBigDecmial(), PERCENTAGE_CONTEXT).toFloat() } - private fun interned(): Decimal { - return pool[this] ?: this - } - @Suppress("unused") companion object { /** @@ -604,13 +600,6 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe private const val cacheSizeL = cacheSize.toLong() private val cache = Array(cacheSize) { Decimal(BigInteger.valueOf(it.toLong() - cacheSize / 2)) } - private val pool = Object2ObjectOpenHashMap() - - init { - for (value in cache) { - pool[value] = value - } - } /** * Returns pooled value if present, otherwise constructs new object @@ -648,11 +637,11 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe @JvmStatic fun valueOf(value: Byte) = valueOf(value.toInt()) - @JvmStatic fun valueOf(value: BigInteger) = Decimal(value).interned() - @JvmStatic fun valueOf(value: BigDecimal) = Decimal(value).interned() - @JvmStatic fun valueOf(value: String) = Decimal(value).interned() - @JvmStatic fun valueOf(value: Float) = Decimal(value).interned() - @JvmStatic fun valueOf(value: Double) = Decimal(value).interned() + @JvmStatic fun valueOf(value: BigInteger) = Decimal(value) + @JvmStatic fun valueOf(value: BigDecimal) = Decimal(value) + @JvmStatic fun valueOf(value: String) = Decimal(value) + @JvmStatic fun valueOf(value: Float) = Decimal(value) + @JvmStatic fun valueOf(value: Double) = Decimal(value) @JvmStatic fun fromByteArray(input: ByteArray): Decimal { From 2bc9aa8f0607a95eb00901b14d79ba85f27a46ac Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 18 Jun 2023 18:32:42 +0700 Subject: [PATCH 0617/1199] Put 3 decimals by default when formatting numbers, always SI format numbers smaller than 1 Formatting numbers in SI format when they are smaller than 1 by absolute value avoids case where we want to see "exact" values, but value is too small to be displayed without SI prefix --- .../mc/otm/core/util/Formatting.kt | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt index 6a7bc0a01..49aee5756 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt @@ -60,7 +60,7 @@ fun BigInteger.formatReadableNumber(): String { return String(buffer) } -fun BigInteger.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never): Component { +fun BigInteger.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 3, formatAsReadable: BooleanSupplier = never): Component { require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } val prefix = SiPrefix.determine(this) if (prefix.isEmpty) return concat(toString(decimalPlaces), suffix) @@ -135,8 +135,9 @@ private fun reformat(numbers: String): String { }) } -fun Long.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never, bias: Int = 0): Component { +fun Long.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 3, formatAsReadable: BooleanSupplier = never, bias: Int = 0): Component { require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } + if (formatAsReadable.asBoolean) { if (bias == 0) { return concat(reformat(toString()), suffix) @@ -150,38 +151,38 @@ fun Long.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsRea return TranslatableComponent(prefix.neighbour(bias).formatLocaleKey, "%.${decimalPlaces}f".format(this.toDouble() / prefix.long!!.toDouble()), suffix) } -fun Int.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never, bias: Int = 0): Component { +fun Int.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 3, formatAsReadable: BooleanSupplier = never, bias: Int = 0): Component { return toLong().formatSiComponent(suffix, decimalPlaces, formatAsReadable, bias) } -fun Double.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never, bias: Int = 0): Component { +fun Double.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 3, formatAsReadable: BooleanSupplier = never, bias: Int = 0): Component { require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } - if (formatAsReadable.asBoolean) return concat(reformat("%.${decimalPlaces}f".format(this)), suffix) + if (formatAsReadable.asBoolean && this.absoluteValue >= 1.0) return concat(reformat("%.${decimalPlaces}f".format(this)), suffix) val prefix = SiPrefix.determine(this) return TranslatableComponent(prefix.neighbour(bias).formatLocaleKey, "%.${decimalPlaces}f".format(this / prefix.double), suffix) } -fun Decimal.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never, bias: Int = 0): Component { +fun Decimal.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 3, formatAsReadable: BooleanSupplier = never, bias: Int = 0): Component { require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } - if (formatAsReadable.asBoolean) return concat(reformat(toString(decimalPlaces)), suffix) + if (formatAsReadable.asBoolean && this.absoluteValue >= Decimal.ONE) return concat(reformat(toString(decimalPlaces)), suffix) val prefix = SiPrefix.determine(this) return TranslatableComponent(prefix.neighbour(bias).formatLocaleKey, (this / prefix.decimal).toString(decimalPlaces), suffix) } -fun Int.formatPower(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.power.name"), decimalPlaces, formatAsReadable = formatAsReadable) -fun Int.formatFluid(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.fluid.name"), decimalPlaces, formatAsReadable = formatAsReadable, bias = -1) -fun Decimal.formatPower(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.power.name"), decimalPlaces, formatAsReadable = formatAsReadable) -fun Decimal.formatMatter(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.matter.name"), decimalPlaces, formatAsReadable = formatAsReadable) -fun Decimal.formatMatterFull(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = TranslatableComponent("otm.gui.matter.format", formatSiComponent(TranslatableComponent("otm.gui.matter.name"), decimalPlaces, formatAsReadable = formatAsReadable)) +fun Int.formatPower(decimalPlaces: Int = 3, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.power.name"), decimalPlaces, formatAsReadable = formatAsReadable) +fun Int.formatFluid(decimalPlaces: Int = 3, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.fluid.name"), decimalPlaces, formatAsReadable = formatAsReadable, bias = -1) +fun Decimal.formatPower(decimalPlaces: Int = 3, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.power.name"), decimalPlaces, formatAsReadable = formatAsReadable) +fun Decimal.formatMatter(decimalPlaces: Int = 3, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.matter.name"), decimalPlaces, formatAsReadable = formatAsReadable) +fun Decimal.formatMatterFull(decimalPlaces: Int = 3, formatAsReadable: BooleanSupplier = never) = TranslatableComponent("otm.gui.matter.format", formatSiComponent(TranslatableComponent("otm.gui.matter.name"), decimalPlaces, formatAsReadable = formatAsReadable)) -fun BigInteger.formatPower(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.power.name"), decimalPlaces, formatAsReadable = formatAsReadable) -fun BigInteger.formatMatter(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.matter.name"), decimalPlaces, formatAsReadable = formatAsReadable) -fun BigInteger.formatMatterFull(decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = TranslatableComponent("otm.gui.matter.format", formatSiComponent(TranslatableComponent("otm.gui.matter.name"), decimalPlaces, formatAsReadable = formatAsReadable)) +fun BigInteger.formatPower(decimalPlaces: Int = 3, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.power.name"), decimalPlaces, formatAsReadable = formatAsReadable) +fun BigInteger.formatMatter(decimalPlaces: Int = 3, formatAsReadable: BooleanSupplier = never) = formatSiComponent(TranslatableComponent("otm.gui.matter.name"), decimalPlaces, formatAsReadable = formatAsReadable) +fun BigInteger.formatMatterFull(decimalPlaces: Int = 3, formatAsReadable: BooleanSupplier = never) = TranslatableComponent("otm.gui.matter.format", formatSiComponent(TranslatableComponent("otm.gui.matter.name"), decimalPlaces, formatAsReadable = formatAsReadable)) -fun formatPowerLevel(a: Decimal, b: Decimal, decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = TranslatableComponent("otm.gui.level", a.formatPower(decimalPlaces, formatAsReadable = formatAsReadable), b.formatPower(decimalPlaces, formatAsReadable = formatAsReadable)) -fun formatMatterLevel(a: Decimal, b: Decimal, decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = TranslatableComponent("otm.gui.level", a.formatMatter(decimalPlaces, formatAsReadable = formatAsReadable), b.formatMatter(decimalPlaces, formatAsReadable = formatAsReadable)) -fun formatFluidLevel(a: Int, b: Int, decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = TranslatableComponent("otm.gui.level", a.formatFluid(decimalPlaces, formatAsReadable = formatAsReadable), b.formatFluid(decimalPlaces, formatAsReadable = formatAsReadable)) -fun formatFluidLevel(a: Int, b: Int, name: Component, decimalPlaces: Int = 2, formatAsReadable: BooleanSupplier = never) = TranslatableComponent("otm.gui.fluid.level", a.formatFluid(decimalPlaces, formatAsReadable = formatAsReadable), b.formatFluid(decimalPlaces, formatAsReadable = formatAsReadable), name) +fun formatPowerLevel(a: Decimal, b: Decimal, decimalPlaces: Int = 3, formatAsReadable: BooleanSupplier = never) = TranslatableComponent("otm.gui.level", a.formatPower(decimalPlaces, formatAsReadable = formatAsReadable), b.formatPower(decimalPlaces, formatAsReadable = formatAsReadable)) +fun formatMatterLevel(a: Decimal, b: Decimal, decimalPlaces: Int = 3, formatAsReadable: BooleanSupplier = never) = TranslatableComponent("otm.gui.level", a.formatMatter(decimalPlaces, formatAsReadable = formatAsReadable), b.formatMatter(decimalPlaces, formatAsReadable = formatAsReadable)) +fun formatFluidLevel(a: Int, b: Int, decimalPlaces: Int = 3, formatAsReadable: BooleanSupplier = never) = TranslatableComponent("otm.gui.level", a.formatFluid(decimalPlaces, formatAsReadable = formatAsReadable), b.formatFluid(decimalPlaces, formatAsReadable = formatAsReadable)) +fun formatFluidLevel(a: Int, b: Int, name: Component, decimalPlaces: Int = 3, formatAsReadable: BooleanSupplier = never) = TranslatableComponent("otm.gui.fluid.level", a.formatFluid(decimalPlaces, formatAsReadable = formatAsReadable), b.formatFluid(decimalPlaces, formatAsReadable = formatAsReadable), name) private fun padded(num: Int): String { if (num in 0 .. 9) { From dfa14ca2a1f87470ff020e49adb98ad0763f4133 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 19 Jun 2023 21:31:14 +0700 Subject: [PATCH 0618/1199] Add missing json null writer for `writeJson` --- .../kotlin/ru/dbotthepony/mc/otm/core/util/FriendlyStreams.kt | 2 ++ 1 file changed, 2 insertions(+) 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 ef31ac554..d13b20bb5 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 @@ -212,6 +212,8 @@ fun OutputStream.writeJson(element: JsonElement) { } else { write(TYPE_NULL) } + } else if (element is JsonNull) { + write(TYPE_NULL) } else { throw IllegalArgumentException("Unknown element type: ${element::class.qualifiedName}") } From 09db4ad9e98ff8953e0d4bfd722ca4ed959d10dd Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 19 Jun 2023 21:37:43 +0700 Subject: [PATCH 0619/1199] Revisit how android research datapacks work Instead of "feature results" provide them with just "results", which reference arbitrary features from registry Do the same to research description, with its own registry --- .../mc/otm/datagen/ResearchData.kt | 58 ++-- .../mc/otm/android/AndroidResearch.kt | 90 +----- .../android/AndroidResearchDataProvider.kt | 2 - .../otm/android/AndroidResearchDescription.kt | 133 +++++++++ .../mc/otm/android/AndroidResearchManager.kt | 55 ---- .../mc/otm/android/AndroidResearchResult.kt | 180 ++++++++++++ .../mc/otm/android/AndroidResearchType.kt | 278 ++++-------------- .../android/feature/EnderTeleporterFeature.kt | 19 +- .../android/feature/FallDampenersFeature.kt | 6 - .../otm/android/feature/ItemMagnetFeature.kt | 8 - .../otm/android/feature/JumpBoostFeature.kt | 9 - .../android/feature/NanobotsArmorFeature.kt | 28 -- .../otm/android/feature/ShockwaveFeature.kt | 8 - .../ru/dbotthepony/mc/otm/data/Codecs.kt | 33 +++ .../dbotthepony/mc/otm/data/ComponentCodec.kt | 25 ++ .../mc/otm/data/SerializedFunctionRegistry.kt | 225 -------------- .../dbotthepony/mc/otm/data/SingletonCodec.kt | 16 + .../mc/otm/registry/AndroidFeatures.kt | 28 +- .../dbotthepony/mc/otm/registry/MRegistry.kt | 16 +- 19 files changed, 508 insertions(+), 709 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDescription.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchResult.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/Codecs.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/ComponentCodec.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/SerializedFunctionRegistry.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/SingletonCodec.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt index 5d8dc61b8..00599e085 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt @@ -4,6 +4,9 @@ import net.minecraft.tags.ItemTags import net.minecraft.world.item.Items import net.minecraftforge.common.Tags import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.android.AndroidResearchDescriptions +import ru.dbotthepony.mc.otm.android.AndroidResearchResult +import ru.dbotthepony.mc.otm.android.AndroidResearchResults import ru.dbotthepony.mc.otm.android.AndroidResearchType import ru.dbotthepony.mc.otm.android.feature.EnderTeleporterFeature import ru.dbotthepony.mc.otm.android.feature.FallDampenersFeature @@ -132,11 +135,13 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang ) ) .addItem(MItemTags.COPPER_WIRES, 4 + i * 2) - .addFeatureResult(OverdriveThatMatters.loc(MNames.LIMB_OVERCLOCKING), i) if (i > 0) { + research.addFeatureLevel(AndroidFeatures.LIMB_OVERCLOCKING) research.addPrerequisite(OverdriveThatMatters.loc(MNames.LIMB_OVERCLOCKING_LIST[i - 1]), rigid = true) research.addItem(MItemTags.GOLD_WIRES, i * 2) + } else { + research.addFeatureResult(AndroidFeatures.LIMB_OVERCLOCKING) } research.build() @@ -155,18 +160,20 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang (i + 1) * 15 ) ) - .addFeatureResult(AndroidFeatures.ATTACK_BOOST, i) .addBlocker(NANOBOTS_ARMOR) if (i > 0) { + research.addFeatureLevel(AndroidFeatures.ATTACK_BOOST) research.addPrerequisite(OverdriveThatMatters.loc(MNames.ATTACK_BOOST_LIST[i - 1]), rigid = true) + } else { + research.addFeatureResult(AndroidFeatures.ATTACK_BOOST) } research.build() }) regenList.add(run { - val regeneration = AndroidResearchType.Builder(modLocation(MNames.NANOBOTS_REGENERATION_LIST[i])) + val research = AndroidResearchType.Builder(modLocation(MNames.NANOBOTS_REGENERATION_LIST[i])) .withExperience(20 + i * 6) .withIconText(TextComponent((i + 1).toString())) .withIcon(ResearchIcons.ICON_NANOBOTS) @@ -179,15 +186,16 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang .addItem(MItems.MATTER_CAPACITOR_PARTS, 1) .addItem(Items.SUGAR, 2 + i * 2) .addItem(Tags.Items.DUSTS_REDSTONE, 2 + i * 2) - .addFeatureResult(AndroidFeatures.NANOBOTS_REGENERATION, i) if (i > 0) { - regeneration.addPrerequisite(OverdriveThatMatters.loc(MNames.NANOBOTS_REGENERATION_LIST[i - 1]), rigid = true) + research.addFeatureLevel(AndroidFeatures.NANOBOTS_REGENERATION) + research.addPrerequisite(OverdriveThatMatters.loc(MNames.NANOBOTS_REGENERATION_LIST[i - 1]), rigid = true) } else { - regeneration.addPrerequisite(OverdriveThatMatters.loc(MNames.NANOBOTS), rigid = true) + research.addPrerequisite(OverdriveThatMatters.loc(MNames.NANOBOTS), rigid = true) + research.addFeatureResult(AndroidFeatures.NANOBOTS_REGENERATION) } - regeneration.build() + research.build() }) } @@ -216,10 +224,7 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang .addItem(MItemTags.TRITANIUM_PLATES, 2 + i * 2) .addItem(Items.SUGAR, 1 + i) .addItem(MItems.ELECTROMAGNET) - .addFeatureResult(AndroidFeatures.NANOBOTS_ARMOR, 0, - transformersUp = listOf(NanobotsArmorFeature.STRENGTH_TRANSFORMER_UP.bind(level)), - transformersDown = listOf(NanobotsArmorFeature.STRENGTH_TRANSFORMER_DOWN.bind(level)), - ) + .addResult(AndroidResearchResults.NANOBOTS_ARMOR_STRENGTH) .build() }) @@ -243,10 +248,7 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang ) ) .addItem(Tags.Items.DUSTS_REDSTONE, 4 + i * 4) - .addFeatureResult(AndroidFeatures.NANOBOTS_ARMOR, 0, - transformersUp = listOf(NanobotsArmorFeature.SPEED_TRANSFORMER_UP.bind(level)), - transformersDown = listOf(NanobotsArmorFeature.SPEED_TRANSFORMER_DOWN.bind(level)), - ) + .addResult(AndroidResearchResults.NANOBOTS_ARMOR_SPEED) .build() }) } @@ -261,7 +263,7 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang AndroidResearchType.Builder(modLocation(MNames.SHOCKWAVE)) .withExperience(40) .withDescription(0 .. 1) - .appendDescription(ShockwaveFeature.POWER_COST_DESCRIPTION) + .withDescription(AndroidResearchDescriptions.SHOCKWAVE) .withIcon(ResearchIcons.ICON_SHOCKWAVE) .addFeatureResult(AndroidFeatures.SHOCKWAVE) .addPrerequisite(attackBoostList[2]) @@ -276,7 +278,7 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang AndroidResearchType.Builder(modLocation(MNames.ITEM_MAGNET)) .withExperience(28) .withDescription(0 .. 1) - .appendDescription(ItemMagnetFeature.POWER_COST_DESCRIPTION) + .withDescription(AndroidResearchDescriptions.ITEM_MAGNET) .withIcon(ResearchIcons.ICON_ITEM_MAGNET) .addFeatureResult(AndroidFeatures.ITEM_MAGNET) .addPrerequisite(STEP_ASSIST) @@ -292,9 +294,9 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang AndroidResearchType.Builder(modLocation(MNames.FALL_DAMPENERS + "_1")) .withExperience(25) .withDescription() - .appendDescription(FallDampenersFeature.DESCRIPTION.bind(1)) + .withDescription(AndroidResearchDescriptions.FALL_DAMPENERS.Instance(1)) .withIcon(ResearchIcons.ICON_FEATHER_FALLING) - .addFeatureResult(AndroidFeatures.FALL_DAMPENERS, 0) + .addFeatureResult(AndroidFeatures.FALL_DAMPENERS) .addPrerequisite(STEP_ASSIST) .addItem(MItems.ELECTROMAGNET, 2) .addItem(ItemTags.WOOL, 2) @@ -305,9 +307,9 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang AndroidResearchType.Builder(modLocation(MNames.FALL_DAMPENERS + "_2")) .withExperience(30) .withDescription() - .appendDescription(FallDampenersFeature.DESCRIPTION.bind(2)) + .withDescription(AndroidResearchDescriptions.FALL_DAMPENERS.Instance(2)) .withIcon(ResearchIcons.ICON_FEATHER_FALLING) - .addFeatureResult(AndroidFeatures.FALL_DAMPENERS, 1) + .addFeatureLevel(AndroidFeatures.FALL_DAMPENERS) .addPrerequisite(FALL_DAMPENERS_1) .addItem(MItemTags.GOLD_PLATES, 2) .addItem(MItemTags.COPPER_WIRES, 4) @@ -319,9 +321,9 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang AndroidResearchType.Builder(modLocation(MNames.FALL_DAMPENERS + "_3")) .withExperience(35) .withDescription(0 .. 1) - .appendDescription(FallDampenersFeature.DESCRIPTION.bind(3)) + .withDescription(AndroidResearchDescriptions.FALL_DAMPENERS.Instance(2)) .withIcon(ResearchIcons.ICON_FEATHER_FALLING) - .addFeatureResult(AndroidFeatures.FALL_DAMPENERS, 2) + .addFeatureLevel(AndroidFeatures.FALL_DAMPENERS) .addPrerequisite(FALL_DAMPENERS_2) .addItem(MItemTags.ADVANCED_CIRCUIT, 2) .addItem(Tags.Items.GEMS_DIAMOND, 4) @@ -337,7 +339,7 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang AndroidResearchType.Builder(modLocation(MNames.ENDER_TELEPORTER)) .withExperience(35) .withDescription() - .appendDescription(EnderTeleporterFeature.POWER_COST_DESCRIPTION) + .withDescription(AndroidResearchDescriptions.ENDER_TELEPORTER) .withIcon(ResearchIcons.ICON_ENDER_TELEPORT) .addFeatureResult(AndroidFeatures.ENDER_TELEPORTER) .addPrerequisite(FALL_DAMPENERS_1) @@ -368,9 +370,9 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang AndroidResearchType.Builder(modLocation(MNames.JUMP_BOOST + "_1")) .withExperience(27) .withDescription(0 .. 1) - .appendDescription(JumpBoostFeature.POWER_COST_DESCRIPTION) + .withDescription(AndroidResearchDescriptions.JUMP_BOOST) .withIcon(ResearchIcons.ICON_JUMP_BOOST) - .addFeatureResult(AndroidFeatures.JUMP_BOOST, 0) + .addFeatureResult(AndroidFeatures.JUMP_BOOST) .addItem(MItemTags.PISTONS, 2) .addItem(MItemTags.GOLD_WIRES, 4) .addItem(MItems.ELECTROMAGNET, 2) @@ -382,9 +384,9 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang AndroidResearchType.Builder(modLocation(MNames.JUMP_BOOST + "_2")) .withExperience(34) .withDescription() - .appendDescription(JumpBoostFeature.POWER_COST_DESCRIPTION) + .withDescription(AndroidResearchDescriptions.JUMP_BOOST) .withIcon(ResearchIcons.ICON_JUMP_BOOST) - .addFeatureResult(AndroidFeatures.JUMP_BOOST, 1) + .addFeatureLevel(AndroidFeatures.JUMP_BOOST) .addItem(MItems.ELECTRIC_PARTS, 4) .addItem(MItems.ELECTROMAGNET, 4) .addPrerequisite(JUMP_BOOST_1) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt index c9cc9e664..aa03048e3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.android import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream -import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap import net.minecraft.ChatFormatting import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.ListTag @@ -15,7 +14,6 @@ import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.awareItemsStream import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.core.addAll import ru.dbotthepony.mc.otm.core.nbt.getCompoundList import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.core.nbt.set @@ -46,62 +44,19 @@ class AndroidResearch(val type: AndroidResearchType, val capability: MatteryPlay return } - onUnResearch() + onRefunded() isResearched = false } - private data class RememberResearchLevel(val level: Int?) - - private val oldResearchLevel = Object2ObjectArrayMap, RememberResearchLevel>() - - fun onUnResearch() { - for (feature in type.resolvedFeatures) { - val level = oldResearchLevel[feature.feature] - val get = capability.getFeature(feature.feature) - - if (level != null && get != null) { - if (get.level == feature.level) { - if (level.level == null) { - capability.removeFeature(feature.feature) - } else { - get.level = level.level - - for (transformer in type.features.first { it.id == feature.feature.registryName }.transformersDown) { - transformer.apply(this to get) - } - } - } - } + fun onRefunded() { + for (result in type.results) { + result.onRefunded(this) } - - oldResearchLevel.clear() } fun onResearched() { - oldResearchLevel.clear() - - try { - for (feature in type.resolvedFeatures) { - var get = capability.getFeature(feature.feature) - - if (get == null) { - get = capability.addFeature(feature.feature) - get.level = feature.level - oldResearchLevel[feature.feature] = RememberResearchLevel(null) - } else { - if (get.level < feature.level) { - oldResearchLevel[feature.feature] = RememberResearchLevel(feature.level) - get.level = feature.level - } - } - - for (transformer in type.features.first { it.id == feature.feature.registryName }.transformersUp) { - transformer.apply(this to get) - } - } - } catch(err: Throwable) { - oldResearchLevel.clear() - throw err + for (result in type.results) { + result.onResearched(this) } } @@ -297,7 +252,10 @@ class AndroidResearch(val type: AndroidResearchType, val capability: MatteryPlay val tooltipLines: List get() { val lines = ArrayList() lines.add(type.displayName) - lines.addAll(type.description.iterator()) + + for (line in type.description) { + line.addLines(this, lines) + } return lines } @@ -382,38 +340,10 @@ class AndroidResearch(val type: AndroidResearchType, val capability: MatteryPlay override fun serializeNBT(): CompoundTag { return CompoundTag().also { it["researched"] = isResearched - - it["oldResearchLevel"] = ListTag().also { - for ((k, v) in oldResearchLevel) { - it.add(CompoundTag().also { - it["key"] = k.registryName!!.toString() - it["value"] = CompoundTag().also { - it["isPresent"] = v.level != null - - if (v.level != null) { - it["value"] = v.level - } - } - }) - } - } } } override fun deserializeNBT(nbt: CompoundTag) { isResearched = nbt.getBoolean("researched") - - oldResearchLevel.clear() - - for (tag in nbt.getCompoundList("oldResearchLevel")) { - val key = tag.getString("key") - val type = MRegistry.ANDROID_FEATURES.getValue(ResourceLocation(key)) ?: continue - val value = tag.getCompound("value") - - val isPresent = value.getBoolean("isPresent") - val int = value.getInt("value") - - oldResearchLevel[type] = RememberResearchLevel(if (isPresent) int else null) - } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDataProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDataProvider.kt index 779263e7d..ee9b57c9a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDataProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDataProvider.kt @@ -50,8 +50,6 @@ open class AndroidResearchDataProvider() : DataProvider { } final override fun run(output: CachedOutput): CompletableFuture<*> { - AndroidResearchManager.fireRegistrationEvent() - val set = ObjectArraySet() val added = LinkedList() val futures = ArrayList>() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDescription.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDescription.kt new file mode 100644 index 000000000..1a5c51867 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDescription.kt @@ -0,0 +1,133 @@ +package ru.dbotthepony.mc.otm.android + +import com.mojang.datafixers.util.Either +import com.mojang.serialization.Codec +import com.mojang.serialization.codecs.RecordCodecBuilder +import net.minecraft.ChatFormatting +import net.minecraft.network.chat.Component +import net.minecraftforge.eventbus.api.IEventBus +import net.minecraftforge.registries.DeferredRegister +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.client.ShiftPressedCond +import ru.dbotthepony.mc.otm.config.AndroidConfig +import ru.dbotthepony.mc.otm.core.TextComponent +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.getValue +import ru.dbotthepony.mc.otm.core.util.formatPower +import ru.dbotthepony.mc.otm.data.ComponentCodec +import ru.dbotthepony.mc.otm.data.SingletonCodec +import ru.dbotthepony.mc.otm.data.simpleCodec +import ru.dbotthepony.mc.otm.registry.RegistryDelegate + +object AndroidResearchDescriptions { + private val registrar = DeferredRegister.create(AndroidResearchDescription.registryKey, OverdriveThatMatters.MOD_ID) + + init { + registrar.register("plain") { PlainAndroidResearchDescription } + } + + internal fun register(bus: IEventBus) { + registrar.register(bus) + } + + val ENDER_TELEPORTER: AndroidResearchDescription.Singleton by registrar.register("ender_teleporter") { + AndroidResearchDescription.singleton { + TranslatableComponent("otm.gui.power_cost_per_use", AndroidConfig.EnderTeleporter.ENERGY_COST.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.YELLOW)) } + } + + val FALL_DAMPENERS: AndroidResearchDescription.Leveled by registrar.register("fall_dampeners") { + AndroidResearchDescription.Leveled { _, _, level -> TranslatableComponent("otm.fall_dampeners.description", TextComponent("%.1f".format((AndroidConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL * level).toFloat().coerceAtLeast(0f).coerceAtMost(1f) * 100f)).withStyle(ChatFormatting.YELLOW)) } + } + + val ITEM_MAGNET: AndroidResearchDescription.Singleton by registrar.register("item_magnet") { + AndroidResearchDescription.singleton { TranslatableComponent("otm.gui.power_cost_per_tick", AndroidConfig.Magnet.POWER_DRAW.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.YELLOW)) } + } + + val JUMP_BOOST: AndroidResearchDescription.Singleton by registrar.register("jump_boost") { + AndroidResearchDescription.singleton { TranslatableComponent("otm.gui.power_cost_per_use", AndroidConfig.JumpBoost.ENERGY_COST.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.YELLOW)) } + } + + val SHOCKWAVE: AndroidResearchDescription.Singleton by registrar.register("shockwave") { + AndroidResearchDescription.singleton { TranslatableComponent("otm.gui.power_cost_per_use", AndroidConfig.Shockwave.ENERGY_COST.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.YELLOW)) } + } +} + +/** + * Instance, representing ready to use description populator + */ +interface AndroidResearchDescription { + /** + * Type, representing raw description populator in registry + */ + interface Type { + val codec: Codec + } + + abstract class Singleton : AndroidResearchDescription, Type { + override val codec = SingletonCodec(this) + override val type: Type<*> + get() = this + } + + class Leveled(val callback: (research: AndroidResearch, lines: MutableList, level: Int) -> Unit) : Type { + inner class Instance(val level: Int) : AndroidResearchDescription { + override fun addLines(research: AndroidResearch, lines: MutableList) { + callback.invoke(research, lines, level) + } + + override val type: Type<*> + get() = this@Leveled + } + + override val codec: Codec by lazy { + RecordCodecBuilder.create { + it.group(Codec.INT.fieldOf("level").forGetter(Instance::level)).apply(it, ::Instance) + } + } + } + + fun addLines(research: AndroidResearch, lines: MutableList) + val type: Type<*> + + companion object { + private val delegate = RegistryDelegate>("android_research_description") + + val registry by delegate + val registryKey get() = delegate.key + + val CODEC: Codec by lazy { + registry.codec.dispatch({ it.type }, { it.codec }) + } + + internal fun register(bus: IEventBus) { + bus.addListener(delegate::build) + } + + fun singleton(callback: (research: AndroidResearch) -> Component): Singleton { + return object : Singleton() { + override fun addLines(research: AndroidResearch, lines: MutableList) { + lines.add(callback.invoke(research)) + } + } + } + } +} + +object PlainAndroidResearchDescription : AndroidResearchDescription.Type { + data class Instance(val line: Component) : AndroidResearchDescription { + override fun addLines(research: AndroidResearch, lines: MutableList) { + lines.add(line.copy()) + } + + override val type: PlainAndroidResearchDescription + get() = PlainAndroidResearchDescription + } + + fun make(line: Component) = Instance(line) + + override val codec: Codec by lazy { + Codec + .either(ComponentCodec, simpleCodec(::Instance, Instance::line, ComponentCodec)) + .xmap({ c -> c.map({ Instance(it) }, { it }) }, { c -> Either.left(c.line) }) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchManager.kt index bddc41cd8..363d6e12d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchManager.kt @@ -6,7 +6,6 @@ import com.google.gson.JsonElement import com.google.gson.JsonObject import net.minecraft.client.server.IntegratedServer import net.minecraft.network.FriendlyByteBuf -import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation import net.minecraft.server.packs.resources.ResourceManager import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener @@ -23,8 +22,6 @@ import ru.dbotthepony.mc.otm.NULLABLE_MINECRAFT_SERVER import ru.dbotthepony.mc.otm.SERVER_IS_LIVE import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.data.SerializedFunctionRegistry import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.RegistryNetworkChannel import ru.dbotthepony.mc.otm.network.enqueueWork @@ -33,47 +30,7 @@ import ru.dbotthepony.mc.otm.onceServer import java.util.LinkedList import java.util.function.Supplier -typealias AndroidResultTransformer = SerializedFunctionRegistry.BoundFunction, Unit> -typealias ComponentSupplier = SerializedFunctionRegistry.BoundFunction - object AndroidResearchManager : SimpleJsonResourceReloadListener(GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(), "otm_android_research"), Iterable { - /** - * Feel free to register functions inside this thing from anywhere in your code - * (registration and querying is completely thread safe). - * - * Just make sure client and server has the same set of functions defined. - */ - val featureResultTransformers = SerializedFunctionRegistry, Unit>() - - /** - * Feel free to register functions inside this thing from anywhere in your code - * (registration and querying is completely thread safe). - * - * Just make sure client and server has the same set of functions defined. - */ - val descriptionFuncs = SerializedFunctionRegistry() - - fun descriptionFunc(name: ResourceLocation, base: String, vararg argument: Supplier): ComponentSupplier { - return descriptionFuncs.register(name) {-> - return@register TranslatableComponent(base, *argument.map { it.get() }.toTypedArray()) - }.bind() - } - - private var firedRegistrationEvent = false - - /** - * Event-style registration of serializable functions, for those who prefer/need it - * - * Fired *once* on [MinecraftForge.EVENT_BUS] before loading android research - */ - object RegisterFuncsEvent : Event() { - val manager get() = AndroidResearchManager - val featureResults by ::featureResultTransformers - val descriptionFunctions by ::descriptionFuncs - - fun descriptionFunc(name: ResourceLocation, base: String, vararg argument: Supplier): ComponentSupplier = AndroidResearchManager.descriptionFunc(name, base, *argument) - } - const val DIRECTORY = "otm_android_research" private val LOGGER = LogManager.getLogger() @@ -97,23 +54,11 @@ object AndroidResearchManager : SimpleJsonResourceReloadListener(GsonBuilder().s var researchMap: Map = mapOf() private set - internal fun fireRegistrationEvent() { - if (!firedRegistrationEvent) { - try { - MinecraftForge.EVENT_BUS.post(RegisterFuncsEvent) - } finally { - firedRegistrationEvent = true - } - } - } - override fun apply( jsonElementMap: Map, manager: ResourceManager, profiler: ProfilerFiller ) { - fireRegistrationEvent() - val builder = ImmutableMap.builder() for ((k, v) in jsonElementMap) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchResult.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchResult.kt new file mode 100644 index 000000000..39e43b686 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchResult.kt @@ -0,0 +1,180 @@ +package ru.dbotthepony.mc.otm.android + +import com.mojang.datafixers.util.Either +import com.mojang.serialization.Codec +import com.mojang.serialization.codecs.RecordCodecBuilder +import net.minecraft.resources.ResourceLocation +import net.minecraftforge.eventbus.api.IEventBus +import net.minecraftforge.registries.DeferredRegister +import org.apache.logging.log4j.LogManager +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.core.getValue +import ru.dbotthepony.mc.otm.data.SingletonCodec +import ru.dbotthepony.mc.otm.registry.AndroidFeatures +import ru.dbotthepony.mc.otm.registry.MRegistry +import ru.dbotthepony.mc.otm.registry.RegistryDelegate + +object AndroidResearchResults { + private val registrar = DeferredRegister.create(AndroidResearchResult.registryKey, OverdriveThatMatters.MOD_ID) + + init { + registrar.register("feature") { AndroidResearchResult.Feature.Companion } + registrar.register("feature_level") { AndroidResearchResult.FeatureLevel.Companion } + } + + private object NanobotsArmorStrength : AndroidResearchResult.Singleton { + override val codec: Codec = SingletonCodec(this) + override val type: AndroidResearchResult.Type<*> + get() = this + + override fun onResearched(research: AndroidResearch) { + val feature = research.capability.getFeature(AndroidFeatures.NANOBOTS_ARMOR) ?: return + feature.strength++ + } + + override fun onRefunded(research: AndroidResearch) { + val feature = research.capability.getFeature(AndroidFeatures.NANOBOTS_ARMOR) ?: return + feature.strength-- + } + } + + private object NanobotsArmorSpeed : AndroidResearchResult.Singleton { + override val codec: Codec = SingletonCodec(this) + override val type: AndroidResearchResult.Type<*> + get() = this + + override fun onResearched(research: AndroidResearch) { + val feature = research.capability.getFeature(AndroidFeatures.NANOBOTS_ARMOR) ?: return + feature.speed++ + } + + override fun onRefunded(research: AndroidResearch) { + val feature = research.capability.getFeature(AndroidFeatures.NANOBOTS_ARMOR) ?: return + feature.speed-- + } + } + + val NANOBOTS_ARMOR_STRENGTH: AndroidResearchResult.Singleton<*> by registrar.register("nanobots_armor_strength") { NanobotsArmorStrength } + val NANOBOTS_ARMOR_SPEED: AndroidResearchResult.Singleton<*> by registrar.register("nanobots_armor_speed") { NanobotsArmorSpeed } + + internal fun register(bus: IEventBus) { + registrar.register(bus) + } +} + +interface AndroidResearchResult { + interface Type { + val codec: Codec + } + + interface Singleton> : Type, AndroidResearchResult + + /** + * Adds specific android feature [id] to target, does nothing if target already has specified feature + */ + class Feature(val id: ResourceLocation, val optional: Boolean = false) : AndroidResearchResult { + val feature = MRegistry.ANDROID_FEATURES.getValue(id) ?: if (optional) null else throw NoSuchElementException("Unknown android feature $id") + + override val type: Type<*> + get() = Companion + + override fun onResearched(research: AndroidResearch) { + research.capability.addFeature(feature ?: return) + } + + override fun onRefunded(research: AndroidResearch) { + research.capability.removeFeature(feature ?: return) + } + + companion object : Type { + override val codec: Codec by lazy { + Codec + .either(ResourceLocation.CODEC, RecordCodecBuilder.create { // KT-52757 + it.group( + ResourceLocation.CODEC.fieldOf("id").forGetter(Feature::id), + Codec.BOOL.optionalFieldOf("optional", false).forGetter(Feature::optional) + ).apply(it, ::Feature) + }) + .xmap( + { c -> c.map({ Feature(it) }, { it }) }, + { c -> if (c.optional) Either.left(c.id) else Either.right(c) } + ) + } + } + } + + /** + * Increases level of specific android feature [id] by specified amount [levels] + */ + class FeatureLevel(val id: ResourceLocation, val optional: Boolean = false, val levels: Int = 1) : AndroidResearchResult { + val feature = MRegistry.ANDROID_FEATURES.getValue(id) ?: if (optional) null else throw NoSuchElementException("Unknown android feature $id") + + override val type: Type<*> + get() = Companion + + override fun onResearched(research: AndroidResearch) { + val get = research.capability.getFeature(feature ?: return) + + if (get == null) { + LOGGER.warn("Unable to advance level of android feature $id for ${research.ply} because they have no such android feature.") + } else { + get.level += levels + } + } + + override fun onRefunded(research: AndroidResearch) { + val get = research.capability.getFeature(feature ?: return) + + if (get == null) { + LOGGER.warn("Unable to decrease level of android feature $id for ${research.ply} because they have no such android feature.") + } else { + get.level += levels + } + } + + companion object : Type { + override val codec: Codec by lazy { + Codec + .either(ResourceLocation.CODEC, RecordCodecBuilder.create { // KT-52757 + it.group( + ResourceLocation.CODEC.fieldOf("id").forGetter(FeatureLevel::id), + Codec.BOOL.optionalFieldOf("optional", false).forGetter(FeatureLevel::optional), + Codec.INT.optionalFieldOf("levels", 1).forGetter(FeatureLevel::levels), + ).apply(it, ::FeatureLevel) + }) + .xmap( + { c -> c.map({ FeatureLevel(it) }, { it }) }, + { c -> if (c.optional && c.levels == 1) Either.left(c.id) else Either.right(c) } + ) + } + } + } + + val type: Type<*> + + /** + * Called when research is applied + */ + fun onResearched(research: AndroidResearch) {} + + /** + * Called when research is refunded + */ + fun onRefunded(research: AndroidResearch) {} + + companion object { + private val LOGGER = LogManager.getLogger() + private val delegate = RegistryDelegate>("android_research_result") + + val registry by delegate + val registryKey get() = delegate.key + + val CODEC: Codec by lazy { + registry.codec.dispatch({ it.type }, { it.codec }) + } + + internal fun register(bus: IEventBus) { + bus.addListener(delegate::build) + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt index bf8003e45..2d150b697 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt @@ -1,13 +1,13 @@ package ru.dbotthepony.mc.otm.android import com.google.common.collect.ImmutableList -import com.google.common.collect.Streams import com.google.gson.JsonArray import com.google.gson.JsonElement import com.google.gson.JsonObject import com.google.gson.JsonPrimitive import com.google.gson.JsonSyntaxException import com.google.gson.internal.bind.TypeAdapters +import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet import net.minecraft.network.FriendlyByteBuf import net.minecraft.network.chat.Component import net.minecraft.network.chat.ComponentContents @@ -28,10 +28,12 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.isActuallyEmpty import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.core.set -import ru.dbotthepony.mc.otm.core.toImmutableList import ru.dbotthepony.mc.otm.core.collect.stream +import ru.dbotthepony.mc.otm.core.fromJsonStrict +import ru.dbotthepony.mc.otm.core.toJsonStrict +import ru.dbotthepony.mc.otm.core.util.readJson +import ru.dbotthepony.mc.otm.core.util.writeJson import ru.dbotthepony.mc.otm.isClient -import ru.dbotthepony.mc.otm.registry.MRegistry import java.util.LinkedList import java.util.stream.Stream import kotlin.collections.ArrayList @@ -39,7 +41,7 @@ import kotlin.collections.HashSet private fun findPrerequisites( initial: Collection, - add: MutableSet = HashSet(), + add: MutableSet = ObjectOpenHashSet(), top: Boolean = true ): Set { for (value in initial) { @@ -55,7 +57,7 @@ private fun findPrerequisites( private fun findAllPrerequisites( initial: Collection, - add: MutableSet = HashSet(), + add: MutableSet = ObjectOpenHashSet(), ): Set { for (value in initial) { add.add(value) @@ -67,7 +69,7 @@ private fun findAllPrerequisites( private fun findAllChildren( initial: Collection, - add: MutableSet = HashSet(), + add: MutableSet = ObjectOpenHashSet(), ): Set { for (value in initial) { add.add(value) @@ -83,10 +85,9 @@ class AndroidResearchType( blockedBy: Collection, items: Collection>, - features: Collection, + results: Collection, - descriptionLines: Collection, - descriptionSuppliers: Collection = listOf(), + description: Collection, val experienceLevels: Int = 0, private val customName: Component? = null, @@ -145,74 +146,6 @@ class AndroidResearchType( } } - data class FeatureReference( - val id: ResourceLocation, - val level: Int = 0, - val isRigid: Boolean, - val transformersUp: Collection = listOf(), - val transformersDown: Collection = listOf(), - ) { - fun toJson(): JsonObject { - return JsonObject().also { - it["id"] = JsonPrimitive(id.toString()) - it["level"] = JsonPrimitive(level) - it["is_rigid"] = JsonPrimitive(isRigid) - it["functions_up"] = JsonArray().also { - for (transformer in transformersUp) { - it.add(transformer.toJson()) - } - } - - it["functions_down"] = JsonArray().also { - for (transformer in transformersDown) { - it.add(transformer.toJson()) - } - } - } - } - - fun toNetwork(buff: FriendlyByteBuf) { - buff.writeUtf(id.toString()) - buff.writeVarInt(level) - buff.writeBoolean(isRigid) - buff.writeCollection(transformersUp) { a, b -> b.toNetwork(a) } - buff.writeCollection(transformersDown) { a, b -> b.toNetwork(a) } - } - - companion object { - fun fromNetwork(buff: FriendlyByteBuf): FeatureReference { - return FeatureReference( - ResourceLocation(buff.readUtf()), - buff.readVarInt(), - buff.readBoolean(), - buff.readCollection({ LinkedList() }, AndroidResearchManager.featureResultTransformers::fromNetwork).filterNotNull().toImmutableList(), - buff.readCollection({ LinkedList() }, AndroidResearchManager.featureResultTransformers::fromNetwork).filterNotNull().toImmutableList() - ) - } - - fun fromJson(value: JsonElement): FeatureReference { - if (value is JsonPrimitive) { - return FeatureReference(ResourceLocation(value.asString), 0, true) - } else if (value is JsonObject) { - return FeatureReference( - ResourceLocation((value["id"] as? JsonPrimitive ?: throw JsonSyntaxException("Invalid `id` value")).asString), - (value["level"] as JsonPrimitive?)?.asInt ?: 0, - (value["is_rigid"] as JsonPrimitive?)?.asBoolean ?: true, - (value["functions_up"] as JsonArray? ?: JsonArray()).stream().map { AndroidResearchManager.featureResultTransformers.fromJson(it) }.filter { it != null }.collect(ImmutableList.toImmutableList()), - (value["functions_down"] as JsonArray? ?: JsonArray()).stream().map { AndroidResearchManager.featureResultTransformers.fromJson(it) }.filter { it != null }.collect(ImmutableList.toImmutableList()), - ) - } else { - throw JsonSyntaxException("Unknown element type ${value::class.qualifiedName}") - } - } - } - } - - data class ResolvedFeature( - val feature: AndroidFeatureType<*>, - val level: Int, - ) - val researchTreeDepth: Int by lazy { if (flatPrerequisites.isEmpty()) { return@lazy 0 @@ -248,31 +181,11 @@ class AndroidResearchType( ImmutableList.copyOf(this.blockedBy.mapNotNull { AndroidResearchManager[it.id].also { e -> if (e == null && it.isRigid) throw NoSuchElementException("Unable to find research ${it.id}") } }) } - val features: List = ImmutableList.copyOf(features) - - val resolvedFeatures: List by lazy { - ImmutableList.copyOf(features.mapNotNull { - MRegistry.ANDROID_FEATURES.getValue(it.id) - .let { e -> if (e == null && it.isRigid) - throw NoSuchElementException("Unable to find research ${it.id}") - else if (e != null) - ResolvedFeature(e, it.level) - else - null } }) - } - private val definedItems: List> = ImmutableList.copyOf(items) + val results: ImmutableList = ImmutableList.copyOf(results) val items: Stream> get() = definedItems.stream().filter { !it.first.isActuallyEmpty } - - private val descriptionLines: List = ImmutableList.copyOf(descriptionLines.map { it.copy() }) - - private val descriptionSuppliers: List = ImmutableList.copyOf(descriptionSuppliers) - - /** - * Stream containing copies of original [Component]s in list - */ - val description: Stream get() = Streams.concat(descriptionLines.stream().map { it.copy() }, descriptionSuppliers.stream().map { it.apply(Unit) }) + val description: ImmutableList = ImmutableList.copyOf(description) /** * Flat list of research preceding this research. @@ -469,14 +382,11 @@ class AndroidResearchType( fun toJson(): JsonElement { return JsonObject().also { - // it["id"] = JsonPrimitive(id.toString()) - it["prerequisites"] = JsonArray().also { for (value in prerequisites) it.add(value.toJson()) } it["blocked_by"] = JsonArray().also { for (value in blockedBy) it.add(value.toJson()) } it["required_items"] = JsonArray().also { for (item in definedItems) it.add(JsonObject().also { it["count"] = JsonPrimitive(item.second); it["ingredient"] = item.first.toJson() }) } - it["feature_result"] = JsonArray().also { for (feature in features) it.add(feature.toJson()) } - it["description"] = JsonArray().also { for (line in descriptionLines) it.add(Component.Serializer.toJsonTree(line)) } - it["description_funcs"] = JsonArray().also { for (line in descriptionSuppliers) it.add(line.toJson()) } + it["results"] = JsonArray().also { for (result in results) it.add(AndroidResearchResult.CODEC.toJsonStrict(result)) } + it["description"] = JsonArray().also { for (line in description) it.add(AndroidResearchDescription.CODEC.toJsonStrict(line)) } it["experience"] = JsonPrimitive(experienceLevels) if (skinIcon != null) { @@ -498,7 +408,6 @@ class AndroidResearchType( } fun validate() { - resolvedFeatures resolvedBlockedBy resolvedPrerequisites } @@ -508,9 +417,8 @@ class AndroidResearchType( buff.writeCollection(prerequisites) { a, b -> b.toNetwork(a) } buff.writeCollection(blockedBy) { a, b -> b.toNetwork(a) } buff.writeCollection(definedItems) { a, b -> b.first.toNetwork(a); a.writeVarInt(b.second) } - buff.writeCollection(features) { a, b -> b.toNetwork(a) } - buff.writeCollection(descriptionLines) { a, b -> a.writeComponent(b) } - buff.writeCollection(descriptionSuppliers) { a, b -> b.toNetwork(a) } + buff.writeCollection(results) { a, b -> a.writeJson(AndroidResearchResult.CODEC.toJsonStrict(b)) } + buff.writeCollection(description) { a, b -> a.writeJson(AndroidResearchDescription.CODEC.toJsonStrict(b)) } buff.writeVarInt(experienceLevels) buff.writeBoolean(customName != null) @@ -532,9 +440,8 @@ class AndroidResearchType( val prerequisites = buff.readCollection({ LinkedList() }, Reference::fromNetwork) val blockedBy = buff.readCollection({ LinkedList() }, Reference::fromNetwork) val items = buff.readCollection({ LinkedList() }, { Ingredient.fromNetwork(it) to it.readVarInt() }) - val features = buff.readCollection({ LinkedList() }, FeatureReference::fromNetwork) - val descriptionLines = buff.readCollection({ LinkedList() }, FriendlyByteBuf::readComponent) - val descriptionSuppliers = buff.readCollection({ LinkedList() }, { AndroidResearchManager.descriptionFuncs.fromNetwork(it) }) + val results = buff.readCollection({ LinkedList() }, { AndroidResearchResult.CODEC.fromJsonStrict(it.readJson()) }) + val description = buff.readCollection({ LinkedList() }, { AndroidResearchDescription.CODEC.fromJsonStrict(it.readJson()) }) val experienceLevels = buff.readVarInt() val customName = if (buff.readBoolean()) { @@ -566,9 +473,8 @@ class AndroidResearchType( prerequisites = prerequisites, blockedBy = blockedBy, items = items, - features = features, - descriptionLines = descriptionLines, - descriptionSuppliers = descriptionSuppliers.filterNotNull(), + results = results, + description = description, experienceLevels = experienceLevels, customName = customName, iconText = iconTextValue, @@ -587,7 +493,6 @@ class AndroidResearchType( val items = value["required_items"] as JsonArray? ?: JsonArray() val features = value["feature_result"] as JsonArray? ?: JsonArray() val description = value["description"] as JsonArray? ?: JsonArray() - val description_funcs = value["description_funcs"] as JsonArray? ?: JsonArray() val experience = value["experience"]?.asInt ?: 0 val customName = value["custom_name"]?.let(Component.Serializer::fromJson) val iconText = value["icon_text"]?.let(Component.Serializer::fromJson) @@ -598,15 +503,12 @@ class AndroidResearchType( id = id, prerequisites = prerequisites.stream().map { Reference.fromJson(it) }.toList(), blockedBy = blocked_by.stream().map { Reference.fromJson(it) }.toList(), - features = features.stream().map { FeatureReference.fromJson(it) }.toList(), + results = features.stream().map { AndroidResearchResult.CODEC.fromJsonStrict(it) }.toList(), items = items.stream() .map { it as? JsonObject ?: throw JsonSyntaxException("One of items is not an JsonObject") } .map { Ingredient.fromJson(it["ingredient"] ?: throw JsonSyntaxException("Missing ingredient key")) to (it["count"]?.asInt ?: throw JsonSyntaxException("Missing count key")) } .toList(), - descriptionLines = description.stream().map { Component.Serializer.fromJson(it) }.toList() as List, - descriptionSuppliers = description_funcs.stream() - .map { AndroidResearchManager.descriptionFuncs.fromJson(it) ?: throw NullPointerException("$id is missing description supplier function or it is invalid! JSON: $it") } - .toList() as List, + description = description.stream().map { AndroidResearchDescription.CODEC.fromJsonStrict(it) }.toList(), experienceLevels = experience, customName = customName, iconText = iconText, @@ -621,18 +523,18 @@ class AndroidResearchType( val id: ResourceLocation, var experience: Int = 0, var customName: Component? = null, - var description: MutableList? = null, - var descriptionSuppliers: MutableList? = null, + description: MutableList? = null, var itemIcon: Item? = null, var skinIcon: AbstractMatterySprite? = null, var iconText: Component? = null, ) { + val description = ArrayList(description ?: listOf()) + val results = ArrayList() + private val items = ArrayList>() private val prerequisites = ArrayList() private val blockers = ArrayList() - private val features = ArrayList() - fun withIconText(icon: Component? = null): Builder { this.iconText = icon return this @@ -661,19 +563,20 @@ class AndroidResearchType( return this } - fun withDescription(): Builder { - this.description = mutableListOf(TranslatableComponent("android_research.${id.namespace}.${id.path}.description")) + fun clearDescription(): Builder { + this.description.clear() return this } - fun withDescription(range: IntRange): Builder { - val result = ArrayList() + fun withDescription(): Builder { + return withDescription(TranslatableComponent("android_research.${id.namespace}.${id.path}.description")) + } + fun withDescription(range: IntRange): Builder { for (i in range) { - result.add(TranslatableComponent("android_research.${id.namespace}.${id.path}.description$i")) + withDescription(TranslatableComponent("android_research.${id.namespace}.${id.path}.description$i")) } - this.description = result return this } @@ -683,73 +586,21 @@ class AndroidResearchType( } fun withDescription(vararg description: Component): Builder { - this.description = description.toMutableList() + for (component in description) + withDescription(PlainAndroidResearchDescription.Instance(component)) + return this } fun withDescription(description: Collection): Builder { - this.description = ArrayList(description.size).also { it.addAll(description) } + for (component in description) + withDescription(PlainAndroidResearchDescription.Instance(component)) + return this } - fun appendDescription(range: IntRange): Builder { - val result = this.description ?: ArrayList() - - for (i in range) { - result.add(TranslatableComponent("android_research.${id.namespace}.${id.path}.description$i")) - } - - this.description = result - return this - } - - fun appendDescription(description: Component): Builder { - this.description = (this.description ?: mutableListOf()).also { it.add(description) } - return this - } - - fun appendDescription(vararg description: Component): Builder { - this.description = (this.description ?: mutableListOf()).also { it.addAll(description) } - return this - } - - fun appendDescription(description: Collection): Builder { - this.description = (this.description ?: mutableListOf()).also { it.addAll(description) } - return this - } - - fun withDescription(vararg description: ComponentSupplier): Builder { - this.descriptionSuppliers = description.toMutableList() - return this - } - - fun withDescriptionSupplier(description: Collection): Builder { - this.descriptionSuppliers = ArrayList(description.size).also { it.addAll(description) } - return this - } - - fun appendDescription(description: ComponentSupplier): Builder { - this.descriptionSuppliers = (this.descriptionSuppliers ?: mutableListOf()).also { it.add(description) } - return this - } - - fun appendDescriptionSupplier(description: ComponentSupplier): Builder { - this.descriptionSuppliers = (this.descriptionSuppliers ?: mutableListOf()).also { it.add(description) } - return this - } - - fun appendDescription(vararg description: ComponentSupplier): Builder { - this.descriptionSuppliers = (this.descriptionSuppliers ?: mutableListOf()).also { it.addAll(description) } - return this - } - - fun appendDescriptionSupplier(vararg description: ComponentSupplier): Builder { - this.descriptionSuppliers = (this.descriptionSuppliers ?: mutableListOf()).also { it.addAll(description) } - return this - } - - fun appendDescriptionSupplier(description: Collection): Builder { - this.descriptionSuppliers = (this.descriptionSuppliers ?: mutableListOf()).also { it.addAll(description) } + fun withDescription(vararg description: AndroidResearchDescription): Builder { + this.description.addAll(description) return this } @@ -776,43 +627,25 @@ class AndroidResearchType( fun addPrerequisite(type: AndroidResearchType, rigid: Boolean = true) = addPrerequisite(type.id, rigid) fun addBlocker(type: AndroidResearchType, rigid: Boolean = true) = addBlocker(type.id, rigid) - @JvmOverloads - fun addFeatureResult( - id: ResourceLocation, - level: Int = 0, - rigid: Boolean = false, - transformersUp: Collection = listOf(), - transformersDown: Collection = listOf(), - ): Builder { - features.add(FeatureReference(id, level, rigid, transformersUp, transformersDown)) + fun addResult(result: AndroidResearchResult): Builder { + results.add(result) return this } - @JvmOverloads - fun addFeatureResult( - feature: AndroidFeatureType<*>, - level: Int = 0, - rigid: Boolean = true, - transformersUp: Collection = listOf(), - transformersDown: Collection = listOf(), - ): Builder { - features.add(FeatureReference(feature.registryName ?: throw NullPointerException("Feature $feature does not have registry name"), level, rigid, transformersUp, transformersDown)) - return this + fun addFeatureResult(id: ResourceLocation, optional: Boolean = false): Builder { + return addResult(AndroidResearchResult.Feature(id, optional)) } - fun addFeatureResult( - id: ResourceLocation, - rigid: Boolean = false, - transformersUp: Collection = listOf(), - transformersDown: Collection = listOf(), - ): Builder { - features.add(FeatureReference(id, 0, rigid, transformersUp, transformersDown)) - return this + fun addFeatureResult(feature: AndroidFeatureType<*>, optional: Boolean = false): Builder { + return addFeatureResult(feature.registryName!!, optional) } - fun addFeatureResult(ref: FeatureReference): Builder { - features.add(ref) - return this + fun addFeatureLevel(id: ResourceLocation, optional: Boolean = false, levels: Int = 1): Builder { + return addResult(AndroidResearchResult.FeatureLevel(id, optional, levels)) + } + + fun addFeatureLevel(feature: AndroidFeatureType<*>, optional: Boolean = false, levels: Int = 1): Builder { + return addFeatureLevel(feature.registryName!!, optional, levels) } fun addItem(cost: ItemStack): Builder { @@ -844,9 +677,8 @@ class AndroidResearchType( prerequisites = prerequisites, blockedBy = blockers, items = items, - features = features, - descriptionLines = description ?: listOf(), - descriptionSuppliers = descriptionSuppliers ?: listOf(), + results = results, + description = description, experienceLevels = experience, customName = customName, skinIcon = skinIcon?.toJson(), diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt index b8a30b8f5..5e5931bbb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.android.feature import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack -import net.minecraft.ChatFormatting import net.minecraft.client.Camera import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.renderer.LevelRenderer @@ -28,25 +27,22 @@ import net.minecraftforge.event.entity.living.LivingDeathEvent import ru.dbotthepony.mc.otm.NULLABLE_MINECRAFT_SERVER import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.android.AndroidActiveFeature -import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.capability.matteryPlayer -import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.render.ResearchIcons -import ru.dbotthepony.mc.otm.client.render.sprite import ru.dbotthepony.mc.otm.client.render.linesIgnoreZRenderType +import ru.dbotthepony.mc.otm.client.render.sprite import ru.dbotthepony.mc.otm.config.AndroidConfig +import ru.dbotthepony.mc.otm.core.genericPositions +import ru.dbotthepony.mc.otm.core.holder +import ru.dbotthepony.mc.otm.core.isFall import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.math.asVector import ru.dbotthepony.mc.otm.core.math.component1 import ru.dbotthepony.mc.otm.core.math.component2 import ru.dbotthepony.mc.otm.core.math.component3 -import ru.dbotthepony.mc.otm.core.util.formatPower -import ru.dbotthepony.mc.otm.core.genericPositions -import ru.dbotthepony.mc.otm.core.holder -import ru.dbotthepony.mc.otm.core.isFall import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.core.math.rotateXDegrees import ru.dbotthepony.mc.otm.core.math.rotateYDegrees @@ -54,7 +50,6 @@ import ru.dbotthepony.mc.otm.core.math.shortestDistanceBetween import ru.dbotthepony.mc.otm.core.math.times import ru.dbotthepony.mc.otm.milliTime import ru.dbotthepony.mc.otm.registry.AndroidFeatures -import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.triggers.EnderTeleporterFallDeathTrigger import java.util.* import kotlin.math.sin @@ -399,12 +394,6 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv val SPRITE = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/item/black_hole.png").sprite(0f, 0f, 16f, 16f, 16f, 16f) - val POWER_COST_DESCRIPTION = - AndroidResearchManager.descriptionFunc( - ResourceLocation(OverdriveThatMatters.MOD_ID, MNames.ENDER_TELEPORTER), - "otm.gui.power_cost_per_use", - { AndroidConfig.EnderTeleporter.ENERGY_COST.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.YELLOW) }) - fun onEntityDeath(event: LivingDeathEvent) { val android = event.entity.matteryPlayer ?: return val server = NULLABLE_MINECRAFT_SERVER ?: return diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt index 5cc0c71e7..dbf0004d8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt @@ -35,10 +35,4 @@ class FallDampenersFeature(capability: MatteryPlayerCapability) : AndroidFeature } } } - - companion object { - val DESCRIPTION = AndroidResearchManager.descriptionFuncs.register(ResourceLocation(OverdriveThatMatters.MOD_ID, MNames.FALL_DAMPENERS)) { level: Int -> - TranslatableComponent("otm.fall_dampeners.description", TextComponent("%.1f".format((AndroidConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL * level).toFloat().coerceAtLeast(0f).coerceAtMost(1f) * 100f)).withStyle(ChatFormatting.YELLOW)) - } - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt index 4c7160245..46e9c4477 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt @@ -132,12 +132,4 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float) { ResearchIcons.ICON_ITEM_MAGNET.render(graphics, x, y, width, height) } - - companion object { - val POWER_COST_DESCRIPTION = - AndroidResearchManager.descriptionFunc(ResourceLocation( - OverdriveThatMatters.MOD_ID, MNames.ITEM_MAGNET), - "otm.gui.power_cost_per_tick", - { AndroidConfig.Magnet.POWER_DRAW.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.YELLOW) }) - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt index 555bd86e6..4d3044802 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt @@ -125,13 +125,4 @@ class JumpBoostFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF RenderSystem.setShaderColor(1f, 1f, 1f, 1f) } } - - - companion object { - val POWER_COST_DESCRIPTION = - AndroidResearchManager.descriptionFunc( - ResourceLocation(OverdriveThatMatters.MOD_ID, MNames.JUMP_BOOST), - "otm.gui.power_cost_per_use", - { AndroidConfig.JumpBoost.ENERGY_COST.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.YELLOW) }) - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt index b9a17f54a..8dc1f81db 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt @@ -106,33 +106,5 @@ class NanobotsArmorFeature(android: MatteryPlayerCapability) : AndroidFeature(An 0.45f, 0.6f, ) - - val STRENGTH_TRANSFORMER_UP = AndroidResearchManager.featureResultTransformers.register(ResourceLocation(OverdriveThatMatters.MOD_ID, "nanobots_armor_strength_up")) - { level: Int -> - if (second is NanobotsArmorFeature && (second as NanobotsArmorFeature).strength == level - 1) { - (second as NanobotsArmorFeature).strength = level - } - } - - val STRENGTH_TRANSFORMER_DOWN = AndroidResearchManager.featureResultTransformers.register(ResourceLocation(OverdriveThatMatters.MOD_ID, "nanobots_armor_strength_down")) - { level: Int -> - if (second is NanobotsArmorFeature && (second as NanobotsArmorFeature).strength == level) { - (second as NanobotsArmorFeature).strength = level - 1 - } - } - - val SPEED_TRANSFORMER_UP = AndroidResearchManager.featureResultTransformers.register(ResourceLocation(OverdriveThatMatters.MOD_ID, "nanobots_armor_speed_up")) - { level: Int -> - if (second is NanobotsArmorFeature && (second as NanobotsArmorFeature).speed == level - 1) { - (second as NanobotsArmorFeature).speed = level - } - } - - val SPEED_TRANSFORMER_DOWN = AndroidResearchManager.featureResultTransformers.register(ResourceLocation(OverdriveThatMatters.MOD_ID, "nanobots_armor_speed_down")) - { level: Int -> - if (second is NanobotsArmorFeature && (second as NanobotsArmorFeature).speed == level) { - (second as NanobotsArmorFeature).speed = level - 1 - } - } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt index cc415b297..ce0fbb20c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt @@ -251,12 +251,4 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF RenderSystem.setShaderColor(1f, 1f, 1f, 1f) } } - - companion object { - val POWER_COST_DESCRIPTION = - AndroidResearchManager.descriptionFunc( - ResourceLocation(OverdriveThatMatters.MOD_ID, MNames.SHOCKWAVE), - "otm.gui.power_cost_per_use", - { AndroidConfig.Shockwave.ENERGY_COST.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.YELLOW) }) - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codecs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codecs.kt new file mode 100644 index 000000000..ef688c49c --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codecs.kt @@ -0,0 +1,33 @@ +package ru.dbotthepony.mc.otm.data + +import com.mojang.serialization.Codec +import com.mojang.serialization.codecs.RecordCodecBuilder +import kotlin.reflect.KProperty1 + + +fun simpleCodec(factory: (T1) -> V, field1: KProperty1, codec1: Codec): Codec { + return RecordCodecBuilder.create { + it.group( + codec1.fieldOf(field1.name).forGetter(field1::get) + ).apply(it, factory) + } +} + +fun simpleCodec(factory: (T1, T2) -> V, field1: KProperty1, codec1: Codec, field2: KProperty1, codec2: Codec): Codec { + return RecordCodecBuilder.create { + it.group( + codec1.fieldOf(field1.name).forGetter(field1::get), + codec2.fieldOf(field2.name).forGetter(field2::get), + ).apply(it, factory) + } +} + +fun simpleCodec(factory: (T1, T2, T3) -> V, field1: KProperty1, codec1: Codec, field2: KProperty1, codec2: Codec, field3: KProperty1, codec3: Codec): Codec { + return RecordCodecBuilder.create { + it.group( + codec1.fieldOf(field1.name).forGetter(field1::get), + codec2.fieldOf(field2.name).forGetter(field2::get), + codec3.fieldOf(field3.name).forGetter(field3::get), + ).apply(it, factory) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComponentCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComponentCodec.kt new file mode 100644 index 000000000..9efaeb74f --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComponentCodec.kt @@ -0,0 +1,25 @@ +package ru.dbotthepony.mc.otm.data + +import com.google.gson.JsonSyntaxException +import com.mojang.datafixers.util.Pair +import com.mojang.serialization.Codec +import com.mojang.serialization.DataResult +import com.mojang.serialization.DynamicOps +import com.mojang.serialization.JsonOps +import net.minecraft.network.chat.Component + +object ComponentCodec : Codec { + override fun encode(input: Component, ops: DynamicOps, prefix: T): DataResult { + return DataResult.success(JsonOps.INSTANCE.convertTo(ops, Component.Serializer.toJsonTree(input))) + } + + override fun decode(ops: DynamicOps, input: T): DataResult> { + val value = ops.convertTo(JsonOps.INSTANCE, input) + + try { + return DataResult.success(Pair(Component.Serializer.fromJson(value), ops.empty())) + } catch (err: JsonSyntaxException) { + return DataResult.error { err.message } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/SerializedFunctionRegistry.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/SerializedFunctionRegistry.kt deleted file mode 100644 index 0a916f07b..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/SerializedFunctionRegistry.kt +++ /dev/null @@ -1,225 +0,0 @@ -package ru.dbotthepony.mc.otm.data - -import com.google.gson.Gson -import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonDeserializer -import com.google.gson.JsonElement -import com.google.gson.JsonObject -import com.google.gson.JsonPrimitive -import com.google.gson.JsonSerializationContext -import com.google.gson.JsonSerializer -import com.google.gson.JsonSyntaxException -import com.google.gson.TypeAdapter -import com.google.gson.internal.bind.TypeAdapters -import com.google.gson.stream.JsonReader -import com.google.gson.stream.JsonWriter -import io.netty.buffer.ByteBufInputStream -import io.netty.buffer.ByteBufOutputStream -import it.unimi.dsi.fastutil.io.FastByteArrayInputStream -import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream -import net.minecraft.nbt.NbtAccounter -import net.minecraft.network.FriendlyByteBuf -import net.minecraft.resources.ResourceLocation -import ru.dbotthepony.mc.otm.core.util.readType -import ru.dbotthepony.mc.otm.core.util.readVarIntLE -import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.core.set -import ru.dbotthepony.mc.otm.core.util.writeType -import ru.dbotthepony.mc.otm.core.util.writeVarIntLE -import java.io.DataInputStream -import java.io.DataOutputStream -import java.lang.reflect.Type -import java.util.Base64 -import java.util.Collections -import java.util.LinkedList - -class SerializedFunctionRegistry(val gson: Gson = Gson()) : JsonSerializer>, JsonDeserializer>, TypeAdapter>() { - fun interface AnonymousFunction { - fun invoke(receiver: R, arguments: List): T - } - - data class BoundFunction( - val function: Function, - val arguments: List - ) : java.util.function.Function { - fun toJson(): JsonElement { - return JsonObject().also { - it["function"] = function.toJson() - val stream = FastByteArrayOutputStream() - val dataStream = DataOutputStream(stream) - - stream.writeVarIntLE(arguments.size) - - for (argument in arguments) { - dataStream.writeType(argument) - } - - it["arguments"] = JsonPrimitive(Base64.getEncoder().encode(stream.array.copyOfRange(0, stream.length)).toString(Charsets.UTF_8)) - } - } - - fun toNetwork(buff: FriendlyByteBuf) { - function.toNetwork(buff) - - val stream = DataOutputStream(ByteBufOutputStream(buff)) - stream.writeVarIntLE(arguments.size) - for (argument in arguments) { - stream.writeType(argument) - } - } - - override fun apply(t: R): T { - return function.body.invoke(t, arguments) - } - } - - data class Function( - val id: ResourceLocation, - val body: AnonymousFunction, - val registry: SerializedFunctionRegistry - ) { - fun bind(vararg arguments: Any?): BoundFunction { - validate(arguments.iterator().withIndex()) - return BoundFunction(this, Collections.unmodifiableList(LinkedList().also { it.addAll(arguments) })) - } - - fun bind(arguments: List): BoundFunction { - validate(arguments.iterator().withIndex()) - return BoundFunction(this, Collections.unmodifiableList(LinkedList().also { it.addAll(arguments) })) - } - - fun toJson(): JsonElement { - return JsonPrimitive(id.toString()) - } - - fun toNetwork(buff: FriendlyByteBuf) { - buff.writeUtf(id.toString()) - } - - companion object { - private fun validate(iterator: Iterator>) { - try { - val stream = DataOutputStream(FastByteArrayOutputStream()) - - for ((i, argument) in iterator) { - try { - stream.writeType(argument) - } catch(err: Exception) { - throw IllegalArgumentException("Argument at $i can not be serialized", err) - } - } - } catch(err: Exception) { - throw IllegalArgumentException("Argument list validation failed", err) - } - } - } - } - - private val map = HashMap>() - - fun register(id: ResourceLocation, function: AnonymousFunction): Function { - synchronized(map) { - return map.computeIfAbsent(id) { Function(id, function, this) } - } - } - - fun register(id: ResourceLocation, function: R.() -> T): Function { - return register(id, AnonymousFunction { r, args -> - check(args.isEmpty()) { "Invalid amount of arguments. No arguments are required" } - function.invoke(r) - }) - } - - inline fun register(id: ResourceLocation, noinline function: R.(A) -> T): Function { - return register(id, AnonymousFunction { r, args -> - check(args.size == 1) { "Invalid amount of arguments. 1 is required" } - function.invoke( - r, - args[0] as? A ?: throw ClassCastException("Argument at 0 is supposed to be ${A::class.qualifiedName}, ${args[0]?.let { it::class.qualifiedName }} given") - ) - }) - } - - inline fun register(id: ResourceLocation, noinline function: R.(A, B) -> T): Function { - return register(id, AnonymousFunction { r, args -> - check(args.size == 2) { "Invalid amount of arguments. 2 is required" } - - function.invoke( - r, - args[0] as? A ?: throw ClassCastException("Argument at 0 is supposed to be ${A::class.qualifiedName}, ${args[0]?.let { it::class.qualifiedName }} given"), - args[1] as? B ?: throw ClassCastException("Argument at 1 is supposed to be ${B::class.qualifiedName}, ${args[1]?.let { it::class.qualifiedName }} given"), - ) - }) - } - - inline fun register(id: ResourceLocation, noinline function: R.(A, B, C) -> T): Function { - return register(id, AnonymousFunction { r, args -> - check(args.size == 3) { "Invalid amount of arguments. 3 is required" } - - function.invoke( - r, - args[0] as? A ?: throw ClassCastException("Argument at 0 is supposed to be ${A::class.qualifiedName}, ${args[0]?.let { it::class.qualifiedName }} given"), - args[1] as? B ?: throw ClassCastException("Argument at 1 is supposed to be ${B::class.qualifiedName}, ${args[1]?.let { it::class.qualifiedName }} given"), - args[2] as? C ?: throw ClassCastException("Argument at 2 is supposed to be ${B::class.qualifiedName}, ${args[2]?.let { it::class.qualifiedName }} given"), - ) - }) - } - - fun get(id: ResourceLocation): Function? { - synchronized(map) { - return map[id] - } - } - - fun fromNetwork(buff: FriendlyByteBuf): BoundFunction? { - val id = ResourceLocation(buff.readUtf()) - val stream = DataInputStream(ByteBufInputStream(buff)) - - val arguments = LinkedList() - val sizeLimit = NbtAccounter(1L shl 18 /* 256 KiB */) - - for (i in 0 until stream.readVarIntLE(sizeLimit)) { - arguments.add(stream.readType(sizeLimit)) - } - - return map[id]?.bind(arguments) - } - - fun fromJson(value: JsonElement): BoundFunction? { - if (value !is JsonObject) { - return null - } - - val id = value["function"]?.asString ?: return null - val argumentString = value["arguments"]?.asString ?: return null - val stream = DataInputStream(FastByteArrayInputStream(Base64.getDecoder().decode(argumentString))) - val arguments = LinkedList() - val sizeLimit = NbtAccounter(1L shl 18 /* 256 KiB */) - - for (i in 0 until stream.readVarIntLE(sizeLimit)) { - arguments.add(stream.readType(sizeLimit)) - } - - return map[ResourceLocation(id)]?.bind(arguments) - } - - override fun serialize(src: BoundFunction, typeOfSrc: Type, context: JsonSerializationContext): JsonElement { - return src.toJson() - } - - override fun deserialize( - json: JsonElement, - typeOfT: Type, - context: JsonDeserializationContext - ): BoundFunction { - return fromJson(json) ?: throw JsonSyntaxException("Function is invalid") - } - - override fun write(out: JsonWriter, value: BoundFunction) { - TypeAdapters.JSON_ELEMENT.write(out, value.toJson()) - } - - override fun read(`in`: JsonReader): BoundFunction { - return fromJson(TypeAdapters.JSON_ELEMENT.read(`in`)) ?: throw JsonSyntaxException("Function is invalid") - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/SingletonCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/SingletonCodec.kt new file mode 100644 index 000000000..eb2ade209 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/SingletonCodec.kt @@ -0,0 +1,16 @@ +package ru.dbotthepony.mc.otm.data + +import com.mojang.datafixers.util.Pair +import com.mojang.serialization.Codec +import com.mojang.serialization.DataResult +import com.mojang.serialization.DynamicOps + +class SingletonCodec(val value: V) : Codec { + override fun encode(input: V, ops: DynamicOps, prefix: T): DataResult { + return DataResult.success(ops.empty()) + } + + override fun decode(ops: DynamicOps, input: T? /* Так то, оно должно быть null */): DataResult> { + return DataResult.success(Pair(value, ops.empty())) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/AndroidFeatures.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/AndroidFeatures.kt index d729b079d..c1ee11123 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/AndroidFeatures.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/AndroidFeatures.kt @@ -10,20 +10,20 @@ import ru.dbotthepony.mc.otm.android.feature.* object AndroidFeatures { private val registry = DeferredRegister.create(MRegistry.ANDROID_FEATURES_KEY, OverdriveThatMatters.MOD_ID) - val AIR_BAGS: AndroidFeatureType<*> by registry.register(MNames.AIR_BAGS) { AndroidFeatureType(::DummyAndroidFeature) } - val STEP_ASSIST: AndroidFeatureType<*> by registry.register(MNames.STEP_ASSIST) { AndroidFeatureType(::StepAssistFeature) } - val LIMB_OVERCLOCKING: AndroidFeatureType<*> by registry.register(MNames.LIMB_OVERCLOCKING) { AndroidFeatureType(::LimbOverclockingFeature) } - val ATTACK_BOOST: AndroidFeatureType<*> by registry.register(MNames.ATTACK_BOOST) { AndroidFeatureType(::AttackBoostFeature) } - val NANOBOTS_REGENERATION: AndroidFeatureType<*> by registry.register(MNames.NANOBOTS_REGENERATION) { AndroidFeatureType(::NanobotsRegenerationFeature) } - val NANOBOTS_ARMOR: AndroidFeatureType<*> by registry.register(MNames.NANOBOTS_ARMOR) { AndroidFeatureType(::NanobotsArmorFeature) } - val EXTENDED_REACH: AndroidFeatureType<*> by registry.register(MNames.EXTENDED_REACH) { AndroidFeatureType(::ExtendedReachFeature) } - val NIGHT_VISION: AndroidFeatureType<*> by registry.register(MNames.NIGHT_VISION) { AndroidFeatureType(::NightVisionFeature) } - val SHOCKWAVE: AndroidFeatureType<*> by registry.register(MNames.SHOCKWAVE) { AndroidFeatureType(::ShockwaveFeature) } - val ITEM_MAGNET: AndroidFeatureType<*> by registry.register(MNames.ITEM_MAGNET) { AndroidFeatureType(::ItemMagnetFeature) } - val FALL_DAMPENERS: AndroidFeatureType<*> by registry.register(MNames.FALL_DAMPENERS) { AndroidFeatureType(::FallDampenersFeature) } - val PHANTOM_ATTRACTOR: AndroidFeatureType<*> by registry.register(MNames.PHANTOM_ATTRACTOR) { AndroidFeatureType(::PhantomAttractorFeature) } - val JUMP_BOOST: AndroidFeatureType<*> by registry.register(MNames.JUMP_BOOST) { AndroidFeatureType(::JumpBoostFeature) } - val ENDER_TELEPORTER: AndroidFeatureType<*> by registry.register(MNames.ENDER_TELEPORTER) { AndroidFeatureType(::EnderTeleporterFeature) } + val AIR_BAGS: AndroidFeatureType by registry.register(MNames.AIR_BAGS) { AndroidFeatureType(::DummyAndroidFeature) } + val STEP_ASSIST: AndroidFeatureType by registry.register(MNames.STEP_ASSIST) { AndroidFeatureType(::StepAssistFeature) } + val LIMB_OVERCLOCKING: AndroidFeatureType by registry.register(MNames.LIMB_OVERCLOCKING) { AndroidFeatureType(::LimbOverclockingFeature) } + val ATTACK_BOOST: AndroidFeatureType by registry.register(MNames.ATTACK_BOOST) { AndroidFeatureType(::AttackBoostFeature) } + val NANOBOTS_REGENERATION: AndroidFeatureType by registry.register(MNames.NANOBOTS_REGENERATION) { AndroidFeatureType(::NanobotsRegenerationFeature) } + val NANOBOTS_ARMOR: AndroidFeatureType by registry.register(MNames.NANOBOTS_ARMOR) { AndroidFeatureType(::NanobotsArmorFeature) } + val EXTENDED_REACH: AndroidFeatureType by registry.register(MNames.EXTENDED_REACH) { AndroidFeatureType(::ExtendedReachFeature) } + val NIGHT_VISION: AndroidFeatureType by registry.register(MNames.NIGHT_VISION) { AndroidFeatureType(::NightVisionFeature) } + val SHOCKWAVE: AndroidFeatureType by registry.register(MNames.SHOCKWAVE) { AndroidFeatureType(::ShockwaveFeature) } + val ITEM_MAGNET: AndroidFeatureType by registry.register(MNames.ITEM_MAGNET) { AndroidFeatureType(::ItemMagnetFeature) } + val FALL_DAMPENERS: AndroidFeatureType by registry.register(MNames.FALL_DAMPENERS) { AndroidFeatureType(::FallDampenersFeature) } + val PHANTOM_ATTRACTOR: AndroidFeatureType by registry.register(MNames.PHANTOM_ATTRACTOR) { AndroidFeatureType(::PhantomAttractorFeature) } + val JUMP_BOOST: AndroidFeatureType by registry.register(MNames.JUMP_BOOST) { AndroidFeatureType(::JumpBoostFeature) } + val ENDER_TELEPORTER: AndroidFeatureType by registry.register(MNames.ENDER_TELEPORTER) { AndroidFeatureType(::EnderTeleporterFeature) } internal fun register(bus: IEventBus) { registry.register(bus) 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 1acaf7a3b..de5c7a32d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -16,13 +16,13 @@ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent import net.minecraftforge.registries.NewRegistryEvent import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.android.AndroidResearchResult +import ru.dbotthepony.mc.otm.android.AndroidResearchResults import ru.dbotthepony.mc.otm.android.AndroidFeatureType +import ru.dbotthepony.mc.otm.android.AndroidResearchDescription +import ru.dbotthepony.mc.otm.android.AndroidResearchDescriptions import ru.dbotthepony.mc.otm.android.feature.EnderTeleporterFeature -import ru.dbotthepony.mc.otm.android.feature.FallDampenersFeature -import ru.dbotthepony.mc.otm.android.feature.ItemMagnetFeature -import ru.dbotthepony.mc.otm.android.feature.JumpBoostFeature import ru.dbotthepony.mc.otm.android.feature.NanobotsArmorFeature -import ru.dbotthepony.mc.otm.android.feature.ShockwaveFeature import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock import ru.dbotthepony.mc.otm.block.decorative.TritaniumPressurePlate import ru.dbotthepony.mc.otm.capability.matteryEnergy @@ -208,6 +208,10 @@ object MRegistry { MCreativeTabs.initialize(bus) DecimalProvider.register(bus) + AndroidResearchDescription.register(bus) + AndroidResearchDescriptions.register(bus) + AndroidResearchResult.register(bus) + AndroidResearchResults.register(bus) MBlocks.register(bus) MBlockEntities.register(bus) @@ -224,10 +228,6 @@ object MRegistry { // call static constructors NanobotsArmorFeature.Companion - ShockwaveFeature.Companion - ItemMagnetFeature.Companion - FallDampenersFeature.Companion - JumpBoostFeature.Companion EnderTeleporterFeature.Companion } From ddc385072281d03c6d95f82fc02dfb90b4b1275a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 20 Jun 2023 00:23:34 +0700 Subject: [PATCH 0620/1199] Fix writeJson and readJson trying to correct negative numbers, when writeVarLong already does this --- .../mc/otm/core/util/FriendlyStreams.kt | 26 +++---------------- 1 file changed, 3 insertions(+), 23 deletions(-) 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 d13b20bb5..c4e5ffbc5 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 @@ -149,18 +149,6 @@ private const val TYPE_STRING = 0x05 private const val TYPE_ARRAY = 0x06 private const val TYPE_OBJECT = 0x07 -private fun fixSignedInt(read: Long): Long { - val sign = read and 0x1L - @Suppress("name_shadowing") - val read = read ushr 1 - - if (sign == 1L) { - return -read - 1L - } else { - return read - } -} - /** * Writes binary json to stream in Starbound Object Notation format * @@ -186,17 +174,9 @@ fun OutputStream.writeJson(element: JsonElement) { if (element.isNumber) { val num = element.asNumber - if (num is Int || num is Long) { + if (num is Int || num is Long || num is Short || num is Byte) { write(TYPE_INT) - var int = num.toLong() - - if (int < 0) { - int = int.absoluteValue.shl(1).or(1) - } else { - int.shl(1) - } - - writeVarLongLE(int) + writeVarLongLE(num.toLong()) } else if (num is Float || num is Double) { write(TYPE_DOUBLE) writeDouble(num.toDouble()) @@ -237,7 +217,7 @@ fun InputStream.readJson(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 sizeLimit.accountBytes(1L) JsonPrimitive(read() > 1) } - TYPE_INT -> JsonPrimitive(fixSignedInt(readVarLongLE(sizeLimit))) + TYPE_INT -> JsonPrimitive(readVarLongLE(sizeLimit)) TYPE_STRING -> JsonPrimitive(readBinaryString(sizeLimit)) TYPE_ARRAY -> { val values = readVarIntLE(sizeLimit) From 90de22b288be698b7a07792941b323c33f25fd91 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 20 Jun 2023 00:23:44 +0700 Subject: [PATCH 0621/1199] Update streams tests --- .../mc/otm/tests/FriendlyStreams.kt | 126 ++++++------------ 1 file changed, 38 insertions(+), 88 deletions(-) diff --git a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FriendlyStreams.kt b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FriendlyStreams.kt index 332832e17..b54aa47aa 100644 --- a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FriendlyStreams.kt +++ b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/FriendlyStreams.kt @@ -18,104 +18,54 @@ object FriendlyStreams { fun test() { val output = FastByteArrayOutputStream() - output.writeInt(4) - output.writeInt(16) - output.writeInt(-1) - output.writeInt(1000000) + for (i in 0 .. 65565) { + output.writeInt(i) + } - output.writeVarIntLE(0) - output.writeVarIntLE(1) - output.writeVarIntLE(4) - output.writeVarIntLE(15) - output.writeVarIntLE(16) - output.writeVarIntLE(127) - output.writeVarIntLE(128) - output.writeVarIntLE(129) - output.writeVarIntLE(10023) - output.writeVarIntLE(100000) + for (i in 0 .. 65565) { + output.writeVarIntLE(i) + } - output.writeVarIntLE(-0) - output.writeVarIntLE(-1) - output.writeVarIntLE(-4) - output.writeVarIntLE(-15) - output.writeVarIntLE(-16) - output.writeVarIntLE(-127) - output.writeVarIntLE(-128) - output.writeVarIntLE(-129) - output.writeVarIntLE(-10023) - output.writeVarIntLE(-100000) + for (i in 0 .. 65565) { + output.writeVarLongLE(i.toLong()) + } - output.writeVarLongLE(0) - output.writeVarLongLE(1) - output.writeVarLongLE(4) - output.writeVarLongLE(15) - output.writeVarLongLE(16) - output.writeVarLongLE(127) - output.writeVarLongLE(128) - output.writeVarLongLE(129) - output.writeVarLongLE(10023) - output.writeVarLongLE(100000) + for (i in 0 .. 65565) { + output.writeInt(-i) + } - output.writeVarLongLE(-0) - output.writeVarLongLE(-1) - output.writeVarLongLE(-4) - output.writeVarLongLE(-15) - output.writeVarLongLE(-16) - output.writeVarLongLE(-127) - output.writeVarLongLE(-128) - output.writeVarLongLE(-129) - output.writeVarLongLE(-10023) - output.writeVarLongLE(-100000) + for (i in 0 .. 65565) { + output.writeVarIntLE(-i) + } + + for (i in 0 .. 65565) { + output.writeVarLongLE(-i.toLong()) + } val input = FastByteArrayInputStream(output.array, 0, output.length) - assertEquals(4, input.readInt()) - assertEquals(16, input.readInt()) - assertEquals(-1, input.readInt()) - assertEquals(1000000, input.readInt()) + for (i in 0 .. 65565) { + assertEquals(i, input.readInt()) + } - assertEquals(0, input.readVarIntLE()) - assertEquals(1, input.readVarIntLE()) - assertEquals(4, input.readVarIntLE()) - assertEquals(15, input.readVarIntLE()) - assertEquals(16, input.readVarIntLE()) - assertEquals(127, input.readVarIntLE()) - assertEquals(128, input.readVarIntLE()) - assertEquals(129, input.readVarIntLE()) - assertEquals(10023, input.readVarIntLE()) - assertEquals(100000, input.readVarIntLE()) + for (i in 0 .. 65565) { + assertEquals(i, input.readVarIntLE()) + } - assertEquals(-0, input.readVarIntLE()) - assertEquals(-1, input.readVarIntLE()) - assertEquals(-4, input.readVarIntLE()) - assertEquals(-15, input.readVarIntLE()) - assertEquals(-16, input.readVarIntLE()) - assertEquals(-127, input.readVarIntLE()) - assertEquals(-128, input.readVarIntLE()) - assertEquals(-129, input.readVarIntLE()) - assertEquals(-10023, input.readVarIntLE()) - assertEquals(-100000, input.readVarIntLE()) + for (i in 0 .. 65565) { + assertEquals(i.toLong(), input.readVarLongLE()) + } - assertEquals(0, input.readVarLongLE()) - assertEquals(1, input.readVarLongLE()) - assertEquals(4, input.readVarLongLE()) - assertEquals(15, input.readVarLongLE()) - assertEquals(16, input.readVarLongLE()) - assertEquals(127, input.readVarLongLE()) - assertEquals(128, input.readVarLongLE()) - assertEquals(129, input.readVarLongLE()) - assertEquals(10023, input.readVarLongLE()) - assertEquals(100000, input.readVarLongLE()) + for (i in 0 .. 65565) { + assertEquals(-i, input.readInt()) + } - assertEquals(-0, input.readVarLongLE()) - assertEquals(-1, input.readVarLongLE()) - assertEquals(-4, input.readVarLongLE()) - assertEquals(-15, input.readVarLongLE()) - assertEquals(-16, input.readVarLongLE()) - assertEquals(-127, input.readVarLongLE()) - assertEquals(-128, input.readVarLongLE()) - assertEquals(-129, input.readVarLongLE()) - assertEquals(-10023, input.readVarLongLE()) - assertEquals(-100000, input.readVarLongLE()) + for (i in 0 .. 65565) { + assertEquals(-i, input.readVarIntLE()) + } + + for (i in 0 .. 65565) { + assertEquals(-i.toLong(), input.readVarLongLE()) + } } } From e39bb8e1abfdb3ee08a5d80a2b5e76cb2ee00125 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 20 Jun 2023 00:23:55 +0700 Subject: [PATCH 0622/1199] More meaningful error --- src/main/kotlin/ru/dbotthepony/mc/otm/data/ComponentCodec.kt | 2 +- src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComponentCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComponentCodec.kt index 9efaeb74f..ec65bb31a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComponentCodec.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComponentCodec.kt @@ -19,7 +19,7 @@ object ComponentCodec : Codec { try { return DataResult.success(Pair(Component.Serializer.fromJson(value), ops.empty())) } catch (err: JsonSyntaxException) { - return DataResult.error { err.message } + return DataResult.error { "Error decoding component: ${err.message}" } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt index 4b600cb78..371e0a017 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt @@ -16,7 +16,7 @@ object DecimalCodec : Codec { try { DataResult.success(Pair(Decimal(it), ops.empty())) } catch (err: NumberFormatException) { - DataResult.error { "Not a number: $it" } + DataResult.error { "Not a valid number for converting into Decimal: $it" } } } } From 31173497573ba94db15d2540d4a997bbffd8a295 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 20 Jun 2023 00:32:59 +0700 Subject: [PATCH 0623/1199] Move android research type to codecs --- .../android/AndroidResearchDataProvider.kt | 5 +- .../mc/otm/android/AndroidResearchManager.kt | 22 +- .../mc/otm/android/AndroidResearchType.kt | 229 ++++++------------ .../mc/otm/core/UnOverengineering.kt | 10 + .../mc/otm/data/IngredientCodec.kt | 23 ++ .../mc/otm/data/JsonElementCodec.kt | 18 ++ 6 files changed, 143 insertions(+), 164 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientCodec.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/JsonElementCodec.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDataProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDataProvider.kt index ee9b57c9a..98d175bfc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDataProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDataProvider.kt @@ -1,11 +1,14 @@ package ru.dbotthepony.mc.otm.android +import com.google.gson.JsonObject import it.unimi.dsi.fastutil.objects.ObjectArraySet import net.minecraft.data.CachedOutput import net.minecraft.data.DataProvider import net.minecraft.data.PackOutput import net.minecraft.resources.ResourceLocation import net.minecraftforge.data.event.GatherDataEvent +import ru.dbotthepony.mc.otm.core.toJson +import ru.dbotthepony.mc.otm.core.toJsonStrict import ru.dbotthepony.mc.otm.core.util.WriteOnce import java.util.Collections import java.util.LinkedList @@ -56,7 +59,7 @@ open class AndroidResearchDataProvider() : DataProvider { addEverything { if (set.add(it.id)) { - futures.add(DataProvider.saveStable(output, it.toJson(), pathProvider.json(it.id))) + futures.add(DataProvider.saveStable(output, AndroidResearchType.CODEC.toJsonStrict(it).also { (it as JsonObject).remove("id") }, pathProvider.json(it.id))) AndroidResearchManager.put(it) added.add(it) } else { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchManager.kt index 363d6e12d..7f1672933 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchManager.kt @@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableMap import com.google.gson.GsonBuilder import com.google.gson.JsonElement import com.google.gson.JsonObject +import com.google.gson.JsonSyntaxException import net.minecraft.client.server.IntegratedServer import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation @@ -22,6 +23,13 @@ import ru.dbotthepony.mc.otm.NULLABLE_MINECRAFT_SERVER import ru.dbotthepony.mc.otm.SERVER_IS_LIVE import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.core.fromJsonStrict +import ru.dbotthepony.mc.otm.core.fromNetwork +import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.toJsonStrict +import ru.dbotthepony.mc.otm.core.toNetwork +import ru.dbotthepony.mc.otm.core.util.readJson +import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.RegistryNetworkChannel import ru.dbotthepony.mc.otm.network.enqueueWork @@ -67,7 +75,13 @@ object AndroidResearchManager : SimpleJsonResourceReloadListener(GsonBuilder().s continue } - builder.put(k, AndroidResearchType.fromJson(v, k)) + v["id"] = k.toString() + + try { + builder.put(k, AndroidResearchType.CODEC.fromJsonStrict(v)) + } catch(err: RuntimeException) { + throw JsonSyntaxException("Caught an exception while decoding android research $k", err) + } } researchMap = builder.build() @@ -101,7 +115,8 @@ object AndroidResearchManager : SimpleJsonResourceReloadListener(GsonBuilder().s class SyncPacket(val collection: Collection) : MatteryPacket { override fun write(buff: FriendlyByteBuf) { - buff.writeCollection(collection) { a, b -> b.toNetwork(a) } + buff.writeCollection(collection) { a, b -> AndroidResearchType.CODEC.toNetwork(a, b) } + LOGGER.debug("Constructed android research registry packet, ${buff.writerIndex()} bytes in size") } override fun play(context: Supplier) { @@ -130,6 +145,7 @@ object AndroidResearchManager : SimpleJsonResourceReloadListener(GsonBuilder().s } fun readSyncPacket(buff: FriendlyByteBuf): SyncPacket { - return SyncPacket(buff.readCollection({ LinkedList() }, AndroidResearchType.Companion::fromNetwork)) + LOGGER.info("Received android research registry packet, ${buff.readableBytes()} bytes in size") + return SyncPacket(buff.readCollection({ LinkedList() }, { AndroidResearchType.CODEC.fromNetwork(it) })) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt index 2d150b697..b987b6c33 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt @@ -7,6 +7,12 @@ import com.google.gson.JsonObject import com.google.gson.JsonPrimitive import com.google.gson.JsonSyntaxException import com.google.gson.internal.bind.TypeAdapters +import com.mojang.datafixers.util.Either +import com.mojang.serialization.Codec +import com.mojang.serialization.JsonOps +import com.mojang.serialization.codecs.ListCodec +import com.mojang.serialization.codecs.PairCodec +import com.mojang.serialization.codecs.RecordCodecBuilder import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet import net.minecraft.network.FriendlyByteBuf import net.minecraft.network.chat.Component @@ -33,11 +39,18 @@ import ru.dbotthepony.mc.otm.core.fromJsonStrict import ru.dbotthepony.mc.otm.core.toJsonStrict import ru.dbotthepony.mc.otm.core.util.readJson import ru.dbotthepony.mc.otm.core.util.writeJson +import ru.dbotthepony.mc.otm.data.ComponentCodec +import ru.dbotthepony.mc.otm.data.IngredientCodec +import ru.dbotthepony.mc.otm.data.JsonElementCodec +import ru.dbotthepony.mc.otm.data.simpleCodec import ru.dbotthepony.mc.otm.isClient import java.util.LinkedList +import java.util.Optional +import java.util.function.Function import java.util.stream.Stream import kotlin.collections.ArrayList import kotlin.collections.HashSet +import kotlin.jvm.optionals.getOrNull private fun findPrerequisites( initial: Collection, @@ -97,6 +110,25 @@ class AndroidResearchType( val itemIcon: Item? = null, iconText: Component? = null, ) { + private constructor( + id: ResourceLocation, + prerequisites: Collection, + blockedBy: Collection, + + items: Collection>, + results: Collection, + + description: Collection, + + experienceLevels: Int, + customName: Optional, + + // ok + skinIcon: Optional, + itemIcon: Optional, + iconText: Optional, + ) : this(id, prerequisites, blockedBy, items.stream().map { Pair(it.first, it.second) }.toList(), results, description, experienceLevels, customName.getOrNull(), skinIcon.getOrNull(), itemIcon.getOrNull(), iconText.getOrNull()) + private val iconTextValue = iconText?.copy() val iconText get() = iconTextValue?.copy() @@ -110,38 +142,21 @@ class AndroidResearchType( data class Reference( val id: ResourceLocation, - val isRigid: Boolean + val optional: Boolean = false ) { - fun toJson(): JsonObject { - return JsonObject().also { - it["id"] = JsonPrimitive(id.toString()) - it["is_rigid"] = JsonPrimitive(isRigid) - } - } - - fun toNetwork(buff: FriendlyByteBuf) { - buff.writeUtf(id.toString()) - buff.writeBoolean(isRigid) - } - companion object { - fun fromNetwork(buff: FriendlyByteBuf): Reference { - return Reference( - ResourceLocation(buff.readUtf()), - buff.readBoolean() - ) - } - - fun fromJson(value: JsonElement): Reference { - if (value is JsonPrimitive) { - return Reference(ResourceLocation(value.asString), true) - } else if (value is JsonObject) { - return Reference( - ResourceLocation((value["id"] as? JsonPrimitive ?: throw JsonSyntaxException("Invalid `id` value")).asString), - (value["is_rigid"] as JsonPrimitive?)?.asBoolean ?: true) - } else { - throw JsonSyntaxException("Unknown element type ${value::class.qualifiedName}") - } + val CODEC: Codec by lazy { + Codec + .either(ResourceLocation.CODEC, RecordCodecBuilder.create { + it.group( + ResourceLocation.CODEC.fieldOf("id").forGetter(Reference::id), + Codec.BOOL.optionalFieldOf("optional", false).forGetter(Reference::optional) + ).apply(it, ::Reference) + }) + .xmap( + { c -> c.map(::Reference, Function.identity()) }, + { c -> if (c.optional) Either.right(c) else Either.left(c.id) } + ) } } } @@ -174,11 +189,11 @@ class AndroidResearchType( val blockedBy: List = ImmutableList.copyOf(blockedBy) val resolvedPrerequisites: List by lazy { - ImmutableList.copyOf(this.prerequisites.mapNotNull { AndroidResearchManager[it.id].also { e -> if (e == null && it.isRigid) throw NoSuchElementException("Unable to find research ${it.id}") } }) + ImmutableList.copyOf(this.prerequisites.mapNotNull { AndroidResearchManager[it.id].also { e -> if (e == null && it.optional) throw NoSuchElementException("Unable to find research ${it.id}") } }) } val resolvedBlockedBy: List by lazy { - ImmutableList.copyOf(this.blockedBy.mapNotNull { AndroidResearchManager[it.id].also { e -> if (e == null && it.isRigid) throw NoSuchElementException("Unable to find research ${it.id}") } }) + ImmutableList.copyOf(this.blockedBy.mapNotNull { AndroidResearchManager[it.id].also { e -> if (e == null && it.optional) throw NoSuchElementException("Unable to find research ${it.id}") } }) } private val definedItems: List> = ImmutableList.copyOf(items) @@ -380,141 +395,35 @@ class AndroidResearchType( return customName?.copy() ?: MutableComponent.create(displayContents) } - fun toJson(): JsonElement { - return JsonObject().also { - it["prerequisites"] = JsonArray().also { for (value in prerequisites) it.add(value.toJson()) } - it["blocked_by"] = JsonArray().also { for (value in blockedBy) it.add(value.toJson()) } - it["required_items"] = JsonArray().also { for (item in definedItems) it.add(JsonObject().also { it["count"] = JsonPrimitive(item.second); it["ingredient"] = item.first.toJson() }) } - it["results"] = JsonArray().also { for (result in results) it.add(AndroidResearchResult.CODEC.toJsonStrict(result)) } - it["description"] = JsonArray().also { for (line in description) it.add(AndroidResearchDescription.CODEC.toJsonStrict(line)) } - it["experience"] = JsonPrimitive(experienceLevels) - - if (skinIcon != null) { - it["skin_icon"] = skinIcon - } - - if (itemIcon != null) { - it["item_icon"] = JsonPrimitive(itemIcon.registryName!!.toString()) - } - - if (iconTextValue != null) { - it["icon_text"] = Component.Serializer.toJsonTree(iconTextValue) - } - - if (customName != null) { - it["custom_name"] = Component.Serializer.toJsonTree(customName) - } - } - } - fun validate() { resolvedBlockedBy resolvedPrerequisites } - fun toNetwork(buff: FriendlyByteBuf) { - buff.writeUtf(id.toString()) - buff.writeCollection(prerequisites) { a, b -> b.toNetwork(a) } - buff.writeCollection(blockedBy) { a, b -> b.toNetwork(a) } - buff.writeCollection(definedItems) { a, b -> b.first.toNetwork(a); a.writeVarInt(b.second) } - buff.writeCollection(results) { a, b -> a.writeJson(AndroidResearchResult.CODEC.toJsonStrict(b)) } - buff.writeCollection(description) { a, b -> a.writeJson(AndroidResearchDescription.CODEC.toJsonStrict(b)) } - buff.writeVarInt(experienceLevels) - - buff.writeBoolean(customName != null) - if (customName != null) buff.writeComponent(customName) - - buff.writeBoolean(iconTextValue != null) - if (iconTextValue != null) buff.writeComponent(iconTextValue) - - buff.writeBoolean(skinIcon != null) - if (skinIcon != null) buff.writeUtf(skinIcon.toString()) - - buff.writeBoolean(itemIcon != null) - if (itemIcon != null) buff.writeUtf(itemIcon.registryName!!.toString()) - } - companion object { - fun fromNetwork(buff: FriendlyByteBuf): AndroidResearchType { - val id = ResourceLocation(buff.readUtf()) - val prerequisites = buff.readCollection({ LinkedList() }, Reference::fromNetwork) - val blockedBy = buff.readCollection({ LinkedList() }, Reference::fromNetwork) - val items = buff.readCollection({ LinkedList() }, { Ingredient.fromNetwork(it) to it.readVarInt() }) - val results = buff.readCollection({ LinkedList() }, { AndroidResearchResult.CODEC.fromJsonStrict(it.readJson()) }) - val description = buff.readCollection({ LinkedList() }, { AndroidResearchDescription.CODEC.fromJsonStrict(it.readJson()) }) - val experienceLevels = buff.readVarInt() - - val customName = if (buff.readBoolean()) { - buff.readComponent() - } else { - null + val CODEC: Codec by lazy { + RecordCodecBuilder.create { + it.group( + ResourceLocation.CODEC.fieldOf("id").forGetter(AndroidResearchType::id), + ListCodec(Reference.CODEC).fieldOf("prerequisites").forGetter(AndroidResearchType::prerequisites), + ListCodec(Reference.CODEC).fieldOf("blockedBy").forGetter(AndroidResearchType::blockedBy), + ListCodec( + RecordCodecBuilder.create> { + it.group( + IngredientCodec.fieldOf("item").forGetter { it.first }, + Codec.intRange(1, Int.MAX_VALUE).optionalFieldOf("count", 1).forGetter { it.second } + ).apply(it, ::Pair) + } + ).fieldOf("items").forGetter { it.definedItems }, + ListCodec(AndroidResearchResult.CODEC).fieldOf("results").forGetter(AndroidResearchType::results), + ListCodec(AndroidResearchDescription.CODEC).fieldOf("description").forGetter(AndroidResearchType::description), + Codec.intRange(0, Int.MAX_VALUE).fieldOf("experienceLevels").forGetter(AndroidResearchType::experienceLevels), + ComponentCodec.optionalFieldOf("customName").forGetter { Optional.ofNullable(it.customName) }, + JsonElementCodec.xmap({ it as? JsonObject ?: throw JsonSyntaxException("Not a json object: $it") }, { it }).optionalFieldOf("skinIcon").forGetter { Optional.ofNullable(it.skinIcon) }, + ForgeRegistries.ITEMS.codec.optionalFieldOf("itemIcon").forGetter { Optional.ofNullable(it.itemIcon) }, + ComponentCodec.optionalFieldOf("iconTextValue").forGetter { Optional.ofNullable(it.iconTextValue) }, + ).apply(it, ::AndroidResearchType) } - - val iconTextValue = if (buff.readBoolean()) { - buff.readComponent() - } else { - null - } - - val skinIcon = if (buff.readBoolean()) { - TypeAdapters.JSON_ELEMENT.fromJson(buff.readUtf()) as JsonObject - } else { - null - } - - val itemIcon = if (buff.readBoolean()) { - ForgeRegistries.ITEMS.getValue(ResourceLocation(buff.readUtf()))?.let { if (it == Items.AIR) null else it } - } else { - null - } - - return AndroidResearchType( - id = id, - prerequisites = prerequisites, - blockedBy = blockedBy, - items = items, - results = results, - description = description, - experienceLevels = experienceLevels, - customName = customName, - iconText = iconTextValue, - skinIcon = skinIcon, - itemIcon = itemIcon, - ) - } - - fun fromJson(value: JsonElement, id: ResourceLocation): AndroidResearchType { - if (value !is JsonObject) { - throw JsonSyntaxException("Android research type must be of Json Object") - } - - val prerequisites = value["prerequisites"] as JsonArray? ?: JsonArray() - val blocked_by = value["blocked_by"] as JsonArray? ?: JsonArray() - val items = value["required_items"] as JsonArray? ?: JsonArray() - val features = value["feature_result"] as JsonArray? ?: JsonArray() - val description = value["description"] as JsonArray? ?: JsonArray() - val experience = value["experience"]?.asInt ?: 0 - val customName = value["custom_name"]?.let(Component.Serializer::fromJson) - val iconText = value["icon_text"]?.let(Component.Serializer::fromJson) - val skinIcon = value["skin_icon"] as JsonObject? - val itemIcon = value["item_icon"]?.let { ForgeRegistries.ITEMS.getValue(ResourceLocation(it.asString)).let { if (it == Items.AIR) null else it } } - - return AndroidResearchType( - id = id, - prerequisites = prerequisites.stream().map { Reference.fromJson(it) }.toList(), - blockedBy = blocked_by.stream().map { Reference.fromJson(it) }.toList(), - results = features.stream().map { AndroidResearchResult.CODEC.fromJsonStrict(it) }.toList(), - items = items.stream() - .map { it as? JsonObject ?: throw JsonSyntaxException("One of items is not an JsonObject") } - .map { Ingredient.fromJson(it["ingredient"] ?: throw JsonSyntaxException("Missing ingredient key")) to (it["count"]?.asInt ?: throw JsonSyntaxException("Missing count key")) } - .toList(), - description = description.stream().map { AndroidResearchDescription.CODEC.fromJsonStrict(it) }.toList(), - experienceLevels = experience, - customName = customName, - iconText = iconText, - skinIcon = skinIcon, - itemIcon = itemIcon, - ) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt index 354dd0ee5..f643eb1a9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt @@ -26,6 +26,8 @@ import net.minecraft.world.level.material.Fluid import net.minecraft.world.phys.Vec3 import net.minecraftforge.registries.ForgeRegistries import net.minecraftforge.registries.IForgeRegistry +import ru.dbotthepony.mc.otm.core.util.readJson +import ru.dbotthepony.mc.otm.core.util.writeJson // because doing it inline is ugly fun Codec.fromJson(value: JsonElement): V? { @@ -60,6 +62,14 @@ fun Codec.toNbtStrict(value: V, prefix: Tag = NbtOps.INSTANCE.empty return encode(value, NbtOps.INSTANCE, prefix).get().map({ it }, { throw RuntimeException("Error encoding element: ${it.message()}") }) } +fun Codec.toNetwork(buff: FriendlyByteBuf, value: V) { + buff.writeJson(toJsonStrict(value)) +} + +fun Codec.fromNetwork(buff: FriendlyByteBuf): V { + return fromJsonStrict(buff.readJson()) +} + // 1.19 being 1.19 fun TranslatableComponent(key: String, vararg values: Any): MutableComponent = MutableComponent.create(TranslatableContents(key, null, values)) fun TextComponent(value: String): MutableComponent = MutableComponent.create(LiteralContents(value)) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientCodec.kt new file mode 100644 index 000000000..27c18ade8 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientCodec.kt @@ -0,0 +1,23 @@ +package ru.dbotthepony.mc.otm.data + +import com.google.gson.JsonSyntaxException +import com.mojang.datafixers.util.Pair +import com.mojang.serialization.Codec +import com.mojang.serialization.DataResult +import com.mojang.serialization.DynamicOps +import com.mojang.serialization.JsonOps +import net.minecraft.world.item.crafting.Ingredient + +object IngredientCodec : Codec { + override fun encode(input: Ingredient, ops: DynamicOps, prefix: T): DataResult { + return DataResult.success(JsonOps.INSTANCE.convertTo(ops, input.toJson())) + } + + override fun decode(ops: DynamicOps, input: T): DataResult> { + try { + return DataResult.success(Pair(Ingredient.fromJson(ops.convertTo(JsonOps.INSTANCE, input)), ops.empty())) + } catch (err: JsonSyntaxException) { + return DataResult.error { "Error decoding Ingredient: ${err.message}" } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/JsonElementCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/JsonElementCodec.kt new file mode 100644 index 000000000..783222a0e --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/JsonElementCodec.kt @@ -0,0 +1,18 @@ +package ru.dbotthepony.mc.otm.data + +import com.google.gson.JsonElement +import com.mojang.datafixers.util.Pair +import com.mojang.serialization.Codec +import com.mojang.serialization.DataResult +import com.mojang.serialization.DynamicOps +import com.mojang.serialization.JsonOps + +object JsonElementCodec : Codec { + override fun encode(input: JsonElement, ops: DynamicOps, prefix: T): DataResult { + return DataResult.success(JsonOps.INSTANCE.convertTo(ops, input)) + } + + override fun decode(ops: DynamicOps, input: T): DataResult> { + return DataResult.success(Pair(ops.convertTo(JsonOps.INSTANCE, input), ops.empty())) + } +} From fa22fb7cced75a3d20bb1ed8c509a5fd7ac6122d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 20 Jun 2023 11:22:36 +0700 Subject: [PATCH 0624/1199] Add compound tag to android research for storing arbitrary data with research --- .../ru/dbotthepony/mc/otm/android/AndroidResearch.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt index aa03048e3..e092efa06 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt @@ -29,7 +29,10 @@ class AndroidResearch(val type: AndroidResearchType, val capability: MatteryPlay val synchronizer = FieldSynchronizer() - var isResearched by synchronizer.bool() + var isResearched by synchronizer.bool().property + private set + + var tag = CompoundTag() private set /** @@ -340,10 +343,12 @@ class AndroidResearch(val type: AndroidResearchType, val capability: MatteryPlay override fun serializeNBT(): CompoundTag { return CompoundTag().also { it["researched"] = isResearched + it["tag"] = tag } } override fun deserializeNBT(nbt: CompoundTag) { isResearched = nbt.getBoolean("researched") + tag = nbt.getCompound("tag") } } From 734655f53b899b1818f0afae7a941d1245753e6f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 20 Jun 2023 11:30:40 +0700 Subject: [PATCH 0625/1199] Fix "isRigid" being the opposite of "optional" in research builder --- .../mc/otm/datagen/ResearchData.kt | 17 ++++------- .../mc/otm/android/AndroidResearchType.kt | 29 ++++--------------- 2 files changed, 11 insertions(+), 35 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt index 00599e085..ed1655e51 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt @@ -5,15 +5,8 @@ import net.minecraft.world.item.Items import net.minecraftforge.common.Tags import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.android.AndroidResearchDescriptions -import ru.dbotthepony.mc.otm.android.AndroidResearchResult import ru.dbotthepony.mc.otm.android.AndroidResearchResults import ru.dbotthepony.mc.otm.android.AndroidResearchType -import ru.dbotthepony.mc.otm.android.feature.EnderTeleporterFeature -import ru.dbotthepony.mc.otm.android.feature.FallDampenersFeature -import ru.dbotthepony.mc.otm.android.feature.ItemMagnetFeature -import ru.dbotthepony.mc.otm.android.feature.JumpBoostFeature -import ru.dbotthepony.mc.otm.android.feature.NanobotsArmorFeature -import ru.dbotthepony.mc.otm.android.feature.ShockwaveFeature import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent @@ -106,7 +99,7 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang .addPrerequisite(OverdriveThatMatters.loc(MNames.NANOBOTS)) .addFeatureResult(OverdriveThatMatters.loc(MNames.NANOBOTS_ARMOR)) .withIcon(ResearchIcons.ICON_ARMOR) - .addBlocker(OverdriveThatMatters.loc(MNames.ATTACK_BOOST_1), rigid = true) + .addBlocker(OverdriveThatMatters.loc(MNames.ATTACK_BOOST_1), optional = true) .addItem(MItemTags.TRITANIUM_PLATES, 4) .addItem(MItemTags.COPPER_WIRES, 8) .build() @@ -138,7 +131,7 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang if (i > 0) { research.addFeatureLevel(AndroidFeatures.LIMB_OVERCLOCKING) - research.addPrerequisite(OverdriveThatMatters.loc(MNames.LIMB_OVERCLOCKING_LIST[i - 1]), rigid = true) + research.addPrerequisite(OverdriveThatMatters.loc(MNames.LIMB_OVERCLOCKING_LIST[i - 1]), optional = true) research.addItem(MItemTags.GOLD_WIRES, i * 2) } else { research.addFeatureResult(AndroidFeatures.LIMB_OVERCLOCKING) @@ -164,7 +157,7 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang if (i > 0) { research.addFeatureLevel(AndroidFeatures.ATTACK_BOOST) - research.addPrerequisite(OverdriveThatMatters.loc(MNames.ATTACK_BOOST_LIST[i - 1]), rigid = true) + research.addPrerequisite(OverdriveThatMatters.loc(MNames.ATTACK_BOOST_LIST[i - 1]), optional = true) } else { research.addFeatureResult(AndroidFeatures.ATTACK_BOOST) } @@ -189,9 +182,9 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang if (i > 0) { research.addFeatureLevel(AndroidFeatures.NANOBOTS_REGENERATION) - research.addPrerequisite(OverdriveThatMatters.loc(MNames.NANOBOTS_REGENERATION_LIST[i - 1]), rigid = true) + research.addPrerequisite(OverdriveThatMatters.loc(MNames.NANOBOTS_REGENERATION_LIST[i - 1]), optional = true) } else { - research.addPrerequisite(OverdriveThatMatters.loc(MNames.NANOBOTS), rigid = true) + research.addPrerequisite(OverdriveThatMatters.loc(MNames.NANOBOTS), optional = true) research.addFeatureResult(AndroidFeatures.NANOBOTS_REGENERATION) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt index b987b6c33..af0b2b592 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt @@ -1,20 +1,13 @@ package ru.dbotthepony.mc.otm.android import com.google.common.collect.ImmutableList -import com.google.gson.JsonArray -import com.google.gson.JsonElement import com.google.gson.JsonObject -import com.google.gson.JsonPrimitive import com.google.gson.JsonSyntaxException -import com.google.gson.internal.bind.TypeAdapters import com.mojang.datafixers.util.Either import com.mojang.serialization.Codec -import com.mojang.serialization.JsonOps import com.mojang.serialization.codecs.ListCodec -import com.mojang.serialization.codecs.PairCodec import com.mojang.serialization.codecs.RecordCodecBuilder import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet -import net.minecraft.network.FriendlyByteBuf import net.minecraft.network.chat.Component import net.minecraft.network.chat.ComponentContents import net.minecraft.network.chat.MutableComponent @@ -23,7 +16,6 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.tags.TagKey import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.Items import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.level.ItemLike import net.minecraftforge.registries.ForgeRegistries @@ -32,19 +24,10 @@ import ru.dbotthepony.mc.otm.client.render.SpriteType import ru.dbotthepony.mc.otm.core.collect.ListSet import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.isActuallyEmpty -import ru.dbotthepony.mc.otm.core.registryName -import ru.dbotthepony.mc.otm.core.set -import ru.dbotthepony.mc.otm.core.collect.stream -import ru.dbotthepony.mc.otm.core.fromJsonStrict -import ru.dbotthepony.mc.otm.core.toJsonStrict -import ru.dbotthepony.mc.otm.core.util.readJson -import ru.dbotthepony.mc.otm.core.util.writeJson import ru.dbotthepony.mc.otm.data.ComponentCodec import ru.dbotthepony.mc.otm.data.IngredientCodec import ru.dbotthepony.mc.otm.data.JsonElementCodec -import ru.dbotthepony.mc.otm.data.simpleCodec import ru.dbotthepony.mc.otm.isClient -import java.util.LinkedList import java.util.Optional import java.util.function.Function import java.util.stream.Stream @@ -518,14 +501,14 @@ class AndroidResearchType( * research tree render logic (yet). */ @JvmOverloads - fun addPrerequisite(id: ResourceLocation, rigid: Boolean = false): Builder { - prerequisites.add(Reference(id, rigid)) + fun addPrerequisite(id: ResourceLocation, optional: Boolean = true): Builder { + prerequisites.add(Reference(id, optional)) return this } @JvmOverloads - fun addBlocker(id: ResourceLocation, rigid: Boolean = false): Builder { - blockers.add(Reference(id, rigid)) + fun addBlocker(id: ResourceLocation, optional: Boolean = true): Builder { + blockers.add(Reference(id, optional)) return this } @@ -533,8 +516,8 @@ class AndroidResearchType( * Please avoid having multiple prerequisites as case with more than 1 prerequisite does not have proper * research tree render logic (yet). */ - fun addPrerequisite(type: AndroidResearchType, rigid: Boolean = true) = addPrerequisite(type.id, rigid) - fun addBlocker(type: AndroidResearchType, rigid: Boolean = true) = addBlocker(type.id, rigid) + fun addPrerequisite(type: AndroidResearchType, optional: Boolean = false) = addPrerequisite(type.id, optional) + fun addBlocker(type: AndroidResearchType, optional: Boolean = false) = addBlocker(type.id, optional) fun addResult(result: AndroidResearchResult): Builder { results.add(result) From a8eeebc1663cd07200c8699ce23808caea45010b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 20 Jun 2023 11:32:00 +0700 Subject: [PATCH 0626/1199] Useless --- .../kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt index af0b2b592..592b73257 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt @@ -110,7 +110,7 @@ class AndroidResearchType( skinIcon: Optional, itemIcon: Optional, iconText: Optional, - ) : this(id, prerequisites, blockedBy, items.stream().map { Pair(it.first, it.second) }.toList(), results, description, experienceLevels, customName.getOrNull(), skinIcon.getOrNull(), itemIcon.getOrNull(), iconText.getOrNull()) + ) : this(id, prerequisites, blockedBy, items, results, description, experienceLevels, customName.getOrNull(), skinIcon.getOrNull(), itemIcon.getOrNull(), iconText.getOrNull()) private val iconTextValue = iconText?.copy() val iconText get() = iconTextValue?.copy() From 02606c5ac67c894ec0198bf61ed2b7cc0ed11522 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 20 Jun 2023 11:33:29 +0700 Subject: [PATCH 0627/1199] Mappings are no longer present --- .../mc/otm/network/synchronizer/FieldSynchronizer.kt | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt index 8de4d082e..22f349eb2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt @@ -353,12 +353,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa var unused: Boolean = false private set - private var mappingVersion = -1 - - fun invalidateMappings() { - mappingVersion = -1 - } - fun markUnused() { require(this === defaultEndpoint) { "This is not a default endpoint" } if (unused) return @@ -1823,10 +1817,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa for (field in fields) { field?.markDirty() } - - forEachEndpoint { - it.invalidateMappings() - } } /** From c9026b1cf7d8f06540bd110b5df54dcd8101821b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 20 Jun 2023 17:20:01 +0700 Subject: [PATCH 0628/1199] Bump forge to 47.0.4 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index ed573d7c8..d6c35d542 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,7 +17,7 @@ jei_mc_version=1.20 curios_mc_version=1.20 forge_gradle_version=[6.0,6.2) -forge_version=47.0.1 +forge_version=47.0.4 mixingradle_version=0.7.33 mixin_version=0.8.5 From c6e0777942b3d28bdf244a65ae0083b182fd4621 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 20 Jun 2023 17:39:24 +0700 Subject: [PATCH 0629/1199] =?UTF-8?q?YuRaNnNzZZ=20=E2=80=94=20=D0=A1=D0=B5?= =?UTF-8?q?=D0=B3=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=2017:38=20:WiseTree:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/block/entity/tech/BatteryBankBlockEntity.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index bb98310ec..ec8a38a77 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -88,6 +88,8 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte if (!simulate && !summ.isZero) { setChangedLight() gaugeLevel = (batteryLevel / maxBatteryLevel).toFloat() + } else if (!simulate && container.isEmpty) { + gaugeLevel = 0f } if (!simulate) { From 85c426e2b6c1a7a1abf00191048507d566669b42 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 20 Jun 2023 18:08:54 +0700 Subject: [PATCH 0630/1199] Update striped tritanium block texture --- colomposer.js | 7 +++++-- .../tritanium_striped_block_black_blue.png | Bin 475 -> 462 bytes .../tritanium_striped_block_black_brown.png | Bin 473 -> 462 bytes .../tritanium_striped_block_black_cyan.png | Bin 479 -> 458 bytes .../tritanium_striped_block_black_gray.png | Bin 477 -> 451 bytes .../tritanium_striped_block_black_green.png | Bin 473 -> 462 bytes ...tritanium_striped_block_black_light_blue.png | Bin 489 -> 466 bytes ...tritanium_striped_block_black_light_gray.png | Bin 479 -> 458 bytes .../tritanium_striped_block_black_lime.png | Bin 489 -> 460 bytes .../tritanium_striped_block_black_magenta.png | Bin 485 -> 460 bytes .../tritanium_striped_block_black_orange.png | Bin 489 -> 466 bytes .../tritanium_striped_block_black_pink.png | Bin 489 -> 466 bytes .../tritanium_striped_block_black_purple.png | Bin 489 -> 466 bytes .../tritanium_striped_block_black_red.png | Bin 481 -> 462 bytes .../tritanium_striped_block_black_white.png | Bin 486 -> 463 bytes .../tritanium_striped_block_black_yellow.png | Bin 489 -> 466 bytes .../tritanium_striped_block_blue_black.png | Bin 544 -> 439 bytes .../tritanium_striped_block_blue_brown.png | Bin 554 -> 462 bytes .../tritanium_striped_block_blue_cyan.png | Bin 559 -> 458 bytes .../tritanium_striped_block_blue_gray.png | Bin 556 -> 451 bytes .../tritanium_striped_block_blue_green.png | Bin 554 -> 462 bytes .../tritanium_striped_block_blue_light_blue.png | Bin 570 -> 466 bytes .../tritanium_striped_block_blue_light_gray.png | Bin 559 -> 458 bytes .../tritanium_striped_block_blue_lime.png | Bin 570 -> 460 bytes .../tritanium_striped_block_blue_magenta.png | Bin 565 -> 460 bytes .../tritanium_striped_block_blue_orange.png | Bin 570 -> 466 bytes .../tritanium_striped_block_blue_pink.png | Bin 570 -> 466 bytes .../tritanium_striped_block_blue_purple.png | Bin 570 -> 466 bytes .../stripe/tritanium_striped_block_blue_red.png | Bin 562 -> 462 bytes .../tritanium_striped_block_blue_white.png | Bin 567 -> 463 bytes .../tritanium_striped_block_blue_yellow.png | Bin 570 -> 466 bytes .../tritanium_striped_block_brown_black.png | Bin 535 -> 439 bytes .../tritanium_striped_block_brown_blue.png | Bin 545 -> 462 bytes .../tritanium_striped_block_brown_cyan.png | Bin 549 -> 458 bytes .../tritanium_striped_block_brown_gray.png | Bin 546 -> 451 bytes .../tritanium_striped_block_brown_green.png | Bin 544 -> 462 bytes ...tritanium_striped_block_brown_light_blue.png | Bin 558 -> 466 bytes ...tritanium_striped_block_brown_light_gray.png | Bin 549 -> 458 bytes .../tritanium_striped_block_brown_lime.png | Bin 558 -> 460 bytes .../tritanium_striped_block_brown_magenta.png | Bin 554 -> 460 bytes .../tritanium_striped_block_brown_orange.png | Bin 558 -> 466 bytes .../tritanium_striped_block_brown_pink.png | Bin 558 -> 466 bytes .../tritanium_striped_block_brown_purple.png | Bin 558 -> 466 bytes .../tritanium_striped_block_brown_red.png | Bin 551 -> 462 bytes .../tritanium_striped_block_brown_white.png | Bin 555 -> 463 bytes .../tritanium_striped_block_brown_yellow.png | Bin 558 -> 466 bytes .../tritanium_striped_block_cyan_black.png | Bin 564 -> 439 bytes .../tritanium_striped_block_cyan_blue.png | Bin 574 -> 462 bytes .../tritanium_striped_block_cyan_brown.png | Bin 573 -> 462 bytes .../tritanium_striped_block_cyan_gray.png | Bin 576 -> 451 bytes .../tritanium_striped_block_cyan_green.png | Bin 573 -> 462 bytes .../tritanium_striped_block_cyan_light_blue.png | Bin 588 -> 466 bytes .../tritanium_striped_block_cyan_light_gray.png | Bin 578 -> 458 bytes .../tritanium_striped_block_cyan_lime.png | Bin 588 -> 460 bytes .../tritanium_striped_block_cyan_magenta.png | Bin 584 -> 460 bytes .../tritanium_striped_block_cyan_orange.png | Bin 588 -> 466 bytes .../tritanium_striped_block_cyan_pink.png | Bin 588 -> 466 bytes .../tritanium_striped_block_cyan_purple.png | Bin 588 -> 466 bytes .../stripe/tritanium_striped_block_cyan_red.png | Bin 580 -> 462 bytes .../tritanium_striped_block_cyan_white.png | Bin 585 -> 463 bytes .../tritanium_striped_block_cyan_yellow.png | Bin 588 -> 466 bytes .../tritanium_striped_block_gray_black.png | Bin 531 -> 439 bytes .../tritanium_striped_block_gray_blue.png | Bin 541 -> 462 bytes .../tritanium_striped_block_gray_brown.png | Bin 539 -> 462 bytes .../tritanium_striped_block_gray_cyan.png | Bin 545 -> 458 bytes .../tritanium_striped_block_gray_green.png | Bin 539 -> 462 bytes .../tritanium_striped_block_gray_light_blue.png | Bin 555 -> 466 bytes .../tritanium_striped_block_gray_light_gray.png | Bin 545 -> 458 bytes .../tritanium_striped_block_gray_lime.png | Bin 555 -> 460 bytes .../tritanium_striped_block_gray_magenta.png | Bin 551 -> 460 bytes .../tritanium_striped_block_gray_orange.png | Bin 555 -> 466 bytes .../tritanium_striped_block_gray_pink.png | Bin 555 -> 466 bytes .../tritanium_striped_block_gray_purple.png | Bin 555 -> 466 bytes .../stripe/tritanium_striped_block_gray_red.png | Bin 547 -> 462 bytes .../tritanium_striped_block_gray_white.png | Bin 552 -> 463 bytes .../tritanium_striped_block_gray_yellow.png | Bin 555 -> 466 bytes .../tritanium_striped_block_green_black.png | Bin 528 -> 439 bytes .../tritanium_striped_block_green_blue.png | Bin 539 -> 462 bytes .../tritanium_striped_block_green_brown.png | Bin 537 -> 462 bytes .../tritanium_striped_block_green_cyan.png | Bin 543 -> 458 bytes .../tritanium_striped_block_green_gray.png | Bin 540 -> 451 bytes ...tritanium_striped_block_green_light_blue.png | Bin 552 -> 466 bytes ...tritanium_striped_block_green_light_gray.png | Bin 543 -> 458 bytes .../tritanium_striped_block_green_lime.png | Bin 552 -> 460 bytes .../tritanium_striped_block_green_magenta.png | Bin 549 -> 460 bytes .../tritanium_striped_block_green_orange.png | Bin 552 -> 466 bytes .../tritanium_striped_block_green_pink.png | Bin 552 -> 466 bytes .../tritanium_striped_block_green_purple.png | Bin 552 -> 466 bytes .../tritanium_striped_block_green_red.png | Bin 545 -> 462 bytes .../tritanium_striped_block_green_white.png | Bin 549 -> 463 bytes .../tritanium_striped_block_green_yellow.png | Bin 552 -> 466 bytes ...tritanium_striped_block_light_blue_black.png | Bin 578 -> 439 bytes .../tritanium_striped_block_light_blue_blue.png | Bin 589 -> 462 bytes ...tritanium_striped_block_light_blue_brown.png | Bin 588 -> 462 bytes .../tritanium_striped_block_light_blue_cyan.png | Bin 593 -> 458 bytes .../tritanium_striped_block_light_blue_gray.png | Bin 590 -> 451 bytes ...tritanium_striped_block_light_blue_green.png | Bin 588 -> 462 bytes ...nium_striped_block_light_blue_light_gray.png | Bin 593 -> 458 bytes .../tritanium_striped_block_light_blue_lime.png | Bin 603 -> 460 bytes ...itanium_striped_block_light_blue_magenta.png | Bin 598 -> 460 bytes ...ritanium_striped_block_light_blue_orange.png | Bin 603 -> 466 bytes .../tritanium_striped_block_light_blue_pink.png | Bin 603 -> 466 bytes ...ritanium_striped_block_light_blue_purple.png | Bin 603 -> 466 bytes .../tritanium_striped_block_light_blue_red.png | Bin 595 -> 462 bytes ...tritanium_striped_block_light_blue_white.png | Bin 600 -> 463 bytes ...ritanium_striped_block_light_blue_yellow.png | Bin 603 -> 466 bytes ...tritanium_striped_block_light_gray_black.png | Bin 552 -> 439 bytes .../tritanium_striped_block_light_gray_blue.png | Bin 562 -> 462 bytes ...tritanium_striped_block_light_gray_brown.png | Bin 560 -> 462 bytes .../tritanium_striped_block_light_gray_cyan.png | Bin 565 -> 458 bytes .../tritanium_striped_block_light_gray_gray.png | Bin 563 -> 451 bytes ...tritanium_striped_block_light_gray_green.png | Bin 560 -> 462 bytes ...nium_striped_block_light_gray_light_blue.png | Bin 575 -> 466 bytes .../tritanium_striped_block_light_gray_lime.png | Bin 575 -> 460 bytes ...itanium_striped_block_light_gray_magenta.png | Bin 571 -> 460 bytes ...ritanium_striped_block_light_gray_orange.png | Bin 575 -> 466 bytes .../tritanium_striped_block_light_gray_pink.png | Bin 575 -> 466 bytes ...ritanium_striped_block_light_gray_purple.png | Bin 575 -> 466 bytes .../tritanium_striped_block_light_gray_red.png | Bin 568 -> 462 bytes ...tritanium_striped_block_light_gray_white.png | Bin 572 -> 463 bytes ...ritanium_striped_block_light_gray_yellow.png | Bin 575 -> 466 bytes .../tritanium_striped_block_lime_black.png | Bin 565 -> 439 bytes .../tritanium_striped_block_lime_blue.png | Bin 576 -> 462 bytes .../tritanium_striped_block_lime_brown.png | Bin 574 -> 462 bytes .../tritanium_striped_block_lime_cyan.png | Bin 579 -> 458 bytes .../tritanium_striped_block_lime_gray.png | Bin 578 -> 451 bytes .../tritanium_striped_block_lime_green.png | Bin 574 -> 462 bytes .../tritanium_striped_block_lime_light_blue.png | Bin 589 -> 466 bytes .../tritanium_striped_block_lime_light_gray.png | Bin 579 -> 458 bytes .../tritanium_striped_block_lime_magenta.png | Bin 585 -> 460 bytes .../tritanium_striped_block_lime_orange.png | Bin 589 -> 466 bytes .../tritanium_striped_block_lime_pink.png | Bin 589 -> 466 bytes .../tritanium_striped_block_lime_purple.png | Bin 589 -> 466 bytes .../stripe/tritanium_striped_block_lime_red.png | Bin 582 -> 462 bytes .../tritanium_striped_block_lime_white.png | Bin 586 -> 463 bytes .../tritanium_striped_block_lime_yellow.png | Bin 589 -> 466 bytes .../tritanium_striped_block_magenta_black.png | Bin 573 -> 439 bytes .../tritanium_striped_block_magenta_blue.png | Bin 584 -> 462 bytes .../tritanium_striped_block_magenta_brown.png | Bin 583 -> 462 bytes .../tritanium_striped_block_magenta_cyan.png | Bin 587 -> 458 bytes .../tritanium_striped_block_magenta_gray.png | Bin 584 -> 451 bytes .../tritanium_striped_block_magenta_green.png | Bin 583 -> 462 bytes ...itanium_striped_block_magenta_light_blue.png | Bin 597 -> 466 bytes ...itanium_striped_block_magenta_light_gray.png | Bin 587 -> 458 bytes .../tritanium_striped_block_magenta_lime.png | Bin 597 -> 460 bytes .../tritanium_striped_block_magenta_orange.png | Bin 597 -> 466 bytes .../tritanium_striped_block_magenta_pink.png | Bin 597 -> 466 bytes .../tritanium_striped_block_magenta_purple.png | Bin 597 -> 466 bytes .../tritanium_striped_block_magenta_red.png | Bin 589 -> 462 bytes .../tritanium_striped_block_magenta_white.png | Bin 594 -> 463 bytes .../tritanium_striped_block_magenta_yellow.png | Bin 597 -> 466 bytes .../tritanium_striped_block_orange_black.png | Bin 578 -> 439 bytes .../tritanium_striped_block_orange_blue.png | Bin 589 -> 462 bytes .../tritanium_striped_block_orange_brown.png | Bin 588 -> 462 bytes .../tritanium_striped_block_orange_cyan.png | Bin 593 -> 458 bytes .../tritanium_striped_block_orange_gray.png | Bin 590 -> 451 bytes .../tritanium_striped_block_orange_green.png | Bin 588 -> 462 bytes ...ritanium_striped_block_orange_light_blue.png | Bin 603 -> 466 bytes ...ritanium_striped_block_orange_light_gray.png | Bin 593 -> 458 bytes .../tritanium_striped_block_orange_lime.png | Bin 603 -> 460 bytes .../tritanium_striped_block_orange_magenta.png | Bin 598 -> 460 bytes .../tritanium_striped_block_orange_pink.png | Bin 603 -> 466 bytes .../tritanium_striped_block_orange_purple.png | Bin 603 -> 466 bytes .../tritanium_striped_block_orange_red.png | Bin 595 -> 462 bytes .../tritanium_striped_block_orange_white.png | Bin 600 -> 463 bytes .../tritanium_striped_block_orange_yellow.png | Bin 603 -> 466 bytes .../tritanium_striped_block_pink_black.png | Bin 575 -> 439 bytes .../tritanium_striped_block_pink_blue.png | Bin 585 -> 462 bytes .../tritanium_striped_block_pink_brown.png | Bin 583 -> 462 bytes .../tritanium_striped_block_pink_cyan.png | Bin 589 -> 458 bytes .../tritanium_striped_block_pink_gray.png | Bin 586 -> 451 bytes .../tritanium_striped_block_pink_green.png | Bin 583 -> 462 bytes .../tritanium_striped_block_pink_light_blue.png | Bin 599 -> 466 bytes .../tritanium_striped_block_pink_light_gray.png | Bin 589 -> 458 bytes .../tritanium_striped_block_pink_lime.png | Bin 599 -> 460 bytes .../tritanium_striped_block_pink_magenta.png | Bin 595 -> 460 bytes .../tritanium_striped_block_pink_orange.png | Bin 599 -> 466 bytes .../tritanium_striped_block_pink_purple.png | Bin 599 -> 466 bytes .../stripe/tritanium_striped_block_pink_red.png | Bin 591 -> 462 bytes .../tritanium_striped_block_pink_white.png | Bin 596 -> 463 bytes .../tritanium_striped_block_pink_yellow.png | Bin 599 -> 466 bytes .../tritanium_striped_block_purple_black.png | Bin 564 -> 439 bytes .../tritanium_striped_block_purple_blue.png | Bin 573 -> 462 bytes .../tritanium_striped_block_purple_brown.png | Bin 573 -> 462 bytes .../tritanium_striped_block_purple_cyan.png | Bin 576 -> 458 bytes .../tritanium_striped_block_purple_gray.png | Bin 575 -> 451 bytes .../tritanium_striped_block_purple_green.png | Bin 573 -> 462 bytes ...ritanium_striped_block_purple_light_blue.png | Bin 588 -> 466 bytes ...ritanium_striped_block_purple_light_gray.png | Bin 576 -> 458 bytes .../tritanium_striped_block_purple_lime.png | Bin 588 -> 460 bytes .../tritanium_striped_block_purple_magenta.png | Bin 584 -> 460 bytes .../tritanium_striped_block_purple_orange.png | Bin 588 -> 466 bytes .../tritanium_striped_block_purple_pink.png | Bin 588 -> 466 bytes .../tritanium_striped_block_purple_red.png | Bin 580 -> 462 bytes .../tritanium_striped_block_purple_white.png | Bin 585 -> 463 bytes .../tritanium_striped_block_purple_yellow.png | Bin 588 -> 466 bytes .../tritanium_striped_block_red_black.png | Bin 545 -> 439 bytes .../stripe/tritanium_striped_block_red_blue.png | Bin 554 -> 462 bytes .../tritanium_striped_block_red_brown.png | Bin 553 -> 462 bytes .../stripe/tritanium_striped_block_red_cyan.png | Bin 557 -> 458 bytes .../stripe/tritanium_striped_block_red_gray.png | Bin 555 -> 451 bytes .../tritanium_striped_block_red_green.png | Bin 553 -> 462 bytes .../tritanium_striped_block_red_light_blue.png | Bin 567 -> 466 bytes .../tritanium_striped_block_red_light_gray.png | Bin 557 -> 458 bytes .../stripe/tritanium_striped_block_red_lime.png | Bin 567 -> 460 bytes .../tritanium_striped_block_red_magenta.png | Bin 563 -> 460 bytes .../tritanium_striped_block_red_orange.png | Bin 567 -> 466 bytes .../stripe/tritanium_striped_block_red_pink.png | Bin 567 -> 466 bytes .../tritanium_striped_block_red_purple.png | Bin 567 -> 466 bytes .../tritanium_striped_block_red_white.png | Bin 564 -> 463 bytes .../tritanium_striped_block_red_yellow.png | Bin 567 -> 466 bytes .../tritanium_striped_block_white_black.png | Bin 575 -> 436 bytes .../tritanium_striped_block_white_blue.png | Bin 586 -> 459 bytes .../tritanium_striped_block_white_brown.png | Bin 585 -> 459 bytes .../tritanium_striped_block_white_cyan.png | Bin 590 -> 455 bytes .../tritanium_striped_block_white_gray.png | Bin 587 -> 448 bytes .../tritanium_striped_block_white_green.png | Bin 585 -> 459 bytes ...tritanium_striped_block_white_light_blue.png | Bin 600 -> 463 bytes ...tritanium_striped_block_white_light_gray.png | Bin 590 -> 455 bytes .../tritanium_striped_block_white_lime.png | Bin 600 -> 457 bytes .../tritanium_striped_block_white_magenta.png | Bin 595 -> 457 bytes .../tritanium_striped_block_white_orange.png | Bin 600 -> 463 bytes .../tritanium_striped_block_white_pink.png | Bin 600 -> 463 bytes .../tritanium_striped_block_white_purple.png | Bin 600 -> 463 bytes .../tritanium_striped_block_white_red.png | Bin 592 -> 459 bytes .../tritanium_striped_block_white_yellow.png | Bin 600 -> 463 bytes .../tritanium_striped_block_yellow_black.png | Bin 578 -> 439 bytes .../tritanium_striped_block_yellow_blue.png | Bin 589 -> 462 bytes .../tritanium_striped_block_yellow_brown.png | Bin 588 -> 462 bytes .../tritanium_striped_block_yellow_cyan.png | Bin 593 -> 458 bytes .../tritanium_striped_block_yellow_gray.png | Bin 590 -> 451 bytes .../tritanium_striped_block_yellow_green.png | Bin 588 -> 462 bytes ...ritanium_striped_block_yellow_light_blue.png | Bin 603 -> 466 bytes ...ritanium_striped_block_yellow_light_gray.png | Bin 593 -> 458 bytes .../tritanium_striped_block_yellow_lime.png | Bin 603 -> 460 bytes .../tritanium_striped_block_yellow_magenta.png | Bin 598 -> 460 bytes .../tritanium_striped_block_yellow_orange.png | Bin 603 -> 466 bytes .../tritanium_striped_block_yellow_pink.png | Bin 603 -> 466 bytes .../tritanium_striped_block_yellow_purple.png | Bin 603 -> 466 bytes .../tritanium_striped_block_yellow_red.png | Bin 595 -> 462 bytes .../tritanium_striped_block_yellow_white.png | Bin 600 -> 463 bytes 241 files changed, 5 insertions(+), 2 deletions(-) diff --git a/colomposer.js b/colomposer.js index b65a227b3..6a7a2bb2f 100644 --- a/colomposer.js +++ b/colomposer.js @@ -48,21 +48,24 @@ for (const colorA of colors) { const magick = child_process.spawn('magick', [ 'convert', - '-compose', 'Multiply', '-size', `${width}x${height}`, '(', `${root_main}${texA}.png`, `xc:rgb(${rgbA[0]}, ${rgbA[1]}, ${rgbA[2]})`, + '-compose', 'Multiply', '-composite', ')', '(', `${root_main}${texB}.png`, `xc:rgb(${rgbB[0]}, ${rgbB[1]}, ${rgbB[2]})`, + '-channel', 'rgb', + '-compose', 'Multiply', '-composite', ')', - + + '-channel', 'rgba', '-compose', 'Over', '-composite', diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_black_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_black_blue.png index a0a64f4a12a94011dbe87b4edc3487337c4c1c72..080eda87c0a80cd75f130628477157075156ec6e 100644 GIT binary patch delta 332 zcmcc3e2#g71SbnK0|Ud`yN`kvu*y7`9>lcgU*+E&OA1VEZuEMo)Ue3xb!K?y z8zgxmVbY0tT4I|!j|y8z)>N^|7f&n7QLj!^8E<Bq?NKf_n!C_I=&Twb; z5~B$RRVLbo>ZA#Gs}~sk_`+rPN$2McmjbV;i(0o$+k3V0XZ}5Ny;OF7wpBZo{{Ssh zEpd$~sZU8PNwrEYN(E93Mg~U4x(3F&hQ=X=rd9^VK%{M8U}a#CqPnpnA-7jSNBz4XvaNEUXMIA+`hCk iWnl2#fxl*QETgy@cIh_R?FWG7F?hQAxvXsekrd2W+85m*LAY51Z z7N|i3Y%oYeNoHO>_%)r36AA}h#Sc6r7g6t)pzOL-gSVcLE*jB!~B?lDh^K@|xsh7Cy>wi(`umTU0 zQS{v4+yDRH6x`ijxO|4p1daeMqd24Ph9jR27X~q2XAl;P;+q;ZRW&z6xg<<1wY#-y zInx^3Mc(qR+#d>hzFKzW$e!~lXS3LLa_3wAGj3{awwW(o?pvp%-9>;=IxzHEk0N|ELhAL0I= zM;^1@k+Iv`$iH^cbAf}3zE`;RzJ9Ux-T$+{kFkbo^QGNSuG;{#N43N?q9i4;B-Lti z4I`J7v95u!uAy;=p{bRDF%W4R7+4t?Bq<*ZoVL6hhgGG zx%y|Uq8vtSE8pFc14{LHx;TbNT=w<9D0J9>gDK`#%FN8~|Lv_ae;d5(SJ5H#Uq zP^#dB8*(|;qAR2p1Rh!BytaI23a2T@+qu4Z8w2x=57;R$`x4m0uzi!}KKF^qi)_|z zbG*qn_5Ba#yBm_H9Gm2MCY!x{UAdBR_|ZbW=kpBF~4S%Aaq19%NK(ke=%CgTtb#o#D>x zB}Nkts!X&E)kzcXRxdF6@rBFolg`f@E(Kmw7qxDiw)bk~&-{Dlda3OEY^!!E{{dR2 zTH+c}QlFAol4_M)lnSI6j0}v7bq$Pl4UIz#O|1-!fk@lHz{$POb1v)ZhlH; zS|x4`!gZBzff_VGR)95>Wag$8mn7yEK=qjE8X1Hb8d^ykSXdcaKy3Nu{{J^n6N9I# KpUXO@geCxB5OxFr delta 354 zcmX@de3N;C1SbbG0|SGGE`RVuMSCB!0G|+7QBetLX*nq=IcaHmNl95jL16&_Aprql zQBiSud1W~{B`GOcF)@jdT$$i(ncy6mpe*VC|NnP8NN@v9VodUOcM*KF)ppm!>2meY zSVcLE*jB!~B?px1_H=O!k+|&Ze^KbL0uPf>cx>9+|MhR1-X7l3ZCT`?%2F1)teC(@1A$vu6td(M^PTpQ9|yyA~?e26t%`dzC?MeA}Nd&rxB zr+xMpnAP1Xb3B#4^Uix?Zus10^|jJnXFG$l?IOw(cdjj-IsMxqyW7+6{9pOLs(#jc z+aHW#kt|>CW=LlM-KARM8c~vxSdwa$T$Bo=7>o>zjC2i5bq&oz3{9*IEUgSpwG9lc h3=F>S5uQyLfgUx3pOZBV7$gA#+YrMB4EPC?8qU{A@ShA)w4(U>RvtCnz+ilqg!0S zNQd|PsVJ#O&l&@mi`f`*ck=to-YW(=he5T(HKHUXu_Vlzw| z7@Arc7z2^Efq|8QK~jnG!9Wxpx%nxXX_dHj2-j7<1!~ZMTTzmkn_66wm|FnVW2S3l f5MpR(Wnf`tXaTY1oBRLYKs^keu6{1-oD!M<4G(w( delta 352 zcmcb_{E~Ts1SbbG0|SGGE`RVuMf*_u0G|+7QBetLX*nq=IcaHmNl95jL16&_Aprql zQBiSud1W~{B`GOcF)<12Ew`;V-?G|x!+P^gs}0vI*I%{TbmRa3|1*t@#ehaKCV9KN zh)lYF(sbf1x%y|Uq8vtSE8pFc14>Quba4!kxa{kHQRuJ&hxehFQoh{h|Np-}@GkLA zW`j2q!<3#a?M$u?Nk5N%UceK`e1;?G!or}{n^HKga>!0~y_vKy?j%FD`Rhy3*LZ5$ zd_NS6+_XAmd^J;GoA1Nh|C(-kxO4k@SzY|jck^a_JOBK5b#a=-eGbRf6VhMTMI_JJ z_l)bygSZ>n&(*%$7UrFMANk($2a|jPt9-f8!wZuQ7{#TGbPY^(4b4IfO{@$otqe`I k4GgRd48A+?*Gx`i6j#G8-6p&J0MK&`p00i_>zopr08{#bs{jB1 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_black_light_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_black_light_gray.png index f3f3dc40dc57a2b96fcf8a9ff566ea44369bbee0..589e8c777f835437dd6b63dfe339e967401aea71 100644 GIT binary patch delta 348 zcmcc5e2RI31SbnK0|Ud`yN`kO>_%)r36AA}h#Sc6r7g6t)pzOL-gSVcLE*jB!~B?lDh^K@|xsh7Cy>wi(`umTU0 zQS{v4+yDRH6x`ijxO|4p1daeMqd24Ph9jR27X~q2XAl;P;+q;ZRW&z6xg<<1wY#-y zInx^3Mc(qR+#d>hzFKzW$e!~lXS3LLa_3wAGj3{awwW(o?pvp%-^~1SbnK0|Ud`yN`kUJwiviuZJJ4B@!$+Lz1QV8G*&uW^HynVFqi%**kBkVrj`ro{pMr7RVH zKmRK96nx>bLAuxH2oKA#29`UslZ+;uTspzl*XEgUzj#5>k1uR?X;YtOC|NA+idvYv zYx}C#^`G|@GA8iy?bof_;RUoywZt`|BqgyV)hf9t6-Y4{85kMs8W`&u8iyE~S{WDv zk+y+>m4QK$^1(o$hCGCh-29Zxv`XAMgzGBb0(EG>ttiRNO)V}-%q@WGG1E0N2r)FY bGO(~Rw1C+1&HevxpdJQKS3j3^P65O+0U>#Q*>QZ+8@X0F7i!@^*I- znRNf8>BQ-B_0L#EIgHp=zPlv{l$zw};us=v+1LM~&|w7*??W-Ae7Vp6|9^epUE-b0 z25%;YDLq@-nOq%`ejfe2fG3do3`f$1g+Z$~rEpy3ke%v!GihPmNrr6m*O#KN@zk{W zekc~XX?4i>YNo(8--oyVHQn@Z=l1ooy7-;%=FR$c{`v3f;_8e09FD6eq`$61dPPegLS0!PC{xWt~$( F696^Kif{k` diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_black_magenta.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_black_magenta.png index e4fd730a6a32960e79a26ef586879e84b178e9e3..bf2de6158e03ed71313f157d7bbde9314aeff396 100644 GIT binary patch delta 386 zcmaFLe1>^~1SbnK0|Ud`yN`kmY*DNDuQ z&%X*i1z)&qknZ(4!ozZ`f#uHZB%=u@mrk(twRtAoFJ4ge;|rTz+SI2RN)}7Iq88@v z+P>;_{pWp!j0wDa`*rJfcmeHFEpd$~Nl7e8wMs5Z1yT$~21drZ2FALE#vz8LRtCmE zq-|heWnhq`d@vBGArGM=H$NpatrE8m;kwGVKph%zD@rnRQ;SOya|@t)%yf+mLJSS9 b3@oe+Eg-ghbN~MvsE5JR)z4*}Q$iB}byj;u delta 385 zcmX@Z{FHfu1SbbG0|SGGE`RVuMf)I|0G|+7QBetLX*nq=IcaHmNl95jL16&_Aprql zQBiSud1W~{B`GOcF)@i<_Um`ruiI|7W}DsWt+uOn*scBl|NrcFb$fv3F(!Gty9o2_ zj+r)bx?KG;R#6Tkww3R0$pNJ%db&7yzbJHAfy4XIu2*wz{roS#JK?**JCg&d zj0|3m$DG{+Csh1-R2js0ox#}0MAphHaN3rDsTU$EG@@-*gc}{Wq%`YG*cFEP+YIg9 zCvH7BZ>1me?Xa8M|FLeK*q7+*C3W!|-_4u#&hoY2?j1L+e{N7#!($!&{jgN>7t`q* zXICe#pF8``_aArW+~0Js_yeoVBvzs21vc$K*Qu7cMwFx^mZVxG7o`Fz1|tI_BV7Yi zT|=`FLlY|lODjWDZ36=<1B34l{52>Va`RI%(<-rO5Qpk$lihv*sDr`N)z4*}Q$iB} D>KlrM diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_black_orange.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_black_orange.png index 43ff3cb657bf1bb0fbeccbd05b1c10bff61f588b..d48bb2c4f7625dadc2b4319b9d4efddb90f5e5ec 100644 GIT binary patch delta 392 zcmaFKe2IC21SbnK0|Ud`yN`kA#$nz{1MV0%FTI_y50vdKf%i{an^LB{Ts5hWB>YuTSau~6#e0NI@C^gB`#W6(UvakO|p~DIs-iKmJ`EsBC|Nr{HyTm)0 z4c<%)Q+l?vGr2k>{XF`40Z$Tn0M}dO!5h=^5sGgFHAOI6qhp6H89mRGz&2_u`;l>S5uQyLfgUx3pOZBV7$gA#+YrMB4EPC?8qU{A@ShA)w4(U>RvtCnz+ilqg!0S zNQd|PsVJ#O&l&@mi`f`*ck=to-YW(=he5T(HKHUXu_Vlzw| z7@Arc7z2^Efq|8QK~jnG!9Wxpx%nxXX_dHj2-j7<1!~ZMTTzmkn_66wm|FnVW2S3l f5MpR(Wnf`tXaTY1oBRLYKs^keu6{1-oD!MQuba4!kxa{kHQRuJ&hxehFQoh{h|Np-}@GkLA zW`j2q!<3#a?M$u?Nk5N%UceK`e1;?G!or}{n^HKga>!0~y_vKy?j%FD`Rhy3*LZ5$ zd_NS6+_XAmd^J;GoA1Nh|C(-kxO4k@SzY|jck^a_JOBK5b#a=-eGbRf6VhMTMI_JJ z_l)bygSZ>n&(*%$7UrFMANk($2a|jPt9-f8!wZuQ7{#TGbPY^(4b4IfO{@$otqe`I k4GgRd48A+?*Gx`i6j#G8-6p&J0MK&`p00i_>zopr0GY>xuK)l5 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_black_purple.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_black_purple.png index 7b28def84ec49126587eaeb84e61116c0e7d65b8..1a97cf7f4e5741b50515d9827b15d6265ad4a3ae 100644 GIT binary patch delta 392 zcmaFKe2IC21SbnK0|Ud`yN`k}cX|DWz6l?~L#nB?v5!YzOO$N?aSv%n*=n1O+BKL|5gum-CD1=&kH zeO=j~vx#tX2rZbsAQ&i=2OC7#SED>lzsA8XAWf znpznc1Ch3Yft7(lQi<}xKolLh`6-!cmAG{X*Hyj+YS4gNQIeUPT3nKtTL9H#rfXyn eVrXb(U}0rw0kP$q`~TlSJq(_%elF{r5}E+xjdUvj delta 352 zcmcb_{E~Ts1SbbG0|SGGE`RVuMf*_u0G|+7QBetLX*nq=IcaHmNl95jL16&_Aprql zQBiSud1W~{B`GOcF)@h}wUs4mD~eQ?6|1c%R9#xAx};cb`Tzg_5AQ8p4m6T6$=lsU zWYYbUrW0q$)jwkuE=i(`nyWnce`LWdPNybr~c^5s7N|Nr%YcZqj0 z8@!nqru1xSXL5B&`g!#80-iwTGaN}576z@}l)`b9Lw2g`&7_5KCmFKMUtfy8##7Vg z`=MCmrqv`Ka*L2gvo!i&T>f(34n>Xv*`RBi@i_B@@#|Nk$w5#k4GVodUOcj3yo@Fi^Gdb#@NY$Dto!q?|aI0}?X^mK6y;kfSF zm&@B=z~hpyaf6qcnVnngR9l0phJwZnR+$IWgP8XGtNgoTNr8#Yjb1O68Wx$o&J6E- zgCtKROgb@7OKfxJQDFb@zLypEZ}#_I?&J!-$CEPo>wuQ2 zmbgZg)Tbntq*^5xr2;7iBLgF2T?1oXL*o!bQ!4{wAksE4ure@6Qa%_6(*f3yo1c=I zR*74Ka9!nFpau<)6<`e|nYpROC5gEOP(5b4Mg}2zm0Xkxq!^40jEr;*Omz*-LJUo; q3@oh-O|=aStPBjkJMh;`j%5^A!!F$>yZr#rJO)o!KbLh*2~7Y=0eb)d diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_black_white.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_black_white.png index b70e6ecceafca4f2a43c683ae0e8766ac750d638..eed5f76d3e7c921958889e4d570eb36de717f514 100644 GIT binary patch delta 389 zcmaFHe4crN1SbnK0|Ud`yN`kCdSIjX5D1PG)E1SBLRh=?TArwAk^Fr1WN zlI&_~a!P1hxM0Bsg$az;*u)sK%~J$S*q9wTPnpnA-7jSNBz d4Xq3;tPCw6wtRE{{~M@>!PC{xWt~$(69B+qey9Kd delta 332 zcmX@l{ET^m1SbbG0|SGGE`RVuMSC5a0G|+7QBetLX*nq=IcaHmNl95jL16&_Aprql zQBiSud1W~{B`GOcF)@jWg`$EJWD0_S+8L9)-CcOUZAtt(ak^anGgeU!Bes?AZpi_q zCV9FzhDcoY^}i@|Sb@X)P)sRb?(_fuUmtjvcqg;Ln~7mc&z5#3SBIpZM?Wv%31mLQ zk#u2U(CSSo99KDHr@G!uS{QedA=~`*rRZxsHEq5hibZZ(9WuU}DX`7=;q8A-H$B|B zeZ8zMe&@S+v%Z~w{=2$3&Eh_X>S5uQyLfgUx3pOZBV7$gA#+YrMB4EPC?8qU{A@ShA)w4(U>RvtCnz+ilqg!0S zNQd|PsVJ#O&l&@mi`f`*ck=to-YW(=he5T(HKHUXu_Vlzw| z7@Arc7z2^Efq|8QK~jnG!9Wxpx%nxXX_dHj2-j7<1!~ZMTTzmkn_66wm|FnVW2S3l f5MpR(Wnf`tXaTY1oBRLYKs^keu6{1-oD!M<{d#$G delta 352 zcmcb_{E~Ts1SbbG0|SGGE`RVuMf*_u0G|+7QBetLX*nq=IcaHmNl95jL16&_Aprql zQBiSud1W~{B`GOcF)@ih$5nnGQ~7a3`PWgEZ-9#Z~!ROSEw|C^q*Edd(InB?v5 zA~NazNz;k5g=4c>zx#^BIn$3k!o*Z%W~~${{<|^=8t-xRVUo=C3bBU*oB1 z^ZigPa?|RN@zqR$ZN3k0|7*JG;m+;rWp(j8-_4u#?fmoK)x~KR_cFdh=oK1wALukS51;Id} zFi#i95RU7veHR5A3^<&F)iYi(UFEG>#~?lBZ+PaB;QQB=Cs+r}2q~zyc2&<}=gM|u zes^|)Op3SU6F<*uMkjwUtZzB5^WkBhTw>dX%py;X8Snm|{e6tdJ&uoY-p;!{L0G|+7WtB`Fy>@NgW?lVG9lcf^y*4fFdTren zWz}qHnP3^&5GiSYX_+8hy$&7SR%MkeCFOJ_l?)@3nMNklwRM`5Rdb9@XG_Zj8k^42 z)$h>OX_S{&mX}wOlT-Tt|9__7s_Q@t8I!!-UF3?m6tsaH&H|6fVg?4j{S&7P)jwku z#KZ>`QvyWy)FB0V&!~QUL@w-OboR=&#nrF=tlk(#IJ!$K; zjeE~MX7@h#HU3lgWB%no)*X+Vbh4I1%XF^Y2I*7x^1n(4Nb+#4R-MBSbhm1WYeY#( zVo9o1a#1RfVlXl=GSW3L)ipE=F*LCv T+3g2_Iv6}%{an^LB{Ts5w-=gy diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_blue_brown.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_blue_brown.png index f01cce5576689c6954ecc91d8e970f7014f53885..3b7486a7af76eeba374be72f0f9617d8bfba61f8 100644 GIT binary patch delta 343 zcmZ3*a*la|1SbnK0|Ud`yN`kbW<;IRnK=- z&vR8Pa8v*P|9@us&1pbQj7i?^E?gNGzJyJ@CRhKQO@y06Xu<3S!9b}*PZ!4!j_a;{ z-hvGVJTBWcUWhTXvdii$G1x24DPz#Uta3$Pk>^8E<Bq?NKf_n!C_I=&Twb; z5~B$RRVLbo>ZA#Gs}~sk_`+rPN$2McmjbV;i(0o$+k3V0XZ}5Ny;OF7wpBZo{{Ssh zEpd$~(M(A!NwrEYN(E93Mg~U4x(3F&hQ=X=rd9^VK%{M8U}a#Cq@pnDD2Y0 zb(L>{25Nu|1e;fqnVVW%l9*cnHPTGi$RNbf(8|EV%FqI0`M0G|+7WtB`Fy>@NgW?lVG9lcf^y*4fFdTren zWz}qHnP3^&5GiSYX_+8hy$&7SR%MkeCFOJ_l?)@3nMNklwRM`5Rdb9@XG_Zj8k^42 z)$h>OX)JQrC~#9RbkoRpRsaA0|2{v5e?U7Klf2zsA@kbB&ON* zN%3WyS5k)U)vDin9OkH0t?dagJs#S+=I%Q&u4d!g%qr8XON3drY_#oNbA1Qzcg1h1 zsa6knb8*|~H&pUD?LTD7)xL5{CdC3w0xhHzYW?aSqD zFyL{?*SNvU%*@U$cB-vGRYO5z2FnFsO~$zYd+K6>ETrV#xTy-+G4{X0G|+7WtB`Fy>@NgW?lVG9lcf^y*4fFdTren zWz}qHnP3^&5GiSYX_+8hy$&7SR%MkeCFOJ_l?)@3nMNklwRM`5Rdb9@XG_Zj8k^42 z)$h>OX%uUlDAqbbtfgPHxlgpI_y7O@-i0@A0j*_B@^*Jo*qm+K0OW8Mc+^K0GcfS& z2Vq7F)?gK&D0_*guPggAR#6TkR)go=OMpUKJY5_^BrdD=cjq}9ayU0Wn3&SKZ_}FS zqTB!fpI&%X$cjTTrz2vC#;JA{-l<0}RIU2@t+L6&^GlTE!mPf{T#>tDbVbqgPWF28z;oKSNuEj*_&I}l zn|VFkC;i;|k1^~9kLJ1Ml_5Y6sFt`!l%yn#a`RI%(<xzHEk0N|ELhAL0I= zM;^1@k+Iv`$iH^cbAf}3zE`;RzJ9Ux-T$+{kFkbo^QGNSuG;{#N43N?q9i4;B-Lv2 zX+|z7V_gGdT|?s#LsKgQV<6HtFt9Q(NK!r+IQc!JcocSN;kwGVK%+F^MwMjdrWThZ r<`ys*85jZenCTiBgcurH8CX~unnR3a;O`d#>S6G7^>bP0l+XkKxLRsy delta 443 zcmX@iyoP0h1SbbG0|SGGE`RVuMf>{X0G|+7WtB`Fy>@NgW?lVG9lcf^y*4fFdTren zWz}qHnP3^&5GiSYX_+8hy$&7SR%MkeCFOJ_l?)@3nMNklwRM`5Rdb9@XG_Zj8k^42 z)$h>OX|!{4vvqW}b9A+JaItZ4`TzfaWn$(hptX!i-tI06o3m{jfE>;OkBQSI>YuTS zau~51Jnvot6x-^8E<Bq?NKf_n!C_I=&Twb; z5~B$RRVLbo>ZA#Gs}~sk_`+rPN$2McmjbV;i(0o$+k3V0XZ}5Ny;OF7wpBZo{{Ssh zEpd$~(M(A!NwrEYN(E93Mg~U4x(3F&hQ=X=rd9^VK%{M8U}a#Cq@pnDD2Y0 zb(L>{25Nu|1e;fqnVVW%l9*cnHPTGi$RNbf(8|EV%FqI0`M0G|+7WtB`Fy>@NgW?lVG9lcf^y*4fFdTren zWz}qHnP3^&5GiSYX_+8hy$&7SR%MkeCFOJ_l?)@3nMNklwRM`5Rdb9@XG_Zj8k^42 z)$h>OX$;Ag3C@-Y&XEbqlK%hy|8nPME1;c>N#5=*@~pf9dx0Fz0*}aIhKUPA>z}cT zau~51Jnvot6yD_N;us=vS+}1%kHwI~x$(iICEUNgFXtK?f45JQEY-D*^x%+I64UJZ zr1-MUD=EYFYSr&O4s%qh*7gLL9uI9@bN8JXSF`bLW|isHCBiIQHrn>CxxRz+w<9 zxhLy#mala^UX}g7{oCblx%SWR*q$(o+vLgeNilI%;s(W;0h{(;vk&3sk@eoq&I)wC zYKdz^NlIc#s#S7PDv)9@GB7gIH89mRGz&2_u`;l&lnh&@4b%V{2r;iDGdH!kBr&%DYNVO2kwJ)|p_PG!m7zJrNCy6XA)p=xPgg&e IbxsLQ04acPK>z>% delta 433 zcmcb_yo+Um1SbbG0|SGGE`RVuMf>{90G|+7WtB`Fy>@NgW?lVG9lcf^y*4fFdTren zWz}qHnP3^&5GiSYX_+8hy$&7SR%MkeCFOJ_l?)@3nMNklwRM`5Rdb9@XG_Zj8k^42 z)$h>OX|&#Q+j{dYtBp6TH{Z0{aLsc4RjW-m{{R0!S!BWopyiB7-tI0+v8gd@CeD(p zf5s}xVZ>_iyn6{yYNw}*V~E6M)&ARg%!V8;jK)XHn0H<&y2W>8eb+=%%urQ5rnwa?B^pS$EM_;KH$Qi79)J zrS9P0=&ya5Gd?upK_%mvVu4?h>jEu&mij242-tJ~`J9!v=Oivs6Vmu0=3wZ+EF<&k z4NuwMgXm45BcCanQ>Eyqt zdd65G9*^w6HMWxt7{#TGbPY^(4b4IfO{@$otqe`I4GgRd48A+?*Gx`i6j#G8-6p&J R05A*~JYD@<);T3K0RS?*rP2TZ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_blue_light_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_blue_light_gray.png index a93db72a40b1d764d481979a32e7975cdb80e432..aa8033dc5c1334660dffe8c13ffe714972cfcbb2 100644 GIT binary patch delta 348 zcmZ3_a*BC^1SbnK0|Ud`yN`k{X0G|+7WtB`Fy>@NgW?lVG9lcf^y*4fFdTren zWz}qHnP3^&5GiSYX_+8hy$&7SR%MkeCFOJ_l?)@3nMNklwRM`5Rdb9@XG_Zj8k^42 z)$h>OY3%7~?(S~t>T2xlZ0P8y|NsAg&ibEhKx-M3yxm>&pI&Rg}Ys)!=#e5}?o)PZ!4!iOZ_}-FeQ29L|joCZ@FR+q5RS z==T5rrx#uovf@z8>4;dOajIQ~cj}P~Rja;!t8B9H{1PR(FspAfSLE&(T@kkQZPFfo z*I%e{WF+sFj$B_T`Of*x>H1S8hss68D&iPE%e2(BWsC3yYhLCslJB=nzm|K>AV`=~ zFf^*SQ^?eoGnPZotg+HZZ&_4vJ=lf9li@SOH-lBd!He$HUt zW?s+sNk6y#V+^~&qj_$5WeCs%swJ)wB`Jv|saDBFsX&Us$iT=**T7Ua$j~gr(8S8X u(#p_O+rYrez~H+Be+`O`-29Zxv`V-R3=M6v+YbOWFnGH9xvX diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_blue_lime.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_blue_lime.png index df6afdcde55eb2070948c8c4633cf3df532834d5..577821e527dc7bca333e55f45bf74b46e37e3a79 100644 GIT binary patch delta 341 zcmdnRa)x<=1SbnK0|Ud`yN`ki80CB-GwXT!k4g#_vPxJvx#tX2wG11_!1};@9E+g!g1ZT zFPFE$fX5|Y;|4D?Gds7Km*W8;5gtv81Nuu@D*k@{Rp=@B!exVWug?)4mSYVpcV;IU zO*px9f~~L3GvR*mf}$T^*zD4#KFv_FSlSh}Fn8DXRj=zm?<-_X;N{z|TergtXq9S- zYeY#(qIyZHRdP{kVo554k%5u1u7Rc?zsg;2-5NR72SQ!{3DIW}+{FhNY3cIv$ zUFBP#ff^74f##KD=B5^xB<2=CjWp9WG6*p=v@)=;GBk%6$-v()1k}Ue>FVdQ&MBb@ E0G6q6z5oCK delta 470 zcmX@Zyo+Um1SbbG0|SGGE`RVuMf>{90G|+7WtB`Fy>@NgW?lVG9lcf^y*4fFdTren zWz}qHnP3^&5GiSYX_+8hy$&7SR%MkeCFOJ_l?)@3nMNklwRM`5Rdb9@XG_Zj8k^42 z)$h>OY0Td(k-tkKcZWpYE{UA&;yK&I^L9%7|NsBux(n-omNO=KySpgGrpBz9I9;y( z8LKFV5v#%T?j=B}ot`d^ArhBW`)}tl8*;cX8XqlV-g%|;a+UeXfB*f(wt6f!=I@Z~ zh*+X=YPJgR)FT(F{9eEP%ThS$#a1Jyt1{`Lo62@ZY4DuOF`qDJ-9=x43&*}CrtCeI zx`ThCzxHL$_|S+4m5gVK1%64c3$*ZA>Z5$3e$V~qb5`D-lek1pNaKf?gP{YnjLfSy zJY|0uZe3fu_G`tv-_v5gc>US=IKCw3cCzg6i7`8WtDLSlsU~=$y=7(F!L}5qlmDXX z8DoWbJhB7V*aCf_TH+c}l9E`GYL#4+3Zxi}42+C)4NP?n%|Z-KtPCuz3{ABS46FcptHiCNO?LYMpaup{S3j3^P6FZ0=9zH6ctO#RFKl*cQ=euiSuE{}T9~_Q`>NOVpZ66qCh+p@*R9*(1++@F z#5JNMC9%FF)hf9tHL)a>!N|bKSl7T<*U&h`(A3Jn7>KkD46F`+0G|+7WtB`Fy>@NgW?lVG9lcf^y*4fFdTren zWz}qHnP3^&5GiSYX_+8hy$&7SR%MkeCFOJ_l?)@3nMNklwRM`5Rdb9@XG_Zj8k^42 z)$h>OY20PMey9Dq?RIOn*{$AcyK0Bs+W-ImU;MM?KG0^yByV>Y#UnYqVnEKsS<>~- zSVcLESPh;!aki&)1_~>i4qT;(-zN!8GA0K%|q4%7PLYhL- z#6=qNlT1Q{4qq$Uwyk!af}haZFt-)69#QzZ3osxbYWU~ttSV!DsU&G^^yQ7$~z ze<$W#1^Pj?#5JNMC9x#cD!C{XNHG{07#ZmrnCcpug&3Mx8CY5wnra&uSQ!|6ci^wF eMbVL)pOTqYiCagT?Dhjd4Gf;HelF{r5}E+?)unX+ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_blue_orange.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_blue_orange.png index f4fe3744beb7611bb58543d0503ad54e91f22938..60f1c6cfe1394929c8c8fa4894347142cc2fce07 100644 GIT binary patch delta 347 zcmdnRa*26@1SbnK0|Ud`yN`k8Tk8!fO;4_UHx3v IIVCg!0CM{90G|+7WtB`Fy>@NgW?lVG9lcf^y*4fFdTren zWz}qHnP3^&5GiSYX_+8hy$&7SR%MkeCFOJ_l?)@3nMNklwRM`5Rdb9@XG_Zj8k^42 z)$h>OY5ZCu@TElHW0An;VuAOC0`Ce1J{1f6|NsBH`<-B*<%~(*?k-BPsWEFN&XTKt z#wyBT#A@)odkIi#r>Bc!h{R>p{@Z!Xh8!-8#z)JTcU~#ITxEXp-+zCxtsaYw`8y;# zB9>^Jnytb+^~i-Pzt?a7vJ_5wvDL`ws!Y1*rm~$;8a(H6%qPrQchOhi!m)3ODSMBl z?%?0(uYH*_J~ZM%CF7Z5fnSpA0xf)&`Y4|W*mM8+oRzodBrZ`C()c0fVCcXsBlGGF zPubsvTi4dE{aW$v_q3QVUVnBzjxWi%ohstKNGZ&}%Pur0;uPx# diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_blue_pink.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_blue_pink.png index 25d53a459cac74707e4df6738329a6160fcdb598..dd7cbd6af61252727e01beae9b1186e966ff6ec7 100644 GIT binary patch delta 347 zcmdnRa*26@1SbnK0|Ud`yN`k`nX951lLi|NsA-UEwECA7hfYy9>Ac^&s01Q8ZyMm9$^RfPb76oG(*gai?hgcO0K1cs9mOp;wqO->1I3l}WdpfG{)8k-nn zwt0$x2^+H`hdhVGg9BI39^I>Z^=ND2D({YNaRDP8-tVWPq#iwM3}7y1W60gf?=O3= zxEN@gYKd!vR!K@?Nvc(HQ7VvPFfuSQ)-^EJH8c(}G_^7?1|n?(11kfAB;|vFlm9Y` zM`4#1uB&_tG*AO*AjG_q%-q!ClEmBssF7y6Mg}2{90G|+7WtB`Fy>@NgW?lVG9lcf^y*4fFdTren zWz}qHnP3^&5GiSYX_+8hy$&7SR%MkeCFOJ_l?)@3nMNklwRM`5Rdb9@XG_Zj8k^42 z)$h>OY5d&1>QmRs_npf>cCCEdvFuIz(hr?0{{R1f+4b2spyiB7-tI0+v8gd@CeD(p zf5s}xVZ>_iyn6{yYNw}*V~E6M)&ARg%!V8;jK)XHn0H<&y2W>8eb+=%%urQ5rnwa?B^pS$EM_;KH$Qi79)J zrS9P0=&ya5Gd?upK_%mvVu4?h>jEu&mij242-tJ~`J9!v=Oivs6Vmu0=3wZ+EF<&k z4NuwMgXm45BcCanQ>Eyqt zdd65G9*^w6HMWxt7{#TGbPY^(4b4IfO{@$otqe`I4GgRd48A+?*Gx`i6j#G8-6p&J R05A*~JYD@<);T3K0RT)msU`pb diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_blue_purple.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_blue_purple.png index ad839557d22eaaf978551e22ad25cf0cd8921f72..69a299e15448a398cac8ab47ac469319a93cc5c4 100644 GIT binary patch delta 347 zcmdnRa*26@1SbnK0|Ud`yN`kT-qth%B|by>0M z@blLV!SuKtMu5f`~{$ia=5V!$}Dy$*!g*r-ZhJ3l?lpn80|AO^h+y zJVn5SjoFbyozBqgyV)hf9t6-Y4{85kMs8W`&u8iyE~S{WDvk+y+>m4QK$^1;B#e;LK2 zuuBWqRlWrpr~xz(VqQsRZfbE!Vr~J{NHbj{gAhYQD+3EFLvx6c4E+5{90G|+7WtB`Fy>@NgW?lVG9lcf^y*4fFdTren zWz}qHnP3^&5GiSYX_+8hy$&7SR%MkeCFOJ_l?)@3nMNklwRM`5Rdb9@XG_Zj8k^42 z)$h>OX)IA&S)#V0NOf7U+KNKerG=_Xiq)3?|NsBw>`RV7%Ndir-CdMoQ)AXloF!NP zj8&Awh}GbE_Y$DgPEQxd5Q)pG{kQX&4LMvGjgOWw@4QlaxytX8doey`vDWhtEWVyltURhe|rO=UZyG32J1zPwl^-(?%u;>2sIV*3^NnD~Pr13+{!O($OM&{KU zp0d9Sx2~;S`?ccT?`bh#y#DNb9AA=iJ6ZPk#F(AGRZdr&R1-YW-mGoXy85}Sb4q9e01=gA%(bL5-gyXtv zUoLNh0gp?*#tmL(W_E6|Q*8~Z8VVXSSY;ke4`SN$uk!DXB?TrnH+sEPYFK3UIy1cU z4U#;OFzLiREwRm=M};jUYpPh~i>DRkC|NA^y66;r`d(JtzuDh=xsxmS9#6{TuLD}9 zTH+c}QlFAol4_M)lnSI6j0}v7bq$Pl4UIz#O|1-!fk@lHz{$POb1v)ZhlH; zS|x4`!gZBzff_VGR)95>Wag$8mn7yEK=qjE8X1Hb8d^ykSXdcaKy3Nu{{J^n6N9I# KpUXO@geCyop>=}* delta 449 zcmX@dyoqIk1SbbG0|SGGE`RVuMf>{X0G|+7WtB`Fy>@NgW?lVG9lcf^y*4fFdTren zWz}qHnP3^&5GiSYX_+8hy$&7SR%MkeCFOJ_l?)@3nMNklwRM`5Rdb9@XG_Zj8k^42 z)$h>OX`G{~G+R|^mWtvG6~$SqO8@`=7s@|*0B9{^lDE5y!scw-1|WyCz+>WEiTY=( zq8vu72G6^f0L8X@x;TbNTvqMBoyTIx;oSIOlBf8$OF3n?Q_}wZ*YA!}dHsVi(fNpy zYoMJ<<_eXzwNG<$fA4XaqY|~YC&2W0Xlu^yySgH5>D$;n^uA}PalAP8Ej4BBv9-I) zH!h$0uq9kntRjx#^NW_U)@%{JV9moEM)mjJ8@jzRbdy-w$-=ddHJ~JboxR=4x;eH! zW8Kd4me)7F*S37=@n`4f_>y&7pY5D~a^`OK$Yb7Soep*?KBhd^RE531UH`=$ahJ#B z@OohdpdVCATq8QYut8x0<25!h#%%Kx z0TVW6M-F)oi3bO+o;|u(_v+Es#8uuM-Qog9I=tUcMM*t+))>HC%*K$rliy$VUU4zd zHq{c>i29P0#FA92Uh51Ao5|P!ofv LtDnm{r-UW|G}C#U delta 413 zcmX@lyq#r&1SbbG0|SGGE`RVuMf@NgW?lVG9lcf^y*4fFdTren zWz}qHnP3^&5GiSYX_+8hy$&7SR%MkeCFOJ_l?)@3nMNklwRM`5Rdb9@XG_Zj8k^42 z)$h>OX`EOnDtL=;ks;6`#w2fd7ip%1D@!I$m#crqD#~HRYVf>!2~cXMr;B5V#AVg~ z+j-1}94?H;N6VOZUMam?Wq$JCe}A#99*d3nJ0v?ImS~)st-?F?$b~Au*Khx_6i#}v z)yV0pOuFc%vYk;HJm+%EC(K!Q(O2NYv2Tefdyl2=;NR%4eVH>pG~z)exD4z(}bN~6AmAB_4E>RQG_#x(C=)f!^^Xd&x+24g**VeB6TJi4pw3shme|A2O zFUh%`Ec<(6%+B8`rz=jX37%+gS=n~5Eyd~Nzo>e~SRo#d?7%g)lXV%zrHph9Omz*- vLJUo;3@oh-O|=aStPBjkJMh;`j$;&8!!F$>yZrz#3>Z9J{an^LB{Ts5(6g5U diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_blue_yellow.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_blue_yellow.png index bb4a22bb6e0b7cb8260722585b12c140df61f707..3e53eee3e1f7a33e56c038c0b100bb9702c81479 100644 GIT binary patch delta 347 zcmdnRa*26@1SbnK0|Ud`yN`kAc^&s01Q8ZyMm9$^RfPb76oG(*gai?hgcO0K1cs9mOp;wqO->1I3l}WdpfG{)8k-nn zwt0$x2^+H`hdhVGg9BI39^I>Z^=ND2D({YNaRDP8-tVWPq#iwM3}7y1W60gf?=O3= zxEN@gYKd!vR!K@?Nvc(HQ7VvPFfuSQ)-^EJH8c(}G_^7?1|n?(11kfAB;|vFlm9Y` zM`4#1uB&_tG*AO*AjG_q%-q!ClEmBssF7y6Mg}2{90G|+7WtB`Fy>@NgW?lVG9lcf^y*4fFdTren zWz}qHnP3^&5GiSYX_+8hy$&7SR%MkeCFOJ_l?)@3nMNklwRM`5Rdb9@XG_Zj8k^42 z)$h>OY5a3s<@Yg_A4imb9aZ^uNcrm_<)24Y{{R2KRC=H%-Ip!1Qth?wdaN*du#FV|q zQg`rg^w+-386O()ppx-SvA{3Mb%7Q>OMR421njy0e9p?-a}t-R32FQgb1-yZmXUe& zhNtZB!mVp-*M6;d_j_8*7q34%AIF#E+)kGLJuznIZzopr0O5b8QUCw| diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_brown_black.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_brown_black.png index d8424f6fd5d1d85b8175c5a98a2978d6cbd6e290..fd3697e994a8e4508d004089604305bb256772c7 100644 GIT binary patch delta 339 zcmbQvvYmN?1SbnK0|Ud`yN`kEal|aox4=qF{pohjXxc#w(_) zyjANMq^JB1&pZ-*|GM%7>wp;{1=g*kacdB+t9%R8paHj{Br`X)xFj*R0IJ7K j*T^8m(9p`j!phJBVu`>v_y50vnixD?{an^LB{Ts5_U&&+ delta 453 zcmdnaJe_5N1SbbG0|SGGE`RVuMf>{j0G|+7Ujyl6JLN+Ru} zz1NO*8a_8WZf2+dLEzanYn@QZZ%ak`UiYqaV>w`bM1T7n6(Oqw?wZ@?h4&Yvr{8w| z@PtMs(qtDEpHY=`NxCkWnl2#fxiYtLvFraN@iLmZXIp1+YbPBFnGH9 KxvXn+9CdMRhcNeaV3tz$}UXZJQ&L+amA+%ujf?%LjqNj^v2*-8T zzFgi010I)rjT^ko%vu*y7`9>lcgU*+E&OA1VEZuEMo)Ue3xb!K?y z8zgxmVbY0tT4I|!j|y8z)>N^|7f&n7QL2OC7#SED>lzsA8XAWfnpznc1Ch3Yft7(llJdbom=3Up-29Zx zv`X9>gzGBb0ySuWtN?2$$;?eHE=kNSfa)>RH8Kb>G_;a7u&^?;fY|cQ{r_*ECI(Me KKbLh*2~7YKkam#( delta 449 zcmX@dypUyr1SbbG0|SGGE`RVuMf>`w0G|+7Ujyl6JLN(@9f&FwNJ}5 zt@pa%rY2z!yQV%lLxjatROIoWvL>4nJ@a+d-Mhn(pkP7w^PhVH|=WHU} z96}3bF9-$-C3w0xhHzYW?aSqDFyL{?*SNvU%*@U$cB-vGRYO5zMm@^~Uroli|9k3U zf-I!u-ngj>*)jFqQ)KwAwvs2sz%#{PwEO0fN1Stb?DjVGTY6iX3(5p7%~-fLHQ!YK z|JmQiSQ94LL9!x%nxXX_dHj2-j7<1?td%TTzmkn_66wm|FnVW2S3l5MpR(Wnf`t XXaTY1oBRLYKs^keu6{1-oD!M{L0G|+7Ujyl6JLNYxgstFZ6JrUz$3Dlfq`#-J&0hmU=3CQ zin5n@`ns||V-@8vVl{Z)y#y$r*mv zoV+}uIg}K-qbiH57KRos`das;Y|D4<8ji;+M8#Igd|N28?RD=$H=c&_j`+Nbo-A7$ z`$J?**V(mMYoC^BN>|OOR~F`(p?A&R(1fdL7FSo{zsGjz0aM;39&MYgdFP0(cuU`% zte1Z$ZN0wp+O74U@0|4BH@R;2=k-tSSete(k=fIdS=#Qdu$W`z#PXfdbq9)r>KUHP zaH~FcoF@r%ylRPSL`h0wNvc(HQ7VvPFfuSQ(ls#EH8cw`G_f+Uv@-NC)iyA&GBEh= jz+Z!+BR4-KGp!Pf4ycAU+3g2_8W=oX{an^LB{Ts53>Kp( diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_brown_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_brown_gray.png index fcce9200ea8ac1d43e7319fa362a2d2717cb4751..e8680debde9fa150b0a98987fd5391a0fd7178c7 100644 GIT binary patch delta 377 zcmZ3)a+rC71SbnK0|Ud`yN`k;OkH}&M2EP3u%xJ+HtO68dFY)wsWq-~l!p$MH zVD^Gwpiqpbi(?4Kb=SVzf(;5hEd1IJHZX2sJ|-rV!{D`mW$k?l_q+9fa^%c~S*!%- zgeeOfGB+A3Fn(V)Lnoz3^NEje|IZ_jS?|c$?QP^=yXd*VK}FvyTzg-?So`k(+26-l zL$&$R?kCr609vG4;u=wsl30>zm0Xkxq!^40jEr>+jCBo-Lkvx=42*$D+rYrez#vKa zU?8%FRIA+ll+3hB+&YBoD&GQiXuz!~$;?eHE=kNSfa)>RH8Kb>G_*3XurjoO*z(Q& R|8Jlk22WQ%mvv4FO#sqZcJ%-N delta 439 zcmX@iyohCj1SbbG0|SGGE`RVuMf>{L0G|+7Ujyl6JLNUszq9yq+2{ZNeGP*radX~jR$$t+VygLa z@hDOCsQ2#q?$!1O+YS1n5*MCIl=n)sj+e+f!cfur6#DA>MDNui0Am=;NLJ zxw=2&>bJ&EIFkJK@2&S=MV4KWm22Fhw8ZV+)4ZRI=RN;2KF;G7S<-PWVX`8lc({?S zfvK*cS%{&Dm4T&|p{cfkft7*5cL)9&pvP28Tq8^8E<Bq?NKf_n!C_I=&Twb; z5~B$RRVLbo>ZA#Gs}~sk_`+rPN$2McmjbV;i(0o$+k3V0XZ}5Ny;OF7wpBZo{{Ssh zEpd$~sZU8PNwrEYN(E93Mg~U4x(3F&hQ=X=rd9^VK%{M8U}a#CqPnpnA-7jSNBz4XvaNEUXMIAhvvS|Nk4PiNVv= K&t;ucLK6UY{C36w delta 449 zcmX@dyntnb1SbbG0|SGGE`RVuMf>`w0G|+7Ujyl6JLN7jq=1#t)uQk2*P^OFS$to; zM)mox!ygyPgj;@l{3^JbtN5y{T;mp{C2seg=KW+m@A;SYi9fgGGRGgMflgN~ag8WR zNi0dVN-jzTQVd20Mn<{@rn-h^A%-Sa29{QarrHJuRt5&&9r$bD8YZVP@~L50*CxCD Q08kx+r>mdKI;Vst0P-}QRsaA1 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_brown_light_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_brown_light_blue.png index 4b00f3160dc18745a39496664117a9c6f29373dc..5575d61fe627bd03a5a5304925d0014350111ea2 100644 GIT binary patch delta 335 zcmZ3-a*26@1SbnK0|Ud`yN`kA%$eoOCdsa*CZ~k9g$ovJP?*4YjZKU( z+dM_UgpJveL!Lw8!GWu1kM7mIdbBlhm3K$CxPXxk@Ap$tQjeZB1~3=1G34&#_m{m_ zTnw~LwZt`I@^MB1DPvs&V_iez5JOWd17jf4HZZU{X0G|+7Ujyl6JLN_~uq%2d&y{>(4Zs_jn=l}l4dznm{pqL`ZA~?Zy z?H-H07gkwZth!%y`_^k#yOxbtxwu35s)M<1e?1nU%yz)~i2n8$DonQyd{44#p&JcNfl&H+p?*E>; zm>>%&xi@aALUv4j_Y@hvtF7coG4M?B7wx`z$PSVIm>M{a&fW?Cg~9l~{$Z-F{A;8v7m=B5^xB<2=C^_b}z8H5-bS{Yba Y8CpPW`R4xrH&73Qr>mdKI;Vst0Pmi8@Bjb+ delta 476 zcmX@byp&~v1SbbG0|SGGE`RVuMf>{L0G|+7Ujyl6JLN8cs^%ECM|^sd<(ns7DE;_52=_t-8yV9LA1qiwS_?;Oz;Z|S>} z_44net=D&6yS4uFos-`CCfDu$y#C1@YtzmpGJ9GwOWWNQ7IUneSiUp5?m%%+J;QSu zZq>(*^CW?eS1oakC`m~yNwrEYN(E93Mg~Skx(24YhGrp#CRPTPR)!v?+6D$z1_s|9 i_-jyfM_$bG6*p=v@)=;GPHmg`OW?RZ=fCqPgg&ebxsLQ0N8$S A&;S4c delta 464 zcmX@ZypCmp1SbbG0|SGGE`RVuMf>{X0G|+7Ujyl6JLN$U${WDfk z4kK2B=iN(yVw*i(977~7n+A0Iu^4isEK|t6u6=KA=gSl>hJr#m4rd;n);*+5f)QPk;i}5*Z-d57`UrlR61{2f$(-74%wMmEB{W~x;}aB z*9y7g^L9M3epqhxKk8g<{hH4f!r?{p4^7#1Sb0KN%as$m@95e;*tydFZ5X!;-`>~? zp!-!zTq8>cSbZh_s delta 463 zcmX@ZyozOl1SbbG0|SGGE`RVuMf>`M0G|+7Ujyl6JLNv!6(+itgJo89WIwySp7t^NQ1zsrHbML;_llf2zs%#ZA``@I4LVs* z&%SI8JKDJ|_xH7L-|8C66W?q-cv{y?h%xtpvSfAd>hJH) zoif_>Ad)l6pPjj_J9qvIDON{cwxbsRUf0{X1x$IDcy!ln%{xbQnVqVaMP=gEC)@IR)MuM>M`qrcZm{&-2aYA8il(3R%1`rGblLV!SuKtMu5f`~{$ia=5V!$}Dy$*!g*r-ZhJ3l?lpn80|AO^h+y zJVn5SjoFbyozopr E0N=uEH2?qr delta 427 zcmcb_ypCmp1SbbG0|SGGE`RVuMf>{X0G|+7Ujyl6JLN!%J{WDfk z4kK2B=iN(yVw*i(977~7n+A0Iu^4isEK|t6u6=KA=gSl>hJr#m4rd;n);*+5f)QPk;i}5d;Ol{7`UrlR61{2f$(-74%wMmEB{W~x;}aB z*9y7g^L9M3epqhxKk8g<{hH4f!r?{p4^7#1Sb0KN%as$m@95e;*tydFZ5X!;-`?1Y z$p(z#QbxK4rn-h^A%-Sa29{QarrHJuRt5&&9r$Y|Co+nwVV7=`-F^V*dj?NeKbLh* G2~7ZYf0|tY diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_brown_pink.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_brown_pink.png index 00da07f37baa32c730886f770e4414ac68264db5..51b89f4a377b5266d1a560c551efba45ac96bf77 100644 GIT binary patch delta 335 zcmZ3-a*26@1SbnK0|Ud`yN`k{X0G|+7Ujyl6JLNJ9n0RdFa6ND;{X5uQ>Nb93bd9n$=lsUVRN=^1CYa6;4yK5MEx^X zQ4S+kgXi5#fMT0HT^vIsE}I5)`>_~uq%2d&y{>(4Zs_jn=l}l4dznm{pqL`ZA~?Zy z?H-H07gkwZth!%y`_^k#yOxbtxwu35s)M<1e?1nU%yz)~i2n8$DonQyd{4}cX|6iH3parOpG0EHAgblLV!SuKtMu5f`~{$ia=5V!$}Dy$*!g*r-ZhJ3l?lpn80|AO^h+y zJVn5SjoFbyo{X0G|+7Ujyl6JLNvOk5yQ|BO|X z!-&=3dG`{a*k(@`#}J9jrUBi4EQTB@%M^02Yu}q2y1V-MzyI-GCX*&8rpU1fPHNUccu!2JUJXmCjpMAiSN2Lw07?%Dna^=MCJG%A{cCNI48^-Ozw>P$8 zvH_#Gl##B1sji_}h@pvB@@#|NqZfsFV%V#F*sm?!uLE;Y%2h!&%@FSUJwivO7wJb4B@!$+Lz1QV8G*&uW^HynVFqi>{MHWsz$wn#tc@O2h)R? z_WY~-yJJa#iOr2(FO?b=nZ3>o?|g$KPb5q_F;7cubLUZE3(1-)R{7#-ML9|qOT8{S zMW4Qx758uU_g?Pg3ckmaGWqL(wyBo5MwFx^mZVxG7o`Fz1|tI_V_gGdT|?s#LsKgQ zV<6HtFt9Q(NK!r+$WVZ+BR4-KGp!Q04&l1Ww?Hd2;8v7m=B5^xB<2=C^_b}z8H5-b cS{Yba8CpPW`R4xrH&73Qr>mdKI;Vst09*EWLI3~& delta 449 zcmX@dyqsl%1SbbG0|SGGE`RVuMf>{L0G|+7Ujyl6JLN_iyn6{yW|OCjV~E6M(}3>0!v-8r&KbN(G0nEl-#q!x|9rkuDIu$tcZ~v!kylR5 zzRbP0OE~xTx3zEI{$+cA=tg#HtJdyXjn=pS5>^PxJ`jGi-91Nz>DGbsDQ`^Q-P>)g zefmYydanyrRuTp=IltYmYj9*4X&n0)Uw_`PX;BHk_O-h{57qJ{1#TH%4f?HId^Y*q z&U23=I)l%(Trc^%H70v)rEK^kpLd!*E3IvqGF?4-_nf}_iFw}aU)(PhxeYW$=H&vN zuUg_7QIe8al4_M)lnSI6j0}v7bPY^(4b4IfO{@$otqe`I4GgRd48A+?*MK!lPGS^N W!>*=HcKZRK8U{~SKbLh*2~7aMk)JXE diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_brown_white.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_brown_white.png index b8cf02801f5e249d3b1f1274be2067395925a652..c4ff24eaf76faa6f89c2a212e87521f87dcfb746 100644 GIT binary patch delta 315 zcmZ3@a-MmD1SbnK0|Ud`yN`kYmi~;JffKLE)jwww;pPxpFnd8TP%6pO#W95AdUApY3o|2|qnfHhfIx~sKte)- zh)6<;KvDw3NeL#&uBIlZgtmnX7Hm+Mz<7;Kj4|6hMZkoO*^xt@L*l`Kt7nhy)xCPO zHF1@9N4L0ukq+mdKI;Vst0PxgbfB*mh delta 401 zcmX@lyqaZ#1SbbG0|SGGE`RVuMf-q+0G|+7Ujyl6JLNQ_y8T!TIZ~D> z_*Ix_#?4t6j^+t6bcneAU5R zx4#|>P-Z(|eMEoz3l*kY2fnA|n69&Hv(`Q>)70;E!Ocp-Aa+fCQiceNsier`KkL1I z&v6Xg)h;TXx2!;TI}eBK%&e7vCv9Dyy!LB_-0^uko>)IDxB4G-uC{*7XA9x*qWOoW z>^iJGA*|)fiQRW}?H}x1Y5z8i+l6m$Y{g_mdKI;Vst0KlM)A^-pY diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_brown_yellow.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_brown_yellow.png index c0f2914b66cb6a1a2ecddabb13f1c1b7fafced70..1e57623ae7da2f3351ccb8d33f035d2af0737edf 100644 GIT binary patch delta 335 zcmZ3-a*26@1SbnK0|Ud`yN`kAc^&s01Q8ZyMm9$^RfPb76oG(*gai?hgcO0K1cs9mOp;wqO->1I3l}WdpfG{)8k-nn zwt0$x2^+H`hdhVGg9BI39^I>Z^=ND2D({YNaRDP8-tVWPq#iwM3}7y1W60gf?=O3= zxEN@gYKd#a<_2F5_7ZD3$!V34GIFmUomM)4@@(!zC>Z-Itr z01YWgNi0dVD#^@EEiOsSEnqM*Faqi^(={>(F*LL?u&^?;fEfAB{r_*E9tKZWKbLh* G2~7adCT_d{ delta 427 zcmcb_ypCmp1SbbG0|SGGE`RVuMf>{X0G|+7Ujyl6JLNTp&^Zj8&Aw zh}GbE_Y$DkW=|K#5Q)pC0o{Hqh8!u&6mqX?-J5uG?Ra1t_x}us)){{e=qCtpndva!l9RwOMPQ zmTBtuy5MFdVGz5fJ}Eyq$+bc4pSfzmvAEPhR`A zLhksy9Z#$umRtRgI#*l2=Cg%xc+vbrQ+6Fzo)Fe@<;3ngy7mutuC#v}#_htlH@0H3 z0i(E-k*UO_QmvAUQh`)GgOP!ev95u! zuAy;=p{bRDF%W4R7+4t?Bq<*ZMA4C(pOTqYiCcqkUFBP#1`W6sC7HRY#U+Wk1yDU^ jx<&>ehK5!K7FLGl5K9CY`1^%`nixD?{an^LB{Ts5wQX)= delta 464 zcmdnayoF_g1SbbG0|SGGE`RVuMf>{90G|+7{^%s((mLUyYT>d5;o@51l3Jm>a^b=% z{+JZuk~$uDUmj0?9#20W4?k`fFX7U9;o=(p$VC3AM6s5B(WYMh$ONH+D*o71;qpeY zwuwA$KK#+iVyzQ|%j$&+D&^&s<>i&+?)FK#IZ0z{p6~z*N`JEX2^n%D~df&{W&Nz{NP{I@ dM{a&fW?Cg~9c{AP4*+#Ac)I$ztaD0e0syXMr?CJ4 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_cyan_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_cyan_blue.png index 6ab4dd8af30298ba6a27ea71a8d055fbb1915acc..d0cb1f966d8bc0b51fa500ad07b621f8960bf03c 100644 GIT binary patch delta 351 zcmdnTa*la|1SbnK0|Ud`yN`kq!GOmlU*iTZGc!B4*r~P#RSjPSjTx*m52gn( z?fF;vcgK-u ziavcWEAHRy@4ei~6?~5;W%AcezQ8ChWvpvptZQf-VrXh*U<^ds1_o9J21&{X11B>w ziAQ0V7Oty&3v{bSiEBhjN@7W>RY_)UYH>+oZUKXlfe}!TnXZvRh@qjCfrXW!ImAc? S{(d2#9tKZWKbLh*2~7aX)@;`R delta 457 zcmX@dypLsq1SbbG0|SGGE`RVuMf>`k0G|+7{^%s((mLUyYT>d5;o@51l3Jm>a^b=% z{+JZuk~$uDUmj0?9#20W4?k`fFX7U9;o=(p$VC3AM6s5B(WYMh$ONH+D*o71;qpeY zwuwA$KK#+iVyzQ|%j$&+DveEN8=KBDGMQ;)GX4Mm|GT+^V}SNECV9KNC~Gk%*4>7kmBhSNl&mptJSG_LW`c zOP9@=BP6p%=9BYdiRTiJcbxk?L#D*{PweykFKzm6&YU&lpld;@@iw3DA_iAm7SBA# zf5YdM{zq%xJzFR4Nd|gDwZt`|BqgyV)hf9t6-Y4{85kMq8kp)DnuQpeSQ%Ja8JcPv k7+4t?d}nsxubCXnD6WQGzD;)f0ib~lp00i_>zopr0KW95MF0Q* diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_cyan_brown.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_cyan_brown.png index 8d6eb3d1014940921eaf1f0d9b0e7934e720ef8c..c7bbff3bb76298df0cb117ad34c886d97ddf478f 100644 GIT binary patch delta 350 zcmdnXa*la|1SbnK0|Ud`yN`kFdh= zoK1wAL(p>4$Cp5%L{AsT5RU7vecpl%20Sj?HC~7@v$D(TEHT(C&gm;-(7>#6MPHHU zLs8|=H$D$CDmF+@_4vVIQPs|HXZ8}K2?tds+J@?+33sa(82$LdW%o(v=M9$vuc?b# zw@ur7wen~FJ#)QOc7C>1JC*-TKF=sFWvpvptZQf-VrXh*U<^ds1_o9J21&{X11B+w zM`4#0uB&_tbgD*)YeY#(Vo9o1NoH#6$-E Rej%V922WQ%mvv4FO#tKIZXf^v delta 456 zcmX@dyq9Hy1SbbG0|SGGE`RVuMf>`k0G|+7{^%s((mLUyYT>d5;o@51l3Jm>a^b=% z{+JZuk~$uDUmj0?9#20W4?k`fFX7U9;o=(p$VC3AM6s5B(WYMh$ONH+D*o71;qpeY zwuwA$KK#+iVyzQ|%j$&+DvR7T3f$BS-8AxD)&KwhpAyFq4YZ#z$=lsUS&KO-$7D^xW?o zx<@PY>4OP}TBmmZ33&f^M$hLRYs#&D?>{DQq9=WP$EP>*Si;Scy9@XkgZV60y^J~V zO!Yt0yN$dX=RHbx1o}d?#5JNMC9x#cD!C{XNHG{07#ZmrnCcpug&3Mx8CY5wnra&u jSQ!|6cVObLnH;OkH}&M2EP3u%xJ+HtO68dFY)wsWq-~l!p$LQ zIqBm|piqpbi(?4Kb=SVzf(;5hEd1IJHZX2sJ|-rV!{D`mW$k?l_q+9fa^%c~S*!%- zgeeOfGB+A3Fn(V)Lnoz3^NEje|IZ_jS?|c$?QP^=yXd*VK}FvyTzg-?So`k(+26-l zL$&$R?kCr609vG4;u=wsl30>zm0Xkxq!^40jEr>+jCBo-Lkvx=42*$D+rYrez#vKa zU?8%FRIA+ll+3hB+&YBoD&GQiXuz!~$;?eHE=kNSfa)>RH8Kb>G_*3Xurf4<*uucy RF9g)X;OXk;vd$@?2>_*$bus_| delta 458 zcmX@ie1K(w1SbbG0|SGGE`RVuMf>{v0G|+7{^%s((mLUyYT>d5;o@51l3Jm>a^b=% z{+JZuk~$uDUmj0?9#20W4?k`fFX7U9;o=(p$VC3AM6s5B(WYMh$ONH+D*o71;qpeY zwuwA$KK#+iVyzQ|%j$&+D(#%yY#m+g99?Z4Tx=X%{{R2)Ewl0v&O2A`xL*h;RKh~+=~%X?94&wl9Zk2`5^ED?2`J@sAhmYT|`9x?#}OZbAmoL>5UpT&1Mg~rH? zOZmZ~`Ch)37E6j!pK95g9GlVoI``jP!xwh{Oyw^;vU*nYr1%cUx}0NT59OGa$rPAe z-rAt6{-5dX1>Q9uZf`c9tjH)HZlr5qs%vN#VrXJzU}CkWnl2#fxiamN!1e9 nh?11Vl2ohQ{FKbJN(LhXBkUU5WVasxYGCkm^>bP0l+XkK1fHtz diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_cyan_green.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_cyan_green.png index 7a4eb234aa862849575d596e7f22c90ba9d2851f..af930a478a941843b5c7de625207dc90b0f09eeb 100644 GIT binary patch delta 350 zcmdnXa*la|1SbnK0|Ud`yN`kFdh= zoK1wAL(p>4$Cp5%L{AsT5RU7vecpl%20Sj?HC~7@v$D(TEHT(C&gm;-(7>#6MPHHU zLs8|=H$D$CDmF+@_4vVIQPs|HXZ8}K2?tds+J@?+33sa(82$LdW%o(v=M9$vuc?b# zw@ur7wen~FJ#)QOc7C>1JC*-TKF=sFWvpvptZQf-VrXh*U<^ds1_o9J21&{X11B+w zM`4#0uB&_tbgD*)YeY#(Vo9o1NoH#6$-E Rej%V922WQ%mvv4FO#t)`ZZQA= delta 456 zcmX@dyq9Hy1SbbG0|SGGE`RVuMf>`k0G|+7{^%s((mLUyYT>d5;o@51l3Jm>a^b=% z{+JZuk~$uDUmj0?9#20W4?k`fFX7U9;o=(p$VC3AM6s5B(WYMh$ONH+D*o71;qpeY zwuwA$KK#+iVyzQ|%j$&+DnoK*g0p3Ub7X?Dr2qf_UmJXQKG1%~ByV>YWi95U9IJ`b zEak7aani5Z9f)69%o^5#j`OPH(H$%7heAPzkiAHhLRM^ zO`j5!*d}FE8AUXu8U5I_?)I*n-=80aacq2gMoLLz7HiAjr)>hQ;%Rs0=IlJmRk7nu z&-I%(iuPO$TJ=y?e(i+%G=nW?_)p!@dim?At5RXT!vrahi*o(fZaujd)xeUr&~v|U z=pL=mrw=9^YMt8sC*b|x89kqOtSPtpz5kfJiJtWF9iQIJV+l7)?k?bG4Cb>~^)lwb zGu8i0?>6#oocAc%5$Frm64!{5l*E!$tK_0oAjM#0U}U6gV5)0q7Gh{(WngJ#XsT^s kU}a$N-GPa}W^yc}xEgl(Hree5fCe&ny85}Sb4q9e05BY`eEehK5!K7FLGl5F;7*`-Omd7(8A5T-G@y GGywo+x@v*| delta 452 zcmcb_e1>I$1SbbG0|SGGE`RVuMf>{F0G|+7{^%s((mLUyYT>d5;o@51l3Jm>a^b=% z{+JZuk~$uDUmj0?9#20W4?k`fFX7U9;o=(p$VC3AM6s5B(WYMh$ONH+D*o71;qpeY zwuwA$KK#+iVyzQ|%j$&+Dy_HNw%&ZpYU2&-%{Q$!T(ew%)oRm?|Ns9VIA~_cz{9}6 znB?v5q87z5W9!6Oa`n$xMLCRE4W4%|0XlNOr;B5V#AVe9w}Y4sd7N{P9{U*Ak*O%4 zk+S{mzyJD^GUZL&7hing=)$9N@k`PMma{1zGUrXNjJkIH8=w4Gu{7kc`o1W||K}1iB)L!B(R%skv8z&8p~D0zkBfTK zuid(^b1MVq8K=qrX056SU3Kc9Vk@_{_|L`rzV7{AxA*ODvl}n%J`@}eF3GvQRsOf( z4fpSE1*yi{IKB%QJZ)G!tB*ZL<){4j9lUqG9Bz0q*?>`8%1GD1RM*ff#L&dbz|zXl mRNKJ7%D~{e1AoorL`HEn?9y$r+YbOkg2B_(&t;ucLK6TvLbRCx diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_cyan_light_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_cyan_light_gray.png index 463648c0dfe63fdda43da0453b4783159afb8ad3..50918583a8d0e4e26948f3f8bdc54e0b497924e9 100644 GIT binary patch delta 384 zcmX@aa*BC^1SbnK0|Ud`yN`k`sfb2brf z4nfOFA72865 zm4QK$^1(o`h8&oV-29Zxv`XAMgzGBb0(EG>ttiRNO)V}-%q@WGG1E0N2r)FYGO(~R XG>6#2z~3(f)WhKE>gTe~DWM4fKV5lJ delta 505 zcmX@be28U&1SbbG0|SGGE`RVuMf>{v0G|+7{^%s((mLUyYT>d5;o@51l3Jm>a^b=% z{+JZuk~$uDUmj0?9#20W4?k`fFX7U9;o=(p$VC3AM6s5B(WYMh$ONH+D*o71;qpeY zwuwA$KK#+iVyzQ|%j$&+DtmgGyStmZx*9t>8#+4b|Ns9VcgfNW=mf?jZ})l^l`U*P zX99Vg1s;*b3=DkxL735kHCP2G$X?><>&pI&Rg}Ys)!=#e5}?p-PZ!4!iOZ@JZu_wq z@;D2dE1r$8r8O#P|o!Xt9=Q_2RWwJ9G`W4D*y{Pz5)F2~NR zr)DW}tYtd%ugJ0MP_tyXdVRFsPNsQ!){jfgw#~}dT_kz$Ap0ahLt^S9so{blQS7S1z4-F359RRm|9I;nZ^;3-9WlfJ?}!@l2@a+90u)c>vf ze7{8Q_!}SJGY|X1je+Ol}&IsO|yub4m9@$L;{3GxB@L$$;;q9i3Xu_Vm4QK$^1;B#{7m9e*rkQ*D&GRl(SVp! zl4@0wnVVW%l9*e-U}Rtf)MKV=WDsI#Xk}nwWoQmDl7YWp2&jj_)78&qol`;+0JgSn Am;e9( delta 489 zcmX@Ze1>I$1SbbG0|SGGE`RVuMf>{F0G|+7{^%s((mLUyYT>d5;o@51l3Jm>a^b=% z{+JZuk~$uDUmj0?9#20W4?k`fFX7U9;o=(p$VC3AM6s5B(WYMh$ONH+D*o71;qpeY zwuwA$KK#+iVyzQ|%j$&+D)Vein`e&@797e1L&%2iZ9l77r#W6(Uvg(A}LCl6c&bddAeT?hKR20xi z+5Yz5fBi|B@+R(!FTQYe;ZeExC20f8*_02N^QKouUAumAtw7SrnWioQCfppaZ*wYg z>7TK%zFE>G`Jo_E^8MnCPkyXe8gf{DUzFnia|s!e+^6nnz5MgoRjIzvVS<#$MZM|Q zZe7^9m4Wk&)8v1%R#k+qI(1O7m0Mf<=i+@|_kOS2`}ViljhA*G3XTVt2OC7#SED z=^B{o8k&U|nphcFS{a&Z8@L)+85n$b;IBc^k(-~AnO2Ei2S`Jk?Dhjd4Gf;HelF{r G5}E*J{k%Q^ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_cyan_magenta.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_cyan_magenta.png index 603fbca1562a05c5d1b72460182662f6a892fa23..0f72645b289acbc647033b778a1a68300e408f61 100644 GIT binary patch delta 360 zcmX@Xa)x<=1SbnK0|Ud`yN`k#e2FqhHzYW z?aSqDFyL{?*SNvU%*@U$=H+-mNQ6hz;(-2AmWsche-(NPzHr$f-RpCNhvirU%bnRt zMiWjhonY&0^Gvv3yrAgE7dE@JsZTSMES7dfEzI4uebwvw&-)4)6L|Ud>(=e?0$Qb7 z;u=wsl2~7oYL#4+npl#`U}RuqtZQJbYiJx|Xli9(3`E)n237_JNy-NU5jubxa`RI% z(<*Um5U#6y3)G+iu>z=}Br`X)xFj*R0IJ7K*T^8m(9p`jLek369AXOtf4>k=6N9I# KpUXO@geCw+4tV?k delta 485 zcmX@Ze1c_y1SbbG0|SGGE`RVuMf>`q0G|+7{^%s((mLUyYT>d5;o@51l3Jm>a^b=% z{+JZuk~$uDUmj0?9#20W4?k`fFX7U9;o=(p$VC3AM6s5B(WYMh$ONH+D*o71;qpeY zwuwA$KK#+iVyzQ|%j$&+DtFnh-)X;YyWN^?cB{AAuG(R@_W%F?0yigb0=j~cGs)ZC zMfEV_N&bn`Eak7aanc3Z9f)69%o^5#j`OPH(H$%7tX!= z^MC%5Cid46)1I;m8%}V!Jo%uI$>f96OYdGwy**!iyHkg5`ZWQ^i#iH#^u=2=_82^V zm2z4&?7-pF^gZW}O?$j{S`hF19~rHGjGGsx>S+|OUh;anc;}INM#n4#*WGucvV*T* zV^T5T_WhN+>QU%QE%tU1y)`jU+JC)pe_wm2KiQ|O%ID9{&+#RFhQBK3Os*|^&k}By z++D!W7|ds}>SfJ=v`O`hUtaN^Z~w0u4)ls@iEBhjN@7W>RdP`(kYX@0Ff!6LFx53Q z3o$gYGO)BVG}SgRaIrEl`0l`8gQ6ohKP5A*5{C|;hBn#l2Y?zFJYD@<);T3K0RRuN BxBUPB diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_cyan_orange.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_cyan_orange.png index 2b4f7f58aa29bb682a35611ef4ec22df38116df5..2bfb01d1f44c5d11469087ad82c8600de3f6de92 100644 GIT binary patch delta 335 zcmX@Za*26@1SbnK0|Ud`yN`k|gIVH3$T(Dq+!UV=^Y+{Vr z<|zUuY|M@v@*ENm4qQEZbg%B!qpgXnygRzZ1&nlfzn_Yddi1O@fVr5BA$KRgzwEu@ zVxVoRC9V;ZpE3$a8S5Gt>lzw|7@Arc7z2^Efq|8QL6Y*pz{&hf;!)V8h3hKc0u9js z8d8#ySdwa0l9`)YT#}euz+hxx1k_`uYh(~&XlP|%VP$9zF_MA5UkIp&!PC{xWt~$( F699tNX~F;i delta 452 zcmcb_e1>I$1SbbG0|SGGE`RVuMf>{F0G|+7{^%s((mLUyYT>d5;o@51l3Jm>a^b=% z{+JZuk~$uDUmj0?9#20W4?k`fFX7U9;o=(p$VC3AM6s5B(WYMh$ONH+D*o71;qpeY zwuwA$KK#+iVyzQ|%j$&+D!-Npd?^w5SS0YdSm1r3z`H_$PsIZN|NmbyscIGj4+8^Z zlDE5yS`^2OtrKU-)jwku|e}^_YXy={&NOuiFyZESeVbE} zOaF|8_05tl$qxmQlJ6I9eDY(((vZXI`=S*8pG(M)*b%vu1aBr4ilt2F6vFc zcI(24`QL^& z+`qdOq#AGI_%2}Zv|;hAKK2}ypYq>#@ZR}yxZ%ZQ14eNvBV7YiT|=`FLlY|lODjWD lZ36=<1B34l{56vk8O7DGOSj2xKL88~22WQ%mvv4FO#th7vcv!Y diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_cyan_pink.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_cyan_pink.png index d22b55f2cdb5e60092a69bc15d72509c6223ac44..c8455a07c85e8edb7471169294e0bc7b4a8e8016 100644 GIT binary patch delta 335 zcmX@Za*26@1SbnK0|Ud`yN`k`nX951lLi|Np<7Cz=(gk1@&H-Gy8J`jG<@U(3}$XA|M(5VV~1@g-0y$eoOCdsa*CZ~k9g$ovJP?*4YjZKU( z+dM_UgpJveL!Lw8!GWu1kM7mIdbBlhm3K$CxPXxk@Ap$tQjeZB1~3=1G34&#_m{m_ zTnw~LwZt`I@>50uDPvs&V_iez5JOWd17jf4HZZUv~XSJTc9Bt zKtoDW5=&C8N-}d(i%Sx73mA+HjDUK~bd3x`3=OReEUXO8Ax1Lr_X`2_FnGH9xvXI$1SbbG0|SGGE`RVuMf>{F0G|+7{^%s((mLUyYT>d5;o@51l3Jm>a^b=% z{+JZuk~$uDUmj0?9#20W4?k`fFX7U9;o=(p$VC3AM6s5B(WYMh$ONH+D*o71;qpeY zwuwA$KK#+iVyzQ|%j$&+DnECx`qZ`ZedqFzT`S*qEPK2 zNZJ1O-+%o{nery?i!Z)#bm39C_$6rr%h{9IzeP5K~|8of$lH8~6XubUN*i|X4&|!j<$3?yA z*KS?dxs`$QjMLh&e9Nz^Do;EC=)yJNr@>Bl%4&FOo4mZ4*Y``ckWu$9hs%vN#VrXJzU}CkWnl2#fxl*QBBQt(cIh_R?FWD%!QkoY=d#Wzp$P!}GPb_} diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_cyan_purple.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_cyan_purple.png index bcd18c6db43a55b257a3345027953d4e59943899..13ee645e3bd58547946b118ede099a9819d544f5 100644 GIT binary patch delta 335 zcmX@Za*26@1SbnK0|Ud`yN`k0M z@sNG3IPHs0s#pL2_hm1DFR6e3@0U+B)giLoD$j=E?BTZVFKedHZjI* z^ArISHfBc-c@BvO2dxt=(bmLO-W}cI0!BK#-%mwJJ$lv{z+BA6kh_!LU-n*c zG0-;E64!{yPZG_*3Xurf4<7|FojF9g)X;OXk;vd$@? F2>=)@XPE#1 delta 452 zcmcb_e1>I$1SbbG0|SGGE`RVuMf>{F0G|+7{^%s((mLUyYT>d5;o@51l3Jm>a^b=% z{+JZuk~$uDUmj0?9#20W4?k`fFX7U9;o=(p$VC3AM6s5B(WYMh$ONH+D*o71;qpeY zwuwA$KK#+iVyzQ|%j$&+DofN>mZ+^LQe9T8wxUpVX`$+pVzuS}|No!mSJJ`2!@$6p z%>`d_0L#EIgD5ho_8++I�Ki(`nyWz`9{gP09@oO6#J`xw`esVJb4 zvi5) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_cyan_red.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_cyan_red.png index 031bc92391baec3bd243d36d7e0d50649230bbe2..5121cfef4ef12e3d395d758b4bcd6fa67b6229f0 100644 GIT binary patch delta 388 zcmX@Ya*la|1SbnK0|Ud`yN`k21s zKW7u+<`A@;^zkK7DACi!F@)o~YhNyJg8`3AzQzq+W@dJ7u~Tggsv7kQ8Z%gB9!w8n z+VijS?~Ww}CN?*Ey;N#gWcE5Uyz>o`JdrTz#5^sr&7DVuEhKBISmleS73C;dEcLqR z6n*+$R@}eY-+Q@}EBGEy%H*#D+NN6K8c~vxSdwa$T$Bo=7>o>zjCBo+bq$R}3{9;J zjDbkoz`)ADAW8XPAVUGNj@WDsI# cXk}nwWoQnug@M0c2&jj_)78&qol`;+0Q~=V-T(jq delta 463 zcmX@de1v6!1SbbG0|SGGE`RVuMf>{v0G|+7{^%s((mLUyYT>d5;o@51l3Jm>a^b=% z{+JZuk~$uDUmj0?9#20W4?k`fFX7U9;o=(p$VC3AM6s5B(WYMh$ONH+D*o71;qpeY zwuwA$KK#+iVyzQ|%j$&+D(9#w%~n;KrJ^`PMRAs@(*OVe6@)lH0G+^?Eak7aanc3Z9f)69%o^5#j`OPH(H$%7tWpe|G&Fd z#fHAr$T|Z-W=|7aNgYRH$(qRPxv|^+Ru*cv+$c)p6%;wkbm(7^bH^cW<9B}B?j*6= z#FQO-os(mEFH7_4hra%>6ZXauQO}x;wtMZWtDNW|Q!lWDEojT}#aqov^K~7VHeXnB zf0xI7GZrXCL%Q+_YP>yMt zOhL%ypABbK{xf}U<~{MpPUHm8C#of`5hW>!C8<`)MX5lF!N|bKNY}tr*U&7)(8S8X s(#p_O+rYqz&A{Nh1AoorSVnO*Z1M&MZL-@B01agDboFyt=akR{0GZyYumAu6 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_cyan_white.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_cyan_white.png index a51af9ae1584df4151eeb852ef10906ce28ec0cd..d9af327a927771f284e4f240a5bdef8c174ecc7b 100644 GIT binary patch delta 363 zcmX@fa-MmD1SbnK0|Ud`yN`kQYut8x0<25!h#%%Kx z0TVW6M-F)oi3bO+o;|u(_v+Es#8uuM-Qog9I=tUcMM*t+))>HC%*K$rliy$VUU4zd zHq{c>i29P0#FA92Uh51Ao5|P!ofv LtDnm{r-UW|>(qKC delta 431 zcmX@le3E5?1SbbG0|SGGE`RVuMf;?p0G|+7{^%s((mLUyYT>d5;o@51l3Jm>a^b=% z{+JZuk~$uDUmj0?9#20W4?k`fFX7U9;o=(p$VC3AM6s5B(WYMh$ONH+D*o71;qpeY zwuwA$KK#+iVyzQ|%j$&+Dkm0-3QB9wjR9K9nB?v5BG1Yzuy^8gx%y|Uq8vu72G6^f z0HyYOx;TbNTvnZMJBZnk$2s@tv5#>bnTi4$Dcj%v`>#JKQ{KdV@x>R8E<7q1za(v7 zIh*n!bKdmIsB70xt`$f+In&f7z=WIQ^=(c?F8wnW);CMKBtH~HO1@vb@yU-BOG6H; z?~79We=Z?IlKa#ht(SiuyDEhhI!uuAxTrV%+N}#aw=!^^ahm*Z)~broRi_RrwsLEW z|6IK9>)!8md*A*xyYbTQL&5RjlAPOH<$oLAaR2UBkZQb*qibud@Wc1oK1wAL(p>4$Cp5e1H3Ro)%l;sQoGyx&hnNj-Yj7{FZ2#*n*{-(U7# zaWT*~)e_f;$xj&tq>Ob9jCBo-Lkvx=42*$D+rYrez#vKaVBlnaCh;ij(!zC>Z-Itr z01YWgNi0dVD#^@EEiOsSEnqM*Faqi^(={>(F*LL?u&^>ThZxDg-!BBz!{F)a=d#Wz Gp$PyK0&MXB delta 452 zcmcb_e1>I$1SbbG0|SGGE`RVuMf>{F0G|+7{^%s((mLUyYT>d5;o@51l3Jm>a^b=% z{+JZuk~$uDUmj0?9#20W4?k`fFX7U9;o=(p$VC3AM6s5B(WYMh$ONH+D*o71;qpeY zwuwA$KK#+iVyzQ|%j$&+D*qf;`F%{~#}VaUM^(NZQvP~K`R7rU|NsBL7H#fk;9+23 zO!9VjQH$c3v324sx%y|Uq8vu72G6^f03EsC)5S4F;2 zNZJ1O-+%o{nery?i!Z)#bm39C_$6rr%h{9IzeP5K~|8of$lH8~6XubUN*i|X4&|!j<$3?yA z*KS?dxs`$QjMLh&e9Nz^Do;EC=)yJNr@>Bl%4&FOo4mZ4*Y``ckWu$9hs%vN#VrXJzU}CkWnl2#fxl*QBBQt(cIh_R?FWD%!QkoY=d#Wzp$PzF0JVPr diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_gray_black.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_gray_black.png index f76117d1ccf10f4a99b02e903f056d6fca502fda..8a2cd437fa1bd304c408e172ebac731abe079923 100644 GIT binary patch delta 339 zcmbQtvYmN?1SbnK0|Ud`yN`kEal|aox4=qF{pohjXxc#w(_) zyjANMq^JB1&pZ-*|GM%7>wp;{1=g*kacdB+t9%R8paHj{Br`X)xFj*R0IJ7K i*T^8m(9p`j!phJbVu=6)f4>k=6N9I#pUXO@geCyxu51DT delta 449 zcmdnaJeg&J1SbbG0|SGGE`RVuMf>{j0G|+7EnR&xOIuS5YjZ0*Q%f6TGfNW-Yf}pw zZ9M};WmP2=HAQ7L1tk?TD_d<{15F)$EggMZM^_sM7fl^K6LV{AJwrPuH!WQQ6LTwh zd1ZNdB{?~z|NsA+@3pN3TE&>;?d~EohsBW{$l)yTh%9Dc;M)(vj208;^3*?L73DBu zaeuJe2q?eA)5S4F;&Q0pTR&z)p6+1b?d4N)*Jyuv_xJu}o-OhbU2|MMwM*XNj=Xnh zamQ7sjOazVzpI@~igUL%DP8^PX#RHk>Uru`3#4^!h0c~?Dt{3?jq9%ad*v?yGw)tl zb@=Ax#sf0P-g3{?@=(?fcAKw%=UGU-ort2?w}dRVTm$AK^H%!2-M)5f-<(pp{afC| z{79^$()IuytXkq4QIe8al4_M)lnSI6 zj0}v7bPY^(4b4IfO{@$otqe`I4GgRd48A+?*Pv*~%}>cptJK1+qfK`E0iX^BPgg&e IbxsLQ03#-tRR910 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_gray_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_gray_blue.png index 634752bea28797a3767448bf215569df9560bf50..223cd62d229e0dce165529bd2978d45f229f1697 100644 GIT binary patch delta 332 zcmbQsa*la|1SbnK0|Ud`yN`kb@zLypEZ}#_I?&J!-$CEPo>wuQ2 zmbgZgOy17OFJ-K2V61Cs9Aao{Wnc_M+6D$z1_nvW2LmTRU=)wSE-hSF`4(u32FR3@ z#FA92lFZ!H;*!MN0tO=kBcL8LT_b}KLqjVA3oAo&h>;BZ{h$zF@O1TaS?83{1OSMR BY1RM$ delta 449 zcmX@dJeOsH1SbbG0|SGGE`RVuMf>`w0G|+7EnR&xOIuS5YjZ0*Q%f6TGfNW-Yf}pw zZ9M};WmP2=HAQ7L1tk?TD_d<{15F)$EggMZM^_sM7fl^K6LV{AJwrPuH!WQQ6LTwL z)7i$Rvy4n;8ktQ0|Nno;6bpW!ZH!6Y?k=*gnF}WZIh+L^k;M!QeEWfT;xhjFXRM+e zMyv+UyO#hZS9`iRhDcmC^pO&2A5k4W%)GMYsg#)~SnzOujR=9ZtmJLoOY-Kr(75hW>! zC8<`)MX5lF!N|bKNY}tr*U&7)(8S8X(#p_O+rYrez~H+Be+{yR$(fAYYS@*w$!gTe~DWM4f>(rOM diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_gray_brown.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_gray_brown.png index 7c1d4934dee6652078e254d0a7747cd22de5ad22..ee99025dd66d767198f08a1d5c87dfa384aa3a2e 100644 GIT binary patch delta 332 zcmbQua*la|1SbnK0|Ud`yN`krCc@1jXgTTQOQ2Mur;B3<$92~} zZ@~rw9+&MJFT|Kx*=2Q>80;12lrd;vR=J|D$n&A7^5+|$2N@L`q^ElP;IOD_XSg$a ziP40EDidu(b<%{p)eDS%eBrYDr1SHJOM%zaMXlSW?Y&z0Gyk5sUMf33+p3+)e}I;$ zmbgZgOy0`KFJ-K2V61Cs9Aao{Wnc_M+6D$z1_nvW2LmVHV-%0VE-hSF`4(u32FR3@ z#FA92lFZ!H;*!MN0tO=kBcL8LT_b}KLqjVA3oAo&h>;BZ{X#%J44$rjF6*2UngH#v BYwrL6 delta 449 zcmX@dJey^L1SbbG0|SGGE`RVuMf>`w0G|+7EnR&xOIuS5YjZ0*Q%f6TGfNW-Yf}pw zZ9M};WmP2=HAQ7L1tk?TD_d<{15F)$EggMZM^_sM7fl^K6LV{AJwrPuH!WQQ6LYH~ zcZ~u!^+Gp|d{_1V|NnO%%;o^v#+c;o?jrk|xo{$o!&%@FS?l(MEZe0lb) z^TeYoLCj0#-n;JY-1uyb!htsa86S4s-5H*{s%AyS&drymbUFX@{E(vTh(b({@|F}d?J@ehpmS-G(?IkUY7Y~UZ{5#F^x#ZS$#oH~P z&Z>{tubRERblu+L?^P!T+`W3zgD?1`;l}*#Cxs{NUomovOc1dS2fA9d#5JNMC9x#c zD!C{XNHG{07#ZmrnCcpug&3Mx8CY5wnra&uSQ!|6ci^u<(U3bin~_ruyW%$4?FWF0 O89ZJ6T-G@yGywqhlbjO( diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_gray_cyan.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_gray_cyan.png index 6106af3ac7ad91f06d4540263af082f91c0b3430..13d072b6fcb80d18b86eeb534322617c4fd824cd 100644 GIT binary patch delta 384 zcmZ3;a*BC^1SbnK0|Ud`yN`kZJi+6+$Y-7 zFWS`m|NsA2mzf>`bucD*ySs3Hyt(uZki%Kv5n0T@z_%ZS87)|YRe*x*C7!;n?9bUm zxH$wZCw+Vg6iV=PaSY+O?%J2j+hD-slCN=tmzkNJTkKR@gQ|vt#*BKF3%;6+asT(! z#ROSM$-Qw?6|!UMyQj$TU2P>#ih*Z}zi9W(Bab-e@YwBb>bLZ^G#8W!TAHzNZEC)$ z{{OSTkFh3t@Li5L`2HWzGSw2-h?11Vl2ohYqEsNoU}RuqtZQJbYiJx|Xli9(3`E)n z237_JNy-NU!5VU4I&$+kzK1d<)c}0k@(gGdH!kBr&%Ds>e*%$RNbf(8|EV Y%FrBQ3j=?@5Ks?;r>mdKI;Vst0In)^_5c6? delta 472 zcmX@bypUyr1SbbG0|SGGE`RVuMf>{L0G|+7EnR&xOIuS5YjZ0*Q%f6TGfNW-Yf}pw zZ9M};WmP2=HAQ7L1tk?TD_d<{15F)$EggMZM^_sM7fl^K6LV{AJwrPuH!WQQ6LTxE zwuxe`6U18jMVtFXn|lBM|Nqf{ODNDn#w2fd7r7!X1#KXQv%n*=n1O+Be?5p`v|tTZ z0gAGhc>21sKVuc;Fk*3ku-gbIw8qoLF+}3BsULTciy;TIl;>^rUGt-I?^pfLKJ{vb zq}l{U7C}>OhswgwP9cR^uRE{xUtcDd^k%CThrtInVY&C>cJ92PaiM!+Z)AEMUAQOk z(!t*y66g4*NiJGDOG-)Kp}v&Q@&6Tu?q`bHlbL4!-*N7w$O}J_7G+yzqX~>IDO#6) zt7fk+Ub|KP`OeAHYt;XiJ&!-Rv;3XPq@W6qx)twUrPT2Sue@1kqujMTsGi}?Ic|jx zc7r=WhpU#jMwFx^mZVxG7o`Fz1|tI_BV7YiT|=`FLlY|lODjWDZ36=rD+7b?4*WGJ fI&$+Eal|aox4g zTd=`^$7Q?53o&L^c3GVz27ARhWeggaRj%kO@_Z<&{Q1V`K}N*}>8Tz+I4r8#8Sczp zVl?5P%0$~xoiyQY^#Y?GU%2c(>HNImQs6apQR}v8d#_gh%)e)@m&(r1wrZ#HAE0Hb zC9V-AleaSROBw4L80#7uhZve#85jeRwt<0_fkBe;!NAG)7{#NoOAFUkz6F}10Wu{e zu_V>1Br`X)xFj*RfWgSX2&l(Q*T^8m(9p`j!phJbVk859zYtIlgQu&X%Q~loCICT0 BYF+>U delta 449 zcmX@dJey^L1SbbG0|SGGE`RVuMf>`w0G|+7EnR&xOIuS5YjZ0*Q%f6TGfNW-Yf}pw zZ9M};WmP2=HAQ7L1tk?TD_d<{15F)$EggMZM^_sM7fl^K6LV{AJwrPuH!WQQ6LYJO zT$$i(ncy6mpe*VC|Nl=qv*HZUHpV1xcNf{$%!Lzy9L@rd$YKTtzWqQvaT$O8GgeU! zBUXdw-AjOyD?MEtLnJPn`gQxUDDvc-zQGu_$NH&71*i zqy#&2v##jVTcMwua7kd3iN=PH{l_JG>Y49$wmjqTYcFYGym(0T;NNMM&n366E8cGT zbXI-De%0*lrR(+{f3G?*;O^Cv9(=(k4L9a@KPfzE|B8`YWP*rwIMCIqC9V-ADTyVi zR>?)FK#IZ0z{p6~z*N`JEX2^n%D~df&{W&Nz{iiX_D*^HcO*cG?QZa)B2 O%;4$j=d#Wzp$Pzfbe&27 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_gray_light_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_gray_light_blue.png index fd9ec89b2fb8045e35de57998c26a7a3d07430cd..1df29e6203e1bb863064d777a518af51f019e2b5 100644 GIT binary patch delta 335 zcmZ3@a*26@1SbnK0|Ud`yN`keoOCdsa*CZ~k9g$ovJP?*4YjZKU( z+dM_UgpJveL!Lw8!GWu1kM7mIdbBlhm3K$CxPXxk@Ap$tQjeZB1~3=1G34&#_m{m_ zTnw~LwZt`I@)1S>DPvs&V_iez5JOWd17jf4HZZU{X0G|+7EnR&xOIuS5YjZ0*Q%f6TGfNW-Yf}pw zZ9M};WmP2=HAQ7L1tk?TD_d<{15F)$EggMZM^_sM7fl^K6LV{AJwrPuH!WQQ6LTx; zEw`;V-?G|x!+P^gs}0vI*I%{TbmRa3|37#mo&v39O!9VjQP`Yq+W_Qn7I;itAW{E} zRg}Ys#r?r&UhF=Y4ID+{g|UNO-`ib|+51rblYko>djQH(Z|5<@?jkll8v)k%GDn zX9RMuUJ>}oxT=`r*K)Q96Zy!QA~*i5e?7*`B4#p&JcNfl&HnFwLJ6KOjv*Y^UHfu*8w_|{@-=SoGBdMti=Ap~P}NY-m{HGi!B>+p?*E>; zm>>%&xi@aALUv4j_Y@hvtF7coG4M?B7wx`z$PSVIm>M{a&fW?Cg~9l~{$Z-F{A;8v7m=B5^xB<2=C^_b}z8H5-bS{Yba Y8Ja_EVc_o<0_tJ#boFyt=akR{00=90wg3PC delta 472 zcmX@bypUyr1SbbG0|SGGE`RVuMf>{L0G|+7EnR&xOIuS5YjZ0*Q%f6TGfNW-Yf}pw zZ9M};WmP2=HAQ7L1tk?TD_d<{15F)$EggMZM^_sM7fl^K6LV{AJwrPuH!WQQ6LYJc zp62fErmn8W&d!F8j{5)q|6iLpwG(I|W0JSKi(CO>_%)r36zaB&|TCfJI z07cnLJbhi+pRtN^7_qoN*lh$9TI1>B7$R}m)Q>yJ#gKzp%Ja7RuK7{9_pAPApL#Vz zQf-1Fi=e5tLuKJ-r;x&|*PYk;uP>8Jdb3rF!{7s(u-tobJ9pmDxX?YZH!{7BF5DA% z>EQ1UiF5qZBp0onC8ebAP+!XD`2Pw+_cKN9$xO5V?>Ki-gTe~DWM4f%QBoA diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_gray_lime.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_gray_lime.png index e77ca2a2ca96c0f75e48479d1f455584ae656016..e5869f654268f13d5d9d15882fef0ca54f99bacb 100644 GIT binary patch delta 332 zcmZ3@a)x<=1SbnK0|Ud`yN`kR delta 461 zcmX@ZyqaZ#1SbbG0|SGGE`RVuMf>{X0G|+7EnR&xOIuS5YjZ0*Q%f6TGfNW-Yf}pw zZ9M};WmP2=HAQ7L1tk?TD_d<{15F)$EggMZM^_sM7fl^K6LV{AJwrPuH!WQQ6LYKl z-4gk`Byx915O+0U>#Q*>QcWsy04YZaq$=lsUVRN=^1CYa6;4yKoMEx^X zQ4S*(_XoR;fMOdwT^vIsE}Qx>2C*1&FiUyf7TtR}>g~I^zyHUddU=9p@&N%MK~rsq z%A(IsA%$75BiH7i_q9E8BRfR*8A>93hFkT z5y-uIMc^mns$z~`%h@7KO*wSaI+T)4{k@LQP89#Gy+rLX%S_X8y zYKdz^NlIc#s#S7PDv)9@GB7gIH89mRGz&2_u`;lq!GOmlU*iTZGc!B4n3v-LArT%;iv#*gSt|a1{#EEH_`+p_bg$159+qPbEO%xn z8BI93bb_s~%`@SC@q(fsU)b!@rasM3vRK*`wJ>+r_EoRzKkqAKOyK3)uUogn3uu*U ziEBhjN@9IUs#S7PYGO$$gOP!ev95u!uAy;=p{bRDF%W4R7+4t?Bq<*ZMCbr&$jwj5 zOsmALLAb8+El`67#0sE>lFZ!H;*!MN0;nD{T_b}KLqjVA3rQ`M0G|+7EnR&xOIuS5YjZ0*Q%f6TGfNW-Yf}pw zZ9M};WmP2=HAQ7L1tk?TD_d<{15F)$EggMZM^_sM7fl^K6LV{AJwrPuH!WQQ6LYIw z_Um`ruiI|7W}DsWt+uOn*scBl|G)8`lQ)2NGA4PuyU4Th3hV`PI14-?iy0;^5Uqd4 zD#~HR;{IT_5m0!&r;B5V#AQ=I#vm3$4rVFO-P%><*Rpm$|M!1pk=1dY$p-|41WmOa zDhoe5g%oDp-gIl*ezUIvkHc0sF)-&FJp5PpF!@Tr)6k>0Tcv$h-k56crS;>Y@~+R5 zQ(H1tFKau&A0QjMp*FL@_4CB3j*Y$PvB&EZ^j`Rhv?!a(UYf|}vP3)Rw{G#-}RlBWbo=ns-mHd5pQAOS>{SQ{$M!tKi`+;s( zEpd$~Nl7e8wMs5Z1yT$~21Z7@2Bx}(W+8?qRtA<Z!pI&$+< ZGSez?>u8hRegLS0!PC{xWt~$(69A#Iqxb*- diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_gray_orange.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_gray_orange.png index fdf3d7a1d1d8f939c1fc71c19aa26f374e62036a..25cbe6e1a5bd4d6f89ba1e0b9aca1cf3ae629aa4 100644 GIT binary patch delta 335 zcmZ3@a*26@1SbnK0|Ud`yN`kblLV!SuKtMu5f`~{$ia=5V!$}Dy$*!g*r-ZhJ3l?lpn80|AO^h+y zJVn5SjoFbyo(iV_gGdT|?s#LsKgQV<6HtFt9Q(NK!r+IQbo;cocSN;kwGVKtnWu zhLofvmZVyhWag$8mn7yEFc=va0ri;a8X1Hb8d@1xSQ(l_jAY>N7Xs>G@O1TaS?83{ F1ON$~Xd3_k delta 424 zcmcb_yqaZ#1SbbG0|SGGE`RVuMf>{X0G|+7EnR&xOIuS5YjZ0*Q%f6TGfNW-Yf}pw zZ9M};WmP2=HAQ7L1tk?TD_d<{15F)$EggMZM^_sM7fl^K6LV{AJwrPuH!WQQ6LYJt zB?4bc1U?oCd@dGvUnuadP~cOs!2kdM=fsJ)0j*_B@^*Jo*qm+K0OW8McuZU%QU8op zl*5R{{lRV{px6da7sn8Z%cg#eK`e$G%u=4WMfYBgdi!qf@Bi_qUY_8Yd_X`*&{W%@ zvgor@NMY9N$hG)p<#f+cAVY?m53N?fz{r@Va~k$v~w z@r~+wKmC5BK94`W^ZoWxx%5Y;ZtqTUDh*dRw)9!5_P8QKAc^&s01Q8ZyMm9$^RfPb76oG(*gai?hgcO0K1cs9mOp;wqO->1I3l}WdpfG{)8k-nn zwt0$x2^+H`hdhVGg9BI39^I>Z^=ND2D({YNaRDP8-tVWPq#iwM3}7y1W60gf?=O3= zxEN@gYKd#a<_2F5_7ZD3$!V34GIFmUoaM)4@@(!zC>Z-Itr z01YWgNi0dVD#^@EEiOsSEnqM*Faqi^(={>(F*LL?u&^>ThZxDg-!BBz!{F)a=d#Wz Gp$P!SRc{X0G|+7EnR&xOIuS5YjZ0*Q%f6TGfNW-Yf}pw zZ9M};WmP2=HAQ7L1tk?TD_d<{15F)$EggMZM^_sM7fl^K6LV{AJwrPuH!WQQ6LYK2 z-K#!zt$g3P{A1V3w;jvgv@iY8x#Iu-|2tyz9s{jqO!9VjQP`Yq+W_Qn7I;itAW{E} zRg}Ys#r?r&UhF=Y4ID+{g|UNO-`ib|+51rblYko>djQH(Z|5<@?jkll8v)k%GDn zX9RMuUJ>}oxT=`r*K)Q96Zy!QA~*i5e?7}cX|Gyz+Vir&zW0JSK3%C6BBL^nll&gQvCc@1jXgTTQOQ2Mer;B3< z$Mxg{5f)}fHb*s8g#dvRfq;aB1QC&h6oI4!hLaLZl3h(rP6=%b7cAJIFoE$Jn;2uZ zd5VAu8?z&aJcq=C16R);-K%@`Xlvps?~ZP90V5sW@28@q9zAOeU@m53$lb~BFMF@J z7-*YniEG5G_*3Xurf4<7|FojF9g)X;OXk;vd$@? F2>|8LXC?pu delta 424 zcmcb_yqaZ#1SbbG0|SGGE`RVuMf>{X0G|+7EnR&xOIuS5YjZ0*Q%f6TGfNW-Yf}pw zZ9M};WmP2=HAQ7L1tk?TD_d<{15F)$EggMZM^_sM7fl^K6LV{AJwrPuH!WQQ6LYH) zwUs4mD~eQ?6|1c%R9#xAx};cb`Tzg_7d1(R0Ig+A@^*Jo*qm+K0OW8McuZU%QU8op zl*5R{{lRV{px6da7sn8Z%cg#eK`e$G%u=4WMfYBgdi!qf@Bi_qUY_8Yd_X`*&{W%@ zvgor@NMY9N$hG)p<#f+cAVY?m53N?fz{r@Va~k$v~w z@r~+wKmC5BK94`W^ZoWxx%5Y;ZtqTUDh*dRw)9!5_P8QKB@@#|Nme8@52V5CdMRhcNeaV3tz&39L@rd$YKTtzWpG~Xu%q+0u*E~@$_|N zf6gYt%^_$x>ElbFP@<=cV+hA}*S=id1_K_Ke2p8t%*^cEVyD^~R5j`qG-j~MJeVHD zwC7*t-yKT|Ol)rSda2Z~$n14yc;_1=c_LxbiFsOLn>&vRTS(SavC0=uE6P!_Sn74r zDf;xithj%(zxQ${SMWWal*wNQv`w|dHKHUXu_Vlzw|7@Arc z7z2^Efq|8QL6Y*pK!yTj9l7}_nQ4`{bqLp0z6DyL0k@(gGdH!kBr&%Ds>e*%$RNbf c(8|EV%FrBQ3j=?@5Ks?;r>mdKI;Vst091>2egFUf delta 449 zcmX@dyqINz1SbbG0|SGGE`RVuMf>{L0G|+7EnR&xOIuS5YjZ0*Q%f6TGfNW-Yf}pw zZ9M};WmP2=HAQ7L1tk?TD_d<{15F)$EggMZM^_sM7fl^K6LV{AJwrPuH!WQQ6LYIM zs!Fp}m1e0Z&QMXDrKfGPi!Tg4KTeUb0KClVD+ipF7ahsOB*1dOkGQ5tit69FJN#1smwSA;p z$F{7jjz0`nFS6dA&K6-JA1NtvblA^me(s~ zvgTe~DWM4fMIe>3 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_gray_white.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_gray_white.png index b7f3d15c2688673408cfcb957aec7b6581f6d640..392fa864c933f736797497ac0bb1076443c60839 100644 GIT binary patch delta 346 zcmZ3%a-MmD1SbnK0|Ud`yN`kt|3 zCa&`C=oS|+(&7DnDoX0nv&I1CVm5}{o&5f?_lk>wwyBo5M%0(2B$lLFB^RXvDF!10 zBV%0yV_iez5JOWd17jf4HZZU{X0G|+7EnR&xOIuS5YjZ0*Q%f6TGfNW-Yf}pw zZ9M};WmP2=HAQ7L1tk?TD_d<{15F)$EggMZM^_sM7fl^K6LV{AJwrPuH!WQQ6LYIS z$5nnGQ~7a3`PWgEZ-9#Z~!ROSEw|CevR4F_7wnB?v5qOdvJwgJfDEby4PK%)K` zt0;#Ni~ED!MnJI*o-U3d5|>T=7=u_0Ihdt9Z;S4|9QF3y+~5D>PrW?BGx>mkkf5oy zLuJutr;x&|*O6=U&->aQxse?zknn(2?M|G2O^?*7J*z5qZ@4_A%lD_7C+mIpBL#IE z&IsgQy&~|FaaA$LujOnJCi0OpMQ;3A|9X!58P>a3bdEal|aox4=qF{pohjXxc#w(_) zyjANMq^JB1&pZ-*|GM%7>wp;{1=g*kacdB+t9%R8paHj{Br`X)xFj*R0IJ7K j*T^8m(9p`j!phJBVu`>v_y50vnixD?{an^LB{Ts5VRmlE delta 449 zcmdnaJb`6`1SbbG0|SGGE`RVuMf>`Y0G|+7OD|#1cnS9y39kf6k2nd}NOAXA2`g`5 z&o~KPD}Fs|eqC#RZ3{jfD}Iky2@6l*;2fEtENKf5VYg^;D<5I6M9Gj`868W0d3j}d zc_leHrT_o`AKbFr7ibS-lDE5yG*iNrB|r{mfk$L90|VcF5N5Ps4OW@BfV2J?t0;#N z+sb#hkVDxdC}--|HP>Ii`(M9e#pA=NY(@qG9ULLtk$$ss z)+~DV{92Xu_qv_CoJ^|LCQM)pTNQENta>WnfjqscyNhO4Sy;b0UbN^~Eravh#QnmL z>O&X0XbH@4zHuaYvqDeQGS1Sv!r8|4n-W(YJhVuqHh@jABZl3m@I+Mh`H18HmZ={9 z#sBldzopJ+X4Wkfe0R_!{P3M)uU$_5kDR}A9oLS@SA?yB4puF3jVMV;EJ?LWE=mPb z3`Pb=;`7Z!g1ZT zFPFE$fX5|Y;|4D?Gds7~skR1H4F!!EtTGR#2QlsWSNV6xk^&Q(8@*mCH7qiFof+Qw z21%Ysm~>*Eme}Ubqrw)FHC3$g#nXy%lq{BdU37{*eJ?BS-|X+b+{qPuk0)jF*8we4 zEpd$~nY@*eU&>h5z*yJNIKehK5!K7FLE95F@|2|Njlt!{F)a=d#Wzp$PyI C>1?L} delta 449 zcmX@dJey^L1SbbG0|SGGE`RVuMf>{j0G|+7OD|#1cnS9y39kf6k2nd}NOAXA2`g`5 z&o~KPD}Fs|eqC#RZ3{jfD}Iky2@6l*;2fEtENKf5VYg^;D<5I6M9Gj`868W0W7FBj zrn8JpW*V7H|NsAg%C9J(O$>}l-tI0kb66bNfgH{PkH}&M2EP3u%xE!jB~Se`R#6Tk zR)go=OMvogJY5_^Brco!cL%W;awwYwt^0c8a#n8n|Nr(+_ZS)rBviPvtZLQCpOv#_ z(X;K>s&;?@1e za;X+EH(Iv%+LVj61fDioc&^^&Sx>#rjI0eCG(6>}II<`mZ!D47^v&ve)NiZvbN4*) z`qh1I`pKQ;-&7`TD(JKf);Bq1JL6H-jN29SG=AE@)<2-dbxp`8bg=d#Wzp$Pz}kDBNJ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_green_brown.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_green_brown.png index b1dfe07495061927faabf32c052b1d0a5d250926..9cf6a552ffca87bfdaca496d5860c28a77740b3d 100644 GIT binary patch delta 362 zcmbQqa*la|1SbnK0|Ud`yN`k80;12lrd;vR=J|D$n&A7^5+|$2N@L`q^ElP;IOD_XSg$a ziP40EDidu(b<%{p)eDS%eBrYDr1SHJOM%zaMXlSW?Y&z0Gyk5sUMf33+p3+)e}I;$ zmbgZg)Tbntq*^5xr2;7iBLgF2T?1oXL*o!bQ!4{wAksE4ure@6Qa%_6(*f3yo1c=I zR*74Ka9!nFpau<)6<`e|nYpROC5gEOP(5b4Mg}2>v|Njlt#Ng@b K=d#Wzp$PyG6?Sg` delta 449 zcmX@dJd{j0G|+7OD|#1cnS9y39kf6k2nd}NOAXA2`g`5 z&o~KPD}Fs|eqC#RZ3{jfD}Iky2@6l*;2fEtENKf5VYg^;D<5I6M9Gj`868XhB6p1f zH}yg{jeJ-2|NsB*UeC!6w2Cpw+ucQG4vQm*!&%@FStp!_ON7sn8Z%clN}MTZSIoFfijiSrCEpEvo>|M|+>`>YoVvopCYh&u6U;mKoK zS#{ZKw@1I9Umo7!wqBIy(g82g*SFKAmoR)QxcFP_?3Kee6XU1Jn$BaE$kP8kPvHMb zF4aqo2V@SZ&6~%Xc*V$f#b diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_green_cyan.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_green_cyan.png index 3ec876831c53f96fe3e17816439c0533940108c5..57ae5da836f3388530666e67684a08e70d636c6e 100644 GIT binary patch delta 348 zcmbQwa*BC^1SbnK0|Ud`yN`k znc^?nee=j8&N)1Gdz<<#y)DfJWrCJwEL@wKZ>sehK5!K7FLE95KF$f|NqSc)WqQF>gTe~DWM4f DE?01( delta 470 zcmX@bJfCHP1SbbG0|SGGE`RVuMf>`w0G|+7OD|#1cnS9y39kf6k2nd}NOAXA2`g`5 z&o~KPD}Fs|eqC#RZ3{jfD}Iky2@6l*;2fEtENKf5VYg^;D<5I6M9Gj`868W0v9^g~ ztrNsr`bC@jM4Nj5|NqZ^X`2$zHpV1xcNf{$%!Lzy9L@rd$YKTtzWqR4zn{^9HCP2G z%3k8>>&pI&Rg}Ys)!=#e5}?ppPZ!4!iOZ(`+(FKU94RNgGLkB{t~AvD`tSLaS38V1 z9QY6|xI%2xp3F@fyJp2ly?%S?_wTEsi!NrfHk)h+I{K^dhIT1KS@Ff!f@iNBzL_XL zP1f`svqTpE?>PehS8=HpF*jP)xA@wWi?sxvHd%PC{?4-=of%mhHfVUtPjO^XI^I|! zv+3N{>ru~(-y2t+EWeb$<-gCj$~1o^O>Td~^jEEJJJ^F`c#Eai3#M&@N-F^V5fx*+&&t;ucLK6VvexdjP diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_green_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_green_gray.png index d0c5bed6a2ee97e32ff928fbd2c7bc4ade18c0c9..aa54e057b519bf24e6fab453906f1e448845c8c5 100644 GIT binary patch delta 326 zcmbQka+rC71SbnK0|Ud`yN`k|=1 zHzSvnv95u!uAy;=p{bRDF%W4R7+4t?Bq<*ZoP3{AJPNzCa9!nFpivrdqe?P!Q;SOy ra|;-Z42*z!%yf+mLJSS93@oe+Eg(jIbN~MvsE5JR)z4*}Q$iB}S}ts1 delta 436 zcmX@iJcnh11SbbG0|SGGE`RVuMf>`w0G|+7OD|#1cnS9y39kf6k2nd}NOAXA2`g`5 z&o~KPD}Fs|eqC#RZ3{jfD}Iky2@6l*;2fEtENKf5VYg^;D<5I6M9Gj`868W0J0~|= zM^`&XS6c@c8wZ#F|NomFV&?+d#+c;o?jrk|xo{$o!&%@FSLynY_UKvT1S2KK~-q-t8UfyNQeR#fTW0vCS*~`qs z0zZ3a?~Sdh-@nVrq-t%#1h%kM5%zr6&g=>1;(O&T`q<8q{g!w$@NqGN^V`$=)Q{A! za_YR}kieHHe10x#;uRy`6`$p|TPiyWFO$;I@w&vGD$sbMP=U97&DOF{|86Xg_O83m z{oB*?-t~Luf5q_|roU=++rb_j!&@x}0WJN~ta3fsUf LtDnm{r-UW|2Gx;# diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_green_light_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_green_light_blue.png index c1b9d96a83c68ad42f53ac0f2993f45c41009e6c..72e25855a04d21befc98d6e15d2d68f98a8b5624 100644 GIT binary patch delta 366 zcmZ3%a*26@1SbnK0|Ud`yN`k$PR0l*u zZhlH;S|x4`!gZBzff_V`RzNhAWag$8mn7yEK=qjE8X1Hb8p>E1SXdcaKy3Nu{{J^n O6N9I#pUXO@geCwrR(3l8 delta 424 zcmcb_yn`M0G|+7OD|#1cnS9y39kf6k2nd}NOAXA2`g`5 z&o~KPD}Fs|eqC#RZ3{jfD}Iky2@6l*;2fEtENKf5VYg^;D<5I6M9Gj`868W0>n*pf zH{Y__c*A=0O{)#pEZ1MP+H~Xp|NmK?49|gfGA4PuyU4Th3hV`PI14-?iy0;^7Oj8A zD#~HRYVf>!2~c>0r;B5V#AQ=|#vo=xj+B#L8A&^{OrEX#`tQHb%DyuPm^SMuFkN+; zChltz7Wmmadv9!2{oY+pCRJ+_Ca{IAinwo9J&o@`o?g}6MKh}`tlylS6!^H7!TIfB zJM|;`S2=ZtC>XSF=v27x97M|3z%nH-CyPzyIBL?y*nI$=VLf&+!>8)durdC+0ogx#-E?HTK7rbA3BCtFvjc z0i(E-k*7=4#p&JcNfl&HbP0l+XkK DO^kC! delta 470 zcmX@bJfCHP1SbbG0|SGGE`RVuMf>`w0G|+7OD|#1cnS9y39kf6k2nd}NOAXA2`g`5 z&o~KPD}Fs|eqC#RZ3{jfD}Iky2@6l*;2fEtENKf5VYg^;D<5I6M9Gj`868Xho}T9J z?xwD;#?H=$j*j~O|NkrSO#cV8jWNmF-9`2_bKyiFhqJ&VvY3H^Z$A*%?`O1N4ORh) zvX^-Jy0SlG73DBuHF(~=1SquD)5S4F;uisw!{rjruqKnzA%_bXyj{YjVp!C8<`)MX5lF!N|bKNY}tr*U&7)(8S8X(#p_O+rYrez{%jd1Ah&Q ej@RJF#F*sm?!uLE;Y--WYjX9^*+jTGgci(R5Db)x_jGX#;kfSF zm&@B=z~hpyaf6qcnVnnA%khAa2#==40sW;c6@NefD)bb5;j%%x*XIZi%drNQJF}CF zCY)S4!PeL2nQ*^&LD7#dY<6i=pJpgoEbWR~n7eEHs@L_O_Z2cG@bc}~t=r)Rv`V$a zHKHUXvA!hLD!C{%u_Tqj$iT>0*T7iU&^W}<)XKmZh_nq1tPBj2ln(|XbO1Hv=BH$) zRpQnlTvz!Ps6hi_1yDmtW^QV6Nn&mRRF9dikwJ)|p_PG!q?Mrs#FlUF|9=BDF?hQA KxvX`M0G|+7OD|#1cnS9y39kf6k2nd}NOAXA2`g`5 z&o~KPD}Fs|eqC#RZ3{jfD}Iky2@6l*;2fEtENKf5VYg^;D<5I6M9Gj`868Xh{M{1y zyCiaVNaXF3$k{HQvrRm2r^NsN|22#qb^`5WO!9Vjk!R%<*bC%v7I;J!GfZ3{TK|ky zl*5SC;Cc5FpzsDy7sn8Z%clN}LCl66DJQ)$l6Gd9JX`nm-+!N#eP<3ZZPrm>y6QAd z+}9*5@UwUJ-q@=8y}O)Ds@5h#5Pzd1W8@Nq4J^V`FA z>PPmka_S6GFlgVS4d$;-%zM0Z(UZSx?2j$y`gUqoXA{uz zswJ)wB`Jv|saDBFsX&Us$iT=**T7WQ&@9Bz#LB?Z%FtBXz`)AD;JX8V4OD{}L`QCZ aN@iLmZXIp1+YbPBFnGH9xvXvL>4nJ@a+d-Mhn(p6`&w{iKnkC z`*SuCZVsUZvlj#dh2lM3978y+yY}VsHW=`@@8tIl{wotbygu>?ETJCznpJ^|g5>+%H~G^y3SgUE0*A8A=vQyP_86 z?%KZUb^Ygkg^UTjeEW6lc6b5pQY~?fC`m~yNwrEYN(E93Mg~U4x(3F&hQ=X=rd9^V zK%{M8U}a#CqolD)78&qol`;+04|h$P5=M^ delta 461 zcmX@Zyp&~v1SbbG0|SGGE`RVuMf>{L0G|+7OD|#1cnS9y39kf6k2nd}NOAXA2`g`5 z&o~KPD}Fs|eqC#RZ3{jfD}Iky2@6l*;2fEtENKf5VYg^;D<5I6M9Gj`868XhUH0pD z+OOMgw`QB&>aDh`cG#``|NsBJE~^Hhg^Wqw?k;jgTngGi4rhT!WHAE+-~NeEak7aoNW2BfsW0vCS z*=ka&SNu%9eXA_)#lA&O}t{{v*PjnyySWpGau84h$&0Tz0{c|K6YR$o0%P3kBaDtXbE#^Xv7lN#8gBV>o=1>*cJ7wTpm` zS1oakC`m~yNwrEYN(E93Mg~Skx(24YhGrp#CRPTPR)(h91_o9J2Hzd{YoHp;AUbmM aQ!>*kaqDQ4-F^V5gTd3)&t;ucLK6Umh^TJ> diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_green_orange.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_green_orange.png index a8988d87e41c00ecee2cd4cf591f22d7bdd71a15..914429da8c9c1865843cfd6ea1c3550c9d877eb9 100644 GIT binary patch delta 366 zcmZ3%a*26@1SbnK0|Ud`yN`k*Zb{MFSG0EHAgblLV!SuKtMu5f`~{$ia=5V!$}Dy$*!g*r-ZhJ3l?lpn80|AO^h+y zJVn5SjoFbyom4QK$^1(o;4v2=_ z{FKbJO57TR>nh&@HD~~>fM_Vm%uOvWNz5&P>M_$bG6*p=l(90furjoO*z(Q&|8Jls N22WQ%mvv4FO#sk`b8`Ry delta 424 zcmcb_yn`M0G|+7OD|#1cnS9y39kf6k2nd}NOAXA2`g`5 z&o~KPD}Fs|eqC#RZ3{jfD}Iky2@6l*;2fEtENKf5VYg^;D<5I6M9Gj`868XhuO$Ls zN(4R@34AUVcwZ>+u2A4pvB3ZT|M_nDxB%^BO!9Vjk!R%<*bC%v7I;J!GfZ48TK|ky zl*5SC;Cc5FpzsDy7sn8Z%clN}LCl66DJQ)$l6Gd9JX`nm-+!N#eP<3ZZPrm>y6QAd z+}9*5@UwUJ-q@=8y}O)Ds@5h#5Pzd1W8@Nq4J^V`FA z>PPmka_S6GFlgVS4d$;-%zM0Z(UZSx?2j$y`gUqoXVYW@ zMsX=4T?12HL$eS=6DtEtD??Ll0|P4qgYORfHIow=#nrG&x5;il0Q5S8r>mdKI;Vst E0O16j{{R30 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_green_pink.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_green_pink.png index 39f2be5c8d1f8e4b45b276f9a5c6d0e21e837fa1..4437698b9e6fea91e99c0255867b8ac06e668333 100644 GIT binary patch delta 366 zcmZ3%a*26@1SbnK0|Ud`yN`k$PR0l*u zZhlH;S|x4`!gZBzff_V`RzNhAWag$8mn7yEK=qjE8X1Hb8p>E1SXdcaKy3Nu{{J^n O6N9I#pUXO@geCw~`M0G|+7OD|#1cnS9y39kf6k2nd}NOAXA2`g`5 z&o~KPD}Fs|eqC#RZ3{jfD}Iky2@6l*;2fEtENKf5VYg^;D<5I6M9Gj`868Xh&)us& zb*+5gx%^|-%C{ZM-n1|M(7EFO|NmMy${qskWK8mQcadl171#^pa29w(7Bfs-EL#7J zRg}Ys)!=#e5}@z~PZ!4!iOZ(`j6uwX94RNgGLm*?nLJzf_1}M=m3?OpFm2XRV7lrw zP2ATcEby~;_TJd4`n|iHOsdu;CJdK%w>JiV&Bi)L0?Sid> z14eNvBV7YiT|=`FLlY|lODjWDZ36=<1B34l{56vk8O7DGOSj2xKLGSPgQu&X%Q~lo FCIGtgqLu&v diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_green_purple.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_green_purple.png index 405c3229249982aa08605768e6514194a3058206..726307e8870c373d07db347920c771bc9c534591 100644 GIT binary patch delta 366 zcmZ3%a*26@1SbnK0|Ud`yN`k}cX|L>)>eGgC{W0JSK3%C6BBL^m4ldFHuCc@1jv|#pvV4zfzr;B3< z$Mxg{5f)}fHb*s8g#dvRfq;aB1QC&h6oI4!hLaLZl3h(rP6=%b7cAJIFoE$Jn;2uZ zd5VAu8?z&aJcq=C16R);-K%@`Xlvps?~ZP90V5sW@28@q9zAOeU@m53$lb~BFMF@J z7-*YniEBiCNlIc#s#S7PDv)9@GB7gMH89pSG!8K|wK6aUB5eZ$D+7Zh<%5Ax9S{w< z`6-!cmAEws*Hyj+YR~{$0nt#BnVVW%l9*cn)nle>WDsI#C}U+{VP$9mvE`fl|KC7O N44$rjF6*2UngD#4a&7`M0G|+7OD|#1cnS9y39kf6k2nd}NOAXA2`g`5 z&o~KPD}Fs|eqC#RZ3{jfD}Iky2@6l*;2fEtENKf5VYg^;D<5I6M9Gj`868Xh619~j zYAcFVmldn6C{$fqsJf(BZTbKI{|(rj!hm)%CV9KN$g}ba>;-Z-3p^r=873|kt$)TU z%3;K6@Vt8oP6RcjL_u!XIPxNlZHjqgC7Ue(=2Gpj7D-<+Kk__&tA`R!pl z^&|UNIdz687_@KbT%P7AvDHWT)t~LR=eSSg4dxXSQ+?TN)Zy^NVnUB@@#|Nq~|Y?=(z#F*sm?!uLE;Y--W3v%_(*+jTGgci(R5Db(`^mK6y;kfSF zm&@B=z~hpyaf6qcnVnngR9l0phJwZnR+$IWgP8XGtNgoTNr8#Yjb1O68Wx$o&J6E- zgCtKROgb@7OKfxJQDFb@zLypEZ}#_I?&J!-$CEPo>wuQ2 zmbgZg)Tbntq*^5xr2;7iBLgF2T?1oXL*o!bQ!4{wAksE4ure@6Qa%_6(*f3yo1c=I zR*74Ka9!nFpau<)6<`e|nYpROC5gEOP(5b4Mg}2>v|Njlt#Ng@b K=d#Wzp$PyPlXMaQ delta 449 zcmX@dypUyr1SbbG0|SGGE`RVuMf>`w0G|+7OD|#1cnS9y39kf6k2nd}NOAXA2`g`5 z&o~KPD}Fs|eqC#RZ3{jfD}Iky2@6l*;2fEtENKf5VYg^;D<5I6M9Gj`868XhIjTyt zRh4F`D9%t(oTaMt|NsBEGs`W2wlOAoySvD~W-govvL>4nJ@a+fUiOcxwpRtN^ z7_k~W?_L6wT<_`P7$R}m)St2FumOj2#9@;-PxJhFbD#WwFY`9S^)6;UrV$ZSmXv#`GfjN#z*aUhTdw$AsoZg| zIYnxFHoZRoG%EY->m5SrMgE5A|G0Y#_@5P^-jK4s7Rui}S_xE{G(xxoW;yK0GR zL`h0wNvc(HQ7VvPFfuSQ(ls#EH8cw`G_f+Uv@$f+HZZU&XcsEX<5-j%un30Rkxk0SO5SA|eU(DFR6e3@0U+ zB)giLoD$j=E?BTZVFKedHZjI*^ArISHfBc-c@BvO2dxt=(bmLO-W}cI0!BK# z-%mwJJ$lv{z+BA6kh_!LU-n)x&^ZjMC9V-ADTyViR>?)FK#IZ0z{ptFz*yJNIKbyr{u!$%hY_p6^X?@;sSTbkjv*44P5l{zm<>5nPI_e| z?aVTHw(je{|2`}G&KzLctfRnm)oGfzuSrAc^&s01Q8ZyMm9$^RfPb76oG(*gai?hgcO0K1cs9mOp;wqO->1I3l}WdpfG{)8k-nn zwt0$x2^+H`hdhVGg9BI39^I>Z^=ND2D({YNaRDP8-tVWPq#iwM3}7y1W60gf?=O3= zxEN@gYKdz^eMw4UNvc(HQ7VvPFfuSQ)-^EJH8c(}G_^7?1|n?(11kfAB;|vFP#q8r zx%nxXX_dG&2-j7<1!~X$S^?2el9`)YT#}eu0M%orYh(~&XeeW4U}0rw0kP$q`~TlS OO$?r{elF{r5}E++S$CWO delta 424 zcmcb_yn`M0G|+7OD|#1cnS9y39kf6k2nd}NOAXA2`g`5 z&o~KPD}Fs|eqC#RZ3{jfD}Iky2@6l*;2fEtENKf5VYg^;D<5I6M9Gj`868XhKgU&m zA5-~pMETcIm2ZcXzaCQlc~s^9|NoA$TSI|%GA4PuyU4Th3hV`PI14-?iy0;^7Oj8A zD#~HRYVf>!2~c>0r;B5V#AQ=|#vo=xj+B#L8A&^{OrEX#`tQHb%DyuPm^SMuFkN+; zChltz7Wmmadv9!2{oY+pCRJ+_Ca{IAinwo9J&o@`o?g}6MKh}`tlylS6!^H7!TIfB zJM|;`S2=ZtC>XSF=v27x97M|3z%nH-CyPzyIBL?y*nI$=VLf&+!>8)durdC+0ogx#-E?HTK7rbA3BCtFvjc z0i(E-k*Q7j2Jnw);)fDS3x8>!P<>Zw9|Ns9( z?wuJ>A!Cxay9--l+K$?ZFXZZ4AsSPzs6^K@|x;kfSFcTupxfWtXhJ>wPA zRo<#~4AN8nhG!lLzJFbLf_1=*kOFI0^(=O-Y)9sIXD7&{cuPL<^Sows@)yJUmh(Cv z9_Gm2Q6GZ+~d8S5Gt z>lzw|7@Arc7z2^Efq|8QL6Y*pKolLh`6-!cmAEws*Hyj+YS4gNQIeUPT3nKtTL9H# jrfXynVrXb(U}0rw2C+n7Sw+h-pe6=SS3j3^P6`q0G|+7jjE}}bN3s~*kv;Rpz-WI#PbgJLDpyDZqB6Od0{Qq7leq_sX6@FfnWkPbNuzSI)utPk>#wSp zPc)joL$h{<$$~@HTW-t87i&~cwcdQoWZnV8Y1`%HmF4A?&4n5*3@%-s{LG-8(P7b{Ah{`9W`qQMzPxG8>CC%w=hrb#$zH2*GDp$hC*k(z zqmz!>2)uo@;JLS++q`qqx4IkGn#M=F1XpkVF84rw>I9W%O$y)GHr3Zu6^QvHYu$BN zaX)YG_mf+{ncptHiCNO?LYMpaup{S3j3^P6Q7j2Jnw);)fDS3w~b9_8=1^9GMQmy zGSkp_x}ov3|Ns9-OPjg?H8Cc6ySs2@T=)_;@wHt2b2brf4gtTZ2kU`SiJmTwAsp9T z`*L|340v4fHE!@SGqZDxooZ`P)lkrw!7B4$dJxl|f0ciCEGaOtxzX#TQo|y%*O}p+ zZ;<4Pgh?mnX^Cy_JSuD}d0%bi@o_jpn!e;v>= z)e_f;lF82*`K63?4UBaSjYAAgtqhETNZY``%D^B=`C#B=0VeS%?9#$@m2ZKjXn;&f zNi0dVD#^@EEiOsSEnqM*Faqi^(={>(F*LL?u&^>TgBZE2qGcIS4}+(xpUXO@geCy5 CgKcjB delta 472 zcmX@de3oT`1SbbG0|SGGE`RVuMf>{F0G|+7jjE}}bN3s~*kv;Rpz-WI#PbgJLDpyDZqB6Od0{Qq7leq_sX6@FfnWkPbNuzSI)utPk>#wSp zPc)joL$h{<$$~@HTW-t87i&~cwcdQoWZnV8Y1@rWXB(T&GBTNIWHSB#|Nj%KLLwM= z7#J9nyxm>YqBv%3oj6^t{u!$%hY^eWgWX0zM;`EWaSV~TtUBSLAG0GzOCxLI%UIov z)vH&ptuBB6zbkJ_$|qkn;W{1$A<=1{mMl5Cq-oatX{oV(uYdl0B;~O4TGymAVxJDN zl-2Ex+BAcG(OsD@MQ4wmxcsx{TUtW)+3#W(uh_lW%>E->Ri*Q%qd+xt;4P@|i^>bP0 Hl+XkK6X(Cb diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_blue_brown.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_blue_brown.png index ec6fab118e17422a2ae918cb84b38c3c590bc156..665c99d4ab2eeaed2ec5a1902b2f70d9c625def2 100644 GIT binary patch delta 332 zcmX@Za*la|1SbnK0|Ud`yN`kQ7j2Jnw);)fDS3w~O303fcRlU_DSO(bL5-gyXtv zpSNIx0guaejTd6ftn9KnOAPjkbIKSrFsoeASLFFnRQdCb&x4GL4boFResEY+wKLqA zy~Jq3L6wQNp*m^8-RcEKKfZ9;ebV`P!==D$>Y~nz{1MV3}WQ6ik4+SJq(_%elF{r5}E+b CVQ@77 delta 471 zcmX@de1>I$1SbbG0|SGGE`RVuMf>{F0G|+7jjE}}bN3s~*kv;Rpz-WI#PbgJLDpyDZqB6Od0{Qq7leq_sX6@FfnWkPbNuzSI)utPk>#wSp zPc)joL$h{<$$~@HTW-t87i&~cwcdQoWZnV8Y1@n3H45C+3*9vGUDf~p|L>>I9?!tT zz`&T~?e3x$#W7>+#OZSN&saq{j9A^1^Aa=)jGV~E6M-3b@-4jXW|G9Er)ax!aM z+2?0#=T83fU;kWScS%XfdI5e0g}@|FeXm(QMk{`1&U*IJM1OtybtaMGa~cP8T<^^| zFztIcYj>sNmetMk^bI8|E%Ye5aXHv3+Og)Q^m^zW>;ts_{?H%quSd`bD+GHKHUXu_VKdAb7@AlaSXvpHY8!AESQ!|6ci^v?9Lp%KhA9t{Zj;@90B9hCr>mdKI;Vst E0Jmkg%m4rY diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_blue_cyan.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_blue_cyan.png index 61b3df6c099fc931e92dc804627c7bc6c0ff3a4d..2a895fdb465b5b119d711b9920b3b07b4d998764 100644 GIT binary patch delta 358 zcmcb}a*BC^1SbnK0|Ud`yN`kQ7j2Jnw);)fDS3x5e5findM=ZSE6o z=@)J4{r~^}$#=EBKpl)p-tI1(A8#&wGx42V{c|=EZVmyzsR!$UQVE_ejv*Y^UHfu* z8w_|{@-=SoGBdMti=Ap~P}NY-n89+vSCcXB|DL*-APXtEH*Tszc1(Tu6dAs&t>j5D z@J#U+?Y?>B5$7BpyS+{Qmfn`;f-*r%GZwB*%{SHmfA;q=)$PTn9))ZhlH;S|x4` z!gZBzff_WxR)92=Wag$8mn7yEK=qjE8X1Hb8d@1hSy&mGL2Ox8(XtGviNVv=&t;uc GLK6VYly=Ji delta 520 zcmX@be34~>1SbbG0|SGGE`RVuMf>`S0G|+7jjE}}bN3s~*kv;Rpz-WI#PbgJLDpyDZqB6Od0{Qq7leq_sX6@FfnWkPbNuzSI)utPk>#wSp zPc)joL$h{<$$~@HTW-t87i&~cwcdQoWZnV8Y1_rxCW^IA5NqidZSE6o>iz%!znEKn zdLhs;j7i?^F6z4cE0lp8&H|6fVg?4j{UFR}!5XXr6l5>)^mS!_#wyBT#Nz&7w-He2 zpr?yth{R>p2@m~P3^`gFn*#F6Z7*1_4fEe!z3;#BEsc{;X8Wl9kzi2K(s}CW+3m?{ zYOi~G*PLr_KfaN2*m#>S?D z_YJ-k_85NqUHE1)bDi41J0JBezSWjJ^F8x`?^)BT6*J$RYzer0XV$40hxDL&#^;|) z_!mpZwRr=*qgvt`QIe8al4_M)lnSI6j0}v7bPY^(4b4IfO{@$otqe`I4GgRd48A+? f*Pv*~%}>cptHiCLO?LYMpaup{S3j3^P6Q7j2Jnw);)fDS3x9yzVY#m)~9b9Z2 zT>k(6Uw3#5KTtVilDE4HN87!rRTJOI)jwww;pPzVn|iPwC>7)B;uykl-L>zwV1oh= z3%~Y*4UAiukBJH8FnBFsS$ki?{qCO}IdfqaE5SKo%EE@sjfM)0-`S0G|+7jjE}}bN3s~*kv;Rpz-WI#PbgJLDpyDZqB6Od0{Qq7leq_sX6@FfnWkPbNuzSI)utPk>#wSp zPc)joL$h{<$$~@HTW-t87i&~cwcdQoWZnV8Y1{3b+-x0P?HpZg9b9Z2T>k(6uM)<8 zEfVM$#w2fd7j<3!70MGQ%GEz(73DBuaeuJe2q?AB)5S4F;_? zM>0!`a5a}b{%=2VQR2%JlXQO`Wbl|0ajAKd+GL)rI*nBA_S|}#U11Au6uEJxt^Ra` zWt;tcorp8qi{{FHspv|2@^H`My%IO3J>Git)|Gp2_J)7x_wfk2-lXu2Eyyl(Z;=X5 zve#XQ74dp|zaQQC-5?>D*Ynd-r8m9{IN8|3*Jwoils+a=T)6kFy)<*(vHj0vBVvxv z`Civ2J%fAIBDWpv!cKg}*;=m|V?F<|K5^xrq#k-VaQ7j2Jnw);)fDS3w?lGef^(#UvZaHv zqyw|0gR`ao|NkGgzA_T1i80CB-GwXT!k4g#ujT5Wvx#tX2>4AsSPzs+^mK6y;kfSF z=PlS^z~i!A4{?F@Hj zFEN^MP-UWRs7{)2w|armk1t$ypLBlSa4GPbx~O&Aw7pj=f9Bsa*GpyRXIr&X`47-C z)e_f;lF82)`K63?4UBaSjYAAgtqhETNZY``%D^B=`C#B=ekSoK?9#$@m2ZKjXn;&f zNi0dVD#^@EEiOsSEnqM*Faqi^(={>(F*LL?u&^>TgBZE2qGcIS4}+(xpUXO@geCyl C7H?7j delta 471 zcmX@de1>I$1SbbG0|SGGE`RVuMf>{F0G|+7jjE}}bN3s~*kv;Rpz-WI#PbgJLDpyDZqB6Od0{Qq7leq_sX6@FfnWkPbNuzSI)utPk>#wSp zPc)joL$h{<$$~@HTW-t87i&~cwcdQoWZnV8Y1>0`WrDM1f^%eovZVk2{~xY&WHtj2 z0|R4{x4Vm46vvFM6Q|47KVuc;Fk*3ku-gde$o-x!jv*44bthcRJ8Zz=%6RyI$;qs3 zWuKp|ojdu@fBkcT-6bU@>jn536atex^}S~K7_Io3IqTU=6aDq+*O^3$&uJXYalJR= zz_jn(tlgE4TUIyE(>Ii?w9wCxXES^LW6jc#t@^+7SpTRCPnuHbC=ks$v%YR`feKHu z*I9=Zck|Y6J-BtNK|(OEXHmG|H?06x=4Ng&5uHEmd%u@%c>8+cy~OwDZ^|7g%ZT2t z+<#a03~Okh@||W*#rB<{Q$I4w`u<~os>VM(Gq1b==oi%z*NBpo#FA92zopr E0NfS0vH$=8 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_blue_light_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_blue_light_gray.png index 86adaadf389510d46557699f84cb10daed9472a6..148a890eab2ab27da5392f8dbcf2b33d1fabbb50 100644 GIT binary patch delta 358 zcmcb}a*BC^1SbnK0|Ud`yN`kQ7j2Jnw);)fDS3w|jb;yStk@I~%&X z8aq1b|NsC0DY!fosDm-d+ueopc?zsg;2-5NR72SQ!{3DIW}k>i}uU%}>cptHiBA zxUTXoP=f~83Xq19%-q!ClEmBss2($2BZCk_Ln{L*3oAo2h%L)1T9yGdF?hQAxvX1SbbG0|SGGE`RVuMf>`S0G|+7jjE}}bN3s~*kv;Rpz-WI#PbgJLDpyDZqB6Od0{Qq7leq_sX6@FfnWkPbNuzSI)utPk>#wSp zPc)joL$h{<$$~@HTW-t87i&~cwcdQoWZnV8Y1?~xn!CH3y1E)WI~zJW>i_@$Z#bjg zZ7t9-j7i?^F6z4cE0lp8&H|6fVg?4j{UFR}!5XXr6l5>)^mS!_#wyBT#Nz&7w-He2 zpr?yth{R>p2@m~P3^`gFn*#F6Z7*1_4fEe!z3;#BEsc{;X8Wl9kzi2K(s}CW+3m?{ zYOi~G*PLr_KfaN2*m#>S?D z_YJ-k_85NqUHE1)bDi41J0JBezSWjJ^F8x`?^)BT6*J$RYzer0XV$40hxDL&#^;|) z_!mpZwRr=*qgvt`QIe8al4_M)lnSI6j0}v7bPY^(4b4IfO{@$otqe`I4GgRd48A+? f*Pv*~%}>cptHiCLO?LYMpaup{S3j3^P6Q7j2Jnw);)fDS3xAS*Pud8&xL>@W=*Jf}yR@lKGn6crc111B z-L-wy>-x|83KKkD46F^=G ST9yIzFnGH9xvX`?0G|+7jjE}}bN3s~*kv;Rpz-WI#PbgJLDpyDZqB6Od0{Qq7leq_sX6@FfnWkPbNuzSI)utPk>#wSp zPc)joL$h{<$$~@HTW-t87i&~cwcdQoWZnV8Y1{L6OXTm8$lW24w@V^tyLiqv@w}a) z6951Ix2(Fn7w9C$ByV>Y%~RW3RVGfCtAEBS%3;Lf{$RHeQ0l0si(`nyWz`9R!G{fa zn%^Ed)^~l{&E#f>gb8Jf|Nj@)W9Q%Hzx?t`M}`?eYUlhXsc4G}Y&~pp_Hts}ynZ!4 z&1XRqnmy+FPjQ$&eKXs}S<0`DI`loCVG=2!yJ9_;)%1$h??S)C+RtjPoz~J>t7DL~ z`au2V>6Wg?0=#x=7Gzz|&dz;tDN18P7fbp-v9wL60wkH6Wn?Ai)-70H`+D#Fcel6k zmHm+YQT%&Q7j2Jnw);)fDS3w|CjE-)XmQyWN@{ zc5AoVuG(U|>i_@$7g?w50%~GR@^*LO%DC_)Y~n|``sZvS+#CXaQxDbyrQ$tZ978y+ zyY}VsHW=`@mY*DNDuQ&%X*i1z)&qknZ(4!ozZ`f#uHZ zB%=u@mrk(twRtAoFJ4ge;|rTz+SI2RN)}7Iq88@v+P>;_{pWp!j0wDa`*rJfcmb_a zEpd$~NlC0PNwrEYN=+{d0G|+7jjE}}bN3s~*kv;Rpz-WI#PbgJLDpyDZqB6Od0{Qq7leq_sX6@FfnWkPbNuzSI)utPk>#wSp zPc)joL$h{<$$~@HTW-t87i&~cwcdQoWZnV8Y1?<%uit6EZoA!@ZFZ}-+OFDRxAy;k zq5t;{Ije#0VNCLNchT6pVe6)e)8*=)v5ImSvA93jZ3L7$?CIhdB5_%D!oeVBLmub1 zM~?OF-hHJ_jH%ISQ|kZ!{3j1Mem0Tng=guM*-XpJc5l75Y~9*crj;HA&-4@3R`X0XG&pf_;>DNJzg|?ouf6lV)~D>p z%pb+a_dk$G{*r93_WR8}$KF5|)k8WOicbv*yp#^qP?fc{Y}ag8WR zNi0dVN-jzTQVd20Mn<{@rn-h^A%-Sa29{QyhNjvE237_J-yQgCP;}(xr(~v8V(Nft UXp`N30H}e%)78&qol`;+0Qi^DKL7v# diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_blue_orange.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_blue_orange.png index 4ce74f8bbeba5447a69d74787a890a7a7886ceb9..293d56452c7af4821d4a09aeb40c45db48129a6e 100644 GIT binary patch delta 355 zcmcc3a*26@1SbnK0|Ud`yN`kQ7j2Jnw);)fDS3x4)JMd@1JtSj7Li znE!nt|GNVIPeuIy|NobMk@FR(k1@&H-Gy8J`jG=b4rhT!WHAE+-+mBgv|tTZ0SdC0 zc>21sKW7u+<`D3kdaxcSl;r8+7{YNqIYESlnUT#=O;sU4AVnY`At519L?j_aASr?2 zqy&>>S5uQyLfgUx3pOZBV7$gA#+YrMB4EPC?8qU{A@ShA)w4(U>RvtCnz+ilqg!0S zNQd|PsVJ#O&l&@mi`f`*ck=to-YYJi{FYH%%2?OHSl7@v#L(2rz!-?M4GgRd43d-& z22Pe^5|6?zEnHXm7U)=w64!{5l*E!$tCGyz)Z&uF+yVw810$dwGhHKt5JN*N0}Crd XGl-GPDq5BS^)Pt4`njxgN@xNAd^B&8 delta 467 zcmcb_e4Ay01SbbG0|SGGE`RVuMf>`?0G|+7jjE}}bN3s~*kv;Rpz-WI#PbgJLDpyDZqB6Od0{Qq7leq_sX6@FfnWkPbNuzSI)utPk>#wSp zPc)joL$h{<$$~@HTW-t87i&~cwcdQoWZnV8Y1_Y+2z)6K_*f+Hxme(Rp}@OBfltMv z0{{R2m!Ev!0q7*gByV>Y%~RW3RVL1otAEBS%3;Lf{$RHeQ0l0si(`nyWz`9R!G{fa zn%^Ed)^~l{&E#f>gb8Jf|Nj@)W9Q%Hzx?t`M}`?eYUlhXsc4G}Y&~pp_Hts}ynZ!4 z&1XRqnmy+FPjQ$&eKXs}S<0`DI`loCVG=2!yJ9_;)%1$h??S)C+RtjPoz~J>t7DL~ z`asO(>6Wg?0=#x=7Gzz|&dz;tDN18P7fbp-v9wL60wkH6Wn?Ai)-70H`+D#Fcel6k zmHm+YQT%&`8 z%1GD1RM*ff#L&dbz|zXlRNKJ7%D~{e1AoorL`HEn?9y$r+YbQ4gTd3)&t;ucLK6TD C8o>$x diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_blue_pink.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_blue_pink.png index f5146d9b57ac9b39e08c75c6a94b98f8cf7e65a3..edb7286beb74b5613a5229222a56961712193080 100644 GIT binary patch delta 355 zcmcc3a*26@1SbnK0|Ud`yN`kQ7j2Jnw);)fDS3w?B8U`qZ`ZeaG^T zoh#n9FMHFz^h4*0|NsBjJ$_>Z)W?|Q?e4-YfBnb-AcwQSBeIx*fp0$uGg`0)s{jSr zOFVsD*`KqCaB~RwO+8o-6iV`RaSY+Oo}3`U!pz9#sHUnAAdn&ukdTlNC?b-OB9N58 za8iOvva6}dDWPrQf(08CCNN%O6JyLaPZ2O-V|L__=a6`C;Og0`?0G|+7jjE}}bN3s~*kv;Rpz-WI#PbgJLDpyDZqB6Od0{Qq7leq_sX6@FfnWkPbNuzSI)utPk>#wSp zPc)joL$h{<$$~@HTW-t87i&~cwcdQoWZnV8Y1=<{ulm%r@_py>k6kO@b}W0-zVt(< z=!*aU|65Od`V{CS#w2fd7tK@KTU92`lB<8lD#~HR;{IT_5m4%=r;B5V#AVe9fx(9j zc$(iHIo5Z5+RfxS*v4^ zwE95I<>{8L#{#@|Y8GT&&(6+$aVbh;LKjQ=Ke4n;rvfCIn`LAr=hiJ)U;BFR{dc#w z@s<6M{ZagTe?t8A==;!-K)o)z4*}Q$iB} D3-`u_ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_blue_purple.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_blue_purple.png index 3c6f1d3c8bd1e7d77555a2bfc46b39ceaa3a39e2..e30949891edb07470ce88f1a5ebb8858d14c09e8 100644 GIT binary patch delta 355 zcmcc3a*26@1SbnK0|Ud`yN`kQ7j2Jnw);)fDS3w@cJk7OSo(Qe9T8 zy1Y21sKW7u+<`D3kdaxcSl;r8+7{YNqIYESlnUT#=O;sU4AVnY`At519L?j_aASr?2 zqy&>>S5uQyLfgUx3pOZBV7$gA#+YrMB4EPC?8qU{A@ShA)w4(U>RvtCnz+ilqg!0S zNQd|PsVJ#O&l&@mi`f`*ck=to-YYJi{FYH%%2?OHSl7@v#L(2rz!-?M4GgRd43d-& z22Pe^5|6?zEnHXm7U)=w64!{5l*E!$tCGyz)Z&uF+yVw810$dwGhHKt5JN*N0}Crd XGl-GPDq5BS^)Pt4`njxgN@xNAZ`?0G|+7jjE}}bN3s~*kv;Rpz-WI#PbgJLDpyDZqB6Od0{Qq7leq_sX6@FfnWkPbNuzSI)utPk>#wSp zPc)joL$h{<$$~@HTW-t87i&~cwcdQoWZnV8Y1>QGR+gx(C{kTkthS<1b!nmMl43Q{ z<^TWxSM$^VfW^%Jb!i2KL|No2YvGecpUw-+eBg2d!wR8THRJ6qfwjMS)dpR*~UcVZj z=Chy)%^q|8r#MWXzL{;~Eag{69r~WnFo~4VU9q0aYI?=$ccEWm?PoRDPHX9`)iFp~ zeIVxYbW7J`0bV;b3$m_fXXn1S6s0ktizWS^SlXsj0g}wkGP06$>lUo9eZBYoyW89N z%6`cHDE_@aA^v*w{q40I`rpZ3k#G%AI@2WN#A&+r&|^kP&q{`Oy8MUs%bc&BY``ck zWu$9hs%vN#VrXJzU}CkWnl2#fxl*QBBQt(cIh_R?FWG2!QkoY=d#Wzp$P!i CZ@*Rm diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_blue_red.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_blue_red.png index db4335541bd23e36ba31e2fc7f1ad6cc44040591..3cae33c64719bf76c4a637052946af8bdcb37e29 100644 GIT binary patch delta 362 zcmcc2a*la|1SbnK0|Ud`yN`kQ7j2Jnw);)fDS3x96xT%~nyIsiHVb zMRA6T;&f%j|NsAYiXMIj)Wn$N?e4;rap6nY#CLM_&)Gz{IRyNs9;^pSC3?CzhHzYW z?aSqDFyL{?*SNvU%*@U$cB-vGRYO5z2CK}2=|N0;{#E|nv82Gn=0>lVN)3z5UT21P zzCn^F5+`S0G|+7jjE}}bN3s~*kv;Rpz-WI#PbgJLDpyDZqB6Od0{Qq7leq_sX6@FfnWkPbNuzSI)utPk>#wSp zPc)joL$h{<$$~@HTW-t87i&~cwcdQoWZnV8Y1`+hD$Q0^nx&#RLq&0xs?z`e|NSHQ z%d&xvVNCLNcTv~nU!gp4x?KG;R#6Tk7WW6cjet^zJzX3_BrdB?I2goi$m5)Q{8-=a zXenpzMhEXryZ`_1OnI=NQmWUDolzk$$@1H-?Ohwf8?_`PVm2&Dcqsp3asJ-#8}o0^c(cL(&(6p3 z1wDqpHp)(}Eh{$=4{_}+;8$yrc@`G>jM-}PAMTew_}5AK$>{_Aqgvt`QIe8al4_M) zlnSI6j0}v7bPY^(4b4IfO{@$ot#}MgwG9lc3=FQ7j2Jnw);)fDS3xBvhD|L@Ymi~;JffGN<)jwww;pPzVn|iPwD3#>t;uykl zJvl*yg_)7fQB74LKp;gRAR!?^L?j_aASr?2qy&>>S5uQyLfgUx3pOZBV7$gA#+YrM zB4EPC?8qU{A@ShA)w4(U>RvtCnz+ilqg!0SNQd|PsVJ#O&l&@mi`f`*ck=to-YYH! z+NN6K8c|=8l30>zm0Xkxq!^40jEr>+jCBo-Lkvx=42*$D+rYrez#vKaU?5ZnL_=G=Nq>G?ZlKrWThZ<`zKpnCTiBgcusiSQ%JY8JadP0G|+7jjE}}bN3s~*kv;Rpz-WI#PbgJLDpyDZqB6Od0{Qq7leq_sX6@FfnWkPbNuzSI)utPk>#wSp zPc)joL$h{<$$~@HTW-t87i&~cwcdQoWZnV8Y1=0jiV9vi%sv%pJ7bc!yNgn6YRsC6 z)8*=)v5ImSvA93jZ3L7$>gnPbB5_%DLSXP=1D@u$M~?MfpLR33*&$&<+2a5I#r4?v zclj^B{L+zOMv&S$|4Ay^;sRR_o1DFz7&ot9jZgDg(1d1>x&Biercd9@wsDs7tD_Em z&u5rKO6aaw&t)~eV)eVwFR}Ksnro-Ebk^z^B&|LWb9uU@>#+c@otgz%*R!*8UtEgP zn9#+N{!c7z)2RSS=4KgL$+>k4*4Mt?d;i_-ZG2@vWPcR@-k%VEJ^KFk+712hWUolL z1}L3r5^~}+U3=&;qoijg!#iF6L;GdU*G|@D6qhp6H89mRGz&2_u`;lQ7j2Jnw);)fDS3xBnbh`F%|J$6@7P zN0q-FQvP~S`R5Vk|NsBb)Zl&()W?|Q?e4-YfBnb-AcwQSBeIx*fp0$uGg`0)s{jSr zOFVsD*`KqCaB~RwO+8o-6iV`RaSY+Oo}3`U!pz9#sHUnAAdn&ukdTlNC?b-OB9N58 za8iOvva6}dDWPrQf(08CCNN%O6JyLaPZ2O-V|L__=a6`C;Og0`?0G|+7jjE}}bN3s~*kv;Rpz-WI#PbgJLDpyDZqB6Od0{Qq7leq_sX6@FfnWkPbNuzSI)utPk>#wSp zPc)joL$h{<$$~@HTW-t87i&~cwcdQoWZnV8Y1{uCSNVNR<;M}_Uq@BG9a8>!Ncrbc zQI-Gy{|AVu1p=MKnB?v5qIqh2tIEV#a`n$xMLCRE+#l>V0!khAba4!kxU4!MF!-Bul6NbQ{eBo%FOfvty4&R$N8o7b<# zr}->sLbJzQ|0xdBr*CH4I7|7}QHQ?gGfW~SbXTnBvYKA8`d#RkSo>McwbNQUYjq5g zRv(DDJl)duSb*0~&4R4!+1a@-E=6ff=weC#CziJ9RDdLNvy80d+`0wpYhUlZ|L*oS zzOo;(KZ<|vPl&%BeSdrHhW>Z5S0r2ml+H8>IdPh#1a7p{(exPFnGH9xvXHg delta 461 zcmdnayn`M0G|-o`1r`Gs-p7p{F<7Qii*O@%EIE}?6R`F z#Kfq|$|7%XHybnPG!xidQ~Z`Pe{S)vuTGuRJb3Vw zqP@v;n`zH0_ZYmK^WSy9#lHffn43Mimu*>nOdq~j_L?!;vzDnnj%T*IOW0(f<5f#s zBT7;dOH!?pi&B9UgOP!ek*R|A6^>bP0l+XkKI1Z}0 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_gray_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_gray_blue.png index f579ae0f568965b8b11ba45662e99cd789bb9aa2..991a9fdb9199905c648d640585a4292ecb837487 100644 GIT binary patch delta 362 zcmdnQa*la|1SbnK0|Ud`yN`kDRkC|NA^y66;r`d(JtzuDh=xsxmS9#6{TuLD}9 zTH+c}QlFAol4_M)lnSI6j0}v7bq$Pl4UIz#O|1-!fk@lHz{$POb1v)ZhlH; zS|x4`!gZA(uWEp-0Bb18%uOvWNz5&P>M_$bG6*p=w30Tkurf4<*uucyF9g)Y;OXk; Jvd$@?2>^OVcGv&_ delta 449 zcmX@dyoqIk1SbbG0|SGGE`RVuMf>{X0G|-o`1r`Gs-p7p{F<7Qii*O@%EIE}?6R`F z#Kfq|$|7%XHy43W63I^m(;5d)rPVROZ^r=;HX1@Y~A`}h7Qr41>To9v#pcS>k1 zdU`g2HR|MpXz$$I>ic)C6rSvsPKF9d)3}XkT%@-EgFVnJ{(pFU9@%-GW z*t$&F*D=|$*DK{_cCYK%|N4*l+~X5{w3NHMADl|d5qzhZu!`}x!C6+F*}s^2Z}IGW z%pX?_^n+@NYeY#(Vo9o1a#1RfVlXl=GSW3L)ipE=F*LCt amQh>{yL6lE_5(ok7(8A5T-G@yGywn=qOXDg diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_gray_brown.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_gray_brown.png index 22f3e336bbba3f6a2b9d8a14978b570cd69b9117..8062a88be5741a7f8be1a9c00d21806a0dd78bde 100644 GIT binary patch delta 351 zcmdnMa*la|1SbnK0|Ud`yN`kgN%v|(o;Qta9C8eGu)ZI z#Aw1nm5H{YI%&e)>IFtWzHr%n()oGArNC?IqSkHG_Fk?0nSak*FO{92ZPiZYKS0Y= zOI#yLCZA&DuQ%2;FxE9R4ly*fGB5@rZ36=<1A`>xgMlz*DTyViR=N2pnQ4^_Mg~UM zH3-*Lz6EN~0GSKcP?DLOT3nKtTL9H#rfXynVrXb(U}0rw4zYxRzh8(4sENVT)z4*} HQ$iB}5BYO7 delta 449 zcmX@dyn$tc1SbbG0|SGGE`RVuMf>{X0G|-o`1r`Gs-p7p{F<7Qii*O@%EIE}?6R`F z#Kfq|$|7%XHy zeDm47FZi(OmoB~XY2Qv$rz>+JomqVCSz3yAE4w`GmE>2y{VtG^fBK;xF>YrIU#~4a zEPg5DNi>`D?OhAbES`KVKVPVmc@xis`XrnA$vsDtdl)#+I8FXHV^u}?t5XLRd!@C_ ze=fCrzR%*^-&K|`=lr+)x8U)rWcziMJJk=Lpk$9D(ttXsbI z+aI70R7+eVN>UO_QmvAUQh^kMk%5tsu7Rnpp;?HbiIst+m7%G&fq|8Q!FLD#8U}{R a@rC3w0xhHzYW?aSqD zFyL{?*SNvU%*@U$cB-vGRYO5z2FnFsO~$zYd+K6>ETrV#xTy-+G4WDsI#Xk{Q}VP$9zv4w%ZUkIp)!PC{xWt~$( F695hObi)7u delta 492 zcmX@byp?5w1SbbG0|SGGE`RVuMf>`+0G|-o`1r`Gs-p7p{F<7Qii*O@%EIE}?6R`F z#Kfq|$|7%XHyMPTU-9RC1dNRHjZ6&92~cwb_ukW zr`?&8v)_%`CdTZTZD&~hW1}khHvcI%Pk!fW`}SwSnc@lC^xq4$GEZXhFqH4NO#fw; z-oTQ!&~?9WXpIK%(+3mI&7HdY&jqV%JFi*IdtRBM_v`GB{pY5?wCPI;l8m(BT$gi9 z?4cafGN}Td%P|Kwt*q~p<=J)a^n6F4A5=?RBT7;dOH!?pi&B9UgONdmk&&)}sji_} zh@pvgTe~DWM4fMPau+ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_gray_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_gray_gray.png index 9b6bd3bcd1f141b9c286431398ea8d6947518ab5..cc693dca8a78b251a17a027284e1e3595b6cda5a 100644 GIT binary patch delta 351 zcmdnYa+rC71SbnK0|Ud`yN`k&f6gYt%^_$x>ElbFRE(#KV+hA}*S_0=4GKIg z{MrvTFm7Q!CMJ}_;I)8d?R^RNyMJ=z%!OI31m}b)3mY;w8Y(b;Up7N0rAYIMk8uCb zBad0{$k^>|nh&@HE6)C vD9OxCEiOsSEr9AV(={>(F*LL?u&^>T7lYWsz~3(f)WqQF>gTe~DWM4f2DEbg delta 447 zcmX@iyqRT!1SbbG0|SGGE`RVuMf>`+0G|-o`1r`Gs-p7p{F<7Qii*O@%EIE}?6R`F z#Kfq|$|7%XHyPGgeU! zBUXdw-AjN1TRmMILnJQiPPpjjY{=s*Y_51#*ZYQ>W^>u&|NAE`N_=@@Qu5P-E<7R^ zKP7EoTAT7=ajxv!3frBmiqUJ=Xf|CiXMAW8KVi{_gkx7v`c2PiSbq9o#r@u}&v%q} zJ!DR0`MI)b;YNFn&o7p|z3jZHz^RORiI2qg+Y-sevdWH3o3AX2U#4|$>aL<9uYwIl zC(O@UUVrv4qTWpX@0t3w>RWc6-#YKRsXR-#S@P);f5u>6i(N0{4wMDeGj`?ktYoNh zUNTvcQ9Rs8*T7WQ&@9Bz#LB?Z%FtBXz`)AD;JX8V4bX$CC9V-ADTyViR=N2pnQ4^_ ZMg~UMHMGfYKLFIg;OXk;vd$@?2>=(=uUh~B diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_gray_green.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_gray_green.png index 8951d7c55e88730bc05b2821de12ad034ea51407..0741dea8e5a4a3f2d17ea373041ce0a5776c6c8d 100644 GIT binary patch delta 351 zcmdnMa*la|1SbnK0|Ud`yN`k80;12lrd;vR=J|D$n&A7^5+|$2N@L`q^ElP;IOD_XSg$a ziP40EDidu(b<%{p)eDS%eBrYDr1SHJOM%zaMXlSW?Y&z0Gyk5sUMf33+p3+)e}I;$ zmbgZgOg_cPUvI2yV61Cs9Aao{Wnc_M+6D$z1_nvW2LoZsQW8s2t#b2IGSeynz{1MV9AXIrf4>k9P!ofvtDnm{ Hr-UW|QcQDl delta 449 zcmX@dyn$tc1SbbG0|SGGE`RVuMf>{X0G|-o`1r`Gs-p7p{F<7Qii*O@%EIE}?6R`F z#Kfq|$|7%XHyHq)J#aGsuL^ZnEI2>^h z^37-SzTm^AU%K?lr+qt3ovzG@bY}6jXK5+gt?cr!SCU`-_Panv{^^H)#JHU;e7&~x zu=u5nC(&%qw|6Z#vv~5g{CuHK=1n{k>XU5dC-)pp?qT3O<23o-j8zrkuTC9Q?3LCw z|GCui`96zte^*()ob%uE--5@hlI_=3?o>ZG_3RC$JI)8DF!$x{vP;OG9N!(lvu^p; zZ-0P3P%UwdC`m~yNwrEYN(E93Mg~Skx(24YhGrp#CRPTPR)(h91_o9J2Hzd{YZw?N a$1{qmVOP*5yZr#rL21sKW7u+<`A@;^zkK7D9O{sF@)oKa)Jm8Gb5X$nyNy8K#D*>LPA2Ih)6<;KvDw3 zNeL#&uBIlZgtmnX7Hm+Mz<7;Kj4|6hMZkoO*^xt@L*l`Kt7nhy)xCPOHF1@9N4L0u zkq+`k0G|-o`1r`Gs-p7p{F<7Qii*O@%EIE}?6R`F z#Kfq|$|7%XHy! diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_gray_lime.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_gray_lime.png index d2492ea3637bfa94bc4d2a8784ff286b6ef9af9d..610f1346003efed5d9fccb83ffc5ac749f8988ff 100644 GIT binary patch delta 368 zcmdnba)x<=1SbnK0|Ud`yN`k21s zKW7u+<`A@;^zkK7DBjb>F@)o~YhNyJg8`3AzQzq+W@dJ7F)zmhLL%NgnidE2m$Fp+ z{rs!YQ}Bh$2I*d(BRnj}8d&bkPBNNsa_IzHUz=yb{o(~hKfbWprA>XBp=7bND{5ix zuI;N{*MHtu$e6&(w_mqzhu7qbjN`k0G|-o`1r`Gs-p7p{F<7Qii*O@%EIE}?6R`F z#Kfq|$|7%XHy5O+0U>#Q*>Qjc;?y0_|r^@^*Jo)?!Y|v6?tt zuKpRTD2EZN!Sn7VK)KzXE{-7*msKZR^kX*UVR_rz`?#e$)0?C9&el8s>s16JqRyU@ z`gzcWN9E#|qzx=*Q$7S;pAr>kzTK^3mT`8+f|s)!0`$ULH1-%iewK3ERO`XRAc^;< zS6J%p-J18qL8`arbV5e7_>{_$OTS+FDiu0RW2_JA`CZ$yu}E6kfob!FCGpF&?oHiQ zRN(RW*eTzAneRT&D7Kq-e51bKugD+S&+A{@`F`A{zqnBEyJtbF@iva{0tQbT7SCSC zf8*AZ_$lE$H=ju9tpfT(wZt`|BqgyV)hf9t6-Y4{85kMq8kp)DnuQpeSQ%Ja8JcPv n7+4t?IDU8FuR+m~o1c=IR*73jo9y-jKn)C@u6{1-oD!M#e2FqhHzYW z?aSqDFyL{?*SNvU%*@U$=H+-mNQ6hz;(-2AmWsche-(NPzHr$f-RpCNhvirU%bnRt zMiWjhonY&0^Gvv3yrAgE7dE@JsZTSMES7dfEzI4uebwvw&-)4)6L|Ud>(=e?0$Qb7 z;u=wsk~sM~Bd?UPu7Rc?zsg;2-5NR72SQ!{3DIW}+{EtyQ3cIv$UFBP#IT{di zN>Z&#GILXlOA>Pn7>o>zfO^byjSNBz4Xq3;tPIT|Ml$gC3jy^oc)I$ztaD0e0sz}> Ba>@Vz delta 471 zcmX@Zyqjf$1SbbG0|SGGE`RVuMf>{90G|-o`1r`Gs-p7p{F<7Qii*O@%EIE}?6R`F z#Kfq|$|7%XHyTcTtK>jaf5sx?KG; zR#6TkR)go=OMp_lJY5_^BrdB?c}>Y>Cg@M|D?r-8yIW{{JL1y_08mDysi! z=x9`#b&qG-f|)$~rkY0IyjQ;6t7DRJcE^HO?F}1Z*Kq_^q#iqa@>{mZfy1fEccupx z#YC+=`=RrS_Ro0-FYMCOD9&H<^z>?%M-4j6^-Es#yT7k}dab&FC2gVSe&5hNnx;=5 zOgJ@l>gqoiW;~WiKJ&cr%u&bv-2dO!w4SqkZqZ*{sPo;kAk}yq$9DmPrwxl|uH(OP z>xuouPM$O8A6nl6dPB9uHKHUXu_VKdAb7@AlaSXvpHY8x0> l85n$baNw^&(UF^KkD46Fzm7AZEnO4bQWMG6{gK%BtTc8FFxQ3F<+|=Td#M}a?9y47dgAhYQ cD+3EFLvx5F4E+5zopr093GYTmS$7 delta 439 zcmcb_yq{%)1SbbG0|SGGE`RVuMf>`k0G|-o`1r`Gs-p7p{F<7Qii*O@%EIE}?6R`F z#Kfq|$|7%XHys16JqRyU@ z`gzcWN9E#|qzx=*Q$7S;pAr>kzTK^3mT`8+f|s)!0`$ULH1-%iewK3ERO`XRAc^;< zS6J%p-J18qL8`arbV5e7_>{_$OTS+FDiu0RV+;!F`CZ$yu}E6kfob!FCGpF&?oHiQ zRN(RW*eTzAneRT&D7Kq-e51bKugD+S&+A{@`F`A{zqnBEyJtbF@iva{0tQbT7SCSC zf8*AZ_$lE$H=ju9t(t7WC@y8BYhbEtXcl5FVdQ&MBb@0HbHMdH?_b diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_gray_pink.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_gray_pink.png index 950c27a0d0a8ce39bdecb2262c0a9d4d1188d880..2ac56b23f9de396c14fd3fbd8e7132be231e99cc 100644 GIT binary patch delta 374 zcmdnba*26@1SbnK0|Ud`yN`kAc^&9L@rd$YKTtzWpG~Xu%q+0u*E~ z@$_|Nf6gYt%^_$x>ElbFP?D#MV+hCfG~gOaGILXlOA>PnpnA-7jSNBz e4Xq3;tPIT|mN4-53-JIoF?hQAxvX`k0G|-o`1r`Gs-p7p{F<7Qii*O@%EIE}?6R`F z#Kfq|$|7%XHy!2~cjgr;B5V#AVe97yXzGd05`|_C9Xu&h+MJy|eYs|9Ta{h^Vut zq<$WB;ZeExC20f8*_01K*QZ3qnQwRNm}Q*ZvEb$Gh5)_r7L7fIkDsO7Hr0CYFi7J4 z=@piGd$;EOaFFV)Ih~LZEk32P}cX|KE~-H3F!QG0EHAg#BBOY{v95u!uAy;=p{bRDF%W4R7+4t?Bq<*Z z1iD7G#5JNMC9x#cDmOnRGp&-r$iN7@2I0EOw?GXVa1AAyxv9k^iMa((J!ZN_1|f!q dRt6SUhUO4U82I~zcz~K1JYD@<);T3K0RWTean}F< delta 439 zcmcb_yq{%)1SbbG0|SGGE`RVuMf>`k0G|-o`1r`Gs-p7p{F<7Qii*O@%EIE}?6R`F z#Kfq|$|7%XHyNM> zT>UdvQ4S+kgXi5#fO5M%T^vIsE~`$s=*Mix!}7Mb_i;;irZ-3HovnBN*Q*FdM4de) z_4A+$kIKa_NgG(srhEvxJ|!y7e7jr6EaU8s1uthe1n7mgXzVe3{4C|Rsn&ysK@#sz zudvkHyEX5JgH&(L>4c1E@hO!hmwvtURVs9t#uyaT^SicZW0AD71JmXUOX8Pl-J80r zsKDd#u~WYLGT(ikQEWHw_(pxdUy(nupVz;*^ZmF@e{rGSch7=U<82(@1q_}xES|lN z|HiE+@l(QiZa$IHTQ%8$QC!MM*T7WQ&@9Bz#LB?Z%FtBXz`)AD;JX8V&E!NzaW(AH UZL-@B07HSn)78&qol`;+01%k99RL6T diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_gray_red.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_light_gray_red.png index d5a9a2e77cf46d90c8e6c669bece7f0031033c2c..ea08fbab54079a95920d895c6281d57160519824 100644 GIT binary patch delta 362 zcmdnNa*la|1SbnK0|Ud`yN`kB@@#|Nq~&Pt_l&i80CB-GwXT!k4g#cjW4yvx#tX2wG11_!20U=;`7Z!g1ZT zFPFE$fX5|Y;|4D?Gds7~skR1H4F!!EtTGR#2QlsWSNV6xk^&Q(8@*mCH7qiFof+Qw z21%Ysm~>*Eme}Ubqrw)FHC3$g#nXy%lq{BdU37{*eJ?BS-|X+b+{qPuk0)jF*8we4 zEpd$~sZU8PNwrEYN(E93Mg~U4x(3F&hQ=X=rd9^VK%{M8U}a#CqPnpnA-7jSNBz4XvaNEUXO8A+|8^_X`0vF?hQA KxvX`+0G|-o`1r`Gs-p7p{F<7Qii*O@%EIE}?6R`F z#Kfq|$|7%XHyn8I!!-T@;Vx@QMLB6K6@+KVuc; zFk&@$-n|4Uu*=iMF+}3B>V%7VM+`Vv5_yjv>3wVv9?+ZR`_fO4QoAZ8mw5rR=nWioQU!5Ip@j-$Fy*%`*MoeSVLF3or>k$mQ}#j{5XiXX0z{l75#oaMU5Q8K4(IoIVJ6MHDfv`nVJ=-Gdm zCMfY7tv|PQGSC~UC9V-ADTyViR>?)FK#IZ0z{p6~z*N`JEX2^n%D~df&{W&Nz{QYut8x0<25!h#%%Kx z0TVW6M-F)oi3bO+o;|u(_v+Es#8uuM-Qog9I=tUcMM*t+))>HC%*K$rliy$VUU4zd zHq{c>h{;zO1*D914UBaSjYAAgtqhETNZY``%D^B=`C#DW|BT{M*rkQ*D&GPP(Eu7! zl9E`GYE_b%n_66wm|MVLWMBl;W2S3l5MpR(Wnf`tXbv%wfxlk}sE5JR)z4*}Q$iB} D%zSdV delta 418 zcmX@lyoY6i1SbbG0|SGGE`RVuMf=Fi0G|-o`1r`Gs-p7p{F<7Qii*O@%EIE}?6R`F z#Kfq|$|7%XHyN9&!fcmCI_2u4JmJtg(?pbL-6#V<)4Sk9(=2)aHcD$abn zTgNQp?2ZL5XEy}sg|}$zF?{?i<+iETgNH#9?@zC=)Z4o??}vj_Z_Vk1jA-#Gl_i&c zz4TQobeP5%6x8#(wr69Jw6X)!<_k;WmucObx~r(bh&e9Nz^Do;EC=y^jCJttatQ!g+2!k>S5uQyLfgUx3pOZBV7$gA#+YrMB4EPC?8qU{A@ShA)w4(U>RvtCnz+ilqg!0S zNQd|PsVJ#O&l&@mi`f`*ck=to-YYJie34PS-dNYbSl7@v#L(2rz!-?M4GgRd43d-& z1_E89TH+c}l9E`GYL%Oxl9^V?U}Ru~U4w94`k0G|-o`1r`Gs-p7p{F<7Qii*O@%EIE}?6R`F z#Kfq|$|7%XHy9#Z~!ROSEw|5022eFWOinB?v5qO8T7lw&n< zmR$WaR#6Tk7WW6cjev5yJzX3_BrdB?xah}h$iwosxA$>NccwQ->z%E4{@1GrMns)G zCH3>53y;dhFG(9%&Zc|_x;`Z;&V0LD$1LOQjs-7gHw5T~w`lA!eEclswyD;Ghd~nW zPp`1l+q*UIhl5ma&FO@UXz?kPC6|7^^i?W!n8p|s)bqQxXJe7HvIEoR3rpgcY2BN; ztEj-^@v&3B`!e5so>6Q!@AyW2zh99*vY*$#xbywEO@DEr-gnP}RO4+N-vtbwHY}dK zj{nB3C-GCld2T+D(pxpzfKgn^NY}tr*U&7)(8S8X(#p_O+rYrez~H+Bf6e4XMsYRl V(rvQa4*)}f!PC{xWt~$(699lcxTq5dSCy>8eLS9~3PEP6n|NnbD zoHc<88I!!-UDy)ScGOP1FIWGZO@y06z;EiodZ1L8r;B3<$931fi-HXX9L~Y&8LybG z@>Z>5ke>24Jo8BK{p-pTtOI6*6j-~eXR&i-J2JmJJ3%JJTk?sY=QX2~zZllHoY(pA zFi$SAZ9`^}r^bwT|IhwD#^fHy$2f22-5Q_`swJ)wB`Jv|saDBFsX(fp!N|bKSl7T< z*U&h`(A3Jn7>KkD46F{90G|+7?|Om6#iDWZM3R<@#xE32SST7jQzUM_ zh;O4{!Xi=Y6kgjjUYk^2n-pHlcpmFy-oz!M@e4$K8U(y*1@d-Ev2#S^<(1{-mE`1<{{R2ax#xl`&~nBkZ+91^*wmOc6T9W= zpRtN^7_qoN*lh%q+T!Wr7$R{wbV8v25d)rPVROZ^xsNB^c3db^^80`NB(5XO)7HE{ zyUF*6gP^Ye43o7ipHFXEb2|0zy!CwwPolK5yCPorI&6Epd+CZwgWGpGuiJ_@FF$?k zTT)8)+3R8#6Y{^^YyPviX`!L;l%3|6o<38Iw5azD*fnvHz1-gKFRR~Ys<15)``far zA~@^RNzH=?PbtQm9J5$Tq5dSCy>8e!q{}Sk;yD0lNm-P zGYyTW8yZjh|Np-Rmq-&(6JwIMy9-ywg)d=14rhT!WHAE+-+mBgv|tTZ0SdC0c>21s zKW7u+<`D3kdaxcSl<4W=7{YPgwJ(>q!GOmlU*iTZGc!B4*r~P#RgHQDjTx*m52gn( z?fF;vcgK-u ziavcWEAHRy@4ei~6?~5;W%AbnZBs3AjVMV;EJ?LWE=mPb3`Pb<#<~W^x`xIfhNe~q z#z3TPU|?lnkfeMtkf8usM{a&fW?Cg~9l~{$Z-G{5z^y3B%uOvWNz5&P>M_$bG6*p= cv@)=;GBktOvaF(I8Bh;{r>mdKI;Vst027^fi~s-t delta 459 zcmX@de1K(w1SbbG0|SGGE`RVuMf>`k0G|+7?|Om6#iDWZM3R<@#xE32SST7jQzUM_ zh;O4{!Xi=Y6kgjjUYk^2n-pHlcpmFy-oz!M@e4$K8U(y*1@d-Ev2#R>O=laM&N4EYX=F0}|Ns9DQ~cC`_A@4VySpfBF(>6% zO`I-Q|BO|X!-&QG!EPg<+#XLC#}J9jsuLRX4jXW|G#)VU-Q;xn>fGyR%l`dWZZ}(U z*;&1Xk6}VaV&pxIl|c2~HXd zmrYf%pYU_%A0}HXK4l|&_N_pVsFt`!l%ynTq5dSCy>8eqR3sN&`rI-RXyKT zJa29w(7BevL?FV5-3)Wy2pdfpRr>`sf zb2brf4gtTZ2kU`CiJmTwAsp9T`@97k40v3&YrGI+W@VSvSz@qPoYPmvpn+NCioPPx zhoZ`#Z+sqPRBVu*>hXiaqN<(Y&g>;d6Ar3Ov<=ls6Yf?oF#7R@%kGoT&l@fUUQ-vf zZkx9EYUR)Td**tn?EGx2b}Ijwe1TD1%2?OHSl7@v#L(2rz!-?M4GgRd43d-&22N&V z5|6?zEnHXm7U))u64!{5l*E!$tCGyz)Z&uF+yVw810$dwGhHKt5JN*N0}CrdGl-GP TDq5BS^)Pt4`njxgN@xNAMA&d` delta 457 zcmX@dypLsq1SbbG0|SGGE`RVuMf>`k0G|+7?|Om6#iDWZM3R<@#xE32SST7jQzUM_ zh;O4{!Xi=Y6kgjjUYk^2n-pHlcpmFy-oz!M@e4$K8U(y*1@d-Ev2#R<+%*c^)C=7-@?F*c|NkF^1_*?ecVS43W63JApCpumOiF<6(o+O-`53&AxuN@Ll~0%czO- z=Iv_{U}$jZRNZ@Vix*qa?kSt5oZhrAzE?(L+MK|q$k;re1+TYdZdhTt=pOHjU9N$f z4B`UixpqDIvEtp-FTwj~HP@y)3C$N~*%&&Z$oRR3ME$8Lvzh{`?V__MS7$Fg;3YEY zNxRF9RSu#&JY^*!CI4FQ{kD@lUbm{;;@9e9_6B~vwR0-J$t_U(9JhpHbAr=}h0CU< z)Fr$-|C8Tp1E0hz;iUyYZ>W~IMwFx^mZVxG7o`Fz1|tI_BV7YiT|=`FLlY|lODjWD mZ36=<1B36(4*WHfV;RNOu*Tq5dSCy>8eLac3~XzK*g=04Gu ze$l4h|NsBT3r}+g>R?Rrc6Z_Ycys9+AcwQSBeIx*fp0$uGg`0)s{jSrOFVsD*`KqC zaB~RwO+8o-6iV=PaSY+O?%J2j+hD-slCN=tmzkNJTkKR@gQ|vt#*BKF3%;6+asT(! z#ROSM$-Qw?6|!UMyQj$TU2P>#ih*Z}zi9W(Bab-e@YwBb>bLZ^G#8W!TAHzNZEC)$ z{{OSTkFh3t@Li5L`2HWzGSw2-h?11Vl2ohYqEsNoU}RuqtZQJbYiJx|Xli9(3`E)n z237_JNy-NU!5VU4I&$+kzK1d<)c}0k@(gGdH!kBr&%Ds>e*%$RNbf(8|EV Y%FqmA%d(1=Wk5X)p00i_>zopr0Q|3adjJ3c delta 506 zcmX@be3)f|1SbbG0|SGGE`RVuMf>{v0G|+7?|Om6#iDWZM3R<@#xE32SST7jQzUM_ zh;O4{!Xi=Y6kgjjUYk^2n-pHlcpmFy-oz!M@e4$K8U(y*1@d-Ev2#Sk+9ry%P7rJ97j5nnZR-91|Ns7N;`4w`U`+CMuXj<| z!uE3}kjGiz5n0T@z_%ZS87)|YRe*x*C7!;n?9W(5IgD7`AM7>)3hnW9aSV~TtU94F z@2~-f3*%vf(oIg6&&|Gm*7NuO{}x-6=E_+qmM}E9v@YEf7_^jW<=m*~TbYsf&%5!7 zc(2tsxJFN0?Lz5olZY!af$Q1oOYSYwjFecv!kjfWtES|;->;SNhY#-4R_uJv<|re( zB=(FYSDVq)g$gF`z8ku|vU1bdAk-@IQ&Di6-UU|XW?5O*x%G+fKF=tA*Z=s&WZ`+8 z|KC+`_SK%BxyD6`KVb46am_% zsaDBFsX&Us$iT=**T7WQ&@9Bz#LB?Z%FtBXz`)AD;JX8V4NM1ELvDUbW?Cg~4Q;a9 R4*)eVc)I$ztaD0e0ss^zvETpz diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_lime_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_lime_gray.png index f0e6b7c4a531f28517060b6d8089e36b62c4eed5..d143589cf77407855bd418d35bdeab60a1467aef 100644 GIT binary patch delta 377 zcmX@aa+rC71SbnK0|Ud`yN`kTq5dSCy>8e!p_Of*3s40!NtbG z<^TWxa~ZW*fXW$@yxm#lvb1sfE2SopOcY+&5Nd`wIzhrw$B%i8-A?sx0|{v0G|+7?|Om6#iDWZM3R<@#xE32SST7jQzUM_ zh;O4{!Xi=Y6kgjjUYk^2n-pHlcpmFy-oz!M@e4$K8U(y*1@d-Ev2#T1oZM_3UF{rQZ5>=}99;hY|KGc8**2gP7?Zr+*<4h% zu>G7laiU!PGgeU!BNq1uyN!TyyFFbTLnJQiPPpjD?8xEzQ18TryIU`WxgUS!bNl~) z_v0axCVwuNEZxx2=vq>Fa7(7*4EbxN(fqgnRh6(PZV!qGKH}uhwCQinHW5?)wA~gD zE6!bg@N(1Uy^=S>KJ9f2xzS#`P2s;*LdF@k)V!%Bwv`@wL37k1W=&iayMFD~lS{Xn z2r&nV|7}}U5xVNsNzH=?Pbu18sg|F7yY|n@@~SWYCH*ssUMJgpzW6?6-RC&BWz}3W zyk diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_lime_green.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_lime_green.png index 9c1a05b9893f3144b2f7eb54f11301b823beb71c..abcb44a8943b93e3429559bbe461f377ac059236 100644 GIT binary patch delta 351 zcmdnTa*la|1SbnK0|Ud`yN`kTq5dSCy>8eA|zKPI7d1tTRJF9 zIxtH*I9vMv|Nol%BIW}%F(!GtyKrS(_!0)>a29w(7BevL?FV5-3)Wy2pdfpRr>`sf zb2brf4gtTZ2kU`CiJmTwAsp9T`@97k40v3&YrGI+W@VSvSz@qPoYPmvpn+NCioPPx zhoZ`#Z+sqPRBVu*>hXiaqN<(Y&g>;d6Ar3Ov<=ls6Yf?oF#7R@%kGoT&l@fUUQ-vf zZkx9EYUR)Td**tn?EGx2b}Ijwe1TD1%2?OHSl7@v#L(2rz!-?M4GgRd43d-&22N&V z5|6?zEnHXm7U))u64!{5l*E!$tCGyz)Z&uF+yVw810$dwGhHKt5JN*N0}CrdGl-GP TDq5BS^)Pt4`njxgN@xNA9;k0@ delta 457 zcmX@dypLsq1SbbG0|SGGE`RVuMf>`k0G|+7?|Om6#iDWZM3R<@#xE32SST7jQzUM_ zh;O4{!Xi=Y6kgjjUYk^2n-pHlcpmFy-oz!M@e4$K8U(y*1@d-Ev2#R1a%Ft&%t<*` z6Q|47KVuc;Fk*3ku-gbIx69MTF+}3B?gYlX!v-9#jE4$UbB4hJ>7QEh;xnYInqIBSG_uEeLc-^XUi(jjc*&F!v*3PN?CbvNCbKDY+%?VB?7A~8b zQkU@V{7-(X4SW)>gqIcoy`fs-8c~vxSdwa$T$Bo=7>o>zjC2i5bq&oz3{9*IEUgSp mwG9lc3=F diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_lime_light_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_lime_light_blue.png index d19d37d6a50df8e4777d26d16c7407f619caf4c2..b4c151c28dade66382640e615b0b700cb846e7d0 100644 GIT binary patch delta 335 zcmX@ha*26@1SbnK0|Ud`yN`kTq5dSCy>8e!g|YXtIfBpHeR>d zbklPERm=5PtTx{G|NnpQqJsNCeT+%o?k?Q&*N+^S_*$<1IhzPKhk)PIgY`hEBu^K| z5RU7~2_h`ajBJi-stN%DDFOir2?-)12`K_e2@EGCm?XQJnw%2a7A{z@L16;pH8wHE zZ1WTW6Ee1H3Ro)%l;sQoGyx&hnNj-Yj7{FZ2#*n*{-(U7# zaWT*~)e_f;$Ob9jCBo-Lkvx=42*$D+rYrez#vKaVBll{Ch;ij(!zC>Z-Itr z01YWgNi0dVD#^@EEiOsSEnqM*Faqi^(={>(F*LL?u&^>TgBZE2qGcIS4}+(xpUXO@ GgeCy`-EC(8 delta 453 zcmcb_e3oT`1SbbG0|SGGE`RVuMf>{F0G|+7?|Om6#iDWZM3R<@#xE32SST7jQzUM_ zh;O4{!Xi=Y6kgjjUYk^2n-pHlcpmFy-oz!M@e4$K8U(y*1@d-Ev2#SMx7@bge9LO%4eQM}tu|b+#94Cn&saq{j9A^1^A@_?s{V~E6M)d?4a4m)tTHnK*}I^q-@ z8@qb;mb3r=FY2+IV`+0|Co_XWV4|k}l(3Z!S<5qLEx){H&%9n4jb~ATO_8yBJ_}Co z%G$8Pa#0-bi#^Adq$KWHuutcfatSn(& zShxG@y~)|{7as5u33@Wy<;E-rVIH2c5|NUBjT?JwdkX8{{GKNF!RN2Tq5dSCy>8eqNk_1ySu5gv!Sc2 zv7@8@|Ns9f>*mA*bucD*ySs3Hyt(uZki%Kv5n0T@z_%ZS87)|YRe*x*C7!;n?9bUm zxH$y;rXH*Z3MF{DIEHXsckRpNZ7|?*$=A5S%goHqEq1D{K~+ORV@5s81z%0Zxc__V zVuCEB#dnhVMVEzMZCHZ|W= z|Nq(F$5<0R_%25reE$zWDsI#Xk}nw YWoQPmWm!ebGN2v?Pgg&ebxsLQ0L4vuSpWb4 delta 506 zcmX@be3)f|1SbbG0|SGGE`RVuMf>{v0G|+7?|Om6#iDWZM3R<@#xE32SST7jQzUM_ zh;O4{!Xi=Y6kgjjUYk^2n-pHlcpmFy-oz!M@e4$K8U(y*1@d-Ev2#RvdYZeto4UFhJ3AXXI_m%b|34$c%n9fO#w2g|dKZ-~ zY(HlLd7K3vk;M!QeEUI|(SkKt1t`c~;_2(k{)|l}0#}J9jsuLRX z4jXW|FdjB2-Q;xn-0bUTJ%9iIZ?Q#buAG%(2}6TR>(V`eK}(rd&W(z`l^J>eyc?g0 z_gamEYxKm`E|lIjiMS#YxSp-Psb|Laib{6$Q8HU0`KymX&3lTc7yu^Niwm{f}=<7M|Dn z|6K)VU+wvsYh0xG119eg*F2;%Lm+EKrus?#l)82GwzYgJ|Gge_06n5w;u=wsmXcVK zYL#4+3Zxi}42+C)4NP?n%|Z-KtPCuz3{ABS46FmdKI;Vst06lE8OaK4? diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_lime_magenta.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_lime_magenta.png index 91cc19413e9259291dcc97f55cf57807349d4894..392f032989cffb5379ba4aca782f090675aee347 100644 GIT binary patch delta 360 zcmX@fa)x<=1SbnK0|Ud`yN`kTq5dSCy>8eVwe5;op$TC+pXDQ zw|1-Tsx7vw{{R2KNMvgbP!nU4x4R2h#)U6o6JN;HKW7u+<`D3kdaxcS74PZd7{YPg zwJ(>q!GOmlU*iTZGc!B4n3v-LArT%;iv#*gSt|a1{#EEH_`+p_bg$159+qPbEO%xn z8BI93bb_s~%`@SC@q(fsU)b!@rasM3vRK*`wJ>+r_EoRzKkqAKOyK3)uUogn3uu*U ziEBhjN@9IUs#S7PYGO$$gOP!ev95u!uAy;=p{bRDF%W4R7+4t?Bq<*ZMCbr&$jwj5 zOsmALLAb8+El`67#0sE>lFZ!H;*!MN0;nD{T_b}KLqjVA3rQ`q0G|+7?|Om6#iDWZM3R<@#xE32SST7jQzUM_ zh;O4{!Xi=Y6kgjjUYk^2n-pHlcpmFy-oz!M@e4$K8U(y*1@d-Ev2#Rr*{|PezizwTnr(Kgx7x1SVYl}G|NrlKMVA6y!N{59 z?e3y_nDHe4#OZSN&saq{j9A^1_*?e}zX43W63I^kjvvmu9TV?#^Yb*Js7QmapH z`~ClZ#xc7&mNs{GGBYRyCVA$Ytew<&#c!$3(=BV>rz^8}sisd!2%F9={9;$GlulOP zig0GD{J<$XJ>geoH|bg0t*Tc2du9Ezg!?lm97%6h*v1v4_e_Sf-g#zFut3)L>g?R2 zTwRffPNzwKCU8WHu4rmJ*w@!|ZvO@M`_=CsZ+xG;>u~X_daJkthR0qUuk-mnv$kQ@ znd*s3XPP(_+h>JM`q{YC{<*!wOFpy2S?()UftDnm{r-UW| D0JFGF diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_lime_orange.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_lime_orange.png index 9ffbb10fd5a9f3b7a38f055eb66b42a216b94f8a..8f53cf7166499c1353225901181d0000fad25b7b 100644 GIT binary patch delta 335 zcmX@ha*26@1SbnK0|Ud`yN`kTq5dSCy>8e;%kY(mty{pMf{(O z`QI1vzboMXRK)-P|No4qn^S@M7?Zr+UAX11A2~4bwOsvkHW6+P0l%pS>w!{9o-U3d z9M_W*L|B*^*&NkW6#@iO1OgHg5=2B2QUsC`7*0wsNp>|gIVH3$T(Dq+!UV=^Y+{Vr z<|zUuY|M@v@*ENm4qQEZbg%B!qpgXnygRzZ1&nlfzn_Yddi1O@fVr5BA$KRgzwEu@ zVxVoRC9V;ZpD_wZ8S5Gt>lzw|7@Arc7z2^Efq|8QL6Y*pz{vtk;!)V8h3hKc0u9js z8d8#ySdwa0l9`)YT#}euz+hxx1k_`uYh(~&XlP|%VP$9rF>+Z&%QB!I22WQ%mvv4F FO#pT(Yaajr delta 453 zcmcb_e3oT`1SbbG0|SGGE`RVuMf>{F0G|+7?|Om6#iDWZM3R<@#xE32SST7jQzUM_ zh;O4{!Xi=Y6kgjjUYk^2n-pHlcpmFy-oz!M@e4$K8U(y*1@d-Ev2#SemI!<)5%^dn@VQvveWAd+LV-`k0{{R251jLC0s{{N z17ni6yNg;B$BeBLXUWw+V-@8vVsU@4+X(2$1D-C9ArhBWCtM6V?7-pL$Qn88h*NNE z?CRND&i?~kN560zr_Fd4d1s=PEQ+YmW}2UUM8Ij3^$mvvV?VE z-R`gVCTG82c)&{}=*euC8?zjQd3ef7L`wcOZtSh?DXf3Tq5dSCy>8e;&b<^PhBhDcP#(d zx#Dg6vN!EZKXk76|NlSlJL5$_eT+%o?k?Q&*N+^S_*$<1IhzPKhk)PIgY`hEBu^K| z5RU7~2_h`ajBJi-stN%DDFOir2?-)12`K_e2@EGCm?XQJnw%2a7A{z@L16;pH8wHE zZ1WTW6Ee1H3Ro)%l;sQoGyx&hnNj-Yj7{FZ2#*n*{-(U7# zaWT*~)e_f;$Ob9jCBo-Lkvx=42*$D+rYrez#vKaVBll{Ch;ij(!zC>Z-Itr z01YWgNi0dVD#^@EEiOsSEnqM*Faqi^(={>(F*LL?u&^>TgBZE2qGcIS4}+(xpUXO@ GgeCwbhHpgx delta 453 zcmcb_e3oT`1SbbG0|SGGE`RVuMf>{F0G|+7?|Om6#iDWZM3R<@#xE32SST7jQzUM_ zh;O4{!Xi=Y6kgjjUYk^2n-pHlcpmFy-oz!M@e4$K8U(y*1@d-Ev2#Q|cdz=?weo%E@{e6B-*zl})4udW=ZgRT|Ci3YW6Hq8 zz`&T~?e3x$#W7>+#94Cn&saq{j9A^1^A@_?s{V~E6M)d?4a4m)tTHnK*}I^q-@ z8@qb;mb3r=FY2+IV`+0|Co_XWV4|k}l(3Z!S<5qLEx){H&%9n4jb~ATO_8yBJ_}Co z%G$8Pa#0-bi#^Adq$KWHuutcfatSn(& zShxG@y~)|{7as5u33@Wy<;E-rVIH2c5|NUBjT?JwdkX8{{GKNF!RN2Tq5dSCy>8eqC{sNG3IPHs0s#pL2_hm1DFR6e3@0U+B)giLoD$j=E?BTZVFKedHZjI* z^ArISHfBc-c@BvO2dxt=(bmLO-W}cI0!BK#-%mwJJ$lv{z+BA6kh_!LU-n*c zG0-;E64!{y&lm-yjCBo+bq$R}3{9;JjDbkoz`)ADAW8XP;A8G_*3Xurf4*7`d#XWf@QpgQu&X%Q~lo FCIAVlX!HO8 delta 453 zcmcb_e3oT`1SbbG0|SGGE`RVuMf>{F0G|+7?|Om6#iDWZM3R<@#xE32SST7jQzUM_ zh;O4{!Xi=Y6kgjjUYk^2n-pHlcpmFy-oz!M@e4$K8U(y*1@d-Ev2#R9)K-?Ltte7mR;;$7P<3gc>XKr$<^TWx&v$sy#K6PA zz?kIi?xGgOF=Ok*S#tHySVcLESll1%HUc{GfTxRNh{R>p2^WJ7J8-x*vPRB2;uIVk zyL$GPv;Y4u>am++X>(^MGlN24qNe_ou$2y3%QI&!zr1J9yj~fNXHkJok+FI{3r_FK z+OWcMQ5^4!J;#=$B<@+TPxD30Tq5dSCy>8eVvefPY!$_sDvGmI z6lbU?PFGg^|Ns9lmPZOeO^iw2?k-#z7rul6Ih+L^k;M!QeEUI|(SkKt1t`c~;_2(k z{+vyOn?t~F>cM)TP@<=cV+hA}*S=id1_K_Ke2p8t%*^cEVyD^~R5j`qG-j~MJeVHD zwC7*t-yKT|Ol)rSda2Z~$n14yc;_1=c_LxbiFsOLn>&vRTS(SavC0=uE6P!_Sn74r zDf;xithj%(zxQ${SMWWal*wNQv`w|dHKHUXu_Vlzw|7@Arc z7z2^Efq|8QL6Y*pK!yTj9l7}_nQ4`{bqLp0z6DyL0k@(gGdH!kBr&%Ds>e*%$RNbf c(8|EV%FqmA%d(1=Wk5X)p00i_>zopr0Jg$;4FCWD delta 465 zcmX@de2is+1SbbG0|SGGE`RVuMf>{v0G|+7?|Om6#iDWZM3R<@#xE32SST7jQzUM_ zh;O4{!Xi=Y6kgjjUYk^2n-pHlcpmFy-oz!M@e4$K8U(y*1@d-Ev2#S`s4C4?Rhp%uI73Boma5YK|Noz@U~2(7ficP3oy|pM z3)|0`6Q|47KVuc;Fk*3ku-gbIx8KvnF+}3B>V%6$hYdJb7##&C-gTH0vUXP3roaFH zNBDl;u-WF$9R>!EDG`^XeOIR_Z1vXk-l_BY_tg`PNhc*$XIy=HjAd8eY_{%M%CGJ= ztcw;=<$f&sb>RZ^sri ztYM2LsMxC<3S(WBkg#F#;su}ezg+x&@3+ObTAy-@W&f6cW}TDVQ}^z9$^4tlS5oeE zizJHqa9Cd1GU*KenZK6*8SR_+^qcf{E&}>RwZt`|BqgyV)hf9t6-Y4{85kMq8kp)D ynuQpeSQ%Ja8JcPva2Qw_7<_l&ubCXnD6WPn50Y+^-F^UQAcLo?pUXO@geCw43$on+ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_lime_white.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_lime_white.png index cd17d44e9175ab7f5dd8072a637ac9316f35a797..2a94cf2a42bd778d5b0f7e8e81c33c5df2d118de 100644 GIT binary patch delta 344 zcmX@ba-MmD1SbnK0|Ud`yN`kTq5dSCy>8e;{X5u|Ni~^{rmUd zzkh%J{Q2X@k3WC@q~8jh1=PftF|C(6(#lPSz`cmF&jhfPJVycd&R{- z+f++jBeY6V5=&C8l8aJ-6oZk0k+H6Uv96(Uh@q*KfiVzi8yHv_7$hkl44ll%Bp!ub zTDY$AEzm#>pn(wcN-}d(i%Sx73!p}t=^7b?7#dm`SXddFL5y5h(XtGvhr!d;&t;uc GLK6VT3w6=} delta 432 zcmX@le2Qg)1SbbG0|SGGE`RVuMf;?p0G|+7?|Om6#iDWZM3R<@#xE32SST7jQzUM_ zh;O4{!Xi=Y6kgjjUYk^2n-pHlcpmFy-oz!M@e4$K8U(y*1@d-Ev2#Qw7K#c!`7iAaw3IQ)+ucQ;l~-Wz#OZSN&saq{j9A^1^Q9q@E<43W63I^kl_VFwP^M%Kt#N1TFVV^`1Ka`ylKMLl+NEN$-WWM)tZOw`n$ z61LJIYkB6Z<(K#Dnb#|$@hmE^DKb{iXTj-RSsPYZE{fxQvFF&5l*By?_G!L|dAxV0 z`6d3pZ}`52a(dcGvure<@G|LKV7S4Ql_jhT>vn&=H#z(L!UJ9+K~HA8+?eGc%)?Vw zB2x0Nabs_7PhtI=-_zti`26)fZeNgdyH@7+M7f!@4YQu?^$<)u*b?CEEA3gQ@csEO zZs+ZM&by~(xEglpHree5 QfI-3F>FVdQ&MBb@05*xEq5uE@ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_lime_yellow.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_lime_yellow.png index 49db9480177a3385955035800dcad84abf63c5e2..d703184e30c11aba790c8a46682e713920049ca5 100644 GIT binary patch delta 335 zcmX@ha*26@1SbnK0|Ud`yN`kTq5dSCy>8e;?HrF-^Y}H99I5y zRQcN><*x^oe;!f(|Ns9h)hqQteT+%o?k?Q&*N+^S_*$<1IhzPKhk)PIgCMCSPZ!4! zj_b(@A}q{|Y>sNG3IPHs0s#pL2_hm1DFR6e3@0U+B)giLoD$j=E?BTZVFKedHZjI* z^ArISHfBc-c@BvO2dxt=(bmLO-W}cI0!BK#-%mwJJ$lv{z+BA6kh_!LU-n*c zG0-;E64!{y&lm-yjCBo+bq$R}3{9;JjDbkoz`)ADAW8XP;A8G_*3Xurf4*7`d#XWf@QpgQu&X%Q~lo FCIHM!ZWaIl delta 453 zcmcb_e3oT`1SbbG0|SGGE`RVuMf>{F0G|+7?|Om6#iDWZM3R<@#xE32SST7jQzUM_ zh;O4{!Xi=Y6kgjjUYk^2n-pHlcpmFy-oz!M@e4$K8U(y*1@d-Ev2#TJ99Q{$Oy$QBDGgeU!BNq1uyN!U3JmBf#7$R|5b;8AmitSuqD9RSK6~q;rsJn+|JwioOe&zSTWgvQC!MM*T7WQ&@9Bz#LB?Z o%FtBXz`)AD;JX8V&E!NzaW(AHZL-@B0E2?T)78&qol`;+0Ir_0J^%m! diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_magenta_black.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_magenta_black.png index e5bf0f2be82ab7a20710ea985aee414bc60ad0d1..d4eb056a91d51333562e2b43b3661369e397e749 100644 GIT binary patch delta 327 zcmdnXvYmN?1SbnK0|Ud`yN`kD zid6?HWK8mQcVSCR+ffVTa29w(7BevL?FV5-3)Wy2pdfpRr>`sfb2brf4gtTZ2kU`C zVV*9IAsp9T`z{JL7;rcTt7p7oy2@L%jzN0L-|);M!S}B#Pp}S{5mI1g?W&%|&Xw)R z{O;@onG|oyCw`vSj86VySl@D9=flH1xx}^&nMIx&Gv56_`}-J^dmJC*yq$MzCZA^% zmonBhFxE9R4ly*fGB5@rZ36=<1A`>xgMpKn#G|mw3fEP>1-eh8#5JNMC9x#csw6Wv uwYVfPw}8ROzzC?vOxMUD#L&>nz{1MV3}WK4ik4+SJq(_%elF{r5}E*<;%LVJ delta 474 zcmdnayq9Hy1SbbG0|SGGE`RVuMf>{v0G|-oI_>gB<}>D*PFZ3xYk}Fc1!mJ{nDoyz zoifjCYJ+y=Lh~8PO0lU*@hM7i@d}Yiim{8$XU;d9)}UQcqg7g~Rl37&?N-}W)mkNU zOeZ($R4%ocy~}=ml44A~cKJ^Gb&Jhs%{HARFRv^wuOug@^#A{VyMUfZpc5FAyxrMc zRJO4FoH?;uuKpRTD2EY?`-9y^K)G$6E{-7*mqRBU^kX*UamhV?tZ(*Gvn>J~TT;IN z|38uANaMtL^Gw<;c^HI5r+r$m@2T|ySp}&H|oupAtRw7@rSkeT&-dMUw7fYpY|VC|Mh2|!M$ox+AeirC*R`N zTCW*negCqp{J_s$eE5F{&gTe~DWM4f;b^rL diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_magenta_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_magenta_blue.png index 59b4386ee17af1c598668bab71cc18bcefff4ea6..c4765af84c388910df988f53de90dc9a9f819c00 100644 GIT binary patch delta 362 zcmX@Xa*la|1SbnK0|Ud`yN`kKkD46F`q0G|-oI_>gB<}>D*PFZ3xYk}Fc1!mJ{nDoyz zoifjCYJ+y=Lh~8PO0lU*@hM7i@d}Yiim{8$XU;d9)}UQcqg7g~Rl37&?N-}W)mkNU zOeZ($R4%ocy~}=ml44A~cKJ^Gb&Jhs%{HB6Y&zT6be56HOe2%&|NsB@*m|7}=n6*8 zByV>Y)x(S@`6o`7tAEBS%3;Lf{$RHeP;Q^6i(`nyWz`7}{g@4TnkSnnW?tLKVx}Qt zR#pD~e~(MT$zMvRKlL*tXinW>=Q(lJ9fvD^wxzG0Kkx2z?z|^eB(U-`x9Ek>uS1(7 z&I*1_Q<$DzqATW>e#M;it?s?{-vWOxoPU`RzcwN9JgeIr<{kC3gX=?hmIf_nnqIm8 zyyfNXmd=eKDmy+o&p63;IDvTwQIM^{@$l5F4MU``@i{{+tcQTC^a)* zk#G%AI@84E#BC~j=qKaJC4ZSVzopr036P? A;s5{u diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_magenta_brown.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_magenta_brown.png index 6aee57ce878dd491e078a0e6865efaca39d93273..068e4b6539d529336424fbb7ed807da6859dc1ce 100644 GIT binary patch delta 362 zcmX@ka*la|1SbnK0|Ud`yN`k2OC7#SED>lzsA8XAWfnpznc1Ch3Yft7(llJdbom=3Up-29Zx zv`X9>gzGBb0ySuWtN?2$$;?eHE=kNSfa)>RH8Kb>G_;a7u&^>TgV?gHqGcIS6N9I# KpUXO@geCw=L3jNC delta 466 zcmX@de4J&11SbbG0|SGGE`RVuMf>`q0G|-oI_>gB<}>D*PFZ3xYk}Fc1!mJ{nDoyz zoifjCYJ+y=Lh~8PO0lU*@hM7i@d}Yiim{8$XU;d9)}UQcqg7g~Rl37&?N-}W)mkNU zOeZ($R4%ocy~}=ml44A~cKJ^Gb&Jhs%{HA>?<@S2IIEF}E)}8Rs@2~++OYZSwebYBp4LPOwic4L|oNZP4dd0kY#?UmA1RX7HC*5X4xFN)1Xl|Kb%|a zb618ryKVepiAoFojQ4C|MKxQZX5U&~`<3h8Tu#qdIRZ!SIh^VbukUL~^jRs*@%8uK z?{+)C%CY6FQuLJ5I&_a^RzgC-(XOVc^@%+j{kGNG=J4D&zJHtg2H9DPo{~6al;+OlfDQ_##C#of`5hW>!C8<`)MX5lF!N|bKNY}tr z*U&7)(8S8X(#p_O+rYqz&A{Nh1AoorSVnO*Z1M&MZL-@B01agDboFyt=akR{05i(C A;Q#;t diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_magenta_cyan.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_magenta_cyan.png index 0161a7452e014c9e582eaaa1bffb37616c38dc25..b1dd8b1b2ecec530ece9040ce3122c922961158e 100644 GIT binary patch delta 329 zcmX@ja*BC^1SbnK0|Ud`yN`kcM)TRD!3AV+hA}*S=id z1_K_Ke2p8t%*^cEVyD^~R5cVdX0TlF)nttOzo#xH$U;i)jhm{F9aG;uMTYNcD|u23 zJX8EdyKf$O#5sq@Zf{e+rMIQIpiI!xjD>4c^G)^tpZ$G|HPM6ba>T*+|A2O>mbgZg zq)dLs$R}m2YhbKvXdGf_YGq&yMA`-hRt5%1$_E1{^D&7>VV4%Jt9%PIMgwe2Vo9o1 yNoHh8Ez5v<7(8A5T-G@yGywqJHf)&y delta 514 zcmX@be41r~1SbbG0|SGGE`RVuMf>{F0G|-oI_>gB<}>D*PFZ3xYk}Fc1!mJ{nDoyz zoifjCYJ+y=Lh~8PO0lU*@hM7i@d}Yiim{8$XU;d9)}UQcqg7g~Rl37&?N-}W)mkNU zOeZ($R4%ocy~}=ml44A~cKJ^Gb&Jhs%{HAR);3YBb%Iz+zi4xxXjAY1|NpZE3wATq zGcYhFdAqx)MRCm73Un4{fk$L90|VcF5N5Ps4ORgPvX^-Jy0SlG73DBuaeuJe2q?7A z)5S4F;cptHiCLO?LYMpaup{S3j3^P6+oZUIz}nXZvRh@qjCfrXW!nHa>DWfd*UfSMRQUHx3vIVCg!0J2eZBme*a delta 466 zcmX@ie1c_y1SbbG0|SGGE`RVuMf>{F0G|-oI_>gB<}>D*PFZ3xYk}Fc1!mJ{nDoyz zoifjCYJ+y=Lh~8PO0lU*@hM7i@d}Yiim{8$XU;d9)}UQcqg7g~Rl37&?N-}W)mkNU zOeZ($R4%ocy~}=ml44A~cKJ^Gb&Jhs%{HB6=j3MV=xXQaYU|))YqBv%3oj6gh{u!$%hY^eWgWX0zNAC7?aSV~TtUKYNpR*y4^JEjn%rbrN zgl4D23weM3>j#;H86O(`njxgN@xNAcZac> diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_magenta_green.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_magenta_green.png index 8a9f3f62c422b19a9644bfc7b6a5859f157bf3a1..d1991e2ed4734b02d5f4ed8a8e267c1b28f406d0 100644 GIT binary patch delta 362 zcmX@ka*la|1SbnK0|Ud`yN`kA)=M;B4vt|NnOjecJ)l#F*sm?!uLE;Y--W7jpH_*+jTG1pKBRtOrUZdb&7C{;Bncm@j{H5m0eb6iNRiRP8ov+W|b@YiaZ~RDu2H5d5}@DL3*mk4-Si}c7{8% zml#brs4~$uR3}ZiTfM;O#}_WUPdYzuxD`KlAUI>!q^uv#r{x{0C^6 zYKdz^NqtIUNvc(HQ7VvPFfuSQ)-^EJH8c(}G_^7?1|n?(11kfAB;|vFFdbkGx%nxX zX_dG&2-j7<1!~X$Spn8il9`)YT#}eu0M%orYh(~&XlNyEU}0rw2C-#XMawdvCI(Me KKbLh*2~7YHvUsKd delta 466 zcmX@de4J&11SbbG0|SGGE`RVuMf>`q0G|-oI_>gB<}>D*PFZ3xYk}Fc1!mJ{nDoyz zoifjCYJ+y=Lh~8PO0lU*@hM7i@d}Yiim{8$XU;d9)}UQcqg7g~Rl37&?N-}W)mkNU zOeZ($R4%ocy~}=ml44A~cKJ^Gb&Jhs%{HABk}DIOEfbt06O<+W|NsBKx9&%Qu3+R$ z@^*JoJ?<@S2IIEF}E)}8Rs@2~++OYZSwebYBp4LPOwic4L|oNZP4dd0kY#?UmA1RX7HC*5X4xFN)1Xl|Kb%|a zb618ryKVepiAoFojQ4C|MKxQZX5U&~`<3h8Tu#qdIRZ!SIh^VbukUL~^jRs*@%8uK z?{+)C%CY6FQuLJ5I&_a^RzgC-(XOVc^@%+j{kGNG=J4D&zJHtg2H9DPo{~6al;+OlfDQ_##C#of`5hW>!C8<`)MX5lF!N|bKNY}tr z*U&7)(8S8X(#p_O+rYqz&A{Nh1AoorSVnO*Z1M&MZL-@B01agDboFyt=akR{0MC25 AT>t<8 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_magenta_light_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_magenta_light_blue.png index fbbb10dd174ed1befd35fbffeb639f901405ce5a..c725fba36329eb2415958eb7fa010819d98fda26 100644 GIT binary patch delta 366 zcmcc0a*26@1SbnK0|Ud`yN`ktv27X+IZb+ z(@o3uS1s3HvD$d!|NsB-E^&K+`WTbE-CelluOB%u@uOV*b2brf4gtTZ2kU`SNuDl_ zAsp9}6GT{;8QC1wR22dQQUn4L5)wp25>f<`5*SWOFiCbbH8~};EnKi*gTe&HYiweS z+2$z%CTz@(9P%6z4-Q;Cdvvev)uXM6tGqk9#RZIXc)y>Dl6v&4F@U+4jUjg@zrXCg z;$om}swJ)w^(85ZC8<`)MX5lF!N|bKSl7T<*U&h`(A3Jn7>KkD46F# delta 461 zcmcb_e3fN_1SbbG0|SGGE`RVuMf>{d0G|-oI_>gB<}>D*PFZ3xYk}Fc1!mJ{nDoyz zoifjCYJ+y=Lh~8PO0lU*@hM7i@d}Yiim{8$XU;d9)}UQcqg7g~Rl37&?N-}W)mkNU zOeZ($R4%ocy~}=ml44A~cKJ^Gb&Jhs%{HB6z2&y`=37=9Z&+`>X|>^+<@&2un{NF7 zFZ5ryL320IJ&Z}-?k*a8H*DQBah6>DGgeU!BNq1uyN!TShdf;zLnJP%PPiDvY{=o- z*dQ=#>%nbOyHkF@Yg5T6GurN1khl#BD!<;O8TjFuq{cWXH2i{*v zzV*McHa0)`{ETrV#xTy-+G4{F0G|-oI_>gB<}>D*PFZ3xYk}Fc1!mJ{nDoyz zoifjCYJ+y=Lh~8PO0lU*@hM7i@d}Yiim{8$XU;d9)}UQcqg7g~Rl37&?N-}W)mkNU zOeZ($R4%ocy~}=ml44A~cKJ^Gb&Jhs%{HCX)6?AD-PG09*xA|8(NX{Z|9_wJf$0qO z3=E7(-tI1HQ5-Y20-eQK;1OBOz`(a3gc&VZgH?cn>?NMQuI$fPMLCRE+#l>V0t)T( zba4!kxU4$ip&yGOM@wTdoO2w-Lm`n@BNEh)MwVD7|oPtPzX%a-ehnxfp*cxOX9rXU)|L*}eQ*&8z3j z{#h(E=}U~j5le?#%gg(k5`9voIL_YAJvVdTIZ3vhRf?|rLRxA$cn%(T&?n1kU4Qu2 z^^MnVy+6KDUHp&AzjcrA7rd!13+m)~m!P+zOX{JV4~OZQ+!asQO(y^1-msouOZ>x& zvw1+jsFt`!l%yn+VL8^oa%Xmu z(S(yrC)oPhJQMC0FDUx)h0QK)>eCD*i=|yr3v+jEU-i2F^S(mH1YW-Vx^+9efL5uN zxJHzuB-WRtS|t~yCYGc!7#SED>lzsA8XAWfnpznc1Ch3Yft7(llJdbogbtvF-29Zx zv`X9>gzGBb0yStrtN>~#$;?eHE=kNSfa)>RH8Kb>G_*3XkhC&1gV?gHqGcIS6N9I# KpUXO@geCxDdwHM$ delta 498 zcmX@Ze3fN_1SbbG0|SGGE`RVuMf>{d0G|-oI_>gB<}>D*PFZ3xYk}Fc1!mJ{nDoyz zoifjCYJ+y=Lh~8PO0lU*@hM7i@d}Yiim{8$XU;d9)}UQcqg7g~Rl37&?N-}W)mkNU zOeZ($R4%ocy~}=ml44A~cKJ^Gb&Jhs%{HBszgr@ImqhLkiM(ABIori^wu$HMl=%N& z=zpM9=2M`17?Zr+T{QM?*t%)rbh-LxtfCx7Ebb3>8v&&bdAc};NL*H(a50G4ki)gH zL15O_gWIHf!#3aE_5Xi++N-&i#S(1~A2KNfCVBdM&GIo?@pIuBnNy!?O4d3A7P)bz zt^Ra~W!s!{Vmi-6FY57C*|-~iDu}xf$Ghf9MfO&+t>wR8i2gAao^<7>qd+yYW_(<| zrBIvU(maJL>#yJY{p3=$#DwjZyY<}|nZ!Zn=-zVs;=#qLU=fh!nX6?!|Y$bW0B z=6_$v|E_@lQxX6F|NnO}&t(JZV@&dPcj1=5e&oQ!k8<_T*+jTG1pKBRtOrUZdAc}; za9mGL5Mg0vWOGzgRR|DB5eP^~NDvW8ND)X%U^pqkB-z!}d~{t0On#ghTNU}{<8Oq zi-ESOmbgaLm!u??q*^5xr2;7iBLgF2T?1oXL*o!bQ!4{wAksE4ure@6Qa%_6)dA6v zo1c=IR*74Ka9!nFpau<~6%Y+2nYpROC5gEOP(5b4Mg}2{d0G|-oI_>gB<}>D*PFZ3xYk}Fc1!mJ{nDoyz zoifjCYJ+y=Lh~8PO0lU*@hM7i@d}Yiim{8$XU;d9)}UQcqg7g~Rl37&?N-}W)mkNU zOeZ($R4%ocy~}=ml44A~cKJ^Gb&Jhs%{HC%wM5`ciNMDqfzQPP?+XRq6$*SR7Wn^P z=zsa;R0*Ja7?Zr+T{QM?*t%)rEV=q;tfCx7Ebb3>8v&&bdAc};NL*H(a50G4ki)gH zL15O_gWIHf!#3aE_5Xi++N-&i#S(1~A2KNfCVBdM&GIo?@pIuBnNy!?O4d3A7P)bz zt^Ra~W!s!{Vmi-6FY57C*|-~iDu}xf$Ghf9MfO&+t>wR8i2gAao^<7>qd+yYW_(#yJY{p3=$#DwjZyY<}|nZ!Zn=-zVs;=#qLU=fh!nX6?!|Y$bW0mdKI;Vst09YHnx&QzG diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_magenta_pink.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_magenta_pink.png index b54d782379f4a814e45df05ddd17008fb6ef1224..9446c82963a9c0e07b2462808df3ce8cfdec4e0d 100644 GIT binary patch delta 366 zcmcc0a*26@1SbnK0|Ud`yN`kPu1*OH!?pi&B9UgOP!ev95u!uAy;=p{bRDF%W4R7+4t?Bq<*ZgzA83 z$jwj5OsmALLAb8+El`67&{d0G|-oI_>gB<}>D*PFZ3xYk}Fc1!mJ{nDoyz zoifjCYJ+y=Lh~8PO0lU*@hM7i@d}Yiim{8$XU;d9)}UQcqg7g~Rl37&?N-}W)mkNU zOeZ($R4%ocy~}=ml44A~cKJ^Gb&Jhs%{HC%xqH>8u9fdQmw)V9`L<)(oA#w2I#>Mv zFZ4h7V*Fm9dl-|v-CZ>HZrHkM;w-uPXRM+eMl9|Rb{heu4tcsbhDcmiop3RT*^tAv zu|Z(g)`Q!mdc!u~-u3@~d)lkHmc3ekzE&5XZabNk#Tnv#sU7Ux@xO7M^tFr=vhMvu1o; zq@_@s;nF;XE9ZESw>{ckS~^WP`vt>}_^DCfgrd1md(Gi)V!pX9f_ghgQu&X%Q~loCIIS)!s!42 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_magenta_purple.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_magenta_purple.png index ed3b8ff9b3d7d9d1d1b0fe6ab3e621cdc573a082..4819bd5c8b8ee0fef7210913b758947aca39b02c 100644 GIT binary patch delta 366 zcmcc0a*26@1SbnK0|Ud`yN`kFr1WNlI&_~a!P1hxM0Bsg$az;*u)sK z%~J$S*q9wTc?zsg;2-5NR72SQ!{3DIW}k>VRm- z%}>cptHiBAxUTXoP=f~03W$c1%-q!ClEmBss2($2BZCk_Lm4Xr3oAo2h%L)1T9yGd OF?hQAxvX{d0G|-oI_>gB<}>D*PFZ3xYk}Fc1!mJ{nDoyz zoifjCYJ+y=Lh~8PO0lU*@hM7i@d}Yiim{8$XU;d9)}UQcqg7g~Rl37&?N-}W)mkNU zOeZ($R4%ocy~}=ml44A~cKJ^Gb&Jhs%{HA>qPDU`ZAFplvSPIrg{n&nRhJa2E&u;t z=)Wg_HW$!6j7i?^E*g6`Y~3_*mR$WaR#6Tk7WW6cjet^zJY5_^BrdB?xERE2$l==9 zATVp|!EI8#VViI7`v1Q@?bTe%Vu`kg51AAKlRW*sX89Pc__^?m%&AW`C2Ji5i`+QV zR)0FgvTe>eF`Z|k7xnn6Y}^e$6~tYL<6ZNlB73XZ*7DykME@8IPrCBcQJ|VxGd?cT zQmD;vX`aHB_1EwHesZZ=V#CTdm7igP-_$O!FgI(5iLCj5*gQC!MM*T7WQ w&@9Bz#LB?Z%FtBXz`)AD;JX8V&E!NzaW(AHZL-@B00V=;)78&qol`;+07ARFN&o-= diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_magenta_red.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_magenta_red.png index 7c2fe17a0da7bbb3f9190e0c49cb883f7918847d..b84d822b080242c4edf8507f5f812e1212f20495 100644 GIT binary patch delta 332 zcmX@ha*la|1SbnK0|Ud`yN`k&)=Z zH%RhC!lV=Pw8S=d9u>Bbtf^v^FP>JEqhztv>!MTi>3dmm|7L&hisZ{8Glc2FALE#vz8LRtCmEq-|heWnhq`d@yjb0F!tWc4^_d%C|sMG(e`L zB$lLFm1O3o7MCRE7BCnY7y{F0G|-oI_>gB<}>D*PFZ3xYk}Fc1!mJ{nDoyz zoifjCYJ+y=Lh~8PO0lU*@hM7i@d}Yiim{8$XU;d9)}UQcqg7g~Rl37&?N-}W)mkNU zOeZ($R4%ocy~}=ml44A~cKJ^Gb&Jhs%{HAhM^$OIs?sbK#ThD!vs9J-|Nn2qpSX~L zhk=1H$=lsUEsA5t)``>Q>YuTSau~6=KiF*qbmRd~7sn8Z%c>I|`Z*hNxGiK|xTbi) z?6B3d-|qeXH~ymA{wGfaoPK;{Oz@g%VedIXT-Bb47XYG5@aiYvKI62lsg$IPdDb32PBI)b{cSdaj0I|!nvL;CHIv6rY-!Y9cQL=0X?Hy;u=wsl30>zm0Xkx zq!^40jEr;*Omz*-LJUo;3@oh-O|>}<46FYmi~;JffL`!)jwww;pPzVn|iPwD3#>t;uykl zJvl*yg_)7fQB74LKp;gRAR!?^L?j_aASr?2qy&>>S5uQyLfgUx3pOZBV7$gA#+YrM zB4EPC?8qU{A@ShA)w4(U>RvtCnz+ilqg!0SNQd|PsVJ#O&l&@mi`f`*ck=to-YYH! z+NN6K8c|=8l30>zm0Xkxq!^40jEr>+jCBo-Lkvx=42*$D+rYrez#vKaU?5ZnL_=G=Nq>G?ZlKrWThZ<`zKpnCTiBgcusiSQ%JY8JagB<}>D*PFZ3xYk}Fc1!mJ{nDoyz zoifjCYJ+y=Lh~8PO0lU*@hM7i@d}Yiim{8$XU;d9)}UQcqg7g~Rl37&?N-}W)mkNU zOeZ($R4%ocy~}=ml44A~cKJ^Gb&Jhs%{HAhu~1ZSM|sG8pw)~?-tI1nM{;<@CQg^D zf5s}xVZ`G8V7C!a>X4_4V~E6M)d?4am<>5x8yf^>Z9TY6syA%&?Op%>x2L_DYgsJO z_V6K-LST}ozt=1uqZL0Fo{>5AsitJDLtv2`XWHsdhgi1FIVYy`O!T52UzLr!;irPQ z3vs+_o>XLSHQQSL`-SKqW8q0xemV+NGi%1jMOq5A87|FJxU&BGz28qRRZDDG*{1R{ zOz@l91s3LJ?J$uwf0&bHZ%aHbyT7fp>cIOe$+!MD*2d;1-~aZ~F#mmm-ij`%hjKm~ zmS@(kJi}I!_ep-+OMXv>rE-%d>oST<8R;6B>KdAb7@AlaSXvpHY8x0>85n$b;IEk+ a$0)9bUAj$n`vG8JFnGH9xvXPu1*OH!?pi&B9UgOP!ev95u!uAy;=p{bRDF%W4R7+4t?Bq<*ZgzA83 z$jwj5OsmALLAb8+El`67&{d0G|-oI_>gB<}>D*PFZ3xYk}Fc1!mJ{nDoyz zoifjCYJ+y=Lh~8PO0lU*@hM7i@d}Yiim{8$XU;d9)}UQcqg7g~Rl37&?N-}W)mkNU zOeZ($R4%ocy~}=ml44A~cKJ^Gb&Jhs%{HC%=eWx6V=6z6DE~UD^6ilF*F(xbkE;Ct zFZACcWDY0LJ&Z}-?k*a8H*DQBah6>DGgeU!BNq1uyN!TShdf;zLnJP%PPiDvY{=o- z*dQ=#>%nbOyHkF@Yg5T6GurN1khl#BD!<;O8TjFuq{cWXH2i{*v zzV*McHa0)`{UO_QmvAUQh`)GgOP!ev95u! zuAy;=p{bRDF%W4R7+4t?Bq<*ZMA4C(pOTqYiCcqkUFBP#1`W6sC7HRY#U+Wk1yDU^ jx<&>ehK5!K7FLF45K9D>RkSPvYGUwo^>bP0l+XkKCL3@l delta 479 zcmdnae28U&1SbbG0|SGGE`RVuMf>`q0G|-oW&Ye(Q~53=@!d${yOhFrIfd_JJn#7= z-V4cmD+9Q%r1CY}akklWw%T*H*m2fcb2QmTX-b=P6V z{k*;3Pj3Bgk`U~xSrjh#P3;1U@MLCY*5>^QJsbUxZTz2c!0;b?-PZpv8Hyc4ulRgV zaaxg?=bLJ`VDrlR4^8-6o*q=12=s(%iEBhjN@7W>RdP`(kYX@0Ff!6LFx53Q3o$gY vGO)BVG}SgRure_C?!a$XgQ6ohKP5A*61R>v+3g2_8W=oX{an^LB{Ts5xGlGW diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_orange_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_orange_blue.png index aad85980622edc0312cee54b74a93ec128ab5fe8..5df924638642afa955ab84ad13b6064883a0751f 100644 GIT binary patch delta 332 zcmX@ha*la|1SbnK0|Ud`yN`kN1CNqpo zW*Qn#H#DC1|NsBZYacfOH8Cc6ySs2@T=)_;@wHt2b2brf4gtTZ2kU`SiJmTwAsp9T z`*L|340v4fHE!@SGqZDxooZ`P)lkrw!7B4$dJxl|f0ciCEGaOtxzX#TQo|y%*O}p+ zZ;<4Pgh?mnX^Cy_JSuD}d0%bi@o_jpn!e;v>= z)e_f;lF82*`K63?4UBaSjYAAgtqhETNZY``%D^B=`C#B=0VeS%?9#$@m2ZKjXn;&f zNi0dVD#^@EEiOsSEnqM*Faqi^(={>(F*LL?u&^>TgBZE2qGcIS4}+(xpUXO@geCxH Ci*7Rj delta 472 zcmX@de3oT`1SbbG0|SGGE`RVuMf>{F0G|-oW&Ye(Q~53=@!d${yOhFrIfd_JJn#7= z-V4cmD+9Q%r1CY}akklWw%T*H*m2fcb2QmeM%KiavAP+n zSFc`MUH<-mSKgGAPrhoxbvz70qSHPtS#oqq)2#W^Qe*vI|NQw#%3<|M>>~MP=Q`vVopaEpd$~Nl7e8wMs5Z1yT$~ z21Z7@2Bx}(W+8?qRtA<w!{=kpBF~4S%Aaq19%NK(ke=%CgTtb#o#D>x zB}Nkts!X&E)kzcXRxdF6@rBFolg`f@E(Kmw7qxDiw)bk~&-{Dlda3OEY^!!E{{dR2 zTH+c}GWi)Jzm&1Afw8WkafqR*m4Pu3X&V?=85krf9}Jw#&mehK5!K7FLF45F?jWv@8SaVeoYIb6Mw<&;$S- CRBg!s delta 471 zcmX@de1>I$1SbbG0|SGGE`RVuMf>{F0G|-oW&Ye(Q~53=@!d${yOhFrIfd_JJn#7= z-V4cmD+9Q%r1CY}akklWw%T*H*m2fcb2Qmq=9Rm*o z17ni6yNg;B$BeBLr_0qpV-@8vVsU@4+X(2${hlt4ArhB$CtS=sY{22lc=&+H$*gT< zpP#LrJNeIl{d0lcB_$>61^5{h0+T%Ty=M6st@xQa>)A^a{q^bBnM8`uX&lUPy*J~) zwC~-l-Ib18RyWVnHe*zn5-!`+DKM#P{cK${i@nh~BQ; ze^>SlYiOYIon}tO_MM?qKQhYt{$qct#y>qXue<>07u6Eih?11Vl2ohYqEsNoU}Ruq zq-$WRYiJf?XkukxX=P}tZNOn*Wnl2#fxl*QETgy@raVZxO?LYMpn(jYu6{1-oD!M< Dj6ATU diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_orange_cyan.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_orange_cyan.png index dc877ddbc3134f1b76217bd3a7e96ed9cf520277..ed9eeef41a6aa96857cfe09b38315c637fbadf43 100644 GIT binary patch delta 358 zcmcb}a*BC^1SbnK0|Ud`yN`kcM)TRD!3AV+hA}*S=id z1_K_Ke2p8t%*^cEVyD^~R5cVdX0TlF)nttOzo#xH$U;i)jhm{F9aG;uMTYNcD|u23 zJX8EdyKf$O#5sq@Zf{e+rMIQIpiI!xjD>4c^G)^tpZ$G|HPM6ba>T*+|A2O>mbgZg zq|_&tq*^5xr2;7iBLgF2T?1oXL*o!bQ!4{wAksE4ure@6Qa%_6*8$Ryo1c=IR*74K za9!nFpau=F6(9{InYpROC5gEOP(5b4Mg}21SbbG0|SGGE`RVuMf>`S0G|-oW&Ye(Q~53=@!d${yOhFrIfd_JJn#7= z-V4cmD+9Q%r1CY}akklWw%T*H*m2fcb2Qm1cQo}&QnLvZckQI zd)?E!=3IOG@r{(j&TCzh&WL@gKf(u_;`KWL4t+wo$@0kaD&ze@PnECExOTgtjvrff0qzBbAKL1?8 zzgRl1%^T<))e_f;l9a@fRIB8oR3OD*WME{ZYhbEtXcl5;H86O(`njxgN@xNA5{ku{ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_orange_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_orange_gray.png index 43d8e34bc75f68c90a5a0d95eaf69288e60e6e48..5a7e80c34ec9aaf3aefed477b657aca69fbdc6f9 100644 GIT binary patch delta 326 zcmX@da+rC71SbnK0|Ud`yN`kk$>%?=K=>6eXnrsef?tXyZ>i@A7c&G=1aSuT(<#ek7|i)L`h0wNvhT4 zw~Sm;#<~W^x`xIfhNe~q#z3TPU|?lnkfeMtaIzqicocSN;kwGVK%+F^MwMjdrWThZ r<`ys*85jZenCTiBgcurH8CX~unn8?QR?)HysE5JR)z4*}Q$iB}nF4GF delta 472 zcmX@ie2!&;1SbbG0|SGGE`RVuMf>`S0G|-oW&Ye(Q~53=@!d${yOhFrIfd_JJn#7= z-V4cmD+9Q%r1CY}akklWw%T*H*m2fcb2Qmbm?ZlqXJs2i(`nyW!(uE{hSSXoF|(oW?rj~ zWR@1;YA$>H-+tnv#Fr-~>Ha*(;4vlQQu8FW$vjzg8mZdtx%D=?!WP^pa^p-}{pkqH zHv9QH5ofd)&6WL9(UtV%;hx2NC2mZ6y!Gm>EBD^)4gb*Z;}LYdN#Pq?kX`8BA{Cxw zue%N_;`R1^Kf3d~K|(OE=clDgZ+sVUvayA)(TMmdeN3XbaPL`rY390P`=7~1#2laV zy{=Ds2KTB(Zadh8o%o8gwO%vEdj4a5;>tfsJ@jtmWJN~ta3fsUftDnm{r-UW| D?;@~u diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_orange_green.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_orange_green.png index c77ef34d43f5690847af760623c3e1e55b8a8380..41273e5680058bba38e50d0eaa8dc4fd2e318b0d 100644 GIT binary patch delta 332 zcmX@Za*la|1SbnK0|Ud`yN`kC{;Bncm@j{H5m0eb6iNRiRP8ov+W|b@YiaZ~RDu2H5d5}@DL3*mk4-Si}c7{8% zml#brs4~$uR3}ZiTfM;O#}_WUPdYzuxD`KlAUI>!q^uv#r{x{0C^6 zYKdz^$>e8@{8Glc2FALE#vz8LRtCmEq-|heWnhq`d@yh_Ka+SAc4^_d%C|sMG(e`L zB$lLFm1O3o7MCRE7BCnY7yI$1SbbG0|SGGE`RVuMf>{F0G|-oW&Ye(Q~53=@!d${yOhFrIfd_JJn#7= z-V4cmD+9Q%r1CY}akklWw%T*H*m2fcb2Qmi^DT{i7~CX-c7^Ks4*j`ntUZDm=+v zXB}4D&0D+m;MT1M3BkOcMd589oStCs7pSZ%!V|NsAaZw*U<`WTbE-CelluOB%8vL>4nJ@a+d-Mhn(p6`&w{ ziKnkC`*SuCZVmyzsR!$ULP?%3jv*Y^lM_T(m>Jm|)l?M%1X2V75)u*uMMM%(1dTs?bqukO{Ot%<9=JG#XM zjC6RvpNf)t^sF&}xtNV1cPGEU?7iaR$!{6OrHpkAjCBo-Lkvx=42*$D+rYrez#vKa zVBlmqCh;ij(!zC>Z-I{0C~=J_Nl7e8wJOQXO)V}-%q?IrGB5(_G1E0N2r)FYGO(~R XG=mtqtfFNZP!EHrtDnm{r-UW|gS~Kk delta 467 zcmcb_e4Ay01SbbG0|SGGE`RVuMf>`?0G|-oW&Ye(Q~53=@!d${yOhFrIfd_JJn#7= z-V4cmD+9Q%r1CY}akklWw%T*H*m2fcb2Qm*}XZN2%H)y5mvn{QfexMsQjs?{dZ z8~^|R-($!A3FsuoByV>Y%~RW3RVL1otAEBS%3;Lf{$RHeQ0l0si(`nyWz`9R!G{fa zn%^Ed)^~l{&E#f>gb8Jf|Nj@)W9Q%Hzx?t`M}`?eYUlhXsc4G}Y&~pp_Hts}ynZ!4 z&1XRqnmy+FPjQ$&eKXs}S<0`DI`loCVG=2!yJ9_;)%1$h??S)C+RtjPoz~J>t7DL~ z`asO(>6Wg?0=#x=7Gzz|&dz;tDN18P7fbp-v9wL60wkH6Wn?Ai)-70H`+D#Fcel6k zmHm+YQT%&`8 z%1GD1RM*ff#L&dbz|zXlRNKJ7%D~{e1AoorL`HEn?9y$r+YbQ4gTd3)&t;ucLK6U) Cg1aUF diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_orange_light_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_orange_light_gray.png index 016babd256c01d6150227e782d41d8e4c29c09b4..36225bba65c7f3267681284cfc404b22ef1bd0fb 100644 GIT binary patch delta 358 zcmcb}a*BC^1SbnK0|Ud`yN`kR?Rrc6Z_YcysBSiSOj{MHWs)mBb43-PNnv8M(_teD%SxCvfaZ?qtW9qx7$naflB~OZh zXNtdQ_st`ZIOp)#?QQC}^tLn?lnGjzv2bl_zN!BIv%inACVKE)jyU-KAJ8t<64!{5 zl={SyRIB8oR3OD*WME{hYhbKvXdGf_YGq&yMA`-hRt5%1$_E4CIzSq7^HVa@DsgKN zuB&_t)Sv;j0;HiNGdH!kBr&%Ds>e*%$RNbf(8@r{!phJLV#~6MmSsRq44$rjF6*2U FngF!@cZ>i4 delta 520 zcmX@be34~>1SbbG0|SGGE`RVuMf>`S0G|-oW&Ye(Q~53=@!d${yOhFrIfd_JJn#7= z-V4cmD+9Q%r1CY}akklWw%T*H*m2fcb2Qm1cQo}&QnLvZckQI zd)?E!=3IOG@r{(j&TCzh&WL@gKf(u_;`KWL4t+wo$@0kaD&ze@PnECExOTgtjvrff0qzBbAKL1?8 zzgRl1%^T<))e_f;l9a@fRIB8oR3OD*WME{ZYhbEtXcl5;H86O(`njxgN@xNA%)QBT diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_orange_lime.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_orange_lime.png index 72e21ad492272686328634997344254c00f4faec..1aa7bed498adf9058f67ad87a5bb7ebc09206c25 100644 GIT binary patch delta 349 zcmcc3a)x<=1SbnK0|Ud`yN`klutyj|kCJH+#L zisx(-&)zEj|Nno^XRAzrni!M3-CejcE_?|CaySb-B8wRq`1XS^qXlcQ3Q&-}#M9T6 z{W+TmH-~`V)Pwavp?FUh#}JO|u6?<@4F)_e`5HHPnVH$S#k?F32#I*}Xj&Z5U&>PP z_w%npPr(;18>D-Ej_|M?YhbxEJIQFm$)yu)eQllz_lp-4{rJLWmp1ijhLXk7uBe5% zySA@-UH^GsA!7nB-+tY?9bS{)GKxzX>lzsA8XAWfnpznc1Ch3Yft7(llJdd8$#P8M zQP`!0>nh&@U8+&y8c~vxSdwa0l9`)YT#}euz+hxx1k_`uYh(~&XlP|%VP$9rF>+Z& R%QB!I22WQ%mvv4FO#r4GadiLy delta 504 zcmX@Ze4Ay01SbbG0|SGGE`RVuMf>`?0G|-oW&Ye(Q~53=@!d${yOhFrIfd_JJn#7= z-V4cmD+9Q%r1CY}akklWw%T*H*m2fcb2Qm(pVeGDt);V8#~^9- zf%?nSEnSZVcCkWnl2#fxiYtM{a&fW?Ch> X4upm_+3g2_8W=oX{an^LB{Ts5bI`+M diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_orange_magenta.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_orange_magenta.png index 28010a3a1fba6f40983496b73772296d3ee7bd80..0c1a44f4912715dd02ef103164eaf29257658411 100644 GIT binary patch delta 360 zcmcb{a)x<=1SbnK0|Ud`yN`kq!GOmlU*iTZGc!B4n3v-LArT%;iv#*gSt|a1{#EEH_`+p_bg$159+qPbEO%xn z8BI93bb_s~%`@SC@q(fsU)b!@rasM3vRK*`wJ>+r_EoRzKkqAKOyK3)uUogn3uu*U ziEBhjN@9IUs#S7PYGO$$gOP!ev95u!uAy;=p{bRDF%W4R7+4t?Bq<*ZMCbr&$jwj5 zOsmALLAb8+El`67#0sE>lFZ!H;*!MN0;nD{T_b}KLqjVA3rQ{d0G|-oW&Ye(Q~53=@!d${yOhFrIfd_JJn#7= z-V4cmD+9Q%r1CY}akklWw%T*H*m2fcb2Qm{f5JUA4n*?f?Hm z|I>16w*lS5nB?v5qOo_w)=d+q%hf+)73DBuaeuJe2q<;f)5S4F;A z9P8V?`%0S_Q=`+S)c^naPabgmY$Dam$8=zdQDNN#mB^h9E9Op1jrDu|t-`F(W8<_Y z8JAaoTsTXr_hksIwp#y0xuLD?JLH=_jhK=9y|}aN^>`i!Y^ry{LX)d*^$tPuY)| zKZ=j_nUi;y@4#MhjcU)rvzNqvXP%Kb4vW{c>b-8%dg}C{i9mq8c~vx zSdwa$T$Bo=7>o>zjC2i5bq&oz3{9*IEUi2ZO|=aStPBjkJMh<_=*Z1a$xN%n)B)4b TCcFIrPy>UftDnm{r-UW|C%4Ia diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_orange_pink.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_orange_pink.png index c71e570e9e1b3216c68e1ea535b8c64e7c07f424..3b43402e6be8236410c058bc9d79b90a0d62c0bb 100644 GIT binary patch delta 355 zcmcc3a*26@1SbnK0|Ud`yN`kC{F~)536af=9W=9Tr4v7Z`uAV)*SNH1C*2Gob9o^yr zMmoITPen;Rde#`gT+GIhyOZBv_Fi%E<_2F5_7ZD3$!V34GI zFmSRQlXw(%Y2mucw?M~gl(`?0G|-oW&Ye(Q~53=@!d${yOhFrIfd_JJn#7= z-V4cmD+9Q%r1CY}akklWw%T*H*m2fcb2QmvKSoWrU>4#3y z761SL|C3+%1?VKkByV>Y%~RW3RVL1otAEBS%3;Lf{$RHeQ0l0si(`nyWz`9R!G{fa zn%^Ed)^~l{&E#f>gb8Jf|Nj@)W9Q%Hzx?t`M}`?eYUlhXsc4G}Y&~pp_Hts}ynZ!4 z&1XRqnmy+FPjQ$&eKXs}S<0`DI`loCVG=2!yJ9_;)%1$h??S)C+RtjPoz~J>t7DL~ z`asO(>6Wg?0=#x=7Gzz|&dz;tDN18P7fbp-v9wL60wkH6Wn?Ai)-70H`+D#Fcel6k zmHm+YQT%&`8 z%1GD1RM*ff#L&dbz|zXlRNKJ7%D~{e1AoorL`HEn?9y$r+YbQ4gTd3)&t;ucLK6V- CIlhVj diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_orange_purple.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_orange_purple.png index 40a37ef76250ca3f6e208a7cecc5a95709ac7671..4146a131f9dc8e26a84e7f31d13620a2b2b1a14b 100644 GIT binary patch delta 355 zcmcc3a*26@1SbnK0|Ud`yN`k_O1 zmlvuoEl^ofq`Lh7|NqrXm^T3RF(!GtyKu{2KXL%b;VkfoEM{Qf+YiEw7OcT4Ktc8r zPhVH|=WHU}90Gn*57q;Pl001;LpZJ{Cy1~xGqO3VsVW2rqzD8gBqRiih$N&4BqcDM zlwgwVYHD&yXj`~o!3Kp1jMv!27_-e&1WeeN9XaGVBpw{NdiLmE-K$4i6IXe6bc+iZ z>F|C(6(#lPSz`cmF&jhfPJVycd&R|*-!h6z8S5Gt>lzw|7@Arc7z2^Efq|8QL6Y*p zz{zq<;!)V8h3hKc0v)SS;u=wsl30>zRg#&TT3nKtTfkssU`?0G|-oW&Ye(Q~53=@!d${yOhFrIfd_JJn#7= z-V4cmD+9Q%r1CY}akklWw%T*H*m2fcb2Qm(pVeGDt);V8#~^9- zftbtFEnSZVcvu*y7`9>lcgU*+E&OA1VEZuEMo)Ue3xb!K?y z8zgxmVbY0tT4I|!j|y8z)>N^|7f&n7QL2OC7#SED>lzsA8XAWfnpznc1Ch3Yft7(llJdbom=3Up-29Zx zv`X9>gzGBb0ySuWtN?2$$;?eHE=kNSfa)>RH8Kb>G_;a7u&^>TgV?gHqGcIS6N9I# KpUXO@geCy#-*r&{ delta 478 zcmX@de3@l}1SbbG0|SGGE`RVuMf>`S0G|-oW&Ye(Q~53=@!d${yOhFrIfd_JJn#7= z-V4cmD+9Q%r1CY}akklWw%T*H*m2fcb2QmEak7aanc3!60Ts9_QTS$NF|h zOF45lI(To|{r`Vw%7X=!QoU~Mj0%BCp8j65e2iB7%#6JDbj!T?`s-LVuFVN-y4khI zpmA>edNG}6tQYh6s&*brdh)Qwt=f2l>G5jarK@Uhq-#HjpE+U48CJ&}(Ukh1-wsVQ z=+QJ~URbt&`?Y0xYg-v-XL(F&@7fUFs3jp0vtdEPL-`kr^Y?z=n16f5n+^Vdc0P_T z=rR1YQFd}|S-F9Dh-+^FzgmmTv#`)-%vO{CaKHS)zfQ_eP9NwW)e_f;l9a@fRIB8o zR3OD*WME{ZYhbEtXcl5$PR0l*uZhlH; zS|x4`!gZBzff_V`RzNhAWag$8mn7yEK=qjE8X1Hb8p>E1SXddFL2Ox8(XtGviNVv= K&t;ucLK6Vzt$iv0 delta 446 zcmX@le1m0z1SbbG0|SGGE`RVuMf>dP0G|-oW&Ye(Q~53=@!d${yOhFrIfd_JJn#7= z-V4cmD+9Q%r1CY}akklWw%T*H*m2fcb2QmV0!khAba4!kxU4!MF!-Bul6NbQ{eBo%FOfvty4&R$N8o7b<#r}->sLbJzQ|0xdBr*CH4I7|7}QHQ?g zGfW~SbXTnBvYKA8`d#RkSo>McwbNQUYjq5gRv(DDJl)duSb*0~&4R4!+1a@-E=6ff z=weC#CziJ9RDdLNvy80d+`0wpYhUlZ|L*oSzOo;(KZ<|vPl&%BeSdrHhW>Z5S0r2m zl+H8>IdPhH=O_UCLO+#CXaQxDbyg_1m7978y+Cnt!oFf+0_s;Mdj2&4!EBqSsRiijkn2qYyi zoRnaa>}qOqN@!cSV8I5335?g+#2B;9Qv^)dm>oIfIV2t&xO(>JUfrulTN77#cXW#j z80qkSKNThQ=viX`b1@r3?oNJx*?YyslixCmOBw4L80#7uhZve#85jeRwt<0_fkBe; z!NAFKOyW`4rG@J%-vS-0QQ{g=l9E`GYE_b%n_66wm|MVLWMBl;W2S3l5MpR(Wnf`t XXa+HISw+h-pdJQKS3j3^P6`?0G|-oW&Ye(Q~53=@!d${yOhFrIfd_JJn#7= z-V4cmD+9Q%r1CY}akklWw%T*H*m2fcb2QmIsgAW_< zG`~G^tnd1?o5{@%2@}c||Nk$p$IidYfBEH?jtnz`)Xw=&QqdL{*m~IH?B&F`dHrg9 zn$LnJG<(eTpW-lm`ewF`vy@*Qb?AFO!z5Bdcg1=xtLYW1--UjOwV%~oJFTU&R>vS| z^?{hn(=A<(1$gb$EXcZ^ot^vQQk2GoE|&CvVriRB1xPYC%g9R3ty{3Z_VwQT?{077 zEBhh)qxkp!g!t>x_qW$>=zk}BMZz^e=}eQ56Q}9gLys9HJu4aB>GB`iFLSI-GwbNZAUGT!&%@FS{v0G|-orE$eqDyN()n{cgq+QsromntS7FX}#9 z+JC-m;);aQ%N3KGyrNrtVq3gpn!TfI+`}8aqOMj=y-+@Jd3@=j*uurJMISm>ylG#$ zFsATKY5&TEvg_5;KX`_>d3j}dc_leHrT_o`D>47s40HlxlD9jX zi^>+ZpED`>U$1DH< diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_pink_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_pink_blue.png index d625689da5f755cbe00a6100050a73c9c1dcd011..84739230c0740ddeccabac2895190ac9a0664124 100644 GIT binary patch delta 362 zcmX@fa*la|1SbnK0|Ud`yN`kF8H8Cc6ySs2@T=)_;@r7Ldb2brf4gtTZ2kU`SiJmTwAsp9T z`*L|340v4fHE!@SGqZDxooZ`P)lkrw!7B4$dJxl|f0ciCEGaOtxzX#TQo|y%*O}p+ zZ;<4Pgh?mnX^Cy_JSuD}d0%bi@o_jpn!e;v>= z)e_f;lKPayl2ohYqEsNoU}RuqtZQJbYiJx|Xli9(3`E)n237_JNy-NUVLHGXa`RI% z(<*Um5U#6y3)G+ivI4B3Br`X)xFj*R0IJ7K*T^8m(9lZSz{1MV3}VZ&ik4+SO$?r{ KelF{r5}E+Gq`q0G|-orE$eqDyN()n{cgq+QsromntS7FX}#9 z+JC-m;);aQ%N3KGyrNrtVq3gpn!TfI+`}8aqOMj=y-+@Jd3@=j*uurJMISm>ylG#$ zFsATKY5&TEvg_5;KX`_>W7FBjrn8JpW*V7H|NsBL;oRR>fUaQV zO!9VjQ9aCfl7HfKx%y|Uq8vsn?hkew0p<34x;TbNTvna%(2vECqouJaAg|o^g7w<4 z^Y7mMwqM*k$!FimltcZD4vP*2&6~1iMo7Tt)0@_uPQ5#C{W``e*=sdU<|yj>B;0;| zcG6KBfw%7#T#wdsn|Dt7*6hZ$ruU;=f`4x~FZUpR>I9W%?2d1EQ+|G{f1oqtSjeu% zfO?y%_rc%qU2gC-UFxxdqgptlsqFVdQ&MBb@ E0Oc~y1^@s6 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_pink_brown.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_pink_brown.png index 63ecc09f7ef0f4a4bb677d86242dcfb6b5b4b21b..fb14cf2c83d743ab69785d63a584d08562529eb9 100644 GIT binary patch delta 362 zcmX@ka*la|1SbnK0|Ud`yN`kLEvuIl-& z>Upke1#as9|No!VeX#+ki80CB-GwXT!k4g#FXZZ4AsSPzs+^mK6y;kfSF z=PlS^z~i!A4{?F@Hj zFEN^MP-UWRs7{)2w|armk1t$ypLBlSa4GPbx~O&Aw7pj=f9Bsa*GpyRXIr&X`47-C z)e_f;lKPayl2ohYqEsNoU}RuqtZQJbYiJx|Xli9(3`E)n237_JNy-NUVLHGXa`RI% z(<*Um5U#6y3)G+ivI4B3Br`X)xFj*R0IJ7K*T^8m(9lZSz{1MV3}VZ&ik4+SO$?r{ KelF{r5}E*pS$dBE delta 466 zcmX@de4J&11SbbG0|SGGE`RVuMf>`q0G|-orE$eqDyN()n{cgq+QsromntS7FX}#9 z+JC-m;);aQ%N3KGyrNrtVq3gpn!TfI+`}8aqOMj=y-+@Jd3@=j*uurJMISm>ylG#$ zFsATKY5&TEvg_5;KX`{XB6p1fH}yg{jeJ-2|NsBLJF((2&=riF zN#5=*s)rd*@=u&DSO1Jvl*5R{{lRV{pxjtxGrQ}_~y)x1-qlx zuA6)AfBoXQ8YfSl+^cBA(4d+6=#Pr$rXt3`-8!dt#aw&)GwacWBwbd^jw?S~gyODB`1RJ#seC85 z;Fv~}P@>or0k0LAqVwb@+?*1B*^EDYRtcvJ&?l-Tt`Q|Ei6yC4$wjF^iowXh$Vk_~ zRM*ff#L&dbz|zXlRNKJ7ip{{_y90mC=HEi+*25qw24*(5h@O1TaS?83{1OVy& B#d`n% diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_pink_cyan.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_pink_cyan.png index 27058cd01ebc29c5c60962db2790ca843f98767b..b31bb33864573ca20318d4ef5f65bc5a35dd1a92 100644 GIT binary patch delta 329 zcmX@ha*BC^1SbnK0|Ud`yN`k#_^=GT9yIzFnGH9xvX{F0G|-orE$eqDyN()n{cgq+QsromntS7FX}#9 z+JC-m;);aQ%N3KGyrNrtVq3gpn!TfI+`}8aqOMj=y-+@Jd3@=j*uurJMISm>ylG#$ zFsATKY5&TEvg_5;KX`_>v9^g~trNsr`bC@jM4Nj5|NsATM$id{ zdIko@ByV>YwJ44mTY=8vEbxddW?8v%t5 zc)B=-NL*H(@X(Lhk)x%NHSy)$$O~cN;kWm$e*eEKZ%WE1Up3)69tI)NX`hxXIl822 z*8FLyv3{?=)s*orh{<;KOyjOhWV&4+r$0^SSz|^xyKQ`t;ir;&7w+-oto?aUY1Xaw z+HVa1SGA}Z+H)l3E1cfWo_^3|*(KhVUvIBf&)@ZJ9$U^TO;;z^8?zmReSG+MM0oZc zzH!{}*bVvP8~yoy%=}S&eE)+R-*3(|H*98~!M$ox+AeirC*R_1tzyQxo_|@dG4m&H z-Bqx0CD1pjC9V-ADTyViR>?)FK#IZ0z{p6~z*N`JEX2^n%D~df&{W&Nz{ eiiX_$l+3hB+#1?sw;up%VDNPHb6Mw<&;$UZd(l(? diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_pink_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_pink_gray.png index 8aa1199a581293baeb2a94e72e63ab227ec23918..8791fbc0a642f00017345664161888c141cf4b21 100644 GIT binary patch delta 332 zcmX@ba+rC71SbnK0|Ud`yN`kYuZTaB~RwO+8o-l#20maSY+O?%H=-ut9-` zg= zl8aJ-G=q_Wk+H6Uv96(Uh@q*KfiVzi8yHv_7$hkl44ll%Bp!ubTDY$AEzm#>xPc{^ sxv9k^iMa((Bh7S;3_=VItqd%z49y@$E~{u+2Gqmg>FVdQ&MBb@03_3JAOHXW delta 468 zcmX@ie2Qg)1SbbG0|SGGE`RVuMf>{F0G|-orE$eqDyN()n{cgq+QsromntS7FX}#9 z+JC-m;);aQ%N3KGyrNrtVq3gpn!TfI+`}8aqOMj=y-+@Jd3@=j*uurJMISm>ylG#$ zFsATKY5&TEvg_5;KX`_>J0~|=M^`&XS6c@c8wZ#F|Nr0ac>I8Y zhk=1H$=lsUEsA5t)`=74>YuTSau~6=KiF*qbmU%77sn8Z%eoUT`Z*i&I8QcH%)C|| z$s{ep6}|i8|NR~pH>sDk0POyTQBzgTDBm%^ZT=VF7{tGTi*!xoN?nilkzvVnEfGVHI3SW zPQ^9`?~kc^-(CEEp@WvtoSUsP*BF`{JD}k1?zUXJ$MD&svibF9Y=3&{&$4gW(Q7IH zSEf85S;Vo^fZK~h^~x5`_3SCCPsJ~V@(0DF#I;XWWE2lK(ls#EH8cw`G_f+Uv@$f+ zHZZU4AsSPzs+^mK6y;kfSF z=PlS^z~i!A4{?F@Hj zFEN^MP-UWRs7{)2w|armk1t$ypLBlSa4GPbx~O&Aw7pj=f9Bsa*GpyRXIr&X`47-C z)e_f;lKPayl2ohYqEsNoU}RuqtZQJbYiJx|Xli9(3`E)n237_JNy-NUVLHGXa`RI% z(<*Um5U#6y3)G+ivI4B3Br`X)xFj*R0IJ7K*T^8m(9lZSz{1MV3}VZ&ik4+SO$?r{ KelF{r5}E)leR@U! delta 466 zcmX@de4J&11SbbG0|SGGE`RVuMf>`q0G|-orE$eqDyN()n{cgq+QsromntS7FX}#9 z+JC-m;);aQ%N3KGyrNrtVq3gpn!TfI+`}8aqOMj=y-+@Jd3@=j*uurJMISm>ylG#$ zFsATKY5&TEvg_5;KX`{XkX)JIY?A`|NsAgKbkELbOj@4 zlDE5y>S4x{{1d0k)jwku*k*OU%z;+#>tZ>_bS>jG-#$i`lI5xsfaOfx6bKZG1uPy%z88-Nte~Kq( zE-Qo;yX=)d@l~u_je9ZgS6|2LLhrBc?W%i`Uc6!bB!i9TxqEJCefU(L>o?JGN>Cox zoLi4CM$Ntx&CMD#@xd9rGbvLS8nLliS{YgWb$DMpzbD!Lsbp3HscSURl+F)^oeSTYeY#(Vo9o1a#1RfVlXl=GSW3L z)ipE=F*LCTW!8&weh;u zrkj@QuUf9ZVzu$c|NsBxT4y{1>SIjuc6Z^HzkcMv#E)|I&)Gz{IRyNs9;^pSC3(6y zhHzX@P7q;XW@K|zQ&k8MND&A~NJtP7Nk|b$N?#Q?JUDRm?9sitSC6(PuJZ2a78fwm;r)IpO6t+G#sKDGHiq1t{Qk1{ zii?4^sg}4#)R&|rmZVxG7o`Fz1|tI_V_gGdT|?s#LsKgQV<6HtFt9Q(NK!r+2-N}6 zkei>9nO2EggK%BtTc8FFpcN1eC7HRY#U+Wk1yDU^x<&>ehK4d$1{PL^W)NGJRkSPv PYGUwo^>bP0l+XkKK?Hg7 delta 463 zcmcb_e4S;21SbbG0|SGGE`RVuMf>{d0G|-orE$eqDyN()n{cgq+QsromntS7FX}#9 z+JC-m;);aQ%N3KGyrNrtVq3gpn!TfI+`}8aqOMj=y-+@Jd3@=j*uurJMISm>ylG#$ zFsATKY5&TEvg_5;KX`_>>n*pfH{Y__c*A=0O{)#pEZ1MP+H~Xp zf1&^3*Ja)V-NTsV?e3zncf;0A6KBcQKVuc;Fk*3ku-gbIb;Q%fF+}3B>V&}H!v;Lf zZ;u@7yFTq^ahWxu=p^2;v@3_hB|&&53_P37*ml{o9!O9TD&?!xUN z#hND^mz-1gT5$SyWOKw>!LLaQ$BTVt>GX(QDQBJQT@&(M>(|Qovj_KiA398TxZ}kWFt^2+&|967?UG^1*T?<@hu&TBQWkt0fXEvJjiT#c(f74aY`)ZR77{#TG zbPY^(4b4IfO{@$otqe`I4GgRd48A+?*Gx`i6j#G8-6p&J05CWhJYD@<);T3K0RUs% B(AfY0 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_pink_light_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_pink_light_gray.png index 8eb21d251b2a1d8db065c0362b07a428f3bd77c8..18efc6324ee6af6bf684154013f34ae03aaf38c5 100644 GIT binary patch delta 329 zcmX@ha*BC^1SbnK0|Ud`yN`kR?Rrc6Z_YcysBSiLd4ApR{MHWs)mBb43-PNnv8M(_teD%SxCvfaZ?qtW9qx7$naflB~OZh zXNtdQ_st`ZIOp)#?QQC}^tLn?lnGjzv2bl_zN!BIv%inACVKE)jyU-KAJ8t<64!{5 zl*um``J{|>4UBaSjYAAgtqhETNZY``%D^B=`C#B=0VeS%?9#$@m2ZK@Xn>7LEJ?L0 x$;?eHE=kNSU@$T;0_ri-H8Kb>G_*3Xurf4*7`d#XWf@QpgQu&X%Q~loCIE~;Z_EGy delta 516 zcmX@be3oT`1SbbG0|SGGE`RVuMf>{F0G|-orE$eqDyN()n{cgq+QsromntS7FX}#9 z+JC-m;);aQ%N3KGyrNrtVq3gpn!TfI+`}8aqOMj=y-+@Jd3@=j*uurJMISm>ylG#$ zFsATKY5&TEvg_5;KX`{Xo}T9J?xwD;#?H=$j*j~O|NozJD;8m> zXJBAV@^*Joi{hBE73eI^0*}aI1_r+UAk1jN8ms~oWH0gbb!C6XD#~HR;{IT_5m4xW zr;B5V#AVe95B-=OIa(T76JOqqybu;1etYlg_y4={rlfrGRTHk`VGt6X_G!tIqf44* z&7YPU>-YLwO&RZkm~2zm0Xkxq!^40jEr;*Omz*-LJUo;3@oh-O|=aStPBjkJMh<_ dXvob^$xN%nt)WeJ`vIT^22WQ%mvv4FO#oqp(sBR* diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_pink_lime.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_pink_lime.png index 19dbd4946eed5f8911e1844c70bde98da71f0623..bb8d8c4d87924b550412f1f40bc1626438208263 100644 GIT binary patch delta 360 zcmcc4a)x<=1SbnK0|Ud`yN`km?hw!0 zDW0=UJbSD7|NsBneM7>4ni!M3-CejcE_?}__))I@IhzPKhk)PIgY`hEcuyC{5RU7v zeYw0120SkL8aH^Enc2C;yc`b*iSTGz9ME6NQt|imuR>437cLv5dwq`ZupDb(xidS- zXu`>*6Ks8Lo(cDh7Zm;Y!e*B?^=XEZ#nP^*g}J-7uX$PLI+SoZhlH; zS|x4`!gZBzff_U*Rsc1WWag$8mn7yEK=qjE8X1Hb8d@1xNLm@1L2Ox8(XtGviNVv= K&t;ucLK6Vb4SK8q delta 500 zcmX@Ze4S;21SbbG0|SGGE`RVuMf>{d0G|-orE$eqDyN()n{cgq+QsromntS7FX}#9 z+JC-m;);aQ%N3KGyrNrtVq3gpn!TfI+`}8aqOMj=y-+@Jd3@=j*uurJMISm>ylG#$ zFsATKY5&TEvg_5;KX`{X{M{1yyCiaVNaXF3$k{HQvrRm2r^NsN zLjOf`V>SZa!_2lsg&I$|d#u`%>P z{mbKXl#(@;-Vw3b`g-eDvyx0*5f9fU{6}*XjTO diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_pink_magenta.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_pink_magenta.png index 5008ded16861658f101033115ad711c509ac23cf..c71554338c55669ea2ee9bf0df0b1f41aacf137e 100644 GIT binary patch delta 360 zcmcc2a)x<=1SbnK0|Ud`yN`k?Gk(BfSMSSyxm>6GA?`xoA^$y{yCcnH-~`V)Pwavsd!Hp#}JO| zu6?<@4F)_e`5HHPnVH$S#k?F32#N4$S{%?{%2M(7^RGfr!51zYq`S0G|-orE$eqDyN()n{cgq+QsromntS7FX}#9 z+JC-m;);aQ%N3KGyrNrtVq3gpn!TfI+`}8aqOMj=y-+@Jd3@=j*uurJMISm>ylG#$ zFsATKY5&TEvg_5;KX`{XUH0pD+OOMgw`QB&>aDh`cG#``|NsBB zC;T7lfR15I@^*Jo*X3WKJaM{Q{WDfk4kH%#2fK}cQinZV977~7t4=r=#B9jp{PxJP zzTLa8w23h_n%&&=|9@x7g9VjRy>9G`30^ZT>^&!~iE+5%cY2fF^3rO%*%nJ8ydC+J zO6wM~?AjY=(s5NLa6Mbmz9WlH9?Ed84Zg7TNOkG@Me@IH%Dh>v;`64sQ81b{u72NH zO{2D;Q@)MCyYEJ22VcMD)EJ^-v6TZS|6Kw9ry~CU|Ns9!6deQ9$C%{p?!qm9{m6ldALZ(wvx#tX2>4AsSPzs+@^oPnpnA-7jSNBz4P~qhEUXO8Ahs;4Xjul- O#Ng@b=d#Wzp$P!@Y{d0G|-orE$eqDyN()n{cgq+QsromntS7FX}#9 z+JC-m;);aQ%N3KGyrNrtVq3gpn!TfI+`}8aqOMj=y-+@Jd3@=j*uurJMISm>ylG#$ zFsATKY5&TEvg_5;KX`{XuO$LsN(4R@34AUVcwZ>+u2A4pvB3ZT zLjR3h0(^k(VNCLNchT6pVe6)ev*hZZv5ImSvA93jZ3L7$;_2cTB5_%DLSXP=1D@u$ zM~?MfpLR33*&)Gu_r?GJ`A_z;-(7zB^IpVC~*Cd7G#Xhridc>}jv(ELd3Hh$|Yi0b|gZsP>9kCOW*ckdC z`sMLCO34~a?}%7zeZ6(7SxKg@h=*&F@ot03p>3xmB%ZuD@uH-8-?z2j>*{lETitkA z{@~@e`h)w{eczY=J3;;~`wGLZ1uipKRa=CzqFRqL8%_Gee#e%-=_==awaEsI;!;Ms z2Bx}(W+8?qRtA<eoOCdsa*CZ~k9g$ovJP?*4YjZKU( z+dM_UgpJveL!Lw8!GWu1kM7mIdbBlhm3K$CxPXxk@Ap$tQjeZB1~3=1G34&#_m{m_ zTnw~LwZt`|z9c2FB-JXpC>2OC7#SED>lzsA8XAWfnpznc1Ch3Yft7(llJdbos1AsR z-29Zxv`X9>gzGBb0ySs=t$=7K$;?eHE=kNSfa)>RH8Kb>G?cM2u&^>ThuFfv-!BBz O#Ng@b=d#Wzp$P!GP<5>U delta 463 zcmcb_e4S;21SbbG0|SGGE`RVuMf>{d0G|-orE$eqDyN()n{cgq+QsromntS7FX}#9 z+JC-m;);aQ%N3KGyrNrtVq3gpn!TfI+`}8aqOMj=y-+@Jd3@=j*uurJMISm>ylG#$ zFsATKY5&TEvg_5;KX`{X619~jYAcFVmldn6C{$fqsJf(BZTbKI zLjQRq;^KhrVNCLNchT6pVe6)ev*hZZv5ImSvA93jZ3L7$;_2cTB5_%DLSXP=1D@u$ zM~?MfpLR33*&)Gu_r?GJ`A_z;-(7zB^IpVC~*Cd7G#Xhridc>}jv(ELd3Hh$|Yi0b|gZsP>9kCOW*ckdC z`sMLCO34~a?}%7zeZ6(7SxKg@h=*&F@ot03p>3xmB%ZuD@uH-8-?z2j>*{lETitkA z{@~@e`h)w{eczY=J3;;~`wGLZ1uipKRa=CzqFRqL8%_Gee#e%-=_==awaEsI;!;Ms z2Bx}(W+8?qRtA<C3?CzhHzYW z?aSqDFyL{?*SNvU%*@U$cB-vGRYO5z2CK}2=|N0;{#E|nv82Gn=0>lVN)3z5UT21P zzCn^F5+{F0G|-orE$eqDyN()n{cgq+QsromntS7FX}#9 z+JC-m;);aQ%N3KGyrNrtVq3gpn!TfI+`}8aqOMj=y-+@Jd3@=j*uurJMISm>ylG#$ zFsATKY5&TEvg_5;KX`{XIjTytRh4F`D9%t(oTaMt|Ns9DZO)e% zco-NMlf2zs)S@_MY@Ik=uKpRTD2EY?`-9y^Kt~?(ba4!kxU4$iV9*f*9_P15j`eNV z%|5Kh!sLDF+yDBBJTfN!i!Z)VVDQltey;90X)1Tet<=bCPdDYA4;OA1$<{pKxa6Gv z6o>8CXR~dbrTpry!@BJeCXo`kEAqK^O{-Y{F7%7D{p{x2sV$wgdIm|W51g*wZs~d~ zz-y;wK~}$ecJ8ZtQ5qAvSklW9)mHONH8ePJapJ|7?7v=Azps_~ZKq}}BV7OPkNBMA zp1OC>Q|8}gz9Qiopme55$cfW*?V-<%Gd+K@-r(TRD>M%{1oVz-iEBhjN@7W>RdP`( zkYX@0Ff!6LFx53Q3o$gYGO)BVYmi~;JffL`!)jwww;pPzVn|iPwD3#>t;uykl zJvl*yg_)7fQB74LKp;gRAR!?^L?j_aASr?2qy&>>S5uQyLfgUx3pOZBV7$gA#+YrM zB4EPC?8qU{A@ShA)w4(U>RvtCnz+ilqg!0SNQd|PsVJ#O&l&@mi`f`*ck=to-YYH! z+NN6K8c|=8l30>zm0Xkxq!^40jEr>+jCBo-Lkvx=42*$D+rYrez#vKaU?5ZnL_=G=Nq>G?ZlKrWThZ<`zKpnCTiBgcusiSQ%JY8JaylG#$ zFsATKY5&TEvg_5;KX`{XiG`wqcg6ls09wtM?rH**IIEF}ER-F(SeAs}e`R$Qoeb=YmOm22a@ZNp#|9}3Iz3g|F zUw-*Tfx$;p__?^}q^aB;w-RSPdugD*-d(s|q*(KWgigQu&X%Q~loCIE__!7Ts) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_pink_yellow.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_pink_yellow.png index 3c20b58811bfb0fe659cc0fd0aea16a447b41401..05915e9523b1f8e323f962b8486a5f254de0787a 100644 GIT binary patch delta 366 zcmcc4a*26@1SbnK0|Ud`yN`kf<`5*SWOFiCbbH8~};EnKi*gTe&HYiweS z+2$z%CTz@(9P%6z4-Q;Cdvvev)uXM6tGqk9#RZIXc)y>Dl6v&4F@U+4jUjg@zrXCg z;$om}swJ)w^(85ZC8<`)MX5lF!N|bKSl7T<*U&h`(A3Jn7>KkD46F{d0G|-orE$eqDyN()n{cgq+QsromntS7FX}#9 z+JC-m;);aQ%N3KGyrNrtVq3gpn!TfI+`}8aqOMj=y-+@Jd3@=j*uurJMISm>ylG#$ zFsATKY5&TEvg_5;KX`{XKgU&mA5-~pMETcIm2ZcXzaCQlc~s^9 zf1&?1%qwGo?qN*wc6ZU(yJ735iL>PDpRtN^7_qoN*lh%qI^yZ#7$R|5bwXh9VFRA# zw?~fkU7vO{x!EDXd-uiv|M^e$vfo{P`Q;Y{1|Ln~=i;7|rgC@ON}ToVrGfr>cj0!C zV$BndOU|i#EjWEUvN__c;MXLDzopr0F$fG A?EnA( diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_purple_black.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_purple_black.png index 59c9f08ff04608ad30d0af1e4466fae30b94dc6a..514dc425eff463fd5789027ad7337ed32e2fdd56 100644 GIT binary patch delta 339 zcmdnOvYmN?1SbnK0|Ud`yN`klm&Do*i}EGki3DKD=qC#UrP|NmLS z@+*J}8I!!-UDy)ScGOP1FIWGZO@y06&~nnpmq4j7PZ!4!j_a;{7X=#(IGlskGhQ)W z<*i!BAU)-8c;=Dd``48xSO?4qDX?}`&tm7wc4U5cc7jZbx8xH)&uc~}e=)3YIj{5K zVV+!K+lI^{PmLMx{-6DQjLAKYk8$44yEQ-?R7+eVN>UO_QmvAUQh`)GgOP!ev95u! zuAy;=p{bRDF%W4R7+4t?Bq<*ZMA4C(pOTqYiCcqkUFBP#1`W6sC7HRY#U+Wk1yDU^ jx<&>ehK5!K7FLGl5K9CY`1^%`nixD?{an^LB{Ts5Q`c?@ delta 464 zcmdnayoF_g1SbbG0|SGGE`RVuMf>{90G|+7f2rbB#mPwu{b@>5QxqqrC{Bu(?@m(a zOIDZ=AXS>GILS^V%3d_aUNqWHB-&ay%vK~aRdGsyREe)-p`T=7vD)%N)g``?1&IoM zfl{UEO4CZzR+gx(NK>4WsL(4fuPiUGBqyiz|Nno*vgSoV%Ndir-CdMoQ)AXl?3Sy4 z#wyBT#A@)odkIi#v!{z=h{Wa42@m~P3^`gFn|yZO-Rt^(%dN}r_Wk$1mGMXMt)ziNqVL`h0wNvc(HQ7VvPFfuSQ(ls#EH8cw`G_f+Uv@$f+HZZU{+` diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_purple_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_purple_blue.png index 5f9a5ab54e0e21e7c4f4a65b6f23513dcc15e8d4..ec73c72ae9cc6d0215e6219d6da71510ab9a2575 100644 GIT binary patch delta 350 zcmdnXa*la|1SbnK0|Ud`yN`klm&Do*i}EGki3X>2;%$Yhq0$qXZt znTE#G4UMP$|Nmd`^1lk8CdMRhcNeaV3tz&39L@rd$YKTtzWpG~Xu%q+0u*E~@$_|N zf6gYt%^_$x>ElbFP@<=cV+hA}*S=id1_K_Ke2p8t%*^cEVyD^~R5g4RG-j~MJeVHD zwC7*t-yKT|Ol)rSda2Z~$n14yc;_1=c_LxbiFsOLn>&vRTS(SavC0=uE6P!_Sn74r zDf;xithj%(zxQ${SMWWal*wN=`8=bzl(DXXv96(Uh@q*KfiVzi8yHv_7$hkl44lLy z9)(?2xUTXo(5V_Ft`Q|Ei6yC4C7HRY#U+Wk1q?<8MnFAgx<&>ehK5!K7FLGl5EB{r S`-Omd7(8A5T-G@yGywpknQhnr delta 456 zcmX@dyq9Hy1SbbG0|SGGE`RVuMf>`k0G|+7f2rbB#mPwu{b@>5QxqqrC{Bu(?@m(a zOIDZ=AXS>GILS^V%3d_aUNqWHB-&ay%vK~aRdGsyREe)-p`T=7vD)%N)g``?1&IoM zfl{UEO4CZzR+gx(NK>4WsL*R{I@{QEmXXO!Ba`X>|NmdI@sbqKe#RtkcNb+X=A;~} ziPPokpRtN^7_k~W?_L6w+v(}z7$R|5HGt9YhyjoHt(F}--{v)1YkXO7``>>LrH+)F zn}njd1g8hNzU~%XeZh@wzs~7hG1p$_7ISMwL?^d$IK?j&SeIY!AR>3B!s2Gx@uo)w zJB{u+RyOv_UF4nrL&|aA)lm&Do*i}EGki3S>&!!=%!xas-Ewv zp69Ao;HLin|Nnh)MiM|xj7i?^E?gNGzJvieoCO|{#S9F5`$3q|f;CtLD9B#o>Fdh= zoK1wAL(p>4$Cp5%L{AsT5RU7vecpl%20Sj?HC~7@v$D(TEHT(C&gm;-(7>#6MPHHU zLs8|=H$D$CDmF+@_4vVIQPs|HXZ8}K2?tds+J@?+33sa(82$LdW%o(v=M9$vuc?b# zw@ur7wen~FJ#)QOc7C>1JC*-TKF=sFWvpvptZQf-VrXh*U<^ds1_o9J21&{X11B+w zM`4#0uB&_tbgD*)YeY#(Vo9o1NoH#6$-E Rej%V922WQ%mvv4FO#r+$ZS?>E delta 456 zcmX@dyq9Hy1SbbG0|SGGE`RVuMf>`k0G|+7f2rbB#mPwu{b@>5QxqqrC{Bu(?@m(a zOIDZ=AXS>GILS^V%3d_aUNqWHB-&ay%vK~aRdGsyREe)-p`T=7vD)%N)g``?1&IoM zfl{UEO4CZzR+gx(NK>4WsL)&Fu2JBoUg)Ng@2dX)|NrVIjj}-d8I!!-U6i$$lX9#k zPM52H#wyBT#A@)odkIi(r>Bc!h{R>x35|J&4LDp5wiPb(l-gDH`B|Rdr~mSn?%J0w zGd4Llbp)SU^z-bb)C|Su_+^>%^gb8G-fa?k78Ie_bYZs2p-*+}E)Ng(v`=1J?&HBX zz4arbl=P1^f>%GZz88Cv?K#J!t=VY1m(|2}h0g}{UOO92wm#py)vRI*+k^u=v%Ve= zIl4M1l+C%Rd8%{W%J2Jlza?8QEw}om{jEO3KK1^$&2pRB4^BOMgW-GOjFmk+S4(OR zxGn#~==hnBqdB;S1?UUa64!{5l*E!$tK_0oAjM#0U}U6gV5)0q7Gh{(WngJ#XsT^s kU}a$N-GPa}W^yc}xEgl(Hree5fCe&ny85}Sb4q9e0H_13Jpcdz diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_purple_cyan.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_purple_cyan.png index 26d56ecd237c22d5c491a52256acac94ce345b9c..3000a92954f5d4d3f108f1cc26b8ed0b656fc545 100644 GIT binary patch delta 384 zcmX@Wa*BC^1SbnK0|Ud`yN`klm&Do*i}EGki3Db_Yov~_}LbDwBS zzi3nM|NsB*OtxPF)WMkK?e4<)@#fMuKn`btM`SSr1K)lSX0%`pRsjmKmw5WRvOi}N z;pPyuob>S}P$!(+F%so&Du(p*p`Xlcg6wW;~0 z`v1@VKE|5p!FM_0;QN0-%T!BTBT7;dOH!?pi&B9UgOP!ev95u!uAy;=p{bRDF%W4R z7+4t?Bq<*Z1Z&8F>B!Ab$xN%ntwXr3@-0w@2Hc90%-q!ClEmBss2($2BZCk_Ln{Ld YD?@XLEe!nqLO?wXp00i_>zopr0J(H`X#fBK delta 503 zcmX@be1K(w1SbbG0|SGGE`RVuMf>{v0G|+7f2rbB#mPwu{b@>5QxqqrC{Bu(?@m(a zOIDZ=AXS>GILS^V%3d_aUNqWHB-&ay%vK~aRdGsyREe)-p`T=7vD)%N)g``?1&IoM zfl{UEO4CZzR+gx(NK>4WsL(6cHc_l~f>=wxXmg)vQ}6%(|5?nXf27u?wP>zv*dbM0+qIk#3s zbaE?)Q~VNvZP&FGxcJlV%&E`WpX6A$Bd5naAnw6l_macxcJ342uPwNEf+baMZiynl z<5M23(uOTPziWFY?&xKlaDXT3>*!N|bKNY}tr*U&7)(8S8X(#p_O+rYrez~H+Be+`n3RIA+ll+3hB+#1?sw;up% OVDNPHb6Mw<&;$T?2C#_$ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_purple_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_purple_gray.png index 235c9b2a5a25c260901ba03d692103e02b718270..d94151a532ddb02f62dabc4c236aefd206af1dbd 100644 GIT binary patch delta 358 zcmdnba+rC71SbnK0|Ud`yN`klm&Do*i}EGki3Y3Jl->*#9h;9}$8 z^8f$;sfTKvfXW$@yxm{XdU9X1yb0x3`gh?V{%b2Niv{v0G|+7f2rbB#mPwu{b@>5QxqqrC{Bu(?@m(a zOIDZ=AXS>GILS^V%3d_aUNqWHB-&ay%vK~aRdGsyREe)-p`T=7vD)%N)g``?1&IoM zfl{UEO4CZzR+gx(NK>4WsL*TY)>MJ;PU_fe>3&f=0GPfCV9KFxu|Sm z`#E#sM7jEBtfCx7tOn1!mjLBVUIUfyOepXbOKt+__P@kO`Fp?_6uE)Ng(bWfH| z4^e49eXfFeE$^P~9ce!fr1O7Ttl}r7?KrbqdF>O$6MLHcg5D|k{;hhuS6^>0vx-4; z+Fzs4kISx1IXK}#!qW-)QpsnIzP0;*OX7?1zihh&M|02o{P28-aLmmf-h%k{nWtu5 z@VU;Oqxn?aQHYP(s!VLM0;5E@k*UO_Qmu0HQ!>*k8H@~!uxn_O-F^V5fx*+&&t;ucLK6T-IjWxk diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_purple_green.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_purple_green.png index f194a4775b67275d60ebecbb2748455549d8ac8e..cec4dce4bf786fa6664689484b6dd1d42ef8a67c 100644 GIT binary patch delta 350 zcmdnXa*la|1SbnK0|Ud`yN`klm&Do*i}EGki38Img#oFg5SEgh64 z9hfB@oGtzT|9^q>O{qXlj7i?^E?gNGzJvieoCO|{#S9F5`$3q|f;CtLD9B#o>Fdh= zoK1wAL(p>4$Cp5%L{AsT5RU7vecpl%20Sj?HC~7@v$D(TEHT(C&gm;-(7>#6MPHHU zLs8|=H$D$CDmF+@_4vVIQPs|HXZ8}K2?tds+J@?+33sa(82$LdW%o(v=M9$vuc?b# zw@ur7wen~FJ#)QOc7C>1JC*-TKF=sFWvpvptZQf-VrXh*U<^ds1_o9J21&{X11B+w zM`4#0uB&_tbgD*)YeY#(Vo9o1NoH#6$-E Rej%V922WQ%mvv4FO#sXsZUz7V delta 456 zcmX@dyq9Hy1SbbG0|SGGE`RVuMf>`k0G|+7f2rbB#mPwu{b@>5QxqqrC{Bu(?@m(a zOIDZ=AXS>GILS^V%3d_aUNqWHB-&ay%vK~aRdGsyREe)-p`T=7vD)%N)g``?1&IoM zfl{UEO4CZzR+gx(NK>4WsL&gdD-)b86PzOxlqLQD|No?yPB($}GbVYvyC`chC*@d8 zoGw@Yj8&Awh}GbE_Y$DoPEQxd5Q)pW6B_dl8*sQBY%5&mDYdKY^Rqm^PygjD-L)@W zW^8h9>Igoy=;zr3uGWz1t-8EGR;;>B4N4L!au{T^=6nX`j5d+{c4& zdh16>R5Y<<3Yt69Yswh0G#W_>*# za&&c2D4TOr^Hk@$mEZUAeoMAqT5k1A`&)g6ed_&ho8>mMADnvj2E+Hl87q5uu9nms za9jR|(eX1MM{{ru3(yy;C9V-ADTyViR>?)FK#IZ0z{p6~z*N`JEX2^n%D~df&{W&N kz{lm&Do*i}EGki3X}#sP)#h7P8?Re! zx@o!os^$7CRvT~p|NlQP|NA$fKE@<(cNcE?>qibud@Wc1oK1wAL(p>4$Cp5e1H3Ro)%l;sQoGyx&hnNj-Yj7{FZ2#*n*{-(U7# zaWT*~)e_f;$xj&tq>Ob9jCBo-Lkvx=42*$D+rYrez#vKaVBlnaCh;ij(!zC>Z-Itr z01YWgNi0dVD#^@EEiOsSEnqM*Faqi^(={>(F*LL?u&^>ThZxDg-!BBz!{F)a=d#Wz Gp$P!4_H3R2 delta 452 zcmcb_e1>I$1SbbG0|SGGE`RVuMf>{F0G|+7f2rbB#mPwu{b@>5QxqqrC{Bu(?@m(a zOIDZ=AXS>GILS^V%3d_aUNqWHB-&ay%vK~aRdGsyREe)-p`T=7vD)%N)g``?1&IoM zfl{UEO4CZzR+gx(NK>4WsL*S@<+k7Ps@jh4pi+;+toC`zu;=_wD0d9Zk=`BC+KyC$zSEfnf!NqpCvqV%~b?2O=)B6iPL z+oRvxmb{f+z!d5+EniggTFWd0iK90oZ=B}u&3%*H^E>(e_6G~@AGj?0e^K)7caLxM zKj^s2ey}Apl5w*}+Ny^aLLMlm&Do*i}EGki3+0)b9-QCpL+0fP1 z*wIn{|NsBzdZv4TIvA6@-Ca08-dy?y$l)yTh%9Dc;M)(vj25iHDnLQ@5>H=O_UCLO z+#G_IlRmx#3MF{DIEHXsckRpNZ7|?*$=A5S%goHqEq1D{K~+ORV@5s81z%0Zxc__V zVuCEB#dnhVMVEzMZCHZ|W= z|Nq(F$5<0R_%25reE$zWDsI#Xk}nw YWoQnug@M0c2&jj_)78&qol`;+04+&*Jpcdz delta 503 zcmX@be1K(w1SbbG0|SGGE`RVuMf>{v0G|+7f2rbB#mPwu{b@>5QxqqrC{Bu(?@m(a zOIDZ=AXS>GILS^V%3d_aUNqWHB-&ay%vK~aRdGsyREe)-p`T=7vD)%N)g``?1&IoM zfl{UEO4CZzR+gx(NK>4WsLf27u?wP>zv*dbM0+qIk#3s zbaE?)Q~VNvZP&FGxcJlV%&E`WpX6A$Bd5naAnw6l_macxcJ342uPwNEf+baMZiynl z<5M23(uOTPziWFY?&xKlaDXT3>*!N|bKNY}tr*U&7)(8S8X(#p_O+rYrez~H+Be+`n3RIA+ll+3hB+#1?sw;up% OVDNPHb6Mw<&;$V8XtX^5 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_purple_lime.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_purple_lime.png index 5e5d883a61048c2a58f9426376048505d7401107..ad2f43e40e98f75296bc58cf16b95ee5b829eeed 100644 GIT binary patch delta 332 zcmX@Za)x<=1SbnK0|Ud`yN`klm&Do*i}EGki3nZH{iZ|NnpWjP2)uni!M3-CejcE_?}__*$<1IhzPKhoI%8k1v5z@t!V@Asp9T z`*L|340v4fHE!@SGqZDxc{v^s65-LbIH13jrQ+}BUxl86FI+ZA_xc>+VL8^oa%Xmu z(S(yrC)oPhJQMC0FDUx)h0QK)>eCD*i=|yr3v+jEU-i2F^S(mH1YW-Vx^+9efL5uN zxJHzuBu;+8$SY;6YhbKvXdGf_YGq&yMA`-hRt5%1$_E1{^D~J@VV4%Jt9%PIM+0I` zNvc&zW^QV6Nn&mRgOPy|P>-3ekwJ)|p_PG!m7zJrNCy6XA)p=xPgg&ebxsLQ0B2!u AH2?qr delta 489 zcmX@Ze1>I$1SbbG0|SGGE`RVuMf>{F0G|+7f2rbB#mPwu{b@>5QxqqrC{Bu(?@m(a zOIDZ=AXS>GILS^V%3d_aUNqWHB-&ay%vK~aRdGsyREe)-p`T=7vD)%N)g``?1&IoM zfl{UEO4CZzR+gx(NK>4WsL-3gTOxm#MD7lWyj>DG+r@LXiRbN<`2YX^vFDn63_J`B zj7i?^E^1L6Gqz5gE?57IRg}Ys)!=#e5}+gZd%8G=NL*H(@X+tD0Z+?Ym1E-Tbxm(8 zOmMu_yYIhtQm_2-_bE5aCv{pZjZxX3afxT;k`0$l&R))piwh54-m)`HYzou#?UOi8 z|6~$rv@~Alwkys+QF4t=PkBJhgT*_|kE-w6HF>RRp-?|d;=A4yrO!?EX9TAdv3tJS z9{t|7A3Ey&neo-xPjVMV;EJ?LWE=mPb3`Pb< zM!E*3x`t*Uh9*`9mR5$Q+6Jx$Rt5&&9r$ZdbmZozWTsVO*8$SdCcFIrPy>UftDnm{ Hr-UW|lJdHu diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_purple_magenta.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_purple_magenta.png index 34e43a8be8a3ea991a63401f848a8df9059a8222..e5f4bb6b8d16a9d575c2339693709b73d24391a7 100644 GIT binary patch delta 360 zcmX@Xa)x<=1SbnK0|Ud`yN`klm&Do*i}EGki3xyye2PP=v6?bhtD zTf5bE)fU@T|NsA=eKx)gsEIMj+uemLq!GOmlU*iTZGc!B4n3v-LArT%;iv#*gSt|a1{#EEH_`+p_bg$159+qPbEO%xn z8BI93bb_s~%`@SC@q(fsU)b!@rasM3vRK*`wJ>+r_EoRzKkqAKOyK3)uUogn3uu*U ziEBhjN@9IUs#S7PYGO$$gOP!ev95u!uAy;=p{bRDF%W4R7+4t?Bq<*ZMCbr&$jwj5 zOsmALLAb8+El`67#0sE>lFZ!H;*!MN0;nD{T_b}KLqjVA3rQ`q0G|+7f2rbB#mPwu{b@>5QxqqrC{Bu(?@m(a zOIDZ=AXS>GILS^V%3d_aUNqWHB-&ay%vK~aRdGsyREe)-p`T=7vD)%N)g``?1&IoM zfl{UEO4CZzR+gx(NK>4WsL;F1e*I4Sb=&RMY_nUv)ppemyS4xS|5tduG6?7jM$RN} zcNf*ej3@agPM52H#wyBT#A@)odkIi(pQnpsh{R>p2@m}a8}PKeRXHZUUe`27;Do}< z7r*V5#r{~-s-NCB+2@GnQ>CAtlhZs@TVtoC#_GNPwr94L>YA;a7KrTFGsWdb+SY`?%O@4xBT$b#Kk(8IL8B&m1p2^I*aJ1M{u_yFQ;&Jm6X+bz?WsE2<@~5hW>!C8<`)MX5lF!N|bKNY}tr z*U&7)(8S8X(#p_O+rYrZ%D~{e1Ah&Qj@bP0l+XkK Dx-z&_ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_purple_orange.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_purple_orange.png index d18c524c42be61e4f50653505008f60c0040e392..974a2c1a841cc8b6c8ee34b8399c0f8e0f01f3b3 100644 GIT binary patch delta 335 zcmX@Za*26@1SbnK0|Ud`yN`klm&Do*i}EGki3`L#sgOELe)BL2_C z{O=3--xctGD&qhD|9`iJi4Ra8W0JSK3%C6BBL^nFmaBixCc@1jXgTTQOQ2Mer;B3< z$Mxg{5f)}fHb*s8g#dvRfq;aB1QC&h6oI4!hLaLZl3h(rP6=%b7cAJIFoE$Jn;2uZ zd5VAu8?z&aJcq=C16R);-K%@`Xlvps?~ZP90V5sW@28@q9zAOeU@m53$lb~BFMF@J z7-*YniEG5N7Xs>G@O1TaS?83{ F1OSw8XxIP% delta 452 zcmcb_e1>I$1SbbG0|SGGE`RVuMf>{F0G|+7f2rbB#mPwu{b@>5QxqqrC{Bu(?@m(a zOIDZ=AXS>GILS^V%3d_aUNqWHB-&ay%vK~aRdGsyREe)-p`T=7vD)%N)g``?1&IoM zfl{UEO4CZzR+gx(NK>4WsL=bhMBqz_z{eti&&2}o3kBX43VbRS`2YX^13uNy3_J`B zj7i?^E^1L6Gqz5gC0GB9Rg}Ys)!=#e5}+gZd%8G=NL*H(@X+tD0Z+?Ym1E-Tbxm(8 zOmMu_yYIhtQm_2-_bE5aCv{pZjZxX3afxT;k`0$l&R))piwh54-m)`HYzou#?UOi8 z|6~$rv@~Alwkys+QF4t=PkBJhgT*_|kE-w6HF>RRp-?|d;=A4yrO!=aX9TAdv3tJS z9{t|7A3Ey%i8!(DX8R;6B>KdAb7@AlaSXvpH mY8x0>85n$b;IEmS$SAIcUAj$n`vG7`FnGH9xvXlm&Do*i}EGki3`MG=5r>>RnJC=X! zT=BMj*_-yIA39h3|NsA;@|JF(KE@<(cNcE?>qibud@Wc1oK1wAL(p>4$Cp5e1H3Ro)%l;sQoGyx&hnNj-Yj7{FZ2#*n*{-(U7# zaWT*~)e_f;$xj&tq>Ob9jCBo-Lkvx=42*$D+rYrez#vKaVBlnaCh;ij(!zC>Z-Itr z01YWgNi0dVD#^@EEiOsSEnqM*Faqi^(={>(F*LL?u&^>ThZxDg-!BBz!{F)a=d#Wz Gp$PyIb#AZ# delta 452 zcmcb_e1>I$1SbbG0|SGGE`RVuMf>{F0G|+7f2rbB#mPwu{b@>5QxqqrC{Bu(?@m(a zOIDZ=AXS>GILS^V%3d_aUNqWHB-&ay%vK~aRdGsyREe)-p`T=7vD)%N)g``?1&IoM zfl{UEO4CZzR+gx(NK>4WsL=bld)23|mG3*3f9zWMwqx0w_N5;>SN#9~{|JwK7y}Oj z17ni6yNg;B$BeBLXUWw+V-@8vVl{Z)y#(mU{hlt4ArhBWCp`2!Y{1jPuS}4@dlK8GSMd@=>*crhoMeLrh zwnx9WEqN=ufGN~tTE3{}wU${15=U=F-Z;(QoBJlY=Xdh`?GF~*KX6(0|DxpE?;hXi zf6#H4{a{OIB;#g{v{er;ggj!Fn*591>ldFfZ^E~n$p(z#QbxK4rn-h^A%-Sa29{Qa mrrHJuRt5&&9r$Y|Co+nwVV7=`-F^TV5)7WMelF{r5}E-1L$uET diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_purple_red.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_purple_red.png index 517fa81a2c9a53fb04fe38b8791ac85ce6bb225e..144216e5fb0612689bb2e3a67cde52d4f2097a22 100644 GIT binary patch delta 388 zcmX@Ya*la|1SbnK0|Ud`yN`klm&Do*i}EGki3IY(7#wu<6R6~$R9 ziZfIcrzkzK1d<(Qf18zl0W^QV6Nn&mRRF9dikwJ)| cp_PG!m7zJr76$%)A)p=xPgg&ebxsLQ0ME*JdjJ3c delta 463 zcmX@de1v6!1SbbG0|SGGE`RVuMf>{v0G|+7f2rbB#mPwu{b@>5QxqqrC{Bu(?@m(a zOIDZ=AXS>GILS^V%3d_aUNqWHB-&ay%vK~aRdGsyREe)-p`T=7vD)%N)g``?1&IoM zfl{UEO4CZzR+gx(NK>4WsL(q{RcW@W(kvCl87hjiRF(e!{~xQ#%?fk^W0JQ!n~Ta8 zwx2U6PM52H#wyBT#A@)odkIi(ucwP+h{R>p2@m}a8}PKeJ#tKZ{avXW3KJYJefxV~ zkh^ZqzR9WgJ=Gpf*_2VYF-0=!#DnRnk<(9C?aj@bDs(LG8~ekujcXpQ4*#@P#V<Nr-_4#Hszikz} zM*`c~U%9Iu`L5J#R-CG>9sYBn;c>fTGmh^&|6qaghv(<&FIqmAd0xln{zi@^+$@>- z&f*y>Tbzx1`6GNz>AM}}ljl%9l>qdKYKdz^NlIc#s#S7PDv)9@GB7gIH89mRGz&2_ vu`;llm&Do*i}EGki3`Tzg_fB*jd{{8#! z-@iY9{`~Rd$Dcoc;+S_Q05vftdAqx?^k>`*ocKbn{yCcnH;16*q>nFwQc0dJjv*Y^ zlM_T(m>Jm|)l?M%1X2V75)u+bL=sX2k`fqBN-#-wH8nXUv@Kk)V1vR0#%pY1jM?TX z0w!$CjvVqF5)TesJ$rPo?$x8MiL1Ojy2S;Iba=m?ijsQttTBMOn2jNKC%?b!z2ah^ zZK@@%5%nc0i6yC4$wjF^iowXh$XM6FSl7@v#L(2rz!-?M4GgRd43d-&210c}H00)| zWTsW()*xJ0`4*@_184+oZUIz}nXZvRh@qj3m4Stop*h4B2L65_pe6=S LS3j3^P65QxqqrC{Bu(?@m(a zOIDZ=AXS>GILS^V%3d_aUNqWHB-&ay%vK~aRdGsyREe)-p`T=7vD)%N)g``?1&IoM zfl{UEO4CZzR+gx(NK>4WsL(sHP*hM`a`_&hrHo15?k@7IyaIbCPM52H#wyBT#A@)o zdkIi#zo(01h{R>p2@m}a8}PKeRXHZUUf1-t!UV@#z5D)aC-urNf1h%*d{U>y(ioNf z8JBogF4=I|>BA9UPhKiCo)$+%e~ZPmjIA&;1)CjVmh z`o(9=oA51XvM!^zl##B1sji_}h@pv*rnTKw;uq8 O1cRrmpUXO@geCwL9HV9c diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_purple_yellow.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_purple_yellow.png index 0cad0ebfd7ad479c7c864c4ede243f1575391058..76746af82cf6d073ca924cfe57769b8f8e5a0069 100644 GIT binary patch delta 335 zcmX@Za*26@1SbnK0|Ud`yN`klm&Do*i}EGki3`RBOG?_Ac^&s01Q8ZyMm9$^RfPb76oG(*gai?hgcO0K1cs9mOp;wqO->1I3l}WdpfG{)8k-nn zwt0$x2^+H`hdhVGg9BI39^I>Z^=ND2D({YNaRDP8-tVWPq#iwM3}7y1W60gf?=O3= zxEN@gYKd#a<_2F5_7ZD3$!V34GIFmN(IlXw(%Y2mucw?IQQ zfQFQ$B$lLFm1O3o7MCRE7BCnY7yI$1SbbG0|SGGE`RVuMf>{F0G|+7f2rbB#mPwu{b@>5QxqqrC{Bu(?@m(a zOIDZ=AXS>GILS^V%3d_aUNqWHB-&ay%vK~aRdGsyREe)-p`T=7vD)%N)g``?1&IoM zfl{UEO4CZzR+gx(NK>4WsL=c8xXSNiDnE`W|2nGj?U3@vc_U zD@<^_)w}P%c2ckW^7kn>%O`bOER9jwpK*z2<&q7TP0n7*IH&7NF2QxdE+#HZ|&lP{L0G|-oEJ^VW1-TY^*)B!7HU-&s1=$8UnO1q( z94YZ&5us2K;Sdp_0Aaya1=(y#@eE1vOiA%ss!B6d6w@Wen?cGX=BO$K2@B0uRq9lf zYm%3dmsggTSCW%c`v3p`!7rJ|ffh0*dAqyF6>%wO138=p9+AZi41D`1P8X_w#wyBT z#J2L?Ejggf8c!F;5Q)p7{RfMf4LO_{7oW;*SId-9Ut9kFzxm-Mmz`%`+{5kR;c~WX zaZSXe6-h^~Mde4oU(UNM>0)+hi?!(dyhC;S3}jkXed5~qR;ahFq5P?M@#15-EBGGI zOU!_U=0?sRoGcK(4;mWbApI?0LO6j=;7H64Q@3UF3r8qbrHV(dgxISg= z*5%hW?%((%;=g;{#{Ulm()K)67d+t>_g_3QPYGH^$4ja^~{bhv7XYeY#( zVo9o1a#1RfVlXl=GSW3L)ipE=F*LC=;`7Z!g1ZT zFPFE$fX5|Y;|4D?Gds7~skR1H4F!!EtTGR#2QlsWSNV6xk^&Q(8@*mCH7qiFof+Qw z21%Ysm~>*Eme}Ubqrw)FHC3$g#nXy%lq{BdU37{*eJ?BS-|X+b+{qPuk0)jF*8we4 zEpd$~(M(A!NwrEYN(E93Mg~U4x(3F&hQ=X=rd9^VK%{M8U}a#Cq@pnDD2Y0 zb(L>{25Nu|1e;fqnVVW%l9*cnHPTGi$RNbf(8|EV%FqI0 delta 449 zcmX@dyozOl1SbbG0|SGGE`RVuMf>`M0G|-oEJ^VW1-TY^*)B!7HU-&s1=$8UnO1q( z94YZ&5us2K;Sdp_0Aaya1=(y#@eE1vOiA%ss!B6d6w@Wen?cGX=BO$K2@B0uRq9lf zYm%2SHl1y3I?Kpprjg0?|NsB{b}2;z?PN^yc6X6yvL>4nlTp(Kij8&Aw zh;8M&TXI0*O`a}}ArhBW{TuyU3^|zH-riHYH}_oSuD##?&({o`w5-J;+U3d`i&NdI z!l6ADQLo>=`1`eCWyF^#(T9FVXV2bn{~Zte!c{d6Z+5sZR(ufq^W2>k9}Pp=KTb|v z^E#NuP(AKtm`LeeECvLrt z$$tCVru@?+?U(DV|0_Pfw{!B;Db3z9zD@H~n!x|G*p!3MyM5Bnz5keA*Kk*My4~;v zI$yQKHKHUXu_VKdAb7@AlaSXvpHY8x0>85n$b;I9E|n4H8Y Xq=sEho9y-jKs5}Wu6{1-oD!M^8E<Bq?NKf_n!C_I=&Twb; z5~B$RRVLbo>ZA#Gs}~sk_`+rPN$2McmjbV;i(0o$+k3V0XZ}5Ny;OF7wpBZo{{Ssh zEpd$~sZU8PNwrEYN(E93Mg~U4x(3F&hQ=X=rd9^VK%{M8U}a#CqPnpnA-7jSNBz4XvaNEUXMIAhvvS|Nk4PiNVv= K&t;ucLK6TxlXi{( delta 449 zcmX@dypm;t1SbbG0|SGGE`RVuMf>`M0G|-oEJ^VW1-TY^*)B!7HU-&s1=$8UnO1q( z94YZ&5us2K;Sdp_0Aaya1=(y#@eE1vOiA%ss!B6d6w@Wen?cGX=BO$K2@B0uRq9lf zYm%2Ka@QzuQ!jMW$ahu$|NsA_`-L$;I~kL_-Cg8ac?I?YIh+L^k;M!X7l_tBV-@8v zVq5v{mK;!cqo<2wh{R=Ge@4F}20Y%EB+7Lgtu>x5xc%?{nbRy2b+jiXTPtOS$vize zsZ+}>XYJQ*U;pho7@||PwyR+IqqDv@?&tHcFI=_9IcK-)V#NosKM#gn`609F@Qd1vuenzS$Ays|js!df4$96Pz<`g2EW&n>Vx%fxEWX2F)?;C$FP`10ZU)U{jH z`-=Bx=vrR?FH=9^@uFn=b+%iV8$8yX?V=!m>Uoxc%rs8b-_^BDFFtYSSup#Q0bQ?J z;u=wsl30>zm0Xkxq!^40jEr;*Omz*-LJUo;3@oh-O|=aStPBjkJMh;)G)zur6jZ~m Us7-eJ0iYrVPgg&ebxsLQ0B>2E+yDRo diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_red_cyan.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_red_cyan.png index 786f025a43b49214e19b9c36f1ca190ae7b24cb6..951b7810aa1dcba85812dfec3a743d99d09b643f 100644 GIT binary patch delta 329 zcmZ3>a*BC^1SbnK0|Ud`yN`kUJwkFO7L`X4B@!$+Lz1Q zV8G*&uW^HynVFqi>{MHWs)mBb43-PNnv8M(_teD%SxCvfaZ?qtW9qx7$naflB~OZh zXNtdQ_st`ZIOp)#?QQC}^tLn?lnGjzv2bl_zN!BIv%inACVKE)jyU-KAJ8t<64!{5 zl*uO;`J{|>4UBaSjYAAgtqhETNZY``%D^B=`C#DW4~*hb*rkQ*D&GQ)(EuBhSdwa0 xl9`)YT#}euz+hxx1k_`uYh(~&XlP|%VP$9mG4h-H|KC7844$rjF6*2UngEXnYbgK# delta 484 zcmX@byq0Bx1SbbG0|SGGE`RVuMf>{X0G|-oEJ^VW1-TY^*)B!7HU-&s1=$8UnO1q( z94YZ&5us2K;Sdp_0Aaya1=(y#@eE1vOiA%ss!B6d6w@Wen?cGX=BO$K2@B0uRq9lf zYm%1{Ynv$6IzgwQG)LN!*boZw!}F*`uFt4;b;iQ==rcF%ocp7V$oD@6R@ zy=0-$EG0E<-Ylta%Gv9S*KU=6zH{<)o5}xneU>kJH`hAS)3Tytxvh~W%jbnP>)I}} zUs{+_w|f8U{oGaB3L5u;&Q~pQjVMV;EJ?LWE=mPb3`PbUftDnm{r-UW|;|{1e diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_red_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_red_gray.png index e14cfeffd4ac9eec53294cf9c0872e1dd91297b3..912f25d598310f9ffe7f8bc49e7cbf78ec7cd02b 100644 GIT binary patch delta 326 zcmZ3@a+rC71SbnK0|Ud`yN`k#9FpmN3}Z+91twtG{nCf<~*f6gYt%^|d4_JUxbRE(#KV+hA}*S_0=4GKIg z{MrvTFm7Q!CMJ}_;I)8d?R^RNyMJ=z%!OI31m}b)3mY;w8Y(b;Up7N0rAYIMk8uCb zBad0{$k^>|>i z6eE|Ev95u!uAy;=p{bRDF%W4R7+4t?Bq<*ZocxYaJPNzCa9!nFpivrdqe?P!Q;SOy ra|;-Z42*z!%yf+mLJSS93@oe+Eg(jIbN~MvsE5JR)z4*}Q$iB}@!)G4 delta 441 zcmX@iyqaZ#1SbbG0|SGGE`RVuMf>{X0G|-oEJ^VW1-TY^*)B!7HU-&s1=$8UnO1q( z94YZ&5us2K;Sdp_0Aaya1=(y#@eE1vOiA%ss!B6d6w@Wen?cGX=BO$K2@B0uRq9lf zYm%3-b8@qFbhUGIwRLc@ad7$n|No;CE*pT>GA4PuyC`hVwrv1%I14-`PM4^E#wyBT z#J2L?Ejggr22U5q5Q)pW{5sOYdGm&OgSeoncHgI@ zlP;pleb=h2tLkkNw8Zv?x$X%5_)P81d-b;FfY5o0Wpfr?6!@@ikAZ$x4bRoYKPfY{ zeym!?=G$5`%lQJ!t3Z<%VQQ>q>#tk7r9ZMs515nI*p$yK!)&x*;lr0JS3b1gbnRB> z?b`pBqdx7Pw^@F|k=(a`Z@e!RU$!@O5=Y8Ho$%%d8%i{0-hVCsLXbQ2_SM^y6&NML zjdTr6bq&oz3{9*IEUgSpwG9lc3=FgN%v|(o;Qta9C8eGu)ZI z#Aw1nm5H{YI%&e)>IFtWzHr%n()oGArNC?IqSkHG_Fk?0nSak*FO{92ZPiZYKS0Y= zOI#yL>QfR+QmvAUQh^kMk%5u1u7Rc?zsg;2-5NR72SQ!{3DIW}k=>TiU%}>cp ztHiBAxUTXoP=f}@3b2Nf%-q!ClEmBss2($2BZCk_Ln~`M0G|-oEJ^VW1-TY^*)B!7HU-&s1=$8UnO1q( z94YZ&5us2K;Sdp_0Aaya1=(y#@eE1vOiA%ss!B6d6w@Wen?cGX=BO$K2@B0uRq9lf zYm%1<$(0GtmI=<03CfcG|NnpYrA;${b}}Y;ySvD<@(Sz)aySb-B8wR&E)cDM#wyBT z#J2L?Ejgg@Mo$;V5Q)pW{)~P{40yaRNtEk0T5CLAaQol?GpAW5>S#|&wpPjtlX-e{ zQm2+%&f2frzW&>FFhr+nZCAnaM`wL++|TD>U$|uk3!H+ZZ&+eJbC)blI>nQ5G=zpHDRUVP%tvtafq1G-+d z#5JNMC9x#cD!C{XNHG{07#ZmrnCcpug&3Mx8CY5wnra&uSQ!|6ci^vqXqcSLD5!>A UQJd`c13*O#p00i_>zopr0N|{fHUIzs diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_red_light_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_red_light_blue.png index ec2be46d55188d693d7f484b206a3fc1af765580..e685237e12beb4a68d7e35d5a7d36c5e94cff66c 100644 GIT binary patch delta 366 zcmdnaa*26@1SbnK0|Ud`yN`kqibuyf0V(oK1wALukS51;Ie6Bu^K| z5RU7~2_h`ajBJi-stN%DDFOir2?-)12`K_e2@EGCm?XQJnw%2a7A{z@L16;pH8wHE zZ1WTW6Ee1H3Ro)%l;sQoGyx&hnNj-Yj7{FZ2#*n*{-(U7# zaWT*~)e_f;`jV8yl2ohYqEsNoU}RuqtZQJbYiJx|Xli9(3`E)n237_JNy-NUp*kQM za`RI%(<*Um5U#6y3)G+iv;v}`Br`X)xFj*R0IJ7K*T^8m&``$8z{1MV0%FTI_y50v PnixD?{an^LB{Ts5=J$5X delta 430 zcmcb_yq#r&1SbbG0|SGGE`RVuMf>{90G|-oEJ^VW1-TY^*)B!7HU-&s1=$8UnO1q( z94YZ&5us2K;Sdp_0Aaya1=(y#@eE1vOiA%ss!B6d6w@Wen?cGX=BO$K2@B0uRq9lf zYm%3--g4V|^DV25H>@|`wAygZa{X1SO*j7k|F8Ms;vS&oj7i?^E=sYfF>5BylB<8l zD#~HRw({LAIiS=wPZ!4!iOZ_~-eJs!Jey^?Q-yeRTLMn_oWApa(vO2q{&6RMb*zXi zoTBcnwn}2-)@!$~{r=1ryz#|WtwVFW#LW}y_ZrBwtop>Y@vTsATSNI%>EOV}wJZ1@ zv!4z*m~LvCVfEy)Op{tb|02ijMw%Nccc1mO6uxfR{K$k`q(<_A!~{lO-t#`b{QswI zU7x(Rv|i@;ygg6UU%t2culRi5{p*!;PHJ!EPdpZF*6F}^s?d~!?{v$gzkB~Nef-Hi z^X^a4gOd#y#ifjN4NP?n%|Z-KtPCuz3{ABS46Fa*BC^1SbnK0|Ud`yN`kgj3j?r!SrZ0PE0 z?C7Zf|NsAzd2?ieIvA6@-Ca08-dy@-;!U~w=WHU}96}3bF9-%oC3w0xhHzYW?aSqD zFyL{?*SNvU%*@U$cB-vGRYO5z2FnFsO~$zYd+K6>ETrV#xTy-+G47LEJ?L0 x$;?eHE=kNSU@$T;0_ri-H8Kb>G_*3XurjoO82Qcp|8Jlk22WQ%mvv4FO#qj~ZRY?0 delta 484 zcmX@byq0Bx1SbbG0|SGGE`RVuMf>{X0G|-oEJ^VW1-TY^*)B!7HU-&s1=$8UnO1q( z94YZ&5us2K;Sdp_0Aaya1=(y#@eE1vOiA%ss!B6d6w@Wen?cGX=BO$K2@B0uRq9lf zYm%4g>1ponZtCi4?Cfml=&1ky|NnQkD=t858I!!-T@*HF+cp3>oCO~Bk;M!QeEUI| z(SkKt1t`j1;_2(k{)|f+ZuVYd|p_yuI)1W zrG+VVtM|X&&t0Xhpm87QeAN=yh?11Vl2ohYqEsNoU}Ruqq-$WRYiJe_VrXJzU}CkWnl2#fxiYtM{a&fW?ChZ4m1sIvfB>;H86O(`njxgN@xNAWLK#+ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_red_lime.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_red_lime.png index 21b3f435fcfe5fef2b26fd0b9c51a1ab61a7b79e..9eaa8fbf166b036611cae85d38458a4c85976577 100644 GIT binary patch delta 360 zcmdnaa)x<=1SbnK0|Ud`yN`kA%-qXb~gyXtv zUoLNh0gp?*#tmL(W_E5dFUJEyB0QQF2lSV+RQ&z?tI$*Mh06x%UY{d8EXNvH?#xay zns9RI1Y2L5XTtsB1w}u;u-T>v|Njlt#Ng@b K=d#Wzp$Py{t#~Z} delta 467 zcmX@Zyq#r&1SbbG0|SGGE`RVuMf>{90G|-oEJ^VW1-TY^*)B!7HU-&s1=$8UnO1q( z94YZ&5us2K;Sdp_0Aaya1=(y#@eE1vOiA%ss!B6d6w@Wen?cGX=BO$K2@B0uRq9lf zYm%4A-z|~9OCooNMBXlmobBQ{+r;yBO8o!-Kig~KBcSDsN#5=*O0lUiYbH*YtAEBS z%3;K|^4%>tpwu=`7sn8Z%c}m~Va$d+n`OCEg?MyZ0#5jxzVm<5kAqJBaVLIttcWa} zqVBD>N@C;IYqzic{>&D<@x@lHLvy>t%@gbQ8pyP)`oy*Itx#`UL-|wb;K0YVEBGF> zpAI>gZfcrg_2jZllUhLkBFF7Unj0#2pRKnPzHZt4$b?&@M)HBg1V&!o^FF@(|EFzT zpS-rTUgr3`Jx|nMzPI|X_y>j(YH#IFJQi)%>A-iY(3FGkbjzf_d;c+g{K-A@ z?oZK!Krg74xJHzuB$lLFB^RXvDF!10BO_e{Q(Z%|5JM9y14}DIQ*8qSD+7b?4*WF? fHpn`1^HVa@Dsk&*lihv*Xa$3(tDnm{r-UW|Fgd8R diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_red_magenta.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_red_magenta.png index e20bf701cb93c71fce160f92e5d046e54223fdbd..0439f8f9dc3e587dd09a2959f3f1ce9f6bf8ef9b 100644 GIT binary patch delta 360 zcmdnYa)x<=1SbnK0|Ud`yN`k0X~BJS@i=SnkYD zGMaF5=>%I}n`grP;sr%NzOdP)O?{f7WU;g>YGLlK?W9 znO2EggK%BtTc8FFh!sE$C7HRY#U+Wk1yDU^x<&>ehK5!K7Lrzm77$y$x&QwS)WqQF L>gTe~DWM4fMKF7C delta 466 zcmX@ZyqRT!1SbbG0|SGGE`RVuMf>`+0G|-oEJ^VW1-TY^*)B!7HU-&s1=$8UnO1q( z94YZ&5us2K;Sdp_0Aaya1=(y#@eE1vOiA%ss!B6d6w@Wen?cGX=BO$K2@B0uRq9lf zYm%4QWxsx>{krXTYqr^~-fFvQhuzx$|NrYA+TsbcnK8-R-9_<84zC!HGjW!5{WDfk z4kNae?{3Kf1-5#+IEF}ER`vG|V>aa3EX$p$CUHy1NpYspcYD>kl7;H}DYY(F)>xeC zRuvBIx$$l9+vx1|(mqEQU0uadu66HD%iF()3ItZ2(mt}y`;7_99?g6o*WUhhw|eL6 zIJ3rIy|Uot1pmd{WsOxLyt}44HunCmt?!w*qfby|dE|lzw;9~qOENMl(z2?4^q(>9 zw|rhDbKGm*r`ccX=lY-6d2QD7LbdZ(>{=xAZ>lg^Y8=0+a6?zv>)ZEV?C-U?dyLuI zRe(NFEpd$~Nl7e8wMs5Z1yT$~21Z7@2Bx}(W+8?qRtA<sNG3IPHs0s#pL2_hm1DFR6e3@0U+B)giLoD$j=E?BTZVFKedHZjI* z^ArISHfBc-c@BvO2dxt=(bmLO-W}cI0!BK#-%mwJJ$lv{z+BA6kh_!LU-n*c zG0-;E64!|Ol9a@fRIB8oR3OD*WME{hYhbKvXdGf_YGq&yMA`-hRt5%1$_E3XIv^Ty z^HVa@DsgKNuB&_t)Sv;h0-~WLGdH!kBr&%Ds>e*%$RNbfP{zu@!phJBV#_!8|G$Bn O7(8A5T-G@yGywo%2z0*y delta 430 zcmcb_yq#r&1SbbG0|SGGE`RVuMf>{90G|-oEJ^VW1-TY^*)B!7HU-&s1=$8UnO1q( z94YZ&5us2K;Sdp_0Aaya1=(y#@eE1vOiA%ss!B6d6w@Wen?cGX=BO$K2@B0uRq9lf zYm%4wS|aeJMBrnQz~^Ft_k{xQ3I#qD3;h58-*@p`d7$NtN#5=*O0lUiYbMT;tAEBS z%3;K|^4%>tpwu=`7sn8Z%c}m~Va$d+n`OCEg?MyZ0#5jxzVm<5kAqJBaVLIttcWa} zqVBD>N@C;IYqzic{>&D<@x@lHLvy>t%@gbQ8pyP)`oy*Itx#`UL-|wb;K0YVEBGF> zpAI>gZfcrg_2jZllUhLkBFF7Unj0#2pY^pAzHZt4$b?&@M)HBg1V&!o^FF@(|EFzT zpS-rTUgr3`Jx|nMzPI|X_y>j(YH#IFJQi)%>A-iY(3FGkbjzf_d;c+g{K-A@ z?oZK!lMNWfrHph9Omz*-LJUo;3@oh-O|=aStPBjkJMh;`PGl5U!!F$>yZrz#02n-7 L{an^LB{Ts5UgVxl diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_red_pink.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_red_pink.png index 99c5caef5cc1a6041224cd3d0823cf445d005619..07e0837d17462b8fe61fdef726ed0a16c18f84b4 100644 GIT binary patch delta 366 zcmdnaa*26@1SbnK0|Ud`yN`k`nX951lLi|NpP|>zfKtA7hfYy9>Ac^&s01Q8ZyMm9$^RfPb76oG(*gai?hgcO0K1cs9mOp;wqO->1I3l}WdpfG{)8k-nn zwt0$x2^+H`hdhVGg9BI39^I>Z^=ND2D({YNaRDP8-tVWPq#iwM3}7y1W60gf?=O3= zxEN@gYKdz^eMw4UNvc(HQ7VvPFfuSQ)-^EJH8c(}G_^7?1|n?(11kfAB;|vFP#q8r zx%nxXX_dG&2-j7<1!~X$S^?2el9`)YT#}eu0M%orYh(~&XeeW4U}0rw0kP$q`~TlS OO$?r{elF{r5}E+ulzArr delta 430 zcmcb_yq#r&1SbbG0|SGGE`RVuMf>{90G|-oEJ^VW1-TY^*)B!7HU-&s1=$8UnO1q( z94YZ&5us2K;Sdp_0Aaya1=(y#@eE1vOiA%ss!B6d6w@Wen?cGX=BO$K2@B0uRq9lf zYm%4w+`Z~k*UI;u%RhFleA}_?P5aUhoh$zT|DU;V`7WU4j7i?^E=sYfF>5BylB<8l zD#~HRw({LAIiS=wPZ!4!iOZ_~-eJs!Jey^?Q-yeRTLMn_oWApa(vO2q{&6RMb*zXi zoTBcnwn}2-)@!$~{r=1ryz#|WtwVFW#LW}y_ZrBwtop>Y@vTsATSNI%>EOV}wJZ1@ zv!4z*m~LvCVfEy)Op{tb|02ijMw%Nccc1mO6uxfR{K$k`q(<_A!~{lO-t#`b{QswI zU7x(Rv|i@;ygg6UU%t2culRi5{p*!;PHJ!EPdpZF*6F}^s?d~!?{v$gzkB~Nef-Hi z^X^a4gOd#y#ifjN4NP?n%|Z-KtPCuz3{ABS46F0M z@sNG3IPHs0s#pL2_hm1DFR6e3@0U+B)giLoD$j=E?BTZVFKedHZjI* z^ArISHfBc-c@BvO2dxt=(bmLO-W}cI0!BK#-%mwJJ$lv{z+BA6kh_!LU-n*c zG0-;E64!|Ol9a@fRIB8oR3OD*WME{hYhbKvXdGf_YGq&yMA`-hRt5%1$_E3XIv^Ty z^HVa@DsgKNuB&_t)Sv;h0-~WLGdH!kBr&%Ds>e*%$RNbfP{zu@!phJBV#_!8|G$Bn O7(8A5T-G@yGywovX>%d~ delta 430 zcmcb_yq#r&1SbbG0|SGGE`RVuMf>{90G|-oEJ^VW1-TY^*)B!7HU-&s1=$8UnO1q( z94YZ&5us2K;Sdp_0Aaya1=(y#@eE1vOiA%ss!B6d6w@Wen?cGX=BO$K2@B0uRq9lf zYm%2KQCnG}wxURNS+UxRLe-^(s!NL1mjD0%zqo!fFVJ$vByV>YrP$P%H4|sa)jwku zf}i(`nyWmSLgFlIxZ&9dC7LOi-H0VjM;-}yi3$3Z9mxD&rRRzwy~ zQTJ9`C9!eqwcFQze`X8b_+qQpp}Ae+=85%t4P;tYed5~qR;ahFq5P?IaNy(G6?~7` zPlp^#H#N<$dU9E&NiCp%k>hqF%?*{i&-z*lU$<<2WWp^{Bl$pL0wXW)c^_Z?|I@av zPhMMEFLQj}o+s)r-&_4xe7^7g^~yOXwYTyo9*Z{Xbl^KxXv)ENx@FSez5kd#{^Xu{ z_owK=$p(z#QbxK4rn-h^A%-Sa29{QarrHJuRt5&&9r$Y|Co+nwVV7=`-F^TV01Te4 KelF{r5}E*RRh+#5 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_red_white.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_red_white.png index 4d3bd4e9d962c9f906fa3af289827e093aedb299..9dafe38ff394ce81e6baae5af14d9c91af1a923a 100644 GIT binary patch delta 363 zcmdnOa-MmD1SbnK0|Ud`yN`kLW43vU zfC(G3BZoYP#DfD@&mP^Yd-Z5*;wtZsZgBx49p3M!qNE-@YYbp6W@E_R$?q?Fueca! zn`((`M14t0Vo9o1a#1RfVlXl=GS)RP)-^N^F*LO@Fa{!R0|P4qgCymHflwU~4Y~O# znQ4`{H3-*Lz6EN~09pajP?DLOT3nKtTL9H#rfXynVrVF1Wnf`tXaTY1oBRLYKurvu Lu6{1-oD!M<_w9Nf delta 410 zcmX@lyoF_g1SbbG0|SGGE`RVuMfolPt;$&xB9R6eBb@+ zm2*yNZ{<%s7H!t)z;~+9l!Nbd%cQ@1|1o|1$vyM#Ptk*ubs5E_jC2i5bq&oz3{9*I qEUgSpwG9lc3=FAc^&s01Q8ZyMm9$^RfPb76oG(*gai?hgcO0K1cs9mOp;wqO->1I3l}WdpfG{)8k-nn zwt0$x2^+H`hdhVGg9BI39^I>Z^=ND2D({YNaRDP8-tVWPq#iwM3}7y1W60gf?=O3= zxEN@gYKdz^eMw4UNvc(HQ7VvPFfuSQ)-^EJH8c(}G_^7?1|n?(11kfAB;|vFP#q8r zx%nxXX_dG&2-j7<1!~X$S^?2el9`)YT#}eu0M%orYh(~&XeeW4U}0rw0kP$q`~TlS OO$?r{elF{r5}E*N{C6k- delta 430 zcmcb_yq#r&1SbbG0|SGGE`RVuMf>{90G|-oEJ^VW1-TY^*)B!7HU-&s1=$8UnO1q( z94YZ&5us2K;Sdp_0Aaya1=(y#@eE1vOiA%ss!B6d6w@Wen?cGX=BO$K2@B0uRq9lf zYm%4wb6n;3F_j-jlz$yn`F2S8>mlWzM^*m+|Ieh7!UwdRG0EHAMJYBlX3fM|a`n$x zMLCSvR=&F>2b9|8>Eak7aaq;hJB-yy`(*2^59x95ra%lB6Q6`$|Bf4y?fN$sutiN~VNIvw~<6`FGJoo<=*cke%@k3YF* z-u)?haIyiTxRjBufvK*cS%{&Dm4T&|p{cfkft7*5cL)BO$%%~OYS^XQWVasx1^|Pn LtDnm{r-UW|zigl| diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_white_black.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_white_black.png index 5dca0f55577aa69d88ee79a31a2fc15922b7775b..7a13b45490b9319b807e65eb52d495f21e49a5dc 100644 GIT binary patch delta 344 zcmdnbvW0nq1SbnK0|Ud`yN`ko!Gi~D*RK8l|G&JvvYecf)?vYm zKvj%M-tI2Uf;>K-fE>;OkH}&M2EP3u%xJ+HtO68dFY)wsWq-~l!p$MzH}zmWP$!3F~k=V0}WS4>xVtJX0{Px%|3c_jG$b>#`x0W(4htX{v0G|-owQJYjyLa!#jT;XiKD>SV_MJO-E?&HN z{rdHrH*ap(u;K3AyB!@J-QC??U0t1>olQ+m?d|RN@87?5>(=`9>sPH>wR-jHKY#xG z`0-=q%9YoyUE8>EYP2x8bb0bKgLX!TMTdgqrfiuJ67c!*rZuNC@5-HD$2cW>t;We5MSq`! z+n- z*I~u|yuIH~ZvAeO5bUd26fXEp?E;JNWM*d8=KTph8~u-M{GV~a@E?2K*8eXViXB6* z_o!Gi~D*RK8l|G%;6Y$KCdMkX_i zOlBGyPd7B4_L=oz2v7%OlDE4HvmlSpr-?7*>YuZTaB~RwO+8o-luGn;aSY+O?%J2j z+hD-slCN=tmzkNJTkKR@gQ|vt#tc@O2h)R?_WY~-yJJa#iOr2(FO?b=nZ3>o?|g$K zPb5q_F;7cubLUZE3(1-)R{7#-ML9|qOT8{SMW4Qx758uU_g?Pg3ckmaGWqL(mZ_Gw zMwDo#B$lLFB^RXvDF!10BV%0yV_iez5JOWd17jf4HZZUv~XSJ zTcCj&AOpeXm1O3o7MCRE7C?(F*LL?u&^>TgBZE2qGcIS4}+(xpUXO@geCwN Cf^pse delta 513 zcmX@je2Qg)1SbbG0|SGGE`RVuMf>`q0G|-owQJYjyLa!#jT;XiKD>SV_MJO-E?&HN z{rdHrH*ap(u;K3AyB!@J-QC??U0t1>olQ+m?d|RN@87?5>(=`9>sPH>wR-jHKY#xG z`0-=q%9YoyUE8>E)^mS!_#wyBT#Nz&7w-He2 zfTxRNh{R>p2@n049XVPWSrcEz>Sh34v9`MW{r|4KDJh?P)r9MK7=%QpeOj{Q=#r*c z^QWc8`n~@7^O2Op&TCzh&WL?F#8OtbH>!Tq4E9BLWxf=hJ$mBu&z^5-3E5}Ai(R~8 z_hvKuk8o9$&Yz9~)y$FmY%RE#8BWbpxbpt{z28^Xem6-7_SO6pAoxw~0*mluW@gsr z`h=Wh`Q)7A`|>9<_jTHD|Ihs`clO*$VPlH}F#)2cmu+VXWX*~Wp2_{f=av5R4g8DB zx{qZumdKI;Vst0HQhNO#lD@ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_white_brown.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_white_brown.png index e8c1d0745fef9feef3afb68d684d74250d83dfd2..12b7a0809fce900a17a16c7f9cf9d87c219cd43a 100644 GIT binary patch delta 359 zcmX@fa+-O91SbnK0|Ud`yN`ko!Gi~D*RK8l|9_FYMxmQ}fvbAH zt9qWRT7jFo%*4$cM)TRHCPgV+hA}*FJB- z1_K_K?HVt{m|59nb(R?H73Y*OXkb>kqOZvFp{Vlb8=nUm6&s|ddi>z9sA^}pGkb~A zgo7#*Z9{d^guB%XjDCFKviqd-^M*@-*VIL=+otWkTKO~op1EEsJ3rg1oyvcJmZ_Gw zMwHa2B$lLFB^RXvDF!10BV%0yV_iez5JOWd17jf4HZZU`q0G|-owQJYjyLa!#jT;XiKD>SV_MJO-E?&HN z{rdHrH*ap(u;K3AyB!@J-QC??U0t1>olQ+m?d|RN@87?5>(=`9>sPH>wR-jHKY#xG z`0-=q%9YoyUE8>E(j3@i4>pHIGE#lZ^nUX-@EHsyDJ^HtZtsCZzx%5p`RhoX7>EYnx!FI z^?&EF{!tg6G^Nl{Aewb%-QEHfo@B4H4lC~Ft=)QX>sEt=U|!FnaKUd{0j$i;++rd+ zf7thaFWvC=^}>6J@6X?qJ5ZJpyx1M4ufimYeY#(Vo9o1a#1RfVlXl=GSW3L)ipE=F*LC;H86O(`njxgN@xNAou=J$ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_white_cyan.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_white_cyan.png index d0d98cb00e5e3249a14bfeab8dd15aa869b331e2..280018bf771eb1193396b52b6dd2666ba7d4e1fc 100644 GIT binary patch delta 326 zcmX@da-4aB1SbnK0|Ud`yN`ko!Gi~D*RK8l|G!wqRoAx zE&ZZRy(Z=U^MT44lf2zsm<4%!K23ZrSO1(%gquUaZ|cE%pj3jVi(?4Kb=SUJ-Ub66 zmwb&Iyv)q(++wHN8dNnDG-j||@YQ6D`@g3yCdfic?v0zOkR4OsJw=A^YAbnC3_Mf( zMZ0evdBiz~$8K*^zooaOxu8tY(u{>`Q}a#r|DXMRj5X1N?{dV!_y2%)sg}4#l%!04 z$;c;VtZQJbYiJx|Xli9(3`E)n237_JNy-NUCkrx(M`4#1uB&_tG)4n#Okzo@RY_)U vYH>+oZUKXlfe}!TnXZvRh@qjCfrXW!8N|qC6)nqvdKf%i{an^LB{Ts5P>5^e delta 491 zcmX@ke2!&;1SbbG0|SGGE`RVuMf>{F0G|-owQJYjyLa!#jT;XiKD>SV_MJO-E?&HN z{rdHrH*ap(u;K3AyB!@J-QC??U0t1>olQ+m?d|RN@87?5>(=`9>sPH>wR-jHKY#xG z`0-=q%9YoyUE8>E(}S|^CL^out4i8l3~ zXP#Tlz{9}6nB?v5A~T1@k$vJsx%y|Uq8vsn?hkew0UdeJ)5S4F;pqMeboL)FsNwhJazQ!_GC4+*FC*!&b7B6-$*&^yw)}8 zjM%3mEZc13bt2C&UtGsmweLyNlb3rI?v=O^^?9qS$yW2~_l*AnIX#o=1diNunC4&4 zf37LhXQ?#D*V}8q+m*hx<-HLS+*PxZqgptlsqr{+GdQd&%^UwT?rQ_PXfxb~Kag8WRNi0dV zN-jzTQVd20Mn<{@rn-h^A%-Sa29{QartaDX237_J-yQgCP;}(xr(~v8V$%W9&?dY6 Q08j&ir>mdKI;Vst01_tV3IG5A diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_white_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_white_gray.png index 460b6516807e931f2421111bd40cdda098e92eb1..423eaf00a363754c469c95603e421956f23743cc 100644 GIT binary patch delta 323 zcmX@ja)5b)1SbnK0|Ud`yN`ko!Gi~D*RK8l|G%A+o2{d(t%Hk= zgNxI_M_fR)j7i?^F3f^FKA$GOmaBixCc@1j;5YSPJy0sf)5S4_ z2OAi-Fdq{W%3<(Yz_Rwfg!|n;IdbO0ELMVZ!jy##nHvoi7{4!@p_5Xi`NT)K|L2j% ztaoJW_BQgbUG!YwprY>;uD!2ctbOAgk;^JtmI3uJc)I$ztaD0e0sulWZD9Za delta 451 zcmX@We41r~1SbbG0|SGGE`RVuMf>{F0G|-owQJYjyLa!#jT;XiKD>SV_MJO-E?&HN z{rdHrH*ap(u;K3AyB!@J-QC??U0t1>olQ+m?d|RN@87?5>(=`9>sPH>wR-jHKY#xG z`0-=q%9YoyUE8>E0! zG4on=B(t;#S996p|Mn9XCB8f{N%!YL29GHbmzpQ3P3Fm}(@52B&#kxF6}I3;ksD{) z>Q6^lw%O0ui8!OZXs+y+ims$55BDtID{*7mY3UAgyWZ}^9PACI8xO$y)Gg6u-~ z7OC(gd);+d5wExR`_Y}>4HANRJwGi~dgHr*lZ`EWjYh;z>0=Vbg?rE1OEcFU+y6{9 zBIfvY;ZdC(AL4OBv}JnCcpug&3Mx r8CY5wnra&uSQ!|6ci^v??9V8!hF!W%cKZQfKrnc^`njxgN@xNAOoY#F diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_white_green.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_white_green.png index ca39a27d22d6326ac86cabedae6b1bf3a049c290..16012079897b6af11e9b4a597a48c35bfd050954 100644 GIT binary patch delta 359 zcmX@fa+-O91SbnK0|Ud`yN`ko!Gi~D*RK8l|9?oXOmL2LP_}eX zmULj2ba1xx^c9D^fjStIyxm=x1$lfvO?)9&|C~*Pn?t~F>cM)TRHCPgV+hA}*FJB- z1_K_K?HVt{m|59nb(R?H73Y*OXkb>kqOZvFp{Vlb8=nUm6&s|ddi>z9sA^}pGkb~A zgo7#*Z9{d^guB%XjDCFKviqd-^M*@-*VIL=+otWkTKO~op1EEsJ3rg1oyvcJmZ_Gw zMwHa2B$lLFB^RXvDF!10BV%0yV_iez5JOWd17jf4HZZU`q0G|-owQJYjyLa!#jT;XiKD>SV_MJO-E?&HN z{rdHrH*ap(u;K3AyB!@J-QC??U0t1>olQ+m?d|RN@87?5>(=`9>sPH>wR-jHKY#xG z`0-=q%9YoyUE8>E8v%v( zd%8G=NL<#Pa53+&0f#H&;R7Zov$mCeeztb*O!CzCn&o4( z;%DZpXD?0k*QZ}+5-C2XaWKdA-i!m&zIWHNc2_!XS=~HO-%zsBLO(;E&FuM)HA_Rb z>i^DT{i7~CX-c7^Ks4*jy1fM|Jjq^X9ah}UTf6n()~yB!!MvVD;ey|^0$7=wxy3|u z{;==;Ub^A!>xK6c-=DuJcc3gIdb@J}UD-3Np@GVGnmHBQcZN>=$SCXkkNv3{|Mbkf z@&X2i90t`A*NBpo#FA92CkWnl2#fxiam fdxVDE{FKbJO57USWVasxYGCkm^>bP0l+XkK%vRn+ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_white_light_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_white_light_blue.png index 3c1b92e1e00070b0db43628ad940433981c4096d..25dca393f1e1b93c2af6fd56eefe8f1ffbfee9f5 100644 GIT binary patch delta 363 zcmcb?a-MmD1SbnK0|Ud`yN`ko!Gi~D*RK8l|G)K?+g6)zS#7*- zwdtni`m2`fuUKuou}!dbKTs26lDE4HvmlSpr->is>YuZTaB~RwO+8o-luGh+aSY+O zo}3`U!pz9#sHUnAAdn&ukdTldB9f3Ikd(l1Qi4gctEtH;p>5%U1sfD5FkWL5W6U;B z5int6cI1%fka%$5>e-`vb*~<6O{O#cT|@JNf-(?-dsV zZBs3Aji@h4Ni0dVN-jzTQVd20M#j1Z#=3^aA%><_2F5_7ZD3$!V34GIFc7K(q9Hdw zB{QuOw+7+5%C|rb8bB)`8cH&AQ;SOya|@t)%yf+mLJSRMtPCuy49y_6EURc)2Gqph M>FVdQ&MBb@0Eo_begFUf delta 464 zcmV;>0Wbc~1K0$R7zqdi0000eEe}(XAwPe6P)t-st*x!z-rm^Q*x}*f+uPgR+}zR8 z(bw14+1c5!u&~|T-H3>Yi;Ihjii(MeiGqTHhlhvX-{0EW+OMy#s;a81tE>F{{P_6z zsi~>f*4DAHvEt(5|NsAnhK8=LuKxc1;NalZ)zv$++dH$`Ijm;JY#a006~FL_t&-(G|kgtUY?I84k_kRkb_8_ zPn1BHm$L@3nj`APK#u2_G+7uesILk-mw2o0RrFmynuC3ogo%ADFk-8~T+^31MaED{ zxhZgJ*K2ES=+as!kctFn{uXAk%1{{tgB%?hoqnLNee1p7?%TEwcK99mbNjzwU)NjT zw|%gW?j6(^MNlHlf)YXrHLb$q0U1eo0PZah!oM8PeUmK#7aB4xFf}bPHdHY*Ixsmp zF*PeNFgh?W_dpMPlU@NACNeEBH7zkVR53Io!Gi~D*RK8l|9?+Ub9Z-BXJ%xX~x2}srjb*|IhwD#+vBCcRAwV`+q>YR7+eVN>V1j zWaN`F)-^EJH8c(}G_^7?1|n?(11kfAB;|vFlLeW?qp(X0*Hyj+8lwR=Cb1;dsw6Wv uwYVfPw}8ROzzC?vOxMUD#L&>nz{1MV3}WQ6ik4+SJq(_%elF{r5}E+}yKYYa delta 491 zcmX@ke2!&;1SbbG0|SGGE`RVuMf>{F0G|-owQJYjyLa!#jT;XiKD>SV_MJO-E?&HN z{rdHrH*ap(u;K3AyB!@J-QC??U0t1>olQ+m?d|RN@87?5>(=`9>sPH>wR-jHKY#xG z`0-=q%9YoyUE8>E$PXPS2z|fg|@Eruo>O9%l*mUr|!MDO5!*9O}-%Mt%Q~P)4 zqrSzr+OlW9XCCl9Yg)Bp=DU+E0hjO0Iu+xP9#qfx{4@Vz>9{s;pl?)5Tq8FVdQ&MBb@0Bz#vasU7T diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_white_lime.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_white_lime.png index e19d0e0d9cd9e3cb5535b76b6bcfd63b0a1e671f..c8053ece542f3672568ae4d54225441c5298f9dd 100644 GIT binary patch delta 357 zcmcb?a*}z11SbnK0|Ud`yN`ko!Gi~D*RK8l|9}2&iM(CnxjV%3 zc8ce06VKi%-uxtr5vYSP$=lt9S&+x))5MQ*_0QQvxH$y;rXH*ZO2vD+IEHXsckRpN zZ7|?*$=A5S%goHqE#~ETKuCl~)8c^sQkIIppMMp43chgJAl>V8goou=1IwM+Nk$V+ zE}dZOYx7LFU%a5`#}_ucw5d-slq{BZMJ>$TwSCp=`p^3c854N<_UqQ|@B&(;TH+c} zl9E_ol4_M)l$uzQ%3x$*WUOmotZQf-VrXh*U<^ds1_o9J21&{X0}(oa8glbfGSez? zYY?uhd<)c|0kHz8p(HamwYVfPw*acgOxMUD#L&>nz(Uf>&{d0G|-owQJYjyLa!#jT;XiKD>SV_MJO-E?&HN z{rdHrH*ap(u;K3AyB!@J-QC??U0t1>olQ+m?d|RN@87?5>(=`9>sPH>wR-jHKY#xG z`0-=q%9YoyUE8>E#kjUF5k+WSq zXPbE5&U%UDlQCO>?qN*wc6X7P!{W#evL>4nJ@a+d-Mhn(p6`&w{iKnkC`!iNi z4kH%#2fK}cLPtGa977~7t4;_EK5W3#{PxJPzU$L&CO11IOekCY|G&5%JO3{K<(FSN zGRz24JLf-1MO$28>tU0#mlNaW^{eq|J`1X!(CjhSe~QEO>6_U$&QgAL)S>VB43kI+ z-4*M(tfp72ei!;B)_zuV?X;H8S{;L=)dwz5w{$%g;I&h;AnST|cJ7NyQ5qAvSknKA zrENMDAj#Y;BP%(#Zo&H6*L&~3ySF-(I_+|DEg=3D*FnGfhHH zoTh6JJ+5Yy^sHofr^|n6zs&hspqErjTq8>-B>OlYi diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_white_magenta.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_white_magenta.png index 71b05f5157e97469402a2efbd2a92d5f8cae95ed..02266296df7e2c8d6680e2892fc74931f4a6aa14 100644 GIT binary patch delta 357 zcmcc2a*}z11SbnK0|Ud`yN`ko!Gi~D*RK8l|Nk!g^*im>ZMR#q z!*1ud8&xL>@W=*Jf}yR@lKGn6crc111B-L-wy>-x|83K*k zacdB+t9%R8paHQ0sG%e?H?_DVF}DD!$4uAAAjHtn%D_U>%FqmA%d(1=Wk5{~p00i_ I>zopr0C)?0*Z=?k delta 522 zcmX@fe3@l}1SbbG0|SGGE`RVuMf>`S0G|-owQJYjyLa!#jT;XiKD>SV_MJO-E?&HN z{rdHrH*ap(u;K3AyB!@J-QC??U0t1>olQ+m?d|RN@87?5>(=`9>sPH>wR-jHKY#xG z`0-=q%9YoyUE8>E> z?XX*Wp|L*mAkZ<4N#5=*GILlQ*?}C+0*}aI1_r+UAk1jN8ms~oWH0gbb!C6XD#~HR z;{IT_5m4x`r;B5V#AVe92ZNXmd7R%KIo7v(_mws=rbeetssI1;pFH6B*+i)IR?MB28teD^TZLJn$Hr+*GA^&`|G03LRPW0WSZ%o|j`vATr|aa_i*3Ia zEy(V?{wmJ({+GR$H{3mE+<4BUyp3y5&8*-Qo~2V}Gc7OMz4h9%b!%IhR(cdX(@#`e z%`?@|;Kap=7hg*MdQttp_RjZOpRyk_e-t0z|3D)7OR~M%?>F}xdjnZi59w$qP6@cI zWg|af=9Kud*YW&Y8<$_n1A0ic#5JNMC9x#cD!C{XNHG{07#ZmrnCcpug&3Mx8CY5w pnra&uSQ!|6ci^u<(U6;;l9^VCTSJ@d_5(l-44$rjF6*2UngCS1@LvD` diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_white_orange.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_white_orange.png index 8c1e2c181bbcfc13da28c53c629128bd61fff3c1..332298c966901f9a6a3044672136ca77b48bcc26 100644 GIT binary patch delta 363 zcmcb?a-MmD1SbnK0|Ud`yN`ko!Gi~D*RK8l|Nqw#fiK1UAB*@u z7xTX_#Q?JUDRm?9sitSC6(PuJZ2a78fwm;r)IpO6t+G#sKDGHiq1t{Qk1{ii?4^ zsg}4#)R&|rmZVxG7o`Fz1|tI_V_gGdT|?s#LsKgQV<6HtFt9Q(NK!r+2-N}6kei>9 znO2EggK%BtTc8FFpcN1eC7HRY#U+Wk1yDU^x<&>ehK4d$1{PL^W)NGJRkSPvYGUwo L^>bP0l+XkKpvQGU delta 464 zcmX@le1m0z1SbbG0|SGGE`RVuMf>{d0G|-owQJYjyLa!#jT;XiKD>SV_MJO-E?&HN z{rdHrH*ap(u;K3AyB!@J-QC??U0t1>olQ+m?d|RN@87?5>(=`9>sPH>wR-jHKY#xG z`0-=q%9YoyUE8>EtJ1=dl-|v-CbnnusE_$oGw@Yj8&Awh{gTEZX=-7QBN1g5Q)pG69R(| z8}Ky0J#wt?`m~$L%?=3@$`=3sFRsVVzsrC5<(G~OGlJC4`A<^O78lrh*yQZx#JG9= zYJ8f{f+jS3%=Mq*Fn#)FwvDrtUmbPmdp^S?QbKpddM>N!6|3Kceu=f8)m%HRrL$JY zAZhi1n9I{GU5^EL?bIyDx}Ke#`{GiR#)K}G^nYS$n@$BtGB?Y}O3tlYu)g;7-uv%v zZ{sWbA^W5F_x^(TeO*KX*4CwoQ0H9+Z1laLdq>Doh&86`a{8Q$sgAKEW-zIL)M zqqvlju7Rnpp;?HbiIst+m7%G&fq|8Q!FLD#n#pmD;%eBX+hn&N0EP#Hr>mdKI;Vst E02wCQ+5i9m diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_white_pink.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_white_pink.png index 2cc87e4e4cb6bfe61abe0db0a95d62d9535fd886..619d10c13c213f148b545a65d0576396d45731b6 100644 GIT binary patch delta 363 zcmcb?a-MmD1SbnK0|Ud`yN`ko!Gi~D*RK8l|NrOiRiC<6zVBH6 zv2(@S_GNF{mwxD6vHEG-QlKWrByV>YWt;uykl zJvl*yg_)7fQB74LKp;gRAR!?^L?j_aASr?2qy&>>S5uQyLfgUx3pOZBV7$gA#+YrM zB4EPC?8qU{A@ShA)w4(U>RvtCnz+ilqg!0SNQd|PsVJ#O&l&@mi`f`*ck=to-YYH! z+NN6K8c|=8l30>zm0Xkxq!^40jEr>+jCBo-Lkvx=42*$D+rYrez#vKaU?5ZnL_=G=Nq>G?ZlKrWThZ<`zKpnCTiBgcusiSQ%JY8Ja0Wbc~1K0$R7zqdi0000eEe}(XAwPe6P)t-st*x!z-rm^Q*x}*f+uPgR+}zR8 z(bw14+1c5!u&~|T-H3>Yi;Ihjii(MeiGqTHhlhvX-{0EW+OMy#s;a81tE>F{{P_6z zsi~>f*4DAHvEt(5|NsAnhK8=LuKxc1;NalZ)z$Nhs`84d?}?}JimC00rtF8M@QD(r zKc5`*00001VoOIv9GnC}2a%T^f93@h2r>jm;JY#a006~FL_t&-(G|kgtUY?I84k_kRkb_8_ zPn1BHm$L@3nj`APK#u2_G+7uesILk-mw2o0RrFmynuC3ogo%ADFk-8~T+^31MaED{ zxhZgJ*K2ES=+as!kctFn{uXAk%1{{tgB%?hoqnLNee1p7?%TEwcK99mbNjzwU)NjT zw|%gW?j6(^MNlHlf)YXrHLb$q0U1eo0PZah!oM8PeUmK#7aB4xFf}bPHdHY*Ixsmp zF*PeNFgh?W_dpMPlU@NACNeEBH7zkVR53Io!Gi~D*RK8l|9^?v%3{?OMXJk+ zRhJj4E-g@5Qlz?E)^+AvpeDv7Z+91FK^~t^6Fo>zjCBo+bq$R}3{9;JjDbkoz`)ADAW8XPAXEoLLvDUb zW?Cg~4Z?MmAirt=t$=7K$;?eHE=kNSfa)>RH8Kb>G?cM2u&^>TgV?gHqGcIS6N9I# KpUXO@geCyuFLbv6 delta 464 zcmV;>0Wbc~1K0$R7zqdi0000eEe}(XAwPe6P)t-st*x!z-rm^Q*x}*f+uPgR+}zR8 z(bw14+1c5!u&~|T-H3>Yi;Ihjii(MeiGqTHhlhvX-{0EW+OMy#s;a81tE>F{{P_6z zsi~>f*4DAHvEt(5|NsAnhK8=LuKxc1;NalZ)zx$+sdOf&awVp7Ca7^GrEw*sb0!j} zy}nY^00001VoOIv9GnC}2a%T^f93@h2r>jm;JY#a006~FL_t&-(G|kgtUY?I84k_kRkb_8_ zPn1BHm$L@3nj`APK#u2_G+7uesILk-mw2o0RrFmynuC3ogo%ADFk-8~T+^31MaED{ zxhZgJ*K2ES=+as!kctFn{uXAk%1{{tgB%?hoqnLNee1p7?%TEwcK99mbNjzwU)NjT zw|%gW?j6(^MNlHlf)YXrHLb$q0U1eo0PZah!oM8PeUmK#7aB4xFf}bPHdHY*Ixsmp zF*PeNFgh?W_dpMPlU@NACNeEBH7zkVR53Ia+-O91SbnK0|Ud`yN`ko!Gi~D*RK8l|Nk6SrP(TqGgTC4 zsVL4+QJk)<_(kOI8=wxxByV>YW-uiavcWEAHRy@4ei~6?~5;W%AbnEmJLV zjVP&4Ni0dVN-jzTQVd20M#j1Z#=3^aA%><_2F5_7ZD3$!V34GIFc78#tRXi)B{QuO zw+7+5%C|rb8Xzmc8cH&AQ;SOya|@t)%yf+mLJSS9qzx>r49y_6EURc)2Gqph>FVdQ I&MBb@03kzn$^ZZW delta 519 zcmX@je1T{F0G|-owQJYjyLa!#jT;XiKD>SV_MJO-E?&HN z{rdHrH*ap(u;K3AyB!@J-QC??U0t1>olQ+m?d|RN@87?5>(=`9>sPH>wR-jHKY#xG z`0-=q%9YoyUE8>EQJkToI7?N@ z@9l;-hI$4D#w2fd7nwOMj_g2ZaTa()7BevL?FV5-3)Wy2pdfpRr>`sfGgeU!BNq1u zyN!TChdo^!LnJP%PB<9EY{=uBd;D16?r14z?nVdiO}qd9?@W2Hpi-*Wjh#^;Fv-*3 zYnG4Eil3R0*Pd>fH(!4ptH!lCflW8N_82tQ&y8O%rt^&TVjf@B&SObW9@e;38*eZ@ zUah-yRqc&*?FaEQCoDO`>X;*%^7GrFi3UBIrpyb=_HVzoEN^Wq)J|Ig0H@dZ7Gzc$KFt}QD!5D#(fE#Oyck$Dyt`i$9X z@*nP(KlqE+N%_g?13jc#;u=wsl30>zm0Xkxq!^40jEr;*Omz*-LJUo;3@oh-O|=aS ltPBjkJMh<_Xvob^$xN%nt)WeJ`vIT^22WQ%mvv4FO#ltJo!Gi~D*RK8l|No!kD!-2@|2VAt z>!|X#L&{$dD*rs9%)Q*D3aE)O$=lt9S&+x))5MQ*_0QQvxH$y;rXH*ZN+o%^IEHXs zPfieFVP<4=R8v(55J(XSNJvN!5lKi9NJ?NhDZwP!)zsva(6(^Ff(;527_YI3F=m^m z2$--jJ95Z#NIW=j_3Y8Tx>t|3Ca&`C=oS|+(&7DnDoX0nv&I1CVm5}{o&5f?_lk>w zwyBo5M%0(2B$lLFB^RXvDF!10BV%0yV_iez5JOWd17jf4HZZU0Wbc~1K0$R7zqdi0000eEe}(XAwPe6P)t-st*x!z-rm^Q*x}*f+uPgR+}zR8 z(bw14+1c5!u&~|T-H3>Yi;Ihjii(MeiGqTHhlhvX-{0EW+OMy#s;a81tE>F{{P_6z zsi~>f*4DAHvEt(5|NsAnhK8=LuKxc1;NalZ)z$pRB>ToB_{1an#U%E^BlW@~`Na|> z7v;Aw00001VoOIv9GnC}2a%T^f93@h2r>jm;JY#a006~FL_t&-(G|kgtUY?I84k_kRkb_8_ zPn1BHm$L@3nj`APK#u2_G+7uesILk-mw2o0RrFmynuC3ogo%ADFk-8~T+^31MaED{ zxhZgJ*K2ES=+as!kctFn{uXAk%1{{tgB%?hoqnLNee1p7?%TEwcK99mbNjzwU)NjT zw|%gW?j6(^MNlHlf)YXrHLb$q0U1eo0PZah!oM8PeUmK#7aB4xFf}bPHdHY*Ixsmp zF*PeNFgh?W_dpMPlU@NACNeEBH7zkVR53IZw9|Ns9- zs=EuQkTJ>I-GwbNZAb0I7jpH_*+jTG1pKBRtOrVkdAc};a9nroyC~RTz~LOMp7Dz5 zDsR;~2I(n(!!wTr-@mRr!8%|@NP)GhdKNoZwj=YqvlC=eyd|Ibd0sO*`HNwF%Xys- z5A);_+csntd1}mf_y6qgV@&RGe2nvU-mL-JpjzS@QIe8al4_M)lnSKk8H@~!jCBo+ zbq$R}3{9;JjDbkoz`)ADAW8XPAc~IM{FKbJO57TR>nh&@HE6)CD9OxCEiOsSEr9AV j(={>(F*LL?u&^>TgIFT4tfFNZP!ofvtDnm{r-UW|Z69(H delta 479 zcmdnae28U&1SbbG0|SGGE`RVuMf>`q0G|-o)$J0u*UDdADR*y!!j0APH`mCYUo3ZJ zh1|83^6NS!Z>^DU%M$L)5$VVgZqF8ONEK?$6uz@g{`xBUwVjeHS|wJtO8h*k^7WAN z@)n89%jMR0N#5U}@aMQnOQ!Ie4$0rgRPL@Hq)#L0%#}Kvytw zCV9KNs2*lK$v?4MuKpRTD2EY?`-9y^K)D^BE{-7*mqRBU^kX*UamhV?tZ(=3D{W#- zjnm%z`)@APXkl>a^5ka*?TikK4h6|g*)k&};Pd58Yffk0l{>$VaZ2`DjgvWw{yqt} zKOdcR)JEX#s|C-!_1xy2lfKp6xYjg2+9kMp^LM!i@>3_MJZn<;#W-@V7iYs5BAi3DpwUh?11Vl2ohYqEsNoU}Ruqq-$WRYiJf? xXkukxX=P}tZD3$!VDR06->wElM{a&fW?Cg~9c{AP4*)eVc)I$ztaD0e0szFt!G{0< diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_yellow_blue.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_yellow_blue.png index 2d3d97f7d803374ce98d57124b1db37e8f7026d3..85aee41f1adbdbd2aebd3366be2670db41790019 100644 GIT binary patch delta 332 zcmX@ha*la|1SbnK0|Ud`yN`km4QK$^1;B#0!-pj*rkQ*D&GQ4(Eyo} zl30>zRg#&TT3nKtTfkssU{F0G|-o)$J0u*UDdADR*y!!j0APH`mCYUo3ZJ zh1|83^6NS!Z>^DU%M$L)5$VVgZqF8ONEK?$6uz@g{`xBUwVjeHS|wJtO8h*k^7WAN z@)n89%jMR0N#5U}@aMQnOQ!Ie4$0rgRPL@-YNS&qq=YJFj(3IwSV! z5KCFz-l$D8*caWE`BHTD=!wfed%mS5WS{*mcJYeco6YP$!c|o|e>w_OGe_>Lx3%D2 zW;iuZ;mZ5(_kLel``siV*jMvYfZ#W^3oOEunVDIe>l1R4<&$%c@5`Ue+}CNp{Xh4& z+}U$0g^eu^!~}?%UbdYnkTokhcqaD?pI7?NH}Eei>pqqZ^o(kWYeY#(Vo9o1a#1Rf zVlXl=GSW3L)ipE=F*LC0B6JwIMy9-ywg)d;B;u9wQr&$eo(@*kjO zswJ)wC6k{q@=F=(8W`&u8iyE~S{WDvk+y+>m4QK$^1;B#{7m9e*rkQ*D&GQ4(Eyo} zl30>zRg#&TT3nKtTfkssUI$1SbbG0|SGGE`RVuMf>{F0G|-o)$J0u*UDdADR*y!!j0APH`mCYUo3ZJ zh1|83^6NS!Z>^DU%M$L)5$VVgZqF8ONEK?$6uz@g{`xBUwVjeHS|wJtO8h*k^7WAN z@)n89%jMR0N#5U}@aMQnOQ!Ie4$0rgRPL@UdvQ4S*(_XoR;fR5bn>Eak7aani5#k|7?9IlLq515?H z+E(`Y+1k02|NPfK7ua1=QnFrvpFtro$y48JmXFbjpP93sy)@BZpMIT5r1+f1!5r6n zGY(Aq-p$%w>9}Qe^E`b+$w~|T40$%Q=Rejg4cV&yJCF5`y6~hag^mKztTXHD_7>4vwj7v4*JfBvT2fwGL~ z?aKXkWzVpN1}fia=2UFo89MbNqpa^g_NQw6(=+qR3xIx6Epd$~Nl7e8wMs5Z1yT$~ z21Z7@2Bx}(W+8?qRtA<PnpnA-7jSNBz4Xq5MEUXO8Ahs;4Xjul-#Ng@b=d#Wz Gp$Py$baqGp delta 520 zcmX@be34~>1SbbG0|SGGE`RVuMf>`S0G|-o)$J0u*UDdADR*y!!j0APH`mCYUo3ZJ zh1|83^6NS!Z>^DU%M$L)5$VVgZqF8ONEK?$6uz@g{`xBUwVjeHS|wJtO8h*k^7WAN z@)n89%jMR0N#5U}@aMQnOQ!Ie4$0rgRPL@jbfue$nPW(Wc)2|NpP> zt!J1BbPQvXx4VnFF8>N;AcwQSBeIx*fp0$uGg`0)s{jSrOFVsD*`KkBau~6=KiF*q z6gueX;us=vS#`ogKNdrdmd2)lymH$M)@#H3cUSNGuY616zZ^%>{I;_mTk82I+16XFRtUO+V>>s$;&+p_e$J|`n=WE zWUG1gd&Yl(oSsQ_0!QvSO!MbI*OckARGQ=K?X}EL~XZ-qUE-+mXqnao_L_V3O|eT#3kWzT%iJm7oQv}(o7cPCo{F5j7TD#jr_sGjlp z=Mw(K(s6CxK<}uQxJHzuB$lLFB^RXvDF!10BO_e{Q(Z%|5JM9y14}DIQ*8qSD+7b? h4*WGJ8glbfGSez?YiN_*egLR}!PC{xWt~$(697^C(6Imj diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_yellow_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_yellow_gray.png index 9cbcc2bfc723fe84e7fb843ab7f583d87039ba39..bb2814a1f1daadac8f97c9da902f3810c3931748 100644 GIT binary patch delta 326 zcmX@da+rC71SbnK0|Ud`yN`kk(6f2wG~cA#>`ByV>Yj<$PKt0umatAEZW!p$MzH}zmWP%6gL#W95Ax@+HU!3G5$ z7Jlsq8yL4R9}^SGVeneOvi81&``te|a^}J;R)TZFl!XnM8x0j0zb~7ilTxJl#7DUQ z=aI*(cVz7LHuA4s^jzSeqVE;1y{})aefR(D?_;c?+I(sElj}AB?NKdpjVMV;EJ?MR z{FaeR%2?OHSl7@v#L(2rz!-?M4GgRd43d-&22K`a5|6?zEnHXm7HE_P+^CYw+|=Td s#M}Y~BLgF#9y47dgAhYQD+3EFLo`S0G|-o)$J0u*UDdADR*y!!j0APH`mCYUo3ZJ zh1|83^6NS!Z>^DU%M$L)5$VVgZqF8ONEK?$6uz@g{`xBUwVjeHS|wJtO8h*k^7WAN z@)n89%jMR0N#5U}@aMQnOQ!Ie4$0rgRPL@^1^Q?elbT43W63JK>_AvmuZ3WD~{A zYt@m=(jr{VWsm>cPh6Dv^28+Fp9dK{rbJw7o}@OJC#y~)Rl7a6-eyjcJd!UcGhY-kZJQANqYfg043yd}9l;3*B3! z!jtTE*I`Ax-rny=cYZfW2z`Tz72$Gueok z<8!{(^-0g*UbV<=2fMHnUvak9YsOg5f2>bj`6sD|-i@5B$S59eq-$WRYiJf?Xkukx zX=P}tZD3$!VDR06zXs@2)e_f;l9a@fRIA+ll+3hB1|tI_>>Ao+w;up%VDNPHb6Mw< G&;$UBki4+~ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_yellow_green.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_yellow_green.png index 07a604232b7f7747b5727628081a74e32097a4e3..d7b328244402743e4063d1ac7099d0af3ddf869d 100644 GIT binary patch delta 332 zcmX@Za*la|1SbnK0|Ud`yN`k;B;u9wQr&$eo(@*kjO zswJ)wC6k{q@=F=(8W`&u8iyE~S{WDvk+y+>m4QK$^1;B#{7m9e*rkQ*D&GQ4(Eyo} zl30>zRg#&TT3nKtTfkssUI$1SbbG0|SGGE`RVuMf>{F0G|-o)$J0u*UDdADR*y!!j0APH`mCYUo3ZJ zh1|83^6NS!Z>^DU%M$L)5$VVgZqF8ONEK?$6uz@g{`xBUwVjeHS|wJtO8h*k^7WAN z@)n89%jMR0N#5U}@aMQnOQ!Ie4$0rgRPL@UdvQ4S*(_XoR;fR5bn>Eak7aani5#k|7?9IlLq515?H z+E(`Y+1k02|NPfK7ua1=QnFrvpFtro$y48JmXFbjpP93sy)@BZpMIT5r1+f1!5r6n zGY(Aq-p$%w>9}Qe^E`b+$w~|T40$%Q=Rejg4cV&yJCF5`y6~hag^mKztTXHD_7>4vwj7v4*JfBvT2fwGL~ z?aKXkWzVpN1}fia=2UFo89MbNqpa^g_NQw6(=+qR3xIx6Epd$~Nl7e8wMs5Z1yT$~ z21Z7@2Bx}(W+8?qRtA<80YN6#7qn2XsMa(D9k%ib$4p8S?kT*_G2z*yJNIK`?0G|-o)$J0u*UDdADR*y!!j0APH`mCYUo3ZJ zh1|83^6NS!Z>^DU%M$L)5$VVgZqF8ONEK?$6uz@g{`xBUwVjeHS|wJtO8h*k^7WAN z@)n89%jMR0N#5U}@aMQnOQ!Ie4$0rgRPL@zNsLL}?k<|AwzsNGoF!NPj8&Awh{gTEZX=-7QBN1g5Q)pG69R(| z8}Ky0J#wt?`m~$L%?=3@$`=3sFRsVVzsrC5<(G~OGlJC4`A<^O78lrh*yQZx#JG9= zYJ8f{f+jS3%=Mq*Fn#)FwvDrtUmbPmdp^S?QbKpddM>N!6|3Kceu=f8)m%HRrL$JY zAZhi1n9I{GU5^EL?bIyDx}Ke#`{GiR#)K}G^nYS$n@$BtGB?Y}O3tlYu)g;7-uv%v zZ{sWbA^W5F_x^(TeO*KX*4CwoQ0H9+Z1laLdq>Doh&86`a{8Q$sgAKEW-zIL(! zqqvlju7Rnpp;?HbiIst+m7%G&fq|8Q!FLD#n#qZb;%eBX+hn&N0EP#Hr>mdKI;Vst E0MYuzr2qf` diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_yellow_light_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_yellow_light_gray.png index 6057c3d011b8d314cc08dfe139874bff3f608668..33063b2f5a6cfa9e96ed178c823d84f9d0ac2860 100644 GIT binary patch delta 358 zcmcb}a*BC^1SbnK0|Ud`yN`kcM)TRD!3AV+hA}*S=id z1_K_Ke2p8t%*^cEVyD^~R5cVdX0TlF)nttOzo#xH$U;i)jhm{F9aG;uMTYNcD|u23 zJX8EdyKf$O#5sq@Zf{e+rMIQIpiI!xjD>4c^G)^tpZ$G|HPM6ba>T*+|A2O>mbgZg zq|_&tq*^5xr2;7iBLgF2T?1oXL*o!bQ!4{wAksE4ure@6Qa%_6*8$Ryo1c=IR*74K za9!nFpau=F6(9{InYpROC5gEOP(5b4Mg}21SbbG0|SGGE`RVuMf>`S0G|-o)$J0u*UDdADR*y!!j0APH`mCYUo3ZJ zh1|83^6NS!Z>^DU%M$L)5$VVgZqF8ONEK?$6uz@g{`xBUwVjeHS|wJtO8h*k^7WAN z@)n89%jMR0N#5U}@aMQnOQ!Ie4$0rgRPL@D8QyQ!lJ;0j$uslc6U+NvL>4nJ@a+d-Mhn(p6`&w{iKnkC`!iNi4kH%#2fK}c zLI*uv977~7t4?_6$70CQ(%2M`S8jX3dTp5h?&^L2m2YXBd@|cd?T-Y5ik8k(N6&6g zR#SW3)4S$ed;9T?l*7(zU6am;eX2jgvduPLC-MyQ#dUmD`<^5{dAVodUWpq~pSQZ2 zY&EZb&-gEp(=(|~;K)6PY5x4@nlgQsN^^X@z4p6Z>04Xg8zI46H7hx)g)^EuPc}9- z9lUSwt+2=N+wa0RlbP$({@wYgZ}F|R?3wSG2Yk<(R;`%%?qo~ACkWnl2# hfxiYtLvDUbW?Cg~4Q;a94*)eVc)I$ztaD0e0sxg0(%Aq2 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_yellow_lime.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_yellow_lime.png index dc255ce9c873deddbe5c58640c353fedcdb41b20..44634e68df8478c3db1fae02faf80243851b9891 100644 GIT binary patch delta 349 zcmcc3a)x<=1SbnK0|Ud`yN`kehK5!K7FLF45F?jW Sv@8SaVeoYIb6Mw<&;$So&~t16 delta 504 zcmX@Ze4Ay01SbbG0|SGGE`RVuMf>`?0G|-o)$J0u*UDdADR*y!!j0APH`mCYUo3ZJ zh1|83^6NS!Z>^DU%M$L)5$VVgZqF8ONEK?$6uz@g{`xBUwVjeHS|wJtO8h*k^7WAN z@)n89%jMR0N#5U}@aMQnOQ!Ie4$0rgRPL@*|9_dc=9NGvF(!GtyJ();-l{Tjx?KG;R#6Tk7WW6cjet@|JzX3_BrdB?2n;@K zz|;Kp$g#fb({3g=J0wgfTm1jOxE?$IF8}41Upg|(2vR%eKS@PfTwv>Ale3o-}#Q?nrJdUkg1i%U@&6S`Q^|B0n-Iu#(v+$=g;u0HrfcLQb5fYY#nUl=Q4*c&E#MXur()TA+_q zOI#yLQW8s2t&)pUffR$0fsv7}fvK*cS%{&Dm4UaVm7%G&fq|8Q!FLD#8WbJ5`6-!c ZmFPMU8ro#H9{_4#@O1TaS?83{1ON#s&Bg!# diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_yellow_magenta.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_yellow_magenta.png index 3dc7d82491a54b114f76bc3dca827289dd895e24..310022b33e6953a861df55539f5cc07be266de9f 100644 GIT binary patch delta 360 zcmcb{a)x<=1SbnK0|Ud`yN`ki_@$S5v(&12r)wdAqxCWnB0YHu0le{c|=EZVmyzsR!$UQt_THjv*Y^ zUHfu*8w_|{@-=SoGBdMti+MR75E9|hv^b!@l%?YD=U;`Mf-hV)NcZ|2;bA$}z;b7H zlF@{dODEX++B_5P7cVIK@rBJUZR*nuC5xq9Q44c-ZC~}e{`0;<#sprz{knBKynt4z zmbgZgq$Jjtq*^5xr6!i7G8h>c8S5Gt>lzw|7@Arc7z2^Efq|8QL6Y*pK!gsUhTQy= z%(P0}8ieaA-vTvgK&$|2D9OxCEiOsSEr9AV(={>(F*LL?u#mJeG=tc(tfFNZP!ofv LtDnm{r-UW|ne%-H delta 499 zcmX@Ze2ry-1SbbG0|SGGE`RVuMf>{d0G|-o)$J0u*UDdADR*y!!j0APH`mCYUo3ZJ zh1|83^6NS!Z>^DU%M$L)5$VVgZqF8ONEK?$6uz@g{`xBUwVjeHS|wJtO8h*k^7WAN z@)n89%jMR0N#5U}@aMQnOQ!Ie4$0rgRPL@K~ z{}=jydhg#}pnDjTyxm?r4D<#IEF}ER-JG#h}n?G z`R$QoeYB1 z_SDzR3Qpl!I%PJ~^0M7quPs}*wv}n6N5M1wM77mCQw z`!VxJ@$vl+B$B@*+pGP4bI-9ikVW;7j)vltfXiAo@)KrGiGLl>zqN7sl{}z-R7+eV zN>UO_QmvAUQh^kMk%5tsu7Rnpp;?HbiIst+m8YSpwt<0_fx&kN{u&e=x%nxXX_c5d WU>e$Fw;up%VDNPHb6Mw<&;$VXq}8VY diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_yellow_orange.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_yellow_orange.png index dd34f3c85f268888b76d32a2f76bd6af65eac4d9..c5346cb00704ce845c5765a204d5c6607d0281f3 100644 GIT binary patch delta 355 zcmcc3a*26@1SbnK0|Ud`yN`k21sKW7u+<`D3kdaxcSl;r8+7{YNqIYESlnUT#=O;sU4AVnY`At519L?j_aASr?2 zqy&>>S5uQyLfgUx3pOZBV7$gA#+YrMB4EPC?8qU{A@ShA)w4(U>RvtCnz+ilqg!0S zNQd|PsVJ#O&l&@mi`f`*ck=to-YYJi{FYH%%2?OHSl7@v#L(2rz!-?M4GgRd43d-& z22Pe^5|6?zEnHXm7U)=w64!{5l*E!$tCGyz)Z&uF+yVw810$dwGhHKt5JN*N0}Crd XGl-GPDq5BS^)Pt4`njxgN@xNAmS%67 delta 467 zcmcb_e4Ay01SbbG0|SGGE`RVuMf>`?0G|-o)$J0u*UDdADR*y!!j0APH`mCYUo3ZJ zh1|83^6NS!Z>^DU%M$L)5$VVgZqF8ONEK?$6uz@g{`xBUwVjeHS|wJtO8h*k^7WAN z@)n89%jMR0N#5U}@aMQnOQ!Ie4$0rgRPL@kM>lUDs7?Zr+T{KT^Z&jH%ORoMIt0;#Ni~ED!MnI{fo-U3d5|>pc1O^{A z;Awt)p#U|`t;3g8)qrMI_l8(e1=J+gzk#`?0G|-o)$J0u*UDdADR*y!!j0APH`mCYUo3ZJ zh1|83^6NS!Z>^DU%M$L)5$VVgZqF8ONEK?$6uz@g{`xBUwVjeHS|wJtO8h*k^7WAN z@)n89%jMR0N#5U}@aMQnOQ!Ie4$0rgRPL@bmH|1r7NsLL}?k<|AwzsNGoF!NPj8&Awh{gTEZX=-7QBN1g5Q)pG69R(| z8}Ky0J#wt?`m~$L%?=3@$`=3sFRsVVzsrC5<(G~OGlJC4`A<^O78lrh*yQZx#JG9= zYJ8f{f+jS3%=Mq*Fn#)FwvDrtUmbPmdp^S?QbKpddM>N!6|3Kceu=f8)m%HRrL$JY zAZhi1n9I{GU5^EL?bIyDx}Ke#`{GiR#)K}G^nYS$n@$BtGB?Y}O3tlYu)g;7-uv%v zZ{sWbA^W5F_x^(TeO*KX*4CwoQ0H9+Z1laLdq>Doh&86`a{8Q$sgAKEW-zIL(! zqqvlju7Rnpp;?HbiIst+m7%G&fq|8Q!FLD#n#qZb;%eBX+hn&N0EP#Hr>mdKI;Vst E0MP%(9{>OV diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_yellow_purple.png b/src/main/resources/assets/overdrive_that_matters/textures/block/decorative/stripe/tritanium_striped_block_yellow_purple.png index 61817ab14072e85c5e4ba66f03c9f7c49f5ac817..c68cb80d875dbc99374edd55a2fbc3b9c8b1a306 100644 GIT binary patch delta 355 zcmcc3a*26@1SbnK0|Ud`yN`kAc^&9L@rd$YKTtzWpG~Xu%q+0u*E~ z@$_|Nf6gYt%^~17^LPA2Ih)6<;KvDw3 zNeL#&uBIlZgtmnX7Hm+Mz<7;Kj4|6hMZkoO*^xt@L*l`Kt7nhy)xCPOHF1@9N4L0u zkq+-Bp!ubTDY$AEzq$VC9V-ADTyViRwbFasl_FUxdjYH21YS6G7^>bP0l+XkKSu1Xz delta 467 zcmcb_e4Ay01SbbG0|SGGE`RVuMf>`?0G|-o)$J0u*UDdADR*y!!j0APH`mCYUo3ZJ zh1|83^6NS!Z>^DU%M$L)5$VVgZqF8ONEK?$6uz@g{`xBUwVjeHS|wJtO8h*k^7WAN z@)n89%jMR0N#5U}@aMQnOQ!Ie4$0rgRPL@+KM98WyNYM3RRaDsxB#3 z6J7rQ|9_Snrqh58v&(`db&7laXohaUH;22zjS1n5u|p`f0Bx}xWLxKCTA}v#?9+j zC-o}ZJee2>Zn8C^BE?Q61pqab6HKVSp6>aORW8@=Gtj3owYg! zNvjXUT%K;}dMvO=*((yR0ZM0@gq%1{*B*MzDCt?r@J^Ti(0-ZowUZ4P z#ifjN4NP?n%|Z-KtPCuz3{ABS46F}d0%bi@o_jpn!e;v>= z)e_f;lKPayl2ohYqEsNoU}RuqtZQJbYiJx|Xli9(3`E)n237_JNy-NUVLHGXa`RI% z(<*Um5U#6y3)G+ivI4B3Br`X)xFj*R0IJ7K*T^8m(9lZSz{1MV3}VZ&ik4+SO$?r{ KelF{r5}E)|0(Uk5 delta 478 zcmX@de3@l}1SbbG0|SGGE`RVuMf>`S0G|-o)$J0u*UDdADR*y!!j0APH`mCYUo3ZJ zh1|83^6NS!Z>^DU%M$L)5$VVgZqF8ONEK?$6uz@g{`xBUwVjeHS|wJtO8h*k^7WAN z@)n89%jMR0N#5U}@aMQnOQ!Ie4$0rgRPL@aeGaV~E6M)d>fKm<@THbB`bE z+Z`?C%-!hVy=nLV|D7oh7F0_0y0J4V1SWaVJMa zG|`|()0BB(+5YXghb4S1ql!3Uo6hw`+Z~n?HO-2`2X4Y zIKH6A@YhD!$+czW2I3*Ey#@SgEi%u-LZ2~PP5#6E@(2GqDL*-Vpnp_LTq8mdKI;Vst0C$CbfdBvi delta 446 zcmX@le1m0z1SbbG0|SGGE`RVuMf>dP0G|-o)$J0u*UDdADR*y!!j0APH`mCYUo3ZJ zh1|83^6NS!Z>^DU%M$L)5$VVgZqF8ONEK?$6uz@g{`xBUwVjeHS|wJtO8h*k^7WAN z@)n89%jMR0N#5U}@aMQnOQ!Ie4$0rgRPL@(pVeGDt);V8#~^9-ftbtFEnSZVc Date: Tue, 20 Jun 2023 19:23:53 +0700 Subject: [PATCH 0631/1199] a --- .../mc/otm/block/entity/tech/BatteryBankBlockEntity.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index ec8a38a77..f444512cd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -33,7 +33,7 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { super.setChanged(slot, new, old) batteryStatus[slot].boolean = new.getCapability(ForgeCapabilities.ENERGY).isPresent - gaugeLevel = (batteryLevel / maxBatteryLevel).toFloat() + gaugeLevel = batteryLevel.percentage(maxBatteryLevel) } }.also(::addDroppableContainer) @@ -87,9 +87,7 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte if (!simulate && !summ.isZero) { setChangedLight() - gaugeLevel = (batteryLevel / maxBatteryLevel).toFloat() - } else if (!simulate && container.isEmpty) { - gaugeLevel = 0f + gaugeLevel = batteryLevel.percentage(maxBatteryLevel) } if (!simulate) { From ab61101ab64a58d4a5367d000e44446ca92353c4 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 20 Jun 2023 20:36:33 +0700 Subject: [PATCH 0632/1199] Pull and push modes now can be independently configured --- .../mc/otm/datagen/lang/English.kt | 3 + .../mc/otm/datagen/lang/Russian.kt | 3 + .../mc/otm/capability/FlowDirection.kt | 4 +- .../mc/otm/client/render/Widgets18.kt | 134 +++++++++++------- .../otm/client/screen/panels/EditablePanel.kt | 20 +++ .../client/screen/panels/button/Buttons.kt | 129 ++++++++++------- .../mc/otm/matter/MatterManager.kt | 2 +- .../otm/menu/input/EnergyConfigPlayerInput.kt | 21 +-- .../otm/menu/input/FluidConfigPlayerInput.kt | 21 +-- .../otm/menu/input/ItemConfigPlayerInput.kt | 22 +-- .../textures/gui/widgets/redstone.png | Bin 713 -> 0 bytes .../textures/gui/widgets/redstone.xcf | Bin 4764 -> 0 bytes .../textures/gui/widgets/side_controls.png | Bin 2050 -> 2631 bytes .../textures/gui/widgets/side_controls.xcf | Bin 37629 -> 70796 bytes 14 files changed, 203 insertions(+), 156 deletions(-) delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/redstone.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/redstone.xcf diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 2f178dfb4..efaf4c0c7 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -661,6 +661,9 @@ private fun gui(provider: MatteryLanguageProvider) { gui("sides.energy_config", "Energy Configuration") gui("sides.fluid_config", "Fluid Configuration") + gui("sides.pull_help", "Hold Shift to cycle pull mode") + gui("sides.push_help", "Hold Ctrl to cycle push mode") + gui("sides.top", "Top") gui("sides.bottom", "Bottom") gui("sides.front", "Front") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index c450a4a45..ad0fc506c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -666,6 +666,9 @@ private fun gui(provider: MatteryLanguageProvider) { gui("sides.energy_config", "Настройка энергии") gui("sides.fluid_config", "Настройка жидкости") + gui("sides.pull_help", "Удерживайте Shift для настройки режима забора") + gui("sides.push_help", "Удерживайте Ctrl для настройки режима выталкивания") + gui("sides.top", "Верхняя сторона") gui("sides.bottom", "Нижняя сторона") gui("sides.front", "Передняя сторона") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt index 4e72ceb3a..ae15a5428 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt @@ -68,14 +68,14 @@ enum class FlowDirection(val input: Boolean, val output: Boolean, val translatio get() = TranslatableComponent(translationKey) /** - * Subtype test (returns true if we can assign [t] to this, e.g. we can assign [BI_DIRECTIONAL] to [INPUT]) + * Subtype test (returns true if we can assign [t] to this, for example if we can assign [BI_DIRECTIONAL] to [INPUT]) */ override fun test(t: FlowDirection): Boolean { return t === this || (!input || t.input) && (!output || t.output) } /** - * Subtype test (returns true if we can assign [value] to this, e.g. we can assign [BI_DIRECTIONAL] to [INPUT]) + * Subtype test (returns true if we can assign [value] to this, for example if we can assign [BI_DIRECTIONAL] to [INPUT]) */ fun isSubtype(value: FlowDirection) = test(value) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt index a34697f1c..3e03f8ed5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt @@ -59,40 +59,99 @@ object Widgets18 { val PATTERN_SLOT_BACKGROUND = slotBgGrid.next() val MATTER_CAPACITOR_SLOT_BACKGROUND = slotBgGrid.next() - private val redstoneGrid = WidgetLocation.REDSTONE_CONTROLS.grid(rows = 1, columns = 3) + private val controlsGrid = WidgetLocation.SIDE_CONTROLS.grid(rows = 7, columns = 9) - val REDSTONE_IGNORED = redstoneGrid.next() - val REDSTONE_LOW = redstoneGrid.next() - val REDSTONE_HIGH = redstoneGrid.next() + val BATTERY_ONLY = controlsGrid.next() + val ITEMS_CONFIGURATION = controlsGrid.next() + val ENERGY_CONFIGURATION = controlsGrid.next() + val FLUID_CONFIGURATION = controlsGrid.next() - private val controlsGrid = WidgetLocation.SIDE_CONTROLS.grid(rows = 4, columns = 8) + val REDSTONE_IGNORED = controlsGrid.next() + val REDSTONE_LOW = controlsGrid.next() + val REDSTONE_HIGH = controlsGrid.next() - val PULL = controlsGrid.next() - val PUSH = controlsGrid.next() - val PULL_DISABLED = controlsGrid.next() - val PUSH_DISABLED = controlsGrid.next() - - private fun controls() = immutableMap { - put(FlowDirection.NONE, controlsGrid.next()) - put(FlowDirection.INPUT, controlsGrid.next()) - put(FlowDirection.OUTPUT, controlsGrid.next()) - put(FlowDirection.BI_DIRECTIONAL, controlsGrid.next()) + init { + controlsGrid.jump() } - private fun controls2(input: Map) = immutableMap { - put(MatteryDeviceBlockEntity.ItemHandlerMode.DISABLED, input[FlowDirection.NONE]!!) - put(MatteryDeviceBlockEntity.ItemHandlerMode.INPUT, input[FlowDirection.INPUT]!!) - put(MatteryDeviceBlockEntity.ItemHandlerMode.OUTPUT, input[FlowDirection.OUTPUT]!!) - put(MatteryDeviceBlockEntity.ItemHandlerMode.INPUT_OUTPUT, input[FlowDirection.BI_DIRECTIONAL]!!) - put(MatteryDeviceBlockEntity.ItemHandlerMode.BATTERY, BATTERY_ONLY) + class SideControls { + val disabled = controlsGrid.next() + val input = controlsGrid.next() + val pull = controlsGrid.next() + val output = controlsGrid.next() + val push = controlsGrid.next() + val inputOutput = controlsGrid.next() + val pullOutput = controlsGrid.next() + val inputPush = controlsGrid.next() + val pullPush = controlsGrid.next() + + val flow = immutableMap { + put(FlowDirection.NONE, disabled) + put(FlowDirection.INPUT, input) + put(FlowDirection.OUTPUT, output) + put(FlowDirection.BI_DIRECTIONAL, inputOutput) + } + + val flowPush = immutableMap { + put(FlowDirection.NONE, disabled) + put(FlowDirection.INPUT, input) + put(FlowDirection.OUTPUT, push) + put(FlowDirection.BI_DIRECTIONAL, inputPush) + } + + val flowPull = immutableMap { + put(FlowDirection.NONE, disabled) + put(FlowDirection.INPUT, pull) + put(FlowDirection.OUTPUT, output) + put(FlowDirection.BI_DIRECTIONAL, pullOutput) + } + + val flowPullPush = immutableMap { + put(FlowDirection.NONE, disabled) + put(FlowDirection.INPUT, pull) + put(FlowDirection.OUTPUT, push) + put(FlowDirection.BI_DIRECTIONAL, pullPush) + } + + val items = immutableMap { + put(MatteryDeviceBlockEntity.ItemHandlerMode.DISABLED, disabled) + put(MatteryDeviceBlockEntity.ItemHandlerMode.INPUT, input) + put(MatteryDeviceBlockEntity.ItemHandlerMode.OUTPUT, output) + put(MatteryDeviceBlockEntity.ItemHandlerMode.INPUT_OUTPUT, inputOutput) + put(MatteryDeviceBlockEntity.ItemHandlerMode.BATTERY, BATTERY_ONLY) + } + + val itemsPush = immutableMap { + put(MatteryDeviceBlockEntity.ItemHandlerMode.DISABLED, disabled) + put(MatteryDeviceBlockEntity.ItemHandlerMode.INPUT, input) + put(MatteryDeviceBlockEntity.ItemHandlerMode.OUTPUT, push) + put(MatteryDeviceBlockEntity.ItemHandlerMode.INPUT_OUTPUT, inputPush) + put(MatteryDeviceBlockEntity.ItemHandlerMode.BATTERY, BATTERY_ONLY) + } + + val itemsPull = immutableMap { + put(MatteryDeviceBlockEntity.ItemHandlerMode.DISABLED, disabled) + put(MatteryDeviceBlockEntity.ItemHandlerMode.INPUT, pull) + put(MatteryDeviceBlockEntity.ItemHandlerMode.OUTPUT, output) + put(MatteryDeviceBlockEntity.ItemHandlerMode.INPUT_OUTPUT, pullOutput) + put(MatteryDeviceBlockEntity.ItemHandlerMode.BATTERY, BATTERY_ONLY) + } + + val itemsPullPush = immutableMap { + put(MatteryDeviceBlockEntity.ItemHandlerMode.DISABLED, disabled) + put(MatteryDeviceBlockEntity.ItemHandlerMode.INPUT, pull) + put(MatteryDeviceBlockEntity.ItemHandlerMode.OUTPUT, push) + put(MatteryDeviceBlockEntity.ItemHandlerMode.INPUT_OUTPUT, pullPush) + put(MatteryDeviceBlockEntity.ItemHandlerMode.BATTERY, BATTERY_ONLY) + } } - val LEFT_CONTROLS = controls() - val RIGHT_CONTROLS = controls() - val TOP_CONTROLS = controls() - val BOTTOM_CONTROLS = controls() - val FRONT_CONTROLS = controls() - val BACK_CONTROLS = controls() + val LEFT_CONTROLS = SideControls() + val RIGHT_CONTROLS = SideControls() + val TOP_CONTROLS = SideControls() + val BOTTOM_CONTROLS = SideControls() + val FRONT_CONTROLS = SideControls() + val BACK_CONTROLS = SideControls() val CONTROLS = immutableMap { put(RelativeSide.BOTTOM, BOTTOM_CONTROLS) @@ -102,25 +161,4 @@ object Widgets18 { put(RelativeSide.FRONT, FRONT_CONTROLS) put(RelativeSide.BACK, BACK_CONTROLS) } - - val BATTERY_ONLY = controlsGrid.next() - val ITEMS_CONFIGURATION = controlsGrid.next() - val ENERGY_CONFIGURATION = controlsGrid.next() - val FLUID_CONFIGURATION = controlsGrid.next() - - val LEFT_CONTROLS_ITEMS = controls2(LEFT_CONTROLS) - val RIGHT_CONTROLS_ITEMS = controls2(RIGHT_CONTROLS) - val TOP_CONTROLS_ITEMS = controls2(TOP_CONTROLS) - val BOTTOM_CONTROLS_ITEMS = controls2(BOTTOM_CONTROLS) - val FRONT_CONTROLS_ITEMS = controls2(FRONT_CONTROLS) - val BACK_CONTROLS_ITEMS = controls2(BACK_CONTROLS) - - val ITEMS_CONTROLS = immutableMap { - put(RelativeSide.BOTTOM, BOTTOM_CONTROLS_ITEMS) - put(RelativeSide.TOP, TOP_CONTROLS_ITEMS) - put(RelativeSide.LEFT, LEFT_CONTROLS_ITEMS) - put(RelativeSide.RIGHT, RIGHT_CONTROLS_ITEMS) - put(RelativeSide.FRONT, FRONT_CONTROLS_ITEMS) - put(RelativeSide.BACK, BACK_CONTROLS_ITEMS) - } } 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 c322ffbc0..a0ca9d7c8 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 @@ -391,6 +391,26 @@ open class EditablePanel @JvmOverloads constructor( field = value } + fun prependTooltip(text: Component) { + if (tooltip == null && tooltipList == null) { + tooltip = text + } else if (tooltip != null) { + tooltipList = listOf(text, tooltip!!) + } else { + tooltipList = tooltipList!!.toMutableList().also { it.add(0, text) } + } + } + + fun appendTooltip(text: Component) { + if (tooltip == null && tooltipList == null) { + tooltip = text + } else if (tooltip != null) { + tooltipList = listOf(text, tooltip!!) + } else { + tooltipList = tooltipList!!.toMutableList().also { it.add(text) } + } + } + var blockingWindow: EditablePanel<*>? = null get() { if (field?.isRemoved != true) { 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 d89dbc847..7db124cc0 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 @@ -1,14 +1,20 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import com.mojang.blaze3d.platform.InputConstants +import net.minecraft.ChatFormatting +import net.minecraft.client.gui.GuiGraphics import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.client.isCtrlDown +import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback @@ -42,11 +48,64 @@ private fun > makeRedstoneSettingButton( } } +private class PullPushButton, T : Enum>( + screen: S, + parent: EditablePanel<*>?, + x: Float = 0f, + y: Float = 0f, + enum: Class, + prop: GetterSetter, + defaultValue: T, + val pullProp: BooleanInputWithFeedback, + val pushProp: BooleanInputWithFeedback +) : LargeEnumRectangleButtonPanel(screen, parent, x = x, y = y, enum = enum, prop = prop, defaultValue = defaultValue) { + init { + if (pullProp.test(minecraft.player) && pushProp.test(minecraft.player)) { + tooltipList = listOf(TranslatableComponent("otm.gui.sides.pull_help").withStyle(ChatFormatting.GRAY), TranslatableComponent("otm.gui.sides.push_help").withStyle(ChatFormatting.GRAY)) + } else if (pullProp.test(minecraft.player)) { + tooltip = TranslatableComponent("otm.gui.sides.pull_help").withStyle(ChatFormatting.GRAY) + } else if (pushProp.test(minecraft.player)) { + tooltip = TranslatableComponent("otm.gui.sides.push_help").withStyle(ChatFormatting.GRAY) + } + } + + data class State>(val pull: Boolean, val push: Boolean, val value: T) + private val sprites = HashMap, AbstractMatterySprite>() + + fun addSprite(pull: Boolean, push: Boolean, value: T, sprite: AbstractMatterySprite) { + sprites[State(pull, push, value)] = sprite + } + + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + super.innerRender(graphics, mouseX, mouseY, partialTick) + sprites[State(pullProp.value, pushProp.value, prop.get())]?.render(graphics, 0f, 0f, width, height) + } + + override fun onClick(mouseButton: Int) { + if (mouseButton != InputConstants.MOUSE_BUTTON_MIDDLE && minecraft.window.isShiftDown) { + if (pullProp.test(minecraft.player)) { + pullProp.switchValue() + } + } else if (mouseButton != InputConstants.MOUSE_BUTTON_MIDDLE && minecraft.window.isCtrlDown) { + if (pushProp.test(minecraft.player)) { + pushProp.switchValue() + } + } else { + super.onClick(mouseButton) + } + } +} + private fun > makeItemModeButton(screen: S, parent: FramePanel, input: ItemConfigPlayerInput.Piece, side: RelativeSide): LargeEnumRectangleButtonPanel { - val button = LargeEnumRectangleButtonPanel(screen, parent, enum = MatteryDeviceBlockEntity.ItemHandlerMode::class.java, prop = input.input, defaultValue = input.default) + val button = PullPushButton(screen, parent, enum = MatteryDeviceBlockEntity.ItemHandlerMode::class.java, prop = input.input, defaultValue = input.default, pullProp = input.pull, pushProp = input.push) + val widgets = Widgets18.CONTROLS[side]!! for (v in MatteryDeviceBlockEntity.ItemHandlerMode.values()) { - button.add(v, skinElement = Widgets18.ITEMS_CONTROLS[side]!![v]!!, tooltip = TranslatableComponent(v.translationKey)) + button.add(v, tooltip = TranslatableComponent(v.translationKey)) + button.addSprite(false, false, v, widgets.items[v]!!) + button.addSprite(true, false, v, widgets.itemsPull[v]!!) + button.addSprite(false, true, v, widgets.itemsPush[v]!!) + button.addSprite(true, true, v, widgets.itemsPullPush[v]!!) } button.finish() @@ -56,10 +115,15 @@ private fun > makeItemModeButton(screen: S, parent: FramePa } private fun > makeEnergyModeButton(screen: S, parent: FramePanel, input: EnergyConfigPlayerInput.Piece, side: RelativeSide): LargeEnumRectangleButtonPanel { - val button = LargeEnumRectangleButtonPanel(screen, parent, enum = FlowDirection::class.java, prop = input.input, defaultValue = input.default) + val button = PullPushButton(screen, parent, enum = FlowDirection::class.java, prop = input.input, defaultValue = input.default, pullProp = input.pull, pushProp = input.push) + val widgets = Widgets18.CONTROLS[side]!! for (v in FlowDirection.values()) { - button.add(v, skinElement = Widgets18.CONTROLS[side]!![v]!!, tooltip = TranslatableComponent(v.translationKey)) + button.add(v, tooltip = TranslatableComponent(v.translationKey)) + button.addSprite(false, false, v, widgets.flow[v]!!) + button.addSprite(true, false, v, widgets.flowPull[v]!!) + button.addSprite(false, true, v, widgets.flowPush[v]!!) + button.addSprite(true, true, v, widgets.flowPullPush[v]!!) } button.finish() @@ -68,10 +132,15 @@ private fun > makeEnergyModeButton(screen: S, parent: Frame } private fun > makeFluidModeButton(screen: S, parent: FramePanel, input: FluidConfigPlayerInput.Piece, side: RelativeSide): LargeEnumRectangleButtonPanel { - val button = LargeEnumRectangleButtonPanel(screen, parent, enum = FlowDirection::class.java, prop = input.input, defaultValue = input.default) + val button = PullPushButton(screen, parent, enum = FlowDirection::class.java, prop = input.input, defaultValue = input.default, pullProp = input.pull, pushProp = input.push) + val widgets = Widgets18.CONTROLS[side]!! for (v in FlowDirection.values()) { - button.add(v, skinElement = Widgets18.CONTROLS[side]!![v]!!, tooltip = TranslatableComponent(v.translationKey)) + button.add(v, tooltip = TranslatableComponent(v.translationKey)) + button.addSprite(false, false, v, widgets.flow[v]!!) + button.addSprite(true, false, v, widgets.flowPull[v]!!) + button.addSprite(false, true, v, widgets.flowPush[v]!!) + button.addSprite(true, true, v, widgets.flowPullPush[v]!!) } button.finish() @@ -87,12 +156,12 @@ private fun moveButtons( top: EditablePanel<*>, bottom: EditablePanel<*>, ) { - top.tooltip = TranslatableComponent("otm.gui.sides.top") - bottom.tooltip = TranslatableComponent("otm.gui.sides.bottom") - back.tooltip = TranslatableComponent("otm.gui.sides.back") - front.tooltip = TranslatableComponent("otm.gui.sides.front") - left.tooltip = TranslatableComponent("otm.gui.sides.left") - right.tooltip = TranslatableComponent("otm.gui.sides.right") + top.prependTooltip(TranslatableComponent("otm.gui.sides.top")) + bottom.prependTooltip(TranslatableComponent("otm.gui.sides.bottom")) + back.prependTooltip(TranslatableComponent("otm.gui.sides.back")) + front.prependTooltip(TranslatableComponent("otm.gui.sides.front")) + left.prependTooltip(TranslatableComponent("otm.gui.sides.left")) + right.prependTooltip(TranslatableComponent("otm.gui.sides.right")) top.x = 30f top.y = 14f @@ -113,39 +182,6 @@ private fun moveButtons( back.y = 14f + 42f } -@Suppress("name_shadowing") -private fun pullPush(frame: FramePanel<*>, pull: BooleanInputWithFeedback, push: BooleanInputWithFeedback) { - if (pull.test(minecraft.player)) { - val pull = LargeBooleanRectangleButtonPanel( - frame.screen, - frame, - skinElementActive = Widgets18.PULL, - skinElementInactive = Widgets18.PULL_DISABLED, - prop = pull, - ) - - pull.tooltip = TranslatableComponent("otm.gui.side_mode.pull") - - pull.x = 30f - 20f - pull.y = 14f - } - - if (push.test(minecraft.player)) { - val push = LargeBooleanRectangleButtonPanel( - frame.screen, - frame, - skinElementActive = Widgets18.PUSH, - skinElementInactive = Widgets18.PUSH_DISABLED, - prop = push, - ) - - push.tooltip = TranslatableComponent("otm.gui.side_mode.push") - - push.x = 30f + 20f - push.y = 14f - } -} - private fun > makeItemHandlerControlPanel( screen: S, inputs: ItemConfigPlayerInput @@ -167,7 +203,6 @@ private fun > makeItemHandlerControlPanel( val top = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.TOP]!!, RelativeSide.TOP) val bottom = makeItemModeButton(screen, frame, inputs.pieces[RelativeSide.BOTTOM]!!, RelativeSide.BOTTOM) - pullPush(frame, inputs.pull, inputs.push) moveButtons(front, back, left, right, top, bottom) screen.addPanel(frame) frame.requestFocus() @@ -196,7 +231,6 @@ private fun > makeEnergyConfigPanel( val top = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.TOP]!!, RelativeSide.TOP).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } val bottom = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.BOTTOM]!!, RelativeSide.BOTTOM).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } - pullPush(frame, inputs.pull, inputs.push) moveButtons(front, back, left, right, top, bottom) screen.addPanel(frame) frame.requestFocus() @@ -225,7 +259,6 @@ private fun > makeFluidConfigPanel( val top = makeFluidModeButton(screen, frame, inputs.pieces[RelativeSide.TOP]!!, RelativeSide.TOP).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } val bottom = makeFluidModeButton(screen, frame, inputs.pieces[RelativeSide.BOTTOM]!!, RelativeSide.BOTTOM).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } - pullPush(frame, inputs.pull, inputs.push) moveButtons(front, back, left, right, top, bottom) screen.addPanel(frame) frame.requestFocus() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 95c511b37..ea34a8d46 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -1686,7 +1686,7 @@ object MatterManager { fun onServerStarted(event: ServerStartedEvent) { check(Resolver.ready) { "Recipe resolver is not ready somehow" } check(Registry.ready) { "Matter registry is not ready somehow" } - finishUpIfRequiredAndPossible(event.server ?: throw NullPointerException("what.")) + finishUpIfRequiredAndPossible(event.server) } fun get(value: Item): IMatterValue { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyConfigPlayerInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyConfigPlayerInput.kt index 2abbbbf96..3525c023f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyConfigPlayerInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyConfigPlayerInput.kt @@ -21,8 +21,8 @@ class EnergyConfigPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockE var default by menu.mSynchronizer.enum(FlowDirection.NONE) init { - pull.filter { allowPull } - push.filter { allowPush } + pull.filter { allowPull && possibleModes.isSupertype(FlowDirection.INPUT) } + push.filter { allowPush && possibleModes.isSupertype(FlowDirection.OUTPUT) } } fun with(config: MatteryDeviceBlockEntity.ConfigurableEnergy<*>.Piece, parent: MatteryDeviceBlockEntity.ConfigurableEnergy<*>) { @@ -34,17 +34,6 @@ class EnergyConfigPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockE val pieces = immutableMap { for (side in RelativeSide.values()) put(side, Piece(side)) } - // TODO - val pull = BooleanInputWithFeedback(menu) - - // TODO - val push = BooleanInputWithFeedback(menu) - - init { - pull.filter { allowPull } - push.filter { allowPush } - } - fun with(config: MatteryDeviceBlockEntity.ConfigurableEnergy<*>) { possibleModes = config.possibleModes @@ -52,12 +41,6 @@ class EnergyConfigPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockE pieces[side]!!.with(v, config) pieces[side]!!.default = config.defaults[side]!! } - - pull.withSupplier { pieces.values.all { it.pull.value } } - push.withSupplier { pieces.values.all { it.push.value } } - - pull.withConsumer { v -> pieces.values.forEach { it.pull.input.invoke(v) } } - push.withConsumer { v -> pieces.values.forEach { it.push.input.invoke(v) } } } init { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/FluidConfigPlayerInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/FluidConfigPlayerInput.kt index aa0afad4e..b7c33511e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/FluidConfigPlayerInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/FluidConfigPlayerInput.kt @@ -21,8 +21,8 @@ class FluidConfigPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEn var default by menu.mSynchronizer.enum(FlowDirection.NONE) init { - pull.filter { allowPull } - push.filter { allowPush } + pull.filter { allowPull && possibleModes.isSupertype(FlowDirection.INPUT) } + push.filter { allowPush && possibleModes.isSupertype(FlowDirection.OUTPUT) } } fun with(config: MatteryDeviceBlockEntity.ConfigurableFluidHandler<*>.Piece, parent: MatteryDeviceBlockEntity.ConfigurableFluidHandler<*>) { @@ -34,17 +34,6 @@ class FluidConfigPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEn val pieces = immutableMap { for (side in RelativeSide.values()) put(side, Piece(side)) } - // TODO - val pull = BooleanInputWithFeedback(menu) - - // TODO - val push = BooleanInputWithFeedback(menu) - - init { - pull.filter { allowPull } - push.filter { allowPush } - } - fun with(config: MatteryDeviceBlockEntity.ConfigurableFluidHandler<*>) { possibleModes = config.possibleModes @@ -52,12 +41,6 @@ class FluidConfigPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEn pieces[side]!!.with(v, config) pieces[side]!!.default = config.defaults[side]!! } - - pull.withSupplier { pieces.values.all { it.pull.value } } - push.withSupplier { pieces.values.all { it.push.value } } - - pull.withConsumer { v -> pieces.values.forEach { it.pull.input.invoke(v) } } - push.withConsumer { v -> pieces.values.forEach { it.push.input.invoke(v) } } } init { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemConfigPlayerInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemConfigPlayerInput.kt index 3424eb284..8c6216f03 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemConfigPlayerInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/ItemConfigPlayerInput.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.menu.input import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity +import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.core.immutableMap import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.menu.MatteryMenu @@ -22,8 +23,8 @@ class ItemConfigPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEnt var default by menu.mSynchronizer.enum(MatteryDeviceBlockEntity.ItemHandlerMode.DISABLED) init { - pull.filter { allowPull } - push.filter { allowPush } + pull.filter { allowPull && isAllowed(MatteryDeviceBlockEntity.ItemHandlerMode.INPUT) } + push.filter { allowPush && isAllowed(MatteryDeviceBlockEntity.ItemHandlerMode.OUTPUT) } } fun with(config: MatteryDeviceBlockEntity.ConfigurableItemHandler.Piece) { @@ -35,17 +36,6 @@ class ItemConfigPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEnt val pieces = immutableMap { for (side in RelativeSide.values()) put(side, Piece(side)) } - // TODO - val pull = BooleanInputWithFeedback(menu) - - // TODO - val push = BooleanInputWithFeedback(menu) - - init { - pull.filter { allowPull } - push.filter { allowPush } - } - fun with(config: MatteryDeviceBlockEntity.ConfigurableItemHandler) { for ((f, v) in allowedFlags) { f.boolean = v in config.possibleViews @@ -55,12 +45,6 @@ class ItemConfigPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEnt pieces[side]!!.with(v) pieces[side]!!.default = config.defaults[side]!! } - - pull.withSupplier { pieces.values.all { it.pull.value } } - push.withSupplier { pieces.values.all { it.push.value } } - - pull.withConsumer { v -> pieces.values.forEach { it.pull.input.invoke(v) } } - push.withConsumer { v -> pieces.values.forEach { it.push.input.invoke(v) } } } init { diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/redstone.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/redstone.png deleted file mode 100644 index 25899a087574c82adaee823065459db4e5ee89c9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 713 zcmV;)0yh1LP)4Tx04UFukv&MmP!xqvQ$>+V2Rn#}WQa}{L`57Wibb$c+6t{Yn7s54nlvOS zE{=k0!NH%!s)LKOt`4q(Aov5~>f)s6A|>9J6k3D|UUf6M;+ajy zXOi*FVmSBXL5wX~)VPnKpk7L>+T_rIKP;p3I@Jrmk zjCUiO<7;zsKW48)9)PBWV0TsT)3o1VUpdRVy5nYzST;7F{$1At70;t2A*OOL1Jq2DdBc z8BjoZhNx!26L`gvS765;p_G&+y8Qlk<|dP3m8zAhz_rfI`MmecIrl$zl2*HOFTTIN z8GpODv}70`L-S%7KR{QZAmAcp3Az?a(B(B~`W8+i#_Lc7y$ijW@``)|`U5JrSZrav z+vzlS`pCvjduzA3)^BdagLZ!_zWw=^U&&H&uIZZN0tIikB9V9$b)8Vd0yd zc0X?KtZy}Yis)``_L}|J`Dgfqz38l*Gb4DI2>I*DefrnrKJ$HYFRv!|E1xF!tGVQU z;aWiwsd95$?bgY>z8Vf}~eeG3B|L_cHuD8D4FczeWss zekQ}uX83Z3zXGrIK7h2|6r^~~FP)$3nt03L{(gq{n@IaEGs2%Tg0Dh4SNO{W8>;X( zudf`IO>me`DKaOA#vDe7Ib%h`9DHbw4~-0F7$OFkrp%v16jEb8!Z_q7xhM+^X1p!* z*vV!%WuCYg=FqfmuE^wuT25J%P35psgR7B`Bl4*kQ^TP~E}|-dHS(z$8BCSAYUEQR zANpF88uJmxDnH5O;~30%Tj;TqO_h9H40C8&Hy8O-wVbjbpW3C%$C8<)K8~mlyTp>P zr8X%Amikz2buK)cr9PJWNFg=4qr~WB>Vr-OSuFI}$%dFGE=F@uA2%2Eamy(S>Vw^( z&Lgk9-5p$7;OVXWGQbmnGo$cfMtBN%h1(Nss0w$yJ^`MfM0p(mtqC3K1cxBu1rzKc z@@WdboU=R{dhj{pu?L^5wD$~vK%H0*z{puOqW~yN0M^5yRyzf=CG$im&j3--!rOt7 z{2U4e4;XwGZZ%c}kg^0|KdfrCQ@~7q zLVX69mpDHMR6&oYabTr>4xvITPvrOnRw44K1Ezo`%OeLoffbSZi4jI+b?{9AOZ_l= zz)~x>npTu2^#iQBhxU|s>gVQ7fvdww2bVB0ztQfk-Q8|(TtKhBWi&3+@u|aK^rFY- zoF3?W6n{VGjju?0e3m5p;cdtz9oKHq%W=`1jExyj89U}BJkFcrv5~?!amxIa2)vXN z#t?x{0`FTW6CMx~j0+|=j`$w<&(3YBiFO(_VIx|$|Ji{gk($V=^9H@!nke_JR9XYo^@**csiT&JiybD zJP!{3;puEu+c0lK44=1}R^%HYZt<6m440{K`oMmf#_3&}8FOD`1$Y%9ZQNXIf=w<% zuUF$rHdwY?!{w6AEk`yQ$h(X-DFv3+$pEBHQwamP_}4 z>ULfabUrHebN=kv({5M3o?t^&>3ID_m`0;u5ROWN0+4+kuttrb9yUt#0!@1!$WHQq zCUE^Xg0j9$trTcq2DnfCKVd#?n`@5W#;I;TcG~3PZAkNSt98S!G(TQ(X@`_`>m d^bKC4dZ$M9Y2Tt}=>6YzAkY*caG9u9&EHSXR#*T4 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.png index b9553b67fcfaa477c3745da08c68d80db3bd8028..23f14bebe429fc7a8ec2139feced02e13080f676 100644 GIT binary patch delta 2595 zcmXw32Q=H;9}kL9TePY9q++$TtJSpjrW&!Hk!OUWcpfDk#;+6=K}o4Tqr{3xjnt@7 z`uePDOX)z2hghZ3J}WUo|IxnxJ?Gy0z2EOS_n!M1-$b!Kh$0T@U?nUlEeHaEgl(+N zQJlS$GvmR0oRuW<`bxHi3j7an=-D(VGW zqr7B!M-%TV;9dBS2cqS?cuoH0>HgGXGi+hY_C^JX&%KN=`e!O;vV(`6A?P$v3oW_! zFx#QK$1C1KsI!!xdsn=-s@wk3pYE^zz8*W()i>I%`flBjwFE^9Dg!*Ru!!{K6pQB$ z7aM|?3t2c`*M|`Lb-KV^4QuwRXxhTLLHND>i%wckmks<9emxysKl$=WXjS)zZgGoG zs?){S-DjWoxYvCA^~+;+GBL5aaQ4E0xKe$p5=u<5EJfJaN70sInTFG2^j%{6_7%hO z>}!R!BHxw?N)hJxzuyI>r}BHqHs{nJ{B7Q$dl(_`SMGtfFhF4fyKw}3k;lzr!aEGq zP+UGb;V}<}PV#BgPUJu5_xcLzy3*!voe3#f);yNL(%r4Rs1pqh@%{J!=WM9dz`p7KJWCO@*%bKy)LhX6i5J1cY0gElTzfDa-hta;~+NFoRX zHn%Z1alSduK%WVhwGm^S*g2QP`y@(LAFO4d=Hs4Z57O=B+Zn z?WK+!3`Vwwp7-~v8_m$}eY*wxILNTkOe!m2epyHmfvA4~3XJ~VF z*{^kukp0-f(@Wb8ztt5yyu-w(yNBvD8=(_>35Xtt2-rW5Nu-ZMEbM*Z81wsWtw@v=J8p z%xYClsxegKWt;j*5)A8NDH1$c*&T2A+JHXVF8bZIKn8=ok7nQewyJ$VuMi=jx}vW| zZ(b6eJ=kMS%{8NvrJs1teYnVJ8*bFbKmxH^h5ov|FTMSp|dSX<68h=~oJEZ*}H zi2ES)46*27J+Sj#rqobcb5`=Xgu94_UgUYi@j1eg2?Kc)HH>oU71#pwV?QM)! z6MjjO$;*)o+Zm>dw!*O4VxV%sSlWZpT5{QxH6iawp9*&i#oc(ppqd5SdZDn53xPqv zN~iz0QsYumj*?S~t}PORI1ChRy+rfw!LX_a$aOQSS-&V;Bh3hcs5Lrk4VHMQOq_TE z#n{jNDe0O}{%t@jP-Ta-v3?MQKh@(9IQll&K4nFtDVm%Ue)~8uc@(yAzqtj)`1m=K zD;nJp?vN@1G20lzu5`ksakJFMq8vO#I@5Nq?2LvQ0-gbj`B zCun!7dKFzDcuT&F^o&x$uq<)^bmh`UQyKpwCo)bL6Eiv%zjMb7=pm3nJnBe$V#faG ziwEfeMz;ZEa&rzeHxiSnPt{oPv%z81cCsaCD0=Dk+&J09G^<`u;QKkfy>9B{SLiv* zj8jI^Y;m`sxz5Fi1uI6}z~{^aI=UgpRK`p<fP5sym5xNtm4u)F>iMP&`!p`(w~v{1ApwS#S!zl5+ zLW#)2hE*|JB`e_3e9T8>?ij8CJDQg*l9p48iVvdm$ObY zpAu2BDAhQ;t!zNyC!jv>xRS9@WKbW?SFO>^KS+U8NIX-a+RS6ydLLVD8%bu*uag#) z-B)tzb7pp3zhGWHFolKv$ZwK>OgP6Z&8eshIY@`6q-v$S*H?ZAM0SOm@C{^wmYM~% z13Jz}Xrt)B;jPZ`k$XJJ`X$^P7471{$@<8`RIxtp9voPLyES448`}xbpG*q~d%e`@ zBvi%v*LJ7uOszAbDb6>JzcmkeI>gEFobsW$BryZXJ$`CVwvb~i+F_s@!DAu{Px|5xD%3r13R3hse(;boucBi1XCoPgLDQ3 z)b&o}t>62gmZH2hzJ5~b_@`ogxK-oTiu*|*F+3++9C&cK1!k);+-*Iw*BPK@C#L-j zDiq9VV0znT7t9LqAGb7d^C*BM0bl)L6s&*YO1bRiH!bY{TY9kn=5$gaEG=0g#%rga z*v(YrsQ=_i3!*R_D-ZNmb}Nf#m&R6}zHNr%d{JAS8iTWTH0&d2rI;iA?w{fyZ=yp( z2xw0LhesoWoUwTWKW|LphD3rQ^14kb%&i{}>8w&^XT2r6I{{c?*@1y_# delta 2010 zcmV<02POE&6oL>TiBL{Q4GJ0x0000DNk~Le0001x0000;2nGNE02wQM`jH_Ve^3;K zPg6@pDh_rK5zJ7X+C@biOBIV?p|llRbufA9A2ex5Qd}Gb*MfsTi&X~~XI&j!1wrr! z#MQ+~(M3wUFDbN$@xkSNocGS*zWV^7Rb#5z7Y9_$GBU}8m@lk~!B+$@P8CH^Vy2$T zF6Q95zV6}U`(2D@dEfhU4Jt*Ge*r#`IL>s#BHkdL-L!Ph`@~^Zkrd){;;2Cl5?YXf{|kZb*PXWKlmT~f1a&bnx1l# zLJ1)7V%r}RKyVjmH*Nd-*tXjzfd3h|(z^b73z+*Pz1h_wN5IfFaBw3XSuNiH2Zz99nX=bC-re6jw}0<+=Jx}k zZ*sW{e|^gU000JJOGiWilez&Ye+3@}HU?q4zlZ<;1^-DzK~#9!?Oicz+)5ChJ@g~e zqzI%4z9xm62QJ*XISf8hJ$V1XadVY%9a6cuNq;W_QaN#EZVqcM5 zyjHY3-^{LbI%z&IHeTImr2RCrv-6=NG8hbo-s05|ByAc6iPp9k+fB7<-vBxY{ zJH9J_5NQ0F0LS>>KUw&3KJ`D&^Dp$p;i-Rdc$#hJ^zey4J$&NZBu|P&Lm&@IASywg zroT6ZkT?<&Nh8lctCbrvd5DM{kit9>(Wn2M%Oy{U=ZjmXjX*?1-#@=~x#S7)_VZ7d zJ6Zoed-mt=k9T)OMD*_VfAMu{C+mFn&6OZeX@4eNMIOmm7m-IYhMUBTqVF2Z=lgi4cF9?6_FUf8wA`Y1)*bdoJnuPPO0*|c$q&Y zAPv$|?S($HDcZ1Oe=ryf27|#cN~{-m$bzzqMcF16o3Z{=_k9orf9+J7$YVXAzb96@Q=KA6 zNQfNbhlFU$PK7W$yg4Cxnm&U%%k^l`o5%HxO8JAV3CH+wP0$5l{mDWmxRkI8Nkd%< ztBgDe0vUO9-p+@aMJS3RNC6sNe;+A;Dl1hQ%i zi>k4Q3tjYce|sxvB;@vty7I@hk<+(DO(z9cjiO|VMZvXisGV4JUw;lQ<2ip)b|!69 z6GK$dNwzXH{%Cw`I(OIpOzIJ*R8AiniJIDLE^9^&U{6^V!PmTGh4ZpN1I zrz<-X>CLeQtKAacQfR@~tllx?DS^*nA9^S}@m@c6Ff2ySma&YNuYta|$}tAE}*EYr-MD zsUA`!mQud;K|!arQ?eQ@CD`hNXb)B-mQud;O+km+DXrKX5{V23gTY`h7)D*j$I9kd zRl+SOx2db#6;4i0R2zQF<GjFil1D=#P7#;Wve1&~`e@g^gs1XM9kohC9%<^*qVW}XIf}&a ze>3X_-!{DKPlB&EZ~V*MGbbHOMV9$|PDDf(7Z)2L51PW*HBfB9jF4w6_?4c{#AAJq zJYkBGj8{_f({Ji`7fBRXfXHyGmR*{%e+@X`kJ=rLUn(aJR<&}7O zXV>X$o2#*;BGD9g_}&h>Kh#I^ESF1%>;*L)Q%S2Wi3$$+UIwJBM!vVAZGWzhcHQ3P zjer02ijMCOsQ!Cwk>@W0ZR%Tzw@Fy_u#tF1;qSf611}|!wkOsWdAKMP8>>RnEFcZi sv63f+P4v4;mElb!Ds9(bFc{jw|9?KV+G)6PX#fBK07*qoM6N<$f?ImX*8l(j diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.xcf b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.xcf index 119df61fc020d2e69e58d8a153e997de00d0f0b6..1556edefad368ba7a8de5d74c0a2feb9fcabf0c0 100644 GIT binary patch literal 70796 zcmeI53zTJ7S?ABax8B{AC$FfZogsmyZbuT(Aj@7L4vWEMvlP8cM${1qNoZDArKc-6 zx^z(l6S5R4pkf#WVYFsBA&XfZu%ZkZLVPxAGghy06tzSY5g&*+C<5KpXMX?xe%y2J zqq@3o(%cBA`_y;#TuWqP`td*+)z z@cFBB^ZXd@399>E;N!w`q0Eov{vh`yH`Cf{4llm+<{PiM`Pku?6Xo=G?O(q2hmPF1 zZ~2xZhhP4bx&1fYe8VkAZaKDZzri)fZhqNI_g(9M*FA;gmkmh1ZlC`t`3IMezVwE} zOE>Sk?pi`WR13wxHLqGaeCxi$OE0I&XBfKL(bxDI?}fKPoS0{r%+0KfBf0e;u(1N`pa2=IIVAi(c`V}LKaDZm@=3h)*03-FbH8{p#Y z0j~UMfIk}B^SW5ikNt9pUyc2K({u>`)Wrebtug2NnXd})t%m}9`-=m-Z!N%I`c#0w z@^t~e??(cB|8EEQ(1!y2_5T~-Z~aMtzx@{ho)lSg{oX!<;*bAlfPZ>LfPZ#tfPemb z0siGv1N^HW4)CvIJ%1P5`}Z#k@&E9X0siAB1Kj#g0ha&Uu+a>7Z%hPUYfOc9HD;e2 z()Sz-aQ?vnFPRDOvadI+|GA!^`XOGKJ$B>Emv6mg=|*Ll;)bD$lKVlR7P8H=tq&zfLY*DClt+YZey}(Vd zq~y;%RH(4xp-F;GayInFN;B2|xqAz>N-?UZq}uW!AVsLu&#oxZ|7n&2tzwJPn#C7F zv900@DnTu66#ukRtc2{uGz-cmOpIDO%gwtasALjT&e>wiS=?z_LD|a5%T&jI75vXJ zvtmf*);rzi3bQK{F8A}Hxht``AeF)zvHK0MqVhZvpq^mEJ)bUG>N!O=R~lqF?QTpI zElMptd~-!C*(2C9pqIySz8>1WSsmjyRPyY0lPx;z~wbc|rVvLJx{jJ$b|_ zLZyBd26lR(W+~7=;wnKcWyG(9;hmirmra-$nvzDG1eHu;%E^d3OYex&Cd&^M{LeA7 zVrVG0-sv`1ow<_HqTJ7i=3W__TN!Z@8(>A{#m+0(aL?n2Q)Kf>M*P5OcY_h9)Y8Mp zh(|A%CO!lU#fU-osP-&Cb z!gGjo`xF(TLy0a*xoW8h9@nlGz$|5I9U_f_8&o2w_z>Pxv_ODb)g-M|Ud?+e#e1a^ zFNt>pc-hopZ#$8;d}1cL2!a%8oYXjDwYtf1io<3-3m+<(@Qfn>oJ&F zUv6AKUU!H&cx%>tH3`22X%QGUg!h=o%3`wIf{(;+(~-{xLF$BkyEkJ5Urv@XZf&|J z^Znves~hj%xc}5^HhyX2y{F!&52ndLD5bdMP4PiMsL&mG@RD~a zGF~Z-;3dD2A`cX;rFrhX#l+GcNPe!ETAKAeYu=o5oZ`d1$N46fuEDan@NZrN8C(QO zNfg)bS(98nF66n0cRYbl{g?ckI(+Mmi_1d7I8laLsB5>Bp($bIx{O&vzEbZaWnA`K zIi*WAL|yig6n}LwkBrsbSZWrncVZUwJWnn$1tBg$(%;F%9{V8;>p0PRBD3An z`bDXL03UmIC7k*nY5lS98IVTQV}B>bKckpG2*wZ2ZZv>r53WqHK6`eB=Q9UaRyHP9 zP8SOW5X$7fGA zfM<`dOua$%^L*y`%F0Pqc(O>r;|d-h96WmTxavP%9Od2e_@0wx1x_EIAWZ$oPx_xi z)PLOdpQQeivv)LrXHTw7{b$wB^O=(?D|e{EJBk!c&55bC;L)QeRsYH2D5>SiJ$IB9 zIDK-0F!i6j!~Ybb{*$ghQh(_w2=!_@5RLZp2_-I?$NbpKq-3g;$?KJQQH3~S&&JPh z{L03CnCUjp|BceQ#*I0S(5787M?-6iU&9?4fTw&t;RE@xi}Naf*7l z1!JA9MdoXys3pw!1ak^=Oj4NNQGdCNXzc(yK-$`(yjDzWER%<{MknM|+LY^J+Ok}_ zHl8}F14!yLadXr+*O@9NXkCN2nOdBBJ4@g7K7TuyG$-bGQt$cOxuiIIqEN({*#@iY+=8*rRvYY+qLzSN!JGniNdaTj zU#^4IHQ*YMwzep*71J8)%5{Ou_0qNRw5B?Mq)rnzM}2c^V3*c4h?}X! zskgKAUGMXE4eTD8<4L{e?;6-WR4C%ideH`yYhbtChusA*t96itI(8Qp^k%zM*{y{d zb{8txEsfoU8g>^d*e#9Sg$i~TB6ee)73`8??BrGZ_=BBx9>*>Gm>8GE8zyGtl%ha5@itXCUZWm3QYo`O5f_2@~QuEtUQm@8qHi! zoZdaFm8p!Xgfd>4U|Gi~N~p?^^;A~@g51n1oHmk#C?gB~wI@D@aOi>&Lm=BmY)Q5uM}^D!C#A*qLrI;NPKXab zX)H5ULq<+-N;c}LNo*4dHz`@=f+dYqtR-Wt%Fms>$UbOgGggi4Z7iN$Rum$zM4+YQ zhQ*_jy8@ENxC#c;B6ni3Dj*qF3B^rr3rFS+yU;A*UbK?xr{BLW(Tr`DUk4EBb_l9Y?ckHU|4#Fk)T(&C@zHPr&v+UjPB z$d?GDwl)}SS1{NHgNOxV5DGR1$=h0p7+fgJg@{3E5@ek*xX>sY3lW3TAPdGIu}vhE zyXS(9K{19p8msa%E6hfbH5G$LxnOWX*fP&X43caNI=L(8A_hryVGCfeBIv+|1ew%@ z1sWLa4b#Jj!6@Kr7>q)$hC#$S7?kMA7+kIJ`4cLl?Qs>6_Lzz&dt4nTMNZ8jx9VXn(MeXN8$!?Rk(jN@tRT1UES@Vlkc0*T zsa$Mr21(W0gcLR*4U4K7#8MDWw2(I}h{zw_4&o?;Bw2#sQL!++vMAExhPXz@_TXj~ zGQ>4Isz@TH+??&82mE}tvpGWoMr4*M(^;BK6;oM?z#EI-puV&-`yv|3c55|Id~21y ztOhclT%|9oK}^sW-Y`LvKfG<~iy;%RMS!FN?58Y>G~*N3ShMxDn%SMW=9(%JvzM#0 zYxKp>XV+F|NWf&v{5_rdn!aRy7SF3MG8fIku&9j0z{O(E*bn$>UcwGGoR{n&pWX>< zsb{y|?5ConsU2mOBSuRVvx&*{A_`LlQ7LLwPiM>a43V@sa};fkoa8n~4hn64UZgj~ zfK3A0YBKTA=%=EOw3?G=C zb~vYXUgYPqYv!QH+%USb!qjUN#j_Y$&`eA_oIpF;*c`kF^D^h69c{HEFfPWanU*$~ zVJFP2^YB?<(!`DMnDnBB3M>jkGC^q(GYflCqgc>2673q9pSVWmA)&_okpD%n++Nsi z4pvL-Ad%l?uf$ejr(pV`E_qL^SeD|DyagfFcr0x3?v4AlXAET=C&qX+?HPqJ#0BDjQMjOIef}D`8K$d;3$BUFh)zyv1g?2ydcjj^J{eTEn`0`Ejcfdz;~85M;Cno7bCovxyovznOWrE}^CP3AC} zPPa9Wlvzb%Ja?2?MWvoGdgg<4pCJZq!8=h~V8St{iQ2*e&C1}6wXU|9v#yxqrR^03 z1xrA?F`AOa#&{YQ8{^4WY)ly&Bb!JQUfyv#G!+Uc2@zE3NrJ&?Jj%v?LCrEQhIx#o6dA*p=L7F2pLih^O(Tk0b+DY&RQP3{xwnktVI1-r4hdVSc)_S?^38o3Pz$w3P$uJzmVeLFZ<<#D0r9h zJ5n&hJ5n%G-qJFQ?Os}=Z@U)Nu{Pv%tPO!4WOMjS-+K7v5ut3P@{uD0q_XIFoM`$g z+A|7Gi#99QGppf5w~?lw`L&gdDUGOSJ};eNsFduY@vI*~?M z!O1ilCI1Dp^QA_#xD=bh3QulIR11$jdw(xJYj557>5Y5#J@Fev300e48w}&bE^6N> z>|(!u6%wvzA5Bld9(H;58wR8i_3Zza;;$>p6BpxN#WMAdZKU1n>)UF z^U#QIvXI{E+rE8R3-8`+O1RN_`r|l&^jeM~J#gx-Q+ICM&#{OH2T+c7w*ECyPCQ4R z#{N0m_`g5rw^A-(!W@s!`ACXq3kJ(Wb49r>$|A9wB60JC=YdMs>LMj*1DVqkaEtfz z?hp^$=T`N9LQT~F&t2p_u5bUY2wxVU|E9bIp8L}w{#$Mi@CC04P>0L!fM`XSB?2#a z;9ds#VkY8;x~JxSdx_#=yle^i+sXtN+~RZ$i+lLpa-5Si`P#}17bIu&xn>pVJntWTS_yH+}ye@WHZ!nhQh~|J~)lsep7F0=|vv4 zt?Xed|KH$YTaS~k@r?2>X4Ip_XlX`ZMD4Mj4Ckt-3rM%h}e=s1?#(s(H z5017V(YAK;5J;>z*@8qH7>bt_Bo7Lp-D|hjK_YII^1ssZrJO!BaS$YDbgc!6cI5?$ zDhbEgZk?>s;4BLgnTI!UK`Yr0Xy8aIUYElrNc7f&Qfa$Wfy{RG=9K#2H_7cZy`>c; zInshK`;l>=E<4iJH^D(Js+eFc%br6VmEql#0pbv@mr>!Hg z>r2~%L~J%A(O$G$3pFINQ)eXFgBCZEE)rcs4T-VNj6{}d8+f7V%&(5k^dQlxwB4ya zNOT&=b6O7)qi^hV_Ll{TmAH(=h3HZxga#xgAL9xV7eJu=K{FCxPlIq>g(U3m@&voX z1lO3VJDJX5Pgh*Z?R{`S)I(R;3DA!*Re^v z%T{oaaKf%pa)%Y1CSN@aac8$O;Q}JfZBo0!S@4K}=oEW9%y?ViS$nFIuY;<^`!zVk z&Ie~$oV1s5LbNk1q~m=-JlzmG!4Vczcz=+A7yIX;qBy99K?}mCfdg$_bSW<=aT>5D zxReG;oCd53t|`K-)Mn4u-mrux=&+!Yqd)Dli24fJ0WvI`R*JgOgyC=kkN;fva`dn$;~ zJ}8J-00{_^Ng#p(w^R@T`%fc4rh!fGi_*|qQFN{^91$TQR}&%18xbLXtqBmNMMOwe z*8~V1ulb$!h9e>@Fd`x>Dk35*BQhd-Sg7kr4?CJk<++M(G*2%B5e+Z;<;c3IB4!9nG1S$81~H?iWq|OEdA2+y%LCJ- zvG^?Y#Vpg1?q8)cv~z2HLylsux8{l+Ta<_w)H9T zhW+eQU&M@I38uxYL{8nYAL2+FH!m*a2+_QEutE>gJ7?MpYQGI1k&s&KbsQTzj&XAq zW>shmYa?rxh0@?7H&dQ%lR%qU^r3XPKnp`|Gtabn!EKiFTKieWA?Q=|zEiJL(5h-P zFVH}T6aA}3r6-zC-lhpET`DlCb$NPA@qL@@_?>v2J|-`qcDK{?Zdw`Ayk6Hh&F|kt zdq$X4HS#e-_pEr~j|b?#X$~JJQZM|)0ck|N@WB+nKT8kBE=mqY#Zm()iNt6{X#t5v zNin5Ui%ClGnl~sU9UwHkN`q7gazOIHGC&VXOdd(ok_Nb(iu)UjUscc!NH(%%;qn+Ae1|#Q$ zQzdP>E~gR_O6T-j;7$>}R#(H~11GUmXW3GX;=Wj8-kXRumZ`?C<@G@>r%B%=UP?Ta zbcVv>Rq@MHHJoYewZ3p!cC|~s*ve7m3gsFnu6Q-=8HFp7f4cg~)%mXm;ZMR$qs?H1%RUAz) zTZF$so6!VoGV_A9*!l88)KpX&HI%DFGs&eQ+(8MsDin~bvhqBsNTOgI|Mezftj_P577gf){r!+FY=nqo?kp+AoXQ(TT5Ff#}&yz|)k&uWCZ&?*&&SlkzmxI9K^Wv@uTlLvE%c z@IxchvN~E6-}kWq{kMl7zK@mDe5EuZ{$oD>wmTC_n}=bYAw9{tT8kABK;`dVSY!{{ zXl|tGgPcFZlp{UKi8;&~sz%aYNO2EzJa^uc1eL4FLV#%!5$vJfQXdf;XwUF@@i_XJ zjzGS}iA<1wc!@R&)0Idxiu0E|m=b^~jmMY#L5kmg_v1IW$ z$>XbN&j1-0e%NuzF4Y?jjm8{+{!x-9wGv_2{_sM;>l_2a}VqURBK zrT9&CuzTI~j_z|7@R3(;dSE~rQ8#7#zgPHk*pihUtF-9u+s!9ga991Hh#ss^y@?+RdyLi@6u7&rOEFx28TGoWJ|epu{@V~;OC#_~EuZ=NvUh3MyR?sT#?iZU6w0ZtoiqAJs*8?2M#&Kw zKs{L7#MYq6;7;~%WXbMy zdKRqahr85=%{oqQk=obMw_V@QPcZz-sUH=l$MxH;TCb2DB0=+2+*ikEz`1_QsW?rZ zuc_qMJMmh2YkC4Ev_xUH6eo!*(Oy_NH6SlhOL4vLRnf!rN3tz0&(d(h)lTt5~Ktf*pD@t%LZ~r&6a`B*lppd>DccAJZpQ<<6M%<$30rHMrC#bI+Ur85A+F z!TL_DM++wB<3IjbEOTo)bZOaM{-biz3I}8G67^HdE?tb4KgFt4YL}m=pC+B3(ekHQ z87VabzG!nsRv)A*$|*0=clr}EH*L$Thz`l;bi_&V93)=|1WXWiz$cjYHL zxLnpq@rxanN|{5_+}cC>MB#LMt5~Nuf@}05PbNH2BfN7Mu#5D zJJz+Y4uK4f#h?Zc8!bH4+;e;g&jZwD3Ul zXyJ?1SQs!`ef8Hyt1q=ST79XN(dtR-8Lghw+Gy3%>Z7$lZ!}u^L7{2R0r!j+`0!|f z4}bijK3d??qXjPYN#EYls#Tjui!Y+sF&7N`kx|M}aV-1`vp|nghDw8vG%^EV@G63b z{BAE)|L8Ymh0orq3BC0;sIMBA@~FPjPQTrDcGD*8@H_aumK}Zvr|ENl^){q3`Mie9 zWIXzya03r%H2R>@R3>B52N@fF9V(+aRh3{Eo7V)X=nqiRXawyRvsgWm578SwVau?{ z* zx0u`Oi5U4b%a?YQ0TI*}1f-b+`9{)&d=Bw_WJ8TOp!AX;{)yq+xeSQ5;MRdia6^Ad zX}cP?Z_gJml>u3mWCpGaM~2o&)c;paDXhZn5H_Ct?sx;rqOCfb`J?DI-C-8*5-tg&rVO&!kk5Ac8A={WlKK0#GVQ z5RT5eabS((n#zEnbUZ){!VzIqsgzJQ6f{5!4A6pfkdBBrk>QY?paCLIuj+{yr-JGs z$PWW_8~MmHP!KXa_QKY1Ff7Q>E|fPo!!bbb1kZ4W10B(?d!%!Q)u-~tDUBiM(>EFt zwUZI((>EFsrGfuGeWUT%u74Vh=OOsBijfNF@CGqfD}u;Gs}!jcsTR~sV-qY(eF&mj z2A2@kR;A3*W6;W*QPd;)JG5nTGl_S}dm7sUMv*QdAG=en`uXZK@+FFG335#fB(f!{ z1(7or(-O}T*ZS)5DxH-`7PPPVpc4Aa96g3kuc{PC197@WTP9bN$dn9~&H*Y5R3O0_ zyHl;&orY(lC=`E+Hi)tK6NGmy`m*({Pl?glY-!tO9Z*7lnWM*ebv#?e`eJz!LYltN zRQ~&|e>lUvMkd{?F}Q@G`j(ix zw|*_e?8x2zlEb&`^VfaChu5C2_tG-CR&sQW)2@PSQ;zd_vS{H=8X?iLris5rO0_UI!Xm_nz+acpGH{G(+Deg5pc?JK2L#* zJe3IwI&o38ur3#QP9iSyVi=9E;-wK*xN1boaXwGxA{pyJVJ0rB7Bx0pq|eRuagnws z$4M8-U1=09I-58kz&mfNgnPK?&Yv5QM%116r+B!?D?(NdUiE>CyuyPT@M;cfpq3-* zq8-ISz^tTL7irbRy2vXesX8T^dc5jk<=~YK8sSw88lja7na{NxQ5Wqfjz+LrU|pn@ z0qY{K0;KAc=tg*EZ}s5WJB{#6okn<8P9thLqAuD|9F1T`tZA2Lzt%>c>89$GI0k%l z$>F7=ue$a7Z+X?NfSzwR%CH+p*Z)zNsp`H=_kMgE|A!wR;{Wja?EjFMDJ-u>l_X~J zvT0OFW}K8Gs-zvo1!f8>kDj9SjF{&gnlT=b(2FxnSER^y_<+M#) zV5YFT<~bvch)ZfTBEHyVrm##FRg#!VDk(2@WtC(WN_nGl+9obAQ&>UrERIIRWg{99 zUmOEwil3#fxq_s9?s3vcVxSS2NM>sFy6f^vs7E8+_0$1rMBVl8Q#?$BH5c{>ARO&V z$g1;B1T3W8hDv(MHylDNoEJduGP4Rx^=#aEe?qmGN-*5QqBiw;v7P#~ZmVgK7SAi` zDc^8NeH^Q#KHd&1&)SNFE?tW2!$xzAY&F%F)`zt?qWUW7Dc^9Yk6z0qA2anc1>(VkJbAR9x0 zlHV-ftaSBo!J7xo|H=F2?@TZ3heoyL&c}%s*~n)pOD;lkk%E?4oA0KkT-!lt#O_8= z38m>5tb+@YO4oa$5}i<#Ly+887sXKwxXNMW;qcr`db8v!D>3Toc z$9k~qWAVxLF-xF6Z+(%^sXKw8KF={!pBKEU?~MT$%zAn;U|u1!Xq?zUq&f;4Xr5HL z-tweMpob0K^34O%hbA3UUB2b(*%myrUnGKj#zy>UHbyHKW?OR&C z>%B~t_#l`pS<^CEGJ$|BSTZgBmGk zlNV@%8tLb0B_@Rp>PmXbHykqUk~z)0!6!MI(=NjjrZS1U0F%56TU*`{1CtkK$Ltpv zM~%5AS@WD~c#poBed>z?+Nf-Cj%^kr@YB{$hiib2;dxSjuYWq@7aQoLG4eR$ca*^gZ%jQ z5pDfGUa$W@t`VyAQF4+2n}ib(L23ZC)hH>#lq8(XP*1k_czKX7$Qi8wOWrVb(e{ec zboL@iBA~V}6$Xp?g~8EJGz6CxY^Ov1`gPaxieC7WcGXkrAP;_hr&~V>+w1use0Cl! zXBZeK&OU@iHK2B5waDiEBsnTFPKUPIjFT1~uoipIbtp}zE*KXt)B&+y9R`c~8OC1k zc+A@Fp_1$!Z}Hqcd4et4JovCo<#cM0xk6-OdT0 z@z8RL*Vw)3N(7QOc<6^Um%)zzG;Etn$1!!ggBjZ$=*TvL21wf)(m{gAes4w$!Na*v zF-R9w^-Wd(D2=f|?hb+)pMJfQP5^-YtZ$N@6I7YwlBS>7sOlT+w;bkM0dDIc-NW|+ zr2Dg;(Kw{A${W_d!KWC|{`R8v*)BGq8~tYmdJhwTL^39?L(nSY{}GGfnGsCUQj zVH7$*UthSjqN=Mxv%AvB<0^FiT9E{dlFcXfP$W>?fLjnML2R?sveDrOlAT`mf0SB(f; zxSnf-LkJXDQD$A0yVEC{V8sa@tT1UpRFtZ0Y`93L82Y%V3E7Mj7wHtkC|vXz-mhHm z&HkT6CQgZ5^xhjP8B-cj@BQHv4;R`0xq83=0uE;m;36MFfO=x4-914)(na#;_9{Nq z(?JHuGEF^9#&wtgDQutU%9#Ti;X?>i9W(9jiAH$wnnp+$dG=2uVwr9P6V9lMyf9ih zb3h|}2!X0&rrkZ!2pMM-AJ$*NgtSpCa}4;X=M+QD=}v~-IG$n{g_-^-F+zY3ytxui z3=^5@f%^ue5%s_aQ+#5k@D-D+lEPiIzGlNYw^HEoXaep-KSwp|~lSXeWT_4x#XP9so@)6NIR+BCsYZM>fr zQ)6wOzI@T9H~ADppDG#0Qw*bU!DkZ%2l%UhRtYCckE-NXPY*~V>ent$@j;bz&l|`l zlfx8L$!P@W19^XbFmi$PhPXg_BW_nkEqA2anc1>(VkJb z;9n922lyKwuY`NJ;5P@&|H=NF`TS3G-)6E9&Kp3Li)_{~nF!|*o^g}ue zk9V=85#`g@B?_!oOT|}&U3PFmceUsX|HJ9#HMWN-JW8Q-8|$J z!^SfcQ3DfV;>>d6#*p^MKOf=$7?78!jnxqU`@bIGhhtc$7~UW!`x6)OLkj#b`r=pU zN9Rw>!xH>d`r;Kh-(Lh9gJ;O2TrVHzeJV^(IWDL*QhcR;;Nd{(-AQ)2fxvVbAmF>S@g_$Td@o11D;I^*w${ zfqt!Xuc?3Fgr6Ot-|O6K>i@_%VV2&96XLeT39jhI1x`f+aYDLrL3$5P7U*BugA=|$ zJ&zcx;UvdJoK)WnI9UK6Weq0_;G?YJ1ea{+L~-R;u)PD7=#3I8Q5)i|y3;+4k4}1a zo0tzy=Dbiw$x#Y_iWo{z?@8}MxW!KLP=>aW)cYEg6CiYv%bV<}tG90Yp7W}`9D#BB zW6#;XqCM_i?0Ffe;kAKhHi;GQXq#MIwaG2WUWNH?lQPABI_@N1#WmVI%X2*p{VHG1 zuRRa?4X-ygfsz^uOKMQI>m#isO^1LSmc(G1qaQ=E#9E%!Q)iwSYOP3ydYD=z-z+7r zKqkZZ~RT}TD`ES^~97W5VfxmUTxJ(}u>uU5GQ^%K(K#Z_)W?s}L$*YazN zg+9W|ja8teg2Ivtl2oc=c64H&CHchl3XAS3 z+x4l>l7ixR)i0W7vY7k4;6B57xsQ>v>)}c(;m+IxxHk6=+K%H~qj=RxU-M0$YdoVv zE%dc=*TeL=mY+V?c$&WEFnzA^GkwkBODpBj+e&?^yB?;uxlVeU+fHwD-_+X|z(b5H zd}rR>L_3KG*>y3m;>sH!GR5(>ZBE> zO3E;#71lSj!diw_Shu(p9wA!cQKJ$=kPu)sJ)*g zf6`bQ4O!HITRKlI zC)?5m7FPd+nJpzr3_9cs; zCRwARC@e!tDP4*wiBe3Vlv27B=vFk_gTA$$k%Jq>0l|VvCB(0BV`#xPMjqpcak|MVuEsJi3(<0lXg^>h7 zNIYYrHEp^voXgvimPIe6Smc^0Fgqwg;uWK(X=8{|*0&`si%v?h$aEPLx|8|DKcpOldrRd^yE$qY}Nsz*u@UVJfd<&U+OB8%b*bi`%M0&(|rz zb8|}Y904WfIXNYGPO+^jR0&@5gPyRmwkhG^wXm|cR-crTojOj`q>ZIfsOj$#B?S11 zy#7r%QB0(!PrS2|H>DBviC<0e+ej%=~MzMv%} zj8+}>!|h#qL9583((Z^XDxg*}hs*){W^a-{lpt$Laz%4MpwTK1x`igbOj-tN7pa(bEhF94C6x5RXDn zpHczc>r+3_eeP9spZduGX+(YM-W303|C_G=O&{fGiSu6*<>UkFVe~&e==@WZM4vvH zC`#v8(z}Hm*s(t`^VjrMMEk@tKmN1?{R($?+o!|`Al{GpU@IX z>ND~8PPV?A_qn#BXNv;@iRwkl*U@W3i>r{*zz_Xsf^C$0G99uDBrSQoMMzpP2HzQsggk zSJ~{(5N~f5EyZ%nuO@r5=FL<+bxLDjU2IZ;zHZqn2+?_Grm*;HBb^3X$f-hocUx0$=3q>j`Tw3%fBJO7bC!wxsQ@U^gb zyPBV!e|+3Z?V1b9D3@1@AZ6R%jkN3sC;35I*+smL*@uc22mfq)NR=y)kB1zV?laTtLqndNm)@?%wy)FMRdIUY_UP4-dTV~K^wu0->8<&< z(%Z=4xwj5idh7hLw~~8RPZmvjv%?t>goCdO z9uwlS>;r>DwGRv)6XGhKgYS%eHmqA|fjLLJS+rn{7MN3Lfgvq$Jhg}`#0`R4rx7QJ z0|W^NKNniCN(-|83oQ_};~x|JWN3k?eAO*5Rnr1fvv$JB$@jm4ze(~tp#_eo7Ex-} zNIZ)=vj$4kO$*HPyl+Sg%;U7cvVsUeQY5pw4vUo?7AtW?35$`fVipIL5?AWLOqg(H zBE%`qWPyP&>C7;Y>Za#qIG)JaxQQc5SdgR?98~OLVuqj;GXkYR?12d=MdIBA?^62a zW-g@+jw%qeTuwyPayc13N9-#F){(&0(x*z0>x)X*nbXRQiEH^4LRpor#?fPC6uSCY zq6x!B@sUb6(N3VNMo~T4lhXKwiiVzjL05fl1*WUzOjnv-Sx9e7R|w&{TY)KJJ=2vY zBNnvV(iMWV?pEMZ7BXGs&6NvIS4WNrUsbwl5*{acr3Q{dSAU@n=Bv^2v9}mbv=iy7 z^&L51SC&CntyiY_bI7Y`b_Wxiu^hf8zMZ_nWc9aOZMss*@OAM%NmG$m(M+^yC~0${ z*2d?nzhf=DRf%gHeN{#wuDt7J0%=VCR3a2$4{=Q%ACLxdO`b^c=MY+++aYc=e?xd} zLtNVlEfJT5mWT_u4RLKJv_xFlU*!T4SM*h>EuG8A5(AHu(2}ppD0KDbi6#si(^YSS z9=e**x@x*o8gwE6>AU!cZ5-ZUOJZ|)YAEI0}GqH?$66CLOa4TuC#P6C8(wI z;l|al5;SYr+2VVjxEsl^nhw8@EEH8m)Hph-j6zC#0ujW&jk#^~-`sap@>WP`uB!ir zk&?udc3~u*L`uVT-!MXuXc8evG>Mdk>%CzmNGz!YEr+Ot3#Id-qe`Dxl1LgSv2+#f z8HJWUTA>d_%-+{l!iip@Ew%UU1Jd-)FQ@oHwiFEQWlP2p7`8gLb$aTvqbR{kfs_FB zY>m%$?!skBVo9?#&-Zp!!tUmKQ?{Rkq^eXJM=zC8C`o(W-K%lYp#9%SNf-TfH)A%c zprng)^dQ3tI>1QsW|}wBkO*ID?sK#34Zn5cr#J2qqN>C+LwKCTlG-;4F{v-zt8wWS z-9RRoNKBXJ?|+jgi7bfe(ifz6zC>MAF5h_Y)N421xADNKyON8FFj6I(ar93ag>1wI z-K%l=w|4`XG$Pqt?q!mgULl*yZ%^+GGP03DSVERTvWymG8Evc0`s^A?z>e|4y6hV1 PqV3(eM=xPSBm4gY4|(?1 literal 37629 zcmeI5e~esLb;sY#?Ck7MJ0Zb1G$l@BU^9b53?UJfQ%Fig3L8U(+X4+ZvEw*aJ?mx1 zPGX9(f#8NTaY#{XQK5>WP|37KPSZu9r6g2Uwf*6$>-1MD+)BC^%(AE-EbYl zU5G1{_<0rXEx7y2{Os4yhxK!_ey&x5&HA}k-p%@Xm1WZ1MYxe0pZVctIqomU4dMP3 zx53{l-K%kbg}Y!cjoPxWdHdcyTlUWFyMv%ah5g}F>)_%2dp5NW?B93Cm19$P?%jQ0 z|ADzpQ%1JT?cH_zrmO95>yj=?@&e;wDGympHnm;po-kBiCE6a`bHkN&5lkNNtY&;MQkm6Obj?>e;mSN0sd zYIeq+%(Ev^b0vZ)?sDC~<9>b-Q=Gz;RZY>ouAjn%`%9zyvFLtNbUz;5Pek{V(fxYv zRo^^L?62WehsuAwzlS87b)RxUuZZsBVMK7aDyPF8G_b9Mc<9Lq~`MsIr?cTZIJw|ouOqr}N93y8n`94XX zJAO=_;p7K+DC5}72yMI=E%HiBUjm+{^nO~!(G}?^j^6aNOn4dpGLl$LOKou>O*>T? zHC)xxVSi5#rV?M9R5Y<@ysbZVbm^N*UpsaG(jPB<{nTd_JxIe;n($iOT8F9EfO;%l zwFexvU$H>W57XKg3*rc>Jr%;=lvHLWaTCeV%s2yKEE%2|H8;xe9mTJ(+>Kkhp_who zk0R$5#AzL(Guh=v5s%S=@G|L3=@vb1;EhCNc;CT2&6Yw3Nisf6d-{g@~79Fyo+xzbEIseGjjZNIP1l)hCZEKuUVQu-Fo(#7|qK5sE~ z^}PParA8FrB(8)qEJajdE?jX%u04HmeiMPvpOW;EUAG@RxM%LLI(m>~U0SRkSzo6I z%C8A;|5`|RelP12zn7=Wv;aX9-wff`C6n9W__ood5_DzT{P1JtWM!WF7q-pMFAdE< zpDZQ8yG`D0#opQ3Z9}t)oh5I&ZG0(>Xl>gN{-NZD+m`H4KJ@Lj>#*7;Pf-7f(UT?U z%8B{mM^r!eFPxa4KdA~&Cc%3`-V?>%+1V4S|3orN-t@%y$uy$16GQl^|HMiAlaKmO zSp6rd|K#YA5_IL{{O~=hpZgb1&d(oFg-4R$4bAbfZQj}0ldAt@GD~cFa{Ndd(b~x& z{M3K)i2cb&{U@z{Fa2pc&eTr5mB&o+)z?&mJl)E|IBBc)2;6)LL?-q(*qTIowuwrCFkkaQa9HH%1RvK`QP`E-pDfx|3R%rpwQBK9j zl@?r@lJ_fa*y?~&3n~?ArHhuQYs8H$I5$L_N`#HHh3T0_dCKwvTx;N_$M9L38*pwq zkvCm{a}7Ax=;B-*&Y5fHT)i&N)#chaS2xbp;at6qb9Lif9nRGw&P9bsoNEisI7dAx z`AeeWTs`6(VWm2p6BXy68Rxh!*WsL~IA_#zt`6sLL$oR5To#sbuHMEuwJzdZJ?7jI zObe}@s3s+ux#6UOvecTaf&uLuEK4b#uqq1KxpGniI#5^*)5SR+$I|h*S$QfOAw&7L zhbiw$Vpb0vYNIu937#;8Gc={0)@YKNqGHv|nAVap9w)dV=8f?-zk39&0dmK9$eIdk zC@)P#<>r&mCO0rlrEOTEqLr$Q_G*iBf#fSJU9c4N zk|dyvlvU}yYMm7HtisZ|rJ$u+AeVVMErP4GzHCoV3b&};jGFa0R%W+IosTU&z4S** zPi(qktMu^ea3eUc#0P33(E7>ypnn zYQKRiULjoa<$^fn`Lht-&%mf;qoRV$YfOxEjE4!r$4NDI4#q$w8vqq#OX5G$A^H=9 zkCSTb9EiKG4O#cKF({mT2PyBY?In@y38cE0T+>=JP`znx z-xM@;))X)6n60iUFPn*Ag7y6umVRsL_@*n~CP|3xqYC~(8ZK&IKf~o8R6u@RW-mLu zzhk&u=HK{QY>2~i*d{jVE`5zxM^6_>jwaLpPm=SGq1PR~JcD%b2kv+S z;_~lAX+s=AmoJC#Hy8*cyIQc1S=B;$P^XjlC!qp~WKDy#;8=1Rt@?PErrS^uKq5O; zkce5SUOi3XpCnH4GLTtI<0#cArCPj8(>X=c)|a5vb2jk@NKTTu9!>U)y~zC9AfuIP z@@CvxUuX)3?}1iszKytW1=e`6-27=50mhSGAq^p$zwCmq{Dlxb4~m_dAf_ldhgQA{ zamAVg&>PQ@$_o_W1D&w|2m(&I%qv5OQ;rgwuT?t^6c|{I^WZ`F6 z0E30V9Y#0m8qbVg&$`r&=4S;j9 zr7V^PTP)OLm&0nf#VNINLWSOtv&JI?d{UUHL)qHH1jdeNxe*Xb?BhhUrq`=nDCedNFE5jjS0$Ajy*>xpt zAf#%@ut*RX#%Q~9TA|!}lTst)0+oggmn1cE+3ws(C@)xQdbR>!GsFT{Xt?^K-I1C! z<+`QjnJZwFLxxw98tk&&k&-m!^i9&Ynh=Vx%bLS3l_VJERe87u$-KIc_UIATI;X|v z6vZ^A_z71qp@v*Q<6R*F8sfNZ+#15C{8ZuAt`!7A_@bt$D&kRX))0^pn~q?=O$|!P zd$%S@90;jjcaKE{KsjW|HA9q{{@ky^!xFe=6@Y~6?OF5EgeI8gbPGkAzzWv%0NP#e zS87Pz2y0pCSEpl@l4+rVGIt=PTj=UnMjZ;-l1tT=O$qB);bG}pvkHLP^)jWAHNntC z%{&#u7g0qBuQdTtrU@uW-vmqfLZfa?aM}2!Is94^04|lBCPcq9AzSkLCe%X{u0rCA zfXkpog4PI{A-tQAU!z>(`pxRq(9N>)#&h6OQSqo4G}KaC*ZLV1i+aHPy6R{0`-~-i zR9vOaP~i&f!hh9V2wdB!(89wFiEt;xUZz|a25vA+FpkC<1Y>;-04+$I^oKhk;~FOI zazBAUjwA15eaX7jVS*m+thPwFouGHt_L7M8Xh1F1U$IaR8e}O!>qn^nG6rBnk0w88pbU-_`y%f~Y%s&5e;i3<*D6uK8#|96{II9l~FMEOW@R zOLD};L9(g)m7MH-rR)7`i{Afu$+`CPK|-KGs<^%Oi4g7-t$TaPq9)kW%=!VclqH=* zl>xF0@q#QXNwJmS-WyV?S5Z}F_W)VSI?bWV09l53L6($SXbqg}QqS3}A22s(%zg;~ z{p(9loq9l=9@Nd1n`zrxmv;JWAi$M+#^`$c`p6U5;zjc9Z*_6+{QH751ik$OF8m$e z4eT!V-{JZDT3{^;JnP z;4o~sWPe6WX@D%6%SnrkPc=b|s&tW>Y>P}>BM^ygy-d}P!dL(lwsH1~)uzqjIKh+T z?Ga0vJ>rI`FQxUse=Seh23oT%TzVos3ANN-er z+a$^^%tbM=NA=pqY5jzuUv8|py_|Yk!BaAl1yYvSEM}Vr0nO+q+q^^n*vbHE%je~U zMJln{OjZI|tg=m0FlE@@Nk1(p4gJ$tP8KM!CO}h_POFB_8hJL`=xG}f3uEE6fw9GT z1-}-TD@c#LJz^=dM;!e`K5Yl(<+r13I<478Iz5q|guSqW5=cS+i1G|o+f+(F0U)cz zdeK8ak>05Mwk4H*nidm#RA1Cjw)M&PlWp8=>nGdcZ zhJLawtn?Fbb<|I!&-%#&%W*$-RiE_}NTY$jaL8`yr;O51fRIA~kfPcrmQ(FqE#cSB zRmKp&a8BbLtO9xI9Rqts=_Sf4+qP6y9oMHesLVJlq)}W-TZ-d`to-7*inXsePMbp8 z+Ysubf2gl!n@2mTo(X(q#xD_Vx@*%ju5 z#xX{MaIvOf*$71l_67T9W)B_QdEn4N$fhf7S`Q00ncKPs$?Vqtl78%+8GEAa=Z62u zZgbPx+c-DI_D^JX-}uImX9`(hs^^zME0e{H5g8>6LQIjC88$8jL&K*%yE`}euQdG} zui4+t<*wK%z-(>6qH<;qn~!a#)r?Ccm}eJk)^;hV+NV9cJ2$hfH2egnsm)DPu2^dX z05*-V$wgGt2#v5wL#mbveTuc-)l6-x5vHB35vGM*#nuQL?m>eFZ5cEp757vJK`nIB zpp}C530g+!rX&YJFtlD6>p6@D4g1y*>Sq`o(4*(qO+TIAXB_dv=%!yRh$HBxY$#62 z>UV?4DE(%ZJ^f~OytXGO{%oj*O&Qx+mNAob_u_eHUhbtwkPea3oh_6pWgZeZyEah2I4F;=^v0(L4x+`S>#=)pfDh0F2 zprPd&y!{M=*+{gxz4?a79~6Th1~-4CAWnJwnKFqKxfXaV+$vZb`eLujB2Zro*6bTX z7mE_JRA)j_Ubd7(dD(&y<>i-!<)(>=7Ah=2D%dFcTC2)pM&H=gc%?)67JD|7`fN!= zeYWtSKEJ#vH>^Gx+^Ub6!Ro^(xB7UgLp>IIHq_TgX;xn_&#jyR7zPm#-ep$}8W1kw z>}Mo=ERt?+-}~Ok-!T&2ySE@tdFDg-D?oS-gm+1f^vNJu6ZsLg9o%WoQn3EecB z04ixveS3@!bg#Y@M=h4-OsLmq0*VZX@cPs8{|IV3|HgDcnPo0dvS0W~?H4|EWN_j4 z(BQSg?^1<5;P>}G8VP%-#~Tyxf6~Q$@V0_91ik-R7ye84hWHnS-+@?6syRErER1&G zSg{&UoE|`I7!6PlJlif{8)<@{d%@SB5vt>50>)cw7prD}b-q^6Q)qeNtTfiSrfIbD zm(}KC#V^@%EG0yF^6)C7e-NHtFs;CO1!kvZu%yAqij_WMM=-HLn?ODMY&(xlQwiMc z1!D93s^et>$y;lut7g6CptXCspr_Dc$=SH{l4)wFK_xC${E{V1FNyNx4p1372T*)l zZv`ur8Y%`~wDnf7WiU*Ne)04HY-65l~F9EyB8>h zdCxsCAN5w(D~7h-f*)CL8K%_MTktaLEiJF%RR4fH`~Xz08YoR4wSmiuqi1>m(rypMml(lM-<$~`&yIpsw}=-3_70FI z=c?PqivW8E$dePn@4a=r2%vX>JUKCwdT%2y0_e{MkbjFN@Bqlm%Fs1P=Kp=PM`rq3 zEudX`p#1vKr}O(xB=JMPTM$RkhwSJp#pQrJ=5{N`$}{+!ulnp|`dTr0VKKt>HOnLO z8Sby@x&e7Y7jmpTgU|U0(B2fU6_Xc0BV3WFC#s|`Evw@(zDleL3;)**$KF>=BG~6N<6q}AT+*d8JEhtaLyEr=uNR$iyND**BW+yitTpmYbU)6-`R$J1*D z zSb}FWD1v7*$YC|(nRaLSl@4wF;>L84r2xo3!~Y?80$AR@JQ&pd@Djwes!a)Q4?zAd zg@-FJ#v2oN{j7^<-VhQ%LmF=H^7i@u-wyHf$s=~q@H&4y#cTB?b2!L@V|B}mob%~V zw+N>RPXdhSLyi0-VfnS|LJ09s(5l~8khK1UwL5LD~qe2b~hBq=-`PRDUtES&YbW(@h4JbJORuyo?w8vbCdCBVHr;> zR{>90!KB)cDxL^~?&Jya+OKLnfwu8PWfIoL6Kamn)G(e{Sj3Z%FXxG!`O(G`J%2sp z30NX>Vqc-Z791d)s{u!%vnlcu)M*2lLAzi7aE11ogAc5K!+9C{=PW`ob1LMQ@j@By zJPn@Tkl{dep2m1oH|I8?ZiDNtn`h7JRvWba8!5@ zu5~5w(0zjm#2RvbIg zP4}aPN9~Yaj>1MR^afJ$VdpS$O1(>i#dJnU(=9<396fYv^qiOUc)%c&x@9p>64IpX3V8BFT5ek5mm=ygZ$ITralBY+` zBrIQ=h-uE2uf>|EYf_>FCL_}$nv|r8FnLzdME#f0za|QBgv=oQ+o*4FJn#S`Icl!1 zwN7Y1N8TPt&f)*ClHE^Wi&sV;pLD_V*+HxLLmF;BzQx7g_fX-0ba5pSgd?NB4ayne090am zCuxWeEfJ*!0SR&lkA?#)P%Bmc9ZFUoZdG)LCs3Y{PkTl)e23{*oXF4}{T~{4EKazd}zcYt(sJVefs5jh`%~36}ghLF!fZ#Bjt;EBo4$p0{QVgvb7=HGwg>{27x0twq6Vvit{Th z$63wDLYH0*Z)O94G)VT1cD(6Y>%`~ZIpj+!czP*92iLzI$%MwEg|l=4m&^gb*#V24t&<++tow^F26*c9V{Axg{Jh6+ewE3J);LP{jG)Awe763nVuwS;r4lt#n<^%3u4VHz|XsNZFnX71>E@Q%n61jY-~gZCH2 z5%l2aL->y=4s=oXKlKquVzChm2gyk4S8PT?mpl5<7b1U$*gW)9K^#F3WoHu>&1L~^ z_Bu$j87`mcx^z(2Tto>L<~4}sB3wSxb?Kn~OE|YWXx;3g)?J(K*w?y!*Zw^=E(b}1 z^xjq1T4%A>y6oZi;eQKv&<+WD_=g2?1U+(L2){ll9p%s=@&Jd%ta=6}K* z#`Ny#8VR|!lWRM$Xb9Cx@>_kW@nGv$YC= z4D9IojsJ~29YXNAO#hQ6#Buw%D?=W-a|dkg>0t8?*t`Qa?|{uaVDk>^&d15s(~;|O day?G2$I10LxgNJ%S@*?V8Saa_^z4P;{{WHCEs+2K From 378f39b877b7ddf7c9ee77d6316dd3809f546331 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 20 Jun 2023 20:41:35 +0700 Subject: [PATCH 0633/1199] Remove phantom attractor as android feature --- .../mc/otm/datagen/ResearchData.kt | 21 ------------------- .../mc/otm/datagen/lang/English.kt | 1 - .../mc/otm/datagen/lang/Russian.kt | 1 - .../feature/PhantomAttractorFeature.kt | 14 ------------- .../otm/capability/MatteryPlayerCapability.kt | 9 +------- .../mc/otm/registry/AndroidFeatures.kt | 1 - 6 files changed, 1 insertion(+), 46 deletions(-) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/PhantomAttractorFeature.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt index ed1655e51..fa7d66bdc 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt @@ -345,20 +345,6 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang serializer.accept(ENDER_TELEPORTER) - val PHANTOM_ATTRACTOR = - AndroidResearchType.Builder(modLocation(MNames.PHANTOM_ATTRACTOR)) - .withExperience(20) - .withDescription() - .withIcon(ResearchIcons.ICON_PHANTOM_ATTRACTOR) - .addFeatureResult(AndroidFeatures.PHANTOM_ATTRACTOR) - .addPrerequisite(NANOBOTS) - .addItem(MItems.PHANTOM_ATTRACTOR) - .addItem(MItemTags.COPPER_WIRES, 2) - .addItem(MItemTags.TRITANIUM_PLATES, 2) - .build() - - serializer.accept(PHANTOM_ATTRACTOR) - val JUMP_BOOST_1 = AndroidResearchType.Builder(modLocation(MNames.JUMP_BOOST + "_1")) .withExperience(27) @@ -511,13 +497,6 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang russian("Используйте с осторожностью, так как данная технология сама по себе не поглащает урон от падения!") } - add(PHANTOM_ATTRACTOR, "Builtin Phantom Attractor") { - russian("Встроенный Приманщик Фантомов") - } - add(PHANTOM_ATTRACTOR, "description", "Allows to attract phantoms while active under same conditions as non-Androids") { - russian("Позволяет привлекать фантомов под теми же условиями, как и не Андроиды") - } - add(JUMP_BOOST_1, "Jump Boost") { russian("Усилитель Прыжка") } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index efaf4c0c7..ec5f59c67 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -628,7 +628,6 @@ private fun androidFeatures(provider: MatteryLanguageProvider) { add(AndroidFeatures.NANOBOTS_ARMOR, "Nanobots Armor") add(AndroidFeatures.ITEM_MAGNET, "Item Magnet") add(AndroidFeatures.STEP_ASSIST, "Step Assist") - add(AndroidFeatures.PHANTOM_ATTRACTOR, "Phantom Attractor") add(AndroidFeatures.JUMP_BOOST, "Jump Boost") add(AndroidFeatures.ENDER_TELEPORTER, "Ender Teleporter") } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index ad0fc506c..bfe2cda11 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -633,7 +633,6 @@ private fun androidFeatures(provider: MatteryLanguageProvider) { add(AndroidFeatures.NANOBOTS_ARMOR, "Броня из наноботов") add(AndroidFeatures.ITEM_MAGNET, "Предметный магнит") add(AndroidFeatures.STEP_ASSIST, "Помощник подъёма") - add(AndroidFeatures.PHANTOM_ATTRACTOR, "Приманщик фантомов") add(AndroidFeatures.JUMP_BOOST, "Усилитель прыжка") add(AndroidFeatures.ENDER_TELEPORTER, "Телепортатор края") } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/PhantomAttractorFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/PhantomAttractorFeature.kt deleted file mode 100644 index b8dd02dd1..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/PhantomAttractorFeature.kt +++ /dev/null @@ -1,14 +0,0 @@ -package ru.dbotthepony.mc.otm.android.feature - -import com.mojang.blaze3d.vertex.PoseStack -import net.minecraft.client.gui.GuiGraphics -import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature -import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability -import ru.dbotthepony.mc.otm.client.render.ResearchIcons -import ru.dbotthepony.mc.otm.registry.AndroidFeatures - -class PhantomAttractorFeature(android: MatteryPlayerCapability) : AndroidSwitchableFeature(AndroidFeatures.PHANTOM_ATTRACTOR, android) { - override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float) { - ResearchIcons.ICON_PHANTOM_ATTRACTOR.render(graphics, x, y, width, height) - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index af3645ec9..36c96ccb7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -1274,14 +1274,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial */ @JvmStatic fun phantomSpawnHook(iterator: Iterator): Iterator { - return iterator.filter { - if (it.matteryPlayer?.isAndroid == true) { - val feature = it.matteryPlayer?.getFeature(AndroidFeatures.PHANTOM_ATTRACTOR) as AndroidSwitchableFeature? - feature?.isActive == true - } else { - true - } - } + return iterator.filter { it.matteryPlayer?.isAndroid != true } } /** diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/AndroidFeatures.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/AndroidFeatures.kt index c1ee11123..bfaf0ed4b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/AndroidFeatures.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/AndroidFeatures.kt @@ -21,7 +21,6 @@ object AndroidFeatures { val SHOCKWAVE: AndroidFeatureType by registry.register(MNames.SHOCKWAVE) { AndroidFeatureType(::ShockwaveFeature) } val ITEM_MAGNET: AndroidFeatureType by registry.register(MNames.ITEM_MAGNET) { AndroidFeatureType(::ItemMagnetFeature) } val FALL_DAMPENERS: AndroidFeatureType by registry.register(MNames.FALL_DAMPENERS) { AndroidFeatureType(::FallDampenersFeature) } - val PHANTOM_ATTRACTOR: AndroidFeatureType by registry.register(MNames.PHANTOM_ATTRACTOR) { AndroidFeatureType(::PhantomAttractorFeature) } val JUMP_BOOST: AndroidFeatureType by registry.register(MNames.JUMP_BOOST) { AndroidFeatureType(::JumpBoostFeature) } val ENDER_TELEPORTER: AndroidFeatureType by registry.register(MNames.ENDER_TELEPORTER) { AndroidFeatureType(::EnderTeleporterFeature) } From c76681d7406a6ce9b64f9ed518a413d82d91b108 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 20 Jun 2023 20:58:14 +0700 Subject: [PATCH 0634/1199] React to ESC press while android research tree is open --- .../mc/otm/client/screen/tech/AndroidStationScreen.kt | 3 +++ 1 file changed, 3 insertions(+) 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 81188a326..2f3eda8cb 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 @@ -614,6 +614,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I if (research?.isRemoved == false) { research!!.toScreenCenter() popup(research!!) + research!!.requestFocus() return } @@ -635,7 +636,9 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I researchCanvas.setDockMargin(4f, 4f, 4f, 4f) research!!.toScreenCenter() + research!!.closeOnEscape = true addPanel(research!!) + research!!.requestFocus() } override fun resize(minecraft: Minecraft, p_96576_: Int, p_96577_: Int) { From 1a9ae25fa89a84f7c0ba2348027a3b93f1a3f7f5 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 20 Jun 2023 21:01:16 +0700 Subject: [PATCH 0635/1199] Remove phantom attractor research advancement --- .../advancements/AndroidAdvancementsData.kt | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt index 436127d29..a487f0b3c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt @@ -145,20 +145,6 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .addCriterion("has_item", criterion(MItems.PHANTOM_ATTRACTOR)) .save(serializer, modLocation("regular/phantom_attractor"), existingFileHelper) - AdvancementBuilder() - .parent(attractor) - .display( - itemStack = ItemStack(MItems.PHANTOM_ATTRACTOR), - title = translation.add("phantom_attractor_research", "Deception of Phantoms") { - russian("Обман фантомов") - }, - description = translation.add("phantom_attractor_research.desc", "Research into how to attract Phantoms the same way as the ones who need to sleep") { - russian("Исследуйте привлечение фантомов, чтоб привлекать их так же, как те, кому нужно спать") - }, - ) - .addCriterion("researched", AndroidResearchTrigger.Instance(modLocation(MNames.PHANTOM_ATTRACTOR))) - .save(serializer, modLocation("regular/phantom_attractor_research"), existingFileHelper) - val researchAnything = AdvancementBuilder() .parent(root) .display( From da89401985c6ea4722f0c07dd1bcd2afd9a0e544 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 20 Jun 2023 21:14:44 +0700 Subject: [PATCH 0636/1199] updated localization files --- .../mc/otm/datagen/advancements/AndroidAdvancementsData.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt index a487f0b3c..c93400485 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt @@ -108,7 +108,7 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper russian("Изготовленный по старинке") }, description = translation.add("death.desc", "In event of death, become an Android; Veteran's favorite") { - russian("Будучи умерев, станьте андроидом; Ветераны оценят") + russian("Станьте андроидом, будучи умерев; Ветераны оценят") }, hidden = true, ) @@ -136,7 +136,7 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper .display( itemStack = ItemStack(MItems.PHANTOM_ATTRACTOR), title = translation.add("phantom_attractor", "Eversleeping Decoy") { - russian("Вечноспящий декой") + russian("Фантоматичная приманка") }, description = translation.add("phantom_attractor.desc", "Put together a Phantom Attractor, to be able to fight Phantoms as Android again") { russian("Создайте приманщик фантомов, для привлечения фантомов вновь, будучи андроидом") From 070b962df91c3e108d2f97a9d2aeeb10a47a7b20 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 20 Jun 2023 21:28:01 +0700 Subject: [PATCH 0637/1199] Add GatherTooltipsEvent to AndroidResearch --- .../ru/dbotthepony/mc/otm/android/AndroidResearch.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt index e092efa06..ad276b238 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt @@ -8,7 +8,9 @@ import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.player.Player +import net.minecraftforge.common.MinecraftForge import net.minecraftforge.common.util.INBTSerializable +import net.minecraftforge.eventbus.api.Event import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.awareItemsStream @@ -249,6 +251,11 @@ class AndroidResearch(val type: AndroidResearchType, val capability: MatteryPlay return false } + /** + * Fired on main event bus each time research lines are being gathered + */ + data class GatherTooltipsEvent(val research: AndroidResearch, val tooltips: MutableList) : Event() + /** * List of all tooltip lines for this research */ @@ -260,6 +267,8 @@ class AndroidResearch(val type: AndroidResearchType, val capability: MatteryPlay line.addLines(this, lines) } + MinecraftForge.EVENT_BUS.post(GatherTooltipsEvent(this, lines)) + return lines } From 805297564a7f1e2139ab33f8fa97ee6da6252e13 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 20 Jun 2023 21:31:56 +0700 Subject: [PATCH 0638/1199] Add more events to android research --- .../mc/otm/android/AndroidResearch.kt | 29 +++++++++++-------- .../mc/otm/android/AndroidResearchResult.kt | 10 +++---- .../otm/capability/MatteryPlayerCapability.kt | 2 +- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt index ad276b238..2a5ab14df 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt @@ -3,25 +3,23 @@ package ru.dbotthepony.mc.otm.android import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream import net.minecraft.ChatFormatting import net.minecraft.nbt.CompoundTag -import net.minecraft.nbt.ListTag import net.minecraft.network.chat.Component -import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.player.Player import net.minecraftforge.common.MinecraftForge import net.minecraftforge.common.util.INBTSerializable +import net.minecraftforge.eventbus.api.Cancelable import net.minecraftforge.eventbus.api.Event +import net.minecraftforge.eventbus.api.Event.HasResult import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.awareItemsStream import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.core.nbt.getCompoundList import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.milliTime import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer -import ru.dbotthepony.mc.otm.registry.MRegistry import ru.dbotthepony.mc.otm.triggers.AndroidResearchTrigger import java.io.InputStream import kotlin.math.absoluteValue @@ -49,20 +47,27 @@ class AndroidResearch(val type: AndroidResearchType, val capability: MatteryPlay return } - onRefunded() + onUnResearched() isResearched = false } - fun onRefunded() { + data class OnResearched(val research: AndroidResearch) : Event() + data class OnUnResearched(val research: AndroidResearch) : Event() + + fun onUnResearched() { for (result in type.results) { - result.onRefunded(this) + result.onUnResearched(this) } + + MinecraftForge.EVENT_BUS.post(OnUnResearched(this)) } fun onResearched() { for (result in type.results) { result.onResearched(this) } + + MinecraftForge.EVENT_BUS.post(OnResearched(this)) } /** @@ -114,16 +119,14 @@ class AndroidResearch(val type: AndroidResearchType, val capability: MatteryPlay return true } + data class OnRefunded(val research: AndroidResearch) : Event() + /** * Grants all (or some) resources back consumed by [consumeResearchCost]. * * Returns true whenever player accepted all resources refunded, false otherwise. */ - fun refund(simulate: Boolean): Boolean { - if (simulate) { - return true - } - + fun refund(): Boolean { if (type.experienceLevels > 0) { var experiencePoints = 0 @@ -148,6 +151,8 @@ class AndroidResearch(val type: AndroidResearchType, val capability: MatteryPlay } } + MinecraftForge.EVENT_BUS.post(OnRefunded(this)) + return true } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchResult.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchResult.kt index 39e43b686..8dfa6821d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchResult.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchResult.kt @@ -32,7 +32,7 @@ object AndroidResearchResults { feature.strength++ } - override fun onRefunded(research: AndroidResearch) { + override fun onUnResearched(research: AndroidResearch) { val feature = research.capability.getFeature(AndroidFeatures.NANOBOTS_ARMOR) ?: return feature.strength-- } @@ -48,7 +48,7 @@ object AndroidResearchResults { feature.speed++ } - override fun onRefunded(research: AndroidResearch) { + override fun onUnResearched(research: AndroidResearch) { val feature = research.capability.getFeature(AndroidFeatures.NANOBOTS_ARMOR) ?: return feature.speed-- } @@ -82,7 +82,7 @@ interface AndroidResearchResult { research.capability.addFeature(feature ?: return) } - override fun onRefunded(research: AndroidResearch) { + override fun onUnResearched(research: AndroidResearch) { research.capability.removeFeature(feature ?: return) } @@ -122,7 +122,7 @@ interface AndroidResearchResult { } } - override fun onRefunded(research: AndroidResearch) { + override fun onUnResearched(research: AndroidResearch) { val get = research.capability.getFeature(feature ?: return) if (get == null) { @@ -160,7 +160,7 @@ interface AndroidResearchResult { /** * Called when research is refunded */ - fun onRefunded(research: AndroidResearch) {} + fun onUnResearched(research: AndroidResearch) {} companion object { private val LOGGER = LogManager.getLogger() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 36c96ccb7..f7bccfebb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -492,7 +492,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial instance.unResearch() if (refund) { - instance.refund(simulate = false) + instance.refund() } } } From a518c98999a56b607516e736d886608bcb7514a3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 20 Jun 2023 21:38:38 +0700 Subject: [PATCH 0639/1199] Visual clarity for added event classes --- .../mc/otm/android/AndroidResearch.kt | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt index 2a5ab14df..41e754cf6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt @@ -25,6 +25,26 @@ import java.io.InputStream import kotlin.math.absoluteValue class AndroidResearch(val type: AndroidResearchType, val capability: MatteryPlayerCapability) : INBTSerializable { + /** + * Fired on main event bus [MinecraftForge.EVENT_BUS] + */ + data class OnResearched(val research: AndroidResearch) : Event() + + /** + * Fired on main event bus [MinecraftForge.EVENT_BUS] + */ + data class OnUnResearched(val research: AndroidResearch) : Event() + + /** + * Fired on main event bus [MinecraftForge.EVENT_BUS] + */ + data class OnRefunded(val research: AndroidResearch) : Event() + + /** + * Fired on main event bus [MinecraftForge.EVENT_BUS] + */ + data class GatherTooltipsEvent(val research: AndroidResearch, val tooltips: MutableList) : Event() + val ply: Player get() = capability.ply val synchronizer = FieldSynchronizer() @@ -51,9 +71,6 @@ class AndroidResearch(val type: AndroidResearchType, val capability: MatteryPlay isResearched = false } - data class OnResearched(val research: AndroidResearch) : Event() - data class OnUnResearched(val research: AndroidResearch) : Event() - fun onUnResearched() { for (result in type.results) { result.onUnResearched(this) @@ -119,8 +136,6 @@ class AndroidResearch(val type: AndroidResearchType, val capability: MatteryPlay return true } - data class OnRefunded(val research: AndroidResearch) : Event() - /** * Grants all (or some) resources back consumed by [consumeResearchCost]. * @@ -256,11 +271,6 @@ class AndroidResearch(val type: AndroidResearchType, val capability: MatteryPlay return false } - /** - * Fired on main event bus each time research lines are being gathered - */ - data class GatherTooltipsEvent(val research: AndroidResearch, val tooltips: MutableList) : Event() - /** * List of all tooltip lines for this research */ From c40375d6078e0be10be00bde82e2d8a79e1a3145 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 20 Jun 2023 21:43:03 +0700 Subject: [PATCH 0640/1199] Add ConsumeResearchCost event --- .../dbotthepony/mc/otm/android/AndroidResearch.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt index 41e754cf6..563f0e293 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt @@ -45,6 +45,12 @@ class AndroidResearch(val type: AndroidResearchType, val capability: MatteryPlay */ data class GatherTooltipsEvent(val research: AndroidResearch, val tooltips: MutableList) : Event() + /** + * Fired on main event bus [MinecraftForge.EVENT_BUS] + */ + @HasResult + data class ConsumeResearchCost(val research: AndroidResearch, val isSimulating: Boolean) : Event() + val ply: Player get() = capability.ply val synchronizer = FieldSynchronizer() @@ -100,6 +106,15 @@ class AndroidResearch(val type: AndroidResearchType, val capability: MatteryPlay return true } + val event = ConsumeResearchCost(this, simulate) + MinecraftForge.EVENT_BUS.post(event) + + if (event.result == Event.Result.ALLOW) { + return true + } else if (event.result == Event.Result.DENY) { + return false + } + if (!simulate && !consumeResearchCost(true)) { return false } From 4cd0c4c555b83b52a30b97a81541ad860a2e2536 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Tue, 20 Jun 2023 21:03:43 +0300 Subject: [PATCH 0641/1199] ad astra version bump --- build.gradle.kts | 9 ++++++--- gradle.properties | 5 ++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 538d65843..109a5b536 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -181,6 +181,9 @@ dependencies { val curios_version: String by project val jei_mc_version: String by project val curios_mc_version: String by project + val resourceful_lib_id: String by project + val resourceful_config_id: String by project + val botarium_id: String by project val ad_astra_id: String by project compileOnly(fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}+${curios_mc_version}")) @@ -193,10 +196,10 @@ dependencies { //runtimeOnly(fg.deobf("curse.maven:jade-324717:${jade_id}")) //runtimeOnly(fg.deobf("curse.maven:configured-457570:${configured_id}")) + compileOnly(fg.deobf("curse.maven:resourceful-lib-570073:${resourceful_lib_id}")) + compileOnly(fg.deobf("curse.maven:resourceful-config-714059:${resourceful_config_id}")) + compileOnly(fg.deobf("curse.maven:botarium-704113:${botarium_id}")) compileOnly(fg.deobf("curse.maven:ad-astra-635042:${ad_astra_id}")) - compileOnly(fg.deobf("curse.maven:resourceful-lib-570073:4574449")) - compileOnly(fg.deobf("curse.maven:resourceful-config-714059:4444198")) - compileOnly(fg.deobf("curse.maven:botarium-704113:4416456")) // runtimeOnly(fg.deobf("curse.maven:worldedit-225608:${worldedit_fileid}")) // runtimeOnly(fg.deobf("at.ridgo8.moreoverlays:MoreOverlays-updated:${more_overlays_version}")) diff --git a/gradle.properties b/gradle.properties index d6c35d542..5840466ca 100644 --- a/gradle.properties +++ b/gradle.properties @@ -26,7 +26,10 @@ jupiter_version=5.9.2 mekanism_version=1.19.2-10.3.5.homebaked curios_version=5.2.0-beta.2 cosmetic_armor_reworked_id=4575609 -ad_astra_id=4452010 +ad_astra_id=4594155 +botarium_id=4594094 +resourceful_lib_id=4598948 +resourceful_config_id=4576455 jade_id=4573193 configured_id=4462894 From 2298dd17c774b23f2ea01a6b212d8e269475651b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 22 Jun 2023 22:55:00 +0700 Subject: [PATCH 0642/1199] Update black hole code structure --- .../entity/blackhole/BlackHoleBlockEntity.kt | 134 ++++++++---------- 1 file changed, 60 insertions(+), 74 deletions(-) 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 41e9360d7..917d02b53 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 @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.block.entity.blackhole +import it.unimi.dsi.fastutil.objects.ObjectArraySet import net.minecraft.client.Minecraft import net.minecraft.core.BlockPos import net.minecraft.nbt.CompoundTag @@ -28,7 +29,6 @@ import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MItems -import ru.dbotthepony.mc.otm.registry.MRegistry import ru.dbotthepony.mc.otm.core.math.getSphericalBlockPositions import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set @@ -36,13 +36,17 @@ import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.registry.MDamageTypes import ru.dbotthepony.mc.otm.registry.MatteryDamageSource import ru.dbotthepony.mc.otm.triggers.BlackHoleTrigger -import java.util.LinkedList import kotlin.math.pow import kotlin.math.roundToInt import kotlin.math.sqrt class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryBlockEntity(MBlockEntities.BLACK_HOLE, p_155229_, p_155230_) { var mass by synchronizer.fraction(BASELINE_MASS, setter = setter@{ mass, field, setByRemote -> + if (setByRemote) { + field.write(mass) + return@setter + } + if (mass <= Decimal.ZERO) { collapse() return@setter @@ -50,77 +54,41 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery field.write(mass) setChanged() - var massForDiv = mass - - when (if (level?.isClientSide == false) stabilizers.size else stabilizerClientCount) { - 1 -> {massForDiv /= 4} - 2 -> {massForDiv /= 16} - 3 -> {massForDiv /= 64} - 4 -> {massForDiv /= 512} - 5 -> {massForDiv /= 2048} - 6 -> {massForDiv /= 16384} - } - - gravitationStrength = sqrt(massForDiv.div(BASELINE_MASS).toDouble()).coerceIn(0.2, 40.0) - - affectedBounds = BoundingBox( - (-30 * gravitationStrength).toInt(), - (-30 * gravitationStrength).toInt(), - (-30 * gravitationStrength).toInt(), - (30 * gravitationStrength).toInt(), - (30 * gravitationStrength).toInt(), - (30 * gravitationStrength).toInt() - ).moved( - blockPos.x, blockPos.y, blockPos.z - ) - - affectedBoundsAABB = AABB.of(affectedBounds) + updateGravStrength() }) - override fun getRenderBoundingBox(): AABB { - return AABB(blockPos.offset(-GravitationStabilizerBlockEntity.RANGE, -GravitationStabilizerBlockEntity.RANGE, -GravitationStabilizerBlockEntity.RANGE), blockPos.offset( - GravitationStabilizerBlockEntity.RANGE, GravitationStabilizerBlockEntity.RANGE, GravitationStabilizerBlockEntity.RANGE)) - } - - var gravitationStrength = 1.0 + var gravitationStrength by synchronizer.double(1.0).property + private set + var affectedBounds = BoundingBox(0, 0, 0, 1, 1, 1) + private set + var affectedBoundsAABB: AABB = AABB.of(affectedBounds) private set - private var suppressUpdates = true - var spinDirection = false + var spinDirection by synchronizer.bool().property + private var lastSphereSizeOuter = 0 + private var sphereIndexOuter = 0 private var sleepTicks = 4 + private val stabilizers = ObjectArraySet(6) + + init { + updateGravStrength() + } override fun setLevel(level: Level) { super.setLevel(level) sleepTicks = 4 } - private fun updateMass() { - mass = mass - } - - private val stabilizers = LinkedList() - private var stabilizerClientCount by synchronizer.int(setter = setter@{ value, field, setByRemote -> - field.write(value) - - if (setByRemote) { - updateMass() - } - }).property - fun stabilizerAttached(stabilizer: GravitationStabilizerBlockEntity) { - if (stabilizer in stabilizers) - return - - stabilizers.add(stabilizer) - mass = mass - stabilizerClientCount = stabilizers.size + if (stabilizers.add(stabilizer)) { + updateGravStrength() + } } fun stabilizerDetached(stabilizer: GravitationStabilizerBlockEntity) { if (stabilizers.remove(stabilizer)) { - mass = mass - stabilizerClientCount = stabilizers.size + updateGravStrength() } } @@ -161,6 +129,39 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery } } + private fun updateGravStrength() { + var massForDiv = mass + + when (stabilizers.size) { + 0 -> {} + 1 -> massForDiv /= 4 + 2 -> massForDiv /= 16 + 3 -> massForDiv /= 64 + 4 -> massForDiv /= 512 + 5 -> massForDiv /= 2048 + else -> massForDiv /= 16384 + } + + gravitationStrength = sqrt(massForDiv.div(BASELINE_MASS).toDouble()).coerceIn(0.2, 40.0) + affectedBounds = BoundingBox( + (-30 * gravitationStrength).toInt(), + (-30 * gravitationStrength).toInt(), + (-30 * gravitationStrength).toInt(), + (30 * gravitationStrength).toInt(), + (30 * gravitationStrength).toInt(), + (30 * gravitationStrength).toInt() + ).moved( + blockPos.x, blockPos.y, blockPos.z + ) + + affectedBoundsAABB = AABB.of(affectedBounds) + } + + override fun getRenderBoundingBox(): AABB { + return AABB(blockPos.offset(-GravitationStabilizerBlockEntity.RANGE, -GravitationStabilizerBlockEntity.RANGE, -GravitationStabilizerBlockEntity.RANGE), blockPos.offset( + GravitationStabilizerBlockEntity.RANGE, GravitationStabilizerBlockEntity.RANGE, GravitationStabilizerBlockEntity.RANGE)) + } + override fun saveLevel(nbt: CompoundTag) { super.saveLevel(nbt) nbt["mass"] = mass.serializeNBT() @@ -173,11 +174,6 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery spinDirection = nbt.getBoolean("spin_direction") } - var affectedBounds = BoundingBox(0, 0, 0, 1, 1, 1) - private set - var affectedBoundsAABB: AABB = AABB.of(affectedBounds) - private set - private fun setDeltaMovement(living: Entity, center: Vec3, distance: Double, weaker: Boolean) { //final double mult = Math.min(2, (30 * this.gravitation_strength) / Math.max(1, Math.pow(distance, 2))); // Сила притяжения @@ -204,9 +200,8 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery } fun clientTick() { - sleepTicks-- - if (sleepTicks > 0) return - val ply = Minecraft.getInstance().player!! + if (--sleepTicks > 0) return + val ply = Minecraft.getInstance().player ?: return val center = Vec3.atCenterOf(blockPos) if (!ply.abilities.mayfly && ply.getItemBySlot(EquipmentSlot.CHEST).item != MItems.PORTABLE_GRAVITATION_STABILIZER) { @@ -222,10 +217,8 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery override fun tick() { super.tick() - sleepTicks-- - if (sleepTicks > 0) return + if (--sleepTicks > 0) return val level = level as? ServerLevel ?: return - suppressUpdates = false val center = Vec3.atCenterOf(blockPos) @@ -311,13 +304,6 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery } } - private var lastSphereSizeOuter = 0 - private var sphereIndexOuter = 0 - - init { - mass = mass - } - companion object { const val ITERATIONS = 30_000 val BASELINE_MASS = Decimal(50_000) From 4e62b47f84b9bc6849bbeac63cdf49de81696578 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 22 Jun 2023 22:55:30 +0700 Subject: [PATCH 0643/1199] Rename fraction() to decimal() in FieldSynchronizer --- .../otm/block/entity/blackhole/BlackHoleBlockEntity.kt | 2 +- .../mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt | 4 ++-- .../mc/otm/capability/energy/AndroidPowerSource.kt | 4 ++-- .../mc/otm/menu/storage/StoragePowerSupplierMenu.kt | 3 +-- .../ru/dbotthepony/mc/otm/menu/tech/EnergyCounterMenu.kt | 9 ++++----- .../mc/otm/network/synchronizer/FieldSynchronizer.kt | 2 +- 6 files changed, 11 insertions(+), 13 deletions(-) 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 917d02b53..1a52a7391 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 @@ -41,7 +41,7 @@ import kotlin.math.roundToInt import kotlin.math.sqrt class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryBlockEntity(MBlockEntities.BLACK_HOLE, p_155229_, p_155230_) { - var mass by synchronizer.fraction(BASELINE_MASS, setter = setter@{ mass, field, setByRemote -> + var mass by synchronizer.decimal(BASELINE_MASS, setter = setter@{ mass, field, setByRemote -> if (setByRemote) { field.write(mass) return@setter diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt index 967565860..d98d77123 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt @@ -28,7 +28,7 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import java.util.* class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.ENERGY_COUNTER, p_155229_, p_155230_) { - var passed by synchronizer.fraction() + var passed by synchronizer.decimal() override val blockRotation: BlockRotation get() { return BlockRotation.of(blockState[EnergyCounterBlock.INPUT_DIRECTION]) @@ -37,7 +37,7 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat private val history = Array(10 * 20) { Decimal.ZERO } internal var historyTick = 0 - var lastTick by synchronizer.fraction() + var lastTick by synchronizer.decimal() internal set var ioLimit: Decimal? = null diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt index 75550ca61..c5aeff61e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt @@ -27,8 +27,8 @@ class AndroidPowerSource( override val energyFlow: FlowDirection get() = FlowDirection.INPUT - private var battery by synchronizer.fraction(initialCharge) - private var maxBattery by synchronizer.fraction(maxCharge) + private var battery by synchronizer.decimal(initialCharge) + private var maxBattery by synchronizer.decimal(maxCharge) var item by synchronizer.item(setter = setter@{ value, access, setByRemote -> access.write(value) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StoragePowerSupplierMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StoragePowerSupplierMenu.kt index e1f84a444..4e4a2bc00 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StoragePowerSupplierMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StoragePowerSupplierMenu.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.menu.storage import net.minecraft.world.entity.player.Inventory -import net.minecraft.world.inventory.Slot import ru.dbotthepony.mc.otm.block.entity.storage.StoragePowerSupplierBlockEntity import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.registry.MMenus @@ -11,7 +10,7 @@ class StoragePowerSupplierMenu @JvmOverloads constructor( inventory: Inventory, tile: StoragePowerSupplierBlockEntity? = null ) : MatteryPoweredMenu(MMenus.STORAGE_POWER_SUPPLIER, p_38852_, inventory, tile) { - var totalTransferred by mSynchronizer.fraction() + var totalTransferred by mSynchronizer.decimal() var activeNodes by mSynchronizer.int() init { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyCounterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyCounterMenu.kt index 80d56a523..7898683ff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyCounterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyCounterMenu.kt @@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.menu.tech import net.minecraft.core.Direction import kotlin.jvm.JvmOverloads import net.minecraft.world.entity.player.Inventory -import net.minecraft.world.inventory.Slot import net.minecraft.world.level.block.Block import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.block.tech.EnergyCounterBlock @@ -19,10 +18,10 @@ class EnergyCounterMenu @JvmOverloads constructor( inventory: Inventory, tile: EnergyCounterBlockEntity? = null ) : MatteryMenu(MMenus.ENERGY_COUNTER, p_38852_, inventory, tile) { - var passed by mSynchronizer.fraction() - var average by mSynchronizer.fraction() - var last20Ticks by mSynchronizer.fraction() - var lastTick by mSynchronizer.fraction() + var passed by mSynchronizer.decimal() + var average by mSynchronizer.decimal() + var last20Ticks by mSynchronizer.decimal() + var lastTick by mSynchronizer.decimal() var maxIO by mSynchronizer.bigDecimal() val switchDirection = oneWayInput { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt index 22f349eb2..2cc385b8b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt @@ -241,7 +241,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } @JvmOverloads - fun fraction( + fun decimal( value: Decimal = Decimal.ZERO, getter: FieldGetter? = null, setter: FieldSetter? = null, From 97d3a07065860d6e57d0a53abf72bf6b9bd2bb11 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 23 Jun 2023 00:00:35 +0700 Subject: [PATCH 0644/1199] Allow MatteryWorkerBlockEntity to have multiple job event loops --- .../block/entity/MatteryWorkerBlockEntity.kt | 90 ++++++++++++------- 1 file changed, 56 insertions(+), 34 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt index 76b08ebb7..99bb0d976 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt @@ -1,7 +1,9 @@ package ru.dbotthepony.mc.otm.block.entity +import com.google.common.collect.ImmutableList import net.minecraft.core.BlockPos import net.minecraft.nbt.CompoundTag +import net.minecraft.nbt.ListTag import net.minecraft.network.chat.Component import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag @@ -12,12 +14,14 @@ import net.minecraft.world.level.block.state.BlockState import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matteryEnergy +import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.nbt.getCompoundList import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set /** - * Simple machine, which can work on only one job at time. + * Simple machine, which can work on only one job type. * * From technical point, this is a specialized use case of [MachineJobEventLoop]. */ @@ -25,32 +29,35 @@ abstract class MatteryWorkerBlockEntity( type: BlockEntityType<*>, blockPos: BlockPos, blockState: BlockState, - val jobDeserializer: (tag: CompoundTag) -> JobType? + val jobDeserializer: (tag: CompoundTag) -> JobType?, + maxJobs: Int = 1 ) : MatteryPoweredBlockEntity(type, blockPos, blockState) { - val jobEventLoop = object : MachineJobEventLoop() { - override val energy: IMatteryEnergyStorage? - get() = matteryEnergy - override val isBlockedByRedstone: Boolean - get() = redstoneControl.isBlockedByRedstone + val jobEventLoops: ImmutableList> = immutableList(maxJobs) { + object : MachineJobEventLoop() { + override val energy: IMatteryEnergyStorage? + get() = matteryEnergy + override val isBlockedByRedstone: Boolean + get() = redstoneControl.isBlockedByRedstone - override fun deserializeJob(nbt: CompoundTag): JobType? { - return jobDeserializer.invoke(nbt) - } + override fun deserializeJob(nbt: CompoundTag): JobType? { + return jobDeserializer.invoke(nbt) + } - override fun onJobFinish(job: JobType): JobStatus { - return this@MatteryWorkerBlockEntity.onJobFinish(job) - } + override fun onJobFinish(job: JobType): JobStatus { + return this@MatteryWorkerBlockEntity.onJobFinish(job) + } - override fun computeNextJob(): JobContainer { - return this@MatteryWorkerBlockEntity.computeNextJob() - } + override fun computeNextJob(): JobContainer { + return this@MatteryWorkerBlockEntity.computeNextJob() + } - override fun jobUpdated(new: JobType?, old: JobType?) { - this@MatteryWorkerBlockEntity.jobUpdated(new, old) - } + override fun jobUpdated(new: JobType?, old: JobType?) { + this@MatteryWorkerBlockEntity.jobUpdated(new, old) + } - override fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: JobType): JobStatus { - return this@MatteryWorkerBlockEntity.onWorkTick(requiredPower, extractedPower, ticksAdvanced, job) + override fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: JobType): JobStatus { + return this@MatteryWorkerBlockEntity.onWorkTick(requiredPower, extractedPower, ticksAdvanced, job) + } } } @@ -64,53 +71,68 @@ abstract class MatteryWorkerBlockEntity( override fun saveShared(nbt: CompoundTag) { super.saveShared(nbt) - nbt["JobLoop"] = jobEventLoop.serializeNBT() + nbt["jobs"] = ListTag().also { + for ((i, job) in jobEventLoops.withIndex()) { + it.add(job.serializeNBT().also { + it["_id"] = i + }) + } + } } override fun load(nbt: CompoundTag) { super.load(nbt) - nbt.map("JobLoop", jobEventLoop::deserializeNBT) + + for (v in nbt.getCompoundList("jobs")) { + if ("_id" in v) { + val id = v.getInt("_id") + + if (id in jobEventLoops.indices) { + jobEventLoops[id].deserializeNBT(v) + } + } + } } override fun setChanged() { super.setChanged() - jobEventLoop.isIdling = false + jobEventLoops.forEach { it.isIdling = false } } override fun setChangedLight() { super.setChangedLight() - jobEventLoop.isIdling = false + jobEventLoops.forEach { it.isIdling = false } } protected fun powerLevelUpdated() { super.setChangedLight() - jobEventLoop.notify(MachineJobEventLoop.IdleReason.POWER) + jobEventLoops.forEach { it.notify(MachineJobEventLoop.IdleReason.POWER) } } protected fun itemContainerUpdated() { super.setChanged() - jobEventLoop.notify(MachineJobEventLoop.IdleReason.ITEM) + jobEventLoops.forEach { it.notify(MachineJobEventLoop.IdleReason.ITEM) } } protected fun matterLevelUpdated() { super.setChangedLight() - jobEventLoop.notify(MachineJobEventLoop.IdleReason.MATTER) + jobEventLoops.forEach { it.notify(MachineJobEventLoop.IdleReason.MATTER) } } override fun redstoneStatusUpdated(newBlocked: Boolean, oldBlocked: Boolean) { super.redstoneStatusUpdated(newBlocked, oldBlocked) - jobEventLoop.isIdling = newBlocked + jobEventLoops.forEach { it.isIdling = newBlocked } } override fun tick() { super.tick() - jobEventLoop.think() + jobEventLoops.forEach { it.think() } - if (jobEventLoop.errorTicksAnim > 20 && blockState.hasProperty(WorkerState.WORKER_STATE) && blockState.getValue(WorkerState.WORKER_STATE) != WorkerState.ERROR) { - level?.setBlock(blockPos, blockState.setValue(WorkerState.WORKER_STATE, WorkerState.ERROR), Block.UPDATE_CLIENTS) - } else if (jobEventLoop.workingTicksAnim > 20 && blockState.hasProperty(WorkerState.WORKER_STATE) && blockState.getValue(WorkerState.WORKER_STATE) != WorkerState.WORKING) { + if (jobEventLoops.any { it.workingTicksAnim > 20 } && blockState.hasProperty(WorkerState.WORKER_STATE) && blockState.getValue(WorkerState.WORKER_STATE) != WorkerState.WORKING) { level?.setBlock(blockPos, blockState.setValue(WorkerState.WORKER_STATE, WorkerState.WORKING), Block.UPDATE_CLIENTS) - } else if (jobEventLoop.idleTicksAnim > 20 && blockState.hasProperty(WorkerState.WORKER_STATE) && blockState.getValue(WorkerState.WORKER_STATE) != WorkerState.IDLE) { + } else if (jobEventLoops.any { it.errorTicksAnim > 20 } && blockState.hasProperty(WorkerState.WORKER_STATE) && blockState.getValue(WorkerState.WORKER_STATE) != WorkerState.ERROR) { + level?.setBlock(blockPos, blockState.setValue(WorkerState.WORKER_STATE, WorkerState.ERROR), Block.UPDATE_CLIENTS) + } else if (jobEventLoops.all { it.idleTicksAnim > 20 } && blockState.hasProperty(WorkerState.WORKER_STATE) && blockState.getValue(WorkerState.WORKER_STATE) != WorkerState.IDLE) { level?.setBlock(blockPos, blockState.setValue(WorkerState.WORKER_STATE, WorkerState.IDLE), Block.UPDATE_CLIENTS) } } From f4c36cc7283ad572749ecbd8f45958d17ccc86da Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 23 Jun 2023 00:04:10 +0700 Subject: [PATCH 0645/1199] Specify "id" of job event loop --- .../block/entity/MatteryWorkerBlockEntity.kt | 18 +++++++++--------- .../matter/MatterDecomposerBlockEntity.kt | 4 ++-- .../entity/matter/MatterRecyclerBlockEntity.kt | 6 +++--- .../matter/MatterReplicatorBlockEntity.kt | 18 +++++++++--------- .../block/entity/tech/CobblerBlockEntity.kt | 4 ++-- .../block/entity/tech/PlatePressBlockEntity.kt | 4 ++-- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt index 99bb0d976..c6682a858 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt @@ -32,7 +32,7 @@ abstract class MatteryWorkerBlockEntity( val jobDeserializer: (tag: CompoundTag) -> JobType?, maxJobs: Int = 1 ) : MatteryPoweredBlockEntity(type, blockPos, blockState) { - val jobEventLoops: ImmutableList> = immutableList(maxJobs) { + val jobEventLoops: ImmutableList> = immutableList(maxJobs) { id -> object : MachineJobEventLoop() { override val energy: IMatteryEnergyStorage? get() = matteryEnergy @@ -44,28 +44,28 @@ abstract class MatteryWorkerBlockEntity( } override fun onJobFinish(job: JobType): JobStatus { - return this@MatteryWorkerBlockEntity.onJobFinish(job) + return this@MatteryWorkerBlockEntity.onJobFinish(job, id) } override fun computeNextJob(): JobContainer { - return this@MatteryWorkerBlockEntity.computeNextJob() + return this@MatteryWorkerBlockEntity.computeNextJob(id) } override fun jobUpdated(new: JobType?, old: JobType?) { - this@MatteryWorkerBlockEntity.jobUpdated(new, old) + this@MatteryWorkerBlockEntity.jobUpdated(new, old, id) } override fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: JobType): JobStatus { - return this@MatteryWorkerBlockEntity.onWorkTick(requiredPower, extractedPower, ticksAdvanced, job) + return this@MatteryWorkerBlockEntity.onWorkTick(requiredPower, extractedPower, ticksAdvanced, job, id) } } } - protected open fun jobUpdated(new: JobType?, old: JobType?) {} - protected abstract fun onJobFinish(job: JobType): JobStatus - protected abstract fun computeNextJob(): JobContainer + protected open fun jobUpdated(new: JobType?, old: JobType?, id: Int) {} + protected abstract fun onJobFinish(job: JobType, id: Int): JobStatus + protected abstract fun computeNextJob(id: Int): JobContainer - protected open fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: JobType): JobStatus { + protected open fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: JobType, id: Int): JobStatus { return JobStatus.SUCCESS } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index a40f508ac..3fdb11ce5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -165,7 +165,7 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) return MatterDecomposerMenu(containerID, inventory, this) } - override fun onJobFinish(job: DecomposerJob): JobStatus { + override fun onJobFinish(job: DecomposerJob, id: Int): JobStatus { if (job.toDust) { job.matterValue = moveMatterAsDustIntoContainer(job.matterValue, outputContainer, 0, 1) @@ -183,7 +183,7 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) return JobStatus.SUCCESS } - override fun computeNextJob(): JobContainer { + override fun computeNextJob(id: Int): JobContainer { val stack = inputContainer[0] if (!stack.isEmpty) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index 3aed65360..aac8e8df3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -107,12 +107,12 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) return MatterRecyclerMenu(containerID, inventory, this) } - override fun onJobFinish(job: RecyclerJob): JobStatus { + override fun onJobFinish(job: RecyclerJob, id: Int): JobStatus { // вся логика в onWorkTick return JobStatus.SUCCESS } - override fun computeNextJob(): JobContainer { + override fun computeNextJob(id: Int): JobContainer { if (matter.missingMatter.isZero) return JobContainer.noMatter() @@ -127,7 +127,7 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) return JobContainer.success(RecyclerJob(dustMatter.matter.toDouble() * TICKS_PER_MATTER, POWER_CONSUMPTION, dustMatter.matter * (0.4 + level!!.random.nextDouble() * 0.6))) } - override fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: RecyclerJob): JobStatus { + override fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: RecyclerJob, id: Int): JobStatus { val receive = job.totalMatter / job.ticks if (receive.isZero) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index a7d1c70b3..e82116f59 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -118,15 +118,15 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } override fun onMatterTaskCreated(task: IReplicationTask<*>) { - jobEventLoop.notify(MachineJobEventLoop.IdleReason.OBSERVING) + jobEventLoops[0].notify(MachineJobEventLoop.IdleReason.OBSERVING) } override fun > onMatterTaskUpdated(newState: T, oldState: T) { - jobEventLoop.notify(MachineJobEventLoop.IdleReason.OBSERVING) + jobEventLoops[0].notify(MachineJobEventLoop.IdleReason.OBSERVING) } override fun onPatternAdded(state: IPatternState) { - jobEventLoop.notify(MachineJobEventLoop.IdleReason.OBSERVING) + jobEventLoops[0].notify(MachineJobEventLoop.IdleReason.OBSERVING) } } @@ -143,7 +143,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return MatterReplicatorMenu(containerID, inventory, this) } - override fun onJobFinish(job: ReplicatorJob): JobStatus { + override fun onJobFinish(job: ReplicatorJob, id: Int): JobStatus { if (job.asDust) { job.matterValue = moveMatterAsDustIntoContainer(job.matterValue, container, OUTPUT_DUST_MAIN, OUTPUT_DUST_STACKING) @@ -173,7 +173,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : matterNode.discover(this) } - override fun jobUpdated(new: ReplicatorJob?, old: ReplicatorJob?) { + override fun jobUpdated(new: ReplicatorJob?, old: ReplicatorJob?, id: Int) { visualItemStack = new?.itemStack ?: ItemStack.EMPTY visualProgress = 0f } @@ -188,7 +188,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : var lastRender = 0L var particleRenderScore = 0L - override fun computeNextJob(): JobContainer { + override fun computeNextJob(id: Int): JobContainer { if (energy.batteryLevel < BASE_CONSUMPTION) { return JobContainer.noEnergy() } @@ -213,7 +213,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : )) } - override fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: ReplicatorJob): JobStatus { + override fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: ReplicatorJob, id: Int): JobStatus { val drainPerTick = job.matterPerTick * ticksAdvanced if (matter.extractMatter(drainPerTick, true) < drainPerTick) { @@ -237,7 +237,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : // в тик требуется меньше материи, чем её может хранить репликатор // примем из сети недостающее количество бака материи, или 200 тиков репликации, что меньше val drain = matterNode.graph.extractMatter((drainPerTick * DRAIN_MULT) - .coerceAtMost(job.matterPerTick * (job.ticks - jobEventLoop.workTicks - ticksAdvanced)) + .coerceAtMost(job.matterPerTick * (job.ticks - jobEventLoops[0].workTicks - ticksAdvanced)) .coerceAtLeast(Decimal.ONE) .coerceAtMost(matter.missingMatter), false) @@ -261,7 +261,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : // в машине достаточно материи matter.extractMatter(drainPerTick, false) - visualProgress = jobEventLoop.workProgress + visualProgress = jobEventLoops[0].workProgress return JobStatus.SUCCESS } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt index 7b7c446e5..04249f93d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt @@ -36,7 +36,7 @@ class CobblerBlockEntity(blockPos: BlockPos, blockState: BlockState) savetable(::container, INVENTORY_KEY) } - override fun onJobFinish(job: MachineItemJob): JobStatus { + override fun onJobFinish(job: MachineItemJob, id: Int): JobStatus { if (!container.fullyAddItem(job.itemStack)) { return JobStatus.FAILURE_ITEM } @@ -44,7 +44,7 @@ class CobblerBlockEntity(blockPos: BlockPos, blockState: BlockState) return JobStatus.SUCCESS } - override fun computeNextJob(): JobContainer { + override fun computeNextJob(id: Int): JobContainer { return JobContainer.success(MachineItemJob(ItemStack(Items.COBBLESTONE), 40.0)) } 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 375c2d347..c2a02d2c2 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 @@ -58,7 +58,7 @@ class PlatePressBlockEntity( return PlatePressMenu(containerID, inventory, this) } - override fun onJobFinish(job: MachineItemJob): JobStatus { + override fun onJobFinish(job: MachineItemJob, id: Int): JobStatus { if (job.itemStack.isEmpty) return JobStatus.SUCCESS @@ -69,7 +69,7 @@ class PlatePressBlockEntity( return JobStatus.SUCCESS } - override fun computeNextJob(): JobContainer { + override fun computeNextJob(id: Int): JobContainer { if (energy.batteryLevel.isZero) { return JobContainer.noEnergy() } From 2e37ff5de4cc3142318db8a8602f69562a2ce1ae Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 23 Jun 2023 00:47:32 +0700 Subject: [PATCH 0646/1199] Twin plate press --- .../mc/otm/datagen/lang/English.kt | 1 + .../mc/otm/datagen/lang/Russian.kt | 1 + .../mc/otm/datagen/loot/LootTablesData.kt | 1 + .../datagen/recipes/CraftingTableRecipes.kt | 6 ++ .../dbotthepony/mc/otm/datagen/tags/Tags.kt | 1 + .../dbotthepony/mc/otm/registry/MRecipes.java | 3 +- .../entity/matter/MatterScannerBlockEntity.kt | 12 +-- .../entity/tech/PlatePressBlockEntity.kt | 23 +++-- .../mc/otm/block/tech/PlatePressBlock.kt | 6 +- .../screen/tech/TwinPlatePressScreen.kt | 34 +++++++ .../ru/dbotthepony/mc/otm/menu/Slots.kt | 6 ++ .../mc/otm/menu/tech/CobblerMenu.kt | 2 +- .../mc/otm/menu/tech/TwinPlatePressMenu.kt | 36 +++++++ .../mc/otm/menu/widget/ProgressGaugeWidget.kt | 30 +++++- .../mc/otm/recipe/PlatePressRecipe.kt | 98 ++++++++++--------- .../mc/otm/registry/MBlockEntities.kt | 1 + .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 1 + .../ru/dbotthepony/mc/otm/registry/MItems.kt | 3 +- .../ru/dbotthepony/mc/otm/registry/MMenus.kt | 4 + .../ru/dbotthepony/mc/otm/registry/MNames.kt | 1 + 20 files changed, 200 insertions(+), 70 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/TwinPlatePressScreen.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/TwinPlatePressMenu.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index ec5f59c67..010baecff 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -397,6 +397,7 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.DRIVE_RACK, "Condensation Drive Rack") add(MBlocks.ITEM_MONITOR, "Item Monitor") add(MBlocks.PLATE_PRESS, "Plate Press") + add(MBlocks.TWIN_PLATE_PRESS, "Twin Plate Press") add(MBlocks.MATTER_RECYCLER, "Matter Recycler") add(MBlocks.ENERGY_SERVO, "Energy Servo") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index bfe2cda11..821b12b9b 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -402,6 +402,7 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.DRIVE_RACK, "Стеллаж дисков конденсации") add(MBlocks.ITEM_MONITOR, "Монитор предметов") add(MBlocks.PLATE_PRESS, "Пресс пластин") + add(MBlocks.TWIN_PLATE_PRESS, "Двойной пресс пластин") add(MBlocks.MATTER_RECYCLER, "Перерабатыватель материи") add(MBlocks.ENERGY_SERVO, "Энергетическая помпа") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index e6217e755..3817e4fe7 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -151,6 +151,7 @@ fun addLootTables(lootTables: LootTables) { lootTables.tile(MBlocks.MATTER_RECYCLER) lootTables.tile(MBlocks.MATTER_SCANNER) lootTables.tile(MBlocks.PLATE_PRESS) + lootTables.tile(MBlocks.TWIN_PLATE_PRESS) lootTables.tile(MBlocks.MATTER_PANEL) lootTables.tile(MBlocks.PATTERN_STORAGE) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index 16c140657..d708e8627 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -71,6 +71,12 @@ fun addCraftingTableRecipes(consumer: Consumer) { .unlockedBy(MItems.ELECTRIC_PARTS) .build(consumer, "advanced") + MatteryRecipe(MBlocks.TWIN_PLATE_PRESS, category = machinesCategory) + .rowB(MItemTags.PISTONS) + .row(MItemTags.TRITANIUM_PLATES, MItems.PLATE_PRESS, MItemTags.TRITANIUM_PLATES) + .unlockedBy(MItems.PLATE_PRESS) + .build(consumer) + MatteryRecipe(MItems.PATTERN_DRIVE_NORMAL, category = machinesCategory) .rowAC(MItemTags.ADVANCED_CIRCUIT, MItemTags.ADVANCED_CIRCUIT) .row(MItemTags.ADVANCED_CIRCUIT, MItemTags.TRITANIUM_PLATES, MItemTags.ADVANCED_CIRCUIT) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index e6746402c..08f622e84 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -156,6 +156,7 @@ fun addTags(tagsProvider: TagsProvider) { MBlocks.ENERGY_COUNTER, MBlocks.CHEMICAL_GENERATOR, MBlocks.PLATE_PRESS, + MBlocks.TWIN_PLATE_PRESS, MBlocks.MATTER_RECYCLER, MBlocks.STORAGE_BUS, diff --git a/src/main/java/ru/dbotthepony/mc/otm/registry/MRecipes.java b/src/main/java/ru/dbotthepony/mc/otm/registry/MRecipes.java index 9652761e5..304ce47e0 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/registry/MRecipes.java +++ b/src/main/java/ru/dbotthepony/mc/otm/registry/MRecipes.java @@ -11,7 +11,6 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters; import ru.dbotthepony.mc.otm.recipe.EnergyContainerRecipe; import ru.dbotthepony.mc.otm.recipe.ExplosiveHammerPrimingRecipe; import ru.dbotthepony.mc.otm.recipe.PlatePressRecipe; -import ru.dbotthepony.mc.otm.recipe.PlatePressRecipeFactory; import ru.dbotthepony.mc.otm.recipe.UpgradeRecipe; public class MRecipes { @@ -37,7 +36,7 @@ public class MRecipes { private static final DeferredRegister> typeRegistry = DeferredRegister.create(ForgeRegistries.RECIPE_TYPES, OverdriveThatMatters.MOD_ID); static { - serializerRegistry.register(MNames.PLATE_PRESS, () -> PlatePressRecipeFactory.INSTANCE); + serializerRegistry.register(MNames.PLATE_PRESS, () -> PlatePressRecipe.Companion); serializerRegistry.register(ENERGY_CONTAINER.name.getPath(), () -> EnergyContainerRecipe.Companion); serializerRegistry.register(UPGRADE.name.getPath(), () -> UpgradeRecipe.Companion); serializerRegistry.register(HAMMER_PRIMING.name.getPath(), () -> ExplosiveHammerPrimingRecipe.Companion); diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt index 262a58e6b..fe2ac2847 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt @@ -46,7 +46,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { - return jobEventLoop.isIdling + return jobEventLoops[0].isIdling } })) @@ -54,15 +54,15 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val matterNode = object : MatterNode() { override fun onPatternAdded(state: IPatternState) { - jobEventLoop.notify(MachineJobEventLoop.IdleReason.PATTERN) + jobEventLoops[0].notify(MachineJobEventLoop.IdleReason.PATTERN) } override fun onPatternRemoved(state: IPatternState) { - jobEventLoop.notify(MachineJobEventLoop.IdleReason.PATTERN) + jobEventLoops[0].notify(MachineJobEventLoop.IdleReason.PATTERN) } override fun onPatternUpdated(newState: IPatternState, oldState: IPatternState) { - jobEventLoop.notify(MachineJobEventLoop.IdleReason.PATTERN) + jobEventLoops[0].notify(MachineJobEventLoop.IdleReason.PATTERN) } } @@ -87,7 +87,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return MatterScannerMenu(containerID, inventory, this) } - override fun onJobFinish(job: MachineItemJob): JobStatus { + override fun onJobFinish(job: MachineItemJob, id: Int): JobStatus { val stack = job.itemStack if (stack.isEmpty || !MatterManager.hasMatterValue(stack)) return JobStatus.SUCCESS @@ -117,7 +117,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } - override fun computeNextJob(): JobContainer { + override fun computeNextJob(id: Int): JobContainer { if (energy.batteryLevel.isZero) { return JobContainer.noEnergy() } 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 c2a02d2c2..0daaade96 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 @@ -19,16 +19,18 @@ import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu +import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MRecipes class PlatePressBlockEntity( p_155229_: BlockPos, - p_155230_: BlockState -) : MatteryWorkerBlockEntity(MBlockEntities.PLATE_PRESS, p_155229_, p_155230_, ::MachineItemJob) { + p_155230_: BlockState, + val isTwin: Boolean = false, +) : MatteryWorkerBlockEntity(if (isTwin) MBlockEntities.TWIN_PLATE_PRESS else MBlockEntities.PLATE_PRESS, p_155229_, p_155230_, ::MachineItemJob, if (isTwin) 2 else 1) { val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::setChangedLight, MachinesConfig.PLATE_PRESS)) - val inputContainer = MatteryContainer(this::itemContainerUpdated, 1).also(::addDroppableContainer) - val outputContainer = MatteryContainer(this::itemContainerUpdated, 1).also(::addDroppableContainer) + val inputContainer = MatteryContainer(this::itemContainerUpdated, if (isTwin) 2 else 1).also(::addDroppableContainer) + val outputContainer = MatteryContainer(this::itemContainerUpdated, if (isTwin) 2 else 1).also(::addDroppableContainer) var experience = 0.0 @@ -55,14 +57,17 @@ class PlatePressBlockEntity( } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { - return PlatePressMenu(containerID, inventory, this) + if (isTwin) + return TwinPlatePressMenu(containerID, inventory, this) + else + return PlatePressMenu(containerID, inventory, this) } override fun onJobFinish(job: MachineItemJob, id: Int): JobStatus { if (job.itemStack.isEmpty) return JobStatus.SUCCESS - if (!outputContainer.fullyAddItem(job.itemStack)) + if (!outputContainer.fullyAddItem(job.itemStack, start = id, end = id) && !outputContainer.fullyAddItem(job.itemStack)) return JobStatus.FAILURE_ITEM experience = (experience + job.experience).coerceAtMost(100.0) @@ -76,9 +81,9 @@ class PlatePressBlockEntity( val level = level ?: return JobContainer.failure() - val recipe = level.recipeManager.getRecipeFor(MRecipes.PLATE_PRESS, inputContainer, level).orElse(null) ?: return JobContainer.noItem() - inputContainer[0].shrink(1) - inputContainer.setChanged(0) + val recipe = level.recipeManager.byType(MRecipes.PLATE_PRESS).values.stream().filter { it.matches(inputContainer, id) }.findAny().orElse(null) ?: return JobContainer.noItem() + inputContainer[id].shrink(1) + inputContainer.setChanged(id) return JobContainer.success(MachineItemJob(recipe.getResultItem(level.registryAccess()), recipe.workTime.toDouble(), BASELINE_CONSUMPTION, experience = recipe.experience.sample(level.random))) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt index c9fc9e6ce..2a9b889ec 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt @@ -26,9 +26,9 @@ import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes -class PlatePressBlock(properties: Properties = DEFAULT_PROPERTIES) : RotatableMatteryBlock(properties), EntityBlock { +class PlatePressBlock(properties: Properties = DEFAULT_PROPERTIES, val isTwin: Boolean = false) : RotatableMatteryBlock(properties), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { - return PlatePressBlockEntity(p_153215_, p_153216_) + return PlatePressBlockEntity(p_153215_, p_153216_, isTwin) } override fun getTicker( @@ -36,7 +36,7 @@ class PlatePressBlock(properties: Properties = DEFAULT_PROPERTIES) : RotatableMa p_153213_: BlockState, p_153214_: BlockEntityType ): BlockEntityTicker? { - if (p_153212_.isClientSide || p_153214_ !== MBlockEntities.PLATE_PRESS) + if (p_153212_.isClientSide) return null return BlockEntityTicker { _, _, _, tile -> if (tile is PlatePressBlockEntity) tile.tick() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/TwinPlatePressScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/TwinPlatePressScreen.kt new file mode 100644 index 000000000..22ab1cecf --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/TwinPlatePressScreen.kt @@ -0,0 +1,34 @@ +package ru.dbotthepony.mc.otm.client.screen.tech + +import net.minecraft.network.chat.Component +import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls +import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel +import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu + +class TwinPlatePressScreen(menu: TwinPlatePressMenu, inventory: Inventory, title: Component) : + MatteryScreen(menu, inventory, title) { + override fun makeMainFrame(): FramePanel> { + val frame = super.makeMainFrame()!! + + WideProfiledPowerGaugePanel(this, frame, menu.profiledEnergy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) + BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) + + SlotPanel(this, frame, menu.inputSlots[0], 56f, PROGRESS_SLOT_TOP - 10f) + ProgressGaugePanel(this, frame, menu.progressGauge0, 78f, PROGRESS_ARROW_TOP - 10f) + SlotPanel(this, frame, menu.outputSlots[0], 104f, PROGRESS_SLOT_TOP - 10f) + + SlotPanel(this, frame, menu.inputSlots[1], 56f, PROGRESS_SLOT_TOP + 10f) + ProgressGaugePanel(this, frame, menu.progressGauge1, 78f, PROGRESS_ARROW_TOP + 10f) + SlotPanel(this, frame, menu.outputSlots[1], 104f, PROGRESS_SLOT_TOP + 10f) + + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig) + + return frame + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt index 0d312681e..68ee7387d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.menu +import com.google.common.collect.ImmutableList import net.minecraft.world.Container import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.Slot @@ -10,8 +11,13 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.GetterSetter +import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.runOnClient +inline fun makeSlots(container: C, initializer: (C, Int) -> S): ImmutableList { + return immutableList(container.containerSize) { initializer.invoke(container, it) } +} + open class MatterySlot @JvmOverloads constructor(container: Container, index: Int, x: Int = 0, y: Int = 0) : Slot(container, index, x, y) { var ignoreSpectators = true diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt index 8490c62af..af64aef16 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt @@ -25,7 +25,7 @@ class CobblerMenu @JvmOverloads constructor( init { if (tile != null) { - progress.with(tile.jobEventLoop::workProgress, tile.jobEventLoop::isUnableToProcess) + progress.with(tile.jobEventLoops[0]) redstone.with(tile.redstoneControl::redstoneSetting) itemConfig.with(tile.itemConfig) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/TwinPlatePressMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/TwinPlatePressMenu.kt new file mode 100644 index 000000000..b8e1622fa --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/TwinPlatePressMenu.kt @@ -0,0 +1,36 @@ +package ru.dbotthepony.mc.otm.menu.tech + +import net.minecraft.server.level.ServerPlayer +import net.minecraft.world.SimpleContainer +import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity +import ru.dbotthepony.mc.otm.menu.MachineOutputSlot +import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu +import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput +import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput +import ru.dbotthepony.mc.otm.menu.makeSlots +import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget +import ru.dbotthepony.mc.otm.registry.MMenus + +class TwinPlatePressMenu @JvmOverloads constructor( + containerID: Int, + inventory: Inventory, + tile: PlatePressBlockEntity? = null +) : MatteryPoweredMenu(MMenus.TWIN_PLATE_PRESS, containerID, inventory, tile) { + val inputSlots = makeSlots(tile?.inputContainer ?: SimpleContainer(2), ::MatterySlot) + val outputSlots = makeSlots(tile?.outputContainer ?: SimpleContainer(2)) { a, b -> MachineOutputSlot(a, b) { tile?.popExperience(ply as ServerPlayer) } } + + val progressGauge0 = ProgressGaugeWidget(this, tile?.jobEventLoops?.get(0)) + val progressGauge1 = ProgressGaugeWidget(this, tile?.jobEventLoops?.get(1)) + val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig, allowPush = true) + val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig, allowPull = true) + val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) + + init { + addStorageSlot(inputSlots) + addStorageSlot(outputSlots) + addInventorySlots() + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt index 11489492d..6ca06cff3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/widget/ProgressGaugeWidget.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.menu.widget +import ru.dbotthepony.mc.otm.block.entity.MachineJobEventLoop import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.core.FloatSupplier import ru.dbotthepony.mc.otm.menu.MatteryMenu @@ -13,8 +14,8 @@ class ProgressGaugeWidget(synchronizer: FieldSynchronizer) { var progressSupplier: FloatSupplier = FloatSupplier { 0f } var stuckSupplier: BooleanSupplier = BooleanSupplier { false } - val percentage by synchronizer.ComputedFloatField(getter = { progressSupplier.getAsFloat() }) - val isStuck by synchronizer.ComputedBooleanField(getter = { stuckSupplier.asBoolean }) + val percentage by synchronizer.ComputedFloatField(getter = { progressSupplier.getAsFloat() }).property + val isStuck by synchronizer.ComputedBooleanField(getter = { stuckSupplier.asBoolean }).property constructor( menu: MatteryMenu, @@ -32,6 +33,15 @@ class ProgressGaugeWidget(synchronizer: FieldSynchronizer) { } } + constructor( + menu: MatteryMenu, + job: MachineJobEventLoop<*>? + ) : this(menu) { + if (job != null) { + with(job) + } + } + constructor( synchronizer: FieldSynchronizer, progress: FloatSupplier @@ -48,6 +58,15 @@ class ProgressGaugeWidget(synchronizer: FieldSynchronizer) { } } + constructor( + synchronizer: FieldSynchronizer, + job: MachineJobEventLoop<*>? + ) : this(synchronizer) { + if (job != null) { + with(job) + } + } + constructor( menu: MatteryMenu, progress: FloatSupplier, @@ -70,7 +89,12 @@ class ProgressGaugeWidget(synchronizer: FieldSynchronizer) { } fun with(blockEntity: MatteryWorkerBlockEntity<*>): ProgressGaugeWidget { - with(blockEntity.jobEventLoop::workProgress, blockEntity.jobEventLoop::isUnableToProcess) + with(blockEntity.jobEventLoops[0]::workProgress, blockEntity.jobEventLoops[0]::isUnableToProcess) + return this + } + + fun with(job: MachineJobEventLoop<*>): ProgressGaugeWidget { + with(job::workProgress, job::isUnableToProcess) return this } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt index 246995f21..f471b091f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt @@ -42,6 +42,13 @@ class PlatePressRecipe( return input.test(container[0]) } + fun matches(container: Container, slot: Int): Boolean { + if (output.isActuallyEmpty || input.isActuallyEmpty) + return false + + return input.test(container[slot]) + } + private val outputStack: ItemStack by lazy { if (output.isActuallyEmpty || input.isActuallyEmpty) { ItemStack.EMPTY @@ -70,60 +77,61 @@ class PlatePressRecipe( override fun getId() = id override fun getSerializer(): RecipeSerializer<*> { - return PlatePressRecipeFactory + return Companion } override fun getType(): RecipeType = MRecipes.PLATE_PRESS -} -object PlatePressRecipeFactory : RecipeSerializer { - private val EMPTY = PlatePressRecipe(ResourceLocation(OverdriveThatMatters.MOD_ID, "empty"), Ingredient.EMPTY, Ingredient.EMPTY, 1) - private val LOGGER = LogManager.getLogger() + companion object : RecipeSerializer { + private val EMPTY = PlatePressRecipe(ResourceLocation(OverdriveThatMatters.MOD_ID, "empty"), Ingredient.EMPTY, Ingredient.EMPTY, 1) + private val LOGGER = LogManager.getLogger() - override fun fromJson(loc: ResourceLocation, obj: JsonObject): PlatePressRecipe { - val input = try { - Ingredient.fromJson(obj["input"] ?: throw IllegalStateException("Recipe $loc has no input field defined")) - } catch (err: Throwable) { - if (err.message?.lowercase()?.contains("unknown item tag") == true) { - LOGGER.warn("Ignoring recipe Input of $loc deserialization error, defaulting to empty recipe") - LOGGER.warn(err) - return EMPTY - } else { - throw IllegalStateException("Input of $loc is malformed", err) + override fun fromJson(loc: ResourceLocation, obj: JsonObject): PlatePressRecipe { + val input = try { + Ingredient.fromJson(obj["input"] ?: throw IllegalStateException("Recipe $loc has no input field defined")) + } catch (err: Throwable) { + if (err.message?.lowercase()?.contains("unknown item tag") == true) { + LOGGER.warn("Ignoring recipe Input of $loc deserialization error, defaulting to empty recipe") + LOGGER.warn(err) + return EMPTY + } else { + throw IllegalStateException("Input of $loc is malformed", err) + } } + + val result = try { + Ingredient.fromJson(obj["result"] ?: throw IllegalStateException("Recipe $loc has no result field defined")) + } catch (err: Throwable) { + if (err.message?.lowercase()?.contains("unknown item tag") == true) { + LOGGER.warn("Ignoring recipe Output of $loc deserialization error, defaulting to empty recipe") + LOGGER.warn(err) + return EMPTY + } else { + throw IllegalStateException("Result of $loc is malformed", err) + } + } + + val workTime = (obj["work_time"] as? JsonPrimitive)?.let { return@let try {it.asInt} catch(err: Throwable) {throw IllegalStateException("Invalid work_time")} } ?: 200 + + check(workTime >= 0) { "work_time of $loc does not make any sense" } + + val count = ((obj["result"] as JsonObject)["count"] as? JsonPrimitive)?.let { return@let try {it.asInt} catch(err: Throwable) {throw IllegalStateException("Invalid result.count")} } ?: 1 + + val experience = obj["experience"]?.let { FloatProvider.CODEC.fromJsonStrict(it) } ?: ConstantFloat.ZERO + return PlatePressRecipe(loc, input, result, count, workTime, experience) } - val result = try { - Ingredient.fromJson(obj["result"] ?: throw IllegalStateException("Recipe $loc has no result field defined")) - } catch (err: Throwable) { - if (err.message?.lowercase()?.contains("unknown item tag") == true) { - LOGGER.warn("Ignoring recipe Output of $loc deserialization error, defaulting to empty recipe") - LOGGER.warn(err) - return EMPTY - } else { - throw IllegalStateException("Result of $loc is malformed", err) - } + override fun fromNetwork(loc: ResourceLocation, buff: FriendlyByteBuf): PlatePressRecipe { + return PlatePressRecipe(loc, Ingredient.fromNetwork(buff), Ingredient.fromNetwork(buff), buff.readInt(), buff.readInt(), FloatProvider.CODEC.fromJsonStrict(buff.readJson())) } - val workTime = (obj["work_time"] as? JsonPrimitive)?.let { return@let try {it.asInt} catch(err: Throwable) {throw IllegalStateException("Invalid work_time")} } ?: 200 - - check(workTime >= 0) { "work_time of $loc does not make any sense" } - - val count = ((obj["result"] as JsonObject)["count"] as? JsonPrimitive)?.let { return@let try {it.asInt} catch(err: Throwable) {throw IllegalStateException("Invalid result.count")} } ?: 1 - - val experience = obj["experience"]?.let { FloatProvider.CODEC.fromJsonStrict(it) } ?: ConstantFloat.ZERO - return PlatePressRecipe(loc, input, result, count, workTime, experience) - } - - override fun fromNetwork(loc: ResourceLocation, buff: FriendlyByteBuf): PlatePressRecipe { - return PlatePressRecipe(loc, Ingredient.fromNetwork(buff), Ingredient.fromNetwork(buff), buff.readInt(), buff.readInt(), FloatProvider.CODEC.fromJsonStrict(buff.readJson())) - } - - override fun toNetwork(buff: FriendlyByteBuf, recipe: PlatePressRecipe) { - recipe.input.toNetwork(buff) - recipe.output.toNetwork(buff) - buff.writeInt(recipe.count) - buff.writeInt(recipe.workTime) - buff.writeJson(FloatProvider.CODEC.toJsonStrict(recipe.experience)) + override fun toNetwork(buff: FriendlyByteBuf, recipe: PlatePressRecipe) { + recipe.input.toNetwork(buff) + recipe.output.toNetwork(buff) + buff.writeInt(recipe.count) + buff.writeInt(recipe.workTime) + buff.writeJson(FloatProvider.CODEC.toJsonStrict(recipe.experience)) + } } } + 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 2f33fe80f..49767b43c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt @@ -47,6 +47,7 @@ object MBlockEntities { val ENERGY_COUNTER: BlockEntityType by registry.register(MNames.ENERGY_COUNTER) { BlockEntityType.Builder.of(::EnergyCounterBlockEntity, MBlocks.ENERGY_COUNTER).build(null) } val CHEMICAL_GENERATOR: BlockEntityType by registry.register(MNames.CHEMICAL_GENERATOR) { BlockEntityType.Builder.of(::ChemicalGeneratorBlockEntity, MBlocks.CHEMICAL_GENERATOR).build(null) } val PLATE_PRESS: BlockEntityType by registry.register(MNames.PLATE_PRESS) { BlockEntityType.Builder.of(::PlatePressBlockEntity, MBlocks.PLATE_PRESS).build(null) } + val TWIN_PLATE_PRESS: BlockEntityType by registry.register(MNames.TWIN_PLATE_PRESS) { BlockEntityType.Builder.of({ a, b -> PlatePressBlockEntity(a, b, true) }, MBlocks.TWIN_PLATE_PRESS).build(null) } val GRAVITATION_STABILIZER: BlockEntityType by registry.register(MNames.GRAVITATION_STABILIZER) { BlockEntityType.Builder.of(::GravitationStabilizerBlockEntity, MBlocks.GRAVITATION_STABILIZER).build(null) } val MATTER_RECYCLER: BlockEntityType by registry.register(MNames.MATTER_RECYCLER) { BlockEntityType.Builder.of(::MatterRecyclerBlockEntity, MBlocks.MATTER_RECYCLER).build(null) } val ENERGY_SERVO: BlockEntityType by registry.register(MNames.ENERGY_SERVO) { BlockEntityType.Builder.of(::EnergyServoBlockEntity, MBlocks.ENERGY_SERVO).build(null) } 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 70fac7edc..6e4b99881 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -83,6 +83,7 @@ object MBlocks { val ENERGY_COUNTER: Block by registry.register(MNames.ENERGY_COUNTER) { EnergyCounterBlock() } val CHEMICAL_GENERATOR: Block by registry.register(MNames.CHEMICAL_GENERATOR) { ChemicalGeneratorBlock() } val PLATE_PRESS: Block by registry.register(MNames.PLATE_PRESS) { PlatePressBlock() } + val TWIN_PLATE_PRESS: Block by registry.register(MNames.TWIN_PLATE_PRESS) { PlatePressBlock(isTwin = true) } val MATTER_RECYCLER: Block by registry.register(MNames.MATTER_RECYCLER) { MatterRecyclerBlock() } val ENERGY_SERVO: Block by registry.register(MNames.ENERGY_SERVO) { EnergyServoBlock() } val COBBLESTONE_GENERATOR: Block by registry.register(MNames.COBBLESTONE_GENERATOR) { CobblerBlock() } 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 5e916a1ef..6ab288fe1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -60,6 +60,7 @@ object MItems { val ENERGY_COUNTER: BlockItem by registry.register(MNames.ENERGY_COUNTER) { BlockItem(MBlocks.ENERGY_COUNTER, DEFAULT_PROPERTIES) } val CHEMICAL_GENERATOR: BlockItem by registry.register(MNames.CHEMICAL_GENERATOR) { BlockItem(MBlocks.CHEMICAL_GENERATOR, DEFAULT_PROPERTIES) } val PLATE_PRESS: BlockItem by registry.register(MNames.PLATE_PRESS) { BlockItem(MBlocks.PLATE_PRESS, DEFAULT_PROPERTIES) } + val TWIN_PLATE_PRESS: BlockItem by registry.register(MNames.TWIN_PLATE_PRESS) { BlockItem(MBlocks.TWIN_PLATE_PRESS, DEFAULT_PROPERTIES) } val MATTER_RECYCLER: BlockItem by registry.register(MNames.MATTER_RECYCLER) { BlockItem(MBlocks.MATTER_RECYCLER, DEFAULT_PROPERTIES) } val STORAGE_BUS: BlockItem by registry.register(MNames.STORAGE_BUS) { BlockItem(MBlocks.STORAGE_BUS, DEFAULT_PROPERTIES) } @@ -135,7 +136,7 @@ object MItems { val MACHINES = SupplierList( ::ANDROID_STATION, ::BATTERY_BANK, ::MATTER_DECOMPOSER, ::MATTER_CAPACITOR_BANK, ::MATTER_CABLE, ::PATTERN_STORAGE, ::MATTER_SCANNER, ::MATTER_PANEL, ::MATTER_REPLICATOR, ::MATTER_BOTTLER, ::ENERGY_COUNTER, ::CHEMICAL_GENERATOR, - ::PLATE_PRESS, ::MATTER_RECYCLER, + ::PLATE_PRESS, ::TWIN_PLATE_PRESS, ::MATTER_RECYCLER, // ::STORAGE_BUS, ::STORAGE_IMPORTER, ::STORAGE_EXPORTER, ::DRIVE_VIEWER, // ::DRIVE_RACK, ::ITEM_MONITOR, ::STORAGE_CABLE, ::STORAGE_POWER_SUPPLIER, ::ENERGY_SERVO, 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 adc1016b4..8e6f0e6f4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt @@ -36,6 +36,7 @@ import ru.dbotthepony.mc.otm.client.screen.tech.EnergyCounterScreen import ru.dbotthepony.mc.otm.client.screen.tech.EnergyServoScreen import ru.dbotthepony.mc.otm.client.screen.tech.EssenceStorageScreen import ru.dbotthepony.mc.otm.client.screen.tech.PlatePressScreen +import ru.dbotthepony.mc.otm.client.screen.tech.TwinPlatePressScreen import ru.dbotthepony.mc.otm.menu.decorative.CargoCrateMenu import ru.dbotthepony.mc.otm.menu.decorative.FluidTankMenu import ru.dbotthepony.mc.otm.menu.decorative.HoloSignMenu @@ -64,6 +65,7 @@ import ru.dbotthepony.mc.otm.menu.tech.EnergyCounterMenu import ru.dbotthepony.mc.otm.menu.tech.EnergyServoMenu import ru.dbotthepony.mc.otm.menu.tech.EssenceStorageMenu import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu +import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu object MMenus { private val registry = DeferredRegister.create(ForgeRegistries.MENU_TYPES, OverdriveThatMatters.MOD_ID) @@ -85,6 +87,7 @@ object MMenus { val ENERGY_COUNTER: MenuType by registry.register(MNames.ENERGY_COUNTER) { MenuType(::EnergyCounterMenu, FeatureFlags.VANILLA_SET) } val CHEMICAL_GENERATOR: MenuType by registry.register(MNames.CHEMICAL_GENERATOR) { MenuType(::ChemicalGeneratorMenu, FeatureFlags.VANILLA_SET) } val PLATE_PRESS: MenuType by registry.register(MNames.PLATE_PRESS) { MenuType(::PlatePressMenu, FeatureFlags.VANILLA_SET) } + val TWIN_PLATE_PRESS: MenuType by registry.register(MNames.TWIN_PLATE_PRESS) { MenuType(::TwinPlatePressMenu, FeatureFlags.VANILLA_SET) } val MATTER_RECYCLER: MenuType by registry.register(MNames.MATTER_RECYCLER) { MenuType(::MatterRecyclerMenu, FeatureFlags.VANILLA_SET) } val ENERGY_SERVO: MenuType by registry.register(MNames.ENERGY_SERVO) { MenuType(::EnergyServoMenu, FeatureFlags.VANILLA_SET) } val HOLO_SIGN: MenuType by registry.register(MNames.HOLO_SIGN) { MenuType(::HoloSignMenu, FeatureFlags.VANILLA_SET) } @@ -123,6 +126,7 @@ object MMenus { MenuScreens.register(ENERGY_COUNTER, ::EnergyCounterScreen) MenuScreens.register(CHEMICAL_GENERATOR, ::ChemicalGeneratorScreen) MenuScreens.register(PLATE_PRESS, ::PlatePressScreen) + MenuScreens.register(TWIN_PLATE_PRESS, ::TwinPlatePressScreen) MenuScreens.register(MATTER_RECYCLER, ::MatterRecyclerScreen) MenuScreens.register(STORAGE_BUS, ::StorageBusScreen) MenuScreens.register(STORAGE_EXPORTER, ::StorageExporterScreen) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index 1f8e0b1ac..bafe6e318 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -31,6 +31,7 @@ object MNames { const val ENERGY_COUNTER = "energy_counter" const val CHEMICAL_GENERATOR = "chemical_generator" const val PLATE_PRESS = "plate_press" + const val TWIN_PLATE_PRESS = "twin_plate_press" const val MATTER_RECYCLER = "matter_recycler" const val ENERGY_SERVO = "energy_servo" const val COBBLESTONE_GENERATOR = "cobblestone_generator" From 4f7c9ea176fd33d37fe1fd4d0aa5a5feb2ecd04b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 23 Jun 2023 23:30:40 +0700 Subject: [PATCH 0647/1199] Input balancing --- .../mc/otm/datagen/lang/English.kt | 2 + .../mc/otm/datagen/lang/Russian.kt | 2 + .../recipes/PlatePressFinishedRecipe.kt | 7 +- .../block/entity/MatteryWorkerBlockEntity.kt | 6 + .../entity/tech/PlatePressBlockEntity.kt | 9 ++ .../mc/otm/client/render/Widgets18.kt | 5 +- .../client/screen/panels/button/Buttons.kt | 19 ++- .../screen/tech/TwinPlatePressScreen.kt | 2 +- .../ru/dbotthepony/mc/otm/container/Ext.kt | 138 ++++++++++++++++++ .../mc/otm/container/ItemStackHashStrategy.kt | 15 ++ .../menu/input/BooleanInputWithFeedback.kt | 2 +- .../mc/otm/menu/tech/TwinPlatePressMenu.kt | 9 ++ .../textures/gui/widgets/side_controls.png | Bin 2631 -> 2775 bytes .../textures/gui/widgets/side_controls.xcf | Bin 70796 -> 72882 bytes 14 files changed, 205 insertions(+), 11 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemStackHashStrategy.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 010baecff..1af4b870d 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -680,6 +680,8 @@ private fun gui(provider: MatteryLanguageProvider) { gui("side_mode.pull", "Pull") gui("side_mode.push", "Push") + gui("balance_inputs", "Balance input slots") + gui("sorting.default", "Default sorting") gui("sorting.name", "Sort by name") gui("sorting.id", "Sort by ID") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 821b12b9b..a2c5111a1 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -685,6 +685,8 @@ private fun gui(provider: MatteryLanguageProvider) { gui("side_mode.pull", "Автоматическое вытягивание") gui("side_mode.push", "Автоматическое выталкивание") + gui("balance_inputs", "Балансировать входные слоты") + gui("sorting.default", "Сортировка по умолчанию") gui("sorting.name", "Сортировка по имени") gui("sorting.id", "Сортировка по ID") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressFinishedRecipe.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressFinishedRecipe.kt index 4fac241ba..2b0ca00fc 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressFinishedRecipe.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressFinishedRecipe.kt @@ -7,13 +7,10 @@ import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.resources.ResourceLocation import net.minecraft.util.valueproviders.ConstantFloat import net.minecraft.util.valueproviders.FloatProvider -import net.minecraft.util.valueproviders.UniformFloat import net.minecraft.world.item.crafting.RecipeSerializer import ru.dbotthepony.mc.otm.recipe.PlatePressRecipe -import ru.dbotthepony.mc.otm.recipe.PlatePressRecipeFactory import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.core.toJsonStrict -import ru.dbotthepony.mc.otm.data.getOrNull class PlatePressFinishedRecipe(private val recipe: PlatePressRecipe) : FinishedRecipe { override fun serializeRecipeData(it: JsonObject) { @@ -33,7 +30,7 @@ class PlatePressFinishedRecipe(private val recipe: PlatePressRecipe) : FinishedR } override fun getType(): RecipeSerializer<*> { - return PlatePressRecipeFactory + return PlatePressRecipe.Companion } override fun serializeAdvancement(): JsonObject? { @@ -74,7 +71,7 @@ class PlatePressShallowFinishedRecipe( } override fun getType(): RecipeSerializer<*> { - return PlatePressRecipeFactory + return PlatePressRecipe.Companion } override fun serializeAdvancement(): JsonObject? { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt index c6682a858..61867953a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt @@ -61,6 +61,12 @@ abstract class MatteryWorkerBlockEntity( } } + var balanceInputs = false + + init { + savetables.bool(::balanceInputs) + } + protected open fun jobUpdated(new: JobType?, old: JobType?, id: Int) {} protected abstract fun onJobFinish(job: JobType, id: Int): JobStatus protected abstract fun computeNextJob(id: Int): JobContainer 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 0daaade96..e88dbb13f 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 @@ -17,6 +17,7 @@ import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage 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.container.balance import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu @@ -87,6 +88,14 @@ class PlatePressBlockEntity( return JobContainer.success(MachineItemJob(recipe.getResultItem(level.registryAccess()), recipe.workTime.toDouble(), BASELINE_CONSUMPTION, experience = recipe.experience.sample(level.random))) } + override fun tick() { + if (isTwin && balanceInputs) { + inputContainer.balance() + } + + super.tick() + } + companion object { private val BASELINE_CONSUMPTION = Decimal(15) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt index 3e03f8ed5..d347c5feb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt @@ -70,9 +70,8 @@ object Widgets18 { val REDSTONE_LOW = controlsGrid.next() val REDSTONE_HIGH = controlsGrid.next() - init { - controlsGrid.jump() - } + val BALANCING_DISABLED = controlsGrid.next() + val BALANCING_ENABLED = controlsGrid.next() class SideControls { val disabled = controlsGrid.next() 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 7db124cc0..d9bbffeec 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 @@ -274,11 +274,13 @@ class DeviceControls>( val itemConfig: ItemConfigPlayerInput? = null, val energyConfig: EnergyConfigPlayerInput? = null, val fluidConfig: FluidConfigPlayerInput? = null, + val balanceInputs: BooleanInputWithFeedback? = null, ) : EditablePanel(screen, parent, x = parent.width + 3f, height = 0f, width = 0f) { val itemConfigButton: LargeRectangleButtonPanel? val energyConfigButton: LargeRectangleButtonPanel? val fluidConfigButton: LargeRectangleButtonPanel? val redstoneControlsButton: LargeEnumRectangleButtonPanel? + val balanceInputsButton: LargeBooleanRectangleButtonPanel? private var nextY = 0f fun

> addButton(button: P): P { @@ -302,6 +304,18 @@ class DeviceControls>( redstoneControlsButton = null } + if (balanceInputs != null) { + balanceInputsButton = addButton(LargeBooleanRectangleButtonPanel( + screen, this, + prop = balanceInputs, + skinElementActive = Widgets18.BALANCING_ENABLED, + skinElementInactive = Widgets18.BALANCING_DISABLED).also { + it.tooltip = TranslatableComponent("otm.gui.balance_inputs") + }) + } else { + balanceInputsButton = null + } + if (itemConfig != null) { itemConfigButton = addButton(object : LargeRectangleButtonPanel(screen, this@DeviceControls, skinElement = Widgets18.ITEMS_CONFIGURATION) { init { @@ -375,6 +389,9 @@ fun > makeDeviceControls( itemConfig: ItemConfigPlayerInput? = null, energyConfig: EnergyConfigPlayerInput? = null, fluidConfig: FluidConfigPlayerInput? = null, + balanceInputs: BooleanInputWithFeedback? = null, ): DeviceControls { - return DeviceControls(screen, parent, extra = extra, redstoneConfig = redstoneConfig, itemConfig = itemConfig, energyConfig = energyConfig, fluidConfig = fluidConfig) + return DeviceControls(screen, parent, extra = extra, redstoneConfig = redstoneConfig, + itemConfig = itemConfig, energyConfig = energyConfig, fluidConfig = fluidConfig, + balanceInputs = balanceInputs) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/TwinPlatePressScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/TwinPlatePressScreen.kt index 22ab1cecf..6a2952f8c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/TwinPlatePressScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/TwinPlatePressScreen.kt @@ -27,7 +27,7 @@ class TwinPlatePressScreen(menu: TwinPlatePressMenu, inventory: Inventory, title ProgressGaugePanel(this, frame, menu.progressGauge1, 78f, PROGRESS_ARROW_TOP + 10f) SlotPanel(this, frame, menu.outputSlots[1], 104f, PROGRESS_SLOT_TOP + 10f) - makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig, balanceInputs = menu.balanceInputs) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt index ace16d30d..89024f2bf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt @@ -1,11 +1,19 @@ package ru.dbotthepony.mc.otm.container +import it.unimi.dsi.fastutil.ints.IntAVLTreeSet +import it.unimi.dsi.fastutil.ints.IntArrayList +import it.unimi.dsi.fastutil.ints.IntArraySet +import it.unimi.dsi.fastutil.ints.IntSet +import it.unimi.dsi.fastutil.objects.Object2ObjectFunction +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap import net.minecraft.world.Container import net.minecraft.world.item.ItemStack import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.fluids.capability.IFluidHandler +import ru.dbotthepony.mc.otm.core.addAll import ru.dbotthepony.mc.otm.core.collect.iterator import ru.dbotthepony.mc.otm.core.collect.nonEmpty +import kotlin.math.roundToInt operator fun Container.set(index: Int, value: ItemStack) = setItem(index, value) operator fun Container.get(index: Int): ItemStack = getItem(index) @@ -109,3 +117,133 @@ inline fun Container.forEachNonEmpty(lambda: (ItemStack) -> Unit) { lambda(value) } } + +fun Container.balance(slots: IntSet) { + if (slots.isEmpty()) return + + val empty = IntArrayList() + val itemTypes = Object2ObjectOpenCustomHashMap(ItemStackHashStrategy) + + for (i in slots.intIterator()) { + val item = getItem(i) + + if (item.isEmpty) { + empty.add(i) + } else { + itemTypes.computeIfAbsent(item, Object2ObjectFunction { IntAVLTreeSet() }).add(i) + } + } + + if (itemTypes.isEmpty()) + return + + // только один вид предмета, просто балансируем его во все слоты + if (itemTypes.size == 1) { + val (item, list) = itemTypes.entries.first() + var count = list.stream().mapToInt { getItem(it).count }.sum() + + // всего предметов меньше, чем слотов + if (count < slots.size) { + for (slot in list.intIterator()) { + getItem(slot).count = 1 + } + + count -= list.size + + while (count > 0 && empty.isNotEmpty()) { + setItem(empty.removeInt(0), item.copyWithCount(1)) + count-- + } + + if (count > 0) { + getItem(list.firstInt()).count += count + } + } else { + // всего предметов больше, чем слотов + val perSlot = count / slots.size + var leftover = count - perSlot * slots.size + + for (i in slots.intIterator()) { + setItem(i, item.copyWithCount(perSlot)) + } + + for (i in slots.intIterator()) { + if (leftover <= 0) break + getItem(i).count++ + leftover-- + } + } + + setChanged() + return + } + + // а вот тут уже проблемы + // для упрощения задачи, выполним рекурсивное разбитие задачи на более простые, + // где балансировка будет происходить только между пустыми слотами и предметами одного типа + + // если у нас нет пустых слотов, просто балансируем между заполненными слотами + if (empty.isEmpty) { + for (set in itemTypes.values) { + balance(set) + } + + return + } else if (empty.size == 1) { + // только один пустой слот, отдадим самому "жирному" предмету + val type = itemTypes.entries.stream().max { a, b -> b.value.intStream().sum().compareTo(a.value.intStream().sum()) }.orElseThrow() + type.value.add(empty.getInt(0)) + balance(type.value) + + for ((a, set) in itemTypes) { + if (a !== type.key) { + balance(set) + } + } + + return + } + + // определяем общее количество предметов + val totalCount = itemTypes.values.stream().mapToInt { it.stream().mapToInt { getItem(it).count }.sum() }.sum().toDouble() + val totalEmpty = empty.size + + // определяем доли предметов по их количеству к общему количеству, + // что позволит нам выделить претендентов на пустые слоты + for (list in itemTypes.values) { + if (empty.isEmpty) break // ошибка округления + + val perc = list.stream().mapToInt { getItem(it).count }.sum() / totalCount + + for (i in 0 until (perc * totalEmpty).roundToInt()) { + list.add(empty.removeInt(0)) + if (empty.isEmpty) break // ошибка округления + } + } + + if (empty.isNotEmpty()) { + // ошибка округления + itemTypes.values.stream().max { a, b -> b.intStream().sum().compareTo(a.intStream().sum()) }.orElseThrow().add(empty.removeInt(0)) + } + + for (list in itemTypes.values) { + balance(list) + } +} + +fun Container.balance(slots: Iterator) { + balance(IntArraySet().also { it.addAll(slots) }) +} + +fun Container.balance(slots: Iterable) { + balance(IntArraySet().also { it.addAll(slots) }) +} + +fun Container.balance(slots: IntRange) { + balance(IntArraySet().also { it.addAll(slots) }) +} + +fun Container.balance(startSlot: Int = 0, endSlot: Int = containerSize - 1) { + require(startSlot <= endSlot) { "Invalid slot range: $startSlot .. $endSlot" } + balance(IntArrayList(endSlot - startSlot + 1).also { for (i in startSlot .. endSlot) it.add(i) }) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemStackHashStrategy.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemStackHashStrategy.kt new file mode 100644 index 000000000..cd9c7e5ff --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemStackHashStrategy.kt @@ -0,0 +1,15 @@ +package ru.dbotthepony.mc.otm.container + +import it.unimi.dsi.fastutil.Hash +import net.minecraft.world.item.ItemStack + +object ItemStackHashStrategy : Hash.Strategy { + override fun equals(a: ItemStack?, b: ItemStack?): Boolean { + return a === b || a != null && b != null && ItemStack.isSameItemSameTags(a, b) + } + + override fun hashCode(o: ItemStack?): Int { + o ?: return 0 + return o.item.hashCode().xor(o.tag.hashCode()) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/BooleanInputWithFeedback.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/BooleanInputWithFeedback.kt index 14291198f..21d71fca9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/BooleanInputWithFeedback.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/BooleanInputWithFeedback.kt @@ -7,7 +7,7 @@ import kotlin.reflect.KMutableProperty0 class BooleanInputWithFeedback(menu: MatteryMenu) : AbstractPlayerInputWithFeedback() { override val input = menu.booleanInput { consumer?.invoke(it) } - override val value by menu.mSynchronizer.computedBool(BooleanSupplier { supplier?.invoke() ?: false }) + override val value by menu.mSynchronizer.computedBool(BooleanSupplier { supplier?.invoke() ?: false }).property constructor(menu: MatteryMenu, state: KMutableProperty0) : this(menu) { with(state) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/TwinPlatePressMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/TwinPlatePressMenu.kt index b8e1622fa..f6bda5c84 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/TwinPlatePressMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/TwinPlatePressMenu.kt @@ -7,6 +7,7 @@ import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity import ru.dbotthepony.mc.otm.menu.MachineOutputSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import ru.dbotthepony.mc.otm.menu.makeSlots @@ -28,6 +29,14 @@ class TwinPlatePressMenu @JvmOverloads constructor( val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig, allowPull = true) val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) + val balanceInputs = BooleanInputWithFeedback(this) + + init { + if (tile != null) { + balanceInputs.with(tile::balanceInputs) + } + } + init { addStorageSlot(inputSlots) addStorageSlot(outputSlots) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.png index 23f14bebe429fc7a8ec2139feced02e13080f676..2c2c135b45749997a8b2951fe4eaa463661da934 100644 GIT binary patch delta 2318 zcmXX_dpy(YAD2q`bzzHN#3;5gNimTY)2y<&lqn*UTo>I;R!Y7RX-*eu#Nw)om^rNYF=a#x>R(Epu;5mZmAc5t{uZ;wJ$sGYWFKGwx>1}#nA9lz) z>mpK$Hcq7@n6@SC~qWM)-v93lB1BwTynoc!0 zNFMhdDsXTV2EKJwwm*ToK5MHXms(0G@kHyHQB{LV{fE2hv?n9@xr~5di)FGn3K;*b zmIze<+zXso@fD9)@dsR8Ola$pwUSb=UatusO5#|p#i|0o>TL0WoJ0wfP6V}!d_Bi` zePi$AgCD)`P4X!0;9amp^#;AJ%9d7oO+pkPb`**q;e^UEB$px#>^MvFWK%6`!~JvEfqT<tP-W( z-W~?ZwPE)BP;;X%(BePD7v$_SCsGuj_~nP_6&p`)_pC00GYPFP@gzh=(wT`Npntr1 zp|Trtr8srRazoB@cas}VF65OBM5s$H1|N64C;5?;{GaA7tv|Raozir-WD_{ZI7tf6HC-_ejru_^s!5c@W8jt%tn2 zh?i&Y`MhBDfwqP>s*+$z7<6Yk5?Jr-#Xmpn#SO8>`oorp-6yrgK$PCE^|9rSMpHw; zYtxR??kiJHP5H<6j&$bM7hbG3L9u0(M*$Wk#MN-?_WU4`wHpZN>+SWLn~-zq;di&T z9+>59q9SqMlkWxL5mTD?L|Ffb`t^rG?7-Z2HW#}1fDjf}c^{ai4Hz}rP_7#5m3yxW zZ;$MNGSActi%x13dFv)rJys}MMa$2Nv)`0EA@~X$=AKhrglTEsdh1Ztm4QGNR!DJAR>T6|si4i>lQw{I-?at>>+f9!^<&dyaBi`WI`x2X0t z9R}uGx3f>}BE{TM|M)8s*}mLF>J5O*{F#@uBU|P!#-W=+bLwekh2#T)2cwCirv+dk zVbT_Mm)){$LRcSsE_-!<2Xyubi9(HOycZK;wvjhW`*`I6#zM03%38D_QgX4!dBgYH zVR+^xrnwJN!iY4H5=8y9A+jCPLrE)QyqN`sk_HX@21Pp$&i(2Y(DP0}_I2jpxD$-! zJE1B=Uxf$8DDHlh`}C4m#Yldn_MGUSOMjv)@Jv=dnC%}HPNf~mh)7P>CihIJ2j3@A zV1=xXithfGyMh(PRR0nP-7pYD#jAtEBlr|~$K7o0syHKhv>l}c+IqQKUJmt;-NgMw z5tKyHysj^RpkTv!EP;}~=sfCO%R|XeBMTD~G|0wbUZz*aaFSU0Bp>2Xt|)Fcn9&m` zpv7-sW!+|(Rlj~J_c-V5kjh#Q3j#qG7}&9Bs}||8sP<>HE_$`p#bEtL=OxR8%(^Xd zf4BR?+sY48@9Jp_zt&w6QJ_=)d+Cvf7qMZdA|&$SneWe=H*aIAw`(p z9R}J>GAk(|FB*B1HcG1GLa&Q8=tfsr%7~MJIO!yN7O{@E8&#JUMRX@yWB3vD$)4+g z@5`Ja!W`}Yq1>{YnA5%j@lnm}6UB9{4DL{P)?k02pT&^S0&HnE} z|4ToVsnidh7}XEWeAj?>iks~IYHND^RUjqDZLFqD$l$-2%VkiG9Bwa=Hy|0yq~V|B6=a-XhO1D;murTl1bm}OkJ}k1AZbx zZT^Nq$785|J9MGW$71u1p_U>>o(rnJKltgftjUdor8m>tAJEXHC9FG~_3LyTL0XT~ zrElSD*MRlC9bZ~~l22W$dt!rkdfnpN<&zL50%Kpm49-Xa#5y$WyH8WD+e*&pe(*DP zJ=mvPcg9xVgAMM!LG}-Cl^Ok3d)#f1dA`&pF9&=&Lj8={LV4OOQP|jSV=jYHtbo>v z7C7iCE4{+;ln+%W-PwVE4qI-|h{2ip*x2)hrlDNO`jQuA*~LnVzr7S(<$RCB#{WvbEPd{8V+WjA9bU2WTD|9Ph=H+v1vOf1b%u);OEJf<2( z5$D7R=z_CO4>RtDBwR`9I???%Ke57GCUzWRDVJ{?H0HV{oe;}qW{Kqz z`BCS%9pu&pb2&1%$a37q4E^TR@A>Qfd_J$&^SnOq%V$Wg16(yF3VD=p%2PBD2&?_lek%30(s z2}pyxyiSpo>h>m~Ek-BY`vf@=(f)|Z zWG<>wAGHv(s+iDH3M=NVii6;HXC%zw*8TBj6?YF!gCj+M5?8g&_Rh8m^5x#lY1h#A=J$fZTZE~iA2?${D>Gh*$s z)a0&UV|=R4F;O0pt~jyk&?{401QzG=ZU%9{MeK|Fpbq2Nw%vwDu0RT zS@T=eI6BqrugiTyLmxj-j_EyIrgKz#)h6e-gAm-?rHzg3grXdEzzvivSRE>-{FI=O zLsca32RKptF0eE1c*>^;> zW-fuM>XdZO8Use|0TpXcshs;zqQ)*}1KjKRp~#^)`?Ko8Yuqt75X+o|7W zUE_+EdUONS`SjJ5T|8N<%|2l0ZJ=$^f_7~LgBo)8#29cCI+IaX@5ue|IbAdYTODFg zk_4ky`-uz9F!|(3R!u&Y43n4&VP^u@nj&=<6_#=b%>Sfptg%WuoL z;isBsLuamVV|qTP$8oULRFnexT$2BDO)aQpT~wQ1fLu*0*yUOup1opcVtW8V=fd{GuRF|p3xn4Daxnx|Y2Rsi;BEE!?%I9Wyw6*l$r zfnGwRE2DZKY^pHi;#ZIEBI1jfpz9yfD}(%uEHdG8L(Z!YMhjk5BE(^o>O4?bUiG51 zwd$2ez>k(P1=XlUV+7qrm?p-P9S+;Ho&UH!y+$X_#Wx$$@`u5l|5db1F&mduHGitT z_gYbp@^?bL`a~0n5DdP9?G3L%`{I@9d9<@78g=`v8#0LH)?tk8=@t5{n)?E^iu!5G z^$YH=2Pi1v-})Lo9e@eLQb%&UM8(*@pqH!WbY1-gkld1}C08>jx^Qz=6J+EN&w67ub6EV6O_INDCkI*&O>?BdP@sBmX z=TQ_*dd+<>P}7#}qh8iOSooj8 z(&#$b+!f>bJ?Vs*{ox(2IA%XDj=8xW$23tIQ7+KCv&hd%(ehPqL@5LW%`FE62LuJU z;HQGQLVGU3Rq7n?4IK(lqzsrCGxPI+K$*!IN;b@IG6`0GwM;q!u~_f zg{1~+2-Vitor-R;)>}?aRvMvSG=y=ckiMV3*EEB>lWiGd6V_z3YCMH$x|n@TK10!$D^D@VgK|Nj4bn_M%kbk>Y>);jk)dw<{m z@BjS&-us+;^53++v%^}rid|T-`gGnG8XmSQgnnHJ17it8A0Z5HB#iPS>~fy4yN$5# zy@dUrARP1z;jhaGZ~K67=t9C_QwZ}$ETM~$I|xUgBGl&-PWX^;;z`2E&4drc5I!`J z@ZlE1NB0vxewy&faKhYCgioCyTyz^^p0?Bz(K63KD?>=IYAT`YLBdxaBV0R+aNV*Zx*HFKjwH}8SahiR8 zVwHEzrXDjB2D^^aG_lyKBI;DB>*Zbpd8&kbE${A*T=BCREOEG4A!YEKH%ElNJu!p6 z!!U!s6TEDkX686GmSfkfIi_aG@zHF6)*Ku3b!a&`RzP)qMMF@RzMd{GDv6RR&H^Vx z-U4oXz#Rv)}hNEtS+ zXb7qwvWeGTR1&3C9AwpmtirVg{P=)B4rntWt2j=as^(AUOSJoE=ZKPugF*S;mDZ{{ z{(1N(;XLuzah~{Rdzs#z0^YEBq6WON^WC`RkNowP-6MofcrM|EN(cRvehy7V5+h=e!oy6QzRx!k>^N3cQ zK#_iG0`bTg`L45p@n~P{jqag({h~cjAx-QJnIjH{%#sH~su=Hj9!1?8Xxc4S?h8B5 zc}y44-yIbkGn$6(JJf??pgSZC8Zn;Nj9y!aNqATWMBZ#?oy71OA$Ir5;7PO5aZ({V zPI^OR#gCFpVs|hRTILeR;&eWsKq=S&@oG~zAFx+u#kVq%S?&^{{Zd5NL}E3i`RE5h0c@TLpHe{+2l*&(Oc5x=l%Y|L`#KB#17Q?kk3&uaCr*FyC{D zmLWP%UyE$|PGr+Rk&mYU>sRd(lOs~ZeQ6Fp>JTbMokGQECX3Tzm>BU9DuPrRe{zha zYK_He@v%eXr^D~(eB4?r#JFlwPLLj~^cG@VJN4XsfbibqvLM|VC>p+SiNSa4{C7-s%DKs)vPH{hfpSNnqe3F+ep0R_I5BBvI;AwhU)1LPfVnMd3EQyoOnHQa+ zsKX^*ovZW3_n_;=Ip})vOEP9&A{XaOmuQ@?^L!Vw`DMuFe{p=E*3%WT$Hz%gZOH2B2<}V5d7-DyU&R0Ky-dE?N z_thI@+Ok$=jPV2W1BE&-nuB!FN~DW6%G*}}y($3cYN7Mu=a4RTAzl2o)c<&fG5?iS z23V&EyW!v^^HEY#f|8PQd5>|98GW4K;aHK**V8IrkE?t=tnxK6%*YN#HYLdO?}d`8 zX&b80*M^hmYr|!^y7&m^ue-4Zum3=@?OQ!q;jO_Np6YD&yjgFHla(bw_B?oo=lW@^ z7I3_eW~t@S?nF4=rrB!Y`JU@bINqxH)^=#Qxju;F$HO~;vis5gKWK;kI|pL+rlD5_ zHd-60u>u&X3_?{{3ZWK2sAUkU!cqve075N;P!*O!s0AHbSs8>1SXv69U1k4^?OxYr zAf|7|P=5>zLrs7X;~`Xq@K$6=fDq#$RE6-iWJ`b$;~`XqCWM;Mp~c5TsDP$=D$Dn=ntukOA@~zE= zC_JF^LjlMiibeiVnhZJ!YcODCRXukHBjxUklzXI%c>f$wMxv7$;@C$i;&`=#AL)Xk zBgrT_au;rYH>tM|ts9)`-)?}|Jxm$s{OE5{d~_Cyk1ml}hhPPMHU(GUXG@ilrqx$@ z@Q8N>e&%^F)q1`j)JeI}J;k2|VkMqAmcdVckB%Ec&~Zb8>^Sxt2K=z&^}Lbx$41&8 z8($I~$9l*=e0ejo1;Rj7iN19iym=G)X#N0wG@mdkZLEu|sY_6fR5=!$N)aE|JNRik z3QxzO@bqvJCY|h|glcE}ra|YewBfhXhTmF*qb~b8SZUTZ*7G)rPTFeFNm~;-5jAzb zvbM>oM6J#B{2Udxor>E&P}H97A$xxl1iacLRY3L@2fr{5eO-72eO;J~vZq=?K}N-z zcs4~$I^*Eq6{GOG?I`@tO~vZ3^6f2FAQo%lS)E_}6vY?YQT%s*S$noC=a=KKSeNN@ z1hc^>4mg-?skc~{pT{1}tR%+rw9Gg^)}Pt2SczBev@oByjG!PE#eLof*J04EGd2f8 zu0Os4DYUEQvuZKZxu2C}e%(ptm#mT$Ti&0s2xhZ`dn}%DoU;rbkVWEvXGk1Sh(60- zu(00BDHPC1wSiar4iegrlF;5-4qnrg25M)l_63bIh&0Yb(l~EdDJ{RP6LTmXtS#e! zlcgA4{h5OYdqxiSj2v8u;)VVU>S%{L8b)FuI1PP+oQ57Cr=hjwaMy4%cB9VD>UrmO z;=|Q95y(n-uOH`xsBQYe2zRnD(8B7g=aFfojhsl@$XrpJW*X_i>}D7emYZ=o7>10V TL$YY~00x)Q8_S;yfw2Ao3)Y^Q delta 3437 zcmY+G2~-qE8ppe87(irXW)S6C@mO^Q5tJiAMwFF@N9&@I4G|%-BB+R%4VvAz`a(1a z9vosR-HM8c&loi;TG3Ha)OesqBd+JFLB%tivc&a7w)*>qXLjD3`E}R-Utd+%zq+UQ z9kR>&)^7DWl2BCKkoAKEA7>rXWeL)>8`-@W*>eZ7|4ZZ`SL9$XWI!BpSUNJ~56BNG zGTa{-k$@bPhs+v101qZ*AgAOYKVF5LdJ36v9XY)aIU^OBQh=O&7@1a&oR^Kv`WgAP zZ9+M=aaJ6F_ADvicIB%b(8yen#cs&;-pG;($j$M{igF}xMp}cBhZiG{o zdFD3qT%E=&NxERhhD*JXw+TC6IuUfy5u3a>Cq-HO5Bwhy|wo##Hi+9+{n zCnj|Fu+71}0ekhoXJaGl^Tt(MS`XWn@AVNX{havhK0XGbhgo?A#L$5~q5QxgC_hjx z-x5HDTsE|h`UZmJI{_r$nQTkIn0-OpiIA5ZQ&>cZO#MT_;{Op?{L}cc5KpappL&I5 zhg;ZpAG*-MIp7Ig2A;r8tU4l!hlU-{>NE|nqd|*74^lx7su06O@o|H zWEvU)rqFmWg?`SfBPz85t4kE-87b2+Gw5MMKo5)NC6PU}i5N2!HZDr0mPpVoiJ)5+ z^7B!k-;b`NBR>OeWFBZEw<&WyNC$g4wy$0$b9bU-(IWC4qVpNe36^*RrLF4~I zX;h?GY)^C4JY3;PAKN&iGlQsg*fMSwa^hFKeuB}N*h2;dQ)B4ll`w(H+hGEet5|w! z1fLv#j0le@p^nCG0X_Bz=&@HppOv^<)3qdaO_yn0Ie6lZfhX<;ADq;a3SCR$_6(WE zUjaS71@vhSJR$jo*1u`E!WvR!n)m?p#17Cu?a9+qMbh?|z|Pq+P1*{Eq$)5ZU1tf& z5q!>^e`rOt6c){uX>ulbk_*9;{0)CQ*HxQ@F{6&AmV%aA30mqE(chhqn*UDge?MAb z#swBrC9Y8C@0_2Y%ba@Xl14j&abt5c4SIWF!*HAz#L#p{@TUJByy+HRv>=hvj1mYZ zqZ&(Qowo6EXE+%x*s{MBferW=*f0}QI9T3S zul@UA0vX$4=*Bdtu`vf~Y~0M-wq2pLG!qgiEyZ=Nu>D0=D4hwE+OpX`4IR5LaPJ)^ z1DloIjSX97?yZ;fciu|#GBX{-0g*_oo#b$*U7Xu%lww(9c7N89ZT`RSx&6Ux?6SVY z>?K`3k=p&f|K3p?QHhj`a`|s1(ICnRiIj_S`Ik?>{&~WGt0LI zv%uWm{I1oFu-qXk%R3~~y_K+7dvCyE?QP+P!~T?Q8LF~>9g*pN0_y(Xfx170PdO^o z?ZGN@KQ7aQV?aHa4C=u}eEsoY%KrU<%2H0sv~n$|l@*{?p5>2E4yLSexXN~(kx3P+ z3HPE^&p|w9;C|I&k2vB+syHXp6L+Eai8o;Q!Icj^-$dBbQ7SudL8hl3fqI&NdfJ13 zaIu-Ny`xoj^pZ@g8$mtm2nRhdzXKf&04skxXj`gQs>ZcxsctQ})=0FxTlS z`{b!i@8yEyUO71KRVsm9h&O-!)Q_;yGgNl4UZ!u}RrYC%OrPX~`s7yAkj2#&|T8{MubJXiwjFH!LRGOCc_oBsG5l!#1yhVVifp zPw37I1N(cXs&!&VU%Jp|72te!0i4esV)g#7UK84;gP7WE?|4qb&o7YYWd)810tbVQeCUEY;M5#pphfR&jB;n6en==Y#UU#+e3 zK&x{%;!fDt>r~~4i?BH~pv}<%ZH_)xvDCu|TcL`<%);Sh8_dZzm{S_8hIN;j7zryZ zQMK_bN?~{6LYLuFc!}tUD2pisH?xvZ;qC+3f<_x;;gki`2OTbVM29 zF1$`!hDyD=Fq=HkY|{P)#KoE>TE**3FT!q>tD3{2BzlRVT_>T;C}Vi{L~6 From dbf28efe895dfbf465351a873db3061a620ef29a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 23 Jun 2023 23:42:30 +0700 Subject: [PATCH 0648/1199] Optimize Container.balance --- .../ru/dbotthepony/mc/otm/container/Ext.kt | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt index 89024f2bf..94024d62d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt @@ -13,6 +13,7 @@ import net.minecraftforge.fluids.capability.IFluidHandler import ru.dbotthepony.mc.otm.core.addAll import ru.dbotthepony.mc.otm.core.collect.iterator import ru.dbotthepony.mc.otm.core.collect.nonEmpty +import ru.dbotthepony.mc.otm.core.isNotEmpty import kotlin.math.roundToInt operator fun Container.set(index: Int, value: ItemStack) = setItem(index, value) @@ -119,7 +120,7 @@ inline fun Container.forEachNonEmpty(lambda: (ItemStack) -> Unit) { } fun Container.balance(slots: IntSet) { - if (slots.isEmpty()) return + if (slots.isEmpty() || !slots.any { getItem(it).isNotEmpty }) return val empty = IntArrayList() val itemTypes = Object2ObjectOpenCustomHashMap(ItemStackHashStrategy) @@ -140,12 +141,15 @@ fun Container.balance(slots: IntSet) { // только один вид предмета, просто балансируем его во все слоты if (itemTypes.size == 1) { val (item, list) = itemTypes.entries.first() - var count = list.stream().mapToInt { getItem(it).count }.sum() + var count = 0 + for (i in list.intIterator()) count += getItem(i).count + var ghostChanges = false // всего предметов меньше, чем слотов if (count < slots.size) { for (slot in list.intIterator()) { getItem(slot).count = 1 + ghostChanges = true } count -= list.size @@ -157,6 +161,7 @@ fun Container.balance(slots: IntSet) { if (count > 0) { getItem(list.firstInt()).count += count + ghostChanges = true } } else { // всего предметов больше, чем слотов @@ -164,17 +169,17 @@ fun Container.balance(slots: IntSet) { var leftover = count - perSlot * slots.size for (i in slots.intIterator()) { - setItem(i, item.copyWithCount(perSlot)) - } + val target = perSlot + leftover.coerceAtMost(1) - for (i in slots.intIterator()) { - if (leftover <= 0) break - getItem(i).count++ - leftover-- + if (getItem(i).count != target) { + setItem(i, item.copyWithCount(target)) + } + + if (leftover > 0) leftover-- } } - setChanged() + if (ghostChanges) setChanged() return } From 7cddbdea313caa8cbddd8930112db3f536b80d0a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 23 Jun 2023 23:42:30 +0700 Subject: [PATCH 0649/1199] Optimize Container.balance --- .../ru/dbotthepony/mc/otm/container/Ext.kt | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt index 94024d62d..6b279ce3c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt @@ -119,8 +119,8 @@ inline fun Container.forEachNonEmpty(lambda: (ItemStack) -> Unit) { } } -fun Container.balance(slots: IntSet) { - if (slots.isEmpty() || !slots.any { getItem(it).isNotEmpty }) return +fun Container.balance(slots: IntSet, checkForEmpty: Boolean = true) { + if (slots.isEmpty() || checkForEmpty && !slots.any { getItem(it).isNotEmpty }) return val empty = IntArrayList() val itemTypes = Object2ObjectOpenCustomHashMap(ItemStackHashStrategy) @@ -250,5 +250,15 @@ fun Container.balance(slots: IntRange) { fun Container.balance(startSlot: Int = 0, endSlot: Int = containerSize - 1) { require(startSlot <= endSlot) { "Invalid slot range: $startSlot .. $endSlot" } - balance(IntArrayList(endSlot - startSlot + 1).also { for (i in startSlot .. endSlot) it.add(i) }) + var any = false + + for (i in startSlot .. endSlot) { + if (getItem(i).isNotEmpty) { + any = true + break + } + } + + if (!any) return + balance(IntArraySet(endSlot - startSlot + 1).also { for (i in startSlot .. endSlot) it.add(i) }, false) } From 65008b2a56be9fc0eea5c8ae6be5e9ce683f128f Mon Sep 17 00:00:00 2001 From: GearShocky Date: Sun, 25 Jun 2023 04:03:22 +0600 Subject: [PATCH 0650/1199] Update cobblestone generator model and make matter decomposer matter canisters glow --- .../models/block/cobblestone_generator.json | 66 ++++++++++-- .../models/block/matter_decomposer_error.json | 94 ++++++++++++++---- .../models/block/matter_decomposer_idle.json | 84 +++++++++++----- .../block/matter_decomposer_working.json | 94 ++++++++++++++---- .../textures/block/cobblestone_generator.png | Bin 1104 -> 989 bytes .../textures/block/lava_still.png | Bin 0 -> 6540 bytes .../textures/block/lava_still.png.mcmeta | 45 +++++++++ .../textures/block/water_still.png | Bin 0 -> 5409 bytes .../textures/block/water_still.png.mcmeta | 5 + 9 files changed, 315 insertions(+), 73 deletions(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/lava_still.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/lava_still.png.mcmeta create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/water_still.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/water_still.png.mcmeta diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/cobblestone_generator.json b/src/main/resources/assets/overdrive_that_matters/models/block/cobblestone_generator.json index 2f06eb12d..f296349d7 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/cobblestone_generator.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/cobblestone_generator.json @@ -1,8 +1,11 @@ { "credit": "Made with Blockbench", + "render_type": "translucent", "texture_size": [32, 64], "textures": { "0": "overdrive_that_matters:block/cobblestone_generator", + "1": "overdrive_that_matters:block/lava_still", + "2": "overdrive_that_matters:block/water_still", "particle": "overdrive_that_matters:block/cobblestone_generator" }, "elements": [ @@ -30,18 +33,65 @@ } }, { - "from": [1, 6, 1], - "to": [4, 15, 15], + "from": [12, 6, 1], + "to": [15, 15, 15], "faces": { - "north": {"uv": [8.5, 7, 7, 9.25], "texture": "#0"}, - "south": {"uv": [7, 7, 8.5, 9.25], "texture": "#0"}, - "west": {"uv": [0, 7, 7, 9.25], "texture": "#0"}, - "up": {"uv": [0, 9.25, 7, 10], "rotation": 270, "texture": "#0"} + "north": {"uv": [7, 4, 8.5, 6.25], "texture": "#0"}, + "east": {"uv": [0, 4, 7, 6.25], "texture": "#0"}, + "south": {"uv": [8.5, 4, 7, 6.25], "texture": "#0"}, + "up": {"uv": [0, 6.25, 7, 7], "rotation": 90, "texture": "#0"} } }, { - "from": [12, 6, 1], - "to": [15, 15, 15], + "name": "water", + "from": [12, 6, 1.1], + "to": [14.9, 14.9, 14.9], + "faces": { + "north": {"uv": [6.5, 7, 7.5, 9], "texture": "#2"}, + "east": {"uv": [0, 7, 6.5, 9], "texture": "#2"}, + "south": {"uv": [14, 7, 15, 9], "texture": "#2"}, + "west": {"uv": [7.5, 7, 14, 9], "texture": "#2"}, + "up": {"uv": [7.5, 7, 6.5, 3.75], "texture": "#2"}, + "down": {"uv": [8.5, 3.75, 7.5, 7], "texture": "#2"} + } + }, + { + "from": [15, 6, 1], + "to": [12, 15, 15], + "faces": { + "north": {"uv": [8.5, 4, 7, 6.25], "texture": "#0"}, + "south": {"uv": [7, 4, 8.5, 6.25], "texture": "#0"}, + "west": {"uv": [0, 4, 7, 6.25], "texture": "#0"}, + "up": {"uv": [0, 6.25, 7, 7], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [1, 6, 1], + "to": [4, 15, 15], + "faces": { + "north": {"uv": [8.5, 4, 7, 6.25], "texture": "#0"}, + "south": {"uv": [7, 4, 8.5, 6.25], "texture": "#0"}, + "west": {"uv": [0, 4, 7, 6.25], "texture": "#0"}, + "up": {"uv": [0, 6.25, 7, 7], "rotation": 270, "texture": "#0"} + } + }, + { + "name": "lava", + "from": [1.1, 6, 1.1], + "to": [4, 14.9, 14.9], + "faces": { + "north": {"uv": [6.5, 4, 7.5, 6], "texture": "#1"}, + "east": {"uv": [0, 4, 6.5, 6], "texture": "#1"}, + "south": {"uv": [14, 4, 15, 6], "texture": "#1"}, + "west": {"uv": [7.5, 4, 14, 6], "texture": "#1"}, + "up": {"uv": [7.5, 4, 6.5, 0.75], "texture": "#1"}, + "down": {"uv": [8.5, 0.75, 7.5, 4], "texture": "#1"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "from": [4, 6, 1], + "to": [1, 15, 15], "faces": { "north": {"uv": [7, 4, 8.5, 6.25], "texture": "#0"}, "east": {"uv": [0, 4, 7, 6.25], "texture": "#0"}, diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/matter_decomposer_error.json b/src/main/resources/assets/overdrive_that_matters/models/block/matter_decomposer_error.json index 4207d56fd..6ba86b60e 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/matter_decomposer_error.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/matter_decomposer_error.json @@ -1,9 +1,10 @@ { + "credit": "Made with Blockbench", "parent": "block/block", "texture_size": [64, 64], "textures": { - "texture": "overdrive_that_matters:block/matter_decomposer", - "particle": "overdrive_that_matters:block/matter_decomposer" + "particle": "overdrive_that_matters:block/matter_decomposer", + "texture": "overdrive_that_matters:block/matter_decomposer" }, "elements": [ { @@ -26,32 +27,83 @@ "east": {"uv": [4, 10.5, 8, 13.75], "texture": "#texture"}, "south": {"uv": [6, 7.25, 8, 10.5], "texture": "#texture"}, "west": {"uv": [8, 10.5, 12, 13.75], "texture": "#texture"}, - "up": {"uv": [4, 13.75, 8, 15.25], "rotation": 90, "texture": "#texture"}, - "down": {"uv": [0, 7.25, 2, 11.25], "texture": "#texture"} + "up": {"uv": [4, 13.75, 8, 15.25], "rotation": 90, "texture": "#texture"} + } + }, + { + "name": "glow", + "from": [1, 5, 9], + "to": [7, 12, 15], + "faces": { + "north": {"uv": [0, 5, 1.5, 6.75], "texture": "#texture"}, + "east": {"uv": [0, 5, 1.5, 6.75], "texture": "#texture"}, + "south": {"uv": [0, 5, 1.5, 6.75], "texture": "#texture"}, + "west": {"uv": [0, 5, 1.5, 6.75], "texture": "#texture"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#texture"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "from": [1, 3, 9], + "to": [7, 5, 15], + "faces": { + "north": {"uv": [0, 6.75, 1.5, 7.25], "texture": "#texture"}, + "east": {"uv": [0, 6.75, 1.5, 7.25], "texture": "#texture"}, + "south": {"uv": [0, 6.75, 1.5, 7.25], "texture": "#texture"}, + "west": {"uv": [0, 6.75, 1.5, 7.25], "texture": "#texture"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#texture"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#texture"} } }, { "from": [1, 3, 1], - "to": [7, 14, 7], + "to": [7, 5, 7], "faces": { - "north": {"uv": [0, 4.5, 1.5, 7.25], "texture": "#texture"}, - "east": {"uv": [0, 4.5, 1.5, 7.25], "texture": "#texture"}, - "south": {"uv": [0, 4.5, 1.5, 7.25], "texture": "#texture"}, - "west": {"uv": [0, 4.5, 1.5, 7.25], "texture": "#texture"}, - "up": {"uv": [0, 3, 1.5, 4.5], "texture": "#texture"}, - "down": {"uv": [0, 3, 1.5, 4.5], "texture": "#texture"} + "north": {"uv": [0, 6.75, 1.5, 7.25], "texture": "#texture"}, + "east": {"uv": [0, 6.75, 1.5, 7.25], "texture": "#texture"}, + "south": {"uv": [0, 6.75, 1.5, 7.25], "texture": "#texture"}, + "west": {"uv": [0, 6.75, 1.5, 7.25], "texture": "#texture"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#texture"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#texture"} } }, { - "from": [1, 3, 9], + "name": "glow", + "from": [1, 5, 1], + "to": [7, 12, 7], + "faces": { + "north": {"uv": [0, 5, 1.5, 6.75], "texture": "#texture"}, + "east": {"uv": [0, 5, 1.5, 6.75], "texture": "#texture"}, + "south": {"uv": [0, 5, 1.5, 6.75], "texture": "#texture"}, + "west": {"uv": [0, 5, 1.5, 6.75], "texture": "#texture"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#texture"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "from": [1, 12, 1], + "to": [7, 14, 7], + "faces": { + "north": {"uv": [0, 4.5, 1.5, 5], "texture": "#texture"}, + "east": {"uv": [0, 4.5, 1.5, 5], "texture": "#texture"}, + "south": {"uv": [0, 4.5, 1.5, 5], "texture": "#texture"}, + "west": {"uv": [0, 4.5, 1.5, 5], "texture": "#texture"}, + "up": {"uv": [0, 3, 1.5, 4.5], "texture": "#texture"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#texture"} + } + }, + { + "from": [1, 12, 9], "to": [7, 14, 15], "faces": { - "north": {"uv": [0, 4.5, 1.5, 7.25], "texture": "#texture"}, - "east": {"uv": [0, 4.5, 1.5, 7.25], "texture": "#texture"}, - "south": {"uv": [0, 4.5, 1.5, 7.25], "texture": "#texture"}, - "west": {"uv": [0, 4.5, 1.5, 7.25], "texture": "#texture"}, + "north": {"uv": [0, 4.5, 1.5, 5], "texture": "#texture"}, + "east": {"uv": [0, 4.5, 1.5, 5], "texture": "#texture"}, + "south": {"uv": [0, 4.5, 1.5, 5], "texture": "#texture"}, + "west": {"uv": [0, 4.5, 1.5, 5], "texture": "#texture"}, "up": {"uv": [0, 3, 1.5, 4.5], "texture": "#texture"}, - "down": {"uv": [0, 3, 1.5, 4.5], "texture": "#texture"} + "down": {"uv": [0, 0, 0, 0], "texture": "#texture"} } }, { @@ -59,11 +111,11 @@ "to": [8, 15, 13], "faces": { "north": {"uv": [1.75, 6, 2.25, 7.25], "rotation": 270, "texture": "#texture"}, - "east": {"uv": [0.5, 3.5, 1, 3.75], "texture": "#texture"}, + "east": {"uv": [0, 0, 0, 0], "texture": "#texture"}, "south": {"uv": [1.75, 6, 2.25, 7.25], "rotation": 90, "texture": "#texture"}, "west": {"uv": [1.75, 6.75, 2.25, 7.25], "rotation": 90, "texture": "#texture"}, "up": {"uv": [2.25, 6, 2.75, 7.25], "rotation": 90, "texture": "#texture"}, - "down": {"uv": [1.5, 5.25, 1.75, 7.25], "texture": "#texture"} + "down": {"uv": [0, 0, 0, 0], "texture": "#texture"} } }, { @@ -71,11 +123,11 @@ "to": [8, 15, 5], "faces": { "north": {"uv": [1.75, 6, 2.25, 7.25], "rotation": 270, "texture": "#texture"}, - "east": {"uv": [0.5, 3.5, 1, 3.75], "texture": "#texture"}, + "east": {"uv": [0, 0, 0, 0], "texture": "#texture"}, "south": {"uv": [1.75, 6, 2.25, 7.25], "rotation": 90, "texture": "#texture"}, "west": {"uv": [1.75, 6.75, 2.25, 7.25], "rotation": 90, "texture": "#texture"}, "up": {"uv": [2.25, 6, 2.75, 7.25], "rotation": 90, "texture": "#texture"}, - "down": {"uv": [1.5, 5.25, 1.75, 7.25], "texture": "#texture"} + "down": {"uv": [0, 0, 0, 0], "texture": "#texture"} } } ] diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/matter_decomposer_idle.json b/src/main/resources/assets/overdrive_that_matters/models/block/matter_decomposer_idle.json index 4207d56fd..64954b86b 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/matter_decomposer_idle.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/matter_decomposer_idle.json @@ -1,9 +1,10 @@ { + "credit": "Made with Blockbench", "parent": "block/block", "texture_size": [64, 64], "textures": { - "texture": "overdrive_that_matters:block/matter_decomposer", - "particle": "overdrive_that_matters:block/matter_decomposer" + "particle": "overdrive_that_matters:block/matter_decomposer", + "texture": "overdrive_that_matters:block/matter_decomposer" }, "elements": [ { @@ -26,32 +27,73 @@ "east": {"uv": [4, 10.5, 8, 13.75], "texture": "#texture"}, "south": {"uv": [6, 7.25, 8, 10.5], "texture": "#texture"}, "west": {"uv": [8, 10.5, 12, 13.75], "texture": "#texture"}, - "up": {"uv": [4, 13.75, 8, 15.25], "rotation": 90, "texture": "#texture"}, - "down": {"uv": [0, 7.25, 2, 11.25], "texture": "#texture"} + "up": {"uv": [4, 13.75, 8, 15.25], "rotation": 90, "texture": "#texture"} } }, { - "from": [1, 3, 1], + "from": [1, 12, 1], "to": [7, 14, 7], "faces": { - "north": {"uv": [0, 4.5, 1.5, 7.25], "texture": "#texture"}, - "east": {"uv": [0, 4.5, 1.5, 7.25], "texture": "#texture"}, - "south": {"uv": [0, 4.5, 1.5, 7.25], "texture": "#texture"}, - "west": {"uv": [0, 4.5, 1.5, 7.25], "texture": "#texture"}, - "up": {"uv": [0, 3, 1.5, 4.5], "texture": "#texture"}, - "down": {"uv": [0, 3, 1.5, 4.5], "texture": "#texture"} + "north": {"uv": [0, 4.5, 1.5, 5], "texture": "#texture"}, + "east": {"uv": [0, 4.5, 1.5, 5], "texture": "#texture"}, + "south": {"uv": [0, 4.5, 1.5, 5], "texture": "#texture"}, + "west": {"uv": [0, 4.5, 1.5, 5], "texture": "#texture"}, + "up": {"uv": [0, 3, 1.5, 4.5], "texture": "#texture"} + } + }, + { + "name": "glow", + "from": [1, 5, 1], + "to": [7, 12, 7], + "faces": { + "north": {"uv": [0, 5, 1.5, 6.75], "texture": "#texture"}, + "east": {"uv": [0, 5, 1.5, 6.75], "texture": "#texture"}, + "south": {"uv": [0, 5, 1.5, 6.75], "texture": "#texture"}, + "west": {"uv": [0, 5, 1.5, 6.75], "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "from": [1, 3, 1], + "to": [7, 5, 7], + "faces": { + "north": {"uv": [0, 6.75, 1.5, 7.25], "texture": "#texture"}, + "east": {"uv": [0, 6.75, 1.5, 7.25], "texture": "#texture"}, + "south": {"uv": [0, 6.75, 1.5, 7.25], "texture": "#texture"}, + "west": {"uv": [0, 6.75, 1.5, 7.25], "texture": "#texture"} } }, { "from": [1, 3, 9], + "to": [7, 5, 15], + "faces": { + "north": {"uv": [0, 6.75, 1.5, 7.25], "texture": "#texture"}, + "east": {"uv": [0, 6.75, 1.5, 7.25], "texture": "#texture"}, + "south": {"uv": [0, 6.75, 1.5, 7.25], "texture": "#texture"}, + "west": {"uv": [0, 6.75, 1.5, 7.25], "texture": "#texture"} + } + }, + { + "name": "glow", + "from": [1, 5, 9], + "to": [7, 12, 15], + "faces": { + "north": {"uv": [0, 5, 1.5, 6.75], "texture": "#texture"}, + "east": {"uv": [0, 5, 1.5, 6.75], "texture": "#texture"}, + "south": {"uv": [0, 5, 1.5, 6.75], "texture": "#texture"}, + "west": {"uv": [0, 5, 1.5, 6.75], "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "from": [1, 12, 9], "to": [7, 14, 15], "faces": { - "north": {"uv": [0, 4.5, 1.5, 7.25], "texture": "#texture"}, - "east": {"uv": [0, 4.5, 1.5, 7.25], "texture": "#texture"}, - "south": {"uv": [0, 4.5, 1.5, 7.25], "texture": "#texture"}, - "west": {"uv": [0, 4.5, 1.5, 7.25], "texture": "#texture"}, - "up": {"uv": [0, 3, 1.5, 4.5], "texture": "#texture"}, - "down": {"uv": [0, 3, 1.5, 4.5], "texture": "#texture"} + "north": {"uv": [0, 4.5, 1.5, 5], "texture": "#texture"}, + "east": {"uv": [0, 4.5, 1.5, 5], "texture": "#texture"}, + "south": {"uv": [0, 4.5, 1.5, 5], "texture": "#texture"}, + "west": {"uv": [0, 4.5, 1.5, 5], "texture": "#texture"}, + "up": {"uv": [0, 3, 1.5, 4.5], "texture": "#texture"} } }, { @@ -59,11 +101,9 @@ "to": [8, 15, 13], "faces": { "north": {"uv": [1.75, 6, 2.25, 7.25], "rotation": 270, "texture": "#texture"}, - "east": {"uv": [0.5, 3.5, 1, 3.75], "texture": "#texture"}, "south": {"uv": [1.75, 6, 2.25, 7.25], "rotation": 90, "texture": "#texture"}, "west": {"uv": [1.75, 6.75, 2.25, 7.25], "rotation": 90, "texture": "#texture"}, - "up": {"uv": [2.25, 6, 2.75, 7.25], "rotation": 90, "texture": "#texture"}, - "down": {"uv": [1.5, 5.25, 1.75, 7.25], "texture": "#texture"} + "up": {"uv": [2.25, 6, 2.75, 7.25], "rotation": 90, "texture": "#texture"} } }, { @@ -71,11 +111,9 @@ "to": [8, 15, 5], "faces": { "north": {"uv": [1.75, 6, 2.25, 7.25], "rotation": 270, "texture": "#texture"}, - "east": {"uv": [0.5, 3.5, 1, 3.75], "texture": "#texture"}, "south": {"uv": [1.75, 6, 2.25, 7.25], "rotation": 90, "texture": "#texture"}, "west": {"uv": [1.75, 6.75, 2.25, 7.25], "rotation": 90, "texture": "#texture"}, - "up": {"uv": [2.25, 6, 2.75, 7.25], "rotation": 90, "texture": "#texture"}, - "down": {"uv": [1.5, 5.25, 1.75, 7.25], "texture": "#texture"} + "up": {"uv": [2.25, 6, 2.75, 7.25], "rotation": 90, "texture": "#texture"} } } ] diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/matter_decomposer_working.json b/src/main/resources/assets/overdrive_that_matters/models/block/matter_decomposer_working.json index 6f9ca6c20..9d6fe8781 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/matter_decomposer_working.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/matter_decomposer_working.json @@ -1,9 +1,10 @@ { + "credit": "Made with Blockbench", "parent": "block/block", "texture_size": [64, 64], "textures": { - "texture": "overdrive_that_matters:block/matter_decomposer", - "particle": "overdrive_that_matters:block/matter_decomposer" + "particle": "overdrive_that_matters:block/matter_decomposer", + "texture": "overdrive_that_matters:block/matter_decomposer" }, "elements": [ { @@ -26,32 +27,83 @@ "east": {"uv": [8, 7.25, 12, 10.5], "texture": "#texture"}, "south": {"uv": [6, 7.25, 8, 10.5], "texture": "#texture"}, "west": {"uv": [8, 10.5, 12, 13.75], "texture": "#texture"}, - "up": {"uv": [4, 13.75, 8, 15.25], "rotation": 90, "texture": "#texture"}, - "down": {"uv": [0, 7.25, 2, 11.25], "texture": "#texture"} + "up": {"uv": [4, 13.75, 8, 15.25], "rotation": 90, "texture": "#texture"} + } + }, + { + "name": "glow", + "from": [1, 5, 9], + "to": [7, 12, 15], + "faces": { + "north": {"uv": [0, 5, 1.5, 6.75], "texture": "#texture"}, + "east": {"uv": [0, 5, 1.5, 6.75], "texture": "#texture"}, + "south": {"uv": [0, 5, 1.5, 6.75], "texture": "#texture"}, + "west": {"uv": [0, 5, 1.5, 6.75], "texture": "#texture"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#texture"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "from": [1, 3, 9], + "to": [7, 5, 15], + "faces": { + "north": {"uv": [0, 6.75, 1.5, 7.25], "texture": "#texture"}, + "east": {"uv": [0, 6.75, 1.5, 7.25], "texture": "#texture"}, + "south": {"uv": [0, 6.75, 1.5, 7.25], "texture": "#texture"}, + "west": {"uv": [0, 6.75, 1.5, 7.25], "texture": "#texture"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#texture"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#texture"} } }, { "from": [1, 3, 1], - "to": [7, 14, 7], + "to": [7, 5, 7], "faces": { - "north": {"uv": [0, 4.5, 1.5, 7.25], "texture": "#texture"}, - "east": {"uv": [0, 4.5, 1.5, 7.25], "texture": "#texture"}, - "south": {"uv": [0, 4.5, 1.5, 7.25], "texture": "#texture"}, - "west": {"uv": [0, 4.5, 1.5, 7.25], "texture": "#texture"}, - "up": {"uv": [0, 3, 1.5, 4.5], "texture": "#texture"}, - "down": {"uv": [0, 3, 1.5, 4.5], "texture": "#texture"} + "north": {"uv": [0, 6.75, 1.5, 7.25], "texture": "#texture"}, + "east": {"uv": [0, 6.75, 1.5, 7.25], "texture": "#texture"}, + "south": {"uv": [0, 6.75, 1.5, 7.25], "texture": "#texture"}, + "west": {"uv": [0, 6.75, 1.5, 7.25], "texture": "#texture"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#texture"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#texture"} } }, { - "from": [1, 3, 9], + "name": "glow", + "from": [1, 5, 1], + "to": [7, 12, 7], + "faces": { + "north": {"uv": [0, 5, 1.5, 6.75], "texture": "#texture"}, + "east": {"uv": [0, 5, 1.5, 6.75], "texture": "#texture"}, + "south": {"uv": [0, 5, 1.5, 6.75], "texture": "#texture"}, + "west": {"uv": [0, 5, 1.5, 6.75], "texture": "#texture"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#texture"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "from": [1, 12, 1], + "to": [7, 14, 7], + "faces": { + "north": {"uv": [0, 4.5, 1.5, 5], "texture": "#texture"}, + "east": {"uv": [0, 4.5, 1.5, 5], "texture": "#texture"}, + "south": {"uv": [0, 4.5, 1.5, 5], "texture": "#texture"}, + "west": {"uv": [0, 4.5, 1.5, 5], "texture": "#texture"}, + "up": {"uv": [0, 3, 1.5, 4.5], "texture": "#texture"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#texture"} + } + }, + { + "from": [1, 12, 9], "to": [7, 14, 15], "faces": { - "north": {"uv": [0, 4.5, 1.5, 7.25], "texture": "#texture"}, - "east": {"uv": [0, 4.5, 1.5, 7.25], "texture": "#texture"}, - "south": {"uv": [0, 4.5, 1.5, 7.25], "texture": "#texture"}, - "west": {"uv": [0, 4.5, 1.5, 7.25], "texture": "#texture"}, + "north": {"uv": [0, 4.5, 1.5, 5], "texture": "#texture"}, + "east": {"uv": [0, 4.5, 1.5, 5], "texture": "#texture"}, + "south": {"uv": [0, 4.5, 1.5, 5], "texture": "#texture"}, + "west": {"uv": [0, 4.5, 1.5, 5], "texture": "#texture"}, "up": {"uv": [0, 3, 1.5, 4.5], "texture": "#texture"}, - "down": {"uv": [0, 3, 1.5, 4.5], "texture": "#texture"} + "down": {"uv": [0, 0, 0, 0], "texture": "#texture"} } }, { @@ -59,11 +111,11 @@ "to": [8, 15, 13], "faces": { "north": {"uv": [1.75, 6, 2.25, 7.25], "rotation": 270, "texture": "#texture"}, - "east": {"uv": [0.5, 3.5, 1, 3.75], "texture": "#texture"}, + "east": {"uv": [0, 0, 0, 0], "texture": "#texture"}, "south": {"uv": [1.75, 6, 2.25, 7.25], "rotation": 90, "texture": "#texture"}, "west": {"uv": [1.75, 6.75, 2.25, 7.25], "rotation": 90, "texture": "#texture"}, "up": {"uv": [2.25, 6, 2.75, 7.25], "rotation": 90, "texture": "#texture"}, - "down": {"uv": [1.5, 5.25, 1.75, 7.25], "texture": "#texture"} + "down": {"uv": [0, 0, 0, 0], "texture": "#texture"} } }, { @@ -71,11 +123,11 @@ "to": [8, 15, 5], "faces": { "north": {"uv": [1.75, 6, 2.25, 7.25], "rotation": 270, "texture": "#texture"}, - "east": {"uv": [0.5, 3.5, 1, 3.75], "texture": "#texture"}, + "east": {"uv": [0, 0, 0, 0], "texture": "#texture"}, "south": {"uv": [1.75, 6, 2.25, 7.25], "rotation": 90, "texture": "#texture"}, "west": {"uv": [1.75, 6.75, 2.25, 7.25], "rotation": 90, "texture": "#texture"}, "up": {"uv": [2.25, 6, 2.75, 7.25], "rotation": 90, "texture": "#texture"}, - "down": {"uv": [1.5, 5.25, 1.75, 7.25], "texture": "#texture"} + "down": {"uv": [0, 0, 0, 0], "texture": "#texture"} } } ] diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cobblestone_generator.png index d1c82ec86ab9b99853eec50a33dbeefcc652268c..46cf1b6b32582852a05bc40c4b3c3d5ac0311342 100644 GIT binary patch delta 978 zcmV;@11d>j1gS4~l>Z%knSPmYdo#N6#kjUk79vNPT_=_*O zmt5`=akOrJT+~Sy@@(^oOD< zg0e-td;g)511hDRA}@ns7)d7d;T-^=*=%BAVPRzK!^1=Bf3Md=v)M$i*NYt>0PROK6$~&-0MYrc6gs6v6j> zv|25MVHi75HhLMhZ36&I(*%Ir=tZa>c+5a{Crrxu`T11y+U<7r3=qEWPc)t$*VGyy z#57M*$Y}1|w1(@*ny%}y1ElClm}X9vAPC||5Jge4V1JoPNOS5y6~$v1MyW|+DX#1Q z)ql_PQklquBBw$k?rGpjU|B)twX0OEvIfQ>s~uuC^R}hfuIoBfs$j0`CRL3wmNFn4 zL%6Ps>+5SJ&(ZyZLp~hzadCQ*YG2#h!TjPt&TA|{#YHj9M!aU=|B!#Hk z?V{0WpwsCjXNIe*D*(V;_L&kz#%J1Cqzj1cq6P@6cEHoENMzO8 zO#N>PztudWMabr44a=@$GSqQfNJiN?7pEs!+uFg|&mXy(nfgdp7c&Q@u4E$n2Zub{ zR)1QAbvPgzq}?FfjxuV=KoPR+h`hK4W)938P&=JYN~Nz}zbTw>_xDfgh*jpb{QK8; zc%GMPYqeU~*xrrnK)2gXI^K?PKpfj{x5wEA0BmgUVk4(drD)22;Sle5dEbDtjLpDv zQ<#D0HvaYV$3l%%+6A)n{-jiLpsWU-%}aq=GEhepl^m!NMJBZ99M^aR3LtaLH~;_u07*qoM6N<$f}6hD A3;+NC literal 1104 zcmeAS@N?(olHy`uVBq!ia0vp^3P9|@!3-pQ0$S$)DaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(ehKlmmQ1Tun_)wY9ay#KhFp)Y2+ja+~`9|Nmc9R8(JI-`?IH5)zV-kYF6V z-Xv^`Mf5?J{Fhbas@zN!yO}2TVv+5u zm5!GJd9TF?UJmBH9Kv^}Q1(%~_Vsw->#;%)+jZ_$Dc#DHc-*IdGez`vuJp4RX0KK` z-z}Cq>%?(8N9yHLhlj127reM`=Sp3T6u1(~cfUsE-7dek+k752s-Jb?yy(My(vt07 zh2pd6rsqAlE(h^mPY^z7!FIxo^@11o+pS)&*Sfr1=J0f?$?NrQ7k#-;S+gBCVLffj ze#VjGdYsUwv(b;*wVuzmIOoQBJ6rNnAkVEV$wwVJ4_h>^MhKku;<{TZeP!%DzPNUFBlj&GzARn8uAT+mT?w%L>4nJ@ErnSMo|r~1_lNuPfr)e5D)LC zQ>()-I|v+2-?VaVtl8ETf-J!<7lTBn1l4FO?Q>wfpMU%Pf6YC+tvwI7$(;-Q|GE5D z$>p8a)#+ukg$kE&DJ{DZwEC#2eMhHe(3u|!X`+JjITmOfGHEP)tTs&{^*Q&6g|EII z^YmuEBK_5BrP7-K-vzUyZu3`jvh+mH5DUI0tjSp!k@?{HE}31E9KDY+u?T&NVD!?o zaJmrk^qA(1DH8;^R>`fBY;p@_DKHXyuuSR0?57)h9Yt3hb~S8Jxbx0yW|Z-**3df) z(XTORw@>;3(4^S*!e z{!hmIDsjrc6(&wf{_QgH#}6Bm_QMO0B=a0+YW$Mu82o6du&JklkI0jjrl5uM>L(-y z&9pqOFPQS9`rt;ne@pm(yq{2!vpsH~{)zb(!awy{7GKQYEo~fndW*z6U`k`~boFyt I=akR{0I=K?MF0Q* diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/lava_still.png b/src/main/resources/assets/overdrive_that_matters/textures/block/lava_still.png new file mode 100644 index 0000000000000000000000000000000000000000..e62298cefbcc9c06013871e8d1564113a566615b GIT binary patch literal 6540 zcmV;78FS`|P)jo z{@eZ41v~GavvcF@15cf?XUpP!Pb}Yl!}RSp&D{6+@M5^ZdE(AHXYc);Q{H>%Bxe5niW7Oxa=-k?FMs+k*ZlG)R~43V4PJ0=xGw1BQ zYYtl-d}bv_Vnv2=RPIZpzilRebF*j5k`Mp%3rByvYVRXUk!{a|i$DI+=Ig6Rwp}}waV-C{i;w4*i!nI^8el3SZM$yt zz_(Vs|NZm!{MHhTz=?l;`H4Jd=xdi%?QNJ<4t;ke3jXj*N zyv+2%U0XQrZN;8|K|nAu_QZSvj2Yl4&E}FSE#$N z9UEzB40+_wE@B#MBT_8$r71|u07c?eVVp+b+#kJsDc0dn?ZvCO$&J(4lZzWPTiA|; zn`X!7zkAPIyyK14Bdm&|(P@;iZqz47U%8^7M=nmoNmw$+z4&+qP+F#;7=F=dERDA^ zn$sM4=@PbLA6~E?hGP!m;cVy-Z$%2G6->hj_T_NAU=1eo#AEP0c-S-#+sE_4gUCR1 zrI>6W+dInt0f`anAPjGgxcyW6Riw zIf(Q>d&WQho69pnO$QR!jUqbe0StIv!^7BAtaSA6R&n9vIYR`!Z6-QlF@E%IktU-;~izqn-Y!zUx#?(qeX2x?`MDC3c(v9zwCX7@h&8Blxll`8?p8*4^51LO1* zot)poiO~R4BhvMw&;)`qjtPuoAJr;H1rO--@DDx*B#??Ff3bc#LN+{Hc-)&`o)Z1M zazzl22)H-vfjFL`E@aiu@J$TD4y^sFe_!|UUw=`kfSKZs?8W77ti)&$3?7h{0k|V` zat2u=)O6cSe2J}eK3xqNIv#kA6b1P>G;(u#JxV-q!vu61Jd90siC7u{L4(Y}w~$Iq zGlxNJ%QRL&RIJ3zkTK_AUoI5IdPp3R){X?zV^c8#C_Vhb`S^vr->5Ri|LOuZVJjmB z6PW46^0*e34j!1mrg4ppvl(jas5~+kM>_EPr$>#q%s>R>3AZu`NgTR;{WNsXG4Rvs zIOae5;1aGs+-zVgUlUb^phKO-K9T4;>JpeVIp5`CXo&eR;>`f2;W zajNFS7sNw$zGtq!$bDD?d*P&k!L?I)y6fJ#66Q}YI{wY8MmR3+?dZ5S2gf2jLX}b- zzbu^ab4B2Wvw>`uFw*4=$R{L1Z_k~}p9me+s5&*~i;#$fxW?Rs`{&Oipm5KG1l0!? z$uXdZEBOc_A)?6uR~Q6v4dKBc{Z`Eon80$G0LoB*gt=`dYlDYQ-Qt01NWsjIF$)U` zCh*Iuio}&ThMzvNl;uz+_aQRuAgd-oJ-vd(SRzpm4z3ag4>j1KlDK#L6p|dDA3Qv? zL~yHyWJVR!T)aY_a4WBQD(M?|jQDZ#EsMDlZE@j8mI8fbE4n_y8TOJdZA`w@@eoI< z41_m?1Vp{0V6X|DiTY|&Ch(S!$tDpg$gEPbwX$M9R_eSWPitScEh<=TB#^#%A!adO zLN>Ny33aGq3Y)4{^oSUr{_C}*FGz*4;~+J_x}q{C!3umg&X&4Efuv7c7Mm|6MpjAm z&NyF$e(v1l4R_B;zI0>DmjDA7H!ub6!%!AY3dizr1dlkDzMxkN354Ml%dwUbEF>Tw zG7j}KSz5>u>sI{o7K6BX;&g8`SYTKv80DMr7G%pNXSBuxRkkv`9Q-14psvS z^N|M$*&)n_!3h)So1+_}Sd7;O*`#(=jb?2%(X9*>>7QO9Rfz|+%s8Y%RK#Psdg#07 z7$M{Ik1gYMqF|*hL{doffk%s$V*CtsZk%lrG$e1-_K1XUR%ZCM-& zTstBog}^-nPxEf`Lbftm@+Z$3s>VzY6M+a>@)YY?bJTokImj~e<0MQ&JP0NLR3u(7 z&h&$Q&bH}$CA*f6w9R*3*;$vHfg{5Vf|`<59=bT%(cmRt?OlVYG(vxoupk_oaf zqO)fL?D%{&+3;Wp)I*JyNiwT)*hC*mjIAkKBV&$_UzkTDoB5J>z~m?ZA?3_4UwG-M zGkC-r>}axWLSqh!n{g8HkVC6b=^np8Bx80m=9;4^JqC#{v4en~D4KErLq9f>4m%!L zF>xCAW==}3EsJFkt!o0pKH|Xuz)_R)fgvsqr(Ic$39_4B*lMt`sbM}IAsH4x_fnNC zsGB4vY+jfURWt6!e7u%%dud=PXb@8$@>RUm#9ItFR956lKp=0Zq-f%uj4X9VP1~8x zXe$|B$LDL>*f~>1oH)ZHOOc2B;GxE{46O=~5Lj`jc&*uAE2+n(CP#bf3>Df7GF-um zpmgZ)g3(DjYtheqk*TGPosI5QqNR%oEX&JWIq0T&=JirZG0+>BS&u9QdSjfat5l+I zYr7)wB(Ls5JhArEM?x@_7J|5l@tw2qi-5SM!a6DW5*M3TDH_X@!o@%nkHjvEA&C)) zZBalFTiGdeZxl7)Cf_05sAjgKVmXSa79TMjFPNw9jKl(!g#|Zq;_zH4WXWcb9wh>6 ze$~SO4-k6=kmB(wgM7(?{Go>>pnEf&>C?B71PaqCY2H(^_Q4^7>uRW88S(Et;~0|KA}5f^)} z9kEEs1kaQ}S`$8_fz%`(!RFhz;2?hwz;M@|W8*FR0ap%q!V;lW(NgqW>ZPs-`M z7$U8nR`gRQ@S2ru5pX^&rQYNl)g3Lx^;hRYFt$d6ra$7_(;J6ax5(JqKPlYTPj22S z9@dW7aFJ&tk}U|^Gq!Ye(uRlCBbWk{nY-uE@)AKHNmV4*%? zt!o%tlV8--!&H-nm>dN{#=xyreK)q=oIH!|ku!eU@o?MBB)VDYfki#tH2pz<&ahHe zgX`AQ6XQSvp_bX|DtMSEb;X16GUYyWuX`pVt5Ku(TzVqN9NwC}20*$1o63Yn14+N< z4ZJe=CdP@zcyi4iO@dPx*95$uzUuwKE)EOLO!QgIJLKb{`pvP@VOiZ; zDrv8*4jwG24L>1cruOXGc7&XO^uc;nC}W^T&r=lLVnqM5ZES&Qlo1cIbu>S!)DP1~-Dt2~`Q%~&#l|AeUUPaLS-8dtHIW5bTkg9i?Jpf;fd zp$h1DNaJhsLMGVnXaGtLUJFr+BORNCw18gNJCP{|bW&3hDGV(oG}bPN@zQ2(s1jkU zE?HjRG#1*oG@a{sNcw|cNEWOo*)%*DmPyZCaP`DLm?A9q`S3lRPHxLwm8B#2#JqKyR6lm zkH1kCXbLse^e6p1%I)gy=8P6}!RG3b;@5&?^it~Tkq+pFhs&ZL{XY}@mLLsw1No;K zGsR7+P`RU3iaq&~;yHu%l3m1u303KK@wN6s03FFxsyA%7ic!9|GVwgCP=l343fi15Qk>8Ddj%;vXU zMQF_WE{4 zFgkf1+N^yR#-KVnD!~KAS`u_q`?Vu2-KBng=4{p93ZS}5dvg4GQa*VxH$><_b2CMTqJb z&<22}C0)&8#Q4{iuhQGT^)NYf&@-_$MwE_Rh~EPf9~eY=(Gm0(P3xC5@zwhc=n!QF z4@^kfR{ME&6HHIK1XaHpH9K%bkZHu{h2Kpq0s8k>5uXy@{9pJgz0G=xAsnG) zgw>1l6^!(UcRkI~SS-vt_?+IJ9p;XQbk=26UZ=8}(3lx!s|HQ5YKolfp6xI*-8yvV z*7At%t;zc)iE&EL@_zbgA8aRD=TeS!TPwidxM~U?KVSReiQK%tW`v9H#@lb6v6H;& z$z|`{nJ)mLv!|9He)0TW4=yUNUUC8-dw9*D*H>j4uXjJZaU$pc(mj8SuDoIK5oLpx2~DW zJ);@K4Qn|$?5)K7@`z=Sfh7>YvvKic{~w&;fWkj0c&Y0YU{zjo(>0d$He{6~YZD4p_`(AG^U*7pu${~6PC9AkR3k)h zYev{Ghwkdv3%uBt*TMt6>8eOE2@hQT=xocL*bCYC6X(Sm=&;}vjEnQ}sjTjXnb8l{ z&4j!7?mS)nYWr%3P4hVZzNb%f4)U;)?%;_%Si?i;=+>FMb_7occ&H959@tid#JySA ztvydaamNEg_ikM#NGcx2Mm?@B&CLIg2baqPrDR`$t4GB#>k&1grcl&Lc#u8<(W*-4 zU?RLr3l8C-I*bbFc+fIv0zh*Hlo^OJfxGzgy5ND=TppnF8fFm>%?^y<4@5@+++Y*L z@J~HLEjPoVP)UkM2%5?FFT@e>Z7d^>6_~dGv%p`-E$6VFrr-&lgY8|_2?z{$8Xlm^ zY_+N>-u1eP1`4=qPVm4#AHIA6C+lc*H)*^%eBCNBPCX3pPz~3q$qOlzIfzqeE^WzZ zB;;aS_CyDa<`)HUq)ZSGVoEPSdS0UtC+x6Ia@7>i)6Re)x#S35<9tkDv@Y$X^A?n) zy>ysk@ZcbIsymmcuX=!^rpsS?QYR37K1$NjVJ<-1Wf2 zJtNeQreqcTSIo2>7{MuxCP*KPZki{R@X7-Sud3D!v&2_K#}V$Cn}AfOVQ(e$O6a(M zVezRt^*8_D)y*@4<0qF5@UUitw>&8khS$%YnXOi}xF&|WbyWjb@SrLW|L{D{)Pl`K zDx%VuqYDe`(!8yrKEhP-26(7;)DD9khVc+2RG;A;drByX&9CkhJm}$O9L5{op%5pi z;vRe>lImxWWN5Cz1o5B?cV!f{!KSKf7!N&~nY8dEt|1cGL{jP@bQljj0f5*vnAQzL zdmCm6NE3)-@Sw(`C7r%guUdyH#r`lJWS~iS&|wUU9GW>2iZON)9t419@)-W9W$?F9 z#D?S}!2@^bQGRDJ(>tT184DXu!b8t0V>0sFtx1S==AG#+XCL0WP%*g`4}!r1;K`UW z>GA{~vM#v>3O19B`YTiDf^21iCDDrq4%6^pSQ&PK9aF$vb*PSIF4P%CH|c)K6GYIU z#WY1TcZedrjOGOGAWjB&7|tq*`0m`(SgnzO()ZQRRlho5j=J}po~q$N$ZJ}c)Sxcx z0ZgT02h&>l(4eo6$P^xL5*~PAYR)nVHUPTj``TCn*Y+`7rxO`Abh0VQ(eM0ILI&AUyl8P!ad+Y?KdmEF`elaYhuUkui9#n_%pean;26*Td zf)$~mRt37P8lQ}Zid~jK@pz&8B%P} zH?~GJw88+8X&$EM=f#2% zB}n(fcn~_hjMBaZ12xE3-|k8HF?di>$y>#PCBUGhxo?3HzT?3xC7lx%>t#rD()H6R z6IqY7hVc*`r0^TUgVD(X1`IK$aoz+N26*W05do;NO>V>Ol_I3wVjg4Z6iTcqvUo5h z&=n@(!DXU{hnHYilbF`HqWM;{T=UfI(6ynWv~g>-RFCX<(7}r7Z_D;8P^B${P)~ZD zkh~Sc8CpzQJ05y)aK5dPh6nyo>-v(r8RRv*oglfibk8#f4A^Ui*%4>22<>UphKJrB zX;pEpuZ)~@*HB&OvZ9%L?Pf7;>&7`~R)x0KV~=RPcPiE#ZGau%0mGpskJuZm9S^gRAE~A&ioPNAX1-L;?0_C!CA=NhQSBmg>#b9OEfP>nF?fUJdrM2Hg z2dj!`7zCL*vN`Al|0&TPd&TAv_Y0razsFV&K}QK#q!PaFa09HHbwEI=*Ju}|*Zj0(tzuLGp z_t^nV_QI=mSC7HNL?zXtXbN?kXJakv_V*Y(SOVh*#Xc|R!^RRvYs!s{4&#B}bUA61 zvv$M7y3yW{LNh5LHqGlk-}JdZj0d?&a89)=SI@eu#5(i%s40oB}F zcS;8I;3Cm%t!|FhYIyJ&M~pgy)z=mum(1Fdl4+dKh<(u3ox;S2{$|_&sa3!r;=e*&Icq)84Kx zo%@;7o3)11UfXm$M6Hl`uP6BWHwh0zfmE3jc5UVf7bAm)?+wFVaKsN@Jiqkv3G51* z_R(et58kkR0MzjycCDL^{OCeUh+g`zCnip%I0+A&p?<_lz-CV2OvWijIfjI?mLpm1Rbn;qRI~LF*IH y1i?;C|Ni3{ZDCZwqV0000x^}o?S6z`gyX$)WbxVh$a z@6WI8h%okaF4W?xpQ13b*yDC1W6feKGtnw_&)wnb#jl@5fc_5pTB&I`_FI;`x6ZnZ zdFs?_d&&dUN^UKuVR*{R=mcT$kkP@smeI_~doA7dMG2U3ncT>$(e|^o z7O%|rlSAu2rc0P@Y*@B_^~b!tR#AFwU$fF}zdP&D_J(JQGr$I>WtW&OOr@xLie0m* z(Y5BX^68HDFp)V;t#>jehbzzXT`xr2oocPVXqx|Hh zxGxKjSQk&AZykfP7$FoJ^CiWU7ZyzKqH!$$QgPqQj-yD4awLZ+*UdsX6LFOv^%_%C zhrfn)gJ)7*n!q|@5{C+!YmSf&gkANxH2ovdVsL<^!2x2%GJ$wuX$Cv~YSeCXKAM}I zA=|C%voJB01k0zYTmHL@LB*w?@MBHacPtbMiT|1TVu&e7m=mDB6kDfvn^KX}d9EPYrxjsPGh;HxK7G&simF2Smc%*7;q zm`c+qdLGBBkdUgcsmWoZRFg$kb(IxiVtTBqwD;A zQW2tXd}qyt&(8Og8eX9G3iT-+MAzAt>OS>WEw!jlwtn~ZckgE~rf7ZyEh5yIO5?9R zIyZu@pF3rPkyo)!N`lVK3tLSeu}gV?c-2qFLWF<_H^A8?ANTC*1;xVT>p3{dgFxOH z_g3(FfHJM0x2IEeg$J3=onW~nfuSL!^PNo^wB=Vp7!oKO0Rz(*4Fs=ebh~$UZY8^o z@pqg+_h5%~JxQiC!M>EUohMg>y@r!)%f~7Vt<^sA`*CH)T9Hy(>}2%6sVnKOAqvH@G|M zfG}eG4S$%L5fP#PF&=7)%32-z?Aio&l(93Q=l5kUkD^0dSq-=S(aAJ0-s8DiK%cZ> zW;pv~^pfP^(pvsgyQQ?6esr5t^e+&Trrer9s@}>J2TKx53zQkJZU?FGy}O}{IHC3@ zf*fLKvkQSCckuXb4}|#?`i7=zf3jghxlmS9)($h7!7;LLAy%ih9mGneB=_l+QVp1r zUt0!rvasNo$bh4W?@>|>ao}4o1yWZsPDmId7d28KVjP37Ug-=%_hymU&sdXPZm-lTvHNjupP~-5^#4<+lz&C{CV@sxvU#3X-W>1WvWgOhlJH#WJ-)B_5mnz6(Nr@hCrW|8DK&EL!s__dF6<(Bx-?%Y52mW6!9U$%VgQgoU z#KGQ|qhyR=$Hf=3TU*4+-?Q!rwaA{0at4m;ut+rQ;P+Ka2XXoQt%t6kVjzdGRH*Vq zhy*Nk=5AZGGv(P6vTL_|a1X`r#f1q81CuyUQ=A@7h78pnauSKqN>AwA2>6h3&lV|3 z10x!`q~z)jt8i7(RXQwHJ6B)_Ch`CX~Eubq_wPRRspt)U7c!RVPn8NvqB|&ra&S z2s9Viu~5APyS+*t0NI|6E95KnTp>x@S7?o*({Fy=XB)yMHM+D)XhlDTo({25Z`WzL zdg$Bty1}QU5%Pzj?~3tFvuFd{LxR@du*#}vx^it$fm%SdOu7{;KRC!Yy82|%y#sur zd0IJBl^FyDkl(OS?o!x4)cNcW{4h11ivLq}KSbQtB>wc(<`iiK$-;SIP4`g#t65|2 z%TXx07fEr6GT;&<1_L|aoh$&8S2M*1{+Re%b!+JsHp&FJc^BA{Dm&h3jke2V6^gED znY%8ViR6Hu#X7#|QturhTexkl!5d3+1KFQCJ2%tu3!B4!&ttRO zm*k8tMQ-~Au2wjkOD_H^E5F&7wmthYH;S9REO}8qf;|oUh#h%zAW!P>`P@5qj3pbZ zs={xFZEUPJfIZJzFJ)2PR%uh235SNiw>XKPj=}6-Lujod%Fp8|4u5F>L~z3h#P`nk z@%?h+X!%X!QFIY`%Syno)@yRg23dDEg0aAP%M+FHkg>l2;WEN(33An{Xa`eO9VmP< z@Nul{+vIyiEL6#x8Rv1nraw;9vLwhawPgf-R=~mDXLSL^HiTD0%`vUtF)43RbQ5YGL*Hp`M7ifhB3UO6B!`%pR`8qm)nT2z-CdX} zb@x${uXeIT9qnRu2}HVUe~MC;L#%;V#m5+(QFOl1?#2PJ+m?6QuHUI3|J_4Wjr(ap zuM3ir=B3Pmj|>9P8rH6fSXCP>nfs&O; zq#g`RBtb8nzrSS14iJDPYL_t!g^nos4ARCVU@Olz*$HNoT1QL|3~9jmB2*rb0K2a9 zUUos`2HoIx5mj2PzQxc6_5OLJ1*7y ztK{|AOkknHyaQb+o&X|>E@gW+41iBN0);tR<-<%I&ZbOQa*GILkyTn`Jkx!imIW=quz5vtKn zQpo1A!&N75OAn3M!RpaLheTVngvsTyHzf=-Z1q8tAo@Y)L<&TaS64@}{JapB9v8TR z<P(6@gNe0Z3|r3C2p%CVL2sHHDt1k-m%{>2xn-p}@4CrRZ_Wv_kZqRzffI7g(wP2(vq54#+Z1!3>{ zzr64%y8bbmiW0duAKR2$CH-s>Rf7_-jMnX?PNEBSY=?{cW2>FN&!2&xHym}1q91#r z^l|Tgm;F{(`MNJU=oRug%*;3njg|#bgzriOZb>FXVLp+fu$9jYdB0Enj$NMbwY~=i z2Png)H${>dcDXesK3Zy_- zacufE_us@sY#V6vauKy!owVjMbxAA?%cZ8W;vp+Vci7>g=L1N5Wm)}hl`W$6%C0s1 zyb7Nk7m!3f`+cnoi5a#W-Sr}W*)X|Z8y@pJ6>Z#~b8 z6W*iM?B#hF2&E_Ks9bD06|4;lOl`X(%<)k+>E_cj>?Vb2V0kYApS|jNE>~J_h9@j% z933*)s19BZ)&B8&1Z}M^^><`M11YE_>_OxZ_ z$IJhm`Dot%pPNBUf-K^jMrpo;ATZE(l`9JqJ15cg`6D-KsYAY*kSI^mCoVPZpGqmD zb$+*o{;v}W_vxs&72{2v^Set&`0$N3n6S!ruu{M`d7H(GYXoOsC; zN9u~y@{h!Qi@#|YbaZ)IneV~h><*sE5JE)Cci!%qJ!z3$$`2Eluqmj?J%$_GO`zZ! z3*~69y6mfmSkhH{ z11QZPEfL#zhea9+i;;$}@>zsW)tO!+(C3SB`Qd?mR(1TagG8qO82KQ06rrN}QOxHO zmJmn9zZul2td4BF6M=0Hvp2mv@!M8QU03FrKuLUADhkor=T9ZCcY{5$1YkPETqoASoL20bbG}>_ zkC{n4IW1nf zUEXyYIMcYQvdg%;48AujmU&fD9j_^gGH3JZL<(f{Md6HY&^bsRp_V7xi&*cij9*A> z3FZ*A7E$_F>P;4+tUay=jO84F`o&7?4TTR*3-)b?5&!|8Oz3!clP`Sw{{It95IEK* zgK-XJlLVJuno!5F8j24K+apHMkcgKt)rml%-FSEwSzr)#Y8mLz9qRacquonw=SR^G zP?_ZyFmblLY7u=35!K|A2}u?`&Z^-OwOekMX-OW{9YdRX9DD^zIW3?}l2f2__6_|R z(2ES^fJ?}NenXDnBkiDD-QcA++GDA8II5Qb{#Lm0saI=_pd3%Fz?$SD$@DY0srzJC9Enj`&napgLhC^`E-CVmwYEKy?;hM2-R+=B@5w zm&lPM;4PRczj#m$eowvSEgm+3LaS>+-eFdOagFMz%Nt1-WVXuEIMb#|ydY1#UvTl<_c@dr zlGS%-5#vBst&QEuHBK}B>2f8x?BezvceO&w&B-YDnMV4?*3FWuK)emZ^>YItc4Ix zJ=TCD^@%}ZiblXsUPb=zlI2@WP`esTv@yj@<}R$Y+elw})Lx3dg&9HK$nvVhTl40>qX;qPrI>L*z7KVsf;JunHm;S4-m-_eGB9U5bmA1*Onm42p91t6ot?!a z2Sq247Zh{C5Ucvmj=q>9#&oeB?bW*Rirvp Date: Sun, 25 Jun 2023 02:21:16 +0700 Subject: [PATCH 0651/1199] Bump forge to 47.0.19 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 5840466ca..51c3d1606 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,7 +17,7 @@ jei_mc_version=1.20 curios_mc_version=1.20 forge_gradle_version=[6.0,6.2) -forge_version=47.0.4 +forge_version=47.0.19 mixingradle_version=0.7.33 mixin_version=0.8.5 From 064866748042d34c826533846ce0c7f6a4f49697 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 25 Jun 2023 10:54:19 +0700 Subject: [PATCH 0652/1199] Revert "Forge seemingly removed its lootpool deserializer patches" This reverts commit 926b9a2a1708c1b572fd7c223df6a955608bc3da. --- .../mc/otm/data/loot/LootPoolAppender.kt | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt index 9f1ff7ec8..1b473af22 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt @@ -43,14 +43,35 @@ class LootPoolAppender(conditions: Array, pools: Stream> + private val forgeHooksLootContext by lazy { + val field = ForgeHooks::class.java.getDeclaredField("lootContext") + field.isAccessible = true + field + } + + private val lootTableContextConstructor by lazy { + val clazz = ForgeHooks::class.java.declaredClasses.firstOrNull { it.name.contains("LootTableContext") } ?: throw NoSuchElementException("Unable to find ForgeHooks\$LootTableContext!") + val constructor = clazz.getDeclaredConstructor(ResourceLocation::class.java, Boolean::class.java) + constructor.isAccessible = true + constructor + } + init { val serializer = Deserializers.createLootTableSerializer().create() + val notExistingLocation = ResourceLocation("null", "null") lootPoolCodec = Codec.list(Codec.PASSTHROUGH.flatXmap({ + val dequeueHolder = forgeHooksLootContext.get(null) as ThreadLocal> + val deque = dequeueHolder.get() ?: java.util.ArrayDeque() + dequeueHolder.set(deque) + try { + deque.push(lootTableContextConstructor.newInstance(notExistingLocation, true)) DataResult.success(serializer.fromJson(it.convert(JsonOps.INSTANCE).value, LootPool::class.java)) } catch(err: JsonSyntaxException) { DataResult.error { err.message } + } finally { + deque.pop() } }, { try { From bc340cc317539fa54cc6fdac6af83589ef16de6d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 25 Jun 2023 20:55:13 +0700 Subject: [PATCH 0653/1199] =?UTF-8?q?YuRaNnNzZZ=20=E2=80=94=20=D0=A1=D0=B5?= =?UTF-8?q?=D0=B3=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=2018:27=20thanks=20dir?= =?UTF-8?q?ewolf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index ea34a8d46..77822466f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -559,8 +559,8 @@ object MatterManager { width = it.recipeWidth height = it.recipeHeight } else { - width = it.ingredients.size - height = 1 + width = 3 + height = 3 } val container = TransientCraftingContainer(object : AbstractContainerMenu(null, 0) { From 7eaab24f9daea84bf2c99e85b3e6e7b897051e3d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 25 Jun 2023 20:55:13 +0700 Subject: [PATCH 0654/1199] =?UTF-8?q?YuRaNnNzZZ=20=E2=80=94=20=D0=A1=D0=B5?= =?UTF-8?q?=D0=B3=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=2018:27=20thanks=20dir?= =?UTF-8?q?ewolf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 77822466f..59cd19849 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -552,8 +552,8 @@ object MatterManager { if (resultItem.isEmpty) { null } else { - val width: Int - val height: Int + var width: Int + var height: Int if (it is IShapedRecipe<*>) { width = it.recipeWidth @@ -563,6 +563,11 @@ object MatterManager { height = 3 } + if (width * height < it.ingredients.size) { + width = it.ingredients.size.coerceAtLeast(width) + height = it.ingredients.size.coerceAtLeast(height) + } + val container = TransientCraftingContainer(object : AbstractContainerMenu(null, 0) { override fun quickMoveStack(pPlayer: Player, pIndex: Int): ItemStack { return ItemStack.EMPTY From 6a283bafe992f3b59fd8f5f1f919471accbd58b2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 25 Jun 2023 21:04:29 +0700 Subject: [PATCH 0655/1199] Make datapack registries not persistent because they don't need to --- .../dbotthepony/mc/otm/android/AndroidResearchDescription.kt | 4 +++- .../ru/dbotthepony/mc/otm/android/AndroidResearchResult.kt | 4 +++- src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalProvider.kt | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDescription.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDescription.kt index 1a5c51867..7e5d420e6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDescription.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDescription.kt @@ -90,7 +90,9 @@ interface AndroidResearchDescription { val type: Type<*> companion object { - private val delegate = RegistryDelegate>("android_research_description") + private val delegate = RegistryDelegate>("android_research_description") { + disableSaving() + } val registry by delegate val registryKey get() = delegate.key diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchResult.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchResult.kt index 8dfa6821d..06f430dd2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchResult.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchResult.kt @@ -164,7 +164,9 @@ interface AndroidResearchResult { companion object { private val LOGGER = LogManager.getLogger() - private val delegate = RegistryDelegate>("android_research_result") + private val delegate = RegistryDelegate>("android_research_result") { + disableSaving() + } val registry by delegate val registryKey get() = delegate.key diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalProvider.kt index 172e6b07e..1143aac1f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalProvider.kt @@ -28,6 +28,7 @@ abstract class DecimalProvider : SampledDecimal { companion object { private val registryHolder = RegistryDelegate>("decimal_provider_type") { setDefaultKey(ResourceLocation(OverdriveThatMatters.MOD_ID, "zero")) + disableSaving() } val CODEC: Codec by lazy { From 8dd332a2e16bcd9e72a82c4df0e29d8c50768c2d Mon Sep 17 00:00:00 2001 From: GearShocky Date: Mon, 26 Jun 2023 01:55:29 +0600 Subject: [PATCH 0656/1199] Plate press 2 --- .../mc/otm/datagen/blocks/BlockStates.kt | 1 + .../mc/otm/datagen/items/ItemModels.kt | 1 + .../models/block/plate_press_error.json | 367 ++++++++-------- .../models/block/plate_press_idle.json | 391 ++++++++++-------- .../models/block/plate_press_working.json | 371 +++++++++-------- .../models/block/twin_plate_press_error.json | 291 +++++++++++++ .../models/block/twin_plate_press_idle.json | 315 ++++++++++++++ .../block/twin_plate_press_working.json | 293 +++++++++++++ .../textures/block/piston_offset.png | Bin 0 -> 633 bytes .../textures/block/piston_offset.png.mcmeta | 1 + .../textures/block/plate_press2.png | Bin 0 -> 717 bytes .../textures/block/plate_press_piston.png | Bin 621 -> 633 bytes 12 files changed, 1516 insertions(+), 515 deletions(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/twin_plate_press_error.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/twin_plate_press_idle.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/twin_plate_press_working.json create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/piston_offset.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/piston_offset.png.mcmeta create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/plate_press2.png diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt index f985ac4e1..6c0672fec 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt @@ -80,6 +80,7 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { provider.block(MBlocks.MATTER_DECOMPOSER) provider.block(MBlocks.MATTER_REPLICATOR) provider.block(MBlocks.PLATE_PRESS) + provider.block(MBlocks.TWIN_PLATE_PRESS) provider.block(MBlocks.GRAVITATION_STABILIZER) provider.block(MBlocks.GRAVITATION_STABILIZER_LENS) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index 874a4d749..3686becd2 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -128,6 +128,7 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.block(MItems.MATTER_RECONSTRUCTOR, "matter_reconstructor") provider.block(MItems.PLATE_PRESS, "plate_press_idle") + provider.block(MItems.TWIN_PLATE_PRESS, "twin_plate_press_idle") provider.block(MItems.STORAGE_POWER_SUPPLIER, "storage_power_supplier") provider.block(MItems.MATTER_RECYCLER, "matter_recycler_working") provider.block(MItems.COBBLESTONE_GENERATOR, "cobblestone_generator") diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/plate_press_error.json b/src/main/resources/assets/overdrive_that_matters/models/block/plate_press_error.json index b28894a7f..f94bc7c12 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/plate_press_error.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/plate_press_error.json @@ -1,218 +1,243 @@ { - "parent" : "block/block", + "credit": "Made with Blockbench", + "texture_size": [64, 32], "textures": { - "particle": "overdrive_that_matters:block/plate_press", - "body": "overdrive_that_matters:block/plate_press" + "0": "overdrive_that_matters:block/plate_press2", + "particle": "overdrive_that_matters:block/plate_press2" }, "elements": [ { - "name": "body", - "from": [0, 0, 0], - "to": [16, 8, 16], + "from": [10, 0, 0], + "to": [16, 6, 16], "faces": { - "north": {"uv": [0, 4, 4, 8], "texture": "#body"}, - "east": {"uv": [12, 4, 16, 8], "texture": "#body"}, - "south": {"uv": [4, 4, 8, 8], "texture": "#body"}, - "west": {"uv": [8, 4, 12, 8], "texture": "#body"}, - "up": {"uv": [4, 8, 8, 16], "texture": "#body"}, - "down": {"uv": [0, 8, 4, 16], "texture": "#body"} + "north": {"uv": [5.5, 13, 7, 16], "texture": "#0"}, + "east": {"uv": [1.5, 13, 5.5, 16], "texture": "#0"}, + "south": {"uv": [7, 13, 8.5, 16], "texture": "#0"}, + "west": {"uv": [5.5, 13, 1.5, 16], "texture": "#0"}, + "up": {"uv": [0, 8, 1.5, 16], "texture": "#0"}, + "down": {"uv": [0, 8, 1.5, 16], "texture": "#0"} } }, { - "name": "body", - "from": [0, 8, 7], - "to": [16, 12, 16], + "from": [10, 10, 0], + "to": [16, 16, 16], "faces": { - "north": {"uv": [4, 12, 8, 14], "texture": "#body"}, - "east": {"uv": [12, 2, 14.25, 4], "texture": "#body"}, - "south": {"uv": [4, 2, 8, 4], "texture": "#body"}, - "west": {"uv": [9.75, 2, 12, 4], "texture": "#body"}, - "up": {"uv": [4, 12, 8, 16], "texture": "#body"}, - "down": {"uv": [0, 0, 16, 9], "texture": "#missing"} + "north": {"uv": [5.5, 8, 7, 11], "texture": "#0"}, + "east": {"uv": [1.5, 8, 5.5, 11], "texture": "#0"}, + "south": {"uv": [7, 8, 8.5, 11], "texture": "#0"}, + "west": {"uv": [5.5, 8, 1.5, 11], "texture": "#0"}, + "up": {"uv": [0, 5, 4, 8], "rotation": 90, "texture": "#0"}, + "down": {"uv": [0, 8, 1.5, 16], "texture": "#0"} } }, { - "name": "body", - "from": [12, 8, 1], - "to": [16, 12, 7], + "from": [10, 6, 2], + "to": [16, 10, 16], "faces": { - "north": {"uv": [13.25, 0, 14.25, 2], "texture": "#body"}, - "east": {"uv": [14.25, 2, 15.75, 4], "texture": "#body"}, - "south": {"uv": [0, 0, 4, 4], "texture": "#missing"}, - "west": {"uv": [15.75, 2, 14.25, 4], "texture": "#body"}, - "up": {"uv": [14.25, 0, 15.75, 2], "rotation": 270, "texture": "#body"}, - "down": {"uv": [0, 0, 4, 6], "texture": "#missing"} + "north": {"uv": [5.5, 11, 7, 13], "texture": "#0"}, + "east": {"uv": [1.5, 11, 5, 13], "texture": "#0"}, + "south": {"uv": [7, 11, 8.5, 13], "texture": "#0"}, + "west": {"uv": [5, 11, 1.5, 13], "texture": "#0"} } }, { - "name": "press", - "from": [2, 8, 4], - "to": [11, 16, 13], + "from": [11, 6, 1], + "to": [15, 10, 2], "faces": { - "north": {"uv": [8.1, 8, 10.25, 12], "texture": "#body"}, - "east": {"uv": [10.25, 8, 12.5, 12], "texture": "#body"}, - "south": {"uv": [8, 12, 10.25, 16], "texture": "#body"}, - "west": {"uv": [10.25, 8, 12.5, 12], "texture": "#body"}, - "up": {"uv": [12.5, 8, 14.75, 12.5], "texture": "#body"}, - "down": {"uv": [0, 0, 9, 9], "texture": "#missing"} - } - }, - { - "name": "screenholder", - "from": [13, 8, 0], - "to": [15, 12, 1], - "faces": { - "north": {"uv": [4, 0, 4.5, 2], "texture": "#body"}, - "east": {"uv": [4.25, 0, 4.5, 2], "texture": "#body"}, - "south": {"uv": [0, 0, 2, 4], "texture": "#missing"}, - "west": {"uv": [4, 0, 4.25, 2], "texture": "#body"}, - "up": {"uv": [4, 0, 4.5, 0.5], "texture": "#body"}, - "down": {"uv": [0, 0, 2, 1], "texture": "#missing"} - } - }, - { - "name": "frame", - "from": [15, 12, 15], - "to": [16, 14, 16], - "faces": { - "north": {"uv": [8.25, 0, 8.5, 1], "texture": "#body"}, - "east": {"uv": [8.25, 0, 8.5, 1], "texture": "#body"}, - "south": {"uv": [8.25, 0, 8.5, 1], "texture": "#body"}, - "west": {"uv": [8.25, 0, 8.5, 1], "texture": "#body"}, - "up": {"uv": [8.25, 0, 8.5, 0.5], "texture": "#body"}, - "down": {"uv": [0, 0, 1, 1], "texture": "#missing"} - } - }, - { - "name": "frame", - "from": [0, 12, 15], - "to": [1, 14, 16], - "faces": { - "north": {"uv": [8.25, 0, 8.5, 1], "texture": "#body"}, - "east": {"uv": [8.25, 0, 8.5, 1], "texture": "#body"}, - "south": {"uv": [8.25, 0, 8.5, 1], "texture": "#body"}, - "west": {"uv": [8.25, 0, 8.5, 1], "texture": "#body"}, - "up": {"uv": [8.25, 0, 8.5, 0.5], "texture": "#body"}, - "down": {"uv": [0, 0, 1, 1], "texture": "#missing"} - } - }, - { - "name": "frame", - "from": [0.3, 13, 1], - "to": [0.8, 14, 15], - "faces": { - "north": {"uv": [0, 0, 0.5, 1], "texture": "#missing"}, - "east": {"uv": [0, 2.5, 3.75, 3], "texture": "#body"}, - "south": {"uv": [0, 0, 0.5, 1], "texture": "#missing"}, - "west": {"uv": [0, 2.5, 3.75, 3], "texture": "#body"}, - "up": {"uv": [0, 2.5, 3.75, 3], "rotation": 90, "texture": "#body"}, - "down": {"uv": [0, 2.5, 3.75, 3], "rotation": 90, "texture": "#body"} - } - }, - { - "name": "frame", - "from": [0, 8, 0], - "to": [1, 14, 1], - "faces": { - "north": {"uv": [8.25, 0, 8.5, 3], "texture": "#body"}, - "east": {"uv": [8.25, 0, 8.5, 3], "texture": "#body"}, - "south": {"uv": [8.25, 0, 8.5, 3], "texture": "#body"}, - "west": {"uv": [8.25, 0, 8.5, 3], "texture": "#body"}, - "up": {"uv": [8.25, 0, 8.5, 0.5], "texture": "#body"}, - "down": {"uv": [0, 0, 1, 1], "texture": "#missing"} - } - }, - { - "name": "frame", - "from": [1, 13, 15.2], - "to": [15, 14, 15.7], - "faces": { - "north": {"uv": [0, 2.5, 3.75, 3], "texture": "#body"}, - "east": {"uv": [0, 0, 0.5, 1], "texture": "#missing"}, - "south": {"uv": [0, 2.5, 3.75, 3], "texture": "#body"}, - "west": {"uv": [0, 0, 0.5, 1], "texture": "#missing"}, - "up": {"uv": [0, 2.5, 3.75, 3], "texture": "#body"}, - "down": {"uv": [0, 2.5, 3.75, 3], "texture": "#body"} + "north": {"uv": [4.25, 5, 5.25, 7], "texture": "#0"}, + "east": {"uv": [4, 5, 4.25, 7], "texture": "#0"}, + "west": {"uv": [5, 5, 5.25, 7], "texture": "#0"}, + "up": {"uv": [0, 0, 1, 0.5], "texture": "#missing"} } }, { "name": "screen", - "from": [12, 10, 0], - "to": [16, 14, 1], + "from": [11, 4, 2], + "to": [15, 8, 3], "rotation": {"angle": 22.5, "axis": "x", "origin": [14, 13, -0.5]}, "faces": { - "north": {"uv": [2, 0, 3, 2], "texture": "#body"}, - "east": {"uv": [3, 2, 4, 2.5], "rotation": 90, "texture": "#body"}, - "south": {"uv": [3, 0, 4, 2], "texture": "#body"}, - "west": {"uv": [3, 2, 4, 2.5], "rotation": 90, "texture": "#body"}, - "up": {"uv": [3, 2, 4, 2.5], "texture": "#body"}, - "down": {"uv": [3, 2, 4, 2.5], "texture": "#body"} + "north": {"uv": [2, 0, 3, 2], "texture": "#0"}, + "east": {"uv": [3, 2, 4, 2.5], "rotation": 90, "texture": "#0"}, + "south": {"uv": [3, 0, 4, 2], "texture": "#0"}, + "west": {"uv": [3, 2, 4, 2.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [3, 2, 4, 2.5], "texture": "#0"}, + "down": {"uv": [3, 2, 4, 2.5], "texture": "#0"} } }, { - "name": "gaspipes", - "from": [11, 8, 9], - "to": [12, 14, 12], + "from": [1, 8, 3], + "to": [9, 15, 15], "faces": { - "north": {"uv": [9.25, 0.5, 9.5, 3.5], "texture": "#body"}, - "east": {"uv": [8.5, 0.5, 9.25, 3.5], "texture": "#body"}, - "south": {"uv": [9.25, 0.5, 9.5, 3.5], "texture": "#body"}, - "west": {"uv": [0, 0, 0.75, 3], "texture": "#missing"}, - "up": {"uv": [8.5, 0.5, 9.25, 0], "rotation": 90, "texture": "#body"}, - "down": {"uv": [0, 0, 0.25, 1.5], "texture": "#missing"} + "north": {"uv": [8.5, 12.1, 10.5, 16], "texture": "#0"}, + "east": {"uv": [14, 12.5, 11, 16], "texture": "#0"}, + "south": {"uv": [14, 12.5, 16, 16], "texture": "#0"}, + "west": {"uv": [11, 12.5, 14, 16], "texture": "#0"}, + "up": {"uv": [8.5, 5.5, 10.5, 11.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [10.5, 5.5, 12.5, 11.5], "texture": "#0"} } }, { - "name": "gaspipes", - "from": [11, 8, 5], - "to": [12, 14, 8], + "from": [1, 0, 0], + "to": [9, 7, 16], "faces": { - "north": {"uv": [9.25, 0.5, 9.5, 3.5], "texture": "#body"}, - "east": {"uv": [8.5, 0.5, 9.25, 3.5], "texture": "#body"}, - "south": {"uv": [9.25, 0.5, 9.5, 3.5], "texture": "#body"}, - "west": {"uv": [0, 0, 0.75, 3], "texture": "#missing"}, - "up": {"uv": [8.5, 0.5, 9.25, 0], "rotation": 90, "texture": "#body"}, - "down": {"uv": [0, 0, 0.25, 1.5], "texture": "#missing"} + "north": {"uv": [8, 0, 10, 3.5], "texture": "#0"}, + "east": {"uv": [10, 0, 14, 3.5], "texture": "#0"}, + "south": {"uv": [8, 0, 10, 3.5], "texture": "#0"}, + "west": {"uv": [10, 0, 14, 3.5], "texture": "#0"}, + "up": {"uv": [14, 0, 16, 8], "texture": "#0"}, + "down": {"uv": [14, 0, 16, 8], "texture": "#0"} } }, { - "name": "gaspipes", - "from": [1, 8, 5], - "to": [2, 14, 8], + "name": "cubeframe", + "from": [9, 0, 1], + "to": [10, 16, 3], "faces": { - "north": {"uv": [9.25, 0.5, 9.5, 3.5], "texture": "#body"}, - "east": {"uv": [0, 0, 0.75, 3], "texture": "#missing"}, - "south": {"uv": [9.25, 0.5, 9.5, 3.5], "texture": "#body"}, - "west": {"uv": [8.5, 0.5, 9.25, 3.5], "texture": "#body"}, - "up": {"uv": [8.5, 0.5, 9.25, 0], "rotation": 90, "texture": "#body"}, - "down": {"uv": [0, 0, 0.25, 1.5], "texture": "#missing"} + "north": {"uv": [5.5, 0, 5.75, 8], "texture": "#0"}, + "east": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "south": {"uv": [5.75, 0, 6, 8], "texture": "#0"}, + "west": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "up": {"uv": [5, 0, 5.25, 1], "texture": "#0"}, + "down": {"uv": [5.25, 0, 5.5, 1], "texture": "#0"} } }, { - "name": "gaspipes", - "from": [1, 8, 9], - "to": [2, 14, 12], + "name": "cubeframe", + "from": [9, 0, 13], + "to": [10, 16, 15], "faces": { - "north": {"uv": [9.25, 0.5, 9.5, 3.5], "texture": "#body"}, - "east": {"uv": [0, 0, 0.75, 3], "texture": "#missing"}, - "south": {"uv": [9.25, 0.5, 9.5, 3.5], "texture": "#body"}, - "west": {"uv": [8.5, 0.5, 9.25, 3.5], "texture": "#body"}, - "up": {"uv": [8.5, 0.5, 9.25, 0], "rotation": 90, "texture": "#body"}, - "down": {"uv": [0, 0, 0.25, 1.5], "texture": "#missing"} + "north": {"uv": [5.5, 0, 5.75, 8], "texture": "#0"}, + "east": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "south": {"uv": [5.75, 0, 6, 8], "texture": "#0"}, + "west": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "up": {"uv": [5, 0, 5.25, 1], "texture": "#0"}, + "down": {"uv": [5.25, 0, 5.5, 1], "texture": "#0"} } }, { - "name": "gas", - "from": [12.4, 12, 2], - "to": [15.4, 15, 14], + "name": "cubeframe", + "from": [0, 0, 1], + "to": [1, 16, 3], "faces": { - "north": {"uv": [7.5, 0, 8.25, 1.5], "texture": "#body"}, - "east": {"uv": [4.5, 0, 7.5, 1.5], "rotation": 180, "texture": "#body"}, - "south": {"uv": [7.5, 0, 8.25, 1.5], "texture": "#body"}, - "west": {"uv": [4.5, 0, 7.5, 1.5], "texture": "#body"}, - "up": {"uv": [4.5, 0, 7.5, 1.5], "rotation": 90, "texture": "#body"}, - "down": {"uv": [0, 0, 3, 12], "texture": "#missing"} + "north": {"uv": [5.5, 0, 5.75, 8], "texture": "#0"}, + "east": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "south": {"uv": [5.75, 0, 6, 8], "texture": "#0"}, + "west": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "up": {"uv": [5, 0, 5.25, 1], "texture": "#0"}, + "down": {"uv": [5.25, 0, 5.5, 1], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [0, 0, 13], + "to": [1, 16, 15], + "faces": { + "north": {"uv": [5.5, 0, 5.75, 8], "texture": "#0"}, + "east": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "south": {"uv": [5.75, 0, 6, 8], "texture": "#0"}, + "west": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "up": {"uv": [5, 0, 5.25, 1], "texture": "#0"}, + "down": {"uv": [5.25, 0, 5.5, 1], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [9, 13, 3], + "to": [10, 15, 13], + "faces": { + "east": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [6, 1.5, 6.25, 6.5], "texture": "#0"}, + "down": {"uv": [6.25, 1.5, 6.5, 6.5], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [9, 1, 3], + "to": [10, 3, 13], + "faces": { + "east": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [6, 1.5, 6.25, 6.5], "texture": "#0"}, + "down": {"uv": [6.25, 1.5, 6.5, 6.5], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [0, 13, 3], + "to": [1, 15, 13], + "faces": { + "east": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [6, 1.5, 6.25, 6.5], "texture": "#0"}, + "down": {"uv": [6.25, 1.5, 6.5, 6.5], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [0, 1, 3], + "to": [1, 3, 13], + "faces": { + "east": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [6, 1.5, 6.25, 6.5], "texture": "#0"}, + "down": {"uv": [6.25, 1.5, 6.5, 6.5], "texture": "#0"} + } + }, + { + "from": [2, 9, -1], + "to": [8, 9, 1], + "faces": { + "up": {"uv": [0, 4, 1.5, 5], "texture": "#0"}, + "down": {"uv": [0, 4, 1.5, 5], "texture": "#0"} + } + }, + { + "from": [1, 8, 1], + "to": [9, 9, 3], + "faces": { + "north": {"uv": [8.5, 15.5, 10.5, 16], "texture": "#0"}, + "east": {"uv": [11, 15.5, 10.5, 16], "texture": "#0"}, + "west": {"uv": [10.5, 15.5, 11, 16], "texture": "#0"}, + "up": {"uv": [8.5, 11.5, 10.5, 12.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [10.5, 11.5, 12.5, 12.5], "texture": "#0"} + } + }, + { + "from": [1, 14, 1], + "to": [9, 15, 3], + "faces": { + "north": {"uv": [8.5, 12.5, 10.5, 13], "texture": "#0"}, + "east": {"uv": [11, 12.5, 10.5, 13], "texture": "#0"}, + "west": {"uv": [10.5, 13, 11, 13.5], "texture": "#0"}, + "up": {"uv": [8.5, 11.5, 10.5, 12.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [8.5, 11.5, 10.5, 12.5], "texture": "#0"} + } + }, + { + "from": [8, 9, 1], + "to": [9, 14, 3], + "faces": { + "north": {"uv": [8.5, 13, 8.75, 15.5], "texture": "#0"}, + "east": {"uv": [11, 13, 10.5, 15.5], "texture": "#0"}, + "west": {"uv": [10.5, 13, 11, 15.5], "texture": "#0"} + } + }, + { + "from": [1, 9, 1], + "to": [2, 14, 3], + "faces": { + "north": {"uv": [10.25, 13, 10.5, 15.5], "texture": "#0"}, + "east": {"uv": [11, 13, 10.5, 15.5], "texture": "#0"}, + "west": {"uv": [10.5, 13, 11, 15.5], "texture": "#0"} } } - ] + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + } + } } \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/plate_press_idle.json b/src/main/resources/assets/overdrive_that_matters/models/block/plate_press_idle.json index 7a89ce8e7..0dd2264f2 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/plate_press_idle.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/plate_press_idle.json @@ -1,218 +1,267 @@ { - "parent" : "block/block", + "credit": "Made with Blockbench", + "texture_size": [64, 32], "textures": { - "particle": "overdrive_that_matters:block/plate_press", - "body": "overdrive_that_matters:block/plate_press" + "0": "overdrive_that_matters:block/plate_press2", + "particle": "overdrive_that_matters:block/plate_press2" }, "elements": [ { - "name": "body", - "from": [0, 0, 0], - "to": [16, 8, 16], + "from": [10, 0, 0], + "to": [16, 6, 16], "faces": { - "north": {"uv": [0, 4, 4, 8], "texture": "#body"}, - "east": {"uv": [12, 4, 16, 8], "texture": "#body"}, - "south": {"uv": [4, 4, 8, 8], "texture": "#body"}, - "west": {"uv": [8, 4, 12, 8], "texture": "#body"}, - "up": {"uv": [4, 8, 8, 16], "texture": "#body"}, - "down": {"uv": [0, 8, 4, 16], "texture": "#body"} + "north": {"uv": [5.5, 13, 7, 16], "texture": "#0"}, + "east": {"uv": [1.5, 13, 5.5, 16], "texture": "#0"}, + "south": {"uv": [7, 13, 8.5, 16], "texture": "#0"}, + "west": {"uv": [5.5, 13, 1.5, 16], "texture": "#0"}, + "up": {"uv": [0, 8, 1.5, 16], "texture": "#0"}, + "down": {"uv": [0, 8, 1.5, 16], "texture": "#0"} } }, { - "name": "body", - "from": [0, 8, 7], - "to": [16, 12, 16], + "from": [10, 10, 0], + "to": [16, 16, 16], "faces": { - "north": {"uv": [4, 12, 8, 14], "texture": "#body"}, - "east": {"uv": [12, 2, 14.25, 4], "texture": "#body"}, - "south": {"uv": [4, 2, 8, 4], "texture": "#body"}, - "west": {"uv": [9.75, 2, 12, 4], "texture": "#body"}, - "up": {"uv": [4, 12, 8, 16], "texture": "#body"}, - "down": {"uv": [0, 0, 16, 9], "texture": "#missing"} + "north": {"uv": [5.5, 8, 7, 11], "texture": "#0"}, + "east": {"uv": [1.5, 8, 5.5, 11], "texture": "#0"}, + "south": {"uv": [7, 8, 8.5, 11], "texture": "#0"}, + "west": {"uv": [5.5, 8, 1.5, 11], "texture": "#0"}, + "up": {"uv": [0, 5, 4, 8], "rotation": 90, "texture": "#0"}, + "down": {"uv": [0, 8, 1.5, 16], "texture": "#0"} } }, { - "name": "body", - "from": [12, 8, 1], - "to": [16, 12, 7], + "from": [10, 6, 2], + "to": [16, 10, 16], "faces": { - "north": {"uv": [13.25, 0, 14.25, 2], "texture": "#body"}, - "east": {"uv": [14.25, 2, 15.75, 4], "texture": "#body"}, - "south": {"uv": [0, 0, 4, 4], "texture": "#missing"}, - "west": {"uv": [15.75, 2, 14.25, 4], "texture": "#body"}, - "up": {"uv": [14.25, 0, 15.75, 2], "rotation": 270, "texture": "#body"}, - "down": {"uv": [0, 0, 4, 6], "texture": "#missing"} + "north": {"uv": [5.5, 11, 7, 13], "texture": "#0"}, + "east": {"uv": [1.5, 11, 5, 13], "texture": "#0"}, + "south": {"uv": [7, 11, 8.5, 13], "texture": "#0"}, + "west": {"uv": [5, 11, 1.5, 13], "texture": "#0"} } }, { - "name": "press", - "from": [2, 8, 4], - "to": [11, 16, 13], + "from": [11, 6, 1], + "to": [15, 10, 2], "faces": { - "north": {"uv": [8, 8, 10.25, 12], "texture": "#body"}, - "east": {"uv": [10.25, 8, 12.5, 12], "texture": "#body"}, - "south": {"uv": [8, 12, 10.25, 16], "texture": "#body"}, - "west": {"uv": [10.25, 8, 12.5, 12], "texture": "#body"}, - "up": {"uv": [12.5, 8, 14.75, 12.5], "texture": "#body"}, - "down": {"uv": [0, 0, 9, 9], "texture": "#missing"} - } - }, - { - "name": "screenholder", - "from": [13, 8, 0], - "to": [15, 12, 1], - "faces": { - "north": {"uv": [4, 0, 4.5, 2], "texture": "#body"}, - "east": {"uv": [4.25, 0, 4.5, 2], "texture": "#body"}, - "south": {"uv": [0, 0, 2, 4], "texture": "#missing"}, - "west": {"uv": [4, 0, 4.25, 2], "texture": "#body"}, - "up": {"uv": [4, 0, 4.5, 0.5], "texture": "#body"}, - "down": {"uv": [0, 0, 2, 1], "texture": "#missing"} - } - }, - { - "name": "frame", - "from": [15, 12, 15], - "to": [16, 14, 16], - "faces": { - "north": {"uv": [8.25, 0, 8.5, 1], "texture": "#body"}, - "east": {"uv": [8.25, 0, 8.5, 1], "texture": "#body"}, - "south": {"uv": [8.25, 0, 8.5, 1], "texture": "#body"}, - "west": {"uv": [8.25, 0, 8.5, 1], "texture": "#body"}, - "up": {"uv": [8.25, 0, 8.5, 0.5], "texture": "#body"}, - "down": {"uv": [0, 0, 1, 1], "texture": "#missing"} - } - }, - { - "name": "frame", - "from": [0, 12, 15], - "to": [1, 14, 16], - "faces": { - "north": {"uv": [8.25, 0, 8.5, 1], "texture": "#body"}, - "east": {"uv": [8.25, 0, 8.5, 1], "texture": "#body"}, - "south": {"uv": [8.25, 0, 8.5, 1], "texture": "#body"}, - "west": {"uv": [8.25, 0, 8.5, 1], "texture": "#body"}, - "up": {"uv": [8.25, 0, 8.5, 0.5], "texture": "#body"}, - "down": {"uv": [0, 0, 1, 1], "texture": "#missing"} - } - }, - { - "name": "frame", - "from": [0.3, 13, 1], - "to": [0.8, 14, 15], - "faces": { - "north": {"uv": [0, 0, 0.5, 1], "texture": "#missing"}, - "east": {"uv": [0, 2.5, 3.75, 3], "texture": "#body"}, - "south": {"uv": [0, 0, 0.5, 1], "texture": "#missing"}, - "west": {"uv": [0, 2.5, 3.75, 3], "texture": "#body"}, - "up": {"uv": [0, 2.5, 3.75, 3], "rotation": 90, "texture": "#body"}, - "down": {"uv": [0, 2.5, 3.75, 3], "rotation": 90, "texture": "#body"} - } - }, - { - "name": "frame", - "from": [0, 8, 0], - "to": [1, 14, 1], - "faces": { - "north": {"uv": [8.25, 0, 8.5, 3], "texture": "#body"}, - "east": {"uv": [8.25, 0, 8.5, 3], "texture": "#body"}, - "south": {"uv": [8.25, 0, 8.5, 3], "texture": "#body"}, - "west": {"uv": [8.25, 0, 8.5, 3], "texture": "#body"}, - "up": {"uv": [8.25, 0, 8.5, 0.5], "texture": "#body"}, - "down": {"uv": [0, 0, 1, 1], "texture": "#missing"} - } - }, - { - "name": "frame", - "from": [1, 13, 15.2], - "to": [15, 14, 15.7], - "faces": { - "north": {"uv": [0, 2.5, 3.75, 3], "texture": "#body"}, - "east": {"uv": [0, 0, 0.5, 1], "texture": "#missing"}, - "south": {"uv": [0, 2.5, 3.75, 3], "texture": "#body"}, - "west": {"uv": [0, 0, 0.5, 1], "texture": "#missing"}, - "up": {"uv": [0, 2.5, 3.75, 3], "texture": "#body"}, - "down": {"uv": [0, 2.5, 3.75, 3], "texture": "#body"} + "north": {"uv": [4.25, 5, 5.25, 7], "texture": "#0"}, + "east": {"uv": [4, 5, 4.25, 7], "texture": "#0"}, + "west": {"uv": [5, 5, 5.25, 7], "texture": "#0"}, + "up": {"uv": [0, 0, 1, 0.5], "texture": "#missing"} } }, { "name": "screen", - "from": [12, 10, 0], - "to": [16, 14, 1], + "from": [11, 4, 2], + "to": [15, 8, 3], "rotation": {"angle": 22.5, "axis": "x", "origin": [14, 13, -0.5]}, "faces": { - "north": {"uv": [1, 0, 2, 2], "texture": "#body"}, - "east": {"uv": [3, 2, 4, 2.5], "rotation": 90, "texture": "#body"}, - "south": {"uv": [3, 0, 4, 2], "texture": "#body"}, - "west": {"uv": [3, 2, 4, 2.5], "rotation": 90, "texture": "#body"}, - "up": {"uv": [3, 2, 4, 2.5], "texture": "#body"}, - "down": {"uv": [3, 2, 4, 2.5], "texture": "#body"} + "north": {"uv": [1, 0, 2, 2], "texture": "#0"}, + "east": {"uv": [3, 2, 4, 2.5], "rotation": 90, "texture": "#0"}, + "south": {"uv": [3, 0, 4, 2], "texture": "#0"}, + "west": {"uv": [3, 2, 4, 2.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [3, 2, 4, 2.5], "texture": "#0"}, + "down": {"uv": [3, 2, 4, 2.5], "texture": "#0"} } }, { - "name": "gaspipes", - "from": [11, 8, 9], - "to": [12, 14, 12], + "from": [1, 8, 3], + "to": [9, 15, 15], "faces": { - "north": {"uv": [9.25, 0.5, 9.5, 3.5], "texture": "#body"}, - "east": {"uv": [8.5, 0.5, 9.25, 3.5], "texture": "#body"}, - "south": {"uv": [9.25, 0.5, 9.5, 3.5], "texture": "#body"}, - "west": {"uv": [0, 0, 0.75, 3], "texture": "#missing"}, - "up": {"uv": [8.5, 0.5, 9.25, 0], "rotation": 90, "texture": "#body"}, - "down": {"uv": [0, 0, 0.25, 1.5], "texture": "#missing"} + "north": {"uv": [8.5, 12.1, 10.5, 16], "texture": "#0"}, + "east": {"uv": [14, 12.5, 11, 16], "texture": "#0"}, + "south": {"uv": [14, 12.5, 16, 16], "texture": "#0"}, + "west": {"uv": [11, 12.5, 14, 16], "texture": "#0"}, + "up": {"uv": [8.5, 5.5, 10.5, 11.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [10.5, 5.5, 12.5, 11.5], "texture": "#0"} } }, { - "name": "gaspipes", - "from": [11, 8, 5], - "to": [12, 14, 8], + "from": [1, 0, 0], + "to": [9, 7, 16], "faces": { - "north": {"uv": [9.25, 0.5, 9.5, 3.5], "texture": "#body"}, - "east": {"uv": [8.5, 0.5, 9.25, 3.5], "texture": "#body"}, - "south": {"uv": [9.25, 0.5, 9.5, 3.5], "texture": "#body"}, - "west": {"uv": [0, 0, 0.75, 3], "texture": "#missing"}, - "up": {"uv": [8.5, 0.5, 9.25, 0], "rotation": 90, "texture": "#body"}, - "down": {"uv": [0, 0, 0.25, 1.5], "texture": "#missing"} + "north": {"uv": [8, 0, 10, 3.5], "texture": "#0"}, + "east": {"uv": [10, 0, 14, 3.5], "texture": "#0"}, + "south": {"uv": [8, 0, 10, 3.5], "texture": "#0"}, + "west": {"uv": [10, 0, 14, 3.5], "texture": "#0"}, + "up": {"uv": [14, 0, 16, 8], "texture": "#0"}, + "down": {"uv": [14, 0, 16, 8], "texture": "#0"} } }, { - "name": "gaspipes", - "from": [1, 8, 5], - "to": [2, 14, 8], + "name": "cubeframe", + "from": [9, 0, 1], + "to": [10, 16, 3], "faces": { - "north": {"uv": [9.25, 0.5, 9.5, 3.5], "texture": "#body"}, - "east": {"uv": [0, 0, 0.75, 3], "texture": "#missing"}, - "south": {"uv": [9.25, 0.5, 9.5, 3.5], "texture": "#body"}, - "west": {"uv": [8.5, 0.5, 9.25, 3.5], "texture": "#body"}, - "up": {"uv": [8.5, 0.5, 9.25, 0], "rotation": 90, "texture": "#body"}, - "down": {"uv": [0, 0, 0.25, 1.5], "texture": "#missing"} + "north": {"uv": [5.5, 0, 5.75, 8], "texture": "#0"}, + "east": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "south": {"uv": [5.75, 0, 6, 8], "texture": "#0"}, + "west": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "up": {"uv": [5, 0, 5.25, 1], "texture": "#0"}, + "down": {"uv": [5.25, 0, 5.5, 1], "texture": "#0"} } }, { - "name": "gaspipes", - "from": [1, 8, 9], - "to": [2, 14, 12], + "name": "cubeframe", + "from": [9, 0, 13], + "to": [10, 16, 15], "faces": { - "north": {"uv": [9.25, 0.5, 9.5, 3.5], "texture": "#body"}, - "east": {"uv": [0, 0, 0.75, 3], "texture": "#missing"}, - "south": {"uv": [9.25, 0.5, 9.5, 3.5], "texture": "#body"}, - "west": {"uv": [8.5, 0.5, 9.25, 3.5], "texture": "#body"}, - "up": {"uv": [8.5, 0.5, 9.25, 0], "rotation": 90, "texture": "#body"}, - "down": {"uv": [0, 0, 0.25, 1.5], "texture": "#missing"} + "north": {"uv": [5.5, 0, 5.75, 8], "texture": "#0"}, + "east": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "south": {"uv": [5.75, 0, 6, 8], "texture": "#0"}, + "west": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "up": {"uv": [5, 0, 5.25, 1], "texture": "#0"}, + "down": {"uv": [5.25, 0, 5.5, 1], "texture": "#0"} } }, { - "name": "gas", - "from": [12.4, 12, 2], - "to": [15.4, 15, 14], + "name": "cubeframe", + "from": [0, 0, 1], + "to": [1, 16, 3], "faces": { - "north": {"uv": [7.5, 0, 8.25, 1.5], "texture": "#body"}, - "east": {"uv": [4.5, 0, 7.5, 1.5], "rotation": 180, "texture": "#body"}, - "south": {"uv": [7.5, 0, 8.25, 1.5], "texture": "#body"}, - "west": {"uv": [4.5, 0, 7.5, 1.5], "texture": "#body"}, - "up": {"uv": [4.5, 0, 7.5, 1.5], "rotation": 90, "texture": "#body"}, - "down": {"uv": [0, 0, 3, 12], "texture": "#missing"} + "north": {"uv": [5.5, 0, 5.75, 8], "texture": "#0"}, + "east": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "south": {"uv": [5.75, 0, 6, 8], "texture": "#0"}, + "west": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "up": {"uv": [5, 0, 5.25, 1], "texture": "#0"}, + "down": {"uv": [5.25, 0, 5.5, 1], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [0, 0, 13], + "to": [1, 16, 15], + "faces": { + "north": {"uv": [5.5, 0, 5.75, 8], "texture": "#0"}, + "east": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "south": {"uv": [5.75, 0, 6, 8], "texture": "#0"}, + "west": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "up": {"uv": [5, 0, 5.25, 1], "texture": "#0"}, + "down": {"uv": [5.25, 0, 5.5, 1], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [9, 13, 3], + "to": [10, 15, 13], + "faces": { + "east": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [6, 1.5, 6.25, 6.5], "texture": "#0"}, + "down": {"uv": [6.25, 1.5, 6.5, 6.5], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [9, 1, 3], + "to": [10, 3, 13], + "faces": { + "east": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [6, 1.5, 6.25, 6.5], "texture": "#0"}, + "down": {"uv": [6.25, 1.5, 6.5, 6.5], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [0, 13, 3], + "to": [1, 15, 13], + "faces": { + "east": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [6, 1.5, 6.25, 6.5], "texture": "#0"}, + "down": {"uv": [6.25, 1.5, 6.5, 6.5], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [0, 1, 3], + "to": [1, 3, 13], + "faces": { + "east": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [6, 1.5, 6.25, 6.5], "texture": "#0"}, + "down": {"uv": [6.25, 1.5, 6.5, 6.5], "texture": "#0"} + } + }, + { + "from": [2, 9, -1], + "to": [8, 9, 1], + "faces": { + "up": {"uv": [0, 4, 1.5, 5], "texture": "#0"}, + "down": {"uv": [0, 4, 1.5, 5], "texture": "#0"} + } + }, + { + "from": [1, 8, 1], + "to": [9, 9, 3], + "faces": { + "north": {"uv": [8.5, 15.5, 10.5, 16], "texture": "#0"}, + "east": {"uv": [11, 15.5, 10.5, 16], "texture": "#0"}, + "west": {"uv": [10.5, 15.5, 11, 16], "texture": "#0"}, + "up": {"uv": [8.5, 11.5, 10.5, 12.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [10.5, 11.5, 12.5, 12.5], "texture": "#0"} + } + }, + { + "from": [1, 14, 1], + "to": [9, 15, 3], + "faces": { + "north": {"uv": [8.5, 12.5, 10.5, 13], "texture": "#0"}, + "east": {"uv": [11, 12.5, 10.5, 13], "texture": "#0"}, + "west": {"uv": [10.5, 13, 11, 13.5], "texture": "#0"}, + "up": {"uv": [8.5, 11.5, 10.5, 12.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [8.5, 11.5, 10.5, 12.5], "texture": "#0"} + } + }, + { + "from": [8, 9, 1], + "to": [9, 14, 3], + "faces": { + "north": {"uv": [8.5, 13, 8.75, 15.5], "texture": "#0"}, + "east": {"uv": [11, 13, 10.5, 15.5], "texture": "#0"}, + "west": {"uv": [10.5, 13, 11, 15.5], "texture": "#0"} + } + }, + { + "from": [1, 9, 1], + "to": [2, 14, 3], + "faces": { + "north": {"uv": [10.25, 13, 10.5, 15.5], "texture": "#0"}, + "east": {"uv": [11, 13, 10.5, 15.5], "texture": "#0"}, + "west": {"uv": [10.5, 13, 11, 15.5], "texture": "#0"} } } - ] + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 225, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "scale": [0.5, 0.5, 0.5] + } + } } \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/plate_press_working.json b/src/main/resources/assets/overdrive_that_matters/models/block/plate_press_working.json index 875259071..624ba9586 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/plate_press_working.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/plate_press_working.json @@ -1,219 +1,244 @@ -{ - "parent" : "block/block", +{ + "credit": "Made with Blockbench", + "texture_size": [64, 32], "textures": { - "particle": "overdrive_that_matters:block/plate_press", - "body": "overdrive_that_matters:block/plate_press", - "press": "overdrive_that_matters:block/plate_press_piston" + "0": "overdrive_that_matters:block/plate_press2", + "1": "overdrive_that_matters:block/plate_press_piston", + "particle": "overdrive_that_matters:block/plate_press2" }, "elements": [ { - "name": "body", - "from": [0, 0, 0], - "to": [16, 8, 16], + "from": [10, 0, 0], + "to": [16, 6, 16], "faces": { - "north": {"uv": [0, 4, 4, 8], "texture": "#body"}, - "east": {"uv": [12, 4, 16, 8], "texture": "#body"}, - "south": {"uv": [4, 4, 8, 8], "texture": "#body"}, - "west": {"uv": [8, 4, 12, 8], "texture": "#body"}, - "up": {"uv": [4, 8, 8, 16], "texture": "#body"}, - "down": {"uv": [0, 8, 4, 16], "texture": "#body"} + "north": {"uv": [5.5, 13, 7, 16], "texture": "#0"}, + "east": {"uv": [1.5, 13, 5.5, 16], "texture": "#0"}, + "south": {"uv": [7, 13, 8.5, 16], "texture": "#0"}, + "west": {"uv": [5.5, 13, 1.5, 16], "texture": "#0"}, + "up": {"uv": [0, 8, 1.5, 16], "texture": "#0"}, + "down": {"uv": [0, 8, 1.5, 16], "texture": "#0"} } }, { - "name": "body", - "from": [0, 8, 7], - "to": [16, 12, 16], + "from": [10, 10, 0], + "to": [16, 16, 16], "faces": { - "north": {"uv": [4, 12, 8, 14], "texture": "#body"}, - "east": {"uv": [12, 2, 14.25, 4], "texture": "#body"}, - "south": {"uv": [4, 2, 8, 4], "texture": "#body"}, - "west": {"uv": [9.75, 2, 12, 4], "texture": "#body"}, - "up": {"uv": [4, 12, 8, 16], "texture": "#body"}, - "down": {"uv": [0, 0, 16, 9], "texture": "#missing"} + "north": {"uv": [5.5, 8, 7, 11], "texture": "#0"}, + "east": {"uv": [1.5, 8, 5.5, 11], "texture": "#0"}, + "south": {"uv": [7, 8, 8.5, 11], "texture": "#0"}, + "west": {"uv": [5.5, 8, 1.5, 11], "texture": "#0"}, + "up": {"uv": [0, 5, 4, 8], "rotation": 90, "texture": "#0"}, + "down": {"uv": [0, 8, 1.5, 16], "texture": "#0"} } }, { - "name": "body", - "from": [12, 8, 1], - "to": [16, 12, 7], + "from": [10, 6, 2], + "to": [16, 10, 16], "faces": { - "north": {"uv": [13.25, 0, 14.25, 2], "texture": "#body"}, - "east": {"uv": [14.25, 2, 15.75, 4], "texture": "#body"}, - "south": {"uv": [0, 0, 4, 4], "texture": "#missing"}, - "west": {"uv": [15.75, 2, 14.25, 4], "texture": "#body"}, - "up": {"uv": [14.25, 0, 15.75, 2], "rotation": 270, "texture": "#body"}, - "down": {"uv": [0, 0, 4, 6], "texture": "#missing"} + "north": {"uv": [5.5, 11, 7, 13], "texture": "#0"}, + "east": {"uv": [1.5, 11, 5, 13], "texture": "#0"}, + "south": {"uv": [7, 11, 8.5, 13], "texture": "#0"}, + "west": {"uv": [5, 11, 1.5, 13], "texture": "#0"} } }, { - "name": "press", - "from": [2, 8, 4], - "to": [11, 16, 13], + "from": [11, 6, 1], + "to": [15, 10, 2], "faces": { - "north": {"uv": [0, 0, 8.9, 8], "texture": "#press"}, - "east": {"uv": [10.25, 8, 12.5, 12], "texture": "#body"}, - "south": {"uv": [8, 12, 10.25, 16], "texture": "#body"}, - "west": {"uv": [10.25, 8, 12.5, 12], "texture": "#body"}, - "up": {"uv": [12.5, 8, 14.75, 12.5], "texture": "#body"}, - "down": {"uv": [0, 0, 9, 9], "texture": "#missing"} - } - }, - { - "name": "screenholder", - "from": [13, 8, 0], - "to": [15, 12, 1], - "faces": { - "north": {"uv": [4, 0, 4.5, 2], "texture": "#body"}, - "east": {"uv": [4.25, 0, 4.5, 2], "texture": "#body"}, - "south": {"uv": [0, 0, 2, 4], "texture": "#missing"}, - "west": {"uv": [4, 0, 4.25, 2], "texture": "#body"}, - "up": {"uv": [4, 0, 4.5, 0.5], "texture": "#body"}, - "down": {"uv": [0, 0, 2, 1], "texture": "#missing"} - } - }, - { - "name": "frame", - "from": [15, 12, 15], - "to": [16, 14, 16], - "faces": { - "north": {"uv": [8.25, 0, 8.5, 1], "texture": "#body"}, - "east": {"uv": [8.25, 0, 8.5, 1], "texture": "#body"}, - "south": {"uv": [8.25, 0, 8.5, 1], "texture": "#body"}, - "west": {"uv": [8.25, 0, 8.5, 1], "texture": "#body"}, - "up": {"uv": [8.25, 0, 8.5, 0.5], "texture": "#body"}, - "down": {"uv": [0, 0, 1, 1], "texture": "#missing"} - } - }, - { - "name": "frame", - "from": [0, 12, 15], - "to": [1, 14, 16], - "faces": { - "north": {"uv": [8.25, 0, 8.5, 1], "texture": "#body"}, - "east": {"uv": [8.25, 0, 8.5, 1], "texture": "#body"}, - "south": {"uv": [8.25, 0, 8.5, 1], "texture": "#body"}, - "west": {"uv": [8.25, 0, 8.5, 1], "texture": "#body"}, - "up": {"uv": [8.25, 0, 8.5, 0.5], "texture": "#body"}, - "down": {"uv": [0, 0, 1, 1], "texture": "#missing"} - } - }, - { - "name": "frame", - "from": [0.3, 13, 1], - "to": [0.8, 14, 15], - "faces": { - "north": {"uv": [0, 0, 0.5, 1], "texture": "#missing"}, - "east": {"uv": [0, 2.5, 3.75, 3], "texture": "#body"}, - "south": {"uv": [0, 0, 0.5, 1], "texture": "#missing"}, - "west": {"uv": [0, 2.5, 3.75, 3], "texture": "#body"}, - "up": {"uv": [0, 2.5, 3.75, 3], "rotation": 90, "texture": "#body"}, - "down": {"uv": [0, 2.5, 3.75, 3], "rotation": 90, "texture": "#body"} - } - }, - { - "name": "frame", - "from": [0, 8, 0], - "to": [1, 14, 1], - "faces": { - "north": {"uv": [8.25, 0, 8.5, 3], "texture": "#body"}, - "east": {"uv": [8.25, 0, 8.5, 3], "texture": "#body"}, - "south": {"uv": [8.25, 0, 8.5, 3], "texture": "#body"}, - "west": {"uv": [8.25, 0, 8.5, 3], "texture": "#body"}, - "up": {"uv": [8.25, 0, 8.5, 0.5], "texture": "#body"}, - "down": {"uv": [0, 0, 1, 1], "texture": "#missing"} - } - }, - { - "name": "frame", - "from": [1, 13, 15.2], - "to": [15, 14, 15.7], - "faces": { - "north": {"uv": [0, 2.5, 3.75, 3], "texture": "#body"}, - "east": {"uv": [0, 0, 0.5, 1], "texture": "#missing"}, - "south": {"uv": [0, 2.5, 3.75, 3], "texture": "#body"}, - "west": {"uv": [0, 0, 0.5, 1], "texture": "#missing"}, - "up": {"uv": [0, 2.5, 3.75, 3], "texture": "#body"}, - "down": {"uv": [0, 2.5, 3.75, 3], "texture": "#body"} + "north": {"uv": [4.25, 5, 5.25, 7], "texture": "#0"}, + "east": {"uv": [4, 5, 4.25, 7], "texture": "#0"}, + "west": {"uv": [5, 5, 5.25, 7], "texture": "#0"}, + "up": {"uv": [0, 0, 1, 0.5], "texture": "#missing"} } }, { "name": "screen", - "from": [12, 10, 0], - "to": [16, 14, 1], + "from": [11, 4, 2], + "to": [15, 8, 3], "rotation": {"angle": 22.5, "axis": "x", "origin": [14, 13, -0.5]}, "faces": { - "north": {"uv": [0, 0, 1, 2], "texture": "#body"}, - "east": {"uv": [3, 2, 4, 2.5], "rotation": 90, "texture": "#body"}, - "south": {"uv": [3, 0, 4, 2], "texture": "#body"}, - "west": {"uv": [3, 2, 4, 2.5], "rotation": 90, "texture": "#body"}, - "up": {"uv": [3, 2, 4, 2.5], "texture": "#body"}, - "down": {"uv": [3, 2, 4, 2.5], "texture": "#body"} + "north": {"uv": [0, 0, 1, 2], "texture": "#0"}, + "east": {"uv": [3, 2, 4, 2.5], "rotation": 90, "texture": "#0"}, + "south": {"uv": [3, 0, 4, 2], "texture": "#0"}, + "west": {"uv": [3, 2, 4, 2.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [3, 2, 4, 2.5], "texture": "#0"}, + "down": {"uv": [3, 2, 4, 2.5], "texture": "#0"} } }, { - "name": "gaspipes", - "from": [11, 8, 9], - "to": [12, 14, 12], + "from": [1, 8, 3], + "to": [9, 15, 15], "faces": { - "north": {"uv": [9.25, 0.5, 9.5, 3.5], "texture": "#body"}, - "east": {"uv": [8.5, 0.5, 9.25, 3.5], "texture": "#body"}, - "south": {"uv": [9.25, 0.5, 9.5, 3.5], "texture": "#body"}, - "west": {"uv": [0, 0, 0.75, 3], "texture": "#missing"}, - "up": {"uv": [8.5, 0.5, 9.25, 0], "rotation": 90, "texture": "#body"}, - "down": {"uv": [0, 0, 0.25, 1.5], "texture": "#missing"} + "north": {"uv": [0, 2, 16, 16], "texture": "#1"}, + "east": {"uv": [14, 12.5, 11, 16], "texture": "#0"}, + "south": {"uv": [14, 12.5, 16, 16], "texture": "#0"}, + "west": {"uv": [11, 12.5, 14, 16], "texture": "#0"}, + "up": {"uv": [8.5, 5.5, 10.5, 11.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [10.5, 5.5, 12.5, 11.5], "texture": "#0"} } }, { - "name": "gaspipes", - "from": [11, 8, 5], - "to": [12, 14, 8], + "from": [1, 0, 0], + "to": [9, 7, 16], "faces": { - "north": {"uv": [9.25, 0.5, 9.5, 3.5], "texture": "#body"}, - "east": {"uv": [8.5, 0.5, 9.25, 3.5], "texture": "#body"}, - "south": {"uv": [9.25, 0.5, 9.5, 3.5], "texture": "#body"}, - "west": {"uv": [0, 0, 0.75, 3], "texture": "#missing"}, - "up": {"uv": [8.5, 0.5, 9.25, 0], "rotation": 90, "texture": "#body"}, - "down": {"uv": [0, 0, 0.25, 1.5], "texture": "#missing"} + "north": {"uv": [8, 0, 10, 3.5], "texture": "#0"}, + "east": {"uv": [10, 0, 14, 3.5], "texture": "#0"}, + "south": {"uv": [8, 0, 10, 3.5], "texture": "#0"}, + "west": {"uv": [10, 0, 14, 3.5], "texture": "#0"}, + "up": {"uv": [14, 0, 16, 8], "texture": "#0"}, + "down": {"uv": [14, 0, 16, 8], "texture": "#0"} } }, { - "name": "gaspipes", - "from": [1, 8, 5], - "to": [2, 14, 8], + "name": "cubeframe", + "from": [9, 0, 1], + "to": [10, 16, 3], "faces": { - "north": {"uv": [9.25, 0.5, 9.5, 3.5], "texture": "#body"}, - "east": {"uv": [0, 0, 0.75, 3], "texture": "#missing"}, - "south": {"uv": [9.25, 0.5, 9.5, 3.5], "texture": "#body"}, - "west": {"uv": [8.5, 0.5, 9.25, 3.5], "texture": "#body"}, - "up": {"uv": [8.5, 0.5, 9.25, 0], "rotation": 90, "texture": "#body"}, - "down": {"uv": [0, 0, 0.25, 1.5], "texture": "#missing"} + "north": {"uv": [5.5, 0, 5.75, 8], "texture": "#0"}, + "east": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "south": {"uv": [5.75, 0, 6, 8], "texture": "#0"}, + "west": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "up": {"uv": [5, 0, 5.25, 1], "texture": "#0"}, + "down": {"uv": [5.25, 0, 5.5, 1], "texture": "#0"} } }, { - "name": "gaspipes", - "from": [1, 8, 9], - "to": [2, 14, 12], + "name": "cubeframe", + "from": [9, 0, 13], + "to": [10, 16, 15], "faces": { - "north": {"uv": [9.25, 0.5, 9.5, 3.5], "texture": "#body"}, - "east": {"uv": [0, 0, 0.75, 3], "texture": "#missing"}, - "south": {"uv": [9.25, 0.5, 9.5, 3.5], "texture": "#body"}, - "west": {"uv": [8.5, 0.5, 9.25, 3.5], "texture": "#body"}, - "up": {"uv": [8.5, 0.5, 9.25, 0], "rotation": 90, "texture": "#body"}, - "down": {"uv": [0, 0, 0.25, 1.5], "texture": "#missing"} + "north": {"uv": [5.5, 0, 5.75, 8], "texture": "#0"}, + "east": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "south": {"uv": [5.75, 0, 6, 8], "texture": "#0"}, + "west": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "up": {"uv": [5, 0, 5.25, 1], "texture": "#0"}, + "down": {"uv": [5.25, 0, 5.5, 1], "texture": "#0"} } }, { - "name": "gas", - "from": [12.4, 12, 2], - "to": [15.4, 15, 14], + "name": "cubeframe", + "from": [0, 0, 1], + "to": [1, 16, 3], "faces": { - "north": {"uv": [7.5, 0, 8.25, 1.5], "texture": "#body"}, - "east": {"uv": [4.5, 0, 7.5, 1.5], "rotation": 180, "texture": "#body"}, - "south": {"uv": [7.5, 0, 8.25, 1.5], "texture": "#body"}, - "west": {"uv": [4.5, 0, 7.5, 1.5], "texture": "#body"}, - "up": {"uv": [4.5, 0, 7.5, 1.5], "rotation": 90, "texture": "#body"}, - "down": {"uv": [0, 0, 3, 12], "texture": "#missing"} + "north": {"uv": [5.5, 0, 5.75, 8], "texture": "#0"}, + "east": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "south": {"uv": [5.75, 0, 6, 8], "texture": "#0"}, + "west": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "up": {"uv": [5, 0, 5.25, 1], "texture": "#0"}, + "down": {"uv": [5.25, 0, 5.5, 1], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [0, 0, 13], + "to": [1, 16, 15], + "faces": { + "north": {"uv": [5.5, 0, 5.75, 8], "texture": "#0"}, + "east": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "south": {"uv": [5.75, 0, 6, 8], "texture": "#0"}, + "west": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "up": {"uv": [5, 0, 5.25, 1], "texture": "#0"}, + "down": {"uv": [5.25, 0, 5.5, 1], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [9, 13, 3], + "to": [10, 15, 13], + "faces": { + "east": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [6, 1.5, 6.25, 6.5], "texture": "#0"}, + "down": {"uv": [6.25, 1.5, 6.5, 6.5], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [9, 1, 3], + "to": [10, 3, 13], + "faces": { + "east": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [6, 1.5, 6.25, 6.5], "texture": "#0"}, + "down": {"uv": [6.25, 1.5, 6.5, 6.5], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [0, 13, 3], + "to": [1, 15, 13], + "faces": { + "east": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [6, 1.5, 6.25, 6.5], "texture": "#0"}, + "down": {"uv": [6.25, 1.5, 6.5, 6.5], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [0, 1, 3], + "to": [1, 3, 13], + "faces": { + "east": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [6, 1.5, 6.25, 6.5], "texture": "#0"}, + "down": {"uv": [6.25, 1.5, 6.5, 6.5], "texture": "#0"} + } + }, + { + "from": [2, 9, -1], + "to": [8, 9, 1], + "faces": { + "up": {"uv": [0, 4, 1.5, 5], "texture": "#0"}, + "down": {"uv": [0, 4, 1.5, 5], "texture": "#0"} + } + }, + { + "from": [1, 8, 1], + "to": [9, 9, 3], + "faces": { + "north": {"uv": [8.5, 15.5, 10.5, 16], "texture": "#0"}, + "east": {"uv": [11, 15.5, 10.5, 16], "texture": "#0"}, + "west": {"uv": [10.5, 15.5, 11, 16], "texture": "#0"}, + "up": {"uv": [8.5, 11.5, 10.5, 12.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [10.5, 11.5, 12.5, 12.5], "texture": "#0"} + } + }, + { + "from": [1, 14, 1], + "to": [9, 15, 3], + "faces": { + "north": {"uv": [8.5, 12.5, 10.5, 13], "texture": "#0"}, + "east": {"uv": [11, 12.5, 10.5, 13], "texture": "#0"}, + "west": {"uv": [10.5, 13, 11, 13.5], "texture": "#0"}, + "up": {"uv": [8.5, 11.5, 10.5, 12.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [8.5, 11.5, 10.5, 12.5], "texture": "#0"} + } + }, + { + "from": [8, 9, 1], + "to": [9, 14, 3], + "faces": { + "north": {"uv": [8.5, 13, 8.75, 15.5], "texture": "#0"}, + "east": {"uv": [11, 13, 10.5, 15.5], "texture": "#0"}, + "west": {"uv": [10.5, 13, 11, 15.5], "texture": "#0"} + } + }, + { + "from": [1, 9, 1], + "to": [2, 14, 3], + "faces": { + "north": {"uv": [10.25, 13, 10.5, 15.5], "texture": "#0"}, + "east": {"uv": [11, 13, 10.5, 15.5], "texture": "#0"}, + "west": {"uv": [10.5, 13, 11, 15.5], "texture": "#0"} } } - ] + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + } + } } \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/twin_plate_press_error.json b/src/main/resources/assets/overdrive_that_matters/models/block/twin_plate_press_error.json new file mode 100644 index 000000000..49e49a54f --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/twin_plate_press_error.json @@ -0,0 +1,291 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [64, 32], + "textures": { + "0": "overdrive_that_matters:block/plate_press2", + "particle": "overdrive_that_matters:block/plate_press2" + }, + "elements": [ + { + "from": [10, 0, 0], + "to": [16, 6, 16], + "faces": { + "north": {"uv": [5.5, 13, 7, 16], "texture": "#0"}, + "east": {"uv": [1.5, 13, 5.5, 16], "texture": "#0"}, + "south": {"uv": [7, 13, 8.5, 16], "texture": "#0"}, + "west": {"uv": [5.5, 13, 1.5, 16], "texture": "#0"}, + "up": {"uv": [0, 8, 1.5, 16], "texture": "#0"}, + "down": {"uv": [0, 8, 1.5, 16], "texture": "#0"} + } + }, + { + "from": [10, 10, 0], + "to": [16, 16, 16], + "faces": { + "north": {"uv": [5.5, 8, 7, 11], "texture": "#0"}, + "east": {"uv": [1.5, 8, 5.5, 11], "texture": "#0"}, + "south": {"uv": [7, 8, 8.5, 11], "texture": "#0"}, + "west": {"uv": [5.5, 8, 1.5, 11], "texture": "#0"}, + "up": {"uv": [0, 5, 4, 8], "rotation": 90, "texture": "#0"}, + "down": {"uv": [0, 8, 1.5, 16], "texture": "#0"} + } + }, + { + "from": [10, 6, 2], + "to": [16, 10, 16], + "faces": { + "north": {"uv": [5.5, 11, 7, 13], "texture": "#0"}, + "east": {"uv": [1.5, 11, 5, 13], "texture": "#0"}, + "south": {"uv": [7, 11, 8.5, 13], "texture": "#0"}, + "west": {"uv": [5, 11, 1.5, 13], "texture": "#0"} + } + }, + { + "from": [11, 6, 1], + "to": [15, 10, 2], + "faces": { + "north": {"uv": [4.25, 5, 5.25, 7], "texture": "#0"}, + "east": {"uv": [4, 5, 4.25, 7], "texture": "#0"}, + "west": {"uv": [5, 5, 5.25, 7], "texture": "#0"}, + "up": {"uv": [0, 0, 1, 0.5], "texture": "#missing"} + } + }, + { + "name": "screen", + "from": [11, 4, 2], + "to": [15, 8, 3], + "rotation": {"angle": 22.5, "axis": "x", "origin": [14, 13, -0.5]}, + "faces": { + "north": {"uv": [2, 0, 3, 2], "texture": "#0"}, + "east": {"uv": [3, 2, 4, 2.5], "rotation": 90, "texture": "#0"}, + "south": {"uv": [3, 0, 4, 2], "texture": "#0"}, + "west": {"uv": [3, 2, 4, 2.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [3, 2, 4, 2.5], "texture": "#0"}, + "down": {"uv": [3, 2, 4, 2.5], "texture": "#0"} + } + }, + { + "from": [1, 8, 3], + "to": [9, 15, 15], + "faces": { + "north": {"uv": [8.5, 12.1, 10.5, 16], "texture": "#0"}, + "east": {"uv": [14, 12.5, 11, 16], "texture": "#0"}, + "south": {"uv": [14, 12.5, 16, 16], "texture": "#0"}, + "west": {"uv": [11, 12.5, 14, 16], "texture": "#0"}, + "up": {"uv": [8.5, 5.5, 10.5, 11.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [10.5, 5.5, 12.5, 11.5], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [9, 0, 1], + "to": [10, 16, 3], + "faces": { + "north": {"uv": [5.5, 0, 5.75, 8], "texture": "#0"}, + "east": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "south": {"uv": [5.75, 0, 6, 8], "texture": "#0"}, + "west": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "up": {"uv": [5, 0, 5.25, 1], "texture": "#0"}, + "down": {"uv": [5.25, 0, 5.5, 1], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [9, 0, 13], + "to": [10, 16, 15], + "faces": { + "north": {"uv": [5.5, 0, 5.75, 8], "texture": "#0"}, + "east": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "south": {"uv": [5.75, 0, 6, 8], "texture": "#0"}, + "west": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "up": {"uv": [5, 0, 5.25, 1], "texture": "#0"}, + "down": {"uv": [5.25, 0, 5.5, 1], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [0, 0, 1], + "to": [1, 16, 3], + "faces": { + "north": {"uv": [5.5, 0, 5.75, 8], "texture": "#0"}, + "east": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "south": {"uv": [5.75, 0, 6, 8], "texture": "#0"}, + "west": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "up": {"uv": [5, 0, 5.25, 1], "texture": "#0"}, + "down": {"uv": [5.25, 0, 5.5, 1], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [0, 0, 13], + "to": [1, 16, 15], + "faces": { + "north": {"uv": [5.5, 0, 5.75, 8], "texture": "#0"}, + "east": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "south": {"uv": [5.75, 0, 6, 8], "texture": "#0"}, + "west": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "up": {"uv": [5, 0, 5.25, 1], "texture": "#0"}, + "down": {"uv": [5.25, 0, 5.5, 1], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [9, 13, 3], + "to": [10, 15, 13], + "faces": { + "east": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [6, 1.5, 6.25, 6.5], "texture": "#0"}, + "down": {"uv": [6.25, 1.5, 6.5, 6.5], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [9, 1, 3], + "to": [10, 3, 13], + "faces": { + "east": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [6, 1.5, 6.25, 6.5], "texture": "#0"}, + "down": {"uv": [6.25, 1.5, 6.5, 6.5], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [0, 13, 3], + "to": [1, 15, 13], + "faces": { + "east": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [6, 1.5, 6.25, 6.5], "texture": "#0"}, + "down": {"uv": [6.25, 1.5, 6.5, 6.5], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [0, 1, 3], + "to": [1, 3, 13], + "faces": { + "east": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [6, 1.5, 6.25, 6.5], "texture": "#0"}, + "down": {"uv": [6.25, 1.5, 6.5, 6.5], "texture": "#0"} + } + }, + { + "from": [2, 9, -1], + "to": [8, 9, 1], + "faces": { + "up": {"uv": [0, 4, 1.5, 5], "texture": "#0"}, + "down": {"uv": [0, 4, 1.5, 5], "texture": "#0"} + } + }, + { + "from": [1, 8, 1], + "to": [9, 9, 3], + "faces": { + "north": {"uv": [8.5, 15.5, 10.5, 16], "texture": "#0"}, + "east": {"uv": [11, 15.5, 10.5, 16], "texture": "#0"}, + "west": {"uv": [10.5, 15.5, 11, 16], "texture": "#0"}, + "up": {"uv": [8.5, 11.5, 10.5, 12.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [10.5, 11.5, 12.5, 12.5], "texture": "#0"} + } + }, + { + "from": [1, 14, 1], + "to": [9, 15, 3], + "faces": { + "north": {"uv": [8.5, 12.5, 10.5, 13], "texture": "#0"}, + "east": {"uv": [11, 12.5, 10.5, 13], "texture": "#0"}, + "west": {"uv": [10.5, 13, 11, 13.5], "texture": "#0"}, + "up": {"uv": [8.5, 11.5, 10.5, 12.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [8.5, 11.5, 10.5, 12.5], "texture": "#0"} + } + }, + { + "from": [8, 9, 1], + "to": [9, 14, 3], + "faces": { + "north": {"uv": [8.5, 13, 8.75, 15.5], "texture": "#0"}, + "east": {"uv": [11, 13, 10.5, 15.5], "texture": "#0"}, + "west": {"uv": [10.5, 13, 11, 15.5], "texture": "#0"} + } + }, + { + "from": [1, 9, 1], + "to": [2, 14, 3], + "faces": { + "north": {"uv": [10.25, 13, 10.5, 15.5], "texture": "#0"}, + "east": {"uv": [11, 13, 10.5, 15.5], "texture": "#0"}, + "west": {"uv": [10.5, 13, 11, 15.5], "texture": "#0"} + } + }, + { + "from": [1, 0, 3], + "to": [9, 7, 15], + "faces": { + "north": {"uv": [8.5, 12.1, 10.5, 16], "texture": "#0"}, + "east": {"uv": [14, 12.5, 11, 16], "texture": "#0"}, + "south": {"uv": [14, 12.5, 16, 16], "texture": "#0"}, + "west": {"uv": [11, 12.5, 14, 16], "texture": "#0"}, + "up": {"uv": [8.5, 5.5, 10.5, 11.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [10.5, 5.5, 12.5, 11.5], "texture": "#0"} + } + }, + { + "from": [8, 1, 1], + "to": [9, 6, 3], + "faces": { + "north": {"uv": [8.5, 13, 8.75, 15.5], "texture": "#0"}, + "east": {"uv": [11, 13, 10.5, 15.5], "texture": "#0"}, + "west": {"uv": [10.5, 13, 11, 15.5], "texture": "#0"} + } + }, + { + "from": [1, 6, 1], + "to": [9, 7, 3], + "faces": { + "north": {"uv": [8.5, 12.5, 10.5, 13], "texture": "#0"}, + "east": {"uv": [11, 12.5, 10.5, 13], "texture": "#0"}, + "west": {"uv": [10.5, 13, 11, 13.5], "texture": "#0"}, + "up": {"uv": [8.5, 11.5, 10.5, 12.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [8.5, 11.5, 10.5, 12.5], "texture": "#0"} + } + }, + { + "from": [1, 1, 1], + "to": [2, 6, 3], + "faces": { + "north": {"uv": [10.25, 13, 10.5, 15.5], "texture": "#0"}, + "east": {"uv": [11, 13, 10.5, 15.5], "texture": "#0"}, + "west": {"uv": [10.5, 13, 11, 15.5], "texture": "#0"} + } + }, + { + "from": [1, 0, 1], + "to": [9, 1, 3], + "faces": { + "north": {"uv": [8.5, 15.5, 10.5, 16], "texture": "#0"}, + "east": {"uv": [11, 15.5, 10.5, 16], "texture": "#0"}, + "west": {"uv": [10.5, 15.5, 11, 16], "texture": "#0"}, + "up": {"uv": [8.5, 11.5, 10.5, 12.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [10.5, 11.5, 12.5, 12.5], "texture": "#0"} + } + }, + { + "from": [2, 1, -1], + "to": [8, 1, 1], + "faces": { + "up": {"uv": [0, 4, 1.5, 5], "texture": "#0"}, + "down": {"uv": [0, 4, 1.5, 5], "texture": "#0"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/twin_plate_press_idle.json b/src/main/resources/assets/overdrive_that_matters/models/block/twin_plate_press_idle.json new file mode 100644 index 000000000..d66cbfd14 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/twin_plate_press_idle.json @@ -0,0 +1,315 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [64, 32], + "textures": { + "0": "overdrive_that_matters:block/plate_press2", + "particle": "overdrive_that_matters:block/plate_press2" + }, + "elements": [ + { + "from": [10, 0, 0], + "to": [16, 6, 16], + "faces": { + "north": {"uv": [5.5, 13, 7, 16], "texture": "#0"}, + "east": {"uv": [1.5, 13, 5.5, 16], "texture": "#0"}, + "south": {"uv": [7, 13, 8.5, 16], "texture": "#0"}, + "west": {"uv": [5.5, 13, 1.5, 16], "texture": "#0"}, + "up": {"uv": [0, 8, 1.5, 16], "texture": "#0"}, + "down": {"uv": [0, 8, 1.5, 16], "texture": "#0"} + } + }, + { + "from": [10, 10, 0], + "to": [16, 16, 16], + "faces": { + "north": {"uv": [5.5, 8, 7, 11], "texture": "#0"}, + "east": {"uv": [1.5, 8, 5.5, 11], "texture": "#0"}, + "south": {"uv": [7, 8, 8.5, 11], "texture": "#0"}, + "west": {"uv": [5.5, 8, 1.5, 11], "texture": "#0"}, + "up": {"uv": [0, 5, 4, 8], "rotation": 90, "texture": "#0"}, + "down": {"uv": [0, 8, 1.5, 16], "texture": "#0"} + } + }, + { + "from": [10, 6, 2], + "to": [16, 10, 16], + "faces": { + "north": {"uv": [5.5, 11, 7, 13], "texture": "#0"}, + "east": {"uv": [1.5, 11, 5, 13], "texture": "#0"}, + "south": {"uv": [7, 11, 8.5, 13], "texture": "#0"}, + "west": {"uv": [5, 11, 1.5, 13], "texture": "#0"} + } + }, + { + "from": [11, 6, 1], + "to": [15, 10, 2], + "faces": { + "north": {"uv": [4.25, 5, 5.25, 7], "texture": "#0"}, + "east": {"uv": [4, 5, 4.25, 7], "texture": "#0"}, + "west": {"uv": [5, 5, 5.25, 7], "texture": "#0"}, + "up": {"uv": [0, 0, 1, 0.5], "texture": "#missing"} + } + }, + { + "name": "screen", + "from": [11, 4, 2], + "to": [15, 8, 3], + "rotation": {"angle": 22.5, "axis": "x", "origin": [14, 13, -0.5]}, + "faces": { + "north": {"uv": [1, 0, 2, 2], "texture": "#0"}, + "east": {"uv": [3, 2, 4, 2.5], "rotation": 90, "texture": "#0"}, + "south": {"uv": [3, 0, 4, 2], "texture": "#0"}, + "west": {"uv": [3, 2, 4, 2.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [3, 2, 4, 2.5], "texture": "#0"}, + "down": {"uv": [3, 2, 4, 2.5], "texture": "#0"} + } + }, + { + "from": [1, 8, 3], + "to": [9, 15, 15], + "faces": { + "north": {"uv": [8.5, 12.1, 10.5, 16], "texture": "#0"}, + "east": {"uv": [14, 12.5, 11, 16], "texture": "#0"}, + "south": {"uv": [14, 12.5, 16, 16], "texture": "#0"}, + "west": {"uv": [11, 12.5, 14, 16], "texture": "#0"}, + "up": {"uv": [8.5, 5.5, 10.5, 11.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [10.5, 5.5, 12.5, 11.5], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [9, 0, 1], + "to": [10, 16, 3], + "faces": { + "north": {"uv": [5.5, 0, 5.75, 8], "texture": "#0"}, + "east": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "south": {"uv": [5.75, 0, 6, 8], "texture": "#0"}, + "west": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "up": {"uv": [5, 0, 5.25, 1], "texture": "#0"}, + "down": {"uv": [5.25, 0, 5.5, 1], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [9, 0, 13], + "to": [10, 16, 15], + "faces": { + "north": {"uv": [5.5, 0, 5.75, 8], "texture": "#0"}, + "east": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "south": {"uv": [5.75, 0, 6, 8], "texture": "#0"}, + "west": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "up": {"uv": [5, 0, 5.25, 1], "texture": "#0"}, + "down": {"uv": [5.25, 0, 5.5, 1], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [0, 0, 1], + "to": [1, 16, 3], + "faces": { + "north": {"uv": [5.5, 0, 5.75, 8], "texture": "#0"}, + "east": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "south": {"uv": [5.75, 0, 6, 8], "texture": "#0"}, + "west": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "up": {"uv": [5, 0, 5.25, 1], "texture": "#0"}, + "down": {"uv": [5.25, 0, 5.5, 1], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [0, 0, 13], + "to": [1, 16, 15], + "faces": { + "north": {"uv": [5.5, 0, 5.75, 8], "texture": "#0"}, + "east": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "south": {"uv": [5.75, 0, 6, 8], "texture": "#0"}, + "west": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "up": {"uv": [5, 0, 5.25, 1], "texture": "#0"}, + "down": {"uv": [5.25, 0, 5.5, 1], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [9, 13, 3], + "to": [10, 15, 13], + "faces": { + "east": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [6, 1.5, 6.25, 6.5], "texture": "#0"}, + "down": {"uv": [6.25, 1.5, 6.5, 6.5], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [9, 1, 3], + "to": [10, 3, 13], + "faces": { + "east": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [6, 1.5, 6.25, 6.5], "texture": "#0"}, + "down": {"uv": [6.25, 1.5, 6.5, 6.5], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [0, 13, 3], + "to": [1, 15, 13], + "faces": { + "east": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [6, 1.5, 6.25, 6.5], "texture": "#0"}, + "down": {"uv": [6.25, 1.5, 6.5, 6.5], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [0, 1, 3], + "to": [1, 3, 13], + "faces": { + "east": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [6, 1.5, 6.25, 6.5], "texture": "#0"}, + "down": {"uv": [6.25, 1.5, 6.5, 6.5], "texture": "#0"} + } + }, + { + "from": [2, 9, -1], + "to": [8, 9, 1], + "faces": { + "up": {"uv": [0, 4, 1.5, 5], "texture": "#0"}, + "down": {"uv": [0, 4, 1.5, 5], "texture": "#0"} + } + }, + { + "from": [1, 8, 1], + "to": [9, 9, 3], + "faces": { + "north": {"uv": [8.5, 15.5, 10.5, 16], "texture": "#0"}, + "east": {"uv": [11, 15.5, 10.5, 16], "texture": "#0"}, + "west": {"uv": [10.5, 15.5, 11, 16], "texture": "#0"}, + "up": {"uv": [8.5, 11.5, 10.5, 12.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [10.5, 11.5, 12.5, 12.5], "texture": "#0"} + } + }, + { + "from": [1, 14, 1], + "to": [9, 15, 3], + "faces": { + "north": {"uv": [8.5, 12.5, 10.5, 13], "texture": "#0"}, + "east": {"uv": [11, 12.5, 10.5, 13], "texture": "#0"}, + "west": {"uv": [10.5, 13, 11, 13.5], "texture": "#0"}, + "up": {"uv": [8.5, 11.5, 10.5, 12.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [8.5, 11.5, 10.5, 12.5], "texture": "#0"} + } + }, + { + "from": [8, 9, 1], + "to": [9, 14, 3], + "faces": { + "north": {"uv": [8.5, 13, 8.75, 15.5], "texture": "#0"}, + "east": {"uv": [11, 13, 10.5, 15.5], "texture": "#0"}, + "west": {"uv": [10.5, 13, 11, 15.5], "texture": "#0"} + } + }, + { + "from": [1, 9, 1], + "to": [2, 14, 3], + "faces": { + "north": {"uv": [10.25, 13, 10.5, 15.5], "texture": "#0"}, + "east": {"uv": [11, 13, 10.5, 15.5], "texture": "#0"}, + "west": {"uv": [10.5, 13, 11, 15.5], "texture": "#0"} + } + }, + { + "from": [1, 0, 3], + "to": [9, 7, 15], + "faces": { + "north": {"uv": [8.5, 12.1, 10.5, 16], "texture": "#0"}, + "east": {"uv": [14, 12.5, 11, 16], "texture": "#0"}, + "south": {"uv": [14, 12.5, 16, 16], "texture": "#0"}, + "west": {"uv": [11, 12.5, 14, 16], "texture": "#0"}, + "up": {"uv": [8.5, 5.5, 10.5, 11.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [10.5, 5.5, 12.5, 11.5], "texture": "#0"} + } + }, + { + "from": [8, 1, 1], + "to": [9, 6, 3], + "faces": { + "north": {"uv": [8.5, 13, 8.75, 15.5], "texture": "#0"}, + "east": {"uv": [11, 13, 10.5, 15.5], "texture": "#0"}, + "west": {"uv": [10.5, 13, 11, 15.5], "texture": "#0"} + } + }, + { + "from": [1, 6, 1], + "to": [9, 7, 3], + "faces": { + "north": {"uv": [8.5, 12.5, 10.5, 13], "texture": "#0"}, + "east": {"uv": [11, 12.5, 10.5, 13], "texture": "#0"}, + "west": {"uv": [10.5, 13, 11, 13.5], "texture": "#0"}, + "up": {"uv": [8.5, 11.5, 10.5, 12.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [8.5, 11.5, 10.5, 12.5], "texture": "#0"} + } + }, + { + "from": [1, 1, 1], + "to": [2, 6, 3], + "faces": { + "north": {"uv": [10.25, 13, 10.5, 15.5], "texture": "#0"}, + "east": {"uv": [11, 13, 10.5, 15.5], "texture": "#0"}, + "west": {"uv": [10.5, 13, 11, 15.5], "texture": "#0"} + } + }, + { + "from": [1, 0, 1], + "to": [9, 1, 3], + "faces": { + "north": {"uv": [8.5, 15.5, 10.5, 16], "texture": "#0"}, + "east": {"uv": [11, 15.5, 10.5, 16], "texture": "#0"}, + "west": {"uv": [10.5, 15.5, 11, 16], "texture": "#0"}, + "up": {"uv": [8.5, 11.5, 10.5, 12.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [10.5, 11.5, 12.5, 12.5], "texture": "#0"} + } + }, + { + "from": [2, 1, -1], + "to": [8, 1, 1], + "faces": { + "up": {"uv": [0, 4, 1.5, 5], "texture": "#0"}, + "down": {"uv": [0, 4, 1.5, 5], "texture": "#0"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 225, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "scale": [0.5, 0.5, 0.5] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/twin_plate_press_working.json b/src/main/resources/assets/overdrive_that_matters/models/block/twin_plate_press_working.json new file mode 100644 index 000000000..96ab82259 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/twin_plate_press_working.json @@ -0,0 +1,293 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [64, 32], + "textures": { + "0": "overdrive_that_matters:block/plate_press2", + "1": "overdrive_that_matters:block/plate_press_piston", + "2": "overdrive_that_matters:block/piston_offset", + "particle": "overdrive_that_matters:block/plate_press2" + }, + "elements": [ + { + "from": [10, 0, 0], + "to": [16, 6, 16], + "faces": { + "north": {"uv": [5.5, 13, 7, 16], "texture": "#0"}, + "east": {"uv": [1.5, 13, 5.5, 16], "texture": "#0"}, + "south": {"uv": [7, 13, 8.5, 16], "texture": "#0"}, + "west": {"uv": [5.5, 13, 1.5, 16], "texture": "#0"}, + "up": {"uv": [0, 8, 1.5, 16], "texture": "#0"}, + "down": {"uv": [0, 8, 1.5, 16], "texture": "#0"} + } + }, + { + "from": [10, 10, 0], + "to": [16, 16, 16], + "faces": { + "north": {"uv": [5.5, 8, 7, 11], "texture": "#0"}, + "east": {"uv": [1.5, 8, 5.5, 11], "texture": "#0"}, + "south": {"uv": [7, 8, 8.5, 11], "texture": "#0"}, + "west": {"uv": [5.5, 8, 1.5, 11], "texture": "#0"}, + "up": {"uv": [0, 5, 4, 8], "rotation": 90, "texture": "#0"}, + "down": {"uv": [0, 8, 1.5, 16], "texture": "#0"} + } + }, + { + "from": [10, 6, 2], + "to": [16, 10, 16], + "faces": { + "north": {"uv": [5.5, 11, 7, 13], "texture": "#0"}, + "east": {"uv": [1.5, 11, 5, 13], "texture": "#0"}, + "south": {"uv": [7, 11, 8.5, 13], "texture": "#0"}, + "west": {"uv": [5, 11, 1.5, 13], "texture": "#0"} + } + }, + { + "from": [11, 6, 1], + "to": [15, 10, 2], + "faces": { + "north": {"uv": [4.25, 5, 5.25, 7], "texture": "#0"}, + "east": {"uv": [4, 5, 4.25, 7], "texture": "#0"}, + "west": {"uv": [5, 5, 5.25, 7], "texture": "#0"}, + "up": {"uv": [0, 0, 1, 0.5], "texture": "#missing"} + } + }, + { + "name": "screen", + "from": [11, 4, 2], + "to": [15, 8, 3], + "rotation": {"angle": 22.5, "axis": "x", "origin": [14, 13, -0.5]}, + "faces": { + "north": {"uv": [0, 0, 1, 2], "texture": "#0"}, + "east": {"uv": [3, 2, 4, 2.5], "rotation": 90, "texture": "#0"}, + "south": {"uv": [3, 0, 4, 2], "texture": "#0"}, + "west": {"uv": [3, 2, 4, 2.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [3, 2, 4, 2.5], "texture": "#0"}, + "down": {"uv": [3, 2, 4, 2.5], "texture": "#0"} + } + }, + { + "from": [1, 8, 3], + "to": [9, 15, 15], + "faces": { + "north": {"uv": [0, 2, 8.5, 15.9], "texture": "#1"}, + "east": {"uv": [14, 12.5, 11, 16], "texture": "#0"}, + "south": {"uv": [14, 12.5, 16, 16], "texture": "#0"}, + "west": {"uv": [11, 12.5, 14, 16], "texture": "#0"}, + "up": {"uv": [8.5, 5.5, 10.5, 11.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [10.5, 5.5, 12.5, 11.5], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [9, 0, 1], + "to": [10, 16, 3], + "faces": { + "north": {"uv": [5.5, 0, 5.75, 8], "texture": "#0"}, + "east": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "south": {"uv": [5.75, 0, 6, 8], "texture": "#0"}, + "west": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "up": {"uv": [5, 0, 5.25, 1], "texture": "#0"}, + "down": {"uv": [5.25, 0, 5.5, 1], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [9, 0, 13], + "to": [10, 16, 15], + "faces": { + "north": {"uv": [5.5, 0, 5.75, 8], "texture": "#0"}, + "east": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "south": {"uv": [5.75, 0, 6, 8], "texture": "#0"}, + "west": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "up": {"uv": [5, 0, 5.25, 1], "texture": "#0"}, + "down": {"uv": [5.25, 0, 5.5, 1], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [0, 0, 1], + "to": [1, 16, 3], + "faces": { + "north": {"uv": [5.5, 0, 5.75, 8], "texture": "#0"}, + "east": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "south": {"uv": [5.75, 0, 6, 8], "texture": "#0"}, + "west": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "up": {"uv": [5, 0, 5.25, 1], "texture": "#0"}, + "down": {"uv": [5.25, 0, 5.5, 1], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [0, 0, 13], + "to": [1, 16, 15], + "faces": { + "north": {"uv": [5.5, 0, 5.75, 8], "texture": "#0"}, + "east": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "south": {"uv": [5.75, 0, 6, 8], "texture": "#0"}, + "west": {"uv": [5.5, 0, 6, 8], "texture": "#0"}, + "up": {"uv": [5, 0, 5.25, 1], "texture": "#0"}, + "down": {"uv": [5.25, 0, 5.5, 1], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [9, 13, 3], + "to": [10, 15, 13], + "faces": { + "east": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [6, 1.5, 6.25, 6.5], "texture": "#0"}, + "down": {"uv": [6.25, 1.5, 6.5, 6.5], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [9, 1, 3], + "to": [10, 3, 13], + "faces": { + "east": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [6, 1.5, 6.25, 6.5], "texture": "#0"}, + "down": {"uv": [6.25, 1.5, 6.5, 6.5], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [0, 13, 3], + "to": [1, 15, 13], + "faces": { + "east": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [6, 1.5, 6.25, 6.5], "texture": "#0"}, + "down": {"uv": [6.25, 1.5, 6.5, 6.5], "texture": "#0"} + } + }, + { + "name": "cubeframe", + "from": [0, 1, 3], + "to": [1, 3, 13], + "faces": { + "east": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [6, 1.5, 6.5, 6.5], "rotation": 90, "texture": "#0"}, + "up": {"uv": [6, 1.5, 6.25, 6.5], "texture": "#0"}, + "down": {"uv": [6.25, 1.5, 6.5, 6.5], "texture": "#0"} + } + }, + { + "from": [2, 9, -1], + "to": [8, 9, 1], + "faces": { + "up": {"uv": [0, 4, 1.5, 5], "texture": "#0"}, + "down": {"uv": [0, 4, 1.5, 5], "texture": "#0"} + } + }, + { + "from": [1, 8, 1], + "to": [9, 9, 3], + "faces": { + "north": {"uv": [8.5, 15.5, 10.5, 16], "texture": "#0"}, + "east": {"uv": [11, 15.5, 10.5, 16], "texture": "#0"}, + "west": {"uv": [10.5, 15.5, 11, 16], "texture": "#0"}, + "up": {"uv": [8.5, 11.5, 10.5, 12.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [10.5, 11.5, 12.5, 12.5], "texture": "#0"} + } + }, + { + "from": [1, 14, 1], + "to": [9, 15, 3], + "faces": { + "north": {"uv": [8.5, 12.5, 10.5, 13], "texture": "#0"}, + "east": {"uv": [11, 12.5, 10.5, 13], "texture": "#0"}, + "west": {"uv": [10.5, 13, 11, 13.5], "texture": "#0"}, + "up": {"uv": [8.5, 11.5, 10.5, 12.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [8.5, 11.5, 10.5, 12.5], "texture": "#0"} + } + }, + { + "from": [8, 9, 1], + "to": [9, 14, 3], + "faces": { + "north": {"uv": [8.5, 13, 8.75, 15.5], "texture": "#0"}, + "east": {"uv": [11, 13, 10.5, 15.5], "texture": "#0"}, + "west": {"uv": [10.5, 13, 11, 15.5], "texture": "#0"} + } + }, + { + "from": [1, 9, 1], + "to": [2, 14, 3], + "faces": { + "north": {"uv": [10.25, 13, 10.5, 15.5], "texture": "#0"}, + "east": {"uv": [11, 13, 10.5, 15.5], "texture": "#0"}, + "west": {"uv": [10.5, 13, 11, 15.5], "texture": "#0"} + } + }, + { + "from": [1, 0, 3], + "to": [9, 7, 15], + "faces": { + "north": {"uv": [0, 2, 8, 16], "texture": "#2"}, + "east": {"uv": [14, 12.5, 11, 16], "texture": "#0"}, + "south": {"uv": [14, 12.5, 16, 16], "texture": "#0"}, + "west": {"uv": [11, 12.5, 14, 16], "texture": "#0"}, + "up": {"uv": [8.5, 5.5, 10.5, 11.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [10.5, 5.5, 12.5, 11.5], "texture": "#0"} + } + }, + { + "from": [8, 1, 1], + "to": [9, 6, 3], + "faces": { + "north": {"uv": [8.5, 13, 8.75, 15.5], "texture": "#0"}, + "east": {"uv": [11, 13, 10.5, 15.5], "texture": "#0"}, + "west": {"uv": [10.5, 13, 11, 15.5], "texture": "#0"} + } + }, + { + "from": [1, 6, 1], + "to": [9, 7, 3], + "faces": { + "north": {"uv": [8.5, 12.5, 10.5, 13], "texture": "#0"}, + "east": {"uv": [11, 12.5, 10.5, 13], "texture": "#0"}, + "west": {"uv": [10.5, 13, 11, 13.5], "texture": "#0"}, + "up": {"uv": [8.5, 11.5, 10.5, 12.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [8.5, 11.5, 10.5, 12.5], "texture": "#0"} + } + }, + { + "from": [1, 1, 1], + "to": [2, 6, 3], + "faces": { + "north": {"uv": [10.25, 13, 10.5, 15.5], "texture": "#0"}, + "east": {"uv": [11, 13, 10.5, 15.5], "texture": "#0"}, + "west": {"uv": [10.5, 13, 11, 15.5], "texture": "#0"} + } + }, + { + "from": [1, 0, 1], + "to": [9, 1, 3], + "faces": { + "north": {"uv": [8.5, 15.5, 10.5, 16], "texture": "#0"}, + "east": {"uv": [11, 15.5, 10.5, 16], "texture": "#0"}, + "west": {"uv": [10.5, 15.5, 11, 16], "texture": "#0"}, + "up": {"uv": [8.5, 11.5, 10.5, 12.5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [10.5, 11.5, 12.5, 12.5], "texture": "#0"} + } + }, + { + "from": [2, 1, -1], + "to": [8, 1, 1], + "faces": { + "up": {"uv": [0, 4, 1.5, 5], "texture": "#0"}, + "down": {"uv": [0, 4, 1.5, 5], "texture": "#0"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/piston_offset.png b/src/main/resources/assets/overdrive_that_matters/textures/block/piston_offset.png new file mode 100644 index 0000000000000000000000000000000000000000..227dde8cbe3dd52b206010e8ef08bfa3ce2c018d GIT binary patch literal 633 zcmV-<0*3vGP)4Tx04UFukvT{MK^TQU6Gail!iXXkTSO}bQ4vdtVh|K0M(`@!-Iyq3H(@uy z#!|2iSa>vEg^jhg7Pf*Qcz{@1St;6xtp99;1R;V0!+gA%_n3JDfrGSZxz)X3**PZ` zjcBuT^IGjQ^|a7PD`DMqvy;j;96aABAHnFAPl7rju@ z!u!y)0cV#b&De(XO=x?_>W=P9L79PM5?)W_o93YT8tNB{z5VQSd4y8n&$)oc4ltSF%sGX&`#f>2ePN-gLpnP4pvts}6fJ=O@> zxaT1bPvY+gLN+cvf&1z3B%aB_LmXw`PW|-|N6F2{o?G|1^*-rgg0&FN{!8Qo$czRZ Tfy|zj00000NkvXXu0mjf&choB literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/piston_offset.png.mcmeta b/src/main/resources/assets/overdrive_that_matters/textures/block/piston_offset.png.mcmeta new file mode 100644 index 000000000..55c29419e --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/textures/block/piston_offset.png.mcmeta @@ -0,0 +1 @@ +{ "animation": { "frametime": 2 } } \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/plate_press2.png b/src/main/resources/assets/overdrive_that_matters/textures/block/plate_press2.png new file mode 100644 index 0000000000000000000000000000000000000000..dbe92085b9df466609ecebaff915844cca384ee6 GIT binary patch literal 717 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3-p)I`?e@QjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`?E`#5T>sx-`2WCDOiXMm1H*p?hJ=KKqN1YQrv8wSkhIDcZEbB+Q&TlH zwfg${_V)J1Su4u>XRn>>GtboY*p_gh8NajJCjcqYk|4j}|5yNn_RZQ?Kn0uy9+AZi z415Pcm~qF%?6*M2ee-m24Ds+@I<>c~S%JsxEq_zP;;8%oBfr;rvfK*3{_RcJ!ClX! zlr|(<@E(?oSvS3#Sz3az`cZk4NyFaHlNk@bT+;MB#>Gj)iIf)_n)N`iJ zhtUb|)voZn@;r1f=-d6ELuZl%@5>%s~pnBrK zfxbiA=N0Q8NS3>>TWo#PlnMzZRW66L*0#xW|G1@aBI3Jd_(5^Wf=8+EZv<~xW7MK=^x#Tsf?T>xBhzYqGroh5 zw8S#6@N8I7;K6oz+sl$)ZUQQdrym3+DF0Z^rs?l!%;By7KyJnEfPPo0pk|K7)D7!i zUtwWN`tsA_drX$q!n6Zl&HHjU=d?uLSUmOBrtJm$?w{vhZgy!`^|SW>ZBil%w?kPB zpW1~vJ$1V6AZ+9B+>j6{#+7hEQT{#UiDh9~({X20fVw?3!A7T>jXTBGP% tCU)uQbH7^O-TI)o>*K4n(_21p2X2a+C->sYbzrh!@O1TaS?83{1OP{8I?Vt8 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/plate_press_piston.png b/src/main/resources/assets/overdrive_that_matters/textures/block/plate_press_piston.png index 2cf5fac10e171f43aa3e46b82e873d001c89c4d7..ea816cbe7f7057f966c279a448249f9aefd4dfbc 100644 GIT binary patch literal 633 zcmV-<0*3vGP)4Tx04UFukvT{MK^TQU6Gail!iXXkTSO}bQ4vdtVh|K0M(`@!-Iyq3H(@uy z#!|2iSa>vEg^jhg7Pf*Qcz{@1St;6xtp99;1R;V0!+gA%_n3JDfrGSZxz)X3**PZ` zjcBuT^IGjQ^|a7PD`DMqvy;j;96aABAHnFAPl7rju@ z!u!y)0cV#b&De(XO=x?_>W=P9L79PM5?)W_o93YT8tNB{z5VQSdgk)3JT)Ag4lJ5x1pb56~3>V2A{fVBc{{#SD<$O+lgz~BHMDtiVU TY1zEh00000NkvXXu0mjfl))KC literal 621 zcmV-z0+RiSP)EX>4Tx04R}tkv&MmKpe$iQ$;B)4ptO#$WWauh>AE$6^me@v=v%)FuC*#nlvOS zE{=k0!NHHks)LKOt`4q(Aou~|=;Wm6A|?JWDYS_3;J6>}?mh0_0Yam~RI_UWP&La) z#baVNw<`9$B7gyeFo=l6Og)ia%)oPe-NVP%yC~1{KKJJcDS49tK9P8i>4rtTK|Hf* z>74h8!>lAJ#OK8023?T&k?XR{Z=8z`3p_JyWK#3QVPdh^!Ey()lA#h$6Gs$PqkJLj zvch?bvs$UK);;+PgL!Qw&2^e1h+_!}Bq2gZ4P{hdAxf)8iis5M$2|PQjz38*nOtQs zax9<<6_Voz|AXJ%nuV!JHz^ncx?gPjV-)Dw1)6o+{yw(t<_X|`2ClTWzuEw1KS{5* zwa5|Bw+&oew>5bWxZDATo^;8O9LY~pC=`JAGy0|+(0>aA*4*A&`#607GSt=b4RCM> zj1?(+-Q(T8oxS~grq$mMkhyZRVnLd70000IP)t-s0001BU|=;hHGhA978Vu&004AB zLLC4A00DGTPE!Ct=GbNc0004EOGiWihy@);00009a7bBm000id000id0mpBsWB>pF z2XskIMF-{z77!)??DJxY0000)NklXMR8mqDU;qMPVPj!1Ls3vrPyxhHadB}W z#1H{8z`AH?j<7Mr9A%)00s)f;#2kcy7*aqR1nF)L9m59zX1FZrCB7%H00000NkvXX Hu0mjfBHj5I From 5b6a6513407a3f492d7fd9e5a392e27c98b75187 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Mon, 26 Jun 2023 09:10:21 +0300 Subject: [PATCH 0657/1199] plate press block shape 2 --- .../mc/otm/shapes/BlockShapes.java | 61 ++++++++++++++----- .../mc/otm/block/tech/PlatePressBlock.kt | 2 +- 2 files changed, 47 insertions(+), 16 deletions(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java index 87609a632..55402a469 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java +++ b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java @@ -380,21 +380,52 @@ public class BlockShapes { ); public static final BlockShape PLATE_PRESS_IDLE = new BlockShape( - new SimpleCuboid(0d, 0d, 0d, 1d, 0.5d, 1d), - new SimpleCuboid(0d, 0.5d, 0.4375d, 1d, 0.75d, 1d), - new SimpleCuboid(0.75d, 0.5d, 0.0625d, 1d, 0.75d, 0.4375d), - new SimpleCuboid(0.125d, 0.5d, 0.25d, 0.6875d, 1d, 0.8125d), - new SimpleCuboid(0.8125d, 0.5d, 0d, 0.9375d, 0.75d, 0.0625d), - new SimpleCuboid(0.9375d, 0.75d, 0.9375d, 1d, 0.875d, 1d), - new SimpleCuboid(0d, 0.75d, 0.9375d, 0.0625d, 0.875d, 1d), - new SimpleCuboid(0.01875d, 0.8125d, 0.0625d, 0.05d, 0.875d, 0.9375d), - new SimpleCuboid(0d, 0.5d, 0d, 0.0625d, 0.875d, 0.0625d), - new SimpleCuboid(0.0625d, 0.8125d, 0.95d, 0.9375d, 0.875d, 0.98125d), - new SimpleCuboid(0.6875d, 0.5d, 0.5625d, 0.75d, 0.875d, 0.75d), - new SimpleCuboid(0.6875d, 0.5d, 0.3125d, 0.75d, 0.875d, 0.5d), - new SimpleCuboid(0.0625d, 0.5d, 0.3125d, 0.125d, 0.875d, 0.5d), - new SimpleCuboid(0.0625d, 0.5d, 0.5625d, 0.125d, 0.875d, 0.75d), - new SimpleCuboid(0.775d, 0.75d, 0.125d, 0.9625d, 0.9375d, 0.875d) + new SimpleCuboid(0.625d, 0d, 0d, 1d, 0.375d, 1d), + new SimpleCuboid(0.625d, 0.625d, 0d, 1d, 1d, 1d), + new SimpleCuboid(0.625d, 0.375d, 0.125d, 1d, 0.625d, 1d), + new SimpleCuboid(0.6875d, 0.375d, 0.0625d, 0.9375d, 0.625d, 0.125d), + new SimpleCuboid(0.0625d, 0.5d, 0.1875d, 0.5625d, 0.9375d, 0.9375d), + new SimpleCuboid(0.0625d, 0d, 0d, 0.5625d, 0.4375d, 1d), + new SimpleCuboid(0.5625d, 0d, 0.0625d, 0.625d, 1d, 0.1875d), + new SimpleCuboid(0.5625d, 0d, 0.8125d, 0.625d, 1d, 0.9375d), + new SimpleCuboid(0d, 0d, 0.0625d, 0.0625d, 1d, 0.1875d), + new SimpleCuboid(0d, 0d, 0.8125d, 0.0625d, 1d, 0.9375d), + new SimpleCuboid(0.5625d, 0.8125d, 0.1875d, 0.625d, 0.9375d, 0.8125d), + new SimpleCuboid(0.5625d, 0.0625d, 0.1875d, 0.625d, 0.1875d, 0.8125d), + new SimpleCuboid(0d, 0.8125d, 0.1875d, 0.0625d, 0.9375d, 0.8125d), + new SimpleCuboid(0d, 0.0625d, 0.1875d, 0.0625d, 0.1875d, 0.8125d), + new SimpleCuboid(0.125d, 0.5625d, -0.0625d, 0.5d, 0.5625d, 0.0625d), + new SimpleCuboid(0.0625d, 0.5d, 0.0625d, 0.5625d, 0.5625d, 0.1875d), + new SimpleCuboid(0.0625d, 0.875d, 0.0625d, 0.5625d, 0.9375d, 0.1875d), + new SimpleCuboid(0.5d, 0.5625d, 0.0625d, 0.5625d, 0.875d, 0.1875d), + new SimpleCuboid(0.0625d, 0.5625d, 0.0625d, 0.125d, 0.875d, 0.1875d) + ); + + public static final BlockShape TWIN_PLATE_PRESS_IDLE = new BlockShape( + new SimpleCuboid(0.625d, 0d, 0d, 1d, 0.375d, 1d), + new SimpleCuboid(0.625d, 0.625d, 0d, 1d, 1d, 1d), + new SimpleCuboid(0.625d, 0.375d, 0.125d, 1d, 0.625d, 1d), + new SimpleCuboid(0.6875d, 0.375d, 0.0625d, 0.9375d, 0.625d, 0.125d), + new SimpleCuboid(0.0625d, 0.5d, 0.1875d, 0.5625d, 0.9375d, 0.9375d), + new SimpleCuboid(0.5625d, 0d, 0.0625d, 0.625d, 1d, 0.1875d), + new SimpleCuboid(0.5625d, 0d, 0.8125d, 0.625d, 1d, 0.9375d), + new SimpleCuboid(0d, 0d, 0.0625d, 0.0625d, 1d, 0.1875d), + new SimpleCuboid(0d, 0d, 0.8125d, 0.0625d, 1d, 0.9375d), + new SimpleCuboid(0.5625d, 0.8125d, 0.1875d, 0.625d, 0.9375d, 0.8125d), + new SimpleCuboid(0.5625d, 0.0625d, 0.1875d, 0.625d, 0.1875d, 0.8125d), + new SimpleCuboid(0d, 0.8125d, 0.1875d, 0.0625d, 0.9375d, 0.8125d), + new SimpleCuboid(0d, 0.0625d, 0.1875d, 0.0625d, 0.1875d, 0.8125d), + new SimpleCuboid(0.125d, 0.5625d, -0.0625d, 0.5d, 0.5625d, 0.0625d), + new SimpleCuboid(0.0625d, 0.5d, 0.0625d, 0.5625d, 0.5625d, 0.1875d), + new SimpleCuboid(0.0625d, 0.875d, 0.0625d, 0.5625d, 0.9375d, 0.1875d), + new SimpleCuboid(0.5d, 0.5625d, 0.0625d, 0.5625d, 0.875d, 0.1875d), + new SimpleCuboid(0.0625d, 0.5625d, 0.0625d, 0.125d, 0.875d, 0.1875d), + new SimpleCuboid(0.0625d, 0d, 0.1875d, 0.5625d, 0.4375d, 0.9375d), + new SimpleCuboid(0.5d, 0.0625d, 0.0625d, 0.5625d, 0.375d, 0.1875d), + new SimpleCuboid(0.0625d, 0.375d, 0.0625d, 0.5625d, 0.4375d, 0.1875d), + new SimpleCuboid(0.0625d, 0.0625d, 0.0625d, 0.125d, 0.375d, 0.1875d), + new SimpleCuboid(0.0625d, 0d, 0.0625d, 0.5625d, 0.0625d, 0.1875d), + new SimpleCuboid(0.125d, 0.0625d, -0.0625d, 0.5d, 0.0625d, 0.0625d) ); public static final BlockShape GRAVITATION_STABILIZER = new BlockShape( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt index 2a9b889ec..01810fb82 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt @@ -57,7 +57,7 @@ class PlatePressBlock(properties: Properties = DEFAULT_PROPERTIES, val isTwin: B MatteryWorkerBlockEntity.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) } - private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.PLATE_PRESS_IDLE.rotateFromNorth(it[rotationProperty]).computeShape() } + private val shapes = getShapeForEachState(rotationProperty) { (if (isTwin) BlockShapes.TWIN_PLATE_PRESS_IDLE else BlockShapes.PLATE_PRESS_IDLE).rotateFromNorth(it[rotationProperty]).computeShape() } @Suppress("override_deprecation") override fun getShape( From 23dc91fb554280ddfabda892f6315e9210cb7818 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Mon, 26 Jun 2023 09:58:51 +0300 Subject: [PATCH 0658/1199] use vanilla water/lava textures for cobblegen --- .../mc/otm/registry/MBlockColors.kt | 33 +++++++++++ .../dbotthepony/mc/otm/registry/MRegistry.kt | 1 + .../models/block/cobblestone_generator.json | 55 ++++++++---------- .../textures/block/lava_still.png | Bin 6540 -> 0 bytes .../textures/block/lava_still.png.mcmeta | 45 -------------- .../textures/block/water_still.png | Bin 5409 -> 0 bytes .../textures/block/water_still.png.mcmeta | 5 -- 7 files changed, 59 insertions(+), 80 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockColors.kt delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/lava_still.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/lava_still.png.mcmeta delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/water_still.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/water_still.png.mcmeta diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockColors.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockColors.kt new file mode 100644 index 000000000..648c9a94d --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockColors.kt @@ -0,0 +1,33 @@ +package ru.dbotthepony.mc.otm.registry + +import net.minecraft.client.renderer.BiomeColors +import net.minecraft.core.BlockPos +import net.minecraft.world.item.ItemStack +import net.minecraft.world.level.BlockAndTintGetter +import net.minecraft.world.level.block.state.BlockState +import net.minecraftforge.client.event.RegisterColorHandlersEvent +import net.minecraftforge.eventbus.api.IEventBus + +object MBlockColors { + private const val DEFAULT_WATER_TINT: Int = 0x3F76E4; + + private fun registerBlockColors(event: RegisterColorHandlersEvent.Block) { + event.register({ state: BlockState?, light: BlockAndTintGetter?, pos: BlockPos?, index: Int -> + if (index == 0) { + if (light == null || pos == null) DEFAULT_WATER_TINT + BiomeColors.getAverageWaterColor(light!!, pos!!) + } else -1 + }, MBlocks.COBBLESTONE_GENERATOR) + } + + private fun registerItemColors(event: RegisterColorHandlersEvent.Item) { + event.register({ stack: ItemStack?, index: Int -> + if (index == 0) DEFAULT_WATER_TINT else -1 + }, MBlocks.COBBLESTONE_GENERATOR) + } + + internal fun register(bus: IEventBus) { + bus.addListener(this::registerBlockColors) + bus.addListener(this::registerItemColors) + } +} 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 de5c7a32d..391200982 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -223,6 +223,7 @@ object MRegistry { LootModifiers.register(bus) MItemFunctionTypes.register(bus) MLootItemConditions.register(bus) + MBlockColors.register(bus) MRecipes.register(bus) diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/cobblestone_generator.json b/src/main/resources/assets/overdrive_that_matters/models/block/cobblestone_generator.json index f296349d7..1e9f62a3c 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/cobblestone_generator.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/cobblestone_generator.json @@ -4,9 +4,9 @@ "texture_size": [32, 64], "textures": { "0": "overdrive_that_matters:block/cobblestone_generator", - "1": "overdrive_that_matters:block/lava_still", - "2": "overdrive_that_matters:block/water_still", - "particle": "overdrive_that_matters:block/cobblestone_generator" + "particle": "overdrive_that_matters:block/cobblestone_generator", + "lava": "block/lava_still", + "water": "block/water_still" }, "elements": [ { @@ -42,19 +42,6 @@ "up": {"uv": [0, 6.25, 7, 7], "rotation": 90, "texture": "#0"} } }, - { - "name": "water", - "from": [12, 6, 1.1], - "to": [14.9, 14.9, 14.9], - "faces": { - "north": {"uv": [6.5, 7, 7.5, 9], "texture": "#2"}, - "east": {"uv": [0, 7, 6.5, 9], "texture": "#2"}, - "south": {"uv": [14, 7, 15, 9], "texture": "#2"}, - "west": {"uv": [7.5, 7, 14, 9], "texture": "#2"}, - "up": {"uv": [7.5, 7, 6.5, 3.75], "texture": "#2"}, - "down": {"uv": [8.5, 3.75, 7.5, 7], "texture": "#2"} - } - }, { "from": [15, 6, 1], "to": [12, 15, 15], @@ -75,20 +62,6 @@ "up": {"uv": [0, 6.25, 7, 7], "rotation": 270, "texture": "#0"} } }, - { - "name": "lava", - "from": [1.1, 6, 1.1], - "to": [4, 14.9, 14.9], - "faces": { - "north": {"uv": [6.5, 4, 7.5, 6], "texture": "#1"}, - "east": {"uv": [0, 4, 6.5, 6], "texture": "#1"}, - "south": {"uv": [14, 4, 15, 6], "texture": "#1"}, - "west": {"uv": [7.5, 4, 14, 6], "texture": "#1"}, - "up": {"uv": [7.5, 4, 6.5, 0.75], "texture": "#1"}, - "down": {"uv": [8.5, 0.75, 7.5, 4], "texture": "#1"} - }, - "forge_data": { "block_light": 15, "sky_light": 15 } - }, { "from": [4, 6, 1], "to": [1, 15, 15], @@ -98,6 +71,28 @@ "south": {"uv": [8.5, 4, 7, 6.25], "texture": "#0"}, "up": {"uv": [0, 6.25, 7, 7], "rotation": 90, "texture": "#0"} } + }, + { + "name": "lava", + "from": [1.1, 6, 1.1], + "to": [4, 14.9, 14.9], + "faces": { + "north": {"uv": [12, 1, 15, 10], "texture": "#lava"}, + "south": {"uv": [1, 1, 4, 10], "texture": "#lava"}, + "west": {"uv": [1, 1, 15, 10], "texture": "#lava"}, + "up": {"uv": [4, 15, 1, 1], "texture": "#lava"} + } + }, + { + "name": "water", + "from": [12, 6, 1.1], + "to": [14.9, 14.9, 14.9], + "faces": { + "north": {"uv": [1, 1, 4, 10], "texture": "#water", "tintindex": 0}, + "east": {"uv": [1, 1, 15, 10], "texture": "#water", "tintindex": 0}, + "south": {"uv": [12, 1, 15, 10], "texture": "#water", "tintindex": 0}, + "up": {"uv": [15, 15, 12, 1], "texture": "#water", "tintindex": 0} + } } ], "display": { diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/lava_still.png b/src/main/resources/assets/overdrive_that_matters/textures/block/lava_still.png deleted file mode 100644 index e62298cefbcc9c06013871e8d1564113a566615b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6540 zcmV;78FS`|P)jo z{@eZ41v~GavvcF@15cf?XUpP!Pb}Yl!}RSp&D{6+@M5^ZdE(AHXYc);Q{H>%Bxe5niW7Oxa=-k?FMs+k*ZlG)R~43V4PJ0=xGw1BQ zYYtl-d}bv_Vnv2=RPIZpzilRebF*j5k`Mp%3rByvYVRXUk!{a|i$DI+=Ig6Rwp}}waV-C{i;w4*i!nI^8el3SZM$yt zz_(Vs|NZm!{MHhTz=?l;`H4Jd=xdi%?QNJ<4t;ke3jXj*N zyv+2%U0XQrZN;8|K|nAu_QZSvj2Yl4&E}FSE#$N z9UEzB40+_wE@B#MBT_8$r71|u07c?eVVp+b+#kJsDc0dn?ZvCO$&J(4lZzWPTiA|; zn`X!7zkAPIyyK14Bdm&|(P@;iZqz47U%8^7M=nmoNmw$+z4&+qP+F#;7=F=dERDA^ zn$sM4=@PbLA6~E?hGP!m;cVy-Z$%2G6->hj_T_NAU=1eo#AEP0c-S-#+sE_4gUCR1 zrI>6W+dInt0f`anAPjGgxcyW6Riw zIf(Q>d&WQho69pnO$QR!jUqbe0StIv!^7BAtaSA6R&n9vIYR`!Z6-QlF@E%IktU-;~izqn-Y!zUx#?(qeX2x?`MDC3c(v9zwCX7@h&8Blxll`8?p8*4^51LO1* zot)poiO~R4BhvMw&;)`qjtPuoAJr;H1rO--@DDx*B#??Ff3bc#LN+{Hc-)&`o)Z1M zazzl22)H-vfjFL`E@aiu@J$TD4y^sFe_!|UUw=`kfSKZs?8W77ti)&$3?7h{0k|V` zat2u=)O6cSe2J}eK3xqNIv#kA6b1P>G;(u#JxV-q!vu61Jd90siC7u{L4(Y}w~$Iq zGlxNJ%QRL&RIJ3zkTK_AUoI5IdPp3R){X?zV^c8#C_Vhb`S^vr->5Ri|LOuZVJjmB z6PW46^0*e34j!1mrg4ppvl(jas5~+kM>_EPr$>#q%s>R>3AZu`NgTR;{WNsXG4Rvs zIOae5;1aGs+-zVgUlUb^phKO-K9T4;>JpeVIp5`CXo&eR;>`f2;W zajNFS7sNw$zGtq!$bDD?d*P&k!L?I)y6fJ#66Q}YI{wY8MmR3+?dZ5S2gf2jLX}b- zzbu^ab4B2Wvw>`uFw*4=$R{L1Z_k~}p9me+s5&*~i;#$fxW?Rs`{&Oipm5KG1l0!? z$uXdZEBOc_A)?6uR~Q6v4dKBc{Z`Eon80$G0LoB*gt=`dYlDYQ-Qt01NWsjIF$)U` zCh*Iuio}&ThMzvNl;uz+_aQRuAgd-oJ-vd(SRzpm4z3ag4>j1KlDK#L6p|dDA3Qv? zL~yHyWJVR!T)aY_a4WBQD(M?|jQDZ#EsMDlZE@j8mI8fbE4n_y8TOJdZA`w@@eoI< z41_m?1Vp{0V6X|DiTY|&Ch(S!$tDpg$gEPbwX$M9R_eSWPitScEh<=TB#^#%A!adO zLN>Ny33aGq3Y)4{^oSUr{_C}*FGz*4;~+J_x}q{C!3umg&X&4Efuv7c7Mm|6MpjAm z&NyF$e(v1l4R_B;zI0>DmjDA7H!ub6!%!AY3dizr1dlkDzMxkN354Ml%dwUbEF>Tw zG7j}KSz5>u>sI{o7K6BX;&g8`SYTKv80DMr7G%pNXSBuxRkkv`9Q-14psvS z^N|M$*&)n_!3h)So1+_}Sd7;O*`#(=jb?2%(X9*>>7QO9Rfz|+%s8Y%RK#Psdg#07 z7$M{Ik1gYMqF|*hL{doffk%s$V*CtsZk%lrG$e1-_K1XUR%ZCM-& zTstBog}^-nPxEf`Lbftm@+Z$3s>VzY6M+a>@)YY?bJTokImj~e<0MQ&JP0NLR3u(7 z&h&$Q&bH}$CA*f6w9R*3*;$vHfg{5Vf|`<59=bT%(cmRt?OlVYG(vxoupk_oaf zqO)fL?D%{&+3;Wp)I*JyNiwT)*hC*mjIAkKBV&$_UzkTDoB5J>z~m?ZA?3_4UwG-M zGkC-r>}axWLSqh!n{g8HkVC6b=^np8Bx80m=9;4^JqC#{v4en~D4KErLq9f>4m%!L zF>xCAW==}3EsJFkt!o0pKH|Xuz)_R)fgvsqr(Ic$39_4B*lMt`sbM}IAsH4x_fnNC zsGB4vY+jfURWt6!e7u%%dud=PXb@8$@>RUm#9ItFR956lKp=0Zq-f%uj4X9VP1~8x zXe$|B$LDL>*f~>1oH)ZHOOc2B;GxE{46O=~5Lj`jc&*uAE2+n(CP#bf3>Df7GF-um zpmgZ)g3(DjYtheqk*TGPosI5QqNR%oEX&JWIq0T&=JirZG0+>BS&u9QdSjfat5l+I zYr7)wB(Ls5JhArEM?x@_7J|5l@tw2qi-5SM!a6DW5*M3TDH_X@!o@%nkHjvEA&C)) zZBalFTiGdeZxl7)Cf_05sAjgKVmXSa79TMjFPNw9jKl(!g#|Zq;_zH4WXWcb9wh>6 ze$~SO4-k6=kmB(wgM7(?{Go>>pnEf&>C?B71PaqCY2H(^_Q4^7>uRW88S(Et;~0|KA}5f^)} z9kEEs1kaQ}S`$8_fz%`(!RFhz;2?hwz;M@|W8*FR0ap%q!V;lW(NgqW>ZPs-`M z7$U8nR`gRQ@S2ru5pX^&rQYNl)g3Lx^;hRYFt$d6ra$7_(;J6ax5(JqKPlYTPj22S z9@dW7aFJ&tk}U|^Gq!Ye(uRlCBbWk{nY-uE@)AKHNmV4*%? zt!o%tlV8--!&H-nm>dN{#=xyreK)q=oIH!|ku!eU@o?MBB)VDYfki#tH2pz<&ahHe zgX`AQ6XQSvp_bX|DtMSEb;X16GUYyWuX`pVt5Ku(TzVqN9NwC}20*$1o63Yn14+N< z4ZJe=CdP@zcyi4iO@dPx*95$uzUuwKE)EOLO!QgIJLKb{`pvP@VOiZ; zDrv8*4jwG24L>1cruOXGc7&XO^uc;nC}W^T&r=lLVnqM5ZES&Qlo1cIbu>S!)DP1~-Dt2~`Q%~&#l|AeUUPaLS-8dtHIW5bTkg9i?Jpf;fd zp$h1DNaJhsLMGVnXaGtLUJFr+BORNCw18gNJCP{|bW&3hDGV(oG}bPN@zQ2(s1jkU zE?HjRG#1*oG@a{sNcw|cNEWOo*)%*DmPyZCaP`DLm?A9q`S3lRPHxLwm8B#2#JqKyR6lm zkH1kCXbLse^e6p1%I)gy=8P6}!RG3b;@5&?^it~Tkq+pFhs&ZL{XY}@mLLsw1No;K zGsR7+P`RU3iaq&~;yHu%l3m1u303KK@wN6s03FFxsyA%7ic!9|GVwgCP=l343fi15Qk>8Ddj%;vXU zMQF_WE{4 zFgkf1+N^yR#-KVnD!~KAS`u_q`?Vu2-KBng=4{p93ZS}5dvg4GQa*VxH$><_b2CMTqJb z&<22}C0)&8#Q4{iuhQGT^)NYf&@-_$MwE_Rh~EPf9~eY=(Gm0(P3xC5@zwhc=n!QF z4@^kfR{ME&6HHIK1XaHpH9K%bkZHu{h2Kpq0s8k>5uXy@{9pJgz0G=xAsnG) zgw>1l6^!(UcRkI~SS-vt_?+IJ9p;XQbk=26UZ=8}(3lx!s|HQ5YKolfp6xI*-8yvV z*7At%t;zc)iE&EL@_zbgA8aRD=TeS!TPwidxM~U?KVSReiQK%tW`v9H#@lb6v6H;& z$z|`{nJ)mLv!|9He)0TW4=yUNUUC8-dw9*D*H>j4uXjJZaU$pc(mj8SuDoIK5oLpx2~DW zJ);@K4Qn|$?5)K7@`z=Sfh7>YvvKic{~w&;fWkj0c&Y0YU{zjo(>0d$He{6~YZD4p_`(AG^U*7pu${~6PC9AkR3k)h zYev{Ghwkdv3%uBt*TMt6>8eOE2@hQT=xocL*bCYC6X(Sm=&;}vjEnQ}sjTjXnb8l{ z&4j!7?mS)nYWr%3P4hVZzNb%f4)U;)?%;_%Si?i;=+>FMb_7occ&H959@tid#JySA ztvydaamNEg_ikM#NGcx2Mm?@B&CLIg2baqPrDR`$t4GB#>k&1grcl&Lc#u8<(W*-4 zU?RLr3l8C-I*bbFc+fIv0zh*Hlo^OJfxGzgy5ND=TppnF8fFm>%?^y<4@5@+++Y*L z@J~HLEjPoVP)UkM2%5?FFT@e>Z7d^>6_~dGv%p`-E$6VFrr-&lgY8|_2?z{$8Xlm^ zY_+N>-u1eP1`4=qPVm4#AHIA6C+lc*H)*^%eBCNBPCX3pPz~3q$qOlzIfzqeE^WzZ zB;;aS_CyDa<`)HUq)ZSGVoEPSdS0UtC+x6Ia@7>i)6Re)x#S35<9tkDv@Y$X^A?n) zy>ysk@ZcbIsymmcuX=!^rpsS?QYR37K1$NjVJ<-1Wf2 zJtNeQreqcTSIo2>7{MuxCP*KPZki{R@X7-Sud3D!v&2_K#}V$Cn}AfOVQ(e$O6a(M zVezRt^*8_D)y*@4<0qF5@UUitw>&8khS$%YnXOi}xF&|WbyWjb@SrLW|L{D{)Pl`K zDx%VuqYDe`(!8yrKEhP-26(7;)DD9khVc+2RG;A;drByX&9CkhJm}$O9L5{op%5pi z;vRe>lImxWWN5Cz1o5B?cV!f{!KSKf7!N&~nY8dEt|1cGL{jP@bQljj0f5*vnAQzL zdmCm6NE3)-@Sw(`C7r%guUdyH#r`lJWS~iS&|wUU9GW>2iZON)9t419@)-W9W$?F9 z#D?S}!2@^bQGRDJ(>tT184DXu!b8t0V>0sFtx1S==AG#+XCL0WP%*g`4}!r1;K`UW z>GA{~vM#v>3O19B`YTiDf^21iCDDrq4%6^pSQ&PK9aF$vb*PSIF4P%CH|c)K6GYIU z#WY1TcZedrjOGOGAWjB&7|tq*`0m`(SgnzO()ZQRRlho5j=J}po~q$N$ZJ}c)Sxcx z0ZgT02h&>l(4eo6$P^xL5*~PAYR)nVHUPTj``TCn*Y+`7rxO`Abh0VQ(eM0ILI&AUyl8P!ad+Y?KdmEF`elaYhuUkui9#n_%pean;26*Td zf)$~mRt37P8lQ}Zid~jK@pz&8B%P} zH?~GJw88+8X&$EM=f#2% zB}n(fcn~_hjMBaZ12xE3-|k8HF?di>$y>#PCBUGhxo?3HzT?3xC7lx%>t#rD()H6R z6IqY7hVc*`r0^TUgVD(X1`IK$aoz+N26*W05do;NO>V>Ol_I3wVjg4Z6iTcqvUo5h z&=n@(!DXU{hnHYilbF`HqWM;{T=UfI(6ynWv~g>-RFCX<(7}r7Z_D;8P^B${P)~ZD zkh~Sc8CpzQJ05y)aK5dPh6nyo>-v(r8RRv*oglfibk8#f4A^Ui*%4>22<>UphKJrB zX;pEpuZ)~@*HB&OvZ9%L?Pf7;>&7`~R)x0KV~=RPcPiE#ZGau%0mGpskJuZm9S^gRAE~A&ioPNAX1-L;?0_C!CA=NhQSBmg>#b9OEfP>nF?fUJdrM2Hg z2dj!`7zCL*vN`Al|0&TPd&TAv_Y0razsFV&K}QK#q!PaFa09HHbwEI=*Ju}|*Zj0(tzuLGp z_t^nV_QI=mSC7HNL?zXtXbN?kXJakv_V*Y(SOVh*#Xc|R!^RRvYs!s{4&#B}bUA61 zvv$M7y3yW{LNh5LHqGlk-}JdZj0d?&a89)=SI@eu#5(i%s40oB}F zcS;8I;3Cm%t!|FhYIyJ&M~pgy)z=mum(1Fdl4+dKh<(u3ox;S2{$|_&sa3!r;=e*&Icq)84Kx zo%@;7o3)11UfXm$M6Hl`uP6BWHwh0zfmE3jc5UVf7bAm)?+wFVaKsN@Jiqkv3G51* z_R(et58kkR0MzjycCDL^{OCeUh+g`zCnip%I0+A&p?<_lz-CV2OvWijIfjI?mLpm1Rbn;qRI~LF*IH y1i?;C|Ni3{ZDCZwqV0000x^}o?S6z`gyX$)WbxVh$a z@6WI8h%okaF4W?xpQ13b*yDC1W6feKGtnw_&)wnb#jl@5fc_5pTB&I`_FI;`x6ZnZ zdFs?_d&&dUN^UKuVR*{R=mcT$kkP@smeI_~doA7dMG2U3ncT>$(e|^o z7O%|rlSAu2rc0P@Y*@B_^~b!tR#AFwU$fF}zdP&D_J(JQGr$I>WtW&OOr@xLie0m* z(Y5BX^68HDFp)V;t#>jehbzzXT`xr2oocPVXqx|Hh zxGxKjSQk&AZykfP7$FoJ^CiWU7ZyzKqH!$$QgPqQj-yD4awLZ+*UdsX6LFOv^%_%C zhrfn)gJ)7*n!q|@5{C+!YmSf&gkANxH2ovdVsL<^!2x2%GJ$wuX$Cv~YSeCXKAM}I zA=|C%voJB01k0zYTmHL@LB*w?@MBHacPtbMiT|1TVu&e7m=mDB6kDfvn^KX}d9EPYrxjsPGh;HxK7G&simF2Smc%*7;q zm`c+qdLGBBkdUgcsmWoZRFg$kb(IxiVtTBqwD;A zQW2tXd}qyt&(8Og8eX9G3iT-+MAzAt>OS>WEw!jlwtn~ZckgE~rf7ZyEh5yIO5?9R zIyZu@pF3rPkyo)!N`lVK3tLSeu}gV?c-2qFLWF<_H^A8?ANTC*1;xVT>p3{dgFxOH z_g3(FfHJM0x2IEeg$J3=onW~nfuSL!^PNo^wB=Vp7!oKO0Rz(*4Fs=ebh~$UZY8^o z@pqg+_h5%~JxQiC!M>EUohMg>y@r!)%f~7Vt<^sA`*CH)T9Hy(>}2%6sVnKOAqvH@G|M zfG}eG4S$%L5fP#PF&=7)%32-z?Aio&l(93Q=l5kUkD^0dSq-=S(aAJ0-s8DiK%cZ> zW;pv~^pfP^(pvsgyQQ?6esr5t^e+&Trrer9s@}>J2TKx53zQkJZU?FGy}O}{IHC3@ zf*fLKvkQSCckuXb4}|#?`i7=zf3jghxlmS9)($h7!7;LLAy%ih9mGneB=_l+QVp1r zUt0!rvasNo$bh4W?@>|>ao}4o1yWZsPDmId7d28KVjP37Ug-=%_hymU&sdXPZm-lTvHNjupP~-5^#4<+lz&C{CV@sxvU#3X-W>1WvWgOhlJH#WJ-)B_5mnz6(Nr@hCrW|8DK&EL!s__dF6<(Bx-?%Y52mW6!9U$%VgQgoU z#KGQ|qhyR=$Hf=3TU*4+-?Q!rwaA{0at4m;ut+rQ;P+Ka2XXoQt%t6kVjzdGRH*Vq zhy*Nk=5AZGGv(P6vTL_|a1X`r#f1q81CuyUQ=A@7h78pnauSKqN>AwA2>6h3&lV|3 z10x!`q~z)jt8i7(RXQwHJ6B)_Ch`CX~Eubq_wPRRspt)U7c!RVPn8NvqB|&ra&S z2s9Viu~5APyS+*t0NI|6E95KnTp>x@S7?o*({Fy=XB)yMHM+D)XhlDTo({25Z`WzL zdg$Bty1}QU5%Pzj?~3tFvuFd{LxR@du*#}vx^it$fm%SdOu7{;KRC!Yy82|%y#sur zd0IJBl^FyDkl(OS?o!x4)cNcW{4h11ivLq}KSbQtB>wc(<`iiK$-;SIP4`g#t65|2 z%TXx07fEr6GT;&<1_L|aoh$&8S2M*1{+Re%b!+JsHp&FJc^BA{Dm&h3jke2V6^gED znY%8ViR6Hu#X7#|QturhTexkl!5d3+1KFQCJ2%tu3!B4!&ttRO zm*k8tMQ-~Au2wjkOD_H^E5F&7wmthYH;S9REO}8qf;|oUh#h%zAW!P>`P@5qj3pbZ zs={xFZEUPJfIZJzFJ)2PR%uh235SNiw>XKPj=}6-Lujod%Fp8|4u5F>L~z3h#P`nk z@%?h+X!%X!QFIY`%Syno)@yRg23dDEg0aAP%M+FHkg>l2;WEN(33An{Xa`eO9VmP< z@Nul{+vIyiEL6#x8Rv1nraw;9vLwhawPgf-R=~mDXLSL^HiTD0%`vUtF)43RbQ5YGL*Hp`M7ifhB3UO6B!`%pR`8qm)nT2z-CdX} zb@x${uXeIT9qnRu2}HVUe~MC;L#%;V#m5+(QFOl1?#2PJ+m?6QuHUI3|J_4Wjr(ap zuM3ir=B3Pmj|>9P8rH6fSXCP>nfs&O; zq#g`RBtb8nzrSS14iJDPYL_t!g^nos4ARCVU@Olz*$HNoT1QL|3~9jmB2*rb0K2a9 zUUos`2HoIx5mj2PzQxc6_5OLJ1*7y ztK{|AOkknHyaQb+o&X|>E@gW+41iBN0);tR<-<%I&ZbOQa*GILkyTn`Jkx!imIW=quz5vtKn zQpo1A!&N75OAn3M!RpaLheTVngvsTyHzf=-Z1q8tAo@Y)L<&TaS64@}{JapB9v8TR z<P(6@gNe0Z3|r3C2p%CVL2sHHDt1k-m%{>2xn-p}@4CrRZ_Wv_kZqRzffI7g(wP2(vq54#+Z1!3>{ zzr64%y8bbmiW0duAKR2$CH-s>Rf7_-jMnX?PNEBSY=?{cW2>FN&!2&xHym}1q91#r z^l|Tgm;F{(`MNJU=oRug%*;3njg|#bgzriOZb>FXVLp+fu$9jYdB0Enj$NMbwY~=i z2Png)H${>dcDXesK3Zy_- zacufE_us@sY#V6vauKy!owVjMbxAA?%cZ8W;vp+Vci7>g=L1N5Wm)}hl`W$6%C0s1 zyb7Nk7m!3f`+cnoi5a#W-Sr}W*)X|Z8y@pJ6>Z#~b8 z6W*iM?B#hF2&E_Ks9bD06|4;lOl`X(%<)k+>E_cj>?Vb2V0kYApS|jNE>~J_h9@j% z933*)s19BZ)&B8&1Z}M^^><`M11YE_>_OxZ_ z$IJhm`Dot%pPNBUf-K^jMrpo;ATZE(l`9JqJ15cg`6D-KsYAY*kSI^mCoVPZpGqmD zb$+*o{;v}W_vxs&72{2v^Set&`0$N3n6S!ruu{M`d7H(GYXoOsC; zN9u~y@{h!Qi@#|YbaZ)IneV~h><*sE5JE)Cci!%qJ!z3$$`2Eluqmj?J%$_GO`zZ! z3*~69y6mfmSkhH{ z11QZPEfL#zhea9+i;;$}@>zsW)tO!+(C3SB`Qd?mR(1TagG8qO82KQ06rrN}QOxHO zmJmn9zZul2td4BF6M=0Hvp2mv@!M8QU03FrKuLUADhkor=T9ZCcY{5$1YkPETqoASoL20bbG}>_ zkC{n4IW1nf zUEXyYIMcYQvdg%;48AujmU&fD9j_^gGH3JZL<(f{Md6HY&^bsRp_V7xi&*cij9*A> z3FZ*A7E$_F>P;4+tUay=jO84F`o&7?4TTR*3-)b?5&!|8Oz3!clP`Sw{{It95IEK* zgK-XJlLVJuno!5F8j24K+apHMkcgKt)rml%-FSEwSzr)#Y8mLz9qRacquonw=SR^G zP?_ZyFmblLY7u=35!K|A2}u?`&Z^-OwOekMX-OW{9YdRX9DD^zIW3?}l2f2__6_|R z(2ES^fJ?}NenXDnBkiDD-QcA++GDA8II5Qb{#Lm0saI=_pd3%Fz?$SD$@DY0srzJC9Enj`&napgLhC^`E-CVmwYEKy?;hM2-R+=B@5w zm&lPM;4PRczj#m$eowvSEgm+3LaS>+-eFdOagFMz%Nt1-WVXuEIMb#|ydY1#UvTl<_c@dr zlGS%-5#vBst&QEuHBK}B>2f8x?BezvceO&w&B-YDnMV4?*3FWuK)emZ^>YItc4Ix zJ=TCD^@%}ZiblXsUPb=zlI2@WP`esTv@yj@<}R$Y+elw})Lx3dg&9HK$nvVhTl40>qX;qPrI>L*z7KVsf;JunHm;S4-m-_eGB9U5bmA1*Onm42p91t6ot?!a z2Sq247Zh{C5Ucvmj=q>9#&oeB?bW*Rirvp Date: Mon, 26 Jun 2023 16:30:08 +0700 Subject: [PATCH 0659/1199] =?UTF-8?q?=D0=92=D1=8B=D1=81=D1=82=D1=80=D0=B5?= =?UTF-8?q?=D0=BB=20=D1=81=D0=B5=D0=B1=D0=B5=20=D0=B2=20=D0=BD=D0=BE=D0=B3?= =?UTF-8?q?=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/dbotthepony/mc/otm/registry/MBlockColors.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockColors.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockColors.kt index 648c9a94d..85900d227 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockColors.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockColors.kt @@ -9,19 +9,21 @@ import net.minecraftforge.client.event.RegisterColorHandlersEvent import net.minecraftforge.eventbus.api.IEventBus object MBlockColors { - private const val DEFAULT_WATER_TINT: Int = 0x3F76E4; + private const val DEFAULT_WATER_TINT: Int = 0x3F76E4 private fun registerBlockColors(event: RegisterColorHandlersEvent.Block) { - event.register({ state: BlockState?, light: BlockAndTintGetter?, pos: BlockPos?, index: Int -> + event.register({ state: BlockState, light: BlockAndTintGetter?, pos: BlockPos?, index: Int -> if (index == 0) { - if (light == null || pos == null) DEFAULT_WATER_TINT - BiomeColors.getAverageWaterColor(light!!, pos!!) + if (light == null || pos == null) + DEFAULT_WATER_TINT + else + BiomeColors.getAverageWaterColor(light, pos) } else -1 }, MBlocks.COBBLESTONE_GENERATOR) } private fun registerItemColors(event: RegisterColorHandlersEvent.Item) { - event.register({ stack: ItemStack?, index: Int -> + event.register({ stack: ItemStack, index: Int -> if (index == 0) DEFAULT_WATER_TINT else -1 }, MBlocks.COBBLESTONE_GENERATOR) } From eec453f7ff7a49b82f3dcb487f99c889b7d498de Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 26 Jun 2023 18:45:19 +0700 Subject: [PATCH 0660/1199] Allow to configure event horizon damage and gravity forces --- .../entity/blackhole/BlackHoleBlockEntity.kt | 51 ++++++++++++------- .../dbotthepony/mc/otm/config/ServerConfig.kt | 32 ++++++++++++ 2 files changed, 64 insertions(+), 19 deletions(-) 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 1a52a7391..a838aed26 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 @@ -9,6 +9,7 @@ import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.Entity import net.minecraft.world.entity.EquipmentSlot import net.minecraft.world.entity.LivingEntity +import net.minecraft.world.entity.boss.wither.WitherBoss import net.minecraft.world.entity.item.ItemEntity import net.minecraft.world.entity.player.Player import net.minecraft.world.level.Level @@ -18,10 +19,13 @@ import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.levelgen.structure.BoundingBox import net.minecraft.world.phys.AABB import net.minecraft.world.phys.Vec3 +import net.minecraftforge.common.Tags +import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.block.BlackHoleBlock import ru.dbotthepony.mc.otm.block.entity.tech.GravitationStabilizerBlockEntity import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.block.entity.blackhole.ExplosionQueue.Companion.queueForLevel +import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.core.damageType import ru.dbotthepony.mc.otm.core.getExplosionResistance import ru.dbotthepony.mc.otm.core.gracefulBlockBreak @@ -30,6 +34,7 @@ import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.core.math.getSphericalBlockPositions +import ru.dbotthepony.mc.otm.core.math.times import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.matter.MatterManager @@ -174,28 +179,27 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery spinDirection = nbt.getBoolean("spin_direction") } - private fun setDeltaMovement(living: Entity, center: Vec3, distance: Double, weaker: Boolean) { + private fun setDeltaMovement(living: Entity, center: Vec3, distance: Double) { //final double mult = Math.min(2, (30 * this.gravitation_strength) / Math.max(1, Math.pow(distance, 2))); // Сила притяжения - val mult = (1 - distance / (30 * gravitationStrength)).coerceAtLeast(0.0).pow(2.0) * gravitationStrength / 8 + var mult = (1 - distance / (30 * gravitationStrength)).coerceAtLeast(0.0).pow(2.0) * gravitationStrength / 8 + + if (living is Player) { + mult *= ServerConfig.Blackhole.PLAYER_FORCE_MULTIPLIER + } else if (living.type.`is`(Tags.EntityTypes.BOSSES)) { + mult *= ServerConfig.Blackhole.BOSS_FORCE_MULTIPLIER + } else { + mult *= ServerConfig.Blackhole.MOB_FORCE_MULTIPLIER + } // Притяжение к ядру val delta = living.position().vectorTo(center).normalize() if (distance < gravitationStrength) { - living.deltaMovement = living.deltaMovement.add(delta.multiply(mult, mult, mult)) + living.deltaMovement += delta * mult } else { // Закручивание - val rotate = if (spinDirection) delta.yRot((Math.PI / 2).toFloat()) else delta.yRot((-Math.PI / 2).toFloat()) - - if (weaker) - living.deltaMovement = living.deltaMovement - .add(rotate.multiply(mult * 0.2f, mult * 0.2f, mult * 0.2f)) - .add(delta.multiply(mult * 0.33f, mult * 0.33f, mult * 0.33f)) - else - living.deltaMovement = living.deltaMovement - .add(rotate.multiply(mult * 0.2f, mult * 0.2f, mult * 0.2f)) - .add(delta.multiply(mult, mult, mult)) + living.deltaMovement += (if (spinDirection) delta.yRot((Math.PI / 2).toFloat()) else delta.yRot((-Math.PI / 2).toFloat())) * (mult * 0.2f) + delta * mult } } @@ -206,12 +210,12 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery if (!ply.abilities.mayfly && ply.getItemBySlot(EquipmentSlot.CHEST).item != MItems.PORTABLE_GRAVITATION_STABILIZER) { val distance = ply.position().distanceTo(center) - setDeltaMovement(ply, center, distance, true) + setDeltaMovement(ply, center, distance) } for (item in level!!.getEntitiesOfClass(ItemEntity::class.java, affectedBoundsAABB)) { val distance = item.position().distanceTo(center) - setDeltaMovement(item, center, distance, false) + setDeltaMovement(item, center, distance) } } @@ -229,21 +233,30 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery val distance = living.position().distanceTo(center) if (living !is Player || !living.abilities.mayfly && living.getItemBySlot(EquipmentSlot.CHEST).item != MItems.PORTABLE_GRAVITATION_STABILIZER) { - setDeltaMovement(living, center, distance, living !is Player) + setDeltaMovement(living, center, distance) if (living is ServerPlayer) { BlackHoleTrigger.trigger(living) } } - if (distance < gravitationStrength + 1) { - living.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EVENT_HORIZON)), (gravitationStrength / distance).toFloat()) + if (distance < gravitationStrength + 1.0) { + val source = MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EVENT_HORIZON)) + val damage = (gravitationStrength / distance).toFloat() + + if (living is Player) { + living.hurt(source, damage * ServerConfig.Blackhole.PLAYER_DAMAGE_SCALE.toFloat()) + } else if (living.type.`is`(Tags.EntityTypes.BOSSES)) { + living.hurt(source, damage * ServerConfig.Blackhole.BOSS_DAMAGE_SCALE.toFloat()) + } else { + living.hurt(source, damage * ServerConfig.Blackhole.MOB_DAMAGE_SCALE.toFloat()) + } } } for (item in level.getEntitiesOfClass(ItemEntity::class.java, affectedBoundsAABB)) { val distance = item.position().distanceTo(center) - setDeltaMovement(item, center, distance, false) + setDeltaMovement(item, center, distance) if (distance < gravitationStrength + 1) { if (item.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EVENT_HORIZON)), (gravitationStrength / distance).toFloat()) && item.isRemoved) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt index f9d230094..03d7d1c0e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt @@ -21,6 +21,38 @@ object ServerConfig : AbstractConfig("misc") { .comment("Maximal percent of experience dropped on death into capsules") .defineInRange("MAXIMAL_PERCENT", 0.8, 0.0, 1.0) + init { + builder.pop() + builder.push("BLACKHOLES") + Blackhole + } + + object Blackhole { + val PLAYER_DAMAGE_SCALE: Double by builder + .comment("Percentage of damage received by players from Event Horizon of Singularities") + .defineInRange("PLAYER_DAMAGE_SCALE", 0.25, 0.0, Float.MAX_VALUE.toDouble()) + + val MOB_DAMAGE_SCALE: Double by builder + .comment("Percentage of damage received by non players from Event Horizon of Singularities") + .defineInRange("MOB_DAMAGE_SCALE", 1.0, 0.0, Float.MAX_VALUE.toDouble()) + + val BOSS_DAMAGE_SCALE: Double by builder + .comment("Percentage of damage received by bosses (forge:bosses tag) from Event Horizon of Singularities") + .defineInRange("BOSS_DAMAGE_SCALE", 0.25, 0.0, Float.MAX_VALUE.toDouble()) + + val PLAYER_FORCE_MULTIPLIER: Double by builder + .comment("Percentage of gravity force experienced by players from Singularities") + .defineInRange("PLAYER_FORCE_MULTIPLIER", 0.4, 0.0, Float.MAX_VALUE.toDouble()) + + val MOB_FORCE_MULTIPLIER: Double by builder + .comment("Percentage of gravity force experienced by non players from Singularities") + .defineInRange("MOB_FORCE_MULTIPLIER", 1.0, 0.0, Float.MAX_VALUE.toDouble()) + + val BOSS_FORCE_MULTIPLIER: Double by builder + .comment("Percentage of gravity force experienced by bosses (forge:bosses tag) from Singularities") + .defineInRange("BOSS_FORCE_MULTIPLIER", 0.4, 0.0, Float.MAX_VALUE.toDouble()) + } + init { builder.pop() } From b3d1db2afa509c67027bad5030eea3ddcff9b1b5 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 26 Jun 2023 19:16:17 +0700 Subject: [PATCH 0661/1199] Buff plate press and twin plate press recipes --- .../mc/otm/datagen/recipes/CraftingTableRecipes.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index d708e8627..0cf235240 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -65,15 +65,16 @@ fun addCraftingTableRecipes(consumer: Consumer) { .build(consumer) MatteryRecipe(MBlocks.PLATE_PRESS, category = machinesCategory) + .rowB(MItemTags.PISTONS) .rowB(MItems.MACHINE_FRAME) - .rowAC(MItemTags.PISTONS, MItemTags.PISTONS) .unlockedBy(MItemTags.TRITANIUM_INGOTS) .unlockedBy(MItems.ELECTRIC_PARTS) .build(consumer, "advanced") MatteryRecipe(MBlocks.TWIN_PLATE_PRESS, category = machinesCategory) .rowB(MItemTags.PISTONS) - .row(MItemTags.TRITANIUM_PLATES, MItems.PLATE_PRESS, MItemTags.TRITANIUM_PLATES) + .rowB(MItems.PLATE_PRESS) + .rowB(MItemTags.TRITANIUM_PLATES) .unlockedBy(MItems.PLATE_PRESS) .build(consumer) From 0704da4be0e65679cab308e769a5f5870ada24b8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 26 Jun 2023 22:24:54 +0700 Subject: [PATCH 0662/1199] Creative tabs no longer appear where they shouldn't --- .../kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt index 26cd6e470..6434da4ae 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt @@ -1,7 +1,9 @@ package ru.dbotthepony.mc.otm.registry import net.minecraft.core.registries.Registries +import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.CreativeModeTab +import net.minecraft.world.item.CreativeModeTabs import net.minecraft.world.item.DyeColor import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack @@ -262,6 +264,7 @@ object MCreativeTabs { CreativeModeTab.builder() .title(TranslatableComponent("itemGroup.otm")) .icon { ItemStack(BATTERY_CREATIVE, 1) } + .withTabsBefore(CreativeModeTabs.SPAWN_EGGS) .build() } @@ -269,6 +272,7 @@ object MCreativeTabs { CreativeModeTab.builder() .title(TranslatableComponent("itemGroup.otm_decorative")) .icon { ItemStack(MRegistry.VENT.item, 1) } + .withTabsBefore(ResourceLocation(OverdriveThatMatters.MOD_ID, "main")) .build() } From f7af09b62e90ac5ba88febb203eec1f0d5ca6a21 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 26 Jun 2023 23:35:59 +0700 Subject: [PATCH 0663/1199] Actually make custom machine names working --- .../ru/dbotthepony/mc/otm/block/MatteryBlock.kt | 11 +++++++++-- .../mc/otm/data/loot/CopyTileNbtFunction.kt | 10 ++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt index cb57cc668..86ad9bba1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt @@ -6,6 +6,7 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectFunction import net.minecraft.core.BlockPos import net.minecraft.core.Direction import net.minecraft.core.particles.DustParticleOptions +import net.minecraft.network.chat.Component import net.minecraft.util.RandomSource import net.minecraft.world.Containers import net.minecraft.world.InteractionHand @@ -32,6 +33,7 @@ import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.math.component1 import ru.dbotthepony.mc.otm.core.math.component2 import ru.dbotthepony.mc.otm.core.math.component3 +import ru.dbotthepony.mc.otm.core.tagNotNull import ru.dbotthepony.mc.otm.once fun Block.getShapeForEachState(properties: List>, fn: (BlockState) -> VoxelShape): Map { @@ -71,8 +73,13 @@ abstract class MatteryBlock @JvmOverloads constructor( if (this is EntityBlock && itemStack.hasCustomHoverName() && !level.isClientSide) { val tile = level.getBlockEntity(blockPos) - if (tile is MatteryDeviceBlockEntity) - tile.customDisplayName = itemStack.displayName + if (tile is MatteryDeviceBlockEntity) { + try { + tile.customDisplayName = Component.Serializer.fromJson(itemStack.tagNotNull.getCompound("display").getString("Name")) + } catch(_: Exception) { + + } + } } super.setPlacedBy(level, blockPos, blockState, entity, itemStack) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt index 4858c7cf3..b363b59a6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt @@ -7,6 +7,7 @@ import com.google.gson.JsonObject import com.google.gson.JsonPrimitive import com.google.gson.JsonSerializationContext import net.minecraft.nbt.CompoundTag +import net.minecraft.network.chat.Component import net.minecraft.world.item.BlockItem import net.minecraft.world.item.ItemStack import net.minecraft.world.level.storage.loot.LootContext @@ -20,6 +21,7 @@ import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.core.stream import ru.dbotthepony.mc.otm.core.tagNotNull import ru.dbotthepony.mc.otm.core.collect.stream +import ru.dbotthepony.mc.otm.core.nbt.getJson import ru.dbotthepony.mc.otm.registry.MItemFunctionTypes import java.util.stream.Stream @@ -56,6 +58,14 @@ class CopyTileNbtFunction(filter: Stream = Stream.empty()) : LootIte } } + if ("Name" in data && "display" !in t.tagNotNull) { + t.tagNotNull["display"] = CompoundTag().also { + it["Name"] = Component.Serializer.toJson(Component.Serializer.fromJson(data.getJson("Name")!!)!!) + } + + data.remove("Name") + } + return t } From 26236a5b0799b603423f5ad75d8f693af2f32b63 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Mon, 26 Jun 2023 23:50:50 +0600 Subject: [PATCH 0664/1199] Fix twin plate press texture funny --- .../models/block/twin_plate_press_working.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/twin_plate_press_working.json b/src/main/resources/assets/overdrive_that_matters/models/block/twin_plate_press_working.json index 96ab82259..1eaa521f3 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/twin_plate_press_working.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/twin_plate_press_working.json @@ -70,7 +70,7 @@ "from": [1, 8, 3], "to": [9, 15, 15], "faces": { - "north": {"uv": [0, 2, 8.5, 15.9], "texture": "#1"}, + "north": {"uv": [0, 2, 16, 16], "texture": "#1"}, "east": {"uv": [14, 12.5, 11, 16], "texture": "#0"}, "south": {"uv": [14, 12.5, 16, 16], "texture": "#0"}, "west": {"uv": [11, 12.5, 14, 16], "texture": "#0"}, @@ -226,7 +226,7 @@ "from": [1, 0, 3], "to": [9, 7, 15], "faces": { - "north": {"uv": [0, 2, 8, 16], "texture": "#2"}, + "north": {"uv": [0, 2, 16, 16], "texture": "#2"}, "east": {"uv": [14, 12.5, 11, 16], "texture": "#0"}, "south": {"uv": [14, 12.5, 16, 16], "texture": "#0"}, "west": {"uv": [11, 12.5, 14, 16], "texture": "#0"}, From 3c90489dea6f8ff59196771dbe18c1a0d0533371 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Tue, 27 Jun 2023 00:07:10 +0600 Subject: [PATCH 0665/1199] Reduce the humongous amount of empty (But not really) space on texture atlas --- .../mc/otm/datagen/DecorativeData.kt | 4 +- .../models/block/cargo_crate_closed.json | 97 +++--------------- .../models/block/cargo_crate_open.json | 76 ++++++-------- .../block/cargo_crates/cargo_crate.png | Bin 559 -> 372 bytes .../block/cargo_crates/cargo_crate_black.png | Bin 559 -> 372 bytes .../block/cargo_crates/cargo_crate_blue.png | Bin 559 -> 372 bytes .../block/cargo_crates/cargo_crate_brown.png | Bin 559 -> 372 bytes .../block/cargo_crates/cargo_crate_core.png | Bin 0 -> 297 bytes .../block/cargo_crates/cargo_crate_cyan.png | Bin 559 -> 372 bytes .../block/cargo_crates/cargo_crate_gray.png | Bin 559 -> 372 bytes .../block/cargo_crates/cargo_crate_green.png | Bin 559 -> 372 bytes .../cargo_crates/cargo_crate_light_blue.png | Bin 559 -> 372 bytes .../cargo_crates/cargo_crate_light_gray.png | Bin 559 -> 372 bytes .../block/cargo_crates/cargo_crate_lime.png | Bin 559 -> 372 bytes .../cargo_crates/cargo_crate_magenta.png | Bin 559 -> 372 bytes .../block/cargo_crates/cargo_crate_orange.png | Bin 559 -> 372 bytes .../block/cargo_crates/cargo_crate_pink.png | Bin 559 -> 372 bytes .../block/cargo_crates/cargo_crate_purple.png | Bin 559 -> 372 bytes .../block/cargo_crates/cargo_crate_red.png | Bin 559 -> 372 bytes .../block/cargo_crates/cargo_crate_white.png | Bin 559 -> 372 bytes .../block/cargo_crates/cargo_crate_yellow.png | Bin 559 -> 372 bytes 21 files changed, 50 insertions(+), 127 deletions(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_core.png diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt index 0a921075f..d4f75f0da 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt @@ -247,11 +247,11 @@ fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelPr blockModelProvider.exec { for (crate in MRegistry.CARGO_CRATES.blocks.values) { it.withExistingParent("${crate.registryName!!.path}_closed", modLocation("${MNames.CARGO_CRATE}_closed")) - .texture("texture", "block/cargo_crates/${crate.registryName!!.path}") + .texture("body", "block/cargo_crates/${crate.registryName!!.path}") .texture("particle", "block/cargo_crates/${crate.registryName!!.path}") it.withExistingParent("${crate.registryName!!.path}_open", modLocation("${MNames.CARGO_CRATE}_open")) - .texture("texture", "block/cargo_crates/${crate.registryName!!.path}") + .texture("body", "block/cargo_crates/${crate.registryName!!.path}") .texture("particle", "block/cargo_crates/${crate.registryName!!.path}") } } diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/cargo_crate_closed.json b/src/main/resources/assets/overdrive_that_matters/models/block/cargo_crate_closed.json index d055be750..826915b14 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/cargo_crate_closed.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/cargo_crate_closed.json @@ -1,8 +1,11 @@ { + "credit": "Made with Blockbench", "parent": "block/block", + "texture_size": [16, 32], "textures": { - "texture": "overdrive_that_matters:block/cargo_crates/cargo_crate", - "particle": "overdrive_that_matters:block/cargo_crates/cargo_crate" + "particle": "overdrive_that_matters:block/cargo_crates/cargo_crate", + "body": "overdrive_that_matters:block/cargo_crates/cargo_crate", + "core": "overdrive_that_matters:block/cargo_crates/cargo_crate_core" }, "elements": [ { @@ -10,25 +13,11 @@ "from": [0, 0, 0], "to": [16, 13, 16], "faces": { - "north": {"uv": [0, 4.75, 8, 8], "texture": "#texture"}, - "east": {"uv": [0, 4.75, 8, 8], "texture": "#texture"}, - "south": {"uv": [0, 4.75, 8, 8], "texture": "#texture"}, - "west": {"uv": [0, 4.75, 8, 8], "texture": "#texture"}, - "up": {"uv": [0, 0, 8, 4], "texture": "#texture"}, - "down": {"uv": [0, 8, 8, 12], "texture": "#texture"} - } - }, - { - "name": "inside", - "from": [2, 13, 2], - "to": [14, 15, 14], - "faces": { - "north": {"uv": [9, 0, 15, 0.5], "texture": "#texture"}, - "east": {"uv": [9, 0, 15, 0.5], "texture": "#texture"}, - "south": {"uv": [9, 0, 15, 0.5], "texture": "#texture"}, - "west": {"uv": [9, 0, 15, 0.5], "texture": "#texture"}, - "up": {"uv": [0, 0, 6, 3], "texture": "#missing"}, - "down": {"uv": [0, 0, 6, 3], "texture": "#missing"} + "north": {"uv": [0, 9.5, 16, 16], "texture": "#body"}, + "east": {"uv": [0, 9.5, 16, 16], "texture": "#body"}, + "south": {"uv": [0, 9.5, 16, 16], "texture": "#body"}, + "west": {"uv": [0, 9.5, 16, 16], "texture": "#body"}, + "down": {"uv": [0, 0, 16, 8], "texture": "#core"} } }, { @@ -36,65 +25,13 @@ "from": [0, 13, 0], "to": [16, 16, 16], "faces": { - "north": {"uv": [0, 4, 8, 4.75], "texture": "#texture"}, - "east": {"uv": [0, 4, 8, 4.75], "texture": "#texture"}, - "south": {"uv": [0, 4, 8, 4.75], "texture": "#texture"}, - "west": {"uv": [0, 4, 8, 4.75], "texture": "#texture"}, - "up": {"uv": [0, 0, 8, 4], "texture": "#texture"}, - "down": {"uv": [0, 0, 8, 4], "texture": "#texture"} - } - }, - { - "from": [0, 13, 7], - "to": [0, 15, 9], - "rotation": {"angle": 0, "axis": "y", "origin": [0, 14, 8]}, - "faces": { - "north": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, - "east": {"uv": [3.5, 4.25, 4.5, 4.75], "texture": "#texture"}, - "south": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, - "west": {"uv": [3.5, 4.75, 4.5, 5.25], "texture": "#texture"}, - "up": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, - "down": {"uv": [0, 0, 0, 0.5], "texture": "#missing"} - } - }, - { - "from": [16, 13, 7], - "to": [16, 15, 9], - "rotation": {"angle": 0, "axis": "y", "origin": [0, 14, 8]}, - "faces": { - "north": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, - "east": {"uv": [3.5, 4.25, 4.5, 4.75], "texture": "#texture"}, - "south": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, - "west": {"uv": [3.5, 4.75, 4.5, 5.25], "texture": "#texture"}, - "up": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, - "down": {"uv": [0, 0, 0, 0.5], "texture": "#missing"} - } - }, - { - "from": [7, 13, 16], - "to": [9, 15, 16], - "rotation": {"angle": 0, "axis": "y", "origin": [8, 14, 16]}, - "faces": { - "north": {"uv": [3.5, 4.75, 4.5, 5.25], "texture": "#texture"}, - "east": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, - "south": {"uv": [3.5, 4.25, 4.5, 4.75], "texture": "#texture"}, - "west": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, - "up": {"uv": [0, 0, 0, 0.5], "rotation": 90, "texture": "#missing"}, - "down": {"uv": [0, 0, 0, 0.5], "rotation": 270, "texture": "#missing"} - } - }, - { - "from": [7, 13, 0], - "to": [9, 15, 0], - "rotation": {"angle": 0, "axis": "y", "origin": [8, 14, 16]}, - "faces": { - "north": {"uv": [3.5, 4.75, 4.5, 5.25], "texture": "#texture"}, - "east": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, - "south": {"uv": [3.5, 4.25, 4.5, 4.75], "texture": "#texture"}, - "west": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, - "up": {"uv": [0, 0, 0, 0.5], "rotation": 90, "texture": "#missing"}, - "down": {"uv": [0, 0, 0, 0.5], "rotation": 270, "texture": "#missing"} + "north": {"uv": [0, 8, 16, 9.5], "texture": "#body"}, + "east": {"uv": [0, 8, 16, 9.5], "texture": "#body"}, + "south": {"uv": [0, 8, 16, 9.5], "texture": "#body"}, + "west": {"uv": [0, 8, 16, 9.5], "texture": "#body"}, + "up": {"uv": [0, 0, 16, 8], "texture": "#body"} } } - ] + ], + "display": {} } \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/cargo_crate_open.json b/src/main/resources/assets/overdrive_that_matters/models/block/cargo_crate_open.json index 1cf744a25..89531631f 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/cargo_crate_open.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/cargo_crate_open.json @@ -1,8 +1,11 @@ { + "credit": "Made with Blockbench", "parent": "block/block", + "texture_size": [16, 32], "textures": { - "texture": "overdrive_that_matters:block/cargo_crates/cargo_crate", - "particle": "overdrive_that_matters:block/cargo_crates/cargo_crate" + "particle": "overdrive_that_matters:block/cargo_crates/cargo_crate", + "body": "overdrive_that_matters:block/cargo_crates/cargo_crate", + "core": "overdrive_that_matters:block/cargo_crates/cargo_crate_core" }, "elements": [ { @@ -10,12 +13,12 @@ "from": [0, 0, 0], "to": [16, 13, 16], "faces": { - "north": {"uv": [0, 4.75, 8, 8], "texture": "#texture"}, - "east": {"uv": [0, 4.75, 8, 8], "texture": "#texture"}, - "south": {"uv": [0, 4.75, 8, 8], "texture": "#texture"}, - "west": {"uv": [0, 4.75, 8, 8], "texture": "#texture"}, - "up": {"uv": [0, 0, 8, 4], "texture": "#texture"}, - "down": {"uv": [0, 8, 8, 12], "texture": "#texture"} + "north": {"uv": [0, 9.5, 16, 16], "texture": "#body"}, + "east": {"uv": [0, 9.5, 16, 16], "texture": "#body"}, + "south": {"uv": [0, 9.5, 16, 16], "texture": "#body"}, + "west": {"uv": [0, 9.5, 16, 16], "texture": "#body"}, + "up": {"uv": [0, 0, 16, 8], "texture": "#body"}, + "down": {"uv": [0, 0, 16, 8], "texture": "#core"} } }, { @@ -23,12 +26,10 @@ "from": [2, 13, 2], "to": [14, 15, 14], "faces": { - "north": {"uv": [9, 0, 15, 0.5], "texture": "#texture"}, - "east": {"uv": [9, 0, 15, 0.5], "texture": "#texture"}, - "south": {"uv": [9, 0, 15, 0.5], "texture": "#texture"}, - "west": {"uv": [9, 0, 15, 0.5], "texture": "#texture"}, - "up": {"uv": [0, 0, 6, 3], "texture": "#missing"}, - "down": {"uv": [0, 0, 6, 3], "texture": "#missing"} + "north": {"uv": [0, 8, 16, 9], "texture": "#core"}, + "east": {"uv": [0, 8, 16, 9], "texture": "#core"}, + "south": {"uv": [0, 8, 16, 9], "texture": "#core"}, + "west": {"uv": [0, 8, 16, 9], "texture": "#core"} } }, { @@ -36,12 +37,12 @@ "from": [0, 15, 0], "to": [16, 18, 16], "faces": { - "north": {"uv": [0, 4, 8, 4.75], "texture": "#texture"}, - "east": {"uv": [0, 4, 8, 4.75], "texture": "#texture"}, - "south": {"uv": [0, 4, 8, 4.75], "texture": "#texture"}, - "west": {"uv": [0, 4, 8, 4.75], "texture": "#texture"}, - "up": {"uv": [0, 0, 8, 4], "texture": "#texture"}, - "down": {"uv": [0, 0, 8, 4], "texture": "#texture"} + "north": {"uv": [0, 8, 16, 9.5], "texture": "#body"}, + "east": {"uv": [0, 8, 16, 9.5], "texture": "#body"}, + "south": {"uv": [0, 8, 16, 9.5], "texture": "#body"}, + "west": {"uv": [0, 8, 16, 9.5], "texture": "#body"}, + "up": {"uv": [0, 0, 16, 8], "texture": "#body"}, + "down": {"uv": [0, 0, 16, 8], "texture": "#body"} } }, { @@ -49,12 +50,8 @@ "to": [0, 15, 9], "rotation": {"angle": 0, "axis": "y", "origin": [0, 14, 8]}, "faces": { - "north": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, - "east": {"uv": [3.5, 4.25, 4.5, 4.75], "texture": "#texture"}, - "south": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, - "west": {"uv": [3.5, 4.75, 4.5, 5.25], "texture": "#texture"}, - "up": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, - "down": {"uv": [0, 0, 0, 0.5], "texture": "#missing"} + "east": {"uv": [7, 9.5, 9, 10.5], "texture": "#body"}, + "west": {"uv": [7, 9.5, 9, 10.5], "texture": "#body"} } }, { @@ -62,12 +59,8 @@ "to": [16, 15, 9], "rotation": {"angle": 0, "axis": "y", "origin": [0, 14, 8]}, "faces": { - "north": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, - "east": {"uv": [3.5, 4.25, 4.5, 4.75], "texture": "#texture"}, - "south": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, - "west": {"uv": [3.5, 4.75, 4.5, 5.25], "texture": "#texture"}, - "up": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, - "down": {"uv": [0, 0, 0, 0.5], "texture": "#missing"} + "east": {"uv": [7, 9.5, 9, 10.5], "texture": "#body"}, + "west": {"uv": [7, 9.5, 9, 10.5], "texture": "#body"} } }, { @@ -75,12 +68,8 @@ "to": [9, 15, 16], "rotation": {"angle": 0, "axis": "y", "origin": [8, 14, 16]}, "faces": { - "north": {"uv": [3.5, 4.75, 4.5, 5.25], "texture": "#texture"}, - "east": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, - "south": {"uv": [3.5, 4.25, 4.5, 4.75], "texture": "#texture"}, - "west": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, - "up": {"uv": [0, 0, 0, 0.5], "rotation": 90, "texture": "#missing"}, - "down": {"uv": [0, 0, 0, 0.5], "rotation": 270, "texture": "#missing"} + "north": {"uv": [7, 8.5, 9, 9.5], "texture": "#body"}, + "south": {"uv": [7, 8.5, 9, 9.5], "texture": "#body"} } }, { @@ -88,13 +77,10 @@ "to": [9, 15, 0], "rotation": {"angle": 0, "axis": "y", "origin": [8, 14, 16]}, "faces": { - "north": {"uv": [3.5, 4.75, 4.5, 5.25], "texture": "#texture"}, - "east": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, - "south": {"uv": [3.5, 4.25, 4.5, 4.75], "texture": "#texture"}, - "west": {"uv": [0, 0, 0, 0.5], "texture": "#missing"}, - "up": {"uv": [0, 0, 0, 0.5], "rotation": 90, "texture": "#missing"}, - "down": {"uv": [0, 0, 0, 0.5], "rotation": 270, "texture": "#missing"} + "north": {"uv": [7, 8.5, 9, 9.5], "texture": "#body"}, + "south": {"uv": [7, 8.5, 9, 9.5], "texture": "#body"} } } - ] + ], + "display": {} } \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate.png index 9c627d98a36ff788ceaed8de7759431e2cc8a90a..a7130ccc8140521547712cc3a0c7353a354dcff3 100644 GIT binary patch delta 351 zcmZ3_@`XvUGr-TCmrII^fq{Y7)59eQNDBb50t+*ce7XGT|A~qU^(p~AA+DyTrXe9A z2?+^-fq`mjYDGmw_4V~)Vq$5PExAqo+S=N&`BgjmHZKM0<1FxqEM{Qf+YiEw7OcT4 zK*5`yE{-7@=aUlzLW0bKgi;a`3JVK;fjB`xQ$O8IL%%#lVC9RHgcmvGDFG{I+{`iD ze3$b`##sjAdI_s3y;c%)B+l@hIn&fUvsu!I*T;AA8*WA*5Bb1VfFH!&<~>uxN5b|!P8ak`(wiis^9 zJ}DP~1e2kI(qsW8DdRMTyT*$<9TzQLd=rQ#I#zvumwVB4cX@uwgL`|cH-CM1S6V_$ rgli?MW>>MHjz;9soTE?Au`--|7rya9tj=AaHyJ!#{an^LB{Ts5KOKVU delta 539 zcmeyuw4Oz=Gr-TCmrII^fq{Y7)59eQNGkxb0|zsZ^a*I4Gf`2YUN^ue#MRW)G$bS> zAt50!Fi=}tyS~2u{|$!!4?NY>)QXCV#KgqXDqC`!`eXB}fI4fptZ@ZW{3Stt!T(VJ z!<9QT76PR>3p^r=85sBufG}g$wN6e32F3zU7sn6}@3$d0iw-OBh_Ed^apBMZ=k;Z! zGhUh~&3l=>TW)bgj##Xj;M5`+_q7pTidjec`wujK^th|==G)YOUz`DJmu#EvxzS{BWbfiJxlSwX>pDa277IyySFun$@hM^^c|<+W+CwyAS#?EYoBcDp)TF+wRFz z&LuJPz2TM*`UE9AI5Ksbt#_t`xEQXzf!v z(zNuU;veq98IgbHhcLEWs|K3%x=e#1x=GVPS@8zj<{2(d7v48L*t(rH{D=67JvX+3 z=tmra&&~?^?P$7_uBbLa>yD_FS1woP%Ds`iZ||9C-+CMWd(GX%?LX8l{;@p#`G@Jc Xd03MD?du%CIAQQ~^>bP0l+XkK;U@0Z diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_black.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_black.png index 351e6d1f97cd80185954894fabb915c92baee1f1..513d5e3a30a362771fa00b547e3d1ad2ee40884c 100644 GIT binary patch delta 351 zcmZ3_@`XvUGr-TCmrII^fq{Y7)59eQNDBb50t+*ce7XGT|A~qU^(p~AA+DyTrXe9A z2?+^-fq`mjYDGmw_4V~)Vq&tgit_Tx+S=OE((*G6l^32JCL0VIdZ!4wwl{;mKubgr4 zfB|!c!X2&!OY;;JydR!pFuKy@z;kk@v3m5mIhKNon-~_gbvG72JCixlINi@-#l)5l zpOgzgg2~W9X|jNllyMrvUE{@_j*AvAz6rz=9jm^-%e`p2yF5ST!M(lJo4>xhD=i@= q!nKlBv#Z!pMf3*Y!4R_89zn+%?=elF{r5}E)<;(s#$ delta 520 zcmeyuw4Oz=Gr-TCmrII^fq{Y7)59eQNGkxb0|zsZ^a*I4Gf`0?P&dFQ#MRW)G$bS> zAt50!Fi=}tyS~2u{|$!!4?NY>)QXCV#Kgp8WfkS+m8GTSfjYM&eA@=3_)CKPg8!oc zhAVewES#7pUe8$I>EamT;r%w`X3=2<9uc;sCocT?|Gcbp#!C~Wc`vhf%Po$`5sNhw zoLVH~zBa;3G3!Ww|AFR@9(NVqe485Zi!)&Dl5NwU^J^sbbWYAVGf|LF;F-+US5@DX z|8R>tR`@skxS(^);mG=yQ=$3Ow0{^5RgIr@NM+7Iz}{SFiAg&%HIIPp`hyLML8 z3eLhsmY1CFPP3YI^wG3K`#)TI_d!2~Wt!|l1?vT2+dX;8xg=)3H{9|;U!j({`*!>h zffjE?Nz3~?L?)&EJhpU$>YhLc{fqAN*?s(eh_B#bes*v|%E!!v!r4=9nP-*Gp8D%b zRJOjC<>a8|3(<#NOtWm21FY*yC)F%EH%;y#*OekxAFX{#N1B#CRQ$s|Bl6Gu5XP2k z)j*S8muWCWH)%R3E8bw+Jj2E5!uzHNTeq`@{}4a1=f+kL{fI;G*;zrq9Zh%A71bta z-4WID%H_&jxi^yc?L8CiTW{lkueqDJ{fD~6KbD6-|1e!Q4@UYHIUt9y!$64SJS`dlF<8(iV6%$)J zd{Qm|2_{1arO5(HQpRZvca0Z!Ixbqg_$ClfbgcURF88A8?(+PU2lw_?Z~pr3uC#=h r2-iwh&8}iY9gWDNIY*zKV`Vt`E_~yISe?5-Z!&ng`njxgN@xNAJVJp7 delta 520 zcmeyuw4Oz=Gr-TCmrII^fq{Y7)59eQNGkxb0|zsZ^a*I4Gf`0?P&dFQ#MRW)G$bS> zAt50!Fi=}tyS~2u{|$!!4?NY>)QXCV#Kgo5j3yeJ&eqlM0O}N&@Ua(2@s|Yo1^-6@ z3|H>VSU53Hyq>YZ)5S5w!~1Q>&7#8!JR)pMPh9x(|9M&IjF%=#^Im4}mRlT=BNl5W zIJHQ|eQku7V%CxV{sYY)J?<*J`8GA+7iYlQCEKPy=hsN=>71N#W}+aUz%!Yxud2Q& z|KS#QtnhF6aY5&p!;$qZr$Y0mY5h<%{loq0a`XYiv>)Q{`W+_J3qRbbaN?(0ckQgG z6`X~OEH63Ton|%b=%Z zsBC>N%gI5_7orclm}c232UypaPO4dSZkpUft}8{XK3e;fjx;TOsQ8C_M&zIQA&f28 zs(~iGF4JI$Zqjs6R=mNsd4`MAh4)Plwr*z){~>;2&yB4h`VoiVv$KMJJDTpKE2>S< zx+ALPmCKd6a&IK>+j}P3x8BD8UUN5b`ww-Ce=HAw{$aXq9+qT(`#J|OYB(7@UHx3v IIVCg!0C!sHhyVZp diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_brown.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_brown.png index 8142ac08f868ae497db8f35cafe0effd14e030a4..7a0af145fcca8b805cd71538fa430b60b01f09a2 100644 GIT binary patch delta 351 zcmZ3_@`XvUGr-TCmrII^fq{Y7)59eQNDBb50t+*ce7XGT|A~qU^(p~AA+DyTrXe9A z2?+^-fq`mjYDGmw_4V~)Vq)3OszvS^+S=MFcFLb0Y$^rn<1FxqEM{Qf+YiEw7OcT4 zK*5`yE{-7@=aUlzLW0bKgi;a`3JVK;fjB`xQ$O8IL%%#lVC9RHgcmvGDFG{I+{`iD ze3$b`##sjAdI_s3y;c%)B+l@hIn&fUvsu!I*T;AA8*WA*5Bb1VfFH!&<~>uxN5b|!P8ak`(wiis^9 zJ}DP~1e2kI(qsW8DdRMTyT*$<9TzQLd=rQ#I#zvumwVB4cX@uwgL`|cH-CM1S6V_$ rgli?MW>>MHjz;9soTE?Au`--|7rya9tj=AaHyJ!#{an^LB{Ts5(tClI delta 520 zcmeyuw4Oz=Gr-TCmrII^fq{Y7)59eQNGkxb0|zsZ^a*I4Gf`0?P&dFQ#MRW)G$bS> zAt50!Fi=}tyS~2u{|$!!4?NY>)QXCV#Kgq1omGq6HB#)9fjVtU*nR>j{*oZS;QuIq z;mVyE3n%7@*E1G)x;Tb-c)ty~S#(%|M}%$Zi3@-JKQAkt@zO+T-plOWa*HE!#A3|^ zrxwY$uZ{3h%sSHFf1vrJ$6bXt-=+rq;tW{3WZU%T{2GZpos%=pOcdl3cqX&;Rn<4; zKiuMu75)uBF6bO{II_OwRA~M*tsjb}f4E;=jy_>QKjIL4c2>}DN7J2jMYRc9 zcSN7I;J!GcfS&2Vq7F)?gK&V4bInV~9rZU4KTtBL*Coy59Zz&(A-z z+`G(vhT4*VoTF#LH%#a~eKNOocj(OOHOp3~It$G?vgrL*G6l^32JCL0VIdZ!4wwl{;mKubgr4 zfB|!c!X2&!OY;;JydR!pFuKy@z;kk@v3m5mIhKNon-~_gbvG72JCixlINi@-#l)5l zpOgzgg2~W9X|jNllyMrvUE{@_j*AvAz6rz=9jm^-%e`p2yF5ST!M(lJo4>xhD=i@= q!nKlBv#Z!pMf3*Y!4R_89zn+%?=elF{r5}E*$4}n$y delta 520 zcmeyuw4Oz=Gr-TCmrII^fq{Y7)59eQNGkxb0|zsZ^a*I4Gf`0?P&dFQ#MRW)G$bS> zAt50!Fi=}tyS~2u{|$!!4?NY>)QXCV#Kgoz>pH~RCJL9;19fh8yYK->@s|Yo1^-6@ z3|H>VSU53Hyq>YZ)5S5w!~1Q>&7#8!JR)pMPh9x(|9M&IjF%=#^Im4}mRlT=BNl5W zIJHQ|eQku7V%CxV{sYY)J?<*J`8GA+7iYlQCEKPy=hsN=>71N#W}+aUz%!Yxud2Q& z|KS#QtnhF6aY5&p!;$qZr$Y0mY5h<%{loq0a`XYiv>)Q{`W+_J3qRbbaN?(0ckQgG z6`X~OEH63Ton|%b=%Z zsBC>N%gI5_7orclm}c232UypaPO4dSZkpUft}8{XK3e;fjx;TOsQ8C_M&zIQA&f28 zs(~iGF4JI$Zqjs6R=mNsd4`MAh4)Plwr*z){~>;2&yB4h`VoiVv$KMJJDTpKE2>S< zx+ALPmCKd6a&IK>+j}P3x8BD8UUN5b`ww-Ce=HAw{$aXq9+qT(`#J|OYB(7@UHx3v IIVCg!07A{`nE(I) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_gray.png index c4fa7b5cf4f8d40b331b96b91f5b03698b0cd0eb..9b239959569e7385dea25afb7ab8117315dcdb63 100644 GIT binary patch delta 351 zcmZ3_@`XvUGr-TCmrII^fq{Y7)59eQNDBb50t+*ce7XGT|A~qU^(p~AA+DyTrXe9A z2?+^-fq`mjYDGmw_4V~)Vq#WyPIgXi+S=M?R<<1K`E!B#I14-?iy0XB_Jc5^1#7Sh zQ1GUwi(`n!`Q!wFkRY=lp_GJ#!oosdAWjg_)K53l&@WFBSotC);YCh)O2En)H**X( z-{m}#ahAcjUczchua(3ci8DNB&NMa8Y?k!l_3@oNdFEunAg!s!x0TZT%AGRASI#(i zz<@bJ;SSe=rFn`9-Ve_)7+q;{;5j+dSUvjO97{pPO$>|Lx*Ln1oynYNobKnaVq!~& zPs#-#!DQ&5G+97N$~cYTuJPhd$3=@5-vr``j#b~^QTit8*9VO$JX_KbLh*2~7a3oqvn~ delta 520 zcmeyuw4Oz=Gr-TCmrII^fq{Y7)59eQNGkxb0|zsZ^a*I4Gf`0?P&dFQ#MRW)G$bS> zAt50!Fi=}tyS~2u{|$!!4?NY>)QXCV#Kgp`?40bJ+{~^^=!#8>bzKRY-f7n=>q-%;kJdh=BTY*mD*oY~5&36+2xH5& zYM@E4%QP6Gn=~Di6>qR@p5fwj;eFGCt=n0{e~6#hb7L!re#9a8?5v>Qj;1^5ifR+I z?ucr6<#J`N+#AXJ_MVCMt+(;N*W69q{zKj3AIrm^f0(YDhb7tHzRm%R8cqgJS3j3^ HP6*G6l^32JCL0VIdZ!4wwl{;mKubgr4 zfB|!c!X2&!OY;;JydR!pFuKy@z;kk@v3m5mIhKNon-~_gbvG72JCixlINi@-#l)5l zpOgzgg2~W9X|jNllyMrvUE{@_j*AvAz6rz=9jm^-%e`p2yF5ST!M(lJo4>xhD=i@= q!nKlBv#Z!pMf3*Y!4R_89zn+%?=elF{r5}E+qNPw&W delta 520 zcmeyuw4Oz=Gr-TCmrII^fq{Y7)59eQNGkxb0|zsZ^a*I4Gf`0?P&dFQ#MRW)G$bS> zAt50!Fi=}tyS~2u{|$!!4?NY>)QXCV#Kgq>)1*RjWxNt3fjU>QKjIL4c2>}DN7J2jMYRc9 zcSNH+BGiREbXEsav@cQ^po;-81V35{ST(5!O}cM1@DLF7>uqoIq;mEX{;W7ZjPm(;wFYgZQYH<&(35{G*0((STV7s z!zbkekYF-&P?{{DBxRh&aMyTor{ki+yd2nxU_2#ed?n+CD riEyoC)$A%Z)X|7MnsfB&IaY>~@4`1eh}F3Z^d^I+tDnm{r-UW|1KWe3 delta 520 zcmeyuw4Oz=Gr-TCmrII^fq{Y7)59eQNGkxb0|zsZ^a*I4Gf`0?P&dFQ#MRW)G$bS> zAt50!Fi=}tyS~2u{|$!!4?NY>)QXCV#KgqRSDv-ra@%Cy0iaH_aA8f=y6x!&9|umzc>TdF4;EyIlo3?Pv_)}GZO{*1fI!keO2{M z`46|aV}*aij|)1-9FDASITe~eP3woE=^yS_m!l6Dru`6q*Y7Z)Uijfgg%dy3x@%`e zt>7$NWO>Qy?lh}eM;}c)wEx4UcOUd)SfT4%`;q_F1&Aguys3Y_z&?Ddv0t6(T_L;pPd!-+tG9FVdQ I&MBb@0FqSeSpWb4 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_light_gray.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_light_gray.png index 62e44425351d1f35247499f06d110c5d6ce51894..32f7fd48c3090db9eb93d90f78321c9bb065722e 100644 GIT binary patch delta 351 zcmZ3_@`XvUGr-TCmrII^fq{Y7)59eQNDBb50t+*ce7XGT|A~qU^(p~AA+DyTrXe9A z2?+^-fq`mjYDGmw_4V~)Vq(qB)jd7U+S=OH)x~9Q)87E~aTa()7BevL?FV5-3)Wy2 zpx{kU7sn8d^T`PUAwgzALMaIeg@uK_K%5|;sh@79p*G6l^32JCL0VIdZ!4wwl{;mKubgr4 zfB|!c!X2&!OY;;JydR!pFuKy@z;kk@v3m5mIhKNon-~_gbvG72JCixlINi@-#l)5l zpOgzgg2~W9X|jNllyMrvUE{@_j*AvAz6rz=9jm^-%e`p2yF5ST!M(lJo4>xhD=i@= q!nKlBv#Z!pMf3*Y!4R_89zn+%?=elF{r5}E)&s)FbM delta 520 zcmeyuw4Oz=Gr-TCmrII^fq{Y7)59eQNGkxb0|zsZ^a*I4Gf`0?P&dFQ#MRW)G$bS> zAt50!Fi=}tyS~2u{|$!!4?NY>)QXCV#Kgp!o2z?znyagefjS=syZQhr{*oZS;QuIq z;mVyE3n%7@*E1G)x;Tb-c)ty~S#(%|M}%$Zi3@-JKQAkt@zO+T-plOWa*HE!#A3|^ zrxwY$uZ{3h%sSHFf1vrJ$6bXt-=+rq;tW{3WZU%T{2GZpos%=pOcdl3cqX&;Rn<4; zKiuMu75)uBF6bO{II_OwRA~M*tsjb}f4E;=jy_>QKjIL4c2>}DN7J2jMYRc9 zcSN`dlF<8(iV6%$)J zd{Qm|2_{1arO5(HQpRZvca0Z!Ixbqg_$ClfbgcURF88A8?(+PU2lw_?Z~pr3uC#=h r2-iwh&8}iY9gWDNIY*zKV`Vt`E_~yISe?5-Z!&ng`njxgN@xNAJduF^ delta 520 zcmeyuw4Oz=Gr-TCmrII^fq{Y7)59eQNGkxb0|zsZ^a*I4Gf`0?P&dFQ#MRW)G$bS> zAt50!Fi=}tyS~2u{|$!!4?NY>)QXCV#Kgoh){EuumPlG63NoW@*(V^yUlQaO{2v7{ zT)8u2;lw=gdd31z7sn6}@3$d0iw-OBh_Ed^apBMZ=VhfcUYaP)dzrmkZgE78Sge`g z)FK)8wGm#5Sx5T&4>W)DxU2By+th$xoB?Z>Y@7a^Un8-nb8^O+iGq9r&t$f~s`{q< zhg;mS!oT6i1)XCKN7lET3eBIU^+VD05BICf(FY9Eeu%&8cbHHw{BWbfiJxlSwX>pD za277IyySFun$@hMkER{k|KZZR5Bf1I(_|MaST6|M?#WZmB{B28;g%2j3boALx8sip zw0J8@THfCwGAZrnv85YS_XIlVUv!_(?&J4Ed<75lvx5^-K4vBq&Yp71Jgao})L&Pk zvh}?zCkHiOh(7FMnq{jTU|nB2sbt#_t`xEQXzf!v(zNuU;veoAk$>igFt%K) z2AcG`OoJi1Nz*}D@dn%G87@v2-Zwqix}7!rhxmy-H@1T4M;wCB&I?H&E3T9Kh!P$u{`|whv~X`Sd#ti>m0zS;bic1^>bP0 Hl+XkK+CA!6 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_magenta.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_magenta.png index 25eb700cab5706481e20e710b8ddef7dc539c8a5..37b0ca179c268bd4751aaf460b829fa7fae9f79f 100644 GIT binary patch delta 351 zcmZ3_@`XvUGr-TCmrII^fq{Y7)59eQNDBb50t+*ce7XGT|A~qU^(p~AA+DyTrXe9A z2?+^-fq`mjYDGmw_4V~)Vq)v8m+Z1%udS`U*nHLoSLQ&VKF$J<$YKTtzWpG~Xu%q+ z0u;RI>EaloaXvXgASB2vNGK&Cp|G&f7l;!CH1*TXH1x|;1XjLCNqCV{o)WNf#?2hV z&38GEWSnI%u9vWy(rYC#N8$|6nKMnzGn*xSczt{)Po6nhFi2~v@ol9vzjCJx@s%?U z9x!0eP`JajU}>JBg7?F73`SR)9C%L7G**v3H^)*?aTCL$w(iE_XJ;}e8mId?teDu+ z;gfO!NH7^XC`}enk}^(XxNE$)({a(_#W#U?qGQ$fcexi$cbDgFdh^$Jccmr7 rM7UP6YIYSH>S#nB%{lt?94o`gci|f!#OmAydXvG^)z4*}Q$iB}XvBgR delta 520 zcmeyuw4Oz=Gr-TCmrII^fq{Y7)59eQNGkxb0|zsZ^a*I4Gf`0?P&dFQ#MRW)G$bS> zAt50!Fi=}tyS~2u{|$!!4?NY>)QXCV#KgqbSufdTzkad#ETGPpCr^n0DgKfmzu^BU zfZ@uW84D-oiPtk0c)B=-czC}Jxmk2rfk%XG>4^(}{y#4(o$=B{Y2M51-ExZ~a>QcI z1g93sxUY@yQp`Hi-+!R_qsLu^H{YfP{NfB)yJXw+=lmLpJ)M&?&P){K6L==G^;Ok3 z#m&@ zwSu#7k>w?)yVI;@9ep(I(EbmX-hI%IVVNeoP{DdZ*mh5zaxRIP?+v$n&{wEs?!Fy= zM4-i6QPT4M4v|S|KaVZlpt>i}LI0xre0CqdAL1)`n4cY-kn%Azp>Xz;Tjp7%v#0*L z5|yp*WjQ&h`9kzz7t<_TmdK II;Vst08N_f$p8QV diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_orange.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_orange.png index 8b47feec8aa6c2610253b9661cd2246814f17366..12962078b5ebbdbfc33fb4129c88c6f307436852 100644 GIT binary patch delta 351 zcmZ3_@`XvUGr-TCmrII^fq{Y7)59eQNDBb50t+*ce7XGT|A~qU^(p~AA+DyTrXe9A z2?+^-fq`mjYDGmw_4V~)Vq(v7`M;J3XlrXy#5E5h-B$SenP*_;#3&aTmn)>Nx8v5la0xMsnB)rHePYGB#<7STG z=DVCnGR`s>*GpJU>9vxWBXNf3%$cUAk8mmX2n`0@cxQSs=TX$pevoo0!jnn-cR!nT^ z@JYD9}a|;+sG`(Xs0LyWESWyUX)a9^Bhoz4`0AyV4S3 rB3vt3HM@!pbu=Q6<{W)`j+No$yYP(gTe~DWM4fydi^M delta 520 zcmeyuw4Oz=Gr-TCmrII^fq{Y7)59eQNGkxb0|zsZ^a*I4Gf`0?P&dFQ#MRW)G$bS> zAt50!Fi=}tyS~2u{|$!!4?NY>)QXCV#Kgp&n_&*9@ zxN>L4!ijm}^^66cE{-7{-fu&079CdL5n)?;;=-T*&&x_@yfjgo_cD98+~SBFu~;*~ zsYNpGYa_fAvySxlA87vQaaZBZx2XZYI0M!$**5(-zeZwD=j4nt69xGMp2=)|RrO8z z54X5ug@4133p&Rfj;wDv6`DUy>xZK0AMRI|qYoIS{SbfG?=YcW_~Ax{6F=3uYiC8R z;4EBZdCBSSG^<%hA5A;7|HGwsAM|5brpYc;uwD?h-IJ%BOJe4G!z~~56>6EgZ^s`I zXz^B*w7kDVWK!DCV@o%v?g@0zzvw=n-N)~T_zE88X9p*we9TNJoIT~1c~nFd32lcs~R;tjUVGhCc5yl;B2bvtYL5AhRwZfph7k2nOMofY)k(R3$WQEh_O z9Z@Z>T&~QOdn0+@-ZRm@^)~+Zn!AbHf2dphV|n=V57Tw?uq6B2*ExVu!^z<3>gTe~ HDWM4f<4x%$ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_pink.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_pink.png index 712b0e1d93f5d8eedc65415eaf97e80400e518af..ab52ab2eca90c31aaa7d801bea4d4e56cf01dbd9 100644 GIT binary patch delta 351 zcmZ3_@`XvUGr-TCmrII^fq{Y7)59eQNDBb50t+*ce7XGT|A~qU^(p~AA+DyTrXe9A z2?+^-fq`mjYDGmw_4V~)Vq#C4=6~*9rLC=fwQ8zns{9n7KF$J<$YKTtzWpG~Xu%q+ z0u;RI>EaloaXvXgASB2vNGK&Cp|G&f7l;!CH1*TXH1x|;1XjLCNqCV{o)WNf#?2hV z&38GEWSnI%u9vWy(rYC#N8$|6nKMnzGn*xSczt{)Po6nhFi2~v@ol9vzjCJx@s%?U z9x!0eP`JajU}>JBg7?F73`SR)9C%L7G**v3H^)*?aTCL$w(iE_XJ;}e8mId?teDu+ z;gfO!NH7^XC`}enk}^(XxNE$)({a(_#W#U?qGQ$fcexi$cbDgFdh^$Jccmr7 rM7UP6YIYSH>S#nB%{lt?94o`gci|f!#OmAydXvG^)z4*}Q$iB};_8ET delta 520 zcmeyuw4Oz=Gr-TCmrII^fq{Y7)59eQNGkxb0|zsZ^a*I4Gf`0?P&dFQ#MRW)G$bS> zAt50!Fi=}tyS~2u{|$!!4?NY>)QXCV#Kgp&G|m6qz3OV!RG`iaZ9Ox96n{yOU+{kv zz;NZxjD-{P#OoOgJY5_^JiOnA+$=h*z$3!8^u&cf|DTtY&Uk5}H1B2hZn?z~IbyM9 zf>VoR+}B2UDP|q%??2G|(c`Ydn{QJCesKn@U9xTZbAFA)p3cb`XC?~r2|Sb8`l{-i z@*i$-#|r<39~X3vIUHHvaw;@`n${0R(?8s=E=M0QO#31JuHRuoz3{`03MYQ5b=S^{ zTESVk$nuiY-Dy^{jy{@pX#a;x?>^|quuPL(s9?PyY`Z5*;9XA ziOSaZvYZ^$d?EU7<%P=cdU$Z7$!=}6Pkhl+o=XGH#)AHvvj ztr}?3>oN_7=q61EWyKq8n`gKA7_C_WHAE+-+mBgv|tTZ z0Seyqba4#PIG>y#5E5h-B$SenP*_;#3&aTmn)>Nx8v5la0xMsnB)rHePYGB#<7STG z=DVCnGR`s>*GpJU>9vxWBXNf3%$cUAk8mmX2n`0@cxQSs=TX$pevoo0!jnn-cR!nT^ z@JYD9}a|;+sG`(Xs0LyWESWyUX)a9^Bhoz4`0AyV4S3 rB3vt3HM@!pbu=Q6<{W)`j+No$yYP(gTe~DWM4fep!Mw delta 520 zcmeyuw4Oz=Gr-TCmrII^fq{Y7)59eQNGkxb0|zsZ^a*I4Gf`0?P&dFQ#MRW)G$bS> zAt50!Fi=}tyS~2u{|$!!4?NY>)QXCV#KgpMRpynbtxQv#0@S%FeE&Zn#a|NS7yKUu zFkHDaW8uU+@p{GrPZ!4!5AU}jH;WD{@QAQ2J#pdB|L0|;GhUh~&3l=>TW)bgj##Xj z;M5`+_q7pTidjec`wujK^th|==G)YOUz`DJmu#Evxz?FZ^($!ik@1-LE9AI5vI;m#SxoL6_xvmtk`e^M_I?}ZCq2eFz8IgbHhcLEW zs|K3%x=e#1x=GVPS@8zj<{2(d7v48L*t(rH{D=67JvX+3=tmra&&~?^?P$7_uBbLa z>yD_FS1woP%Ds`iZ||9C-+CMWd(GX%?LX8l{;@p#`G@Jcd03MD?du%CsNrPrboFyt I=akR{0KpyV;{X5v diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_red.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_red.png index ac61d4fa4d845c8cad4efb1c82591c8fca40a854..cb8f60e327fbe741d768598439247e111780b710 100644 GIT binary patch delta 351 zcmZ3_@`XvUGr-TCmrII^fq{Y7)59eQNDBb50t+*ce7XGT|A~qU^(p~AA+DyTrXe9A z2?+^-fq`mjYDGmw_4V~)Vq%k&73QcaX=`hDD$38*WA*5Bb1VfFH!&<~>uxN5b|!P8ak`(wiis^9 zJ}DP~1e2kI(qsW8DdRMTyT*$<9TzQLd=rQ#I#zvumwVB4cX@uwgL`|cH-CM1S6V_$ rgli?MW>>MHjz;9soTE?Au`--|7rya9tj=AaHyJ!#{an^LB{Ts5P_KX_ delta 520 zcmeyuw4Oz=Gr-TCmrII^fq{Y7)59eQNGkxb0|zsZ^a*I4Gf`0?P&dFQ#MRW)G$bS> zAt50!Fi=}tyS~2u{|$!!4?NY>)QXCV#KgoVDJ#rTRq9lf1M0kchP4Su@s|Yo1^-6@ z3|H>VSU53Hyq>YZ)5S5w!~1Q>&7#8!JR)pMPh9x(|9M&IjF%=#^Im4}mRlT=BNl5W zIJHQ|eQku7V%CxV{sYY)J?<*J`8GA+7iYlQCEKPy=hsN=>71N#W}+aUz%!Yxud2Q& z|KS#QtnhF6aY5&p!;$qZr$Y0mY5h<%{loq0a`XYiv>)Q{`W+_J3qRbbaN?(0ckQgG z6`X~OEH63Ton|%b=%Z zsBC>N%gI5_7orclm}c232UypaPO4dSZkpUft}8{XK3e;fjx;TOsQ8C_M&zIQA&f28 zs(~iGF4JI$Zqjs6R=mNsd4`MAh4)Plwr*z){~>;2&yB4h`VoiVv$KMJJDTpKE2>S< zx+ALPmCKd6a&IK>+j}P3x8BD8UUN5b`ww-Ce=HAw{$aXq9+qT(`#J|OYB(7@UHx3v IIVCg!003O+KmY&$ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_white.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_white.png index 42c4ce711e8ac21ae02d40425e8a4ddade4f6748..e711e7d0b02af9aa751bf89d8bcb6c1e13b0d2da 100644 GIT binary patch delta 351 zcmZ3_@`XvUGr-TCmrII^fq{Y7)59eQNDBb50t+*ce7XGT|A~qU^(p~AA+DyTrXe9A z2?+^-fq`mjYDGmw_4V~)Vq)*#zyJULzqYpag9i_oWBR#)`Zx_88>qb zH{azvl5v*7xL(3)O0Si~9EmeLXU;S=&uo_T;q~#IJbC71!62=v#RTF&JHGa^N{R(^x(F+#E|m#Z3&0+PWKypPk8^Xq@inuwr6M zhfm4{Ai-qlpfp)PNy<2l;jZ!GPRB)y7vBWpiH=p@-{oF3-Cdra^5EXy>djx@-IbOQ r6X9CPs@YX+sG|{iH0S8kbF2&}--T~{5UX<+=uHMsS3j3^P6e8Nklb}m3={^X$k6=% z=XQ0N=`1(?lqgZSfT{aPwavVpkSV|#k#E*}_gYih+Anf*)Q2Gf_t)#Y>=MN}h zjER$I%#jfe5at}U>U#Dg{0kRBcu#=%&@9G4#IJfqzxA-SG{siIq`~ufER$@Qf*9ZUr00{s| KMNUMnLSTX<8t$6_ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_yellow.png b/src/main/resources/assets/overdrive_that_matters/textures/block/cargo_crates/cargo_crate_yellow.png index 869b0ec60720f92a3c65c89b1b3adc2911a951f6..67d2d174b3b81c1f48ec44b3d355b946c6125a8f 100644 GIT binary patch delta 351 zcmZ3_@`XvUGr-TCmrII^fq{Y7)59eQNDBb50t+*ce7XGT|A~qU^(p~AA+DyTrXe9A z2?+^-fq`mjYDGmw_4V~)Vq$N0EB!gHqOGlccfEr7=1uNEeVhdzk;M!QeEUI|(SkKt z1t@sa)5S4F<9u?0KuC~TkWflOLSbQ{FAygPXzHh%Y3P@y2&{aOlJFv@JSAY|jGH-z zo9}WS$vDekTrXiYrPoSgj>H+BGiREbXEsav@cQ^po;-81V35{ST(5!O}cM1@DLF7>uqoIq;mEX{;W7ZjPm(;wFYgZQYH<&(35{G*0((STV7s z!zbkekYF-&P?{{DBxRh&aMyTor{ki+yd2nxU_2#ed?n+CD riEyoC)$A%Z)X|7MnsfB&IaY>~@4`1eh}F3Z^d^I+tDnm{r-UW|%Kn36 delta 520 zcmeyuw4Oz=Gr-TCmrII^fq{Y7)59eQNGkxb0|zsZ^a*I4Gf`0?P&dFQ#MRW)G$bS> zAt50!Fi=}tyS~2u{|$!!4?NY>)QXCV#Kgqj>{j}7T;=Y1kbZ`@r`&)fe@T#E@P8D* zaOKX7g%k6{>lq6?T^vI^yx)f0EIO>fBf_@y#DzcqpO=-+cxj?E?`8IGxy2DVVzFj| zQ;THW*G70LW*zD8KhXTqWfOUQ8q?$$NrpZ0zx>CgIqqR@zNYm1XihsCgME;o{!q{@H z8fen%G7X04CQS!r#T#s!XSg_Bc;ED3>vq=gAL1wW+}H}DA8`miJ1gk7qv=k%qS^$l zJEB@%xm=km_eS!*y=S6*>uvn+HFp!Y|4_I1$MW#!AExW(VM+G4uX6yShLge5)z4*} HQ$iB}ibd<` From 0ec8f3709a989c3d66b0a39307036639a88caf3d Mon Sep 17 00:00:00 2001 From: GearShocky Date: Tue, 27 Jun 2023 00:22:40 +0600 Subject: [PATCH 0666/1199] Add a few pixels to matter cable texture --- .../textures/block/matter_cable.png | Bin 171 -> 175 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/matter_cable.png b/src/main/resources/assets/overdrive_that_matters/textures/block/matter_cable.png index 8a8dcfa904e401123b2a01174a7c7568bbe53926..544079c53c97cc55af45b757aead4d153f2b2a68 100644 GIT binary patch delta 78 zcmZ3@xSnx>C*J`E2EGG~S=Tx_85kH`CWb4UHr!BPc=VWA-oB3IvX27O5(za2tpzu@ i7bl4HFbO0iFfhCq;Gb;2m%$9Efx*+&&t;ucLK6VKD;JXh delta 74 zcmZ3_xSDZ-C*MH^2EK!gJ0@noWnf@%m>8~Xc;Lp7hJJZ_BZEc>1zrU{%Z4QVo~A$p eE{BFjMusO9{FBS~CX@gbGkCiCxvX Date: Tue, 27 Jun 2023 19:14:10 +0700 Subject: [PATCH 0667/1199] Wireless android charger and misc fixes --- .../mc/otm/datagen/lang/English.kt | 2 + .../mc/otm/datagen/lang/Russian.kt | 1 + .../mc/otm/datagen/loot/LootTablesData.kt | 1 + .../dbotthepony/mc/otm/datagen/tags/Tags.kt | 1 + .../block/entity/MatteryDeviceBlockEntity.kt | 81 +++++++---- .../block/entity/MatteryPoweredBlockEntity.kt | 2 +- .../entity/tech/AndroidChargerBlockEntity.kt | 52 +++++++ .../entity/tech/BatteryBankBlockEntity.kt | 2 +- .../entity/tech/EnergyServoBlockEntity.kt | 1 + .../mc/otm/block/tech/AndroidChargerBlock.kt | 135 ++++++++++++++++++ .../energy/BlockEnergyStorageImpl.kt | 6 +- .../capability/energy/IEnergyStorageImpl.kt | 21 ++- .../client/screen/panels/button/Buttons.kt | 18 ++- .../screen/tech/AndroidChargerScreen.kt | 47 ++++++ .../client/screen/tech/EnergyServoScreen.kt | 18 +-- .../mc/otm/config/MachinesConfig.kt | 12 ++ .../mc/otm/container/MatteryContainer.kt | 6 +- .../ru/dbotthepony/mc/otm/core/LevelExt.kt | 26 ++-- .../otm/menu/input/EnergyConfigPlayerInput.kt | 15 +- .../otm/menu/input/EnumInputWithFeedback.kt | 8 +- .../mc/otm/menu/tech/AndroidChargerMenu.kt | 21 +++ .../mc/otm/menu/tech/BatteryBankMenu.kt | 2 +- .../mc/otm/registry/MBlockEntities.kt | 1 + .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 2 + .../ru/dbotthepony/mc/otm/registry/MItems.kt | 3 +- .../ru/dbotthepony/mc/otm/registry/MMenus.kt | 4 + .../ru/dbotthepony/mc/otm/registry/MNames.kt | 1 + 27 files changed, 402 insertions(+), 87 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/AndroidChargerScreen.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidChargerMenu.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 1af4b870d..4898a13e3 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -226,6 +226,7 @@ private fun misc(provider: MatteryLanguageProvider) { misc("item.power.last_tick", "Last tick: %s") misc("item.power.storage", "Stored energy: %s / %s") + misc("item.power.storage0", "Stored energy: %s") misc("item.power.throughput", "Max I/O: %s / %s") misc("item.power.throughput_mono", "Max I/O: %s") misc("item.power.infinity", "∞ MtJ") @@ -362,6 +363,7 @@ private fun death(provider: MatteryLanguageProvider) { private fun blocks(provider: MatteryLanguageProvider) { with(provider.english) { add(MBlocks.ANDROID_STATION, "Android Station") + add(MBlocks.ANDROID_CHARGER, "Wireless Android Charger") add(MBlocks.BATTERY_BANK, "Battery Bank") add(MBlocks.MATTER_DECOMPOSER, "Matter Decomposer") add(MBlocks.MATTER_CAPACITOR_BANK, "Matter Capacitor Bank") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index a2c5111a1..166f337bc 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -367,6 +367,7 @@ private fun death(provider: MatteryLanguageProvider) { private fun blocks(provider: MatteryLanguageProvider) { with(provider.russian) { add(MBlocks.ANDROID_STATION, "Станция андроидов") + add(MBlocks.ANDROID_CHARGER, "Беспроводной зарядник андроидов") add(MBlocks.BATTERY_BANK, "Банк аккумуляторов") add(MBlocks.MATTER_DECOMPOSER, "Декомпозитор материи") add(MBlocks.MATTER_CAPACITOR_BANK, "Банк накопителей материи") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index 3817e4fe7..971a5b63f 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -137,6 +137,7 @@ fun addLootTables(lootTables: LootTables) { lootTables.tile(MBlocks.HOLO_SIGN, "isLocked") lootTables.tile(MBlocks.STORAGE_CABLE) lootTables.tile(MBlocks.ANDROID_STATION) + lootTables.tile(MBlocks.ANDROID_CHARGER) lootTables.tile(MBlocks.BATTERY_BANK) lootTables.tile(MBlocks.DRIVE_VIEWER) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index 08f622e84..9932f8709 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -180,6 +180,7 @@ fun addTags(tagsProvider: TagsProvider) { MBlocks.ESSENCE_STORAGE, MBlocks.MATTER_RECONSTRUCTOR, MBlocks.FLUID_TANK, + MBlocks.ANDROID_CHARGER, ), Tiers.IRON) tagsProvider.requiresPickaxe(MBlocks.TRITANIUM_ANVIL, Tiers.IRON) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index 44ed68d03..18f816e35 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -32,7 +32,6 @@ import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.core.nbt.getJson import ru.dbotthepony.mc.otm.core.nbt.putJson -import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.ITickable import ru.dbotthepony.mc.otm.once @@ -235,27 +234,51 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo } inner class ConfigurableEnergy( - val capability: T, + val energy: T, - val possibleModes: FlowDirection = capability.energyFlow, + val modesFront: FlowDirection = energy.energyFlow, + val modesBack: FlowDirection = energy.energyFlow, + val modesLeft: FlowDirection = energy.energyFlow, + val modesRight: FlowDirection = energy.energyFlow, + val modesTop: FlowDirection = energy.energyFlow, + val modesBottom: FlowDirection = energy.energyFlow, - val frontDefault: FlowDirection = possibleModes, - val backDefault: FlowDirection = possibleModes, - val leftDefault: FlowDirection = possibleModes, - val rightDefault: FlowDirection = possibleModes, - val topDefault: FlowDirection = possibleModes, - val bottomDefault: FlowDirection = possibleModes, + val frontDefault: FlowDirection = modesFront, + val backDefault: FlowDirection = modesBack, + val leftDefault: FlowDirection = modesLeft, + val rightDefault: FlowDirection = modesRight, + val topDefault: FlowDirection = modesTop, + val bottomDefault: FlowDirection = modesBottom, ) { + constructor( + energy: T, + possibleModes: FlowDirection, + frontDefault: FlowDirection = possibleModes, + backDefault: FlowDirection = possibleModes, + leftDefault: FlowDirection = possibleModes, + rightDefault: FlowDirection = possibleModes, + topDefault: FlowDirection = possibleModes, + bottomDefault: FlowDirection = possibleModes, + ) : this( + energy, + modesFront = possibleModes, frontDefault = frontDefault, + modesBack = possibleModes, backDefault = backDefault, + modesLeft = possibleModes, leftDefault = leftDefault, + modesRight = possibleModes, rightDefault = rightDefault, + modesTop = possibleModes, topDefault = topDefault, + modesBottom = possibleModes, bottomDefault = bottomDefault, + ) + init { - exposeEnergySideless(capability) + exposeEnergySideless(energy) } - val front = Piece(RelativeSide.FRONT).also { it.energyFlow = frontDefault } - val back = Piece(RelativeSide.BACK).also { it.energyFlow = backDefault } - val left = Piece(RelativeSide.LEFT).also { it.energyFlow = leftDefault } - val right = Piece(RelativeSide.RIGHT).also { it.energyFlow = rightDefault } - val top = Piece(RelativeSide.TOP).also { it.energyFlow = topDefault } - val bottom = Piece(RelativeSide.BOTTOM).also { it.energyFlow = bottomDefault } + val front = Piece(RelativeSide.FRONT, modesFront).also { it.energyFlow = frontDefault } + val back = Piece(RelativeSide.BACK, modesBack).also { it.energyFlow = backDefault } + val left = Piece(RelativeSide.LEFT, modesLeft).also { it.energyFlow = leftDefault } + val right = Piece(RelativeSide.RIGHT, modesRight).also { it.energyFlow = rightDefault } + val top = Piece(RelativeSide.TOP, modesTop).also { it.energyFlow = topDefault } + val bottom = Piece(RelativeSide.BOTTOM, modesBottom).also { it.energyFlow = bottomDefault } val pieces = immutableMap { put(RelativeSide.FRONT, front) @@ -275,15 +298,15 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo put(RelativeSide.BOTTOM, bottomDefault) } - inner class Piece(val side: RelativeSide) : IMatteryEnergyStorage, ITickable { + inner class Piece(val side: RelativeSide, val possibleModes: FlowDirection) : IMatteryEnergyStorage, ITickable { private val capControllers = exposeEnergy(side, this@Piece) private val neighbour by sides[side]!!.track(ForgeCapabilities.ENERGY) - override var batteryLevel: Decimal by capability::batteryLevel - override val maxBatteryLevel: Decimal by capability::maxBatteryLevel - override val missingPower: Decimal by capability::missingPower + override var batteryLevel: Decimal by energy::batteryLevel + override val maxBatteryLevel: Decimal by energy::maxBatteryLevel + override val missingPower: Decimal by energy::missingPower - override val canSetBatteryLevel: Boolean by capability::canSetBatteryLevel + override val canSetBatteryLevel: Boolean by energy::canSetBatteryLevel // var automatePull by synchronizer.bool().property var automatePull = false @@ -299,33 +322,33 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo } override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { - return capability.extractEnergy(howMuch, simulate) + return energy.extractEnergy(howMuch, simulate) } override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { - return capability.receiveEnergy(howMuch, simulate) + return energy.receiveEnergy(howMuch, simulate) } override fun extractEnergyChecked(howMuch: Decimal, simulate: Boolean): Decimal { if (energyFlow.output) - return capability.extractEnergyChecked(howMuch, simulate) + return energy.extractEnergyChecked(howMuch, simulate) return Decimal.ZERO } override fun receiveEnergyChecked(howMuch: Decimal, simulate: Boolean): Decimal { if (energyFlow.input) - return capability.receiveEnergyChecked(howMuch, simulate) + return energy.receiveEnergyChecked(howMuch, simulate) return Decimal.ZERO } override fun drainBattery(): Boolean { - return capability.drainBattery() + return energy.drainBattery() } override fun fillBattery(): Boolean { - return capability.fillBattery() + return energy.fillBattery() } override fun tick() { @@ -334,11 +357,11 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo neighbour.ifPresentK { if (energyFlow.input && automatePull) { - moveEnergy(source = it, destination = capability, simulate = false) + moveEnergy(source = it, destination = energy, simulate = false) } if (energyFlow.output && automatePush) { - moveEnergy(source = capability, destination = it, simulate = false) + moveEnergy(source = energy, destination = it, simulate = false) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt index a563312ce..c1ef9e92e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt @@ -32,7 +32,7 @@ abstract class MatteryPoweredBlockEntity(p_155228_: BlockEntityType<*>, p_155229 super.tick() val energy = matteryEnergy - if (energy == null || !batteryContainer.any { !it.isEmpty }) + if (energy == null || batteryContainer.isEmpty) return var demand = energy.receiveEnergy(energy.missingPower, true) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt new file mode 100644 index 000000000..16749c109 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt @@ -0,0 +1,52 @@ +package ru.dbotthepony.mc.otm.block.entity.tech + +import net.minecraft.core.BlockPos +import net.minecraft.world.entity.player.Inventory +import net.minecraft.world.entity.player.Player +import net.minecraft.world.inventory.AbstractContainerMenu +import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.phys.Vec3 +import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity +import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.config.MachinesConfig +import ru.dbotthepony.mc.otm.core.getEntitiesInEllipsoid +import ru.dbotthepony.mc.otm.menu.tech.AndroidChargerMenu +import ru.dbotthepony.mc.otm.registry.MBlockEntities + +class AndroidChargerBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.ANDROID_CHARGER, blockPos, blockState) { + override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu? { + return AndroidChargerMenu(containerID, inventory, this) + } + + val energyConfig = ConfigurableEnergy(ProfiledEnergyStorage(WorkerEnergyStorage(this::setChangedLight, MachinesConfig.ANDROID_CHARGER)), modesTop = FlowDirection.NONE) + + init { + savetables.stateful(energyConfig::energy, ENERGY_KEY) + } + + override fun tick() { + super.tick() + + val level = level ?: return + var available = energyConfig.energy.extractEnergy(energyConfig.energy.batteryLevel, true) + if (!available.isPositive) return + + val ents = level.getEntitiesInEllipsoid(blockPos.center, Vec3(MachinesConfig.AndroidCharger.RADIUS_WIDTH, MachinesConfig.AndroidCharger.RADIUS_HEIGHT, MachinesConfig.AndroidCharger.RADIUS_WIDTH)) { it is Player } + + ents.sort() + + for ((ent) in ents) { + val ply = ent.matteryPlayer ?: continue + + if (ply.isAndroid) { + val received = ply.androidEnergy.receiveEnergyChecked(available, false) + available -= received + energyConfig.energy.extractEnergy(received, false) + if (!available.isPositive) return + } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index f444512cd..f610bbe08 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -181,7 +181,7 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte init { energyConfig.front.automatePush = true - savetables.stateful(Supplier { energyConfig.capability.savedata }, "energyUsageHistory") + savetables.stateful(Supplier { energyConfig.energy.savedata }, "energyUsageHistory") } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt index e50396454..74f2edd4f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt @@ -62,6 +62,7 @@ class EnergyServoBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte }) val energyConfig = ConfigurableEnergy(energy, possibleModes = FlowDirection.BI_DIRECTIONAL) + val itemConfig = ConfigurableItemHandler( input = charge.handler(HandlerFilter.OnlyIn.and(HandlerFilter.Chargeable)), output = discharge.handler(HandlerFilter.OnlyOut.and(HandlerFilter.Dischargeable)) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt new file mode 100644 index 000000000..d7be418c5 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt @@ -0,0 +1,135 @@ +package ru.dbotthepony.mc.otm.block.tech + +import net.minecraft.core.BlockPos +import net.minecraft.network.chat.Component +import net.minecraft.util.StringRepresentable +import net.minecraft.world.entity.LivingEntity +import net.minecraft.world.entity.player.Player +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.TooltipFlag +import net.minecraft.world.item.context.BlockPlaceContext +import net.minecraft.world.level.BlockGetter +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.Block +import net.minecraft.world.level.block.Blocks +import net.minecraft.world.level.block.EntityBlock +import net.minecraft.world.level.block.entity.BlockEntity +import net.minecraft.world.level.block.entity.BlockEntityTicker +import net.minecraft.world.level.block.entity.BlockEntityType +import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.level.block.state.StateDefinition +import net.minecraft.world.level.block.state.properties.EnumProperty +import net.minecraft.world.level.material.PushReaction +import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.AndroidChargerBlockEntity +import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.core.gracefulBlockBreak +import ru.dbotthepony.mc.otm.core.math.plus +import ru.dbotthepony.mc.otm.oncePre + +class AndroidChargerBlock : RotatableMatteryBlock(Properties.of().destroyTime(2.5f).explosionResistance(40f).pushReaction(PushReaction.BLOCK).requiresCorrectToolForDrops()), EntityBlock { + enum class Type : StringRepresentable { + BASE, + MIDDLE, + TOP; + + override fun getSerializedName(): String { + return name.lowercase() + } + } + + override fun createBlockStateDefinition(builder: StateDefinition.Builder) { + super.createBlockStateDefinition(builder) + builder.add(PART) + } + + init { + registerDefaultState(defaultBlockState().setValue(PART, Type.BASE)) + } + + override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { + val level = context.level + if (level.isOutsideBuildHeight(context.clickedPos + BlockPos(0, 0, 2))) return null + + for (i in 1 .. 2) { + val pos = context.clickedPos + BlockPos(0, 0, i) + if (!level.getBlockState(pos).canBeReplaced(context)) return null + } + + return super.getStateForPlacement(context) + } + + override fun setPlacedBy(level: Level, blockPos: BlockPos, blockState: BlockState, entity: LivingEntity?, itemStack: ItemStack) { + super.setPlacedBy(level, blockPos, blockState, entity, itemStack) + + if (blockState[PART] == Type.BASE) { + level.setBlock(blockPos.above(), blockState.setValue(PART, Type.MIDDLE), UPDATE_ALL) + level.setBlock(blockPos.above().above(), blockState.setValue(PART, Type.TOP), UPDATE_ALL) + } + } + + override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity? { + if (p_153216_[PART] != Type.BASE) return null + return AndroidChargerBlockEntity(p_153215_, p_153216_) + } + + override fun getTicker(p_153212_: Level, blockState: BlockState, p_153214_: BlockEntityType): BlockEntityTicker? { + if (p_153212_.isClientSide || blockState[PART] != Type.BASE) return null + return BlockEntityTicker { _, _, _, t -> if (t is AndroidChargerBlockEntity) t.tick() } + } + + override fun getDestroyProgress(p_60466_: BlockState, p_60467_: Player, p_60468_: BlockGetter, p_60469_: BlockPos): Float { + // запрет на ломание не нижнего блока игроком + if (p_60466_[PART] != Type.BASE) return 0f + return super.getDestroyProgress(p_60466_, p_60467_, p_60468_, p_60469_) + } + + override fun neighborChanged(state: BlockState, level: Level, pos: BlockPos, neighbour: Block, neighbourPos: BlockPos, movedByPiston: Boolean) { + super.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston) + + level.oncePre { + if (level.getBlockState(pos) == state) { + when (state[PART]!!) { + Type.BASE -> { + val a = level.getBlockState(pos.above()) + val b = level.getBlockState(pos.above().above()) + + if (a.block != this || b.block != this || a[PART] != Type.MIDDLE || b[PART] != Type.TOP) { + level.gracefulBlockBreak(pos, state) + } + } + + Type.MIDDLE -> { + val a = level.getBlockState(pos.below()) + val b = level.getBlockState(pos.above()) + + if (a.block != this || b.block != this || a[PART] != Type.BASE || b[PART] != Type.TOP) { + level.setBlock(pos, Blocks.AIR.defaultBlockState(), UPDATE_ALL) + } + } + + Type.TOP -> { + val a = level.getBlockState(pos.below()) + val b = level.getBlockState(pos.below().below()) + + if (a.block != this || b.block != this || a[PART] != Type.MIDDLE || b[PART] != Type.BASE) { + level.setBlock(pos, Blocks.AIR.defaultBlockState(), UPDATE_ALL) + } + } + } + } + } + } + + override fun appendHoverText(p_49816_: ItemStack, p_49817_: BlockGetter?, p_49818_: MutableList, p_49819_: TooltipFlag) { + super.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) + WorkerEnergyStorage.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) + MatteryPoweredBlockEntity.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) + } + + companion object { + val PART: EnumProperty = EnumProperty.create("part", Type::class.java) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt index 42d35b2c7..4abaceb73 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt @@ -166,7 +166,7 @@ sealed class BlockEnergyStorageImpl( const val MAX_INPUT_KEY = "max_input" const val MAX_OUTPUT_KEY = "max_output" - fun makeConfigEntry(builder: ForgeConfigSpec.Builder, name: String? = null, capacity: Decimal = DEFAULT_MAX_CAPACITY, throughput: Decimal = DEFAULT_MAX_IO): ConciseBalanceValues { + fun makeConfigEntry(builder: ForgeConfigSpec.Builder, name: String? = null, capacity: Decimal = DEFAULT_MAX_CAPACITY, throughput: Decimal = DEFAULT_MAX_IO, configurator: ForgeConfigSpec.Builder.() -> Unit = {}): ConciseBalanceValues { if (name != null) builder.push(name) @@ -175,6 +175,8 @@ sealed class BlockEnergyStorageImpl( override val throughput: Decimal by builder.defineDecimal("throughput", throughput, Decimal.ONE) } + configurator.invoke(builder) + if (name != null) builder.pop() @@ -226,7 +228,7 @@ open class WorkerEnergyStorage( val tag = (itemStack.tag?.get(BlockItem.BLOCK_ENTITY_TAG) as? CompoundTag)?.get(MatteryBlockEntity.ENERGY_KEY) as? CompoundTag ?: return val cap = WorkerEnergyStorage({}, DEFAULT_MAX_CAPACITY) cap.deserializeNBT(tag) - batteryLevel(cap, tooltips) + batteryLevel(cap, tooltips, false) } fun appendHoverText(itemStack: ItemStack, blockGetter: BlockGetter?, tooltips: MutableList, flag: TooltipFlag) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt index a290fcb05..9903b26db 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IEnergyStorageImpl.kt @@ -23,13 +23,20 @@ internal fun batteryLevel(it: IEnergyStorage, tooltips: MutableList) ).withStyle(ChatFormatting.GRAY)) } -internal fun batteryLevel(it: IMatteryEnergyStorage, tooltips: MutableList) { - tooltips.add( - TranslatableComponent( - "otm.item.power.storage", - it.batteryLevel.formatPower(formatAsReadable = ShiftPressedCond), - it.maxBatteryLevel.formatPower(formatAsReadable = ShiftPressedCond) - ).withStyle(ChatFormatting.GRAY)) +internal fun batteryLevel(it: IMatteryEnergyStorage, tooltips: MutableList, displayMaxLevel: Boolean = true) { + if (displayMaxLevel) + tooltips.add( + TranslatableComponent( + "otm.item.power.storage", + it.batteryLevel.formatPower(formatAsReadable = ShiftPressedCond), + it.maxBatteryLevel.formatPower(formatAsReadable = ShiftPressedCond) + ).withStyle(ChatFormatting.GRAY)) + else + tooltips.add( + TranslatableComponent( + "otm.item.power.storage0", + it.batteryLevel.formatPower(formatAsReadable = ShiftPressedCond) + ).withStyle(ChatFormatting.GRAY)) if (it is IEnergyStorageImpl) { when (it.energyFlow) { 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 d9bbffeec..759e7bdba 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 @@ -128,6 +128,12 @@ private fun > makeEnergyModeButton(screen: S, parent: Frame button.finish() + if (input.possibleModes == FlowDirection.NONE) { + button.visible = false + } + + button.predicate = Predicate { input.possibleModes.isSupertype(it) } + return button } @@ -224,12 +230,12 @@ private fun > makeEnergyConfigPanel( } } - val front = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.FRONT]!!, RelativeSide.FRONT).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } - val back = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.BACK]!!, RelativeSide.BACK).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } - val left = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.LEFT]!!, RelativeSide.LEFT).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } - val right = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.RIGHT]!!, RelativeSide.RIGHT).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } - val top = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.TOP]!!, RelativeSide.TOP).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } - val bottom = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.BOTTOM]!!, RelativeSide.BOTTOM).also { it.predicate = Predicate { inputs.possibleModes.isSupertype(it) } } + val front = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.FRONT]!!, RelativeSide.FRONT) + val back = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.BACK]!!, RelativeSide.BACK) + val left = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.LEFT]!!, RelativeSide.LEFT) + val right = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.RIGHT]!!, RelativeSide.RIGHT) + val top = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.TOP]!!, RelativeSide.TOP) + val bottom = makeEnergyModeButton(screen, frame, inputs.pieces[RelativeSide.BOTTOM]!!, RelativeSide.BOTTOM) moveButtons(front, back, left, right, top, bottom) screen.addPanel(frame) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/AndroidChargerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/AndroidChargerScreen.kt new file mode 100644 index 000000000..2c7037616 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/AndroidChargerScreen.kt @@ -0,0 +1,47 @@ +package ru.dbotthepony.mc.otm.client.screen.tech + +import net.minecraft.network.chat.Component +import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.Dock +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls +import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.SpritePanel +import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalProfiledPowerGaugePanel +import ru.dbotthepony.mc.otm.menu.tech.AndroidChargerMenu + +class AndroidChargerScreen(menu: AndroidChargerMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { + override fun makeMainFrame(): FramePanel> { + val frame = super.makeMainFrame()!! + + frame.height = 42f + frame.width -= 20f + + val strip = EditablePanel(this, frame, height = AbstractSlotPanel.SIZE) + strip.dock = Dock.BOTTOM + + BatterySlotPanel(this, strip, menu.batterySlot).also { + it.dock = Dock.LEFT + it.dockRight = 2f + } + + SpritePanel(this, strip, ProgressGaugePanel.GAUGE_BACKGROUND).also { + it.dock = Dock.LEFT + it.dockRight = 2f + it.dockTop = 2f + } + + TallHorizontalProfiledPowerGaugePanel(this, strip, menu.profiledEnergy).also { + it.dock = Dock.LEFT + it.dockRight = 2f + } + + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig) + + return frame + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt index 7729e32b3..bdaa7aeb4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.client.screen.tech -import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory @@ -14,9 +13,9 @@ import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.PlayerEquipmentPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.makeCuriosPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.SpritePanel import ru.dbotthepony.mc.otm.client.screen.widget.HorizontalPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel -import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.menu.tech.EnergyServoMenu @@ -40,17 +39,10 @@ class EnergyServoScreen(menu: EnergyServoMenu, inventory: Inventory, title: Comp it.dockRight = 2f } - object : EditablePanel(this@EnergyServoScreen, strip) { - init { - dock = Dock.LEFT - dockRight = 2f - dockTop = 2f - width = ProgressGaugePanel.GAUGE_BACKGROUND.width - } - - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { - ProgressGaugePanel.GAUGE_BACKGROUND.render(graphics) - } + SpritePanel(this, strip, ProgressGaugePanel.GAUGE_BACKGROUND).also { + it.dock = Dock.LEFT + it.dockRight = 2f + it.dockTop = 2f } TallHorizontalProfiledPowerGaugePanel(this, strip, menu.powerGauge).also { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt index 4efd5d53c..8fc6c4cef 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt @@ -30,4 +30,16 @@ object MachinesConfig : AbstractConfig("machines") { val ITEM_MONITOR = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.ITEM_MONITOR) val DRIVE_VIEWER = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.DRIVE_VIEWER) val DRIVE_RACK = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.DRIVE_RACK, capacity = Decimal(80_000)) + + object AndroidCharger { + val RADIUS_WIDTH: Double by builder + .comment("Effective charger range on horizontal plane") + .defineInRange("RADIUS_WIDTH", 16.0, 1.0, Double.MAX_VALUE) + + val RADIUS_HEIGHT: Double by builder + .comment("Effective charger range on vertical plane") + .defineInRange("RADIUS_HEIGHT", 4.0, 1.0, Double.MAX_VALUE) + } + + val ANDROID_CHARGER = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.ANDROID_CHARGER, capacity = Decimal(400_000), throughput = Decimal(8192)) { AndroidCharger } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt index 757662ebd..186726e8a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt @@ -360,11 +360,7 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I } override fun isEmpty(): Boolean { - for (stack in slots) - if (!stack.isEmpty) - return false - - return true + return slots.all { it.isEmpty } } operator fun get(slot: Int) = getItem(slot) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/LevelExt.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/LevelExt.kt index 38d70d4b8..6e03b8bff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/LevelExt.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/LevelExt.kt @@ -9,10 +9,16 @@ import java.util.LinkedList import java.util.function.Predicate import kotlin.math.pow +data class EntityDistance(val entity: T, val distance: Double) : Comparable> { + override fun compareTo(other: EntityDistance<*>): Int { + return distance.compareTo(other.distance) + } +} + /** * Pair of entity and distance fraction to center of ellipsoid */ -fun Level.getEntitiesInEllipsoid(pos: Vector, dimensions: Vector, except: Entity?, predicate: Predicate): List> { +fun Level.getEntitiesInEllipsoid(pos: Vector, dimensions: Vector, except: Entity?, predicate: Predicate): MutableList> { val entities = getEntities(except, AABB( pos.x - dimensions.x, pos.y - dimensions.y, @@ -23,7 +29,7 @@ fun Level.getEntitiesInEllipsoid(pos: Vector, dimensions: Vector, except: Entity pos.z + dimensions.z, ), predicate) - val result = LinkedList>() + val result = ArrayList>() for (it in entities) { val a = (it.position - pos).let { vec -> @@ -41,7 +47,7 @@ fun Level.getEntitiesInEllipsoid(pos: Vector, dimensions: Vector, except: Entity val min = a.coerceAtMost(b) if (min <= 1.0) { - result.add(it to min) + result.add(EntityDistance(it, min)) } } @@ -51,7 +57,7 @@ fun Level.getEntitiesInEllipsoid(pos: Vector, dimensions: Vector, except: Entity /** * Pair of entity and distance fraction to center of ellipsoid */ -fun Level.getEntitiesInEllipsoid(type: Class, pos: Vector, dimensions: Vector, predicate: Predicate): List> { +fun Level.getEntitiesInEllipsoid(type: Class, pos: Vector, dimensions: Vector, predicate: Predicate): MutableList> { val entities = getEntitiesOfClass(type, AABB( pos.x - dimensions.x, pos.y - dimensions.y, @@ -62,7 +68,7 @@ fun Level.getEntitiesInEllipsoid(type: Class, pos: Vector, d pos.z + dimensions.z, ), predicate) - val result = LinkedList>() + val result = ArrayList>() for (it in entities) { val a = (it.position - pos).let { vec -> @@ -80,7 +86,7 @@ fun Level.getEntitiesInEllipsoid(type: Class, pos: Vector, d val min = a.coerceAtMost(b) if (min <= 1.0) { - result.add(it to min) + result.add(EntityDistance(it, min)) } } @@ -90,27 +96,27 @@ fun Level.getEntitiesInEllipsoid(type: Class, pos: Vector, d /** * Pair of entity and distance fraction to center of ellipsoid */ -fun Level.getEntitiesInEllipsoid(pos: Vector, dimensions: Vector, predicate: Predicate): List> { +fun Level.getEntitiesInEllipsoid(pos: Vector, dimensions: Vector, predicate: Predicate): MutableList> { return getEntitiesInEllipsoid(pos, dimensions, null, predicate) } /** * Pair of entity and distance fraction to center of ellipsoid */ -fun Level.getEntitiesInSphere(pos: Vector, radius: Double, except: Entity?, predicate: Predicate): List> { +fun Level.getEntitiesInSphere(pos: Vector, radius: Double, except: Entity?, predicate: Predicate): MutableList> { return getEntitiesInEllipsoid(pos, Vector(radius, radius, radius), except, predicate) } /** * Pair of entity and distance fraction to center of ellipsoid */ -fun Level.getEntitiesInSphere(pos: Vector, radius: Double, predicate: Predicate): List> { +fun Level.getEntitiesInSphere(pos: Vector, radius: Double, predicate: Predicate): MutableList> { return getEntitiesInEllipsoid(pos, Vector(radius, radius, radius), null, predicate) } /** * Pair of entity and distance fraction to center of ellipsoid */ -fun Level.getEntitiesInSphere(type: Class, pos: Vector, radius: Double, predicate: Predicate): List> { +fun Level.getEntitiesInSphere(type: Class, pos: Vector, radius: Double, predicate: Predicate): MutableList> { return getEntitiesInEllipsoid(type, pos, Vector(radius, radius, radius), predicate) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyConfigPlayerInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyConfigPlayerInput.kt index 3525c023f..0205c1d57 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyConfigPlayerInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnergyConfigPlayerInput.kt @@ -10,14 +10,14 @@ import ru.dbotthepony.mc.otm.menu.MatteryMenu * [allowPull] and [allowPush] controls whenever player is allowed to change these options */ class EnergyConfigPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockEntity.ConfigurableEnergy<*>? = null, val allowPull: Boolean = false, val allowPush: Boolean = false) { - var possibleModes by menu.mSynchronizer.enum(FlowDirection::class.java) - private set - inner class Piece(val side: RelativeSide) { val pull = BooleanInputWithFeedback(menu) val push = BooleanInputWithFeedback(menu) val input = EnumInputWithFeedback(menu) + var possibleModes by menu.mSynchronizer.enum(FlowDirection::class.java) + private set + var default by menu.mSynchronizer.enum(FlowDirection.NONE) init { @@ -25,20 +25,19 @@ class EnergyConfigPlayerInput(val menu: MatteryMenu, config: MatteryDeviceBlockE push.filter { allowPush && possibleModes.isSupertype(FlowDirection.OUTPUT) } } - fun with(config: MatteryDeviceBlockEntity.ConfigurableEnergy<*>.Piece, parent: MatteryDeviceBlockEntity.ConfigurableEnergy<*>) { + fun with(config: MatteryDeviceBlockEntity.ConfigurableEnergy<*>.Piece) { + possibleModes = config.possibleModes pull.with(config::automatePull) push.with(config::automatePush) - input.withSupplier { config.energyFlow }.withConsumer { if (parent.possibleModes.isSupertype(it)) config.energyFlow = it } + input.withSupplier { config.energyFlow }.withConsumer { if (possibleModes.isSupertype(it)) config.energyFlow = it } } } val pieces = immutableMap { for (side in RelativeSide.values()) put(side, Piece(side)) } fun with(config: MatteryDeviceBlockEntity.ConfigurableEnergy<*>) { - possibleModes = config.possibleModes - for ((side, v) in config.pieces) { - pieces[side]!!.with(v, config) + pieces[side]!!.with(v) pieces[side]!!.default = config.defaults[side]!! } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt index 457b3674b..61df43a35 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt @@ -6,7 +6,7 @@ import ru.dbotthepony.mc.otm.menu.MatteryMenu import kotlin.reflect.KMutableProperty0 inline fun > EnumInputWithFeedback(menu: MatteryMenu) = EnumInputWithFeedback(menu, E::class.java) -inline fun > EnumInputWithFeedback(menu: MatteryMenu, state: KMutableProperty0) = EnumInputWithFeedback(menu, E::class.java, state) +inline fun > EnumInputWithFeedback(menu: MatteryMenu, state: KMutableProperty0?) = EnumInputWithFeedback(menu, E::class.java, state) inline fun > EnumInputWithFeedback(menu: MatteryMenu, state: GetterSetter) = EnumInputWithFeedback(menu, E::class.java, state) class EnumInputWithFeedback>(menu: MatteryMenu, clazz: Class) : AbstractPlayerInputWithFeedback() { @@ -16,8 +16,10 @@ class EnumInputWithFeedback>(menu: MatteryMenu, clazz: Class) : A override val input = menu.PlayerInput(codec, false) { consumer?.invoke(it) } override val value by menu.mSynchronizer.ComputedField(getter = { supplier?.invoke() ?: default }, codec) - constructor(menu: MatteryMenu, clazz: Class, state: KMutableProperty0) : this(menu, clazz) { - with(state) + constructor(menu: MatteryMenu, clazz: Class, state: KMutableProperty0?) : this(menu, clazz) { + if (state != null) { + with(state) + } } constructor(menu: MatteryMenu, clazz: Class, state: GetterSetter) : this(menu, clazz) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidChargerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidChargerMenu.kt new file mode 100644 index 000000000..9b50f53c5 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidChargerMenu.kt @@ -0,0 +1,21 @@ +package ru.dbotthepony.mc.otm.menu.tech + +import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.block.entity.tech.AndroidChargerBlockEntity +import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu +import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput +import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget +import ru.dbotthepony.mc.otm.registry.MMenus + +class AndroidChargerMenu( + p_38852_: Int, + inventory: Inventory, + tile: AndroidChargerBlockEntity? = null +) : MatteryPoweredMenu(MMenus.ANDROID_CHARGER, p_38852_, inventory, tile) { + val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) + val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energyConfig?.energy, energyWidget) + + init { + addInventorySlots() + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt index a9d284f09..af4335ec6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/BatteryBankMenu.kt @@ -21,7 +21,7 @@ class BatteryBankMenu @JvmOverloads constructor( inventory: Inventory, tile: BatteryBankBlockEntity? = null, ) : MatteryMenu(MMenus.BATTERY_BANK, p_38852_, inventory, tile) { - val powerLevel = ProfiledLevelGaugeWidget(this, tile?.energyConfig?.capability) + val powerLevel = ProfiledLevelGaugeWidget(this, tile?.energyConfig?.energy) val storageSlots: List val redstone = EnumInputWithFeedback(this, RedstoneSetting::class.java) val energyConfig = EnergyConfigPlayerInput(this, allowPull = false, allowPush = true) 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 49767b43c..6bfc64e38 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt @@ -55,6 +55,7 @@ object MBlockEntities { val ESSENCE_STORAGE: BlockEntityType by registry.register(MNames.ESSENCE_STORAGE) { BlockEntityType.Builder.of(::EssenceStorageBlockEntity, MBlocks.ESSENCE_STORAGE).build(null) } val MATTER_RECONSTRUCTOR: BlockEntityType by registry.register(MNames.MATTER_RECONSTRUCTOR) { BlockEntityType.Builder.of(::MatterReconstructorBlockEntity, MBlocks.MATTER_RECONSTRUCTOR).build(null) } val FLUID_TANK: BlockEntityType by registry.register(MNames.FLUID_TANK) { BlockEntityType.Builder.of(::FluidTankBlockEntity, MBlocks.FLUID_TANK).build(null) } + val ANDROID_CHARGER: BlockEntityType by registry.register(MNames.ANDROID_CHARGER) { BlockEntityType.Builder.of(::AndroidChargerBlockEntity, MBlocks.ANDROID_CHARGER).build(null) } val STORAGE_BUS: BlockEntityType by registry.register(MNames.STORAGE_BUS) { BlockEntityType.Builder.of(::StorageBusBlockEntity, MBlocks.STORAGE_BUS).build(null) } val STORAGE_IMPORTER: BlockEntityType by registry.register(MNames.STORAGE_IMPORTER) { BlockEntityType.Builder.of(::StorageImporterBlockEntity, MBlocks.STORAGE_IMPORTER).build(null) } 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 6e4b99881..474441f83 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -58,6 +58,7 @@ import ru.dbotthepony.mc.otm.block.storage.StorageBusBlock import ru.dbotthepony.mc.otm.block.storage.StorageExporterBlock import ru.dbotthepony.mc.otm.block.storage.StorageImporterBlock import ru.dbotthepony.mc.otm.block.storage.StoragePowerSupplierBlock +import ru.dbotthepony.mc.otm.block.tech.AndroidChargerBlock import ru.dbotthepony.mc.otm.block.tech.CobblerBlock import ru.dbotthepony.mc.otm.block.tech.EssenceStorageBlock import ru.dbotthepony.mc.otm.core.TranslatableComponent @@ -71,6 +72,7 @@ object MBlocks { } val ANDROID_STATION: Block by registry.register(MNames.ANDROID_STATION) { AndroidStationBlock() } + val ANDROID_CHARGER: Block by registry.register(MNames.ANDROID_CHARGER) { AndroidChargerBlock() } val BATTERY_BANK: Block by registry.register(MNames.BATTERY_BANK) { BatteryBankBlock() } val MATTER_DECOMPOSER: Block by registry.register(MNames.MATTER_DECOMPOSER) { MatterDecomposerBlock() } val MATTER_CAPACITOR_BANK: Block by registry.register(MNames.MATTER_CAPACITOR_BANK) { MatterCapacitorBankBlock() } 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 6ab288fe1..4577d88c7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -44,6 +44,7 @@ object MItems { } val ANDROID_STATION: BlockItem by registry.register(MNames.ANDROID_STATION) { BlockItem(MBlocks.ANDROID_STATION, DEFAULT_PROPERTIES) } + val ANDROID_CHARGER: BlockItem by registry.register(MNames.ANDROID_CHARGER) { BlockItem(MBlocks.ANDROID_CHARGER, DEFAULT_PROPERTIES) } val BATTERY_BANK: BlockItem by registry.register(MNames.BATTERY_BANK) { BlockItem(MBlocks.BATTERY_BANK, DEFAULT_PROPERTIES) } val MATTER_DECOMPOSER: BlockItem by registry.register(MNames.MATTER_DECOMPOSER) { BlockItem(MBlocks.MATTER_DECOMPOSER, DEFAULT_PROPERTIES) } val MATTER_CAPACITOR_BANK: BlockItem by registry.register(MNames.MATTER_CAPACITOR_BANK) { BlockItem(MBlocks.MATTER_CAPACITOR_BANK, DEFAULT_PROPERTIES) } @@ -134,7 +135,7 @@ object MItems { } val MACHINES = SupplierList( - ::ANDROID_STATION, ::BATTERY_BANK, ::MATTER_DECOMPOSER, ::MATTER_CAPACITOR_BANK, ::MATTER_CABLE, ::PATTERN_STORAGE, + ::ANDROID_STATION, ::ANDROID_CHARGER, ::BATTERY_BANK, ::MATTER_DECOMPOSER, ::MATTER_CAPACITOR_BANK, ::MATTER_CABLE, ::PATTERN_STORAGE, ::MATTER_SCANNER, ::MATTER_PANEL, ::MATTER_REPLICATOR, ::MATTER_BOTTLER, ::ENERGY_COUNTER, ::CHEMICAL_GENERATOR, ::PLATE_PRESS, ::TWIN_PLATE_PRESS, ::MATTER_RECYCLER, // ::STORAGE_BUS, ::STORAGE_IMPORTER, ::STORAGE_EXPORTER, ::DRIVE_VIEWER, 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 8e6f0e6f4..f4c515991 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt @@ -28,6 +28,7 @@ import ru.dbotthepony.mc.otm.client.screen.storage.StorageBusScreen import ru.dbotthepony.mc.otm.client.screen.storage.StorageExporterScreen import ru.dbotthepony.mc.otm.client.screen.storage.StorageImporterScreen import ru.dbotthepony.mc.otm.client.screen.storage.StoragePowerSupplierScreen +import ru.dbotthepony.mc.otm.client.screen.tech.AndroidChargerScreen import ru.dbotthepony.mc.otm.client.screen.tech.AndroidStationScreen import ru.dbotthepony.mc.otm.client.screen.tech.BatteryBankScreen import ru.dbotthepony.mc.otm.client.screen.tech.ChemicalGeneratorScreen @@ -57,6 +58,7 @@ import ru.dbotthepony.mc.otm.menu.storage.StorageBusMenu import ru.dbotthepony.mc.otm.menu.storage.StorageExporterMenu import ru.dbotthepony.mc.otm.menu.storage.StorageImporterMenu import ru.dbotthepony.mc.otm.menu.storage.StoragePowerSupplierMenu +import ru.dbotthepony.mc.otm.menu.tech.AndroidChargerMenu import ru.dbotthepony.mc.otm.menu.tech.AndroidStationMenu import ru.dbotthepony.mc.otm.menu.tech.BatteryBankMenu import ru.dbotthepony.mc.otm.menu.tech.ChemicalGeneratorMenu @@ -71,6 +73,7 @@ object MMenus { private val registry = DeferredRegister.create(ForgeRegistries.MENU_TYPES, OverdriveThatMatters.MOD_ID) val ANDROID_STATION: MenuType by registry.register(MNames.ANDROID_STATION) { MenuType(::AndroidStationMenu, FeatureFlags.VANILLA_SET) } + val ANDROID_CHARGER: MenuType by registry.register(MNames.ANDROID_CHARGER) { MenuType(::AndroidChargerMenu, FeatureFlags.VANILLA_SET) } val BATTERY_BANK: MenuType by registry.register(MNames.BATTERY_BANK) { MenuType(::BatteryBankMenu, FeatureFlags.VANILLA_SET) } val MATTER_DECOMPOSER: MenuType by registry.register(MNames.MATTER_DECOMPOSER) { MenuType(::MatterDecomposerMenu, FeatureFlags.VANILLA_SET) } val MATTER_CAPACITOR_BANK: MenuType by registry.register(MNames.MATTER_CAPACITOR_BANK) { MenuType(::MatterCapacitorBankMenu, FeatureFlags.VANILLA_SET) } @@ -110,6 +113,7 @@ object MMenus { private fun registerClient(event: FMLClientSetupEvent) { event.enqueueWork { MenuScreens.register(ANDROID_STATION, ::AndroidStationScreen) + MenuScreens.register(ANDROID_CHARGER, ::AndroidChargerScreen) MenuScreens.register(BATTERY_BANK, ::BatteryBankScreen) MenuScreens.register(MATTER_DECOMPOSER, ::MatterDecomposerScreen) MenuScreens.register(MATTER_CAPACITOR_BANK, ::MatterCapacitorBankScreen) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index bafe6e318..37d3e2ad3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -12,6 +12,7 @@ object MNames { const val ENGINE = "engine" const val HOLO_SIGN = "holo_sign" const val FLUID_TANK = "fluid_tank" + const val ANDROID_CHARGER = "android_charger" // blocks const val ANDROID_STATION = "android_station" From d74c8a06f5a739067b55bfb686796cd066365e38 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 27 Jun 2023 20:51:18 +0700 Subject: [PATCH 0668/1199] Damage android players in event of battery discharge --- .../dbotthepony/mc/otm/datagen/DamageTypes.kt | 4 ++ .../otm/capability/MatteryPlayerCapability.kt | 47 +++++++++++++++---- .../mc/otm/registry/MDamageTypes.kt | 1 + 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DamageTypes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DamageTypes.kt index 40bcca1c9..525fbf309 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DamageTypes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DamageTypes.kt @@ -23,6 +23,7 @@ fun registerDamageTypes(context: BootstapContext) { context.register(MDamageTypes.COSMIC_RAYS, DamageType("otm_cosmic_rays", DamageScaling.NEVER, 0f)) context.register(MDamageTypes.EXPLOSIVE_HAMMER, DamageType("otm_explosive_hammer", DamageScaling.NEVER, 0.1f)) context.register(MDamageTypes.HAMMER_NAIL, DamageType("otm_hammer_nail", DamageScaling.NEVER, 0.1f)) + context.register(MDamageTypes.ANDROID_DISCHARGE, DamageType("otm_android_discharge", DamageScaling.NEVER, 4.0f)) } fun registerDamageTypeTags(provider: TagsProvider.Delegate) { @@ -38,14 +39,17 @@ fun registerDamageTypeTags(provider: TagsProvider.Delegate) { .add(MDamageTypes.EMP) .add(MDamageTypes.SHOCKWAVE) .add(MDamageTypes.COSMIC_RAYS) + .add(MDamageTypes.ANDROID_DISCHARGE) ignoreMagic .add(MDamageTypes.EXOPACK_PROBE) .add(MDamageTypes.BECOME_ANDROID) .add(MDamageTypes.BECOME_HUMANE) .add(MDamageTypes.COSMIC_RAYS) + .add(MDamageTypes.ANDROID_DISCHARGE) ignoreInvl .add(MDamageTypes.BECOME_HUMANE) .add(MDamageTypes.BECOME_ANDROID) + .add(MDamageTypes.ANDROID_DISCHARGE) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index f7bccfebb..eb75317a7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -11,6 +11,7 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import net.minecraft.tags.TagKey import net.minecraft.world.Difficulty +import net.minecraft.world.damagesource.DamageSource import net.minecraft.world.effect.MobEffect import net.minecraft.world.effect.MobEffectInstance import net.minecraft.world.effect.MobEffects @@ -51,6 +52,8 @@ import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidResearchType import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.energy.AndroidPowerSource +import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact +import ru.dbotthepony.mc.otm.capability.energy.receiveEnergyExact import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.container.MatteryContainer @@ -277,6 +280,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial private var shouldPlaySound = false private val research = IdentityHashMap() + private var nextDischargeHurt = 20 // players tracking us // stored separately because EntityTracker and ChunkMup, etc are buried deep and @@ -335,6 +339,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial savetables.bool(::hasExoPack, "hasExoSuit") savetables.bool(::displayExoPack, "displayExoSuit") savetables.bool(::isExoPackCraftingUpgraded, "isExoSuitCraftingUpgraded") + savetables.int(::nextDischargeHurt) savetables.vector(::lastOutsideLiquid) savetables.location(::lastDimension) @@ -876,18 +881,21 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } val stats = ply.foodData + val fourTimesTheHunger = AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT * 4 - while (stats.foodLevel < 18 && androidEnergy.extractEnergy(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT, true) >= AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT) { - androidEnergy.extractEnergy(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false) - stats.foodLevel = stats.foodLevel + 1 + // Обычный голод + while ( + stats.foodLevel < 18 && + androidEnergy.batteryLevel >= fourTimesTheHunger && + androidEnergy.extractEnergyExact(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false) + ) { + stats.foodLevel++ } - // "block" quick regeneration - // also cause power to generate while in peaceful + // "поглощение" излишек голода, как при мирном режиме, так и при поедании обычной еды if (AndroidConfig.REGENERATE_ENERGY) { - while (stats.foodLevel > 18 && androidEnergy.receiveEnergy(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT, true) >= AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT) { - androidEnergy.receiveEnergy(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false) - stats.foodLevel = stats.foodLevel - 1 + while (stats.foodLevel > 18 && androidEnergy.receiveEnergyExact(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false)) { + stats.foodLevel-- } } else if (ply.level().server?.worldData?.difficulty != Difficulty.PEACEFUL) { stats.foodLevel = stats.foodLevel.coerceAtMost(18) @@ -895,15 +903,33 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial val foodLevel = stats.foodLevel.toFloat() - if (stats.saturationLevel < foodLevel) { + // насыщение + if (stats.saturationLevel < foodLevel && androidEnergy.batteryLevel >= fourTimesTheHunger) { val extracted = androidEnergy.extractEnergy(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT * (foodLevel - stats.saturationLevel), false) stats.setSaturation(stats.saturationLevel + (extracted / AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT).toFloat()) } - if (stats.exhaustionLevel > 0f) { + // истощение + if (stats.exhaustionLevel > 0f && androidEnergy.batteryLevel >= fourTimesTheHunger) { val extracted = androidEnergy.extractEnergy(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT * (stats.exhaustionLevel / 4f), false) stats.setExhaustion(stats.exhaustionLevel - (extracted / AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT).toFloat() * 4f) } + + if (androidEnergy.batteryLevel <= Decimal.TEN && !ply.isCreative && ply.level().server?.worldData?.difficulty != Difficulty.PEACEFUL) { + if (stats.foodLevel <= 6 || !androidEnergy.receiveEnergyExact(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false).also { if (it) stats.foodLevel-- }) { + if (--nextDischargeHurt <= 0 && ply.hurt(DamageSource(ply.level().registryAccess().damageType(MDamageTypes.ANDROID_DISCHARGE)), 1f)) { + nextDischargeHurt = 20 + } + + val effect = ply.activeEffectsMap[MobEffects.MOVEMENT_SLOWDOWN] + + if (effect == null || effect.duration < 40 || effect.amplifier < 2) { + ply.addEffect(MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, effect?.duration?.coerceAtLeast(60) ?: 60, effect?.amplifier?.coerceAtLeast(2) ?: 2, false, false)) + } + } + } else { + nextDischargeHurt = 20 + } } for (feature in featureMap.values) { @@ -1223,6 +1249,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial mattery.iteration++ mattery.shouldSendIteration = true mattery.deathLog.addLast(ply.tickCount to ply.combatTracker.deathMessage) + mattery.androidEnergy.fillBattery() // если смерть была от разряда батареи, то предотвращаем софтлок while (mattery.deathLog.size > 6) { mattery.deathLog.removeFirst() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MDamageTypes.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MDamageTypes.kt index f4f3b8e8d..a1af1bade 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MDamageTypes.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MDamageTypes.kt @@ -20,4 +20,5 @@ object MDamageTypes { val COSMIC_RAYS = register("cosmic_rays") val EXPLOSIVE_HAMMER = register("explosive_hammer") val HAMMER_NAIL = register("hammer_nail") + val ANDROID_DISCHARGE = register("android_discharge") } From 48d58c42dcecfc0ad5e5266575f4874b5806227c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 27 Jun 2023 21:59:14 +0700 Subject: [PATCH 0669/1199] Further update hunger handling and patch FoodData --- .../mc/otm/mixin/FoodDataMixin.java | 49 +++++++++++++++++++ .../feature/NanobotsRegenerationFeature.kt | 3 +- .../otm/capability/MatteryPlayerCapability.kt | 45 +++++++++++++---- .../mc/otm/config/AndroidConfig.kt | 13 ++++- .../overdrive_that_matters.mixins.json | 1 + 5 files changed, 100 insertions(+), 11 deletions(-) create mode 100644 src/main/java/ru/dbotthepony/mc/otm/mixin/FoodDataMixin.java diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/FoodDataMixin.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/FoodDataMixin.java new file mode 100644 index 000000000..bcccde05d --- /dev/null +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/FoodDataMixin.java @@ -0,0 +1,49 @@ +package ru.dbotthepony.mc.otm.mixin; + +import net.minecraft.world.Difficulty; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.food.FoodData; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import ru.dbotthepony.mc.otm.capability.MatteryCapability; + +@Mixin(FoodData.class) +public class FoodDataMixin { + @Shadow + private int lastFoodLevel; + @Shadow + private int tickTimer; + @Shadow + private int foodLevel; + @Shadow + private float exhaustionLevel; + + @Inject( + method = "tick(Lnet/minecraft/world/entity/player/Player;)V", + at = @At("HEAD"), + cancellable = true + ) + private void tick(Player player, CallbackInfo info) { + player.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresent(it -> { + if (it.isAndroid()) { + info.cancel(); + + // полностью подменяем логику если андроид + lastFoodLevel = foodLevel; + + if (player.level().getDifficulty() == Difficulty.PEACEFUL) { + exhaustionLevel = 0f; + } else { + tickTimer = 0; + } + + // не обновляем уровень истощения ибо он обнуляется логикой внутри MatteryPlayerCapability + // а так же не регенерируем + // ну и не получаем урон от "голодания" + } + }); + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsRegenerationFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsRegenerationFeature.kt index 539fd57c4..b5cd2d73c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsRegenerationFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsRegenerationFeature.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.android.feature import net.minecraft.nbt.CompoundTag import net.minecraft.server.level.ServerPlayer +import net.minecraft.world.level.GameRules import net.minecraftforge.event.entity.living.LivingHurtEvent import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.android.AndroidFeature @@ -16,7 +17,7 @@ class NanobotsRegenerationFeature(android: MatteryPlayerCapability) : AndroidFea private var healTicks = 0 override fun tickServer() { - if (ply.health > 0f && ply.health < ply.maxHealth) { + if (ply.isHurt && ply.level().gameRules.getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { ticksPassed++ val waitTime = AndroidConfig.NanobotsRegeneration.COOLDOWN.getOrElse(healTicks) { AndroidConfig.NanobotsRegeneration.COOLDOWN.last() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index eb75317a7..110ba7170 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -26,6 +26,7 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.item.ProjectileWeaponItem import net.minecraft.world.item.enchantment.EnchantmentHelper.hasVanishingCurse +import net.minecraft.world.level.GameRules import net.minecraft.world.level.Level import net.minecraft.world.phys.Vec3 import net.minecraftforge.common.ForgeHooks @@ -281,6 +282,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial private var shouldPlaySound = false private val research = IdentityHashMap() private var nextDischargeHurt = 20 + private var nextHealTick = 0 // players tracking us // stored separately because EntityTracker and ChunkMup, etc are buried deep and @@ -340,6 +342,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial savetables.bool(::displayExoPack, "displayExoSuit") savetables.bool(::isExoPackCraftingUpgraded, "isExoSuitCraftingUpgraded") savetables.int(::nextDischargeHurt) + savetables.int(::nextHealTick) savetables.vector(::lastOutsideLiquid) savetables.location(::lastDimension) @@ -883,6 +886,12 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial val stats = ply.foodData val fourTimesTheHunger = AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT * 4 + // истощение + if (stats.exhaustionLevel > 0f) { + val extracted = androidEnergy.extractEnergy(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT * (stats.exhaustionLevel / 4f), false) + stats.setExhaustion(stats.exhaustionLevel - (extracted / AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT).toFloat() * 4f) + } + // Обычный голод while ( stats.foodLevel < 18 && @@ -894,10 +903,10 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial // "поглощение" излишек голода, как при мирном режиме, так и при поедании обычной еды if (AndroidConfig.REGENERATE_ENERGY) { - while (stats.foodLevel > 18 && androidEnergy.receiveEnergyExact(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false)) { + while (stats.foodLevel > 18 && androidEnergy.receiveEnergyExact(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT / 2, false)) { stats.foodLevel-- } - } else if (ply.level().server?.worldData?.difficulty != Difficulty.PEACEFUL) { + } else if (ply.level().difficulty != Difficulty.PEACEFUL) { stats.foodLevel = stats.foodLevel.coerceAtMost(18) } @@ -909,14 +918,23 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial stats.setSaturation(stats.saturationLevel + (extracted / AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT).toFloat()) } - // истощение - if (stats.exhaustionLevel > 0f && androidEnergy.batteryLevel >= fourTimesTheHunger) { - val extracted = androidEnergy.extractEnergy(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT * (stats.exhaustionLevel / 4f), false) - stats.setExhaustion(stats.exhaustionLevel - (extracted / AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT).toFloat() * 4f) - } + if (androidEnergy.batteryLevel <= Decimal.TEN && !ply.isCreative && ply.level().difficulty != Difficulty.PEACEFUL) { + if (stats.saturationLevel > 1f) { + if (androidEnergy.receiveEnergyExact(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false)) { + stats.setSaturation(stats.saturationLevel - 1f) + } + } else if (stats.saturationLevel > 0f) { + val received = androidEnergy.receiveEnergy(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT * stats.saturationLevel, false) + stats.setSaturation(stats.saturationLevel - (received / AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT).toFloat()) + } else if (stats.foodLevel > 0) { + // так как голод не тикает для андроидов, "умереть с голоду" мы не можем + // но со стороны будет выглядеть как будто мы умираем с голода + if (androidEnergy.receiveEnergyExact(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false)) { + stats.foodLevel-- + } + } - if (androidEnergy.batteryLevel <= Decimal.TEN && !ply.isCreative && ply.level().server?.worldData?.difficulty != Difficulty.PEACEFUL) { - if (stats.foodLevel <= 6 || !androidEnergy.receiveEnergyExact(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false).also { if (it) stats.foodLevel-- }) { + if (androidEnergy.batteryLevel <= Decimal.TEN) { if (--nextDischargeHurt <= 0 && ply.hurt(DamageSource(ply.level().registryAccess().damageType(MDamageTypes.ANDROID_DISCHARGE)), 1f)) { nextDischargeHurt = 20 } @@ -929,6 +947,15 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } } else { nextDischargeHurt = 20 + + if (ply.isHurt && ply.level().gameRules.getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { + if (--nextHealTick <= 0) { + nextHealTick = if (ply.level().difficulty == Difficulty.PEACEFUL) 10 else AndroidConfig.TIME_BETWEEN_NATURAL_REGENERATION + ply.heal(1f) + } + } else { + nextHealTick = if (ply.level().difficulty == Difficulty.PEACEFUL) 10 else AndroidConfig.TIME_BETWEEN_NATURAL_REGENERATION + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt index 3a6981e53..55cfb0e5c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt @@ -11,6 +11,17 @@ object AndroidConfig : AbstractConfig("androids") { .comment("If this is disabled, any (technically) excess hunger will be nullified, unless playing on peaceful difficulty.") .define("REGENERATE_ENERGY", true) + val TIME_BETWEEN_NATURAL_REGENERATION: Int by builder + .comment("Time in ticks between natural health regeneration ticks") + .comment("Default value is meant to be one of downsides of being an android,") + .comment("so please, don't blindly buff it, players have ability to research into Nanobots Regeneration,") + .comment("which provide superior regeneration on average than human players.") + .comment("---") + .comment("This regeneration obeys natural regeneration gamerule") + .comment("---") + .comment("Reason for this config option is that FoodData does not tick") + .comment("for android players, since 'hunger' (for compatibility) is managed by mod in such case") + .defineInRange("TIME_BETWEEN_NATURAL_REGENERATION", 120, 0, Int.MAX_VALUE) object NanobotsRegeneration { init { @@ -29,7 +40,7 @@ object AndroidConfig : AbstractConfig("androids") { .comment(" ticksSinceTakingDamage = 0") .comment(" this.ply.heal(...)") .comment("}") - .defineList("COOLDOWN", { mutableListOf(80, 60, 40, 20) }) { it is Int } + .defineList("COOLDOWN", { mutableListOf(60, 50, 40, 30) }) { it is Int } val ENERGY_PER_HITPOINT by builder .comment("Energy required to regenerate 1 health point (half a heart)") diff --git a/src/main/resources/overdrive_that_matters.mixins.json b/src/main/resources/overdrive_that_matters.mixins.json index 626eb012c..3d4d5f070 100644 --- a/src/main/resources/overdrive_that_matters.mixins.json +++ b/src/main/resources/overdrive_that_matters.mixins.json @@ -7,6 +7,7 @@ "refmap": "overdrive_that_matters.refmap.json", "mixins": [ "EnchantmentHelperMixin", + "FoodDataMixin", "MixinPatchProjectileFinder", "MixinLivingEntity", "MixinAnvilBlock", From f6519e12e33ba321eadaf5564ea04cd803d1c3f2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 27 Jun 2023 22:21:01 +0700 Subject: [PATCH 0670/1199] Add missing locale strings for running out of power --- src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt | 1 + src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt | 1 + 2 files changed, 2 insertions(+) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 4898a13e3..64e5cf0a6 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -342,6 +342,7 @@ private fun death(provider: MatteryLanguageProvider) { death("otm_hawking_radiation", "%1\$s discovered Hawking radiation") death("otm_emp", "%1\$s electronics' fried") death("otm_cosmic_rays", "%1\$s electronics' got scrambled by cosmic radiation") + death("otm_android_discharge", "%1\$s ran out of power") death("otm_become_android.player", "%1\$s lost their humanity whilst %2\$s tried to reason with them") death("otm_become_humane.player", "%1\$s gained their humanity whilst %2\$s tried to reason with them") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 166f337bc..948acb1dd 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -346,6 +346,7 @@ private fun death(provider: MatteryLanguageProvider) { death("otm_hawking_radiation", "%1\$s открыл излучение Хокинга") death("otm_emp", "Электроника %1\$s перегорела") death("otm_cosmic_rays", "Электроника %1\$s была ошеломлена космическим излучением") + death("otm_android_discharge", "В аккумуляторах %1\$s закончился заряд") death("otm_become_android.player", "%1\$s потерял свою человечность, когда %2\$s пытался образумить их") death("otm_become_humane.player", "%1\$s восстановил свою человечность, когда %2\$s пытался образумить их") From 6660a929b9af1960e9edf736b240b43e89cd6058 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 27 Jun 2023 22:22:58 +0700 Subject: [PATCH 0671/1199] Don't do full battery refill --- .../ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 110ba7170..28e18f30c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -1276,7 +1276,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial mattery.iteration++ mattery.shouldSendIteration = true mattery.deathLog.addLast(ply.tickCount to ply.combatTracker.deathMessage) - mattery.androidEnergy.fillBattery() // если смерть была от разряда батареи, то предотвращаем софтлок + mattery.androidEnergy.batteryLevel = mattery.androidEnergy.batteryLevel.coerceAtLeast(Decimal(20_000)) // если смерть была от разряда батареи, то предотвращаем софтлок while (mattery.deathLog.size > 6) { mattery.deathLog.removeFirst() From 516ba8ca348dcab9614b74ed51b4bacb92077e3e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 28 Jun 2023 13:50:42 +0700 Subject: [PATCH 0672/1199] Bump mekanism version --- build.gradle.kts | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 109a5b536..b08081996 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -204,7 +204,7 @@ dependencies { // runtimeOnly(fg.deobf("curse.maven:worldedit-225608:${worldedit_fileid}")) // runtimeOnly(fg.deobf("at.ridgo8.moreoverlays:MoreOverlays-updated:${more_overlays_version}")) - compileOnly(fg.deobf("mekanism:Mekanism:${mekanism_version}:all")) + implementation(fg.deobf("mekanism:Mekanism:${mekanism_version}:all")) // runtimeOnly(fg.deobf("curse.maven:cyclops-core-232758:4392602")) // runtimeOnly(fg.deobf("curse.maven:integrated-dynamics-236307:4391535")) diff --git a/gradle.properties b/gradle.properties index 51c3d1606..36f394177 100644 --- a/gradle.properties +++ b/gradle.properties @@ -23,7 +23,7 @@ mixin_version=0.8.5 jei_version=14.0.0.5 jupiter_version=5.9.2 -mekanism_version=1.19.2-10.3.5.homebaked +mekanism_version=1.20.1-10.3.9.homebaked curios_version=5.2.0-beta.2 cosmetic_armor_reworked_id=4575609 ad_astra_id=4594155 From 708281df4c8aed6f96937a965ef8aa145c7e3334 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 28 Jun 2023 14:43:12 +0700 Subject: [PATCH 0673/1199] Update mekanism energy integration code pieces --- .../mc/otm/block/entity/MatteryBlockEntity.kt | 52 ++++++++++++++++++- .../block/entity/MatteryDeviceBlockEntity.kt | 2 +- .../entity/tech/EnergyCounterBlockEntity.kt | 4 +- 3 files changed, 54 insertions(+), 4 deletions(-) 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 2cdd698da..800e50c18 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 @@ -6,6 +6,7 @@ import it.unimi.dsi.fastutil.longs.Long2ObjectFunction import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.ObjectArraySet import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap +import mekanism.api.energy.IStrictEnergyHandler import net.minecraft.core.BlockPos import net.minecraft.core.Direction import net.minecraft.core.SectionPos @@ -29,6 +30,7 @@ import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.INBTSerializable import net.minecraftforge.common.util.LazyOptional +import net.minecraftforge.energy.IEnergyStorage import net.minecraftforge.event.TickEvent import net.minecraftforge.event.TickEvent.LevelTickEvent import net.minecraftforge.event.entity.player.PlayerEvent @@ -42,6 +44,7 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.isMekanismLoaded import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper +import ru.dbotthepony.mc.otm.compat.mekanism.Mekanism2MatteryEnergyWrapper import ru.dbotthepony.mc.otm.core.collect.SupplierList import ru.dbotthepony.mc.otm.core.collect.WeakHashSet import ru.dbotthepony.mc.otm.core.forValidRefs @@ -62,6 +65,8 @@ import java.lang.ref.WeakReference import java.util.* import java.util.function.Supplier import java.util.stream.Stream +import kotlin.NoSuchElementException +import kotlin.collections.ArrayList import kotlin.properties.ReadWriteProperty import kotlin.reflect.KProperty import kotlin.reflect.KProperty0 @@ -202,7 +207,27 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc private val subscriptions = Reference2ObjectOpenHashMap, SubRef<*>>() private val knownLOs = WeakHashSet>() - private inner class SubRef(var value: LazyOptional) : Supplier> { + private inner class SubRef(value: LazyOptional) : Supplier> { + var value: LazyOptional = value + set(value) { + if (value !== field) { + field = value + + if (value.isPresent) + for (tracker in listeners) + tracker.run() + } + } + + private val listeners = ArrayList(0) + + fun addListener(listener: Runnable) { + listeners.add(listener) + + if (value.isPresent) + listener.run() + } + override fun get(): LazyOptional { return value } @@ -224,6 +249,31 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc return subref } + fun trackEnergy(): Supplier> { + return object : Supplier> { + private val regular = track(ForgeCapabilities.ENERGY) + private val mekanism: SubRef? + private var actualMekanism: LazyOptional? = null + + init { + if (isMekanismLoaded) { + mekanism = track(MatteryCapability.MEKANISM_ENERGY) as SubRef + + mekanism.addListener { + actualMekanism?.invalidate() + actualMekanism = LazyOptional.of { Mekanism2MatteryEnergyWrapper(mekanism.value.orElseThrow { NoSuchElementException() }) } + } + } else { + mekanism = null + } + } + + override fun get(): LazyOptional { + return actualMekanism ?: regular.get() + } + } + } + fun updateTracked() { for (key in subscriptions.keys) { // Concurrent Modification safety: diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index 18f816e35..8b236083c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -300,7 +300,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo inner class Piece(val side: RelativeSide, val possibleModes: FlowDirection) : IMatteryEnergyStorage, ITickable { private val capControllers = exposeEnergy(side, this@Piece) - private val neighbour by sides[side]!!.track(ForgeCapabilities.ENERGY) + private val neighbour by sides[side]!!.trackEnergy() override var batteryLevel: Decimal by energy::batteryLevel override val maxBatteryLevel: Decimal by energy::maxBatteryLevel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt index d98d77123..91b42964f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt @@ -124,8 +124,8 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat private val energyInput = EnergyCounterCap(true) private val energyOutput = EnergyCounterCap(false) - private val inputCapability by front.track(ForgeCapabilities.ENERGY) - private val outputCapability by back.track(ForgeCapabilities.ENERGY) + private val inputCapability by front.trackEnergy() + private val outputCapability by back.trackEnergy() private inner class EnergyCounterCap(isInput: Boolean) : IMatteryEnergyStorage { override val energyFlow = FlowDirection.input(isInput) From 4d4ecd28a57be3ba0d2ef7d9557fde5050575150 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 28 Jun 2023 15:49:21 +0700 Subject: [PATCH 0674/1199] Move sprite panel to general panels --- .../mc/otm/client/screen/decorative/FluidTankScreen.kt | 2 +- .../mc/otm/client/screen/panels/{util => }/SpritePanel.kt | 4 +--- .../mc/otm/client/screen/tech/AndroidChargerScreen.kt | 2 +- .../mc/otm/client/screen/tech/EnergyServoScreen.kt | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/{util => }/SpritePanel.kt (81%) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/FluidTankScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/FluidTankScreen.kt index 9edcc6387..1027ce7f7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/FluidTankScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/FluidTankScreen.kt @@ -11,7 +11,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.PlayerEquipmentPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.makeCuriosPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel -import ru.dbotthepony.mc.otm.client.screen.panels.util.SpritePanel +import ru.dbotthepony.mc.otm.client.screen.panels.SpritePanel import ru.dbotthepony.mc.otm.client.screen.widget.FluidGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.menu.decorative.FluidTankMenu diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/SpritePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SpritePanel.kt similarity index 81% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/SpritePanel.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SpritePanel.kt index b461a0e4b..ba04c9a63 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/SpritePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SpritePanel.kt @@ -1,11 +1,9 @@ -package ru.dbotthepony.mc.otm.client.screen.panels.util +package ru.dbotthepony.mc.otm.client.screen.panels -import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.UVWindingOrder -import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel class SpritePanel( screen: S, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/AndroidChargerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/AndroidChargerScreen.kt index 2c7037616..27b80cb22 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/AndroidChargerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/AndroidChargerScreen.kt @@ -9,7 +9,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel -import ru.dbotthepony.mc.otm.client.screen.panels.util.SpritePanel +import ru.dbotthepony.mc.otm.client.screen.panels.SpritePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.menu.tech.AndroidChargerMenu diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt index bdaa7aeb4..1a353dc7f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt @@ -13,7 +13,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.PlayerEquipmentPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.makeCuriosPanel -import ru.dbotthepony.mc.otm.client.screen.panels.util.SpritePanel +import ru.dbotthepony.mc.otm.client.screen.panels.SpritePanel import ru.dbotthepony.mc.otm.client.screen.widget.HorizontalPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalProfiledPowerGaugePanel From fced3058d58e5f136676c7ba02bab1818636220a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 28 Jun 2023 19:29:15 +0700 Subject: [PATCH 0675/1199] Update energy counter screen --- .../mc/otm/datagen/lang/English.kt | 5 + .../mc/otm/datagen/lang/Russian.kt | 5 + .../otm/client/screen/panels/DynamicLabel.kt | 21 ++++ .../client/screen/tech/EnergyCounterScreen.kt | 102 ++++++------------ 4 files changed, 63 insertions(+), 70 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DynamicLabel.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 64e5cf0a6..3fce11216 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -225,6 +225,11 @@ private fun misc(provider: MatteryLanguageProvider) { misc("item.power.last_20_ticks", "Last second: %s") misc("item.power.last_tick", "Last tick: %s") + gui("power.passed", "Total passed energy:") + gui("power.average", "Average throughput per tick:") + gui("power.last_20_ticks", "Last second:") + gui("power.last_tick", "Last tick:") + misc("item.power.storage", "Stored energy: %s / %s") misc("item.power.storage0", "Stored energy: %s") misc("item.power.throughput", "Max I/O: %s / %s") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 948acb1dd..14b993b9e 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -233,6 +233,11 @@ private fun misc(provider: MatteryLanguageProvider) { misc("item.power.last_20_ticks", "Последняя секунда: %s") misc("item.power.last_tick", "Последний тик: %s") + gui("power.passed", "Всего передано энергии:") + gui("power.average", "Средняя передача в тик:") + gui("power.last_20_ticks", "Последняя секунда:") + gui("power.last_tick", "Последний тик:") + misc("item.power.storage", "Хранимая энергия: %s / %s") misc("item.power.throughput", "Максимальная пропускная способность: %s / %s") misc("item.power.throughput_mono", "Максимальная пропускная способность: %s") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DynamicLabel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DynamicLabel.kt new file mode 100644 index 000000000..9e13f1b7c --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DynamicLabel.kt @@ -0,0 +1,21 @@ +package ru.dbotthepony.mc.otm.client.screen.panels + +import net.minecraft.client.gui.screens.Screen +import net.minecraft.network.chat.Component +import java.util.function.Supplier + +open class DynamicLabel( + screen: S, + parent: EditablePanel<*>?, + x: Float = 0f, + y: Float = 0f, + width: Float = 100f, + height: Float = 10f, + val textSupplier: Supplier, + shadow: Boolean = false +) : Label(screen, parent, x, y, width, height, textSupplier.get(), shadow) { + override fun tickInner() { + super.tickInner() + text = textSupplier.get() + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt index 08845d991..b21634eb0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt @@ -11,92 +11,54 @@ import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.input.NetworkNumberInputPanel import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.menu.tech.EnergyCounterMenu +import java.util.function.Supplier class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! - var label: Label = object : Label(this@EnergyCounterScreen, frame) { - override fun tickInner() { - super.tickInner() - text = TranslatableComponent( - "otm.item.power.passed", - menu.passed.formatPower(formatAsReadable = ShiftPressedCond) - ) + frame.height = 160f + frame.width += 40f + + val labels = ArrayList>() + + labels.add(Label(this, frame, text = TranslatableComponent("otm.gui.power.passed"))) + labels.add(DynamicLabel(this, frame, textSupplier = { menu.passed.formatPower(formatAsReadable = ShiftPressedCond) })) + labels.add(Label(this, frame, text = TranslatableComponent("otm.gui.power.average"))) + labels.add(DynamicLabel(this, frame, textSupplier = { menu.average.formatPower(formatAsReadable = ShiftPressedCond) })) + labels.add(Label(this, frame, text = TranslatableComponent("otm.gui.power.last_20_ticks"))) + labels.add(DynamicLabel(this, frame, textSupplier = { menu.last20Ticks.formatPower(formatAsReadable = ShiftPressedCond) })) + labels.add(Label(this, frame, text = TranslatableComponent("otm.gui.power.last_tick"))) + labels.add(DynamicLabel(this, frame, textSupplier = { menu.lastTick.formatPower(formatAsReadable = ShiftPressedCond) })) + labels.add(DynamicLabel(this, frame, textSupplier = { TranslatableComponent("block.overdrive_that_matters.energy_counter.facing", menu.inputDirection) })) + + for ((i, label) in labels.withIndex()) { + if (i == 0) { + label.dockTop = 5f + } else { + label.dockTop = 2f } + + label.dock = Dock.TOP } - label.dock = Dock.TOP - label.setDockMargin(4f, 0f, 0f, 0f) - - label = object : Label(this@EnergyCounterScreen, frame) { - override fun tickInner() { - super.tickInner() - text = TranslatableComponent( - "otm.item.power.average", - menu.average.formatPower(formatAsReadable = ShiftPressedCond) - ) - } - } - - label.dock = Dock.TOP - label.setDockMargin(4f, 0f, 0f, 0f) - - label = object : Label(this@EnergyCounterScreen, frame) { - override fun tickInner() { - super.tickInner() - text = TranslatableComponent( - "otm.item.power.last_20_ticks", - menu.last20Ticks.formatPower(formatAsReadable = ShiftPressedCond) - ) - } - } - - label.dock = Dock.TOP - label.setDockMargin(4f, 0f, 0f, 0f) - - label = object : Label(this@EnergyCounterScreen, frame) { - override fun tickInner() { - super.tickInner() - text = TranslatableComponent( - "otm.item.power.last_tick", - menu.lastTick.formatPower(formatAsReadable = ShiftPressedCond) - ) - } - } - - label.dock = Dock.TOP - label.setDockMargin(4f, 0f, 0f, 0f) - - label = object : Label(this@EnergyCounterScreen, frame) { - override fun tickInner() { - super.tickInner() - - text = TranslatableComponent( - "block.overdrive_that_matters.energy_counter.facing", - menu.inputDirection - ) - } - } - - label.dock = Dock.TOP - label.setDockMargin(4f, 0f, 0f, 0f) - if (!menu.ply.isSpectator) { val button = ButtonPanel(this, frame, 0f, 0f, 0f, 20f, TranslatableComponent("block.overdrive_that_matters.energy_counter.switch"), onPress = Runnable { menu.switchDirection.input(null) }) button.dock = Dock.TOP - button.setDockMargin(4f, 0f, 4f, 0f) + button.setDockMargin(4f, 5f, 4f, 0f) } val infoPanels = frame.fetchChildren() - label = Label(this, frame, TranslatableComponent("block.overdrive_that_matters.energy_counter.limit")) - label.dock = Dock.TOP - label.setDockMargin(4f, 0f, 0f, 0f) + Label(this, frame, TranslatableComponent("block.overdrive_that_matters.energy_counter.limit")).also { + it.dock = Dock.TOP + it.dockTop = 10f + } - val inputPanel = NetworkNumberInputPanel(this, frame, widget = menu.maxIOInput, networkValue = menu::maxIO) - inputPanel.dock = Dock.TOP - inputPanel.setDockMargin(4f, 0f, 4f, 0f) + NetworkNumberInputPanel(this, frame, widget = menu.maxIOInput, networkValue = menu::maxIO).also { + it.dock = Dock.TOP + it.dockTop = 4f + } val limitsPanels = frame.fetchChildren().filter { !infoPanels.contains(it) } From 2f59edd606e87470392ec8b533d056d00fd8a191 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Wed, 28 Jun 2023 15:40:33 +0300 Subject: [PATCH 0676/1199] =?UTF-8?q?=D1=87=D1=83=D0=B4=D0=B5=D1=81=D0=B0?= =?UTF-8?q?=20ASM=20=D0=B8=20=D0=BC=D0=BD=D0=BE=D0=B3=D0=BE=D0=BA=D1=80?= =?UTF-8?q?=D0=B0=D1=82=D0=BD=D0=BE=D0=B9=20=D0=BF=D0=BE=D1=82=D0=B5=D1=80?= =?UTF-8?q?=D0=B8=20=D1=80=D0=B0=D1=81=D1=81=D1=83=D0=B4=D0=BA=D0=B0=20#19?= =?UTF-8?q?3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/OverdriveThatMatters.java | 4 +- .../mc/otm/compat/mekanism/MekanismHooks.kt | 49 ++++++++++++ .../mc/otm/compat/mekanism/Tooltips.kt | 20 ----- src/main/resources/coremods/code_injector.js | 75 +++++++++++++++++++ 4 files changed, 126 insertions(+), 22 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/MekanismHooks.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Tooltips.kt diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 1eaa1daa5..236a26062 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -36,8 +36,8 @@ import ru.dbotthepony.mc.otm.client.render.blockentity.BatteryBankRenderer; import ru.dbotthepony.mc.otm.client.render.blockentity.MatterBatteryBankRenderer; import ru.dbotthepony.mc.otm.compat.adastra.AdAstraCompatKt; import ru.dbotthepony.mc.otm.compat.curios.CuriosCompatKt; +import ru.dbotthepony.mc.otm.compat.mekanism.MekanismHooks; import ru.dbotthepony.mc.otm.compat.mekanism.QIOKt; -import ru.dbotthepony.mc.otm.compat.mekanism.TooltipsKt; import ru.dbotthepony.mc.otm.config.AndroidConfig; import ru.dbotthepony.mc.otm.config.ClientConfig; import ru.dbotthepony.mc.otm.config.ItemsConfig; @@ -244,7 +244,7 @@ public final class OverdriveThatMatters { EVENT_BUS.addListener(EventPriority.NORMAL, QuantumBatteryItem.Companion::clientDisconnect); if (ModList.get().isLoaded("mekanism")) { - EVENT_BUS.addListener(EventPriority.NORMAL, TooltipsKt::tooltipEvent); + EVENT_BUS.addListener(EventPriority.NORMAL, MekanismHooks::tooltipEvent); } EVENT_BUS.addListener(EventPriority.NORMAL, AndroidMenuKeyMapping.INSTANCE::onRenderGuiEvent); diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/MekanismHooks.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/MekanismHooks.kt new file mode 100644 index 000000000..05741dcc6 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/MekanismHooks.kt @@ -0,0 +1,49 @@ +package ru.dbotthepony.mc.otm.compat.mekanism + +import mekanism.api.Action +import mekanism.api.AutomationType +import mekanism.common.capabilities.energy.MachineEnergyContainer +import mekanism.common.registries.MekanismItems +import mekanism.common.tile.TileEntityChargepad +import net.minecraft.ChatFormatting +import net.minecraft.world.entity.LivingEntity +import net.minecraft.world.entity.player.Player +import net.minecraftforge.event.entity.player.ItemTooltipEvent +import ru.dbotthepony.mc.otm.capability.isMekanismLoaded +import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.core.TranslatableComponent + +object MekanismHooks { + @JvmStatic + fun chargeAndroidFromPadHook(container: MachineEnergyContainer, entity: LivingEntity) { + if (entity !is Player) return + + if (entity.matteryPlayer?.isAndroid == true) { + val androidEnergy = entity.matteryPlayer!!.androidEnergy + + val expectedAmount = container.energyPerTick + val remaining = androidEnergy.receiveEnergy(expectedAmount.toDecimal(), true).toFloatingLong() + + if (remaining.smallerThan(expectedAmount)) { + val extracted = container.extract(expectedAmount.subtract(remaining), Action.EXECUTE, AutomationType.INTERNAL) + + if (!extracted.isZero) { + androidEnergy.receiveEnergy(extracted.toDecimal(), false) + } + } + } + } + + private val BLACKHOLE_IMMUNITY = TranslatableComponent("otm.item.blackhole_immunity").withStyle(ChatFormatting.DARK_GRAY) + + @JvmStatic + fun tooltipEvent(event: ItemTooltipEvent) { + if (!isMekanismLoaded) { + throw IllegalStateException("Mekanism is not loaded!") + } + + if (event.itemStack.`is`(MekanismItems.MODULE_GRAVITATIONAL_MODULATING.get())) { + event.toolTip.add(BLACKHOLE_IMMUNITY) + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Tooltips.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Tooltips.kt deleted file mode 100644 index 41bb89455..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Tooltips.kt +++ /dev/null @@ -1,20 +0,0 @@ -package ru.dbotthepony.mc.otm.compat.mekanism - -import mekanism.common.registries.MekanismItems -import net.minecraft.ChatFormatting -import net.minecraftforge.event.entity.player.ItemTooltipEvent -import net.minecraftforge.eventbus.api.SubscribeEvent -import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.capability.isMekanismLoaded - -private val BLACKHOLE_IMMUNITY = TranslatableComponent("otm.item.blackhole_immunity").withStyle(ChatFormatting.DARK_GRAY) - -fun tooltipEvent(event: ItemTooltipEvent) { - if (!isMekanismLoaded) { - throw IllegalStateException("Mekanism is not loaded!") - } - - if (event.itemStack.`is`(MekanismItems.MODULE_GRAVITATIONAL_MODULATING.get())) { - event.toolTip.add(BLACKHOLE_IMMUNITY) - } -} diff --git a/src/main/resources/coremods/code_injector.js b/src/main/resources/coremods/code_injector.js index e1c5310d5..d556eb438 100644 --- a/src/main/resources/coremods/code_injector.js +++ b/src/main/resources/coremods/code_injector.js @@ -2,6 +2,7 @@ var ASMAPI = Java.type('net.minecraftforge.coremod.api.ASMAPI') var AbstractInsnNode = Java.type('org.objectweb.asm.tree.AbstractInsnNode') var Opcodes = Java.type('org.objectweb.asm.Opcodes') +var FieldInsnNode = Java.type('org.objectweb.asm.tree.FieldInsnNode') var VarInsnNode = Java.type('org.objectweb.asm.tree.VarInsnNode') var MethodInsnNode = Java.type('org.objectweb.asm.tree.MethodInsnNode') var JumpInsnNode = Java.type('org.objectweb.asm.tree.JumpInsnNode') @@ -727,6 +728,80 @@ function initializeCoreMod() { } } + return node + } + }, + + 'Mekanism Chargepad Android Charge': { + 'target': { + 'type': 'METHOD', + 'class': 'mekanism.common.tile.TileEntityChargepad', + 'methodName': 'onUpdateServer', + 'methodDesc': '()V' + }, + + 'transformer': function(node) { + var skipLabel = new Label() + var skipLabelNode = new LabelNode(skipLabel) + + var labelIteratorEndNode + + for (i = 0; i < node.instructions.size(); i++) { + var insn = node.instructions.get(i) + + if (insn && insn.getOpcode() == opcodesRemapped.getfield && insn.name == 'CuriosLoaded') { + var nextInsn = node.instructions.get(i + 1) // IFEQ + + labelIteratorEndNode = nextInsn.label + + break + } + } + + if (!labelIteratorEndNode) return node + + for (i = 0; i < node.instructions.size(); i++) { + var insn = node.instructions.get(i) + + if (insn && insn.getType() == AbstractInsnNode.LABEL) { + if (insn == labelIteratorEndNode) { + putInstructions(node, insn, [ + new VarInsnNode(opcodesRemapped.aload, 0), + new FieldInsnNode( + opcodesRemapped.getfield, + 'mekanism/common/tile/TileEntityChargepad', + 'energyContainer', + 'Lmekanism/common/capabilities/energy/MachineEnergyContainer;' + ), + new VarInsnNode(opcodesRemapped.aload, 4), + new MethodInsnNode( + opcodesRemapped.invokestatic, + 'ru/dbotthepony/mc/otm/compat/mekanism/MekanismHooks', + 'chargeAndroidFromPadHook', + '(Lmekanism/common/capabilities/energy/MachineEnergyContainer;Lnet/minecraft/world/entity/LivingEntity;)V' + ), + skipLabelNode + ]) + + break + } + } + } + + for (i = 0; i < node.instructions.size(); i++) { + var insn = node.instructions.get(i) + + if (insn && insn.getOpcode() == opcodesRemapped.invokevirtual && insn.name == 'chargeHandler' && insn.desc == '(Ljava/util/Optional;)Z') { + var nextInsn = node.instructions.get(i + 1) // curios call is POP, pre-curios check call is IFNE; both need to redirect to loop skip label + + if (nextInsn && (nextInsn.getOpcode() == opcodesRemapped.pop || nextInsn.getOpcode() == opcodesRemapped.ifne && nextInsn.label == labelIteratorEndNode)) { + node.instructions.set(nextInsn, new JumpInsnNode(opcodesRemapped.ifne, skipLabelNode)) + + continue + } + } + } + return node } } From f08635e192750a906d562cd326fca46eac68f519 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 28 Jun 2023 19:59:13 +0700 Subject: [PATCH 0677/1199] =?UTF-8?q?YuRaNnNzZZ=20=E2=80=94=20=D0=A1=D0=B5?= =?UTF-8?q?=D0=B3=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=2019:51=20=D0=BD=D1=83?= =?UTF-8?q?=20=D1=82=D0=B0=D0=BA=20=D1=80=D0=B0=D0=B7=D0=B4=D1=8E=D0=BF?= =?UTF-8?q?=D0=B0=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/compat/mekanism/MekanismHooks.kt | 4 +- .../mc/otm/compat/mekanism/Power.kt | 58 ++++++++++--------- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/MekanismHooks.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/MekanismHooks.kt index 05741dcc6..be5a4d36e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/MekanismHooks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/MekanismHooks.kt @@ -22,13 +22,13 @@ object MekanismHooks { val androidEnergy = entity.matteryPlayer!!.androidEnergy val expectedAmount = container.energyPerTick - val remaining = androidEnergy.receiveEnergy(expectedAmount.toDecimal(), true).toFloatingLong() + val remaining = (androidEnergy.receiveEnergy(expectedAmount.toDecimal() * Mekanism2MatteryEnergyWrapper.mekanism2MtJ, true) * Mattery2MekanismEnergyWrapper.mtj2Mekanism).toFloatingLong() if (remaining.smallerThan(expectedAmount)) { val extracted = container.extract(expectedAmount.subtract(remaining), Action.EXECUTE, AutomationType.INTERNAL) if (!extracted.isZero) { - androidEnergy.receiveEnergy(extracted.toDecimal(), false) + androidEnergy.receiveEnergy(extracted.toDecimal() * Mekanism2MatteryEnergyWrapper.mekanism2MtJ, false) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt index fa7a627f6..0f2d21f9d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt @@ -49,36 +49,27 @@ private class DoubleLazy(onion: () -> Lazy) : Lazy { } } -private val mekanism2MtJ by DoubleLazy lazy@{ - try { - val conf = MekanismConfig.general - return@lazy LazyCache(conf.forgeConversionRate::get) { Decimal.ONE / it.toDecimal() } - } catch(err: Throwable) { - LOGGER.error("Unable to get Forge Energy to Mekanism Joules's conversion rate! Expect issues", err) - } - - return@lazy lazyOf(Decimal.ONE) -} - -private val mtj2Mekanism by DoubleLazy lazy@{ - try { - val conf = MekanismConfig.general - return@lazy LazyCache(conf.forgeConversionRate::get) { it.toDecimal() } - } catch(err: Throwable) { - LOGGER.error("Unable to get Mekanism Joules's to Forge Energy conversion rate! Expect issues", err) - } - - return@lazy lazyOf(Decimal.ONE) -} - class Mekanism2MatteryEnergyWrapper(private val power: IStrictEnergyHandler, private val forgePower: IEnergyStorage? = null) : IMatteryEnergyStorage { + companion object { + val mekanism2MtJ by DoubleLazy lazy@{ + try { + val conf = MekanismConfig.general + return@lazy LazyCache(conf.forgeConversionRate::get) { Decimal.ONE / it.toDecimal() } + } catch(err: Throwable) { + LOGGER.error("Unable to get Forge Energy to Mekanism Joules's conversion rate! Expect issues", err) + } + + return@lazy lazyOf(Decimal.ONE) + } + } + override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { val action = when (simulate) { true -> Action.SIMULATE false -> Action.EXECUTE } - return power.extractEnergy((howMuch * mtj2Mekanism).toFloatingLong(), action).toDecimal() * mekanism2MtJ + return power.extractEnergy((howMuch * Mattery2MekanismEnergyWrapper.mtj2Mekanism).toFloatingLong(), action).toDecimal() * mekanism2MtJ } override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { @@ -87,7 +78,7 @@ class Mekanism2MatteryEnergyWrapper(private val power: IStrictEnergyHandler, pri false -> Action.EXECUTE } - return howMuch - power.insertEnergy((howMuch * mtj2Mekanism).toFloatingLong(), action).toDecimal() * mekanism2MtJ + return howMuch - power.insertEnergy((howMuch * Mattery2MekanismEnergyWrapper.mtj2Mekanism).toFloatingLong(), action).toDecimal() * mekanism2MtJ } override val canSetBatteryLevel: Boolean @@ -107,7 +98,7 @@ class Mekanism2MatteryEnergyWrapper(private val power: IStrictEnergyHandler, pri if (power.energyContainerCount != 1) throw UnsupportedOperationException("Can set power only when we have 1 energy container, ${power.energyContainerCount} present") - power.setEnergy(0, (value * mtj2Mekanism).toFloatingLong()) + power.setEnergy(0, (value * Mattery2MekanismEnergyWrapper.mtj2Mekanism).toFloatingLong()) } override val maxBatteryLevel: Decimal @@ -126,6 +117,19 @@ class Mekanism2MatteryEnergyWrapper(private val power: IStrictEnergyHandler, pri } class Mattery2MekanismEnergyWrapper(private val power: IMatteryEnergyStorage) : IStrictEnergyHandler { + companion object { + val mtj2Mekanism by DoubleLazy lazy@{ + try { + val conf = MekanismConfig.general + return@lazy LazyCache(conf.forgeConversionRate::get) { it.toDecimal() } + } catch(err: Throwable) { + LOGGER.error("Unable to get Mekanism Joules's to Forge Energy conversion rate! Expect issues", err) + } + + return@lazy lazyOf(Decimal.ONE) + } + } + override fun getEnergyContainerCount(): Int = 1 override fun getEnergy(container: Int): FloatingLong { @@ -158,11 +162,11 @@ class Mattery2MekanismEnergyWrapper(private val power: IMatteryEnergyStorage) : override fun insertEnergy(container: Int, howMuch: FloatingLong, action: Action): FloatingLong { val copy = howMuch.copy() - return copy.minusEqual((power.receiveEnergy(howMuch.toDecimal() * mekanism2MtJ, action.simulate()) * mtj2Mekanism).toFloatingLong()) + return copy.minusEqual((power.receiveEnergy(howMuch.toDecimal() * Mekanism2MatteryEnergyWrapper.mekanism2MtJ, action.simulate()) * mtj2Mekanism).toFloatingLong()) } override fun extractEnergy(container: Int, howMuch: FloatingLong, action: Action): FloatingLong { - return (power.extractEnergy(howMuch.toDecimal() * mekanism2MtJ, action.simulate()) * mtj2Mekanism).toFloatingLong() + return (power.extractEnergy(howMuch.toDecimal() * Mekanism2MatteryEnergyWrapper.mekanism2MtJ, action.simulate()) * mtj2Mekanism).toFloatingLong() } } From e987c64cd998b21fdb5a30d4c4ebfaa6877a67a2 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Wed, 28 Jun 2023 19:37:43 +0300 Subject: [PATCH 0678/1199] debug commands to toggle exopack and android capabilities --- .../mc/otm/OverdriveThatMatters.java | 1 + .../otm/capability/MatteryPlayerCapability.kt | 64 +++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 236a26062..972fadf72 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -166,6 +166,7 @@ public final class OverdriveThatMatters { EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayerCapability.Companion::onPlayerCloneEvent); EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayerCapability.Companion::onStartTracking); EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayerCapability.Companion::onStopTracking); + EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayerCapability.MPCommands::addCommands); EVENT_BUS.addListener(EventPriority.NORMAL, ExplosionQueue.Companion::onWorldTick); EVENT_BUS.addListener(EventPriority.NORMAL, AbstractWeaponItem.Companion::tick); diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 28e18f30c..de6ebb734 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -2,6 +2,8 @@ package ru.dbotthepony.mc.otm.capability import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import net.minecraft.ChatFormatting +import net.minecraft.commands.Commands +import net.minecraft.commands.arguments.EntityArgument import net.minecraft.core.Direction import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.ListTag @@ -22,6 +24,7 @@ import net.minecraft.world.entity.boss.wither.WitherBoss import net.minecraft.world.entity.monster.Phantom import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player +import net.minecraft.world.inventory.InventoryMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.item.ProjectileWeaponItem @@ -36,6 +39,7 @@ import net.minecraftforge.common.capabilities.ICapabilityProvider import net.minecraftforge.common.util.INBTSerializable import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.event.AttachCapabilitiesEvent +import net.minecraftforge.event.RegisterCommandsEvent import net.minecraftforge.event.TickEvent import net.minecraftforge.event.TickEvent.PlayerTickEvent import net.minecraftforge.event.entity.living.LivingDeathEvent @@ -1181,6 +1185,66 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial return stack.isEmpty } + object MPCommands { + @JvmStatic + private fun setExoPack(players: Collection, hasExoPack: Boolean): Int { + for (player in players) { + if (player.containerMenu is InventoryMenu || player.containerMenu is ExoPackInventoryMenu) player.closeContainer() + + player.matteryPlayer?.hasExoPack = hasExoPack + } + + return players.size + } + + @JvmStatic + private fun makeAndroid(players: Collection): Int { + for (player in players) { + player.matteryPlayer?.becomeAndroid() + } + + return players.size + } + + @JvmStatic + private fun makeHuman(players: Collection): Int { + for (player in players) { + player.matteryPlayer?.becomeHumane() + } + + return players.size + } + + @JvmStatic + fun addCommands(event: RegisterCommandsEvent) { + event.dispatcher.register( + Commands.literal("exopack") + .requires { it.hasPermission(Commands.LEVEL_GAMEMASTERS) } + .then(Commands.literal("add") + .executes { setExoPack(Collections.singleton(it.source.playerOrException), true) } + .then(Commands.argument("targets", EntityArgument.players()).executes { setExoPack(EntityArgument.getPlayers(it, "targets"), true) }) + ) + .then(Commands.literal("remove") + .executes { setExoPack(Collections.singleton(it.source.playerOrException), false) } + .then(Commands.argument("targets", EntityArgument.players()).executes { setExoPack(EntityArgument.getPlayers(it, "targets"), false) }) + ) + ) + + event.dispatcher.register( + Commands.literal("android") + .requires { it.hasPermission(Commands.LEVEL_GAMEMASTERS) } + .then(Commands.literal("on") + .executes { makeAndroid(Collections.singleton(it.source.playerOrException)) } + .then(Commands.argument("targets", EntityArgument.players()).executes { makeAndroid(EntityArgument.getPlayers(it, "targets")) }) + ) + .then(Commands.literal("off") + .executes { makeHuman(Collections.singleton(it.source.playerOrException)) } + .then(Commands.argument("targets", EntityArgument.players()).executes { makeHuman(EntityArgument.getPlayers(it, "targets")) }) + ) + ) + } + } + @Suppress("unused") companion object { private fun stackStacks(it: ItemStack, stack: ItemStack): Boolean { From b27ef2ea79937d623cfe7cb37d21214905051e63 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Thu, 29 Jun 2023 11:31:21 +0300 Subject: [PATCH 0679/1199] better combat presets for energy sword and explosive hammer (both not autodetected by mod) --- .../overdrive_that_matters/weapon_attributes/energy_sword.json | 3 +++ .../weapon_attributes/explosive_hammer.json | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 src/main/resources/data/overdrive_that_matters/weapon_attributes/energy_sword.json create mode 100644 src/main/resources/data/overdrive_that_matters/weapon_attributes/explosive_hammer.json diff --git a/src/main/resources/data/overdrive_that_matters/weapon_attributes/energy_sword.json b/src/main/resources/data/overdrive_that_matters/weapon_attributes/energy_sword.json new file mode 100644 index 000000000..c8bb11ed1 --- /dev/null +++ b/src/main/resources/data/overdrive_that_matters/weapon_attributes/energy_sword.json @@ -0,0 +1,3 @@ +{ + "parent": "bettercombat:sword" +} \ No newline at end of file diff --git a/src/main/resources/data/overdrive_that_matters/weapon_attributes/explosive_hammer.json b/src/main/resources/data/overdrive_that_matters/weapon_attributes/explosive_hammer.json new file mode 100644 index 000000000..6db48eab5 --- /dev/null +++ b/src/main/resources/data/overdrive_that_matters/weapon_attributes/explosive_hammer.json @@ -0,0 +1,3 @@ +{ + "parent": "bettercombat:hammer" +} \ No newline at end of file From c110aed90b88d99701aba7a8a10cbd2c82c51502 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sat, 1 Jul 2023 04:09:43 +0300 Subject: [PATCH 0680/1199] =?UTF-8?q?=D0=B2=D1=8B=D1=81=D1=82=D1=80=D0=B5?= =?UTF-8?q?=D0=BB=20=D0=B2=20=D0=BD=D0=BE=D0=B3=D1=83=20=D0=92=D0=A1=D0=95?= =?UTF-8?q?=D0=9C=20progress=20towards=20#258=20prototype,=20missing:=20li?= =?UTF-8?q?ghting,=20item=20render?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../render/blockentity/FluidTankRenderer.kt | 102 ++++++++++++++++++ .../mc/otm/registry/MBlockEntities.kt | 1 + 2 files changed, 103 insertions(+) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/FluidTankRenderer.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/FluidTankRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/FluidTankRenderer.kt new file mode 100644 index 000000000..bfd99551a --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/FluidTankRenderer.kt @@ -0,0 +1,102 @@ +package ru.dbotthepony.mc.otm.client.render.blockentity + +import com.mojang.blaze3d.systems.RenderSystem +import com.mojang.blaze3d.vertex.* +import com.mojang.math.Axis +import net.minecraft.client.renderer.* +import net.minecraft.client.renderer.blockentity.BlockEntityRenderer +import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider +import net.minecraft.world.inventory.InventoryMenu +import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions +import ru.dbotthepony.mc.otm.block.entity.decorative.FluidTankBlockEntity +import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.client.render.* +import ru.dbotthepony.mc.otm.core.math.RGBAColor +import ru.dbotthepony.mc.otm.core.math.linearInterpolation + +class FluidTankRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer { + private val fluidTop = 13f / 16f + private val fluidBottom = 3f / 16f + private val fluidHeight = 10f / 16f + private val fluidWidth = 15.8f / 16f + + private val fluidPadding = (1f - fluidWidth) * .5f + + override fun render( + tile: FluidTankBlockEntity, + partialTick: Float, + poseStack: PoseStack, + bufferSource: MultiBufferSource, + packedLight: Int, + overlayLight: Int + ) { + val fluid = tile.synchronizedFluid + + if (fluid.isEmpty) + return + + val fluidLevel = fluid.amount.toFloat() / tile.fluid.getTankCapacity(0).toFloat() + + if (fluidLevel < 0.01f) + return + + val data = IClientFluidTypeExtensions.of(fluid.fluid) + val texture = data.stillTexture + val sprite = minecraft.getTextureAtlas(InventoryMenu.BLOCK_ATLAS).apply(texture) + val tint = RGBAColor.argb(data.getTintColor(fluid)) + val gas = fluid.fluid.fluidType.isLighterThanAir + + val interp = linearInterpolation(fluidLevel, sprite.v1, sprite.v0) + val v1 = linearInterpolation(fluidBottom, sprite.v1, sprite.v0) + + val builder = tesselator.builder + builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK) + + poseStack.pushPose() + poseStack.translate(0f, fluidBottom + (if (gas) 1f - fluidLevel else 0f) * fluidHeight, 0f) + + for (i in 0 .. 3) { + poseStack.pushPose() + + poseStack.translate(0.5, 0.0, 0.5) + poseStack.rotateAround(Axis.YP.rotationDegrees(i * 90.0f), 0.0f, 1.0f, 0.0f) + poseStack.translate(-0.5f, 0f, fluidWidth * .5f) + + val matrix = poseStack.last().pose() + + builder.vertex(matrix, fluidPadding, 0f, 0f).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u0, v1).overlayCoords(overlayLight).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() + builder.vertex(matrix, fluidPadding + fluidWidth, 0f, 0f).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u1, v1).overlayCoords(overlayLight).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() + builder.vertex(matrix, fluidPadding + fluidWidth, fluidLevel * fluidHeight, 0f).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u1, interp).overlayCoords(overlayLight).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() + builder.vertex(matrix, fluidPadding, fluidLevel * fluidHeight, 0f).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u0, interp).overlayCoords(overlayLight).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() + + poseStack.popPose() + } + + val matrix = poseStack.last().pose() + + if (!gas && fluidLevel < 1f) { // top + builder.vertex(matrix, fluidPadding, fluidLevel * fluidHeight, fluidPadding + fluidWidth).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u0, sprite.v1).overlayCoords(overlayLight).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() + builder.vertex(matrix, fluidPadding + fluidWidth, fluidLevel * fluidHeight, fluidPadding + fluidWidth).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u1, sprite.v1).overlayCoords(overlayLight).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() + builder.vertex(matrix, fluidPadding + fluidWidth, fluidLevel * fluidHeight, fluidPadding).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u1, sprite.v0).overlayCoords(overlayLight).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() + builder.vertex(matrix, fluidPadding, fluidLevel * fluidHeight, fluidPadding).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u0, sprite.v0).overlayCoords(overlayLight).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() + } + + if (gas && fluidLevel < 1f) { // bottom + builder.vertex(matrix, fluidPadding, 0f, fluidPadding).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u0, sprite.v0).overlayCoords(overlayLight).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() + builder.vertex(matrix, fluidPadding + fluidWidth, 0f, fluidPadding).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u1, sprite.v0).overlayCoords(overlayLight).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() + builder.vertex(matrix, fluidPadding + fluidWidth, 0f, fluidPadding + fluidWidth).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u1, sprite.v1).overlayCoords(overlayLight).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() + builder.vertex(matrix, fluidPadding, 0f, fluidPadding + fluidWidth).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u0, sprite.v1).overlayCoords(overlayLight).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() + } + + poseStack.popPose() + + RenderSystem.setShader(GameRenderer::getPositionColorTexLightmapShader) + RenderSystem.setShaderTexture(0, InventoryMenu.BLOCK_ATLAS) + + RenderSystem.enableCull() + RenderSystem.enableBlend() + RenderSystem.enableDepthTest() + + BufferUploader.drawWithShader(builder.end()) + } +} 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 6bfc64e38..f281a490f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt @@ -83,6 +83,7 @@ object MBlockEntities { BlockEntityRenderers.register(MATTER_RECONSTRUCTOR, ::MatterReconstructorRenderer) BlockEntityRenderers.register(MATTER_REPLICATOR, ::MatterReplicatorRenderer) BlockEntityRenderers.register(HOLO_SIGN, ::HoloSignRenderer) + BlockEntityRenderers.register(FLUID_TANK, ::FluidTankRenderer) } } } From dc70b9986833412706e5fcda788a34f901114f34 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sat, 1 Jul 2023 17:10:06 +0300 Subject: [PATCH 0681/1199] correct lighting for liquid in tank (no glow) --- .../render/blockentity/FluidTankRenderer.kt | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/FluidTankRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/FluidTankRenderer.kt index bfd99551a..5ca459112 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/FluidTankRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/FluidTankRenderer.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.client.render.blockentity -import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.* import com.mojang.math.Axis import net.minecraft.client.renderer.* @@ -10,7 +9,6 @@ import net.minecraft.world.inventory.InventoryMenu import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions import ru.dbotthepony.mc.otm.block.entity.decorative.FluidTankBlockEntity import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.linearInterpolation @@ -49,8 +47,9 @@ class FluidTankRenderer(private val context: BlockEntityRendererProvider.Context val interp = linearInterpolation(fluidLevel, sprite.v1, sprite.v0) val v1 = linearInterpolation(fluidBottom, sprite.v1, sprite.v0) - val builder = tesselator.builder - builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK) +// val lightLevel = fluid.fluid.fluidType.getLightLevel(fluid) // 0-15 + + val builder = bufferSource.getBuffer(Sheets.translucentCullBlockSheet()) poseStack.pushPose() poseStack.translate(0f, fluidBottom + (if (gas) 1f - fluidLevel else 0f) * fluidHeight, 0f) @@ -89,14 +88,5 @@ class FluidTankRenderer(private val context: BlockEntityRendererProvider.Context } poseStack.popPose() - - RenderSystem.setShader(GameRenderer::getPositionColorTexLightmapShader) - RenderSystem.setShaderTexture(0, InventoryMenu.BLOCK_ATLAS) - - RenderSystem.enableCull() - RenderSystem.enableBlend() - RenderSystem.enableDepthTest() - - BufferUploader.drawWithShader(builder.end()) } } From 6690ca03c476ee8970970896507eb49fff5a74fc Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sat, 1 Jul 2023 18:18:15 +0300 Subject: [PATCH 0682/1199] =?UTF-8?q?YuRaNnNzZZ=20=E2=80=94=20=D0=A1=D0=B5?= =?UTF-8?q?=D0=B3=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=2017:34=20=D1=8D=D1=82?= =?UTF-8?q?=D0=BE-=D1=82=D0=BE=20=D0=BB=D0=B5=D0=B3=D0=BA=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit <----- clueless --- .../mc/otm/block/decorative/FluidTankBlock.kt | 19 +++++++++++++++++++ .../entity/decorative/FluidTankBlockEntity.kt | 7 +++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt index 37e5483ac..6764fc0b4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt @@ -53,4 +53,23 @@ class FluidTankBlock : RotatableMatteryBlock(), EntityBlock { ): VoxelShape { return shapes[state]!! } + + override fun getLightEmission(state: BlockState?, level: BlockGetter?, pos: BlockPos?): Int { + if (pos == BlockPos.ZERO) return 15 + + val lightLevel = super.getLightEmission(state, level, pos) + + val tile = level?.getExistingBlockEntity(pos) ?: lightLevel + + if (tile is FluidTankBlockEntity) { + val fluid = tile.synchronizedFluid + + if (!fluid.isEmpty) { + val newLevel = fluid.fluid.fluidType.getLightLevel(fluid) + return newLevel.coerceAtLeast(lightLevel) + } + } + + return lightLevel + } } 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 5b184133e..ce5f0ac78 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 @@ -29,8 +29,11 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities class FluidTankBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.FLUID_TANK, blockPos, blockState) { val fluid = BlockMatteryFluidHandler(::onChanged, ItemsConfig::FLUID_TANK_CAPACITY) - var synchronizedFluid by synchronizer.Field(FluidStack.EMPTY, FluidStackValueCodec) - private set + var synchronizedFluid by synchronizer.Field(FluidStack.EMPTY, FluidStackValueCodec, setter = { value, access, remote -> + access.write(value) + + level?.lightEngine?.checkBlock(blockPos) + }) val fillInput = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) val drainInput = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) From 9dcf24cae76d27f94a81cc2c9f6a7549afbfa009 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 5 Jul 2023 17:06:23 +0700 Subject: [PATCH 0683/1199] Upgrade system, conditional quickmove slots, frame panel close button --- .../mc/otm/datagen/lang/English.kt | 33 +++ .../mc/otm/datagen/lang/Russian.kt | 33 +++ .../dbotthepony/mc/otm/datagen/tags/Tags.kt | 2 + .../mc/otm/capability/MatteryCapability.java | 5 + .../dbotthepony/mc/otm/block/entity/Jobs.kt | 21 +- .../block/entity/MatteryWorkerBlockEntity.kt | 8 +- .../entity/tech/PlatePressBlockEntity.kt | 7 +- .../dbotthepony/mc/otm/capability/Upgrades.kt | 200 ++++++++++++++++++ .../mc/otm/client/render/Widgets18.kt | 4 +- .../mc/otm/client/screen/MatteryScreen.kt | 5 +- .../otm/client/screen/panels/EditablePanel.kt | 29 ++- .../mc/otm/client/screen/panels/FramePanel.kt | 69 +++++- .../client/screen/panels/button/Buttons.kt | 99 ++++++++- .../screen/panels/input/QueryUserPanel.kt | 1 + .../screen/tech/AndroidStationScreen.kt | 2 +- .../client/screen/tech/PlatePressScreen.kt | 3 +- .../screen/tech/TwinPlatePressScreen.kt | 2 +- .../mc/otm/config/MachinesConfig.kt | 31 +++ .../mc/otm/container/UpgradeContainer.kt | 54 +++++ .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 4 +- .../mc/otm/core/collect/ConditionalEnumSet.kt | 41 ++++ .../mc/otm/core/collect/ConditionalSet.kt | 85 ++++---- .../dbotthepony/mc/otm/item/SimpleUpgrade.kt | 51 +++++ .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 90 +++++++- .../ru/dbotthepony/mc/otm/menu/Slots.kt | 1 + .../mc/otm/menu/tech/PlatePressMenu.kt | 2 + .../mc/otm/menu/tech/TwinPlatePressMenu.kt | 2 + .../mc/otm/registry/MCreativeTabs.kt | 1 + .../ru/dbotthepony/mc/otm/registry/MItems.kt | 35 ++- .../ru/dbotthepony/mc/otm/registry/Tags.kt | 1 + .../textures/gui/widgets/misc.png | Bin 468 -> 1327 bytes .../textures/gui/widgets/side_controls.png | Bin 2775 -> 2953 bytes .../textures/gui/widgets/side_controls.xcf | Bin 72882 -> 73073 bytes 33 files changed, 840 insertions(+), 81 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ConditionalEnumSet.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/item/SimpleUpgrade.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 3fce11216..e76ae4983 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -603,6 +603,18 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.ZPM_BATTERY, "Zero Point Module") add(MItems.ZPM_BATTERY, "description", "Can be found in hands of those who travel between dimensions, if they ever reached different reality of origin of these constructs...") + + add(MItems.CreativeUpgrades.SPEED, "Creative Speed Upgrade") + add(MItems.CreativeUpgrades.ENERGY_CONSUMPTION, "Creative Energy Consumption Upgrade") + add(MItems.CreativeUpgrades.ENERGY_STORAGE, "Creative Energy Storage Upgrade") + add(MItems.CreativeUpgrades.ENERGY_STORAGE_FLAT, "Creative Energy Storage Upgrade (Flat)") + add(MItems.CreativeUpgrades.ENERGY_STORAGE_FLAT_SMALL, "Creative Energy Storage Upgrade (Flat Small)") + add(MItems.CreativeUpgrades.ENERGY_THROUGHPUT, "Creative Energy Throughput Upgrade") + add(MItems.CreativeUpgrades.ENERGY_THROUGHPUT_FLAT, "Creative Energy Throughput Upgrade (Flat)") + add(MItems.CreativeUpgrades.ENERGY_THROUGHPUT_FLAT_SMALL, "Creative Energy Throughput Upgrade (Flat Small)") + add(MItems.CreativeUpgrades.FAILSAFE, "Creative Failsafe Upgrade") + add(MItems.CreativeUpgrades.FAILURE, "Creative Failure Upgrade") + add(MItems.CreativeUpgrades.PROCESSING_ITEMS, "Creative Item Processing Upgrade") } } @@ -688,6 +700,27 @@ private fun gui(provider: MatteryLanguageProvider) { gui("side_mode.pull", "Pull") gui("side_mode.push", "Push") + gui("upgrades", "Upgrades") + gui("upgrades.current", "Active upgrades:") + gui("upgrade.speed", "Operation speed: %s%%") + gui("upgrade.processing_items", "Items processed per cycle: +%s") + gui("upgrade.energy_storage_flat", "Energy capacity: +%s") + gui("upgrade.energy_storage", "Energy capacity: +%s%%") + gui("upgrade.energy_consumed", "Energy consumption: %s%%") + gui("upgrade.energy_throughput_flat", "Energy throughput: +%s") + gui("upgrade.energy_throughput", "Energy throughput: +%s%%") + gui("upgrade.failsafe", "Failure chance: %s%%") + + gui("upgrade_type.list", "Upgrade classification:") + gui("upgrade_type.allowed", "Allowed upgrades:") + gui("upgrade_type.allowed_none", "No possible upgrades at the moment.") + gui("upgrade_type.speed", "Speed") + gui("upgrade_type.processing", "Processing") + gui("upgrade_type.energy_storage", "Energy Storage") + gui("upgrade_type.energy_consumption", "Energy Consumption") + gui("upgrade_type.energy_throughput", "Energy Throughput") + gui("upgrade_type.failsafe", "Failsafe") + gui("balance_inputs", "Balance input slots") gui("sorting.default", "Default sorting") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 14b993b9e..291b4ff5a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -607,6 +607,18 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.ZPM_BATTERY, "Модуль нулевой точки") add(MItems.ZPM_BATTERY, "description", "Может быть найден у тех, кто путешествует между измерениями, если, конечно, они смогли достигнуть вселенной, где данные устройства были созиданы...") + + add(MItems.CreativeUpgrades.SPEED, "Творческое улучшение скорости") + add(MItems.CreativeUpgrades.ENERGY_CONSUMPTION, "Творческое улучшение энергоэффективности") + add(MItems.CreativeUpgrades.ENERGY_STORAGE, "Творческое улучшение энергохраналища") + add(MItems.CreativeUpgrades.ENERGY_STORAGE_FLAT, "Творческое улучшение энергохраналища (простое)") + add(MItems.CreativeUpgrades.ENERGY_STORAGE_FLAT_SMALL, "Творческое улучшение энергохраналища (малое простое)") + add(MItems.CreativeUpgrades.ENERGY_THROUGHPUT, "Творческое улучшение энергоканала") + add(MItems.CreativeUpgrades.ENERGY_THROUGHPUT_FLAT, "Творческое улучшение энергоканала (простое)") + add(MItems.CreativeUpgrades.ENERGY_THROUGHPUT_FLAT_SMALL, "Творческое улучшение энергоканала (малое простое)") + add(MItems.CreativeUpgrades.FAILSAFE, "Творческое улучшение отказоустойчивости") + add(MItems.CreativeUpgrades.FAILURE, "Творческое улучшение краха") + add(MItems.CreativeUpgrades.PROCESSING_ITEMS, "Творческое улучшение обработки") } } @@ -692,6 +704,27 @@ private fun gui(provider: MatteryLanguageProvider) { gui("side_mode.pull", "Автоматическое вытягивание") gui("side_mode.push", "Автоматическое выталкивание") + gui("upgrades", "Улучшения") + gui("upgrades.current", "Активные улучшения:") + gui("upgrade.speed", "Скорость работы: %s%%") + gui("upgrade.processing_items", "Работы за цикл: +%s") + gui("upgrade.energy_storage_flat", "Хранилище энергии: +%s") + gui("upgrade.energy_storage", "Хранилище энергии: +%s%%") + gui("upgrade.energy_consumed", "Потребление энергии: %s%%") + gui("upgrade.energy_throughput_flat", "Пропускная способность энергии: +%s") + gui("upgrade.energy_throughput", "Пропускная способность энергии: +%s%%") + gui("upgrade.failsafe", "Шанс неудачи: %s%%") + + gui("upgrade_type.list", "Классификация улучшения:") + gui("upgrade_type.allowed", "Допустимые улучшения:") + gui("upgrade_type.allowed_none", "На данный момент нет допустимых улучшений.") + gui("upgrade_type.speed", "Скорость") + gui("upgrade_type.processing", "Обработка") + gui("upgrade_type.energy_storage", "Энергохранилище") + gui("upgrade_type.energy_consumption", "Энергоэффективность") + gui("upgrade_type.energy_throughput", "Энергоканал") + gui("upgrade_type.failsafe", "Отказоустойчивость") + gui("balance_inputs", "Балансировать входные слоты") gui("sorting.default", "Сортировка по умолчанию") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index 9932f8709..b69231e57 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -112,6 +112,8 @@ fun addTags(tagsProvider: TagsProvider) { tagsProvider.items.forge("shears").add(MItems.TRITANIUM_SHEARS) tagsProvider.items.forge("shields").add(MItems.TRITANIUM_SHIELD) + tagsProvider.items.Appender(MItemTags.UPGRADES).add(MItems.CreativeUpgrades.LIST) + tagsProvider.blocks.Appender(BlockTags.STAIRS) .add(MRegistry.FLOOR_TILES_STAIRS.blocks.values) .add(MRegistry.TRITANIUM_STAIRS.allBlocks.values) diff --git a/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java b/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java index ad3d8aeff..37a8aba97 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java +++ b/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java @@ -63,6 +63,10 @@ public class MatteryCapability { @NotNull public static final Capability CURIOS_ITEM = CapabilityManager.get(new CapabilityToken<>() {}); + @Nonnull + @NotNull + public static final Capability UPGRADE = CapabilityManager.get(new CapabilityToken<>() {}); + public static void register(RegisterCapabilitiesEvent event) { event.register(IMatteryEnergyStorage.class); event.register(MatteryPlayerCapability.class); @@ -72,5 +76,6 @@ public class MatteryCapability { event.register(IReplicationTaskProvider.class); event.register(IMatteryDrive.class); event.register(StorageNode.class); + event.register(IMatteryUpgrade.class); } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt index 3ebeaff46..7a595a8cd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt @@ -3,7 +3,9 @@ package ru.dbotthepony.mc.otm.block.entity import net.minecraft.nbt.CompoundTag import net.minecraft.world.item.ItemStack import net.minecraftforge.common.util.INBTSerializable +import ru.dbotthepony.mc.otm.capability.IMatteryUpgrade import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage +import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.getDecimal import ru.dbotthepony.mc.otm.core.math.set @@ -153,6 +155,7 @@ abstract class MachineJobEventLoop : INBTSerializable : INBTSerializable : INBTSerializable( blockPos: BlockPos, blockState: BlockState, val jobDeserializer: (tag: CompoundTag) -> JobType?, - maxJobs: Int = 1 + maxJobs: Int = 1, ) : MatteryPoweredBlockEntity(type, blockPos, blockState) { val jobEventLoops: ImmutableList> = immutableList(maxJobs) { id -> object : MachineJobEventLoop() { @@ -38,6 +40,8 @@ abstract class MatteryWorkerBlockEntity( get() = matteryEnergy override val isBlockedByRedstone: Boolean get() = redstoneControl.isBlockedByRedstone + override val upgrades: IMatteryUpgrade? + get() = this@MatteryWorkerBlockEntity.upgrades override fun deserializeJob(nbt: CompoundTag): JobType? { return jobDeserializer.invoke(nbt) @@ -61,6 +65,8 @@ abstract class MatteryWorkerBlockEntity( } } + open val upgrades: IMatteryUpgrade? get() = null + var balanceInputs = false init { 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 e88dbb13f..e5737178a 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 @@ -12,11 +12,14 @@ import ru.dbotthepony.mc.otm.block.entity.JobContainer import ru.dbotthepony.mc.otm.block.entity.JobStatus import ru.dbotthepony.mc.otm.block.entity.MachineItemJob import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity +import ru.dbotthepony.mc.otm.capability.IMatteryUpgrade +import ru.dbotthepony.mc.otm.capability.UpgradeType import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage 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.container.UpgradeContainer import ru.dbotthepony.mc.otm.container.balance import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu @@ -29,7 +32,8 @@ class PlatePressBlockEntity( p_155230_: BlockState, val isTwin: Boolean = false, ) : MatteryWorkerBlockEntity(if (isTwin) MBlockEntities.TWIN_PLATE_PRESS else MBlockEntities.PLATE_PRESS, p_155229_, p_155230_, ::MachineItemJob, if (isTwin) 2 else 1) { - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::setChangedLight, MachinesConfig.PLATE_PRESS)) + override val upgrades = UpgradeContainer(this::setChangedLight, if (isTwin) 4 else 3, UpgradeType.BASIC) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::setChangedLight, upgrades.transform(MachinesConfig.PLATE_PRESS))) val inputContainer = MatteryContainer(this::itemContainerUpdated, if (isTwin) 2 else 1).also(::addDroppableContainer) val outputContainer = MatteryContainer(this::itemContainerUpdated, if (isTwin) 2 else 1).also(::addDroppableContainer) @@ -55,6 +59,7 @@ class PlatePressBlockEntity( savetable(::inputContainer) savetable(::outputContainer) savetables.double(::experience) + savetables.stateful(::upgrades) } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt new file mode 100644 index 000000000..67040f3b0 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt @@ -0,0 +1,200 @@ +package ru.dbotthepony.mc.otm.capability + +import net.minecraft.ChatFormatting +import net.minecraft.network.chat.Component +import ru.dbotthepony.mc.otm.client.ShiftPressedCond +import ru.dbotthepony.mc.otm.config.MachinesConfig +import ru.dbotthepony.mc.otm.core.TextComponent +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.immutableSet +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.util.formatPower + +/** + * Upgrades merge by sum of their effects + * + * Values which are otherwise not stated to allow negatives or not, Do allow negative values. + */ +interface IMatteryUpgrade { + /** + * Type(s) this upgrade represent + */ + val upgradeTypes: Set get() = setOf() + + /** + * [speedBonus] of `1.0` means that machine doubles the speed (performs twice the amount of + * work ticks per work cycle). + */ + val speedBonus: Double get() = 0.0 + + /** + * **CAN NOT be negative.** + * + * [processingItems] of `4` means machine will accept at most 5 (1 + 4) of items per job. + */ + val processingItems: Int get() = 0 + + /** + * **CAM NOT be negative.** + * + * Added directly over regular energy storage capacity. + */ + val energyStorageFlat: Decimal get() = Decimal.ZERO + + /** + * **CAM NOT be negative.** + */ + val energyStorage: Decimal get() = Decimal.ZERO + + /** + * Value of `1` means power consumption is doubled, `2` is tripled, `-0.5` is halved. + */ + val energyConsumed: Decimal get() = Decimal.ZERO + + /** + * **CAN NOT be negative.** + * + * Added directly over regular throughput + */ + val energyThroughputFlat: Decimal get() = Decimal.ZERO + + /** + * **CAN NOT be negative.** + * + * Value of `1` means power throughput is doubled, `2` is tripled, and so on. + */ + val energyThroughput: Decimal get() = Decimal.ZERO + + /** + * **CAN NOT be negative.** + * + * **Merged by multiplication** + */ + val failureMultiplier: Double get() = 1.0 + + companion object : IMatteryUpgrade +} + +fun IMatteryUpgrade.addUpgradeTooltipLines(tooltips: MutableCollection) { + if (upgradeTypes.isNotEmpty() && ShiftPressedCond.asBoolean) { + tooltips.add(TranslatableComponent("otm.gui.upgrade_type.list").withStyle(ChatFormatting.GRAY)) + + for (upgrade in upgradeTypes) { + tooltips.add(upgrade.component.copy().withStyle(ChatFormatting.GRAY)) + } + + tooltips.add(TextComponent("")) + } + + if (speedBonus >= 0.01) { + tooltips.add(TranslatableComponent("otm.gui.upgrade.speed", TextComponent("+" + (speedBonus.coerceIn(MachinesConfig.Upgrades.MIN_SPEED, MachinesConfig.Upgrades.MAX_SPEED) * 100.0).toInt().toString()).withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) + } else if (speedBonus <= -0.01) { + tooltips.add(TranslatableComponent("otm.gui.upgrade.speed", TextComponent((speedBonus.coerceIn(MachinesConfig.Upgrades.MIN_SPEED, MachinesConfig.Upgrades.MAX_SPEED) * 100.0).toInt().toString()).withStyle(ChatFormatting.DARK_RED)).withStyle(ChatFormatting.GRAY)) + } + + if (processingItems != 0) { + tooltips.add(TranslatableComponent("otm.gui.upgrade.processing_items", TextComponent("+$processingItems").withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) + } + + if (energyStorageFlat != Decimal.ZERO) { + tooltips.add(TranslatableComponent("otm.gui.upgrade.energy_storage_flat", energyStorageFlat.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) + } + + if (energyStorage != Decimal.ZERO) { + tooltips.add(TranslatableComponent("otm.gui.upgrade.energy_storage", TextComponent((energyStorage * 100).toString(0)).withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) + } + + if (energyConsumed > Decimal.ONE) { + tooltips.add(TranslatableComponent("otm.gui.upgrade.energy_consumed", TextComponent("+" + (energyConsumed.coerceIn(MachinesConfig.Upgrades.MIN_ENERGY, MachinesConfig.Upgrades.MAX_ENERGY) * 100).toString(0)).withStyle(ChatFormatting.DARK_RED)).withStyle(ChatFormatting.GRAY)) + } else if (energyConsumed < Decimal.MINUS_ONE) { + tooltips.add(TranslatableComponent("otm.gui.upgrade.energy_consumed", TextComponent((energyConsumed.coerceIn(MachinesConfig.Upgrades.MIN_ENERGY, MachinesConfig.Upgrades.MAX_ENERGY) * 100).toString(0)).withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) + } + + if (energyThroughputFlat != Decimal.ZERO) { + tooltips.add(TranslatableComponent("otm.gui.upgrade.energy_throughput_flat", energyThroughputFlat.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) + } + + if (energyThroughput != Decimal.ZERO) { + tooltips.add(TranslatableComponent("otm.gui.upgrade.energy_throughput", TextComponent((energyThroughput * 100).toString(0)).withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) + } + + if (failureMultiplier >= 1.01) { + tooltips.add(TranslatableComponent("otm.gui.upgrade.failsafe", TextComponent("+" + ((failureMultiplier - 1) * 100).toInt().toString()).withStyle(ChatFormatting.DARK_RED)).withStyle(ChatFormatting.GRAY)) + } else if (failureMultiplier <= 0.99) { + tooltips.add(TranslatableComponent("otm.gui.upgrade.failsafe", TextComponent(((failureMultiplier.coerceAtLeast(0.0) - 1) * 100).toInt().toString()).withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) + } +} + +fun IMatteryUpgrade.getUpgradeTooltipLines(): MutableList { + return ArrayList().also { addUpgradeTooltipLines(it) } +} + +enum class UpgradeType { + SPEED, + PROCESSING, + ENERGY_STORAGE, + ENERGY_CONSUMPTION, + ENERGY_THROUGHPUT, + FAILSAFE; + + val localeId = "otm.gui.upgrade_type.${name.lowercase()}" + val component: Component get() = TranslatableComponent(localeId) + + val flag = 1 shl (ordinal + 1) + fun set() = sets[flag] + + companion object { + private val cached = values() + + private val sets = Array(2 shl cached.size) { + immutableSet { + for (u in values()) if (it.and(u.flag) != 0) accept(u) + } + } + + @JvmField + val ALL = set(*values()) + @JvmField + val BASIC = set(SPEED, ENERGY_STORAGE, ENERGY_CONSUMPTION, ENERGY_THROUGHPUT) + + fun set(vararg types: UpgradeType): Set { + var flags = 0 + for (v in types) flags = flags or v.flag + return sets[flags] + } + + fun set(): Set { + return sets[0] + } + + fun set( + type0: UpgradeType, + ): Set = sets[type0.flag] + + fun set( + type0: UpgradeType, + type1: UpgradeType, + ): Set = sets[type0.flag or type1.flag] + + fun set( + type0: UpgradeType, + type1: UpgradeType, + type2: UpgradeType, + ): Set = sets[type0.flag or type1.flag or type2.flag] + + fun set( + type0: UpgradeType, + type1: UpgradeType, + type2: UpgradeType, + type3: UpgradeType, + ): Set = sets[type0.flag or type1.flag or type2.flag or type3.flag] + + fun set( + type0: UpgradeType, + type1: UpgradeType, + type2: UpgradeType, + type3: UpgradeType, + type4: UpgradeType, + ): Set = sets[type0.flag or type1.flag or type2.flag or type3.flag or type4.flag] + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt index d347c5feb..71f858864 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt @@ -59,7 +59,7 @@ object Widgets18 { val PATTERN_SLOT_BACKGROUND = slotBgGrid.next() val MATTER_CAPACITOR_SLOT_BACKGROUND = slotBgGrid.next() - private val controlsGrid = WidgetLocation.SIDE_CONTROLS.grid(rows = 7, columns = 9) + private val controlsGrid = WidgetLocation.SIDE_CONTROLS.grid(rows = 8, columns = 9) val BATTERY_ONLY = controlsGrid.next() val ITEMS_CONFIGURATION = controlsGrid.next() @@ -160,4 +160,6 @@ object Widgets18 { put(RelativeSide.FRONT, FRONT_CONTROLS) put(RelativeSide.BACK, BACK_CONTROLS) } + + val UPGRADES = controlsGrid.next() } 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 1d5bd9dd1..468a71ba5 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 @@ -319,7 +319,10 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit * @return FramePanel created, or null */ protected open fun makeMainFrame(): FramePanel>? { - return FramePanel(this, null, 0f, 0f, DEFAULT_FRAME_WIDTH, DEFAULT_FRAME_HEIGHT, getTitle()) + return FramePanel(this, null, 0f, 0f, DEFAULT_FRAME_WIDTH, DEFAULT_FRAME_HEIGHT, getTitle()).also { + it.onClose { onClose() } + it.makeCloseButton() + } } public override fun recalculateQuickCraftRemaining() { 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 a0ca9d7c8..c188af33e 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 @@ -1,8 +1,10 @@ package ru.dbotthepony.mc.otm.client.screen.panels import com.google.common.collect.ImmutableList +import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack +import it.unimi.dsi.fastutil.ints.IntAVLTreeSet import it.unimi.dsi.fastutil.objects.ReferenceArraySet import net.minecraft.client.gui.ComponentPath import net.minecraft.client.gui.Font @@ -23,6 +25,7 @@ import ru.dbotthepony.mc.otm.client.render.currentScissorRect import ru.dbotthepony.mc.otm.client.render.popScissorRect import ru.dbotthepony.mc.otm.client.render.pushScissorRect import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.button.AbstractButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.input.QueryUserPanel import java.util.* import kotlin.collections.ArrayList @@ -417,6 +420,7 @@ open class EditablePanel @JvmOverloads constructor( return field } + field = null return null } @@ -965,7 +969,7 @@ open class EditablePanel @JvmOverloads constructor( return true } - if (isHovered) { + if (isHovered || this is AbstractButtonPanel<*> && isPressed) { val tooltip = tooltip val tooltipList = tooltipList @@ -1186,10 +1190,6 @@ open class EditablePanel @JvmOverloads constructor( this.height = height } - companion object { - private val LOGGER = LogManager.getLogger()!! - } - protected open fun visibilityChanges(new: Boolean, old: Boolean) { } @@ -1589,7 +1589,7 @@ open class EditablePanel @JvmOverloads constructor( fun keyPressed(key: Int, scancode: Int, mods: Int): Boolean { if (!isVisible() || !acceptKeyboardInput) return false if (!isEverFocused()) return false - if (flashAnyBlocker(true)) return true + if (flashAnyBlocker(key !in ignoreFlashKeys)) return true if (isFocusedThis) return keyPressedInternal(key, scancode, mods) for (child in visibleChildrenInternal) { @@ -1737,4 +1737,21 @@ open class EditablePanel @JvmOverloads constructor( fun queryUser(title: Component, text: Collection, onConfirm: Runnable, onCancel: Runnable? = null): QueryUserPanel { return QueryUserPanel(screen, title, text, onConfirm, onCancel).also { blockingWindow = it } } + + companion object { + private val LOGGER = LogManager.getLogger()!! + + private val ignoreFlashKeys = IntAVLTreeSet() + + init { + ignoreFlashKeys.add(InputConstants.KEY_LEFT) + ignoreFlashKeys.add(InputConstants.KEY_RIGHT) + ignoreFlashKeys.add(InputConstants.KEY_UP) + ignoreFlashKeys.add(InputConstants.KEY_DOWN) + ignoreFlashKeys.add(InputConstants.KEY_RCONTROL) + ignoreFlashKeys.add(InputConstants.KEY_LCONTROL) + ignoreFlashKeys.add(InputConstants.KEY_RSHIFT) + ignoreFlashKeys.add(InputConstants.KEY_LSHIFT) + } + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index d1f9e24cb..ace546c82 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -12,6 +12,8 @@ import net.minecraft.network.chat.Component import org.lwjgl.opengl.GL30 import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.render.* +import ru.dbotthepony.mc.otm.client.screen.panels.button.AbstractButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.ButtonPanel open class FramePanel( screen: S, @@ -123,6 +125,30 @@ open class FramePanel( } } + inner class CloseButton : AbstractButtonPanel(screen, this@FramePanel, this@FramePanel.width - CLOSE_BUTTON.width, 0f, CLOSE_BUTTON.width, CLOSE_BUTTON.height) { + override fun onClick(mouseButton: Int) { + close() + } + + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + if (isPressed) { + CLOSE_BUTTON_PRESSED.render(graphics, 0f, 0f, width, height) + } else if (isHovered) { + CLOSE_BUTTON_HOVERED.render(graphics, 0f, 0f, width, height) + } else { + CLOSE_BUTTON.render(graphics, 0f, 0f, width, height) + } + } + + override fun onRemoved() { + super.onRemoved() + + if (closeButton == this) { + closeButton = null + } + } + } + protected val tabs: java.util.ArrayList = ArrayList() override fun performLayout() { @@ -131,13 +157,29 @@ open class FramePanel( tab.initial = i == 0 } + closeButton?.setPos(width - CLOSE_BUTTON.width, 0f) + super.performLayout() } protected var dragging = false + protected var closeButton: CloseButton? = null var closeOnEscape = false + fun makeCloseButton() { + if (closeButton == null) + closeButton = CloseButton() + } + + /** + * Adds close button and makes panel [close] when user presses ESC with this panel focused + */ + fun behaveAsWindow() { + closeOnEscape = true + makeCloseButton() + } + init { setDockPadding(PADDING, if (title != null) PADDING_TOP else PADDING, PADDING, PADDING) } @@ -187,9 +229,24 @@ open class FramePanel( } + protected val closeCallbacks = ArrayList() + + fun onClose(callback: Runnable) { + closeCallbacks.add(callback) + } + + /** + * Usually just calls [remove] + */ + open fun close() { + if (isRemoved) return + remove() + closeCallbacks.forEach { it.run() } + } + override fun keyPressedInternal(key: Int, scancode: Int, mods: Int): Boolean { if (key == InputConstants.KEY_ESCAPE && closeOnEscape) { - remove() + close() return true } @@ -258,9 +315,13 @@ open class FramePanel( padding = DockProperty(-3f, -3f, -3f, -3f) ) - val TAB_RIGHT_CONNECTION = WidgetLocation.MISC.sprite(x = 30f, y = 0f, width = 3f, height = 5f) - val TAB_LEFT_CONNECTION = WidgetLocation.MISC.sprite(x = 33f, y = 0f, width = 3f, height = 5f) - val TAB_BACKGROUND = WidgetLocation.MISC.sprite(x = 30f, y = 6f, width = 6f, height = 6f) + val TAB_RIGHT_CONNECTION = WidgetLocation.MISC.sprite(x = 30f, y = 0f, width = 3f, height = 5f) + val TAB_LEFT_CONNECTION = WidgetLocation.MISC.sprite(x = 33f, y = 0f, width = 3f, height = 5f) + val TAB_BACKGROUND = WidgetLocation.MISC.sprite(x = 30f, y = 6f, width = 6f, height = 6f) + + val CLOSE_BUTTON = WidgetLocation.MISC.sprite(x = 51f, y = 0f, width = 13f, height = 11f) + val CLOSE_BUTTON_HOVERED = WidgetLocation.MISC.sprite(x = 51f, y = 11f, width = 13f, height = 11f) + val CLOSE_BUTTON_PRESSED = WidgetLocation.MISC.sprite(x = 51f, y = 22f, width = 13f, height = 11f) const val TAB_HEIGHT = 28f const val TAB_WIDTH = 28f 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 759e7bdba..31e47b284 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 @@ -3,26 +3,38 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import com.mojang.blaze3d.platform.InputConstants import net.minecraft.ChatFormatting import net.minecraft.client.gui.GuiGraphics +import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.capability.addUpgradeTooltipLines import ru.dbotthepony.mc.otm.client.isCtrlDown import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.Dock +import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel import ru.dbotthepony.mc.otm.core.GetterSetter +import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.RelativeSide +import ru.dbotthepony.mc.otm.core.value +import ru.dbotthepony.mc.otm.menu.UpgradeSlots import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.FluidConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.IPlayerInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import java.util.function.Predicate +import kotlin.math.ceil +import kotlin.math.pow private fun > makeRedstoneSettingButton( screen: S, @@ -212,6 +224,7 @@ private fun > makeItemHandlerControlPanel( moveButtons(front, back, left, right, top, bottom) screen.addPanel(frame) frame.requestFocus() + frame.closeOnEscape = true return frame } @@ -240,6 +253,7 @@ private fun > makeEnergyConfigPanel( moveButtons(front, back, left, right, top, bottom) screen.addPanel(frame) frame.requestFocus() + frame.closeOnEscape = true return frame } @@ -268,6 +282,7 @@ private fun > makeFluidConfigPanel( moveButtons(front, back, left, right, top, bottom) screen.addPanel(frame) frame.requestFocus() + frame.closeOnEscape = true return frame } @@ -281,12 +296,17 @@ class DeviceControls>( val energyConfig: EnergyConfigPlayerInput? = null, val fluidConfig: FluidConfigPlayerInput? = null, val balanceInputs: BooleanInputWithFeedback? = null, + val upgrades: UpgradeSlots? = null, ) : EditablePanel(screen, parent, x = parent.width + 3f, height = 0f, width = 0f) { val itemConfigButton: LargeRectangleButtonPanel? val energyConfigButton: LargeRectangleButtonPanel? val fluidConfigButton: LargeRectangleButtonPanel? val redstoneControlsButton: LargeEnumRectangleButtonPanel? val balanceInputsButton: LargeBooleanRectangleButtonPanel? + val upgradesButton: LargeRectangleButtonPanel? + + private var upgradeWindow: FramePanel? = null + private var nextY = 0f fun

> addButton(button: P): P { @@ -310,6 +330,82 @@ class DeviceControls>( redstoneControlsButton = null } + if (upgrades != null) { + upgradesButton = addButton(object : LargeRectangleButtonPanel( + screen, this@DeviceControls, + skinElement = Widgets18.UPGRADES + ) { + init { + tooltip = TranslatableComponent("otm.gui.upgrades") + } + + override fun tickInner() { + super.tickInner() + + tooltipList = ArrayList().also { + it.add(TranslatableComponent("otm.gui.upgrades")) + it.add(TextComponent("")) + + if (upgrades.allowedTypes.isEmpty()) { + it.add(TranslatableComponent("otm.gui.upgrade_type.allowed_none").withStyle(ChatFormatting.DARK_GRAY)) + } else { + it.add(TranslatableComponent("otm.gui.upgrade_type.allowed").withStyle(ChatFormatting.GRAY)) + + for (upgrade in upgrades.allowedTypes) { + it.add(upgrade.component.copy().withStyle(ChatFormatting.GRAY)) + } + } + + val i = it.size + upgrades.currentStats.addUpgradeTooltipLines(it) + + if (it.size != i) { + it.add(i, TranslatableComponent("otm.gui.upgrades.current").withStyle(ChatFormatting.GRAY)) + it.add(i, TextComponent("")) + } + } + } + + override fun onClick(mouseButton: Int) { + if (mouseButton == InputConstants.MOUSE_BUTTON_LEFT) { + if (upgradeWindow != null && !upgradeWindow!!.isRemoved) { + upgradeWindow!!.toScreenCenter() + upgradeWindow!!.popup() + } else { + val square = ceil(upgrades.slots.size.toDouble().pow(0.5)).toInt() + val size = square * AbstractSlotPanel.SIZE + + upgradeWindow = FramePanel(screen, (size + 40f).coerceAtLeast(120f), 30f + size, TranslatableComponent("otm.gui.upgrades")).also { frame -> + val grid = GridPanel(screen, frame, width = AbstractSlotPanel.SIZE * square, height = AbstractSlotPanel.SIZE * square, columns = square, rows = square) + + for (slot in upgrades.slots) { + SlotPanel(screen, grid, slot) + } + + grid.dock = Dock.FILL + grid.dockResize = DockResizeMode.NONE + + screen.addPanel(frame) + + val parentFrame = this@DeviceControls.parent!! + + frame.behaveAsWindow() + frame.setPos(parentFrame.absoluteX + parentFrame.width / 2f - frame.width / 2f, parentFrame.absoluteY + parentFrame.height / 2f - frame.height / 2f) + frame.popup() + + upgrades.openState.value = true + frame.onClose { upgrades.openState.value = false } + + parentFrame.blockingWindow = frame + } + } + } + } + }) + } else { + upgradesButton = null + } + if (balanceInputs != null) { balanceInputsButton = addButton(LargeBooleanRectangleButtonPanel( screen, this, @@ -396,8 +492,9 @@ fun > makeDeviceControls( energyConfig: EnergyConfigPlayerInput? = null, fluidConfig: FluidConfigPlayerInput? = null, balanceInputs: BooleanInputWithFeedback? = null, + upgrades: UpgradeSlots? = null, ): DeviceControls { return DeviceControls(screen, parent, extra = extra, redstoneConfig = redstoneConfig, itemConfig = itemConfig, energyConfig = energyConfig, fluidConfig = fluidConfig, - balanceInputs = balanceInputs) + balanceInputs = balanceInputs, upgrades = upgrades) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/QueryUserPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/QueryUserPanel.kt index 4b7a8ec99..b36deebb1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/QueryUserPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/QueryUserPanel.kt @@ -63,6 +63,7 @@ open class QueryUserPanel( this.width = maxWidth.coerceAtLeast(bottom.children.stream().mapToDouble { it.width.toDouble() }.sum().toFloat() + 2f) + PADDING * 2f toScreenCenter() + behaveAsWindow() } override fun keyPressedInternal(key: Int, scancode: Int, mods: Int): Boolean { 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 2f3eda8cb..16d955ba2 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 @@ -636,7 +636,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I researchCanvas.setDockMargin(4f, 4f, 4f, 4f) research!!.toScreenCenter() - research!!.closeOnEscape = true + research!!.behaveAsWindow() addPanel(research!!) research!!.requestFocus() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt index d937ce9fd..3a3d28b6e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt @@ -8,7 +8,6 @@ import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel -import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu @@ -24,7 +23,7 @@ class PlatePressScreen(menu: PlatePressMenu, inventory: Inventory, title: Compon ProgressGaugePanel(this, frame, menu.progressGauge, 78f, PROGRESS_ARROW_TOP) SlotPanel(this, frame, menu.outputSlot, 104f, PROGRESS_SLOT_TOP) - makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig, upgrades = menu.upgrades) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/TwinPlatePressScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/TwinPlatePressScreen.kt index 6a2952f8c..946201340 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/TwinPlatePressScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/TwinPlatePressScreen.kt @@ -27,7 +27,7 @@ class TwinPlatePressScreen(menu: TwinPlatePressMenu, inventory: Inventory, title ProgressGaugePanel(this, frame, menu.progressGauge1, 78f, PROGRESS_ARROW_TOP + 10f) SlotPanel(this, frame, menu.outputSlots[1], 104f, PROGRESS_SLOT_TOP + 10f) - makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig, balanceInputs = menu.balanceInputs) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig, balanceInputs = menu.balanceInputs, upgrades = menu.upgrades) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt index 8fc6c4cef..607a4e858 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt @@ -10,6 +10,7 @@ import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.ChemicalGeneratorBlockEntity import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.registry.MNames object MachinesConfig : AbstractConfig("machines") { @@ -42,4 +43,34 @@ object MachinesConfig : AbstractConfig("machines") { } val ANDROID_CHARGER = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.ANDROID_CHARGER, capacity = Decimal(400_000), throughput = Decimal(8192)) { AndroidCharger } + + object Upgrades { + init { + builder.push("UPGRADES") + } + + val MIN_SPEED: Double by builder + .comment("Minimal combined upgrade speed percentage (upgrades can't decrease machine speed below this)") + .defineInRange("MIN_SPEED", -0.8, -1.0, Double.MAX_VALUE) + + val MAX_SPEED: Double by builder + .comment("Maximal combined upgrade speed percentage") + .defineInRange("MAX_SPEED", Double.MAX_VALUE, 0.0, Double.MAX_VALUE) + + val MIN_ENERGY by builder + .comment("Minimal combined energy consumption percentage (upgrades can't decrease machine energy consumption below this)") + .defineDecimal("MIN_ENERGY", Decimal(-0.8), Decimal(-1.0)) + + val MAX_ENERGY by builder + .comment("Maximal combined energy consumption percentage") + .defineDecimal("MAX_ENERGY", Decimal.LONG_MAX_VALUE, Decimal.ZERO) + + init { + builder.pop() + } + } + + init { + Upgrades + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt new file mode 100644 index 000000000..d93c2c282 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt @@ -0,0 +1,54 @@ +package ru.dbotthepony.mc.otm.container + +import ru.dbotthepony.mc.otm.capability.IMatteryUpgrade +import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.UpgradeType +import ru.dbotthepony.mc.otm.config.ConciseBalanceValues +import ru.dbotthepony.mc.otm.config.VerboseBalanceValues +import ru.dbotthepony.mc.otm.core.isNotEmpty +import ru.dbotthepony.mc.otm.core.math.Decimal +import kotlin.math.pow + +open class UpgradeContainer(slotCount: Int, open val allowedUpgrades: Set = UpgradeType.ALL, watcher: Runnable = Runnable {}) : MatteryContainer(watcher, slotCount), IMatteryUpgrade { + constructor(watcher: Runnable, slotCount: Int, allowedUpgrades: Set) : this(slotCount, allowedUpgrades, watcher) + + final override val upgradeTypes: Set + get() = setOf() + + override val speedBonus: Double + get() = stream().filter { it.isNotEmpty }.mapToDouble { it.getCapability(MatteryCapability.UPGRADE).map { it.speedBonus }.orElse(0.0) * it.count }.sum() + override val processingItems: Int + get() = stream().filter { it.isNotEmpty }.mapToInt { it.getCapability(MatteryCapability.UPGRADE).map { it.processingItems }.orElse(0).coerceAtLeast(0) * it.count }.sum() + override val energyStorageFlat: Decimal + get() = stream().filter { it.isNotEmpty }.map { it.getCapability(MatteryCapability.UPGRADE).map { it.energyStorageFlat }.orElse(Decimal.ZERO).moreThanZero() * it.count }.reduce(Decimal.ZERO, Decimal::plus) + override val energyStorage: Decimal + get() = stream().filter { it.isNotEmpty }.map { it.getCapability(MatteryCapability.UPGRADE).map { it.energyStorage }.orElse(Decimal.ZERO).moreThanZero() * it.count }.reduce(Decimal.ZERO, Decimal::plus) + override val energyConsumed: Decimal + get() = stream().filter { it.isNotEmpty }.map { it.getCapability(MatteryCapability.UPGRADE).map { it.energyConsumed }.orElse(Decimal.ZERO) * it.count }.reduce(Decimal.ZERO, Decimal::plus) + override val failureMultiplier: Double + get() = stream().filter { it.isNotEmpty }.mapToDouble { it.getCapability(MatteryCapability.UPGRADE).map { it.failureMultiplier }.orElse(1.0).coerceAtLeast(0.0).pow(it.count.toDouble()) }.reduce(1.0) { a, b -> a * b } + override val energyThroughputFlat: Decimal + get() = stream().filter { it.isNotEmpty }.map { it.getCapability(MatteryCapability.UPGRADE).map { it.energyThroughputFlat }.orElse(Decimal.ZERO).moreThanZero() * it.count }.reduce(Decimal.ZERO, Decimal::plus) + override val energyThroughput: Decimal + get() = stream().filter { it.isNotEmpty }.map { it.getCapability(MatteryCapability.UPGRADE).map { it.energyThroughput }.orElse(Decimal.ZERO).moreThanZero() * it.count }.reduce(Decimal.ZERO, Decimal::plus) + + fun transform(values: ConciseBalanceValues): ConciseBalanceValues { + return object : ConciseBalanceValues { + override val capacity: Decimal + get() = values.capacity * (energyStorage + Decimal.ONE) + energyStorageFlat + override val throughput: Decimal + get() = values.throughput * (energyThroughput + Decimal.ONE) + energyThroughputFlat + } + } + + fun transform(values: VerboseBalanceValues): VerboseBalanceValues { + return object : VerboseBalanceValues { + override val capacity: Decimal + get() = values.capacity * (energyStorage + Decimal.ONE) + energyStorageFlat + override val receive: Decimal + get() = values.receive * (energyThroughput + Decimal.ONE) + energyThroughputFlat + override val extract: Decimal + get() = values.extract * (energyThroughput + Decimal.ONE) + energyThroughputFlat + } + } +} 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 efbf72a36..2a1d8b81d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -91,8 +91,8 @@ inline fun LazyOptional.ifPresentK(lambda: (T) -> Unit) { val ItemStack.tagNotNull: CompoundTag get() = orCreateTag -val FluidStack.isNotEmpty get() = !isEmpty -val ItemStack.isNotEmpty get() = !isEmpty +inline val FluidStack.isNotEmpty get() = !isEmpty +inline val ItemStack.isNotEmpty get() = !isEmpty inline var Entity.position: Vec3 get() = position() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ConditionalEnumSet.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ConditionalEnumSet.kt new file mode 100644 index 000000000..9dbbf12ab --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ConditionalEnumSet.kt @@ -0,0 +1,41 @@ +package ru.dbotthepony.mc.otm.core.collect + +import java.util.EnumMap +import java.util.function.BooleanSupplier +import java.util.stream.Stream + +class ConditionalEnumSet>private constructor(private val backing: EnumMap, marker: Unit) : Set { + constructor(clazz: Class) : this(EnumMap(clazz), Unit) + constructor(map: Map) : this(EnumMap(map), Unit) + + override val size: Int + get() = backing.values.stream().filter { it.asBoolean }.count().toInt() + + override fun contains(element: T): Boolean { + return backing[element]?.asBoolean ?: false + } + + override fun containsAll(elements: Collection): Boolean { + return elements.all { contains(it) } + } + + override fun isEmpty(): Boolean { + return backing.isEmpty() || backing.values.none { it.asBoolean } + } + + override fun stream(): Stream { + return backing.entries.stream().filter { it.value.asBoolean }.map { it.key } + } + + override fun iterator(): Iterator { + return backing.entries.iterator().filter { it.value.asBoolean }.map { it.key } + } + + fun add(value: T, condition: BooleanSupplier) { + backing[value] = condition + } + + fun remove(value: T): Boolean { + return backing.remove(value) != null + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ConditionalSet.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ConditionalSet.kt index 781f9ef47..9596f15e9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ConditionalSet.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ConditionalSet.kt @@ -1,68 +1,57 @@ package ru.dbotthepony.mc.otm.core.collect +import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap +import java.util.function.BooleanSupplier import java.util.stream.Stream -class ConditionalSet : AbstractSet { - // method without boxing - fun interface Condition { - fun check(): Boolean +class ConditionalSet : Set { + private val backing = Object2ObjectLinkedOpenHashMap() + + override val size: Int + get() = backing.values.stream().filter { it.asBoolean }.count().toInt() + + override fun contains(element: E): Boolean { + return backing[element]?.asBoolean ?: false } - private val getters: Array> - - constructor(vararg getters: Pair) : super() { - this.getters = Array(getters.size) { getters[it] } + override fun containsAll(elements: Collection): Boolean { + return elements.all { contains(it) } } - constructor(getters: List>) : super() { - this.getters = Array(getters.size) { getters[it] } + override fun isEmpty(): Boolean { + return backing.isEmpty() || backing.values.stream().noneMatch { it.asBoolean } } - constructor(getters: Stream>) : super() { - this.getters = getters.toArray { arrayOfNulls>(it) } + override fun stream(): Stream { + return backing.entries.stream().filter { it.value.asBoolean }.map { it.key } } - override val size: Int get() { - var i = 0 - - for (pair in getters) { - if (pair.first.check()) { - i++ - } - } - - return i + override fun iterator(): Iterator { + return backing.entries.iterator().filter { it.value.asBoolean }.map { it.key } } - override fun iterator(): Iterator { - return object : Iterator { - val parent = getters.iterator() - private var pair: Pair? = null + fun add(element: E, condition: BooleanSupplier): Boolean { + if (element in backing) return false + backing[element] = condition + return true + } - private fun search() { - for (pair in parent) { - if (pair.first.check()) { - this.pair = pair - return - } - } + fun addFirst(element: E, condition: BooleanSupplier): Boolean { + if (element in backing) return false + backing.putAndMoveToFirst(element, condition) + return true + } - this.pair = null - } + fun replace(element: E, condition: BooleanSupplier) { + backing[element] = condition + } - init { - search() - } + fun replaceFirst(element: E, condition: BooleanSupplier) { + backing.remove(element) + backing.putAndMoveToFirst(element, condition) + } - override fun hasNext(): Boolean { - return pair != null - } - - override fun next(): T { - val pair = pair ?: throw NoSuchElementException() - search() - return pair.second - } - } + fun remove(element: E): Boolean { + return backing.remove(element) != null } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/SimpleUpgrade.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/SimpleUpgrade.kt new file mode 100644 index 000000000..66fdf57bd --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/SimpleUpgrade.kt @@ -0,0 +1,51 @@ +package ru.dbotthepony.mc.otm.item + +import net.minecraft.core.Direction +import net.minecraft.nbt.CompoundTag +import net.minecraft.network.chat.Component +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.TooltipFlag +import net.minecraft.world.level.Level +import net.minecraftforge.common.capabilities.Capability +import net.minecraftforge.common.capabilities.ICapabilityProvider +import net.minecraftforge.common.util.LazyOptional +import ru.dbotthepony.mc.otm.capability.IMatteryUpgrade +import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.UpgradeType +import ru.dbotthepony.mc.otm.capability.addUpgradeTooltipLines +import ru.dbotthepony.mc.otm.core.TextComponent +import ru.dbotthepony.mc.otm.core.math.Decimal + +class SimpleUpgrade( + properties: Properties, + override val upgradeTypes: Set, + override val speedBonus: Double = 0.0, + override val processingItems: Int = 0, + override val energyStorageFlat: Decimal = Decimal.ZERO, + override val energyStorage: Decimal = Decimal.ZERO, + override val energyConsumed: Decimal = Decimal.ZERO, + override val energyThroughputFlat: Decimal = Decimal.ZERO, + override val energyThroughput: Decimal = Decimal.ZERO, + override val failureMultiplier: Double = 1.0, +) : Item(properties), IMatteryUpgrade, ICapabilityProvider { + private val resolver = LazyOptional.of { this } + + override fun getCapability(cap: Capability, side: Direction?): LazyOptional { + if (cap === MatteryCapability.UPGRADE) { + return resolver.cast() + } + + return LazyOptional.empty() + } + + override fun appendHoverText(p_41421_: ItemStack, p_41422_: Level?, p_41423_: MutableList, p_41424_: TooltipFlag) { + super.appendHoverText(p_41421_, p_41422_, p_41423_, p_41424_) + addUpgradeTooltipLines(p_41423_) + } + + override fun initCapabilities(stack: ItemStack, nbt: CompoundTag?): ICapabilityProvider { + return this + } +} + diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index bc92c1a77..24429784e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -11,6 +11,7 @@ import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer 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.inventory.AbstractContainerMenu @@ -23,6 +24,9 @@ import net.minecraft.world.item.enchantment.EnchantmentHelper.hasBindingCurse import net.minecraft.world.level.block.entity.BlockEntity import net.minecraftforge.network.NetworkEvent import net.minecraftforge.network.PacketDistributor +import ru.dbotthepony.mc.otm.capability.IMatteryUpgrade +import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.UpgradeType import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.compat.cos.cosmeticArmorSlots @@ -31,7 +35,12 @@ import ru.dbotthepony.mc.otm.compat.curios.isCurioSlot import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot import ru.dbotthepony.mc.otm.container.MatteryContainer +import ru.dbotthepony.mc.otm.container.UpgradeContainer import ru.dbotthepony.mc.otm.core.GetterSetter +import ru.dbotthepony.mc.otm.core.collect.ConditionalEnumSet +import ru.dbotthepony.mc.otm.core.collect.ConditionalSet +import ru.dbotthepony.mc.otm.core.immutableList +import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.util.BigDecimalValueCodec import ru.dbotthepony.mc.otm.core.util.BinaryStringCodec import ru.dbotthepony.mc.otm.core.util.BooleanValueCodec @@ -49,10 +58,14 @@ import ru.dbotthepony.mc.otm.network.packetHandled import ru.dbotthepony.mc.otm.network.sender import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer import ru.dbotthepony.mc.otm.network.synchronizer.IField +import ru.dbotthepony.mc.otm.network.synchronizer.IMutableBooleanField import java.io.DataInputStream import java.io.DataOutputStream import java.math.BigDecimal import java.util.* +import java.util.function.BooleanSupplier +import java.util.function.DoubleSupplier +import java.util.function.IntSupplier import java.util.function.Predicate import java.util.function.Supplier @@ -63,6 +76,17 @@ data class EquipmentSlots( val curiosSlots: List> ) +/** + * [openState] **is clientside only**, attempting to use it on server will result + * in classloading exceptions. + */ +data class UpgradeSlots( + val slots: List, + val allowedTypes: Set, + val openState: GetterSetter, + val currentStats: IMatteryUpgrade +) + abstract class MatteryMenu @JvmOverloads protected constructor( menuType: MenuType<*>?, containerId: Int, @@ -382,7 +406,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( return player.distanceToSqr(pos.x.toDouble() + 0.5, pos.y.toDouble() + 0.5, pos.z.toDouble() + 0.5) <= 64.0 } - private val externalSlots = ArrayList() + private val externalSlots = ConditionalSet() private val quickMoveMapping = Reference2ObjectOpenHashMap>>() override fun addSlot(pSlot: Slot): Slot { @@ -412,11 +436,17 @@ abstract class MatteryMenu @JvmOverloads protected constructor( /** * Adds slot to "storage slots" list (utilized by quick move) and calls [addSlot] + * + * [condition] allows to specify when slot is invisible on GUI (hence being ignored by quick move) */ - protected fun addStorageSlot(slot: T, addMapping: Boolean = true): T { + protected fun addStorageSlot(slot: T, addMapping: Boolean = true, prepend: Boolean = false, condition: BooleanSupplier = BooleanSupplier { true }): T { if (slot !in externalSlots) { addSlot(slot) - externalSlots.add(slot) + + if (prepend) + externalSlots.replaceFirst(slot, condition) + else + externalSlots.replace(slot, condition) if (addMapping) { mapQuickMove(slot, equipmentSlots) @@ -446,8 +476,8 @@ abstract class MatteryMenu @JvmOverloads protected constructor( mapQuickMove(slot, externalSlots, prepend = prepend) } - protected fun mapQuickMove(slot: Slot, target: Collection, prepend: Boolean = false) { - val listing = quickMoveMapping.computeIfAbsent(slot, Reference2ObjectFunction { ReferenceArrayList(1) }) + protected fun mapQuickMove(slot: Slot, target: Collection, prepend: Boolean = false, condition: BooleanSupplier = BooleanSupplier { true }) { + val listing = quickMoveMapping.computeIfAbsent(slot, Reference2ObjectFunction { ReferenceArrayList(1) /* ReferenceArrayList ибо мы используем его в некотором смысле как множество */ }) listing.remove(target) if (prepend) @@ -715,6 +745,56 @@ abstract class MatteryMenu @JvmOverloads protected constructor( ) } + fun makeUpgradeSlots(count: Int, container: UpgradeContainer?): UpgradeSlots { + if (container != null) { + require(count == container.containerSize) { "Upgrade container size ${container.containerSize} does not match with provided size $count" } + } + + val allowedTypes = EnumMap(UpgradeType::class.java) + + for (value in UpgradeType.ALL) { + allowedTypes[value] = mSynchronizer.bool() + + if (container != null) { + allowedTypes[value]!!.boolean = value in container.allowedUpgrades + } + } + + val syncContainer = container ?: SimpleContainer(count) + + var isOpen = false + val input = PlayerInput(BooleanValueCodec, allowSpectators = true, handler = { isOpen = it }) + + return UpgradeSlots( + slots = immutableList(count) { + object : MatterySlot(syncContainer, it) { + init { + mapQuickMoveToInventory(this) + addStorageSlot(this, prepend = true, condition = { isOpen }) + } + + override fun mayPlace(itemStack: ItemStack): Boolean { + return super.mayPlace(itemStack) && itemStack.getCapability(MatteryCapability.UPGRADE).map { it.upgradeTypes.any { allowedTypes[it]!!.boolean } }.orElse(false) + } + } + }, + + allowedTypes = ConditionalEnumSet(allowedTypes), + openState = GetterSetter.of({ isOpen }, { input.input(it); isOpen = it }), + currentStats = object : IMatteryUpgrade { + override val upgradeTypes: Set = setOf() + override val speedBonus: Double by mSynchronizer.computedDouble(DoubleSupplier { container?.speedBonus ?: 0.0 }).property + override val processingItems: Int by mSynchronizer.computedInt(IntSupplier { container?.processingItems ?: 0 }).property + override val energyStorageFlat: Decimal by mSynchronizer.computedDecimal { container?.energyStorageFlat ?: Decimal.ZERO } + override val energyStorage: Decimal by mSynchronizer.computedDecimal { container?.energyStorage ?: Decimal.ZERO } + override val energyConsumed: Decimal by mSynchronizer.computedDecimal { container?.energyConsumed ?: Decimal.ZERO } + override val energyThroughputFlat: Decimal by mSynchronizer.computedDecimal { container?.energyThroughputFlat ?: Decimal.ZERO } + override val energyThroughput: Decimal by mSynchronizer.computedDecimal { container?.energyThroughput ?: Decimal.ZERO } + override val failureMultiplier: Double by mSynchronizer.computedDouble(DoubleSupplier { container?.failureMultiplier ?: 1.0 }).property + } + ) + } + companion object { val TEXTURE_EMPTY_SLOTS: List = ImmutableList.of( InventoryMenu.EMPTY_ARMOR_SLOT_BOOTS, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt index 68ee7387d..01f2cc395 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt @@ -10,6 +10,7 @@ import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.container.UpgradeContainer import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.runOnClient diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt index 0f33d9ed6..935922882 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt @@ -26,6 +26,8 @@ class PlatePressMenu @JvmOverloads constructor( val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig, allowPull = true) val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) + val upgrades = makeUpgradeSlots(3, tile?.upgrades) + init { addStorageSlot(inputSlot) addStorageSlot(outputSlot) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/TwinPlatePressMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/TwinPlatePressMenu.kt index f6bda5c84..e5168c070 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/TwinPlatePressMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/TwinPlatePressMenu.kt @@ -31,6 +31,8 @@ class TwinPlatePressMenu @JvmOverloads constructor( val balanceInputs = BooleanInputWithFeedback(this) + val upgrades = makeUpgradeSlots(4, tile?.upgrades) + init { if (tile != null) { balanceInputs.with(tile::balanceInputs) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt index 6434da4ae..44a35bf41 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt @@ -130,6 +130,7 @@ private fun CreativeModeTab.Output.fluids(value: Item) { private fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { with(consumer) { accept(MItems.MACHINES) + accept(MItems.CreativeUpgrades.LIST) accept(MRegistry.CARGO_CRATES.item) accept(MItems.HOLO_SIGN) 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 4577d88c7..ea6697944 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -4,7 +4,6 @@ package ru.dbotthepony.mc.otm.registry import net.minecraft.ChatFormatting import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation -import net.minecraft.world.entity.EquipmentSlot import net.minecraft.world.food.FoodProperties import net.minecraft.world.item.* import net.minecraft.world.item.crafting.Ingredient @@ -15,9 +14,11 @@ 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.capability.UpgradeType import ru.dbotthepony.mc.otm.config.ItemsConfig import ru.dbotthepony.mc.otm.core.collect.SupplierList import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.item.* import ru.dbotthepony.mc.otm.item.exopack.ExoPackCraftingUpgradeItem import ru.dbotthepony.mc.otm.item.exopack.ExoPackProbeItem @@ -160,6 +161,38 @@ object MItems { TRITANIUM_ANVIL = SupplierList(props) } + object CreativeUpgrades { + val SPEED: SimpleUpgrade by registry.register("creative_speed_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.SPEED.set(), speedBonus = 1.0) } + val ENERGY_CONSUMPTION: SimpleUpgrade by registry.register("creative_energy_consumption_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_CONSUMPTION.set(), energyConsumed = Decimal.MINUS_ONE) } + val ENERGY_STORAGE: SimpleUpgrade by registry.register("creative_energy_storage_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_STORAGE.set(), energyStorage = Decimal.ONE) } + val ENERGY_STORAGE_FLAT: SimpleUpgrade by registry.register("creative_energy_storage_flat_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_STORAGE.set(), energyStorageFlat = Decimal.LONG_MAX_VALUE) } + val ENERGY_STORAGE_FLAT_SMALL: SimpleUpgrade by registry.register("creative_energy_storage_flat2_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_STORAGE.set(), energyStorageFlat = Decimal.INT_MAX_VALUE) } + val ENERGY_THROUGHPUT: SimpleUpgrade by registry.register("creative_energy_throughput_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_THROUGHPUT.set(), energyThroughput = Decimal.ONE) } + val ENERGY_THROUGHPUT_FLAT: SimpleUpgrade by registry.register("creative_energy_throughput_flat_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_THROUGHPUT.set(), energyThroughputFlat = Decimal.LONG_MAX_VALUE) } + val ENERGY_THROUGHPUT_FLAT_SMALL: SimpleUpgrade by registry.register("creative_energy_throughput_flat2_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_THROUGHPUT.set(), energyThroughputFlat = Decimal.INT_MAX_VALUE) } + val FAILSAFE: SimpleUpgrade by registry.register("creative_failsafe_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.FAILSAFE.set(), failureMultiplier = 0.0) } + val FAILURE: SimpleUpgrade by registry.register("creative_failure_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.FAILSAFE.set(), failureMultiplier = 2.0) } + val PROCESSING_ITEMS: SimpleUpgrade by registry.register("creative_processing_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.PROCESSING.set(), processingItems = 1) } + + val LIST = SupplierList( + ::SPEED, + ::ENERGY_CONSUMPTION, + ::ENERGY_STORAGE, + ::ENERGY_STORAGE_FLAT, + ::ENERGY_STORAGE_FLAT_SMALL, + ::ENERGY_THROUGHPUT, + ::ENERGY_THROUGHPUT_FLAT, + ::ENERGY_THROUGHPUT_FLAT_SMALL, + ::FAILSAFE, + ::FAILURE, + ::PROCESSING_ITEMS, + ) + } + + init { + CreativeUpgrades + } + val MATTER_DUST: Item by registry.register(MNames.MATTER_DUST) { MatterDustItem() } val TRITANIUM_ORE_CLUMP: Item by registry.register(MNames.TRITANIUM_ORE_CLUMP) { Item(DEFAULT_PROPERTIES) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt index a7d5a8e79..ae77498d5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt @@ -25,6 +25,7 @@ object MItemTags { val CARGO_CRATES: TagKey = ItemTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "cargo_crates")) val MINECART_CARGO_CRATES: TagKey = ItemTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "minecart_cargo_crates")) val INDUSTRIAL_GLASS: TagKey = ItemTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "industrial_glass")) + val UPGRADES: TagKey = ItemTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "upgrades")) val CRAFTING_TABLES: TagKey = ItemTags.create(ResourceLocation("forge", "crafting_tables")) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/misc.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/misc.png index 8923a02d7129ba396ac5c898077776eab444eda6..bc3b614b3dd43b4cce917a916ff7fc140deec3db 100644 GIT binary patch delta 1299 zcmV+u1?>9N1Fs5@8Gi-<0063Kaozv`0fcEoLr_UWLm+T+Z)Rz1WdHyuk$sUpNW(xJ z#b47(RVpHO5OK&*o$R6_j-`r4uu$3xtvZ-o`UOoIk`xz5!L{Jv$70pN#aUMeS3wZ` z0C9D3Qgo3L|Cbb6#CUMrk9YSTckck9S!Jpjhyki*8Ry{D6reiwfL2XskIMF-~x1PwGB!$4z|0009l zNklbu^{sX!c8@!ZwNdEy@ z5CZAwp>eScB9J9y$ef{I67Z7sI>hJ7Mmjy|Wcdg8S;U#M?!NEdyZ3a5<#L&UB)YDH zZQFl1Yl_~-`+#8>3;@7&-M2rnx4$7GN=${SWj;oc3y{IGEU;~RrXzX|h{%G2Q~7at zNb2|H=7y#|FpmOchfq8KfaiHhRwPVPOzwgkG-) zrfDubH_8B`(MU=>#S`MhXT1sL!m`-7FyKarA~z4V4-p^d30WEd5s`VG zCnYv3mc>SeLDnIFl}bg}VOII!ri9cgLI8t#UQ~u=O`P!~OW~|zT+=kLEGx2NL_~kA zR;!sC;LqtPso#h5^LZ(psRwA9Hvcw2M6A_np`H-+dv5!~$qAU3mka=KWm$kR#zYli ztJTWf2=5;sN&S93Kf~991NeS-$5vVgtTP)NO(w$j))qoku1lr4=%dL5u1lrxETHSU zXv5kGBSeV@04UnF%?~qV-92f_!aRS%AkGLy0DyYEE;Ufv&)Pi1$9Y2R9^g0*IF7TG z?k{SS3=kB)jYg0zg&U2A)R$4-Y4F`(khl~^kUXU1wA<~4Y$AEQor>Sb$0RKuude1s zK$i4WQn2E@2&7tnT?QCDJ;ArzTbP%^olZw;;K0hq+B5Cl0EPRP7gE2!udjdbX@4Jn zK0L&i!j@%G3ndo3-3enn9`kx(<$DA5{-8iyS#q@~iv2u_9}Yh-<>I5x4ux4jHZ;}^ z<^G_UWOcU<%KgF4ehr4*A4GZpKgmgp@B16+{-QS71AO1#NP)SO!a?D_?~^>m^E?){ z+poGbJ{t}bXBlLSu`EJhmi}8<+_}J}-3#ngDV!<NS%G}H0G|+7 zb93|V?rtD2G&J=8|NqC19rN?^3kwS~H8lkadfCga1X5fjL4LtNSqNa*bVlbqP?WR4 zBeIx*f$uN~Gak=hkpi?()3e^iF(ktM?bMso4l8gtterIT!+(1l1rH-mTdml6d-PQm zW3FfI`si?mNom?7V+L0Lg-zTIAwi1H9v5CEo-TAe8(6BDv&!H91M8$@#_Ri)ZfJda zaar($cIB6!OBT4W&M;rKmW9=0wfa|$^RYQn zDz~uin($H1Vd58amfU@OYOK4G)Xz29Y5tGv;9@Z0;Hvl_v^Sl@LUD)V+wHX`4v+Tz zKmO0V#<0Y5!SCZ1?^yRq?3%%#vq3p`G4n!i;euwV)Y*-a2M=y}aO^tk@75IzIvt!l z-bw6k}sn;6@9+$#Mq5qL1KF^w&g>D_L(S&~n9op&sp s={V_MTV#`J!n6d=8LAbL4L{f?EGRR&WxDMWFfbWBUHx3vIVCg!07Q7ai~s-t diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.png index 2c2c135b45749997a8b2951fe4eaa463661da934..54effb4a70e92979c02510d7900df312682508c1 100644 GIT binary patch delta 2899 zcmXw52{hDS8=i`oK75QVWwMQZNwSNH#-80|$%sJ)O&Ky&_?5~Sglx$+F_x%CV+KjY zpDaUVAM0O8qLEBlvVNn^ckj99-1naQy!U;d_kGT}Oi`kEn)s14-oqdeDCz9W#)mS} zz<>=>MHVlJ>vSw&70afSCYrx=96R#DFvn|?+wNGph`41-&8JTt=%JQ(9&S8trh?lb zTm;Vf`a{UxBN5NGsL+Yj$n_JE%b+5UfJ%vk1C^I077$)Nb8hcGsmAe2-!tK}?itK@ z{7&sm2h%t@x-p5Zwj2(m94PhCYF31F06ACP+m5%<^0GhNAnEro(#@jn&jj^y6Q$}k z8n)Z(Kfi1~-D;t0>>#NiW{XmbJf(VEWrYuiaMEFjhiRzh*XchSG7Oo@c&q8!dqK;q z+#sGSI}LF})_>5+R8*{(9$b=RH4r<|3SZoC`JCQ`JRsL`FxXMXAod4*WAcSZK2R8z zVTOA$|E?C^e&>@$Z}7<4Iu%=I5868&S{kukqoBENeUnT!Pr2QK{WSBM+;yvYPC%1g zVjKV2DmK@Q%KL`Yr#E+J`r;Gd{nCrZ)Bzr8Ta@|~h=2n&q&RLBq|b&K_mb z$YglyJOp@6`NnfFw@O|Sh?Va7F`$4^tCz^^#$6}f8hS**#ZqkGWB$uPUwYKc)Q|J(Z1)&6T-`jOWs%O_Mh~21}`NlQEA6T zAK2(`Xqz|PH7*vrqG<2nU`c52Md}WRmv9xB`MV8eT(D?}dw^^&O8>1g<}RO1^_wq` z_(gT0#0>)OE$OWaBklp2u5DC?(t;4SIA^)Ev8>9|ftWS9x3je<*Y~~V!JdgxLn8b} zgR1sie3S@fZnJw*El8;tVhD>1+dYjOGk_tFS7H7CLn46g6ilg!i5 zvJtOC!L$fw_5s&NanS#+PWyd}RRE(*aI9Ar4O#W^QG2cPyQ@p7*YT@qEE2&BjKann z8)er@9Ww3l!1ibwU$*R*iswDuQ^uq9I(lXVR{+l@Hw7yAZ&D{UDr0PQJM~lHSumUec z(aEfM@_gzpMH{l-aS~Z-%4?*d4j7frm5Tr)qPXOHpeNkJy}@g73gD$@#YRIl!N8)UmK`M5SVplce>z!Mq(gwS@l6nBGJpDs8c72Bzo$p0KNEz- zJET&e>||Icg}jVg)jVaIuK>}7GC-;3mtfU7*Knhb6%%G4V%rV z@9*#-3917&NvcEk4@OTpPCOqS5=I|REV>bF6oDaH_(kQ9+cT`${FdQcE}mYVc)Y(F zHt!jIsd^+9qr$=2b_@Jv4TP|hbT+5vbo$8pp)cIm?c~+65O%s)#IF^Xj1X3$Q<>X< zPu1fZy35Yf-zcOPUlY-VP|Z@j|P zEG_gZFWBf4fy=tq0ko&dS zVfym*{axqn_nFoP21UoBn)|ESF1hgiSOLz`97|5s`TPZ!qBI;ZzwoZWyZ>kd>rCvx zdV2fFY9wk6wQ)0cBDJfq1n;$L^>cQ!NgGaiRkHhvwXwbOU8f?i|`Y{xNAEz58W^h*BU@XDbbrt?dnhJa;q2+!70N!{Y$LN3`|P zbF%72O~P`}t7wxv2C09>riQkqSO1055?cJ;Z(`|f8dQVM%4s;<3Qiog)-1I>hxX$t z{^O()I{e~b?l=GvG)JTf<`g7&21|kx6pGh&x8p#UtDG zYPF=~ItLR&F8$0HCm90Tr&i>htMg~Vy{cKCY)cS16{5_hFN$?=wfk%CW-iQM=r}gF zI9Xu$4`P5c_MIDLT=aNEr0b1@RU%@N4`yCW*@tkr{agIohj>KBV$T*q11(E>*B<&t z6|niR>gH4lM@9^Ns}ja!IA{RDLFqMxkZcIxg{d)#Kcfs&v9qRRk@9y3sj%pV$q&Vu zYx1t?tQcf^$Q&n_XK6*gI9(*9tW-%?{2bw|b0l)jdLJ;cd$x#QJ+-hg_FD#o<-ybpw&^Qb3s$L(H78qRcr2 z;Y!EAD)f0*wMS*qCu}i`11FsKt0-dReIE}_oa@j0cp2@ot5}fD5l?9V&);l8h%^;C zDorJpv(n1fI!e!b-;AZtut&Q%ZAq*7xj~}`h6Expv!i1-wmoKOH8f@V%9W)vyK1YW zW2{7=Oc`wJv^{1l=(H)PM&Gu+aX6yucVA*RM;jbz3{DWO`M@jJ!X9Oj40bB&VS}$C zL^!JUKyZOg|Eb@u(5LwwHxW&SDP20P0cJ3hLw?IWR^H6r>}Qij#hE0xDf_65EJ5%A zX|bxNf?nFi=-Rz~Gd2uRqK+D)G3dB?`GYP`veN~} zfg3Ezv9(Ksr|G5^X-?y$uYs7m$XEK?hqmm4{GxZ z0e!t*7qH{9erLU9Jz=mkp&W=w-#G`wU@dm278`Kl&}}uu8%jKEhYv(oouM2P;Bgea z^Bh4}^=3v4MnEfN(;8*JS5E63xFx&TKskrxVhiF*`d2yM1J5dEmYs>Kxep@|rWHUQo0zFV-TlnYM6CDq!6eKCJVZq du-{{$uQqsMeEE!g#)-6j+uGb7K{4}*`yZiNgv9^= delta 2720 zcmXX_dpy%?7+)%vZftQ7BbuS4n8rWRXi2)yZUC$S-nfP8T#{hcjD-k!2M^ zm(yu8DW$@g+%LIo4ytLkan?EKegAph_xnEI&-;Cz=S$M&YvpQhNL5t^fk2g8+Wqp3 zwgboN=~^lX&jeL$sgQ1bi;?3|=P%e$>rfQ7Y-DrF6C0+#o}Yfr@V6r>+Oarj*!lzW zYdPIq^al@&EF6mmkG)Jl4h|%LezsP2b3wd~J$x0&rtG%j2o9)1y<1i|GV+ugQrmTO_77PmExn;+ z#GwNWtGf=vY8c(i+I%>|2vc(~hh!t-Im=G)sK$4_S)2C~-rn1wl|QDkdTnTc!UdRU zJ9ABy=J3cA-%R4qp_AaJzriM{9_5 zMZcuWM(Hq=JmY*M$4&#t_+tkUAtbMq4099KK!v$oXXC((AuzcIH~ zHrb`sbXOn2Fu9QdT>Xn*o3NPT2V6)_{2}1Wro}lRCA<84ev6k4_x%ok@Mkriza*GE&ePJy*0{skY5WLH&1+o(VFDH{9Ue7U8O|GfWn{!R;??$X}#iN1h%5@)zPD{d4^ezVhBa;65pnZTMex+W%Kh!D)TIvflTR$pgEcipy+?ixbZ zM+LWT+{G_(>33OhC&tay>21sRs>$d&kr~H_QE=dnc2DPd*5KU0$-rj={qgn%oviEn zj{N~2sxkzXE{jkhm=WQ~4zqO3ZtV=|=}s(PSLzlW+&va_uq8d|$U)re6s_7CNNX?q zYvRaMlr(HTlMSSEvwiAV?QP8KxPrV-I|L{zYGSfac>UZ~M9ZpFJQd0mMd__RyRfJM z%wykMFh?Bf9h(1;o?H4pD`v9}KUdqtyES{sLRZ8n?Gm>q-9H!t&Nim?txBpRuai#> zoy^ZXri&vAzp%?sQ!4f)A9SuMgwwFC?=X1tiufxF!1%~~%X(2S^mb9wp)G36H+Gu8 zTUrye8*wn}Y&T5I`M!i_1~ac(dgR`a<`jBw!c8I~ar46P*E73WAt`wxqUaI6fL z?W;eaiT&z68i_%A2=5DhBj2)({+jB048QlrGzZFG*kM0YQ^?9ObAFS*{X|>iM{#i= zF$Ct90wDHSxv;Y)U8;i&QQjsSyX+R_IA2GFPkydp&I75m7K@QzI!}HqO1%8tJGy_W zJG-IaMvbN;W1{j`fKCjuQ9E!jH=y0n77Psb_q(ht%v4iCA0B8uA!F_*A<#b(9tB{` zze@*jCL>dl4?_j0(Ul*JYMAN?o=Hq4@K{D3Rc|sT=4pV+UAKjH9PfnDt~BrpFG__u zyBEZL29D$kj^g2C**B3N6jOnAdt_P;E4D5PNT>JG6v3u|(Pre3Hrst6JKrz|ib*v~ z2$0cw*>dIqx7>4hh~SPEgB%BSJ~4q_ezz&{WInJTI!OIEieZ1UkDmm*y_YGtLR&9J z$uzD`{W=-R;1n-0_%o zVME6e0Wst>vg@uQ&m>0Wzp{bo@GVUGQSa!zc~(|cZhFz{bnlVOYCDy64;*A%_Qyv( zkgWcB9MQ2wQvkSvb-Zae@!I=$YodUuM-&2ve_Lun(9(Hku$wLOmV}aKY zcr9c5NGD8o7EdHaH9d+7)7i(8k%wKi3| z_;tp;pRg^8znau{VPqxcg(%-SLG(m6GRgaX>1=9PLV`S@Z$UCP5KlBIpm$dEj=b{^ z6c&-Zi=h-XUoZ(H2@DNm6K6UfX2`e2s8b?MiN&ziTQxJ~F#Cxz^iR~B7}vh02l$(t zzc&koC8nrkIez9m<^L>XL0qg9(KN|QbLpIn?-ISph3+gD7PTlZgSbLi(MOZgUY)e6 z|2ma@o_Td#YzRVu!LW78rgZW)6%d_dc13Otsw1gFl$xwIZsyVIoo2jkA5VIeE+o~y z<*8aTMk#Tr1ZiM49DqMZ5efrSZY35%Q%K{gi2osXEdGLtO_I+ZxLNo)tCUhbYmvI9z!iMeP0x&a-5B;$VP#Ydij27bx@7DK{%+Y(OCQN;xb1}9bh&~=G5h}y`kzX{G?7y9 z!mLto+UG{3Wz1sl*Bx4S-}@3XZRcuBc~thmF~=G=y``RaWAAnTt}XSU-As=EvJiWJ zsRtfxgGK{Kb4K}dX=Kcc%uF)Ue5uUR9*Iqm2wiELHPa{#RwN^%RQQE3iS9=#1>;8Y zI;1dlE((>a0n=}%=2$y6j0Cx`WMC+%MTpS9{1Rgb_nXNiSiXdV7?n^^25D3+g6)78xDERXn?r)D()DP zMp)*bWicy(u^VzQgJMx>SIn5fZIBhqTy7Mt6^0W zj3W*=aBOLiYbU9n$puG~#iq*!g6%un%%=UcsxyqxI$eTPAw5*8@MDr%1a76v9JcPN z<7nIrzo_FhcAld7LooBf0#f! diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.xcf b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.xcf index 3182f633b7e8dd318147176c666ef86ab1156cab..cbb5a84e4b0545bf1529bc4c8b29b40395524bb1 100644 GIT binary patch delta 8031 zcmcIp3wTt;6}~f@&F&`I-E2bMfe#kNIje`e)j%&~iedHCADwLt*-_6=qc`Y+J9e z{pSiheygy{pA{A?R@nVbg*^`|EIhC9_LT~KznH0Be))mIzDE_hGZpp^D|~RM!l92V z{OwZ;N9YP4`AFfINeai`tMIWuD*Rp4kn$?ke$q?m)20kj9n;=WIODiN(M{pprxm^w z_3Y*8s{P6wg|E(6_}VswZ$uTWdRMjAG%DQCTj8d^DBQA7qEFL4u2vn}4=LOcU4dP7 zs=X&y;l9oa4=z>sWt_sVM=3nILE-WC3cnq%ux_=&Q_+x~8Kl~0p8?8MIePO77FX65=yednJl->Y0z8Qw{L zbCG{Oz$OVtd9NgPn#NuF6;m&E-kQmccEK`Iea24BM25!7Y?`4gK{J-cRcq zS@3SaW5)YMZNmnD3C)OR*wCnzmBpfcUfZDIhnE>aoRKo}DJzRX*I5u{WyH!^8o?OK zm>lY(X-`RB!;ch`692m+Py5kq^<9gxS7F-sjQ>BjO8q~{!d|7VzAIKbPjhK3f+UC} z0FeL@Bm!X^5Ozk82!!Tnzm!2HM9yjv4L^}cED>j^g(i|A(xhR?MM=gGc}BjHe8fOuljYhvz^1nOs^eTg$aq}UW#>^si8rm3l z_+RMvnD%gP%b;FcH|n+Z*9XUK;@puW+FLU-9XB=a1z>kPNviEA);-o_bN7tFE%-#d z%O^(lWjy%<9J(@Q=nGPc4LtiZQk-2+irdEP85xHdZ&ydXIab+g$;pe(A=+g>p}&*W zlk?oqNg($e4eQ|0bK2E&o);@}FJva=-K^xhVDHF(U7kXBathw^9;6Po~?1E)~I}<*0fcV&4@QqeAJ=88wulLA?AwLjA5>sUA%<33>tT_Fn2*QIEkh( z6oca~C=Nqu2u~P_T~Lf(C=T02X-BDeV@FaPg5r`m7Zj5`6qjhS83`wfj@R|?Mv5b( z*m;FwXH;>76gyiecG|^?>r$9qY`ab>%E==|$p5G!Cya_*R^&|7C+BrxKEKAQ2{MYZA|P>hz+6wei8i(q>Cdm^x8CUZBUP zJ&$7%zW5#GzM)V*m@(JS!A!%H&T0Ues zd~?Ak`GoO=F8L-UD2nh6xngj_H)kZ`gl{rKo$$?x0_TKpGAo_%4Q&pdCa0kp+WnUs zQRiInMLOvOVh}@Ri$tQnfg|6*F(>+{>P3A6N4|mMPLnV@I~BC>%?aOR0d4k;)VJ`> z3Ev{{O_V$9eZ?w$suNTOR>!H-t2V2YLz~hI*?AdZrA#ZCX2={$DVa$!wLH)(v&b9G zCXZ2ztB%zo)fVKLd~5Pln?3OmfRUaA&8PC8Ha=$StHBv0KAhScpSY|>vnh_z`jI|0~t@{EbxG^Q%IOI&++7 zi}P!E*L6g7-A`24lVVZlU%gxKIupqc1w~OeH}A2T1bY031bUp+*LTb0qW8l=@$9XI z;;mckyjKGxvRE<+-0Biri~8u@d#+?+&?qV7=0$NdMbXblqNoTu`sn=%M=_D~XiyXv zx%nO2N#c&LN#agT-&*tm69>lzMdqDu-g^Y9(Hj&Wv@aC3{p`Ht7LqFQkW|Td zz2L6loZr2Jj=sAusDtgnUq*3Y^U*h;qv{zHz4ks}(~p+an|&q7Z{+7y?-%SllwpSQ z9g&q5JAhFe`9N*#TWVuxQ(Ns4izk9zB=?Ki(^QR3r1pzd6W1R|lr~(`9)S&E=*Iqu z$O?)4XViub)W-DGh7HuFouOGm5$qhfTg;&*KQ@lqB3A5K+9Rl8R3!&!u;-fg2<(wn z4V91Xa`Nz|HtdmA&IMJ}hCS4V6_Bw+BG^HAGil~XlPh8rH`HW^>mS%DM!gUevw!2} zgMUw<9{eJOdhlCf{3AvBzz5eevFtBFv1Evw51T;}!9%_}e5ge2ad=Z__x76S+qN;$IKD`N$86ANd9GBhTnVMl>+-%!@&BY?Pai-bL)_ zT4EoK)yF@A-8Ll{6iXj<^Rcst9s3rsV?Po@Mil8|#yrKujQK(FhjDIR`Y=h9P9llY zx%$O%$z04`7!+@mx%q_Y#7`eCk;SJS*}X^6Lq zhIs3m_ehEu=e3Icp&$mi`QvhvXYwc1E`P$M&nh3v`NXNTM*j3KoKCcX>Jouo7z9EySUYRQ%`g2#2UqPecHF*n^AN%B~ z^iXx=Ok!O{u71z+DNLMtKPVbsaPz6ki9Tt{ja>9v6BNCt zxtU+A*p$Wndx`Yd>YJy5{L}iNm@>o7P?HU9#DsDapOsAlv%2bWGrMx}>4!nFceb0) z=}&Xd8AI%x$@=}`1}>7e1Vz?dHxH=uBB0KTz!v@GxyPAE|5$3iRSbD4kPyENzM*H%ui*<8N{%fMEBd7I1-tYmFV`}Ww<9QSdd1Bbsf*nrb+KDir7wS_ zP7YkWxQ2(8)1;woG->Fds_XBEI*2j5gW{G~3&q>7+4*0Okkso&l6t+ZUjN!ZIbU*; z>iV1QRMlQJFN&`>*Y!7xRnPMM3RfoS*-IA2`X>LM`W#J;A1HfNCR;6+Nb^?9EcR#f z8FFp4yT!n3s`;&tb9}FMi~Y-o`fz(`_0+neHu3gL#x-EX7?9p~_wOnG|{Efa= z>MZVf&*&F=~^WZw?W= zc|Eb4KhwY5ghDv+8(eO;xcSzviT!&Fv479jU0YEIx6}s3J0F*@S|Yc_5xK2{p8pBR zq`IJ3xxIv)BJv-JME>LFdXGstr}v;bR`sRoSXHhj zJUBaw3!AHB)yt~q^IZxLOcl%ajWqC5o1RqVU`n_qk=Wn{0@ra$%XDa=S;d?Mk%ALUyZ1J#?;Cemw8GAsUHMu>$6 z2k=AcbL5cv965AG%sSptFFusR0%>N3v+=N-f7O=U{HiCp`PD!YS^Q-V!!#Ses^Lc_ z5`Sb4@kjm^=we~n`suG-EU-NRbG(1FgzY1dW2Z>un*=3t@3D?7aGf0@iO1c%whPJB zmXJ*CNPX7vZY=Pa1N5+O-TcHPqEE~t`oz0xiVNSSvA_q(kXc&i<|kF+o>Yl@vMF#| zBI~H%ebT`K##G2O)VulVG@9ph0nKyTtz_n(YQqA*PKQj>XN8Vh6`1DV4WnsD!!tCb zVgBWesBW+Zrevy7V(nQwKew1f&#fiVb9>b6dFL)LB&qyc`Nj4$D~m0P;$6*Yaj~!J z(bRuwvY77T@e5&Q({H+%%mBrW1jCw!o0v_;FEA*U4dAA6ffZJk$xY8gWr~5BUa8m@ z%WlUA`~@cvSZ-z|Y?BhP{9B1w8Y&PX5}CX{5HQ6vH&4h?G6_ADOu~SQ7vfnTISsyC z10$`Fu}xGmHW_KCvQelzRV3J0x)eO#D-c*?hrUWBm-vm6bHr325H~|4Fu}oUcyd%% za#UCH09vMsWl1bi&NFj9DJ%@kXv6G0Wwe?tMJ_+Irpyn(!R(3?ZCHww#x4&mNQHT6 zE0kc`r%EvGaC43rSm3sFNZaI|4;)R0iA_p2Q~vD-lV;vrfj|DVV@4Z-U=ek_W(3-1 YVRf^+DY@){N-lehG&MW0E{mP|FZ=9X_W%F@ delta 8441 zcmcIp3w)DRmjCWe(j>(YT3VnKgo;qfr$9vqgi=tkh+lQoUuJ*GLtsG>HKGKcyG|Tm zh>#idG9)-^l@yeD%6u6MI4BAu4lZjEQCTy{YY+x`gQ6|X{?EBz16{#ccd@@;dv4A- z_q^^o_ney^T<-qkGWVQf@zbX}#Ke)O=k1C8m%%@tW)1yaG(4+Z!=hU??6_0I&VCKM z9M-VAN5eip(Xiq!4KKQ1!vSdx2mMvUA&+Y~Y@CL%%b(JV>SY>Uxm!c)Q4Mc+Ps7pM zHN0t;hW}co;m!Ruocx7`x2@7JvPZ+aJ8Bpmq2WDSHGFaq!ZK>i#1$Sui;Y1(?1vK&u@;>@a+W}{$;<0?{WlVhVfpbM!YXH z{J^K-hXXbIxLU()pK18_p&EYvtcJUfYWRh71p8jnpAR^S4iDC!k3Om4S4%bgrVtQ& zgeSoW;XR^ZevO7_)oB>ihKYi!_2>3U4U2bZ*r|_(okugoA63w{z5TJ*C8YZh)}5uN ztvXoNL3(=G?ffM|NOkQeN_8LYR?G4&={=Wuyu+BsdxJfw%|s;AL zo*LY1NY88}V90P=aO7hpqJsX0+ZoMk3_>(TjYuS*=JmR|Cv=-0Lzp5Z%r=H6Ee)S3 zYlI0aOp%s=SU*$Vu^UvI_)S558tP4`uaPFyr}H4ftNN5fy_u&TE{A#(>Qhi(laG~1 z3;LUa`Wk}}O=-h41M1WAtI2iKqk5mmu4|=PX~OjoT!$f&bcP(=S?CV6(hUmfj-ID= z|K&VKcQ&Ux#JaO5bcaZ{-Mx1|5qku2_ZuQZ5v4Q08Zi@ysVfsOTv0j=FM<^gN8wMz zV|X$MQB?98K@E#&zTv@vc{6law35Kes2^C^%z}MlEKY50Vh3?mV_V~ z0XR-xWTTSSVOSX{!|x47%s_x}79vh(PA7#mPF3L4U2y~`P04`(rBkUiR3MK$amt|> zB1B1*MpC6A8|UhcBSL9fNnm9fR?x|^WFO}hB1GBb=;Cz>0W#rl+|iBX6lQapP${5N z2#`Y-1eq+-KBFsg${(8HkEW zUSv@YSf^m6i3ph|MaZPgbgV?~afHC@3ONx9WwRkCLR4j;mI#GJR)m}gan^H$fR!O9 zLM)jhL^(}PJK@t&ct=%$KVaN z@EKx*-p=uMKAp&FN_3<{m-}WeOPIt!>+I1(+4E1&gGfc6i$Az(N11zqpQ`QZ|tjz`qc?v zZnC(x!jgTbb4TtwhdXlLS5oUMBv>kTCe)OREO}v^$rmnW@`Z1y^%W!Rii;Ns;Y;*w zBNA%r083u1nCap_Fw@0r>;nTjlaL82p|)FI7pW|#i>urF4P!p3oDc-BCX(In%_WFxquP?0hsb^An}dLrB~GXhnI zx&?>Gc))S;?xsjIf-NM@ixMXiL}HN9IIJ0mj6>nNAtpxqsm;+ zAQHC^om__bCW(5fD`PED=6UFiSsnnY3^+r%8|N;7BBO!G70;S*1_ddR^xW!DrXG`f zTRaADsBXa`;!x0Pdy|+{128H}2m08@71iP~oNm}``%_a!M#8zkdG7PcN zSi|TL8_f;0N-e+f1GThYQk^^6k~e+S`8=vrHBYXxw~u~PsP+AmYS2xV9CMsG z#+ES0*b3(O`ljCs_3@9AYRCjjj;Du8XF0wLbBw>peq%yMsqzOURb-MSC-!6N#2Thf zoMi8t^p#Luha}ZQlP!76Fs9xzhN-tqx0@#~66&*|NmY59C2!3#bxJ8yr}S6*CRN#u zw>>D7eOXckB9^?pfjMsff;sMR+dq%AmulM;Np;Cxmb|lxsZ%>Kb!tEC?__^)SF=zB zBa`aRYbpy~*QM6-cbdr?rj6hY)5huYK0ZC5EQ>d&&G!W5^qZM$`p=ka`h2^`yDQp~kW=K3O;lBjd)wLjXXF(>j4GjVnR+)M=F#JksG1)e zi+S@D6imT_Mrh2jKQJ}c+NAHHI1eMoalC~9qi_aqEI=d7CVO#T3AhRvZ8AWl1rSX1 z;Zj5GV#0PsMKuKigSm@F^nc=R%$R|}8lgn737#APF}WT$)2jSu9LjG~FfI!kwlVRZ zV&9ph##)>7JwzjP@#A<~0jA+hnxTdok_%;P3g&7-Q#nRs4&@I=js2fRBXp({$`G8vBi9=` z&eJ?iU3i@6P=*l7PzVUTm9;;J8+8;4Wk{Sufxr;vqN)GX?%HLK)e4WU<5iCj!K;K4 z84;p_qL(0Y{D;7}sqCN$j-mX*^p?$_#4h0)qoP9*xd5HAqDni3HCLib)1XYHv+xPF z9=QYSDTnEmrfFv!1MA~Xh9l!s^v;aqC@$f&raVX9x&WO_rsO__HEcaji?Vgb3~hag zvXjz=UrgMg4ARscQGQ+rIb70-*1COr4!(>g@lpcg8_oI6kRTOpo zejzV*$|l^ZquE$fiLwzg6PHO$Fv^tl@iNWB9p`O!nADw=( zPN(e$5X#eawHSSGdHR0n+)>o8bnE{fefEE~ zxBAS8RuBAm}EjoXdy0+yCrpI+UmFhX}`aXgvc|4yB$d z{y(#W@}|cY)0^sBCaJQ=OukhYr3ZM_jG0Mw&vHvH+sb#wvg3SbEHAddT#kEl9j?>Y zS6FgIIa60$&eRp7?aDVmZ9gZe)S5~)kC?b>pZ)%7T&xS{(RNF|qn|Tt^mArSf4k^iT$#U_pH%bL)(8*FU0cRm*Ir_G zehC$1YN!!~Ol;`G#D;3Sd_8W`w-+SUs~ar2 zp$k(t3}ottYjKm73Ds0b)JoOsqoCaQFU+xV8gp!X%D(+0+@hb1<6HETS^D$i;qS52l1TD?a+*BY@D?ohWv$umM5$O$VU$`h*ud zh-$(%=M%B2?b{Bizb(T%bcZFkf5l$zXwP2mFztOiE)%N9illmXrzLmlUb|EG+MQ3R zeLH&CcYNMWs3|Lxs>g0i?)n|?-}P7CziVq^zh88*SMD~2dTmuwJ-Vkx1ejw_Z|2x@ zspjbZMGv7G-$|-Z_gZqVemU;dFUP&}SxszTp-^INQuRJy$^AA9+5bKZ+5b5UQ7dPQR!TZq4BD zt{MCT>v2$En6)dJc&80Sv>Bs0+T5=>+RUjRah4b^)SiDN6Fu63Bd|V>&``2m0SILei1` zIgF5W?3K%z*E$Jg!Gm8W6I)6}W#aE8qMaD3xl2ZC?vkjg_%NI3U5aW;A7e&KmeOno Sk)<@;L1gK#>ycRP#D4>tK;n@A From 1ad0a41786a8fba804a9c38742900f10fbf021e7 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 5 Jul 2023 17:07:59 +0700 Subject: [PATCH 0684/1199] oh my god --- .../kotlin/ru/dbotthepony/mc/otm/core/math/Decimal.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 267509fb1..e91bc36a9 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 @@ -142,9 +142,9 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe operator fun times(other: Decimal): Decimal { if (other.mag.signum() == 0) { return ZERO - } else if (other.mag == BigInteger.ONE) { + } else if (other == ONE) { return this - } else if (other.mag == BI_MINUS_ONE) { + } else if (other == MINUS_ONE) { return Decimal(-mag, null) } @@ -161,9 +161,9 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe operator fun div(other: Decimal): Decimal { if (other.mag.signum() == 0) { throw ArithmeticException("Attempt to divide $this by zero") - } else if (other.mag == BigInteger.ONE) { + } else if (other == ONE) { return this - } else if (other.mag == BI_MINUS_ONE) { + } else if (other == MINUS_ONE) { return Decimal(-mag, null) } From 90dc9060cf7e0e6d4a0dbab2bb9458cda2974c2c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 5 Jul 2023 17:45:09 +0700 Subject: [PATCH 0685/1199] Add missing close buttons --- .../mc/otm/client/screen/decorative/CargoCrateScreen.kt | 4 ++++ .../mc/otm/client/screen/decorative/HoloSignScreen.kt | 3 +++ .../otm/client/screen/decorative/MinecartCargoCrateScreen.kt | 4 ++++ .../mc/otm/client/screen/matter/MatterPanelScreen.kt | 3 +++ .../mc/otm/client/screen/storage/DriveViewerScreen.kt | 4 +++- .../mc/otm/client/screen/storage/ItemMonitorScreen.kt | 3 +++ .../mc/otm/client/screen/storage/StorageBusScreen.kt | 2 +- .../mc/otm/client/screen/storage/StorageExporterScreen.kt | 2 +- .../mc/otm/client/screen/storage/StorageImporterScreen.kt | 2 +- .../otm/client/screen/storage/StoragePowerSupplierScreen.kt | 3 +++ .../mc/otm/client/screen/tech/AndroidStationScreen.kt | 3 +++ .../mc/otm/client/screen/tech/EnergyServoScreen.kt | 3 +++ .../mc/otm/client/screen/tech/EssenceStorageScreen.kt | 3 +++ 13 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt index a3febd6c8..bd81403cf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt @@ -12,6 +12,10 @@ import ru.dbotthepony.mc.otm.menu.decorative.CargoCrateMenu class CargoCrateScreen(menu: CargoCrateMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { override fun makeMainFrame(): FramePanel> { val frame = FramePanel(this, null, 0f, 0f, INVENTORY_FRAME_WIDTH, 22f + 4f + 6f * 18f, getTitle()) + + frame.makeCloseButton() + frame.onClose { onClose() } + val grid = GridPanel(this, frame, 8f, 18f, 9f * 18f, 6f * 18f, 9, 6) for (slot in menu.storageSlots) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt index 217ec4f57..059286d25 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt @@ -16,6 +16,9 @@ class HoloSignScreen(menu: HoloSignMenu, inventory: Inventory, title: Component) override fun makeMainFrame(): FramePanel> { val frame = FramePanel(this, null, 0f, 0f, 200f, 200f, getTitle()) + frame.makeCloseButton() + frame.onClose { onClose() } + val input = NetworkedStringInputPanel(this, frame, backend = menu.text) input.dock = Dock.FILL input.multiLine = true diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/MinecartCargoCrateScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/MinecartCargoCrateScreen.kt index 5e938ac69..c274f233a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/MinecartCargoCrateScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/MinecartCargoCrateScreen.kt @@ -11,6 +11,10 @@ import ru.dbotthepony.mc.otm.menu.decorative.MinecartCargoCrateMenu class MinecartCargoCrateScreen(menu: MinecartCargoCrateMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { override fun makeMainFrame(): FramePanel> { val frame = FramePanel(this, null, 0f, 0f, INVENTORY_FRAME_WIDTH, 22f + 4f + 6f * 18f, getTitle()) + + frame.makeCloseButton() + frame.onClose { onClose() } + val grid = GridPanel(this, frame, 8f, 18f, 9f * 18f, 6f * 18f, 9, 6) for (slot in menu.storageSlots) 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 9f16c5b60..38bc40dcb 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 @@ -49,6 +49,9 @@ class MatterPanelScreen( val frame = FramePanel.padded(this, null, GRID_WIDTH * AbstractSlotPanel.SIZE + ScrollBarConstants.WIDTH + 4f, GRID_HEIGHT * AbstractSlotPanel.SIZE + 2f, title) frame.dockPadding = frame.dockPadding.copy(top = frame.dockPadding.top + 2f) + frame.makeCloseButton() + frame.onClose { onClose() } + val controls = DeviceControls(this, frame) LargeBooleanRectangleButtonPanel(this, controls, 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 4f34c313b..f08354adb 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 @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.client.screen.storage -import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory @@ -28,6 +27,9 @@ class DriveViewerScreen(menu: DriveViewerMenu, inventory: Inventory, title: Comp override fun makeMainFrame(): FramePanel> { val frame = FramePanel(this, null, 0f, 0f, FRAME_WIDTH, FRAME_HEIGHT, getTitle()) + frame.makeCloseButton() + frame.onClose { onClose() } + val views = ArrayList>() val settings = ArrayList>() 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 e66f2b2fd..965518f7c 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 @@ -42,6 +42,9 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp override fun makeMainFrame(): FramePanel> { val frame = FramePanel(this@ItemMonitorScreen, null, 0f, 0f, 1f, 1f, getTitle()) + frame.makeCloseButton() + frame.onClose { onClose() } + val topPanel = EditablePanel(this, frame) topPanel.height = ITEM_GRID_HEIGHT * 18f topPanel.dock = Dock.TOP diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt index 71e3497d2..17eddc453 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt @@ -15,7 +15,7 @@ import ru.dbotthepony.mc.otm.menu.storage.StorageBusMenu class StorageBusScreen(menu: StorageBusMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { - override fun makeMainFrame(): FramePanel> { + override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! WidePowerGaugePanel(this, frame, menu.energyWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt index 8299b3879..6b4b7dbdc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt @@ -15,7 +15,7 @@ import ru.dbotthepony.mc.otm.menu.storage.StorageExporterMenu class StorageExporterScreen(menu: StorageExporterMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { - override fun makeMainFrame(): FramePanel> { + override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! WidePowerGaugePanel(this, frame, menu.energyWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt index 97ad88d5e..ecbb2f538 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt @@ -15,7 +15,7 @@ import ru.dbotthepony.mc.otm.menu.storage.StorageImporterMenu class StorageImporterScreen(menu: StorageImporterMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { - override fun makeMainFrame(): FramePanel> { + override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! WidePowerGaugePanel(this, frame, menu.energyWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt index 69a5f9cf3..f9eb3e7ce 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt @@ -18,6 +18,9 @@ class StoragePowerSupplierScreen(menu: StoragePowerSupplierMenu, inventory: Inve override fun makeMainFrame(): FramePanel> { val frame = FramePanel(this, width = 200f, height = 60f, title) + frame.makeCloseButton() + frame.onClose { onClose() } + HorizontalPowerGaugePanel(this, frame, menu.energyWidget).also { it.dock = Dock.BOTTOM it.dockResize = DockResizeMode.NONE 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 16d955ba2..a937153ab 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 @@ -656,6 +656,9 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I override fun makeMainFrame(): FramePanel { val frame = FramePanel(this, 200f, 108f, title) + frame.makeCloseButton() + frame.onClose { onClose() } + object : Label(this@AndroidStationScreen, frame, height = 11f, shadow = true) { init { dock = Dock.BOTTOM diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt index 1a353dc7f..e6a65370d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt @@ -25,6 +25,9 @@ class EnergyServoScreen(menu: EnergyServoMenu, inventory: Inventory, title: Comp width = AbstractSlotPanel.SIZE * 2f + HorizontalPowerGaugePanel.GAUGE_BACKGROUND_TALL.width + 8f + ProgressGaugePanel.GAUGE_BACKGROUND.width * 2f, AbstractSlotPanel.SIZE + PlayerEquipmentPanel.HEIGHT + 4f, title) + frame.makeCloseButton() + frame.onClose { onClose() } + val equipment = PlayerEquipmentPanel(this, frame, armorSlots = menu.equipment.armorSlots) equipment.dock = Dock.FILL equipment.dockResize = DockResizeMode.NONE diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt index f8e45312c..2ae976f46 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt @@ -34,6 +34,9 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title override fun makeMainFrame(): FramePanel> { val frame = FramePanel.padded(this, width = DEFAULT_FRAME_WIDTH, height = 18f * 2f + 36f + 25f, title) + frame.makeCloseButton() + frame.onClose { onClose() } + val inputs = HorizontalStripPanel(this, frame, height = 18f) inputs.dock = Dock.TOP inputs.dockMargin = DockProperty(bottom = 3f, top = 3f) From 5d69275fd4f28697a5bfdf8773073261dc69949e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 5 Jul 2023 17:57:08 +0700 Subject: [PATCH 0686/1199] Fix speed upgrade not actually working --- src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt index 7a595a8cd..8459f1ea7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt @@ -316,7 +316,7 @@ abstract class MachineJobEventLoop : INBTSerializable Date: Wed, 5 Jul 2023 18:02:51 +0700 Subject: [PATCH 0687/1199] Fix energy consumption upgrade not showing its value --- .../kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt index 67040f3b0..cc4c30bb3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt @@ -75,6 +75,9 @@ interface IMatteryUpgrade { companion object : IMatteryUpgrade } +private val positiveBound = Decimal("0.01") +private val negativeBound = Decimal("-0.01") + fun IMatteryUpgrade.addUpgradeTooltipLines(tooltips: MutableCollection) { if (upgradeTypes.isNotEmpty() && ShiftPressedCond.asBoolean) { tooltips.add(TranslatableComponent("otm.gui.upgrade_type.list").withStyle(ChatFormatting.GRAY)) @@ -104,9 +107,9 @@ fun IMatteryUpgrade.addUpgradeTooltipLines(tooltips: MutableCollection Decimal.ONE) { + if (energyConsumed >= positiveBound) { tooltips.add(TranslatableComponent("otm.gui.upgrade.energy_consumed", TextComponent("+" + (energyConsumed.coerceIn(MachinesConfig.Upgrades.MIN_ENERGY, MachinesConfig.Upgrades.MAX_ENERGY) * 100).toString(0)).withStyle(ChatFormatting.DARK_RED)).withStyle(ChatFormatting.GRAY)) - } else if (energyConsumed < Decimal.MINUS_ONE) { + } else if (energyConsumed <= negativeBound) { tooltips.add(TranslatableComponent("otm.gui.upgrade.energy_consumed", TextComponent((energyConsumed.coerceIn(MachinesConfig.Upgrades.MIN_ENERGY, MachinesConfig.Upgrades.MAX_ENERGY) * 100).toString(0)).withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY)) } From 6d409f29f6bd0e7069228b20e2dacc8b2d693d3c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 5 Jul 2023 18:03:05 +0700 Subject: [PATCH 0688/1199] Useless bounds --- src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt index 8459f1ea7..e6517b2df 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt @@ -312,7 +312,7 @@ abstract class MachineJobEventLoop : INBTSerializable Date: Wed, 5 Jul 2023 18:08:32 +0700 Subject: [PATCH 0689/1199] Fix unexpected quickmove order for upgrade slots --- src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 24429784e..702258b2e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -770,14 +770,13 @@ abstract class MatteryMenu @JvmOverloads protected constructor( object : MatterySlot(syncContainer, it) { init { mapQuickMoveToInventory(this) - addStorageSlot(this, prepend = true, condition = { isOpen }) } override fun mayPlace(itemStack: ItemStack): Boolean { return super.mayPlace(itemStack) && itemStack.getCapability(MatteryCapability.UPGRADE).map { it.upgradeTypes.any { allowedTypes[it]!!.boolean } }.orElse(false) } } - }, + }.also { for (i in it.indices.reversed()) addStorageSlot(it[i], prepend = true, condition = { isOpen }) }, allowedTypes = ConditionalEnumSet(allowedTypes), openState = GetterSetter.of({ isOpen }, { input.input(it); isOpen = it }), From 87d29f0c4bbaa22c9ccaa2bac8ee09b6dd024fef Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 5 Jul 2023 21:19:31 +0700 Subject: [PATCH 0690/1199] Blackhole "destroy blocks" config entry --- .../mc/otm/block/entity/blackhole/BlackHoleBlockEntity.kt | 2 +- src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) 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 a838aed26..91d485cc1 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 @@ -278,7 +278,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery this.mass += HAWKING_MASS_LOSE_STEP } - if (gravitationStrength > 0.4) { + if (ServerConfig.Blackhole.DESTROY_BLOCKS && gravitationStrength > 0.4) { val sphere = getSphericalBlockPositions((gravitationStrength * 12.0).roundToInt()) if (sphere.size != lastSphereSizeOuter) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt index 03d7d1c0e..f9e2c87dd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt @@ -51,6 +51,10 @@ object ServerConfig : AbstractConfig("misc") { val BOSS_FORCE_MULTIPLIER: Double by builder .comment("Percentage of gravity force experienced by bosses (forge:bosses tag) from Singularities") .defineInRange("BOSS_FORCE_MULTIPLIER", 0.4, 0.0, Float.MAX_VALUE.toDouble()) + + val DESTROY_BLOCKS: Boolean by builder + .comment("Whenever singularities should destroy blocks") + .define("DESTROY_BLOCKS", true) } init { From 296476e1d89d3a994576a2fca7541dd487a755ff Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 6 Jul 2023 00:35:32 +0700 Subject: [PATCH 0691/1199] Update singularity formulas, make getEllipsoidBlockPositions return iterator --- .../entity/blackhole/BlackHoleBlockEntity.kt | 27 ++-- .../mc/otm/core/collect/StreamyIterator.kt | 132 ++++++++++++------ .../mc/otm/core/math/EuclidMath.kt | 68 +++------ 3 files changed, 115 insertions(+), 112 deletions(-) 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 91d485cc1..5041fc5e5 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 @@ -71,8 +71,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery var spinDirection by synchronizer.bool().property - private var lastSphereSizeOuter = 0 - private var sphereIndexOuter = 0 + private var sphereIterator: Iterator? = null private var sleepTicks = 4 private val stabilizers = ObjectArraySet(6) @@ -182,7 +181,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery private fun setDeltaMovement(living: Entity, center: Vec3, distance: Double) { //final double mult = Math.min(2, (30 * this.gravitation_strength) / Math.max(1, Math.pow(distance, 2))); // Сила притяжения - var mult = (1 - distance / (30 * gravitationStrength)).coerceAtLeast(0.0).pow(2.0) * gravitationStrength / 8 + var mult = (1 - distance / (30 * gravitationStrength)).coerceAtLeast(0.0).pow(3.0) * gravitationStrength / 16 if (living is Player) { mult *= ServerConfig.Blackhole.PLAYER_FORCE_MULTIPLIER @@ -279,29 +278,23 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery } if (ServerConfig.Blackhole.DESTROY_BLOCKS && gravitationStrength > 0.4) { - val sphere = getSphericalBlockPositions((gravitationStrength * 12.0).roundToInt()) + var sphereIterator = sphereIterator - if (sphere.size != lastSphereSizeOuter) { - lastSphereSizeOuter = sphere.size - sphereIndexOuter = 0 + if (sphereIterator == null || !sphereIterator.hasNext()) { + sphereIterator = getSphericalBlockPositions((gravitationStrength * 18.0).roundToInt()) + this.sphereIterator = sphereIterator } var iterations = 0 - while (iterations < ITERATIONS) { + while (iterations < ITERATIONS && sphereIterator!!.hasNext()) { iterations++ - val pos = sphere[sphereIndexOuter] + blockPos - sphereIndexOuter = (sphereIndexOuter + 1) % lastSphereSizeOuter - - if (sphereIndexOuter == 0 && lastSphereSizeOuter <= ITERATIONS) - break - + val pos = sphereIterator.next() + blockPos val getBlock = level.getBlockState(pos) if (!getBlock.isAir && getBlock.block !is BlackHoleBlock) { val speed = getBlock.getDestroySpeed(level, pos) - val eResist = getBlock.getExplosionResistance(level, pos) var strengthLinear = sqrt(blockPos.distSqr(pos)) @@ -309,7 +302,9 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery strengthLinear *= 1.0 + 8.0 * (gravitationStrength - strengthLinear) / gravitationStrength } - if (speed >= 0f && (speed * 2f).coerceAtLeast(eResist / 3f) < gravitationStrength * (12.0 / strengthLinear)) { + val blockStrength = (speed * 4f).coerceAtLeast(eResist) + + if (speed >= 0f && blockStrength.pow(0.5f).toDouble() < gravitationStrength * (12.0 / strengthLinear)) { level.gracefulBlockBreak(pos, getBlock) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt index d0d195ba1..ddd5193d7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt @@ -5,6 +5,15 @@ import java.util.function.BinaryOperator import java.util.function.Predicate import java.util.stream.Collector +// Purpose of Stream API over Iterators is that it is simple enough for JIT to inline most of it, +// unlike actual Streams. + +// We lose only one (actual) element of Stream API here: ability to parallelize work, +// except it doesn't (properly) work in Minecraft (Forge) either, due to classloader bug: +// https://github.com/MinecraftForge/EventBus/issues/44 + +// Aside parallel work, unimplemented Stream API elements can be easily implemented when required + class FilteredIterator(private val parent: Iterator, private val predicate: Predicate) : Iterator { private var foundValue: Any? = Companion @@ -58,9 +67,73 @@ class MappingIterator(private val parent: Iterator, private val transfo } } +class FlatMappingIterator(private val parent: Iterator, private val transform: (T) -> Iterator) : Iterator { + private var current: Iterator? = null + + override fun hasNext(): Boolean { + while (current?.hasNext() != true && parent.hasNext()) { + current = transform.invoke(parent.next()) + } + + return current?.hasNext() == true + } + + override fun next(): R { + if (!hasNext()) + throw NoSuchElementException() + + return current!!.next() + } +} + +class LimitingIterator(val parent: Iterator, val limit: Long) : Iterator { + init { + require(limit > 0) { "Invalid limit $limit" } + } + + private var found = 0L + + override fun hasNext(): Boolean { + return found < limit && parent.hasNext() + } + + override fun next(): T { + if (found >= limit) + throw NoSuchElementException() + + return parent.next() + } +} + +class SkippingIterator(val parent: Iterator, skip: Long) : Iterator { + init { + require(skip >= 0) { "Invalid skip amount $skip" } + } + + private var found = skip + + override fun hasNext(): Boolean { + while (parent.hasNext() && found > 0L) { + found-- + parent.next() + } + + return parent.hasNext() + } + + override fun next(): T { + if (!hasNext()) + throw NoSuchElementException() + + return parent.next() + } +} + fun Iterator.filter(condition: Predicate): Iterator = FilteredIterator(this, condition) fun Iterator.map(mapper: (T) -> R): Iterator = MappingIterator(this, mapper) fun Iterator.map(mapper: java.util.function.Function): Iterator = MappingIterator(this, mapper::apply) +fun Iterator.flatMap(mapper: (T) -> Iterator): Iterator = FlatMappingIterator(this, mapper) +fun Iterator.flatMap(mapper: java.util.function.Function>): Iterator = FlatMappingIterator(this, mapper::apply) fun Iterator.reduce(identity: T, reducer: (T, T) -> T): T { var result = identity @@ -125,51 +198,8 @@ fun Iterator.findFirst(): Optional { } fun Iterator.findAny() = findFirst() - -fun Iterator.limit(limit: Long): Iterator { - require(limit > 0) { "Invalid limit $limit" } - - return object : Iterator { - var found = 0L - - override fun hasNext(): Boolean { - return found < limit && this@limit.hasNext() - } - - override fun next(): T { - if (found >= limit) { - throw NoSuchElementException() - } - - return this@limit.next() - } - } -} - -fun Iterator.skip(skip: Long): Iterator { - require(skip > 0) { "Invalid skip $skip" } - - return object : Iterator { - var found = skip - - override fun hasNext(): Boolean { - while (this@skip.hasNext() && found > 0L) { - found-- - this@skip.next() - } - - return this@skip.hasNext() - } - - override fun next(): T { - if (!hasNext()) { - throw NoSuchElementException() - } - - return this@skip.next() - } - } -} +fun Iterator.limit(limit: Long) = LimitingIterator(this, limit) +fun Iterator.skip(skip: Long) = if (skip == 0L) this else SkippingIterator(this, skip) inline fun Iterator.forEach(action: (T) -> Unit) { for (value in this) { @@ -208,3 +238,15 @@ fun Iterator.max(comparator: Comparator): Optional { return Optional.of(max) } + +fun Iterator.peek(peeker: (T) -> Unit): Iterator { + return object : Iterator { + override fun hasNext(): Boolean { + return this@peek.hasNext() + } + + override fun next(): T { + return this@peek.next().also(peeker) + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/EuclidMath.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/EuclidMath.kt index 440d4a6f1..2f3602cd2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/EuclidMath.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/EuclidMath.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.core.math import com.mojang.blaze3d.vertex.PoseStack +import it.unimi.dsi.fastutil.ints.IntSpliterators import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap import net.minecraft.core.BlockPos import net.minecraft.core.Direction @@ -11,7 +12,12 @@ import org.joml.Matrix3f import org.joml.Matrix4f import org.joml.Quaternionf import org.joml.Vector3f +import ru.dbotthepony.mc.otm.core.collect.filter +import ru.dbotthepony.mc.otm.core.collect.flatMap +import ru.dbotthepony.mc.otm.core.collect.map import java.lang.ref.SoftReference +import java.util.stream.Stream +import java.util.stream.StreamSupport import kotlin.math.* typealias Vector = Vec3 @@ -433,66 +439,26 @@ operator fun Direction.unaryMinus(): Direction = this.opposite operator fun Vec3i.unaryMinus(): Vec3i = Vec3i(-x, -y, -z) operator fun BlockPos.unaryMinus(): BlockPos = BlockPos(-x, -y, -z) -private fun ellipsoidShapeCacheKey(x: Int, y: Int, z: Int): Long { - require(x > 0) { "Negative X $x" } - require(y > 0) { "Negative Y $y" } - require(z > 0) { "Negative Z $z" } - - return (x.toLong() and 0xFFFFFL) or - ((y.toLong() and 0xFFFFFL) shl 20) or - ((z.toLong() and 0xFFFFFL) shl 40) -} - -private val blockShapeCache = Long2ObjectOpenHashMap>>() - -fun getSphericalBlockPositions(size: Int): List { +fun getSphericalBlockPositions(size: Int): Iterator { return getEllipsoidBlockPositions(size, size, size) } -fun getEllipsoidBlockPositions(x: Int, y: Int, z: Int): List { - val getResult = blockShapeCache[ellipsoidShapeCacheKey(x, y, z)]?.get() - - if (getResult != null) { - return getResult - } - - val result = ArrayList((x * y * z * Math.PI * (4.0 / 3.0)).toInt() + 16) - +fun getEllipsoidBlockPositions(x: Int, y: Int, z: Int): Iterator { val xPow = x.toDouble().pow(2.0) val yPow = y.toDouble().pow(2.0) val zPow = z.toDouble().pow(2.0) - for (ellipsoidX in -x..x) { - for (ellipsoidY in -y..y) { - for (ellipsoidZ in -z..z) { - if ( - ellipsoidX.toDouble().pow(2.0) / xPow + - ellipsoidY.toDouble().pow(2.0) / yPow + - ellipsoidZ.toDouble().pow(2.0) / zPow <= 1.0 - ) { - result.add(BlockPos(ellipsoidX, ellipsoidY, ellipsoidZ)) - } - } + return (-x .. x).iterator().flatMap { ix -> + (-y .. y).iterator().flatMap { iy -> + (-z .. z).iterator().map { BlockPos(ix, iy, it) } } + }.filter { pos -> + val (ellipsoidX, ellipsoidY, ellipsoidZ) = pos + + ellipsoidX.toDouble().pow(2.0) / xPow + + ellipsoidY.toDouble().pow(2.0) / yPow + + ellipsoidZ.toDouble().pow(2.0) / zPow <= 1.0 } - - result.sortWith { a, b -> - val xa = a.x - val ya = a.y - val za = a.z - val distA = sqrt(xa * xa.toDouble() + ya * ya.toDouble() + za * za.toDouble()) - - val xb = b.x - val yb = b.y - val zb = b.z - val distB = sqrt(xb * xb.toDouble() + yb * yb.toDouble() + zb * zb.toDouble()) - - return@sortWith distA.compareTo(distB) - } - - val immutableList = com.google.common.collect.ImmutableList.copyOf(result) - blockShapeCache[ellipsoidShapeCacheKey(x, y, z)] = SoftReference(immutableList) - return immutableList } fun normalizeAngle(angle: Double): Double { From 6b5b1f938acf24437caa308e3a7f77be8d6ecbff Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 6 Jul 2023 01:09:39 +0700 Subject: [PATCH 0692/1199] =?UTF-8?q?YuRaNnNzZZ=20=E2=80=94=20=D0=A1=D0=B5?= =?UTF-8?q?=D0=B3=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=200:22=20=D0=B2=D1=80?= =?UTF-8?q?=D0=B5=D0=BC=D1=8F=20=D0=BF=D1=80=D0=BE=D0=B2=D0=BE=D0=B4=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=B8=D0=BC=D0=B8?= =?UTF-8?q?=D1=84=D0=B8=D0=BA=D0=B0=D1=86=D0=B8=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/container/UpgradeContainer.kt | 22 +++--- .../mc/otm/core/collect/StreamyIterator.kt | 72 +++++++++++++++++++ 2 files changed, 86 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt index d93c2c282..521a25a0a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt @@ -5,6 +5,12 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.UpgradeType import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.config.VerboseBalanceValues +import ru.dbotthepony.mc.otm.core.collect.filter +import ru.dbotthepony.mc.otm.core.collect.map +import ru.dbotthepony.mc.otm.core.collect.mapToDouble +import ru.dbotthepony.mc.otm.core.collect.mapToInt +import ru.dbotthepony.mc.otm.core.collect.reduce +import ru.dbotthepony.mc.otm.core.collect.sum import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.core.math.Decimal import kotlin.math.pow @@ -16,21 +22,21 @@ open class UpgradeContainer(slotCount: Int, open val allowedUpgrades: Set a + b } override val energyStorageFlat: Decimal - get() = stream().filter { it.isNotEmpty }.map { it.getCapability(MatteryCapability.UPGRADE).map { it.energyStorageFlat }.orElse(Decimal.ZERO).moreThanZero() * it.count }.reduce(Decimal.ZERO, Decimal::plus) + get() = iterator().filter { it.isNotEmpty }.map { it.getCapability(MatteryCapability.UPGRADE).map { it.energyStorageFlat }.orElse(Decimal.ZERO).moreThanZero() * it.count }.reduce(Decimal.ZERO, Decimal::plus) override val energyStorage: Decimal - get() = stream().filter { it.isNotEmpty }.map { it.getCapability(MatteryCapability.UPGRADE).map { it.energyStorage }.orElse(Decimal.ZERO).moreThanZero() * it.count }.reduce(Decimal.ZERO, Decimal::plus) + get() = iterator().filter { it.isNotEmpty }.map { it.getCapability(MatteryCapability.UPGRADE).map { it.energyStorage }.orElse(Decimal.ZERO).moreThanZero() * it.count }.reduce(Decimal.ZERO, Decimal::plus) override val energyConsumed: Decimal - get() = stream().filter { it.isNotEmpty }.map { it.getCapability(MatteryCapability.UPGRADE).map { it.energyConsumed }.orElse(Decimal.ZERO) * it.count }.reduce(Decimal.ZERO, Decimal::plus) + get() = iterator().filter { it.isNotEmpty }.map { it.getCapability(MatteryCapability.UPGRADE).map { it.energyConsumed }.orElse(Decimal.ZERO) * it.count }.reduce(Decimal.ZERO, Decimal::plus) override val failureMultiplier: Double - get() = stream().filter { it.isNotEmpty }.mapToDouble { it.getCapability(MatteryCapability.UPGRADE).map { it.failureMultiplier }.orElse(1.0).coerceAtLeast(0.0).pow(it.count.toDouble()) }.reduce(1.0) { a, b -> a * b } + get() = iterator().filter { it.isNotEmpty }.mapToDouble { it.getCapability(MatteryCapability.UPGRADE).map { it.failureMultiplier }.orElse(1.0).coerceAtLeast(0.0).pow(it.count.toDouble()) }.reduce(1.0) { a, b -> a * b } override val energyThroughputFlat: Decimal - get() = stream().filter { it.isNotEmpty }.map { it.getCapability(MatteryCapability.UPGRADE).map { it.energyThroughputFlat }.orElse(Decimal.ZERO).moreThanZero() * it.count }.reduce(Decimal.ZERO, Decimal::plus) + get() = iterator().filter { it.isNotEmpty }.map { it.getCapability(MatteryCapability.UPGRADE).map { it.energyThroughputFlat }.orElse(Decimal.ZERO).moreThanZero() * it.count }.reduce(Decimal.ZERO, Decimal::plus) override val energyThroughput: Decimal - get() = stream().filter { it.isNotEmpty }.map { it.getCapability(MatteryCapability.UPGRADE).map { it.energyThroughput }.orElse(Decimal.ZERO).moreThanZero() * it.count }.reduce(Decimal.ZERO, Decimal::plus) + get() = iterator().filter { it.isNotEmpty }.map { it.getCapability(MatteryCapability.UPGRADE).map { it.energyThroughput }.orElse(Decimal.ZERO).moreThanZero() * it.count }.reduce(Decimal.ZERO, Decimal::plus) fun transform(values: ConciseBalanceValues): ConciseBalanceValues { return object : ConciseBalanceValues { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt index ddd5193d7..53cda603a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt @@ -135,6 +135,78 @@ fun Iterator.map(mapper: java.util.function.Function): Iterator< fun Iterator.flatMap(mapper: (T) -> Iterator): Iterator = FlatMappingIterator(this, mapper) fun Iterator.flatMap(mapper: java.util.function.Function>): Iterator = FlatMappingIterator(this, mapper::apply) +fun interface O2DFunction { + fun apply(value: T): Double +} + +fun interface O2IFunction { + fun apply(value: T): Int +} + +fun Iterator.mapToDouble(mapper: O2DFunction): it.unimi.dsi.fastutil.doubles.DoubleIterator { + return object : it.unimi.dsi.fastutil.doubles.DoubleIterator { + override fun hasNext(): Boolean { + return this@mapToDouble.hasNext() + } + + override fun remove() { + throw UnsupportedOperationException() + } + + override fun nextDouble(): Double { + return mapper.apply(this@mapToDouble.next()) + } + } +} + +fun Iterator.mapToInt(mapper: O2IFunction): it.unimi.dsi.fastutil.ints.IntIterator { + return object : it.unimi.dsi.fastutil.ints.IntIterator { + override fun hasNext(): Boolean { + return this@mapToInt.hasNext() + } + + override fun remove() { + throw UnsupportedOperationException() + } + + override fun nextInt(): Int { + return mapper.apply(this@mapToInt.next()) + } + } +} + +fun it.unimi.dsi.fastutil.doubles.DoubleIterator.sum(): Double { + var value = 0.0 + while (hasNext()) value += nextDouble() + return value +} + +fun it.unimi.dsi.fastutil.ints.IntIterator.sum(): Int { + var value = 0 + while (hasNext()) value += nextInt() + return value +} + +fun interface DD2DFunction { + fun apply(a: Double, b: Double): Double +} + +fun interface II2IFunction { + fun apply(a: Int, b: Int): Int +} + +fun it.unimi.dsi.fastutil.doubles.DoubleIterator.reduce(identity: Double, reducer: DD2DFunction): Double { + var result = identity + while (hasNext()) result = reducer.apply(result, nextDouble()) + return result +} + +fun it.unimi.dsi.fastutil.ints.IntIterator.reduce(identity: Int, reducer: II2IFunction): Int { + var result = identity + while (hasNext()) result = reducer.apply(result, nextInt()) + return result +} + fun Iterator.reduce(identity: T, reducer: (T, T) -> T): T { var result = identity From 507f0cbe41bf54e4d3ac8ed677156294e3729c46 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Thu, 6 Jul 2023 03:18:12 +0600 Subject: [PATCH 0693/1199] Android charger segmented model --- .../models/block/android_charger_base.json | 150 +++++++++++++++++ .../models/block/android_charger_middle.json | 128 ++++++++++++++ .../models/block/android_charger_top.json | 157 ++++++++++++++++++ .../textures/block/android_charger.png | Bin 0 -> 695 bytes 4 files changed, 435 insertions(+) create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/android_charger_base.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/android_charger_middle.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/android_charger_top.json create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/android_charger.png diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/android_charger_base.json b/src/main/resources/assets/overdrive_that_matters/models/block/android_charger_base.json new file mode 100644 index 000000000..df420b334 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/android_charger_base.json @@ -0,0 +1,150 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [32, 64], + "textures": { + "0": "overdrive_that_matters:block/android_charger", + "particle": "overdrive_that_matters:block/android_charger" + }, + "elements": [ + { + "name": "body", + "from": [0, 0, 0], + "to": [16, 8, 16], + "faces": { + "north": {"uv": [0, 5, 8, 7], "texture": "#0"}, + "east": {"uv": [0, 8, 8, 10], "texture": "#0"}, + "south": {"uv": [0, 10, 8, 12], "texture": "#0"}, + "west": {"uv": [8, 8, 0, 10], "texture": "#0"}, + "up": {"uv": [0, 12, 8, 16], "texture": "#0"}, + "down": {"uv": [0, 12, 8, 16], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [11, 8, 1], + "to": [15, 12, 15], + "faces": { + "north": {"uv": [2, 7, 0, 8], "texture": "#0"}, + "east": {"uv": [9, 7, 2, 8], "texture": "#0"}, + "south": {"uv": [0, 7, 2, 8], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [5, 8, 1], + "to": [1, 12, 15], + "faces": { + "north": {"uv": [2, 7, 0, 8], "texture": "#0"}, + "east": {"uv": [9, 7, 2, 8], "texture": "#0"}, + "south": {"uv": [0, 7, 2, 8], "texture": "#0"} + } + }, + { + "name": "body", + "from": [2, 8, 2], + "to": [14, 11, 14], + "faces": { + "north": {"uv": [14, 13, 15.5, 16], "rotation": 90, "texture": "#0"}, + "east": {"uv": [14, 13, 15.5, 16], "rotation": 90, "texture": "#0"}, + "south": {"uv": [14, 13, 15.5, 16], "rotation": 90, "texture": "#0"}, + "west": {"uv": [14, 13, 15.5, 16], "rotation": 90, "texture": "#0"}, + "up": {"uv": [8, 13, 14, 16], "texture": "#0"}, + "down": {"uv": [0, 0, 12, 12], "texture": "#missing"} + } + }, + { + "name": "frame", + "from": [1, 8, 1], + "to": [5, 12, 15], + "faces": { + "north": {"uv": [0, 7, 2, 8], "texture": "#0"}, + "south": {"uv": [2, 7, 0, 8], "texture": "#0"}, + "west": {"uv": [2, 7, 9, 8], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [15, 8, 1], + "to": [11, 12, 15], + "faces": { + "north": {"uv": [0, 7, 2, 8], "texture": "#0"}, + "south": {"uv": [2, 7, 0, 8], "texture": "#0"}, + "west": {"uv": [2, 7, 9, 8], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [3, 11, 3], + "to": [5, 16, 5], + "faces": { + "north": {"uv": [7.5, 0, 8.5, 1.25], "texture": "#0"}, + "east": {"uv": [8.5, 0, 9.5, 1.25], "texture": "#0"}, + "south": {"uv": [7.5, 0, 8.5, 1.25], "texture": "#0"}, + "west": {"uv": [8.5, 0, 9.5, 1.25], "texture": "#0"} + } + }, + { + "name": "core", + "from": [4, 11, 4], + "to": [12, 16, 12], + "faces": { + "north": {"uv": [8, 9, 12, 10.25], "texture": "#0"}, + "east": {"uv": [8, 9, 12, 10.25], "texture": "#0"}, + "south": {"uv": [8, 9, 12, 10.25], "texture": "#0"}, + "west": {"uv": [8, 9, 12, 10.25], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [11, 11, 3], + "to": [13, 16, 5], + "faces": { + "north": {"uv": [8.5, 0, 9.5, 1.25], "texture": "#0"}, + "east": {"uv": [7.5, 0, 8.5, 1.25], "texture": "#0"}, + "south": {"uv": [8.5, 0, 9.5, 1.25], "texture": "#0"}, + "west": {"uv": [7.5, 0, 8.5, 1.25], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [11, 11, 11], + "to": [13, 16, 13], + "faces": { + "north": {"uv": [7.5, 0, 8.5, 1.25], "texture": "#0"}, + "east": {"uv": [8.5, 0, 9.5, 1.25], "texture": "#0"}, + "south": {"uv": [7.5, 0, 8.5, 1.25], "texture": "#0"}, + "west": {"uv": [8.5, 0, 9.5, 1.25], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [3, 11, 11], + "to": [5, 16, 13], + "faces": { + "north": {"uv": [8.5, 0, 9.5, 1.25], "texture": "#0"}, + "east": {"uv": [7.5, 0, 8.5, 1.25], "texture": "#0"}, + "south": {"uv": [8.5, 0, 9.5, 1.25], "texture": "#0"}, + "west": {"uv": [7.5, 0, 8.5, 1.25], "texture": "#0"} + } + }, + { + "name": "spine", + "from": [5, 8, 12], + "to": [11, 16, 16], + "faces": { + "east": {"uv": [16, 5, 14, 7], "texture": "#0"}, + "south": {"uv": [12, 9, 15, 11], "texture": "#0"}, + "west": {"uv": [14, 5, 16, 7], "texture": "#0"} + } + } + ], + "display": {}, + "groups": [ + { + "name": "base", + "origin": [0, 0, 0], + "color": 0, + "children": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/android_charger_middle.json b/src/main/resources/assets/overdrive_that_matters/models/block/android_charger_middle.json new file mode 100644 index 000000000..26c215bb2 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/android_charger_middle.json @@ -0,0 +1,128 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [32, 64], + "textures": { + "0": "overdrive_that_matters:block/android_charger", + "particle": "overdrive_that_matters:block/android_charger" + }, + "elements": [ + { + "name": "core", + "from": [4, 0, 4], + "to": [12, 16, 12], + "faces": { + "north": {"uv": [8, 9, 12, 13], "texture": "#0"}, + "east": {"uv": [8, 9, 12, 13], "texture": "#0"}, + "south": {"uv": [8, 9, 12, 13], "texture": "#0"}, + "west": {"uv": [8, 9, 12, 13], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [3, 0, 11], + "to": [5, 16, 13], + "faces": { + "north": {"uv": [8.5, 0, 9.5, 4], "texture": "#0"}, + "east": {"uv": [7.5, 0, 8.5, 4], "texture": "#0"}, + "south": {"uv": [8.5, 0, 9.5, 4], "texture": "#0"}, + "west": {"uv": [7.5, 0, 8.5, 4], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [11, 0, 3], + "to": [13, 16, 5], + "faces": { + "north": {"uv": [8.5, 0, 9.5, 4], "texture": "#0"}, + "east": {"uv": [7.5, 0, 8.5, 4], "texture": "#0"}, + "south": {"uv": [8.5, 0, 9.5, 4], "texture": "#0"}, + "west": {"uv": [7.5, 0, 8.5, 4], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [3, 0, 3], + "to": [5, 16, 5], + "faces": { + "north": {"uv": [7.5, 0, 8.5, 4], "texture": "#0"}, + "east": {"uv": [8.5, 0, 9.5, 4], "texture": "#0"}, + "south": {"uv": [7.5, 0, 8.5, 4], "texture": "#0"}, + "west": {"uv": [8.5, 0, 9.5, 4], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [11, 0, 11], + "to": [13, 16, 13], + "faces": { + "north": {"uv": [7.5, 0, 8.5, 4], "texture": "#0"}, + "east": {"uv": [8.5, 0, 9.5, 4], "texture": "#0"}, + "south": {"uv": [7.5, 0, 8.5, 4], "texture": "#0"}, + "west": {"uv": [8.5, 0, 9.5, 4], "texture": "#0"} + } + }, + { + "name": "spine", + "from": [5, 0, 12], + "to": [11, 16, 16], + "faces": { + "east": {"uv": [16, 5, 14, 9], "texture": "#0"}, + "south": {"uv": [12, 9, 15, 13], "texture": "#0"}, + "west": {"uv": [14, 5, 16, 9], "texture": "#0"} + } + }, + { + "name": "grid", + "from": [2, -1, 2], + "to": [14, 5, 14], + "faces": { + "north": {"uv": [0, 0, 6, 1.5], "texture": "#0"}, + "east": {"uv": [0, 1.5, 6, 3], "rotation": 180, "texture": "#0"}, + "south": {"uv": [0, 3, 6, 4.5], "texture": "#0"}, + "west": {"uv": [0, 1.5, 6, 3], "texture": "#0"} + } + }, + { + "name": "grid", + "from": [2, -1, 14], + "to": [14, 5, 2], + "faces": { + "north": {"uv": [0, 3, 6, 4.5], "texture": "#0"}, + "east": {"uv": [6, 1.5, 0, 3], "rotation": 180, "texture": "#0"}, + "south": {"uv": [0, 0, 6, 1.5], "texture": "#0"}, + "west": {"uv": [6, 1.5, 0, 3], "texture": "#0"} + } + }, + { + "name": "grid", + "from": [2, 11, 14], + "to": [14, 17, 2], + "faces": { + "north": {"uv": [0, 3, 6, 4.5], "texture": "#0"}, + "east": {"uv": [6, 1.5, 0, 3], "rotation": 180, "texture": "#0"}, + "south": {"uv": [0, 0, 6, 1.5], "texture": "#0"}, + "west": {"uv": [6, 1.5, 0, 3], "texture": "#0"} + } + }, + { + "name": "grid", + "from": [2, 11, 2], + "to": [14, 17, 14], + "faces": { + "north": {"uv": [0, 0, 6, 1.5], "texture": "#0"}, + "east": {"uv": [0, 1.5, 6, 3], "rotation": 180, "texture": "#0"}, + "south": {"uv": [0, 3, 6, 4.5], "texture": "#0"}, + "west": {"uv": [0, 1.5, 6, 3], "texture": "#0"} + } + } + ], + "display": {}, + "groups": [ + { + "name": "middle", + "origin": [0, 0, 0], + "color": 0, + "children": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/android_charger_top.json b/src/main/resources/assets/overdrive_that_matters/models/block/android_charger_top.json new file mode 100644 index 000000000..2382ec8da --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/android_charger_top.json @@ -0,0 +1,157 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [32, 64], + "textures": { + "0": "overdrive_that_matters:block/android_charger", + "particle": "overdrive_that_matters:block/android_charger" + }, + "elements": [ + { + "name": "screen", + "from": [3, 11, 0], + "to": [13, 14, 0], + "faces": { + "north": {"uv": [11, 2.25, 12.5, 4.75], "rotation": 90, "texture": "#0"} + } + }, + { + "name": "frame", + "from": [3, 0, 11], + "to": [5, 5, 13], + "faces": { + "north": {"uv": [8.5, 2.75, 9.5, 4], "texture": "#0"}, + "east": {"uv": [7.5, 2.75, 8.5, 4], "texture": "#0"}, + "south": {"uv": [8.5, 2.75, 9.5, 4], "texture": "#0"}, + "west": {"uv": [7.5, 2.75, 8.5, 4], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [11, 0, 3], + "to": [13, 5, 5], + "faces": { + "north": {"uv": [8.5, 2.75, 9.5, 4], "texture": "#0"}, + "east": {"uv": [7.5, 2.75, 8.5, 4], "texture": "#0"}, + "south": {"uv": [8.5, 2.75, 9.5, 4], "texture": "#0"}, + "west": {"uv": [7.5, 2.75, 8.5, 4], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [3, 0, 3], + "to": [5, 5, 5], + "faces": { + "north": {"uv": [7.5, 2.75, 8.5, 4], "texture": "#0"}, + "east": {"uv": [8.5, 2.75, 9.5, 4], "texture": "#0"}, + "south": {"uv": [7.5, 2.75, 8.5, 4], "texture": "#0"}, + "west": {"uv": [8.5, 2.75, 9.5, 4], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [11, 0, 11], + "to": [13, 5, 13], + "faces": { + "north": {"uv": [7.5, 2.75, 8.5, 4], "texture": "#0"}, + "east": {"uv": [8.5, 2.75, 9.5, 4], "texture": "#0"}, + "south": {"uv": [7.5, 2.75, 8.5, 4], "texture": "#0"}, + "west": {"uv": [8.5, 2.75, 9.5, 4], "texture": "#0"} + } + }, + { + "name": "core", + "from": [4, 0, 4], + "to": [12, 5, 12], + "faces": { + "north": {"uv": [8, 11.75, 12, 13], "texture": "#0"}, + "east": {"uv": [8, 11.75, 12, 13], "texture": "#0"}, + "south": {"uv": [8, 11.75, 12, 13], "texture": "#0"}, + "west": {"uv": [8, 11.75, 12, 13], "texture": "#0"} + } + }, + { + "name": "spine", + "from": [5, 0, 12], + "to": [11, 8, 16], + "faces": { + "east": {"uv": [16, 7, 14, 9], "texture": "#0"}, + "south": {"uv": [12, 11, 15, 13], "texture": "#0"}, + "west": {"uv": [14, 7, 16, 9], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [1, 4, 1], + "to": [5, 8, 15], + "faces": { + "north": {"uv": [2, 7, 0, 8], "rotation": 180, "texture": "#0"}, + "south": {"uv": [0, 7, 2, 8], "rotation": 180, "texture": "#0"}, + "west": {"uv": [2, 7, 9, 8], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "frame", + "from": [15, 4, 1], + "to": [11, 8, 15], + "faces": { + "north": {"uv": [2, 7, 0, 8], "rotation": 180, "texture": "#0"}, + "south": {"uv": [0, 7, 2, 8], "rotation": 180, "texture": "#0"}, + "west": {"uv": [2, 7, 9, 8], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "frame", + "from": [11, 4, 1], + "to": [15, 8, 15], + "faces": { + "north": {"uv": [0, 7, 2, 8], "rotation": 180, "texture": "#0"}, + "east": {"uv": [2, 7, 9, 8], "rotation": 180, "texture": "#0"}, + "south": {"uv": [2, 7, 0, 8], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "frame", + "from": [5, 4, 1], + "to": [1, 8, 15], + "faces": { + "north": {"uv": [0, 7, 2, 8], "rotation": 180, "texture": "#0"}, + "east": {"uv": [2, 7, 9, 8], "rotation": 180, "texture": "#0"}, + "south": {"uv": [2, 7, 0, 8], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "body", + "from": [2, 5, 2], + "to": [14, 8, 14], + "faces": { + "north": {"uv": [14, 13, 15.5, 16], "rotation": 270, "texture": "#0"}, + "east": {"uv": [14, 13, 15.5, 16], "rotation": 270, "texture": "#0"}, + "south": {"uv": [14, 13, 15.5, 16], "rotation": 270, "texture": "#0"}, + "west": {"uv": [14, 13, 15.5, 16], "rotation": 270, "texture": "#0"}, + "down": {"uv": [8, 13, 14, 16], "texture": "#0"} + } + }, + { + "name": "body", + "from": [0, 8, 0], + "to": [16, 16, 16], + "faces": { + "north": {"uv": [10, 5, 14, 9], "rotation": 90, "texture": "#0"}, + "east": {"uv": [8, 8, 0, 10], "rotation": 180, "texture": "#0"}, + "south": {"uv": [0, 10, 8, 12], "rotation": 180, "texture": "#0"}, + "west": {"uv": [0, 8, 8, 10], "rotation": 180, "texture": "#0"}, + "up": {"uv": [0, 12, 8, 16], "texture": "#0"}, + "down": {"uv": [0, 12, 8, 16], "texture": "#0"} + } + } + ], + "display": {}, + "groups": [ + { + "name": "top", + "origin": [0, 0, 0], + "color": 0, + "children": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/android_charger.png b/src/main/resources/assets/overdrive_that_matters/textures/block/android_charger.png new file mode 100644 index 0000000000000000000000000000000000000000..747af985d1c5a4ae3a5c05b84674b885c79a7307 GIT binary patch literal 695 zcmeAS@N?(olHy`uVBq!ia0vp^3P9|@!3-pQ0$S$)DaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(ehe1_3@Hu0=&f2?+_>+S;b3rtR(RAt53EA9()1!Jww5mR8x4+teSMUnM3c zR!~q-UtbS0RZkP;{f@(cct3K$+J$4Ua_I14-?iy0XB4ude`@%$AjK!<$sba4#v z@SZ#6_O8_mJS~kKN4>uOyVQ~pKwgmJd?<0W3}eB_hEj%wI`-CpGnlYWck1{ zx$42+=4OFI2bV`&4?VoUf%mldPxk{)vK-EcXI90U-uS8ZJmLAu2};M;-MO@+C4GmU z>QaT70&n^i8F_^lg)z|6qvq8&S+%L+x)}I zU|oZo)Vev6F?_e!_X@u~?9aQCQD>%uSu=MB!?q=lLjSCEl)gI6;EN-pN!=~>-ph&C z*jZl~ympS3VDQ{pa`npZ1%;&(x@L05d8`as@_}y+ Date: Thu, 6 Jul 2023 03:14:08 +0300 Subject: [PATCH 0694/1199] =?UTF-8?q?=D0=B1=D0=BB=D0=BE=D0=BA=D1=81=D1=82?= =?UTF-8?q?=D0=B5=D0=B9=D1=82=D1=8B=20+=20=D1=88=D0=B5=D0=B9=D0=BF=D1=8B?= =?UTF-8?q?=20+=20=D0=BC=D0=BE=D0=B4=D0=B5=D0=BB=D1=8C=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B5=D0=B4=D0=BC=D0=B5=D1=82=D0=B0=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=B7=D0=B0=D1=80=D1=8F=D0=B4=D0=BD=D0=B8=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/datagen/blocks/BlockStates.kt | 14 + .../mc/otm/shapes/BlockShapes.java | 44 ++ .../mc/otm/block/tech/AndroidChargerBlock.kt | 23 + .../models/block/android_charger_base.json | 6 +- .../models/block/android_charger_middle.json | 6 +- .../models/block/android_charger_top.json | 11 +- .../models/item/android_charger.json | 456 ++++++++++++++++++ 7 files changed, 556 insertions(+), 4 deletions(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/models/item/android_charger.json diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt index 6c0672fec..0c4759b33 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt @@ -7,6 +7,7 @@ import ru.dbotthepony.mc.otm.block.CableBlock import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock +import ru.dbotthepony.mc.otm.block.tech.AndroidChargerBlock import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.math.xRotationBlockstateNorth import ru.dbotthepony.mc.otm.core.math.xRotationBlockstateSouth @@ -45,6 +46,19 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { } } + with(provider.getMultipartBuilder(MBlocks.ANDROID_CHARGER)) { + for (dir in BlockRotationFreedom.ONE.possibleValues) { + for (part in AndroidChargerBlock.PART.possibleValues) { + part().modelFile(provider.models().getExistingFile(modLocation("block/${MNames.ANDROID_CHARGER}_${part.serializedName}"))) + .rotationY(dir.front.yRotationBlockstateNorth()) + .addModel() + .condition(AndroidChargerBlock.PART, part) + .condition(BlockRotationFreedom.ONE.property, dir) + .end() + } + } + } + with(provider.getMultipartBuilder(MBlocks.MATTER_BOTTLER)) { for (dir in BlockRotationFreedom.ONE.possibleValues) { for (enum in WorkerState.SEMI_WORKER_STATE.possibleValues) { diff --git a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java index 55402a469..9e09e6691 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java +++ b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java @@ -688,4 +688,48 @@ public class BlockShapes { new SimpleCuboid(0.03125d, 0.8125d, 0.03125d, 0.96875d, 0.875d, 0.96875d), new SimpleCuboid(0d, 0.1875d, 0d, 1d, 0.8125d, 1d) ); + + public static final BlockShape ANDROID_CHARGER_BASE = new BlockShape( + new SimpleCuboid(0d, 0d, 0d, 1d, 0.5d, 1d), + new SimpleCuboid(0.6875d, 0.5d, 0.0625d, 0.9375d, 0.75d, 0.9375d), + new SimpleCuboid(0.3125d, 0.5d, 0.0625d, 0.0625d, 0.75d, 0.9375d), + new SimpleCuboid(0.125d, 0.5d, 0.125d, 0.875d, 0.6875d, 0.875d), + new SimpleCuboid(0.0625d, 0.5d, 0.0625d, 0.3125d, 0.75d, 0.9375d), + new SimpleCuboid(0.9375d, 0.5d, 0.0625d, 0.6875d, 0.75d, 0.9375d), + new SimpleCuboid(0.1875d, 0.6875d, 0.1875d, 0.3125d, 1d, 0.3125d), + new SimpleCuboid(0.25d, 0.6875d, 0.25d, 0.75d, 1d, 0.75d), + new SimpleCuboid(0.6875d, 0.6875d, 0.1875d, 0.8125d, 1d, 0.3125d), + new SimpleCuboid(0.6875d, 0.6875d, 0.6875d, 0.8125d, 1d, 0.8125d), + new SimpleCuboid(0.1875d, 0.6875d, 0.6875d, 0.3125d, 1d, 0.8125d), + new SimpleCuboid(0.3125d, 0.5d, 0.75d, 0.6875d, 1d, 1d) + ); + + public static final BlockShape ANDROID_CHARGER_MIDDLE = new BlockShape( + new SimpleCuboid(0.25d, 0d, 0.25d, 0.75d, 1d, 0.75d), + new SimpleCuboid(0.1875d, 0d, 0.6875d, 0.3125d, 1d, 0.8125d), + new SimpleCuboid(0.6875d, 0d, 0.1875d, 0.8125d, 1d, 0.3125d), + new SimpleCuboid(0.1875d, 0d, 0.1875d, 0.3125d, 1d, 0.3125d), + new SimpleCuboid(0.6875d, 0d, 0.6875d, 0.8125d, 1d, 0.8125d), + new SimpleCuboid(0.3125d, 0d, 0.75d, 0.6875d, 1d, 1d), + new SimpleCuboid(0.125d, -0.0625d, 0.125d, 0.875d, 0.3125d, 0.875d), + new SimpleCuboid(0.125d, -0.0625d, 0.875d, 0.875d, 0.3125d, 0.125d), + new SimpleCuboid(0.125d, 0.6875d, 0.875d, 0.875d, 1.0625d, 0.125d), + new SimpleCuboid(0.125d, 0.6875d, 0.125d, 0.875d, 1.0625d, 0.875d) + ); + + public static final BlockShape ANDROID_CHARGER_TOP = new BlockShape( + new SimpleCuboid(0.1875d, 0.6875d, 0d, 0.8125d, 0.875d, 0d), + new SimpleCuboid(0.1875d, 0d, 0.6875d, 0.3125d, 0.3125d, 0.8125d), + new SimpleCuboid(0.6875d, 0d, 0.1875d, 0.8125d, 0.3125d, 0.3125d), + new SimpleCuboid(0.1875d, 0d, 0.1875d, 0.3125d, 0.3125d, 0.3125d), + new SimpleCuboid(0.6875d, 0d, 0.6875d, 0.8125d, 0.3125d, 0.8125d), + new SimpleCuboid(0.25d, 0d, 0.25d, 0.75d, 0.3125d, 0.75d), + new SimpleCuboid(0.3125d, 0d, 0.75d, 0.6875d, 0.5d, 1d), + new SimpleCuboid(0.0625d, 0.25d, 0.0625d, 0.3125d, 0.5d, 0.9375d), + new SimpleCuboid(0.9375d, 0.25d, 0.0625d, 0.6875d, 0.5d, 0.9375d), + new SimpleCuboid(0.6875d, 0.25d, 0.0625d, 0.9375d, 0.5d, 0.9375d), + new SimpleCuboid(0.3125d, 0.25d, 0.0625d, 0.0625d, 0.5d, 0.9375d), + new SimpleCuboid(0.125d, 0.3125d, 0.125d, 0.875d, 0.5d, 0.875d), + new SimpleCuboid(0d, 0.5d, 0d, 1d, 1d, 1d) + ); } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt index d7be418c5..c71cefd83 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt @@ -20,14 +20,18 @@ import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.level.block.state.properties.EnumProperty import net.minecraft.world.level.material.PushReaction +import net.minecraft.world.phys.shapes.CollisionContext +import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.AndroidChargerBlockEntity +import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.gracefulBlockBreak import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.oncePre +import ru.dbotthepony.mc.otm.shapes.BlockShapes class AndroidChargerBlock : RotatableMatteryBlock(Properties.of().destroyTime(2.5f).explosionResistance(40f).pushReaction(PushReaction.BLOCK).requiresCorrectToolForDrops()), EntityBlock { enum class Type : StringRepresentable { @@ -129,6 +133,25 @@ class AndroidChargerBlock : RotatableMatteryBlock(Properties.of().destroyTime(2. MatteryPoweredBlockEntity.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) } + private val shapes = getShapeForEachState(listOf(rotationProperty, PART)) { + val shape = when (it[PART]!!) { + Type.BASE -> BlockShapes.ANDROID_CHARGER_BASE + Type.MIDDLE -> BlockShapes.ANDROID_CHARGER_MIDDLE + Type.TOP -> BlockShapes.ANDROID_CHARGER_TOP + } + + shape.rotateFromNorth(it[rotationProperty]).computeShape() + } + + override fun getShape( + p_60555_: BlockState, + p_60556_: BlockGetter, + p_60557_: BlockPos, + p_60558_: CollisionContext + ): VoxelShape { + return shapes[p_60555_]!! + } + companion object { val PART: EnumProperty = EnumProperty.create("part", Type::class.java) } diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/android_charger_base.json b/src/main/resources/assets/overdrive_that_matters/models/block/android_charger_base.json index df420b334..e38c6c3ac 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/android_charger_base.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/android_charger_base.json @@ -1,5 +1,6 @@ { "credit": "Made with Blockbench", + "render_type": "cutout", "texture_size": [32, 64], "textures": { "0": "overdrive_that_matters:block/android_charger", @@ -92,7 +93,10 @@ "east": {"uv": [8, 9, 12, 10.25], "texture": "#0"}, "south": {"uv": [8, 9, 12, 10.25], "texture": "#0"}, "west": {"uv": [8, 9, 12, 10.25], "texture": "#0"} - } + }, + "forge_data": { + "block_light": 15 + } }, { "name": "frame", diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/android_charger_middle.json b/src/main/resources/assets/overdrive_that_matters/models/block/android_charger_middle.json index 26c215bb2..4faec05de 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/android_charger_middle.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/android_charger_middle.json @@ -1,5 +1,6 @@ { "credit": "Made with Blockbench", + "render_type": "cutout", "texture_size": [32, 64], "textures": { "0": "overdrive_that_matters:block/android_charger", @@ -15,7 +16,10 @@ "east": {"uv": [8, 9, 12, 13], "texture": "#0"}, "south": {"uv": [8, 9, 12, 13], "texture": "#0"}, "west": {"uv": [8, 9, 12, 13], "texture": "#0"} - } + }, + "forge_data": { + "block_light": 15 + } }, { "name": "frame", diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/android_charger_top.json b/src/main/resources/assets/overdrive_that_matters/models/block/android_charger_top.json index 2382ec8da..c93c5609f 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/android_charger_top.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/android_charger_top.json @@ -1,5 +1,6 @@ { "credit": "Made with Blockbench", + "render_type": "cutout", "texture_size": [32, 64], "textures": { "0": "overdrive_that_matters:block/android_charger", @@ -12,7 +13,10 @@ "to": [13, 14, 0], "faces": { "north": {"uv": [11, 2.25, 12.5, 4.75], "rotation": 90, "texture": "#0"} - } + }, + "forge_data": { + "block_light": 15 + } }, { "name": "frame", @@ -67,7 +71,10 @@ "east": {"uv": [8, 11.75, 12, 13], "texture": "#0"}, "south": {"uv": [8, 11.75, 12, 13], "texture": "#0"}, "west": {"uv": [8, 11.75, 12, 13], "texture": "#0"} - } + }, + "forge_data": { + "block_light": 15 + } }, { "name": "spine", diff --git a/src/main/resources/assets/overdrive_that_matters/models/item/android_charger.json b/src/main/resources/assets/overdrive_that_matters/models/item/android_charger.json new file mode 100644 index 000000000..fa38f4ae2 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/item/android_charger.json @@ -0,0 +1,456 @@ +{ + "credit": "Made with Blockbench", + "render_type": "cutout", + "texture_size": [32, 64], + "textures": { + "0": "overdrive_that_matters:block/android_charger", + "particle": "overdrive_that_matters:block/android_charger" + }, + "elements": [ + { + "name": "body", + "from": [0, -16, 0], + "to": [16, -8, 16], + "faces": { + "north": {"uv": [0, 5, 8, 7], "texture": "#0"}, + "east": {"uv": [0, 8, 8, 10], "texture": "#0"}, + "south": {"uv": [0, 10, 8, 12], "texture": "#0"}, + "west": {"uv": [8, 8, 0, 10], "texture": "#0"}, + "up": {"uv": [0, 12, 8, 16], "texture": "#0"}, + "down": {"uv": [0, 12, 8, 16], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [11, -8, 1], + "to": [15, -4, 15], + "faces": { + "north": {"uv": [2, 7, 0, 8], "texture": "#0"}, + "east": {"uv": [9, 7, 2, 8], "texture": "#0"}, + "south": {"uv": [0, 7, 2, 8], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [5, -8, 1], + "to": [1, -4, 15], + "faces": { + "north": {"uv": [2, 7, 0, 8], "texture": "#0"}, + "east": {"uv": [9, 7, 2, 8], "texture": "#0"}, + "south": {"uv": [0, 7, 2, 8], "texture": "#0"} + } + }, + { + "name": "body", + "from": [2, -8, 2], + "to": [14, -5, 14], + "faces": { + "north": {"uv": [14, 13, 15.5, 16], "rotation": 90, "texture": "#0"}, + "east": {"uv": [14, 13, 15.5, 16], "rotation": 90, "texture": "#0"}, + "south": {"uv": [14, 13, 15.5, 16], "rotation": 90, "texture": "#0"}, + "west": {"uv": [14, 13, 15.5, 16], "rotation": 90, "texture": "#0"}, + "up": {"uv": [8, 13, 14, 16], "texture": "#0"}, + "down": {"uv": [0, 0, 12, 12], "texture": "#missing"} + } + }, + { + "name": "frame", + "from": [1, -8, 1], + "to": [5, -4, 15], + "faces": { + "north": {"uv": [0, 7, 2, 8], "texture": "#0"}, + "south": {"uv": [2, 7, 0, 8], "texture": "#0"}, + "west": {"uv": [2, 7, 9, 8], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [15, -8, 1], + "to": [11, -4, 15], + "faces": { + "north": {"uv": [0, 7, 2, 8], "texture": "#0"}, + "south": {"uv": [2, 7, 0, 8], "texture": "#0"}, + "west": {"uv": [2, 7, 9, 8], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [3, -5, 3], + "to": [5, 0, 5], + "faces": { + "north": {"uv": [7.5, 0, 8.5, 1.25], "texture": "#0"}, + "east": {"uv": [8.5, 0, 9.5, 1.25], "texture": "#0"}, + "south": {"uv": [7.5, 0, 8.5, 1.25], "texture": "#0"}, + "west": {"uv": [8.5, 0, 9.5, 1.25], "texture": "#0"} + } + }, + { + "name": "core", + "from": [4, -5, 4], + "to": [12, 0, 12], + "faces": { + "north": {"uv": [8, 9, 12, 10.25], "texture": "#0"}, + "east": {"uv": [8, 9, 12, 10.25], "texture": "#0"}, + "south": {"uv": [8, 9, 12, 10.25], "texture": "#0"}, + "west": {"uv": [8, 9, 12, 10.25], "texture": "#0"} + }, + "forge_data": { + "block_light": 15 + } + }, + { + "name": "frame", + "from": [11, -5, 3], + "to": [13, 0, 5], + "faces": { + "north": {"uv": [8.5, 0, 9.5, 1.25], "texture": "#0"}, + "east": {"uv": [7.5, 0, 8.5, 1.25], "texture": "#0"}, + "south": {"uv": [8.5, 0, 9.5, 1.25], "texture": "#0"}, + "west": {"uv": [7.5, 0, 8.5, 1.25], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [11, -5, 11], + "to": [13, 0, 13], + "faces": { + "north": {"uv": [7.5, 0, 8.5, 1.25], "texture": "#0"}, + "east": {"uv": [8.5, 0, 9.5, 1.25], "texture": "#0"}, + "south": {"uv": [7.5, 0, 8.5, 1.25], "texture": "#0"}, + "west": {"uv": [8.5, 0, 9.5, 1.25], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [3, -5, 11], + "to": [5, 0, 13], + "faces": { + "north": {"uv": [8.5, 0, 9.5, 1.25], "texture": "#0"}, + "east": {"uv": [7.5, 0, 8.5, 1.25], "texture": "#0"}, + "south": {"uv": [8.5, 0, 9.5, 1.25], "texture": "#0"}, + "west": {"uv": [7.5, 0, 8.5, 1.25], "texture": "#0"} + } + }, + { + "name": "spine", + "from": [5, -8, 12], + "to": [11, 0, 16], + "faces": { + "east": {"uv": [16, 5, 14, 7], "texture": "#0"}, + "south": {"uv": [12, 9, 15, 11], "texture": "#0"}, + "west": {"uv": [14, 5, 16, 7], "texture": "#0"} + } + }, + { + "name": "core", + "from": [4, 0, 4], + "to": [12, 16, 12], + "faces": { + "north": {"uv": [8, 9, 12, 13], "texture": "#0"}, + "east": {"uv": [8, 9, 12, 13], "texture": "#0"}, + "south": {"uv": [8, 9, 12, 13], "texture": "#0"}, + "west": {"uv": [8, 9, 12, 13], "texture": "#0"} + }, + "forge_data": { + "block_light": 15 + } + }, + { + "name": "frame", + "from": [3, 0, 11], + "to": [5, 16, 13], + "faces": { + "north": {"uv": [8.5, 0, 9.5, 4], "texture": "#0"}, + "east": {"uv": [7.5, 0, 8.5, 4], "texture": "#0"}, + "south": {"uv": [8.5, 0, 9.5, 4], "texture": "#0"}, + "west": {"uv": [7.5, 0, 8.5, 4], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [11, 0, 3], + "to": [13, 16, 5], + "faces": { + "north": {"uv": [8.5, 0, 9.5, 4], "texture": "#0"}, + "east": {"uv": [7.5, 0, 8.5, 4], "texture": "#0"}, + "south": {"uv": [8.5, 0, 9.5, 4], "texture": "#0"}, + "west": {"uv": [7.5, 0, 8.5, 4], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [3, 0, 3], + "to": [5, 16, 5], + "faces": { + "north": {"uv": [7.5, 0, 8.5, 4], "texture": "#0"}, + "east": {"uv": [8.5, 0, 9.5, 4], "texture": "#0"}, + "south": {"uv": [7.5, 0, 8.5, 4], "texture": "#0"}, + "west": {"uv": [8.5, 0, 9.5, 4], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [11, 0, 11], + "to": [13, 16, 13], + "faces": { + "north": {"uv": [7.5, 0, 8.5, 4], "texture": "#0"}, + "east": {"uv": [8.5, 0, 9.5, 4], "texture": "#0"}, + "south": {"uv": [7.5, 0, 8.5, 4], "texture": "#0"}, + "west": {"uv": [8.5, 0, 9.5, 4], "texture": "#0"} + } + }, + { + "name": "spine", + "from": [5, 0, 12], + "to": [11, 16, 16], + "faces": { + "east": {"uv": [16, 5, 14, 9], "texture": "#0"}, + "south": {"uv": [12, 9, 15, 13], "texture": "#0"}, + "west": {"uv": [14, 5, 16, 9], "texture": "#0"} + } + }, + { + "name": "grid", + "from": [2, -1, 2], + "to": [14, 5, 14], + "faces": { + "north": {"uv": [0, 0, 6, 1.5], "texture": "#0"}, + "east": {"uv": [0, 1.5, 6, 3], "rotation": 180, "texture": "#0"}, + "south": {"uv": [0, 3, 6, 4.5], "texture": "#0"}, + "west": {"uv": [0, 1.5, 6, 3], "texture": "#0"} + } + }, + { + "name": "grid", + "from": [2, -1, 14], + "to": [14, 5, 2], + "faces": { + "north": {"uv": [0, 3, 6, 4.5], "texture": "#0"}, + "east": {"uv": [6, 1.5, 0, 3], "rotation": 180, "texture": "#0"}, + "south": {"uv": [0, 0, 6, 1.5], "texture": "#0"}, + "west": {"uv": [6, 1.5, 0, 3], "texture": "#0"} + } + }, + { + "name": "grid", + "from": [2, 11, 14], + "to": [14, 17, 2], + "faces": { + "north": {"uv": [0, 3, 6, 4.5], "texture": "#0"}, + "east": {"uv": [6, 1.5, 0, 3], "rotation": 180, "texture": "#0"}, + "south": {"uv": [0, 0, 6, 1.5], "texture": "#0"}, + "west": {"uv": [6, 1.5, 0, 3], "texture": "#0"} + } + }, + { + "name": "grid", + "from": [2, 11, 2], + "to": [14, 17, 14], + "faces": { + "north": {"uv": [0, 0, 6, 1.5], "texture": "#0"}, + "east": {"uv": [0, 1.5, 6, 3], "rotation": 180, "texture": "#0"}, + "south": {"uv": [0, 3, 6, 4.5], "texture": "#0"}, + "west": {"uv": [0, 1.5, 6, 3], "texture": "#0"} + } + }, + { + "name": "screen", + "from": [3, 27, 0], + "to": [13, 30, 0], + "faces": { + "north": {"uv": [11, 2.25, 12.5, 4.75], "rotation": 90, "texture": "#0"} + }, + "forge_data": { + "block_light": 15 + } + }, + { + "name": "frame", + "from": [3, 16, 11], + "to": [5, 21, 13], + "faces": { + "north": {"uv": [8.5, 2.75, 9.5, 4], "texture": "#0"}, + "east": {"uv": [7.5, 2.75, 8.5, 4], "texture": "#0"}, + "south": {"uv": [8.5, 2.75, 9.5, 4], "texture": "#0"}, + "west": {"uv": [7.5, 2.75, 8.5, 4], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [11, 16, 3], + "to": [13, 21, 5], + "faces": { + "north": {"uv": [8.5, 2.75, 9.5, 4], "texture": "#0"}, + "east": {"uv": [7.5, 2.75, 8.5, 4], "texture": "#0"}, + "south": {"uv": [8.5, 2.75, 9.5, 4], "texture": "#0"}, + "west": {"uv": [7.5, 2.75, 8.5, 4], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [3, 16, 3], + "to": [5, 21, 5], + "faces": { + "north": {"uv": [7.5, 2.75, 8.5, 4], "texture": "#0"}, + "east": {"uv": [8.5, 2.75, 9.5, 4], "texture": "#0"}, + "south": {"uv": [7.5, 2.75, 8.5, 4], "texture": "#0"}, + "west": {"uv": [8.5, 2.75, 9.5, 4], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [11, 16, 11], + "to": [13, 21, 13], + "faces": { + "north": {"uv": [7.5, 2.75, 8.5, 4], "texture": "#0"}, + "east": {"uv": [8.5, 2.75, 9.5, 4], "texture": "#0"}, + "south": {"uv": [7.5, 2.75, 8.5, 4], "texture": "#0"}, + "west": {"uv": [8.5, 2.75, 9.5, 4], "texture": "#0"} + } + }, + { + "name": "core", + "from": [4, 16, 4], + "to": [12, 21, 12], + "faces": { + "north": {"uv": [8, 11.75, 12, 13], "texture": "#0"}, + "east": {"uv": [8, 11.75, 12, 13], "texture": "#0"}, + "south": {"uv": [8, 11.75, 12, 13], "texture": "#0"}, + "west": {"uv": [8, 11.75, 12, 13], "texture": "#0"} + }, + "forge_data": { + "block_light": 15 + } + }, + { + "name": "spine", + "from": [5, 16, 12], + "to": [11, 24, 16], + "faces": { + "east": {"uv": [16, 7, 14, 9], "texture": "#0"}, + "south": {"uv": [12, 11, 15, 13], "texture": "#0"}, + "west": {"uv": [14, 7, 16, 9], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [1, 20, 1], + "to": [5, 24, 15], + "faces": { + "north": {"uv": [2, 7, 0, 8], "rotation": 180, "texture": "#0"}, + "south": {"uv": [0, 7, 2, 8], "rotation": 180, "texture": "#0"}, + "west": {"uv": [2, 7, 9, 8], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "frame", + "from": [15, 20, 1], + "to": [11, 24, 15], + "faces": { + "north": {"uv": [2, 7, 0, 8], "rotation": 180, "texture": "#0"}, + "south": {"uv": [0, 7, 2, 8], "rotation": 180, "texture": "#0"}, + "west": {"uv": [2, 7, 9, 8], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "frame", + "from": [11, 20, 1], + "to": [15, 24, 15], + "faces": { + "north": {"uv": [0, 7, 2, 8], "rotation": 180, "texture": "#0"}, + "east": {"uv": [2, 7, 9, 8], "rotation": 180, "texture": "#0"}, + "south": {"uv": [2, 7, 0, 8], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "frame", + "from": [5, 20, 1], + "to": [1, 24, 15], + "faces": { + "north": {"uv": [0, 7, 2, 8], "rotation": 180, "texture": "#0"}, + "east": {"uv": [2, 7, 9, 8], "rotation": 180, "texture": "#0"}, + "south": {"uv": [2, 7, 0, 8], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "body", + "from": [2, 21, 2], + "to": [14, 24, 14], + "faces": { + "north": {"uv": [14, 13, 15.5, 16], "rotation": 270, "texture": "#0"}, + "east": {"uv": [14, 13, 15.5, 16], "rotation": 270, "texture": "#0"}, + "south": {"uv": [14, 13, 15.5, 16], "rotation": 270, "texture": "#0"}, + "west": {"uv": [14, 13, 15.5, 16], "rotation": 270, "texture": "#0"}, + "down": {"uv": [8, 13, 14, 16], "texture": "#0"} + } + }, + { + "name": "body", + "from": [0, 24, 0], + "to": [16, 32, 16], + "faces": { + "north": {"uv": [10, 5, 14, 9], "rotation": 90, "texture": "#0"}, + "east": {"uv": [8, 8, 0, 10], "rotation": 180, "texture": "#0"}, + "south": {"uv": [0, 10, 8, 12], "rotation": 180, "texture": "#0"}, + "west": {"uv": [0, 8, 8, 10], "rotation": 180, "texture": "#0"}, + "up": {"uv": [0, 12, 8, 16], "texture": "#0"}, + "down": {"uv": [0, 12, 8, 16], "texture": "#0"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.3, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, -135, 0], + "scale": [0.3, 0.3, 0.3] + }, + "head": { + "translation": [0, 30, 0] + }, + "fixed": { + "translation": [0, 0, -2], + "scale": [0.375, 0.375, 0.375] + } + }, + "groups": [ + { + "name": "base", + "origin": [0, 0, 0], + "color": 0, + "children": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] + }, + { + "name": "middle", + "origin": [0, 0, 0], + "color": 0, + "children": [12, 13, 14, 15, 16, 17, 18, 19, 20, 21] + }, + { + "name": "top", + "origin": [0, 0, 0], + "color": 0, + "children": [22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34] + } + ] +} \ No newline at end of file From e2b340ceaf9afd117eb3c77b7454a27ca8b1b77e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 6 Jul 2023 12:48:32 +0700 Subject: [PATCH 0695/1199] Clarify destroy_blocks config option --- .../mc/otm/block/entity/blackhole/BlackHoleBlockEntity.kt | 2 +- src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) 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 5041fc5e5..a1e304372 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 @@ -287,7 +287,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery var iterations = 0 - while (iterations < ITERATIONS && sphereIterator!!.hasNext()) { + while (iterations < ITERATIONS && sphereIterator.hasNext()) { iterations++ val pos = sphereIterator.next() + blockPos diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt index f9e2c87dd..a4d6dc4bf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ServerConfig.kt @@ -54,6 +54,8 @@ object ServerConfig : AbstractConfig("misc") { val DESTROY_BLOCKS: Boolean by builder .comment("Whenever singularities should destroy blocks") + .comment("Keep in mind that mobs behind blocks can cause serious server lag") + .comment("when trying to reach singularity") .define("DESTROY_BLOCKS", true) } From 1955975ceef7f4d4c0c4042710b7874ebd217ed0 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 6 Jul 2023 13:12:44 +0700 Subject: [PATCH 0696/1199] Fix updating machine configuration not marking chunk dirty --- .../block/entity/MatteryDeviceBlockEntity.kt | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index 8b236083c..6cfc56de3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -145,6 +145,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo if (access.read() != value) { access.write(value) + setChangedLight() if (value == FlowDirection.NONE) { controller.close() @@ -157,8 +158,16 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo // var automatePull by synchronizer.bool().property var automatePull = false + set(value) { + field = value + setChangedLight() + } // var automatePush by synchronizer.bool().property var automatePush = false + set(value) { + field = value + setChangedLight() + } override fun tick() { if (flow == FlowDirection.NONE || !automatePull && !automatePush || redstoneControl.isBlockedByRedstone) @@ -310,8 +319,16 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo // var automatePull by synchronizer.bool().property var automatePull = false + set(value) { + field = value + setChangedLight() + } // var automatePush by synchronizer.bool().property var automatePush = false + set(value) { + field = value + setChangedLight() + } init { tickList.always(this) @@ -371,6 +388,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo if (access.read() != value) { access.write(value) + setChangedLight() if (value == FlowDirection.NONE) { for (controller in capControllers) @@ -499,6 +517,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo if (access.read() != value) { access.write(value) + setChangedLight() if (value == ItemHandlerMode.DISABLED) { capController.close() @@ -543,6 +562,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo set(value) { if (field != value) { field = value + setChangedLight() if (value) { innerSlotPush = 0 @@ -555,6 +575,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo set(value) { if (field != value) { field = value + setChangedLight() if (value) { innerSlotPush = 0 From 0d069a2d8e9fd74e3513749c4eb8559709973395 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 6 Jul 2023 13:12:54 +0700 Subject: [PATCH 0697/1199] Add proxied energy storage --- .../capability/energy/ProxiedEnergyStorage.kt | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ProxiedEnergyStorage.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ProxiedEnergyStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ProxiedEnergyStorage.kt new file mode 100644 index 000000000..70d345734 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ProxiedEnergyStorage.kt @@ -0,0 +1,35 @@ +package ru.dbotthepony.mc.otm.capability.energy + +import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.core.math.Decimal + +class ProxiedEnergyStorage(var parent: T? = null) : IMatteryEnergyStorage { + override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { + return parent?.extractEnergy(howMuch, simulate) ?: Decimal.ZERO + } + + override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { + return parent?.receiveEnergy(howMuch, simulate) ?: Decimal.ZERO + } + + override var batteryLevel: Decimal + get() = parent?.batteryLevel ?: Decimal.ZERO + set(value) { parent?.batteryLevel = value } + override val maxBatteryLevel: Decimal + get() = parent?.maxBatteryLevel ?: Decimal.ZERO + override val energyFlow: FlowDirection + get() = parent?.energyFlow ?: FlowDirection.NONE + + override val canSetBatteryLevel: Boolean + get() = parent?.canSetBatteryLevel ?: false + override val missingPower: Decimal + get() = parent?.missingPower ?: Decimal.ZERO + + override fun drainBattery(): Boolean { + return parent?.drainBattery() ?: false + } + + override fun fillBattery(): Boolean { + return parent?.fillBattery() ?: false + } +} From 6d205b3b4a3b8b2b1a560a8438b85ffea5af9eaa Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 6 Jul 2023 13:13:01 +0700 Subject: [PATCH 0698/1199] Add empty energy storage --- .../energy/IMatteryEnergyStorage.kt | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt index 70efbdc09..53407ac9d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt @@ -200,6 +200,49 @@ interface IMatteryEnergyStorage : IEnergyStorage { override fun canReceive(): Boolean { return energyFlow.input } + + /** + * Companion object of [IMatteryEnergyStorage] represents empty energy storage + */ + companion object : IMatteryEnergyStorage { + override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { + return Decimal.ZERO + } + + override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { + return Decimal.ZERO + } + + override var batteryLevel: Decimal + get() = Decimal.ZERO + set(value) {} + override val maxBatteryLevel: Decimal + get() = Decimal.ZERO + override val energyFlow: FlowDirection + get() = FlowDirection.NONE + + override val canSetBatteryLevel: Boolean + get() = false + + override val missingPower: Decimal + get() = Decimal.ZERO + + override fun drainBattery(): Boolean { + return false + } + + override fun fillBattery(): Boolean { + return false + } + + override fun receiveEnergy(maxReceive: Int, simulate: Boolean): Int { + return 0 + } + + override fun extractEnergy(maxReceive: Int, simulate: Boolean): Int { + return 0 + } + } } /** From 4dbf7cdc1c18f82faaa0bd15510437b381cbf845 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 6 Jul 2023 13:54:59 +0700 Subject: [PATCH 0699/1199] Fix gracefulBlockBreak not calling onRemove --- src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 2 ++ 1 file changed, 2 insertions(+) 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 2a1d8b81d..b369caf52 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -25,6 +25,7 @@ import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block +import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateHolder import net.minecraft.world.level.block.state.properties.Property @@ -230,6 +231,7 @@ fun BlockState.getExplosionResistance(level: BlockGetter, pos: BlockPos): Float } fun Level.gracefulBlockBreak(blockPos: BlockPos, block: BlockState = getBlockState(blockPos)) { + block.onRemove(this, blockPos, Blocks.AIR.defaultBlockState(), false) Block.dropResources(block, this, blockPos, getBlockEntity(blockPos)) block.block.destroy(this, blockPos, block) setBlock(blockPos, block.fluidState.createLegacyBlock(), Block.UPDATE_ALL) From b578e9d8d8a7fc629fe1b21c8c727805e52a1b83 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 6 Jul 2023 13:57:13 +0700 Subject: [PATCH 0700/1199] Add middle and top block entities to android charger --- .../block/entity/MatteryDeviceBlockEntity.kt | 31 +++++- .../entity/tech/AndroidChargerBlockEntity.kt | 100 +++++++++++++++++- .../mc/otm/block/tech/AndroidChargerBlock.kt | 18 +++- .../mc/otm/menu/tech/AndroidChargerMenu.kt | 39 +++++-- .../mc/otm/registry/MBlockEntities.kt | 2 + .../ru/dbotthepony/mc/otm/registry/MMenus.kt | 3 +- 6 files changed, 179 insertions(+), 14 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index 6cfc56de3..fe8636ced 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.block.entity import com.google.common.collect.ImmutableSet +import mekanism.common.tile.interfaces.IRedstoneControl import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.core.BlockPos import net.minecraft.world.level.block.state.BlockState @@ -42,7 +43,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo : MatteryBlockEntity(blockEntityType, blockPos, blockState), MenuProvider, IRedstoneControlled { var customDisplayName: Component? = null - override val redstoneControl = RedstoneControl { new, old -> + override val redstoneControl: AbstractRedstoneControl = RedstoneControl { new, old -> setChangedLight() if (new != old) @@ -307,6 +308,12 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo put(RelativeSide.BOTTOM, bottomDefault) } + fun invalidate(force: Boolean = false) { + for (piece in pieces.values) { + piece.invalidate(force) + } + } + inner class Piece(val side: RelativeSide, val possibleModes: FlowDirection) : IMatteryEnergyStorage, ITickable { private val capControllers = exposeEnergy(side, this@Piece) private val neighbour by sides[side]!!.trackEnergy() @@ -401,6 +408,28 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo } } }) + + fun invalidate(force: Boolean = false) { + if (force) { + for (controller in capControllers) { + controller.close() + controller.expose() + } + + if (energyFlow == FlowDirection.NONE) { + for (controller in capControllers) { + controller.close() + } + } + } else { + if (energyFlow != FlowDirection.NONE) { + for (controller in capControllers) { + controller.close() + controller.expose() + } + } + } + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt index 16749c109..943589746 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt @@ -1,14 +1,18 @@ package ru.dbotthepony.mc.otm.block.entity.tech import net.minecraft.core.BlockPos +import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.phys.Vec3 +import ru.dbotthepony.mc.otm.block.entity.AbstractRedstoneControl import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity +import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.ProxiedEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.config.MachinesConfig @@ -17,7 +21,7 @@ import ru.dbotthepony.mc.otm.menu.tech.AndroidChargerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities class AndroidChargerBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.ANDROID_CHARGER, blockPos, blockState) { - override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu? { + override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { return AndroidChargerMenu(containerID, inventory, this) } @@ -50,3 +54,97 @@ class AndroidChargerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Ma } } } + +class AndroidChargerMiddleBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.ANDROID_CHARGER_MIDDLE, blockPos, blockState) { + override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu? { + if (proxy.parent == null || lastTileEntity == null) return null + return AndroidChargerMenu(containerID, inventory, this) + } + + private val proxy = ProxiedEnergyStorage>() + var lastTileEntity: AndroidChargerBlockEntity? = null + private set + val energyConfig = ConfigurableEnergy( + proxy, + modesBottom = FlowDirection.NONE, + modesTop = FlowDirection.NONE, + modesBack = FlowDirection.INPUT, + modesFront = FlowDirection.INPUT, + modesLeft = FlowDirection.INPUT, + modesRight = FlowDirection.INPUT, + ) + + override val redstoneControl = object : AbstractRedstoneControl() { + override var redstoneSetting: RedstoneSetting + get() = lastTileEntity?.redstoneControl?.redstoneSetting ?: RedstoneSetting.IGNORED + set(value) {} + override var redstoneSignal: Int + get() = lastTileEntity?.redstoneControl?.redstoneSignal ?: 0 + set(value) {} + } + + override fun getDisplayName(): Component { + return lastTileEntity?.getDisplayName() ?: super.getDisplayName() + } + + override fun tick() { + super.tick() + + if (proxy.parent == null || lastTileEntity?.isRemoved == true) { + lastTileEntity = level?.getBlockEntity(blockPos.below()) as? AndroidChargerBlockEntity + val energy = lastTileEntity?.energyConfig?.energy + + if (proxy.parent !== energy) { + proxy.parent = energy + energyConfig.invalidate(true) + } + } + } +} + +class AndroidChargerTopBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.ANDROID_CHARGER_TOP, blockPos, blockState) { + override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu? { + if (proxy.parent == null || lastTileEntity == null) return null + return AndroidChargerMenu(containerID, inventory, this) + } + + private val proxy = ProxiedEnergyStorage>() + var lastTileEntity: AndroidChargerBlockEntity? = null + private set + val energyConfig = ConfigurableEnergy( + proxy, + modesBottom = FlowDirection.NONE, + modesTop = FlowDirection.INPUT, + modesBack = FlowDirection.INPUT, + modesFront = FlowDirection.INPUT, + modesLeft = FlowDirection.INPUT, + modesRight = FlowDirection.INPUT, + ) + + override val redstoneControl = object : AbstractRedstoneControl() { + override var redstoneSetting: RedstoneSetting + get() = lastTileEntity?.redstoneControl?.redstoneSetting ?: RedstoneSetting.IGNORED + set(value) {} + override var redstoneSignal: Int + get() = lastTileEntity?.redstoneControl?.redstoneSignal ?: 0 + set(value) {} + } + + override fun getDisplayName(): Component { + return lastTileEntity?.getDisplayName() ?: super.getDisplayName() + } + + override fun tick() { + super.tick() + + if (proxy.parent == null || lastTileEntity?.isRemoved == true) { + lastTileEntity = level?.getBlockEntity(blockPos.below(2)) as? AndroidChargerBlockEntity + val energy = lastTileEntity?.energyConfig?.energy + + if (proxy.parent !== energy) { + proxy.parent = energy + energyConfig.invalidate(true) + } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt index c71cefd83..93faa46bc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt @@ -25,6 +25,8 @@ import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.AndroidChargerBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.AndroidChargerMiddleBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.AndroidChargerTopBlockEntity import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.core.get @@ -75,13 +77,21 @@ class AndroidChargerBlock : RotatableMatteryBlock(Properties.of().destroyTime(2. } override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity? { - if (p_153216_[PART] != Type.BASE) return null - return AndroidChargerBlockEntity(p_153215_, p_153216_) + return when (p_153216_[PART]!!) { + Type.BASE -> AndroidChargerBlockEntity(p_153215_, p_153216_) + Type.MIDDLE -> AndroidChargerMiddleBlockEntity(p_153215_, p_153216_) + Type.TOP -> AndroidChargerTopBlockEntity(p_153215_, p_153216_) + } } override fun getTicker(p_153212_: Level, blockState: BlockState, p_153214_: BlockEntityType): BlockEntityTicker? { - if (p_153212_.isClientSide || blockState[PART] != Type.BASE) return null - return BlockEntityTicker { _, _, _, t -> if (t is AndroidChargerBlockEntity) t.tick() } + if (p_153212_.isClientSide) return null + + return when (blockState[PART]!!) { + Type.BASE -> BlockEntityTicker { _, _, _, t -> if (t is AndroidChargerBlockEntity) t.tick() } + Type.MIDDLE -> BlockEntityTicker { _, _, _, t -> if (t is AndroidChargerMiddleBlockEntity) t.tick() } + Type.TOP -> BlockEntityTicker { _, _, _, t -> if (t is AndroidChargerTopBlockEntity) t.tick() } + } } override fun getDestroyProgress(p_60466_: BlockState, p_60467_: Player, p_60468_: BlockGetter, p_60469_: BlockPos): Float { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidChargerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidChargerMenu.kt index 9b50f53c5..ae6266a1b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidChargerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidChargerMenu.kt @@ -2,18 +2,43 @@ package ru.dbotthepony.mc.otm.menu.tech import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.block.entity.tech.AndroidChargerBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.AndroidChargerMiddleBlockEntity +import ru.dbotthepony.mc.otm.block.entity.tech.AndroidChargerTopBlockEntity import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus -class AndroidChargerMenu( - p_38852_: Int, - inventory: Inventory, - tile: AndroidChargerBlockEntity? = null -) : MatteryPoweredMenu(MMenus.ANDROID_CHARGER, p_38852_, inventory, tile) { - val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) - val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energyConfig?.energy, energyWidget) +class AndroidChargerMenu : MatteryPoweredMenu { + val energyConfig: EnergyConfigPlayerInput + val profiledEnergy: ProfiledLevelGaugeWidget<*> + + constructor( + p_38852_: Int, + inventory: Inventory, + tile: AndroidChargerBlockEntity? = null + ) : super(MMenus.ANDROID_CHARGER, p_38852_, inventory, tile) { + energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) + profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energyConfig?.energy, energyWidget) + } + + constructor( + p_38852_: Int, + inventory: Inventory, + tile: AndroidChargerTopBlockEntity? = null + ) : super(MMenus.ANDROID_CHARGER, p_38852_, inventory, tile?.lastTileEntity) { + energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) + profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.lastTileEntity?.energyConfig?.energy, energyWidget) + } + + constructor( + p_38852_: Int, + inventory: Inventory, + tile: AndroidChargerMiddleBlockEntity? = null + ) : super(MMenus.ANDROID_CHARGER, p_38852_, inventory, tile?.lastTileEntity) { + energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) + profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.lastTileEntity?.energyConfig?.energy, energyWidget) + } init { addInventorySlots() 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 f281a490f..493bb583b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt @@ -56,6 +56,8 @@ object MBlockEntities { val MATTER_RECONSTRUCTOR: BlockEntityType by registry.register(MNames.MATTER_RECONSTRUCTOR) { BlockEntityType.Builder.of(::MatterReconstructorBlockEntity, MBlocks.MATTER_RECONSTRUCTOR).build(null) } val FLUID_TANK: BlockEntityType by registry.register(MNames.FLUID_TANK) { BlockEntityType.Builder.of(::FluidTankBlockEntity, MBlocks.FLUID_TANK).build(null) } val ANDROID_CHARGER: BlockEntityType by registry.register(MNames.ANDROID_CHARGER) { BlockEntityType.Builder.of(::AndroidChargerBlockEntity, MBlocks.ANDROID_CHARGER).build(null) } + val ANDROID_CHARGER_MIDDLE: BlockEntityType by registry.register(MNames.ANDROID_CHARGER + "_middle") { BlockEntityType.Builder.of(::AndroidChargerMiddleBlockEntity, MBlocks.ANDROID_CHARGER).build(null) } + val ANDROID_CHARGER_TOP: BlockEntityType by registry.register(MNames.ANDROID_CHARGER + "_top") { BlockEntityType.Builder.of(::AndroidChargerTopBlockEntity, MBlocks.ANDROID_CHARGER).build(null) } val STORAGE_BUS: BlockEntityType by registry.register(MNames.STORAGE_BUS) { BlockEntityType.Builder.of(::StorageBusBlockEntity, MBlocks.STORAGE_BUS).build(null) } val STORAGE_IMPORTER: BlockEntityType by registry.register(MNames.STORAGE_IMPORTER) { BlockEntityType.Builder.of(::StorageImporterBlockEntity, MBlocks.STORAGE_IMPORTER).build(null) } 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 f4c515991..113c4803a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt @@ -8,6 +8,7 @@ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.block.entity.tech.AndroidChargerBlockEntity import ru.dbotthepony.mc.otm.client.screen.decorative.CargoCrateScreen import ru.dbotthepony.mc.otm.client.screen.decorative.FluidTankScreen import ru.dbotthepony.mc.otm.client.screen.decorative.HoloSignScreen @@ -73,7 +74,7 @@ object MMenus { private val registry = DeferredRegister.create(ForgeRegistries.MENU_TYPES, OverdriveThatMatters.MOD_ID) val ANDROID_STATION: MenuType by registry.register(MNames.ANDROID_STATION) { MenuType(::AndroidStationMenu, FeatureFlags.VANILLA_SET) } - val ANDROID_CHARGER: MenuType by registry.register(MNames.ANDROID_CHARGER) { MenuType(::AndroidChargerMenu, FeatureFlags.VANILLA_SET) } + val ANDROID_CHARGER: MenuType by registry.register(MNames.ANDROID_CHARGER) { MenuType({ a, b -> AndroidChargerMenu(a, b, null as AndroidChargerBlockEntity?) }, FeatureFlags.VANILLA_SET) } val BATTERY_BANK: MenuType by registry.register(MNames.BATTERY_BANK) { MenuType(::BatteryBankMenu, FeatureFlags.VANILLA_SET) } val MATTER_DECOMPOSER: MenuType by registry.register(MNames.MATTER_DECOMPOSER) { MenuType(::MatterDecomposerMenu, FeatureFlags.VANILLA_SET) } val MATTER_CAPACITOR_BANK: MenuType by registry.register(MNames.MATTER_CAPACITOR_BANK) { MenuType(::MatterCapacitorBankMenu, FeatureFlags.VANILLA_SET) } From 92fa4a413099ac91f313d62ff77225d130085f3a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 6 Jul 2023 13:59:00 +0700 Subject: [PATCH 0701/1199] ConditionalSet#actuallyContains --- .../ru/dbotthepony/mc/otm/core/collect/ConditionalSet.kt | 4 ++++ src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ConditionalSet.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ConditionalSet.kt index 9596f15e9..7b70a3f0a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ConditionalSet.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ConditionalSet.kt @@ -30,6 +30,10 @@ class ConditionalSet : Set { return backing.entries.iterator().filter { it.value.asBoolean }.map { it.key } } + fun actuallyContains(element: E): Boolean { + return element in backing + } + fun add(element: E, condition: BooleanSupplier): Boolean { if (element in backing) return false backing[element] = condition diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 702258b2e..0e4260970 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -440,7 +440,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( * [condition] allows to specify when slot is invisible on GUI (hence being ignored by quick move) */ protected fun addStorageSlot(slot: T, addMapping: Boolean = true, prepend: Boolean = false, condition: BooleanSupplier = BooleanSupplier { true }): T { - if (slot !in externalSlots) { + if (!externalSlots.actuallyContains(slot)) { addSlot(slot) if (prepend) From a935ce6874477cafabf93f60cb82a3856c7d6a30 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 6 Jul 2023 14:01:03 +0700 Subject: [PATCH 0702/1199] Add battery slot to "storage slots" in android charger menu --- .../kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidChargerMenu.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidChargerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidChargerMenu.kt index ae6266a1b..23f9071b3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidChargerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidChargerMenu.kt @@ -41,6 +41,7 @@ class AndroidChargerMenu : MatteryPoweredMenu { } init { + addStorageSlot(batterySlot) addInventorySlots() } } From 27908cfe8310b76fb7ed8265b72ad9b16d2a52ea Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 6 Jul 2023 14:06:57 +0700 Subject: [PATCH 0703/1199] Fix gracefulBlockBreak not dropping correct blockentity drops --- src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 b369caf52..6387b3a8e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -231,10 +231,12 @@ fun BlockState.getExplosionResistance(level: BlockGetter, pos: BlockPos): Float } fun Level.gracefulBlockBreak(blockPos: BlockPos, block: BlockState = getBlockState(blockPos)) { - block.onRemove(this, blockPos, Blocks.AIR.defaultBlockState(), false) - Block.dropResources(block, this, blockPos, getBlockEntity(blockPos)) + val tile = getBlockEntity(blockPos) + val state = block.fluidState.createLegacyBlock() + block.onRemove(this, blockPos, state, false) + Block.dropResources(block, this, blockPos, tile) block.block.destroy(this, blockPos, block) - setBlock(blockPos, block.fluidState.createLegacyBlock(), Block.UPDATE_ALL) + setBlock(blockPos, state, Block.UPDATE_ALL) } fun MutableCollection.addAll(elements: Iterator) { From f9a365b6dcee4afd40a15d1e26255e7430b1b89a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 6 Jul 2023 16:51:32 +0700 Subject: [PATCH 0704/1199] Add flat fall damage resistance and nerf percent based damage resistance --- .../ru/dbotthepony/mc/otm/datagen/ResearchData.kt | 6 +++--- .../mc/otm/android/AndroidResearchDescription.kt | 6 +++++- .../mc/otm/android/feature/FallDampenersFeature.kt | 6 ++++-- .../ru/dbotthepony/mc/otm/config/AndroidConfig.kt | 11 ++++++++++- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt index fa7d66bdc..19e80c062 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt @@ -314,7 +314,7 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang AndroidResearchType.Builder(modLocation(MNames.FALL_DAMPENERS + "_3")) .withExperience(35) .withDescription(0 .. 1) - .withDescription(AndroidResearchDescriptions.FALL_DAMPENERS.Instance(2)) + .withDescription(AndroidResearchDescriptions.FALL_DAMPENERS.Instance(3)) .withIcon(ResearchIcons.ICON_FEATHER_FALLING) .addFeatureLevel(AndroidFeatures.FALL_DAMPENERS) .addPrerequisite(FALL_DAMPENERS_2) @@ -376,8 +376,8 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang serializer.accept(JUMP_BOOST_2) with(lang) { - misc("fall_dampeners.description", "Reduces fall damage by %s%%") { - russian("Уменьшает урон от падения на %s%%") + misc("fall_dampeners.description", "Reduces fall damage by %s%% and increases fall damage flat resist by %s half a hearts") { + russian("Уменьшает урон от падения на %s%% и повышает сопротивление урону от падения на %s полусердец") } add(limbList[0], "Limb Overclocking %s") { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDescription.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDescription.kt index 7e5d420e6..402c46eac 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDescription.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDescription.kt @@ -36,7 +36,11 @@ object AndroidResearchDescriptions { } val FALL_DAMPENERS: AndroidResearchDescription.Leveled by registrar.register("fall_dampeners") { - AndroidResearchDescription.Leveled { _, _, level -> TranslatableComponent("otm.fall_dampeners.description", TextComponent("%.1f".format((AndroidConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL * level).toFloat().coerceAtLeast(0f).coerceAtMost(1f) * 100f)).withStyle(ChatFormatting.YELLOW)) } + AndroidResearchDescription.Leveled { _, list, level -> + list.add(TranslatableComponent("otm.fall_dampeners.description", + TextComponent("%.1f".format((AndroidConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL_P * level).toFloat().coerceIn(0f, 1f) * 100f)).withStyle(ChatFormatting.YELLOW), + TextComponent("%.1f".format((AndroidConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL_F * level).toFloat())).withStyle(ChatFormatting.YELLOW), + )) } } val ITEM_MAGNET: AndroidResearchDescription.Singleton by registrar.register("item_magnet") { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt index dbf0004d8..c0db601b9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt @@ -19,14 +19,16 @@ import ru.dbotthepony.mc.otm.triggers.FallDampenersSaveTrigger class FallDampenersFeature(capability: MatteryPlayerCapability) : AndroidFeature(AndroidFeatures.FALL_DAMPENERS, capability) { override fun onHurt(event: LivingHurtEvent) { if (event.source.isFall) { - val reduction = (AndroidConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL * (level + 1)).toFloat() + val reduction = (AndroidConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL_P * (level + 1)).toFloat().coerceIn(0f, 1f) + val flat = (AndroidConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL_F * (level + 1)).toFloat().coerceIn(0f, Float.MAX_VALUE) val old = event.amount - if (reduction >= 1f) { + if (reduction >= 1f || event.amount <= flat) { event.isCanceled = true event.amount = 0f } else { + event.amount -= flat event.amount *= (1f - reduction) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt index 55cfb0e5c..9614c5948 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt @@ -54,7 +54,16 @@ object AndroidConfig : AbstractConfig("androids") { val ANDROID_ENERGY_PER_HUNGER_POINT by builder.defineDecimal("energyPerHunger", Decimal(2000), Decimal.ZERO) val ANDROID_MAX_ENERGY by builder.comment("Internal battery of every android has this much storage").defineDecimal("capacity", Decimal(80_000), Decimal.ZERO) val NIGHT_VISION_POWER_DRAW by builder.defineDecimal("nightVisionPowerDraw", Decimal(8), Decimal.ZERO) - val FALL_DAMAGE_REDUCTION_PER_LEVEL: Double by builder.comment("In percent. Level of feature is multiplied by this").defineInRange("fallDamageReductionPerDampenerLevel", 0.25, 0.01, 1.0) + + val FALL_DAMAGE_REDUCTION_PER_LEVEL_P: Double by builder + .comment("In percent. Level of feature is multiplied by this") + .comment("First, fall damage is reduced by flat resistance, then reduced by percentage resistance (this)") + .defineInRange("FALL_DAMAGE_REDUCTION_PER_LEVEL_P", 0.2, 0.01, 1.0) + + val FALL_DAMAGE_REDUCTION_PER_LEVEL_F: Double by builder + .comment("In flat half of hearts. Level of feature is multiplied by this") + .comment("First, fall damage is reduced by flat resistance (this), then reduced by percentage resistance") + .defineInRange("FALL_DAMAGE_REDUCTION_PER_LEVEL_F", 1.5, 0.0, Float.MAX_VALUE.toDouble()) object EnderTeleporter { init { From 311af4f8d9e09261b975d9d022c282adea7d53b3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 6 Jul 2023 17:07:00 +0700 Subject: [PATCH 0705/1199] This is stupid --- .../mc/otm/OverdriveThatMatters.java | 1 + .../mc/otm/android/AndroidFeature.kt | 2 ++ .../android/feature/FallDampenersFeature.kt | 19 ++++++++++++++----- .../otm/capability/MatteryPlayerCapability.kt | 13 +++++++++++++ 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 972fadf72..4b410adfc 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -160,6 +160,7 @@ public final class OverdriveThatMatters { EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayerCapability.Companion::onPlayerTick); EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayerCapability.Companion::isMobEffectApplicable); EVENT_BUS.addListener(EventPriority.LOW, MatteryPlayerCapability.Companion::onHurtEvent); + EVENT_BUS.addListener(EventPriority.LOW, MatteryPlayerCapability.Companion::onAttackEvent); EVENT_BUS.addGenericListener(Entity.class, EventPriority.NORMAL, MatteryPlayerCapability.Companion::onAttachCapabilityEvent); EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayerCapability.Companion::onPlayerChangeDimensionEvent); EVENT_BUS.addListener(EventPriority.LOWEST, MatteryPlayerCapability.Companion::onPlayerDeath); diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeature.kt index fc9fb84d9..a681d2a20 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeature.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.android import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream import net.minecraft.nbt.CompoundTag import net.minecraftforge.common.util.INBTSerializable +import net.minecraftforge.event.entity.living.LivingAttackEvent import net.minecraftforge.event.entity.living.LivingHurtEvent import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.core.nbt.set @@ -34,6 +35,7 @@ abstract class AndroidFeature(val type: AndroidFeatureType<*>, val android: Matt open fun removeModifiers() {} open fun onHurt(event: LivingHurtEvent) {} + open fun onAttack(event: LivingAttackEvent) {} open fun collectNetworkPayload(): FastByteArrayOutputStream? { return synchronizer.collectNetworkPayload() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt index c0db601b9..4b1b75900 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.android.feature import net.minecraft.ChatFormatting import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer +import net.minecraftforge.event.entity.living.LivingAttackEvent import net.minecraftforge.event.entity.living.LivingHurtEvent import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.android.AndroidFeature @@ -23,13 +24,10 @@ class FallDampenersFeature(capability: MatteryPlayerCapability) : AndroidFeature val flat = (AndroidConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL_F * (level + 1)).toFloat().coerceIn(0f, Float.MAX_VALUE) val old = event.amount + event.amount = ((event.amount - flat) * (1f - reduction)).coerceAtLeast(0f) - if (reduction >= 1f || event.amount <= flat) { + if (event.amount == 0f) { event.isCanceled = true - event.amount = 0f - } else { - event.amount -= flat - event.amount *= (1f - reduction) } if (ply is ServerPlayer && ply.health > event.amount && ply.health <= old) { @@ -37,4 +35,15 @@ class FallDampenersFeature(capability: MatteryPlayerCapability) : AndroidFeature } } } + + override fun onAttack(event: LivingAttackEvent) { + if (event.source.isFall) { + val reduction = (AndroidConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL_P * (level + 1)).toFloat().coerceIn(0f, 1f) + val flat = (AndroidConfig.FALL_DAMAGE_REDUCTION_PER_LEVEL_F * (level + 1)).toFloat().coerceIn(0f, Float.MAX_VALUE) + + if (reduction >= 1f || event.amount <= flat) { + event.isCanceled = true + } + } + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index de6ebb734..5341a58b4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -42,6 +42,7 @@ import net.minecraftforge.event.AttachCapabilitiesEvent import net.minecraftforge.event.RegisterCommandsEvent import net.minecraftforge.event.TickEvent import net.minecraftforge.event.TickEvent.PlayerTickEvent +import net.minecraftforge.event.entity.living.LivingAttackEvent import net.minecraftforge.event.entity.living.LivingDeathEvent import net.minecraftforge.event.entity.living.LivingHurtEvent import net.minecraftforge.event.entity.living.MobEffectEvent @@ -653,6 +654,14 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } } + internal fun onAttack(event: LivingAttackEvent) { + if (isAndroid) { + for (feature in featureMap.values) { + feature.onAttack(event) + } + } + } + internal fun computeIfAbsent(feature: AndroidFeatureType): T { return getFeature(feature) ?: addFeature(feature) } @@ -1307,6 +1316,10 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial event.entity.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresentK { it.onHurt(event) } } + fun onAttackEvent(event: LivingAttackEvent) { + event.entity.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresentK { it.onAttack(event) } + } + val CAPABILITY_LOCATION = ResourceLocation(OverdriveThatMatters.MOD_ID, "player") fun onAttachCapabilityEvent(event: AttachCapabilitiesEvent) { From 3cacf7f11f7cf3abd5564f2536e5a2e3a9c1b9df Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 8 Jul 2023 00:51:37 +0700 Subject: [PATCH 0706/1199] Exopack smelting, RenderGravity, IGUIRenderable --- .../mc/otm/datagen/lang/English.kt | 3 + .../mc/otm/datagen/lang/Russian.kt | 9 +- .../mc/otm/OverdriveThatMatters.java | 4 +- .../otm/capability/MatteryPlayerCapability.kt | 190 ++++++++++++++---- ...ource.kt => BatteryBackedEnergyStorage.kt} | 30 ++- .../mc/otm/client/AndroidMenuKeyMapping.kt | 10 +- .../dbotthepony/mc/otm/client/MatteryGUI.kt | 16 +- .../client/render/AbstractMatterySprite.kt | 11 +- .../dbotthepony/mc/otm/client/render/Ext.kt | 187 +++++------------ .../mc/otm/client/render/IGUIRenderable.kt | 64 ++++++ .../mc/otm/client/render/RenderGravity.kt | 184 +++++++++++++++++ .../render/blockentity/BlackHoleRenderer.kt | 8 +- .../blockentity/EnergyCounterRenderer.kt | 16 +- .../GravitationStabilizerRenderer.kt | 9 +- .../render/blockentity/HoloSignRenderer.kt | 4 +- .../render/entity/PlasmaProjectileRenderer.kt | 4 +- .../client/screen/ExoPackInventoryScreen.kt | 86 +++++++- .../otm/client/screen/panels/EditablePanel.kt | 39 +++- .../client/screen/panels/EffectListPanel.kt | 9 +- .../mc/otm/client/screen/panels/FramePanel.kt | 13 +- .../mc/otm/client/screen/panels/Label.kt | 40 ++-- .../otm/client/screen/panels/SpritePanel.kt | 9 +- .../screen/panels/button/ButtonPanel.kt | 6 +- .../screen/panels/input/TextInputPanel.kt | 17 +- .../screen/panels/slot/AbstractSlotPanel.kt | 4 +- .../client/screen/panels/slot/SlotPanel.kt | 5 +- .../screen/tech/AndroidStationScreen.kt | 8 +- .../screen/tech/EssenceStorageScreen.kt | 5 +- .../compat/jei/PlatePressRecipeCategory.kt | 6 +- .../mc/otm/config/ExopackConfig.kt | 15 ++ ...ngUpgradeItem.kt => ExopackUpgradeItem.kt} | 27 ++- .../mc/otm/item/weapon/AbstractWeaponItem.kt | 5 +- .../mc/otm/menu/ExoPackInventoryMenu.kt | 41 ++++ .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 12 +- .../mc/otm/menu/input/InstantBooleanInput.kt | 25 +++ .../network/synchronizer/FieldSynchronizer.kt | 2 +- .../mc/otm/registry/MCreativeTabs.kt | 1 + .../ru/dbotthepony/mc/otm/registry/MItems.kt | 6 +- 38 files changed, 804 insertions(+), 326 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/{AndroidPowerSource.kt => BatteryBackedEnergyStorage.kt} (86%) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderGravity.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/config/ExopackConfig.kt rename src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/{ExoPackCraftingUpgradeItem.kt => ExopackUpgradeItem.kt} (74%) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/InstantBooleanInput.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index e76ae4983..ac240e091 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -148,6 +148,7 @@ private fun misc(provider: MatteryLanguageProvider) { gui("exopack_upgrades.already_activated", "Upgrade is already active!") gui("exopack_upgrades.slots_upgrade", "Using this will permanently grant %s slots in your Exopack inventory.") gui("exopack_upgrades.crafting_upgrade", "Using this will permanently grant 3x3 crafting grid in your Exopack inventory.") + gui("exopack_upgrades.smelting_upgrade", "Using this will permanently grant smelter in your Exopack inventory.") gui("crude_battery.replace_in_world", "Simplistic nature of this battery allows to replace your energy source in the field without using Android Station.") gui("crude_battery.replace_in_world_warning", "This operation is very unstable and can cause extreme damage to your systems!") @@ -158,6 +159,7 @@ private fun misc(provider: MatteryLanguageProvider) { misc("exopack_upgrades.slots_upgraded", "Your Exopack has permanently gained %s slots") misc("exopack_upgrades.crafting_upgraded", "Your Exopack has permanently gained 3x3 crafting grid") + misc("exopack_upgrades.smelting_installed", "Your Exopack has permanently gained smelting module") misc("exopack.granted1", "As you keep pressing on the fingerprint reader, probe disappears.") misc("exopack.granted2", "After a moment, you are getting pierced into back multiple times...") @@ -474,6 +476,7 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.EXOPACK_PROBE, "Exopack Probe") add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_CREATIVE, "Creative Exopack Inventory Upgrade") add(MItems.ExopackUpgrades.CRAFTING_UPGRADE, "Exopack Crafting Upgrade") + add(MItems.ExopackUpgrades.SMELTING_UPGRADE, "Exopack Smelting Module") add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_WITHER, "Superdense Packing Upgrade") add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_WITHER, "description", "Utilizes similar principle that exhibit Nether Stars") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 291b4ff5a..4faf716dd 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -155,7 +155,8 @@ private fun misc(provider: MatteryLanguageProvider) { gui("exopack_upgrades.already_activated", "Улучшение уже активно!") gui("exopack_upgrades.slots_upgrade", "Активируя данное улучшение даст %s слотов в вашем экзопаке.") - gui("exopack_upgrades.crafting_upgrade", "Активируя данное улучшение даст 3x3 сетку создания в вашем экзопаке.") + gui("exopack_upgrades.crafting_upgrade", "Активация данного улучшения даст 3x3 сетку создания в вашем экзопаке.") + gui("exopack_upgrades.smelting_upgrade", "Активация данного улучшения даст плавильню в вашем экзопаке.") gui("crude_battery.replace_in_world", "Простота устройства данного аккумулятора позволяет вам заменить .") gui("crude_battery.replace_in_world_warning", "Данная операция крайне рискованная и может нанести огромный урон вашим системам!") @@ -164,8 +165,9 @@ private fun misc(provider: MatteryLanguageProvider) { misc("battery.single_use", "Единоразовая батарейка, не может быть перезаряжена.") - misc("exopack_upgrades.slots_upgraded", "Ваш Экзопак был расширен на %s слотов") - misc("exopack_upgrades.crafting_upgraded", "Ваш Экзопак получил 3x3 сетку создания") + misc("exopack_upgrades.slots_upgraded", "Ваш экзопак был расширен на %s слотов") + misc("exopack_upgrades.crafting_upgraded", "Ваш экзопак получил 3x3 сетку создания") + misc("exopack_upgrades.smelting_upgraded", "Ваш экзопак получил плавильню") misc("exopack.granted1", "После некоторого времени нажатия на сканер отпечатка, маяк исчезает.") misc("exopack.granted2", "Через мгновение, вашу спину пронзают множество раз...") @@ -478,6 +480,7 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.EXOPACK_PROBE, "Маяк экзопака") add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_CREATIVE, "Творческое обновление инвентаря экзопака") add(MItems.ExopackUpgrades.CRAFTING_UPGRADE, "Обновление сетки крафта экзопака") + add(MItems.ExopackUpgrades.SMELTING_UPGRADE, "Модуль плавильни экзопака") add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_WITHER, "Обновление сверхмассивной упаковки") add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_WITHER, "description", "Использует те же принципы, которыми обладают звёзды незера") diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 4b410adfc..c03666bbd 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -40,6 +40,7 @@ import ru.dbotthepony.mc.otm.compat.mekanism.MekanismHooks; import ru.dbotthepony.mc.otm.compat.mekanism.QIOKt; import ru.dbotthepony.mc.otm.config.AndroidConfig; import ru.dbotthepony.mc.otm.config.ClientConfig; +import ru.dbotthepony.mc.otm.config.ExopackConfig; import ru.dbotthepony.mc.otm.config.ItemsConfig; import ru.dbotthepony.mc.otm.config.MachinesConfig; import ru.dbotthepony.mc.otm.config.ServerCompatConfig; @@ -140,6 +141,7 @@ public final class OverdriveThatMatters { ServerConfig.INSTANCE.register(); ServerCompatConfig.INSTANCE.register(); AndroidConfig.INSTANCE.register(); + ExopackConfig.INSTANCE.register(); ItemsConfig.INSTANCE.register(); MachinesConfig.INSTANCE.register(); ToolsConfig.INSTANCE.register(); @@ -167,7 +169,7 @@ public final class OverdriveThatMatters { EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayerCapability.Companion::onPlayerCloneEvent); EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayerCapability.Companion::onStartTracking); EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayerCapability.Companion::onStopTracking); - EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayerCapability.MPCommands::addCommands); + EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayerCapability.Companion::addCommands); EVENT_BUS.addListener(EventPriority.NORMAL, ExplosionQueue.Companion::onWorldTick); EVENT_BUS.addListener(EventPriority.NORMAL, AbstractWeaponItem.Companion::tick); diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 5341a58b4..d1737afff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -10,6 +10,7 @@ import net.minecraft.nbt.ListTag import net.minecraft.nbt.StringTag import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation +import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerPlayer import net.minecraft.tags.TagKey import net.minecraft.world.Difficulty @@ -19,15 +20,14 @@ import net.minecraft.world.effect.MobEffectInstance import net.minecraft.world.effect.MobEffects import net.minecraft.world.entity.Entity import net.minecraft.world.entity.LivingEntity -import net.minecraft.world.entity.MobSpawnType import net.minecraft.world.entity.boss.wither.WitherBoss -import net.minecraft.world.entity.monster.Phantom import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player -import net.minecraft.world.inventory.InventoryMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.item.ProjectileWeaponItem +import net.minecraft.world.item.crafting.RecipeManager +import net.minecraft.world.item.crafting.RecipeType import net.minecraft.world.item.enchantment.EnchantmentHelper.hasVanishingCurse import net.minecraft.world.level.GameRules import net.minecraft.world.level.Level @@ -47,8 +47,10 @@ import net.minecraftforge.event.entity.living.LivingDeathEvent import net.minecraftforge.event.entity.living.LivingHurtEvent import net.minecraftforge.event.entity.living.MobEffectEvent import net.minecraftforge.event.entity.player.PlayerEvent +import net.minecraftforge.eventbus.api.Cancelable import net.minecraftforge.eventbus.api.Event import net.minecraftforge.registries.ForgeRegistries +import net.minecraftforge.server.command.EnumArgument import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.* import ru.dbotthepony.mc.otm.android.AndroidFeature @@ -56,12 +58,18 @@ import ru.dbotthepony.mc.otm.android.AndroidFeatureType import ru.dbotthepony.mc.otm.android.AndroidResearch import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidResearchType -import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature -import ru.dbotthepony.mc.otm.capability.energy.AndroidPowerSource +import ru.dbotthepony.mc.otm.block.entity.JobContainer +import ru.dbotthepony.mc.otm.block.entity.JobStatus +import ru.dbotthepony.mc.otm.block.entity.MachineItemJob +import ru.dbotthepony.mc.otm.block.entity.MachineJobEventLoop +import ru.dbotthepony.mc.otm.capability.energy.BatteryBackedEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.capability.energy.receiveEnergyExact import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.config.AndroidConfig +import ru.dbotthepony.mc.otm.config.ExopackConfig import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.stream import ru.dbotthepony.mc.otm.core.* @@ -95,6 +103,7 @@ import java.util.stream.Stream import kotlin.collections.ArrayDeque import kotlin.collections.ArrayList import kotlin.collections.HashMap +import kotlin.reflect.KMutableProperty1 @Suppress("unused") class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerializable { @@ -103,10 +112,8 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial * * Cancelling it is probably not a good idea, but you can do it anyway. */ + @Cancelable data class PreTick(val capability: MatteryPlayerCapability) : Event() { - override fun isCancelable() = true - override fun hasResult() = false - val player get() = capability.ply val level: Level get() = capability.ply.level() } @@ -115,9 +122,6 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial * This event is fired on main event bus after ticking logic took place. */ data class PostTick(val capability: MatteryPlayerCapability) : Event() { - override fun isCancelable() = false - override fun hasResult() = false - val player get() = capability.ply val level: Level get() = capability.ply.level() } @@ -127,10 +131,6 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial * (both in [Inventory] and [MatteryPlayerCapability] exopack due to inventory filters or no free space). */ data class ItemStackLeftoverEvent(val stack: ItemStack, val capability: MatteryPlayerCapability) : Event() { - override fun isCancelable() = false - override fun hasResult() = false - override fun setResult(value: Result) {} - val player get() = capability.ply val level: Level get() = capability.ply.level() } @@ -149,25 +149,26 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial /** * For fields that need to be synchronized only to owning player * - * Please mind if you really need to use this in your mod; - * any differences in field order/types/etc will break *everything* - * + * Please mind when you use this in your mod; + * any differences in field order/types/etc between client and server + * will break *everything* */ val synchronizer = FieldSynchronizer() - /** - * For data to be stored and loaded from NBT automatically - */ - val savetables = Savetables() - /** * For fields that need to be synchronized to everyone * - * Please mind if you really need to use this in your mod; - * any differences in field order/types/etc will break *everything* + * Please mind when you use this in your mod; + * any differences in field order/types/etc between client and server + * will break *everything* */ val publicSynchronizer = FieldSynchronizer() + /** + * For data to be stored to and loaded from NBT automatically + */ + val savetables = Savetables() + /** * Whenever player has Exopack */ @@ -238,7 +239,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial * Whenever Exopack has 3x3 crafting grid upgrade installed */ var isExoPackCraftingUpgraded by publicSynchronizer.bool(setter = setter@{ value, access, _ -> - if (value != access.read()) { + if (value != access.readBoolean()) { access.write(value) _exoPackMenu = null } @@ -324,16 +325,91 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial * * But they can be harmed using harm potion * * Can't be poisoned (with default datapack) * * CAN be withered (with default datapack) + * * Ignored by the Wither but not by Wither Skeletons + * * Can't drown * * etc * * Android-immune (de)buffs are specified in `data/overdrive_that_matters/tags/mob_effect/android_immune_effects.json` */ var isAndroid by publicSynchronizer.bool().property + /** + * Whenever player has exosuit smelting upgrade + */ + var isExoPackSmeltingInstalled by synchronizer.bool(setter = { value, access, _ -> + if (value != access.readBoolean()) { + access.write(value) + _exoPackMenu = null + } + }).property + + inner class SmelterBelt(index: Int) : MachineJobEventLoop() { + override val energy: IMatteryEnergyStorage + get() = exoPackEnergy + override val isBlockedByRedstone: Boolean + get() = false + + override fun deserializeJob(nbt: CompoundTag): MachineItemJob { + return MachineItemJob(nbt) + } + + override val upgrades: IMatteryUpgrade? + get() = null + + override fun jobUpdated(new: MachineItemJob?, old: MachineItemJob?) {} + + override fun onJobFinish(job: MachineItemJob): JobStatus { + if (output.fullyAddItem(job.itemStack)) { + exoPackSmelterExperience += job.experience + return JobStatus.SUCCESS + } else { + return JobStatus.FAILURE_ITEM + } + } + + private val cache = RecipeManager.createCheck(RecipeType.SMELTING) + + override fun computeNextJob(): JobContainer { + val level = ply.level() as? ServerLevel ?: return JobContainer.failure() + val recipe = cache.getRecipeFor(input, level) + + if (recipe.isEmpty) { + return JobContainer.noItem() + } else { + val actual = recipe.get() + val item = actual.assemble(input, level.registryAccess()) + input[0].shrink(1) + input.setChanged(0) + return JobContainer.success(MachineItemJob(item, actual.cookingTime.toDouble(), ExopackConfig.FURNACE_POWER_CONSUMPTION, actual.experience)) + } + } + + val input = MatteryContainer({ notify(IdleReason.ITEM) }, 1) + val output = MatteryContainer({ notify(IdleReason.ITEM) }, 1) + + init { + savetables.stateful(::input, "exopack_smelter_input_$index") + savetables.stateful(::output, "exopack_smelter_output_$index") + savetables.stateful(this, "exopack_smelter_worker_$index") + } + } + + val smelter0 = SmelterBelt(0) + val smelter1 = SmelterBelt(1) + val smelter2 = SmelterBelt(2) + val smelters = listOf(smelter0, smelter1, smelter2) + + var exoPackSmelterExperience = 0f + /** * [IMatteryEnergyStorage] instance, representing Android' battery charge */ - val androidEnergy = AndroidPowerSource(ply, synchronizer, AndroidConfig.ANDROID_MAX_ENERGY, AndroidConfig.ANDROID_MAX_ENERGY) + val androidEnergy = BatteryBackedEnergyStorage(ply, synchronizer, AndroidConfig.ANDROID_MAX_ENERGY, AndroidConfig.ANDROID_MAX_ENERGY) + + /** + * [IMatteryEnergyStorage] instance, representing Exopack battery charge + */ + val exoPackEnergy = ProfiledEnergyStorage(BatteryBackedEnergyStorage(ply, synchronizer, Decimal.ZERO, ExopackConfig.ENERGY_CAPACITY)) init { savetables.int(::ticksIExist) @@ -355,6 +431,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial savetables.stateful(::exoPackSlotModifier, "exoSuitSlotCountModifiers") savetables.stateful(::exoPackContainer, "exoSuitContainer") savetables.stateful(::androidEnergy) + savetables.stateful(::exoPackEnergy) + savetables.float(::exoPackSmelterExperience) + savetables.bool(::isExoPackSmeltingInstalled) } fun invalidateNetworkState() { @@ -642,7 +721,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial return featureMap[feature] as T? } - internal fun onHurt(event: LivingHurtEvent) { + private fun onHurt(event: LivingHurtEvent) { if (isAndroid) { for (feature in featureMap.values) { feature.onHurt(event) @@ -654,7 +733,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } } - internal fun onAttack(event: LivingAttackEvent) { + private fun onAttack(event: LivingAttackEvent) { if (isAndroid) { for (feature in featureMap.values) { feature.onAttack(event) @@ -862,6 +941,14 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } } + if (hasExoPack) { + exoPackEnergy.parent.tick() + + if (!ply.isSpectator && isExoPackSmeltingInstalled) { + smelters.forEach { it.think() } + } + } + if (isAndroid) { androidEnergy.tick() @@ -1194,19 +1281,22 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial return stack.isEmpty } - object MPCommands { - @JvmStatic + enum class UpgradeType(val prop: KMutableProperty1) { + CRAFTING(MatteryPlayerCapability::isExoPackCraftingUpgraded), + SMELTING(MatteryPlayerCapability::isExoPackSmeltingInstalled); + } + + @Suppress("unused") + companion object { private fun setExoPack(players: Collection, hasExoPack: Boolean): Int { for (player in players) { - if (player.containerMenu is InventoryMenu || player.containerMenu is ExoPackInventoryMenu) player.closeContainer() - player.matteryPlayer?.hasExoPack = hasExoPack + player.matteryPlayer?._exoPackMenu = null } return players.size } - @JvmStatic private fun makeAndroid(players: Collection): Int { for (player in players) { player.matteryPlayer?.becomeAndroid() @@ -1215,7 +1305,6 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial return players.size } - @JvmStatic private fun makeHuman(players: Collection): Int { for (player in players) { player.matteryPlayer?.becomeHumane() @@ -1224,38 +1313,51 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial return players.size } - @JvmStatic + private fun setUpgrade(players: Collection, type: UpgradeType, state: Boolean): Int { + for (player in players) { + player.matteryPlayer?.let { type.prop.set(it, state) } + } + + return players.size + } + fun addCommands(event: RegisterCommandsEvent) { event.dispatcher.register( Commands.literal("exopack") .requires { it.hasPermission(Commands.LEVEL_GAMEMASTERS) } .then(Commands.literal("add") - .executes { setExoPack(Collections.singleton(it.source.playerOrException), true) } + .executes { setExoPack(listOf(it.source.playerOrException), true) } .then(Commands.argument("targets", EntityArgument.players()).executes { setExoPack(EntityArgument.getPlayers(it, "targets"), true) }) ) .then(Commands.literal("remove") - .executes { setExoPack(Collections.singleton(it.source.playerOrException), false) } + .executes { setExoPack(listOf(it.source.playerOrException), false) } .then(Commands.argument("targets", EntityArgument.players()).executes { setExoPack(EntityArgument.getPlayers(it, "targets"), false) }) ) + .then(Commands.literal("upgrade") + .then(Commands.argument("type", EnumArgument.enumArgument(UpgradeType::class.java)) + .then(Commands.literal("add") + .executes { setUpgrade(listOf(it.source.playerOrException), it.getArgument("type", UpgradeType::class.java), true) } + .then(Commands.argument("targets", EntityArgument.players()).executes { setUpgrade(EntityArgument.getPlayers(it, "targets"), it.getArgument("type", UpgradeType::class.java), true) })) + .then(Commands.literal("remove") + .executes { setUpgrade(listOf(it.source.playerOrException), it.getArgument("type", UpgradeType::class.java), false) } + .then(Commands.argument("targets", EntityArgument.players()).executes { setUpgrade(EntityArgument.getPlayers(it, "targets"), it.getArgument("type", UpgradeType::class.java), false) }))) + ) ) event.dispatcher.register( Commands.literal("android") .requires { it.hasPermission(Commands.LEVEL_GAMEMASTERS) } .then(Commands.literal("on") - .executes { makeAndroid(Collections.singleton(it.source.playerOrException)) } + .executes { makeAndroid(listOf(it.source.playerOrException)) } .then(Commands.argument("targets", EntityArgument.players()).executes { makeAndroid(EntityArgument.getPlayers(it, "targets")) }) ) .then(Commands.literal("off") - .executes { makeHuman(Collections.singleton(it.source.playerOrException)) } + .executes { makeHuman(listOf(it.source.playerOrException)) } .then(Commands.argument("targets", EntityArgument.players()).executes { makeHuman(EntityArgument.getPlayers(it, "targets")) }) ) ) } - } - @Suppress("unused") - companion object { private fun stackStacks(it: ItemStack, stack: ItemStack): Boolean { if ( !it.isEmpty && @@ -1353,7 +1455,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial mattery.iteration++ mattery.shouldSendIteration = true mattery.deathLog.addLast(ply.tickCount to ply.combatTracker.deathMessage) - mattery.androidEnergy.batteryLevel = mattery.androidEnergy.batteryLevel.coerceAtLeast(Decimal(20_000)) // если смерть была от разряда батареи, то предотвращаем софтлок + mattery.androidEnergy.batteryLevel = mattery.androidEnergy.batteryLevel.coerceAtLeast(AndroidConfig.ANDROID_MAX_ENERGY * Decimal("0.2")) // если смерть была от разряда батареи, то предотвращаем софтлок while (mattery.deathLog.size > 6) { mattery.deathLog.removeFirst() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BatteryBackedEnergyStorage.kt similarity index 86% rename from src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BatteryBackedEnergyStorage.kt index c5aeff61e..5d9e30922 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/AndroidPowerSource.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BatteryBackedEnergyStorage.kt @@ -4,6 +4,7 @@ import net.minecraft.nbt.CompoundTag import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.player.Player import net.minecraft.world.item.ItemStack +import net.minecraft.world.ticks.ContainerSingleItem import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.INBTSerializable import ru.dbotthepony.mc.otm.capability.FlowDirection @@ -18,19 +19,19 @@ import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer import ru.dbotthepony.mc.otm.registry.StatNames import ru.dbotthepony.mc.otm.triggers.AndroidBatteryTrigger -class AndroidPowerSource( +class BatteryBackedEnergyStorage( private val ply: Player, synchronizer: FieldSynchronizer, initialCharge: Decimal, maxCharge: Decimal -) : IMatteryEnergyStorage, INBTSerializable { +) : IMatteryEnergyStorage, INBTSerializable, ContainerSingleItem { override val energyFlow: FlowDirection get() = FlowDirection.INPUT private var battery by synchronizer.decimal(initialCharge) private var maxBattery by synchronizer.decimal(maxCharge) - var item by synchronizer.item(setter = setter@{ value, access, setByRemote -> + var item by synchronizer.item(setter = setter@{ value, access, _ -> access.write(value) if (ply is ServerPlayer) { @@ -38,6 +39,29 @@ class AndroidPowerSource( } }) + override fun getItem(slot: Int): ItemStack { + require(slot == 0) { "Invalid slot $slot" } + return item + } + + override fun removeItem(slot: Int, count: Int): ItemStack { + require(slot == 0) { "Invalid slot $slot" } + return item.split(count) + } + + override fun setItem(slot: Int, stack: ItemStack) { + require(slot == 0) { "Invalid slot $slot" } + item = stack + } + + override fun setChanged() { + + } + + override fun stillValid(p_18946_: Player): Boolean { + return true + } + override fun serializeNBT(): CompoundTag { return CompoundTag().also { it["battery"] = battery.serializeNBT() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt index 3aac27d2d..8c1ca9854 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt @@ -13,7 +13,7 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.android.AndroidFeature import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.matteryPlayer -import ru.dbotthepony.mc.otm.client.render.TextAlign +import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.drawAligned import ru.dbotthepony.mc.otm.client.render.drawArc import ru.dbotthepony.mc.otm.core.math.RGBAColor @@ -257,15 +257,15 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon val shift = size * 0.6f feature.renderIcon(event.guiGraphics, -iconSize / 2f + shift * cos, -shift * sin - iconSize / 2f, iconSize, iconSize) - event.guiGraphics.drawAligned(minecraft.font, feature.type.displayName, TextAlign.CENTER_CENTER, shift * cos + 1f, -shift * sin - iconSize / 1.5f + 1f, 0) - event.guiGraphics.drawAligned(minecraft.font, feature.type.displayName, TextAlign.CENTER_CENTER, shift * cos, -shift * sin - iconSize / 1.5f, if (feature.isActive) RGBAColor.DARK_GREEN else RGBAColor.DARK_RED) + event.guiGraphics.drawAligned(minecraft.font, feature.type.displayName, RenderGravity.CENTER_CENTER, shift * cos + 1f, -shift * sin - iconSize / 1.5f + 1f, 0) + event.guiGraphics.drawAligned(minecraft.font, feature.type.displayName, RenderGravity.CENTER_CENTER, shift * cos, -shift * sin - iconSize / 1.5f, if (feature.isActive) RGBAColor.DARK_GREEN else RGBAColor.DARK_RED) if (feature.isOnCooldown && feature.cooldownPercent > 0.0f) { RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f) drawArc(event.guiGraphics, shift * cos, -shift * sin, iconSize / 2f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * feature.cooldownPercent.toDouble()) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) - event.guiGraphics.drawAligned(minecraft.font, formatTickDuration(feature.cooldown), TextAlign.CENTER_CENTER, shift * cos, -shift * sin + iconSize / 1.5f, RGBAColor.WHITE) + event.guiGraphics.drawAligned(minecraft.font, formatTickDuration(feature.cooldown), RenderGravity.CENTER_CENTER, shift * cos, -shift * sin + iconSize / 1.5f, RGBAColor.WHITE) } } @@ -302,7 +302,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon drawArc(event.guiGraphics, x, y, COOLDOWN_ICON_SIZE / 2f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * feature.cooldownPercent, alignAtCenter = false) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) - event.guiGraphics.drawAligned(font, formatTickDuration(feature.cooldown), TextAlign.TOP_CENTER, x + COOLDOWN_ICON_SIZE / 2f, y + COOLDOWN_ICON_SIZE + 1f, RGBAColor.WHITE) + event.guiGraphics.drawAligned(font, formatTickDuration(feature.cooldown), RenderGravity.TOP_CENTER, x + COOLDOWN_ICON_SIZE / 2f, y + COOLDOWN_ICON_SIZE + 1f, RGBAColor.WHITE) x += COOLDOWN_ICON_SIZE + COOLDOWN_ICON_MARGIN } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index 6e9372b08..53a4fc24d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -160,8 +160,8 @@ object MatteryGUI { val text = TranslatableComponent("otm.iteration", iteration) - minecraft.font.drawAligned(stack, text, TextAlign.CENTER_CENTER, x + 1f, y + 1f, RGBAColor.BLACK) - minecraft.font.drawAligned(stack, text, TextAlign.CENTER_CENTER, x, y, RGBAColor.WHITE) + minecraft.font.drawAligned(stack, text, RenderGravity.CENTER_CENTER, x + 1f, y + 1f, RGBAColor.BLACK) + minecraft.font.drawAligned(stack, text, RenderGravity.CENTER_CENTER, x, y, RGBAColor.WHITE) stack.scale(0.35f, 0.35f, 0.35f) @@ -177,8 +177,8 @@ object MatteryGUI { for (i in deathLog.indices.reversed()) { val component = deathLog[i] - minecraft.font.drawAligned(stack, component.second, TextAlign.CENTER_CENTER, x + 1f, y + 1f, RGBAColor.BLACK) - minecraft.font.drawAligned(stack, component.second, TextAlign.CENTER_CENTER, x, y, RGBAColor(color, color, color)) + minecraft.font.drawAligned(stack, component.second, RenderGravity.CENTER_CENTER, x + 1f, y + 1f, RGBAColor.BLACK) + minecraft.font.drawAligned(stack, component.second, RenderGravity.CENTER_CENTER, x, y, RGBAColor(color, color, color)) y += minecraft.font.lineHeight color = (color - 0x20).coerceAtLeast(0x0) @@ -249,8 +249,8 @@ object MatteryGUI { val formattedPower = mattery.androidEnergy.batteryLevel.formatPower() - event.guiGraphics.drawScaledAligned(gui.font, formattedPower, 0.5f, TextAlign.CENTER_LEFT, left + 83f, top + 4f, RGBAColor.BLACK.toInt()) - event.guiGraphics.drawScaledAligned(gui.font, formattedPower, 0.5f, TextAlign.CENTER_LEFT, left + 82f, top + 3f, RGBAColor.YELLOW.toInt()) + event.guiGraphics.drawScaledAligned(gui.font, formattedPower, 0.5f, RenderGravity.CENTER_LEFT, left + 83f, top + 4f, RGBAColor.BLACK.toInt()) + event.guiGraphics.drawScaledAligned(gui.font, formattedPower, 0.5f, RenderGravity.CENTER_LEFT, left + 82f, top + 3f, RGBAColor.YELLOW.toInt()) } } @@ -325,8 +325,8 @@ object MatteryGUI { if (ply.absorptionAmount > 0) formattedHealth = "%d+%d/%d".format(ply.health.toInt(), ply.absorptionAmount.toInt(), ply.maxHealth.toInt()) - event.guiGraphics.drawScaledAligned(minecraft.font, formattedHealth, 0.5f, TextAlign.CENTER_RIGHT, left - 4f, top + 4f, RGBAColor.BLACK.toInt()) - event.guiGraphics.drawScaledAligned(minecraft.font, formattedHealth, 0.5f, TextAlign.CENTER_RIGHT, left - 5f, top + 3f, getHealthColorForPlayer(ply)) + event.guiGraphics.drawScaledAligned(minecraft.font, formattedHealth, 0.5f, RenderGravity.CENTER_RIGHT, left - 4f, top + 4f, RGBAColor.BLACK.toInt()) + event.guiGraphics.drawScaledAligned(minecraft.font, formattedHealth, 0.5f, RenderGravity.CENTER_RIGHT, left - 5f, top + 3f, getHealthColorForPlayer(ply)) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt index e82597258..3b331de9c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt @@ -17,7 +17,7 @@ import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.linearInterpolation import java.util.concurrent.ConcurrentHashMap -sealed class AbstractMatterySprite { +sealed class AbstractMatterySprite : IGUIRenderable { /** * Expected image width in pixels, used in calculations * and as default width argument in render methods @@ -76,7 +76,6 @@ sealed class AbstractMatterySprite { renderRaw(stack, x, y, width, height, winding) } - @JvmOverloads fun render( graphics: GuiGraphics, x: Float = 0f, @@ -88,6 +87,14 @@ sealed class AbstractMatterySprite { render(graphics.pose(), x, y, width, height, winding) } + override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float) { + return render(guiGraphics, x, y, width, height, winding) + } + + override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, gravity: RenderGravity) { + return render(guiGraphics, gravity.x(x, width), gravity.y(y, height), width, height, winding) + } + @JvmOverloads fun render( stack: PoseStack, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt index 4cc6ba666..fad69667b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt @@ -20,7 +20,6 @@ import ru.dbotthepony.mc.otm.core.math.rotateAroundThis import ru.dbotthepony.mc.otm.core.math.times import ru.dbotthepony.mc.otm.core.math.translation import ru.dbotthepony.mc.otm.core.math.unaryMinus -import kotlin.math.roundToInt val tesselator: Tesselator get() = Tesselator.getInstance() @@ -63,20 +62,6 @@ fun PoseStack.translation(): Vector3f { inline val PoseStack.last: PoseStack.Pose get() = last() inline val PoseStack.Pose.pose: Matrix4f get() = pose() -enum class TextAlign { - TOP_LEFT, - TOP_CENTER, - TOP_RIGHT, - - CENTER_LEFT, - CENTER_CENTER, - CENTER_RIGHT, - - BOTTOM_LEFT, - BOTTOM_CENTER, - BOTTOM_RIGHT, -} - private fun Font.drawScaledDuckTyped(poseStack: PoseStack, text: Any, scale: Float, x: Float, y: Float, color: Int): Int { val translation = poseStack.translation() @@ -152,27 +137,15 @@ private fun Font.widthDuckTyped(text: Any): Int { } } -private fun Font.drawAlignedDuckTyped(poseStack: PoseStack, text: Any, align: TextAlign, x: Float, y: Float, color: Int): Int { - return when (align) { - TextAlign.TOP_LEFT -> drawDuckTyped(poseStack, text, x, y, color) - TextAlign.TOP_CENTER -> drawDuckTyped(poseStack, text, (x - widthDuckTyped(text) / 2f), y, color) - TextAlign.TOP_RIGHT -> drawDuckTyped(poseStack, text, (x - widthDuckTyped(text)), y, color) - - TextAlign.CENTER_LEFT -> drawDuckTyped(poseStack, text, x, (y - lineHeight / 2f), color) - TextAlign.CENTER_CENTER -> drawDuckTyped(poseStack, text, (x - widthDuckTyped(text) / 2f), (y - lineHeight / 2f), color) - TextAlign.CENTER_RIGHT -> drawDuckTyped(poseStack, text, (x - widthDuckTyped(text)), (y - lineHeight / 2f), color) - - TextAlign.BOTTOM_LEFT -> drawDuckTyped(poseStack, text, x, (y - lineHeight), color) - TextAlign.BOTTOM_CENTER -> drawDuckTyped(poseStack, text, (x - widthDuckTyped(text) / 2f), (y - lineHeight), color) - TextAlign.BOTTOM_RIGHT -> drawDuckTyped(poseStack, text, (x - widthDuckTyped(text)), (y - lineHeight), color) - } +private fun Font.drawAlignedDuckTyped(poseStack: PoseStack, text: Any, align: RenderGravity, x: Float, y: Float, color: Int): Int { + return drawDuckTyped(poseStack, text, align.x(x, widthDuckTyped(text)), align.y(y, lineHeight), color) } private fun Font.drawAlignedDuckTyped( poseStack: PoseStack, buffer: MultiBufferSource, text: Any, - align: TextAlign, + align: RenderGravity, x: Float, y: Float, color: Int, @@ -181,25 +154,13 @@ private fun Font.drawAlignedDuckTyped( packedLightCoords: Int = 15728880, effectColor: Int = 0 ): Int { - return when (align) { - TextAlign.TOP_LEFT -> drawDuckTyped(poseStack, buffer, text, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.TOP_CENTER -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text) / 2f), y, color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.TOP_RIGHT -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text)), y, color, drawShadow, displayMode, packedLightCoords, effectColor) - - TextAlign.CENTER_LEFT -> drawDuckTyped(poseStack, buffer, text, x, (y - lineHeight / 2f), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.CENTER_CENTER -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text) / 2f), (y - lineHeight / 2f), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.CENTER_RIGHT -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text)), (y - lineHeight / 2f), color, drawShadow, displayMode, packedLightCoords, effectColor) - - TextAlign.BOTTOM_LEFT -> drawDuckTyped(poseStack, buffer, text, x, (y - lineHeight), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.BOTTOM_CENTER -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text) / 2f), (y - lineHeight), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.BOTTOM_RIGHT -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text)), (y - lineHeight), color, drawShadow, displayMode, packedLightCoords, effectColor) - } + return drawDuckTyped(poseStack, buffer, text, align.x(x, widthDuckTyped(text)), align.y(y, lineHeight), color, drawShadow, displayMode, packedLightCoords, effectColor) } private fun GuiGraphics.drawAlignedDuckTyped( font: Font, text: Any, - align: TextAlign, + align: RenderGravity, x: Float, y: Float, color: Int, @@ -208,39 +169,13 @@ private fun GuiGraphics.drawAlignedDuckTyped( packedLightCoords: Int = 15728880, effectColor: Int = 0 ): Int { - val width = when (align) { - TextAlign.TOP_LEFT -> font.drawDuckTyped(pose(), bufferSource(), text, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.TOP_CENTER -> font.drawDuckTyped(pose(), bufferSource(), text, (x - font.widthDuckTyped(text) / 2f), y, color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.TOP_RIGHT -> font.drawDuckTyped(pose(), bufferSource(), text, (x - font.widthDuckTyped(text)), y, color, drawShadow, displayMode, packedLightCoords, effectColor) - - TextAlign.CENTER_LEFT -> font.drawDuckTyped(pose(), bufferSource(), text, x, (y - font.lineHeight / 2f), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.CENTER_CENTER -> font.drawDuckTyped(pose(), bufferSource(), text, (x - font.widthDuckTyped(text) / 2f), (y - font.lineHeight / 2f), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.CENTER_RIGHT -> font.drawDuckTyped(pose(), bufferSource(), text, (x - font.widthDuckTyped(text)), (y - font.lineHeight / 2f), color, drawShadow, displayMode, packedLightCoords, effectColor) - - TextAlign.BOTTOM_LEFT -> font.drawDuckTyped(pose(), bufferSource(), text, x, (y - font.lineHeight), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.BOTTOM_CENTER -> font.drawDuckTyped(pose(), bufferSource(), text, (x - font.widthDuckTyped(text) / 2f), (y - font.lineHeight), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.BOTTOM_RIGHT -> font.drawDuckTyped(pose(), bufferSource(), text, (x - font.widthDuckTyped(text)), (y - font.lineHeight), color, drawShadow, displayMode, packedLightCoords, effectColor) - } - + val width = font.drawDuckTyped(pose(), bufferSource(), text, align.x(x, font.widthDuckTyped(text)), align.y(y, font.lineHeight), color, drawShadow, displayMode, packedLightCoords, effectColor) flush() - return width } -private fun Font.drawScaledAlignedDuckTyped(poseStack: PoseStack, text: Any, scale: Float, align: TextAlign, x: Float, y: Float, color: Int): Int { - return when (align) { - TextAlign.TOP_LEFT -> drawScaledDuckTyped(poseStack, text, scale, x, y, color) - TextAlign.TOP_CENTER -> drawScaledDuckTyped(poseStack, text, scale, (x - widthDuckTyped(text) * scale / 2f), y, color) - TextAlign.TOP_RIGHT -> drawScaledDuckTyped(poseStack, text, scale, (x - widthDuckTyped(text) * scale), y, color) - - TextAlign.CENTER_LEFT -> drawScaledDuckTyped(poseStack, text, scale, x, (y - lineHeight / 2f * scale), color) - TextAlign.CENTER_CENTER -> drawScaledDuckTyped(poseStack, text, scale, (x - widthDuckTyped(text) * scale / 2f), (y - lineHeight * scale / 2f), color) - TextAlign.CENTER_RIGHT -> drawScaledDuckTyped(poseStack, text, scale, (x - widthDuckTyped(text) * scale), (y - lineHeight * scale / 2f), color) - - TextAlign.BOTTOM_LEFT -> drawScaledDuckTyped(poseStack, text, scale, x, (y - lineHeight * scale), color) - TextAlign.BOTTOM_CENTER -> drawScaledDuckTyped(poseStack, text, scale, (x - widthDuckTyped(text) * scale / 2f), (y - lineHeight * scale), color) - TextAlign.BOTTOM_RIGHT -> drawScaledDuckTyped(poseStack, text, scale, (x - widthDuckTyped(text) * scale), (y - lineHeight * scale), color) - } +private fun Font.drawScaledAlignedDuckTyped(poseStack: PoseStack, text: Any, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int): Int { + return drawScaledDuckTyped(poseStack, text, scale, align.x(x, widthDuckTyped(text)), align.y(y, lineHeight * scale), color) } private fun Font.drawScaledAlignedDuckTyped( @@ -248,7 +183,7 @@ private fun Font.drawScaledAlignedDuckTyped( buffer: MultiBufferSource, text: Any, scale: Float, - align: TextAlign, + align: RenderGravity, x: Float, y: Float, color: Int, @@ -257,26 +192,14 @@ private fun Font.drawScaledAlignedDuckTyped( packedLightCoords: Int = 15728880, effectColor: Int = 0 ): Int { - return when (align) { - TextAlign.TOP_LEFT -> drawScaledDuckTyped(poseStack, buffer, text, scale, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.TOP_CENTER -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale / 2f), y, color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.TOP_RIGHT -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale), y, color, drawShadow, displayMode, packedLightCoords, effectColor) - - TextAlign.CENTER_LEFT -> drawScaledDuckTyped(poseStack, buffer, text, scale, x, (y - lineHeight / 2f * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.CENTER_CENTER -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale / 2f), (y - lineHeight * scale / 2f), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.CENTER_RIGHT -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale), (y - lineHeight * scale / 2f), color, drawShadow, displayMode, packedLightCoords, effectColor) - - TextAlign.BOTTOM_LEFT -> drawScaledDuckTyped(poseStack, buffer, text, scale, x, (y - lineHeight * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.BOTTOM_CENTER -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale / 2f), (y - lineHeight * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.BOTTOM_RIGHT -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale), (y - lineHeight * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) - } + return drawScaledDuckTyped(poseStack, buffer, text, scale, align.x(x, widthDuckTyped(text) * scale), align.y(y, lineHeight * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) } private fun GuiGraphics.drawScaledAlignedDuckTyped( font: Font, text: Any, scale: Float, - align: TextAlign, + align: RenderGravity, x: Float, y: Float, color: Int, @@ -285,69 +208,55 @@ private fun GuiGraphics.drawScaledAlignedDuckTyped( packedLightCoords: Int = 15728880, effectColor: Int = 0 ): Int { - val width = when (align) { - TextAlign.TOP_LEFT -> font.drawScaledDuckTyped(pose(), bufferSource(), text, scale, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.TOP_CENTER -> font.drawScaledDuckTyped(pose(), bufferSource(), text, scale, (x - font.widthDuckTyped(text) * scale / 2f), y, color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.TOP_RIGHT -> font.drawScaledDuckTyped(pose(), bufferSource(), text, scale, (x - font.widthDuckTyped(text) * scale), y, color, drawShadow, displayMode, packedLightCoords, effectColor) - - TextAlign.CENTER_LEFT -> font.drawScaledDuckTyped(pose(), bufferSource(), text, scale, x, (y - font.lineHeight / 2f * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.CENTER_CENTER -> font.drawScaledDuckTyped(pose(), bufferSource(), text, scale, (x - font.widthDuckTyped(text) * scale / 2f), (y - font.lineHeight * scale / 2f), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.CENTER_RIGHT -> font.drawScaledDuckTyped(pose(), bufferSource(), text, scale, (x - font.widthDuckTyped(text) * scale), (y - font.lineHeight * scale / 2f), color, drawShadow, displayMode, packedLightCoords, effectColor) - - TextAlign.BOTTOM_LEFT -> font.drawScaledDuckTyped(pose(), bufferSource(), text, scale, x, (y - font.lineHeight * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.BOTTOM_CENTER -> font.drawScaledDuckTyped(pose(), bufferSource(), text, scale, (x - font.widthDuckTyped(text) * scale / 2f), (y - font.lineHeight * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) - TextAlign.BOTTOM_RIGHT -> font.drawScaledDuckTyped(pose(), bufferSource(), text, scale, (x - font.widthDuckTyped(text) * scale), (y - font.lineHeight * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) - } - + val width = font.drawScaledDuckTyped(pose(), bufferSource(), text, scale, align.x(x, font.widthDuckTyped(text) * scale), align.y(y, font.lineHeight * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) flush() - return width } -fun Font.drawAligned(poseStack: PoseStack, text: String, align: TextAlign, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(poseStack, text, align, x, y, color) -fun Font.drawAligned(poseStack: PoseStack, text: Component, align: TextAlign, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(poseStack, text, align, x, y, color) -fun Font.drawAligned(poseStack: PoseStack, text: FormattedCharSequence, align: TextAlign, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(poseStack, text, align, x, y, color) +fun Font.drawAligned(poseStack: PoseStack, text: String, align: RenderGravity, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(poseStack, text, align, x, y, color) +fun Font.drawAligned(poseStack: PoseStack, text: Component, align: RenderGravity, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(poseStack, text, align, x, y, color) +fun Font.drawAligned(poseStack: PoseStack, text: FormattedCharSequence, align: RenderGravity, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(poseStack, text, align, x, y, color) -fun Font.drawAligned(poseStack: PoseStack, text: String, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawAligned(poseStack, text, align, x, y, color.toInt()) -fun Font.drawAligned(poseStack: PoseStack, text: Component, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawAligned(poseStack, text, align, x, y, color.toInt()) -fun Font.drawAligned(poseStack: PoseStack, text: FormattedCharSequence, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawAligned(poseStack, text, align, x, y, color.toInt()) +fun Font.drawAligned(poseStack: PoseStack, text: String, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawAligned(poseStack, text, align, x, y, color.toInt()) +fun Font.drawAligned(poseStack: PoseStack, text: Component, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawAligned(poseStack, text, align, x, y, color.toInt()) +fun Font.drawAligned(poseStack: PoseStack, text: FormattedCharSequence, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawAligned(poseStack, text, align, x, y, color.toInt()) -fun Font.drawScaledAligned(poseStack: PoseStack, text: String, scale: Float, align: TextAlign, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(poseStack, text, scale, align, x, y, color) -fun Font.drawScaledAligned(poseStack: PoseStack, text: Component, scale: Float, align: TextAlign, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(poseStack, text, scale, align, x, y, color) -fun Font.drawScaledAligned(poseStack: PoseStack, text: FormattedCharSequence, scale: Float, align: TextAlign, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(poseStack, text, scale, align, x, y, color) +fun Font.drawScaledAligned(poseStack: PoseStack, text: String, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(poseStack, text, scale, align, x, y, color) +fun Font.drawScaledAligned(poseStack: PoseStack, text: Component, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(poseStack, text, scale, align, x, y, color) +fun Font.drawScaledAligned(poseStack: PoseStack, text: FormattedCharSequence, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(poseStack, text, scale, align, x, y, color) -fun Font.drawScaledAligned(poseStack: PoseStack, text: String, scale: Float, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(poseStack, text, scale, align, x, y, color.toInt()) -fun Font.drawScaledAligned(poseStack: PoseStack, text: Component, scale: Float, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(poseStack, text, scale, align, x, y, color.toInt()) -fun Font.drawScaledAligned(poseStack: PoseStack, text: FormattedCharSequence, scale: Float, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(poseStack, text, scale, align, x, y, color.toInt()) +fun Font.drawScaledAligned(poseStack: PoseStack, text: String, scale: Float, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(poseStack, text, scale, align, x, y, color.toInt()) +fun Font.drawScaledAligned(poseStack: PoseStack, text: Component, scale: Float, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(poseStack, text, scale, align, x, y, color.toInt()) +fun Font.drawScaledAligned(poseStack: PoseStack, text: FormattedCharSequence, scale: Float, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(poseStack, text, scale, align, x, y, color.toInt()) -fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAlignedDuckTyped(poseStack, buffer, text, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAlignedDuckTyped(poseStack, buffer, text, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAlignedDuckTyped(poseStack, buffer, text, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) +fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, align: RenderGravity, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAlignedDuckTyped(poseStack, buffer, text, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) +fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, align: RenderGravity, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAlignedDuckTyped(poseStack, buffer, text, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) +fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, align: RenderGravity, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAlignedDuckTyped(poseStack, buffer, text, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, align: TextAlign, x: Float, y: Float, color: RGBAColor, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAligned(poseStack, buffer, text, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, align: TextAlign, x: Float, y: Float, color: RGBAColor, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAligned(poseStack, buffer, text, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, align: TextAlign, x: Float, y: Float, color: RGBAColor, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAligned(poseStack, buffer, text, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) +fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, align: RenderGravity, x: Float, y: Float, color: RGBAColor, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAligned(poseStack, buffer, text, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) +fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, align: RenderGravity, x: Float, y: Float, color: RGBAColor, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAligned(poseStack, buffer, text, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) +fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, align: RenderGravity, x: Float, y: Float, color: RGBAColor, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAligned(poseStack, buffer, text, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, scale: Float, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0,) = drawScaledAlignedDuckTyped(poseStack, buffer, text, scale, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, scale: Float, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0,) = drawScaledAlignedDuckTyped(poseStack, buffer, text, scale, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, scale: Float, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0,) = drawScaledAlignedDuckTyped(poseStack, buffer, text, scale, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) +fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0,) = drawScaledAlignedDuckTyped(poseStack, buffer, text, scale, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) +fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0,) = drawScaledAlignedDuckTyped(poseStack, buffer, text, scale, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) +fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0,) = drawScaledAlignedDuckTyped(poseStack, buffer, text, scale, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, scale: Float, align: TextAlign, x: Float, y: Float, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, scale: Float, align: TextAlign, x: Float, y: Float, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, scale: Float, align: TextAlign, x: Float, y: Float, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) +fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, scale: Float, align: RenderGravity, x: Float, y: Float, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) +fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, scale: Float, align: RenderGravity, x: Float, y: Float, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) +fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, scale: Float, align: RenderGravity, x: Float, y: Float, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) -fun GuiGraphics.drawAligned(font: Font, text: String, align: TextAlign, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(font, text, align, x, y, color) -fun GuiGraphics.drawAligned(font: Font, text: Component, align: TextAlign, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(font, text, align, x, y, color) -fun GuiGraphics.drawAligned(font: Font, text: FormattedCharSequence, align: TextAlign, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(font, text, align, x, y, color) +fun GuiGraphics.drawAligned(font: Font, text: String, align: RenderGravity, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(font, text, align, x, y, color) +fun GuiGraphics.drawAligned(font: Font, text: Component, align: RenderGravity, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(font, text, align, x, y, color) +fun GuiGraphics.drawAligned(font: Font, text: FormattedCharSequence, align: RenderGravity, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(font, text, align, x, y, color) -fun GuiGraphics.drawAligned(font: Font, text: String, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawAligned(font, text, align, x, y, color.toInt()) -fun GuiGraphics.drawAligned(font: Font, text: Component, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawAligned(font, text, align, x, y, color.toInt()) -fun GuiGraphics.drawAligned(font: Font, text: FormattedCharSequence, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawAligned(font, text, align, x, y, color.toInt()) +fun GuiGraphics.drawAligned(font: Font, text: String, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawAligned(font, text, align, x, y, color.toInt()) +fun GuiGraphics.drawAligned(font: Font, text: Component, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawAligned(font, text, align, x, y, color.toInt()) +fun GuiGraphics.drawAligned(font: Font, text: FormattedCharSequence, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawAligned(font, text, align, x, y, color.toInt()) -fun GuiGraphics.drawScaledAligned(font: Font, text: String, scale: Float, align: TextAlign, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(font, text, scale, align, x, y, color) -fun GuiGraphics.drawScaledAligned(font: Font, text: Component, scale: Float, align: TextAlign, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(font, text, scale, align, x, y, color) -fun GuiGraphics.drawScaledAligned(font: Font, text: FormattedCharSequence, scale: Float, align: TextAlign, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(font, text, scale, align, x, y, color) +fun GuiGraphics.drawScaledAligned(font: Font, text: String, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(font, text, scale, align, x, y, color) +fun GuiGraphics.drawScaledAligned(font: Font, text: Component, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(font, text, scale, align, x, y, color) +fun GuiGraphics.drawScaledAligned(font: Font, text: FormattedCharSequence, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(font, text, scale, align, x, y, color) -fun GuiGraphics.drawScaledAligned(font: Font, text: String, scale: Float, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(font, text, scale, align, x, y, color.toInt()) -fun GuiGraphics.drawScaledAligned(font: Font, text: Component, scale: Float, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(font, text, scale, align, x, y, color.toInt()) -fun GuiGraphics.drawScaledAligned(font: Font, text: FormattedCharSequence, scale: Float, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(font, text, scale, align, x, y, color.toInt()) +fun GuiGraphics.drawScaledAligned(font: Font, text: String, scale: Float, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(font, text, scale, align, x, y, color.toInt()) +fun GuiGraphics.drawScaledAligned(font: Font, text: Component, scale: Float, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(font, text, scale, align, x, y, color.toInt()) +fun GuiGraphics.drawScaledAligned(font: Font, text: FormattedCharSequence, scale: Float, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(font, text, scale, align, x, y, color.toInt()) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt new file mode 100644 index 000000000..716d9a1c2 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt @@ -0,0 +1,64 @@ +package ru.dbotthepony.mc.otm.client.render + +import net.minecraft.client.gui.GuiGraphics +import net.minecraft.world.item.ItemStack + +interface IGUIRenderable { + fun render(guiGraphics: GuiGraphics, x: Float, y: Float, gravity: RenderGravity = RenderGravity.TOP_LEFT) + + /** + * Render at specified [x], [y] with fixed [width] x [height] + */ + fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float) + + fun composeBefore(other: IGUIRenderable): IGUIRenderable { + return object : IGUIRenderable { + override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, gravity: RenderGravity) { + this@IGUIRenderable.render(guiGraphics, x, y, gravity) + other.render(guiGraphics, x, y, gravity) + } + + override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float) { + this@IGUIRenderable.render(guiGraphics, x, y, width, height) + other.render(guiGraphics, x, y, width, height) + } + } + } + + fun composeAfter(other: IGUIRenderable): IGUIRenderable { + return other.composeBefore(this) + } + + companion object { + fun of(value: ItemStack, width: Float = 16f, height: Float = 16f): IGUIRenderable { + return ItemStackIcon(value, width, height) + } + + fun of(value: IGUIRenderable): IGUIRenderable { + return value + } + } +} + +data class ItemStackIcon(private val itemStack: ItemStack, val width: Float = 16f, val height: Float = 16f) : IGUIRenderable { + override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, gravity: RenderGravity) { + return render(guiGraphics, gravity.x(x, width), gravity.y(y, height), width, height) + } + + override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float) { + if (x % 1f == 0f && y % 1f == 0f && width == 16f && height == 16f) { + guiGraphics.renderFakeItem(itemStack, x.toInt(), y.toInt()) + } else { + val pose = guiGraphics.pose() + + pose.pushPose() + pose.translate(x % 1f, y % 1f, 0f) + + if (width != 16f || height != 16f) + pose.scale(width / 16f, height / 16f, 1f) + + guiGraphics.renderFakeItem(itemStack, x.toInt(), y.toInt()) + pose.popPose() + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderGravity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderGravity.kt new file mode 100644 index 000000000..e3fbf8d71 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderGravity.kt @@ -0,0 +1,184 @@ +package ru.dbotthepony.mc.otm.client.render + +import ru.dbotthepony.mc.otm.core.FloatSupplier +import kotlin.math.roundToInt + +private operator fun FloatSupplier.div(other: Float): Float { + return getAsFloat() / other +} + +private operator fun Float.minus(other: FloatSupplier): Float { + return this - other.getAsFloat() +} + +enum class RenderGravity { + TOP_LEFT { + override fun x(x: Float, width: FloatSupplier): Float { + return x + } + + override fun y(y: Float, height: FloatSupplier): Float { + return y + } + + override fun x(x: Float, width: Float): Float { + return x + } + + override fun y(y: Float, height: Float): Float { + return y + } + }, + TOP_CENTER { + override fun x(x: Float, width: FloatSupplier): Float { + return x - width / 2f + } + + override fun y(y: Float, height: FloatSupplier): Float { + return y + } + + override fun x(x: Float, width: Float): Float { + return x - width / 2f + } + + override fun y(y: Float, height: Float): Float { + return y + } + }, + TOP_RIGHT { + override fun x(x: Float, width: FloatSupplier): Float { + return x - width + } + + override fun y(y: Float, height: FloatSupplier): Float { + return y + } + + override fun x(x: Float, width: Float): Float { + return x - width + } + + override fun y(y: Float, height: Float): Float { + return y + } + }, + + CENTER_LEFT { + override fun x(x: Float, width: FloatSupplier): Float { + return x + } + + override fun y(y: Float, height: FloatSupplier): Float { + return y - height / 2f + } + + override fun x(x: Float, width: Float): Float { + return x + } + + override fun y(y: Float, height: Float): Float { + return y - height / 2f + } + }, + CENTER_CENTER { + override fun x(x: Float, width: FloatSupplier): Float { + return x - width / 2f + } + + override fun y(y: Float, height: FloatSupplier): Float { + return y - height / 2f + } + + override fun x(x: Float, width: Float): Float { + return x - width / 2f + } + + override fun y(y: Float, height: Float): Float { + return y - height / 2f + } + }, + CENTER_RIGHT { + override fun x(x: Float, width: FloatSupplier): Float { + return x - width + } + + override fun y(y: Float, height: FloatSupplier): Float { + return y - height / 2f + } + + override fun x(x: Float, width: Float): Float { + return x - width + } + + override fun y(y: Float, height: Float): Float { + return y - height / 2f + } + }, + + BOTTOM_LEFT { + override fun x(x: Float, width: FloatSupplier): Float { + return x + } + + override fun y(y: Float, height: FloatSupplier): Float { + return y - height + } + + override fun x(x: Float, width: Float): Float { + return x + } + + override fun y(y: Float, height: Float): Float { + return y - height + } + }, + BOTTOM_CENTER { + override fun x(x: Float, width: FloatSupplier): Float { + return x - width / 2f + } + + override fun y(y: Float, height: FloatSupplier): Float { + return y - height + } + + override fun x(x: Float, width: Float): Float { + return x - width / 2f + } + + override fun y(y: Float, height: Float): Float { + return y - height + } + }, + BOTTOM_RIGHT { + override fun x(x: Float, width: FloatSupplier): Float { + return x - width + } + + override fun y(y: Float, height: FloatSupplier): Float { + return y - height + } + + override fun x(x: Float, width: Float): Float { + return x - width + } + + override fun y(y: Float, height: Float): Float { + return y - height + } + }; + + abstract fun x(x: Float, width: FloatSupplier): Float + abstract fun y(y: Float, height: FloatSupplier): Float + + abstract fun x(x: Float, width: Float): Float + abstract fun y(y: Float, height: Float): Float + + fun x(x: Float, width: Int): Float { + return x(x, width.toFloat()).roundToInt().toFloat() + } + + fun y(y: Float, height: Int): Float { + return y(y, height.toFloat()).roundToInt().toFloat() + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt index 09da620e7..a5ad2be22 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt @@ -185,11 +185,11 @@ class BlackHoleRenderer(private val context: BlockEntityRendererProvider.Context val sorse = DynamicBufferSource.WORLD - font.drawAligned(poseStack, sorse, text1, TextAlign.TOP_LEFT, 0.8f, 0.8f - font.lineHeight.toFloat() / 2f, 0x0) - font.drawAligned(poseStack, sorse, text2, TextAlign.TOP_LEFT, 0.8f, 0.8f + font.lineHeight.toFloat() / 2f, 0x0) + font.drawAligned(poseStack, sorse, text1, RenderGravity.TOP_LEFT, 0.8f, 0.8f - font.lineHeight.toFloat() / 2f, 0x0) + font.drawAligned(poseStack, sorse, text2, RenderGravity.TOP_LEFT, 0.8f, 0.8f + font.lineHeight.toFloat() / 2f, 0x0) poseStack.translate(0.0, 0.0, -1.0) - font.drawAligned(poseStack, sorse, text1, TextAlign.TOP_LEFT, 0f, -font.lineHeight.toFloat() / 2f, 0xFFFFFF) - font.drawAligned(poseStack, sorse, text2, TextAlign.TOP_LEFT, 0f, font.lineHeight.toFloat() / 2f, 0xFFFFFF) + font.drawAligned(poseStack, sorse, text1, RenderGravity.TOP_LEFT, 0f, -font.lineHeight.toFloat() / 2f, 0xFFFFFF) + font.drawAligned(poseStack, sorse, text2, RenderGravity.TOP_LEFT, 0f, font.lineHeight.toFloat() / 2f, 0xFFFFFF) poseStack.popPose() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/EnergyCounterRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/EnergyCounterRenderer.kt index fccd11b5c..378c3c998 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/EnergyCounterRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/EnergyCounterRenderer.kt @@ -48,21 +48,21 @@ class EnergyCounterRenderer(private val context: BlockEntityRendererProvider.Con var y = -16f - val finalX = font.drawAligned(poseStack, sorse, "00000000", TextAlign.CENTER_CENTER, -4f, y, RGBAColor.GRAY) - font.drawAligned(poseStack, sorse, "00000000", TextAlign.CENTER_CENTER, -4f, y + font.lineHeight, RGBAColor.GRAY) - font.drawAligned(poseStack, sorse, "/t", TextAlign.CENTER_LEFT, finalX.toFloat(), y, RGBAColor.GRAY) - font.drawAligned(poseStack, sorse, "/s", TextAlign.CENTER_LEFT, finalX.toFloat(), y + font.lineHeight, RGBAColor.GRAY) + val finalX = font.drawAligned(poseStack, sorse, "00000000", RenderGravity.CENTER_CENTER, -4f, y, RGBAColor.GRAY) + font.drawAligned(poseStack, sorse, "00000000", RenderGravity.CENTER_CENTER, -4f, y + font.lineHeight, RGBAColor.GRAY) + font.drawAligned(poseStack, sorse, "/t", RenderGravity.CENTER_LEFT, finalX.toFloat(), y, RGBAColor.GRAY) + font.drawAligned(poseStack, sorse, "/s", RenderGravity.CENTER_LEFT, finalX.toFloat(), y + font.lineHeight, RGBAColor.GRAY) poseStack.pushPose() poseStack.translate(-0.1, -0.1, -0.1) - font.drawAligned(poseStack, sorse, tile.lastTick.toString(0), TextAlign.CENTER_RIGHT, finalX.toFloat(), y, RGBAColor.WHITE) - font.drawAligned(poseStack, sorse, tile.sumHistory(20).toString(0), TextAlign.CENTER_RIGHT, finalX.toFloat(), y + font.lineHeight, RGBAColor.WHITE) + font.drawAligned(poseStack, sorse, tile.lastTick.toString(0), RenderGravity.CENTER_RIGHT, finalX.toFloat(), y, RGBAColor.WHITE) + font.drawAligned(poseStack, sorse, tile.sumHistory(20).toString(0), RenderGravity.CENTER_RIGHT, finalX.toFloat(), y + font.lineHeight, RGBAColor.WHITE) poseStack.popPose() y += font.lineHeight * 3 - font.drawAligned(poseStack, sorse, TOTAL, TextAlign.CENTER_CENTER, 0f, y, RGBAColor.WHITE) - font.drawAligned(poseStack, sorse, tile.passed.formatPower(), TextAlign.CENTER_CENTER, 0f, y + font.lineHeight, RGBAColor.WHITE) + font.drawAligned(poseStack, sorse, TOTAL, RenderGravity.CENTER_CENTER, 0f, y, RGBAColor.WHITE) + font.drawAligned(poseStack, sorse, tile.passed.formatPower(), RenderGravity.CENTER_CENTER, 0f, y + font.lineHeight, RGBAColor.WHITE) poseStack.popPose() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt index 1d58c78ca..f3031ecfa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt @@ -12,7 +12,6 @@ import net.minecraft.core.Direction import org.joml.Matrix4f import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.block.BlackHoleBlock -import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.tech.GravitationStabilizerBlockEntity import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState @@ -157,12 +156,12 @@ class GravitationStabilizerRenderer(private val context: BlockEntityRendererProv val sorse = DynamicBufferSource.WORLD val font = minecraft.font - font.drawAligned(poseStack, sorse, TranslatableComponent("otm.3d2d.gravitation_stabilizer.mass", bhTile.mass.formatMatter(formatAsReadable = ShiftPressedCond)), TextAlign.TOP_CENTER, 1f, -font.lineHeight.toFloat() / 2f + 1f, 0) - font.drawAligned(poseStack, sorse, TranslatableComponent("otm.3d2d.gravitation_stabilizer.strength", "%.2f".format(bhTile.gravitationStrength)), TextAlign.TOP_CENTER, 1f, font.lineHeight.toFloat() / 2f + 1f, 0) + font.drawAligned(poseStack, sorse, TranslatableComponent("otm.3d2d.gravitation_stabilizer.mass", bhTile.mass.formatMatter(formatAsReadable = ShiftPressedCond)), RenderGravity.TOP_CENTER, 1f, -font.lineHeight.toFloat() / 2f + 1f, 0) + font.drawAligned(poseStack, sorse, TranslatableComponent("otm.3d2d.gravitation_stabilizer.strength", "%.2f".format(bhTile.gravitationStrength)), RenderGravity.TOP_CENTER, 1f, font.lineHeight.toFloat() / 2f + 1f, 0) poseStack.translate(0.2f, 0f, -0.5f) - font.drawAligned(poseStack, sorse, TranslatableComponent("otm.3d2d.gravitation_stabilizer.mass", bhTile.mass.formatMatter(formatAsReadable = ShiftPressedCond)), TextAlign.TOP_CENTER, 0f, -font.lineHeight.toFloat() / 2f, 0xFFFFFF) - font.drawAligned(poseStack, sorse, TranslatableComponent("otm.3d2d.gravitation_stabilizer.strength", "%.2f".format(bhTile.gravitationStrength)), TextAlign.TOP_CENTER, 0f, font.lineHeight.toFloat() / 2f, 0xFFFFFF) + font.drawAligned(poseStack, sorse, TranslatableComponent("otm.3d2d.gravitation_stabilizer.mass", bhTile.mass.formatMatter(formatAsReadable = ShiftPressedCond)), RenderGravity.TOP_CENTER, 0f, -font.lineHeight.toFloat() / 2f, 0xFFFFFF) + font.drawAligned(poseStack, sorse, TranslatableComponent("otm.3d2d.gravitation_stabilizer.strength", "%.2f".format(bhTile.gravitationStrength)), RenderGravity.TOP_CENTER, 0f, font.lineHeight.toFloat() / 2f, 0xFFFFFF) poseStack.popPose() } 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 a482b3641..32994e002 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 @@ -7,7 +7,7 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity import ru.dbotthepony.mc.otm.client.font import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource -import ru.dbotthepony.mc.otm.client.render.TextAlign +import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.drawAligned import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.rotateWithBlockFacing @@ -37,7 +37,7 @@ class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context) var y = -totalHeight / 2f for (line in lines) { - font.drawAligned(poseStack = poseStack, buffer = sorse, text = line, align = TextAlign.TOP_CENTER, x = 0f, y = y, color = RGBAColor.YELLOW.toInt()) + font.drawAligned(poseStack = poseStack, buffer = sorse, text = line, align = RenderGravity.TOP_CENTER, x = 0f, y = y, color = RGBAColor.YELLOW.toInt()) y += font.lineHeight + 2f } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/entity/PlasmaProjectileRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/entity/PlasmaProjectileRenderer.kt index b13fb7963..583e1d519 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/entity/PlasmaProjectileRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/entity/PlasmaProjectileRenderer.kt @@ -5,7 +5,7 @@ import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.client.renderer.entity.EntityRenderer import net.minecraft.client.renderer.entity.EntityRendererProvider import net.minecraft.resources.ResourceLocation -import ru.dbotthepony.mc.otm.client.render.TextAlign +import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.drawAligned import ru.dbotthepony.mc.otm.client.render.rotateAroundPoint import ru.dbotthepony.mc.otm.client.render.translation @@ -30,7 +30,7 @@ class PlasmaProjectileRenderer(context: EntityRendererProvider.Context) : Entity pose.pushPose() pose.scale(0.03f, 0.03f, 0.03f) pose.rotateAroundPoint(pose.translation(), Angle.deg(roll = entity.xRot.toDouble(), yaw = entity.yRot.toDouble(), pitch = 180.0)) - font.drawAligned(pose, "PLASMA", TextAlign.CENTER_CENTER, 0f, 0f, 0xFFFFFF) + font.drawAligned(pose, "PLASMA", RenderGravity.CENTER_CENTER, 0f, 0f, 0xFFFFFF) pose.popPose() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt index 43447b8da..ae6778d90 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt @@ -1,23 +1,33 @@ package ru.dbotthepony.mc.otm.client.screen -import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.inventory.InventoryScreen +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.Items import ru.dbotthepony.mc.otm.client.mousePos import ru.dbotthepony.mc.otm.client.moveMousePosScaled +import ru.dbotthepony.mc.otm.client.render.ItemStackIcon import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.render.sprite import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.UserFilteredSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.BackgroundPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel +import ru.dbotthepony.mc.otm.client.screen.widget.HorizontalPowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalProfiledPowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.client.setMousePos import ru.dbotthepony.mc.otm.client.shouldOpenVanillaInventory import ru.dbotthepony.mc.otm.core.math.integerDivisionDown import ru.dbotthepony.mc.otm.menu.ExoPackInventoryMenu +import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.network.ExoPackMenuOpen import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel import yalter.mousetweaks.api.MouseTweaksDisableWheelTweak @@ -133,18 +143,74 @@ class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen( - this@ExoPackInventoryScreen, - craftingCanvas, - x = craftingSlotsCanvas.width, - width = craftingCanvas.width - resultPanel.width - craftingSlotsCanvas.width, - height = topLine.height - ) { - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { - CRAFT_ARROW.render(graphics, x = width / 2f - CRAFT_ARROW.width / 2f, y = height / 2f - CRAFT_ARROW.height / 2f) + SpritePanel(this, craftingCanvas, CRAFT_ARROW, x = craftingSlotsCanvas.width, + width = craftingCanvas.width - resultPanel.width - craftingSlotsCanvas.width, + height = topLine.height, centerSprite = true) + + if (menu.capability.isExoPackSmeltingInstalled) { + val craftingTab = frame.Tab() + val furnaceTab = frame.Tab() + + craftingTab.activeIcon = ItemStackIcon(ItemStack(Items.CRAFTING_TABLE)) + craftingTab.inactiveIcon = craftingTab.activeIcon + furnaceTab.activeIcon = ItemStackIcon(ItemStack(Items.FURNACE)) + furnaceTab.inactiveIcon = furnaceTab.activeIcon + + craftingTab.onOpen = Runnable { craftingCanvas.visible = true } + craftingTab.onClose = Runnable { craftingCanvas.visible = false } + + val furnaceCanvas = EditablePanel(this, topLine, width = 90f) + furnaceCanvas.dock = Dock.LEFT + furnaceCanvas.visible = false + + furnaceTab.onOpen = Runnable { furnaceCanvas.visible = true; menu.furnaceMenuOpenState.accept(true) } + furnaceTab.onClose = Runnable { furnaceCanvas.visible = false; menu.furnaceMenuOpenState.accept(false) } + + for (i in menu.capability.smelters.indices) { + val row = EditablePanel(this, furnaceCanvas, height = AbstractSlotPanel.SIZE) + row.dock = Dock.TOP + row.dockTop = 4f + + SlotPanel(this, row, menu.furnaceInputs[i]).also { + it.dock = Dock.LEFT + it.dockLeft = 12f + it.dockResize = DockResizeMode.NONE + } + + ProgressGaugePanel(this, row, menu.furnaceProgress[i]).also { + it.dock = Dock.LEFT + it.dockLeft = 9f + it.dockResize = DockResizeMode.NONE + } + + SlotPanel(this, row, menu.furnaceOutputs[i]).also { + it.dock = Dock.LEFT + it.dockLeft = 10f + it.dockResize = DockResizeMode.NONE + } } } + val chargeWidth = HorizontalPowerGaugePanel.GAUGE_BACKGROUND_TALL.width + AbstractSlotPanel.SIZE + 4f + ProgressGaugePanel.GAUGE_BACKGROUND.width + val chargeStrip = BackgroundPanel.paddedCenter(this, frame, frame.width / 2f - chargeWidth / 2f, frame.height + 2f, chargeWidth, AbstractSlotPanel.SIZE) + + chargeStrip.customDock { chargeStrip.setPos(frame.width / 2f - chargeWidth / 2f, frame.height + 2f) } + + BatterySlotPanel(this, chargeStrip, menu.exoPackPowerSlot).also { + it.dock = Dock.LEFT + } + + SpritePanel(this, chargeStrip, ProgressGaugePanel.GAUGE_BACKGROUND).also { + it.dock = Dock.LEFT + it.dockLeft = 2f + it.dockResize = DockResizeMode.NONE + } + + TallHorizontalProfiledPowerGaugePanel(this, chargeStrip, menu.exoPackPower).also { + it.dock = Dock.LEFT + it.dockLeft = 2f + } + scrollPanel.dock = Dock.RIGHT scrollPanel.setDockMargin(right = 3f) 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 c188af33e..add7aa7cb 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 @@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.client.screen.panels import com.google.common.collect.ImmutableList import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.systems.RenderSystem -import com.mojang.blaze3d.vertex.PoseStack import it.unimi.dsi.fastutil.ints.IntAVLTreeSet import it.unimi.dsi.fastutil.objects.ReferenceArraySet import net.minecraft.client.gui.ComponentPath @@ -550,6 +549,19 @@ open class EditablePanel @JvmOverloads constructor( return x < 0 || y < 0 || x + width > parent.width || y + height > parent.height } + private var once = false + set(value) { + if (value && field != value) { + if (updateVisibility) { + updateVisible() + } + + field = value + } + } + + private var updateVisibility = false + fun calculateAbsoluteRectangle(): Rect2f { if (scissor) { return Rect2f(absoluteX, absoluteY, width, height) @@ -703,7 +715,10 @@ open class EditablePanel @JvmOverloads constructor( } if (child.isVisible() != isVisible()) { - updateVisible() + if (once) + updateVisible() + else + updateVisibility = true } } @@ -768,6 +783,8 @@ open class EditablePanel @JvmOverloads constructor( } fun render(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + once = true + if (!isVisible()) { return } @@ -1145,6 +1162,21 @@ open class EditablePanel @JvmOverloads constructor( } updateBounds() + + for (child in visibleChildrenInternal) { + child.parentLayoutPerformed() + } + } + + private var repositioningCallback: Runnable? = null + + fun customDock(callback: Runnable?) { + if (callback != null) dock = Dock.NONE + repositioningCallback = callback + } + + open fun parentLayoutPerformed() { + repositioningCallback?.run() } fun updateBounds() { @@ -1656,6 +1688,7 @@ open class EditablePanel @JvmOverloads constructor( protected open fun tickInner() {} fun tick() { + once = true tickCount++ tickInner() @@ -1663,8 +1696,6 @@ open class EditablePanel @JvmOverloads constructor( for (child in Array(visibleChildrenInternal.size) { visibleChildrenInternal[it] }) { child.tick() } - - } var isRemoved = false diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt index bd84d5141..3cf406d10 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.client.screen.panels import com.mojang.blaze3d.systems.RenderSystem -import com.mojang.blaze3d.vertex.PoseStack import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap import it.unimi.dsi.fastutil.objects.Object2ObjectFunction import net.minecraft.client.gui.GuiGraphics @@ -11,7 +10,7 @@ import net.minecraft.world.effect.MobEffect import net.minecraft.world.effect.MobEffectInstance import net.minecraft.world.entity.LivingEntity import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.client.render.TextAlign +import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.determineTooltipPosition import ru.dbotthepony.mc.otm.client.render.drawAligned import ru.dbotthepony.mc.otm.client.render.drawScaledAligned @@ -118,7 +117,7 @@ open class EffectListPanel @JvmOverloads constructor( minecraft.mobEffectTextures.get(effect.effect).render(graphics, x = 3f, y = 3f, width = width - 6f, height = height - 6f) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) - graphics.drawScaledAligned(font, formatTickDuration(effect.duration), 0.75f, TextAlign.CENTER_CENTER, width / 2f - 1f, height / 2f, RGBAColor.WHITE) + graphics.drawScaledAligned(font, formatTickDuration(effect.duration), 0.75f, RenderGravity.CENTER_CENTER, width / 2f - 1f, height / 2f, RGBAColor.WHITE) } override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { @@ -146,8 +145,8 @@ open class EffectListPanel @JvmOverloads constructor( name.append(" ${effect.amplifier + 1}") } - graphics.drawAligned(font, name, TextAlign.TOP_LEFT, x + renderWidth + 12f, y + 7f, RGBAColor.WHITE) - graphics.drawAligned(font, formatTickDuration(effect.duration, true), TextAlign.TOP_LEFT, x + renderWidth + 12f, y + 7f + font.lineHeight + 2f, 8355711) + graphics.drawAligned(font, name, RenderGravity.TOP_LEFT, x + renderWidth + 12f, y + 7f, RGBAColor.WHITE) + graphics.drawAligned(font, formatTickDuration(effect.duration, true), RenderGravity.TOP_LEFT, x + renderWidth + 12f, y + 7f + font.lineHeight + 2f, 8355711) } return isHovered diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index ace546c82..cb35b2580 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.client.screen.panels import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.systems.RenderSystem -import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.narration.NarratableEntry import net.minecraft.client.gui.narration.NarratableEntry.NarrationPriority @@ -13,7 +12,6 @@ import org.lwjgl.opengl.GL30 import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.client.screen.panels.button.AbstractButtonPanel -import ru.dbotthepony.mc.otm.client.screen.panels.button.ButtonPanel open class FramePanel( screen: S, @@ -29,8 +27,8 @@ open class FramePanel( open inner class Tab( var onOpen: Runnable? = null, var onClose: Runnable? = null, - var activeIcon: AbstractMatterySprite? = null, - var inactiveIcon: AbstractMatterySprite? = null, + var activeIcon: IGUIRenderable? = null, + var inactiveIcon: IGUIRenderable? = null, ) : EditablePanel(this@FramePanel.screen, this@FramePanel, 0f, 0f, 28f, 28f) { var isActive = tabs.isEmpty() var initial = false @@ -54,7 +52,6 @@ open class FramePanel( } override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { - val stack = graphics.pose() val width: Float val height: Float @@ -88,10 +85,10 @@ open class FramePanel( ) val skinActive = activeIcon ?: return - skinActive.render(graphics, TAB_WIDTH_ACTIVE / 2f - skinActive.width / 2f, TAB_HEIGHT_ACTIVE / 2f - skinActive.height / 2f) + skinActive.render(graphics, TAB_WIDTH_ACTIVE / 2f, TAB_HEIGHT_ACTIVE / 2f, gravity = RenderGravity.CENTER_CENTER) } else { val skinInactive = inactiveIcon ?: return - skinInactive.render(graphics, width / 2f - skinInactive.width / 2f, TAB_HEIGHT_ACTIVE / 2f - skinInactive.height / 2f) + skinInactive.render(graphics, width / 2f, TAB_HEIGHT_ACTIVE / 2f, gravity = RenderGravity.CENTER_CENTER) } } @@ -259,7 +256,7 @@ open class FramePanel( // title val title = title ?: return RenderSystem.depthFunc(GL30.GL_ALWAYS) - graphics.drawAligned(font, title, TextAlign.TOP_LEFT, 8f, 5f, 4210752) + graphics.drawAligned(font, title, RenderGravity.TOP_LEFT, 8f, 5f, 4210752) RenderSystem.depthFunc(GL30.GL_ALWAYS) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt index a67574e2d..b21085fd3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt @@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component -import ru.dbotthepony.mc.otm.client.render.TextAlign +import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.drawAligned import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.math.RGBAColor @@ -29,35 +29,35 @@ open class Label @JvmOverloads constructor( } var color = RGBAColor.SLATE_GRAY - var align = TextAlign.TOP_LEFT + var align = RenderGravity.TOP_LEFT override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { clearDepth(graphics) if (shadow) { when (align) { - TextAlign.TOP_LEFT -> graphics.drawAligned(font, text, align, shadowX, shadowY, shadowColor.toInt()) - TextAlign.TOP_CENTER -> graphics.drawAligned(font, text, align, shadowX + width / 2f, shadowY, shadowColor.toInt()) - TextAlign.TOP_RIGHT -> graphics.drawAligned(font, text, align, shadowX + width, shadowY, shadowColor.toInt()) - TextAlign.CENTER_LEFT -> graphics.drawAligned(font, text, align, shadowX, height / 2f + shadowY, shadowColor.toInt()) - TextAlign.CENTER_CENTER -> graphics.drawAligned(font, text, align, shadowX + width / 2f, height / 2f + shadowY, shadowColor.toInt()) - TextAlign.CENTER_RIGHT -> graphics.drawAligned(font, text, align, shadowX + width, height / 2f + shadowY, shadowColor.toInt()) - TextAlign.BOTTOM_LEFT -> graphics.drawAligned(font, text, align, shadowX, height + shadowY, shadowColor.toInt()) - TextAlign.BOTTOM_CENTER -> graphics.drawAligned(font, text, align, shadowX + width / 2f, height + shadowY, shadowColor.toInt()) - TextAlign.BOTTOM_RIGHT -> graphics.drawAligned(font, text, align, shadowX + width, height + shadowY, shadowColor.toInt()) + RenderGravity.TOP_LEFT -> graphics.drawAligned(font, text, align, shadowX, shadowY, shadowColor.toInt()) + RenderGravity.TOP_CENTER -> graphics.drawAligned(font, text, align, shadowX + width / 2f, shadowY, shadowColor.toInt()) + RenderGravity.TOP_RIGHT -> graphics.drawAligned(font, text, align, shadowX + width, shadowY, shadowColor.toInt()) + RenderGravity.CENTER_LEFT -> graphics.drawAligned(font, text, align, shadowX, height / 2f + shadowY, shadowColor.toInt()) + RenderGravity.CENTER_CENTER -> graphics.drawAligned(font, text, align, shadowX + width / 2f, height / 2f + shadowY, shadowColor.toInt()) + RenderGravity.CENTER_RIGHT -> graphics.drawAligned(font, text, align, shadowX + width, height / 2f + shadowY, shadowColor.toInt()) + RenderGravity.BOTTOM_LEFT -> graphics.drawAligned(font, text, align, shadowX, height + shadowY, shadowColor.toInt()) + RenderGravity.BOTTOM_CENTER -> graphics.drawAligned(font, text, align, shadowX + width / 2f, height + shadowY, shadowColor.toInt()) + RenderGravity.BOTTOM_RIGHT -> graphics.drawAligned(font, text, align, shadowX + width, height + shadowY, shadowColor.toInt()) } } when (align) { - TextAlign.TOP_LEFT -> font.drawAligned(graphics.pose(), text, align, 0f, 0f, color.toInt()) - TextAlign.TOP_CENTER -> font.drawAligned(graphics.pose(), text, align, width / 2f, 0f, color.toInt()) - TextAlign.TOP_RIGHT -> font.drawAligned(graphics.pose(), text, align, width - (if (shadow) shadowX else 0f), 0f, color.toInt()) - TextAlign.CENTER_LEFT -> font.drawAligned(graphics.pose(), text, align, 0f, height / 2f, color.toInt()) - TextAlign.CENTER_CENTER -> font.drawAligned(graphics.pose(), text, align, width / 2f, height / 2f, color.toInt()) - TextAlign.CENTER_RIGHT -> font.drawAligned(graphics.pose(), text, align, width - (if (shadow) shadowX else 0f), height / 2f, color.toInt()) - TextAlign.BOTTOM_LEFT -> font.drawAligned(graphics.pose(), text, align, 0f, height, color.toInt()) - TextAlign.BOTTOM_CENTER -> font.drawAligned(graphics.pose(), text, align, width / 2f, height, color.toInt()) - TextAlign.BOTTOM_RIGHT -> font.drawAligned(graphics.pose(), text, align, width - (if (shadow) shadowX else 0f), height, color.toInt()) + RenderGravity.TOP_LEFT -> font.drawAligned(graphics.pose(), text, align, 0f, 0f, color.toInt()) + RenderGravity.TOP_CENTER -> font.drawAligned(graphics.pose(), text, align, width / 2f, 0f, color.toInt()) + RenderGravity.TOP_RIGHT -> font.drawAligned(graphics.pose(), text, align, width - (if (shadow) shadowX else 0f), 0f, color.toInt()) + RenderGravity.CENTER_LEFT -> font.drawAligned(graphics.pose(), text, align, 0f, height / 2f, color.toInt()) + RenderGravity.CENTER_CENTER -> font.drawAligned(graphics.pose(), text, align, width / 2f, height / 2f, color.toInt()) + RenderGravity.CENTER_RIGHT -> font.drawAligned(graphics.pose(), text, align, width - (if (shadow) shadowX else 0f), height / 2f, color.toInt()) + RenderGravity.BOTTOM_LEFT -> font.drawAligned(graphics.pose(), text, align, 0f, height, color.toInt()) + RenderGravity.BOTTOM_CENTER -> font.drawAligned(graphics.pose(), text, align, width / 2f, height, color.toInt()) + RenderGravity.BOTTOM_RIGHT -> font.drawAligned(graphics.pose(), text, align, width - (if (shadow) shadowX else 0f), height, color.toInt()) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SpritePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SpritePanel.kt index ba04c9a63..836444940 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SpritePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SpritePanel.kt @@ -13,9 +13,14 @@ class SpritePanel( y: Float = 0f, width: Float = sprite.width, height: Float = sprite.height, - val winding: UVWindingOrder = sprite.winding + var winding: UVWindingOrder = sprite.winding, + var centerSprite: Boolean = false ) : EditablePanel(screen, parent, x, y, width, height) { override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { - sprite.render(graphics, 0f, 0f, width, height, winding) + if (centerSprite) { + sprite.render(graphics, width / 2f - sprite.width / 2f, height / 2f - sprite.height / 2f, sprite.width, sprite.height, winding) + } else { + sprite.render(graphics, 0f, 0f, width, height, winding) + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt index 43d4485e0..94e07f8d9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt @@ -1,11 +1,9 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button -import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component -import ru.dbotthepony.mc.otm.client.playGuiClickSound -import ru.dbotthepony.mc.otm.client.render.TextAlign +import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.render.drawAligned import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel @@ -55,7 +53,7 @@ open class ButtonPanel( override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { renderStretchableBackground(graphics, mouseX, mouseY, partialTick) - graphics.drawAligned(font, label, TextAlign.CENTER_CENTER, width / 2f, height / 2f, textColor.toInt()) + graphics.drawAligned(font, label, RenderGravity.CENTER_CENTER, width / 2f, height / 2f, textColor.toInt()) } override fun sizeToContents() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt index 7fccf017b..c4372fe51 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt @@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.client.screen.panels.input import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.DefaultVertexFormat -import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.VertexFormat import it.unimi.dsi.fastutil.chars.Char2IntFunction import it.unimi.dsi.fastutil.chars.Char2IntOpenHashMap @@ -20,7 +19,7 @@ import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource -import ru.dbotthepony.mc.otm.client.render.TextAlign +import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.drawAligned import ru.dbotthepony.mc.otm.client.render.drawRect import ru.dbotthepony.mc.otm.client.render.tesselator @@ -1119,7 +1118,7 @@ open class TextInputPanel( graphics.drawAligned( font = font, text = placeholder, - align = TextAlign.TOP_LEFT, + align = RenderGravity.TOP_LEFT, x = dockPadding.left, y = y, color = placeholderColor @@ -1133,7 +1132,7 @@ open class TextInputPanel( graphics.drawAligned( font = font, text = line, - align = TextAlign.TOP_LEFT, + align = RenderGravity.TOP_LEFT, x = dockPadding.left, y = y, color = textColor @@ -1187,7 +1186,7 @@ open class TextInputPanel( graphics.drawAligned( font = font, text = "_", - align = TextAlign.TOP_LEFT, + align = RenderGravity.TOP_LEFT, x = dockPadding.left + (if (activeLine == null) 0f else font.width(activeLine).toFloat()), y = topPadding + (cursorLine - scrollLines) * (font.lineHeight + rowSpacing), color = cursorColor @@ -1196,7 +1195,7 @@ open class TextInputPanel( graphics.drawAligned( font = font, text = "|", - align = TextAlign.TOP_LEFT, + align = RenderGravity.TOP_LEFT, x = dockPadding.left + font.width(activeLine.substring(0, cursorRow)).toFloat() - 1f, y = topPadding + (cursorLine - scrollLines) * (font.lineHeight + rowSpacing), color = cursorColor @@ -1210,7 +1209,7 @@ open class TextInputPanel( graphics.drawAligned( font = font, text = cursorLine.toString(), - align = TextAlign.TOP_RIGHT, + align = RenderGravity.TOP_RIGHT, x = width, y = topPadding, color = cursorColor @@ -1219,7 +1218,7 @@ open class TextInputPanel( graphics.drawAligned( font = font, text = cursorRow.toString(), - align = TextAlign.TOP_RIGHT, + align = RenderGravity.TOP_RIGHT, x = width - dockPadding.right, y = topPadding + font.lineHeight + rowSpacing, color = cursorColor @@ -1228,7 +1227,7 @@ open class TextInputPanel( graphics.drawAligned( font = font, text = lines.size.toString(), - align = TextAlign.TOP_RIGHT, + align = RenderGravity.TOP_RIGHT, x = width - dockPadding.right, y = topPadding + font.lineHeight * 2f + rowSpacing * 2f, color = cursorColor diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt index e90c7aef0..f4b84dd1e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt @@ -21,7 +21,7 @@ abstract class AbstractSlotPanel> @JvmOverloads constru y: Float = 0f, width: Float = SIZE, height: Float = SIZE, - open val noItemIcon: MatterySprite? = null + open val noItemIcon: IGUIRenderable? = null ) : EditablePanel(screen, parent, x, y, width, height), IItemStackPanel { protected open fun renderSlotBackground(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { SLOT_BACKGROUND.render(graphics, width = width, height = height) @@ -51,7 +51,7 @@ abstract class AbstractSlotPanel> @JvmOverloads constru renderRegular(graphics, itemStack) if (itemStack.isEmpty) { - noItemIcon?.render(graphics, width = width, height = height) + noItemIcon?.render(graphics, 0f, 0f, width, height) } } 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 ab5ca2056..98fe73aac 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 @@ -11,6 +11,7 @@ import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.render.MatterySprite import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.render.drawRect @@ -29,7 +30,7 @@ open class SlotPanel, out T : Slot> @JvmOverloads const y: Float = 0f, width: Float = SIZE, height: Float = SIZE, - noItemIcon: MatterySprite? = null + noItemIcon: IGUIRenderable? = null ) : AbstractSlotPanel(screen, parent, x, y, width, height, noItemIcon), ISlotPanel { override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { screen.returnSlot = slot @@ -107,7 +108,7 @@ open class SlotPanel, out T : Slot> @JvmOverloads const RenderSystem.setShaderTexture(0, texture.atlasLocation()) graphics.blit(1, 1, 0, 16, 16, texture) } else { - noItemIcon?.render(graphics, width = width, height = height) + noItemIcon?.render(graphics, 0f, 0f, width = width, height = height) } } 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 a937153ab..7d51e8a86 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 @@ -1,8 +1,6 @@ package ru.dbotthepony.mc.otm.client.screen.tech import com.mojang.blaze3d.platform.InputConstants -import com.mojang.blaze3d.systems.RenderSystem -import com.mojang.blaze3d.vertex.PoseStack import it.unimi.dsi.fastutil.ints.Int2FloatAVLTreeMap import it.unimi.dsi.fastutil.ints.Int2ObjectFunction import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap @@ -12,7 +10,6 @@ import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack -import org.lwjgl.opengl.GL11 import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.android.AndroidResearch import ru.dbotthepony.mc.otm.android.AndroidResearchManager @@ -22,7 +19,7 @@ import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.playGuiClickSound -import ru.dbotthepony.mc.otm.client.render.TextAlign +import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.render.drawColor import ru.dbotthepony.mc.otm.client.render.drawLine @@ -35,7 +32,6 @@ import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.EquipmentBatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.DraggableCanvasPanel -import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.ifPresentK @@ -663,7 +659,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I init { dock = Dock.BOTTOM dockTop = 2f - align = TextAlign.TOP_RIGHT + align = RenderGravity.TOP_RIGHT } override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt index 2ae976f46..896c8513d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.client.screen.tech -import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.ChatFormatting import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component @@ -9,7 +8,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.render.MatteryAtlas -import ru.dbotthepony.mc.otm.client.render.TextAlign +import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty @@ -74,7 +73,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title init { dock = Dock.TOP dockMargin = DockProperty(bottom = 3f) - align = TextAlign.TOP_CENTER + align = RenderGravity.TOP_CENTER } override fun tickInner() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt index 2e46da76f..ceed77e88 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt @@ -14,7 +14,7 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Ingredient import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.client.render.TextAlign +import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.drawAligned import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel @@ -70,12 +70,12 @@ object PlatePressRecipeCategory : IRecipeCategory, IDrawable { mouseX: Double, mouseY: Double ) { - graphics.drawAligned(minecraft.font, TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), TextAlign.TOP_CENTER, 40f, 30f, RGBAColor.BLACK) + graphics.drawAligned(minecraft.font, TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), RenderGravity.TOP_CENTER, 40f, 30f, RGBAColor.BLACK) val average = recipe.experience.toString() if (average != "0.0") { - graphics.drawAligned(minecraft.font, TranslatableComponent("gui.jei.category.smelting.experience", average), TextAlign.TOP_CENTER, 40f, 1f, RGBAColor.BLACK) + graphics.drawAligned(minecraft.font, TranslatableComponent("gui.jei.category.smelting.experience", average), RenderGravity.TOP_CENTER, 40f, 1f, RGBAColor.BLACK) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ExopackConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ExopackConfig.kt new file mode 100644 index 000000000..ab652e63d --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ExopackConfig.kt @@ -0,0 +1,15 @@ +package ru.dbotthepony.mc.otm.config + +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.defineDecimal + +object ExopackConfig : AbstractConfig("exopack") { + val ENERGY_CAPACITY by builder + .comment("Internal battery capacity of Exopack") + .defineDecimal("ENERGY_CAPACITY", Decimal(400_000), Decimal.ZERO) + + val FURNACE_POWER_CONSUMPTION by builder + .comment("Power consumed per tick by built in furnace") + .comment("Vanilla furnace consumes 10 MtU/t (1 tick = 10 MtU, 1 Coal = 16 000 MtU,", "this ratio is utilized by almost all mods)") + .defineDecimal("FURNACE_POWER_CONSUMPTION", Decimal(20), Decimal.ZERO) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExoPackCraftingUpgradeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExopackUpgradeItem.kt similarity index 74% rename from src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExoPackCraftingUpgradeItem.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExopackUpgradeItem.kt index 86f904785..2c393c725 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExoPackCraftingUpgradeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExopackUpgradeItem.kt @@ -7,15 +7,23 @@ import net.minecraft.world.InteractionHand import net.minecraft.world.InteractionResultHolder import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.player.Player -import net.minecraft.world.item.* +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.Rarity +import net.minecraft.world.item.TooltipFlag +import net.minecraft.world.item.UseAnim import net.minecraft.world.level.Level -import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.runIfClient -class ExoPackCraftingUpgradeItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)) { +class ExopackUpgradeItem( + val type: MatteryPlayerCapability.UpgradeType, + val upgradeName: String, + val upgradedName: String, +) : Item(Properties().stacksTo(1).rarity(Rarity.RARE)) { override fun getUseDuration(p_41454_: ItemStack): Int { return 30 } @@ -36,13 +44,13 @@ class ExoPackCraftingUpgradeItem : Item(Properties().stacksTo(1).rarity(Rarity.R } val alreadyHas = runIfClient(true) { - minecraft.player?.matteryPlayer?.isExoPackCraftingUpgraded == true + type.prop.get(minecraft.player?.matteryPlayer ?: return@runIfClient false) } if (alreadyHas) { tooltip.add(TranslatableComponent("otm.gui.exopack_upgrades.already_activated").withStyle(ChatFormatting.DARK_RED)) } else { - tooltip.add(TranslatableComponent("otm.gui.exopack_upgrades.crafting_upgrade").withStyle(ChatFormatting.DARK_GREEN)) + tooltip.add(TranslatableComponent("otm.gui.exopack_upgrades.$upgradeName").withStyle(ChatFormatting.DARK_GREEN)) } } @@ -59,7 +67,7 @@ class ExoPackCraftingUpgradeItem : Item(Properties().stacksTo(1).rarity(Rarity.R if (player !is Player) return super.finishUsingItem(itemStack, level, player) val mattery = player.matteryPlayer ?: return super.finishUsingItem(itemStack, level, player) - if (!mattery.hasExoPack || mattery.isExoPackCraftingUpgraded) { + if (!mattery.hasExoPack || type.prop.get(mattery)) { return super.finishUsingItem(itemStack, level, player) } @@ -67,9 +75,8 @@ class ExoPackCraftingUpgradeItem : Item(Properties().stacksTo(1).rarity(Rarity.R itemStack.shrink(1) if (player is ServerPlayer) { - mattery.isExoPackCraftingUpgraded = true - - player.displayClientMessage(TranslatableComponent("otm.exopack_upgrades.crafting_upgraded").withStyle(ChatFormatting.DARK_GREEN), false) + type.prop.set(mattery, true) + player.displayClientMessage(TranslatableComponent("otm.exopack_upgrades.$upgradedName").withStyle(ChatFormatting.DARK_GREEN), false) } return itemStack diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt index 7c67f68e7..19c2c5f02 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt @@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.item.weapon import com.mojang.blaze3d.systems.RenderSystem import net.minecraft.client.Minecraft import net.minecraft.client.model.HumanoidModel -import net.minecraft.client.renderer.block.model.ItemTransforms import net.minecraft.nbt.CompoundTag import net.minecraft.network.FriendlyByteBuf import net.minecraft.server.level.ServerPlayer @@ -24,7 +23,7 @@ import net.minecraftforge.network.NetworkEvent import ru.dbotthepony.mc.otm.* import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.client.font -import ru.dbotthepony.mc.otm.client.render.TextAlign +import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.drawAligned import ru.dbotthepony.mc.otm.client.render.drawRect import ru.dbotthepony.mc.otm.client.render.setDrawColor @@ -468,7 +467,7 @@ abstract class AbstractWeaponItem(val tables: KClass, pr pose.translate(0.0, 0.0, -1.0) pose.scale(0.7f, 0.7f, 0.7f) val text = it.batteryLevel.formatPower() - font.drawAligned(pose, text, TextAlign.TOP_LEFT, 2f, 2f, RGBAColor.WHITE.toInt()) + font.drawAligned(pose, text, RenderGravity.TOP_LEFT, 2f, 2f, RGBAColor.WHITE.toInt()) pose.popPose() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt index 8e3c13dc0..4fd40ba70 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt @@ -4,14 +4,19 @@ import com.google.common.collect.ImmutableList import com.mojang.datafixers.util.Pair import net.minecraft.core.NonNullList import net.minecraft.resources.ResourceLocation +import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerPlayer import net.minecraft.world.Container +import net.minecraft.world.entity.ExperienceOrb import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.* import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.compat.curios.curiosSlots import ru.dbotthepony.mc.otm.container.iterator +import ru.dbotthepony.mc.otm.menu.input.InstantBooleanInput +import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.network.ExoSuitCarriedPacket import ru.dbotthepony.mc.otm.network.ExoSuitMenuInitPacket import ru.dbotthepony.mc.otm.network.ExoSuitSlotPacket @@ -102,6 +107,42 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen } } + private fun popFurnaceExp() { + if (capability.isExoPackSmeltingInstalled && capability.exoPackSmelterExperience >= 1f && !ply.level().isClientSide) { + val whole = capability.exoPackSmelterExperience.toInt() + capability.exoPackSmelterExperience -= whole + ExperienceOrb.award(ply.level() as ServerLevel, ply.position(), whole) + } + } + + val furnaceInputs: List = capability.smelters.map { + object : MatterySlot(it.input, 0) { + override fun mayPlace(itemStack: ItemStack): Boolean { + return super.mayPlace(itemStack) && capability.isExoPackSmeltingInstalled + } + } + } + + val furnaceOutputs: List = capability.smelters.map { + object : MachineOutputSlot(it.output, 0, onTake = ::popFurnaceExp) { + override fun mayPickup(player: Player): Boolean { + return super.mayPickup(player) && capability.isExoPackSmeltingInstalled + } + } + } + + val furnaceProgress = capability.smelters.map { ProgressGaugeWidget(mSynchronizer, it) } + val exoPackPowerSlot = BatterySlot(capability.exoPackEnergy.parent, 0) + val exoPackPower = ProfiledLevelGaugeWidget(mSynchronizer, capability.exoPackEnergy) + + val furnaceMenuOpenState = InstantBooleanInput(this) + + init { + addStorageSlot(furnaceInputs, condition = furnaceMenuOpenState) + addStorageSlot(furnaceOutputs, condition = furnaceMenuOpenState) + addSlot(exoPackPowerSlot) + } + private var isRemoved = false override fun slotsChanged(container: Container) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 0e4260970..cf4523b61 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -48,6 +48,7 @@ import ru.dbotthepony.mc.otm.core.util.IStreamCodec import ru.dbotthepony.mc.otm.core.util.ItemValueCodec import ru.dbotthepony.mc.otm.core.util.NullValueCodec import ru.dbotthepony.mc.otm.core.util.VarIntValueCodec +import ru.dbotthepony.mc.otm.menu.input.InstantBooleanInput import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel import ru.dbotthepony.mc.otm.network.MenuFieldPacket @@ -457,9 +458,9 @@ abstract class MatteryMenu @JvmOverloads protected constructor( return slot } - protected fun addStorageSlot(slot: Iterable, addMapping: Boolean = true) { + protected fun addStorageSlot(slot: Iterable, addMapping: Boolean = true, prepend: Boolean = false, condition: BooleanSupplier = BooleanSupplier { true }) { for (value in slot) - addStorageSlot(value, addMapping) + addStorageSlot(value, addMapping, prepend, condition) } /** @@ -762,8 +763,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( val syncContainer = container ?: SimpleContainer(count) - var isOpen = false - val input = PlayerInput(BooleanValueCodec, allowSpectators = true, handler = { isOpen = it }) + val isOpen = InstantBooleanInput(this) return UpgradeSlots( slots = immutableList(count) { @@ -776,10 +776,10 @@ abstract class MatteryMenu @JvmOverloads protected constructor( return super.mayPlace(itemStack) && itemStack.getCapability(MatteryCapability.UPGRADE).map { it.upgradeTypes.any { allowedTypes[it]!!.boolean } }.orElse(false) } } - }.also { for (i in it.indices.reversed()) addStorageSlot(it[i], prepend = true, condition = { isOpen }) }, + }.also { for (i in it.indices.reversed()) addStorageSlot(it[i], prepend = true, condition = isOpen) }, allowedTypes = ConditionalEnumSet(allowedTypes), - openState = GetterSetter.of({ isOpen }, { input.input(it); isOpen = it }), + openState = isOpen, currentStats = object : IMatteryUpgrade { override val upgradeTypes: Set = setOf() override val speedBonus: Double by mSynchronizer.computedDouble(DoubleSupplier { container?.speedBonus ?: 0.0 }).property diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/InstantBooleanInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/InstantBooleanInput.kt new file mode 100644 index 000000000..49204ce6b --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/InstantBooleanInput.kt @@ -0,0 +1,25 @@ +package ru.dbotthepony.mc.otm.menu.input + +import ru.dbotthepony.mc.otm.core.GetterSetter +import ru.dbotthepony.mc.otm.menu.MatteryMenu +import java.util.function.BooleanSupplier + +class InstantBooleanInput(menu: MatteryMenu) : GetterSetter, BooleanSupplier { + var value = false + private set + + val input = menu.booleanInput(true) { value = it } + + override fun get(): Boolean { + return value + } + + override fun getAsBoolean(): Boolean { + return value + } + + override fun accept(t: Boolean) { + value = t + input.input(t) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt index 2cc385b8b..a86c4e5f4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt @@ -345,7 +345,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } } - private val dirtyFields = ReferenceArraySet>(fields.size) + private val dirtyFields = ReferenceArraySet>(4) // use LinkedList because it is ensured memory is freed on LinkedList#clear private val mapBacklogs = Reference2ObjectOpenHashMap, LinkedList Unit>>>() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt index 44a35bf41..dcbc6ac30 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt @@ -187,6 +187,7 @@ private fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { accept(MItems.EXOPACK_PROBE) accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_CREATIVE) accept(MItems.ExopackUpgrades.CRAFTING_UPGRADE) + accept(MItems.ExopackUpgrades.SMELTING_UPGRADE) accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_BIG) accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_HUGE) 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 ea6697944..4a5be5b0f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -14,13 +14,13 @@ 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.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.UpgradeType import ru.dbotthepony.mc.otm.config.ItemsConfig import ru.dbotthepony.mc.otm.core.collect.SupplierList import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.item.* -import ru.dbotthepony.mc.otm.item.exopack.ExoPackCraftingUpgradeItem import ru.dbotthepony.mc.otm.item.exopack.ExoPackProbeItem import ru.dbotthepony.mc.otm.item.exopack.ExoPackSlotUpgradeItem import ru.dbotthepony.mc.otm.item.matter.CreativePatternItem @@ -33,6 +33,7 @@ import ru.dbotthepony.mc.otm.item.tool.MatteryAxeItem import ru.dbotthepony.mc.otm.item.armor.PortableGravitationStabilizerItem import ru.dbotthepony.mc.otm.item.armor.SimpleTritaniumArmorItem import ru.dbotthepony.mc.otm.item.armor.TritaniumArmorItem +import ru.dbotthepony.mc.otm.item.exopack.ExopackUpgradeItem import ru.dbotthepony.mc.otm.item.exopack.ProceduralExoPackSlotUpgradeItem import ru.dbotthepony.mc.otm.item.weapon.PlasmaRifleItem @@ -500,7 +501,8 @@ object MItems { object ExopackUpgrades { val INVENTORY_UPGRADE_CREATIVE: Item by registry.register("exosuit_inventory_upgrade_creative") { ExoPackSlotUpgradeItem(null, 27, Rarity.EPIC) } - val CRAFTING_UPGRADE: Item by registry.register("exosuit_crafting_upgrade", ::ExoPackCraftingUpgradeItem) + val CRAFTING_UPGRADE: Item by registry.register("exosuit_crafting_upgrade") { ExopackUpgradeItem(MatteryPlayerCapability.UpgradeType.CRAFTING, "crafting_upgrade", "crafting_upgraded") } + val SMELTING_UPGRADE: Item by registry.register("exopack_smelting_upgrade") { ExopackUpgradeItem(MatteryPlayerCapability.UpgradeType.SMELTING, "smelting_upgrade", "smelting_installed") } val INVENTORY_UPGRADES = SupplierList(8) { registry.register("exosuit_inventory_upgrade_$it") { ExoPackSlotUpgradeItem(18, Rarity.COMMON) }::get From ccf2a162a36de49cb2f2dab2c5679b75a59bfa23 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 8 Jul 2023 00:57:16 +0700 Subject: [PATCH 0707/1199] Fix moveItemStackTo not calling onTake --- src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index cf4523b61..97b480caf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -577,11 +577,15 @@ abstract class MatteryMenu @JvmOverloads protected constructor( return false } + val copy = source.item.copy() + if (remainder.isEmpty) { source.set(ItemStack.EMPTY) + source.onTake(ply, copy) } else { + copy.count = source.item.count - remainder.count source.item.count = remainder.count - source.setChanged() + source.onTake(ply, copy) } return true From c9ef3e635b7c5486122ccab4cda5d6e4fbc01c34 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 8 Jul 2023 01:03:13 +0700 Subject: [PATCH 0708/1199] Make exopack smelters drop their slots and lose current progress on death --- .../otm/capability/MatteryPlayerCapability.kt | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index d1737afff..0dd420e4a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -1582,11 +1582,13 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial @JvmStatic fun inventoryDropAll(inventory: Inventory) { - if (inventory.player.matteryPlayer?.hasExoPack == false) { + val mattery = inventory.player.matteryPlayer ?: return + + if (!mattery.hasExoPack) { return } - val iterator = inventory.player.matteryPlayer?.exoPackContainer?.iterator() ?: return + val iterator = mattery.exoPackContainer.iterator() for (item in iterator) { if (!item.isEmpty) { @@ -1594,6 +1596,20 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial iterator.remove() } } + + for (smelter in mattery.smelters) { + if (!smelter.input[0].isEmpty) { + inventory.player.drop(smelter.input[0], true, false) + smelter.input[0] = ItemStack.EMPTY + } + + if (!smelter.output[0].isEmpty) { + inventory.player.drop(smelter.output[0], true, false) + smelter.output[0] = ItemStack.EMPTY + } + + smelter.currentJob = null + } } @JvmStatic From 84640e0ca4fa1dbcb76d8afbe79e776464877c1f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 8 Jul 2023 01:04:17 +0700 Subject: [PATCH 0709/1199] Do the same for inventory clear --- .../mc/otm/capability/MatteryPlayerCapability.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 0dd420e4a..3b7956141 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -1614,11 +1614,19 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial @JvmStatic fun inventoryClearContent(inventory: Inventory) { - if (inventory.player.matteryPlayer?.hasExoPack == false) { + val mattery = inventory.player.matteryPlayer ?: return + + if (!mattery.hasExoPack) { return } - inventory.player.matteryPlayer?.exoPackContainer?.clearContent() + mattery.exoPackContainer.clearContent() + + for (smelter in mattery.smelters) { + smelter.input.clearContent() + smelter.output.clearContent() + smelter.currentJob = null + } } @JvmStatic From e084221fde4050a32d90d2012146e2ee30327d77 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 8 Jul 2023 01:07:51 +0700 Subject: [PATCH 0710/1199] Remove unused hooks code --- .../otm/capability/MatteryPlayerCapability.kt | 50 ------------------- 1 file changed, 50 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 3b7956141..a5f3a3e6e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -1530,56 +1530,6 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial return iterator } - /** - * this method is hooked through coremod transformer - */ - @JvmStatic - fun inventoryAddItemHook(inventory: Inventory, item: ItemStack) { - if (item.isEmpty) { - return - } - - val it = inventory.player.matteryPlayer ?: return - - if (!it.hasExoPack) { - return - } - - val leftover = it.exoPackContainer.addItem(item, false, popTime = 5) - item.count = leftover.count - } - - /** - * this method is hooked through coremod transformer - */ - @JvmStatic - fun inventoryAddItemHookPre(inventory: Inventory, item: ItemStack) { - if (item.isEmpty || !item.isStackable) { - return - } - - val it = inventory.player.matteryPlayer ?: return - - if (!it.hasExoPack) { - return - } - - val leftover = it.exoPackContainer.addItem(item, simulate = false, onlyIntoExisting = true, popTime = 5) - item.count = leftover.count - } - - /** - * this method is hooked through coremod transformer - */ - @JvmStatic - fun inventoryAddDamagedItemHook(determinedSlot: Int, inventory: Inventory, item: ItemStack) { - if (determinedSlot > 0) { - return - } - - inventoryAddItemHook(inventory, item) - } - @JvmStatic fun inventoryDropAll(inventory: Inventory) { val mattery = inventory.player.matteryPlayer ?: return From 109145c3ce6fddb2d487bfa026d26630a82dc0a1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 8 Jul 2023 01:08:48 +0700 Subject: [PATCH 0711/1199] Clear depth after rendering item stack icons --- .../ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt index 716d9a1c2..44f5b5937 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt @@ -48,6 +48,7 @@ data class ItemStackIcon(private val itemStack: ItemStack, val width: Float = 16 override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float) { if (x % 1f == 0f && y % 1f == 0f && width == 16f && height == 16f) { guiGraphics.renderFakeItem(itemStack, x.toInt(), y.toInt()) + clearDepth(guiGraphics.pose(), x, y, width, height) } else { val pose = guiGraphics.pose() @@ -59,6 +60,8 @@ data class ItemStackIcon(private val itemStack: ItemStack, val width: Float = 16 guiGraphics.renderFakeItem(itemStack, x.toInt(), y.toInt()) pose.popPose() + + clearDepth(pose, x, y, width, height) } } } From f9c1258afebef7e22277d430d46fa7ed2922fc47 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 8 Jul 2023 01:12:42 +0700 Subject: [PATCH 0712/1199] Make FramePanel.Tab inherit actual button --- .../mc/otm/client/screen/panels/FramePanel.kt | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index cb35b2580..bd149b4e9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -29,7 +29,7 @@ open class FramePanel( var onClose: Runnable? = null, var activeIcon: IGUIRenderable? = null, var inactiveIcon: IGUIRenderable? = null, - ) : EditablePanel(this@FramePanel.screen, this@FramePanel, 0f, 0f, 28f, 28f) { + ) : AbstractButtonPanel(this@FramePanel.screen, this@FramePanel, 0f, 0f, 28f, 28f) { var isActive = tabs.isEmpty() var initial = false @@ -100,25 +100,20 @@ open class FramePanel( onClose?.run() } - override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { - if (isActive) { - return true - } - - for (tab in tabs) { - if (tab !== this) { - if (tab.isActive) { - tab.onClose() - tab.isActive = false + override fun onClick(mouseButton: Int) { + if (!isActive) { + for (tab in tabs) { + if (tab !== this) { + if (tab.isActive) { + tab.onClose() + tab.isActive = false + } } } + + isActive = true + onOpen() } - - isActive = true - onOpen() - playGuiClickSound() - - return true } } From b957378c60edca813d7913b24a35f8ddede63f95 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 8 Jul 2023 02:15:09 +0700 Subject: [PATCH 0713/1199] Iterate IGUIRenderable, update panels to accept IGUIRenderable where applicable --- .../client/render/AbstractMatterySprite.kt | 30 +++--- .../mc/otm/client/render/IGUIRenderable.kt | 92 +++++++++++++++---- .../button/BooleanRectangleButtonPanel.kt | 7 +- .../client/screen/panels/button/Buttons.kt | 15 ++- .../panels/button/EnumRectangleButtonPanel.kt | 5 +- .../button/LargeRectangleButtonPanel.kt | 7 +- .../panels/button/RectangleButtonPanel.kt | 9 +- .../dbotthepony/mc/otm/config/ClientConfig.kt | 30 ++---- 8 files changed, 126 insertions(+), 69 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt index 3b331de9c..4b34ee8c4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt @@ -22,13 +22,13 @@ sealed class AbstractMatterySprite : IGUIRenderable { * Expected image width in pixels, used in calculations * and as default width argument in render methods */ - abstract val width: Float + abstract override val width: Float /** * Expected image height in pixels, used in calculations * and as default height argument in render methods */ - abstract val height: Float + abstract override val height: Float abstract val u0: Float abstract val v0: Float @@ -45,7 +45,7 @@ sealed class AbstractMatterySprite : IGUIRenderable { abstract val type: SpriteType - open val winding: UVWindingOrder get() = UVWindingOrder.NORMAL + override val winding: UVWindingOrder get() = UVWindingOrder.NORMAL abstract val texture: ResourceLocation @@ -76,23 +76,19 @@ sealed class AbstractMatterySprite : IGUIRenderable { renderRaw(stack, x, y, width, height, winding) } - fun render( - graphics: GuiGraphics, - x: Float = 0f, - y: Float = 0f, - width: Float = this.width, - height: Float = this.height, - winding: UVWindingOrder = this.winding + override fun render( + guiGraphics: GuiGraphics, + x: Float, + y: Float, + width: Float, + height: Float, + winding: UVWindingOrder ) { - render(graphics.pose(), x, y, width, height, winding) + render(guiGraphics.pose(), x, y, width, height, winding) } - override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float) { - return render(guiGraphics, x, y, width, height, winding) - } - - override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, gravity: RenderGravity) { - return render(guiGraphics, gravity.x(x, width), gravity.y(y, height), width, height, winding) + override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, gravity: RenderGravity, winding: UVWindingOrder) { + render(guiGraphics.pose(), x, y, width, height, winding) } @JvmOverloads diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt index 44f5b5937..935dcac75 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt @@ -4,23 +4,40 @@ import net.minecraft.client.gui.GuiGraphics import net.minecraft.world.item.ItemStack interface IGUIRenderable { - fun render(guiGraphics: GuiGraphics, x: Float, y: Float, gravity: RenderGravity = RenderGravity.TOP_LEFT) + /** + * Expected width of this gui element, in pixels + */ + val width: Float /** - * Render at specified [x], [y] with fixed [width] x [height] + * Expected height of this gui element, in pixels */ - fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float) + val height: Float + + /** + * Utilized only for purpose of default argument + */ + val winding: UVWindingOrder get() = UVWindingOrder.NORMAL + + fun render(guiGraphics: GuiGraphics, x: Float = 0f, y: Float = 0f, gravity: RenderGravity = RenderGravity.TOP_LEFT, winding: UVWindingOrder = this.winding) { + render(guiGraphics, gravity.x(x, width), gravity.y(y, height), width, height, winding) + } + + /** + * Render at specified position [x], [y] with size of [width] x [height], optionally with UV [winding], if we are rendering flat texture/sprite + */ + fun render(guiGraphics: GuiGraphics, x: Float = 0f, y: Float = 0f, width: Float = this.width, height: Float = this.height, winding: UVWindingOrder = this.winding) fun composeBefore(other: IGUIRenderable): IGUIRenderable { return object : IGUIRenderable { - override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, gravity: RenderGravity) { - this@IGUIRenderable.render(guiGraphics, x, y, gravity) - other.render(guiGraphics, x, y, gravity) - } + override val width: Float + get() = this@IGUIRenderable.width.coerceAtLeast(other.width) + override val height: Float + get() = this@IGUIRenderable.height.coerceAtLeast(other.height) - override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float) { - this@IGUIRenderable.render(guiGraphics, x, y, width, height) - other.render(guiGraphics, x, y, width, height) + override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder) { + this@IGUIRenderable.render(guiGraphics, x, y, width, height, winding) + other.render(guiGraphics, x, y, width, height, winding) } } } @@ -29,6 +46,53 @@ interface IGUIRenderable { return other.composeBefore(this) } + fun padded(left: Float, top: Float, right: Float, bottom: Float): IGUIRenderable { + return object : IGUIRenderable { + override val width: Float + get() = this@IGUIRenderable.width + override val height: Float + get() = this@IGUIRenderable.height + + override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder) { + this@IGUIRenderable.render(guiGraphics, x + left, y + top, width + right + left, height + bottom + top, winding) + } + } + } + + /** + * Locks argument values to default ones and aligns render position to center of render rectangle + * + * e.g. for example, if we want [ItemStackIcon] to always render as 16x16 pixels icon, even if required render + * dimensions are bigger (e.g. 18x18), after calling [fix] on [ItemStackIcon] it will always render as 16x16 icon, + * positioned on center of render canvas (e.g. rendering on +0+0 with 18x18 size will put icon at +1+1 and render as 16x16; + * rendering on +0+0 with 32x32 canvas will put icon at +8+8 and render as 16x16) + */ + fun fixed(fixedWidth: Boolean = true, fixedHeight: Boolean = true, fixedWinding: Boolean = true): IGUIRenderable { + if (!fixedHeight && !fixedWidth && !fixedWinding) return this + + return object : IGUIRenderable { + override val width: Float + get() = this@IGUIRenderable.width + override val height: Float + get() = this@IGUIRenderable.height + + override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder) { + var realX = x + var realY = y + + if (fixedWidth && width > this.width) { + realX += (width - this.width) / 2f + } + + if (fixedHeight && height > this.height) { + realY += (height - this.height) / 2f + } + + this@IGUIRenderable.render(guiGraphics, realX, realY, if (fixedWidth) this.width else width, if (fixedHeight) this.height else height, if (fixedWinding) this.winding else winding) + } + } + } + companion object { fun of(value: ItemStack, width: Float = 16f, height: Float = 16f): IGUIRenderable { return ItemStackIcon(value, width, height) @@ -40,12 +104,8 @@ interface IGUIRenderable { } } -data class ItemStackIcon(private val itemStack: ItemStack, val width: Float = 16f, val height: Float = 16f) : IGUIRenderable { - override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, gravity: RenderGravity) { - return render(guiGraphics, gravity.x(x, width), gravity.y(y, height), width, height) - } - - override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float) { +data class ItemStackIcon(private val itemStack: ItemStack, override val width: Float = 16f, override val height: Float = 16f) : IGUIRenderable { + override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder) { if (x % 1f == 0f && y % 1f == 0f && width == 16f && height == 16f) { guiGraphics.renderFakeItem(itemStack, x.toInt(), y.toInt()) clearDepth(guiGraphics.pose(), x, y, width, height) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt index d2a2ceb29..4fda37f4d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt @@ -1,12 +1,11 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button -import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.ChatFormatting import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite +import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.TextComponent @@ -21,8 +20,8 @@ abstract class BooleanRectangleButtonPanel( width: Float, height: Float, val prop: GetterSetter, - var skinElementActive: AbstractMatterySprite? = null, - var skinElementInactive: AbstractMatterySprite? = null, + var skinElementActive: IGUIRenderable? = null, + var skinElementInactive: IGUIRenderable? = null, val onChange: ((newValue: Boolean) -> Unit)? = null, var tooltipActive: Component? = null, var tooltipInactive: Component? = null, 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 31e47b284..96d5ae994 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 @@ -4,6 +4,8 @@ import com.mojang.blaze3d.platform.InputConstants import net.minecraft.ChatFormatting import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.Items import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.capability.FlowDirection @@ -12,6 +14,7 @@ import ru.dbotthepony.mc.otm.client.isCtrlDown import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite +import ru.dbotthepony.mc.otm.client.render.ItemStackIcon import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.Dock @@ -21,6 +24,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel +import ru.dbotthepony.mc.otm.config.ClientConfig import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent @@ -36,6 +40,11 @@ import java.util.function.Predicate import kotlin.math.ceil import kotlin.math.pow +private val gunpowder = ItemStackIcon(ItemStack(Items.GUNPOWDER)).fixed() +private val barrier = ItemStackIcon(ItemStack(Items.BARRIER)).fixed() +private val redstone = ItemStackIcon(ItemStack(Items.REDSTONE)).fixed() +private val redstoneUnderBarrier = barrier.composeAfter(redstone).fixed() + private fun > makeRedstoneSettingButton( screen: S, parent: EditablePanel<*>?, @@ -53,9 +62,9 @@ private fun > makeRedstoneSettingButton( set(value) {} init { - add(RedstoneSetting.IGNORED, tooltip = RedstoneSetting.IGNORED.description, skinElement = Widgets18.REDSTONE_IGNORED) - add(RedstoneSetting.LOW, tooltip = RedstoneSetting.LOW.description, skinElement = Widgets18.REDSTONE_LOW) - add(RedstoneSetting.HIGH, tooltip = RedstoneSetting.HIGH.description, skinElement = Widgets18.REDSTONE_HIGH) + add(RedstoneSetting.IGNORED, tooltip = RedstoneSetting.IGNORED.description, skinElement = if (ClientConfig.REDSTONE_CONTROLS_ITEM_ICONS) gunpowder else Widgets18.REDSTONE_IGNORED) + add(RedstoneSetting.LOW, tooltip = RedstoneSetting.LOW.description, skinElement = if (ClientConfig.REDSTONE_CONTROLS_ITEM_ICONS) redstoneUnderBarrier else Widgets18.REDSTONE_LOW) + add(RedstoneSetting.HIGH, tooltip = RedstoneSetting.HIGH.description, skinElement = if (ClientConfig.REDSTONE_CONTROLS_ITEM_ICONS) redstone else Widgets18.REDSTONE_HIGH) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt index 83be28cdd..84571b6e8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt @@ -8,6 +8,7 @@ import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite +import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.GetterSetter @@ -49,14 +50,14 @@ abstract class EnumRectangleButtonPanel>( data class Entry>( val key: T, - val skinElement: AbstractMatterySprite?, + val skinElement: IGUIRenderable?, val winding: UVWindingOrder = UVWindingOrder.NORMAL, val tooltip: Component? = null ) protected val enumMapping = EnumMap>(enum) - fun add(key: T, skinElement: AbstractMatterySprite? = null, tooltip: Component? = null, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumRectangleButtonPanel { + fun add(key: T, skinElement: IGUIRenderable? = null, tooltip: Component? = null, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumRectangleButtonPanel { return add(Entry(key = key, skinElement = skinElement, winding = winding, tooltip = tooltip)) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt index f7a11ca8a..a5662a752 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt @@ -4,6 +4,7 @@ import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite +import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel @@ -16,8 +17,8 @@ open class LargeRectangleButtonPanel( width: Float = SIZE, height: Float = SIZE, onPress: ((clickButton: Int) -> Unit)? = null, - val skinElement: AbstractMatterySprite? = null, - val skinElementWinding: UVWindingOrder? = null, + var skinElement: IGUIRenderable? = null, + var skinElementWinding: UVWindingOrder? = null, ) : RectangleButtonPanel(screen, parent, x, y, width, height, onPress) { final override val IDLE = Widgets18.BUTTON_IDLE final override val HOVERED = Widgets18.BUTTON_HOVERED @@ -28,7 +29,7 @@ open class LargeRectangleButtonPanel( super.innerRender(graphics, mouseX, mouseY, partialTick) if (skinElementWinding != null) { - skinElement?.render(graphics, width = width, height = height, winding = skinElementWinding) + skinElement?.render(graphics, width = width, height = height, winding = skinElementWinding!!) } else { skinElement?.render(graphics, width = width, height = height) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/RectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/RectangleButtonPanel.kt index 980beb7be..e7388dd61 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/RectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/RectangleButtonPanel.kt @@ -5,6 +5,7 @@ import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite +import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.TextComponent import java.util.function.IntConsumer @@ -19,10 +20,10 @@ abstract class RectangleButtonPanel( height: Float, var onPress: IntConsumer? = null, ) : AbstractButtonPanel(screen, parent, x, y, width, height) { - abstract val PRESSED: AbstractMatterySprite - abstract val HOVERED: AbstractMatterySprite - abstract val IDLE: AbstractMatterySprite - abstract val DISABLED: AbstractMatterySprite + abstract val PRESSED: IGUIRenderable + abstract val HOVERED: IGUIRenderable + abstract val IDLE: IGUIRenderable + abstract val DISABLED: IGUIRenderable override fun onClick(mouseButton: Int) { onPress?.accept(mouseButton) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ClientConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ClientConfig.kt index 089a1ada3..1c4a80cac 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ClientConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ClientConfig.kt @@ -4,38 +4,28 @@ import net.minecraftforge.common.ForgeConfigSpec import net.minecraftforge.fml.ModLoadingContext import net.minecraftforge.fml.config.ModConfig -object ClientConfig { - private val specBuilder = ForgeConfigSpec.Builder() - @Suppress("JoinDeclarationAndAssignment") - private val spec: ForgeConfigSpec - private var registered = false - - var ALWAYS_DISPLAY_MATTER_VALUE: Boolean by specBuilder +object ClientConfig : AbstractConfig("client", ModConfig.Type.CLIENT) { + var ALWAYS_DISPLAY_MATTER_VALUE: Boolean by builder .define("ALWAYS_DISPLAY_MATTER_VALUE", false) - var EXOPACK_INVENTORY_ROWS: Int by specBuilder + var EXOPACK_INVENTORY_ROWS: Int by builder .comment("Amount of inventory rows to show when wearing Exosuit") .defineInRange("EXOPACK_INVENTORY_ROWS", 3, 3, 6) - var JUMP_BOOST_LOOK_ANGLE: Double by specBuilder + var JUMP_BOOST_LOOK_ANGLE: Double by builder .comment("If looking below this angle (actually, looking 'above' as you see in game, but not as you expect it, check with debug screen), Crouch + Jump will trigger jump boost android ability") .defineInRange("JUMP_BOOST_LOOK_ANGLE", 30.0, -180.0, 180.0) - var EXOPACK_FREE_SCROLL: Boolean by specBuilder + var EXOPACK_FREE_SCROLL: Boolean by builder .comment("Allow to scroll Exopack inventory in non OTM inventories when hovering just over inventory slots, not only scrollbar") .define("EXOPACK_FREE_SCROLL", true) - var ANDROID_HEALTH_HUD: Boolean by specBuilder + var ANDROID_HEALTH_HUD: Boolean by builder .comment("Replace hearts with health bar on HUD when you are an android") .define("ANDROID_HEALTH_HUD", true) - init { - spec = specBuilder.build() - } - - fun register() { - check(!registered) { "Already registered config" } - registered = true - ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, spec) - } + var REDSTONE_CONTROLS_ITEM_ICONS: Boolean by builder + .comment("Display redstone control button using items instead of custom sprites") + .comment("For those who want it.") + .define("REDSTONE_CONTROLS_ITEM_ICONS", false) } From 1902912a3b6e22581358e421e4cc8a57c1e8c0a6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 8 Jul 2023 15:33:20 +0700 Subject: [PATCH 0714/1199] Fix exopack battery slot granting android achievements --- .../dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt | 4 ++-- .../mc/otm/capability/energy/BatteryBackedEnergyStorage.kt | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index a5f3a3e6e..e76eba2fc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -404,12 +404,12 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial /** * [IMatteryEnergyStorage] instance, representing Android' battery charge */ - val androidEnergy = BatteryBackedEnergyStorage(ply, synchronizer, AndroidConfig.ANDROID_MAX_ENERGY, AndroidConfig.ANDROID_MAX_ENERGY) + val androidEnergy = BatteryBackedEnergyStorage(ply, synchronizer, AndroidConfig.ANDROID_MAX_ENERGY, AndroidConfig.ANDROID_MAX_ENERGY, true) /** * [IMatteryEnergyStorage] instance, representing Exopack battery charge */ - val exoPackEnergy = ProfiledEnergyStorage(BatteryBackedEnergyStorage(ply, synchronizer, Decimal.ZERO, ExopackConfig.ENERGY_CAPACITY)) + val exoPackEnergy = ProfiledEnergyStorage(BatteryBackedEnergyStorage(ply, synchronizer, Decimal.ZERO, ExopackConfig.ENERGY_CAPACITY, false)) init { savetables.int(::ticksIExist) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BatteryBackedEnergyStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BatteryBackedEnergyStorage.kt index 5d9e30922..9740cedf2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BatteryBackedEnergyStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BatteryBackedEnergyStorage.kt @@ -23,7 +23,8 @@ class BatteryBackedEnergyStorage( private val ply: Player, synchronizer: FieldSynchronizer, initialCharge: Decimal, - maxCharge: Decimal + maxCharge: Decimal, + val isAndroid: Boolean ) : IMatteryEnergyStorage, INBTSerializable, ContainerSingleItem { override val energyFlow: FlowDirection get() = FlowDirection.INPUT @@ -34,7 +35,7 @@ class BatteryBackedEnergyStorage( var item by synchronizer.item(setter = setter@{ value, access, _ -> access.write(value) - if (ply is ServerPlayer) { + if (ply is ServerPlayer && isAndroid) { AndroidBatteryTrigger.trigger(ply, value) } }) From 86a8011f29e75d4f29ace217cc2582963b33a109 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 8 Jul 2023 21:47:13 +0700 Subject: [PATCH 0715/1199] Jump boost now have particles --- .../otm/android/feature/JumpBoostFeature.kt | 64 +++++++++++++++---- .../network/MatteryPlayerNetworkChannel.kt | 2 + 2 files changed, 52 insertions(+), 14 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt index 4d3044802..002bf99f2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt @@ -4,11 +4,17 @@ import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.ChatFormatting import net.minecraft.client.gui.GuiGraphics +import net.minecraft.core.particles.ParticleTypes import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import net.minecraft.sounds.SoundSource +import net.minecraft.util.RandomSource +import net.minecraft.world.level.Level +import net.minecraft.world.phys.Vec3 import net.minecraftforge.network.NetworkEvent +import net.minecraftforge.network.PacketDistributor +import net.minecraftforge.network.PacketDistributor.TargetPoint import ru.dbotthepony.mc.otm.config.ClientConfig import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.config.AndroidConfig @@ -18,8 +24,12 @@ import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.ShiftPressedCond +import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.core.math.Vector +import ru.dbotthepony.mc.otm.core.math.component1 +import ru.dbotthepony.mc.otm.core.math.component2 +import ru.dbotthepony.mc.otm.core.math.component3 import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.network.MatteryPacket @@ -32,6 +42,11 @@ import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.registry.MSoundEvents import java.util.function.Supplier +private fun makeSmoke(x: Double, y: Double, z: Double, random: RandomSource, level: Level) { + for (i in 0 .. random.nextInt(4, 8)) + level.addParticle(ParticleTypes.POOF, x + random.nextDouble() * 0.5 - 0.25, y + random.nextDouble() * 0.5 - 0.25, z + random.nextDouble() * 0.5 - 0.25, random.nextGaussian() * 0.02, random.nextGaussian() * 0.02, random.nextGaussian() * 0.02) +} + object TriggerJumpBoostPacket : MatteryPacket { override fun write(buff: FriendlyByteBuf) { // no op @@ -46,26 +61,48 @@ object TriggerJumpBoostPacket : MatteryPacket { if (!mattery.isAndroid) return@enqueueWork - val feature = mattery.getFeature(AndroidFeatures.JUMP_BOOST) as JumpBoostFeature? ?: return@enqueueWork + val feature = mattery.getFeature(AndroidFeatures.JUMP_BOOST) ?: return@enqueueWork if (feature.isActive && feature.cooldown <= 4 && mattery.androidEnergy.extractEnergyExact(AndroidConfig.JumpBoost.ENERGY_COST, false)) { feature.putOnCooldown() context.sender?.let { it.level().playSound( - it, - it, - MSoundEvents.ANDROID_JUMP_BOOST, - SoundSource.PLAYERS, - 1f, - 1f + it, it, + MSoundEvents.ANDROID_JUMP_BOOST, SoundSource.PLAYERS, + 1f, 1f ) + + MatteryPlayerNetworkChannel.send(PacketDistributor.NEAR.with { TargetPoint(it, it.x, it.y, it.z, 64.0, it.level().dimension()) }, JumpBoostParticlesPacket(it.x, it.y, it.z)) } } } } } +class JumpBoostParticlesPacket(val x: Double, val y: Double, val z: Double) : MatteryPacket { + override fun write(buff: FriendlyByteBuf) { + buff.writeDouble(x) + buff.writeDouble(y) + buff.writeDouble(z) + } + + override fun play(context: Supplier) { + context.packetHandled = true + context.enqueueWork { + minecraft.player?.level()?.let { + makeSmoke(x, y, z, it.random, it) + } + } + } + + companion object { + fun read(buff: FriendlyByteBuf): JumpBoostParticlesPacket { + return JumpBoostParticlesPacket(buff.readDouble(), buff.readDouble(), buff.readDouble()) + } + } +} + class JumpBoostFeature(capability: MatteryPlayerCapability) : AndroidSwitchableFeature(AndroidFeatures.JUMP_BOOST, capability) { private var tickCooldownClient = false @@ -78,7 +115,7 @@ class JumpBoostFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF if (setByRemote) { tickCooldownClient = false } - }) + }).property private var lastGround = false @@ -98,13 +135,12 @@ class JumpBoostFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF MatteryPlayerNetworkChannel.sendToServer(TriggerJumpBoostPacket) ply.level().playSound( - ply, - ply, - MSoundEvents.ANDROID_JUMP_BOOST, - SoundSource.PLAYERS, - 1f, - 1f + ply, ply, + MSoundEvents.ANDROID_JUMP_BOOST, SoundSource.PLAYERS, + 1f, 1f ) + + makeSmoke(ply.x, ply.y, ply.z, ply.random, ply.level()) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt index 8915ec7f1..a1364a351 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt @@ -17,6 +17,7 @@ import ru.dbotthepony.mc.otm.android.AndroidFeatureType import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidResearchType import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature +import ru.dbotthepony.mc.otm.android.feature.JumpBoostParticlesPacket import ru.dbotthepony.mc.otm.android.feature.TriggerJumpBoostPacket import ru.dbotthepony.mc.otm.android.feature.TriggerShockwavePacket import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability @@ -582,6 +583,7 @@ object MatteryPlayerNetworkChannel : MatteryNetworkChannel( add(TriggerShockwavePacket::class, { TriggerShockwavePacket }, PLAY_TO_SERVER) add(TriggerJumpBoostPacket::class, { TriggerJumpBoostPacket }, PLAY_TO_SERVER) + add(JumpBoostParticlesPacket::class, JumpBoostParticlesPacket.Companion::read, PLAY_TO_CLIENT) add(PickItemFromInventoryPacket::class, PickItemFromInventoryPacket.Companion::read, PLAY_TO_SERVER) From 8091f6aeb00e48008dcc1b13a159f7a05ad814f3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 8 Jul 2023 21:57:59 +0700 Subject: [PATCH 0716/1199] Fix Server being unable to start --- .../kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 391200982..9dfb64918 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -11,9 +11,11 @@ import net.minecraft.world.level.block.state.BlockBehaviour import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.properties.NoteBlockInstrument import net.minecraft.world.level.material.MapColor +import net.minecraftforge.api.distmarker.Dist import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent +import net.minecraftforge.fml.loading.FMLEnvironment import net.minecraftforge.registries.NewRegistryEvent import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.android.AndroidResearchResult @@ -223,7 +225,10 @@ object MRegistry { LootModifiers.register(bus) MItemFunctionTypes.register(bus) MLootItemConditions.register(bus) - MBlockColors.register(bus) + + if (FMLEnvironment.dist == Dist.CLIENT) { + MBlockColors.register(bus) + } MRecipes.register(bus) From 55d56e3efef8acf51401509a7b29a1d86874ba15 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 8 Jul 2023 22:17:26 +0700 Subject: [PATCH 0717/1199] Add exopack smelting upgrade recipe --- .../mc/otm/datagen/recipes/CraftingTableRecipes.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index 0cf235240..0b68c0418 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -310,6 +310,13 @@ fun addCraftingTableRecipes(consumer: Consumer) { .row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) .build(consumer) + // апгрейд на переплавку + MatteryRecipe(MItems.ExopackUpgrades.SMELTING_UPGRADE, category = RecipeCategory.TOOLS) + .row(MItemTags.ADVANCED_CIRCUIT, MItemTags.ADVANCED_CIRCUIT, MItemTags.ADVANCED_CIRCUIT) + .row(Items.FURNACE, MItems.QUANTUM_TRANSCEIVER, Items.FURNACE) + .row(MItemTags.TRITANIUM_PLATES, Items.FURNACE, MItemTags.TRITANIUM_PLATES) + .build(consumer) + // генератор коблы MatteryRecipe(MItems.COBBLESTONE_GENERATOR, category = machinesCategory) .row(MItemTags.HARDENED_GLASS_COLORLESS, MItems.TRITANIUM_PICKAXE, MItemTags.HARDENED_GLASS_COLORLESS) From 2e4cb8b3f9a9c14216e76a3f367df0de725faf66 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 8 Jul 2023 23:25:26 +0700 Subject: [PATCH 0718/1199] Massively buff exopack energy storage --- src/main/kotlin/ru/dbotthepony/mc/otm/config/ExopackConfig.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ExopackConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ExopackConfig.kt index ab652e63d..34cb073f7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ExopackConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ExopackConfig.kt @@ -6,7 +6,7 @@ import ru.dbotthepony.mc.otm.core.math.defineDecimal object ExopackConfig : AbstractConfig("exopack") { val ENERGY_CAPACITY by builder .comment("Internal battery capacity of Exopack") - .defineDecimal("ENERGY_CAPACITY", Decimal(400_000), Decimal.ZERO) + .defineDecimal("ENERGY_CAPACITY", Decimal(40_000_000), Decimal.ZERO) val FURNACE_POWER_CONSUMPTION by builder .comment("Power consumed per tick by built in furnace") From 024a25f72a9468b1cd8213dbe72dcbd4cd7ae65a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 8 Jul 2023 23:58:41 +0700 Subject: [PATCH 0719/1199] Exopack charger slots --- .../otm/capability/MatteryPlayerCapability.kt | 23 +++++++++++++++++-- .../client/screen/ExoPackInventoryScreen.kt | 18 ++++++++++++--- .../mc/otm/menu/ExoPackInventoryMenu.kt | 6 +++++ .../ru/dbotthepony/mc/otm/menu/Slots.kt | 14 +++++++---- 4 files changed, 52 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index e76eba2fc..0f35c3dac 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -35,6 +35,7 @@ import net.minecraft.world.phys.Vec3 import net.minecraftforge.common.ForgeHooks import net.minecraftforge.common.MinecraftForge import net.minecraftforge.common.capabilities.Capability +import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.capabilities.ICapabilityProvider import net.minecraftforge.common.util.INBTSerializable import net.minecraftforge.common.util.LazyOptional @@ -411,6 +412,8 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial */ val exoPackEnergy = ProfiledEnergyStorage(BatteryBackedEnergyStorage(ply, synchronizer, Decimal.ZERO, ExopackConfig.ENERGY_CAPACITY, false)) + val exoPackChargeSlots = MatteryContainer(4) + init { savetables.int(::ticksIExist) savetables.int(::iteration) @@ -432,6 +435,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial savetables.stateful(::exoPackContainer, "exoSuitContainer") savetables.stateful(::androidEnergy) savetables.stateful(::exoPackEnergy) + savetables.stateful(::exoPackChargeSlots) savetables.float(::exoPackSmelterExperience) savetables.bool(::isExoPackSmeltingInstalled) } @@ -944,8 +948,23 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial if (hasExoPack) { exoPackEnergy.parent.tick() - if (!ply.isSpectator && isExoPackSmeltingInstalled) { - smelters.forEach { it.think() } + if (!ply.isSpectator) { + if (isExoPackSmeltingInstalled) + smelters.forEach { it.think() } + + if (!exoPackChargeSlots.isEmpty && exoPackEnergy.batteryLevel.isPositive) { + var available = exoPackEnergy.extractEnergy(exoPackEnergy.batteryLevel, true) + + for (item in exoPackChargeSlots) { + if (item.isNotEmpty) { + item.energy?.let { + available -= exoPackEnergy.extractEnergy(it.receiveEnergy(available, false), false) + } + + if (!available.isPositive) break + } + } + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt index ae6778d90..2c2a19585 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt @@ -191,10 +191,12 @@ class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen makeSlots(container: C, initializer: (C, In return immutableList(container.containerSize) { initializer.invoke(container, it) } } -open class MatterySlot @JvmOverloads constructor(container: Container, index: Int, x: Int = 0, y: Int = 0) : Slot(container, index, x, y) { +open class MatterySlot(container: Container, index: Int, x: Int = 0, y: Int = 0) : Slot(container, index, x, y) { var ignoreSpectators = true override fun mayPickup(player: Player): Boolean { @@ -64,7 +64,7 @@ open class UserFilteredSlot(container: Container, index: Int, x: Int = 0, y: Int } } -open class MachineOutputSlot @JvmOverloads constructor(container: Container, index: Int, x: Int = 0, y: Int = 0, val onTake: () -> Unit = {}) : MatterySlot(container, index, x, y) { +open class MachineOutputSlot(container: Container, index: Int, x: Int = 0, y: Int = 0, val onTake: () -> Unit = {}) : MatterySlot(container, index, x, y) { override fun mayPlace(itemStack: ItemStack): Boolean { return false } @@ -80,13 +80,19 @@ open class MachineOutputSlot @JvmOverloads constructor(container: Container, ind } } -open class BatterySlot @JvmOverloads constructor(container: Container, index: Int, x: Int = 0, y: Int = 0) : MatterySlot(container, index, x, y) { +open class BatterySlot(container: Container, index: Int, x: Int = 0, y: Int = 0) : MatterySlot(container, index, x, y) { override fun mayPlace(itemStack: ItemStack): Boolean { return super.mayPlace(itemStack) && (itemStack.energy?.canExtract() ?: false) } } -open class MatterContainerInputSlot @JvmOverloads constructor( +open class ChargeSlot(container: Container, index: Int, x: Int = 0, y: Int = 0) : MatterySlot(container, index, x, y) { + override fun mayPlace(itemStack: ItemStack): Boolean { + return super.mayPlace(itemStack) && (itemStack.energy?.canReceive() ?: false) + } +} + +open class MatterContainerInputSlot( container: Container, index: Int, x: Int = 0, From db99fb339c0e532594981126998494896ad0c1bb Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 9 Jul 2023 00:09:49 +0700 Subject: [PATCH 0720/1199] Update vanish/clear/drop inventory hooks --- .../otm/capability/MatteryPlayerCapability.kt | 57 ++++++++++--------- .../ru/dbotthepony/mc/otm/container/Ext.kt | 11 ++++ 2 files changed, 41 insertions(+), 27 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 0f35c3dac..691c4eea9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -13,6 +13,7 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerPlayer import net.minecraft.tags.TagKey +import net.minecraft.world.Container import net.minecraft.world.Difficulty import net.minecraft.world.damagesource.DamageSource import net.minecraft.world.effect.MobEffect @@ -35,7 +36,6 @@ import net.minecraft.world.phys.Vec3 import net.minecraftforge.common.ForgeHooks import net.minecraftforge.common.MinecraftForge import net.minecraftforge.common.capabilities.Capability -import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.capabilities.ICapabilityProvider import net.minecraftforge.common.util.INBTSerializable import net.minecraftforge.common.util.LazyOptional @@ -72,7 +72,9 @@ import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.config.ExopackConfig import ru.dbotthepony.mc.otm.container.MatteryContainer +import ru.dbotthepony.mc.otm.container.iterator import ru.dbotthepony.mc.otm.container.stream +import ru.dbotthepony.mc.otm.container.vanishCursedItems import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.collect.UUIDIntModifiersMap import ru.dbotthepony.mc.otm.core.collect.filter @@ -106,6 +108,17 @@ import kotlin.collections.ArrayList import kotlin.collections.HashMap import kotlin.reflect.KMutableProperty1 +private fun Player.dropContainer(container: Container, spill: Boolean = true, setThrower: Boolean = false) { + val iterator = container.iterator() + + for (item in iterator) { + if (item.isNotEmpty) { + drop(item, spill, setThrower) + iterator.remove() + } + } +} + @Suppress("unused") class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerializable { /** @@ -1557,26 +1570,13 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial return } - val iterator = mattery.exoPackContainer.iterator() - - for (item in iterator) { - if (!item.isEmpty) { - inventory.player.drop(item, true, false) - iterator.remove() - } - } + inventory.player.dropContainer(mattery.exoPackContainer) + inventory.player.dropContainer(mattery.exoPackChargeSlots) + inventory.player.dropContainer(mattery.exoPackEnergy.parent) for (smelter in mattery.smelters) { - if (!smelter.input[0].isEmpty) { - inventory.player.drop(smelter.input[0], true, false) - smelter.input[0] = ItemStack.EMPTY - } - - if (!smelter.output[0].isEmpty) { - inventory.player.drop(smelter.output[0], true, false) - smelter.output[0] = ItemStack.EMPTY - } - + inventory.player.dropContainer(smelter.input) + inventory.player.dropContainer(smelter.output) smelter.currentJob = null } } @@ -1590,6 +1590,8 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } mattery.exoPackContainer.clearContent() + mattery.exoPackChargeSlots.clearContent() + mattery.exoPackEnergy.parent.clearContent() for (smelter in mattery.smelters) { smelter.input.clearContent() @@ -1600,15 +1602,16 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial @JvmStatic fun playerDestroyVanishingCursedItems(player: Player) { - if (player.matteryPlayer?.hasExoPack == false) { - return - } + player.matteryPlayer?.let { + if (it.hasExoPack) { + it.exoPackContainer.vanishCursedItems() + it.exoPackChargeSlots.vanishCursedItems() + it.exoPackEnergy.parent.vanishCursedItems() - val iterator = player.matteryPlayer?.exoPackContainer?.iterator() ?: return - - for (item in iterator) { - if (!item.isEmpty && hasVanishingCurse(item)) { - iterator.remove() + for (smelter in it.smelters) { + smelter.input.vanishCursedItems() + smelter.output.vanishCursedItems() + } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt index 6b279ce3c..3900cd640 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt @@ -8,6 +8,7 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectFunction import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap import net.minecraft.world.Container import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.enchantment.EnchantmentHelper.hasVanishingCurse import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.fluids.capability.IFluidHandler import ru.dbotthepony.mc.otm.core.addAll @@ -83,6 +84,16 @@ fun Container.addItem(stack: ItemStack, range: IntRange, simulate: Boolean = fal fun Container.addItem(stack: ItemStack, simulate: Boolean): ItemStack = addItem(stack, 0 until containerSize, simulate) +fun Container.vanishCursedItems() { + val iterator = iterator() + + for (item in iterator) { + if (item.isNotEmpty && hasVanishingCurse(item)) { + iterator.remove() + } + } +} + inline fun Container.forEach(cap: Capability, consumer: (Pair) -> Unit) { for (value in iterator(cap)) { consumer(value) From 8f450c2058f7af28951aa8b78fc203b096295d0c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 9 Jul 2023 00:11:23 +0700 Subject: [PATCH 0721/1199] Actually, internal energy storage of exopack can be made upgradeable instead of giving it huge capacity by default --- src/main/kotlin/ru/dbotthepony/mc/otm/config/ExopackConfig.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ExopackConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ExopackConfig.kt index 34cb073f7..c62aaa42b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ExopackConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ExopackConfig.kt @@ -6,7 +6,7 @@ import ru.dbotthepony.mc.otm.core.math.defineDecimal object ExopackConfig : AbstractConfig("exopack") { val ENERGY_CAPACITY by builder .comment("Internal battery capacity of Exopack") - .defineDecimal("ENERGY_CAPACITY", Decimal(40_000_000), Decimal.ZERO) + .defineDecimal("ENERGY_CAPACITY", Decimal(200_000), Decimal.ZERO) val FURNACE_POWER_CONSUMPTION by builder .comment("Power consumed per tick by built in furnace") From 6f4b0284614f3926a73f049c57b7910ee3a1619a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 9 Jul 2023 00:12:36 +0700 Subject: [PATCH 0722/1199] Clarify about exopack and android energy max capacity config values --- .../kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt | 5 ++++- .../kotlin/ru/dbotthepony/mc/otm/config/ExopackConfig.kt | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt index 9614c5948..73d1b105e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt @@ -52,7 +52,10 @@ object AndroidConfig : AbstractConfig("androids") { } val ANDROID_ENERGY_PER_HUNGER_POINT by builder.defineDecimal("energyPerHunger", Decimal(2000), Decimal.ZERO) - val ANDROID_MAX_ENERGY by builder.comment("Internal battery of every android has this much storage").defineDecimal("capacity", Decimal(80_000), Decimal.ZERO) + val ANDROID_MAX_ENERGY by builder + .comment("Internal battery of every android has this much storage") + .comment("Keep in mind that already existing players won't get their value changed since it is", "stored inside their savedata") + .defineDecimal("capacity", Decimal(80_000), Decimal.ZERO) val NIGHT_VISION_POWER_DRAW by builder.defineDecimal("nightVisionPowerDraw", Decimal(8), Decimal.ZERO) val FALL_DAMAGE_REDUCTION_PER_LEVEL_P: Double by builder diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ExopackConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ExopackConfig.kt index c62aaa42b..ecc938e42 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ExopackConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ExopackConfig.kt @@ -6,6 +6,7 @@ import ru.dbotthepony.mc.otm.core.math.defineDecimal object ExopackConfig : AbstractConfig("exopack") { val ENERGY_CAPACITY by builder .comment("Internal battery capacity of Exopack") + .comment("Keep in mind that already existing players won't get their value changed since it is", "stored inside their savedata") .defineDecimal("ENERGY_CAPACITY", Decimal(200_000), Decimal.ZERO) val FURNACE_POWER_CONSUMPTION by builder From a3c794271fe466d6a22a5498e329b7295bdc0cc4 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 9 Jul 2023 00:15:44 +0700 Subject: [PATCH 0723/1199] Increase "onAttackEvent" listener priority e.g. so other mods which add armor with fall damage immunity won't receive event of fall damage received when damage is actually negated by android fall dampeners --- src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index c03666bbd..7a73a9cbb 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -162,7 +162,7 @@ public final class OverdriveThatMatters { EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayerCapability.Companion::onPlayerTick); EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayerCapability.Companion::isMobEffectApplicable); EVENT_BUS.addListener(EventPriority.LOW, MatteryPlayerCapability.Companion::onHurtEvent); - EVENT_BUS.addListener(EventPriority.LOW, MatteryPlayerCapability.Companion::onAttackEvent); + EVENT_BUS.addListener(EventPriority.HIGH, MatteryPlayerCapability.Companion::onAttackEvent); EVENT_BUS.addGenericListener(Entity.class, EventPriority.NORMAL, MatteryPlayerCapability.Companion::onAttachCapabilityEvent); EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayerCapability.Companion::onPlayerChangeDimensionEvent); EVENT_BUS.addListener(EventPriority.LOWEST, MatteryPlayerCapability.Companion::onPlayerDeath); From 344364520d900849e9be351e9c472e25b90532be Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 9 Jul 2023 11:38:11 +0700 Subject: [PATCH 0724/1199] Frame panel help button, panel post render, more straightforward tooltips --- .../mc/otm/datagen/lang/English.kt | 2 + .../mc/otm/datagen/lang/Russian.kt | 2 + .../mc/otm/client/ClientEventHandler.kt | 2 +- .../client/screen/ExoPackInventoryScreen.kt | 8 +- .../mc/otm/client/screen/MatteryScreen.kt | 9 +- .../screen/decorative/CargoCrateScreen.kt | 1 + .../screen/decorative/HoloSignScreen.kt | 2 +- .../client/screen/matter/MatterPanelScreen.kt | 4 +- .../otm/client/screen/panels/EditablePanel.kt | 111 ++++++------------ .../screen/panels/EntityRendererPanel.kt | 2 +- .../mc/otm/client/screen/panels/FramePanel.kt | 80 ++++++++++++- .../otm/client/screen/panels/Panel2Widget.kt | 3 +- .../panels/button/AbstractButtonPanel.kt | 7 +- .../button/BooleanRectangleButtonPanel.kt | 15 +-- .../client/screen/panels/button/Buttons.kt | 44 +++---- .../panels/button/EnumRectangleButtonPanel.kt | 15 +-- .../screen/storage/ItemMonitorScreen.kt | 6 +- .../screen/tech/EssenceStorageScreen.kt | 22 ++-- .../textures/gui/widgets/misc.png | Bin 1327 -> 1397 bytes 19 files changed, 187 insertions(+), 148 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index ac240e091..bd6ba264a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -117,6 +117,8 @@ private fun sounds(provider: MatteryLanguageProvider) { private fun misc(provider: MatteryLanguageProvider) { with(provider.english) { + gui("help.slot_filters", "Hold CTRL to setup slot filters") + misc("needs_no_power", "Requires no power to operate") gui("lock_holo_screen", "Lock contents") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 4faf716dd..ee2336182 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -125,6 +125,8 @@ private fun sounds(provider: MatteryLanguageProvider) { private fun misc(provider: MatteryLanguageProvider) { with(provider.russian) { + gui("help.slot_filters", "Удерживайте CTRL для настройки фильтрации слотов") + misc("needs_no_power", "Не требует энергии для работы") gui("lock_holo_screen", "Заблокировать содержимое") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt index b8e68d950..0375aca37 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt @@ -98,7 +98,7 @@ private fun inventoryLogic(event: ScreenEvent.Init.Post) { minecraft.setScreen(ExoPackInventoryScreen(player.exoPackMenu)) InputConstants.grabOrReleaseMouse(minecraft.window.window, 212993, mouseX, mouseY) - }).also { it.tooltip = TranslatableComponent("otm.gui.exopack.go_in") }) + }).also { it.tooltips.add(TranslatableComponent("otm.gui.exopack.go_in")) }) event.addListener(widget) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt index 2c2a19585..7f4b2051c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.client.screen -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.inventory.InventoryScreen import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items @@ -19,15 +18,12 @@ import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.BackgroundPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel import ru.dbotthepony.mc.otm.client.screen.widget.HorizontalPowerGaugePanel -import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalProfiledPowerGaugePanel -import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.client.setMousePos import ru.dbotthepony.mc.otm.client.shouldOpenVanillaInventory import ru.dbotthepony.mc.otm.core.math.integerDivisionDown import ru.dbotthepony.mc.otm.menu.ExoPackInventoryMenu -import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.network.ExoPackMenuOpen import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel import yalter.mousetweaks.api.MouseTweaksDisableWheelTweak @@ -59,6 +55,8 @@ class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen> { val frame = FramePanel(this, width = 200f, height = FRAME_BASE_HEIGHT + inventoryRows * AbstractSlotPanel.SIZE, title = this.title) + frame.makeHelpButton().addSlotFiltersHelp() + val hotbarStrip = EditablePanel(this, frame, height = 18f) hotbarStrip.dock = Dock.BOTTOM @@ -236,7 +234,7 @@ class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen frame.y += movePixels 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 468a71ba5..ab786302b 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 @@ -523,7 +523,14 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit val panel = panels[i] RenderSystem.depthFunc(GL11.GL_ALWAYS) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) - panel.render(graphics, mouseXf, mouseYf, partialTick) + panel.render(graphics, false, mouseXf, mouseYf, partialTick) + } + + for (i in panels.indices.reversed()) { + val panel = panels[i] + RenderSystem.depthFunc(GL11.GL_ALWAYS) + RenderSystem.setShaderColor(1f, 1f, 1f, 1f) + panel.render(graphics, true, mouseXf, mouseYf, partialTick) } RenderSystem.depthFunc(GL11.GL_LESS) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt index bd81403cf..6aeaa70e4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt @@ -15,6 +15,7 @@ class CargoCrateScreen(menu: CargoCrateMenu, inventory: Inventory, title: Compon frame.makeCloseButton() frame.onClose { onClose() } + frame.makeHelpButton().addSlotFiltersHelp() val grid = GridPanel(this, frame, 8f, 18f, 9f * 18f, 6f * 18f, 9, 6) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt index 059286d25..0e041f81e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt @@ -26,7 +26,7 @@ class HoloSignScreen(menu: HoloSignMenu, inventory: Inventory, title: Component) val lock = CheckBoxLabelInputPanel(this, frame, menu.locked, TranslatableComponent("otm.gui.lock_holo_screen")) lock.dock = Dock.BOTTOM lock.dockMargin = DockProperty(2f, 2f, 2f, 2f) - lock.tooltip = TranslatableComponent("otm.gui.lock_holo_screen.tip") + lock.tooltips.add(TranslatableComponent("otm.gui.lock_holo_screen.tip")) makeDeviceControls(this, frame, redstoneConfig = menu.redstone) 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 38bc40dcb..38b61c58e 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 @@ -110,11 +110,11 @@ class MatterPanelScreen( scrollBar.dock = Dock.RIGHT frame.Tab(onOpen = { isPatternView = true; scrollBar.scroll = scrollPatterns }, activeIcon = PATTERN_LIST_ACTIVE, inactiveIcon = PATTERN_LIST_INACTIVE).also { - it.tooltip = TranslatableComponent("otm.gui.matter_panel.patterns") + it.tooltips.add(TranslatableComponent("otm.gui.matter_panel.patterns")) } frame.Tab(onOpen = { isPatternView = false; scrollBar.scroll = scrollTasks }, activeIcon = TASK_LIST_ACTIVE, inactiveIcon = TASK_LIST_INACTIVE).also { - it.tooltip = TranslatableComponent("otm.gui.matter_panel.tasks") + it.tooltips.add(TranslatableComponent("otm.gui.matter_panel.tasks")) } val canvas = object : EditablePanel(this@MatterPanelScreen, frame, width = GRID_WIDTH * AbstractSlotPanel.SIZE) { 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 add7aa7cb..357b78fa6 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 @@ -24,7 +24,6 @@ import ru.dbotthepony.mc.otm.client.render.currentScissorRect import ru.dbotthepony.mc.otm.client.render.popScissorRect import ru.dbotthepony.mc.otm.client.render.pushScissorRect import ru.dbotthepony.mc.otm.client.screen.MatteryScreen -import ru.dbotthepony.mc.otm.client.screen.panels.button.AbstractButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.input.QueryUserPanel import java.util.* import kotlin.collections.ArrayList @@ -357,6 +356,8 @@ open class EditablePanel @JvmOverloads constructor( var acceptKeyboardInput = true var grabMouseInput = false + open val needsPostRender: Boolean get() = false + fun tryToGrabMouseInput(): Boolean { if (grabMouseInput) { return true @@ -375,43 +376,7 @@ open class EditablePanel @JvmOverloads constructor( return true } - var tooltip: Component? = null - set(value) { - if (value != null) { - tooltipList = null - } - - field = value - } - - var tooltipList: List? = null - set(value) { - if (value != null) { - tooltip = null - } - - field = value - } - - fun prependTooltip(text: Component) { - if (tooltip == null && tooltipList == null) { - tooltip = text - } else if (tooltip != null) { - tooltipList = listOf(text, tooltip!!) - } else { - tooltipList = tooltipList!!.toMutableList().also { it.add(0, text) } - } - } - - fun appendTooltip(text: Component) { - if (tooltip == null && tooltipList == null) { - tooltip = text - } else if (tooltip != null) { - tooltipList = listOf(text, tooltip!!) - } else { - tooltipList = tooltipList!!.toMutableList().also { it.add(text) } - } - } + val tooltips = ArrayList() var blockingWindow: EditablePanel<*>? = null get() { @@ -738,10 +703,15 @@ open class EditablePanel @JvmOverloads constructor( } protected open fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {} + protected open fun innerRenderPost(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {} protected open fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { return false } + protected open fun shouldRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + return isHovered || isGrabbingMouseInput() + } + fun isVisible(): Boolean { return visible && visibleAsChildren && !isRemoved } @@ -782,7 +752,7 @@ open class EditablePanel @JvmOverloads constructor( } } - fun render(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + fun render(graphics: GuiGraphics, post: Boolean, mouseX: Float, mouseY: Float, partialTick: Float) { once = true if (!isVisible()) { @@ -791,22 +761,24 @@ open class EditablePanel @JvmOverloads constructor( val poseStack = graphics.pose() - performLayoutIfNeeded() + if (!post) { + performLayoutIfNeeded() - val parent = this.parent + val parent = this.parent - if (parent == null) { - absoluteX = x - absoluteY = y - } else { - if ((x < 0f || y < 0f || x + width > parent.width || y + height > parent.height) && parent.parent == null) { - // no op - we updated ourselves in tickHover + if (parent == null) { + absoluteX = x + absoluteY = y } else { - isHovered = parent.isHovered && - mouseX >= absoluteX && - mouseX < absoluteX + width && - mouseY >= absoluteY && - mouseY < absoluteY + height + if ((x < 0f || y < 0f || x + width > parent.width || y + height > parent.height) && parent.parent == null) { + // no op - we updated ourselves in tickHover + } else { + isHovered = parent.isHovered && + mouseX >= absoluteX && + mouseX < absoluteX + width && + mouseY >= absoluteY && + mouseY < absoluteY + height + } } } @@ -827,13 +799,18 @@ open class EditablePanel @JvmOverloads constructor( val currentScissorRect = currentScissorRect - if (currentScissorRect == null || currentScissorRect.crossScaled(absoluteX, absoluteY, width, height)) { + if ((!post || needsPostRender) && (currentScissorRect == null || currentScissorRect.crossScaled(absoluteX, absoluteY, width, height))) { // do not render if we are getting cut off by screen scissor clearDepth(graphics, absoluteX, absoluteY, width, height) poseStack.pushPose() poseStack.translate(absoluteX.toDouble(), absoluteY.toDouble(), 10.0) RenderSystem.setShaderColor(1f, 1f, 1f, if (isFlashFrameRecursive) 0.5f else 1f) - innerRender(graphics, mouseX, mouseY, partialTick) + + if (post) + innerRenderPost(graphics, mouseX, mouseY, partialTick) + else + innerRender(graphics, mouseX, mouseY, partialTick) + RenderSystem.setShaderColor(1f, 1f, 1f, 1f) poseStack.popPose() } @@ -842,7 +819,7 @@ open class EditablePanel @JvmOverloads constructor( child.absoluteX = absoluteX + child.x + xOffset child.absoluteY = absoluteY + child.y + yOffset - child.render(graphics, mouseX, mouseY, partialTick) + child.render(graphics, post, mouseX, mouseY, partialTick) } if (scissor) { @@ -982,31 +959,19 @@ open class EditablePanel @JvmOverloads constructor( } } - if (innerRenderTooltips(graphics, mouseX, mouseY, partialTick)) { - return true - } + if (shouldRenderTooltips(graphics, mouseX, mouseY, partialTick)) { + if (innerRenderTooltips(graphics, mouseX, mouseY, partialTick)) { + return true + } - if (isHovered || this is AbstractButtonPanel<*> && isPressed) { - val tooltip = tooltip - val tooltipList = tooltipList - - if (tooltip != null) { + if (tooltips.isNotEmpty()) { graphics.renderComponentTooltip( font, - listOf(tooltip), + tooltips, mouseX.toInt(), mouseY.toInt() ) - return true - } else if (tooltipList != null) { - graphics.renderComponentTooltip( - font, - tooltipList, - mouseX.toInt(), - mouseY.toInt(), - ) - return true } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt index 06734b95c..def0e809d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt @@ -81,7 +81,7 @@ class EntityRendererPanel @JvmOverloads constructor( } ) - exosuitButton.tooltip = TranslatableComponent("otm.gui.exopack.toggle_visibility") + exosuitButton.tooltips.add(TranslatableComponent("otm.gui.exopack.toggle_visibility")) } else { exosuitButton = null } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index bd149b4e9..9372a505d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -9,9 +9,9 @@ import net.minecraft.client.gui.narration.NarrationElementOutput import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import org.lwjgl.opengl.GL30 -import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.client.screen.panels.button.AbstractButtonPanel +import ru.dbotthepony.mc.otm.core.TranslatableComponent open class FramePanel( screen: S, @@ -141,6 +141,58 @@ open class FramePanel( } } + inner class HelpButton : EditablePanel(screen, this@FramePanel, this@FramePanel.width - HELP_BUTTON.width - CLOSE_BUTTON.width, 0f, HELP_BUTTON.width, HELP_BUTTON.height) { + // var isActive = false + + /*override fun onClick(mouseButton: Int) { + isActive = !isActive + }*/ + + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + /*if (isPressed) { + HELP_BUTTON_PRESSED.render(graphics, 0f, 0f, width, height) + } else*/ if (isHovered /*|| isActive */) { + HELP_BUTTON_HOVERED.render(graphics, 0f, 0f, width, height) + } else { + HELP_BUTTON.render(graphics, 0f, 0f, width, height) + } + } + + /*override val needsPostRender: Boolean + get() = isActive + + override fun innerRenderPost(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + val tooltip = tooltip + val tooltipList = tooltipList + + val list = tooltipList ?: tooltip?.let { listOf(it) } ?: listOf() + + if (list.isNotEmpty()) { + graphics.renderComponentTooltip( + font, list, + mouseX.toInt(), mouseY.toInt() + ) + } + }*/ + + /*override fun shouldRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + return super.shouldRenderTooltips(graphics, mouseX, mouseY, partialTick) && !isActive + }*/ + + fun addSlotFiltersHelp(): HelpButton { + tooltips.add(TranslatableComponent("otm.gui.help.slot_filters")) + return this + } + + override fun onRemoved() { + super.onRemoved() + + if (helpButton == this) { + helpButton = null + } + } + } + protected val tabs: java.util.ArrayList = ArrayList() override fun performLayout() { @@ -150,18 +202,38 @@ open class FramePanel( } closeButton?.setPos(width - CLOSE_BUTTON.width, 0f) + helpButton?.setPos(width - HELP_BUTTON.width - CLOSE_BUTTON.width, 0f) super.performLayout() } protected var dragging = false protected var closeButton: CloseButton? = null + protected var helpButton: HelpButton? = null var closeOnEscape = false - fun makeCloseButton() { + fun makeCloseButton(): CloseButton { if (closeButton == null) closeButton = CloseButton() + + return closeButton!! + } + + fun makeHelpButton(): HelpButton { + if (helpButton == null) + helpButton = HelpButton() + + return helpButton!! + } + + fun makeHelpButton(tooltips: Collection): HelpButton { + if (helpButton == null) { + helpButton = HelpButton() + helpButton!!.tooltips.addAll(tooltips) + } + + return helpButton!! } /** @@ -315,6 +387,10 @@ open class FramePanel( val CLOSE_BUTTON_HOVERED = WidgetLocation.MISC.sprite(x = 51f, y = 11f, width = 13f, height = 11f) val CLOSE_BUTTON_PRESSED = WidgetLocation.MISC.sprite(x = 51f, y = 22f, width = 13f, height = 11f) + val HELP_BUTTON = WidgetLocation.MISC.sprite(x = 41f, y = 0f, width = 10f, height = 11f) + val HELP_BUTTON_HOVERED = WidgetLocation.MISC.sprite(x = 41f, y = 11f, width = 10f, height = 11f) + val HELP_BUTTON_PRESSED = WidgetLocation.MISC.sprite(x = 41f, y = 22f, width = 10f, height = 11f) + const val TAB_HEIGHT = 28f const val TAB_WIDTH = 28f const val TAB_HEIGHT_ACTIVE = 32f 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 7610be9bd..65ce9462e 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 @@ -20,7 +20,8 @@ class Panel2Widget>( val yFloat = mouseY.toFloat() panel.tickHover(xFloat, yFloat) - panel.render(graphics, xFloat, yFloat, partialTick) + panel.render(graphics, false, xFloat, yFloat, partialTick) + panel.render(graphics, true, xFloat, yFloat, partialTick) panel.renderTooltips(graphics, xFloat, yFloat, partialTick) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractButtonPanel.kt index 15f224659..1fbefa244 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractButtonPanel.kt @@ -1,11 +1,10 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import com.mojang.blaze3d.platform.InputConstants +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen -import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel -import java.util.function.IntConsumer import java.util.function.IntPredicate abstract class AbstractButtonPanel( @@ -65,4 +64,8 @@ abstract class AbstractButtonPanel( return true } + + override fun shouldRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + return super.shouldRenderTooltips(graphics, mouseX, mouseY, partialTick) || isPressed + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt index 4fda37f4d..d6000d0a5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt @@ -36,19 +36,12 @@ abstract class BooleanRectangleButtonPanel( if (isHovered) { val tooltipActive = tooltipActive val tooltipInactive = tooltipInactive - val tooltipList = tooltipList - val tooltip = tooltip - if (tooltipActive != null || tooltipInactive != null || tooltipList != null || tooltip != null) { - val tooltips = ArrayList(2) + if (tooltipActive != null || tooltipInactive != null || tooltips.isNotEmpty()) { + val tooltips = ArrayList(2 + this.tooltips.size) - if (tooltipList != null) { - tooltips.addAll(tooltipList) - - if (tooltipActive != null || tooltipInactive != null) - tooltips.add(SPACE) - } else if (tooltip != null) { - tooltips.add(tooltip) + if (this.tooltips.isNotEmpty()) { + tooltips.addAll(this.tooltips) if (tooltipActive != null || tooltipInactive != null) tooltips.add(SPACE) 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 96d5ae994..cf0be7ad5 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 @@ -81,12 +81,12 @@ private class PullPushButton, T : Enum>( val pushProp: BooleanInputWithFeedback ) : LargeEnumRectangleButtonPanel(screen, parent, x = x, y = y, enum = enum, prop = prop, defaultValue = defaultValue) { init { - if (pullProp.test(minecraft.player) && pushProp.test(minecraft.player)) { - tooltipList = listOf(TranslatableComponent("otm.gui.sides.pull_help").withStyle(ChatFormatting.GRAY), TranslatableComponent("otm.gui.sides.push_help").withStyle(ChatFormatting.GRAY)) - } else if (pullProp.test(minecraft.player)) { - tooltip = TranslatableComponent("otm.gui.sides.pull_help").withStyle(ChatFormatting.GRAY) - } else if (pushProp.test(minecraft.player)) { - tooltip = TranslatableComponent("otm.gui.sides.push_help").withStyle(ChatFormatting.GRAY) + if (pullProp.test(minecraft.player)) { + tooltips.add(TranslatableComponent("otm.gui.sides.pull_help").withStyle(ChatFormatting.GRAY)) + } + + if (pushProp.test(minecraft.player)) { + tooltips.add(TranslatableComponent("otm.gui.sides.push_help").withStyle(ChatFormatting.GRAY)) } } @@ -183,12 +183,12 @@ private fun moveButtons( top: EditablePanel<*>, bottom: EditablePanel<*>, ) { - top.prependTooltip(TranslatableComponent("otm.gui.sides.top")) - bottom.prependTooltip(TranslatableComponent("otm.gui.sides.bottom")) - back.prependTooltip(TranslatableComponent("otm.gui.sides.back")) - front.prependTooltip(TranslatableComponent("otm.gui.sides.front")) - left.prependTooltip(TranslatableComponent("otm.gui.sides.left")) - right.prependTooltip(TranslatableComponent("otm.gui.sides.right")) + top.tooltips.add(0, TranslatableComponent("otm.gui.sides.top")) + bottom.tooltips.add(0, TranslatableComponent("otm.gui.sides.bottom")) + back.tooltips.add(0, TranslatableComponent("otm.gui.sides.back")) + front.tooltips.add(0, TranslatableComponent("otm.gui.sides.front")) + left.tooltips.add(0, TranslatableComponent("otm.gui.sides.left")) + right.tooltips.add(0, TranslatableComponent("otm.gui.sides.right")) top.x = 30f top.y = 14f @@ -345,13 +345,11 @@ class DeviceControls>( skinElement = Widgets18.UPGRADES ) { init { - tooltip = TranslatableComponent("otm.gui.upgrades") + tooltips.add(TranslatableComponent("otm.gui.upgrades")) } - override fun tickInner() { - super.tickInner() - - tooltipList = ArrayList().also { + override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + graphics.renderComponentTooltip(font, ArrayList().also { it.add(TranslatableComponent("otm.gui.upgrades")) it.add(TextComponent("")) @@ -372,7 +370,9 @@ class DeviceControls>( it.add(i, TranslatableComponent("otm.gui.upgrades.current").withStyle(ChatFormatting.GRAY)) it.add(i, TextComponent("")) } - } + }, mouseX.toInt(), mouseY.toInt()) + + return true } override fun onClick(mouseButton: Int) { @@ -421,7 +421,7 @@ class DeviceControls>( prop = balanceInputs, skinElementActive = Widgets18.BALANCING_ENABLED, skinElementInactive = Widgets18.BALANCING_DISABLED).also { - it.tooltip = TranslatableComponent("otm.gui.balance_inputs") + it.tooltips.add(TranslatableComponent("otm.gui.balance_inputs")) }) } else { balanceInputsButton = null @@ -430,7 +430,7 @@ class DeviceControls>( if (itemConfig != null) { itemConfigButton = addButton(object : LargeRectangleButtonPanel(screen, this@DeviceControls, skinElement = Widgets18.ITEMS_CONFIGURATION) { init { - tooltip = TranslatableComponent("otm.gui.sides.item_config") + tooltips.add(TranslatableComponent("otm.gui.sides.item_config")) } override fun onClick(mouseButton: Int) { @@ -449,7 +449,7 @@ class DeviceControls>( if (energyConfig != null) { energyConfigButton = addButton(object : LargeRectangleButtonPanel(screen, this@DeviceControls, y = nextY, skinElement = Widgets18.ENERGY_CONFIGURATION) { init { - tooltip = TranslatableComponent("otm.gui.sides.energy_config") + tooltips.add(TranslatableComponent("otm.gui.sides.energy_config")) } override fun onClick(mouseButton: Int) { @@ -468,7 +468,7 @@ class DeviceControls>( if (fluidConfig != null) { fluidConfigButton = addButton(object : LargeRectangleButtonPanel(screen, this@DeviceControls, y = nextY, skinElement = Widgets18.FLUID_CONFIGURATION) { init { - tooltip = TranslatableComponent("otm.gui.sides.fluid_config") + tooltips.add(TranslatableComponent("otm.gui.sides.fluid_config")) } override fun onClick(mouseButton: Int) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt index 84571b6e8..c7332ec61 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt @@ -151,23 +151,14 @@ abstract class EnumRectangleButtonPanel>( } override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { - if (!isHovered && !isGrabbingMouseInput()) { - return super.innerRenderTooltips(graphics, mouseX, mouseY, partialTick) - } - - if (tooltip == null && tooltipList == null && enumMapping.entries.none { predicate.test(it.key) && it.value.tooltip != null }) { + if (tooltips.isEmpty() && enumMapping.entries.none { predicate.test(it.key) && it.value.tooltip != null }) { return super.innerRenderTooltips(graphics, mouseX, mouseY, partialTick) } val listing = ArrayList() - val tooltipList = tooltipList - val tooltip = tooltip - if (tooltipList != null) { - listing.addAll(tooltipList) - listing.add(SPACE) - } else if (tooltip != null) { - listing.add(tooltip) + if (tooltips.isNotEmpty()) { + listing.addAll(tooltips) listing.add(SPACE) } 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 965518f7c..f139c43da 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 @@ -147,7 +147,7 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp prop = menu.settings::ingredientPriority.asGetterSetter(watch = { _, _ -> menu.sendSettingsToServer() }), defaultValue = ItemMonitorPlayerSettings.IngredientPriority.SYSTEM) - refillPriority.tooltip = TranslatableComponent("otm.gui.item_monitor.refill_source.desc") + refillPriority.tooltips.add(TranslatableComponent("otm.gui.item_monitor.refill_source.desc")) refillPriority.add(ItemMonitorPlayerSettings.IngredientPriority.SYSTEM, tooltip = ItemMonitorPlayerSettings.IngredientPriority.SYSTEM.component, skinElement = Widgets8.WHITE_ARROW_DOWN, winding = UVWindingOrder.FLIP) refillPriority.add(ItemMonitorPlayerSettings.IngredientPriority.INVENTORY, tooltip = ItemMonitorPlayerSettings.IngredientPriority.INVENTORY.component, skinElement = Widgets8.WHITE_ARROW_DOWN) refillPriority.add(ItemMonitorPlayerSettings.IngredientPriority.INVENTORY_FIRST, tooltip = ItemMonitorPlayerSettings.IngredientPriority.INVENTORY_FIRST.component, skinElement = Widgets8.ARROW_SIDEWAYS, winding = UVWindingOrder.FLIP) @@ -168,7 +168,7 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp prop = menu.settings::resultTarget.asGetterSetter(watch = { _, _ -> menu.sendSettingsToServer() }), defaultValue = ItemMonitorPlayerSettings.ResultTarget.MIXED) - resultTarget.tooltip = TranslatableComponent("otm.gui.item_monitor.result_target.desc") + resultTarget.tooltips.add(TranslatableComponent("otm.gui.item_monitor.result_target.desc")) resultTarget.add(ItemMonitorPlayerSettings.ResultTarget.MIXED, tooltip = ItemMonitorPlayerSettings.ResultTarget.MIXED.component, skinElement = Widgets8.ARROW_SIDEWAYS) resultTarget.add(ItemMonitorPlayerSettings.ResultTarget.ALL_INVENTORY, tooltip = ItemMonitorPlayerSettings.ResultTarget.ALL_INVENTORY.component, skinElement = Widgets8.ARROW_PAINTED_UP, winding = UVWindingOrder.FLIP) resultTarget.add(ItemMonitorPlayerSettings.ResultTarget.ALL_SYSTEM, tooltip = ItemMonitorPlayerSettings.ResultTarget.ALL_SYSTEM.component, skinElement = Widgets8.ARROW_PAINTED_UP) @@ -178,7 +178,7 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp prop = menu.settings::craftingAmount.asGetterSetter(watch = { _, _ -> menu.sendSettingsToServer() }), defaultValue = ItemMonitorPlayerSettings.Amount.STACK) - craftingAmount.tooltip = TranslatableComponent("otm.gui.item_monitor.amount.desc") + craftingAmount.tooltips.add(TranslatableComponent("otm.gui.item_monitor.amount.desc")) craftingAmount.add(ItemMonitorPlayerSettings.Amount.ONE, tooltip = ItemMonitorPlayerSettings.Amount.ONE.component, skinElement = Widgets8.ONE) craftingAmount.add(ItemMonitorPlayerSettings.Amount.STACK, tooltip = ItemMonitorPlayerSettings.Amount.STACK.component, skinElement = Widgets8.S) craftingAmount.add(ItemMonitorPlayerSettings.Amount.FULL, tooltip = ItemMonitorPlayerSettings.Amount.FULL.component, skinElement = Widgets8.F) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt index 896c8513d..0853c201c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt @@ -42,7 +42,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title SlotPanel(this, inputs, menu.capsuleSlot).also { it.dock = Dock.RIGHT - it.tooltip = MItems.ESSENCE_CAPSULE.description.copy().withStyle(ChatFormatting.GRAY) + it.tooltips.add(MItems.ESSENCE_CAPSULE.description.copy().withStyle(ChatFormatting.GRAY)) } HorizontalStripPanel(this, frame, height = 18f).also { @@ -65,7 +65,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title SlotPanel(this, it, menu.servoSlot).also { it.dock = Dock.RIGHT - it.tooltip = MItems.ESSENCE_SERVO.description.copy().withStyle(ChatFormatting.GRAY) + it.tooltips.add(MItems.ESSENCE_SERVO.description.copy().withStyle(ChatFormatting.GRAY)) } } @@ -95,7 +95,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title object : LargeRectangleButtonPanel(this@EssenceStorageScreen, inputs, skinElement = STORE_1) { init { dockRight = 3f - tooltip = TranslatableComponent("otm.gui.experience.store", 1) + tooltips.add(TranslatableComponent("otm.gui.experience.store", 1)) } override fun onClick(mouseButton: Int) { @@ -110,7 +110,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title object : LargeRectangleButtonPanel(this@EssenceStorageScreen, inputs, skinElement = STORE_10) { init { dockRight = 3f - tooltip = TranslatableComponent("otm.gui.experience.store", 10) + tooltips.add(TranslatableComponent("otm.gui.experience.store", 10)) } override fun onClick(mouseButton: Int) { @@ -125,7 +125,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title object : LargeRectangleButtonPanel(this@EssenceStorageScreen, inputs, skinElement = STORE_ALL) { init { dockRight = 3f - tooltip = TranslatableComponent("otm.gui.experience.store_all") + tooltips.add(TranslatableComponent("otm.gui.experience.store_all")) } override fun onClick(mouseButton: Int) { @@ -140,7 +140,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title object : LargeRectangleButtonPanel(this@EssenceStorageScreen, outputs, skinElement = DISPENSE_1) { init { dockRight = 3f - tooltip = TranslatableComponent("otm.gui.experience.dispense", 1) + tooltips.add(TranslatableComponent("otm.gui.experience.dispense", 1)) } override fun onClick(mouseButton: Int) { @@ -155,7 +155,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title object : LargeRectangleButtonPanel(this@EssenceStorageScreen, outputs, skinElement = DISPENSE_10) { init { dockRight = 3f - tooltip = TranslatableComponent("otm.gui.experience.dispense", 10) + tooltips.add(TranslatableComponent("otm.gui.experience.dispense", 10)) } override fun onClick(mouseButton: Int) { @@ -170,7 +170,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title object : LargeRectangleButtonPanel(this@EssenceStorageScreen, outputs, skinElement = DISPENSE_ALL) { init { dockRight = 3f - tooltip = TranslatableComponent("otm.gui.experience.dispense_all") + tooltips.add(TranslatableComponent("otm.gui.experience.dispense_all")) } override fun onClick(mouseButton: Int) { @@ -187,7 +187,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title object : LargeRectangleButtonPanel(this@EssenceStorageScreen, customBar, skinElement = STORE_CUSTOM) { init { - tooltip = TranslatableComponent("otm.gui.experience.store", customDispense) + tooltips.add(TranslatableComponent("otm.gui.experience.store", customDispense)) } override fun onClick(mouseButton: Int) { @@ -212,7 +212,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title object : LargeRectangleButtonPanel(this@EssenceStorageScreen, customBar, skinElement = DISPENSE_CUSTOM) { init { - tooltip = TranslatableComponent("otm.gui.experience.dispense", customDispense) + tooltips.add(TranslatableComponent("otm.gui.experience.dispense", customDispense)) } override fun onClick(mouseButton: Int) { @@ -226,7 +226,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title object : LargeRectangleButtonPanel(this@EssenceStorageScreen, customBar, skinElement = SET_EXACT) { init { - tooltip = TranslatableComponent("otm.gui.experience.set_exact", customDispense) + tooltips.add(TranslatableComponent("otm.gui.experience.set_exact", customDispense)) dock = Dock.RIGHT dockMargin = DockProperty(right = 4f) } diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/misc.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/misc.png index bc3b614b3dd43b4cce917a916ff7fc140deec3db..defe0ff4e3e1ee706b645d29f6c32f68b0348c7c 100644 GIT binary patch delta 929 zcmV;S177^E3iS%G;{ksO1Rw~M>lRD^00VMKL_t(|+U=UZOB_KI$KN}yzapgaKQL(o zSwRV;N~eX~>OT;RErlIpkv|~u1PLTA#MHvwfd~mUslA13Bt?YSgam|;L*W|Rm%`h1 zz3lwho!PxTnGY;F>)W~czIkuv?VPx=5v{vv-Ha9x)G0J`1o?L&0? z7$RcIbJ}C%jiVk3(82e8V2q7)@W+aXl>Bg2M1AH`pBP8YV80|AXs_2RVm33A97nyV z4@nDU*LBHtUFdeZlx23qFf=;0y}dn%#!)Lvd>WljCv)GP=f#)IPSn1)226s@&CSd+ z>v#Ny z0pItz6(b_z($bQ0-^V|GD%m}H*HW^3w!a^j!bT&&ah!kn-2f4BWo0Eb5_tE^B3NAo z@92mC01K-Fh=@cL;r8~nvJ*PL21<5sE-sYpzFb|wtGPLNdv->JZi7Ya2H)96e2G{d z42128SAu!PKWQCs+etn@ehkZl!M&fU4rn%;q6Mo`@Wk?vi3b3vGsdFB4Bc?gy0xLn zXyB!RGy;DB0M^#lw8ZCmtu0HuEE1%PV7uLhcDp@wsW2{<7XdYy__W`vuo#w73a_uP zYrPqn+6E6_IRD-ImU8bfM=6Y8=#aA2YTesSRFB0}cz^O$X^c-leo*S~`SEe=gc=cn ziHk9YBVeSRIM>8^JwG3f?=}T?cXzcqOw7FWXgq(7QV5sN+;4q>Cw$i55criN)|ysb?3krR00V+TyjyFgkr$kIUOgsD6h&mw+29a1A8 zI>~>@OTXW*Tq=yuc*`l><|%%2*NPruJ&X96oFN6rqBUd zQed?Gk?dTcO5$S&80qM4|CjZLRZ6G2?(A1xpwjE`w4Dfi6a5hNeC+j{;M3^fZhQSQO0M~U{z-o!!`+08Y z_lJpJ#xzY~dtrYMSO?8!le}VKVGw78UatqHX)ZiB$^fI$NJ>1#6XL{Yy$R;Rve>vV z;6{idHxJ->KMiNYA#HaL5g+FXSsDNlk$IjcB{nOT#YTle)**nEN=4XVR{7zkgw!fR z0E2m6REB0vobe+|;jCj^(=@OwE3#rlM66b;nH%8G=_!Ay--q+_c`2N!2WXl$|29BG ztkr6vo)GnWZu`T@37D6c3;=LtS%5LdL=|DH)ymum?;jsY{eC?^!`FiY_M%lJ!#6qJi;K( z2t@#ZdcA)xHBj2m+C0R^c|zqn@ZDgL zxD-Z^Jf!5b+wFyHB6+->ir>e_BrPAWuI5HSmh@Cou;RQ3q*{Mn1{gd&!MEF6n3uwx zPDg6sz{$%a{L=IoGJulSAWw5lJwt3g1;D2-Bc!Xl#uEcG<-h3WY+UP$(1% kg+ifFC=?2XLZSH2KWe9D*)zAxga7~l07*qoM6N<$f|DPbn*aa+ From 37f4b7799419f10b7b1f959f59497bc227247396 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 9 Jul 2023 14:45:13 +0700 Subject: [PATCH 0725/1199] Exopack arbitrary inventory slots charging --- .../mc/otm/datagen/lang/English.kt | 1 + .../mc/otm/datagen/lang/Russian.kt | 1 + .../otm/capability/MatteryPlayerCapability.kt | 107 ++++++- .../ru/dbotthepony/mc/otm/client/Ext.kt | 1 + .../client/screen/ExoPackInventoryScreen.kt | 6 +- .../mc/otm/client/screen/MatteryScreen.kt | 27 +- .../screen/panels/PlayerEquipmentPanel.kt | 5 +- .../screen/panels/slot/InventorySlotPanel.kt | 50 +++ .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 30 +- .../{MapAction.kt => ChangesetAction.kt} | 2 +- .../network/synchronizer/FieldSynchronizer.kt | 301 ++++++++++++++++-- .../otm/network/synchronizer/MapChangeset.kt | 12 +- .../otm/network/synchronizer/SetChangeset.kt | 22 ++ 13 files changed, 510 insertions(+), 55 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt rename src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/{MapAction.kt => ChangesetAction.kt} (71%) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/SetChangeset.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index bd6ba264a..08a7414d8 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -118,6 +118,7 @@ private fun sounds(provider: MatteryLanguageProvider) { private fun misc(provider: MatteryLanguageProvider) { with(provider.english) { gui("help.slot_filters", "Hold CTRL to setup slot filters") + gui("help.slot_charging", "Hold ALT to switch slot charging") misc("needs_no_power", "Requires no power to operate") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index ee2336182..1d6dac6ea 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -126,6 +126,7 @@ private fun sounds(provider: MatteryLanguageProvider) { private fun misc(provider: MatteryLanguageProvider) { with(provider.russian) { gui("help.slot_filters", "Удерживайте CTRL для настройки фильтрации слотов") + gui("help.slot_charging", "Удерживайте ALT для переключения зарядки слотов") misc("needs_no_power", "Не требует энергии для работы") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 691c4eea9..3a03ed84f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -1,11 +1,14 @@ package ru.dbotthepony.mc.otm.capability +import it.unimi.dsi.fastutil.ints.IntAVLTreeSet import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import net.minecraft.ChatFormatting import net.minecraft.commands.Commands import net.minecraft.commands.arguments.EntityArgument import net.minecraft.core.Direction +import net.minecraft.nbt.ByteTag import net.minecraft.nbt.CompoundTag +import net.minecraft.nbt.IntTag import net.minecraft.nbt.ListTag import net.minecraft.nbt.StringTag import net.minecraft.network.chat.Component @@ -72,6 +75,7 @@ import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.config.ExopackConfig import ru.dbotthepony.mc.otm.container.MatteryContainer +import ru.dbotthepony.mc.otm.container.get import ru.dbotthepony.mc.otm.container.iterator import ru.dbotthepony.mc.otm.container.stream import ru.dbotthepony.mc.otm.container.vanishCursedItems @@ -80,14 +84,18 @@ import ru.dbotthepony.mc.otm.core.collect.UUIDIntModifiersMap import ru.dbotthepony.mc.otm.core.collect.filter import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.minus +import ru.dbotthepony.mc.otm.core.nbt.getByteList import ru.dbotthepony.mc.otm.core.nbt.getCompoundList +import ru.dbotthepony.mc.otm.core.nbt.getIntList import ru.dbotthepony.mc.otm.core.nbt.getStringList import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.core.util.BooleanValueCodec import ru.dbotthepony.mc.otm.core.util.IntValueCodec import ru.dbotthepony.mc.otm.core.util.ItemValueCodec import ru.dbotthepony.mc.otm.core.util.Savetables import ru.dbotthepony.mc.otm.core.util.TickList import ru.dbotthepony.mc.otm.core.util.UUIDValueCodec +import ru.dbotthepony.mc.otm.core.util.VarIntValueCodec import ru.dbotthepony.mc.otm.menu.ExoPackInventoryMenu import ru.dbotthepony.mc.otm.network.* import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer @@ -224,6 +232,27 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial synchronizer.Field(null, ItemValueCodec.nullable) } + val regularSlotChargeFlag = immutableList(Inventory.INVENTORY_SIZE + 4) { + synchronizer.bool() + } + + private fun slotChargeToDefault() { + // броня + regularSlotChargeFlag[36].boolean = true + regularSlotChargeFlag[37].boolean = true + regularSlotChargeFlag[38].boolean = true + regularSlotChargeFlag[39].boolean = true + } + + init { + slotChargeToDefault() + } + + val exoPackSlotsChargeFlag by synchronizer.Set( + codec = VarIntValueCodec, + backingSet = IntAVLTreeSet(), + ) + /** * Exopack container, which actually store items inside Exopack */ @@ -808,6 +837,18 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } } + tag["regularSlotChargeFlag"] = ListTag().also { + for (flag in regularSlotChargeFlag) { + it.add(ByteTag.valueOf(flag.boolean)) + } + } + + tag["exoPackSlotsChargeFlag"] = ListTag().also { + for (value in exoPackSlotsChargeFlag) { + it.add(IntTag.valueOf(value)) + } + } + return tag } @@ -818,6 +859,14 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial filter.value = null } + for (flag in regularSlotChargeFlag) { + flag.boolean = false + } + + exoPackSlotsChargeFlag.clear() + + slotChargeToDefault() + val regularSlotFilters = tag.getStringList("regularSlotFilters") for (i in 0 until regularSlotFilters.size.coerceAtMost(this.regularSlotFilters.size)) { @@ -826,6 +875,16 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial this.regularSlotFilters[i].value = ForgeRegistries.ITEMS.getValue(ResourceLocation.tryParse(path) ?: continue) ?: Items.AIR } + val regularSlotChargeFlag = tag.getByteList("regularSlotChargeFlag") + + for (i in 0 until regularSlotChargeFlag.size.coerceAtMost(this.regularSlotChargeFlag.size)) { + this.regularSlotChargeFlag[i].boolean = regularSlotChargeFlag[i].asInt > 0 + } + + for (v in tag.getIntList("exoPackSlotsChargeFlag")) { + this.exoPackSlotsChargeFlag.add(v.asInt) + } + // iterations deathLog.clear() @@ -965,16 +1024,50 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial if (isExoPackSmeltingInstalled) smelters.forEach { it.think() } - if (!exoPackChargeSlots.isEmpty && exoPackEnergy.batteryLevel.isPositive) { + if (exoPackEnergy.batteryLevel.isPositive) { var available = exoPackEnergy.extractEnergy(exoPackEnergy.batteryLevel, true) - for (item in exoPackChargeSlots) { - if (item.isNotEmpty) { - item.energy?.let { - available -= exoPackEnergy.extractEnergy(it.receiveEnergy(available, false), false) - } + if (!exoPackChargeSlots.isEmpty) { + for (item in exoPackChargeSlots) { + if (item.isNotEmpty) { + item.energy?.let { + available -= exoPackEnergy.extractEnergy(it.receiveEnergy(available, false), false) + } - if (!available.isPositive) break + if (!available.isPositive) break + } + } + } + + if (available.isPositive) { + for ((i, flag) in regularSlotChargeFlag.withIndex()) { + if (flag.boolean) { + val item = ply.inventory[i] + + if (item.isNotEmpty) { + item.energy?.let { + available -= exoPackEnergy.extractEnergy(it.receiveEnergy(available, false), false) + } + + if (!available.isPositive) break + } + } + } + } + + if (available.isPositive) { + for (slot in exoPackSlotsChargeFlag) { + if (slot in 0 until exoPackContainer.containerSize) { + val item = exoPackContainer[slot] + + if (item.isNotEmpty) { + item.energy?.let { + available -= exoPackEnergy.extractEnergy(it.receiveEnergy(available, false), false) + } + + if (!available.isPositive) break + } + } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/Ext.kt index c62ca4bd2..55f05461a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/Ext.kt @@ -21,6 +21,7 @@ fun Window.isKeyDown(key: Int) = InputConstants.isKeyDown(window, key) val Window.isShiftDown get() = isKeyDown(InputConstants.KEY_LSHIFT) || isKeyDown(InputConstants.KEY_RSHIFT) val Window.isCtrlDown get() = isKeyDown(InputConstants.KEY_RCONTROL) || isKeyDown(InputConstants.KEY_LCONTROL) +val Window.isAltDown get() = isKeyDown(InputConstants.KEY_RALT) || isKeyDown(InputConstants.KEY_LALT) object ShiftPressedCond : BooleanSupplier { override fun getAsBoolean(): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt index 7f4b2051c..31aaa3131 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt @@ -13,7 +13,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel -import ru.dbotthepony.mc.otm.client.screen.panels.slot.UserFilteredSlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.InventorySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.BackgroundPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel @@ -55,7 +55,7 @@ class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen> { val frame = FramePanel(this, width = 200f, height = FRAME_BASE_HEIGHT + inventoryRows * AbstractSlotPanel.SIZE, title = this.title) - frame.makeHelpButton().addSlotFiltersHelp() + frame.makeHelpButton().addSlotFiltersHelp().tooltips.add(TranslatableComponent("otm.gui.help.slot_charging")) val hotbarStrip = EditablePanel(this, frame, height = 18f) hotbarStrip.dock = Dock.BOTTOM @@ -92,7 +92,7 @@ class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen(menu: T, inventory: Inventory, tit if (menu.playerInventorySlots.isNotEmpty() && menu.autoCreateInventoryFrame) { if (menu.playerExoSuitSlots.isEmpty()) { inventoryFrame = FramePanel>(this, null, 0f, 0f, INVENTORY_FRAME_WIDTH, INVENTORY_FRAME_HEIGHT, inventory.displayName).also(this::addPanel) + inventoryFrame!!.makeHelpButton().addSlotFiltersHelp().tooltips.add(TranslatableComponent("otm.gui.help.slot_charging")) val hotbarStrip = EditablePanel(this, inventoryFrame, height = AbstractSlotPanel.SIZE) hotbarStrip.dock = Dock.BOTTOM for (slot in menu.playerHotbarSlots) { - UserFilteredSlotPanel.of(this, hotbarStrip, slot).also { + InventorySlotPanel(this, hotbarStrip, slot).also { it.dock = Dock.LEFT } } @@ -174,6 +176,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } } else { inventoryFrame = FramePanel>(this, null, 0f, 0f, INVENTORY_FRAME_WIDTH_EXTENDED, BASE_INVENTORY_FRAME_HEIGHT + AbstractSlotPanel.SIZE * inventoryRows, inventory.displayName).also(this::addPanel) + inventoryFrame!!.makeHelpButton().addSlotFiltersHelp().tooltips.add(TranslatableComponent("otm.gui.help.slot_charging")) inventoryScrollbar = DiscreteScrollBarPanel(this, inventoryFrame, { integerDivisionDown(menu.playerCombinedInventorySlots.size, 9) }, { _, old, new -> @@ -206,7 +209,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit hotbarStrip.dock = Dock.BOTTOM for (slot in menu.playerHotbarSlots) { - UserFilteredSlotPanel.of(this, hotbarStrip, slot).also { + InventorySlotPanel(this, hotbarStrip, slot).also { it.dock = Dock.LEFT } } @@ -249,7 +252,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit for (i in 0 .. (8).coerceAtMost(menu.playerCombinedInventorySlots.size - offset - 1)) { val slot = menu.playerCombinedInventorySlots[offset + i] - object : UserFilteredSlotPanel, Slot>(this@MatteryScreen, canvas, slot) { + object : InventorySlotPanel, MatteryMenu.InventorySlot>(this@MatteryScreen, canvas, slot) { init { dock = Dock.LEFT } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/PlayerEquipmentPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/PlayerEquipmentPanel.kt index 2560ad982..b0e2781cb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/PlayerEquipmentPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/PlayerEquipmentPanel.kt @@ -5,6 +5,7 @@ import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.FoldableSlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.InventorySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.BackgroundPanel import ru.dbotthepony.mc.otm.compat.cos.CosmeticToggleButton @@ -64,10 +65,10 @@ open class PlayerEquipmentPanel>( for ((slot, cosmeticSlot) in armorSlots) { if (cosmeticSlot == null) { - SlotPanel(screen, armorSlotsStrip, slot).dock = Dock.TOP + InventorySlotPanel(screen, armorSlotsStrip, slot).dock = Dock.TOP } else { FoldableSlotPanel(screen, armorSlotsStrip, - SlotPanel(screen, null, slot).also { CosmeticToggleButton(screen, it, slot.type) }, + InventorySlotPanel(screen, null, slot).also { CosmeticToggleButton(screen, it, slot.type) }, listOf(SlotPanel(screen, null, cosmeticSlot))).dock = Dock.TOP } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt new file mode 100644 index 000000000..eefd83760 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt @@ -0,0 +1,50 @@ +package ru.dbotthepony.mc.otm.client.screen.panels.slot + +import com.mojang.blaze3d.platform.InputConstants +import net.minecraft.client.gui.GuiGraphics +import net.minecraft.world.item.Item +import ru.dbotthepony.mc.otm.client.isAltDown +import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.client.playGuiClickSound +import ru.dbotthepony.mc.otm.client.render.MatterySprite +import ru.dbotthepony.mc.otm.client.render.Widgets18 +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.menu.MatteryMenu + +open class InventorySlotPanel, out T : MatteryMenu.InventorySlot>( + screen: S, + parent: EditablePanel<*>?, + slot: T, + x: Float = 0f, + y: Float = 0f, + noItemIcon: MatterySprite? = null +) : UserFilteredSlotPanel(screen, parent, slot, x, y, SIZE, SIZE, noItemIcon) { + override var slotFilter: Item? + get() = slot.filter?.get() + set(value) { slot.filter?.accept(value) } + + override fun renderSlotBackground(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + super.renderSlotBackground(graphics, mouseX, mouseY, partialTick) + + if (slot.chargeFlag?.get() == true) { + Widgets18.BATTERY_SLOT_BACKGROUND.render(graphics, 0f, 0f, width, height) + } + } + + override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { + if (button == InputConstants.MOUSE_BUTTON_LEFT && minecraft.window.isAltDown) { + val chargeFlag = slot.chargeFlag + + if (chargeFlag == null) { + return super.mouseClickedInner(x, y, button) + } else { + chargeFlag.accept(!chargeFlag.get()) + playGuiClickSound() + return true + } + } + + return super.mouseClickedInner(x, y, button) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 97b480caf..a4049eacf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -262,20 +262,40 @@ abstract class MatteryMenu @JvmOverloads protected constructor( return super.isSameInventory(other) } + var chargeFlag: GetterSetter? = null + private set + init { val mattery = ply.matteryPlayer if (mattery != null) { - if (container === inventory && slotIndex in mattery.regularSlotFilters.indices) { - filter = GetterSetter.of( - getter = { mattery.regularSlotFilters[slotIndex].value }, - setter = { MatteryPlayerNetworkChannel.sendToServer(SetInventoryFilterPacket(SetInventoryFilterPacket.Type.INVENTORY, slotIndex, it)) } - ) + if (container === inventory) { + if (slotIndex in mattery.regularSlotFilters.indices) + filter = GetterSetter.of( + getter = { mattery.regularSlotFilters[slotIndex].value }, + setter = { MatteryPlayerNetworkChannel.sendToServer(SetInventoryFilterPacket(SetInventoryFilterPacket.Type.INVENTORY, slotIndex, it)) } + ) + + if (slotIndex in mattery.regularSlotChargeFlag.indices) { + val input = booleanInput(true) { mattery.regularSlotChargeFlag[slotIndex].boolean = it } + + chargeFlag = GetterSetter.of( + getter = { mattery.regularSlotChargeFlag[slotIndex].boolean }, + setter = input::input + ) + } } else if (container === mattery.exoPackContainer) { filter = GetterSetter.of( getter = { mattery.exoPackContainer.getSlotFilter(slotIndex) }, setter = { MatteryPlayerNetworkChannel.sendToServer(SetInventoryFilterPacket(SetInventoryFilterPacket.Type.EXOPACK, slotIndex, it)) } ) + + val input = booleanInput(true) { if (it) mattery.exoPackSlotsChargeFlag.add(slotIndex) else mattery.exoPackSlotsChargeFlag.remove(slotIndex) } + + chargeFlag = GetterSetter.of( + getter = { slotIndex in mattery.exoPackSlotsChargeFlag }, + setter = input::input + ) } else { filter = null } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/MapAction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/ChangesetAction.kt similarity index 71% rename from src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/MapAction.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/ChangesetAction.kt index 2065e8c65..870e44ea7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/MapAction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/ChangesetAction.kt @@ -1,5 +1,5 @@ package ru.dbotthepony.mc.otm.network.synchronizer -enum class MapAction { +enum class ChangesetAction { CLEAR, ADD, REMOVE } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt index a86c4e5f4..76a7c5ae5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt @@ -349,6 +349,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa // use LinkedList because it is ensured memory is freed on LinkedList#clear private val mapBacklogs = Reference2ObjectOpenHashMap, LinkedList Unit>>>() + private val setBacklogs = Reference2ObjectOpenHashMap, LinkedList Unit>>>() var unused: Boolean = false private set @@ -401,6 +402,24 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa }) } + internal fun removeMapBacklog(map: Map) { + mapBacklogs.remove(map) + } + + internal fun getSetBacklog(set: Set): LinkedList Unit>> { + if (unused) { + return LinkedList() + } + + return setBacklogs.computeIfAbsent(set, Reference2ObjectFunction { + LinkedList() + }) + } + + internal fun removeSetBacklog(set: Set) { + setBacklogs.remove(set) + } + fun collectNetworkPayload(): FastByteArrayOutputStream? { if (unused || dirtyFields.isEmpty()) { return null @@ -1527,6 +1546,246 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } } + inner class Set( + private val codec: IStreamCodec, + private val backingSet: MutableSet, + private val callback: ((changes: Collection>) -> Unit)? = null, + ) : AbstractField>() { + private var isRemote = false + private var isDirty = false + + private fun pushBacklog(element: E, action: (DataOutputStream) -> Unit) { + check(!isRemote) { "Field marked as remote" } + + val pair = element to action + + forEachEndpoint { + val list = it.getSetBacklog(this) + val iterator = list.listIterator() + + for (value in iterator) { + if (value.first == element) { + iterator.remove() + } + } + + list.addLast(pair) + } + } + + override fun observe(): Boolean { + return false + } + + override fun remove() { + if (!isRemoved) { + forEachEndpoint { it.removeSetBacklog(this) } + } + + super.remove() + } + + override fun markDirty() { + check(!isRemoved) { "Field was removed" } + notifyEndpoints(this) + isDirty = true + } + + override fun markDirty(endpoint: Endpoint) { + super.markDirty(endpoint) + + endpoint.getSetBacklog(this).let { + it.clear() + it.add(null to ClearBacklogEntry) + + for (value in backingSet) { + it.add(value to { it.write(ChangesetAction.ADD.ordinal + 1); codec.write(it, value) }) + } + } + } + + override val value: MutableSet = object : MutableSet { + override fun add(element: E): Boolean { + if (backingSet.add(element)) { + if (!isRemote) { + markDirty() + + pushBacklog(element) { + it.write(ChangesetAction.ADD.ordinal + 1) + codec.write(it, element) + } + } + + return true + } + + return false + } + + override fun addAll(elements: Collection): Boolean { + var any = false + elements.forEach { any = add(it) || any } + return any + } + + override fun clear() { + if (backingSet.isNotEmpty()) { + backingSet.clear() + + if (!isRemote) { + markDirty() + + forEachEndpoint { + it.getSetBacklog(this@Set).let { + it.clear() + it.add(null to ClearBacklogEntry) + } + } + } + } + } + + override fun iterator(): MutableIterator { + return object : MutableIterator { + private val parent = backingSet.iterator() + private var lastElement: Any? = Mark + + override fun hasNext(): Boolean { + return parent.hasNext() + } + + override fun next(): E { + return parent.next().also { lastElement = it } + } + + override fun remove() { + parent.remove() + val lastElement = lastElement + + if (lastElement !== Mark) { + this.lastElement = Mark + + if (!isRemote) { + markDirty() + + pushBacklog(lastElement as E) { + it.write(ChangesetAction.REMOVE.ordinal + 1) + codec.write(it, lastElement as E) + } + } + } + } + } + } + + override fun remove(element: E): Boolean { + if (backingSet.remove(element)) { + if (!isRemote) { + markDirty() + + pushBacklog(element) { + it.write(ChangesetAction.REMOVE.ordinal + 1) + codec.write(it, element) + } + } + + return true + } + + return false + } + + override fun removeAll(elements: Collection): Boolean { + var any = false + elements.forEach { any = remove(it) || any } + return any + } + + override fun retainAll(elements: Collection): Boolean { + var any = false + + val iterator = iterator() + + for (value in iterator) { + if (value !in elements) { + any = true + iterator.remove() + } + } + + return any + } + + override val size: Int + get() = backingSet.size + + override fun contains(element: E): Boolean { + return element in backingSet + } + + override fun containsAll(elements: Collection): Boolean { + return backingSet.containsAll(elements) + } + + override fun isEmpty(): Boolean { + return backingSet.isEmpty() + } + } + + override fun write(stream: DataOutputStream, endpoint: Endpoint) { + val list = endpoint.getSetBacklog(this) + + for (value in list) { + value.second.invoke(stream) + } + + stream.write(0) + list.clear() + isDirty = false + } + + override fun read(stream: DataInputStream) { + if (!isRemote) { + isRemote = true + forEachEndpoint { it.removeSetBacklog(this) } + } + + isDirty = false + + var action = stream.read() + val changeset = LinkedList>() + + while (action != 0) { + if ((action - 1) !in ChangesetActionList.indices) { + throw IllegalArgumentException("Unknown changeset action with index ${action - 1}") + } + + when (ChangesetActionList[action - 1]) { + ChangesetAction.CLEAR -> { + changeset.add(SetChangeset(ChangesetAction.CLEAR, null)) + backingSet.clear() + } + + ChangesetAction.ADD -> { + val read = codec.read(stream) + changeset.add(SetChangeset(ChangesetAction.ADD, read)) + backingSet.add(read) + } + + ChangesetAction.REMOVE -> { + val read = codec.read(stream) + changeset.add(SetChangeset(ChangesetAction.REMOVE, read)) + backingSet.remove(read) + } + } + + action = stream.read() + } + + callback?.invoke(changeset) + } + } + inner class Map( private val keyCodec: IStreamCodec, private val valueCodec: IStreamCodec, @@ -1545,17 +1804,19 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } private fun pushBacklog(key: Any?, value: (DataOutputStream) -> Unit) { + val pair = key to value + forEachEndpoint { val list = it.getMapBacklog(this) val iterator = list.listIterator() - for (pair in iterator) { - if (pair.first == key) { + for (e in iterator) { + if (e.first == key) { iterator.remove() } } - list.addLast(key to value) + list.addLast(pair) } } @@ -1582,7 +1843,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa val valueCopy = valueCodec.copy(value) pushBacklog(key) { - it.write(MapAction.ADD.ordinal + 1) + it.write(ChangesetAction.ADD.ordinal + 1) keyCodec.write(it, key) valueCodec.write(it, valueCopy) } @@ -1631,7 +1892,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa val valueCopy = valueCodec.copy(value) val action = { it: DataOutputStream -> - it.write(MapAction.ADD.ordinal + 1) + it.write(ChangesetAction.ADD.ordinal + 1) keyCodec.write(it, key) valueCodec.write(it, valueCopy) } @@ -1660,7 +1921,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa val valueCopy = valueCodec.copy(value) backlog.add(key to { - it.write(MapAction.ADD.ordinal + 1) + it.write(ChangesetAction.ADD.ordinal + 1) keyCodec.write(it, key) valueCodec.write(it, valueCopy) }) @@ -1707,7 +1968,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa pushBacklog(key) { @Suppress("BlockingMethodInNonBlockingContext") // false positive - it.write(MapAction.ADD.ordinal + 1) + it.write(ChangesetAction.ADD.ordinal + 1) keyCodec.write(it, key) valueCodec.write(it, valueCopy) } @@ -1735,7 +1996,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa pushBacklog(key) { @Suppress("BlockingMethodInNonBlockingContext") // false positive - it.write(MapAction.REMOVE.ordinal + 1) + it.write(ChangesetAction.REMOVE.ordinal + 1) keyCodec.write(it, keyCopy) } @@ -1767,7 +2028,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa override fun read(stream: DataInputStream) { if (!isRemote) { isRemote = true - clearBacklog() + forEachEndpoint { it.removeMapBacklog(this) } observingBackingMap?.clear() } @@ -1777,27 +2038,27 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa var readAction = stream.read() - 1 while (readAction != -1) { - if (readAction >= MapActionList.size) { + if (readAction >= ChangesetActionList.size) { throw IndexOutOfBoundsException("Unknown map action with ID $readAction") } - when (MapActionList[readAction]) { - MapAction.CLEAR -> { + when (ChangesetActionList[readAction]) { + ChangesetAction.CLEAR -> { backingMap.clear() changeset.add(ClearMapChangeset) } - MapAction.ADD -> { + ChangesetAction.ADD -> { val key = keyCodec.read(stream) val value = valueCodec.read(stream) backingMap[key] = value - changeset.add(MapChangeset(MapAction.ADD, key, value)) + changeset.add(MapChangeset(ChangesetAction.ADD, key, value)) } - MapAction.REMOVE -> { + ChangesetAction.REMOVE -> { val key = keyCodec.read(stream) backingMap.remove(key) - changeset.add(MapChangeset(MapAction.REMOVE, key, null)) + changeset.add(MapChangeset(ChangesetAction.REMOVE, key, null)) } } @@ -1860,9 +2121,11 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return i } + private object Mark + companion object { - private val ClearBacklogEntry = { stream: DataOutputStream -> stream.write(MapAction.CLEAR.ordinal + 1) } - private val MapActionList = MapAction.values() - private val ClearMapChangeset = MapChangeset(MapAction.CLEAR, null, null) + private val ClearBacklogEntry = { stream: DataOutputStream -> stream.write(ChangesetAction.CLEAR.ordinal + 1) } + private val ChangesetActionList = ChangesetAction.values() + private val ClearMapChangeset = MapChangeset(ChangesetAction.CLEAR, null, null) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/MapChangeset.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/MapChangeset.kt index f7cf986e4..47b1f5105 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/MapChangeset.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/MapChangeset.kt @@ -1,23 +1,23 @@ package ru.dbotthepony.mc.otm.network.synchronizer data class MapChangeset( - val action: MapAction, + val action: ChangesetAction, val key: K?, val value: V? ) { inline fun map(add: (K, V) -> Unit, remove: (K) -> Unit) { when (action) { - MapAction.ADD -> add.invoke(key!!, value!!) - MapAction.REMOVE -> remove.invoke(key!!) + ChangesetAction.ADD -> add.invoke(key!!, value!!) + ChangesetAction.REMOVE -> remove.invoke(key!!) else -> {} } } inline fun map(add: (K, V) -> Unit, remove: (K) -> Unit, clear: () -> Unit) { when (action) { - MapAction.CLEAR -> clear.invoke() - MapAction.ADD -> add.invoke(key!!, value!!) - MapAction.REMOVE -> remove.invoke(key!!) + ChangesetAction.CLEAR -> clear.invoke() + ChangesetAction.ADD -> add.invoke(key!!, value!!) + ChangesetAction.REMOVE -> remove.invoke(key!!) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/SetChangeset.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/SetChangeset.kt new file mode 100644 index 000000000..8c8894616 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/SetChangeset.kt @@ -0,0 +1,22 @@ +package ru.dbotthepony.mc.otm.network.synchronizer + +data class SetChangeset( + val action: ChangesetAction, + val value: V? +) { + inline fun map(add: (V) -> Unit, remove: (V) -> Unit) { + when (action) { + ChangesetAction.ADD -> add.invoke(value!!) + ChangesetAction.REMOVE -> remove.invoke(value!!) + else -> {} + } + } + + inline fun map(add: (V) -> Unit, remove: (V) -> Unit, clear: () -> Unit) { + when (action) { + ChangesetAction.CLEAR -> clear.invoke() + ChangesetAction.ADD -> add.invoke(value!!) + ChangesetAction.REMOVE -> remove.invoke(value!!) + } + } +} From 2e894abd670149f4840dc57aa2448bfe296e2849 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 9 Jul 2023 14:50:55 +0700 Subject: [PATCH 0726/1199] Make help and close buttons lesss ugly --- .../mc/otm/client/screen/panels/FramePanel.kt | 12 ++++++------ .../textures/gui/widgets/misc.png | Bin 1397 -> 1385 bytes 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index 9372a505d..8d3588158 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -383,13 +383,13 @@ open class FramePanel( val TAB_LEFT_CONNECTION = WidgetLocation.MISC.sprite(x = 33f, y = 0f, width = 3f, height = 5f) val TAB_BACKGROUND = WidgetLocation.MISC.sprite(x = 30f, y = 6f, width = 6f, height = 6f) - val CLOSE_BUTTON = WidgetLocation.MISC.sprite(x = 51f, y = 0f, width = 13f, height = 11f) - val CLOSE_BUTTON_HOVERED = WidgetLocation.MISC.sprite(x = 51f, y = 11f, width = 13f, height = 11f) - val CLOSE_BUTTON_PRESSED = WidgetLocation.MISC.sprite(x = 51f, y = 22f, width = 13f, height = 11f) + val CLOSE_BUTTON = WidgetLocation.MISC.sprite(x = 51f, y = 0f, width = 13f, height = 12f) + val CLOSE_BUTTON_HOVERED = WidgetLocation.MISC.sprite(x = 51f, y = 12f, width = 13f, height = 12f) + val CLOSE_BUTTON_PRESSED = WidgetLocation.MISC.sprite(x = 51f, y = 24f, width = 13f, height = 12f) - val HELP_BUTTON = WidgetLocation.MISC.sprite(x = 41f, y = 0f, width = 10f, height = 11f) - val HELP_BUTTON_HOVERED = WidgetLocation.MISC.sprite(x = 41f, y = 11f, width = 10f, height = 11f) - val HELP_BUTTON_PRESSED = WidgetLocation.MISC.sprite(x = 41f, y = 22f, width = 10f, height = 11f) + val HELP_BUTTON = WidgetLocation.MISC.sprite(x = 41f, y = 0f, width = 10f, height = 12f) + val HELP_BUTTON_HOVERED = WidgetLocation.MISC.sprite(x = 41f, y = 12f, width = 10f, height = 12f) + val HELP_BUTTON_PRESSED = WidgetLocation.MISC.sprite(x = 41f, y = 24f, width = 10f, height = 12f) const val TAB_HEIGHT = 28f const val TAB_WIDTH = 28f diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/misc.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/misc.png index defe0ff4e3e1ee706b645d29f6c32f68b0348c7c..86ed9112a370e41578c233a9dab7af36f76c224e 100644 GIT binary patch delta 916 zcmV;F18e;C3h4^4T>`NK zGKKzuW(dCc57dK3gVbi|4``D>D6|nY{R6fj7*euywhZ==DS>7wEd)wU0$#FSheYbx zNT)m9$+E+Jlg>Py-}l~kr}yq~b90k|BAU%6xUP#2L*9I$4G@1qC;))(`}Z%=`_~W= zW8PEtG0Bf|NI(US;B|f;_S*4c3oxUVjoN zWkLuggn;k+R3^K_;ZUn@hlhs{`cYmK`8f1?J?Xh^+m4<+&r|lbT$BtuosM*7ZQGt9 zJwMK3TUY=FgMokaJ2DyfJTD^63sebK6g*OKK}f>F0uX-p7e$`6WA}|bmjEIn4T3-` z*{n-}4H8cYx)p$yWpNE2DnC?JfNYSGf|kc7i0pTsSBB=PfQ5esS=ra?b#NRfv0_9- zY&06ebEm0Fxfjrddc7X?28f7TTU)V8Ncueq{U1Mt?4Eyo+!wNYadZ^*0=d-zlv2v8 z2zPgP3+oBI?QO76PAC9iu7waGg!;a(yyknqCPH@audambzTMow+x2z$aDGk;s|2&+ z!fi*-&-RbiH^FAJ$=k4&jyy|xe$3+4WCEwvYT`Hwfa|*9VTP*QrR*)sl3p4z89%L7 zBhpFaqfLKsXJCBm_`qJjh5|n)J1r81llxAZxpBm3B zcLSf!z6;qs|MFSL?q$C(elOrSj%cAo+1s5s42OTiuwE$iZs6U$NrbdU?t31yq+t9=P`QqUWdf8$AaitI`WxdwVma z=f^CLr&DNGDv4v^N^qGVlks+?0>{%Smwcpv@FXWIMx#;TYTyMSiM)^kMx#+71Xani znGb)JARPdfxM&c9AfUVxqD3tQHuJn7l+(&v$zqTaLbybA+zW`xpEsTffJTX@-3cg@ z*Y){}oT=4nT4XsMj}cZ7D|;fO3ndY9t4vTS04(vx8U*fFKy_)XOaLCU#0?A#3=9km q3=9km3=9km3=9km3=9nZ;~$b}lamsA4NnXJ000004mdqM&HM~cgveeb-t;0^Dl%b78&SHH=74D5FI#*v5{ga% zL`3TKdPc?OO@(nA-ZQ2n02db*g$AR_4|OBJ6h$n8nB3<@WvD7?PL(-2Qz>jZ#~sH3 z-}ku{BO>C`(vouD$3K25**$vKQnGutzaN*vMkBy+ocMp;01JN_KB9E|l!PTwTGdxjA@yc1DG6gGKBH-`PfdiC7*C zgzbq}f_cS1X&rFeNj^V*49kPTy`QNLXf~Uo1*=l<#PX1d2LPxu#-hUv-EhykwV}yq z;H7~y0swyi*4Eav#OHafEla#C5~Pb@yWNI%yFGQOFfNuC0X3QUwBM_+7?x5BudlCb zy&0L>1`l62|K0nRa_=xlDU4v~kh0Zk-P=u6kHu7YfAUpnj88v)Q0njb@p0^g8WDks zi!p{HV5FTm*Ti`}KOc?nHU)NfceOf9%)InyJkNi311G=#su^BiE1CVdxq+9nv+(Ks zTwV(MzOPy+QS#fJG{P{9>V@2qa2f2xmxzPmP}o-51(L#5t3^@n>lQzk!4AxLTk$1w z!bYPJi#`|*VWZK=z6{fsXP|XB7Qs_QX?Qb z$;p39zu&K1DvZx~?g;4j`=tw1i2zd|5fLu}#)XUQ5D|z7!Z75n_GAAPfmLv(&;eOe zV6^>_>|CHq;$sIG>F93%m-UBLN~gN+>{nf&((CZFod}tvrXp^d1!_4UDg2>2LHI79 zn;KK&fQKC77K_DVu~;k?i^XEGSS%Kc#bOw--0=^RJ Date: Sun, 9 Jul 2023 15:06:42 +0700 Subject: [PATCH 0727/1199] Proper charge slot background --- .../mc/otm/client/render/Widgets18.kt | 1 + .../client/screen/ExoPackInventoryScreen.kt | 5 ++++- .../screen/panels/slot/AbstractSlotPanel.kt | 5 ++++- .../screen/panels/slot/InventorySlotPanel.kt | 6 ++---- .../panels/slot/UserFilteredSlotPanel.kt | 4 ++++ .../textures/gui/widgets/slot_backgrounds.png | Bin 995 -> 1030 bytes .../textures/gui/widgets/slot_backgrounds.xcf | Bin 3973 -> 4981 bytes 7 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt index 71f858864..8a54ddce1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt @@ -58,6 +58,7 @@ object Widgets18 { val EQUIPMENT_BATTERY_SLOT_BACKGROUND = slotBgGrid.next() val PATTERN_SLOT_BACKGROUND = slotBgGrid.next() val MATTER_CAPACITOR_SLOT_BACKGROUND = slotBgGrid.next() + val CHARGE_SLOT_BACKGROUND = slotBgGrid.next() private val controlsGrid = WidgetLocation.SIDE_CONTROLS.grid(rows = 8, columns = 9) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt index 31aaa3131..f3e494f47 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt @@ -218,7 +218,10 @@ class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen> @JvmOverloads constru y: Float = 0f, width: Float = SIZE, height: Float = SIZE, - open val noItemIcon: IGUIRenderable? = null + open var noItemIcon: IGUIRenderable? = null ) : EditablePanel(screen, parent, x, y, width, height), IItemStackPanel { + open var slotBackground: IGUIRenderable? = null + protected open fun renderSlotBackground(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { SLOT_BACKGROUND.render(graphics, width = width, height = height) + slotBackground?.render(graphics, 0f, 0f, width, height) } protected open fun renderRegular(graphics: GuiGraphics, itemstack: ItemStack, countOverride: String? = null) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt index eefd83760..afbb6d4b1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt @@ -24,11 +24,9 @@ open class InventorySlotPanel, out T : MatteryMenu.Inve get() = slot.filter?.get() set(value) { slot.filter?.accept(value) } - override fun renderSlotBackground(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { - super.renderSlotBackground(graphics, mouseX, mouseY, partialTick) - + override fun renderBackgroundBeforeFilter(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (slot.chargeFlag?.get() == true) { - Widgets18.BATTERY_SLOT_BACKGROUND.render(graphics, 0f, 0f, width, height) + Widgets18.CHARGE_SLOT_BACKGROUND.render(graphics, 0f, 0f, width, height) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt index d38a4f77e..2c23eb01d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt @@ -36,9 +36,13 @@ abstract class UserFilteredSlotPanel, out T : Slot>( ) : SlotPanel(screen, parent, slot, x, y, width, height, noItemIcon) { abstract var slotFilter: Item? + protected open fun renderBackgroundBeforeFilter(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {} + override fun renderSlotBackground(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { super.renderSlotBackground(graphics, mouseX, mouseY, partialTick) + renderBackgroundBeforeFilter(graphics, mouseX, mouseY, partialTick) + if (slotFilter != null) { if (slotFilter !== Items.AIR) { val itemStack = ItemStack(slotFilter!!, 1) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/slot_backgrounds.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/slot_backgrounds.png index 33348815c94a6593e190e4067a75b03fa76988e3..38f3005c642c03f263065b6b08599cda8a6176e0 100644 GIT binary patch delta 947 zcmV;k15Etm2ZjicJ%2zP#b47(RVpHO5OK&*o$R6_j-`r4uu$3xtvZ-o`UOoIk`xz5 z!L{Jv$70pN#aUMeS3wZ`0C9D3Qgo3L|Cbb6#CUMrk9YSTckck9S!Jpjhyki*8RK2h-P^xs+Wq|iHMDY$BSn|v00006VoOIv0F$}_D1QeD2m&XOl9W*Z00IL^ zL_t(|+U=OVQo=wKMiYjD#=DXCY*i-uoc8)KRajbX)D#QY@qGT8v zyS3VwESqFE34(ggOeP^AckX_CckeEq2d75}A=795{yEb=*TjNuzmj;Hk9WVxJd$8R zZ%{3v^(vE4V}EhFed#(_(>rzZIdD)k3atXnU*C+Sr0&;=Q^iR|V(Q|T3Y`))BhbzD zm4A8hnfv1H-Fnb+kMB=kFtr?WfIn(<%wewVSm0@W{zXhaK+ZnG-ls#{XXgo~j9n<`CY@sr3-nR3k%f!^?tHg;$ zVWvb?%T`@X2~^a@^4fe^KIw9gMqy@LXH#ND9n2(5(+fhY5-XZGU0hKmPF|Z&i=)a* z-Ak{Lihl&FGp?52|J4in*>wf#8po#1o7#F=7qiJH8imP`I|tb=q-<8H$_@J2C63Kj zBk1;}D#5%tsP4GhF0OFdxi_-px7cQw%B|}D@5k0bW#w{;T{!^!J!a1n`5XQ=t&I>u z&YmZdpBx9_ARL5)a1agx90WKB2jL(b1ONa404M+e0000000000000000000cz5u2W Vb#uK*(9Qq=002ovPDHLkV1miJ!Gr(+ delta 912 zcmV;B18@9>2;&EkJ%3OXg-=sOkxBY4yF-8NJ4 zn3&D2iaoCgU<6@EkYr{ViS%LyzV&ra-Bfo`p5@>7XZ5Rji+=$Dk$8?7rcJy-JhN#V zocD<%tR$<%=fvYCU6A;Z>x##3oQp0CJTqcuQuD+SVzJo4N(Zx&sS!^TORA<*zL51; z<-EmNtJGNQp8SQOyuOm=I;~;Ev4jMY5TT%kGAghUrCle*LW<5~KK>!spCp$;t}+-o z7Epx-+4Y0}!GG`BT7{`eFDVoQx?ddUV-)Dw1)6oo`95}><_Qpd2CnqBzuEw1KS{5* zHR%WlZvz+CZB5w&E_Z;zCqp)6R|?V+3I*W(jJ_!c4BP^JYu?;i=Qw=;GBm5@8{ps& z7%Nity3f0NJLmRqPiuZZxTA8z1ijBF00006VoOIv0F$}_D1QMT1}hqU5SKy#00H1h zL_t(|+U?gpPQx%1!11K&(1n39Q$L0@opOy_03w41dSD>tIdqwC&H)3`&#Os)5DZyD^pI{Wk6R%%r+t>cMXebSbDxfbMQ@ z!t1NA$`|h+9*gVwd>%YKzbKs-LWI$1l5aQbaJyMMbtucSTnJ$tNIIMT1a!Gle#?8U z(zz56J(xZH&%47Q5U-1TcNhfv(X_C-EW-M;s^FM{uzy&tl;f0ouG7BmnLbG0cA939 zyiRA+quKOts#skL$=|1*Jx2lB@At-QlcwigNoUhy-7&2{rw)`-=4~raIZaGu-lv^3 ziIo(UC0kZ88KAlMgQT}+DARWMUvy5104rC8m<=`t&P+Nmn@<>1Kl zlK0Acq<^}AwHa4WumAD|{p`8}b#2F{%$v%3Qx&u6PnyKVQMm@$Zlr8>sd6^xXP0(t zJ~g7@IF~6{wFb2vSKnn;xO};HvgNn<%rK>!@Au!Y?Sq=qYJDXc#TTj-L6ErfvD zX_KgMf_Q>OAf>ST4_KzLxFV-uqFKN5W|OSuK%99q-<|K9eLEj^clFY@%j-A23mdn- zUSB0?{vD^|D^A<9PA6|T{bQcO$_@|XT=5|Pn13oBn*4qKwzyxc3;0CSqbckI^6{N{MCOvDQvoEBeK$4)}+5 z&IEbv$tc;UA$B>RNc(iCQGgZwgz6Y+Xe}+aq9aZx_@FAsrEbueZt}h}G)r&tQOXTc zyock#LAX4pj5A8e<8gFBAfEmUC#FF{ln~3@x4ZgnV|fw-9^;&|JkBRF;4vs*d7xMh zA+@Zy7AFBtRgFsn90QzwEKf8n9X!bi4;+NMgA>LXCH}!fgNP_1mU+<@Uu=gKCklZR zI;VycSMSFqh(hp$s9<@ZSPmhzthkmZ0#8+r%Md&vc$^Wkbl^lMIB*ay&k^H{64%b~ z%#l~(+bJ*pr_N>fyerxB=97%o!hCDv`16HMR-@^>*7k@Ttk!Ptv)WQBxNZN8nP9E9 v?f7ql6};-b@n1GnXCYheoY%{vcXb~19tU3cH!x0_Y{BMl#mZM2u-K7CE30)78y;+14;Iu{KZM$Rs?uj+32BdP^L)-_%uJl|P#F%! fYOn<7 Date: Sun, 9 Jul 2023 15:09:51 +0700 Subject: [PATCH 0728/1199] Move empty slot background from constructor to mutable property --- .../screen/panels/slot/AbstractSlotPanel.kt | 5 ++--- .../screen/panels/slot/InventorySlotPanel.kt | 3 +-- .../otm/client/screen/panels/slot/SlotPanel.kt | 16 ++++++---------- .../screen/panels/slot/UserFilteredSlotPanel.kt | 9 +++------ 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt index 14e06d1b0..61866d64f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.client.screen.panels.slot import com.mojang.blaze3d.systems.RenderSystem -import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen.getTooltipFromItem import net.minecraft.client.renderer.GameRenderer @@ -21,9 +20,9 @@ abstract class AbstractSlotPanel> @JvmOverloads constru y: Float = 0f, width: Float = SIZE, height: Float = SIZE, - open var noItemIcon: IGUIRenderable? = null ) : EditablePanel(screen, parent, x, y, width, height), IItemStackPanel { open var slotBackground: IGUIRenderable? = null + open var slotBackgroundEmpty: IGUIRenderable? = null protected open fun renderSlotBackground(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { SLOT_BACKGROUND.render(graphics, width = width, height = height) @@ -54,7 +53,7 @@ abstract class AbstractSlotPanel> @JvmOverloads constru renderRegular(graphics, itemStack) if (itemStack.isEmpty) { - noItemIcon?.render(graphics, 0f, 0f, width, height) + slotBackgroundEmpty?.render(graphics, 0f, 0f, width, height) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt index afbb6d4b1..03b4f9517 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt @@ -18,8 +18,7 @@ open class InventorySlotPanel, out T : MatteryMenu.Inve slot: T, x: Float = 0f, y: Float = 0f, - noItemIcon: MatterySprite? = null -) : UserFilteredSlotPanel(screen, parent, slot, x, y, SIZE, SIZE, noItemIcon) { +) : UserFilteredSlotPanel(screen, parent, slot, x, y, SIZE, SIZE) { override var slotFilter: Item? get() = slot.filter?.get() set(value) { slot.filter?.accept(value) } 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 98fe73aac..509a530d6 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 @@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.client.screen.panels.slot import com.mojang.blaze3d.systems.RenderSystem -import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.ChatFormatting import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.renderer.GameRenderer @@ -11,8 +10,6 @@ import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.client.render.IGUIRenderable -import ru.dbotthepony.mc.otm.client.render.MatterySprite import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.render.drawRect import ru.dbotthepony.mc.otm.client.render.setDrawColor @@ -30,8 +27,7 @@ open class SlotPanel, out T : Slot> @JvmOverloads const y: Float = 0f, width: Float = SIZE, height: Float = SIZE, - noItemIcon: IGUIRenderable? = null -) : AbstractSlotPanel(screen, parent, x, y, width, height, noItemIcon), ISlotPanel { +) : AbstractSlotPanel(screen, parent, x, y, width, height), ISlotPanel { override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { screen.returnSlot = slot return true @@ -108,7 +104,7 @@ open class SlotPanel, out T : Slot> @JvmOverloads const RenderSystem.setShaderTexture(0, texture.atlasLocation()) graphics.blit(1, 1, 0, 16, 16, texture) } else { - noItemIcon?.render(graphics, 0f, 0f, width = width, height = height) + slotBackgroundEmpty?.render(graphics, 0f, 0f, width = width, height = height) } } @@ -133,7 +129,7 @@ fun , T : Slot> BatterySlotPanel( y: Float = 0f, width: Float = AbstractSlotPanel.SIZE, height: Float = AbstractSlotPanel.SIZE, -) = SlotPanel(screen, parent, slot, x, y, width, height, Widgets18.BATTERY_SLOT_BACKGROUND) +) = SlotPanel(screen, parent, slot, x, y, width, height).also { it.slotBackgroundEmpty = Widgets18.BATTERY_SLOT_BACKGROUND } fun , T : Slot> EquipmentBatterySlotPanel( screen: S, @@ -143,7 +139,7 @@ fun , T : Slot> EquipmentBatterySlotPanel( y: Float = 0f, width: Float = AbstractSlotPanel.SIZE, height: Float = AbstractSlotPanel.SIZE, -) = SlotPanel(screen, parent, slot, x, y, width, height, Widgets18.EQUIPMENT_BATTERY_SLOT_BACKGROUND) +) = SlotPanel(screen, parent, slot, x, y, width, height).also { it.slotBackgroundEmpty = Widgets18.EQUIPMENT_BATTERY_SLOT_BACKGROUND } fun , T : Slot> PatternSlotPanel( screen: S, @@ -153,7 +149,7 @@ fun , T : Slot> PatternSlotPanel( y: Float = 0f, width: Float = AbstractSlotPanel.SIZE, height: Float = AbstractSlotPanel.SIZE, -) = SlotPanel(screen, parent, slot, x, y, width, height, Widgets18.PATTERN_SLOT_BACKGROUND) +) = SlotPanel(screen, parent, slot, x, y, width, height).also { it.slotBackgroundEmpty = Widgets18.PATTERN_SLOT_BACKGROUND } fun , T : Slot> MatterCapacitorSlotPanel( screen: S, @@ -163,4 +159,4 @@ fun , T : Slot> MatterCapacitorSlotPanel( y: Float = 0f, width: Float = AbstractSlotPanel.SIZE, height: Float = AbstractSlotPanel.SIZE, -) = SlotPanel(screen, parent, slot, x, y, width, height, Widgets18.MATTER_CAPACITOR_SLOT_BACKGROUND) +) = SlotPanel(screen, parent, slot, x, y, width, height).also { it.slotBackgroundEmpty = Widgets18.MATTER_CAPACITOR_SLOT_BACKGROUND } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt index 2c23eb01d..efdaea426 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt @@ -32,8 +32,7 @@ abstract class UserFilteredSlotPanel, out T : Slot>( y: Float = 0f, width: Float = SIZE, height: Float = SIZE, - noItemIcon: MatterySprite? = null -) : SlotPanel(screen, parent, slot, x, y, width, height, noItemIcon) { +) : SlotPanel(screen, parent, slot, x, y, width, height) { abstract var slotFilter: Item? protected open fun renderBackgroundBeforeFilter(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {} @@ -129,10 +128,9 @@ abstract class UserFilteredSlotPanel, out T : Slot>( y: Float = 0f, width: Float = SIZE, height: Float = SIZE, - noItemIcon: MatterySprite? = null, filter: GetterSetter ): UserFilteredSlotPanel { - return object : UserFilteredSlotPanel(screen, parent, slot, x, y, width, height, noItemIcon) { + return object : UserFilteredSlotPanel(screen, parent, slot, x, y, width, height) { override var slotFilter: Item? by filter } } @@ -145,9 +143,8 @@ abstract class UserFilteredSlotPanel, out T : Slot>( y: Float = 0f, width: Float = SIZE, height: Float = SIZE, - noItemIcon: MatterySprite? = null ): UserFilteredSlotPanel { - return object : UserFilteredSlotPanel(screen, parent, slot, x, y, width, height, noItemIcon) { + return object : UserFilteredSlotPanel(screen, parent, slot, x, y, width, height) { override var slotFilter: Item? get() = slot.filter?.get() set(value) { slot.filter?.accept(value) } From 2095120abdfdb2ae5a114c0d110ef672818ad2c3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 9 Jul 2023 15:22:29 +0700 Subject: [PATCH 0729/1199] Make help and close buttons bigger --- .../mc/otm/client/screen/panels/FramePanel.kt | 12 ++++++------ .../textures/gui/widgets/misc.png | Bin 1385 -> 1378 bytes 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index 8d3588158..58b1be9c0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -383,13 +383,13 @@ open class FramePanel( val TAB_LEFT_CONNECTION = WidgetLocation.MISC.sprite(x = 33f, y = 0f, width = 3f, height = 5f) val TAB_BACKGROUND = WidgetLocation.MISC.sprite(x = 30f, y = 6f, width = 6f, height = 6f) - val CLOSE_BUTTON = WidgetLocation.MISC.sprite(x = 51f, y = 0f, width = 13f, height = 12f) - val CLOSE_BUTTON_HOVERED = WidgetLocation.MISC.sprite(x = 51f, y = 12f, width = 13f, height = 12f) - val CLOSE_BUTTON_PRESSED = WidgetLocation.MISC.sprite(x = 51f, y = 24f, width = 13f, height = 12f) + val CLOSE_BUTTON = WidgetLocation.MISC.sprite(x = 51f, y = 0f, width = 13f, height = 14f) + val CLOSE_BUTTON_HOVERED = WidgetLocation.MISC.sprite(x = 51f, y = 14f, width = 13f, height = 14f) + val CLOSE_BUTTON_PRESSED = WidgetLocation.MISC.sprite(x = 51f, y = 28f, width = 13f, height = 14f) - val HELP_BUTTON = WidgetLocation.MISC.sprite(x = 41f, y = 0f, width = 10f, height = 12f) - val HELP_BUTTON_HOVERED = WidgetLocation.MISC.sprite(x = 41f, y = 12f, width = 10f, height = 12f) - val HELP_BUTTON_PRESSED = WidgetLocation.MISC.sprite(x = 41f, y = 24f, width = 10f, height = 12f) + val HELP_BUTTON = WidgetLocation.MISC.sprite(x = 40f, y = 0f, width = 11f, height = 14f) + val HELP_BUTTON_HOVERED = WidgetLocation.MISC.sprite(x = 40f, y = 14f, width = 11f, height = 14f) + val HELP_BUTTON_PRESSED = WidgetLocation.MISC.sprite(x = 40f, y = 28f, width = 11f, height = 14f) const val TAB_HEIGHT = 28f const val TAB_WIDTH = 28f diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/misc.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/misc.png index 86ed9112a370e41578c233a9dab7af36f76c224e..60771438404512ce03cc5215d6cc037946f39f9f 100644 GIT binary patch delta 909 zcmV;819JT73gQZ|^y2WT6EDYOyPoeQ=WLrRv;mcdJ=2AZX`P$)GCc*%MlVku{1 zot|_jTc-B|5nXta-|zjo_udIAl?o%0sMqU+QVR2>=zXCKv2A~w5kiRX`}YsA`^NwP zmY$K;Po#$t5|DxGx`a|X=Mk?j05JZ?F%Z2kGkZ>tlEU}0BxQpj$jhUt!0Tb;^&=}n znb@|?Y}+Qj?=!52$K$bb-MZZ_3H316MSc|qgF)(dJB}0Gd!8q)tFfstY_(dcz3Vv6 z0_o*-7TJv%U^IUkrG6%j$34%BNQ(?rB3lX(sZ~aZ!`ciG*8O#n=jHf)BhM570AN87 zC?%UU6?h|wB0+TofMr=ifqCZ#vJsHhNO4BXV-p0v&Wqa6JR@N3Wsnbh(=>_ey0IN2 z06?``EyQN3Gy+W1jAjD>fLg7#G7{qczx4)K9t=bsVY`3bMj0V#Pf;=r=2`lD-%SMPJpI8Q)&8F03l-E#%AED4*&0I@YTV=!!*dBH*0hxBH%g}<=|P?*C>-vly~kBbJZ5n}s*9C91hu@7LP0UZI`aw3!_ z6?oDjBa|@Y)=e-?B@l(bXpJ%ePrOJ*P*MI+RX{d1wgE=bysM$1p`oFnp`oFnp`oFn jp`oFnp`oFXAN~R0m%T>`NK zGKKzuW(dCc57dK3gVbi|4``D>D6|nY{R6fj7*euywhZ==DS>7wEd)wU0$#FSheYbx zNT)m9$+E+Jlg>Py-}l~kr}yq~b90k|BAU%6xUP#2L*9I$4G@1qC;))(`}Z%=`_~W= zW8PEtG0Bf|NI(US;B|f;_S*4c3oxUVjoN zWkLuggn;k+R3^K_;ZUn@hlhs{`cYmK`8f1?J?Xh^+m4<+&r|lbT$BtuosM*7ZQGt9 zJwMK3TUY=FgMokaJ2DyfJTD^63sebK6g*OKK}f>F0uX-p7e$`6WA}|bmjEIn4T3-` z*{n-}4H8cYx)p$yWpNE2DnC?JfNYSGf|kc7i0pTsSBB=PfQ5esS=ra?b#NRfv0_9- zY&06ebEm0Fxfjrddc7X?28f7TTU)V8Ncueq{U1Mt?4Eyo+!wNYadZ^*0=d-zlv2v8 z2zPgP3+oBI?QO76PAC9iu7waGg!;a(yyknqCPH@audambzTMow+x2z$aDGk;s|2&+ z!fi*-&-RbiH^FAJ$=k4&jyy|xe$3+4WCEwvYT`Hwfa|*9VTP*QrR*)sl3p4z89%L7 zBhpFaqfLKsXJCBm_`qJjh5|n)J1r81llxAZxpBm3B zcLSf!z6;qs|MFSL?q$C(elOrSj%cAo+1s5s42OTiuwE$iZs6U$NrbdU?t31yq+t9=P`QqUWdf8$AaitI`WxdwVma z=f^CLr&DNGDv4v^N^qGVlks+?0>{%Smwcpv@FXWIMx#;TYTyMSiM)^kMx#+71Xani znGb)JARPdfxM&c9AfUVxqD3tQHuJn7l+(&v$zqTaLbybA+zW`xpEsTffJTX@-3cg@ z*Y){}oT=4nT4XsMj}cZ7D|;fO3ndY9t4vTS04(vx8U*fFKy_)XOaLCU#0?A#3=9km q3=9km3=9km3=9km3=9nZ;~$b}lamsA4NnXJ0000= From 5d8b770b94ee255f464c1930761ebfbc3759588a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 9 Jul 2023 15:48:04 +0700 Subject: [PATCH 0730/1199] Do some code cleaning in field synchronizer --- .../network/synchronizer/FieldSynchronizer.kt | 222 ++++-------------- 1 file changed, 41 insertions(+), 181 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt index 76a7c5ae5..0c5a96766 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt @@ -48,7 +48,7 @@ import kotlin.reflect.KProperty0 * Universal, one-to-many value synchronizer, allowing to synchronize values from server to client * anywhere, where input/output streams are supported */ -@Suppress("unused") +@Suppress("unused", "BlockingMethodInNonBlockingContext") class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCallback: Boolean) { constructor() : this(Runnable {}, false) constructor(callback: Runnable) : this(callback, false) @@ -485,6 +485,8 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa final override var isRemoved = false private set + protected var isDirty = false + override fun remove() { if (isRemoved) return @@ -508,6 +510,12 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa check(!isRemoved) { "Field was removed" } endpoint.addDirtyField(this) } + + override fun markDirty() { + check(!isRemoved) { "Field was removed" } + notifyEndpoints(this@AbstractField) + isDirty = true + } } /** @@ -528,8 +536,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } } - private var isDirty = false - private val access = object : FieldAccess { override fun read(): V { return field @@ -582,12 +588,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa this.field = value } - override fun markDirty() { - check(!isRemoved) { "Field was removed" } - notifyEndpoints(this@Field) - isDirty = true - } - override fun write(stream: DataOutputStream, endpoint: Endpoint) { check(!isRemoved) { "Field was removed" } codec.write(stream, field) @@ -609,19 +609,11 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } } - abstract inner class PrimitiveField() : AbstractField() { - protected var isDirty = false - + abstract inner class PrimitiveField : AbstractField() { override fun observe(): Boolean { check(!isRemoved) { "Field was removed" } return isDirty } - - override fun markDirty() { - check(!isRemoved) { "Field was removed" } - notifyEndpoints(this) - isDirty = true - } } /** @@ -1022,7 +1014,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa ) : AbstractField(), IField { private var remote: V? = null private var clientValue: V? = null - private var isDirty = false init { observers.add(this) @@ -1042,12 +1033,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return isDirty } - override fun markDirty() { - check(!isRemoved) { "Field was removed" } - notifyEndpoints(this) - isDirty = true - } - override val value: V get() = clientValue ?: getter.invoke() @@ -1075,7 +1060,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa private var isRemoteSet = false private var clientValue: Float = 0f private var isClientValue = false - private var isDirty = false override val property = object : IFloatProperty { override fun getValue(thisRef: Any?, property: KProperty<*>): Float { @@ -1133,7 +1117,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) override fun getValue(thisRef: Any?, property: KProperty<*>): Float { - return super.getValue(thisRef, property) + return float } } @@ -1147,7 +1131,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa private var isRemoteSet = false private var clientValue: Double = 0.0 private var isClientValue = false - private var isDirty = false override val property = object : IDoubleProperty { override fun getValue(thisRef: Any?, property: KProperty<*>): Double { @@ -1174,12 +1157,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return isDirty } - override fun markDirty() { - check(!isRemoved) { "Field was removed" } - notifyEndpoints(this) - isDirty = true - } - override val double: Double get() { if (isClientValue) { @@ -1205,7 +1182,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) override fun getValue(thisRef: Any?, property: KProperty<*>): Double { - return super.getValue(thisRef, property) + return double } } @@ -1219,7 +1196,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa private var isRemoteSet = false protected var clientValue: Int = 0 protected var isClientValue = false - protected var isDirty = false final override val property = object : IIntProperty { override fun getValue(thisRef: Any?, property: KProperty<*>): Int { @@ -1246,12 +1222,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return isDirty } - final override fun markDirty() { - check(!isRemoved) { "Field was removed" } - notifyEndpoints(this) - isDirty = true - } - final override val int: Int get() { if (isClientValue) { @@ -1263,7 +1233,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) override fun getValue(thisRef: Any?, property: KProperty<*>): Int { - return super.getValue(thisRef, property) + return int } } @@ -1319,7 +1289,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa private var isRemoteSet = false protected var clientValue: Long = 0L protected var isClientValue = false - protected var isDirty = false final override val property = object : ILongProperty { override fun getValue(thisRef: Any?, property: KProperty<*>): Long { @@ -1346,12 +1315,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return isDirty } - final override fun markDirty() { - check(!isRemoved) { "Field was removed" } - notifyEndpoints(this) - isDirty = true - } - final override val long: Long get() { if (isClientValue) { @@ -1363,7 +1326,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) override fun getValue(thisRef: Any?, property: KProperty<*>): Long { - return super.getValue(thisRef, property) + return long } } @@ -1419,7 +1382,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa private var isRemoteSet = false private var clientValue: Boolean = false private var isClientValue = false - private var isDirty = false override val property = object : IBooleanProperty { override fun getValue(thisRef: Any?, property: KProperty<*>): Boolean { @@ -1446,12 +1408,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return isDirty } - override fun markDirty() { - check(!isRemoved) { "Field was removed" } - notifyEndpoints(this) - isDirty = true - } - override val boolean: Boolean get() { if (isClientValue) { @@ -1477,7 +1433,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) override fun getValue(thisRef: Any?, property: KProperty<*>): Boolean { - return super.getValue(thisRef, property) + return boolean } } @@ -1508,8 +1464,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa remote = codec.copy(value) } - private var isDirty = false - init { observers.add(this) } @@ -1528,12 +1482,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return isDirty } - override fun markDirty() { - check(!isRemoved) { "Field was removed" } - notifyEndpoints(this) - isDirty = true - } - override fun write(stream: DataOutputStream, endpoint: Endpoint) { check(!isRemoved) { "Field was removed" } codec.write(stream, value) @@ -1552,7 +1500,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa private val callback: ((changes: Collection>) -> Unit)? = null, ) : AbstractField>() { private var isRemote = false - private var isDirty = false private fun pushBacklog(element: E, action: (DataOutputStream) -> Unit) { check(!isRemote) { "Field marked as remote" } @@ -1585,12 +1532,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa super.remove() } - override fun markDirty() { - check(!isRemoved) { "Field was removed" } - notifyEndpoints(this) - isDirty = true - } - override fun markDirty(endpoint: Endpoint) { super.markDirty(endpoint) @@ -1610,9 +1551,11 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa if (!isRemote) { markDirty() + val copy = codec.copy(element) + pushBacklog(element) { it.write(ChangesetAction.ADD.ordinal + 1) - codec.write(it, element) + codec.write(it, copy) } } @@ -1668,6 +1611,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa if (!isRemote) { markDirty() + @Suppress("unchecked_cast") pushBacklog(lastElement as E) { it.write(ChangesetAction.REMOVE.ordinal + 1) codec.write(it, lastElement as E) @@ -1683,9 +1627,11 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa if (!isRemote) { markDirty() + val copy = codec.copy(element) + pushBacklog(element) { it.write(ChangesetAction.REMOVE.ordinal + 1) - codec.write(it, element) + codec.write(it, copy) } } @@ -1790,19 +1736,11 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa private val keyCodec: IStreamCodec, private val valueCodec: IStreamCodec, private val backingMap: MutableMap, - private val observingBackingMap: MutableMap? = null, private val callback: ((changes: Collection>) -> Unit)? = null, ) : AbstractField>(), IField> { - private var isDirty = false private var sentAllValues = false private var isRemote = false - init { - if (observingBackingMap != null) { - observers.add(this) - } - } - private fun pushBacklog(key: Any?, value: (DataOutputStream) -> Unit) { val pair = key to value @@ -1820,62 +1758,15 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } } - private fun clearBacklog() { - forEachEndpoint { - it.getMapBacklog(this).clear() - } - } - override fun observe(): Boolean { - check(!isRemoved) { "Field was removed" } - - if (isRemote) { - return false - } - - val observingBackingMap = observingBackingMap - - if (observingBackingMap != null) { - for ((key, value) in backingMap) { - val remoteValue = observingBackingMap[key] ?: throw ConcurrentModificationException("Backing map of $this was modified externally, or $value missed a modification") - - if (!valueCodec.compare(value, remoteValue)) { - val valueCopy = valueCodec.copy(value) - - pushBacklog(key) { - it.write(ChangesetAction.ADD.ordinal + 1) - keyCodec.write(it, key) - valueCodec.write(it, valueCopy) - } - - observingBackingMap[key] = valueCopy - - if (!isDirty) { - notifyEndpoints(this) - isDirty = true - } - } - } - } - - return isDirty + return false } override fun markDirty() { check(!isRemoved) { "Field was removed" } - if (isRemote) { + if (isRemote || endpoints.isEmpty()) return - } - - if (endpoints.isEmpty()) { - val observingBackingMap = observingBackingMap ?: return - - for ((key, value) in backingMap) - observingBackingMap[key] = valueCodec.copy(value) - - return - } isDirty = true val backlogs = LinkedList Unit>>>() @@ -1900,17 +1791,14 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa for (backlog in backlogs) { backlog.add(key to action) } - - observingBackingMap?.put(key, valueCopy) } } override fun markDirty(endpoint: Endpoint) { check(!isRemoved) { "Field was removed" } - if (isRemote) { + if (isRemote) return - } val backlog = endpoint.getMapBacklog(this) @@ -1928,69 +1816,49 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } } + private fun lmarkDirty() { + if (!isDirty) { + notifyEndpoints(this@Map) + isDirty = true + } + } + override val value: MutableMap = object : ProxiedMap(backingMap) { override fun onClear() { - if (isRemote) { + if (isRemote || endpoints.isEmpty()) return - } - - if (endpoints.isEmpty()) { - return - } - - observingBackingMap?.clear() forEachEndpoint { endpoint -> - endpoint.getMapBacklog(this@Map).also { + endpoint.getMapBacklog(this@Map).let { it.clear() it.add(null to ClearBacklogEntry) } } - if (!isDirty) { - notifyEndpoints(this@Map) - isDirty = true - } - + lmarkDirty() hasChanges = true } override fun onValueAdded(key: K, value: V) { - if (isRemote) { + if (isRemote || endpoints.isEmpty()) return - } - - if (endpoints.isEmpty()) { - return - } + val keyCopy = keyCodec.copy(key) val valueCopy = valueCodec.copy(value) pushBacklog(key) { @Suppress("BlockingMethodInNonBlockingContext") // false positive it.write(ChangesetAction.ADD.ordinal + 1) - keyCodec.write(it, key) + keyCodec.write(it, keyCopy) valueCodec.write(it, valueCopy) } - observingBackingMap?.put(key, valueCopy) - - if (!isDirty) { - notifyEndpoints(this@Map) - isDirty = true - } - - hasChanges = true + lmarkDirty() } override fun onValueRemoved(key: K, value: V) { - if (isRemote) { + if (isRemote || endpoints.isEmpty()) return - } - - if (endpoints.isEmpty()) { - return - } val keyCopy = keyCodec.copy(key) @@ -2000,14 +1868,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa keyCodec.write(it, keyCopy) } - observingBackingMap?.remove(key) - - if (!isDirty) { - notifyEndpoints(this@Map) - isDirty = true - } - - hasChanges = true + lmarkDirty() } } @@ -2029,7 +1890,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa if (!isRemote) { isRemote = true forEachEndpoint { it.removeMapBacklog(this) } - observingBackingMap?.clear() } isDirty = false From cef4bdb033935a5af93fffd7b7e57ce47419e086 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 9 Jul 2023 15:50:44 +0700 Subject: [PATCH 0731/1199] Holy shit --- .../item/exopack/ExoPackSlotUpgradeItem.kt | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExoPackSlotUpgradeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExoPackSlotUpgradeItem.kt index d029c75fe..dbd9535b9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExoPackSlotUpgradeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExoPackSlotUpgradeItem.kt @@ -9,7 +9,6 @@ import java.util.UUID class ExoPackSlotUpgradeItem : AbstractExoPackSlotUpgradeItem { val hasDescription: Boolean val slotCount: Int - val isCreative: Boolean private val uuidProvider: () -> UUID? @@ -25,31 +24,15 @@ class ExoPackSlotUpgradeItem : AbstractExoPackSlotUpgradeItem { return slotCount } - constructor(slotCount: Int, properties: Properties = defaultProperties(), hasDescription: Boolean = false) : super(properties) { - isCreative = false - this.slotCount = slotCount - this.uuidProvider = lazy { registryName!!.toUUID() }::value - this.hasDescription = hasDescription - } - - constructor(uuid: UUID?, slotCount: Int, properties: Properties = defaultProperties(), hasDescription: Boolean = false) : super(properties) { - isCreative = uuid == null - this.slotCount = slotCount - this.uuidProvider = { UUID(0L, 0L) } - this.hasDescription = hasDescription - } - constructor(slotCount: Int, rarity: Rarity, hasDescription: Boolean = false) : super(defaultProperties(rarity)) { - isCreative = false this.slotCount = slotCount this.uuidProvider = lazy { registryName!!.toUUID() }::value this.hasDescription = hasDescription } constructor(uuid: UUID?, slotCount: Int, rarity: Rarity, hasDescription: Boolean = false) : super(defaultProperties(rarity)) { - isCreative = uuid == null this.slotCount = slotCount - this.uuidProvider = { UUID(0L, 0L) } + this.uuidProvider = { uuid } this.hasDescription = hasDescription } } From c12364a8552f886c04f94db54cc4dbc90de5c34a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 9 Jul 2023 15:51:33 +0700 Subject: [PATCH 0732/1199] Fix upgrades not checking correct property --- .../ru/dbotthepony/mc/otm/item/exopack/ExopackUpgradeItem.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExopackUpgradeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExopackUpgradeItem.kt index 2c393c725..f3ead9561 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExopackUpgradeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExopackUpgradeItem.kt @@ -55,7 +55,7 @@ class ExopackUpgradeItem( } override fun use(p_41432_: Level, player: Player, hand: InteractionHand): InteractionResultHolder { - if (player.matteryPlayer?.hasExoPack == true && !player.matteryPlayer!!.isExoPackCraftingUpgraded) { + if (player.matteryPlayer?.hasExoPack == true && !type.prop.get(player.matteryPlayer!!)) { player.startUsingItem(hand) return InteractionResultHolder.consume(player.getItemInHand(hand)) } From 7ec4a66923021dbbc784628feb9271ecfd1f242a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 9 Jul 2023 15:59:11 +0700 Subject: [PATCH 0733/1199] Wireless android charger crafting recipe --- .../mc/otm/datagen/recipes/CraftingTableRecipes.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index 0b68c0418..ca9ed68bc 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -295,6 +295,13 @@ fun addCraftingTableRecipes(consumer: Consumer) { .row(MItemTags.TRITANIUM_PLATES, MItems.ELECTRIC_PARTS, MItemTags.TRITANIUM_PLATES) .build(consumer) + // беспроводной зарядник андроидов + MatteryRecipe(MItems.ANDROID_CHARGER, category = machinesCategory) + .row(MItems.ELECTRIC_PARTS, MItems.QUANTUM_TRANSCEIVER, MItems.ELECTRIC_PARTS) + .row(MItemTags.TRITANIUM_PLATES, MItems.MACHINE_FRAME, MItemTags.TRITANIUM_PLATES) + .row(MItemTags.TRITANIUM_PLATES, MItems.MACHINE_FRAME, MItemTags.TRITANIUM_PLATES) + .build(consumer) + // Энерго меч MatteryRecipe(MItems.ENERGY_SWORD, category = RecipeCategory.COMBAT) .rowBC(MItemTags.TRITANIUM_PLATES, MItemTags.GOLD_WIRES) From 0b06ea4739cf71f8bb2d29e497df602a177106f8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 9 Jul 2023 15:59:42 +0700 Subject: [PATCH 0734/1199] Buff wireless android charger energy capacity --- src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt index 607a4e858..e04ef4afb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt @@ -42,7 +42,7 @@ object MachinesConfig : AbstractConfig("machines") { .defineInRange("RADIUS_HEIGHT", 4.0, 1.0, Double.MAX_VALUE) } - val ANDROID_CHARGER = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.ANDROID_CHARGER, capacity = Decimal(400_000), throughput = Decimal(8192)) { AndroidCharger } + val ANDROID_CHARGER = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.ANDROID_CHARGER, capacity = Decimal(1_000_000), throughput = Decimal(8192)) { AndroidCharger } object Upgrades { init { From 4e6b6d16812735fc1b02fd276ca1c701638a6638 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 9 Jul 2023 16:01:40 +0700 Subject: [PATCH 0735/1199] =?UTF-8?q?=D0=B8=20=D0=BF=D0=BE=D1=87=D0=B5?= =?UTF-8?q?=D0=BC=D1=83=20=D0=BA=D1=80=D0=B5=D1=81=D1=82=D0=B8=D0=BA=D0=B0?= =?UTF-8?q?=20=D0=BD=D0=B5=D1=82=20=D0=B2=20=D1=8D=D0=BA=D0=B7=D0=BE=D0=BF?= =?UTF-8?q?=D0=B0=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt index f3e494f47..f11babb5c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt @@ -55,6 +55,9 @@ class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen> { val frame = FramePanel(this, width = 200f, height = FRAME_BASE_HEIGHT + inventoryRows * AbstractSlotPanel.SIZE, title = this.title) + frame.makeCloseButton() + frame.onClose { onClose() } + frame.makeHelpButton().addSlotFiltersHelp().tooltips.add(TranslatableComponent("otm.gui.help.slot_charging")) val hotbarStrip = EditablePanel(this, frame, height = 18f) From 27e767033e0f8f76a98430209b37ca5c9074b08e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 9 Jul 2023 16:02:57 +0700 Subject: [PATCH 0736/1199] updated localization files --- src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 1d6dac6ea..faecb219c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -170,7 +170,7 @@ private fun misc(provider: MatteryLanguageProvider) { misc("exopack_upgrades.slots_upgraded", "Ваш экзопак был расширен на %s слотов") misc("exopack_upgrades.crafting_upgraded", "Ваш экзопак получил 3x3 сетку создания") - misc("exopack_upgrades.smelting_upgraded", "Ваш экзопак получил плавильню") + misc("exopack_upgrades.smelting_installed", "Ваш экзопак получил плавильню") misc("exopack.granted1", "После некоторого времени нажатия на сканер отпечатка, маяк исчезает.") misc("exopack.granted2", "Через мгновение, вашу спину пронзают множество раз...") From 0cab072037eb20b33c0f1aa0c1914215f0338ffe Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 9 Jul 2023 16:14:10 +0700 Subject: [PATCH 0737/1199] Make onClick public, so code can simulate button press --- .../mc/otm/client/screen/panels/button/AbstractButtonPanel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractButtonPanel.kt index 1fbefa244..41baa457c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractButtonPanel.kt @@ -34,7 +34,7 @@ abstract class AbstractButtonPanel( return value == InputConstants.MOUSE_BUTTON_LEFT } - protected abstract fun onClick(mouseButton: Int) + abstract fun onClick(mouseButton: Int) override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { if (isDisabled || isPressed || !test(button)) { From a71cab356449329a22a136816c1f414116af5cac Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 9 Jul 2023 16:14:36 +0700 Subject: [PATCH 0738/1199] Fix closing exopack inventory with furnace tab open won't reopen it (visually) on furnace tab --- .../mc/otm/client/screen/ExoPackInventoryScreen.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt index f11babb5c..802182da8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.client.screen +import com.mojang.blaze3d.platform.InputConstants import net.minecraft.client.gui.screens.inventory.InventoryScreen import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items @@ -190,6 +191,10 @@ class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen Date: Sun, 9 Jul 2023 16:39:37 +0700 Subject: [PATCH 0739/1199] Fix awarding android stats for using exopack energy --- .../mc/otm/capability/energy/BatteryBackedEnergyStorage.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BatteryBackedEnergyStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BatteryBackedEnergyStorage.kt index 9740cedf2..a04a14b70 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BatteryBackedEnergyStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BatteryBackedEnergyStorage.kt @@ -98,7 +98,7 @@ class BatteryBackedEnergyStorage( howMuch -= extracted if (howMuch.isZero) { - if (!simulate && ply is ServerPlayer) { + if (!simulate && ply is ServerPlayer && isAndroid) { ply.awardStat(StatNames.POWER_CONSUMED, drained.toInt() * 10) } @@ -113,7 +113,7 @@ class BatteryBackedEnergyStorage( if (!simulate) { battery = new - if (ply is ServerPlayer) { + if (ply is ServerPlayer && isAndroid) { ply.awardStat(StatNames.POWER_CONSUMED, drained.toInt() * 10) } } From 5800ddc9ad7144e9a8de79132cf982405e63d6d8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 9 Jul 2023 22:54:21 +0700 Subject: [PATCH 0740/1199] Reorganize advancements, add exopack and more machine advancements --- .../ru/dbotthepony/mc/otm/datagen/DataGen.kt | 1 - .../datagen/advancements/AdvancementData.kt | 8 +- .../advancements/AndroidAdvancementsData.kt | 14 +- .../advancements/ExopackAdvancementsData.kt | 249 ++++++++++++++++++ .../advancements/MachineAdvancementsData.kt | 184 ++++++++----- .../otm/capability/MatteryPlayerCapability.kt | 23 +- .../energy/BatteryBackedEnergyStorage.kt | 3 + .../kotlin/ru/dbotthepony/mc/otm/data/Ext.kt | 45 ++++ .../mc/otm/data/ItemPredicateCodec.kt | 27 ++ .../exopack/AbstractExoPackSlotUpgradeItem.kt | 2 + .../mc/otm/menu/ExoPackInventoryMenu.kt | 2 +- .../ru/dbotthepony/mc/otm/menu/Slots.kt | 6 +- .../otm/menu/matter/MatterReplicatorMenu.kt | 8 +- .../dbotthepony/mc/otm/registry/MRegistry.kt | 12 + .../mc/otm/triggers/AndroidBatteryTrigger.kt | 40 --- .../mc/otm/triggers/AndroidStatusTriggers.kt | 95 ------- .../mc/otm/triggers/BlackHoleTrigger.kt | 32 --- .../EnderTeleporterFallDeathTrigger.kt | 32 --- .../mc/otm/triggers/ExopackTriggers.kt | 55 ++++ .../otm/triggers/FallDampenersSaveTrigger.kt | 32 --- .../mc/otm/triggers/ItemTrigger.kt | 44 ++++ .../mc/otm/triggers/SimpleTriggers.kt | 17 ++ ...hockwaveTrigger.kt => SingletonTrigger.kt} | 15 +- 23 files changed, 623 insertions(+), 323 deletions(-) create mode 100644 src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/ExopackAdvancementsData.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/ItemPredicateCodec.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidBatteryTrigger.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidStatusTriggers.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/triggers/BlackHoleTrigger.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/triggers/EnderTeleporterFallDeathTrigger.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ExopackTriggers.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/triggers/FallDampenersSaveTrigger.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ItemTrigger.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/triggers/SimpleTriggers.kt rename src/main/kotlin/ru/dbotthepony/mc/otm/triggers/{ShockwaveTrigger.kt => SingletonTrigger.kt} (56%) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt index 81e3b1bdd..47ffc4fdc 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -508,7 +508,6 @@ object DataGen { AdvancementGenerator { registries, saver, existingFileHelper -> addAdvancements(saver, existingFileHelper, languageProvider) addAndroidAdvancements(saver, existingFileHelper, languageProvider) - addMachineAdvancements(saver, existingFileHelper, languageProvider) } )) {} diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt index 3898e9ce8..6625eaf74 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt @@ -38,6 +38,8 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .addCriterion("has_tritanium_ingot", InventoryChangeTrigger.TriggerInstance.hasItems(MItems.TRITANIUM_INGOT)) .save(serializer, modLocation("regular/root"), existingFileHelper) + addMachineAdvancements(serializer, existingFileHelper, lang, root) + val crude = AdvancementBuilder() .parent(root) .display( @@ -127,7 +129,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .addCriterion("has_item1", criterion(MItems.QUANTUM_CAPACITOR)) .save(serializer, modLocation("regular/quantum_battery"), existingFileHelper) - AdvancementBuilder() + val zpm = AdvancementBuilder() .parent(root) .display( itemStack = ItemStack(MItems.ZPM_BATTERY), @@ -144,6 +146,8 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .addCriterion("has_item", criterion(MItems.ZPM_BATTERY)) .save(serializer, modLocation("regular/zpm_battery"), existingFileHelper) + addExopackAdvancements(serializer, existingFileHelper, lang, root, zpm) + val blackhole = AdvancementBuilder() .parent(root) .display( @@ -156,7 +160,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist }, hidden = true ) - .addCriterion("pulled_by_black_hole", BlackHoleTrigger.Instance) + .addCriterion("pulled_by_black_hole", BlackHoleTrigger.instance) .save(serializer, modLocation("regular/black_hole"), existingFileHelper) AdvancementBuilder() diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt index c93400485..f84f15be1 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt @@ -48,7 +48,7 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper announceChat = false, background = modLocation("textures/block/decorative/metal_beam_top.png") ) - .addCriterion("became_android", BecomeAndroidTrigger.Instance) + .addCriterion("became_android", BecomeAndroidTrigger.instance) .save(serializer, modLocation("android/root"), existingFileHelper) AdvancementBuilder() @@ -97,7 +97,7 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper }, hidden = true, ) - .addCriterion("became_android", BecomeAndroidSleepTrigger.Instance) + .addCriterion("became_android", BecomeAndroidSleepTrigger.instance) .save(serializer, modLocation("android/become_thru_sleep"), existingFileHelper) AdvancementBuilder() @@ -112,7 +112,7 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper }, hidden = true, ) - .addCriterion("became_android", BecomeAndroidDeathTrigger.Instance) + .addCriterion("became_android", BecomeAndroidDeathTrigger.instance) .save(serializer, modLocation("android/become_thru_death"), existingFileHelper) AdvancementBuilder() @@ -128,7 +128,7 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper hidden = true, frameType = FrameType.GOAL ) - .addCriterion("become_humane", BecomeHumaneTrigger.Instance) + .addCriterion("become_humane", BecomeHumaneTrigger.instance) .save(serializer, modLocation("android/become_humane"), existingFileHelper) val attractor = AdvancementBuilder() @@ -246,7 +246,7 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper }, frameType = FrameType.GOAL ) - .addCriterion("saved", FallDampenersSaveTrigger.Instance) + .addCriterion("saved", FallDampenersSaveTrigger.instance) .save(serializer, modLocation("android/fall_dampeners_save"), existingFileHelper) AdvancementBuilder() @@ -262,7 +262,7 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper frameType = FrameType.GOAL, hidden = true ) - .addCriterion("death", EnderTeleporterFallDeathTrigger.Instance) + .addCriterion("death", EnderTeleporterFallDeathTrigger.instance) .save(serializer, modLocation("android/ender_teleport_fall_death"), existingFileHelper) val regen = AdvancementBuilder() @@ -330,7 +330,7 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper russian("Вызовите ударную волну при приземлении") }, ) - .addCriterion("shockwave", ShockwaveTrigger.Instance) + .addCriterion("shockwave", ShockwaveTrigger.instance) .save(serializer, modLocation("android/shockwave"), existingFileHelper) AdvancementBuilder() diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/ExopackAdvancementsData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/ExopackAdvancementsData.kt new file mode 100644 index 000000000..aec551e13 --- /dev/null +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/ExopackAdvancementsData.kt @@ -0,0 +1,249 @@ +package ru.dbotthepony.mc.otm.datagen.advancements + +import net.minecraft.advancements.Advancement +import net.minecraft.advancements.FrameType +import net.minecraft.advancements.critereon.ItemPredicate +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.Items +import net.minecraftforge.common.data.ExistingFileHelper +import ru.dbotthepony.mc.otm.datagen.lang.MatteryLanguageProvider +import ru.dbotthepony.mc.otm.datagen.modLocation +import ru.dbotthepony.mc.otm.registry.MItems +import ru.dbotthepony.mc.otm.triggers.ExopackBatterySlotTrigger +import ru.dbotthepony.mc.otm.triggers.ExopackGainedCraftingTrigger +import ru.dbotthepony.mc.otm.triggers.ExopackGainedSmeltingTrigger +import ru.dbotthepony.mc.otm.triggers.ExopackObtainedTrigger +import ru.dbotthepony.mc.otm.triggers.ExopackSlotsExpandedTrigger +import java.util.function.Consumer + +fun addExopackAdvancements(serializer: Consumer, existingFileHelper: ExistingFileHelper, lang: MatteryLanguageProvider, root: Advancement, zpm: Advancement) { + val translation = lang.MultiBuilder("otm.advancements.exopack") + + AdvancementBuilder() + .parent(zpm) + .display( + hidden = true, + itemStack = ItemStack(MItems.ZPM_BATTERY), + title = translation.add("zpm_battery", "At Maximum Battery Capacity") { + russian("Достигнут максимальный заряд батареи") + }, + description = translation.add("zpm_battery.desc", "Use Zero Point Module as power source in Exopack") { + russian("Используйте модуль нулевой точки как источник питания в Экзопаке") + }, + frameType = FrameType.GOAL + ) + .addCriterion("zpm_battery", ExopackBatterySlotTrigger.Instance(ItemPredicate.Builder.item().of(MItems.ZPM_BATTERY).build())) + .save(serializer, modLocation("exopack/zpm_battery"), existingFileHelper) + + val obtained = AdvancementBuilder() + .parent(root) + .display( + itemStack = ItemStack(MItems.EXOPACK_PROBE), + title = translation.add("obtained", "One Dimension Bigger") { + russian("Больше на одно измерение") + }, + description = translation.add("obtained.desc", "Obtain an Exopack, a mysterious, semi-present, light as a feather, stuff storage on your back") { + russian("Получите Экзопак, загадочное, полу-присутствующее, лёгкое как пёрышко, хранилище штуковин на вашей спине") + }, + frameType = FrameType.GOAL + ) + .addCriterion("obtained", ExopackObtainedTrigger.instance) + .save(serializer, modLocation("exopack/obtained"), existingFileHelper) + + AdvancementBuilder() + .parent(obtained) + .display( + itemStack = ItemStack(Items.CRAFTING_TABLE), + title = translation.add("crafting", "Crafting on Go") { + russian("Крафт по пути") + }, + description = translation.add("crafting.desc", "Install Crafting Upgrade in your Exopack, allowing to craft 3x3 recipes") { + russian("Установите улучшение сетки крафта в ваш Экзопаке, который позволяет создавать предметы, требующие сетку крафта рабочего стола") + }, + ) + .addCriterion("crafting", ExopackGainedCraftingTrigger.instance) + .save(serializer, modLocation("exopack/crafting"), existingFileHelper) + + AdvancementBuilder() + .parent(obtained) + .display( + itemStack = ItemStack(Items.FURNACE), + title = translation.add("smelting", "Pocket Furnace") { + russian("Печь в кармане") + }, + description = translation.add("smelting.desc", "Install Smelting Module in your Exopack, allowing to smelt items right inside your inventory") { + russian("Установите модуль переплавки в ваш Экзопак, позволяющий переплавлять предметы прямо у вас в инвентаре") + }, + ) + .addCriterion("smelting", ExopackGainedSmeltingTrigger.instance) + .save(serializer, modLocation("exopack/smelting"), existingFileHelper) + + var size = AdvancementBuilder() + .parent(obtained) + .display( + itemStack = ItemStack(Items.CHEST), + title = translation.add("size0", "Closet Upgrade") { + russian("Обновление чуланчика") + }, + description = translation.add("size0.desc", "Upgrade Exopack storage") { + russian("Улучшите размер инвентаря Экзопака") + }, + ) + .addCriterion("size0", ExopackSlotsExpandedTrigger.Instance(minTotal = 1)) + .save(serializer, modLocation("exopack/size0"), existingFileHelper) + + val size0 = size + + size = AdvancementBuilder() + .parent(size) + .display( + itemStack = ItemStack(Items.CHEST), + title = translation.add("size1", "Double the Capacity") { + russian("Двойной объём") + }, + description = translation.add("size1.desc", "Reach 27 slots in your Exopack storage") { + russian("Достигните 27 слотов хранилища Экзопака") + }, + ) + .addCriterion("size1", ExopackSlotsExpandedTrigger.Instance(minTotal = 27)) + .save(serializer, modLocation("exopack/size1"), existingFileHelper) + + size = AdvancementBuilder() + .parent(size) + .display( + itemStack = ItemStack(Items.CHEST), + hidden = true, + title = translation.add("size2", "Pack Rat") { + russian("Воришка") + }, + description = translation.add("size2.desc", "Reach 54 slots in your Exopack storage") { + russian("Достигните 54 слотов хранилища Экзопака") + }, + ) + .addCriterion("size2", ExopackSlotsExpandedTrigger.Instance(minTotal = 54)) + .save(serializer, modLocation("exopack/size2"), existingFileHelper) + + size = AdvancementBuilder() + .parent(size) + .display( + itemStack = ItemStack(Items.CHEST), + hidden = true, + title = translation.add("size3", "Its Getting Big In Here") { + russian("Тут становится просторно") + }, + description = translation.add("size3.desc", "Reach 108 slots in your Exopack storage") { + russian("Достигните 108 слотов хранилища Экзопака") + }, + frameType = FrameType.GOAL + ) + .addCriterion("size3", ExopackSlotsExpandedTrigger.Instance(minTotal = 108)) + .save(serializer, modLocation("exopack/size3"), existingFileHelper) + + size = AdvancementBuilder() + .parent(size) + .display( + itemStack = ItemStack(Items.ENDER_CHEST), + hidden = true, + title = translation.add("size4", "Warehousing Pioneer") { + russian("Пионер складских решений") + }, + description = translation.add("size4.desc", "Reach 432 slots in your Exopack storage. You could fit a house in there") { + russian("Достигните 432 слотов хранилища Экзопака. Туда можно уже впихнуть целый дом") + }, + frameType = FrameType.CHALLENGE + ) + .addCriterion("size4", ExopackSlotsExpandedTrigger.Instance(minTotal = 432)) + .save(serializer, modLocation("exopack/size4"), existingFileHelper) + + AdvancementBuilder() + .parent(size) + .display( + itemStack = ItemStack(Items.ENDER_CHEST), + hidden = true, + title = translation.add("size5", "With Volume Like This...") { + russian("С таким объёмом...") + }, + description = translation.add("size5.desc", "Reach 1728 slots in your Exopack storage. Why would you need to go any bigger?!") { + russian("Достигните 1728 слотов хранилища Экзопака. Куда вам столько?!") + }, + frameType = FrameType.CHALLENGE + ) + .addCriterion("size5", ExopackSlotsExpandedTrigger.Instance(minTotal = 1728)) + .save(serializer, modLocation("exopack/size5"), existingFileHelper) + + var once = AdvancementBuilder() + .parent(size0) + .display( + itemStack = ItemStack(Items.CHEST), + title = translation.add("once0", "One Module - One Row") { + russian("Один модуль - одна строка") + }, + description = translation.add("once0.desc", "Upgrade your Exopack storage with 9 slots using one module") { + russian("Улучшите хранилище Экзопака модулем на 9 слотов") + }, + ) + .addCriterion("once0", ExopackSlotsExpandedTrigger.Instance(minGained = 9)) + .save(serializer, modLocation("exopack/once0"), existingFileHelper) + + once = AdvancementBuilder() + .parent(once) + .display( + itemStack = ItemStack(Items.CHEST), + title = translation.add("once1", "One Module - One Chest") { + russian("Один модуль - один сундук") + }, + description = translation.add("once1.desc", "Upgrade your Exopack storage with 27 slots using one module") { + russian("Улучшите хранилище Экзопака модулем на 27 слотов") + }, + ) + .addCriterion("once1", ExopackSlotsExpandedTrigger.Instance(minGained = 27)) + .save(serializer, modLocation("exopack/once1"), existingFileHelper) + + once = AdvancementBuilder() + .parent(once) + .display( + itemStack = ItemStack(Items.CHEST), + hidden = true, + title = translation.add("once2", "One Module - Two Chests?") { + russian("Один модуль - два сундука?") + }, + description = translation.add("once2.desc", "Upgrade your Exopack storage with 54 slots using one module") { + russian("Улучшите хранилище Экзопака модулем на 54 слотов") + }, + frameType = FrameType.GOAL + ) + .addCriterion("once2", ExopackSlotsExpandedTrigger.Instance(minGained = 54)) + .save(serializer, modLocation("exopack/once2"), existingFileHelper) + + once = AdvancementBuilder() + .parent(once) + .display( + itemStack = ItemStack(Items.ENDER_CHEST), + hidden = true, + title = translation.add("once3", "Storage Housing Construct") { + russian("Хранилище быстрого приготовления") + }, + description = translation.add("once3.desc", "Upgrade your Exopack storage with 90 slots using one module") { + russian("Улучшите хранилище Экзопака модулем на 90 слотов") + }, + frameType = FrameType.GOAL + ) + .addCriterion("once3", ExopackSlotsExpandedTrigger.Instance(minGained = 90)) + .save(serializer, modLocation("exopack/once3"), existingFileHelper) + + AdvancementBuilder() + .parent(once) + .display( + itemStack = ItemStack(Items.ENDER_CHEST), + hidden = true, + title = translation.add("once4", "Non-Euclidean Wardrobe") { + russian("Неевклидов Шкаф") + }, + description = translation.add("once4.desc", "Upgrade your Exopack storage with 150 slots using one module. After you open one, tens meters long racks roll out of it!") { + russian("Улучшите хранилище Экзопака модулем на 150 слотов. Открой один - и покатились стеллажи на десятки метров!") + }, + frameType = FrameType.CHALLENGE + ) + .addCriterion("once4", ExopackSlotsExpandedTrigger.Instance(minGained = 150)) + .save(serializer, modLocation("exopack/once4"), existingFileHelper) +} diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt index b50ef7bb0..349354dbc 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt @@ -1,10 +1,13 @@ package ru.dbotthepony.mc.otm.datagen.advancements import net.minecraft.advancements.Advancement +import net.minecraft.advancements.FrameType import net.minecraft.advancements.RequirementsStrategy +import net.minecraft.advancements.critereon.ItemPredicate import net.minecraft.network.chat.contents.TranslatableContents import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.Items import net.minecraftforge.common.data.ExistingFileHelper import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.key @@ -13,6 +16,7 @@ import ru.dbotthepony.mc.otm.datagen.lang.MatteryLanguageProvider import ru.dbotthepony.mc.otm.datagen.modLocation import ru.dbotthepony.mc.otm.registry.MItemTags import ru.dbotthepony.mc.otm.registry.MItems +import ru.dbotthepony.mc.otm.triggers.TakeItemOutOfReplicatorTrigger import java.util.function.Consumer private data class CraftEntry( @@ -22,30 +26,37 @@ private data class CraftEntry( val russianName: String? = null, val russianSuffix: String? = null, -) +) { + fun make(serializer: Consumer, existingFileHelper: ExistingFileHelper, parent: Advancement, translation: MatteryLanguageProvider.MultiBuilder): Advancement { + val path = item.registryName!!.path -fun addMachineAdvancements(serializer: Consumer, existingFileHelper: ExistingFileHelper, lang: MatteryLanguageProvider) { + val translated = translation.add("$path.desc", "Craft a %s%s") { + russian("Создайте %s%s") + } + + val translatedSuffix = translation.add("$path.suffix", if (englishSuffix != null) ". $englishSuffix" else "") { + russian(if (russianSuffix != null) ". $russianSuffix" else "") + } + + return AdvancementBuilder() + .parent(parent) + .display( + itemStack = ItemStack(item), + title = translation.add(path, englishName) { + if (russianName != null) { + russian(russianName) + } + }, + description = TranslatableComponent(translated.contents.key, item.description, translatedSuffix), + ) + .addCriterion("has_machine", criterion(item)) + .save(serializer, modLocation("machines/$path"), existingFileHelper) + } +} + +fun addMachineAdvancements(serializer: Consumer, existingFileHelper: ExistingFileHelper, lang: MatteryLanguageProvider, root: Advancement) { val translation = lang.MultiBuilder("otm.advancements.machine") - val root = AdvancementBuilder() - .requirements(RequirementsStrategy.OR) - .display( - itemStack = ItemStack(MItems.CHEMICAL_GENERATOR), - title = translation.add("root", "Tritanium Empowered Machinery") { - russian("Тританово запитанные механизмы") - }, - description = translation.add("root.desc", "Do not drop in anything if you want the latter preserved intact") { - russian("Не роняйте ничего внутрь если хотите чтоб последнее осталось таким, какое оно есть") - }, - showToast = false, - announceChat = false, - background = modLocation("textures/block/decorative/floor_tiles_gray.png") - ) - .addCriterion("has_machine", criterion(MItemTags.MACHINES)) - .addCriterion("has_tritanium_ingot", criterion(MItemTags.TRITANIUM_INGOTS)) - .addCriterion("has_tritanium_plate_somehow", criterion(MItemTags.TRITANIUM_PLATES)) - .save(serializer, modLocation("machines/root"), existingFileHelper) - val chem = AdvancementBuilder() .parent(root) .display( @@ -74,55 +85,98 @@ fun addMachineAdvancements(serializer: Consumer, existingFileHelper .addCriterion("has_machine", criterion(MItems.PLATE_PRESS)) .save(serializer, modLocation("machines/plate_press"), existingFileHelper) - val entries = listOf( - CraftEntry(MItems.MATTER_SCANNER, "Scanning Things that Matter", - russianName = "Сканируем вещи которые материальны"), - CraftEntry(MItems.PATTERN_STORAGE, "Digital Knowledge Library", - russianName = "Цифровая библиотека знаний"), - CraftEntry(MItems.MATTER_DECOMPOSER, "Decaying the Atoms", "Keep your limbs outside of the working chamber at all times", - russianName = "Разлагаем атомы", russianSuffix = "Во всех ситуациях держите свои конечности вне рабочей камеры"), - CraftEntry(MItems.MATTER_PANEL, "Indexing the Library", - russianName = "Индексируем библиотеку"), - CraftEntry(MItems.MATTER_REPLICATOR, "Local Bakery", "Now let's bake some perfect bread", - russianName = "Местная выпечка", russianSuffix = "А теперь давайте выпечем немного идеального хлеба"), - CraftEntry(MItems.MATTER_BOTTLER, "Transfusing Pure Matter", "For those who loved to play with water in their childhood", - russianName = "Переливаем чистую материю", russianSuffix = "Для тех, кто любил играться в воде в детстве"), - CraftEntry(MItems.MATTER_RECYCLER, "Refine and Redefine", "This is what waste recycling should look like", - russianName = "Переработка и перегонка", russianSuffix = "Вот он, пик переработки отходов"), - CraftEntry(MItems.MATTER_CAPACITOR_BANK, "Modular Matter Tank", - russianName = "Модульный бак материи"), + CraftEntry(MItems.TWIN_PLATE_PRESS, "Twice the Thud", + russianName = "Двойной стук").make(serializer, existingFileHelper, press, translation) - CraftEntry(MItems.ENERGY_COUNTER, "Visualize Power Burn", - russianName = "Визуализация сжигания энергии"), - CraftEntry(MItems.BATTERY_BANK, "Batteries Not Included", "By all means avoid the urge to hammer incompatible batteries into the power bus.", - russianName = "Батарейки в комплект не входят", russianSuffix = "Пожалуйста, воздержитесь от вбивания кувалдой несовместимых батарей в энергетическую шину."), - ) + val scanner = CraftEntry(MItems.MATTER_SCANNER, "Scanning Things that Matter", + russianName = "Сканируем вещи которые материальны") + val decomposer = CraftEntry(MItems.MATTER_DECOMPOSER, "Decaying the Atoms", "Keep your limbs outside of the working chamber at all times", + russianName = "Разлагаем атомы", russianSuffix = "Во всех ситуациях держите свои конечности вне рабочей камеры") + val panel = CraftEntry(MItems.MATTER_PANEL, "Indexing the Library", + russianName = "Индексируем библиотеку") + val replicator = CraftEntry(MItems.MATTER_REPLICATOR, "Cook with (Im)Perfection", "Now let's bake some perfect bread", + russianName = "Повар с (не) идеальностями", russianSuffix = "А теперь давайте выпечем немного идеального хлеба") + val bottler = CraftEntry(MItems.MATTER_BOTTLER, "Transfusing Pure Matter", "For those who loved to play with water in their childhood", + russianName = "Переливаем чистую материю", russianSuffix = "Для тех, кто любил играться в воде в детстве") + val recycler = CraftEntry(MItems.MATTER_RECYCLER, "Refine and Redefine", "This is what waste recycling should look like", + russianName = "Переработка и перегонка", russianSuffix = "Вот он, пик переработки отходов") + val capacitor = CraftEntry(MItems.MATTER_CAPACITOR_BANK, "Modular Matter Tank", + russianName = "Модульный бак материи") - val built = mutableMapOf() + val counter = CraftEntry(MItems.ENERGY_COUNTER, "Visualize Power Burn", + russianName = "Визуализация сжигания энергии") + val battery = CraftEntry(MItems.BATTERY_BANK, "Batteries Not Included", "By all means avoid the urge to hammer incompatible batteries into the power bus.", + russianName = "Батарейки в комплект не входят", russianSuffix = "Пожалуйста, воздержитесь от вбивания кувалдой несовместимых батарей в энергетическую шину.") - for (entry in entries) { - val path = entry.item.registryName!!.path + val pattern = CraftEntry(MItems.PATTERN_STORAGE, "Digital Knowledge Library", + russianName = "Цифровая библиотека знаний") - val translated = translation.add("$path.desc", "Craft a %s%s") { - russian("Создайте %s%s") + val reconstructor = CraftEntry(MItems.MATTER_RECONSTRUCTOR, "Flipping Hourglass", + russianName = "Переворачиваем песочные часы") + + decomposer.make(serializer, existingFileHelper, press, translation).also { + pattern.make(serializer, existingFileHelper, it, translation).also { + scanner.make(serializer, existingFileHelper, it, translation) + panel.make(serializer, existingFileHelper, it, translation) + + replicator.make(serializer, existingFileHelper, it, translation).also { + AdvancementBuilder() + .parent(it) + .display( + itemStack = ItemStack(Items.BREAD), + title = translation.add("replicate_something", "Local Bakery") { + russian("Местная выпечка") + }, + description = translation.add("replicate_something.desc", "Replicate something using Matter Replicator. If you replicated some food, be the first to taste it among your company") { + russian("Среплицируйте что либо используя репликатор материи. Если это еда, то не стесняйтесь быть первым, кто попробует её на вкус среди вашей компании") + }, + frameType = FrameType.GOAL + ) + .addCriterion("replicate_something", TakeItemOutOfReplicatorTrigger.Instance(ItemPredicate.Builder.item().of(MItems.MATTER_DUST).build(), true)) + .save(serializer, modLocation("machines/replicate_something"), existingFileHelper) + + AdvancementBuilder() + .parent(it) + .display( + hidden = true, + itemStack = ItemStack(MItems.MATTER_DUST), + title = translation.add("replicate_failure", "Unhealthy Flavor") { + russian("Вредная посыпка") + }, + description = translation.add("replicate_failure.desc", "Experience replication failure and have your thing turn into matter dust") { + russian("Наблюдайте неудачный результат репликации, где ваш заказ рассыпался в материальную труху") + }, + ) + .addCriterion("replicate_failure", TakeItemOutOfReplicatorTrigger.Instance(ItemPredicate.Builder.item().of(MItems.MATTER_DUST).build())) + .save(serializer, modLocation("machines/replicate_failure"), existingFileHelper) + } + + reconstructor.make(serializer, existingFileHelper, it, translation) } - val translatedSuffix = translation.add("$path.suffix", if (entry.englishSuffix != null) ". " + entry.englishSuffix else "") { - russian(if (entry.russianSuffix != null) ". " + entry.russianSuffix else "") - } - - built[entry.item] = AdvancementBuilder() - .parent(press) - .display( - itemStack = ItemStack(entry.item), - title = translation.add(path, entry.englishName) { - if (entry.russianName != null) { - russian(entry.russianName) - } - }, - description = TranslatableComponent(translated.contents.key, entry.item.description, translatedSuffix), - ) - .addCriterion("has_machine", criterion(entry.item)) - .save(serializer, modLocation("machines/$path"), existingFileHelper) + bottler.make(serializer, existingFileHelper, it, translation) + recycler.make(serializer, existingFileHelper, it, translation) + capacitor.make(serializer, existingFileHelper, it, translation) } + + counter.make(serializer, existingFileHelper, press, translation).also { + battery.make(serializer, existingFileHelper, it, translation) + } + + val station = CraftEntry(MItems.ANDROID_STATION, "Android Home Page", + russianName = "Домашняя страница андроидов", + russianSuffix = "Только пользоваться этим устройством могут вёдра с болтами", + englishSuffix = "Except only buckets of bolts can use this thing") + + val charger = CraftEntry(MItems.ANDROID_CHARGER, "Android Home Router", + russianName = "Домашняя страница андроидов") + + station.make(serializer, existingFileHelper, press, translation).also { + charger.make(serializer, existingFileHelper, it, translation) + } + + CraftEntry(MItems.COBBLESTONE_GENERATOR, "Cobblestone: Infinity + 1", + russianName = "Булыжник: бесконечность + 1", + russianSuffix = "Смотрите, чтоб он не просыпался во все сундуки", + englishSuffix = "Watch for not to spill it over all your chests").make(serializer, existingFileHelper, press, translation) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 3a03ed84f..8db96a554 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -109,6 +109,10 @@ import ru.dbotthepony.mc.otm.triggers.BecomeAndroidDeathTrigger import ru.dbotthepony.mc.otm.triggers.BecomeAndroidSleepTrigger import ru.dbotthepony.mc.otm.triggers.BecomeAndroidTrigger import ru.dbotthepony.mc.otm.triggers.BecomeHumaneTrigger +import ru.dbotthepony.mc.otm.triggers.ExopackGainedCraftingTrigger +import ru.dbotthepony.mc.otm.triggers.ExopackGainedSmeltingTrigger +import ru.dbotthepony.mc.otm.triggers.ExopackObtainedTrigger +import ru.dbotthepony.mc.otm.triggers.ExopackSlotsExpandedTrigger import java.util.* import java.util.stream.Stream import kotlin.collections.ArrayDeque @@ -194,7 +198,13 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial /** * Whenever player has Exopack */ - var hasExoPack by publicSynchronizer.bool().property + var hasExoPack by publicSynchronizer.bool(setter = setter@{ value, access, _ -> + access.write(value) + + if (value && ply is ServerPlayer) { + ExopackObtainedTrigger.trigger(ply) + } + }).property /** * Whenever to render Exopack on player @@ -285,6 +295,10 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial if (value != access.readBoolean()) { access.write(value) _exoPackMenu = null + + if (value && ply is ServerPlayer) { + ExopackGainedCraftingTrigger.trigger(ply) + } } }).property @@ -383,6 +397,10 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial if (value != access.readBoolean()) { access.write(value) _exoPackMenu = null + + if (value && ply is ServerPlayer) { + ExopackGainedSmeltingTrigger.trigger(ply) + } } }).property @@ -855,6 +873,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial override fun deserializeNBT(tag: CompoundTag) { savetables.deserializeNBT(tag) + if (ply is ServerPlayer && hasExoPack) + ExopackSlotsExpandedTrigger.trigger(ply, 0, exoPackContainer.containerSize) + for (filter in regularSlotFilters) { filter.value = null } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BatteryBackedEnergyStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BatteryBackedEnergyStorage.kt index a04a14b70..cec3e8396 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BatteryBackedEnergyStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BatteryBackedEnergyStorage.kt @@ -18,6 +18,7 @@ import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer import ru.dbotthepony.mc.otm.registry.StatNames import ru.dbotthepony.mc.otm.triggers.AndroidBatteryTrigger +import ru.dbotthepony.mc.otm.triggers.ExopackBatterySlotTrigger class BatteryBackedEnergyStorage( private val ply: Player, @@ -37,6 +38,8 @@ class BatteryBackedEnergyStorage( if (ply is ServerPlayer && isAndroid) { AndroidBatteryTrigger.trigger(ply, value) + } else if (ply is ServerPlayer && !isAndroid) { + ExopackBatterySlotTrigger.trigger(ply, value) } }) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Ext.kt index 6cf8c6434..fcc744d47 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Ext.kt @@ -1,11 +1,56 @@ package ru.dbotthepony.mc.otm.data +import com.google.gson.JsonArray +import com.google.gson.JsonNull +import com.google.gson.JsonObject import com.mojang.serialization.DataResult +import it.unimi.dsi.fastutil.ints.IntAVLTreeSet import net.minecraft.world.entity.player.Player import net.minecraft.world.level.storage.loot.LootContext import net.minecraft.world.level.storage.loot.parameters.LootContextParam import net.minecraft.world.level.storage.loot.parameters.LootContextParams +fun JsonArray.getRidOfNulls(): JsonArray { + val toRemove = IntAVLTreeSet() + + for (i in 0 until size()) { + when (val value = this[i]) { + JsonNull.INSTANCE -> toRemove.add(i) + is JsonArray -> value.getRidOfNulls() + is JsonObject -> value.getRidOfNulls() + } + } + + if (toRemove.isNotEmpty()) { + remove(toRemove.lastInt()) + val iterator = toRemove.iterator(toRemove.lastInt()) + + while (iterator.hasPrevious()) { + remove(iterator.previousInt()) + } + } + + return this +} + +fun JsonObject.getRidOfNulls(): JsonObject { + val toRemove = ArrayList() + + for ((key, value) in entrySet()) { + when (value) { + JsonNull.INSTANCE -> toRemove.add(key) + is JsonArray -> value.getRidOfNulls() + is JsonObject -> value.getRidOfNulls() + } + } + + for (key in toRemove) { + remove(key) + } + + return this +} + operator fun LootContext.get(param: LootContextParam): T? { return getParamOrNull(param) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/ItemPredicateCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/ItemPredicateCodec.kt new file mode 100644 index 000000000..b37fb23a9 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/ItemPredicateCodec.kt @@ -0,0 +1,27 @@ +package ru.dbotthepony.mc.otm.data + +import com.google.gson.JsonObject +import com.google.gson.JsonParseException +import com.google.gson.JsonSyntaxException +import com.mojang.datafixers.util.Pair +import com.mojang.serialization.Codec +import com.mojang.serialization.DataResult +import com.mojang.serialization.DynamicOps +import com.mojang.serialization.JsonOps +import net.minecraft.advancements.critereon.ItemPredicate + +object ItemPredicateCodec : Codec { + override fun encode(input: ItemPredicate, ops: DynamicOps, prefix: T): DataResult { + return DataResult.success(JsonOps.INSTANCE.convertTo(ops, input.serializeToJson().let { if (it is JsonObject) it.getRidOfNulls() else it })) + } + + override fun decode(ops: DynamicOps, input: T): DataResult> { + return try { + DataResult.success(Pair(ItemPredicate.fromJson(ops.convertTo(JsonOps.INSTANCE, input)), ops.empty())) + } catch (err: JsonSyntaxException) { + DataResult.error { "Failed to deserialize ItemPredicate: ${err.message}" } + } catch (err: JsonParseException) { + DataResult.error { "Failed to deserialize ItemPredicate: ${err.message}" } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/AbstractExoPackSlotUpgradeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/AbstractExoPackSlotUpgradeItem.kt index d2dbcb804..591ae73ac 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/AbstractExoPackSlotUpgradeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/AbstractExoPackSlotUpgradeItem.kt @@ -21,6 +21,7 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.isExplosion import ru.dbotthepony.mc.otm.core.isFire import ru.dbotthepony.mc.otm.runIfClient +import ru.dbotthepony.mc.otm.triggers.ExopackSlotsExpandedTrigger import java.util.UUID abstract class AbstractExoPackSlotUpgradeItem(properties: Properties = defaultProperties()) : Item(properties) { @@ -105,6 +106,7 @@ abstract class AbstractExoPackSlotUpgradeItem(properties: Properties = defaultPr matteryPlayer.exoPackSlotModifier[UUID.randomUUID()] = slotCount } + ExopackSlotsExpandedTrigger.trigger(player, slotCount, matteryPlayer.exoPackContainer.containerSize) player.displayClientMessage(TranslatableComponent("otm.exopack_upgrades.slots_upgraded", slotCount).withStyle(ChatFormatting.DARK_GREEN), false) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt index 59ef84a53..ccf112f43 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt @@ -124,7 +124,7 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen } val furnaceOutputs: List = capability.smelters.map { - object : MachineOutputSlot(it.output, 0, onTake = ::popFurnaceExp) { + object : MachineOutputSlot(it.output, 0, onTake = { popFurnaceExp() }) { override fun mayPickup(player: Player): Boolean { return super.mayPickup(player) && capability.isExoPackSmeltingInstalled } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt index ae8d1dc44..74bda90bd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt @@ -64,19 +64,19 @@ open class UserFilteredSlot(container: Container, index: Int, x: Int = 0, y: Int } } -open class MachineOutputSlot(container: Container, index: Int, x: Int = 0, y: Int = 0, val onTake: () -> Unit = {}) : MatterySlot(container, index, x, y) { +open class MachineOutputSlot(container: Container, index: Int, x: Int = 0, y: Int = 0, val onTake: (ItemStack) -> Unit = {}) : MatterySlot(container, index, x, y) { override fun mayPlace(itemStack: ItemStack): Boolean { return false } override fun onTake(pPlayer: Player, pStack: ItemStack) { super.onTake(pPlayer, pStack) - this.onTake.invoke() + this.onTake.invoke(pStack) } override fun onQuickCraft(pStack: ItemStack, pAmount: Int) { super.onQuickCraft(pStack, pAmount) - this.onTake.invoke() + this.onTake.invoke(pStack) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt index 949333bbb..684dac899 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.menu.matter +import net.minecraft.server.level.ServerPlayer import kotlin.jvm.JvmOverloads import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity @@ -7,12 +8,15 @@ import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import net.minecraft.world.SimpleContainer import ru.dbotthepony.mc.otm.core.immutableList +import ru.dbotthepony.mc.otm.core.isNotEmpty +import ru.dbotthepony.mc.otm.item.matter.MatterDustItem import ru.dbotthepony.mc.otm.menu.MachineOutputSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus +import ru.dbotthepony.mc.otm.triggers.TakeItemOutOfReplicatorTrigger class MatterReplicatorMenu @JvmOverloads constructor( p_38852_: Int, @@ -30,7 +34,9 @@ class MatterReplicatorMenu @JvmOverloads constructor( val container = tile?.container ?: SimpleContainer(5) storageSlots = immutableList(5) { - addStorageSlot(MachineOutputSlot(container, it)) + addStorageSlot(MachineOutputSlot(container, it, onTake = { + if (inventory.player is ServerPlayer && it.isNotEmpty) + TakeItemOutOfReplicatorTrigger.trigger(inventory.player as ServerPlayer, it) })) } addInventorySlots() 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 9dfb64918..c8ced79fb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -44,11 +44,17 @@ import ru.dbotthepony.mc.otm.triggers.BecomeAndroidTrigger import ru.dbotthepony.mc.otm.triggers.BecomeHumaneTrigger import ru.dbotthepony.mc.otm.triggers.BlackHoleTrigger import ru.dbotthepony.mc.otm.triggers.EnderTeleporterFallDeathTrigger +import ru.dbotthepony.mc.otm.triggers.ExopackBatterySlotTrigger +import ru.dbotthepony.mc.otm.triggers.ExopackGainedCraftingTrigger +import ru.dbotthepony.mc.otm.triggers.ExopackGainedSmeltingTrigger +import ru.dbotthepony.mc.otm.triggers.ExopackObtainedTrigger +import ru.dbotthepony.mc.otm.triggers.ExopackSlotsExpandedTrigger import ru.dbotthepony.mc.otm.triggers.FallDampenersSaveTrigger import ru.dbotthepony.mc.otm.triggers.NailedEntityTrigger import ru.dbotthepony.mc.otm.triggers.NanobotsArmorTrigger import ru.dbotthepony.mc.otm.triggers.ShockwaveDamageMobTrigger import ru.dbotthepony.mc.otm.triggers.ShockwaveTrigger +import ru.dbotthepony.mc.otm.triggers.TakeItemOutOfReplicatorTrigger object MRegistry { private val features = RegistryDelegate>("android_features") @@ -254,6 +260,12 @@ object MRegistry { CriteriaTriggers.register(KillAsAndroidTrigger) CriteriaTriggers.register(AndroidTravelUnderwater) CriteriaTriggers.register(NailedEntityTrigger) + CriteriaTriggers.register(ExopackObtainedTrigger) + CriteriaTriggers.register(ExopackGainedSmeltingTrigger) + CriteriaTriggers.register(ExopackGainedCraftingTrigger) + CriteriaTriggers.register(ExopackSlotsExpandedTrigger) + CriteriaTriggers.register(ExopackBatterySlotTrigger) + CriteriaTriggers.register(TakeItemOutOfReplicatorTrigger) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidBatteryTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidBatteryTrigger.kt deleted file mode 100644 index 4a7a4a26c..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidBatteryTrigger.kt +++ /dev/null @@ -1,40 +0,0 @@ -package ru.dbotthepony.mc.otm.triggers - -import com.google.gson.JsonObject -import net.minecraft.advancements.critereon.* -import net.minecraft.resources.ResourceLocation -import net.minecraft.server.level.ServerPlayer -import net.minecraft.world.item.ItemStack -import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.core.set - -object AndroidBatteryTrigger : SimpleCriterionTrigger() { - val ID = ResourceLocation(OverdriveThatMatters.MOD_ID, "android_battery") - - override fun getId(): ResourceLocation { - return ID - } - - override fun createInstance( - p_66248_: JsonObject, - p_286603_: ContextAwarePredicate, - p_66250_: DeserializationContext - ): Instance { - return Instance( - ItemPredicate.fromJson(p_66248_["predicate"]) - ) - } - - fun trigger(player: ServerPlayer, newItem: ItemStack) { - trigger(player) { it.predicate.matches(newItem) } - } - - class Instance(val predicate: ItemPredicate) : AbstractCriterionTriggerInstance(ID, ContextAwarePredicate.ANY) { - override fun serializeToJson(p_16979_: SerializationContext): JsonObject { - return super.serializeToJson(p_16979_).also { - it["predicate"] = predicate.serializeToJson() - } - } - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidStatusTriggers.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidStatusTriggers.kt deleted file mode 100644 index 7efbf0e6d..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidStatusTriggers.kt +++ /dev/null @@ -1,95 +0,0 @@ -package ru.dbotthepony.mc.otm.triggers - -import com.google.gson.JsonObject -import net.minecraft.advancements.critereon.* -import net.minecraft.resources.ResourceLocation -import net.minecraft.server.level.ServerPlayer -import ru.dbotthepony.mc.otm.OverdriveThatMatters - -object BecomeAndroidTrigger : SimpleCriterionTrigger() { - val ID = ResourceLocation(OverdriveThatMatters.MOD_ID, "become_android") - - override fun getId(): ResourceLocation { - return ID - } - - override fun createInstance( - p_66248_: JsonObject, - p_286603_: ContextAwarePredicate, - p_66250_: DeserializationContext - ): Instance { - return Instance - } - - fun trigger(player: ServerPlayer) { - trigger(player) { true } - } - - object Instance : AbstractCriterionTriggerInstance(ID, ContextAwarePredicate.ANY) -} - -object BecomeAndroidSleepTrigger : SimpleCriterionTrigger() { - val ID = ResourceLocation(OverdriveThatMatters.MOD_ID, "become_android_sleep") - - override fun getId(): ResourceLocation { - return ID - } - - override fun createInstance( - p_66248_: JsonObject, - p_286603_: ContextAwarePredicate, - p_66250_: DeserializationContext - ): Instance { - return Instance - } - - fun trigger(player: ServerPlayer) { - trigger(player) { true } - } - - object Instance : AbstractCriterionTriggerInstance(ID, ContextAwarePredicate.ANY) -} - -object BecomeAndroidDeathTrigger : SimpleCriterionTrigger() { - val ID = ResourceLocation(OverdriveThatMatters.MOD_ID, "become_android_death") - - override fun getId(): ResourceLocation { - return ID - } - - override fun createInstance( - p_66248_: JsonObject, - p_286603_: ContextAwarePredicate, - p_66250_: DeserializationContext - ): Instance { - return Instance - } - - fun trigger(player: ServerPlayer) { - trigger(player) { true } - } - - object Instance : AbstractCriterionTriggerInstance(ID, ContextAwarePredicate.ANY) -} - -object BecomeHumaneTrigger : SimpleCriterionTrigger() { - val ID = ResourceLocation(OverdriveThatMatters.MOD_ID, "become_humane") - - override fun getId(): ResourceLocation { - return ID - } - - override fun createInstance( - p_66248_: JsonObject, - p_286603_: ContextAwarePredicate, - p_66250_: DeserializationContext - ): Instance { - return Instance - } - - fun trigger(player: ServerPlayer) { - trigger(player) { true } - } - - object Instance : AbstractCriterionTriggerInstance(ID, ContextAwarePredicate.ANY) -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/BlackHoleTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/BlackHoleTrigger.kt deleted file mode 100644 index 3f33a3b0d..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/BlackHoleTrigger.kt +++ /dev/null @@ -1,32 +0,0 @@ -package ru.dbotthepony.mc.otm.triggers - -import com.google.gson.JsonObject -import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance -import net.minecraft.advancements.critereon.ContextAwarePredicate -import net.minecraft.advancements.critereon.DeserializationContext -import net.minecraft.advancements.critereon.SimpleCriterionTrigger -import net.minecraft.resources.ResourceLocation -import net.minecraft.server.level.ServerPlayer -import ru.dbotthepony.mc.otm.OverdriveThatMatters - -object BlackHoleTrigger : SimpleCriterionTrigger() { - val ID = ResourceLocation(OverdriveThatMatters.MOD_ID, "black_hole_pull") - - override fun getId(): ResourceLocation { - return ID - } - - override fun createInstance( - p_66248_: JsonObject, - p_286603_: ContextAwarePredicate, - p_66250_: DeserializationContext - ): Instance { - return Instance - } - - fun trigger(player: ServerPlayer) { - trigger(player) { true } - } - - object Instance : AbstractCriterionTriggerInstance(ID, ContextAwarePredicate.ANY) -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/EnderTeleporterFallDeathTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/EnderTeleporterFallDeathTrigger.kt deleted file mode 100644 index 4db93ebed..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/EnderTeleporterFallDeathTrigger.kt +++ /dev/null @@ -1,32 +0,0 @@ -package ru.dbotthepony.mc.otm.triggers - -import com.google.gson.JsonObject -import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance -import net.minecraft.advancements.critereon.ContextAwarePredicate -import net.minecraft.advancements.critereon.DeserializationContext -import net.minecraft.advancements.critereon.SimpleCriterionTrigger -import net.minecraft.resources.ResourceLocation -import net.minecraft.server.level.ServerPlayer -import ru.dbotthepony.mc.otm.OverdriveThatMatters - -object EnderTeleporterFallDeathTrigger : SimpleCriterionTrigger() { - val ID = ResourceLocation(OverdriveThatMatters.MOD_ID, "ender_teleporter_fall_death") - - override fun getId(): ResourceLocation { - return ID - } - - override fun createInstance( - p_66248_: JsonObject, - p_286603_: ContextAwarePredicate, - p_66250_: DeserializationContext - ): Instance { - return Instance - } - - fun trigger(player: ServerPlayer) { - trigger(player) { true } - } - - object Instance : AbstractCriterionTriggerInstance(ID, ContextAwarePredicate.ANY) -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ExopackTriggers.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ExopackTriggers.kt new file mode 100644 index 000000000..c036e5556 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ExopackTriggers.kt @@ -0,0 +1,55 @@ +package ru.dbotthepony.mc.otm.triggers + +import com.google.gson.JsonObject +import com.mojang.serialization.Codec +import com.mojang.serialization.codecs.RecordCodecBuilder +import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance +import net.minecraft.advancements.critereon.ContextAwarePredicate +import net.minecraft.advancements.critereon.DeserializationContext +import net.minecraft.advancements.critereon.SerializationContext +import net.minecraft.advancements.critereon.SimpleCriterionTrigger +import net.minecraft.resources.ResourceLocation +import net.minecraft.server.level.ServerPlayer +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.core.fromJsonStrict +import ru.dbotthepony.mc.otm.core.toJsonStrict + +val ExopackObtainedTrigger = SingletonTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "exopack_obtained")) +val ExopackGainedCraftingTrigger = SingletonTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "exopack_gained_crafting")) +val ExopackGainedSmeltingTrigger = SingletonTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "exopack_gained_smelting")) + +val ExopackBatterySlotTrigger = ItemTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "exopack_battery_slot")) + +object ExopackSlotsExpandedTrigger : SimpleCriterionTrigger() { + val ID = ResourceLocation(OverdriveThatMatters.MOD_ID, "exopack_expanded") + + override fun getId(): ResourceLocation { + return ID + } + + val codec: Codec = RecordCodecBuilder.create { + it.group( + Codec.intRange(0, Int.MAX_VALUE).optionalFieldOf("minGained", 0).forGetter(Instance::minGained), + Codec.intRange(0, Int.MAX_VALUE).optionalFieldOf("minTotal", 0).forGetter(Instance::minTotal), + ).apply(it, ::Instance) + } + + fun trigger(player: ServerPlayer, gained: Int, total: Int) { + trigger(player) { it.minGained <= gained && it.minTotal <= total } + } + + override fun createInstance(p_66248_: JsonObject, p_286603_: ContextAwarePredicate, p_66250_: DeserializationContext): Instance { + return codec.fromJsonStrict(p_66248_) + } + + data class Instance(val minGained: Int = 0, val minTotal: Int = 0) : AbstractCriterionTriggerInstance(ID, ContextAwarePredicate.ANY) { + init { + require(minGained >= 0) { "Invalid minGained $minGained" } + require(minTotal >= 0) { "Invalid minTotal $minTotal" } + } + + override fun serializeToJson(p_16979_: SerializationContext): JsonObject { + return codec.toJsonStrict(this) as JsonObject + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/FallDampenersSaveTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/FallDampenersSaveTrigger.kt deleted file mode 100644 index 3acd19f8b..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/FallDampenersSaveTrigger.kt +++ /dev/null @@ -1,32 +0,0 @@ -package ru.dbotthepony.mc.otm.triggers - -import com.google.gson.JsonObject -import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance -import net.minecraft.advancements.critereon.ContextAwarePredicate -import net.minecraft.advancements.critereon.DeserializationContext -import net.minecraft.advancements.critereon.SimpleCriterionTrigger -import net.minecraft.resources.ResourceLocation -import net.minecraft.server.level.ServerPlayer -import ru.dbotthepony.mc.otm.OverdriveThatMatters - -object FallDampenersSaveTrigger : SimpleCriterionTrigger() { - val ID = ResourceLocation(OverdriveThatMatters.MOD_ID, "fall_dampeners_save") - - override fun getId(): ResourceLocation { - return ID - } - - override fun createInstance( - p_66248_: JsonObject, - p_286603_: ContextAwarePredicate, - p_66250_: DeserializationContext - ): Instance { - return Instance - } - - fun trigger(player: ServerPlayer) { - trigger(player) { true } - } - - object Instance : AbstractCriterionTriggerInstance(ID, ContextAwarePredicate.ANY) -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ItemTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ItemTrigger.kt new file mode 100644 index 000000000..1b43b2356 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ItemTrigger.kt @@ -0,0 +1,44 @@ +package ru.dbotthepony.mc.otm.triggers + +import com.google.gson.JsonObject +import com.mojang.serialization.Codec +import com.mojang.serialization.codecs.RecordCodecBuilder +import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance +import net.minecraft.advancements.critereon.ContextAwarePredicate +import net.minecraft.advancements.critereon.DeserializationContext +import net.minecraft.advancements.critereon.ItemPredicate +import net.minecraft.advancements.critereon.SerializationContext +import net.minecraft.advancements.critereon.SimpleCriterionTrigger +import net.minecraft.resources.ResourceLocation +import net.minecraft.server.level.ServerPlayer +import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.core.fromJsonStrict +import ru.dbotthepony.mc.otm.core.toJsonStrict +import ru.dbotthepony.mc.otm.data.ItemPredicateCodec + +class ItemTrigger(val ID: ResourceLocation) : SimpleCriterionTrigger() { + override fun getId(): ResourceLocation { + return ID + } + + fun trigger(player: ServerPlayer, item: ItemStack) { + trigger(player) { if (it.invert) !it.predicate.matches(item) else it.predicate.matches(item) } + } + + val codec: Codec = RecordCodecBuilder.create { + it.group( + ItemPredicateCodec.fieldOf("predicate").forGetter(Instance::predicate), + Codec.BOOL.optionalFieldOf("invert", false).forGetter(Instance::invert), + ).apply(it, ::Instance) + } + + override fun createInstance(p_66248_: JsonObject, p_286603_: ContextAwarePredicate, p_66250_: DeserializationContext): Instance { + return codec.fromJsonStrict(p_66248_) + } + + inner class Instance(val predicate: ItemPredicate, val invert: Boolean = false) : AbstractCriterionTriggerInstance(ID, ContextAwarePredicate.ANY) { + override fun serializeToJson(p_16979_: SerializationContext): JsonObject { + return codec.toJsonStrict(this) as JsonObject + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/SimpleTriggers.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/SimpleTriggers.kt new file mode 100644 index 000000000..174884c99 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/SimpleTriggers.kt @@ -0,0 +1,17 @@ +package ru.dbotthepony.mc.otm.triggers + +import net.minecraft.resources.ResourceLocation +import ru.dbotthepony.mc.otm.OverdriveThatMatters + +val BlackHoleTrigger = SingletonTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "black_hole_pull")) +val FallDampenersSaveTrigger = SingletonTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "fall_dampeners_save")) +val ShockwaveTrigger = SingletonTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "shockwave")) +val EnderTeleporterFallDeathTrigger = SingletonTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "ender_teleporter_fall_death")) + +val BecomeAndroidTrigger = SingletonTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "become_android")) +val BecomeAndroidSleepTrigger = SingletonTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "become_android_sleep")) +val BecomeAndroidDeathTrigger = SingletonTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "become_android_death")) +val BecomeHumaneTrigger = SingletonTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "become_humane")) + +val AndroidBatteryTrigger = ItemTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "android_battery")) +val TakeItemOutOfReplicatorTrigger = ItemTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "take_item_out_of_replicator")) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ShockwaveTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/SingletonTrigger.kt similarity index 56% rename from src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ShockwaveTrigger.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/triggers/SingletonTrigger.kt index 04d761755..c555138d1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ShockwaveTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/SingletonTrigger.kt @@ -7,26 +7,19 @@ import net.minecraft.advancements.critereon.DeserializationContext import net.minecraft.advancements.critereon.SimpleCriterionTrigger import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer -import ru.dbotthepony.mc.otm.OverdriveThatMatters - -object ShockwaveTrigger : SimpleCriterionTrigger() { - val ID = ResourceLocation(OverdriveThatMatters.MOD_ID, "shockwave") +class SingletonTrigger(val ID: ResourceLocation) : SimpleCriterionTrigger() { override fun getId(): ResourceLocation { return ID } - override fun createInstance( - p_66248_: JsonObject, - p_286603_: ContextAwarePredicate, - p_66250_: DeserializationContext - ): Instance { - return Instance + override fun createInstance(p_66248_: JsonObject, p_286603_: ContextAwarePredicate, p_66250_: DeserializationContext): AbstractCriterionTriggerInstance { + return instance } fun trigger(player: ServerPlayer) { trigger(player) { true } } - object Instance : AbstractCriterionTriggerInstance(ID, ContextAwarePredicate.ANY) + val instance = object : AbstractCriterionTriggerInstance(ID, ContextAwarePredicate.ANY) {} } From 2ac990c82dc6176495d322bef0db76c6c7c88bba Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 9 Jul 2023 22:57:59 +0700 Subject: [PATCH 0741/1199] Make exopack smelter not start new job when no power is present, and make exopack power changes notify smelters --- .../mc/otm/capability/MatteryPlayerCapability.kt | 3 ++- .../capability/energy/BatteryBackedEnergyStorage.kt | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 8db96a554..b85fbebc7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -431,6 +431,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial private val cache = RecipeManager.createCheck(RecipeType.SMELTING) override fun computeNextJob(): JobContainer { + if (!exoPackEnergy.batteryLevel.isPositive) return JobContainer.noEnergy() val level = ply.level() as? ServerLevel ?: return JobContainer.failure() val recipe = cache.getRecipeFor(input, level) @@ -470,7 +471,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial /** * [IMatteryEnergyStorage] instance, representing Exopack battery charge */ - val exoPackEnergy = ProfiledEnergyStorage(BatteryBackedEnergyStorage(ply, synchronizer, Decimal.ZERO, ExopackConfig.ENERGY_CAPACITY, false)) + val exoPackEnergy = ProfiledEnergyStorage(BatteryBackedEnergyStorage(ply, synchronizer, Decimal.ZERO, ExopackConfig.ENERGY_CAPACITY, false, onChange = { for (v in smelters) v.notify(MachineJobEventLoop.IdleReason.POWER) })) val exoPackChargeSlots = MatteryContainer(4) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BatteryBackedEnergyStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BatteryBackedEnergyStorage.kt index cec3e8396..3edbd1170 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BatteryBackedEnergyStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BatteryBackedEnergyStorage.kt @@ -25,7 +25,8 @@ class BatteryBackedEnergyStorage( synchronizer: FieldSynchronizer, initialCharge: Decimal, maxCharge: Decimal, - val isAndroid: Boolean + val isAndroid: Boolean, + val onChange: Runnable? = null ) : IMatteryEnergyStorage, INBTSerializable, ContainerSingleItem { override val energyFlow: FlowDirection get() = FlowDirection.INPUT @@ -41,6 +42,8 @@ class BatteryBackedEnergyStorage( } else if (ply is ServerPlayer && !isAndroid) { ExopackBatterySlotTrigger.trigger(ply, value) } + + onChange?.run() }) override fun getItem(slot: Int): ItemStack { @@ -105,6 +108,7 @@ class BatteryBackedEnergyStorage( ply.awardStat(StatNames.POWER_CONSUMED, drained.toInt() * 10) } + onChange?.run() return drained } } @@ -119,6 +123,8 @@ class BatteryBackedEnergyStorage( if (ply is ServerPlayer && isAndroid) { ply.awardStat(StatNames.POWER_CONSUMED, drained.toInt() * 10) } + + onChange?.run() } return drained @@ -137,6 +143,7 @@ class BatteryBackedEnergyStorage( } if (howMuch.isZero) { + onChange?.run() return received } } @@ -146,6 +153,7 @@ class BatteryBackedEnergyStorage( if (!simulate) { battery = new + onChange?.run() } return received @@ -167,6 +175,7 @@ class BatteryBackedEnergyStorage( } set(value) { battery = value + onChange?.run() } override var maxBatteryLevel: Decimal @@ -185,5 +194,6 @@ class BatteryBackedEnergyStorage( } set(value) { maxBattery = value + onChange?.run() } } From fe77e8df60db53cff46bbca6ff1fb27de13018ce Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 9 Jul 2023 22:58:50 +0700 Subject: [PATCH 0742/1199] updated localization files --- .../mc/otm/datagen/advancements/MachineAdvancementsData.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt index 349354dbc..754624d6a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt @@ -127,7 +127,7 @@ fun addMachineAdvancements(serializer: Consumer, existingFileHelper title = translation.add("replicate_something", "Local Bakery") { russian("Местная выпечка") }, - description = translation.add("replicate_something.desc", "Replicate something using Matter Replicator. If you replicated some food, be the first to taste it among your company") { + description = translation.add("replicate_something.desc", "Replicate something using Matter Replicator. If you replicated some food, be first to taste it among your company") { russian("Среплицируйте что либо используя репликатор материи. Если это еда, то не стесняйтесь быть первым, кто попробует её на вкус среди вашей компании") }, frameType = FrameType.GOAL From 5973ea3565402503910afa99789835448be25f13 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Mon, 10 Jul 2023 01:46:22 +0600 Subject: [PATCH 0743/1199] Fix funny blockpos checks for Android chargers --- .../ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt index 93faa46bc..2ffc08985 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt @@ -57,10 +57,10 @@ class AndroidChargerBlock : RotatableMatteryBlock(Properties.of().destroyTime(2. override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { val level = context.level - if (level.isOutsideBuildHeight(context.clickedPos + BlockPos(0, 0, 2))) return null + if (level.isOutsideBuildHeight(context.clickedPos + BlockPos(0, 2, 0))) return null for (i in 1 .. 2) { - val pos = context.clickedPos + BlockPos(0, 0, i) + val pos = context.clickedPos + BlockPos(0, i, 0) if (!level.getBlockState(pos).canBeReplaced(context)) return null } From 4b6909fc0b01a922510db7b810bfb6279413a72f Mon Sep 17 00:00:00 2001 From: GearShocky Date: Mon, 10 Jul 2023 03:38:09 +0600 Subject: [PATCH 0744/1199] Smelting upgrade texture and machine upgrade textures --- .../mc/otm/datagen/items/ItemModels.kt | 17 +++++++++++++++++ .../models/item/zpm_battery.json | 1 + .../block/resource/roflite_alloy_1.png | Bin 0 -> 226 bytes .../block/resource/roflite_alloy_2.png | Bin 0 -> 223 bytes .../block/resource/roflite_alloy_top.png | Bin 0 -> 205 bytes .../item/component/roflite_alloy_ingot.png | Bin 0 -> 251 bytes .../textures/item/exopack_smelting_upgrade.png | Bin 0 -> 276 bytes .../textures/item/exosuit_crafting_upgrade.png | Bin 273 -> 273 bytes .../textures/item/upgrade_capacity.png | Bin 0 -> 251 bytes .../textures/item/upgrade_energy.png | Bin 0 -> 257 bytes .../textures/item/upgrade_failure.png | Bin 0 -> 260 bytes .../textures/item/upgrade_processing.png | Bin 0 -> 266 bytes .../textures/item/upgrade_speed.png | Bin 0 -> 257 bytes .../textures/item/zpm_battery.png | Bin 446 -> 365 bytes 14 files changed, 18 insertions(+) create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/resource/roflite_alloy_1.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/resource/roflite_alloy_2.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/resource/roflite_alloy_top.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/component/roflite_alloy_ingot.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/exopack_smelting_upgrade.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_capacity.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_energy.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_failure.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_processing.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_speed.png diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index 3686becd2..3ef5c0e9e 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -77,6 +77,7 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.generated(MItems.ExopackUpgrades.INVENTORY_UPGRADE_CREATIVE) provider.generated(MItems.ExopackUpgrades.CRAFTING_UPGRADE) + provider.generated(MItems.ExopackUpgrades.SMELTING_UPGRADE) provider.component(MItems.TRITANIUM_DUST) provider.component(MItems.TRITANIUM_INGOT) @@ -97,6 +98,22 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.generated(MItems.MATTER_CAPACITOR_DENSE, modLocation("item/matter_capacitor_tier3")) provider.generated(MItems.MATTER_CAPACITOR_CREATIVE) + provider.generated(MItems.CreativeUpgrades.SPEED, modLocation("item/upgrade_speed")) + + provider.generated(MItems.CreativeUpgrades.ENERGY_CONSUMPTION, modLocation("item/upgrade_energy")) + provider.generated(MItems.CreativeUpgrades.ENERGY_THROUGHPUT, modLocation("item/upgrade_energy")) + provider.generated(MItems.CreativeUpgrades.ENERGY_THROUGHPUT_FLAT, modLocation("item/upgrade_energy")) + provider.generated(MItems.CreativeUpgrades.ENERGY_THROUGHPUT_FLAT_SMALL, modLocation("item/upgrade_energy")) + + provider.generated(MItems.CreativeUpgrades.ENERGY_STORAGE, modLocation("item/upgrade_capacity")) + provider.generated(MItems.CreativeUpgrades.ENERGY_STORAGE_FLAT, modLocation("item/upgrade_capacity")) + provider.generated(MItems.CreativeUpgrades.ENERGY_STORAGE_FLAT_SMALL, modLocation("item/upgrade_capacity")) + + provider.generated(MItems.CreativeUpgrades.FAILSAFE, modLocation("item/upgrade_failure")) + provider.generated(MItems.CreativeUpgrades.FAILURE, modLocation("item/upgrade_failure")) + + provider.generated(MItems.CreativeUpgrades.PROCESSING_ITEMS, modLocation("item/upgrade_processing")) + provider.generated(MItems.QUANTUM_BATTERY) provider.generated(MItems.QUANTUM_CAPACITOR) provider.generated(MItems.QUANTUM_BATTERY_CREATIVE) diff --git a/src/main/resources/assets/overdrive_that_matters/models/item/zpm_battery.json b/src/main/resources/assets/overdrive_that_matters/models/item/zpm_battery.json index 6fa136c36..4e8564c07 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/item/zpm_battery.json +++ b/src/main/resources/assets/overdrive_that_matters/models/item/zpm_battery.json @@ -1,4 +1,5 @@ { + "credit": "Made with Blockbench", "textures": { "0": "overdrive_that_matters:item/zpm_battery" }, diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/resource/roflite_alloy_1.png b/src/main/resources/assets/overdrive_that_matters/textures/block/resource/roflite_alloy_1.png new file mode 100644 index 0000000000000000000000000000000000000000..7dc22ae16dfa00f01f1fde3dfeb017da40f8cce5 GIT binary patch literal 226 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFOM6CBeIx*ftwG686EaL1ZrZ4_jGX# zk+>||drmdKI;Vst0JxD(5&!@I literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/resource/roflite_alloy_2.png b/src/main/resources/assets/overdrive_that_matters/textures/block/resource/roflite_alloy_2.png new file mode 100644 index 0000000000000000000000000000000000000000..14d4e1fb85e19aafb18f7382e62b4b0826e466e7 GIT binary patch literal 223 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFOM6CBeIx*ftwG686EaL1ZrZ4@pN$v zk+`hecTupxfX8X2ut)5HNt`^t->ZE+BQ9Q{av&s)u|4|fKINR7+$_gpRM^^|v@iH) zviiyY5Pt$Gzj}JVT)&lKe N@O1TaS?83{1OOq_N}~V( literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/resource/roflite_alloy_top.png b/src/main/resources/assets/overdrive_that_matters/textures/block/resource/roflite_alloy_top.png new file mode 100644 index 0000000000000000000000000000000000000000..d0cd682da7b9e01b16009cdc1fd92f5584013e6d GIT binary patch literal 205 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFOM6Huo0wh@A5n0T@z|9B3j1K!A0(CI>db&7NS%G}f0G|+7T_we2FHcW%v#RK*Fb4;Dd3m4=yTU<`A?zhVe!>62fI-Te*$pVf zS>O>_%)r36AA}h#Sc6r7f-#;hjv*SswSAUC2Mjovk3RixZzT$H}Z!>&1UscxpN@2c;7vzCSz hd=<*}|Nlzpxs5^y3pZ~ZTN=NS%G}T0G|-oz`(#2D^}dRdGoO8gQlh?F)^`ww*O5{P1V%YeEtI!F)U6`o<| zOM?7@|HA=;mp|htpfG2FM`SSr1K)lSX0%`pRsjm8db&7=%LU4#Gt literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/exosuit_crafting_upgrade.png b/src/main/resources/assets/overdrive_that_matters/textures/item/exosuit_crafting_upgrade.png index ab31babfcfb3ef91c8486ceb9a67ad44cf1a620b..0712ac982570320315fd28e70382b3f4485666e4 100644 GIT binary patch delta 147 zcmV;E0Brw}0+9lcQWk=Of)*AQH8nLRCMHb(00000#T<~^k!Uw^Q4YW$2m??A6uke1 z*CJcC@uBu%0$Y0%)n6$+1Ne6R{T~VW$_6_7_-yy)QE@21T0mj8^~v002ovPDHLkV1inx BIN|^R delta 147 zcmbQpG?8gSkQfj&H8q)&o(#=AsMUzgiL)P@592Es^#kuu`aP%~FkL%!=(fX)+y3GiRRE yWC>DmX3(8#Y`M)NN#R?P%9}4tm;NzvZ}`qCUCAcxxy&*OWTU66pUXO@geCyZ7B^=A diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_capacity.png b/src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_capacity.png new file mode 100644 index 0000000000000000000000000000000000000000..6eb8335b6e43196a7de21a039279c9cce8bb4cb9 GIT binary patch literal 251 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}H0G|-oz`(%z`uc)`0x>bM|NsA+nws)i2uUW$|GxoL!7#VK@;i{?Dhcun z2FgMJ!=^Jj=YgV}1s;*b3=DkxL735kHCP2G7~tvR7@`qedOnh`!GOc{B2!e&@B15k z1Wi7EDrd^v^&vBHZ;`^XE>EF(TyFIRDa=JaOgkEdclf=T*>ukFT;KtL!Wr6+=5L;= h#}FN=KcDvj+x;%)ADb1{9|xMv;OXk;vd$@?2>{W`REhuq literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_energy.png b/src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_energy.png new file mode 100644 index 0000000000000000000000000000000000000000..6403f04c2d03bb2e05444c51e85266a0bd6d8320 GIT binary patch literal 257 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}H0G|-oz`(%z`uc)`0x>bM|NsA+nws)i2uUW$|GxoL!7#VK@;i{?Dhcun z2FgMJ!=^Jj=YgV}1s;*b3=DkxL735kHCP2G80P8X7@`qed;THU0R;}Xz_X`*{?oUy z-+Jv^vbl#9i{MRlqbk-1$3l}mZ-~m|zPP8qrnt$TiD4_tlk^_pB!-j)a=$q|I#~k3 nl@31tb1JyOH+1iYWi#*I-^={1@}_n;&;|xiS3j3^P6f literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_failure.png b/src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_failure.png new file mode 100644 index 0000000000000000000000000000000000000000..c9dca5ab939f9ff2a67ec1f27a04188559a97937 GIT binary patch literal 260 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}H0G|-oz`(%z`uc)`0x>bM|NsA+nws)i2uUW$|GxoL!7#VK@;i{?Dhcun z2FgMJ!=^Jj=YgV}1s;*b3=DkxL735kHCP2G80qQa7@`qedcK#hL4m_9@QM55zws7! zDqFYZUH;Uw*7INIoH$0Q?On5dB1C0!1I}Kz&)C9X-znUnZm{}XDT9{4W{WG+6n>oZ qVUVa4iqUf`NS%G}H0G|-oz`(%z`uc)`0x>bM|NsA+nws)i2uUW$|GxoL!7#VK@;i{?Dhcun z2FgMJ!=^Jj=YgV}1s;*b3=DkxL735kHCP2G81L!g7@`pzd!Cc;fC2}L!_x_${_{^~ zjmo_)km_W@_doT=4;F*WvW%jGv)h#UJ6v)FzNp#;GI%bq_{t$V;Q{NxGA2*v)vH`G x@2ut2y{N@pwB+!Qn4UK(Ka4hWXYc&Yd+i|e6Bu literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_speed.png b/src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_speed.png new file mode 100644 index 0000000000000000000000000000000000000000..0a1af7fd93baeb6c179a4a0dccad0070070b3f0d GIT binary patch literal 257 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}H0G|-oz`(%z`uc)`0x>bM|NsA+nws)i2uUW$|GxoL!7#VK@;i{?Dhcun z2FgMJ!=^Jj=YgV}1s;*b3=DkxL735kHCP2G80P8X7@`qedOn)#fC7(8;92Lh|IF|B zm}GJ9{ruEXpu1KpERIp@s%YrE4bcT(*_%$Xx-)$^AvEg&r`i_9^Nee>W~>l@Fv*Z1 o-00ZzKc_SgM7^&~ID1C!>U!qq%h!F`0*F93G{2+-U2AOLp&vZeG40dOJ&S&nWgObnC=VSj3{0hk&nmt;V;;mEm% zVh2FkSOGo<40U^f|1Hd7$t^N&^3jtn@B2X5c3Zj7oI2{1;IjwyU0s|fb zICB9#d=CQP5IB4P0ScxkVEq5Urw7W0gDvt<1`_bm{sm00000NkvXXu0mjfrT}w} delta 382 zcmV-^0fGMQ0=@%~Nq@rt01m?e$8V@)0003~NklD@$mnzsIJZM@!eYnWWX;Z z%y9qaRR)k8DPZUFIZzfVaF0x3SUjYwTOiciH04{(WG7oRx z0Am;c$)RIh0GAxt0idA9hCu*VXn+8Es1Z_&4S*dWBr1UwgMR=aU!h}M0GAv%5yC7( z2k&0LASw}(n(&YT!8AZ?K$Q@{2MC1#K?fY!v5~R9zW)EEOP8Rcs6bCokD;-#5w9iq z08tKra!~-tQBWpD4gjYCkVV)qApo+N63an=NtBa`0UxF{UsB9sdOL9_Lt zECz=4>(^7{Lw7=8z_TGv2Y`G|Yu|&wz!yZIGyr9z0DAZy1i&G1^ypC(Oi#f0|A9{r zlnn=4~C;G_Ku%0d8bh9@OZCfQ){<^ph($07*qoM6N<$f^Gqs^Z)<= From 0444568c64d0f780487bccc1bc8cd580cceb74d0 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 10 Jul 2023 18:44:43 +0700 Subject: [PATCH 0745/1199] =?UTF-8?q?YuRaNnNzZZ=20=E2=80=94=20=D0=A1=D0=B5?= =?UTF-8?q?=D0=B3=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=2018:42=20=D1=83=D0=B1?= =?UTF-8?q?=D0=B5=D1=80=D0=B8=20=D0=BD=D0=B0=D1=85=D1=83=D0=B9=20=D0=BA?= =?UTF-8?q?=D1=83=D1=80=D0=B8=D0=BE=20=D1=81=D0=BB=D0=BE=D1=82=D1=8B=20?= =?UTF-8?q?=D0=B8=D0=B7=20=D1=8D=D0=BA=D0=B7=D0=BE=D0=BF=D0=B0=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt index 9c435a6e1..e99c1f020 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt @@ -67,6 +67,8 @@ private fun Player.getCuriosSlotsImpl(): List> { * [Pair] */ val Player.curiosSlots: List> get() { + return listOf() + if (!isCuriosLoaded) { return listOf() } @@ -91,6 +93,8 @@ private fun Player.curiosStreamImpl(includeCosmetics: Boolean): Stream { + return Stream.empty() + if (!isCuriosLoaded) { return Stream.empty() } @@ -115,6 +119,8 @@ private fun Player.curiosAwareStreamImpl(includeCosmetics: Boolean): Stream { + return Stream.empty() + if (!isCuriosLoaded) { return Stream.empty() } From 37974d40b94f8c908b5f29d6ab232067d2d40b3a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 10 Jul 2023 21:48:59 +0700 Subject: [PATCH 0746/1199] Refine render methods and functions --- .../otm/android/AndroidSwitchableFeature.kt | 8 +- .../android/feature/EnderTeleporterFeature.kt | 5 +- .../otm/android/feature/ItemMagnetFeature.kt | 5 +- .../otm/android/feature/JumpBoostFeature.kt | 13 +- .../otm/android/feature/NightVisionFeature.kt | 7 +- .../otm/android/feature/ShockwaveFeature.kt | 13 +- .../otm/android/feature/StepAssistFeature.kt | 5 +- .../energy/IMatteryEnergyStorage.kt | 2 +- .../otm/capability/matter/IMatterStorage.kt | 2 +- .../otm/capability/matter/IPatternStorage.kt | 2 +- .../mc/otm/client/AndroidAbilityKeyMapping.kt | 13 +- .../dbotthepony/mc/otm/client/MatteryGUI.kt | 22 +- .../client/render/AbstractMatterySprite.kt | 272 ++-------- .../dbotthepony/mc/otm/client/render/Ext.kt | 43 +- .../mc/otm/client/render/IGUIRenderable.kt | 38 +- .../mc/otm/client/render/MatterySprite.kt | 12 +- .../mc/otm/client/render/RenderHelper.kt | 478 +++++------------- .../mc/otm/client/render/UVStuff.kt | 168 +++--- .../client/render/blockentity/BankRenderer.kt | 11 +- .../render/blockentity/BlackHoleRenderer.kt | 3 +- .../render/blockentity/HoloSignRenderer.kt | 2 +- .../mc/otm/client/screen/panels/FramePanel.kt | 6 +- .../mc/otm/client/screen/panels/Label.kt | 36 +- .../screen/panels/button/ButtonPanel.kt | 2 +- .../screen/panels/input/TextInputPanel.kt | 4 +- .../screen/panels/slot/AbstractSlotPanel.kt | 3 +- .../client/screen/panels/slot/SlotPanel.kt | 6 +- .../panels/slot/UserFilteredSlotPanel.kt | 11 +- .../screen/tech/AndroidStationScreen.kt | 45 +- .../dbotthepony/mc/otm/core/math/RGBAColor.kt | 66 +-- .../mc/otm/item/weapon/AbstractWeaponItem.kt | 14 +- 31 files changed, 424 insertions(+), 893 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt index bc52c0b0e..a17deba7c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt @@ -1,9 +1,9 @@ package ru.dbotthepony.mc.otm.android -import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.GuiGraphics import net.minecraft.nbt.CompoundTag import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability +import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.nbt.set abstract class AndroidSwitchableFeature(type: AndroidFeatureType<*>, android: MatteryPlayerCapability) : AndroidFeature(type, android) { @@ -25,7 +25,7 @@ abstract class AndroidSwitchableFeature(type: AndroidFeatureType<*>, android: Ma open val allowToSwitchByPlayerWhileSpectator: Boolean get() = true open val maxCooldown: Int get() = 0 - open var cooldown by synchronizer.int() + open var cooldown by synchronizer.int().property val isOnCooldown: Boolean get() = maxCooldown > 0 && cooldown > 0 @@ -38,9 +38,9 @@ abstract class AndroidSwitchableFeature(type: AndroidFeatureType<*>, android: Ma cooldown = maxCooldown } - // TODO: PoseStack is stripped from server dist + // TODO: GuiGraphics is stripped from server dist // but it doesn't seem to cause issues? - abstract fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float) + abstract fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor = RGBAColor.WHITE) override fun serializeNBT(): CompoundTag { return super.serializeNBT().also { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt index 5e5931bbb..e8a417e10 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt @@ -38,6 +38,7 @@ import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.core.genericPositions import ru.dbotthepony.mc.otm.core.holder import ru.dbotthepony.mc.otm.core.isFall +import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.math.asVector import ru.dbotthepony.mc.otm.core.math.component1 @@ -372,12 +373,12 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv } } - override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float) { + override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { if (cooldown > 0) { RenderSystem.setShaderColor(1f, 0.4f, 0.4f, 1f) } - ResearchIcons.ICON_ENDER_TELEPORT.render(graphics, x, y, width, height) + ResearchIcons.ICON_ENDER_TELEPORT.render(graphics, x, y, width, height, color = color) if (cooldown > 0) { RenderSystem.setShaderColor(1f, 1f, 1f, 1f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt index 46e9c4477..bafb85a0a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt @@ -21,6 +21,7 @@ import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.core.getEntitiesInEllipsoid +import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.minus import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.core.position @@ -129,7 +130,7 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable } } - override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float) { - ResearchIcons.ICON_ITEM_MAGNET.render(graphics, x, y, width, height) + override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { + ResearchIcons.ICON_ITEM_MAGNET.render(graphics, x, y, width, height, color = color) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt index 002bf99f2..fe281455d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt @@ -26,6 +26,7 @@ import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.ResearchIcons +import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.math.component1 import ru.dbotthepony.mc.otm.core.math.component2 @@ -150,15 +151,7 @@ class JumpBoostFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF } } - override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float) { - if (cooldown > 0) { - RenderSystem.setShaderColor(1f, 0.4f, 0.4f, 1f) - } - - ResearchIcons.ICON_JUMP_BOOST.render(graphics, x, y, width, height) - - if (cooldown > 0) { - RenderSystem.setShaderColor(1f, 1f, 1f, 1f) - } + override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { + ResearchIcons.ICON_JUMP_BOOST.render(graphics, x, y, width, height, color = if (cooldown > 0) color * RGBAColor.REDDISH else color) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt index 01f5dc6ea..c7241d161 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt @@ -1,15 +1,14 @@ package ru.dbotthepony.mc.otm.android.feature -import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.GuiGraphics import net.minecraft.world.effect.MobEffectInstance import net.minecraft.world.effect.MobEffects -import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.config.AndroidConfig +import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.registry.AndroidFeatures class NightVisionFeature(android: MatteryPlayerCapability) : AndroidSwitchableFeature(AndroidFeatures.NIGHT_VISION, android) { @@ -34,7 +33,7 @@ class NightVisionFeature(android: MatteryPlayerCapability) : AndroidSwitchableFe } } - override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float) { - ResearchIcons.ICON_NIGHT_VISION.render(graphics, x, y, width, height) + override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { + ResearchIcons.ICON_NIGHT_VISION.render(graphics, x, y, width, height, color = color) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt index ce0fbb20c..faad7ecd9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt @@ -34,6 +34,7 @@ import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.core.damageType +import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.ShockwaveEffectPacket import ru.dbotthepony.mc.otm.network.enqueueWork @@ -240,15 +241,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF ticker(false) } - override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float) { - if (isOnCooldown) { - RenderSystem.setShaderColor(1f, 0.4f, 0.4f, 1f) - } - - ResearchIcons.ICON_SHOCKWAVE.render(graphics, x, y, width, height) - - if (isOnCooldown) { - RenderSystem.setShaderColor(1f, 1f, 1f, 1f) - } + override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { + ResearchIcons.ICON_SHOCKWAVE.render(graphics, x, y, width, height, color = if (isOnCooldown) color * RGBAColor.REDDISH else color) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/StepAssistFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/StepAssistFeature.kt index 81f3be363..a26e62bd8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/StepAssistFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/StepAssistFeature.kt @@ -7,6 +7,7 @@ import net.minecraftforge.common.ForgeMod import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.client.render.ResearchIcons +import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.registry.AndroidFeatures import java.util.* @@ -54,8 +55,8 @@ class StepAssistFeature(android: MatteryPlayerCapability) : AndroidSwitchableFea sharedTick() } - override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float) { - ResearchIcons.ICON_STEP_ASSIST.render(graphics, x, y, width, height) + override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { + ResearchIcons.ICON_STEP_ASSIST.render(graphics, x, y, width, height, color = color) } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt index 53407ac9d..98ad13ab6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt @@ -366,5 +366,5 @@ fun IMatteryEnergyStorage.getBarWidth(): Int { } fun IMatteryEnergyStorage.getBarColor(): Int { - return RGBAColor.LOW_POWER.linearInterpolation((batteryLevel / maxBatteryLevel).toFloat(), RGBAColor.FULL_POWER).toInt() + return RGBAColor.LOW_POWER.linearInterpolation((batteryLevel / maxBatteryLevel).toFloat(), RGBAColor.FULL_POWER).toRGB() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterStorage.kt index 7c75ad595..196389911 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IMatterStorage.kt @@ -123,7 +123,7 @@ fun IMatterStorage.getBarWidth(): Int { } fun IMatterStorage.getBarColor(): Int { - return RGBAColor.LOW_MATTER.linearInterpolation((storedMatter / maxStoredMatter).toFloat(), RGBAColor.FULL_MATTER).toInt() + return RGBAColor.LOW_MATTER.linearInterpolation((storedMatter / maxStoredMatter).toFloat(), RGBAColor.FULL_MATTER).toRGB() } val ICapabilityProvider.matter: IMatterStorage? get() = getCapability(MatteryCapability.MATTER).orNull() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IPatternStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IPatternStorage.kt index 087d02a65..b43508eb6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IPatternStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IPatternStorage.kt @@ -73,7 +73,7 @@ fun IPatternStorage.getBarWidth(): Int { } fun IPatternStorage.getBarColor(): Int { - return RGBAColor.LOW_PATTERNS.linearInterpolation((storedPatterns / patternCapacity).toFloat(), RGBAColor.FULL_PATTERNS).toInt() + return RGBAColor.LOW_PATTERNS.linearInterpolation((storedPatterns / patternCapacity).toFloat(), RGBAColor.FULL_PATTERNS).toRGB() } val ICapabilityProvider.patterns: IPatternStorage? get() = getCapability(MatteryCapability.PATTERN).orNull() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt index 41b816802..72ec6ec00 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt @@ -11,7 +11,7 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.android.AndroidActiveFeature import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.render.Widgets18 -import ru.dbotthepony.mc.otm.client.render.drawRect +import ru.dbotthepony.mc.otm.client.render.renderRect import ru.dbotthepony.mc.otm.client.render.is3DContext import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.network.ActivateAndroidFeaturePacket @@ -58,25 +58,16 @@ object AndroidAbilityKeyMapping : KeyMapping("key.otm.android_ability", KeyConfl val x = minecraft.window.guiScaledWidth.toFloat() * .5f + iconSize / 2f val y = minecraft.window.guiScaledHeight.toFloat() * .5f - iconSize / 2f - RGBAColor.WHITE.setSystemColor() - feature.renderIcon(event.guiGraphics, x, y, iconSize, iconSize) if (feature.isOnCooldown) { - RGBAColor.WHITE.setSystemColor() - val cooldownPct = feature.cooldownPercent if (cooldownPct > 0.0f) { - RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f) - val nodrawpixels = (iconSize * (1 - cooldownPct)).roundToInt().toFloat() - drawRect(event.guiGraphics, x, y + nodrawpixels, iconSize, iconSize - nodrawpixels) - - RenderSystem.setShaderColor(1f, 1f, 1f, 1f) + event.guiGraphics.renderRect(x, y + nodrawpixels, iconSize, iconSize - nodrawpixels, color = RGBAColor.HALF_TRANSPARENT) } - Widgets18.COOLDOWN.render(event.guiGraphics, x, y + iconSize, iconSize, iconSize) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index 53a4fc24d..11bd4aad9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -155,8 +155,12 @@ object MatteryGUI { pushScissorRect(0, (scissorBase + scissorHeight * (1f - progress)).toInt(), window.width, (scissorHeight * progress * 2f).toInt()) - setDrawColor(RGBAColor(1f, 1f, 1f, 0.4f)) - drawRect(event.guiGraphics, 0f, y - 12f, window.guiScaledWidth.toFloat(), 24f + (deathLog.size - 2f).coerceAtLeast(0f) * minecraft.font.lineHeight * modifyScale * 0.175f) + event.guiGraphics.renderRect( + 0f, + y - 12f, + window.guiScaledWidth.toFloat(), + 24f + (deathLog.size - 2f).coerceAtLeast(0f) * minecraft.font.lineHeight * modifyScale * 0.175f, + color = RGBAColor(1f, 1f, 1f, 0.4f)) val text = TranslatableComponent("otm.iteration", iteration) @@ -249,8 +253,8 @@ object MatteryGUI { val formattedPower = mattery.androidEnergy.batteryLevel.formatPower() - event.guiGraphics.drawScaledAligned(gui.font, formattedPower, 0.5f, RenderGravity.CENTER_LEFT, left + 83f, top + 4f, RGBAColor.BLACK.toInt()) - event.guiGraphics.drawScaledAligned(gui.font, formattedPower, 0.5f, RenderGravity.CENTER_LEFT, left + 82f, top + 3f, RGBAColor.YELLOW.toInt()) + event.guiGraphics.drawScaledAligned(gui.font, formattedPower, 0.5f, RenderGravity.CENTER_LEFT, left + 83f, top + 4f, RGBAColor.BLACK.toRGB()) + event.guiGraphics.drawScaledAligned(gui.font, formattedPower, 0.5f, RenderGravity.CENTER_LEFT, left + 82f, top + 3f, RGBAColor.YELLOW.toRGB()) } } @@ -268,14 +272,14 @@ object MatteryGUI { private fun getHealthColorForPlayer(player: Player): Int { if (player.hasEffect(MobEffects.POISON)) { - return RGBAColor.DARK_GREEN.toInt() + return RGBAColor.DARK_GREEN.toRGB() } else if (player.hasEffect(MobEffects.WITHER)) { - return RGBAColor.WHITE.toInt() + return RGBAColor.WHITE.toRGB() } else if (player.isFullyFrozen) { - return RGBAColor.AQUA.toInt() + return RGBAColor.AQUA.toRGB() } - return RGBAColor.RED.toInt() + return RGBAColor.RED.toRGB() } // можно вынести в конфиг, но для этого нужен селектор цвета private fun renderPlayerHealth(event: RenderGuiOverlayEvent.Pre, gui: ForgeGui) { @@ -325,7 +329,7 @@ object MatteryGUI { if (ply.absorptionAmount > 0) formattedHealth = "%d+%d/%d".format(ply.health.toInt(), ply.absorptionAmount.toInt(), ply.maxHealth.toInt()) - event.guiGraphics.drawScaledAligned(minecraft.font, formattedHealth, 0.5f, RenderGravity.CENTER_RIGHT, left - 4f, top + 4f, RGBAColor.BLACK.toInt()) + event.guiGraphics.drawScaledAligned(minecraft.font, formattedHealth, 0.5f, RenderGravity.CENTER_RIGHT, left - 4f, top + 4f, RGBAColor.BLACK.toRGB()) event.guiGraphics.drawScaledAligned(minecraft.font, formattedHealth, 0.5f, RenderGravity.CENTER_RIGHT, left - 5f, top + 3f, getHealthColorForPlayer(ply)) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt index 4b34ee8c4..d4ac1afef 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt @@ -17,7 +17,7 @@ import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.linearInterpolation import java.util.concurrent.ConcurrentHashMap -sealed class AbstractMatterySprite : IGUIRenderable { +sealed class AbstractMatterySprite : IGUIRenderable, IUVCoords { /** * Expected image width in pixels, used in calculations * and as default width argument in render methods @@ -30,11 +30,6 @@ sealed class AbstractMatterySprite : IGUIRenderable { */ abstract override val height: Float - abstract val u0: Float - abstract val v0: Float - abstract val u1: Float - abstract val v1: Float - fun partialU(offset: Float): Float { return u0 + (offset / width) * (u1 - u0) } @@ -44,9 +39,7 @@ sealed class AbstractMatterySprite : IGUIRenderable { } abstract val type: SpriteType - override val winding: UVWindingOrder get() = UVWindingOrder.NORMAL - abstract val texture: ResourceLocation /** @@ -60,7 +53,6 @@ sealed class AbstractMatterySprite : IGUIRenderable { height: Float = this.height, ) = ru.dbotthepony.mc.otm.client.render.clearDepth(graphics, x, y, width, height) - @JvmOverloads fun render( stack: PoseStack, x: Float = 0f, @@ -69,11 +61,7 @@ sealed class AbstractMatterySprite : IGUIRenderable { height: Float = this.height, winding: UVWindingOrder = this.winding ) { - RenderSystem.setShaderTexture(0, texture) - RenderSystem.enableBlend() - RenderSystem.defaultBlendFunc() - - renderRaw(stack, x, y, width, height, winding) + renderTexturedRect(stack.last().pose(), x, y, width, height, uvWinding = winding, uv = this, texture = texture) } override fun render( @@ -82,217 +70,44 @@ sealed class AbstractMatterySprite : IGUIRenderable { y: Float, width: Float, height: Float, - winding: UVWindingOrder + winding: UVWindingOrder, + color: RGBAColor ) { - render(guiGraphics.pose(), x, y, width, height, winding) + guiGraphics.renderTexturedRect(x, y, width, height, uvWinding = winding, color = color, texture = texture, uv = this) } - override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, gravity: RenderGravity, winding: UVWindingOrder) { - render(guiGraphics.pose(), x, y, width, height, winding) - } - - @JvmOverloads - fun render( - stack: PoseStack, - x: Double, - y: Double = 0.0, - width: Double = this.width.toDouble(), - height: Double = this.height.toDouble(), - winding: UVWindingOrder = this.winding - ) = render(stack, x.toFloat(), y.toFloat(), width.toFloat(), height.toFloat(), winding) - - @JvmOverloads fun renderPartial( stack: PoseStack, x: Float = 0f, y: Float = 0f, width: Float = this.width, height: Float = this.height, - winding: UVWindingOrder = this.winding + winding: UVWindingOrder = this.winding, + color: RGBAColor = RGBAColor.WHITE ) { - RenderSystem.setShaderTexture(0, texture) - RenderSystem.enableBlend() - RenderSystem.defaultBlendFunc() + val u1 = u0 + linearInterpolation(width / this.width, 0f, u1 - u0) + val v1 = v0 + linearInterpolation(height / this.height, 0f, v1 - v0) - renderRawPartial(stack, x, y, width, height, winding) - } + val winded = winding.translate(u0, v0, u1.coerceIn(0f, 1f), v1.coerceIn(0f, 1f)) - @JvmOverloads - fun renderPartial( - graphics: GuiGraphics, - x: Float = 0f, - y: Float = 0f, - width: Float = this.width, - height: Float = this.height, - winding: UVWindingOrder = this.winding - ) = renderPartial(graphics.pose(), x, y, width, height, winding) - - @JvmOverloads - fun renderPartial( - stack: PoseStack, - x: Double, - y: Double = 0.0, - width: Double = this.width.toDouble(), - height: Double = this.height.toDouble(), - winding: UVWindingOrder = this.winding - ) = renderPartial(stack, x.toFloat(), y.toFloat(), width.toFloat(), height.toFloat(), winding) - - @JvmOverloads - fun renderPartial( - graphics: GuiGraphics, - x: Double, - y: Double = 0.0, - width: Double = this.width.toDouble(), - height: Double = this.height.toDouble(), - winding: UVWindingOrder = this.winding - ) = renderPartial(graphics.pose(), x, y, width, height, winding) - - @JvmOverloads - fun renderWidth( - stack: PoseStack, - x: Float = 0f, - y: Float = 0f, - width: Float = this.width, - winding: UVWindingOrder = this.winding - ) = render(stack, x, y, width = width, winding = winding) - - @JvmOverloads - fun renderWidth( - graphics: GuiGraphics, - x: Float = 0f, - y: Float = 0f, - width: Float = this.width, - winding: UVWindingOrder = this.winding - ) = renderWidth(graphics.pose(), x, y, width, winding) - - @JvmOverloads - fun renderWidth( - stack: PoseStack, - x: Double, - y: Double = 0.0, - width: Double = this.width.toDouble(), - winding: UVWindingOrder = this.winding - ) = renderWidth(stack, x.toFloat(), y.toFloat(), width.toFloat(), winding) - - @JvmOverloads - fun renderWidth( - graphics: GuiGraphics, - x: Double, - y: Double = 0.0, - width: Double = this.width.toDouble(), - winding: UVWindingOrder = this.winding - ) = renderWidth(graphics.pose(), x, y, width, winding) - - @JvmOverloads - fun renderHeight( - stack: PoseStack, - x: Float = 0f, - y: Float = 0f, - height: Float = this.height, - winding: UVWindingOrder = this.winding - ) = render(stack, x, y, height = height, winding = winding) - - @JvmOverloads - fun renderHeight( - graphics: GuiGraphics, - x: Float = 0f, - y: Float = 0f, - height: Float = this.height, - winding: UVWindingOrder = this.winding - ) = renderHeight(graphics.pose(), x, y, height, winding) - - @JvmOverloads - fun renderHeight( - stack: PoseStack, - x: Double, - y: Double = 0.0, - height: Double = this.height.toDouble(), - winding: UVWindingOrder = this.winding - ) = renderHeight(stack, x.toFloat(), y.toFloat(), height.toFloat(), winding) - - @JvmOverloads - fun renderHeight( - graphics: GuiGraphics, - x: Double, - y: Double = 0.0, - height: Double = this.height.toDouble(), - winding: UVWindingOrder = this.winding - ) = renderHeight(graphics.pose(), x, y, height, winding) - - @JvmOverloads - fun renderRaw( - stack: PoseStack, - x: Float = 0f, - y: Float = 0f, - width: Float = this.width, - height: Float = this.height, - winding: UVWindingOrder = this.winding - ) { - val winded = winding.translate(u0, v0, u1, v1) - - drawTexturedRect( - stack, - x, - y, - width, - height, - winded, + renderTexturedRect( + stack.last().pose(), + x = x, y = y, + width = width, height = height, + uv = winded, texture = texture, + color = color ) } - @JvmOverloads - fun renderRaw( - stack: PoseStack, - x: Double, - y: Double = 0.0, - width: Double = this.width.toDouble(), - height: Double = this.height.toDouble(), - winding: UVWindingOrder = this.winding - ) = renderRaw(stack, x.toFloat(), y.toFloat(), width.toFloat(), height.toFloat(), winding) - - @JvmOverloads - fun renderRaw( + fun renderPartial( graphics: GuiGraphics, - x: Double, - y: Double = 0.0, - width: Double = this.width.toDouble(), - height: Double = this.height.toDouble(), - winding: UVWindingOrder = this.winding - ) = renderRaw(graphics.pose(), x, y, width, height, winding) - - @JvmOverloads - fun renderRawPartial( - stack: PoseStack, x: Float = 0f, y: Float = 0f, width: Float = this.width, height: Float = this.height, - winding: UVWindingOrder = this.winding - ) { - val u1 = (u0 + linearInterpolation(width / this.width, 0f, u1 - u0)).coerceAtLeast(0f).coerceAtMost(1f) - val v1 = (v0 + linearInterpolation(height / this.height, 0f, v1 - v0)).coerceAtLeast(0f).coerceAtMost(1f) - - val winded = winding.translate(u0, v0, u1, v1) - - drawTexturedRect( - stack, - x, - y, - width, - height, - winded, - ) - } - - @JvmOverloads - fun renderRawPartial( - stack: PoseStack, - x: Double, - y: Double = 0.0, - width: Double = this.width.toDouble(), - height: Double = this.height.toDouble(), - winding: UVWindingOrder = this.winding - ) = renderRawPartial(stack, x.toFloat(), y.toFloat(), width.toFloat(), height.toFloat(), winding) + winding: UVWindingOrder = this.winding, + color: RGBAColor = RGBAColor.WHITE + ) = renderPartial(graphics.pose(), x, y, width, height, winding, color) protected fun uploadOnto( pose: PoseStack, @@ -308,15 +123,13 @@ sealed class AbstractMatterySprite : IGUIRenderable { u1: Float, v1: Float, ) { - val intColor = color?.toARGB() ?: 0 val matrix = pose.last().pose() - builder.vertex(matrix, x, y + height, z).also { if (color != null) it.color(intColor) }.uv(u0, v1).endVertex() - builder.vertex(matrix, x + width, y + height, z).also { if (color != null) it.color(intColor) }.uv(u1, v1).endVertex() - builder.vertex(matrix, x + width, y, z).also { if (color != null) it.color(intColor) }.uv(u1, v0).endVertex() - builder.vertex(matrix, x, y, z).also { if (color != null) it.color(intColor) }.uv(u0, v0).endVertex() + builder.vertex(matrix, x, y + height, z).color(color).uv(u0, v1).endVertex() + builder.vertex(matrix, x + width, y + height, z).color(color).uv(u1, v1).endVertex() + builder.vertex(matrix, x + width, y, z).color(color).uv(u1, v0).endVertex() + builder.vertex(matrix, x, y, z).color(color).uv(u0, v0).endVertex() } - @JvmOverloads fun uploadOnto( pose: PoseStack, builder: VertexConsumer, @@ -328,11 +141,14 @@ sealed class AbstractMatterySprite : IGUIRenderable { color: RGBAColor? = null, winding: UVWindingOrder = this.winding, ) { - val (u0, v0, u1, v1) = winding.translate(u0, v0, u1, v1) + val u0 = winding.u0(this) + val v0 = winding.v0(this) + val u1 = winding.u1(this) + val v1 = winding.v1(this) + uploadOnto(pose, builder, x, y, width, height, z, color, u0, v0, u1, v1) } - @JvmOverloads fun uploadOntoPartial( pose: PoseStack, builder: VertexConsumer, @@ -351,36 +167,6 @@ sealed class AbstractMatterySprite : IGUIRenderable { uploadOnto(pose, builder, x, y, width, height, z, color, u0_, v0_, u1_, v1_) } - @JvmOverloads - fun uploadOntoPartialColor( - pose: PoseStack, - builder: VertexConsumer, - x: Float = 0f, - y: Float = 0f, - width: Float = this.width, - height: Float = this.height, - z: Float = 0f, - color: RGBAColor = RGBAColor.WHITE, - winding: UVWindingOrder = this.winding, - ) { - uploadOntoPartial(pose, builder, x, y, width, height, z, color, winding) - } - - @JvmOverloads - fun uploadOntoColor( - pose: PoseStack, - builder: VertexConsumer, - x: Float = 0f, - y: Float = 0f, - width: Float = this.width, - height: Float = this.height, - z: Float = 0f, - color: RGBAColor = RGBAColor.WHITE, - winding: UVWindingOrder = this.winding, - ) { - uploadOnto(pose, builder, x, y, width, height, z, color, winding) - } - fun toJson(): JsonObject { return type.toActualJson(this) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt index fad69667b..fd3def77d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt @@ -25,7 +25,12 @@ val tesselator: Tesselator get() = Tesselator.getInstance() fun VertexConsumer.normal(vector: Vector): VertexConsumer = normal(vector.x.toFloat(), vector.y.toFloat(), vector.z.toFloat()) fun VertexConsumer.vertex(matrix4f: Matrix4f, vector: Vector): VertexConsumer = vertex(matrix4f, vector.x.toFloat(), vector.y.toFloat(), vector.z.toFloat()) -fun VertexConsumer.color(color: RGBAColor): VertexConsumer = color(color.red, color.green, color.blue, color.alpha) +fun VertexConsumer.color(color: RGBAColor?): VertexConsumer { + if (color != null) + color(color.redInt, color.greenInt, color.blueInt, color.alphaInt) + + return this +} 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()) @@ -217,46 +222,46 @@ fun Font.drawAligned(poseStack: PoseStack, text: String, align: RenderGravity, x fun Font.drawAligned(poseStack: PoseStack, text: Component, align: RenderGravity, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(poseStack, text, align, x, y, color) fun Font.drawAligned(poseStack: PoseStack, text: FormattedCharSequence, align: RenderGravity, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(poseStack, text, align, x, y, color) -fun Font.drawAligned(poseStack: PoseStack, text: String, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawAligned(poseStack, text, align, x, y, color.toInt()) -fun Font.drawAligned(poseStack: PoseStack, text: Component, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawAligned(poseStack, text, align, x, y, color.toInt()) -fun Font.drawAligned(poseStack: PoseStack, text: FormattedCharSequence, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawAligned(poseStack, text, align, x, y, color.toInt()) +fun Font.drawAligned(poseStack: PoseStack, text: String, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawAligned(poseStack, text, align, x, y, color.toRGB()) +fun Font.drawAligned(poseStack: PoseStack, text: Component, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawAligned(poseStack, text, align, x, y, color.toRGB()) +fun Font.drawAligned(poseStack: PoseStack, text: FormattedCharSequence, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawAligned(poseStack, text, align, x, y, color.toRGB()) fun Font.drawScaledAligned(poseStack: PoseStack, text: String, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(poseStack, text, scale, align, x, y, color) fun Font.drawScaledAligned(poseStack: PoseStack, text: Component, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(poseStack, text, scale, align, x, y, color) fun Font.drawScaledAligned(poseStack: PoseStack, text: FormattedCharSequence, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(poseStack, text, scale, align, x, y, color) -fun Font.drawScaledAligned(poseStack: PoseStack, text: String, scale: Float, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(poseStack, text, scale, align, x, y, color.toInt()) -fun Font.drawScaledAligned(poseStack: PoseStack, text: Component, scale: Float, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(poseStack, text, scale, align, x, y, color.toInt()) -fun Font.drawScaledAligned(poseStack: PoseStack, text: FormattedCharSequence, scale: Float, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(poseStack, text, scale, align, x, y, color.toInt()) +fun Font.drawScaledAligned(poseStack: PoseStack, text: String, scale: Float, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(poseStack, text, scale, align, x, y, color.toRGB()) +fun Font.drawScaledAligned(poseStack: PoseStack, text: Component, scale: Float, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(poseStack, text, scale, align, x, y, color.toRGB()) +fun Font.drawScaledAligned(poseStack: PoseStack, text: FormattedCharSequence, scale: Float, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(poseStack, text, scale, align, x, y, color.toRGB()) fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, align: RenderGravity, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAlignedDuckTyped(poseStack, buffer, text, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, align: RenderGravity, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAlignedDuckTyped(poseStack, buffer, text, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, align: RenderGravity, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAlignedDuckTyped(poseStack, buffer, text, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, align: RenderGravity, x: Float, y: Float, color: RGBAColor, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAligned(poseStack, buffer, text, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, align: RenderGravity, x: Float, y: Float, color: RGBAColor, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAligned(poseStack, buffer, text, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, align: RenderGravity, x: Float, y: Float, color: RGBAColor, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAligned(poseStack, buffer, text, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) +fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, align: RenderGravity, x: Float, y: Float, color: RGBAColor, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAligned(poseStack, buffer, text, align, x, y, color.toRGB(), drawShadow, displayMode, packedLightCoords, effectColor) +fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, align: RenderGravity, x: Float, y: Float, color: RGBAColor, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAligned(poseStack, buffer, text, align, x, y, color.toRGB(), drawShadow, displayMode, packedLightCoords, effectColor) +fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, align: RenderGravity, x: Float, y: Float, color: RGBAColor, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAligned(poseStack, buffer, text, align, x, y, color.toRGB(), drawShadow, displayMode, packedLightCoords, effectColor) fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0,) = drawScaledAlignedDuckTyped(poseStack, buffer, text, scale, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0,) = drawScaledAlignedDuckTyped(poseStack, buffer, text, scale, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0,) = drawScaledAlignedDuckTyped(poseStack, buffer, text, scale, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, scale: Float, align: RenderGravity, x: Float, y: Float, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, scale: Float, align: RenderGravity, x: Float, y: Float, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, scale: Float, align: RenderGravity, x: Float, y: Float, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor) +fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, scale: Float, align: RenderGravity, x: Float, y: Float, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toRGB(), drawShadow, displayMode, packedLightCoords, effectColor) +fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, scale: Float, align: RenderGravity, x: Float, y: Float, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toRGB(), drawShadow, displayMode, packedLightCoords, effectColor) +fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, scale: Float, align: RenderGravity, x: Float, y: Float, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toRGB(), drawShadow, displayMode, packedLightCoords, effectColor) fun GuiGraphics.drawAligned(font: Font, text: String, align: RenderGravity, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(font, text, align, x, y, color) fun GuiGraphics.drawAligned(font: Font, text: Component, align: RenderGravity, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(font, text, align, x, y, color) fun GuiGraphics.drawAligned(font: Font, text: FormattedCharSequence, align: RenderGravity, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(font, text, align, x, y, color) -fun GuiGraphics.drawAligned(font: Font, text: String, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawAligned(font, text, align, x, y, color.toInt()) -fun GuiGraphics.drawAligned(font: Font, text: Component, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawAligned(font, text, align, x, y, color.toInt()) -fun GuiGraphics.drawAligned(font: Font, text: FormattedCharSequence, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawAligned(font, text, align, x, y, color.toInt()) +fun GuiGraphics.drawAligned(font: Font, text: String, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawAligned(font, text, align, x, y, color.toRGB()) +fun GuiGraphics.drawAligned(font: Font, text: Component, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawAligned(font, text, align, x, y, color.toRGB()) +fun GuiGraphics.drawAligned(font: Font, text: FormattedCharSequence, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawAligned(font, text, align, x, y, color.toRGB()) fun GuiGraphics.drawScaledAligned(font: Font, text: String, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(font, text, scale, align, x, y, color) fun GuiGraphics.drawScaledAligned(font: Font, text: Component, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(font, text, scale, align, x, y, color) fun GuiGraphics.drawScaledAligned(font: Font, text: FormattedCharSequence, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(font, text, scale, align, x, y, color) -fun GuiGraphics.drawScaledAligned(font: Font, text: String, scale: Float, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(font, text, scale, align, x, y, color.toInt()) -fun GuiGraphics.drawScaledAligned(font: Font, text: Component, scale: Float, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(font, text, scale, align, x, y, color.toInt()) -fun GuiGraphics.drawScaledAligned(font: Font, text: FormattedCharSequence, scale: Float, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(font, text, scale, align, x, y, color.toInt()) +fun GuiGraphics.drawScaledAligned(font: Font, text: String, scale: Float, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(font, text, scale, align, x, y, color.toRGB()) +fun GuiGraphics.drawScaledAligned(font: Font, text: Component, scale: Float, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(font, text, scale, align, x, y, color.toRGB()) +fun GuiGraphics.drawScaledAligned(font: Font, text: FormattedCharSequence, scale: Float, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(font, text, scale, align, x, y, color.toRGB()) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt index 935dcac75..0f3da165c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.client.render import net.minecraft.client.gui.GuiGraphics import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.core.math.RGBAColor interface IGUIRenderable { /** @@ -19,14 +20,29 @@ interface IGUIRenderable { */ val winding: UVWindingOrder get() = UVWindingOrder.NORMAL - fun render(guiGraphics: GuiGraphics, x: Float = 0f, y: Float = 0f, gravity: RenderGravity = RenderGravity.TOP_LEFT, winding: UVWindingOrder = this.winding) { - render(guiGraphics, gravity.x(x, width), gravity.y(y, height), width, height, winding) + fun render( + guiGraphics: GuiGraphics, + x: Float = 0f, + y: Float = 0f, + gravity: RenderGravity = RenderGravity.TOP_LEFT, + winding: UVWindingOrder = this.winding, + color: RGBAColor = RGBAColor.WHITE, + ) { + render(guiGraphics, gravity.x(x, width), gravity.y(y, height), width, height, winding, color) } /** * Render at specified position [x], [y] with size of [width] x [height], optionally with UV [winding], if we are rendering flat texture/sprite */ - fun render(guiGraphics: GuiGraphics, x: Float = 0f, y: Float = 0f, width: Float = this.width, height: Float = this.height, winding: UVWindingOrder = this.winding) + fun render( + guiGraphics: GuiGraphics, + x: Float = 0f, + y: Float = 0f, + width: Float = this.width, + height: Float = this.height, + winding: UVWindingOrder = this.winding, + color: RGBAColor = RGBAColor.WHITE + ) fun composeBefore(other: IGUIRenderable): IGUIRenderable { return object : IGUIRenderable { @@ -35,9 +51,9 @@ interface IGUIRenderable { override val height: Float get() = this@IGUIRenderable.height.coerceAtLeast(other.height) - override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder) { - this@IGUIRenderable.render(guiGraphics, x, y, width, height, winding) - other.render(guiGraphics, x, y, width, height, winding) + override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder, color: RGBAColor) { + this@IGUIRenderable.render(guiGraphics, x, y, width, height, winding, color) + other.render(guiGraphics, x, y, width, height, winding, color) } } } @@ -53,8 +69,8 @@ interface IGUIRenderable { override val height: Float get() = this@IGUIRenderable.height - override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder) { - this@IGUIRenderable.render(guiGraphics, x + left, y + top, width + right + left, height + bottom + top, winding) + override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder, color: RGBAColor) { + this@IGUIRenderable.render(guiGraphics, x + left, y + top, width + right + left, height + bottom + top, winding, color) } } } @@ -76,7 +92,7 @@ interface IGUIRenderable { override val height: Float get() = this@IGUIRenderable.height - override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder) { + override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder, color: RGBAColor) { var realX = x var realY = y @@ -88,7 +104,7 @@ interface IGUIRenderable { realY += (height - this.height) / 2f } - this@IGUIRenderable.render(guiGraphics, realX, realY, if (fixedWidth) this.width else width, if (fixedHeight) this.height else height, if (fixedWinding) this.winding else winding) + this@IGUIRenderable.render(guiGraphics, realX, realY, if (fixedWidth) this.width else width, if (fixedHeight) this.height else height, if (fixedWinding) this.winding else winding, color) } } } @@ -105,7 +121,7 @@ interface IGUIRenderable { } data class ItemStackIcon(private val itemStack: ItemStack, override val width: Float = 16f, override val height: Float = 16f) : IGUIRenderable { - override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder) { + override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder, color: RGBAColor) { if (x % 1f == 0f && y % 1f == 0f && width == 16f && height == 16f) { guiGraphics.renderFakeItem(itemStack, x.toInt(), y.toInt()) clearDepth(guiGraphics.pose(), x, y, width, height) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt index 867b6be9e..d561b8f4f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt @@ -35,7 +35,7 @@ fun ResourceLocation.vLine( ) = MatterySprite(this, x, y, 1f, height, textureWidth, textureHeight) @Suppress("unused") -data class MatterySprite @JvmOverloads constructor( +class MatterySprite( override val texture: ResourceLocation, val x: Float, val y: Float, @@ -65,6 +65,16 @@ data class MatterySprite @JvmOverloads constructor( override val type: SpriteType get() = SpriteType.SINGLE + fun copy( + x: Float = this.x, + y: Float = this.y, + width: Float = this.width, + height: Float = this.height, + winding: UVWindingOrder = this.winding, + ): MatterySprite { + return MatterySprite(texture, x, y, width, height, atlasWidth, atlasHeight, winding) + } + companion object { fun single(texture: ResourceLocation, width: Float, height: Float, winding: UVWindingOrder = UVWindingOrder.NORMAL): MatterySprite { return MatterySprite(texture, 0f, 0f, width, height, width, height, winding) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt index 44cd9fcbb..84c95ceea 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt @@ -9,6 +9,7 @@ import net.minecraft.client.renderer.RenderStateShard import net.minecraft.client.renderer.RenderStateShard.LineStateShard import net.minecraft.client.renderer.RenderType import net.minecraft.client.renderer.texture.TextureAtlasSprite +import net.minecraft.resources.ResourceLocation import org.joml.Matrix4f import org.lwjgl.opengl.GL11.GL_ALWAYS import org.lwjgl.opengl.GL11.GL_LESS @@ -23,10 +24,6 @@ import kotlin.math.pow import kotlin.math.roundToInt import kotlin.math.sin -private val identity = Matrix4f() - -var zLevel = 0f -var drawColor = RGBAColor(255, 255, 255, 255) var is3DContext = false /** @@ -36,24 +33,86 @@ var is3DContext = false */ var lockBlendFunc = false -@JvmName("setDrawColor\$JVM") -fun setDrawColor(color: RGBAColor) { - drawColor = color -} +private val defaultUV = UVCoords(0f, 0f, 1f, 1f) -// Regular functions -fun drawTexturedRect( +fun renderRect( matrix: Matrix4f, x: Float, y: Float, width: Float, height: Float, - u0: Float = 0f, - v0: Float = 0f, - u1: Float = 1f, - v1: Float = 1f + z: Float = 0f, + color: RGBAColor = RGBAColor.WHITE ) { - RenderSystem.setShader(GameRenderer::getPositionTexShader) + if (color.isWhite) + RenderSystem.setShader(GameRenderer::getPositionShader) + else + RenderSystem.setShader(GameRenderer::getPositionColorShader) + + RenderSystem.enableBlend() + RenderSystem.defaultBlendFunc() + + if (!is3DContext) + RenderSystem.depthFunc(GL_ALWAYS) + + val tess = tesselator + val builder = tess.builder + + if (color.isWhite) { + builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION) + + builder.vertex(matrix, x, y + height, z).endVertex() + builder.vertex(matrix, x + width, y + height, z).endVertex() + builder.vertex(matrix, x + width, y, z).endVertex() + builder.vertex(matrix, x, y, z).endVertex() + } else { + builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR) + + builder.vertex(matrix, x, y + height, z).color(color).endVertex() + builder.vertex(matrix, x + width, y + height, z).color(color).endVertex() + builder.vertex(matrix, x + width, y, z).color(color).endVertex() + builder.vertex(matrix, x, y, z).color(color).endVertex() + } + + tess.end() +} + +fun GuiGraphics.renderRect( + x: Float, + y: Float, + width: Float, + height: Float, + z: Float = 0f, + color: RGBAColor = RGBAColor.WHITE +) { + renderRect(pose().last().pose(), x, y, width, height, z, color) +} + +fun renderTexturedRect( + matrix: Matrix4f, + x: Float, + y: Float, + width: Float, + height: Float, + z: Float = 0f, + uv: IUVCoords = defaultUV, + uvWinding: UVWindingOrder = UVWindingOrder.NORMAL, + color: RGBAColor = RGBAColor.WHITE, + texture: ResourceLocation? = null +) { + val u0 = uvWinding.u0(uv) + val v0 = uvWinding.v0(uv) + val u1 = uvWinding.u1(uv) + val v1 = uvWinding.v1(uv) + + if (color.isWhite) + RenderSystem.setShader(GameRenderer::getPositionTexShader) + else + RenderSystem.setShader(GameRenderer::getPositionTexColorShader) + + if (texture != null) + RenderSystem.setShaderTexture(0, texture) + RenderSystem.enableBlend() RenderSystem.defaultBlendFunc() @@ -62,86 +121,40 @@ fun drawTexturedRect( val builder = tesselator.builder - builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX) - builder.vertex(matrix, x, y + height, zLevel).uv(u0, v1).endVertex() - builder.vertex(matrix, x + width, y + height, zLevel).uv(u1, v1).endVertex() - builder.vertex(matrix, x + width, y, zLevel).uv(u1, v0).endVertex() - builder.vertex(matrix, x, y, zLevel).uv(u0, v0).endVertex() + if (color.isWhite) { + builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX) + + builder.vertex(matrix, x, y + height, z).uv(u0, v1).endVertex() + builder.vertex(matrix, x + width, y + height, z).uv(u1, v1).endVertex() + builder.vertex(matrix, x + width, y, z).uv(u1, v0).endVertex() + builder.vertex(matrix, x, y, z).uv(u0, v0).endVertex() + } else { + builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR) + + builder.vertex(matrix, x, y + height, z).uv(u0, v1).color(color).endVertex() + builder.vertex(matrix, x + width, y + height, z).uv(u1, v1).color(color).endVertex() + builder.vertex(matrix, x + width, y, z).uv(u1, v0).color(color).endVertex() + builder.vertex(matrix, x, y, z).uv(u0, v0).color(color).endVertex() + } BufferUploader.drawWithShader(builder.end()) } -fun drawTexturedRect( - matrix: Matrix4f, +fun GuiGraphics.renderTexturedRect( x: Float, y: Float, width: Float, height: Float, - uv: IUVCoords -) = drawTexturedRect(matrix, x, y, width, height, uv.u0, uv.v0, uv.u1, uv.v1) + z: Float = 0f, + uv: IUVCoords = defaultUV, + uvWinding: UVWindingOrder = UVWindingOrder.NORMAL, + color: RGBAColor = RGBAColor.WHITE, + texture: ResourceLocation? = null +) { + renderTexturedRect(pose().last().pose(), x, y, width, height, z, uv, uvWinding, color, texture) +} -fun drawTexturedRect( - stack: PoseStack, - x: Float, - y: Float, - width: Float, - height: Float, - uv: IUVCoords -) = drawTexturedRect(stack.last().pose(), x, y, width, height, uv.u0, uv.v0, uv.u1, uv.v1) - -fun drawTexturedRect( - graphics: GuiGraphics, - x: Float, - y: Float, - width: Float, - height: Float, - uv: IUVCoords -) = drawTexturedRect(graphics.pose(), x, y, width, height, uv) - -fun drawTexturedRect( - stack: PoseStack, - x: Float, - y: Float, - width: Float, - height: Float, - u0: Float, - v0: Float, - u1: Float, - v1: Float -) = drawTexturedRect(stack.last().pose(), x, y, width, height, u0, v0, u1, v1) - -fun drawTexturedRect( - graphics: GuiGraphics, - x: Float, - y: Float, - width: Float, - height: Float, - u0: Float, - v0: Float, - u1: Float, - v1: Float -) = drawTexturedRect(graphics.pose(), x, y, width, height, u0, v0, u1, v1) - -fun drawTexturedRect( - x: Float, - y: Float, - width: Float, - height: Float, - uv: IUVCoords -) = drawTexturedRect(identity, x, y, width, height, uv.u0, uv.v0, uv.u1, uv.v1) - -fun drawTexturedRect( - x: Float, - y: Float, - width: Float, - height: Float, - u0: Float, - v0: Float, - u1: Float, - v1: Float -) = drawTexturedRect(identity, x, y, width, height, u0, v0, u1, v1) - -fun colorSphere(matrix: Matrix4f, radius: Float) { +fun renderColoredSphere(pose: PoseStack, radius: Float, color: RGBAColor = RGBAColor.WHITE) { val fragments = 32 RenderSystem.enableBlend() RenderSystem.defaultBlendFunc() @@ -166,20 +179,20 @@ fun colorSphere(matrix: Matrix4f, radius: Float) { val yPre = (sin(tiltPre) + 0.5).toFloat() * radius val yPost = (sin(tiltPost) + 0.5).toFloat() * radius - builder.vertex(matrix, xPre * cos(tiltPost).toFloat(), yPost, zPre * cos(tiltPost).toFloat()) - .color(drawColor) + builder.vertex(pose.last().pose(), xPre * cos(tiltPost).toFloat(), yPost, zPre * cos(tiltPost).toFloat()) + .color(color) .endVertex() - builder.vertex(matrix, xPost * cos(tiltPost).toFloat(), yPost, zPost * cos(tiltPost).toFloat()) - .color(drawColor) + builder.vertex(pose.last().pose(), xPost * cos(tiltPost).toFloat(), yPost, zPost * cos(tiltPost).toFloat()) + .color(color) .endVertex() - builder.vertex(matrix, xPost * cos(tiltPre).toFloat(), yPre, zPost * cos(tiltPre).toFloat()) - .color(drawColor) + builder.vertex(pose.last().pose(), xPost * cos(tiltPre).toFloat(), yPre, zPost * cos(tiltPre).toFloat()) + .color(color) .endVertex() - builder.vertex(matrix, xPre * cos(tiltPre).toFloat(), yPre, zPre * cos(tiltPre).toFloat()) - .color(drawColor) + builder.vertex(pose.last().pose(), xPre * cos(tiltPre).toFloat(), yPre, zPre * cos(tiltPre).toFloat()) + .color(color) .endVertex() } } @@ -187,200 +200,6 @@ fun colorSphere(matrix: Matrix4f, radius: Float) { BufferUploader.drawWithShader(builder.end()) } -fun colorSphere(pose: PoseStack, radius: Float) = colorSphere(pose.last().pose(), radius) - -fun drawTexturedRectAuto( - stack: PoseStack, - x: Float, - y: Float, - width: Float, - height: Float, - image_x: Float, - image_y: Float, - mapped_width: Float, - mapped_height: Float -) = drawTexturedRect( - stack, - x, - y, - width, - height, - image_x / mapped_width, - image_y / mapped_height, - (image_x + width) / mapped_width, - (image_y + height) / mapped_height -) - -fun drawTexturedRectAuto( - stack: PoseStack, - x: Float, - y: Float, - width: Float, - height: Float, - image_x: Float, - image_y: Float, - mapped_width: Float, - mapped_height: Float, - order: UVWindingOrder -) = drawTexturedRect( - stack, - x, - y, - width, - height, - order.translate( - image_x / mapped_width, - image_y / mapped_height, - (image_x + width) / mapped_width, - (image_y + height) / mapped_height - ) -) - -fun drawTexturedRectAuto( - matrix: Matrix4f, - x: Float, - y: Float, - width: Float, - height: Float, - image_x: Float, - image_y: Float, - mapped_width: Float, - mapped_height: Float -) = drawTexturedRect( - matrix, - x, - y, - width, - height, - image_x / mapped_width, - image_y / mapped_height, - (image_x + width) / mapped_width, - (image_y + height) / mapped_height -) - -fun drawTexturedRectAuto( - matrix: Matrix4f, - x: Float, - y: Float, - width: Float, - height: Float, - image_x: Float, - image_y: Float, - mapped_width: Float, - mapped_height: Float, - order: UVWindingOrder -) = drawTexturedRect( - matrix, - x, - y, - width, - height, - order.translate( - image_x / mapped_width, - image_y / mapped_height, - (image_x + width) / mapped_width, - (image_y + height) / mapped_height - ) -) - - -fun drawTexturedRectAuto( - x: Float, - y: Float, - width: Float, - height: Float, - image_x: Float, - image_y: Float, - mapped_width: Float, - mapped_height: Float -) = drawTexturedRect( - x, - y, - width, - height, - image_x / mapped_width, - image_y / mapped_height, - (image_x + width) / mapped_width, - (image_y + height) / mapped_height -) - -fun drawTexturedRectAuto( - x: Float, - y: Float, - width: Float, - height: Float, - image_x: Float, - image_y: Float, - mapped_width: Float, - mapped_height: Float, - order: UVWindingOrder -) = drawTexturedRect( - x, - y, - width, - height, - order.translate( - image_x / mapped_width, - image_y / mapped_height, - (image_x + width) / mapped_width, - (image_y + height) / mapped_height - ) -) - -fun drawRect( - matrix: Matrix4f, - x: Float, - y: Float, - width: Float, - height: Float, - color: RGBAColor = drawColor -) { - RenderSystem.enableBlend() - RenderSystem.defaultBlendFunc() - RenderSystem.setShader(GameRenderer::getPositionColorShader) - - if (!is3DContext) - RenderSystem.depthFunc(GL_ALWAYS) - - val tess = tesselator - val builder = tess.builder - - builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR) - - builder.vertex(matrix, x, y + height, zLevel).color(color).endVertex() - builder.vertex(matrix, x + width, y + height, zLevel).color(color).endVertex() - builder.vertex(matrix, x + width, y, zLevel).color(color).endVertex() - builder.vertex(matrix, x, y, zLevel).color(color).endVertex() - - tess.end() -} - -fun drawRect( - pose: PoseStack, - x: Float, - y: Float, - width: Float, - height: Float, - color: RGBAColor = drawColor -) = drawRect(pose.last().pose(), x, y, width, height, color = color) - -fun drawRect( - graphics: GuiGraphics, - x: Float, - y: Float, - width: Float, - height: Float, - color: RGBAColor = drawColor -) = drawRect(graphics.pose(), x, y, width, height, color = color) - -fun drawRect( - x: Float, - y: Float, - width: Float, - height: Float, - color: RGBAColor = drawColor -) = drawRect(identity, x, y, width, height, color = color) - fun drawLine( matrix: Matrix4f, startX: Float, @@ -388,11 +207,12 @@ fun drawLine( endX: Float, endY: Float, width: Float, - color: RGBAColor = drawColor + z: Float = 0f, + color: RGBAColor = RGBAColor.WHITE ) { + RenderSystem.setShader(GameRenderer::getPositionColorShader) RenderSystem.enableBlend() RenderSystem.defaultBlendFunc() - RenderSystem.setShader(GameRenderer::getPositionColorShader) if (!is3DContext) RenderSystem.depthFunc(GL_ALWAYS) @@ -421,54 +241,37 @@ fun drawLine( builder.vertex(matrix, startX - y0 * sin, startY + y0 * cos, - zLevel).color(color).endVertex() + z).color(color).endVertex() builder.vertex(matrix, startX - y1 * sin, startY + y1 * cos, - zLevel).color(color).endVertex() + z).color(color).endVertex() builder.vertex(matrix, startX + x2 * cos - y2 * sin, startY + x2 * sin + y2 * cos, - zLevel).color(color).endVertex() + z).color(color).endVertex() builder.vertex(matrix, startX + x3 * cos - y3 * sin, startY + x3 * sin + y3 * cos, - zLevel).color(color).endVertex() + z).color(color).endVertex() tess.end() } -fun drawLine( - pose: PoseStack, +fun GuiGraphics.drawLine( startX: Float, startY: Float, endX: Float, endY: Float, width: Float, - color: RGBAColor = drawColor -) = drawLine(pose.last().pose(), startX, startY, endX, endY, width, color = color) - -fun drawLine( - graphics: GuiGraphics, - startX: Float, - startY: Float, - endX: Float, - endY: Float, - width: Float, - color: RGBAColor = drawColor -) = drawLine(graphics.pose(), startX, startY, endX, endY, width, color = color) - -fun drawLine( - startX: Float, - startY: Float, - endX: Float, - endY: Float, - width: Float, - color: RGBAColor = drawColor -) = drawLine(identity, startX, startY, endX, endY, width, color = color) + z: Float = 0f, + color: RGBAColor = RGBAColor.WHITE +) { + drawLine(pose().last().pose(), startX, startY, endX, endY, width, z, color) +} data class ScissorRect(val x: Int, val y: Int, val width: Int, val height: Int) { fun withinBounds(x: Int, y: Int): Boolean { @@ -562,9 +365,9 @@ fun TextureAtlasSprite.render( RenderSystem.setShaderTexture(0, atlasLocation()) if (winding.isIdentity) { - drawTexturedRect(stack.last().pose(), x, y, width, height, u0, v0, u1, v1) + renderTexturedRect(stack.last().pose(), x, y, width, height, uv = UVCoords(u0, v0, u1, v1)) } else { - drawTexturedRect(stack.last().pose(), x, y, width, height, winding.translate(u0, v0, u1, v1)) + renderTexturedRect(stack.last().pose(), x, y, width, height, uv = winding.translate(u0, v0, u1, v1)) } } @@ -672,6 +475,7 @@ fun uploadArc( endDegree: Double = PI * 2.0, steps: Int = (outerRadius * (endDegree - startDegree) * 4.0).roundToInt().coerceAtLeast(12), alignAtCenter: Boolean = true, + z: Float = 0f, triangleFan: Boolean ) { require(startDegree < endDegree) { "Invalid arc degree range: $startDegree - $endDegree" } @@ -701,13 +505,13 @@ fun uploadArc( if (triangleFan) { val singleStep = (endDegree - startDegree) / steps - builder.vertex(matrix, x, y, zLevel).endVertex() + builder.vertex(matrix, x, y, z).endVertex() for (i in 0 .. steps) { val sin = sin(startDegree + i * singleStep).toFloat() val cos = cos(startDegree + i * singleStep).toFloat() - builder.vertex(matrix, x + outerRadius * sin, y + cos * outerRadius, zLevel).endVertex() + builder.vertex(matrix, x + outerRadius * sin, y + cos * outerRadius, z).endVertex() } } else { val singleStep = (endDegree - startDegree) / (steps + 1) @@ -719,10 +523,10 @@ fun uploadArc( val sin2 = sin(startDegree + (i + 1) * singleStep).toFloat() val cos2 = cos(startDegree + (i + 1) * singleStep).toFloat() - builder.vertex(matrix, x + outerRadius * sin, y + cos * outerRadius, zLevel).endVertex() - builder.vertex(matrix, x + outerRadius * sin2, y + cos2 * outerRadius, zLevel).endVertex() - builder.vertex(matrix, x + innerRadius * sin2, y + cos2 * innerRadius, zLevel).endVertex() - builder.vertex(matrix, x + innerRadius * sin, y + cos * innerRadius, zLevel).endVertex() + builder.vertex(matrix, x + outerRadius * sin, y + cos * outerRadius, z).endVertex() + builder.vertex(matrix, x + outerRadius * sin2, y + cos2 * outerRadius, z).endVertex() + builder.vertex(matrix, x + innerRadius * sin2, y + cos2 * innerRadius, z).endVertex() + builder.vertex(matrix, x + innerRadius * sin, y + cos * innerRadius, z).endVertex() } } } @@ -736,7 +540,8 @@ fun drawArc( startDegree: Double = 0.0, endDegree: Double = PI * 2.0, steps: Int = (outerRadius * (endDegree - startDegree) * 4.0).roundToInt().coerceAtLeast(12), - alignAtCenter: Boolean = true + alignAtCenter: Boolean = true, + z: Float = 0f ) { require(startDegree < endDegree) { "Invalid arc degree range: $startDegree - $endDegree" } require(steps >= 0) { "Invalid amount of arc steps: $steps" } @@ -752,12 +557,12 @@ fun drawArc( if (innerRadius == 0f) { if (steps >= 1) { builder.begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION) - uploadArc(matrix, builder, x, y, outerRadius, innerRadius, startDegree, endDegree, steps, alignAtCenter, triangleFan = true) + uploadArc(matrix, builder, x, y, outerRadius, innerRadius, startDegree, endDegree, steps, alignAtCenter, triangleFan = true, z = z) BufferUploader.drawWithShader(builder.end()) } } else { builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION) - uploadArc(matrix, builder, x, y, outerRadius, innerRadius, startDegree, endDegree, steps, alignAtCenter, triangleFan = false) + uploadArc(matrix, builder, x, y, outerRadius, innerRadius, startDegree, endDegree, steps, alignAtCenter, triangleFan = false, z = z) BufferUploader.drawWithShader(builder.end()) } } @@ -804,20 +609,3 @@ val linesIgnoreZRenderType by lazy { .createCompositeState(false) ) as RenderType } - -fun VertexConsumer.quad( - pose: PoseStack, - x: Float, - y: Float, - width: Float, - height: Float, - z: Float, - color: RGBAColor? = null, -) { - val intColor = color?.toARGB() ?: 0 - val matrix = pose.last().pose() - vertex(matrix, x, y + height, z).also { if (color != null) it.color(intColor) }.endVertex() - vertex(matrix, x + width, y + height, z).also { if (color != null) it.color(intColor) }.endVertex() - vertex(matrix, x + width, y, z).also { if (color != null) it.color(intColor) }.endVertex() - vertex(matrix, x, y, z).also { if (color != null) it.color(intColor) }.endVertex() -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/UVStuff.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/UVStuff.kt index 406e8fec9..b71b9d1c7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/UVStuff.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/UVStuff.kt @@ -1,34 +1,47 @@ package ru.dbotthepony.mc.otm.client.render -import com.google.common.collect.ImmutableList - -sealed interface IUVCoords { +interface IUVCoords { val u0: Float val v0: Float val u1: Float val v1: Float - operator fun get(index: Int): Float + + operator fun component1() = u0 + operator fun component2() = v0 + operator fun component3() = u1 + operator fun component4() = v1 + + fun getUV(index: Int): Float { + return when (index) { + 0 -> u0 + 1 -> v0 + 2 -> u1 + 3 -> v1 + else -> throw IndexOutOfBoundsException("$index") + } + } } -private val mapImmutable = ArrayList<(input: UVCoords) -> Float>() +private fun interface FlatGetter { + operator fun get(u0: Float, v0: Float, u1: Float, v1: Float): Float +} + +private fun interface RegularGetter { + operator fun get(input: IUVCoords): Float +} + +private val getters = ArrayList() .also { it.add { it.u0 } } .also { it.add { it.v0 } } .also { it.add { it.u1 } } .also { it.add { it.v1 } } .toTypedArray() -private val mapMutable = ArrayList<(input: MutableUVCoords) -> Float>() - .also { it.add { it.u0 } } - .also { it.add { it.v0 } } - .also { it.add { it.u1 } } - .also { it.add { it.v1 } } - .toTypedArray() - -private val mapSetMutable = ArrayList<(input: MutableUVCoords, value: Float) -> Unit>() - .also { it.add { input, value -> input.u0 = value } } - .also { it.add { input, value -> input.v0 = value } } - .also { it.add { input, value -> input.u1 = value } } - .also { it.add { input, value -> input.v1 = value } } +private val flatGetters = ArrayList() + .also { it.add { u0, _, _, _ -> u0 } } + .also { it.add { _, v0, _, _ -> v0 } } + .also { it.add { _, _, u1, _ -> u1 } } + .also { it.add { _, _, _, v1 -> v1 } } .toTypedArray() data class UVCoords( @@ -36,43 +49,16 @@ data class UVCoords( override val v0: Float, override val u1: Float, override val v1: Float, -) : IUVCoords { - override fun get(index: Int): Float { - return mapImmutable[index].invoke(this) - } -} +) : IUVCoords data class MutableUVCoords( override var u0: Float, override var v0: Float, override var u1: Float, override var v1: Float, -) : IUVCoords { - override fun get(index: Int): Float { - return mapMutable[index].invoke(this) - } +) : IUVCoords - operator fun set(index: Int, value: Float) { - mapSetMutable[index].invoke(this, value) - } -} - -private val pickers = ArrayList<(u0: Float, - v0: Float, - u1: Float, - v1: Float) -> Float>() - .also { it.add { u0, _, _, _ -> u0 } } - .also { it.add { _, v0, _, _ -> v0 } } - .also { it.add { _, _, u1, _ -> u1 } } - .also { it.add { _, _, _, v1 -> v1 } } - .toTypedArray() - -enum class UVWindingOrder( - val u0: Int, - val v0: Int, - val u1: Int, - val v1: Int, -) { +enum class UVWindingOrder(val u0: Int, val v0: Int, val u1: Int, val v1: Int) { NORMAL(0, 1, 2, 3), // normal operation U0_V0_U1_V1(0, 1, 2, 3), // normal operation U0_V1_U1_V0(0, 3, 2, 1), // mirror y @@ -82,10 +68,6 @@ enum class UVWindingOrder( U1_V1_U0_V0(2, 3, 0, 1), // mirror both FLIP_FLOP(2, 3, 0, 1); // mirror both - companion object { - val distinct: List = ImmutableList.of(NORMAL, FLIP, FLOP, FLIP_FLOP) - } - val isIdentity: Boolean = u0 == 0 && v0 == 1 && u1 == 2 && v1 == 3 operator fun component1() = u0 @@ -93,57 +75,55 @@ enum class UVWindingOrder( operator fun component3() = u1 operator fun component4() = v1 - val u0Picker = pickers[u0] - val v0Picker = pickers[v0] - val u1Picker = pickers[u1] - val v1Picker = pickers[v1] + private val u0FlatGetter = flatGetters[u0] + private val v0FlatGetter = flatGetters[v0] + private val u1FlatGetter = flatGetters[u1] + private val v1FlatGetter = flatGetters[v1] - private val buffer = FloatArray(4) + private val u0Getter = getters[u0] + private val v0Getter = getters[v0] + private val u1Getter = getters[u1] + private val v1Getter = getters[v1] - fun translate( - u0: Float, - v0: Float, - u1: Float, - v1: Float, - ): UVCoords { - synchronized(buffer) { - buffer[0] = u0 - buffer[1] = v0 - buffer[2] = u1 - buffer[3] = v1 + fun u0(u0: Float, v0: Float, u1: Float, v1: Float): Float = u0FlatGetter[u0, v0, u1, v1] + fun v0(u0: Float, v0: Float, u1: Float, v1: Float): Float = v0FlatGetter[u0, v0, u1, v1] + fun u1(u0: Float, v0: Float, u1: Float, v1: Float): Float = u1FlatGetter[u0, v0, u1, v1] + fun v1(u0: Float, v0: Float, u1: Float, v1: Float): Float = v1FlatGetter[u0, v0, u1, v1] - return UVCoords(buffer[this.u0], buffer[this.v0], buffer[this.u1], buffer[this.v1]) - } + fun u0(input: IUVCoords): Float = u0Getter[input] + fun v0(input: IUVCoords): Float = v0Getter[input] + fun u1(input: IUVCoords): Float = u1Getter[input] + fun v1(input: IUVCoords): Float = v1Getter[input] + + fun translate(u0: Float, v0: Float, u1: Float, v1: Float): IUVCoords { + return UVCoords( + u0FlatGetter[u0, v0, u1, v1], + v0FlatGetter[u0, v0, u1, v1], + u1FlatGetter[u0, v0, u1, v1], + v1FlatGetter[u0, v0, u1, v1] + ) } - fun translate( - input: UVCoords - ): UVCoords { - synchronized(buffer) { - buffer[0] = input.u0 - buffer[1] = input.v0 - buffer[2] = input.u1 - buffer[3] = input.v1 - - return UVCoords(buffer[this.u0], buffer[this.v0], buffer[this.u1], buffer[this.v1]) - } + fun translate(input: IUVCoords): IUVCoords { + return UVCoords( + u0Getter[input], + v0Getter[input], + u1Getter[input], + v1Getter[input], + ) } - fun translate( - input: MutableUVCoords - ): MutableUVCoords { - synchronized(buffer) { - buffer[0] = input.u0 - buffer[1] = input.v0 - buffer[2] = input.u1 - buffer[3] = input.v1 + fun translate(input: MutableUVCoords): MutableUVCoords { + val u0 = u0(input) + val v0 = v0(input) + val u1 = u1(input) + val v1 = v1(input) - input[0] = buffer[this.u0] - input[1] = buffer[this.v0] - input[2] = buffer[this.u1] - input[3] = buffer[this.v1] + input.u0 = u0 + input.v0 = v0 + input.u1 = u1 + input.v1 = v1 - return input - } + return input } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt index bc4e42e8d..cd8a147de 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt @@ -22,6 +22,7 @@ import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom +import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.core.math.rotate import ru.dbotthepony.mc.otm.core.math.rotateY @@ -91,25 +92,27 @@ abstract class BankRenderer(private val context: B val buffer = DynamicBufferSource.WORLD.getBuffer(texture.renderTypeWorld) - texture.uploadOntoPartialColor( + texture.uploadOntoPartial( stack, buffer, x = 25f - width / 2f, y = 30f, width = width, - height = heightMax * gaugeLevel(blockEntity) + height = heightMax * gaugeLevel(blockEntity), + color = RGBAColor.WHITE ) stack.rotateY(PI.toFloat()) stack.translate(-50.0, 0.0, -101.0) - texture.uploadOntoPartialColor( + texture.uploadOntoPartial( stack, buffer, x = 25f - width / 2f, y = 30f, width = width, - height = heightMax * gaugeLevel(blockEntity) + height = heightMax * gaugeLevel(blockEntity), + color = RGBAColor.WHITE ) stack.popPose() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt index a5ad2be22..efd6fcea3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt @@ -105,7 +105,6 @@ class BlackHoleRenderer(private val context: BlockEntityRendererProvider.Context i: Int, i1: Int ) { - setDrawColor(RGBAColor.BLACK) RenderSystem.setShader(GameRenderer::getPositionColorShader) RenderSystem.depthFunc(GL30.GL_LESS) @@ -116,7 +115,7 @@ class BlackHoleRenderer(private val context: BlockEntityRendererProvider.Context poseStack.pushPose() val size = tile.gravitationStrength.pow(0.5) poseStack.translate(0.5, -size / 2.0 + 0.5, 0.5) - colorSphere(poseStack, size.toFloat()) + renderColoredSphere(poseStack, size.toFloat(), color = RGBAColor.BLACK) RenderSystem.enableCull() 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 32994e002..465db9cf5 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 @@ -37,7 +37,7 @@ class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context) var y = -totalHeight / 2f for (line in lines) { - font.drawAligned(poseStack = poseStack, buffer = sorse, text = line, align = RenderGravity.TOP_CENTER, x = 0f, y = y, color = RGBAColor.YELLOW.toInt()) + font.drawAligned(poseStack = poseStack, buffer = sorse, text = line, align = RenderGravity.TOP_CENTER, x = 0f, y = y, color = RGBAColor.YELLOW.toRGB()) y += font.lineHeight + 2f } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index 58b1be9c0..cfd032691 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -65,10 +65,10 @@ open class FramePanel( TAB_BACKGROUND.render(graphics, 2f, 2f, width - 4, height - 2) } - RECTANGLE.top.renderWidth(graphics, 3f, 0f, width - 6) - RECTANGLE.left.renderHeight(graphics, 0f, 3f, (height - if (isActive) if (initial) 2 else 4 else 3)) + RECTANGLE.top.render(graphics, 3f, 0f, width = width - 6) + RECTANGLE.left.render(graphics, 0f, 3f, height = (height - if (isActive) if (initial) 2 else 4 else 3)) - RECTANGLE.right.renderHeight(graphics, width - RECTANGLE.right.width, 3f, (height - if (isActive) 4 else 3)) + RECTANGLE.right.render(graphics, width - RECTANGLE.right.width, 3f, height = (height - if (isActive) 4 else 3)) RECTANGLE.topLeft.render(graphics, 0f, 0f) RECTANGLE.topRight.render(graphics, width - RECTANGLE.topRight.width, 0f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt index b21085fd3..95e017ac9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt @@ -36,28 +36,28 @@ open class Label @JvmOverloads constructor( if (shadow) { when (align) { - RenderGravity.TOP_LEFT -> graphics.drawAligned(font, text, align, shadowX, shadowY, shadowColor.toInt()) - RenderGravity.TOP_CENTER -> graphics.drawAligned(font, text, align, shadowX + width / 2f, shadowY, shadowColor.toInt()) - RenderGravity.TOP_RIGHT -> graphics.drawAligned(font, text, align, shadowX + width, shadowY, shadowColor.toInt()) - RenderGravity.CENTER_LEFT -> graphics.drawAligned(font, text, align, shadowX, height / 2f + shadowY, shadowColor.toInt()) - RenderGravity.CENTER_CENTER -> graphics.drawAligned(font, text, align, shadowX + width / 2f, height / 2f + shadowY, shadowColor.toInt()) - RenderGravity.CENTER_RIGHT -> graphics.drawAligned(font, text, align, shadowX + width, height / 2f + shadowY, shadowColor.toInt()) - RenderGravity.BOTTOM_LEFT -> graphics.drawAligned(font, text, align, shadowX, height + shadowY, shadowColor.toInt()) - RenderGravity.BOTTOM_CENTER -> graphics.drawAligned(font, text, align, shadowX + width / 2f, height + shadowY, shadowColor.toInt()) - RenderGravity.BOTTOM_RIGHT -> graphics.drawAligned(font, text, align, shadowX + width, height + shadowY, shadowColor.toInt()) + RenderGravity.TOP_LEFT -> graphics.drawAligned(font, text, align, shadowX, shadowY, shadowColor.toRGB()) + RenderGravity.TOP_CENTER -> graphics.drawAligned(font, text, align, shadowX + width / 2f, shadowY, shadowColor.toRGB()) + RenderGravity.TOP_RIGHT -> graphics.drawAligned(font, text, align, shadowX + width, shadowY, shadowColor.toRGB()) + RenderGravity.CENTER_LEFT -> graphics.drawAligned(font, text, align, shadowX, height / 2f + shadowY, shadowColor.toRGB()) + RenderGravity.CENTER_CENTER -> graphics.drawAligned(font, text, align, shadowX + width / 2f, height / 2f + shadowY, shadowColor.toRGB()) + RenderGravity.CENTER_RIGHT -> graphics.drawAligned(font, text, align, shadowX + width, height / 2f + shadowY, shadowColor.toRGB()) + RenderGravity.BOTTOM_LEFT -> graphics.drawAligned(font, text, align, shadowX, height + shadowY, shadowColor.toRGB()) + RenderGravity.BOTTOM_CENTER -> graphics.drawAligned(font, text, align, shadowX + width / 2f, height + shadowY, shadowColor.toRGB()) + RenderGravity.BOTTOM_RIGHT -> graphics.drawAligned(font, text, align, shadowX + width, height + shadowY, shadowColor.toRGB()) } } when (align) { - RenderGravity.TOP_LEFT -> font.drawAligned(graphics.pose(), text, align, 0f, 0f, color.toInt()) - RenderGravity.TOP_CENTER -> font.drawAligned(graphics.pose(), text, align, width / 2f, 0f, color.toInt()) - RenderGravity.TOP_RIGHT -> font.drawAligned(graphics.pose(), text, align, width - (if (shadow) shadowX else 0f), 0f, color.toInt()) - RenderGravity.CENTER_LEFT -> font.drawAligned(graphics.pose(), text, align, 0f, height / 2f, color.toInt()) - RenderGravity.CENTER_CENTER -> font.drawAligned(graphics.pose(), text, align, width / 2f, height / 2f, color.toInt()) - RenderGravity.CENTER_RIGHT -> font.drawAligned(graphics.pose(), text, align, width - (if (shadow) shadowX else 0f), height / 2f, color.toInt()) - RenderGravity.BOTTOM_LEFT -> font.drawAligned(graphics.pose(), text, align, 0f, height, color.toInt()) - RenderGravity.BOTTOM_CENTER -> font.drawAligned(graphics.pose(), text, align, width / 2f, height, color.toInt()) - RenderGravity.BOTTOM_RIGHT -> font.drawAligned(graphics.pose(), text, align, width - (if (shadow) shadowX else 0f), height, color.toInt()) + RenderGravity.TOP_LEFT -> font.drawAligned(graphics.pose(), text, align, 0f, 0f, color.toRGB()) + RenderGravity.TOP_CENTER -> font.drawAligned(graphics.pose(), text, align, width / 2f, 0f, color.toRGB()) + RenderGravity.TOP_RIGHT -> font.drawAligned(graphics.pose(), text, align, width - (if (shadow) shadowX else 0f), 0f, color.toRGB()) + RenderGravity.CENTER_LEFT -> font.drawAligned(graphics.pose(), text, align, 0f, height / 2f, color.toRGB()) + RenderGravity.CENTER_CENTER -> font.drawAligned(graphics.pose(), text, align, width / 2f, height / 2f, color.toRGB()) + RenderGravity.CENTER_RIGHT -> font.drawAligned(graphics.pose(), text, align, width - (if (shadow) shadowX else 0f), height / 2f, color.toRGB()) + RenderGravity.BOTTOM_LEFT -> font.drawAligned(graphics.pose(), text, align, 0f, height, color.toRGB()) + RenderGravity.BOTTOM_CENTER -> font.drawAligned(graphics.pose(), text, align, width / 2f, height, color.toRGB()) + RenderGravity.BOTTOM_RIGHT -> font.drawAligned(graphics.pose(), text, align, width - (if (shadow) shadowX else 0f), height, color.toRGB()) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt index 94e07f8d9..c885d244e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt @@ -53,7 +53,7 @@ open class ButtonPanel( override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { renderStretchableBackground(graphics, mouseX, mouseY, partialTick) - graphics.drawAligned(font, label, RenderGravity.CENTER_CENTER, width / 2f, height / 2f, textColor.toInt()) + graphics.drawAligned(font, label, RenderGravity.CENTER_CENTER, width / 2f, height / 2f, textColor.toRGB()) } override fun sizeToContents() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt index c4372fe51..fb9d10ba8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt @@ -21,7 +21,7 @@ import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.drawAligned -import ru.dbotthepony.mc.otm.client.render.drawRect +import ru.dbotthepony.mc.otm.client.render.renderRect import ru.dbotthepony.mc.otm.client.render.tesselator import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel @@ -1073,7 +1073,7 @@ open class TextInputPanel( override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (!backgroundColor.isFullyTransparent) - drawRect(graphics, 0f, 0f, width, height, backgroundColor) + graphics.renderRect(0f, 0f, width, height, color = backgroundColor) var topPadding = dockPadding.top diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt index 61866d64f..2b6bb7c4a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt @@ -38,8 +38,7 @@ abstract class AbstractSlotPanel> @JvmOverloads constru } if (isHovered) { - drawColor = SLOT_HIGHLIGHT - drawRect(graphics, 1f, 1f, width - 1, height - 1) + graphics.renderRect(1f, 1f, width - 1, height - 1, color = SLOT_HIGHLIGHT) } } 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 509a530d6..d2402e13b 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 @@ -11,8 +11,7 @@ import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.Widgets18 -import ru.dbotthepony.mc.otm.client.render.drawRect -import ru.dbotthepony.mc.otm.client.render.setDrawColor +import ru.dbotthepony.mc.otm.client.render.renderRect import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.ISlotPanel @@ -92,8 +91,7 @@ open class SlotPanel, out T : Slot> @JvmOverloads const RenderSystem.setShader(GameRenderer::getPositionTexShader) if (dragHit) { - setDrawColor(SLOT_HIGHLIGHT_DRAG) - drawRect(graphics, 1f, 1f, width - 1, height - 1) + graphics.renderRect(1f, 1f, width - 1, height - 1, color = SLOT_HIGHLIGHT_DRAG) } if (itemstack.isEmpty) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt index efdaea426..7c9ce2e35 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.client.screen.panels.slot import com.mojang.blaze3d.platform.InputConstants -import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.ChatFormatting import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component @@ -13,9 +12,7 @@ import net.minecraftforge.client.extensions.common.IClientItemExtensions import ru.dbotthepony.mc.otm.client.isCtrlDown import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.playGuiClickSound -import ru.dbotthepony.mc.otm.client.render.MatterySprite -import ru.dbotthepony.mc.otm.client.render.drawColor -import ru.dbotthepony.mc.otm.client.render.drawRect +import ru.dbotthepony.mc.otm.client.render.renderRect import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.GetterSetter @@ -49,12 +46,10 @@ abstract class UserFilteredSlotPanel, out T : Slot>( screen.renderItemStack(graphics, itemStack, null) clearDepth(graphics) - drawColor = SLOT_FILTER_COLOR + graphics.renderRect(0f, 0f, width, height, color = SLOT_FILTER_COLOR) } else { - drawColor = SLOT_BLOCK_COLOR + graphics.renderRect(0f, 0f, width, height, color = SLOT_BLOCK_COLOR) } - - drawRect(graphics, 0f, 0f, width, height) } } 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 7d51e8a86..edd721913 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 @@ -21,9 +21,8 @@ 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.drawColor import ru.dbotthepony.mc.otm.client.render.drawLine -import ru.dbotthepony.mc.otm.client.render.drawRect +import ru.dbotthepony.mc.otm.client.render.renderRect 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 @@ -293,26 +292,24 @@ private class AndroidResearchButton( val isBlockedByHovered = hovered != null && node.type in hovered.type.allBlocking if (isBlockedByHovered) { - AndroidStationScreen.CAN_NOT_BE_RESEARCHED.setSystemColor() - - drawRect(graphics, 0f, 0f, width, height) + graphics.renderRect(0f, 0f, width, height, color = AndroidStationScreen.CAN_NOT_BE_RESEARCHED) } - if (node.isResearched) { - AndroidStationScreen.RESEARCHED.setSystemColor() + val nodeColor = if (node.isResearched) { + AndroidStationScreen.RESEARCHED } else if (node.isAnyBlockerResearchedIndirect) { - AndroidStationScreen.ALREADY_BLOCKED.setSystemColor() + AndroidStationScreen.ALREADY_BLOCKED } else if (node.canResearch) { - AndroidStationScreen.CAN_BE_RESEARCHED.setSystemColor() + AndroidStationScreen.CAN_BE_RESEARCHED } else { - AndroidStationScreen.CAN_NOT_BE_RESEARCHED.setSystemColor() + AndroidStationScreen.CAN_NOT_BE_RESEARCHED } val icon = node.type.resolvedSkinIcon val itemIcon = node.type.itemIcon if (icon != null) { - icon.render(graphics, 0f, 0f, width, height) + icon.render(graphics, 0f, 0f, width, height, color = nodeColor) } else if (itemIcon != null) { val itemstack = ItemStack(itemIcon, 1) @@ -324,17 +321,13 @@ private class AndroidResearchButton( clearDepth(graphics) } else { - drawRect(graphics, 0f, 0f, width, height) + graphics.renderRect(0f, 0f, width, height, color = nodeColor) } if (isBlockedByHovered) { - RGBAColor.RED.setSystemColor() - - Widgets18.CROSS.render(graphics) + Widgets18.CROSS.render(graphics, color = RGBAColor.RED) } else if (node.isAnyBlockerResearched) { - RGBAColor.RED.setSystemColor() - - Widgets18.FORWARD_SLASH.render(graphics) + Widgets18.FORWARD_SLASH.render(graphics, color = RGBAColor.RED) } val text = node.type.iconText @@ -343,29 +336,24 @@ private class AndroidResearchButton( graphics.drawString(font, text.visualOrderText, width - font.width(text), height - font.lineHeight, -0x1, true) } - drawColor = RGBAColor.WHITE - RGBAColor.WHITE.setShaderColor() - for (line in lines) { val (pos1, pos2) = line val (x1, y1) = pos1 val (x2, y2) = pos2 - drawLine(graphics, x1, y1, x2, y2, 0.5f) + graphics.drawLine(x1, y1, x2, y2, 0.5f, color = RGBAColor.WHITE) } hovered ?: return val pathLines = highlightLines[hovered.type] if (pathLines != null) { - drawColor = RGBAColor.LIGHT_GREEN - for (line in pathLines) { val (pos1, pos2) = line val (x1, y1) = pos1 val (x2, y2) = pos2 - drawLine(graphics, x1, y1, x2, y2, 0.5f) + graphics.drawLine(x1, y1, x2, y2, 0.5f, color = RGBAColor.LIGHT_GREEN) } } @@ -377,8 +365,6 @@ private class AndroidResearchButton( val blockLines = highlightLines[blocker] if (blockLines != null) { - drawColor = RGBAColor.RED - for (line in blockLines) { if (drawn.containsKey(line)) { continue @@ -390,7 +376,7 @@ private class AndroidResearchButton( val (x1, y1) = pos1 val (x2, y2) = pos2 - drawLine(graphics, x1, y1, x2, y2, 0.5f) + graphics.drawLine(x1, y1, x2, y2, 0.5f, color = RGBAColor.RED) } } } @@ -515,8 +501,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I private var firstTick = false override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { - drawColor = RGBAColor.BLACK - drawRect(graphics, 0f, 0f, width, height) + graphics.renderRect(0f, 0f, width, height, color = RGBAColor.BLACK) } override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/RGBAColor.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/RGBAColor.kt index 3b61517be..01eb2ba9c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/RGBAColor.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/RGBAColor.kt @@ -16,66 +16,51 @@ data class RGBAColor(val red: Float, val green: Float, val blue: Float, val alph (((color and 0xFF)) / 255f) ) - fun toInt(): Int { - val r = (this.red * 255).roundToInt() - val g = (this.green * 255).roundToInt() - val b = (this.blue * 255).roundToInt() - return (r shl 16) or (g shl 8) or b + val isWhite = red >= 1f && green >= 1f && blue >= 1f && alpha >= 1f + + val redInt = (red.coerceIn(0f, 1f) * 255f).roundToInt() + val greenInt = (green.coerceIn(0f, 1f) * 255f).roundToInt() + val blueInt = (blue.coerceIn(0f, 1f) * 255f).roundToInt() + val alphaInt = (alpha.coerceIn(0f, 1f) * 255f).roundToInt() + + fun toRGB(): Int { + return (redInt shl 16) or (greenInt shl 8) or blueInt } fun toRGBA(): Int { - val r = (this.red * 255).roundToInt() - val g = (this.green * 255).roundToInt() - val b = (this.blue * 255).roundToInt() - val a = (this.alpha * 255).roundToInt() - return (r shl 24) or (g shl 16) or (b shl 8) or a + return (redInt shl 24) or (greenInt shl 16) or (blueInt shl 8) or alphaInt } fun toARGB(): Int { - val r = (this.red * 255).roundToInt() - val g = (this.green * 255).roundToInt() - val b = (this.blue * 255).roundToInt() - val a = (this.alpha * 255).roundToInt() - return (a shl 24) or (r shl 16) or (g shl 8) or b + return (alphaInt shl 24) or (redInt shl 16) or (greenInt shl 8) or blueInt } fun toBGRA(): Int { - val r = (this.red * 255).roundToInt() - val g = (this.green * 255).roundToInt() - val b = (this.blue * 255).roundToInt() - val a = (this.alpha * 255).roundToInt() - return (r shl 24) or (g shl 16) or (r shl 8) or a + return (blueInt shl 24) or (greenInt shl 16) or (redInt shl 8) or alphaInt } fun toIntInv(): Int { - val r = (this.red * 255).roundToInt() - val g = (this.green * 255).roundToInt() - val b = (this.blue * 255).roundToInt() - return (b shl 16) or (g shl 8) or r + return (blueInt shl 16) or (greenInt shl 8) or redInt } - fun setSystemColor() { - setShaderColor() - setDrawColor() - } - - fun setShaderColor() { - RenderSystem.setShaderColor(red, green, blue, alpha) - } - - fun setDrawColor() { - ru.dbotthepony.mc.otm.client.render.setDrawColor(this) - } - - fun linearInterpolation(t: Float, other: RGBAColor): RGBAColor { + fun linearInterpolation(t: Float, other: RGBAColor, interpolateAlpha: Boolean = true): RGBAColor { return RGBAColor( linearInterpolation(t, red, other.red), linearInterpolation(t, green, other.green), linearInterpolation(t, blue, other.blue), - linearInterpolation(t, alpha, other.alpha), + if (interpolateAlpha) linearInterpolation(t, alpha, other.alpha) else alpha, ) } + operator fun times(other: RGBAColor): RGBAColor { + if (isWhite) + return other + else if (other.isWhite) + return this + + return RGBAColor(red * other.red, green * other.green, blue * other.blue, alpha * other.alpha) + } + val isFullyTransparent get() = alpha <= 0f companion object { @@ -109,6 +94,9 @@ data class RGBAColor(val red: Float, val green: Float, val blue: Float, val alph @JvmField val LOW_PATTERNS = RGBAColor(44, 104, 57) @JvmField val FULL_PATTERNS = RGBAColor(65, 255, 87) + @JvmField val HALF_TRANSPARENT = RGBAColor(1f, 1f, 1f, 0.5f) + @JvmField val REDDISH = RGBAColor(1f, 0.4f, 0.4f) + fun inv(color: Int): RGBAColor { val r = (color and -0x1000000 ushr 24) / 255f val g = (color and 0xFF0000 ushr 16) / 255f diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt index 19c2c5f02..1824364c8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt @@ -25,8 +25,7 @@ import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.client.font import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.drawAligned -import ru.dbotthepony.mc.otm.client.render.drawRect -import ru.dbotthepony.mc.otm.client.render.setDrawColor +import ru.dbotthepony.mc.otm.client.render.renderRect import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.math.Angle import ru.dbotthepony.mc.otm.core.math.RGBAColor @@ -459,26 +458,23 @@ abstract class AbstractWeaponItem(val tables: KClass, pr pose.rotateY(PI.toFloat()) pose.scale(0.01f, 0.01f, 0.01f) - setDrawColor(holoHudBackground) - drawRect(pose, -2f, -2f, 72f, 34f) + renderRect(pose.last().pose(), -2f, -2f, 72f, 34f, color = holoHudBackground) stack.matteryEnergy?.let { pose.pushPose() pose.translate(0.0, 0.0, -1.0) pose.scale(0.7f, 0.7f, 0.7f) val text = it.batteryLevel.formatPower() - font.drawAligned(pose, text, RenderGravity.TOP_LEFT, 2f, 2f, RGBAColor.WHITE.toInt()) + font.drawAligned(pose, text, RenderGravity.TOP_LEFT, 2f, 2f, RGBAColor.WHITE.toRGB()) pose.popPose() } pose.translate(60.0, 0.0, 0.0) - setDrawColor(heatBackground) - drawRect(pose, -1f, -1f, 9f, 32f) + renderRect(pose.last().pose(), -1f, -1f, 9f, 32f, color = heatBackground) val heat = item.heatProgress(stack, event.partialTick.toDouble()).toFloat() - setDrawColor(linearInterpolation(heat, initialHeatColor, finalHeatColor)) - drawRect(pose, 0f, 30f * (1f - heat), 7f, 30f * heat) + renderRect(pose.last().pose(), 0f, 30f * (1f - heat), 7f, 30f * heat, color = linearInterpolation(heat, initialHeatColor, finalHeatColor)) } pose.popPose() From 30fdd2fd28640716255896015bc065596afbde3b Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Tue, 11 Jul 2023 18:57:15 +0300 Subject: [PATCH 0747/1199] procedural battery energy bar --- .../mc/otm/item/ProceduralBatteryItem.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralBatteryItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralBatteryItem.kt index 42c68d400..19445751b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralBatteryItem.kt @@ -15,6 +15,8 @@ import net.minecraftforge.common.capabilities.ICapabilityProvider import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.energy.ItemEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.energy.batteryLevel +import ru.dbotthepony.mc.otm.capability.energy.getBarColor +import ru.dbotthepony.mc.otm.capability.energy.getBarWidth import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.Decimal @@ -47,6 +49,18 @@ class ProceduralBatteryItem : Item(Properties().stacksTo(1)) { get() = maxBatteryLevel } + override fun isBarVisible(p_150899_: ItemStack): Boolean { + return p_150899_.matteryEnergy != null + } + + override fun getBarWidth(p_150900_: ItemStack): Int { + return p_150900_.matteryEnergy?.getBarWidth() ?: super.getBarWidth(p_150900_) + } + + override fun getBarColor(p_150901_: ItemStack): Int { + return p_150901_.matteryEnergy?.getBarColor() ?: super.getBarColor(p_150901_) + } + override fun appendHoverText(p_41421_: ItemStack, p_41422_: Level?, p_41423_: MutableList, p_41424_: TooltipFlag) { super.appendHoverText(p_41421_, p_41422_, p_41423_, p_41424_) From 203f4e56c977b7918714bd2581786c97cfd33335 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Tue, 11 Jul 2023 19:02:32 +0300 Subject: [PATCH 0748/1199] =?UTF-8?q?YuRaNnNzZZ=20=E2=80=94=20=D0=92=D1=87?= =?UTF-8?q?=D0=B5=D1=80=D0=B0,=20=D0=B2=2020:54=20=D0=BC=D0=BD=D0=B5=20?= =?UTF-8?q?=D0=BA=D0=B0=D0=B6=D0=B5=D1=82=D1=81=D1=8F=20=D0=BD=D0=B0=D0=B4?= =?UTF-8?q?=D0=BE=20=D0=B7=D0=B0=D0=B4=D0=B0=D1=82=D1=8C=20=D0=BC=D0=B0?= =?UTF-8?q?=D0=BA=D1=81=D0=B8=D0=BC=D0=B0=D0=BB=D1=8C=D0=BD=D1=8B=D0=B9=20?= =?UTF-8?q?=D1=80=D0=B0=D0=B7=D0=BC=D0=B5=D1=80=20=D1=81=D1=82=D0=B0=D0=BA?= =?UTF-8?q?=D0=B0=201=20=D0=B2=20=D0=B1=D0=B0=D0=BD=D0=BA=D0=B0=D1=85=20:W?= =?UTF-8?q?iseTree:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt | 2 ++ .../mc/otm/block/entity/matter/PatternStorageBlockEntity.kt | 4 +--- .../mc/otm/block/entity/tech/BatteryBankBlockEntity.kt | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt index ba365952a..a45fd8958 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt @@ -126,6 +126,8 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) capacitorStatus[slot].boolean = new.getCapability(MatteryCapability.MATTER).isPresent gaugeLevel = (storedMatter / maxStoredMatter).toFloat() } + + override fun getMaxStackSize(): Int = 1 }.also(::addDroppableContainer) val itemConfig = ConfigurableItemHandler(inputOutput = container.handler(object : HandlerFilter { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt index 59230312f..1e4e0a821 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt @@ -54,9 +54,7 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : super.setChanged(slot, new, old) } - override fun getMaxStackSize(): Int { - return 1 - } + override fun getMaxStackSize(): Int = 1 }.also(::addDroppableContainer) private fun updateBlockstate() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index f610bbe08..8e429535c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -35,6 +35,8 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte batteryStatus[slot].boolean = new.getCapability(ForgeCapabilities.ENERGY).isPresent gaugeLevel = batteryLevel.percentage(maxBatteryLevel) } + + override fun getMaxStackSize(): Int = 1 }.also(::addDroppableContainer) val batteryStatus = immutableList(CAPACITY) { From 6105ca797beb3f39c03eb36510bbd1f4e0c79fd8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 12 Jul 2023 14:41:40 +0700 Subject: [PATCH 0749/1199] If it ever happens, avoid dividing by zero --- .../mc/otm/capability/energy/IMatteryEnergyStorage.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt index 98ad13ab6..ffd4e221d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt @@ -362,9 +362,15 @@ fun IMatteryEnergyStorage.transferChecked(other: IMatteryEnergyStorage, amount: } fun IMatteryEnergyStorage.getBarWidth(): Int { - return ((batteryLevel / maxBatteryLevel).toFloat().coerceAtLeast(0f).coerceAtMost(1f) * 13f).roundToInt() + if (!maxBatteryLevel.isPositive) + return 0 + + return ((batteryLevel / maxBatteryLevel).toFloat().coerceIn(0f, 1f) * 13f).roundToInt() } fun IMatteryEnergyStorage.getBarColor(): Int { + if (!maxBatteryLevel.isPositive) + return 0 + return RGBAColor.LOW_POWER.linearInterpolation((batteryLevel / maxBatteryLevel).toFloat(), RGBAColor.FULL_POWER).toRGB() } From 027d6ef65f2be6e5731d6a5908ebcfa649510539 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Fri, 14 Jul 2023 22:25:48 +0300 Subject: [PATCH 0750/1199] exopack curios inventory button --- .../mc/otm/datagen/lang/English.kt | 1 + .../mc/otm/datagen/lang/Russian.kt | 1 + .../mc/otm/client/render/Widgets18.kt | 1 + .../client/screen/ExoPackInventoryScreen.kt | 10 +++++++++- .../mc/otm/compat/curios/CuriosCompat.kt | 9 +++++++++ .../textures/gui/widgets/misc18.png | Bin 815 -> 826 bytes .../textures/gui/widgets/misc18.xcf | Bin 3113 -> 3924 bytes 7 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 08a7414d8..99d467195 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -138,6 +138,7 @@ private fun misc(provider: MatteryLanguageProvider) { gui("exopack", "Exopack Inventory") gui("exopack.go_back", "Open vanilla inventory") gui("exopack.go_in", "Open Exopack inventory") + gui("exopack.go_curios", "Open Curios inventory") gui("exopack.toggle_visibility", "Toggle Exopack visibility") gui("exopack.probe1", "This little device feels unnatural to touch, it is almost certainly resilient to any possible attempt to break it open.") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index faecb219c..6b33fac1c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -146,6 +146,7 @@ private fun misc(provider: MatteryLanguageProvider) { gui("exopack", "Инвентарь Экзопака") gui("exopack.go_back", "Открыть обычный инвентарь") gui("exopack.go_in", "Открыть инвентарь экзопака") + gui("exopack.go_curios", "Открыть инвентарь Curios") gui("exopack.toggle_visibility", "Переключить отображение Экзопака") gui("exopack.probe1", "Данное маленькое устройство необычно на ощупь, а так же неприступно для любых попыток вскрыть.") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt index 8a54ddce1..93e07d358 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt @@ -51,6 +51,7 @@ object Widgets18 { val CROSS = miscGrid.next() val FORWARD_SLASH = miscGrid.next() val RETURN_ARROW_LEFT = miscGrid.next() + val CURIOS_INVENTORY = miscGrid.next() private val slotBgGrid = WidgetLocation.SLOT_BACKGROUNDS.grid(4, 4) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt index 802182da8..9dc4547ee 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt @@ -23,6 +23,8 @@ import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.client.setMousePos import ru.dbotthepony.mc.otm.client.shouldOpenVanillaInventory +import ru.dbotthepony.mc.otm.compat.curios.isCuriosLoaded +import ru.dbotthepony.mc.otm.compat.curios.openCuriosScreen import ru.dbotthepony.mc.otm.core.math.integerDivisionDown import ru.dbotthepony.mc.otm.menu.ExoPackInventoryMenu import ru.dbotthepony.mc.otm.network.ExoPackMenuOpen @@ -235,7 +237,7 @@ class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen frame.y += movePixels moveMousePosScaled(y = movePixels) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt index e99c1f020..50802c1be 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt @@ -4,7 +4,10 @@ import com.google.common.collect.Streams import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack +import net.minecraftforge.api.distmarker.Dist import net.minecraftforge.fml.ModList +import net.minecraftforge.fml.loading.FMLEnvironment +import net.minecraftforge.network.PacketDistributor import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.container.awareStream @@ -16,6 +19,8 @@ import top.theillusivec4.curios.api.CuriosApi import top.theillusivec4.curios.api.event.SlotModifiersUpdatedEvent import top.theillusivec4.curios.common.inventory.CosmeticCurioSlot import top.theillusivec4.curios.common.inventory.CurioSlot +import top.theillusivec4.curios.common.network.NetworkHandler +import top.theillusivec4.curios.common.network.client.CPacketOpenCurios import java.util.stream.Stream import kotlin.collections.ArrayList @@ -28,6 +33,10 @@ fun onCuriosSlotModifiersUpdated(event: SlotModifiersUpdatedEvent) { event.entity.matteryPlayer?.recreateExoPackMenu() } +fun openCuriosScreen(carriedStack: ItemStack = ItemStack.EMPTY) { + if (FMLEnvironment.dist.isClient) NetworkHandler.INSTANCE.send(PacketDistributor.SERVER.noArg(), CPacketOpenCurios(carriedStack)) +} + private fun Player.getCuriosSlotsImpl(): List> { val handler = getCapability(MatteryCapability.CURIOS_INVENTORY).orNull() ?: return listOf() diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/misc18.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/misc18.png index 9a54260fbf9ee9815e6e266c7c3e632276a8b038..e8e91ae609122f954b900a2c7067d82e53a4673a 100644 GIT binary patch delta 778 zcmV+l1NHo`2D%22J%2zP#a~mUB2_^(9i@szuu$3xtvZ-o`UOoIk`xz5 z!L{Jv$70pN#aUMeS3wZ`0C9D3Qgo3L|Cbb6#CUMrk9YSTckck9S!Jr(GY6=eWuy~v zF_&Kz1Fr~R5W|QeDlt<}W)`#X9AEeF@%1jkv%Js!IR=!1$$tQ!NIb`M!y?`wp53%` z&ilk6R+bdvbK)t3E=c^yb=l=N&LxKho*6Q->3QN1u~_P2xrE-V!-}d=zL0ZS z;k?CJt=3ulp8SQug0_<3I?Zt;u!JO15Fw+E3aYRWp;aTrM4I;F9{w@MpCXq`t_m1A z7Epr<$?=2#!GG^=&0=)gO$x?=-WS{cm;eI1K&xTf-^aGyIsyF8z?IhV*P1}=lk`SM z3m*YP+rY(jN0aw}%N=0!NtX=Ck^D4;Vi9;hqi@OsBey{Rn%i4@AEysMmbzNL0S*p< z$r5F+d%U}^ySIPOwEO!3C(?57(?dC*00006VoOIv0Dk}g0002_L%V+f000SaNLh0L z01FcU01FcV0GgZ_00007bV*G`2j>S4696=-zQZK|00B2iL_t(|+U?rW4#FS|h2cSb z|5wHvO$Y(nLSaMy@6yc*XISRqbzz_MG5fyJIxD<*}4fs-3U>tdTma zM9*URWPda(AU`L6ueHwhfXb_8xr*A!wZd5)lC@UU6tNbSCMSinDx{IGY_KF;>ovVe z)`HN6GZN_R%Biko%|N8rdxLHb%sNr8kfgDe$D`(I&n$JRzpUB-S~a9^NO?SJ2Y>f= z>lu>kHa~mQCN=3hLUIczWM;!D>zopj*oa4)WPk5`kA~}6r`M#XcCnd(KOv-Y^@-cO z$9<4xz)xLC%XTsAKu_#Rk9gd%`||++hw46OuH8s!9&!A%Zved?nSZ~P=0W5LhZSUd z+yMe2AeuBy`d-aHFGx3v00000000000000000000fHS=TbW5+S+^SdJ00000NkvXX It^-0~g4MKWaR2}S delta 766 zcmVY4yF-8NJ4 zn3&D2iaoCgU<6@EkYr{ViS%LyzV&ra-Bfo`p5@>7XZ5Rji+=$Dk$8?7rcJy-JhN#V zocD<%tR$<%=fvYCU6A;Z>x##3oQp0CJTqcuQuD+SVzJo4N(Zx&sS!^TORA<*zL51; z<-EmNtJGNQp8SQOyuOm=I;~;Ev4jMY5TT%kGAghUrCle*LW<5~KK>!spCp$;t}+-o z7Epx-+4Y0}!GG`BT7{`eFDVoQx?ddUV-)Dw1)6oo`95}><_Qpd2CnqBzuEw1KS{5* zHR%WlZvz+CZB5w&E_Z;zCqp)6R|?V+3I*W(jJ_!c4BP^JYu?;i=Qw=;GBm5@8{ps& z7%Nity3f0NJLmRqPiuZZxTA8z1ijBF00006VoOIv0Du1g{{a7>y{D4^000SaNLh0L z01FcU01FcV0GgZ_00007bV*G`2j>AF1UnGagScY=00AsXL_t(|+U?lM5`!QRMNuFB z|IeL`3oB`crXkVPJyk9oAo!Fa%FK=xBpv^#tgOsV*>bb>d@~?(w$^nYHyjCP=G-IS zAYJ;|$bZdUuep|u*7J*i)Y(smR10T!NYT1lU97dA3aJ;)u8_>k6r4@uwZCRncaw0fGi=v&k4VwnN=+e?66K)P(HaCdZiT1aJJif8E3_;l&$AI*pX>Iy$*^r_zoe>bg}7KEZWc~j7eo+a8@U@)H-L?6W68>QsRRd w0000000000000000000000000007+C3xodq3oa&mCIA2c07*qoM6N<$g8r9Zm;e9( diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/misc18.xcf b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/misc18.xcf index 3d5a11d54b733ece614ee6b950f5ea8662e481c8..f42db9b994b3fc280f69543f7e8326997086cf2f 100644 GIT binary patch delta 850 zcmZ1}aYb%|9-AZs1A_|VM16fmj*0QF6&rwDAYciE(Ci)%n#&VH^XP3(X5?XHY@J-d zB(1OzA_yjhfFuY50n<(h%`o{QXYu3&&L@*6FtcoCW2s@3odJ~rQ6fML(!m1aFfg!g znLM9Wobk-&?W{`}CnvMtVf3Bsz#*-W36TbqNS1IkLdB6RDcbD9#l^@N19Y5}6n6!7 zjocF^H*+sD1WLk8V+69LF6_9l_rj(NTQBUr*mPmT#fFPL3dyBKnfb*aQ<#8wazEn) zRuD&MvN@}@AP0zv0K6U`OY3=45JGVCfkM1BFmZ1N#{d5rnE(G}`2U}s;qQNj|IA>L zgW(@Y_#eZ64kS@z6}Z?)I_puiA}sP|psBTRTk9Esexkp%a9eA^!AdXR!mWkc3IOAf BDO&&l delta 178 zcmca2w^Cw)9;3)a6MaVZi7Broiy6Rx#RWpMTSI6rm(2x?JdBJLlM^|FCr@DFV4MPE zi7_#)*}ReI9us5tt}W?c(m9+`+vJ0PfKzwg3PC From f2e4c80d31caad3da5c6aa6ca4b7dc257d055db0 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sat, 15 Jul 2023 07:48:59 +0300 Subject: [PATCH 0751/1199] jade compat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DBot — Сегодня, в 6:21 Не думай. --- build.gradle.kts | 2 +- gradle.properties | 2 +- .../mc/otm/datagen/lang/English.kt | 17 ++++ .../datagen/lang/MatteryLanguageProvider.kt | 4 + .../mc/otm/datagen/lang/Russian.kt | 16 ++++ .../mc/otm/compat/jade/JadeCompatData.kt | 22 +++++ .../mc/otm/compat/jade/JadePlugin.kt | 38 +++++++++ .../jade/providers/MatterBottlerProvider.kt | 67 +++++++++++++++ .../providers/MatterReconstructorProvider.kt | 62 ++++++++++++++ .../jade/providers/MatterStorageProvider.kt | 63 ++++++++++++++ .../jade/providers/MatteryEnergyProvider.kt | 61 ++++++++++++++ .../jade/providers/MatteryWorkerProvider.kt | 84 +++++++++++++++++++ 12 files changed, 436 insertions(+), 2 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/JadeCompatData.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/JadePlugin.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterBottlerProvider.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterReconstructorProvider.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterStorageProvider.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatteryEnergyProvider.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatteryWorkerProvider.kt diff --git a/build.gradle.kts b/build.gradle.kts index b08081996..de8377dc3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -193,7 +193,7 @@ dependencies { compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge-api:${jei_version}")) //runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}")) - //runtimeOnly(fg.deobf("curse.maven:jade-324717:${jade_id}")) + implementation(fg.deobf("curse.maven:jade-324717:${jade_id}")) //runtimeOnly(fg.deobf("curse.maven:configured-457570:${configured_id}")) compileOnly(fg.deobf("curse.maven:resourceful-lib-570073:${resourceful_lib_id}")) diff --git a/gradle.properties b/gradle.properties index 36f394177..6029c59d9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -30,7 +30,7 @@ ad_astra_id=4594155 botarium_id=4594094 resourceful_lib_id=4598948 resourceful_config_id=4576455 -jade_id=4573193 +jade_id=4614153 configured_id=4462894 kotlin_for_forge_version=3.1.0 diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 99d467195..e74d098b3 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -777,6 +777,21 @@ private fun gui(provider: MatteryLanguageProvider) { } } +private fun jade(provider: MatteryLanguageProvider) { + with(provider.english) { + jadeloc("matter_storage", "Matter Storage") + jadeloc("mattery_energy", "Energy Storage") + jadeloc("mattery_worker", "Machine Job Progress") + jadeloc("matter_bottler", "Matter Bottler Mode") + jadeloc("matter_reconstructor", "Matter Reconstructor Progress") + + jade("mode", "Mode: %s") + + jade("matter_bottler.mode.fill", "Filling") + jade("matter_bottler.mode.drain", "Emptying") + } +} + fun AddEnglishLanguage(provider: MatteryLanguageProvider) { decoratives(provider) sounds(provider) @@ -791,6 +806,8 @@ fun AddEnglishLanguage(provider: MatteryLanguageProvider) { research(provider) gui(provider) + jade(provider) + with(provider.english) { add("itemGroup.otm", "Overdrive That Matters") add("itemGroup.otm_decorative", "Overdrive That Matters Decorative") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/MatteryLanguageProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/MatteryLanguageProvider.kt index bd7aa1ec9..9da3b9f2a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/MatteryLanguageProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/MatteryLanguageProvider.kt @@ -21,6 +21,7 @@ import ru.dbotthepony.mc.otm.android.AndroidFeatureType import ru.dbotthepony.mc.otm.android.AndroidResearch import ru.dbotthepony.mc.otm.android.AndroidResearchType import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.datagen.DataGen import ru.dbotthepony.mc.otm.registry.objects.ColoredDecorativeBlock private fun researchString(key: AndroidResearchType): String { @@ -104,6 +105,9 @@ class MatteryLanguageProvider(private val gen: DataGenerator) { fun sound(key: String, value: String) = slave.add("otm.sound.$key", value) fun sound(key: SoundEvent, value: String) = slave.add("otm.sound.${key.location.path}", value) + fun jade(key: String, value: String) = slave.add("otm.jade.$key", value) + fun jadeloc(key: String, value: String) = slave.add("config.jade.plugin_${DataGen.MOD_ID}.$key", value) + inner class Prepended(path: String) { val path = "$path." constructor(vararg path: String) : this(path.joinToString(".")) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 6b33fac1c..f2bd9a0e4 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -778,6 +778,21 @@ private fun gui(provider: MatteryLanguageProvider) { } } +private fun jade(provider: MatteryLanguageProvider) { + with(provider.russian) { + jadeloc("matter_storage", "Хранилище материи") + jadeloc("mattery_energy", "Хранилище энергии") + jadeloc("mattery_worker", "Прогресс работы механизма") + jadeloc("matter_bottler", "Режим бутилировщика материи") + jadeloc("matter_reconstructor", "Прогресс материального реконструктора") + + jade("mode", "Режим: %s") + + jade("matter_bottler.mode.fill", "Заполнение") + jade("matter_bottler.mode.drain", "Опустошение") + } +} + fun AddRussianLanguage(provider: MatteryLanguageProvider) { decoratives(provider) blocks(provider) @@ -789,4 +804,5 @@ fun AddRussianLanguage(provider: MatteryLanguageProvider) { research(provider) death(provider) androidFeatures(provider) + jade(provider) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/JadeCompatData.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/JadeCompatData.kt new file mode 100644 index 000000000..2423d7ffb --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/JadeCompatData.kt @@ -0,0 +1,22 @@ +package ru.dbotthepony.mc.otm.compat.jade + +import net.minecraft.resources.ResourceLocation +import ru.dbotthepony.mc.otm.OverdriveThatMatters.loc + +object JadeUids { + val MATTERY_ENERGY: ResourceLocation = loc("mattery_energy") + val MATTER_STORAGE: ResourceLocation = loc("matter_storage") + val MATTERY_WORKER: ResourceLocation = loc("mattery_worker") + + val MATTER_BOTTLER: ResourceLocation = loc("matter_bottler") + val MATTER_RECONSTRUCTOR: ResourceLocation = loc("matter_reconstructor") +} + +object JadeTagKeys { + val MATTERY_ENERGY_DATA = "otmJadeMatteryEnergyData" + val MATTER_STORAGE_DATA = "otmJadeMatterStorageData" + val MATTERY_WORKER_DATA = "otmJadeMatteryWorkerData" + + val MATTER_BOTTLER_DATA = "otmJadeMatterBottlerData" + val MATTER_RECONSTRUCTOR_DATA = "otmJadeMatterReconstructorData" +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/JadePlugin.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/JadePlugin.kt new file mode 100644 index 000000000..d5ca7cba5 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/JadePlugin.kt @@ -0,0 +1,38 @@ +package ru.dbotthepony.mc.otm.compat.jade + +import net.minecraft.world.level.block.Block +import net.minecraft.world.level.block.entity.BlockEntity +import ru.dbotthepony.mc.otm.block.MatteryBlock +import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity +import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity +import ru.dbotthepony.mc.otm.block.entity.matter.MatterReconstructorBlockEntity +import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity +import ru.dbotthepony.mc.otm.block.entity.matter.MatterScannerBlockEntity +import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock +import ru.dbotthepony.mc.otm.block.matter.MatterReconstructorBlock +import ru.dbotthepony.mc.otm.block.matter.MatterReplicatorBlock +import ru.dbotthepony.mc.otm.block.matter.MatterScannerBlock +import ru.dbotthepony.mc.otm.compat.jade.providers.* +import snownee.jade.api.IWailaClientRegistration +import snownee.jade.api.IWailaCommonRegistration +import snownee.jade.api.IWailaPlugin +import snownee.jade.api.WailaPlugin + +@WailaPlugin +class JadePlugin : IWailaPlugin { + override fun register(reg: IWailaCommonRegistration) { + reg.registerBlockDataProvider(MatterStorageProvider, BlockEntity::class.java) + reg.registerBlockDataProvider(MatteryEnergyProvider, BlockEntity::class.java) + reg.registerBlockDataProvider(MatteryWorkerProvider, MatteryWorkerBlockEntity::class.java) + reg.registerBlockDataProvider(MatterBottlerProvider, MatterBottlerBlockEntity::class.java) + reg.registerBlockDataProvider(MatterReconstructorProvider, MatterReconstructorBlockEntity::class.java) + } + + override fun registerClient(reg: IWailaClientRegistration) { + reg.registerBlockComponent(MatteryEnergyProvider, Block::class.java) + reg.registerBlockComponent(MatterStorageProvider, Block::class.java) + reg.registerBlockComponent(MatteryWorkerProvider, MatteryBlock::class.java) + reg.registerBlockComponent(MatterBottlerProvider, MatterBottlerBlock::class.java) + reg.registerBlockComponent(MatterReconstructorProvider, MatterReconstructorBlock::class.java) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterBottlerProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterBottlerProvider.kt new file mode 100644 index 000000000..9ac8d29bf --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterBottlerProvider.kt @@ -0,0 +1,67 @@ +package ru.dbotthepony.mc.otm.compat.jade.providers + +import net.minecraft.nbt.CompoundTag +import net.minecraft.resources.ResourceLocation +import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity +import ru.dbotthepony.mc.otm.compat.jade.JadeTagKeys +import ru.dbotthepony.mc.otm.compat.jade.JadeUids +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.math.RGBAColor +import snownee.jade.api.BlockAccessor +import snownee.jade.api.IBlockComponentProvider +import snownee.jade.api.IServerDataProvider +import snownee.jade.api.ITooltip +import snownee.jade.api.config.IPluginConfig +import snownee.jade.api.ui.BoxStyle + +object MatterBottlerProvider : IBlockComponentProvider, IServerDataProvider { + override fun getUid(): ResourceLocation = JadeUids.MATTER_BOTTLER + + override fun appendServerData(data: CompoundTag, accessor: BlockAccessor) { + if (accessor.blockEntity is MatterBottlerBlockEntity) { + val bottler = accessor.blockEntity as MatterBottlerBlockEntity + + val bottlerData = CompoundTag() + bottlerData.putBoolean("isBottling", bottler.isBottling) + bottlerData.putBoolean("isIdling", accessor.blockState.getValue(WorkerState.SEMI_WORKER_STATE) !== WorkerState.WORKING) + bottlerData.putFloat("workProgress", bottler.getWorkProgress()) + data.put(JadeTagKeys.MATTER_BOTTLER_DATA, bottlerData) + } + } + + override fun appendTooltip(tooltip: ITooltip, accessor: BlockAccessor, config: IPluginConfig) { + val data = accessor.serverData + + if (!data.contains(JadeTagKeys.MATTER_BOTTLER_DATA)) return + val bottlerData = data.getCompound(JadeTagKeys.MATTER_BOTTLER_DATA) + + val elementHelper = tooltip.elementHelper + tooltip.add( + elementHelper.text( + TranslatableComponent( + "otm.jade.mode", + if (bottlerData.getBoolean("isBottling")) + TranslatableComponent("otm.jade.matter_bottler.mode.fill") + else + TranslatableComponent("otm.jade.matter_bottler.mode.drain") + ) + ) + ) + + if (!data.getBoolean("isIdling")) { + val workProgress = data.getFloat("workProgress") + val style = elementHelper.progressStyle().color(RGBAColor.WHITE.toARGB()) + + tooltip.add( + elementHelper.progress( + workProgress, + null, + style, + BoxStyle.DEFAULT, + true + ) + ) + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterReconstructorProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterReconstructorProvider.kt new file mode 100644 index 000000000..bbe6cece3 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterReconstructorProvider.kt @@ -0,0 +1,62 @@ +package ru.dbotthepony.mc.otm.compat.jade.providers + +import net.minecraft.nbt.CompoundTag +import net.minecraft.resources.ResourceLocation +import ru.dbotthepony.mc.otm.block.entity.matter.MatterReconstructorBlockEntity +import ru.dbotthepony.mc.otm.compat.jade.JadeTagKeys +import ru.dbotthepony.mc.otm.compat.jade.JadeUids +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.math.RGBAColor +import snownee.jade.api.BlockAccessor +import snownee.jade.api.IBlockComponentProvider +import snownee.jade.api.IServerDataProvider +import snownee.jade.api.ITooltip +import snownee.jade.api.config.IPluginConfig +import snownee.jade.api.ui.BoxStyle + +object MatterReconstructorProvider : IBlockComponentProvider, IServerDataProvider { + override fun getUid(): ResourceLocation = JadeUids.MATTER_RECONSTRUCTOR + + override fun appendServerData(data: CompoundTag, accessor: BlockAccessor) { + if (accessor.blockEntity is MatterReconstructorBlockEntity) { + val reconstructor = accessor.blockEntity as MatterReconstructorBlockEntity + + val item = reconstructor.repairContainer.get(0) + + if (!item.isEmpty && item.isDamageableItem && item.maxDamage != 0) { + val reconstructorData = CompoundTag() + + reconstructorData.putInt("damage", item.maxDamage - item.damageValue) + reconstructorData.putInt("maxDamage", item.maxDamage) + + data.put(JadeTagKeys.MATTER_RECONSTRUCTOR_DATA, reconstructorData) + } + } + } + + override fun appendTooltip(tooltip: ITooltip, accessor: BlockAccessor, config: IPluginConfig) { + val data = accessor.serverData + + if (!data.contains(JadeTagKeys.MATTER_RECONSTRUCTOR_DATA)) return + val reconstructorData = data.getCompound(JadeTagKeys.MATTER_RECONSTRUCTOR_DATA) + + val damage = reconstructorData.getInt("damage") + val maxDamage = reconstructorData.getInt("maxDamage") + + val ratio = damage.toFloat() / maxDamage.toFloat() + + tooltip.add( + tooltip.elementHelper.progress( + ratio, + TranslatableComponent( + "item.durability", + damage, + maxDamage + ), + tooltip.elementHelper.progressStyle().color(RGBAColor.DARK_GREEN.toARGB()).textColor(RGBAColor.WHITE.toARGB()), + BoxStyle.DEFAULT, + true + ) + ) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterStorageProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterStorageProvider.kt new file mode 100644 index 000000000..43620216a --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterStorageProvider.kt @@ -0,0 +1,63 @@ +package ru.dbotthepony.mc.otm.compat.jade.providers + +import net.minecraft.nbt.CompoundTag +import net.minecraft.resources.ResourceLocation +import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.compat.jade.JadeTagKeys +import ru.dbotthepony.mc.otm.compat.jade.JadeUids +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.ifPresentK +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.RGBAColor +import ru.dbotthepony.mc.otm.core.math.getDecimal +import ru.dbotthepony.mc.otm.core.math.putDecimal +import ru.dbotthepony.mc.otm.core.util.formatMatter +import snownee.jade.api.BlockAccessor +import snownee.jade.api.IBlockComponentProvider +import snownee.jade.api.IServerDataProvider +import snownee.jade.api.ITooltip +import snownee.jade.api.config.IPluginConfig +import snownee.jade.api.ui.BoxStyle + +object MatterStorageProvider : IBlockComponentProvider, IServerDataProvider { + override fun getUid(): ResourceLocation = JadeUids.MATTER_STORAGE + + override fun appendServerData(data: CompoundTag, accessor: BlockAccessor) { + accessor.blockEntity?.getCapability(MatteryCapability.MATTER)?.ifPresentK { + val matterData = CompoundTag() + + matterData.putDecimal("storedMatter", it.storedMatter) + matterData.putDecimal("maxStoredMatter", it.maxStoredMatter) + + data.put(JadeTagKeys.MATTER_STORAGE_DATA, matterData) + } + } + + override fun appendTooltip(tooltip: ITooltip, accessor: BlockAccessor, config: IPluginConfig) { + val data = accessor.serverData + if (!data.contains(JadeTagKeys.MATTER_STORAGE_DATA)) return + + val matterData = data.getCompound(JadeTagKeys.MATTER_STORAGE_DATA) + val storedMatter = matterData.getDecimal("storedMatter") + val maxStoredMatter = matterData.getDecimal("maxStoredMatter") + + val ratio = if (maxStoredMatter.isZero) 0f else (storedMatter / maxStoredMatter).coerceIn(Decimal.ZERO, Decimal.ONE).toFloat() + val style = tooltip.elementHelper.progressStyle() + .color(RGBAColor.LOW_MATTER.linearInterpolation(ratio, RGBAColor.FULL_MATTER).toARGB()) + .textColor(RGBAColor.WHITE.toARGB()) + + tooltip.add( + tooltip.elementHelper.progress( + ratio, + TranslatableComponent( + "otm.gui.level", + storedMatter.formatMatter(), + maxStoredMatter.formatMatter() + ), + style, + BoxStyle.DEFAULT, + true + ) + ) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatteryEnergyProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatteryEnergyProvider.kt new file mode 100644 index 000000000..56e6189ae --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatteryEnergyProvider.kt @@ -0,0 +1,61 @@ +package ru.dbotthepony.mc.otm.compat.jade.providers + +import net.minecraft.nbt.CompoundTag +import net.minecraft.resources.ResourceLocation +import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.compat.jade.JadeTagKeys +import ru.dbotthepony.mc.otm.compat.jade.JadeUids +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.ifPresentK +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.RGBAColor +import ru.dbotthepony.mc.otm.core.math.getDecimal +import ru.dbotthepony.mc.otm.core.math.putDecimal +import ru.dbotthepony.mc.otm.core.util.formatPower +import snownee.jade.api.* +import snownee.jade.api.config.IPluginConfig +import snownee.jade.api.ui.BoxStyle + +object MatteryEnergyProvider : IBlockComponentProvider, IServerDataProvider { + override fun getUid(): ResourceLocation = JadeUids.MATTERY_ENERGY + + override fun appendServerData(data: CompoundTag, accessor: BlockAccessor) { + accessor.blockEntity?.getCapability(MatteryCapability.ENERGY)?.ifPresentK { + val energyData = CompoundTag() + + energyData.putDecimal("batteryLevel", it.batteryLevel) + energyData.putDecimal("maxBatteryLevel", it.maxBatteryLevel) + + data.put(JadeTagKeys.MATTERY_ENERGY_DATA, energyData) + } + } + + override fun appendTooltip(tooltip: ITooltip, accessor: BlockAccessor, config: IPluginConfig) { + val data = accessor.serverData + + if (!data.contains(JadeTagKeys.MATTERY_ENERGY_DATA)) return + val energyData = data.getCompound(JadeTagKeys.MATTERY_ENERGY_DATA) + + val batteryLevel = energyData.getDecimal("batteryLevel") + val maxBatteryLevel = energyData.getDecimal("maxBatteryLevel") + + val ratio = if (maxBatteryLevel.isZero) 0f else (batteryLevel / maxBatteryLevel).coerceIn(Decimal.ZERO, Decimal.ONE).toFloat() + val style = tooltip.elementHelper.progressStyle() + .color(RGBAColor.LOW_POWER.linearInterpolation(ratio, RGBAColor.FULL_POWER).toARGB()) + .textColor(RGBAColor.WHITE.toARGB()) + + tooltip.add( + tooltip.elementHelper.progress( + ratio, + TranslatableComponent( + "otm.gui.level", + batteryLevel.formatPower(), + maxBatteryLevel.formatPower() + ), + style, + BoxStyle.DEFAULT, + true + ) + ) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatteryWorkerProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatteryWorkerProvider.kt new file mode 100644 index 000000000..a0b62cda3 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatteryWorkerProvider.kt @@ -0,0 +1,84 @@ +package ru.dbotthepony.mc.otm.compat.jade.providers + +import net.minecraft.nbt.CompoundTag +import net.minecraft.nbt.ListTag +import net.minecraft.resources.ResourceLocation +import ru.dbotthepony.mc.otm.block.entity.MachineItemJob +import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity +import ru.dbotthepony.mc.otm.compat.jade.JadeTagKeys +import ru.dbotthepony.mc.otm.compat.jade.JadeUids +import ru.dbotthepony.mc.otm.core.math.RGBAColor +import ru.dbotthepony.mc.otm.core.nbt.getCompoundList +import ru.dbotthepony.mc.otm.core.nbt.getItemStack +import ru.dbotthepony.mc.otm.core.nbt.set +import snownee.jade.api.BlockAccessor +import snownee.jade.api.IBlockComponentProvider +import snownee.jade.api.IServerDataProvider +import snownee.jade.api.ITooltip +import snownee.jade.api.config.IPluginConfig +import snownee.jade.api.ui.BoxStyle + +object MatteryWorkerProvider : IBlockComponentProvider, IServerDataProvider { + override fun getUid(): ResourceLocation = JadeUids.MATTERY_WORKER + + override fun appendServerData(data: CompoundTag, accessor: BlockAccessor) { + if (accessor.blockEntity is MatteryWorkerBlockEntity<*>) { + val worker = accessor.blockEntity as MatteryWorkerBlockEntity<*> + + val workerData = CompoundTag() + + workerData["jobs"] = ListTag().also { + for (job in worker.jobEventLoops) { + val jobData = CompoundTag() + jobData.putFloat("workProgress", job.workProgress) + jobData.putBoolean("isIdling", job.isIdling) + jobData.putBoolean("isUnableToProcess", job.isUnableToProcess) + + if (job.currentJob is MachineItemJob) { + val currentJob = job.currentJob as MachineItemJob + jobData.put("itemStack", currentJob.itemStack.serializeNBT()) + } + + it.add(jobData) + } + } + + data.put(JadeTagKeys.MATTERY_WORKER_DATA, workerData) + } + } + + override fun appendTooltip(tooltip: ITooltip, accessor: BlockAccessor, config: IPluginConfig) { + val data = accessor.serverData + + if (!data.contains(JadeTagKeys.MATTERY_WORKER_DATA)) return + val workerData = data.getCompound(JadeTagKeys.MATTERY_WORKER_DATA) + + val elementHelper = tooltip.elementHelper + val style = elementHelper.progressStyle().color(RGBAColor.WHITE.toARGB()) + val styleError = elementHelper.progressStyle().color(RGBAColor.REDDISH.toARGB()) + + for (job in workerData.getCompoundList("jobs")) { + val progress = job.getFloat("workProgress") + val isIdling = job.getBoolean("isIdling") + val isUnableToProcess = job.getBoolean("isUnableToProcess") + val itemStack = job.getItemStack("itemStack") + + if (!isIdling) { + if (!itemStack.isEmpty) { + tooltip.add(elementHelper.smallItem(itemStack)) + tooltip.append(elementHelper.text(itemStack.hoverName)) + } + + tooltip.add( + elementHelper.progress( + progress, + null, + if (isUnableToProcess) styleError else style, + BoxStyle.DEFAULT, + true + ) + ) + } + } + } +} From f5a9e98c6fdd807586c2f66c6c0a8b93b1ee0937 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 15 Jul 2023 19:35:11 +0700 Subject: [PATCH 0752/1199] Add codec to savetables --- .../mc/otm/core/util/Savetables.kt | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt index ce92d4f66..1948ff68f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.core.util +import com.mojang.serialization.Codec import net.minecraft.nbt.ByteTag import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.DoubleTag @@ -7,6 +8,7 @@ import net.minecraft.nbt.FloatTag import net.minecraft.nbt.IntTag import net.minecraft.nbt.ListTag import net.minecraft.nbt.LongTag +import net.minecraft.nbt.NbtOps import net.minecraft.nbt.NumericTag import net.minecraft.nbt.StringTag import net.minecraft.nbt.Tag @@ -17,12 +19,14 @@ import ru.dbotthepony.mc.otm.core.asGetterSetter import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.data.getOrNull import java.util.function.Supplier import kotlin.reflect.KMutableProperty0 import kotlin.reflect.KProperty0 /** * Utility class to manage serialization and deserialization of properties + * of mutable class */ class Savetables : INBTSerializable { private val entries = ArrayList>() @@ -175,6 +179,26 @@ class Savetables : INBTSerializable { .withDeserializer { map.invoke(it.asString) } } + fun codecNullable(prop: GetterSetter, codec: Codec, name: String): Stateless { + return Stateless(prop, name, Tag::class.java) + .withSerializer { prop.get()?.let { codec.encode(it, NbtOps.INSTANCE, NbtOps.INSTANCE.empty()).getOrThrow(false) { throw IllegalStateException("Failed to write NBT data for $name: $it") } } } + .withDeserializer { codec.decode(NbtOps.INSTANCE, it).getOrThrow(false) { throw IllegalStateException("Failed to read NBT data for $name: $it") }.first } + } + + fun codecNullable(prop: KMutableProperty0, codec: Codec, name: String = prop.name): Stateless { + return codecNullable(prop.asGetterSetter(), codec, name) + } + + fun codec(prop: GetterSetter, codec: Codec, name: String): Stateless { + return Stateless(prop, name, Tag::class.java) + .withSerializer { codec.encode(prop.get(), NbtOps.INSTANCE, NbtOps.INSTANCE.empty()).getOrThrow(false) { throw IllegalStateException("Failed to write NBT data for $name: $it") } } + .withDeserializer { codec.decode(NbtOps.INSTANCE, it).getOrThrow(false) { throw IllegalStateException("Failed to read NBT data for $name: $it") }.first } + } + + fun codec(prop: KMutableProperty0, codec: Codec, name: String = prop.name): Stateless { + return codec(prop.asGetterSetter(), codec, name) + } + fun vector(prop: GetterSetter, name: String, default: Vector = Vector.ZERO): Stateless { return Stateless(prop, name, ListTag::class.java) .withSerializer { ListTag().also { l -> From 57b2b64ff9de5f297d89c182856ee9e0cc849472 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 15 Jul 2023 19:35:38 +0700 Subject: [PATCH 0753/1199] Add custom position/tex/color shader without fragment discarding --- .../mc/otm/mixin/MixinGameRenderer.java | 10 +++++++++ .../mc/otm/client/render/RenderHelper.kt | 13 ++++++++++- .../shaders/core/position_tex_color.fsh | 14 ++++++++++++ .../shaders/core/position_tex_color.json | 22 +++++++++++++++++++ .../shaders/core/position_tex_color.vsh | 18 +++++++++++++++ 5 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/shaders/core/position_tex_color.fsh create mode 100644 src/main/resources/assets/overdrive_that_matters/shaders/core/position_tex_color.json create mode 100644 src/main/resources/assets/overdrive_that_matters/shaders/core/position_tex_color.vsh diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinGameRenderer.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinGameRenderer.java index 02c823a2d..53c0c3d30 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinGameRenderer.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinGameRenderer.java @@ -1,11 +1,13 @@ package ru.dbotthepony.mc.otm.mixin; import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.server.packs.resources.ResourceProvider; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import ru.dbotthepony.mc.otm.client.render.GlitchRenderer; +import ru.dbotthepony.mc.otm.client.render.RenderHelperKt; @Mixin(GameRenderer.class) public class MixinGameRenderer { @@ -19,4 +21,12 @@ public class MixinGameRenderer { private void render(float p_109094_, long p_109095_, boolean p_109096_, CallbackInfo ci) { GlitchRenderer.render(); } + + @Inject( + method = "reloadShaders(Lnet/minecraft/server/packs/resources/ResourceProvider;)V", + at = @At("HEAD") + ) + private void reloadShaders(ResourceProvider p_250719_, CallbackInfo ci) { + RenderHelperKt.reloadShaders(p_250719_); + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt index 84c95ceea..7421ec99f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt @@ -8,11 +8,14 @@ import net.minecraft.client.renderer.GameRenderer import net.minecraft.client.renderer.RenderStateShard import net.minecraft.client.renderer.RenderStateShard.LineStateShard import net.minecraft.client.renderer.RenderType +import net.minecraft.client.renderer.ShaderInstance import net.minecraft.client.renderer.texture.TextureAtlasSprite import net.minecraft.resources.ResourceLocation +import net.minecraft.server.packs.resources.ResourceProvider import org.joml.Matrix4f import org.lwjgl.opengl.GL11.GL_ALWAYS import org.lwjgl.opengl.GL11.GL_LESS +import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.math.RGBAColor import java.util.* @@ -23,6 +26,7 @@ import kotlin.math.cos import kotlin.math.pow import kotlin.math.roundToInt import kotlin.math.sin +import kotlin.properties.Delegates var is3DContext = false @@ -35,6 +39,13 @@ var lockBlendFunc = false private val defaultUV = UVCoords(0f, 0f, 1f, 1f) +var customTexColorShader: ShaderInstance by Delegates.notNull() + private set + +fun reloadShaders(provider: ResourceProvider) { + customTexColorShader = ShaderInstance(provider, ResourceLocation(OverdriveThatMatters.MOD_ID, "position_tex_color"), DefaultVertexFormat.POSITION_TEX_COLOR) +} + fun renderRect( matrix: Matrix4f, x: Float, @@ -108,7 +119,7 @@ fun renderTexturedRect( if (color.isWhite) RenderSystem.setShader(GameRenderer::getPositionTexShader) else - RenderSystem.setShader(GameRenderer::getPositionTexColorShader) + RenderSystem.setShader { customTexColorShader } if (texture != null) RenderSystem.setShaderTexture(0, texture) diff --git a/src/main/resources/assets/overdrive_that_matters/shaders/core/position_tex_color.fsh b/src/main/resources/assets/overdrive_that_matters/shaders/core/position_tex_color.fsh new file mode 100644 index 000000000..0ed69a40d --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/shaders/core/position_tex_color.fsh @@ -0,0 +1,14 @@ +#version 150 + +uniform sampler2D Sampler0; + +uniform vec4 ColorModulator; + +in vec2 texCoord0; +in vec4 vertexColor; + +out vec4 fragColor; + +void main() { + fragColor = texture(Sampler0, texCoord0) * vertexColor * ColorModulator; +} diff --git a/src/main/resources/assets/overdrive_that_matters/shaders/core/position_tex_color.json b/src/main/resources/assets/overdrive_that_matters/shaders/core/position_tex_color.json new file mode 100644 index 000000000..f127dbe01 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/shaders/core/position_tex_color.json @@ -0,0 +1,22 @@ +{ + "blend": { + "func": "add", + "srcrgb": "srcalpha", + "dstrgb": "1-srcalpha" + }, + "vertex": "overdrive_that_matters:position_tex_color", + "fragment": "overdrive_that_matters:position_tex_color", + "attributes": [ + "Position", + "UV0", + "Color" + ], + "samplers": [ + { "name": "Sampler0" } + ], + "uniforms": [ + { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } + ] +} diff --git a/src/main/resources/assets/overdrive_that_matters/shaders/core/position_tex_color.vsh b/src/main/resources/assets/overdrive_that_matters/shaders/core/position_tex_color.vsh new file mode 100644 index 000000000..1ed8e4068 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/shaders/core/position_tex_color.vsh @@ -0,0 +1,18 @@ +#version 150 + +in vec3 Position; +in vec2 UV0; +in vec4 Color; + +uniform mat4 ModelViewMat; +uniform mat4 ProjMat; + +out vec2 texCoord0; +out vec4 vertexColor; + +void main() { + gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0); + + texCoord0 = UV0; + vertexColor = Color; +} From c71a1ab0d6a297ee7e5fb99b9f79de7dae47dba9 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 15 Jul 2023 19:37:56 +0700 Subject: [PATCH 0754/1199] Open FramePanel's `title` getter/setter to public --- .../dbotthepony/mc/otm/client/screen/panels/FramePanel.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index cfd032691..83955fe6d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -20,7 +20,7 @@ open class FramePanel( y: Float, width: Float, height: Float, - protected var title: Component? + var title: Component? = null, ) : EditablePanel(screen, parent, x, y, width, height), NarratableEntry { constructor(screen: S, width: Float, height: Float, title: Component?) : this(screen, null, 0f, 0f, width, height, title) @@ -345,7 +345,7 @@ open class FramePanel( y: Float, width: Float, height: Float, - title: Component? + title: Component? = null, ) = FramePanel(screen, parent, x, y, width + PADDING * 2, height + PADDING_TOP + PADDING, title) fun padded( @@ -353,14 +353,14 @@ open class FramePanel( parent: EditablePanel<*>?, width: Float, height: Float, - title: Component? + title: Component? = null, ) = FramePanel(screen, parent, 0f, 0f, width + PADDING * 2, height + PADDING_TOP + PADDING, title) fun padded( screen: S, width: Float, height: Float, - title: Component? + title: Component? = null, ) = FramePanel(screen, null, 0f, 0f, width + PADDING * 2, height + PADDING_TOP + PADDING, title) const val PADDING = 8f From d855234808f92a64589cc266871c8bcad131995e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 15 Jul 2023 19:38:53 +0700 Subject: [PATCH 0755/1199] Add panel children sorting --- .../client/screen/panels/FlexGridPanel.java | 20 ++++---- .../otm/client/screen/panels/EditablePanel.kt | 49 +++++++++++++++++-- 2 files changed, 55 insertions(+), 14 deletions(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/client/screen/panels/FlexGridPanel.java b/src/main/java/ru/dbotthepony/mc/otm/client/screen/panels/FlexGridPanel.java index a2a960fe3..9c5b42457 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/client/screen/panels/FlexGridPanel.java +++ b/src/main/java/ru/dbotthepony/mc/otm/client/screen/panels/FlexGridPanel.java @@ -65,15 +65,15 @@ public class FlexGridPanel extends EditablePanel { float min_width = getWidth(); // "финальная" ширина этой панели - float this_width = getWidth() - getDockPadding().left() - getDockPadding().right(); + float this_width = getWidth() - getDockPadding().getLeft() - getDockPadding().getRight(); if (this_width <= 0) { return; } for (var child : children) { - min_width = Math.min(min_width, child.getWidth() + child.getDockMargin().left() + child.getDockMargin().right()); - desired_width += child.getWidth() + child.getDockMargin().left() + child.getDockMargin().right(); + min_width = Math.min(min_width, child.getWidth() + child.getDockMargin().getLeft() + child.getDockMargin().getRight()); + desired_width += child.getWidth() + child.getDockMargin().getLeft() + child.getDockMargin().getRight(); } int rows = 1; @@ -108,7 +108,7 @@ public class FlexGridPanel extends EditablePanel { for (int i = index; i < children.size(); i++) { var child = children.get(i); - var gain_width = child.getWidth() + child.getDockMargin().left() + child.getDockMargin().right(); + var gain_width = child.getWidth() + child.getDockMargin().getLeft() + child.getDockMargin().getRight(); index = i; @@ -121,7 +121,7 @@ public class FlexGridPanel extends EditablePanel { break; } - max_height = Math.max(max_height, child.getHeight() + child.getDockMargin().top() + child.getDockMargin().bottom()); + max_height = Math.max(max_height, child.getHeight() + child.getDockMargin().getTop() + child.getDockMargin().getBottom()); total_width += gain_width; } @@ -142,7 +142,7 @@ public class FlexGridPanel extends EditablePanel { this_width /= 2; // определение точки по середине по высоте - float h_middle = (getHeight() - getDockPadding().bottom() - getDockPadding().top() - total_height) / 2; + float h_middle = (getHeight() - getDockPadding().getBottom() - getDockPadding().getTop() - total_height) / 2; // OverdriveThatMatters.LOGGER.info("Общая высота {}, рядов {}, середина {}", total_height, rows, h_middle); @@ -154,7 +154,7 @@ public class FlexGridPanel extends EditablePanel { for (int i = index; i < children.size(); i++) { var child = children.get(i); - var gain_width = child.getWidth() + child.getDockMargin().left() + child.getDockMargin().right(); + var gain_width = child.getWidth() + child.getDockMargin().getLeft() + child.getDockMargin().getRight(); until = i; @@ -162,7 +162,7 @@ public class FlexGridPanel extends EditablePanel { break; } - max_height = Math.max(max_height, child.getHeight() + child.getDockMargin().top() + child.getDockMargin().bottom()); + max_height = Math.max(max_height, child.getHeight() + child.getDockMargin().getTop() + child.getDockMargin().getBottom()); total_width += gain_width; } @@ -176,8 +176,8 @@ public class FlexGridPanel extends EditablePanel { for (int i = index; i <= until; i++) { var child = children.get(i); - child.setPos((int) (this_width - total_width + accumulate_width + child.getDockMargin().left()), (int) (h_middle + max_height - child.getHeight() / 2)); - accumulate_width += child.getWidth() + child.getDockMargin().left() + child.getDockMargin().right(); + child.setPos((int) (this_width - total_width + accumulate_width + child.getDockMargin().getLeft()), (int) (h_middle + max_height - child.getHeight() / 2)); + accumulate_width += child.getWidth() + child.getDockMargin().getLeft() + child.getDockMargin().getRight(); } h_middle += max_height * 2; 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 357b78fa6..dc154f555 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 @@ -29,11 +29,9 @@ import java.util.* import kotlin.collections.ArrayList import kotlin.math.roundToInt -@JvmRecord data class ScreenPos(val x: Float, val y: Float) -@JvmRecord -data class DockProperty @JvmOverloads constructor(val left: Float = 0f, val top: Float = 0f, val right: Float = 0f, val bottom: Float = 0f) { +data class DockProperty(val left: Float = 0f, val top: Float = 0f, val right: Float = 0f, val bottom: Float = 0f) { val isEmpty get() = left == 0f && right == 0f && top == 0f && bottom == 0f companion object { @@ -73,7 +71,7 @@ open class EditablePanel @JvmOverloads constructor( width: Float = 10f, height: Float = 10f, -) { +) : Comparable> { // layout engine does not support navigation using keyboard // fuck off val listener: GuiEventListener = object : GuiEventListener { @@ -140,6 +138,18 @@ open class EditablePanel @JvmOverloads constructor( } } + var childrenOrder = 0 + set(value) { + if (field != value) { + field = value + parent?.sortChildren() + } + } + + override fun compareTo(other: EditablePanel<*>): Int { + return childrenOrder.compareTo(other.childrenOrder) + } + var parent: EditablePanel<*>? = null set(value) { if (field === value) @@ -670,9 +680,17 @@ open class EditablePanel @JvmOverloads constructor( this.parent = parent } + var childrenSortingInvalidated = false + private set + + fun invalidateChildrenSorting() { + childrenSortingInvalidated = true + } + private fun onParent(child: EditablePanel<*>) { if (childrenInternal.contains(child)) throw IllegalStateException("Already containing $child") childrenInternal.add(child) + invalidateChildrenSorting() if (child.visible) { visibleChildrenInternal.add(child) @@ -691,6 +709,7 @@ open class EditablePanel @JvmOverloads constructor( val indexOf = childrenInternal.indexOf(child) if (indexOf == -1) throw IllegalStateException("Already not containing $child") childrenInternal.removeAt(indexOf) + invalidateChildrenSorting() if (child.visible) { visibleChildrenInternal.remove(child) @@ -702,6 +721,18 @@ open class EditablePanel @JvmOverloads constructor( } } + private fun sortChildren() { + childrenSortingInvalidated = false + childrenInternal.sort() + + val old = ArrayList(visibleChildrenInternal) + visibleChildrenInternal.sort() + + if (old != visibleChildrenInternal) { + invalidateLayout() + } + } + protected open fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {} protected open fun innerRenderPost(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {} protected open fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { @@ -731,6 +762,9 @@ open class EditablePanel @JvmOverloads constructor( } fun performLayoutIfNeeded() { + if (childrenSortingInvalidated) + sortChildren() + if (layoutInvalidated) { performLayout() } else if (boundsInvalidated) { @@ -1267,7 +1301,14 @@ open class EditablePanel @JvmOverloads constructor( return findHierarchicalFocus() != null } + /** + * Called when [hasFocusedChildren] changes + */ protected open fun onHierarchicalFocusChanged() {} + + /** + * Called when [isFocusedThis] changes + */ protected open fun onFocusChanged() {} fun isEverFocused(): Boolean { From 04f58c01dbf7b31f4d21b088b27ec50a094259df Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 15 Jul 2023 19:39:25 +0700 Subject: [PATCH 0756/1199] Add HSVColor, massively overhaul RGBAColor class --- .../ru/dbotthepony/mc/otm/core/math/Colors.kt | 388 ++++++++++++++++++ .../dbotthepony/mc/otm/core/math/RGBAColor.kt | 127 ------ 2 files changed, 388 insertions(+), 127 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Colors.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/math/RGBAColor.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Colors.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Colors.kt new file mode 100644 index 000000000..98741982c --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Colors.kt @@ -0,0 +1,388 @@ +package ru.dbotthepony.mc.otm.core.math + +import com.mojang.serialization.Codec +import com.mojang.serialization.codecs.RecordCodecBuilder +import it.unimi.dsi.fastutil.chars.CharAVLTreeSet +import net.minecraft.ChatFormatting +import kotlin.math.roundToInt + +class HSVColor(hue: Float, saturation: Float, value: Float) : Comparable { + val hue = (hue % 360f).let { if (it < 0f) it + 360f else it } + val saturation = saturation.coerceIn(0f, 1f) + val value = value.coerceIn(0f, 1f) + + override fun equals(other: Any?): Boolean { + return other === this || other is HSVColor && other.hue == hue && other.saturation == saturation && other.value == value + } + + override fun hashCode(): Int { + return hue.hashCode() + saturation.hashCode() * 31 + value.hashCode() * 31 * 31 + } + + fun copy(hue: Float = this.hue, saturation: Float = this.saturation, value: Float = this.value): HSVColor { + return HSVColor(hue, saturation, value) + } + + operator fun component1() = hue + operator fun component2() = saturation + operator fun component3() = value + + fun toRGBA(alpha: Float = 1f): RGBAColor { + val valueMin = (1f - saturation) * value + val delta = (value - valueMin) * (hue % 60f) / 60f + val valueInc = valueMin + delta + val valueDec = value - delta + + return when ((hue / 60f).toInt()) { + 0 -> RGBAColor(value, valueInc, valueMin, alpha) + 1 -> RGBAColor(valueDec, value, valueMin, alpha) + 2 -> RGBAColor(valueMin, value, valueInc, alpha) + 3 -> RGBAColor(valueMin, valueDec, value, alpha) + 4 -> RGBAColor(valueInc, valueMin, value, alpha) + 5 -> RGBAColor(value, valueMin, valueDec, alpha) + else -> throw IllegalStateException("whut") + } + } + + override fun compareTo(other: HSVColor): Int { + return comparator.compare(this, other) + } + + companion object { + @JvmField val WHITE = HSVColor(0f, 1f, 1f) + + private val comparator = Comparator + .comparing(HSVColor::hue) + .thenComparing(HSVColor::saturation) + .thenComparing(HSVColor::value) + } +} + +private fun hex(value: Int): String { + require(value in 0 .. 255) + val v = value.toString(16) + + if (v.length == 1) + return "0$v" + else + return v +} + +class RGBAColor(red: Float, green: Float, blue: Float, alpha: Float = 1f) : Comparable { + constructor(r: Int, g: Int, b: Int) : this((r / 255f), (g / 255f), (b / 255f), 1f) + constructor(r: Int, g: Int, b: Int, a: Int) : this((r / 255f), (g / 255f), (b / 255f), (a / 255f)) + constructor(r: Int, g: Int, b: Int, a: Float) : this((r / 255f), (g / 255f), (b / 255f), a) + + val red = red.coerceIn(0f, 1f) + val green = green.coerceIn(0f, 1f) + val blue = blue.coerceIn(0f, 1f) + val alpha = alpha.coerceIn(0f, 1f) + + val redInt get() = (red * 255f).roundToInt() + val greenInt get() = (green * 255f).roundToInt() + val blueInt get() = (blue * 255f).roundToInt() + val alphaInt get() = (alpha * 255f).roundToInt() + + fun toRGBA(): Int { + return (redInt shl 24) or (greenInt shl 16) or (blueInt shl 8) or alphaInt + } + + fun toARGB(): Int { + return (alphaInt shl 24) or (redInt shl 16) or (greenInt shl 8) or blueInt + } + + fun toBGRA(): Int { + return (blueInt shl 24) or (greenInt shl 16) or (redInt shl 8) or alphaInt + } + + val isFullyTransparent get() = alpha <= 0f + val isWhite: Boolean get() = red >= 1f && green >= 1f && blue >= 1f && alpha >= 1f + + fun canRepresentHue(): Boolean { + val min = red.coerceAtMost(green).coerceAtMost(blue) + val max = red.coerceAtLeast(green).coerceAtLeast(blue) + return min != max + } + + fun hue(ifNoHue: Float = 0f): Float { + val min = red.coerceAtMost(green).coerceAtMost(blue) + val max = red.coerceAtLeast(green).coerceAtLeast(blue) + + if (min == max) { + return ifNoHue + } + + val diff = max - min + + return if (max == red && green >= blue) { + 60f * (green - blue) / diff + } else if (max == red) { + 60f * (green - blue) / diff + 360f + } else if (max == green) { + 60f * (blue - red) / diff + 120f + } else if (max == blue) { + 60f * (red - green) / diff + 240f + } else { + throw IllegalStateException("Whut $red $green $blue ($min / $max)") + } + } + + fun toHSV(): HSVColor { + val min = red.coerceAtMost(green).coerceAtMost(blue) + val max = red.coerceAtLeast(green).coerceAtLeast(blue) + + if (min == max) { + return HSVColor(0f, if (max == 0f) 0f else 1f - min / max, max) + } + + val diff = max - min + + val hue = if (max == red && green >= blue) { + 60f * (green - blue) / diff + } else if (max == red) { + 60f * (green - blue) / diff + 360f + } else if (max == green) { + 60f * (blue - red) / diff + 120f + } else if (max == blue) { + 60f * (red - green) / diff + 240f + } else { + throw IllegalStateException("Whut $red $green $blue ($min / $max)") + } + + return HSVColor(hue, 1f - min / max, max) + } + + fun toHexStringRGB(): String { + return "#${hex(redInt)}${hex(greenInt)}${hex(blueInt)}" + } + + fun toHexStringRGBA(): String { + return "#${hex(redInt)}${hex(greenInt)}${hex(blueInt)}${hex(alphaInt)}" + } + + fun toHexStringARGB(): String { + return "#${hex(alphaInt)}${hex(redInt)}${hex(greenInt)}${hex(blueInt)}" + } + + override fun toString(): String { + return "RGBAColor[$red $green $blue $alpha]" + } + + operator fun component1() = red + operator fun component2() = green + operator fun component3() = blue + operator fun component4() = alpha + + fun toIntInv(): Int { + return (blueInt shl 16) or (greenInt shl 8) or redInt + } + + fun toRGB(): Int { + return (redInt shl 16) or (greenInt shl 8) or blueInt + } + + fun copy(red: Float = this.red, green: Float = this.green, blue: Float = this.blue, alpha: Float = this.alpha): RGBAColor { + return RGBAColor(red, green, blue, alpha) + } + + override fun compareTo(other: RGBAColor): Int { + if (canRepresentHue() && other.canRepresentHue()) + return hue().compareTo(other.hue()).let { + if (it != 0) + it + else + toHSV().compareTo(other.toHSV()) + } + + return comparator.compare(this, other) + } + + override fun equals(other: Any?): Boolean { + return other === this || other is RGBAColor && comparator.compare(this, other) == 0 + } + + override fun hashCode(): Int { + return red.hashCode() + green.hashCode() * 31 + blue.hashCode() * 31 * 31 + alpha.hashCode() * 31 * 31 * 31 + } + + fun linearInterpolation(t: Float, other: RGBAColor, interpolateAlpha: Boolean = true): RGBAColor { + return RGBAColor( + linearInterpolation(t, red, other.red), + linearInterpolation(t, green, other.green), + linearInterpolation(t, blue, other.blue), + if (interpolateAlpha) linearInterpolation(t, alpha, other.alpha) else alpha, + ) + } + + operator fun times(other: RGBAColor): RGBAColor { + if (isWhite) + return other + else if (other.isWhite) + return this + + return RGBAColor(red * other.red, green * other.green, blue * other.blue, alpha * other.alpha) + } + + @Suppress("unused") + companion object { + private val comparator = Comparator + .comparing(RGBAColor::red) + .thenComparing(RGBAColor::green) + .thenComparing(RGBAColor::blue) + .thenComparing(RGBAColor::alpha) + + @JvmField val TRANSPARENT_BLACK = RGBAColor(0f, 0f, 0f, 0f) + @JvmField val TRANSPARENT_WHITE = RGBAColor(1f, 1f, 1f, 0f) + + @JvmField val BLACK = RGBAColor(0f, 0f, 0f) + @JvmField val WHITE = RGBAColor(1f, 1f, 1f) + @JvmField val RED = RGBAColor(1f, 0f, 0f) + @JvmField val GREEN = RGBAColor(0f, 1f, 0f) + @JvmField val LIGHT_GREEN = RGBAColor(136, 255, 124) + @JvmField val SLATE_GRAY = RGBAColor(64, 64, 64) + @JvmField val GRAY = rgb(0x2C2C2CL) + + @JvmField val DARK_BLUE = rgb(ChatFormatting.DARK_BLUE.color!!) + @JvmField val DARK_GREEN = rgb(ChatFormatting.DARK_GREEN.color!!) + @JvmField val DARK_AQUA = rgb(ChatFormatting.DARK_AQUA.color!!) + @JvmField val DARK_RED = rgb(ChatFormatting.DARK_RED.color!!) + @JvmField val DARK_PURPLE = rgb(ChatFormatting.DARK_PURPLE.color!!) + @JvmField val GOLD = rgb(ChatFormatting.GOLD.color!!) + @JvmField val DARK_GRAY = rgb(ChatFormatting.DARK_GRAY.color!!) + @JvmField val BLUE = rgb(ChatFormatting.BLUE.color!!) + @JvmField val AQUA = rgb(ChatFormatting.AQUA.color!!) + @JvmField val LIGHT_PURPLE = rgb(ChatFormatting.LIGHT_PURPLE.color!!) + @JvmField val YELLOW = rgb(ChatFormatting.YELLOW.color!!) + + @JvmField val LOW_POWER = RGBAColor(173, 41, 41) + @JvmField val FULL_POWER = RGBAColor(255, 242, 40) + @JvmField val LOW_MATTER = RGBAColor(0, 24, 148) + @JvmField val FULL_MATTER = RGBAColor(72, 90, 255) + @JvmField val LOW_PATTERNS = RGBAColor(44, 104, 57) + @JvmField val FULL_PATTERNS = RGBAColor(65, 255, 87) + + @JvmField val HALF_TRANSPARENT = RGBAColor(1f, 1f, 1f, 0.5f) + @JvmField val REDDISH = RGBAColor(1f, 0.4f, 0.4f) + + @JvmField + val CODECRGBA: Codec = RecordCodecBuilder.create { + it.group( + Codec.floatRange(0f, 1f).fieldOf("red").forGetter(RGBAColor::red), + Codec.floatRange(0f, 1f).fieldOf("green").forGetter(RGBAColor::green), + Codec.floatRange(0f, 1f).fieldOf("blue").forGetter(RGBAColor::blue), + Codec.floatRange(0f, 1f).optionalFieldOf("alpha", 1f).forGetter(RGBAColor::alpha), + ).apply(it, ::RGBAColor) + } + + @JvmField + val CODECRGB: Codec = RecordCodecBuilder.create { + it.group( + Codec.floatRange(0f, 1f).fieldOf("red").forGetter(RGBAColor::red), + Codec.floatRange(0f, 1f).fieldOf("green").forGetter(RGBAColor::green), + Codec.floatRange(0f, 1f).fieldOf("blue").forGetter(RGBAColor::blue), + ).apply(it, ::RGBAColor) + } + + fun rgb(color: Int): RGBAColor { + val r = (color and 0xFF0000 ushr 16) / 255f + val g = (color and 0xFF00 ushr 8) / 255f + val b = (color and 0xFF) / 255f + return RGBAColor(r, g, b) + } + + fun rgb(color: Long): RGBAColor { + val r = (color and 0xFF0000 ushr 16) / 255f + val g = (color and 0xFF00 ushr 8) / 255f + val b = (color and 0xFF) / 255f + return RGBAColor(r, g, b) + } + + fun bgr(color: Int): RGBAColor { + val r = (color and 0xFF0000 ushr 16) / 255f + val g = (color and 0xFF00 ushr 8) / 255f + val b = (color and 0xFF) / 255f + return RGBAColor(b, g, r) + } + + fun bgr(color: Long): RGBAColor { + val r = (color and 0xFF0000 ushr 16) / 255f + val g = (color and 0xFF00 ushr 8) / 255f + val b = (color and 0xFF) / 255f + return RGBAColor(b, g, r) + } + + fun abgr(color: Int): RGBAColor { + val r = (color and -0x1000000 ushr 24) / 255f + val g = (color and 0xFF0000 ushr 16) / 255f + val b = (color and 0xFF00 ushr 8) / 255f + val a = (color and 0xFF) / 255f + return RGBAColor(a, b, g, r) + } + + fun argb(color: Int): RGBAColor { + val a = (color and -0x1000000 ushr 24) / 255f + val r = (color and 0xFF0000 ushr 16) / 255f + val g = (color and 0xFF00 ushr 8) / 255f + val b = (color and 0xFF) / 255f + return RGBAColor(r, g, b, a) + } + + private val hexChars = CharAVLTreeSet() + + init { + "#0123456789abcdefABCDEF".forEach { hexChars.add(it) } + } + + fun isHexCharacter(char: Char): Boolean { + return char in hexChars + } + + private val shorthandRGBHex = Regex("#?([0-9abcdef])([0-9abcdef])([0-9abcdef])", RegexOption.IGNORE_CASE) + private val longhandRGBHex = Regex("#?([0-9abcdef]{2})([0-9abcdef]{2})([0-9abcdef]{2})", RegexOption.IGNORE_CASE) + + private val shorthandRGBAHex = Regex("#?([0-9abcdef])([0-9abcdef])([0-9abcdef])([0-9abcdef])", RegexOption.IGNORE_CASE) + private val longhandRGBAHex = Regex("#?([0-9abcdef]{2})([0-9abcdef]{2})([0-9abcdef]{2})([0-9abcdef]{2})", RegexOption.IGNORE_CASE) + + fun fromHexStringRGB(value: String): RGBAColor? { + if (value.length == 3 || value.length == 4) { + val match = shorthandRGBHex.find(value) ?: return null + val red = match.groupValues[1].toIntOrNull(16) ?: return null + val green = match.groupValues[2].toIntOrNull(16) ?: return null + val blue = match.groupValues[3].toIntOrNull(16) ?: return null + return RGBAColor(red * 16, green * 16, blue * 16) + } else if (value.length == 6 || value.length == 7) { + val match = longhandRGBHex.find(value) ?: return null + val red = match.groupValues[1].toIntOrNull(16) ?: return null + val green = match.groupValues[2].toIntOrNull(16) ?: return null + val blue = match.groupValues[3].toIntOrNull(16) ?: return null + return RGBAColor(red, green, blue) + } else { + return null + } + } + + fun fromHexStringRGBA(value: String): RGBAColor? { + if (value.length == 4 || value.length == 5) { + val match = shorthandRGBAHex.find(value) ?: return null + val red = match.groupValues[1].toIntOrNull(16) ?: return null + val green = match.groupValues[2].toIntOrNull(16) ?: return null + val blue = match.groupValues[3].toIntOrNull(16) ?: return null + val alpha = match.groupValues[4].toIntOrNull(16) ?: return null + return RGBAColor(red * 16, green * 16, blue * 16, alpha * 16) + } else if (value.length == 8 || value.length == 9) { + val match = longhandRGBAHex.find(value) ?: return null + val red = match.groupValues[1].toIntOrNull(16) ?: return null + val green = match.groupValues[2].toIntOrNull(16) ?: return null + val blue = match.groupValues[3].toIntOrNull(16) ?: return null + val alpha = match.groupValues[4].toIntOrNull(16) ?: return null + return RGBAColor(red, green, blue, alpha) + } else { + return null + } + } + } +} + +fun linearInterpolation(t: Float, a: RGBAColor, b: RGBAColor): RGBAColor { + return a.linearInterpolation(t, b) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/RGBAColor.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/RGBAColor.kt deleted file mode 100644 index 01eb2ba9c..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/RGBAColor.kt +++ /dev/null @@ -1,127 +0,0 @@ -package ru.dbotthepony.mc.otm.core.math - -import com.mojang.blaze3d.systems.RenderSystem -import net.minecraft.ChatFormatting -import kotlin.math.roundToInt - -data class RGBAColor(val red: Float, val green: Float, val blue: Float, val alpha: Float = 1f) { - constructor(r: Int, g: Int, b: Int) : this((r / 255f), (g / 255f), (b / 255f), 1f) - constructor(r: Int, g: Int, b: Int, a: Int) : this((r / 255f), (g / 255f), (b / 255f), (a / 255f)) - constructor(r: Int, g: Int, b: Int, a: Float) : this((r / 255f), (g / 255f), (b / 255f), a) - - constructor(color: Long) : this( - (((color and -0x1000000) ushr 24) / 255f), - (((color and 0xFF0000) ushr 16) / 255f), - (((color and 0xFF00) ushr 8) / 255f), - (((color and 0xFF)) / 255f) - ) - - val isWhite = red >= 1f && green >= 1f && blue >= 1f && alpha >= 1f - - val redInt = (red.coerceIn(0f, 1f) * 255f).roundToInt() - val greenInt = (green.coerceIn(0f, 1f) * 255f).roundToInt() - val blueInt = (blue.coerceIn(0f, 1f) * 255f).roundToInt() - val alphaInt = (alpha.coerceIn(0f, 1f) * 255f).roundToInt() - - fun toRGB(): Int { - return (redInt shl 16) or (greenInt shl 8) or blueInt - } - - fun toRGBA(): Int { - return (redInt shl 24) or (greenInt shl 16) or (blueInt shl 8) or alphaInt - } - - fun toARGB(): Int { - return (alphaInt shl 24) or (redInt shl 16) or (greenInt shl 8) or blueInt - } - - fun toBGRA(): Int { - return (blueInt shl 24) or (greenInt shl 16) or (redInt shl 8) or alphaInt - } - - fun toIntInv(): Int { - return (blueInt shl 16) or (greenInt shl 8) or redInt - } - - fun linearInterpolation(t: Float, other: RGBAColor, interpolateAlpha: Boolean = true): RGBAColor { - return RGBAColor( - linearInterpolation(t, red, other.red), - linearInterpolation(t, green, other.green), - linearInterpolation(t, blue, other.blue), - if (interpolateAlpha) linearInterpolation(t, alpha, other.alpha) else alpha, - ) - } - - operator fun times(other: RGBAColor): RGBAColor { - if (isWhite) - return other - else if (other.isWhite) - return this - - return RGBAColor(red * other.red, green * other.green, blue * other.blue, alpha * other.alpha) - } - - val isFullyTransparent get() = alpha <= 0f - - companion object { - @JvmField val TRANSPARENT_BLACK = RGBAColor(0f, 0f, 0f, 0f) - @JvmField val TRANSPARENT_WHITE = RGBAColor(1f, 1f, 1f, 0f) - - @JvmField val BLACK = RGBAColor(0f, 0f, 0f, 1f) - @JvmField val WHITE = RGBAColor(1f, 1f, 1f, 1f) - @JvmField val RED = RGBAColor(1f, 0f, 0f) - @JvmField val GREEN = RGBAColor(0f, 1f, 0f, 1f) - @JvmField val LIGHT_GREEN = RGBAColor(136, 255, 124) - @JvmField val SLATE_GRAY = RGBAColor(64, 64, 64) - @JvmField val GRAY = RGBAColor(0x2C2C2CFFL) - - @JvmField val DARK_BLUE = rgb(ChatFormatting.DARK_BLUE.color!!) - @JvmField val DARK_GREEN = rgb(ChatFormatting.DARK_GREEN.color!!) - @JvmField val DARK_AQUA = rgb(ChatFormatting.DARK_AQUA.color!!) - @JvmField val DARK_RED = rgb(ChatFormatting.DARK_RED.color!!) - @JvmField val DARK_PURPLE = rgb(ChatFormatting.DARK_PURPLE.color!!) - @JvmField val GOLD = rgb(ChatFormatting.GOLD.color!!) - @JvmField val DARK_GRAY = rgb(ChatFormatting.DARK_GRAY.color!!) - @JvmField val BLUE = rgb(ChatFormatting.BLUE.color!!) - @JvmField val AQUA = rgb(ChatFormatting.AQUA.color!!) - @JvmField val LIGHT_PURPLE = rgb(ChatFormatting.LIGHT_PURPLE.color!!) - @JvmField val YELLOW = rgb(ChatFormatting.YELLOW.color!!) - - @JvmField val LOW_POWER = RGBAColor(173, 41, 41) - @JvmField val FULL_POWER = RGBAColor(255, 242, 40) - @JvmField val LOW_MATTER = RGBAColor(0, 24, 148) - @JvmField val FULL_MATTER = RGBAColor(72, 90, 255) - @JvmField val LOW_PATTERNS = RGBAColor(44, 104, 57) - @JvmField val FULL_PATTERNS = RGBAColor(65, 255, 87) - - @JvmField val HALF_TRANSPARENT = RGBAColor(1f, 1f, 1f, 0.5f) - @JvmField val REDDISH = RGBAColor(1f, 0.4f, 0.4f) - - fun inv(color: Int): RGBAColor { - val r = (color and -0x1000000 ushr 24) / 255f - val g = (color and 0xFF0000 ushr 16) / 255f - val b = (color and 0xFF00 ushr 8) / 255f - val a = (color and 0xFF) / 255f - return RGBAColor(a, b, g, r) - } - - fun rgb(color: Int): RGBAColor { - val r = (color and 0xFF0000 ushr 16) / 255f - val g = (color and 0xFF00 ushr 8) / 255f - val b = (color and 0xFF) / 255f - return RGBAColor(r, g, b) - } - - fun argb(color: Int): RGBAColor { - val a = (color and -0x1000000 ushr 24) / 255f - val r = (color and 0xFF0000 ushr 16) / 255f - val g = (color and 0xFF00 ushr 8) / 255f - val b = (color and 0xFF) / 255f - return RGBAColor(r, g, b, a) - } - } -} - -fun linearInterpolation(t: Float, a: RGBAColor, b: RGBAColor): RGBAColor { - return a.linearInterpolation(t, b) -} From 9fe8d1734ec5d3123b19112bbdb2d211bc561813 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 15 Jul 2023 19:39:38 +0700 Subject: [PATCH 0757/1199] Add RGBAColor stream codecs --- .../ru/dbotthepony/mc/otm/core/util/DataStreams.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt index c0a32fee9..d08146816 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt @@ -9,6 +9,7 @@ import net.minecraft.nbt.NbtAccounter import net.minecraft.world.item.ItemStack import net.minecraftforge.fluids.FluidStack import ru.dbotthepony.mc.otm.core.immutableMap +import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.readDecimal import ru.dbotthepony.mc.otm.core.math.writeDecimal import ru.dbotthepony.mc.otm.core.readItemType @@ -122,6 +123,14 @@ val VarIntValueCodec = StreamCodec(DataInputStream::readVarIntLE, DataOutputStre val VarLongValueCodec = StreamCodec(DataInputStream::readVarLongLE, DataOutputStream::writeVarLongLE) { a, b -> a == b } val BinaryStringCodec = StreamCodec(DataInputStream::readBinaryString, DataOutputStream::writeBinaryString) +val RGBCodec: StreamCodec = StreamCodec( + { s, a -> a.accountBytes(12L); RGBAColor(s.readFloat(), s.readFloat(), s.readFloat()) }, + { s, v -> s.writeFloat(v.red); s.writeFloat(v.green); s.writeFloat(v.blue) }) + +val RGBACodec: StreamCodec = StreamCodec( + { s, a -> a.accountBytes(16L); RGBAColor(s.readFloat(), s.readFloat(), s.readFloat(), s.readFloat()) }, + { s, v -> s.writeFloat(v.red); s.writeFloat(v.green); s.writeFloat(v.blue); s.writeFloat(v.alpha) }) + class EnumValueCodec>(clazz: Class) : IStreamCodec, Codec { val clazz = searchClass(clazz) val values: ImmutableList = ImmutableList.copyOf(this.clazz.enumConstants!!) From 9394de61d9e3be5c3839b8b4aef112f62b9b7686 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 15 Jul 2023 19:40:11 +0700 Subject: [PATCH 0758/1199] Make TextInputPanel obey acceptsCharacter when pasting from clipboard --- .../mc/otm/client/screen/panels/input/TextInputPanel.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt index fb9d10ba8..3c8c9ea5d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt @@ -894,7 +894,7 @@ open class TextInputPanel( pushbackSnapshot() if (multiLine) { - val insert = minecraft.keyboardHandler.clipboard.replace("\t", " ").split(NEWLINES).toMutableList() + val insert = minecraft.keyboardHandler.clipboard.replace("\t", " ").filter { acceptsCharacter(it) }.split(NEWLINES).toMutableList() val actualLastSize = insert.lastOrNull()?.length ?: 0 val line = this[cursorLine] @@ -933,7 +933,7 @@ open class TextInputPanel( cursorRow = actualLastSize } } else { - val insert = minecraft.keyboardHandler.clipboard.replace("\t", " ").replace(NEWLINES, "") + val insert = minecraft.keyboardHandler.clipboard.replace("\t", " ").replace(NEWLINES, "").filter { acceptsCharacter(it) } val line = this[cursorLine] if (line == null) { From 4daa0be19ae520d8588b348e8bc91eaf9920a06d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 15 Jul 2023 19:41:31 +0700 Subject: [PATCH 0759/1199] Color picker panel --- .../mc/otm/datagen/lang/English.kt | 18 + .../mc/otm/datagen/lang/Russian.kt | 18 + .../otm/client/screen/panels/ColorPicker.kt | 746 ++++++++++++++++++ .../textures/gui/gradient_h.png | Bin 0 -> 627 bytes .../textures/gui/gradient_v.png | Bin 0 -> 682 bytes .../textures/gui/hsv.png | Bin 0 -> 1881 bytes .../textures/gui/widgets/misc.png | Bin 1378 -> 1405 bytes 7 files changed, 782 insertions(+) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/gradient_h.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/gradient_v.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/hsv.png diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 08a7414d8..5c97f4607 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -139,6 +139,8 @@ private fun misc(provider: MatteryLanguageProvider) { gui("exopack.go_back", "Open vanilla inventory") gui("exopack.go_in", "Open Exopack inventory") gui("exopack.toggle_visibility", "Toggle Exopack visibility") + gui("exopack.change_color", "Customize Exopack color") + gui("exopack.change_color2", "Press Middle Mouse Button to remove color") gui("exopack.probe1", "This little device feels unnatural to touch, it is almost certainly resilient to any possible attempt to break it open.") gui("exopack.probe2", "There is fingerprint reader built into one of sides which gently glow when touched.") @@ -664,6 +666,22 @@ private fun gui(provider: MatteryLanguageProvider) { with(provider.english) { gui("quicksearch", "Quick search...") + gui("color_picker", "Color Picker") + + gui("color.short.red", "R") + gui("color.short.green", "G") + gui("color.short.blue", "B") + gui("color.short.hue", "H") + gui("color.short.saturation", "S") + gui("color.short.value", "V") + + gui("color.full.red", "Red") + gui("color.full.green", "Green") + gui("color.full.blue", "Blue") + gui("color.full.hue", "Hue") + gui("color.full.saturation", "Saturation") + gui("color.full.value", "Value") + gui("item_monitor.refill_source.desc", "Controls from where to take items for slot auto refill") gui("item_monitor.refill_source.system", "System only. Crafting grid will be auto refilled only from storage system. This is the behavior you see in AE2 and Refined Storage") gui("item_monitor.refill_source.inventory", "Inventory only. Crafting grid will be auto refilled only from player's inventory") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index faecb219c..34b334622 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -147,6 +147,8 @@ private fun misc(provider: MatteryLanguageProvider) { gui("exopack.go_back", "Открыть обычный инвентарь") gui("exopack.go_in", "Открыть инвентарь экзопака") gui("exopack.toggle_visibility", "Переключить отображение Экзопака") + gui("exopack.change_color", "Изменить окраску Экзопака") + gui("exopack.change_color2", "Нажмите среднюю кнопку мыши для сброса окраски") gui("exopack.probe1", "Данное маленькое устройство необычно на ощупь, а так же неприступно для любых попыток вскрыть.") gui("exopack.probe2", "На одной из сторон данного устройства находится сканер отпечатка, который тускло загорается при касании.") @@ -668,6 +670,22 @@ private fun gui(provider: MatteryLanguageProvider) { with(provider.russian) { gui("quicksearch", "Быстрый поиск...") + gui("color_picker", "Выбор цвета") + + gui("color.short.red", "К") + gui("color.short.green", "З") + gui("color.short.blue", "С") + gui("color.short.hue", "Ц") + gui("color.short.saturation", "Н") + gui("color.short.value", "Я") + + gui("color.full.red", "Красный") + gui("color.full.green", "Зелёный") + gui("color.full.blue", "Синий") + gui("color.full.hue", "Цвет") + gui("color.full.saturation", "Насыщение") + gui("color.full.value", "Яркость") + gui("item_monitor.refill_source.desc", "Контролирует источник предметов для заполнения сетки создания") gui("item_monitor.refill_source.system", "Только система. Сетка создания будет заполняться только из системы предметов. Данный параметр соответствует поведению AE2 и Refined Storage") gui("item_monitor.refill_source.inventory", "Только инвентарь. Сетка создания будет заполняться только из инвентаря игрока") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt new file mode 100644 index 000000000..af60b2190 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt @@ -0,0 +1,746 @@ +package ru.dbotthepony.mc.otm.client.screen.panels + +import com.mojang.blaze3d.platform.InputConstants +import com.mojang.datafixers.util.Either +import it.unimi.dsi.fastutil.floats.FloatConsumer +import net.minecraft.client.gui.GuiGraphics +import net.minecraft.client.gui.screens.Screen +import net.minecraft.network.chat.Component +import net.minecraft.resources.ResourceLocation +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.client.playGuiClickSound +import ru.dbotthepony.mc.otm.client.render.MatterySprite +import ru.dbotthepony.mc.otm.client.render.RenderGravity +import ru.dbotthepony.mc.otm.client.render.UVWindingOrder +import ru.dbotthepony.mc.otm.client.render.WidgetLocation +import ru.dbotthepony.mc.otm.client.render.renderRect +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.button.AbstractButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.input.TextInputPanel +import ru.dbotthepony.mc.otm.core.TextComponent +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.math.HSVColor +import ru.dbotthepony.mc.otm.core.math.RGBAColor +import java.util.function.Consumer +import kotlin.math.roundToInt + +open class ColorBoxPanel( + screen: S, + parent: EditablePanel<*>?, + x: Float, + y: Float, + width: Float = 64f, + height: Float = 64f, + protected val callback: Consumer? = null, +) : EditablePanel(screen, parent, x, y, width, height) { + var backgroundColor = RGBAColor.RED + private set + var markerPos = backgroundColor.toHSV() + protected set + + fun setColor(color: Either) { + color.map( + { markerPos = it.toHSV(); if (it.canRepresentHue()) backgroundColor = HSVColor(it.toHSV().hue, 1f, 1f).toRGBA() }, + { markerPos = it; backgroundColor = HSVColor(it.hue, 1f, 1f).toRGBA() }) + } + + var isPressed = false + private set + + override fun shouldRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + return super.shouldRenderTooltips(graphics, mouseX, mouseY, partialTick) || isPressed + } + + protected open fun onPickedColor(color: HSVColor) { + callback?.accept(color) + } + + protected fun pickColor(mouseX: Double, mouseY: Double) { + val (x, y) = screenToLocal(mouseX, mouseY) + + val saturation = 1f - x.coerceIn(0f, width) / width + val value = 1f - y.coerceIn(0f, height) / height + + markerPos = HSVColor(backgroundColor.toHSV().hue, saturation, value) + onPickedColor(markerPos) + } + + override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { + if (button == InputConstants.MOUSE_BUTTON_LEFT) { + if (!isPressed) { + isPressed = true + grabMouseInput = true + + pickColor(x, y) + playGuiClickSound() + } + + return true + } + + return super.mouseClickedInner(x, y, button) + } + + override fun mouseDraggedInner(x: Double, y: Double, button: Int, xDelta: Double, yDelta: Double): Boolean { + if (isPressed && button == InputConstants.MOUSE_BUTTON_LEFT) { + pickColor(x, y) + return true + } + + return super.mouseDraggedInner(x, y, button, xDelta, yDelta) + } + + override fun mouseReleasedInner(x: Double, y: Double, button: Int): Boolean { + if (button == InputConstants.MOUSE_BUTTON_LEFT) { + if (isPressed) { + isPressed = false + grabMouseInput = false + } + + return true + } + + return super.mouseReleasedInner(x, y, button) + } + + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + graphics.renderRect(0f, 0f, width, height, color = RGBAColor.WHITE) + GRADIENT_LEFT.render(graphics, 0f, 0f, width, height, color = backgroundColor) + GRADIENT_DOWN.render(graphics, 0f, 0f, width, height, color = RGBAColor.BLACK) + + val x = (1f - markerPos.saturation) * width + val y = (1f - markerPos.value) * height + + LINE_VERTICAL.render(graphics, x = x - 1f, height = height) + LINE_HORIZONTAL.render(graphics, y = y - 1f, width = width) + LINE_CROSS.render(graphics, x = x - 1f, y = y - 1f) + } + + companion object { + val GRADIENT_UP = MatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/gradient_v.png"), 0f, 0f, 32f, 256f, 32f, 256f) + val GRADIENT_DOWN = GRADIENT_UP.copy(winding = UVWindingOrder.FLIP) + val GRADIENT_RIGHT = MatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/gradient_h.png"), 0f, 0f, 256f, 32f, 256f, 32f) + val GRADIENT_LEFT = GRADIENT_RIGHT.copy(winding = UVWindingOrder.FLOP) + + val LINE_VERTICAL = WidgetLocation.MISC.sprite(36f, 0f, 3f, 3f) + val LINE_HORIZONTAL = WidgetLocation.MISC.sprite(36f, 3f, 3f, 3f) + val LINE_CROSS = WidgetLocation.MISC.sprite(36f, 6f, 3f, 3f) + } +} + +abstract class AbstractColorWangPanel( + screen: S, + parent: EditablePanel<*>?, + x: Float = 0f, + y: Float = 0f, + width: Float = 40f, + height: Float = 10f, + protected val callback: Consumer? = null, +) : EditablePanel(screen, parent, x, y, width, height) { + abstract val leftColor: RGBAColor + abstract val rightColor: RGBAColor + abstract val wangPosition: Float + abstract fun setColor(color: Either) + protected abstract fun onWangInput(newPosition: Float) + + init { + scissor = true + } + + var isPressed = false + private set + + protected fun updateColor(mouseX: Double) { + onWangInput((screenToLocal(mouseX, 0.0).x / width).coerceIn(0f, 1f)) + } + + override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { + if (button == InputConstants.MOUSE_BUTTON_LEFT) { + if (!isPressed) { + isPressed = true + grabMouseInput = true + + updateColor(x) + playGuiClickSound() + } + + return true + } + + return super.mouseClickedInner(x, y, button) + } + + override fun mouseDraggedInner(x: Double, y: Double, button: Int, xDelta: Double, yDelta: Double): Boolean { + if (isPressed && button == InputConstants.MOUSE_BUTTON_LEFT) { + updateColor(x) + return true + } + + return super.mouseDraggedInner(x, y, button, xDelta, yDelta) + } + + override fun mouseReleasedInner(x: Double, y: Double, button: Int): Boolean { + if (button == InputConstants.MOUSE_BUTTON_LEFT) { + if (isPressed) { + isPressed = false + grabMouseInput = false + } + + return true + } + + return super.mouseReleasedInner(x, y, button) + } + + protected fun renderGradients(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + ColorBoxPanel.GRADIENT_RIGHT.render(graphics, 0f, 0f, width, height, color = rightColor) + ColorBoxPanel.GRADIENT_LEFT.render(graphics, 0f, 0f, width, height, color = leftColor) + } + + protected fun renderWang(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + if (wangPosition in 0f .. 1f) { + ColorBoxPanel.LINE_VERTICAL.render(graphics, x = wangPosition * width - 1f, height = height) + } + } + + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + renderGradients(graphics, mouseX, mouseY, partialTick) + renderWang(graphics, mouseX, mouseY, partialTick) + } +} + +open class RedColorWangPanel( + screen: S, + parent: EditablePanel<*>?, + x: Float = 0f, + y: Float = 0f, + width: Float = 40f, + height: Float = 10f, + callback: Consumer? = null, +) : AbstractColorWangPanel(screen, parent, x, y, width, height, callback) { + override var leftColor: RGBAColor = RGBAColor.BLACK + protected set + override var rightColor: RGBAColor = RGBAColor.RED + protected set + override var wangPosition: Float = 0f + protected set + + override fun onWangInput(newPosition: Float) { + val color = leftColor.copy(red = newPosition) + wangPosition = newPosition + callback?.accept(color) + } + + override fun setColor(color: Either) { + @Suppress("name_shadowing") + val color = color.map({ it }, { it.toRGBA() }) + leftColor = color.copy(red = 0f, alpha = 1f) + rightColor = color.copy(red = 1f, alpha = 1f) + wangPosition = color.red + } +} + +open class GreenColorWangPanel( + screen: S, + parent: EditablePanel<*>?, + x: Float = 0f, + y: Float = 0f, + width: Float = 40f, + height: Float = 10f, + callback: Consumer? = null, +) : AbstractColorWangPanel(screen, parent, x, y, width, height, callback) { + override var leftColor: RGBAColor = RGBAColor.BLACK + protected set + override var rightColor: RGBAColor = RGBAColor.GREEN + protected set + override var wangPosition: Float = 0f + protected set + + override fun onWangInput(newPosition: Float) { + val color = leftColor.copy(green = newPosition) + wangPosition = newPosition + callback?.accept(color) + } + + override fun setColor(color: Either) { + @Suppress("name_shadowing") + val color = color.map({ it }, { it.toRGBA() }) + leftColor = color.copy(green = 0f, alpha = 1f) + rightColor = color.copy(green = 1f, alpha = 1f) + wangPosition = color.green + } +} + +open class BlueColorWangPanel( + screen: S, + parent: EditablePanel<*>?, + x: Float = 0f, + y: Float = 0f, + width: Float = 40f, + height: Float = 10f, + callback: Consumer? = null, +) : AbstractColorWangPanel(screen, parent, x, y, width, height, callback) { + override var leftColor: RGBAColor = RGBAColor.BLACK + protected set + override var rightColor: RGBAColor = RGBAColor.BLUE + protected set + override var wangPosition: Float = 0f + protected set + + override fun onWangInput(newPosition: Float) { + val color = leftColor.copy(blue = newPosition) + wangPosition = newPosition + callback?.accept(color) + } + + override fun setColor(color: Either) { + @Suppress("name_shadowing") + val color = color.map({ it }, { it.toRGBA() }) + leftColor = color.copy(blue = 0f, alpha = 1f) + rightColor = color.copy(blue = 1f, alpha = 1f) + wangPosition = color.blue + } +} + +open class HueWangPanel( + screen: S, + parent: EditablePanel<*>?, + x: Float = 0f, + y: Float = 0f, + width: Float = 40f, + height: Float = 10f, + protected val hueCallback: FloatConsumer? = null, +) : AbstractColorWangPanel(screen, parent, x, y, width, height) { + override val leftColor: RGBAColor get() = RGBAColor.WHITE + override val rightColor: RGBAColor get() = RGBAColor.WHITE + override var wangPosition: Float = 1f + protected set + + override fun setColor(color: Either) { + color.map( + { + if (it.canRepresentHue()) { + wangPosition = it.toHSV().hue / 360f + } + }, + { + wangPosition = it.hue / 360f + } + ) + } + + override fun onWangInput(newPosition: Float) { + wangPosition = newPosition + hueCallback?.accept(newPosition * 360f) + } + + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + HSV_BAR.render(graphics, 0f, 0f, width, height) + renderWang(graphics, mouseX, mouseY, partialTick) + } + + companion object { + val HSV_BAR = MatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/hsv.png"), 0f, 0f, 256f, 16f, 256f, 16f) + } +} + +open class SaturationWangPanel( + screen: S, + parent: EditablePanel<*>?, + x: Float = 0f, + y: Float = 0f, + width: Float = 40f, + height: Float = 10f, + protected val saturationCallback: FloatConsumer? = null, +) : AbstractColorWangPanel(screen, parent, x, y, width, height) { + override var leftColor: RGBAColor = RGBAColor.WHITE + protected set + override var rightColor: RGBAColor = RGBAColor.WHITE + protected set + override var wangPosition: Float = 1f + protected set + + override fun onWangInput(newPosition: Float) { + wangPosition = newPosition + saturationCallback?.accept(newPosition) + } + + override fun setColor(color: Either) { + color.map( + { + val hsv = it.toHSV() + + if (it.canRepresentHue()) { + leftColor = hsv.copy(saturation = 0f).toRGBA() + rightColor = hsv.copy(saturation = 1f).toRGBA() + } else { + leftColor = hsv.copy(hue = leftColor.toHSV().hue, saturation = 0f).toRGBA() + rightColor = hsv.copy(hue = rightColor.toHSV().hue, saturation = 1f).toRGBA() + } + + wangPosition = hsv.saturation + }, + { hsv -> + leftColor = hsv.copy(saturation = 0f).toRGBA() + rightColor = hsv.copy(saturation = 1f).toRGBA() + wangPosition = hsv.saturation + } + ) + } +} + +open class ValueWangPanel( + screen: S, + parent: EditablePanel<*>?, + x: Float = 0f, + y: Float = 0f, + width: Float = 40f, + height: Float = 10f, + protected val valueCallback: FloatConsumer? = null, +) : AbstractColorWangPanel(screen, parent, x, y, width, height) { + override var leftColor: RGBAColor = RGBAColor.BLACK + protected set + override var rightColor: RGBAColor = RGBAColor.WHITE + protected set + override var wangPosition: Float = 1f + protected set + + override fun onWangInput(newPosition: Float) { + wangPosition = newPosition + valueCallback?.accept(newPosition) + } + + override fun setColor(color: Either) { + color.map( + { + val hsv = it.toHSV() + + if (it.canRepresentHue()) { + leftColor = hsv.copy(value = 0f).toRGBA() + rightColor = hsv.copy(value = 1f).toRGBA() + } else { + leftColor = hsv.copy(hue = leftColor.toHSV().hue, value = 0f).toRGBA() + rightColor = hsv.copy(hue = rightColor.toHSV().hue, value = 1f).toRGBA() + } + + wangPosition = hsv.value + }, + { hsv -> + leftColor = hsv.copy(value = 0f).toRGBA() + rightColor = hsv.copy(value = 1f).toRGBA() + wangPosition = hsv.value + } + ) + } +} + +open class ColorPalettePanel( + screen: S, + parent: EditablePanel<*>?, + x: Float = 0f, + y: Float = 0f, + width: Float = 64f, + height: Float = 64f, + protected val callback: Consumer? = null +) : EditablePanel(screen, parent, x, y, width, height) { + open fun onColorChoose(color: RGBAColor) { + callback?.accept(color) + } + + inner class Button(val color: RGBAColor) : AbstractButtonPanel(screen, this@ColorPalettePanel, 0f, 0f, 8f, 8f) { + init { + tooltips.add(TextComponent("${color.redInt}, ${color.greenInt}, ${color.blueInt}")) + tooltips.add(TextComponent(color.toHexStringRGB())) + } + + override fun onClick(mouseButton: Int) { + onColorChoose(color) + } + + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + graphics.renderRect(0f, 0f, width, height, color = RGBAColor.BLACK) + graphics.renderRect(1f, 1f, width - 2f, height - 2f, color = color) + } + + override fun compareTo(other: EditablePanel<*>): Int { + return super.compareTo(other).let { + if (it != 0 || other !is Button) + it + else + color.compareTo(other.color) + } + } + } + + override fun performLayout() { + super.performLayout() + + var x = 0f + var y = 0f + + for (children in visibleChildren) { + if (children is Button) { + if (x != 0f && x + children.width > width) { + y += 9f + x = 0f + } + + children.x = x + children.y = y + x += 9f + } + } + } +} + +open class ColorPickerPanel( + screen: S, + parent: EditablePanel<*>?, + x: Float = 0f, + y: Float = 0f, + width: Float = 164f, + height: Float = 118f, + val callback: Consumer? = null +) : EditablePanel(screen, parent, x, y, width, height) { + open fun onColorChanged(color: RGBAColor) { + callback?.accept(color) + } + + var currentColor: Either = Either.left(RGBAColor.WHITE) + protected set + + fun setColor(color: Either) { + currentColor = color + hexInput.text = color.map({ it }, { it.toRGBA() }).toHexStringRGB() + updateWangs(color) + } + + protected fun updateWangs(color: Either) { + box.setColor(color) + + for (wang in wangs) + wang.update(color) + } + + protected open fun onPaletteChoose(color: RGBAColor) { + setColor(Either.left(color)) + onColorChanged(color) + } + + protected open fun onColorBoxChoose(color: HSVColor) { + setColor(Either.right(color)) + onColorChanged(color.toRGBA()) + } + + protected open fun onWangChoose(color: RGBAColor) { + setColor(Either.left(color)) + onColorChanged(color) + } + + protected open fun onHueChoose(hue: Float) { + val current = currentColor.map({ it.toHSV() }, { it }) + val new = current.copy(hue = hue) + setColor(Either.right(new)) + onColorChanged(new.toRGBA()) + } + + protected open fun onSaturationChoose(saturation: Float) { + val current = currentColor.map({ it.toHSV() }, { it }) + val new = current.copy(saturation = saturation) + setColor(Either.right(new)) + onColorChanged(new.toRGBA()) + } + + protected open fun onValueChoose(value: Float) { + val current = currentColor.map({ it.toHSV() }, { it }) + val new = current.copy(value = value) + setColor(Either.right(new)) + onColorChanged(new.toRGBA()) + } + + val topStrip = EditablePanel(screen, this, 0f, 0f, width = width, height = 70f) + val middleStrip = EditablePanel(screen, this) + val palette = ColorPalettePanel(screen, this, callback = { onPaletteChoose(it) }) + + val hexInput = object : TextInputPanel(screen, middleStrip, width = 50f) { + init { + dock = Dock.RIGHT + } + + override fun onFocusChanged() { + if (!isFocusedThis) { + val newColor = RGBAColor.fromHexStringRGB(text) + + if (newColor == null) { + text = currentColor.map({ it }, { it.toRGBA() }).toHexStringRGB() + } else { + setColor(Either.left(newColor)) + onColorChanged(newColor) + } + } + } + + override fun acceptsCharacter(codepoint: Char, mods: Int): Boolean { + return RGBAColor.isHexCharacter(codepoint) + } + } + + init { + topStrip.dock = Dock.TOP + middleStrip.dock = Dock.TOP + palette.dock = Dock.FILL + palette.dockTop = 2f + middleStrip.dockTop = 2f + + for (color in paletteColors) { + palette.Button(color) + } + } + + val box = ColorBoxPanel(screen, topStrip, 0f, 0f, width = 70f, height = 70f, callback = { onColorBoxChoose(it) }) + val wangCanvas = EditablePanel(screen, topStrip, width = 80f) + + inner class WangLine(label: String, val wang: AbstractColorWangPanel, val text: (color: Either) -> Component?) { + val canvas = EditablePanel(screen, wangCanvas, height = 10f) + val label = Label(screen, canvas, width = 10f, text = TranslatableComponent("otm.gui.color.short.$label")) + val textLabel = Label(screen, canvas, width = 25f) + + init { + this.wang.parent = canvas + this.wang.width = 45f + + this.label.childrenOrder = 0 + this.wang.childrenOrder = 1 + this.textLabel.childrenOrder = 2 + + this.canvas.dock = Dock.TOP + this.canvas.dockTop = 2f + + this.label.dock = Dock.LEFT + this.label.dockRight = 2f + + this.wang.dock = Dock.LEFT + this.wang.dockRight = 2f + + this.textLabel.dock = Dock.LEFT + this.textLabel.align = RenderGravity.CENTER_LEFT + + this.label.tooltips.add(TranslatableComponent("otm.gui.color.full.$label")) + this.label.align = RenderGravity.CENTER_RIGHT + } + + fun update(color: Either) { + wang.setColor(color) + + text.invoke(color)?.let { + textLabel.text = it + } + } + } + + val red = WangLine("red", RedColorWangPanel(screen, wangCanvas, callback = { onWangChoose(it) })) { TextComponent((it.map({ it }, { it.toRGBA() }).red * 255f).roundToInt().toString()) } + val green = WangLine("green", GreenColorWangPanel(screen, wangCanvas, callback = { onWangChoose(it) })) { TextComponent((it.map({ it }, { it.toRGBA() }).green * 255f).roundToInt().toString()) } + val blue = WangLine("blue", BlueColorWangPanel(screen, wangCanvas, callback = { onWangChoose(it) })) { TextComponent((it.map({ it }, { it.toRGBA() }).blue * 255f).roundToInt().toString()) } + + val hue = WangLine("hue", HueWangPanel(screen, wangCanvas, hueCallback = { onHueChoose(it) })) { it.map({ if (it.canRepresentHue()) it.toHSV() else null }, { it })?.let { TextComponent(it.hue.roundToInt().toString()) } } + val saturation = WangLine("saturation", SaturationWangPanel(screen, wangCanvas, saturationCallback = { onSaturationChoose(it) })) { it.map({ if (it.canRepresentHue()) it.toHSV() else null }, { it })?.let { TextComponent((it.saturation * 100f).roundToInt().toString() + "%") } } + val value = WangLine("value", ValueWangPanel(screen, wangCanvas, valueCallback = { onValueChoose(it) })) { it.map({ if (it.canRepresentHue()) it.toHSV() else null }, { it })?.let { TextComponent((it.value * 100f).roundToInt().toString() + "%") } } + + val wangs = listOf(red, green, blue, hue, saturation, value) + + init { + box.dock = Dock.LEFT + wangCanvas.dock = Dock.RIGHT + red.canvas.dockTop = 0f + + setColor(Either.right(HSVColor.WHITE)) + } + + companion object { + val paletteColors = listOf( + RGBAColor.rgb(0x9b59b6L), // Amethyst + RGBAColor.rgb(0x010101L), // Black + RGBAColor.rgb(0x0000ffL), // Blue + RGBAColor.rgb(0x8B4513L), // Brown + RGBAColor.rgb(0xe67e22L), // Carrot + RGBAColor.rgb(0xD2691EL), // Chocolate + RGBAColor.rgb(0xecf0f1L), // Clouds + RGBAColor.rgb(0xFF7F50L), // Coral + RGBAColor.rgb(0xDC143CL), // Crimson + RGBAColor.rgb(0x00FFFFL), // Cyan + RGBAColor.rgb(0x008B8BL), // DarkCyan + RGBAColor.rgb(0xBDB76BL), // DarkGold + RGBAColor.rgb(0xB8860BL), // DarkGoldenRod + RGBAColor.rgb(0x006400L), // DarkGreen + RGBAColor.rgb(0x16a085L), // DarkGreen + RGBAColor.rgb(0x8B008BL), // DarkMagenta + RGBAColor.rgb(0x556B2FL), // DarkOlive + RGBAColor.rgb(0xFF8C00L), // DarkOrange + RGBAColor.rgb(0x8B0000L), // DarkRed + RGBAColor.rgb(0xE9967AL), // DarkSalmon + RGBAColor.rgb(0x9400D3L), // DarkViolet + RGBAColor.rgb(0xFF1493L), // DeepPink + RGBAColor.rgb(0x00BFFFL), // DeepSkyBlue + RGBAColor.rgb(0x2ecc71L), // Emerald + RGBAColor.rgb(0xB22222L), // FireBrick + RGBAColor.rgb(0x228B22L), // ForestGreen + RGBAColor.rgb(0xFF00FFL), // Fuchsia + RGBAColor.rgb(0xDCDCDCL), // Gainsboro + RGBAColor.rgb(0xFFD700L), // Gold + RGBAColor.rgb(0xDAA520L), // GoldenRod + RGBAColor.rgb(0x00B000L), // Green + RGBAColor.rgb(0x808080L), // Grey + RGBAColor.rgb(0xFF69B4L), // HotPink + RGBAColor.rgb(0x4B0082L), // Indigo + RGBAColor.rgb(0xF0E68CL), // Khaki + RGBAColor.rgb(0xE6E6FAL), // Lavender + RGBAColor.rgb(0xFF9FF7L), // LavenderRose + RGBAColor.rgb(0xD3D3D3L), // LightGrey + RGBAColor.rgb(0x87CEFAL), // LightSkyBlue + RGBAColor.rgb(0xFFFFE0L), // LightYellow + RGBAColor.rgb(0x00ff00L), // Lime + RGBAColor.rgb(0x32CD32L), // LimeGreen + RGBAColor.rgb(0xBA55D3L), // MediumOrchid + RGBAColor.rgb(0x9370DBL), // MediumPurple + RGBAColor.rgb(0x7B68EEL), // MediumSlateBlue + RGBAColor.rgb(0x808000L), // Olive + RGBAColor.rgb(0x6B8E23L), // OliveGreen + RGBAColor.rgb(0xFFA500L), // Orange + RGBAColor.rgb(0xDA70D6L), // Orchid + RGBAColor.rgb(0xDB7093L), // PaleVioletRed + RGBAColor.rgb(0xCD853FL), // Peru + RGBAColor.rgb(0xFFC0CBL), // Pink + RGBAColor.rgb(0xB0E0E6L), // PowderBlue + RGBAColor.rgb(0xd35400L), // Pumpkin + RGBAColor.rgb(0x800080L), // Purple + RGBAColor.rgb(0xff0000L), // Red + RGBAColor.rgb(0x4169E1L), // RoyalBlue + RGBAColor.rgb(0xFA8072L), // Salmon + RGBAColor.rgb(0xF4A460L), // SandyBrown + RGBAColor.rgb(0x2E8B57L), // SeaGreen + RGBAColor.rgb(0xA0522DL), // Sienna + RGBAColor.rgb(0xbdc3c7L), // Silver + RGBAColor.rgb(0x87CEEBL), // SkyBlue + RGBAColor.rgb(0x708090L), // SlateGrey + RGBAColor.rgb(0x4682B4L), // SteelBlue + RGBAColor.rgb(0xf1c40fL), // SunFlower + RGBAColor.rgb(0x008080L), // Teal + RGBAColor.rgb(0xD8BFD8L), // Thistle + RGBAColor.rgb(0xEE82EEL), // Violet + ) + + fun > frame(screen: S, callback: Consumer, color: RGBAColor = RGBAColor.RED, title: Component? = TranslatableComponent("otm.gui.color_picker")): FramePanel { + return FramePanel.padded(screen, 164f, 118f, title).also { + ColorPickerPanel(screen, it, 0f, 0f, callback = callback).also { + it.dock = Dock.FILL + it.setColor(Either.left(color)) + } + + screen.addPanel(it) + it.toScreenCenter() + it.behaveAsWindow() + it.popup() + } + } + } +} diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/gradient_h.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/gradient_h.png new file mode 100644 index 0000000000000000000000000000000000000000..2a39ad8d4ae39a50aaa1f44e40b0c8572f05a007 GIT binary patch literal 627 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K56gb#`>zVA{<2r7mQtBO;fa8`Zx$)_E$wpM5O9lYt<{W}U#z}TlSIVb4{m+% z;CRy2gGVF7*~1+L{xB4l76z3}6#741B>2^Qex^@$0rVHG8{1>AWwl?_*q=V01uT==hAhh$GTRHqV}R zu5!M`nNyRTYW!?6FR*sX@6_A<=h)6C8x9yBb~Cf}mr)b*j@2nQ)Rxxz$W!PNXnIP# zNKbptc8k?lt+MY=-fs|cArLjjk(+X82%d1pO$#HJ@KfU<+PDw&-{z#Pa7XbFQ`BJcJ1E& z%j^o?vAXve*xL`dbZ)wCd++Y;ySMkJ-}?KP!E{SepR()p$G~V|OY(Mi0mTvn!%yek z^+1ZVz$3Dlfq`2Xgc%uT&5-~KvX^-Jy0SlK=M&K7S#V)KFHoq!)5S5Q;?~APeQ9c*r_RiK^KJjvXZx6IycrxoX@P}7fNVy?T4pI;7Mr-% R`dFad44$rjF6*2UngF&8@XG)I literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/gradient_v.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/gradient_v.png new file mode 100644 index 0000000000000000000000000000000000000000..cb1905189cd34b514b077bb9df5a2874c323feba GIT binary patch literal 682 zcmeAS@N?(olHy`uVBq!ia0vp^3JeU43><7g)}@6dWk60#rn7T^r?ay{K~a8MW=<*t zgT}<#iMAex9b}HiU-k;sQYsTDJP|PW%_60~rCqKY0&a1wwVDz0i`7?Zl8Ctb!L1J- z98bD>@MvT>d$^;(ABMux!l06gLjR|WL>;LpxYJ+$U9S8+!@|haRgxWytI{N2y2PA$ z8h-SFb`ys}iye>WnJbfL9@Viqe%-dFW^eZ=o%hA{eT+*Jj1H&^9iNdGaYXva=GoKE zRnE6Kb83=Pjh{{C1=ddaoqD_f9NYP1!vW*NZf3UrGHPPpu{!03+R|Ddc?w+uO;3pz z>1of|Zn65RRrdYK`wc=agc-#ww`^mXHo=8UDdkF_qo~-TEm=!ucwDZ#bJ+gXkKiYh zPKGinA7{!6P_(T3VE^Op+Q>QciY7Z1E_i-)oBgrI2YMH>ZhZT`F?YKk!++y~rKNwi zsu_IutXjO-wXfk|?t@3W7N4v>@RZNs(-QBtCmwaPoHlaonSaszY2(A_1@&j&uHD;z znO(s4B|a8caOMKHz7`jo{Os^{RnAKA4r`&`XyL OkY%2(elF{r5}E)QWA3*A literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/hsv.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/hsv.png new file mode 100644 index 0000000000000000000000000000000000000000..0c21edb22c8a64ff15a05989e49571614180a7d0 GIT binary patch literal 1881 zcmV-f2d4OmP)EX>4Tx04R}tkv&MmKpe$i(@Iq;B6bjQ$WWc^q9Tr^ibb$c+6t{Ym|Xe=O&XFE z7e~Rh;NZt%)xpJCR|i)?5c~jfb#YR3krMxx6k5c1aNLh~_a1le0HIlBsu_p@s%9DK zL|n|}SH<8ff(RglJ`73B)RURTEIh~8J$!t6^Clbe)Zdk+{#Iu{0 z&Uv3W%*v8Nd`>)R&;^Mfxh}i>#<}FMz%#=}Ha$-qCKgLwEO#+08!GV(aYRuy$`^7j zE1b7DtJOMd-;=*ERM1v3T&FpP1eTCQ3L<3GQ9%_JqO@wHm`Kxp+`~WW_*3MP$yEU( z#{z0lAvu2VKlt6PS)877lR|Nz=f$=^#)052&}!KB_pxoaP5}QiaHVzpwI(q4NqVEB zMUH^MZQ$a%qse=~K2h-P^xs+Wq|iHMDY$BSn|v00006VoOIv00000008+zyMF)x010qNS#tmY z3ljhU3ljkVnw%H_000McNliru=LZf5D+Qfna_0a51y)H!K~#9!ty}GO>oyD{+@{^$ z|6y<1><;_UWK$H10Oj=@9owmGN&EmoN(LhsZxQi+ZA(r1nvm=4bNk+{dipw@JcBaI)Uaaw}n8?*hCQ zzs&-FJbxR6dwa6pBiuhGzoEDv(=!X0&tv%}m?MCAPDuoX zLNdw0(=~^NMVCnQkHyqr*nv<8g*nmGFQ=)n&;k>4=3@H#4~^M4Z>?sERKUlUg>t1Ro>jI817kg5KtNnY(<=hXBCl!)8%;dh2^dNld=);7_{U-j zFu4>Br&rp6bYex(*$7iA0cJYm<5b!Kk>Wa_!U7z`ZEEU_R?I8os3Kd>Vt}athnT{+ z*O8175zqvMZfXEwyU?j%H$kFN51QG5>!M+>k2=Iu2&r;nHkFn0nxo4MB`bk}^el`b z(Ev|m)GirEqkyRWfkwo3%Zr^NOb5BWL`G&Ksutk#b%)u~&*?jvvSY4nW<0OIt;&cj zoRnsf&}9LyGdLu4(F~PbB-_gCXlkmNcB)!B49tS5+}G!^!Ch8#$_dM=GzL+!YNiGd z8OAOcG;zqmC#M7ov#$;_fMvN9Ie%uQN?_-J#rPch?G%7^ z3}>;%#zlq9DJj5AzAIKtJwu#yOl4nLW*bJ|*m711{WsRjZCK&}0B7tp1G6d}P>Z>R zTsp)8W@gPICOVrJ^Xr|Re6y#qk>@FoGk&iSt^)SeUKWU8vEj8&HQ(8AxI?Hrv6ij7 z!*p&6<`9N-G6vx6!mIYD&|sMJR#FxbA39j59Nt-#>=cF=dT#*QsHu_^rD%75qD#HZ zZgw^Wu_#wG7BJ8(e>ryKZsm3Lp92pJz3eRQxl}#x|0rkHVJj6tRV+chAA2jI6nUMq z^hZ&%#IrR1@y6@U44&lEFn<5P`YetOTW}y0; z6-k;q`bTl@=%0oQupP2gRSTy6)fXpF2XskI zMF-~x3ko7AJtVP*000AelkWi-f1rR&p;Nbb2$uZ?nn7d0mwM<2Xd8nmv=P*u3$_+R zN|w%%!AqtDlBKjzC^ZRq$$A}PIcK9gJ?T!iOz#K6I`bsG-}`s>?qGL!mk~wOYBfSB zh3QcCzDS0+uFD7^BnX0shuFho06-XH1OOs=W&LD&SP=mgG@DIADV_2Vf9neXjQ=s`ljgwJ@MH%EGLoJDqJ1~@-ImlnP_ z@2By&@B1^-GDDR}!4RcDe^Nn}k%}{d2um|SH18wohcN%skmu$2x{+rJ006Ks4AEq> z*3dNMlOjQP1c0oFaVtMi`H0M;A|r{6mPZi;ex8>tL$gB1^rzhbeAwHzO`6T7u+9Mh zR4SE16kV+mVB7YrHvj;rR;#g*Ao_pp4Y1f4$f{YZ)j}B|sitV@e+KiM`hp-(%K5?d z547x)5639E=O-t*bc1UHe}Dh68?4o8vVyg8^nZ@gvTtv0P;%dHZ^`TJZSwBof?1T( zXfs1K+*8Rrj*}@hF6qJS{^@a7PZ6xw>uO$#X>0SqB|VrUy*TEvHy)GIa#=V=uLOI& z9_jUZg-C}q9zQLYf63l>EG3_40G@bJjDYd}q7g*o6Q{vOqoLH%C^kh(KZ^L6?oDzBa|3pM8`!bg(;$5o(V235rC-yvhiF5wA*bZg*eYAZjEO-8&D~R zNho2+As0%FJKc%Ja5#+C3x#QhN=VP5SBtU+DC^>9W!<1^e`@H!*OxY4HfuLn|+;v(KMUaxVsh|GOJ}v$ONq4e~oVSuq-oa#Qx~*I&Hw-5pBo&;31lwY5dQTwNuf z4MyZtjid{|{r9u`P46h*S%CK}*2`fSGT9E1D)~+CXm;_&SVVU+k&aQbKuWIz05I2e zr9@TE1=4u@d|+dPbSIO!U!egs=5W%PKxXoyXuujlxDLo6w_zD|022-92w0aLp){$$ zla?8wgdw+Vf@x*~S@_GwCfK@c_8Wv6B&%v~PR{#J207*qoM6N<$f><26;Q#;t delta 931 zcmV;U16=(53gQZ|x&bx+0RI60puMM)00009a7bBm000id000id0mpBsWB>pF2XskI zMF-~x2?!1!6(wWC000ADlkWi-e;|WQp;Nbb2$uZ?nn9yMmwM<2Xd8nmv=P*u3$_+R zN|w%+!AqtFnx(W*C^ZRq$$A}PDQ9Dyo^&T$ruPF8U3ik;@BO*=-U%v|3L}!J*Xx8* z3iGAteW47oZJQB7i0}LN53&2l005Srk=9S7hY=Exf$O@2Qaa}muP*>FfBwfY5WO!m zdrps%!uPTyWrHBd%cH5l>tW>eBP&9g*tX4V+a|v6GpvWlp0E=>E(46*^L=sG#aITCXL5E&x=Tl3{@gq3K6MQ zMu@}O3=r1+b&==g_PlFu^l4-K($&e#Ad2A0!-74W&;3#TCKJ+65{^9^#)iT z3`8AayWK_^A!$!hG7aWg`h4G)%K72F!KZ&_BR)c8h^qx;9FJvEzPqtTG_ zQiicMD|w#u@|wrtbV|<4<=8d46YTfM)MS*`e^7)W&wE~E1VdF0uWEl~djOeK;7N;&P-2V`6&Ixx<{2n+knhwn1m9B9I{bj{MVgT7>~zczfhQAsD$(^x?2dZ7?J!Ya~_p?Y)iecb$`bs{rp=te1lzV4@Qu zS@OHiNp$hXSVnI)6RuHJAf?v<0GMstLZUL?1=4u@cxQ+7X0wIAu?A3>!%5!+GLw&s z2CNZc`+yvBVH?)54`8AJ9Rb^NB9tZ-c+w&xlrZGhO)yO*5QV>JjWPgFyhuh+QT|X> zKsGhD0Y=fhtD&Kxp`oFnp`oFnp`oFnp`oFnp`no<{sG{Z!WzT57w-T7002ovPDHLk FV1j=wyPN<3 From d0334e761d3c5795bc232f452d0c672097b49c34 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sat, 15 Jul 2023 21:02:47 +0300 Subject: [PATCH 0760/1199] better colors for jade bars --- .../ru/dbotthepony/mc/otm/compat/jade/JadeCompatData.kt | 7 +++++++ .../mc/otm/compat/jade/providers/MatterStorageProvider.kt | 3 ++- .../mc/otm/compat/jade/providers/MatteryEnergyProvider.kt | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/JadeCompatData.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/JadeCompatData.kt index 2423d7ffb..7678283fb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/JadeCompatData.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/JadeCompatData.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.compat.jade import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.OverdriveThatMatters.loc +import ru.dbotthepony.mc.otm.core.math.RGBAColor object JadeUids { val MATTERY_ENERGY: ResourceLocation = loc("mattery_energy") @@ -20,3 +21,9 @@ object JadeTagKeys { val MATTER_BOTTLER_DATA = "otmJadeMatterBottlerData" val MATTER_RECONSTRUCTOR_DATA = "otmJadeMatterReconstructorData" } + +object JadeColors { + val ENERGY_COLOR = RGBAColor(231, 232, 0) + val ENERGY_COLOR2 = RGBAColor(192, 193, 0) + val MATTER_COLOR = RGBAColor(71, 255, 187) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterStorageProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterStorageProvider.kt index 43620216a..1ed43911c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterStorageProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterStorageProvider.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.compat.jade.providers import net.minecraft.nbt.CompoundTag import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.compat.jade.JadeColors import ru.dbotthepony.mc.otm.compat.jade.JadeTagKeys import ru.dbotthepony.mc.otm.compat.jade.JadeUids import ru.dbotthepony.mc.otm.core.TranslatableComponent @@ -43,7 +44,7 @@ object MatterStorageProvider : IBlockComponentProvider, IServerDataProvider Date: Sat, 15 Jul 2023 22:48:14 +0300 Subject: [PATCH 0761/1199] bump forge to recommended build --- gradle.properties | 2 +- src/main/resources/META-INF/mods.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 6029c59d9..eaa8ca684 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,7 +17,7 @@ jei_mc_version=1.20 curios_mc_version=1.20 forge_gradle_version=[6.0,6.2) -forge_version=47.0.19 +forge_version=47.1.0 mixingradle_version=0.7.33 mixin_version=0.8.5 diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index a3199ff6b..841489a93 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -43,7 +43,7 @@ Matter. Energy. Combined. # Does this dependency have to exist - if not, ordering below must be specified mandatory=true #mandatory # The version range of the dependency - versionRange="[47.0.1,)" #mandatory + versionRange="[47.1.0,)" #mandatory # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory ordering="NONE" # Side this dependency is applied on - BOTH, CLIENT or SERVER From 6a5924267a597851b1dd066b0b174faa34703fc2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 18 Jul 2023 00:52:42 +0700 Subject: [PATCH 0762/1199] Make callback be mutable property --- .../ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt index af60b2190..df4bab6d9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt @@ -500,7 +500,7 @@ open class ColorPickerPanel( y: Float = 0f, width: Float = 164f, height: Float = 118f, - val callback: Consumer? = null + var callback: Consumer? = null ) : EditablePanel(screen, parent, x, y, width, height) { open fun onColorChanged(color: RGBAColor) { callback?.accept(color) From 687b5c97262a3dfba7c0b517f742b1fe48a7569d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 18 Jul 2023 00:56:16 +0700 Subject: [PATCH 0763/1199] Move extension functions to interface itself, add box() GetterSetter --- .../dbotthepony/mc/otm/core/GetterSetter.kt | 57 ++++++++++++++----- 1 file changed, 43 insertions(+), 14 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt index b64cbd207..700b2c868 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt @@ -27,6 +27,35 @@ interface GetterSetter : Supplier, Consumer, ReadWriteProperty accept(value) } + fun asGetterOnly(): GetterSetter { + val self = this + + return object : GetterSetter { + override fun get(): V { + return self.get() + } + + override fun accept(t: V) { + } + } + } + + fun watch(watch: (old: V, new: V) -> Unit): GetterSetter { + val self = this + + return object : GetterSetter { + override fun get(): V { + return self.get() + } + + override fun accept(t: V) { + val old = get() + self.accept(t) + watch.invoke(old, t) + } + } + } + companion object { fun of(getter: Supplier, setter: Consumer): GetterSetter { return object : GetterSetter { @@ -63,6 +92,20 @@ interface GetterSetter : Supplier, Consumer, ReadWriteProperty } } } + + fun box(value: V): GetterSetter { + return object : GetterSetter { + private var value = value + + override fun get(): V { + return value + } + + override fun accept(t: V) { + this.value = t + } + } + } } } @@ -84,18 +127,4 @@ fun KMutableProperty0.asGetterSetter(watch: ((old: V, new: V) -> Unit)? = } } -fun GetterSetter.watch(watch: (old: V, new: V) -> Unit): GetterSetter { - return object : GetterSetter { - override fun get(): V { - return this@watch.get() - } - - override fun accept(t: V) { - val old = get() - this@watch.accept(t) - watch.invoke(old, t) - } - } -} - fun KMutableProperty0.asGetterOnly() = GetterSetter.of(Supplier { this.get() }, Consumer { /* do nothing */ }) From 0e9a480dd8e225e899b084aa5fd17fdb8f416131 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 18 Jul 2023 00:57:24 +0700 Subject: [PATCH 0764/1199] Make checkboxes accept GetterSetter as checking property --- .../panels/button/CheckBoxInputPanel.kt | 12 ++-------- .../panels/button/CheckBoxLabelInputPanel.kt | 5 ++-- .../panels/button/CheckBoxLabelPanel.kt | 9 ++++---- .../screen/panels/button/CheckBoxPanel.kt | 23 +++++++------------ 4 files changed, 17 insertions(+), 32 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxInputPanel.kt index ff562de31..7d266e86b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxInputPanel.kt @@ -8,7 +8,7 @@ import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.value import ru.dbotthepony.mc.otm.menu.input.IPlayerInputWithFeedback -open class CheckBoxInputPanel @JvmOverloads constructor( +open class CheckBoxInputPanel( screen: S, parent: EditablePanel<*>?, val widget: IPlayerInputWithFeedback, @@ -16,16 +16,8 @@ open class CheckBoxInputPanel @JvmOverloads constructor( y: Float = 0f, width: Float = REGULAR_DIMENSIONS + 120f, height: Float = REGULAR_DIMENSIONS -) : CheckBoxPanel(screen, parent, x, y, width, height) { - override var isChecked: Boolean - get() = widget.value - set(value) {} - +) : CheckBoxPanel(screen, parent, x, y, width, height, isChecked = widget) { override var isDisabled: Boolean get() = !widget.test(minecraft.player) set(value) {} - - override fun onClick(mouseButton: Int) { - widget.accept(!isChecked) - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelInputPanel.kt index 905bfff6a..ac46a9b5a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelInputPanel.kt @@ -9,17 +9,16 @@ import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.IPlayerInputWithFeedback import kotlin.math.roundToInt -open class CheckBoxLabelInputPanel @JvmOverloads constructor( +open class CheckBoxLabelInputPanel( screen: S, parent: EditablePanel<*>?, - widget: IPlayerInputWithFeedback, + val widget: IPlayerInputWithFeedback, text: Component, x: Float = 0f, y: Float = 0f, width: Float = CheckBoxPanel.REGULAR_DIMENSIONS + 120f, height: Float = CheckBoxPanel.REGULAR_DIMENSIONS ) : AbstractCheckBoxLabelPanel(screen, parent, x, y, width, height) { - val widget get() = checkbox.widget override val checkbox = CheckBoxInputPanel(screen = screen, parent = this, widget = widget, x = 0f, y = 0f, width = CheckBoxPanel.REGULAR_DIMENSIONS, height = CheckBoxPanel.REGULAR_DIMENSIONS) override val label = Label(screen, this, CheckBoxPanel.REGULAR_DIMENSIONS + 4f, 4f, text = text) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelPanel.kt index e9dd03780..19893eb3f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxLabelPanel.kt @@ -4,17 +4,18 @@ import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.Label -import kotlin.math.roundToInt +import ru.dbotthepony.mc.otm.core.GetterSetter -open class CheckBoxLabelPanel @JvmOverloads constructor( +open class CheckBoxLabelPanel( screen: S, parent: EditablePanel<*>?, text: Component, x: Float = 0f, y: Float = 0f, width: Float = CheckBoxPanel.REGULAR_DIMENSIONS + 120f, - height: Float = CheckBoxPanel.REGULAR_DIMENSIONS + height: Float = CheckBoxPanel.REGULAR_DIMENSIONS, + isChecked: GetterSetter = GetterSetter.box(false) ) : AbstractCheckBoxLabelPanel(screen, parent, x, y, width, height) { - override val checkbox = CheckBoxPanel(screen, this, 0f, 0f, CheckBoxPanel.REGULAR_DIMENSIONS, CheckBoxPanel.REGULAR_DIMENSIONS) + override val checkbox = CheckBoxPanel(screen, this, 0f, 0f, isChecked = isChecked) override val label = Label(screen, this, CheckBoxPanel.REGULAR_DIMENSIONS + 4f, 4f, text = text) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt index 8cb9bc42b..361e04a48 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt @@ -1,27 +1,21 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button -import com.mojang.blaze3d.platform.InputConstants -import com.mojang.blaze3d.vertex.PoseStack -import it.unimi.dsi.fastutil.booleans.BooleanConsumer import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel -import ru.dbotthepony.mc.otm.core.TextComponent +import ru.dbotthepony.mc.otm.core.GetterSetter -open class CheckBoxPanel @JvmOverloads constructor( +open class CheckBoxPanel( screen: S, parent: EditablePanel<*>?, x: Float = 0f, y: Float = 0f, width: Float = REGULAR_DIMENSIONS, height: Float = REGULAR_DIMENSIONS, - var onPress: BooleanConsumer? = null + open val isChecked: GetterSetter = GetterSetter.box(false) ) : AbstractButtonPanel(screen, parent, x, y, width, height) { - open var isChecked = false - open val IDLE_UNCHECKED: AbstractMatterySprite = Companion.IDLE_UNCHECKED open val IDLE_CHECKED: AbstractMatterySprite = Companion.IDLE_CHECKED open val HOVERED_UNCHECKED: AbstractMatterySprite = Companion.HOVERED_UNCHECKED @@ -33,26 +27,26 @@ open class CheckBoxPanel @JvmOverloads constructor( protected fun renderCheckboxBackground(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (isDisabled) { - if (isChecked) { + if (isChecked.get()) { DISABLED_CHECKED.render(graphics, width = width, height = height) } else { DISABLED_UNCHECKED.render(graphics, width = width, height = height) } } else { if (isPressed) { - if (isChecked) { + if (isChecked.get()) { PRESSED_CHECKED.render(graphics, width = width, height = height) } else { PRESSED_UNCHECKED.render(graphics, width = width, height = height) } } else if (isHovered) { - if (isChecked) { + if (isChecked.get()) { HOVERED_CHECKED.render(graphics, width = width, height = height) } else { HOVERED_UNCHECKED.render(graphics, width = width, height = height) } } else { - if (isChecked) { + if (isChecked.get()) { IDLE_CHECKED.render(graphics, width = width, height = height) } else { IDLE_UNCHECKED.render(graphics, width = width, height = height) @@ -66,8 +60,7 @@ open class CheckBoxPanel @JvmOverloads constructor( } override fun onClick(mouseButton: Int) { - isChecked = !isChecked - onPress?.accept(isChecked) + isChecked.accept(!isChecked.get()) } companion object { From 25875b162e88eeaa0b66455dc88458db8f7e2957 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 18 Jul 2023 01:54:21 +0700 Subject: [PATCH 0765/1199] Improve blocker flashing --- .../otm/client/screen/panels/EditablePanel.kt | 46 +++++++------------ 1 file changed, 17 insertions(+), 29 deletions(-) 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 dc154f555..cad6d06bb 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 @@ -403,12 +403,10 @@ open class EditablePanel @JvmOverloads constructor( var isFlashing: Boolean get() { - if (flashingSince == null) { - return false - } + val flashingSince = flashingSince ?: return false - if (flashingSince!!.millis >= 1200L) { - flashingSince = null + if (flashingSince.millis >= 1200L) { + this.flashingSince = null return false } @@ -416,8 +414,14 @@ open class EditablePanel @JvmOverloads constructor( } set(value) { if (value) { - flashingSince = SystemTime() - popup() + if (screen is MatteryScreen<*>) { + screen.popup(findAbsoluteRoot() as EditablePanel>) + } + + if (!flashAnyBlocker(true)) { + flashingSince = SystemTime() + findAbsoluteRoot().requestFocus() + } } else { flashingSince = null } @@ -466,23 +470,7 @@ open class EditablePanel @JvmOverloads constructor( } protected fun flashAnyBlocker(doFlash: Boolean = true): Boolean { - var blockingWindow = blockingWindow - var parent = parent - - while (blockingWindow == null && parent != null) { - blockingWindow = parent.blockingWindow - parent = parent.parent - } - - if (blockingWindow == null) { - return flashAnyBlockerInner(doFlash) - } - - if (doFlash) { - blockingWindow.isFlashing = true - } - - return true + return findAbsoluteRoot().flashAnyBlockerInner(doFlash) } @JvmOverloads @@ -1732,17 +1720,17 @@ open class EditablePanel @JvmOverloads constructor( isRemoved = true } - fun popup(focus: Boolean = true) { + fun popup(focus: Boolean = true, doFlash: Boolean = true) { if (isRemoved) { return } - if (screen is MatteryScreen<*> && parent == null) { - screen.popup(this as EditablePanel>) + if (screen is MatteryScreen<*>) { + screen.popup(findAbsoluteRoot() as EditablePanel>) } - if (focus) { - requestFocus() + if (focus && !flashAnyBlocker(doFlash)) { + findAbsoluteRoot().requestFocus() } } From a707e49b8c7cbd054bcbf91f24d3ae7af50d7bc6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 18 Jul 2023 01:55:17 +0700 Subject: [PATCH 0766/1199] Exopack coloring and toggle exopack glowing --- .../mc/otm/datagen/lang/English.kt | 11 +- .../mc/otm/datagen/lang/Russian.kt | 13 ++- .../mc/otm/client/model/ExosuitModel.java | 41 +++++-- .../otm/capability/MatteryPlayerCapability.kt | 14 ++- .../mc/otm/client/render/Widgets8.kt | 5 +- .../screen/panels/EntityRendererPanel.kt | 109 +++++++++++++++--- .../network/MatteryPlayerNetworkChannel.kt | 61 +++++++++- .../textures/gui/widgets_8.png | Bin 915 -> 964 bytes .../textures/gui/widgets_8.xcf | Bin 6564 -> 7074 bytes 9 files changed, 215 insertions(+), 39 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 5c97f4607..6cb9a002e 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -136,11 +136,16 @@ private fun misc(provider: MatteryLanguageProvider) { gui("recipe.ticks", "%s Ticks") gui("exopack", "Exopack Inventory") + + gui("exopack.customize", "Customize Exopack appearance") + gui("exopack.customization", "Exopack appearance settings") + gui("exopack.go_back", "Open vanilla inventory") gui("exopack.go_in", "Open Exopack inventory") - gui("exopack.toggle_visibility", "Toggle Exopack visibility") - gui("exopack.change_color", "Customize Exopack color") - gui("exopack.change_color2", "Press Middle Mouse Button to remove color") + gui("exopack.toggle_visibility", "Visibile on player") + gui("exopack.toggle_glow", "Glows in dark") + gui("exopack.change_color", "Customize color") + gui("exopack.change_color2", "Remove color") gui("exopack.probe1", "This little device feels unnatural to touch, it is almost certainly resilient to any possible attempt to break it open.") gui("exopack.probe2", "There is fingerprint reader built into one of sides which gently glow when touched.") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 34b334622..6fbffacf8 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -144,11 +144,16 @@ private fun misc(provider: MatteryLanguageProvider) { gui("recipe.ticks", "%s Тиков") gui("exopack", "Инвентарь Экзопака") + + gui("exopack.customize", "Изменить внешний вид Экзопака") + gui("exopack.customization", "Внешний вид Экзопака") + gui("exopack.go_back", "Открыть обычный инвентарь") - gui("exopack.go_in", "Открыть инвентарь экзопака") - gui("exopack.toggle_visibility", "Переключить отображение Экзопака") - gui("exopack.change_color", "Изменить окраску Экзопака") - gui("exopack.change_color2", "Нажмите среднюю кнопку мыши для сброса окраски") + gui("exopack.go_in", "Открыть инвентарь Экзопака") + gui("exopack.toggle_visibility", "Отображать на игроке") + gui("exopack.toggle_glow", "Свечение в темноте") + gui("exopack.change_color", "Изменить окраску") + gui("exopack.change_color2", "Убрать окраску") gui("exopack.probe1", "Данное маленькое устройство необычно на ощупь, а так же неприступно для любых попыток вскрыть.") gui("exopack.probe2", "На одной из сторон данного устройства находится сканер отпечатка, который тускло загорается при касании.") diff --git a/src/main/java/ru/dbotthepony/mc/otm/client/model/ExosuitModel.java b/src/main/java/ru/dbotthepony/mc/otm/client/model/ExosuitModel.java index 12c4f44e7..fa3b2878a 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/client/model/ExosuitModel.java +++ b/src/main/java/ru/dbotthepony/mc/otm/client/model/ExosuitModel.java @@ -32,6 +32,7 @@ public final class ExosuitModel { public static final HumanoidModel modelGlow; public static final ResourceLocation texture = new ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/models/armor/exosuit.png"); + public static final ResourceLocation textureColor = new ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/models/armor/exosuit_color.png"); static { MeshDefinition meshdefinition = new MeshDefinition(); @@ -138,14 +139,38 @@ public final class ExosuitModel { 1f, 1f, 1f, 1f ); - modelGlow.renderToBuffer( - poseStack, - bufferSource.getBuffer(RenderType.entityTranslucentEmissive(texture)), - packedLight, - overlayCoords, - // rgba - 1f, 1f, 1f, 1f - ); + var color = cap.resolve().get().getExopackColor(); + + if (color != null) { + modelNormal.renderToBuffer( + poseStack, + bufferSource.getBuffer(RenderType.entityCutoutNoCull(textureColor)), + packedLight, + overlayCoords, + // rgba + color.getRed(), color.getGreen(), color.getBlue(), 1f + ); + } + + if (cap.resolve().get().getExopackGlows()) { + modelGlow.renderToBuffer( + poseStack, + bufferSource.getBuffer(RenderType.entityTranslucentEmissive(texture)), + packedLight, + overlayCoords, + // rgba + 1f, 1f, 1f, 1f + ); + } else { + modelGlow.renderToBuffer( + poseStack, + bufferSource.getBuffer(RenderType.entityCutoutNoCull(texture)), + packedLight, + overlayCoords, + // rgba + 1f, 1f, 1f, 1f + ); + } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index b85fbebc7..1896bbc82 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -32,7 +32,6 @@ import net.minecraft.world.item.Items import net.minecraft.world.item.ProjectileWeaponItem import net.minecraft.world.item.crafting.RecipeManager import net.minecraft.world.item.crafting.RecipeType -import net.minecraft.world.item.enchantment.EnchantmentHelper.hasVanishingCurse import net.minecraft.world.level.GameRules import net.minecraft.world.level.Level import net.minecraft.world.phys.Vec3 @@ -83,15 +82,16 @@ import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.collect.UUIDIntModifiersMap import ru.dbotthepony.mc.otm.core.collect.filter import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.minus import ru.dbotthepony.mc.otm.core.nbt.getByteList import ru.dbotthepony.mc.otm.core.nbt.getCompoundList import ru.dbotthepony.mc.otm.core.nbt.getIntList import ru.dbotthepony.mc.otm.core.nbt.getStringList import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.core.util.BooleanValueCodec import ru.dbotthepony.mc.otm.core.util.IntValueCodec import ru.dbotthepony.mc.otm.core.util.ItemValueCodec +import ru.dbotthepony.mc.otm.core.util.RGBCodec import ru.dbotthepony.mc.otm.core.util.Savetables import ru.dbotthepony.mc.otm.core.util.TickList import ru.dbotthepony.mc.otm.core.util.UUIDValueCodec @@ -211,6 +211,13 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial */ var displayExoPack by publicSynchronizer.bool(true).property + /** + * Whenever to render Exopack glow in dark + */ + var exopackGlows by publicSynchronizer.bool(true).property + + var exopackColor by publicSynchronizer.Field(null, RGBCodec.nullable) + /** * Tick event schedulers */ @@ -499,6 +506,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial savetables.stateful(::exoPackChargeSlots) savetables.float(::exoPackSmelterExperience) savetables.bool(::isExoPackSmeltingInstalled) + + savetables.codecNullable(::exopackColor, RGBAColor.CODECRGB) + savetables.bool(::exopackGlows) } fun invalidateNetworkState() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt index 3a8f5ba75..3cf7bbf71 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt @@ -21,6 +21,7 @@ object Widgets8 { val ARROW_PAINTED_UP = GRID[1, 2] val MINUS = GRID[1, 3] - val EXOSUIT_SHOWN = GRID[2, 1] - val EXOSUIT_HIDDEN = GRID[3, 1] + val EXOPACK_SHOWN = GRID[2, 1] + val EXOPACK_HIDDEN = GRID[3, 1] + val EXOPACK_COLOR = GRID[4, 1] } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt index def0e809d..a4c1608cf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt @@ -1,24 +1,39 @@ package ru.dbotthepony.mc.otm.client.screen.panels -import com.mojang.blaze3d.vertex.PoseStack +import com.mojang.blaze3d.platform.InputConstants +import it.unimi.dsi.fastutil.booleans.BooleanConsumer +import net.minecraft.ChatFormatting import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen import net.minecraft.client.gui.screens.inventory.InventoryScreen import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.player.Player +import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.render.Widgets8 import ru.dbotthepony.mc.otm.client.render.sprite import ru.dbotthepony.mc.otm.client.screen.ExoPackInventoryScreen +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.button.ButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.CheckBoxLabelPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.SmallBooleanRectangleButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.SmallRectangleButtonPanel import ru.dbotthepony.mc.otm.compat.cos.CosmeticToggleRenderButton import ru.dbotthepony.mc.otm.compat.cos.isCosmeticArmorLoaded +import ru.dbotthepony.mc.otm.core.GetterSetter +import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.asGetterOnly -import ru.dbotthepony.mc.otm.network.DisplayExosuitPacket -import ru.dbotthepony.mc.otm.network.HideExosuitPacket +import ru.dbotthepony.mc.otm.core.math.RGBAColor +import ru.dbotthepony.mc.otm.network.DisableExopackGlowPacket +import ru.dbotthepony.mc.otm.network.DisplayExopackPacket +import ru.dbotthepony.mc.otm.network.EnableExopackGlowPacket +import ru.dbotthepony.mc.otm.network.HideExopackPacket import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel +import ru.dbotthepony.mc.otm.network.ResetExopackColorPacket +import ru.dbotthepony.mc.otm.network.SetExopackColorPacket +import java.util.function.IntConsumer private fun calculateScale(width: Float, height: Float): Int { val aspectRatio = width / height @@ -34,6 +49,76 @@ private fun calculateScale(width: Float, height: Float): Int { } } +private fun createExopackAppearanceWindow(screen: MatteryScreen<*>, matteryPlayer: MatteryPlayerCapability): FramePanel<*> { + val frame = FramePanel.padded(screen, width = 200f, height = 90f, title = TranslatableComponent("otm.gui.exopack.customization")) + + screen.addPanel(frame) + + frame.toScreenCenter() + frame.behaveAsWindow() + frame.requestFocus() + + CheckBoxLabelPanel( + screen, + frame, + text = TranslatableComponent("otm.gui.exopack.toggle_visibility"), + isChecked = GetterSetter.of( + { + matteryPlayer.displayExoPack + }, + { + if (it) { + MatteryPlayerNetworkChannel.sendToServer(DisplayExopackPacket) + } else { + MatteryPlayerNetworkChannel.sendToServer(HideExopackPacket) + } + } + ) + ).also { + it.dock = Dock.TOP + it.dockTop = 2f + } + + CheckBoxLabelPanel( + screen, + frame, + text = TranslatableComponent("otm.gui.exopack.toggle_glow"), + isChecked = GetterSetter.of( + { + matteryPlayer.exopackGlows + }, + { + if (it) { + MatteryPlayerNetworkChannel.sendToServer(EnableExopackGlowPacket) + } else { + MatteryPlayerNetworkChannel.sendToServer(DisableExopackGlowPacket) + } + } + ) + ).also { + it.dock = Dock.TOP + it.dockTop = 2f + } + + ButtonPanel(screen, frame, label = TranslatableComponent("otm.gui.exopack.change_color"), onPress = IntConsumer { + frame.blockingWindow = ColorPickerPanel.frame( + screen, + callback = { MatteryPlayerNetworkChannel.sendToServer(SetExopackColorPacket(it)) }, + color = matteryPlayer.exopackColor ?: RGBAColor.WHITE, + title = TranslatableComponent("otm.gui.exopack.change_color")) + }).also { + it.dock = Dock.TOP + it.dockTop = 2f + } + + ButtonPanel(screen, frame, label = TranslatableComponent("otm.gui.exopack.change_color2"), onPress = IntConsumer { MatteryPlayerNetworkChannel.sendToServer(ResetExopackColorPacket) }).also { + it.dock = Dock.TOP + it.dockTop = 2f + } + + return frame +} + class EntityRendererPanel @JvmOverloads constructor( screen: S, parent: EditablePanel<*>?, @@ -67,21 +152,15 @@ class EntityRendererPanel @JvmOverloads constructor( if (entity is Player) { val matteryPlayer = entity.matteryPlayer - if (matteryPlayer != null && matteryPlayer.hasExoPack) { - exosuitButton = SmallBooleanRectangleButtonPanel(screen, this, this.width - 2f - SmallBooleanRectangleButtonPanel.SIZE, 2f, - prop = matteryPlayer::displayExoPack.asGetterOnly(), - skinElementActive = Widgets8.EXOSUIT_SHOWN, - skinElementInactive = Widgets8.EXOSUIT_HIDDEN, - onChange = { - if (it) { - MatteryPlayerNetworkChannel.sendToServer(DisplayExosuitPacket) - } else { - MatteryPlayerNetworkChannel.sendToServer(HideExosuitPacket) - } + if (matteryPlayer != null && matteryPlayer.hasExoPack && screen is MatteryScreen<*>) { + exosuitButton = SmallRectangleButtonPanel(screen, this, this.width - 2f - SmallBooleanRectangleButtonPanel.SIZE, 2f, + skinElement = Widgets8.EXOPACK_SHOWN, + onPress = { + blockingWindow = createExopackAppearanceWindow(screen, matteryPlayer) } ) - exosuitButton.tooltips.add(TranslatableComponent("otm.gui.exopack.toggle_visibility")) + exosuitButton.tooltips.add(TranslatableComponent("otm.gui.exopack.customize")) } else { exosuitButton = null } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt index a1364a351..d2a766275 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt @@ -28,6 +28,7 @@ import ru.dbotthepony.mc.otm.client.render.GlitchRenderer import ru.dbotthepony.mc.otm.client.render.ShockwaveRenderer import ru.dbotthepony.mc.otm.container.get import ru.dbotthepony.mc.otm.container.set +import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.readItemType import ru.dbotthepony.mc.otm.core.writeItemType @@ -496,7 +497,7 @@ class ShockwaveEffectPacket(val pos: Vector) : MatteryPacket { } } -object DisplayExosuitPacket : MatteryPacket { +object DisplayExopackPacket : MatteryPacket { override fun write(buff: FriendlyByteBuf) {} override fun play(context: Supplier) { @@ -505,7 +506,7 @@ object DisplayExosuitPacket : MatteryPacket { } } -object HideExosuitPacket : MatteryPacket { +object HideExopackPacket : MatteryPacket { override fun write(buff: FriendlyByteBuf) {} override fun play(context: Supplier) { @@ -514,6 +515,52 @@ object HideExosuitPacket : MatteryPacket { } } +object EnableExopackGlowPacket : MatteryPacket { + override fun write(buff: FriendlyByteBuf) {} + + override fun play(context: Supplier) { + context.packetHandled = true + context.sender?.matteryPlayer?.exopackGlows = true + } +} + +object DisableExopackGlowPacket : MatteryPacket { + override fun write(buff: FriendlyByteBuf) {} + + override fun play(context: Supplier) { + context.packetHandled = true + context.sender?.matteryPlayer?.exopackGlows = false + } +} + +object ResetExopackColorPacket : MatteryPacket { + override fun write(buff: FriendlyByteBuf) {} + + override fun play(context: Supplier) { + context.packetHandled = true + context.sender?.matteryPlayer?.exopackColor = null + } +} + +data class SetExopackColorPacket(val color: RGBAColor) : MatteryPacket { + override fun write(buff: FriendlyByteBuf) { + buff.writeFloat(color.red) + buff.writeFloat(color.green) + buff.writeFloat(color.blue) + } + + override fun play(context: Supplier) { + context.packetHandled = true + context.sender?.matteryPlayer?.exopackColor = color + } + + companion object { + fun read(buff: FriendlyByteBuf): SetExopackColorPacket { + return SetExopackColorPacket(RGBAColor(buff.readFloat(), buff.readFloat(), buff.readFloat())) + } + } +} + class SetInventoryFilterPacket(val type: Type, val slot: Int, val item: Item?) : MatteryPacket { enum class Type { INVENTORY, @@ -559,7 +606,7 @@ class SetInventoryFilterPacket(val type: Type, val slot: Int, val item: Item?) : } object MatteryPlayerNetworkChannel : MatteryNetworkChannel( - version = "3", + version = "4", name = "player" ) { fun register() { @@ -590,8 +637,12 @@ object MatteryPlayerNetworkChannel : MatteryNetworkChannel( add(GlitchPacket::class, GlitchPacket.Companion::read, PLAY_TO_CLIENT) add(ShockwaveEffectPacket::class, ShockwaveEffectPacket.Companion::read, PLAY_TO_CLIENT) - add(DisplayExosuitPacket::class, { DisplayExosuitPacket }, PLAY_TO_SERVER) - add(HideExosuitPacket::class, { HideExosuitPacket }, PLAY_TO_SERVER) + add(DisplayExopackPacket::class, { DisplayExopackPacket }, PLAY_TO_SERVER) + add(HideExopackPacket::class, { HideExopackPacket }, PLAY_TO_SERVER) + add(EnableExopackGlowPacket::class, { EnableExopackGlowPacket }, PLAY_TO_SERVER) + add(DisableExopackGlowPacket::class, { DisableExopackGlowPacket }, PLAY_TO_SERVER) + add(ResetExopackColorPacket::class, { ResetExopackColorPacket }, PLAY_TO_SERVER) + add(SetExopackColorPacket::class, SetExopackColorPacket.Companion::read, PLAY_TO_SERVER) add(SetInventoryFilterPacket::class, SetInventoryFilterPacket.Companion::read, PLAY_TO_SERVER) } diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets_8.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets_8.png index 8144a8fa67cf6621d891b5f0236cc3d7723a3318..e39800d868cd69d71ef872f6020ac8129475247a 100644 GIT binary patch delta 913 zcmV;C18)422gC=EL4VUqRVpHO5OK&*o$R6_j-`r4uu$3xtvZ-o`UOoIk`xz5!L{Jv z$70pN#aUMeS3wZ`0C9D3Qgo3L|Cbb6#CUMrk9YSTckck9S!Jpjhyki*8RK2h-P^xs+Wq|iHMDY$BSn|v00006VoOIv000000Dl1aL%V+f000SaNLh0L01FcU z01FcV0GgZ_00007bV*G`2j>S51r{5<;PVUs00F^CL_t(&-tAbsPQx%1J+4a2))`TS zj%+YhrOcW5fG%`GLdrycfQcXIR*AJN{Qy3J5@iY-BSawPZqUU{u3X2C9h%UGeYWV> z(Y?pV_kZ4mc%Da*fh0)?b{JIv=yW<#G7Q6|XG$pr078gVlq{Zc4B{Fc&#zN)e-@w! z@PVm<)CI2NMUjd?#WXpS6E$%NLteh%>!W+ujDXcKxrDSnCz&^?!O&ax$4LJrC!U-t47CnNFut5xd(9AHbeSK$}IECyyH?wOAO015yANkvXXu0mjf6d3G6miHt ztRyMK=fvX%U6A;Z>$1yloQn<%JTq)$QuD-NVzJo4atE`Lp%PCMM-)|~d?D+y!g-6c zTB)(tJ^2fRd2J=lb($lHV+jc)AwotCWmI4xN~=bSi4^U}Jp99sKS?f`TxBqFET9S% zlH&*egWuhng@36@Hz^ncx?gPjV-)Dw1)6o+{yw(t<_X|`2ClTWzuEw1KS{5*wa5|B zw+&oew>5bWxZDATo^;8O9LY~pC=`JAGy0|+(0>aA*4*A&`#607GSt=b4RCM>j1?(+ z-Q(T8oxS~grq$mMkhyZRVnLd700006VoOIv0RI600Du3Wy{D4^000SaNLh0L01FcU z01FcV0GgZ_00007bV*G`2j&VD4=Xf%CZo~-00EFmL_t(&-tAa1QiL!Rec4%8J8DM< zE$!?Wq^I%#G}79-7qIdITias80lWe-oWN2UJpi3<6RXSwNJv;=6_VF6FT?!*{>%R# zi0ir(9e*gxl3>PI0)X%PLNd?u+B2n;0stXIC`uR4IELmK70;iOaXSkz1o*&YL8<~* z@lBD2z(O}Uor>x>grP4#bmeAgOUDf#8*9V*&odEzozuxh9aX+0VC`!IL?)Zc+aol>x ze@S>}2dr0wFd;;JW7ZB>uhe_M>>Z$*46NbF8e_BJ$r_^_gL}pThGPi;p63b4qA0ZX z09Yd&z>mTyee4V(fNT#i$^rZ+H0}!M>;ZNP*w5jKj=?Yt?H*87m5_8CXZ8ZvO;G1h p*Kcs^023TA=Sg54U`n@_;Rg%5=0fI#A$R})002ovPDHLkV1oT5iunKl diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets_8.xcf b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets_8.xcf index 7b7a7bc10ffdb6d1a67e7de848cd7e0b4f6e6e32..cc53a4fea8b84e4f73d2e477b05756f54b1b4e1b 100644 GIT binary patch delta 691 zcmZvZ!Al!a5QleWvvIS@x^7%IW&;u;7IW&s7DWpA2gFJ#rNu4|W>lcngMy#jZFKhtaBNMm2FLn#HKz!e^4=D5^y-qqpLVXtDs`Ly^@J6?eYmC)ljG_{*-sa!5~WUtHrXX}kd zy(3Gd-KuZG?45C&pXoYa@(1mhjA=*g%5m4&0W|kXnkQ14zxa7_0nmC%(pr?#+Td&E zbHMaJk{MUZOqs2j18mwFW6!LBF)K#<1NH3#*|$&lxAY32GqL3qU`{$`l`q+^0No@7 z-4e-^JAVDG*nOvuPdPSVc9#0tnjFgRaMsh>)4M~`o08I-<1^UtkWYG5 xz}zXx+yzOiKh^#ftl|gs@QObMn6FYO|4~lnId9}%02T&F7RIG4JYW;~$5#N(v#|gG delta 448 zcmY+c6W7m#X1{YED=Ew+l^^-!LST$s@YKexMgU0hoM~zg`FG zAXm*0^_bk$F`#kFYSdYc4{C@tK(WXwHdw`>%-db^(Hy6S=>WEU@ziW@O(Phjyj=mb zP8qESzGBts$=L*SrdgdbtFuk(?k=D!SlwP(aw90vaAp9|TW0ij_^5Y6HNW*ff0Wgq zW%bKc3hn`e9@b!jHJGQVunL%cWzBxFh897t^_OUiH9BLB?&vCB0gSs@;{t0uCnr0L Ee{=(6DF6Tf From 15f53ea124128719b87c994a1880b749e5cf462e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 18 Jul 2023 13:02:01 +0700 Subject: [PATCH 0767/1199] Don't display "slot charging" help if player has no exopack --- .../dbotthepony/mc/otm/client/screen/MatteryScreen.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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 440a6e431..c50c54490 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 @@ -16,6 +16,7 @@ import net.minecraftforge.client.event.ContainerScreenEvent.Render.Background import net.minecraftforge.client.event.ContainerScreenEvent.Render.Foreground import net.minecraftforge.common.MinecraftForge import org.lwjgl.opengl.GL11 +import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.moveMousePosScaled import ru.dbotthepony.mc.otm.client.render.translation import ru.dbotthepony.mc.otm.client.screen.panels.* @@ -152,7 +153,10 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit if (menu.playerInventorySlots.isNotEmpty() && menu.autoCreateInventoryFrame) { if (menu.playerExoSuitSlots.isEmpty()) { inventoryFrame = FramePanel>(this, null, 0f, 0f, INVENTORY_FRAME_WIDTH, INVENTORY_FRAME_HEIGHT, inventory.displayName).also(this::addPanel) - inventoryFrame!!.makeHelpButton().addSlotFiltersHelp().tooltips.add(TranslatableComponent("otm.gui.help.slot_charging")) + inventoryFrame!!.makeHelpButton().addSlotFiltersHelp().also { + if (menu.ply.matteryPlayer?.hasExoPack == true) + it.tooltips.add(TranslatableComponent("otm.gui.help.slot_charging")) + } val hotbarStrip = EditablePanel(this, inventoryFrame, height = AbstractSlotPanel.SIZE) hotbarStrip.dock = Dock.BOTTOM @@ -176,7 +180,10 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } } else { inventoryFrame = FramePanel>(this, null, 0f, 0f, INVENTORY_FRAME_WIDTH_EXTENDED, BASE_INVENTORY_FRAME_HEIGHT + AbstractSlotPanel.SIZE * inventoryRows, inventory.displayName).also(this::addPanel) - inventoryFrame!!.makeHelpButton().addSlotFiltersHelp().tooltips.add(TranslatableComponent("otm.gui.help.slot_charging")) + inventoryFrame!!.makeHelpButton().addSlotFiltersHelp().also { + if (menu.ply.matteryPlayer?.hasExoPack == true) + it.tooltips.add(TranslatableComponent("otm.gui.help.slot_charging")) + } inventoryScrollbar = DiscreteScrollBarPanel(this, inventoryFrame, { integerDivisionDown(menu.playerCombinedInventorySlots.size, 9) }, { _, old, new -> From c6117e659d9de8c8ee462da0b27bce70604f6c1a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 18 Jul 2023 13:19:03 +0700 Subject: [PATCH 0768/1199] Don't process android ability key logic if we are a spectator server already ignores feature activation if we are a spectator --- .../ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt index 72ec6ec00..fae782495 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt @@ -25,7 +25,7 @@ object AndroidAbilityKeyMapping : KeyMapping("key.otm.android_ability", KeyConfl val old = this.isDown super.setDown(isDown) - if (old != isDown) { + if (old != isDown && minecraft.player?.isSpectator == false) { if (isDown) { val capability = minecraft.player?.matteryPlayer ?: return From 1ee071bfdb91e40ead25c6078fc37d6aeafc353c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 18 Jul 2023 13:32:02 +0700 Subject: [PATCH 0769/1199] Build creative mode tabs contents when it is not built when using creativetabsorter --- .../mc/otm/core/util/ItemSorter.kt | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt index fe6c1b229..a2034d840 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt @@ -3,8 +3,10 @@ package ru.dbotthepony.mc.otm.core.util import it.unimi.dsi.fastutil.objects.Reference2IntFunction import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap import net.minecraft.network.chat.Component +import net.minecraft.world.item.CreativeModeTabs import net.minecraft.world.item.Item import net.minecraftforge.common.CreativeModeTabRegistry +import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.nullsFirst import ru.dbotthepony.mc.otm.core.nullsLast @@ -23,14 +25,26 @@ object CreativeMenuComparator : Comparator { item2index.defaultReturnValue(Int.MAX_VALUE) } + private fun doRebuild() { + var i = 0 + + for (tab in CreativeModeTabRegistry.getSortedCreativeModeTabs()) { + for (item in tab.displayItems) { + item2index.computeIfAbsent(item.item, Reference2IntFunction { i++ }) + } + } + } + private fun rebuild() { if (item2index.isEmpty()) { - var i = 0 + doRebuild() - for (tab in CreativeModeTabRegistry.getSortedCreativeModeTabs()) { - for (item in tab.displayItems) { - item2index.computeIfAbsent(item.item, Reference2IntFunction { i++ }) - } + if (item2index.isEmpty()) { + val player = minecraft.player ?: return + // creative tabs were not populated yet + CreativeModeTabs.tryRebuildTabContents(player.connection.enabledFeatures(), false /* operator tabs */, player.level().registryAccess()) + + doRebuild() } } } From bafe74ea24d4d68173a2390a8fb4c662ee05d417 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 18 Jul 2023 13:37:16 +0700 Subject: [PATCH 0770/1199] Move quicksearch bar in pattern monitor to not overlap close button --- .../client/screen/matter/MatterPanelScreen.kt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) 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 38b61c58e..06a46c8d2 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 @@ -54,12 +54,14 @@ class MatterPanelScreen( val controls = DeviceControls(this, frame) - LargeBooleanRectangleButtonPanel(this, controls, - prop = menu.isAscendingGS, - skinElementActive = Widgets18.ARROW_UP, - skinElementInactive = Widgets18.ARROW_DOWN, - tooltipActive = TranslatableComponent("otm.gui.sorting.ascending"), - tooltipInactive = TranslatableComponent("otm.gui.sorting.descending"), + LargeBooleanRectangleButtonPanel( + this, + controls, + prop = menu.isAscendingGS, + skinElementActive = Widgets18.ARROW_UP, + skinElementInactive = Widgets18.ARROW_DOWN, + tooltipActive = TranslatableComponent("otm.gui.sorting.ascending"), + tooltipInactive = TranslatableComponent("otm.gui.sorting.descending"), ).also { controls.addButton(it) } @@ -91,7 +93,7 @@ class MatterPanelScreen( object : TextInputPanel(this@MatterPanelScreen, frame) { init { width = frame.width * 0.4f - x = frame.width - width - FramePanel.PADDING + x = frame.width - width - FramePanel.PADDING - 6f y = 4f placeholder = TranslatableComponent("otm.gui.quicksearch") } From 667e0743627dbe79858eb905658bcc4167d1fa4f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 18 Jul 2023 13:39:09 +0700 Subject: [PATCH 0771/1199] Expose help and close buttons as properties --- .../dbotthepony/mc/otm/client/screen/panels/FramePanel.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index 83955fe6d..5019f7a23 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -208,8 +208,11 @@ open class FramePanel( } protected var dragging = false - protected var closeButton: CloseButton? = null - protected var helpButton: HelpButton? = null + + var closeButton: CloseButton? = null + protected set + var helpButton: HelpButton? = null + protected set var closeOnEscape = false From cc9d2ef4eb8ee7c6e2f4681088f5b58eeed12d52 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 18 Jul 2023 20:35:49 +0700 Subject: [PATCH 0772/1199] Move matter registry to codecs, simplify manual writing of matter json files --- .../dbotthepony/mc/otm/datagen/MatterData.kt | 1 - .../mc/otm/matter/AbstractRegistryAction.kt | 207 ++++----- .../mc/otm/matter/BlacklistAction.kt | 26 -- .../mc/otm/matter/BoundMatterFunction.kt | 57 --- .../mc/otm/matter/ComputeAction.kt | 397 ++++++++---------- .../dbotthepony/mc/otm/matter/DeleteAction.kt | 83 ++-- .../mc/otm/matter/IMatterFunction.kt | 84 ++++ .../dbotthepony/mc/otm/matter/InsertAction.kt | 180 +++----- .../mc/otm/matter/MatterDataProvider.kt | 248 ++++------- .../mc/otm/matter/MatterFunction.kt | 78 ---- .../mc/otm/matter/MatterManager.kt | 175 +++----- .../mc/otm/matter/RegistryEntries.kt | 60 +++ .../dbotthepony/mc/otm/matter/UpdateAction.kt | 251 ++++------- .../dbotthepony/mc/otm/registry/MRegistry.kt | 5 + 14 files changed, 699 insertions(+), 1153 deletions(-) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/matter/BlacklistAction.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/matter/BoundMatterFunction.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/matter/IMatterFunction.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterFunction.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/matter/RegistryEntries.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt index b6df91306..0781b1800 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt @@ -7,7 +7,6 @@ import net.minecraftforge.common.Tags import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.matter.ComputeAction import ru.dbotthepony.mc.otm.matter.MatterDataProvider -import ru.dbotthepony.mc.otm.matter.MatterFunction import ru.dbotthepony.mc.otm.registry.MItemTags import ru.dbotthepony.mc.otm.registry.MItems 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 7922d3331..d03613743 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/AbstractRegistryAction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/AbstractRegistryAction.kt @@ -1,128 +1,46 @@ package ru.dbotthepony.mc.otm.matter -import com.google.gson.JsonObject import com.google.gson.JsonParseException -import com.google.gson.JsonPrimitive -import com.google.gson.JsonSyntaxException +import com.mojang.datafixers.util.Either +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.ItemTags import net.minecraft.tags.TagKey import net.minecraft.world.item.Item -import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.core.set +import net.minecraftforge.eventbus.api.IEventBus +import net.minecraftforge.registries.DeferredRegister +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.registry.RegistryDelegate +import java.util.* -sealed class AbstractRegistryAction : Comparable { - sealed class Condition { - abstract fun test(): Boolean +abstract class AbstractRegistryAction( + val id: Either>, + val errorOnFailure: Boolean = false, + val priority: Optional = Optional.empty(), +) : Comparable { + interface Type { + val codec: Codec } - class CombinedCondition(val conditions: Collection) : Condition() { - override fun test(): Boolean { - return conditions.all { it.test() } + fun update(registry: MutableCollection, source: ResourceLocation) { + if (!checkConditions()) { + return } + + doUpdate(registry, source) } - val errorOnFailure: Boolean - val tag: TagKey? - val key: ResourceLocation? - val matter: Decimal? - val complexity: Double? - val priority: Int? + protected abstract fun doUpdate(registry: MutableCollection, source: ResourceLocation) - constructor(json: JsonObject) { - errorOnFailure = json["error_on_failure"]?.asBoolean ?: false - priority = json["priority"]?.asInt + abstract val type: Type<*> - val id = json["id"]?.asString ?: throw JsonParseException("Missing `id` value") - - if (id.startsWith("#")) { - if (id.startsWith("#:")) { - throw JsonSyntaxException("Invalid `id` value: $id") - } - - tag = ItemTags.create( - ResourceLocation.tryParse(id.substring(1)) ?: throw JsonSyntaxException("Invalid `id` value: $id") - ) - key = null - } else { - key = ResourceLocation.tryParse(id) ?: throw JsonSyntaxException("Invalid `id` value: $id") - tag = null - } - - try { - matter = json["matter"]?.asString?.let(::Decimal) - - if (matter != null && !matter.isPositive) { - throw JsonParseException("Can't have non-positive matter value. To remove an entry from registry please use 'delete' action instead.") - } - } catch(err: NumberFormatException) { - throw JsonParseException("Invalid `matter` field: ${json["matter"]}", err) - } - - try { - complexity = json["complexity"]?.asString?.toDouble() - - if (complexity != null && complexity <= 0.0) { - throw JsonParseException("Can't have non-positive complexity. To remove an entry from registry please use 'delete' action instead.") - } - } catch(err: NumberFormatException) { - throw JsonParseException("Invalid `complexity` field: ${json["complexity"]}", err) - } - } - - constructor( - tag: TagKey, - matter: Decimal?, - complexity: Double?, - priority: Int? = null, - errorOnFailure: Boolean = false - ) { - this.tag = tag - this.key = null - this.matter = matter - this.complexity = complexity - this.priority = priority - this.errorOnFailure = errorOnFailure - - if (matter != null && !matter.isPositive) { - throw IllegalArgumentException("Can't have non-positive matter value. To remove an entry from registry please use 'delete' action instead.") - } - - if (complexity != null && complexity <= 0.0) { - throw IllegalArgumentException("Can't have non-positive complexity. To remove an entry from registry please use 'delete' action instead.") - } - } - - constructor( - key: ResourceLocation, - matter: Decimal?, - complexity: Double?, - priority: Int? = null, - errorOnFailure: Boolean = false - ) { - this.tag = null - this.key = key - this.matter = matter - this.complexity = complexity - this.priority = priority - this.errorOnFailure = errorOnFailure - - if (matter != null && !matter.isPositive) { - throw IllegalArgumentException("Can't have non-positive matter value. To remove an entry from registry please use 'delete' action instead.") - } - - if (complexity != null && complexity <= 0.0) { - throw IllegalArgumentException("Can't have non-positive complexity. To remove an entry from registry please use 'delete' action instead.") - } - } - - fun checkConditions(): Boolean { + open fun checkConditions(): Boolean { return true } - internal abstract fun update(registry: MutableCollection, modifier: ResourceLocation) - protected inline fun fail(reason: () -> String) { if (errorOnFailure) { throw JsonParseException(reason.invoke()) @@ -133,43 +51,76 @@ sealed class AbstractRegistryAction : Comparable { if (other == null) return true - if (other.priority != null && priority != null) - return other.priority <= priority + if (other.priority.isPresent && priority.isPresent) + return other.priority.get() <= priority.get() - return other.priority == null + return other.priority.isEmpty } - override fun compareTo(other: AbstractRegistryAction): Int { - if (other.priority == null) { - if (priority == null) { + final override fun compareTo(other: AbstractRegistryAction): Int { + if (other.priority.isEmpty) { + if (priority.isEmpty) { return 0 } return 1 } - if (priority == null) { + if (priority.isEmpty) { return -1 } - return priority.compareTo(other.priority) + return priority.get().compareTo(other.priority.get()) } - open fun toJson(): JsonObject { - return JsonObject().also { - if (key != null) - it["id"] = JsonPrimitive(key.toString()) - else - it["id"] = JsonPrimitive("#${tag!!.location}") + object TargetCodec : Codec>> { + private val tagCodec = TagKey.codec(Registries.ITEM) - if (priority != null) - it["priority"] = priority + override fun encode(input: Either>, ops: DynamicOps, prefix: T): DataResult { + return DataResult.success(input.map( + { + ops.createString(it.toString()) + }, + { + ops.createString("#" + it.location.toString()) + } + )) + } - if (matter != null) - it["matter"] = matter.toString() + override fun decode(ops: DynamicOps, input: T): DataResult>, T>> { + return ops.getStringValue(input).flatMap { + if (it[0] == '#') + tagCodec.decode(ops, ops.createString(it.substring(1))).map { Pair(Either.right(it.first), it.second) } + else + ResourceLocation.CODEC.decode(ops, input).map { Pair(Either.left(it.first), it.second) } + } + } + } - if (complexity != null) - it["complexity"] = complexity + companion object { + private val registryDelegate = RegistryDelegate>("matter_registry_action") { disableSaving(); disableSync() } + + val registryKey get() = registryDelegate.key + val registry by registryDelegate + + private val registrar = DeferredRegister.create(registryKey, OverdriveThatMatters.MOD_ID) + + init { + registrar.register("insert") { InsertAction.Companion } + registrar.register("update") { UpdateAction.Companion } + registrar.register("compute") { ComputeAction.Companion } + registrar.register("delete") { DeleteAction.Companion } + registrar.register("blacklist") { BlacklistAction.Companion } + } + + internal fun register(bus: IEventBus) { + registrar.register(bus) + bus.addListener(registryDelegate::build) + } + + val CODEC: Codec by lazy { + registry.codec.dispatch({ it.type }, { it.codec }) } } } + diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/BlacklistAction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/BlacklistAction.kt deleted file mode 100644 index 41ec5e35e..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/BlacklistAction.kt +++ /dev/null @@ -1,26 +0,0 @@ -package ru.dbotthepony.mc.otm.matter - -import com.google.gson.JsonObject -import net.minecraft.resources.ResourceLocation -import net.minecraft.tags.TagKey -import net.minecraft.world.item.Item -import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.core.set - -class BlacklistAction : DeleteAction { - constructor( - tag: TagKey, - ) : super(tag = tag, errorOnFailure = false) - - constructor( - key: ResourceLocation, - ) : super(key = key, errorOnFailure = false) - - constructor(json: JsonObject) : super(json) - - override fun toJson(): JsonObject { - return super.toJson().also { - it["action"] = "blacklist" - } - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/BoundMatterFunction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/BoundMatterFunction.kt deleted file mode 100644 index 27e55bf04..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/BoundMatterFunction.kt +++ /dev/null @@ -1,57 +0,0 @@ -package ru.dbotthepony.mc.otm.matter - -import com.google.gson.JsonElement -import com.google.gson.JsonObject -import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.core.set - -class BoundMatterFunction(val function: MatterFunction, val value: T) { - fun apply(self: T): T { - return function.updateValue(self, value) - } - - fun toJson(): JsonObject { - return JsonObject().also { - it["type"] = function.name - - if (value is Int || value is Double) - it["value"] = value - else - it["value"] = value.toString() - } - } - - companion object { - inline fun getValue(value: JsonElement): T { - return when (T::class) { - Decimal::class -> Decimal(value.asString) as T - Double::class -> value.asDouble as T - Int::class -> value.asInt as T - else -> throw RuntimeException("Unknown number type: ${T::class.qualifiedName}") - } - } - - fun apply(value: T, funcs: Collection>): T { - if (funcs.isEmpty()) { - return value - } - - var newValue = value - - for (func in funcs) { - newValue = func.apply(newValue) - } - - return newValue - } - - fun apply(funcs: Collection>, value: T): T { - return apply(value, funcs) - } - } -} - -fun Collection>.apply(value: T): T { - return BoundMatterFunction.apply(this, value) -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt index ba23936bd..5ea678522 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt @@ -1,68 +1,164 @@ package ru.dbotthepony.mc.otm.matter import com.google.common.collect.ImmutableList -import com.google.gson.JsonArray -import com.google.gson.JsonObject -import com.google.gson.JsonSyntaxException +import com.mojang.datafixers.util.Either +import com.mojang.datafixers.util.Pair +import com.mojang.serialization.Codec +import com.mojang.serialization.DataResult +import com.mojang.serialization.DynamicOps +import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.resources.ResourceLocation -import net.minecraft.tags.ItemTags import net.minecraft.tags.TagKey import net.minecraft.world.item.Item -import net.minecraft.world.level.ItemLike import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.registryName -import ru.dbotthepony.mc.otm.core.set -import ru.dbotthepony.mc.otm.core.collect.stream -import java.util.stream.Stream +import ru.dbotthepony.mc.otm.data.DecimalCodec +import java.util.Optional -class ComputeAction : AbstractRegistryAction { - sealed class Source { - val matterFunction: MatterFunction - val complexityFunction: MatterFunction - - constructor( - matterFunction: MatterFunction, - complexityFunction: MatterFunction, - ) { - this.matterFunction = matterFunction - this.complexityFunction = complexityFunction - } - - constructor(json: JsonObject) { - val function = json["function"]?.asString?.uppercase() - - if (function == null) { - try { - this.matterFunction = MatterFunction.valueOf(json["matter_function"]?.asString?.uppercase() ?: throw JsonSyntaxException("Missing matter_function value")) - } catch(err: NoSuchElementException) { - throw JsonSyntaxException("Invalid matter_function: ${json["matter_function"]}", err) - } - - try { - this.complexityFunction = MatterFunction.valueOf(json["complexity_function"]?.asString?.uppercase() ?: throw JsonSyntaxException("Missing complexity_function value")) - } catch(err: NoSuchElementException) { - throw JsonSyntaxException("Invalid complexity_function: ${json["complexity_function"]}", err) - } - } else { - try { - this.matterFunction = MatterFunction.valueOf(function) - this.complexityFunction = this.matterFunction - } catch(err: NoSuchElementException) { - throw JsonSyntaxException("Invalid function: ${json["function"]}", err) - } +class ComputeAction( + id: Either>, + values: Collection, + priority: Optional = Optional.empty(), +) : AbstractRegistryAction(id, priority = priority) { + companion object : Type { + private val constantCodecConcise: Codec by lazy { + RecordCodecBuilder.create { + it.group( + DecimalCodec.fieldOf("matter").forGetter(Constant::matter), + Codec.DOUBLE.fieldOf("complexity").forGetter(Constant::complexity), + IMatterFunction.registry.codec.fieldOf("function").forGetter(Constant::matterFunction), + ).apply(it, ::Constant) } } + private val constantCodecVeryConcise: Codec by lazy { + RecordCodecBuilder.create { + it.group( + DecimalCodec.fieldOf("value").forGetter(Constant::matter), + IMatterFunction.registry.codec.fieldOf("function").forGetter(Constant::matterFunction), + ).apply(it, ::Constant) + } + } + + private val constantCodecVeryConcise2: Codec by lazy { + RecordCodecBuilder.create { + it.group( + Codec.DOUBLE.fieldOf("value").forGetter(Constant::complexity), + IMatterFunction.registry.codec.fieldOf("function").forGetter(Constant::matterFunction), + ).apply(it, ::Constant) + } + } + + private val constantCodecVerbose: Codec by lazy { + RecordCodecBuilder.create { + it.group( + DecimalCodec.fieldOf("matter").forGetter(Constant::matter), + Codec.DOUBLE.fieldOf("complexity").forGetter(Constant::complexity), + IMatterFunction.registry.codec.fieldOf("matterFunction").forGetter(Constant::matterFunction), + IMatterFunction.registry.codec.fieldOf("complexityFunction").forGetter(Constant::complexityFunction), + ).apply(it, ::Constant) + } + } + + private val constantCodec: Codec by lazy { + Codec.either(constantCodecConcise, constantCodecVerbose) + .xmap({ it.map({ it }, { it }) }, { if (it.matterFunction == it.complexityFunction) Either.left(it) else Either.right(it) }) + } + + private object ActualConstantCodec : Codec { + override fun encode(input: Constant, ops: DynamicOps, prefix: T): DataResult { + if (input.complexity == input.matter.toDouble()) { + return constantCodecVeryConcise.encode(input, ops, prefix) + } else { + return constantCodec.encode(input, ops, prefix) + } + } + + override fun decode(ops: DynamicOps, input: T): DataResult> { + var result = constantCodecVeryConcise.decode(ops, input) + + if (result.result().isPresent) { + return result + } + + result = constantCodecVeryConcise2.decode(ops, input) + + if (result.result().isPresent) { + return result + } + + return constantCodec.decode(ops, input) + } + } + + private val valueCodecConcise: Codec by lazy { + RecordCodecBuilder.create { + it.group( + TargetCodec.fieldOf("id").forGetter(Value::id), + IMatterFunction.registry.codec.fieldOf("function").forGetter(Value::matterFunction), + ).apply(it, ::Value) + } + } + + private val valueCodecVerbose: Codec by lazy { + RecordCodecBuilder.create { + it.group( + TargetCodec.fieldOf("id").forGetter(Value::id), + IMatterFunction.registry.codec.fieldOf("matterFunction").forGetter(Value::matterFunction), + IMatterFunction.registry.codec.fieldOf("complexityFunction").forGetter(Value::complexityFunction), + ).apply(it, ::Value) + } + } + + private val valueCodec: Codec by lazy { + Codec.either(valueCodecConcise, valueCodecVerbose) + .xmap({ it.map({ it }, { it }) }, { if (it.matterFunction == it.complexityFunction) Either.left(it) else Either.right(it) }) + } + + private object ActualValueCodec : Codec { + override fun encode(input: Value, ops: DynamicOps, prefix: T): DataResult { + if (input.matterFunction == input.complexityFunction && input.matterFunction == IMatterFunction.PLUS) { + return TargetCodec.encode(input.id, ops, prefix) + } else { + return valueCodec.encode(input, ops, prefix) + } + } + + override fun decode(ops: DynamicOps, input: T): DataResult> { + val result = TargetCodec.decode(ops, input) + + if (result.result().isPresent) { + return result.map { it.mapFirst { Value(it, IMatterFunction.PLUS) } } + } + + return valueCodec.decode(ops, input) + } + } + + override val codec: Codec by lazy { + RecordCodecBuilder.create { + it.group( + TargetCodec.fieldOf("id").forGetter(ComputeAction::id), + Codec.list(Codec + .either(ActualConstantCodec, ActualValueCodec) + .xmap({ it.map({ it }, { it }) }, { if (it is Constant) Either.left(it) else Either.right(it as Value) })) + .fieldOf("values") + .forGetter(ComputeAction::values), + Codec.INT.optionalFieldOf("prority").forGetter(ComputeAction::priority) + ).apply(it, ::ComputeAction) + } + } + } + + override val type: Type<*> + get() = Companion + + sealed class Source( + val matterFunction: IMatterFunction, + val complexityFunction: IMatterFunction + ) { internal abstract fun provideValues(): MatterManager.Result - open fun toJson(): JsonObject { - return JsonObject().also { - it["matter_function"] = matterFunction.name - it["complexity_function"] = complexityFunction.name - } - } - internal fun update(self: IMatterValue): MatterManager.Result { val grab = provideValues() @@ -77,156 +173,47 @@ class ComputeAction : AbstractRegistryAction { } } - class Constant : Source { - val matter: Decimal - val complexity: Double + class Constant( + val matter: Decimal, + val complexity: Double, + matterFunction: IMatterFunction, + complexityFunction: IMatterFunction = matterFunction, + ) : Source(matterFunction, complexityFunction) { + constructor( + value: Decimal, + matterFunction: IMatterFunction, + complexityFunction: IMatterFunction = matterFunction + ) : this(value, value.toDouble(), matterFunction, complexityFunction) constructor( - matter: Decimal, - complexity: Double, - matterFunction: MatterFunction, - complexityFunction: MatterFunction = matterFunction, - ) : super(matterFunction, complexityFunction) { - this.matter = matter - this.complexity = complexity - } - - constructor(json: JsonObject) : super(json) { - try { - matter = Decimal(json["matter"]?.asString ?: throw JsonSyntaxException("Missing matter value")) - } catch(err: NumberFormatException) { - throw JsonSyntaxException("Invalid matter value: ${json["matter"]}") - } - - try { - complexity = json["complexity"]?.asDouble ?: throw JsonSyntaxException("Missing complexity value") - } catch(err: NumberFormatException) { - throw JsonSyntaxException("Invalid complexity value: ${json["complexity"]}") - } - } + value: Double, + matterFunction: IMatterFunction, + complexityFunction: IMatterFunction = matterFunction + ) : this(Decimal(value.toString()), value, matterFunction, complexityFunction) override fun provideValues(): MatterManager.Result { return MatterManager.Result(MatterValue(matter, complexity)) } - - override fun toJson(): JsonObject { - return super.toJson().also { - it["type"] = "constant" - it["matter"] = matter.toString() - it["complexity"] = complexity - } - } } - class Key : Source { - val key: ResourceLocation - - constructor( - key: ResourceLocation, - matterFunction: MatterFunction, - complexityFunction: MatterFunction = matterFunction, - ) : super(matterFunction, complexityFunction) { - this.key = key - } - - constructor( - key: ItemLike, - matterFunction: MatterFunction, - complexityFunction: MatterFunction = matterFunction, - ) : super(matterFunction, complexityFunction) { - this.key = key.asItem().registryName ?: throw IllegalStateException("${key.asItem()} has no registry ID!") - } - - constructor(json: JsonObject) : super(json) { - key = ResourceLocation.tryParse(json["key"]?.asString ?: throw JsonSyntaxException("Missing key")) ?: throw JsonSyntaxException("Invalid key value: ${json["key"]}") - } - + class Value( + val id: Either>, + matterFunction: IMatterFunction, + complexityFunction: IMatterFunction = matterFunction, + ) : Source(matterFunction, complexityFunction) { override fun provideValues(): MatterManager.Result { - return MatterManager.compute(ForgeRegistries.ITEMS.getValue(key) ?: throw NullPointerException("$key does not point to anything")) - } - - override fun toJson(): JsonObject { - return super.toJson().also { - it["type"] = "key" - it["key"] = key.toString() - } + return id.map( + { + MatterManager.compute(ForgeRegistries.ITEMS.getValue(it) ?: throw NullPointerException("$it does not point to anything")) + }, + { + MatterManager.compute(it) + } + ) } } - class Tag : Source { - val tag: TagKey - - constructor( - tag: TagKey, - matterFunction: MatterFunction, - complexityFunction: MatterFunction = matterFunction, - ) : super(matterFunction, complexityFunction) { - this.tag = tag - } - - constructor(json: JsonObject) : super(json) { - tag = ItemTags.create(ResourceLocation.tryParse(json["tag"]?.asString ?: throw JsonSyntaxException("Missing tag")) ?: throw JsonSyntaxException("Invalid tag value: ${json["tag"]}")) - } - - override fun provideValues(): MatterManager.Result { - return MatterManager.compute(tag) - } - - override fun toJson(): JsonObject { - return super.toJson().also { - it["type"] = "tag" - it["tag"] = tag.location.toString() - } - } - } - - val values: List - - constructor( - key: ResourceLocation, - value: Source - ) : super(key = key, errorOnFailure = false, matter = null, complexity = null) { - values = listOf(value) - } - - constructor( - tag: TagKey, - value: Source - ) : super(tag = tag, errorOnFailure = false, matter = null, complexity = null) { - values = listOf(value) - } - - constructor( - key: ResourceLocation, - value: Stream - ) : super(key = key, errorOnFailure = false, matter = null, complexity = null) { - values = value.collect(ImmutableList.toImmutableList()) - require(values.isNotEmpty()) { "Provided compute source Stream is empty" } - } - - constructor( - tag: TagKey, - value: Stream - ) : super(tag = tag, errorOnFailure = false, matter = null, complexity = null) { - values = value.collect(ImmutableList.toImmutableList()) - require(values.isNotEmpty()) { "Provided compute source Stream is empty" } - } - - constructor( - key: ResourceLocation, - value: Collection - ) : super(key = key, errorOnFailure = false, matter = null, complexity = null) { - require(value.isNotEmpty()) { "Provided compute source list is empty" } - values = ImmutableList.copyOf(value) - } - - constructor( - tag: TagKey, - value: Collection - ) : super(tag = tag, errorOnFailure = false, matter = null, complexity = null) { - require(value.isNotEmpty()) { "Provided compute source list is empty" } - values = ImmutableList.copyOf(value) - } + val values: ImmutableList = ImmutableList.copyOf(values) internal fun tryCompute(): MatterManager.Result { var compute: IMatterValue = IMatterValue.Companion @@ -244,37 +231,7 @@ class ComputeAction : AbstractRegistryAction { return MatterManager.Result(compute) } - constructor(json: JsonObject) : super(json) { - val values = json["values"] as? JsonArray ?: throw JsonSyntaxException("Invalid `values` value: ${json["values"]}") - - this.values = values.stream().map { - it as? JsonObject ?: throw JsonSyntaxException("JsonObject expected, $it <${it::class.qualifiedName}> given") - - when (val type = it["type"]?.asString?.lowercase() ?: throw JsonSyntaxException("Missing type")) { - "tag" -> Tag(it) - "key" -> Key(it) - "constant" -> Constant(it) - else -> throw JsonSyntaxException("Invalid type provided: $type") - } - }.collect(ImmutableList.toImmutableList()) - - if (this.values.isEmpty()) { - throw JsonSyntaxException("Compute action is empty") - } - } - - override fun toJson(): JsonObject { - return super.toJson().also { - it["action"] = "compute" - it["values"] = JsonArray(values.size).also { - for (value in values) { - it.add(value.toJson()) - } - } - } - } - - override fun update(registry: MutableCollection, modifier: ResourceLocation) { + override fun doUpdate(registry: MutableCollection, source: ResourceLocation) { // do nothing } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/DeleteAction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/DeleteAction.kt index ad5b7b29a..f208c3bfc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/DeleteAction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/DeleteAction.kt @@ -1,61 +1,52 @@ package ru.dbotthepony.mc.otm.matter -import com.google.gson.JsonObject +import com.mojang.datafixers.util.Either +import com.mojang.serialization.Codec +import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.resources.ResourceLocation import net.minecraft.tags.TagKey import net.minecraft.world.item.Item -import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.core.set -open class DeleteAction : AbstractRegistryAction { - constructor( - tag: TagKey, - errorOnFailure: Boolean = false, - ) : super(tag = tag, errorOnFailure = errorOnFailure, matter = null, complexity = null) +open class DeleteAction( + id: Either>, + errorOnFailure: Boolean = false, +) : AbstractRegistryAction(id, errorOnFailure) { + override fun doUpdate(registry: MutableCollection, source: ResourceLocation) { + val iterator = registry.iterator() - constructor( - key: ResourceLocation, - errorOnFailure: Boolean = false, - ) : super(key = key, errorOnFailure = errorOnFailure, matter = null, complexity = null) - - constructor(json: JsonObject) : super(json) - - override fun toJson(): JsonObject { - return super.toJson().also { - it["action"] = "delete" + for (value in iterator) { + if (value.name == id) { + iterator.remove() + return + } } + + fail { "Could not find matter value with name $id (source: $source)" } } - override fun update(registry: MutableCollection, modifier: ResourceLocation) { - if (!checkConditions()) { - return - } + override val type: Type<*> + get() = Companion - check(matter == null) { "Delete action can't have matter value (for $modifier)" } - check(complexity == null) { "Delete action can't have complexity value (for $modifier)" } - - if (key != null) { - val iterator = registry.iterator() - - for (value in iterator) { - if (value is MutableKeyEntry && value.key == key) { - iterator.remove() - return - } + companion object : Type { + override val codec: Codec by lazy { + RecordCodecBuilder.create { + it.group( + TargetCodec.fieldOf("id").forGetter(DeleteAction::id), + Codec.BOOL.optionalFieldOf("errorOnFailure", false).forGetter(DeleteAction::errorOnFailure) + ).apply(it, ::DeleteAction) + } + } + } +} + +class BlacklistAction(id: Either>) : DeleteAction(id) { + companion object : Type { + override val codec: Codec by lazy { + RecordCodecBuilder.create { + it.group( + TargetCodec.fieldOf("id").forGetter(BlacklistAction::id) + ).apply(it, ::BlacklistAction) } - - fail { "Could not find matter value with key $key" } - } else { - val iterator = registry.iterator() - - for (value in iterator) { - if (value is MutableTagEntry && value.tag == tag) { - iterator.remove() - return - } - } - - fail { "Could not find matter value with tag $tag" } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/IMatterFunction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/IMatterFunction.kt new file mode 100644 index 000000000..b225a7c10 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/IMatterFunction.kt @@ -0,0 +1,84 @@ +package ru.dbotthepony.mc.otm.matter + +import net.minecraftforge.eventbus.api.IEventBus +import net.minecraftforge.registries.DeferredRegister +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.core.getValue +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.registry.RegistryDelegate + +interface IMatterFunction { + fun updateValue(self: Int, other: Int): Int + fun updateValue(self: Decimal, other: Decimal): Decimal + fun updateValue(self: Double, other: Double): Double + + companion object : IMatterFunction { + private val registryDelegate = RegistryDelegate("matter_function") { disableSync(); disableSaving() } + + val registryKey get() = registryDelegate.key + val registry by registryDelegate + + private val registrar = DeferredRegister.create(registryKey, OverdriveThatMatters.MOD_ID) + + init { + registrar.register("noop") { this } + } + + val NOOP = this + val PLUS: IMatterFunction by registrar.register("plus") { SimpleMatterFunction(Int::plus, Double::plus, Decimal::plus) } + val MINUS: IMatterFunction by registrar.register("minus") { SimpleMatterFunction(Int::minus, Double::minus, Decimal::minus) } + val DIV: IMatterFunction by registrar.register("div") { SimpleMatterFunction(Int::div, Double::div, Decimal::div) } + val MUL: IMatterFunction by registrar.register("mul") { SimpleMatterFunction(Int::times, Double::times, Decimal::times) } + val MOD: IMatterFunction by registrar.register("mod") { SimpleMatterFunction(Int::mod, Double::mod) } + val AT_LEAST: IMatterFunction by registrar.register("at_least") { SimpleMatterFunction(Int::coerceAtLeast, Double::coerceAtLeast, Decimal::coerceAtLeast) } + val AT_MOST: IMatterFunction by registrar.register("at_most") { SimpleMatterFunction(Int::coerceAtMost, Double::coerceAtMost, Decimal::coerceAtMost) } + val REPLACE: IMatterFunction by registrar.register("replace") { SimpleMatterFunction({ _, value -> value }, { _, value -> value }, { _, value -> value }) } + + internal fun register(bus: IEventBus) { + registrar.register(bus) + bus.addListener(registryDelegate::build) + } + + override fun updateValue(self: Int, other: Int): Int { + return self + } + + override fun updateValue(self: Decimal, other: Decimal): Decimal { + return self + } + + override fun updateValue(self: Double, other: Double): Double { + return self + } + } +} + +data class SimpleMatterFunction( + val int: IntFunction = IntFunction { _, _ -> throw UnsupportedOperationException("Can't do this with Int") }, + val double: DoubleFunction = DoubleFunction { _, _ -> throw UnsupportedOperationException("Can't do this with Double") }, + val decimal: DecimalFunction = DecimalFunction { _, _ -> throw UnsupportedOperationException("Can't do this with Decimal") } +) : IMatterFunction { + fun interface IntFunction { + fun update(self: Int, value: Int): Int + } + + fun interface DoubleFunction { + fun update(self: Double, value: Double): Double + } + + fun interface DecimalFunction { + fun update(self: Decimal, value: Decimal): Decimal + } + + override fun updateValue(self: Int, other: Int): Int { + return int.update(self, other) + } + + override fun updateValue(self: Decimal, other: Decimal): Decimal { + return decimal.update(self, other) + } + + override fun updateValue(self: Double, other: Double): Double { + return double.update(self, other) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/InsertAction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/InsertAction.kt index 116b9fa2e..b0fccf9c5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/InsertAction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/InsertAction.kt @@ -1,151 +1,67 @@ package ru.dbotthepony.mc.otm.matter -import com.google.gson.JsonObject +import com.mojang.datafixers.util.Either +import com.mojang.serialization.Codec +import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.resources.ResourceLocation import net.minecraft.tags.TagKey import net.minecraft.world.item.Item import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.data.DecimalCodec +import java.util.Optional -class InsertAction : AbstractRegistryAction { - val replaceIfExists: Boolean - val comparePriority: Boolean - - constructor( - key: ResourceLocation, - matter: Decimal?, - complexity: Double?, - priority: Int? = null, - errorOnFailure: Boolean = false, - replaceIfExists: Boolean = false, - comparePriority: Boolean = true, - ) : super(key = key, matter = matter, complexity = complexity, priority = priority, errorOnFailure = errorOnFailure) { - this.replaceIfExists = replaceIfExists - this.comparePriority = comparePriority - } - - constructor( - tag: TagKey, - matter: Decimal?, - complexity: Double?, - priority: Int? = null, - errorOnFailure: Boolean = false, - replaceIfExists: Boolean = false, - comparePriority: Boolean = true, - ) : super(tag = tag, matter = matter, complexity = complexity, priority = priority, errorOnFailure = errorOnFailure) { - this.replaceIfExists = replaceIfExists - this.comparePriority = comparePriority - } - - constructor(json: JsonObject) : super(json) { - this.replaceIfExists = json["replace_if_exists"]?.asBoolean ?: false - this.comparePriority = json["compare_priority"]?.asBoolean ?: true - } - - override fun toJson(): JsonObject { - checkNotNull(matter) { "Missing matter value, which is required for insert action" } - checkNotNull(complexity) { "Missing complexity value, which is required for insert action" } - - return super.toJson().also { - it["action"] = "insert" - it["replace_if_exists"] = replaceIfExists - it["compare_priority"] = comparePriority - } - } - - override fun update(registry: MutableCollection, modifier: ResourceLocation) { - checkNotNull(matter) { "Missing matter value, which is required for insert action (for $modifier)" } - checkNotNull(complexity) { "Missing complexity value, which is required for insert action (for $modifier)" } - - check(!comparePriority || priority != null) { "If compare_priority is true then priority must not be null (for $modifier)" } - - if (!checkConditions()) { - return - } - - if (key != null) { - if (replaceIfExists) { - // search & replace in parallel, if possible - val replaced = registry.stream().anyMatch { - if (it is MutableKeyEntry && it.key == key) { - if (!comparePriority || it.priority < priority!!) { - it.matter = matter - it.complexity = complexity - it.priority = priority ?: 0 - } - - return@anyMatch true - } else { - return@anyMatch false +class InsertAction( + id: Either>, + val matter: Decimal, + val complexity: Double, + val replaceIfExists: Boolean = false, + errorOnFailure: Boolean = false, + priority: Optional = Optional.empty(), +) : AbstractRegistryAction(id, errorOnFailure, priority) { + override fun doUpdate(registry: MutableCollection, source: ResourceLocation) { + if (replaceIfExists) { + // search & replace in parallel, if possible + val replaced = registry.stream().anyMatch { + if (it.name == id) { + if (priority.isEmpty || it.priority < priority.get()) { + it.matter = matter + it.complexity = complexity + it.priority = priority.orElse(0) } - } - if (!replaced) { - registry.add( - MutableKeyEntry( - key, - matter, - complexity, - priority ?: 0 - ) - ) - } - } else { - if (registry.stream().anyMatch { it is MutableKeyEntry && it.key == key }) { - fail { "Value with key $key already exists" } - return + return@anyMatch true + } else { + return@anyMatch false } + } - registry.add( - MutableKeyEntry( - key, - matter, - complexity, - priority ?: 0 - ) - ) + if (!replaced) { + registry.add(MutableRegistryEntry(id, matter, complexity, priority.orElse(0))) } } else { - if (replaceIfExists) { - // search & replace in parallel, if possible - val replaced = registry.stream().anyMatch { - if (it is MutableTagEntry && it.tag == tag) { - if (!comparePriority || it.priority < priority!!) { - it.matter = matter - it.complexity = complexity - it.priority = priority ?: 0 - } + if (registry.stream().anyMatch { it.name == id }) { + fail { "Value with name $id already exists (source: $source)" } + return + } - return@anyMatch true - } else { - return@anyMatch false - } - } + registry.add(MutableRegistryEntry(id, matter, complexity, priority.orElse(0))) + } + } - if (!replaced) { - registry.add( - MutableTagEntry( - tag!!, - matter, - complexity, - priority ?: 0 - ) - ) - } - } else { - if (registry.stream().anyMatch { it is MutableTagEntry && it.tag == tag }) { - fail { "Value with tag $tag already exists" } - return - } + override val type: Type<*> + get() = Companion - registry.add( - MutableTagEntry( - tag!!, - matter, - complexity, - priority ?: 0 - ) - ) + companion object : Type { + override val codec: Codec by lazy { + RecordCodecBuilder.create { + it.group( + TargetCodec.fieldOf("id").forGetter(InsertAction::id), + DecimalCodec.fieldOf("matter").forGetter(InsertAction::matter), + Codec.doubleRange(0.0, Double.MAX_VALUE).fieldOf("complexity").forGetter(InsertAction::complexity), + Codec.BOOL.optionalFieldOf("replace", false).forGetter(InsertAction::replaceIfExists), + Codec.BOOL.optionalFieldOf("errorOnFailure", false).forGetter(InsertAction::errorOnFailure), + Codec.INT.optionalFieldOf("priority").forGetter(InsertAction::priority), + ).apply(it, ::InsertAction) } } } 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 13fc067dc..6f45e0283 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterDataProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterDataProvider.kt @@ -1,5 +1,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 @@ -11,9 +12,13 @@ import net.minecraftforge.data.event.GatherDataEvent import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.core.registryName -import java.util.Collections +import ru.dbotthepony.mc.otm.core.toJsonStrict +import java.util.* import java.util.concurrent.CompletableFuture import java.util.function.Consumer +import kotlin.ConcurrentModificationException +import kotlin.collections.ArrayList +import kotlin.collections.LinkedHashMap @Suppress("FunctionName", "unused") open class MatterDataProvider(val modid: String? = null) : DataProvider { @@ -38,27 +43,10 @@ open class MatterDataProvider(val modid: String? = null) : DataProvider { var complexity: Double? = null var priority: Int? = null - private var _key: ResourceLocation? = null - private var _tag: TagKey? = null + var target: Either>? = null - var key: ResourceLocation? - get() = _key - set(value) { - checkNotNull(value) { "Can't set key to null" } - _tag = null - _key = value - } - - var tag: TagKey? - get() = _tag - set(value) { - checkNotNull(value) { "Can't set tag to null" } - _key = null - _tag = value - } - - protected fun checkKeyTag() { - check(_key != null || _tag != null) { "You must define either key or tag for $name" } + protected fun target(): Either> { + return checkNotNull(target) { "You must define either key or tag for $name" } } protected fun checkMatterValues() { @@ -71,75 +59,38 @@ open class MatterDataProvider(val modid: String? = null) : DataProvider { class InsertConfiguration(name: ResourceLocation) : Configuration(name) { var replaceIfExists: Boolean = false - var comparePriority: Boolean = false override fun build(): InsertAction { - checkKeyTag() checkMatterValues() check(matter != null && complexity != null) { "You must define both matter value and complexity for $name" } - if (key != null) { - return InsertAction( - key = key ?: throw ConcurrentModificationException(), - matter = matter, - complexity = complexity, - priority = priority, - errorOnFailure = errorOnFailure, - replaceIfExists = replaceIfExists, - comparePriority = comparePriority - ) - } else { - return InsertAction( - tag = tag ?: throw ConcurrentModificationException(), - matter = matter, - complexity = complexity, - priority = priority, - errorOnFailure = errorOnFailure, - replaceIfExists = replaceIfExists, - comparePriority = comparePriority - ) - } + return InsertAction( + id = target(), + matter = matter!!, + complexity = complexity!!, + priority = Optional.ofNullable(priority), + errorOnFailure = errorOnFailure, + replaceIfExists = replaceIfExists, + ) } } class DeleteConfiguration(name: ResourceLocation) : Configuration(name) { override fun build(): DeleteAction { - checkKeyTag() - check(matter == null) { "Delete action can't have matter value" } check(complexity == null) { "Delete action can't have complexity value" } - if (key != null) { - return DeleteAction( - key = key ?: throw ConcurrentModificationException(), - errorOnFailure = errorOnFailure, - ) - } else { - return DeleteAction( - tag = tag ?: throw ConcurrentModificationException(), - errorOnFailure = errorOnFailure, - ) - } + return DeleteAction(target(), errorOnFailure = errorOnFailure) } } class BlacklistConfiguration(name: ResourceLocation) : Configuration(name) { override fun build(): BlacklistAction { - checkKeyTag() - check(matter == null) { "Blacklist action can't have matter value" } check(complexity == null) { "Blacklist action can't have complexity value" } check(!errorOnFailure) { "Blacklist can't error on 'failure'" } - if (key != null) { - return BlacklistAction( - key = key ?: throw ConcurrentModificationException(), - ) - } else { - return BlacklistAction( - tag = tag ?: throw ConcurrentModificationException(), - ) - } + return BlacklistAction(target()) } } @@ -152,167 +103,128 @@ open class MatterDataProvider(val modid: String? = null) : DataProvider { } fun plus(matter: Decimal, complexity: Double): ComputeConfiguration { - values.add(ComputeAction.Constant(matter, complexity, MatterFunction.ADD)) + values.add(ComputeAction.Constant(matter, complexity, IMatterFunction.PLUS)) return this } fun minus(matter: Decimal, complexity: Double): ComputeConfiguration { - values.add(ComputeAction.Constant(matter, complexity, MatterFunction.SUBTRACT)) + values.add(ComputeAction.Constant(matter, complexity, IMatterFunction.MINUS)) return this } fun multiply(matter: Decimal, complexity: Double): ComputeConfiguration { - values.add(ComputeAction.Constant(matter, complexity, MatterFunction.MULTIPLY)) + values.add(ComputeAction.Constant(matter, complexity, IMatterFunction.MUL)) return this } fun divide(matter: Decimal, complexity: Double): ComputeConfiguration { - values.add(ComputeAction.Constant(matter, complexity, MatterFunction.DIVIDE)) + values.add(ComputeAction.Constant(matter, complexity, IMatterFunction.DIV)) return this } fun plus(key: ResourceLocation): ComputeConfiguration { - values.add(ComputeAction.Key(key, MatterFunction.ADD)) + values.add(ComputeAction.Value(Either.left(key), IMatterFunction.PLUS)) return this } fun plus(key: ItemLike): ComputeConfiguration { - values.add(ComputeAction.Key(key, MatterFunction.ADD)) + values.add(ComputeAction.Value(Either.left(key.asItem().registryName!!), IMatterFunction.PLUS)) return this } fun minus(key: ResourceLocation): ComputeConfiguration { - values.add(ComputeAction.Key(key, MatterFunction.SUBTRACT)) + values.add(ComputeAction.Value(Either.left(key), IMatterFunction.MINUS)) return this } fun minus(key: ItemLike): ComputeConfiguration { - values.add(ComputeAction.Key(key, MatterFunction.SUBTRACT)) + values.add(ComputeAction.Value(Either.left(key.asItem().registryName!!), IMatterFunction.MINUS)) return this } fun multiply(key: ResourceLocation): ComputeConfiguration { - values.add(ComputeAction.Key(key, MatterFunction.MULTIPLY)) + values.add(ComputeAction.Value(Either.left(key), IMatterFunction.MUL)) return this } fun multiply(key: ItemLike): ComputeConfiguration { - values.add(ComputeAction.Key(key, MatterFunction.MULTIPLY)) + values.add(ComputeAction.Value(Either.left(key.asItem().registryName!!), IMatterFunction.MUL)) return this } fun divide(key: ResourceLocation): ComputeConfiguration { - values.add(ComputeAction.Key(key, MatterFunction.DIVIDE)) + values.add(ComputeAction.Value(Either.left(key), IMatterFunction.DIV)) return this } fun divide(key: ItemLike): ComputeConfiguration { - values.add(ComputeAction.Key(key, MatterFunction.DIVIDE)) + values.add(ComputeAction.Value(Either.left(key.asItem().registryName!!), IMatterFunction.DIV)) return this } fun plus(tag: TagKey): ComputeConfiguration { - values.add(ComputeAction.Tag(tag, MatterFunction.ADD)) + values.add(ComputeAction.Value(Either.right(tag), IMatterFunction.PLUS)) return this } fun minus(tag: TagKey): ComputeConfiguration { - values.add(ComputeAction.Tag(tag, MatterFunction.SUBTRACT)) + values.add(ComputeAction.Value(Either.right(tag), IMatterFunction.MINUS)) return this } fun multiply(tag: TagKey): ComputeConfiguration { - values.add(ComputeAction.Tag(tag, MatterFunction.MULTIPLY)) + values.add(ComputeAction.Value(Either.right(tag), IMatterFunction.MUL)) return this } fun divide(tag: TagKey): ComputeConfiguration { - values.add(ComputeAction.Tag(tag, MatterFunction.DIVIDE)) + values.add(ComputeAction.Value(Either.right(tag), IMatterFunction.DIV)) return this } override fun build(): ComputeAction { - checkKeyTag() - check(matter == null) { "Compute action can't have matter value" } check(complexity == null) { "Compute action can't have complexity value" } - check(values.isNotEmpty()) { "Compute action is empty" } - if (key != null) { - return ComputeAction( - key = key ?: throw ConcurrentModificationException(), - value = values, - ) - } else { - return ComputeAction( - tag = tag ?: throw ConcurrentModificationException(), - value = values, - ) - } + return ComputeAction(target(), values,) } } class UpdateConfiguration(name: ResourceLocation) : Configuration(name) { - val matterFunctions = ArrayList>() - val complexityFunctions = ArrayList>() - val priorityFunctions = ArrayList>() + val matterFunctions = ArrayList() + val complexityFunctions = ArrayList() + val priorityFunctions = ArrayList() - fun addMatterFunction(function: MatterFunction, value: Decimal): UpdateConfiguration { - matterFunctions.add(BoundMatterFunction(function, value)) - matter = null + fun addMatterFunction(function: IMatterFunction, value: Decimal): UpdateConfiguration { + matterFunctions.add(UpdateAction.MatterFunction(function, value)) return this } - fun addComplexityFunction(function: MatterFunction, value: Double): UpdateConfiguration { - complexityFunctions.add(BoundMatterFunction(function, value)) - matter = null + fun addComplexityFunction(function: IMatterFunction, value: Double): UpdateConfiguration { + complexityFunctions.add(UpdateAction.ComplexityFunction(function, value)) return this } - fun addPriorityFunction(function: MatterFunction, value: Int): UpdateConfiguration { - priorityFunctions.add(BoundMatterFunction(function, value)) - matter = null + fun addPriorityFunction(function: IMatterFunction, value: Int): UpdateConfiguration { + priorityFunctions.add(UpdateAction.PriorityFunction(function, value)) return this } override fun build(): UpdateAction { - check(!(matterFunctions.isNotEmpty() && matter != null)) { "Can't have both matter value and matter value functions be defined at the same time" } - check(!(complexityFunctions.isNotEmpty() && complexity != null)) { "Can't have both complexity and complexity functions be defined at the same time" } - check(!(priorityFunctions.isNotEmpty() && priority != null)) { "Can't have both priority and priority functions be defined at the same time" } - check( - matterFunctions.isNotEmpty() || matter != null || - complexityFunctions.isNotEmpty() || complexity != null || - priorityFunctions.isNotEmpty() || priority != null + matterFunctions.isNotEmpty() || + complexityFunctions.isNotEmpty() || + priorityFunctions.isNotEmpty() ) { "Update configuration is completely empty" } - checkMatterValues() - checkKeyTag() - - if (key != null) { - return UpdateAction( - key = key ?: throw ConcurrentModificationException(), - matter = matter, - complexity = complexity, - priority = priority, - errorOnFailure = errorOnFailure, - matterFunctions = matterFunctions, - complexityFunctions = complexityFunctions, - priorityFunctions = priorityFunctions - ) - } else { - return UpdateAction( - tag = tag ?: throw ConcurrentModificationException(), - matter = matter, - complexity = complexity, - priority = priority, - errorOnFailure = errorOnFailure, - matterFunctions = matterFunctions, - complexityFunctions = complexityFunctions, - priorityFunctions = priorityFunctions - ) - } + return UpdateAction( + target(), + errorOnFailure = errorOnFailure, + matterFunctions = matterFunctions, + complexityFunctions = complexityFunctions, + priorityFunctions = priorityFunctions + ) } } @@ -1069,32 +981,32 @@ open class MatterDataProvider(val modid: String? = null) : DataProvider { // direct inheritance fun inherit(destination: ItemLike, source: ItemLike, configurator: ComputeConfiguration.() -> Unit): ComputeAction { return compute(updateLocation(destination, "item/")) { - key = destination.asItem().registryName ?: throw ConcurrentModificationException() - add(ComputeAction.Key(source, MatterFunction.ADD)) + target = Either.left(destination.asItem().registryName!!) + add(ComputeAction.Value(Either.left(source.asItem().registryName!!), IMatterFunction.PLUS)) configurator.invoke(this) } } fun inherit(destination: TagKey, source: ItemLike, configurator: ComputeConfiguration.() -> Unit): ComputeAction { return compute(updateLocation(destination.location, "tag/")) { - tag = destination - add(ComputeAction.Key(source, MatterFunction.ADD)) + target = Either.right(destination) + add(ComputeAction.Value(Either.left(source.asItem().registryName!!), IMatterFunction.PLUS)) configurator.invoke(this) } } fun inherit(destination: ItemLike, source: TagKey, configurator: ComputeConfiguration.() -> Unit): ComputeAction { return compute(updateLocation(destination, "item/")) { - key = destination.asItem().registryName ?: throw ConcurrentModificationException() - add(ComputeAction.Tag(source, MatterFunction.ADD)) + target = Either.left(destination.asItem().registryName!!) + add(ComputeAction.Value(Either.right(source), IMatterFunction.PLUS)) configurator.invoke(this) } } fun inherit(destination: TagKey, source: TagKey, configurator: ComputeConfiguration.() -> Unit): ComputeAction { return compute(updateLocation(destination.location, "tag/")) { - tag = destination - add(ComputeAction.Tag(source, MatterFunction.ADD)) + target = Either.right(destination) + add(ComputeAction.Value(Either.right(source), IMatterFunction.PLUS)) configurator.invoke(this) } } @@ -1102,56 +1014,56 @@ open class MatterDataProvider(val modid: String? = null) : DataProvider { // multiplied inheritance fun inherit(destination: ItemLike, source: ItemLike, multiplier: Double, configurator: ComputeConfiguration.() -> Unit): ComputeAction { return inherit(destination, source) { - add(ComputeAction.Constant(Decimal(multiplier), multiplier, MatterFunction.MULTIPLY)) + add(ComputeAction.Constant(Decimal(multiplier), multiplier, IMatterFunction.MUL)) configurator.invoke(this) } } fun inherit(destination: TagKey, source: ItemLike, multiplier: Double, configurator: ComputeConfiguration.() -> Unit): ComputeAction { return inherit(destination, source) { - add(ComputeAction.Constant(Decimal(multiplier), multiplier, MatterFunction.MULTIPLY)) + add(ComputeAction.Constant(Decimal(multiplier), multiplier, IMatterFunction.MUL)) configurator.invoke(this) } } fun inherit(destination: ItemLike, source: TagKey, multiplier: Double, configurator: ComputeConfiguration.() -> Unit): ComputeAction { return inherit(destination, source) { - add(ComputeAction.Constant(Decimal(multiplier), multiplier, MatterFunction.MULTIPLY)) + add(ComputeAction.Constant(Decimal(multiplier), multiplier, IMatterFunction.MUL)) configurator.invoke(this) } } fun inherit(destination: TagKey, source: TagKey, multiplier: Double, configurator: ComputeConfiguration.() -> Unit): ComputeAction { return inherit(destination, source) { - add(ComputeAction.Constant(Decimal(multiplier), multiplier, MatterFunction.MULTIPLY)) + add(ComputeAction.Constant(Decimal(multiplier), multiplier, IMatterFunction.MUL)) configurator.invoke(this) } } fun inherit(destination: ItemLike, source: ItemLike, multiplier: Decimal, configurator: ComputeConfiguration.() -> Unit): ComputeAction { return inherit(destination, source) { - add(ComputeAction.Constant(multiplier, multiplier.toDouble(), MatterFunction.MULTIPLY)) + add(ComputeAction.Constant(multiplier, multiplier.toDouble(), IMatterFunction.MUL)) configurator.invoke(this) } } fun inherit(destination: TagKey, source: ItemLike, multiplier: Decimal, configurator: ComputeConfiguration.() -> Unit): ComputeAction { return inherit(destination, source) { - add(ComputeAction.Constant(multiplier, multiplier.toDouble(), MatterFunction.MULTIPLY)) + add(ComputeAction.Constant(multiplier, multiplier.toDouble(), IMatterFunction.MUL)) configurator.invoke(this) } } fun inherit(destination: ItemLike, source: TagKey, multiplier: Decimal, configurator: ComputeConfiguration.() -> Unit): ComputeAction { return inherit(destination, source) { - add(ComputeAction.Constant(multiplier, multiplier.toDouble(), MatterFunction.MULTIPLY)) + add(ComputeAction.Constant(multiplier, multiplier.toDouble(), IMatterFunction.MUL)) configurator.invoke(this) } } fun inherit(destination: TagKey, source: TagKey, multiplier: Decimal, configurator: ComputeConfiguration.() -> Unit): ComputeAction { return inherit(destination, source) { - add(ComputeAction.Constant(multiplier, multiplier.toDouble(), MatterFunction.MULTIPLY)) + add(ComputeAction.Constant(multiplier, multiplier.toDouble(), IMatterFunction.MUL)) configurator.invoke(this) } } @@ -1219,54 +1131,54 @@ open class MatterDataProvider(val modid: String? = null) : DataProvider { fun insert(name: ItemLike, configurator: InsertConfiguration.() -> Unit): InsertAction { return insert(updateLocation(name.asItem().registryName ?: throw NullPointerException("${name.asItem()} does not have registry name!"), "item/")) { - key = name.asItem().registryName ?: throw ConcurrentModificationException() + target = Either.left(name.asItem().registryName!!) configurator.invoke(this) } } fun delete(name: ItemLike, configurator: DeleteConfiguration.() -> Unit): DeleteAction { return delete(updateLocation(name.asItem().registryName ?: throw NullPointerException("${name.asItem()} does not have registry name!"), "item/")) { - key = name.asItem().registryName ?: throw ConcurrentModificationException() + target = Either.left(name.asItem().registryName!!) configurator.invoke(this) } } fun blacklist(name: ItemLike): BlacklistAction { return blacklist(updateLocation(name.asItem().registryName ?: throw NullPointerException("${name.asItem()} does not have registry name!"), "item/")) { - key = name.asItem().registryName ?: throw ConcurrentModificationException() + target = Either.left(name.asItem().registryName!!) } } fun blacklist(name: TagKey): BlacklistAction { return blacklist(updateLocation(name.location, "tag/")) { - tag = name + target = Either.right(name) } } fun update(name: ItemLike, configurator: UpdateConfiguration.() -> Unit): UpdateAction { return update(updateLocation(name.asItem().registryName ?: throw NullPointerException("${name.asItem()} does not have registry name!"), "item/")) { - key = name.asItem().registryName ?: throw ConcurrentModificationException() + target = Either.left(name.asItem().registryName!!) configurator.invoke(this) } } fun insert(name: TagKey, configurator: InsertConfiguration.() -> Unit): InsertAction { return insert(updateLocation(name.location, "tag/")) { - tag = name + target = Either.right(name) configurator.invoke(this) } } fun delete(name: TagKey, configurator: DeleteConfiguration.() -> Unit): DeleteAction { return delete(updateLocation(name.location, "tag/")) { - tag = name + target = Either.right(name) configurator.invoke(this) } } fun update(name: TagKey, configurator: UpdateConfiguration.() -> Unit): UpdateAction { return update(updateLocation(name.location, "tag/")) { - tag = name + target = Either.right(name) configurator.invoke(this) } } @@ -1350,7 +1262,7 @@ open class MatterDataProvider(val modid: String? = null) : DataProvider { val promises = ArrayList>() for ((key, value) in actions) { - promises.add(DataProvider.saveStable(output, value.toJson(), pathProvider.json(key))) + promises.add(DataProvider.saveStable(output, AbstractRegistryAction.CODEC.toJsonStrict(value), pathProvider.json(key))) added.add(value) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterFunction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterFunction.kt deleted file mode 100644 index f4774ae06..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterFunction.kt +++ /dev/null @@ -1,78 +0,0 @@ -package ru.dbotthepony.mc.otm.matter - -import com.google.gson.JsonParseException -import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.math.integerDivisionDown -import ru.dbotthepony.mc.otm.core.math.integerDivisionUp - -enum class MatterFunction { - ADD { - override fun updateValue(self: Int, other: Int): Int = self + other - override fun updateValue(self: Decimal, other: Decimal): Decimal = self + other - override fun updateValue(self: Double, other: Double): Double = self + other - }, - SUBTRACT { - override fun updateValue(self: Int, other: Int): Int = self - other - override fun updateValue(self: Decimal, other: Decimal): Decimal = self - other - override fun updateValue(self: Double, other: Double): Double = self - other - }, - MULTIPLY { - override fun updateValue(self: Int, other: Int): Int = self * other - override fun updateValue(self: Decimal, other: Decimal): Decimal = self * other - override fun updateValue(self: Double, other: Double): Double = self * other - }, - DIVIDE { - override fun updateValue(self: Int, other: Int): Int = self / other - override fun updateValue(self: Decimal, other: Decimal): Decimal = self / other - override fun updateValue(self: Double, other: Double): Double = self / other - }, - DIVIDE_UP { - override fun updateValue(self: Int, other: Int): Int = integerDivisionUp(self, other) - override fun updateValue(self: Decimal, other: Decimal): Decimal = throw JsonParseException("Integer division up is available only for integers") - override fun updateValue(self: Double, other: Double): Double = throw JsonParseException("Integer division up is available only for integers") - }, - DIVIDE_DOWN { - override fun updateValue(self: Int, other: Int): Int = integerDivisionDown(self, other) - override fun updateValue(self: Decimal, other: Decimal): Decimal = throw JsonParseException("Integer division down is available only for integers") - override fun updateValue(self: Double, other: Double): Double = throw JsonParseException("Integer division down is available only for integers") - }, - MODULO { - override fun updateValue(self: Int, other: Int): Int = self % other - override fun updateValue(self: Decimal, other: Decimal): Decimal = self % other - override fun updateValue(self: Double, other: Double): Double = self % other - }, - AT_LEAST { - override fun updateValue(self: Int, other: Int): Int = self.coerceAtLeast(other) - override fun updateValue(self: Decimal, other: Decimal): Decimal = self.coerceAtLeast(other) - override fun updateValue(self: Double, other: Double): Double = self.coerceAtLeast(other) - }, - AT_MOST { - override fun updateValue(self: Int, other: Int): Int = self.coerceAtMost(other) - override fun updateValue(self: Decimal, other: Decimal): Decimal = self.coerceAtMost(other) - override fun updateValue(self: Double, other: Double): Double = self.coerceAtMost(other) - }, - REPLACE { - override fun updateValue(self: Int, other: Int): Int = other - override fun updateValue(self: Decimal, other: Decimal): Decimal = other - override fun updateValue(self: Double, other: Double): Double = other - }, - NOOP { - override fun updateValue(self: Int, other: Int): Int = self - override fun updateValue(self: Decimal, other: Decimal): Decimal = self - override fun updateValue(self: Double, other: Double): Double = self - }, - ; - - protected abstract fun updateValue(self: Int, other: Int): Int - protected abstract fun updateValue(self: Decimal, other: Decimal): Decimal - protected abstract fun updateValue(self: Double, other: Double): Double - - fun updateValue(self: T, other: T): T { - return when (self) { - is Decimal -> updateValue(self as Decimal, other as Decimal) as T - is Double -> updateValue(self as Double, other as Double) as T - is Int -> updateValue(self as Int, other as Int) as T - else -> throw RuntimeException("Unknown number type: ${self::class.qualifiedName}") - } - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 59cd19849..43579a4cf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -10,13 +10,13 @@ import com.google.gson.JsonParseException import com.google.gson.JsonSyntaxException import com.mojang.brigadier.arguments.StringArgumentType import com.mojang.brigadier.context.CommandContext +import com.mojang.serialization.JsonOps import it.unimi.dsi.fastutil.io.FastByteArrayInputStream import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream import it.unimi.dsi.fastutil.objects.Object2BooleanFunction import it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap import it.unimi.dsi.fastutil.objects.Object2IntArrayMap import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap -import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet import it.unimi.dsi.fastutil.objects.Reference2BooleanFunction import it.unimi.dsi.fastutil.objects.Reference2BooleanOpenHashMap import it.unimi.dsi.fastutil.objects.Reference2ObjectFunction @@ -39,7 +39,6 @@ import net.minecraft.util.profiling.ProfilerFiller import net.minecraft.world.Container import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu -import net.minecraft.world.inventory.CraftingContainer import net.minecraft.world.inventory.TransientCraftingContainer import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack @@ -77,7 +76,6 @@ import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.filterNotNull -import ru.dbotthepony.mc.otm.core.getID import ru.dbotthepony.mc.otm.core.util.formatMatter import ru.dbotthepony.mc.otm.core.util.formatMatterFull import ru.dbotthepony.mc.otm.core.util.formatSiComponent @@ -120,73 +118,6 @@ import kotlin.jvm.optionals.getOrNull import kotlin.math.pow import kotlin.math.roundToInt -internal sealed class MutableEntry( - var matter: Decimal, - var complexity: Double, - var priority: Int -) { - abstract fun freeze(): Entry -} - -internal class MutableTagEntry( - val tag: TagKey, - matter: Decimal, - complexity: Double, - priority: Int -) : MutableEntry(matter, complexity, priority) { - override fun freeze(): Entry { - return TagEntry(tag, matter, complexity, priority) - } -} - -internal class MutableKeyEntry( - val key: ResourceLocation, - matter: Decimal, - complexity: Double, - priority: Int -) : MutableEntry(matter, complexity, priority) { - init { - if (key == AIR) { - throw JsonSyntaxException("you wot, can't modify $key") - } - } - - override fun freeze(): Entry { - return KeyEntry(key, matter, complexity, priority) - } - - companion object { - private val AIR = ResourceLocation("minecraft", "air") - } -} - -internal sealed class Entry( - final override val matter: Decimal, - final override val complexity: Double, - val priority: Int, -) : IMatterValue { - companion object : Entry(Decimal.ZERO, 0.0, Int.MIN_VALUE) -} - -internal class TagEntry( - val tag: TagKey, - matter: Decimal, - complexity: Double, - priority: Int, -) : Entry(matter, complexity, priority) { - val bound by lazy { - val manager = ForgeRegistries.ITEMS.tags() ?: throw NullPointerException("Forge registry of Items has no tags!") - manager.getTag(tag) - } -} - -internal class KeyEntry( - val key: ResourceLocation, - matter: Decimal, - complexity: Double, - priority: Int, -) : Entry(matter, complexity, priority) - private fun transformQuotes(it: String?): String = if (it != null) '"' + it.replace("\"", "\"\"") + '"' else "NULL" object MatterManager { @@ -195,8 +126,8 @@ object MatterManager { private val LOGGER = LogManager.getLogger() private object Registry : SimpleJsonResourceReloadListener(GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(), MATTER_DIRECTORY) { - val keyEntries = HashMap() - val tagEntries = LinkedHashMap, TagEntry>() + val keyEntries = HashMap() + val tagEntries = LinkedHashMap, IRegistryEntry>() val keyEntriesBlacklist = HashMap() val tagEntriesBlacklist = LinkedHashMap, BlacklistAction>() @@ -235,7 +166,7 @@ object MatterManager { .orElse(null) ?: IMatterValue.Companion } - return Entry.Companion + return IRegistryEntry.Companion } /** @@ -360,51 +291,52 @@ object MatterManager { throw JsonParseException("Matter value $key has invalid type: ${json::class.qualifiedName} ($json)") } - when (val action = json["action"]?.asString?.lowercase() ?: throw JsonParseException("Missing `action` json element in $key. Possible values are: (INSERT, DELETE and UPDATE (case-insensitive))")) { - "insert" -> { - val value = InsertAction(json) + val result = AbstractRegistryAction.CODEC + .decode(JsonOps.INSTANCE, json) + .getOrThrow(false) { throw JsonSyntaxException("Failed to deserialize matter registry entry $key: $it") } + .first - if (value.replaceIfExists) { - addOrReplace.add(value to key) + when (result) { + is InsertAction -> { + if (result.replaceIfExists) { + addOrReplace.add(result to key) } else { - add.add(value to key) + add.add(result to key) } } - "update" -> update.add(UpdateAction(json) to key) - "delete" -> delete.add(DeleteAction(json) to key) - - "compute" -> { - try { - ComputeAction(json).also { - if (it.key != null) { - computeKeys.compute(it.key) { _, existing -> if (it.canReplace(existing)) it else existing } - } else { - computeTags.compute(it.tag!!) { _, existing -> if (it.canReplace(existing)) it else existing } - } + is UpdateAction -> update.add(result to key) + is ComputeAction -> { + result.id.map( + { + computeKeys.compute(it) { _, existing -> if (result.canReplace(existing)) result else existing } + }, + { + computeTags.compute(it) { _, existing -> if (result.canReplace(existing)) result else existing } } - } catch (err: Throwable) { - throw JsonSyntaxException("Processing $key failed", err) - } + ) } - "blacklist" -> { - val value = BlacklistAction(json) + is BlacklistAction -> { + result.id.map( + { + keyEntriesBlacklist[it] = result + }, + { + tagEntriesBlacklist[it] = result + } + ) - if (value.key != null) { - keyEntriesBlacklist[value.key] = value - } else { - tagEntriesBlacklist[value.tag!!] = value - } - - delete.add(value to key) + delete.add(result to key) } - else -> throw JsonParseException("Unknown action $action of $key") + is DeleteAction -> delete.add(result to key) + + else -> throw JsonParseException("Unknown action ${result::class.qualifiedName} in $key") } } - val registry = ArrayList() + val registry = ArrayList() for ((action, key) in add) action.update(registry, key) for ((action, key) in addOrReplace) action.update(registry, key) @@ -414,39 +346,42 @@ object MatterManager { for (key in keyEntriesBlacklist.keys) computeKeys.remove(key) for (key in tagEntriesBlacklist.keys) computeTags.remove(key) - val tags = HashMap, MutableTagEntry>() - val keys = HashMap() + val tags = HashMap, IMutableRegistryEntry>() + val keys = HashMap() for (entry in registry) { - if (entry is MutableTagEntry) { - val existing = tags[entry.tag] + entry.name.map( + { + val existing = keys[it] - if (existing == null || existing.priority < entry.priority) { - tags[entry.tag] = entry - } - } else if (entry is MutableKeyEntry) { - val existing = keys[entry.key] + if (existing == null || existing.priority < entry.priority) { + keys[it] = entry + } + }, + { + val existing = tags[it] - if (existing == null || existing.priority < entry.priority) { - keys[entry.key] = entry + if (existing == null || existing.priority < entry.priority) { + tags[it] = entry + } } - } + ) } for (key in keys.values) { - keyEntries[key.key] = key.freeze() as KeyEntry + keyEntries[key.name.left().orElseThrow()] = key.freeze() } - val tagEntries = ArrayList() + val tagEntries = ArrayList() for (tag in tags.values) { - tagEntries.add(tag.freeze() as TagEntry) + tagEntries.add(tag.freeze()) } tagEntries.sortBy { it.priority } for (entry in tagEntries) { - this.tagEntries[entry.tag] = entry + this.tagEntries[entry.name.right().orElseThrow()] = entry } } finally { profilerFiller.pop() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/RegistryEntries.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/RegistryEntries.kt new file mode 100644 index 000000000..ddab4fed1 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/RegistryEntries.kt @@ -0,0 +1,60 @@ +package ru.dbotthepony.mc.otm.matter + +import com.mojang.datafixers.util.Either +import net.minecraft.resources.ResourceLocation +import net.minecraft.tags.TagKey +import net.minecraft.world.item.Item +import ru.dbotthepony.mc.otm.core.math.Decimal + +interface IRegistryEntry : IMatterValue { + val name: Either> + override val matter: Decimal + override val complexity: Double + val priority: Int + + fun freeze(): IRegistryEntry { + return this + } + + companion object : IRegistryEntry { + override fun freeze(): IRegistryEntry { + return this + } + + override val name: Either> = Either.left(ResourceLocation("minecraft", "air")) + override val matter: Decimal + get() = Decimal.ZERO + override val complexity: Double + get() = 0.0 + override val priority: Int + get() = 0 + } +} + +interface IMutableRegistryEntry : IRegistryEntry { + override var matter: Decimal + override var complexity: Double + override var priority: Int + + override fun freeze(): IRegistryEntry { + throw UnsupportedOperationException() + } +} + +data class RegistryEntry( + override val name: Either>, + override val matter: Decimal, + override val complexity: Double, + override val priority: Int, +) : IRegistryEntry + +data class MutableRegistryEntry( + override val name: Either>, + override var matter: Decimal, + override var complexity: Double, + override var priority: Int, +) : IMutableRegistryEntry { + override fun freeze(): IRegistryEntry { + return RegistryEntry(name, matter, complexity, priority) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/UpdateAction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/UpdateAction.kt index ffa1ee732..6f6748ecf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/UpdateAction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/UpdateAction.kt @@ -1,195 +1,92 @@ package ru.dbotthepony.mc.otm.matter import com.google.common.collect.ImmutableList -import com.google.gson.JsonArray -import com.google.gson.JsonElement -import com.google.gson.JsonObject -import com.google.gson.JsonParseException +import com.mojang.datafixers.util.Either +import com.mojang.serialization.Codec +import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.resources.ResourceLocation import net.minecraft.tags.TagKey import net.minecraft.world.item.Item import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.set -import ru.dbotthepony.mc.otm.core.collect.stream +import ru.dbotthepony.mc.otm.data.DecimalCodec +import ru.dbotthepony.mc.otm.data.simpleCodec -class UpdateAction : AbstractRegistryAction { - companion object { - private inline fun deserializeFunctionTree(input: JsonElement?, name: String): List> { - if (input == null) { - return listOf() - } - - if (input !is JsonArray) { - throw JsonParseException("Expected $name to be JsonArray, ${input::class.qualifiedName} given") - } - - return input.stream().map { - if (it !is JsonObject) { - throw JsonParseException("All elements in function tree must be JsonObjects, ${it::class.qualifiedName} given") - } - - val type = it["type"]?.asString ?: throw JsonParseException("Invalid `type` value in function object") - val value = it["value"] ?: throw JsonParseException("Missing `value` value in function object") - - val parsedValue: T = BoundMatterFunction.getValue(value) - val fn: MatterFunction - - try { - fn = MatterFunction.valueOf(type.uppercase()) - } catch (err: NoSuchElementException) { - throw JsonParseException("No such function: $type", err) - } - - return@map BoundMatterFunction(fn, parsedValue) - }.collect(ImmutableList.toImmutableList()) - } - } - - val matterFunctions: List> - val complexityFunctions: List> - val priorityFunctions: List> - - constructor(json: JsonObject) : super(json) { - matterFunctions = deserializeFunctionTree(json["matter_functions"], "matter_functions") - complexityFunctions = deserializeFunctionTree(json["complexity_functions"], "complexity_functions") - priorityFunctions = deserializeFunctionTree(json["priority_functions"], "priority_functions") - } - - constructor( - tag: TagKey, - matter: Decimal? = null, - complexity: Double? = null, - priority: Int? = null, - errorOnFailure: Boolean = false, - matterFunctions: List> = ImmutableList.of(), - complexityFunctions: List> = ImmutableList.of(), - priorityFunctions: List> = ImmutableList.of(), - ) : super(tag = tag, matter = matter, complexity = complexity, priority = priority, errorOnFailure = errorOnFailure) { - check(matter != null || complexity != null || priority != null || matterFunctions.isNotEmpty() || complexityFunctions.isNotEmpty() || priorityFunctions.isNotEmpty()) { - "Can't update existing entries without anything specified" - } - - this.matterFunctions = ImmutableList.copyOf(matterFunctions) - this.complexityFunctions = ImmutableList.copyOf(complexityFunctions) - this.priorityFunctions = ImmutableList.copyOf(priorityFunctions) - } - - constructor( - key: ResourceLocation, - matter: Decimal? = null, - complexity: Double? = null, - priority: Int? = null, - errorOnFailure: Boolean = false, - matterFunctions: List> = ImmutableList.of(), - complexityFunctions: List> = ImmutableList.of(), - priorityFunctions: List> = ImmutableList.of(), - ) : super(key = key, matter = matter, complexity = complexity, priority = priority, errorOnFailure = errorOnFailure) { - check(matter != null || complexity != null || priority != null || matterFunctions.isNotEmpty() || complexityFunctions.isNotEmpty() || priorityFunctions.isNotEmpty()) { - "Can't update existing entries without anything specified" - } - - this.matterFunctions = ImmutableList.copyOf(matterFunctions) - this.complexityFunctions = ImmutableList.copyOf(complexityFunctions) - this.priorityFunctions = ImmutableList.copyOf(priorityFunctions) - } - - override fun toJson(): JsonObject { - return super.toJson().also { - it["action"] = "update" - - if (matterFunctions.isNotEmpty()) { - it["matter_functions"] = JsonArray().also { - for (fn in matterFunctions) { - it.add(fn.toJson()) - } - } - } - - if (complexityFunctions.isNotEmpty()) { - it["complexity_functions"] = JsonArray().also { - for (fn in complexityFunctions) { - it.add(fn.toJson()) - } - } - } - - if (priorityFunctions.isNotEmpty()) { - it["priority_functions"] = JsonArray().also { - for (fn in priorityFunctions) { - it.add(fn.toJson()) - } - } +class UpdateAction( + id: Either>, + matterFunctions: Collection, + complexityFunctions: Collection, + priorityFunctions: Collection, + errorOnFailure: Boolean = false, +) : AbstractRegistryAction(id, errorOnFailure) { + data class MatterFunction(val function: IMatterFunction, val value: Decimal) { + companion object { + val CODEC: Codec by lazy { + simpleCodec(::MatterFunction, MatterFunction::function, IMatterFunction.registry.codec, MatterFunction::value, DecimalCodec) } } } - private fun apply(value: MutableEntry, modifier: ResourceLocation) { - if (matterFunctions.isNotEmpty()) - value.matter = matterFunctions.apply(value.matter) - else if (matter != null) - value.matter = matter - - if (complexityFunctions.isNotEmpty()) - value.complexity = complexityFunctions.apply(value.complexity) - else if (complexity != null) - value.complexity = complexity - - if (priorityFunctions.isNotEmpty()) - value.priority = priorityFunctions.apply(value.priority) - else if (priority != null) - value.priority = priority + data class ComplexityFunction(val function: IMatterFunction, val value: Double) { + companion object { + val CODEC: Codec by lazy { + simpleCodec(::ComplexityFunction, ComplexityFunction::function, IMatterFunction.registry.codec, ComplexityFunction::value, Codec.DOUBLE) + } + } } - override fun update(registry: MutableCollection, modifier: ResourceLocation) { - if(!( - matter != null || - complexity != null || - priority != null || - matterFunctions.isNotEmpty() || - complexityFunctions.isNotEmpty() || - priorityFunctions.isNotEmpty() - )) { - throw JsonParseException("Can't update existing entries without anything specified (for $modifier)") - } - - if (matter != null && matterFunctions.isNotEmpty()) { - throw JsonParseException("Can't have both matter and matter functions specified at the same time (for $modifier)") - } - - if (complexity != null && complexityFunctions.isNotEmpty()) { - throw JsonParseException("Can't have both complexity and complexity functions specified at the same time (for $modifier)") - } - - if (priority != null && priorityFunctions.isNotEmpty()) { - throw JsonParseException("Can't have both priority and priority functions specified at the same time (for $modifier)") - } - - if (!checkConditions()) { - return - } - - if (key != null) { - val iterator = registry.iterator() - - for (value in iterator) { - if (value is MutableKeyEntry && value.key == key) { - apply(value, modifier) - return - } + data class PriorityFunction(val function: IMatterFunction, val value: Int) { + companion object { + val CODEC: Codec by lazy { + simpleCodec(::PriorityFunction, PriorityFunction::function, IMatterFunction.registry.codec, PriorityFunction::value, Codec.INT) } - - fail { "Could not find matter value with key $key" } - } else { - val iterator = registry.iterator() - - for (value in iterator) { - if (value is MutableTagEntry && value.tag == tag) { - apply(value, modifier) - return - } - } - - fail { "Could not find matter value with tag $tag" } } } + + companion object : Type { + override val codec: Codec by lazy { + RecordCodecBuilder.create { + it.group( + TargetCodec.fieldOf("id").forGetter(UpdateAction::id), + Codec.list(MatterFunction.CODEC).fieldOf("matterFunctions").forGetter(UpdateAction::matterFunctions), + Codec.list(ComplexityFunction.CODEC).fieldOf("complexityFunctions").forGetter(UpdateAction::complexityFunctions), + Codec.list(PriorityFunction.CODEC).fieldOf("priorityFunctions").forGetter(UpdateAction::priorityFunctions), + Codec.BOOL.optionalFieldOf("errorOnFailure", false).forGetter(UpdateAction::errorOnFailure) + ).apply(it, ::UpdateAction) + } + } + } + + val matterFunctions: ImmutableList = ImmutableList.copyOf(matterFunctions) + val complexityFunctions: ImmutableList = ImmutableList.copyOf(complexityFunctions) + val priorityFunctions: ImmutableList = ImmutableList.copyOf(priorityFunctions) + + override val type: Type<*> + get() = Companion + + private fun apply(value: IMutableRegistryEntry, modifier: ResourceLocation) { + matterFunctions.forEach { + value.matter = it.function.updateValue(value.matter, it.value) + } + + complexityFunctions.forEach { + value.complexity = it.function.updateValue(value.complexity, it.value) + } + + priorityFunctions.forEach { + value.priority = it.function.updateValue(value.priority, it.value) + } + } + + override fun doUpdate(registry: MutableCollection, source: ResourceLocation) { + val iterator = registry.iterator() + + for (value in iterator) { + if (value.name == id) { + apply(value, source) + return + } + } + + fail { "Could not find matter value with name $id" } + } } 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 c8ced79fb..443936596 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -31,6 +31,8 @@ import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.data.DecimalProvider import ru.dbotthepony.mc.otm.item.weapon.EnergySwordItem +import ru.dbotthepony.mc.otm.matter.AbstractRegistryAction +import ru.dbotthepony.mc.otm.matter.IMatterFunction import ru.dbotthepony.mc.otm.registry.objects.ColoredDecorativeBlock import ru.dbotthepony.mc.otm.registry.objects.DecorativeBlock import ru.dbotthepony.mc.otm.registry.objects.StripedColoredDecorativeBlock @@ -221,6 +223,9 @@ object MRegistry { AndroidResearchResult.register(bus) AndroidResearchResults.register(bus) + AbstractRegistryAction.register(bus) + IMatterFunction.register(bus) + MBlocks.register(bus) MBlockEntities.register(bus) MEntityTypes.register(bus) From 9758a3474c879642b096b3a28b8463345a595720 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 18 Jul 2023 21:13:51 +0700 Subject: [PATCH 0773/1199] Fix processing upgrade showing two plus signs in description --- .../kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt index cc4c30bb3..0221e0f31 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt @@ -96,7 +96,7 @@ fun IMatteryUpgrade.addUpgradeTooltipLines(tooltips: MutableCollection { var flags = 0 for (v in types) flags = flags or v.flag From 035c3edcadcfef557e74b0358e040ef09d0eb4ac Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 18 Jul 2023 21:14:06 +0700 Subject: [PATCH 0774/1199] Make plate press accept processing upgrade --- .../entity/tech/PlatePressBlockEntity.kt | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) 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 e5737178a..b68d30b98 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 @@ -32,7 +32,7 @@ class PlatePressBlockEntity( p_155230_: BlockState, val isTwin: Boolean = false, ) : MatteryWorkerBlockEntity(if (isTwin) MBlockEntities.TWIN_PLATE_PRESS else MBlockEntities.PLATE_PRESS, p_155229_, p_155230_, ::MachineItemJob, if (isTwin) 2 else 1) { - override val upgrades = UpgradeContainer(this::setChangedLight, if (isTwin) 4 else 3, UpgradeType.BASIC) + override val upgrades = UpgradeContainer(this::setChangedLight, if (isTwin) 4 else 3, UpgradeType.BASIC_PROCESSING) val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::setChangedLight, upgrades.transform(MachinesConfig.PLATE_PRESS))) val inputContainer = MatteryContainer(this::itemContainerUpdated, if (isTwin) 2 else 1).also(::addDroppableContainer) val outputContainer = MatteryContainer(this::itemContainerUpdated, if (isTwin) 2 else 1).also(::addDroppableContainer) @@ -87,10 +87,25 @@ class PlatePressBlockEntity( val level = level ?: return JobContainer.failure() - val recipe = level.recipeManager.byType(MRecipes.PLATE_PRESS).values.stream().filter { it.matches(inputContainer, id) }.findAny().orElse(null) ?: return JobContainer.noItem() - inputContainer[id].shrink(1) + val recipe = level.recipeManager + .byType(MRecipes.PLATE_PRESS) + .values + .stream() + .filter { it.matches(inputContainer, id) } + .findAny(). + orElse(null) ?: return JobContainer.noItem() + + val toProcess = inputContainer[id].count.coerceAtMost(1 + upgrades.processingItems) + + inputContainer[id].shrink(toProcess) inputContainer.setChanged(id) - return JobContainer.success(MachineItemJob(recipe.getResultItem(level.registryAccess()), recipe.workTime.toDouble(), BASELINE_CONSUMPTION, experience = recipe.experience.sample(level.random))) + + return JobContainer.success( + MachineItemJob( + recipe.getResultItem(level.registryAccess()).copyWithCount(toProcess), + recipe.workTime.toDouble(), + BASELINE_CONSUMPTION * toProcess, + experience = recipe.experience.sample(level.random))) } override fun tick() { From 3b57dcb599d582db63927d3fdb7195b740cb77ec Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Wed, 19 Jul 2023 02:12:03 +0300 Subject: [PATCH 0775/1199] =?UTF-8?q?=D1=82=D1=8B=20=D0=BA=D0=BE=D0=BC?= =?UTF-8?q?=D1=83=20=D0=B7=D0=B2=D0=BE=D0=BD=D0=B8=D1=88=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt index fd3def77d..4f913442f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt @@ -88,7 +88,6 @@ private fun Font.drawScaledDuckTyped(poseStack: PoseStack, buffer: MultiBufferSo poseStack.translate(-translation) poseStack.scale(scale, scale, scale) val inv = 1f / scale - poseStack.translate(translation * inv) val size = drawDuckTyped(poseStack, buffer, text, x * inv, y * inv, color, drawShadow, displayMode, packedLightCoords, effectColor) poseStack.popPose() From ab7e416453e004aafdc2b9892752175b921c0efd Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Wed, 19 Jul 2023 02:27:10 +0300 Subject: [PATCH 0776/1199] draw research and replication progress in pattern monitor --- .../client/screen/matter/MatterPanelScreen.kt | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) 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 06a46c8d2..80af32568 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 @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.matter import net.minecraft.ChatFormatting +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.components.EditBox import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory @@ -8,8 +9,7 @@ import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.capability.matter.IPatternState import ru.dbotthepony.mc.otm.capability.matter.IReplicationTask import ru.dbotthepony.mc.otm.client.ShiftPressedCond -import ru.dbotthepony.mc.otm.client.render.WidgetLocation -import ru.dbotthepony.mc.otm.client.render.Widgets18 +import ru.dbotthepony.mc.otm.client.render.* 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 @@ -23,6 +23,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.ScrollBarConstants import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.integerDivisionDown import ru.dbotthepony.mc.otm.core.util.ItemSorter import ru.dbotthepony.mc.otm.core.util.formatMatter @@ -177,6 +178,35 @@ class MatterPanelScreen( return list } + override fun renderRegular(graphics: GuiGraphics, itemstack: ItemStack, countOverride: String?) { + if (isPatternView) { + super.renderRegular(graphics, itemstack, "") + + menu.patternsFiltered.getOrNull(index)?.let { + if (it.researchPercent < 1f) { + font.drawScaledAligned(graphics.pose(), graphics.bufferSource(), (it.researchPercent * 100.0).roundToInt().toString() + "%", .5f, RenderGravity.BOTTOM_RIGHT, width - 1f, height - 1f, true, color = RGBAColor.WHITE) + } + } + } else { + super.renderRegular(graphics, itemstack, countOverride) + + menu.tasksFiltered.getOrNull(index)?.let { + val progress = it.finished.toFloat() / it.total.toFloat() + val processing = it.inProgress.toFloat() / it.total.toFloat() + + val barLeft = 2f + val barTop = 2f + val barWidth = width - 4f + val barHeight = 1f + + graphics.renderRect(barLeft - .5f, barTop - .5f, barWidth + 1f, barHeight + 1f, color = RGBAColor.WHITE) + graphics.renderRect(barLeft, barTop, barWidth, barHeight, color = RGBAColor.BLACK) + graphics.renderRect(barLeft, barTop, barWidth * progress, barHeight, color = RGBAColor.GREEN) + graphics.renderRect(barLeft + barWidth * progress, barTop, barWidth * processing, barHeight, color = RGBAColor.YELLOW) + } + } + } + override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { if (isPatternView) { if (minecraft?.player?.isSpectator != true) From 18a10e1f6c8a2b91ab2427ef9f99c6283158f66d Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Wed, 19 Jul 2023 03:13:33 +0300 Subject: [PATCH 0777/1199] round down scan percent --- .../mc/otm/client/screen/matter/MatterPanelScreen.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 80af32568..1c31477ba 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 @@ -184,7 +184,7 @@ class MatterPanelScreen( menu.patternsFiltered.getOrNull(index)?.let { if (it.researchPercent < 1f) { - font.drawScaledAligned(graphics.pose(), graphics.bufferSource(), (it.researchPercent * 100.0).roundToInt().toString() + "%", .5f, RenderGravity.BOTTOM_RIGHT, width - 1f, height - 1f, true, color = RGBAColor.WHITE) + font.drawScaledAligned(graphics.pose(), graphics.bufferSource(), (it.researchPercent * 100.0).toInt().toString() + "%", .5f, RenderGravity.BOTTOM_RIGHT, width - 1f, height - 1f, true, color = RGBAColor.WHITE) } } } else { From 5c2791c30c5c70a20cae5cefb4f2e8a252644ee1 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Wed, 19 Jul 2023 04:42:58 +0300 Subject: [PATCH 0778/1199] matter scanner visual progress --- .../entity/matter/MatterScannerBlockEntity.kt | 26 +++++++ .../blockentity/MatterScannerRenderer.kt | 71 +++++++++++++++++++ .../mc/otm/registry/MBlockEntities.kt | 1 + 3 files changed, 98 insertions(+) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterScannerRenderer.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt index fe2ac2847..32ff3b70d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt @@ -162,6 +162,32 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : matterNode.discover(this) } + + override fun jobUpdated(new: MachineItemJob?, old: MachineItemJob?, id: Int) { + visualItemStack = new?.itemStack ?: ItemStack.EMPTY + visualProgress = 0f + } + + var visualItemStack by synchronizer.item(observe = false) + private set + + var visualProgress by synchronizer.float().property + private set + + override fun onWorkTick( + requiredPower: Decimal, + extractedPower: Decimal, + ticksAdvanced: Double, + job: MachineItemJob, + id: Int + ): JobStatus { + val result = super.onWorkTick(requiredPower, extractedPower, ticksAdvanced, job, id) + + visualProgress = jobEventLoops[0].workProgress + + return result + } + companion object { private val BASE_CONSUMPTION get() = _BASE_CONSUMPTION.get() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterScannerRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterScannerRenderer.kt new file mode 100644 index 000000000..adf55b8b1 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterScannerRenderer.kt @@ -0,0 +1,71 @@ +package ru.dbotthepony.mc.otm.client.render.blockentity + +import com.mojang.blaze3d.platform.GlStateManager +import com.mojang.blaze3d.systems.RenderSystem +import com.mojang.blaze3d.vertex.PoseStack +import com.mojang.math.Axis +import net.minecraft.client.renderer.MultiBufferSource +import net.minecraft.client.renderer.blockentity.BlockEntityRenderer +import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider +import net.minecraft.world.item.ItemDisplayContext +import ru.dbotthepony.mc.otm.block.entity.matter.MatterScannerBlockEntity +import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource +import ru.dbotthepony.mc.otm.client.render.lockBlendFunc + +class MatterScannerRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer { + companion object { + private val source = DynamicBufferSource(maximalInitialBufferSize = 2 shl 10) + } + + override fun render( + tile: MatterScannerBlockEntity, + partialTick: Float, + pose: PoseStack, + bufferSource: MultiBufferSource, + packedLight: Int, + packedOverlay: Int + ) { + val item = tile.visualItemStack + + if (item.isEmpty) { + return + } + + pose.pushPose() + + pose.translate(0.5, 0.5, 0.5) + pose.scale(0.5f, 0.5f, 0.5f) + + pose.mulPose(Axis.XP.rotationDegrees(90f)) + pose.mulPose(Axis.ZP.rotationDegrees(tile.blockRotation.back.toYRot())) + + context.itemRenderer.renderStatic( + item, + ItemDisplayContext.FIXED, + packedLight, + packedOverlay, + pose, + source, + tile.level, + tile.blockPos.asLong().toInt() + ) + + RenderSystem.enableBlend() + RenderSystem.setShaderColor(1f, 1f, 1f, 1f - tile.visualProgress) + RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA) + + lockBlendFunc = true + + try { + source.endBatch() + } finally { + lockBlendFunc = false + } + + RenderSystem.disableBlend() + RenderSystem.defaultBlendFunc() + RenderSystem.setShaderColor(1f, 1f, 1f, 1f) + + pose.popPose() + } +} 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 493bb583b..4dd4a8041 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt @@ -84,6 +84,7 @@ object MBlockEntities { BlockEntityRenderers.register(MATTER_CAPACITOR_BANK, ::MatterBatteryBankRenderer) BlockEntityRenderers.register(MATTER_RECONSTRUCTOR, ::MatterReconstructorRenderer) BlockEntityRenderers.register(MATTER_REPLICATOR, ::MatterReplicatorRenderer) + BlockEntityRenderers.register(MATTER_SCANNER, ::MatterScannerRenderer) BlockEntityRenderers.register(HOLO_SIGN, ::HoloSignRenderer) BlockEntityRenderers.register(FLUID_TANK, ::FluidTankRenderer) } From 824d75a68081c742a6efb0f1950840b7978621d0 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Wed, 19 Jul 2023 05:06:33 +0300 Subject: [PATCH 0779/1199] highlight selected enum in tooltips --- .../ru/dbotthepony/mc/otm/datagen/lang/English.kt | 2 ++ .../screen/panels/button/EnumRectangleButtonPanel.kt | 10 ++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 71590fef0..def2d9c69 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -797,6 +797,8 @@ private fun gui(provider: MatteryLanguageProvider) { gui("slot_filter.filtered", "This slot is filtered for automation") gui("slot_filter.forbidden", "This slot is forbidden for automation mechanisms") gui("slot_filter.hint", "To remove slot filter press Ctrl + LMB") + + gui("tooltip.enum.active", "> %s") } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt index c7332ec61..44d1a1d34 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt @@ -11,12 +11,8 @@ import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel -import ru.dbotthepony.mc.otm.core.GetterSetter -import ru.dbotthepony.mc.otm.core.TextComponent -import ru.dbotthepony.mc.otm.core.next -import ru.dbotthepony.mc.otm.core.prev +import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.util.EnumValueCodec -import ru.dbotthepony.mc.otm.core.value import ru.dbotthepony.mc.otm.menu.input.IPlayerInputWithFeedback import java.util.* import java.util.function.Predicate @@ -164,7 +160,9 @@ abstract class EnumRectangleButtonPanel>( for ((k, entry) in enumMapping) { if (entry.tooltip != null && predicate.test(k)) { - listing.add(entry.tooltip.copy().withStyle(if (entry.key == prop.get()) ChatFormatting.WHITE else ChatFormatting.GRAY)) + val active = entry.key == prop.get() + val tooltip = entry.tooltip.copy().withStyle(if (active) ChatFormatting.WHITE else ChatFormatting.GRAY) + listing.add(if (active) TranslatableComponent("otm.gui.tooltip.enum.active", tooltip) else tooltip) } } From cc31b6e4bb114d9ba99de7fde571027489df1658 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Wed, 19 Jul 2023 05:51:59 +0300 Subject: [PATCH 0780/1199] pattern monitor pattern advanced tooltip lines --- .../mc/otm/datagen/lang/English.kt | 3 +++ .../mc/otm/datagen/lang/Russian.kt | 2 ++ .../client/screen/matter/MatterPanelScreen.kt | 20 ++++++++++++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index def2d9c69..ae6da6449 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -258,6 +258,9 @@ private fun misc(provider: MatteryLanguageProvider) { misc("item.pattern.infinite.stored", "Stored patterns: %s") misc("item.pattern.line", "%s [%s%%]") misc("item.pattern.research", "Researched: %s%%") + misc("item.pattern.research.item_count", "Items: %s / %s") + misc("item.pattern.research.advance", "Progress per item: %s%%") + misc("item.matter.infinite", "Stored matter: ∞ / ∞") misc("item.matter.normal", "Stored matter: %s / %s") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index ff0aed63d..ba67e6fff 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -264,6 +264,8 @@ private fun misc(provider: MatteryLanguageProvider) { misc("item.pattern.stored", "Хранимые шаблоны: %s / %s") misc("item.pattern.infinite.stored", "Хранимые шаблоны: %s") misc("item.pattern.research", "Исследовано: %s%%") + misc("item.pattern.research.item_count", "Предметы: %s / %s") + misc("item.pattern.research.advance", "Исследование за предмет: %s%%") misc("item.matter.infinite", "Хранимая материя неиссякаема") misc("item.matter.normal", "Хранимая материя: %s / %s") 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 1c31477ba..82c88585c 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 @@ -34,6 +34,7 @@ import ru.dbotthepony.mc.otm.menu.matter.ReplicationRequestPacket import ru.dbotthepony.mc.otm.network.MenuNetworkChannel import yalter.mousetweaks.api.MouseTweaksDisableWheelTweak import java.util.function.Predicate +import kotlin.math.ceil import kotlin.math.roundToInt @MouseTweaksDisableWheelTweak @@ -165,7 +166,24 @@ class MatterPanelScreen( list.add(TranslatableComponent( "otm.item.pattern.research", String.format("%.2f", it.researchPercent * 100.0) - ).withStyle(ChatFormatting.AQUA)) } + ).withStyle(ChatFormatting.AQUA)) + + if (minecraft?.options?.advancedItemTooltips == true) { + val researchAdvance = MatterManager.getResearchAdvance(it.item) + val required = ceil(1.0 / researchAdvance).toInt() + val researched = (required.toDouble() * it.researchPercent).toInt() + + list.add(TranslatableComponent( + "otm.item.pattern.research.item_count", + researched, + required + ).withStyle(ChatFormatting.DARK_GRAY)) + list.add(TranslatableComponent( + "otm.item.pattern.research.advance", + String.format("%.2f", researchAdvance * 100.0) + ).withStyle(ChatFormatting.DARK_GRAY)) + } + } } else { menu.tasksFiltered.getOrNull(index)?.let { list.add(TranslatableComponent("otm.gui.matter_task.total", it.total).withStyle(ChatFormatting.GRAY)) From ec8aa1330c85c9d374246f07a046410508b3b7c2 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Wed, 19 Jul 2023 06:20:33 +0300 Subject: [PATCH 0781/1199] =?UTF-8?q?YuRaNnNzZZ=20=E2=80=94=20=D0=A1=D0=B5?= =?UTF-8?q?=D0=B3=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=206:06=20=D0=B0=20?= =?UTF-8?q?=D0=B3=D0=B4=D0=B5.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/client/screen/matter/MatterPanelScreen.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 82c88585c..0ac028c7d 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 @@ -168,7 +168,7 @@ class MatterPanelScreen( String.format("%.2f", it.researchPercent * 100.0) ).withStyle(ChatFormatting.AQUA)) - if (minecraft?.options?.advancedItemTooltips == true) { + if (ru.dbotthepony.mc.otm.client.minecraft.options.advancedItemTooltips) { val researchAdvance = MatterManager.getResearchAdvance(it.item) val required = ceil(1.0 / researchAdvance).toInt() val researched = (required.toDouble() * it.researchPercent).toInt() From b00d275d0f7956380df184f6adc773d30bbd30cd Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 19 Jul 2023 11:27:10 +0700 Subject: [PATCH 0782/1199] Add upgrades to matter replicator --- .../otm/block/entity/matter/MatterReplicatorBlockEntity.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index e82116f59..a5f85fddf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -16,6 +16,7 @@ import ru.dbotthepony.mc.otm.block.entity.MachineJobEventLoop import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.UpgradeType import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage @@ -29,6 +30,7 @@ import ru.dbotthepony.mc.otm.capability.matter.ReplicationTask import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer +import ru.dbotthepony.mc.otm.container.UpgradeContainer import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal @@ -105,7 +107,8 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::powerLevelUpdated, ENERGY_VALUES)) + override val upgrades = UpgradeContainer(this::setChangedLight, 3, UpgradeType.BASIC) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::powerLevelUpdated, upgrades.transform(ENERGY_VALUES))) val matter = ProfiledMatterStorage(MatterStorageImpl(::matterLevelUpdated, FlowDirection.INPUT, ::MATTER_CAPACITY)) val container = MatteryContainer(::itemContainerUpdated, 5).also(::addDroppableContainer) From fe870bd4a82e5e1ae9ac623bd320a2cc5cba71cd Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 19 Jul 2023 11:29:07 +0700 Subject: [PATCH 0783/1199] Send matter back into network when not working, inside matter replicator --- .../block/entity/matter/MatterReplicatorBlockEntity.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index a5f85fddf..7bd9a001c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -191,6 +191,14 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : var lastRender = 0L var particleRenderScore = 0L + override fun tick() { + super.tick() + + if (jobEventLoops[0].currentJob == null && matter.storedMatter.isPositive) { + matter.extractMatter(matterNode.graph.receiveMatter(matter.storedMatter, false), false) + } + } + override fun computeNextJob(id: Int): JobContainer { if (energy.batteryLevel < BASE_CONSUMPTION) { return JobContainer.noEnergy() From bd34ad8d3be79c78adc5a1ad49c3d66576fc2ae3 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Wed, 19 Jul 2023 09:28:35 +0300 Subject: [PATCH 0784/1199] replicator return unused matter back to network --- .../matter/MatterReplicatorBlockEntity.kt | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index e82116f59..d3a879565 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -19,13 +19,7 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage -import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage -import ru.dbotthepony.mc.otm.capability.matter.IPatternState -import ru.dbotthepony.mc.otm.capability.matter.IReplicationTask -import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl -import ru.dbotthepony.mc.otm.capability.matter.PatternState -import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage -import ru.dbotthepony.mc.otm.capability.matter.ReplicationTask +import ru.dbotthepony.mc.otm.capability.matter.* import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer @@ -37,6 +31,7 @@ import ru.dbotthepony.mc.otm.core.math.set import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.WriteOnce +import ru.dbotthepony.mc.otm.graph.matter.MatterGraph import ru.dbotthepony.mc.otm.graph.matter.MatterNode import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.menu.matter.MatterReplicatorMenu @@ -265,6 +260,19 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return JobStatus.SUCCESS } + override fun tick() { + super.tick() + + if (jobEventLoops[0].currentJob == null && matter.storedMatter.isPositive) { + val graph = matterNode.graph as MatterGraph? ?: return + val received = graph.receiveMatter(matter.storedMatter, false) + + if (!received.isZero) { + matter.extractMatter(received, false) + } + } + } + companion object { private val BASE_CONSUMPTION get() = _BASE_CONSUMPTION.get() private val DRAIN_MULT get() = _DRAIN_MULT.get() From 03c12c5737b4c0299069009137f639db7e9a8dd2 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Wed, 19 Jul 2023 11:24:52 +0300 Subject: [PATCH 0785/1199] do use recipe_type for crafting recipe finder for things like create mechanical crafting support --- .../ru/dbotthepony/mc/otm/matter/MatterManager.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 43579a4cf..f792586c8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -471,10 +471,19 @@ object MatterManager { registrar.register("crafting") { Finder { server, data -> + val location = (data["recipe_type"] ?: throw JsonSyntaxException("Missing recipe type")).let { ResourceLocation.tryParse(it.asString) } ?: throw JsonSyntaxException("Invalid recipe type: ${data["recipe_type"]}") + + if (!ForgeRegistries.RECIPE_TYPES.containsKey(location)) { + LOGGER.error("Invalid or missing recipe category: $location!") + return@Finder Stream.empty() + } + + val findRecipeType = ForgeRegistries.RECIPE_TYPES.getValue(location) as RecipeType>? ?: throw ConcurrentModificationException() + val allowBacktrack = data["allow_backtrack"]?.asBoolean ?: true val ignoreDamageables = data["ignore_damageables"]?.asBoolean ?: false val isCritical = data["is_critical"]?.asBoolean ?: true - var stream = server.recipeManager.byType(RecipeType.CRAFTING).values.stream().filter { !it.isIncomplete } + var stream = server.recipeManager.byType(findRecipeType).values.stream().filter { !it.isIncomplete } if (ignoreDamageables) { stream = stream.filter { it.ingredients.stream().flatMap { it.items.stream() }.noneMatch { it.isDamageableItem } } From 47feee8425ac61fd89d83a40db7c40b0cbe856b9 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 19 Jul 2023 17:06:39 +0700 Subject: [PATCH 0786/1199] Fix blacklist action were not properly serialized --- src/main/kotlin/ru/dbotthepony/mc/otm/matter/DeleteAction.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/DeleteAction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/DeleteAction.kt index f208c3bfc..f1b91b715 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/DeleteAction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/DeleteAction.kt @@ -40,6 +40,9 @@ open class DeleteAction( } class BlacklistAction(id: Either>) : DeleteAction(id) { + override val type: Type<*> + get() = Companion + companion object : Type { override val codec: Codec by lazy { RecordCodecBuilder.create { From 41b5b1a57bd09dc6b08efe1374d27ee185c61241 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 19 Jul 2023 17:14:45 +0700 Subject: [PATCH 0787/1199] Even more ComputeAction/Constant codecs --- .../ru/dbotthepony/mc/otm/data/CodecList.kt | 112 ++++++++++ .../dbotthepony/mc/otm/data/DecimalCodec.kt | 10 +- .../mc/otm/matter/ComputeAction.kt | 210 ++++++++++++------ 3 files changed, 266 insertions(+), 66 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/CodecList.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/CodecList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/CodecList.kt new file mode 100644 index 000000000..0466a82da --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/CodecList.kt @@ -0,0 +1,112 @@ +package ru.dbotthepony.mc.otm.data + +import com.google.common.collect.ImmutableList +import com.mojang.datafixers.util.Pair +import com.mojang.serialization.Codec +import com.mojang.serialization.DataResult +import com.mojang.serialization.DynamicOps +import ru.dbotthepony.mc.otm.core.stream +import java.util.function.Predicate +import java.util.stream.Stream + +class CodecList(codecs: Stream>) : Codec { + constructor(codecs: Collection>) : this(codecs.stream()) + constructor(vararg codecs: Codec) : this(codecs.stream() as Stream>) + + private val codecs = codecs.collect(ImmutableList.toImmutableList()) + + init { + require(this.codecs.isNotEmpty()) { "No codecs provided" } + } + + override fun encode(input: S, ops: DynamicOps, prefix: T): DataResult { + val results = ArrayList>(codecs.size) + + for (codec in codecs) { + val result = codec.encode(input, ops, prefix) + + if (result.result().isPresent) { + return result + } else { + results.add(result) + } + } + + return DataResult.error { + "None of codecs encoded the input:\n " + results.joinToString(";\n ") { it.error().get().message() } + } + } + + override fun decode(ops: DynamicOps, input: T): DataResult> { + val results = ArrayList>>(codecs.size) + + for (codec in codecs) { + val result = codec.decode(ops, input) + + if (result.result().isPresent) { + return result + } else { + results.add(result) + } + } + + return DataResult.error { + "None of codecs decoded the input:\n " + results.joinToString(";\n ") { it.error().get().message() } + } + } +} + +class PredicatedCodecList(codecs: Stream, Predicate>>) : Codec { + constructor(codecs: Collection, Predicate>>) : this(codecs.stream()) + constructor(vararg codecs: kotlin.Pair, Predicate>) : this(codecs.stream() as Stream, Predicate>>) + + private val codecs = codecs.collect(ImmutableList.toImmutableList()) + + init { + require(this.codecs.isNotEmpty()) { "No codecs provided" } + } + + override fun encode(input: S, ops: DynamicOps, prefix: T): DataResult { + val results = ArrayList>(codecs.size) + var i = -1 + + for ((codec, predicate) in codecs) { + i++ + + if (predicate.test(input)) { + val result = codec.encode(input, ops, prefix) + + if (result.result().isPresent) { + return result + } else { + results.add(result) + } + } else { + val i2 = i + results.add(DataResult.error { "Codec #$i2 predicate tested false" }) + } + } + + return DataResult.error { + "None of codecs encoded the input:\n " + results.joinToString(";\n ") { it.error().get().message() } + } + } + + override fun decode(ops: DynamicOps, input: T): DataResult> { + val results = ArrayList>>(codecs.size) + + for ((codec) in codecs) { + val result = codec.decode(ops, input) + + if (result.result().isPresent) { + return result + } else { + results.add(result) + } + } + + return DataResult.error { + "None of codecs decoded the input:\n " + results.joinToString(";\n ") { it.error().get().message() } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt index 371e0a017..140bd0848 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt @@ -12,12 +12,20 @@ object DecimalCodec : Codec { } override fun decode(ops: DynamicOps, input: T): DataResult> { - return ops.getStringValue(input).flatMap { + val result = ops.getStringValue(input).flatMap { try { DataResult.success(Pair(Decimal(it), ops.empty())) } catch (err: NumberFormatException) { DataResult.error { "Not a valid number for converting into Decimal: $it" } } } + + if (result.result().isPresent) { + return result + } + + return ops.getNumberValue(input).flatMap { + DataResult.success(Pair(Decimal(it.toString()), ops.empty())) + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt index 5ea678522..50449c5dd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt @@ -13,7 +13,9 @@ import net.minecraft.world.item.Item import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.data.DecimalCodec +import ru.dbotthepony.mc.otm.data.PredicatedCodecList import java.util.Optional +import java.util.function.Predicate class ComputeAction( id: Either>, @@ -21,74 +23,158 @@ class ComputeAction( priority: Optional = Optional.empty(), ) : AbstractRegistryAction(id, priority = priority) { companion object : Type { - private val constantCodecConcise: Codec by lazy { - RecordCodecBuilder.create { - it.group( - DecimalCodec.fieldOf("matter").forGetter(Constant::matter), - Codec.DOUBLE.fieldOf("complexity").forGetter(Constant::complexity), - IMatterFunction.registry.codec.fieldOf("function").forGetter(Constant::matterFunction), - ).apply(it, ::Constant) - } - } - - private val constantCodecVeryConcise: Codec by lazy { - RecordCodecBuilder.create { - it.group( - DecimalCodec.fieldOf("value").forGetter(Constant::matter), - IMatterFunction.registry.codec.fieldOf("function").forGetter(Constant::matterFunction), - ).apply(it, ::Constant) - } - } - - private val constantCodecVeryConcise2: Codec by lazy { - RecordCodecBuilder.create { - it.group( - Codec.DOUBLE.fieldOf("value").forGetter(Constant::complexity), - IMatterFunction.registry.codec.fieldOf("function").forGetter(Constant::matterFunction), - ).apply(it, ::Constant) - } - } - - private val constantCodecVerbose: Codec by lazy { - RecordCodecBuilder.create { + private val constantCodecFull: kotlin.Pair, Predicate> by lazy { + RecordCodecBuilder.create { it.group( DecimalCodec.fieldOf("matter").forGetter(Constant::matter), Codec.DOUBLE.fieldOf("complexity").forGetter(Constant::complexity), IMatterFunction.registry.codec.fieldOf("matterFunction").forGetter(Constant::matterFunction), IMatterFunction.registry.codec.fieldOf("complexityFunction").forGetter(Constant::complexityFunction), ).apply(it, ::Constant) + } to Predicate { true } + } + + private val constantCodecValues: kotlin.Pair, Predicate> by lazy { + RecordCodecBuilder.create { + it.group( + DecimalCodec.fieldOf("matter").forGetter(Constant::matter), + Codec.DOUBLE.fieldOf("complexity").forGetter(Constant::complexity), + IMatterFunction.registry.codec.fieldOf("function").forGetter(Constant::matterFunction), + ).apply(it) { a, b, c -> Constant(a, b, c, c) } + } to Predicate { it.matterFunction == it.complexityFunction } + } + + private val constantCodecFunctions: kotlin.Pair, Predicate> by lazy { + RecordCodecBuilder.create { + it.group( + DecimalCodec.fieldOf("value").forGetter(Constant::matter), + IMatterFunction.registry.codec.fieldOf("matterFunction").forGetter(Constant::matterFunction), + IMatterFunction.registry.codec.fieldOf("complexityFunction").forGetter(Constant::complexityFunction), + ).apply(it) { a, b, c -> Constant(a, a.toDouble(), b, c) } + } to Predicate { it.matter == Decimal(it.complexity.toString()) } + } + + private val constantCodecConcise: kotlin.Pair, Predicate> by lazy { + RecordCodecBuilder.create { + it.group( + DecimalCodec.fieldOf("value").forGetter(Constant::matter), + IMatterFunction.registry.codec.fieldOf("function").forGetter(Constant::matterFunction), + ).apply(it) { a, b -> Constant(a, a.toDouble(), b, b) } + } to Predicate { it.matter == Decimal(it.complexity.toString()) && it.matterFunction == it.complexityFunction } + } + + private val constantCodecComplexity: kotlin.Pair, Predicate> by lazy { + RecordCodecBuilder.create { + it.group( + Codec.DOUBLE.fieldOf("complexity").forGetter(Constant::complexity), + IMatterFunction.registry.codec.fieldOf("function").forGetter(Constant::complexityFunction), + ).apply(it) { a, b -> Constant(Decimal.ZERO, a.toDouble(), IMatterFunction.NOOP, b) } + } to Predicate { it.matterFunction == IMatterFunction.NOOP } + } + + private val constantCodecComplexity2: kotlin.Pair, Predicate> by lazy { + RecordCodecBuilder.create { + it.group( + Codec.DOUBLE.fieldOf("complexity").forGetter(Constant::complexity), + IMatterFunction.registry.codec.fieldOf("complexityFunction").forGetter(Constant::complexityFunction), + ).apply(it) { a, b -> Constant(Decimal.ZERO, a.toDouble(), IMatterFunction.NOOP, b) } + } to Predicate { it.matterFunction == IMatterFunction.NOOP } + } + + private val constantCodecMatter: kotlin.Pair, Predicate> by lazy { + RecordCodecBuilder.create { + it.group( + DecimalCodec.fieldOf("matter").forGetter(Constant::matter), + IMatterFunction.registry.codec.fieldOf("function").forGetter(Constant::matterFunction), + ).apply(it) { a, b -> Constant(a, 0.0, b, IMatterFunction.NOOP) } + } to Predicate { it.complexityFunction == IMatterFunction.NOOP } + } + + private val constantCodecMatter2: kotlin.Pair, Predicate> by lazy { + RecordCodecBuilder.create { + it.group( + DecimalCodec.fieldOf("matter").forGetter(Constant::matter), + IMatterFunction.registry.codec.fieldOf("matterFunction").forGetter(Constant::matterFunction), + ).apply(it) { a, b -> Constant(a, 0.0, b, IMatterFunction.NOOP) } + } to Predicate { it.complexityFunction == IMatterFunction.NOOP } + } + + private data class StringConstantCodec(val fn: IMatterFunction, val symbol: Char) : Codec, Predicate { + val pair = this to this + + override fun encode(input: Constant, ops: DynamicOps, prefix: T): DataResult { + return DataResult.success(ops.createString(symbol + input.matter.toString())) + } + + override fun decode(ops: DynamicOps, input: T): DataResult> { + return ops.getStringValue(input).flatMap { + if (it[0] == symbol) { + try { + DataResult.success(Pair(Constant(Decimal(it.substring(1).trim()), it.substring(1).trim().toDouble(), fn, fn), ops.empty())) + } catch (err: NumberFormatException) { + DataResult.error { "Not a number: ${it.substring(1).trim()} (input string: $it)" } + } + } else { + DataResult.error { "Input string does not match expected operand: expected $symbol, got ${it[0]} (for input $it)" } + } + } + } + + override fun test(t: Constant): Boolean { + return t.matterFunction == fn && t.complexityFunction == fn && t.matter == Decimal(t.complexity.toString()) + } + } + + private object PlainStringConstantCodec : Codec, Predicate { + override fun encode(input: Constant, ops: DynamicOps, prefix: T): DataResult { + return DataResult.success(ops.createString(input.matter.toString())) + } + + override fun decode(ops: DynamicOps, input: T): DataResult> { + val result = ops.getNumberValue(input).flatMap { + try { + DataResult.success(Pair(Constant(Decimal(it.toString()), it.toDouble(), IMatterFunction.PLUS, IMatterFunction.PLUS), ops.empty())) + } catch (err: NumberFormatException) { + DataResult.error { "Not a number: $it" } + } + } + + if (result.result().isPresent) + return result + + return ops.getStringValue(input).flatMap { + try { + DataResult.success(Pair(Constant(Decimal(it), it.toDouble(), IMatterFunction.PLUS, IMatterFunction.PLUS), ops.empty())) + } catch (err: NumberFormatException) { + DataResult.error { "Not a number: $it" } + } + } + } + + override fun test(t: Constant): Boolean { + return t.matterFunction == IMatterFunction.PLUS && t.complexityFunction == IMatterFunction.PLUS && t.matter == Decimal(t.complexity.toString()) } } private val constantCodec: Codec by lazy { - Codec.either(constantCodecConcise, constantCodecVerbose) - .xmap({ it.map({ it }, { it }) }, { if (it.matterFunction == it.complexityFunction) Either.left(it) else Either.right(it) }) - } - - private object ActualConstantCodec : Codec { - override fun encode(input: Constant, ops: DynamicOps, prefix: T): DataResult { - if (input.complexity == input.matter.toDouble()) { - return constantCodecVeryConcise.encode(input, ops, prefix) - } else { - return constantCodec.encode(input, ops, prefix) - } - } - - override fun decode(ops: DynamicOps, input: T): DataResult> { - var result = constantCodecVeryConcise.decode(ops, input) - - if (result.result().isPresent) { - return result - } - - result = constantCodecVeryConcise2.decode(ops, input) - - if (result.result().isPresent) { - return result - } - - return constantCodec.decode(ops, input) - } + PredicatedCodecList( + PlainStringConstantCodec to PlainStringConstantCodec, + StringConstantCodec(IMatterFunction.DIV, '/').pair, + StringConstantCodec(IMatterFunction.MUL, '*').pair, + StringConstantCodec(IMatterFunction.AT_LEAST, '>').pair, + StringConstantCodec(IMatterFunction.AT_MOST, '<').pair, + StringConstantCodec(IMatterFunction.MINUS, '-').pair, + StringConstantCodec(IMatterFunction.MOD, '%').pair, + StringConstantCodec(IMatterFunction.REPLACE, '^').pair, + constantCodecMatter, + constantCodecMatter2, + constantCodecComplexity, + constantCodecComplexity2, + constantCodecConcise, + constantCodecFunctions, + constantCodecValues, + constantCodecFull, + ) } private val valueCodecConcise: Codec by lazy { @@ -140,7 +226,7 @@ class ComputeAction( it.group( TargetCodec.fieldOf("id").forGetter(ComputeAction::id), Codec.list(Codec - .either(ActualConstantCodec, ActualValueCodec) + .either(constantCodec, ActualValueCodec) .xmap({ it.map({ it }, { it }) }, { if (it is Constant) Either.left(it) else Either.right(it as Value) })) .fieldOf("values") .forGetter(ComputeAction::values), @@ -179,12 +265,6 @@ class ComputeAction( matterFunction: IMatterFunction, complexityFunction: IMatterFunction = matterFunction, ) : Source(matterFunction, complexityFunction) { - constructor( - value: Decimal, - matterFunction: IMatterFunction, - complexityFunction: IMatterFunction = matterFunction - ) : this(value, value.toDouble(), matterFunction, complexityFunction) - constructor( value: Double, matterFunction: IMatterFunction, From d534ebbbf225a3a89dbdb25c00719a1a52409210 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 19 Jul 2023 17:17:45 +0700 Subject: [PATCH 0788/1199] GabeN --- .../entity/matter/MatterReplicatorBlockEntity.kt | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index fc6f0da05..48ce40fbc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -271,19 +271,6 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return JobStatus.SUCCESS } - override fun tick() { - super.tick() - - if (jobEventLoops[0].currentJob == null && matter.storedMatter.isPositive) { - val graph = matterNode.graph as MatterGraph? ?: return - val received = graph.receiveMatter(matter.storedMatter, false) - - if (!received.isZero) { - matter.extractMatter(received, false) - } - } - } - companion object { private val BASE_CONSUMPTION get() = _BASE_CONSUMPTION.get() private val DRAIN_MULT get() = _DRAIN_MULT.get() From 31cb9973d56d66e1628690e34b0792402604f1c2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 19 Jul 2023 17:18:02 +0700 Subject: [PATCH 0789/1199] Shortcut when trying to receive/extract zero matter --- .../capability/matter/MatterStorageImpl.kt | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt index 72daab76b..4b60d458f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt @@ -44,25 +44,14 @@ open class MatterStorageImpl @JvmOverloads constructor( override var storedMatter = Decimal.ZERO - private var handler = LazyOptional.of { this } - - fun invalidate() { - handler.invalidate() - } - - fun revive() { - handler = LazyOptional.of { this } - } - - fun get(): LazyOptional { - return handler - } - open fun canReceiveAll(value: Decimal): Boolean { return maxStoredMatter >= value && storedMatter + value <= maxStoredMatter } override fun receiveMatter(howMuch: Decimal, simulate: Boolean): Decimal { + if (!howMuch.isPositive) + return Decimal.ZERO + val new: Decimal if (maxReceive == null) { @@ -82,6 +71,9 @@ open class MatterStorageImpl @JvmOverloads constructor( } override fun extractMatter(howMuch: Decimal, simulate: Boolean): Decimal { + if (!howMuch.isPositive) + return Decimal.ZERO + val new: Decimal if (maxExtract == null) { From 91d0f5a65b3582c3e95b8b732f5cab3ff3a21d91 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 19 Jul 2023 17:32:33 +0700 Subject: [PATCH 0790/1199] I forgor to add replicator upgrades to its menu :skull: --- .../mc/otm/client/screen/matter/MatterReplicatorScreen.kt | 2 +- .../ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt index 2bec6d949..5fb05042a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReplicatorScreen.kt @@ -32,7 +32,7 @@ class MatterReplicatorScreen(p_97741_: MatterReplicatorMenu, p_97742_: Inventory SlotPanel(this, frame, menu.storageSlots[3], 80f, PROGRESS_SLOT_TOP + 22f) SlotPanel(this, frame, menu.storageSlots[4], 80f + 18f, PROGRESS_SLOT_TOP + 22f) - makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig, upgrades = menu.upgrades) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt index 684dac899..9b8527bda 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt @@ -30,6 +30,8 @@ class MatterReplicatorMenu @JvmOverloads constructor( val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) + val upgrades = makeUpgradeSlots(3, tile?.upgrades) + init { val container = tile?.container ?: SimpleContainer(5) From 2095055e73a363a22bc44e3d03571209e0a8dcab Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 19 Jul 2023 18:30:35 +0700 Subject: [PATCH 0791/1199] Add matter capacity upgrade --- .../mc/otm/datagen/lang/English.kt | 6 +++++ .../mc/otm/datagen/lang/Russian.kt | 6 +++++ .../matter/MatterReplicatorBlockEntity.kt | 4 +-- .../dbotthepony/mc/otm/capability/Upgrades.kt | 25 +++++++++++++++++++ .../mc/otm/container/UpgradeContainer.kt | 25 +++++++++++++++---- .../dbotthepony/mc/otm/item/SimpleUpgrade.kt | 2 ++ .../ru/dbotthepony/mc/otm/registry/MItems.kt | 7 ++++++ 7 files changed, 68 insertions(+), 7 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index ae6da6449..fbfc1924a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -626,6 +626,9 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.CreativeUpgrades.ENERGY_STORAGE, "Creative Energy Storage Upgrade") add(MItems.CreativeUpgrades.ENERGY_STORAGE_FLAT, "Creative Energy Storage Upgrade (Flat)") add(MItems.CreativeUpgrades.ENERGY_STORAGE_FLAT_SMALL, "Creative Energy Storage Upgrade (Flat Small)") + add(MItems.CreativeUpgrades.MATTER_STORAGE, "Creative Matter Storage Upgrade") + add(MItems.CreativeUpgrades.MATTER_STORAGE_FLAT, "Creative Matter Storage Upgrade (Flat)") + add(MItems.CreativeUpgrades.MATTER_STORAGE_FLAT_SMALL, "Creative Matter Storage Upgrade (Flat Small)") add(MItems.CreativeUpgrades.ENERGY_THROUGHPUT, "Creative Energy Throughput Upgrade") add(MItems.CreativeUpgrades.ENERGY_THROUGHPUT_FLAT, "Creative Energy Throughput Upgrade (Flat)") add(MItems.CreativeUpgrades.ENERGY_THROUGHPUT_FLAT_SMALL, "Creative Energy Throughput Upgrade (Flat Small)") @@ -738,7 +741,9 @@ private fun gui(provider: MatteryLanguageProvider) { gui("upgrade.speed", "Operation speed: %s%%") gui("upgrade.processing_items", "Items processed per cycle: +%s") gui("upgrade.energy_storage_flat", "Energy capacity: +%s") + gui("upgrade.matter_storage_flat", "Matter capacity: +%s") gui("upgrade.energy_storage", "Energy capacity: +%s%%") + gui("upgrade.matter_storage", "Matter capacity: +%s%%") gui("upgrade.energy_consumed", "Energy consumption: %s%%") gui("upgrade.energy_throughput_flat", "Energy throughput: +%s") gui("upgrade.energy_throughput", "Energy throughput: +%s%%") @@ -749,6 +754,7 @@ private fun gui(provider: MatteryLanguageProvider) { gui("upgrade_type.allowed_none", "No possible upgrades at the moment.") gui("upgrade_type.speed", "Speed") gui("upgrade_type.processing", "Processing") + gui("upgrade_type.matter_storage", "Matter Storage") gui("upgrade_type.energy_storage", "Energy Storage") gui("upgrade_type.energy_consumption", "Energy Consumption") gui("upgrade_type.energy_throughput", "Energy Throughput") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index ba67e6fff..bc91aed29 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -629,6 +629,9 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.CreativeUpgrades.ENERGY_STORAGE, "Творческое улучшение энергохраналища") add(MItems.CreativeUpgrades.ENERGY_STORAGE_FLAT, "Творческое улучшение энергохраналища (простое)") add(MItems.CreativeUpgrades.ENERGY_STORAGE_FLAT_SMALL, "Творческое улучшение энергохраналища (малое простое)") + add(MItems.CreativeUpgrades.MATTER_STORAGE, "Творческое улучшение хранилища материи") + add(MItems.CreativeUpgrades.MATTER_STORAGE_FLAT, "Творческое улучшение хранилища материи (простое)") + add(MItems.CreativeUpgrades.MATTER_STORAGE_FLAT_SMALL, "Творческое улучшение хранилища материи (малое простое)") add(MItems.CreativeUpgrades.ENERGY_THROUGHPUT, "Творческое улучшение энергоканала") add(MItems.CreativeUpgrades.ENERGY_THROUGHPUT_FLAT, "Творческое улучшение энергоканала (простое)") add(MItems.CreativeUpgrades.ENERGY_THROUGHPUT_FLAT_SMALL, "Творческое улучшение энергоканала (малое простое)") @@ -741,7 +744,9 @@ private fun gui(provider: MatteryLanguageProvider) { gui("upgrade.speed", "Скорость работы: %s%%") gui("upgrade.processing_items", "Работы за цикл: +%s") gui("upgrade.energy_storage_flat", "Хранилище энергии: +%s") + gui("upgrade.matter_storage_flat", "Хранилище материи: +%s") gui("upgrade.energy_storage", "Хранилище энергии: +%s%%") + gui("upgrade.matter_storage", "Хранилище материи: +%s%%") gui("upgrade.energy_consumed", "Потребление энергии: %s%%") gui("upgrade.energy_throughput_flat", "Пропускная способность энергии: +%s") gui("upgrade.energy_throughput", "Пропускная способность энергии: +%s%%") @@ -752,6 +757,7 @@ private fun gui(provider: MatteryLanguageProvider) { gui("upgrade_type.allowed_none", "На данный момент нет допустимых улучшений.") gui("upgrade_type.speed", "Скорость") gui("upgrade_type.processing", "Обработка") + gui("upgrade_type.matter_storage", "Хранилище материи") gui("upgrade_type.energy_storage", "Энергохранилище") gui("upgrade_type.energy_consumption", "Энергоэффективность") gui("upgrade_type.energy_throughput", "Энергоканал") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index 48ce40fbc..9a0452ec3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -102,9 +102,9 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } - override val upgrades = UpgradeContainer(this::setChangedLight, 3, UpgradeType.BASIC) + override val upgrades = UpgradeContainer(this::setChangedLight, 3, UpgradeType.BASIC_MATTER) val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::powerLevelUpdated, upgrades.transform(ENERGY_VALUES))) - val matter = ProfiledMatterStorage(MatterStorageImpl(::matterLevelUpdated, FlowDirection.INPUT, ::MATTER_CAPACITY)) + val matter = ProfiledMatterStorage(MatterStorageImpl(::matterLevelUpdated, FlowDirection.INPUT, upgrades.matterCapacity(::MATTER_CAPACITY))) val container = MatteryContainer(::itemContainerUpdated, 5).also(::addDroppableContainer) val energyConfig = ConfigurableEnergy(energy) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt index 0221e0f31..510a2850e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt @@ -8,6 +8,7 @@ import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.immutableSet import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.util.formatMatter import ru.dbotthepony.mc.otm.core.util.formatPower /** @@ -46,6 +47,18 @@ interface IMatteryUpgrade { */ val energyStorage: Decimal get() = Decimal.ZERO + /** + * **CAM NOT be negative.** + * + * Added directly over regular matter storage capacity. + */ + val matterStorageFlat: Decimal get() = Decimal.ZERO + + /** + * **CAM NOT be negative.** + */ + val matterStorage: Decimal get() = Decimal.ZERO + /** * Value of `1` means power consumption is doubled, `2` is tripled, `-0.5` is halved. */ @@ -107,6 +120,14 @@ fun IMatteryUpgrade.addUpgradeTooltipLines(tooltips: MutableCollection= positiveBound) { tooltips.add(TranslatableComponent("otm.gui.upgrade.energy_consumed", TextComponent("+" + (energyConsumed.coerceIn(MachinesConfig.Upgrades.MIN_ENERGY, MachinesConfig.Upgrades.MAX_ENERGY) * 100).toString(0)).withStyle(ChatFormatting.DARK_RED)).withStyle(ChatFormatting.GRAY)) } else if (energyConsumed <= negativeBound) { @@ -138,6 +159,7 @@ enum class UpgradeType { ENERGY_STORAGE, ENERGY_CONSUMPTION, ENERGY_THROUGHPUT, + MATTER_STORAGE, FAILSAFE; val localeId = "otm.gui.upgrade_type.${name.lowercase()}" @@ -161,6 +183,9 @@ enum class UpgradeType { @JvmField val BASIC = set(SPEED, ENERGY_STORAGE, ENERGY_CONSUMPTION, ENERGY_THROUGHPUT) + @JvmField + val BASIC_MATTER = set(SPEED, ENERGY_STORAGE, ENERGY_CONSUMPTION, ENERGY_THROUGHPUT, MATTER_STORAGE) + @JvmField val BASIC_PROCESSING = set(SPEED, ENERGY_STORAGE, ENERGY_CONSUMPTION, ENERGY_THROUGHPUT, PROCESSING) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt index 521a25a0a..1a1be7d62 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt @@ -21,22 +21,33 @@ open class UpgradeContainer(slotCount: Int, open val allowedUpgrades: Set get() = setOf() + protected fun decimals(fn: (IMatteryUpgrade) -> Decimal, reducer: (Decimal, Decimal) -> Decimal): Decimal { + return iterator() + .filter { it.isNotEmpty } + .map { it.getCapability(MatteryCapability.UPGRADE).map(fn).orElse(Decimal.ZERO).moreThanZero() * it.count } + .reduce(Decimal.ZERO, reducer) + } + override val speedBonus: Double get() = iterator().filter { it.isNotEmpty }.mapToDouble { it.getCapability(MatteryCapability.UPGRADE).map { it.speedBonus }.orElse(0.0) * it.count }.sum() override val processingItems: Int get() = iterator().filter { it.isNotEmpty }.mapToInt { it.getCapability(MatteryCapability.UPGRADE).map { it.processingItems }.orElse(0).coerceAtLeast(0) * it.count }.reduce(0) { a, b -> a + b } override val energyStorageFlat: Decimal - get() = iterator().filter { it.isNotEmpty }.map { it.getCapability(MatteryCapability.UPGRADE).map { it.energyStorageFlat }.orElse(Decimal.ZERO).moreThanZero() * it.count }.reduce(Decimal.ZERO, Decimal::plus) + get() = decimals(IMatteryUpgrade::energyStorageFlat, Decimal::plus) override val energyStorage: Decimal - get() = iterator().filter { it.isNotEmpty }.map { it.getCapability(MatteryCapability.UPGRADE).map { it.energyStorage }.orElse(Decimal.ZERO).moreThanZero() * it.count }.reduce(Decimal.ZERO, Decimal::plus) + get() = decimals(IMatteryUpgrade::energyStorage, Decimal::plus) + override val matterStorageFlat: Decimal + get() = decimals(IMatteryUpgrade::matterStorageFlat, Decimal::plus) + override val matterStorage: Decimal + get() = decimals(IMatteryUpgrade::matterStorage, Decimal::plus) override val energyConsumed: Decimal - get() = iterator().filter { it.isNotEmpty }.map { it.getCapability(MatteryCapability.UPGRADE).map { it.energyConsumed }.orElse(Decimal.ZERO) * it.count }.reduce(Decimal.ZERO, Decimal::plus) + get() = decimals(IMatteryUpgrade::energyConsumed, Decimal::plus) override val failureMultiplier: Double get() = iterator().filter { it.isNotEmpty }.mapToDouble { it.getCapability(MatteryCapability.UPGRADE).map { it.failureMultiplier }.orElse(1.0).coerceAtLeast(0.0).pow(it.count.toDouble()) }.reduce(1.0) { a, b -> a * b } override val energyThroughputFlat: Decimal - get() = iterator().filter { it.isNotEmpty }.map { it.getCapability(MatteryCapability.UPGRADE).map { it.energyThroughputFlat }.orElse(Decimal.ZERO).moreThanZero() * it.count }.reduce(Decimal.ZERO, Decimal::plus) + get() = decimals(IMatteryUpgrade::energyThroughputFlat, Decimal::plus) override val energyThroughput: Decimal - get() = iterator().filter { it.isNotEmpty }.map { it.getCapability(MatteryCapability.UPGRADE).map { it.energyThroughput }.orElse(Decimal.ZERO).moreThanZero() * it.count }.reduce(Decimal.ZERO, Decimal::plus) + get() = decimals(IMatteryUpgrade::energyThroughput, Decimal::plus) fun transform(values: ConciseBalanceValues): ConciseBalanceValues { return object : ConciseBalanceValues { @@ -57,4 +68,8 @@ open class UpgradeContainer(slotCount: Int, open val allowedUpgrades: Set Decimal): () -> Decimal { + return { value.invoke() * (matterStorage + Decimal.ONE) + matterStorageFlat } + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/SimpleUpgrade.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/SimpleUpgrade.kt index 66fdf57bd..ff1acb9e2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/SimpleUpgrade.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/SimpleUpgrade.kt @@ -27,6 +27,8 @@ class SimpleUpgrade( override val energyConsumed: Decimal = Decimal.ZERO, override val energyThroughputFlat: Decimal = Decimal.ZERO, override val energyThroughput: Decimal = Decimal.ZERO, + override val matterStorage: Decimal = Decimal.ZERO, + override val matterStorageFlat: Decimal = Decimal.ZERO, override val failureMultiplier: Double = 1.0, ) : Item(properties), IMatteryUpgrade, ICapabilityProvider { private val resolver = LazyOptional.of { this } 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 4a5be5b0f..0fcb51a37 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -175,6 +175,10 @@ object MItems { val FAILURE: SimpleUpgrade by registry.register("creative_failure_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.FAILSAFE.set(), failureMultiplier = 2.0) } val PROCESSING_ITEMS: SimpleUpgrade by registry.register("creative_processing_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.PROCESSING.set(), processingItems = 1) } + val MATTER_STORAGE: SimpleUpgrade by registry.register("creative_matter_storage_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.MATTER_STORAGE.set(), matterStorage = Decimal.ONE) } + val MATTER_STORAGE_FLAT: SimpleUpgrade by registry.register("creative_matter_storage_flat_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.MATTER_STORAGE.set(), matterStorageFlat = Decimal.LONG_MAX_VALUE) } + val MATTER_STORAGE_FLAT_SMALL: SimpleUpgrade by registry.register("creative_matter_storage_flat2_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.MATTER_STORAGE.set(), matterStorageFlat = Decimal.INT_MAX_VALUE) } + val LIST = SupplierList( ::SPEED, ::ENERGY_CONSUMPTION, @@ -187,6 +191,9 @@ object MItems { ::FAILSAFE, ::FAILURE, ::PROCESSING_ITEMS, + ::MATTER_STORAGE, + ::MATTER_STORAGE_FLAT, + ::MATTER_STORAGE_FLAT_SMALL, ) } From 135dcb667df428fa75720654e99e5d8eeb728413 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 19 Jul 2023 18:39:30 +0700 Subject: [PATCH 0792/1199] Fix matter replicator losing upgrades --- .../mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index 9a0452ec3..415dbaef8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -135,6 +135,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : savetables.stateful(::energy, ENERGY_KEY) savetables.stateful(::matter, MATTER_STORAGE_KEY) savetables.stateful(::container, INVENTORY_KEY) + savetables.stateful(::upgrades) } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { From 9cd5bad152d293e27b71ca368712bdf5ad1327a3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 19 Jul 2023 18:43:26 +0700 Subject: [PATCH 0793/1199] If we are ticking normally, don't use global tick handler to send blockentity changes to players --- .../dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 800e50c18..f3fb2360e 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 @@ -113,8 +113,12 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc */ protected val savetablesLevel = Savetables() + private var tickedOnce = false + open fun tick() { tickList.tick() + tickedOnce = true + synchronizeToPlayers(false) } /** @@ -528,7 +532,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } val synchronizer = FieldSynchronizer { - if (isSynchronizing) + if (isSynchronizing || tickedOnce) return@FieldSynchronizer if (!isRemoved && level?.isClientSide == false && (_subCache == null || (_subCache ?: throw ConcurrentModificationException()).players.isNotEmpty())) { From ab51740ddf612ea1b96d9e5d0eaa125d455a92f3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 19 Jul 2023 21:26:22 +0700 Subject: [PATCH 0794/1199] Matter reconstructor upgrades support --- .../matter/MatterReconstructorBlockEntity.kt | 40 ++++++++++++------- .../dbotthepony/mc/otm/capability/Upgrades.kt | 3 ++ .../matter/MatterReconstructorScreen.kt | 2 +- .../menu/matter/MatterReconstructorMenu.kt | 2 + 4 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt index 0fcff8458..a2072e291 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt @@ -16,6 +16,7 @@ import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.UpgradeType import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage @@ -26,6 +27,7 @@ import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer +import ru.dbotthepony.mc.otm.container.UpgradeContainer import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal @@ -58,8 +60,9 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) var isUnableToProcess = false private set - val matter = ProfiledMatterStorage(MatterStorageImpl(::setChangedLight, FlowDirection.INPUT, ::CAPACITY)) - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::setChangedLight, ENERGY_VALUES)) + val upgrades = UpgradeContainer(this::setChangedLight, 3, UpgradeType.REPLICATOR) + val matter = ProfiledMatterStorage(MatterStorageImpl(::setChangedLight, FlowDirection.INPUT, upgrades.matterCapacity(::CAPACITY))) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::setChangedLight, upgrades.transform(ENERGY_VALUES))) val matterNode = object : MatterNode() { override fun getMatterHandler(): IMatterStorage { @@ -86,6 +89,7 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) savetables.stateful(::repairContainer) savetables.stateful(::matter) savetables.stateful(::energy) + savetables.stateful(::upgrades) savetables.decimal(::matterPerTick) savetables.double(::progressPerTick) @@ -219,13 +223,17 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) val item = repairContainer[0] - if (!item.isEmpty && matterPerTick.isPositive && progressPerTick > 0.0 && item.isRepairable && item.isDamaged) { - var progressPerTick = (repairProgress + progressPerTick).coerceAtMost(item.damageValue.toDouble()) - repairProgress + val thisProgressPerTick = progressPerTick * (1.0 + upgrades.speedBonus) + val matterPerTick = matterPerTick * (1.0 + upgrades.speedBonus) + val energyConsumption = ENERGY_CONSUMPTION * (1.0 + upgrades.speedBonus) * (upgrades.energyConsumed + Decimal.ONE) + + if (!item.isEmpty && matterPerTick.isPositive && thisProgressPerTick > 0.0 && item.isRepairable && item.isDamaged) { + var progressPerTick = (repairProgress + thisProgressPerTick).coerceAtMost(item.damageValue.toDouble()) - repairProgress if (progressPerTick <= 0.0) return - if (ENERGY_CONSUMPTION.isPositive) { + if (energyConsumption.isPositive) { if (!energy.batteryLevel.isPositive) return - val multEnergy = ENERGY_CONSUMPTION * (progressPerTick / this.progressPerTick) + val multEnergy = energyConsumption * (progressPerTick / thisProgressPerTick) progressPerTick *= (energy.extractEnergy(multEnergy, true) / multEnergy).toDouble() if (progressPerTick <= 0.0) { @@ -235,32 +243,34 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) } if (matter.storedMatter < matterPerTick) { - val graph = matterNode.graph as MatterGraph? + val toDrain = (matterPerTick * EXTRACT_TICKS + .coerceAtMost(item.damageValue) - matter.storedMatter) + .coerceAtLeast(Decimal.ZERO) + .coerceAtMost(matter.missingMatter) - if (graph != null) { - val toDrain = (matterPerTick * EXTRACT_TICKS.coerceAtMost(item.damageValue) - matter.storedMatter).coerceAtLeast(Decimal.ZERO).coerceAtMost(matter.missingMatter) - matter.receiveMatter(graph.extractMatter(toDrain, false), false) - } + matter.receiveMatter(matterNode.graph.extractMatter(toDrain, false), false) } - val toDrain = matterPerTick * (progressPerTick / this.progressPerTick) + val toDrain = matterPerTick * (progressPerTick / thisProgressPerTick) val drain = matter.extractMatter(toDrain, true) + if (!drain.isPositive) { isUnableToProcess = true return } progressPerTick *= (drain / toDrain).toDouble() + if (progressPerTick <= 0.0) { isUnableToProcess = true return } - if (failureChance <= 0.0 || level!!.random.nextDouble() >= failureChance) + if (failureChance * upgrades.failureMultiplier <= 0.0 || level!!.random.nextDouble() >= failureChance * upgrades.failureMultiplier) repairProgress += progressPerTick - energy.extractEnergy(ENERGY_CONSUMPTION * (progressPerTick / this.progressPerTick), false) - matter.extractMatter(matterPerTick * (progressPerTick / this.progressPerTick), false) + energy.extractEnergy(energyConsumption * (progressPerTick / thisProgressPerTick), false) + matter.extractMatter(matterPerTick * (progressPerTick / thisProgressPerTick), false) if (repairProgress >= 1.0) { item.damageValue = (item.damageValue - repairProgress.toInt()).coerceAtLeast(0) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt index 510a2850e..9ae1d54fe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt @@ -186,6 +186,9 @@ enum class UpgradeType { @JvmField val BASIC_MATTER = set(SPEED, ENERGY_STORAGE, ENERGY_CONSUMPTION, ENERGY_THROUGHPUT, MATTER_STORAGE) + @JvmField + val REPLICATOR = set(SPEED, ENERGY_STORAGE, ENERGY_CONSUMPTION, ENERGY_THROUGHPUT, MATTER_STORAGE, FAILSAFE) + @JvmField val BASIC_PROCESSING = set(SPEED, ENERGY_STORAGE, ENERGY_CONSUMPTION, ENERGY_THROUGHPUT, PROCESSING) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt index d87f67aec..7d9d99dff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterReconstructorScreen.kt @@ -30,7 +30,7 @@ class MatterReconstructorScreen(menu: MatterReconstructorMenu, inventory: Invent SlotPanel(this, frame, menu.slot, 66f, PROGRESS_SLOT_TOP) ProgressGaugePanel(this, frame, menu.progress, 37f, PROGRESS_ARROW_TOP) - makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig, upgrades = menu.upgrades) makeCuriosPanel(this, frame, menu.equipment.curiosSlots, autoAlign = true) PlayerEquipmentPanel(this, frame, armorSlots = menu.equipment.armorSlots).also { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt index 8527bf717..f019cbbea 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReconstructorMenu.kt @@ -32,6 +32,8 @@ class MatterReconstructorMenu( val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) + val upgrades = makeUpgradeSlots(3, tile?.upgrades) + init { addStorageSlot(slot) addInventorySlots() From b3e6caf5ba3dd4ca7ce16554bd1855cad63c235e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 19 Jul 2023 21:26:33 +0700 Subject: [PATCH 0795/1199] Matter replicator failsafe upgrades support --- .../mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index 415dbaef8..8bcb8245d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -102,7 +102,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } - override val upgrades = UpgradeContainer(this::setChangedLight, 3, UpgradeType.BASIC_MATTER) + override val upgrades = UpgradeContainer(this::setChangedLight, 3, UpgradeType.REPLICATOR) val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::powerLevelUpdated, upgrades.transform(ENERGY_VALUES))) val matter = ProfiledMatterStorage(MatterStorageImpl(::matterLevelUpdated, FlowDirection.INPUT, upgrades.matterCapacity(::MATTER_CAPACITY))) val container = MatteryContainer(::itemContainerUpdated, 5).also(::addDroppableContainer) @@ -215,7 +215,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : task = allocation.task.asImmutable(), matterValue = matter.matter, pattern = allocation.pattern?.asImmutable(), - asDust = (level?.random?.nextDouble() ?: 1.0) > (allocation.pattern?.researchPercent ?: 2.0), + asDust = (level?.random?.nextDouble() ?: 1.0) * upgrades.failureMultiplier > (allocation.pattern?.researchPercent ?: 2.0), ticks = ticks, )) } From ecb68ec36f220383b755754675e76282f379e78a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 19 Jul 2023 21:29:27 +0700 Subject: [PATCH 0796/1199] Make matter reconstructor push excess matter back into network --- .../otm/block/entity/matter/MatterReconstructorBlockEntity.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt index a2072e291..2cb36e21f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt @@ -283,6 +283,10 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) initialDamage = 0.0 visualItemStack = item visualProgress = 0f + + if (matter.storedMatter.isPositive) { + matter.extractMatter(matterNode.graph.receiveMatter(matter.storedMatter, false), false) + } } } } From 7f22b1e1755da818cbae5f4fa23919c1137e5741 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Thu, 20 Jul 2023 01:34:15 +0300 Subject: [PATCH 0797/1199] block sweeping edge enchantment for energy sword --- .../ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt index 73f2ae4ca..b36d1bc2e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt @@ -20,6 +20,7 @@ import net.minecraft.world.item.TooltipFlag import net.minecraft.world.item.Vanishable import net.minecraft.world.item.enchantment.Enchantment import net.minecraft.world.item.enchantment.EnchantmentCategory +import net.minecraft.world.item.enchantment.Enchantments import net.minecraft.world.level.Level import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.state.BlockState @@ -72,7 +73,7 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani } override fun canApplyAtEnchantingTable(stack: ItemStack, enchantment: Enchantment): Boolean { - return enchantment.category == EnchantmentCategory.WEAPON + return enchantment.category == EnchantmentCategory.WEAPON && enchantment != Enchantments.SWEEPING_EDGE } override fun getEnchantmentValue(stack: ItemStack): Int { From 54bc1bdd40cbbbc441f29d4a335b98d9f5f1ad42 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Thu, 20 Jul 2023 02:05:33 +0300 Subject: [PATCH 0798/1199] plasma projectile render --- .../render/entity/PlasmaProjectileRenderer.kt | 50 ++++++++++++------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/entity/PlasmaProjectileRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/entity/PlasmaProjectileRenderer.kt index 583e1d519..926a04f65 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/entity/PlasmaProjectileRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/entity/PlasmaProjectileRenderer.kt @@ -1,36 +1,50 @@ package ru.dbotthepony.mc.otm.client.render.entity import com.mojang.blaze3d.vertex.PoseStack +import com.mojang.math.Axis import net.minecraft.client.renderer.MultiBufferSource +import net.minecraft.client.renderer.RenderType import net.minecraft.client.renderer.entity.EntityRenderer import net.minecraft.client.renderer.entity.EntityRendererProvider +import net.minecraft.client.renderer.texture.OverlayTexture import net.minecraft.resources.ResourceLocation -import ru.dbotthepony.mc.otm.client.render.RenderGravity -import ru.dbotthepony.mc.otm.client.render.drawAligned -import ru.dbotthepony.mc.otm.client.render.rotateAroundPoint -import ru.dbotthepony.mc.otm.client.render.translation -import ru.dbotthepony.mc.otm.core.math.Angle +import ru.dbotthepony.mc.otm.OverdriveThatMatters.loc import ru.dbotthepony.mc.otm.entity.PlasmaProjectile class PlasmaProjectileRenderer(context: EntityRendererProvider.Context) : EntityRenderer(context) { - override fun getTextureLocation(p_114482_: PlasmaProjectile): ResourceLocation { - throw UnsupportedOperationException() - } + override fun getTextureLocation(p_114482_: PlasmaProjectile): ResourceLocation = PLASMA_PROJECTILE_LOCATION override fun render( entity: PlasmaProjectile, - p_114486_: Float, - p_114487_: Float, - pose: PoseStack, + entityYaw: Float, + partialTick: Float, + poseStack: PoseStack, buffer: MultiBufferSource, - p_114490_: Int + packedLight: Int ) { - super.render(entity, p_114486_, p_114487_, pose, buffer, p_114490_) + val consumer = buffer.getBuffer(RENDER_TYPE) - pose.pushPose() - pose.scale(0.03f, 0.03f, 0.03f) - pose.rotateAroundPoint(pose.translation(), Angle.deg(roll = entity.xRot.toDouble(), yaw = entity.yRot.toDouble(), pitch = 180.0)) - font.drawAligned(pose, "PLASMA", RenderGravity.CENTER_CENTER, 0f, 0f, 0xFFFFFF) - pose.popPose() + poseStack.pushPose() + + poseStack.mulPose(entityRenderDispatcher.cameraOrientation()) + poseStack.mulPose(Axis.YP.rotationDegrees(180f)) + poseStack.scale(.3f, .3f, .3f) + + val matrix = poseStack.last().pose() + val normal = poseStack.last().normal() + + consumer.vertex(matrix, -.5f, -.5f, 0f).color(1f, 1f, 1f, 1f).uv(0f, 1f).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(packedLight).normal(normal, 0f, 1f, 0f).endVertex() + consumer.vertex(matrix, .5f, -.5f, 0f).color(1f, 1f, 1f, 1f).uv(1f, 1f).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(packedLight).normal(normal, 0f, 1f, 0f).endVertex() + consumer.vertex(matrix, .5f, .5f, 0f).color(1f, 1f, 1f, 1f).uv(1f, 0f).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(packedLight).normal(normal, 0f, 1f, 0f).endVertex() + consumer.vertex(matrix, -.5f, .5f, 0f).color(1f, 1f, 1f, 1f).uv(0f, 0f).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(packedLight).normal(normal, 0f, 1f, 0f).endVertex() + + poseStack.popPose() + + super.render(entity, entityYaw, partialTick, poseStack, buffer, packedLight) + } + + companion object { + private val PLASMA_PROJECTILE_LOCATION: ResourceLocation = loc("textures/misc/plasma_ball.png") + private val RENDER_TYPE = RenderType.itemEntityTranslucentCull(PLASMA_PROJECTILE_LOCATION) } } From 1f1b6e5f5918877c7f142f3e79ba268c35880f5f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 20 Jul 2023 17:27:01 +0700 Subject: [PATCH 0799/1199] Powered Furnace, Blast Furnace, Smoker --- .../mc/otm/datagen/lang/English.kt | 4 + .../mc/otm/datagen/lang/Russian.kt | 4 + .../mc/otm/datagen/loot/LootTablesData.kt | 4 + .../dbotthepony/mc/otm/datagen/tags/Tags.kt | 4 + .../block/entity/MatteryWorkerBlockEntity.kt | 4 +- .../matter/MatterRecyclerBlockEntity.kt | 2 +- .../matter/MatterReplicatorBlockEntity.kt | 3 +- .../entity/matter/MatterScannerBlockEntity.kt | 2 +- .../entity/tech/PlatePressBlockEntity.kt | 6 +- .../entity/tech/PoweredFurnaceBlockEntity.kt | 117 ++++++++++++++++++ .../mc/otm/block/tech/PoweredFurnaceBlock.kt | 27 ++++ .../screen/tech/PoweredFurnaceScreen.kt | 35 ++++++ .../mc/otm/config/AbstractConfig.kt | 61 +++++++++ .../mc/otm/config/BalanceValues.kt | 23 ++++ .../mc/otm/config/BatteryBalanceValues.kt | 7 -- .../mc/otm/config/ConciseBalanceValues.kt | 8 -- .../dbotthepony/mc/otm/config/ItemsConfig.kt | 42 ------- .../mc/otm/config/MachinesConfig.kt | 24 ++++ .../mc/otm/config/VerboseBalanceValues.kt | 9 -- ...ContainerProxy.kt => CombinedContainer.kt} | 81 ++++++------ .../mc/otm/core/util/Savetables.kt | 8 ++ .../ru/dbotthepony/mc/otm/menu/Slots.kt | 11 ++ .../mc/otm/menu/tech/PoweredFurnaceMenu.kt | 41 ++++++ .../mc/otm/registry/MBlockEntities.kt | 4 + .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 7 +- .../ru/dbotthepony/mc/otm/registry/MItems.kt | 7 +- .../ru/dbotthepony/mc/otm/registry/MMenus.kt | 4 + .../ru/dbotthepony/mc/otm/registry/MNames.kt | 3 + .../dbotthepony/mc/otm/registry/MRegistry.kt | 36 ++++++ 29 files changed, 473 insertions(+), 115 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PoweredFurnaceBlockEntity.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PoweredFurnaceScreen.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/config/BalanceValues.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/config/BatteryBalanceValues.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/config/ConciseBalanceValues.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/config/VerboseBalanceValues.kt rename src/main/kotlin/ru/dbotthepony/mc/otm/container/{ContainerProxy.kt => CombinedContainer.kt} (68%) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PoweredFurnaceMenu.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index fbfc1924a..ec8988def 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -423,6 +423,10 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.PLATE_PRESS, "Plate Press") add(MBlocks.TWIN_PLATE_PRESS, "Twin Plate Press") + add(MBlocks.POWERED_FURNACE, "Powered Furnace") + add(MBlocks.POWERED_SMOKER, "Powered Smoker") + add(MBlocks.POWERED_BLAST_FURNACE, "Powered Blast Furnace") + add(MBlocks.MATTER_RECYCLER, "Matter Recycler") add(MBlocks.ENERGY_SERVO, "Energy Servo") add(MBlocks.ENERGY_SERVO, "desc", "Charges, Discharges or Exchanges energy of items") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index bc91aed29..7eb5f2596 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -426,6 +426,10 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.PLATE_PRESS, "Пресс пластин") add(MBlocks.TWIN_PLATE_PRESS, "Двойной пресс пластин") + add(MBlocks.POWERED_FURNACE, "Электрическая печь") + add(MBlocks.POWERED_BLAST_FURNACE, "Электрическая плавильная печь") + add(MBlocks.POWERED_SMOKER, "Электрическая коптильня") + add(MBlocks.MATTER_RECYCLER, "Перерабатыватель материи") add(MBlocks.ENERGY_SERVO, "Энергетическая помпа") add(MBlocks.ENERGY_SERVO, "Desc", "заряжает, разряжает и передаёт энергию между предметами") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index 971a5b63f..d4d9e9566 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -154,6 +154,10 @@ fun addLootTables(lootTables: LootTables) { lootTables.tile(MBlocks.PLATE_PRESS) lootTables.tile(MBlocks.TWIN_PLATE_PRESS) + lootTables.tile(MBlocks.POWERED_FURNACE) + lootTables.tile(MBlocks.POWERED_SMOKER) + lootTables.tile(MBlocks.POWERED_BLAST_FURNACE) + lootTables.tile(MBlocks.MATTER_PANEL) lootTables.tile(MBlocks.PATTERN_STORAGE) lootTables.tile(MBlocks.MATTER_CAPACITOR_BANK) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index b69231e57..5f9851f86 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -161,6 +161,10 @@ fun addTags(tagsProvider: TagsProvider) { MBlocks.TWIN_PLATE_PRESS, MBlocks.MATTER_RECYCLER, + MBlocks.POWERED_FURNACE, + MBlocks.POWERED_SMOKER, + MBlocks.POWERED_BLAST_FURNACE, + MBlocks.STORAGE_BUS, MBlocks.STORAGE_IMPORTER, MBlocks.STORAGE_EXPORTER, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt index 42b5c7a49..78be6a527 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt @@ -15,11 +15,9 @@ import ru.dbotthepony.mc.otm.capability.IMatteryUpgrade import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matteryEnergy -import ru.dbotthepony.mc.otm.container.UpgradeContainer import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.nbt.getCompoundList -import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set /** @@ -116,7 +114,7 @@ abstract class MatteryWorkerBlockEntity( jobEventLoops.forEach { it.isIdling = false } } - protected fun powerLevelUpdated() { + protected fun energyLevelUpdated() { super.setChangedLight() jobEventLoops.forEach { it.notify(MachineJobEventLoop.IdleReason.POWER) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index aac8e8df3..fd31b7739 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -70,7 +70,7 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) val container = MatteryContainer(::itemContainerUpdated, 1).also(::addDroppableContainer) val matterNode = SimpleMatterNode(matter = matter) - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::powerLevelUpdated, ENERGY_CONFIG)) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::energyLevelUpdated, ENERGY_CONFIG)) val itemConfig = ConfigurableItemHandler(input = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index 8bcb8245d..a71405fc6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -33,7 +33,6 @@ import ru.dbotthepony.mc.otm.core.math.set import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.WriteOnce -import ru.dbotthepony.mc.otm.graph.matter.MatterGraph import ru.dbotthepony.mc.otm.graph.matter.MatterNode import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.menu.matter.MatterReplicatorMenu @@ -103,7 +102,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } override val upgrades = UpgradeContainer(this::setChangedLight, 3, UpgradeType.REPLICATOR) - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::powerLevelUpdated, upgrades.transform(ENERGY_VALUES))) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::energyLevelUpdated, upgrades.transform(ENERGY_VALUES))) val matter = ProfiledMatterStorage(MatterStorageImpl(::matterLevelUpdated, FlowDirection.INPUT, upgrades.matterCapacity(::MATTER_CAPACITY))) val container = MatteryContainer(::itemContainerUpdated, 5).also(::addDroppableContainer) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt index 32ff3b70d..ad51f4083 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt @@ -38,7 +38,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryWorkerBlockEntity(MBlockEntities.MATTER_SCANNER, p_155229_, p_155230_, ::MachineItemJob) { val container = MatteryContainer(::itemContainerUpdated, 1).also(::addDroppableContainer) - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::powerLevelUpdated, ENERGY_VALUES)) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::energyLevelUpdated, ENERGY_VALUES)) val itemConfig = ConfigurableItemHandler(inputOutput = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { 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 b68d30b98..ea539f9fb 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 @@ -12,7 +12,6 @@ import ru.dbotthepony.mc.otm.block.entity.JobContainer import ru.dbotthepony.mc.otm.block.entity.JobStatus import ru.dbotthepony.mc.otm.block.entity.MachineItemJob import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity -import ru.dbotthepony.mc.otm.capability.IMatteryUpgrade import ru.dbotthepony.mc.otm.capability.UpgradeType import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage @@ -33,11 +32,12 @@ class PlatePressBlockEntity( val isTwin: Boolean = false, ) : MatteryWorkerBlockEntity(if (isTwin) MBlockEntities.TWIN_PLATE_PRESS else MBlockEntities.PLATE_PRESS, p_155229_, p_155230_, ::MachineItemJob, if (isTwin) 2 else 1) { override val upgrades = UpgradeContainer(this::setChangedLight, if (isTwin) 4 else 3, UpgradeType.BASIC_PROCESSING) - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::setChangedLight, upgrades.transform(MachinesConfig.PLATE_PRESS))) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::energyLevelUpdated, upgrades.transform(MachinesConfig.PLATE_PRESS))) val inputContainer = MatteryContainer(this::itemContainerUpdated, if (isTwin) 2 else 1).also(::addDroppableContainer) val outputContainer = MatteryContainer(this::itemContainerUpdated, if (isTwin) 2 else 1).also(::addDroppableContainer) var experience = 0.0 + private set fun popExperience(player: ServerPlayer) { val whole = experience.toInt() @@ -105,7 +105,7 @@ class PlatePressBlockEntity( recipe.getResultItem(level.registryAccess()).copyWithCount(toProcess), recipe.workTime.toDouble(), BASELINE_CONSUMPTION * toProcess, - experience = recipe.experience.sample(level.random))) + experience = recipe.experience.sample(level.random) * toProcess)) } override fun tick() { 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 new file mode 100644 index 000000000..7d04fe739 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PoweredFurnaceBlockEntity.kt @@ -0,0 +1,117 @@ +package ru.dbotthepony.mc.otm.block.entity.tech + +import net.minecraft.core.BlockPos +import net.minecraft.server.level.ServerLevel +import net.minecraft.server.level.ServerPlayer +import net.minecraft.world.Container +import net.minecraft.world.entity.ExperienceOrb +import net.minecraft.world.entity.player.Inventory +import net.minecraft.world.entity.player.Player +import net.minecraft.world.inventory.AbstractContainerMenu +import net.minecraft.world.item.crafting.AbstractCookingRecipe +import net.minecraft.world.item.crafting.Recipe +import net.minecraft.world.item.crafting.RecipeType +import net.minecraft.world.level.block.entity.BlockEntityType +import net.minecraft.world.level.block.state.BlockState +import ru.dbotthepony.mc.otm.block.entity.JobContainer +import ru.dbotthepony.mc.otm.block.entity.JobStatus +import ru.dbotthepony.mc.otm.block.entity.MachineItemJob +import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity +import ru.dbotthepony.mc.otm.capability.CombinedItemHandler +import ru.dbotthepony.mc.otm.capability.UpgradeType +import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.config.WorkerBalanceValues +import ru.dbotthepony.mc.otm.container.CombinedContainer +import ru.dbotthepony.mc.otm.container.HandlerFilter +import ru.dbotthepony.mc.otm.container.MatteryContainer +import ru.dbotthepony.mc.otm.container.UpgradeContainer +import ru.dbotthepony.mc.otm.container.balance +import ru.dbotthepony.mc.otm.core.immutableList +import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu + +class PoweredFurnaceBlockEntity( + type: BlockEntityType, + blockPos: BlockPos, + blockState: BlockState, + val recipeType: RecipeType, + val config: WorkerBalanceValues +) : MatteryWorkerBlockEntity(type, blockPos, blockState, ::MachineItemJob, 2) { + override val upgrades = UpgradeContainer(this::setChangedLight, 2, UpgradeType.BASIC_PROCESSING) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::energyLevelUpdated, upgrades.transform(config))) + + val inputs = immutableList(2) { MatteryContainer(this::itemContainerUpdated, 1) } + val outputs = immutableList(2) { MatteryContainer(this::itemContainerUpdated, 1) } + + val energyConfig = ConfigurableEnergy(energy) + val itemConfig = ConfigurableItemHandler( + input = CombinedItemHandler(inputs.map { it.handler(HandlerFilter.OnlyIn) }), + output = CombinedItemHandler(outputs.map { it.handler(HandlerFilter.OnlyOut) }), + battery = batteryItemHandler + ) + + var experience = 0.0 + private set + + fun popExperience(player: ServerPlayer) { + val whole = experience.toInt() + + if (whole > 0) { + experience -= whole + ExperienceOrb.award(player.level() as ServerLevel, player.position(), whole) + } + } + + init { + savetables.stateful(::upgrades) + savetables.stateful(::energy) + + savetables.double(::experience) + + savetables.stateful(inputs, "input") + savetables.stateful(outputs, "output") + } + + private val combined = CombinedContainer(inputs) + + override fun tick() { + super.tick() + + if (balanceInputs) { + combined.balance() + } + } + + override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { + return PoweredFurnaceMenu(containerID, inventory, this) + } + + override fun onJobFinish(job: MachineItemJob, id: Int): JobStatus { + if (outputs[id].fullyAddItem(job.itemStack)) { + experience += job.experience + return JobStatus.SUCCESS + } + + return JobStatus.FAILURE_ITEM + } + + override fun computeNextJob(id: Int): JobContainer { + if (!energy.batteryLevel.isPositive) + return JobContainer.noEnergy() + + if (inputs[id].isEmpty) + return JobContainer.noItem() + + val level = level as? ServerLevel ?: return JobContainer.failure() + + return level.recipeManager.getRecipeFor(recipeType as RecipeType, inputs[id], level).map { + val output = it.assemble(inputs[id], level.registryAccess()) + val toProcess = inputs[id][0].count.coerceAtMost(upgrades.processingItems + 1) + inputs[id][0].shrink(toProcess) + + JobContainer.success(MachineItemJob( + output.copyWithCount(toProcess), it.cookingTime * config.workTimeMultiplier, config.powerConsumption * toProcess, it.experience * toProcess + )) + }.orElse(JobContainer.noItem()) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt new file mode 100644 index 000000000..e6c0c95f6 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt @@ -0,0 +1,27 @@ +package ru.dbotthepony.mc.otm.block.tech + +import net.minecraft.core.BlockPos +import net.minecraft.world.item.crafting.AbstractCookingRecipe +import net.minecraft.world.item.crafting.RecipeType +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.EntityBlock +import net.minecraft.world.level.block.entity.BlockEntity +import net.minecraft.world.level.block.entity.BlockEntityTicker +import net.minecraft.world.level.block.entity.BlockEntityType +import net.minecraft.world.level.block.state.BlockState +import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.entity.tech.PoweredFurnaceBlockEntity +import ru.dbotthepony.mc.otm.config.WorkerBalanceValues + +class PoweredFurnaceBlock(val type: () -> BlockEntityType, val recipeType: RecipeType, val config: WorkerBalanceValues) : RotatableMatteryBlock(), EntityBlock { + override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): PoweredFurnaceBlockEntity { + return PoweredFurnaceBlockEntity(type.invoke(), p_153215_, p_153216_, recipeType, config) + } + + override fun getTicker(p_153212_: Level, p_153213_: BlockState, p_153214_: BlockEntityType): BlockEntityTicker? { + if (p_153212_.isClientSide) + return null + + return BlockEntityTicker { _, _, _, tile -> if (tile is PoweredFurnaceBlockEntity) tile.tick() } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PoweredFurnaceScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PoweredFurnaceScreen.kt new file mode 100644 index 000000000..2f124d235 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PoweredFurnaceScreen.kt @@ -0,0 +1,35 @@ +package ru.dbotthepony.mc.otm.client.screen.tech + +import net.minecraft.network.chat.Component +import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls +import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel +import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu +import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu + +class PoweredFurnaceScreen(menu: PoweredFurnaceMenu, inventory: Inventory, title: Component) : + MatteryScreen(menu, inventory, title) { + override fun makeMainFrame(): FramePanel> { + val frame = super.makeMainFrame()!! + + WideProfiledPowerGaugePanel(this, frame, menu.profiledEnergy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) + BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) + + SlotPanel(this, frame, menu.inputSlots[0], 56f, PROGRESS_SLOT_TOP - 10f) + ProgressGaugePanel(this, frame, menu.progressGauge[0], 78f, PROGRESS_ARROW_TOP - 10f) + SlotPanel(this, frame, menu.outputSlots[0], 104f, PROGRESS_SLOT_TOP - 10f) + + SlotPanel(this, frame, menu.inputSlots[1], 56f, PROGRESS_SLOT_TOP + 10f) + ProgressGaugePanel(this, frame, menu.progressGauge[1], 78f, PROGRESS_ARROW_TOP + 10f) + SlotPanel(this, frame, menu.outputSlots[1], 104f, PROGRESS_SLOT_TOP + 10f) + + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig, balanceInputs = menu.balanceInputs, upgrades = menu.upgrades) + + return frame + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt index 399ffca68..3beed9f61 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt @@ -4,6 +4,8 @@ import net.minecraftforge.common.ForgeConfigSpec import net.minecraftforge.fml.ModLoadingContext import net.minecraftforge.fml.config.ModConfig import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.core.util.WriteOnce abstract class AbstractConfig(private val configName: String, private val type: ModConfig.Type = ModConfig.Type.SERVER) { @@ -11,6 +13,65 @@ abstract class AbstractConfig(private val configName: String, private val type: protected val builder = ForgeConfigSpec.Builder() private var registered = false + fun verboseValues(name: String, storage: Decimal, receive: Decimal, extract: Decimal = receive): VerboseBalanceValues { + builder.push(name) + + val obj = object : VerboseBalanceValues { + override val capacity: Decimal by builder.defineDecimal("capacity", storage, minimum = Decimal.ONE) + override val receive: Decimal by builder.defineDecimal("receive", receive, minimum = Decimal.ONE) + override val extract: Decimal by builder.defineDecimal("extract", extract, minimum = Decimal.ONE) + } + + builder.pop() + + return obj + } + + fun batteryValues(name: String, storage: Decimal, receive: Decimal, extract: Decimal = receive, initialBatteryLevel: Decimal = Decimal.ZERO): BatteryBalanceValues { + builder.push(name) + + val obj = object : BatteryBalanceValues { + override val capacity: Decimal by builder.defineDecimal("capacity", storage, minimum = Decimal.ONE) + override val receive: Decimal by builder.defineDecimal("receive", receive, minimum = Decimal.ONE) + override val extract: Decimal by builder.defineDecimal("extract", extract, minimum = Decimal.ONE) + override val initialBatteryLevel: Decimal by builder.defineDecimal("initialBatteryLevel", initialBatteryLevel, minimum = Decimal.ZERO) + } + + builder.pop() + + return obj + } + + fun conciseValues(name: String, storage: Decimal, throughput: Decimal, configurator: ForgeConfigSpec.Builder.() -> Unit = {}): ConciseBalanceValues { + builder.push(name) + + val obj = object : ConciseBalanceValues { + override val capacity: Decimal by builder.defineDecimal("capacity", storage, minimum = Decimal.ONE) + override val throughput: Decimal by builder.defineDecimal("throughput", throughput, minimum = Decimal.ONE) + } + + configurator.invoke(builder) + builder.pop() + + return obj + } + + fun workerValues(name: String, storage: Decimal, throughput: Decimal, workTimeMultiplier: Double = 1.0, powerConsumption: Decimal, configurator: ForgeConfigSpec.Builder.() -> Unit = {}): WorkerBalanceValues { + builder.push(name) + + val obj = object : WorkerBalanceValues { + override val capacity: Decimal by builder.defineDecimal("capacity", storage, minimum = Decimal.ONE) + override val throughput: Decimal by builder.defineDecimal("throughput", throughput, minimum = Decimal.ONE) + override val powerConsumption: Decimal by builder.defineDecimal("powerConsumption", powerConsumption, minimum = Decimal.ONE) + override val workTimeMultiplier: Double by builder.defineInRange("workTimeMultiplier", workTimeMultiplier, 0.0) + } + + configurator.invoke(builder) + builder.pop() + + return obj + } + fun register() { check(!registered) { "Already registered config" } registered = true diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/BalanceValues.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/BalanceValues.kt new file mode 100644 index 000000000..5a7ed0fbc --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/BalanceValues.kt @@ -0,0 +1,23 @@ +package ru.dbotthepony.mc.otm.config + +import ru.dbotthepony.mc.otm.core.math.Decimal + +interface ConciseBalanceValues { + val capacity: Decimal + val throughput: Decimal +} + +interface WorkerBalanceValues : ConciseBalanceValues { + val workTimeMultiplier: Double + val powerConsumption: Decimal +} + +interface BatteryBalanceValues : VerboseBalanceValues { + val initialBatteryLevel: Decimal +} + +interface VerboseBalanceValues { + val capacity: Decimal + val receive: Decimal + val extract: Decimal +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/BatteryBalanceValues.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/BatteryBalanceValues.kt deleted file mode 100644 index 5cb55730a..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/BatteryBalanceValues.kt +++ /dev/null @@ -1,7 +0,0 @@ -package ru.dbotthepony.mc.otm.config - -import ru.dbotthepony.mc.otm.core.math.Decimal - -interface BatteryBalanceValues : VerboseBalanceValues { - val initialBatteryLevel: Decimal -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ConciseBalanceValues.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ConciseBalanceValues.kt deleted file mode 100644 index 06b3e90bd..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ConciseBalanceValues.kt +++ /dev/null @@ -1,8 +0,0 @@ -package ru.dbotthepony.mc.otm.config - -import ru.dbotthepony.mc.otm.core.math.Decimal - -interface ConciseBalanceValues { - val capacity: Decimal - val throughput: Decimal -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt index 02864211c..2bc71c21a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ItemsConfig.kt @@ -5,48 +5,6 @@ import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.registry.MNames object ItemsConfig : AbstractConfig("items") { - private fun verboseValues(name: String, storage: Decimal, receive: Decimal, extract: Decimal = receive): VerboseBalanceValues { - builder.push(name) - - val obj = object : VerboseBalanceValues { - override val capacity: Decimal by builder.defineDecimal("capacity", storage, minimum = Decimal.ONE) - override val receive: Decimal by builder.defineDecimal("receive", receive, minimum = Decimal.ONE) - override val extract: Decimal by builder.defineDecimal("extract", extract, minimum = Decimal.ONE) - } - - builder.pop() - - return obj - } - - private fun batteryValues(name: String, storage: Decimal, receive: Decimal, extract: Decimal = receive, initialBatteryLevel: Decimal = Decimal.ZERO): BatteryBalanceValues { - builder.push(name) - - val obj = object : BatteryBalanceValues { - override val capacity: Decimal by builder.defineDecimal("capacity", storage, minimum = Decimal.ONE) - override val receive: Decimal by builder.defineDecimal("receive", receive, minimum = Decimal.ONE) - override val extract: Decimal by builder.defineDecimal("extract", extract, minimum = Decimal.ONE) - override val initialBatteryLevel: Decimal by builder.defineDecimal("initialBatteryLevel", initialBatteryLevel, minimum = Decimal.ZERO) - } - - builder.pop() - - return obj - } - - private fun conciseValues(name: String, storage: Decimal, throughput: Decimal): ConciseBalanceValues { - builder.push(name) - - val obj = object : ConciseBalanceValues { - override val capacity: Decimal by builder.defineDecimal("capacity", storage, minimum = Decimal.ONE) - override val throughput: Decimal by builder.defineDecimal("throughput", throughput, minimum = Decimal.ONE) - } - - builder.pop() - - return obj - } - init { builder.push("EnergyBatteries") } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt index e04ef4afb..65bdf5a4c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt @@ -44,6 +44,30 @@ object MachinesConfig : AbstractConfig("machines") { val ANDROID_CHARGER = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.ANDROID_CHARGER, capacity = Decimal(1_000_000), throughput = Decimal(8192)) { AndroidCharger } + val POWERED_FURNACE = workerValues( + "POWERED_FURNACE", + storage = Decimal(40_000), + throughput = Decimal(200), + powerConsumption = Decimal(20), + workTimeMultiplier = 0.75 + ) + + val POWERED_BLAST_FURNACE = workerValues( + "POWERED_BLAST_FURNACE", + storage = Decimal(40_000), + throughput = Decimal(200), + powerConsumption = Decimal(20), + workTimeMultiplier = 0.75 + ) + + val POWERED_SMOKER = workerValues( + "POWERED_SMOKER", + storage = Decimal(40_000), + throughput = Decimal(200), + powerConsumption = Decimal(10), + workTimeMultiplier = 0.75 + ) + object Upgrades { init { builder.push("UPGRADES") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/VerboseBalanceValues.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/VerboseBalanceValues.kt deleted file mode 100644 index 9b50f3bc2..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/VerboseBalanceValues.kt +++ /dev/null @@ -1,9 +0,0 @@ -package ru.dbotthepony.mc.otm.config - -import ru.dbotthepony.mc.otm.core.math.Decimal - -interface VerboseBalanceValues { - val capacity: Decimal - val receive: Decimal - val extract: Decimal -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerProxy.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/CombinedContainer.kt similarity index 68% rename from src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerProxy.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/container/CombinedContainer.kt index b8cb0a3ed..c37b8e51a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerProxy.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/CombinedContainer.kt @@ -5,31 +5,25 @@ import com.google.common.collect.ImmutableMap import com.google.common.collect.ImmutableSet import it.unimi.dsi.fastutil.ints.IntAVLTreeSet import it.unimi.dsi.fastutil.ints.IntOpenHashSet +import it.unimi.dsi.fastutil.ints.IntSet import it.unimi.dsi.fastutil.objects.Object2ObjectFunction import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import net.minecraft.world.Container import net.minecraft.world.entity.player.Player import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.core.GetterSetter +import ru.dbotthepony.mc.otm.core.stream import java.util.LinkedList -import java.util.function.Consumer -import java.util.function.Supplier import java.util.stream.Stream -import kotlin.properties.ReadWriteProperty -import kotlin.reflect.KProperty -open class ContainerProxy(containers: Stream>>) : Container { - data class ContainerSlot(val container: Container, val outerIndex: Int, val index: Int) : ReadWriteProperty, Supplier, Consumer { +class CombinedContainer(containers: Stream>>) : Container { + constructor(vararg containers: Container) : this(containers.stream().map { it to (0 until it.containerSize).iterator() }) + constructor(containers: Collection) : this(containers.stream().map { it to (0 until it.containerSize).iterator() }) + + class ContainerSlot(val container: Container, val containerIndex: Int) : GetterSetter { var item: ItemStack - get() = container[index] - set(value) { container[index] = value } - - override fun getValue(thisRef: Any, property: KProperty<*>): ItemStack { - return item - } - - override fun setValue(thisRef: Any, property: KProperty<*>, value: ItemStack) { - this.item = value - } + get() = container[containerIndex] + set(value) { container[containerIndex] = value } override fun get(): ItemStack { return item @@ -42,25 +36,26 @@ open class ContainerProxy(containers: Stream>>) : val isEmpty: Boolean get() = item.isEmpty } - protected val slots: List - protected val slotsMap: Map> - protected val containers: Set - protected val fullCoverage: List - protected val notFullCoverage: Map> + private val slots: List + private val slotsMap: Map> + private val containers: Set + private val fullCoverage: List + private val notFullCoverage: Map> init { val list = ImmutableList.Builder() var i = 0 - val validationMap = Reference2ObjectOpenHashMap() + val validationMap = Reference2ObjectOpenHashMap() val slotsMap = Reference2ObjectOpenHashMap>() for ((container, slots) in containers) { - val validator = validationMap.computeIfAbsent(container, Object2ObjectFunction { IntOpenHashSet() }) + val validator = validationMap.computeIfAbsent(container, Object2ObjectFunction { IntAVLTreeSet() }) val slotList = slotsMap.computeIfAbsent(container, Object2ObjectFunction { ArrayList() }) for (slot in slots) { if (validator.add(slot)) { - val slotObj = ContainerSlot(container, i++, slot) + i++ + val slotObj = ContainerSlot(container, slot) list.add(slotObj) slotList.add(slotObj) } else { @@ -106,15 +101,17 @@ open class ContainerProxy(containers: Stream>>) : } override fun isEmpty(): Boolean { - for (container in fullCoverage) - if (!container.isEmpty) - return false - - for (slots in notFullCoverage.values) - for (slot in slots) - if (!slot.isEmpty) + if (fullCoverage.isNotEmpty()) + for (container in fullCoverage) + if (!container.isEmpty) return false + if (notFullCoverage.isNotEmpty()) + for (slots in notFullCoverage.values) + for (slot in slots) + if (!slot.isEmpty) + return false + return true } @@ -129,16 +126,16 @@ open class ContainerProxy(containers: Stream>>) : override fun removeItem(index: Int, count: Int): ItemStack { val data = slots.getOrNull(index) ?: return ItemStack.EMPTY - return data.container.removeItem(data.index, count) + return data.container.removeItem(data.containerIndex, count) } override fun removeItemNoUpdate(index: Int): ItemStack { - val data = slots[index] - return data.container.removeItemNoUpdate(data.index) + val data = slots.getOrNull(index) ?: return ItemStack.EMPTY + return data.container.removeItemNoUpdate(data.containerIndex) } override fun setItem(index: Int, value: ItemStack) { - slots[index].item = value + slots.getOrNull(index)?.item = value } override fun setChanged() { @@ -147,6 +144,16 @@ open class ContainerProxy(containers: Stream>>) : } } + fun setChanged(index: Int) { + val data = slots.getOrNull(index) ?: return + + if (data.container is MatteryContainer) { + data.container.setChanged(data.containerIndex) + } else { + data.container.setChanged() + } + } + override fun stillValid(player: Player): Boolean { for (container in containers) if (!container.stillValid(player)) @@ -177,9 +184,9 @@ open class ContainerProxy(containers: Stream>>) : return this } - fun build(): ContainerProxy { + fun build(): CombinedContainer { check(!built) { "Already built!" } - val value = ContainerProxy(values.stream()) + val value = CombinedContainer(values.stream()) values.clear() return value } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt index 1948ff68f..ba1e29b5f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.core.util +import com.google.common.collect.ImmutableList import com.mojang.serialization.Codec import net.minecraft.nbt.ByteTag import net.minecraft.nbt.CompoundTag @@ -16,6 +17,7 @@ import net.minecraft.resources.ResourceLocation import net.minecraftforge.common.util.INBTSerializable import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.asGetterSetter +import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.nbt.set @@ -49,6 +51,12 @@ class Savetables : INBTSerializable { return stateful(getter, name, T::class.java) } + inline fun , reified T : Tag> stateful(values: List, name: String): ImmutableList> { + return immutableList(values.size) { + stateful(values[it], "${name}_$it", T::class.java) + } + } + fun , T : Tag> stateful(getter: Supplier, name: String, type: Class): Stateful { return Stateful(getter, name, type) .withSerializer { it.serializeNBT() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt index 74bda90bd..5ba1b1ccf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.menu import com.google.common.collect.ImmutableList import net.minecraft.world.Container +import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.Slot import net.minecraft.world.item.Item @@ -15,10 +16,20 @@ import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.runOnClient +/** + * Make slots for single container + */ inline fun makeSlots(container: C, initializer: (C, Int) -> S): ImmutableList { return immutableList(container.containerSize) { initializer.invoke(container, it) } } +/** + * Make slots for list of containers with single slot in them + */ +inline fun makeSlots(containers: List?, size: Int, initializer: (Container, Int) -> S): ImmutableList { + return immutableList(size) { initializer(containers?.get(it) ?: SimpleContainer(1), 0) } +} + open class MatterySlot(container: Container, index: Int, x: Int = 0, y: Int = 0) : Slot(container, index, x, y) { var ignoreSpectators = true diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PoweredFurnaceMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PoweredFurnaceMenu.kt new file mode 100644 index 000000000..c728c159f --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PoweredFurnaceMenu.kt @@ -0,0 +1,41 @@ +package ru.dbotthepony.mc.otm.menu.tech + +import net.minecraft.server.level.ServerPlayer +import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.block.entity.tech.PoweredFurnaceBlockEntity +import ru.dbotthepony.mc.otm.core.immutableList +import ru.dbotthepony.mc.otm.menu.MachineOutputSlot +import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu +import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput +import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput +import ru.dbotthepony.mc.otm.menu.makeSlots +import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget +import ru.dbotthepony.mc.otm.registry.MMenus + +class PoweredFurnaceMenu( + containerID: Int, + inventory: Inventory, + tile: PoweredFurnaceBlockEntity? = null +) : MatteryPoweredMenu(MMenus.POWERED_FURNACE, containerID, inventory, tile) { + val inputSlots = makeSlots(tile?.inputs, 2, ::MatterySlot) + val outputSlots = makeSlots(tile?.outputs, 2) { c, s -> MachineOutputSlot(c, s) { tile?.popExperience(ply as ServerPlayer) } } + + val progressGauge = immutableList(2) { ProgressGaugeWidget(this, tile?.jobEventLoops?.get(it)) } + val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig, allowPush = true) + val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig, allowPull = true) + val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) + + val balanceInputs = BooleanInputWithFeedback(this) + + val upgrades = makeUpgradeSlots(2, tile?.upgrades) + + init { + if (tile != null) balanceInputs.with(tile::balanceInputs) + addStorageSlot(inputSlots) + addStorageSlot(outputSlots) + addInventorySlots() + } +} 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 4dd4a8041..5a2dfde67 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt @@ -59,6 +59,10 @@ object MBlockEntities { val ANDROID_CHARGER_MIDDLE: BlockEntityType by registry.register(MNames.ANDROID_CHARGER + "_middle") { BlockEntityType.Builder.of(::AndroidChargerMiddleBlockEntity, MBlocks.ANDROID_CHARGER).build(null) } val ANDROID_CHARGER_TOP: BlockEntityType by registry.register(MNames.ANDROID_CHARGER + "_top") { BlockEntityType.Builder.of(::AndroidChargerTopBlockEntity, MBlocks.ANDROID_CHARGER).build(null) } + val POWERED_FURNACE: BlockEntityType by registry.register(MNames.POWERED_FURNACE) { BlockEntityType.Builder.of({ a, b -> MBlocks.POWERED_FURNACE.newBlockEntity(a, b) }, MBlocks.POWERED_FURNACE).build(null) } + val POWERED_BLAST_FURNACE: BlockEntityType by registry.register(MNames.POWERED_BLAST_FURNACE) { BlockEntityType.Builder.of({ a, b -> MBlocks.POWERED_BLAST_FURNACE.newBlockEntity(a, b) }, MBlocks.POWERED_BLAST_FURNACE).build(null) } + val POWERED_SMOKER: BlockEntityType by registry.register(MNames.POWERED_SMOKER) { BlockEntityType.Builder.of({ a, b -> MBlocks.POWERED_SMOKER.newBlockEntity(a, b) }, MBlocks.POWERED_SMOKER).build(null) } + val STORAGE_BUS: BlockEntityType by registry.register(MNames.STORAGE_BUS) { BlockEntityType.Builder.of(::StorageBusBlockEntity, MBlocks.STORAGE_BUS).build(null) } val STORAGE_IMPORTER: BlockEntityType by registry.register(MNames.STORAGE_IMPORTER) { BlockEntityType.Builder.of(::StorageImporterBlockEntity, MBlocks.STORAGE_IMPORTER).build(null) } val STORAGE_EXPORTER: BlockEntityType by registry.register(MNames.STORAGE_EXPORTER) { BlockEntityType.Builder.of(::StorageExporterBlockEntity, MBlocks.STORAGE_EXPORTER).build(null) } 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 474441f83..813a504a3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.registry import net.minecraft.ChatFormatting import net.minecraft.core.BlockPos import net.minecraft.network.chat.Component -import net.minecraft.sounds.SoundEvents import net.minecraft.util.valueproviders.UniformInt import net.minecraft.world.entity.Entity import net.minecraft.world.entity.EntityType @@ -11,6 +10,7 @@ import net.minecraft.world.entity.monster.Zombie import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag +import net.minecraft.world.item.crafting.RecipeType import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.block.* import net.minecraft.world.level.block.state.BlockBehaviour @@ -61,6 +61,8 @@ import ru.dbotthepony.mc.otm.block.storage.StoragePowerSupplierBlock import ru.dbotthepony.mc.otm.block.tech.AndroidChargerBlock import ru.dbotthepony.mc.otm.block.tech.CobblerBlock import ru.dbotthepony.mc.otm.block.tech.EssenceStorageBlock +import ru.dbotthepony.mc.otm.block.tech.PoweredFurnaceBlock +import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.collect.SupplierList @@ -86,6 +88,9 @@ object MBlocks { val CHEMICAL_GENERATOR: Block by registry.register(MNames.CHEMICAL_GENERATOR) { ChemicalGeneratorBlock() } val PLATE_PRESS: Block by registry.register(MNames.PLATE_PRESS) { PlatePressBlock() } val TWIN_PLATE_PRESS: Block by registry.register(MNames.TWIN_PLATE_PRESS) { PlatePressBlock(isTwin = true) } + val POWERED_FURNACE: PoweredFurnaceBlock by registry.register(MNames.POWERED_FURNACE) { PoweredFurnaceBlock(MBlockEntities::POWERED_FURNACE, RecipeType.SMELTING, MachinesConfig.POWERED_FURNACE) } + val POWERED_BLAST_FURNACE: PoweredFurnaceBlock by registry.register(MNames.POWERED_BLAST_FURNACE) { PoweredFurnaceBlock(MBlockEntities::POWERED_BLAST_FURNACE, RecipeType.BLASTING, MachinesConfig.POWERED_BLAST_FURNACE) } + val POWERED_SMOKER: PoweredFurnaceBlock by registry.register(MNames.POWERED_SMOKER) { PoweredFurnaceBlock(MBlockEntities::POWERED_SMOKER, RecipeType.SMOKING, MachinesConfig.POWERED_SMOKER) } val MATTER_RECYCLER: Block by registry.register(MNames.MATTER_RECYCLER) { MatterRecyclerBlock() } val ENERGY_SERVO: Block by registry.register(MNames.ENERGY_SERVO) { EnergyServoBlock() } val COBBLESTONE_GENERATOR: Block by registry.register(MNames.COBBLESTONE_GENERATOR) { CobblerBlock() } 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 0fcb51a37..3afedaf0e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -66,6 +66,10 @@ object MItems { val TWIN_PLATE_PRESS: BlockItem by registry.register(MNames.TWIN_PLATE_PRESS) { BlockItem(MBlocks.TWIN_PLATE_PRESS, DEFAULT_PROPERTIES) } val MATTER_RECYCLER: BlockItem by registry.register(MNames.MATTER_RECYCLER) { BlockItem(MBlocks.MATTER_RECYCLER, DEFAULT_PROPERTIES) } + val POWERED_FURNACE: BlockItem by registry.register(MNames.POWERED_FURNACE) { BlockItem(MBlocks.POWERED_FURNACE, DEFAULT_PROPERTIES) } + val POWERED_BLAST_FURNACE: BlockItem by registry.register(MNames.POWERED_BLAST_FURNACE) { BlockItem(MBlocks.POWERED_BLAST_FURNACE, DEFAULT_PROPERTIES) } + val POWERED_SMOKER: BlockItem by registry.register(MNames.POWERED_SMOKER) { BlockItem(MBlocks.POWERED_SMOKER, DEFAULT_PROPERTIES) } + val STORAGE_BUS: BlockItem by registry.register(MNames.STORAGE_BUS) { BlockItem(MBlocks.STORAGE_BUS, DEFAULT_PROPERTIES) } val STORAGE_IMPORTER: BlockItem by registry.register(MNames.STORAGE_IMPORTER) { BlockItem(MBlocks.STORAGE_IMPORTER, DEFAULT_PROPERTIES) } val STORAGE_EXPORTER: BlockItem by registry.register(MNames.STORAGE_EXPORTER) { BlockItem(MBlocks.STORAGE_EXPORTER, DEFAULT_PROPERTIES) } @@ -139,7 +143,8 @@ object MItems { val MACHINES = SupplierList( ::ANDROID_STATION, ::ANDROID_CHARGER, ::BATTERY_BANK, ::MATTER_DECOMPOSER, ::MATTER_CAPACITOR_BANK, ::MATTER_CABLE, ::PATTERN_STORAGE, ::MATTER_SCANNER, ::MATTER_PANEL, ::MATTER_REPLICATOR, ::MATTER_BOTTLER, ::ENERGY_COUNTER, ::CHEMICAL_GENERATOR, - ::PLATE_PRESS, ::TWIN_PLATE_PRESS, ::MATTER_RECYCLER, + ::MATTER_RECYCLER, ::PLATE_PRESS, ::TWIN_PLATE_PRESS, ::POWERED_FURNACE, ::POWERED_BLAST_FURNACE, + ::POWERED_SMOKER, // ::STORAGE_BUS, ::STORAGE_IMPORTER, ::STORAGE_EXPORTER, ::DRIVE_VIEWER, // ::DRIVE_RACK, ::ITEM_MONITOR, ::STORAGE_CABLE, ::STORAGE_POWER_SUPPLIER, ::ENERGY_SERVO, 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 113c4803a..185878fd5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt @@ -38,6 +38,7 @@ import ru.dbotthepony.mc.otm.client.screen.tech.EnergyCounterScreen import ru.dbotthepony.mc.otm.client.screen.tech.EnergyServoScreen import ru.dbotthepony.mc.otm.client.screen.tech.EssenceStorageScreen import ru.dbotthepony.mc.otm.client.screen.tech.PlatePressScreen +import ru.dbotthepony.mc.otm.client.screen.tech.PoweredFurnaceScreen import ru.dbotthepony.mc.otm.client.screen.tech.TwinPlatePressScreen import ru.dbotthepony.mc.otm.menu.decorative.CargoCrateMenu import ru.dbotthepony.mc.otm.menu.decorative.FluidTankMenu @@ -68,6 +69,7 @@ import ru.dbotthepony.mc.otm.menu.tech.EnergyCounterMenu import ru.dbotthepony.mc.otm.menu.tech.EnergyServoMenu import ru.dbotthepony.mc.otm.menu.tech.EssenceStorageMenu import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu +import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu object MMenus { @@ -91,6 +93,7 @@ object MMenus { val ENERGY_COUNTER: MenuType by registry.register(MNames.ENERGY_COUNTER) { MenuType(::EnergyCounterMenu, FeatureFlags.VANILLA_SET) } val CHEMICAL_GENERATOR: MenuType by registry.register(MNames.CHEMICAL_GENERATOR) { MenuType(::ChemicalGeneratorMenu, FeatureFlags.VANILLA_SET) } val PLATE_PRESS: MenuType by registry.register(MNames.PLATE_PRESS) { MenuType(::PlatePressMenu, FeatureFlags.VANILLA_SET) } + val POWERED_FURNACE: MenuType by registry.register(MNames.POWERED_FURNACE) { MenuType(::PoweredFurnaceMenu, FeatureFlags.VANILLA_SET) } val TWIN_PLATE_PRESS: MenuType by registry.register(MNames.TWIN_PLATE_PRESS) { MenuType(::TwinPlatePressMenu, FeatureFlags.VANILLA_SET) } val MATTER_RECYCLER: MenuType by registry.register(MNames.MATTER_RECYCLER) { MenuType(::MatterRecyclerMenu, FeatureFlags.VANILLA_SET) } val ENERGY_SERVO: MenuType by registry.register(MNames.ENERGY_SERVO) { MenuType(::EnergyServoMenu, FeatureFlags.VANILLA_SET) } @@ -143,6 +146,7 @@ object MMenus { MenuScreens.register(ESSENCE_STORAGE, ::EssenceStorageScreen) MenuScreens.register(ITEM_REPAIER, ::MatterReconstructorScreen) MenuScreens.register(FLUID_TANK, ::FluidTankScreen) + MenuScreens.register(POWERED_FURNACE, ::PoweredFurnaceScreen) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index 37d3e2ad3..2cf4382a0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -32,6 +32,9 @@ object MNames { const val ENERGY_COUNTER = "energy_counter" const val CHEMICAL_GENERATOR = "chemical_generator" const val PLATE_PRESS = "plate_press" + const val POWERED_FURNACE = "powered_furnace" + const val POWERED_BLAST_FURNACE = "powered_blast_furnace" + const val POWERED_SMOKER = "powered_smoker" const val TWIN_PLATE_PRESS = "twin_plate_press" const val MATTER_RECYCLER = "matter_recycler" const val ENERGY_SERVO = "energy_servo" 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 443936596..ad4caab70 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -1,10 +1,16 @@ package ru.dbotthepony.mc.otm.registry +import com.google.common.collect.ImmutableSet +import com.google.common.collect.Streams import net.minecraft.advancements.CriteriaTriggers import net.minecraft.client.renderer.item.ItemProperties import net.minecraft.core.BlockPos +import net.minecraft.core.Registry +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 +import net.minecraft.world.entity.ai.village.poi.PoiTypes import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.block.* import net.minecraft.world.level.block.state.BlockBehaviour @@ -17,6 +23,7 @@ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent import net.minecraftforge.fml.loading.FMLEnvironment import net.minecraftforge.registries.NewRegistryEvent +import net.minecraftforge.registries.RegisterEvent import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.android.AndroidResearchResult import ru.dbotthepony.mc.otm.android.AndroidResearchResults @@ -209,11 +216,40 @@ object MRegistry { WallBlock(BlockBehaviour.Properties.copy(TRITANIUM_STRIPED_BLOCK.getBlock(colorA, colorB))) }) + private fun registerEvent(event: RegisterEvent) { + // mojang moment + + if (event.registryKey == Registries.POINT_OF_INTEREST_TYPE) { + val reg = event.getVanillaRegistry() ?: throw IllegalStateException("POI registry is not a vanilla registry") + + event.register(Registries.POINT_OF_INTEREST_TYPE, 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())) { + old + } else { + PoiType(Streams.concat(old.matchingStates.stream(), MBlocks.POWERED_SMOKER.stateDefinition.possibleStates.stream()).collect(ImmutableSet.toImmutableSet()), old.maxTickets, old.validRange) + } + } + + event.register(Registries.POINT_OF_INTEREST_TYPE, 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())) { + old + } else { + PoiType(Streams.concat(old.matchingStates.stream(), MBlocks.POWERED_BLAST_FURNACE.stateDefinition.possibleStates.stream()).collect(ImmutableSet.toImmutableSet()), old.maxTickets, old.validRange) + } + } + } + } + fun initialize(bus: IEventBus) { bus.addListener(this::register) bus.addListener(this::initializeClient) bus.addListener(this::initializeCommon) bus.addListener(MStats::registerVanilla) + bus.addListener(this::registerEvent) MCreativeTabs.initialize(bus) From 5659fb2040d9202f634fcbabe14adcdeb1edde02 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 20 Jul 2023 17:58:14 +0700 Subject: [PATCH 0800/1199] =?UTF-8?q?YuRaNnNzZZ=20=D0=BF=D1=80=D0=BE=D0=BA?= =?UTF-8?q?=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD=D1=82=D0=B8=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=BB(=D0=B0)=201=20=D0=B4=D0=B5=D0=BD=D1=8C=20=D0=BD?= =?UTF-8?q?=D0=B0=D0=B7=D0=B0=D0=B4=20=D1=8D=D0=BB=D0=B5=D0=BA=D1=82=D1=80?= =?UTF-8?q?=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=B0=D1=8F=20=D0=BF=D0=B5=D1=87?= =?UTF-8?q?=D1=8C=20-=20furnace=20=D0=B8=D0=BD=D0=B4=D1=83=D0=BA=D1=86?= =?UTF-8?q?=D0=B8=D0=BE=D0=BD=D0=BD=D0=B0=D1=8F=20=D0=BF=D0=B5=D1=87=D1=8C?= =?UTF-8?q?=20-=20blast=20furnace=20=D0=BC=D0=B8=D0=BA=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=BE=D0=BB=D0=BD=D0=BE=D0=B2=D0=BA=D0=B0=20-=20smoker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt | 6 +++--- .../kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index ec8988def..302221c37 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -423,9 +423,9 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.PLATE_PRESS, "Plate Press") add(MBlocks.TWIN_PLATE_PRESS, "Twin Plate Press") - add(MBlocks.POWERED_FURNACE, "Powered Furnace") - add(MBlocks.POWERED_SMOKER, "Powered Smoker") - add(MBlocks.POWERED_BLAST_FURNACE, "Powered Blast Furnace") + add(MBlocks.POWERED_FURNACE, "Electric Furnace") + add(MBlocks.POWERED_SMOKER, "Microwave Oven") + add(MBlocks.POWERED_BLAST_FURNACE, "Induction Furnace") add(MBlocks.MATTER_RECYCLER, "Matter Recycler") add(MBlocks.ENERGY_SERVO, "Energy Servo") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 7eb5f2596..9747409a6 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -427,8 +427,8 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.TWIN_PLATE_PRESS, "Двойной пресс пластин") add(MBlocks.POWERED_FURNACE, "Электрическая печь") - add(MBlocks.POWERED_BLAST_FURNACE, "Электрическая плавильная печь") - add(MBlocks.POWERED_SMOKER, "Электрическая коптильня") + add(MBlocks.POWERED_BLAST_FURNACE, "Индукционная печь") + add(MBlocks.POWERED_SMOKER, "Микроволновая печь") add(MBlocks.MATTER_RECYCLER, "Перерабатыватель материи") add(MBlocks.ENERGY_SERVO, "Энергетическая помпа") From e1681a5c6ff17c73d30dc8a6ca5bc0504d445f43 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 20 Jul 2023 18:09:30 +0700 Subject: [PATCH 0801/1199] recipes for new machines --- .../otm/datagen/recipes/CraftingTableRecipes.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index ca9ed68bc..0db9748ed 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -401,4 +401,20 @@ fun addCraftingTableRecipes(consumer: Consumer) { .rowB(Tags.Items.RODS_WOODEN) .unlockedBy(Items.FLINT_AND_STEEL) .build(consumer) + + MatteryRecipe(MItems.POWERED_FURNACE, category = machinesCategory) + .row(Items.FURNACE, MItems.MACHINE_FRAME, Items.FURNACE) + .unlockedBy(MItems.MACHINE_FRAME) + .build(consumer) + + MatteryRecipe(MItems.POWERED_SMOKER, category = machinesCategory) + .row(Items.SMOKER, MItems.MACHINE_FRAME, Items.SMOKER) + .unlockedBy(MItems.MACHINE_FRAME) + .build(consumer) + + MatteryRecipe(MItems.POWERED_BLAST_FURNACE, category = machinesCategory) + .rowAC(Items.FURNACE, Items.FURNACE) + .row(MItems.ELECTROMAGNET, MItems.MACHINE_FRAME, MItems.ELECTROMAGNET) + .unlockedBy(MItems.MACHINE_FRAME) + .build(consumer) } From 436d324b50f9b2554b66d0581fb0ff541c226b35 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 20 Jul 2023 18:17:48 +0700 Subject: [PATCH 0802/1199] Less generous recipe for blast furnace, update microwave recipe --- .../mc/otm/datagen/recipes/CraftingTableRecipes.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index 0db9748ed..ee01b293b 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -408,13 +408,15 @@ fun addCraftingTableRecipes(consumer: Consumer) { .build(consumer) MatteryRecipe(MItems.POWERED_SMOKER, category = machinesCategory) - .row(Items.SMOKER, MItems.MACHINE_FRAME, Items.SMOKER) - .unlockedBy(MItems.MACHINE_FRAME) - .build(consumer) - - MatteryRecipe(MItems.POWERED_BLAST_FURNACE, category = machinesCategory) .rowAC(Items.FURNACE, Items.FURNACE) .row(MItems.ELECTROMAGNET, MItems.MACHINE_FRAME, MItems.ELECTROMAGNET) .unlockedBy(MItems.MACHINE_FRAME) .build(consumer) + + MatteryRecipe(MItems.POWERED_BLAST_FURNACE, category = machinesCategory) + .row(MItems.ELECTROMAGNET, Items.FURNACE, MItems.ELECTROMAGNET) + .row(MItems.ELECTROMAGNET, MItems.MACHINE_FRAME, MItems.ELECTROMAGNET) + .row(MItems.ELECTROMAGNET, Items.FURNACE, MItems.ELECTROMAGNET) + .unlockedBy(MItems.MACHINE_FRAME) + .build(consumer) } From 77a619cba6bc698254b4afb236df88e370c2d678 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 20 Jul 2023 18:24:38 +0700 Subject: [PATCH 0803/1199] Add worker blockstate to powered furnaces --- .../dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt index e6c0c95f6..9888fbda3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt @@ -4,12 +4,15 @@ import net.minecraft.core.BlockPos import net.minecraft.world.item.crafting.AbstractCookingRecipe import net.minecraft.world.item.crafting.RecipeType import net.minecraft.world.level.Level +import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.EntityBlock import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.entity.BlockEntityTicker import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.level.block.state.StateDefinition import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.entity.tech.PoweredFurnaceBlockEntity import ru.dbotthepony.mc.otm.config.WorkerBalanceValues @@ -18,6 +21,11 @@ class PoweredFurnaceBlock(val type: () -> BlockEntityType) { + super.createBlockStateDefinition(builder) + builder.add(WorkerState.WORKER_STATE) + } + override fun getTicker(p_153212_: Level, p_153213_: BlockState, p_153214_: BlockEntityType): BlockEntityTicker? { if (p_153212_.isClientSide) return null From 8d4e0d83eeb1f2eb894abf523cd2da5ff14e2cab Mon Sep 17 00:00:00 2001 From: GearShocky Date: Fri, 21 Jul 2023 02:52:59 +0600 Subject: [PATCH 0804/1199] Electric furnace model (Looks broken atm, TODO: fix it) --- .../mc/otm/datagen/blocks/BlockStates.kt | 1 + .../mc/otm/datagen/items/ItemModels.kt | 1 + .../models/block/powered_furnace_error.json | 245 +++++++++++++++ .../models/block/powered_furnace_idle.json | 245 +++++++++++++++ .../models/block/powered_furnace_working.json | 286 ++++++++++++++++++ .../textures/block/electric_furnace.png | Bin 0 -> 852 bytes .../block/electric_furnace_offline.png | Bin 0 -> 820 bytes 7 files changed, 778 insertions(+) create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_error.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_idle.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_working.json create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/electric_furnace.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/electric_furnace_offline.png diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt index 0c4759b33..391f7d877 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt @@ -97,6 +97,7 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { provider.block(MBlocks.TWIN_PLATE_PRESS) provider.block(MBlocks.GRAVITATION_STABILIZER) provider.block(MBlocks.GRAVITATION_STABILIZER_LENS) + provider.block(MBlocks.POWERED_FURNACE) provider.block(MBlocks.STORAGE_POWER_SUPPLIER) provider.block(MBlocks.MATTER_RECYCLER) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index 3ef5c0e9e..4f747ee5c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -143,6 +143,7 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.block(MItems.ENERGY_SERVO, "energy_servo") provider.block(MItems.ESSENCE_STORAGE, "essence_storage") provider.block(MItems.MATTER_RECONSTRUCTOR, "matter_reconstructor") + provider.block(MItems.POWERED_FURNACE, "powered_furnace_working") provider.block(MItems.PLATE_PRESS, "plate_press_idle") provider.block(MItems.TWIN_PLATE_PRESS, "twin_plate_press_idle") diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_error.json b/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_error.json new file mode 100644 index 000000000..597d7d580 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_error.json @@ -0,0 +1,245 @@ +{ + "render_type": "cutout", + "textures": { + "0": "overdrive_that_matters:block/electric_furnace_offline", + "particle": "overdrive_that_matters:block/electric_furnace_offline" + }, + "elements": [ + { + "name": "heatsink", + "from": [1, 10, 11], + "to": [15, 11, 15], + "faces": { + "east": {"uv": [7, 0.25, 9, 0.5], "texture": "#0"}, + "south": {"uv": [9, 0, 16, 0.25], "texture": "#0"}, + "west": {"uv": [7, 0, 9, 0.25], "texture": "#0"}, + "up": {"uv": [0, 0, 7, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 7, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "heatsink", + "from": [1, 8, 11], + "to": [15, 9, 15], + "faces": { + "east": {"uv": [7, 0.25, 9, 0.5], "texture": "#0"}, + "south": {"uv": [9, 0, 16, 0.25], "texture": "#0"}, + "west": {"uv": [7, 0, 9, 0.25], "texture": "#0"}, + "up": {"uv": [0, 0, 7, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 7, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "heatsink", + "from": [1, 6, 11], + "to": [15, 7, 15], + "faces": { + "east": {"uv": [7, 0.25, 9, 0.5], "texture": "#0"}, + "south": {"uv": [9, 0, 16, 0.25], "texture": "#0"}, + "west": {"uv": [7, 0, 9, 0.25], "texture": "#0"}, + "up": {"uv": [0, 0, 7, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 7, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "base", + "from": [0, 0, 0], + "to": [16, 5, 16], + "faces": { + "north": {"uv": [0, 9.5, 8, 10.75], "texture": "#0"}, + "east": {"uv": [0, 10.75, 8, 12], "texture": "#0"}, + "south": {"uv": [0, 10.75, 8, 12], "texture": "#0"}, + "west": {"uv": [0, 10.75, 8, 12], "texture": "#0"}, + "up": {"uv": [0, 12, 8, 16], "texture": "#0"}, + "down": {"uv": [0, 12, 8, 16], "texture": "#0"} + } + }, + { + "name": "base", + "from": [0, 5, 6], + "to": [16, 16, 11], + "faces": { + "north": {"uv": [0, 3.5, 8, 6.25], "texture": "#0"}, + "east": {"uv": [13, 7.25, 10.5, 10], "texture": "#0"}, + "south": {"uv": [0, 12, 8, 14.75], "texture": "#0"}, + "west": {"uv": [10.5, 7.25, 13, 10], "texture": "#0"}, + "up": {"uv": [0, 2.25, 8, 3.5], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "base", + "from": [0, 12, 11], + "to": [16, 16, 16], + "faces": { + "east": {"uv": [15.5, 7.25, 13, 8.25], "texture": "#0"}, + "south": {"uv": [0, 6.25, 8, 7.25], "texture": "#0"}, + "west": {"uv": [13, 7.25, 15.5, 8.25], "texture": "#0"}, + "up": {"uv": [0, 1, 8, 2.25], "rotation": 180, "texture": "#0"}, + "down": {"uv": [0, 12, 8, 13.25], "texture": "#0"} + } + }, + { + "name": "base", + "from": [2, 5, 11], + "to": [14, 12, 14], + "faces": { + "east": {"uv": [6, 7.75, 7.5, 9.5], "texture": "#0"}, + "south": {"uv": [1, 7.75, 7, 9.5], "texture": "#0"}, + "west": {"uv": [0, 7.75, 1.5, 9.5], "texture": "#0"} + } + }, + { + "name": "chamber", + "from": [3, 5, 0], + "to": [13, 16, 6], + "faces": { + "north": {"uv": [8, 13.25, 13, 16], "texture": "#0"}, + "east": {"uv": [16, 13.25, 13, 16], "texture": "#0"}, + "west": {"uv": [13, 13.25, 16, 16], "texture": "#0"}, + "up": {"uv": [8, 11.75, 13, 13.25], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "smokething", + "from": [4, 16, 4], + "to": [12, 17, 12], + "faces": { + "north": {"uv": [8, 3, 12, 3.25], "texture": "#0"}, + "east": {"uv": [8, 3, 12, 3.25], "texture": "#0"}, + "south": {"uv": [8, 3, 12, 3.25], "texture": "#0"}, + "west": {"uv": [8, 3, 12, 3.25], "texture": "#0"}, + "up": {"uv": [8, 1, 12, 3], "texture": "#0"} + } + }, + { + "name": "net", + "from": [0.5, 5, 10.5], + "to": [15.5, 12, 15.5], + "faces": { + "east": {"uv": [13, 8.25, 15.5, 10], "texture": "#0"}, + "south": {"uv": [8, 10, 15.5, 11.75], "texture": "#0"}, + "west": {"uv": [13, 8.25, 15.5, 10], "texture": "#0"} + } + }, + { + "name": "net", + "from": [15.5, 5, 10.5], + "to": [0.5, 12, 15.5], + "faces": { + "east": {"uv": [13, 8.25, 15.5, 10], "texture": "#0"}, + "south": {"uv": [8, 10, 15.5, 11.75], "texture": "#0"}, + "west": {"uv": [13, 8.25, 15.5, 10], "texture": "#0"} + } + }, + { + "name": "detals", + "from": [13, 5, 1], + "to": [15, 15, 6], + "faces": { + "north": {"uv": [8, 5, 9, 7.5], "texture": "#0"}, + "east": {"uv": [8, 7.5, 10.5, 10], "texture": "#0"}, + "up": {"uv": [10, 5, 9, 6.25], "texture": "#0"} + } + }, + { + "name": "detals", + "from": [1, 5, 1], + "to": [3, 15, 6], + "faces": { + "north": {"uv": [9, 5, 8, 7.5], "texture": "#0"}, + "west": {"uv": [8, 7.5, 10.5, 10], "texture": "#0"}, + "up": {"uv": [9, 5, 10, 6.25], "texture": "#0"} + } + }, + { + "name": "light", + "from": [1, 13, 2], + "to": [2, 14, 5], + "faces": { + "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, + "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + } + }, + { + "name": "light", + "from": [1, 11, 2], + "to": [2, 12, 5], + "faces": { + "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, + "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + } + }, + { + "name": "light", + "from": [1, 9, 2], + "to": [2, 10, 5], + "faces": { + "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, + "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + } + }, + { + "name": "light", + "from": [14, 9, 2], + "to": [15, 10, 5], + "faces": { + "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, + "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + } + }, + { + "name": "light", + "from": [14, 13, 2], + "to": [15, 14, 5], + "faces": { + "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, + "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + } + }, + { + "name": "light", + "from": [14, 11, 2], + "to": [15, 12, 5], + "faces": { + "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, + "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + } + }, + { + "name": "light", + "from": [5, 15, 2], + "to": [11, 16, 3], + "faces": { + "north": {"uv": [12.5, 1.5, 15.5, 1.75], "texture": "#0"}, + "east": {"uv": [15, 1.5, 15.5, 1.75], "texture": "#0"}, + "south": {"uv": [12.5, 1.5, 15.5, 1.75], "texture": "#0"}, + "west": {"uv": [12.5, 1.5, 13, 1.75], "texture": "#0"}, + "up": {"uv": [12.5, 1.5, 15.5, 1.75], "texture": "#0"} + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_idle.json b/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_idle.json new file mode 100644 index 000000000..6eac0cd04 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_idle.json @@ -0,0 +1,245 @@ +{ + "render_type": "translucent", + "textures": { + "0": "overdrive_that_matters:block/electric_furnace_offline", + "particle": "overdrive_that_matters:block/electric_furnace_offline" + }, + "elements": [ + { + "name": "heatsink", + "from": [1, 10, 11], + "to": [15, 11, 15], + "faces": { + "east": {"uv": [7, 0.25, 9, 0.5], "texture": "#0"}, + "south": {"uv": [9, 0, 16, 0.25], "texture": "#0"}, + "west": {"uv": [7, 0, 9, 0.25], "texture": "#0"}, + "up": {"uv": [0, 0, 7, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 7, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "heatsink", + "from": [1, 8, 11], + "to": [15, 9, 15], + "faces": { + "east": {"uv": [7, 0.25, 9, 0.5], "texture": "#0"}, + "south": {"uv": [9, 0, 16, 0.25], "texture": "#0"}, + "west": {"uv": [7, 0, 9, 0.25], "texture": "#0"}, + "up": {"uv": [0, 0, 7, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 7, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "heatsink", + "from": [1, 6, 11], + "to": [15, 7, 15], + "faces": { + "east": {"uv": [7, 0.25, 9, 0.5], "texture": "#0"}, + "south": {"uv": [9, 0, 16, 0.25], "texture": "#0"}, + "west": {"uv": [7, 0, 9, 0.25], "texture": "#0"}, + "up": {"uv": [0, 0, 7, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 7, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "base", + "from": [0, 0, 0], + "to": [16, 5, 16], + "faces": { + "north": {"uv": [0, 9.5, 8, 10.75], "texture": "#0"}, + "east": {"uv": [0, 10.75, 8, 12], "texture": "#0"}, + "south": {"uv": [0, 10.75, 8, 12], "texture": "#0"}, + "west": {"uv": [0, 10.75, 8, 12], "texture": "#0"}, + "up": {"uv": [0, 12, 8, 16], "texture": "#0"}, + "down": {"uv": [0, 12, 8, 16], "texture": "#0"} + } + }, + { + "name": "base", + "from": [0, 5, 6], + "to": [16, 16, 11], + "faces": { + "north": {"uv": [0, 3.5, 8, 6.25], "texture": "#0"}, + "east": {"uv": [13, 7.25, 10.5, 10], "texture": "#0"}, + "south": {"uv": [0, 12, 8, 14.75], "texture": "#0"}, + "west": {"uv": [10.5, 7.25, 13, 10], "texture": "#0"}, + "up": {"uv": [0, 2.25, 8, 3.5], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "base", + "from": [0, 12, 11], + "to": [16, 16, 16], + "faces": { + "east": {"uv": [15.5, 7.25, 13, 8.25], "texture": "#0"}, + "south": {"uv": [0, 6.25, 8, 7.25], "texture": "#0"}, + "west": {"uv": [13, 7.25, 15.5, 8.25], "texture": "#0"}, + "up": {"uv": [0, 1, 8, 2.25], "rotation": 180, "texture": "#0"}, + "down": {"uv": [0, 12, 8, 13.25], "texture": "#0"} + } + }, + { + "name": "base", + "from": [2, 5, 11], + "to": [14, 12, 14], + "faces": { + "east": {"uv": [6, 7.75, 7.5, 9.5], "texture": "#0"}, + "south": {"uv": [1, 7.75, 7, 9.5], "texture": "#0"}, + "west": {"uv": [0, 7.75, 1.5, 9.5], "texture": "#0"} + } + }, + { + "name": "chamber", + "from": [3, 5, 0], + "to": [13, 16, 6], + "faces": { + "north": {"uv": [8, 13.25, 13, 16], "texture": "#0"}, + "east": {"uv": [16, 13.25, 13, 16], "texture": "#0"}, + "west": {"uv": [13, 13.25, 16, 16], "texture": "#0"}, + "up": {"uv": [8, 11.75, 13, 13.25], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "smokething", + "from": [4, 16, 4], + "to": [12, 17, 12], + "faces": { + "north": {"uv": [8, 3, 12, 3.25], "texture": "#0"}, + "east": {"uv": [8, 3, 12, 3.25], "texture": "#0"}, + "south": {"uv": [8, 3, 12, 3.25], "texture": "#0"}, + "west": {"uv": [8, 3, 12, 3.25], "texture": "#0"}, + "up": {"uv": [8, 1, 12, 3], "texture": "#0"} + } + }, + { + "name": "net", + "from": [0.5, 5, 10.5], + "to": [15.5, 12, 15.5], + "faces": { + "east": {"uv": [13, 8.25, 15.5, 10], "texture": "#0"}, + "south": {"uv": [8, 10, 15.5, 11.75], "texture": "#0"}, + "west": {"uv": [13, 8.25, 15.5, 10], "texture": "#0"} + } + }, + { + "name": "net", + "from": [15.5, 5, 10.5], + "to": [0.5, 12, 15.5], + "faces": { + "east": {"uv": [13, 8.25, 15.5, 10], "texture": "#0"}, + "south": {"uv": [8, 10, 15.5, 11.75], "texture": "#0"}, + "west": {"uv": [13, 8.25, 15.5, 10], "texture": "#0"} + } + }, + { + "name": "detals", + "from": [13, 5, 1], + "to": [15, 15, 6], + "faces": { + "north": {"uv": [8, 5, 9, 7.5], "texture": "#0"}, + "east": {"uv": [8, 7.5, 10.5, 10], "texture": "#0"}, + "up": {"uv": [10, 5, 9, 6.25], "texture": "#0"} + } + }, + { + "name": "detals", + "from": [1, 5, 1], + "to": [3, 15, 6], + "faces": { + "north": {"uv": [9, 5, 8, 7.5], "texture": "#0"}, + "west": {"uv": [8, 7.5, 10.5, 10], "texture": "#0"}, + "up": {"uv": [9, 5, 10, 6.25], "texture": "#0"} + } + }, + { + "name": "light", + "from": [1, 13, 2], + "to": [2, 14, 5], + "faces": { + "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, + "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + } + }, + { + "name": "light", + "from": [1, 11, 2], + "to": [2, 12, 5], + "faces": { + "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, + "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + } + }, + { + "name": "light", + "from": [1, 9, 2], + "to": [2, 10, 5], + "faces": { + "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, + "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + } + }, + { + "name": "light", + "from": [14, 9, 2], + "to": [15, 10, 5], + "faces": { + "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, + "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + } + }, + { + "name": "light", + "from": [14, 13, 2], + "to": [15, 14, 5], + "faces": { + "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, + "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + } + }, + { + "name": "light", + "from": [14, 11, 2], + "to": [15, 12, 5], + "faces": { + "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, + "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + } + }, + { + "name": "light", + "from": [5, 15, 2], + "to": [11, 16, 3], + "faces": { + "north": {"uv": [12.5, 1.5, 15.5, 1.75], "texture": "#0"}, + "east": {"uv": [15, 1.5, 15.5, 1.75], "texture": "#0"}, + "south": {"uv": [12.5, 1.5, 15.5, 1.75], "texture": "#0"}, + "west": {"uv": [12.5, 1.5, 13, 1.75], "texture": "#0"}, + "up": {"uv": [12.5, 1.5, 15.5, 1.75], "texture": "#0"} + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_working.json b/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_working.json new file mode 100644 index 000000000..1e8beef7b --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_working.json @@ -0,0 +1,286 @@ +{ + "render_type": "translucent", + "textures": { + "0": "overdrive_that_matters:block/electric_furnace", + "particle": "overdrive_that_matters:block/electric_furnace" + }, + "elements": [ + { + "name": "heatsink", + "from": [1, 10, 11], + "to": [15, 11, 15], + "faces": { + "east": {"uv": [7, 0.25, 9, 0.5], "texture": "#0"}, + "south": {"uv": [9, 0, 16, 0.25], "texture": "#0"}, + "west": {"uv": [7, 0, 9, 0.25], "texture": "#0"}, + "up": {"uv": [0, 0, 7, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 7, 1], "rotation": 180, "texture": "#0"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "heatsink", + "from": [1, 8, 11], + "to": [15, 9, 15], + "faces": { + "east": {"uv": [7, 0.25, 9, 0.5], "texture": "#0"}, + "south": {"uv": [9, 0, 16, 0.25], "texture": "#0"}, + "west": {"uv": [7, 0, 9, 0.25], "texture": "#0"}, + "up": {"uv": [0, 0, 7, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 7, 1], "rotation": 180, "texture": "#0"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "heatsink", + "from": [1, 6, 11], + "to": [15, 7, 15], + "faces": { + "east": {"uv": [7, 0.25, 9, 0.5], "texture": "#0"}, + "south": {"uv": [9, 0, 16, 0.25], "texture": "#0"}, + "west": {"uv": [7, 0, 9, 0.25], "texture": "#0"}, + "up": {"uv": [0, 0, 7, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 7, 1], "rotation": 180, "texture": "#0"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "base", + "from": [0, 0, 0], + "to": [16, 5, 16], + "faces": { + "north": {"uv": [0, 9.5, 8, 10.75], "texture": "#0"}, + "east": {"uv": [0, 10.75, 8, 12], "texture": "#0"}, + "south": {"uv": [0, 10.75, 8, 12], "texture": "#0"}, + "west": {"uv": [0, 10.75, 8, 12], "texture": "#0"}, + "up": {"uv": [0, 12, 8, 16], "texture": "#0"}, + "down": {"uv": [0, 12, 8, 16], "texture": "#0"} + } + }, + { + "name": "base", + "from": [0, 5, 6], + "to": [16, 16, 11], + "faces": { + "north": {"uv": [0, 3.5, 8, 6.25], "texture": "#0"}, + "east": {"uv": [13, 7.25, 10.5, 10], "texture": "#0"}, + "south": {"uv": [0, 12, 8, 14.75], "texture": "#0"}, + "west": {"uv": [10.5, 7.25, 13, 10], "texture": "#0"}, + "up": {"uv": [0, 2.25, 8, 3.5], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "base", + "from": [0, 12, 11], + "to": [16, 16, 16], + "faces": { + "east": {"uv": [15.5, 7.25, 13, 8.25], "texture": "#0"}, + "south": {"uv": [0, 6.25, 8, 7.25], "texture": "#0"}, + "west": {"uv": [13, 7.25, 15.5, 8.25], "texture": "#0"}, + "up": {"uv": [0, 1, 8, 2.25], "rotation": 180, "texture": "#0"}, + "down": {"uv": [0, 12, 8, 13.25], "texture": "#0"} + } + }, + { + "name": "base", + "from": [2, 5, 11], + "to": [14, 12, 14], + "faces": { + "east": {"uv": [6, 7.75, 7.5, 9.5], "texture": "#0"}, + "south": {"uv": [1, 7.75, 7, 9.5], "texture": "#0"}, + "west": {"uv": [0, 7.75, 1.5, 9.5], "texture": "#0"} + } + }, + { + "name": "chamber", + "from": [3, 5, 0], + "to": [13, 16, 6], + "faces": { + "north": {"uv": [8, 13.25, 13, 16], "texture": "#0"}, + "east": {"uv": [16, 13.25, 13, 16], "texture": "#0"}, + "west": {"uv": [13, 13.25, 16, 16], "texture": "#0"}, + "up": {"uv": [8, 11.75, 13, 13.25], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "smokething", + "from": [4, 16, 4], + "to": [12, 17, 12], + "faces": { + "north": {"uv": [8, 3, 12, 3.25], "texture": "#0"}, + "east": {"uv": [8, 3, 12, 3.25], "texture": "#0"}, + "south": {"uv": [8, 3, 12, 3.25], "texture": "#0"}, + "west": {"uv": [8, 3, 12, 3.25], "texture": "#0"}, + "up": {"uv": [8, 1, 12, 3], "texture": "#0"} + } + }, + { + "name": "net", + "from": [0.5, 5, 10.5], + "to": [15.5, 12, 15.5], + "faces": { + "east": {"uv": [13, 8.25, 15.5, 10], "texture": "#0"}, + "south": {"uv": [8, 10, 15.5, 11.75], "texture": "#0"}, + "west": {"uv": [13, 8.25, 15.5, 10], "texture": "#0"} + } + }, + { + "name": "net", + "from": [15.5, 5, 10.5], + "to": [0.5, 12, 15.5], + "faces": { + "east": {"uv": [13, 8.25, 15.5, 10], "texture": "#0"}, + "south": {"uv": [8, 10, 15.5, 11.75], "texture": "#0"}, + "west": {"uv": [13, 8.25, 15.5, 10], "texture": "#0"} + } + }, + { + "name": "detals", + "from": [13, 5, 1], + "to": [15, 15, 6], + "faces": { + "north": {"uv": [8, 5, 9, 7.5], "texture": "#0"}, + "east": {"uv": [8, 7.5, 10.5, 10], "texture": "#0"}, + "up": {"uv": [10, 5, 9, 6.25], "texture": "#0"} + } + }, + { + "name": "detals", + "from": [1, 5, 1], + "to": [3, 15, 6], + "faces": { + "north": {"uv": [9, 5, 8, 7.5], "texture": "#0"}, + "west": {"uv": [8, 7.5, 10.5, 10], "texture": "#0"}, + "up": {"uv": [9, 5, 10, 6.25], "texture": "#0"} + } + }, + { + "name": "light", + "from": [1, 13, 2], + "to": [2, 14, 5], + "faces": { + "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, + "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "light", + "from": [1, 11, 2], + "to": [2, 12, 5], + "faces": { + "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, + "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "light", + "from": [1, 9, 2], + "to": [2, 10, 5], + "faces": { + "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, + "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "light", + "from": [14, 9, 2], + "to": [15, 10, 5], + "faces": { + "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, + "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "light", + "from": [14, 13, 2], + "to": [15, 14, 5], + "faces": { + "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, + "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "light", + "from": [14, 11, 2], + "to": [15, 12, 5], + "faces": { + "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, + "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, + "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "light", + "from": [5, 15, 2], + "to": [11, 16, 3], + "faces": { + "north": {"uv": [12.5, 1.5, 15.5, 1.75], "texture": "#0"}, + "east": {"uv": [15, 1.5, 15.5, 1.75], "texture": "#0"}, + "south": {"uv": [12.5, 1.5, 15.5, 1.75], "texture": "#0"}, + "west": {"uv": [12.5, 1.5, 13, 1.75], "texture": "#0"}, + "up": {"uv": [12.5, 1.5, 15.5, 1.75], "texture": "#0"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 225, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "scale": [0.5, 0.5, 0.5] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/electric_furnace.png b/src/main/resources/assets/overdrive_that_matters/textures/block/electric_furnace.png new file mode 100644 index 0000000000000000000000000000000000000000..b488e27a0992e0278390a313d23c2fbae0ca6a36 GIT binary patch literal 852 zcmeAS@N?(olHy`uVBq!ia0vp^3P9|@!3-pQ0$S$)DaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(ehefdM`tuIKdipPHDg*U-?`)(!~?Nk~XAH8oXJQ~UqGGd92KSxxxCD6_Q6 zmfWU(F)^{*w{QQM)l^heR9{~&!ojI5B&Z=QVyvX}>eZ`bTf+bU{|_`({%yTKkdiJ5 z@(Tuv-~bHjCfue#Wt;^bk;M!Qd6)WZky|R+IxBa#+>(2M>3-7#7mH1`%`%35q)tP)T8nt>_8awqB4dYf@ zTsYGD+o12qsl*-Zh7GNf0T+}NdLBRa3Xq$#&ZbP0NBooDh35r&M#@J|F*lXYWSgcb zs>M95Qs~Ft1J%;`0UOGU+Pod*ikLNX_B1Nlvm87ot>iFS;7H<$i^rt(f*Sh&&XrY| zu#)HT6R!m)f3oI;yk>OdUBankwN(4zC1(rngau7{zUR|zI1fGhz%sjejYy8E3ztyz z-^$Cswz>$GaKVA!5;L1NTSQ05DzQ!ql(m>Cx5VF!wPx#1ZP1_K>z@;j|==^1poj5KTu3mMUjz_rKP2Re}5}0D^yfeU|?W1H8mzCCKeVJ zU2l5kd{@C*HfDK*ZGw;6+uQt_f^u?l>gwvov{(QC{{R30QuzCA0000LbW%=J|NsC0 z|NsC0|NsC0|NsC0|NsC004v#j>Hq)$32;bRa{vGi!T0RZ8-tSc_LEzckU5W)hGFvB2N*VivXebHUzhO&Ol&pIqoCGjCx055UC!$4pa$up-& z`ZzhFK;{RK0HI5w2Khh23s+l{;C+ltK`(j>T7*b~WYh?BW(-|g1RH$Uz#v@r2#wIa z7^babtI7LXg!cQWzTun{q`Y zRj^YOX&nKm01=Y6HWS$=vjRr&DNh)YjB3gWeQz)V=OYsYJRS}+?1%n3=sF2de3<`9 z=w`umbo?av3jx^I)$y%*;uql-0ecF_;Lm?VFq7h+goG5*_;98es?fLB8R6cjL*HJV yaBua#>f5WQ&|xV!tmDwPSC4QXw`s5x>-rZ!`B=hYV6ry=0000 Date: Fri, 21 Jul 2023 02:54:39 +0600 Subject: [PATCH 0805/1199] Matter upgrades texture (not implemented) --- .../textures/item/upgrade_matter.png | Bin 0 -> 263 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_matter.png diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_matter.png b/src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_matter.png new file mode 100644 index 0000000000000000000000000000000000000000..0144f3c1378f49d14dbfc25bef0805686f8f3995 GIT binary patch literal 263 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}H0G|-oz`(%z`uc)`0x>bM|NsA+nws)i2uUW$|GxoL!7#VK@;i{?Dhcun z2FgMJ!=^Jj=YgV}1s;*b3=DkxL735kHCP2G7~|>U7@`pzd)}MxfC2|gz|YK`|6946 zFWuPa_MBB*_TT9bg{qA+%4RHCu=%0OSBE=~b}!KSD(quoVAaAMVX4^1e3vmPZPixZ u2|-s?7?rIj*^4X3GuT~^@?ZDzo&MV$EIiEJ7taFiVeoYIb6Mw<&;$T;5?T2G literal 0 HcmV?d00001 From 19e205b527832eec4cca01bf962469d789f7c579 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Fri, 21 Jul 2023 17:53:25 +0600 Subject: [PATCH 0806/1199] Furnaces --- .../mc/otm/datagen/blocks/BlockStates.kt | 1 + .../mc/otm/datagen/items/ItemModels.kt | 1 + .../mc/otm/shapes/BlockShapes.java | 53 ++ .../block/powered_blast_furnace_error.json | 259 ++++++++++ .../block/powered_blast_furnace_idle.json | 250 ++++++++++ .../block/powered_blast_furnace_working.json | 260 ++++++++++ .../models/block/powered_furnace_error.json | 470 +++++++++++------- .../models/block/powered_furnace_idle.json | 468 ++++++++++------- .../models/block/powered_furnace_working.json | 456 +++++++++-------- .../textures/block/electric_furnace.png | Bin 852 -> 724 bytes .../block/electric_furnace_offline.png | Bin 820 -> 671 bytes .../textures/block/induction_furnace.png | Bin 0 -> 906 bytes .../block/induction_furnace_offline.png | Bin 0 -> 824 bytes 13 files changed, 1663 insertions(+), 555 deletions(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/powered_blast_furnace_error.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/powered_blast_furnace_idle.json create mode 100644 src/main/resources/assets/overdrive_that_matters/models/block/powered_blast_furnace_working.json create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/induction_furnace.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/induction_furnace_offline.png diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt index 391f7d877..c5f1f5680 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt @@ -97,6 +97,7 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { provider.block(MBlocks.TWIN_PLATE_PRESS) provider.block(MBlocks.GRAVITATION_STABILIZER) provider.block(MBlocks.GRAVITATION_STABILIZER_LENS) + provider.block(MBlocks.POWERED_BLAST_FURNACE) provider.block(MBlocks.POWERED_FURNACE) provider.block(MBlocks.STORAGE_POWER_SUPPLIER) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index 4f747ee5c..1dab2caeb 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -143,6 +143,7 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.block(MItems.ENERGY_SERVO, "energy_servo") provider.block(MItems.ESSENCE_STORAGE, "essence_storage") provider.block(MItems.MATTER_RECONSTRUCTOR, "matter_reconstructor") + provider.block(MItems.POWERED_BLAST_FURNACE, "powered_blast_furnace_working") provider.block(MItems.POWERED_FURNACE, "powered_furnace_working") provider.block(MItems.PLATE_PRESS, "plate_press_idle") diff --git a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java index 9e09e6691..dc64f03ec 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java +++ b/src/main/java/ru/dbotthepony/mc/otm/shapes/BlockShapes.java @@ -732,4 +732,57 @@ public class BlockShapes { new SimpleCuboid(0.125d, 0.3125d, 0.125d, 0.875d, 0.5d, 0.875d), new SimpleCuboid(0d, 0.5d, 0d, 1d, 1d, 1d) ); + + public static final BlockShape POWERED_FURNACE = new BlockShape( + new SimpleCuboid(0.9375d, 0.5d, 0d, 1d, 1d, 0.0625d), + new SimpleCuboid(0d, 0.5d, 0d, 0.0625d, 1d, 0.0625d), + new SimpleCuboid(0d, 0.5d, 0.0625d, 1d, 1d, 0.6875d), + new SimpleCuboid(0.6875d, 0.5d, 0.6875d, 1d, 1d, 0.9375d), + new SimpleCuboid(0.6875d, 0.3125d, 0.9375d, 0.75d, 1d, 1d), + new SimpleCuboid(0.9375d, 0.3125d, 0.9375d, 1d, 1d, 1d), + new SimpleCuboid(0.75d, 0.9375d, 0.9375d, 0.9375d, 1d, 1d), + new SimpleCuboid(0.6875d, 0d, 0.9375d, 1d, 0.3125d, 1d), + new SimpleCuboid(0d, 0.375d, 0.9375d, 0.6875d, 0.5d, 1d), + new SimpleCuboid(0.0625d, 0.5d, 0d, 0.9375d, 0.5625d, 0.0625d), + new SimpleCuboid(0.0625d, 0.9375d, 0d, 0.9375d, 1d, 0.0625d), + new SimpleCuboid(0d, 0.0625d, 0.0625d, 1d, 0.4375d, 0.4375d), + new SimpleCuboid(0.8125d, 0d, 0d, 0.9375d, 0.5d, 0.5d), + new SimpleCuboid(0.0625d, 0d, 0d, 0.1875d, 0.5d, 0.5d), + new SimpleCuboid(0.0625d, 0.5d, 0.75d, 0.3125d, 1d, 1d), + new SimpleCuboid(0.375d, 0.5d, 0.75d, 0.625d, 1d, 1d), + new SimpleCuboid(0d, 0d, 0.5d, 1d, 0.5d, 0.9375d), + new SimpleCuboid(0d, 0.5d, 0.6875d, 0.6875d, 0.875d, 0.9375d), + new SimpleCuboid(-0.03125d, 1.03125d, 0.0625d, 1.03125d, 1.03125d, 0.125d), + new SimpleCuboid(-0.03125d, 0.71875d, 0.0625d, -0.03125d, 1.03125d, 0.125d), + new SimpleCuboid(-0.03125d, 0.71875d, 0.125d, -0.03125d, 0.78125d, 0.625d), + new SimpleCuboid(1.03125d, 0.71875d, 0.125d, 1.03125d, 0.78125d, 0.625d), + new SimpleCuboid(1.03125d, 0.71875d, 0.0625d, 1.03125d, 1.03125d, 0.125d), + new SimpleCuboid(-0.0625d, 0.625d, 0.375d, 0d, 0.875d, 0.625d), + new SimpleCuboid(1d, 0.625d, 0.375d, 1.0625d, 0.875d, 0.625d), + new SimpleCuboid(0.0625d, 0.5625d, 0.061875d, 0.9375d, 0.9375d, 0.061875d) + ); + + public static final BlockShape POWERED_BLAST_FURNACE = new BlockShape( + new SimpleCuboid(0.0625d, 0.625d, 0.6875d, 0.9375d, 0.6875d, 0.9375d), + new SimpleCuboid(0.0625d, 0.5d, 0.6875d, 0.9375d, 0.5625d, 0.9375d), + new SimpleCuboid(0.0625d, 0.375d, 0.6875d, 0.9375d, 0.4375d, 0.9375d), + new SimpleCuboid(0d, 0d, 0d, 1d, 0.3125d, 1d), + new SimpleCuboid(0d, 0.3125d, 0.375d, 1d, 1d, 0.6875d), + new SimpleCuboid(0d, 0.75d, 0.6875d, 1d, 1d, 1d), + new SimpleCuboid(0.125d, 0.3125d, 0.6875d, 0.875d, 0.75d, 0.875d), + new SimpleCuboid(0.1875d, 0.3125d, 0d, 0.8125d, 1d, 0.375d), + new SimpleCuboid(0.25d, 1d, 0.25d, 0.75d, 1.0625d, 0.75d), + new SimpleCuboid(0.03125d, 0.3125d, 0.65625d, 0.96875d, 0.5d, 0.96875d), + new SimpleCuboid(0.96875d, 0.3125d, 0.65625d, 0.03125d, 0.75d, 0.96875d), + new SimpleCuboid(0.8125d, 0.3125d, 0.0625d, 0.9375d, 0.9375d, 0.375d), + new SimpleCuboid(0.0625d, 0.3125d, 0.0625d, 0.1875d, 0.9375d, 0.375d), + new SimpleCuboid(0.061875d, 0.5625d, 0.125d, 0.061875d, 0.625d, 0.3125d), + new SimpleCuboid(0.061875d, 0.6875d, 0.125d, 0.061875d, 0.75d, 0.3125d), + new SimpleCuboid(0.061875d, 0.8125d, 0.125d, 0.061875d, 0.875d, 0.3125d), + new SimpleCuboid(0.938125d, 0.8125d, 0.125d, 0.938125d, 0.875d, 0.3125d), + new SimpleCuboid(0.938125d, 0.5625d, 0.125d, 0.938125d, 0.625d, 0.3125d), + new SimpleCuboid(0.938125d, 0.6875d, 0.125d, 0.938125d, 0.75d, 0.3125d), + new SimpleCuboid(0.3125d, 1.000625d, 0.125d, 0.6875d, 1.000625d, 0.1875d) + ); + } diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/powered_blast_furnace_error.json b/src/main/resources/assets/overdrive_that_matters/models/block/powered_blast_furnace_error.json new file mode 100644 index 000000000..e2d063ba8 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/powered_blast_furnace_error.json @@ -0,0 +1,259 @@ +{ + "render_type": "translucent", + "texture_size": [32, 64], + "textures": { + "particle": "overdrive_that_matters:block/induction_furnace", + "texture": "overdrive_that_matters:block/induction_furnace" + }, + "elements": [ + { + "name": "heatsink", + "from": [1, 10, 11], + "to": [15, 11, 15], + "faces": { + "east": {"uv": [7, 0.25, 9, 0.5], "texture": "#texture"}, + "south": {"uv": [9, 0, 16, 0.25], "texture": "#texture"}, + "west": {"uv": [7, 0, 9, 0.25], "texture": "#texture"}, + "up": {"uv": [0, 0, 7, 1], "texture": "#texture"}, + "down": {"uv": [0, 0, 7, 1], "rotation": 180, "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "heatsink", + "from": [1, 8, 11], + "to": [15, 9, 15], + "faces": { + "east": {"uv": [7, 0.25, 9, 0.5], "texture": "#texture"}, + "south": {"uv": [9, 0, 16, 0.25], "texture": "#texture"}, + "west": {"uv": [7, 0, 9, 0.25], "texture": "#texture"}, + "up": {"uv": [0, 0, 7, 1], "texture": "#texture"}, + "down": {"uv": [0, 0, 7, 1], "rotation": 180, "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "heatsink", + "from": [1, 6, 11], + "to": [15, 7, 15], + "faces": { + "east": {"uv": [7, 0.25, 9, 0.5], "texture": "#texture"}, + "south": {"uv": [9, 0, 16, 0.25], "texture": "#texture"}, + "west": {"uv": [7, 0, 9, 0.25], "texture": "#texture"}, + "up": {"uv": [0, 0, 7, 1], "texture": "#texture"}, + "down": {"uv": [0, 0, 7, 1], "rotation": 180, "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "base", + "from": [0, 0, 0], + "to": [16, 5, 16], + "faces": { + "north": {"uv": [0, 9.5, 8, 10.75], "texture": "#texture"}, + "east": {"uv": [0, 10.75, 8, 12], "texture": "#texture"}, + "south": {"uv": [0, 10.75, 8, 12], "texture": "#texture"}, + "west": {"uv": [0, 10.75, 8, 12], "texture": "#texture"}, + "up": {"uv": [0, 12, 8, 16], "texture": "#texture"}, + "down": {"uv": [0, 12, 8, 16], "texture": "#texture"} + } + }, + { + "name": "base", + "from": [0, 5, 6], + "to": [16, 16, 11], + "faces": { + "north": {"uv": [0, 3.5, 8, 6.25], "texture": "#texture"}, + "east": {"uv": [13, 7.25, 10.5, 10], "texture": "#texture"}, + "south": {"uv": [0, 12, 8, 14.75], "texture": "#texture"}, + "west": {"uv": [10.5, 7.25, 13, 10], "texture": "#texture"}, + "up": {"uv": [0, 2.25, 8, 3.5], "rotation": 180, "texture": "#texture"} + } + }, + { + "name": "base", + "from": [0, 12, 11], + "to": [16, 16, 16], + "faces": { + "east": {"uv": [15.5, 7.25, 13, 8.25], "texture": "#texture"}, + "south": {"uv": [0, 6.25, 8, 7.25], "texture": "#texture"}, + "west": {"uv": [13, 7.25, 15.5, 8.25], "texture": "#texture"}, + "up": {"uv": [0, 1, 8, 2.25], "rotation": 180, "texture": "#texture"}, + "down": {"uv": [0, 12, 8, 13.25], "texture": "#texture"} + } + }, + { + "name": "base", + "from": [2, 5, 11], + "to": [14, 12, 14], + "faces": { + "east": {"uv": [6, 7.75, 7.5, 9.5], "texture": "#texture"}, + "south": {"uv": [1, 7.75, 7, 9.5], "texture": "#texture"}, + "west": {"uv": [0, 7.75, 1.5, 9.5], "texture": "#texture"} + } + }, + { + "name": "chamber", + "from": [3, 5, 0], + "to": [13, 16, 6], + "faces": { + "north": {"uv": [8, 13.25, 13, 16], "texture": "#texture"}, + "east": {"uv": [16, 13.25, 13, 16], "texture": "#texture"}, + "west": {"uv": [13, 13.25, 16, 16], "texture": "#texture"}, + "up": {"uv": [8, 11.75, 13, 13.25], "rotation": 180, "texture": "#texture"} + } + }, + { + "name": "smokething", + "from": [4, 16, 4], + "to": [12, 17, 12], + "faces": { + "north": {"uv": [8, 3, 12, 3.25], "texture": "#texture"}, + "east": {"uv": [8, 3, 12, 3.25], "texture": "#texture"}, + "south": {"uv": [8, 3, 12, 3.25], "texture": "#texture"}, + "west": {"uv": [8, 3, 12, 3.25], "texture": "#texture"}, + "up": {"uv": [8, 1, 12, 3], "texture": "#texture"} + } + }, + { + "name": "net", + "from": [0.5, 5, 10.5], + "to": [15.5, 8, 15.5], + "faces": { + "east": {"uv": [15.5, 9.25, 13, 10], "texture": "#texture"}, + "south": {"uv": [8, 11, 15.5, 11.75], "texture": "#texture"}, + "west": {"uv": [13, 9.25, 15.5, 10], "texture": "#texture"} + } + }, + { + "name": "net", + "from": [15.5, 5, 10.5], + "to": [0.5, 12, 15.5], + "faces": { + "east": {"uv": [13, 8.25, 15.5, 10], "texture": "#texture"}, + "south": {"uv": [8, 10, 15.5, 11.75], "texture": "#texture"}, + "west": {"uv": [13, 8.25, 15.5, 10], "texture": "#texture"} + } + }, + { + "name": "detals", + "from": [13, 5, 1], + "to": [15, 15, 6], + "faces": { + "north": {"uv": [8, 5, 9, 7.5], "texture": "#texture"}, + "east": {"uv": [8, 7.5, 10.5, 10], "texture": "#texture"}, + "up": {"uv": [10, 5, 9, 6.25], "texture": "#texture"} + } + }, + { + "name": "detals", + "from": [1, 5, 1], + "to": [3, 15, 6], + "faces": { + "north": {"uv": [9, 5, 8, 7.5], "texture": "#texture"}, + "west": {"uv": [8, 7.5, 10.5, 10], "texture": "#texture"}, + "up": {"uv": [9, 5, 10, 6.25], "texture": "#texture"} + } + }, + { + "name": "light", + "from": [1, 9, 2], + "to": [1, 10, 5], + "faces": { + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "light", + "from": [1, 11, 2], + "to": [1, 12, 5], + "faces": { + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "light", + "from": [1, 13, 2], + "to": [1, 14, 5], + "faces": { + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "light", + "from": [15, 13, 2], + "to": [15, 14, 5], + "faces": { + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "light", + "from": [15, 9, 2], + "to": [15, 10, 5], + "faces": { + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "light", + "from": [15, 11, 2], + "to": [15, 12, 5], + "faces": { + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "light", + "from": [5, 16, 2], + "to": [11, 16, 3], + "faces": { + "up": {"uv": [12.5, 1.5, 15.5, 1.75], "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 225, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "scale": [0.5, 0.5, 0.5] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/powered_blast_furnace_idle.json b/src/main/resources/assets/overdrive_that_matters/models/block/powered_blast_furnace_idle.json new file mode 100644 index 000000000..fddc23f2a --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/powered_blast_furnace_idle.json @@ -0,0 +1,250 @@ +{ + "credit": "Made with Blockbench", + "render_type": "translucent", + "texture_size": [32, 64], + "textures": { + "particle": "overdrive_that_matters:block/induction_furnace_offline", + "texture": "overdrive_that_matters:block/induction_furnace_offline" + }, + "elements": [ + { + "name": "heatsink", + "from": [1, 10, 11], + "to": [15, 11, 15], + "faces": { + "east": {"uv": [7, 0.25, 9, 0.5], "texture": "#texture"}, + "south": {"uv": [9, 0, 16, 0.25], "texture": "#texture"}, + "west": {"uv": [7, 0, 9, 0.25], "texture": "#texture"}, + "up": {"uv": [0, 0, 7, 1], "texture": "#texture"}, + "down": {"uv": [0, 0, 7, 1], "rotation": 180, "texture": "#texture"} + } + }, + { + "name": "heatsink", + "from": [1, 8, 11], + "to": [15, 9, 15], + "faces": { + "east": {"uv": [7, 0.25, 9, 0.5], "texture": "#texture"}, + "south": {"uv": [9, 0, 16, 0.25], "texture": "#texture"}, + "west": {"uv": [7, 0, 9, 0.25], "texture": "#texture"}, + "up": {"uv": [0, 0, 7, 1], "texture": "#texture"}, + "down": {"uv": [0, 0, 7, 1], "rotation": 180, "texture": "#texture"} + } + }, + { + "name": "heatsink", + "from": [1, 6, 11], + "to": [15, 7, 15], + "faces": { + "east": {"uv": [7, 0.25, 9, 0.5], "texture": "#texture"}, + "south": {"uv": [9, 0, 16, 0.25], "texture": "#texture"}, + "west": {"uv": [7, 0, 9, 0.25], "texture": "#texture"}, + "up": {"uv": [0, 0, 7, 1], "texture": "#texture"}, + "down": {"uv": [0, 0, 7, 1], "rotation": 180, "texture": "#texture"} + } + }, + { + "name": "base", + "from": [0, 0, 0], + "to": [16, 5, 16], + "faces": { + "north": {"uv": [0, 9.5, 8, 10.75], "texture": "#texture"}, + "east": {"uv": [0, 10.75, 8, 12], "texture": "#texture"}, + "south": {"uv": [0, 10.75, 8, 12], "texture": "#texture"}, + "west": {"uv": [0, 10.75, 8, 12], "texture": "#texture"}, + "up": {"uv": [0, 12, 8, 16], "texture": "#texture"}, + "down": {"uv": [0, 12, 8, 16], "texture": "#texture"} + } + }, + { + "name": "base", + "from": [0, 5, 6], + "to": [16, 16, 11], + "faces": { + "north": {"uv": [0, 3.5, 8, 6.25], "texture": "#texture"}, + "east": {"uv": [13, 7.25, 10.5, 10], "texture": "#texture"}, + "south": {"uv": [0, 12, 8, 14.75], "texture": "#texture"}, + "west": {"uv": [10.5, 7.25, 13, 10], "texture": "#texture"}, + "up": {"uv": [0, 2.25, 8, 3.5], "rotation": 180, "texture": "#texture"} + } + }, + { + "name": "base", + "from": [0, 12, 11], + "to": [16, 16, 16], + "faces": { + "east": {"uv": [15.5, 7.25, 13, 8.25], "texture": "#texture"}, + "south": {"uv": [0, 6.25, 8, 7.25], "texture": "#texture"}, + "west": {"uv": [13, 7.25, 15.5, 8.25], "texture": "#texture"}, + "up": {"uv": [0, 1, 8, 2.25], "rotation": 180, "texture": "#texture"}, + "down": {"uv": [0, 12, 8, 13.25], "texture": "#texture"} + } + }, + { + "name": "base", + "from": [2, 5, 11], + "to": [14, 12, 14], + "faces": { + "east": {"uv": [6, 7.75, 7.5, 9.5], "texture": "#texture"}, + "south": {"uv": [1, 7.75, 7, 9.5], "texture": "#texture"}, + "west": {"uv": [0, 7.75, 1.5, 9.5], "texture": "#texture"} + } + }, + { + "name": "chamber", + "from": [3, 5, 0], + "to": [13, 16, 6], + "faces": { + "north": {"uv": [8, 13.25, 13, 16], "texture": "#texture"}, + "east": {"uv": [16, 13.25, 13, 16], "texture": "#texture"}, + "west": {"uv": [13, 13.25, 16, 16], "texture": "#texture"}, + "up": {"uv": [8, 11.75, 13, 13.25], "rotation": 180, "texture": "#texture"} + } + }, + { + "name": "smokething", + "from": [4, 16, 4], + "to": [12, 17, 12], + "faces": { + "north": {"uv": [8, 3, 12, 3.25], "texture": "#texture"}, + "east": {"uv": [8, 3, 12, 3.25], "texture": "#texture"}, + "south": {"uv": [8, 3, 12, 3.25], "texture": "#texture"}, + "west": {"uv": [8, 3, 12, 3.25], "texture": "#texture"}, + "up": {"uv": [8, 1, 12, 3], "texture": "#texture"} + } + }, + { + "name": "net", + "from": [0.5, 5, 10.5], + "to": [15.5, 8, 15.5], + "faces": { + "east": {"uv": [15.5, 9.25, 13, 10], "texture": "#texture"}, + "south": {"uv": [8, 11, 15.5, 11.75], "texture": "#texture"}, + "west": {"uv": [13, 9.25, 15.5, 10], "texture": "#texture"} + } + }, + { + "name": "net", + "from": [15.5, 5, 10.5], + "to": [0.5, 12, 15.5], + "faces": { + "east": {"uv": [13, 8.25, 15.5, 10], "texture": "#texture"}, + "south": {"uv": [8, 10, 15.5, 11.75], "texture": "#texture"}, + "west": {"uv": [13, 8.25, 15.5, 10], "texture": "#texture"} + } + }, + { + "name": "detals", + "from": [13, 5, 1], + "to": [15, 15, 6], + "faces": { + "north": {"uv": [8, 5, 9, 7.5], "texture": "#texture"}, + "east": {"uv": [8, 7.5, 10.5, 10], "texture": "#texture"}, + "up": {"uv": [10, 5, 9, 6.25], "texture": "#texture"} + } + }, + { + "name": "detals", + "from": [1, 5, 1], + "to": [3, 15, 6], + "faces": { + "north": {"uv": [9, 5, 8, 7.5], "texture": "#texture"}, + "west": {"uv": [8, 7.5, 10.5, 10], "texture": "#texture"}, + "up": {"uv": [9, 5, 10, 6.25], "texture": "#texture"} + } + }, + { + "name": "light", + "from": [0.99, 9, 2], + "to": [0.99, 10, 5], + "faces": { + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"} + } + }, + { + "name": "light", + "from": [0.99, 11, 2], + "to": [0.99, 12, 5], + "faces": { + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"} + } + }, + { + "name": "light", + "from": [0.99, 13, 2], + "to": [0.99, 14, 5], + "faces": { + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"} + } + }, + { + "name": "light", + "from": [15.01, 13, 2], + "to": [15.01, 14, 5], + "faces": { + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"} + } + }, + { + "name": "light", + "from": [15.01, 9, 2], + "to": [15.01, 10, 5], + "faces": { + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"} + } + }, + { + "name": "light", + "from": [15.01, 11, 2], + "to": [15.01, 12, 5], + "faces": { + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"} + } + }, + { + "name": "light", + "from": [5, 16.01, 2], + "to": [11, 16.01, 3], + "faces": { + "up": {"uv": [12.5, 1.5, 15.5, 1.75], "texture": "#texture"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 225, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "scale": [0.5, 0.5, 0.5] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/powered_blast_furnace_working.json b/src/main/resources/assets/overdrive_that_matters/models/block/powered_blast_furnace_working.json new file mode 100644 index 000000000..9d4ea6959 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/powered_blast_furnace_working.json @@ -0,0 +1,260 @@ +{ + "credit": "Made with Blockbench", + "render_type": "translucent", + "texture_size": [32, 64], + "textures": { + "particle": "overdrive_that_matters:block/induction_furnace", + "texture": "overdrive_that_matters:block/induction_furnace" + }, + "elements": [ + { + "name": "heatsink", + "from": [1, 10, 11], + "to": [15, 11, 15], + "faces": { + "east": {"uv": [7, 0.25, 9, 0.5], "texture": "#texture"}, + "south": {"uv": [9, 0, 16, 0.25], "texture": "#texture"}, + "west": {"uv": [7, 0, 9, 0.25], "texture": "#texture"}, + "up": {"uv": [0, 0, 7, 1], "texture": "#texture"}, + "down": {"uv": [0, 0, 7, 1], "rotation": 180, "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "heatsink", + "from": [1, 8, 11], + "to": [15, 9, 15], + "faces": { + "east": {"uv": [7, 0.25, 9, 0.5], "texture": "#texture"}, + "south": {"uv": [9, 0, 16, 0.25], "texture": "#texture"}, + "west": {"uv": [7, 0, 9, 0.25], "texture": "#texture"}, + "up": {"uv": [0, 0, 7, 1], "texture": "#texture"}, + "down": {"uv": [0, 0, 7, 1], "rotation": 180, "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "heatsink", + "from": [1, 6, 11], + "to": [15, 7, 15], + "faces": { + "east": {"uv": [7, 0.25, 9, 0.5], "texture": "#texture"}, + "south": {"uv": [9, 0, 16, 0.25], "texture": "#texture"}, + "west": {"uv": [7, 0, 9, 0.25], "texture": "#texture"}, + "up": {"uv": [0, 0, 7, 1], "texture": "#texture"}, + "down": {"uv": [0, 0, 7, 1], "rotation": 180, "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "base", + "from": [0, 0, 0], + "to": [16, 5, 16], + "faces": { + "north": {"uv": [0, 9.5, 8, 10.75], "texture": "#texture"}, + "east": {"uv": [0, 10.75, 8, 12], "texture": "#texture"}, + "south": {"uv": [0, 10.75, 8, 12], "texture": "#texture"}, + "west": {"uv": [0, 10.75, 8, 12], "texture": "#texture"}, + "up": {"uv": [0, 12, 8, 16], "texture": "#texture"}, + "down": {"uv": [0, 12, 8, 16], "texture": "#texture"} + } + }, + { + "name": "base", + "from": [0, 5, 6], + "to": [16, 16, 11], + "faces": { + "north": {"uv": [0, 3.5, 8, 6.25], "texture": "#texture"}, + "east": {"uv": [13, 7.25, 10.5, 10], "texture": "#texture"}, + "south": {"uv": [0, 12, 8, 14.75], "texture": "#texture"}, + "west": {"uv": [10.5, 7.25, 13, 10], "texture": "#texture"}, + "up": {"uv": [0, 2.25, 8, 3.5], "rotation": 180, "texture": "#texture"} + } + }, + { + "name": "base", + "from": [0, 12, 11], + "to": [16, 16, 16], + "faces": { + "east": {"uv": [15.5, 7.25, 13, 8.25], "texture": "#texture"}, + "south": {"uv": [0, 6.25, 8, 7.25], "texture": "#texture"}, + "west": {"uv": [13, 7.25, 15.5, 8.25], "texture": "#texture"}, + "up": {"uv": [0, 1, 8, 2.25], "rotation": 180, "texture": "#texture"}, + "down": {"uv": [0, 12, 8, 13.25], "texture": "#texture"} + } + }, + { + "name": "base", + "from": [2, 5, 11], + "to": [14, 12, 14], + "faces": { + "east": {"uv": [6, 7.75, 7.5, 9.5], "texture": "#texture"}, + "south": {"uv": [1, 7.75, 7, 9.5], "texture": "#texture"}, + "west": {"uv": [0, 7.75, 1.5, 9.5], "texture": "#texture"} + } + }, + { + "name": "chamber", + "from": [3, 5, 0], + "to": [13, 16, 6], + "faces": { + "north": {"uv": [8, 13.25, 13, 16], "texture": "#texture"}, + "east": {"uv": [16, 13.25, 13, 16], "texture": "#texture"}, + "west": {"uv": [13, 13.25, 16, 16], "texture": "#texture"}, + "up": {"uv": [8, 11.75, 13, 13.25], "rotation": 180, "texture": "#texture"} + } + }, + { + "name": "smokething", + "from": [4, 16, 4], + "to": [12, 17, 12], + "faces": { + "north": {"uv": [8, 3, 12, 3.25], "texture": "#texture"}, + "east": {"uv": [8, 3, 12, 3.25], "texture": "#texture"}, + "south": {"uv": [8, 3, 12, 3.25], "texture": "#texture"}, + "west": {"uv": [8, 3, 12, 3.25], "texture": "#texture"}, + "up": {"uv": [8, 1, 12, 3], "texture": "#texture"} + } + }, + { + "name": "net", + "from": [0.5, 5, 10.5], + "to": [15.5, 8, 15.5], + "faces": { + "east": {"uv": [15.5, 9.25, 13, 10], "texture": "#texture"}, + "south": {"uv": [8, 11, 15.5, 11.75], "texture": "#texture"}, + "west": {"uv": [13, 9.25, 15.5, 10], "texture": "#texture"} + } + }, + { + "name": "net", + "from": [15.5, 5, 10.5], + "to": [0.5, 12, 15.5], + "faces": { + "east": {"uv": [13, 8.25, 15.5, 10], "texture": "#texture"}, + "south": {"uv": [8, 10, 15.5, 11.75], "texture": "#texture"}, + "west": {"uv": [13, 8.25, 15.5, 10], "texture": "#texture"} + } + }, + { + "name": "detals", + "from": [13, 5, 1], + "to": [15, 15, 6], + "faces": { + "north": {"uv": [8, 5, 9, 7.5], "texture": "#texture"}, + "east": {"uv": [8, 7.5, 10.5, 10], "texture": "#texture"}, + "up": {"uv": [10, 5, 9, 6.25], "texture": "#texture"} + } + }, + { + "name": "detals", + "from": [1, 5, 1], + "to": [3, 15, 6], + "faces": { + "north": {"uv": [9, 5, 8, 7.5], "texture": "#texture"}, + "west": {"uv": [8, 7.5, 10.5, 10], "texture": "#texture"}, + "up": {"uv": [9, 5, 10, 6.25], "texture": "#texture"} + } + }, + { + "name": "light", + "from": [0.99, 9, 2], + "to": [0.99, 10, 5], + "faces": { + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "light", + "from": [0.99, 11, 2], + "to": [0.99, 12, 5], + "faces": { + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "light", + "from": [0.99, 13, 2], + "to": [0.99, 14, 5], + "faces": { + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "light", + "from": [15.01, 13, 2], + "to": [15.01, 14, 5], + "faces": { + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "light", + "from": [15.01, 9, 2], + "to": [15.01, 10, 5], + "faces": { + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "light", + "from": [15.01, 11, 2], + "to": [15.01, 12, 5], + "faces": { + "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"}, + "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + }, + { + "name": "light", + "from": [5, 16.01, 2], + "to": [11, 16.01, 3], + "faces": { + "up": {"uv": [12.5, 1.5, 15.5, 1.75], "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 225, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "scale": [0.5, 0.5, 0.5] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_error.json b/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_error.json index 597d7d580..4402744be 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_error.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_error.json @@ -1,245 +1,353 @@ { - "render_type": "cutout", + "credit": "Made with Blockbench", + "render_type": "translucent", + "texture_size": [64, 32], "textures": { "0": "overdrive_that_matters:block/electric_furnace_offline", "particle": "overdrive_that_matters:block/electric_furnace_offline" }, "elements": [ { - "name": "heatsink", - "from": [1, 10, 11], - "to": [15, 11, 15], + "name": "chamber", + "from": [15, 8, 0], + "to": [16, 16, 1], "faces": { - "east": {"uv": [7, 0.25, 9, 0.5], "texture": "#0"}, - "south": {"uv": [9, 0, 16, 0.25], "texture": "#0"}, - "west": {"uv": [7, 0, 9, 0.25], "texture": "#0"}, - "up": {"uv": [0, 0, 7, 1], "texture": "#0"}, - "down": {"uv": [0, 0, 7, 1], "rotation": 180, "texture": "#0"} - } - }, - { - "name": "heatsink", - "from": [1, 8, 11], - "to": [15, 9, 15], - "faces": { - "east": {"uv": [7, 0.25, 9, 0.5], "texture": "#0"}, - "south": {"uv": [9, 0, 16, 0.25], "texture": "#0"}, - "west": {"uv": [7, 0, 9, 0.25], "texture": "#0"}, - "up": {"uv": [0, 0, 7, 1], "texture": "#0"}, - "down": {"uv": [0, 0, 7, 1], "rotation": 180, "texture": "#0"} - } - }, - { - "name": "heatsink", - "from": [1, 6, 11], - "to": [15, 7, 15], - "faces": { - "east": {"uv": [7, 0.25, 9, 0.5], "texture": "#0"}, - "south": {"uv": [9, 0, 16, 0.25], "texture": "#0"}, - "west": {"uv": [7, 0, 9, 0.25], "texture": "#0"}, - "up": {"uv": [0, 0, 7, 1], "texture": "#0"}, - "down": {"uv": [0, 0, 7, 1], "rotation": 180, "texture": "#0"} - } - }, - { - "name": "base", - "from": [0, 0, 0], - "to": [16, 5, 16], - "faces": { - "north": {"uv": [0, 9.5, 8, 10.75], "texture": "#0"}, - "east": {"uv": [0, 10.75, 8, 12], "texture": "#0"}, - "south": {"uv": [0, 10.75, 8, 12], "texture": "#0"}, - "west": {"uv": [0, 10.75, 8, 12], "texture": "#0"}, - "up": {"uv": [0, 12, 8, 16], "texture": "#0"}, - "down": {"uv": [0, 12, 8, 16], "texture": "#0"} - } - }, - { - "name": "base", - "from": [0, 5, 6], - "to": [16, 16, 11], - "faces": { - "north": {"uv": [0, 3.5, 8, 6.25], "texture": "#0"}, - "east": {"uv": [13, 7.25, 10.5, 10], "texture": "#0"}, - "south": {"uv": [0, 12, 8, 14.75], "texture": "#0"}, - "west": {"uv": [10.5, 7.25, 13, 10], "texture": "#0"}, - "up": {"uv": [0, 2.25, 8, 3.5], "rotation": 180, "texture": "#0"} - } - }, - { - "name": "base", - "from": [0, 12, 11], - "to": [16, 16, 16], - "faces": { - "east": {"uv": [15.5, 7.25, 13, 8.25], "texture": "#0"}, - "south": {"uv": [0, 6.25, 8, 7.25], "texture": "#0"}, - "west": {"uv": [13, 7.25, 15.5, 8.25], "texture": "#0"}, - "up": {"uv": [0, 1, 8, 2.25], "rotation": 180, "texture": "#0"}, - "down": {"uv": [0, 12, 8, 13.25], "texture": "#0"} - } - }, - { - "name": "base", - "from": [2, 5, 11], - "to": [14, 12, 14], - "faces": { - "east": {"uv": [6, 7.75, 7.5, 9.5], "texture": "#0"}, - "south": {"uv": [1, 7.75, 7, 9.5], "texture": "#0"}, - "west": {"uv": [0, 7.75, 1.5, 9.5], "texture": "#0"} + "north": {"uv": [4, 9.5, 4.25, 13.5], "texture": "#0"}, + "east": {"uv": [3.75, 9.5, 4, 13.5], "texture": "#0"}, + "south": {"uv": [0, 0, 1, 8], "texture": "#missing"}, + "west": {"uv": [4, 9.5, 4.25, 13.5], "texture": "#0"}, + "up": {"uv": [4, 9, 4.25, 9.5], "texture": "#0"}, + "down": {"uv": [4, 9, 4.25, 9.5], "texture": "#0"} } }, { "name": "chamber", - "from": [3, 5, 0], - "to": [13, 16, 6], + "from": [0, 8, 0], + "to": [1, 16, 1], "faces": { - "north": {"uv": [8, 13.25, 13, 16], "texture": "#0"}, - "east": {"uv": [16, 13.25, 13, 16], "texture": "#0"}, - "west": {"uv": [13, 13.25, 16, 16], "texture": "#0"}, - "up": {"uv": [8, 11.75, 13, 13.25], "rotation": 180, "texture": "#0"} + "north": {"uv": [7.75, 9.5, 8, 13.5], "texture": "#0"}, + "east": {"uv": [7.75, 9.5, 8, 13.5], "texture": "#0"}, + "south": {"uv": [0, 0, 1, 8], "texture": "#missing"}, + "west": {"uv": [3.75, 9.5, 4, 13.5], "texture": "#0"}, + "up": {"uv": [7.75, 9, 8, 9.5], "texture": "#0"}, + "down": {"uv": [7.75, 9, 8, 9.5], "texture": "#0"} } }, { - "name": "smokething", - "from": [4, 16, 4], - "to": [12, 17, 12], + "name": "chamber", + "from": [0, 8, 1], + "to": [16, 16, 11], "faces": { - "north": {"uv": [8, 3, 12, 3.25], "texture": "#0"}, - "east": {"uv": [8, 3, 12, 3.25], "texture": "#0"}, - "south": {"uv": [8, 3, 12, 3.25], "texture": "#0"}, - "west": {"uv": [8, 3, 12, 3.25], "texture": "#0"}, - "up": {"uv": [8, 1, 12, 3], "texture": "#0"} + "north": {"uv": [4, 9.5, 8, 13.5], "texture": "#0"}, + "east": {"uv": [1.25, 9.5, 3.75, 13.5], "texture": "#0"}, + "south": {"uv": [4, 4, 8, 8], "texture": "#0"}, + "west": {"uv": [3.75, 9.5, 1.25, 13.5], "texture": "#0"}, + "up": {"uv": [4, 4, 8, 9], "rotation": 180, "texture": "#0"}, + "down": {"uv": [4, 4, 8, 9], "texture": "#0"} } }, { - "name": "net", - "from": [0.5, 5, 10.5], - "to": [15.5, 12, 15.5], + "name": "exhaust", + "from": [11, 8, 11], + "to": [16, 16, 15], "faces": { - "east": {"uv": [13, 8.25, 15.5, 10], "texture": "#0"}, - "south": {"uv": [8, 10, 15.5, 11.75], "texture": "#0"}, - "west": {"uv": [13, 8.25, 15.5, 10], "texture": "#0"} + "north": {"uv": [0, 0, 5, 8], "texture": "#missing"}, + "east": {"uv": [8, 7.5, 9, 11.5], "texture": "#0"}, + "south": {"uv": [12.25, 0, 13.5, 4], "texture": "#0"}, + "west": {"uv": [9, 7.5, 8, 11.5], "texture": "#0"}, + "up": {"uv": [2.75, 13.5, 4, 15.5], "texture": "#0"}, + "down": {"uv": [0, 0, 5, 4], "texture": "#missing"} } }, { - "name": "net", - "from": [15.5, 5, 10.5], - "to": [0.5, 12, 15.5], + "name": "exhaust", + "from": [11, 5, 15], + "to": [12, 16, 16], "faces": { - "east": {"uv": [13, 8.25, 15.5, 10], "texture": "#0"}, - "south": {"uv": [8, 10, 15.5, 11.75], "texture": "#0"}, - "west": {"uv": [13, 8.25, 15.5, 10], "texture": "#0"} + "north": {"uv": [0, 0, 1, 11], "texture": "#missing"}, + "east": {"uv": [0, 9, 0.25, 14.5], "texture": "#0"}, + "south": {"uv": [0, 9, 0.25, 14.5], "texture": "#0"}, + "west": {"uv": [0, 9, 0.25, 14.5], "texture": "#0"}, + "up": {"uv": [0, 9, 0.25, 9.5], "texture": "#0"}, + "down": {"uv": [0, 0, 1, 1], "texture": "#missing"} } }, { - "name": "detals", - "from": [13, 5, 1], - "to": [15, 15, 6], + "name": "exhaust", + "from": [15, 5, 15], + "to": [16, 16, 16], "faces": { - "north": {"uv": [8, 5, 9, 7.5], "texture": "#0"}, - "east": {"uv": [8, 7.5, 10.5, 10], "texture": "#0"}, - "up": {"uv": [10, 5, 9, 6.25], "texture": "#0"} + "north": {"uv": [0, 0, 1, 11], "texture": "#missing"}, + "east": {"uv": [1, 9, 1.25, 14.5], "texture": "#0"}, + "south": {"uv": [1, 9, 1.25, 14.5], "texture": "#0"}, + "west": {"uv": [1, 9, 1.25, 14.5], "texture": "#0"}, + "up": {"uv": [1, 9, 1.25, 9.5], "texture": "#0"}, + "down": {"uv": [0, 0, 1, 1], "texture": "#missing"} } }, { - "name": "detals", - "from": [1, 5, 1], - "to": [3, 15, 6], + "name": "exhaust", + "from": [12, 15, 15], + "to": [15, 16, 16], "faces": { - "north": {"uv": [9, 5, 8, 7.5], "texture": "#0"}, - "west": {"uv": [8, 7.5, 10.5, 10], "texture": "#0"}, - "up": {"uv": [9, 5, 10, 6.25], "texture": "#0"} + "north": {"uv": [0, 0, 3, 1], "texture": "#missing"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#missing"}, + "south": {"uv": [0.25, 9, 1, 9.5], "texture": "#0"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#missing"}, + "up": {"uv": [0.25, 9, 1, 9.5], "texture": "#0"}, + "down": {"uv": [0.25, 9, 1, 9.5], "texture": "#0"} } }, { - "name": "light", - "from": [1, 13, 2], - "to": [2, 14, 5], + "name": "exhaust", + "from": [11, 0, 15], + "to": [16, 5, 16], "faces": { - "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, - "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, - "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, - "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + "north": {"uv": [0, 0, 5, 5], "texture": "#missing"}, + "east": {"uv": [2.5, 13.5, 2.75, 16], "texture": "#0"}, + "south": {"uv": [1.25, 13.5, 2.5, 16], "texture": "#0"}, + "west": {"uv": [2.5, 13.5, 2.75, 16], "texture": "#0"}, + "up": {"uv": [1.25, 13.5, 2.5, 14], "texture": "#0"}, + "down": {"uv": [0, 0, 5, 1], "texture": "#missing"} } }, { - "name": "light", - "from": [1, 11, 2], - "to": [2, 12, 5], + "name": "details", + "from": [0, 6, 15], + "to": [11, 8, 16], "faces": { - "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, - "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, - "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, - "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + "north": {"uv": [0, 0, 11, 2], "texture": "#missing"}, + "east": {"uv": [0, 0, 1, 2], "texture": "#missing"}, + "south": {"uv": [8.25, 0, 11, 1], "texture": "#0"}, + "west": {"uv": [8.25, 0, 8.5, 1], "texture": "#0"}, + "up": {"uv": [8.75, 0, 11, 0.5], "texture": "#0"}, + "down": {"uv": [8.5, 0.5, 11, 1], "texture": "#0"} } }, { - "name": "light", - "from": [1, 9, 2], - "to": [2, 10, 5], + "name": "chamber", + "from": [1, 8, 0], + "to": [15, 9, 1], "faces": { - "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, - "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, - "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, - "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + "north": {"uv": [4, 13, 8, 13.5], "texture": "#0"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#missing"}, + "south": {"uv": [0, 0, 14, 1], "texture": "#missing"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#missing"}, + "up": {"uv": [4.25, 13, 7.75, 13.5], "texture": "#0"}, + "down": {"uv": [4.25, 9, 7.75, 9.5], "texture": "#0"} } }, { - "name": "light", - "from": [14, 9, 2], - "to": [15, 10, 5], + "name": "chamber", + "from": [1, 15, 0], + "to": [15, 16, 1], "faces": { - "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, - "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, - "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, - "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + "north": {"uv": [4.25, 9.5, 7.75, 10], "texture": "#0"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#missing"}, + "south": {"uv": [0, 0, 14, 1], "texture": "#missing"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#missing"}, + "up": {"uv": [4.25, 9, 7.75, 9.5], "texture": "#0"}, + "down": {"uv": [4.25, 9.5, 7.75, 10], "texture": "#0"} } }, { - "name": "light", - "from": [14, 13, 2], - "to": [15, 14, 5], + "name": "cylinder", + "from": [0, 1, 1], + "to": [16, 7, 7], "faces": { - "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, - "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, - "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, - "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + "north": {"uv": [0, 3, 4, 6], "texture": "#0"}, + "east": {"uv": [4.25, 0.5, 5.75, 3.5], "texture": "#0"}, + "south": {"uv": [0, 3, 4, 6], "texture": "#0"}, + "west": {"uv": [4.25, 0.5, 5.75, 3.5], "texture": "#0"}, + "up": {"uv": [0, 0, 4, 3], "texture": "#0"}, + "down": {"uv": [0, 6, 4, 9], "texture": "#0"} } }, { - "name": "light", - "from": [14, 11, 2], - "to": [15, 12, 5], + "name": "details", + "from": [13, 0, 0], + "to": [15, 8, 8], "faces": { - "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, - "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, - "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, - "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + "north": {"uv": [6, 0, 6.5, 4], "texture": "#0"}, + "east": {"uv": [4, 0, 6, 4], "texture": "#0"}, + "south": {"uv": [6, 0, 6.5, 4], "texture": "#0"}, + "west": {"uv": [4, 0, 6, 4], "texture": "#0"}, + "up": {"uv": [6, 0, 6.5, 4], "texture": "#0"}, + "down": {"uv": [6, 0, 6.5, 4], "texture": "#0"} } }, { - "name": "light", - "from": [5, 15, 2], - "to": [11, 16, 3], + "name": "details", + "from": [1, 0, 0], + "to": [3, 8, 8], "faces": { - "north": {"uv": [12.5, 1.5, 15.5, 1.75], "texture": "#0"}, - "east": {"uv": [15, 1.5, 15.5, 1.75], "texture": "#0"}, - "south": {"uv": [12.5, 1.5, 15.5, 1.75], "texture": "#0"}, - "west": {"uv": [12.5, 1.5, 13, 1.75], "texture": "#0"}, - "up": {"uv": [12.5, 1.5, 15.5, 1.75], "texture": "#0"} + "north": {"uv": [6, 0, 6.5, 4], "texture": "#0"}, + "east": {"uv": [4, 0, 6, 4], "texture": "#0"}, + "south": {"uv": [6, 0, 6.5, 4], "texture": "#0"}, + "west": {"uv": [4, 0, 6, 4], "texture": "#0"}, + "up": {"uv": [6, 0, 6.5, 4], "texture": "#0"}, + "down": {"uv": [6, 0, 6.5, 4], "texture": "#0"} + } + }, + { + "name": "pipe", + "from": [1, 8, 12], + "to": [5, 16, 16], + "faces": { + "north": {"uv": [9, 7.5, 10, 11.5], "texture": "#0"}, + "east": {"uv": [9, 7.5, 10, 11.5], "texture": "#0"}, + "south": {"uv": [9, 7.5, 10, 11.5], "texture": "#0"}, + "west": {"uv": [9, 7.5, 10, 11.5], "texture": "#0"}, + "up": {"uv": [10, 7.5, 11, 9.5], "texture": "#0"} + } + }, + { + "name": "pipe", + "from": [6, 8, 12], + "to": [10, 16, 16], + "faces": { + "north": {"uv": [9, 7.5, 10, 11.5], "texture": "#0"}, + "east": {"uv": [9, 7.5, 10, 11.5], "texture": "#0"}, + "south": {"uv": [9, 7.5, 10, 11.5], "texture": "#0"}, + "west": {"uv": [9, 7.5, 10, 11.5], "texture": "#0"}, + "up": {"uv": [10, 7.5, 11, 9.5], "texture": "#0"} + } + }, + { + "name": "body", + "from": [0, 0, 8], + "to": [16, 8, 15], + "faces": { + "north": {"uv": [8.25, 0, 12.25, 4], "texture": "#0"}, + "east": {"uv": [8.25, 0, 6.5, 4], "texture": "#0"}, + "south": {"uv": [8.25, 0, 12.25, 4], "texture": "#0"}, + "west": {"uv": [6.5, 0, 8.25, 4], "texture": "#0"}, + "up": {"uv": [0, 0, 16, 7], "texture": "#missing"}, + "down": {"uv": [8, 4, 12, 7.5], "texture": "#0"} + } + }, + { + "name": "body", + "from": [0, 8, 11], + "to": [11, 14, 15], + "faces": { + "north": {"uv": [0, 0, 11, 6], "texture": "#missing"}, + "east": {"uv": [0, 0, 4, 6], "texture": "#missing"}, + "south": {"uv": [13.25, 6, 16, 9], "texture": "#0"}, + "west": {"uv": [13.5, 0, 14.5, 3], "texture": "#0"}, + "up": {"uv": [13.25, 4, 16, 6], "texture": "#0"}, + "down": {"uv": [0, 0, 11, 4], "texture": "#missing"} + } + }, + { + "name": "details", + "from": [-0.5, 16.5, 1], + "to": [16.5, 16.5, 2], + "faces": { + "up": {"uv": [11.75, 15.5, 16, 16], "texture": "#0"}, + "down": {"uv": [11.75, 15.5, 16, 16], "texture": "#0"} + } + }, + { + "name": "details", + "from": [-0.5, 11.5, 1], + "to": [-0.5, 16.5, 2], + "faces": { + "east": {"uv": [14.75, 15, 16, 15.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [14.75, 15, 16, 15.5], "rotation": 90, "texture": "#0"} + } + }, + { + "name": "details", + "from": [-0.5, 11.5, 2], + "to": [-0.5, 12.5, 10], + "faces": { + "east": {"uv": [11.75, 15, 13.75, 15.5], "texture": "#0"}, + "west": {"uv": [11.75, 15, 13.75, 15.5], "texture": "#0"} + } + }, + { + "name": "details", + "from": [16.5, 11.5, 2], + "to": [16.5, 12.5, 10], + "faces": { + "east": {"uv": [11.75, 15, 13.75, 15.5], "texture": "#0"}, + "west": {"uv": [11.75, 15, 13.75, 15.5], "texture": "#0"} + } + }, + { + "name": "details", + "from": [16.5, 11.5, 1], + "to": [16.5, 16.5, 2], + "faces": { + "east": {"uv": [14.75, 15, 16, 15.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [14.75, 15, 16, 15.5], "rotation": 90, "texture": "#0"} + } + }, + { + "name": "details", + "from": [-1, 10, 6], + "to": [0, 14, 10], + "faces": { + "north": {"uv": [14.75, 0, 15, 2], "texture": "#0"}, + "east": {"uv": [15, 0, 16, 2], "texture": "#0"}, + "south": {"uv": [14.75, 0, 15, 2], "texture": "#0"}, + "west": {"uv": [15, 0, 16, 2], "texture": "#0"}, + "up": {"uv": [14.75, 0, 15, 2], "texture": "#0"}, + "down": {"uv": [14.75, 0, 15, 2], "texture": "#0"} + } + }, + { + "name": "details", + "from": [16, 10, 6], + "to": [17, 14, 10], + "faces": { + "north": {"uv": [14.75, 0, 15, 2], "texture": "#0"}, + "east": {"uv": [15, 0, 16, 2], "texture": "#0"}, + "south": {"uv": [14.75, 0, 15, 2], "texture": "#0"}, + "west": {"uv": [15, 0, 16, 2], "texture": "#0"}, + "up": {"uv": [14.75, 0, 15, 2], "texture": "#0"}, + "down": {"uv": [14.75, 0, 15, 2], "texture": "#0"} + } + }, + { + "name": "furnace_burn", + "from": [1, 9, 0.99], + "to": [15, 15, 0.99], + "faces": { + "north": {"uv": [4.25, 10, 7.75, 13], "texture": "#0"} } } - ] + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 225, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "scale": [0.5, 0.5, 0.5] + } + } } \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_idle.json b/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_idle.json index 6eac0cd04..4402744be 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_idle.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_idle.json @@ -1,245 +1,353 @@ { + "credit": "Made with Blockbench", "render_type": "translucent", + "texture_size": [64, 32], "textures": { "0": "overdrive_that_matters:block/electric_furnace_offline", "particle": "overdrive_that_matters:block/electric_furnace_offline" }, "elements": [ { - "name": "heatsink", - "from": [1, 10, 11], - "to": [15, 11, 15], + "name": "chamber", + "from": [15, 8, 0], + "to": [16, 16, 1], "faces": { - "east": {"uv": [7, 0.25, 9, 0.5], "texture": "#0"}, - "south": {"uv": [9, 0, 16, 0.25], "texture": "#0"}, - "west": {"uv": [7, 0, 9, 0.25], "texture": "#0"}, - "up": {"uv": [0, 0, 7, 1], "texture": "#0"}, - "down": {"uv": [0, 0, 7, 1], "rotation": 180, "texture": "#0"} - } - }, - { - "name": "heatsink", - "from": [1, 8, 11], - "to": [15, 9, 15], - "faces": { - "east": {"uv": [7, 0.25, 9, 0.5], "texture": "#0"}, - "south": {"uv": [9, 0, 16, 0.25], "texture": "#0"}, - "west": {"uv": [7, 0, 9, 0.25], "texture": "#0"}, - "up": {"uv": [0, 0, 7, 1], "texture": "#0"}, - "down": {"uv": [0, 0, 7, 1], "rotation": 180, "texture": "#0"} - } - }, - { - "name": "heatsink", - "from": [1, 6, 11], - "to": [15, 7, 15], - "faces": { - "east": {"uv": [7, 0.25, 9, 0.5], "texture": "#0"}, - "south": {"uv": [9, 0, 16, 0.25], "texture": "#0"}, - "west": {"uv": [7, 0, 9, 0.25], "texture": "#0"}, - "up": {"uv": [0, 0, 7, 1], "texture": "#0"}, - "down": {"uv": [0, 0, 7, 1], "rotation": 180, "texture": "#0"} - } - }, - { - "name": "base", - "from": [0, 0, 0], - "to": [16, 5, 16], - "faces": { - "north": {"uv": [0, 9.5, 8, 10.75], "texture": "#0"}, - "east": {"uv": [0, 10.75, 8, 12], "texture": "#0"}, - "south": {"uv": [0, 10.75, 8, 12], "texture": "#0"}, - "west": {"uv": [0, 10.75, 8, 12], "texture": "#0"}, - "up": {"uv": [0, 12, 8, 16], "texture": "#0"}, - "down": {"uv": [0, 12, 8, 16], "texture": "#0"} - } - }, - { - "name": "base", - "from": [0, 5, 6], - "to": [16, 16, 11], - "faces": { - "north": {"uv": [0, 3.5, 8, 6.25], "texture": "#0"}, - "east": {"uv": [13, 7.25, 10.5, 10], "texture": "#0"}, - "south": {"uv": [0, 12, 8, 14.75], "texture": "#0"}, - "west": {"uv": [10.5, 7.25, 13, 10], "texture": "#0"}, - "up": {"uv": [0, 2.25, 8, 3.5], "rotation": 180, "texture": "#0"} - } - }, - { - "name": "base", - "from": [0, 12, 11], - "to": [16, 16, 16], - "faces": { - "east": {"uv": [15.5, 7.25, 13, 8.25], "texture": "#0"}, - "south": {"uv": [0, 6.25, 8, 7.25], "texture": "#0"}, - "west": {"uv": [13, 7.25, 15.5, 8.25], "texture": "#0"}, - "up": {"uv": [0, 1, 8, 2.25], "rotation": 180, "texture": "#0"}, - "down": {"uv": [0, 12, 8, 13.25], "texture": "#0"} - } - }, - { - "name": "base", - "from": [2, 5, 11], - "to": [14, 12, 14], - "faces": { - "east": {"uv": [6, 7.75, 7.5, 9.5], "texture": "#0"}, - "south": {"uv": [1, 7.75, 7, 9.5], "texture": "#0"}, - "west": {"uv": [0, 7.75, 1.5, 9.5], "texture": "#0"} + "north": {"uv": [4, 9.5, 4.25, 13.5], "texture": "#0"}, + "east": {"uv": [3.75, 9.5, 4, 13.5], "texture": "#0"}, + "south": {"uv": [0, 0, 1, 8], "texture": "#missing"}, + "west": {"uv": [4, 9.5, 4.25, 13.5], "texture": "#0"}, + "up": {"uv": [4, 9, 4.25, 9.5], "texture": "#0"}, + "down": {"uv": [4, 9, 4.25, 9.5], "texture": "#0"} } }, { "name": "chamber", - "from": [3, 5, 0], - "to": [13, 16, 6], + "from": [0, 8, 0], + "to": [1, 16, 1], "faces": { - "north": {"uv": [8, 13.25, 13, 16], "texture": "#0"}, - "east": {"uv": [16, 13.25, 13, 16], "texture": "#0"}, - "west": {"uv": [13, 13.25, 16, 16], "texture": "#0"}, - "up": {"uv": [8, 11.75, 13, 13.25], "rotation": 180, "texture": "#0"} + "north": {"uv": [7.75, 9.5, 8, 13.5], "texture": "#0"}, + "east": {"uv": [7.75, 9.5, 8, 13.5], "texture": "#0"}, + "south": {"uv": [0, 0, 1, 8], "texture": "#missing"}, + "west": {"uv": [3.75, 9.5, 4, 13.5], "texture": "#0"}, + "up": {"uv": [7.75, 9, 8, 9.5], "texture": "#0"}, + "down": {"uv": [7.75, 9, 8, 9.5], "texture": "#0"} } }, { - "name": "smokething", - "from": [4, 16, 4], - "to": [12, 17, 12], + "name": "chamber", + "from": [0, 8, 1], + "to": [16, 16, 11], "faces": { - "north": {"uv": [8, 3, 12, 3.25], "texture": "#0"}, - "east": {"uv": [8, 3, 12, 3.25], "texture": "#0"}, - "south": {"uv": [8, 3, 12, 3.25], "texture": "#0"}, - "west": {"uv": [8, 3, 12, 3.25], "texture": "#0"}, - "up": {"uv": [8, 1, 12, 3], "texture": "#0"} + "north": {"uv": [4, 9.5, 8, 13.5], "texture": "#0"}, + "east": {"uv": [1.25, 9.5, 3.75, 13.5], "texture": "#0"}, + "south": {"uv": [4, 4, 8, 8], "texture": "#0"}, + "west": {"uv": [3.75, 9.5, 1.25, 13.5], "texture": "#0"}, + "up": {"uv": [4, 4, 8, 9], "rotation": 180, "texture": "#0"}, + "down": {"uv": [4, 4, 8, 9], "texture": "#0"} } }, { - "name": "net", - "from": [0.5, 5, 10.5], - "to": [15.5, 12, 15.5], + "name": "exhaust", + "from": [11, 8, 11], + "to": [16, 16, 15], "faces": { - "east": {"uv": [13, 8.25, 15.5, 10], "texture": "#0"}, - "south": {"uv": [8, 10, 15.5, 11.75], "texture": "#0"}, - "west": {"uv": [13, 8.25, 15.5, 10], "texture": "#0"} + "north": {"uv": [0, 0, 5, 8], "texture": "#missing"}, + "east": {"uv": [8, 7.5, 9, 11.5], "texture": "#0"}, + "south": {"uv": [12.25, 0, 13.5, 4], "texture": "#0"}, + "west": {"uv": [9, 7.5, 8, 11.5], "texture": "#0"}, + "up": {"uv": [2.75, 13.5, 4, 15.5], "texture": "#0"}, + "down": {"uv": [0, 0, 5, 4], "texture": "#missing"} } }, { - "name": "net", - "from": [15.5, 5, 10.5], - "to": [0.5, 12, 15.5], + "name": "exhaust", + "from": [11, 5, 15], + "to": [12, 16, 16], "faces": { - "east": {"uv": [13, 8.25, 15.5, 10], "texture": "#0"}, - "south": {"uv": [8, 10, 15.5, 11.75], "texture": "#0"}, - "west": {"uv": [13, 8.25, 15.5, 10], "texture": "#0"} + "north": {"uv": [0, 0, 1, 11], "texture": "#missing"}, + "east": {"uv": [0, 9, 0.25, 14.5], "texture": "#0"}, + "south": {"uv": [0, 9, 0.25, 14.5], "texture": "#0"}, + "west": {"uv": [0, 9, 0.25, 14.5], "texture": "#0"}, + "up": {"uv": [0, 9, 0.25, 9.5], "texture": "#0"}, + "down": {"uv": [0, 0, 1, 1], "texture": "#missing"} } }, { - "name": "detals", - "from": [13, 5, 1], - "to": [15, 15, 6], + "name": "exhaust", + "from": [15, 5, 15], + "to": [16, 16, 16], "faces": { - "north": {"uv": [8, 5, 9, 7.5], "texture": "#0"}, - "east": {"uv": [8, 7.5, 10.5, 10], "texture": "#0"}, - "up": {"uv": [10, 5, 9, 6.25], "texture": "#0"} + "north": {"uv": [0, 0, 1, 11], "texture": "#missing"}, + "east": {"uv": [1, 9, 1.25, 14.5], "texture": "#0"}, + "south": {"uv": [1, 9, 1.25, 14.5], "texture": "#0"}, + "west": {"uv": [1, 9, 1.25, 14.5], "texture": "#0"}, + "up": {"uv": [1, 9, 1.25, 9.5], "texture": "#0"}, + "down": {"uv": [0, 0, 1, 1], "texture": "#missing"} } }, { - "name": "detals", - "from": [1, 5, 1], - "to": [3, 15, 6], + "name": "exhaust", + "from": [12, 15, 15], + "to": [15, 16, 16], "faces": { - "north": {"uv": [9, 5, 8, 7.5], "texture": "#0"}, - "west": {"uv": [8, 7.5, 10.5, 10], "texture": "#0"}, - "up": {"uv": [9, 5, 10, 6.25], "texture": "#0"} + "north": {"uv": [0, 0, 3, 1], "texture": "#missing"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#missing"}, + "south": {"uv": [0.25, 9, 1, 9.5], "texture": "#0"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#missing"}, + "up": {"uv": [0.25, 9, 1, 9.5], "texture": "#0"}, + "down": {"uv": [0.25, 9, 1, 9.5], "texture": "#0"} } }, { - "name": "light", - "from": [1, 13, 2], - "to": [2, 14, 5], + "name": "exhaust", + "from": [11, 0, 15], + "to": [16, 5, 16], "faces": { - "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, - "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, - "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, - "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + "north": {"uv": [0, 0, 5, 5], "texture": "#missing"}, + "east": {"uv": [2.5, 13.5, 2.75, 16], "texture": "#0"}, + "south": {"uv": [1.25, 13.5, 2.5, 16], "texture": "#0"}, + "west": {"uv": [2.5, 13.5, 2.75, 16], "texture": "#0"}, + "up": {"uv": [1.25, 13.5, 2.5, 14], "texture": "#0"}, + "down": {"uv": [0, 0, 5, 1], "texture": "#missing"} } }, { - "name": "light", - "from": [1, 11, 2], - "to": [2, 12, 5], + "name": "details", + "from": [0, 6, 15], + "to": [11, 8, 16], "faces": { - "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, - "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, - "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, - "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + "north": {"uv": [0, 0, 11, 2], "texture": "#missing"}, + "east": {"uv": [0, 0, 1, 2], "texture": "#missing"}, + "south": {"uv": [8.25, 0, 11, 1], "texture": "#0"}, + "west": {"uv": [8.25, 0, 8.5, 1], "texture": "#0"}, + "up": {"uv": [8.75, 0, 11, 0.5], "texture": "#0"}, + "down": {"uv": [8.5, 0.5, 11, 1], "texture": "#0"} } }, { - "name": "light", - "from": [1, 9, 2], - "to": [2, 10, 5], + "name": "chamber", + "from": [1, 8, 0], + "to": [15, 9, 1], "faces": { - "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, - "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, - "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, - "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + "north": {"uv": [4, 13, 8, 13.5], "texture": "#0"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#missing"}, + "south": {"uv": [0, 0, 14, 1], "texture": "#missing"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#missing"}, + "up": {"uv": [4.25, 13, 7.75, 13.5], "texture": "#0"}, + "down": {"uv": [4.25, 9, 7.75, 9.5], "texture": "#0"} } }, { - "name": "light", - "from": [14, 9, 2], - "to": [15, 10, 5], + "name": "chamber", + "from": [1, 15, 0], + "to": [15, 16, 1], "faces": { - "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, - "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, - "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, - "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + "north": {"uv": [4.25, 9.5, 7.75, 10], "texture": "#0"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#missing"}, + "south": {"uv": [0, 0, 14, 1], "texture": "#missing"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#missing"}, + "up": {"uv": [4.25, 9, 7.75, 9.5], "texture": "#0"}, + "down": {"uv": [4.25, 9.5, 7.75, 10], "texture": "#0"} } }, { - "name": "light", - "from": [14, 13, 2], - "to": [15, 14, 5], + "name": "cylinder", + "from": [0, 1, 1], + "to": [16, 7, 7], "faces": { - "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, - "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, - "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, - "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + "north": {"uv": [0, 3, 4, 6], "texture": "#0"}, + "east": {"uv": [4.25, 0.5, 5.75, 3.5], "texture": "#0"}, + "south": {"uv": [0, 3, 4, 6], "texture": "#0"}, + "west": {"uv": [4.25, 0.5, 5.75, 3.5], "texture": "#0"}, + "up": {"uv": [0, 0, 4, 3], "texture": "#0"}, + "down": {"uv": [0, 6, 4, 9], "texture": "#0"} } }, { - "name": "light", - "from": [14, 11, 2], - "to": [15, 12, 5], + "name": "details", + "from": [13, 0, 0], + "to": [15, 8, 8], "faces": { - "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, - "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, - "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, - "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} + "north": {"uv": [6, 0, 6.5, 4], "texture": "#0"}, + "east": {"uv": [4, 0, 6, 4], "texture": "#0"}, + "south": {"uv": [6, 0, 6.5, 4], "texture": "#0"}, + "west": {"uv": [4, 0, 6, 4], "texture": "#0"}, + "up": {"uv": [6, 0, 6.5, 4], "texture": "#0"}, + "down": {"uv": [6, 0, 6.5, 4], "texture": "#0"} } }, { - "name": "light", - "from": [5, 15, 2], - "to": [11, 16, 3], + "name": "details", + "from": [1, 0, 0], + "to": [3, 8, 8], "faces": { - "north": {"uv": [12.5, 1.5, 15.5, 1.75], "texture": "#0"}, - "east": {"uv": [15, 1.5, 15.5, 1.75], "texture": "#0"}, - "south": {"uv": [12.5, 1.5, 15.5, 1.75], "texture": "#0"}, - "west": {"uv": [12.5, 1.5, 13, 1.75], "texture": "#0"}, - "up": {"uv": [12.5, 1.5, 15.5, 1.75], "texture": "#0"} + "north": {"uv": [6, 0, 6.5, 4], "texture": "#0"}, + "east": {"uv": [4, 0, 6, 4], "texture": "#0"}, + "south": {"uv": [6, 0, 6.5, 4], "texture": "#0"}, + "west": {"uv": [4, 0, 6, 4], "texture": "#0"}, + "up": {"uv": [6, 0, 6.5, 4], "texture": "#0"}, + "down": {"uv": [6, 0, 6.5, 4], "texture": "#0"} + } + }, + { + "name": "pipe", + "from": [1, 8, 12], + "to": [5, 16, 16], + "faces": { + "north": {"uv": [9, 7.5, 10, 11.5], "texture": "#0"}, + "east": {"uv": [9, 7.5, 10, 11.5], "texture": "#0"}, + "south": {"uv": [9, 7.5, 10, 11.5], "texture": "#0"}, + "west": {"uv": [9, 7.5, 10, 11.5], "texture": "#0"}, + "up": {"uv": [10, 7.5, 11, 9.5], "texture": "#0"} + } + }, + { + "name": "pipe", + "from": [6, 8, 12], + "to": [10, 16, 16], + "faces": { + "north": {"uv": [9, 7.5, 10, 11.5], "texture": "#0"}, + "east": {"uv": [9, 7.5, 10, 11.5], "texture": "#0"}, + "south": {"uv": [9, 7.5, 10, 11.5], "texture": "#0"}, + "west": {"uv": [9, 7.5, 10, 11.5], "texture": "#0"}, + "up": {"uv": [10, 7.5, 11, 9.5], "texture": "#0"} + } + }, + { + "name": "body", + "from": [0, 0, 8], + "to": [16, 8, 15], + "faces": { + "north": {"uv": [8.25, 0, 12.25, 4], "texture": "#0"}, + "east": {"uv": [8.25, 0, 6.5, 4], "texture": "#0"}, + "south": {"uv": [8.25, 0, 12.25, 4], "texture": "#0"}, + "west": {"uv": [6.5, 0, 8.25, 4], "texture": "#0"}, + "up": {"uv": [0, 0, 16, 7], "texture": "#missing"}, + "down": {"uv": [8, 4, 12, 7.5], "texture": "#0"} + } + }, + { + "name": "body", + "from": [0, 8, 11], + "to": [11, 14, 15], + "faces": { + "north": {"uv": [0, 0, 11, 6], "texture": "#missing"}, + "east": {"uv": [0, 0, 4, 6], "texture": "#missing"}, + "south": {"uv": [13.25, 6, 16, 9], "texture": "#0"}, + "west": {"uv": [13.5, 0, 14.5, 3], "texture": "#0"}, + "up": {"uv": [13.25, 4, 16, 6], "texture": "#0"}, + "down": {"uv": [0, 0, 11, 4], "texture": "#missing"} + } + }, + { + "name": "details", + "from": [-0.5, 16.5, 1], + "to": [16.5, 16.5, 2], + "faces": { + "up": {"uv": [11.75, 15.5, 16, 16], "texture": "#0"}, + "down": {"uv": [11.75, 15.5, 16, 16], "texture": "#0"} + } + }, + { + "name": "details", + "from": [-0.5, 11.5, 1], + "to": [-0.5, 16.5, 2], + "faces": { + "east": {"uv": [14.75, 15, 16, 15.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [14.75, 15, 16, 15.5], "rotation": 90, "texture": "#0"} + } + }, + { + "name": "details", + "from": [-0.5, 11.5, 2], + "to": [-0.5, 12.5, 10], + "faces": { + "east": {"uv": [11.75, 15, 13.75, 15.5], "texture": "#0"}, + "west": {"uv": [11.75, 15, 13.75, 15.5], "texture": "#0"} + } + }, + { + "name": "details", + "from": [16.5, 11.5, 2], + "to": [16.5, 12.5, 10], + "faces": { + "east": {"uv": [11.75, 15, 13.75, 15.5], "texture": "#0"}, + "west": {"uv": [11.75, 15, 13.75, 15.5], "texture": "#0"} + } + }, + { + "name": "details", + "from": [16.5, 11.5, 1], + "to": [16.5, 16.5, 2], + "faces": { + "east": {"uv": [14.75, 15, 16, 15.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [14.75, 15, 16, 15.5], "rotation": 90, "texture": "#0"} + } + }, + { + "name": "details", + "from": [-1, 10, 6], + "to": [0, 14, 10], + "faces": { + "north": {"uv": [14.75, 0, 15, 2], "texture": "#0"}, + "east": {"uv": [15, 0, 16, 2], "texture": "#0"}, + "south": {"uv": [14.75, 0, 15, 2], "texture": "#0"}, + "west": {"uv": [15, 0, 16, 2], "texture": "#0"}, + "up": {"uv": [14.75, 0, 15, 2], "texture": "#0"}, + "down": {"uv": [14.75, 0, 15, 2], "texture": "#0"} + } + }, + { + "name": "details", + "from": [16, 10, 6], + "to": [17, 14, 10], + "faces": { + "north": {"uv": [14.75, 0, 15, 2], "texture": "#0"}, + "east": {"uv": [15, 0, 16, 2], "texture": "#0"}, + "south": {"uv": [14.75, 0, 15, 2], "texture": "#0"}, + "west": {"uv": [15, 0, 16, 2], "texture": "#0"}, + "up": {"uv": [14.75, 0, 15, 2], "texture": "#0"}, + "down": {"uv": [14.75, 0, 15, 2], "texture": "#0"} + } + }, + { + "name": "furnace_burn", + "from": [1, 9, 0.99], + "to": [15, 15, 0.99], + "faces": { + "north": {"uv": [4.25, 10, 7.75, 13], "texture": "#0"} } } - ] + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 225, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "scale": [0.5, 0.5, 0.5] + } + } } \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_working.json b/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_working.json index 1e8beef7b..6b1b04b40 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_working.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_working.json @@ -1,253 +1,321 @@ { + "credit": "Made with Blockbench", "render_type": "translucent", + "texture_size": [64, 32], "textures": { "0": "overdrive_that_matters:block/electric_furnace", "particle": "overdrive_that_matters:block/electric_furnace" }, "elements": [ { - "name": "heatsink", - "from": [1, 10, 11], - "to": [15, 11, 15], + "name": "chamber", + "from": [15, 8, 0], + "to": [16, 16, 1], "faces": { - "east": {"uv": [7, 0.25, 9, 0.5], "texture": "#0"}, - "south": {"uv": [9, 0, 16, 0.25], "texture": "#0"}, - "west": {"uv": [7, 0, 9, 0.25], "texture": "#0"}, - "up": {"uv": [0, 0, 7, 1], "texture": "#0"}, - "down": {"uv": [0, 0, 7, 1], "rotation": 180, "texture": "#0"} - }, - "forge_data": { "block_light": 15, "sky_light": 15 } - }, - { - "name": "heatsink", - "from": [1, 8, 11], - "to": [15, 9, 15], - "faces": { - "east": {"uv": [7, 0.25, 9, 0.5], "texture": "#0"}, - "south": {"uv": [9, 0, 16, 0.25], "texture": "#0"}, - "west": {"uv": [7, 0, 9, 0.25], "texture": "#0"}, - "up": {"uv": [0, 0, 7, 1], "texture": "#0"}, - "down": {"uv": [0, 0, 7, 1], "rotation": 180, "texture": "#0"} - }, - "forge_data": { "block_light": 15, "sky_light": 15 } - }, - { - "name": "heatsink", - "from": [1, 6, 11], - "to": [15, 7, 15], - "faces": { - "east": {"uv": [7, 0.25, 9, 0.5], "texture": "#0"}, - "south": {"uv": [9, 0, 16, 0.25], "texture": "#0"}, - "west": {"uv": [7, 0, 9, 0.25], "texture": "#0"}, - "up": {"uv": [0, 0, 7, 1], "texture": "#0"}, - "down": {"uv": [0, 0, 7, 1], "rotation": 180, "texture": "#0"} - }, - "forge_data": { "block_light": 15, "sky_light": 15 } - }, - { - "name": "base", - "from": [0, 0, 0], - "to": [16, 5, 16], - "faces": { - "north": {"uv": [0, 9.5, 8, 10.75], "texture": "#0"}, - "east": {"uv": [0, 10.75, 8, 12], "texture": "#0"}, - "south": {"uv": [0, 10.75, 8, 12], "texture": "#0"}, - "west": {"uv": [0, 10.75, 8, 12], "texture": "#0"}, - "up": {"uv": [0, 12, 8, 16], "texture": "#0"}, - "down": {"uv": [0, 12, 8, 16], "texture": "#0"} - } - }, - { - "name": "base", - "from": [0, 5, 6], - "to": [16, 16, 11], - "faces": { - "north": {"uv": [0, 3.5, 8, 6.25], "texture": "#0"}, - "east": {"uv": [13, 7.25, 10.5, 10], "texture": "#0"}, - "south": {"uv": [0, 12, 8, 14.75], "texture": "#0"}, - "west": {"uv": [10.5, 7.25, 13, 10], "texture": "#0"}, - "up": {"uv": [0, 2.25, 8, 3.5], "rotation": 180, "texture": "#0"} - } - }, - { - "name": "base", - "from": [0, 12, 11], - "to": [16, 16, 16], - "faces": { - "east": {"uv": [15.5, 7.25, 13, 8.25], "texture": "#0"}, - "south": {"uv": [0, 6.25, 8, 7.25], "texture": "#0"}, - "west": {"uv": [13, 7.25, 15.5, 8.25], "texture": "#0"}, - "up": {"uv": [0, 1, 8, 2.25], "rotation": 180, "texture": "#0"}, - "down": {"uv": [0, 12, 8, 13.25], "texture": "#0"} - } - }, - { - "name": "base", - "from": [2, 5, 11], - "to": [14, 12, 14], - "faces": { - "east": {"uv": [6, 7.75, 7.5, 9.5], "texture": "#0"}, - "south": {"uv": [1, 7.75, 7, 9.5], "texture": "#0"}, - "west": {"uv": [0, 7.75, 1.5, 9.5], "texture": "#0"} + "north": {"uv": [4, 9.5, 4.25, 13.5], "texture": "#0"}, + "east": {"uv": [3.75, 9.5, 4, 13.5], "texture": "#0"}, + "south": {"uv": [0, 0, 1, 8], "texture": "#missing"}, + "west": {"uv": [4, 9.5, 4.25, 13.5], "texture": "#0"}, + "up": {"uv": [4, 9, 4.25, 9.5], "texture": "#0"}, + "down": {"uv": [4, 9, 4.25, 9.5], "texture": "#0"} } }, { "name": "chamber", - "from": [3, 5, 0], - "to": [13, 16, 6], + "from": [0, 8, 0], + "to": [1, 16, 1], "faces": { - "north": {"uv": [8, 13.25, 13, 16], "texture": "#0"}, - "east": {"uv": [16, 13.25, 13, 16], "texture": "#0"}, - "west": {"uv": [13, 13.25, 16, 16], "texture": "#0"}, - "up": {"uv": [8, 11.75, 13, 13.25], "rotation": 180, "texture": "#0"} + "north": {"uv": [7.75, 9.5, 8, 13.5], "texture": "#0"}, + "east": {"uv": [7.75, 9.5, 8, 13.5], "texture": "#0"}, + "south": {"uv": [0, 0, 1, 8], "texture": "#missing"}, + "west": {"uv": [3.75, 9.5, 4, 13.5], "texture": "#0"}, + "up": {"uv": [7.75, 9, 8, 9.5], "texture": "#0"}, + "down": {"uv": [7.75, 9, 8, 9.5], "texture": "#0"} } }, { - "name": "smokething", - "from": [4, 16, 4], - "to": [12, 17, 12], + "name": "chamber", + "from": [0, 8, 1], + "to": [16, 16, 11], "faces": { - "north": {"uv": [8, 3, 12, 3.25], "texture": "#0"}, - "east": {"uv": [8, 3, 12, 3.25], "texture": "#0"}, - "south": {"uv": [8, 3, 12, 3.25], "texture": "#0"}, - "west": {"uv": [8, 3, 12, 3.25], "texture": "#0"}, - "up": {"uv": [8, 1, 12, 3], "texture": "#0"} + "north": {"uv": [4, 9.5, 8, 13.5], "texture": "#0"}, + "east": {"uv": [1.25, 9.5, 3.75, 13.5], "texture": "#0"}, + "south": {"uv": [4, 4, 8, 8], "texture": "#0"}, + "west": {"uv": [3.75, 9.5, 1.25, 13.5], "texture": "#0"}, + "up": {"uv": [4, 4, 8, 9], "rotation": 180, "texture": "#0"}, + "down": {"uv": [4, 4, 8, 9], "texture": "#0"} } }, { - "name": "net", - "from": [0.5, 5, 10.5], - "to": [15.5, 12, 15.5], + "name": "exhaust", + "from": [11, 8, 11], + "to": [16, 16, 15], "faces": { - "east": {"uv": [13, 8.25, 15.5, 10], "texture": "#0"}, - "south": {"uv": [8, 10, 15.5, 11.75], "texture": "#0"}, - "west": {"uv": [13, 8.25, 15.5, 10], "texture": "#0"} + "north": {"uv": [0, 0, 5, 8], "texture": "#missing"}, + "east": {"uv": [8, 7.5, 9, 11.5], "texture": "#0"}, + "south": {"uv": [12.25, 0, 13.5, 4], "texture": "#0"}, + "west": {"uv": [9, 7.5, 8, 11.5], "texture": "#0"}, + "up": {"uv": [2.75, 13.5, 4, 15.5], "texture": "#0"}, + "down": {"uv": [0, 0, 5, 4], "texture": "#missing"} } }, { - "name": "net", - "from": [15.5, 5, 10.5], - "to": [0.5, 12, 15.5], + "name": "exhaust", + "from": [11, 5, 15], + "to": [12, 16, 16], "faces": { - "east": {"uv": [13, 8.25, 15.5, 10], "texture": "#0"}, - "south": {"uv": [8, 10, 15.5, 11.75], "texture": "#0"}, - "west": {"uv": [13, 8.25, 15.5, 10], "texture": "#0"} + "north": {"uv": [0, 0, 1, 11], "texture": "#missing"}, + "east": {"uv": [0, 9, 0.25, 14.5], "texture": "#0"}, + "south": {"uv": [0, 9, 0.25, 14.5], "texture": "#0"}, + "west": {"uv": [0, 9, 0.25, 14.5], "texture": "#0"}, + "up": {"uv": [0, 9, 0.25, 9.5], "texture": "#0"}, + "down": {"uv": [0, 0, 1, 1], "texture": "#missing"} } }, { - "name": "detals", - "from": [13, 5, 1], - "to": [15, 15, 6], + "name": "exhaust", + "from": [15, 5, 15], + "to": [16, 16, 16], "faces": { - "north": {"uv": [8, 5, 9, 7.5], "texture": "#0"}, - "east": {"uv": [8, 7.5, 10.5, 10], "texture": "#0"}, - "up": {"uv": [10, 5, 9, 6.25], "texture": "#0"} + "north": {"uv": [0, 0, 1, 11], "texture": "#missing"}, + "east": {"uv": [1, 9, 1.25, 14.5], "texture": "#0"}, + "south": {"uv": [1, 9, 1.25, 14.5], "texture": "#0"}, + "west": {"uv": [1, 9, 1.25, 14.5], "texture": "#0"}, + "up": {"uv": [1, 9, 1.25, 9.5], "texture": "#0"}, + "down": {"uv": [0, 0, 1, 1], "texture": "#missing"} } }, { - "name": "detals", - "from": [1, 5, 1], - "to": [3, 15, 6], + "name": "exhaust", + "from": [12, 15, 15], + "to": [15, 16, 16], "faces": { - "north": {"uv": [9, 5, 8, 7.5], "texture": "#0"}, - "west": {"uv": [8, 7.5, 10.5, 10], "texture": "#0"}, - "up": {"uv": [9, 5, 10, 6.25], "texture": "#0"} + "north": {"uv": [0, 0, 3, 1], "texture": "#missing"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#missing"}, + "south": {"uv": [0.25, 9, 1, 9.5], "texture": "#0"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#missing"}, + "up": {"uv": [0.25, 9, 1, 9.5], "texture": "#0"}, + "down": {"uv": [0.25, 9, 1, 9.5], "texture": "#0"} } }, { - "name": "light", - "from": [1, 13, 2], - "to": [2, 14, 5], + "name": "exhaust", + "from": [11, 0, 15], + "to": [16, 5, 16], "faces": { - "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, - "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, - "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, - "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} - }, - "forge_data": { "block_light": 15, "sky_light": 15 } + "north": {"uv": [0, 0, 5, 5], "texture": "#missing"}, + "east": {"uv": [2.5, 13.5, 2.75, 16], "texture": "#0"}, + "south": {"uv": [1.25, 13.5, 2.5, 16], "texture": "#0"}, + "west": {"uv": [2.5, 13.5, 2.75, 16], "texture": "#0"}, + "up": {"uv": [1.25, 13.5, 2.5, 14], "texture": "#0"}, + "down": {"uv": [0, 0, 5, 1], "texture": "#missing"} + } }, { - "name": "light", - "from": [1, 11, 2], - "to": [2, 12, 5], + "name": "details", + "from": [0, 6, 15], + "to": [11, 8, 16], "faces": { - "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, - "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, - "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, - "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} - }, - "forge_data": { "block_light": 15, "sky_light": 15 } + "north": {"uv": [0, 0, 11, 2], "texture": "#missing"}, + "east": {"uv": [0, 0, 1, 2], "texture": "#missing"}, + "south": {"uv": [8.25, 0, 11, 1], "texture": "#0"}, + "west": {"uv": [8.25, 0, 8.5, 1], "texture": "#0"}, + "up": {"uv": [8.75, 0, 11, 0.5], "texture": "#0"}, + "down": {"uv": [8.5, 0.5, 11, 1], "texture": "#0"} + } }, { - "name": "light", - "from": [1, 9, 2], - "to": [2, 10, 5], + "name": "chamber", + "from": [1, 8, 0], + "to": [15, 9, 1], "faces": { - "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, - "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, - "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, - "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} - }, - "forge_data": { "block_light": 15, "sky_light": 15 } + "north": {"uv": [4, 13, 8, 13.5], "texture": "#0"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#missing"}, + "south": {"uv": [0, 0, 14, 1], "texture": "#missing"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#missing"}, + "up": {"uv": [4.25, 13, 7.75, 13.5], "texture": "#0"}, + "down": {"uv": [4.25, 9, 7.75, 9.5], "texture": "#0"} + } }, { - "name": "light", - "from": [14, 9, 2], - "to": [15, 10, 5], + "name": "chamber", + "from": [1, 15, 0], + "to": [15, 16, 1], "faces": { - "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, - "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, - "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, - "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} - }, - "forge_data": { "block_light": 15, "sky_light": 15 } + "north": {"uv": [4.25, 9.5, 7.75, 10], "texture": "#0"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#missing"}, + "south": {"uv": [0, 0, 14, 1], "texture": "#missing"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#missing"}, + "up": {"uv": [4.25, 9, 7.75, 9.5], "texture": "#0"}, + "down": {"uv": [4.25, 9.5, 7.75, 10], "texture": "#0"} + } }, { - "name": "light", - "from": [14, 13, 2], - "to": [15, 14, 5], + "name": "cylinder", + "from": [0, 1, 1], + "to": [16, 7, 7], "faces": { - "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, - "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, - "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, - "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} - }, - "forge_data": { "block_light": 15, "sky_light": 15 } + "north": {"uv": [0, 3, 4, 6], "texture": "#0"}, + "east": {"uv": [4.25, 0.5, 5.75, 3.5], "texture": "#0"}, + "south": {"uv": [0, 3, 4, 6], "texture": "#0"}, + "west": {"uv": [4.25, 0.5, 5.75, 3.5], "texture": "#0"}, + "up": {"uv": [0, 0, 4, 3], "texture": "#0"}, + "down": {"uv": [0, 6, 4, 9], "texture": "#0"} + } }, { - "name": "light", - "from": [14, 11, 2], - "to": [15, 12, 5], + "name": "details", + "from": [13, 0, 0], + "to": [15, 8, 8], "faces": { - "north": {"uv": [12.5, 1, 13, 1.25], "texture": "#0"}, - "east": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "south": {"uv": [13.5, 1, 14, 1.25], "texture": "#0"}, - "west": {"uv": [12.5, 1, 14, 1.25], "texture": "#0"}, - "up": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"}, - "down": {"uv": [12.5, 1, 14, 1.25], "rotation": 90, "texture": "#0"} - }, - "forge_data": { "block_light": 15, "sky_light": 15 } + "north": {"uv": [6, 0, 6.5, 4], "texture": "#0"}, + "east": {"uv": [4, 0, 6, 4], "texture": "#0"}, + "south": {"uv": [6, 0, 6.5, 4], "texture": "#0"}, + "west": {"uv": [4, 0, 6, 4], "texture": "#0"}, + "up": {"uv": [6, 0, 6.5, 4], "texture": "#0"}, + "down": {"uv": [6, 0, 6.5, 4], "texture": "#0"} + } }, { - "name": "light", - "from": [5, 15, 2], - "to": [11, 16, 3], + "name": "details", + "from": [1, 0, 0], + "to": [3, 8, 8], "faces": { - "north": {"uv": [12.5, 1.5, 15.5, 1.75], "texture": "#0"}, - "east": {"uv": [15, 1.5, 15.5, 1.75], "texture": "#0"}, - "south": {"uv": [12.5, 1.5, 15.5, 1.75], "texture": "#0"}, - "west": {"uv": [12.5, 1.5, 13, 1.75], "texture": "#0"}, - "up": {"uv": [12.5, 1.5, 15.5, 1.75], "texture": "#0"} + "north": {"uv": [6, 0, 6.5, 4], "texture": "#0"}, + "east": {"uv": [4, 0, 6, 4], "texture": "#0"}, + "south": {"uv": [6, 0, 6.5, 4], "texture": "#0"}, + "west": {"uv": [4, 0, 6, 4], "texture": "#0"}, + "up": {"uv": [6, 0, 6.5, 4], "texture": "#0"}, + "down": {"uv": [6, 0, 6.5, 4], "texture": "#0"} + } + }, + { + "name": "pipe", + "from": [1, 8, 12], + "to": [5, 16, 16], + "faces": { + "north": {"uv": [9, 7.5, 10, 11.5], "texture": "#0"}, + "east": {"uv": [9, 7.5, 10, 11.5], "texture": "#0"}, + "south": {"uv": [9, 7.5, 10, 11.5], "texture": "#0"}, + "west": {"uv": [9, 7.5, 10, 11.5], "texture": "#0"}, + "up": {"uv": [10, 7.5, 11, 9.5], "texture": "#0"} + } + }, + { + "name": "pipe", + "from": [6, 8, 12], + "to": [10, 16, 16], + "faces": { + "north": {"uv": [9, 7.5, 10, 11.5], "texture": "#0"}, + "east": {"uv": [9, 7.5, 10, 11.5], "texture": "#0"}, + "south": {"uv": [9, 7.5, 10, 11.5], "texture": "#0"}, + "west": {"uv": [9, 7.5, 10, 11.5], "texture": "#0"}, + "up": {"uv": [10, 7.5, 11, 9.5], "texture": "#0"} + } + }, + { + "name": "body", + "from": [0, 0, 8], + "to": [16, 8, 15], + "faces": { + "north": {"uv": [8.25, 0, 12.25, 4], "texture": "#0"}, + "east": {"uv": [8.25, 0, 6.5, 4], "texture": "#0"}, + "south": {"uv": [8.25, 0, 12.25, 4], "texture": "#0"}, + "west": {"uv": [6.5, 0, 8.25, 4], "texture": "#0"}, + "up": {"uv": [0, 0, 16, 7], "texture": "#missing"}, + "down": {"uv": [8, 4, 12, 7.5], "texture": "#0"} + } + }, + { + "name": "body", + "from": [0, 8, 11], + "to": [11, 14, 15], + "faces": { + "north": {"uv": [0, 0, 11, 6], "texture": "#missing"}, + "east": {"uv": [0, 0, 4, 6], "texture": "#missing"}, + "south": {"uv": [13.25, 6, 16, 9], "texture": "#0"}, + "west": {"uv": [13.5, 0, 14.5, 3], "texture": "#0"}, + "up": {"uv": [13.25, 4, 16, 6], "texture": "#0"}, + "down": {"uv": [0, 0, 11, 4], "texture": "#missing"} + } + }, + { + "name": "details", + "from": [-0.5, 16.5, 1], + "to": [16.5, 16.5, 2], + "faces": { + "up": {"uv": [11.75, 15.5, 16, 16], "texture": "#0"}, + "down": {"uv": [11.75, 15.5, 16, 16], "texture": "#0"} + } + }, + { + "name": "details", + "from": [-0.5, 11.5, 1], + "to": [-0.5, 16.5, 2], + "faces": { + "east": {"uv": [14.75, 15, 16, 15.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [14.75, 15, 16, 15.5], "rotation": 90, "texture": "#0"} + } + }, + { + "name": "details", + "from": [-0.5, 11.5, 2], + "to": [-0.5, 12.5, 10], + "faces": { + "east": {"uv": [11.75, 15, 13.75, 15.5], "texture": "#0"}, + "west": {"uv": [11.75, 15, 13.75, 15.5], "texture": "#0"} + } + }, + { + "name": "details", + "from": [16.5, 11.5, 2], + "to": [16.5, 12.5, 10], + "faces": { + "east": {"uv": [11.75, 15, 13.75, 15.5], "texture": "#0"}, + "west": {"uv": [11.75, 15, 13.75, 15.5], "texture": "#0"} + } + }, + { + "name": "details", + "from": [16.5, 11.5, 1], + "to": [16.5, 16.5, 2], + "faces": { + "east": {"uv": [14.75, 15, 16, 15.5], "rotation": 90, "texture": "#0"}, + "west": {"uv": [14.75, 15, 16, 15.5], "rotation": 90, "texture": "#0"} + } + }, + { + "name": "details", + "from": [-1, 10, 6], + "to": [0, 14, 10], + "faces": { + "north": {"uv": [14.75, 0, 15, 2], "texture": "#0"}, + "east": {"uv": [15, 0, 16, 2], "texture": "#0"}, + "south": {"uv": [14.75, 0, 15, 2], "texture": "#0"}, + "west": {"uv": [15, 0, 16, 2], "texture": "#0"}, + "up": {"uv": [14.75, 0, 15, 2], "texture": "#0"}, + "down": {"uv": [14.75, 0, 15, 2], "texture": "#0"} + } + }, + { + "name": "details", + "from": [16, 10, 6], + "to": [17, 14, 10], + "faces": { + "north": {"uv": [14.75, 0, 15, 2], "texture": "#0"}, + "east": {"uv": [15, 0, 16, 2], "texture": "#0"}, + "south": {"uv": [14.75, 0, 15, 2], "texture": "#0"}, + "west": {"uv": [15, 0, 16, 2], "texture": "#0"}, + "up": {"uv": [14.75, 0, 15, 2], "texture": "#0"}, + "down": {"uv": [14.75, 0, 15, 2], "texture": "#0"} + } + }, + { + "name": "furnace_burn", + "from": [1, 9, 0.99], + "to": [15, 15, 0.99], + "faces": { + "north": {"uv": [4.25, 10, 7.75, 13], "texture": "#0"} }, "forge_data": { "block_light": 15, "sky_light": 15 } } diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/electric_furnace.png b/src/main/resources/assets/overdrive_that_matters/textures/block/electric_furnace.png index b488e27a0992e0278390a313d23c2fbae0ca6a36..8f380ea7cfa6911297aac73ff0112ac6bc51efe5 100644 GIT binary patch delta 641 zcmV-{0)G9}2Gj*1iBL{Q4GJ0x0000DNk~Le0000$0000W2m=5B0F^_IwvizvRkuDq zH8nM!H8mzCCR9{Z3JVJ>EiW7%AQl!DD=RBtU|@1`a%OpiZGw+~e}9K9E&p#E#OfYSmvIEjs82;nDCPHsg&bUk?lXnd3cJ-I3zY)nCPEe}GJ zGBP_5YJY*2r_dq?7VsB!0Ja4f8@+-!&|sz(n4pn(zychkiA3VSq5%i#Ga2-A$_2=$ zlj)PpC_0iTo`F$05P`nWC}<%-k-a#F#>0RJAcZ59gFYc}BK0ERgjpcYtOzU+0gc}f z7@Qj>(6>iV>^i6fBmr~P93UD=cu(M*7gbh)IDe1DDp&%U6$j@<<@Z7UYllIC8GAaj zl7r%ZU&B24)XJPE$Y5NxeAiR^Z8oTti!gc9SGdz)y(?>;(#|(#L*A* z_WP&<{s!51LvO!NBQ16;cCDz$^*>MnpHTQ)w(CF-Cp}ki&Jd{pe~Im|*@1=@2Ll@X bpfk`f$=Gfr%i~9{00000NkvXXu0mjfzB~`h delta 770 zcmV+d1O5Ee1=I#1iBL{Q4GJ0x0000DNk~Le0000W0000$2m=5B08CJYoRJ|VRn9Lj za&mHi ze}5DR2_q5_C=(PjA|mSQ>c+HJ|Ns90001BDe@~H{K7RsbNkl~e^56uX9t0SCe*l>Ufpa#xV>MF_ zvx)OQgcu?TA$Xrs>N*_Wx7$qxx$lRe-0x)=`ab*ARnR4w4qPaGE-EOwFCj5rt2ofa zh5Im$_E^;cl8hYCsAI5LhJ{7AAn7tb!@lB$DE=U8jdl1ehfgaB&iF70ENFl=ODr z;5Yc@2Z%vvCB5Ar@R#7ob8(=+`xu#mvp8E=9U=viQ5`s$9;7+g#^^3e@0G zLw_u#*v)sYfiMO7FiqHQT+Xw$b)F>(xWyQGBaQPl+G7RcYbTfx=l$?%TLF{T`KI;V z2e$eR)KGOg2=%y^B4}~lz5^)o^{U&?V{KDp53ov{v&elMMe-v8IXf3AiV1>AwNfOj zV5eB5bp)^iI3!6--ux9Y}~;NXBU1!eH>KO8Ki{3u9BA&n1Piqk6e?X@`^8@1@$ zs|k*+o=1IqwG_Hp3O8$6^zGFgj@xZDSc-A{2OzU@vUEvFlK=n!07*qoM6N<$f`*$@ ACIA2c diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/electric_furnace_offline.png b/src/main/resources/assets/overdrive_that_matters/textures/block/electric_furnace_offline.png index d3cd1ae1e5d43fd3fe5f30016dc3d6a4b702bae3..7085ec5a9c664161869704889843fc6f2fe9766b 100644 GIT binary patch delta 652 zcmdnOHlJ0oGr-TCmrII^fq{Y7)59eQNIL+r0tYjYoa)@SZK9$=y=8z;i0gJcJ5y8B zd8VdnYHA@NAza+t+PeBOatdN%V%pl;2?+^BMMY_qExAqo_4W1by1K`C0r8Z7yKUsFl?&5!vU1$EbxddW?awR>8# z0*_0thvJ2+W&i&tmw)=udF|a%=ZljPIXYt9uax`wUukV!sCq1;*ZtH_bJb;6xFU>M z^mJcNJk@ZDbw!As;0sBArq7?*ZORWE49>L)^4i~-y-=9(DzA({!pBJNFJJN=KS<(Q z^|~@()3lja8!vHvF=~~w{LrBMj3K6;o8#VZmePcSPTCs|7*`%(;)zO4D}8X$p()3Q z@om&AwkMNIeyuS+bwoRj#G73_jKl~J~-Cer+z@+16wJMleh1m16vR(q>2-XFuTaOpFj*{e@UHq8}TQ{8QSp@N}NBD2`> z!QX!x8%hnZwex%U;(z~K$t0O1ROkL&;2sZLyg31vHv%?4UjWUFfOEEcK?|n1c@xh25Mqc#2*LZ5(lp`r z$vG>b%=5C;=d&)$JQtrPSn`y_9dMz}r7EG8xrRi0&JqCt;km3UF1anwe;@%6!UB*m z!ys7K*DpeS(OvPnq%gQpE`+&+QDi}ih8GB}Oasakg^C4b4g`NCcyIe1B(zS(@RLxM z(t#AV-vNzhO&Ol&pIqoCGjCx055UC!$4pa$up-&`ZzhFK;{RK0HI5w2Khh23s+l{ z;C+ltK`(j>T7*b~WYh?BW(-|g1RH$Uz#v@r2#wIa7^babtA^mC$j=Z z@F`Cik&J4}34L!ccmn4m69haS4m0eB{yOM72~d2P|4Ha(!E|)|B=`#f*w@wZt$N}Y z;T8dV3drEke?%~o;-7?s6w>%`rWmTwx7Qir-l#+0UY&4n^}g!ctEbRmDLAa-(6?8Q ga38m6uoUb17eM(~!eU^uHvj+t07*qoM6N<$g4T*^g8%>k diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/induction_furnace.png b/src/main/resources/assets/overdrive_that_matters/textures/block/induction_furnace.png new file mode 100644 index 0000000000000000000000000000000000000000..3eb4d807db38369161a2f7ff1b3b12113d350c2b GIT binary patch literal 906 zcmeAS@N?(olHy`uVBq!ia0vp^3P9|@!3-pQ0$S$)DaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(ehe2?0JKuK$&k{wpdzR#w*5)(!~?Nk~XAH8oXJQ~UqGGd92KSxxxCD6_Q6 zmfWU(F)^{*w{QQM)l^heR9|0zY)iNZ2d5=BkDG{alBj5XwQDFREwXdYrN5#3o+DXV>|j6&;)|zWBl0 z#)hNUr5(H-56sxI>#&ws;SFC2!R)!EEnCBmRL6_#*t2inKBa|gR_)^R6@ImAmDfjC zZjrd{%*WbR@k|srr4@0$;`XoWt?Tp@OiHgmTs?i)MlFU;6$hu*hDEQ}&F6S{>aF1Q z*e;gj)3OV--rh{<6wzL%uqIV)flsMK;NmmFj^9`&ZkgwJ=$2=?z0j#$XB@h=%wwFK z&ocX(@stKN#SZV-U0dcQ%5eTzQlHK$P@;W!$4{4zlRsH+thmF>B-i0n@FHYQ%hKp- zH3tPDuKV}%-nnd;eTesl$d;gl&ksC4b9^VHh!j85IN8Kda z7+Y-gUSx{;Y*f1_(q1?>&P+97dftJ4;l|L4gVmQO8F%3DS5p zpQT^qR>kh67NLUv>wO>ISfM&EZe~Hw*UjC_!~F!?MGq$GdfV*Xbg1yoNoTK%rS**N XjCFRW-+S)^rc(w_S3j3^P6f8Y^gPYlnn{BqSu5nwqMqsfme+#pYK%s|io5Y{_lv zzkU1mpIJ>sMMd@X^~bh^zk2oR|Ns9$Gv4R%`vNJ^k|4iepa=$F(7svw3aEgyz$3Dl zfr0M;2s36~>*Qo$U`q6KaSZYB?hWCdwAz4&dp3WgL*#<*_OB=Bs0Un{S=)3;;PfZ{ zg1j9E|NeRKP>1m{I7~t;K})$mAt)`P*-4Yo{F|b&cMRTCD42lsG%r{;SET^$p}uj*k6vC|UD&kcF?Z2OmeF z;I~@#g}vNWL9EVK6oeibu6vg%%(UkSqq%Hjs7n9$6iuI(Z=VRV8u1_aES|vb%+a$d z&f@hfmiNgi990*i14NZLrGi9W`0&QgYU17Z)Io6FY$sI{{Zm&;b(Y>ZeEqqD0n4uq zxf14i{m!?mWRh4dlHTkQJoZ!O?N+8ob;>y#K3Cqjt)Z~#JOA42FGTwTJw+q$Ha3Xl z?q_UCyZ+I(LFKz`ynX+zZ71Xwc&(ZF++0pXGmjc zeX{nf%eRwj8U$-jDZ8mGmMUI!h%tucoVyxF!IkHyUOwG3&&?rDoKbRq=t99+kp}a4 z<2nDiF(^Fw5xVz7?}vbde@wbh>qX8i`7wEdfRmK`I)PZxUtf2L%^q^)LRUSz#d-H_D#^Qy_z Date: Fri, 21 Jul 2023 20:47:43 +0700 Subject: [PATCH 0807/1199] Add jei catalysts for new furnaces --- src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt index 39e0a3e06..d764f12df 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt @@ -65,6 +65,9 @@ class JEIPlugin : IModPlugin { override fun registerRecipeCatalysts(registration: IRecipeCatalystRegistration) { registration.addRecipeCatalyst(ItemStack(MItems.CHEMICAL_GENERATOR), RecipeTypes.FUELING) + registration.addRecipeCatalyst(ItemStack(MItems.POWERED_FURNACE), RecipeTypes.SMELTING) + registration.addRecipeCatalyst(ItemStack(MItems.POWERED_BLAST_FURNACE), RecipeTypes.BLASTING) + registration.addRecipeCatalyst(ItemStack(MItems.POWERED_SMOKER), RecipeTypes.SMOKING) registration.addRecipeCatalyst(ItemStack(MItems.PLATE_PRESS), PlatePressRecipeCategory.recipeType) } From 93696261e41b008f1bd012f13425fb51c7e02c08 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 21 Jul 2023 21:11:11 +0700 Subject: [PATCH 0808/1199] Prevent cargo crate dupe --- .../mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt index 35b893734..636a47b1c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt @@ -43,6 +43,7 @@ class CargoCrateBlockEntity( val container = MatteryContainer(this::setChanged, CAPACITY).also(::addDroppableContainer) private var interactingPlayers = 0 + val handler = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { return lootTable == null @@ -67,7 +68,7 @@ class CargoCrateBlockEntity( fun onPlayerOpen() { val level = level - if (interactingPlayers++ == 0 && level != null) { + if (interactingPlayers++ == 0 && level != null && !isRemoved && level.getBlockState(blockPos).block is CargoCrateBlock) { level.setBlock(blockPos, blockState.setValue(CargoCrateBlock.IS_OPEN, true), Block.UPDATE_CLIENTS) level.playSound(null, blockPos, MSoundEvents.CARGO_CRATE_OPEN, SoundSource.BLOCKS, 1f, 0.8f + level.random.nextFloat() * 0.2f) level.gameEvent(GameEvent.CONTAINER_OPEN, blockPos, GameEvent.Context.of(blockState)) @@ -77,7 +78,7 @@ class CargoCrateBlockEntity( fun onPlayerClose() { val level = level - if (--interactingPlayers == 0 && level != null) { + if (--interactingPlayers == 0 && level != null && !isRemoved && level.getBlockState(blockPos).block is CargoCrateBlock) { level.setBlock(blockPos, blockState.setValue(CargoCrateBlock.IS_OPEN, false), Block.UPDATE_CLIENTS) level.gameEvent(GameEvent.CONTAINER_CLOSE, blockPos, GameEvent.Context.of(blockState)) } From ca32929f3ca13a92c7d8cd3352579773a3c100fb Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 21 Jul 2023 21:31:49 +0700 Subject: [PATCH 0809/1199] New furnaces shapes --- .../mc/otm/block/tech/PoweredFurnaceBlock.kt | 28 ++++++++++++++++++- .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 7 +++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt index 9888fbda3..747014792 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.block.tech import net.minecraft.core.BlockPos import net.minecraft.world.item.crafting.AbstractCookingRecipe import net.minecraft.world.item.crafting.RecipeType +import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.EntityBlock @@ -11,12 +12,23 @@ import net.minecraft.world.level.block.entity.BlockEntityTicker import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition +import net.minecraft.world.phys.shapes.CollisionContext +import net.minecraft.world.phys.shapes.Shapes +import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.entity.tech.PoweredFurnaceBlockEntity +import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.config.WorkerBalanceValues +import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.shapes.BlockShape -class PoweredFurnaceBlock(val type: () -> BlockEntityType, val recipeType: RecipeType, val config: WorkerBalanceValues) : RotatableMatteryBlock(), EntityBlock { +class PoweredFurnaceBlock( + val type: () -> BlockEntityType, + val recipeType: RecipeType, + val config: WorkerBalanceValues, + shape: BlockShape? +) : RotatableMatteryBlock(), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): PoweredFurnaceBlockEntity { return PoweredFurnaceBlockEntity(type.invoke(), p_153215_, p_153216_, recipeType, config) } @@ -26,6 +38,20 @@ class PoweredFurnaceBlock(val type: () -> BlockEntityType getTicker(p_153212_: Level, p_153213_: BlockState, p_153214_: BlockEntityType): BlockEntityTicker? { if (p_153212_.isClientSide) return null 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 813a504a3..7dc016d49 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -65,6 +65,7 @@ import ru.dbotthepony.mc.otm.block.tech.PoweredFurnaceBlock import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.collect.SupplierList +import ru.dbotthepony.mc.otm.shapes.BlockShapes object MBlocks { private val registry = DeferredRegister.create(ForgeRegistries.BLOCKS, OverdriveThatMatters.MOD_ID) @@ -88,9 +89,9 @@ object MBlocks { val CHEMICAL_GENERATOR: Block by registry.register(MNames.CHEMICAL_GENERATOR) { ChemicalGeneratorBlock() } val PLATE_PRESS: Block by registry.register(MNames.PLATE_PRESS) { PlatePressBlock() } val TWIN_PLATE_PRESS: Block by registry.register(MNames.TWIN_PLATE_PRESS) { PlatePressBlock(isTwin = true) } - val POWERED_FURNACE: PoweredFurnaceBlock by registry.register(MNames.POWERED_FURNACE) { PoweredFurnaceBlock(MBlockEntities::POWERED_FURNACE, RecipeType.SMELTING, MachinesConfig.POWERED_FURNACE) } - val POWERED_BLAST_FURNACE: PoweredFurnaceBlock by registry.register(MNames.POWERED_BLAST_FURNACE) { PoweredFurnaceBlock(MBlockEntities::POWERED_BLAST_FURNACE, RecipeType.BLASTING, MachinesConfig.POWERED_BLAST_FURNACE) } - val POWERED_SMOKER: PoweredFurnaceBlock by registry.register(MNames.POWERED_SMOKER) { PoweredFurnaceBlock(MBlockEntities::POWERED_SMOKER, RecipeType.SMOKING, MachinesConfig.POWERED_SMOKER) } + val POWERED_FURNACE: PoweredFurnaceBlock by registry.register(MNames.POWERED_FURNACE) { PoweredFurnaceBlock(MBlockEntities::POWERED_FURNACE, RecipeType.SMELTING, MachinesConfig.POWERED_FURNACE, BlockShapes.POWERED_FURNACE) } + val POWERED_BLAST_FURNACE: PoweredFurnaceBlock by registry.register(MNames.POWERED_BLAST_FURNACE) { PoweredFurnaceBlock(MBlockEntities::POWERED_BLAST_FURNACE, RecipeType.BLASTING, MachinesConfig.POWERED_BLAST_FURNACE, BlockShapes.POWERED_BLAST_FURNACE) } + val POWERED_SMOKER: PoweredFurnaceBlock by registry.register(MNames.POWERED_SMOKER) { PoweredFurnaceBlock(MBlockEntities::POWERED_SMOKER, RecipeType.SMOKING, MachinesConfig.POWERED_SMOKER, null) } val MATTER_RECYCLER: Block by registry.register(MNames.MATTER_RECYCLER) { MatterRecyclerBlock() } val ENERGY_SERVO: Block by registry.register(MNames.ENERGY_SERVO) { EnergyServoBlock() } val COBBLESTONE_GENERATOR: Block by registry.register(MNames.COBBLESTONE_GENERATOR) { CobblerBlock() } From b2e50a6c1b878f14d70840f8bafd0e0e82cc0b33 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 21 Jul 2023 21:40:15 +0700 Subject: [PATCH 0810/1199] Fix mekanism energy getting above potential IMatteryEnergyStorage --- .../ru/dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 f3fb2360e..b7a3bcc7b 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 @@ -49,6 +49,7 @@ import ru.dbotthepony.mc.otm.core.collect.SupplierList import ru.dbotthepony.mc.otm.core.collect.WeakHashSet import ru.dbotthepony.mc.otm.core.forValidRefs import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.RelativeSide @@ -273,7 +274,9 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } override fun get(): LazyOptional { - return actualMekanism ?: regular.get() + val get = regular.get() + get.ifPresentK { if (it is IMatteryEnergyStorage) return get } + return actualMekanism ?: get } } } From 1ff20b090f0b84aa97178452eeb9bad3ac29b765 Mon Sep 17 00:00:00 2001 From: GearShocky Date: Sat, 22 Jul 2023 05:47:43 +0600 Subject: [PATCH 0811/1199] *Collapses* --- .../mc/otm/datagen/items/ItemModels.kt | 6 + .../models/block/android_station_idle.json | 93 +++---- .../models/block/android_station_working.json | 107 ++++---- .../models/block/matter_replicator_error.json | 5 +- .../models/block/matter_replicator_idle.json | 5 +- .../block/matter_replicator_working.json | 258 ++++++++++-------- .../textures/block/android_station.png | Bin 544 -> 291 bytes .../textures/block/android_station_base.png | Bin 0 -> 410 bytes .../block/android_station_offline.png | Bin 530 -> 276 bytes .../textures/block/matter_replicator.png | Bin 758 -> 496 bytes .../textures/block/matter_replicator_base.png | Bin 0 -> 459 bytes .../block/matter_replicator_halted.png | Bin 753 -> 494 bytes .../block/matter_replicator_offline.png | Bin 742 -> 480 bytes .../textures/item/battery_procedural.png | Bin 0 -> 262 bytes 14 files changed, 241 insertions(+), 233 deletions(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/android_station_base.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/block/matter_replicator_base.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/battery_procedural.png diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index 1dab2caeb..cfd8b083c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -92,6 +92,7 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.generatedTiered(MItems.BATTERIES, "battery_tier") provider.generated(MItems.BATTERY_CREATIVE) + provider.generated(MItems.PROCEDURAL_BATTERY, modLocation("item/battery_procedural")) provider.generated(MItems.MATTER_CAPACITOR_BASIC, modLocation("item/matter_capacitor_tier1")) provider.generated(MItems.MATTER_CAPACITOR_NORMAL, modLocation("item/matter_capacitor_tier2")) @@ -114,6 +115,11 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.generated(MItems.CreativeUpgrades.PROCESSING_ITEMS, modLocation("item/upgrade_processing")) + provider.generated(MItems.CreativeUpgrades.MATTER_STORAGE, modLocation("item/upgrade_matter")) + provider.generated(MItems.CreativeUpgrades.MATTER_STORAGE_FLAT, modLocation("item/upgrade_matter")) + provider.generated(MItems.CreativeUpgrades.MATTER_STORAGE_FLAT_SMALL, modLocation("item/upgrade_matter")) + + provider.generated(MItems.QUANTUM_BATTERY) provider.generated(MItems.QUANTUM_CAPACITOR) provider.generated(MItems.QUANTUM_BATTERY_CREATIVE) diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/android_station_idle.json b/src/main/resources/assets/overdrive_that_matters/models/block/android_station_idle.json index ff09df1fa..233ecf9eb 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/android_station_idle.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/android_station_idle.json @@ -1,8 +1,11 @@ -{ +{ + "credit": "Made with Blockbench", "parent": "block/cube_all", - "render_type": "translucent", + "render_type": "translucent", + "texture_size": [32, 32], "textures": { "0": "overdrive_that_matters:block/android_station_offline", + "1": "overdrive_that_matters:block/android_station_base", "particle": "overdrive_that_matters:block/android_station_offline" }, "elements": [ @@ -11,12 +14,12 @@ "from": [0, 7, 0], "to": [16, 9, 16], "faces": { - "north": {"uv": [8, 4, 16, 4.5], "texture": "#0"}, - "east": {"uv": [0, 4, 8, 4.5], "texture": "#0"}, - "south": {"uv": [8, 4, 16, 4.5], "texture": "#0"}, - "west": {"uv": [0, 4, 8, 4.5], "texture": "#0"}, - "up": {"uv": [8, 0, 16, 4], "texture": "#0"}, - "down": {"uv": [8, 4.5, 16, 8.5], "texture": "#0"} + "north": {"uv": [8, 0, 16, 1], "texture": "#1"}, + "east": {"uv": [0, 0, 8, 1], "texture": "#1"}, + "south": {"uv": [8, 0, 16, 1], "texture": "#1"}, + "west": {"uv": [0, 0, 8, 1], "texture": "#1"}, + "up": {"uv": [8, 0, 16, 16], "texture": "#0"}, + "down": {"uv": [8, 8, 16, 16], "texture": "#1"} } }, { @@ -24,12 +27,12 @@ "from": [0, 0, 0], "to": [16, 4, 16], "faces": { - "north": {"uv": [0, 8.5, 8, 9.5], "texture": "#0"}, - "east": {"uv": [0, 8.5, 8, 9.5], "texture": "#0"}, - "south": {"uv": [8, 8.5, 16, 9.5], "texture": "#0"}, - "west": {"uv": [8, 8.5, 16, 9.5], "texture": "#0"}, - "up": {"uv": [8, 4.5, 16, 8.5], "texture": "#0"}, - "down": {"uv": [8, 9.5, 16, 13.5], "texture": "#0"} + "north": {"uv": [8, 1, 16, 3], "texture": "#1"}, + "east": {"uv": [0, 1, 8, 3], "texture": "#1"}, + "south": {"uv": [8, 1, 16, 3], "texture": "#1"}, + "west": {"uv": [0, 1, 8, 3], "texture": "#1"}, + "up": {"uv": [8, 8, 16, 16], "texture": "#1"}, + "down": {"uv": [0, 8, 8, 16], "texture": "#1"} } }, { @@ -37,12 +40,10 @@ "from": [2, 4, 2], "to": [14, 7, 14], "faces": { - "north": {"uv": [1, 0, 7, 0.75], "texture": "#0"}, - "east": {"uv": [1, 0, 7, 0.75], "texture": "#0"}, - "south": {"uv": [1, 0, 7, 0.75], "texture": "#0"}, - "west": {"uv": [1, 0, 7, 0.75], "texture": "#0"}, - "up": {"uv": [9, 5, 15, 8], "texture": "#0"}, - "down": {"uv": [9, 5, 15, 8], "texture": "#0"} + "north": {"uv": [1, 0, 7, 3], "texture": "#0"}, + "east": {"uv": [1, 0, 7, 3], "texture": "#0"}, + "south": {"uv": [1, 0, 7, 3], "texture": "#0"}, + "west": {"uv": [1, 0, 7, 3], "texture": "#0"} } }, { @@ -50,25 +51,10 @@ "from": [1, 4, 13], "to": [3, 7, 15], "faces": { - "north": {"uv": [7, 0, 8, 0.75], "texture": "#0"}, - "east": {"uv": [0, 0, 1, 0.75], "texture": "#0"}, - "south": {"uv": [7, 0, 8, 0.75], "texture": "#0"}, - "west": {"uv": [0, 0, 1, 0.75], "texture": "#0"}, - "up": {"uv": [0, 0, 1, 0.58182], "texture": "#0"}, - "down": {"uv": [0, 0, 1, 0.58182], "texture": "#0"} - } - }, - { - "name": "frame", - "from": [13, 4, 13], - "to": [15, 7, 15], - "faces": { - "north": {"uv": [0, 0, 1, 0.75], "texture": "#0"}, - "east": {"uv": [7, 0, 8, 0.75], "texture": "#0"}, - "south": {"uv": [0, 0, 1, 0.75], "texture": "#0"}, - "west": {"uv": [0, 0, 1, 0.75], "texture": "#0"}, - "up": {"uv": [0, 0, 1, 0.58182], "texture": "#0"}, - "down": {"uv": [0, 0, 1, 0.58182], "texture": "#0"} + "north": {"uv": [7, 0, 8, 3], "texture": "#0"}, + "east": {"uv": [0, 0, 1, 3], "texture": "#0"}, + "south": {"uv": [7, 0, 8, 3], "texture": "#0"}, + "west": {"uv": [0, 0, 1, 3], "texture": "#0"} } }, { @@ -76,12 +62,21 @@ "from": [13, 4, 1], "to": [15, 7, 3], "faces": { - "north": {"uv": [7, 0, 8, 0.75], "texture": "#0"}, - "east": {"uv": [0, 0, 1, 0.75], "texture": "#0"}, - "south": {"uv": [7, 0, 8, 0.75], "texture": "#0"}, - "west": {"uv": [0, 0, 1, 0.75], "texture": "#0"}, - "up": {"uv": [0, 0, 1, 0.58182], "texture": "#0"}, - "down": {"uv": [0, 0, 1, 0.58182], "texture": "#0"} + "north": {"uv": [7, 0, 8, 3], "texture": "#0"}, + "east": {"uv": [0, 0, 1, 3], "texture": "#0"}, + "south": {"uv": [7, 0, 8, 3], "texture": "#0"}, + "west": {"uv": [0, 0, 1, 3], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [13, 4, 13], + "to": [15, 7, 15], + "faces": { + "north": {"uv": [0, 0, 1, 3], "texture": "#0"}, + "east": {"uv": [7, 0, 8, 3], "texture": "#0"}, + "south": {"uv": [0, 0, 1, 0.75], "texture": "#0"}, + "west": {"uv": [0, 0, 1, 3], "texture": "#0"} } }, { @@ -89,12 +84,10 @@ "from": [1, 4, 1], "to": [3, 7, 3], "faces": { - "north": {"uv": [0, 0, 1, 0.75], "texture": "#0"}, - "east": {"uv": [0, 0, 1, 0.75], "texture": "#0"}, + "north": {"uv": [0, 0, 1, 3], "texture": "#0"}, + "east": {"uv": [7, 0, 8, 3], "texture": "#0"}, "south": {"uv": [0, 0, 1, 0.75], "texture": "#0"}, - "west": {"uv": [7, 0, 8, 0.75], "texture": "#0"}, - "up": {"uv": [0, 0, 1, 0.58182], "texture": "#0"}, - "down": {"uv": [0, 0, 1, 0.58182], "texture": "#0"} + "west": {"uv": [0, 0, 1, 3], "texture": "#0"} } } ], diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/android_station_working.json b/src/main/resources/assets/overdrive_that_matters/models/block/android_station_working.json index 200020ecc..a261046ba 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/android_station_working.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/android_station_working.json @@ -1,11 +1,11 @@ { - "credit": "Made with Blockbench", "parent": "block/cube_all", "render_type": "translucent", "texture_size": [16, 32], "textures": { "0": "overdrive_that_matters:block/android_station", "1": "overdrive_that_matters:block/android_station_em", + "2": "overdrive_that_matters:block/android_station_base", "particle": "overdrive_that_matters:block/android_station" }, "elements": [ @@ -14,12 +14,12 @@ "from": [0, 7, 0], "to": [16, 9, 16], "faces": { - "north": {"uv": [8, 4, 16, 4.5], "texture": "#0"}, - "east": {"uv": [0, 4, 8, 4.5], "texture": "#0"}, - "south": {"uv": [8, 4, 16, 4.5], "texture": "#0"}, - "west": {"uv": [0, 4, 8, 4.5], "texture": "#0"}, - "up": {"uv": [8, 0, 16, 4], "texture": "#0"}, - "down": {"uv": [8, 4.5, 16, 8.5], "texture": "#0"} + "north": {"uv": [8, 0, 16, 1], "texture": "#2"}, + "east": {"uv": [0, 0, 8, 1], "texture": "#2"}, + "south": {"uv": [8, 0, 16, 1], "texture": "#2"}, + "west": {"uv": [0, 0, 8, 1], "texture": "#2"}, + "up": {"uv": [8, 0, 16, 16], "texture": "#0"}, + "down": {"uv": [8, 8, 16, 16], "texture": "#2"} } }, { @@ -41,12 +41,12 @@ "from": [0, 0, 0], "to": [16, 4, 16], "faces": { - "north": {"uv": [0, 8.5, 8, 9.5], "texture": "#0"}, - "east": {"uv": [0, 8.5, 8, 9.5], "texture": "#0"}, - "south": {"uv": [8, 8.5, 16, 9.5], "texture": "#0"}, - "west": {"uv": [8, 8.5, 16, 9.5], "texture": "#0"}, - "up": {"uv": [8, 4.5, 16, 8.5], "texture": "#0"}, - "down": {"uv": [8, 9.5, 16, 13.5], "texture": "#0"} + "north": {"uv": [8, 1, 16, 3], "texture": "#2"}, + "east": {"uv": [0, 1, 8, 3], "texture": "#2"}, + "south": {"uv": [8, 1, 16, 3], "texture": "#2"}, + "west": {"uv": [0, 1, 8, 3], "texture": "#2"}, + "up": {"uv": [8, 8, 16, 16], "texture": "#2"}, + "down": {"uv": [0, 8, 8, 16], "texture": "#2"} } }, { @@ -54,12 +54,10 @@ "from": [2, 4, 2], "to": [14, 7, 14], "faces": { - "north": {"uv": [1, 0, 7, 0.75], "texture": "#0"}, - "east": {"uv": [1, 0, 7, 0.75], "texture": "#0"}, - "south": {"uv": [1, 0, 7, 0.75], "texture": "#0"}, - "west": {"uv": [1, 0, 7, 0.75], "texture": "#0"}, - "up": {"uv": [9, 5, 15, 8], "texture": "#0"}, - "down": {"uv": [9, 5, 15, 8], "texture": "#0"} + "north": {"uv": [1, 0, 7, 3], "texture": "#0"}, + "east": {"uv": [1, 0, 7, 3], "texture": "#0"}, + "south": {"uv": [1, 0, 7, 3], "texture": "#0"}, + "west": {"uv": [1, 0, 7, 3], "texture": "#0"} } }, { @@ -76,43 +74,15 @@ }, "forge_data": { "block_light": 15, "sky_light": 15 } }, - { - "name": "frame", - "from": [1, 4, 13], - "to": [3, 7, 15], - "faces": { - "north": {"uv": [7, 0, 8, 0.75], "texture": "#0"}, - "east": {"uv": [0, 0, 1, 0.75], "texture": "#0"}, - "south": {"uv": [7, 0, 8, 0.75], "texture": "#0"}, - "west": {"uv": [0, 0, 1, 0.75], "texture": "#0"}, - "up": {"uv": [0, 0, 1, 0.58182], "texture": "#0"}, - "down": {"uv": [0, 0, 1, 0.58182], "texture": "#0"} - } - }, { "name": "frame", "from": [13, 4, 13], "to": [15, 7, 15], "faces": { - "north": {"uv": [0, 0, 1, 0.75], "texture": "#0"}, - "east": {"uv": [7, 0, 8, 0.75], "texture": "#0"}, - "south": {"uv": [0, 0, 1, 0.75], "texture": "#0"}, - "west": {"uv": [0, 0, 1, 0.75], "texture": "#0"}, - "up": {"uv": [0, 0, 1, 0.58182], "texture": "#0"}, - "down": {"uv": [0, 0, 1, 0.58182], "texture": "#0"} - } - }, - { - "name": "frame", - "from": [13, 4, 1], - "to": [15, 7, 3], - "faces": { - "north": {"uv": [7, 0, 8, 0.75], "texture": "#0"}, - "east": {"uv": [0, 0, 1, 0.75], "texture": "#0"}, - "south": {"uv": [7, 0, 8, 0.75], "texture": "#0"}, - "west": {"uv": [0, 0, 1, 0.75], "texture": "#0"}, - "up": {"uv": [0, 0, 1, 0.58182], "texture": "#0"}, - "down": {"uv": [0, 0, 1, 0.58182], "texture": "#0"} + "north": {"uv": [0, 0, 1, 3], "texture": "#0"}, + "east": {"uv": [7, 0, 8, 3], "texture": "#0"}, + "south": {"uv": [0, 0, 1, 3], "texture": "#0"}, + "west": {"uv": [0, 0, 1, 3], "texture": "#0"} } }, { @@ -120,12 +90,32 @@ "from": [1, 4, 1], "to": [3, 7, 3], "faces": { - "north": {"uv": [0, 0, 1, 0.75], "texture": "#0"}, - "east": {"uv": [0, 0, 1, 0.75], "texture": "#0"}, - "south": {"uv": [0, 0, 1, 0.75], "texture": "#0"}, - "west": {"uv": [7, 0, 8, 0.75], "texture": "#0"}, - "up": {"uv": [0, 0, 1, 0.58182], "texture": "#0"}, - "down": {"uv": [0, 0, 1, 0.58182], "texture": "#0"} + "north": {"uv": [0, 0, 1, 3], "texture": "#0"}, + "east": {"uv": [7, 0, 8, 3], "texture": "#0"}, + "south": {"uv": [0, 0, 1, 3], "texture": "#0"}, + "west": {"uv": [0, 0, 1, 3], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [1, 4, 13], + "to": [3, 7, 15], + "faces": { + "north": {"uv": [7, 0, 8, 3], "texture": "#0"}, + "east": {"uv": [0, 0, 1, 3], "texture": "#0"}, + "south": {"uv": [7, 0, 8, 3], "texture": "#0"}, + "west": {"uv": [0, 0, 1, 3], "texture": "#0"} + } + }, + { + "name": "frame", + "from": [13, 4, 1], + "to": [15, 7, 3], + "faces": { + "north": {"uv": [7, 0, 8, 3], "texture": "#0"}, + "east": {"uv": [0, 0, 1, 3], "texture": "#0"}, + "south": {"uv": [7, 0, 8, 3], "texture": "#0"}, + "west": {"uv": [0, 0, 1, 3], "texture": "#0"} } }, { @@ -167,8 +157,7 @@ "faces": { "north": {"uv": [5.5, 7.25, 2.5, 8.25], "texture": "#1"}, "south": {"uv": [2.5, 7.25, 5.5, 8.25], "texture": "#1"} - }, - "forge_data": { "block_light": 15, "sky_light": 15 } + } } ], "display": { diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/matter_replicator_error.json b/src/main/resources/assets/overdrive_that_matters/models/block/matter_replicator_error.json index 5b894ac93..676bb08aa 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/matter_replicator_error.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/matter_replicator_error.json @@ -1,8 +1,9 @@ { "parent": "overdrive_that_matters:block/matter_replicator_working", - "texture_size": [32, 64], + "texture_size": [32, 32], "textures": { - "particle": "overdrive_that_matters:block/matter_replicator_halted", + "1": "overdrive_that_matters:block/matter_replicator_base", + "particle": "overdrive_that_matters:block/matter_replicator_base", "texture": "overdrive_that_matters:block/matter_replicator_halted" } } \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/matter_replicator_idle.json b/src/main/resources/assets/overdrive_that_matters/models/block/matter_replicator_idle.json index 06f1f7254..dc7a117ad 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/matter_replicator_idle.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/matter_replicator_idle.json @@ -1,8 +1,9 @@ { "parent": "overdrive_that_matters:block/matter_replicator_working", - "texture_size": [32, 64], + "texture_size": [32, 32], "textures": { - "particle": "overdrive_that_matters:block/matter_replicator_offline", + "1": "overdrive_that_matters:block/matter_replicator_base", + "particle": "overdrive_that_matters:block/matter_replicator_base", "texture": "overdrive_that_matters:block/matter_replicator_offline" } } \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/matter_replicator_working.json b/src/main/resources/assets/overdrive_that_matters/models/block/matter_replicator_working.json index 9fe9f3dfd..db7a07bee 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/matter_replicator_working.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/matter_replicator_working.json @@ -1,9 +1,11 @@ { "credit": "Made with Blockbench", "parent": "block/block", - "texture_size": [16, 32], + "render_type": "translucent", + "texture_size": [32, 32], "textures": { - "particle": "overdrive_that_matters:block/matter_replicator", + "1": "overdrive_that_matters:block/matter_replicator_base", + "particle": "overdrive_that_matters:block/matter_replicator_base", "texture": "overdrive_that_matters:block/matter_replicator" }, "elements": [ @@ -12,12 +14,12 @@ "from": [15, 0, 0], "to": [16, 11, 16], "faces": { - "north": {"uv": [0, 1.25, 0.5, 4], "texture": "#texture"}, - "east": {"uv": [0, 5.25, 8, 8], "texture": "#texture"}, - "south": {"uv": [15.5, 1.25, 16, 4], "texture": "#texture"}, - "west": {"uv": [8, 9, 16, 11.75], "texture": "#texture"}, - "up": {"uv": [0, 8, 0.5, 12], "rotation": 180, "texture": "#texture"}, - "down": {"uv": [8, 8, 8.5, 12], "texture": "#texture"} + "north": {"uv": [0, 2.5, 0.5, 8], "texture": "#texture"}, + "east": {"uv": [0, 2.5, 8, 8], "texture": "#1"}, + "south": {"uv": [15.5, 2.5, 16, 8], "texture": "#texture"}, + "west": {"uv": [8, 9.5, 16, 15], "texture": "#1"}, + "up": {"uv": [0, 8, 0.5, 16], "rotation": 180, "texture": "#1"}, + "down": {"uv": [8, 8, 8.5, 16], "texture": "#1"} } }, { @@ -25,12 +27,12 @@ "from": [0, 0, 0], "to": [1, 11, 16], "faces": { - "north": {"uv": [7.5, 1.25, 8, 4], "texture": "#texture"}, - "east": {"uv": [8, 9, 16, 11.75], "texture": "#texture"}, - "south": {"uv": [8, 1.25, 8.5, 4], "texture": "#texture"}, - "west": {"uv": [8, 5.25, 16, 8], "texture": "#texture"}, - "up": {"uv": [7.5, 8, 8, 12], "rotation": 180, "texture": "#texture"}, - "down": {"uv": [15.5, 8, 16, 12], "texture": "#texture"} + "north": {"uv": [7.5, 2.5, 8, 8], "texture": "#texture"}, + "east": {"uv": [8, 9.5, 16, 15], "texture": "#1"}, + "south": {"uv": [8, 2.5, 8.5, 8], "texture": "#1"}, + "west": {"uv": [8, 2.5, 16, 8], "texture": "#1"}, + "up": {"uv": [7.5, 8, 8, 16], "rotation": 180, "texture": "#1"}, + "down": {"uv": [15.5, 8, 16, 16], "texture": "#1"} } }, { @@ -38,10 +40,10 @@ "from": [0, 11, 1], "to": [8, 16, 6], "faces": { - "north": {"uv": [4, 13.25, 8, 14.5], "texture": "#texture"}, - "south": {"uv": [4, 14.5, 8, 15.75], "texture": "#texture"}, - "west": {"uv": [8.5, 4, 11, 5.25], "texture": "#texture"}, - "up": {"uv": [4, 12, 8, 13.25], "texture": "#texture"} + "north": {"uv": [4, 10.5, 8, 13], "texture": "#texture"}, + "south": {"uv": [4, 13, 8, 15.5], "texture": "#texture"}, + "west": {"uv": [8.5, 0, 11, 2.5], "texture": "#1"}, + "up": {"uv": [4, 8, 8, 10.5], "texture": "#texture"} } }, { @@ -49,11 +51,11 @@ "from": [8, 11, 0], "to": [16, 16, 6], "faces": { - "north": {"uv": [0, 0, 4, 1.25], "texture": "#texture"}, - "east": {"uv": [5, 4, 8, 5.25], "texture": "#texture"}, - "south": {"uv": [0, 12.25, 4, 13.5], "rotation": 180, "texture": "#texture"}, - "west": {"uv": [5, 4, 8, 5.25], "texture": "#texture"}, - "up": {"uv": [0, 12, 4, 13.5], "texture": "#texture"} + "north": {"uv": [0, 0, 4, 2.5], "texture": "#texture"}, + "east": {"uv": [5, 0, 8, 2.5], "texture": "#1"}, + "south": {"uv": [0, 8.5, 4, 11], "rotation": 180, "texture": "#texture"}, + "west": {"uv": [5, 0, 8, 2.5], "texture": "#1"}, + "up": {"uv": [0, 8, 4, 11], "texture": "#texture"} } }, { @@ -61,20 +63,21 @@ "from": [5, 11, 11], "to": [14, 15, 15], "faces": { - "north": {"uv": [11, 12, 15.5, 13], "rotation": 180, "texture": "#texture"}, - "south": {"uv": [11, 12, 15.5, 13], "texture": "#texture"}, - "up": {"uv": [11, 12, 15.5, 13], "texture": "#texture"} - } + "north": {"uv": [11, 0, 15.5, 2], "rotation": 180, "texture": "#texture"}, + "south": {"uv": [11, 0, 15.5, 2], "texture": "#texture"}, + "up": {"uv": [11, 0, 15.5, 2], "texture": "#texture"} + }, + "forge_data": { "block_light": 15, "sky_light": 15 } }, { "name": "canister", "from": [14, 11, 11], "to": [15, 15, 15], "faces": { - "north": {"uv": [15.5, 12, 16, 13], "rotation": 180, "texture": "#texture"}, - "east": {"uv": [8, 12, 10, 13], "texture": "#texture"}, - "south": {"uv": [15.5, 12, 16, 13], "texture": "#texture"}, - "up": {"uv": [15.5, 12, 16, 13], "texture": "#texture"} + "north": {"uv": [15.5, 0, 16, 2], "rotation": 180, "texture": "#texture"}, + "east": {"uv": [8, 0, 10, 2], "texture": "#texture"}, + "south": {"uv": [15.5, 0, 16, 2], "texture": "#texture"}, + "up": {"uv": [15.5, 0, 16, 2], "texture": "#texture"} } }, { @@ -82,10 +85,10 @@ "from": [3, 11, 11], "to": [5, 15, 15], "faces": { - "north": {"uv": [10, 12, 11, 13], "rotation": 180, "texture": "#texture"}, - "south": {"uv": [10, 12, 11, 13], "texture": "#texture"}, - "west": {"uv": [8, 12, 10, 13], "texture": "#texture"}, - "up": {"uv": [10, 12, 11, 13], "texture": "#texture"} + "north": {"uv": [10, 0, 11, 2], "rotation": 180, "texture": "#texture"}, + "south": {"uv": [10, 0, 11, 2], "texture": "#texture"}, + "west": {"uv": [8, 0, 10, 2], "texture": "#texture"}, + "up": {"uv": [10, 0, 11, 2], "texture": "#texture"} } }, { @@ -93,9 +96,9 @@ "from": [3, 11, 6], "to": [5, 15, 10], "faces": { - "south": {"uv": [10, 12, 11, 13], "texture": "#texture"}, - "west": {"uv": [8, 12, 10, 13], "texture": "#texture"}, - "up": {"uv": [10, 12, 11, 13], "texture": "#texture"}, + "south": {"uv": [10, 0, 11, 2], "texture": "#texture"}, + "west": {"uv": [8, 0, 10, 2], "texture": "#texture"}, + "up": {"uv": [10, 0, 11, 2], "texture": "#texture"}, "down": {"uv": [0, 0, 6, 1], "texture": "#missing"} } }, @@ -104,19 +107,20 @@ "from": [5, 11, 6], "to": [14, 15, 10], "faces": { - "south": {"uv": [11, 12, 15.5, 13], "texture": "#texture"}, - "up": {"uv": [11, 12, 15.5, 13], "texture": "#texture"}, + "south": {"uv": [11, 0, 15.5, 2], "texture": "#texture"}, + "up": {"uv": [11, 0, 15.5, 2], "texture": "#texture"}, "down": {"uv": [0, 0, 6, 1], "texture": "#missing"} - } + }, + "forge_data": { "block_light": 15, "sky_light": 15 } }, { "name": "canister", "from": [14, 11, 6], "to": [15, 15, 10], "faces": { - "east": {"uv": [8, 12, 10, 13], "texture": "#texture"}, - "south": {"uv": [15.5, 12, 16, 13], "texture": "#texture"}, - "up": {"uv": [15.5, 12, 16, 13], "texture": "#texture"}, + "east": {"uv": [8, 0, 10, 2], "texture": "#texture"}, + "south": {"uv": [15.5, 0, 16, 2], "texture": "#texture"}, + "up": {"uv": [15.5, 0, 16, 2], "texture": "#texture"}, "down": {"uv": [0, 0, 6, 1], "texture": "#missing"} } }, @@ -125,10 +129,10 @@ "from": [0, 11, 7], "to": [3, 14, 9], "faces": { - "north": {"uv": [0, 14, 1, 14.75], "texture": "#texture"}, - "south": {"uv": [0, 14, 1, 14.75], "texture": "#texture"}, - "west": {"uv": [0, 14, 1, 14.75], "texture": "#texture"}, - "up": {"uv": [0, 13.5, 1, 14], "texture": "#texture"} + "north": {"uv": [1, 12, 0, 13.5], "texture": "#texture"}, + "south": {"uv": [0, 12, 1, 13.5], "texture": "#texture"}, + "west": {"uv": [0, 12, 1, 13.5], "texture": "#texture"}, + "up": {"uv": [0, 11, 1, 12], "texture": "#texture"} } }, { @@ -136,10 +140,33 @@ "from": [0, 11, 12], "to": [3, 14, 14], "faces": { - "north": {"uv": [1, 14, 0, 14.75], "texture": "#texture"}, - "south": {"uv": [0, 14, 1, 14.75], "texture": "#texture"}, - "west": {"uv": [0, 14, 1, 14.75], "texture": "#texture"}, - "up": {"uv": [0, 13.5, 1, 14], "texture": "#texture"} + "north": {"uv": [1, 12, 0, 13.5], "texture": "#texture"}, + "south": {"uv": [0, 12, 1, 13.5], "texture": "#texture"}, + "west": {"uv": [0, 12, 1, 13.5], "texture": "#texture"}, + "up": {"uv": [0, 11, 1, 12], "texture": "#texture"} + } + }, + { + "name": "frame", + "from": [15.5, 11, 15], + "to": [16, 16, 16], + "faces": { + "north": {"uv": [0, 15, 2.5, 15.5], "rotation": 270, "texture": "#texture"}, + "east": {"uv": [0, 15, 2.5, 15.5], "rotation": 270, "texture": "#texture"}, + "south": {"uv": [0, 15, 2.5, 15.5], "rotation": 270, "texture": "#texture"}, + "west": {"uv": [0, 15, 2.5, 15.5], "rotation": 270, "texture": "#texture"}, + "up": {"uv": [2, 15, 2.5, 15.5], "texture": "#texture"} + } + }, + { + "name": "frame", + "from": [15.5, 15, 6], + "to": [16, 16, 15], + "faces": { + "east": {"uv": [0, 15.5, 4.5, 16], "texture": "#texture"}, + "west": {"uv": [0, 15.5, 4.5, 16], "texture": "#texture"}, + "up": {"uv": [0, 15.5, 4.5, 16], "rotation": 90, "texture": "#texture"}, + "down": {"uv": [0, 15.5, 4.5, 16], "rotation": 90, "texture": "#texture"} } }, { @@ -147,11 +174,11 @@ "from": [0, 11, 15], "to": [0.5, 16, 16], "faces": { - "north": {"uv": [0, 15.5, 2.5, 15.75], "rotation": 270, "texture": "#texture"}, - "east": {"uv": [0, 15.5, 2.5, 15.75], "rotation": 270, "texture": "#texture"}, - "south": {"uv": [0, 15.5, 2.5, 15.75], "rotation": 270, "texture": "#texture"}, - "west": {"uv": [0, 15.5, 2.5, 15.75], "rotation": 270, "texture": "#texture"}, - "up": {"uv": [2, 15.5, 2.5, 15.75], "texture": "#texture"} + "north": {"uv": [0, 15, 2.5, 15.5], "rotation": 270, "texture": "#texture"}, + "east": {"uv": [0, 15, 2.5, 15.5], "rotation": 270, "texture": "#texture"}, + "south": {"uv": [0, 15, 2.5, 15.5], "rotation": 270, "texture": "#texture"}, + "west": {"uv": [0, 15, 2.5, 15.5], "rotation": 270, "texture": "#texture"}, + "up": {"uv": [2, 15, 2.5, 15.5], "texture": "#texture"} } }, { @@ -159,33 +186,10 @@ "from": [0, 15, 6], "to": [0.5, 16, 15], "faces": { - "east": {"uv": [0, 15.75, 4.5, 16], "texture": "#texture"}, - "west": {"uv": [0, 15.75, 4.5, 16], "texture": "#texture"}, - "up": {"uv": [0, 15.75, 4.5, 16], "rotation": 90, "texture": "#texture"}, - "down": {"uv": [0, 15.75, 4.5, 16], "rotation": 90, "texture": "#texture"} - } - }, - { - "name": "frame", - "from": [15.4, 11, 15], - "to": [15.9, 16, 16], - "faces": { - "north": {"uv": [0, 15.5, 2.5, 15.75], "rotation": 270, "texture": "#texture"}, - "east": {"uv": [0, 15.5, 2.5, 15.75], "rotation": 270, "texture": "#texture"}, - "south": {"uv": [0, 15.5, 2.5, 15.75], "rotation": 270, "texture": "#texture"}, - "west": {"uv": [0, 15.5, 2.5, 15.75], "rotation": 270, "texture": "#texture"}, - "up": {"uv": [2, 15.5, 2.5, 15.75], "texture": "#texture"} - } - }, - { - "name": "frame", - "from": [15.4, 15, 6], - "to": [15.9, 16, 15], - "faces": { - "east": {"uv": [0, 15.75, 4.5, 16], "texture": "#texture"}, - "west": {"uv": [0, 15.75, 4.5, 16], "texture": "#texture"}, - "up": {"uv": [0, 15.75, 4.5, 16], "rotation": 90, "texture": "#texture"}, - "down": {"uv": [0, 15.75, 4.5, 16], "rotation": 90, "texture": "#texture"} + "east": {"uv": [0, 15.5, 4.5, 16], "texture": "#texture"}, + "west": {"uv": [0, 15.5, 4.5, 16], "texture": "#texture"}, + "up": {"uv": [0, 15.5, 4.5, 16], "rotation": 90, "texture": "#texture"}, + "down": {"uv": [0, 15.5, 4.5, 16], "rotation": 90, "texture": "#texture"} } }, { @@ -193,10 +197,10 @@ "from": [1, 0, 0], "to": [15, 1, 16], "faces": { - "north": {"uv": [0.5, 3.75, 7.5, 4], "texture": "#texture"}, - "south": {"uv": [8.5, 3.75, 15.5, 4], "texture": "#texture"}, - "up": {"uv": [0.5, 8, 7.5, 12], "rotation": 180, "texture": "#texture"}, - "down": {"uv": [8.5, 8, 15.5, 12], "texture": "#texture"} + "north": {"uv": [0.5, 7.5, 7.5, 8], "texture": "#texture"}, + "south": {"uv": [8.5, 7.5, 15.5, 8], "texture": "#texture"}, + "up": {"uv": [0.5, 8.5, 7.5, 15.5], "rotation": 180, "texture": "#1"}, + "down": {"uv": [8.5, 8, 15.5, 16], "texture": "#1"} } }, { @@ -204,10 +208,10 @@ "from": [8, 7, 0], "to": [15, 11, 1], "faces": { - "north": {"uv": [0.5, 1.25, 4, 2.25], "texture": "#texture"}, - "south": {"uv": [0, 0, 3.5, 1], "texture": "#texture"}, - "west": {"uv": [3.5, 1.25, 4, 2], "texture": "#texture"}, - "down": {"uv": [0.5, 2, 4, 2.25], "texture": "#texture"} + "north": {"uv": [0.5, 2.5, 4, 4.5], "texture": "#texture"}, + "south": {"uv": [4, 2.5, 0.5, 4.5], "texture": "#texture"}, + "west": {"uv": [3.5, 2.5, 4, 4.5], "texture": "#texture"}, + "down": {"uv": [0.5, 4, 4, 4.5], "texture": "#texture"} } }, { @@ -215,11 +219,11 @@ "from": [1, 9, 0], "to": [8, 11, 1], "faces": { - "north": {"uv": [4, 1.25, 7.5, 1.75], "texture": "#texture"}, + "north": {"uv": [4, 2.5, 7, 3.5], "texture": "#texture"}, "east": {"uv": [0, 0, 0.5, 0.5], "texture": "#missing"}, - "south": {"uv": [4, 1.25, 7, 1.75], "texture": "#texture"}, - "up": {"uv": [4, 11.75, 7.5, 12], "texture": "#texture"}, - "down": {"uv": [1.5, 3.5, 5, 3.75], "texture": "#texture"} + "south": {"uv": [4, 3, 7, 3.5], "rotation": 180, "texture": "#texture"}, + "up": {"uv": [4, 15.5, 7.5, 16], "texture": "#1"}, + "down": {"uv": [4, 3, 7, 3.5], "rotation": 180, "texture": "#texture"} } }, { @@ -227,9 +231,9 @@ "from": [1, 1, 0], "to": [2, 9, 1], "faces": { - "north": {"uv": [7, 1.75, 7.5, 3.75], "texture": "#texture"}, - "east": {"uv": [7, 1.75, 7.5, 3.75], "texture": "#texture"}, - "south": {"uv": [7, 1.75, 7.5, 3.75], "texture": "#texture"} + "north": {"uv": [7, 3.5, 7.5, 7], "texture": "#texture"}, + "east": {"uv": [7, 3.5, 7.5, 7], "texture": "#texture"}, + "south": {"uv": [7, 3.5, 7.5, 7], "texture": "#texture"} } }, { @@ -237,9 +241,9 @@ "from": [14, 1, 0], "to": [15, 7, 1], "faces": { - "north": {"uv": [0.5, 2.25, 1, 3.75], "texture": "#texture"}, - "south": {"uv": [0.5, 2.25, 1, 3.75], "texture": "#texture"}, - "west": {"uv": [0.5, 2.25, 1, 3.75], "texture": "#texture"} + "north": {"uv": [0.5, 4.5, 1, 7], "texture": "#texture"}, + "south": {"uv": [0.5, 4.5, 1, 7], "texture": "#texture"}, + "west": {"uv": [0.5, 4.5, 1, 7], "texture": "#texture"} } }, { @@ -247,9 +251,9 @@ "from": [2, 1, 0], "to": [14, 2, 1], "faces": { - "north": {"uv": [1, 3.5, 7, 3.75], "texture": "#texture"}, - "south": {"uv": [1, 3.5, 7, 3.75], "texture": "#texture"}, - "up": {"uv": [1, 3.5, 7, 3.75], "texture": "#texture"} + "north": {"uv": [1, 7, 7, 7.5], "texture": "#texture"}, + "south": {"uv": [1, 7, 7, 7.5], "texture": "#texture"}, + "up": {"uv": [1, 7, 7, 7.5], "texture": "#texture"} } }, { @@ -257,8 +261,8 @@ "from": [1, 10, 1], "to": [15, 11, 15], "faces": { - "up": {"uv": [0.5, 8.25, 7.5, 11.75], "rotation": 180, "texture": "#texture"}, - "down": {"uv": [8.5, 8.25, 15.5, 11.75], "texture": "#texture"} + "up": {"uv": [0.5, 8.5, 7.5, 15.5], "rotation": 180, "texture": "#1"}, + "down": {"uv": [8.5, 8.5, 15.5, 15.5], "texture": "#1"} } }, { @@ -266,9 +270,9 @@ "from": [1, 1, 15], "to": [15, 11, 16], "faces": { - "north": {"uv": [8.5, 9, 15.5, 11.5], "texture": "#texture"}, - "south": {"uv": [8.5, 1.25, 15.5, 3.75], "texture": "#texture"}, - "up": {"uv": [0.5, 8, 7.5, 8.25], "texture": "#texture"} + "north": {"uv": [8.5, 9.5, 15.5, 14.5], "texture": "#1"}, + "south": {"uv": [8.5, 2.5, 15.5, 7.5], "texture": "#texture"}, + "up": {"uv": [0.5, 8, 7.5, 8.5], "texture": "#1"} } }, { @@ -276,11 +280,11 @@ "from": [3, 1, 3], "to": [13, 2, 13], "faces": { - "north": {"uv": [10.5, 13, 16, 13.25], "texture": "#texture"}, - "east": {"uv": [10.5, 13, 16, 13.25], "texture": "#texture"}, - "south": {"uv": [10.5, 13, 16, 13.25], "texture": "#texture"}, - "west": {"uv": [10.5, 13, 16, 13.25], "texture": "#texture"}, - "up": {"uv": [10.5, 13, 16, 15.75], "texture": "#texture"} + "north": {"uv": [10.5, 13, 16, 13.5], "texture": "#texture"}, + "east": {"uv": [10.5, 13, 16, 13.5], "texture": "#texture"}, + "south": {"uv": [10.5, 13, 16, 13.5], "texture": "#texture"}, + "west": {"uv": [10.5, 13, 16, 13.5], "texture": "#texture"}, + "up": {"uv": [10.5, 8, 16, 13.5], "texture": "#texture"} } }, { @@ -288,14 +292,28 @@ "to": [0, 14, 8.9], "rotation": {"angle": 22.5, "axis": "z", "origin": [0, 14, 8]}, "faces": { - "north": {"uv": [8.5, 13.75, 9.5, 14.75], "texture": "#texture"}, - "south": {"uv": [8.5, 13.75, 9.5, 14.75], "texture": "#texture"}, - "west": {"uv": [8.5, 13.75, 9.5, 14.75], "texture": "#texture"}, - "up": {"uv": [8.5, 13.25, 9.5, 13.75], "texture": "#texture"}, - "down": {"uv": [8.5, 14.75, 9.5, 15.25], "texture": "#texture"} + "north": {"uv": [8.5, 9.5, 9.5, 11.5], "texture": "#texture"}, + "south": {"uv": [8.5, 9.5, 9.5, 11.5], "texture": "#texture"}, + "west": {"uv": [8.5, 9.5, 9.5, 11.5], "texture": "#texture"}, + "up": {"uv": [8.5, 8.5, 9.5, 9.5], "texture": "#texture"}, + "down": {"uv": [8.5, 11.5, 9.5, 12.5], "texture": "#texture"} } }, { + "name": "pipestuff", + "from": [-2, 10, 12.1], + "to": [0, 14, 13.9], + "rotation": {"angle": 22.5, "axis": "z", "origin": [0, 14, 13]}, + "faces": { + "north": {"uv": [8.5, 9.5, 9.5, 11.5], "texture": "#texture"}, + "south": {"uv": [8.5, 9.5, 9.5, 11.5], "texture": "#texture"}, + "west": {"uv": [8.5, 9.5, 9.5, 11.5], "texture": "#texture"}, + "up": {"uv": [8.5, 8.5, 9.5, 9.5], "texture": "#texture"}, + "down": {"uv": [8.5, 11.5, 9.5, 12.5], "texture": "#texture"} + } + }, + { + "name": "pipestuff", "from": [-2, 10, 12.1], "to": [0, 14, 13.9], "rotation": {"angle": 22.5, "axis": "z", "origin": [0, 14, 8]}, diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/android_station.png b/src/main/resources/assets/overdrive_that_matters/textures/block/android_station.png index be4d27d190e6712537f7325913d556a616acb275..630516c65ae7e20e7166eeeb3c8d72f9328aab83 100644 GIT binary patch delta 218 zcmZ3$vY2UtIF|qiGXn#I!@b_@iHZu0iW8lb>VbTP+NK&H#a$BQ7yKU%7`*%$KLLd~ z3p^r=85sEXgD|57Yp@DXu*B2FF+?MH>cnWi1_d6L>$k-B{%>6C)YHK>cfIe-fQ-i0 zFfK2p!-osX~r=gi}y1=N>qQ?v_mm(ckD)SMTb+4He7R@Z1q)H z){d!zWZS1+0)40Hg4r>mdK II;Vst0NY(q^#A|> delta 473 zcmZ3?w18!TIF|zlGXn#IPeALOiHZu0HWQtc>i_@$fBW|Bw91y;rv8wW+}Ql8^8VS4 zvsU!3*bY?6xqQ+hASF@~&;tdsMp{90KZKY|; zRXQsa-u^voOGG=Mzw%$GmnwSZ0(+D z0j#ByquRu|j#_9eD9ctzNqT4TtGD~x-y8k?rwV0$*ZMr=G4-mDetbgm&S}f+howGm zde7fJRqdqly>Po{;^lur2MY8zC@{yl^Q8#9Yl)c~#6BVW8mHa<`}Pie_qm^!I0{!N zY*~5A<41LyS!iJE_I*y;Q=(qoT61bcWY+HYf4D_mJzfe&_@Ouw#50qmifpVM$9+AZi41D`Rn9+hYSOq9}-P6S} z#KQmWBwoJ53LLE)S?iZ=`hCBQKQ%h*OjTp8?-cQQ84FwYQK9QmyH`~eSC6bU6BDdfbBZ*z&Ho{- z_MPqFExV9ud?8oGxUK6%zsU8vf4^A$@Eo7XixBNTOP-6lKN*}if9A_F*(){WSkC?} zOAlo|=sg%L9Jl^}^fa#U<~yMRAs?==uzkF9VBLo)n+^Ze99|cg%^GdHKYQ!14Qh5e n<^7p2%kISHKAN$;td@~wn})&CxQDBNUS#le^>bP0l+XkKtB$AR literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/android_station_offline.png b/src/main/resources/assets/overdrive_that_matters/textures/block/android_station_offline.png index 2e575e6e4eaea95211778d1fcc0c921862dd9849..abd758f4fa326bc59bdf7921926874259e3a8d11 100644 GIT binary patch delta 203 zcmbQlGKFb^IF|qiGXn#I!@b_@iHZu0iW8lb>VbTP+NK&H#a$BQ7yKU%7`*%$KLLd~ z3p^r=85sEXgD|57Yp@DXFxAt=F+?MH>O^n80}33h^G~eb`@ivYQ|pS}w`(|NGT1e` z&7I`edr;|6z*(jMA!GA$^Mx7ih5~ML849Hf4%!Mjy*fC%KsCB?wc&y82CW3aEnL6i sE!J7cRn|P4zJP6;qo|qV)c0vNIbD3;O^aDAfi^ODy85}Sb4q9e07P_2(f|Me delta 459 zcmbQjG>K(`IF|zlGXn#IPeALOiHZu0HWQtc>i_@$fBW|Bw91y;rv8wW+}Ql8^8VS4 zvsU!3*bY?6xqQ+hASF@~~C*AsxPc!8r{V(-b&AcPf0@!Qfc>!RJRnTT?#keaETR}C~muIKI7(cWlqd6!PbgTmiwM=g%+aP2Q{D!9GP=!opZ2VEPZAMpiw z{Zw!N9+$w{-86AQy{QII%N4GZr#`e5L>{`;93h!9!LekWLDV6UGrm!haT+3z7c|^j z+c?2<=i?XVdbhqO+uLa$FMM;|aH{c=DIbiEO)TCqy?9xowHlw^lia7aic?b< z<^3!Lcer&e}6SKHF9!tNB_Gw z#*ii^CKeVJ|JVTk;7MkAgl&S4#?2Mmq zh1y!H6##lv#KQwkR+0G9HO`Mw=2E+er+wUD{30;hC!r2LDe7Rh<+&l*09@m&0jh!&lslO%1zG?Q zX5J3e%vQXL_}09VJFvK?N%y$!t}9SDQS5wC%-i7(ppPm59C0y%C5*tN_`A-1t daNw%r_yehc9&VxwseJ$d002ovPDHLkV1hV|$#(z% delta 702 zcmV;v0zv)o1NH@w7YaZK0{{R3Oi+cKks%;MHc(7dMO0K&U|?W>e}5Jh7XR1)|KLeA zH8o~=gl&S4H^z`h|GUPtS6y#L3h7ld=n46{!FJv+v#{ ztt)5mSut8^glo{X>?sA`t|kwI}kHut|b|Y#{MHQLs{3g z6as98VDB+RkVOO^i<SZu_MrzXM`8L_pW@nO4>NIKv%v zn1G_1#uxy|BYdWZNVV`;LHxkT`7wxjsDqG)oRjUFl0;y(hbl%s$mHmPM!-gW0zS?l zPYW)(paGyCOPm2KJa-$1&uo>}kP6(m&8YqAOPF1Hliqp5xZ`{{V0M4$(t73%9qxsg zg&oMfV=uVzJh+<&4)POcO%u;UK^MN!K^r2)E`*%Y{r>u*+_Mc}wC@0B8zrA~wfkIu z1RhNjw%R-E9|=v!&dK%`Gi+(%=2MJ@5)zTORMTc+152igb&#jtYr+z`ZGl7E)^L`Y zL{sO%CUDFEpmKZ&bJTzH3{nrb$$?=8oq_&lhH$w6k|?Z)YR09ii&cZ`qL^~w6(Rx#Kewm373Er}byd^-DPd95w1C_5U%=?$(-@A#zwA? z!k`~7ZChef?yHKqKGA=vddMzE+*r?|{L2S#fp3YMW*0Rsc4u7vL1=~KyC&A7?rqH( zH#YKKU=FLg#OdfD8k=$Rug(4an{El*c`Mv>Q>^nK&%AA!dCX?>ZZm|N7WZx9zhXG| z=sRmai(^MlSI=YXbIkbsO7{Vq>fS|s&r-rDt4otNAi`!f^7b5HZC@iloia4XC&vTPLn&O^W&k|Q^OTo+mEmK8Nr-i np=uYVE~ow9^Rco0_Lufni$xE;>`&bb3^WE$S3j3^P6+4NTO^b?(-2d-3KQ=*4 zO-)QpY%2r9e+GuM%9h-w{$pFhWAm%z$Ep4o${}mtJdb5=nw5cH-jfa+=WGdS_Grs?=@wZ5tt}%y5WSH zP<&YL=ff6T7>c=7VvpP^@%?&Y!3pD~XYCm8)XOm~n7c0|ymp=7yh48Q1uOHic^OZ1 z@4MoCWOL1(gg=K2s&$=W;zeo=ZhyKnA%|gI**AvRM($HSXv*YuY~!Kcr03m>?zdSt>|DiA@MPteX@zwm*g9R*h< Y_FL_c3*ZTAXa$BTgQqJnT$~b`0K^%^)&Kwi delta 697 zcmV;q0!IDr1Mvlr7YaZK0{{R3Oi+cKks%;MHc(7dMO0K&U|?W>e}5Jh7PSBX{{R3r zH8o~=gl&S4#Vy6_7+z3VIa(^ zsgD5!xrfeh7bzA#JBSyAobMfIw{$=qa!!^vA&G=h?z$NDAScHZ&=YLcC&EVy^044y z3g`&b!^N3kjc2y8`Ak-+6{Wy~X-4lCcj0oY(i$IFckB-*xZI?+%m;raOi8c`J0Z7* zT=3w2FfA|>zT<3Y;C`4fgjSV+&K9H`YJ-0hItw}y+6xPza)6M}F`O-saDaqRIY5xn!qvqo1|121$U-lL zI>&G+HJf!HZRir4<*;VONjhGacE@R;$}r)s^8FK6jT32W9mumh2~+4h0vJW#5I(xF zk3!BBe>T%p5j#WdgT%KCgc~EleM55Me>NFK0i1x1XIYoR@5o(FP+m@${4BsRf(!zx z$gAKRMS|&ZTslGk0fJD1P$mXv1P>9y*#hT`;0AWWGX~QF1EJ3%^v@WGz7DyfTo*!D f$zy1mGaip$)pkS@LLqU}00000NkvXXu0mjfXzd|| diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/matter_replicator_offline.png b/src/main/resources/assets/overdrive_that_matters/textures/block/matter_replicator_offline.png index c53cc03d34f14b8f47b6c07aadb2aa8db8db5a2e..572b79b0644835e1e2a677b867002515a42869ca 100644 GIT binary patch delta 439 zcmaFH`ha+4NTO^b?(-2d-3KQ=*4 zO-)QpEUmI7x2gZwmhjm8Dmghhpw4YM_g?`i{*oZS;QuIq;mVyE3xQIc1s;*b3=Dkx zL735kHCTm#fl<-Z#WBRfzjspLq$3I(E{=Cx=dSr~U;pkxL+8vh$G3%PeiCu%?C6}C zv8>Bu<(JR1*Uq|M%CtzSit#C@#KJwyXOF(DZ+pQ1AXr_Y!!_yDNvW_7yJIh88PYU2 zi%;+@Q+hqm^c{b4CUX+EOS4DS4yVIP29H{HoHke3KAYi#$NX%A{ojP+zVVqaFy3y< z&iuk-{%eIGe|i1-jAlut<7#tO&tAi)boM=OAalX?y=*JEVkWo?tz=!rAmq2-=ZcS1 zUF+9p{-0P@tx{i^bzXKCv#R-|7<;Y1Mxl&Hw3rV}{jRe1{36bbMr)z|Teki?7~G-{ zOg+rBHlNqsDHMhbBR)v!t5pgr6;_6 eawxWVALG?E(nWXY`%MQ1B7>)^pUXO@geCx<e}5Jh7Bw|BW_g5d zf{(_uS6y#j_Sw(Vjmutle%5_{?@;e}gLj-gUpJ`Ry#u+x$ zVFHS38e;$;kMNluBGtlY1@QwT=f@y_&RYi|4>>2>HzkR{Y!6k8e2~e}1&x4>`UHHO zL7o;|bU_0^KbE)xR(S3<4xia7tsxb-ahp;5)t4~4^d`OYhH>ZlaKP-+rS;4kI@}8} z3kQ&U$6j#bd2lxm9ONg?nkJryf-ZccgEmBpT?jd)ZF_xD?%4(~+8cn`M#(3C-R(Zt zAAv{Hgst|@`bR<&vU9P$#SB}TxcL;Lp@c-_J=L_E*uavhVjbkE_nNST?t9?SzBim@ zCehS+unC+q0H_=v!W{KFgVfV)a$uN2XQ02CAzUs1`5MD@1_GxDgv$j$<{9owTw>4} z_{A>tmZ)nCw^XxOr_zopu~;sDD^@&7=g+O&@ifq7TJUM|^)Id#Po#}?VW0H{Ea4vj z5LN#Jd|bj_3OP6Y*(^&#>2q8cKHGsM>I0HOH7}putXMj&|0IwL#3r)Z(xQp<=VxY!6 lzx_pWon@IFrhN3NQcw002ovPDHLkV1g>lI3)l8 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/battery_procedural.png b/src/main/resources/assets/overdrive_that_matters/textures/item/battery_procedural.png new file mode 100644 index 0000000000000000000000000000000000000000..afdf29101d86420b9d8c828f38e6388c93a379a9 GIT binary patch literal 262 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G|s0G|+7Pjj;{2Zv-YPhBO&s_3Zy4?O?h0Ln4E(_1eNq&P}~{DS{O0K>iJ zy^%mM&H|6fVg?4jLm-JD|YfeA<2I|K4zixzWA>aZv&v zg&Fls1p*l(j!0SjHdI*0t7WX7@MgO6OMxs`k4p!SFwIf3d|W!AM&_Jp$%}i3rWdol tX56Z}p3U>s@|)%x*76EWd*0wJ$p4j>`R#uvD@&kt44$rjF6*2UngEbiRPO)) literal 0 HcmV?d00001 From e8d7f0225c7ba4c4d8dc0d6e625d97e457fc17cc Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 22 Jul 2023 11:47:41 +0700 Subject: [PATCH 0812/1199] Don't check for energy flow when working with mekanism energy --- .../kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt index 0f2d21f9d..451a4070b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt @@ -63,6 +63,14 @@ class Mekanism2MatteryEnergyWrapper(private val power: IStrictEnergyHandler, pri } } + override fun extractEnergyChecked(howMuch: Decimal, simulate: Boolean): Decimal { + return extractEnergy(howMuch, simulate) + } + + override fun receiveEnergyChecked(howMuch: Decimal, simulate: Boolean): Decimal { + return receiveEnergy(howMuch, simulate) + } + override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { val action = when (simulate) { true -> Action.SIMULATE From d2c2fbd3d2b9e9ec6276e6199447a62e24875219 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 22 Jul 2023 11:58:04 +0700 Subject: [PATCH 0813/1199] Fix crash related to tracking mekanism energy --- .../mc/otm/block/entity/MatteryBlockEntity.kt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) 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 b7a3bcc7b..75517e9c3 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 @@ -64,6 +64,7 @@ import ru.dbotthepony.mc.otm.once import ru.dbotthepony.mc.otm.onceServer import java.lang.ref.WeakReference import java.util.* +import java.util.function.Consumer import java.util.function.Supplier import java.util.stream.Stream import kotlin.NoSuchElementException @@ -220,17 +221,17 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc if (value.isPresent) for (tracker in listeners) - tracker.run() + tracker.accept(value) } } - private val listeners = ArrayList(0) + private val listeners = ArrayList>>(0) - fun addListener(listener: Runnable) { + fun addListener(listener: Consumer>) { listeners.add(listener) if (value.isPresent) - listener.run() + listener.accept(value) } override fun get(): LazyOptional { @@ -266,7 +267,12 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc mekanism.addListener { actualMekanism?.invalidate() - actualMekanism = LazyOptional.of { Mekanism2MatteryEnergyWrapper(mekanism.value.orElseThrow { NoSuchElementException() }) } + + if (it.isPresent) { + actualMekanism = LazyOptional.of { Mekanism2MatteryEnergyWrapper(it.orElseThrow { NoSuchElementException("No mekanism energy was present, and tracker did not call back in time") }) } + } else { + actualMekanism = null + } } } else { mekanism = null From c887025a6c492662bee91b27541f259c67678d70 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 22 Jul 2023 12:05:41 +0700 Subject: [PATCH 0814/1199] Fix when Mattery energy is exposed as Mekanism energy it ignore energy flow direction Just like Mekanism for a long time ignored throughput limits when something charge its items through Forge Energy --- .../kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt index 451a4070b..583df483c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt @@ -170,11 +170,11 @@ class Mattery2MekanismEnergyWrapper(private val power: IMatteryEnergyStorage) : override fun insertEnergy(container: Int, howMuch: FloatingLong, action: Action): FloatingLong { val copy = howMuch.copy() - return copy.minusEqual((power.receiveEnergy(howMuch.toDecimal() * Mekanism2MatteryEnergyWrapper.mekanism2MtJ, action.simulate()) * mtj2Mekanism).toFloatingLong()) + return copy.minusEqual((power.receiveEnergyChecked(howMuch.toDecimal() * Mekanism2MatteryEnergyWrapper.mekanism2MtJ, action.simulate()) * mtj2Mekanism).toFloatingLong()) } override fun extractEnergy(container: Int, howMuch: FloatingLong, action: Action): FloatingLong { - return (power.extractEnergy(howMuch.toDecimal() * Mekanism2MatteryEnergyWrapper.mekanism2MtJ, action.simulate()) * mtj2Mekanism).toFloatingLong() + return (power.extractEnergyChecked(howMuch.toDecimal() * Mekanism2MatteryEnergyWrapper.mekanism2MtJ, action.simulate()) * mtj2Mekanism).toFloatingLong() } } From dc2661db9a8a6e7aef76c40b029738d1b3511e09 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 22 Jul 2023 12:31:58 +0700 Subject: [PATCH 0815/1199] Fix quick move not displaying proper item counts --- .../mc/otm/client/screen/panels/slot/SlotPanel.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 d2402e13b..a1361b096 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 @@ -71,13 +71,12 @@ open class SlotPanel, out T : Slot> @JvmOverloads const itemstack = carried.copy() dragHit = true - AbstractContainerMenu.getQuickCraftPlaceCount( + val k = Math.min(AbstractContainerMenu.getQuickCraftPlaceCount( screen.quickCraftSlots, screen.quickCraftingType, itemstack - ) + ) + slot.item.count, slot.getMaxStackSize(itemstack)) - val k = Math.min(itemstack.maxStackSize, slot.getMaxStackSize(itemstack)) if (itemstack.count > k) { countOverride = ChatFormatting.YELLOW.toString() + k itemstack.count = k From 8f76e1455b7954e0c31c6c8f8a81b1eb0e9fc521 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 22 Jul 2023 15:07:35 +0700 Subject: [PATCH 0816/1199] =?UTF-8?q?=D0=BC=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/block/entity/MatteryBlockEntity.kt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) 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 75517e9c3..4577c8cee 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 @@ -219,9 +219,8 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc if (value !== field) { field = value - if (value.isPresent) - for (tracker in listeners) - tracker.accept(value) + for (tracker in listeners) + tracker.accept(value) } } @@ -229,9 +228,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc fun addListener(listener: Consumer>) { listeners.add(listener) - - if (value.isPresent) - listener.accept(value) + listener.accept(value) } override fun get(): LazyOptional { From be802d16742d761b77822858cdcd42c811206a01 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 22 Jul 2023 20:31:53 +0700 Subject: [PATCH 0817/1199] Balance furnace inputs before ticking jobs --- .../mc/otm/block/entity/tech/PoweredFurnaceBlockEntity.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 7d04fe739..afcdcdaac 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 @@ -75,11 +75,11 @@ class PoweredFurnaceBlockEntity( private val combined = CombinedContainer(inputs) override fun tick() { - super.tick() - if (balanceInputs) { combined.balance() } + + super.tick() } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { From 478503e727512407d937302905f516aca946b6d9 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 23 Jul 2023 13:04:04 +0700 Subject: [PATCH 0818/1199] Update default plate press config values, and allow consumption and work speed to be configured --- .../mc/otm/block/entity/tech/PlatePressBlockEntity.kt | 8 ++------ .../kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt | 8 +++++++- 2 files changed, 9 insertions(+), 7 deletions(-) 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 ea539f9fb..e973cc320 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 @@ -103,8 +103,8 @@ class PlatePressBlockEntity( return JobContainer.success( MachineItemJob( recipe.getResultItem(level.registryAccess()).copyWithCount(toProcess), - recipe.workTime.toDouble(), - BASELINE_CONSUMPTION * toProcess, + recipe.workTime * MachinesConfig.PLATE_PRESS.workTimeMultiplier, + MachinesConfig.PLATE_PRESS.powerConsumption * toProcess, experience = recipe.experience.sample(level.random) * toProcess)) } @@ -115,8 +115,4 @@ class PlatePressBlockEntity( super.tick() } - - companion object { - private val BASELINE_CONSUMPTION = Decimal(15) - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt index 65bdf5a4c..a9ec45aff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt @@ -25,7 +25,13 @@ object MachinesConfig : AbstractConfig("machines") { MatterReconstructorBlockEntity.registerConfig(builder) } - val PLATE_PRESS = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.PLATE_PRESS) + val PLATE_PRESS = workerValues( + MNames.PLATE_PRESS, + storage = Decimal(40_000), + throughput = Decimal(200), + powerConsumption = Decimal(15) + ) + val STORAGE_POWER_SUPPLIER = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.STORAGE_POWER_SUPPLIER, capacity = Decimal(100_000), throughput = Decimal(320)) val STORAGE_INTERFACES = BlockEnergyStorageImpl.makeConfigEntry(builder, "STORAGE_INTERFACES", capacity = Decimal(10_000)) val ITEM_MONITOR = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.ITEM_MONITOR) From 94acd585166314392e2b0b97e1f54ecd54fe0a8d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 23 Jul 2023 14:46:48 +0700 Subject: [PATCH 0819/1199] Add exopack upgrades to recipe catalysts --- src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt index d764f12df..6a7ace4cd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt @@ -66,8 +66,10 @@ class JEIPlugin : IModPlugin { override fun registerRecipeCatalysts(registration: IRecipeCatalystRegistration) { registration.addRecipeCatalyst(ItemStack(MItems.CHEMICAL_GENERATOR), RecipeTypes.FUELING) registration.addRecipeCatalyst(ItemStack(MItems.POWERED_FURNACE), RecipeTypes.SMELTING) + registration.addRecipeCatalyst(ItemStack(MItems.ExopackUpgrades.SMELTING_UPGRADE), RecipeTypes.SMELTING) registration.addRecipeCatalyst(ItemStack(MItems.POWERED_BLAST_FURNACE), RecipeTypes.BLASTING) registration.addRecipeCatalyst(ItemStack(MItems.POWERED_SMOKER), RecipeTypes.SMOKING) + registration.addRecipeCatalyst(ItemStack(MItems.ExopackUpgrades.CRAFTING_UPGRADE), RecipeTypes.CRAFTING) registration.addRecipeCatalyst(ItemStack(MItems.PLATE_PRESS), PlatePressRecipeCategory.recipeType) } From 7eec1c70321badda5a82114a990578c5487c1f85 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 23 Jul 2023 16:02:59 +0700 Subject: [PATCH 0820/1199] Don't allow to prime primed hammer --- .../dbotthepony/mc/otm/recipe/ExplosiveHammerPrimingRecipe.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 3cf34752d..ad4687512 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/ExplosiveHammerPrimingRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/ExplosiveHammerPrimingRecipe.kt @@ -38,7 +38,7 @@ class ExplosiveHammerPrimingRecipe(private val _id: ResourceLocation, val payloa override fun matches(pContainer: CraftingContainer, pLevel: Level): Boolean { val result = pContainer.stream().filter { it.isNotEmpty }.toList() if (result.size != 3) return false - return result.any { it.item is ExplosiveHammerItem } && + return result.any { it.item is ExplosiveHammerItem && !(it.item as ExplosiveHammerItem).isPrimed(it) } && result.any { it.`is`(Tags.Items.GUNPOWDER) } && result.any { payload.test(it) } } From 8c83cce40d0c1aea2ed69747b394c8ea1845dfe2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 23 Jul 2023 16:56:49 +0700 Subject: [PATCH 0821/1199] Add close buttons to matter task monitor --- .../mc/otm/client/screen/matter/MatterPanelScreen.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 0ac028c7d..2e0462994 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 @@ -253,7 +253,7 @@ class MatterPanelScreen( private fun openTask(task: IReplicationTask<*>): FramePanel { val frame = FramePanel.padded(this, null, 170f, 20f, TranslatableComponent("otm.gui.matter_panel.task")) - frame.closeOnEscape = true + frame.behaveAsWindow() object : AbstractSlotPanel(this@MatterPanelScreen, frame) { init { @@ -299,7 +299,7 @@ class MatterPanelScreen( private fun openPattern(pattern: IPatternState): FramePanel { val frame = FramePanel.padded(this, null, 213f, (ButtonPanel.HEIGHT + 3f) * 4f + 38f, TranslatableComponent("otm.gui.matter_panel.task")) - frame.closeOnEscape = true + frame.behaveAsWindow() val rowTop = EditablePanel(this, frame, height = ButtonPanel.HEIGHT) val rowInput = EditablePanel(this, frame, height = ButtonPanel.HEIGHT) From ad54cfeb9b2942e74b476daf86d36c00b02bebbc Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 23 Jul 2023 17:43:09 +0700 Subject: [PATCH 0822/1199] Reflect new tritanium block recipe in advancement tree --- .../dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt index 6625eaf74..0bc661bff 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt @@ -420,7 +420,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .save(serializer, modLocation("regular/cargo_crate2"), existingFileHelper) val tritaniumBlock = AdvancementBuilder() - .parent(plate) + .parent(ingot) .display( itemStack = ItemStack(MRegistry.TRITANIUM_BLOCK.item), title = translation.add("tritanium_block", "Cold, Impregnable Wall") { From 7ba96185e598ba9fad10dd7fbef1e2488c482e6d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 23 Jul 2023 17:56:14 +0700 Subject: [PATCH 0823/1199] Make ObservedConfigValue implement GetterSetter --- .../ru/dbotthepony/mc/otm/config/ObservedConfigValue.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ObservedConfigValue.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ObservedConfigValue.kt index 6f8caa5e4..a2a97bfa9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ObservedConfigValue.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ObservedConfigValue.kt @@ -2,12 +2,13 @@ package ru.dbotthepony.mc.otm.config import net.minecraftforge.common.ForgeConfigSpec.ConfigValue import org.apache.logging.log4j.LogManager +import ru.dbotthepony.mc.otm.core.GetterSetter import java.util.function.Consumer import java.util.function.Supplier import kotlin.properties.ReadWriteProperty import kotlin.reflect.KProperty -abstract class ObservedConfigValue(val parent: ConfigValue) : ReadWriteProperty, Supplier, Consumer { +abstract class ObservedConfigValue(val parent: ConfigValue) : GetterSetter { var rawValue: String by parent private var observedValue: String? = null private var cachedValue: V? = null @@ -43,7 +44,7 @@ abstract class ObservedConfigValue(val parent: ConfigValue) : R return cachedValue ?: throw ConcurrentModificationException() } - override fun getValue(thisRef: Any, property: KProperty<*>): V { + override fun getValue(thisRef: Any?, property: KProperty<*>): V { return get() } @@ -64,7 +65,7 @@ abstract class ObservedConfigValue(val parent: ConfigValue) : R } } - override fun setValue(thisRef: Any, property: KProperty<*>, value: V) { + override fun setValue(thisRef: Any?, property: KProperty<*>, value: V) { accept(value) } From 636f99740abb1a6748c8f21de68ec2047502efaa Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 23 Jul 2023 18:22:26 +0700 Subject: [PATCH 0824/1199] Allow to undefine work speed in config value --- .../kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt index 3beed9f61..08e49467c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt @@ -4,6 +4,8 @@ import net.minecraftforge.common.ForgeConfigSpec import net.minecraftforge.fml.ModLoadingContext import net.minecraftforge.fml.config.ModConfig import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.core.GetterSetter +import ru.dbotthepony.mc.otm.core.getValue import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.core.util.WriteOnce @@ -56,14 +58,14 @@ abstract class AbstractConfig(private val configName: String, private val type: return obj } - fun workerValues(name: String, storage: Decimal, throughput: Decimal, workTimeMultiplier: Double = 1.0, powerConsumption: Decimal, configurator: ForgeConfigSpec.Builder.() -> Unit = {}): WorkerBalanceValues { + fun workerValues(name: String, storage: Decimal, throughput: Decimal, workTimeMultiplier: Double? = 1.0, powerConsumption: Decimal, configurator: ForgeConfigSpec.Builder.() -> Unit = {}): WorkerBalanceValues { builder.push(name) val obj = object : WorkerBalanceValues { override val capacity: Decimal by builder.defineDecimal("capacity", storage, minimum = Decimal.ONE) override val throughput: Decimal by builder.defineDecimal("throughput", throughput, minimum = Decimal.ONE) override val powerConsumption: Decimal by builder.defineDecimal("powerConsumption", powerConsumption, minimum = Decimal.ONE) - override val workTimeMultiplier: Double by builder.defineInRange("workTimeMultiplier", workTimeMultiplier, 0.0) + override val workTimeMultiplier: Double by (if (workTimeMultiplier == null) GetterSetter.box(1.0) else builder.defineInRange("workTimeMultiplier", workTimeMultiplier, 0.0)) } configurator.invoke(builder) From a2f5f72aa849138c4c9b910677d2f9954204c868 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 23 Jul 2023 18:22:30 +0700 Subject: [PATCH 0825/1199] Update config values for matter recycler block entity --- .../matter/MatterRecyclerBlockEntity.kt | 55 +++++++++---------- .../mc/otm/config/MachinesConfig.kt | 21 ++++++- 2 files changed, 45 insertions(+), 31 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index fd31b7739..b47136e3f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -22,6 +22,7 @@ import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage +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.math.Decimal @@ -66,11 +67,11 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) } } - val matter = ProfiledMatterStorage(MatterStorageImpl(::matterLevelUpdated, FlowDirection.OUTPUT, ::CAPACITY)) + val matter = ProfiledMatterStorage(MatterStorageImpl(::matterLevelUpdated, FlowDirection.OUTPUT, MachinesConfig.MATTER_RECYCLER_CAPACITY::get)) val container = MatteryContainer(::itemContainerUpdated, 1).also(::addDroppableContainer) val matterNode = SimpleMatterNode(matter = matter) - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::energyLevelUpdated, ENERGY_CONFIG)) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::energyLevelUpdated, MachinesConfig.MATTER_RECYCLER)) val itemConfig = ConfigurableItemHandler(input = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { @@ -108,7 +109,16 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) } override fun onJobFinish(job: RecyclerJob, id: Int): JobStatus { - // вся логика в onWorkTick + if (job.totalMatter.isPositive) { + val received = matter.receiveMatter(job.totalMatter, true) + + if (job.totalMatter != received) + return JobStatus.FAILURE_MATTER + + matter.receiveMatter(job.totalMatter, false) + job.totalMatter -= received + } + return JobStatus.SUCCESS } @@ -122,13 +132,23 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) return JobContainer.noItem() val dustMatter = (stack.item as MatterDustItem).getMatterValue(stack.copy().also { it.count = 1 }) ?: return JobContainer.noItem() + stack.shrink(1) container.setChanged(0) - return JobContainer.success(RecyclerJob(dustMatter.matter.toDouble() * TICKS_PER_MATTER, POWER_CONSUMPTION, dustMatter.matter * (0.4 + level!!.random.nextDouble() * 0.6))) + + val actualMatter = dustMatter.matter * (0.4 + level!!.random.nextDouble() * 0.6) + + return JobContainer.success( + RecyclerJob( + (actualMatter / MachinesConfig.MATTER_RECYCLER_MATTER_PER_TICK.get()).toDouble(), + MachinesConfig.MATTER_RECYCLER.powerConsumption, + actualMatter + ) + ) } override fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: RecyclerJob, id: Int): JobStatus { - val receive = job.totalMatter / job.ticks + val receive = job.totalMatter.coerceAtMost(MachinesConfig.MATTER_RECYCLER_MATTER_PER_TICK.get() * ticksAdvanced) if (receive.isZero) return JobStatus.SUCCESS @@ -153,29 +173,4 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) matter.extractMatter(received, false) } } - - companion object { - private var _CAPACITY: DecimalConfigValue by WriteOnce() - private var _POWER_CONSUMPTION: DecimalConfigValue by WriteOnce() - private var _TICKS_PER_MATTER: ConfigValue by WriteOnce() - - var ENERGY_CONFIG: ConciseBalanceValues by WriteOnce() - private set - - private val CAPACITY get() = _CAPACITY.get() - private val POWER_CONSUMPTION get() = _POWER_CONSUMPTION.get() - private val TICKS_PER_MATTER: Double get() = _TICKS_PER_MATTER.get() - - fun registerConfig(builder: ForgeConfigSpec.Builder) { - builder.push(MNames.MATTER_RECYCLER) - - ENERGY_CONFIG = BlockEnergyStorageImpl.makeConfigEntry(builder, capacity = Decimal(80_000)) - - _CAPACITY = builder.defineDecimal("matterCapacity", Decimal(500), Decimal.ONE) - _POWER_CONSUMPTION = builder.defineDecimal("powerConsumption", Decimal(80), Decimal.ONE) - _TICKS_PER_MATTER = builder.define("ticksPerMatter", 2.0) - - builder.pop() - } - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt index a9ec45aff..37e82edf8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.config +import net.minecraftforge.common.ForgeConfigSpec.ConfigValue import ru.dbotthepony.mc.otm.block.entity.matter.MatterReconstructorBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterDecomposerBlockEntity @@ -10,14 +11,15 @@ import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.ChemicalGeneratorBlockEntity import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal +import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.registry.MNames object MachinesConfig : AbstractConfig("machines") { init { AndroidStationBlockEntity.registerConfig(builder) ChemicalGeneratorBlockEntity.registerConfig(builder) - MatterRecyclerBlockEntity.registerConfig(builder) MatterBottlerBlockEntity.registerConfig(builder) MatterReplicatorBlockEntity.registerConfig(builder) MatterScannerBlockEntity.registerConfig(builder) @@ -32,6 +34,23 @@ object MachinesConfig : AbstractConfig("machines") { powerConsumption = Decimal(15) ) + var MATTER_RECYCLER_MATTER_PER_TICK: DecimalConfigValue by WriteOnce() + private set + + var MATTER_RECYCLER_CAPACITY: DecimalConfigValue by WriteOnce() + private set + + val MATTER_RECYCLER = workerValues( + MNames.MATTER_RECYCLER, + storage = Decimal(80_000), + throughput = Decimal(400), + powerConsumption = Decimal(100), + workTimeMultiplier = null + ) { + MATTER_RECYCLER_MATTER_PER_TICK = defineDecimal("MATTER_PER_TICK", Decimal("0.5")) + MATTER_RECYCLER_CAPACITY = defineDecimal("MATTER_CAPACITY", Decimal(400), Decimal.ONE) + } + val STORAGE_POWER_SUPPLIER = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.STORAGE_POWER_SUPPLIER, capacity = Decimal(100_000), throughput = Decimal(320)) val STORAGE_INTERFACES = BlockEnergyStorageImpl.makeConfigEntry(builder, "STORAGE_INTERFACES", capacity = Decimal(10_000)) val ITEM_MONITOR = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.ITEM_MONITOR) From e9f982eb6b6cdd9e066a4dc0faff7e087f2c2f97 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 23 Jul 2023 23:59:55 +0700 Subject: [PATCH 0826/1199] Redo text rendering as single function and revisit render gravity --- .../mc/otm/client/AndroidMenuKeyMapping.kt | 12 +- .../dbotthepony/mc/otm/client/MatteryGUI.kt | 34 +- .../dbotthepony/mc/otm/client/render/Ext.kt | 412 +++++++++++------- .../mc/otm/client/render/RenderGravity.kt | 312 +++++++------ .../render/blockentity/BlackHoleRenderer.kt | 8 +- .../blockentity/EnergyCounterRenderer.kt | 17 +- .../GravitationStabilizerRenderer.kt | 18 +- .../render/blockentity/HoloSignRenderer.kt | 5 +- .../client/screen/matter/MatterPanelScreen.kt | 5 +- .../otm/client/screen/panels/ColorPicker.kt | 4 +- .../client/screen/panels/EffectListPanel.kt | 10 +- .../mc/otm/client/screen/panels/FramePanel.kt | 4 +- .../mc/otm/client/screen/panels/Label.kt | 44 +- .../screen/panels/button/ButtonPanel.kt | 4 +- .../screen/panels/input/TextInputPanel.kt | 30 +- .../screen/tech/AndroidStationScreen.kt | 2 +- .../screen/tech/EssenceStorageScreen.kt | 2 +- .../compat/jei/PlatePressRecipeCategory.kt | 6 +- .../ru/dbotthepony/mc/otm/core/math/Colors.kt | 2 + .../dbotthepony/mc/otm/core/math/MatrixExt.kt | 4 +- .../mc/otm/item/weapon/AbstractWeaponItem.kt | 4 +- 21 files changed, 525 insertions(+), 414 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt index 8c1ca9854..6dd666d48 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt @@ -14,8 +14,9 @@ import ru.dbotthepony.mc.otm.android.AndroidFeature import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.render.RenderGravity -import ru.dbotthepony.mc.otm.client.render.drawAligned +import ru.dbotthepony.mc.otm.client.render.draw import ru.dbotthepony.mc.otm.client.render.drawArc +import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.angleDifference import ru.dbotthepony.mc.otm.core.math.normalizeAngle @@ -257,15 +258,16 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon val shift = size * 0.6f feature.renderIcon(event.guiGraphics, -iconSize / 2f + shift * cos, -shift * sin - iconSize / 2f, iconSize, iconSize) - event.guiGraphics.drawAligned(minecraft.font, feature.type.displayName, RenderGravity.CENTER_CENTER, shift * cos + 1f, -shift * sin - iconSize / 1.5f + 1f, 0) - event.guiGraphics.drawAligned(minecraft.font, feature.type.displayName, RenderGravity.CENTER_CENTER, shift * cos, -shift * sin - iconSize / 1.5f, if (feature.isActive) RGBAColor.DARK_GREEN else RGBAColor.DARK_RED) + + event.guiGraphics.draw(minecraft.font, feature.type.displayName, shift * cos + 1f, -shift * sin - iconSize / 1.5f + 1f, color = RGBAColor.BLACK, gravity = RenderGravity.CENTER_CENTER) + event.guiGraphics.draw(minecraft.font, feature.type.displayName, shift * cos, -shift * sin - iconSize / 1.5f, color = if (feature.isActive) RGBAColor.DARK_GREEN else RGBAColor.DARK_RED, gravity = RenderGravity.CENTER_CENTER) if (feature.isOnCooldown && feature.cooldownPercent > 0.0f) { RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f) drawArc(event.guiGraphics, shift * cos, -shift * sin, iconSize / 2f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * feature.cooldownPercent.toDouble()) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) - event.guiGraphics.drawAligned(minecraft.font, formatTickDuration(feature.cooldown), RenderGravity.CENTER_CENTER, shift * cos, -shift * sin + iconSize / 1.5f, RGBAColor.WHITE) + event.guiGraphics.draw(minecraft.font, formatTickDuration(feature.cooldown), shift * cos, -shift * sin + iconSize / 1.5f, color = RGBAColor.WHITE, gravity = RenderGravity.CENTER_CENTER) } } @@ -302,7 +304,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon drawArc(event.guiGraphics, x, y, COOLDOWN_ICON_SIZE / 2f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * feature.cooldownPercent, alignAtCenter = false) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) - event.guiGraphics.drawAligned(font, formatTickDuration(feature.cooldown), RenderGravity.TOP_CENTER, x + COOLDOWN_ICON_SIZE / 2f, y + COOLDOWN_ICON_SIZE + 1f, RGBAColor.WHITE) + event.guiGraphics.draw(font, formatTickDuration(feature.cooldown), x + COOLDOWN_ICON_SIZE / 2f, y + COOLDOWN_ICON_SIZE + 1f, color = RGBAColor.WHITE, gravity = RenderGravity.TOP_CENTER) x += COOLDOWN_ICON_SIZE + COOLDOWN_ICON_MARGIN } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index 11bd4aad9..8f3529a79 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -23,6 +23,7 @@ import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.config.ClientConfig +import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.core.ifPresentK @@ -164,8 +165,8 @@ object MatteryGUI { val text = TranslatableComponent("otm.iteration", iteration) - minecraft.font.drawAligned(stack, text, RenderGravity.CENTER_CENTER, x + 1f, y + 1f, RGBAColor.BLACK) - minecraft.font.drawAligned(stack, text, RenderGravity.CENTER_CENTER, x, y, RGBAColor.WHITE) + event.guiGraphics.draw(minecraft.font, text, x + 1f, y + 1f, color = RGBAColor.BLACK, gravity = RenderGravity.CENTER_CENTER) + event.guiGraphics.draw(minecraft.font, text, x, y, color = RGBAColor.WHITE, gravity = RenderGravity.CENTER_CENTER) stack.scale(0.35f, 0.35f, 0.35f) @@ -181,8 +182,8 @@ object MatteryGUI { for (i in deathLog.indices.reversed()) { val component = deathLog[i] - minecraft.font.drawAligned(stack, component.second, RenderGravity.CENTER_CENTER, x + 1f, y + 1f, RGBAColor.BLACK) - minecraft.font.drawAligned(stack, component.second, RenderGravity.CENTER_CENTER, x, y, RGBAColor(color, color, color)) + event.guiGraphics.draw(minecraft.font, component.second, x + 1f, y + 1f, color = RGBAColor.BLACK, gravity = RenderGravity.CENTER_CENTER) + event.guiGraphics.draw(minecraft.font, component.second, x, y, color = RGBAColor(color, color, color), gravity = RenderGravity.CENTER_CENTER) y += minecraft.font.lineHeight color = (color - 0x20).coerceAtLeast(0x0) @@ -253,8 +254,8 @@ object MatteryGUI { val formattedPower = mattery.androidEnergy.batteryLevel.formatPower() - event.guiGraphics.drawScaledAligned(gui.font, formattedPower, 0.5f, RenderGravity.CENTER_LEFT, left + 83f, top + 4f, RGBAColor.BLACK.toRGB()) - event.guiGraphics.drawScaledAligned(gui.font, formattedPower, 0.5f, RenderGravity.CENTER_LEFT, left + 82f, top + 3f, RGBAColor.YELLOW.toRGB()) + event.guiGraphics.draw(gui.font, formattedPower, left + CHARGE_BG.width + 2f, top + CHARGE_BG.height / 2f + 1f, scale = 0.5f, gravity = RenderGravity.CENTER_LEFT, color = RGBAColor.BLACK) + event.guiGraphics.draw(gui.font, formattedPower, left + CHARGE_BG.width + 1f, top + CHARGE_BG.height / 2f, scale = 0.5f, gravity = RenderGravity.CENTER_LEFT, color = RGBAColor.YELLOW) } } @@ -270,16 +271,16 @@ object MatteryGUI { return HEALTH } - private fun getHealthColorForPlayer(player: Player): Int { + private fun getHealthColorForPlayer(player: Player): RGBAColor { if (player.hasEffect(MobEffects.POISON)) { - return RGBAColor.DARK_GREEN.toRGB() + return RGBAColor.DARK_GREEN } else if (player.hasEffect(MobEffects.WITHER)) { - return RGBAColor.WHITE.toRGB() + return RGBAColor.WHITE } else if (player.isFullyFrozen) { - return RGBAColor.AQUA.toRGB() + return RGBAColor.AQUA } - return RGBAColor.RED.toRGB() + return RGBAColor.RED } // можно вынести в конфиг, но для этого нужен селектор цвета private fun renderPlayerHealth(event: RenderGuiOverlayEvent.Pre, gui: ForgeGui) { @@ -325,12 +326,13 @@ object MatteryGUI { HEALTH_ABSORB.renderPartial(event.guiGraphics, left.toFloat(), top.toFloat(), width = ceil(levelAbsorb * 80f - 0.5f)) } - var formattedHealth = "%d/%d".format(ply.health.toInt(), ply.maxHealth.toInt()) - if (ply.absorptionAmount > 0) - formattedHealth = "%d+%d/%d".format(ply.health.toInt(), ply.absorptionAmount.toInt(), ply.maxHealth.toInt()) + var formattedHealth = TextComponent("%d/%d".format(ply.health.toInt(), ply.maxHealth.toInt())) - event.guiGraphics.drawScaledAligned(minecraft.font, formattedHealth, 0.5f, RenderGravity.CENTER_RIGHT, left - 4f, top + 4f, RGBAColor.BLACK.toRGB()) - event.guiGraphics.drawScaledAligned(minecraft.font, formattedHealth, 0.5f, RenderGravity.CENTER_RIGHT, left - 5f, top + 3f, getHealthColorForPlayer(ply)) + if (ply.absorptionAmount > 0) + formattedHealth = TextComponent("%d+%d/%d".format(ply.health.toInt(), ply.absorptionAmount.toInt(), ply.maxHealth.toInt())) + + event.guiGraphics.draw(minecraft.font, formattedHealth, left - 1f, top + HEALTH_BG.height / 2f + 1f, scale = 0.5f, gravity = RenderGravity.CENTER_RIGHT, color = RGBAColor.BLACK) + event.guiGraphics.draw(minecraft.font, formattedHealth, left - 2f, top + HEALTH_BG.height / 2f, scale = 0.5f, gravity = RenderGravity.CENTER_RIGHT, color = getHealthColorForPlayer(ply)) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt index 4f913442f..82bd449f4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt @@ -15,6 +15,9 @@ import org.joml.Vector3f import ru.dbotthepony.mc.otm.core.math.IAngle import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.Vector +import ru.dbotthepony.mc.otm.core.math.component1 +import ru.dbotthepony.mc.otm.core.math.component2 +import ru.dbotthepony.mc.otm.core.math.component3 import ru.dbotthepony.mc.otm.core.math.rotateAroundPoint import ru.dbotthepony.mc.otm.core.math.rotateAroundThis import ru.dbotthepony.mc.otm.core.math.times @@ -67,200 +70,289 @@ fun PoseStack.translation(): Vector3f { inline val PoseStack.last: PoseStack.Pose get() = last() inline val PoseStack.Pose.pose: Matrix4f get() = pose() -private fun Font.drawScaledDuckTyped(poseStack: PoseStack, text: Any, scale: Float, x: Float, y: Float, color: Int): Int { - val translation = poseStack.translation() - - poseStack.pushPose() - poseStack.translate(-translation) - poseStack.scale(scale, scale, scale) - val inv = 1f / scale - poseStack.translate(translation * inv) - val size = drawDuckTyped(poseStack, text, x * inv, y * inv, color) - poseStack.popPose() - - return size -} - -private fun Font.drawScaledDuckTyped(poseStack: PoseStack, buffer: MultiBufferSource, text: Any, scale: Float, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0): Int { - val translation = poseStack.translation() - - poseStack.pushPose() - poseStack.translate(-translation) - poseStack.scale(scale, scale, scale) - val inv = 1f / scale - val size = drawDuckTyped(poseStack, buffer, text, x * inv, y * inv, color, drawShadow, displayMode, packedLightCoords, effectColor) - poseStack.popPose() - - return size -} - private val buffer = DynamicBufferSource(vertexSorting = VertexSorting.ORTHOGRAPHIC_Z) +private fun buffer() = buffer -private fun Font.drawDuckTyped(poseStack: PoseStack, text: Any, x: Float, y: Float, color: Int): Int { - val width = drawDuckTyped(poseStack, buffer, text, x, y, color) - buffer.endBatch() - return width -} - -private fun Font.drawDuckTyped( +private fun Font.drawInternal( poseStack: PoseStack, - buffer: MultiBufferSource, text: Any, x: Float, y: Float, - color: Int, - drawShadow: Boolean = false, - displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, - packedLightCoords: Int = 15728880, - effectColor: Int = 0 -): Int { - if (drawShadow) { + buffer: MultiBufferSource, + gravity: RenderGravity, + scale: Float, + color: RGBAColor, + drawShadow: Boolean, + displayMode: Font.DisplayMode, + packedLightCoords: Int, + effectColor: Int, + shadowColor: RGBAColor, + shadowX: Float, + shadowY: Float, + shadowZ: Float, + customShadow: Boolean, + rounding: GravityRounding, +): Float { + require(!drawShadow && !customShadow || drawShadow != customShadow) { "Can not draw built in shadow and custom shadow at the same time" } + + val inv: Float + + if (scale != 1f) { poseStack.pushPose() + + val (_x, _y, _z) = poseStack.translation() + + poseStack.translate(-_x, -_y, -_z) + poseStack.scale(scale, scale, scale) + inv = 1f / scale + poseStack.translate(_x * inv, _y * inv, _z * inv) + } else { + inv = 1f } - val result = when (text) { - is Component -> drawInBatch(text, x, y, color, drawShadow, poseStack.last().pose(), buffer, displayMode, effectColor, packedLightCoords) - is String -> drawInBatch(text, x, y, color, drawShadow, poseStack.last().pose(), buffer, displayMode, effectColor, packedLightCoords) - is FormattedCharSequence -> drawInBatch(text, x, y, color, drawShadow, poseStack.last().pose(), buffer, displayMode, effectColor, packedLightCoords) - else -> throw ClassCastException(text::class.qualifiedName) + if (customShadow) { + if (shadowZ != 0f) { + poseStack.translate(0f, 0f, shadowZ) + } + + if (text is String) + drawInBatch( + text, + gravity.x((x + shadowX) * inv, this, text, 1f, rounding), + gravity.y((y + shadowY) * inv, lineHeight.toFloat(), 1f, rounding), + shadowColor.toRGB(), + false, + poseStack.last().pose(), + buffer, + displayMode, + effectColor, + packedLightCoords) + else if (text is Component) + drawInBatch( + text, + gravity.x((x + shadowX) * inv, this, text, 1f, rounding), + gravity.y((y + shadowY) * inv, lineHeight.toFloat(), 1f, rounding), + shadowColor.toRGB(), + false, + poseStack.last().pose(), + buffer, + displayMode, + effectColor, + packedLightCoords) + + if (shadowZ != 0f) { + poseStack.translate(0f, 0f, -shadowZ) + } } - if (drawShadow) { + val width: Int + + if (text is String) + width = drawInBatch( + text, + gravity.x(x * inv, this, text, 1f, rounding), + gravity.y(y * inv, lineHeight.toFloat(), 1f, rounding), + color.toRGB(), + drawShadow, + poseStack.last().pose(), + buffer, + displayMode, + effectColor, + packedLightCoords) + else if (text is Component) + width = drawInBatch( + text, + gravity.x(x * inv, this, text, 1f, rounding), + gravity.y(y * inv, lineHeight.toFloat(), 1f, rounding), + color.toRGB(), + drawShadow, + poseStack.last().pose(), + buffer, + displayMode, + effectColor, + packedLightCoords) + else + throw IllegalArgumentException(text::class.qualifiedName) + + if (scale != 1f) { poseStack.popPose() } - return result -} - -private fun Font.widthDuckTyped(text: Any): Int { - return when (text) { - is Component -> width(text) - is String -> width(text) - is FormattedCharSequence -> width(text) - else -> throw ClassCastException(text::class.qualifiedName) + if (buffer === buffer()) { + buffer.endBatch() } + + return width * scale } -private fun Font.drawAlignedDuckTyped(poseStack: PoseStack, text: Any, align: RenderGravity, x: Float, y: Float, color: Int): Int { - return drawDuckTyped(poseStack, text, align.x(x, widthDuckTyped(text)), align.y(y, lineHeight), color) -} - -private fun Font.drawAlignedDuckTyped( +fun Font.draw( poseStack: PoseStack, - buffer: MultiBufferSource, - text: Any, - align: RenderGravity, - x: Float, - y: Float, - color: Int, + text: Component, + x: Float = 0f, + y: Float = 0f, + buffer: MultiBufferSource = buffer(), + gravity: RenderGravity = RenderGravity.TOP_LEFT, + scale: Float = 1f, + color: RGBAColor = RGBAColor.WHITE, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, - effectColor: Int = 0 -): Int { - return drawDuckTyped(poseStack, buffer, text, align.x(x, widthDuckTyped(text)), align.y(y, lineHeight), color, drawShadow, displayMode, packedLightCoords, effectColor) + effectColor: Int = 0, + shadowColor: RGBAColor = RGBAColor.BLACK, + shadowX: Float = 1f, + shadowY: Float = 1f, + shadowZ: Float = 0f, + customShadow: Boolean = false, + rounding: GravityRounding = if (scale == 1f) GravityRounding.DEFAULT else GravityRounding.NO, +): Float { + return drawInternal( + poseStack = poseStack, + text = text, + x = x, + y = y, + buffer = buffer, + gravity = gravity, + scale = scale, + color = color, + drawShadow = drawShadow, + displayMode = displayMode, + packedLightCoords = packedLightCoords, + effectColor = effectColor, + shadowColor = shadowColor, + shadowX = shadowX, + shadowY = shadowY, + shadowZ = shadowZ, + customShadow = customShadow, + rounding = rounding, + ) } -private fun GuiGraphics.drawAlignedDuckTyped( - font: Font, - text: Any, - align: RenderGravity, - x: Float, - y: Float, - color: Int, +fun Font.draw( + poseStack: PoseStack, + text: String, + x: Float = 0f, + y: Float = 0f, + buffer: MultiBufferSource = buffer(), + gravity: RenderGravity = RenderGravity.TOP_LEFT, + scale: Float = 1f, + color: RGBAColor = RGBAColor.WHITE, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, - effectColor: Int = 0 -): Int { - val width = font.drawDuckTyped(pose(), bufferSource(), text, align.x(x, font.widthDuckTyped(text)), align.y(y, font.lineHeight), color, drawShadow, displayMode, packedLightCoords, effectColor) + effectColor: Int = 0, + shadowColor: RGBAColor = RGBAColor.BLACK, + shadowX: Float = 1f, + shadowY: Float = 1f, + shadowZ: Float = 0f, + customShadow: Boolean = false, + rounding: GravityRounding = if (scale == 1f) GravityRounding.DEFAULT else GravityRounding.NO, +): Float { + return drawInternal( + poseStack = poseStack, + text = text, + x = x, + y = y, + buffer = buffer, + gravity = gravity, + scale = scale, + color = color, + drawShadow = drawShadow, + displayMode = displayMode, + packedLightCoords = packedLightCoords, + effectColor = effectColor, + shadowColor = shadowColor, + shadowX = shadowX, + shadowY = shadowY, + shadowZ = shadowZ, + customShadow = customShadow, + rounding = rounding + ) +} + +fun GuiGraphics.draw( + font: Font, + text: Component, + x: Float = 0f, + y: Float = 0f, + gravity: RenderGravity = RenderGravity.TOP_LEFT, + scale: Float = 1f, + color: RGBAColor = RGBAColor.WHITE, + drawShadow: Boolean = false, + displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, + packedLightCoords: Int = 15728880, + effectColor: Int = 0, + shadowColor: RGBAColor = RGBAColor.BLACK, + shadowX: Float = 0f, + shadowY: Float = 0f, + shadowZ: Float = 0f, + customShadow: Boolean = false, + rounding: GravityRounding = if (scale == 1f) GravityRounding.DEFAULT else GravityRounding.NO, +): Float { + val width = font.draw( + poseStack = pose(), + text = text, + x = x, + y = y, + buffer = bufferSource(), + gravity = gravity, + scale = scale, + color = color, + drawShadow = drawShadow, + displayMode = displayMode, + packedLightCoords = packedLightCoords, + effectColor = effectColor, + shadowColor = shadowColor, + shadowX = shadowX, + shadowY = shadowY, + shadowZ = shadowZ, + customShadow = customShadow, + rounding = rounding, + ) + flush() return width } -private fun Font.drawScaledAlignedDuckTyped(poseStack: PoseStack, text: Any, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int): Int { - return drawScaledDuckTyped(poseStack, text, scale, align.x(x, widthDuckTyped(text)), align.y(y, lineHeight * scale), color) -} - -private fun Font.drawScaledAlignedDuckTyped( - poseStack: PoseStack, - buffer: MultiBufferSource, - text: Any, - scale: Float, - align: RenderGravity, - x: Float, - y: Float, - color: Int, - drawShadow: Boolean = false, - displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, - packedLightCoords: Int = 15728880, - effectColor: Int = 0 -): Int { - return drawScaledDuckTyped(poseStack, buffer, text, scale, align.x(x, widthDuckTyped(text) * scale), align.y(y, lineHeight * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) -} - -private fun GuiGraphics.drawScaledAlignedDuckTyped( +fun GuiGraphics.draw( font: Font, - text: Any, - scale: Float, - align: RenderGravity, - x: Float, - y: Float, - color: Int, + text: String, + x: Float = 0f, + y: Float = 0f, + gravity: RenderGravity = RenderGravity.TOP_LEFT, + scale: Float = 1f, + color: RGBAColor = RGBAColor.WHITE, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, - effectColor: Int = 0 -): Int { - val width = font.drawScaledDuckTyped(pose(), bufferSource(), text, scale, align.x(x, font.widthDuckTyped(text) * scale), align.y(y, font.lineHeight * scale), color, drawShadow, displayMode, packedLightCoords, effectColor) + effectColor: Int = 0, + shadowColor: RGBAColor = RGBAColor.BLACK, + shadowX: Float = 0f, + shadowY: Float = 0f, + shadowZ: Float = 0f, + customShadow: Boolean = false, + rounding: GravityRounding = if (scale == 1f) GravityRounding.DEFAULT else GravityRounding.NO, +): Float { + val width = font.draw( + poseStack = pose(), + text = text, + x = x, + y = y, + buffer = bufferSource(), + gravity = gravity, + scale = scale, + color = color, + drawShadow = drawShadow, + displayMode = displayMode, + packedLightCoords = packedLightCoords, + effectColor = effectColor, + shadowColor = shadowColor, + shadowX = shadowX, + shadowY = shadowY, + shadowZ = shadowZ, + customShadow = customShadow, + rounding = rounding, + ) + flush() return width } - -fun Font.drawAligned(poseStack: PoseStack, text: String, align: RenderGravity, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(poseStack, text, align, x, y, color) -fun Font.drawAligned(poseStack: PoseStack, text: Component, align: RenderGravity, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(poseStack, text, align, x, y, color) -fun Font.drawAligned(poseStack: PoseStack, text: FormattedCharSequence, align: RenderGravity, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(poseStack, text, align, x, y, color) - -fun Font.drawAligned(poseStack: PoseStack, text: String, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawAligned(poseStack, text, align, x, y, color.toRGB()) -fun Font.drawAligned(poseStack: PoseStack, text: Component, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawAligned(poseStack, text, align, x, y, color.toRGB()) -fun Font.drawAligned(poseStack: PoseStack, text: FormattedCharSequence, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawAligned(poseStack, text, align, x, y, color.toRGB()) - -fun Font.drawScaledAligned(poseStack: PoseStack, text: String, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(poseStack, text, scale, align, x, y, color) -fun Font.drawScaledAligned(poseStack: PoseStack, text: Component, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(poseStack, text, scale, align, x, y, color) -fun Font.drawScaledAligned(poseStack: PoseStack, text: FormattedCharSequence, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(poseStack, text, scale, align, x, y, color) - -fun Font.drawScaledAligned(poseStack: PoseStack, text: String, scale: Float, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(poseStack, text, scale, align, x, y, color.toRGB()) -fun Font.drawScaledAligned(poseStack: PoseStack, text: Component, scale: Float, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(poseStack, text, scale, align, x, y, color.toRGB()) -fun Font.drawScaledAligned(poseStack: PoseStack, text: FormattedCharSequence, scale: Float, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(poseStack, text, scale, align, x, y, color.toRGB()) - -fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, align: RenderGravity, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAlignedDuckTyped(poseStack, buffer, text, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, align: RenderGravity, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAlignedDuckTyped(poseStack, buffer, text, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, align: RenderGravity, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAlignedDuckTyped(poseStack, buffer, text, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) - -fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, align: RenderGravity, x: Float, y: Float, color: RGBAColor, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAligned(poseStack, buffer, text, align, x, y, color.toRGB(), drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, align: RenderGravity, x: Float, y: Float, color: RGBAColor, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAligned(poseStack, buffer, text, align, x, y, color.toRGB(), drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, align: RenderGravity, x: Float, y: Float, color: RGBAColor, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAligned(poseStack, buffer, text, align, x, y, color.toRGB(), drawShadow, displayMode, packedLightCoords, effectColor) - -fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0,) = drawScaledAlignedDuckTyped(poseStack, buffer, text, scale, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0,) = drawScaledAlignedDuckTyped(poseStack, buffer, text, scale, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0,) = drawScaledAlignedDuckTyped(poseStack, buffer, text, scale, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor) - -fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, scale: Float, align: RenderGravity, x: Float, y: Float, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toRGB(), drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, scale: Float, align: RenderGravity, x: Float, y: Float, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toRGB(), drawShadow, displayMode, packedLightCoords, effectColor) -fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, scale: Float, align: RenderGravity, x: Float, y: Float, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toRGB(), drawShadow, displayMode, packedLightCoords, effectColor) - -fun GuiGraphics.drawAligned(font: Font, text: String, align: RenderGravity, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(font, text, align, x, y, color) -fun GuiGraphics.drawAligned(font: Font, text: Component, align: RenderGravity, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(font, text, align, x, y, color) -fun GuiGraphics.drawAligned(font: Font, text: FormattedCharSequence, align: RenderGravity, x: Float, y: Float, color: Int) = drawAlignedDuckTyped(font, text, align, x, y, color) - -fun GuiGraphics.drawAligned(font: Font, text: String, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawAligned(font, text, align, x, y, color.toRGB()) -fun GuiGraphics.drawAligned(font: Font, text: Component, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawAligned(font, text, align, x, y, color.toRGB()) -fun GuiGraphics.drawAligned(font: Font, text: FormattedCharSequence, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawAligned(font, text, align, x, y, color.toRGB()) - -fun GuiGraphics.drawScaledAligned(font: Font, text: String, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(font, text, scale, align, x, y, color) -fun GuiGraphics.drawScaledAligned(font: Font, text: Component, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(font, text, scale, align, x, y, color) -fun GuiGraphics.drawScaledAligned(font: Font, text: FormattedCharSequence, scale: Float, align: RenderGravity, x: Float, y: Float, color: Int) = drawScaledAlignedDuckTyped(font, text, scale, align, x, y, color) - -fun GuiGraphics.drawScaledAligned(font: Font, text: String, scale: Float, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(font, text, scale, align, x, y, color.toRGB()) -fun GuiGraphics.drawScaledAligned(font: Font, text: Component, scale: Float, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(font, text, scale, align, x, y, color.toRGB()) -fun GuiGraphics.drawScaledAligned(font: Font, text: FormattedCharSequence, scale: Float, align: RenderGravity, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(font, text, scale, align, x, y, color.toRGB()) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderGravity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderGravity.kt index e3fbf8d71..8a8efb451 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderGravity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderGravity.kt @@ -1,5 +1,7 @@ package ru.dbotthepony.mc.otm.client.render +import net.minecraft.client.gui.Font +import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.core.FloatSupplier import kotlin.math.roundToInt @@ -7,178 +9,174 @@ private operator fun FloatSupplier.div(other: Float): Float { return getAsFloat() / other } +private operator fun FloatSupplier.times(other: Float): Float { + return getAsFloat() * other +} + private operator fun Float.minus(other: FloatSupplier): Float { return this - other.getAsFloat() } -enum class RenderGravity { - TOP_LEFT { - override fun x(x: Float, width: FloatSupplier): Float { - return x - } - - override fun y(y: Float, height: FloatSupplier): Float { - return y - } - - override fun x(x: Float, width: Float): Float { - return x - } - - override fun y(y: Float, height: Float): Float { - return y - } - }, - TOP_CENTER { - override fun x(x: Float, width: FloatSupplier): Float { - return x - width / 2f - } - - override fun y(y: Float, height: FloatSupplier): Float { - return y - } - - override fun x(x: Float, width: Float): Float { - return x - width / 2f - } - - override fun y(y: Float, height: Float): Float { - return y - } - }, - TOP_RIGHT { - override fun x(x: Float, width: FloatSupplier): Float { - return x - width - } - - override fun y(y: Float, height: FloatSupplier): Float { - return y - } - - override fun x(x: Float, width: Float): Float { - return x - width - } - - override fun y(y: Float, height: Float): Float { - return y +enum class GravityRounding { + /** + * Round aligned element only if base coordinate is whole + */ + DEFAULT { + override fun round(base: Float, subtraction: Float): Float { + if (base % 1f == 0f) { + return (base - subtraction).roundToInt().toFloat() + } else { + return base - subtraction + } } }, - CENTER_LEFT { - override fun x(x: Float, width: FloatSupplier): Float { - return x - } - - override fun y(y: Float, height: FloatSupplier): Float { - return y - height / 2f - } - - override fun x(x: Float, width: Float): Float { - return x - } - - override fun y(y: Float, height: Float): Float { - return y - height / 2f - } - }, - CENTER_CENTER { - override fun x(x: Float, width: FloatSupplier): Float { - return x - width / 2f - } - - override fun y(y: Float, height: FloatSupplier): Float { - return y - height / 2f - } - - override fun x(x: Float, width: Float): Float { - return x - width / 2f - } - - override fun y(y: Float, height: Float): Float { - return y - height / 2f - } - }, - CENTER_RIGHT { - override fun x(x: Float, width: FloatSupplier): Float { - return x - width - } - - override fun y(y: Float, height: FloatSupplier): Float { - return y - height / 2f - } - - override fun x(x: Float, width: Float): Float { - return x - width - } - - override fun y(y: Float, height: Float): Float { - return y - height / 2f + /** + * Always round final position + */ + YES { + override fun round(base: Float, subtraction: Float): Float { + return (base - subtraction).roundToInt().toFloat() } }, - BOTTOM_LEFT { - override fun x(x: Float, width: FloatSupplier): Float { - return x - } - - override fun y(y: Float, height: FloatSupplier): Float { - return y - height - } - - override fun x(x: Float, width: Float): Float { - return x - } - - override fun y(y: Float, height: Float): Float { - return y - height - } - }, - BOTTOM_CENTER { - override fun x(x: Float, width: FloatSupplier): Float { - return x - width / 2f - } - - override fun y(y: Float, height: FloatSupplier): Float { - return y - height - } - - override fun x(x: Float, width: Float): Float { - return x - width / 2f - } - - override fun y(y: Float, height: Float): Float { - return y - height - } - }, - BOTTOM_RIGHT { - override fun x(x: Float, width: FloatSupplier): Float { - return x - width - } - - override fun y(y: Float, height: FloatSupplier): Float { - return y - height - } - - override fun x(x: Float, width: Float): Float { - return x - width - } - - override fun y(y: Float, height: Float): Float { - return y - height + /** + * Never round final position + */ + NO { + override fun round(base: Float, subtraction: Float): Float { + return base - subtraction } }; - abstract fun x(x: Float, width: FloatSupplier): Float - abstract fun y(y: Float, height: FloatSupplier): Float + abstract fun round(base: Float, subtraction: Float): Float +} - abstract fun x(x: Float, width: Float): Float - abstract fun y(y: Float, height: Float): Float +interface IXGravity { + fun x(x: Float, width: FloatSupplier, scale: Float = 1f, rounding: GravityRounding = GravityRounding.DEFAULT): Float + fun x(x: Float, width: Float, scale: Float = 1f, rounding: GravityRounding = GravityRounding.DEFAULT): Float - fun x(x: Float, width: Int): Float { - return x(x, width.toFloat()).roundToInt().toFloat() - } + fun x(x: Float, width: FloatSupplier): Float = x(x, width, 1f) + fun x(x: Float, width: Float): Float = x(x, width, 1f) - fun y(y: Float, height: Int): Float { - return y(y, height.toFloat()).roundToInt().toFloat() + fun x(x: Float, font: Font, text: Component): Float = x(x, font, text, 1f) + fun x(x: Float, font: Font, text: Component, scale: Float = 1f, rounding: GravityRounding = GravityRounding.DEFAULT): Float + + fun x(x: Float, font: Font, text: String): Float = x(x, font, text, 1f) + fun x(x: Float, font: Font, text: String, scale: Float = 1f, rounding: GravityRounding = GravityRounding.DEFAULT): Float + + fun x(x: Float, width: Int, scale: Float = 1f): Float { + return x(x, width.toFloat() * scale).roundToInt().toFloat() } } + +interface IYGravity { + fun y(y: Float, height: FloatSupplier, scale: Float = 1f, rounding: GravityRounding = GravityRounding.DEFAULT): Float + fun y(y: Float, height: FloatSupplier): Float = y(y, height, 1f) + fun y(y: Float, height: Float, scale: Float = 1f, rounding: GravityRounding = GravityRounding.DEFAULT): Float + fun y(y: Float, height: Float): Float = y(y, height, 1f) + + fun y(y: Float, height: Int, scale: Float = 1f): Float { + return y(y, height.toFloat(), scale).roundToInt().toFloat() + } +} + +enum class XGravity : IXGravity { + LEFT { + override fun x(x: Float, width: FloatSupplier, scale: Float, rounding: GravityRounding): Float { + return x + } + + override fun x(x: Float, width: Float, scale: Float, rounding: GravityRounding): Float { + return x + } + + override fun x(x: Float, font: Font, text: Component, scale: Float, rounding: GravityRounding): Float { + return x + } + + override fun x(x: Float, font: Font, text: String, scale: Float, rounding: GravityRounding): Float { + return x + } + }, + CENTER { + override fun x(x: Float, width: FloatSupplier, scale: Float, rounding: GravityRounding): Float { + return rounding.round(x, width / 2f * scale) + } + + override fun x(x: Float, width: Float, scale: Float, rounding: GravityRounding): Float { + return rounding.round(x, width / 2f * scale) + } + + override fun x(x: Float, font: Font, text: Component, scale: Float, rounding: GravityRounding): Float { + return rounding.round(x, font.width(text) / 2f * scale) + } + + override fun x(x: Float, font: Font, text: String, scale: Float, rounding: GravityRounding): Float { + return rounding.round(x, font.width(text) / 2f * scale) + } + }, + RIGHT { + override fun x(x: Float, width: FloatSupplier, scale: Float, rounding: GravityRounding): Float { + return rounding.round(x, width * scale) + } + + override fun x(x: Float, width: Float, scale: Float, rounding: GravityRounding): Float { + return rounding.round(x, width * scale) + } + + override fun x(x: Float, font: Font, text: Component, scale: Float, rounding: GravityRounding): Float { + return rounding.round(x, font.width(text) * scale) + } + + override fun x(x: Float, font: Font, text: String, scale: Float, rounding: GravityRounding): Float { + return rounding.round(x, font.width(text) * scale) + } + }; +} + +enum class YGravity : IYGravity { + TOP { + override fun y(y: Float, height: FloatSupplier, scale: Float, rounding: GravityRounding): Float { + return y + } + + override fun y(y: Float, height: Float, scale: Float, rounding: GravityRounding): Float { + return y + } + }, + + CENTER { + override fun y(y: Float, height: FloatSupplier, scale: Float, rounding: GravityRounding): Float { + return rounding.round(y, height / 2f * scale) + } + + override fun y(y: Float, height: Float, scale: Float, rounding: GravityRounding): Float { + return rounding.round(y, height / 2f * scale) + } + }, + + BOTTOM { + override fun y(y: Float, height: FloatSupplier, scale: Float, rounding: GravityRounding): Float { + return rounding.round(y, height * scale) + } + + override fun y(y: Float, height: Float, scale: Float, rounding: GravityRounding): Float { + return rounding.round(y, height * scale) + } + }; +} + +enum class RenderGravity(val x: IXGravity, val y: IYGravity) : IXGravity by x, IYGravity by y { + TOP_LEFT(XGravity.LEFT, YGravity.TOP), + TOP_CENTER(XGravity.CENTER, YGravity.TOP), + TOP_RIGHT(XGravity.RIGHT, YGravity.TOP), + + CENTER_LEFT(XGravity.LEFT, YGravity.CENTER), + CENTER_CENTER(XGravity.CENTER, YGravity.CENTER), + CENTER_RIGHT(XGravity.RIGHT, YGravity.CENTER), + + BOTTOM_LEFT(XGravity.LEFT, YGravity.BOTTOM), + BOTTOM_CENTER(XGravity.CENTER, YGravity.BOTTOM), + BOTTOM_RIGHT(XGravity.RIGHT, YGravity.BOTTOM); +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt index efd6fcea3..10904c05f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt @@ -184,11 +184,11 @@ class BlackHoleRenderer(private val context: BlockEntityRendererProvider.Context val sorse = DynamicBufferSource.WORLD - font.drawAligned(poseStack, sorse, text1, RenderGravity.TOP_LEFT, 0.8f, 0.8f - font.lineHeight.toFloat() / 2f, 0x0) - font.drawAligned(poseStack, sorse, text2, RenderGravity.TOP_LEFT, 0.8f, 0.8f + font.lineHeight.toFloat() / 2f, 0x0) + font.draw(poseStack, text1, 0.8f, 0.8f - font.lineHeight.toFloat() / 2f, gravity = RenderGravity.TOP_LEFT, color = RGBAColor.BLACK, buffer = sorse) + font.draw(poseStack, text2, 0.8f, 0.8f + font.lineHeight.toFloat() / 2f, gravity = RenderGravity.TOP_LEFT, color = RGBAColor.BLACK, buffer = sorse) poseStack.translate(0.0, 0.0, -1.0) - font.drawAligned(poseStack, sorse, text1, RenderGravity.TOP_LEFT, 0f, -font.lineHeight.toFloat() / 2f, 0xFFFFFF) - font.drawAligned(poseStack, sorse, text2, RenderGravity.TOP_LEFT, 0f, font.lineHeight.toFloat() / 2f, 0xFFFFFF) + font.draw(poseStack, text1, 0f, -font.lineHeight.toFloat() / 2f, gravity = RenderGravity.TOP_LEFT, color = RGBAColor.WHITE, buffer = sorse) + font.draw(poseStack, text2, 0f, font.lineHeight.toFloat() / 2f, gravity = RenderGravity.TOP_LEFT, color = RGBAColor.WHITE, buffer = sorse) poseStack.popPose() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/EnergyCounterRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/EnergyCounterRenderer.kt index 378c3c998..e67110f66 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/EnergyCounterRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/EnergyCounterRenderer.kt @@ -10,6 +10,7 @@ import ru.dbotthepony.mc.otm.block.tech.EnergyCounterBlock import ru.dbotthepony.mc.otm.block.entity.tech.EnergyCounterBlockEntity import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.* +import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.asAngle import ru.dbotthepony.mc.otm.core.util.formatPower @@ -48,21 +49,21 @@ class EnergyCounterRenderer(private val context: BlockEntityRendererProvider.Con var y = -16f - val finalX = font.drawAligned(poseStack, sorse, "00000000", RenderGravity.CENTER_CENTER, -4f, y, RGBAColor.GRAY) - font.drawAligned(poseStack, sorse, "00000000", RenderGravity.CENTER_CENTER, -4f, y + font.lineHeight, RGBAColor.GRAY) - font.drawAligned(poseStack, sorse, "/t", RenderGravity.CENTER_LEFT, finalX.toFloat(), y, RGBAColor.GRAY) - font.drawAligned(poseStack, sorse, "/s", RenderGravity.CENTER_LEFT, finalX.toFloat(), y + font.lineHeight, RGBAColor.GRAY) + val finalX = font.draw(poseStack, buffer = sorse, text = "00000000", gravity = RenderGravity.CENTER_CENTER, x = -4f, y = y, color = RGBAColor.GRAY) + font.draw(poseStack, buffer = sorse, text = "00000000", gravity = RenderGravity.CENTER_CENTER, x = -4f, y = y + font.lineHeight, color = RGBAColor.GRAY) + font.draw(poseStack, buffer = sorse, text = "/t", gravity = RenderGravity.CENTER_LEFT, x = finalX, y = y, color = RGBAColor.GRAY) + font.draw(poseStack, buffer = sorse, text = "/s", gravity = RenderGravity.CENTER_LEFT, x = finalX, y = y + font.lineHeight, color = RGBAColor.GRAY) poseStack.pushPose() poseStack.translate(-0.1, -0.1, -0.1) - font.drawAligned(poseStack, sorse, tile.lastTick.toString(0), RenderGravity.CENTER_RIGHT, finalX.toFloat(), y, RGBAColor.WHITE) - font.drawAligned(poseStack, sorse, tile.sumHistory(20).toString(0), RenderGravity.CENTER_RIGHT, finalX.toFloat(), y + font.lineHeight, RGBAColor.WHITE) + font.draw(poseStack, buffer = sorse, text = tile.lastTick.toString(0), gravity = RenderGravity.CENTER_RIGHT, x = finalX, y = y, color = RGBAColor.WHITE) + font.draw(poseStack, buffer = sorse, text = tile.sumHistory(20).toString(0), gravity = RenderGravity.CENTER_RIGHT, x = finalX, y = y + font.lineHeight, color = RGBAColor.WHITE) poseStack.popPose() y += font.lineHeight * 3 - font.drawAligned(poseStack, sorse, TOTAL, RenderGravity.CENTER_CENTER, 0f, y, RGBAColor.WHITE) - font.drawAligned(poseStack, sorse, tile.passed.formatPower(), RenderGravity.CENTER_CENTER, 0f, y + font.lineHeight, RGBAColor.WHITE) + font.draw(poseStack, buffer = sorse, text = TOTAL, gravity = RenderGravity.CENTER_CENTER, x = 0f, y = y, color = RGBAColor.WHITE) + font.draw(poseStack, buffer = sorse,text = tile.passed.formatPower(), gravity = RenderGravity.CENTER_CENTER, x = 0f, y = y + font.lineHeight, color = RGBAColor.WHITE) poseStack.popPose() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt index f3031ecfa..1708809b8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt @@ -156,12 +156,20 @@ class GravitationStabilizerRenderer(private val context: BlockEntityRendererProv val sorse = DynamicBufferSource.WORLD val font = minecraft.font - font.drawAligned(poseStack, sorse, TranslatableComponent("otm.3d2d.gravitation_stabilizer.mass", bhTile.mass.formatMatter(formatAsReadable = ShiftPressedCond)), RenderGravity.TOP_CENTER, 1f, -font.lineHeight.toFloat() / 2f + 1f, 0) - font.drawAligned(poseStack, sorse, TranslatableComponent("otm.3d2d.gravitation_stabilizer.strength", "%.2f".format(bhTile.gravitationStrength)), RenderGravity.TOP_CENTER, 1f, font.lineHeight.toFloat() / 2f + 1f, 0) - poseStack.translate(0.2f, 0f, -0.5f) - font.drawAligned(poseStack, sorse, TranslatableComponent("otm.3d2d.gravitation_stabilizer.mass", bhTile.mass.formatMatter(formatAsReadable = ShiftPressedCond)), RenderGravity.TOP_CENTER, 0f, -font.lineHeight.toFloat() / 2f, 0xFFFFFF) - font.drawAligned(poseStack, sorse, TranslatableComponent("otm.3d2d.gravitation_stabilizer.strength", "%.2f".format(bhTile.gravitationStrength)), RenderGravity.TOP_CENTER, 0f, font.lineHeight.toFloat() / 2f, 0xFFFFFF) + font.draw( + poseStack, + TranslatableComponent("otm.3d2d.gravitation_stabilizer.mass", bhTile.mass.formatMatter(formatAsReadable = ShiftPressedCond)), + 1f, -font.lineHeight.toFloat() / 2f + 1f, + color = RGBAColor.WHITE, buffer = sorse, gravity = RenderGravity.TOP_CENTER, + customShadow = true, shadowX = -0.2f, shadowY = 0f, shadowZ = -0.5f) + + font.draw( + poseStack, + TranslatableComponent("otm.3d2d.gravitation_stabilizer.strength", "%.2f".format(bhTile.gravitationStrength)), + 1f, font.lineHeight.toFloat() / 2f + 1f, + color = RGBAColor.BLACK, buffer = sorse, gravity = RenderGravity.TOP_CENTER, + customShadow = true, shadowX = -0.2f, shadowY = 0f, shadowZ = 0.5f) poseStack.popPose() } 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 465db9cf5..518de6d2b 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 @@ -8,7 +8,8 @@ import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity 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.drawAligned +import ru.dbotthepony.mc.otm.client.render.draw +import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.rotateWithBlockFacing import ru.dbotthepony.mc.otm.core.math.rotationThree @@ -37,7 +38,7 @@ class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context) var y = -totalHeight / 2f for (line in lines) { - font.drawAligned(poseStack = poseStack, buffer = sorse, text = line, align = RenderGravity.TOP_CENTER, x = 0f, y = y, color = RGBAColor.YELLOW.toRGB()) + font.draw(poseStack = poseStack, buffer = sorse, text = line, gravity = RenderGravity.TOP_CENTER, y = y, color = RGBAColor.YELLOW) y += font.lineHeight + 2f } 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 2e0462994..c21d4a1ce 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 @@ -202,7 +202,10 @@ class MatterPanelScreen( menu.patternsFiltered.getOrNull(index)?.let { if (it.researchPercent < 1f) { - font.drawScaledAligned(graphics.pose(), graphics.bufferSource(), (it.researchPercent * 100.0).toInt().toString() + "%", .5f, RenderGravity.BOTTOM_RIGHT, width - 1f, height - 1f, true, color = RGBAColor.WHITE) + graphics.draw( + font, + TextComponent((it.researchPercent * 100.0).toInt().toString() + "%"), + width - 1f, height - 1f, scale = 0.5f, gravity = RenderGravity.BOTTOM_RIGHT, drawShadow = true, color = RGBAColor.WHITE) } } } else { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt index df4bab6d9..00e926461 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt @@ -623,10 +623,10 @@ open class ColorPickerPanel( this.wang.dockRight = 2f this.textLabel.dock = Dock.LEFT - this.textLabel.align = RenderGravity.CENTER_LEFT + this.textLabel.gravity = RenderGravity.CENTER_LEFT this.label.tooltips.add(TranslatableComponent("otm.gui.color.full.$label")) - this.label.align = RenderGravity.CENTER_RIGHT + this.label.gravity = RenderGravity.CENTER_RIGHT } fun update(color: Either) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt index 3cf406d10..f8a3ed691 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt @@ -12,11 +12,11 @@ import net.minecraft.world.entity.LivingEntity import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.determineTooltipPosition -import ru.dbotthepony.mc.otm.client.render.drawAligned -import ru.dbotthepony.mc.otm.client.render.drawScaledAligned +import ru.dbotthepony.mc.otm.client.render.draw import ru.dbotthepony.mc.otm.client.render.sprite import ru.dbotthepony.mc.otm.client.render.render import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel +import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.util.formatTickDuration @@ -117,7 +117,7 @@ open class EffectListPanel @JvmOverloads constructor( minecraft.mobEffectTextures.get(effect.effect).render(graphics, x = 3f, y = 3f, width = width - 6f, height = height - 6f) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) - graphics.drawScaledAligned(font, formatTickDuration(effect.duration), 0.75f, RenderGravity.CENTER_CENTER, width / 2f - 1f, height / 2f, RGBAColor.WHITE) + graphics.draw(font, formatTickDuration(effect.duration), width / 2f - 1f, height / 2f, scale = 0.75f, gravity = RenderGravity.CENTER_CENTER, color = RGBAColor.WHITE) } override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { @@ -145,8 +145,8 @@ open class EffectListPanel @JvmOverloads constructor( name.append(" ${effect.amplifier + 1}") } - graphics.drawAligned(font, name, RenderGravity.TOP_LEFT, x + renderWidth + 12f, y + 7f, RGBAColor.WHITE) - graphics.drawAligned(font, formatTickDuration(effect.duration, true), RenderGravity.TOP_LEFT, x + renderWidth + 12f, y + 7f + font.lineHeight + 2f, 8355711) + graphics.draw(font, name, x + renderWidth + 12f, y + 7f, gravity = RenderGravity.TOP_LEFT, color = RGBAColor.WHITE) + graphics.draw(font, formatTickDuration(effect.duration, true), x + renderWidth + 12f, y + 7f + font.lineHeight + 2f, gravity = RenderGravity.TOP_LEFT, color = RGBAColor.LIGHT_GRAY) } return isHovered diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index 5019f7a23..62c0fa997 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -12,6 +12,7 @@ import org.lwjgl.opengl.GL30 import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.client.screen.panels.button.AbstractButtonPanel import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.math.RGBAColor open class FramePanel( screen: S, @@ -21,6 +22,7 @@ open class FramePanel( width: Float, height: Float, var title: Component? = null, + var titleColor: RGBAColor = RGBAColor.HEADING_TEXT ) : EditablePanel(screen, parent, x, y, width, height), NarratableEntry { constructor(screen: S, width: Float, height: Float, title: Component?) : this(screen, null, 0f, 0f, width, height, title) @@ -326,7 +328,7 @@ open class FramePanel( // title val title = title ?: return RenderSystem.depthFunc(GL30.GL_ALWAYS) - graphics.drawAligned(font, title, RenderGravity.TOP_LEFT, 8f, 5f, 4210752) + graphics.draw(font, title, 8f, 5f, color = titleColor) RenderSystem.depthFunc(GL30.GL_ALWAYS) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt index 95e017ac9..68448cb6c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt @@ -4,7 +4,7 @@ import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.client.render.RenderGravity -import ru.dbotthepony.mc.otm.client.render.drawAligned +import ru.dbotthepony.mc.otm.client.render.draw import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.math.RGBAColor @@ -29,35 +29,35 @@ open class Label @JvmOverloads constructor( } var color = RGBAColor.SLATE_GRAY - var align = RenderGravity.TOP_LEFT + var gravity = RenderGravity.TOP_LEFT override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { clearDepth(graphics) if (shadow) { - when (align) { - RenderGravity.TOP_LEFT -> graphics.drawAligned(font, text, align, shadowX, shadowY, shadowColor.toRGB()) - RenderGravity.TOP_CENTER -> graphics.drawAligned(font, text, align, shadowX + width / 2f, shadowY, shadowColor.toRGB()) - RenderGravity.TOP_RIGHT -> graphics.drawAligned(font, text, align, shadowX + width, shadowY, shadowColor.toRGB()) - RenderGravity.CENTER_LEFT -> graphics.drawAligned(font, text, align, shadowX, height / 2f + shadowY, shadowColor.toRGB()) - RenderGravity.CENTER_CENTER -> graphics.drawAligned(font, text, align, shadowX + width / 2f, height / 2f + shadowY, shadowColor.toRGB()) - RenderGravity.CENTER_RIGHT -> graphics.drawAligned(font, text, align, shadowX + width, height / 2f + shadowY, shadowColor.toRGB()) - RenderGravity.BOTTOM_LEFT -> graphics.drawAligned(font, text, align, shadowX, height + shadowY, shadowColor.toRGB()) - RenderGravity.BOTTOM_CENTER -> graphics.drawAligned(font, text, align, shadowX + width / 2f, height + shadowY, shadowColor.toRGB()) - RenderGravity.BOTTOM_RIGHT -> graphics.drawAligned(font, text, align, shadowX + width, height + shadowY, shadowColor.toRGB()) + when (gravity) { + RenderGravity.TOP_LEFT -> graphics.draw(font, text, shadowX, shadowY, color = shadowColor, gravity = gravity) + RenderGravity.TOP_CENTER -> graphics.draw(font, text, shadowX + width / 2f, shadowY, color = shadowColor, gravity = gravity) + RenderGravity.TOP_RIGHT -> graphics.draw(font, text, shadowX + width, shadowY, color = shadowColor, gravity = gravity) + RenderGravity.CENTER_LEFT -> graphics.draw(font, text, shadowX, height / 2f + shadowY, color = shadowColor, gravity = gravity) + RenderGravity.CENTER_CENTER -> graphics.draw(font, text, shadowX + width / 2f, height / 2f + shadowY, color = shadowColor, gravity = gravity) + RenderGravity.CENTER_RIGHT -> graphics.draw(font, text, shadowX + width, height / 2f + shadowY, color = shadowColor, gravity = gravity) + RenderGravity.BOTTOM_LEFT -> graphics.draw(font, text, shadowX, height + shadowY, color = shadowColor, gravity = gravity) + RenderGravity.BOTTOM_CENTER -> graphics.draw(font, text, shadowX + width / 2f, height + shadowY, color = shadowColor, gravity = gravity) + RenderGravity.BOTTOM_RIGHT -> graphics.draw(font, text, shadowX + width, height + shadowY, color = shadowColor, gravity = gravity) } } - when (align) { - RenderGravity.TOP_LEFT -> font.drawAligned(graphics.pose(), text, align, 0f, 0f, color.toRGB()) - RenderGravity.TOP_CENTER -> font.drawAligned(graphics.pose(), text, align, width / 2f, 0f, color.toRGB()) - RenderGravity.TOP_RIGHT -> font.drawAligned(graphics.pose(), text, align, width - (if (shadow) shadowX else 0f), 0f, color.toRGB()) - RenderGravity.CENTER_LEFT -> font.drawAligned(graphics.pose(), text, align, 0f, height / 2f, color.toRGB()) - RenderGravity.CENTER_CENTER -> font.drawAligned(graphics.pose(), text, align, width / 2f, height / 2f, color.toRGB()) - RenderGravity.CENTER_RIGHT -> font.drawAligned(graphics.pose(), text, align, width - (if (shadow) shadowX else 0f), height / 2f, color.toRGB()) - RenderGravity.BOTTOM_LEFT -> font.drawAligned(graphics.pose(), text, align, 0f, height, color.toRGB()) - RenderGravity.BOTTOM_CENTER -> font.drawAligned(graphics.pose(), text, align, width / 2f, height, color.toRGB()) - RenderGravity.BOTTOM_RIGHT -> font.drawAligned(graphics.pose(), text, align, width - (if (shadow) shadowX else 0f), height, color.toRGB()) + when (gravity) { + RenderGravity.TOP_LEFT -> graphics.draw(font, text, 0f, 0f, color = color, gravity = gravity) + RenderGravity.TOP_CENTER -> graphics.draw(font, text, width / 2f, 0f, color = color, gravity = gravity) + RenderGravity.TOP_RIGHT -> graphics.draw(font, text, width - (if (shadow) shadowX else 0f), 0f, color = color, gravity = gravity) + RenderGravity.CENTER_LEFT -> graphics.draw(font, text, 0f, height / 2f, color = color, gravity = gravity) + RenderGravity.CENTER_CENTER -> graphics.draw(font, text, width / 2f, height / 2f, color = color, gravity = gravity) + RenderGravity.CENTER_RIGHT -> graphics.draw(font, text, width - (if (shadow) shadowX else 0f), height / 2f, color = color, gravity = gravity) + RenderGravity.BOTTOM_LEFT -> graphics.draw(font, text, 0f, height, color = color, gravity = gravity) + RenderGravity.BOTTOM_CENTER -> graphics.draw(font, text, width / 2f, height, color = color, gravity = gravity) + RenderGravity.BOTTOM_RIGHT -> graphics.draw(font, text, width - (if (shadow) shadowX else 0f), height, color = color, gravity = gravity) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt index c885d244e..53965c468 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt @@ -5,7 +5,7 @@ import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.Widgets18 -import ru.dbotthepony.mc.otm.client.render.drawAligned +import ru.dbotthepony.mc.otm.client.render.draw import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.math.RGBAColor import java.util.function.IntConsumer @@ -53,7 +53,7 @@ open class ButtonPanel( override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { renderStretchableBackground(graphics, mouseX, mouseY, partialTick) - graphics.drawAligned(font, label, RenderGravity.CENTER_CENTER, width / 2f, height / 2f, textColor.toRGB()) + graphics.draw(font, label, width / 2f, height / 2f, color = textColor, gravity = RenderGravity.CENTER_CENTER) } override fun sizeToContents() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt index 3c8c9ea5d..bebb96588 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt @@ -20,7 +20,7 @@ import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.render.RenderGravity -import ru.dbotthepony.mc.otm.client.render.drawAligned +import ru.dbotthepony.mc.otm.client.render.draw import ru.dbotthepony.mc.otm.client.render.renderRect import ru.dbotthepony.mc.otm.client.render.tesselator import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty @@ -1115,10 +1115,10 @@ open class TextInputPanel( var y = topPadding if (lines.isEmpty() || lines.size == 1 && lines[0] == "") { - graphics.drawAligned( + graphics.draw( font = font, text = placeholder, - align = RenderGravity.TOP_LEFT, + gravity = RenderGravity.TOP_LEFT, x = dockPadding.left, y = y, color = placeholderColor @@ -1129,10 +1129,10 @@ open class TextInputPanel( val line = lines[i] val selection = selections[i] - graphics.drawAligned( + graphics.draw( font = font, text = line, - align = RenderGravity.TOP_LEFT, + gravity = RenderGravity.TOP_LEFT, x = dockPadding.left, y = y, color = textColor @@ -1183,19 +1183,19 @@ open class TextInputPanel( val activeLine = this[cursorLine] if (activeLine == null || cursorRow >= activeLine.length) { - graphics.drawAligned( + graphics.draw( font = font, text = "_", - align = RenderGravity.TOP_LEFT, + gravity = RenderGravity.TOP_LEFT, x = dockPadding.left + (if (activeLine == null) 0f else font.width(activeLine).toFloat()), y = topPadding + (cursorLine - scrollLines) * (font.lineHeight + rowSpacing), color = cursorColor ) } else { - graphics.drawAligned( + graphics.draw( font = font, text = "|", - align = RenderGravity.TOP_LEFT, + gravity = RenderGravity.TOP_LEFT, x = dockPadding.left + font.width(activeLine.substring(0, cursorRow)).toFloat() - 1f, y = topPadding + (cursorLine - scrollLines) * (font.lineHeight + rowSpacing), color = cursorColor @@ -1206,28 +1206,28 @@ open class TextInputPanel( stack.popPose() if (debugDraw) { - graphics.drawAligned( + graphics.draw( font = font, text = cursorLine.toString(), - align = RenderGravity.TOP_RIGHT, + gravity = RenderGravity.TOP_RIGHT, x = width, y = topPadding, color = cursorColor ) - graphics.drawAligned( + graphics.draw( font = font, text = cursorRow.toString(), - align = RenderGravity.TOP_RIGHT, + gravity = RenderGravity.TOP_RIGHT, x = width - dockPadding.right, y = topPadding + font.lineHeight + rowSpacing, color = cursorColor ) - graphics.drawAligned( + graphics.draw( font = font, text = lines.size.toString(), - align = RenderGravity.TOP_RIGHT, + gravity = RenderGravity.TOP_RIGHT, x = width - dockPadding.right, y = topPadding + font.lineHeight * 2f + rowSpacing * 2f, color = cursorColor 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 edd721913..efb855254 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 @@ -644,7 +644,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I init { dock = Dock.BOTTOM dockTop = 2f - align = RenderGravity.TOP_RIGHT + gravity = RenderGravity.TOP_RIGHT } override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt index 0853c201c..7605bfde4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt @@ -73,7 +73,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title init { dock = Dock.TOP dockMargin = DockProperty(bottom = 3f) - align = RenderGravity.TOP_CENTER + gravity = RenderGravity.TOP_CENTER } override fun tickInner() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt index ceed77e88..b3955b5e1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt @@ -15,7 +15,7 @@ import net.minecraft.world.item.crafting.Ingredient import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.RenderGravity -import ru.dbotthepony.mc.otm.client.render.drawAligned +import ru.dbotthepony.mc.otm.client.render.draw 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.math.RGBAColor @@ -70,12 +70,12 @@ object PlatePressRecipeCategory : IRecipeCategory, IDrawable { mouseX: Double, mouseY: Double ) { - graphics.drawAligned(minecraft.font, TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), RenderGravity.TOP_CENTER, 40f, 30f, RGBAColor.BLACK) + graphics.draw(minecraft.font, TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), 40f, 30f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK) val average = recipe.experience.toString() if (average != "0.0") { - graphics.drawAligned(minecraft.font, TranslatableComponent("gui.jei.category.smelting.experience", average), RenderGravity.TOP_CENTER, 40f, 1f, RGBAColor.BLACK) + graphics.draw(minecraft.font, TranslatableComponent("gui.jei.category.smelting.experience", average), 40f, 1f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Colors.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Colors.kt index 98741982c..9c57692b1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Colors.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Colors.kt @@ -241,6 +241,8 @@ class RGBAColor(red: Float, green: Float, blue: Float, alpha: Float = 1f) : Comp @JvmField val LIGHT_GREEN = RGBAColor(136, 255, 124) @JvmField val SLATE_GRAY = RGBAColor(64, 64, 64) @JvmField val GRAY = rgb(0x2C2C2CL) + @JvmField val LIGHT_GRAY = rgb(0x7F7F7FL) + @JvmField val HEADING_TEXT = rgb(0x404040L) @JvmField val DARK_BLUE = rgb(ChatFormatting.DARK_BLUE.color!!) @JvmField val DARK_GREEN = rgb(ChatFormatting.DARK_GREEN.color!!) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/MatrixExt.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/MatrixExt.kt index f12e17d7d..bf434c301 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/MatrixExt.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/MatrixExt.kt @@ -83,7 +83,7 @@ fun Matrix3f.toMatrix4f(): Matrix4f { var Matrix4f.translation: Vector3f get() { - return Vector3f(this[0, 3], this[1, 3], this[2, 3]) + return Vector3f(this[3, 0], this[3, 1], this[3, 2]) } set(value) { @@ -99,7 +99,7 @@ var Matrix4f.translation: Vector3f var Matrix4f.translation4: Vector4f get() { - return Vector4f(this[0, 3], this[1, 3], this[2, 3], this[3, 3]) + return Vector4f(this[3, 0], this[3, 1], this[3, 2], this[3, 3]) } set(value) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt index 1824364c8..18d1b193d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt @@ -24,7 +24,7 @@ import ru.dbotthepony.mc.otm.* import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.client.font import ru.dbotthepony.mc.otm.client.render.RenderGravity -import ru.dbotthepony.mc.otm.client.render.drawAligned +import ru.dbotthepony.mc.otm.client.render.draw import ru.dbotthepony.mc.otm.client.render.renderRect import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.math.Angle @@ -465,7 +465,7 @@ abstract class AbstractWeaponItem(val tables: KClass, pr pose.translate(0.0, 0.0, -1.0) pose.scale(0.7f, 0.7f, 0.7f) val text = it.batteryLevel.formatPower() - font.drawAligned(pose, text, RenderGravity.TOP_LEFT, 2f, 2f, RGBAColor.WHITE.toRGB()) + font.draw(pose, text, 2f, 2f, color = RGBAColor.WHITE) pose.popPose() } From 00c3f17dd2e41d61a0ec89c246c85d31f5bce1e1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 24 Jul 2023 00:30:33 +0700 Subject: [PATCH 0827/1199] Add text outlining to hud values --- .../dbotthepony/mc/otm/client/MatteryGUI.kt | 6 +- .../dbotthepony/mc/otm/client/render/Ext.kt | 199 ++++++++++++------ .../mc/otm/client/render/RenderGravity.kt | 16 ++ 3 files changed, 155 insertions(+), 66 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index 8f3529a79..3dc54f4b9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -254,8 +254,7 @@ object MatteryGUI { val formattedPower = mattery.androidEnergy.batteryLevel.formatPower() - event.guiGraphics.draw(gui.font, formattedPower, left + CHARGE_BG.width + 2f, top + CHARGE_BG.height / 2f + 1f, scale = 0.5f, gravity = RenderGravity.CENTER_LEFT, color = RGBAColor.BLACK) - event.guiGraphics.draw(gui.font, formattedPower, left + CHARGE_BG.width + 1f, top + CHARGE_BG.height / 2f, scale = 0.5f, gravity = RenderGravity.CENTER_LEFT, color = RGBAColor.YELLOW) + event.guiGraphics.draw(gui.font, formattedPower, left + CHARGE_BG.width + 1f, top + CHARGE_BG.height / 2f, scale = 0.5f, gravity = RenderGravity.CENTER_LEFT, color = RGBAColor.YELLOW, drawOutline = true) } } @@ -331,8 +330,7 @@ object MatteryGUI { if (ply.absorptionAmount > 0) formattedHealth = TextComponent("%d+%d/%d".format(ply.health.toInt(), ply.absorptionAmount.toInt(), ply.maxHealth.toInt())) - event.guiGraphics.draw(minecraft.font, formattedHealth, left - 1f, top + HEALTH_BG.height / 2f + 1f, scale = 0.5f, gravity = RenderGravity.CENTER_RIGHT, color = RGBAColor.BLACK) - event.guiGraphics.draw(minecraft.font, formattedHealth, left - 2f, top + HEALTH_BG.height / 2f, scale = 0.5f, gravity = RenderGravity.CENTER_RIGHT, color = getHealthColorForPlayer(ply)) + event.guiGraphics.draw(minecraft.font, formattedHealth, left - 2f, top + HEALTH_BG.height / 2f, scale = 0.5f, gravity = RenderGravity.CENTER_RIGHT, color = getHealthColorForPlayer(ply), drawOutline = true) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt index 82bd449f4..bea85bca2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt @@ -73,6 +73,59 @@ inline val PoseStack.Pose.pose: Matrix4f get() = pose() private val buffer = DynamicBufferSource(vertexSorting = VertexSorting.ORTHOGRAPHIC_Z) private fun buffer() = buffer +private fun Font.drawInBatch( + text: Any, x: Float, y: Float, color: Int, drawShadow: Boolean, + matrix4f: Matrix4f, buffer: MultiBufferSource, displayMode: Font.DisplayMode, + effectColor: Int, packedLightCoords: Int, gravity: RenderGravity, + rounding: GravityRounding +): Int { + if (text is String) + return drawInBatch( + text, + gravity.x(x, this, text, rounding = rounding), + gravity.y(y, lineHeight.toFloat(), rounding = rounding), + color, + drawShadow, + matrix4f, + buffer, + displayMode, + effectColor, + packedLightCoords) + else if (text is Component) + return drawInBatch( + text, + gravity.x(x, this, text, rounding = rounding), + gravity.y(y, lineHeight.toFloat(), rounding = rounding), + color, + drawShadow, + matrix4f, + buffer, + displayMode, + effectColor, + packedLightCoords) + else if (text is FormattedCharSequence) + return drawInBatch( + text, + gravity.x(x, this, text, rounding = rounding), + gravity.y(y, lineHeight.toFloat(), rounding = rounding), + color, + drawShadow, + matrix4f, + buffer, + displayMode, + effectColor, + packedLightCoords) + else + throw IllegalArgumentException(text::class.qualifiedName) +} + +private val outlinePositions = listOf( + 1 to 0, + -1 to 0, + 0 to 1, + 0 to -1, +) + private fun Font.drawInternal( poseStack: PoseStack, text: Any, @@ -92,9 +145,10 @@ private fun Font.drawInternal( shadowZ: Float, customShadow: Boolean, rounding: GravityRounding, + drawOutline: Boolean, + outlineColor: RGBAColor, + outlineZ: Float, ): Float { - require(!drawShadow && !customShadow || drawShadow != customShadow) { "Can not draw built in shadow and custom shadow at the same time" } - val inv: Float if (scale != 1f) { @@ -115,64 +169,61 @@ private fun Font.drawInternal( poseStack.translate(0f, 0f, shadowZ) } - if (text is String) - drawInBatch( - text, - gravity.x((x + shadowX) * inv, this, text, 1f, rounding), - gravity.y((y + shadowY) * inv, lineHeight.toFloat(), 1f, rounding), - shadowColor.toRGB(), - false, - poseStack.last().pose(), - buffer, - displayMode, - effectColor, - packedLightCoords) - else if (text is Component) - drawInBatch( - text, - gravity.x((x + shadowX) * inv, this, text, 1f, rounding), - gravity.y((y + shadowY) * inv, lineHeight.toFloat(), 1f, rounding), - shadowColor.toRGB(), - false, - poseStack.last().pose(), - buffer, - displayMode, - effectColor, - packedLightCoords) + drawInBatch( + text, + (x + shadowX) * inv, + (y + shadowY) * inv, + shadowColor.toRGB(), + false, + poseStack.last().pose(), + buffer, + displayMode, + effectColor, + packedLightCoords, + gravity, rounding) if (shadowZ != 0f) { poseStack.translate(0f, 0f, -shadowZ) } } - val width: Int + if (drawOutline) { + if (outlineZ != 0f) { + poseStack.translate(0f, 0f, outlineZ) + } - if (text is String) - width = drawInBatch( - text, - gravity.x(x * inv, this, text, 1f, rounding), - gravity.y(y * inv, lineHeight.toFloat(), 1f, rounding), - color.toRGB(), - drawShadow, - poseStack.last().pose(), - buffer, - displayMode, - effectColor, - packedLightCoords) - else if (text is Component) - width = drawInBatch( - text, - gravity.x(x * inv, this, text, 1f, rounding), - gravity.y(y * inv, lineHeight.toFloat(), 1f, rounding), - color.toRGB(), - drawShadow, - poseStack.last().pose(), - buffer, - displayMode, - effectColor, - packedLightCoords) - else - throw IllegalArgumentException(text::class.qualifiedName) + for ((_x, _y) in outlinePositions) { + drawInBatch( + text, + x * inv + _x, + y * inv + _y, + outlineColor.toRGB(), + drawShadow, + poseStack.last().pose(), + buffer, + displayMode, + effectColor, + packedLightCoords, + gravity, rounding) + } + + if (outlineZ != 0f) { + poseStack.translate(0f, 0f, -outlineZ) + } + } + + val width = drawInBatch( + text, + x * inv, + y * inv, + color.toRGB(), + drawShadow, + poseStack.last().pose(), + buffer, + displayMode, + effectColor, + packedLightCoords, + gravity, rounding) if (scale != 1f) { poseStack.popPose() @@ -201,9 +252,12 @@ fun Font.draw( shadowColor: RGBAColor = RGBAColor.BLACK, shadowX: Float = 1f, shadowY: Float = 1f, - shadowZ: Float = 0f, + shadowZ: Float = -0.1f, customShadow: Boolean = false, rounding: GravityRounding = if (scale == 1f) GravityRounding.DEFAULT else GravityRounding.NO, + drawOutline: Boolean = false, + outlineColor: RGBAColor = RGBAColor.BLACK, + outlineZ: Float = -0.1f, ): Float { return drawInternal( poseStack = poseStack, @@ -224,6 +278,9 @@ fun Font.draw( shadowZ = shadowZ, customShadow = customShadow, rounding = rounding, + drawOutline = drawOutline, + outlineColor = outlineColor, + outlineZ = outlineZ, ) } @@ -243,9 +300,12 @@ fun Font.draw( shadowColor: RGBAColor = RGBAColor.BLACK, shadowX: Float = 1f, shadowY: Float = 1f, - shadowZ: Float = 0f, + shadowZ: Float = -0.1f, customShadow: Boolean = false, rounding: GravityRounding = if (scale == 1f) GravityRounding.DEFAULT else GravityRounding.NO, + drawOutline: Boolean = false, + outlineColor: RGBAColor = RGBAColor.BLACK, + outlineZ: Float = -0.1f, ): Float { return drawInternal( poseStack = poseStack, @@ -265,7 +325,10 @@ fun Font.draw( shadowY = shadowY, shadowZ = shadowZ, customShadow = customShadow, - rounding = rounding + rounding = rounding, + drawOutline = drawOutline, + outlineColor = outlineColor, + outlineZ = outlineZ, ) } @@ -282,11 +345,14 @@ fun GuiGraphics.draw( packedLightCoords: Int = 15728880, effectColor: Int = 0, shadowColor: RGBAColor = RGBAColor.BLACK, - shadowX: Float = 0f, - shadowY: Float = 0f, - shadowZ: Float = 0f, + shadowX: Float = 1f, + shadowY: Float = 1f, + shadowZ: Float = -0.1f, customShadow: Boolean = false, rounding: GravityRounding = if (scale == 1f) GravityRounding.DEFAULT else GravityRounding.NO, + drawOutline: Boolean = false, + outlineColor: RGBAColor = RGBAColor.BLACK, + outlineZ: Float = -0.1f, ): Float { val width = font.draw( poseStack = pose(), @@ -307,6 +373,9 @@ fun GuiGraphics.draw( shadowZ = shadowZ, customShadow = customShadow, rounding = rounding, + drawOutline = drawOutline, + outlineColor = outlineColor, + outlineZ = outlineZ, ) flush() @@ -326,11 +395,14 @@ fun GuiGraphics.draw( packedLightCoords: Int = 15728880, effectColor: Int = 0, shadowColor: RGBAColor = RGBAColor.BLACK, - shadowX: Float = 0f, - shadowY: Float = 0f, - shadowZ: Float = 0f, + shadowX: Float = 1f, + shadowY: Float = 1f, + shadowZ: Float = -0.1f, customShadow: Boolean = false, rounding: GravityRounding = if (scale == 1f) GravityRounding.DEFAULT else GravityRounding.NO, + drawOutline: Boolean = false, + outlineColor: RGBAColor = RGBAColor.BLACK, + outlineZ: Float = -0.1f, ): Float { val width = font.draw( poseStack = pose(), @@ -351,6 +423,9 @@ fun GuiGraphics.draw( shadowZ = shadowZ, customShadow = customShadow, rounding = rounding, + drawOutline = drawOutline, + outlineColor = outlineColor, + outlineZ = outlineZ, ) flush() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderGravity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderGravity.kt index 8a8efb451..fc755570a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderGravity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderGravity.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.client.render import net.minecraft.client.gui.Font import net.minecraft.network.chat.Component +import net.minecraft.util.FormattedCharSequence import ru.dbotthepony.mc.otm.core.FloatSupplier import kotlin.math.roundToInt @@ -65,6 +66,9 @@ interface IXGravity { fun x(x: Float, font: Font, text: String): Float = x(x, font, text, 1f) fun x(x: Float, font: Font, text: String, scale: Float = 1f, rounding: GravityRounding = GravityRounding.DEFAULT): Float + fun x(x: Float, font: Font, text: FormattedCharSequence): Float = x(x, font, text, 1f) + fun x(x: Float, font: Font, text: FormattedCharSequence, scale: Float = 1f, rounding: GravityRounding = GravityRounding.DEFAULT): Float + fun x(x: Float, width: Int, scale: Float = 1f): Float { return x(x, width.toFloat() * scale).roundToInt().toFloat() } @@ -98,6 +102,10 @@ enum class XGravity : IXGravity { override fun x(x: Float, font: Font, text: String, scale: Float, rounding: GravityRounding): Float { return x } + + override fun x(x: Float, font: Font, text: FormattedCharSequence, scale: Float, rounding: GravityRounding): Float { + return x + } }, CENTER { override fun x(x: Float, width: FloatSupplier, scale: Float, rounding: GravityRounding): Float { @@ -115,6 +123,10 @@ enum class XGravity : IXGravity { override fun x(x: Float, font: Font, text: String, scale: Float, rounding: GravityRounding): Float { return rounding.round(x, font.width(text) / 2f * scale) } + + override fun x(x: Float, font: Font, text: FormattedCharSequence, scale: Float, rounding: GravityRounding): Float { + return rounding.round(x, font.width(text) / 2f * scale) + } }, RIGHT { override fun x(x: Float, width: FloatSupplier, scale: Float, rounding: GravityRounding): Float { @@ -132,6 +144,10 @@ enum class XGravity : IXGravity { override fun x(x: Float, font: Font, text: String, scale: Float, rounding: GravityRounding): Float { return rounding.round(x, font.width(text) * scale) } + + override fun x(x: Float, font: Font, text: FormattedCharSequence, scale: Float, rounding: GravityRounding): Float { + return rounding.round(x, font.width(text) * scale) + } }; } From 9744269ac6ccbcc5449f5fd4bc433260f47e79d7 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 24 Jul 2023 00:41:18 +0700 Subject: [PATCH 0828/1199] GabeN :wtf: --- src/main/kotlin/ru/dbotthepony/mc/otm/core/math/MatrixExt.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/MatrixExt.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/MatrixExt.kt index bf434c301..11acd5701 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/MatrixExt.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/MatrixExt.kt @@ -83,7 +83,7 @@ fun Matrix3f.toMatrix4f(): Matrix4f { var Matrix4f.translation: Vector3f get() { - return Vector3f(this[3, 0], this[3, 1], this[3, 2]) + return Vector3f(this[0, 3], this[1, 3], this[2, 3]) } set(value) { @@ -99,7 +99,7 @@ var Matrix4f.translation: Vector3f var Matrix4f.translation4: Vector4f get() { - return Vector4f(this[3, 0], this[3, 1], this[3, 2], this[3, 3]) + return Vector4f(this[1, 3], this[1, 3], this[2, 3], this[3, 3]) } set(value) { From a1615493924298c57531ae7613e2816b0d6afbc2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 24 Jul 2023 00:43:04 +0700 Subject: [PATCH 0829/1199] positive Z is pointing from viewer --- .../kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt index bea85bca2..f6c42684d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt @@ -257,7 +257,7 @@ fun Font.draw( rounding: GravityRounding = if (scale == 1f) GravityRounding.DEFAULT else GravityRounding.NO, drawOutline: Boolean = false, outlineColor: RGBAColor = RGBAColor.BLACK, - outlineZ: Float = -0.1f, + outlineZ: Float = 0.1f, ): Float { return drawInternal( poseStack = poseStack, @@ -305,7 +305,7 @@ fun Font.draw( rounding: GravityRounding = if (scale == 1f) GravityRounding.DEFAULT else GravityRounding.NO, drawOutline: Boolean = false, outlineColor: RGBAColor = RGBAColor.BLACK, - outlineZ: Float = -0.1f, + outlineZ: Float = 0.1f, ): Float { return drawInternal( poseStack = poseStack, @@ -352,7 +352,7 @@ fun GuiGraphics.draw( rounding: GravityRounding = if (scale == 1f) GravityRounding.DEFAULT else GravityRounding.NO, drawOutline: Boolean = false, outlineColor: RGBAColor = RGBAColor.BLACK, - outlineZ: Float = -0.1f, + outlineZ: Float = 0.1f, ): Float { val width = font.draw( poseStack = pose(), @@ -402,7 +402,7 @@ fun GuiGraphics.draw( rounding: GravityRounding = if (scale == 1f) GravityRounding.DEFAULT else GravityRounding.NO, drawOutline: Boolean = false, outlineColor: RGBAColor = RGBAColor.BLACK, - outlineZ: Float = -0.1f, + outlineZ: Float = 0.1f, ): Float { val width = font.draw( poseStack = pose(), From e7c2f7102294f9dfea4b666d321631bf74b9ca51 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 24 Jul 2023 00:44:32 +0700 Subject: [PATCH 0830/1199] Outline singularity text instead of dropping shadow --- .../mc/otm/client/render/blockentity/BlackHoleRenderer.kt | 7 ++----- .../render/blockentity/GravitationStabilizerRenderer.kt | 6 +++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt index 10904c05f..f47dd49e4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt @@ -184,11 +184,8 @@ class BlackHoleRenderer(private val context: BlockEntityRendererProvider.Context val sorse = DynamicBufferSource.WORLD - font.draw(poseStack, text1, 0.8f, 0.8f - font.lineHeight.toFloat() / 2f, gravity = RenderGravity.TOP_LEFT, color = RGBAColor.BLACK, buffer = sorse) - font.draw(poseStack, text2, 0.8f, 0.8f + font.lineHeight.toFloat() / 2f, gravity = RenderGravity.TOP_LEFT, color = RGBAColor.BLACK, buffer = sorse) - poseStack.translate(0.0, 0.0, -1.0) - font.draw(poseStack, text1, 0f, -font.lineHeight.toFloat() / 2f, gravity = RenderGravity.TOP_LEFT, color = RGBAColor.WHITE, buffer = sorse) - font.draw(poseStack, text2, 0f, font.lineHeight.toFloat() / 2f, gravity = RenderGravity.TOP_LEFT, color = RGBAColor.WHITE, buffer = sorse) + font.draw(poseStack, text1, 0.8f, 0.8f - font.lineHeight.toFloat() / 2f, gravity = RenderGravity.TOP_LEFT, color = RGBAColor.WHITE, buffer = sorse, drawOutline = true) + font.draw(poseStack, text2, 0.8f, 0.8f + font.lineHeight.toFloat() / 2f, gravity = RenderGravity.TOP_LEFT, color = RGBAColor.WHITE, buffer = sorse, drawOutline = true) poseStack.popPose() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt index 1708809b8..a86e716b3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt @@ -162,14 +162,14 @@ class GravitationStabilizerRenderer(private val context: BlockEntityRendererProv TranslatableComponent("otm.3d2d.gravitation_stabilizer.mass", bhTile.mass.formatMatter(formatAsReadable = ShiftPressedCond)), 1f, -font.lineHeight.toFloat() / 2f + 1f, color = RGBAColor.WHITE, buffer = sorse, gravity = RenderGravity.TOP_CENTER, - customShadow = true, shadowX = -0.2f, shadowY = 0f, shadowZ = -0.5f) + drawOutline = true) font.draw( poseStack, TranslatableComponent("otm.3d2d.gravitation_stabilizer.strength", "%.2f".format(bhTile.gravitationStrength)), 1f, font.lineHeight.toFloat() / 2f + 1f, - color = RGBAColor.BLACK, buffer = sorse, gravity = RenderGravity.TOP_CENTER, - customShadow = true, shadowX = -0.2f, shadowY = 0f, shadowZ = 0.5f) + color = RGBAColor.WHITE, buffer = sorse, gravity = RenderGravity.TOP_CENTER, + drawOutline = true) poseStack.popPose() } From 6dccbd5bfafea1472c33ce24662509bfa6461a5e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 24 Jul 2023 00:48:00 +0700 Subject: [PATCH 0831/1199] ...unless you are in gui --- src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index 3dc54f4b9..7272b68d1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -254,7 +254,7 @@ object MatteryGUI { val formattedPower = mattery.androidEnergy.batteryLevel.formatPower() - event.guiGraphics.draw(gui.font, formattedPower, left + CHARGE_BG.width + 1f, top + CHARGE_BG.height / 2f, scale = 0.5f, gravity = RenderGravity.CENTER_LEFT, color = RGBAColor.YELLOW, drawOutline = true) + event.guiGraphics.draw(gui.font, formattedPower, left + CHARGE_BG.width + 1f, top + CHARGE_BG.height / 2f, scale = 0.5f, gravity = RenderGravity.CENTER_LEFT, color = RGBAColor.YELLOW, drawOutline = true, outlineZ = -0.1f) } } @@ -330,7 +330,7 @@ object MatteryGUI { if (ply.absorptionAmount > 0) formattedHealth = TextComponent("%d+%d/%d".format(ply.health.toInt(), ply.absorptionAmount.toInt(), ply.maxHealth.toInt())) - event.guiGraphics.draw(minecraft.font, formattedHealth, left - 2f, top + HEALTH_BG.height / 2f, scale = 0.5f, gravity = RenderGravity.CENTER_RIGHT, color = getHealthColorForPlayer(ply), drawOutline = true) + event.guiGraphics.draw(minecraft.font, formattedHealth, left - 2f, top + HEALTH_BG.height / 2f, scale = 0.5f, gravity = RenderGravity.CENTER_RIGHT, color = getHealthColorForPlayer(ply), drawOutline = true, outlineZ = -0.1f) } } From 699b4e896ce768b9591f58cf501801a7c0f72311 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 24 Jul 2023 00:53:57 +0700 Subject: [PATCH 0832/1199] Im blind --- src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt | 4 ++-- src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index 7272b68d1..3dc54f4b9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -254,7 +254,7 @@ object MatteryGUI { val formattedPower = mattery.androidEnergy.batteryLevel.formatPower() - event.guiGraphics.draw(gui.font, formattedPower, left + CHARGE_BG.width + 1f, top + CHARGE_BG.height / 2f, scale = 0.5f, gravity = RenderGravity.CENTER_LEFT, color = RGBAColor.YELLOW, drawOutline = true, outlineZ = -0.1f) + event.guiGraphics.draw(gui.font, formattedPower, left + CHARGE_BG.width + 1f, top + CHARGE_BG.height / 2f, scale = 0.5f, gravity = RenderGravity.CENTER_LEFT, color = RGBAColor.YELLOW, drawOutline = true) } } @@ -330,7 +330,7 @@ object MatteryGUI { if (ply.absorptionAmount > 0) formattedHealth = TextComponent("%d+%d/%d".format(ply.health.toInt(), ply.absorptionAmount.toInt(), ply.maxHealth.toInt())) - event.guiGraphics.draw(minecraft.font, formattedHealth, left - 2f, top + HEALTH_BG.height / 2f, scale = 0.5f, gravity = RenderGravity.CENTER_RIGHT, color = getHealthColorForPlayer(ply), drawOutline = true, outlineZ = -0.1f) + event.guiGraphics.draw(minecraft.font, formattedHealth, left - 2f, top + HEALTH_BG.height / 2f, scale = 0.5f, gravity = RenderGravity.CENTER_RIGHT, color = getHealthColorForPlayer(ply), drawOutline = true) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt index f6c42684d..103f10939 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt @@ -352,7 +352,7 @@ fun GuiGraphics.draw( rounding: GravityRounding = if (scale == 1f) GravityRounding.DEFAULT else GravityRounding.NO, drawOutline: Boolean = false, outlineColor: RGBAColor = RGBAColor.BLACK, - outlineZ: Float = 0.1f, + outlineZ: Float = -0.1f, ): Float { val width = font.draw( poseStack = pose(), @@ -402,7 +402,7 @@ fun GuiGraphics.draw( rounding: GravityRounding = if (scale == 1f) GravityRounding.DEFAULT else GravityRounding.NO, drawOutline: Boolean = false, outlineColor: RGBAColor = RGBAColor.BLACK, - outlineZ: Float = 0.1f, + outlineZ: Float = -0.1f, ): Float { val width = font.draw( poseStack = pose(), From e9793037bdaa4afaa9e2348d04f72dcb8c7c6c90 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Mon, 24 Jul 2023 04:20:08 +0300 Subject: [PATCH 0833/1199] added harvest tool tag for metal junk and metal mesh (#275) --- src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index 5f9851f86..8d67188da 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -178,6 +178,8 @@ fun addTags(tagsProvider: TagsProvider) { MBlocks.ENERGY_SERVO, MBlocks.TRITANIUM_INGOT_BLOCK, + MBlocks.METAL_JUNK, + MBlocks.METAL_MESH, MBlocks.TRITANIUM_BARS, MBlocks.ENGINE, From 8407ae1328efc39443f7a1ceb7b5ce654bb9af16 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 24 Jul 2023 09:35:14 +0700 Subject: [PATCH 0834/1199] Cache text width when aligning it multiple times --- .../dbotthepony/mc/otm/client/render/Ext.kt | 70 ++++++++++++++++--- 1 file changed, 61 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt index 103f10939..f3fdb5aac 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt @@ -12,6 +12,7 @@ import net.minecraft.network.chat.Component import net.minecraft.util.FormattedCharSequence import org.joml.Matrix4f import org.joml.Vector3f +import ru.dbotthepony.mc.otm.core.FloatSupplier import ru.dbotthepony.mc.otm.core.math.IAngle import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.Vector @@ -77,12 +78,12 @@ private fun Font.drawInBatch( text: Any, x: Float, y: Float, color: Int, drawShadow: Boolean, matrix4f: Matrix4f, buffer: MultiBufferSource, displayMode: Font.DisplayMode, effectColor: Int, packedLightCoords: Int, gravity: RenderGravity, - rounding: GravityRounding + rounding: GravityRounding, width: FloatSupplier ): Int { if (text is String) return drawInBatch( text, - gravity.x(x, this, text, rounding = rounding), + gravity.x(x, width, rounding = rounding), gravity.y(y, lineHeight.toFloat(), rounding = rounding), color, drawShadow, @@ -94,7 +95,7 @@ private fun Font.drawInBatch( else if (text is Component) return drawInBatch( text, - gravity.x(x, this, text, rounding = rounding), + gravity.x(x, width, rounding = rounding), gravity.y(y, lineHeight.toFloat(), rounding = rounding), color, drawShadow, @@ -106,7 +107,7 @@ private fun Font.drawInBatch( else if (text is FormattedCharSequence) return drawInBatch( text, - gravity.x(x, this, text, rounding = rounding), + gravity.x(x, width, rounding = rounding), gravity.y(y, lineHeight.toFloat(), rounding = rounding), color, drawShadow, @@ -126,6 +127,48 @@ private val outlinePositions = listOf( 0 to -1, ) +private class CachedTextWidth0(val font: Font, val text: Component) : FloatSupplier { + private var computed = false + private var width = 0f + + override fun getAsFloat(): Float { + if (!computed) { + width = font.width(text).toFloat() + computed = true + } + + return width + } +} + +private class CachedTextWidth1(val font: Font, val text: String) : FloatSupplier { + private var computed = false + private var width = 0f + + override fun getAsFloat(): Float { + if (!computed) { + width = font.width(text).toFloat() + computed = true + } + + return width + } +} + +private class CachedTextWidth2(val font: Font, val text: FormattedCharSequence) : FloatSupplier { + private var computed = false + private var width = 0f + + override fun getAsFloat(): Float { + if (!computed) { + width = font.width(text).toFloat() + computed = true + } + + return width + } +} + private fun Font.drawInternal( poseStack: PoseStack, text: Any, @@ -164,6 +207,15 @@ private fun Font.drawInternal( inv = 1f } + val cache = if (text is Component) + CachedTextWidth0(this, text) + else if (text is String) + CachedTextWidth1(this, text) + else if (text is FormattedCharSequence) + CachedTextWidth2(this, text) + else + throw IllegalArgumentException(text::class.qualifiedName) + if (customShadow) { if (shadowZ != 0f) { poseStack.translate(0f, 0f, shadowZ) @@ -180,7 +232,7 @@ private fun Font.drawInternal( displayMode, effectColor, packedLightCoords, - gravity, rounding) + gravity, rounding, cache) if (shadowZ != 0f) { poseStack.translate(0f, 0f, -shadowZ) @@ -204,7 +256,7 @@ private fun Font.drawInternal( displayMode, effectColor, packedLightCoords, - gravity, rounding) + gravity, rounding, cache) } if (outlineZ != 0f) { @@ -223,7 +275,7 @@ private fun Font.drawInternal( displayMode, effectColor, packedLightCoords, - gravity, rounding) + gravity, rounding, cache) if (scale != 1f) { poseStack.popPose() @@ -252,7 +304,7 @@ fun Font.draw( shadowColor: RGBAColor = RGBAColor.BLACK, shadowX: Float = 1f, shadowY: Float = 1f, - shadowZ: Float = -0.1f, + shadowZ: Float = 0.1f, customShadow: Boolean = false, rounding: GravityRounding = if (scale == 1f) GravityRounding.DEFAULT else GravityRounding.NO, drawOutline: Boolean = false, @@ -300,7 +352,7 @@ fun Font.draw( shadowColor: RGBAColor = RGBAColor.BLACK, shadowX: Float = 1f, shadowY: Float = 1f, - shadowZ: Float = -0.1f, + shadowZ: Float = 0.1f, customShadow: Boolean = false, rounding: GravityRounding = if (scale == 1f) GravityRounding.DEFAULT else GravityRounding.NO, drawOutline: Boolean = false, From d4fb6d0b241031dcba31b73f7b89f3463de8b4a3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 24 Jul 2023 09:44:13 +0700 Subject: [PATCH 0835/1199] Make androids immune to synesthesia and plague from Rats mod --- src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index 8d67188da..33d5d407b 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.datagen.tags +import net.minecraft.resources.ResourceLocation import net.minecraft.tags.BlockTags import net.minecraft.tags.ItemTags import net.minecraft.world.effect.MobEffects @@ -262,4 +263,9 @@ fun addTags(tagsProvider: TagsProvider) { MobEffects.DOLPHINS_GRACE, MobEffects.CONFUSION, ) + + tagsProvider.androidImmuneEffects.add( + ResourceLocation("rats", "plague"), + ResourceLocation("rats", "synesthesia"), + ) } From 28801252face0e94a78788caee82cc6800c55cf1 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Mon, 24 Jul 2023 21:40:35 +0300 Subject: [PATCH 0836/1199] display i/o in jade for profiled storage (energy and matter) closes #270 --- .../jade/providers/MatterStorageProvider.kt | 43 ++++++++++++++++++ .../jade/providers/MatteryEnergyProvider.kt | 44 +++++++++++++++++++ 2 files changed, 87 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterStorageProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterStorageProvider.kt index 1ed43911c..8e2d45201 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterStorageProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterStorageProvider.kt @@ -1,7 +1,10 @@ package ru.dbotthepony.mc.otm.compat.jade.providers +import net.minecraft.ChatFormatting import net.minecraft.nbt.CompoundTag +import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation +import ru.dbotthepony.mc.otm.capability.AbstractProfiledStorage import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.compat.jade.JadeColors import ru.dbotthepony.mc.otm.compat.jade.JadeTagKeys @@ -30,6 +33,18 @@ object MatterStorageProvider : IBlockComponentProvider, IServerDataProvider) { + val profiledData = CompoundTag() + +// profiledData.putDecimal("lastTickReceive", it.lastTickReceive) +// profiledData.putDecimal("lastTickTransfer", it.lastTickTransfer) + + profiledData.putDecimal("weightedReceive", it.weightedReceive) + profiledData.putDecimal("weightedTransfer", it.weightedTransfer) + + matterData.put("profiledData", profiledData) + } + data.put(JadeTagKeys.MATTER_STORAGE_DATA, matterData) } } @@ -60,5 +75,33 @@ object MatterStorageProvider : IBlockComponentProvider, IServerDataProvider) { + val profiledData = CompoundTag() + +// profiledData.putDecimal("lastTickReceive", it.lastTickReceive) +// profiledData.putDecimal("lastTickTransfer", it.lastTickTransfer) + + profiledData.putDecimal("weightedReceive", it.weightedReceive) + profiledData.putDecimal("weightedTransfer", it.weightedTransfer) + + energyData.put("profiledData", profiledData) + } + data.put(JadeTagKeys.MATTERY_ENERGY_DATA, energyData) } } @@ -58,5 +74,33 @@ object MatteryEnergyProvider : IBlockComponentProvider, IServerDataProvider Date: Tue, 25 Jul 2023 05:58:32 +0300 Subject: [PATCH 0837/1199] =?UTF-8?q?=D1=80=D0=B5=D0=BD=D0=B4=D0=B5=D1=80?= =?UTF-8?q?=20=D1=88=D0=B8=D0=B7=D1=8B=20(=D0=B8=D0=BB=D0=B8=20=D0=B6?= =?UTF-8?q?=D0=B8=D0=B4=D0=BA=D0=BE=D1=81=D1=82=D1=8F=D1=85=20=D0=B2=20?= =?UTF-8?q?=D1=82=D0=B0=D0=BD=D0=BA=D0=B0=D1=85-=D0=BF=D1=80=D0=B5=D0=B4?= =?UTF-8?q?=D0=BC=D0=B5=D1=82=D0=B0=D1=85)=20#258?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/datagen/items/ItemModels.kt | 1 - .../render/blockentity/FluidTankRenderer.kt | 151 ++++++++++++------ .../dbotthepony/mc/otm/item/FluidTankItem.kt | 14 ++ .../models/item/fluid_tank.json | 34 ++++ 4 files changed, 148 insertions(+), 52 deletions(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/models/item/fluid_tank.json diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index cfd8b083c..7db7e577b 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -32,7 +32,6 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.block(MItems.PHANTOM_ATTRACTOR) provider.block(MItems.HOLO_SIGN) provider.generated(MItems.FLUID_CAPSULE) - provider.block(MItems.FLUID_TANK) MRegistry.VENT.allItems.values.forEach(provider::block) MRegistry.VENT_ALTERNATIVE.allItems.values.forEach(provider::block) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/FluidTankRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/FluidTankRenderer.kt index 5ca459112..4d9fd6fc4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/FluidTankRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/FluidTankRenderer.kt @@ -5,88 +5,137 @@ import com.mojang.math.Axis import net.minecraft.client.renderer.* import net.minecraft.client.renderer.blockentity.BlockEntityRenderer import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider +import net.minecraft.client.renderer.entity.ItemRenderer import net.minecraft.world.inventory.InventoryMenu +import net.minecraft.world.item.BlockItem +import net.minecraft.world.item.ItemDisplayContext +import net.minecraft.world.item.ItemStack +import net.minecraft.world.level.block.HalfTransparentBlock +import net.minecraft.world.level.block.StainedGlassPaneBlock import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions +import net.minecraftforge.common.capabilities.ForgeCapabilities +import net.minecraftforge.fluids.FluidStack +import net.minecraftforge.fluids.capability.IFluidHandler import ru.dbotthepony.mc.otm.block.entity.decorative.FluidTankBlockEntity import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.linearInterpolation +import ru.dbotthepony.mc.otm.registry.MBlocks class FluidTankRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer { - private val fluidTop = 13f / 16f - private val fluidBottom = 3f / 16f - private val fluidHeight = 10f / 16f - private val fluidWidth = 15.8f / 16f - - private val fluidPadding = (1f - fluidWidth) * .5f - override fun render( tile: FluidTankBlockEntity, partialTick: Float, poseStack: PoseStack, bufferSource: MultiBufferSource, packedLight: Int, - overlayLight: Int + packedOverlay: Int ) { - val fluid = tile.synchronizedFluid + renderFluidInTank(tile.fluid, tile.synchronizedFluid, poseStack, bufferSource, packedLight, packedOverlay) + } - if (fluid.isEmpty) - return + object FluidTankItemRenderer : BlockEntityWithoutLevelRenderer(minecraft.blockEntityRenderDispatcher, minecraft.entityModels) { + override fun renderByItem( + stack: ItemStack, + displayContext: ItemDisplayContext, + poseStack: PoseStack, + bufferSource: MultiBufferSource, + packedLight: Int, + packedOverlay: Int + ) { + val model = minecraft.modelManager.blockModelShaper.getBlockModel(MBlocks.FLUID_TANK.defaultBlockState()) - val fluidLevel = fluid.amount.toFloat() / tile.fluid.getTankCapacity(0).toFloat() + stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK { + renderFluidInTank(it, it.getFluidInTank(0), poseStack, bufferSource, packedLight, packedOverlay) + } - if (fluidLevel < 0.01f) - return + val hasFoil = stack.hasFoil() + val fabulous = displayContext == ItemDisplayContext.GUI + || displayContext.firstPerson() + || (stack.item is BlockItem && ((stack.item as BlockItem).block is HalfTransparentBlock || (stack.item as BlockItem).block is StainedGlassPaneBlock)) - val data = IClientFluidTypeExtensions.of(fluid.fluid) - val texture = data.stillTexture - val sprite = minecraft.getTextureAtlas(InventoryMenu.BLOCK_ATLAS).apply(texture) - val tint = RGBAColor.argb(data.getTintColor(fluid)) - val gas = fluid.fluid.fluidType.isLighterThanAir + for (renderPass in model.getRenderPasses(stack, fabulous)) { + for (renderType in renderPass.getRenderTypes(stack, fabulous)) { + val buffer = if (fabulous) ItemRenderer.getFoilBufferDirect(bufferSource, renderType, true, hasFoil) else ItemRenderer.getFoilBuffer(bufferSource, renderType, true, hasFoil) + minecraft.itemRenderer.renderModelLists(renderPass, stack, packedLight, packedOverlay, poseStack, buffer) + } + } + } + } - val interp = linearInterpolation(fluidLevel, sprite.v1, sprite.v0) - val v1 = linearInterpolation(fluidBottom, sprite.v1, sprite.v0) + private companion object { + val fluidTop = 13f / 16f + val fluidBottom = 3f / 16f + val fluidHeight = 10f / 16f + val fluidWidth = 15.8f / 16f -// val lightLevel = fluid.fluid.fluidType.getLightLevel(fluid) // 0-15 + val fluidPadding = (1f - fluidWidth) * .5f - val builder = bufferSource.getBuffer(Sheets.translucentCullBlockSheet()) + fun renderFluidInTank( + fluidHandler: IFluidHandler, + fluid: FluidStack, + poseStack: PoseStack, + bufferSource: MultiBufferSource, + packedLight: Int, + packedOverlay: Int + ) { + if (fluid.isEmpty) + return - poseStack.pushPose() - poseStack.translate(0f, fluidBottom + (if (gas) 1f - fluidLevel else 0f) * fluidHeight, 0f) + val fluidLevel = fluid.amount.toFloat() / fluidHandler.getTankCapacity(0).toFloat() + + if (fluidLevel < 0.01f) + return + + val data = IClientFluidTypeExtensions.of(fluid.fluid) + val texture = data.stillTexture + val sprite = minecraft.getTextureAtlas(InventoryMenu.BLOCK_ATLAS).apply(texture) + val tint = RGBAColor.argb(data.getTintColor(fluid)) + val gas = fluid.fluid.fluidType.isLighterThanAir + + val interp = linearInterpolation(fluidLevel, sprite.v1, sprite.v0) + val v1 = linearInterpolation(fluidBottom, sprite.v1, sprite.v0) + + val builder = bufferSource.getBuffer(Sheets.translucentCullBlockSheet()) - for (i in 0 .. 3) { poseStack.pushPose() + poseStack.translate(0f, fluidBottom + (if (gas) 1f - fluidLevel else 0f) * fluidHeight, 0f) - poseStack.translate(0.5, 0.0, 0.5) - poseStack.rotateAround(Axis.YP.rotationDegrees(i * 90.0f), 0.0f, 1.0f, 0.0f) - poseStack.translate(-0.5f, 0f, fluidWidth * .5f) + for (i in 0 .. 3) { + poseStack.pushPose() + + poseStack.translate(0.5, 0.0, 0.5) + poseStack.rotateAround(Axis.YP.rotationDegrees(i * 90.0f), 0.0f, 1.0f, 0.0f) + poseStack.translate(-0.5f, 0f, fluidWidth * .5f) + + val matrix = poseStack.last().pose() + + builder.vertex(matrix, fluidPadding, 0f, 0f).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u0, v1).overlayCoords(packedOverlay).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() + builder.vertex(matrix, fluidPadding + fluidWidth, 0f, 0f).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u1, v1).overlayCoords(packedOverlay).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() + builder.vertex(matrix, fluidPadding + fluidWidth, fluidLevel * fluidHeight, 0f).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u1, interp).overlayCoords(packedOverlay).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() + builder.vertex(matrix, fluidPadding, fluidLevel * fluidHeight, 0f).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u0, interp).overlayCoords(packedOverlay).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() + + poseStack.popPose() + } val matrix = poseStack.last().pose() - builder.vertex(matrix, fluidPadding, 0f, 0f).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u0, v1).overlayCoords(overlayLight).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() - builder.vertex(matrix, fluidPadding + fluidWidth, 0f, 0f).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u1, v1).overlayCoords(overlayLight).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() - builder.vertex(matrix, fluidPadding + fluidWidth, fluidLevel * fluidHeight, 0f).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u1, interp).overlayCoords(overlayLight).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() - builder.vertex(matrix, fluidPadding, fluidLevel * fluidHeight, 0f).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u0, interp).overlayCoords(overlayLight).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() + if (!gas && fluidLevel < 1f) { // top + builder.vertex(matrix, fluidPadding, fluidLevel * fluidHeight, fluidPadding + fluidWidth).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u0, sprite.v1).overlayCoords(packedOverlay).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() + builder.vertex(matrix, fluidPadding + fluidWidth, fluidLevel * fluidHeight, fluidPadding + fluidWidth).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u1, sprite.v1).overlayCoords(packedOverlay).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() + builder.vertex(matrix, fluidPadding + fluidWidth, fluidLevel * fluidHeight, fluidPadding).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u1, sprite.v0).overlayCoords(packedOverlay).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() + builder.vertex(matrix, fluidPadding, fluidLevel * fluidHeight, fluidPadding).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u0, sprite.v0).overlayCoords(packedOverlay).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() + } + + if (gas && fluidLevel < 1f) { // bottom + builder.vertex(matrix, fluidPadding, 0f, fluidPadding).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u0, sprite.v0).overlayCoords(packedOverlay).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() + builder.vertex(matrix, fluidPadding + fluidWidth, 0f, fluidPadding).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u1, sprite.v0).overlayCoords(packedOverlay).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() + builder.vertex(matrix, fluidPadding + fluidWidth, 0f, fluidPadding + fluidWidth).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u1, sprite.v1).overlayCoords(packedOverlay).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() + builder.vertex(matrix, fluidPadding, 0f, fluidPadding + fluidWidth).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u0, sprite.v1).overlayCoords(packedOverlay).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() + } poseStack.popPose() } - - val matrix = poseStack.last().pose() - - if (!gas && fluidLevel < 1f) { // top - builder.vertex(matrix, fluidPadding, fluidLevel * fluidHeight, fluidPadding + fluidWidth).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u0, sprite.v1).overlayCoords(overlayLight).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() - builder.vertex(matrix, fluidPadding + fluidWidth, fluidLevel * fluidHeight, fluidPadding + fluidWidth).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u1, sprite.v1).overlayCoords(overlayLight).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() - builder.vertex(matrix, fluidPadding + fluidWidth, fluidLevel * fluidHeight, fluidPadding).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u1, sprite.v0).overlayCoords(overlayLight).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() - builder.vertex(matrix, fluidPadding, fluidLevel * fluidHeight, fluidPadding).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u0, sprite.v0).overlayCoords(overlayLight).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() - } - - if (gas && fluidLevel < 1f) { // bottom - builder.vertex(matrix, fluidPadding, 0f, fluidPadding).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u0, sprite.v0).overlayCoords(overlayLight).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() - builder.vertex(matrix, fluidPadding + fluidWidth, 0f, fluidPadding).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u1, sprite.v0).overlayCoords(overlayLight).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() - builder.vertex(matrix, fluidPadding + fluidWidth, 0f, fluidPadding + fluidWidth).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u1, sprite.v1).overlayCoords(overlayLight).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() - builder.vertex(matrix, fluidPadding, 0f, fluidPadding + fluidWidth).color(tint.red, tint.green, tint.blue, tint.alpha).uv(sprite.u0, sprite.v1).overlayCoords(overlayLight).uv2(packedLight).normal(0.0f, 1.0f, 0.0f).endVertex() - } - - poseStack.popPose() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidTankItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidTankItem.kt index 582c14b2a..911e44120 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidTankItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidTankItem.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.item +import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer import net.minecraft.nbt.CompoundTag import net.minecraft.network.chat.Component import net.minecraft.world.InteractionResult @@ -8,14 +9,17 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag import net.minecraft.world.item.context.UseOnContext import net.minecraft.world.level.Level +import net.minecraftforge.client.extensions.common.IClientItemExtensions import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.capabilities.ICapabilityProvider import ru.dbotthepony.mc.otm.block.decorative.FluidTankBlock import ru.dbotthepony.mc.otm.block.entity.decorative.FluidTankBlockEntity import ru.dbotthepony.mc.otm.capability.fluid.BlockMatteryFluidHandler import ru.dbotthepony.mc.otm.capability.fluidLevel +import ru.dbotthepony.mc.otm.client.render.blockentity.FluidTankRenderer import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.ifPresentK +import java.util.function.Consumer import java.util.function.IntSupplier class FluidTankItem(block: FluidTankBlock, properties: Properties, val capacity: IntSupplier) : BlockItem(block, properties) { @@ -54,4 +58,14 @@ class FluidTankItem(block: FluidTankBlock, properties: Properties, val capacity: it.fluidLevel(pTooltip) } } + + override fun initializeClient(consumer: Consumer) { + super.initializeClient(consumer) + + consumer.accept(object : IClientItemExtensions { + override fun getCustomRenderer(): BlockEntityWithoutLevelRenderer { + return FluidTankRenderer.FluidTankItemRenderer + } + }) + } } diff --git a/src/main/resources/assets/overdrive_that_matters/models/item/fluid_tank.json b/src/main/resources/assets/overdrive_that_matters/models/item/fluid_tank.json new file mode 100644 index 000000000..ee9352db8 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/item/fluid_tank.json @@ -0,0 +1,34 @@ +{ + "parent": "minecraft:builtin/entity", + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 2], + "translation": [0, 2.75, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 225, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "scale": [0.5, 0.5, 0.5] + } + } +} \ No newline at end of file From 8a78b299c56ddce9af544a7675d5be225a6aa348 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 25 Jul 2023 14:19:35 +0700 Subject: [PATCH 0838/1199] Revamp job event loops, move jobs to codecs Add PatternState codecs Add ReplicationTask codecs Instead of returning job status on job tick, now downstream code directly update status of provided job status object Make Matter Replicator and Matter Recycler not do full stop when there is not enough matter/nowhere to put matter --- .../dbotthepony/mc/otm/block/entity/Jobs.kt | 323 +++++++++++++----- .../block/entity/MatteryWorkerBlockEntity.kt | 29 +- .../matter/MatterDecomposerBlockEntity.kt | 67 ++-- .../entity/matter/MatterPanelBlockEntity.kt | 8 +- .../matter/MatterRecyclerBlockEntity.kt | 73 ++-- .../matter/MatterReplicatorBlockEntity.kt | 171 +++------- .../entity/matter/MatterScannerBlockEntity.kt | 33 +- .../block/entity/tech/CobblerBlockEntity.kt | 16 +- .../entity/tech/PlatePressBlockEntity.kt | 22 +- .../entity/tech/PoweredFurnaceBlockEntity.kt | 21 +- .../otm/capability/MatteryPlayerCapability.kt | 23 +- .../mc/otm/capability/matter/PatternState.kt | 41 ++- .../otm/capability/matter/ReplicationTask.kt | 75 ++-- .../jade/providers/MatteryWorkerProvider.kt | 6 +- .../mc/otm/data/ComparableCodec.kt | 51 +++ .../dbotthepony/mc/otm/data/DecimalCodec.kt | 55 ++- .../kotlin/ru/dbotthepony/mc/otm/data/Ext.kt | 5 + .../ru/dbotthepony/mc/otm/data/UUIDCodec.kt | 26 ++ 18 files changed, 614 insertions(+), 431 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/ComparableCodec.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/UUIDCodec.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt index e6517b2df..33f9e9b5c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt @@ -1,114 +1,229 @@ package ru.dbotthepony.mc.otm.block.entity +import com.mojang.datafixers.Products +import com.mojang.serialization.Codec +import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.nbt.CompoundTag +import net.minecraft.nbt.NbtOps import net.minecraft.world.item.ItemStack import net.minecraftforge.common.util.INBTSerializable +import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.capability.IMatteryUpgrade import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.math.getDecimal -import ru.dbotthepony.mc.otm.core.math.set import ru.dbotthepony.mc.otm.core.math.weakEqualDoubles import ru.dbotthepony.mc.otm.core.math.weakGreaterThan import ru.dbotthepony.mc.otm.core.math.weakLessThan -import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.data.DecimalCodec +import ru.dbotthepony.mc.otm.data.minRange private fun isReason(status: Any?, reason: Any) = status == null || status == reason +private val LOGGER = LogManager.getLogger() -interface IMachineJob { +interface IJob { val ticks: Double val powerUsage: Decimal val experience: Float get() = 0f - - fun serializeNBT(): CompoundTag } -open class MachineJob : IMachineJob { - final override val ticks: Double - final override val powerUsage: Decimal - final override val experience: Float +open class Job( + final override val ticks: Double, + final override val powerUsage: Decimal = Decimal.ZERO, + final override val experience: Float = 0f +) : IJob { + companion object { + fun basicCodec(builder: RecordCodecBuilder.Instance): Products.P3, Double, Decimal, Float> { + return builder.group( + Codec.doubleRange(0.0, Double.MAX_VALUE).fieldOf("ticks").forGetter(Job::ticks), + DecimalCodec.fieldOf("powerUsage").forGetter(Job::powerUsage), // не надо указывать минимальную энергию как 0, + // ибо мы можем таким образом использовать это для создания работ генератора + Codec.floatRange(0f, Float.MAX_VALUE).optionalFieldOf("experience", 0f).forGetter(Job::experience), + ) + } - constructor( - ticks: Double, - powerUsage: Decimal = Decimal.ZERO, - experience: Float = 0f, - ) { - this.ticks = ticks - this.powerUsage = powerUsage - this.experience = experience - } + fun plainCodec(builder: RecordCodecBuilder.Instance): Products.P2, Double, Decimal> { + return builder.group( + Codec.doubleRange(0.0, Double.MAX_VALUE).fieldOf("ticks").forGetter(Job::ticks), + DecimalCodec.fieldOf("powerUsage").forGetter(Job::powerUsage), // не надо указывать минимальную энергию как 0, + // ибо мы можем таким образом использовать это для создания работ генератора + ) + } - constructor( - tag: CompoundTag - ) : this(tag.getDouble("Ticks"), tag.getDecimal("EnergyUsage"), tag.getFloat("Experience")) - - override fun serializeNBT(): CompoundTag { - return CompoundTag().also { - it["Ticks"] = ticks - it["EnergyUsage"] = powerUsage - it["Experience"] = experience + val CODEC: Codec by lazy { + RecordCodecBuilder.create { + basicCodec(it).apply(it, ::Job) + } } } } -open class MachineItemJob : MachineJob { - val itemStack: ItemStack +open class ItemJob( + val itemStack: ItemStack, + ticks: Double, + power: Decimal = Decimal.ZERO, + experience: Float = 0f +) : Job(ticks, power, experience) { + companion object { + fun itemCodec(builder: RecordCodecBuilder.Instance): Products.P4, ItemStack, Double, Decimal, Float> { + return builder.group(ItemStack.CODEC.fieldOf("itemStack").forGetter(ItemJob::itemStack)).and(basicCodec(builder)) + } - constructor( - itemStack: ItemStack, - ticks: Double, - power: Decimal = Decimal.ZERO, - experience: Float = 0f, - ) : super(ticks, power, experience) { - this.itemStack = itemStack - } - - constructor( - tag: CompoundTag - ) : super(tag) { - this.itemStack = (tag["Item"] as? CompoundTag)?.let { ItemStack.of(it) } ?: ItemStack.EMPTY - } - - override fun serializeNBT(): CompoundTag { - return super.serializeNBT().also { - it["Item"] = itemStack.serializeNBT() + val CODEC: Codec by lazy { + RecordCodecBuilder.create { + itemCodec(it).apply(it, ::ItemJob) + } } } } -data class JobStatus( - val success: Boolean, - val throttleTicks: Int = 0, - val idleReason: MachineJobEventLoop.IdleReason? = null, - val newDrainedPower: Decimal? = null -) { - init { - require(throttleTicks >= 0) { "Negative amount of ticks to throttle: $throttleTicks" } +class JobStatus( + var requiredPower: Decimal, + val extractedPower: Decimal, + ticksAdvanced: Double, + val job: T, + val workTicks: Double, +) : IJob by job { + constructor(job: T, workTicks: Double) : this(Decimal.ZERO, Decimal.ZERO, 0.0, job, workTicks) + + val workProgress: Float + get() { + return ((workTicks + workTicks) / job.ticks).coerceAtMost(1.0).toFloat() + } + + var success = true + + var ticksAdvanced = ticksAdvanced + set(value) { + require(value >= 0.0) { "Invalid amount of ticks to advance: $value" } + field = value + } + + var throttleTicks = 0 + set(value) { + require(value >= 0) { "Invalid amount of ticks to throttle: $value" } + if (value != 0) success = false + field = value + } + + var idleReason: Any? = null + set(value) { + if (value != null) success = false + field = value + } + + /** + * You don't have to actually call this, JobStatus is in this state by default + * + * But this is handy to call this when doing early returns, to clearly state that "we are in success" + */ + fun success() { + this.success = true + this.throttleTicks = 0 + this.idleReason = null } - companion object { - val SUCCESS = JobStatus(true) - val FAILURE = JobStatus(false) - val FAILURE_ITEM = JobStatus(false, 20, MachineJobEventLoop.IdleReason.ITEM) - val FAILURE_MATTER = JobStatus(false, 20, MachineJobEventLoop.IdleReason.MATTER) - val FAILURE_WAIT = JobStatus(false, 100) - val FAILURE_WAIT_FAST = JobStatus(false, 20) + fun throttle() { + this.success = false + this.throttleTicks = 100 + } + + fun throttleFast() { + this.success = false + this.throttleTicks = 20 + } + + fun noItem(throttleTicks: Int = 20) { + this.success = false + idleReason = MachineJobEventLoop.IdleReason.ITEM + this.throttleTicks = throttleTicks + } + + fun noPower(throttleTicks: Int = 20) { + this.success = false + idleReason = MachineJobEventLoop.IdleReason.POWER + this.throttleTicks = throttleTicks + } + + fun noMatter(throttleTicks: Int = 20) { + this.success = false + idleReason = MachineJobEventLoop.IdleReason.MATTER + this.throttleTicks = throttleTicks + } + + fun noPattern(throttleTicks: Int = 20) { + this.success = false + idleReason = MachineJobEventLoop.IdleReason.PATTERN + this.throttleTicks = throttleTicks + } + + fun observe(throttleTicks: Int = 20) { + this.success = false + idleReason = MachineJobEventLoop.IdleReason.OBSERVING + this.throttleTicks = throttleTicks + } + + fun failure(reason: Any) { + this.success = false + idleReason = reason + } + + fun failure(throttleTicks: Int = 0) { + this.success = false + this.throttleTicks = throttleTicks + } + + fun scale(value: Decimal) { + require(value >= Decimal.ZERO) { "Attempted to scale by negative value: $value" } + if (value == Decimal.ONE) + return + + if (value.isZero) { + ticksAdvanced = 0.0 + requiredPower = Decimal.ZERO + success = false + } else { + requiredPower *= value + ticksAdvanced *= value.toDouble() + } + } + + fun scale(value: Double) { + require(value >= 0.0) { "Attempted to scale by negative value: $value" } + if (value == 1.0) + return + + if (value == 0.0) { + ticksAdvanced = 0.0 + requiredPower = Decimal.ZERO + success = false + } else { + requiredPower *= value + ticksAdvanced *= value + } } } -data class JobContainer(val job: JobType? = null, val idleReason: Any? = null, val throttleTicks: Int = 0) { +data class JobContainer(val job: JobType? = null, val idleReason: Any? = null, val throttleTicks: Int = 0) { init { require(throttleTicks >= 0) { "Negative amount of ticks to throttle: $throttleTicks" } + + if (job != null && idleReason != null) { + throw IllegalArgumentException("Can't have both job and idle reason specified") + } + + if (job != null && throttleTicks != 0) { + throw IllegalArgumentException("Can't have both job and throttle ticks specified") + } } companion object { - fun success(job: JobType): JobContainer { + fun success(job: JobType): JobContainer { return JobContainer(job, null) } - fun failure(reason: Any?): JobContainer { + fun failure(reason: Any?): JobContainer { return JobContainer(null, reason) } @@ -120,41 +235,40 @@ data class JobContainer(val job: JobType? = null, val idl private val observe = JobContainer(null, MachineJobEventLoop.IdleReason.OBSERVING) @Suppress("unchecked_cast") - fun failure(): JobContainer { + fun failure(): JobContainer { return empty as JobContainer } @Suppress("unchecked_cast") - fun noItem(): JobContainer { + fun noItem(): JobContainer { return noItem as JobContainer } @Suppress("unchecked_cast") - fun noEnergy(): JobContainer { + fun noEnergy(): JobContainer { return noEnergy as JobContainer } @Suppress("unchecked_cast") - fun noMatter(): JobContainer { + fun noMatter(): JobContainer { return noMatter as JobContainer } @Suppress("unchecked_cast") - fun noPattern(): JobContainer { + fun noPattern(): JobContainer { return noPattern as JobContainer } @Suppress("unchecked_cast") - fun observe(): JobContainer { + fun observe(): JobContainer { return observe as JobContainer } } } -abstract class MachineJobEventLoop : INBTSerializable { +abstract class MachineJobEventLoop(val codec: Codec) : INBTSerializable { protected abstract val energy: IMatteryEnergyStorage? protected abstract val isBlockedByRedstone: Boolean - protected abstract fun deserializeJob(nbt: CompoundTag): JobType? protected abstract val upgrades: IMatteryUpgrade? var currentJob: JobType? = null @@ -212,7 +326,17 @@ abstract class MachineJobEventLoop : INBTSerializable nbt["WorkTicks"] = workTicks - currentJob?.let { nbt["Job"] = it.serializeNBT() } + + currentJob?.let { + codec.encode(it, NbtOps.INSTANCE, NbtOps.INSTANCE.empty()).get().map( + { + nbt["Job"] = it + }, + { + LOGGER.error("Failed to serialize job data, it will not persist", RuntimeException(it.message())) + } + ) + } } } @@ -220,27 +344,36 @@ abstract class MachineJobEventLoop : INBTSerializable) /** * Called when there is nothing to do and we are not idling */ protected abstract fun computeNextJob(): JobContainer - protected open fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: JobType): JobStatus { - return JobStatus.SUCCESS - } + protected open fun onJobTick(status: JobStatus) {} /** * Advances job loop by specified [ticks]. If machine is speed up by upgrades, @@ -317,8 +450,11 @@ abstract class MachineJobEventLoop : INBTSerializable : INBTSerializable : INBTSerializable( +abstract class MatteryWorkerBlockEntity( type: BlockEntityType<*>, blockPos: BlockPos, blockState: BlockState, - val jobDeserializer: (tag: CompoundTag) -> JobType?, + jobCodec: Codec, maxJobs: Int = 1, ) : MatteryPoweredBlockEntity(type, blockPos, blockState) { val jobEventLoops: ImmutableList> = immutableList(maxJobs) { id -> - object : MachineJobEventLoop() { + object : MachineJobEventLoop(jobCodec) { override val energy: IMatteryEnergyStorage? get() = matteryEnergy override val isBlockedByRedstone: Boolean @@ -41,12 +42,8 @@ abstract class MatteryWorkerBlockEntity( override val upgrades: IMatteryUpgrade? get() = this@MatteryWorkerBlockEntity.upgrades - override fun deserializeJob(nbt: CompoundTag): JobType? { - return jobDeserializer.invoke(nbt) - } - - override fun onJobFinish(job: JobType): JobStatus { - return this@MatteryWorkerBlockEntity.onJobFinish(job, id) + override fun onJobFinish(status: JobStatus) { + return this@MatteryWorkerBlockEntity.onJobFinish(status, id) } override fun computeNextJob(): JobContainer { @@ -57,8 +54,8 @@ abstract class MatteryWorkerBlockEntity( this@MatteryWorkerBlockEntity.jobUpdated(new, old, id) } - override fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: JobType): JobStatus { - return this@MatteryWorkerBlockEntity.onWorkTick(requiredPower, extractedPower, ticksAdvanced, job, id) + override fun onJobTick(status: JobStatus) { + return this@MatteryWorkerBlockEntity.onJobTick(status, id) } } } @@ -72,12 +69,10 @@ abstract class MatteryWorkerBlockEntity( } protected open fun jobUpdated(new: JobType?, old: JobType?, id: Int) {} - protected abstract fun onJobFinish(job: JobType, id: Int): JobStatus + protected abstract fun onJobFinish(status: JobStatus, id: Int) protected abstract fun computeNextJob(id: Int): JobContainer - protected open fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: JobType, id: Int): JobStatus { - return JobStatus.SUCCESS - } + protected open fun onJobTick(status: JobStatus, id: Int) {} override fun saveShared(nbt: CompoundTag) { super.saveShared(nbt) @@ -148,6 +143,8 @@ abstract class MatteryWorkerBlockEntity( } companion object { + private val LOGGER = LogManager.getLogger() + fun appendHoverText(itemStack: ItemStack, blockGetter: BlockGetter?, tooltips: MutableList, flag: TooltipFlag) { itemStack.tag ?: return diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index 3fdb11ce5..94af8254c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -1,5 +1,7 @@ package ru.dbotthepony.mc.otm.block.entity.matter +import com.mojang.serialization.Codec +import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.core.BlockPos import net.minecraft.nbt.CompoundTag import net.minecraft.world.entity.player.Inventory @@ -11,7 +13,7 @@ import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeConfigSpec import ru.dbotthepony.mc.otm.block.entity.JobContainer import ru.dbotthepony.mc.otm.block.entity.JobStatus -import ru.dbotthepony.mc.otm.block.entity.MachineJob +import ru.dbotthepony.mc.otm.block.entity.Job import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability @@ -30,6 +32,8 @@ import ru.dbotthepony.mc.otm.core.math.getDecimal import ru.dbotthepony.mc.otm.core.math.set import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.WriteOnce +import ru.dbotthepony.mc.otm.data.DecimalCodec +import ru.dbotthepony.mc.otm.data.minRange import ru.dbotthepony.mc.otm.graph.matter.MatterGraph import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode import ru.dbotthepony.mc.otm.item.matter.MatterDustItem @@ -93,32 +97,23 @@ fun moveMatterAsDustIntoContainer(_matterValue: Decimal, container: MatteryConta } class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) - : MatteryWorkerBlockEntity(MBlockEntities.MATTER_DECOMPOSER, pos, state, ::DecomposerJob) { - - class DecomposerJob : MachineJob { - val toDust: Boolean - var matterValue: Decimal - - constructor(tag: CompoundTag) : super(tag) { - toDust = tag.getBoolean(TO_DUST_KEY) - matterValue = tag.getDecimal(MATTER_VALUE_KEY) - } - - constructor(toDust: Boolean, matterValue: Decimal, ticks: Double) : super(ticks, BASE_CONSUMPTION) { - this.toDust = toDust - this.matterValue = matterValue - } - - override fun serializeNBT(): CompoundTag { - return super.serializeNBT().also { - it[TO_DUST_KEY] = toDust - it[MATTER_VALUE_KEY] = matterValue - } - } + : MatteryWorkerBlockEntity(MBlockEntities.MATTER_DECOMPOSER, pos, state, DecomposerJob.CODEC) { + class DecomposerJob( + val toDust: Boolean, + var matterValue: Decimal, + ticks: Double, + ) : Job(ticks, BASE_CONSUMPTION) { companion object { - const val TO_DUST_KEY = "toDust" - const val MATTER_VALUE_KEY = "matterValue" + val CODEC: Codec by lazy { + RecordCodecBuilder.create { + it.group( + Codec.BOOL.fieldOf("toDust").forGetter(DecomposerJob::toDust), + DecimalCodec.minRange(Decimal.ZERO).fieldOf("matterValue").forGetter(DecomposerJob::matterValue), + Codec.DOUBLE.minRange(0.0).fieldOf("ticks").forGetter(DecomposerJob::ticks) + ).apply(it, ::DecomposerJob) + } + } } } @@ -165,22 +160,18 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) return MatterDecomposerMenu(containerID, inventory, this) } - override fun onJobFinish(job: DecomposerJob, id: Int): JobStatus { - if (job.toDust) { - job.matterValue = moveMatterAsDustIntoContainer(job.matterValue, outputContainer, 0, 1) + override fun onJobFinish(status: JobStatus, id: Int) { + if (status.job.toDust) { + status.job.matterValue = moveMatterAsDustIntoContainer(status.job.matterValue, outputContainer, 0, 1) - if (!job.matterValue.isZero) - return JobStatus.FAILURE_WAIT_FAST + if (!status.job.matterValue.isZero) + status.throttleFast() + } else { + status.job.matterValue -= matter.receiveMatter(status.job.matterValue, false) - return JobStatus.SUCCESS + if (status.job.matterValue.isPositive) + status.noMatter() } - - job.matterValue -= matter.receiveMatter(job.matterValue, false) - - if (job.matterValue.isPositive) - return JobStatus.FAILURE_MATTER - - return JobStatus.SUCCESS } override fun computeNextJob(id: Int): JobContainer { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt index b51146f0e..12b9fc174 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt @@ -9,8 +9,6 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import ru.dbotthepony.mc.otm.capability.MatteryCapability -import java.util.HashMap -import java.util.UUID import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.ListTag import net.minecraft.server.level.ServerLevel @@ -29,7 +27,7 @@ import ru.dbotthepony.mc.otm.graph.matter.MatterGraph import ru.dbotthepony.mc.otm.graph.matter.MatterNode import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode import ru.dbotthepony.mc.otm.registry.MBlockEntities -import java.util.ArrayList +import java.util.* import java.util.stream.Stream class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : @@ -100,7 +98,7 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : for ((key, task) in _tasks) { if (task.required > 0) { - val pattern = task.patternId?.let(graph::getPattern) ?: continue + val pattern = task.patternId.map(graph::getPattern).orElse(null) ?: continue if (!simulate) { val new = task.allocate() @@ -198,7 +196,7 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } fun addTask(state: IPatternState, count: Int): IReplicationTask<*> { - val task = ReplicationTask(UUID.randomUUID(), state.id, state.item, 0, 0, count) + val task = ReplicationTask(UUID.randomUUID(), Optional.of(state.id), state.item, 0, 0, count) _tasks[task.id] = task matterNode.graph.onMatterTaskCreated(task) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index b47136e3f..b67971e95 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -1,22 +1,19 @@ package ru.dbotthepony.mc.otm.block.entity.matter +import com.mojang.serialization.Codec +import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.core.BlockPos -import net.minecraft.nbt.CompoundTag import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState -import net.minecraftforge.common.ForgeConfigSpec -import net.minecraftforge.common.ForgeConfigSpec.ConfigValue import ru.dbotthepony.mc.otm.block.entity.JobContainer import ru.dbotthepony.mc.otm.block.entity.JobStatus -import ru.dbotthepony.mc.otm.block.entity.MachineJob -import ru.dbotthepony.mc.otm.config.ConciseBalanceValues +import ru.dbotthepony.mc.otm.block.entity.Job import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection -import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage @@ -30,40 +27,20 @@ import ru.dbotthepony.mc.otm.graph.matter.MatterGraph import ru.dbotthepony.mc.otm.item.matter.MatterDustItem import ru.dbotthepony.mc.otm.menu.matter.MatterRecyclerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities -import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue -import ru.dbotthepony.mc.otm.core.math.defineDecimal -import ru.dbotthepony.mc.otm.registry.MNames -import ru.dbotthepony.mc.otm.core.util.WriteOnce -import ru.dbotthepony.mc.otm.core.math.getDecimal -import ru.dbotthepony.mc.otm.core.math.set +import ru.dbotthepony.mc.otm.data.DecimalCodec +import ru.dbotthepony.mc.otm.data.minRange import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) - : MatteryWorkerBlockEntity(MBlockEntities.MATTER_RECYCLER, blockPos, blockState, ::RecyclerJob) { - - class RecyclerJob : MachineJob { - var totalMatter: Decimal - - constructor( - ticks: Double, - powerUsage: Decimal, - totalMatter: Decimal - ) : super(ticks, powerUsage) { - this.totalMatter = totalMatter - } - - constructor(tag: CompoundTag) : super(tag) { - this.totalMatter = tag.getDecimal(KEY) - } - - override fun serializeNBT(): CompoundTag { - return super.serializeNBT().also { - it[KEY] = totalMatter - } - } + : MatteryWorkerBlockEntity(MBlockEntities.MATTER_RECYCLER, blockPos, blockState, RecyclerJob.CODEC) { + class RecyclerJob(ticks: Double, powerUsage: Decimal, var totalMatter: Decimal) : Job(ticks, powerUsage) { companion object { - const val KEY = "totalMatter" + val CODEC: Codec by lazy { + RecordCodecBuilder.create { + plainCodec(it).and(DecimalCodec.minRange(Decimal.ZERO).fieldOf("totalMatter").forGetter(RecyclerJob::totalMatter)).apply(it, ::RecyclerJob) + } + } } } @@ -108,18 +85,18 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) return MatterRecyclerMenu(containerID, inventory, this) } - override fun onJobFinish(job: RecyclerJob, id: Int): JobStatus { + override fun onJobFinish(status: JobStatus, id: Int) { + val job = status.job + if (job.totalMatter.isPositive) { val received = matter.receiveMatter(job.totalMatter, true) if (job.totalMatter != received) - return JobStatus.FAILURE_MATTER + return status.noMatter() matter.receiveMatter(job.totalMatter, false) job.totalMatter -= received } - - return JobStatus.SUCCESS } override fun computeNextJob(id: Int): JobContainer { @@ -147,20 +124,16 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) ) } - override fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: RecyclerJob, id: Int): JobStatus { - val receive = job.totalMatter.coerceAtMost(MachinesConfig.MATTER_RECYCLER_MATTER_PER_TICK.get() * ticksAdvanced) + override fun onJobTick(status: JobStatus, id: Int) { + val job = status.job + val toReceive = job.totalMatter.coerceAtMost(MachinesConfig.MATTER_RECYCLER_MATTER_PER_TICK.get() * status.ticksAdvanced) - if (receive.isZero) - return JobStatus.SUCCESS + if (toReceive.isZero) + return status.success() - val received = matter.receiveMatter(receive, true) - - if (receive != received) - return JobStatus.FAILURE_MATTER - - matter.receiveMatter(receive, false) + val received = matter.receiveMatter(toReceive, false) + status.scale(received / toReceive) job.totalMatter -= received - return JobStatus.SUCCESS } override fun tick() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index a71405fc6..8ee668a7b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -1,7 +1,8 @@ package ru.dbotthepony.mc.otm.block.entity.matter +import com.mojang.serialization.Codec +import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.core.BlockPos -import net.minecraft.nbt.CompoundTag import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu @@ -11,7 +12,7 @@ import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeConfigSpec import ru.dbotthepony.mc.otm.block.entity.JobContainer import ru.dbotthepony.mc.otm.block.entity.JobStatus -import ru.dbotthepony.mc.otm.block.entity.MachineItemJob +import ru.dbotthepony.mc.otm.block.entity.ItemJob import ru.dbotthepony.mc.otm.block.entity.MachineJobEventLoop import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection @@ -28,76 +29,43 @@ import ru.dbotthepony.mc.otm.container.UpgradeContainer import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal -import ru.dbotthepony.mc.otm.core.math.getDecimal -import ru.dbotthepony.mc.otm.core.math.set -import ru.dbotthepony.mc.otm.core.nbt.map -import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.WriteOnce +import ru.dbotthepony.mc.otm.data.DecimalCodec +import ru.dbotthepony.mc.otm.data.UUIDCodec +import ru.dbotthepony.mc.otm.data.minRange import ru.dbotthepony.mc.otm.graph.matter.MatterNode import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.menu.matter.MatterReplicatorMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MNames +import java.util.* class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : - MatteryWorkerBlockEntity(MBlockEntities.MATTER_REPLICATOR, p_155229_, p_155230_, { - try { - ReplicatorJob(it) - } catch(err: NoSuchElementException) { - null - } - }) { - - class ReplicatorJob : MachineItemJob { - val matterPerTick: Decimal - val task: ReplicationTask - var matterValue: Decimal - val pattern: PatternState? - val asDust: Boolean - - constructor(tag: CompoundTag) : super(tag) { - matterPerTick = tag.getDecimal(MATTER_PER_TICK_KEY) - matterValue = tag.getDecimal(MATTER_VALUE_KEY) - pattern = tag.map(PATTERN_KEY, PatternState::deserializeNBT) - asDust = tag.getBoolean(AS_DUST_KEY) - task = tag.map(TASK_KEY, ReplicationTask::deserializeNBT) ?: throw NoSuchElementException("Unable to deserialize matter task") - } - - constructor( - itemStack: ItemStack, - matterPerTick: Decimal, - task: ReplicationTask, - matterValue: Decimal, - pattern: PatternState?, - asDust: Boolean, - ticks: Double, - ) : super(itemStack, ticks, BASE_CONSUMPTION) { - this.matterPerTick = matterPerTick - this.task = task - this.matterValue = matterValue - this.pattern = pattern - this.asDust = asDust - } - - override fun serializeNBT(): CompoundTag { - return super.serializeNBT().also { - it[MATTER_PER_TICK_KEY] = this.matterPerTick - it[TASK_KEY] = this.task.serializeNBT() - it[MATTER_VALUE_KEY] = this.matterValue - - if (this.pattern != null) - it[PATTERN_KEY] = this.pattern.serializeNBT() - - it[AS_DUST_KEY] = this.asDust - } - } + MatteryWorkerBlockEntity(MBlockEntities.MATTER_REPLICATOR, p_155229_, p_155230_, ReplicatorJob.CODEC) { + class ReplicatorJob( + itemStack: ItemStack, + val matterPerTick: Decimal, + val task: UUID, + var matterValue: Decimal, + val pattern: Optional, + val asDust: Boolean, + ticks: Double, + ) : ItemJob(itemStack, ticks, BASE_CONSUMPTION) { companion object { - const val MATTER_PER_TICK_KEY = "matterPerTick" - const val MATTER_VALUE_KEY = "matterValue" - const val PATTERN_KEY = "pattern" - const val AS_DUST_KEY = "asDust" - const val TASK_KEY = "task" + val CODEC: Codec by lazy { + RecordCodecBuilder.create { + it.group( + ItemStack.CODEC.fieldOf("itemStack").forGetter(ReplicatorJob::itemStack), + DecimalCodec.minRange(Decimal.ZERO).fieldOf("matterPerTick").forGetter(ReplicatorJob::matterPerTick), + UUIDCodec.fieldOf("task").forGetter(ReplicatorJob::task), + DecimalCodec.minRange(Decimal.ZERO).fieldOf("matterValue").forGetter(ReplicatorJob::matterValue), + PatternState.CODEC.optionalFieldOf("pattern").forGetter(ReplicatorJob::pattern), + Codec.BOOL.fieldOf("asDust").forGetter(ReplicatorJob::asDust), + Codec.doubleRange(0.0, Double.MAX_VALUE).fieldOf("ticks").forGetter(ReplicatorJob::ticks), + ).apply(it, ::ReplicatorJob) + } + } } } @@ -141,24 +109,24 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return MatterReplicatorMenu(containerID, inventory, this) } - override fun onJobFinish(job: ReplicatorJob, id: Int): JobStatus { + override fun onJobFinish(status: JobStatus, id: Int) { + val job = status.job + if (job.asDust) { job.matterValue = moveMatterAsDustIntoContainer(job.matterValue, container, OUTPUT_DUST_MAIN, OUTPUT_DUST_STACKING) if (!job.matterValue.isZero) { - return JobStatus.FAILURE_WAIT + return status.throttle() } - matterNode.graph.notifyTaskCompletion(job.task.id) - return JobStatus.SUCCESS - } + matterNode.graph.notifyTaskCompletion(job.task) + } else { + if (!container.fullyAddItem(job.itemStack, FIRST_ACTUAL_OUTPUT_SLOT .. LAST_ACTUAL_OUTPUT_SLOT)) { + return status.noItem() + } - if (!container.fullyAddItem(job.itemStack, FIRST_ACTUAL_OUTPUT_SLOT .. LAST_ACTUAL_OUTPUT_SLOT)) { - return JobStatus.FAILURE_ITEM + matterNode.graph.notifyTaskCompletion(job.task) } - - matterNode.graph.notifyTaskCompletion(job.task.id) - return JobStatus.SUCCESS } override fun setRemoved() { @@ -211,64 +179,29 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return JobContainer.success(ReplicatorJob( itemStack = stack, matterPerTick = matter.matter / ticks, - task = allocation.task.asImmutable(), + task = allocation.task.id, matterValue = matter.matter, - pattern = allocation.pattern?.asImmutable(), + pattern = Optional.ofNullable(allocation.pattern?.asImmutable()), asDust = (level?.random?.nextDouble() ?: 1.0) * upgrades.failureMultiplier > (allocation.pattern?.researchPercent ?: 2.0), ticks = ticks, )) } - override fun onWorkTick(requiredPower: Decimal, extractedPower: Decimal, ticksAdvanced: Double, job: ReplicatorJob, id: Int): JobStatus { - val drainPerTick = job.matterPerTick * ticksAdvanced + override fun onJobTick(status: JobStatus, id: Int) { + val job = status.job + val drainPerTick = job.matterPerTick * status.ticksAdvanced if (matter.extractMatter(drainPerTick, true) < drainPerTick) { - // в машине недостаточно материи + val toDrain = (drainPerTick * DRAIN_MULT) + .coerceAtMost(job.matterPerTick * (status.ticks - status.workTicks + status.ticksAdvanced)) + .coerceAtLeast(Decimal.ONE) + .coerceAtMost(matter.missingMatter) - if (drainPerTick > matter.maxStoredMatter) { - // в тик требуется больше материи, чем её может хранить репликатор - val toExtract = drainPerTick - matter.extractMatter(drainPerTick, true) - val drain = matterNode.graph.extractMatter(toExtract, true) - - if (drain != toExtract) { - // недостаточно материи в сети - return JobStatus.FAILURE_MATTER - } - - // достаточно материи в сети + внутри машины - matter.extractMatter(drainPerTick, false) - matterNode.graph.extractMatter(drain, false) - return JobStatus.SUCCESS - } else { - // в тик требуется меньше материи, чем её может хранить репликатор - // примем из сети недостающее количество бака материи, или 200 тиков репликации, что меньше - val drain = matterNode.graph.extractMatter((drainPerTick * DRAIN_MULT) - .coerceAtMost(job.matterPerTick * (job.ticks - jobEventLoops[0].workTicks - ticksAdvanced)) - .coerceAtLeast(Decimal.ONE) - .coerceAtMost(matter.missingMatter), false) - - if (drain.isZero) { - // в сети нет материи - return JobStatus.FAILURE_MATTER - } - - matter.receiveMatter(drain, false) - - // получили материю, проверяем возможность работы - if (matter.extractMatter(drainPerTick, true) >= drainPerTick) { - matter.extractMatter(drainPerTick, false) - return JobStatus.SUCCESS - } else { - // :( - return JobStatus.FAILURE_WAIT - } - } + matter.receiveMatter(matterNode.graph.extractMatter(toDrain, false), false) } - // в машине достаточно материи - matter.extractMatter(drainPerTick, false) - visualProgress = jobEventLoops[0].workProgress - return JobStatus.SUCCESS + status.scale(matter.extractMatter(drainPerTick, false) / drainPerTick) + visualProgress = status.workProgress } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt index ad51f4083..683957405 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt @@ -10,7 +10,7 @@ import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeConfigSpec import ru.dbotthepony.mc.otm.block.entity.JobContainer import ru.dbotthepony.mc.otm.block.entity.JobStatus -import ru.dbotthepony.mc.otm.block.entity.MachineItemJob +import ru.dbotthepony.mc.otm.block.entity.ItemJob import ru.dbotthepony.mc.otm.block.entity.MachineJobEventLoop import ru.dbotthepony.mc.otm.config.ConciseBalanceValues import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity @@ -35,7 +35,7 @@ import java.util.* import kotlin.math.pow class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : - MatteryWorkerBlockEntity(MBlockEntities.MATTER_SCANNER, p_155229_, p_155230_, ::MachineItemJob) { + MatteryWorkerBlockEntity(MBlockEntities.MATTER_SCANNER, p_155229_, p_155230_, ItemJob.CODEC) { val container = MatteryContainer(::itemContainerUpdated, 1).also(::addDroppableContainer) val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::energyLevelUpdated, ENERGY_VALUES)) @@ -87,9 +87,9 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return MatterScannerMenu(containerID, inventory, this) } - override fun onJobFinish(job: MachineItemJob, id: Int): JobStatus { - val stack = job.itemStack - if (stack.isEmpty || !MatterManager.hasMatterValue(stack)) return JobStatus.SUCCESS + override fun onJobFinish(status: JobStatus, id: Int) { + val stack = status.job.itemStack + if (stack.isEmpty || !MatterManager.hasMatterValue(stack)) return status.success() var findState: IPatternState? = null @@ -110,14 +110,12 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : PatternState(UUID.randomUUID(), stack.item, researchAdvance) } - if (!matterNode.graph.insertPattern(new, onlyUpdate = false, simulate = false).isFailed) { - return JobStatus.SUCCESS - } else { - return JobStatus.FAILURE_WAIT + if (matterNode.graph.insertPattern(new, onlyUpdate = false, simulate = false).isFailed) { + status.throttle() } } - override fun computeNextJob(id: Int): JobContainer { + override fun computeNextJob(id: Int): JobContainer { if (energy.batteryLevel.isZero) { return JobContainer.noEnergy() } @@ -151,7 +149,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : stack.shrink(1) container.setChanged() val complexity = MatterManager.get(copy).complexity - return JobContainer.success(MachineItemJob(copy, (if (complexity > 1.0) complexity.pow(1.25) else complexity.pow(0.5)), BASE_CONSUMPTION)) + return JobContainer.success(ItemJob(copy, (if (complexity > 1.0) complexity.pow(1.25) else complexity.pow(0.5)), BASE_CONSUMPTION)) } return JobContainer.noItem() @@ -163,7 +161,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } - override fun jobUpdated(new: MachineItemJob?, old: MachineItemJob?, id: Int) { + override fun jobUpdated(new: ItemJob?, old: ItemJob?, id: Int) { visualItemStack = new?.itemStack ?: ItemStack.EMPTY visualProgress = 0f } @@ -174,14 +172,11 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : var visualProgress by synchronizer.float().property private set - override fun onWorkTick( - requiredPower: Decimal, - extractedPower: Decimal, - ticksAdvanced: Double, - job: MachineItemJob, + override fun onJobTick( + status: JobStatus, id: Int - ): JobStatus { - val result = super.onWorkTick(requiredPower, extractedPower, ticksAdvanced, job, id) + ) { + val result = super.onJobTick(status, id) visualProgress = jobEventLoops[0].workProgress diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt index 04249f93d..c6f20e2d0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt @@ -7,7 +7,7 @@ import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.level.block.state.BlockState -import ru.dbotthepony.mc.otm.block.entity.MachineItemJob +import ru.dbotthepony.mc.otm.block.entity.ItemJob import ru.dbotthepony.mc.otm.block.entity.JobContainer import ru.dbotthepony.mc.otm.block.entity.JobStatus import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity @@ -17,7 +17,7 @@ import ru.dbotthepony.mc.otm.menu.tech.CobblerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities class CobblerBlockEntity(blockPos: BlockPos, blockState: BlockState) - : MatteryWorkerBlockEntity(MBlockEntities.COBBLESTONE_GENERATOR, blockPos, blockState, ::MachineItemJob) { + : MatteryWorkerBlockEntity(MBlockEntities.COBBLESTONE_GENERATOR, blockPos, blockState, ItemJob.CODEC) { override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { return CobblerMenu(containerID, inventory, this) } @@ -36,16 +36,14 @@ class CobblerBlockEntity(blockPos: BlockPos, blockState: BlockState) savetable(::container, INVENTORY_KEY) } - override fun onJobFinish(job: MachineItemJob, id: Int): JobStatus { - if (!container.fullyAddItem(job.itemStack)) { - return JobStatus.FAILURE_ITEM + override fun onJobFinish(status: JobStatus, id: Int) { + if (!container.fullyAddItem(status.job.itemStack)) { + status.noItem() } - - return JobStatus.SUCCESS } - override fun computeNextJob(id: Int): JobContainer { - return JobContainer.success(MachineItemJob(ItemStack(Items.COBBLESTONE), 40.0)) + override fun computeNextJob(id: Int): JobContainer { + return JobContainer.success(ItemJob(ItemStack(Items.COBBLESTONE), 40.0)) } companion object { 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 e973cc320..df68623fc 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 @@ -10,7 +10,7 @@ import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.level.block.state.BlockState import ru.dbotthepony.mc.otm.block.entity.JobContainer import ru.dbotthepony.mc.otm.block.entity.JobStatus -import ru.dbotthepony.mc.otm.block.entity.MachineItemJob +import ru.dbotthepony.mc.otm.block.entity.ItemJob import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.UpgradeType import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage @@ -20,7 +20,6 @@ import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.UpgradeContainer import ru.dbotthepony.mc.otm.container.balance -import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -30,7 +29,7 @@ class PlatePressBlockEntity( p_155229_: BlockPos, p_155230_: BlockState, val isTwin: Boolean = false, -) : MatteryWorkerBlockEntity(if (isTwin) MBlockEntities.TWIN_PLATE_PRESS else MBlockEntities.PLATE_PRESS, p_155229_, p_155230_, ::MachineItemJob, if (isTwin) 2 else 1) { +) : MatteryWorkerBlockEntity(if (isTwin) MBlockEntities.TWIN_PLATE_PRESS else MBlockEntities.PLATE_PRESS, p_155229_, p_155230_, ItemJob.CODEC, if (isTwin) 2 else 1) { override val upgrades = UpgradeContainer(this::setChangedLight, if (isTwin) 4 else 3, UpgradeType.BASIC_PROCESSING) val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::energyLevelUpdated, upgrades.transform(MachinesConfig.PLATE_PRESS))) val inputContainer = MatteryContainer(this::itemContainerUpdated, if (isTwin) 2 else 1).also(::addDroppableContainer) @@ -69,18 +68,17 @@ class PlatePressBlockEntity( return PlatePressMenu(containerID, inventory, this) } - override fun onJobFinish(job: MachineItemJob, id: Int): JobStatus { - if (job.itemStack.isEmpty) - return JobStatus.SUCCESS + override fun onJobFinish(status: JobStatus, id: Int) { + if (status.job.itemStack.isEmpty) + return status.success() - if (!outputContainer.fullyAddItem(job.itemStack, start = id, end = id) && !outputContainer.fullyAddItem(job.itemStack)) - return JobStatus.FAILURE_ITEM + if (!outputContainer.fullyAddItem(status.job.itemStack, start = id, end = id) && !outputContainer.fullyAddItem(status.job.itemStack)) + return status.noItem() - experience = (experience + job.experience).coerceAtMost(100.0) - return JobStatus.SUCCESS + experience = (experience + status.experience).coerceAtMost(100.0) } - override fun computeNextJob(id: Int): JobContainer { + override fun computeNextJob(id: Int): JobContainer { if (energy.batteryLevel.isZero) { return JobContainer.noEnergy() } @@ -101,7 +99,7 @@ class PlatePressBlockEntity( inputContainer.setChanged(id) return JobContainer.success( - MachineItemJob( + ItemJob( recipe.getResultItem(level.registryAccess()).copyWithCount(toProcess), recipe.workTime * MachinesConfig.PLATE_PRESS.workTimeMultiplier, MachinesConfig.PLATE_PRESS.powerConsumption * toProcess, 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 afcdcdaac..e11236c03 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 @@ -3,19 +3,17 @@ package ru.dbotthepony.mc.otm.block.entity.tech import net.minecraft.core.BlockPos import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerPlayer -import net.minecraft.world.Container import net.minecraft.world.entity.ExperienceOrb import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.crafting.AbstractCookingRecipe -import net.minecraft.world.item.crafting.Recipe import net.minecraft.world.item.crafting.RecipeType import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState import ru.dbotthepony.mc.otm.block.entity.JobContainer import ru.dbotthepony.mc.otm.block.entity.JobStatus -import ru.dbotthepony.mc.otm.block.entity.MachineItemJob +import ru.dbotthepony.mc.otm.block.entity.ItemJob import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.CombinedItemHandler import ru.dbotthepony.mc.otm.capability.UpgradeType @@ -36,7 +34,7 @@ class PoweredFurnaceBlockEntity( blockState: BlockState, val recipeType: RecipeType, val config: WorkerBalanceValues -) : MatteryWorkerBlockEntity(type, blockPos, blockState, ::MachineItemJob, 2) { +) : MatteryWorkerBlockEntity(type, blockPos, blockState, ItemJob.CODEC, 2) { override val upgrades = UpgradeContainer(this::setChangedLight, 2, UpgradeType.BASIC_PROCESSING) val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::energyLevelUpdated, upgrades.transform(config))) @@ -86,16 +84,15 @@ class PoweredFurnaceBlockEntity( return PoweredFurnaceMenu(containerID, inventory, this) } - override fun onJobFinish(job: MachineItemJob, id: Int): JobStatus { - if (outputs[id].fullyAddItem(job.itemStack)) { - experience += job.experience - return JobStatus.SUCCESS + override fun onJobFinish(status: JobStatus, id: Int) { + if (outputs[id].fullyAddItem(status.job.itemStack)) { + experience += status.experience + } else { + status.noItem() } - - return JobStatus.FAILURE_ITEM } - override fun computeNextJob(id: Int): JobContainer { + override fun computeNextJob(id: Int): JobContainer { if (!energy.batteryLevel.isPositive) return JobContainer.noEnergy() @@ -109,7 +106,7 @@ class PoweredFurnaceBlockEntity( val toProcess = inputs[id][0].count.coerceAtMost(upgrades.processingItems + 1) inputs[id][0].shrink(toProcess) - JobContainer.success(MachineItemJob( + JobContainer.success(ItemJob( output.copyWithCount(toProcess), it.cookingTime * config.workTimeMultiplier, config.powerConsumption * toProcess, it.experience * toProcess )) }.orElse(JobContainer.noItem()) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 1896bbc82..e7d735336 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -63,7 +63,7 @@ import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidResearchType import ru.dbotthepony.mc.otm.block.entity.JobContainer import ru.dbotthepony.mc.otm.block.entity.JobStatus -import ru.dbotthepony.mc.otm.block.entity.MachineItemJob +import ru.dbotthepony.mc.otm.block.entity.ItemJob import ru.dbotthepony.mc.otm.block.entity.MachineJobEventLoop import ru.dbotthepony.mc.otm.capability.energy.BatteryBackedEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage @@ -411,33 +411,26 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } }).property - inner class SmelterBelt(index: Int) : MachineJobEventLoop() { + inner class SmelterBelt(index: Int) : MachineJobEventLoop(ItemJob.CODEC) { override val energy: IMatteryEnergyStorage get() = exoPackEnergy override val isBlockedByRedstone: Boolean get() = false - override fun deserializeJob(nbt: CompoundTag): MachineItemJob { - return MachineItemJob(nbt) - } - override val upgrades: IMatteryUpgrade? get() = null - override fun jobUpdated(new: MachineItemJob?, old: MachineItemJob?) {} - - override fun onJobFinish(job: MachineItemJob): JobStatus { - if (output.fullyAddItem(job.itemStack)) { - exoPackSmelterExperience += job.experience - return JobStatus.SUCCESS + override fun onJobFinish(status: JobStatus) { + if (output.fullyAddItem(status.job.itemStack)) { + exoPackSmelterExperience += status.job.experience } else { - return JobStatus.FAILURE_ITEM + status.noItem() } } private val cache = RecipeManager.createCheck(RecipeType.SMELTING) - override fun computeNextJob(): JobContainer { + override fun computeNextJob(): JobContainer { if (!exoPackEnergy.batteryLevel.isPositive) return JobContainer.noEnergy() val level = ply.level() as? ServerLevel ?: return JobContainer.failure() val recipe = cache.getRecipeFor(input, level) @@ -449,7 +442,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial val item = actual.assemble(input, level.registryAccess()) input[0].shrink(1) input.setChanged(0) - return JobContainer.success(MachineItemJob(item, actual.cookingTime.toDouble(), ExopackConfig.FURNACE_POWER_CONSUMPTION, actual.experience)) + return JobContainer.success(ItemJob(item, actual.cookingTime.toDouble(), ExopackConfig.FURNACE_POWER_CONSUMPTION, actual.experience)) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/PatternState.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/PatternState.kt index c1c17a410..a982c17b5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/PatternState.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/PatternState.kt @@ -1,6 +1,10 @@ package ru.dbotthepony.mc.otm.capability.matter +import com.mojang.datafixers.Products +import com.mojang.serialization.Codec +import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.nbt.CompoundTag +import net.minecraft.nbt.NbtOps import net.minecraft.nbt.Tag import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation @@ -11,6 +15,7 @@ import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.nbt.contains import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.data.UUIDCodec import java.util.* sealed interface IPatternState { @@ -45,13 +50,7 @@ sealed interface IPatternState { return ItemStack(item, count) } - fun serializeNBT(): CompoundTag { - return CompoundTag().also { - it["id"] = id - it["item"] = item.registryName!!.toString() - it["researchPercent"] = researchPercent - } - } + fun serializeNBT(): CompoundTag fun write(buff: FriendlyByteBuf) { buff.writeUUID(id) @@ -60,6 +59,14 @@ sealed interface IPatternState { } } +private fun codec(builder: RecordCodecBuilder.Instance): Products.P3, UUID, Item, Double> { + return builder.group( + UUIDCodec.fieldOf("id").forGetter(IPatternState::id), + ForgeRegistries.ITEMS.codec.fieldOf("item").forGetter(IPatternState::item), + Codec.doubleRange(0.0, 1.0).fieldOf("researchPercent").forGetter(IPatternState::researchPercent) + ) +} + private fun deserializeNBT(nbt: Tag?, mutable: Boolean): IPatternState? { if (nbt !is CompoundTag) return null @@ -108,6 +115,10 @@ data class PatternState( return this } + override fun serializeNBT(): CompoundTag { + return CODEC.encode(this, NbtOps.INSTANCE, NbtOps.INSTANCE.empty()).get().map({ it as CompoundTag }, { throw RuntimeException("Failed to serialize PatternState: ${it.message()}") }) + } + companion object { fun deserializeNBT(tag: Tag?): PatternState? { return deserializeNBT(tag, false) as PatternState? @@ -116,6 +127,12 @@ data class PatternState( fun read(buff: FriendlyByteBuf): PatternState? { return read(buff, false) as PatternState? } + + val CODEC: Codec by lazy { + RecordCodecBuilder.create { + codec(it).apply(it, ::PatternState) + } + } } } @@ -132,6 +149,10 @@ data class MutablePatternState( return PatternState(id, item, researchPercent) } + override fun serializeNBT(): CompoundTag { + return CODEC.encode(this, NbtOps.INSTANCE, NbtOps.INSTANCE.empty()).get().map({ it as CompoundTag }, { throw RuntimeException("Failed to serialize MutablePatternState: ${it.message()}") }) + } + companion object { fun deserializeNBT(tag: Tag?): MutablePatternState? { return deserializeNBT(tag, true) as MutablePatternState? @@ -140,6 +161,12 @@ data class MutablePatternState( fun read(buff: FriendlyByteBuf): MutablePatternState? { return read(buff, true) as MutablePatternState? } + + val CODEC: Codec by lazy { + RecordCodecBuilder.create { + codec(it).apply(it, ::MutablePatternState) + } + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/ReplicationTask.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/ReplicationTask.kt index b93b12d7f..234293cff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/ReplicationTask.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/ReplicationTask.kt @@ -1,6 +1,10 @@ package ru.dbotthepony.mc.otm.capability.matter +import com.mojang.datafixers.Products +import com.mojang.serialization.Codec +import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.nbt.CompoundTag +import net.minecraft.nbt.NbtOps import net.minecraft.nbt.Tag import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation @@ -9,14 +13,14 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.core.readItemType -import ru.dbotthepony.mc.otm.core.registryName -import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.writeItemType +import ru.dbotthepony.mc.otm.data.UUIDCodec +import java.util.Optional import java.util.UUID sealed interface IReplicationTask> { val id: UUID - val patternId: UUID? + val patternId: Optional val item: Item val inProgress: Int val finished: Int @@ -29,7 +33,7 @@ sealed interface IReplicationTask> { fun copyAsMutable( id: UUID = this.id, - patternId: UUID? = this.patternId, + patternId: Optional = this.patternId, item: Item = this.item, inProgress: Int = this.inProgress, finished: Int = this.finished, @@ -40,7 +44,7 @@ sealed interface IReplicationTask> { fun copyAsImmutable( id: UUID = this.id, - patternId: UUID? = this.patternId, + patternId: Optional = this.patternId, item: Item = this.item, inProgress: Int = this.inProgress, finished: Int = this.finished, @@ -60,25 +64,13 @@ sealed interface IReplicationTask> { fun allocate(amount: Int = 1): S fun finish(amount: Int = 1): S - fun serializeNBT(): CompoundTag { - return CompoundTag().also { - it["id"] = id - - if (patternId != null) - it["patternId"] = patternId!! - - it["item"] = item.registryName!!.toString() - it["inProgress"] = inProgress - it["finished"] = finished - it["required"] = required - } - } + fun serializeNBT(): CompoundTag fun write(buff: FriendlyByteBuf) { buff.writeUUID(id) - buff.writeBoolean(patternId != null) - patternId?.let(buff::writeUUID) + buff.writeBoolean(patternId.isPresent) + patternId.ifPresent(buff::writeUUID) buff.writeItemType(item) @@ -88,6 +80,17 @@ sealed interface IReplicationTask> { } } +private fun > codec(builder: RecordCodecBuilder.Instance): Products.P6, UUID, Optional, Item, Int, Int, Int> { + return builder.group( + UUIDCodec.fieldOf("id").forGetter(IReplicationTask<*>::id), + UUIDCodec.optionalFieldOf("patternId").forGetter(IReplicationTask<*>::patternId), + ForgeRegistries.ITEMS.codec.fieldOf("item").forGetter(IReplicationTask<*>::item), + Codec.intRange(0, Int.MAX_VALUE).fieldOf("inProgress").forGetter(IReplicationTask<*>::inProgress), + Codec.intRange(0, Int.MAX_VALUE).fieldOf("finished").forGetter(IReplicationTask<*>::finished), + Codec.intRange(0, Int.MAX_VALUE).fieldOf("required").forGetter(IReplicationTask<*>::required), + ) +} + private fun deserializeNBT(nbt: Tag?, mutable: Boolean): IReplicationTask<*>? { if (nbt !is CompoundTag) return null @@ -108,9 +111,9 @@ private fun deserializeNBT(nbt: Tag?, mutable: Boolean): IReplicationTask<*>? { val required = nbt.getInt("required") if (mutable) { - return MutableReplicationTask(id, patternId, item, inProgress, finished, required) + return MutableReplicationTask(id, Optional.ofNullable(patternId), item, inProgress, finished, required) } else { - return ReplicationTask(id, patternId, item, inProgress, finished, required) + return ReplicationTask(id, Optional.ofNullable(patternId), item, inProgress, finished, required) } } @@ -125,15 +128,15 @@ private fun read(buff: FriendlyByteBuf, mutable: Boolean): IReplicationTask<*>? item ?: return null if (mutable) { - return MutableReplicationTask(id, patternId, item, inProgress, finished, required) + return MutableReplicationTask(id, Optional.ofNullable(patternId), item, inProgress, finished, required) } else { - return ReplicationTask(id, patternId, item, inProgress, finished, required) + return ReplicationTask(id, Optional.ofNullable(patternId), item, inProgress, finished, required) } } data class ReplicationTask( override val id: UUID, - override val patternId: UUID?, + override val patternId: Optional, override val item: Item, override val inProgress: Int, override val finished: Int, @@ -155,6 +158,10 @@ data class ReplicationTask( return ReplicationTask(id, patternId, item, inProgress - amount, finished + amount, required) } + override fun serializeNBT(): CompoundTag { + return CODEC.encode(this, NbtOps.INSTANCE, NbtOps.INSTANCE.empty()).get().map({ it as CompoundTag }, { throw RuntimeException("Failed to serialize ReplicationTask: ${it.message()}") }) + } + companion object { fun deserializeNBT(nbt: Tag?): ReplicationTask? { return deserializeNBT(nbt, false) as ReplicationTask? @@ -163,12 +170,18 @@ data class ReplicationTask( fun read(buff: FriendlyByteBuf): ReplicationTask? { return read(buff, false) as ReplicationTask? } + + val CODEC: Codec by lazy { + RecordCodecBuilder.create { + codec(it).apply(it, ::ReplicationTask) + } + } } } data class MutableReplicationTask( override val id: UUID, - override val patternId: UUID?, + override val patternId: Optional, override val item: Item, override var inProgress: Int, override var finished: Int, @@ -194,6 +207,10 @@ data class MutableReplicationTask( return this } + override fun serializeNBT(): CompoundTag { + return CODEC.encode(this, NbtOps.INSTANCE, NbtOps.INSTANCE.empty()).get().map({ it as CompoundTag }, { throw RuntimeException("Failed to serialize MutableReplicationTask: ${it.message()}") }) + } + companion object { fun deserializeNBT(nbt: Tag?): MutableReplicationTask? { return deserializeNBT(nbt, true) as MutableReplicationTask? @@ -202,6 +219,12 @@ data class MutableReplicationTask( fun read(buff: FriendlyByteBuf): MutableReplicationTask? { return read(buff, true) as MutableReplicationTask? } + + val CODEC: Codec by lazy { + RecordCodecBuilder.create { + codec(it).apply(it, ::MutableReplicationTask) + } + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatteryWorkerProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatteryWorkerProvider.kt index a0b62cda3..9da096393 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatteryWorkerProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatteryWorkerProvider.kt @@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.compat.jade.providers import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.ListTag import net.minecraft.resources.ResourceLocation -import ru.dbotthepony.mc.otm.block.entity.MachineItemJob +import ru.dbotthepony.mc.otm.block.entity.ItemJob import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.compat.jade.JadeTagKeys import ru.dbotthepony.mc.otm.compat.jade.JadeUids @@ -34,8 +34,8 @@ object MatteryWorkerProvider : IBlockComponentProvider, IServerDataProvider>(val parent: Codec, val min: S? = null, val max: S? = null, val minExclusive: Boolean = false, val maxExclusive: Boolean = false) : Codec { + private fun check(input: S): DataResult? { + if (min != null) { + if (minExclusive) { + if (input <= min) { + return DataResult.error { "Value $input is smaller or equal to minimal $min" } + } + } else { + if (input < min) { + return DataResult.error { "Value $input is smaller than minimal $min" } + } + } + } + + if (max != null) { + if (maxExclusive) { + if (input >= max) { + return DataResult.error { "Value $input is bigger or equal to maximal $max" } + } + } else { + if (input > max) { + return DataResult.error { "Value $input is bigger than maximal $max" } + } + } + } + + return null + } + + override fun encode(input: S, ops: DynamicOps, prefix: T): DataResult { + check(input)?.let { return it } + return parent.encode(input, ops, prefix) + } + + override fun decode(ops: DynamicOps, input: T): DataResult> { + return parent.decode(ops, input).flatMap { + check>(it.first) ?: DataResult.success(it) + } + } +} + +fun > Codec.minRange(min: S, exclusive: Boolean = false) = ComparableCodec(this, min = min, minExclusive = exclusive) +fun > Codec.maxRange(max: S, exclusive: Boolean = false) = ComparableCodec(this, max = max, maxExclusive = exclusive) +fun > Codec.inRange(min: S, minExclusive: Boolean = false, max: S, maxExclusive: Boolean = false) = ComparableCodec(this, min, max, minExclusive, maxExclusive) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt index 140bd0848..dccd158c9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt @@ -4,28 +4,63 @@ import com.mojang.datafixers.util.Pair import com.mojang.serialization.Codec import com.mojang.serialization.DataResult import com.mojang.serialization.DynamicOps +import it.unimi.dsi.fastutil.bytes.ByteArrayList +import net.minecraft.nbt.NbtOps import ru.dbotthepony.mc.otm.core.math.Decimal +import java.nio.ByteBuffer +import java.util.stream.Collector +import java.util.stream.Stream object DecimalCodec : Codec { override fun encode(input: Decimal, ops: DynamicOps, prefix: T): DataResult { + if (ops === NbtOps.INSTANCE) { + return DataResult.success((ops as DynamicOps).createByteList(ByteBuffer.wrap(input.toByteArray()))) + } + return DataResult.success(ops.createString(input.toString())) } override fun decode(ops: DynamicOps, input: T): DataResult> { - val result = ops.getStringValue(input).flatMap { + return ops.getStringValue(input).flatMap { try { DataResult.success(Pair(Decimal(it), ops.empty())) } catch (err: NumberFormatException) { DataResult.error { "Not a valid number for converting into Decimal: $it" } } - } - - if (result.result().isPresent) { - return result - } - - return ops.getNumberValue(input).flatMap { - DataResult.success(Pair(Decimal(it.toString()), ops.empty())) - } + }.get().map( + { + DataResult.success(it) + }, + { e0 -> + ops.getIntStream(input).flatMap { + try { + DataResult.success(Pair(Decimal.fromByteArray( + it.mapToObj { val v = it.toLong(); Stream.of(v and 0xFFL, (v and 0xFF00L) ushr 8, (v and 0xFF0000L) ushr 16, (v and 0xFF000000L) ushr 24) } + .flatMap { it } + .collect(::ByteArrayList, { v, a -> v.add(a.toByte()) }, ByteArrayList::addAll) + .toByteArray() + ), ops.empty())) + } catch (err: NumberFormatException) { + DataResult.error { "Failed to convert array of bytes into Decimal: $it" } + } + }.get().map( + { + DataResult.success(it) + }, + { e1 -> + ops.getNumberValue(input).flatMap { + DataResult.success(Pair(Decimal(it.toString()), ops.empty())) + }.get().map( + { + DataResult.success(it) + }, + { e2 -> + DataResult.error { "None of attempts at decoding Decimal were successful: ${e0.message()}; ${e1.message()}; ${e2.message()}" } + } + ) + } + ) + } + ) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Ext.kt index fcc744d47..da9e8fde5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Ext.kt @@ -3,12 +3,17 @@ package ru.dbotthepony.mc.otm.data import com.google.gson.JsonArray import com.google.gson.JsonNull import com.google.gson.JsonObject +import com.mojang.datafixers.kinds.App +import com.mojang.serialization.Codec import com.mojang.serialization.DataResult +import com.mojang.serialization.codecs.RecordCodecBuilder import it.unimi.dsi.fastutil.ints.IntAVLTreeSet import net.minecraft.world.entity.player.Player import net.minecraft.world.level.storage.loot.LootContext import net.minecraft.world.level.storage.loot.parameters.LootContextParam import net.minecraft.world.level.storage.loot.parameters.LootContextParams +import java.util.Optional +import kotlin.reflect.KProperty1 fun JsonArray.getRidOfNulls(): JsonArray { val toRemove = IntAVLTreeSet() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/UUIDCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/UUIDCodec.kt new file mode 100644 index 000000000..4accf6e75 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/UUIDCodec.kt @@ -0,0 +1,26 @@ +package ru.dbotthepony.mc.otm.data + +import com.mojang.datafixers.util.Pair +import com.mojang.serialization.Codec +import com.mojang.serialization.DataResult +import com.mojang.serialization.DynamicOps +import java.util.UUID +import java.util.stream.LongStream + +object UUIDCodec : Codec { + override fun encode(input: UUID, ops: DynamicOps, prefix: T): DataResult { + return DataResult.success(ops.createLongList(LongStream.of(input.mostSignificantBits, input.leastSignificantBits))) + } + + override fun decode(ops: DynamicOps, input: T): DataResult> { + return ops.getLongStream(input).flatMap { + val l = it.limit(2).toArray() + + if (l.size != 2) { + DataResult.error { "Can't construct UUID from ${l.size} elements" } + } else { + DataResult.success(Pair(UUID(l[0], l[1]), ops.empty())) + } + } + } +} From 88ddc51254eaa0e604fe0648604cbfc9b1be6183 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 25 Jul 2023 14:29:38 +0700 Subject: [PATCH 0839/1199] Wait im stupid --- src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt index dccd158c9..062564586 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt @@ -35,8 +35,7 @@ object DecimalCodec : Codec { ops.getIntStream(input).flatMap { try { DataResult.success(Pair(Decimal.fromByteArray( - it.mapToObj { val v = it.toLong(); Stream.of(v and 0xFFL, (v and 0xFF00L) ushr 8, (v and 0xFF0000L) ushr 16, (v and 0xFF000000L) ushr 24) } - .flatMap { it } + it .collect(::ByteArrayList, { v, a -> v.add(a.toByte()) }, ByteArrayList::addAll) .toByteArray() ), ops.empty())) From a99d7e47cb71ddc76405c07b6fda40e04b1bf13e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 25 Jul 2023 14:43:25 +0700 Subject: [PATCH 0840/1199] Bring back old structure names for jobs --- .../kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt | 10 +++++----- .../block/entity/matter/MatterReplicatorBlockEntity.kt | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt index 33f9e9b5c..9a5c31416 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt @@ -37,16 +37,16 @@ open class Job( fun basicCodec(builder: RecordCodecBuilder.Instance): Products.P3, Double, Decimal, Float> { return builder.group( Codec.doubleRange(0.0, Double.MAX_VALUE).fieldOf("ticks").forGetter(Job::ticks), - DecimalCodec.fieldOf("powerUsage").forGetter(Job::powerUsage), // не надо указывать минимальную энергию как 0, + DecimalCodec.fieldOf("EnergyUsage").forGetter(Job::powerUsage), // не надо указывать минимальную энергию как 0, // ибо мы можем таким образом использовать это для создания работ генератора - Codec.floatRange(0f, Float.MAX_VALUE).optionalFieldOf("experience", 0f).forGetter(Job::experience), + Codec.floatRange(0f, Float.MAX_VALUE).optionalFieldOf("Experience", 0f).forGetter(Job::experience), ) } fun plainCodec(builder: RecordCodecBuilder.Instance): Products.P2, Double, Decimal> { return builder.group( - Codec.doubleRange(0.0, Double.MAX_VALUE).fieldOf("ticks").forGetter(Job::ticks), - DecimalCodec.fieldOf("powerUsage").forGetter(Job::powerUsage), // не надо указывать минимальную энергию как 0, + Codec.doubleRange(0.0, Double.MAX_VALUE).fieldOf("Ticks").forGetter(Job::ticks), + DecimalCodec.fieldOf("EnergyUsage").forGetter(Job::powerUsage), // не надо указывать минимальную энергию как 0, // ибо мы можем таким образом использовать это для создания работ генератора ) } @@ -67,7 +67,7 @@ open class ItemJob( ) : Job(ticks, power, experience) { companion object { fun itemCodec(builder: RecordCodecBuilder.Instance): Products.P4, ItemStack, Double, Decimal, Float> { - return builder.group(ItemStack.CODEC.fieldOf("itemStack").forGetter(ItemJob::itemStack)).and(basicCodec(builder)) + return builder.group(ItemStack.CODEC.fieldOf("Item").forGetter(ItemJob::itemStack)).and(basicCodec(builder)) } val CODEC: Codec by lazy { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index 8ee668a7b..5fdbf1357 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -56,7 +56,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val CODEC: Codec by lazy { RecordCodecBuilder.create { it.group( - ItemStack.CODEC.fieldOf("itemStack").forGetter(ReplicatorJob::itemStack), + ItemStack.CODEC.fieldOf("Item").forGetter(ReplicatorJob::itemStack), DecimalCodec.minRange(Decimal.ZERO).fieldOf("matterPerTick").forGetter(ReplicatorJob::matterPerTick), UUIDCodec.fieldOf("task").forGetter(ReplicatorJob::task), DecimalCodec.minRange(Decimal.ZERO).fieldOf("matterValue").forGetter(ReplicatorJob::matterValue), From f0f308407036c56a17efef1f15f6a6c14935f639 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 25 Jul 2023 14:49:35 +0700 Subject: [PATCH 0841/1199] GOD DAMN IT --- src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt index 9a5c31416..7ae32ce37 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt @@ -36,7 +36,7 @@ open class Job( companion object { fun basicCodec(builder: RecordCodecBuilder.Instance): Products.P3, Double, Decimal, Float> { return builder.group( - Codec.doubleRange(0.0, Double.MAX_VALUE).fieldOf("ticks").forGetter(Job::ticks), + Codec.doubleRange(0.0, Double.MAX_VALUE).fieldOf("Ticks").forGetter(Job::ticks), DecimalCodec.fieldOf("EnergyUsage").forGetter(Job::powerUsage), // не надо указывать минимальную энергию как 0, // ибо мы можем таким образом использовать это для создания работ генератора Codec.floatRange(0f, Float.MAX_VALUE).optionalFieldOf("Experience", 0f).forGetter(Job::experience), From 1c6889f6bc0b20ed32ddf9ed90d2a3994ce8f5e2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 25 Jul 2023 14:57:38 +0700 Subject: [PATCH 0842/1199] Is this some kind of sick joke --- .../mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index 5fdbf1357..73147dbc3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -62,7 +62,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : DecimalCodec.minRange(Decimal.ZERO).fieldOf("matterValue").forGetter(ReplicatorJob::matterValue), PatternState.CODEC.optionalFieldOf("pattern").forGetter(ReplicatorJob::pattern), Codec.BOOL.fieldOf("asDust").forGetter(ReplicatorJob::asDust), - Codec.doubleRange(0.0, Double.MAX_VALUE).fieldOf("ticks").forGetter(ReplicatorJob::ticks), + Codec.doubleRange(0.0, Double.MAX_VALUE).fieldOf("Ticks").forGetter(ReplicatorJob::ticks), ).apply(it, ::ReplicatorJob) } } From 2be09fe5d249e67b1894dc303d23091ddcaf300c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 25 Jul 2023 16:16:39 +0700 Subject: [PATCH 0843/1199] =?UTF-8?q?YuRaNnNzZZ=20=E2=80=94=20=D0=A1=D0=B5?= =?UTF-8?q?=D0=B3=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=2010:42=20:WiseTree:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/compat/jade/providers/MatteryEnergyProvider.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatteryEnergyProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatteryEnergyProvider.kt index 0d8da5461..2ef189a32 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatteryEnergyProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatteryEnergyProvider.kt @@ -96,11 +96,11 @@ object MatteryEnergyProvider : IBlockComponentProvider, IServerDataProvider Date: Tue, 25 Jul 2023 17:01:57 +0700 Subject: [PATCH 0844/1199] Use codecs to deserialize pattern state from nbt tags --- .../mc/otm/capability/matter/PatternState.kt | 31 +++---------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/PatternState.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/PatternState.kt index a982c17b5..4fd31a930 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/PatternState.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/PatternState.kt @@ -67,27 +67,6 @@ private fun codec(builder: RecordCodecBuilder.Instance): ) } -private fun deserializeNBT(nbt: Tag?, mutable: Boolean): IPatternState? { - if (nbt !is CompoundTag) - return null - - if (!nbt.contains("id", "researchPercent", "item")) - return null - - val id = nbt.getUUID("id") - val researchPercent = nbt.getDouble("researchPercent") - val item = ForgeRegistries.ITEMS.getValue(ResourceLocation(nbt.getString("item"))) ?: return null - - if (item == Items.AIR) - return null - - if (mutable) { - return MutablePatternState(id, item, researchPercent) - } else { - return PatternState(id, item, researchPercent) - } -} - private fun read(buff: FriendlyByteBuf, mutable: Boolean): IPatternState? { val id = buff.readUUID() val item = buff.readItemType() @@ -121,7 +100,8 @@ data class PatternState( companion object { fun deserializeNBT(tag: Tag?): PatternState? { - return deserializeNBT(tag, false) as PatternState? + tag ?: return null + return CODEC.decode(NbtOps.INSTANCE, tag).result().map { it.first }.orElse(null) } fun read(buff: FriendlyByteBuf): PatternState? { @@ -155,7 +135,8 @@ data class MutablePatternState( companion object { fun deserializeNBT(tag: Tag?): MutablePatternState? { - return deserializeNBT(tag, true) as MutablePatternState? + tag ?: return null + return CODEC.decode(NbtOps.INSTANCE, tag).result().map { it.first }.orElse(null) } fun read(buff: FriendlyByteBuf): MutablePatternState? { @@ -169,7 +150,3 @@ data class MutablePatternState( } } } - -fun FriendlyByteBuf.writePatternState(state: IPatternState) = state.write(this) -fun FriendlyByteBuf.readPatternState() = PatternState.read(this) -fun FriendlyByteBuf.readMutablePatternState() = MutablePatternState.read(this) From f6af6d59be7a378c066f90a3bbe1cf2702855899 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 25 Jul 2023 17:04:57 +0700 Subject: [PATCH 0845/1199] Use codecs to deserialize replication task from nbt data --- .../otm/capability/matter/ReplicationTask.kt | 36 +++---------------- .../mc/otm/menu/matter/MatterPanelMenu.kt | 2 +- 2 files changed, 5 insertions(+), 33 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/ReplicationTask.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/ReplicationTask.kt index 234293cff..287726f49 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/ReplicationTask.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/ReplicationTask.kt @@ -91,32 +91,6 @@ private fun > codec(builder: RecordCodecBuilder.Instance ) } -private fun deserializeNBT(nbt: Tag?, mutable: Boolean): IReplicationTask<*>? { - if (nbt !is CompoundTag) - return null - - if (!nbt.contains("id") || !nbt.contains("inProgress") || !nbt.contains("finished") || !nbt.contains("required") || !nbt.contains("item")) - return null - - val item = ForgeRegistries.ITEMS.getValue(ResourceLocation(nbt.getString("item"))) ?: return null - - if (item == Items.AIR) - return null - - val id = nbt.getUUID("id") - val patternId = if (nbt.contains("patternId")) nbt.getUUID("patternId") else null - - val inProgress = nbt.getInt("inProgress") - val finished = nbt.getInt("finished") - val required = nbt.getInt("required") - - if (mutable) { - return MutableReplicationTask(id, Optional.ofNullable(patternId), item, inProgress, finished, required) - } else { - return ReplicationTask(id, Optional.ofNullable(patternId), item, inProgress, finished, required) - } -} - private fun read(buff: FriendlyByteBuf, mutable: Boolean): IReplicationTask<*>? { val id = buff.readUUID() val patternId: UUID? = if (buff.readBoolean()) buff.readUUID() else null @@ -164,7 +138,8 @@ data class ReplicationTask( companion object { fun deserializeNBT(nbt: Tag?): ReplicationTask? { - return deserializeNBT(nbt, false) as ReplicationTask? + nbt ?: return null + return CODEC.decode(NbtOps.INSTANCE, nbt).result().map { it.first }.orElse(null) } fun read(buff: FriendlyByteBuf): ReplicationTask? { @@ -213,7 +188,8 @@ data class MutableReplicationTask( companion object { fun deserializeNBT(nbt: Tag?): MutableReplicationTask? { - return deserializeNBT(nbt, true) as MutableReplicationTask? + nbt ?: return null + return CODEC.decode(NbtOps.INSTANCE, nbt).result().map { it.first }.orElse(null) } fun read(buff: FriendlyByteBuf): MutableReplicationTask? { @@ -227,7 +203,3 @@ data class MutableReplicationTask( } } } - -fun FriendlyByteBuf.writeReplicationTask(task: IReplicationTask<*>) = task.write(this) -fun FriendlyByteBuf.readReplicationTask() = ReplicationTask.read(this) -fun FriendlyByteBuf.readMutableReplicationTask() = MutableReplicationTask.read(this) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt index fda96b746..71578aae5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt @@ -112,7 +112,7 @@ class TasksChangePacket(val isUpdate: Boolean, val tasks: Collection>(size).also { - for (i in 0 until size) it.add(buff.readReplicationTask() ?: throw NullPointerException("Unable to read Replication Task from network at $i")) }) + for (i in 0 until size) it.add(ReplicationTask.read(buff) ?: throw NullPointerException("Unable to read Replication Task from network at $i")) }) } } } From 9abdd784c4c9fa16faba52d7bb4ae842f468e8b4 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 25 Jul 2023 17:17:08 +0700 Subject: [PATCH 0846/1199] Make metal mesh drop itself --- .../kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index d4d9e9566..996aaa641 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -34,6 +34,7 @@ fun addLootTables(lootTables: LootTables) { lootTables.createSlabItemTable(MRegistry.FLOOR_TILES_SLAB.blocks.values) { condition(ExplosionCondition.survivesExplosion()) } lootTables.dropsSelf(MBlocks.CARBON_FIBRE_BLOCK) { condition(ExplosionCondition.survivesExplosion()) } + lootTables.dropsSelf(MBlocks.METAL_MESH) { condition(ExplosionCondition.survivesExplosion()) } lootTables.dropsSelf(MBlocks.TRITANIUM_RAW_BLOCK) { condition(ExplosionCondition.survivesExplosion()) } lootTables.dropsSelf(MBlocks.TRITANIUM_STRIPED_BLOCK) { condition(ExplosionCondition.survivesExplosion()) } lootTables.dropsSelf(MBlocks.TRITANIUM_STRIPED_WALL) { condition(ExplosionCondition.survivesExplosion()) } From 325ee5da2e5294c8942f2b7548cefb504c77efce Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 25 Jul 2023 18:53:05 +0700 Subject: [PATCH 0847/1199] Fix items with damage have wrong matter value calculation (off by one) --- src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index f792586c8..f033af5ad 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -1186,7 +1186,7 @@ object MatterManager { matter = get(value.item) if (matter.hasMatterValue && value.isDamageableItem) { - val severity = 1.0 - value.damageValue.toDouble() / value.maxDamage.toDouble() + val severity = 1.0 - value.damageValue.toDouble() / (value.maxDamage.toDouble() + 1.0) undamagedMatterValue = matter matter = MatterValue(matter.matter * severity, matter.complexity * (0.5 + severity / 2)) } else { From c226a988c3f64a93581ee8df1f931cb80046b962 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 25 Jul 2023 19:39:10 +0700 Subject: [PATCH 0848/1199] Matter decomposer rebalanced values --- .../entity/matter/MatterBottlerBlockEntity.kt | 5 +- .../matter/MatterDecomposerBlockEntity.kt | 54 +++++----------- .../matter/MatterReconstructorBlockEntity.kt | 5 +- .../matter/MatterReplicatorBlockEntity.kt | 4 +- .../entity/matter/MatterScannerBlockEntity.kt | 4 +- .../block/entity/storage/StorageInterfaces.kt | 4 +- .../StoragePowerSupplierBlockEntity.kt | 4 +- .../energy/BlockEnergyStorageImpl.kt | 61 +++++++++---------- .../capability/matter/MatterStorageImpl.kt | 13 ++-- .../mc/otm/config/AbstractConfig.kt | 43 ++++++------- .../mc/otm/config/BalanceValues.kt | 23 +++---- .../mc/otm/config/MachinesConfig.kt | 31 ++++++---- .../mc/otm/container/UpgradeContainer.kt | 32 +++++----- .../ru/dbotthepony/mc/otm/item/BatteryItem.kt | 7 +-- .../mc/otm/item/QuantumBatteryItem.kt | 8 +-- .../mc/otm/item/SingleUseBatteryItem.kt | 5 +- 16 files changed, 137 insertions(+), 166 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index 0cb9a6b8f..9b58cdd29 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -10,7 +10,7 @@ import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeConfigSpec -import ru.dbotthepony.mc.otm.config.ConciseBalanceValues +import ru.dbotthepony.mc.otm.config.EnergyBalanceValues import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState @@ -33,7 +33,6 @@ import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal -import ru.dbotthepony.mc.otm.graph.matter.MatterNode import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : @@ -294,7 +293,7 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : private var _EXTRACTION_TICKS: DecimalConfigValue by WriteOnce() private var _CAPACITY: DecimalConfigValue by WriteOnce() - var ENERGY_VALUES: ConciseBalanceValues by WriteOnce() + var ENERGY_VALUES: EnergyBalanceValues by WriteOnce() private set fun registerConfig(builder: ForgeConfigSpec.Builder) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index 94af8254c..24fc3c4cf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.block.entity.matter import com.mojang.serialization.Codec import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.core.BlockPos -import net.minecraft.nbt.CompoundTag import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu @@ -17,20 +16,20 @@ import ru.dbotthepony.mc.otm.block.entity.Job import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.UpgradeType import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage -import ru.dbotthepony.mc.otm.config.ConciseBalanceValues +import ru.dbotthepony.mc.otm.config.EnergyBalanceValues +import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer +import ru.dbotthepony.mc.otm.container.UpgradeContainer import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal -import ru.dbotthepony.mc.otm.core.math.getDecimal -import ru.dbotthepony.mc.otm.core.math.set -import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.data.DecimalCodec import ru.dbotthepony.mc.otm.data.minRange @@ -103,7 +102,7 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) val toDust: Boolean, var matterValue: Decimal, ticks: Double, - ) : Job(ticks, BASE_CONSUMPTION) { + ) : Job(ticks, MachinesConfig.MATTER_DECOMPOSER.powerConsumption) { companion object { val CODEC: Codec by lazy { RecordCodecBuilder.create { @@ -117,14 +116,15 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) } } - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this, ENERGY_VALUES)) + override val upgrades = UpgradeContainer(this::setChangedLight, 4, UpgradeType.REPLICATOR) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this, upgrades.transform(MachinesConfig.MATTER_DECOMPOSER))) val energyConfig = ConfigurableEnergy(energy) init { savetables.stateful(::energy, ENERGY_KEY) } - val matter = ProfiledMatterStorage(MatterStorageImpl(::setChangedLight, FlowDirection.OUTPUT, ::CAPACITY)) + val matter = ProfiledMatterStorage(MatterStorageImpl(::setChangedLight, FlowDirection.OUTPUT, upgrades.matterCapacity(MachinesConfig.MATTER_DECOMPOSER::matterCapacity))) val matterNode = SimpleMatterNode(matter = matter) init { @@ -185,7 +185,13 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) val matter = MatterManager.get(copy) stack.count-- - return JobContainer.success(DecomposerJob((level?.random?.nextDouble() ?: 1.0) <= 0.2, matter.matter, matter.complexity)) + return JobContainer.success( + DecomposerJob( + (level?.random?.nextDouble() ?: 1.0) <= 0.2 * upgrades.failureMultiplier, + matter.matter, + matter.complexity * MachinesConfig.MATTER_DECOMPOSER.workTimeMultiplier + ) + ) } } @@ -205,36 +211,8 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) override fun tick() { super.tick() - val grid = matterNode.graph as MatterGraph? ?: return - if (!matter.storedMatter.isZero) { - val diff = matter.extractMatter(matter.storedMatter, true) - val diff2 = grid.receiveMatter(diff, true) - - matter.extractMatter(diff2, false) - grid.receiveMatter(diff2, false) - } - } - - companion object { - val CAPACITY get() = _CAPACITY.get() - val BASE_CONSUMPTION get() = _BASE_CONSUMPTION.get() - - private var _CAPACITY: DecimalConfigValue by WriteOnce() - private var _BASE_CONSUMPTION: DecimalConfigValue by WriteOnce() - - var ENERGY_VALUES: ConciseBalanceValues by WriteOnce() - private set - - fun registerConfig(builder: ForgeConfigSpec.Builder) { - builder.push(MNames.MATTER_DECOMPOSER) - - ENERGY_VALUES = BlockEnergyStorageImpl.makeConfigEntry(builder, capacity = Decimal(400_000), throughput = Decimal(2_000)) - - _CAPACITY = builder.defineDecimal("matterCapacity", Decimal(500), Decimal.ONE_TENTH) - _BASE_CONSUMPTION = builder.defineDecimal("baseConsumption", Decimal(240), Decimal.ONE) - - builder.pop() + matter.extractMatter(matterNode.graph.receiveMatter(matter.storedMatter, false), false) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt index 2cb36e21f..74976f0ba 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt @@ -24,7 +24,7 @@ import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage import ru.dbotthepony.mc.otm.capability.matter.IPatternState import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage -import ru.dbotthepony.mc.otm.config.ConciseBalanceValues +import ru.dbotthepony.mc.otm.config.EnergyBalanceValues import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.UpgradeContainer @@ -33,7 +33,6 @@ import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.core.util.WriteOnce -import ru.dbotthepony.mc.otm.graph.matter.MatterGraph import ru.dbotthepony.mc.otm.graph.matter.MatterNode import ru.dbotthepony.mc.otm.matter.IMatterValue import ru.dbotthepony.mc.otm.matter.MatterManager @@ -308,7 +307,7 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) private var _ONLY_ANVIL: ConfigValue by WriteOnce() private var _ALLOW_TO_SKIP_ANVIL: ConfigValue by WriteOnce() - var ENERGY_VALUES: ConciseBalanceValues by WriteOnce() + var ENERGY_VALUES: EnergyBalanceValues by WriteOnce() private set fun registerConfig(builder: ForgeConfigSpec.Builder) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index 73147dbc3..23ef6a790 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -22,7 +22,7 @@ import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.* -import ru.dbotthepony.mc.otm.config.ConciseBalanceValues +import ru.dbotthepony.mc.otm.config.EnergyBalanceValues import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.UpgradeContainer @@ -213,7 +213,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : private var _DRAIN_MULT: DecimalConfigValue by WriteOnce() private var _MATTER_CAPACITY: DecimalConfigValue by WriteOnce() - var ENERGY_VALUES: ConciseBalanceValues by WriteOnce() + var ENERGY_VALUES: EnergyBalanceValues by WriteOnce() private set fun registerConfig(builder: ForgeConfigSpec.Builder) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt index 683957405..577220d47 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt @@ -12,7 +12,7 @@ import ru.dbotthepony.mc.otm.block.entity.JobContainer import ru.dbotthepony.mc.otm.block.entity.JobStatus import ru.dbotthepony.mc.otm.block.entity.ItemJob import ru.dbotthepony.mc.otm.block.entity.MachineJobEventLoop -import ru.dbotthepony.mc.otm.config.ConciseBalanceValues +import ru.dbotthepony.mc.otm.config.EnergyBalanceValues import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.MatteryCapability @@ -187,7 +187,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : private val BASE_CONSUMPTION get() = _BASE_CONSUMPTION.get() private var _BASE_CONSUMPTION: DecimalConfigValue by WriteOnce() - var ENERGY_VALUES: ConciseBalanceValues by WriteOnce() + var ENERGY_VALUES: EnergyBalanceValues by WriteOnce() private set fun registerConfig(builder: ForgeConfigSpec.Builder) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt index a37b4b10e..547ece08f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt @@ -21,7 +21,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact -import ru.dbotthepony.mc.otm.config.ConciseBalanceValues +import ru.dbotthepony.mc.otm.config.EnergyBalanceValues import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.core.TranslatableComponent @@ -48,7 +48,7 @@ abstract class AbstractStorageImportExport( blockType: BlockEntityType<*>, blockPos: BlockPos, blockState: BlockState, - energyValues: ConciseBalanceValues = MachinesConfig.STORAGE_INTERFACES + energyValues: EnergyBalanceValues = MachinesConfig.STORAGE_INTERFACES ) : MatteryPoweredBlockEntity(blockType, blockPos, blockState) { val energy = WorkerEnergyStorage(::setChangedLight, energyValues) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt index 61c395979..3545cbbb0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.block.entity.storage import net.minecraft.core.BlockPos -import net.minecraft.server.level.ServerLevel import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu @@ -14,7 +13,6 @@ import ru.dbotthepony.mc.otm.capability.energy.transferChecked import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.graph.storage.StorageNode -import ru.dbotthepony.mc.otm.graph.storage.StorageGraph import ru.dbotthepony.mc.otm.menu.storage.StoragePowerSupplierMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -65,7 +63,7 @@ class StoragePowerSupplierBlockEntity(blockPos: BlockPos, blockState: BlockState var demand = Decimal.ZERO var i = 0 - val available = energy.batteryLevel.coerceAtMost(MachinesConfig.STORAGE_POWER_SUPPLIER.throughput) + val available = energy.batteryLevel.coerceAtMost(MachinesConfig.STORAGE_POWER_SUPPLIER.energyThroughput) for (demanding in cell.graph.powerDemandingNodes) { val received = demanding.receiveEnergy(available, true) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt index 4abaceb73..d86e4dd58 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt @@ -14,12 +14,11 @@ import net.minecraftforge.common.ForgeConfigSpec import net.minecraftforge.common.util.INBTSerializable import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity -import ru.dbotthepony.mc.otm.config.ConciseBalanceValues -import ru.dbotthepony.mc.otm.config.VerboseBalanceValues +import ru.dbotthepony.mc.otm.config.EnergyBalanceValues +import ru.dbotthepony.mc.otm.config.VerboseEnergyBalanceValues import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.defineDecimal -import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.mapPresent import ru.dbotthepony.mc.otm.core.nbt.set @@ -166,13 +165,13 @@ sealed class BlockEnergyStorageImpl( const val MAX_INPUT_KEY = "max_input" const val MAX_OUTPUT_KEY = "max_output" - fun makeConfigEntry(builder: ForgeConfigSpec.Builder, name: String? = null, capacity: Decimal = DEFAULT_MAX_CAPACITY, throughput: Decimal = DEFAULT_MAX_IO, configurator: ForgeConfigSpec.Builder.() -> Unit = {}): ConciseBalanceValues { + fun makeConfigEntry(builder: ForgeConfigSpec.Builder, name: String? = null, capacity: Decimal = DEFAULT_MAX_CAPACITY, throughput: Decimal = DEFAULT_MAX_IO, configurator: ForgeConfigSpec.Builder.() -> Unit = {}): EnergyBalanceValues { if (name != null) builder.push(name) - val obj = object : ConciseBalanceValues { - override val capacity: Decimal by builder.defineDecimal("capacity", capacity, Decimal.ONE) - override val throughput: Decimal by builder.defineDecimal("throughput", throughput, Decimal.ONE) + val obj = object : EnergyBalanceValues { + override val energyCapacity: Decimal by builder.defineDecimal("capacity", capacity, Decimal.ONE) + override val energyThroughput: Decimal by builder.defineDecimal("throughput", throughput, Decimal.ONE) } configurator.invoke(builder) @@ -199,23 +198,23 @@ open class WorkerEnergyStorage( constructor( listener: () -> Unit, - values: ConciseBalanceValues - ) : this(listener, values::capacity, values::throughput, values::throughput) + values: EnergyBalanceValues + ) : this(listener, values::energyCapacity, values::energyThroughput, values::energyThroughput) constructor( listener: BlockEntity, - values: ConciseBalanceValues - ) : this(listener::setChanged, values::capacity, values::throughput, values::throughput) + values: EnergyBalanceValues + ) : this(listener::setChanged, values::energyCapacity, values::energyThroughput, values::energyThroughput) constructor( listener: () -> Unit, - values: VerboseBalanceValues - ) : this(listener, values::capacity, values::receive, values::extract) + values: VerboseEnergyBalanceValues + ) : this(listener, values::energyCapacity, values::maxEnergyReceive, values::maxEnergyExtract) constructor( listener: BlockEntity, - values: VerboseBalanceValues - ) : this(listener::setChanged, values::capacity, values::receive, values::extract) + values: VerboseEnergyBalanceValues + ) : this(listener::setChanged, values::energyCapacity, values::maxEnergyReceive, values::maxEnergyExtract) constructor( listener: BlockEntity, @@ -251,23 +250,23 @@ open class GeneratorEnergyStorage( constructor( listener: () -> Unit, - values: ConciseBalanceValues - ) : this(listener, values::capacity, values::throughput, values::throughput) + values: EnergyBalanceValues + ) : this(listener, values::energyCapacity, values::energyThroughput, values::energyThroughput) constructor( listener: BlockEntity, - values: ConciseBalanceValues - ) : this(listener::setChanged, values::capacity, values::throughput, values::throughput) + values: EnergyBalanceValues + ) : this(listener::setChanged, values::energyCapacity, values::energyThroughput, values::energyThroughput) constructor( listener: () -> Unit, - values: VerboseBalanceValues - ) : this(listener, values::capacity, values::receive, values::extract) + values: VerboseEnergyBalanceValues + ) : this(listener, values::energyCapacity, values::maxEnergyReceive, values::maxEnergyExtract) constructor( listener: BlockEntity, - values: VerboseBalanceValues - ) : this(listener::setChanged, values::capacity, values::receive, values::extract) + values: VerboseEnergyBalanceValues + ) : this(listener::setChanged, values::energyCapacity, values::maxEnergyReceive, values::maxEnergyExtract) constructor( listener: BlockEntity, @@ -303,23 +302,23 @@ open class CapacitorEnergyStorage( constructor( listener: () -> Unit, - values: ConciseBalanceValues - ) : this(listener, values::capacity, values::throughput, values::throughput) + values: EnergyBalanceValues + ) : this(listener, values::energyCapacity, values::energyThroughput, values::energyThroughput) constructor( listener: BlockEntity, - values: ConciseBalanceValues - ) : this(listener::setChanged, values::capacity, values::throughput, values::throughput) + values: EnergyBalanceValues + ) : this(listener::setChanged, values::energyCapacity, values::energyThroughput, values::energyThroughput) constructor( listener: () -> Unit, - values: VerboseBalanceValues - ) : this(listener, values::capacity, values::receive, values::extract) + values: VerboseEnergyBalanceValues + ) : this(listener, values::energyCapacity, values::maxEnergyReceive, values::maxEnergyExtract) constructor( listener: BlockEntity, - values: VerboseBalanceValues - ) : this(listener::setChanged, values::capacity, values::receive, values::extract) + values: VerboseEnergyBalanceValues + ) : this(listener::setChanged, values::energyCapacity, values::maxEnergyReceive, values::maxEnergyExtract) constructor( listener: BlockEntity, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt index 4b60d458f..f15c6780c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/MatterStorageImpl.kt @@ -2,9 +2,8 @@ package ru.dbotthepony.mc.otm.capability.matter import net.minecraft.nbt.CompoundTag import net.minecraftforge.common.util.INBTSerializable -import net.minecraftforge.common.util.LazyOptional -import ru.dbotthepony.mc.otm.config.ConciseBalanceValues -import ru.dbotthepony.mc.otm.config.VerboseBalanceValues +import ru.dbotthepony.mc.otm.config.EnergyBalanceValues +import ru.dbotthepony.mc.otm.config.VerboseEnergyBalanceValues import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.nbt.set @@ -27,14 +26,14 @@ open class MatterStorageImpl @JvmOverloads constructor( constructor( listener: Runnable?, direction: FlowDirection, - values: ConciseBalanceValues - ) : this(listener, direction, values::capacity, values::throughput, values::throughput) + values: EnergyBalanceValues + ) : this(listener, direction, values::energyCapacity, values::energyThroughput, values::energyThroughput) constructor( listener: Runnable?, direction: FlowDirection, - values: VerboseBalanceValues - ) : this(listener, direction, values::capacity, values::receive, values::extract) + values: VerboseEnergyBalanceValues + ) : this(listener, direction, values::energyCapacity, values::maxEnergyReceive, values::maxEnergyExtract) val maxReceive get() = maxReceiveSupplier.invoke() val maxExtract get() = maxExtractSupplier.invoke() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt index 08e49467c..1214d2f30 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt @@ -15,27 +15,13 @@ abstract class AbstractConfig(private val configName: String, private val type: protected val builder = ForgeConfigSpec.Builder() private var registered = false - fun verboseValues(name: String, storage: Decimal, receive: Decimal, extract: Decimal = receive): VerboseBalanceValues { - builder.push(name) - - val obj = object : VerboseBalanceValues { - override val capacity: Decimal by builder.defineDecimal("capacity", storage, minimum = Decimal.ONE) - override val receive: Decimal by builder.defineDecimal("receive", receive, minimum = Decimal.ONE) - override val extract: Decimal by builder.defineDecimal("extract", extract, minimum = Decimal.ONE) - } - - builder.pop() - - return obj - } - fun batteryValues(name: String, storage: Decimal, receive: Decimal, extract: Decimal = receive, initialBatteryLevel: Decimal = Decimal.ZERO): BatteryBalanceValues { builder.push(name) val obj = object : BatteryBalanceValues { - override val capacity: Decimal by builder.defineDecimal("capacity", storage, minimum = Decimal.ONE) - override val receive: Decimal by builder.defineDecimal("receive", receive, minimum = Decimal.ONE) - override val extract: Decimal by builder.defineDecimal("extract", extract, minimum = Decimal.ONE) + override val energyCapacity: Decimal by builder.defineDecimal("capacity", storage, minimum = Decimal.ONE) + override val maxEnergyReceive: Decimal by builder.defineDecimal("receive", receive, minimum = Decimal.ONE) + override val maxEnergyExtract: Decimal by builder.defineDecimal("extract", extract, minimum = Decimal.ONE) override val initialBatteryLevel: Decimal by builder.defineDecimal("initialBatteryLevel", initialBatteryLevel, minimum = Decimal.ZERO) } @@ -44,12 +30,12 @@ abstract class AbstractConfig(private val configName: String, private val type: return obj } - fun conciseValues(name: String, storage: Decimal, throughput: Decimal, configurator: ForgeConfigSpec.Builder.() -> Unit = {}): ConciseBalanceValues { + fun conciseValues(name: String, storage: Decimal, throughput: Decimal, configurator: ForgeConfigSpec.Builder.() -> Unit = {}): EnergyBalanceValues { builder.push(name) - val obj = object : ConciseBalanceValues { - override val capacity: Decimal by builder.defineDecimal("capacity", storage, minimum = Decimal.ONE) - override val throughput: Decimal by builder.defineDecimal("throughput", throughput, minimum = Decimal.ONE) + val obj = object : EnergyBalanceValues { + override val energyCapacity: Decimal by builder.defineDecimal("capacity", storage, minimum = Decimal.ONE) + override val energyThroughput: Decimal by builder.defineDecimal("throughput", throughput, minimum = Decimal.ONE) } configurator.invoke(builder) @@ -58,13 +44,22 @@ abstract class AbstractConfig(private val configName: String, private val type: return obj } - fun workerValues(name: String, storage: Decimal, throughput: Decimal, workTimeMultiplier: Double? = 1.0, powerConsumption: Decimal, configurator: ForgeConfigSpec.Builder.() -> Unit = {}): WorkerBalanceValues { + fun workerValues( + name: String, + energyStorage: Decimal, + energyThroughput: Decimal, + workTimeMultiplier: Double? = 1.0, + powerConsumption: Decimal, + matterCapacity: Decimal? = null, + configurator: ForgeConfigSpec.Builder.() -> Unit = {} + ): WorkerBalanceValues { builder.push(name) val obj = object : WorkerBalanceValues { - override val capacity: Decimal by builder.defineDecimal("capacity", storage, minimum = Decimal.ONE) - override val throughput: Decimal by builder.defineDecimal("throughput", throughput, minimum = Decimal.ONE) + override val energyCapacity: Decimal by builder.defineDecimal("capacity", energyStorage, minimum = Decimal.ONE) + override val energyThroughput: Decimal by builder.defineDecimal("throughput", energyThroughput, minimum = Decimal.ONE) override val powerConsumption: Decimal by builder.defineDecimal("powerConsumption", powerConsumption, minimum = Decimal.ONE) + override val matterCapacity: Decimal by (if (matterCapacity == null) GetterSetter.box(Decimal.ZERO) else builder.defineDecimal("matterCapacity", matterCapacity, minimum = Decimal.ONE)) override val workTimeMultiplier: Double by (if (workTimeMultiplier == null) GetterSetter.box(1.0) else builder.defineInRange("workTimeMultiplier", workTimeMultiplier, 0.0)) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/BalanceValues.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/BalanceValues.kt index 5a7ed0fbc..6ff056147 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/BalanceValues.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/BalanceValues.kt @@ -2,22 +2,23 @@ package ru.dbotthepony.mc.otm.config import ru.dbotthepony.mc.otm.core.math.Decimal -interface ConciseBalanceValues { - val capacity: Decimal - val throughput: Decimal +interface EnergyBalanceValues { + val energyCapacity: Decimal + val energyThroughput: Decimal } -interface WorkerBalanceValues : ConciseBalanceValues { +interface WorkerBalanceValues : EnergyBalanceValues { val workTimeMultiplier: Double val powerConsumption: Decimal + val matterCapacity: Decimal } -interface BatteryBalanceValues : VerboseBalanceValues { +interface VerboseEnergyBalanceValues { + val energyCapacity: Decimal + val maxEnergyReceive: Decimal + val maxEnergyExtract: Decimal +} + +interface BatteryBalanceValues : VerboseEnergyBalanceValues { val initialBatteryLevel: Decimal } - -interface VerboseBalanceValues { - val capacity: Decimal - val receive: Decimal - val extract: Decimal -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt index 37e82edf8..cb9e1c4d7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt @@ -1,10 +1,8 @@ package ru.dbotthepony.mc.otm.config -import net.minecraftforge.common.ForgeConfigSpec.ConfigValue import ru.dbotthepony.mc.otm.block.entity.matter.MatterReconstructorBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterDecomposerBlockEntity -import ru.dbotthepony.mc.otm.block.entity.matter.MatterRecyclerBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterScannerBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity @@ -23,17 +21,24 @@ object MachinesConfig : AbstractConfig("machines") { MatterBottlerBlockEntity.registerConfig(builder) MatterReplicatorBlockEntity.registerConfig(builder) MatterScannerBlockEntity.registerConfig(builder) - MatterDecomposerBlockEntity.registerConfig(builder) MatterReconstructorBlockEntity.registerConfig(builder) } val PLATE_PRESS = workerValues( MNames.PLATE_PRESS, - storage = Decimal(40_000), - throughput = Decimal(200), + energyStorage = Decimal(40_000), + energyThroughput = Decimal(200), powerConsumption = Decimal(15) ) + val MATTER_DECOMPOSER = workerValues( + MNames.MATTER_DECOMPOSER, + energyStorage = Decimal(100_000), + energyThroughput = Decimal(400), + powerConsumption = Decimal(240), + matterCapacity = Decimal(400), + ) + var MATTER_RECYCLER_MATTER_PER_TICK: DecimalConfigValue by WriteOnce() private set @@ -42,8 +47,8 @@ object MachinesConfig : AbstractConfig("machines") { val MATTER_RECYCLER = workerValues( MNames.MATTER_RECYCLER, - storage = Decimal(80_000), - throughput = Decimal(400), + energyStorage = Decimal(80_000), + energyThroughput = Decimal(400), powerConsumption = Decimal(100), workTimeMultiplier = null ) { @@ -71,24 +76,24 @@ object MachinesConfig : AbstractConfig("machines") { val POWERED_FURNACE = workerValues( "POWERED_FURNACE", - storage = Decimal(40_000), - throughput = Decimal(200), + energyStorage = Decimal(40_000), + energyThroughput = Decimal(200), powerConsumption = Decimal(20), workTimeMultiplier = 0.75 ) val POWERED_BLAST_FURNACE = workerValues( "POWERED_BLAST_FURNACE", - storage = Decimal(40_000), - throughput = Decimal(200), + energyStorage = Decimal(40_000), + energyThroughput = Decimal(200), powerConsumption = Decimal(20), workTimeMultiplier = 0.75 ) val POWERED_SMOKER = workerValues( "POWERED_SMOKER", - storage = Decimal(40_000), - throughput = Decimal(200), + energyStorage = Decimal(40_000), + energyThroughput = Decimal(200), powerConsumption = Decimal(10), workTimeMultiplier = 0.75 ) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt index 1a1be7d62..8a54d54a0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt @@ -3,8 +3,8 @@ package ru.dbotthepony.mc.otm.container import ru.dbotthepony.mc.otm.capability.IMatteryUpgrade import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.UpgradeType -import ru.dbotthepony.mc.otm.config.ConciseBalanceValues -import ru.dbotthepony.mc.otm.config.VerboseBalanceValues +import ru.dbotthepony.mc.otm.config.EnergyBalanceValues +import ru.dbotthepony.mc.otm.config.VerboseEnergyBalanceValues import ru.dbotthepony.mc.otm.core.collect.filter import ru.dbotthepony.mc.otm.core.collect.map import ru.dbotthepony.mc.otm.core.collect.mapToDouble @@ -49,23 +49,23 @@ open class UpgradeContainer(slotCount: Int, open val allowedUpgrades: Set Decimal? = { null }, properties: Properties = Properties().stacksTo(1) ) : Item(properties) { - constructor(values: ConciseBalanceValues, properties: Properties = Properties().stacksTo(1)) : this(values::capacity, values::throughput, properties) + constructor(values: EnergyBalanceValues, properties: Properties = Properties().stacksTo(1)) : this(values::energyCapacity, values::energyThroughput, properties) constructor(storage: Decimal, throughput: Decimal? = null, properties: Properties = Properties().stacksTo(1)) : this({ storage }, { throughput }, properties) val capacity get() = _capacity.invoke() From 9c74b62f1019607d62d015676842a8996987be73 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 25 Jul 2023 19:41:44 +0700 Subject: [PATCH 0849/1199] Move top level matter dust function to matter dust item --- .../matter/MatterDecomposerBlockEntity.kt | 66 +------------------ .../matter/MatterReplicatorBlockEntity.kt | 3 +- .../mc/otm/item/matter/MatterDustItem.kt | 55 ++++++++++++++++ .../ru/dbotthepony/mc/otm/registry/MItems.kt | 2 +- 4 files changed, 60 insertions(+), 66 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index 24fc3c4cf..2cc112b88 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -9,91 +9,29 @@ import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState -import net.minecraftforge.common.ForgeConfigSpec +import ru.dbotthepony.mc.otm.block.entity.Job import ru.dbotthepony.mc.otm.block.entity.JobContainer import ru.dbotthepony.mc.otm.block.entity.JobStatus -import ru.dbotthepony.mc.otm.block.entity.Job import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.UpgradeType -import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage -import ru.dbotthepony.mc.otm.config.EnergyBalanceValues import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.UpgradeContainer import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue -import ru.dbotthepony.mc.otm.core.math.defineDecimal -import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.data.DecimalCodec import ru.dbotthepony.mc.otm.data.minRange -import ru.dbotthepony.mc.otm.graph.matter.MatterGraph import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode -import ru.dbotthepony.mc.otm.item.matter.MatterDustItem import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.menu.matter.MatterDecomposerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MItems -import ru.dbotthepony.mc.otm.registry.MNames - -fun moveMatterAsDustIntoContainer(_matterValue: Decimal, container: MatteryContainer, OUTPUT_DUST_MAIN: Int, OUTPUT_DUST_STACKING: Int): Decimal { - var matterValue = _matterValue - val item = MItems.MATTER_DUST as MatterDustItem - - while (matterValue > Decimal.ZERO) { - val stack = container[OUTPUT_DUST_MAIN] - - // первый слот пустой - if (stack.isEmpty) { - container[OUTPUT_DUST_MAIN] = ItemStack(item, 1).also { - matterValue -= item.addMatterValue(it, matterValue, false) - } - // первый слот не пустой, но мы можем влить туда материю - } else if (!item.isFull(stack) && stack.count == 1) { - matterValue -= item.addMatterValue(stack, matterValue, false) - container.setChanged(OUTPUT_DUST_MAIN) - // первый слот не пустой и мы не можем влить туда материю - } else { - val stack2 = container[OUTPUT_DUST_STACKING] - - // второй слот пустой - if (stack2.isEmpty) { - container[OUTPUT_DUST_STACKING] = ItemStack(item, 1).also { - matterValue -= item.addMatterValue(it, matterValue, false) - } - // второй слот не пустой, но мы можем влить туда материю - } else if (!item.isFull(stack2)) { - if (stack2.count != 1) { - return matterValue - } - - matterValue -= item.addMatterValue(stack2, matterValue, false) - container.setChanged(OUTPUT_DUST_STACKING) - } - - // можем ли мы стакнуть материю из второго слота в первый? - if (!stack2.isEmpty && item.isFull(stack2)) { - if (ItemStack.isSameItemSameTags(stack, stack2) && container.getMaxStackSizeWithItem(OUTPUT_DUST_MAIN) >= stack.count + 1) { - stack.count++ - stack2.count-- - - container.setChanged(OUTPUT_DUST_MAIN) - container.setChanged(OUTPUT_DUST_STACKING) - } else { - return matterValue - } - } - } - } - - return Decimal.ZERO -} class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) : MatteryWorkerBlockEntity(MBlockEntities.MATTER_DECOMPOSER, pos, state, DecomposerJob.CODEC) { @@ -162,7 +100,7 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) override fun onJobFinish(status: JobStatus, id: Int) { if (status.job.toDust) { - status.job.matterValue = moveMatterAsDustIntoContainer(status.job.matterValue, outputContainer, 0, 1) + status.job.matterValue = MItems.MATTER_DUST.moveIntoContainer(status.job.matterValue, outputContainer, 0, 1) if (!status.job.matterValue.isZero) status.throttleFast() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index 23ef6a790..5df4e5218 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -37,6 +37,7 @@ import ru.dbotthepony.mc.otm.graph.matter.MatterNode import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.menu.matter.MatterReplicatorMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities +import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MNames import java.util.* @@ -113,7 +114,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val job = status.job if (job.asDust) { - job.matterValue = moveMatterAsDustIntoContainer(job.matterValue, container, OUTPUT_DUST_MAIN, OUTPUT_DUST_STACKING) + job.matterValue = MItems.MATTER_DUST.moveIntoContainer(job.matterValue, container, OUTPUT_DUST_MAIN, OUTPUT_DUST_STACKING) if (!job.matterValue.isZero) { return status.throttle() 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 f70db8db5..d2ae858c3 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 @@ -11,12 +11,14 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag 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.math.Decimal import ru.dbotthepony.mc.otm.matter.IMatterItem import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.matter.IMatterValue import ru.dbotthepony.mc.otm.matter.MatterValue +import ru.dbotthepony.mc.otm.registry.MItems class MatterDustItem : Item(Properties().stacksTo(64)), IMatterItem { private fun matter(stack: ItemStack): Decimal { @@ -32,6 +34,59 @@ class MatterDustItem : Item(Properties().stacksTo(64)), IMatterItem { return MatterValue(Decimal.deserializeNBT(value), 1.0) } + fun moveIntoContainer(matterValue: Decimal, container: MatteryContainer, mainSlot: Int, stackingSlot: Int): Decimal { + @Suppress("name_shadowing") + var matterValue = matterValue + + while (matterValue > Decimal.ZERO) { + val stack = container[mainSlot] + + // первый слот пустой + if (stack.isEmpty) { + container[mainSlot] = ItemStack(this, 1).also { + matterValue -= addMatterValue(it, matterValue, false) + } + // первый слот не пустой, но мы можем влить туда материю + } else if (!isFull(stack) && stack.count == 1) { + matterValue -= addMatterValue(stack, matterValue, false) + container.setChanged(mainSlot) + // первый слот не пустой и мы не можем влить туда материю + } else { + val stack2 = container[stackingSlot] + + // второй слот пустой + if (stack2.isEmpty) { + container[stackingSlot] = ItemStack(this, 1).also { + matterValue -= addMatterValue(it, matterValue, false) + } + // второй слот не пустой, но мы можем влить туда материю + } else if (!isFull(stack2)) { + if (stack2.count != 1) { + return matterValue + } + + matterValue -= addMatterValue(stack2, matterValue, false) + container.setChanged(stackingSlot) + } + + // можем ли мы стакнуть материю из второго слота в первый? + if (!stack2.isEmpty && isFull(stack2)) { + if (ItemStack.isSameItemSameTags(stack, stack2) && container.getMaxStackSizeWithItem(mainSlot) >= stack.count + 1) { + stack.count++ + stack2.count-- + + container.setChanged(mainSlot) + container.setChanged(stackingSlot) + } else { + return matterValue + } + } + } + } + + return Decimal.ZERO + } + override fun canDecompose(stack: ItemStack) = false override fun appendHoverText( 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 3afedaf0e..9986f0f96 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -206,7 +206,7 @@ object MItems { CreativeUpgrades } - val MATTER_DUST: Item by registry.register(MNames.MATTER_DUST) { MatterDustItem() } + val MATTER_DUST: MatterDustItem by registry.register(MNames.MATTER_DUST) { MatterDustItem() } val TRITANIUM_ORE_CLUMP: Item by registry.register(MNames.TRITANIUM_ORE_CLUMP) { Item(DEFAULT_PROPERTIES) } val TRITANIUM_DUST: Item by registry.register(MNames.TRITANIUM_DUST) { Item(DEFAULT_PROPERTIES) } From ee8c641a61a768d991a7f08dff53e8e5ec2a8256 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 25 Jul 2023 20:16:55 +0700 Subject: [PATCH 0850/1199] Matter scanner rebalanced values and added upgrades support --- .../entity/matter/MatterScannerBlockEntity.kt | 37 +++++-------------- .../mc/otm/config/MachinesConfig.kt | 8 +++- 2 files changed, 16 insertions(+), 29 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt index 577220d47..6869bd9e5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt @@ -14,14 +14,18 @@ import ru.dbotthepony.mc.otm.block.entity.ItemJob import ru.dbotthepony.mc.otm.block.entity.MachineJobEventLoop import ru.dbotthepony.mc.otm.config.EnergyBalanceValues import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity +import ru.dbotthepony.mc.otm.capability.IMatteryUpgrade import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.UpgradeType import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.IPatternState import ru.dbotthepony.mc.otm.capability.matter.PatternState +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.container.UpgradeContainer import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal @@ -37,8 +41,9 @@ import kotlin.math.pow class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryWorkerBlockEntity(MBlockEntities.MATTER_SCANNER, p_155229_, p_155230_, ItemJob.CODEC) { + override val upgrades = UpgradeContainer(this::setChangedLight, 2, UpgradeType.BASIC) val container = MatteryContainer(::itemContainerUpdated, 1).also(::addDroppableContainer) - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::energyLevelUpdated, ENERGY_VALUES)) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::energyLevelUpdated, upgrades.transform(MachinesConfig.MATTER_SCANNER))) val itemConfig = ConfigurableItemHandler(inputOutput = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { @@ -149,7 +154,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : stack.shrink(1) container.setChanged() val complexity = MatterManager.get(copy).complexity - return JobContainer.success(ItemJob(copy, (if (complexity > 1.0) complexity.pow(1.25) else complexity.pow(0.5)), BASE_CONSUMPTION)) + return JobContainer.success(ItemJob(copy, (if (complexity > 1.0) complexity.pow(1.25) else complexity.pow(0.5)) * MachinesConfig.MATTER_SCANNER.workTimeMultiplier, MachinesConfig.MATTER_SCANNER.powerConsumption)) } return JobContainer.noItem() @@ -172,31 +177,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : var visualProgress by synchronizer.float().property private set - override fun onJobTick( - status: JobStatus, - id: Int - ) { - val result = super.onJobTick(status, id) - - visualProgress = jobEventLoops[0].workProgress - - return result - } - - companion object { - private val BASE_CONSUMPTION get() = _BASE_CONSUMPTION.get() - - private var _BASE_CONSUMPTION: DecimalConfigValue by WriteOnce() - var ENERGY_VALUES: EnergyBalanceValues by WriteOnce() - private set - - fun registerConfig(builder: ForgeConfigSpec.Builder) { - builder.push(MNames.MATTER_SCANNER) - - ENERGY_VALUES = BlockEnergyStorageImpl.makeConfigEntry(builder, capacity = Decimal(80_000), throughput = Decimal(400)) - _BASE_CONSUMPTION = builder.defineDecimal("baseConsumption", Decimal(40), Decimal.ONE) - - builder.pop() - } + override fun onJobTick(status: JobStatus, id: Int) { + visualProgress = status.workProgress } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt index cb9e1c4d7..23b7d6238 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt @@ -20,7 +20,6 @@ object MachinesConfig : AbstractConfig("machines") { ChemicalGeneratorBlockEntity.registerConfig(builder) MatterBottlerBlockEntity.registerConfig(builder) MatterReplicatorBlockEntity.registerConfig(builder) - MatterScannerBlockEntity.registerConfig(builder) MatterReconstructorBlockEntity.registerConfig(builder) } @@ -39,6 +38,13 @@ object MachinesConfig : AbstractConfig("machines") { matterCapacity = Decimal(400), ) + val MATTER_SCANNER = workerValues( + MNames.MATTER_SCANNER, + energyStorage = Decimal(40_000), + energyThroughput = Decimal(200), + powerConsumption = Decimal(80), + ) + var MATTER_RECYCLER_MATTER_PER_TICK: DecimalConfigValue by WriteOnce() private set From 1f4f83367b9a0495760cb3b1f5e244b773a221fe Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 25 Jul 2023 20:27:49 +0700 Subject: [PATCH 0851/1199] Add matter decomposer and scanner upgrades to menus --- .../mc/otm/client/screen/matter/MatterDecomposerScreen.kt | 2 +- .../mc/otm/client/screen/matter/MatterScannerScreen.kt | 2 +- .../ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt | 1 + .../ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt index f399232ac..659f914bd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterDecomposerScreen.kt @@ -30,7 +30,7 @@ class MatterDecomposerScreen(p_97741_: MatterDecomposerMenu, p_97742_: Inventory SlotPanel(this, frame, menu.outputMain, 74f, PROGRESS_SLOT_TOP) SlotPanel(this, frame, menu.outputStacking, 56f, PROGRESS_SLOT_TOP) - makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig, upgrades = menu.upgrades) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterScannerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterScannerScreen.kt index 3af6b5302..d58e9b963 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterScannerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterScannerScreen.kt @@ -26,7 +26,7 @@ class MatterScannerScreen(p_97741_: MatterScannerMenu, p_97742_: Inventory, p_97 ProgressGaugePanel(this, frame, menu.progress, 63f, PROGRESS_ARROW_TOP).flop = true SlotPanel(this, frame, menu.input, 93f, PROGRESS_SLOT_TOP) - makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig, upgrades = menu.upgrades) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt index f4dbfcdfe..29e2a6a21 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt @@ -34,6 +34,7 @@ class MatterDecomposerMenu @JvmOverloads constructor( val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) + val upgrades = makeUpgradeSlots(4, tile?.upgrades) init { val container = tile?.outputContainer ?: SimpleContainer(2) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt index 2482505d6..48c500c0d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterScannerMenu.kt @@ -27,6 +27,7 @@ class MatterScannerMenu @JvmOverloads constructor( val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) + val upgrades = makeUpgradeSlots(2, tile?.upgrades) init { val container = tile?.container ?: SimpleContainer(1) From 48fe9ada79e38bfbdf51cfdf1afba495b42da84b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 26 Jul 2023 00:04:52 +0700 Subject: [PATCH 0852/1199] Update UUID codec --- .../ru/dbotthepony/mc/otm/data/UUIDCodec.kt | 38 ++++++++++++++++--- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/UUIDCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/UUIDCodec.kt index 4accf6e75..a6fead1fb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/UUIDCodec.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/UUIDCodec.kt @@ -4,23 +4,49 @@ import com.mojang.datafixers.util.Pair import com.mojang.serialization.Codec import com.mojang.serialization.DataResult import com.mojang.serialization.DynamicOps +import net.minecraft.nbt.NbtOps import java.util.UUID import java.util.stream.LongStream +// because UUIDUtil codec is in unexpected place +// and can't work with both strings, array of longs and array of ints object UUIDCodec : Codec { override fun encode(input: UUID, ops: DynamicOps, prefix: T): DataResult { - return DataResult.success(ops.createLongList(LongStream.of(input.mostSignificantBits, input.leastSignificantBits))) + if (ops === NbtOps.INSTANCE) { + return DataResult.success((ops as DynamicOps).createLongList(LongStream.of(input.mostSignificantBits, input.leastSignificantBits))) + } + + return DataResult.success(ops.createString(input.toString())) } override fun decode(ops: DynamicOps, input: T): DataResult> { return ops.getLongStream(input).flatMap { - val l = it.limit(2).toArray() + val l = it.limit(4).toArray() - if (l.size != 2) { - DataResult.error { "Can't construct UUID from ${l.size} elements" } - } else { + if (l.size == 4) { + // 4 int + DataResult.success(Pair(UUID((l[0] shl 32) or l[1], (l[2] shl 32) or l[3]), ops.empty())) + } else if (l.size == 2) { DataResult.success(Pair(UUID(l[0], l[1]), ops.empty())) + } else { + DataResult.error { "Can't construct UUID from ${l.size} elements" } } - } + }.get().map( + { + DataResult.success(it) + }, + { e0 -> + ops.getStringValue(input).map { + Pair(UUID.fromString(it), ops.empty()) + }.get().map( + { + DataResult.success(it) + }, + { + DataResult.error { "Unable to deserialize UUID: ${e0.message()}; ${it.message()}" } + } + ) + } + ) } } From 662801df7d8111d4daa8824e9618ca69bcf08833 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 26 Jul 2023 01:11:46 +0700 Subject: [PATCH 0853/1199] write/read json -> write/read binary json --- .../mc/otm/android/AndroidResearchManager.kt | 5 ---- .../mc/otm/core/UnOverengineering.kt | 10 +++---- .../mc/otm/core/nbt/CompoundTagExt.kt | 8 ++--- .../mc/otm/core/util/FriendlyStreams.kt | 29 +++++++++---------- .../mc/otm/recipe/PlatePressRecipe.kt | 9 +++--- .../mc/otm/recipe/UpgradeRecipe.kt | 9 +++--- 6 files changed, 30 insertions(+), 40 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchManager.kt index 7f1672933..7062117f1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchManager.kt @@ -11,10 +11,8 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.server.packs.resources.ResourceManager import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener import net.minecraft.util.profiling.ProfilerFiller -import net.minecraftforge.common.MinecraftForge import net.minecraftforge.event.AddReloadListenerEvent import net.minecraftforge.event.OnDatapackSyncEvent -import net.minecraftforge.eventbus.api.Event import net.minecraftforge.network.NetworkEvent import net.minecraftforge.network.PacketDistributor import org.apache.logging.log4j.LogManager @@ -26,10 +24,7 @@ import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.fromJsonStrict import ru.dbotthepony.mc.otm.core.fromNetwork import ru.dbotthepony.mc.otm.core.set -import ru.dbotthepony.mc.otm.core.toJsonStrict import ru.dbotthepony.mc.otm.core.toNetwork -import ru.dbotthepony.mc.otm.core.util.readJson -import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.RegistryNetworkChannel import ru.dbotthepony.mc.otm.network.enqueueWork diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt index f643eb1a9..3cc18df17 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt @@ -4,7 +4,6 @@ import com.google.gson.JsonElement import com.google.gson.JsonSyntaxException import com.mojang.serialization.Codec import com.mojang.serialization.JsonOps -import net.minecraft.core.BlockPos import net.minecraft.core.Holder import net.minecraft.core.RegistryAccess import net.minecraft.core.registries.Registries @@ -23,11 +22,10 @@ import net.minecraft.world.damagesource.DamageType import net.minecraft.world.item.Item import net.minecraft.world.level.block.Block import net.minecraft.world.level.material.Fluid -import net.minecraft.world.phys.Vec3 import net.minecraftforge.registries.ForgeRegistries import net.minecraftforge.registries.IForgeRegistry -import ru.dbotthepony.mc.otm.core.util.readJson -import ru.dbotthepony.mc.otm.core.util.writeJson +import ru.dbotthepony.mc.otm.core.util.readBinaryJson +import ru.dbotthepony.mc.otm.core.util.writeBinaryJson // because doing it inline is ugly fun Codec.fromJson(value: JsonElement): V? { @@ -63,11 +61,11 @@ fun Codec.toNbtStrict(value: V, prefix: Tag = NbtOps.INSTANCE.empty } fun Codec.toNetwork(buff: FriendlyByteBuf, value: V) { - buff.writeJson(toJsonStrict(value)) + buff.writeBinaryJson(toJsonStrict(value)) } fun Codec.fromNetwork(buff: FriendlyByteBuf): V { - return fromJsonStrict(buff.readJson()) + return fromJsonStrict(buff.readBinaryJson()) } // 1.19 being 1.19 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt index 140619739..538382561 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt @@ -20,8 +20,8 @@ import net.minecraft.nbt.ShortTag import net.minecraft.nbt.StringTag import net.minecraft.nbt.Tag import net.minecraft.world.item.ItemStack -import ru.dbotthepony.mc.otm.core.util.readJson -import ru.dbotthepony.mc.otm.core.util.writeJson +import ru.dbotthepony.mc.otm.core.util.readBinaryJson +import ru.dbotthepony.mc.otm.core.util.writeBinaryJson import java.util.UUID operator fun CompoundTag.set(index: String, value: Tag) = put(index, value) @@ -108,7 +108,7 @@ fun CompoundTag.getUUIDSafe(key: String): UUID? { fun CompoundTag.putJson(key: String, json: JsonElement) { val bytes = FastByteArrayOutputStream() - bytes.writeJson(json) + bytes.writeBinaryJson(json) putByteArray(key, bytes.array.copyOfRange(0, bytes.length)) } @@ -118,7 +118,7 @@ fun CompoundTag.getJson(key: String, sizeLimit: NbtAccounter = NbtAccounter.UNLI if (bytes.isEmpty()) return null - return FastByteArrayInputStream(bytes).readJson(sizeLimit) + return FastByteArrayInputStream(bytes).readBinaryJson(sizeLimit) } fun CompoundTag.getBoolean(index: String, orElse: Boolean): Boolean { 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 c4e5ffbc5..308563fa2 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 @@ -24,7 +24,6 @@ import net.minecraftforge.registries.ForgeRegistry import java.io.* import java.math.BigDecimal import java.math.BigInteger -import kotlin.math.absoluteValue // But seriously, Mojang, why would you need to derive from ByteBuf directly, when you can implement // your own InputStream and OutputStream, since ByteBuf is meant to be operated on most time like a stream anyway? @@ -154,21 +153,21 @@ private const val TYPE_OBJECT = 0x07 * * just copy pasted this code from my another project because i was lazy */ -fun OutputStream.writeJson(element: JsonElement) { +fun OutputStream.writeBinaryJson(element: JsonElement) { if (element is JsonObject) { write(TYPE_OBJECT) writeVarIntLE(element.size()) for ((k, v) in element.entrySet()) { writeBinaryString(k) - writeJson(v) + writeBinaryJson(v) } } else if (element is JsonArray) { write(TYPE_ARRAY) writeVarIntLE(element.size()) for (v in element) { - writeJson(v) + writeBinaryJson(v) } } else if (element is JsonPrimitive) { if (element.isNumber) { @@ -204,7 +203,7 @@ fun OutputStream.writeJson(element: JsonElement) { * * just copy pasted this code from my another project because i was lazy */ -fun InputStream.readJson(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 KiB */)): JsonElement { +fun InputStream.readBinaryJson(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 KiB */)): JsonElement { sizeLimit.accountBytes(1L) return when (val id = read()) { @@ -226,7 +225,7 @@ fun InputStream.readJson(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 if (values < 0) throw JsonSyntaxException("Tried to read json array with $values elements in it") val build = JsonArray(values) - for (i in 0 until values) build.add(readJson(sizeLimit)) + for (i in 0 until values) build.add(readBinaryJson(sizeLimit)) return build } TYPE_OBJECT -> { @@ -246,7 +245,7 @@ fun InputStream.readJson(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 } try { - build.add(key, readJson(sizeLimit)) + build.add(key, readBinaryJson(sizeLimit)) } catch(err: Throwable) { throw JsonSyntaxException("Reading json object at $i with name $key", err) } @@ -259,27 +258,27 @@ fun InputStream.readJson(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 } fun InputStream.readBinaryComponent(): Component? { - return Component.Serializer.fromJson(readJson()) + return Component.Serializer.fromJson(readBinaryJson()) } fun OutputStream.writeBinaryComponent(component: Component) { - writeJson(Component.Serializer.toJsonTree(component)) + writeBinaryJson(Component.Serializer.toJsonTree(component)) } -fun FriendlyByteBuf.readJson(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18)): JsonElement { - return ByteBufInputStream(this).readJson(sizeLimit) +fun FriendlyByteBuf.readBinaryJson(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18)): JsonElement { + return ByteBufInputStream(this).readBinaryJson(sizeLimit) } -fun FriendlyByteBuf.writeJson(value: JsonElement) { - ByteBufOutputStream(this).writeJson(value) +fun FriendlyByteBuf.writeBinaryJson(value: JsonElement) { + ByteBufOutputStream(this).writeBinaryJson(value) } fun FriendlyByteBuf.readBinaryComponent(): Component { - return Component.Serializer.fromJson(readJson()) ?: throw NullPointerException("Received null component") + return Component.Serializer.fromJson(readBinaryJson()) ?: throw NullPointerException("Received null component") } fun FriendlyByteBuf.writeBinaryComponent(component: Component) { - writeJson(Component.Serializer.toJsonTree(component)) + writeBinaryJson(Component.Serializer.toJsonTree(component)) } fun S.writeCollection(collection: Collection, writer: S.(V) -> Unit) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt index f471b091f..783ee71d5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt @@ -17,15 +17,14 @@ import net.minecraft.world.item.crafting.RecipeType import net.minecraft.world.level.Level import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity import ru.dbotthepony.mc.otm.container.get import ru.dbotthepony.mc.otm.core.fromJsonStrict import ru.dbotthepony.mc.otm.core.isActuallyEmpty import ru.dbotthepony.mc.otm.registry.MRecipes import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.core.toJsonStrict -import ru.dbotthepony.mc.otm.core.util.readJson -import ru.dbotthepony.mc.otm.core.util.writeJson +import ru.dbotthepony.mc.otm.core.util.readBinaryJson +import ru.dbotthepony.mc.otm.core.util.writeBinaryJson class PlatePressRecipe( private val id: ResourceLocation, @@ -122,7 +121,7 @@ class PlatePressRecipe( } override fun fromNetwork(loc: ResourceLocation, buff: FriendlyByteBuf): PlatePressRecipe { - return PlatePressRecipe(loc, Ingredient.fromNetwork(buff), Ingredient.fromNetwork(buff), buff.readInt(), buff.readInt(), FloatProvider.CODEC.fromJsonStrict(buff.readJson())) + return PlatePressRecipe(loc, Ingredient.fromNetwork(buff), Ingredient.fromNetwork(buff), buff.readInt(), buff.readInt(), FloatProvider.CODEC.fromJsonStrict(buff.readBinaryJson())) } override fun toNetwork(buff: FriendlyByteBuf, recipe: PlatePressRecipe) { @@ -130,7 +129,7 @@ class PlatePressRecipe( recipe.output.toNetwork(buff) buff.writeInt(recipe.count) buff.writeInt(recipe.workTime) - buff.writeJson(FloatProvider.CODEC.toJsonStrict(recipe.experience)) + buff.writeBinaryJson(FloatProvider.CODEC.toJsonStrict(recipe.experience)) } } } 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 224186c4e..71ae269d2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt @@ -14,7 +14,6 @@ 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.Recipe import net.minecraft.world.item.crafting.RecipeSerializer import net.minecraft.world.item.crafting.RecipeType import net.minecraft.world.item.crafting.ShapedRecipe @@ -25,8 +24,8 @@ import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.core.tagNotNull -import ru.dbotthepony.mc.otm.core.util.readJson -import ru.dbotthepony.mc.otm.core.util.writeJson +import ru.dbotthepony.mc.otm.core.util.readBinaryJson +import ru.dbotthepony.mc.otm.core.util.writeBinaryJson import ru.dbotthepony.mc.otm.core.collect.stream import java.util.stream.Stream @@ -241,14 +240,14 @@ class UpgradeRecipe( return UpgradeRecipe( recipe, - buff.readCollection({ ArrayList(it) }, { deserializeOp(it.readJson() as JsonObject) }).stream(), + buff.readCollection({ ArrayList(it) }, { deserializeOp(it.readBinaryJson() as JsonObject) }).stream(), buff.readResourceLocation() ) } override fun toNetwork(buff: FriendlyByteBuf, value: UpgradeRecipe) { ShapedRecipe.Serializer.SHAPED_RECIPE.toNetwork(buff, value.parent) - buff.writeCollection(value.copyPaths) { it, v -> it.writeJson(v.serialize()) } + buff.writeCollection(value.copyPaths) { it, v -> it.writeBinaryJson(v.serialize()) } buff.writeResourceLocation(value.source) } } From a673ed966e282163defc3d02329388c1edbc52a0 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 26 Jul 2023 01:45:14 +0700 Subject: [PATCH 0854/1199] Make PatternState be only immutable, completely move it to codecs, write/read binary json with codec --- .../entity/matter/MatterPanelBlockEntity.kt | 5 +- .../matter/MatterReconstructorBlockEntity.kt | 8 +- .../matter/MatterReplicatorBlockEntity.kt | 4 +- .../entity/matter/MatterScannerBlockEntity.kt | 24 +--- .../matter/PatternStorageBlockEntity.kt | 9 +- .../mc/otm/capability/matter/Data.kt | 10 +- .../otm/capability/matter/IPatternStorage.kt | 18 +-- .../mc/otm/capability/matter/PatternState.kt | 131 +++--------------- .../client/screen/matter/MatterPanelScreen.kt | 6 +- .../mc/otm/core/util/FriendlyStreams.kt | 13 ++ .../otm/graph/matter/IMatterGraphListener.kt | 6 +- .../mc/otm/graph/matter/MatterGraph.kt | 18 +-- .../mc/otm/item/matter/CreativePatternItem.kt | 7 +- .../mc/otm/item/matter/PatternStorageItem.kt | 12 +- .../mc/otm/menu/matter/MatterPanelMenu.kt | 18 +-- 15 files changed, 95 insertions(+), 194 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt index 12b9fc174..6663c1747 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt @@ -11,7 +11,6 @@ import net.minecraft.world.inventory.AbstractContainerMenu import ru.dbotthepony.mc.otm.capability.MatteryCapability import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.ListTag -import net.minecraft.server.level.ServerLevel import net.minecraft.world.level.Level import net.minecraftforge.common.util.INBTSerializable import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity @@ -22,9 +21,7 @@ import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.mapString import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.ItemSorter -import ru.dbotthepony.mc.otm.graph.Graph6Node import ru.dbotthepony.mc.otm.graph.matter.MatterGraph -import ru.dbotthepony.mc.otm.graph.matter.MatterNode import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode import ru.dbotthepony.mc.otm.registry.MBlockEntities import java.util.* @@ -195,7 +192,7 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : setChanged() } - fun addTask(state: IPatternState, count: Int): IReplicationTask<*> { + fun addTask(state: PatternState, count: Int): IReplicationTask<*> { val task = ReplicationTask(UUID.randomUUID(), Optional.of(state.id), state.item, 0, 0, count) _tasks[task.id] = task diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt index 74976f0ba..55c2c0d9d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt @@ -21,7 +21,7 @@ import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage -import ru.dbotthepony.mc.otm.capability.matter.IPatternState +import ru.dbotthepony.mc.otm.capability.matter.PatternState import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage import ru.dbotthepony.mc.otm.config.EnergyBalanceValues @@ -68,15 +68,15 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) return matter } - override fun onPatternAdded(state: IPatternState) { + override fun onPatternAdded(state: PatternState) { containerChanged() } - override fun onPatternRemoved(state: IPatternState) { + override fun onPatternRemoved(state: PatternState) { containerChanged() } - override fun onPatternUpdated(newState: IPatternState, oldState: IPatternState) { + override fun onPatternUpdated(newState: PatternState, oldState: PatternState) { containerChanged() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index 5df4e5218..1e42b8a95 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -91,7 +91,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : jobEventLoops[0].notify(MachineJobEventLoop.IdleReason.OBSERVING) } - override fun onPatternAdded(state: IPatternState) { + override fun onPatternAdded(state: PatternState) { jobEventLoops[0].notify(MachineJobEventLoop.IdleReason.OBSERVING) } } @@ -182,7 +182,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : matterPerTick = matter.matter / ticks, task = allocation.task.id, matterValue = matter.matter, - pattern = Optional.ofNullable(allocation.pattern?.asImmutable()), + pattern = Optional.ofNullable(allocation.pattern), asDust = (level?.random?.nextDouble() ?: 1.0) * upgrades.failureMultiplier > (allocation.pattern?.researchPercent ?: 2.0), ticks = ticks, )) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt index 6869bd9e5..2009e343d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt @@ -7,32 +7,22 @@ import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState -import net.minecraftforge.common.ForgeConfigSpec import ru.dbotthepony.mc.otm.block.entity.JobContainer import ru.dbotthepony.mc.otm.block.entity.JobStatus import ru.dbotthepony.mc.otm.block.entity.ItemJob import ru.dbotthepony.mc.otm.block.entity.MachineJobEventLoop -import ru.dbotthepony.mc.otm.config.EnergyBalanceValues import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity -import ru.dbotthepony.mc.otm.capability.IMatteryUpgrade -import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.UpgradeType import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage -import ru.dbotthepony.mc.otm.capability.matter.IPatternState import ru.dbotthepony.mc.otm.capability.matter.PatternState 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.container.UpgradeContainer -import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue -import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.menu.matter.MatterScannerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities -import ru.dbotthepony.mc.otm.registry.MNames -import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.graph.matter.MatterNode import ru.dbotthepony.mc.otm.matter.MatterManager import java.util.* @@ -58,15 +48,15 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val energyConfig = ConfigurableEnergy(energy) val matterNode = object : MatterNode() { - override fun onPatternAdded(state: IPatternState) { + override fun onPatternAdded(state: PatternState) { jobEventLoops[0].notify(MachineJobEventLoop.IdleReason.PATTERN) } - override fun onPatternRemoved(state: IPatternState) { + override fun onPatternRemoved(state: PatternState) { jobEventLoops[0].notify(MachineJobEventLoop.IdleReason.PATTERN) } - override fun onPatternUpdated(newState: IPatternState, oldState: IPatternState) { + override fun onPatternUpdated(newState: PatternState, oldState: PatternState) { jobEventLoops[0].notify(MachineJobEventLoop.IdleReason.PATTERN) } } @@ -96,7 +86,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val stack = status.job.itemStack if (stack.isEmpty || !MatterManager.hasMatterValue(stack)) return status.success() - var findState: IPatternState? = null + var findState: PatternState? = null for (state in matterNode.graph.patterns.filter { it.item === stack.item }) { if (findState == null && state.researchPercent < 1.0) { @@ -108,7 +98,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val researchAdvance = MatterManager.getResearchAdvance(stack.item) - val new: IPatternState = + val new: PatternState = if (findState != null) { PatternState(findState.id, stack.item, (findState.researchPercent + researchAdvance).coerceAtMost(1.0)) } else { @@ -128,7 +118,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val stack = container.getItem(0) if (stack.isEmpty || !MatterManager.canDecompose(stack)) return JobContainer.noItem() - var findState: IPatternState? = null + var findState: PatternState? = null for (state in matterNode.graph.patterns.filter { it.item === stack.item }) { if (state.researchPercent < 1.0) { @@ -142,7 +132,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val researchAdvance = MatterManager.getResearchAdvance(stack.item) - val new: IPatternState = + val new: PatternState = if (findState != null) { PatternState(findState.id, stack.item, (findState.researchPercent + researchAdvance).coerceAtMost(1.0)) } else { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt index 1e4e0a821..81f4d9375 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt @@ -13,14 +13,11 @@ import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import ru.dbotthepony.mc.otm.menu.matter.PatternStorageMenu import net.minecraft.MethodsReturnNonnullByDefault -import net.minecraft.server.level.ServerLevel import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.matter.* import ru.dbotthepony.mc.otm.core.collect.iterator -import ru.dbotthepony.mc.otm.graph.Graph6Node -import ru.dbotthepony.mc.otm.graph.matter.MatterGraph import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode import ru.dbotthepony.mc.otm.registry.MBlockEntities import java.util.ArrayList @@ -97,8 +94,8 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return PatternStorageMenu(containerID, inventory, this) } - override val patterns: Stream get() { - val streams = ArrayList>() + override val patterns: Stream get() { + val streams = ArrayList>() for (provider in this.container.iterator(MatteryCapability.PATTERN)) { streams.add(provider.second.patterns) @@ -130,7 +127,7 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : matterNode.isValid = false } - override fun insertPattern(pattern: IPatternState, onlyUpdate: Boolean, simulate: Boolean): PatternInsertStatus { + override fun insertPattern(pattern: PatternState, onlyUpdate: Boolean, simulate: Boolean): PatternInsertStatus { for (pair in this.container.iterator(MatteryCapability.PATTERN)) { val status = pair.second.insertPattern(pattern, onlyUpdate, simulate) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/Data.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/Data.kt index 78df561cc..64b6d75cf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/Data.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/Data.kt @@ -8,8 +8,8 @@ private enum class PatternInsertResult { sealed class PatternInsertStatus( private val status: PatternInsertResult, - val newState: IPatternState?, - val oldState: IPatternState? + val newState: PatternState?, + val oldState: PatternState? ) { val isFailed get() = status == PatternInsertResult.FAIL val isUpdated get() = status == PatternInsertResult.UPDATED @@ -17,8 +17,8 @@ sealed class PatternInsertStatus( } object PatternInsertFailure : PatternInsertStatus(PatternInsertResult.FAIL, null, null) -class PatternInsertUpdated(new: IPatternState, old: IPatternState) : PatternInsertStatus(PatternInsertResult.UPDATED, new, old) -class PatternInsertInserted(new: IPatternState) : PatternInsertStatus(PatternInsertResult.INSERTED, new, null) +class PatternInsertUpdated(new: PatternState, old: PatternState) : PatternInsertStatus(PatternInsertResult.UPDATED, new, old) +class PatternInsertInserted(new: PatternState) : PatternInsertStatus(PatternInsertResult.INSERTED, new, null) @JvmRecord -data class ReplicationTaskAllocation(val task: IReplicationTask<*>, val pattern: IPatternState?) +data class ReplicationTaskAllocation(val task: IReplicationTask<*>, val pattern: PatternState?) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IPatternStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IPatternStorage.kt index b43508eb6..4730b3291 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IPatternStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IPatternStorage.kt @@ -15,21 +15,21 @@ interface IPatternStorage { /** * It must return new stream each time */ - val patterns: Stream + val patterns: Stream - fun findPatterns(item: Item): Collection { + fun findPatterns(item: Item): Collection { return findPatterns { item == it.item } } - fun findPatterns(predicate: Predicate): Collection { + fun findPatterns(predicate: Predicate): Collection { return patterns.filter(predicate).collect(Collectors.toList()) } - fun findPattern(item: Item): IPatternState? { + fun findPattern(item: Item): PatternState? { return patterns.filter { it.item == item }.findAny().orElse(null) } - fun getPattern(id: UUID?): IPatternState? { + fun getPattern(id: UUID?): PatternState? { return patterns.filter { it.id == id }.findAny().orElse(null) } @@ -37,7 +37,7 @@ interface IPatternStorage { return patterns.filter { it.item == item }.findAny().isPresent } - fun hasPattern(state: IPatternState): Boolean { + fun hasPattern(state: PatternState): Boolean { return hasPattern(state.id) } @@ -57,13 +57,13 @@ interface IPatternStorage { * @param simulate whenever to affect state * @return record of status of the operation (at status() FAIL, UPDATED, INSERTED) as well as new_state and old_state */ - fun insertPattern(pattern: IPatternState, onlyUpdate: Boolean, simulate: Boolean): PatternInsertStatus + fun insertPattern(pattern: PatternState, onlyUpdate: Boolean, simulate: Boolean): PatternInsertStatus - fun insertPattern(pattern: IPatternState, simulate: Boolean): PatternInsertStatus { + fun insertPattern(pattern: PatternState, simulate: Boolean): PatternInsertStatus { return insertPattern(pattern, false, simulate) } - fun updatePattern(pattern: IPatternState, simulate: Boolean): PatternInsertStatus { + fun updatePattern(pattern: PatternState, simulate: Boolean): PatternInsertStatus { return insertPattern(pattern, true, simulate) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/PatternState.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/PatternState.kt index 4fd31a930..d3ae04379 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/PatternState.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/PatternState.kt @@ -1,101 +1,39 @@ package ru.dbotthepony.mc.otm.capability.matter -import com.mojang.datafixers.Products import com.mojang.serialization.Codec import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.NbtOps import net.minecraft.nbt.Tag import net.minecraft.network.FriendlyByteBuf -import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.Items import net.minecraftforge.registries.ForgeRegistries -import ru.dbotthepony.mc.otm.core.* -import ru.dbotthepony.mc.otm.core.nbt.contains -import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.core.util.readBinaryJsonWithCodec +import ru.dbotthepony.mc.otm.core.util.writeBinaryJsonWithCodec import ru.dbotthepony.mc.otm.data.UUIDCodec import java.util.* -sealed interface IPatternState { - val id: UUID - val item: Item - val researchPercent: Double - - fun asMutable(): MutablePatternState - fun asImmutable() : PatternState - - fun matchId(other: IPatternState): Boolean { +data class PatternState( + val id: UUID, + val item: Item, + val researchPercent: Double, +) { + fun matchId(other: PatternState): Boolean { return other.id == id } - fun copyAsMutable( - id: UUID = this.id, - item: Item = this.item, - researchPercent: Double = this.researchPercent, - ): MutablePatternState { - return MutablePatternState(id, item, researchPercent) - } - - fun copyAsImmutable( - id: UUID = this.id, - item: Item = this.item, - researchPercent: Double = this.researchPercent, - ) : PatternState { - return PatternState(id, item, researchPercent) - } - fun stack(count: Int = 1): ItemStack { return ItemStack(item, count) } - fun serializeNBT(): CompoundTag - fun write(buff: FriendlyByteBuf) { - buff.writeUUID(id) - buff.writeItemType(item) - buff.writeDouble(researchPercent) - } -} - -private fun codec(builder: RecordCodecBuilder.Instance): Products.P3, UUID, Item, Double> { - return builder.group( - UUIDCodec.fieldOf("id").forGetter(IPatternState::id), - ForgeRegistries.ITEMS.codec.fieldOf("item").forGetter(IPatternState::item), - Codec.doubleRange(0.0, 1.0).fieldOf("researchPercent").forGetter(IPatternState::researchPercent) - ) -} - -private fun read(buff: FriendlyByteBuf, mutable: Boolean): IPatternState? { - val id = buff.readUUID() - val item = buff.readItemType() - val researchPercent = buff.readDouble() - - item ?: return null - - if (mutable) { - return MutablePatternState(id, item, researchPercent) - } else { - return PatternState(id, item, researchPercent) - } -} - -data class PatternState( - override val id: UUID, - override val item: Item, - override val researchPercent: Double, -) : IPatternState { - override fun asMutable(): MutablePatternState { - return MutablePatternState(id, item, researchPercent) + buff.writeBinaryJsonWithCodec(CODEC, this) } - override fun asImmutable(): PatternState { - return this - } - - override fun serializeNBT(): CompoundTag { - return CODEC.encode(this, NbtOps.INSTANCE, NbtOps.INSTANCE.empty()).get().map({ it as CompoundTag }, { throw RuntimeException("Failed to serialize PatternState: ${it.message()}") }) + fun serializeNBT(): CompoundTag { + return CODEC.encode(this, NbtOps.INSTANCE, NbtOps.INSTANCE.empty()).get() + .map({ it as CompoundTag }, { throw RuntimeException("Failed to serialize PatternState: ${it.message()}") }) } companion object { @@ -104,48 +42,17 @@ data class PatternState( return CODEC.decode(NbtOps.INSTANCE, tag).result().map { it.first }.orElse(null) } - fun read(buff: FriendlyByteBuf): PatternState? { - return read(buff, false) as PatternState? + fun read(buff: FriendlyByteBuf): PatternState { + return buff.readBinaryJsonWithCodec(CODEC) } val CODEC: Codec by lazy { RecordCodecBuilder.create { - codec(it).apply(it, ::PatternState) - } - } - } -} - -data class MutablePatternState( - override val id: UUID, - override val item: Item, - override var researchPercent: Double, -) : IPatternState { - override fun asMutable(): MutablePatternState { - return this - } - - override fun asImmutable(): PatternState { - return PatternState(id, item, researchPercent) - } - - override fun serializeNBT(): CompoundTag { - return CODEC.encode(this, NbtOps.INSTANCE, NbtOps.INSTANCE.empty()).get().map({ it as CompoundTag }, { throw RuntimeException("Failed to serialize MutablePatternState: ${it.message()}") }) - } - - companion object { - fun deserializeNBT(tag: Tag?): MutablePatternState? { - tag ?: return null - return CODEC.decode(NbtOps.INSTANCE, tag).result().map { it.first }.orElse(null) - } - - fun read(buff: FriendlyByteBuf): MutablePatternState? { - return read(buff, true) as MutablePatternState? - } - - val CODEC: Codec by lazy { - RecordCodecBuilder.create { - codec(it).apply(it, ::MutablePatternState) + it.group( + UUIDCodec.fieldOf("id").forGetter(PatternState::id), + ForgeRegistries.ITEMS.codec.fieldOf("item").forGetter(PatternState::item), + Codec.doubleRange(0.0, 1.0).fieldOf("researchPercent").forGetter(PatternState::researchPercent) + ).apply(it, ::PatternState) } } } 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 c21d4a1ce..e39e56d9d 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 @@ -2,11 +2,10 @@ package ru.dbotthepony.mc.otm.client.screen.matter import net.minecraft.ChatFormatting import net.minecraft.client.gui.GuiGraphics -import net.minecraft.client.gui.components.EditBox import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack -import ru.dbotthepony.mc.otm.capability.matter.IPatternState +import ru.dbotthepony.mc.otm.capability.matter.PatternState import ru.dbotthepony.mc.otm.capability.matter.IReplicationTask import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.render.* @@ -16,7 +15,6 @@ import ru.dbotthepony.mc.otm.client.screen.panels.button.ButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.DeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeBooleanRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeEnumRectangleButtonPanel -import ru.dbotthepony.mc.otm.client.screen.panels.input.EditBoxPanel import ru.dbotthepony.mc.otm.client.screen.panels.input.TextInputPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel @@ -299,7 +297,7 @@ class MatterPanelScreen( return frame } - private fun openPattern(pattern: IPatternState): FramePanel { + private fun openPattern(pattern: PatternState): FramePanel { val frame = FramePanel.padded(this, null, 213f, (ButtonPanel.HEIGHT + 3f) * 4f + 38f, TranslatableComponent("otm.gui.matter_panel.task")) frame.behaveAsWindow() 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 308563fa2..0b3b95b53 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 @@ -7,8 +7,11 @@ import com.google.gson.JsonObject import com.google.gson.JsonParseException import com.google.gson.JsonPrimitive import com.google.gson.JsonSyntaxException +import com.mojang.serialization.Codec +import com.mojang.serialization.JsonOps import io.netty.buffer.ByteBufInputStream import io.netty.buffer.ByteBufOutputStream +import io.netty.handler.codec.DecoderException import io.netty.handler.codec.EncoderException import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.NbtAccounter @@ -273,6 +276,16 @@ fun FriendlyByteBuf.writeBinaryJson(value: JsonElement) { ByteBufOutputStream(this).writeBinaryJson(value) } +fun FriendlyByteBuf.writeBinaryJsonWithCodec(codec: Codec, value: S) { + writeBinaryJson(codec.encode(value, JsonOps.INSTANCE, JsonOps.INSTANCE.empty()) + .get().map({ it }, { throw EncoderException("Failed to encode input data: ${it.message()}") })) +} + +fun FriendlyByteBuf.readBinaryJsonWithCodec(codec: Codec, sizeLimit: NbtAccounter = NbtAccounter(1L shl 18)): S { + return codec.decode(JsonOps.INSTANCE, readBinaryJson(sizeLimit)) + .get().map({ it.first }, { throw DecoderException("Failed to decode data from network: ${it.message()}") }) +} + fun FriendlyByteBuf.readBinaryComponent(): Component { return Component.Serializer.fromJson(readBinaryJson()) ?: throw NullPointerException("Received null component") } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/IMatterGraphListener.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/IMatterGraphListener.kt index 1d2177c8e..462f431e2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/IMatterGraphListener.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/IMatterGraphListener.kt @@ -3,9 +3,9 @@ package ru.dbotthepony.mc.otm.graph.matter import ru.dbotthepony.mc.otm.capability.matter.* interface IMatterGraphListener { - fun onPatternAdded(state: IPatternState) {} - fun onPatternRemoved(state: IPatternState) {} - fun onPatternUpdated(newState: IPatternState, oldState: IPatternState) {} + fun onPatternAdded(state: PatternState) {} + fun onPatternRemoved(state: PatternState) {} + fun onPatternUpdated(newState: PatternState, oldState: PatternState) {} fun onMatterTaskCreated(task: IReplicationTask<*>) {} fun > onMatterTaskUpdated(newState: T, oldState: T) {} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterGraph.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterGraph.kt index 86f0e6b26..08bc17579 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterGraph.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterGraph.kt @@ -170,7 +170,7 @@ class MatterGraph : Abstract6Graph(), IMatterGraphListe return received } - private fun doInsertPattern(state: IPatternState, onlyUpdate: Boolean, simulate: Boolean): PatternInsertStatus { + private fun doInsertPattern(state: PatternState, onlyUpdate: Boolean, simulate: Boolean): PatternInsertStatus { for (node in nodes) { val storage = node.getPatternHandler() @@ -186,7 +186,7 @@ class MatterGraph : Abstract6Graph(), IMatterGraphListe return PatternInsertFailure } - fun insertPattern(state: IPatternState, onlyUpdate: Boolean, simulate: Boolean): PatternInsertStatus { + fun insertPattern(state: PatternState, onlyUpdate: Boolean, simulate: Boolean): PatternInsertStatus { if (onlyUpdate) return doInsertPattern(state, true, simulate) val status = doInsertPattern(state, true, simulate) if (!status.isFailed) return status @@ -201,7 +201,7 @@ class MatterGraph : Abstract6Graph(), IMatterGraphListe return nodes.stream().map { it.getTaskHandler()?.allReplicationTasks }.filterNotNull().flatMap { it } } - val patterns: Stream get() { + val patterns: Stream get() { return nodes.stream().map { it.getPatternHandler()?.patterns }.filterNotNull().flatMap { it } } @@ -233,7 +233,7 @@ class MatterGraph : Abstract6Graph(), IMatterGraphListe return value } - fun getPattern(id: UUID): IPatternState? { + fun getPattern(id: UUID): PatternState? { for (node in nodes) { val storage = node.getPatternHandler() @@ -253,7 +253,7 @@ class MatterGraph : Abstract6Graph(), IMatterGraphListe fun hasPattern(state: PatternState) = getPattern(state.id) != null fun hasPattern(id: UUID) = getPattern(id) != null - fun findPattern(predicate: Predicate): IPatternState? { + fun findPattern(predicate: Predicate): PatternState? { for (node in nodes) { val storage = node.getPatternHandler() @@ -271,7 +271,7 @@ class MatterGraph : Abstract6Graph(), IMatterGraphListe fun findPattern(predicate: Item) = findPattern { it.item == predicate } - fun findPatterns(predicate: Predicate): List { + fun findPatterns(predicate: Predicate): List { return patterns.filter(predicate).toList() } @@ -297,17 +297,17 @@ class MatterGraph : Abstract6Graph(), IMatterGraphListe return nodes.any { it.getTaskHandler()?.notifyTaskCompletion(taskId) == true } } - override fun onPatternAdded(state: IPatternState) { + override fun onPatternAdded(state: PatternState) { for (node in nodes) node.onPatternAdded(state) for (node in listeners) node.onPatternAdded(state) } - override fun onPatternRemoved(state: IPatternState) { + override fun onPatternRemoved(state: PatternState) { for (node in nodes) node.onPatternRemoved(state) for (node in listeners) node.onPatternRemoved(state) } - override fun onPatternUpdated(newState: IPatternState, oldState: IPatternState) { + override fun onPatternUpdated(newState: PatternState, oldState: PatternState) { for (node in nodes) node.onPatternUpdated(newState, oldState) for (node in listeners) node.onPatternUpdated(newState, oldState) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/CreativePatternItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/CreativePatternItem.kt index 8dd5a4659..b07ed0744 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/CreativePatternItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/CreativePatternItem.kt @@ -14,11 +14,10 @@ import net.minecraftforge.common.capabilities.ICapabilityProvider import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.capability.matter.IPatternState +import ru.dbotthepony.mc.otm.capability.matter.PatternState import ru.dbotthepony.mc.otm.capability.matter.IPatternStorage import ru.dbotthepony.mc.otm.capability.matter.PatternInsertFailure import ru.dbotthepony.mc.otm.capability.matter.PatternInsertStatus -import ru.dbotthepony.mc.otm.capability.matter.PatternState import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.getID import ru.dbotthepony.mc.otm.matter.MatterManager @@ -29,7 +28,7 @@ class CreativePatternItem : Item(Properties().rarity(Rarity.EPIC).stacksTo(1)) { private object Patterns : IPatternStorage, ICapabilityProvider { private val resolver = LazyOptional.of { this } - override val patterns: Stream + override val patterns: Stream get() = MatterManager.map.keys.stream().map { PatternState(UUID(34783464838L, 4463458382L + ForgeRegistries.ITEMS.getID(it)), it, 1.0) } override val patternCapacity: Int @@ -43,7 +42,7 @@ class CreativePatternItem : Item(Properties().rarity(Rarity.EPIC).stacksTo(1)) { } override fun insertPattern( - pattern: IPatternState, + pattern: PatternState, onlyUpdate: Boolean, simulate: Boolean ): PatternInsertStatus { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/PatternStorageItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/PatternStorageItem.kt index 0f91e014e..03924bd0a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/PatternStorageItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/PatternStorageItem.kt @@ -108,14 +108,14 @@ class PatternStorageItem : Item { return if (cap == MatteryCapability.PATTERN) resolver.cast() else LazyOptional.empty() } - override val patterns: Stream get() { + override val patterns: Stream get() { return stack.tag?.map("otm_patterns") { it: ListTag -> - it.stream().map { PatternState.deserializeNBT(it) }.filter { it != null } as Stream + it.stream().map { PatternState.deserializeNBT(it) }.filter { it != null } as Stream } ?: Stream.empty() } override fun insertPattern( - pattern: IPatternState, + pattern: PatternState, onlyUpdate: Boolean, simulate: Boolean ): PatternInsertStatus { @@ -128,7 +128,7 @@ class PatternStorageItem : Item { if (simulate) { if (patternCapacity > 0) - return PatternInsertInserted(pattern.asImmutable()) + return PatternInsertInserted(pattern) else return PatternInsertFailure } @@ -148,7 +148,7 @@ class PatternStorageItem : Item { list[i] = pattern.serializeNBT() } - return PatternInsertUpdated(pattern.asImmutable(), state) + return PatternInsertUpdated(pattern, state) } } else { invalidCounter++ @@ -160,7 +160,7 @@ class PatternStorageItem : Item { if (invalidCounter > 0) { if (simulate) - return PatternInsertInserted(pattern.asImmutable()) + return PatternInsertInserted(pattern) for (i in list.indices) { val state = PatternState.deserializeNBT(list.getCompound(i)) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt index 71578aae5..589564d7e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt @@ -49,7 +49,7 @@ class CancelTaskPacket(val id: UUID) : MatteryPacket { } } -class PatternsChangePacket(val isUpdate: Boolean, val patterns: Collection) : MatteryPacket { +class PatternsChangePacket(val isUpdate: Boolean, val patterns: Collection) : MatteryPacket { override fun write(buff: FriendlyByteBuf) { buff.writeBoolean(isUpdate) buff.writeInt(patterns.size) @@ -205,16 +205,16 @@ class MatterPanelMenu @JvmOverloads constructor( val sortingGS = GetterSetter.of(::sorting, changeSorting::input) val isAscendingGS = GetterSetter.of(::isAscending, changeIsAscending::input) - private val actualComparator = Comparator { o1, o2 -> sorting.comparator.compare(o1.item, o2.item) * (if (isAscending) 1 else -1) } + private val actualComparator = Comparator { o1, o2 -> sorting.comparator.compare(o1.item, o2.item) * (if (isAscending) 1 else -1) } private val actualTaskComparator = Comparator> { o1, o2 -> sorting.comparator.compare(o1.item, o2.item) * (if (isAscending) 1 else -1) } - private val patterns = ArrayList() + private val patterns = ArrayList() private val tasks = ArrayList>() - val patternsFiltered = ArrayList() + val patternsFiltered = ArrayList() val tasksFiltered = ArrayList>() - fun networkPatternsUpdated(patterns: Collection) { + fun networkPatternsUpdated(patterns: Collection) { for (pattern in patterns) { val index = this.patterns.indexOfFirst(pattern::matchId) @@ -236,7 +236,7 @@ class MatterPanelMenu @JvmOverloads constructor( } } - fun networkPatternsRemoved(patterns: Collection) { + fun networkPatternsRemoved(patterns: Collection) { for (pattern in patterns) { this.patterns.remove(pattern) } @@ -310,15 +310,15 @@ class MatterPanelMenu @JvmOverloads constructor( MenuNetworkChannel.sendToServer(CancelTaskPacket(id)) } - override fun onPatternAdded(state: IPatternState) { + override fun onPatternAdded(state: PatternState) { sendNetwork(PatternsChangePacket(true, listOf(state))) } - override fun onPatternRemoved(state: IPatternState) { + override fun onPatternRemoved(state: PatternState) { sendNetwork(PatternsChangePacket(false, listOf(state))) } - override fun onPatternUpdated(newState: IPatternState, oldState: IPatternState) { + override fun onPatternUpdated(newState: PatternState, oldState: PatternState) { sendNetwork(PatternsChangePacket(true, listOf(newState))) } From 4638899b20df390cc74e46a4c747b59d62ab14c7 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 26 Jul 2023 11:20:48 +0700 Subject: [PATCH 0855/1199] Make Replication Task be only immutable, network Replication Tasks using codecs --- .../entity/matter/MatterPanelBlockEntity.kt | 4 +- .../matter/MatterReplicatorBlockEntity.kt | 4 +- .../mc/otm/capability/matter/Data.kt | 2 +- .../matter/IReplicationTaskProvider.kt | 14 +- .../otm/capability/matter/ReplicationTask.kt | 187 +++--------------- .../client/screen/matter/MatterPanelScreen.kt | 4 +- .../mc/otm/core/util/FriendlyStreams.kt | 5 + .../otm/graph/matter/IMatterGraphListener.kt | 8 +- .../mc/otm/graph/matter/MatterGraph.kt | 12 +- .../mc/otm/menu/matter/MatterPanelMenu.kt | 43 ++-- 10 files changed, 71 insertions(+), 212 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt index 6663c1747..427dc6b5c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt @@ -179,7 +179,7 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } override fun getTask(id: UUID): ReplicationTask? { - return _tasks[id]?.asImmutable() + return _tasks[id] } fun removeTask(id: UUID) { @@ -192,7 +192,7 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : setChanged() } - fun addTask(state: PatternState, count: Int): IReplicationTask<*> { + fun addTask(state: PatternState, count: Int): ReplicationTask { val task = ReplicationTask(UUID.randomUUID(), Optional.of(state.id), state.item, 0, 0, count) _tasks[task.id] = task diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index 1e42b8a95..ba76baaba 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -83,11 +83,11 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return matter } - override fun onMatterTaskCreated(task: IReplicationTask<*>) { + override fun onMatterTaskCreated(task: ReplicationTask) { jobEventLoops[0].notify(MachineJobEventLoop.IdleReason.OBSERVING) } - override fun > onMatterTaskUpdated(newState: T, oldState: T) { + override fun onMatterTaskUpdated(newState: ReplicationTask, oldState: ReplicationTask) { jobEventLoops[0].notify(MachineJobEventLoop.IdleReason.OBSERVING) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/Data.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/Data.kt index 64b6d75cf..8a52f25e0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/Data.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/Data.kt @@ -21,4 +21,4 @@ class PatternInsertUpdated(new: PatternState, old: PatternState) : PatternInsert class PatternInsertInserted(new: PatternState) : PatternInsertStatus(PatternInsertResult.INSERTED, new, null) @JvmRecord -data class ReplicationTaskAllocation(val task: IReplicationTask<*>, val pattern: PatternState?) +data class ReplicationTaskAllocation(val task: ReplicationTask, val pattern: PatternState?) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IReplicationTaskProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IReplicationTaskProvider.kt index 2fc50bb25..500a9a5e2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IReplicationTaskProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IReplicationTaskProvider.kt @@ -7,19 +7,19 @@ interface IReplicationTaskProvider { /** * It must return new stream each time */ - val replicationTasks: Stream> + val replicationTasks: Stream /** * It must return new stream each time */ - val allReplicationTasks: Stream> + val allReplicationTasks: Stream /** * Allocates (marks as work-in-progress) a task - * by incrementing it's [IReplicationTask.inProgress] by 1 - * and shrinking [IReplicationTask.required] by 1 + * by incrementing it's [ReplicationTask.inProgress] by 1 + * and shrinking [ReplicationTask.required] by 1 * - * If [IReplicationTask.required] == 0, it should not be returned by this method + * If [ReplicationTask.required] == 0, it should not be returned by this method * @param simulate whenever to change internal state * @return MatterTaskAllocation(task, pattern) that should be performed, or null if no work is available */ @@ -38,7 +38,7 @@ interface IReplicationTaskProvider { * @param id uuid of task * @return MatterTask that this capability holds with this id, or null */ - fun getTask(id: UUID): IReplicationTask<*>? { + fun getTask(id: UUID): ReplicationTask? { return allReplicationTasks.filter { it.id == id }.findAny().orElse(null) } @@ -46,4 +46,4 @@ interface IReplicationTaskProvider { * Destroys all tasks this capability contains */ fun dropAllTasks() -} \ No newline at end of file +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/ReplicationTask.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/ReplicationTask.kt index 287726f49..d7682e9f0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/ReplicationTask.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/ReplicationTask.kt @@ -1,59 +1,31 @@ package ru.dbotthepony.mc.otm.capability.matter -import com.mojang.datafixers.Products import com.mojang.serialization.Codec import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.NbtOps import net.minecraft.nbt.Tag import net.minecraft.network.FriendlyByteBuf -import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.Items import net.minecraftforge.registries.ForgeRegistries -import ru.dbotthepony.mc.otm.core.readItemType -import ru.dbotthepony.mc.otm.core.writeItemType +import ru.dbotthepony.mc.otm.core.util.readBinaryJsonWithCodec +import ru.dbotthepony.mc.otm.core.util.writeBinaryJsonWithCodec import ru.dbotthepony.mc.otm.data.UUIDCodec import java.util.Optional import java.util.UUID -sealed interface IReplicationTask> { - val id: UUID - val patternId: Optional - val item: Item - val inProgress: Int - val finished: Int +data class ReplicationTask( + val id: UUID, + val patternId: Optional, + val item: Item, + val inProgress: Int, + val finished: Int, val required: Int - - fun asMutable(): MutableReplicationTask - fun asImmutable(): ReplicationTask - +) { val total get() = inProgress + finished + required - fun copyAsMutable( - id: UUID = this.id, - patternId: Optional = this.patternId, - item: Item = this.item, - inProgress: Int = this.inProgress, - finished: Int = this.finished, - required: Int = this.required, - ): MutableReplicationTask { - return MutableReplicationTask(id, patternId, item, inProgress, finished, required) - } - - fun copyAsImmutable( - id: UUID = this.id, - patternId: Optional = this.patternId, - item: Item = this.item, - inProgress: Int = this.inProgress, - finished: Int = this.finished, - required: Int = this.required, - ): ReplicationTask { - return ReplicationTask(id, patternId, item, inProgress, finished, required) - } - - fun matchId(other: IReplicationTask<*>): Boolean { + fun matchId(other: ReplicationTask): Boolean { return other.id == id } @@ -61,144 +33,41 @@ sealed interface IReplicationTask> { return ItemStack(item, count) } - fun allocate(amount: Int = 1): S - fun finish(amount: Int = 1): S - - fun serializeNBT(): CompoundTag - - fun write(buff: FriendlyByteBuf) { - buff.writeUUID(id) - - buff.writeBoolean(patternId.isPresent) - patternId.ifPresent(buff::writeUUID) - - buff.writeItemType(item) - - buff.writeInt(inProgress) - buff.writeInt(finished) - buff.writeInt(required) - } -} - -private fun > codec(builder: RecordCodecBuilder.Instance): Products.P6, UUID, Optional, Item, Int, Int, Int> { - return builder.group( - UUIDCodec.fieldOf("id").forGetter(IReplicationTask<*>::id), - UUIDCodec.optionalFieldOf("patternId").forGetter(IReplicationTask<*>::patternId), - ForgeRegistries.ITEMS.codec.fieldOf("item").forGetter(IReplicationTask<*>::item), - Codec.intRange(0, Int.MAX_VALUE).fieldOf("inProgress").forGetter(IReplicationTask<*>::inProgress), - Codec.intRange(0, Int.MAX_VALUE).fieldOf("finished").forGetter(IReplicationTask<*>::finished), - Codec.intRange(0, Int.MAX_VALUE).fieldOf("required").forGetter(IReplicationTask<*>::required), - ) -} - -private fun read(buff: FriendlyByteBuf, mutable: Boolean): IReplicationTask<*>? { - val id = buff.readUUID() - val patternId: UUID? = if (buff.readBoolean()) buff.readUUID() else null - val item = buff.readItemType() - val inProgress = buff.readInt() - val finished = buff.readInt() - val required = buff.readInt() - - item ?: return null - - if (mutable) { - return MutableReplicationTask(id, Optional.ofNullable(patternId), item, inProgress, finished, required) - } else { - return ReplicationTask(id, Optional.ofNullable(patternId), item, inProgress, finished, required) - } -} - -data class ReplicationTask( - override val id: UUID, - override val patternId: Optional, - override val item: Item, - override val inProgress: Int, - override val finished: Int, - override val required: Int -) : IReplicationTask { - override fun asMutable(): MutableReplicationTask { - return MutableReplicationTask(id, patternId, item, inProgress, finished, required) - } - - override fun asImmutable(): ReplicationTask { - return this - } - - override fun allocate(amount: Int): ReplicationTask { + fun allocate(amount: Int = 1): ReplicationTask { return ReplicationTask(id, patternId, item, inProgress + amount, finished, required - amount) } - override fun finish(amount: Int): ReplicationTask { + fun finish(amount: Int = 1): ReplicationTask { return ReplicationTask(id, patternId, item, inProgress - amount, finished + amount, required) } - override fun serializeNBT(): CompoundTag { + fun serializeNBT(): CompoundTag { return CODEC.encode(this, NbtOps.INSTANCE, NbtOps.INSTANCE.empty()).get().map({ it as CompoundTag }, { throw RuntimeException("Failed to serialize ReplicationTask: ${it.message()}") }) } + fun write(buff: FriendlyByteBuf) { + buff.writeBinaryJsonWithCodec(CODEC, this) + } + companion object { fun deserializeNBT(nbt: Tag?): ReplicationTask? { - nbt ?: return null - return CODEC.decode(NbtOps.INSTANCE, nbt).result().map { it.first }.orElse(null) + return CODEC.decode(NbtOps.INSTANCE, nbt ?: return null).result().orElse(null)?.first } - fun read(buff: FriendlyByteBuf): ReplicationTask? { - return read(buff, false) as ReplicationTask? + fun read(buff: FriendlyByteBuf): ReplicationTask { + return buff.readBinaryJsonWithCodec(CODEC) } val CODEC: Codec by lazy { RecordCodecBuilder.create { - codec(it).apply(it, ::ReplicationTask) - } - } - } -} - -data class MutableReplicationTask( - override val id: UUID, - override val patternId: Optional, - override val item: Item, - override var inProgress: Int, - override var finished: Int, - override var required: Int -) : IReplicationTask { - override fun asMutable(): MutableReplicationTask { - return this - } - - override fun asImmutable(): ReplicationTask { - return ReplicationTask(id, patternId, item, inProgress, finished, required) - } - - override fun allocate(amount: Int): MutableReplicationTask { - inProgress += amount - finished -= amount - return this - } - - override fun finish(amount: Int): MutableReplicationTask { - finished += amount - inProgress -= amount - return this - } - - override fun serializeNBT(): CompoundTag { - return CODEC.encode(this, NbtOps.INSTANCE, NbtOps.INSTANCE.empty()).get().map({ it as CompoundTag }, { throw RuntimeException("Failed to serialize MutableReplicationTask: ${it.message()}") }) - } - - companion object { - fun deserializeNBT(nbt: Tag?): MutableReplicationTask? { - nbt ?: return null - return CODEC.decode(NbtOps.INSTANCE, nbt).result().map { it.first }.orElse(null) - } - - fun read(buff: FriendlyByteBuf): MutableReplicationTask? { - return read(buff, true) as MutableReplicationTask? - } - - val CODEC: Codec by lazy { - RecordCodecBuilder.create { - codec(it).apply(it, ::MutableReplicationTask) + it.group( + UUIDCodec.fieldOf("id").forGetter(ReplicationTask::id), + UUIDCodec.optionalFieldOf("patternId").forGetter(ReplicationTask::patternId), + ForgeRegistries.ITEMS.codec.fieldOf("item").forGetter(ReplicationTask::item), + Codec.intRange(0, Int.MAX_VALUE).fieldOf("inProgress").forGetter(ReplicationTask::inProgress), + Codec.intRange(0, Int.MAX_VALUE).fieldOf("finished").forGetter(ReplicationTask::finished), + Codec.intRange(0, Int.MAX_VALUE).fieldOf("required").forGetter(ReplicationTask::required), + ).apply(it, ::ReplicationTask) } } } 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 e39e56d9d..c38dc7764 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 @@ -6,7 +6,7 @@ import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.capability.matter.PatternState -import ru.dbotthepony.mc.otm.capability.matter.IReplicationTask +import ru.dbotthepony.mc.otm.capability.matter.ReplicationTask import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.client.screen.MatteryScreen @@ -251,7 +251,7 @@ class MatterPanelScreen( return frame } - private fun openTask(task: IReplicationTask<*>): FramePanel { + private fun openTask(task: ReplicationTask): FramePanel { val frame = FramePanel.padded(this, null, 170f, 20f, TranslatableComponent("otm.gui.matter_panel.task")) frame.behaveAsWindow() 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 0b3b95b53..6b6f332af 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 @@ -294,6 +294,11 @@ fun FriendlyByteBuf.writeBinaryComponent(component: Component) { writeBinaryJson(Component.Serializer.toJsonTree(component)) } +// обратный порядок аргументов у лямбда выражения +fun FriendlyByteBuf.writeCollection(collection: Collection, writer: (T, FriendlyByteBuf) -> Unit) { + writeCollection(collection) { a, b -> writer.invoke(b, a) } +} + fun S.writeCollection(collection: Collection, writer: S.(V) -> Unit) { writeVarIntLE(collection.size) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/IMatterGraphListener.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/IMatterGraphListener.kt index 462f431e2..171668334 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/IMatterGraphListener.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/IMatterGraphListener.kt @@ -7,8 +7,8 @@ interface IMatterGraphListener { fun onPatternRemoved(state: PatternState) {} fun onPatternUpdated(newState: PatternState, oldState: PatternState) {} - fun onMatterTaskCreated(task: IReplicationTask<*>) {} - fun > onMatterTaskUpdated(newState: T, oldState: T) {} - fun onMatterTaskFinished(state: IReplicationTask<*>) {} - fun onMatterTaskRemoved(state: IReplicationTask<*>) {} + fun onMatterTaskCreated(task: ReplicationTask) {} + fun onMatterTaskUpdated(newState: ReplicationTask, oldState: ReplicationTask) {} + fun onMatterTaskFinished(state: ReplicationTask) {} + fun onMatterTaskRemoved(state: ReplicationTask) {} } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterGraph.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterGraph.kt index 08bc17579..2632bb0de 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterGraph.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterGraph.kt @@ -193,11 +193,11 @@ class MatterGraph : Abstract6Graph(), IMatterGraphListe return doInsertPattern(state, false, simulate) } - val tasks: Stream> get() { + val tasks: Stream get() { return nodes.stream().map { it.getTaskHandler()?.replicationTasks }.filterNotNull().flatMap { it } } - val allTasks: Stream> get() { + val allTasks: Stream get() { return nodes.stream().map { it.getTaskHandler()?.allReplicationTasks }.filterNotNull().flatMap { it } } @@ -312,22 +312,22 @@ class MatterGraph : Abstract6Graph(), IMatterGraphListe for (node in listeners) node.onPatternUpdated(newState, oldState) } - override fun onMatterTaskCreated(task: IReplicationTask<*>) { + override fun onMatterTaskCreated(task: ReplicationTask) { for (node in nodes) node.onMatterTaskCreated(task) for (node in listeners) node.onMatterTaskCreated(task) } - override fun > onMatterTaskUpdated(newState: T, oldState: T) { + override fun onMatterTaskUpdated(newState: ReplicationTask, oldState: ReplicationTask) { for (node in nodes) node.onMatterTaskUpdated(newState, oldState) for (node in listeners) node.onMatterTaskUpdated(newState, oldState) } - override fun onMatterTaskFinished(state: IReplicationTask<*>) { + override fun onMatterTaskFinished(state: ReplicationTask) { for (node in nodes) node.onMatterTaskFinished(state) for (node in listeners) node.onMatterTaskFinished(state) } - override fun onMatterTaskRemoved(state: IReplicationTask<*>) { + override fun onMatterTaskRemoved(state: ReplicationTask) { for (node in nodes) node.onMatterTaskRemoved(state) for (node in listeners) node.onMatterTaskRemoved(state) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt index 589564d7e..fb69a94a1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt @@ -18,6 +18,7 @@ import ru.dbotthepony.mc.otm.core.util.BooleanValueCodec import ru.dbotthepony.mc.otm.core.util.DecimalValueCodec import ru.dbotthepony.mc.otm.core.util.ItemSorter import ru.dbotthepony.mc.otm.core.util.codec +import ru.dbotthepony.mc.otm.core.util.writeCollection import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphListener import ru.dbotthepony.mc.otm.graph.matter.MatterGraph import ru.dbotthepony.mc.otm.menu.MatteryMenu @@ -52,11 +53,7 @@ class CancelTaskPacket(val id: UUID) : MatteryPacket { class PatternsChangePacket(val isUpdate: Boolean, val patterns: Collection) : MatteryPacket { override fun write(buff: FriendlyByteBuf) { buff.writeBoolean(isUpdate) - buff.writeInt(patterns.size) - - for (pattern in patterns) { - pattern.write(buff) - } + buff.writeCollection(patterns, PatternState::write) } override fun play(context: Supplier) { @@ -74,23 +71,15 @@ class PatternsChangePacket(val isUpdate: Boolean, val patterns: Collection(size).also { - for (i in 0 until size) it.add(PatternState.read(buff) ?: throw NullPointerException("Unable to read PatternState from network at $i")) }) + return PatternsChangePacket(buff.readBoolean(), buff.readCollection(::ArrayList, PatternState::read)) } } } -class TasksChangePacket(val isUpdate: Boolean, val tasks: Collection>) : MatteryPacket { +class TasksChangePacket(val isUpdate: Boolean, val tasks: Collection) : MatteryPacket { override fun write(buff: FriendlyByteBuf) { buff.writeBoolean(isUpdate) - buff.writeInt(tasks.size) - - for (task in tasks) { - task.write(buff) - } + buff.writeCollection(tasks, ReplicationTask::write) } override fun play(context: Supplier) { @@ -108,11 +97,7 @@ class TasksChangePacket(val isUpdate: Boolean, val tasks: Collection>(size).also { - for (i in 0 until size) it.add(ReplicationTask.read(buff) ?: throw NullPointerException("Unable to read Replication Task from network at $i")) }) + return TasksChangePacket(buff.readBoolean(), buff.readCollection(::ArrayList, ReplicationTask::read)) } } } @@ -142,16 +127,16 @@ class ReplicationRequestPacket(val id: UUID, amount: Int) : MatteryPacket { } } -class MatterPanelMenu @JvmOverloads constructor( +class MatterPanelMenu( p_38852_: Int, inventory: Inventory, tile: MatterPanelBlockEntity? = null ) : MatteryMenu(MMenus.MATTER_PANEL, p_38852_, inventory, tile), IMatterGraphListener { - fun taskUpdated(task: IReplicationTask<*>) { + fun taskUpdated(task: ReplicationTask) { sendNetwork(TasksChangePacket(true, listOf(task))) } - fun taskRemoved(task: IReplicationTask<*>) { + fun taskRemoved(task: ReplicationTask) { sendNetwork(TasksChangePacket(false, listOf(task))) } @@ -206,13 +191,13 @@ class MatterPanelMenu @JvmOverloads constructor( val isAscendingGS = GetterSetter.of(::isAscending, changeIsAscending::input) private val actualComparator = Comparator { o1, o2 -> sorting.comparator.compare(o1.item, o2.item) * (if (isAscending) 1 else -1) } - private val actualTaskComparator = Comparator> { o1, o2 -> sorting.comparator.compare(o1.item, o2.item) * (if (isAscending) 1 else -1) } + private val actualTaskComparator = Comparator { o1, o2 -> sorting.comparator.compare(o1.item, o2.item) * (if (isAscending) 1 else -1) } private val patterns = ArrayList() - private val tasks = ArrayList>() + private val tasks = ArrayList() val patternsFiltered = ArrayList() - val tasksFiltered = ArrayList>() + val tasksFiltered = ArrayList() fun networkPatternsUpdated(patterns: Collection) { for (pattern in patterns) { @@ -242,7 +227,7 @@ class MatterPanelMenu @JvmOverloads constructor( } } - fun networkTasksUpdated(tasks: Collection>) { + fun networkTasksUpdated(tasks: Collection) { for (task in tasks) { val index = this.tasks.indexOfFirst(task::matchId) @@ -264,7 +249,7 @@ class MatterPanelMenu @JvmOverloads constructor( } } - fun networkTasksRemoved(tasks: Collection>) { + fun networkTasksRemoved(tasks: Collection) { for (task in tasks) { val index = this.tasks.indexOfFirst(task::matchId) From f4149b579703bbc2b5c9becf41567cef815e5aa2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 26 Jul 2023 11:21:43 +0700 Subject: [PATCH 0856/1199] Add constructor checks to replication task --- .../dbotthepony/mc/otm/capability/matter/ReplicationTask.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/ReplicationTask.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/ReplicationTask.kt index d7682e9f0..feb080e75 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/ReplicationTask.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/ReplicationTask.kt @@ -23,6 +23,12 @@ data class ReplicationTask( val finished: Int, val required: Int ) { + init { + require(inProgress >= 0) { "Invalid inProgress value: $inProgress"} + require(finished >= 0) { "Invalid finished value: $finished"} + require(required >= 0) { "Invalid required value: $required"} + } + val total get() = inProgress + finished + required fun matchId(other: ReplicationTask): Boolean { From ea42b19e216661c2780ffac694222502b0243094 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 26 Jul 2023 11:27:20 +0700 Subject: [PATCH 0857/1199] Split and move render classes --- .../mc/otm/android/AndroidResearchType.kt | 4 +- .../android/feature/EnderTeleporterFeature.kt | 2 +- .../client/{Ext.kt => ClientExtensions.kt} | 1 - .../dbotthepony/mc/otm/client/MatteryGUI.kt | 2 + .../client/render/{Ext.kt => FontRenderer.kt} | 59 +----------------- .../mc/otm/client/render/RenderExtensions.kt | 60 +++++++++++++++++++ .../mc/otm/client/render/ResearchIcons.kt | 3 + .../mc/otm/client/render/WidgetLocation.kt | 1 + .../mc/otm/client/render/Widgets18.kt | 3 + .../mc/otm/client/render/Widgets8.kt | 1 + .../client/render/blockentity/BankRenderer.kt | 3 +- .../{ => sprites}/AbstractMatterySprite.kt | 7 ++- .../client/render/{ => sprites}/GridAtlas.kt | 2 +- .../render/{ => sprites}/GridInSprite.kt | 2 +- .../render/{ => sprites}/MatteryAtlas.kt | 3 +- .../render/{ => sprites}/MatterySprite.kt | 3 +- .../client/render/{ => sprites}/SpriteType.kt | 4 +- .../StretchingRectangleElement.kt | 2 +- .../render/{ => sprites}/SubMatterySprite.kt | 3 +- .../client/screen/ExoPackInventoryScreen.kt | 2 +- .../otm/client/screen/panels/ColorPicker.kt | 2 +- .../client/screen/panels/EffectListPanel.kt | 3 +- .../screen/panels/EntityRendererPanel.kt | 7 +-- .../mc/otm/client/screen/panels/FramePanel.kt | 1 + .../otm/client/screen/panels/SpritePanel.kt | 2 +- .../client/screen/panels/button/Buttons.kt | 2 +- .../screen/panels/button/CheckBoxPanel.kt | 2 +- .../panels/button/EnumRectangleButtonPanel.kt | 2 - .../LargeBooleanRectangleButtonPanel.kt | 4 +- .../button/LargeRectangleButtonPanel.kt | 2 - .../panels/button/RectangleButtonPanel.kt | 4 -- .../SmallBooleanRectangleButtonPanel.kt | 1 + .../button/SmallRectangleButtonPanel.kt | 3 +- .../screen/panels/slot/InventorySlotPanel.kt | 1 - .../screen/panels/util/BackgroundPanel.kt | 3 +- .../screen/panels/util/HeightControls.kt | 2 +- .../screen/panels/util/ScrollBarConstants.kt | 4 +- .../screen/tech/EssenceStorageScreen.kt | 2 +- .../client/screen/widget/FluidGaugePanel.kt | 4 +- .../mc/otm/compat/cos/CosmeticArmorCompat.kt | 5 +- .../mc/otm/compat/jei/SkinDrawable.kt | 2 +- .../mc/otm/compat/jei/StretchingDrawable.kt | 2 +- 42 files changed, 113 insertions(+), 114 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/{Ext.kt => ClientExtensions.kt} (99%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/render/{Ext.kt => FontRenderer.kt} (80%) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderExtensions.kt rename src/main/kotlin/ru/dbotthepony/mc/otm/client/render/{ => sprites}/AbstractMatterySprite.kt (95%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/render/{ => sprites}/GridAtlas.kt (95%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/render/{ => sprites}/GridInSprite.kt (95%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/render/{ => sprites}/MatteryAtlas.kt (89%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/render/{ => sprites}/MatterySprite.kt (95%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/render/{ => sprites}/SpriteType.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/render/{ => sprites}/StretchingRectangleElement.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/render/{ => sprites}/SubMatterySprite.kt (92%) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt index 592b73257..f4eb7a76a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt @@ -19,8 +19,8 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.level.ItemLike import net.minecraftforge.registries.ForgeRegistries -import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite -import ru.dbotthepony.mc.otm.client.render.SpriteType +import ru.dbotthepony.mc.otm.client.render.sprites.AbstractMatterySprite +import ru.dbotthepony.mc.otm.client.render.sprites.SpriteType import ru.dbotthepony.mc.otm.core.collect.ListSet import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.isActuallyEmpty diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt index e8a417e10..aa8778995 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt @@ -33,7 +33,7 @@ import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.client.render.linesIgnoreZRenderType -import ru.dbotthepony.mc.otm.client.render.sprite +import ru.dbotthepony.mc.otm.client.render.sprites.sprite import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.core.genericPositions import ru.dbotthepony.mc.otm.core.holder diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientExtensions.kt similarity index 99% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/Ext.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientExtensions.kt index 55f05461a..bb55d7bee 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientExtensions.kt @@ -11,7 +11,6 @@ import org.lwjgl.glfw.GLFW.GLFW_CURSOR import ru.dbotthepony.mc.otm.isClient import java.nio.ByteBuffer import java.nio.ByteOrder -import java.nio.DoubleBuffer import java.util.function.BooleanSupplier inline val minecraft: Minecraft get() = Minecraft.getInstance() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index 3dc54f4b9..36533e2f4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -22,6 +22,8 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.render.* +import ru.dbotthepony.mc.otm.client.render.sprites.MatteryAtlas +import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite import ru.dbotthepony.mc.otm.config.ClientConfig import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.math.RGBAColor diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt similarity index 80% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt index f3fdb5aac..4e43bc1bb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt @@ -1,75 +1,18 @@ 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.blaze3d.vertex.VertexSorting import net.minecraft.client.gui.Font import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.renderer.MultiBufferSource -import net.minecraft.core.Vec3i import net.minecraft.network.chat.Component import net.minecraft.util.FormattedCharSequence import org.joml.Matrix4f -import org.joml.Vector3f import ru.dbotthepony.mc.otm.core.FloatSupplier -import ru.dbotthepony.mc.otm.core.math.IAngle import ru.dbotthepony.mc.otm.core.math.RGBAColor -import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.math.component1 import ru.dbotthepony.mc.otm.core.math.component2 import ru.dbotthepony.mc.otm.core.math.component3 -import ru.dbotthepony.mc.otm.core.math.rotateAroundPoint -import ru.dbotthepony.mc.otm.core.math.rotateAroundThis -import ru.dbotthepony.mc.otm.core.math.times -import ru.dbotthepony.mc.otm.core.math.translation -import ru.dbotthepony.mc.otm.core.math.unaryMinus - -val tesselator: Tesselator get() = Tesselator.getInstance() - -fun VertexConsumer.normal(vector: Vector): VertexConsumer = normal(vector.x.toFloat(), vector.y.toFloat(), vector.z.toFloat()) -fun VertexConsumer.vertex(matrix4f: Matrix4f, vector: Vector): VertexConsumer = vertex(matrix4f, vector.x.toFloat(), vector.y.toFloat(), vector.z.toFloat()) -fun VertexConsumer.color(color: RGBAColor?): VertexConsumer { - if (color != null) - color(color.redInt, color.greenInt, color.blueInt, color.alphaInt) - - return this -} - -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()) // TODO: 1.19.3 - -fun PoseStack.rotateAroundPoint(point: Vector, axis: Vector, rotation: Float, isDegrees: Boolean = false) { - val last = last() - last.pose().rotateAroundPoint(point, axis, rotation, isDegrees) - last.normal().rotate(axis.rotateAroundThis(rotation, isDegrees)) -} - -fun PoseStack.rotateAroundPoint(point: Vector, rotation: IAngle) { - val last = last() - last.pose().rotateAroundPoint(point, rotation) - // last.normal().mul(rotation.forward().rotateAroundThis(rotation)) -} - -fun PoseStack.rotateAroundPoint(point: Vector3f, axis: Vector, rotation: Float, isDegrees: Boolean = false) { - val last = last() - last.pose().rotateAroundPoint(point, axis, rotation, isDegrees) - last.normal().rotate(axis.rotateAroundThis(rotation, isDegrees)) -} - -fun PoseStack.rotateAroundPoint(point: Vector3f, rotation: IAngle) { - val last = last() - last.pose().rotateAroundPoint(point, rotation) - // last.normal().mul(rotation.forward().rotateAroundThis(rotation)) -} - -fun PoseStack.translation(): Vector3f { - return last().pose().translation -} - -inline val PoseStack.last: PoseStack.Pose get() = last() -inline val PoseStack.Pose.pose: Matrix4f get() = pose() private val buffer = DynamicBufferSource(vertexSorting = VertexSorting.ORTHOGRAPHIC_Z) private fun buffer() = buffer @@ -262,7 +205,7 @@ private fun Font.drawInternal( if (outlineZ != 0f) { poseStack.translate(0f, 0f, -outlineZ) } - } + } val width = drawInBatch( text, 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 new file mode 100644 index 000000000..1d08afc62 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderExtensions.kt @@ -0,0 +1,60 @@ +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 net.minecraft.core.Vec3i +import org.joml.Matrix4f +import org.joml.Vector3f +import ru.dbotthepony.mc.otm.core.math.IAngle +import ru.dbotthepony.mc.otm.core.math.RGBAColor +import ru.dbotthepony.mc.otm.core.math.Vector +import ru.dbotthepony.mc.otm.core.math.rotateAroundPoint +import ru.dbotthepony.mc.otm.core.math.rotateAroundThis +import ru.dbotthepony.mc.otm.core.math.translation + +val tesselator: Tesselator get() = Tesselator.getInstance() + +fun VertexConsumer.normal(vector: Vector): VertexConsumer = normal(vector.x.toFloat(), vector.y.toFloat(), vector.z.toFloat()) +fun VertexConsumer.vertex(matrix4f: Matrix4f, vector: Vector): VertexConsumer = vertex(matrix4f, vector.x.toFloat(), vector.y.toFloat(), vector.z.toFloat()) +fun VertexConsumer.color(color: RGBAColor?): VertexConsumer { + if (color != null) + color(color.redInt, color.greenInt, color.blueInt, color.alphaInt) + + return this +} + +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()) + +fun PoseStack.rotateAroundPoint(point: Vector, axis: Vector, rotation: Float, isDegrees: Boolean = false) { + val last = last() + last.pose().rotateAroundPoint(point, axis, rotation, isDegrees) + last.normal().rotate(axis.rotateAroundThis(rotation, isDegrees)) +} + +fun PoseStack.rotateAroundPoint(point: Vector, rotation: IAngle) { + val last = last() + last.pose().rotateAroundPoint(point, rotation) + // last.normal().mul(rotation.forward().rotateAroundThis(rotation)) +} + +fun PoseStack.rotateAroundPoint(point: Vector3f, axis: Vector, rotation: Float, isDegrees: Boolean = false) { + val last = last() + last.pose().rotateAroundPoint(point, axis, rotation, isDegrees) + last.normal().rotate(axis.rotateAroundThis(rotation, isDegrees)) +} + +fun PoseStack.rotateAroundPoint(point: Vector3f, rotation: IAngle) { + val last = last() + last.pose().rotateAroundPoint(point, rotation) + // last.normal().mul(rotation.forward().rotateAroundThis(rotation)) +} + +fun PoseStack.translation(): Vector3f { + return last().pose().translation +} + +inline val PoseStack.last: PoseStack.Pose get() = last() +inline val PoseStack.Pose.pose: Matrix4f get() = pose() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt index f043c2c74..1124d674f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt @@ -2,6 +2,9 @@ package ru.dbotthepony.mc.otm.client.render import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.client.render.sprites.AbstractMatterySprite +import ru.dbotthepony.mc.otm.client.render.sprites.GridAtlas +import ru.dbotthepony.mc.otm.client.render.sprites.sprite object ResearchIcons { val ICON_TRANSFER: AbstractMatterySprite diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt index 2588604cf..46e5c5f26 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.client.render import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.client.render.sprites.MatteryAtlas object WidgetLocation { val LARGE_BUTTON = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/large_button.png"), 72f, 18f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt index 93e07d358..e6cea1252 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt @@ -2,6 +2,9 @@ package ru.dbotthepony.mc.otm.client.render import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.client.render.sprites.GridAtlas +import ru.dbotthepony.mc.otm.client.render.sprites.StretchingRectangleElement +import ru.dbotthepony.mc.otm.client.render.sprites.sprite import ru.dbotthepony.mc.otm.core.immutableMap import ru.dbotthepony.mc.otm.core.math.RelativeSide diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt index 3cf7bbf71..44af60e19 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.client.render import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.client.render.sprites.GridAtlas object Widgets8 { val GRID = GridAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets_8.png"), 8f, 8f, columns = 64 / 8, rows = 32 / 8) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt index cd8a147de..29dc62ddb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt @@ -15,7 +15,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterCapacitorBankBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.BatteryBankBlockEntity import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite +import ru.dbotthepony.mc.otm.client.render.sprites.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel @@ -28,7 +28,6 @@ import ru.dbotthepony.mc.otm.core.math.rotate import ru.dbotthepony.mc.otm.core.math.rotateY import ru.dbotthepony.mc.otm.nanoTime import java.util.function.BooleanSupplier -import java.util.function.Supplier import kotlin.math.PI abstract class BankRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/AbstractMatterySprite.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/AbstractMatterySprite.kt index d4ac1afef..90de4157e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/AbstractMatterySprite.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.client.render +package ru.dbotthepony.mc.otm.client.render.sprites import com.google.gson.JsonObject import com.mojang.blaze3d.systems.RenderSystem @@ -13,6 +13,11 @@ import net.minecraft.client.renderer.RenderType import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation import org.lwjgl.opengl.GL11.GL_ALWAYS +import ru.dbotthepony.mc.otm.client.render.IGUIRenderable +import ru.dbotthepony.mc.otm.client.render.IUVCoords +import ru.dbotthepony.mc.otm.client.render.UVWindingOrder +import ru.dbotthepony.mc.otm.client.render.color +import ru.dbotthepony.mc.otm.client.render.renderTexturedRect import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.linearInterpolation import java.util.concurrent.ConcurrentHashMap diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GridAtlas.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/GridAtlas.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GridAtlas.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/GridAtlas.kt index 942fdc287..6d2650488 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GridAtlas.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/GridAtlas.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.client.render +package ru.dbotthepony.mc.otm.client.render.sprites import net.minecraft.resources.ResourceLocation diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GridInSprite.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/GridInSprite.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GridInSprite.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/GridInSprite.kt index ea03082e3..be67b84b2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GridInSprite.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/GridInSprite.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.client.render +package ru.dbotthepony.mc.otm.client.render.sprites @Suppress("unused") data class GridInSprite( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/MatteryAtlas.kt similarity index 89% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/MatteryAtlas.kt index c6f0ab4db..d27706892 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatteryAtlas.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/MatteryAtlas.kt @@ -1,6 +1,7 @@ -package ru.dbotthepony.mc.otm.client.render +package ru.dbotthepony.mc.otm.client.render.sprites import net.minecraft.resources.ResourceLocation +import ru.dbotthepony.mc.otm.client.render.UVWindingOrder fun ResourceLocation.atlas( width: Float, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/MatterySprite.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/MatterySprite.kt index d561b8f4f..719be2139 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/MatterySprite.kt @@ -1,6 +1,7 @@ -package ru.dbotthepony.mc.otm.client.render +package ru.dbotthepony.mc.otm.client.render.sprites import net.minecraft.resources.ResourceLocation +import ru.dbotthepony.mc.otm.client.render.UVWindingOrder fun ResourceLocation.sprite( x: Float, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SpriteType.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/SpriteType.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SpriteType.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/SpriteType.kt index 18149aa40..9fd4b7efd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SpriteType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/SpriteType.kt @@ -1,11 +1,11 @@ -package ru.dbotthepony.mc.otm.client.render +package ru.dbotthepony.mc.otm.client.render.sprites import com.google.gson.JsonObject import com.google.gson.JsonPrimitive import com.google.gson.JsonSyntaxException import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation -import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.core.set enum class SpriteType { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/StretchingRectangleElement.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/StretchingRectangleElement.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/render/StretchingRectangleElement.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/StretchingRectangleElement.kt index 57e2835e6..f777b9f3f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/StretchingRectangleElement.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/StretchingRectangleElement.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.client.render +package ru.dbotthepony.mc.otm.client.render.sprites import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.GuiGraphics diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubMatterySprite.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/SubMatterySprite.kt similarity index 92% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubMatterySprite.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/SubMatterySprite.kt index 4dbdf4087..3ebd1350b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubMatterySprite.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/SubMatterySprite.kt @@ -1,6 +1,7 @@ -package ru.dbotthepony.mc.otm.client.render +package ru.dbotthepony.mc.otm.client.render.sprites import net.minecraft.resources.ResourceLocation +import ru.dbotthepony.mc.otm.client.render.UVWindingOrder class SubMatterySprite( val parent: AbstractMatterySprite, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt index 9dc4547ee..b6a00fb0b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt @@ -9,7 +9,7 @@ import ru.dbotthepony.mc.otm.client.moveMousePosScaled import ru.dbotthepony.mc.otm.client.render.ItemStackIcon import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.client.render.sprite +import ru.dbotthepony.mc.otm.client.render.sprites.sprite import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt index 00e926461..97810e9d7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt @@ -9,7 +9,7 @@ import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.client.playGuiClickSound -import ru.dbotthepony.mc.otm.client.render.MatterySprite +import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.WidgetLocation diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt index f8a3ed691..6fc0d47d8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt @@ -13,10 +13,9 @@ import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.determineTooltipPosition import ru.dbotthepony.mc.otm.client.render.draw -import ru.dbotthepony.mc.otm.client.render.sprite +import ru.dbotthepony.mc.otm.client.render.sprites.sprite import ru.dbotthepony.mc.otm.client.render.render import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel -import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.util.formatTickDuration diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt index a4c1608cf..25fa55509 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt @@ -1,8 +1,5 @@ package ru.dbotthepony.mc.otm.client.screen.panels -import com.mojang.blaze3d.platform.InputConstants -import it.unimi.dsi.fastutil.booleans.BooleanConsumer -import net.minecraft.ChatFormatting import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen @@ -12,7 +9,7 @@ import net.minecraft.world.entity.player.Player import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.render.Widgets8 -import ru.dbotthepony.mc.otm.client.render.sprite +import ru.dbotthepony.mc.otm.client.render.sprites.sprite import ru.dbotthepony.mc.otm.client.screen.ExoPackInventoryScreen import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.button.ButtonPanel @@ -22,9 +19,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.button.SmallRectangleButtonPan import ru.dbotthepony.mc.otm.compat.cos.CosmeticToggleRenderButton import ru.dbotthepony.mc.otm.compat.cos.isCosmeticArmorLoaded import ru.dbotthepony.mc.otm.core.GetterSetter -import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.core.asGetterOnly import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.network.DisableExopackGlowPacket import ru.dbotthepony.mc.otm.network.DisplayExopackPacket diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index 62c0fa997..e921758ff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -10,6 +10,7 @@ import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import org.lwjgl.opengl.GL30 import ru.dbotthepony.mc.otm.client.render.* +import ru.dbotthepony.mc.otm.client.render.sprites.StretchingRectangleElement import ru.dbotthepony.mc.otm.client.screen.panels.button.AbstractButtonPanel import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.RGBAColor diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SpritePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SpritePanel.kt index 836444940..c0c45b58a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SpritePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SpritePanel.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite +import ru.dbotthepony.mc.otm.client.render.sprites.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.UVWindingOrder class SpritePanel( 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 cf0be7ad5..1bbb21a57 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 @@ -13,7 +13,7 @@ import ru.dbotthepony.mc.otm.capability.addUpgradeTooltipLines import ru.dbotthepony.mc.otm.client.isCtrlDown import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite +import ru.dbotthepony.mc.otm.client.render.sprites.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.ItemStackIcon import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.MatteryScreen diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt index 361e04a48..5c5693ae0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite +import ru.dbotthepony.mc.otm.client.render.sprites.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.GetterSetter diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt index 44d1a1d34..9e6ee6522 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt @@ -1,13 +1,11 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import com.mojang.blaze3d.platform.InputConstants -import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.ChatFormatting import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeBooleanRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeBooleanRectangleButtonPanel.kt index f2003f88f..fb36e1996 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeBooleanRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeBooleanRectangleButtonPanel.kt @@ -2,12 +2,10 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component -import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite +import ru.dbotthepony.mc.otm.client.render.sprites.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.GetterSetter -import ru.dbotthepony.mc.otm.menu.input.IPlayerInputWithFeedback open class LargeBooleanRectangleButtonPanel( screen: S, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt index a5662a752..20d14a49f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt @@ -1,9 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button -import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.Widgets18 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/RectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/RectangleButtonPanel.kt index e7388dd61..a89d1436b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/RectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/RectangleButtonPanel.kt @@ -1,13 +1,9 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button -import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.playGuiClickSound -import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel -import ru.dbotthepony.mc.otm.core.TextComponent import java.util.function.IntConsumer @Suppress("PropertyName") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallBooleanRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallBooleanRectangleButtonPanel.kt index 3b64db74c..c9106179d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallBooleanRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallBooleanRectangleButtonPanel.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.render.* +import ru.dbotthepony.mc.otm.client.render.sprites.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.GetterSetter diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallRectangleButtonPanel.kt index 2bb972a17..3b2cab6a9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallRectangleButtonPanel.kt @@ -1,9 +1,8 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button -import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.render.MatterySprite +import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.Widgets8 import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt index 03b4f9517..405909afb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt @@ -6,7 +6,6 @@ import net.minecraft.world.item.Item import ru.dbotthepony.mc.otm.client.isAltDown import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.playGuiClickSound -import ru.dbotthepony.mc.otm.client.render.MatterySprite import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/BackgroundPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/BackgroundPanel.kt index e36c41bf6..62ec2595b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/BackgroundPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/BackgroundPanel.kt @@ -1,9 +1,8 @@ package ru.dbotthepony.mc.otm.client.screen.panels.util -import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.render.StretchingRectangleElement +import ru.dbotthepony.mc.otm.client.render.sprites.StretchingRectangleElement import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/HeightControls.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/HeightControls.kt index 53de032e0..9eeaae48a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/HeightControls.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/HeightControls.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.util import com.mojang.blaze3d.platform.InputConstants import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite +import ru.dbotthepony.mc.otm.client.render.sprites.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.Widgets import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/ScrollBarConstants.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/ScrollBarConstants.kt index 397500379..5309d2144 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/ScrollBarConstants.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/ScrollBarConstants.kt @@ -2,8 +2,8 @@ package ru.dbotthepony.mc.otm.client.screen.panels.util import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.client.render.MatteryAtlas -import ru.dbotthepony.mc.otm.client.render.sprite +import ru.dbotthepony.mc.otm.client.render.sprites.MatteryAtlas +import ru.dbotthepony.mc.otm.client.render.sprites.sprite object ScrollBarConstants { const val WIDTH = 14f diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt index 7605bfde4..a980fdd31 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt @@ -7,7 +7,7 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.client.isShiftDown -import ru.dbotthepony.mc.otm.client.render.MatteryAtlas +import ru.dbotthepony.mc.otm.client.render.sprites.MatteryAtlas import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.Dock 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 ca6bfd7b7..12dee13b7 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 @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.client.screen.widget import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.DefaultVertexFormat -import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.VertexFormat import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen @@ -15,9 +14,8 @@ import org.lwjgl.opengl.GL11 import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.client.render.MatterySprite +import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite import ru.dbotthepony.mc.otm.client.render.tesselator -import ru.dbotthepony.mc.otm.client.render.vertex 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/cos/CosmeticArmorCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt index 2eb86f7d1..d21277685 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.compat.cos import com.mojang.blaze3d.platform.InputConstants -import com.mojang.blaze3d.vertex.PoseStack import lain.mods.cos.impl.ModObjects import lain.mods.cos.impl.client.PlayerRenderHandler import lain.mods.cos.impl.client.gui.GuiCosArmorInventory @@ -18,8 +17,8 @@ import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack import net.minecraftforge.fml.ModList import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.client.render.MatterySprite -import ru.dbotthepony.mc.otm.client.render.sprite +import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite +import ru.dbotthepony.mc.otm.client.render.sprites.sprite import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.button.RectangleButtonPanel import ru.dbotthepony.mc.otm.compat.cos.CosmeticToggleButton.Companion.BUTTON_ACTIVE diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/SkinDrawable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/SkinDrawable.kt index ff81b073e..6ac46e51f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/SkinDrawable.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/SkinDrawable.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.compat.jei import mezz.jei.api.gui.drawable.IDrawable import net.minecraft.client.gui.GuiGraphics -import ru.dbotthepony.mc.otm.client.render.MatterySprite +import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite class SkinDrawable(val element: MatterySprite) : IDrawable { override fun getWidth(): Int { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/StretchingDrawable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/StretchingDrawable.kt index 7d47e2454..72c2c96eb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/StretchingDrawable.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/StretchingDrawable.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.compat.jei import mezz.jei.api.gui.drawable.IDrawable import net.minecraft.client.gui.GuiGraphics -import ru.dbotthepony.mc.otm.client.render.StretchingRectangleElement +import ru.dbotthepony.mc.otm.client.render.sprites.StretchingRectangleElement class StretchingDrawable(val element: StretchingRectangleElement, val rectWidth: Int, val rectHeight: Int) : IDrawable { override fun getWidth(): Int { From 03403eb54dca09eb3b57761e27f84f2640d81bcc Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 26 Jul 2023 11:30:49 +0700 Subject: [PATCH 0858/1199] Split FriendlyStreams --- .../mc/otm/core/util/BinaryJson.kt | 129 ++++++++++++++ .../mc/otm/core/util/ByteBufExtensions.kt | 43 +++++ .../mc/otm/core/util/FriendlyStreams.kt | 161 ------------------ 3 files changed, 172 insertions(+), 161 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/util/BinaryJson.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ByteBufExtensions.kt 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 new file mode 100644 index 000000000..04c27ee5e --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/BinaryJson.kt @@ -0,0 +1,129 @@ +package ru.dbotthepony.mc.otm.core.util + +import com.google.gson.JsonArray +import com.google.gson.JsonElement +import com.google.gson.JsonNull +import com.google.gson.JsonObject +import com.google.gson.JsonParseException +import com.google.gson.JsonPrimitive +import com.google.gson.JsonSyntaxException +import net.minecraft.nbt.NbtAccounter +import java.io.InputStream +import java.io.OutputStream + +private const val TYPE_NULL = 0x01 +private const val TYPE_DOUBLE = 0x02 +private const val TYPE_BOOLEAN = 0x03 +private const val TYPE_INT = 0x04 +private const val TYPE_STRING = 0x05 +private const val TYPE_ARRAY = 0x06 +private const val TYPE_OBJECT = 0x07 + +/** + * Writes binary json to stream in Starbound Object Notation format + * + * just copy pasted this code from my another project because i was lazy + */ +fun OutputStream.writeBinaryJson(element: JsonElement) { + if (element is JsonObject) { + write(TYPE_OBJECT) + writeVarIntLE(element.size()) + + for ((k, v) in element.entrySet()) { + writeBinaryString(k) + writeBinaryJson(v) + } + } else if (element is JsonArray) { + write(TYPE_ARRAY) + writeVarIntLE(element.size()) + + for (v in element) { + writeBinaryJson(v) + } + } else if (element is JsonPrimitive) { + if (element.isNumber) { + val num = element.asNumber + + if (num is Int || num is Long || num is Short || num is Byte) { + write(TYPE_INT) + writeVarLongLE(num.toLong()) + } else if (num is Float || num is Double) { + write(TYPE_DOUBLE) + writeDouble(num.toDouble()) + } else { + throw IllegalArgumentException("Unknown number type: ${num::class.qualifiedName}") + } + } else if (element.isString) { + write(TYPE_STRING) + writeBinaryString(element.asString) + } else if (element.isBoolean) { + write(TYPE_BOOLEAN) + write(if (element.asBoolean) 1 else 0) + } else { + write(TYPE_NULL) + } + } else if (element is JsonNull) { + write(TYPE_NULL) + } else { + throw IllegalArgumentException("Unknown element type: ${element::class.qualifiedName}") + } +} + +/** + * Reads binary json from stream in Starbound Object Notation format + * + * just copy pasted this code from my another project because i was lazy + */ +fun InputStream.readBinaryJson(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 KiB */)): JsonElement { + sizeLimit.accountBytes(1L) + + return when (val id = read()) { + TYPE_NULL -> JsonNull.INSTANCE + TYPE_DOUBLE -> { + sizeLimit.accountBytes(8L) + JsonPrimitive(readDouble()) + } + TYPE_BOOLEAN -> { + sizeLimit.accountBytes(1L) + JsonPrimitive(read() > 1) + } + TYPE_INT -> JsonPrimitive(readVarLongLE(sizeLimit)) + TYPE_STRING -> JsonPrimitive(readBinaryString(sizeLimit)) + TYPE_ARRAY -> { + val values = readVarIntLE(sizeLimit) + + if (values == 0) return JsonArray() + if (values < 0) throw JsonSyntaxException("Tried to read json array with $values elements in it") + + val build = JsonArray(values) + for (i in 0 until values) build.add(readBinaryJson(sizeLimit)) + return build + } + TYPE_OBJECT -> { + val values = readVarIntLE(sizeLimit) + if (values == 0) return JsonObject() + if (values < 0) throw JsonSyntaxException("Tried to read json object with $values elements in it") + + val build = JsonObject() + + for (i in 0 until values) { + val key: String + + try { + key = readBinaryString(sizeLimit) + } catch(err: Throwable) { + throw JsonSyntaxException("Reading json object at $i", err) + } + + try { + build.add(key, readBinaryJson(sizeLimit)) + } catch(err: Throwable) { + throw JsonSyntaxException("Reading json object at $i with name $key", err) + } + } + + return build + } + else -> throw JsonParseException("Unknown element type $id") + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ByteBufExtensions.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ByteBufExtensions.kt new file mode 100644 index 000000000..5de89cfe1 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ByteBufExtensions.kt @@ -0,0 +1,43 @@ +package ru.dbotthepony.mc.otm.core.util + +import com.google.gson.JsonElement +import com.mojang.serialization.Codec +import com.mojang.serialization.JsonOps +import io.netty.buffer.ByteBufInputStream +import io.netty.buffer.ByteBufOutputStream +import io.netty.handler.codec.DecoderException +import io.netty.handler.codec.EncoderException +import net.minecraft.nbt.NbtAccounter +import net.minecraft.network.FriendlyByteBuf +import net.minecraft.network.chat.Component + +fun FriendlyByteBuf.readBinaryJson(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18)): JsonElement { + return ByteBufInputStream(this).readBinaryJson(sizeLimit) +} + +fun FriendlyByteBuf.writeBinaryJson(value: JsonElement) { + ByteBufOutputStream(this).writeBinaryJson(value) +} + +fun FriendlyByteBuf.writeBinaryJsonWithCodec(codec: Codec, value: S) { + writeBinaryJson(codec.encode(value, JsonOps.INSTANCE, JsonOps.INSTANCE.empty()) + .get().map({ it }, { throw EncoderException("Failed to encode input data: ${it.message()}") })) +} + +fun FriendlyByteBuf.readBinaryJsonWithCodec(codec: Codec, sizeLimit: NbtAccounter = NbtAccounter(1L shl 18)): S { + return codec.decode(JsonOps.INSTANCE, readBinaryJson(sizeLimit)) + .get().map({ it.first }, { throw DecoderException("Failed to decode data from network: ${it.message()}") }) +} + +fun FriendlyByteBuf.readBinaryComponent(): Component { + return Component.Serializer.fromJson(readBinaryJson()) ?: throw NullPointerException("Received null component") +} + +fun FriendlyByteBuf.writeBinaryComponent(component: Component) { + writeBinaryJson(Component.Serializer.toJsonTree(component)) +} + +// обратный порядок аргументов у лямбда выражения +fun FriendlyByteBuf.writeCollection(collection: Collection, writer: (T, FriendlyByteBuf) -> Unit) { + writeCollection(collection) { a, b -> writer.invoke(b, a) } +} 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 6b6f332af..e86462576 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 @@ -1,22 +1,9 @@ package ru.dbotthepony.mc.otm.core.util -import com.google.gson.JsonArray -import com.google.gson.JsonElement -import com.google.gson.JsonNull -import com.google.gson.JsonObject -import com.google.gson.JsonParseException -import com.google.gson.JsonPrimitive -import com.google.gson.JsonSyntaxException -import com.mojang.serialization.Codec -import com.mojang.serialization.JsonOps -import io.netty.buffer.ByteBufInputStream -import io.netty.buffer.ByteBufOutputStream -import io.netty.handler.codec.DecoderException import io.netty.handler.codec.EncoderException import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.NbtAccounter import net.minecraft.nbt.NbtIo -import net.minecraft.network.FriendlyByteBuf import net.minecraft.network.chat.Component import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack @@ -143,123 +130,6 @@ fun InputStream.readBigDecimal(sizeLimit: NbtAccounter = NbtAccounter(512L)): Bi return BigDecimal(BigInteger(bytes), scale) } -private const val TYPE_NULL = 0x01 -private const val TYPE_DOUBLE = 0x02 -private const val TYPE_BOOLEAN = 0x03 -private const val TYPE_INT = 0x04 -private const val TYPE_STRING = 0x05 -private const val TYPE_ARRAY = 0x06 -private const val TYPE_OBJECT = 0x07 - -/** - * Writes binary json to stream in Starbound Object Notation format - * - * just copy pasted this code from my another project because i was lazy - */ -fun OutputStream.writeBinaryJson(element: JsonElement) { - if (element is JsonObject) { - write(TYPE_OBJECT) - writeVarIntLE(element.size()) - - for ((k, v) in element.entrySet()) { - writeBinaryString(k) - writeBinaryJson(v) - } - } else if (element is JsonArray) { - write(TYPE_ARRAY) - writeVarIntLE(element.size()) - - for (v in element) { - writeBinaryJson(v) - } - } else if (element is JsonPrimitive) { - if (element.isNumber) { - val num = element.asNumber - - if (num is Int || num is Long || num is Short || num is Byte) { - write(TYPE_INT) - writeVarLongLE(num.toLong()) - } else if (num is Float || num is Double) { - write(TYPE_DOUBLE) - writeDouble(num.toDouble()) - } else { - throw IllegalArgumentException("Unknown number type: ${num::class.qualifiedName}") - } - } else if (element.isString) { - write(TYPE_STRING) - writeBinaryString(element.asString) - } else if (element.isBoolean) { - write(TYPE_BOOLEAN) - write(if (element.asBoolean) 1 else 0) - } else { - write(TYPE_NULL) - } - } else if (element is JsonNull) { - write(TYPE_NULL) - } else { - throw IllegalArgumentException("Unknown element type: ${element::class.qualifiedName}") - } -} - -/** - * Reads binary json from stream in Starbound Object Notation format - * - * just copy pasted this code from my another project because i was lazy - */ -fun InputStream.readBinaryJson(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 KiB */)): JsonElement { - sizeLimit.accountBytes(1L) - - return when (val id = read()) { - TYPE_NULL -> JsonNull.INSTANCE - TYPE_DOUBLE -> { - sizeLimit.accountBytes(8L) - JsonPrimitive(readDouble()) - } - TYPE_BOOLEAN -> { - sizeLimit.accountBytes(1L) - JsonPrimitive(read() > 1) - } - TYPE_INT -> JsonPrimitive(readVarLongLE(sizeLimit)) - TYPE_STRING -> JsonPrimitive(readBinaryString(sizeLimit)) - TYPE_ARRAY -> { - val values = readVarIntLE(sizeLimit) - - if (values == 0) return JsonArray() - if (values < 0) throw JsonSyntaxException("Tried to read json array with $values elements in it") - - val build = JsonArray(values) - for (i in 0 until values) build.add(readBinaryJson(sizeLimit)) - return build - } - TYPE_OBJECT -> { - val values = readVarIntLE(sizeLimit) - if (values == 0) return JsonObject() - if (values < 0) throw JsonSyntaxException("Tried to read json object with $values elements in it") - - val build = JsonObject() - - for (i in 0 until values) { - val key: String - - try { - key = readBinaryString(sizeLimit) - } catch(err: Throwable) { - throw JsonSyntaxException("Reading json object at $i", err) - } - - try { - build.add(key, readBinaryJson(sizeLimit)) - } catch(err: Throwable) { - throw JsonSyntaxException("Reading json object at $i with name $key", err) - } - } - - return build - } - else -> throw JsonParseException("Unknown element type $id") - } -} - fun InputStream.readBinaryComponent(): Component? { return Component.Serializer.fromJson(readBinaryJson()) } @@ -268,37 +138,6 @@ fun OutputStream.writeBinaryComponent(component: Component) { writeBinaryJson(Component.Serializer.toJsonTree(component)) } -fun FriendlyByteBuf.readBinaryJson(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18)): JsonElement { - return ByteBufInputStream(this).readBinaryJson(sizeLimit) -} - -fun FriendlyByteBuf.writeBinaryJson(value: JsonElement) { - ByteBufOutputStream(this).writeBinaryJson(value) -} - -fun FriendlyByteBuf.writeBinaryJsonWithCodec(codec: Codec, value: S) { - writeBinaryJson(codec.encode(value, JsonOps.INSTANCE, JsonOps.INSTANCE.empty()) - .get().map({ it }, { throw EncoderException("Failed to encode input data: ${it.message()}") })) -} - -fun FriendlyByteBuf.readBinaryJsonWithCodec(codec: Codec, sizeLimit: NbtAccounter = NbtAccounter(1L shl 18)): S { - return codec.decode(JsonOps.INSTANCE, readBinaryJson(sizeLimit)) - .get().map({ it.first }, { throw DecoderException("Failed to decode data from network: ${it.message()}") }) -} - -fun FriendlyByteBuf.readBinaryComponent(): Component { - return Component.Serializer.fromJson(readBinaryJson()) ?: throw NullPointerException("Received null component") -} - -fun FriendlyByteBuf.writeBinaryComponent(component: Component) { - writeBinaryJson(Component.Serializer.toJsonTree(component)) -} - -// обратный порядок аргументов у лямбда выражения -fun FriendlyByteBuf.writeCollection(collection: Collection, writer: (T, FriendlyByteBuf) -> Unit) { - writeCollection(collection) { a, b -> writer.invoke(b, a) } -} - fun S.writeCollection(collection: Collection, writer: S.(V) -> Unit) { writeVarIntLE(collection.size) From 2489266a403ac6e180deadbdd62e328dfa57f215 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 26 Jul 2023 11:31:23 +0700 Subject: [PATCH 0859/1199] Rename DataStreams into appropriate StreamCodecs --- .../mc/otm/core/util/{DataStreams.kt => StreamCodecs.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/core/util/{DataStreams.kt => StreamCodecs.kt} (100%) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt similarity index 100% rename from src/main/kotlin/ru/dbotthepony/mc/otm/core/util/DataStreams.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt From b1eb99198adf53d3f207cc51d2dcb2acaa548c55 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 26 Jul 2023 11:31:52 +0700 Subject: [PATCH 0860/1199] Remove unused read/write type --- .../mc/otm/core/util/StreamCodecs.kt | 70 ------------------- 1 file changed, 70 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt index d08146816..718a4137d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt @@ -365,73 +365,3 @@ fun OutputStream.writeBinaryString(input: String) { writeVarIntLE(bytes.size) write(bytes) } - -private data class IndexedStreamCodec( - val condition: Predicate, - val id: Int, - val codec: IStreamCodec -) { - fun read(stream: DataInputStream, sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 KiB */)): T { - return codec.read(stream, sizeLimit) - } - - fun write(stream: DataOutputStream, value: Any?) { - codec.write(stream, value as T) - } -} - -private inline fun IndexedStreamCodec(id: Int, codec: StreamCodec): IndexedStreamCodec { - return IndexedStreamCodec({ it is T }, id, codec) -} - -private val codecs: List> = com.google.common.collect.ImmutableList.builder>().let { - var codecID = 0 - - it.add(IndexedStreamCodec({ it == null }, codecID++, NullValueCodec)) - - it.add(IndexedStreamCodec(codecID++, BooleanValueCodec)) - it.add(IndexedStreamCodec(codecID++, ByteValueCodec)) - it.add(IndexedStreamCodec(codecID++, ShortValueCodec)) - it.add(IndexedStreamCodec(codecID++, VarIntValueCodec)) - it.add(IndexedStreamCodec(codecID++, VarLongValueCodec)) - it.add(IndexedStreamCodec(codecID++, FloatValueCodec)) - it.add(IndexedStreamCodec(codecID++, DoubleValueCodec)) - it.add(IndexedStreamCodec(codecID++, ItemStackValueCodec)) - it.add(IndexedStreamCodec(codecID++, DecimalValueCodec)) - it.add(IndexedStreamCodec(codecID++, BigDecimalValueCodec)) - it.add(IndexedStreamCodec(codecID++, UUIDValueCodec)) - it.add(IndexedStreamCodec(codecID++, BinaryStringCodec)) - - it.build() -} - -class NotSerializableValueException(message: String) : Exception(message) - -/** - * Write arbitrary data to this stream, in exploit-free way - */ -fun DataOutputStream.writeType(value: Any?) { - for (codec in codecs) { - if (codec.condition.test(value)) { - write(codec.id) - codec.write(this, value) - return - } - } - - throw NotSerializableValueException("Value $value <${value?.let { it::class.qualifiedName }}> can not be serialized") -} - -/** - * Read arbitrary data from this stream, in exploit-free way - */ -fun DataInputStream.readType(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 KiB */)): Any? { - sizeLimit.accountBytes(1L) - val id = read() - - if (id >= codecs.size) { - throw IndexOutOfBoundsException("No codec for network type $id") - } - - return codecs[id].read(this, sizeLimit) -} From 7c2d446563cf56f3002ad16690b352a6b5d55fbf Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 26 Jul 2023 11:32:48 +0700 Subject: [PATCH 0861/1199] Move stream extensions from stream codecs to friendly streams --- .../mc/otm/core/util/FriendlyStreams.kt | 169 ++++++++++++++++++ .../mc/otm/core/util/StreamCodecs.kt | 168 ----------------- 2 files changed, 169 insertions(+), 168 deletions(-) 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 e86462576..246401c95 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 @@ -14,6 +14,7 @@ import net.minecraftforge.registries.ForgeRegistry import java.io.* import java.math.BigDecimal import java.math.BigInteger +import kotlin.math.absoluteValue // But seriously, Mojang, why would you need to derive from ByteBuf directly, when you can implement // your own InputStream and OutputStream, since ByteBuf is meant to be operated on most time like a stream anyway? @@ -158,3 +159,171 @@ fun > S.readCollection(reader: S.() } fun S.readCollection(reader: S.() -> V) = readCollection(reader, ::ArrayList) + +fun OutputStream.writeInt(value: Int) { + if (this is DataOutput) { + writeInt(value) + return + } + + write(value ushr 24) + write(value ushr 16) + write(value ushr 8) + write(value) +} + +fun InputStream.readInt(): Int { + if (this is DataInput) { + return readInt() + } + + return (read() shl 24) or (read() shl 16) or (read() shl 8) or read() +} + +fun OutputStream.writeLong(value: Long) { + if (this is DataOutput) { + writeLong(value) + return + } + + write((value ushr 48).toInt()) + write((value ushr 40).toInt()) + write((value ushr 32).toInt()) + write((value ushr 24).toInt()) + write((value ushr 16).toInt()) + write((value ushr 8).toInt()) + write(value.toInt()) +} + +fun InputStream.readLong(): Long { + if (this is DataInput) { + return readLong() + } + + return (read().toLong() shl 48) or + (read().toLong() shl 40) or + (read().toLong() shl 32) or + (read().toLong() shl 24) or + (read().toLong() shl 16) or + (read().toLong() shl 8) or + read().toLong() +} + +fun OutputStream.writeFloat(value: Float) = writeInt(value.toBits()) +fun InputStream.readFloat() = Float.fromBits(readInt()) +fun OutputStream.writeDouble(value: Double) = writeLong(value.toBits()) +fun InputStream.readDouble() = Double.fromBits(readLong()) + +fun InputStream.readVarIntLE(sizeLimit: NbtAccounter? = null): Int { + sizeLimit?.accountBytes(1L) + val readFirst = read() + + if (readFirst < 0) { + throw NoSuchElementException("Reached end of stream") + } + + if (readFirst and 64 == 0) { + return if (readFirst and 128 != 0) -(readFirst and 63) else readFirst and 63 + } + + var result = 0 + var nextBit = readFirst and 64 + var read = readFirst and 63 + var i = 0 + + while (nextBit != 0) { + result = result or (read shl i) + sizeLimit?.accountBytes(1L) + read = read() + + if (read < 0) { + throw NoSuchElementException("Reached end of stream") + } + + nextBit = read and 128 + read = read and 127 + + if (i == 0) + i = 6 + else + i += 7 + } + + result = result or (read shl i) + return if (readFirst and 128 != 0) -result else result +} + +fun OutputStream.writeVarIntLE(value: Int) { + write((if (value < 0) 128 else 0) or (if (value in -63 .. 63) 0 else 64) or (value.absoluteValue and 63)) + var written = value.absoluteValue ushr 6 + + while (written != 0) { + write((written and 127) or (if (written >= 128) 128 else 0)) + written = written ushr 7 + } +} + +fun InputStream.readVarLongLE(sizeLimit: NbtAccounter? = null): Long { + sizeLimit?.accountBytes(1L) + + val readFirst = read() + + if (readFirst < 0) { + throw NoSuchElementException("Reached end of stream") + } + + if (readFirst and 64 == 0) { + return if (readFirst and 128 != 0) -(readFirst and 63).toLong() else (readFirst and 63).toLong() + } + + var result = 0L + var nextBit = readFirst and 64 + var read = readFirst and 63 + var i = 0 + + while (nextBit != 0) { + result = result or (read shl i).toLong() + sizeLimit?.accountBytes(1L) + read = read() + + if (read < 0) { + throw NoSuchElementException("Reached end of stream") + } + + nextBit = read and 128 + read = read and 127 + + if (i == 0) + i = 6 + else + i += 7 + } + + result = result or (read shl i).toLong() + return if (readFirst and 128 != 0) -result else result +} + +fun OutputStream.writeVarLongLE(value: Long) { + write((if (value < 0L) 128 else 0) or (if (value in -63 .. 63) 0 else 64) or (value.absoluteValue and 63).toInt()) + var written = value.absoluteValue ushr 6 + + while (written != 0L) { + write((written and 127).toInt() or (if (written >= 128) 128 else 0)) + written = written ushr 7 + } +} + +fun InputStream.readBinaryString(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 KiB */)): String { + val size = readVarIntLE() + require(size >= 0) { "Negative payload size: $size" } + sizeLimit.accountBytes(size.toLong()) + val bytes = ByteArray(size) + read(bytes) + return bytes.decodeToString() +} + +fun OutputStream.writeBinaryString(input: String) { + val bytes = input.encodeToByteArray() + writeVarIntLE(bytes.size) + write(bytes) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt index 718a4137d..5b15f435d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt @@ -197,171 +197,3 @@ class EnumValueCodec>(clazz: Class) : IStreamCodec, Codec< fun > Class.codec() = EnumValueCodec(this) fun > KClass.codec() = EnumValueCodec(this.java) - -fun OutputStream.writeInt(value: Int) { - if (this is DataOutput) { - writeInt(value) - return - } - - write(value ushr 24) - write(value ushr 16) - write(value ushr 8) - write(value) -} - -fun InputStream.readInt(): Int { - if (this is DataInput) { - return readInt() - } - - return (read() shl 24) or (read() shl 16) or (read() shl 8) or read() -} - -fun OutputStream.writeLong(value: Long) { - if (this is DataOutput) { - writeLong(value) - return - } - - write((value ushr 48).toInt()) - write((value ushr 40).toInt()) - write((value ushr 32).toInt()) - write((value ushr 24).toInt()) - write((value ushr 16).toInt()) - write((value ushr 8).toInt()) - write(value.toInt()) -} - -fun InputStream.readLong(): Long { - if (this is DataInput) { - return readLong() - } - - return (read().toLong() shl 48) or - (read().toLong() shl 40) or - (read().toLong() shl 32) or - (read().toLong() shl 24) or - (read().toLong() shl 16) or - (read().toLong() shl 8) or - read().toLong() -} - -fun OutputStream.writeFloat(value: Float) = writeInt(value.toBits()) -fun InputStream.readFloat() = Float.fromBits(readInt()) -fun OutputStream.writeDouble(value: Double) = writeLong(value.toBits()) -fun InputStream.readDouble() = Double.fromBits(readLong()) - -fun InputStream.readVarIntLE(sizeLimit: NbtAccounter? = null): Int { - sizeLimit?.accountBytes(1L) - val readFirst = read() - - if (readFirst < 0) { - throw NoSuchElementException("Reached end of stream") - } - - if (readFirst and 64 == 0) { - return if (readFirst and 128 != 0) -(readFirst and 63) else readFirst and 63 - } - - var result = 0 - var nextBit = readFirst and 64 - var read = readFirst and 63 - var i = 0 - - while (nextBit != 0) { - result = result or (read shl i) - sizeLimit?.accountBytes(1L) - read = read() - - if (read < 0) { - throw NoSuchElementException("Reached end of stream") - } - - nextBit = read and 128 - read = read and 127 - - if (i == 0) - i = 6 - else - i += 7 - } - - result = result or (read shl i) - return if (readFirst and 128 != 0) -result else result -} - -fun OutputStream.writeVarIntLE(value: Int) { - write((if (value < 0) 128 else 0) or (if (value in -63 .. 63) 0 else 64) or (value.absoluteValue and 63)) - var written = value.absoluteValue ushr 6 - - while (written != 0) { - write((written and 127) or (if (written >= 128) 128 else 0)) - written = written ushr 7 - } -} - -fun InputStream.readVarLongLE(sizeLimit: NbtAccounter? = null): Long { - sizeLimit?.accountBytes(1L) - - val readFirst = read() - - if (readFirst < 0) { - throw NoSuchElementException("Reached end of stream") - } - - if (readFirst and 64 == 0) { - return if (readFirst and 128 != 0) -(readFirst and 63).toLong() else (readFirst and 63).toLong() - } - - var result = 0L - var nextBit = readFirst and 64 - var read = readFirst and 63 - var i = 0 - - while (nextBit != 0) { - result = result or (read shl i).toLong() - sizeLimit?.accountBytes(1L) - read = read() - - if (read < 0) { - throw NoSuchElementException("Reached end of stream") - } - - nextBit = read and 128 - read = read and 127 - - if (i == 0) - i = 6 - else - i += 7 - } - - result = result or (read shl i).toLong() - return if (readFirst and 128 != 0) -result else result -} - -fun OutputStream.writeVarLongLE(value: Long) { - write((if (value < 0L) 128 else 0) or (if (value in -63 .. 63) 0 else 64) or (value.absoluteValue and 63).toInt()) - var written = value.absoluteValue ushr 6 - - while (written != 0L) { - write((written and 127).toInt() or (if (written >= 128) 128 else 0)) - written = written ushr 7 - } -} - -fun InputStream.readBinaryString(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 KiB */)): String { - val size = readVarIntLE() - require(size >= 0) { "Negative payload size: $size" } - sizeLimit.accountBytes(size.toLong()) - val bytes = ByteArray(size) - read(bytes) - return bytes.decodeToString() -} - -fun OutputStream.writeBinaryString(input: String) { - val bytes = input.encodeToByteArray() - writeVarIntLE(bytes.size) - write(bytes) -} From 1e2611fd2e026057bf06a1b0db9b8ce648c1d890 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 26 Jul 2023 12:08:09 +0700 Subject: [PATCH 0862/1199] Improve binary json --- .../mc/otm/core/util/BinaryJson.kt | 285 ++++++++++++------ 1 file changed, 188 insertions(+), 97 deletions(-) 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 04c27ee5e..ba25f9594 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 @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.core.util +import com.google.common.collect.ImmutableList import com.google.gson.JsonArray import com.google.gson.JsonElement import com.google.gson.JsonNull @@ -8,16 +9,186 @@ import com.google.gson.JsonParseException import com.google.gson.JsonPrimitive import com.google.gson.JsonSyntaxException import net.minecraft.nbt.NbtAccounter +import ru.dbotthepony.mc.otm.core.collect.stream import java.io.InputStream import java.io.OutputStream +import java.util.function.Predicate -private const val TYPE_NULL = 0x01 -private const val TYPE_DOUBLE = 0x02 -private const val TYPE_BOOLEAN = 0x03 -private const val TYPE_INT = 0x04 -private const val TYPE_STRING = 0x05 -private const val TYPE_ARRAY = 0x06 -private const val TYPE_OBJECT = 0x07 +private enum class BinaryElementType(private val predicate: Predicate) : Predicate by predicate { + NULL({ it is JsonNull }) { + override fun write(stream: OutputStream, element: JsonElement) { + } + + override fun read(stream: InputStream, accounter: NbtAccounter): JsonElement { + return JsonNull.INSTANCE + } + }, + + DOUBLE({ it is JsonPrimitive && it.isNumber && (it.asNumber is Double || it.asNumber is Float) }) { + override fun write(stream: OutputStream, element: JsonElement) { + stream.writeDouble(element.asDouble) + } + + override fun read(stream: InputStream, accounter: NbtAccounter): JsonElement { + accounter.accountBytes(8L) + return JsonPrimitive(stream.readDouble()) + } + }, + + BOOLEAN({ it is JsonPrimitive && it.isBoolean }) { + override fun write(stream: OutputStream, element: JsonElement) { + stream.write(if (element.asBoolean) 1 else 0) + } + + override fun read(stream: InputStream, accounter: NbtAccounter): JsonElement { + accounter.accountBytes(1L) + return JsonPrimitive(stream.read() > 0) + } + }, + + INT({ it is JsonPrimitive && it.isNumber }) { + override fun write(stream: OutputStream, element: JsonElement) { + val it = element.asNumber + + if (it is Int || it is Long || it is Short || it is Byte) + stream.writeVarLongLE(element.asLong) + else + throw IllegalArgumentException("Unknown number type: ${it::class.qualifiedName}") + } + + override fun read(stream: InputStream, accounter: NbtAccounter): JsonElement { + return JsonPrimitive(stream.readVarLongLE(accounter)) + } + }, + + STRING({ it is JsonPrimitive && it.isString }) { + override fun write(stream: OutputStream, element: JsonElement) { + stream.writeBinaryString(element.asString) + } + + override fun read(stream: InputStream, accounter: NbtAccounter): JsonElement { + return JsonPrimitive(stream.readBinaryString(accounter)) + } + }, + + ARRAY({ it is JsonArray }) { + override fun write(stream: OutputStream, element: JsonElement) { + writeArray(stream, element, OutputStream::writeBinaryJson) + } + + override fun read(stream: InputStream, accounter: NbtAccounter): JsonElement { + return readArray(stream, accounter, InputStream::readBinaryJson) + } + }, + + OBJECT({ it is JsonObject }) { + override fun write(stream: OutputStream, element: JsonElement) { + element as JsonObject + stream.writeVarIntLE(element.size()) + + for ((k, v) in element.entrySet()) { + stream.writeBinaryString(k) + stream.writeBinaryJson(v) + } + } + + override fun read(stream: InputStream, accounter: NbtAccounter): JsonElement { + val count = stream.readVarIntLE(accounter) + + if (count == 0) return JsonObject() + if (count < 0) throw JsonSyntaxException("Tried to read json object with $count elements in it") + + val build = JsonObject() + + for (i in 0 until count) { + val key = try { + stream.readBinaryString(accounter) + } catch(err: Throwable) { + throw JsonSyntaxException("Reading json object at $i", err) + } + + try { + build.add(key, stream.readBinaryJson(accounter)) + } catch(err: Throwable) { + throw JsonSyntaxException("Reading json object at $i with name $key", err) + } + } + + return build + } + }, + + DOUBLE_ARRAY({ it is JsonArray && it.stream().allMatch { DOUBLE.test(it) } }) { + override fun write(stream: OutputStream, element: JsonElement) { + writeArray(stream, element, DOUBLE::write) + } + + override fun read(stream: InputStream, accounter: NbtAccounter): JsonElement { + return readArray(stream, accounter, DOUBLE::read) + } + }, + + INT_ARRAY({ it is JsonArray && it.stream().allMatch { INT.test(it) } }) { + override fun write(stream: OutputStream, element: JsonElement) { + writeArray(stream, element, INT::write) + } + + override fun read(stream: InputStream, accounter: NbtAccounter): JsonElement { + return readArray(stream, accounter, INT::read) + } + }, + + BOOLEAN_ARRAY({ it is JsonArray && it.stream().allMatch { BOOLEAN.test(it) } }) { + override fun write(stream: OutputStream, element: JsonElement) { + writeArray(stream, element, BOOLEAN::write) + } + + override fun read(stream: InputStream, accounter: NbtAccounter): JsonElement { + return readArray(stream, accounter, BOOLEAN::read) + } + }, + + NULL_ARRAY({ it is JsonArray && it.stream().allMatch { NULL.test(it) } }) { + override fun write(stream: OutputStream, element: JsonElement) { + writeArray(stream, element, NULL::write) + } + + override fun read(stream: InputStream, accounter: NbtAccounter): JsonElement { + return readArray(stream, accounter, NULL::read) + } + }; + + protected fun writeArray(stream: OutputStream, element: JsonElement, writer: (OutputStream, JsonElement) -> Unit) { + element as JsonArray + stream.writeVarIntLE(element.size()) + + for (v in element) { + writer.invoke(stream, v) + } + } + + protected fun readArray(stream: InputStream, accounter: NbtAccounter, reader: (InputStream, NbtAccounter) -> JsonElement): JsonArray { + val count = stream.readVarIntLE(accounter) + + if (count == 0) return JsonArray() + if (count < 0) throw JsonSyntaxException("Tried to read json array with $count elements in it") + + return JsonArray(count).also { + for (i in 0 until count) it.add(reader.invoke(stream, accounter)) + } + } + + abstract fun write(stream: OutputStream, element: JsonElement) + abstract fun read(stream: InputStream, accounter: NbtAccounter): JsonElement + + companion object { + val cached: ImmutableList = ImmutableList.of( + NULL, DOUBLE, BOOLEAN, INT, STRING, OBJECT, + DOUBLE_ARRAY, INT_ARRAY, BOOLEAN_ARRAY, ARRAY) + + val ordered: ImmutableList = ImmutableList.copyOf(values()) + } +} /** * Writes binary json to stream in Starbound Object Notation format @@ -25,48 +196,15 @@ private const val TYPE_OBJECT = 0x07 * just copy pasted this code from my another project because i was lazy */ fun OutputStream.writeBinaryJson(element: JsonElement) { - if (element is JsonObject) { - write(TYPE_OBJECT) - writeVarIntLE(element.size()) - - for ((k, v) in element.entrySet()) { - writeBinaryString(k) - writeBinaryJson(v) + for (writer in BinaryElementType.cached) { + if (writer.test(element)) { + write(writer.ordinal + 1) + writer.write(this, element) + return } - } else if (element is JsonArray) { - write(TYPE_ARRAY) - writeVarIntLE(element.size()) - - for (v in element) { - writeBinaryJson(v) - } - } else if (element is JsonPrimitive) { - if (element.isNumber) { - val num = element.asNumber - - if (num is Int || num is Long || num is Short || num is Byte) { - write(TYPE_INT) - writeVarLongLE(num.toLong()) - } else if (num is Float || num is Double) { - write(TYPE_DOUBLE) - writeDouble(num.toDouble()) - } else { - throw IllegalArgumentException("Unknown number type: ${num::class.qualifiedName}") - } - } else if (element.isString) { - write(TYPE_STRING) - writeBinaryString(element.asString) - } else if (element.isBoolean) { - write(TYPE_BOOLEAN) - write(if (element.asBoolean) 1 else 0) - } else { - write(TYPE_NULL) - } - } else if (element is JsonNull) { - write(TYPE_NULL) - } else { - throw IllegalArgumentException("Unknown element type: ${element::class.qualifiedName}") } + + throw IllegalArgumentException("Unknown element type: ${element::class.qualifiedName}") } /** @@ -76,54 +214,7 @@ fun OutputStream.writeBinaryJson(element: JsonElement) { */ fun InputStream.readBinaryJson(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 KiB */)): JsonElement { sizeLimit.accountBytes(1L) - - return when (val id = read()) { - TYPE_NULL -> JsonNull.INSTANCE - TYPE_DOUBLE -> { - sizeLimit.accountBytes(8L) - JsonPrimitive(readDouble()) - } - TYPE_BOOLEAN -> { - sizeLimit.accountBytes(1L) - JsonPrimitive(read() > 1) - } - TYPE_INT -> JsonPrimitive(readVarLongLE(sizeLimit)) - TYPE_STRING -> JsonPrimitive(readBinaryString(sizeLimit)) - TYPE_ARRAY -> { - val values = readVarIntLE(sizeLimit) - - if (values == 0) return JsonArray() - if (values < 0) throw JsonSyntaxException("Tried to read json array with $values elements in it") - - val build = JsonArray(values) - for (i in 0 until values) build.add(readBinaryJson(sizeLimit)) - return build - } - TYPE_OBJECT -> { - val values = readVarIntLE(sizeLimit) - if (values == 0) return JsonObject() - if (values < 0) throw JsonSyntaxException("Tried to read json object with $values elements in it") - - val build = JsonObject() - - for (i in 0 until values) { - val key: String - - try { - key = readBinaryString(sizeLimit) - } catch(err: Throwable) { - throw JsonSyntaxException("Reading json object at $i", err) - } - - try { - build.add(key, readBinaryJson(sizeLimit)) - } catch(err: Throwable) { - throw JsonSyntaxException("Reading json object at $i with name $key", err) - } - } - - return build - } - else -> throw JsonParseException("Unknown element type $id") - } + val id = read() - 1 + val reader = BinaryElementType.ordered.getOrNull(id) ?: throw JsonParseException("Unknown element type ${id + 1}") + return reader.read(this, sizeLimit) } From 07d698aeb56cc40c25db7299cd99b54211d81bf5 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 26 Jul 2023 12:12:28 +0700 Subject: [PATCH 0863/1199] Update IPatternStorage pattern signature --- .../entity/matter/PatternStorageBlockEntity.kt | 18 ++++++++++-------- .../otm/capability/matter/IPatternStorage.kt | 4 ++-- .../mc/otm/item/matter/CreativePatternItem.kt | 2 +- .../mc/otm/item/matter/PatternStorageItem.kt | 5 +++-- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt index 81f4d9375..222f0d67c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt @@ -17,7 +17,11 @@ import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.matter.* +import ru.dbotthepony.mc.otm.container.stream import ru.dbotthepony.mc.otm.core.collect.iterator +import ru.dbotthepony.mc.otm.core.filterNotNull +import ru.dbotthepony.mc.otm.core.isNotEmpty +import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode import ru.dbotthepony.mc.otm.registry.MBlockEntities import java.util.ArrayList @@ -94,14 +98,12 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return PatternStorageMenu(containerID, inventory, this) } - override val patterns: Stream get() { - val streams = ArrayList>() - - for (provider in this.container.iterator(MatteryCapability.PATTERN)) { - streams.add(provider.second.patterns) - } - - return Streams.concat(*streams.toTypedArray()) + override val patterns: Stream get() { + return container.stream() + .filter { it.isNotEmpty } + .map { it.getCapability(MatteryCapability.PATTERN).orNull() } + .filterNotNull() + .flatMap { it.patterns } } override val patternCapacity: Int get() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IPatternStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IPatternStorage.kt index 4730b3291..0eecae475 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IPatternStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/matter/IPatternStorage.kt @@ -13,9 +13,9 @@ import kotlin.math.roundToInt interface IPatternStorage { /** - * It must return new stream each time + * Patterns stored in this pattern storage */ - val patterns: Stream + val patterns: Stream fun findPatterns(item: Item): Collection { return findPatterns { item == it.item } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/CreativePatternItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/CreativePatternItem.kt index b07ed0744..b06eb053f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/CreativePatternItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/CreativePatternItem.kt @@ -28,7 +28,7 @@ class CreativePatternItem : Item(Properties().rarity(Rarity.EPIC).stacksTo(1)) { private object Patterns : IPatternStorage, ICapabilityProvider { private val resolver = LazyOptional.of { this } - override val patterns: Stream + override val patterns: Stream get() = MatterManager.map.keys.stream().map { PatternState(UUID(34783464838L, 4463458382L + ForgeRegistries.ITEMS.getID(it)), it, 1.0) } override val patternCapacity: Int diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/PatternStorageItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/PatternStorageItem.kt index 03924bd0a..6358a8258 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/PatternStorageItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/PatternStorageItem.kt @@ -16,6 +16,7 @@ import net.minecraft.world.level.Level import net.minecraftforge.common.capabilities.Capability import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.capability.matter.* +import ru.dbotthepony.mc.otm.core.filterNotNull import ru.dbotthepony.mc.otm.core.nbt.map import java.util.* import java.util.stream.Stream @@ -108,9 +109,9 @@ class PatternStorageItem : Item { return if (cap == MatteryCapability.PATTERN) resolver.cast() else LazyOptional.empty() } - override val patterns: Stream get() { + override val patterns: Stream get() { return stack.tag?.map("otm_patterns") { it: ListTag -> - it.stream().map { PatternState.deserializeNBT(it) }.filter { it != null } as Stream + it.stream().map { PatternState.deserializeNBT(it) }.filterNotNull() } ?: Stream.empty() } From 7a2ce84e5f488cc80e192324e6c62ea30fdddead Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 26 Jul 2023 12:22:29 +0700 Subject: [PATCH 0864/1199] Update binary json funcs docs to reflect latest changes --- .../kotlin/ru/dbotthepony/mc/otm/core/util/BinaryJson.kt | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) 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 ba25f9594..053228d31 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 @@ -191,9 +191,7 @@ private enum class BinaryElementType(private val predicate: Predicate Date: Wed, 26 Jul 2023 16:23:58 +0700 Subject: [PATCH 0865/1199] Codec2RecipeSerializer, move recipe registry to kotlin --- .../dbotthepony/mc/otm/registry/MRecipes.java | 54 ------------ .../mc/otm/core/util/ByteBufExtensions.kt | 5 ++ .../mc/otm/data/Codec2RecipeSerializer.kt | 86 +++++++++++++++++++ .../mc/otm/recipe/PlatePressRecipe.kt | 81 +++++------------ .../dbotthepony/mc/otm/registry/MRecipes.kt | 46 ++++++++++ 5 files changed, 157 insertions(+), 115 deletions(-) delete mode 100644 src/main/java/ru/dbotthepony/mc/otm/registry/MRecipes.java create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt diff --git a/src/main/java/ru/dbotthepony/mc/otm/registry/MRecipes.java b/src/main/java/ru/dbotthepony/mc/otm/registry/MRecipes.java deleted file mode 100644 index 304ce47e0..000000000 --- a/src/main/java/ru/dbotthepony/mc/otm/registry/MRecipes.java +++ /dev/null @@ -1,54 +0,0 @@ -package ru.dbotthepony.mc.otm.registry; - -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.crafting.Recipe; -import net.minecraft.world.item.crafting.RecipeSerializer; -import net.minecraft.world.item.crafting.RecipeType; -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.recipe.EnergyContainerRecipe; -import ru.dbotthepony.mc.otm.recipe.ExplosiveHammerPrimingRecipe; -import ru.dbotthepony.mc.otm.recipe.PlatePressRecipe; -import ru.dbotthepony.mc.otm.recipe.UpgradeRecipe; - -public class MRecipes { - public static class MatteryRecipeType> implements RecipeType { - public final ResourceLocation name; - - private MatteryRecipeType(ResourceLocation name) { - this.name = name; - } - - @Override - public String toString() { - return name.toString(); - } - } - - public static final MatteryRecipeType PLATE_PRESS = new MatteryRecipeType<>(OverdriveThatMatters.loc(MNames.PLATE_PRESS)); - public static final MatteryRecipeType ENERGY_CONTAINER = new MatteryRecipeType<>(OverdriveThatMatters.loc("energy_container")); - public static final MatteryRecipeType UPGRADE = new MatteryRecipeType<>(OverdriveThatMatters.loc("upgrade")); - public static final MatteryRecipeType HAMMER_PRIMING = new MatteryRecipeType<>(OverdriveThatMatters.loc("hammer_priming")); - - private static final DeferredRegister> serializerRegistry = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, OverdriveThatMatters.MOD_ID); - private static final DeferredRegister> typeRegistry = DeferredRegister.create(ForgeRegistries.RECIPE_TYPES, OverdriveThatMatters.MOD_ID); - - static { - serializerRegistry.register(MNames.PLATE_PRESS, () -> PlatePressRecipe.Companion); - serializerRegistry.register(ENERGY_CONTAINER.name.getPath(), () -> EnergyContainerRecipe.Companion); - serializerRegistry.register(UPGRADE.name.getPath(), () -> UpgradeRecipe.Companion); - serializerRegistry.register(HAMMER_PRIMING.name.getPath(), () -> ExplosiveHammerPrimingRecipe.Companion); - - typeRegistry.register(MNames.PLATE_PRESS, () -> PLATE_PRESS); - typeRegistry.register(ENERGY_CONTAINER.name.getPath(), () -> ENERGY_CONTAINER); - typeRegistry.register(UPGRADE.name.getPath(), () -> UPGRADE); - typeRegistry.register(HAMMER_PRIMING.name.getPath(), () -> HAMMER_PRIMING); - } - - public static void register(IEventBus bus) { - serializerRegistry.register(bus); - typeRegistry.register(bus); - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ByteBufExtensions.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ByteBufExtensions.kt index 5de89cfe1..eaff47fd6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ByteBufExtensions.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ByteBufExtensions.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.core.util import com.google.gson.JsonElement import com.mojang.serialization.Codec +import com.mojang.serialization.DataResult import com.mojang.serialization.JsonOps import io.netty.buffer.ByteBufInputStream import io.netty.buffer.ByteBufOutputStream @@ -29,6 +30,10 @@ fun FriendlyByteBuf.readBinaryJsonWithCodec(codec: Codec, sizeLimit: NbtA .get().map({ it.first }, { throw DecoderException("Failed to decode data from network: ${it.message()}") }) } +fun FriendlyByteBuf.readBinaryJsonWithCodecIndirect(codec: Codec, sizeLimit: NbtAccounter = NbtAccounter(1L shl 18)): DataResult { + return codec.decode(JsonOps.INSTANCE, readBinaryJson(sizeLimit)).map { it.first } +} + fun FriendlyByteBuf.readBinaryComponent(): Component { return Component.Serializer.fromJson(readBinaryJson()) ?: throw NullPointerException("Received null component") } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt new file mode 100644 index 000000000..f3543dbb0 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt @@ -0,0 +1,86 @@ +package ru.dbotthepony.mc.otm.data + +import com.google.gson.JsonObject +import com.google.gson.JsonSyntaxException +import com.mojang.datafixers.util.Pair +import com.mojang.serialization.Codec +import com.mojang.serialization.DataResult +import com.mojang.serialization.DynamicOps +import com.mojang.serialization.JsonOps +import net.minecraft.network.FriendlyByteBuf +import net.minecraft.resources.ResourceLocation +import net.minecraft.world.item.crafting.Recipe +import net.minecraft.world.item.crafting.RecipeSerializer +import org.apache.logging.log4j.LogManager +import ru.dbotthepony.mc.otm.core.util.readBinaryJsonWithCodecIndirect +import ru.dbotthepony.mc.otm.core.util.writeBinaryJsonWithCodec +import java.util.* +import kotlin.NoSuchElementException +import kotlin.concurrent.getOrSet + +class Codec2RecipeSerializer>(val empty: S?, val codec: Codec) : Codec by codec, RecipeSerializer { + constructor(supplier: (() -> ResourceLocation) -> Codec) : this(null, supplier.invoke(::context)) + constructor(empty: S, supplier: (() -> ResourceLocation) -> Codec) : this(empty, supplier.invoke(::context)) + + override fun fromJson(p_44103_: ResourceLocation, p_44104_: JsonObject): S { + try { + deck.getOrSet(::LinkedList).addLast(p_44103_) + + return codec.decode(JsonOps.INSTANCE, p_44104_).get().map( + { + it.first + }, + { + empty ?: throw JsonSyntaxException("Failed to deserialize recipe from JSON: ${it.message()}") + } + ) + } finally { + deck.get().removeLast() + } + } + + override fun fromNetwork(p_44105_: ResourceLocation, p_44106_: FriendlyByteBuf): S? { + try { + deck.getOrSet(::LinkedList).addLast(p_44105_) + + return p_44106_.readBinaryJsonWithCodecIndirect(codec) + .resultOrPartial { LOGGER.error("Failed to read recipe $p_44105_ from network: $it") }.orElse(null) + } finally { + deck.get().removeLast() + } + } + + override fun toNetwork(p_44101_: FriendlyByteBuf, p_44102_: S) { + p_44101_.writeBinaryJsonWithCodec(codec, p_44102_) + } + + companion object : Codec { + private val deck = ThreadLocal>() + + private fun context(): ResourceLocation { + val deck = deck.getOrSet(::LinkedList) + + if (deck.isEmpty()) { + throw NoSuchElementException("Context stack is empty") + } else { + return deck.last + } + } + + override fun encode(input: ResourceLocation, ops: DynamicOps, prefix: T): DataResult { + return DataResult.success(ops.empty()) + } + + override fun decode(ops: DynamicOps, input: T): DataResult> { + val deck = deck.getOrSet(::LinkedList) + + if (deck.isEmpty()) { + return DataResult.error { "Attempt to use recipe serializer codec ResourceLocation' hack outside Codec2RecipeSerializer" } + } else { + return DataResult.success(Pair(deck.last, ops.empty())) + } + } + + private val LOGGER = LogManager.getLogger() + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt index 783ee71d5..e4d1b4b5f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt @@ -1,10 +1,9 @@ package ru.dbotthepony.mc.otm.recipe -import com.google.gson.JsonObject -import com.google.gson.JsonPrimitive +import com.mojang.serialization.Codec +import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.core.NonNullList import net.minecraft.core.RegistryAccess -import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation import net.minecraft.util.valueproviders.ConstantFloat import net.minecraft.util.valueproviders.FloatProvider @@ -15,16 +14,14 @@ import net.minecraft.world.item.crafting.Recipe import net.minecraft.world.item.crafting.RecipeSerializer import net.minecraft.world.item.crafting.RecipeType import net.minecraft.world.level.Level -import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.container.get -import ru.dbotthepony.mc.otm.core.fromJsonStrict import ru.dbotthepony.mc.otm.core.isActuallyEmpty import ru.dbotthepony.mc.otm.registry.MRecipes import ru.dbotthepony.mc.otm.core.registryName -import ru.dbotthepony.mc.otm.core.toJsonStrict -import ru.dbotthepony.mc.otm.core.util.readBinaryJson -import ru.dbotthepony.mc.otm.core.util.writeBinaryJson +import ru.dbotthepony.mc.otm.data.Codec2RecipeSerializer +import ru.dbotthepony.mc.otm.data.IngredientCodec +import ru.dbotthepony.mc.otm.data.minRange class PlatePressRecipe( private val id: ResourceLocation, @@ -35,21 +32,21 @@ class PlatePressRecipe( val experience: FloatProvider = ConstantFloat.ZERO ) : Recipe { override fun matches(container: Container, p_44003_: Level): Boolean { - if (output.isActuallyEmpty || input.isActuallyEmpty) + if (isIncomplete) return false return input.test(container[0]) } fun matches(container: Container, slot: Int): Boolean { - if (output.isActuallyEmpty || input.isActuallyEmpty) + if (isIncomplete) return false return input.test(container[slot]) } private val outputStack: ItemStack by lazy { - if (output.isActuallyEmpty || input.isActuallyEmpty) { + if (isIncomplete) { ItemStack.EMPTY } else { val items = output.items @@ -59,7 +56,7 @@ class PlatePressRecipe( } override fun getIngredients(): NonNullList { - if (input.isActuallyEmpty || output.isActuallyEmpty) + if (isIncomplete) return super.getIngredients() return NonNullList.of(Ingredient.EMPTY, input) @@ -76,60 +73,22 @@ class PlatePressRecipe( override fun getId() = id override fun getSerializer(): RecipeSerializer<*> { - return Companion + return SERIALIZER } override fun getType(): RecipeType = MRecipes.PLATE_PRESS - companion object : RecipeSerializer { - private val EMPTY = PlatePressRecipe(ResourceLocation(OverdriveThatMatters.MOD_ID, "empty"), Ingredient.EMPTY, Ingredient.EMPTY, 1) - private val LOGGER = LogManager.getLogger() - - override fun fromJson(loc: ResourceLocation, obj: JsonObject): PlatePressRecipe { - val input = try { - Ingredient.fromJson(obj["input"] ?: throw IllegalStateException("Recipe $loc has no input field defined")) - } catch (err: Throwable) { - if (err.message?.lowercase()?.contains("unknown item tag") == true) { - LOGGER.warn("Ignoring recipe Input of $loc deserialization error, defaulting to empty recipe") - LOGGER.warn(err) - return EMPTY - } else { - throw IllegalStateException("Input of $loc is malformed", err) - } + companion object { + val SERIALIZER = Codec2RecipeSerializer(PlatePressRecipe(ResourceLocation(OverdriveThatMatters.MOD_ID, "empty"), Ingredient.EMPTY, Ingredient.EMPTY, 1)) { context -> + RecordCodecBuilder.create { + it.group( + IngredientCodec.fieldOf("input").forGetter(PlatePressRecipe::input), + IngredientCodec.fieldOf("output").forGetter(PlatePressRecipe::output), + Codec.INT.minRange(1).fieldOf("count").forGetter(PlatePressRecipe::count), + Codec.INT.minRange(0).optionalFieldOf("workTime", 200).forGetter(PlatePressRecipe::workTime), + FloatProvider.CODEC.optionalFieldOf("experience", ConstantFloat.ZERO).forGetter(PlatePressRecipe::experience) + ).apply(it) { a, b, c, d, e -> PlatePressRecipe(context.invoke(), a, b, c, d, e) } } - - val result = try { - Ingredient.fromJson(obj["result"] ?: throw IllegalStateException("Recipe $loc has no result field defined")) - } catch (err: Throwable) { - if (err.message?.lowercase()?.contains("unknown item tag") == true) { - LOGGER.warn("Ignoring recipe Output of $loc deserialization error, defaulting to empty recipe") - LOGGER.warn(err) - return EMPTY - } else { - throw IllegalStateException("Result of $loc is malformed", err) - } - } - - val workTime = (obj["work_time"] as? JsonPrimitive)?.let { return@let try {it.asInt} catch(err: Throwable) {throw IllegalStateException("Invalid work_time")} } ?: 200 - - check(workTime >= 0) { "work_time of $loc does not make any sense" } - - val count = ((obj["result"] as JsonObject)["count"] as? JsonPrimitive)?.let { return@let try {it.asInt} catch(err: Throwable) {throw IllegalStateException("Invalid result.count")} } ?: 1 - - val experience = obj["experience"]?.let { FloatProvider.CODEC.fromJsonStrict(it) } ?: ConstantFloat.ZERO - return PlatePressRecipe(loc, input, result, count, workTime, experience) - } - - override fun fromNetwork(loc: ResourceLocation, buff: FriendlyByteBuf): PlatePressRecipe { - return PlatePressRecipe(loc, Ingredient.fromNetwork(buff), Ingredient.fromNetwork(buff), buff.readInt(), buff.readInt(), FloatProvider.CODEC.fromJsonStrict(buff.readBinaryJson())) - } - - override fun toNetwork(buff: FriendlyByteBuf, recipe: PlatePressRecipe) { - recipe.input.toNetwork(buff) - recipe.output.toNetwork(buff) - buff.writeInt(recipe.count) - buff.writeInt(recipe.workTime) - buff.writeBinaryJson(FloatProvider.CODEC.toJsonStrict(recipe.experience)) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt new file mode 100644 index 000000000..a1f67f3ab --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt @@ -0,0 +1,46 @@ +package ru.dbotthepony.mc.otm.registry + +import net.minecraft.resources.ResourceLocation +import net.minecraft.world.item.crafting.Recipe +import net.minecraft.world.item.crafting.RecipeType +import net.minecraftforge.eventbus.api.IEventBus +import net.minecraftforge.registries.DeferredRegister +import net.minecraftforge.registries.ForgeRegistries +import net.minecraftforge.registries.RegistryObject +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.recipe.EnergyContainerRecipe +import ru.dbotthepony.mc.otm.recipe.ExplosiveHammerPrimingRecipe +import ru.dbotthepony.mc.otm.recipe.PlatePressRecipe +import ru.dbotthepony.mc.otm.recipe.UpgradeRecipe + +@Suppress("SameParameterValue") +object MRecipes { + class Type>(id: String) : RecipeType { + val id = ResourceLocation(OverdriveThatMatters.MOD_ID, id) + + override fun toString(): String { + return id.toString() + } + } + + private val types = DeferredRegister.create(ForgeRegistries.RECIPE_TYPES, OverdriveThatMatters.MOD_ID) + private val serializers = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, OverdriveThatMatters.MOD_ID) + + internal fun register(bus: IEventBus) { + types.register(bus) + serializers.register(bus) + } + + private fun > register(name: String): RegistryObject> { + return types.register(name) { Type(name) } + } + + val PLATE_PRESS by register("plate_press") + + init { + serializers.register("plate_press") { PlatePressRecipe.SERIALIZER } + serializers.register("energy_container") { EnergyContainerRecipe.Companion } + serializers.register("upgrade") { UpgradeRecipe.Companion } + serializers.register("hammer_priming") { ExplosiveHammerPrimingRecipe.Companion } + } +} From f71bc632a029bc9c87797466b879d5cc8bab0087 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 26 Jul 2023 16:41:10 +0700 Subject: [PATCH 0866/1199] Codec2RecipeSerializer.toFinished(), use it for plate press recipes --- .../datagen/recipes/MatteryRecipeProvider.kt | 11 +-- .../recipes/PlatePressFinishedRecipe.kt | 84 ------------------- .../mc/otm/data/Codec2RecipeSerializer.kt | 38 +++++++++ .../mc/otm/recipe/PlatePressRecipe.kt | 6 +- 4 files changed, 48 insertions(+), 91 deletions(-) delete mode 100644 src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressFinishedRecipe.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt index 945763b6f..bfefe5ca1 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt @@ -10,6 +10,7 @@ import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.data.recipes.RecipeBuilder import net.minecraft.data.recipes.RecipeProvider import net.minecraft.resources.ResourceLocation +import net.minecraft.tags.ItemTags import net.minecraft.tags.TagKey import net.minecraft.util.valueproviders.ConstantFloat import net.minecraft.util.valueproviders.FloatProvider @@ -82,20 +83,20 @@ class MatteryRecipeProvider(generatorIn: DataGenerator) : RecipeProvider(generat fun plate(id: String, count: Int = 1, workTicks: Int = 200, experience: FloatProvider = ConstantFloat.ZERO) { exec { _, consumer -> - consumer.accept(PlatePressShallowFinishedRecipe( + consumer.accept(PlatePressRecipe( modLocation("plates/$id"), - ResourceLocation("forge", "ingots/$id"), - ResourceLocation("forge", "plates/$id"), + Ingredient.of(ItemTags.create(ResourceLocation("forge", "ingots/$id"))), + Ingredient.of(ItemTags.create(ResourceLocation("forge", "plates/$id"))), count, workTicks, experience = experience - )) + ).toFinished()) } } fun plate(id: String, ingredient: Ingredient, result: Ingredient, count: Int = 1, workTicks: Int = 200, experience: FloatProvider = ConstantFloat.ZERO) { exec { it, callback -> - callback.accept(PlatePressFinishedRecipe(PlatePressRecipe(modLocation("plate_$id"), ingredient, result, count, workTicks, experience = experience))) + callback.accept(PlatePressRecipe(modLocation("plate_$id"), ingredient, result, count, workTicks, experience = experience).toFinished()) } } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressFinishedRecipe.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressFinishedRecipe.kt deleted file mode 100644 index 2b0ca00fc..000000000 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressFinishedRecipe.kt +++ /dev/null @@ -1,84 +0,0 @@ -package ru.dbotthepony.mc.otm.datagen.recipes - -import com.google.gson.JsonObject -import com.google.gson.JsonPrimitive -import com.mojang.serialization.JsonOps -import net.minecraft.data.recipes.FinishedRecipe -import net.minecraft.resources.ResourceLocation -import net.minecraft.util.valueproviders.ConstantFloat -import net.minecraft.util.valueproviders.FloatProvider -import net.minecraft.world.item.crafting.RecipeSerializer -import ru.dbotthepony.mc.otm.recipe.PlatePressRecipe -import ru.dbotthepony.mc.otm.core.set -import ru.dbotthepony.mc.otm.core.toJsonStrict - -class PlatePressFinishedRecipe(private val recipe: PlatePressRecipe) : FinishedRecipe { - override fun serializeRecipeData(it: JsonObject) { - it["input"] = recipe.input.toJson() - - it["result"] = recipe.output.toJson().also { - if (it is JsonObject && recipe.count != 1) - it["count"] = JsonPrimitive(recipe.count) - } - - it["work_time"] = JsonPrimitive(recipe.workTime) - it["experience"] = FloatProvider.CODEC.toJsonStrict(recipe.experience) - } - - override fun getId(): ResourceLocation { - return recipe.id - } - - override fun getType(): RecipeSerializer<*> { - return PlatePressRecipe.Companion - } - - override fun serializeAdvancement(): JsonObject? { - return null - } - - override fun getAdvancementId(): ResourceLocation? { - return null - } -} - -class PlatePressShallowFinishedRecipe( - private val id: ResourceLocation, - private val input: ResourceLocation, - private val output: ResourceLocation, - private val count: Int = 1, - private val workTime: Int = 200, - private val experience: FloatProvider = ConstantFloat.ZERO, -) : FinishedRecipe { - override fun serializeRecipeData(it: JsonObject) { - it["input"] = JsonObject().also { - it["tag"] = JsonPrimitive(input.toString()) - } - - it["result"] = JsonObject().also { - it["tag"] = JsonPrimitive(output.toString()) - - if (count != 1) - it["count"] = JsonPrimitive(count) - } - - it["work_time"] = JsonPrimitive(workTime) - it["experience"] = FloatProvider.CODEC.toJsonStrict(experience) - } - - override fun getId(): ResourceLocation { - return id - } - - override fun getType(): RecipeSerializer<*> { - return PlatePressRecipe.Companion - } - - override fun serializeAdvancement(): JsonObject? { - return null - } - - override fun getAdvancementId(): ResourceLocation? { - return null - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt index f3543dbb0..40ba63af0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt @@ -1,17 +1,20 @@ package ru.dbotthepony.mc.otm.data import com.google.gson.JsonObject +import com.google.gson.JsonParseException import com.google.gson.JsonSyntaxException import com.mojang.datafixers.util.Pair import com.mojang.serialization.Codec import com.mojang.serialization.DataResult import com.mojang.serialization.DynamicOps import com.mojang.serialization.JsonOps +import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.crafting.Recipe import net.minecraft.world.item.crafting.RecipeSerializer import org.apache.logging.log4j.LogManager +import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.core.util.readBinaryJsonWithCodecIndirect import ru.dbotthepony.mc.otm.core.util.writeBinaryJsonWithCodec import java.util.* @@ -54,6 +57,41 @@ class Codec2RecipeSerializer>(val empty: S?, val codec: Codec) p_44101_.writeBinaryJsonWithCodec(codec, p_44102_) } + fun toFinished(recipe: S): FinishedRecipe { + return object : FinishedRecipe { + override fun serializeRecipeData(p_125967_: JsonObject) { + codec.encode(recipe, JsonOps.INSTANCE, p_125967_).get().map( + { + it as JsonObject + + for ((k, v) in it.entrySet()) { + p_125967_[k] = v + } + }, + { + throw JsonParseException("Failed to serialize recipe: ${it.message()}") + } + ) + } + + override fun getId(): ResourceLocation { + return recipe.id + } + + override fun getType(): RecipeSerializer<*> { + return this@Codec2RecipeSerializer + } + + override fun serializeAdvancement(): JsonObject? { + return null + } + + override fun getAdvancementId(): ResourceLocation? { + return null + } + } + } + companion object : Codec { private val deck = ThreadLocal>() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt index e4d1b4b5f..08bc643f7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt @@ -27,7 +27,7 @@ class PlatePressRecipe( private val id: ResourceLocation, val input: Ingredient, val output: Ingredient, - val count: Int, + val count: Int = 1, val workTime: Int = 200, val experience: FloatProvider = ConstantFloat.ZERO ) : Recipe { @@ -78,13 +78,15 @@ class PlatePressRecipe( override fun getType(): RecipeType = MRecipes.PLATE_PRESS + fun toFinished() = SERIALIZER.toFinished(this) + companion object { val SERIALIZER = Codec2RecipeSerializer(PlatePressRecipe(ResourceLocation(OverdriveThatMatters.MOD_ID, "empty"), Ingredient.EMPTY, Ingredient.EMPTY, 1)) { context -> RecordCodecBuilder.create { it.group( IngredientCodec.fieldOf("input").forGetter(PlatePressRecipe::input), IngredientCodec.fieldOf("output").forGetter(PlatePressRecipe::output), - Codec.INT.minRange(1).fieldOf("count").forGetter(PlatePressRecipe::count), + Codec.INT.minRange(1).optionalFieldOf("count", 1).forGetter(PlatePressRecipe::count), Codec.INT.minRange(0).optionalFieldOf("workTime", 200).forGetter(PlatePressRecipe::workTime), FloatProvider.CODEC.optionalFieldOf("experience", ConstantFloat.ZERO).forGetter(PlatePressRecipe::experience) ).apply(it) { a, b, c, d, e -> PlatePressRecipe(context.invoke(), a, b, c, d, e) } From 138627f8dead613421833dbf44489146b7d98fb1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 26 Jul 2023 17:03:12 +0700 Subject: [PATCH 0867/1199] Fix rectangle in android station screen not being transparent --- .../mc/otm/client/screen/tech/AndroidStationScreen.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 efb855254..98f54410d 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 @@ -292,7 +292,7 @@ private class AndroidResearchButton( val isBlockedByHovered = hovered != null && node.type in hovered.type.allBlocking if (isBlockedByHovered) { - graphics.renderRect(0f, 0f, width, height, color = AndroidStationScreen.CAN_NOT_BE_RESEARCHED) + graphics.renderRect(0f, 0f, width, height, color = AndroidStationScreen.CAN_NOT_BE_RESEARCHED2) } val nodeColor = if (node.isResearched) { @@ -706,6 +706,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I val RESEARCHED = RGBAColor(150, 150, 200) val CAN_BE_RESEARCHED = RGBAColor(150, 200, 150) val CAN_NOT_BE_RESEARCHED = RGBAColor(200, 150, 150) + val CAN_NOT_BE_RESEARCHED2 = RGBAColor(200, 150, 150, 127) val ALREADY_BLOCKED = RGBAColor(105, 79, 79) private val LOW_POWER_0 = TranslatableComponent("otm.android_station.low_power_0") From 0724d35b50fa0c678ba733d615a5046458465012 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 26 Jul 2023 17:06:36 +0700 Subject: [PATCH 0868/1199] Make pressing enter in essence storage text field also set player level right away --- .../screen/panels/input/TextInputPanel.kt | 5 +++++ .../client/screen/tech/EssenceStorageScreen.kt | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt index bebb96588..ad74f87d4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt @@ -650,6 +650,10 @@ open class TextInputPanel( return true } + open fun onEnter() { + + } + override fun keyPressedInternal(key: Int, scancode: Int, mods: Int): Boolean { if (key == InputConstants.KEY_ESCAPE || !isActive) { killFocus() @@ -706,6 +710,7 @@ open class TextInputPanel( } else { killFocus() triggerChangeCallback() + onEnter() return true } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt index a980fdd31..f1bd75821 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt @@ -7,6 +7,7 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.client.isShiftDown +import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.render.sprites.MatteryAtlas import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.screen.MatteryScreen @@ -205,6 +206,22 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title text = customDispense.toString() } + override fun onEnter() { + val player = minecraft?.player ?: return + + if (player.experienceLevel == customDispense) { + if (player.experienceProgress > 0f) { + menu.storeLevels.input(1) + } + } else if (player.experienceLevel > customDispense) { + menu.storeLevels.input(player.experienceLevel - customDispense) + } else { + menu.dispenseLevels.input(customDispense - player.experienceLevel) + } + + playGuiClickSound() + } + override fun onTextChanged(old: String, new: String) { customDispense = (new.toIntOrNull() ?: 30).coerceAtLeast(1) } From aa7e0d91588f311ff41941165a7f2dc53fa60316 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 26 Jul 2023 17:09:23 +0700 Subject: [PATCH 0869/1199] Add missing attack boost item requiremenets --- src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt index 19e80c062..84b4d166a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt @@ -153,6 +153,9 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang (i + 1) * 15 ) ) + .addItem(MItems.ELECTROMAGNET, 2 + i) + .addItem(MItemTags.GOLD_WIRES, 4 * i + 8) + .addItem(MItemTags.PISTONS) .addBlocker(NANOBOTS_ARMOR) if (i > 0) { From 28950955fd8de08812af3a4013d697cf6a1a65f1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 26 Jul 2023 17:30:35 +0700 Subject: [PATCH 0870/1199] Add missing matter recipes registration to event bus --- src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt | 1 + 1 file changed, 1 insertion(+) 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 ad4caab70..9cc2d9490 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -272,6 +272,7 @@ object MRegistry { LootModifiers.register(bus) MItemFunctionTypes.register(bus) MLootItemConditions.register(bus) + MRecipes.register(bus) if (FMLEnvironment.dist == Dist.CLIENT) { MBlockColors.register(bus) From f78094c1c944bd930f2d1d8fb3f33771c0266c40 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 26 Jul 2023 17:54:13 +0700 Subject: [PATCH 0871/1199] Revert previous commit --- src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt | 2 +- src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt index a1f67f3ab..216531d73 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt @@ -19,7 +19,7 @@ object MRecipes { val id = ResourceLocation(OverdriveThatMatters.MOD_ID, id) override fun toString(): String { - return id.toString() + return "RecipeType[$id]" } } 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 9cc2d9490..f0c2ee936 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -278,8 +278,6 @@ object MRegistry { MBlockColors.register(bus) } - MRecipes.register(bus) - // call static constructors NanobotsArmorFeature.Companion EnderTeleporterFeature.Companion From db5cdbe80254b81b123c23df9de2d4acf34fb6d8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 26 Jul 2023 21:27:48 +0700 Subject: [PATCH 0872/1199] Bump JEI version, re-enable at runtime --- build.gradle.kts | 2 +- gradle.properties | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index de8377dc3..b8c6b9d4b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -191,7 +191,7 @@ dependencies { compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-common-api:${jei_version}")) compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge-api:${jei_version}")) - //runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}")) + runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}")) implementation(fg.deobf("curse.maven:jade-324717:${jade_id}")) //runtimeOnly(fg.deobf("curse.maven:configured-457570:${configured_id}")) diff --git a/gradle.properties b/gradle.properties index eaa8ca684..7402afb41 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ use_commit_hash_in_version=true mc_version=1.20.1 use_parchment=false parchment_version=2023.03.12-1.19.3 -jei_mc_version=1.20 +jei_mc_version=1.20.1 curios_mc_version=1.20 forge_gradle_version=[6.0,6.2) @@ -21,7 +21,7 @@ forge_version=47.1.0 mixingradle_version=0.7.33 mixin_version=0.8.5 -jei_version=14.0.0.5 +jei_version=15.2.0.23 jupiter_version=5.9.2 mekanism_version=1.20.1-10.3.9.homebaked curios_version=5.2.0-beta.2 From 8567e75b6faade0ceaad0a618a5c81f3a4da1f86 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 27 Jul 2023 13:42:07 +0700 Subject: [PATCH 0873/1199] Fix effect duration on rectangle button being misaligned --- .../dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt index 6fc0d47d8..816505845 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt @@ -116,7 +116,7 @@ open class EffectListPanel @JvmOverloads constructor( minecraft.mobEffectTextures.get(effect.effect).render(graphics, x = 3f, y = 3f, width = width - 6f, height = height - 6f) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) - graphics.draw(font, formatTickDuration(effect.duration), width / 2f - 1f, height / 2f, scale = 0.75f, gravity = RenderGravity.CENTER_CENTER, color = RGBAColor.WHITE) + graphics.draw(font, formatTickDuration(effect.duration), width / 2f, height / 2f, scale = 0.75f, gravity = RenderGravity.CENTER_CENTER, color = RGBAColor.WHITE) } override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { From 7bc58bb7ff1100d06b00516cdb81aca468afff87 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 27 Jul 2023 20:49:01 +0700 Subject: [PATCH 0874/1199] Matter reconstructor rebalanced values --- .../matter/MatterReconstructorBlockEntity.kt | 94 ++++--------------- .../mc/otm/config/MachinesConfig.kt | 40 +++++++- 2 files changed, 55 insertions(+), 79 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt index 55c2c0d9d..3dffd4e37 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt @@ -25,6 +25,7 @@ import ru.dbotthepony.mc.otm.capability.matter.PatternState import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage import ru.dbotthepony.mc.otm.config.EnergyBalanceValues +import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.UpgradeContainer @@ -60,8 +61,8 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) private set val upgrades = UpgradeContainer(this::setChangedLight, 3, UpgradeType.REPLICATOR) - val matter = ProfiledMatterStorage(MatterStorageImpl(::setChangedLight, FlowDirection.INPUT, upgrades.matterCapacity(::CAPACITY))) - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::setChangedLight, upgrades.transform(ENERGY_VALUES))) + val matter = ProfiledMatterStorage(MatterStorageImpl(::setChangedLight, FlowDirection.INPUT, upgrades.matterCapacity(MachinesConfig.MatterReconstructor.VALUES::matterCapacity))) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::setChangedLight, upgrades.transform(MachinesConfig.MatterReconstructor.VALUES))) val matterNode = object : MatterNode() { override fun getMatterHandler(): IMatterStorage { @@ -107,7 +108,7 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) return false } - if (ALLOW_TO_SKIP_ANVIL && !ONLY_ANVIL) { + if (MachinesConfig.MatterReconstructor.ALLOW_TO_SKIP_ANVIL && !MachinesConfig.MatterReconstructor.ONLY_ANVIL) { if (MatterManager.get(stack.item).hasMatterValue) { return true } @@ -172,13 +173,13 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) visualItemStack = item visualProgress = 0f } else { - if (ALLOW_TO_SKIP_ANVIL && !ONLY_ANVIL) { + if (MachinesConfig.MatterReconstructor.ALLOW_TO_SKIP_ANVIL && !MachinesConfig.MatterReconstructor.ONLY_ANVIL) { val matter = MatterManager.get(item.item) if (matter.hasMatterValue) { - failureChance = FAILURE_CHANCE - progressPerTick = (item.maxDamage / matter.complexity) / DIVISOR - matterPerTick = (matter.matter / matter.complexity) / DIVISOR + failureChance = MachinesConfig.MatterReconstructor.FAILURE_CHANCE + progressPerTick = (item.maxDamage / matter.complexity) / MachinesConfig.MatterReconstructor.DIVISOR + matterPerTick = (matter.matter / matter.complexity) / MachinesConfig.MatterReconstructor.DIVISOR return@once } } @@ -186,14 +187,14 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) val found = matterNode.graph.patterns.filter { item.item.isValidRepairItem(item, ItemStack(it.item, 1)) }.findFirst().orElse(null) if (found != null) { - failureChance = (1.0 - found.researchPercent) + FAILURE_CHANCE + failureChance = (1.0 - found.researchPercent) + MachinesConfig.MatterReconstructor.FAILURE_CHANCE - if (!ONLY_ANVIL) { + if (!MachinesConfig.MatterReconstructor.ONLY_ANVIL) { val matter = MatterManager.get(item.item) if (matter.hasMatterValue) { - progressPerTick = (item.maxDamage / matter.complexity) / DIVISOR - matterPerTick = (matter.matter / matter.complexity) / DIVISOR + progressPerTick = (item.maxDamage / matter.complexity) / MachinesConfig.MatterReconstructor.DIVISOR + matterPerTick = (matter.matter / matter.complexity) / MachinesConfig.MatterReconstructor.DIVISOR return@once } } @@ -201,8 +202,8 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) @Suppress("name_shadowing") val matter = MatterManager.get(found.item) * 2 - progressPerTick = (item.maxDamage / matter.complexity) / DIVISOR - matterPerTick = (matter.matter / matter.complexity) / DIVISOR + progressPerTick = (item.maxDamage / matter.complexity) / MachinesConfig.MatterReconstructor.DIVISOR + matterPerTick = (matter.matter / matter.complexity) / MachinesConfig.MatterReconstructor.DIVISOR } else { matterPerTick = Decimal.ZERO progressPerTick = 0.0 @@ -224,7 +225,7 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) val thisProgressPerTick = progressPerTick * (1.0 + upgrades.speedBonus) val matterPerTick = matterPerTick * (1.0 + upgrades.speedBonus) - val energyConsumption = ENERGY_CONSUMPTION * (1.0 + upgrades.speedBonus) * (upgrades.energyConsumed + Decimal.ONE) + val energyConsumption = MachinesConfig.MatterReconstructor.VALUES.powerConsumption * (1.0 + upgrades.speedBonus) * (upgrades.energyConsumed + Decimal.ONE) if (!item.isEmpty && matterPerTick.isPositive && thisProgressPerTick > 0.0 && item.isRepairable && item.isDamaged) { var progressPerTick = (repairProgress + thisProgressPerTick).coerceAtMost(item.damageValue.toDouble()) - repairProgress @@ -242,7 +243,7 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) } if (matter.storedMatter < matterPerTick) { - val toDrain = (matterPerTick * EXTRACT_TICKS + val toDrain = (matterPerTick * 200 .coerceAtMost(item.damageValue) - matter.storedMatter) .coerceAtLeast(Decimal.ZERO) .coerceAtMost(matter.missingMatter) @@ -289,67 +290,4 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) } } } - - companion object { - val CAPACITY get() = _CAPACITY.get() - val ENERGY_CONSUMPTION get() = _ENERGY_CONSUMPTION.get() - val DIVISOR: Double get() = _DIVISOR.get() - val EXTRACT_TICKS: Int get() = _EXTRACT_TICKS.get() - val FAILURE_CHANCE: Double get() = _FAILURE_CHANCE.get() - val ONLY_ANVIL: Boolean get() = _ONLY_ANVIL.get() - val ALLOW_TO_SKIP_ANVIL: Boolean get() = _ALLOW_TO_SKIP_ANVIL.get() - - private var _CAPACITY: DecimalConfigValue by WriteOnce() - private var _ENERGY_CONSUMPTION: DecimalConfigValue by WriteOnce() - private var _DIVISOR: ConfigValue by WriteOnce() - private var _FAILURE_CHANCE: ConfigValue by WriteOnce() - private var _EXTRACT_TICKS: ConfigValue by WriteOnce() - private var _ONLY_ANVIL: ConfigValue by WriteOnce() - private var _ALLOW_TO_SKIP_ANVIL: ConfigValue by WriteOnce() - - var ENERGY_VALUES: EnergyBalanceValues by WriteOnce() - private set - - fun registerConfig(builder: ForgeConfigSpec.Builder) { - builder.push(MNames.MATTER_RECONSTRUCTOR) - - ENERGY_VALUES = BlockEnergyStorageImpl.makeConfigEntry(builder, capacity = Decimal(400_000), throughput = Decimal(2_000)) - - _CAPACITY = builder.defineDecimal("matterCapacity", Decimal(800), Decimal.ONE_TENTH) - _ENERGY_CONSUMPTION = builder.defineDecimal("energyConsumption", Decimal(600), Decimal.ONE) - - _ALLOW_TO_SKIP_ANVIL = builder - .comment("Allow to repair tools without having their anvil-repair items researched") - .comment("Ignored if onlyAnvil is true") - .define("allowToSkipAnvil", false) - - _ONLY_ANVIL = builder - .comment("Force repairing only by matter value of anvil materials") - .comment("Doesn't make logical sense but might be good for balancing") - .define("onlyAnvil", false) - - _EXTRACT_TICKS = builder - .comment("How much ticks of matter work will be attempted to be extracted from matter network") - .comment("on matter starvation") - .comment("---") - .comment("This is a performance tuning value, do not change it if you don't know what you are doing!") - .defineInRange("extractTicks", 200, 1, Int.MAX_VALUE) - - _FAILURE_CHANCE = builder - .comment("Constant additional chance (over pattern research factor) that replication will fail at any given tick") - .comment("In event of failure repair tick is wasted, wasting resources") - .defineInRange("failureChance", 0.01, 0.0, 0.99) - - _DIVISOR = builder - .comment("Magnitute of **slowdown** of repairer.") - .comment("If this value is 1, repairer will repair item from 0% to 100% in COMPLEXITY (of tool) ticks") - .comment("(or twice the complexity of anvil repair ingredients if tool itself has no matter value)") - .comment("---") - .comment("If value is smaller than 1, repairer will repair items faster") - .comment("If value is bigger than 1, repairer will repair items slower") - .defineInRange("divisor", 3.0, 0.1, Double.MAX_VALUE) - - builder.pop() - } - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt index 23b7d6238..48571a7fc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt @@ -20,7 +20,6 @@ object MachinesConfig : AbstractConfig("machines") { ChemicalGeneratorBlockEntity.registerConfig(builder) MatterBottlerBlockEntity.registerConfig(builder) MatterReplicatorBlockEntity.registerConfig(builder) - MatterReconstructorBlockEntity.registerConfig(builder) } val PLATE_PRESS = workerValues( @@ -62,6 +61,45 @@ object MachinesConfig : AbstractConfig("machines") { MATTER_RECYCLER_CAPACITY = defineDecimal("MATTER_CAPACITY", Decimal(400), Decimal.ONE) } + private val MATTER_RECONSTRUCTOR = workerValues( + MNames.MATTER_RECONSTRUCTOR, + energyStorage = Decimal(100_000), + energyThroughput = Decimal(1000), + powerConsumption = Decimal(400), + matterCapacity = Decimal(200), + workTimeMultiplier = null, + ) { + MatterReconstructor + } + + object MatterReconstructor { + val VALUES by ::MATTER_RECONSTRUCTOR + + val ALLOW_TO_SKIP_ANVIL: Boolean by builder + .comment("Allow to repair tools without having their anvil-repair items researched") + .comment("Ignored if onlyAnvil is true") + .define("allowToSkipAnvil", false) + + val ONLY_ANVIL: Boolean by builder + .comment("Force repairing only by matter value of anvil materials") + .comment("Doesn't make logical sense but might be good for balancing") + .define("onlyAnvil", false) + + val FAILURE_CHANCE: Double by builder + .comment("Constant additional chance (over pattern research factor) that replication will fail at any given tick") + .comment("In event of failure repair tick is wasted, as well as resources") + .defineInRange("failureChance", 0.01, 0.0, 0.99) + + val DIVISOR: Double by builder + .comment("Magnitute of **slowdown** of repairer.") + .comment("If this value is 1, repairer will repair item from 0% to 100% in COMPLEXITY (of tool) ticks") + .comment("(or twice the complexity of anvil repair ingredients if tool itself has no matter value)") + .comment("---") + .comment("If value is smaller than 1, repairer will repair items faster") + .comment("If value is bigger than 1, repairer will repair items slower") + .defineInRange("divisor", 3.0, 0.1, Double.MAX_VALUE) + } + val STORAGE_POWER_SUPPLIER = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.STORAGE_POWER_SUPPLIER, capacity = Decimal(100_000), throughput = Decimal(320)) val STORAGE_INTERFACES = BlockEnergyStorageImpl.makeConfigEntry(builder, "STORAGE_INTERFACES", capacity = Decimal(10_000)) val ITEM_MONITOR = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.ITEM_MONITOR) From 43d14486b76c05eb98b597a1bb36c4da6fd11992 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 27 Jul 2023 20:51:58 +0700 Subject: [PATCH 0875/1199] Move matter recycler config values to subobject --- .../matter/MatterRecyclerBlockEntity.kt | 10 ++++----- .../mc/otm/config/MachinesConfig.kt | 22 +++++++------------ 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index b67971e95..53e353361 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -44,11 +44,11 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) } } - val matter = ProfiledMatterStorage(MatterStorageImpl(::matterLevelUpdated, FlowDirection.OUTPUT, MachinesConfig.MATTER_RECYCLER_CAPACITY::get)) + val matter = ProfiledMatterStorage(MatterStorageImpl(::matterLevelUpdated, FlowDirection.OUTPUT, MachinesConfig.MatterRecycler.VALUES::matterCapacity)) val container = MatteryContainer(::itemContainerUpdated, 1).also(::addDroppableContainer) val matterNode = SimpleMatterNode(matter = matter) - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::energyLevelUpdated, MachinesConfig.MATTER_RECYCLER)) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::energyLevelUpdated, MachinesConfig.MatterRecycler.VALUES)) val itemConfig = ConfigurableItemHandler(input = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { @@ -117,8 +117,8 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) return JobContainer.success( RecyclerJob( - (actualMatter / MachinesConfig.MATTER_RECYCLER_MATTER_PER_TICK.get()).toDouble(), - MachinesConfig.MATTER_RECYCLER.powerConsumption, + (actualMatter / MachinesConfig.MatterRecycler.MATTER_PER_TICK).toDouble(), + MachinesConfig.MatterRecycler.VALUES.powerConsumption, actualMatter ) ) @@ -126,7 +126,7 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) override fun onJobTick(status: JobStatus, id: Int) { val job = status.job - val toReceive = job.totalMatter.coerceAtMost(MachinesConfig.MATTER_RECYCLER_MATTER_PER_TICK.get() * status.ticksAdvanced) + val toReceive = job.totalMatter.coerceAtMost(MachinesConfig.MatterRecycler.MATTER_PER_TICK * status.ticksAdvanced) if (toReceive.isZero) return status.success() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt index 48571a7fc..57c8dfeaa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt @@ -1,17 +1,12 @@ package ru.dbotthepony.mc.otm.config -import ru.dbotthepony.mc.otm.block.entity.matter.MatterReconstructorBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity -import ru.dbotthepony.mc.otm.block.entity.matter.MatterDecomposerBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity -import ru.dbotthepony.mc.otm.block.entity.matter.MatterScannerBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.ChemicalGeneratorBlockEntity import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal -import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.registry.MNames object MachinesConfig : AbstractConfig("machines") { @@ -44,21 +39,20 @@ object MachinesConfig : AbstractConfig("machines") { powerConsumption = Decimal(80), ) - var MATTER_RECYCLER_MATTER_PER_TICK: DecimalConfigValue by WriteOnce() - private set - - var MATTER_RECYCLER_CAPACITY: DecimalConfigValue by WriteOnce() - private set - - val MATTER_RECYCLER = workerValues( + private val MATTER_RECYCLER = workerValues( MNames.MATTER_RECYCLER, energyStorage = Decimal(80_000), energyThroughput = Decimal(400), powerConsumption = Decimal(100), + matterCapacity = Decimal(400), workTimeMultiplier = null ) { - MATTER_RECYCLER_MATTER_PER_TICK = defineDecimal("MATTER_PER_TICK", Decimal("0.5")) - MATTER_RECYCLER_CAPACITY = defineDecimal("MATTER_CAPACITY", Decimal(400), Decimal.ONE) + MatterRecycler + } + + object MatterRecycler { + val VALUES by ::MATTER_RECYCLER + val MATTER_PER_TICK by builder.defineDecimal("MATTER_PER_TICK", Decimal("0.5")) } private val MATTER_RECONSTRUCTOR = workerValues( From d7332f472078ed82d9eaee4274f0304ef56009af Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 27 Jul 2023 20:53:36 +0700 Subject: [PATCH 0876/1199] More consistent config names --- .../matter/MatterDecomposerBlockEntity.kt | 2 +- .../matter/MatterReconstructorBlockEntity.kt | 10 +-------- .../matter/MatterRecyclerBlockEntity.kt | 2 +- .../entity/matter/MatterScannerBlockEntity.kt | 2 +- .../entity/tech/PlatePressBlockEntity.kt | 2 +- .../entity/tech/PoweredFurnaceBlockEntity.kt | 2 +- .../mc/otm/config/AbstractConfig.kt | 22 +++++++++---------- .../mc/otm/config/BalanceValues.kt | 2 +- .../mc/otm/config/MachinesConfig.kt | 8 +++---- 9 files changed, 22 insertions(+), 30 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index 2cc112b88..6feb56bb3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -40,7 +40,7 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) val toDust: Boolean, var matterValue: Decimal, ticks: Double, - ) : Job(ticks, MachinesConfig.MATTER_DECOMPOSER.powerConsumption) { + ) : Job(ticks, MachinesConfig.MATTER_DECOMPOSER.energyConsumption) { companion object { val CODEC: Codec by lazy { RecordCodecBuilder.create { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt index 3dffd4e37..3e312cf0b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt @@ -10,36 +10,28 @@ import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState -import net.minecraftforge.common.ForgeConfigSpec -import net.minecraftforge.common.ForgeConfigSpec.ConfigValue import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.UpgradeType -import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage import ru.dbotthepony.mc.otm.capability.matter.PatternState import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage -import ru.dbotthepony.mc.otm.config.EnergyBalanceValues import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.UpgradeContainer import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue -import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.core.registryName -import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.graph.matter.MatterNode import ru.dbotthepony.mc.otm.matter.IMatterValue import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.menu.matter.MatterReconstructorMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities -import ru.dbotthepony.mc.otm.registry.MNames class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.MATTER_RECONSTRUCTOR, blockPos, blockState) { val repairContainer = MatteryContainer(::containerChanged, 1).also(::addDroppableContainer) @@ -225,7 +217,7 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) val thisProgressPerTick = progressPerTick * (1.0 + upgrades.speedBonus) val matterPerTick = matterPerTick * (1.0 + upgrades.speedBonus) - val energyConsumption = MachinesConfig.MatterReconstructor.VALUES.powerConsumption * (1.0 + upgrades.speedBonus) * (upgrades.energyConsumed + Decimal.ONE) + val energyConsumption = MachinesConfig.MatterReconstructor.VALUES.energyConsumption * (1.0 + upgrades.speedBonus) * (upgrades.energyConsumed + Decimal.ONE) if (!item.isEmpty && matterPerTick.isPositive && thisProgressPerTick > 0.0 && item.isRepairable && item.isDamaged) { var progressPerTick = (repairProgress + thisProgressPerTick).coerceAtMost(item.damageValue.toDouble()) - repairProgress diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index 53e353361..2717c81e7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -118,7 +118,7 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) return JobContainer.success( RecyclerJob( (actualMatter / MachinesConfig.MatterRecycler.MATTER_PER_TICK).toDouble(), - MachinesConfig.MatterRecycler.VALUES.powerConsumption, + MachinesConfig.MatterRecycler.VALUES.energyConsumption, actualMatter ) ) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt index 2009e343d..1c64fd770 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt @@ -144,7 +144,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : stack.shrink(1) container.setChanged() val complexity = MatterManager.get(copy).complexity - return JobContainer.success(ItemJob(copy, (if (complexity > 1.0) complexity.pow(1.25) else complexity.pow(0.5)) * MachinesConfig.MATTER_SCANNER.workTimeMultiplier, MachinesConfig.MATTER_SCANNER.powerConsumption)) + return JobContainer.success(ItemJob(copy, (if (complexity > 1.0) complexity.pow(1.25) else complexity.pow(0.5)) * MachinesConfig.MATTER_SCANNER.workTimeMultiplier, MachinesConfig.MATTER_SCANNER.energyConsumption)) } return JobContainer.noItem() 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 df68623fc..f7583bede 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 @@ -102,7 +102,7 @@ class PlatePressBlockEntity( ItemJob( recipe.getResultItem(level.registryAccess()).copyWithCount(toProcess), recipe.workTime * MachinesConfig.PLATE_PRESS.workTimeMultiplier, - MachinesConfig.PLATE_PRESS.powerConsumption * toProcess, + MachinesConfig.PLATE_PRESS.energyConsumption * toProcess, experience = recipe.experience.sample(level.random) * toProcess)) } 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 e11236c03..ab30d0401 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 @@ -107,7 +107,7 @@ class PoweredFurnaceBlockEntity( inputs[id][0].shrink(toProcess) JobContainer.success(ItemJob( - output.copyWithCount(toProcess), it.cookingTime * config.workTimeMultiplier, config.powerConsumption * toProcess, it.experience * toProcess + output.copyWithCount(toProcess), it.cookingTime * config.workTimeMultiplier, config.energyConsumption * toProcess, it.experience * toProcess )) }.orElse(JobContainer.noItem()) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt index 1214d2f30..906314c6c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt @@ -19,10 +19,10 @@ abstract class AbstractConfig(private val configName: String, private val type: builder.push(name) val obj = object : BatteryBalanceValues { - override val energyCapacity: Decimal by builder.defineDecimal("capacity", storage, minimum = Decimal.ONE) - override val maxEnergyReceive: Decimal by builder.defineDecimal("receive", receive, minimum = Decimal.ONE) - override val maxEnergyExtract: Decimal by builder.defineDecimal("extract", extract, minimum = Decimal.ONE) - override val initialBatteryLevel: Decimal by builder.defineDecimal("initialBatteryLevel", initialBatteryLevel, minimum = Decimal.ZERO) + override val energyCapacity: Decimal by builder.defineDecimal("ENERGY_CAPACITY", storage, minimum = Decimal.ONE) + override val maxEnergyReceive: Decimal by builder.defineDecimal("MAX_RECEIVE", receive, minimum = Decimal.ONE) + override val maxEnergyExtract: Decimal by builder.defineDecimal("MAX_EXTRACT", extract, minimum = Decimal.ONE) + override val initialBatteryLevel: Decimal by builder.defineDecimal("INITIAL_BATTERY_LEVEL", initialBatteryLevel, minimum = Decimal.ZERO) } builder.pop() @@ -34,8 +34,8 @@ abstract class AbstractConfig(private val configName: String, private val type: builder.push(name) val obj = object : EnergyBalanceValues { - override val energyCapacity: Decimal by builder.defineDecimal("capacity", storage, minimum = Decimal.ONE) - override val energyThroughput: Decimal by builder.defineDecimal("throughput", throughput, minimum = Decimal.ONE) + override val energyCapacity: Decimal by builder.defineDecimal("ENERGY_CAPACITY", storage, minimum = Decimal.ONE) + override val energyThroughput: Decimal by builder.defineDecimal("ENERGY_THROUGHPUT", throughput, minimum = Decimal.ONE) } configurator.invoke(builder) @@ -56,11 +56,11 @@ abstract class AbstractConfig(private val configName: String, private val type: builder.push(name) val obj = object : WorkerBalanceValues { - override val energyCapacity: Decimal by builder.defineDecimal("capacity", energyStorage, minimum = Decimal.ONE) - override val energyThroughput: Decimal by builder.defineDecimal("throughput", energyThroughput, minimum = Decimal.ONE) - override val powerConsumption: Decimal by builder.defineDecimal("powerConsumption", powerConsumption, minimum = Decimal.ONE) - override val matterCapacity: Decimal by (if (matterCapacity == null) GetterSetter.box(Decimal.ZERO) else builder.defineDecimal("matterCapacity", matterCapacity, minimum = Decimal.ONE)) - override val workTimeMultiplier: Double by (if (workTimeMultiplier == null) GetterSetter.box(1.0) else builder.defineInRange("workTimeMultiplier", workTimeMultiplier, 0.0)) + override val energyCapacity: Decimal by builder.defineDecimal("ENERGY_CAPACITY", energyStorage, minimum = Decimal.ONE) + override val energyThroughput: Decimal by builder.defineDecimal("ENERGY_THROUGHPUT", energyThroughput, minimum = Decimal.ONE) + override val energyConsumption: Decimal by builder.defineDecimal("ENERGY_CONSUMPTION", powerConsumption, minimum = Decimal.ONE) + override val matterCapacity: Decimal by (if (matterCapacity == null) GetterSetter.box(Decimal.ZERO) else builder.defineDecimal("MATTER_CAPACITY", matterCapacity, minimum = Decimal.ONE)) + override val workTimeMultiplier: Double by (if (workTimeMultiplier == null) GetterSetter.box(1.0) else builder.defineInRange("WORK_TIME_MULTIPLIER", workTimeMultiplier, 0.0)) } configurator.invoke(builder) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/BalanceValues.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/BalanceValues.kt index 6ff056147..1a0a59e3e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/BalanceValues.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/BalanceValues.kt @@ -9,7 +9,7 @@ interface EnergyBalanceValues { interface WorkerBalanceValues : EnergyBalanceValues { val workTimeMultiplier: Double - val powerConsumption: Decimal + val energyConsumption: Decimal val matterCapacity: Decimal } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt index 57c8dfeaa..1cd3ee462 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt @@ -72,17 +72,17 @@ object MachinesConfig : AbstractConfig("machines") { val ALLOW_TO_SKIP_ANVIL: Boolean by builder .comment("Allow to repair tools without having their anvil-repair items researched") .comment("Ignored if onlyAnvil is true") - .define("allowToSkipAnvil", false) + .define("ALLOW_TO_SKIP_ANVIL", false) val ONLY_ANVIL: Boolean by builder .comment("Force repairing only by matter value of anvil materials") .comment("Doesn't make logical sense but might be good for balancing") - .define("onlyAnvil", false) + .define("ONLY_ANVIL", false) val FAILURE_CHANCE: Double by builder .comment("Constant additional chance (over pattern research factor) that replication will fail at any given tick") .comment("In event of failure repair tick is wasted, as well as resources") - .defineInRange("failureChance", 0.01, 0.0, 0.99) + .defineInRange("FAILURE_CHANCE", 0.01, 0.0, 0.99) val DIVISOR: Double by builder .comment("Magnitute of **slowdown** of repairer.") @@ -91,7 +91,7 @@ object MachinesConfig : AbstractConfig("machines") { .comment("---") .comment("If value is smaller than 1, repairer will repair items faster") .comment("If value is bigger than 1, repairer will repair items slower") - .defineInRange("divisor", 3.0, 0.1, Double.MAX_VALUE) + .defineInRange("DIVISOR", 3.0, 0.1, Double.MAX_VALUE) } val STORAGE_POWER_SUPPLIER = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.STORAGE_POWER_SUPPLIER, capacity = Decimal(100_000), throughput = Decimal(320)) From 5466b134965dc5e0ac5c38b88129a63e9c990115 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 29 Jul 2023 14:18:33 +0700 Subject: [PATCH 0877/1199] Exopack battery is no longer dropped on death --- .../mc/otm/capability/MatteryPlayerCapability.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index e7d735336..5512a3985 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -1690,7 +1690,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial inventory.player.dropContainer(mattery.exoPackContainer) inventory.player.dropContainer(mattery.exoPackChargeSlots) - inventory.player.dropContainer(mattery.exoPackEnergy.parent) + // inventory.player.dropContainer(mattery.exoPackEnergy.parent) for (smelter in mattery.smelters) { inventory.player.dropContainer(smelter.input) @@ -1709,7 +1709,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial mattery.exoPackContainer.clearContent() mattery.exoPackChargeSlots.clearContent() - mattery.exoPackEnergy.parent.clearContent() + // mattery.exoPackEnergy.parent.clearContent() for (smelter in mattery.smelters) { smelter.input.clearContent() @@ -1724,7 +1724,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial if (it.hasExoPack) { it.exoPackContainer.vanishCursedItems() it.exoPackChargeSlots.vanishCursedItems() - it.exoPackEnergy.parent.vanishCursedItems() + // it.exoPackEnergy.parent.vanishCursedItems() for (smelter in it.smelters) { smelter.input.vanishCursedItems() From 1346a3774d5dda449378637eae3a0d9f46f7fd16 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 29 Jul 2023 14:23:40 +0700 Subject: [PATCH 0878/1199] Don't store x and y in separate fields in rendergravity --- .../kotlin/ru/dbotthepony/mc/otm/client/render/RenderGravity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderGravity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderGravity.kt index fc755570a..f67ee6051 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderGravity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderGravity.kt @@ -183,7 +183,7 @@ enum class YGravity : IYGravity { }; } -enum class RenderGravity(val x: IXGravity, val y: IYGravity) : IXGravity by x, IYGravity by y { +enum class RenderGravity(x: IXGravity, y: IYGravity) : IXGravity by x, IYGravity by y { TOP_LEFT(XGravity.LEFT, YGravity.TOP), TOP_CENTER(XGravity.CENTER, YGravity.TOP), TOP_RIGHT(XGravity.RIGHT, YGravity.TOP), From ff308ee67a3159fb39c34d204bdac671c090e049 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 29 Jul 2023 16:30:56 +0700 Subject: [PATCH 0879/1199] Actual tabs sprites, and all 4 sprite states for them --- .../mc/otm/client/render/WidgetLocation.kt | 1 + .../mc/otm/client/screen/panels/FramePanel.kt | 117 +++++++++++------- .../textures/gui/widgets/tabs.png | Bin 0 -> 1201 bytes 3 files changed, 74 insertions(+), 44 deletions(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/tabs.png diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt index 46e5c5f26..7c9ca1069 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt @@ -11,6 +11,7 @@ object WidgetLocation { val SLOT_BACKGROUNDS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/slot_backgrounds.png"), 72f, 72f) val MISC = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/misc.png"), 64f, 64f) + val TABS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/tabs.png"), 224f, 64f) val PATTERN_PANEL_TABS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/pattern_panel_tabs.png"), 60f, 23f) val CHECKBOX = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/checkbox.png"), 30f, 60f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index e921758ff..90325961a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -34,7 +34,6 @@ open class FramePanel( var inactiveIcon: IGUIRenderable? = null, ) : AbstractButtonPanel(this@FramePanel.screen, this@FramePanel, 0f, 0f, 28f, 28f) { var isActive = tabs.isEmpty() - var initial = false init { tabs.add(this) @@ -54,44 +53,59 @@ open class FramePanel( } } + protected fun tabIndex(): Int { + return tabs.indexOf(this) + } + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { - val width: Float - val height: Float - if (isActive) { - width = TAB_WIDTH_ACTIVE - height = TAB_HEIGHT_ACTIVE - RECTANGLE.middle.render(graphics, 2f, 2f, width - 4, height - 2) - } else { - width = TAB_WIDTH - height = TAB_HEIGHT - TAB_BACKGROUND.render(graphics, 2f, 2f, width - 4, height - 2) - } - - RECTANGLE.top.render(graphics, 3f, 0f, width = width - 6) - RECTANGLE.left.render(graphics, 0f, 3f, height = (height - if (isActive) if (initial) 2 else 4 else 3)) - - RECTANGLE.right.render(graphics, width - RECTANGLE.right.width, 3f, height = (height - if (isActive) 4 else 3)) - - RECTANGLE.topLeft.render(graphics, 0f, 0f) - RECTANGLE.topRight.render(graphics, width - RECTANGLE.topRight.width, 0f) - - if (isActive) { - if (!initial) { - TAB_LEFT_CONNECTION.render(graphics, 0f, height - TAB_LEFT_CONNECTION.height - 1) + if (tabIndex() == 0) { + if (isDisabled) { + TAB_ACTIVE0_DISABLED.render(graphics, x = -2f) + } else if (isPressed) { + TAB_ACTIVE0_PRESSED.render(graphics, x = -2f) + } else if (isHovered) { + TAB_ACTIVE0_HOVERED.render(graphics, x = -2f) + } else { + TAB_ACTIVE0_IDLE.render(graphics, x = -2f) + } + } else { + if (isDisabled) { + TAB_ACTIVE_DISABLED.render(graphics, x = -2f) + } else if (isPressed) { + TAB_ACTIVE_PRESSED.render(graphics, x = -2f) + } else if (isHovered) { + TAB_ACTIVE_HOVERED.render(graphics, x = -2f) + } else { + TAB_ACTIVE_IDLE.render(graphics, x = -2f) + } } - TAB_RIGHT_CONNECTION.render( - graphics, - width - TAB_RIGHT_CONNECTION.width, - height - TAB_LEFT_CONNECTION.height - 1 - ) - - val skinActive = activeIcon ?: return - skinActive.render(graphics, TAB_WIDTH_ACTIVE / 2f, TAB_HEIGHT_ACTIVE / 2f, gravity = RenderGravity.CENTER_CENTER) + activeIcon?.render(graphics, x = width / 2f - 1f, y = height / 2f + 1f, gravity = RenderGravity.CENTER_CENTER) } else { - val skinInactive = inactiveIcon ?: return - skinInactive.render(graphics, width / 2f, TAB_HEIGHT_ACTIVE / 2f, gravity = RenderGravity.CENTER_CENTER) + if (tabIndex() == 0) { + if (isDisabled) { + TAB_INACTIVE0_DISABLED.render(graphics) + } else if (isPressed) { + TAB_INACTIVE0_PRESSED.render(graphics) + } else if (isHovered) { + TAB_INACTIVE0_HOVERED.render(graphics) + } else { + TAB_INACTIVE0_IDLE.render(graphics) + } + } else { + if (isDisabled) { + TAB_INACTIVE_DISABLED.render(graphics) + } else if (isPressed) { + TAB_INACTIVE_PRESSED.render(graphics) + } else if (isHovered) { + TAB_INACTIVE_HOVERED.render(graphics) + } else { + TAB_INACTIVE_IDLE.render(graphics) + } + } + + inactiveIcon?.render(graphics, x = width / 2f - 1f, y = height / 2f + 1f, gravity = RenderGravity.CENTER_CENTER) } } @@ -118,6 +132,11 @@ open class FramePanel( onOpen() } } + + override fun onRemoved() { + super.onRemoved() + tabs.remove(this) + } } inner class CloseButton : AbstractButtonPanel(screen, this@FramePanel, this@FramePanel.width - CLOSE_BUTTON.width, 0f, CLOSE_BUTTON.width, CLOSE_BUTTON.height) { @@ -200,8 +219,7 @@ open class FramePanel( override fun performLayout() { for ((i, tab) in tabs.withIndex()) { - tab.setPos(i * TAB_WIDTH, -TAB_HEIGHT) - tab.initial = i == 0 + tab.setPos(i * 28f, -28f) } closeButton?.setPos(width - CLOSE_BUTTON.width, 0f) @@ -385,9 +403,25 @@ open class FramePanel( padding = DockProperty(-3f, -3f, -3f, -3f) ) - val TAB_RIGHT_CONNECTION = WidgetLocation.MISC.sprite(x = 30f, y = 0f, width = 3f, height = 5f) - val TAB_LEFT_CONNECTION = WidgetLocation.MISC.sprite(x = 33f, y = 0f, width = 3f, height = 5f) - val TAB_BACKGROUND = WidgetLocation.MISC.sprite(x = 30f, y = 6f, width = 6f, height = 6f) + val TAB_INACTIVE0_IDLE = WidgetLocation.TABS.sprite(x = 26f * 0f, width = 26f, height = 32f) + val TAB_INACTIVE0_HOVERED = WidgetLocation.TABS.sprite(x = 26f * 1f, width = 26f, height = 32f) + val TAB_INACTIVE0_PRESSED = WidgetLocation.TABS.sprite(x = 26f * 2f, width = 26f, height = 32f) + val TAB_INACTIVE0_DISABLED = WidgetLocation.TABS.sprite(x = 26f * 3f, width = 26f, height = 32f) + + val TAB_INACTIVE_IDLE = WidgetLocation.TABS.sprite(x = 26f * 0f, y = 32f, width = 26f, height = 32f) + val TAB_INACTIVE_HOVERED = WidgetLocation.TABS.sprite(x = 26f * 1f, y = 32f, width = 26f, height = 32f) + val TAB_INACTIVE_PRESSED = WidgetLocation.TABS.sprite(x = 26f * 2f, y = 32f, width = 26f, height = 32f) + val TAB_INACTIVE_DISABLED = WidgetLocation.TABS.sprite(x = 26f * 3f, y = 32f, width = 26f, height = 32f) + + val TAB_ACTIVE0_IDLE = WidgetLocation.TABS.sprite(x = 26f * 4f + 30f * 0f, width = 30f, height = 32f) + val TAB_ACTIVE0_HOVERED = WidgetLocation.TABS.sprite(x = 26f * 4f + 30f * 1f, width = 30f, height = 32f) + val TAB_ACTIVE0_PRESSED = WidgetLocation.TABS.sprite(x = 26f * 4f + 30f * 2f, width = 30f, height = 32f) + val TAB_ACTIVE0_DISABLED = WidgetLocation.TABS.sprite(x = 26f * 4f + 30f * 3f, width = 30f, height = 32f) + + val TAB_ACTIVE_IDLE = WidgetLocation.TABS.sprite(x = 26f * 4f + 30f * 0f, y = 32f, width = 30f, height = 32f) + val TAB_ACTIVE_HOVERED = WidgetLocation.TABS.sprite(x = 26f * 4f + 30f * 1f, y = 32f, width = 30f, height = 32f) + val TAB_ACTIVE_PRESSED = WidgetLocation.TABS.sprite(x = 26f * 4f + 30f * 2f, y = 32f, width = 30f, height = 32f) + val TAB_ACTIVE_DISABLED = WidgetLocation.TABS.sprite(x = 26f * 4f + 30f * 3f, y = 32f, width = 30f, height = 32f) val CLOSE_BUTTON = WidgetLocation.MISC.sprite(x = 51f, y = 0f, width = 13f, height = 14f) val CLOSE_BUTTON_HOVERED = WidgetLocation.MISC.sprite(x = 51f, y = 14f, width = 13f, height = 14f) @@ -396,10 +430,5 @@ open class FramePanel( val HELP_BUTTON = WidgetLocation.MISC.sprite(x = 40f, y = 0f, width = 11f, height = 14f) val HELP_BUTTON_HOVERED = WidgetLocation.MISC.sprite(x = 40f, y = 14f, width = 11f, height = 14f) val HELP_BUTTON_PRESSED = WidgetLocation.MISC.sprite(x = 40f, y = 28f, width = 11f, height = 14f) - - const val TAB_HEIGHT = 28f - const val TAB_WIDTH = 28f - const val TAB_HEIGHT_ACTIVE = 32f - const val TAB_WIDTH_ACTIVE = 28f } } diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/tabs.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/tabs.png new file mode 100644 index 0000000000000000000000000000000000000000..660791b65715f565e057f22126bd24fd4523ea56 GIT binary patch literal 1201 zcmeAS@N?(olHy`uVBq!ia0vp^4}jQ#gAGVB8&>l(Ffg`cIy(n=Iy);A6y>L7=A<$( zXiTh~XzOv))G7Dl&QVtRYK8Aag$7spcom}>rKt_ z-J$H_>9Mjgtd1X;k6bmEm&y_qlP zeD6HGMo06=^CQA+u@inwe7)&({v2;UZX4sAl*^xwBqnXVa$NWa^wU5`E zHqP|FBrU63#KM!qEPh?q_a3uedBZ~WSR)npPnSiyTp#@H*{8|RbC2n7c3%G5+BtR% zk*~6TvRPQL9P^&C_ua>L``+FAXM6eGdv@z@Mc>cPJ8cMz7PcgBcNZWH1V5d3*8?fe z0*}aI1_nK45N51cYF`EvWH0gbb!C6fF3Ty(UU+QQ2cVE-iEBiObAE1aYF-J0b5Uwy zNotBhd1gt5g1e`0KzJjcI0FMyr>Bc!NX4zUcMbg>JBYA7Fz?7NXxy@sD@H+m!AZ>y zk@*Z-t74cqIhS~3YQ#L%yVthi-kOtorz_e_?_Y0Vy0re`&;DSA{UY|I6XT^Se9!HF zdgat)>!f!NTi3n*^nB@*K4VFooq~`ruQ(5_vtx>7mck;Fi3U0ia z!&iTC`~1Co_N1KNxqEkaN5`_vy3;%N>^U>7xUle}w_klg`}Lw5Z_EC!Z=N4CZ~pwv zPuE_5{cp~tl}c~E|IXRj-`@{3B|_)l4C_ZSmsc|N*CMF0XercJ-%i z^>21NJ)a%rXE^)pvQsm~x?QK$@ULSir=#TVff9s`JATL(_8!*_7B=`0Lg@RJ8$vN zX#Cr7c}8;Y&R_l#D?ET+BJ3%+idR}YWi^*g`}}Lg$Bm_}>pRz7+WJGc_%7rAeIkOH zYmRUEF8h{UXIk|Z`3({8F4i3Y3tsyE^*giHga4NfF>U|4@Na`^QTsRMX(wcF@kb=R gT=lo%gXk literal 0 HcmV?d00001 From 092daf80d825a55b45d2a97ecd92e6bf98b69890 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 29 Jul 2023 16:50:31 +0700 Subject: [PATCH 0880/1199] Powered furnaces advancements --- .../datagen/advancements/MachineAdvancementsData.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt index 754624d6a..98f922329 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt @@ -179,4 +179,17 @@ fun addMachineAdvancements(serializer: Consumer, existingFileHelper russianName = "Булыжник: бесконечность + 1", russianSuffix = "Смотрите, чтоб он не просыпался во все сундуки", englishSuffix = "Watch for not to spill it over all your chests").make(serializer, existingFileHelper, press, translation) + + CraftEntry(MItems.POWERED_FURNACE, "One Big Resistor", + russianName = "Один большой резистор", + russianSuffix = "Каждый элемент электрической цепи способен испускать свет и тепло, единожды.", + englishSuffix = "Any electrical element can emit light and heat, once.") + .make(serializer, existingFileHelper, press, translation) + .also { + CraftEntry(MItems.POWERED_BLAST_FURNACE, "Big Microwave Oven", + russianName = "Большая микроволновая печь").make(serializer, existingFileHelper, it, translation) + + CraftEntry(MItems.POWERED_SMOKER, "Small Microwave Oven", + russianName = "Маленькая микроволновая печь").make(serializer, existingFileHelper, it, translation) + } } From 651febed960256fac837877fcc1d7072131b4d8f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 29 Jul 2023 17:02:30 +0700 Subject: [PATCH 0881/1199] Use menu inputs for inventory/exopack slot filter changes --- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 11 +++-- .../network/MatteryPlayerNetworkChannel.kt | 48 +------------------ 2 files changed, 7 insertions(+), 52 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index a4049eacf..4986ce750 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -50,10 +50,8 @@ import ru.dbotthepony.mc.otm.core.util.NullValueCodec import ru.dbotthepony.mc.otm.core.util.VarIntValueCodec import ru.dbotthepony.mc.otm.menu.input.InstantBooleanInput import ru.dbotthepony.mc.otm.network.MatteryPacket -import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel import ru.dbotthepony.mc.otm.network.MenuFieldPacket import ru.dbotthepony.mc.otm.network.MenuNetworkChannel -import ru.dbotthepony.mc.otm.network.SetInventoryFilterPacket import ru.dbotthepony.mc.otm.network.enqueueWork import ru.dbotthepony.mc.otm.network.packetHandled import ru.dbotthepony.mc.otm.network.sender @@ -179,6 +177,8 @@ abstract class MatteryMenu @JvmOverloads protected constructor( fun bigDecimalInput(allowSpectators: Boolean = false, handler: (BigDecimal) -> Unit) = PlayerInput(BigDecimalValueCodec, allowSpectators, handler) fun booleanInput(allowSpectators: Boolean = false, handler: (Boolean) -> Unit) = PlayerInput(BooleanValueCodec, allowSpectators, handler) + fun itemInput(allowSpectators: Boolean = false, handler: (Item) -> Unit) = PlayerInput(ItemValueCodec, allowSpectators, handler) + fun nullableItemInput(allowSpectators: Boolean = false, handler: (Item?) -> Unit) = PlayerInput(ItemValueCodec.nullable, allowSpectators, handler) fun stringInput(allowSpectators: Boolean = false, handler: (String) -> Unit) = PlayerInput(BinaryStringCodec, allowSpectators, handler) fun intInput(allowSpectators: Boolean = false, handler: (Int) -> Unit) = PlayerInput(VarIntValueCodec, allowSpectators, handler) @@ -270,11 +270,12 @@ abstract class MatteryMenu @JvmOverloads protected constructor( if (mattery != null) { if (container === inventory) { - if (slotIndex in mattery.regularSlotFilters.indices) + if (slotIndex in mattery.regularSlotFilters.indices) { filter = GetterSetter.of( getter = { mattery.regularSlotFilters[slotIndex].value }, - setter = { MatteryPlayerNetworkChannel.sendToServer(SetInventoryFilterPacket(SetInventoryFilterPacket.Type.INVENTORY, slotIndex, it)) } + setter = nullableItemInput(true) { mattery.regularSlotFilters[slotIndex].value = it }::input ) + } if (slotIndex in mattery.regularSlotChargeFlag.indices) { val input = booleanInput(true) { mattery.regularSlotChargeFlag[slotIndex].boolean = it } @@ -287,7 +288,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( } else if (container === mattery.exoPackContainer) { filter = GetterSetter.of( getter = { mattery.exoPackContainer.getSlotFilter(slotIndex) }, - setter = { MatteryPlayerNetworkChannel.sendToServer(SetInventoryFilterPacket(SetInventoryFilterPacket.Type.EXOPACK, slotIndex, it)) } + setter = nullableItemInput(true) { mattery.exoPackContainer.setSlotFilter(slotIndex, it) }::input ) val input = booleanInput(true) { if (it) mattery.exoPackSlotsChargeFlag.add(slotIndex) else mattery.exoPackSlotsChargeFlag.remove(slotIndex) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt index d2a766275..3d26e222e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt @@ -561,52 +561,8 @@ data class SetExopackColorPacket(val color: RGBAColor) : MatteryPacket { } } -class SetInventoryFilterPacket(val type: Type, val slot: Int, val item: Item?) : MatteryPacket { - enum class Type { - INVENTORY, - EXOPACK - } - - override fun write(buff: FriendlyByteBuf) { - buff.writeEnum(type) - buff.writeVarInt(slot) - - if (item == null) { - buff.writeByte(0) - } else { - buff.writeByte(1) - buff.writeItemType(item) - } - } - - override fun play(context: Supplier) { - context.packetHandled = true - val player = context.sender?.matteryPlayer ?: return - - when (type) { - Type.INVENTORY -> { - if (slot in 0 until player.regularSlotFilters.size) { - player.regularSlotFilters[slot].value = item - } - } - - Type.EXOPACK -> { - if (slot in 0 until player.exoPackContainer.containerSize) { - player.exoPackContainer.setSlotFilter(slot, item) - } - } - } - } - - companion object { - fun read(buff: FriendlyByteBuf): SetInventoryFilterPacket { - return SetInventoryFilterPacket(buff.readEnum(Type::class.java), buff.readVarInt(), if (buff.readByte() > 0) buff.readItemType() else null) - } - } -} - object MatteryPlayerNetworkChannel : MatteryNetworkChannel( - version = "4", + version = "5", name = "player" ) { fun register() { @@ -643,7 +599,5 @@ object MatteryPlayerNetworkChannel : MatteryNetworkChannel( add(DisableExopackGlowPacket::class, { DisableExopackGlowPacket }, PLAY_TO_SERVER) add(ResetExopackColorPacket::class, { ResetExopackColorPacket }, PLAY_TO_SERVER) add(SetExopackColorPacket::class, SetExopackColorPacket.Companion::read, PLAY_TO_SERVER) - - add(SetInventoryFilterPacket::class, SetInventoryFilterPacket.Companion::read, PLAY_TO_SERVER) } } From 3262cdfe8d287579bcdbb0852692de2545467104 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 29 Jul 2023 17:05:42 +0700 Subject: [PATCH 0882/1199] Get rid of world network channel and merge it into generic network channel --- .../mc/otm/OverdriveThatMatters.java | 1 - .../otm/android/feature/ItemMagnetFeature.kt | 12 +- .../mc/otm/block/entity/MatteryBlockEntity.kt | 4 +- .../mc/otm/network/GenericNetworkChannel.kt | 95 +++++++++++++++- .../mc/otm/network/WorldNetworkChannel.kt | 103 ------------------ 5 files changed, 98 insertions(+), 117 deletions(-) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 7a73a9cbb..4161c855d 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -202,7 +202,6 @@ public final class OverdriveThatMatters { MenuNetworkChannel.INSTANCE.register(); WeaponNetworkChannel.INSTANCE.register(); RegistryNetworkChannel.INSTANCE.register(); - WorldNetworkChannel.INSTANCE.register(); GenericNetworkChannel.INSTANCE.register(); ITEM_STORAGE = StorageRegistry.register(ItemStackWrapper.class, ItemStackWrapper.EMPTY, new Decimal("3.125")); diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt index bafb85a0a..066ccb6fb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt @@ -1,36 +1,28 @@ package ru.dbotthepony.mc.otm.android.feature -import com.mojang.blaze3d.vertex.PoseStack -import net.minecraft.ChatFormatting import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.network.FriendlyByteBuf -import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.Entity import net.minecraft.world.entity.item.ItemEntity import net.minecraftforge.network.NetworkEvent -import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.config.AndroidConfig -import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact -import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.core.math.Vector -import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.core.getEntitiesInEllipsoid import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.minus import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.core.position import ru.dbotthepony.mc.otm.core.math.times +import ru.dbotthepony.mc.otm.network.GenericNetworkChannel import ru.dbotthepony.mc.otm.network.MatteryPacket -import ru.dbotthepony.mc.otm.network.WorldNetworkChannel import ru.dbotthepony.mc.otm.network.packetHandled import ru.dbotthepony.mc.otm.registry.AndroidFeatures -import ru.dbotthepony.mc.otm.registry.MNames import java.util.UUID import java.util.WeakHashMap import java.util.function.Predicate @@ -90,7 +82,7 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable ent as ItemEntity if (server) { - WorldNetworkChannel.send(ply, ItemEntityDataPacket(ent.id, ent.owner?.uuid, ent.age, ent.lifespan, ent.hasPickUpDelay())) + GenericNetworkChannel.send(ply, ItemEntityDataPacket(ent.id, ent.owner?.uuid, ent.age, ent.lifespan, ent.hasPickUpDelay())) if (!serverPredicate.test(ent)) { continue 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 4577c8cee..9c7264abe 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 @@ -58,8 +58,8 @@ import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.core.util.Savetables import ru.dbotthepony.mc.otm.core.util.TickList import ru.dbotthepony.mc.otm.network.BlockEntitySyncPacket +import ru.dbotthepony.mc.otm.network.GenericNetworkChannel import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer -import ru.dbotthepony.mc.otm.network.WorldNetworkChannel import ru.dbotthepony.mc.otm.once import ru.dbotthepony.mc.otm.onceServer import java.lang.ref.WeakReference @@ -662,7 +662,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc val payload = synchronizer.computeEndpointFor(player).collectNetworkPayload() if (payload != null) { - WorldNetworkChannel.send(player, BlockEntitySyncPacket(blockPos, payload.array, payload.length)) + GenericNetworkChannel.send(player, BlockEntitySyncPacket(blockPos, payload.array, payload.length)) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt index be695f2e8..778f084d1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt @@ -1,13 +1,106 @@ package ru.dbotthepony.mc.otm.network +import it.unimi.dsi.fastutil.io.FastByteArrayInputStream +import it.unimi.dsi.fastutil.objects.Object2ObjectFunction +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap +import net.minecraft.core.BlockPos +import net.minecraft.network.FriendlyByteBuf +import net.minecraft.world.level.Level import net.minecraftforge.network.NetworkDirection +import net.minecraftforge.network.NetworkEvent +import org.apache.logging.log4j.LogManager +import ru.dbotthepony.mc.otm.android.feature.ItemEntityDataPacket +import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity +import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.client.onceClient import ru.dbotthepony.mc.otm.item.QuantumBatteryItem +import java.util.* +import java.util.function.Supplier +import kotlin.collections.ArrayList + +class BlockEntitySyncPacket(val position: BlockPos, val buffer: ByteArray, val validBytes: Int) : MatteryPacket { + override fun write(buff: FriendlyByteBuf) { + buff.writeBlockPos(position) + buff.writeBytes(buffer, 0, validBytes) + } + + private fun execute() { + val level = minecraft.player?.level() + + if (level == null) { + LOGGER.error("Received BlockEntitySyncPacket before we are in valid level.") + + onceClient { + execute() + } + + return + } + + val blockEntity = level.getBlockEntity(position) + + if (blockEntity == null) { + LOGGER.warn("Putting BlockEntitySyncPacket received for $position into backlog because there is literally no block entity there!") + LOGGER.warn("This is CERTAINLY a bug in one of optimizing mods you have or server has installed!") + LOGGER.warn("This can cause memory leak.") + + backlog.computeIfAbsent(level) { Object2ObjectOpenHashMap() } + .computeIfAbsent(position, Object2ObjectFunction { ArrayList() }) + .add(this) + + return + } else if (blockEntity !is MatteryBlockEntity) { + LOGGER.warn("Dropping BlockEntitySyncPacket received for $position, because there is $blockEntity which is not MatteryBlockEntity!") + backlog[level]?.remove(position) + return + } + + val packets = backlog[level]?.remove(position) + + try { + if (packets != null) { + for (packet in packets) { + blockEntity.synchronizer.read(FastByteArrayInputStream(packet.buffer, 0, packet.validBytes)) + } + } + + blockEntity.synchronizer.read(FastByteArrayInputStream(buffer, 0, validBytes)) + } catch(err: Throwable) { + LOGGER.error("Exception while reading synchronized BlockEntity data!\nPosition: $position\nBlock: ${level.getBlockState(position)}\nBlock entity: $blockEntity", err) + } + } + + override fun play(context: Supplier) { + context.packetHandled = true + + context.enqueueWork { + execute() + } + } + + companion object { + private val backlog = WeakHashMap>>() + + fun read(buff: FriendlyByteBuf): BlockEntitySyncPacket { + val position = buff.readBlockPos() + val size = buff.readableBytes() + val array = ByteArray(size) + buff.readBytes(array) + return BlockEntitySyncPacket(position, array, size) + } + + private val LOGGER = LogManager.getLogger() + } +} object GenericNetworkChannel : MatteryNetworkChannel( - version = "1", + version = "2", name = "generic" ) { fun register() { add(QuantumBatteryItem.ChargePacket::class.java, QuantumBatteryItem.Companion::readPacket, NetworkDirection.PLAY_TO_CLIENT) + + add(BlockEntitySyncPacket::class.java, BlockEntitySyncPacket.Companion::read, NetworkDirection.PLAY_TO_CLIENT) + add(ItemEntityDataPacket::class.java, ItemEntityDataPacket.Companion::read, NetworkDirection.PLAY_TO_CLIENT) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt deleted file mode 100644 index a0ef27a75..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/WorldNetworkChannel.kt +++ /dev/null @@ -1,103 +0,0 @@ -package ru.dbotthepony.mc.otm.network - -import it.unimi.dsi.fastutil.io.FastByteArrayInputStream -import it.unimi.dsi.fastutil.objects.Object2ObjectFunction -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap -import net.minecraft.core.BlockPos -import net.minecraft.network.FriendlyByteBuf -import net.minecraft.world.level.Level -import net.minecraftforge.network.NetworkDirection -import net.minecraftforge.network.NetworkEvent -import org.apache.logging.log4j.LogManager -import ru.dbotthepony.mc.otm.android.feature.ItemEntityDataPacket -import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity -import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.client.onceClient -import java.lang.ref.SoftReference -import java.util.WeakHashMap -import java.util.function.Supplier - -class BlockEntitySyncPacket(val position: BlockPos, val buffer: ByteArray, val validBytes: Int) : MatteryPacket { - override fun write(buff: FriendlyByteBuf) { - buff.writeBlockPos(position) - buff.writeBytes(buffer, 0, validBytes) - } - - private fun execute() { - val level = minecraft.player?.level() - - if (level == null) { - LOGGER.error("Received BlockEntitySyncPacket before we are in valid level.") - - onceClient { - execute() - } - - return - } - - val blockEntity = level.getBlockEntity(position) - - if (blockEntity == null) { - LOGGER.warn("Putting BlockEntitySyncPacket received for $position into backlog because there is literally no block entity there!") - LOGGER.warn("This is CERTAINLY a bug in one of optimizing mods you have or server has installed!") - LOGGER.warn("This can cause memory leak.") - - backlog.computeIfAbsent(level) { Object2ObjectOpenHashMap() } - .computeIfAbsent(position, Object2ObjectFunction { ArrayList() }) - .add(this) - - return - } else if (blockEntity !is MatteryBlockEntity) { - LOGGER.warn("Dropping BlockEntitySyncPacket received for $position, because there is $blockEntity which is not MatteryBlockEntity!") - backlog[level]?.remove(position) - return - } - - val packets = backlog[level]?.remove(position) - - try { - if (packets != null) { - for (packet in packets) { - blockEntity.synchronizer.read(FastByteArrayInputStream(packet.buffer, 0, packet.validBytes)) - } - } - - blockEntity.synchronizer.read(FastByteArrayInputStream(buffer, 0, validBytes)) - } catch(err: Throwable) { - LOGGER.error("Exception while reading synchronized BlockEntity data!\nPosition: $position\nBlock: ${level.getBlockState(position)}\nBlock entity: $blockEntity", err) - } - } - - override fun play(context: Supplier) { - context.packetHandled = true - - context.enqueueWork { - execute() - } - } - - companion object { - private val backlog = WeakHashMap>>() - - fun read(buff: FriendlyByteBuf): BlockEntitySyncPacket { - val position = buff.readBlockPos() - val size = buff.readableBytes() - val array = ByteArray(size) - buff.readBytes(array) - return BlockEntitySyncPacket(position, array, size) - } - - private val LOGGER = LogManager.getLogger() - } -} - -object WorldNetworkChannel : MatteryNetworkChannel( - version = "4", - name = "world" -) { - fun register() { - add(BlockEntitySyncPacket::class.java, BlockEntitySyncPacket.Companion::read, NetworkDirection.PLAY_TO_CLIENT) - add(ItemEntityDataPacket::class.java, ItemEntityDataPacket.Companion::read, NetworkDirection.PLAY_TO_CLIENT) - } -} From e5d324f4fac92040db2f52debc642f98d61e8dff Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 29 Jul 2023 17:06:46 +0700 Subject: [PATCH 0883/1199] Get rid of registry network channel and merge it into generic network channel --- .../dbotthepony/mc/otm/OverdriveThatMatters.java | 1 - .../mc/otm/android/AndroidResearchManager.kt | 6 +++--- .../ru/dbotthepony/mc/otm/matter/MatterManager.kt | 4 ++-- .../mc/otm/network/GenericNetworkChannel.kt | 7 ++++++- .../mc/otm/network/RegistryNetworkChannel.kt | 15 --------------- 5 files changed, 11 insertions(+), 22 deletions(-) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/network/RegistryNetworkChannel.kt diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 4161c855d..641f7c3b9 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -201,7 +201,6 @@ public final class OverdriveThatMatters { MatteryPlayerNetworkChannel.INSTANCE.register(); MenuNetworkChannel.INSTANCE.register(); WeaponNetworkChannel.INSTANCE.register(); - RegistryNetworkChannel.INSTANCE.register(); GenericNetworkChannel.INSTANCE.register(); ITEM_STORAGE = StorageRegistry.register(ItemStackWrapper.class, ItemStackWrapper.EMPTY, new Decimal("3.125")); diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchManager.kt index 7062117f1..654d97ca4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchManager.kt @@ -25,8 +25,8 @@ import ru.dbotthepony.mc.otm.core.fromJsonStrict import ru.dbotthepony.mc.otm.core.fromNetwork import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.core.toNetwork +import ru.dbotthepony.mc.otm.network.GenericNetworkChannel import ru.dbotthepony.mc.otm.network.MatteryPacket -import ru.dbotthepony.mc.otm.network.RegistryNetworkChannel import ru.dbotthepony.mc.otm.network.enqueueWork import ru.dbotthepony.mc.otm.network.packetHandled import ru.dbotthepony.mc.otm.onceServer @@ -102,9 +102,9 @@ object AndroidResearchManager : SimpleJsonResourceReloadListener(GsonBuilder().s val packet = SyncPacket(researchMap.values) if (event.player != null) { - RegistryNetworkChannel.send(event.player!!, packet) + GenericNetworkChannel.send(event.player!!, packet) } else { - RegistryNetworkChannel.send(PacketDistributor.ALL.noArg(), packet) + GenericNetworkChannel.send(PacketDistributor.ALL.noArg(), packet) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index f033af5ad..298cf1383 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -93,8 +93,8 @@ import ru.dbotthepony.mc.otm.core.util.writeBinaryComponent import ru.dbotthepony.mc.otm.core.util.writeCollection import ru.dbotthepony.mc.otm.core.writeItemType import ru.dbotthepony.mc.otm.milliTime +import ru.dbotthepony.mc.otm.network.GenericNetworkChannel import ru.dbotthepony.mc.otm.network.MatteryPacket -import ru.dbotthepony.mc.otm.network.RegistryNetworkChannel import ru.dbotthepony.mc.otm.registry.RegistryDelegate import ru.dbotthepony.mc.otm.secondTime import ru.dbotthepony.mc.otm.storage.ItemStackWrapper @@ -1705,7 +1705,7 @@ object MatterManager { LOGGER.debug("Encoding matter registry packet took ${time.millis}ms, (${stream.length} bytes total, $totalSize bytes compressed)") for (chunk in chunks) { - RegistryNetworkChannel.send(distributor, chunk) + GenericNetworkChannel.send(distributor, chunk) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt index 778f084d1..c98aa769d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt @@ -9,11 +9,13 @@ import net.minecraft.world.level.Level import net.minecraftforge.network.NetworkDirection import net.minecraftforge.network.NetworkEvent import org.apache.logging.log4j.LogManager +import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.feature.ItemEntityDataPacket import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.onceClient import ru.dbotthepony.mc.otm.item.QuantumBatteryItem +import ru.dbotthepony.mc.otm.matter.MatterManager import java.util.* import java.util.function.Supplier import kotlin.collections.ArrayList @@ -94,7 +96,7 @@ class BlockEntitySyncPacket(val position: BlockPos, val buffer: ByteArray, val v } object GenericNetworkChannel : MatteryNetworkChannel( - version = "2", + version = "3", name = "generic" ) { fun register() { @@ -102,5 +104,8 @@ object GenericNetworkChannel : MatteryNetworkChannel( add(BlockEntitySyncPacket::class.java, BlockEntitySyncPacket.Companion::read, NetworkDirection.PLAY_TO_CLIENT) add(ItemEntityDataPacket::class.java, ItemEntityDataPacket.Companion::read, NetworkDirection.PLAY_TO_CLIENT) + + add(AndroidResearchManager.SyncPacket::class.java, AndroidResearchManager::readSyncPacket, NetworkDirection.PLAY_TO_CLIENT) + add(MatterManager.SyncPacket::class.java, MatterManager::readSyncPacket, NetworkDirection.PLAY_TO_CLIENT) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/RegistryNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/RegistryNetworkChannel.kt deleted file mode 100644 index 8106c4a41..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/RegistryNetworkChannel.kt +++ /dev/null @@ -1,15 +0,0 @@ -package ru.dbotthepony.mc.otm.network - -import net.minecraftforge.network.NetworkDirection -import ru.dbotthepony.mc.otm.android.AndroidResearchManager -import ru.dbotthepony.mc.otm.matter.MatterManager - -object RegistryNetworkChannel : MatteryNetworkChannel( - version = "2", - name = "registry" -) { - fun register() { - add(AndroidResearchManager.SyncPacket::class.java, AndroidResearchManager::readSyncPacket, NetworkDirection.PLAY_TO_CLIENT) - add(MatterManager.SyncPacket::class.java, MatterManager::readSyncPacket, NetworkDirection.PLAY_TO_CLIENT) - } -} From 232701b8bbbb0cba6b2b16322162ca8fbe3895fc Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 29 Jul 2023 17:28:08 +0700 Subject: [PATCH 0884/1199] Fix ComputedField being unable to properly handle nullable types --- .../network/synchronizer/FieldSynchronizer.kt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt index 0c5a96766..4df86bf24 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt @@ -1012,8 +1012,8 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa private val codec: IStreamCodec, private val observer: (new: V) -> Unit = {} ) : AbstractField(), IField { - private var remote: V? = null - private var clientValue: V? = null + private var remote: Any? = Mark + private var clientValue: Any? = Mark init { observers.add(this) @@ -1024,7 +1024,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa val value = value - if (!isDirty && (remote == null || !codec.compare(remote ?: throw ConcurrentModificationException(), value))) { + if (!isDirty && (remote === Mark || !codec.compare(remote as V, value))) { notifyEndpoints(this) isDirty = true remote = codec.copy(value) @@ -1034,7 +1034,15 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } override val value: V - get() = clientValue ?: getter.invoke() + get() { + val clientValue = clientValue + + if (clientValue === Mark) { + return getter.invoke() + } else { + return clientValue as V + } + } override fun write(stream: DataOutputStream, endpoint: Endpoint) { check(!isRemoved) { "Field was removed" } From 1a9877a49de86695d81e3642bf59eea711bf7310 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 29 Jul 2023 17:43:20 +0700 Subject: [PATCH 0885/1199] Add exopack charge slots to all guis --- .../client/screen/ExoPackInventoryScreen.kt | 35 +------------- .../mc/otm/client/screen/MatteryScreen.kt | 48 +++++++++++++++++++ .../mc/otm/menu/ExoPackInventoryMenu.kt | 10 ---- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 15 ++++++ 4 files changed, 64 insertions(+), 44 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt index b6a00fb0b..2396017ca 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt @@ -199,40 +199,7 @@ class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen(menu: T, inventory: Inventory, tit } } + protected fun makeChargePanels(frame: EditablePanel<*>) { + val chargeWidth = HorizontalPowerGaugePanel.GAUGE_BACKGROUND_TALL.width + AbstractSlotPanel.SIZE + 6f + ProgressGaugePanel.GAUGE_BACKGROUND.width * 2f + val chargeStrip = BackgroundPanel.paddedCenter(this, frame, frame.width - chargeWidth - 6f, frame.height + 2f, chargeWidth, AbstractSlotPanel.SIZE) + val chargeStrip2 = BackgroundPanel.paddedCenter(this, frame, frame.width + 2f, frame.height - AbstractSlotPanel.SIZE * 3f + 2f, AbstractSlotPanel.SIZE, AbstractSlotPanel.SIZE * 4f) + + chargeStrip.customDock { chargeStrip.setPos(frame.width - chargeWidth - 6f, frame.height + 2f) } + chargeStrip2.customDock { chargeStrip2.setPos(frame.width + 2f, frame.height - AbstractSlotPanel.SIZE * 3f + 2f) } + + BatterySlotPanel(this, chargeStrip, menu.exopackChargeSlots[0]).also { + it.dock = Dock.LEFT + } + + SpritePanel(this, chargeStrip, ProgressGaugePanel.GAUGE_BACKGROUND).also { + it.dock = Dock.LEFT + it.dockLeft = 2f + it.dockResize = DockResizeMode.NONE + } + + TallHorizontalProfiledPowerGaugePanel(this, chargeStrip, menu.exopackPowerLevel).also { + it.dock = Dock.LEFT + it.dockLeft = 2f + } + + SpritePanel(this, chargeStrip, ProgressGaugePanel.GAUGE_BACKGROUND).also { + it.dock = Dock.LEFT + it.dockLeft = 2f + it.dockResize = DockResizeMode.NONE + } + + for (slot in menu.exopackChargeSlots.listIterator(1)) { + SlotPanel(this, chargeStrip2, slot).also { + it.dock = Dock.BOTTOM + it.slotBackground = Widgets18.CHARGE_SLOT_BACKGROUND + } + } + } + init { if (menu.playerInventorySlots.isNotEmpty() && menu.autoCreateInventoryFrame) { if (menu.playerExoSuitSlots.isEmpty()) { @@ -239,6 +283,10 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit moveMousePosScaled(y = movePixels) } } + + if (menu.exopackChargeSlots.isNotEmpty()) { + makeChargePanels(inventoryFrame!!) + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt index ccf112f43..50d3313bd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt @@ -132,21 +132,11 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen } val furnaceProgress = capability.smelters.map { ProgressGaugeWidget(mSynchronizer, it) } - val exoPackPowerSlot = BatterySlot(capability.exoPackEnergy.parent, 0) - val exoPackPower = ProfiledLevelGaugeWidget(mSynchronizer, capability.exoPackEnergy) - val furnaceMenuOpenState = InstantBooleanInput(this) - val exoPackChargeSlots = makeSlots(capability.exoPackChargeSlots, ::ChargeSlot) - init { addStorageSlot(furnaceInputs, condition = furnaceMenuOpenState) addStorageSlot(furnaceOutputs, condition = furnaceMenuOpenState) - - addSlot(exoPackPowerSlot) - mapQuickMoveToInventory(exoPackPowerSlot) - - exoPackChargeSlots.forEach { addSlot(it); mapQuickMoveToInventory(it) } } private var isRemoved = false diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 4986ce750..2c8394a8d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -27,6 +27,7 @@ import net.minecraftforge.network.PacketDistributor import ru.dbotthepony.mc.otm.capability.IMatteryUpgrade import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.UpgradeType +import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.compat.cos.cosmeticArmorSlots @@ -49,6 +50,7 @@ import ru.dbotthepony.mc.otm.core.util.ItemValueCodec import ru.dbotthepony.mc.otm.core.util.NullValueCodec import ru.dbotthepony.mc.otm.core.util.VarIntValueCodec import ru.dbotthepony.mc.otm.menu.input.InstantBooleanInput +import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.MenuFieldPacket import ru.dbotthepony.mc.otm.network.MenuNetworkChannel @@ -67,6 +69,7 @@ import java.util.function.DoubleSupplier import java.util.function.IntSupplier import java.util.function.Predicate import java.util.function.Supplier +import kotlin.collections.ArrayList data class PlayerSlot(val functional: A, val cosmetic: B? = null) @@ -104,6 +107,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( private val _playerMainSlots = ArrayList() private val _playerExoSuitSlots = ArrayList() private val _playerCombinedInventorySlots = ArrayList() + private val _exopackChargeSlots = ArrayList() private val playerInputs = ArrayList>() @@ -212,6 +216,10 @@ abstract class MatteryMenu @JvmOverloads protected constructor( */ val playerCombinedInventorySlots: List = Collections.unmodifiableList(_playerCombinedInventorySlots) + val exopackChargeSlots: List = Collections.unmodifiableList(_exopackChargeSlots) + + val exopackPowerLevel = ProfiledLevelGaugeWidget>(mSynchronizer) + var autoCreateInventoryFrame = true private set @@ -360,6 +368,13 @@ abstract class MatteryMenu @JvmOverloads protected constructor( mapQuickMoveToExternal(slot) addSlot(slot) } + + _exopackChargeSlots.add(BatterySlot(mattery.exoPackEnergy.parent, 0).also { mapQuickMoveToExternal(it); mapQuickMoveToInventory(it); addSlot(it) }) + + for (i in 0 until mattery.exoPackChargeSlots.containerSize) + _exopackChargeSlots.add(ChargeSlot(mattery.exoPackChargeSlots, i).also { mapQuickMoveToExternal(it); mapQuickMoveToInventory(it); addSlot(it) }) + + exopackPowerLevel.with(mattery.exoPackEnergy) } for (i in 0..8) { From dde37bc502c0006cb310f3cd821cf00de5808916 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 29 Jul 2023 17:50:42 +0700 Subject: [PATCH 0886/1199] Fix frame tabs being too wide --- .../dbotthepony/mc/otm/client/screen/panels/FramePanel.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index 90325961a..eeaa31da3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -32,7 +32,7 @@ open class FramePanel( var onClose: Runnable? = null, var activeIcon: IGUIRenderable? = null, var inactiveIcon: IGUIRenderable? = null, - ) : AbstractButtonPanel(this@FramePanel.screen, this@FramePanel, 0f, 0f, 28f, 28f) { + ) : AbstractButtonPanel(this@FramePanel.screen, this@FramePanel, 0f, 0f, 26f, 28f) { var isActive = tabs.isEmpty() init { @@ -81,7 +81,7 @@ open class FramePanel( } } - activeIcon?.render(graphics, x = width / 2f - 1f, y = height / 2f + 1f, gravity = RenderGravity.CENTER_CENTER) + activeIcon?.render(graphics, x = width / 2f, y = height / 2f + 1f, gravity = RenderGravity.CENTER_CENTER) } else { if (tabIndex() == 0) { if (isDisabled) { @@ -105,7 +105,7 @@ open class FramePanel( } } - inactiveIcon?.render(graphics, x = width / 2f - 1f, y = height / 2f + 1f, gravity = RenderGravity.CENTER_CENTER) + inactiveIcon?.render(graphics, x = width / 2f, y = height / 2f + 1f, gravity = RenderGravity.CENTER_CENTER) } } From 2afc01414bf79224115f341532202039111eaa9d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 29 Jul 2023 17:57:59 +0700 Subject: [PATCH 0887/1199] Add offhand slot to all menus when exopack has at least 1 extra slot --- .../client/screen/ExoPackInventoryScreen.kt | 2 +- .../mc/otm/client/screen/MatteryScreen.kt | 6 +++++- .../mc/otm/menu/ExoPackInventoryMenu.kt | 21 ------------------- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 12 +++++++++++ 4 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt index 2396017ca..302e1f3f6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt @@ -103,7 +103,7 @@ class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen(menu: T, inventory: Inventory, tit val hotbarStrip = EditablePanel(this, inventoryFrame, height = AbstractSlotPanel.SIZE) hotbarStrip.dock = Dock.BOTTOM + val offhand = SlotPanel(this, hotbarStrip, menu.offhandSlot!!) + offhand.dock = Dock.RIGHT + for (slot in menu.playerHotbarSlots) { InventorySlotPanel(this, hotbarStrip, slot).also { it.dock = Dock.LEFT @@ -267,6 +270,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit inventoryScrollbar.parent = slotListCanvas inventoryScrollbar.dock = Dock.RIGHT + inventoryScrollbar.dockRight = 2f inventoryScrollbar.scroll = lastScroll @@ -653,7 +657,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit const val DEFAULT_FRAME_HEIGHT = 100f const val INVENTORY_FRAME_WIDTH = DEFAULT_FRAME_WIDTH - const val INVENTORY_FRAME_WIDTH_EXTENDED = DEFAULT_FRAME_WIDTH + ScrollBarConstants.WIDTH + 2f + const val INVENTORY_FRAME_WIDTH_EXTENDED = DEFAULT_FRAME_WIDTH + ScrollBarConstants.WIDTH + 6f const val INVENTORY_FRAME_HEIGHT = 3f * AbstractSlotPanel.SIZE + AbstractSlotPanel.SIZE + 24f const val BASE_INVENTORY_FRAME_HEIGHT = AbstractSlotPanel.SIZE + 24f diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt index 50d3313bd..744eea904 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt @@ -71,28 +71,7 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen craftingSlots.forEach(this::addSlot) } - val offhandSlot = object : InventorySlot(capability.ply.inventory, 40) { - override fun getNoItemIcon(): Pair { - return Pair.of(InventoryMenu.BLOCK_ATLAS, InventoryMenu.EMPTY_ARMOR_SLOT_SHIELD) - } - } - val armorSlots = makeArmorSlots() - val allAccessibleSlots: List - - init { - mapQuickMove(offhandSlot, playerInventorySlots) - addSlot(offhandSlot) - - val builder = ImmutableList.builder() - - builder.addAll(playerInventorySlots) - builder.addAll(craftingSlots) - builder.add(offhandSlot) - - allAccessibleSlots = builder.build() - } - val curiosSlots: ImmutableList> = ImmutableList.copyOf(ply.curiosSlots) init { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 2c8394a8d..b775f81d7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -220,6 +220,9 @@ abstract class MatteryMenu @JvmOverloads protected constructor( val exopackPowerLevel = ProfiledLevelGaugeWidget>(mSynchronizer) + var offhandSlot: InventorySlot? = null + protected set + var autoCreateInventoryFrame = true private set @@ -340,6 +343,15 @@ abstract class MatteryMenu @JvmOverloads protected constructor( check(_playerInventorySlots.isEmpty()) { "Already created inventory slots" } autoCreateInventoryFrame = autoFrame + offhandSlot = object : InventorySlot(inventory, 40) { + override fun getNoItemIcon(): Pair { + return Pair.of(InventoryMenu.BLOCK_ATLAS, InventoryMenu.EMPTY_ARMOR_SLOT_SHIELD) + } + } + + mapQuickMoveToInventory(offhandSlot!!) + addSlot(offhandSlot!!) + for (i in 9 .. 35) { val slot = InventorySlot(inventory, i) From 9aa2f63a6d0b88a31005361e21a5b1bd702e448e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 29 Jul 2023 18:05:54 +0700 Subject: [PATCH 0888/1199] Decapitalize "p" in "Exopack" --- .../mc/otm/datagen/loot/LootModifiersData.kt | 25 ++-- .../mc/otm/client/model/ExosuitModel.java | 2 +- .../mc/otm/mixin/MixinInventory.java | 4 +- .../ru/dbotthepony/mc/otm/capability/Ext.kt | 10 +- .../otm/capability/MatteryPlayerCapability.kt | 116 +++++++++--------- .../mc/otm/client/ClientEventHandler.kt | 10 +- .../client/screen/ExoPackInventoryScreen.kt | 8 +- .../mc/otm/client/screen/MatteryScreen.kt | 4 +- .../screen/panels/EntityRendererPanel.kt | 4 +- .../mc/otm/compat/ExtendedInventoryHandler.kt | 8 +- .../otm/data/condition/HasExoPackCondition.kt | 2 +- ...m.kt => AbstractExopackSlotUpgradeItem.kt} | 20 +-- ...xoPackProbeItem.kt => ExopackProbeItem.kt} | 12 +- ...gradeItem.kt => ExopackSlotUpgradeItem.kt} | 2 +- .../mc/otm/item/exopack/ExopackUpgradeItem.kt | 6 +- ...kt => ProceduralExopackSlotUpgradeItem.kt} | 3 +- .../mc/otm/menu/ExoPackInventoryMenu.kt | 15 +-- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 24 ++-- .../network/MatteryPlayerNetworkChannel.kt | 21 ++-- .../mc/otm/registry/MItemFunctionTypes.kt | 4 +- .../ru/dbotthepony/mc/otm/registry/MItems.kt | 22 ++-- 21 files changed, 153 insertions(+), 169 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/{AbstractExoPackSlotUpgradeItem.kt => AbstractExopackSlotUpgradeItem.kt} (86%) rename src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/{ExoPackProbeItem.kt => ExopackProbeItem.kt} (90%) rename src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/{ExoPackSlotUpgradeItem.kt => ExopackSlotUpgradeItem.kt} (94%) rename src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/{ProceduralExoPackSlotUpgradeItem.kt => ProceduralExopackSlotUpgradeItem.kt} (96%) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootModifiersData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootModifiersData.kt index cd236189d..3131627ab 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootModifiersData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootModifiersData.kt @@ -4,7 +4,6 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.util.valueproviders.UniformInt import net.minecraft.world.entity.EntityType import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.Rarity import net.minecraft.world.level.storage.loot.BuiltInLootTables import net.minecraft.world.level.storage.loot.predicates.LootItemCondition import net.minecraftforge.common.loot.LootTableIdCondition @@ -16,7 +15,7 @@ import ru.dbotthepony.mc.otm.data.condition.ItemInInventoryCondition import ru.dbotthepony.mc.otm.data.condition.KilledByRealPlayerOrIndirectly import ru.dbotthepony.mc.otm.data.loot.LootPoolAppender import ru.dbotthepony.mc.otm.item.ProceduralBatteryItem -import ru.dbotthepony.mc.otm.item.exopack.ProceduralExoPackSlotUpgradeItem +import ru.dbotthepony.mc.otm.item.exopack.ProceduralExopackSlotUpgradeItem import ru.dbotthepony.mc.otm.registry.MItems @Suppress("FunctionName") @@ -35,12 +34,12 @@ fun addLootModifiers(it: LootModifiers) { singleItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL) { chanceCondition(0.2) - apply(ProceduralExoPackSlotUpgradeItem.Randomizer(UniformInt.of(6, 9))) + apply(ProceduralExopackSlotUpgradeItem.Randomizer(UniformInt.of(6, 9))) }, singleItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL) { chanceCondition(0.05) - apply(ProceduralExoPackSlotUpgradeItem.Randomizer(UniformInt.of(9, 18))) + apply(ProceduralExopackSlotUpgradeItem.Randomizer(UniformInt.of(9, 18))) }, )) @@ -49,12 +48,12 @@ fun addLootModifiers(it: LootModifiers) { singleItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL) { chanceCondition(0.1) - apply(ProceduralExoPackSlotUpgradeItem.Randomizer(UniformInt.of(4, 8))) + apply(ProceduralExopackSlotUpgradeItem.Randomizer(UniformInt.of(4, 8))) }, singleItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL) { chanceCondition(0.1) - apply(ProceduralExoPackSlotUpgradeItem.Randomizer(UniformInt.of(4, 10))) + apply(ProceduralExopackSlotUpgradeItem.Randomizer(UniformInt.of(4, 10))) }, singleItem(MItems.PROCEDURAL_BATTERY) { @@ -73,12 +72,12 @@ fun addLootModifiers(it: LootModifiers) { singleItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL) { chanceCondition(0.1) - apply(ProceduralExoPackSlotUpgradeItem.Randomizer(UniformInt.of(12, 18))) + apply(ProceduralExopackSlotUpgradeItem.Randomizer(UniformInt.of(12, 18))) }, singleItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL) { chanceCondition(0.25) - apply(ProceduralExoPackSlotUpgradeItem.Randomizer(UniformInt.of(4, 9))) + apply(ProceduralExopackSlotUpgradeItem.Randomizer(UniformInt.of(4, 9))) }, )) @@ -87,12 +86,12 @@ fun addLootModifiers(it: LootModifiers) { singleItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL) { chanceCondition(0.15) - apply(ProceduralExoPackSlotUpgradeItem.Randomizer(UniformInt.of(9, 18))) + apply(ProceduralExopackSlotUpgradeItem.Randomizer(UniformInt.of(9, 18))) }, singleItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL) { chanceCondition(0.35) - apply(ProceduralExoPackSlotUpgradeItem.Randomizer(UniformInt.of(16, 28), UniformInt.of(2, 6))) + apply(ProceduralExopackSlotUpgradeItem.Randomizer(UniformInt.of(16, 28), UniformInt.of(2, 6))) }, )) @@ -101,17 +100,17 @@ fun addLootModifiers(it: LootModifiers) { singleItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL) { chanceCondition(0.4) - apply(ProceduralExoPackSlotUpgradeItem.Randomizer(UniformInt.of(9, 18))) + apply(ProceduralExopackSlotUpgradeItem.Randomizer(UniformInt.of(9, 18))) }, singleItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL) { chanceCondition(0.2) - apply(ProceduralExoPackSlotUpgradeItem.Randomizer(UniformInt.of(14, 27), UniformInt.of(2, 6))) + apply(ProceduralExopackSlotUpgradeItem.Randomizer(UniformInt.of(14, 27), UniformInt.of(2, 6))) }, singleItem(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL) { chanceCondition(0.1) - apply(ProceduralExoPackSlotUpgradeItem.Randomizer(UniformInt.of(27, 56), UniformInt.of(2, 6))) + apply(ProceduralExopackSlotUpgradeItem.Randomizer(UniformInt.of(27, 56), UniformInt.of(2, 6))) }, )) diff --git a/src/main/java/ru/dbotthepony/mc/otm/client/model/ExosuitModel.java b/src/main/java/ru/dbotthepony/mc/otm/client/model/ExosuitModel.java index fa3b2878a..00d07f7d8 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/client/model/ExosuitModel.java +++ b/src/main/java/ru/dbotthepony/mc/otm/client/model/ExosuitModel.java @@ -123,7 +123,7 @@ public final class ExosuitModel { return; } - if (cap.resolve().get().getHasExoPack() && cap.resolve().get().getDisplayExoPack()) { + if (cap.resolve().get().getHasExopack() && cap.resolve().get().getDisplayExopack()) { var model = getParentModel(); model.copyPropertiesTo(modelNormal); model.copyPropertiesTo(modelGlow); diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinInventory.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinInventory.java index b2104d243..0b9a709b3 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinInventory.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinInventory.java @@ -79,10 +79,10 @@ public class MixinInventory { ) private void clearOrCountMatchingItems(Predicate predicate, int count, Container container, CallbackInfoReturnable cir) { player.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresent(it -> { - if (!it.getHasExoPack()) return; + if (!it.getHasExopack()) return; int i = cir.getReturnValue(); - i += ContainerHelper.clearOrCountMatchingItems(it.getExoPackContainer(), predicate, count - i, count == 0); + i += ContainerHelper.clearOrCountMatchingItems(it.getExopackContainer(), predicate, count - i, count == 0); cir.setReturnValue(i); }); diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt index 414a3fbcc..c81c4c3bc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.capability import com.google.common.collect.Streams -import earth.terrarium.botarium.common.registry.fluid.FluidSounds import net.minecraft.ChatFormatting import net.minecraft.core.Direction import net.minecraft.network.chat.Component @@ -36,7 +35,6 @@ import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.core.util.formatFluidLevel import java.util.IdentityHashMap -import java.util.LinkedList import java.util.stream.Stream private val LOGGER = LogManager.getLogger() @@ -226,8 +224,8 @@ fun Player.itemsStream(includeCosmetics: Boolean = true): Stream streams.add(inventory.stream()) matteryPlayer?.let { - if (it.hasExoPack) { - streams.add(it.exoPackContainer.stream()) + if (it.hasExopack) { + streams.add(it.exopackContainer.stream()) } } @@ -273,8 +271,8 @@ fun Player.awareItemsStream(includeCosmetics: Boolean = false): Stream + var hasExopack by publicSynchronizer.bool(setter = setter@{ value, access, _ -> access.write(value) if (value && ply is ServerPlayer) { @@ -209,7 +209,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial /** * Whenever to render Exopack on player */ - var displayExoPack by publicSynchronizer.bool(true).property + var displayExopack by publicSynchronizer.bool(true).property /** * Whenever to render Exopack glow in dark @@ -228,7 +228,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial valueCodec = IntValueCodec, backingMap = HashMap(), callback = { - this.exoPackSlotModifier.recompute() + this.exopackSlotModifier.recompute() }, ) @@ -237,11 +237,11 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial * * If you want to properly extend Exopack suit capacity, add your value into this map */ - val exoPackSlotModifier = UUIDIntModifiersMap(observer = observer@{ + val exopackSlotModifier = UUIDIntModifiersMap(observer = observer@{ if (it < 0) { - exoPackContainer = PlayerMatteryContainer(0) + exopackContainer = PlayerMatteryContainer(0) } else { - exoPackContainer = PlayerMatteryContainer(it) + exopackContainer = PlayerMatteryContainer(it) } }, backingMap = this.exoPackSlotModifierMap) @@ -273,7 +273,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial /** * Exopack container, which actually store items inside Exopack */ - var exoPackContainer: MatteryContainer = PlayerMatteryContainer(0) + var exopackContainer: MatteryContainer = PlayerMatteryContainer(0) private set(value) { _exoPackMenu = null field.removeFilterSynchronizer() @@ -298,7 +298,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial /** * Whenever Exopack has 3x3 crafting grid upgrade installed */ - var isExoPackCraftingUpgraded by publicSynchronizer.bool(setter = setter@{ value, access, _ -> + var isExopackCraftingUpgraded by publicSynchronizer.bool(setter = setter@{ value, access, _ -> if (value != access.readBoolean()) { access.write(value) _exoPackMenu = null @@ -400,7 +400,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial /** * Whenever player has exosuit smelting upgrade */ - var isExoPackSmeltingInstalled by synchronizer.bool(setter = { value, access, _ -> + var isExopackSmeltingInstalled by synchronizer.bool(setter = { value, access, _ -> if (value != access.readBoolean()) { access.write(value) _exoPackMenu = null @@ -413,7 +413,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial inner class SmelterBelt(index: Int) : MachineJobEventLoop(ItemJob.CODEC) { override val energy: IMatteryEnergyStorage - get() = exoPackEnergy + get() = exopackEnergy override val isBlockedByRedstone: Boolean get() = false @@ -422,7 +422,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial override fun onJobFinish(status: JobStatus) { if (output.fullyAddItem(status.job.itemStack)) { - exoPackSmelterExperience += status.job.experience + exopackSmelterExperience += status.job.experience } else { status.noItem() } @@ -431,7 +431,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial private val cache = RecipeManager.createCheck(RecipeType.SMELTING) override fun computeNextJob(): JobContainer { - if (!exoPackEnergy.batteryLevel.isPositive) return JobContainer.noEnergy() + if (!exopackEnergy.batteryLevel.isPositive) return JobContainer.noEnergy() val level = ply.level() as? ServerLevel ?: return JobContainer.failure() val recipe = cache.getRecipeFor(input, level) @@ -461,7 +461,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial val smelter2 = SmelterBelt(2) val smelters = listOf(smelter0, smelter1, smelter2) - var exoPackSmelterExperience = 0f + var exopackSmelterExperience = 0f /** * [IMatteryEnergyStorage] instance, representing Android' battery charge @@ -471,9 +471,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial /** * [IMatteryEnergyStorage] instance, representing Exopack battery charge */ - val exoPackEnergy = ProfiledEnergyStorage(BatteryBackedEnergyStorage(ply, synchronizer, Decimal.ZERO, ExopackConfig.ENERGY_CAPACITY, false, onChange = { for (v in smelters) v.notify(MachineJobEventLoop.IdleReason.POWER) })) + val exopackEnergy = ProfiledEnergyStorage(BatteryBackedEnergyStorage(ply, synchronizer, Decimal.ZERO, ExopackConfig.ENERGY_CAPACITY, false, onChange = { for (v in smelters) v.notify(MachineJobEventLoop.IdleReason.POWER) })) - val exoPackChargeSlots = MatteryContainer(4) + val exopackChargeSlots = MatteryContainer(4) init { savetables.int(::ticksIExist) @@ -483,22 +483,22 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial savetables.bool(::wasInLiquid) savetables.bool(::isAndroid) savetables.bool(::willBecomeAndroid) - savetables.bool(::hasExoPack, "hasExoSuit") - savetables.bool(::displayExoPack, "displayExoSuit") - savetables.bool(::isExoPackCraftingUpgraded, "isExoSuitCraftingUpgraded") + savetables.bool(::hasExopack, "hasExoSuit") + savetables.bool(::displayExopack, "displayExoSuit") + savetables.bool(::isExopackCraftingUpgraded, "isExoSuitCraftingUpgraded") savetables.int(::nextDischargeHurt) savetables.int(::nextHealTick) savetables.vector(::lastOutsideLiquid) savetables.location(::lastDimension) - savetables.stateful(::exoPackSlotModifier, "exoSuitSlotCountModifiers") - savetables.stateful(::exoPackContainer, "exoSuitContainer") + savetables.stateful(::exopackSlotModifier, "exoSuitSlotCountModifiers") + savetables.stateful(::exopackContainer, "exoSuitContainer") savetables.stateful(::androidEnergy) - savetables.stateful(::exoPackEnergy) - savetables.stateful(::exoPackChargeSlots) - savetables.float(::exoPackSmelterExperience) - savetables.bool(::isExoPackSmeltingInstalled) + savetables.stateful(::exopackEnergy, "exoPackEnergy") + savetables.stateful(::exopackChargeSlots, "exoPackChargeSlots") + savetables.float(::exopackSmelterExperience, "exoPackSmelterExperience") + savetables.bool(::isExopackSmeltingInstalled, "isExoPackSmeltingInstalled") savetables.codecNullable(::exopackColor, RGBAColor.CODECRGB) savetables.bool(::exopackGlows) @@ -877,8 +877,8 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial override fun deserializeNBT(tag: CompoundTag) { savetables.deserializeNBT(tag) - if (ply is ServerPlayer && hasExoPack) - ExopackSlotsExpandedTrigger.trigger(ply, 0, exoPackContainer.containerSize) + if (ply is ServerPlayer && hasExopack) + ExopackSlotsExpandedTrigger.trigger(ply, 0, exopackContainer.containerSize) for (filter in regularSlotFilters) { filter.value = null @@ -984,8 +984,8 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } private fun tickInventory() { - if (hasExoPack) { - for ((i, stack) in exoPackContainer.withIndex()) { + if (hasExopack) { + for ((i, stack) in exopackContainer.withIndex()) { if (!stack.isEmpty) { stack.inventoryTick(ply.level(), ply, i + 41, false) } @@ -1042,21 +1042,21 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } } - if (hasExoPack) { - exoPackEnergy.parent.tick() + if (hasExopack) { + exopackEnergy.parent.tick() if (!ply.isSpectator) { - if (isExoPackSmeltingInstalled) + if (isExopackSmeltingInstalled) smelters.forEach { it.think() } - if (exoPackEnergy.batteryLevel.isPositive) { - var available = exoPackEnergy.extractEnergy(exoPackEnergy.batteryLevel, true) + if (exopackEnergy.batteryLevel.isPositive) { + var available = exopackEnergy.extractEnergy(exopackEnergy.batteryLevel, true) - if (!exoPackChargeSlots.isEmpty) { - for (item in exoPackChargeSlots) { + if (!exopackChargeSlots.isEmpty) { + for (item in exopackChargeSlots) { if (item.isNotEmpty) { item.energy?.let { - available -= exoPackEnergy.extractEnergy(it.receiveEnergy(available, false), false) + available -= exopackEnergy.extractEnergy(it.receiveEnergy(available, false), false) } if (!available.isPositive) break @@ -1071,7 +1071,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial if (item.isNotEmpty) { item.energy?.let { - available -= exoPackEnergy.extractEnergy(it.receiveEnergy(available, false), false) + available -= exopackEnergy.extractEnergy(it.receiveEnergy(available, false), false) } if (!available.isPositive) break @@ -1082,12 +1082,12 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial if (available.isPositive) { for (slot in exoPackSlotsChargeFlag) { - if (slot in 0 until exoPackContainer.containerSize) { - val item = exoPackContainer[slot] + if (slot in 0 until exopackContainer.containerSize) { + val item = exopackContainer[slot] if (item.isNotEmpty) { item.energy?.let { - available -= exoPackEnergy.extractEnergy(it.receiveEnergy(available, false), false) + available -= exopackEnergy.extractEnergy(it.receiveEnergy(available, false), false) } if (!available.isPositive) break @@ -1278,7 +1278,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial shouldSendIteration = false } - if (hasExoPack && ply.containerMenu == ply.inventoryMenu) { + if (hasExopack && ply.containerMenu == ply.inventoryMenu) { exoPackMenu.broadcastChanges() } @@ -1302,7 +1302,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial */ fun inventoryAddImpl(stack: ItemStack): Boolean { val items = ply.inventory.items - val exoPackContainer = exoPackContainer + val exoPackContainer = exopackContainer if (!stack.isStackable) { // двигаем в отфильтрованные слоты @@ -1432,15 +1432,15 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } enum class UpgradeType(val prop: KMutableProperty1) { - CRAFTING(MatteryPlayerCapability::isExoPackCraftingUpgraded), - SMELTING(MatteryPlayerCapability::isExoPackSmeltingInstalled); + CRAFTING(MatteryPlayerCapability::isExopackCraftingUpgraded), + SMELTING(MatteryPlayerCapability::isExopackSmeltingInstalled); } @Suppress("unused") companion object { private fun setExoPack(players: Collection, hasExoPack: Boolean): Int { for (player in players) { - player.matteryPlayer?.hasExoPack = hasExoPack + player.matteryPlayer?.hasExopack = hasExoPack player.matteryPlayer?._exoPackMenu = null } @@ -1684,12 +1684,12 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial fun inventoryDropAll(inventory: Inventory) { val mattery = inventory.player.matteryPlayer ?: return - if (!mattery.hasExoPack) { + if (!mattery.hasExopack) { return } - inventory.player.dropContainer(mattery.exoPackContainer) - inventory.player.dropContainer(mattery.exoPackChargeSlots) + inventory.player.dropContainer(mattery.exopackContainer) + inventory.player.dropContainer(mattery.exopackChargeSlots) // inventory.player.dropContainer(mattery.exoPackEnergy.parent) for (smelter in mattery.smelters) { @@ -1703,12 +1703,12 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial fun inventoryClearContent(inventory: Inventory) { val mattery = inventory.player.matteryPlayer ?: return - if (!mattery.hasExoPack) { + if (!mattery.hasExopack) { return } - mattery.exoPackContainer.clearContent() - mattery.exoPackChargeSlots.clearContent() + mattery.exopackContainer.clearContent() + mattery.exopackChargeSlots.clearContent() // mattery.exoPackEnergy.parent.clearContent() for (smelter in mattery.smelters) { @@ -1721,9 +1721,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial @JvmStatic fun playerDestroyVanishingCursedItems(player: Player) { player.matteryPlayer?.let { - if (it.hasExoPack) { - it.exoPackContainer.vanishCursedItems() - it.exoPackChargeSlots.vanishCursedItems() + if (it.hasExopack) { + it.exopackContainer.vanishCursedItems() + it.exopackChargeSlots.vanishCursedItems() // it.exoPackEnergy.parent.vanishCursedItems() for (smelter in it.smelters) { @@ -1744,12 +1744,12 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial val matteryPlayer = player.matteryPlayer ?: return - if (!matteryPlayer.hasExoPack) { + if (!matteryPlayer.hasExopack) { return } val targetSlot = player.inventory.suitableHotbarSlot - val itemSlot = matteryPlayer.exoPackContainer.indexOfFirst { !it.isEmpty && ItemStack.isSameItemSameTags(itemStack, it) } + val itemSlot = matteryPlayer.exopackContainer.indexOfFirst { !it.isEmpty && ItemStack.isSameItemSameTags(itemStack, it) } if (itemSlot == -1) { return @@ -1777,11 +1777,11 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial val weapon = weaponItem.item as? ProjectileWeaponItem ?: return null val matteryPlayer = player.matteryPlayer ?: return null - if (!matteryPlayer.hasExoPack) { + if (!matteryPlayer.hasExopack) { return null } - val item = matteryPlayer.exoPackContainer.stream().filter(weapon.allSupportedProjectiles).findFirst().orElse(null) ?: return null + val item = matteryPlayer.exopackContainer.stream().filter(weapon.allSupportedProjectiles).findFirst().orElse(null) ?: return null return ForgeHooks.getProjectile(player, weaponItem, item) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt index 0375aca37..f271be043 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt @@ -77,7 +77,7 @@ var inventoryScroll = 0 private fun inventoryLogic(event: ScreenEvent.Init.Post) { val player = minecraft.player?.matteryPlayer ?: return - if (!player.hasExoPack) { + if (!player.hasExopack) { return } @@ -109,7 +109,7 @@ private fun inventoryLogic(event: ScreenEvent.Init.Post) { } private class InventoryScrollbarPanel(screen: S, matteryPlayer: MatteryPlayerCapability) : DiscreteScrollBarPanel( - screen, null, { integerDivisionUp(matteryPlayer.exoPackContainer.containerSize, 9) }, { _, _, newScroll -> + screen, null, { integerDivisionUp(matteryPlayer.exopackContainer.containerSize, 9) }, { _, _, newScroll -> inventoryScroll = newScroll MenuNetworkChannel.sendToServer(InventoryScrollPacket(newScroll).also { it.play(matteryPlayer.ply) }) }, isSlim = true @@ -122,7 +122,7 @@ private fun exosuitInventoryLogic(screen: Screen, addListener: (GuiEventListener val player = minecraft.player ?: return val matteryPlayer = player.matteryPlayer ?: return - if (!matteryPlayer.hasExoPack || matteryPlayer.exoPackContainer.containerSize == 0) { + if (!matteryPlayer.hasExopack || matteryPlayer.exopackContainer.containerSize == 0) { return } @@ -225,7 +225,7 @@ fun onMouseScrolled(event: MouseScrolled.Pre) { if (ClientConfig.EXOPACK_FREE_SCROLL && widget.panel is InventoryScrollbarPanel) { val slot = screen.slotUnderMouse - if (slot != null && (slot.container == minecraft.player?.inventory && slot.containerSlot in 9 .. 35 || slot.container == minecraft.player?.matteryPlayer?.exoPackContainer)) { + if (slot != null && (slot.container == minecraft.player?.inventory && slot.containerSlot in 9 .. 35 || slot.container == minecraft.player?.matteryPlayer?.exopackContainer)) { widget.panel.mouseScrolledInner(event.mouseX, event.mouseY, event.scrollDelta) event.isCanceled = true return @@ -249,7 +249,7 @@ fun onScreenOpen(event: ScreenEvent.Opening) { val player = minecraft.player?.matteryPlayer ?: return - if (player.hasExoPack && event.newScreen is InventoryScreen) { + if (player.hasExopack && event.newScreen is InventoryScreen) { event.newScreen = ExoPackInventoryScreen(player.exoPackMenu) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt index 302e1f3f6..b85143277 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt @@ -13,14 +13,10 @@ import ru.dbotthepony.mc.otm.client.render.sprites.sprite import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel -import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.InventorySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel -import ru.dbotthepony.mc.otm.client.screen.panels.util.BackgroundPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel -import ru.dbotthepony.mc.otm.client.screen.widget.HorizontalPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel -import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.client.setMousePos import ru.dbotthepony.mc.otm.client.shouldOpenVanillaInventory import ru.dbotthepony.mc.otm.compat.curios.isCuriosLoaded @@ -126,7 +122,7 @@ class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen(menu: T, inventory: Inventory, tit if (menu.playerExoSuitSlots.isEmpty()) { inventoryFrame = FramePanel>(this, null, 0f, 0f, INVENTORY_FRAME_WIDTH, INVENTORY_FRAME_HEIGHT, inventory.displayName).also(this::addPanel) inventoryFrame!!.makeHelpButton().addSlotFiltersHelp().also { - if (menu.ply.matteryPlayer?.hasExoPack == true) + if (menu.ply.matteryPlayer?.hasExopack == true) it.tooltips.add(TranslatableComponent("otm.gui.help.slot_charging")) } @@ -225,7 +225,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } else { inventoryFrame = FramePanel>(this, null, 0f, 0f, INVENTORY_FRAME_WIDTH_EXTENDED, BASE_INVENTORY_FRAME_HEIGHT + AbstractSlotPanel.SIZE * inventoryRows, inventory.displayName).also(this::addPanel) inventoryFrame!!.makeHelpButton().addSlotFiltersHelp().also { - if (menu.ply.matteryPlayer?.hasExoPack == true) + if (menu.ply.matteryPlayer?.hasExopack == true) it.tooltips.add(TranslatableComponent("otm.gui.help.slot_charging")) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt index 25fa55509..119f24699 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt @@ -59,7 +59,7 @@ private fun createExopackAppearanceWindow(screen: MatteryScreen<*>, matteryPlaye text = TranslatableComponent("otm.gui.exopack.toggle_visibility"), isChecked = GetterSetter.of( { - matteryPlayer.displayExoPack + matteryPlayer.displayExopack }, { if (it) { @@ -147,7 +147,7 @@ class EntityRendererPanel @JvmOverloads constructor( if (entity is Player) { val matteryPlayer = entity.matteryPlayer - if (matteryPlayer != null && matteryPlayer.hasExoPack && screen is MatteryScreen<*>) { + if (matteryPlayer != null && matteryPlayer.hasExopack && screen is MatteryScreen<*>) { exosuitButton = SmallRectangleButtonPanel(screen, this, this.width - 2f - SmallBooleanRectangleButtonPanel.SIZE, 2f, skinElement = Widgets8.EXOPACK_SHOWN, onPress = { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/ExtendedInventoryHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/ExtendedInventoryHandler.kt index d27d2759c..6c3a612cc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/ExtendedInventoryHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/ExtendedInventoryHandler.kt @@ -46,8 +46,8 @@ private class MenuConfiguration( val offset = (it - 3) * 9 for (i in 0 .. 8) { - if (matteryPlayer.exoPackContainer.containerSize > i + offset) { - row.add(MatterySlot(matteryPlayer.exoPackContainer, i + offset)) + if (matteryPlayer.exopackContainer.containerSize > i + offset) { + row.add(MatterySlot(matteryPlayer.exopackContainer, i + offset)) } else { row.add(FakeSlot()) } @@ -64,13 +64,13 @@ private class MenuConfiguration( val matteryPlayer = player.matteryPlayer ?: return - if (!matteryPlayer.hasExoPack || matteryPlayer.exoPackContainer.containerSize <= (value - 1) * 9) { + if (!matteryPlayer.hasExopack || matteryPlayer.exopackContainer.containerSize <= (value - 1) * 9) { return } for (rowIndex in 0 .. 2) { for (slot in getRow(rowIndex + field, matteryPlayer)) { - if (slot.container === matteryPlayer.exoPackContainer) { + if (slot.container === matteryPlayer.exopackContainer) { @Suppress("name_shadowing") val indexOf = matteryPlayer.exoPackMenu.slots.indexOfFirst { it.slotIndex == slot.slotIndex } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/HasExoPackCondition.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/HasExoPackCondition.kt index 297e8638e..9f1ba1258 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/HasExoPackCondition.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/HasExoPackCondition.kt @@ -16,7 +16,7 @@ import ru.dbotthepony.mc.otm.registry.MLootItemConditions object HasExoPackCondition : LootItemCondition, Serializer, LootItemCondition.Builder { override fun test(t: LootContext): Boolean { t[LootContextParams.LAST_DAMAGE_PLAYER]?.matteryPlayer?.let { - return it.hasExoPack + return it.hasExopack } return false diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/AbstractExoPackSlotUpgradeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/AbstractExopackSlotUpgradeItem.kt similarity index 86% rename from src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/AbstractExoPackSlotUpgradeItem.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/AbstractExopackSlotUpgradeItem.kt index 591ae73ac..2e667ec48 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/AbstractExoPackSlotUpgradeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/AbstractExopackSlotUpgradeItem.kt @@ -24,7 +24,7 @@ import ru.dbotthepony.mc.otm.runIfClient import ru.dbotthepony.mc.otm.triggers.ExopackSlotsExpandedTrigger import java.util.UUID -abstract class AbstractExoPackSlotUpgradeItem(properties: Properties = defaultProperties()) : Item(properties) { +abstract class AbstractExopackSlotUpgradeItem(properties: Properties = defaultProperties()) : Item(properties) { abstract fun hasDescription(itemStack: ItemStack): Boolean abstract fun slotCount(itemStack: ItemStack): Int abstract fun uuid(itemStack: ItemStack): UUID? @@ -41,7 +41,7 @@ abstract class AbstractExoPackSlotUpgradeItem(properties: Properties = defaultPr super.appendHoverText(p_41421_, p_41422_, tooltip, p_41424_) val alreadyHasExosuit = runIfClient(true) { - minecraft.player?.matteryPlayer?.hasExoPack == true + minecraft.player?.matteryPlayer?.hasExopack == true } if (!alreadyHasExosuit) { @@ -55,7 +55,7 @@ abstract class AbstractExoPackSlotUpgradeItem(properties: Properties = defaultPr val uuid = uuid(p_41421_) val alreadyHas = (uuid != null && !ServerConfig.INFINITE_EXOSUIT_UPGRADES) && runIfClient(false) { - minecraft.player?.matteryPlayer?.exoPackSlotModifier?.contains(uuid) == true + minecraft.player?.matteryPlayer?.exopackSlotModifier?.contains(uuid) == true } if (alreadyHas) { @@ -74,7 +74,7 @@ abstract class AbstractExoPackSlotUpgradeItem(properties: Properties = defaultPr val uuid = uuid(player.getItemInHand(hand)) - if (matteryPlayer.hasExoPack && ((uuid == null || ServerConfig.INFINITE_EXOSUIT_UPGRADES) || uuid !in matteryPlayer.exoPackSlotModifier)) { + if (matteryPlayer.hasExopack && ((uuid == null || ServerConfig.INFINITE_EXOSUIT_UPGRADES) || uuid !in matteryPlayer.exopackSlotModifier)) { player.startUsingItem(hand) return InteractionResultHolder.consume(player.getItemInHand(hand)) } @@ -88,7 +88,7 @@ abstract class AbstractExoPackSlotUpgradeItem(properties: Properties = defaultPr val uuid = uuid(itemStack) val slotCount = slotCount(itemStack) - if (slotCount <= 0 || !matteryPlayer.hasExoPack || (!ServerConfig.INFINITE_EXOSUIT_UPGRADES && uuid != null && uuid in matteryPlayer.exoPackSlotModifier)) { + if (slotCount <= 0 || !matteryPlayer.hasExopack || (!ServerConfig.INFINITE_EXOSUIT_UPGRADES && uuid != null && uuid in matteryPlayer.exopackSlotModifier)) { return super.finishUsingItem(itemStack, level, player) } @@ -97,16 +97,16 @@ abstract class AbstractExoPackSlotUpgradeItem(properties: Properties = defaultPr if (player is ServerPlayer) { if (uuid != null) { - if (ServerConfig.INFINITE_EXOSUIT_UPGRADES && uuid in matteryPlayer.exoPackSlotModifier) { - matteryPlayer.exoPackSlotModifier[UUID.randomUUID()] = slotCount + if (ServerConfig.INFINITE_EXOSUIT_UPGRADES && uuid in matteryPlayer.exopackSlotModifier) { + matteryPlayer.exopackSlotModifier[UUID.randomUUID()] = slotCount } else { - matteryPlayer.exoPackSlotModifier[uuid] = slotCount + matteryPlayer.exopackSlotModifier[uuid] = slotCount } } else { - matteryPlayer.exoPackSlotModifier[UUID.randomUUID()] = slotCount + matteryPlayer.exopackSlotModifier[UUID.randomUUID()] = slotCount } - ExopackSlotsExpandedTrigger.trigger(player, slotCount, matteryPlayer.exoPackContainer.containerSize) + ExopackSlotsExpandedTrigger.trigger(player, slotCount, matteryPlayer.exopackContainer.containerSize) player.displayClientMessage(TranslatableComponent("otm.exopack_upgrades.slots_upgraded", slotCount).withStyle(ChatFormatting.DARK_GREEN), false) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExoPackProbeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExopackProbeItem.kt similarity index 90% rename from src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExoPackProbeItem.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExopackProbeItem.kt index 0b76063f1..fd4a6c8a4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExoPackProbeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExopackProbeItem.kt @@ -9,18 +9,16 @@ import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.player.Player import net.minecraft.world.item.* import net.minecraft.world.level.Level -import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.onceServer import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.damageType import ru.dbotthepony.mc.otm.registry.MDamageTypes -import ru.dbotthepony.mc.otm.registry.MRegistry import ru.dbotthepony.mc.otm.registry.MatteryDamageSource import ru.dbotthepony.mc.otm.runIfClient -class ExoPackProbeItem : Item(Properties().stacksTo(1).rarity(Rarity.EPIC)) { +class ExopackProbeItem : Item(Properties().stacksTo(1).rarity(Rarity.EPIC)) { override fun getUseDuration(p_41454_: ItemStack): Int { return 30 } @@ -29,7 +27,7 @@ class ExoPackProbeItem : Item(Properties().stacksTo(1).rarity(Rarity.EPIC)) { super.appendHoverText(p_41421_, p_41422_, tooltip, p_41424_) val alreadyHas = runIfClient(false) { - return@runIfClient minecraft.player?.matteryPlayer?.hasExoPack ?: false + return@runIfClient minecraft.player?.matteryPlayer?.hasExopack ?: false } if (alreadyHas) { @@ -42,7 +40,7 @@ class ExoPackProbeItem : Item(Properties().stacksTo(1).rarity(Rarity.EPIC)) { } override fun use(p_41432_: Level, player: Player, hand: InteractionHand): InteractionResultHolder { - if (player.matteryPlayer?.hasExoPack == false) { + if (player.matteryPlayer?.hasExopack == false) { player.startUsingItem(hand) return InteractionResultHolder.consume(player.getItemInHand(hand)) } @@ -54,7 +52,7 @@ class ExoPackProbeItem : Item(Properties().stacksTo(1).rarity(Rarity.EPIC)) { if (player !is Player) return super.finishUsingItem(itemStack, level, player) val mattery = player.matteryPlayer ?: return super.finishUsingItem(itemStack, level, player) - if (mattery.hasExoPack) { + if (mattery.hasExopack) { return super.finishUsingItem(itemStack, level, player) } @@ -64,7 +62,7 @@ class ExoPackProbeItem : Item(Properties().stacksTo(1).rarity(Rarity.EPIC)) { itemStack.shrink(1) if (player is ServerPlayer) { - mattery.hasExoPack = true + mattery.hasExopack = true player.displayClientMessage(TranslatableComponent("otm.exopack.granted1").withStyle(ChatFormatting.GRAY), false) player.displayClientMessage(TranslatableComponent("otm.exopack.granted2").withStyle(ChatFormatting.GRAY), false) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExoPackSlotUpgradeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExopackSlotUpgradeItem.kt similarity index 94% rename from src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExoPackSlotUpgradeItem.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExopackSlotUpgradeItem.kt index dbd9535b9..ef1c5981c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExoPackSlotUpgradeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExopackSlotUpgradeItem.kt @@ -6,7 +6,7 @@ import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.core.toUUID import java.util.UUID -class ExoPackSlotUpgradeItem : AbstractExoPackSlotUpgradeItem { +class ExopackSlotUpgradeItem : AbstractExopackSlotUpgradeItem { val hasDescription: Boolean val slotCount: Int diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExopackUpgradeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExopackUpgradeItem.kt index f3ead9561..668539320 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExopackUpgradeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExopackUpgradeItem.kt @@ -32,7 +32,7 @@ class ExopackUpgradeItem( super.appendHoverText(p_41421_, p_41422_, tooltip, p_41424_) val alreadyHasExosuit = runIfClient(true) { - minecraft.player?.matteryPlayer?.hasExoPack == true + minecraft.player?.matteryPlayer?.hasExopack == true } if (!alreadyHasExosuit) { @@ -55,7 +55,7 @@ class ExopackUpgradeItem( } override fun use(p_41432_: Level, player: Player, hand: InteractionHand): InteractionResultHolder { - if (player.matteryPlayer?.hasExoPack == true && !type.prop.get(player.matteryPlayer!!)) { + if (player.matteryPlayer?.hasExopack == true && !type.prop.get(player.matteryPlayer!!)) { player.startUsingItem(hand) return InteractionResultHolder.consume(player.getItemInHand(hand)) } @@ -67,7 +67,7 @@ class ExopackUpgradeItem( if (player !is Player) return super.finishUsingItem(itemStack, level, player) val mattery = player.matteryPlayer ?: return super.finishUsingItem(itemStack, level, player) - if (!mattery.hasExoPack || type.prop.get(mattery)) { + if (!mattery.hasExopack || type.prop.get(mattery)) { return super.finishUsingItem(itemStack, level, player) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ProceduralExoPackSlotUpgradeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ProceduralExopackSlotUpgradeItem.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ProceduralExoPackSlotUpgradeItem.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ProceduralExopackSlotUpgradeItem.kt index 940e4d8b1..f72bb1884 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ProceduralExoPackSlotUpgradeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ProceduralExopackSlotUpgradeItem.kt @@ -6,7 +6,6 @@ import net.minecraft.network.chat.Component import net.minecraft.util.valueproviders.ConstantInt import net.minecraft.util.valueproviders.IntProvider import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.Rarity import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.Level import net.minecraft.world.level.storage.loot.LootContext @@ -19,7 +18,7 @@ import ru.dbotthepony.mc.otm.data.Codec2Serializer import ru.dbotthepony.mc.otm.registry.MItemFunctionTypes import java.util.* -class ProceduralExoPackSlotUpgradeItem : AbstractExoPackSlotUpgradeItem(defaultProperties()) { +class ProceduralExopackSlotUpgradeItem : AbstractExopackSlotUpgradeItem(defaultProperties()) { class Randomizer(val slots: IntProvider, val luckBias: IntProvider = ConstantInt.ZERO) : LootItemFunction, LootItemFunction.Builder { override fun apply(t: ItemStack, u: LootContext): ItemStack { t.tagNotNull[SLOT_COUNT_KEY] = slots.sample(u.random) + (luckBias.sample(u.random) * u.luck / 1024f).coerceAtLeast(0f).toInt() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt index 744eea904..9194fc3c5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt @@ -1,9 +1,7 @@ package ru.dbotthepony.mc.otm.menu import com.google.common.collect.ImmutableList -import com.mojang.datafixers.util.Pair import net.minecraft.core.NonNullList -import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerPlayer import net.minecraft.world.Container @@ -15,7 +13,6 @@ import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.compat.curios.curiosSlots import ru.dbotthepony.mc.otm.container.iterator import ru.dbotthepony.mc.otm.menu.input.InstantBooleanInput -import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.network.ExoSuitCarriedPacket import ru.dbotthepony.mc.otm.network.ExoSuitMenuInitPacket @@ -27,7 +24,7 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen val craftingSlots: List init { - if (capability.isExoPackCraftingUpgraded) { + if (capability.isExopackCraftingUpgraded) { craftingGrid = TransientCraftingContainer(this, 3, 3) } else { craftingGrid = TransientCraftingContainer(this, 2, 2) @@ -87,9 +84,9 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen } private fun popFurnaceExp() { - if (capability.isExoPackSmeltingInstalled && capability.exoPackSmelterExperience >= 1f && !ply.level().isClientSide) { - val whole = capability.exoPackSmelterExperience.toInt() - capability.exoPackSmelterExperience -= whole + if (capability.isExopackSmeltingInstalled && capability.exopackSmelterExperience >= 1f && !ply.level().isClientSide) { + val whole = capability.exopackSmelterExperience.toInt() + capability.exopackSmelterExperience -= whole ExperienceOrb.award(ply.level() as ServerLevel, ply.position(), whole) } } @@ -97,7 +94,7 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen val furnaceInputs: List = capability.smelters.map { object : MatterySlot(it.input, 0) { override fun mayPlace(itemStack: ItemStack): Boolean { - return super.mayPlace(itemStack) && capability.isExoPackSmeltingInstalled + return super.mayPlace(itemStack) && capability.isExopackSmeltingInstalled } } } @@ -105,7 +102,7 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen val furnaceOutputs: List = capability.smelters.map { object : MachineOutputSlot(it.output, 0, onTake = { popFurnaceExp() }) { override fun mayPickup(player: Player): Boolean { - return super.mayPickup(player) && capability.isExoPackSmeltingInstalled + return super.mayPickup(player) && capability.isExopackSmeltingInstalled } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index b775f81d7..73bc13ebd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -267,8 +267,8 @@ abstract class MatteryMenu @JvmOverloads protected constructor( } override fun isSameInventory(other: Slot): Boolean { - if (container === inventory || container === ply.matteryPlayer?.exoPackContainer) - return (other.container === inventory || other.container === ply.matteryPlayer?.exoPackContainer) && isSameFilter(other) + if (container === inventory || container === ply.matteryPlayer?.exopackContainer) + return (other.container === inventory || other.container === ply.matteryPlayer?.exopackContainer) && isSameFilter(other) return super.isSameInventory(other) } @@ -296,10 +296,10 @@ abstract class MatteryMenu @JvmOverloads protected constructor( setter = input::input ) } - } else if (container === mattery.exoPackContainer) { + } else if (container === mattery.exopackContainer) { filter = GetterSetter.of( - getter = { mattery.exoPackContainer.getSlotFilter(slotIndex) }, - setter = nullableItemInput(true) { mattery.exoPackContainer.setSlotFilter(slotIndex, it) }::input + getter = { mattery.exopackContainer.getSlotFilter(slotIndex) }, + setter = nullableItemInput(true) { mattery.exopackContainer.setSlotFilter(slotIndex, it) }::input ) val input = booleanInput(true) { if (it) mattery.exoPackSlotsChargeFlag.add(slotIndex) else mattery.exoPackSlotsChargeFlag.remove(slotIndex) } @@ -367,9 +367,9 @@ abstract class MatteryMenu @JvmOverloads protected constructor( val mattery = ply.matteryPlayer - if (mattery != null && mattery.hasExoPack) { - for (i in 0 until mattery.exoPackContainer.containerSize) { - val slot = InventorySlot(mattery.exoPackContainer, i) + if (mattery != null && mattery.hasExopack) { + for (i in 0 until mattery.exopackContainer.containerSize) { + val slot = InventorySlot(mattery.exopackContainer, i) _playerInventorySlots.add(slot) _playerInventorySlots2.add(slot) @@ -381,12 +381,12 @@ abstract class MatteryMenu @JvmOverloads protected constructor( addSlot(slot) } - _exopackChargeSlots.add(BatterySlot(mattery.exoPackEnergy.parent, 0).also { mapQuickMoveToExternal(it); mapQuickMoveToInventory(it); addSlot(it) }) + _exopackChargeSlots.add(BatterySlot(mattery.exopackEnergy.parent, 0).also { mapQuickMoveToExternal(it); mapQuickMoveToInventory(it); addSlot(it) }) - for (i in 0 until mattery.exoPackChargeSlots.containerSize) - _exopackChargeSlots.add(ChargeSlot(mattery.exoPackChargeSlots, i).also { mapQuickMoveToExternal(it); mapQuickMoveToInventory(it); addSlot(it) }) + for (i in 0 until mattery.exopackChargeSlots.containerSize) + _exopackChargeSlots.add(ChargeSlot(mattery.exopackChargeSlots, i).also { mapQuickMoveToExternal(it); mapQuickMoveToInventory(it); addSlot(it) }) - exopackPowerLevel.with(mattery.exoPackEnergy) + exopackPowerLevel.with(mattery.exopackEnergy) } for (i in 0..8) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt index 3d26e222e..9634b0b73 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt @@ -6,7 +6,6 @@ import net.minecraft.network.chat.Component import net.minecraft.network.protocol.game.ClientboundSetCarriedItemPacket import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.player.Inventory -import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraftforge.network.NetworkDirection.PLAY_TO_CLIENT import net.minecraftforge.network.NetworkDirection.PLAY_TO_SERVER @@ -30,8 +29,6 @@ import ru.dbotthepony.mc.otm.container.get import ru.dbotthepony.mc.otm.container.set import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.Vector -import ru.dbotthepony.mc.otm.core.readItemType -import ru.dbotthepony.mc.otm.core.writeItemType import ru.dbotthepony.mc.otm.menu.tech.AndroidStationMenu import ru.dbotthepony.mc.otm.menu.ExoPackInventoryMenu import ru.dbotthepony.mc.otm.registry.AndroidFeatures @@ -237,7 +234,7 @@ class ExoSuitCarriedPacket(val itemStack: ItemStack, val containerState: Int) : context.enqueueWork { val mattery = minecraft.player?.matteryPlayer ?: return@enqueueWork - if (mattery.hasExoPack) { + if (mattery.hasExopack) { mattery.exoPackMenu.carried = itemStack mattery.exoPackMenu.stateId = containerState } @@ -269,7 +266,7 @@ class ExoSuitSlotPacket(val slotId: Int, val itemStack: ItemStack, val container context.enqueueWork { val mattery = minecraft.player?.matteryPlayer ?: return@enqueueWork - if (mattery.hasExoPack) { + if (mattery.hasExopack) { if (slotId >= mattery.exoPackMenu.slots.size) { LOGGER.error("Unknown slot with ID {} in exosuit menu", slotId) return@enqueueWork @@ -312,7 +309,7 @@ class ExoSuitMenuInitPacket(val slots: List, val carried: ItemStack, context.enqueueWork { val mattery = minecraft.player?.matteryPlayer ?: return@enqueueWork - if (mattery.hasExoPack) { + if (mattery.hasExopack) { mattery.exoPackMenu.initializeContents(containerState, slots, carried) } } @@ -344,7 +341,7 @@ object ExoPackMenuOpen : MatteryPacket { val player = context.sender ?: return@enqueueWork val mattery = player.matteryPlayer ?: return@enqueueWork - if (mattery.hasExoPack) { + if (mattery.hasExopack) { player.containerMenu = mattery.exoPackMenu } } @@ -435,7 +432,7 @@ class PickItemFromInventoryPacket( val player = context.sender ?: return@enqueueWork val mattery = player.matteryPlayer ?: return@enqueueWork - if (!mattery.hasExoPack || sourceExosuitSlot !in 0 until mattery.exoPackContainer.containerSize) { + if (!mattery.hasExopack || sourceExosuitSlot !in 0 until mattery.exopackContainer.containerSize) { return@enqueueWork } @@ -445,10 +442,10 @@ class PickItemFromInventoryPacket( player.inventory.selected = targetHotbarSlot val existingItem = player.inventory[targetHotbarSlot].copy() - val inventoryItem = mattery.exoPackContainer[sourceExosuitSlot].copy() + val inventoryItem = mattery.exopackContainer[sourceExosuitSlot].copy() player.inventory[targetHotbarSlot] = if (inventoryItem.isEmpty) ItemStack.EMPTY else inventoryItem - mattery.exoPackContainer[sourceExosuitSlot] = if (existingItem.isEmpty) ItemStack.EMPTY else existingItem + mattery.exopackContainer[sourceExosuitSlot] = if (existingItem.isEmpty) ItemStack.EMPTY else existingItem player.connection.send(ClientboundSetCarriedItemPacket(targetHotbarSlot)) } @@ -502,7 +499,7 @@ object DisplayExopackPacket : MatteryPacket { override fun play(context: Supplier) { context.packetHandled = true - context.sender?.matteryPlayer?.displayExoPack = true + context.sender?.matteryPlayer?.displayExopack = true } } @@ -511,7 +508,7 @@ object HideExopackPacket : MatteryPacket { override fun play(context: Supplier) { context.packetHandled = true - context.sender?.matteryPlayer?.displayExoPack = false + context.sender?.matteryPlayer?.displayExopack = false } } 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 f8005cdad..10c680a92 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItemFunctionTypes.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItemFunctionTypes.kt @@ -7,14 +7,14 @@ import net.minecraftforge.registries.DeferredRegister import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.data.loot.CopyTileNbtFunction import ru.dbotthepony.mc.otm.item.ProceduralBatteryItem -import ru.dbotthepony.mc.otm.item.exopack.ProceduralExoPackSlotUpgradeItem +import ru.dbotthepony.mc.otm.item.exopack.ProceduralExopackSlotUpgradeItem object MItemFunctionTypes { private val registry = DeferredRegister.create(Registries.LOOT_FUNCTION_TYPE, OverdriveThatMatters.MOD_ID) val COPY_TILE_NBT: LootItemFunctionType by registry.register("copy_tile_nbt") { LootItemFunctionType(CopyTileNbtFunction.Companion) } val PROCEDURAL_BATTERY: LootItemFunctionType by registry.register(MNames.PROCEDURAL_BATTERY) { LootItemFunctionType(ProceduralBatteryItem.Randomizer.SERIALIZER) } - val PROCEDURAL_EXOPACK_UPGRADE: LootItemFunctionType by registry.register("exopack_upgrade") { LootItemFunctionType(ProceduralExoPackSlotUpgradeItem.Randomizer.SERIALIZER) } + val PROCEDURAL_EXOPACK_UPGRADE: LootItemFunctionType by registry.register("exopack_upgrade") { LootItemFunctionType(ProceduralExopackSlotUpgradeItem.Randomizer.SERIALIZER) } internal fun register(bus: IEventBus) { registry.register(bus) 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 9986f0f96..74847ca2d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -21,8 +21,8 @@ import ru.dbotthepony.mc.otm.core.collect.SupplierList import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.item.* -import ru.dbotthepony.mc.otm.item.exopack.ExoPackProbeItem -import ru.dbotthepony.mc.otm.item.exopack.ExoPackSlotUpgradeItem +import ru.dbotthepony.mc.otm.item.exopack.ExopackProbeItem +import ru.dbotthepony.mc.otm.item.exopack.ExopackSlotUpgradeItem import ru.dbotthepony.mc.otm.item.matter.CreativePatternItem import ru.dbotthepony.mc.otm.item.matter.MatterCapacitorItem import ru.dbotthepony.mc.otm.item.matter.MatterDustItem @@ -34,7 +34,7 @@ import ru.dbotthepony.mc.otm.item.armor.PortableGravitationStabilizerItem import ru.dbotthepony.mc.otm.item.armor.SimpleTritaniumArmorItem import ru.dbotthepony.mc.otm.item.armor.TritaniumArmorItem import ru.dbotthepony.mc.otm.item.exopack.ExopackUpgradeItem -import ru.dbotthepony.mc.otm.item.exopack.ProceduralExoPackSlotUpgradeItem +import ru.dbotthepony.mc.otm.item.exopack.ProceduralExopackSlotUpgradeItem import ru.dbotthepony.mc.otm.item.weapon.PlasmaRifleItem object MItems { @@ -509,24 +509,24 @@ object MItems { val CARGO_CRATE_MINECARTS = registry.allColored(MNames.MINECART_CARGO_CRATE) { color, _ -> MinecartCargoCrateItem(color) } - val EXOPACK_PROBE: Item by registry.register(MNames.EXOPACK_PROBE, ::ExoPackProbeItem) + val EXOPACK_PROBE: Item by registry.register(MNames.EXOPACK_PROBE, ::ExopackProbeItem) object ExopackUpgrades { - val INVENTORY_UPGRADE_CREATIVE: Item by registry.register("exosuit_inventory_upgrade_creative") { ExoPackSlotUpgradeItem(null, 27, Rarity.EPIC) } + val INVENTORY_UPGRADE_CREATIVE: Item by registry.register("exosuit_inventory_upgrade_creative") { ExopackSlotUpgradeItem(null, 27, Rarity.EPIC) } val CRAFTING_UPGRADE: Item by registry.register("exosuit_crafting_upgrade") { ExopackUpgradeItem(MatteryPlayerCapability.UpgradeType.CRAFTING, "crafting_upgrade", "crafting_upgraded") } val SMELTING_UPGRADE: Item by registry.register("exopack_smelting_upgrade") { ExopackUpgradeItem(MatteryPlayerCapability.UpgradeType.SMELTING, "smelting_upgrade", "smelting_installed") } val INVENTORY_UPGRADES = SupplierList(8) { - registry.register("exosuit_inventory_upgrade_$it") { ExoPackSlotUpgradeItem(18, Rarity.COMMON) }::get + registry.register("exosuit_inventory_upgrade_$it") { ExopackSlotUpgradeItem(18, Rarity.COMMON) }::get } - val INVENTORY_UPGRADE_PROCEDURAL: Item by registry.register("exosuit_inventory_upgrade_procedural") { ProceduralExoPackSlotUpgradeItem() } + val INVENTORY_UPGRADE_PROCEDURAL: Item by registry.register("exosuit_inventory_upgrade_procedural") { ProceduralExopackSlotUpgradeItem() } - val INVENTORY_UPGRADE_BIG: Item by registry.register("exosuit_inventory_upgrade_big") { ExoPackSlotUpgradeItem(60, Rarity.RARE) } - val INVENTORY_UPGRADE_HUGE: Item by registry.register("exosuit_inventory_upgrade_huge") { ExoPackSlotUpgradeItem(135, Rarity.RARE) } + val INVENTORY_UPGRADE_BIG: Item by registry.register("exosuit_inventory_upgrade_big") { ExopackSlotUpgradeItem(60, Rarity.RARE) } + val INVENTORY_UPGRADE_HUGE: Item by registry.register("exosuit_inventory_upgrade_huge") { ExopackSlotUpgradeItem(135, Rarity.RARE) } - val INVENTORY_UPGRADE_WITHER: Item by registry.register("exosuit_inventory_upgrade_wither") { ExoPackSlotUpgradeItem(180, Rarity.RARE, hasDescription = true) } - val INVENTORY_UPGRADE_ENDER_DRAGON: Item by registry.register("exosuit_inventory_upgrade_ender_dragon") { ExoPackSlotUpgradeItem(180, Rarity.EPIC, hasDescription = true) } + val INVENTORY_UPGRADE_WITHER: Item by registry.register("exosuit_inventory_upgrade_wither") { ExopackSlotUpgradeItem(180, Rarity.RARE, hasDescription = true) } + val INVENTORY_UPGRADE_ENDER_DRAGON: Item by registry.register("exosuit_inventory_upgrade_ender_dragon") { ExopackSlotUpgradeItem(180, Rarity.EPIC, hasDescription = true) } } init { From 1c3001595a560a6185225419f7fb6dfb8ef7df6e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 29 Jul 2023 18:13:22 +0700 Subject: [PATCH 0889/1199] Allow to charge offhand slot --- .../ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt | 2 +- .../dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt | 2 +- .../kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index eaaaffe63..24e571422 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -249,7 +249,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial synchronizer.Field(null, ItemValueCodec.nullable) } - val regularSlotChargeFlag = immutableList(Inventory.INVENTORY_SIZE + 4) { + val regularSlotChargeFlag = immutableList(Inventory.INVENTORY_SIZE + 5) { synchronizer.bool() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt index b85143277..d90871dd4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt @@ -99,7 +99,7 @@ class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen(menu: T, inventory: Inventory, tit val hotbarStrip = EditablePanel(this, inventoryFrame, height = AbstractSlotPanel.SIZE) hotbarStrip.dock = Dock.BOTTOM - val offhand = SlotPanel(this, hotbarStrip, menu.offhandSlot!!) + val offhand = InventorySlotPanel(this, hotbarStrip, menu.offhandSlot!!) offhand.dock = Dock.RIGHT for (slot in menu.playerHotbarSlots) { From e57844bc1a2ad45f024ca64bdf7304024892889b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 29 Jul 2023 18:14:00 +0700 Subject: [PATCH 0890/1199] Decapitalize exopack menu/screen name --- .../otm/capability/MatteryPlayerCapability.kt | 12 ++++----- .../mc/otm/client/ClientEventHandler.kt | 6 ++--- ...oryScreen.kt => ExopackInventoryScreen.kt} | 10 +++---- .../screen/panels/EntityRendererPanel.kt | 4 +-- .../mc/otm/compat/jei/JEIPlugin.kt | 27 +++++++++---------- ...ventoryMenu.kt => ExopackInventoryMenu.kt} | 20 +++++++------- .../network/MatteryPlayerNetworkChannel.kt | 4 +-- .../mc/otm/network/MenuNetworkChannel.kt | 4 +-- 8 files changed, 43 insertions(+), 44 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/{ExoPackInventoryScreen.kt => ExopackInventoryScreen.kt} (95%) rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/{ExoPackInventoryMenu.kt => ExopackInventoryMenu.kt} (91%) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 24e571422..d8c72c869 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -96,7 +96,7 @@ import ru.dbotthepony.mc.otm.core.util.Savetables import ru.dbotthepony.mc.otm.core.util.TickList import ru.dbotthepony.mc.otm.core.util.UUIDValueCodec import ru.dbotthepony.mc.otm.core.util.VarIntValueCodec -import ru.dbotthepony.mc.otm.menu.ExoPackInventoryMenu +import ru.dbotthepony.mc.otm.menu.ExopackInventoryMenu import ru.dbotthepony.mc.otm.network.* import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer import ru.dbotthepony.mc.otm.registry.AndroidFeatures @@ -309,7 +309,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } }).property - private var _exoPackMenu: ExoPackInventoryMenu? = null + private var _exoPackMenu: ExopackInventoryMenu? = null set(value) { if (field == ply.containerMenu) { ply.closeContainer() } field?.actuallyRemoved() @@ -317,19 +317,19 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } /** - * [ExoPackInventoryMenu] which player will see when pressing inventory key + * [ExopackInventoryMenu] which player will see when pressing inventory key */ - val exoPackMenu: ExoPackInventoryMenu + val exoPackMenu: ExopackInventoryMenu get() { if (_exoPackMenu == null) { - _exoPackMenu = ExoPackInventoryMenu(this) + _exoPackMenu = ExopackInventoryMenu(this) } return _exoPackMenu!! } fun recreateExoPackMenu() { - _exoPackMenu = ExoPackInventoryMenu(this) + _exoPackMenu = ExopackInventoryMenu(this) } private var shouldSendIteration = false diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt index f271be043..10cdb96b9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt @@ -18,7 +18,7 @@ import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.Widgets18 -import ru.dbotthepony.mc.otm.client.screen.ExoPackInventoryScreen +import ru.dbotthepony.mc.otm.client.screen.ExopackInventoryScreen import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel @@ -95,7 +95,7 @@ private fun inventoryLogic(event: ScreenEvent.Init.Post) { val mouseY = minecraft.mouseHandler.ypos() event.screen.onClose() - minecraft.setScreen(ExoPackInventoryScreen(player.exoPackMenu)) + minecraft.setScreen(ExopackInventoryScreen(player.exoPackMenu)) InputConstants.grabOrReleaseMouse(minecraft.window.window, 212993, mouseX, mouseY) }).also { it.tooltips.add(TranslatableComponent("otm.gui.exopack.go_in")) }) @@ -250,6 +250,6 @@ fun onScreenOpen(event: ScreenEvent.Opening) { val player = minecraft.player?.matteryPlayer ?: return if (player.hasExopack && event.newScreen is InventoryScreen) { - event.newScreen = ExoPackInventoryScreen(player.exoPackMenu) + event.newScreen = ExopackInventoryScreen(player.exoPackMenu) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt similarity index 95% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt index d90871dd4..018db7198 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt @@ -22,15 +22,15 @@ import ru.dbotthepony.mc.otm.client.shouldOpenVanillaInventory import ru.dbotthepony.mc.otm.compat.curios.isCuriosLoaded import ru.dbotthepony.mc.otm.compat.curios.openCuriosScreen import ru.dbotthepony.mc.otm.core.math.integerDivisionDown -import ru.dbotthepony.mc.otm.menu.ExoPackInventoryMenu +import ru.dbotthepony.mc.otm.menu.ExopackInventoryMenu import ru.dbotthepony.mc.otm.network.ExoPackMenuOpen import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel import yalter.mousetweaks.api.MouseTweaksDisableWheelTweak @MouseTweaksDisableWheelTweak -class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen(menu, TranslatableComponent("otm.gui.exopack")) { - private lateinit var mainInventoryLine: EditablePanel - private lateinit var scrollPanel: DiscreteScrollBarPanel +class ExopackInventoryScreen(menu: ExopackInventoryMenu) : MatteryScreen(menu, TranslatableComponent("otm.gui.exopack")) { + private lateinit var mainInventoryLine: EditablePanel + private lateinit var scrollPanel: DiscreteScrollBarPanel override fun updateInventoryRows(old: Int) { mainFrame!!.height = FRAME_BASE_HEIGHT + inventoryRows * AbstractSlotPanel.SIZE @@ -82,7 +82,7 @@ class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen(this@ExoPackInventoryScreen, frame, height = AbstractSlotPanel.SIZE * inventoryRows) { + mainInventoryLine = object : EditablePanel(this@ExopackInventoryScreen, frame, height = AbstractSlotPanel.SIZE * inventoryRows) { override fun mouseScrolledInner(x: Double, y: Double, scroll: Double): Boolean { return scrollPanel.mouseScrolledInner(x, y, scroll) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt index 119f24699..fcae41d08 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt @@ -10,7 +10,7 @@ import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.render.Widgets8 import ru.dbotthepony.mc.otm.client.render.sprites.sprite -import ru.dbotthepony.mc.otm.client.screen.ExoPackInventoryScreen +import ru.dbotthepony.mc.otm.client.screen.ExopackInventoryScreen import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.button.ButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.CheckBoxLabelPanel @@ -199,7 +199,7 @@ class EntityRendererPanel @JvmOverloads constructor( } override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { - ExoPackInventoryScreen.ENTITY_RECTANGLE.render(graphics) + ExopackInventoryScreen.ENTITY_RECTANGLE.render(graphics) } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt index 6a7ace4cd..3c73c955c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt @@ -33,13 +33,12 @@ import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.toImmutableList -import ru.dbotthepony.mc.otm.menu.ExoPackInventoryMenu +import ru.dbotthepony.mc.otm.menu.ExopackInventoryMenu import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRecipes import java.util.* import java.util.stream.Collectors import kotlin.collections.ArrayList -import kotlin.jvm.optionals.getOrNull import kotlin.properties.Delegates var isJeiLoaded = false @@ -87,13 +86,13 @@ class JEIPlugin : IModPlugin { override fun registerRecipeTransferHandlers(registration: IRecipeTransferRegistration) { val helper = registration.transferHelper - registration.addRecipeTransferHandler(object : IRecipeTransferHandler { - private val transfer = helper.createUnregisteredRecipeTransferHandler(object : IRecipeTransferInfo { - override fun getContainerClass(): Class { - return ExoPackInventoryMenu::class.java + registration.addRecipeTransferHandler(object : IRecipeTransferHandler { + private val transfer = helper.createUnregisteredRecipeTransferHandler(object : IRecipeTransferInfo { + override fun getContainerClass(): Class { + return ExopackInventoryMenu::class.java } - override fun getMenuType(): Optional> { + override fun getMenuType(): Optional> { return Optional.empty() } @@ -101,30 +100,30 @@ class JEIPlugin : IModPlugin { return RecipeTypes.CRAFTING } - override fun canHandle(container: ExoPackInventoryMenu, recipe: CraftingRecipe): Boolean { + override fun canHandle(container: ExopackInventoryMenu, recipe: CraftingRecipe): Boolean { return true } override fun getRecipeSlots( - container: ExoPackInventoryMenu, + container: ExopackInventoryMenu, recipe: CraftingRecipe ): List { return container.craftingSlots } override fun getInventorySlots( - container: ExoPackInventoryMenu, + container: ExopackInventoryMenu, recipe: CraftingRecipe ): List { return container.playerInventorySlots } }) - override fun getContainerClass(): Class { - return ExoPackInventoryMenu::class.java + override fun getContainerClass(): Class { + return ExopackInventoryMenu::class.java } - override fun getMenuType(): Optional> { + override fun getMenuType(): Optional> { return Optional.empty() } @@ -154,7 +153,7 @@ class JEIPlugin : IModPlugin { } override fun transferRecipe( - container: ExoPackInventoryMenu, + container: ExopackInventoryMenu, recipe: CraftingRecipe, recipeSlots: IRecipeSlotsView, player: Player, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt similarity index 91% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt index 9194fc3c5..27810de27 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt @@ -19,7 +19,7 @@ import ru.dbotthepony.mc.otm.network.ExoSuitMenuInitPacket import ru.dbotthepony.mc.otm.network.ExoSuitSlotPacket import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel -class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMenu(null, CONTAINER_ID, capability.ply.inventory) { +class ExopackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMenu(null, CONTAINER_ID, capability.ply.inventory) { val craftingGrid: CraftingContainer val craftingSlots: List @@ -207,35 +207,35 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen const val CONTAINER_ID: Int = 101 override fun sendInitialData(container: AbstractContainerMenu, itemStacks: NonNullList, carried: ItemStack, remoteDataSlots: IntArray) { - return sendInitialData(container as ExoPackInventoryMenu, itemStacks, carried, remoteDataSlots) + return sendInitialData(container as ExopackInventoryMenu, itemStacks, carried, remoteDataSlots) } override fun sendSlotChange(container: AbstractContainerMenu, slotId: Int, itemStack: ItemStack) { - return sendSlotChange(container as ExoPackInventoryMenu, slotId, itemStack) + return sendSlotChange(container as ExopackInventoryMenu, slotId, itemStack) } override fun sendCarriedChange(container: AbstractContainerMenu, itemStack: ItemStack) { - return sendCarriedChange(container as ExoPackInventoryMenu, itemStack) + return sendCarriedChange(container as ExopackInventoryMenu, itemStack) } override fun sendDataChange(container: AbstractContainerMenu, dataSlotId: Int, shortData: Int) { - return sendDataChange(container as ExoPackInventoryMenu, dataSlotId, shortData) + return sendDataChange(container as ExopackInventoryMenu, dataSlotId, shortData) } - fun sendInitialData(container: ExoPackInventoryMenu, itemStacks: NonNullList, carried: ItemStack, remoteDataSlots: IntArray) { + fun sendInitialData(container: ExopackInventoryMenu, itemStacks: NonNullList, carried: ItemStack, remoteDataSlots: IntArray) { MatteryPlayerNetworkChannel.send(container.ply as ServerPlayer, ExoSuitMenuInitPacket(itemStacks, carried, container.incrementStateId())) } - fun sendSlotChange(container: ExoPackInventoryMenu, slotId: Int, itemStack: ItemStack) { - if (container.slots[slotId].container != container.ply.inventory || container.ply.containerMenu is ExoPackInventoryMenu) + fun sendSlotChange(container: ExopackInventoryMenu, slotId: Int, itemStack: ItemStack) { + if (container.slots[slotId].container != container.ply.inventory || container.ply.containerMenu is ExopackInventoryMenu) MatteryPlayerNetworkChannel.send(container.ply as ServerPlayer, ExoSuitSlotPacket(slotId, itemStack, container.stateId)) } - fun sendCarriedChange(container: ExoPackInventoryMenu, itemStack: ItemStack) { + fun sendCarriedChange(container: ExopackInventoryMenu, itemStack: ItemStack) { MatteryPlayerNetworkChannel.send(container.ply as ServerPlayer, ExoSuitCarriedPacket(itemStack, container.stateId)) } - fun sendDataChange(container: ExoPackInventoryMenu, dataSlotId: Int, shortData: Int) { + fun sendDataChange(container: ExopackInventoryMenu, dataSlotId: Int, shortData: Int) { throw UnsupportedOperationException("This should never be called. Dumbass") } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt index 9634b0b73..9015b11c4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt @@ -30,7 +30,7 @@ import ru.dbotthepony.mc.otm.container.set import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.menu.tech.AndroidStationMenu -import ru.dbotthepony.mc.otm.menu.ExoPackInventoryMenu +import ru.dbotthepony.mc.otm.menu.ExopackInventoryMenu import ru.dbotthepony.mc.otm.registry.AndroidFeatures import ru.dbotthepony.mc.otm.registry.MRegistry import java.io.ByteArrayInputStream @@ -274,7 +274,7 @@ class ExoSuitSlotPacket(val slotId: Int, val itemStack: ItemStack, val container // don't duplicate data // really. - if (mattery.exoPackMenu.slots[slotId].container == minecraft.player?.inventory && minecraft.player?.containerMenu !is ExoPackInventoryMenu) + if (mattery.exoPackMenu.slots[slotId].container == minecraft.player?.inventory && minecraft.player?.containerMenu !is ExopackInventoryMenu) return@enqueueWork mattery.exoPackMenu.slots[slotId].set(itemStack) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt index 5cd4aeabb..84a72b312 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt @@ -10,7 +10,7 @@ import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.compat.InventoryScrollPacket import ru.dbotthepony.mc.otm.container.ItemFilterSlotPacket -import ru.dbotthepony.mc.otm.menu.ExoPackInventoryMenu +import ru.dbotthepony.mc.otm.menu.ExopackInventoryMenu import ru.dbotthepony.mc.otm.menu.matter.CancelTaskPacket import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.matter.PatternsChangePacket @@ -36,7 +36,7 @@ class MenuFieldPacket(val containerId: Int, val bytes: ByteArray, val length: In context.packetHandled = true context.enqueueWork { - if (containerId == ExoPackInventoryMenu.CONTAINER_ID) { + if (containerId == ExopackInventoryMenu.CONTAINER_ID) { minecraft.player?.matteryPlayer?.exoPackMenu?.mSynchronizer?.read(ByteArrayInputStream(bytes, 0, length)) } else { val menu = minecraft.player?.containerMenu as? MatteryMenu ?: return@enqueueWork From fa478e4b152ce001799d1122bfb85ebbcf3d6070 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 29 Jul 2023 19:17:40 +0700 Subject: [PATCH 0891/1199] Use separate thread to dispatch OTM network packets to players --- .../dbotthepony/mc/otm/GlobalEventHandler.kt | 7 +- .../mc/otm/network/MatteryNetworkChannel.kt | 77 +++++++++++++++---- 2 files changed, 67 insertions(+), 17 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt index c290f27f9..f1c7c6aeb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt @@ -22,6 +22,7 @@ import ru.dbotthepony.mc.otm.core.util.IConditionalTickable import ru.dbotthepony.mc.otm.core.util.ITickable import ru.dbotthepony.mc.otm.core.util.TickList import ru.dbotthepony.mc.otm.graph.Abstract6Graph +import ru.dbotthepony.mc.otm.network.MatteryNetworkChannel import java.util.* private val preServerTick = TickList() @@ -151,6 +152,7 @@ fun onServerTick(event: ServerTickEvent) { // чтоб не плодить кучу подписчиков, вызовем напрямую отсюда Abstract6Graph.tick() AbstractProfiledStorage.onServerPostTick() + MatteryNetworkChannel.onServerPostTick() } } @@ -270,16 +272,18 @@ fun onServerStarting(event: ServerAboutToStartEvent) { SERVER_IS_LIVE = true _server = event.server _serverThread = Thread.currentThread() + MatteryNetworkChannel.onServerStarting() } fun onServerStopping(event: ServerStoppingEvent) { clear() SERVER_IS_LIVE = false + MatteryNetworkChannel.onServerStopping() } fun onServerStopped(event: ServerStoppedEvent) { if (SERVER_IS_LIVE) { - LOGGER.fatal("ServerStoppingEvent did not fire. If server has crashed this is normal. However, if server finished it's work 'gracefully' this is a bug.") + LOGGER.fatal("ServerStoppingEvent did not fire. If server has crashed this is normal. However, if server finished it's work 'gracefully' this is a bug!") clear() SERVER_IS_LIVE = false @@ -287,4 +291,5 @@ fun onServerStopped(event: ServerStoppedEvent) { _server = null _serverThread = null + MatteryNetworkChannel.onServerStopped() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt index 00f8ae47a..4a0fbfc06 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt @@ -6,17 +6,24 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.Entity import net.minecraft.world.entity.player.Player +import net.minecraftforge.event.TickEvent +import net.minecraftforge.event.TickEvent.ServerTickEvent +import net.minecraftforge.event.server.ServerStoppedEvent +import net.minecraftforge.event.server.ServerStoppingEvent import net.minecraftforge.network.NetworkDirection import net.minecraftforge.network.NetworkEvent import net.minecraftforge.network.NetworkRegistry import net.minecraftforge.network.PacketDistributor import net.minecraftforge.network.simple.SimpleChannel +import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.NULLABLE_MINECRAFT_SERVER import ru.dbotthepony.mc.otm.OverdriveThatMatters import java.math.BigDecimal import java.math.BigInteger import java.util.Optional import java.util.concurrent.CompletableFuture +import java.util.concurrent.ConcurrentLinkedDeque +import java.util.concurrent.locks.LockSupport import java.util.function.BiConsumer import java.util.function.Supplier import kotlin.reflect.KClass @@ -30,18 +37,6 @@ var Supplier.packetHandled: Boolean val Supplier.sender: ServerPlayer? get() = get().sender -fun FriendlyByteBuf.writeDecimal(value: BigDecimal) { - writeInt(value.scale()) - writeByteArray(value.unscaledValue().toByteArray()) -} - -fun FriendlyByteBuf.readDecimal(): BigDecimal { - val scale = readInt() - val bytes = readByteArray() - - return BigDecimal(BigInteger(bytes), scale) -} - interface MatteryPacket { fun write(buff: FriendlyByteBuf) fun play(context: Supplier) @@ -59,7 +54,7 @@ abstract class MatteryNetworkChannel(val version: String, val name: String) { fun send(ply: Player, packet: Any) { if (ply is ServerPlayer) { - channel.send(PacketDistributor.PLAYER.with { ply }, packet) + queue.add(Task(channel, PacketDistributor.PLAYER.with { ply }, packet)) } } @@ -68,7 +63,7 @@ abstract class MatteryNetworkChannel(val version: String, val name: String) { return } - channel.send(PacketDistributor.TRACKING_ENTITY.with { entity }, packet) + queue.add(Task(channel, PacketDistributor.TRACKING_ENTITY.with { entity }, packet)) } fun sendTrackingAndSelf(entity: Entity, packet: Any) { @@ -76,10 +71,12 @@ abstract class MatteryNetworkChannel(val version: String, val name: String) { return } - channel.send(PacketDistributor.TRACKING_ENTITY_AND_SELF.with { entity }, packet) + queue.add(Task(channel, PacketDistributor.TRACKING_ENTITY_AND_SELF.with { entity }, packet)) } - fun send(distributor: PacketDistributor.PacketTarget, packet: Any) = channel.send(distributor, packet) + fun send(distributor: PacketDistributor.PacketTarget, packet: Any) { + queue.add(Task(channel, distributor, packet)) + } private var nextNetworkPacketID = 0 @@ -113,4 +110,52 @@ abstract class MatteryNetworkChannel(val version: String, val name: String) { ) { add(packetClass.java, MatteryPacket::write, reader, MatteryPacket::play, direction) } + + private data class Task(val channel: SimpleChannel, val target: PacketDistributor.PacketTarget, val packet: Any) + + companion object { + private val logger = LogManager.getLogger() + private var thread: Thread? = null + + private val queue = ConcurrentLinkedDeque() + + @Volatile + private var interrupt = false + + private fun run() { + while (!interrupt) { + val task = queue.pollFirst() + + if (task == null) { + LockSupport.park() + } else { + try { + task.channel.send(task.target, task.packet) + } catch(err: Throwable) { + logger.error("Error executing network dispatcher task", err) + } + } + } + + logger.debug("Overdrive That Matters Packet Dispatcher thread exited gracefully") + } + + internal fun onServerPostTick() { + LockSupport.unpark(thread) + } + + internal fun onServerStarting() { + interrupt = false + check(thread == null) { "Already having network dispatcher thread, ServerStartingEvent was fired twice!" } + thread = Thread(this::run, "Overdrive That Matters Network Dispatcher").also { it.start() } + } + + internal fun onServerStopping() { + interrupt = true + } + + internal fun onServerStopped() { + interrupt = true + } + } } From 0da8278998da1a968397915561ef3126f8813352 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 29 Jul 2023 22:45:52 +0700 Subject: [PATCH 0892/1199] Update build script --- build.gradle.kts | 76 ++++++++++++--------------------------------- settings.gradle.kts | 13 -------- 2 files changed, 20 insertions(+), 69 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index b8c6b9d4b..2cb1755d2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,7 +3,6 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import java.util.Date import java.text.SimpleDateFormat import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream -import java.util.UUID val mod_version: String by project val mc_version: String by project @@ -20,16 +19,14 @@ plugins { `maven-publish` id("net.minecraftforge.gradle") id("org.spongepowered.mixin") - id("org.parchmentmc.librarian.forgegradle") } configurations { - create("library") // non-mod libraries create("klibrary") // kotlin libs - get("implementation").extendsFrom(get("library"), get("klibrary")) + get("implementation").extendsFrom(get("klibrary")) } -data class GitInfo(val version: String, val count: String, val tag: String, val buildNumber: String) { +data class GitInfo(val version: String, val tag: String, val buildNumber: String) { // val tagIsVersion: Boolean get() = tag != "" && tag.matches(Regex("v[0-9]+\\.[0-9]\\.[0-9]")) val publishVersion: String get() { @@ -67,7 +64,7 @@ data class GitInfo(val version: String, val count: String, val tag: String, val } } -val gitVersion = getCommitVersion() ?: GitInfo("", "", "", "") +val gitVersion = getCommitVersion() ?: GitInfo("", "", "") version = gitVersion.modVersion group = "ru.dbotthepony" @@ -76,7 +73,6 @@ fun getCommitVersion(): GitInfo? { try { val versionStream = FastByteArrayOutputStream() val tagStream = FastByteArrayOutputStream() - val countStream = FastByteArrayOutputStream() val gotVersion = exec { commandLine("git", "rev-parse", "--short", "HEAD") @@ -84,27 +80,20 @@ fun getCommitVersion(): GitInfo? { standardOutput = versionStream }.exitValue == 0 - val gotCount = exec { - commandLine("git", "rev-list", "--count", "HEAD") - workingDir(".") - standardOutput = countStream - }.exitValue == 0 - val gotTag = exec { commandLine("git", "tag", "--points-at", "HEAD") workingDir(".") standardOutput = tagStream }.exitValue == 0 - if (!gotVersion || !gotCount || !gotTag) { + if (!gotVersion || !gotTag) { return null } val version = versionStream.array.copyOfRange(0, versionStream.length).toString(Charsets.UTF_8).trim() val tag = tagStream.array.copyOfRange(0, tagStream.length).toString(Charsets.UTF_8).trim() - val count = countStream.array.copyOfRange(0, countStream.length).toString(Charsets.UTF_8).trim() - return GitInfo(version, count, tag, System.getenv("BUILD_NUMBER") ?: "") + return GitInfo(version, tag, System.getenv("BUILD_NUMBER") ?: "") } catch(err: Throwable) { println("Error getting git version") println(err) @@ -147,8 +136,6 @@ dependencies { val jupiter_version: String by project val kotlin_version: String by project val kotlin_for_forge_version: String by project - val kotlin_coroutines_version: String by project - val kotlin_serialization_version: String by project val mixin_version: String by project minecraft("net.minecraftforge:forge:$mc_version-$forge_version") @@ -156,7 +143,6 @@ dependencies { implementation("thedarkcolour:kotlinforforge:$kotlin_for_forge_version") - fun library(notation: Any) { this.add("library", notation) } fun klibrary(notation: Any) { this.add("klibrary", notation) } val excludeKGroup = closureOf { @@ -165,9 +151,6 @@ dependencies { klibrary(create("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version", excludeKGroup)) klibrary(create("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version", excludeKGroup)) - klibrary(create("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version", excludeKGroup)) - klibrary(create("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$kotlin_coroutines_version", excludeKGroup)) - klibrary(create("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlin_serialization_version", excludeKGroup)) compileOnly("yalter.mousetweaks:MouseTweaks:2.23:api") annotationProcessor("org.spongepowered:mixin:${mixin_version}:processor") @@ -217,21 +200,26 @@ dependencies { configurations { getByName("dataImplementation").extendsFrom(getByName("implementation")) - getByName("library").resolutionStrategy.cacheChangingModulesFor(10, "minutes") } minecraft { - val use_parchment: String by project - - if (use_parchment.toBoolean()) { - mappings("parchment", parchment_version) - } else { - mappings("official", mc_version) - } + mappings("official", mc_version) accessTransformer(file("src/main/resources/META-INF/accesstransformer.cfg")) runs { + configureEach { + workingDirectory = project.file("run").absolutePath + + // "SCAN": For mods scan. + // "REGISTRIES": For firing of registry events. + // "REGISTRYDUMP": For getting the contents of all registries. + property("forge.logging.markers", "REGISTRIES") + + // Log4j console level + property("forge.logging.console.level", "debug") + } + create("client") { mods { create(mod_id) { @@ -282,33 +270,11 @@ minecraft { } } -mixin { +/*mixin { add(sourceSets.main.get(), "$mod_id.refmap.json") config("$mod_id.mixins.json") config("$mod_id.ad_astra.mixins.json") -} - -minecraft.runs.all { - workingDirectory = project.file("run").absolutePath - - // "SCAN": For mods scan. - // "REGISTRIES": For firing of registry events. - // "REGISTRYDUMP": For getting the contents of all registries. - property("forge.logging.markers", "REGISTRIES") - - // Log4j console level - property("forge.logging.console.level", "debug") - - lazyToken("minecraft_classpath") { - configurations["library"] - .copyRecursive() - .resolve() - .map { it.absolutePath } - .toMutableList() - .also { it.addAll(configurations["klibrary"].copyRecursive().resolve().map { it.absolutePath }) } - .joinToString(File.pathSeparator) - } -} +}*/ repositories { // If you have mod jar dependencies in ./libs, you can declare them as a repository like so: @@ -383,7 +349,6 @@ fun org.gradle.jvm.tasks.Jar.attachManifest() { // Example configuration to allow publishing using the maven-publish plugin // This is the preferred method to reobfuscate your jar file tasks.jar.configure { - from(configurations["library"].map { if (it.isDirectory) it else zipTree(it) }) finalizedBy("reobfJar") attachManifest() archiveVersion.set(gitVersion.jarName) @@ -397,7 +362,6 @@ tasks { create("deobfJar", org.gradle.jvm.tasks.Jar::class.java) { archiveClassifier.set("deobf") - from(configurations["library"].map { if (it.isDirectory) it else zipTree(it) }) from(sourceSets.main.get().output) attachManifest() } diff --git a/settings.gradle.kts b/settings.gradle.kts index caa828904..4293ab440 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -31,15 +31,6 @@ buildscript { } } - maven(url = "https://maven.parchmentmc.org") { - name = "Parchment mappings" - - content { - includeGroup("org.parchmentmc") - includeGroup("org.parchmentmc.feather") - } - } - mavenCentral() } @@ -47,15 +38,11 @@ buildscript { val kotlin_version: String by settings val forge_gradle_version: String by settings val mixingradle_version: String by settings - val koremods_modlauncher_version: String by settings - val koremods_script_version: String by settings classpath(group = "net.minecraftforge.gradle", name = "ForgeGradle", version = forge_gradle_version) classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}") classpath("org.spongepowered:mixingradle:${mixingradle_version}") - classpath(group = "org.parchmentmc", name = "librarian", version = "1.+") - classpath(group = "org.gradle.toolchains", name = "foojay-resolver", version = "0.5.0") } } From 5bb3f91f9a911a1e8366680a83347767c0369e2c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 29 Jul 2023 22:56:11 +0700 Subject: [PATCH 0893/1199] Bump KFF to 4.4.0, Kotlin to 1.9.0 This fixes issue with "classes" triggering "jar" and "reobfJar" --- gradle.properties | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index 7402afb41..7319d4a08 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,6 @@ use_commit_hash_in_version=true mc_version=1.20.1 use_parchment=false -parchment_version=2023.03.12-1.19.3 jei_mc_version=1.20.1 curios_mc_version=1.20 @@ -33,9 +32,7 @@ resourceful_config_id=4576455 jade_id=4614153 configured_id=4462894 -kotlin_for_forge_version=3.1.0 -kotlin_version=1.8.0 -kotlin_coroutines_version=1.6.0 -kotlin_serialization_version=1.3.2 +kotlin_for_forge_version=4.4.0 +kotlin_version=1.9.0 handle_deps=true From e95e0f7d56e71a88c457ec391343f1f9514545e5 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 29 Jul 2023 23:15:21 +0700 Subject: [PATCH 0894/1199] This is already done by KFF --- build.gradle.kts | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 2cb1755d2..1b48fd99d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -21,11 +21,6 @@ plugins { id("org.spongepowered.mixin") } -configurations { - create("klibrary") // kotlin libs - get("implementation").extendsFrom(get("klibrary")) -} - data class GitInfo(val version: String, val tag: String, val buildNumber: String) { // val tagIsVersion: Boolean get() = tag != "" && tag.matches(Regex("v[0-9]+\\.[0-9]\\.[0-9]")) @@ -134,7 +129,6 @@ tasks.test { dependencies { val jupiter_version: String by project - val kotlin_version: String by project val kotlin_for_forge_version: String by project val mixin_version: String by project @@ -143,15 +137,6 @@ dependencies { implementation("thedarkcolour:kotlinforforge:$kotlin_for_forge_version") - fun klibrary(notation: Any) { this.add("klibrary", notation) } - - val excludeKGroup = closureOf { - (this as ExternalModuleDependency).exclude(group = "org.jetbrains", module = "annotations") - } as Closure - - klibrary(create("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version", excludeKGroup)) - klibrary(create("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version", excludeKGroup)) - compileOnly("yalter.mousetweaks:MouseTweaks:2.23:api") annotationProcessor("org.spongepowered:mixin:${mixin_version}:processor") From fc715da518c4ea4496a65a56fb731aa614a25be9 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 29 Jul 2023 23:34:53 +0700 Subject: [PATCH 0895/1199] Update protected -> public properties --- .../dbotthepony/mc/otm/client/screen/MatteryScreen.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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 cdf63913f..ad038b27c 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 @@ -6,6 +6,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import net.minecraft.ChatFormatting import net.minecraft.client.gui.Font import net.minecraft.client.gui.GuiGraphics +import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory @@ -66,14 +67,14 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit private var madeMainFrame = false var font: Font - get() = font + get() = super.font set(font) { super.font = font } var hoveredSlot: Slot? - get() = hoveredSlot + get() = super.hoveredSlot set(value) { super.hoveredSlot = value } - val quickCraftSlots: MutableSet get() = quickCraftSlots - val quickCraftingType get() = quickCraftingType - val isQuickCrafting get() = isQuickCrafting + val quickCraftSlots: MutableSet get() = super.quickCraftSlots + val quickCraftingType: Int get() = super.quickCraftingType + val isQuickCrafting: Boolean get() = super.isQuickCrafting fun renderItemStack(graphics: GuiGraphics, itemstack: ItemStack, countOverride: String? = null) { if (!itemstack.isEmpty) { From bfc7947a62c1869942a0dde62cb3616f20e07882 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 30 Jul 2023 00:54:07 +0700 Subject: [PATCH 0896/1199] Exopack smoke particles when furnace is working --- .../mc/otm/client/model/ExosuitModel.java | 13 ++- .../otm/android/feature/JumpBoostFeature.kt | 47 +--------- .../otm/capability/MatteryPlayerCapability.kt | 50 +++++++++-- .../client/screen/ExopackInventoryScreen.kt | 4 +- .../screen/panels/EntityRendererPanel.kt | 2 +- .../mc/otm/menu/ExopackInventoryMenu.kt | 12 +-- .../mc/otm/network/GenericNetworkChannel.kt | 44 +++++++++- .../mc/otm/network/MatteryNetworkChannel.kt | 9 ++ .../network/MatteryPlayerNetworkChannel.kt | 88 +++++++++++++++---- 9 files changed, 190 insertions(+), 79 deletions(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/client/model/ExosuitModel.java b/src/main/java/ru/dbotthepony/mc/otm/client/model/ExosuitModel.java index 00d07f7d8..a3b528e85 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/client/model/ExosuitModel.java +++ b/src/main/java/ru/dbotthepony/mc/otm/client/model/ExosuitModel.java @@ -1,7 +1,9 @@ package ru.dbotthepony.mc.otm.client.model; +import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; +import net.minecraft.client.Minecraft; import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.PlayerModel; import net.minecraft.client.model.geom.PartPose; @@ -19,8 +21,11 @@ import net.minecraft.client.renderer.entity.layers.RenderLayer; import net.minecraft.client.renderer.entity.player.PlayerRenderer; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.client.event.RenderPlayerEvent; +import org.joml.Vector3f; +import org.joml.Vector4f; import ru.dbotthepony.mc.otm.OverdriveThatMatters; import ru.dbotthepony.mc.otm.capability.MatteryCapability; +import ru.dbotthepony.mc.otm.network.SmokeParticlesPacket; import javax.annotation.Nonnull; import java.util.Set; @@ -123,7 +128,9 @@ public final class ExosuitModel { return; } - if (cap.resolve().get().getHasExopack() && cap.resolve().get().getDisplayExopack()) { + var mattery = cap.resolve().get(); + + if (mattery.getHasExopack() && mattery.isExopackVisible()) { var model = getParentModel(); model.copyPropertiesTo(modelNormal); model.copyPropertiesTo(modelGlow); @@ -152,7 +159,7 @@ public final class ExosuitModel { ); } - if (cap.resolve().get().getExopackGlows()) { + if (mattery.getExopackGlows()) { modelGlow.renderToBuffer( poseStack, bufferSource.getBuffer(RenderType.entityTranslucentEmissive(texture)), @@ -171,6 +178,8 @@ public final class ExosuitModel { 1f, 1f, 1f, 1f ); } + + mattery.makeSmokeParticles(poseStack, model); } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt index fe281455d..ad4205e90 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt @@ -1,53 +1,37 @@ package ru.dbotthepony.mc.otm.android.feature -import com.mojang.blaze3d.systems.RenderSystem -import com.mojang.blaze3d.vertex.PoseStack -import net.minecraft.ChatFormatting import net.minecraft.client.gui.GuiGraphics import net.minecraft.core.particles.ParticleTypes import net.minecraft.network.FriendlyByteBuf -import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import net.minecraft.sounds.SoundSource import net.minecraft.util.RandomSource import net.minecraft.world.level.Level -import net.minecraft.world.phys.Vec3 import net.minecraftforge.network.NetworkEvent import net.minecraftforge.network.PacketDistributor import net.minecraftforge.network.PacketDistributor.TargetPoint import ru.dbotthepony.mc.otm.config.ClientConfig -import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.config.AndroidConfig -import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.capability.matteryPlayer -import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.Vector -import ru.dbotthepony.mc.otm.core.math.component1 -import ru.dbotthepony.mc.otm.core.math.component2 -import ru.dbotthepony.mc.otm.core.math.component3 -import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.core.math.plus +import ru.dbotthepony.mc.otm.network.GenericNetworkChannel import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel +import ru.dbotthepony.mc.otm.network.SmokeParticlesPacket import ru.dbotthepony.mc.otm.network.enqueueWork import ru.dbotthepony.mc.otm.network.packetHandled import ru.dbotthepony.mc.otm.network.sender import ru.dbotthepony.mc.otm.registry.AndroidFeatures -import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.registry.MSoundEvents import java.util.function.Supplier -private fun makeSmoke(x: Double, y: Double, z: Double, random: RandomSource, level: Level) { - for (i in 0 .. random.nextInt(4, 8)) - level.addParticle(ParticleTypes.POOF, x + random.nextDouble() * 0.5 - 0.25, y + random.nextDouble() * 0.5 - 0.25, z + random.nextDouble() * 0.5 - 0.25, random.nextGaussian() * 0.02, random.nextGaussian() * 0.02, random.nextGaussian() * 0.02) -} - object TriggerJumpBoostPacket : MatteryPacket { override fun write(buff: FriendlyByteBuf) { // no op @@ -74,36 +58,13 @@ object TriggerJumpBoostPacket : MatteryPacket { 1f, 1f ) - MatteryPlayerNetworkChannel.send(PacketDistributor.NEAR.with { TargetPoint(it, it.x, it.y, it.z, 64.0, it.level().dimension()) }, JumpBoostParticlesPacket(it.x, it.y, it.z)) + GenericNetworkChannel.makeSmoke(it, it.x, it.y, it.z) } } } } } -class JumpBoostParticlesPacket(val x: Double, val y: Double, val z: Double) : MatteryPacket { - override fun write(buff: FriendlyByteBuf) { - buff.writeDouble(x) - buff.writeDouble(y) - buff.writeDouble(z) - } - - override fun play(context: Supplier) { - context.packetHandled = true - context.enqueueWork { - minecraft.player?.level()?.let { - makeSmoke(x, y, z, it.random, it) - } - } - } - - companion object { - fun read(buff: FriendlyByteBuf): JumpBoostParticlesPacket { - return JumpBoostParticlesPacket(buff.readDouble(), buff.readDouble(), buff.readDouble()) - } - } -} - class JumpBoostFeature(capability: MatteryPlayerCapability) : AndroidSwitchableFeature(AndroidFeatures.JUMP_BOOST, capability) { private var tickCooldownClient = false @@ -141,7 +102,7 @@ class JumpBoostFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF 1f, 1f ) - makeSmoke(ply.x, ply.y, ply.z, ply.random, ply.level()) + SmokeParticlesPacket.makeSmoke(ply.x, ply.y, ply.z, ply.random, ply.level()) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index d8c72c869..1764341f0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -1,11 +1,17 @@ package ru.dbotthepony.mc.otm.capability +import com.mojang.blaze3d.systems.RenderSystem +import com.mojang.blaze3d.vertex.PoseStack import it.unimi.dsi.fastutil.ints.IntAVLTreeSet import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import net.minecraft.ChatFormatting +import net.minecraft.client.Minecraft +import net.minecraft.client.model.PlayerModel +import net.minecraft.client.player.AbstractClientPlayer import net.minecraft.commands.Commands import net.minecraft.commands.arguments.EntityArgument import net.minecraft.core.Direction +import net.minecraft.core.particles.ParticleTypes import net.minecraft.nbt.ByteTag import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.IntTag @@ -52,18 +58,20 @@ import net.minecraftforge.event.entity.living.MobEffectEvent import net.minecraftforge.event.entity.player.PlayerEvent import net.minecraftforge.eventbus.api.Cancelable import net.minecraftforge.eventbus.api.Event +import net.minecraftforge.network.PacketDistributor import net.minecraftforge.registries.ForgeRegistries import net.minecraftforge.server.command.EnumArgument import org.apache.logging.log4j.LogManager +import org.joml.Vector4f import ru.dbotthepony.mc.otm.* import ru.dbotthepony.mc.otm.android.AndroidFeature import ru.dbotthepony.mc.otm.android.AndroidFeatureType import ru.dbotthepony.mc.otm.android.AndroidResearch import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidResearchType +import ru.dbotthepony.mc.otm.block.entity.ItemJob import ru.dbotthepony.mc.otm.block.entity.JobContainer import ru.dbotthepony.mc.otm.block.entity.JobStatus -import ru.dbotthepony.mc.otm.block.entity.ItemJob import ru.dbotthepony.mc.otm.block.entity.MachineJobEventLoop import ru.dbotthepony.mc.otm.capability.energy.BatteryBackedEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage @@ -83,7 +91,11 @@ import ru.dbotthepony.mc.otm.core.collect.UUIDIntModifiersMap import ru.dbotthepony.mc.otm.core.collect.filter import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.RGBAColor +import ru.dbotthepony.mc.otm.core.math.component1 +import ru.dbotthepony.mc.otm.core.math.component2 +import ru.dbotthepony.mc.otm.core.math.component3 import ru.dbotthepony.mc.otm.core.math.minus +import ru.dbotthepony.mc.otm.core.math.toRadians import ru.dbotthepony.mc.otm.core.nbt.getByteList import ru.dbotthepony.mc.otm.core.nbt.getCompoundList import ru.dbotthepony.mc.otm.core.nbt.getIntList @@ -98,6 +110,7 @@ import ru.dbotthepony.mc.otm.core.util.UUIDValueCodec import ru.dbotthepony.mc.otm.core.util.VarIntValueCodec import ru.dbotthepony.mc.otm.menu.ExopackInventoryMenu import ru.dbotthepony.mc.otm.network.* +import ru.dbotthepony.mc.otm.network.SmokeParticlesPacket.Companion.makeSmoke import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer import ru.dbotthepony.mc.otm.registry.AndroidFeatures import ru.dbotthepony.mc.otm.registry.MDamageTypes @@ -116,8 +129,8 @@ import ru.dbotthepony.mc.otm.triggers.ExopackSlotsExpandedTrigger import java.util.* import java.util.stream.Stream import kotlin.collections.ArrayDeque -import kotlin.collections.ArrayList -import kotlin.collections.HashMap +import kotlin.math.cos +import kotlin.math.sin import kotlin.reflect.KMutableProperty1 private fun Player.dropContainer(container: Container, spill: Boolean = true, setThrower: Boolean = false) { @@ -209,7 +222,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial /** * Whenever to render Exopack on player */ - var displayExopack by publicSynchronizer.bool(true).property + var isExopackVisible by publicSynchronizer.bool(true).property /** * Whenever to render Exopack glow in dark @@ -376,6 +389,10 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial private var wasInLiquid = false private var lastDimension = ResourceLocation("overworld") + // clientside only flag for render hook + // TODO: actual code, currently particles spawn just behind player on ExopackSmokePacket + var spawnExopackSmoke = false + /** * Whenever player should become an Android once transformation conditions are met (e.g. player dies or sleeps in bed) */ @@ -446,6 +463,14 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } } + override fun onJobTick(status: JobStatus) { + super.onJobTick(status) + + if (isExopackVisible && ply.level().random.nextFloat() <= 0.05f) { + MatteryPlayerNetworkChannel.send(PacketDistributor.TRACKING_ENTITY_AND_SELF.with { ply as ServerPlayer }, ExopackSmokePacket(ply.uuid)) + } + } + val input = MatteryContainer({ notify(IdleReason.ITEM) }, 1) val output = MatteryContainer({ notify(IdleReason.ITEM) }, 1) @@ -484,7 +509,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial savetables.bool(::isAndroid) savetables.bool(::willBecomeAndroid) savetables.bool(::hasExopack, "hasExoSuit") - savetables.bool(::displayExopack, "displayExoSuit") + savetables.bool(::isExopackVisible, "displayExoSuit") savetables.bool(::isExopackCraftingUpgraded, "isExoSuitCraftingUpgraded") savetables.int(::nextDischargeHurt) savetables.int(::nextHealTick) @@ -1431,6 +1456,21 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial return stack.isEmpty } + fun makeSmokeParticles(poseStack: PoseStack, model: PlayerModel) { + if (spawnExopackSmoke) { + spawnExopackSmoke = false + + // TODO: Proper positioning + + val pos = Vector4f(model.body.x / 16f, model.body.y / 16f, model.body.z / 16f, 1f) + val cam = minecraft.gameRenderer.mainCamera.position + + pos.mul(RenderSystem.getProjectionMatrix()) + pos.mul(poseStack.last().pose()) + makeSmoke(cam.x + pos.x, cam.y + pos.y, cam.z + pos.z, ply.level().random, ply.level()) + } + } + enum class UpgradeType(val prop: KMutableProperty1) { CRAFTING(MatteryPlayerCapability::isExopackCraftingUpgraded), SMELTING(MatteryPlayerCapability::isExopackSmeltingInstalled); diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt index 018db7198..3d33f11ff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt @@ -23,7 +23,7 @@ import ru.dbotthepony.mc.otm.compat.curios.isCuriosLoaded import ru.dbotthepony.mc.otm.compat.curios.openCuriosScreen import ru.dbotthepony.mc.otm.core.math.integerDivisionDown import ru.dbotthepony.mc.otm.menu.ExopackInventoryMenu -import ru.dbotthepony.mc.otm.network.ExoPackMenuOpen +import ru.dbotthepony.mc.otm.network.ExopackMenuOpen import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel import yalter.mousetweaks.api.MouseTweaksDisableWheelTweak @@ -238,7 +238,7 @@ class ExopackInventoryScreen(menu: ExopackInventoryMenu) : MatteryScreen, matteryPlaye text = TranslatableComponent("otm.gui.exopack.toggle_visibility"), isChecked = GetterSetter.of( { - matteryPlayer.displayExopack + matteryPlayer.isExopackVisible }, { if (it) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt index 27810de27..e671e5a9a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt @@ -14,9 +14,9 @@ import ru.dbotthepony.mc.otm.compat.curios.curiosSlots import ru.dbotthepony.mc.otm.container.iterator import ru.dbotthepony.mc.otm.menu.input.InstantBooleanInput import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget -import ru.dbotthepony.mc.otm.network.ExoSuitCarriedPacket -import ru.dbotthepony.mc.otm.network.ExoSuitMenuInitPacket -import ru.dbotthepony.mc.otm.network.ExoSuitSlotPacket +import ru.dbotthepony.mc.otm.network.ExopackCarriedPacket +import ru.dbotthepony.mc.otm.network.ExopackMenuInitPacket +import ru.dbotthepony.mc.otm.network.ExopackSlotPacket import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel class ExopackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMenu(null, CONTAINER_ID, capability.ply.inventory) { @@ -223,16 +223,16 @@ class ExopackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen } fun sendInitialData(container: ExopackInventoryMenu, itemStacks: NonNullList, carried: ItemStack, remoteDataSlots: IntArray) { - MatteryPlayerNetworkChannel.send(container.ply as ServerPlayer, ExoSuitMenuInitPacket(itemStacks, carried, container.incrementStateId())) + MatteryPlayerNetworkChannel.send(container.ply as ServerPlayer, ExopackMenuInitPacket(itemStacks, carried, container.incrementStateId())) } fun sendSlotChange(container: ExopackInventoryMenu, slotId: Int, itemStack: ItemStack) { if (container.slots[slotId].container != container.ply.inventory || container.ply.containerMenu is ExopackInventoryMenu) - MatteryPlayerNetworkChannel.send(container.ply as ServerPlayer, ExoSuitSlotPacket(slotId, itemStack, container.stateId)) + MatteryPlayerNetworkChannel.send(container.ply as ServerPlayer, ExopackSlotPacket(slotId, itemStack, container.stateId)) } fun sendCarriedChange(container: ExopackInventoryMenu, itemStack: ItemStack) { - MatteryPlayerNetworkChannel.send(container.ply as ServerPlayer, ExoSuitCarriedPacket(itemStack, container.stateId)) + MatteryPlayerNetworkChannel.send(container.ply as ServerPlayer, ExopackCarriedPacket(itemStack, container.stateId)) } fun sendDataChange(container: ExopackInventoryMenu, dataSlotId: Int, shortData: Int) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt index c98aa769d..c27a9be9e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt @@ -4,10 +4,14 @@ import it.unimi.dsi.fastutil.io.FastByteArrayInputStream import it.unimi.dsi.fastutil.objects.Object2ObjectFunction import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap import net.minecraft.core.BlockPos +import net.minecraft.core.particles.ParticleTypes import net.minecraft.network.FriendlyByteBuf +import net.minecraft.server.level.ServerPlayer +import net.minecraft.util.RandomSource import net.minecraft.world.level.Level import net.minecraftforge.network.NetworkDirection import net.minecraftforge.network.NetworkEvent +import net.minecraftforge.network.PacketDistributor import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.feature.ItemEntityDataPacket @@ -20,6 +24,34 @@ import java.util.* import java.util.function.Supplier import kotlin.collections.ArrayList +class SmokeParticlesPacket(val x: Double, val y: Double, val z: Double) : MatteryPacket { + override fun write(buff: FriendlyByteBuf) { + buff.writeDouble(x) + buff.writeDouble(y) + buff.writeDouble(z) + } + + override fun play(context: Supplier) { + context.packetHandled = true + context.enqueueWork { + minecraft.player?.level()?.let { + makeSmoke(x, y, z, it.random, it) + } + } + } + + companion object { + fun read(buff: FriendlyByteBuf): SmokeParticlesPacket { + return SmokeParticlesPacket(buff.readDouble(), buff.readDouble(), buff.readDouble()) + } + + fun makeSmoke(x: Double, y: Double, z: Double, random: RandomSource, level: Level) { + for (i in 0 .. random.nextInt(4, 8)) + level.addParticle(ParticleTypes.POOF, x + random.nextDouble() * 0.5 - 0.25, y + random.nextDouble() * 0.5 - 0.25, z + random.nextDouble() * 0.5 - 0.25, random.nextGaussian() * 0.02, random.nextGaussian() * 0.02, random.nextGaussian() * 0.02) + } + } +} + class BlockEntitySyncPacket(val position: BlockPos, val buffer: ByteArray, val validBytes: Int) : MatteryPacket { override fun write(buff: FriendlyByteBuf) { buff.writeBlockPos(position) @@ -96,9 +128,17 @@ class BlockEntitySyncPacket(val position: BlockPos, val buffer: ByteArray, val v } object GenericNetworkChannel : MatteryNetworkChannel( - version = "3", + version = "4", name = "generic" ) { + fun makeSmoke(x: Double, y: Double, z: Double, level: Level) { + send(PacketDistributor.NEAR.with { PacketDistributor.TargetPoint(x, y, z, 64.0, level.dimension()) }, SmokeParticlesPacket(x, y, z)) + } + + fun makeSmoke(excluded: ServerPlayer, x: Double, y: Double, z: Double) { + send(PacketDistributor.NEAR.with { PacketDistributor.TargetPoint(excluded, x, y, z, 64.0, excluded.level().dimension()) }, SmokeParticlesPacket(x, y, z)) + } + fun register() { add(QuantumBatteryItem.ChargePacket::class.java, QuantumBatteryItem.Companion::readPacket, NetworkDirection.PLAY_TO_CLIENT) @@ -107,5 +147,7 @@ object GenericNetworkChannel : MatteryNetworkChannel( add(AndroidResearchManager.SyncPacket::class.java, AndroidResearchManager::readSyncPacket, NetworkDirection.PLAY_TO_CLIENT) add(MatterManager.SyncPacket::class.java, MatterManager::readSyncPacket, NetworkDirection.PLAY_TO_CLIENT) + + add(SmokeParticlesPacket::class, SmokeParticlesPacket.Companion::read, NetworkDirection.PLAY_TO_CLIENT) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt index 4a0fbfc06..d15d9ed8f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt @@ -122,6 +122,15 @@ abstract class MatteryNetworkChannel(val version: String, val name: String) { @Volatile private var interrupt = false + /** + * Reason behind separate thread is that Minecraft connection class does not allow to enqueue messages, + * nor does Forge. This leads to extensive calls to Netty Channel eventLoop().execute(), which is somehow resource + * heavy, as it calls wakeup on Windows, eventFdWrite on Linux, etc., when all we want to do is to enqueue packet. + * + * Concurrent safety - Minecraft Channel (send method) does not do any writes (unless player is unconnected, in which case it uses thread safe queue), hence it is thread safe. + * OTM packets are always dispatched in correct order to client. + * Netty eventLoop executor is thread safe by definition. + */ private fun run() { while (!interrupt) { val task = queue.pollFirst() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt index 9015b11c4..067fb58a3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.network import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream +import net.minecraft.core.particles.ParticleTypes import net.minecraft.network.FriendlyByteBuf import net.minecraft.network.chat.Component import net.minecraft.network.protocol.game.ClientboundSetCarriedItemPacket @@ -16,7 +17,6 @@ import ru.dbotthepony.mc.otm.android.AndroidFeatureType import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidResearchType import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature -import ru.dbotthepony.mc.otm.android.feature.JumpBoostParticlesPacket import ru.dbotthepony.mc.otm.android.feature.TriggerJumpBoostPacket import ru.dbotthepony.mc.otm.android.feature.TriggerShockwavePacket import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability @@ -29,6 +29,11 @@ import ru.dbotthepony.mc.otm.container.get import ru.dbotthepony.mc.otm.container.set import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.Vector +import ru.dbotthepony.mc.otm.core.math.component1 +import ru.dbotthepony.mc.otm.core.math.component2 +import ru.dbotthepony.mc.otm.core.math.component3 +import ru.dbotthepony.mc.otm.core.math.toRadians +import ru.dbotthepony.mc.otm.core.position import ru.dbotthepony.mc.otm.menu.tech.AndroidStationMenu import ru.dbotthepony.mc.otm.menu.ExopackInventoryMenu import ru.dbotthepony.mc.otm.registry.AndroidFeatures @@ -223,7 +228,7 @@ class PlayerIterationPacket(val iteration: Int, val deathLog: List, val carried: ItemStack, val containerState: Int) : MatteryPacket { +class ExopackMenuInitPacket(val slots: List, val carried: ItemStack, val containerState: Int) : MatteryPacket { override fun write(buff: FriendlyByteBuf) { buff.writeInt(slots.size) @@ -316,7 +321,7 @@ class ExoSuitMenuInitPacket(val slots: List, val carried: ItemStack, } companion object { - fun read(buff: FriendlyByteBuf): ExoSuitMenuInitPacket { + fun read(buff: FriendlyByteBuf): ExopackMenuInitPacket { val size = buff.readInt() val slots = ArrayList(size) @@ -327,12 +332,12 @@ class ExoSuitMenuInitPacket(val slots: List, val carried: ItemStack, val carried = buff.readItem() val containerState = buff.readInt() - return ExoSuitMenuInitPacket(slots, carried, containerState) + return ExopackMenuInitPacket(slots, carried, containerState) } } } -object ExoPackMenuOpen : MatteryPacket { +object ExopackMenuOpen : MatteryPacket { override fun write(buff: FriendlyByteBuf) {} override fun play(context: Supplier) { @@ -499,7 +504,7 @@ object DisplayExopackPacket : MatteryPacket { override fun play(context: Supplier) { context.packetHandled = true - context.sender?.matteryPlayer?.displayExopack = true + context.sender?.matteryPlayer?.isExopackVisible = true } } @@ -508,7 +513,7 @@ object HideExopackPacket : MatteryPacket { override fun play(context: Supplier) { context.packetHandled = true - context.sender?.matteryPlayer?.displayExopack = false + context.sender?.matteryPlayer?.isExopackVisible = false } } @@ -558,8 +563,53 @@ data class SetExopackColorPacket(val color: RGBAColor) : MatteryPacket { } } +data class ExopackSmokePacket(val player: UUID) : MatteryPacket { + override fun write(buff: FriendlyByteBuf) { + buff.writeUUID(player) + } + + override fun play(context: Supplier) { + context.packetHandled = true + // minecraft.player?.level()?.getPlayerByUUID(player)?.matteryPlayer?.spawnExopackSmoke = true + + context.enqueueWork { + minecraft.player?.level()?.getPlayerByUUID(player)?.let { ply -> + if (ply != minecraft.player || minecraft.gameRenderer.mainCamera.isDetached) { + var (x, y, z) = ply.position + + y += 1.5 + val deg = toRadians(ply.yBodyRot + 90f) + + x += kotlin.math.cos(deg) * -0.4 + z += kotlin.math.sin(deg) * -0.4 + + val level = ply.level() + val random = level.random + + for (i in 0 .. random.nextInt(2, 4)) + level.addParticle( + ParticleTypes.SMOKE, + x + random.nextDouble() * 0.4 - 0.2, + y + random.nextDouble() * 0.4 - 0.2, + z + random.nextDouble() * 0.4 - 0.2, + random.nextGaussian() * 0.02, + random.nextGaussian() * 0.02, + random.nextGaussian() * 0.02) + } + } + } + + } + + companion object { + fun read(buff: FriendlyByteBuf): ExopackSmokePacket { + return ExopackSmokePacket(buff.readUUID()) + } + } +} + object MatteryPlayerNetworkChannel : MatteryNetworkChannel( - version = "5", + version = "6", name = "player" ) { fun register() { @@ -572,18 +622,18 @@ object MatteryPlayerNetworkChannel : MatteryNetworkChannel( add(PlayerIterationPacket::class, PlayerIterationPacket.Companion::read, PLAY_TO_CLIENT) - add(ExoSuitCarriedPacket::class, ExoSuitCarriedPacket.Companion::read, PLAY_TO_CLIENT) - add(ExoSuitSlotPacket::class, ExoSuitSlotPacket.Companion::read, PLAY_TO_CLIENT) - add(ExoSuitMenuInitPacket::class, ExoSuitMenuInitPacket.Companion::read, PLAY_TO_CLIENT) + add(ExopackCarriedPacket::class, ExopackCarriedPacket.Companion::read, PLAY_TO_CLIENT) + add(ExopackSlotPacket::class, ExopackSlotPacket.Companion::read, PLAY_TO_CLIENT) + add(ExopackMenuInitPacket::class, ExopackMenuInitPacket.Companion::read, PLAY_TO_CLIENT) + add(ExopackSmokePacket::class, ExopackSmokePacket.Companion::read, PLAY_TO_CLIENT) - add(ExoPackMenuOpen::class, { ExoPackMenuOpen }, PLAY_TO_SERVER) + add(ExopackMenuOpen::class, { ExopackMenuOpen }, PLAY_TO_SERVER) add(SwitchAndroidFeaturePacket::class, SwitchAndroidFeaturePacket.Companion::read, PLAY_TO_SERVER) add(ActivateAndroidFeaturePacket::class, ActivateAndroidFeaturePacket.Companion::read, PLAY_TO_SERVER) add(TriggerShockwavePacket::class, { TriggerShockwavePacket }, PLAY_TO_SERVER) add(TriggerJumpBoostPacket::class, { TriggerJumpBoostPacket }, PLAY_TO_SERVER) - add(JumpBoostParticlesPacket::class, JumpBoostParticlesPacket.Companion::read, PLAY_TO_CLIENT) add(PickItemFromInventoryPacket::class, PickItemFromInventoryPacket.Companion::read, PLAY_TO_SERVER) From 912e3616934648fb49384af5d76bb1a15f9cb6f8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 30 Jul 2023 00:56:35 +0700 Subject: [PATCH 0897/1199] why --- .../models/block/powered_blast_furnace_error.json | 2 +- .../models/block/powered_blast_furnace_idle.json | 2 +- .../models/block/powered_blast_furnace_working.json | 2 +- .../models/block/powered_furnace_error.json | 2 +- .../models/block/powered_furnace_idle.json | 2 +- .../models/block/powered_furnace_working.json | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/powered_blast_furnace_error.json b/src/main/resources/assets/overdrive_that_matters/models/block/powered_blast_furnace_error.json index e2d063ba8..74b94f7bd 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/powered_blast_furnace_error.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/powered_blast_furnace_error.json @@ -1,5 +1,5 @@ { - "render_type": "translucent", + "render_type": "cutout", "texture_size": [32, 64], "textures": { "particle": "overdrive_that_matters:block/induction_furnace", diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/powered_blast_furnace_idle.json b/src/main/resources/assets/overdrive_that_matters/models/block/powered_blast_furnace_idle.json index fddc23f2a..e8c1914bc 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/powered_blast_furnace_idle.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/powered_blast_furnace_idle.json @@ -1,6 +1,6 @@ { "credit": "Made with Blockbench", - "render_type": "translucent", + "render_type": "cutout", "texture_size": [32, 64], "textures": { "particle": "overdrive_that_matters:block/induction_furnace_offline", diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/powered_blast_furnace_working.json b/src/main/resources/assets/overdrive_that_matters/models/block/powered_blast_furnace_working.json index 9d4ea6959..800bcd44f 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/powered_blast_furnace_working.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/powered_blast_furnace_working.json @@ -1,6 +1,6 @@ { "credit": "Made with Blockbench", - "render_type": "translucent", + "render_type": "cutout", "texture_size": [32, 64], "textures": { "particle": "overdrive_that_matters:block/induction_furnace", diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_error.json b/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_error.json index 4402744be..d9619a3de 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_error.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_error.json @@ -1,6 +1,6 @@ { "credit": "Made with Blockbench", - "render_type": "translucent", + "render_type": "cutout", "texture_size": [64, 32], "textures": { "0": "overdrive_that_matters:block/electric_furnace_offline", diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_idle.json b/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_idle.json index 4402744be..d9619a3de 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_idle.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_idle.json @@ -1,6 +1,6 @@ { "credit": "Made with Blockbench", - "render_type": "translucent", + "render_type": "cutout", "texture_size": [64, 32], "textures": { "0": "overdrive_that_matters:block/electric_furnace_offline", diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_working.json b/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_working.json index 6b1b04b40..a019fc0b4 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_working.json +++ b/src/main/resources/assets/overdrive_that_matters/models/block/powered_furnace_working.json @@ -1,6 +1,6 @@ { "credit": "Made with Blockbench", - "render_type": "translucent", + "render_type": "cutout", "texture_size": [64, 32], "textures": { "0": "overdrive_that_matters:block/electric_furnace", From ed84905627feb97c79cf7d762e8cd061ac62b1d4 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 30 Jul 2023 01:50:30 +0700 Subject: [PATCH 0898/1199] Exopack ender chest access upgrade --- .../advancements/ExopackAdvancementsData.kt | 15 +++++ .../mc/otm/datagen/items/ItemModels.kt | 1 + .../mc/otm/datagen/lang/English.kt | 5 +- .../mc/otm/datagen/lang/Russian.kt | 17 ++--- .../datagen/recipes/CraftingTableRecipes.kt | 7 +++ .../otm/capability/MatteryPlayerCapability.kt | 31 +++++++--- .../client/screen/ExopackInventoryScreen.kt | 58 +++++++++++++++--- .../mc/otm/client/screen/panels/FramePanel.kt | 7 ++- .../exopack/AbstractExopackSlotUpgradeItem.kt | 5 ++ .../mc/otm/menu/ExopackInventoryMenu.kt | 15 +++++ .../mc/otm/registry/MCreativeTabs.kt | 1 + .../ru/dbotthepony/mc/otm/registry/MItems.kt | 17 ++--- .../dbotthepony/mc/otm/registry/MRegistry.kt | 2 + .../mc/otm/triggers/ExopackTriggers.kt | 1 + .../textures/item/exopack_ender_upgrade.png | Bin 0 -> 273 bytes 15 files changed, 148 insertions(+), 34 deletions(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/exopack_ender_upgrade.png diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/ExopackAdvancementsData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/ExopackAdvancementsData.kt index aec551e13..fa1efb751 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/ExopackAdvancementsData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/ExopackAdvancementsData.kt @@ -11,6 +11,7 @@ import ru.dbotthepony.mc.otm.datagen.modLocation import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.triggers.ExopackBatterySlotTrigger import ru.dbotthepony.mc.otm.triggers.ExopackGainedCraftingTrigger +import ru.dbotthepony.mc.otm.triggers.ExopackGainedEnderAccessTrigger import ru.dbotthepony.mc.otm.triggers.ExopackGainedSmeltingTrigger import ru.dbotthepony.mc.otm.triggers.ExopackObtainedTrigger import ru.dbotthepony.mc.otm.triggers.ExopackSlotsExpandedTrigger @@ -78,6 +79,20 @@ fun addExopackAdvancements(serializer: Consumer, existingFileHelper .addCriterion("smelting", ExopackGainedSmeltingTrigger.instance) .save(serializer, modLocation("exopack/smelting"), existingFileHelper) + AdvancementBuilder() + .parent(obtained) + .display( + itemStack = ItemStack(Items.ENDER_CHEST), + title = translation.add("ender_access", "Ender-ious Access") { + russian("Эендер-иумый Доступ") + }, + description = translation.add("ender_access.desc", "Gain direct access to your Ender Chest out of your Exopack") { + russian("Получите прямой доступ к содержимому вашего сундука края прямо из Экзопака") + }, + ) + .addCriterion("ender_access", ExopackGainedEnderAccessTrigger.instance) + .save(serializer, modLocation("ender_access/smelting"), existingFileHelper) + var size = AdvancementBuilder() .parent(obtained) .display( diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index 7db7e577b..59a70b3fa 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -77,6 +77,7 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.generated(MItems.ExopackUpgrades.INVENTORY_UPGRADE_CREATIVE) provider.generated(MItems.ExopackUpgrades.CRAFTING_UPGRADE) provider.generated(MItems.ExopackUpgrades.SMELTING_UPGRADE) + provider.generated(MItems.ExopackUpgrades.ENDER_UPGRADE) provider.component(MItems.TRITANIUM_DUST) provider.component(MItems.TRITANIUM_INGOT) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 302221c37..da3651e91 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -160,6 +160,7 @@ private fun misc(provider: MatteryLanguageProvider) { gui("exopack_upgrades.slots_upgrade", "Using this will permanently grant %s slots in your Exopack inventory.") gui("exopack_upgrades.crafting_upgrade", "Using this will permanently grant 3x3 crafting grid in your Exopack inventory.") gui("exopack_upgrades.smelting_upgrade", "Using this will permanently grant smelter in your Exopack inventory.") + gui("exopack_upgrades.ender_access_upgrade", "Using this will permanently grant Ender Chest access in your Exopack inventory.") gui("crude_battery.replace_in_world", "Simplistic nature of this battery allows to replace your energy source in the field without using Android Station.") gui("crude_battery.replace_in_world_warning", "This operation is very unstable and can cause extreme damage to your systems!") @@ -171,6 +172,7 @@ private fun misc(provider: MatteryLanguageProvider) { misc("exopack_upgrades.slots_upgraded", "Your Exopack has permanently gained %s slots") misc("exopack_upgrades.crafting_upgraded", "Your Exopack has permanently gained 3x3 crafting grid") misc("exopack_upgrades.smelting_installed", "Your Exopack has permanently gained smelting module") + misc("exopack_upgrades.ender_access_installed", "Your Exopack has permanently gained access to Ender Chest contents") misc("exopack.granted1", "As you keep pressing on the fingerprint reader, probe disappears.") misc("exopack.granted2", "After a moment, you are getting pierced into back multiple times...") @@ -495,12 +497,13 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_CREATIVE, "Creative Exopack Inventory Upgrade") add(MItems.ExopackUpgrades.CRAFTING_UPGRADE, "Exopack Crafting Upgrade") add(MItems.ExopackUpgrades.SMELTING_UPGRADE, "Exopack Smelting Module") + add(MItems.ExopackUpgrades.ENDER_UPGRADE, "Exopack Ender Access Module") add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_WITHER, "Superdense Packing Upgrade") add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_WITHER, "description", "Utilizes similar principle that exhibit Nether Stars") add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_ENDER_DRAGON, "Ender Link Pocket Dimension Upgrade") - add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_ENDER_DRAGON, "description", "Allows to store items in portable pocket dimension") + add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_ENDER_DRAGON, "description", "Allows to store items in portable pocket dimension. Also grants access to Ender Chest contents.") add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, "Indescribable Exopack Inventory Upgrade") add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, "description", "They normally generate in dungeons with appropriate NBT tag attached") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 9747409a6..0e601f7f6 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -165,9 +165,10 @@ private fun misc(provider: MatteryLanguageProvider) { gui("exopack_upgrades.no_exopack", "Данный пазл технологии кажется для вас бесполезным... Или..?!") gui("exopack_upgrades.already_activated", "Улучшение уже активно!") - gui("exopack_upgrades.slots_upgrade", "Активируя данное улучшение даст %s слотов в вашем экзопаке.") - gui("exopack_upgrades.crafting_upgrade", "Активация данного улучшения даст 3x3 сетку создания в вашем экзопаке.") - gui("exopack_upgrades.smelting_upgrade", "Активация данного улучшения даст плавильню в вашем экзопаке.") + gui("exopack_upgrades.slots_upgrade", "Активируя данное улучшение даст %s слотов в вашем Экзопаке.") + gui("exopack_upgrades.crafting_upgrade", "Активация данного улучшения даст 3x3 сетку создания в вашем Экзопаке.") + gui("exopack_upgrades.smelting_upgrade", "Активация данного улучшения даст плавильню в вашем Экзопаке.") + gui("exopack_upgrades.ender_access_upgrade", "Активация данного улучшения даст доступ к сундуку края в вашем Экзопаке.") gui("crude_battery.replace_in_world", "Простота устройства данного аккумулятора позволяет вам заменить .") gui("crude_battery.replace_in_world_warning", "Данная операция крайне рискованная и может нанести огромный урон вашим системам!") @@ -176,9 +177,10 @@ private fun misc(provider: MatteryLanguageProvider) { misc("battery.single_use", "Единоразовая батарейка, не может быть перезаряжена.") - misc("exopack_upgrades.slots_upgraded", "Ваш экзопак был расширен на %s слотов") - misc("exopack_upgrades.crafting_upgraded", "Ваш экзопак получил 3x3 сетку создания") - misc("exopack_upgrades.smelting_installed", "Ваш экзопак получил плавильню") + misc("exopack_upgrades.slots_upgraded", "Ваш Экзопак был расширен на %s слотов") + misc("exopack_upgrades.crafting_upgraded", "Ваш Экзопак получил 3x3 сетку создания") + misc("exopack_upgrades.smelting_installed", "Ваш Экзопак получил плавильню") + misc("exopack_upgrades.ender_access_installed", "Ваш Экзопак получил доступ к содержимому сундука края") misc("exopack.granted1", "После некоторого времени нажатия на сканер отпечатка, маяк исчезает.") misc("exopack.granted2", "Через мгновение, вашу спину пронзают множество раз...") @@ -498,12 +500,13 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_CREATIVE, "Творческое обновление инвентаря экзопака") add(MItems.ExopackUpgrades.CRAFTING_UPGRADE, "Обновление сетки крафта экзопака") add(MItems.ExopackUpgrades.SMELTING_UPGRADE, "Модуль плавильни экзопака") + add(MItems.ExopackUpgrades.ENDER_UPGRADE, "Модуль доступа к сундуку края экзопака") add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_WITHER, "Обновление сверхмассивной упаковки") add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_WITHER, "description", "Использует те же принципы, которыми обладают звёзды незера") add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_ENDER_DRAGON, "Обновление соединения края экзопака") - add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_ENDER_DRAGON, "description", "Позволяет хранить предметы в карманном измерении") + add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_ENDER_DRAGON, "description", "Позволяет хранить предметы в карманном измерении. А так же даёт доступ к содержимому сундука края.") add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, "Неописуемое обновление инвентаря экзопака") add(MItems.ExopackUpgrades.INVENTORY_UPGRADE_PROCEDURAL, "description", "В нормальных условиях, они появляются в сундуках") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index ee01b293b..0510dfb3d 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -324,6 +324,13 @@ fun addCraftingTableRecipes(consumer: Consumer) { .row(MItemTags.TRITANIUM_PLATES, Items.FURNACE, MItemTags.TRITANIUM_PLATES) .build(consumer) + // апгрейд на эндер сундук + MatteryRecipe(MItems.ExopackUpgrades.ENDER_UPGRADE, category = RecipeCategory.TOOLS) + .row(MItemTags.ADVANCED_CIRCUIT, MItems.ELECTROMAGNET, MItemTags.ADVANCED_CIRCUIT) + .row(MItems.ELECTROMAGNET, Items.ENDER_CHEST, MItems.ELECTROMAGNET) + .row(MItemTags.TRITANIUM_PLATES, MItems.ELECTROMAGNET, MItemTags.TRITANIUM_PLATES) + .build(consumer) + // генератор коблы MatteryRecipe(MItems.COBBLESTONE_GENERATOR, category = machinesCategory) .row(MItemTags.HARDENED_GLASS_COLORLESS, MItems.TRITANIUM_PICKAXE, MItemTags.HARDENED_GLASS_COLORLESS) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 1764341f0..8d8431c6d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -5,13 +5,11 @@ import com.mojang.blaze3d.vertex.PoseStack import it.unimi.dsi.fastutil.ints.IntAVLTreeSet import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import net.minecraft.ChatFormatting -import net.minecraft.client.Minecraft import net.minecraft.client.model.PlayerModel import net.minecraft.client.player.AbstractClientPlayer import net.minecraft.commands.Commands import net.minecraft.commands.arguments.EntityArgument import net.minecraft.core.Direction -import net.minecraft.core.particles.ParticleTypes import net.minecraft.nbt.ByteTag import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.IntTag @@ -91,11 +89,7 @@ import ru.dbotthepony.mc.otm.core.collect.UUIDIntModifiersMap import ru.dbotthepony.mc.otm.core.collect.filter import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.RGBAColor -import ru.dbotthepony.mc.otm.core.math.component1 -import ru.dbotthepony.mc.otm.core.math.component2 -import ru.dbotthepony.mc.otm.core.math.component3 import ru.dbotthepony.mc.otm.core.math.minus -import ru.dbotthepony.mc.otm.core.math.toRadians import ru.dbotthepony.mc.otm.core.nbt.getByteList import ru.dbotthepony.mc.otm.core.nbt.getCompoundList import ru.dbotthepony.mc.otm.core.nbt.getIntList @@ -114,6 +108,7 @@ import ru.dbotthepony.mc.otm.network.SmokeParticlesPacket.Companion.makeSmoke import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer import ru.dbotthepony.mc.otm.registry.AndroidFeatures import ru.dbotthepony.mc.otm.registry.MDamageTypes +import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRegistry import ru.dbotthepony.mc.otm.registry.MatteryDamageSource import ru.dbotthepony.mc.otm.triggers.AndroidResearchTrigger @@ -123,14 +118,13 @@ import ru.dbotthepony.mc.otm.triggers.BecomeAndroidSleepTrigger import ru.dbotthepony.mc.otm.triggers.BecomeAndroidTrigger import ru.dbotthepony.mc.otm.triggers.BecomeHumaneTrigger import ru.dbotthepony.mc.otm.triggers.ExopackGainedCraftingTrigger +import ru.dbotthepony.mc.otm.triggers.ExopackGainedEnderAccessTrigger import ru.dbotthepony.mc.otm.triggers.ExopackGainedSmeltingTrigger import ru.dbotthepony.mc.otm.triggers.ExopackObtainedTrigger import ru.dbotthepony.mc.otm.triggers.ExopackSlotsExpandedTrigger import java.util.* import java.util.stream.Stream import kotlin.collections.ArrayDeque -import kotlin.math.cos -import kotlin.math.sin import kotlin.reflect.KMutableProperty1 private fun Player.dropContainer(container: Container, spill: Boolean = true, setThrower: Boolean = false) { @@ -236,7 +230,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial */ val tickList = TickList() - private val exoPackSlotModifierMap: MutableMap by synchronizer.Map( + private val exopackSlotModifierMap: MutableMap by synchronizer.Map( keyCodec = UUIDValueCodec, valueCodec = IntValueCodec, backingMap = HashMap(), @@ -256,7 +250,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } else { exopackContainer = PlayerMatteryContainer(it) } - }, backingMap = this.exoPackSlotModifierMap) + }, backingMap = this.exopackSlotModifierMap) val regularSlotFilters = immutableList(Inventory.INVENTORY_SIZE) { synchronizer.Field(null, ItemValueCodec.nullable) @@ -322,6 +316,17 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } }).property + var isExopackEnderAccessInstalled by publicSynchronizer.bool(setter = setter@{ value, access, _ -> + if (value != access.readBoolean()) { + access.write(value) + _exoPackMenu = null + + if (value && ply is ServerPlayer) { + ExopackGainedEnderAccessTrigger.trigger(ply) + } + } + }).property + private var _exoPackMenu: ExopackInventoryMenu? = null set(value) { if (field == ply.containerMenu) { ply.closeContainer() } @@ -511,6 +516,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial savetables.bool(::hasExopack, "hasExoSuit") savetables.bool(::isExopackVisible, "displayExoSuit") savetables.bool(::isExopackCraftingUpgraded, "isExoSuitCraftingUpgraded") + savetables.bool(::isExopackEnderAccessInstalled, "isExopackEnderAccessUpgraded") savetables.int(::nextDischargeHurt) savetables.int(::nextHealTick) @@ -902,6 +908,10 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial override fun deserializeNBT(tag: CompoundTag) { savetables.deserializeNBT(tag) + if (MItems.ExopackUpgrades.INVENTORY_UPGRADE_ENDER_DRAGON.uuid(ItemStack.EMPTY) in exopackSlotModifierMap) { + isExopackEnderAccessInstalled = true + } + if (ply is ServerPlayer && hasExopack) ExopackSlotsExpandedTrigger.trigger(ply, 0, exopackContainer.containerSize) @@ -1473,6 +1483,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial enum class UpgradeType(val prop: KMutableProperty1) { CRAFTING(MatteryPlayerCapability::isExopackCraftingUpgraded), + ENDER_ACCESS(MatteryPlayerCapability::isExopackEnderAccessInstalled), SMELTING(MatteryPlayerCapability::isExopackSmeltingInstalled); } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt index 3d33f11ff..b978a9521 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt @@ -147,24 +147,28 @@ class ExopackInventoryScreen(menu: ExopackInventoryMenu) : MatteryScreen( var inactiveIcon: IGUIRenderable? = null, ) : AbstractButtonPanel(this@FramePanel.screen, this@FramePanel, 0f, 0f, 26f, 28f) { var isActive = tabs.isEmpty() + protected set init { tabs.add(this) @@ -117,7 +118,7 @@ open class FramePanel( onClose?.run() } - override fun onClick(mouseButton: Int) { + fun activate() { if (!isActive) { for (tab in tabs) { if (tab !== this) { @@ -133,6 +134,10 @@ open class FramePanel( } } + override fun onClick(mouseButton: Int) { + activate() + } + override fun onRemoved() { super.onRemoved() tabs.remove(this) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/AbstractExopackSlotUpgradeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/AbstractExopackSlotUpgradeItem.kt index 2e667ec48..d99790504 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/AbstractExopackSlotUpgradeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/AbstractExopackSlotUpgradeItem.kt @@ -20,6 +20,7 @@ import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.isExplosion import ru.dbotthepony.mc.otm.core.isFire +import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.runIfClient import ru.dbotthepony.mc.otm.triggers.ExopackSlotsExpandedTrigger import java.util.UUID @@ -108,6 +109,10 @@ abstract class AbstractExopackSlotUpgradeItem(properties: Properties = defaultPr ExopackSlotsExpandedTrigger.trigger(player, slotCount, matteryPlayer.exopackContainer.containerSize) player.displayClientMessage(TranslatableComponent("otm.exopack_upgrades.slots_upgraded", slotCount).withStyle(ChatFormatting.DARK_GREEN), false) + + if (this === MItems.ExopackUpgrades.INVENTORY_UPGRADE_ENDER_DRAGON) { + MItems.ExopackUpgrades.ENDER_UPGRADE.finishUsingItem(ItemStack(MItems.ExopackUpgrades.INVENTORY_UPGRADE_ENDER_DRAGON), level, player) + } } return itemStack diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt index e671e5a9a..6e88d8814 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt @@ -115,6 +115,21 @@ class ExopackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen addStorageSlot(furnaceOutputs, condition = furnaceMenuOpenState) } + val enderChestSlots: List + val enderChestOpenState = InstantBooleanInput(this) + + init { + if (capability.isExopackEnderAccessInstalled) { + enderChestSlots = makeSlots(ply.enderChestInventory) { a, b -> + MatterySlot(a, b).also { + addStorageSlot(it, condition = enderChestOpenState) + } + } + } else { + enderChestSlots = listOf() + } + } + private var isRemoved = false override fun slotsChanged(container: Container) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt index dcbc6ac30..e5b562685 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt @@ -188,6 +188,7 @@ private fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_CREATIVE) accept(MItems.ExopackUpgrades.CRAFTING_UPGRADE) accept(MItems.ExopackUpgrades.SMELTING_UPGRADE) + accept(MItems.ExopackUpgrades.ENDER_UPGRADE) accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_BIG) accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_HUGE) 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 74847ca2d..7fe271ea3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -512,21 +512,22 @@ object MItems { val EXOPACK_PROBE: Item by registry.register(MNames.EXOPACK_PROBE, ::ExopackProbeItem) object ExopackUpgrades { - val INVENTORY_UPGRADE_CREATIVE: Item by registry.register("exosuit_inventory_upgrade_creative") { ExopackSlotUpgradeItem(null, 27, Rarity.EPIC) } - val CRAFTING_UPGRADE: Item by registry.register("exosuit_crafting_upgrade") { ExopackUpgradeItem(MatteryPlayerCapability.UpgradeType.CRAFTING, "crafting_upgrade", "crafting_upgraded") } - val SMELTING_UPGRADE: Item by registry.register("exopack_smelting_upgrade") { ExopackUpgradeItem(MatteryPlayerCapability.UpgradeType.SMELTING, "smelting_upgrade", "smelting_installed") } + val INVENTORY_UPGRADE_CREATIVE: ExopackSlotUpgradeItem by registry.register("exosuit_inventory_upgrade_creative") { ExopackSlotUpgradeItem(null, 27, Rarity.EPIC) } + val CRAFTING_UPGRADE: ExopackUpgradeItem by registry.register("exosuit_crafting_upgrade") { ExopackUpgradeItem(MatteryPlayerCapability.UpgradeType.CRAFTING, "crafting_upgrade", "crafting_upgraded") } + val SMELTING_UPGRADE: ExopackUpgradeItem by registry.register("exopack_smelting_upgrade") { ExopackUpgradeItem(MatteryPlayerCapability.UpgradeType.SMELTING, "smelting_upgrade", "smelting_installed") } + val ENDER_UPGRADE: ExopackUpgradeItem by registry.register("exopack_ender_upgrade") { ExopackUpgradeItem(MatteryPlayerCapability.UpgradeType.ENDER_ACCESS, "ender_access_upgrade", "ender_access_installed") } val INVENTORY_UPGRADES = SupplierList(8) { registry.register("exosuit_inventory_upgrade_$it") { ExopackSlotUpgradeItem(18, Rarity.COMMON) }::get } - val INVENTORY_UPGRADE_PROCEDURAL: Item by registry.register("exosuit_inventory_upgrade_procedural") { ProceduralExopackSlotUpgradeItem() } + val INVENTORY_UPGRADE_PROCEDURAL: ProceduralExopackSlotUpgradeItem by registry.register("exosuit_inventory_upgrade_procedural") { ProceduralExopackSlotUpgradeItem() } - val INVENTORY_UPGRADE_BIG: Item by registry.register("exosuit_inventory_upgrade_big") { ExopackSlotUpgradeItem(60, Rarity.RARE) } - val INVENTORY_UPGRADE_HUGE: Item by registry.register("exosuit_inventory_upgrade_huge") { ExopackSlotUpgradeItem(135, Rarity.RARE) } + val INVENTORY_UPGRADE_BIG: ExopackSlotUpgradeItem by registry.register("exosuit_inventory_upgrade_big") { ExopackSlotUpgradeItem(60, Rarity.RARE) } + val INVENTORY_UPGRADE_HUGE: ExopackSlotUpgradeItem by registry.register("exosuit_inventory_upgrade_huge") { ExopackSlotUpgradeItem(135, Rarity.RARE) } - val INVENTORY_UPGRADE_WITHER: Item by registry.register("exosuit_inventory_upgrade_wither") { ExopackSlotUpgradeItem(180, Rarity.RARE, hasDescription = true) } - val INVENTORY_UPGRADE_ENDER_DRAGON: Item by registry.register("exosuit_inventory_upgrade_ender_dragon") { ExopackSlotUpgradeItem(180, Rarity.EPIC, hasDescription = true) } + val INVENTORY_UPGRADE_WITHER: ExopackSlotUpgradeItem by registry.register("exosuit_inventory_upgrade_wither") { ExopackSlotUpgradeItem(180, Rarity.RARE, hasDescription = true) } + val INVENTORY_UPGRADE_ENDER_DRAGON: ExopackSlotUpgradeItem by registry.register("exosuit_inventory_upgrade_ender_dragon") { ExopackSlotUpgradeItem(180, Rarity.EPIC, hasDescription = true) } } init { 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 f0c2ee936..fd51b3838 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -55,6 +55,7 @@ import ru.dbotthepony.mc.otm.triggers.BlackHoleTrigger import ru.dbotthepony.mc.otm.triggers.EnderTeleporterFallDeathTrigger import ru.dbotthepony.mc.otm.triggers.ExopackBatterySlotTrigger import ru.dbotthepony.mc.otm.triggers.ExopackGainedCraftingTrigger +import ru.dbotthepony.mc.otm.triggers.ExopackGainedEnderAccessTrigger import ru.dbotthepony.mc.otm.triggers.ExopackGainedSmeltingTrigger import ru.dbotthepony.mc.otm.triggers.ExopackObtainedTrigger import ru.dbotthepony.mc.otm.triggers.ExopackSlotsExpandedTrigger @@ -303,6 +304,7 @@ object MRegistry { CriteriaTriggers.register(ExopackObtainedTrigger) CriteriaTriggers.register(ExopackGainedSmeltingTrigger) CriteriaTriggers.register(ExopackGainedCraftingTrigger) + CriteriaTriggers.register(ExopackGainedEnderAccessTrigger) CriteriaTriggers.register(ExopackSlotsExpandedTrigger) CriteriaTriggers.register(ExopackBatterySlotTrigger) CriteriaTriggers.register(TakeItemOutOfReplicatorTrigger) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ExopackTriggers.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ExopackTriggers.kt index c036e5556..ec3e399de 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ExopackTriggers.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ExopackTriggers.kt @@ -17,6 +17,7 @@ import ru.dbotthepony.mc.otm.core.toJsonStrict val ExopackObtainedTrigger = SingletonTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "exopack_obtained")) val ExopackGainedCraftingTrigger = SingletonTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "exopack_gained_crafting")) val ExopackGainedSmeltingTrigger = SingletonTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "exopack_gained_smelting")) +val ExopackGainedEnderAccessTrigger = SingletonTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "exopack_gained_ender_access")) val ExopackBatterySlotTrigger = ItemTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "exopack_battery_slot")) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/exopack_ender_upgrade.png b/src/main/resources/assets/overdrive_that_matters/textures/item/exopack_ender_upgrade.png new file mode 100644 index 0000000000000000000000000000000000000000..0712ac982570320315fd28e70382b3f4485666e4 GIT binary patch literal 273 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}H0G|-oz`(#2D^}dRdGns_|E8uUF)=YyQ&TlHHJ|@L6%0pZCfo*6TqQw% z!T(`^Vbd9%^FUF~0*}aI1_r+UAk1jN8ms~oO!IVc4ABUVJr~G#K!JlffJJ1_|JLhD z(c3;Q{FcbHslK$?rhnhDj90`&pYTmQqG7MTu`ZkItS>#`KpPo6UHx3vIVCg! E0E(4eW&i*H literal 0 HcmV?d00001 From 85ca7d8a24db3c70a3ebd5ae61593c4e00a7fa09 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 30 Jul 2023 01:56:48 +0700 Subject: [PATCH 0899/1199] Re-enable mixins --- build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 1b48fd99d..2ab4fae77 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -255,11 +255,11 @@ minecraft { } } -/*mixin { +mixin { add(sourceSets.main.get(), "$mod_id.refmap.json") config("$mod_id.mixins.json") config("$mod_id.ad_astra.mixins.json") -}*/ +} repositories { // If you have mod jar dependencies in ./libs, you can declare them as a repository like so: From c4e7b8ff15216b4aa23d918ede17832e8b3be59d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 30 Jul 2023 10:17:26 +0700 Subject: [PATCH 0900/1199] Add sendNow methods --- .../mc/otm/network/MatteryNetworkChannel.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt index d15d9ed8f..19f265072 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt @@ -58,6 +58,12 @@ abstract class MatteryNetworkChannel(val version: String, val name: String) { } } + fun sendNow(ply: Player, packet: Any) { + if (ply is ServerPlayer) { + channel.send(PacketDistributor.PLAYER.with { ply }, packet) + } + } + fun sendTracking(entity: Entity, packet: Any) { if ((NULLABLE_MINECRAFT_SERVER?.playerCount ?: 0) <= 0) { return @@ -78,6 +84,10 @@ abstract class MatteryNetworkChannel(val version: String, val name: String) { queue.add(Task(channel, distributor, packet)) } + fun sendNow(distributor: PacketDistributor.PacketTarget, packet: Any) { + channel.send(distributor, packet) + } + private var nextNetworkPacketID = 0 fun add( From 7053769e26c0c6b78c631ecfb86d899000630df3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 30 Jul 2023 10:39:32 +0700 Subject: [PATCH 0901/1199] Inline container.set/get --- src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt index 3900cd640..d74d6220b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt @@ -17,10 +17,14 @@ import ru.dbotthepony.mc.otm.core.collect.nonEmpty import ru.dbotthepony.mc.otm.core.isNotEmpty import kotlin.math.roundToInt -operator fun Container.set(index: Int, value: ItemStack) = setItem(index, value) -operator fun Container.get(index: Int): ItemStack = getItem(index) +@Suppress("nothing_to_inline") +inline operator fun Container.set(index: Int, value: ItemStack) = setItem(index, value) -operator fun IFluidHandler.get(index: Int) = getFluidInTank(index) +@Suppress("nothing_to_inline") +inline operator fun Container.get(index: Int): ItemStack = getItem(index) + +@Suppress("nothing_to_inline") +inline operator fun IFluidHandler.get(index: Int) = getFluidInTank(index) fun Container.addItem(stack: ItemStack, range: IntRange, simulate: Boolean = false): ItemStack { if (this is MatteryContainer) { From 1eb90a5c1773b3b2b4ae7935d83aed0242ceab36 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 30 Jul 2023 10:48:49 +0700 Subject: [PATCH 0902/1199] call setChangedLight when job ticks --- .../dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt index 370fd3f6a..90af20413 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt @@ -55,6 +55,7 @@ abstract class MatteryWorkerBlockEntity( } override fun onJobTick(status: JobStatus) { + super@MatteryWorkerBlockEntity.setChangedLight() return this@MatteryWorkerBlockEntity.onJobTick(status, id) } } From 5b30f2e916718ae9f480ae222de70675e64d4b2d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 30 Jul 2023 11:01:22 +0700 Subject: [PATCH 0903/1199] Use sendNow in menus when sending data for first time --- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 73bc13ebd..3fd0165cd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -402,45 +402,45 @@ abstract class MatteryMenu @JvmOverloads protected constructor( } } - override fun broadcastChanges() { + private var broadcastOnce = false + + protected fun matteryBroadcast() { val payload = mSynchronizer.collectNetworkPayload() if (payload != null) { - MenuNetworkChannel.send(ply, MenuFieldPacket(containerId, payload)) + if (broadcastOnce) { + MenuNetworkChannel.send(ply, MenuFieldPacket(containerId, payload)) + } else { + MenuNetworkChannel.sendNow(ply, MenuFieldPacket(containerId, payload)) + } } - super.broadcastChanges() - val consumer = PacketDistributor.PLAYER.with { ply as ServerPlayer } for (slot in _filterSlots) { val packet = slot.sendChanges() if (packet != null) { - MenuNetworkChannel.send(consumer, packet) + if (broadcastOnce) { + MenuNetworkChannel.send(consumer, packet) + } else { + MenuNetworkChannel.sendNow(consumer, packet) + } } } + + broadcastOnce = true + } + + override fun broadcastChanges() { + super.broadcastChanges() + matteryBroadcast() } override fun broadcastFullState() { mSynchronizer.invalidate() - val payload = mSynchronizer.collectNetworkPayload() - - if (payload != null) { - MenuNetworkChannel.send(ply, MenuFieldPacket(containerId, payload)) - } - super.broadcastFullState() - - val consumer = PacketDistributor.PLAYER.with { ply as ServerPlayer } - - for (slot in _filterSlots) { - val packet = slot.sendChanges(true) - - if (packet != null) { - MenuNetworkChannel.send(consumer, packet) - } - } + matteryBroadcast() } override fun stillValid(player: Player): Boolean { From 99132412cd384c613091094870afe74a7169bded Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 30 Jul 2023 11:03:02 +0700 Subject: [PATCH 0904/1199] Get text right away --- .../dbotthepony/mc/otm/client/screen/panels/DynamicLabel.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DynamicLabel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DynamicLabel.kt index 9e13f1b7c..d11bf08a7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DynamicLabel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DynamicLabel.kt @@ -14,6 +14,10 @@ open class DynamicLabel( val textSupplier: Supplier, shadow: Boolean = false ) : Label(screen, parent, x, y, width, height, textSupplier.get(), shadow) { + init { + text = textSupplier.get() + } + override fun tickInner() { super.tickInner() text = textSupplier.get() From 7ce30ffd8183c2c04deed226d021bd5c49dff9dc Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 30 Jul 2023 11:06:08 +0700 Subject: [PATCH 0905/1199] Add beforeBroadcast protected open method to mattery menus --- src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 6 ++++++ .../ru/dbotthepony/mc/otm/menu/tech/EnergyCounterMenu.kt | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 3fd0165cd..db3244d76 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -404,7 +404,13 @@ abstract class MatteryMenu @JvmOverloads protected constructor( private var broadcastOnce = false + protected open fun beforeBroadcast() { + + } + protected fun matteryBroadcast() { + beforeBroadcast() + val payload = mSynchronizer.collectNetworkPayload() if (payload != null) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyCounterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyCounterMenu.kt index 7898683ff..6d98b6857 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyCounterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyCounterMenu.kt @@ -52,7 +52,9 @@ class EnergyCounterMenu @JvmOverloads constructor( // TODO: Graph and proper networking for it private var ticksPassed = 0 - override fun broadcastChanges() { + override fun beforeBroadcast() { + super.beforeBroadcast() + if (tile is EnergyCounterBlockEntity) { passed = tile.passed average = tile.calcAverage(20) @@ -67,8 +69,6 @@ class EnergyCounterMenu @JvmOverloads constructor( maxIO = tile.ioLimit?.toBigDecmial() ?: -BigDecimal.ONE } - - super.broadcastChanges() } companion object { From 49fc5b5eaf60fca4947e61d5fbf907cbfd50f298 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 30 Jul 2023 11:19:39 +0700 Subject: [PATCH 0906/1199] Fix mattery network dispatcher preventing server from exiting sometimes --- .../ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt index 19f265072..1761c3b4c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt @@ -166,14 +166,16 @@ abstract class MatteryNetworkChannel(val version: String, val name: String) { internal fun onServerStarting() { interrupt = false check(thread == null) { "Already having network dispatcher thread, ServerStartingEvent was fired twice!" } - thread = Thread(this::run, "Overdrive That Matters Network Dispatcher").also { it.start() } + thread = Thread(this::run, "Overdrive That Matters Network Dispatcher").also { it.isDaemon = true; it.start() } } internal fun onServerStopping() { + LockSupport.unpark(thread) interrupt = true } internal fun onServerStopped() { + LockSupport.unpark(thread) interrupt = true } } From cd48b90abfcfcd67255679f8fc5a7ad450e5e09d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 30 Jul 2023 11:25:03 +0700 Subject: [PATCH 0907/1199] Wrong order of calls --- .../ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt index 1761c3b4c..5ef60f372 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt @@ -170,13 +170,13 @@ abstract class MatteryNetworkChannel(val version: String, val name: String) { } internal fun onServerStopping() { - LockSupport.unpark(thread) interrupt = true + LockSupport.unpark(thread) } internal fun onServerStopped() { - LockSupport.unpark(thread) interrupt = true + LockSupport.unpark(thread) } } } From 6f17ed27672aa075852dc12aca0a798285b333a7 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 30 Jul 2023 21:57:44 +0700 Subject: [PATCH 0908/1199] Fix matter decomposer causing neighbour updates --- .../mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index 6feb56bb3..abab0b27d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -55,7 +55,7 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) } override val upgrades = UpgradeContainer(this::setChangedLight, 4, UpgradeType.REPLICATOR) - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this, upgrades.transform(MachinesConfig.MATTER_DECOMPOSER))) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::setChangedLight, upgrades.transform(MachinesConfig.MATTER_DECOMPOSER))) val energyConfig = ConfigurableEnergy(energy) init { From 716ccae94aaaebc69bf315c2e24da6d9245a39e3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 2 Aug 2023 13:42:29 +0700 Subject: [PATCH 0909/1199] Get rid of lambda container handler creation --- .../matter/PatternStorageBlockEntity.kt | 3 ++- .../mc/otm/container/HandlerFilter.kt | 7 ++++++ .../mc/otm/container/MatteryContainer.kt | 25 +------------------ 3 files changed, 10 insertions(+), 25 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt index 222f0d67c..39365b5ea 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt @@ -17,6 +17,7 @@ import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.matter.* +import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.stream import ru.dbotthepony.mc.otm.core.collect.iterator import ru.dbotthepony.mc.otm.core.filterNotNull @@ -75,7 +76,7 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } - val itemConfig = ConfigurableItemHandler(inputOutput = container.handler { _: Int, stack: ItemStack -> stack.getCapability(MatteryCapability.PATTERN).isPresent }) + val itemConfig = ConfigurableItemHandler(inputOutput = container.handler(HandlerFilter.IsPattern.and(HandlerFilter.OnlyIn))) override fun setLevel(level: Level) { super.setLevel(level) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt index c36c8af12..ce8051302 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.container import net.minecraft.world.item.ItemStack import net.minecraftforge.common.ForgeHooks import net.minecraftforge.common.capabilities.ForgeCapabilities +import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.isNotEmpty @@ -107,4 +108,10 @@ interface HandlerFilter { return ForgeHooks.getBurnTime(stack, null) > 0 } } + + object IsPattern : HandlerFilter { + override fun canInsert(slot: Int, stack: ItemStack): Boolean { + return stack.getCapability(MatteryCapability.PATTERN).isPresent + } + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt index 186726e8a..060b8804b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt @@ -211,33 +211,10 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I return false } - fun handler( - insert_validator: (slot: Int, stack: ItemStack) -> Boolean, - extract_validator: (slot: Int, amount: Int, stack: ItemStack) -> Boolean - ): ContainerHandler { - return ContainerHandler(this, object : HandlerFilter { - override fun canInsert(slot: Int, stack: ItemStack) = insert_validator(slot, stack) - override fun canExtract(slot: Int, amount: Int, stack: ItemStack) = extract_validator(slot, amount, stack) - }) - } - - fun handler( - filter: HandlerFilter - ): ContainerHandler { + fun handler(filter: HandlerFilter = HandlerFilter.Both): ContainerHandler { return ContainerHandler(this, filter) } - fun handler(insert_validator: (Int, ItemStack) -> Boolean): ContainerHandler { - return ContainerHandler(this, object : HandlerFilter { - override fun canInsert(slot: Int, stack: ItemStack) = insert_validator(slot, stack) - override fun canExtract(slot: Int, amount: Int, stack: ItemStack) = false - }) - } - - fun handler(): ContainerHandler { - return ContainerHandler(this) - } - open fun getMaxStackSize(slot: Int) = maxStackSize open fun getMaxStackSizeWithItem(slot: Int): Int { From 0878bd9a7e032526ff832ffa20e4cb88fedff2d3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 2 Aug 2023 13:50:53 +0700 Subject: [PATCH 0910/1199] Make getMaxStackSize also accept itemstack --- .../entity/matter/MatterBottlerBlockEntity.kt | 2 +- .../mc/otm/container/ContainerHandler.kt | 10 +++++----- .../mc/otm/container/MatteryContainer.kt | 16 +++------------- .../mc/otm/item/matter/MatterDustItem.kt | 2 +- 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index 9b58cdd29..2713dfe01 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -71,7 +71,7 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : //private var work_behavior = true val container: MatteryContainer = object : MatteryContainer(this::setChangedLight, 6) { - override fun getMaxStackSize(slot: Int): Int { + override fun getMaxStackSize(slot: Int, itemStack: ItemStack): Int { return 1 } 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 57121bce9..6a3a4f457 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHandler.kt @@ -20,16 +20,16 @@ class ContainerHandler @JvmOverloads internal constructor( if (localStack.isEmpty) { if (!simulate) { - container.setItem(slot, stack.copyWithCount(stack.count.coerceAtMost(stack.maxStackSize).coerceAtMost(container.getMaxStackSize(slot)))) + container.setItem(slot, stack.copyWithCount(stack.count.coerceAtMost(container.getMaxStackSize(slot, stack)))) } - if (stack.count <= container.getMaxStackSize(slot).coerceAtMost(stack.maxStackSize)) { + if (stack.count <= container.getMaxStackSize(slot, stack)) { return ItemStack.EMPTY } else { - return stack.copyWithCount(container.getMaxStackSize(slot)) + return stack.copyWithCount(container.getMaxStackSize(slot, stack)) } - } else if (localStack.isStackable && localStack.maxStackSize.coerceAtMost(container.getMaxStackSize(slot)) > localStack.count && ItemStack.isSameItemSameTags(localStack, stack)) { - val newCount = localStack.maxStackSize.coerceAtMost(localStack.count + stack.count).coerceAtMost(container.getMaxStackSize(slot)) + } else if (localStack.isStackable && container.getMaxStackSize(slot, localStack) > localStack.count && ItemStack.isSameItemSameTags(localStack, stack)) { + val newCount = container.getMaxStackSize(slot, localStack).coerceAtMost(localStack.count + stack.count) val diff = newCount - localStack.count if (diff != 0) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt index 060b8804b..4b342f692 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt @@ -215,17 +215,7 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I return ContainerHandler(this, filter) } - open fun getMaxStackSize(slot: Int) = maxStackSize - - open fun getMaxStackSizeWithItem(slot: Int): Int { - val item = this[slot] - - if (!item.isEmpty) { - return getMaxStackSize(slot).coerceAtMost(item.maxStackSize) - } - - return getMaxStackSize(slot) - } + open fun getMaxStackSize(slot: Int, itemStack: ItemStack) = maxStackSize.coerceAtMost(itemStack.maxStackSize) /** * @return Leftover [ItemStack] @@ -244,7 +234,7 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I for (slot in range) { if (ItemStack.isSameItemSameTags(slots[slot], copy)) { val slotStack = slots[slot] - val slotLimit = getMaxStackSize(slot).coerceAtMost(slotStack.maxStackSize) + val slotLimit = getMaxStackSize(slot, slotStack) if (slotStack.count < slotLimit) { val newCount = (slotStack.count + copy.count).coerceAtMost(slotLimit) @@ -274,7 +264,7 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I // двигаем в пустые слоты for (slot in range) { if (slots[slot].isEmpty) { - val diff = copy.count.coerceAtMost(getMaxStackSize(slot).coerceAtMost(copy.maxStackSize)) + val diff = copy.count.coerceAtMost(getMaxStackSize(slot, copy)) if (!simulate) { val copyToPut = copy.copy() 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 d2ae858c3..8447d888a 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 @@ -71,7 +71,7 @@ class MatterDustItem : Item(Properties().stacksTo(64)), IMatterItem { // можем ли мы стакнуть материю из второго слота в первый? if (!stack2.isEmpty && isFull(stack2)) { - if (ItemStack.isSameItemSameTags(stack, stack2) && container.getMaxStackSizeWithItem(mainSlot) >= stack.count + 1) { + if (ItemStack.isSameItemSameTags(stack, stack2) && container.getMaxStackSize(mainSlot, stack) >= stack.count + 1) { stack.count++ stack2.count-- From 8653dd343fd4a6a33a65641c67bf04fdf62a4722 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 2 Aug 2023 16:12:46 +0700 Subject: [PATCH 0911/1199] Finely optimize MatteryContainer iterator() and isEmpty(), add Cache to container --- .../mc/otm/container/ContainerIterator.kt | 75 ++++------ .../mc/otm/container/MatteryContainer.kt | 136 ++++++++++++++++-- .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 2 + 3 files changed, 156 insertions(+), 57 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerIterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerIterator.kt index 197633e58..56041d368 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerIterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerIterator.kt @@ -1,59 +1,42 @@ package ru.dbotthepony.mc.otm.container -import it.unimi.dsi.fastutil.objects.ObjectIterators import net.minecraft.world.Container import net.minecraft.world.item.ItemStack -import ru.dbotthepony.mc.otm.core.collect.ContainerItemStackEntry -import ru.dbotthepony.mc.otm.core.collect.AwareItemStack +import ru.dbotthepony.mc.otm.core.isNotEmpty -class ContainerIterator(private val container: Container, initialPosition: Int = 0) : ObjectIterators.AbstractIndexBasedListIterator(0, initialPosition), MutableListIterator { - init { - require(initialPosition in 0 .. container.containerSize) { "Invalid initial position: $initialPosition" } +class ContainerIterator(private val container: Container) : MutableIterator { + private var index = 0 + private var lastIndex = -1 + + override fun hasNext(): Boolean { + while (index < container.containerSize) { + if (container[index].isNotEmpty) { + return true + } + + index++ + } + + return false } - override fun add(location: Int, k: ItemStack) { - throw UnsupportedOperationException() + override fun next(): ItemStack { + if (!hasNext()) { + throw NoSuchElementException() + } + + lastIndex = index + return container[index++] } - override fun set(location: Int, k: ItemStack) { - container[location] = k - } + override fun remove() { + if (lastIndex == -1) { + throw NoSuchElementException() + } - override fun remove(location: Int) { - pos++ - container[location] = ItemStack.EMPTY - } - - override fun get(location: Int): ItemStack { - return container[location] - } - - override fun getMaxPos(): Int { - return container.containerSize + container[lastIndex] = ItemStack.EMPTY + lastIndex = -1 } } -class AwareContainerIterator(private val container: Container, initialPosition: Int = 0) : ObjectIterators.AbstractIndexBasedIterator(0, initialPosition), Iterator { - init { - require(initialPosition in 0 .. container.containerSize) { "Invalid initial position: $initialPosition" } - } - - override fun remove(location: Int) { - pos++ - container[location] = ItemStack.EMPTY - } - - override fun get(location: Int): AwareItemStack { - return ContainerItemStackEntry(location, container) - } - - override fun getMaxPos(): Int { - return container.containerSize - } -} - -@JvmOverloads -fun Container.iterator(initialPosition: Int = 0) = ContainerIterator(this, initialPosition) - -@JvmOverloads -fun Container.awareIterator(initialPosition: Int = 0) = AwareContainerIterator(this, initialPosition) +fun Container.iterator() = ContainerIterator(this) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt index 4b342f692..a18991525 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt @@ -2,6 +2,9 @@ package ru.dbotthepony.mc.otm.container import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import it.unimi.dsi.fastutil.ints.IntAVLTreeSet +import it.unimi.dsi.fastutil.ints.IntArrayList +import it.unimi.dsi.fastutil.ints.IntComparators +import it.unimi.dsi.fastutil.objects.ObjectIterators import net.minecraft.world.item.ItemStack import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.ListTag @@ -14,6 +17,8 @@ import net.minecraft.world.item.Item import net.minecraft.world.item.Items import net.minecraftforge.common.util.INBTSerializable import net.minecraftforge.registries.ForgeRegistries +import ru.dbotthepony.mc.otm.core.addSorted +import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.registryName @@ -23,6 +28,8 @@ import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer import ru.dbotthepony.mc.otm.network.synchronizer.IField import java.lang.ref.WeakReference import java.util.* +import java.util.function.Supplier +import kotlin.NoSuchElementException @Suppress("UNUSED") open class MatteryContainer(protected val watcher: Runnable, private val size: Int) : Container, Iterable, INBTSerializable { @@ -32,11 +39,40 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I require(size >= 0) { "Invalid container size $size" } } - protected val slots: Array = Array(size) { ItemStack.EMPTY } + private val slots = Array(size) { ItemStack.EMPTY } + private val nonEmptyFlags = BitSet() + private val nonEmptyIndices = IntArrayList() private val trackedSlots: Array = Array(size) { ItemStack.EMPTY } private val filters: Array = arrayOfNulls(size) private var filterSynchronizer: WeakReference>>? = null + var changeset = 0 + private set + + inner class Cache(private val supplier: (MatteryContainer) -> T) : Supplier { + private var thisChangeset = -1 + private var value: T? = null + private var isDisabled = false + + fun disable() { + isDisabled = true + } + + fun enable() { + isDisabled = false + } + + override fun get(): T { + if (thisChangeset == changeset && !isDisabled) { + return value as T + } + + value = supplier.invoke(this@MatteryContainer) + thisChangeset = changeset + return value as T + } + } + fun clearSlotFilters() { Arrays.fill(filters, null) filterSynchronizer?.get()?.value?.clear() @@ -159,6 +195,9 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I override fun deserializeNBT(tag: Tag?) { Arrays.fill(slots, ItemStack.EMPTY) Arrays.fill(filters, null) + nonEmptyFlags.clear() + nonEmptyIndices.clear() + filterSynchronizer?.get()?.value?.clear() when (tag) { @@ -244,6 +283,7 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I val old = slotStack.copy() slotStack.count = newCount trackedSlots[slot] = slotStack.copy() + changeset++ setChanged(slot, slotStack, old) if (popTime != null) { @@ -269,7 +309,11 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I if (!simulate) { val copyToPut = copy.copy() copyToPut.count = diff - this[slot] = copyToPut + slots[slot] = copyToPut + trackedSlots[slot] = copyToPut.copy() + updateEmptyFlag(slot) + changeset++ + setChanged(slot, copyToPut, ItemStack.EMPTY) if (popTime != null) { copyToPut.popTime = popTime @@ -327,11 +371,14 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I } override fun isEmpty(): Boolean { - return slots.all { it.isEmpty } + return nonEmptyIndices.isEmpty } - operator fun get(slot: Int) = getItem(slot) - operator fun set(slot: Int, stack: ItemStack) = setItem(slot, stack) + @Suppress("nothing_to_inline") + inline operator fun get(slot: Int) = getItem(slot) + + @Suppress("nothing_to_inline") + inline operator fun set(slot: Int, stack: ItemStack) = setItem(slot, stack) operator fun contains(other: ItemStack): Boolean { for (i in 0 until size) { @@ -346,10 +393,19 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I final override fun getItem(slot: Int): ItemStack { val item = slots[slot] - if (item.isEmpty) + if (item.isEmpty) { + if (nonEmptyFlags[slot]) { + setChanged(slot) + } + return ItemStack.EMPTY - else + } else { + if (!nonEmptyFlags[slot]) { + setChanged(slot) + } + return item + } } final override fun removeItem(slot: Int, amount: Int): ItemStack { @@ -359,6 +415,8 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I val old = slots[slot].copy() val split = slots[slot].split(amount) trackedSlots[slot] = slots[slot].copy() + changeset++ + updateEmptyFlag(slot) setChanged(slot, if (slots[slot].isEmpty) ItemStack.EMPTY else slots[slot], old) return split @@ -368,6 +426,12 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I val old = slots[slot] slots[slot] = ItemStack.EMPTY trackedSlots[slot] = ItemStack.EMPTY + + if (old.isNotEmpty) { + updateEmptyFlag(slot) + changeset++ + } + return old } @@ -376,8 +440,11 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I return val old = slots[slot] - slots[slot] = stack + slots[slot] = if (stack.isEmpty) ItemStack.EMPTY else stack trackedSlots[slot] = if (stack.isEmpty) ItemStack.EMPTY else stack.copy() + + updateEmptyFlag(slot) + changeset++ setChanged(slot, stack, old) } @@ -389,17 +456,38 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I fun setChanged(slot: Int) { if (!slots[slot].equals(trackedSlots[slot], false)) { - setChanged(slot, slots[slot], trackedSlots[slot]) trackedSlots[slot] = slots[slot].copy() + updateEmptyFlag(slot) + changeset++ + setChanged(slot, slots[slot], trackedSlots[slot]) // mojang соси))0)0))0)))))0) } } + private fun updateEmptyFlag(slot: Int) { + if (slots[slot].isEmpty) { + if (nonEmptyFlags[slot]) { + nonEmptyFlags[slot] = false + nonEmptyIndices.removeInt(slot) + } + } else { + if (!nonEmptyFlags[slot]) { + nonEmptyFlags[slot] = true + nonEmptyIndices.addSorted(slot, IntComparators.NATURAL_COMPARATOR) + } + } + } + override fun stillValid(player: Player): Boolean { return true } final override fun clearContent() { + nonEmptyFlags.clear() + nonEmptyIndices.clear() + + Arrays.fill(trackedSlots, ItemStack.EMPTY) + for (slot in 0 until size) { if (!slots[slot].isEmpty) { val old = slots[slot] @@ -407,11 +495,37 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I setChanged(slot, ItemStack.EMPTY, old) } } + } - Arrays.fill(trackedSlots, ItemStack.EMPTY) + private inner class Iterator : MutableIterator { + private val parent = nonEmptyIndices.intIterator() + private var lastIndex = -1 + + override fun hasNext(): Boolean { + return parent.hasNext() + } + + override fun next(): ItemStack { + lastIndex = parent.nextInt() + return getItem(lastIndex) + } + + override fun remove() { + if (lastIndex == -1) { + throw NoSuchElementException() + } + + parent.remove() + setItem(lastIndex, ItemStack.EMPTY) + lastIndex = -1 + } } final override fun iterator(): MutableIterator { - return ContainerIterator(this) + if (isEmpty) { + return ObjectIterators.EMPTY_ITERATOR as MutableIterator + } + + return Iterator() } } 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 6387b3a8e..a0a46e119 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -376,6 +376,7 @@ fun List.searchInsertionIndex(element: E, comparator: Comparator, from return fromIndex } + // линейный поиск если границы маленькие if (toIndex - fromIndex <= 10) { for (i in fromIndex + 1 until toIndex) { val compare = comparator.compare(element, this[i]) @@ -387,6 +388,7 @@ fun List.searchInsertionIndex(element: E, comparator: Comparator, from return size } else { + // двоичный поиск var lower = fromIndex var upper = toIndex - 1 From 2720f6fbf0efcf1ea6663147f825271d754a38b1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 2 Aug 2023 16:21:15 +0700 Subject: [PATCH 0912/1199] Shortcuts for when current decimal is zero --- .../dbotthepony/mc/otm/core/math/Decimal.kt | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) 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 e91bc36a9..3ed4e4750 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 @@ -202,7 +202,7 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe operator fun times(other: Float): Decimal { if (other == 1f) { return this - } else if (other == 0f) { + } else if (other == 0f || isZero) { return ZERO } else if (other == -1f) { return -this @@ -218,7 +218,7 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe operator fun div(other: Float): Decimal { if (other == 0f) { throw ArithmeticException("Attempt to divide $this by zero") - } else if (other == 1f) { + } else if (other == 1f || isZero) { return this } else if (other == -1f) { return -this @@ -258,7 +258,7 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe operator fun times(other: Double): Decimal { if (other == 1.0) { return this - } else if (other == 0.0) { + } else if (other == 0.0 || isZero) { return ZERO } else if (other == -1.0) { return -this @@ -274,7 +274,7 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe operator fun div(other: Double): Decimal { if (other == 0.0) { throw ArithmeticException("Attempt to divide $this by zero") - } else if (other == 1.0) { + } else if (other == 1.0 || isZero) { return this } else if (other == -1.0) { return -this @@ -304,7 +304,7 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe } operator fun times(other: Int): Decimal { - if (other == 1) { + if (other == 1 || isZero) { return this } else if (other == 0) { return ZERO @@ -318,7 +318,7 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe operator fun div(other: Int): Decimal { if (other == 0) { throw ArithmeticException("Attempt to divide $this by zero") - } else if (other == 1) { + } else if (other == 1 || signum() == 0) { return this } else if (other == -1) { return -this @@ -344,7 +344,7 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe } operator fun times(other: Long): Decimal { - if (other == 1L) { + if (other == 1L || isZero) { return this } else if (other == 0L) { return ZERO @@ -358,7 +358,7 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe operator fun div(other: Long): Decimal { if (other == 0L) { throw ArithmeticException("Attempt to divide $this by zero") - } else if (other == 1L) { + } else if (other == 1L || isZero) { return this } else if (other == -1L) { return -this @@ -386,7 +386,7 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe operator fun times(other: BigInteger): Decimal { if (other == BigInteger.ONE) { return this - } else if (other.signum() == 0) { + } else if (other.signum() == 0 || isZero) { return ZERO } else if (other == BI_MINUS_ONE) { return -this @@ -398,7 +398,7 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe operator fun div(other: BigInteger): Decimal { if (other == BigInteger.ZERO) { throw ArithmeticException("Attempt to divide $this by zero") - } else if (other == BigInteger.ONE) { + } else if (other == BigInteger.ONE || isZero) { return this } else if (other == BI_MINUS_ONE) { return -this From cc4fcf398fc1b94c2b07933960e6d55df78426fc Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 2 Aug 2023 16:32:22 +0700 Subject: [PATCH 0913/1199] Remove isNotEmpty filter because they are already not empty --- .../ru/dbotthepony/mc/otm/container/UpgradeContainer.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt index 8a54d54a0..db3e843ec 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt @@ -23,15 +23,14 @@ open class UpgradeContainer(slotCount: Int, open val allowedUpgrades: Set Decimal, reducer: (Decimal, Decimal) -> Decimal): Decimal { return iterator() - .filter { it.isNotEmpty } .map { it.getCapability(MatteryCapability.UPGRADE).map(fn).orElse(Decimal.ZERO).moreThanZero() * it.count } .reduce(Decimal.ZERO, reducer) } override val speedBonus: Double - get() = iterator().filter { it.isNotEmpty }.mapToDouble { it.getCapability(MatteryCapability.UPGRADE).map { it.speedBonus }.orElse(0.0) * it.count }.sum() + get() = iterator().mapToDouble { it.getCapability(MatteryCapability.UPGRADE).map { it.speedBonus }.orElse(0.0) * it.count }.sum() override val processingItems: Int - get() = iterator().filter { it.isNotEmpty }.mapToInt { it.getCapability(MatteryCapability.UPGRADE).map { it.processingItems }.orElse(0).coerceAtLeast(0) * it.count }.reduce(0) { a, b -> a + b } + get() = iterator().mapToInt { it.getCapability(MatteryCapability.UPGRADE).map { it.processingItems }.orElse(0).coerceAtLeast(0) * it.count }.reduce(0) { a, b -> a + b } override val energyStorageFlat: Decimal get() = decimals(IMatteryUpgrade::energyStorageFlat, Decimal::plus) override val energyStorage: Decimal @@ -43,7 +42,7 @@ open class UpgradeContainer(slotCount: Int, open val allowedUpgrades: Set a * b } + get() = iterator().mapToDouble { it.getCapability(MatteryCapability.UPGRADE).map { it.failureMultiplier }.orElse(1.0).coerceAtLeast(0.0).pow(it.count.toDouble()) }.reduce(1.0) { a, b -> a * b } override val energyThroughputFlat: Decimal get() = decimals(IMatteryUpgrade::energyThroughputFlat, Decimal::plus) override val energyThroughput: Decimal From 029a6619784ec7ea77d7bcc7fe7789915f9f863c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 2 Aug 2023 17:13:49 +0700 Subject: [PATCH 0914/1199] Rebalance matter replicator storage values --- .../matter/MatterReplicatorBlockEntity.kt | 34 ++++--------------- .../mc/otm/config/AbstractConfig.kt | 4 +-- .../mc/otm/config/MachinesConfig.kt | 26 ++++++++------ 3 files changed, 24 insertions(+), 40 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index ba76baaba..ce93d1b65 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -23,6 +23,7 @@ import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.* import ru.dbotthepony.mc.otm.config.EnergyBalanceValues +import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.UpgradeContainer @@ -52,7 +53,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val pattern: Optional, val asDust: Boolean, ticks: Double, - ) : ItemJob(itemStack, ticks, BASE_CONSUMPTION) { + ) : ItemJob(itemStack, ticks, MachinesConfig.MATTER_REPLICATOR.energyConsumption) { companion object { val CODEC: Codec by lazy { RecordCodecBuilder.create { @@ -71,8 +72,8 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } override val upgrades = UpgradeContainer(this::setChangedLight, 3, UpgradeType.REPLICATOR) - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::energyLevelUpdated, upgrades.transform(ENERGY_VALUES))) - val matter = ProfiledMatterStorage(MatterStorageImpl(::matterLevelUpdated, FlowDirection.INPUT, upgrades.matterCapacity(::MATTER_CAPACITY))) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::energyLevelUpdated, upgrades.transform(MachinesConfig.MATTER_REPLICATOR))) + val matter = ProfiledMatterStorage(MatterStorageImpl(::matterLevelUpdated, FlowDirection.INPUT, upgrades.matterCapacity(MachinesConfig.MATTER_REPLICATOR::matterCapacity))) val container = MatteryContainer(::itemContainerUpdated, 5).also(::addDroppableContainer) val energyConfig = ConfigurableEnergy(energy) @@ -164,7 +165,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } override fun computeNextJob(id: Int): JobContainer { - if (energy.batteryLevel < BASE_CONSUMPTION) { + if (energy.batteryLevel < MachinesConfig.MATTER_REPLICATOR.energyConsumption) { return JobContainer.noEnergy() } @@ -193,7 +194,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val drainPerTick = job.matterPerTick * status.ticksAdvanced if (matter.extractMatter(drainPerTick, true) < drainPerTick) { - val toDrain = (drainPerTick * DRAIN_MULT) + val toDrain = (drainPerTick * Decimal(200)) .coerceAtMost(job.matterPerTick * (status.ticks - status.workTicks + status.ticksAdvanced)) .coerceAtLeast(Decimal.ONE) .coerceAtMost(matter.missingMatter) @@ -206,29 +207,6 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } companion object { - private val BASE_CONSUMPTION get() = _BASE_CONSUMPTION.get() - private val DRAIN_MULT get() = _DRAIN_MULT.get() - private val MATTER_CAPACITY get() = _MATTER_CAPACITY.get() - - private var _BASE_CONSUMPTION: DecimalConfigValue by WriteOnce() - private var _DRAIN_MULT: DecimalConfigValue by WriteOnce() - private var _MATTER_CAPACITY: DecimalConfigValue by WriteOnce() - - var ENERGY_VALUES: EnergyBalanceValues by WriteOnce() - private set - - fun registerConfig(builder: ForgeConfigSpec.Builder) { - builder.push(MNames.MATTER_REPLICATOR) - - ENERGY_VALUES = BlockEnergyStorageImpl.makeConfigEntry(builder, capacity = Decimal(200_000), throughput = Decimal(4_000)) - - _BASE_CONSUMPTION = builder.defineDecimal("basePowerConsumption", Decimal(400), Decimal.ONE) - _DRAIN_MULT = builder.comment("How much 'ticks' of replication should replicator drain matter from network when running low on internal matter buffer. This is ultimately a performance value.").defineDecimal("drainMultiplier", Decimal(200), Decimal.ONE) - _MATTER_CAPACITY = builder.defineDecimal("matterCapacity", Decimal(1_000), Decimal.ONE_TENTH) - - builder.pop() - } - const val FIRST_ACTUAL_OUTPUT_SLOT = 0 const val LAST_ACTUAL_OUTPUT_SLOT = 2 const val OUTPUT_DUST_MAIN = 3 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt index 906314c6c..aee16436d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt @@ -49,7 +49,7 @@ abstract class AbstractConfig(private val configName: String, private val type: energyStorage: Decimal, energyThroughput: Decimal, workTimeMultiplier: Double? = 1.0, - powerConsumption: Decimal, + energyConsumption: Decimal, matterCapacity: Decimal? = null, configurator: ForgeConfigSpec.Builder.() -> Unit = {} ): WorkerBalanceValues { @@ -58,7 +58,7 @@ abstract class AbstractConfig(private val configName: String, private val type: val obj = object : WorkerBalanceValues { override val energyCapacity: Decimal by builder.defineDecimal("ENERGY_CAPACITY", energyStorage, minimum = Decimal.ONE) override val energyThroughput: Decimal by builder.defineDecimal("ENERGY_THROUGHPUT", energyThroughput, minimum = Decimal.ONE) - override val energyConsumption: Decimal by builder.defineDecimal("ENERGY_CONSUMPTION", powerConsumption, minimum = Decimal.ONE) + override val energyConsumption: Decimal by builder.defineDecimal("ENERGY_CONSUMPTION", energyConsumption, minimum = Decimal.ONE) override val matterCapacity: Decimal by (if (matterCapacity == null) GetterSetter.box(Decimal.ZERO) else builder.defineDecimal("MATTER_CAPACITY", matterCapacity, minimum = Decimal.ONE)) override val workTimeMultiplier: Double by (if (workTimeMultiplier == null) GetterSetter.box(1.0) else builder.defineInRange("WORK_TIME_MULTIPLIER", workTimeMultiplier, 0.0)) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt index 1cd3ee462..875f885ff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.config import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity -import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.ChemicalGeneratorBlockEntity import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl @@ -14,21 +13,20 @@ object MachinesConfig : AbstractConfig("machines") { AndroidStationBlockEntity.registerConfig(builder) ChemicalGeneratorBlockEntity.registerConfig(builder) MatterBottlerBlockEntity.registerConfig(builder) - MatterReplicatorBlockEntity.registerConfig(builder) } val PLATE_PRESS = workerValues( MNames.PLATE_PRESS, energyStorage = Decimal(40_000), energyThroughput = Decimal(200), - powerConsumption = Decimal(15) + energyConsumption = Decimal(15) ) val MATTER_DECOMPOSER = workerValues( MNames.MATTER_DECOMPOSER, energyStorage = Decimal(100_000), energyThroughput = Decimal(400), - powerConsumption = Decimal(240), + energyConsumption = Decimal(240), matterCapacity = Decimal(400), ) @@ -36,14 +34,22 @@ object MachinesConfig : AbstractConfig("machines") { MNames.MATTER_SCANNER, energyStorage = Decimal(40_000), energyThroughput = Decimal(200), - powerConsumption = Decimal(80), + energyConsumption = Decimal(80), + ) + + val MATTER_REPLICATOR = workerValues( + MNames.MATTER_REPLICATOR, + energyStorage = Decimal(200_000), + energyThroughput = Decimal(4_000), + energyConsumption = Decimal(400), + matterCapacity = Decimal(200) ) private val MATTER_RECYCLER = workerValues( MNames.MATTER_RECYCLER, energyStorage = Decimal(80_000), energyThroughput = Decimal(400), - powerConsumption = Decimal(100), + energyConsumption = Decimal(100), matterCapacity = Decimal(400), workTimeMultiplier = null ) { @@ -59,7 +65,7 @@ object MachinesConfig : AbstractConfig("machines") { MNames.MATTER_RECONSTRUCTOR, energyStorage = Decimal(100_000), energyThroughput = Decimal(1000), - powerConsumption = Decimal(400), + energyConsumption = Decimal(400), matterCapacity = Decimal(200), workTimeMultiplier = null, ) { @@ -116,7 +122,7 @@ object MachinesConfig : AbstractConfig("machines") { "POWERED_FURNACE", energyStorage = Decimal(40_000), energyThroughput = Decimal(200), - powerConsumption = Decimal(20), + energyConsumption = Decimal(20), workTimeMultiplier = 0.75 ) @@ -124,7 +130,7 @@ object MachinesConfig : AbstractConfig("machines") { "POWERED_BLAST_FURNACE", energyStorage = Decimal(40_000), energyThroughput = Decimal(200), - powerConsumption = Decimal(20), + energyConsumption = Decimal(20), workTimeMultiplier = 0.75 ) @@ -132,7 +138,7 @@ object MachinesConfig : AbstractConfig("machines") { "POWERED_SMOKER", energyStorage = Decimal(40_000), energyThroughput = Decimal(200), - powerConsumption = Decimal(10), + energyConsumption = Decimal(10), workTimeMultiplier = 0.75 ) From c69fb5107c8eca3c7c1c523d29fd3ee843f12b03 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 2 Aug 2023 17:25:49 +0700 Subject: [PATCH 0915/1199] Split main and dust containers of matter replicator --- .../matter/MatterReplicatorBlockEntity.kt | 27 ++++++------------- .../otm/menu/matter/MatterReplicatorMenu.kt | 4 +-- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index ce93d1b65..a8a108693 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -9,28 +9,23 @@ import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState -import net.minecraftforge.common.ForgeConfigSpec import ru.dbotthepony.mc.otm.block.entity.JobContainer import ru.dbotthepony.mc.otm.block.entity.JobStatus import ru.dbotthepony.mc.otm.block.entity.ItemJob import ru.dbotthepony.mc.otm.block.entity.MachineJobEventLoop import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity +import ru.dbotthepony.mc.otm.capability.CombinedItemHandler import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.UpgradeType -import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.* -import ru.dbotthepony.mc.otm.config.EnergyBalanceValues import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.UpgradeContainer import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue -import ru.dbotthepony.mc.otm.core.math.defineDecimal -import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.data.DecimalCodec import ru.dbotthepony.mc.otm.data.UUIDCodec import ru.dbotthepony.mc.otm.data.minRange @@ -39,7 +34,6 @@ import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.menu.matter.MatterReplicatorMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MItems -import ru.dbotthepony.mc.otm.registry.MNames import java.util.* class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : @@ -74,10 +68,11 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : override val upgrades = UpgradeContainer(this::setChangedLight, 3, UpgradeType.REPLICATOR) val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::energyLevelUpdated, upgrades.transform(MachinesConfig.MATTER_REPLICATOR))) val matter = ProfiledMatterStorage(MatterStorageImpl(::matterLevelUpdated, FlowDirection.INPUT, upgrades.matterCapacity(MachinesConfig.MATTER_REPLICATOR::matterCapacity))) - val container = MatteryContainer(::itemContainerUpdated, 5).also(::addDroppableContainer) + val outputContainer = MatteryContainer(::itemContainerUpdated, 3).also(::addDroppableContainer) + val dustContainer = MatteryContainer(::itemContainerUpdated, 2).also(::addDroppableContainer) val energyConfig = ConfigurableEnergy(energy) - val itemConfig = ConfigurableItemHandler(output = container.handler(HandlerFilter.OnlyOut)) + val itemConfig = ConfigurableItemHandler(output = CombinedItemHandler(outputContainer.handler(HandlerFilter.OnlyOut), dustContainer.handler(HandlerFilter.OnlyOut))) val matterNode = object : MatterNode() { override fun getMatterHandler(): IMatterStorage { @@ -103,7 +98,8 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : savetables.stateful(::energy, ENERGY_KEY) savetables.stateful(::matter, MATTER_STORAGE_KEY) - savetables.stateful(::container, INVENTORY_KEY) + savetables.stateful(::outputContainer, INVENTORY_KEY) + savetables.stateful(::dustContainer) savetables.stateful(::upgrades) } @@ -115,7 +111,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val job = status.job if (job.asDust) { - job.matterValue = MItems.MATTER_DUST.moveIntoContainer(job.matterValue, container, OUTPUT_DUST_MAIN, OUTPUT_DUST_STACKING) + job.matterValue = MItems.MATTER_DUST.moveIntoContainer(job.matterValue, dustContainer, 0, 1) if (!job.matterValue.isZero) { return status.throttle() @@ -123,7 +119,7 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : matterNode.graph.notifyTaskCompletion(job.task) } else { - if (!container.fullyAddItem(job.itemStack, FIRST_ACTUAL_OUTPUT_SLOT .. LAST_ACTUAL_OUTPUT_SLOT)) { + if (!outputContainer.fullyAddItem(job.itemStack)) { return status.noItem() } @@ -205,11 +201,4 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : status.scale(matter.extractMatter(drainPerTick, false) / drainPerTick) visualProgress = status.workProgress } - - companion object { - const val FIRST_ACTUAL_OUTPUT_SLOT = 0 - const val LAST_ACTUAL_OUTPUT_SLOT = 2 - const val OUTPUT_DUST_MAIN = 3 - const val OUTPUT_DUST_STACKING = 4 - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt index 9b8527bda..cc5d52ba9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt @@ -7,9 +7,9 @@ import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import net.minecraft.world.SimpleContainer +import ru.dbotthepony.mc.otm.container.CombinedContainer import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.isNotEmpty -import ru.dbotthepony.mc.otm.item.matter.MatterDustItem import ru.dbotthepony.mc.otm.menu.MachineOutputSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput @@ -33,7 +33,7 @@ class MatterReplicatorMenu @JvmOverloads constructor( val upgrades = makeUpgradeSlots(3, tile?.upgrades) init { - val container = tile?.container ?: SimpleContainer(5) + val container = CombinedContainer(tile?.outputContainer ?: SimpleContainer(3), tile?.dustContainer ?: SimpleContainer(2)) storageSlots = immutableList(5) { addStorageSlot(MachineOutputSlot(container, it, onTake = { From 2614fd1f02ffbc6642e9356f12d3837dc9ee7a02 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 2 Aug 2023 18:08:34 +0700 Subject: [PATCH 0916/1199] Rebalanced matter bottler values --- .../entity/matter/MatterBottlerBlockEntity.kt | 103 ++++++------------ .../mc/otm/config/MachinesConfig.kt | 17 ++- 2 files changed, 50 insertions(+), 70 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index 2713dfe01..8038cab58 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -9,36 +9,29 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState -import net.minecraftforge.common.ForgeConfigSpec -import ru.dbotthepony.mc.otm.config.EnergyBalanceValues import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.capability.FlowDirection -import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage +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.graph.matter.MatterGraph import ru.dbotthepony.mc.otm.menu.matter.MatterBottlerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.core.* -import ru.dbotthepony.mc.otm.registry.MNames -import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue -import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode -class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : - MatteryPoweredBlockEntity(MBlockEntities.MATTER_BOTTLER, p_155229_, p_155230_) { +class MatterBottlerBlockEntity(blockPos: BlockPos, blockState: BlockState) : + MatteryPoweredBlockEntity(MBlockEntities.MATTER_BOTTLER, blockPos, blockState) { - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this, ENERGY_VALUES)) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this, MachinesConfig.MatterBottler.VALUES)) var isBottling: Boolean = true set(value) { @@ -99,7 +92,7 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } }) - val matter: ProfiledMatterStorage = ProfiledMatterStorage(object : MatterStorageImpl(this::setChangedLight, FlowDirection.BI_DIRECTIONAL, ::CAPACITY) { + val matter: ProfiledMatterStorage = ProfiledMatterStorage(object : MatterStorageImpl(this::setChangedLight, FlowDirection.BI_DIRECTIONAL, MachinesConfig.MatterBottler.VALUES::matterCapacity) { override val matterFlow: FlowDirection get() { return if (this@MatterBottlerBlockEntity.isBottling) FlowDirection.INPUT else FlowDirection.OUTPUT } @@ -172,10 +165,10 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return } - var work_stack: ItemStack? = null + var workStack: ItemStack? = null var capability: IMatterStorage? = null val align = if (isBottling) 0 else 3 - var work_slot = -1 + var workSlot = -1 val unexpectedDirection = if (isBottling) FlowDirection.OUTPUT else FlowDirection.INPUT for (i in align until align + 3) { @@ -186,50 +179,52 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : if (cap.matterFlow != unexpectedDirection) { if (this.isBottling && cap.missingMatter > Decimal.ZERO || !this.isBottling && cap.storedMatter > Decimal.ZERO) { - work_stack = itemStack + workStack = itemStack capability = cap - work_slot = i + workSlot = i break } } } } - if (work_stack == null) { + if (workStack == null) { lastWorkStack = null initialCapacity = null - } else if (work_stack != lastWorkStack) { - lastWorkStack = work_stack + } else if (workStack != lastWorkStack) { + lastWorkStack = workStack initialCapacity = capability!!.storedMatter } - val graph = matterNode.graph as MatterGraph? - if (capability != null) { if (blockState.getValue(WorkerState.SEMI_WORKER_STATE) !== WorkerState.WORKING) { level?.setBlock(blockPos, blockState.setValue(WorkerState.SEMI_WORKER_STATE, WorkerState.WORKING), Block.UPDATE_CLIENTS) } + val rate = MachinesConfig.MatterBottler.RATE + val consumption = MachinesConfig.MatterBottler.VALUES.energyConsumption + if (isBottling) { - if (matter.storedMatter < MATTER_EXCHANGE_RATE && graph != null) { - val extracted = graph.extractMatter( - matter.missingMatter.coerceAtMost(MATTER_EXCHANGE_RATE * EXTRACTION_TICKS).coerceAtMost(capability.missingMatter - matter.storedMatter), true - ) + if (matter.storedMatter < rate) { + val extracted = matterNode.graph.extractMatter( + matter.missingMatter + .coerceAtMost(rate * 200) + .coerceAtMost(capability.missingMatter - matter.storedMatter), true) if (extracted > Decimal.ZERO) { val received = matter.receiveMatter(extracted, false) - graph.extractMatter(received, false) + matterNode.graph.extractMatter(received, false) } } if (matter.storedMatter > Decimal.ZERO) { - val energyExtracted = energy.extractEnergy(ENERGY_CONSUMPTION, true) + val energyExtracted = energy.extractEnergy(consumption, true) if (!energyExtracted.isZero) { - val matter = capability.receiveMatter(MATTER_EXCHANGE_RATE.coerceAtMost(matter.storedMatter) * energyExtracted / ENERGY_CONSUMPTION, true) + val matter = capability.receiveMatter(rate.coerceAtMost(matter.storedMatter) * energyExtracted / consumption, true) if (!matter.isZero) { - energy.extractEnergy(ENERGY_CONSUMPTION * matter / MATTER_EXCHANGE_RATE, false) + energy.extractEnergy(consumption * matter / rate, false) capability.receiveMatter(matter, false) this.matter.extractMatter(matter, false) @@ -237,8 +232,8 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : if (capability.missingMatter.isZero) { for (i in 3..5) { if (container.getItem(i).isEmpty) { - container.setItem(work_slot, ItemStack.EMPTY) - container.setItem(i, work_stack!!) + container.setItem(workSlot, ItemStack.EMPTY) + container.setItem(i, workStack!!) break } } @@ -247,13 +242,13 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } } else { - val energyExtracted = energy.extractEnergy(ENERGY_CONSUMPTION, true) + val energyExtracted = energy.extractEnergy(consumption, true) if (!energyExtracted.isZero) { - val matter = capability.extractMatter(MATTER_EXCHANGE_RATE.coerceAtMost(matter.missingMatter) * energyExtracted / ENERGY_CONSUMPTION, true) + val matter = capability.extractMatter(rate.coerceAtMost(matter.missingMatter) * energyExtracted / consumption, true) if (!matter.isZero) { - this.energy.extractEnergy(ENERGY_CONSUMPTION * matter / MATTER_EXCHANGE_RATE,false) + this.energy.extractEnergy(consumption * matter / rate, false) capability.extractMatter(matter, false) this.matter.receiveMatter(matter, false) @@ -261,8 +256,8 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : if (capability.storedMatter.isZero) { for (i in 2 downTo 0) { if (container.getItem(i).isEmpty) { - container.setItem(work_slot, ItemStack.EMPTY) - container.setItem(i, work_stack!!) + container.setItem(workSlot, ItemStack.EMPTY) + container.setItem(i, workStack!!) break } } @@ -271,42 +266,14 @@ class MatterBottlerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } } else { - level!!.setBlock(blockPos, blockState.setValue(WorkerState.SEMI_WORKER_STATE, WorkerState.IDLE), Block.UPDATE_CLIENTS) + level?.setBlock(blockPos, blockState.setValue(WorkerState.SEMI_WORKER_STATE, WorkerState.IDLE), Block.UPDATE_CLIENTS) } - if (!isBottling && !matter.storedMatter.isZero && graph != null) { + if (!isBottling && !matter.storedMatter.isZero) { val diff = matter.extractMatter(matter.storedMatter, true) - val diff2 = graph.receiveMatter(diff, true) + val diff2 = matterNode.graph.receiveMatter(diff, true) matter.extractMatter(diff2, false) - graph.receiveMatter(diff2, false) - } - } - - companion object { - val MATTER_EXCHANGE_RATE get() = _MATTER_EXCHANGE_RATE.get() - val ENERGY_CONSUMPTION get() = _ENERGY_CONSUMPTION.get() - val EXTRACTION_TICKS get() = _EXTRACTION_TICKS.get() - val CAPACITY get() = _CAPACITY.get() - - private var _MATTER_EXCHANGE_RATE: DecimalConfigValue by WriteOnce() - private var _ENERGY_CONSUMPTION: DecimalConfigValue by WriteOnce() - private var _EXTRACTION_TICKS: DecimalConfigValue by WriteOnce() - private var _CAPACITY: DecimalConfigValue by WriteOnce() - - var ENERGY_VALUES: EnergyBalanceValues by WriteOnce() - private set - - fun registerConfig(builder: ForgeConfigSpec.Builder) { - builder.push(MNames.MATTER_BOTTLER) - - ENERGY_VALUES = BlockEnergyStorageImpl.makeConfigEntry(builder) - - _MATTER_EXCHANGE_RATE = builder.defineDecimal("matterExchangeRate", Decimal("0.04"), Decimal("0.0001")) - _ENERGY_CONSUMPTION = builder.defineDecimal("energyConsumption", Decimal(20), Decimal.ONE) - _EXTRACTION_TICKS = builder.defineDecimal("extractionTicks", Decimal(200), Decimal.ONE) - _CAPACITY = builder.defineDecimal("matterCapacity", Decimal(4_000), Decimal.ONE_TENTH) - - builder.pop() + matterNode.graph.receiveMatter(diff2, false) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt index 875f885ff..d42274729 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.config -import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.ChemicalGeneratorBlockEntity import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl @@ -12,7 +11,6 @@ object MachinesConfig : AbstractConfig("machines") { init { AndroidStationBlockEntity.registerConfig(builder) ChemicalGeneratorBlockEntity.registerConfig(builder) - MatterBottlerBlockEntity.registerConfig(builder) } val PLATE_PRESS = workerValues( @@ -56,6 +54,21 @@ object MachinesConfig : AbstractConfig("machines") { MatterRecycler } + private val MATTER_BOTTLER = workerValues( + MNames.MATTER_BOTTLER, + energyStorage = Decimal(40_000), + energyConsumption = Decimal(10), + energyThroughput = Decimal(200), + matterCapacity = Decimal(400) + ) { + MatterBottler + } + + object MatterBottler { + val VALUES by ::MATTER_BOTTLER + val RATE by builder.comment("Matter transferred per tick").defineDecimal("RATE", Decimal("2.0"), Decimal.ONE_TENTH) + } + object MatterRecycler { val VALUES by ::MATTER_RECYCLER val MATTER_PER_TICK by builder.defineDecimal("MATTER_PER_TICK", Decimal("0.5")) From b4c2f27c4c9352ec0ebc39f96585f97f449597a7 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 2 Aug 2023 22:05:01 +0700 Subject: [PATCH 0917/1199] Don't render exopack on invisible players --- .../java/ru/dbotthepony/mc/otm/client/model/ExosuitModel.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/ru/dbotthepony/mc/otm/client/model/ExosuitModel.java b/src/main/java/ru/dbotthepony/mc/otm/client/model/ExosuitModel.java index a3b528e85..3fef0651e 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/client/model/ExosuitModel.java +++ b/src/main/java/ru/dbotthepony/mc/otm/client/model/ExosuitModel.java @@ -122,6 +122,9 @@ public final class ExosuitModel { float p_117357_, float p_117358_ ) { + if (player.isInvisible()) + return; + var cap = player.getCapability(MatteryCapability.MATTERY_PLAYER); if (!cap.isPresent()) { From f18a3eaaaa28f0948a01453f9c0d6478a0ad2717 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 3 Aug 2023 17:24:32 +0700 Subject: [PATCH 0918/1199] Redo matter bottler --- .../block/entity/MatteryDeviceBlockEntity.kt | 12 +- .../block/entity/MatteryPoweredBlockEntity.kt | 16 +- .../entity/matter/MatterBottlerBlockEntity.kt | 350 +++++++++--------- .../mc/otm/capability/ProxiedItemHandler.kt | 30 ++ .../capability/energy/ProxiedEnergyStorage.kt | 8 + .../jade/providers/MatterBottlerProvider.kt | 2 +- .../mc/otm/container/ContainerIterator.kt | 6 +- .../mc/otm/container/IContainerIterator.kt | 12 + .../mc/otm/menu/matter/MatterBottlerMenu.kt | 42 +-- 9 files changed, 269 insertions(+), 209 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/capability/ProxiedItemHandler.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/container/IContainerIterator.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index fe8636ced..b4a250319 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -555,12 +555,12 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo capController.expose() } - when (value) { - ItemHandlerMode.DISABLED -> currentHandler = EmptyItemHandler - ItemHandlerMode.INPUT -> currentHandler = input!! - ItemHandlerMode.OUTPUT -> currentHandler = output!! - ItemHandlerMode.INPUT_OUTPUT -> currentHandler = inputOutput!! - ItemHandlerMode.BATTERY -> currentHandler = battery!! + currentHandler = when (value) { + ItemHandlerMode.DISABLED -> EmptyItemHandler + ItemHandlerMode.INPUT -> input!! + ItemHandlerMode.OUTPUT -> output!! + ItemHandlerMode.INPUT_OUTPUT -> inputOutput!! + ItemHandlerMode.BATTERY -> battery!! } } }) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt index c1ef9e92e..92045b5d8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt @@ -39,16 +39,14 @@ abstract class MatteryPoweredBlockEntity(p_155228_: BlockEntityType<*>, p_155229 if (demand.isZero) return for (stack in batteryContainer) { - if (!stack.isEmpty) { - stack.getCapability(ForgeCapabilities.ENERGY).ifPresentK { - val diff = it.extractEnergy(demand, false) - energy.receiveEnergy(diff, false) - demand -= diff - } - - if (demand <= Decimal.ZERO) - return + stack.getCapability(ForgeCapabilities.ENERGY).ifPresentK { + val diff = it.extractEnergy(demand, false) + energy.receiveEnergy(diff, false) + demand -= diff } + + if (demand <= Decimal.ZERO) + return } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index 8038cab58..82c8941a5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -9,11 +9,14 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState +import net.minecraftforge.items.IItemHandler import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.capability.CombinedItemHandler import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.ProxiedItemHandler import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage @@ -32,66 +35,71 @@ class MatterBottlerBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.MATTER_BOTTLER, blockPos, blockState) { val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this, MachinesConfig.MatterBottler.VALUES)) + val energyConfig = ConfigurableEnergy(energy) - var isBottling: Boolean = true - set(value) { - field = value - this.setChangedLight() + private inner class Container : MatteryContainer(3) { + init { + addDroppableContainer(this) } - private fun updateBlockState() { - val level = level as? ServerLevel ?: return - - var state = blockState - val initial = if (isBottling) 0 else 3 - - for (i in initial .. initial + 2) { - val desired = !container.getItem(i).isEmpty && container.getItem(i).getCapability(MatteryCapability.MATTER).isPresent - - if (state.getValue(MatterBottlerBlock.SLOT_PROPERTIES[i - initial]) != desired) { - state = state.setValue(MatterBottlerBlock.SLOT_PROPERTIES[i - initial], desired) - } - } - - if (state !== blockState) { - level.setBlock(blockPos, state, Block.UPDATE_CLIENTS) - } - } - - // TODO: оно должно что то делать - // true - continue even if empty when bottling / if full while unbottling - // false - spit into output slot - //private var work_behavior = true - - val container: MatteryContainer = object : MatteryContainer(this::setChangedLight, 6) { override fun getMaxStackSize(slot: Int, itemStack: ItemStack): Int { return 1 } override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { - super.setChanged(slot, new, old) + setChangedLight() updateBlockState() } - }.also(::addDroppableContainer) + } - val itemHandler = container.handler(object : HandlerFilter { - override fun canInsert(slot: Int, stack: ItemStack): Boolean { - if (isBottling) { - return slot < 3 && stack.getCapability(MatteryCapability.MATTER).isPresent + val unbottling: MatteryContainer = Container() + val bottling: MatteryContainer = Container() + + var isBottling: Boolean = true + set(value) { + field = value + initialCapacity = null + workProgress = 0f + this.setChangedLight() + + if (value) { + inputHandler.parent = bottlingHandler + outputHandler.parent = unbottlingHandler + } else { + inputHandler.parent = unbottlingHandler + outputHandler.parent = bottlingHandler } - return slot >= 3 && stack.getCapability(MatteryCapability.MATTER).isPresent + updateBlockState() } - override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { - if (isBottling) { - return slot >= 3 - } + var spitItemsWhenCantWork = false + set(value) { + field = value + this.setChangedLight() + } - return slot < 3 + val bottlingHandler = bottling.handler(object : HandlerFilter { + override fun canInsert(slot: Int, stack: ItemStack): Boolean { + return isBottling && stack.getCapability(MatteryCapability.MATTER).map { it.matterFlow.input && it.missingMatter.isPositive }.orElse(false) } }) + val unbottlingHandler = unbottling.handler(object : HandlerFilter { + override fun canInsert(slot: Int, stack: ItemStack): Boolean { + return !isBottling && stack.getCapability(MatteryCapability.MATTER).map { it.matterFlow.output && it.storedMatter.isPositive }.orElse(false) + } + }) + + private val inputHandler = ProxiedItemHandler(bottlingHandler) + private val outputHandler = ProxiedItemHandler(unbottlingHandler) + + val itemConfig = ConfigurableItemHandler( + input = inputHandler, + output = outputHandler, + battery = batteryItemHandler + ) + val matter: ProfiledMatterStorage = ProfiledMatterStorage(object : MatterStorageImpl(this::setChangedLight, FlowDirection.BI_DIRECTIONAL, MachinesConfig.MatterBottler.VALUES::matterCapacity) { override val matterFlow: FlowDirection get() { return if (this@MatterBottlerBlockEntity.isBottling) FlowDirection.INPUT else FlowDirection.OUTPUT @@ -103,18 +111,19 @@ class MatterBottlerBlockEntity(blockPos: BlockPos, blockState: BlockState) : init { exposeGlobally(MatteryCapability.MATTER, matter) exposeGlobally(MatteryCapability.MATTER_NODE, matterNode) - exposeItemsGlobally(itemHandler) savetables.bool(::isBottling) + savetables.bool(::spitItemsWhenCantWork) savetable(::energy, ENERGY_KEY) savetable(::matter, MATTER_STORAGE_KEY) - savetable(::container, INVENTORY_KEY) - - exposeEnergyGlobally(energy) + savetable(::bottling) + savetable(::unbottling) } + var workProgress: Float = 0f + private set + private var initialCapacity: Decimal? = null - private var lastWorkStack: ItemStack? = null override fun setLevel(level: Level) { super.setLevel(level) @@ -125,155 +134,156 @@ class MatterBottlerBlockEntity(blockPos: BlockPos, blockState: BlockState) : return MatterBottlerMenu(containerID, inventory, this) } - fun getWorkProgress(): Float { - val lastWorkStack = lastWorkStack ?: return 0f - val initialCapacity = initialCapacity ?: return 0f - val cap = lastWorkStack.getCapability(MatteryCapability.MATTER).orNull() ?: return 0f - - if (this.isBottling) { - if (cap.maxStoredMatter - initialCapacity <= Decimal.ZERO) { - return 0f - } - - return ((cap.storedMatter - initialCapacity) / (cap.maxStoredMatter - initialCapacity)).toFloat() - } - - if (initialCapacity <= Decimal.ZERO) { - return 0f - } - - return (Decimal.ONE - cap.storedMatter / initialCapacity).toFloat() - } - override fun setRemoved() { super.setRemoved() matterNode.isValid = false } + private fun updateBlockState(container: MatteryContainer) { + val level = level as? ServerLevel ?: return + var state = blockState + + for (i in 0 .. 2) { + val desired = !container.getItem(i).isEmpty && container.getItem(i).getCapability(MatteryCapability.MATTER).isPresent + + if (state.getValue(MatterBottlerBlock.SLOT_PROPERTIES[i]) != desired) { + state = state.setValue(MatterBottlerBlock.SLOT_PROPERTIES[i], desired) + } + } + + if (state !== blockState) { + level.setBlock(blockPos, state, Block.UPDATE_CLIENTS) + } + } + + private fun updateBlockState() { + if (isBottling) + updateBlockState(bottling) + else + updateBlockState(unbottling) + } + + private fun blockstateToWorking() { + if (blockState.getValue(WorkerState.SEMI_WORKER_STATE) !== WorkerState.WORKING) { + level?.setBlock(blockPos, blockState.setValue(WorkerState.SEMI_WORKER_STATE, WorkerState.WORKING), Block.UPDATE_CLIENTS) + } + } + + private fun blockstateToIdle() { + if (blockState.getValue(WorkerState.SEMI_WORKER_STATE) !== WorkerState.IDLE) { + level?.setBlock(blockPos, blockState.setValue(WorkerState.SEMI_WORKER_STATE, WorkerState.IDLE), Block.UPDATE_CLIENTS) + } + } + override fun tick() { super.tick() if (redstoneControl.isBlockedByRedstone) { - if (blockState.getValue(WorkerState.SEMI_WORKER_STATE) !== WorkerState.IDLE) { - level?.setBlock( - blockPos, - blockState.setValue(WorkerState.SEMI_WORKER_STATE, WorkerState.IDLE), - Block.UPDATE_CLIENTS - ) - } - + blockstateToIdle() return } - var workStack: ItemStack? = null - var capability: IMatterStorage? = null - val align = if (isBottling) 0 else 3 - var workSlot = -1 - val unexpectedDirection = if (isBottling) FlowDirection.OUTPUT else FlowDirection.INPUT + if (isBottling) { + var any = false + var idle = false + val iterator = bottling.iterator() - for (i in align until align + 3) { - val itemStack = container.getItem(i) + for (item in iterator) { + item.getCapability(MatteryCapability.MATTER).ifPresentK { + if (!it.missingMatter.isPositive) { + unbottling.consumeItem(item, false) + iterator.setChanged() + } else { + any = true + initialCapacity = initialCapacity ?: it.storedMatter + val rate = MachinesConfig.MatterBottler.RATE - if (!itemStack.isEmpty) { - val cap = itemStack.getCapability(MatteryCapability.MATTER).orNull() ?: continue + if (matter.storedMatter < rate) { + matter.receiveMatter(matterNode.graph.extractMatter(matter.missingMatter + .coerceAtMost(rate * 200) + .coerceAtMost(it.missingMatter - matter.storedMatter), false), false) + } - if (cap.matterFlow != unexpectedDirection) { - if (this.isBottling && cap.missingMatter > Decimal.ZERO || !this.isBottling && cap.storedMatter > Decimal.ZERO) { - workStack = itemStack - capability = cap - workSlot = i - break - } - } - } - } + if (matter.storedMatter.isPositive) { + matter.extractMatter(it.receiveMatter(rate.coerceAtMost(matter.storedMatter), false), false) - if (workStack == null) { - lastWorkStack = null - initialCapacity = null - } else if (workStack != lastWorkStack) { - lastWorkStack = workStack - initialCapacity = capability!!.storedMatter - } + if (!it.missingMatter.isPositive) { + initialCapacity = null + workProgress = 0f + } else { + workProgress = ((it.storedMatter - initialCapacity!!) / it.maxStoredMatter).toFloat() + } + } else { + idle = true - if (capability != null) { - if (blockState.getValue(WorkerState.SEMI_WORKER_STATE) !== WorkerState.WORKING) { - level?.setBlock(blockPos, blockState.setValue(WorkerState.SEMI_WORKER_STATE, WorkerState.WORKING), Block.UPDATE_CLIENTS) - } - - val rate = MachinesConfig.MatterBottler.RATE - val consumption = MachinesConfig.MatterBottler.VALUES.energyConsumption - - if (isBottling) { - if (matter.storedMatter < rate) { - val extracted = matterNode.graph.extractMatter( - matter.missingMatter - .coerceAtMost(rate * 200) - .coerceAtMost(capability.missingMatter - matter.storedMatter), true) - - if (extracted > Decimal.ZERO) { - val received = matter.receiveMatter(extracted, false) - matterNode.graph.extractMatter(received, false) - } - } - - if (matter.storedMatter > Decimal.ZERO) { - val energyExtracted = energy.extractEnergy(consumption, true) - - if (!energyExtracted.isZero) { - val matter = capability.receiveMatter(rate.coerceAtMost(matter.storedMatter) * energyExtracted / consumption, true) - - if (!matter.isZero) { - energy.extractEnergy(consumption * matter / rate, false) - - capability.receiveMatter(matter, false) - this.matter.extractMatter(matter, false) - - if (capability.missingMatter.isZero) { - for (i in 3..5) { - if (container.getItem(i).isEmpty) { - container.setItem(workSlot, ItemStack.EMPTY) - container.setItem(i, workStack!!) - break - } - } + if (spitItemsWhenCantWork) { + unbottling.consumeItem(item, false) + iterator.setChanged() } } } } + + if (any) { + break + } + } + + if (any && !idle) { + blockstateToWorking() } else { - val energyExtracted = energy.extractEnergy(consumption, true) - - if (!energyExtracted.isZero) { - val matter = capability.extractMatter(rate.coerceAtMost(matter.missingMatter) * energyExtracted / consumption, true) - - if (!matter.isZero) { - this.energy.extractEnergy(consumption * matter / rate, false) - - capability.extractMatter(matter, false) - this.matter.receiveMatter(matter, false) - - if (capability.storedMatter.isZero) { - for (i in 2 downTo 0) { - if (container.getItem(i).isEmpty) { - container.setItem(workSlot, ItemStack.EMPTY) - container.setItem(i, workStack!!) - break - } - } - } - } - } + matter.extractMatter(matterNode.graph.receiveMatter(matter.storedMatter, false), false) + blockstateToIdle() } } else { - level?.setBlock(blockPos, blockState.setValue(WorkerState.SEMI_WORKER_STATE, WorkerState.IDLE), Block.UPDATE_CLIENTS) - } + matter.extractMatter(matterNode.graph.receiveMatter(matter.storedMatter, false), false) - if (!isBottling && !matter.storedMatter.isZero) { - val diff = matter.extractMatter(matter.storedMatter, true) - val diff2 = matterNode.graph.receiveMatter(diff, true) - matter.extractMatter(diff2, false) - matterNode.graph.receiveMatter(diff2, false) + if (!matter.missingMatter.isPositive) { + if (spitItemsWhenCantWork) { + val iterator = unbottling.iterator() + + for (item in iterator) { + bottling.consumeItem(item, false) + iterator.setChanged() + } + } + + blockstateToIdle() + return + } + + var any = false + + val iterator = unbottling.iterator() + for (item in iterator) { + item.getCapability(MatteryCapability.MATTER).ifPresentK { + if (!it.storedMatter.isPositive) { + bottling.consumeItem(item, false) + iterator.setChanged() + } else { + any = true + initialCapacity = initialCapacity ?: it.storedMatter + matter.receiveMatter(it.extractMatter(MachinesConfig.MatterBottler.RATE, false), false) + + if (!it.storedMatter.isPositive) { + initialCapacity = null + workProgress = 0f + } else { + workProgress = 1f - (it.storedMatter / initialCapacity!!).toFloat() + } + } + } + + if (any) { + break + } + } + + if (any) { + blockstateToWorking() + } else { + blockstateToIdle() + } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/ProxiedItemHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/ProxiedItemHandler.kt new file mode 100644 index 000000000..82393a0a9 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/ProxiedItemHandler.kt @@ -0,0 +1,30 @@ +package ru.dbotthepony.mc.otm.capability + +import net.minecraft.world.item.ItemStack +import net.minecraftforge.items.IItemHandler + +class ProxiedItemHandler(var parent: T? = null) : IItemHandler { + override fun getSlots(): Int { + return parent?.slots ?: 0 + } + + override fun getStackInSlot(slot: Int): ItemStack { + return parent?.getStackInSlot(slot) ?: ItemStack.EMPTY + } + + override fun insertItem(slot: Int, stack: ItemStack, simulate: Boolean): ItemStack { + return parent?.insertItem(slot, stack, simulate) ?: stack + } + + override fun extractItem(slot: Int, amount: Int, simulate: Boolean): ItemStack { + return parent?.extractItem(slot, amount, simulate) ?: ItemStack.EMPTY + } + + override fun getSlotLimit(slot: Int): Int { + return parent?.getSlotLimit(slot) ?: 0 + } + + override fun isItemValid(slot: Int, stack: ItemStack): Boolean { + return parent?.isItemValid(slot, stack) ?: false + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ProxiedEnergyStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ProxiedEnergyStorage.kt index 70d345734..4aff62fc1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ProxiedEnergyStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ProxiedEnergyStorage.kt @@ -12,6 +12,14 @@ class ProxiedEnergyStorage(var parent: T? = null) : I return parent?.receiveEnergy(howMuch, simulate) ?: Decimal.ZERO } + override fun extractEnergyChecked(howMuch: Decimal, simulate: Boolean): Decimal { + return parent?.extractEnergyChecked(howMuch, simulate) ?: Decimal.ZERO + } + + override fun receiveEnergyChecked(howMuch: Decimal, simulate: Boolean): Decimal { + return parent?.receiveEnergyChecked(howMuch, simulate) ?: Decimal.ZERO + } + override var batteryLevel: Decimal get() = parent?.batteryLevel ?: Decimal.ZERO set(value) { parent?.batteryLevel = value } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterBottlerProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterBottlerProvider.kt index 9ac8d29bf..e2314a0ca 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterBottlerProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterBottlerProvider.kt @@ -25,7 +25,7 @@ object MatterBottlerProvider : IBlockComponentProvider, IServerDataProvider { +class ContainerIterator(private val container: Container) : IContainerIterator { private var index = 0 private var lastIndex = -1 @@ -37,6 +37,10 @@ class ContainerIterator(private val container: Container) : MutableIterator { + /** + * Notifies underlying container that last returned [ItemStack] was modified + * + * @throws NoSuchElementException + */ + fun setChanged() +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt index cc50fadfc..636b17f03 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.menu.matter +import com.google.common.collect.ImmutableList import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack @@ -9,12 +10,14 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage import ru.dbotthepony.mc.otm.capability.matter.canExtractMatter import ru.dbotthepony.mc.otm.capability.matter.canReceiveMatter +import ru.dbotthepony.mc.otm.container.CombinedContainer import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.makeSlots import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus @@ -22,38 +25,33 @@ class MatterBottlerMenu @JvmOverloads constructor( p_38852_: Int, inventory: Inventory, tile: MatterBottlerBlockEntity? = null -) : MatteryPoweredMenu( - MMenus.MATTER_BOTTLER, p_38852_, inventory, tile -) { +) : MatteryPoweredMenu(MMenus.MATTER_BOTTLER, p_38852_, inventory, tile) { val workFlow = BooleanInputWithFeedback(this) val progressWidget = ProgressGaugeWidget(this) val matterWidget = ProfiledLevelGaugeWidget(this, tile?.matter, LevelGaugeWidget(this, tile?.matter)) - val storageSlots: List + + val storageSlots: ImmutableList = makeSlots(CombinedContainer(tile?.bottling ?: SimpleContainer(3), tile?.unbottling ?: SimpleContainer(3))) { it, index -> + object : MatterySlot(it, index) { + override fun mayPlace(itemStack: ItemStack): Boolean { + val cap = itemStack.getCapability(MatteryCapability.MATTER).orNull() ?: return false + + if (workFlow.value) { + return index < 3 && cap.canReceiveMatter + } else { + return index >= 3 && cap.canExtractMatter + } + } + }.also(this::addStorageSlot) + } + val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) init { - val container = tile?.container ?: SimpleContainer(6) - if (tile != null) { - progressWidget.with(tile::getWorkProgress) + progressWidget.with(tile::workProgress) workFlow.with(tile::isBottling) } - storageSlots = immutableList(6) { index -> - object : MatterySlot(container, index) { - override fun mayPlace(itemStack: ItemStack): Boolean { - val cap = itemStack.getCapability(MatteryCapability.MATTER).orNull() ?: return false - - if (workFlow.value) { - return index < 3 && cap.canReceiveMatter - } else { - return index >= 3 && cap.canExtractMatter - } - } - } - } - - storageSlots.forEach(this::addStorageSlot) addInventorySlots() } } From 7b317a2efb9a41fdc9d6489680013ee789020dc7 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 3 Aug 2023 17:25:01 +0700 Subject: [PATCH 0919/1199] CoW non empty indices in container --- .../mc/otm/container/MatteryContainer.kt | 59 ++++++++++++++++--- 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt index a18991525..5a285fbe3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt @@ -26,10 +26,14 @@ import ru.dbotthepony.mc.otm.core.util.ItemValueCodec import ru.dbotthepony.mc.otm.core.util.VarIntValueCodec import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer import ru.dbotthepony.mc.otm.network.synchronizer.IField +import java.lang.ref.PhantomReference +import java.lang.ref.ReferenceQueue import java.lang.ref.WeakReference import java.util.* +import java.util.concurrent.CopyOnWriteArrayList import java.util.function.Supplier import kotlin.NoSuchElementException +import kotlin.collections.ArrayList @Suppress("UNUSED") open class MatteryContainer(protected val watcher: Runnable, private val size: Int) : Container, Iterable, INBTSerializable { @@ -41,7 +45,16 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I private val slots = Array(size) { ItemStack.EMPTY } private val nonEmptyFlags = BitSet() - private val nonEmptyIndices = IntArrayList() + private var nonEmptyIndices = IntArrayList() + private var indicesReferences = 0 + + private fun cowIndices() { + if (indicesReferences != 0) { + nonEmptyIndices = IntArrayList(nonEmptyIndices) + indicesReferences = 0 + } + } + private val trackedSlots: Array = Array(size) { ItemStack.EMPTY } private val filters: Array = arrayOfNulls(size) private var filterSynchronizer: WeakReference>>? = null @@ -196,7 +209,7 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I Arrays.fill(slots, ItemStack.EMPTY) Arrays.fill(filters, null) nonEmptyFlags.clear() - nonEmptyIndices.clear() + nonEmptyIndices = IntArrayList() filterSynchronizer?.get()?.value?.clear() @@ -468,11 +481,13 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I if (slots[slot].isEmpty) { if (nonEmptyFlags[slot]) { nonEmptyFlags[slot] = false - nonEmptyIndices.removeInt(slot) + cowIndices() + nonEmptyIndices.rem(slot) } } else { if (!nonEmptyFlags[slot]) { nonEmptyFlags[slot] = true + cowIndices() nonEmptyIndices.addSorted(slot, IntComparators.NATURAL_COMPARATOR) } } @@ -484,7 +499,7 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I final override fun clearContent() { nonEmptyFlags.clear() - nonEmptyIndices.clear() + nonEmptyIndices = IntArrayList() Arrays.fill(trackedSlots, ItemStack.EMPTY) @@ -497,7 +512,11 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I } } - private inner class Iterator : MutableIterator { + private inner class Iterator : IContainerIterator { + init { + indicesReferences++ + } + private val parent = nonEmptyIndices.intIterator() private var lastIndex = -1 @@ -519,11 +538,37 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I setItem(lastIndex, ItemStack.EMPTY) lastIndex = -1 } + + override fun setChanged() { + if (lastIndex == -1) { + throw NoSuchElementException() + } + + setChanged(lastIndex) + } } - final override fun iterator(): MutableIterator { + private object EmptyIterator : IContainerIterator { + override fun hasNext(): Boolean { + return false + } + + override fun next(): ItemStack { + throw NoSuchElementException() + } + + override fun remove() { + throw NoSuchElementException() + } + + override fun setChanged() { + throw NoSuchElementException() + } + } + + final override fun iterator(): IContainerIterator { if (isEmpty) { - return ObjectIterators.EMPTY_ITERATOR as MutableIterator + return EmptyIterator } return Iterator() From c08e262638542242f218fe9a9ce3890b8cbaf5bf Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 3 Aug 2023 17:26:42 +0700 Subject: [PATCH 0920/1199] Use boolean for indices cow --- .../ru/dbotthepony/mc/otm/container/MatteryContainer.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt index 5a285fbe3..e03d238fd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt @@ -46,12 +46,12 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I private val slots = Array(size) { ItemStack.EMPTY } private val nonEmptyFlags = BitSet() private var nonEmptyIndices = IntArrayList() - private var indicesReferences = 0 + private var indicesReferenced = false private fun cowIndices() { - if (indicesReferences != 0) { + if (indicesReferenced) { nonEmptyIndices = IntArrayList(nonEmptyIndices) - indicesReferences = 0 + indicesReferenced = false } } @@ -514,7 +514,7 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I private inner class Iterator : IContainerIterator { init { - indicesReferences++ + indicesReferenced = true } private val parent = nonEmptyIndices.intIterator() From 20d478cbfb482ad3356fa5113a9ae6be428d474c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 3 Aug 2023 18:32:41 +0700 Subject: [PATCH 0921/1199] The fastest code is code which doesn't execute Side automation no longer ticks if it doesn't automate --- .../dbotthepony/mc/otm/GlobalEventHandler.kt | 16 -- .../block/entity/MatteryDeviceBlockEntity.kt | 106 +++++++---- .../mc/otm/block/entity/RedstoneControl.kt | 30 ++- .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 10 + .../dbotthepony/mc/otm/core/util/TickList.kt | 172 ++++++++---------- 5 files changed, 178 insertions(+), 156 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt index f1c7c6aeb..eec7a0839 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt @@ -180,22 +180,6 @@ fun tickServer(ticker: IConditionalTickable) { postServerTick.add(ticker, SERVER_IS_LIVE, "Server is stopping") } -fun tickUntilServerPre(ticker: () -> Boolean) { - preServerTick.until(ticker, SERVER_IS_LIVE, "Server is stopping") -} - -fun tickUntilServer(ticker: () -> Boolean) { - postServerTick.until(ticker, SERVER_IS_LIVE, "Server is stopping") -} - -fun tickWhileServerPre(condition: () -> Boolean, ticker: () -> Unit) { - preServerTick.`while`(condition, ticker, SERVER_IS_LIVE, "Server is stopping") -} - -fun tickWhileServer(condition: () -> Boolean, ticker: () -> Unit) { - postServerTick.`while`(condition, ticker, SERVER_IS_LIVE, "Server is stopping") -} - fun Level.once(ticker: ITickable) { if (this.isClientSide) return diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index b4a250319..3db9d7ab0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -129,18 +129,21 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo } inner class Piece(val side: RelativeSide) : IFluidHandler, ITickable { - init { - tickList.always(this) + private val ticker = tickList.Ticker(this) + private val controller = sides[side]!!.Cap(ForgeCapabilities.FLUID_HANDLER, this) + private val neighbour by sides[side]!!.track(ForgeCapabilities.FLUID_HANDLER) + private fun updateTickerState() { + ticker.isEnabled = (automatePull || automatePush) && flow != FlowDirection.NONE && !redstoneControl.isBlockedByRedstone + } + + init { // https://tenor.com/view/simp-metal-gear-liquid-snake-running-gif-16717852 savetables.enum(::flow, "fluid_${side}_flow", FlowDirection::valueOf) savetables.bool(::automatePull, "fluid_${side}_pull") savetables.bool(::automatePush, "fluid_${side}_push") } - private val controller = sides[side]!!.Cap(ForgeCapabilities.FLUID_HANDLER, this) - private val neighbour by sides[side]!!.track(ForgeCapabilities.FLUID_HANDLER) - var flow by synchronizer.enum(possibleModes, setter = { value, access, setByRemote -> require(possibleModes.isSupertype(value)) { "Energy mode $value is not allowed (allowed modes: ${possibleModes.family})" } @@ -154,6 +157,8 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo controller.close() controller.expose() } + + updateTickerState() } }) @@ -162,14 +167,27 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo set(value) { field = value setChangedLight() + updateTickerState() } + // var automatePush by synchronizer.bool().property var automatePush = false set(value) { field = value setChangedLight() + updateTickerState() } + init { + tickList.once { + redstoneControl.addListener { + updateTickerState() + } + + updateTickerState() + } + } + override fun tick() { if (flow == FlowDirection.NONE || !automatePull && !automatePush || redstoneControl.isBlockedByRedstone) return @@ -324,25 +342,40 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo override val canSetBatteryLevel: Boolean by energy::canSetBatteryLevel + private val ticker = tickList.Ticker(this) + + private fun updateTickerState() { + ticker.isEnabled = (automatePull || automatePush) && energyFlow != FlowDirection.NONE && !redstoneControl.isBlockedByRedstone + } + // var automatePull by synchronizer.bool().property var automatePull = false set(value) { field = value setChangedLight() + updateTickerState() } + // var automatePush by synchronizer.bool().property var automatePush = false set(value) { field = value setChangedLight() + updateTickerState() } init { - tickList.always(this) - savetables.enum(::energyFlow, "energy_${side}_flow", FlowDirection::valueOf) savetables.bool(::automatePull, "energy_${side}_pull") savetables.bool(::automatePush, "energy_${side}_push") + + tickList.once { + redstoneControl.addListener { + updateTickerState() + } + + updateTickerState() + } } override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { @@ -406,6 +439,8 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo controller.expose() } } + + updateTickerState() } }) @@ -533,11 +568,26 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo inner class Piece(val side: RelativeSide) : IItemHandler, ITickable { private var currentHandler: IItemHandler = EmptyItemHandler + set(value) { + field = value + updateTickerState() + } + private val capController = sides[side]!!.Cap(ForgeCapabilities.ITEM_HANDLER, this) private val neighbour by sides[side]!!.track(ForgeCapabilities.ITEM_HANDLER) + private val ticker = tickList.Ticker(this) + + private var innerSlotPull = 0 + private var outerSlotPull = 0 + + private var innerSlotPush = 0 + private var outerSlotPush = 0 + + private fun updateTickerState() { + ticker.isEnabled = (automatePull || automatePush) && mode != ItemHandlerMode.DISABLED && !redstoneControl.isBlockedByRedstone && currentHandler.slots != 0 + } init { - tickList.always(this) capController.close() } @@ -565,28 +615,6 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo } }) - /*var automatePull by synchronizer.bool(setter = { value, access, _ -> - if (access.readBoolean() != value) { - access.write(value) - - if (value) { - innerSlotPush = 0 - outerSlotPush = 0 - } - } - }).property - - var automatePush by synchronizer.bool(setter = { value, access, _ -> - if (access.readBoolean() != value) { - access.write(value) - - if (value) { - innerSlotPush = 0 - outerSlotPush = 0 - } - } - }).property*/ - var automatePull = false set(value) { if (field != value) { @@ -597,6 +625,8 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo innerSlotPush = 0 outerSlotPush = 0 } + + updateTickerState() } } @@ -610,6 +640,8 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo innerSlotPush = 0 outerSlotPush = 0 } + + updateTickerState() } } @@ -617,14 +649,16 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo savetables.bool(::automatePull, "itemhandler_${side}_automatePull") savetables.bool(::automatePush, "itemhandler_${side}_automatePush") savetables.enum(::mode, "itemhandler_${side}_mode", ItemHandlerMode::valueOf) + + tickList.once { + redstoneControl.addListener { + updateTickerState() + } + + updateTickerState() + } } - private var innerSlotPull = 0 - private var outerSlotPull = 0 - - private var innerSlotPush = 0 - private var outerSlotPush = 0 - override fun tick() { if (mode == ItemHandlerMode.DISABLED || !automatePull && !automatePush || redstoneControl.isBlockedByRedstone || currentHandler.slots == 0) return diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt index e49245b47..4f311198a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.block.entity +import it.unimi.dsi.fastutil.booleans.BooleanConsumer import net.minecraft.nbt.CompoundTag import net.minecraftforge.common.util.INBTSerializable import ru.dbotthepony.mc.otm.core.nbt.mapString @@ -13,9 +14,14 @@ interface IRedstoneControlled { abstract class AbstractRedstoneControl : INBTSerializable { abstract var redstoneSetting: RedstoneSetting abstract var redstoneSignal: Int + protected val listeners = ArrayList() val isBlockedByRedstone: Boolean get() = !redstoneSetting.test(redstoneSignal) + fun addListener(callback: BooleanConsumer) { + listeners.add(callback) + } + override fun serializeNBT(): CompoundTag { return CompoundTag().also { it[SETTING_KEY] = redstoneSetting.toString() @@ -47,7 +53,11 @@ class RedstoneControl(private val valueChanges: (new: Boolean, old: Boolean) -> val old = isBlockedByRedstone field = level val state = isBlockedByRedstone - valueChanges.invoke(state, old) + + if (state != old) { + valueChanges.invoke(state, old) + listeners.forEach { it.accept(state) } + } } override var redstoneSignal: Int = 0 @@ -56,7 +66,11 @@ class RedstoneControl(private val valueChanges: (new: Boolean, old: Boolean) -> val old = isBlockedByRedstone field = setting val state = isBlockedByRedstone - valueChanges.invoke(state, old) + + if (state != old) { + valueChanges.invoke(state, old) + listeners.forEach { it.accept(state) } + } } } @@ -72,7 +86,11 @@ class SynchronizedRedstoneControl( val old = isBlockedByRedstone access.write(value) val state = isBlockedByRedstone - valueChanges.invoke(state, old) + + if (state != old) { + valueChanges.invoke(state, old) + listeners.forEach { it.accept(state) } + } } }) @@ -84,7 +102,11 @@ class SynchronizedRedstoneControl( val old = isBlockedByRedstone access.write(value) val state = isBlockedByRedstone - valueChanges.invoke(state, old) + + if (state != old) { + valueChanges.invoke(state, old) + listeners.forEach { it.accept(state) } + } } }).property } 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 a0a46e119..d39a40ba6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -10,6 +10,7 @@ import com.google.common.collect.ImmutableSet import com.google.gson.JsonElement import com.google.gson.JsonObject import com.google.gson.JsonPrimitive +import it.unimi.dsi.fastutil.objects.ObjectComparators import net.minecraft.core.BlockPos import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.NbtAccounter @@ -417,3 +418,12 @@ fun List.searchInsertionIndex(element: E, comparator: Comparator, from fun MutableList.addSorted(element: E, comparator: Comparator) { add(searchInsertionIndex(element, comparator), element) } + +/** + * Inserts [element] into [MutableList] at index determined by comparing values themselves + * + * If [MutableList] is not sorted, result of this function is undefined + */ +fun > MutableList.addSorted(element: E) { + add(searchInsertionIndex(element, ObjectComparators.NATURAL_COMPARATOR), element) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt index e7a95b0da..13df85dc2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt @@ -1,16 +1,18 @@ package ru.dbotthepony.mc.otm.core.util import org.apache.logging.log4j.LogManager +import ru.dbotthepony.mc.otm.core.addSorted class TickList : ITickable { private val conditional = ArrayDeque() - private val conditionalValveTime = ArrayList() + private val conditionalQueued = ArrayList() private val once = ArrayDeque() - private val onceValveTime = ArrayList() + private val onceQueued = ArrayList() private val always = ArrayList() - private val alwaysValveTime = ArrayList() + private val alwaysQueued = ArrayList() + private val toRemoveFromAlways = ArrayList() private val timers = ArrayDeque() @@ -19,45 +21,18 @@ class TickList : ITickable { var ticks = 0 private set - private var nothingToDo = true - - inner class Timer(val timerTicks: Int, val runnable: Runnable) { + inner class Timer(val timerTicks: Int, val runnable: Runnable) : Comparable { val ringAt = ticks + timerTicks var finished = false private set init { - nothingToDo = false + timers.addSorted(this) + } - if (timers.isEmpty()) { - timers.addLast(this) - } else { - val iterator = timers.listIterator() - var hit = false - - for (value in iterator) { - if (value.ringAt == ringAt) { - hit = true - iterator.add(this) - break - } else if (value.ringAt > ringAt) { - if (iterator.hasPrevious()) { - iterator.previous() - iterator.add(this) - } else { - timers.addFirst(this) - } - - hit = true - break - } - } - - if (!hit) { - timers.addLast(this) - } - } + override fun compareTo(other: Timer): Int { + return ringAt.compareTo(other.ringAt) } fun execute() { @@ -67,13 +42,49 @@ class TickList : ITickable { } } - fun add(ticker: IConditionalTickable) { - if (inTicker) { - conditionalValveTime.add(ticker) - } else { - conditional.addFirst(ticker) - nothingToDo = false + inner class Ticker(parent: ITickable) : ITickable by parent { + init { + add(this, always, alwaysQueued) } + + var isEnabled = true + set(value) { + if (field != value) { + field = value + + if (value) { + add(this, always, alwaysQueued) + } else { + alwaysQueued.remove(this) + + if (inTicker) { + toRemoveFromAlways.add(this) + } else { + always.remove(this) + } + } + } + } + + fun disable() { + isEnabled = false + } + + fun enable() { + isEnabled = true + } + } + + private fun add(value: T, regular: MutableList, queue: MutableList) { + if (inTicker) { + queue.add(value) + } else { + regular.add(value) + } + } + + fun add(ticker: IConditionalTickable) { + add(ticker, conditional, conditionalQueued) } fun add(ticker: IConditionalTickable, condition: Boolean, reason: String) { @@ -86,12 +97,7 @@ class TickList : ITickable { } fun once(ticker: ITickable) { - if (inTicker) { - onceValveTime.add(ticker) - } else { - once.addFirst(ticker) - nothingToDo = false - } + add(ticker, once, onceQueued) } fun once(ticker: ITickable, condition: Boolean, reason: String) { @@ -104,12 +110,7 @@ class TickList : ITickable { } fun always(ticker: ITickable) { - if (inTicker) { - alwaysValveTime.add(ticker) - } else { - always.add(ticker) - nothingToDo = false - } + add(ticker, always, alwaysQueued) } fun timer(timerTicks: Int, action: Runnable, condition: Boolean, reason: String): Timer? { @@ -125,23 +126,7 @@ class TickList : ITickable { return Timer(timerTicks, action) } - fun until(ticker: () -> Boolean) = add(IConditionalTickable.wrap(ticker)) - fun `while`(tickerCondition: () -> Boolean, ticker: () -> Unit) = add( - IConditionalTickable.wrap( - tickerCondition, - ticker - ) - ) - - fun until(ticker: () -> Boolean, condition: Boolean, reason: String) = add(IConditionalTickable.wrap(ticker), condition, reason) - fun `while`(tickerCondition: () -> Boolean, ticker: () -> Unit, condition: Boolean, reason: String) = add( - IConditionalTickable.wrap(tickerCondition, ticker), condition, reason) - override fun tick() { - if (nothingToDo) { - return - } - if (inTicker) { throw ConcurrentModificationException("Already ticking") } @@ -150,23 +135,12 @@ class TickList : ITickable { inTicker = true try { - var nothingToDo = true - val conditional = conditional - val once = once - val always = always - val alwaysValveTime = alwaysValveTime - val conditionalValveTime = conditionalValveTime - val onceValveTime = onceValveTime - val timers = timers - if (conditional.isNotEmpty()) { val iterator = conditional.iterator() for (ticker in iterator) { if (!ticker.tick()) { iterator.remove() - } else { - nothingToDo = false } } } @@ -179,40 +153,40 @@ class TickList : ITickable { once.clear() } + if (toRemoveFromAlways.isNotEmpty()) { + for (v in toRemoveFromAlways) always.remove(v) + toRemoveFromAlways.clear() + } + if (always.isNotEmpty()) { for (ticker in always) { ticker.tick() } - - nothingToDo = false } - if (alwaysValveTime.isNotEmpty()) { - always.addAll(alwaysValveTime) - alwaysValveTime.clear() - nothingToDo = false + if (alwaysQueued.isNotEmpty()) { + always.ensureCapacity(always.size + alwaysQueued.size) + for (v in alwaysQueued) always.add(v) // avoid toArray() + alwaysQueued.clear() } - if (conditionalValveTime.isNotEmpty()) { - for (ticker in conditionalValveTime) { + if (conditionalQueued.isNotEmpty()) { + for (ticker in conditionalQueued) { conditional.addFirst(ticker) } - conditionalValveTime.clear() - nothingToDo = false + conditionalQueued.clear() } - if (onceValveTime.isNotEmpty()) { - for (ticker in onceValveTime) { + if (onceQueued.isNotEmpty()) { + for (ticker in onceQueued) { once.addFirst(ticker) } - onceValveTime.clear() - nothingToDo = false + onceQueued.clear() } while (timers.isNotEmpty()) { - nothingToDo = false val head = timers.first() if (head.ringAt <= ticks) { @@ -222,8 +196,6 @@ class TickList : ITickable { break } } - - this.nothingToDo = nothingToDo } finally { inTicker = false } @@ -233,13 +205,13 @@ class TickList : ITickable { if (inTicker) throw ConcurrentModificationException() conditional.clear() - conditionalValveTime.clear() + conditionalQueued.clear() once.clear() - onceValveTime.clear() + onceQueued.clear() always.clear() - alwaysValveTime.clear() + alwaysQueued.clear() timers.clear() } From 06e6168a7302501bf203ca4cc0f0d53bd8b5bc9d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 3 Aug 2023 18:36:17 +0700 Subject: [PATCH 0922/1199] Faster version of Container.balance --- src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt index d74d6220b..1029bdbff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt @@ -263,7 +263,7 @@ fun Container.balance(slots: IntRange) { balance(IntArraySet().also { it.addAll(slots) }) } -fun Container.balance(startSlot: Int = 0, endSlot: Int = containerSize - 1) { +fun Container.balance(startSlot: Int, endSlot: Int) { require(startSlot <= endSlot) { "Invalid slot range: $startSlot .. $endSlot" } var any = false @@ -277,3 +277,10 @@ fun Container.balance(startSlot: Int = 0, endSlot: Int = containerSize - 1) { if (!any) return balance(IntArraySet(endSlot - startSlot + 1).also { for (i in startSlot .. endSlot) it.add(i) }, false) } + +fun Container.balance() { + if (isEmpty) + return + + balance(IntArraySet(containerSize).also { for (i in 0 until containerSize) it.add(i) }, false) +} From 5e7c8c08f5bc8b84ba17ee102d5436075509fe39 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 3 Aug 2023 19:32:28 +0700 Subject: [PATCH 0923/1199] Remove capability iterator --- .../matter/PatternStorageBlockEntity.kt | 13 ++-- .../mc/otm/container/ContainerIterator.kt | 8 ++- .../ru/dbotthepony/mc/otm/container/Ext.kt | 39 ------------ .../otm/core/collect/CapabilityIterators.kt | 60 ------------------- .../mc/otm/core/collect/ItemStackIterators.kt | 5 -- .../mc/otm/menu/storage/ItemMonitorMenu.kt | 7 +-- 6 files changed, 16 insertions(+), 116 deletions(-) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/CapabilityIterators.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ItemStackIterators.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt index 39365b5ea..7c7be1288 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt @@ -18,14 +18,15 @@ import net.minecraft.world.level.block.Block import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.matter.* import ru.dbotthepony.mc.otm.container.HandlerFilter +import ru.dbotthepony.mc.otm.container.iterator import ru.dbotthepony.mc.otm.container.stream -import ru.dbotthepony.mc.otm.core.collect.iterator +import ru.dbotthepony.mc.otm.core.collect.filterNotNull +import ru.dbotthepony.mc.otm.core.collect.map import ru.dbotthepony.mc.otm.core.filterNotNull import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode import ru.dbotthepony.mc.otm.registry.MBlockEntities -import java.util.ArrayList import java.util.stream.Stream @MethodsReturnNonnullByDefault @@ -110,7 +111,7 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : override val patternCapacity: Int get() { var stored = 0L - for ((_, pattern) in this.container.iterator(MatteryCapability.PATTERN)) + for (pattern in this.container.iterator().map { it.getCapability(MatteryCapability.PATTERN).orNull() }.filterNotNull()) stored += pattern.patternCapacity.toLong() return if (stored > Int.MAX_VALUE) Int.MAX_VALUE else stored.toInt() @@ -119,7 +120,7 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : override val storedPatterns: Int get() { var stored = 0L - for ((_, pattern) in this.container.iterator(MatteryCapability.PATTERN)) + for (pattern in this.container.iterator().map { it.getCapability(MatteryCapability.PATTERN).orNull() }.filterNotNull()) stored += pattern.storedPatterns.toLong() return if (stored > Int.MAX_VALUE) Int.MAX_VALUE else stored.toInt() @@ -131,8 +132,8 @@ class PatternStorageBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } override fun insertPattern(pattern: PatternState, onlyUpdate: Boolean, simulate: Boolean): PatternInsertStatus { - for (pair in this.container.iterator(MatteryCapability.PATTERN)) { - val status = pair.second.insertPattern(pattern, onlyUpdate, simulate) + for (spattern in this.container.iterator().map { it.getCapability(MatteryCapability.PATTERN).orNull() }.filterNotNull()) { + val status = spattern.insertPattern(pattern, onlyUpdate, simulate) if (!status.isFailed) { if (!simulate) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerIterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerIterator.kt index 87a193247..1269f480a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerIterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerIterator.kt @@ -43,4 +43,10 @@ class ContainerIterator(private val container: Container) : IContainerIterator { } } -fun Container.iterator() = ContainerIterator(this) +fun Container.iterator(): IContainerIterator { + return if (this is MatteryContainer) { + iterator() + } else { + ContainerIterator(this) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt index 1029bdbff..9b79113b9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt @@ -9,11 +9,8 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap import net.minecraft.world.Container import net.minecraft.world.item.ItemStack import net.minecraft.world.item.enchantment.EnchantmentHelper.hasVanishingCurse -import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.fluids.capability.IFluidHandler import ru.dbotthepony.mc.otm.core.addAll -import ru.dbotthepony.mc.otm.core.collect.iterator -import ru.dbotthepony.mc.otm.core.collect.nonEmpty import ru.dbotthepony.mc.otm.core.isNotEmpty import kotlin.math.roundToInt @@ -98,42 +95,6 @@ fun Container.vanishCursedItems() { } } -inline fun Container.forEach(cap: Capability, consumer: (Pair) -> Unit) { - for (value in iterator(cap)) { - consumer(value) - } -} - -inline fun Container.forEach(cap: Capability, consumer: (ItemStack, T) -> Unit) { - for ((a, b) in iterator(cap)) { - consumer(a, b) - } -} - -inline fun Container.forEachItem(cap: Capability, consumer: (ItemStack) -> Unit) { - for (pair in iterator(cap)) { - consumer(pair.first) - } -} - -inline fun Container.forEachCapability(cap: Capability, consumer: (T) -> Unit) { - for (pair in iterator(cap)) { - consumer(pair.second) - } -} - -inline fun Container.forEach(lambda: (ItemStack) -> Unit) { - for (value in iterator()) { - lambda(value) - } -} - -inline fun Container.forEachNonEmpty(lambda: (ItemStack) -> Unit) { - for (value in iterator().nonEmpty()) { - lambda(value) - } -} - fun Container.balance(slots: IntSet, checkForEmpty: Boolean = true) { if (slots.isEmpty() || checkForEmpty && !slots.any { getItem(it).isNotEmpty }) return diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/CapabilityIterators.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/CapabilityIterators.kt deleted file mode 100644 index eb4760384..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/CapabilityIterators.kt +++ /dev/null @@ -1,60 +0,0 @@ -package ru.dbotthepony.mc.otm.core.collect - -import net.minecraft.world.Container -import net.minecraftforge.common.capabilities.Capability -import net.minecraftforge.common.capabilities.ICapabilityProvider -import ru.dbotthepony.mc.otm.container.iterator -import ru.dbotthepony.mc.otm.core.ifPresentK - -open class CapabilityIterator

(protected open val parent: Iterator

, private val cap: Capability) : Iterator> { - private var provider: P? = null - private var capability: T? = null - private var searched = false - - private fun search() { - searched = true - - if (provider != null) { - return - } - - for (provider in parent) { - provider.getCapability(cap).ifPresentK { - this.provider = provider - capability = it - return - } - } - } - - override fun hasNext(): Boolean { - if (!searched) { - search() - } - - return provider != null - } - - override fun next(): Pair { - if (!searched) { - search() - } - - val provider = provider ?: throw IllegalStateException("No next element") - val capability = capability ?: throw IllegalStateException("No next element") - this.provider = null - this.capability = null - this.searched = false - return provider to capability - } -} - -class MutableCapabilityIterator

(override val parent: MutableIterator

, cap: Capability) : CapabilityIterator(parent, cap), MutableIterator> { - override fun remove() { - parent.remove() - } -} - -fun Container.iterator(cap: Capability) = CapabilityIterator(iterator().nonEmpty(), cap) -fun

Iterator

.filtered(cap: Capability) = CapabilityIterator(this, cap) -fun

MutableIterator

.filtered(cap: Capability) = MutableCapabilityIterator(this, cap) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ItemStackIterators.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ItemStackIterators.kt deleted file mode 100644 index ea38e5fec..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ItemStackIterators.kt +++ /dev/null @@ -1,5 +0,0 @@ -package ru.dbotthepony.mc.otm.core.collect - -import net.minecraft.world.item.ItemStack - -fun Iterator.nonEmpty() = FilteredIterator(this) { !it.isEmpty } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt index fe5cb8824..c5941db23 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt @@ -5,13 +5,11 @@ 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.inventory.Slot import net.minecraft.world.item.ItemStack import net.minecraftforge.network.PacketDistributor import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorPlayerSettings import ru.dbotthepony.mc.otm.container.get -import ru.dbotthepony.mc.otm.core.collect.nonEmpty import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.data.INetworkedItemViewProvider @@ -21,7 +19,6 @@ import ru.dbotthepony.mc.otm.registry.MMenus import ru.dbotthepony.mc.otm.storage.* import java.util.* - private class ResultSlot(container: Container) : MatterySlot(container, 0) { override fun mayPlace(itemStack: ItemStack): Boolean { return false @@ -198,7 +195,7 @@ class ItemMonitorMenu @JvmOverloads constructor( var maxStack = 64 if (settings.craftingAmount == ItemMonitorPlayerSettings.Amount.FULL) { - for (gridItem in tile.craftingGrid.iterator().nonEmpty()) { + for (gridItem in tile.craftingGrid.iterator()) { if (!gridItem.isStackable) { hasUnstackables = true break @@ -207,7 +204,7 @@ class ItemMonitorMenu @JvmOverloads constructor( } else { maxStack = 0 - for (gridItem in tile.craftingGrid.iterator().nonEmpty()) { + for (gridItem in tile.craftingGrid.iterator()) { maxStack = maxStack.coerceAtLeast(gridItem.maxStackSize) } } From 9ae099ec2349321e49d729ec9085a6441bc2132b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 3 Aug 2023 19:41:58 +0700 Subject: [PATCH 0924/1199] Add mutating operations to streamy iterators --- .../entity/tech/PlatePressBlockEntity.kt | 8 ++- .../mc/otm/core/collect/StreamyIterator.kt | 55 +++++++++++++++---- 2 files changed, 49 insertions(+), 14 deletions(-) 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 f7583bede..484df1610 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 @@ -20,6 +20,8 @@ import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.HandlerFilter 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.findAny import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -88,10 +90,10 @@ class PlatePressBlockEntity( val recipe = level.recipeManager .byType(MRecipes.PLATE_PRESS) .values - .stream() + .iterator() .filter { it.matches(inputContainer, id) } - .findAny(). - orElse(null) ?: return JobContainer.noItem() + .findAny() + .orElse(null) ?: return JobContainer.noItem() val toProcess = inputContainer[id].count.coerceAtMost(1 + upgrades.processingItems) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt index 53cda603a..ad729b6d7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt @@ -14,7 +14,7 @@ import java.util.stream.Collector // Aside parallel work, unimplemented Stream API elements can be easily implemented when required -class FilteredIterator(private val parent: Iterator, private val predicate: Predicate) : Iterator { +class FilteredIterator(private val parent: Iterator, private val predicate: Predicate) : MutableIterator { private var foundValue: Any? = Companion override fun hasNext(): Boolean { @@ -54,10 +54,19 @@ class FilteredIterator(private val parent: Iterator, private val predicate return foundValue as T } + override fun remove() { + if (foundValue === Companion) { + throw NoSuchElementException() + } + + (parent as MutableIterator).remove() + foundValue = Companion + } + private companion object } -class MappingIterator(private val parent: Iterator, private val transform: (T) -> R) : Iterator { +class MappingIterator(private val parent: Iterator, private val transform: (T) -> R) : MutableIterator { override fun hasNext(): Boolean { return parent.hasNext() } @@ -65,10 +74,15 @@ class MappingIterator(private val parent: Iterator, private val transfo override fun next(): R { return transform.invoke(parent.next()) } + + override fun remove() { + (parent as MutableIterator).remove() + } } -class FlatMappingIterator(private val parent: Iterator, private val transform: (T) -> Iterator) : Iterator { +class FlatMappingIterator(private val parent: Iterator, private val transform: (T) -> Iterator) : MutableIterator { private var current: Iterator? = null + private var last: Iterator? = null override fun hasNext(): Boolean { while (current?.hasNext() != true && parent.hasNext()) { @@ -82,7 +96,14 @@ class FlatMappingIterator(private val parent: Iterator, private val tra if (!hasNext()) throw NoSuchElementException() - return current!!.next() + val v = current!!.next() + last = current + return v + } + + override fun remove() { + (last as MutableIterator? ?: throw NoSuchElementException()).remove() + last = null } } @@ -105,12 +126,13 @@ class LimitingIterator(val parent: Iterator, val limit: Long) : Iterator(val parent: Iterator, skip: Long) : Iterator { +class SkippingIterator(val parent: Iterator, skip: Long) : MutableIterator { init { require(skip >= 0) { "Invalid skip amount $skip" } } private var found = skip + private var returned = false override fun hasNext(): Boolean { while (parent.hasNext() && found > 0L) { @@ -125,15 +147,26 @@ class SkippingIterator(val parent: Iterator, skip: Long) : Iterator { if (!hasNext()) throw NoSuchElementException() - return parent.next() + val v = parent.next() + returned = true + return v + } + + override fun remove() { + if (!returned) { + throw NoSuchElementException() + } + + returned = false + (parent as MutableIterator).remove() } } -fun Iterator.filter(condition: Predicate): Iterator = FilteredIterator(this, condition) -fun Iterator.map(mapper: (T) -> R): Iterator = MappingIterator(this, mapper) -fun Iterator.map(mapper: java.util.function.Function): Iterator = MappingIterator(this, mapper::apply) -fun Iterator.flatMap(mapper: (T) -> Iterator): Iterator = FlatMappingIterator(this, mapper) -fun Iterator.flatMap(mapper: java.util.function.Function>): Iterator = FlatMappingIterator(this, mapper::apply) +fun Iterator.filter(condition: Predicate) = FilteredIterator(this, condition) +fun Iterator.map(mapper: (T) -> R) = MappingIterator(this, mapper) +fun Iterator.map(mapper: java.util.function.Function) = MappingIterator(this, mapper::apply) +fun Iterator.flatMap(mapper: (T) -> Iterator) = FlatMappingIterator(this, mapper) +fun Iterator.flatMap(mapper: java.util.function.Function>) = FlatMappingIterator(this, mapper::apply) fun interface O2DFunction { fun apply(value: T): Double From 109de2b4144d37023cec304a615118c98a6d63c6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 3 Aug 2023 19:50:19 +0700 Subject: [PATCH 0925/1199] Add streamy iterator docs --- .../mc/otm/core/collect/StreamyIterator.kt | 66 +++++++++++++++++-- 1 file changed, 60 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt index ad729b6d7..1ca57f6a1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt @@ -14,6 +14,11 @@ import java.util.stream.Collector // Aside parallel work, unimplemented Stream API elements can be easily implemented when required +/** + * Filters elements of [parent] iterator + * + * Resulting [Iterator] is [MutableIterator] if [parent] is + */ class FilteredIterator(private val parent: Iterator, private val predicate: Predicate) : MutableIterator { private var foundValue: Any? = Companion @@ -66,13 +71,18 @@ class FilteredIterator(private val parent: Iterator, private val predicate private companion object } -class MappingIterator(private val parent: Iterator, private val transform: (T) -> R) : MutableIterator { +/** + * Maps elements of [parent] iterator from values of [T] to [R] using function [mapper] + * + * Resulting [Iterator] is [MutableIterator] if [parent] is + */ +class MappingIterator(private val parent: Iterator, private val mapper: (T) -> R) : MutableIterator { override fun hasNext(): Boolean { return parent.hasNext() } override fun next(): R { - return transform.invoke(parent.next()) + return mapper.invoke(parent.next()) } override fun remove() { @@ -80,13 +90,18 @@ class MappingIterator(private val parent: Iterator, private val transfo } } -class FlatMappingIterator(private val parent: Iterator, private val transform: (T) -> Iterator) : MutableIterator { +/** + * Maps elements of [parent] iterator from type [T] to other iterators of type [R] using function [mapper] + * + * Resulting [Iterator] is [MutableIterator] if [parent] is + */ +class FlatMappingIterator(private val parent: Iterator, private val mapper: (T) -> Iterator) : MutableIterator { private var current: Iterator? = null private var last: Iterator? = null override fun hasNext(): Boolean { while (current?.hasNext() != true && parent.hasNext()) { - current = transform.invoke(parent.next()) + current = mapper.invoke(parent.next()) } return current?.hasNext() == true @@ -107,7 +122,12 @@ class FlatMappingIterator(private val parent: Iterator, private val tra } } -class LimitingIterator(val parent: Iterator, val limit: Long) : Iterator { +/** + * Limits amount of values returned by [parent] iterator to return at most [limit] values + * + * Resulting [Iterator] is [MutableIterator] if [parent] is + */ +class LimitingIterator(private val parent: Iterator, private val limit: Long) : Iterator { init { require(limit > 0) { "Invalid limit $limit" } } @@ -126,7 +146,12 @@ class LimitingIterator(val parent: Iterator, val limit: Long) : Iterator(val parent: Iterator, skip: Long) : MutableIterator { +/** + * Skips (discards) up to [skip] values returned by [parent] iterator + * + * Resulting [Iterator] is [MutableIterator] if [parent] is + */ +class SkippingIterator(private val parent: Iterator, skip: Long) : MutableIterator { init { require(skip >= 0) { "Invalid skip amount $skip" } } @@ -162,10 +187,39 @@ class SkippingIterator(val parent: Iterator, skip: Long) : MutableIterator } } +/** + * Filters elements of [this] iterator + * + * Resulting [Iterator] is [MutableIterator] if [this] is + */ fun Iterator.filter(condition: Predicate) = FilteredIterator(this, condition) + +/** + * Maps elements of [this] iterator from values of [T] to [R] using function [mapper] + * + * Resulting [Iterator] is [MutableIterator] if [this] is + */ fun Iterator.map(mapper: (T) -> R) = MappingIterator(this, mapper) + +/** + * Maps elements of [this] iterator from values of [T] to [R] using function [mapper] + * + * Resulting [Iterator] is [MutableIterator] if [this] is + */ fun Iterator.map(mapper: java.util.function.Function) = MappingIterator(this, mapper::apply) + +/** + * Maps elements of [this] iterator from type [T] to other iterators of type [R] using function [mapper] + * + * Resulting [Iterator] is [MutableIterator] if [this] is + */ fun Iterator.flatMap(mapper: (T) -> Iterator) = FlatMappingIterator(this, mapper) + +/** + * Maps elements of [this] iterator from type [T] to other iterators of type [R] using function [mapper] + * + * Resulting [Iterator] is [MutableIterator] if [this] is + */ fun Iterator.flatMap(mapper: java.util.function.Function>) = FlatMappingIterator(this, mapper::apply) fun interface O2DFunction { From 98afdd1671b705be99266e431949fd9326ac8f8b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 3 Aug 2023 20:01:10 +0700 Subject: [PATCH 0926/1199] Don't tick side if no neighbour is present --- .../mc/otm/block/entity/MatteryBlockEntity.kt | 29 ++++++++++++---- .../block/entity/MatteryDeviceBlockEntity.kt | 34 +++++++++++++------ 2 files changed, 46 insertions(+), 17 deletions(-) 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 9c7264abe..aa24a6d06 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 @@ -101,6 +101,8 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc private val _sides = EnumMap(RelativeSide::class.java) val sides: Map = Collections.unmodifiableMap(_sides) + fun side(side: RelativeSide) = sides[side]!! + private data class SidelessCap(val cap: T, var optional: LazyOptional) private val sidelessCaps = Reference2ObjectOpenHashMap, SidelessCap<*>>() protected val tickList = TickList() @@ -203,6 +205,10 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc return SupplierList(_sides.values.map { it.track(capability)::get }) } + interface SideListener : Supplier> { + fun addListener(listener: Consumer>) + } + inner class Side(val side: RelativeSide) { init { check(!_sides.containsKey(side)) { "dafuq are you trying to do" } @@ -213,7 +219,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc private val subscriptions = Reference2ObjectOpenHashMap, SubRef<*>>() private val knownLOs = WeakHashSet>() - private inner class SubRef(value: LazyOptional) : Supplier> { + private inner class SubRef(value: LazyOptional) : SideListener { var value: LazyOptional = value set(value) { if (value !== field) { @@ -226,7 +232,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc private val listeners = ArrayList>>(0) - fun addListener(listener: Consumer>) { + override fun addListener(listener: Consumer>) { listeners.add(listener) listener.accept(value) } @@ -240,8 +246,8 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } } - fun track(capability: Capability): Supplier> { - var subref = subscriptions[capability] as Supplier>? + fun track(capability: Capability): SideListener { + var subref = subscriptions[capability] as SideListener? if (subref == null) { subref = SubRef(LazyOptional.empty()) as SubRef @@ -252,13 +258,22 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc return subref } - fun trackEnergy(): Supplier> { - return object : Supplier> { + fun trackEnergy(): SideListener { + return object : SideListener { private val regular = track(ForgeCapabilities.ENERGY) private val mekanism: SubRef? private var actualMekanism: LazyOptional? = null + private val listeners = ArrayList>>() + + override fun addListener(listener: Consumer>) { + listeners.add(listener) + listener.accept(get()) + } + init { + regular.addListener { a -> listeners.forEach { it.accept(a) } } + if (isMekanismLoaded) { mekanism = track(MatteryCapability.MEKANISM_ENERGY) as SubRef @@ -270,6 +285,8 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } else { actualMekanism = null } + + listeners.forEach { it.accept(get()) } } } else { mekanism = null diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index 3db9d7ab0..81d945102 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -130,11 +130,11 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo inner class Piece(val side: RelativeSide) : IFluidHandler, ITickable { private val ticker = tickList.Ticker(this) - private val controller = sides[side]!!.Cap(ForgeCapabilities.FLUID_HANDLER, this) - private val neighbour by sides[side]!!.track(ForgeCapabilities.FLUID_HANDLER) + private val controller = side(side).Cap(ForgeCapabilities.FLUID_HANDLER, this) + private val neighbour = side(side).track(ForgeCapabilities.FLUID_HANDLER) private fun updateTickerState() { - ticker.isEnabled = (automatePull || automatePush) && flow != FlowDirection.NONE && !redstoneControl.isBlockedByRedstone + ticker.isEnabled = (automatePull || automatePush) && flow != FlowDirection.NONE && !redstoneControl.isBlockedByRedstone && neighbour.get().isPresent } init { @@ -184,6 +184,10 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo updateTickerState() } + neighbour.addListener { + updateTickerState() + } + updateTickerState() } } @@ -192,7 +196,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo if (flow == FlowDirection.NONE || !automatePull && !automatePush || redstoneControl.isBlockedByRedstone) return - neighbour.ifPresentK { + neighbour.get().ifPresentK { if (flow.input && automatePull) { moveFluid(source = it, destination = capability) } @@ -334,7 +338,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo inner class Piece(val side: RelativeSide, val possibleModes: FlowDirection) : IMatteryEnergyStorage, ITickable { private val capControllers = exposeEnergy(side, this@Piece) - private val neighbour by sides[side]!!.trackEnergy() + private val neighbour = side(side).trackEnergy() override var batteryLevel: Decimal by energy::batteryLevel override val maxBatteryLevel: Decimal by energy::maxBatteryLevel @@ -345,7 +349,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo private val ticker = tickList.Ticker(this) private fun updateTickerState() { - ticker.isEnabled = (automatePull || automatePush) && energyFlow != FlowDirection.NONE && !redstoneControl.isBlockedByRedstone + ticker.isEnabled = (automatePull || automatePush) && energyFlow != FlowDirection.NONE && !redstoneControl.isBlockedByRedstone && neighbour.get().isPresent } // var automatePull by synchronizer.bool().property @@ -374,6 +378,10 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo updateTickerState() } + neighbour.addListener { + updateTickerState() + } + updateTickerState() } } @@ -412,7 +420,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo if (energyFlow == FlowDirection.NONE || !automatePull && !automatePush || redstoneControl.isBlockedByRedstone) return - neighbour.ifPresentK { + neighbour.get().ifPresentK { if (energyFlow.input && automatePull) { moveEnergy(source = it, destination = energy, simulate = false) } @@ -573,8 +581,8 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo updateTickerState() } - private val capController = sides[side]!!.Cap(ForgeCapabilities.ITEM_HANDLER, this) - private val neighbour by sides[side]!!.track(ForgeCapabilities.ITEM_HANDLER) + private val capController = side(side).Cap(ForgeCapabilities.ITEM_HANDLER, this) + private val neighbour = side(side).track(ForgeCapabilities.ITEM_HANDLER) private val ticker = tickList.Ticker(this) private var innerSlotPull = 0 @@ -584,7 +592,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo private var outerSlotPush = 0 private fun updateTickerState() { - ticker.isEnabled = (automatePull || automatePush) && mode != ItemHandlerMode.DISABLED && !redstoneControl.isBlockedByRedstone && currentHandler.slots != 0 + ticker.isEnabled = (automatePull || automatePush) && mode != ItemHandlerMode.DISABLED && !redstoneControl.isBlockedByRedstone && currentHandler.slots != 0 && neighbour.get().isPresent } init { @@ -655,6 +663,10 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo updateTickerState() } + neighbour.addListener { + updateTickerState() + } + updateTickerState() } } @@ -663,7 +675,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo if (mode == ItemHandlerMode.DISABLED || !automatePull && !automatePush || redstoneControl.isBlockedByRedstone || currentHandler.slots == 0) return - neighbour.ifPresentK { + neighbour.get().ifPresentK { if (it.slots == 0) return From 0073f41be6c88ee9a98436ed98b874d4ef69c5f3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 3 Aug 2023 20:05:26 +0700 Subject: [PATCH 0927/1199] ugly --- .../mc/otm/block/entity/tech/CobblerBlockEntity.kt | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt index c6f20e2d0..92fc99454 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt @@ -23,14 +23,7 @@ class CobblerBlockEntity(blockPos: BlockPos, blockState: BlockState) } val container = MatteryContainer(this::itemContainerUpdated, CONTAINER_SIZE).also(::addDroppableContainer) - - val itemHandler = container.handler(object : HandlerFilter { - override fun canInsert(slot: Int, stack: ItemStack): Boolean { - return false - } - }) - - val itemConfig = ConfigurableItemHandler(output = itemHandler) + val itemConfig = ConfigurableItemHandler(output = container.handler(HandlerFilter.OnlyOut)) init { savetable(::container, INVENTORY_KEY) From cbb79c89b6c5c9097313ef3c0f21d5511b87b551 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 3 Aug 2023 20:11:32 +0700 Subject: [PATCH 0928/1199] i had enough of CMEs out of nowhere because there is no way there should be one --- .../dbotthepony/mc/otm/capability/AbstractProfiledStorage.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/AbstractProfiledStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/AbstractProfiledStorage.kt index f1c86aa18..3d484f6d0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/AbstractProfiledStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/AbstractProfiledStorage.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.capability import com.google.common.collect.ImmutableList +import it.unimi.dsi.fastutil.objects.ObjectArrayList import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.ListTag import net.minecraft.nbt.NumericTag @@ -154,7 +155,7 @@ abstract class AbstractProfiledStorage(val parent: P) : INBTSerializable< companion object { const val HISTORY_SIZE = 20 - private val storages = ArrayList>>() + private val storages = ObjectArrayList>>() val HISTORY_WEIGHTERS: ImmutableList = ImmutableList.of( Decimal("0.313335967"), From cef79cbe36fd8757ac0951b3ddc1a9a255f9639d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 4 Aug 2023 01:43:23 +0700 Subject: [PATCH 0929/1199] Redo chemical generator config values --- .../tech/ChemicalGeneratorBlockEntity.kt | 70 ++++++------------- .../mc/otm/config/MachinesConfig.kt | 15 +++- 2 files changed, 34 insertions(+), 51 deletions(-) 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 2bf45d05b..7b359587c 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 @@ -16,6 +16,7 @@ import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.GeneratorEnergyStorage 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.* @@ -40,7 +41,7 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe val residueItemHandler = residueContainer.handler(HandlerFilter.OnlyOut) val fuelItemHandler = fuelContainer.handler(HandlerFilter.ChemicalFuel) - val energy = ProfiledEnergyStorage(GeneratorEnergyStorage(::setChangedLight, CAPACITY, THROUGHPUT)) + val energy = ProfiledEnergyStorage(GeneratorEnergyStorage(::setChangedLight, MachinesConfig.ChemicalGenerator.VALUES::energyCapacity, MachinesConfig.ChemicalGenerator.VALUES::energyThroughput)) val itemConfig = ConfigurableItemHandler( input = fuelItemHandler, @@ -59,8 +60,8 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe savetable(::residueContainer) savetable(::fuelContainer) - savetables.int(::workTicks, WORK_TICKS_KEY) - savetables.int(::workTicksTotal, WORK_TICKS_TOTAL_KEY) + savetables.int(::workTicks) + savetables.int(::workTicksTotal) } override fun setChangedLight() { @@ -81,7 +82,7 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe if (workTicks > 0) { workTicks-- - energy.receiveEnergy(GENERATION_SPEED, false) + energy.receiveEnergy(MachinesConfig.ChemicalGenerator.VALUES.energyConsumption, false) if (workTicks == 0) { workTicksTotal = 0 @@ -97,61 +98,30 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe if (workTicks == 0 && !redstoneControl.isBlockedByRedstone && checkFuelSlot) { if (!fuelContainer[0].isEmpty) { - val ticks = ForgeHooks.getBurnTime(fuelContainer[0], null) - val residue = fuelContainer[0].item.getCraftingRemainingItem(fuelContainer[0].copy().also { it.count = 1 }) - val canPutResidue = residue.isEmpty || residueContainer[0].isEmpty || ItemStack.isSameItemSameTags(residueContainer[0], residue) && residueContainer[0].count < residueContainer[0].maxStackSize + val ticks = ForgeHooks.getBurnTime(fuelContainer[0], null) / MachinesConfig.ChemicalGenerator.RATIO - if (canPutResidue && ticks >= 4 && (energy.batteryLevel < Decimal.ONE || GENERATION_SPEED * (ticks / 4) + energy.batteryLevel <= energy.maxBatteryLevel)) { - workTicksTotal = ticks / 4 - workTicks = ticks / 4 - fuelContainer[0].shrink(1) - - if (!residue.isEmpty) { - if (residueContainer[0].isEmpty) { - residueContainer[0] = residue - } else { - residueContainer[0].count++ - } - } - - fuelContainer.setChanged(0) + if ( + ticks > 0 && + (energy.batteryLevel <= Decimal.ONE || MachinesConfig.ChemicalGenerator.VALUES.energyConsumption * ticks + energy.batteryLevel <= energy.maxBatteryLevel) && + residueContainer.fullyAddItem(fuelContainer[0].item.getCraftingRemainingItem(fuelContainer[0].copyWithCount(1))) + ) { + workTicksTotal = ticks + workTicks = workTicksTotal + fuelContainer.removeItem(0, 1) } } checkFuelSlot = false } - if (energy.batteryLevel.isZero) return + if (energy.batteryLevel.isPositive) { + val item = batteryContainer[0] - val item = batteryContainer[0] - - if (!item.isEmpty) { - item.energy?.also { - moveEnergy(energy, it, THROUGHPUT, simulate = false) + if (!item.isEmpty) { + item.energy?.also { + moveEnergy(energy, it, MachinesConfig.ChemicalGenerator.VALUES.energyThroughput, simulate = false) + } } } } - - companion object { - private val THROUGHPUT get() = _THROUGHPUT.get() - private val GENERATION_SPEED get() = _GENERATION_SPEED.get() - private val CAPACITY get() = _CAPACITY.get() - - private var _THROUGHPUT: DecimalConfigValue by WriteOnce() - private var _GENERATION_SPEED: DecimalConfigValue by WriteOnce() - private var _CAPACITY: DecimalConfigValue by WriteOnce() - - fun registerConfig(builder: ForgeConfigSpec.Builder) { - builder.push(MNames.CHEMICAL_GENERATOR) - - _THROUGHPUT = builder.defineDecimal("throughput", Decimal(160), Decimal.ONE) - _GENERATION_SPEED = builder.defineDecimal("generationSpeed", Decimal(40), Decimal.ONE) - _CAPACITY = builder.defineDecimal("capacity", Decimal(24_000), Decimal.ONE) - - builder.pop() - } - - const val WORK_TICKS_KEY = "workTicks" - const val WORK_TICKS_TOTAL_KEY = "workTicksTotal" - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt index d42274729..75a167d7c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt @@ -10,7 +10,6 @@ import ru.dbotthepony.mc.otm.registry.MNames object MachinesConfig : AbstractConfig("machines") { init { AndroidStationBlockEntity.registerConfig(builder) - ChemicalGeneratorBlockEntity.registerConfig(builder) } val PLATE_PRESS = workerValues( @@ -64,6 +63,20 @@ object MachinesConfig : AbstractConfig("machines") { MatterBottler } + private val CHEMICAL_GENERATOR = workerValues( + MNames.CHEMICAL_GENERATOR, + energyStorage = Decimal(24_000), + energyThroughput = Decimal(160), + energyConsumption = Decimal(40) + ) { + ChemicalGenerator + } + + object ChemicalGenerator { + val VALUES by ::CHEMICAL_GENERATOR + val RATIO: Int by builder.comment("This amount of burn ticks result in 1 generation tick").defineInRange("RATIO", 4, 0) + } + object MatterBottler { val VALUES by ::MATTER_BOTTLER val RATE by builder.comment("Matter transferred per tick").defineDecimal("RATE", Decimal("2.0"), Decimal.ONE_TENTH) From e169012d0166ca6083dd3bf8d5a6620a9482303e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 4 Aug 2023 14:54:30 +0700 Subject: [PATCH 0930/1199] Update android station config values --- .../entity/tech/AndroidStationBlockEntity.kt | 27 ++---------------- .../screen/tech/AndroidStationScreen.kt | 9 +++--- .../mc/otm/config/AbstractConfig.kt | 4 +-- .../mc/otm/config/MachinesConfig.kt | 28 +++++++++++++------ .../mc/otm/menu/tech/AndroidStationMenu.kt | 15 +++++----- 5 files changed, 37 insertions(+), 46 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt index a7550f5ac..4a918c9b1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt @@ -16,6 +16,7 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.moveEnergy +import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.math.defineDecimal @@ -25,7 +26,6 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.core.util.WriteOnce -@Suppress("ObjectPropertyName") class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.ANDROID_STATION, p_155229_, p_155230_), MenuProvider { @@ -33,7 +33,7 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return AndroidStationMenu(containerID, inventory, this) } - val energy: ProfiledEnergyStorage = ProfiledEnergyStorage(object : WorkerEnergyStorage(this@AndroidStationBlockEntity::setChangedLight, ::CAPACITY, ::MAX_IO, { null }) { + val energy: ProfiledEnergyStorage = ProfiledEnergyStorage(object : WorkerEnergyStorage(::setChangedLight, MachinesConfig.AndroidStation.VALUES) { override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { return super.extractEnergy(howMuch, simulate).also { if (!simulate && this.batteryLevel.isZero) { @@ -92,27 +92,4 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } } - - companion object { - private var _CAPACITY: DecimalConfigValue by WriteOnce() - private var _MAX_IO: DecimalConfigValue by WriteOnce() - private var _ENERGY_PER_OPERATION: DecimalConfigValue by WriteOnce() - private var _ENERGY_PER_RESEARCH: DecimalConfigValue by WriteOnce() - - val CAPACITY get() = _CAPACITY.get() - val MAX_IO get() = _MAX_IO.get() - val ENERGY_PER_OPERATION get() = _ENERGY_PER_OPERATION.get() - val ENERGY_PER_RESEARCH get() = _ENERGY_PER_RESEARCH.get() - - fun registerConfig(builder: ForgeConfigSpec.Builder) { - builder.push(MNames.ANDROID_STATION) - - _CAPACITY = builder.defineDecimal("capacity", Decimal(100_000), Decimal.ONE) - _MAX_IO = builder.defineDecimal("throughput", Decimal.valueOf(2048), Decimal.ONE) - _ENERGY_PER_OPERATION = builder.comment("Swapping parts, etc").defineDecimal("energyPerOperation", Decimal.valueOf(2048), Decimal.ONE) - _ENERGY_PER_RESEARCH = builder.defineDecimal("energyPerResearch", Decimal.valueOf(16384), Decimal.ONE) - - builder.pop() - } - } } 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 98f54410d..e1894af55 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 @@ -32,6 +32,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.EquipmentBatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.DraggableCanvasPanel import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel +import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.menu.tech.AndroidStationMenu @@ -384,7 +385,7 @@ private class AndroidResearchButton( override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { if (button == InputConstants.MOUSE_BUTTON_LEFT && minecraft.player?.isSpectator != true) { - if (node.canResearch && !node.isResearched && (parent?.screen as AndroidStationScreen).menu.energyWidget.level >= AndroidStationBlockEntity.ENERGY_PER_RESEARCH) { + if (node.canResearch && !node.isResearched && (parent?.screen as AndroidStationScreen).menu.energyWidget.level >= MachinesConfig.AndroidStation.ENERGY_PER_RESEARCH) { if (node.type.flatBlocking.isNotEmpty()) { queryUser( TranslatableComponent("otm.android_station.research.confirm", node.type.displayName), @@ -411,7 +412,7 @@ private class AndroidResearchButton( if (isHovered) { val list = ArrayList().also { it.addAll(node.screenTooltipLines) } - val enoughPower = (parent?.screen as AndroidStationScreen).menu.energyWidget.level >= AndroidStationBlockEntity.ENERGY_PER_RESEARCH + val enoughPower = (parent?.screen as AndroidStationScreen).menu.energyWidget.level >= MachinesConfig.AndroidStation.ENERGY_PER_RESEARCH if (node.isResearched) { list.add(TranslatableComponent("otm.android_station.research.researched").withStyle(ChatFormatting.DARK_AQUA)) @@ -648,10 +649,10 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I } override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { - if (menu.energyWidget.level >= AndroidStationBlockEntity.ENERGY_PER_RESEARCH) { + if (menu.energyWidget.level >= MachinesConfig.AndroidStation.ENERGY_PER_RESEARCH) { text = POWER_OK color = RGBAColor.LIGHT_GREEN - } else if (menu.energyWidget.level >= AndroidStationBlockEntity.ENERGY_PER_OPERATION) { + } else if (menu.energyWidget.level >= MachinesConfig.AndroidStation.ENERGY_PER_OPERATION) { text = LOW_POWER_1 color = RGBAColor.DARK_RED } else { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt index aee16436d..7cf624353 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt @@ -49,7 +49,7 @@ abstract class AbstractConfig(private val configName: String, private val type: energyStorage: Decimal, energyThroughput: Decimal, workTimeMultiplier: Double? = 1.0, - energyConsumption: Decimal, + energyConsumption: Decimal?, matterCapacity: Decimal? = null, configurator: ForgeConfigSpec.Builder.() -> Unit = {} ): WorkerBalanceValues { @@ -58,7 +58,7 @@ abstract class AbstractConfig(private val configName: String, private val type: val obj = object : WorkerBalanceValues { override val energyCapacity: Decimal by builder.defineDecimal("ENERGY_CAPACITY", energyStorage, minimum = Decimal.ONE) override val energyThroughput: Decimal by builder.defineDecimal("ENERGY_THROUGHPUT", energyThroughput, minimum = Decimal.ONE) - override val energyConsumption: Decimal by builder.defineDecimal("ENERGY_CONSUMPTION", energyConsumption, minimum = Decimal.ONE) + override val energyConsumption: Decimal by (if (energyConsumption == null) GetterSetter.box(Decimal.ZERO) else builder.defineDecimal("ENERGY_CONSUMPTION", energyConsumption, minimum = Decimal.ONE)) override val matterCapacity: Decimal by (if (matterCapacity == null) GetterSetter.box(Decimal.ZERO) else builder.defineDecimal("MATTER_CAPACITY", matterCapacity, minimum = Decimal.ONE)) override val workTimeMultiplier: Double by (if (workTimeMultiplier == null) GetterSetter.box(1.0) else builder.defineInRange("WORK_TIME_MULTIPLIER", workTimeMultiplier, 0.0)) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt index 75a167d7c..6a505862e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt @@ -1,17 +1,11 @@ package ru.dbotthepony.mc.otm.config -import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity -import ru.dbotthepony.mc.otm.block.entity.tech.ChemicalGeneratorBlockEntity import ru.dbotthepony.mc.otm.capability.energy.BlockEnergyStorageImpl import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.registry.MNames object MachinesConfig : AbstractConfig("machines") { - init { - AndroidStationBlockEntity.registerConfig(builder) - } - val PLATE_PRESS = workerValues( MNames.PLATE_PRESS, energyStorage = Decimal(40_000), @@ -58,7 +52,8 @@ object MachinesConfig : AbstractConfig("machines") { energyStorage = Decimal(40_000), energyConsumption = Decimal(10), energyThroughput = Decimal(200), - matterCapacity = Decimal(400) + matterCapacity = Decimal(400), + workTimeMultiplier = null ) { MatterBottler } @@ -67,7 +62,8 @@ object MachinesConfig : AbstractConfig("machines") { MNames.CHEMICAL_GENERATOR, energyStorage = Decimal(24_000), energyThroughput = Decimal(160), - energyConsumption = Decimal(40) + energyConsumption = Decimal(40), + workTimeMultiplier = null ) { ChemicalGenerator } @@ -87,6 +83,22 @@ object MachinesConfig : AbstractConfig("machines") { val MATTER_PER_TICK by builder.defineDecimal("MATTER_PER_TICK", Decimal("0.5")) } + private val ANDROID_STATION = workerValues( + MNames.ANDROID_STATION, + energyStorage = Decimal(40_000), + energyThroughput = Decimal(8_000), + energyConsumption = null, + workTimeMultiplier = null, + ) { + AndroidStation + } + + object AndroidStation { + val VALUES by ::ANDROID_STATION + val ENERGY_PER_OPERATION by builder.comment("Swapping parts").defineDecimal("ENERGY_PER_OPERATION", Decimal(2_000), Decimal.ZERO) + val ENERGY_PER_RESEARCH by builder.comment("Researching android stuff").defineDecimal("ENERGY_PER_RESEARCH", Decimal(16_000), Decimal.ZERO) + } + private val MATTER_RECONSTRUCTOR = workerValues( MNames.MATTER_RECONSTRUCTOR, energyStorage = Decimal(100_000), diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt index e3203da1d..60caf7fcb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt @@ -10,6 +10,7 @@ import net.minecraftforge.common.capabilities.ForgeCapabilities import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput @@ -52,10 +53,10 @@ class AndroidStationMenu @JvmOverloads constructor( } override fun removeItem(p_18942_: Int, p_18943_: Int): ItemStack { - if (p_18942_ != 0 || energyWidget.level < AndroidStationBlockEntity.ENERGY_PER_OPERATION || item.isEmpty) + if (p_18942_ != 0 || energyWidget.level < MachinesConfig.AndroidStation.ENERGY_PER_OPERATION || item.isEmpty) return ItemStack.EMPTY - (tile as AndroidStationBlockEntity).energy.extractEnergy(AndroidStationBlockEntity.ENERGY_PER_OPERATION, false) + (tile as AndroidStationBlockEntity).energy.extractEnergy(MachinesConfig.AndroidStation.ENERGY_PER_OPERATION, false) return removeItemNoUpdate(p_18942_) } @@ -72,7 +73,7 @@ class AndroidStationMenu @JvmOverloads constructor( if (p_18944_ != 0) return - (tile as AndroidStationBlockEntity).energy.extractEnergy(AndroidStationBlockEntity.ENERGY_PER_OPERATION, false) + (tile as AndroidStationBlockEntity).energy.extractEnergy(MachinesConfig.AndroidStation.ENERGY_PER_OPERATION, false) item = p_18945_ } @@ -92,18 +93,18 @@ class AndroidStationMenu @JvmOverloads constructor( private inner class AndroidSlot(container: Container, private val condition: (ItemStack) -> Boolean) : MatterySlot(container, 0) { override fun mayPickup(player: Player): Boolean { if (tile is AndroidStationBlockEntity) { - return super.mayPickup(player) && tile.energy.batteryLevel >= AndroidStationBlockEntity.ENERGY_PER_OPERATION + return super.mayPickup(player) && tile.energy.batteryLevel >= MachinesConfig.AndroidStation.ENERGY_PER_OPERATION } - return super.mayPickup(player) && energyWidget.level >= AndroidStationBlockEntity.ENERGY_PER_OPERATION + return super.mayPickup(player) && energyWidget.level >= MachinesConfig.AndroidStation.ENERGY_PER_OPERATION } override fun mayPlace(itemStack: ItemStack): Boolean { if (tile is AndroidStationBlockEntity) { - return tile.energy.batteryLevel >= AndroidStationBlockEntity.ENERGY_PER_OPERATION && condition.invoke(itemStack) + return tile.energy.batteryLevel >= MachinesConfig.AndroidStation.ENERGY_PER_OPERATION && condition.invoke(itemStack) } - return energyWidget.level >= AndroidStationBlockEntity.ENERGY_PER_OPERATION && condition.invoke(itemStack) + return energyWidget.level >= MachinesConfig.AndroidStation.ENERGY_PER_OPERATION && condition.invoke(itemStack) } } From 6ab65c6c17fe5eabe607675ca5437c541b15ec35 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 4 Aug 2023 15:04:40 +0700 Subject: [PATCH 0931/1199] Update default shadow align in Label --- .../ru/dbotthepony/mc/otm/client/screen/panels/Label.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt index 68448cb6c..797f88dd3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt @@ -20,8 +20,8 @@ open class Label @JvmOverloads constructor( ) : EditablePanel(screen, parent, x, y, width, height) { constructor(screen: S, parent: EditablePanel<*>?, text: Component, shadow: Boolean = false) : this(screen, parent, x = 0f, text = text, shadow = shadow) - var shadowX = 0.75f - var shadowY = 0.75f + var shadowX = 0.25f + var shadowY = 0.25f var shadowColor = RGBAColor.BLACK init { From e83933077e933150e5cecb14b06e06a5811818e2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 4 Aug 2023 15:07:11 +0700 Subject: [PATCH 0932/1199] Cleanup --- .../mc/otm/block/entity/MatteryBlockEntity.kt | 9 --------- .../mc/otm/block/entity/MatteryDeviceBlockEntity.kt | 1 + .../otm/block/entity/decorative/CargoCrateBlockEntity.kt | 3 ++- 3 files changed, 3 insertions(+), 10 deletions(-) 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 aa24a6d06..1fac08b2b 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 @@ -196,15 +196,6 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } } - protected fun exposeItemsGlobally(value: IItemHandler) { - exposeGlobally(ForgeCapabilities.ITEM_HANDLER, value) - } - - @Suppress("SuspiciousCallableReferenceInLambda") - protected fun trackGlobally(capability: Capability): List> { - return SupplierList(_sides.values.map { it.track(capability)::get }) - } - interface SideListener : Supplier> { fun addListener(listener: Consumer>) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index 81d945102..de41cc61a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -39,6 +39,7 @@ import ru.dbotthepony.mc.otm.once /** * Device block entity base, implementing [MenuProvider] and [IRedstoneControlled], and also tracks custom display name */ +@Suppress("LiftReturnOrAssignment") abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blockPos: BlockPos, blockState: BlockState) : MatteryBlockEntity(blockEntityType, blockPos, blockState), MenuProvider, IRedstoneControlled { var customDisplayName: Component? = null diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt index 636a47b1c..f09d23fa8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt @@ -25,6 +25,7 @@ import net.minecraft.world.level.storage.loot.LootParams import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets import net.minecraft.world.level.storage.loot.parameters.LootContextParams import net.minecraft.world.phys.Vec3 +import net.minecraftforge.common.capabilities.ForgeCapabilities import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.container.MatteryContainer @@ -85,7 +86,7 @@ class CargoCrateBlockEntity( } init { - exposeItemsGlobally(handler) + exposeGlobally(ForgeCapabilities.ITEM_HANDLER, handler) savetablesLevel.stateful(::container, INVENTORY_KEY) } From 7662c21f4492f56f9979415399fc62ee1f977ac9 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 4 Aug 2023 15:45:47 +0700 Subject: [PATCH 0933/1199] Fix false negative assertions --- .../ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt index 5ef60f372..86fd7f0df 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt @@ -165,7 +165,7 @@ abstract class MatteryNetworkChannel(val version: String, val name: String) { internal fun onServerStarting() { interrupt = false - check(thread == null) { "Already having network dispatcher thread, ServerStartingEvent was fired twice!" } + check(thread?.isAlive != true) { "Already having network dispatcher thread, ServerStartingEvent was fired twice!" } thread = Thread(this::run, "Overdrive That Matters Network Dispatcher").also { it.isDaemon = true; it.start() } } From f27f21e3de29f192a752cbcc7a534a0084504430 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 4 Aug 2023 22:50:59 +0700 Subject: [PATCH 0934/1199] Make Exopack slot changes trigger advancements, and optimize them --- .../mixin/InventoryChangeTriggerMixin.java | 22 ++ .../mixin/SimpleCriterionTriggerMixin.java | 54 ++++ .../otm/capability/MatteryPlayerCapability.kt | 27 +- .../mc/otm/container/CombinedContainer.kt | 11 + .../mc/otm/container/MatteryContainer.kt | 44 ++- .../mc/otm/core/collect/StreamyIterator.kt | 7 + .../triggers/MatteryInventoryChangeTrigger.kt | 269 ++++++++++++++++++ .../resources/META-INF/accesstransformer.cfg | 17 ++ .../overdrive_that_matters.mixins.json | 2 + 9 files changed, 440 insertions(+), 13 deletions(-) create mode 100644 src/main/java/ru/dbotthepony/mc/otm/mixin/InventoryChangeTriggerMixin.java create mode 100644 src/main/java/ru/dbotthepony/mc/otm/mixin/SimpleCriterionTriggerMixin.java create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MatteryInventoryChangeTrigger.kt diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/InventoryChangeTriggerMixin.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/InventoryChangeTriggerMixin.java new file mode 100644 index 000000000..6aea160bd --- /dev/null +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/InventoryChangeTriggerMixin.java @@ -0,0 +1,22 @@ +package ru.dbotthepony.mc.otm.mixin; + +import net.minecraft.advancements.critereon.InventoryChangeTrigger; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import ru.dbotthepony.mc.otm.triggers.MatteryInventoryChangeTrigger; + +@Mixin(InventoryChangeTrigger.class) +public abstract class InventoryChangeTriggerMixin { + @Overwrite + public void trigger(ServerPlayer p_43150_, Inventory p_43151_, ItemStack p_43152_) { + MatteryInventoryChangeTrigger.INSTANCE.trigger(p_43150_, p_43151_, p_43152_); + } + + @Overwrite + private void trigger(ServerPlayer p_43154_, Inventory p_43155_, ItemStack p_43156_, int p_43157_, int p_43158_, int p_43159_) { + MatteryInventoryChangeTrigger.INSTANCE.trigger(p_43154_, p_43155_, p_43156_, p_43157_, p_43158_, p_43159_); + } +} diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/SimpleCriterionTriggerMixin.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/SimpleCriterionTriggerMixin.java new file mode 100644 index 000000000..d5d3e701f --- /dev/null +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/SimpleCriterionTriggerMixin.java @@ -0,0 +1,54 @@ +package ru.dbotthepony.mc.otm.mixin; + +import net.minecraft.advancements.CriterionTrigger; +import net.minecraft.advancements.CriterionTriggerInstance; +import net.minecraft.advancements.critereon.InventoryChangeTrigger; +import net.minecraft.advancements.critereon.SimpleCriterionTrigger; +import net.minecraft.server.PlayerAdvancements; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import ru.dbotthepony.mc.otm.triggers.MatteryInventoryChangeTrigger; + +// i tried to mixin into InventoryChangeTrigger with extends SimpleCriterionTrigger and @Overwrite+@Override +// while also defining SimpleCriterionTrigger methods non final in accesstransfoer +// it didn't work. +@Mixin(SimpleCriterionTrigger.class) +public abstract class SimpleCriterionTriggerMixin implements CriterionTrigger { + @Inject( + method = "removePlayerListener(Lnet/minecraft/server/PlayerAdvancements;Lnet/minecraft/advancements/CriterionTrigger$Listener;)V", + at = @At("HEAD"), + cancellable = true + ) + public void removePlayerListener(PlayerAdvancements p_66254_, CriterionTrigger.Listener p_66255_, CallbackInfo info) { + if (((Object) this) instanceof InventoryChangeTrigger) { + MatteryInventoryChangeTrigger.INSTANCE.removePlayerListener(p_66254_, p_66255_); + info.cancel(); + } + } + + @Inject( + method = "addPlayerListener(Lnet/minecraft/server/PlayerAdvancements;Lnet/minecraft/advancements/CriterionTrigger$Listener;)V", + at = @At("HEAD"), + cancellable = true + ) + public void addPlayerListener(PlayerAdvancements p_66254_, CriterionTrigger.Listener p_66255_, CallbackInfo info) { + if (((Object) this) instanceof InventoryChangeTrigger) { + MatteryInventoryChangeTrigger.INSTANCE.addPlayerListener(p_66254_, p_66255_); + info.cancel(); + } + } + + @Inject( + method = "removePlayerListeners(Lnet/minecraft/server/PlayerAdvancements;)V", + at = @At("HEAD"), + cancellable = true + ) + public void removePlayerListeners(PlayerAdvancements p_66254_, CallbackInfo info) { + if (((Object) this) instanceof InventoryChangeTrigger) { + MatteryInventoryChangeTrigger.INSTANCE.removePlayerListeners(p_66254_); + info.cancel(); + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 8d8431c6d..51c08d53c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -79,6 +79,7 @@ import ru.dbotthepony.mc.otm.capability.energy.receiveEnergyExact import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.config.ExopackConfig +import ru.dbotthepony.mc.otm.container.CombinedContainer import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.get import ru.dbotthepony.mc.otm.container.iterator @@ -122,6 +123,7 @@ import ru.dbotthepony.mc.otm.triggers.ExopackGainedEnderAccessTrigger import ru.dbotthepony.mc.otm.triggers.ExopackGainedSmeltingTrigger import ru.dbotthepony.mc.otm.triggers.ExopackObtainedTrigger import ru.dbotthepony.mc.otm.triggers.ExopackSlotsExpandedTrigger +import ru.dbotthepony.mc.otm.triggers.MatteryInventoryChangeTrigger import java.util.* import java.util.stream.Stream import kotlin.collections.ArrayDeque @@ -170,12 +172,13 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial private inner class PlayerMatteryContainer(size: Int) : MatteryContainer(size) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { - super.setChanged(slot, new, old) - // TODO: Minecraft has hard-coded inventory triggers to Inventory class - // when nothing use Inventory class directly. + if (ply is ServerPlayer) { + val item = new.copy() - // Why? - // CriteriaTriggers.INVENTORY_CHANGED.trigger(this, this.getInventory(), p_143468_) + tickList.once { + MatteryInventoryChangeTrigger.trigger(ply, combinedInventory, item) + } + } } } @@ -300,6 +303,18 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial value.deserializeNBT(field.serializeNBT()) value.addFilterSynchronizer(synchronizer) field = value + + _combinedInventory = CombinedContainer(ply.inventory, exopackContainer) + } + + private var _combinedInventory: CombinedContainer? = null + + val combinedInventory: CombinedContainer + get() { + if (_combinedInventory == null) + _combinedInventory = CombinedContainer(ply.inventory, exopackContainer) + + return _combinedInventory!! } /** @@ -1065,6 +1080,8 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial ticksIExist++ + tickList.tick() + if (willBecomeAndroid) { if (ply.isSleeping && ply.sleepTimer > SLEEP_TICKS_LIMIT) { becomeAndroid() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/CombinedContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/CombinedContainer.kt index c37b8e51a..90c253d10 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/CombinedContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/CombinedContainer.kt @@ -12,6 +12,10 @@ import net.minecraft.world.Container import net.minecraft.world.entity.player.Player import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.core.GetterSetter +import ru.dbotthepony.mc.otm.core.collect.filter +import ru.dbotthepony.mc.otm.core.collect.flatMap +import ru.dbotthepony.mc.otm.core.collect.map +import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.core.stream import java.util.LinkedList import java.util.stream.Stream @@ -162,6 +166,13 @@ class CombinedContainer(containers: Stream>>) : Co return true } + fun optimizedIterator(): Iterator { + return listOf( + fullCoverage.iterator().flatMap { it.iterator() }, + notFullCoverage.values.iterator().flatMap { it.iterator() }.map { it.item }.filter { it.isNotEmpty } + ).iterator().flatMap { it } + } + class Builder { private var built = false private val values = LinkedList>>() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt index e03d238fd..95d1624d8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt @@ -47,6 +47,9 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I private val nonEmptyFlags = BitSet() private var nonEmptyIndices = IntArrayList() private var indicesReferenced = false + private data class Update(val slot: Int, val new: ItemStack, val old: ItemStack) + private val queuedUpdates = ArrayList() + private var queueUpdates = false private fun cowIndices() { if (indicesReferenced) { @@ -224,6 +227,22 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I } } + private fun internalSetChanged(slot: Int, new: ItemStack, old: ItemStack) { + if (queueUpdates) { + queuedUpdates.add(Update(slot, new, old)) + } else { + setChanged(slot, new, old) + } + } + + private fun runUpdates() { + for ((slot, new, old) in queuedUpdates) { + setChanged(slot, new, old) + } + + queuedUpdates.clear() + } + protected open fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { watcher.run() } @@ -297,7 +316,7 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I slotStack.count = newCount trackedSlots[slot] = slotStack.copy() changeset++ - setChanged(slot, slotStack, old) + internalSetChanged(slot, slotStack, old) if (popTime != null) { slotStack.popTime = popTime @@ -326,7 +345,7 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I trackedSlots[slot] = copyToPut.copy() updateEmptyFlag(slot) changeset++ - setChanged(slot, copyToPut, ItemStack.EMPTY) + internalSetChanged(slot, copyToPut, ItemStack.EMPTY) if (popTime != null) { copyToPut.popTime = popTime @@ -430,7 +449,7 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I trackedSlots[slot] = slots[slot].copy() changeset++ updateEmptyFlag(slot) - setChanged(slot, if (slots[slot].isEmpty) ItemStack.EMPTY else slots[slot], old) + internalSetChanged(slot, if (slots[slot].isEmpty) ItemStack.EMPTY else slots[slot], old) return split } @@ -458,12 +477,21 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I updateEmptyFlag(slot) changeset++ - setChanged(slot, stack, old) + internalSetChanged(slot, stack, old) } final override fun setChanged() { - for (slot in 0 until size) { - setChanged(slot) + queueUpdates = true + + try { + for (slot in 0 until size) { + setChanged(slot) + } + + runUpdates() + } finally { + queuedUpdates.clear() + queueUpdates = false } } @@ -472,7 +500,7 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I trackedSlots[slot] = slots[slot].copy() updateEmptyFlag(slot) changeset++ - setChanged(slot, slots[slot], trackedSlots[slot]) + internalSetChanged(slot, slots[slot], trackedSlots[slot]) // mojang соси))0)0))0)))))0) } } @@ -507,7 +535,7 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I if (!slots[slot].isEmpty) { val old = slots[slot] slots[slot] = ItemStack.EMPTY - setChanged(slot, ItemStack.EMPTY, old) + internalSetChanged(slot, ItemStack.EMPTY, old) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt index 1ca57f6a1..b098fa0c5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.core.collect +import ru.dbotthepony.mc.otm.core.addAll import java.util.Optional import java.util.function.BinaryOperator import java.util.function.Predicate @@ -348,6 +349,12 @@ fun Iterator.collect(collector: Collector): R { return collector.finisher().apply(instance) } +fun Iterator.toList(): List { + val result = ArrayList() + result.addAll(this) + return result +} + fun Iterator.findFirst(): Optional { if (hasNext()) { return Optional.of(next()) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MatteryInventoryChangeTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MatteryInventoryChangeTrigger.kt new file mode 100644 index 000000000..fa03d8913 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MatteryInventoryChangeTrigger.kt @@ -0,0 +1,269 @@ +package ru.dbotthepony.mc.otm.triggers + +import com.google.gson.JsonObject +import it.unimi.dsi.fastutil.Hash.Strategy +import it.unimi.dsi.fastutil.objects.Object2ObjectFunction +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap +import it.unimi.dsi.fastutil.objects.ObjectArrayList +import it.unimi.dsi.fastutil.objects.ObjectArraySet +import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet +import it.unimi.dsi.fastutil.objects.Reference2ObjectFunction +import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap +import net.minecraft.advancements.CriteriaTriggers +import net.minecraft.advancements.CriterionTrigger +import net.minecraft.advancements.critereon.DeserializationContext +import net.minecraft.advancements.critereon.InventoryChangeTrigger +import net.minecraft.advancements.critereon.MinMaxBounds +import net.minecraft.resources.ResourceLocation +import net.minecraft.server.PlayerAdvancements +import net.minecraft.server.level.ServerPlayer +import net.minecraft.world.Container +import net.minecraft.world.entity.player.Inventory +import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.container.CombinedContainer +import ru.dbotthepony.mc.otm.container.get +import ru.dbotthepony.mc.otm.container.iterator +import ru.dbotthepony.mc.otm.core.collect.flatMap +import ru.dbotthepony.mc.otm.core.collect.toList +import ru.dbotthepony.mc.otm.core.isNotEmpty +import java.util.stream.Collectors + +/** + * This object detours all necessary InventoryChangeTrigger methods + * + * Reason behind this is to support arbitrary containers (not just [Inventory], done for Exopack) and to improve performance by using search tree + */ +object MatteryInventoryChangeTrigger : CriterionTrigger { + private object BoundsStrategy : Strategy { + override fun equals(a: MinMaxBounds.Ints?, b: MinMaxBounds.Ints?): Boolean { + return a?.min == b?.min && a?.max == b?.max + } + + override fun hashCode(o: MinMaxBounds.Ints?): Int { + return o?.let { Integer.rotateLeft(it.min.hashCode(), 16) xor it.max.hashCode() } ?: 0 + } + } + + private object DefaultStrategy : Strategy { + override fun equals(a: Any?, b: Any?): Boolean { + return a == b + } + + override fun hashCode(o: Any?): Int { + return o.hashCode() + } + } + + private fun interface Tester { + fun test(value: T, inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int): Boolean + } + + private fun interface Hint { + fun getHints(inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int): Collection? + } + + private class Node( + val strategy: Strategy, + private val getter: InventoryChangeTrigger.TriggerInstance.() -> Collection, + val test: Tester, + val hint: Hint? = null + ) { + fun getValues(instance: InventoryChangeTrigger.TriggerInstance): Set { + val result = ObjectArraySet() + result.addAll(getter.invoke(instance)) + return result + } + } + + private val nodes = ArrayList>() + + init { + nodes.add(Node(BoundsStrategy, { listOf(slotsOccupied) }, { v, inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> v.matches(slotsOccupied) })) + nodes.add(Node(BoundsStrategy, { listOf(slotsFull) }, { v, inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> v.matches(slotsFull) })) + nodes.add(Node(BoundsStrategy, { listOf(slotsEmpty) }, { v, inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> v.matches(slotsEmpty) })) + + nodes.add(Node( + DefaultStrategy, + { predicates.iterator().flatMap { (it.items ?: listOf(null)).iterator() }.toList() }, + { v, inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> v == null || item.item == v }, + { inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> mutableListOf(item.item) })) + + nodes.add(Node( + DefaultStrategy, + { predicates.map { it.tag } }, + { v, inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> v == null || item.`is`(v) }, + { inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> item.tags.collect(Collectors.toCollection(::ArrayList)) })) + + nodes.add(Node(BoundsStrategy, { predicates.map { it.count } }, { v, inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> v.matches(item.count) })) + + nodes.add(Node( + BoundsStrategy, + { predicates.map { it.durability } }, + { v, inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> v.isAny || item.isDamageableItem && v.matches(item.maxDamage - item.damageValue) })) + } + + private class ListenerTree(private val advancements: PlayerAdvancements) { + private val set = ObjectOpenHashSet>() + private val tree = Object2ObjectOpenCustomHashMap(nodes.first().strategy as Strategy) + + private fun search(instance: InventoryChangeTrigger.TriggerInstance, tree: MutableMap, nodeId: Int): Collection>> { + val node = nodes[nodeId] + + if (nodeId + 1 != nodes.size) { + val result = ArrayList>>() + + for (v in node.getValues(instance)) { + result.addAll( + search( + instance, + tree.computeIfAbsent(v, Object2ObjectFunction { Object2ObjectOpenCustomHashMap(nodes[nodeId + 1].strategy as Strategy) }) as MutableMap, + nodeId + 1)) + } + + return result + } else { + val result = ArrayList>>() + + for (v in node.getValues(instance)) { + result.add(tree.computeIfAbsent(v, Object2ObjectFunction { ObjectOpenHashSet>() }) as MutableSet>) + } + + return result + } + } + + fun add(listener: CriterionTrigger.Listener) { + if (set.add(listener)) { + search(listener.triggerInstance, tree, 0).forEach { it.add(listener) } + } + } + + fun remove(listener: CriterionTrigger.Listener) { + if (set.remove(listener)) { + search(listener.triggerInstance, tree, 0).forEach { it.remove(listener) } + } + } + + private fun addNull(input: Collection): Collection { + return if (null in input) + input + else if (input is ArrayList) { + input.add(null) + input + } else { + ArrayList(input).also { it.add(null) } + } + } + + private fun trigger(inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int, tree: MutableMap, nodeId: Int, set: MutableSet>) { + val node = nodes[nodeId] as Node + val keys = node.hint?.getHints(inventory, item, slotsFull, slotsEmpty, slotsOccupied)?.let(::addNull) ?: tree.keys + + for (k in keys) { + val v = tree[k] ?: continue + + if (node.test.test(k, inventory, item, slotsFull, slotsEmpty, slotsOccupied)) { + if (nodeId + 1 == nodes.size) { + for (l in v as Set>) { + // переделываем matches у InventoryTriggerInstance + with (l.triggerInstance) { + if ( + this.slotsFull.matches(slotsFull) && + this.slotsEmpty.matches(slotsEmpty) && + this.slotsOccupied.matches(slotsOccupied) + ) { + if (this.predicates.isEmpty() || this.predicates.size == 1 && item.isNotEmpty && this.predicates[0].matches(item)) { + set.add(l) + } else if (this.predicates.size > 1) { + val unsatisfied = ObjectArrayList(this.predicates) + unsatisfied.removeIf { it.matches(ItemStack.EMPTY) } + val iterator = if (inventory is CombinedContainer) inventory.optimizedIterator() else inventory.iterator() + + for (inventoryItem in iterator) { + unsatisfied.removeIf { it.matches(inventoryItem) } + if (unsatisfied.isEmpty) break + } + + if (unsatisfied.isEmpty) { + set.add(l) + } + } + } + } + } + } else { + trigger(inventory, item, slotsFull, slotsEmpty, slotsOccupied, v as MutableMap, nodeId + 1, set) + } + } + } + } + + fun trigger(inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int) { + val matches = ObjectOpenHashSet>() + + trigger(inventory, item, slotsFull, slotsEmpty, slotsOccupied, tree, 0, matches) + + for (l in matches) { + l.run(advancements) + } + } + } + + private val listeners = Reference2ObjectOpenHashMap() + + override fun getId(): ResourceLocation { + return CriteriaTriggers.INVENTORY_CHANGED.id + } + + override fun addPlayerListener(advancements: PlayerAdvancements, instance: CriterionTrigger.Listener) { + listeners.computeIfAbsent(advancements, Reference2ObjectFunction { ListenerTree(it as PlayerAdvancements) }).add(instance) + } + + override fun removePlayerListener(advancements: PlayerAdvancements, instance: CriterionTrigger.Listener) { + listeners[advancements]?.remove(instance) + } + + override fun removePlayerListeners(advancements: PlayerAdvancements) { + listeners.remove(advancements) + } + + override fun createInstance(data: JsonObject, context: DeserializationContext): InventoryChangeTrigger.TriggerInstance { + return CriteriaTriggers.INVENTORY_CHANGED.createInstance(data, context) + } + + // реплицирует ванильный метод + fun trigger(player: ServerPlayer, inventory: Container, item: ItemStack) { + if (inventory === player.inventory) { + val mattery = player.matteryPlayer + + if (mattery != null) { + return trigger(player, mattery.combinedInventory, item) + } + } + + var slotsFull = 0 + var slotsEmpty = 0 + var slotsOccupied = 0 + + for (slot in 0 until inventory.containerSize) { + val slotItem = inventory[slot] + + if (slotItem.isEmpty) + slotsEmpty++ + else { + slotsOccupied++ + + if (slotItem.count >= inventory.maxStackSize) + slotsFull++ + } + } + + trigger(player, inventory, item, slotsFull, slotsEmpty, slotsOccupied) + } + + // реплицирует ванильный метод + fun trigger(player: ServerPlayer, inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int) { + listeners[player.advancements]?.trigger(inventory, item, slotsFull, slotsEmpty, slotsOccupied) + } +} diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 94ab2eea8..c7b31cf87 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -186,3 +186,20 @@ public net.minecraft.world.item.crafting.RecipeManager m_44054_(Lnet/minecraft/w public net.minecraft.world.entity.boss.wither.WitherBoss f_31432_ # TARGETING_CONDITIONS public-f net.minecraft.world.entity.boss.wither.WitherBoss f_31431_ # LIVING_ENTITY_SELECTOR public net.minecraft.world.entity.ai.targeting.TargetingConditions f_26879_ # selector + +public net.minecraft.advancements.critereon.InventoryChangeTrigger$TriggerInstance f_43179_ +public net.minecraft.advancements.critereon.InventoryChangeTrigger$TriggerInstance f_43178_ +public net.minecraft.advancements.critereon.InventoryChangeTrigger$TriggerInstance f_43177_ +public net.minecraft.advancements.critereon.InventoryChangeTrigger$TriggerInstance f_43176_ +#public-f net.minecraft.advancements.critereon.SimpleCriterionTrigger m_6467_(Lnet/minecraft/server/PlayerAdvancements;Lnet/minecraft/advancements/CriterionTrigger$Listener;)V # addPlayerListener +#public-f net.minecraft.advancements.critereon.SimpleCriterionTrigger m_6468_(Lnet/minecraft/server/PlayerAdvancements;Lnet/minecraft/advancements/CriterionTrigger$Listener;)V # removePlayerListener +#public-f net.minecraft.advancements.critereon.SimpleCriterionTrigger m_5656_(Lnet/minecraft/server/PlayerAdvancements;)V # removePlayerListeners + +public net.minecraft.advancements.critereon.ItemPredicate f_45031_ +public net.minecraft.advancements.critereon.ItemPredicate f_45032_ +public net.minecraft.advancements.critereon.ItemPredicate f_45033_ +public net.minecraft.advancements.critereon.ItemPredicate f_151427_ +public net.minecraft.advancements.critereon.ItemPredicate f_45036_ +public net.minecraft.advancements.critereon.ItemPredicate f_45035_ +public net.minecraft.advancements.critereon.ItemPredicate f_45034_ +public net.minecraft.advancements.critereon.ItemPredicate f_45029_ diff --git a/src/main/resources/overdrive_that_matters.mixins.json b/src/main/resources/overdrive_that_matters.mixins.json index 3d4d5f070..cc4920e9d 100644 --- a/src/main/resources/overdrive_that_matters.mixins.json +++ b/src/main/resources/overdrive_that_matters.mixins.json @@ -13,6 +13,8 @@ "MixinAnvilBlock", "MixinInventory", "MixinAbstractHurtingProjectile", + "SimpleCriterionTriggerMixin", + "InventoryChangeTriggerMixin", "MixinPlayer" ], "client": [ From c3ed7f9556ce7319b68cbcf08b6aed6be9784ac2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 4 Aug 2023 22:52:11 +0700 Subject: [PATCH 0935/1199] Unneeded cast --- .../mc/otm/android/feature/EnderTeleporterFeature.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt index aa8778995..30d4268dc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt @@ -400,7 +400,7 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv val server = NULLABLE_MINECRAFT_SERVER ?: return if (android.isAndroid && event.source.isFall) { - val feature = android.getFeature(AndroidFeatures.ENDER_TELEPORTER) as EnderTeleporterFeature? ?: return + val feature = android.getFeature(AndroidFeatures.ENDER_TELEPORTER) ?: return if (server.tickCount - feature.lastTeleport <= 120) { EnderTeleporterFallDeathTrigger.trigger(event.entity as ServerPlayer) From 5c3f0e54c1942af12dc4ae4dce37b547aafe1d00 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 4 Aug 2023 22:59:20 +0700 Subject: [PATCH 0936/1199] Final cleanups regarding energy balance values --- .../entity/matter/MatterBottlerBlockEntity.kt | 2 +- .../entity/storage/DriveRackBlockEntity.kt | 2 +- .../entity/storage/DriveViewerBlockEntity.kt | 2 +- .../entity/storage/ItemMonitorBlockEntity.kt | 2 +- .../StoragePowerSupplierBlockEntity.kt | 2 +- .../energy/BlockEnergyStorageImpl.kt | 101 +----------------- .../mc/otm/config/MachinesConfig.kt | 12 +-- 7 files changed, 16 insertions(+), 107 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index 82c8941a5..d1d3a52db 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -34,7 +34,7 @@ import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode class MatterBottlerBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.MATTER_BOTTLER, blockPos, blockState) { - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this, MachinesConfig.MatterBottler.VALUES)) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::setChangedLight, MachinesConfig.MatterBottler.VALUES)) val energyConfig = ConfigurableEnergy(energy) private inner class Container : MatteryContainer(3) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt index 8f8405bab..ab72fdbbc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt @@ -21,7 +21,7 @@ import ru.dbotthepony.mc.otm.storage.* class DriveRackBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.DRIVE_RACK, p_155229_, p_155230_) { - val energy = WorkerEnergyStorage(this, MachinesConfig.DRIVE_RACK) + val energy = WorkerEnergyStorage(this::setChangedLight, MachinesConfig.DRIVE_RACK) val container: MatteryContainer = object : MatteryContainer(this::setChanged, 4) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt index d442b950c..62e7060dc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt @@ -40,7 +40,7 @@ class DriveViewerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte } } - val energy = WorkerEnergyStorage(this, MachinesConfig.DRIVE_VIEWER) + val energy = WorkerEnergyStorage(this::setChangedLight, MachinesConfig.DRIVE_VIEWER) val container: MatteryContainer = object : MatteryContainer(this::setChanged, 1) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { 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 e8b9d2813..7934932b4 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 @@ -179,7 +179,7 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.ITEM_MONITOR, p_155229_, p_155230_), IStorageEventConsumer { - val energy = WorkerEnergyStorage(this, MachinesConfig.ITEM_MONITOR) + val energy = WorkerEnergyStorage(this::setChangedLight, MachinesConfig.ITEM_MONITOR) init { exposeEnergyGlobally(energy) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt index 3545cbbb0..64f4fdc01 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt @@ -22,7 +22,7 @@ class StoragePowerSupplierBlockEntity(blockPos: BlockPos, blockState: BlockState } val cell = StorageNode() - val energy = WorkerEnergyStorage(this, MachinesConfig.STORAGE_POWER_SUPPLIER) + val energy = WorkerEnergyStorage(this::setChangedLight, MachinesConfig.STORAGE_POWER_SUPPLIER) init { savetable(::energy, ENERGY_KEY) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt index d86e4dd58..150977628 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt @@ -29,14 +29,6 @@ sealed class BlockEnergyStorageImpl( private val maxInputProvider: () -> Decimal?, private val maxOutputProvider: () -> Decimal?, ) : IMatteryEnergyStorage, INBTSerializable, IEnergyStorageImpl { - constructor( - listener: () -> Unit, - direction: FlowDirection, - maxBatteryLevel: Decimal, - maxInput: Decimal?, - maxOutput: Decimal?, - ) : this(listener, direction, { maxBatteryLevel }, { maxInput }, { maxOutput }) - private var maxInputStorage: Decimal? = null private var maxOutputStorage: Decimal? = null private var maxBatteryLevelStorage: Decimal? = null @@ -157,30 +149,13 @@ sealed class BlockEnergyStorageImpl( } companion object { - val DEFAULT_MAX_IO = Decimal(200) - val DEFAULT_MAX_CAPACITY = Decimal(60_000) + val DEFAULT_MAX_IO = Decimal(400) + val DEFAULT_MAX_CAPACITY = Decimal(40_000) const val ENERGY_STORED_KEY = "energy_stored" const val ENERGY_STORED_MAX_KEY = "energy_stored_max" const val MAX_INPUT_KEY = "max_input" const val MAX_OUTPUT_KEY = "max_output" - - fun makeConfigEntry(builder: ForgeConfigSpec.Builder, name: String? = null, capacity: Decimal = DEFAULT_MAX_CAPACITY, throughput: Decimal = DEFAULT_MAX_IO, configurator: ForgeConfigSpec.Builder.() -> Unit = {}): EnergyBalanceValues { - if (name != null) - builder.push(name) - - val obj = object : EnergyBalanceValues { - override val energyCapacity: Decimal by builder.defineDecimal("capacity", capacity, Decimal.ONE) - override val energyThroughput: Decimal by builder.defineDecimal("throughput", throughput, Decimal.ONE) - } - - configurator.invoke(builder) - - if (name != null) - builder.pop() - - return obj - } } } @@ -190,42 +165,20 @@ open class WorkerEnergyStorage( maxInput: () -> Decimal? = { DEFAULT_MAX_IO }, maxOutput: () -> Decimal? = maxInput ) : BlockEnergyStorageImpl(listener, FlowDirection.INPUT, maxBatteryLevel, maxInput, maxOutput) { - constructor( - listener: () -> Unit, - maxBatteryLevel: Decimal = DEFAULT_MAX_CAPACITY, - maxInput: Decimal? = DEFAULT_MAX_IO, - maxOutput: Decimal? = maxInput) : this(listener, { maxBatteryLevel }, { maxInput }, { maxOutput }) - constructor( listener: () -> Unit, values: EnergyBalanceValues ) : this(listener, values::energyCapacity, values::energyThroughput, values::energyThroughput) - constructor( - listener: BlockEntity, - values: EnergyBalanceValues - ) : this(listener::setChanged, values::energyCapacity, values::energyThroughput, values::energyThroughput) - constructor( listener: () -> Unit, values: VerboseEnergyBalanceValues ) : this(listener, values::energyCapacity, values::maxEnergyReceive, values::maxEnergyExtract) - constructor( - listener: BlockEntity, - values: VerboseEnergyBalanceValues - ) : this(listener::setChanged, values::energyCapacity, values::maxEnergyReceive, values::maxEnergyExtract) - - constructor( - listener: BlockEntity, - maxBatteryLevel: Decimal = DEFAULT_MAX_CAPACITY, - maxInput: Decimal? = DEFAULT_MAX_IO, - maxOutput: Decimal? = maxInput) : this(listener::setChanged, maxBatteryLevel, maxInput, maxOutput) - companion object { fun appendHoverText(itemStack: ItemStack, tooltips: MutableList) { val tag = (itemStack.tag?.get(BlockItem.BLOCK_ENTITY_TAG) as? CompoundTag)?.get(MatteryBlockEntity.ENERGY_KEY) as? CompoundTag ?: return - val cap = WorkerEnergyStorage({}, DEFAULT_MAX_CAPACITY) + val cap = WorkerEnergyStorage({}, { DEFAULT_MAX_CAPACITY }) cap.deserializeNBT(tag) batteryLevel(cap, tooltips, false) } @@ -242,42 +195,20 @@ open class GeneratorEnergyStorage( maxInput: () -> Decimal? = { DEFAULT_MAX_IO }, maxOutput: () -> Decimal? = maxInput ) : BlockEnergyStorageImpl(listener, FlowDirection.OUTPUT, maxBatteryLevel, maxInput, maxOutput) { - constructor( - listener: () -> Unit, - maxBatteryLevel: Decimal = DEFAULT_MAX_CAPACITY, - maxInput: Decimal? = DEFAULT_MAX_IO, - maxOutput: Decimal? = maxInput) : this(listener, { maxBatteryLevel }, { maxInput }, { maxOutput }) - constructor( listener: () -> Unit, values: EnergyBalanceValues ) : this(listener, values::energyCapacity, values::energyThroughput, values::energyThroughput) - constructor( - listener: BlockEntity, - values: EnergyBalanceValues - ) : this(listener::setChanged, values::energyCapacity, values::energyThroughput, values::energyThroughput) - constructor( listener: () -> Unit, values: VerboseEnergyBalanceValues ) : this(listener, values::energyCapacity, values::maxEnergyReceive, values::maxEnergyExtract) - constructor( - listener: BlockEntity, - values: VerboseEnergyBalanceValues - ) : this(listener::setChanged, values::energyCapacity, values::maxEnergyReceive, values::maxEnergyExtract) - - constructor( - listener: BlockEntity, - maxBatteryLevel: Decimal = DEFAULT_MAX_CAPACITY, - maxInput: Decimal? = DEFAULT_MAX_IO, - maxOutput: Decimal? = maxInput) : this(listener::setChanged, maxBatteryLevel, maxInput, maxOutput) - companion object { fun appendHoverText(itemStack: ItemStack, tooltips: MutableList) { val tag = (itemStack.tag?.get(BlockItem.BLOCK_ENTITY_TAG) as? CompoundTag)?.get(MatteryBlockEntity.ENERGY_KEY) as? CompoundTag ?: return - val cap = GeneratorEnergyStorage({}, DEFAULT_MAX_CAPACITY) + val cap = GeneratorEnergyStorage({}, { DEFAULT_MAX_CAPACITY }) cap.deserializeNBT(tag) batteryLevel(cap, tooltips) } @@ -294,42 +225,20 @@ open class CapacitorEnergyStorage( maxInput: () -> Decimal? = { DEFAULT_MAX_IO }, maxOutput: () -> Decimal? = maxInput ) : BlockEnergyStorageImpl(listener, FlowDirection.BI_DIRECTIONAL, maxBatteryLevel, maxInput, maxOutput) { - constructor( - listener: () -> Unit, - maxBatteryLevel: Decimal = DEFAULT_MAX_CAPACITY, - maxInput: Decimal? = DEFAULT_MAX_IO, - maxOutput: Decimal? = maxInput) : this(listener, { maxBatteryLevel }, { maxInput }, { maxOutput }) - constructor( listener: () -> Unit, values: EnergyBalanceValues ) : this(listener, values::energyCapacity, values::energyThroughput, values::energyThroughput) - constructor( - listener: BlockEntity, - values: EnergyBalanceValues - ) : this(listener::setChanged, values::energyCapacity, values::energyThroughput, values::energyThroughput) - constructor( listener: () -> Unit, values: VerboseEnergyBalanceValues ) : this(listener, values::energyCapacity, values::maxEnergyReceive, values::maxEnergyExtract) - constructor( - listener: BlockEntity, - values: VerboseEnergyBalanceValues - ) : this(listener::setChanged, values::energyCapacity, values::maxEnergyReceive, values::maxEnergyExtract) - - constructor( - listener: BlockEntity, - maxBatteryLevel: Decimal = DEFAULT_MAX_CAPACITY, - maxInput: Decimal? = DEFAULT_MAX_IO, - maxOutput: Decimal? = maxInput) : this(listener::setChanged, maxBatteryLevel, maxInput, maxOutput) - companion object { fun appendHoverText(itemStack: ItemStack, tooltips: MutableList) { val tag = (itemStack.tag?.get(BlockItem.BLOCK_ENTITY_TAG) as? CompoundTag)?.get(MatteryBlockEntity.ENERGY_KEY) as? CompoundTag ?: return - val cap = CapacitorEnergyStorage({}, DEFAULT_MAX_CAPACITY) + val cap = CapacitorEnergyStorage({}, { DEFAULT_MAX_CAPACITY }) cap.deserializeNBT(tag) batteryLevel(cap, tooltips) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt index 6a505862e..583b1acb0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt @@ -138,11 +138,11 @@ object MachinesConfig : AbstractConfig("machines") { .defineInRange("DIVISOR", 3.0, 0.1, Double.MAX_VALUE) } - val STORAGE_POWER_SUPPLIER = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.STORAGE_POWER_SUPPLIER, capacity = Decimal(100_000), throughput = Decimal(320)) - val STORAGE_INTERFACES = BlockEnergyStorageImpl.makeConfigEntry(builder, "STORAGE_INTERFACES", capacity = Decimal(10_000)) - val ITEM_MONITOR = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.ITEM_MONITOR) - val DRIVE_VIEWER = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.DRIVE_VIEWER) - val DRIVE_RACK = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.DRIVE_RACK, capacity = Decimal(80_000)) + val STORAGE_POWER_SUPPLIER = conciseValues(MNames.STORAGE_POWER_SUPPLIER, Decimal(80_000), Decimal(2_000)) + val STORAGE_INTERFACES = conciseValues("STORAGE_INTERFACES", Decimal(10_000), Decimal(100)) + val ITEM_MONITOR = conciseValues(MNames.ITEM_MONITOR, Decimal(10_000), Decimal(100)) + val DRIVE_VIEWER = conciseValues(MNames.DRIVE_VIEWER, Decimal(10_000), Decimal(100)) + val DRIVE_RACK = conciseValues(MNames.DRIVE_RACK, Decimal(10_000), Decimal(100)) object AndroidCharger { val RADIUS_WIDTH: Double by builder @@ -154,7 +154,7 @@ object MachinesConfig : AbstractConfig("machines") { .defineInRange("RADIUS_HEIGHT", 4.0, 1.0, Double.MAX_VALUE) } - val ANDROID_CHARGER = BlockEnergyStorageImpl.makeConfigEntry(builder, MNames.ANDROID_CHARGER, capacity = Decimal(1_000_000), throughput = Decimal(8192)) { AndroidCharger } + val ANDROID_CHARGER = conciseValues(MNames.ANDROID_CHARGER, Decimal(1_000_000), Decimal(8192)) { AndroidCharger } val POWERED_FURNACE = workerValues( "POWERED_FURNACE", From 75b7614fdfe463f2cfc4b4b049f762bc7f201493 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 5 Aug 2023 00:02:36 +0700 Subject: [PATCH 0937/1199] Delay advancement granting by one tick --- .../otm/capability/MatteryPlayerCapability.kt | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 51c08d53c..61eefa3a2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -212,7 +212,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial access.write(value) if (value && ply is ServerPlayer) { - ExopackObtainedTrigger.trigger(ply) + tickList.once { + ExopackObtainedTrigger.trigger(ply) + } } }).property @@ -326,7 +328,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial _exoPackMenu = null if (value && ply is ServerPlayer) { - ExopackGainedCraftingTrigger.trigger(ply) + tickList.once { + ExopackGainedCraftingTrigger.trigger(ply) + } } } }).property @@ -337,7 +341,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial _exoPackMenu = null if (value && ply is ServerPlayer) { - ExopackGainedEnderAccessTrigger.trigger(ply) + tickList.once { + ExopackGainedEnderAccessTrigger.trigger(ply) + } } } }).property @@ -443,7 +449,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial _exoPackMenu = null if (value && ply is ServerPlayer) { - ExopackGainedSmeltingTrigger.trigger(ply) + tickList.once { + ExopackGainedSmeltingTrigger.trigger(ply) + } } } }).property @@ -609,7 +617,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial wasInLiquid = false if (ply is ServerPlayer) { - BecomeAndroidTrigger.trigger(ply) + tickList.once { + BecomeAndroidTrigger.trigger(ply) + } } } @@ -662,7 +672,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial wasInLiquid = false if (ply is ServerPlayer) { - BecomeHumaneTrigger.trigger(ply) + tickList.once { + BecomeHumaneTrigger.trigger(ply) + } } for (feature in featureMap.values) { @@ -928,7 +940,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } if (ply is ServerPlayer && hasExopack) - ExopackSlotsExpandedTrigger.trigger(ply, 0, exopackContainer.containerSize) + tickList.once { + ExopackSlotsExpandedTrigger.trigger(ply, 0, exopackContainer.containerSize) + } for (filter in regularSlotFilters) { filter.value = null @@ -998,7 +1012,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial this.research[research] = instance if (instance.isResearched && ply is ServerPlayer) { - tickList.timer(20) { + tickList.once { if (!ply.hasDisconnected()) AndroidResearchTrigger.trigger(ply, instance.type) } @@ -1007,7 +1021,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } if (isAndroid && ply is ServerPlayer) { - tickList.timer(20) { + tickList.once { if (!ply.hasDisconnected()) BecomeAndroidTrigger.trigger(ply) } From 2b85e5754f20bbbca9ebdc1a2dee994412a84090 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 5 Aug 2023 02:00:43 +0700 Subject: [PATCH 0938/1199] Decrease initial capacity of hashtable in inventory trigger search tree to reduce memory footprint --- .../mc/otm/triggers/MatteryInventoryChangeTrigger.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MatteryInventoryChangeTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MatteryInventoryChangeTrigger.kt index fa03d8913..d135c63ba 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MatteryInventoryChangeTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MatteryInventoryChangeTrigger.kt @@ -117,7 +117,7 @@ object MatteryInventoryChangeTrigger : CriterionTrigger(nodes[nodeId + 1].strategy as Strategy) }) as MutableMap, + tree.computeIfAbsent(v, Object2ObjectFunction { Object2ObjectOpenCustomHashMap(4, nodes[nodeId + 1].strategy as Strategy) }) as MutableMap, nodeId + 1)) } @@ -126,7 +126,7 @@ object MatteryInventoryChangeTrigger : CriterionTrigger>>() for (v in node.getValues(instance)) { - result.add(tree.computeIfAbsent(v, Object2ObjectFunction { ObjectOpenHashSet>() }) as MutableSet>) + result.add(tree.computeIfAbsent(v, Object2ObjectFunction { ObjectOpenHashSet>(4) }) as MutableSet>) } return result From ecc89e992c805c063b7854ef4aaec6af24b0df96 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 5 Aug 2023 20:39:21 +0700 Subject: [PATCH 0939/1199] Rename block rotation freedom to be more precise --- .../mc/otm/datagen/DecorativeData.kt | 8 ++--- .../mc/otm/datagen/blocks/Banks.kt | 2 +- .../mc/otm/datagen/blocks/BlockStates.kt | 32 +++++++++---------- .../otm/datagen/blocks/ComplexBlockStates.kt | 12 +++---- .../blocks/MatteryBlockStateProvider.kt | 6 ++-- .../dbotthepony/mc/otm/block/MatteryBlock.kt | 6 ++-- .../mc/otm/block/RotatableMatteryBlock.kt | 8 ++--- .../mc/otm/block/decorative/EngineBlock.kt | 3 +- .../mc/otm/block/decorative/HoloSignBlock.kt | 2 +- .../mc/otm/block/decorative/LaboratoryLamp.kt | 3 +- .../entity/storage/StorageBusBlockEntity.kt | 4 +-- .../tech/GravitationStabilizerBlockEntity.kt | 7 ++-- .../mc/otm/block/matter/MatterBottlerBlock.kt | 2 -- .../otm/block/matter/MatterDecomposerBlock.kt | 2 -- .../mc/otm/block/matter/MatterPanelBlock.kt | 10 +++--- .../otm/block/matter/MatterRecyclerBlock.kt | 2 -- .../otm/block/matter/MatterReplicatorBlock.kt | 2 -- .../mc/otm/block/matter/MatterScannerBlock.kt | 2 -- .../mc/otm/block/storage/DriveRackBlock.kt | 2 -- .../mc/otm/block/storage/DriveViewerBlock.kt | 2 -- .../mc/otm/block/storage/ItemMonitorBlock.kt | 2 -- .../mc/otm/block/storage/StorageBusBlock.kt | 6 ++-- .../mc/otm/block/storage/StorageInterfaces.kt | 10 +++--- .../storage/StoragePowerSupplierBlock.kt | 2 -- .../mc/otm/block/tech/EnergyServoBlock.kt | 2 -- .../block/tech/GravitationStabilizerBlock.kt | 24 +++++++------- .../otm/block/tech/PhantomAttractorBlock.kt | 3 -- .../mc/otm/block/tech/PlatePressBlock.kt | 3 -- .../client/render/blockentity/BankRenderer.kt | 5 ++- .../GravitationStabilizerRenderer.kt | 7 ++-- .../render/blockentity/HoloSignRenderer.kt | 6 ++-- .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 6 ++++ .../mc/otm/core/math/BlockRotationFreedom.kt | 16 ++-------- 33 files changed, 85 insertions(+), 124 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt index d4f75f0da..c104e939d 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt @@ -230,16 +230,16 @@ fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelPr blockStateProvider.getVariantBuilder(MBlocks.LABORATORY_LAMP).forAllStates { return@forAllStates ConfiguredModel.builder() .modelFile(if (it[BlockStateProperties.LIT]) labLampOn!! else labLampOff!!) - .rotationX(it[BlockRotationFreedom.TWO.property].front.xRotationBlockstateNorth()) - .rotationY(it[BlockRotationFreedom.TWO.property].front.yRotationBlockstateNorth()) + .rotationX(it[BlockRotationFreedom.XZ_XY.property].front.xRotationBlockstateNorth()) + .rotationY(it[BlockRotationFreedom.XZ_XY.property].front.yRotationBlockstateNorth()) .build() } blockStateProvider.getVariantBuilder(MBlocks.LABORATORY_LAMP_INVERTED).forAllStates { return@forAllStates ConfiguredModel.builder() .modelFile(if (it[BlockStateProperties.LIT]) labLampOn!! else labLampOff!!) - .rotationX(it[BlockRotationFreedom.TWO.property].front.xRotationBlockstateNorth()) - .rotationY(it[BlockRotationFreedom.TWO.property].front.yRotationBlockstateNorth()) + .rotationX(it[BlockRotationFreedom.XZ_XY.property].front.xRotationBlockstateNorth()) + .rotationY(it[BlockRotationFreedom.XZ_XY.property].front.yRotationBlockstateNorth()) .build() } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt index 66444f883..a225b8566 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt @@ -28,7 +28,7 @@ open class BatteryBankProvider(event: GatherDataEvent) : BlockStateProvider(even forAllStates { ConfiguredModel.builder() .modelFile(models().getExistingFile(modLocation("block/$block"))) - .rotationY(it[BlockRotationFreedom.ONE.property].front.yRotationBlockstateNorth()) + .rotationY(it[BlockRotationFreedom.XZ.property].front.yRotationBlockstateNorth()) .build() } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt index c5f1f5680..96e676f1a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt @@ -36,54 +36,54 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { provider.exec { with(provider.getMultipartBuilder(MBlocks.PHANTOM_ATTRACTOR)) { - for (dir in BlockRotationFreedom.ONE.possibleValues) { + for (dir in BlockRotationFreedom.XZ.possibleValues) { part().modelFile(provider.models().getExistingFile(modLocation("block/${MNames.PHANTOM_ATTRACTOR}"))) .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() .condition(BlockStateProperties.DOUBLE_BLOCK_HALF, DoubleBlockHalf.LOWER) - .condition(BlockRotationFreedom.ONE.property, dir) + .condition(BlockRotationFreedom.XZ.property, dir) .end() } } with(provider.getMultipartBuilder(MBlocks.ANDROID_CHARGER)) { - for (dir in BlockRotationFreedom.ONE.possibleValues) { + for (dir in BlockRotationFreedom.XZ.possibleValues) { for (part in AndroidChargerBlock.PART.possibleValues) { part().modelFile(provider.models().getExistingFile(modLocation("block/${MNames.ANDROID_CHARGER}_${part.serializedName}"))) .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() .condition(AndroidChargerBlock.PART, part) - .condition(BlockRotationFreedom.ONE.property, dir) + .condition(BlockRotationFreedom.XZ.property, dir) .end() } } } with(provider.getMultipartBuilder(MBlocks.MATTER_BOTTLER)) { - for (dir in BlockRotationFreedom.ONE.possibleValues) { + for (dir in BlockRotationFreedom.XZ.possibleValues) { for (enum in WorkerState.SEMI_WORKER_STATE.possibleValues) { part().modelFile(provider.models().getExistingFile(modLocation("matter_bottler_${enum.name.lowercase()}"))) .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() - .condition(BlockRotationFreedom.ONE.property, dir) + .condition(BlockRotationFreedom.XZ.property, dir) .condition(WorkerState.WORKER_STATE, enum) .end() } } - for (dir in BlockRotationFreedom.ONE.possibleValues) { + for (dir in BlockRotationFreedom.XZ.possibleValues) { for (enum in MatterBottlerBlock.SLOT_PROPERTIES) { part().modelFile(provider.models().getExistingFile(modLocation("matter_bottler_${enum.name}_open"))) .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() - .condition(BlockRotationFreedom.ONE.property, dir) + .condition(BlockRotationFreedom.XZ.property, dir) .condition(enum, false) .end() part().modelFile(provider.models().getExistingFile(modLocation("matter_bottler_${enum.name}_closed"))) .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() - .condition(BlockRotationFreedom.ONE.property, dir) + .condition(BlockRotationFreedom.XZ.property, dir) .condition(enum, true) .end() } @@ -116,19 +116,19 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { modLocation("${crate.registryName!!.path}_${if (it.getValue( CargoCrateBlock.IS_OPEN)) "open" else "closed"}") )) - .rotationY(it.getValue(BlockRotationFreedom.ONE.property).front.yRotationBlockstateNorth()) + .rotationY(it.getValue(BlockRotationFreedom.XZ.property).front.yRotationBlockstateNorth()) .buildLast() ) } } with(provider.getMultipartBuilder(MBlocks.STORAGE_BUS)) { - for (dir in BlockRotationFreedom.TWO.possibleValues) { + for (dir in BlockRotationFreedom.XZ_XY.possibleValues) { part().modelFile(provider.models().getExistingFile(modLocation("storage_bus"))) .rotationX(dir.front.xRotationBlockstateNorth()) .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() - .condition(BlockRotationFreedom.TWO.property, dir) + .condition(BlockRotationFreedom.XZ_XY.property, dir) .end() part().modelFile(provider.models().getExistingFile(modLocation("storage_cable_connection"))) @@ -144,12 +144,12 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { } with(provider.getMultipartBuilder(MBlocks.STORAGE_IMPORTER)) { - for (dir in BlockRotationFreedom.TWO.possibleValues) { + for (dir in BlockRotationFreedom.XZ_XY.possibleValues) { part().modelFile(provider.models().getExistingFile(modLocation("storage_importer"))) .rotationX(dir.front.xRotationBlockstateNorth()) .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() - .condition(BlockRotationFreedom.TWO.property, dir) + .condition(BlockRotationFreedom.XZ_XY.property, dir) .end() part().modelFile(provider.models().getExistingFile(modLocation("storage_cable_connection"))) @@ -165,12 +165,12 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { } with(provider.getMultipartBuilder(MBlocks.STORAGE_EXPORTER)) { - for (dir in BlockRotationFreedom.TWO.possibleValues) { + for (dir in BlockRotationFreedom.XZ_XY.possibleValues) { part().modelFile(provider.models().getExistingFile(modLocation("storage_exporter"))) .rotationX(dir.front.xRotationBlockstateNorth()) .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() - .condition(BlockRotationFreedom.TWO.property, dir) + .condition(BlockRotationFreedom.XZ_XY.property, dir) .end() part().modelFile(provider.models().getExistingFile(modLocation("storage_cable_connection"))) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt index 73ee45bf9..05e00e779 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt @@ -12,12 +12,12 @@ import ru.dbotthepony.mc.otm.registry.MBlocks fun addComplexBlockStates(provider: MatteryBlockStateProvider) { with(provider.getMultipartBuilder(MBlocks.DRIVE_VIEWER)) { - for (facing in BlockRotationFreedom.ONE.possibleValues) { + for (facing in BlockRotationFreedom.XZ.possibleValues) { part() .modelFile(provider.models().getExistingFile(modLocation("block/drive_viewer_drive_part"))) .rotationY(facing.front.yRotationBlockstateNorth()) .addModel() - .condition(BlockRotationFreedom.ONE.property, facing) + .condition(BlockRotationFreedom.XZ.property, facing) .condition(DriveViewerBlock.DRIVE_PRESENT, true) for (workState in WorkerState.SEMI_WORKER_STATE.possibleValues) { @@ -26,25 +26,25 @@ fun addComplexBlockStates(provider: MatteryBlockStateProvider) { .rotationY(facing.front.yRotationBlockstateNorth()) .addModel() .condition(WorkerState.SEMI_WORKER_STATE, workState) - .condition(BlockRotationFreedom.ONE.property, facing) + .condition(BlockRotationFreedom.XZ.property, facing) } } } with(provider.getMultipartBuilder(MBlocks.PATTERN_STORAGE)) { - for (facing in BlockRotationFreedom.ONE.possibleValues) { + for (facing in BlockRotationFreedom.XZ.possibleValues) { part() .modelFile(provider.models().getExistingFile(modLocation("block/pattern_storage"))) .rotationY(facing.front.yRotationBlockstateNorth()) .addModel() - .condition(BlockRotationFreedom.ONE.property, facing) + .condition(BlockRotationFreedom.XZ.property, facing) for (i in 0 .. 7) { part() .modelFile(provider.models().getExistingFile(modLocation("block/pattern/model$i"))) .rotationY(facing.front.yRotationBlockstateNorth()) .addModel() - .condition(BlockRotationFreedom.ONE.property, facing) + .condition(BlockRotationFreedom.XZ.property, facing) .condition(PatternStorageBlock.PATTERN_STORAGE_DISKS_PROPS[i], true) } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt index b9b99e438..2b2724bbf 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt @@ -21,16 +21,16 @@ private val EMPTY: BlockStateTransform = { _, _, _ -> null } private fun initialTransform(it: BlockState, modelPath: String, builder: ConfiguredModel.Builder<*>): String { @Suppress("NAME_SHADOWING") var modelPath = modelPath - it.getValueNullable(BlockRotationFreedom.ONE.property)?.let { + it.getValueNullable(BlockRotationFreedom.XZ.property)?.let { builder.rotationY(it.front.yRotationBlockstateNorth()) } - it.getValueNullable(BlockRotationFreedom.TWO.property)?.let { + it.getValueNullable(BlockRotationFreedom.XZ_XY.property)?.let { builder.rotationY(it.front.yRotationBlockstateNorth()) builder.rotationX(it.front.xRotationBlockstateNorth()) } - it.getValueNullable(BlockRotationFreedom.THREE.property)?.let { + it.getValueNullable(BlockRotationFreedom.XZ_XY_ZY.property)?.let { builder.rotationY(it.front.yRotationBlockstateNorth() + it.top.yRotationBlockstateNorth()) builder.rotationX(it.front.xRotationBlockstateNorth()) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt index 86ad9bba1..c30bdb301 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt @@ -115,9 +115,9 @@ abstract class MatteryBlock @JvmOverloads constructor( val state = blockState.getOptionalValue(WorkerState.WORKER_STATE).or { blockState.getOptionalValue(WorkerState.SEMI_WORKER_STATE) } if (state.isPresent && state.get() == WorkerState.WORKING) { - val state2 = blockState.getOptionalValue(BlockRotationFreedom.ONE.property) - .or { blockState.getOptionalValue(BlockRotationFreedom.TWO.property) } - .or { blockState.getOptionalValue(BlockRotationFreedom.THREE.property) } + val state2 = blockState.getOptionalValue(BlockRotationFreedom.XZ.property) + .or { blockState.getOptionalValue(BlockRotationFreedom.XZ_XY.property) } + .or { blockState.getOptionalValue(BlockRotationFreedom.XZ_XY_ZY.property) } if (state2.isPresent) { val direction = state2.get() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/RotatableMatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/RotatableMatteryBlock.kt index 401853578..652634be9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/RotatableMatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/RotatableMatteryBlock.kt @@ -22,17 +22,17 @@ abstract class RotatableMatteryBlock @JvmOverloads constructor(properties: Prope override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { return when (val freedom = rotationFreedom()) { - BlockRotationFreedom.ONE -> defaultBlockState().setValue( + BlockRotationFreedom.XZ -> defaultBlockState().setValue( freedom.property, freedom.of(if (faceToPlayer(context)) context.horizontalDirection.opposite else context.horizontalDirection) ) - BlockRotationFreedom.TWO -> defaultBlockState().setValue( + BlockRotationFreedom.XZ_XY -> defaultBlockState().setValue( freedom.property, freedom.of(if (faceToPlayer(context)) context.nearestLookingDirection.opposite else context.nearestLookingDirection) ) - BlockRotationFreedom.THREE -> { + BlockRotationFreedom.XZ_XY_ZY -> { val primary = if (faceToPlayer(context)) context.nearestLookingDirection.opposite else context.nearestLookingDirection var secondary = if (faceToPlayer(context)) context.horizontalDirection else context.horizontalDirection.opposite @@ -59,7 +59,7 @@ abstract class RotatableMatteryBlock @JvmOverloads constructor(properties: Prope val rotationProperty get() = rotationFreedom().property open fun rotationFreedom(): BlockRotationFreedom { - return BlockRotationFreedom.ONE + return BlockRotationFreedom.XZ } open fun faceToPlayer(context: BlockPlaceContext): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt index 72f738fbc..44ea148ab 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt @@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.block.decorative import net.minecraft.ChatFormatting import net.minecraft.core.BlockPos import net.minecraft.network.chat.Component -import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.BlockGetter @@ -30,7 +29,7 @@ class EngineBlock : RotatableMatteryBlock(Properties.of().mapColor(MapColor.COLO } override fun rotationFreedom(): BlockRotationFreedom { - return BlockRotationFreedom.TWO + return BlockRotationFreedom.XZ_XY } private val shapes = getShapeForEachState { BlockShapes.ENGINE.rotateFromNorth(it[rotationProperty]).computeShape() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt index abd308ba9..2d7f0998f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt @@ -15,7 +15,7 @@ import ru.dbotthepony.mc.otm.shapes.BlockShapes class HoloSignBlock : RotatableMatteryBlock(), EntityBlock { override fun rotationFreedom(): BlockRotationFreedom { - return BlockRotationFreedom.THREE + return BlockRotationFreedom.XZ_XY_ZY } override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt index b0e04d1fd..4b942fb23 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt @@ -23,11 +23,10 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.math.blockRotation import ru.dbotthepony.mc.otm.core.math.plus -import ru.dbotthepony.mc.otm.core.math.unaryMinus import ru.dbotthepony.mc.otm.once import ru.dbotthepony.mc.otm.registry.MBlocks -private val FACING_FULL = BlockRotationFreedom.TWO.property +private val FACING_FULL = BlockRotationFreedom.XZ_XY.property class LaboratoryLampLight : Block(Properties.of().strength(-1.0F, 3600000.8F).noCollission().noLootTable().replaceable().lightLevel { 15 }) { override fun createBlockStateDefinition(builder: StateDefinition.Builder) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt index 4ae09678d..3153d60da 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt @@ -122,8 +122,8 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter if (isRemoved) return - val front = blockPos + blockState.getValue(BlockRotationFreedom.TWO.property) - val storage = level?.getBlockEntity(front)?.getCapability(ForgeCapabilities.ITEM_HANDLER, -blockState.getValue(BlockRotationFreedom.TWO.property))?.let { if (it.isPresent) it else null } + val front = blockPos + blockState.getValue(BlockRotationFreedom.XZ_XY.property) + val storage = level?.getBlockEntity(front)?.getCapability(ForgeCapabilities.ITEM_HANDLER, -blockState.getValue(BlockRotationFreedom.XZ_XY.property))?.let { if (it.isPresent) it else null } if (neighbour != storage) { neighbour = storage diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/GravitationStabilizerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/GravitationStabilizerBlockEntity.kt index bd2c70c3d..d5f6e1bc4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/GravitationStabilizerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/GravitationStabilizerBlockEntity.kt @@ -2,20 +2,19 @@ package ru.dbotthepony.mc.otm.block.entity.tech import net.minecraft.core.BlockPos import net.minecraft.core.SectionPos -import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.phys.AABB -import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.block.tech.BlockGravitationStabilizerLens import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity import ru.dbotthepony.mc.otm.block.tech.BlockGravitationStabilizer -import ru.dbotthepony.mc.otm.core.math.facingTwo +import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.core.math.times import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -27,7 +26,7 @@ class GravitationStabilizerBlockEntity(p_155229_: BlockPos, p_155230_: BlockStat fun tick(level: Level) { var findBlackHole: BlackHoleBlockEntity? = null - val dir = blockState.facingTwo.normal + val dir = blockState[BlockRotationFreedom.XZ_XY].normal for (i in 2 .. RANGE) { val pos = blockPos + dir * i diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt index 6cad2f412..ad79208e4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.block.matter import net.minecraft.core.BlockPos -import net.minecraft.core.Direction import net.minecraft.world.item.context.BlockPlaceContext import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level @@ -20,7 +19,6 @@ import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get -import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt index 0d7a7a886..1393720be 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt @@ -4,7 +4,6 @@ import net.minecraft.MethodsReturnNonnullByDefault import javax.annotation.ParametersAreNonnullByDefault import net.minecraft.world.level.block.EntityBlock import net.minecraft.core.BlockPos -import net.minecraft.core.Direction import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.entity.BlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterDecomposerBlockEntity @@ -20,7 +19,6 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get -import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterPanelBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterPanelBlock.kt index 0b593d258..ca4502941 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterPanelBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterPanelBlock.kt @@ -13,9 +13,9 @@ import net.minecraft.world.level.BlockGetter import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.item.context.BlockPlaceContext import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom -import ru.dbotthepony.mc.otm.core.math.rotationTwo class MatterPanelBlock : RotatableMatteryBlock(), EntityBlock { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { @@ -25,10 +25,10 @@ class MatterPanelBlock : RotatableMatteryBlock(), EntityBlock { private val shapes: ImmutableMap init { - registerDefaultState(getStateDefinition().any().setValue(BlockRotationFreedom.TWO.property, BlockRotation.SOUTH)) + registerDefaultState(getStateDefinition().any().setValue(BlockRotationFreedom.XZ_XY.property, BlockRotation.SOUTH)) shapes = getShapeForEachState { - when (it.rotationTwo.front) { + when (it[BlockRotationFreedom.XZ_XY.property].front) { Direction.NORTH -> Shapes.box( 0.0, 0.0, @@ -91,10 +91,10 @@ class MatterPanelBlock : RotatableMatteryBlock(), EntityBlock { } override fun rotationFreedom(): BlockRotationFreedom { - return BlockRotationFreedom.TWO + return BlockRotationFreedom.XZ_XY } override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { - return defaultBlockState().setValue(BlockRotationFreedom.TWO.property, BlockRotation.of(context.clickedFace)) + return defaultBlockState().setValue(BlockRotationFreedom.XZ_XY.property, BlockRotation.of(context.clickedFace)) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt index 673522d9a..1f5078266 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.block.matter import net.minecraft.core.BlockPos -import net.minecraft.core.Direction import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block @@ -18,7 +17,6 @@ import ru.dbotthepony.mc.otm.block.entity.matter.MatterRecyclerBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get -import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt index a483c570a..1609c8740 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.block.matter import net.minecraft.core.BlockPos -import net.minecraft.core.Direction import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block @@ -18,7 +17,6 @@ import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get -import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt index 7a80592c2..157a81bef 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.block.matter import net.minecraft.core.BlockPos -import net.minecraft.core.Direction import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block @@ -18,7 +17,6 @@ import ru.dbotthepony.mc.otm.block.entity.matter.MatterScannerBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get -import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt index cd032b99a..cd4862293 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.block.storage import net.minecraft.core.BlockPos -import net.minecraft.core.Direction import net.minecraft.network.chat.Component import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag @@ -20,7 +19,6 @@ import ru.dbotthepony.mc.otm.block.entity.storage.DriveRackBlockEntity import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.core.get -import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt index d0569066c..ab4b10c66 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.block.storage import net.minecraft.core.BlockPos -import net.minecraft.core.Direction import net.minecraft.network.chat.Component import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag @@ -25,7 +24,6 @@ import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.core.get -import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt index d008bcdfe..95bdd4d32 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.block.storage import net.minecraft.core.BlockPos -import net.minecraft.core.Direction import net.minecraft.network.chat.Component import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag @@ -20,7 +19,6 @@ import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorBlockEntity import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.core.get -import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt index 21ea4a630..ff7937407 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt @@ -27,8 +27,6 @@ import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom -import ru.dbotthepony.mc.otm.core.math.facingTwo -import ru.dbotthepony.mc.otm.core.math.rotationTwo import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes import ru.dbotthepony.mc.otm.core.math.unaryMinus @@ -36,7 +34,7 @@ import ru.dbotthepony.mc.otm.oncePre class StorageBusBlock : RotatableMatteryBlock(), EntityBlock { override fun rotationFreedom(): BlockRotationFreedom { - return BlockRotationFreedom.TWO + return BlockRotationFreedom.XZ_XY } init { @@ -54,7 +52,7 @@ class StorageBusBlock : RotatableMatteryBlock(), EntityBlock { } override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { - return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.TWO.property, BlockRotation.of(-context.clickedFace)) + return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.XZ_XY.property, BlockRotation.of(-context.clickedFace)) } override fun appendHoverText( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt index 6f7a3e0f2..331dfe24a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt @@ -28,15 +28,13 @@ import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom -import ru.dbotthepony.mc.otm.core.math.facingTwo import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes import ru.dbotthepony.mc.otm.core.math.unaryMinus -import ru.dbotthepony.mc.otm.oncePre class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock { override fun rotationFreedom(): BlockRotationFreedom { - return BlockRotationFreedom.TWO + return BlockRotationFreedom.XZ_XY } override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { @@ -78,7 +76,7 @@ class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock { } override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { - return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.TWO.property, BlockRotation.of(-context.clickedFace)) + return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.XZ_XY.property, BlockRotation.of(-context.clickedFace)) } override fun appendHoverText( @@ -118,7 +116,7 @@ class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock { class StorageExporterBlock : RotatableMatteryBlock(), EntityBlock { override fun rotationFreedom(): BlockRotationFreedom { - return BlockRotationFreedom.TWO + return BlockRotationFreedom.XZ_XY } override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { @@ -171,7 +169,7 @@ class StorageExporterBlock : RotatableMatteryBlock(), EntityBlock { } override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { - return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.TWO.property, BlockRotation.of(-context.clickedFace)) + return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.XZ_XY.property, BlockRotation.of(-context.clickedFace)) } private val shapes = getShapeForEachState { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt index 48e84f67b..dcef7302a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.block.storage import net.minecraft.core.BlockPos -import net.minecraft.core.Direction import net.minecraft.network.chat.Component import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag @@ -20,7 +19,6 @@ import ru.dbotthepony.mc.otm.block.entity.storage.StoragePowerSupplierBlockEntit import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.core.get -import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt index 3b23d5079..b6a0aaa1a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.block.tech import net.minecraft.core.BlockPos -import net.minecraft.core.Direction import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraft.world.level.block.EntityBlock @@ -17,7 +16,6 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.tech.EnergyServoBlockEntity import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get -import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt index e78fc081e..3e647b0e2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt @@ -26,8 +26,8 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.tech.GravitationStabilizerBlockEntity import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom -import ru.dbotthepony.mc.otm.core.math.facingTwo import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.core.math.times import ru.dbotthepony.mc.otm.oncePre @@ -55,7 +55,7 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock { } override fun rotationFreedom(): BlockRotationFreedom { - return BlockRotationFreedom.TWO + return BlockRotationFreedom.XZ_XY } override fun createBlockStateDefinition(builder: StateDefinition.Builder) { @@ -68,7 +68,7 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock { val blockPos = context.clickedPos val level = context.level - for (face in BlockRotationFreedom.TWO.possibleValues) { + for (face in BlockRotationFreedom.XZ_XY.possibleValues) { val dir = face.normal for (i in 1 ..GravitationStabilizerBlockEntity.RANGE) { @@ -78,14 +78,14 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock { if (!getState.isAir) { if (chunk.getBlockEntity(pos) is BlackHoleBlockEntity) { - state = state.setValue(BlockRotationFreedom.TWO.property, face) + state = state.setValue(BlockRotationFreedom.XZ_XY.property, face) break } } } } - val bbPos = blockPos + state.getValue(BlockRotationFreedom.TWO.property).normal + val bbPos = blockPos + state.getValue(BlockRotationFreedom.XZ_XY.property).normal if (!context.level.isInWorldBounds(bbPos)) return null if (!level.getBlockState(bbPos).canBeReplaced(context)) return null @@ -103,9 +103,9 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock { super.setPlacedBy(level, blockPos, blockState, entity, itemStack) if (!level.isClientSide) { - val bbPos = blockPos + blockState.getValue(BlockRotationFreedom.TWO.property).normal + val bbPos = blockPos + blockState.getValue(BlockRotationFreedom.XZ_XY.property).normal val newState = MBlocks.GRAVITATION_STABILIZER_LENS.defaultBlockState() - .setValue(BlockRotationFreedom.TWO.property, blockState.getValue(BlockRotationFreedom.TWO.property)) + .setValue(BlockRotationFreedom.XZ_XY.property, blockState.getValue(BlockRotationFreedom.XZ_XY.property)) level.setBlock(bbPos, newState, UPDATE_ALL) } @@ -137,7 +137,7 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock { p_60557_: BlockPos, p_60558_: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.facingTwo.ordinal] + return SHAPES[p_60555_[BlockRotationFreedom.XZ_XY].ordinal] } companion object { @@ -155,14 +155,14 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock { } fun getBoundingBlockPos(blockState: BlockState, blockPos: BlockPos): BlockPos { - return blockPos + blockState.getValue(BlockRotationFreedom.TWO.property).normal + return blockPos + blockState.getValue(BlockRotationFreedom.XZ_XY.property).normal } } } class BlockGravitationStabilizerLens : RotatableMatteryBlock(props) { override fun rotationFreedom(): BlockRotationFreedom { - return BlockRotationFreedom.TWO + return BlockRotationFreedom.XZ_XY } override fun createBlockStateDefinition(builder: StateDefinition.Builder) { @@ -196,7 +196,7 @@ class BlockGravitationStabilizerLens : RotatableMatteryBlock(props) { p_60557_: BlockPos, p_60558_: CollisionContext ): VoxelShape { - return SHAPES[p_60555_.facingTwo.ordinal] + return SHAPES[p_60555_[BlockRotationFreedom.XZ_XY].front.ordinal] } companion object { @@ -205,7 +205,7 @@ class BlockGravitationStabilizerLens : RotatableMatteryBlock(props) { } fun getBoundingBlockPos(blockState: BlockState, blockPos: BlockPos): BlockPos { - return blockPos + blockState.getValue(BlockRotationFreedom.TWO.property).front.opposite.normal + return blockPos + blockState.getValue(BlockRotationFreedom.XZ_XY.property).front.opposite.normal } private val SHAPES = arrayOf( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt index e8e620148..9e0ff3fe7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt @@ -24,15 +24,12 @@ import net.minecraft.world.level.material.MapColor import net.minecraft.world.phys.AABB import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape -import net.minecraftforge.common.ForgeHooks import net.minecraftforge.event.ForgeEventFactory import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get -import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.core.math.minus import ru.dbotthepony.mc.otm.core.math.plus -import ru.dbotthepony.mc.otm.core.math.rotationOne import ru.dbotthepony.mc.otm.once import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.shapes.BlockShapes diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt index 01810fb82..22c3aeca4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.block.tech import net.minecraft.core.BlockPos -import net.minecraft.core.Direction import net.minecraft.network.chat.Component import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag @@ -22,8 +21,6 @@ import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get -import ru.dbotthepony.mc.otm.core.math.facingOne -import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes class PlatePressBlock(properties: Properties = DEFAULT_PROPERTIES, val isTwin: Boolean = false) : RotatableMatteryBlock(properties), EntityBlock { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt index 29dc62ddb..9da03e508 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt @@ -23,7 +23,6 @@ import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.math.RGBAColor -import ru.dbotthepony.mc.otm.core.math.facingOne import ru.dbotthepony.mc.otm.core.math.rotate import ru.dbotthepony.mc.otm.core.math.rotateY import ru.dbotthepony.mc.otm.nanoTime @@ -50,7 +49,7 @@ abstract class BankRenderer(private val context: B stack.pushPose() stack.translate(0.5f, 0.5f, 0.5f) - stack.rotate(blockEntity.blockState[BlockRotationFreedom.ONE.property].front) + stack.rotate(blockEntity.blockState[BlockRotationFreedom.XZ.property].front) stack.translate(-0.5f, -0.5f, -0.5f) for ((i, model) in models.withIndex()) { @@ -74,7 +73,7 @@ abstract class BankRenderer(private val context: B stack.pushPose() - val facing = blockEntity.blockState.facingOne + val facing = blockEntity.blockState[BlockRotationFreedom.XZ].front val rotateFacing = facing == Direction.NORTH || facing == Direction.SOUTH if (rotateFacing) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt index a86e716b3..b57b863b4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt @@ -19,6 +19,7 @@ import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.core.* +import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.VECTOR_DOWN import ru.dbotthepony.mc.otm.core.math.VECTOR_FORWARD @@ -26,14 +27,12 @@ import ru.dbotthepony.mc.otm.core.math.VECTOR_RIGHT import ru.dbotthepony.mc.otm.core.math.VECTOR_UP import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.math.asAngle -import ru.dbotthepony.mc.otm.core.math.facingTwo import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.core.math.rotateAroundAxis import ru.dbotthepony.mc.otm.core.math.times import ru.dbotthepony.mc.otm.core.util.formatMatter import kotlin.math.PI -@Suppress("PrivatePropertyName") class GravitationStabilizerRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer { override fun render( tile: GravitationStabilizerBlockEntity, @@ -48,7 +47,7 @@ class GravitationStabilizerRenderer(private val context: BlockEntityRendererProv var len = 64.0 var lenI = 64 - val normal = tile.blockState.facingTwo.normal + val normal = tile.blockState[BlockRotationFreedom.XZ_XY].normal val level = tile.level var bhTile: BlackHoleBlockEntity? = null @@ -69,7 +68,7 @@ class GravitationStabilizerRenderer(private val context: BlockEntityRendererProv poseStack.pushPose() poseStack.translate(0.5, 0.5, 0.5) - val facing = tile.blockState.facingTwo + val facing = tile.blockState[BlockRotationFreedom.XZ_XY].front val rotateZ: Double val rotateY: Double 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 518de6d2b..015b6f26c 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,10 +9,10 @@ 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.core.TextComponent +import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.rotateWithBlockFacing -import ru.dbotthepony.mc.otm.core.math.rotationThree class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer { override fun render( @@ -27,7 +27,7 @@ class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context) return poseStack.pushPose() - poseStack.rotateWithBlockFacing(tile.blockState.rotationThree) + poseStack.rotateWithBlockFacing(tile.blockState[BlockRotationFreedom.XZ_XY_ZY]) poseStack.translate(0.5f, 0.5f, 0.5f) poseStack.scale(0.01f, 0.01f, 0.01f) 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 d39a40ba6..17ad146f5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -38,6 +38,8 @@ import net.minecraftforge.items.IItemHandler import net.minecraftforge.registries.ForgeRegistries import net.minecraftforge.registries.ForgeRegistry import net.minecraftforge.registries.IForgeRegistry +import ru.dbotthepony.mc.otm.core.math.BlockRotation +import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.util.readInt import ru.dbotthepony.mc.otm.core.util.readVarIntLE @@ -204,6 +206,10 @@ operator fun > StateHolder<*, *>.get(property: Property): T return getValue(property) } +operator fun StateHolder<*, *>.get(property: BlockRotationFreedom): BlockRotation { + return getValue(property.property) +} + operator fun , T : Comparable> S.set(property: Property, value: T): S { setValue(property, value) return this diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotationFreedom.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotationFreedom.kt index efe3ef08a..405446d33 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotationFreedom.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotationFreedom.kt @@ -1,30 +1,20 @@ package ru.dbotthepony.mc.otm.core.math import net.minecraft.core.Direction -import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.properties.EnumProperty -import ru.dbotthepony.mc.otm.core.get import java.util.EnumMap -internal inline val BlockState.rotationOne: BlockRotation get() = this[BlockRotationFreedom.ONE.property] -internal inline val BlockState.rotationTwo: BlockRotation get() = this[BlockRotationFreedom.TWO.property] -internal inline val BlockState.rotationThree: BlockRotation get() = this[BlockRotationFreedom.THREE.property] - -internal inline val BlockState.facingOne: Direction get() = this[BlockRotationFreedom.ONE.property].front -internal inline val BlockState.facingTwo: Direction get() = this[BlockRotationFreedom.TWO.property].front -internal inline val BlockState.facingThree: Direction get() = this[BlockRotationFreedom.THREE.property].front - /** * Controls the rotational freedom of block in space, employing [property] and [of] to get valid value from set of possible values */ enum class BlockRotationFreedom(vararg values: BlockRotation) { - ONE( + XZ( BlockRotation.NORTH, BlockRotation.SOUTH, BlockRotation.WEST, BlockRotation.EAST, ), - TWO( + XZ_XY( BlockRotation.DOWN, BlockRotation.UP, BlockRotation.NORTH, @@ -32,7 +22,7 @@ enum class BlockRotationFreedom(vararg values: BlockRotation) { BlockRotation.WEST, BlockRotation.EAST, ), - THREE( + XZ_XY_ZY( BlockRotation.DOWN, BlockRotation.UP, BlockRotation.NORTH, From be2424055d0132d8971811dde54c58d87ebd0f69 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 5 Aug 2023 21:13:55 +0700 Subject: [PATCH 0940/1199] Infinite water source block --- .../mc/otm/datagen/lang/English.kt | 1 + .../mc/otm/datagen/lang/Russian.kt | 1 + .../mc/otm/datagen/loot/LootTablesData.kt | 2 + .../datagen/recipes/CraftingTableRecipes.kt | 7 +++ .../dbotthepony/mc/otm/datagen/tags/Tags.kt | 2 + .../decorative/InfiniteWaterSourceBlock.kt | 25 ++++++++ .../InfiniteWaterSourceBlockEntity.kt | 61 +++++++++++++++++++ .../mc/otm/registry/MBlockEntities.kt | 2 + .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 2 + .../ru/dbotthepony/mc/otm/registry/MItems.kt | 6 +- .../ru/dbotthepony/mc/otm/registry/MNames.kt | 1 + 11 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/InfiniteWaterSourceBlock.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/InfiniteWaterSourceBlockEntity.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index da3651e91..1cb2eabec 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -400,6 +400,7 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.DRIVE_VIEWER, "Drive Viewer") add(MBlocks.BLACK_HOLE, "Local Anomalous Spacetime Dilation Singular Point") add(MBlocks.COBBLESTONE_GENERATOR, "Cobblestone Generator") + add(MBlocks.INFINITE_WATER_SOURCE, "Infinite Water Source") add(MBlocks.ESSENCE_STORAGE, "Essence Storage") add(MBlocks.ESSENCE_STORAGE, "desc", "Allows to store and retrieve experience levels") add(MBlocks.MATTER_RECONSTRUCTOR, "Matter Reconstructor") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 0e601f7f6..330c03ccc 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -403,6 +403,7 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.DRIVE_VIEWER, "Просмотрщик дисков конденсации") add(MBlocks.BLACK_HOLE, "Локализированная сингулярная точка аномального искажения пространства-времени") add(MBlocks.COBBLESTONE_GENERATOR, "Генератор булыжника") + add(MBlocks.INFINITE_WATER_SOURCE, "Неиссякаемый источник воды") add(MBlocks.ESSENCE_STORAGE, "Хранилище эссенции") add(MBlocks.ESSENCE_STORAGE, "desc", "Позволяет хранить очки опыта") add(MBlocks.MATTER_RECONSTRUCTOR, "Материальный реконструктор") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index 996aaa641..e5c1b8f4c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -51,6 +51,8 @@ fun addLootTables(lootTables: LootTables) { lootTables.dropsSelf(MBlocks.TRITANIUM_INGOT_BLOCK) { condition(ExplosionCondition.survivesExplosion()) } lootTables.dropsSelf(MBlocks.TRITANIUM_BARS) { condition(ExplosionCondition.survivesExplosion()) } + lootTables.dropsSelf(MBlocks.INFINITE_WATER_SOURCE) { condition(ExplosionCondition.survivesExplosion()) } + lootTables.dropsSelf(MBlocks.ENGINE) { condition(ExplosionCondition.survivesExplosion()) } for (block in MBlocks.TRITANIUM_ANVIL) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index 0510dfb3d..be441943c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -426,4 +426,11 @@ fun addCraftingTableRecipes(consumer: Consumer) { .row(MItems.ELECTROMAGNET, Items.FURNACE, MItems.ELECTROMAGNET) .unlockedBy(MItems.MACHINE_FRAME) .build(consumer) + + MatteryRecipe(MItems.INFINITE_WATER_SOURCE, category = machinesCategory) + .row(MItemTags.IRON_PLATES, MItemTags.IRON_PLATES, MItemTags.IRON_PLATES) + .rowAC(Items.WATER_BUCKET, Items.WATER_BUCKET) + .row(MItemTags.IRON_PLATES, MItemTags.IRON_PLATES, MItemTags.IRON_PLATES) + .unlockedBy(Items.WATER_BUCKET) + .build(consumer) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index 33d5d407b..c266a923c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -204,6 +204,8 @@ fun addTags(tagsProvider: TagsProvider) { tagsProvider.requiresPickaxe(MBlocks.TRITANIUM_STRIPED_SLAB, Tiers.IRON) tagsProvider.requiresPickaxe(MBlocks.CARBON_FIBRE_BLOCK, Tiers.IRON) + tagsProvider.requiresPickaxe(MBlocks.INFINITE_WATER_SOURCE, Tiers.STONE) + tagsProvider.requiresPickaxe(MRegistry.CARGO_CRATES.allBlocks.values, Tiers.IRON) tagsProvider.requiresPickaxe(MRegistry.VENT.allBlocks.values, Tiers.IRON) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/InfiniteWaterSourceBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/InfiniteWaterSourceBlock.kt new file mode 100644 index 000000000..faab35e82 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/InfiniteWaterSourceBlock.kt @@ -0,0 +1,25 @@ +package ru.dbotthepony.mc.otm.block.decorative + +import net.minecraft.core.BlockPos +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.EntityBlock +import net.minecraft.world.level.block.entity.BlockEntity +import net.minecraft.world.level.block.entity.BlockEntityTicker +import net.minecraft.world.level.block.entity.BlockEntityType +import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.level.material.MapColor +import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.entity.decorative.InfiniteWaterSourceBlockEntity + +class InfiniteWaterSourceBlock : RotatableMatteryBlock(Properties.of().destroyTime(1.5f).explosionResistance(10f).requiresCorrectToolForDrops().mapColor(MapColor.WATER)), EntityBlock { + override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { + return InfiniteWaterSourceBlockEntity(p_153215_, p_153216_) + } + + override fun getTicker(p_153212_: Level, p_153213_: BlockState, p_153214_: BlockEntityType): BlockEntityTicker? { + if (p_153212_.isClientSide) + return null + + return BlockEntityTicker { _, _, _, p_155256_ -> if (p_155256_ is InfiniteWaterSourceBlockEntity) p_155256_.tick() } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/InfiniteWaterSourceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/InfiniteWaterSourceBlockEntity.kt new file mode 100644 index 000000000..7a5e54219 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/InfiniteWaterSourceBlockEntity.kt @@ -0,0 +1,61 @@ +package ru.dbotthepony.mc.otm.block.entity.decorative + +import net.minecraft.core.BlockPos +import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.level.material.Fluids +import net.minecraftforge.common.capabilities.ForgeCapabilities +import net.minecraftforge.fluids.FluidStack +import net.minecraftforge.fluids.capability.IFluidHandler +import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity +import ru.dbotthepony.mc.otm.core.ifPresentK +import ru.dbotthepony.mc.otm.registry.MBlockEntities + +class InfiniteWaterSourceBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryBlockEntity(MBlockEntities.INFINITE_WATER_SOURCE, blockPos, blockState), IFluidHandler { + override fun getTanks(): Int { + return 1 + } + + override fun getFluidInTank(tank: Int): FluidStack { + return FluidStack(Fluids.WATER, Int.MAX_VALUE) + } + + override fun getTankCapacity(tank: Int): Int { + return Int.MAX_VALUE + } + + override fun isFluidValid(tank: Int, stack: FluidStack): Boolean { + return false + } + + override fun fill(resource: FluidStack, action: IFluidHandler.FluidAction): Int { + return 0 + } + + override fun drain(resource: FluidStack, action: IFluidHandler.FluidAction): FluidStack { + if (resource.fluid == Fluids.WATER || resource.fluid == Fluids.FLOWING_WATER) { + return resource.copy() + } + + return FluidStack.EMPTY + } + + override fun drain(maxDrain: Int, action: IFluidHandler.FluidAction): FluidStack { + return FluidStack(Fluids.WATER, maxDrain) + } + + init { + exposeGlobally(ForgeCapabilities.FLUID_HANDLER, this) + + for (side in sides.values) { + val tracker = side.track(ForgeCapabilities.FLUID_HANDLER) + + val ticker = tickList.Ticker { + tracker.get().ifPresentK { + it.fill(FluidStack(Fluids.WATER, Int.MAX_VALUE), IFluidHandler.FluidAction.EXECUTE) + } + } + + tracker.addListener { ticker.isEnabled = it.isPresent } + } + } +} 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 5a2dfde67..1094cc4a6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt @@ -15,6 +15,7 @@ import ru.dbotthepony.mc.otm.block.entity.blackhole.BlockEntitySphereDebugger import ru.dbotthepony.mc.otm.block.entity.decorative.CargoCrateBlockEntity import ru.dbotthepony.mc.otm.block.entity.decorative.FluidTankBlockEntity import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity +import ru.dbotthepony.mc.otm.block.entity.decorative.InfiniteWaterSourceBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.* import ru.dbotthepony.mc.otm.block.entity.storage.* import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity @@ -58,6 +59,7 @@ object MBlockEntities { val ANDROID_CHARGER: BlockEntityType by registry.register(MNames.ANDROID_CHARGER) { BlockEntityType.Builder.of(::AndroidChargerBlockEntity, MBlocks.ANDROID_CHARGER).build(null) } val ANDROID_CHARGER_MIDDLE: BlockEntityType by registry.register(MNames.ANDROID_CHARGER + "_middle") { BlockEntityType.Builder.of(::AndroidChargerMiddleBlockEntity, MBlocks.ANDROID_CHARGER).build(null) } val ANDROID_CHARGER_TOP: BlockEntityType by registry.register(MNames.ANDROID_CHARGER + "_top") { BlockEntityType.Builder.of(::AndroidChargerTopBlockEntity, MBlocks.ANDROID_CHARGER).build(null) } + val INFINITE_WATER_SOURCE: BlockEntityType by registry.register(MNames.INFINITE_WATER_SOURCE) { BlockEntityType.Builder.of(::InfiniteWaterSourceBlockEntity, MBlocks.INFINITE_WATER_SOURCE).build(null) } val POWERED_FURNACE: BlockEntityType by registry.register(MNames.POWERED_FURNACE) { BlockEntityType.Builder.of({ a, b -> MBlocks.POWERED_FURNACE.newBlockEntity(a, b) }, MBlocks.POWERED_FURNACE).build(null) } val POWERED_BLAST_FURNACE: BlockEntityType by registry.register(MNames.POWERED_BLAST_FURNACE) { BlockEntityType.Builder.of({ a, b -> MBlocks.POWERED_BLAST_FURNACE.newBlockEntity(a, b) }, MBlocks.POWERED_BLAST_FURNACE).build(null) } 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 7dc016d49..a437245d5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -42,6 +42,7 @@ import ru.dbotthepony.mc.otm.block.StorageCableBlock import ru.dbotthepony.mc.otm.block.decorative.EngineBlock import ru.dbotthepony.mc.otm.block.decorative.FluidTankBlock import ru.dbotthepony.mc.otm.block.decorative.HoloSignBlock +import ru.dbotthepony.mc.otm.block.decorative.InfiniteWaterSourceBlock import ru.dbotthepony.mc.otm.block.matter.MatterReconstructorBlock import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock import ru.dbotthepony.mc.otm.block.matter.MatterCapacitorBankBlock @@ -95,6 +96,7 @@ object MBlocks { val MATTER_RECYCLER: Block by registry.register(MNames.MATTER_RECYCLER) { MatterRecyclerBlock() } val ENERGY_SERVO: Block by registry.register(MNames.ENERGY_SERVO) { EnergyServoBlock() } val COBBLESTONE_GENERATOR: Block by registry.register(MNames.COBBLESTONE_GENERATOR) { CobblerBlock() } + val INFINITE_WATER_SOURCE: Block by registry.register(MNames.INFINITE_WATER_SOURCE) { InfiniteWaterSourceBlock() } val ESSENCE_STORAGE: EssenceStorageBlock by registry.register(MNames.ESSENCE_STORAGE) { EssenceStorageBlock() } val MATTER_RECONSTRUCTOR: MatterReconstructorBlock by registry.register(MNames.MATTER_RECONSTRUCTOR) { MatterReconstructorBlock() } 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 7fe271ea3..443b08dbd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -122,6 +122,8 @@ object MItems { } } + val INFINITE_WATER_SOURCE: BlockItem by registry.register(MNames.INFINITE_WATER_SOURCE) { BlockItem(MBlocks.INFINITE_WATER_SOURCE, DEFAULT_PROPERTIES) } + val ESSENCE_STORAGE: BlockItem by registry.register(MNames.ESSENCE_STORAGE) { object : BlockItem(MBlocks.ESSENCE_STORAGE, DEFAULT_PROPERTIES) { override fun appendHoverText(p_40572_: ItemStack, p_40573_: Level?, p_40574_: MutableList, p_40575_: TooltipFlag) { @@ -148,8 +150,8 @@ object MItems { // ::STORAGE_BUS, ::STORAGE_IMPORTER, ::STORAGE_EXPORTER, ::DRIVE_VIEWER, // ::DRIVE_RACK, ::ITEM_MONITOR, ::STORAGE_CABLE, ::STORAGE_POWER_SUPPLIER, ::ENERGY_SERVO, - ::PHANTOM_ATTRACTOR, ::GRAVITATION_STABILIZER, ::COBBLESTONE_GENERATOR, ::ESSENCE_STORAGE, - ::MATTER_RECONSTRUCTOR + ::PHANTOM_ATTRACTOR, ::GRAVITATION_STABILIZER, ::COBBLESTONE_GENERATOR, ::INFINITE_WATER_SOURCE, + ::ESSENCE_STORAGE, ::MATTER_RECONSTRUCTOR ) val DEBUG_EXPLOSION_SMALL: Item by registry.register(MNames.DEBUG_EXPLOSION_SMALL) { BlockItem(MBlocks.DEBUG_EXPLOSION_SMALL, Item.Properties().stacksTo(64)) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index 2cf4382a0..633047e10 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -13,6 +13,7 @@ object MNames { const val HOLO_SIGN = "holo_sign" const val FLUID_TANK = "fluid_tank" const val ANDROID_CHARGER = "android_charger" + const val INFINITE_WATER_SOURCE = "infinite_water_source" // blocks const val ANDROID_STATION = "android_station" From 93d4329acd596759c9de3d5efc6efb5d3f0f95a9 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 6 Aug 2023 01:39:16 +0700 Subject: [PATCH 0941/1199] Refine graphs logic, make neighbouring be not limited on in-world directions, properly add freshly created nodes to graph after they have been properly initialized --- .../dbotthepony/mc/otm/GlobalEventHandler.kt | 5 +- .../dbotthepony/mc/otm/block/entity/Cables.kt | 40 ++- .../entity/storage/StorageBusBlockEntity.kt | 20 +- .../block/entity/storage/StorageInterfaces.kt | 28 +- .../mc/otm/graph/Abstract6Graph.kt | 172 ----------- .../ru/dbotthepony/mc/otm/graph/Graph6Node.kt | 268 ---------------- .../ru/dbotthepony/mc/otm/graph/GraphNode.kt | 292 ++++++++++++++++++ .../dbotthepony/mc/otm/graph/GraphNodeList.kt | 199 ++++++++++++ .../mc/otm/graph/matter/MatterGraph.kt | 4 +- .../mc/otm/graph/matter/MatterNode.kt | 4 +- .../mc/otm/graph/storage/StorageGraph.kt | 15 +- .../mc/otm/graph/storage/StorageNode.kt | 11 +- 12 files changed, 558 insertions(+), 500 deletions(-) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/graph/Abstract6Graph.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/graph/Graph6Node.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/graph/GraphNode.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/graph/GraphNodeList.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt index eec7a0839..2d66cbc24 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt @@ -16,12 +16,11 @@ import net.minecraftforge.event.server.ServerStoppingEvent import net.minecraftforge.fml.loading.FMLLoader import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.capability.AbstractProfiledStorage -import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.util.IConditionalTickable import ru.dbotthepony.mc.otm.core.util.ITickable import ru.dbotthepony.mc.otm.core.util.TickList -import ru.dbotthepony.mc.otm.graph.Abstract6Graph +import ru.dbotthepony.mc.otm.graph.GraphNodeList import ru.dbotthepony.mc.otm.network.MatteryNetworkChannel import java.util.* @@ -150,7 +149,7 @@ fun onServerTick(event: ServerTickEvent) { } else { postServerTick.tick() // чтоб не плодить кучу подписчиков, вызовем напрямую отсюда - Abstract6Graph.tick() + GraphNodeList.tick() AbstractProfiledStorage.onServerPostTick() MatteryNetworkChannel.onServerPostTick() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Cables.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Cables.kt index 12d498cf7..9301f3efc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Cables.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Cables.kt @@ -15,18 +15,22 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities class MatterCableBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryBlockEntity(MBlockEntities.MATTER_CABLE, p_155229_, p_155230_) { val matterNode = object : MatterNode() { - override fun onNeighbour(direction: Direction) { - val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, true) + override fun onNeighbour(link: Link) { + if (link is DirectionLink) { + val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[link.direction]!!, true) - if (newState !== blockState && SERVER_IS_LIVE) - level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + if (newState !== blockState && SERVER_IS_LIVE) + level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + } } - override fun onUnNeighbour(direction: Direction) { - val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, false) + override fun onUnNeighbour(link: Link) { + if (link is DirectionLink) { + val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[link.direction]!!, false) - if (newState !== blockState && SERVER_IS_LIVE) - level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + if (newState !== blockState && SERVER_IS_LIVE) + level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + } } } @@ -50,18 +54,22 @@ class StorageCableBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matt override fun attachComponents(to: StorageGraph) {} override fun removeComponents(from: StorageGraph) {} - override fun onNeighbour(direction: Direction) { - val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, true) + override fun onNeighbour(link: Link) { + if (link is DirectionLink) { + val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[link.direction]!!, true) - if (newState !== blockState && SERVER_IS_LIVE) - level!!.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + if (newState !== blockState && SERVER_IS_LIVE) + level!!.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + } } - override fun onUnNeighbour(direction: Direction) { - val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, false) + override fun onUnNeighbour(link: Link) { + if (link is DirectionLink) { + val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[link.direction]!!, false) - if (newState !== blockState && SERVER_IS_LIVE) - level!!.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + if (newState !== blockState && SERVER_IS_LIVE) + level!!.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt index 3153d60da..2e5635e39 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt @@ -69,18 +69,22 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter } val cell: StorageNode = object : StorageNode(energy) { - override fun onNeighbour(direction: Direction) { - val newState = this@StorageBusBlockEntity.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, true) + override fun onNeighbour(link: Link) { + if (link is DirectionLink) { + val newState = this@StorageBusBlockEntity.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[link.direction]!!, true) - if (newState !== this@StorageBusBlockEntity.blockState && SERVER_IS_LIVE) - level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + if (newState !== this@StorageBusBlockEntity.blockState && SERVER_IS_LIVE) + level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + } } - override fun onUnNeighbour(direction: Direction) { - val newState = this@StorageBusBlockEntity.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, false) + override fun onUnNeighbour(link: Link) { + if (link is DirectionLink) { + val newState = this@StorageBusBlockEntity.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[link.direction]!!, false) - if (newState !== this@StorageBusBlockEntity.blockState && SERVER_IS_LIVE) - level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + if (newState !== this@StorageBusBlockEntity.blockState && SERVER_IS_LIVE) + level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt index 547ece08f..b6b548c32 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt @@ -58,24 +58,28 @@ abstract class AbstractStorageImportExport( } val cell: StorageNode = object : StorageNode(energy) { - override fun onNeighbour(direction: Direction) { - level?.once { - if (!isRemoved) { - val newState = this@AbstractStorageImportExport.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, true) + override fun onNeighbour(link: Link) { + if (link is DirectionLink) { + level?.once { + if (!isRemoved) { + val newState = this@AbstractStorageImportExport.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[link.direction]!!, true) - if (newState !== this@AbstractStorageImportExport.blockState && SERVER_IS_LIVE) - level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + if (newState !== this@AbstractStorageImportExport.blockState && SERVER_IS_LIVE) + level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + } } } } - override fun onUnNeighbour(direction: Direction) { - level?.once { - if (!isRemoved) { - val newState = this@AbstractStorageImportExport.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[direction]!!, false) + override fun onUnNeighbour(link: Link) { + if (link is DirectionLink) { + level?.once { + if (!isRemoved) { + val newState = this@AbstractStorageImportExport.blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[link.direction]!!, false) - if (newState !== this@AbstractStorageImportExport.blockState && SERVER_IS_LIVE) - level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + if (newState !== this@AbstractStorageImportExport.blockState && SERVER_IS_LIVE) + level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Abstract6Graph.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Abstract6Graph.kt deleted file mode 100644 index 6999a110e..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Abstract6Graph.kt +++ /dev/null @@ -1,172 +0,0 @@ -package ru.dbotthepony.mc.otm.graph - -import ru.dbotthepony.mc.otm.core.util.IConditionalTickable -import ru.dbotthepony.mc.otm.core.util.ITickable -import java.lang.ref.WeakReference -import java.util.* -import kotlin.collections.ArrayList - -open class Abstract6Graph, G : Abstract6Graph> : IConditionalTickable { - private val nodesInternal = ArrayList() - private val conditional = ArrayList() - private val always = ArrayList() - - protected val nodes: List = Collections.unmodifiableList(nodesInternal) - - val size get() = nodesInternal.size - - var isMerged = false - private set - - private var isTicking = false - - /** - * Allows storing arbitrary data by external code - */ - val userData = HashMap() - - open fun onNodeRemoved(node: N) {} - open fun onNodeAdded(node: N) {} - open fun onMergedInto(other: G) {} - - protected open fun innerTick(): Boolean { - return false - } - - final override fun tick(): Boolean { - if (isMerged) - return false - - // позволяет вершинам изменять список тикающих вершин - for (i in conditional.size - 1 downTo 0) { - val node = conditional[i] - - if (!node.tick()) { - conditional.removeAt(i) - } - } - - // позволяет вершинам изменять список тикающих вершин - for (node in always.size - 1 downTo 0) { - always[node].tick() - } - - return innerTick() || always.isNotEmpty() || conditional.isNotEmpty() - } - - fun addNode(node: N): Boolean { - if (node in nodesInternal) - return false - - nodesInternal.add(node) - - if (node is IConditionalTickable) { - conditional.add(node) - - if (!isTicking) { - isTicking = true - next.add(WeakReference(this)) - } - } else if (node is ITickable) { - always.add(node) - - if (!isTicking) { - isTicking = true - next.add(WeakReference(this)) - } - } - - onNodeAdded(node) - return true - } - - fun removeNode(node: N): Boolean { - if (!nodesInternal.remove(node)) - return false - - nodesInternal.remove(node) - - if (node is IConditionalTickable) - conditional.remove(node) - else if (node is ITickable) - always.remove(node) - - onNodeRemoved(node) - return true - } - - fun retain(nodes: Set) { - for (i in this.nodesInternal.size - 1 downTo 0) { - if (this.nodesInternal[i] !in nodes) { - val node = this.nodesInternal[i] - - this.nodesInternal.removeAt(i) - - if (node is IConditionalTickable) - conditional.remove(node) - else if (node is ITickable) - always.remove(node) - - onNodeRemoved(node) - } - } - } - - fun merge(other: G, setter: (N, G) -> Unit): G { - if (other === this) - return this - - if (size >= other.size) { - for (node in other.nodesInternal) { - nodesInternal.add(node) - setter.invoke(node, this as G) - onNodeAdded(node) - - if (node is IConditionalTickable) { - conditional.add(node) - - if (!isTicking) { - isTicking = true - next.add(WeakReference(this)) - } - } else if (node is ITickable) { - always.add(node) - - if (!isTicking) { - isTicking = true - next.add(WeakReference(this)) - } - } - } - - other.isMerged = true - other.onMergedInto(this as G) - return this - } else { - return other.merge(this as G, setter) - } - } - - companion object { - private val graphs = ArrayList>>() - private val next = ArrayList>>() - - fun tick() { - if (next.isNotEmpty()) { - graphs.addAll(next) - next.clear() - } - - val iterator = graphs.iterator() - - for (value in iterator) { - val graph = value.get() - - if (graph == null || !graph.tick()) { - graph?.isTicking = false - iterator.remove() - } - } - } - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Graph6Node.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Graph6Node.kt deleted file mode 100644 index 9c0ff9ebe..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/Graph6Node.kt +++ /dev/null @@ -1,268 +0,0 @@ -package ru.dbotthepony.mc.otm.graph - -import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet -import net.minecraft.core.BlockPos -import net.minecraft.core.Direction -import net.minecraft.core.SectionPos -import net.minecraft.server.level.ServerLevel -import net.minecraft.world.level.block.entity.BlockEntity -import net.minecraftforge.common.capabilities.Capability -import ru.dbotthepony.mc.otm.addTicker -import ru.dbotthepony.mc.otm.core.math.plus -import ru.dbotthepony.mc.otm.core.math.unaryMinus -import ru.dbotthepony.mc.otm.core.orNull -import java.util.EnumMap -import java.util.concurrent.atomic.AtomicInteger - -open class Graph6Node, G : Abstract6Graph>(val graphFactory: () -> G) { - private val neighbours = EnumMap(Direction::class.java) - - var graph: G = graphFactory.invoke() - private set - - init { - graph.addNode(this as N) - } - - private var seen: Int = 0 - - operator fun get(direction: Direction): N? = neighbours[direction] - - operator fun set(direction: Direction, node: N?) { - set(direction, node, false) - } - - fun set(direction: Direction, node: N?, allowReplacement: Boolean) { - check(isValid) { "Can not neighbour any node while this node is invalid" } - - val old = neighbours[direction] - if (old === node) return - - if (old != null) - breakConnection(this as N, old, direction) - - if (node != null) { - require(node.isValid) { "Can not neighbour invalid node" } - - val opposite = -direction - - if (allowReplacement) { - node.neighbours[opposite]?.let { - breakConnection(node, it, opposite) - } - - check(node.neighbours[opposite] == null) { "$node didn't break connection at direction $opposite" } - } else { - check(node.neighbours[opposite] == null) { "Trying to form connection from $this to $node at direction $direction, but $node already has neighbour at $opposite (${node.neighbours[opposite]})!" } - } - - node.neighbours[opposite] = this as N - neighbours[direction] = node - node.graph.merge(graph, setter) - node.onNeighbour(opposite) - onNeighbour(direction) - } else { - neighbours.remove(direction) - } - } - - var top: N? - get() = neighbours[Direction.UP] - set(value) { - set(Direction.UP, value) - } - - var bottom: N? - get() = neighbours[Direction.DOWN] - set(value) { - set(Direction.DOWN, value) - } - - var south: N? - get() = neighbours[Direction.SOUTH] - set(value) { - set(Direction.SOUTH, value) - } - - var north: N? - get() = neighbours[Direction.NORTH] - set(value) { - set(Direction.NORTH, value) - } - - var west: N? - get() = neighbours[Direction.WEST] - set(value) { - set(Direction.WEST, value) - } - - var east: N? - get() = neighbours[Direction.EAST] - set(value) { - set(Direction.EAST, value) - } - - open fun onNeighbour(direction: Direction) {} - open fun onUnNeighbour(direction: Direction) {} - - protected open fun invalidate() {} - protected open fun revive() {} - - var isValid: Boolean = true - set(value) { - if (value == field) return - field = value - - if (!value) { - val neighbours = ArrayList(neighbours.entries) - - for ((dir, node) in neighbours) { - breakConnection(this as N, node, dir) - } - - graph.removeNode(this as N) - invalidate() - } else { - revive() - } - } - - fun discover( - level: ServerLevel, - blockPos: BlockPos, - nodeGetter: (BlockEntity) -> N? - ) { - if (!isValid) return - - level.addTicker { - isValid && !discoverStep(level, blockPos, nodeGetter) - } - } - - fun discover( - level: ServerLevel, - blockPos: BlockPos, - capability: Capability - ) { - if (!isValid) return - - level.addTicker { - isValid && !discoverStep(level, blockPos) { it.getCapability(capability).orNull() } - } - } - - fun discover(blockEntity: BlockEntity, nodeGetter: (BlockEntity) -> N?) { - discover(blockEntity.level as? ServerLevel ?: return, blockEntity.blockPos, nodeGetter) - } - - fun discover(blockEntity: BlockEntity, capability: Capability) { - discover(blockEntity.level as? ServerLevel ?: return, blockEntity.blockPos, capability) - } - - fun discoverStep( - level: ServerLevel, - blockPos: BlockPos, - nodeGetter: (BlockEntity) -> N?, - ): Boolean { - if (!isValid) return false - var fullDiscovery = true - - for (dir in directions) { - val offset = blockPos + dir - val chunk = level.chunkSource.getChunkNow(SectionPos.blockToSectionCoord(offset.x), SectionPos.blockToSectionCoord(offset.z)) - - if (chunk == null) { - fullDiscovery = false - set(dir, null) - continue - } - - val entity = chunk.getBlockEntity(offset) - - if (entity != null) { - set(dir, nodeGetter(entity)) - } else { - set(dir, null) - } - } - - return fullDiscovery - } - - companion object { - private val setter = Graph6Node<*, *>::graph::set - private val nextSeen = AtomicInteger() - private val directions = Direction.values() - - private fun , G : Abstract6Graph> breakConnection(a: N, b: N, direction: Direction) { - val opposite = -direction - - require(a.neighbours[direction] === b) { "$a does not neighbour with $b at direction $direction (forward)" } - require(b.neighbours[opposite] === a) { "$b does not neighbour with $a at direction $opposite (backward)" } - require(a.graph === b.graph) { "$a and $b belong to different graphs (${a.graph} vs ${b.graph})" } - - a.neighbours.remove(direction) - b.neighbours.remove(opposite) - - val seen = nextSeen.incrementAndGet() - val flood1 = flood(a, seen) - - if (b.seen != seen) { - val flood2 = flood(b, seen) - - val big: ArrayList - val small: ArrayList - - if (flood1.size >= flood2.size) { - big = flood1 - small = flood2 - } else { - big = flood2 - small = flood1 - } - - a.graph.retain(ReferenceOpenHashSet(big)) - val newGraph = a.graphFactory.invoke() - - for (node in small) { - node.graph = newGraph - } - - for (node in small) { - if (node.isValid) { - newGraph.addNode(node) - } - } - } - - if (a.isValid) - a.onUnNeighbour(direction) - - if (b.isValid) - b.onUnNeighbour(opposite) - } - - private fun , G : Abstract6Graph> flood(startingNode: N, seen: Int): ArrayList { - val unopen = ArrayList() - val result = ArrayList() - unopen.add(startingNode) - - while (unopen.isNotEmpty()) { - val last = unopen.removeLast() - - if (last.seen < seen) { - result.add(last) - last.seen = seen - - for (node in last.neighbours.values) { - if (node.seen < seen) { - unopen.add(node) - } - } - } - } - - return result - } - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/GraphNode.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/GraphNode.kt new file mode 100644 index 000000000..64d45298b --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/GraphNode.kt @@ -0,0 +1,292 @@ +package ru.dbotthepony.mc.otm.graph + +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap +import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet +import net.minecraft.core.BlockPos +import net.minecraft.core.Direction +import net.minecraft.core.SectionPos +import net.minecraft.server.level.ServerLevel +import net.minecraft.world.level.block.entity.BlockEntity +import net.minecraftforge.common.capabilities.Capability +import ru.dbotthepony.mc.otm.addTicker +import ru.dbotthepony.mc.otm.core.math.plus +import ru.dbotthepony.mc.otm.core.orNull + +open class GraphNode, G : GraphNodeList>(val graphFactory: () -> G) { + interface Link { + val opposite: Link + operator fun unaryMinus() = opposite + } + + data class DirectionLink(val direction: Direction) : Link { + override val opposite: Link + get() = wrapped[direction.opposite.ordinal] + + override fun toString(): String { + return "Link[$direction]" + } + } + + private val neighbours = Object2ObjectOpenHashMap() + + var graph: G = graphFactory.invoke() + internal set + + init { + check(graph.addNodeQueued(this as N)) + } + + private var seen: Int = 0 + + operator fun get(key: Link): N? = neighbours[key] + + operator fun set(key: Link, node: N?) { + set(key, node, false) + } + + fun set(key: Link, target: N?, allowReplacement: Boolean) { + check(isValid) { "Can not neighbour any node while this node is invalid" } + + val old = neighbours[key] + if (old === target) return + + if (old != null) + breakConnection(this as N, old, key) + + if (target != null) { + require(target.isValid) { "Can not neighbour invalid node" } + + val opposite = key.opposite + + if (allowReplacement) { + target.neighbours[opposite]?.let { + breakConnection(target, it, opposite) + } + + check(target.neighbours[opposite] == null) { "$target didn't break connection at direction $opposite" } + } else { + check(target.neighbours[opposite] == null) { "Trying to form connection from $this to $target at $key, but $target already has neighbour at $opposite (${target.neighbours[opposite]})!" } + } + + target.neighbours[opposite] = this as N + neighbours[key] = target + target.graph.merge(graph) + target.onNeighbour(opposite) + onNeighbour(key) + } else { + neighbours.remove(key) + } + } + + var top: N? + get() = neighbours[UP] + set(value) { + set(UP, value) + } + + var bottom: N? + get() = neighbours[DOWN] + set(value) { + set(DOWN, value) + } + + var south: N? + get() = neighbours[SOUTH] + set(value) { + set(SOUTH, value) + } + + var north: N? + get() = neighbours[NORTH] + set(value) { + set(NORTH, value) + } + + var west: N? + get() = neighbours[WEST] + set(value) { + set(WEST, value) + } + + var east: N? + get() = neighbours[EAST] + set(value) { + set(EAST, value) + } + + protected open fun onNeighbour(link: Link) {} + protected open fun onUnNeighbour(link: Link) {} + + protected open fun invalidate() {} + protected open fun revive() {} + + var isValid: Boolean = true + set(value) { + if (value == field) return + field = value + + if (!value) { + val neighbours = neighbours.entries.map { it.key to it.value } + + for ((link, node) in neighbours) { + removeNeighbours(this as N, node, link) + } + + graph.removeNode(this as N) + rebuildGraphs(neighbours.map { it.second }) + invalidate() + } else { + revive() + } + } + + fun discover( + level: ServerLevel, + blockPos: BlockPos, + nodeGetter: (BlockEntity) -> N? + ) { + if (!isValid) return + + level.addTicker { + isValid && !discoverStep(level, blockPos, nodeGetter) + } + } + + fun discover( + level: ServerLevel, + blockPos: BlockPos, + capability: Capability + ) { + if (!isValid) return + + level.addTicker { + isValid && !discoverStep(level, blockPos) { it.getCapability(capability).orNull() } + } + } + + fun discover(blockEntity: BlockEntity, nodeGetter: (BlockEntity) -> N?) { + discover(blockEntity.level as? ServerLevel ?: return, blockEntity.blockPos, nodeGetter) + } + + fun discover(blockEntity: BlockEntity, capability: Capability) { + discover(blockEntity.level as? ServerLevel ?: return, blockEntity.blockPos, capability) + } + + fun discoverStep( + level: ServerLevel, + blockPos: BlockPos, + nodeGetter: (BlockEntity) -> N?, + ): Boolean { + if (!isValid) return false + var fullDiscovery = true + + for (dir in wrapped) { + val offset = blockPos + dir.direction + val chunk = level.chunkSource.getChunkNow(SectionPos.blockToSectionCoord(offset.x), SectionPos.blockToSectionCoord(offset.z)) + + if (chunk == null) { + fullDiscovery = false + set(dir, null) + continue + } + + val entity = chunk.getBlockEntity(offset) + + if (entity != null) { + set(dir, nodeGetter(entity)) + } else { + set(dir, null) + } + } + + return fullDiscovery + } + + companion object { + private var nextSeen = 0 + private val wrapped = Direction.entries.map { DirectionLink(it) } + + fun link(direction: Direction): Link { + return wrapped[direction.ordinal] + } + + val UP = link(Direction.UP) + val DOWN = link(Direction.DOWN) + val NORTH = link(Direction.NORTH) + val SOUTH = link(Direction.SOUTH) + val WEST = link(Direction.WEST) + val EAST = link(Direction.EAST) + + private fun , G : GraphNodeList> removeNeighbours(a: N, b: N, key: Link) { + val opposite = key.opposite + + // проверяем, действительно ли a соединён с b по key + require(a.neighbours[key] === b) { "$a does not neighbour with $b at $key (a -> b)" } + + // проверяем обратную связь + require(b.neighbours[opposite] === a) { "$b does not neighbour with $a at $opposite (b -> a)" } + + // находятся ли они в одном графе + require(a.graph === b.graph) { "$a and $b belong to different graphs (${a.graph} / ${b.graph})" } + + a.neighbours.remove(key) + b.neighbours.remove(opposite) + + if (a.isValid) a.onUnNeighbour(key) + if (b.isValid) b.onUnNeighbour(key.opposite) + } + + private fun , G : GraphNodeList> rebuildGraphs(nodes: Collection) { + if (nodes.isEmpty()) + return + + val seen = ++nextSeen + val floods = ArrayList>() + + for (node in nodes) { + if (node.seen < seen) { + floods.add(flood(node, seen)) + } + } + + floods.sortedBy { it.first().graph.size } + floods.first().first().graph.retain(ReferenceOpenHashSet(floods.first())) + + for (i in 1 until floods.size) { + val graph = floods[i].first().graphFactory.invoke() + + for (node in floods[i]) { + graph.addNode(node) + } + } + } + + private fun , G : GraphNodeList> breakConnection(a: N, b: N, key: Link) { + removeNeighbours(a, b, key) + rebuildGraphs(listOf(a, b)) + } + + private fun , G : GraphNodeList> flood(startingNode: N, seen: Int): ArrayList { + val unopen = ArrayList() + val result = ArrayList() + unopen.add(startingNode) + + while (unopen.isNotEmpty()) { + val last = unopen.removeLast() + + if (last.seen < seen) { + result.add(last) + last.seen = seen + + for (node in last.neighbours.values) { + if (node.seen < seen) { + unopen.add(node) + } + } + } + } + + return result + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/GraphNodeList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/GraphNodeList.kt new file mode 100644 index 000000000..763b7beeb --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/GraphNodeList.kt @@ -0,0 +1,199 @@ +package ru.dbotthepony.mc.otm.graph + +import ru.dbotthepony.mc.otm.core.util.IConditionalTickable +import ru.dbotthepony.mc.otm.core.util.ITickable +import java.lang.ref.WeakReference +import java.util.* +import kotlin.collections.ArrayDeque +import kotlin.collections.ArrayList + +open class GraphNodeList, G : GraphNodeList> : IConditionalTickable { + private val queuedAdd = ArrayDeque() + private val queuedRemove = ArrayDeque() + private val nodesInternal = ArrayList() + private val conditional = ArrayList() + private val always = ArrayList() + private var isTicking = false + private var shouldQueueChanges = false + + protected val nodes: List = Collections.unmodifiableList(nodesInternal) + + val size get() = nodesInternal.size + + var isValid = true + private set + + /** + * Allows storing arbitrary data by external code + */ + val userData = HashMap() + + protected open fun onNodeRemoved(node: N) {} + protected open fun onNodeAdded(node: N) {} + + protected open fun innerTick(): Boolean { + return false + } + + private fun addNow(node: N) { + node.graph = this as G + nodesInternal.add(node) + + if (node is IConditionalTickable) + conditional.add(node) + else if (node is ITickable) + always.add(node) + + onNodeAdded(node) + } + + private fun removeNow(node: N, removeFromList: Boolean = true) { + if (removeFromList) + nodesInternal.remove(node) + + if (node is IConditionalTickable) + conditional.remove(node) + else if (node is ITickable) + always.remove(node) + + onNodeRemoved(node) + } + + private fun processAddQueue() { + while (queuedAdd.isNotEmpty()) { + addNow(queuedAdd.removeFirst()) + } + } + + private fun processRemoveQueue() { + while (queuedRemove.isNotEmpty()) { + removeNow(queuedRemove.removeFirst()) + } + } + + private fun processQueues() { + processRemoveQueue() + processAddQueue() + } + + final override fun tick(): Boolean { + if (!isValid) + return false + + processQueues() + conditional.removeIf { !it.tick() } + for (node in always) node.tick() + + return innerTick() || always.isNotEmpty() || conditional.isNotEmpty() + } + + fun addNodeQueued(node: N): Boolean { + check(isValid) { "$this is no longer valid" } + + if (node in nodesInternal || node in queuedAdd) + return false + + queuedAdd.add(node) + beginTicking() + return true + } + + fun addNode(node: N): Boolean { + check(isValid) { "$this is no longer valid" } + + if (node in nodesInternal) + return false + + if (shouldQueueChanges) { + if (node in queuedAdd) return false + queuedAdd.add(node) + beginTicking() + } else { + queuedAdd.remove(node) + addNow(node) + } + + return true + } + + fun removeNode(node: N): Boolean { + check(isValid) { "$this is no longer valid" } + + if (node !in nodesInternal) + return false + + if (shouldQueueChanges) { + if (node in queuedRemove) return false + queuedRemove.add(node) + beginTicking() + } else { + queuedRemove.remove(node) + removeNow(node) + } + + return true + } + + fun retain(nodes: Set) { + check(isValid) { "$this is no longer valid" } + queuedAdd.retainAll(nodes) + nodesInternal.removeIf { + if (it !in nodes) { + removeNow(it, false) + true + } else { + false + } + } + } + + fun merge(other: G): G { + if (other === this) + return this + + check(isValid) { "$this is no longer valid" } + + if (size >= other.size) { + shouldQueueChanges = true + other.processQueues() + other.nodesInternal.forEach { if (it.isValid) addNow(it) } + processQueues() + shouldQueueChanges = false + + other.isValid = false + return this as G + } else { + return other.merge(this as G) + } + } + + private fun beginTicking() { + if (!isTicking) { + isTicking = true + queue.add(WeakReference(this)) + } + } + + companion object { + private val graphs = ArrayList>>() + private val queue = ArrayList>>() + + fun tick() { + if (queue.isNotEmpty()) { + graphs.addAll(queue) + queue.clear() + } + + val iterator = graphs.iterator() + + for (value in iterator) { + val graph = value.get() + + if (graph == null || !graph.tick()) { + graph?.isTicking = false + iterator.remove() + } + } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterGraph.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterGraph.kt index 2632bb0de..0518c56e2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterGraph.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterGraph.kt @@ -6,13 +6,13 @@ import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.matter.* import ru.dbotthepony.mc.otm.core.filterNotNull import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.graph.Abstract6Graph +import ru.dbotthepony.mc.otm.graph.GraphNodeList import java.util.* import java.util.function.Predicate import java.util.stream.Stream @Suppress("unused") -class MatterGraph : Abstract6Graph(), IMatterGraphListener { +class MatterGraph : GraphNodeList(), IMatterGraphListener { private val listeners = ObjectOpenHashSet() fun addListener(listener: IMatterGraphListener) = listeners.add(listener) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNode.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNode.kt index 33b885a98..17b1ca440 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNode.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/MatterNode.kt @@ -5,9 +5,9 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage import ru.dbotthepony.mc.otm.capability.matter.IPatternStorage import ru.dbotthepony.mc.otm.capability.matter.IReplicationTaskProvider -import ru.dbotthepony.mc.otm.graph.Graph6Node +import ru.dbotthepony.mc.otm.graph.GraphNode -open class MatterNode : Graph6Node(::MatterGraph), IMatterGraphListener { +open class MatterNode : GraphNode(::MatterGraph), IMatterGraphListener { open fun getMatterHandler(): IMatterStorage? = null open fun getPatternHandler(): IPatternStorage? = null open fun getTaskHandler(): IReplicationTaskProvider? = null diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageGraph.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageGraph.kt index b85b66ea0..11ce5f853 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageGraph.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageGraph.kt @@ -2,19 +2,12 @@ package ru.dbotthepony.mc.otm.graph.storage import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap import it.unimi.dsi.fastutil.objects.Object2ObjectFunction -import net.minecraft.server.level.ServerLevel -import net.minecraft.world.level.Level -import net.minecraft.world.level.block.entity.BlockEntity -import ru.dbotthepony.mc.otm.addTickerPre import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage -import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.graph.Abstract6Graph -import ru.dbotthepony.mc.otm.graph.Graph6Node -import ru.dbotthepony.mc.otm.core.orNull +import ru.dbotthepony.mc.otm.graph.GraphNodeList import ru.dbotthepony.mc.otm.storage.* import java.util.LinkedList -class StorageGraph : Abstract6Graph() { +class StorageGraph : GraphNodeList() { private val virtualComponents = Object2ObjectArrayMap, VirtualComponent<*>>() val powerDemandingNodes = LinkedList() @@ -46,11 +39,11 @@ class StorageGraph : Abstract6Graph() { } override fun onNodeAdded(node: StorageNode) { - //node.attachComponents(this) + node.attachComponents(this) } override fun onNodeRemoved(node: StorageNode) { - //node.removeComponents(this) + node.removeComponents(this) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNode.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNode.kt index c2b1c3e53..b06493c0c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNode.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNode.kt @@ -3,13 +3,13 @@ package ru.dbotthepony.mc.otm.graph.storage import net.minecraft.world.level.block.entity.BlockEntity import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage -import ru.dbotthepony.mc.otm.graph.Graph6Node +import ru.dbotthepony.mc.otm.graph.GraphNode import ru.dbotthepony.mc.otm.storage.IStorage import ru.dbotthepony.mc.otm.storage.IStorageStack import ru.dbotthepony.mc.otm.storage.StorageStackType import java.util.* -open class StorageNode(private val energyDemander: IMatteryEnergyStorage? = null) : Graph6Node(::StorageGraph) { +open class StorageNode(private val energyDemander: IMatteryEnergyStorage? = null) : GraphNode(::StorageGraph) { protected val components = ArrayList>() /** @@ -37,10 +37,9 @@ open class StorageNode(private val energyDemander: IMatteryEnergyStorage? = null return } - if (components != null) - for (component in components) { - to.add(component) - } + for (component in components) { + to.add(component) + } } /** From a86d30dae42cbb197b0e8e334b2aae6b0640f1f5 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 6 Aug 2023 11:53:54 +0700 Subject: [PATCH 0942/1199] Update storage interface and bus --- .../mc/otm/block/entity/MatteryBlockEntity.kt | 35 +++--------- .../entity/storage/StorageBusBlockEntity.kt | 57 +++++-------------- .../block/entity/storage/StorageInterfaces.kt | 11 +--- .../mc/otm/block/storage/StorageBusBlock.kt | 22 ------- 4 files changed, 25 insertions(+), 100 deletions(-) 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 1fac08b2b..460a3b3b0 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 @@ -65,6 +65,7 @@ import ru.dbotthepony.mc.otm.onceServer import java.lang.ref.WeakReference import java.util.* import java.util.function.Consumer +import java.util.function.Predicate import java.util.function.Supplier import java.util.stream.Stream import kotlin.NoSuchElementException @@ -134,43 +135,23 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc setChanged() } - protected fun exposeAllSidesExcept(side: RelativeSide, capability: Capability, value: T) { - for ((k, v) in _sides) { - if (k != side) { - v.Cap(capability, value) - } - } - } - - protected fun isSidelessExposed(capability: Capability<*>): Boolean { - return sidelessCaps.containsKey(capability) - } - - protected fun removeSideless(capability: Capability<*>): Boolean { - if (sidelessCaps.remove(capability) != null) { - setChanged() - return true - } - - return false - } - /** * Exposes capability unconditionally, on all sides and sideless */ - protected fun exposeGlobally(capability: Capability, value: T) { + protected fun exposeGlobally(capability: Capability, value: T, predicate: Predicate = Predicate { true }) { exposeSideless(capability, value) for (side in _sides.values) - side.Cap(capability, value) + if (predicate.test(side.side)) + side.Cap(capability, value) } - protected fun exposeEnergyGlobally(value: IMatteryEnergyStorage) { - exposeGlobally(ForgeCapabilities.ENERGY, value) - exposeGlobally(MatteryCapability.ENERGY, value) + protected fun exposeEnergyGlobally(value: IMatteryEnergyStorage, predicate: Predicate = Predicate { true }) { + exposeGlobally(ForgeCapabilities.ENERGY, value, predicate) + exposeGlobally(MatteryCapability.ENERGY, value, predicate) if (isMekanismLoaded) { - exposeGlobally(MatteryCapability.MEKANISM_ENERGY, Mattery2MekanismEnergyWrapper(value)) + exposeGlobally(MatteryCapability.MEKANISM_ENERGY, Mattery2MekanismEnergyWrapper(value), predicate) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt index 2e5635e39..a352411dc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt @@ -62,12 +62,6 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter } val energy = WorkerEnergyStorage(this::setChangedLight, MachinesConfig.STORAGE_INTERFACES) - - init { - exposeEnergyGlobally(energy) - savetable(::energy, ENERGY_KEY) - } - val cell: StorageNode = object : StorageNode(energy) { override fun onNeighbour(link: Link) { if (link is DirectionLink) { @@ -88,9 +82,21 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter } } + private var component: ItemHandlerComponent? = null + init { - exposeSideless(MatteryCapability.STORAGE_NODE, cell) - exposeAllSidesExcept(RelativeSide.FRONT, MatteryCapability.STORAGE_NODE, cell) + exposeEnergyGlobally(energy) + savetable(::energy, ENERGY_KEY) + exposeGlobally(MatteryCapability.STORAGE_NODE, cell) { it != RelativeSide.FRONT } + + side(RelativeSide.FRONT).track(ForgeCapabilities.ITEM_HANDLER).addListener { + component?.let(cell::removeStorageComponent) + component = if (it.isPresent) { + ItemHandlerComponent(it.orThrow()).also(cell::addStorageComponent) + } else { + null + } + } } val filter = ItemFilter(MAX_FILTERS) { _, _, _ -> @@ -105,12 +111,8 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter override fun setLevel(level: Level) { super.setLevel(level) cell.discover(this) - tickList.once(this::checkSurroundings) } - private var neighbour: LazyOptional? = null - private var component: ItemHandlerComponent? = null - override fun tick() { super.tick() component?.scan() @@ -122,37 +124,6 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter cell.isValid = false } - fun checkSurroundings() { - if (isRemoved) - return - - val front = blockPos + blockState.getValue(BlockRotationFreedom.XZ_XY.property) - val storage = level?.getBlockEntity(front)?.getCapability(ForgeCapabilities.ITEM_HANDLER, -blockState.getValue(BlockRotationFreedom.XZ_XY.property))?.let { if (it.isPresent) it else null } - - if (neighbour != storage) { - neighbour = storage - - if (storage != null) { - val ref = WeakReference(this) - - storage.addListener { - val self = ref.get() ?: return@addListener - - if (self.neighbour === it && SERVER_IS_LIVE) { - self.checkSurroundings() - } - } - - component?.let(cell::removeStorageComponent) - component = ItemHandlerComponent(storage.orThrow()) - component!!.let(cell::addStorageComponent) - } else { - component?.let(cell::removeStorageComponent) - component = null - } - } - } - companion object { const val MAX_FILTERS = 6 * 3 } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt index b6b548c32..a2dc766ca 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt @@ -51,12 +51,6 @@ abstract class AbstractStorageImportExport( energyValues: EnergyBalanceValues = MachinesConfig.STORAGE_INTERFACES ) : MatteryPoweredBlockEntity(blockType, blockPos, blockState) { val energy = WorkerEnergyStorage(::setChangedLight, energyValues) - - init { - exposeEnergyGlobally(energy) - savetable(::energy, ENERGY_KEY) - } - val cell: StorageNode = object : StorageNode(energy) { override fun onNeighbour(link: Link) { if (link is DirectionLink) { @@ -86,8 +80,9 @@ abstract class AbstractStorageImportExport( } init { - exposeSideless(MatteryCapability.STORAGE_NODE, cell) - exposeAllSidesExcept(RelativeSide.FRONT, MatteryCapability.STORAGE_NODE, cell) + exposeEnergyGlobally(energy) + savetable(::energy, ENERGY_KEY) + exposeGlobally(MatteryCapability.STORAGE_NODE, cell) { it != RelativeSide.FRONT } } override fun setRemoved() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt index ff7937407..1894edeca 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt @@ -112,26 +112,4 @@ class StorageBusBlock : RotatableMatteryBlock(), EntityBlock { ): VoxelShape { return shapes[p_60555_]!! } - - @Suppress("OVERRIDE_DEPRECATION") - override fun neighborChanged( - state: BlockState, - level: Level, - pos: BlockPos, - neighbour: Block, - neighbourPos: BlockPos, - movedByPiston: Boolean - ) { - super.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston) - - if (!level.isClientSide) { - val tile = level.getBlockEntity(pos) - - if (tile is StorageBusBlockEntity) { - level.oncePre { - tile.checkSurroundings() - } - } - } - } } From 22cac9d7a0d83d0a045ff2442f5ad48251683be8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 6 Aug 2023 12:27:12 +0700 Subject: [PATCH 0943/1199] Add dev chest --- .../mc/otm/datagen/lang/English.kt | 2 + .../mc/otm/datagen/lang/Russian.kt | 2 + .../mc/otm/OverdriveThatMatters.java | 3 + .../mc/otm/block/decorative/DevChestBlock.kt | 14 ++++ .../entity/decorative/DevChestBlockEntity.kt | 67 +++++++++++++++++++ .../mc/otm/registry/MBlockEntities.kt | 2 + .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 2 + .../mc/otm/registry/MCreativeTabs.kt | 1 + .../ru/dbotthepony/mc/otm/registry/MItems.kt | 9 +++ .../ru/dbotthepony/mc/otm/registry/MNames.kt | 1 + 10 files changed, 103 insertions(+) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/DevChestBlock.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/DevChestBlockEntity.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 1cb2eabec..3cdaf9e97 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -405,6 +405,8 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.ESSENCE_STORAGE, "desc", "Allows to store and retrieve experience levels") add(MBlocks.MATTER_RECONSTRUCTOR, "Matter Reconstructor") add(MBlocks.MATTER_RECONSTRUCTOR, "desc", "Repairs tools using matter") + add(MBlocks.DEV_CHEST, "Dev Chest") + add(MBlocks.DEV_CHEST, "desc", "Contains all items present in game") add(MBlocks.FLUID_TANK, "Fluid Tank") add(MBlocks.FLUID_TANK, "named", "Fluid Tank (%s)") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 330c03ccc..0db712185 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -408,6 +408,8 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.ESSENCE_STORAGE, "desc", "Позволяет хранить очки опыта") add(MBlocks.MATTER_RECONSTRUCTOR, "Материальный реконструктор") add(MBlocks.MATTER_RECONSTRUCTOR, "desc", "Чинит инструменты используя материю") + add(MBlocks.DEV_CHEST, "Сундук разработчика") + add(MBlocks.DEV_CHEST, "desc", "Хранит все предметы, которые есть в игре") add(MBlocks.FLUID_TANK, "Жидкостный бак") add(MBlocks.FLUID_TANK, "named", "Жидкостный бак (%s)") diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 641f7c3b9..b034e27e3 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -20,6 +20,7 @@ import ru.dbotthepony.mc.otm.android.AndroidResearchManager; import ru.dbotthepony.mc.otm.android.feature.EnderTeleporterFeature; import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity; import ru.dbotthepony.mc.otm.block.entity.blackhole.ExplosionQueue; +import ru.dbotthepony.mc.otm.block.entity.decorative.DevChestBlockEntity; import ru.dbotthepony.mc.otm.capability.MatteryCapability; import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability; import ru.dbotthepony.mc.otm.capability.drive.DrivePool; @@ -198,6 +199,8 @@ public final class OverdriveThatMatters { EVENT_BUS.addListener(EventPriority.NORMAL, ExplosiveHammerItem.Companion::onLeftClickBlock); + EVENT_BUS.addListener(EventPriority.NORMAL, DevChestBlockEntity.Companion::mappingsChanged); + MatteryPlayerNetworkChannel.INSTANCE.register(); MenuNetworkChannel.INSTANCE.register(); WeaponNetworkChannel.INSTANCE.register(); diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/DevChestBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/DevChestBlock.kt new file mode 100644 index 000000000..9e2a1fbd5 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/DevChestBlock.kt @@ -0,0 +1,14 @@ +package ru.dbotthepony.mc.otm.block.decorative + +import net.minecraft.core.BlockPos +import net.minecraft.world.level.block.EntityBlock +import net.minecraft.world.level.block.entity.BlockEntity +import net.minecraft.world.level.block.state.BlockState +import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.entity.decorative.DevChestBlockEntity + +class DevChestBlock : RotatableMatteryBlock(Properties.of().destroyTime(-1f).explosionResistance(360000f)), EntityBlock { + override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { + return DevChestBlockEntity(p_153215_, p_153216_) + } +} 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 new file mode 100644 index 000000000..16b68cb47 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/DevChestBlockEntity.kt @@ -0,0 +1,67 @@ +package ru.dbotthepony.mc.otm.block.entity.decorative + +import it.unimi.dsi.fastutil.ints.Int2ObjectAVLTreeMap +import net.minecraft.core.BlockPos +import net.minecraft.world.item.ItemStack +import net.minecraft.world.level.block.state.BlockState +import net.minecraftforge.common.capabilities.ForgeCapabilities +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.getID +import ru.dbotthepony.mc.otm.registry.MBlockEntities + +class DevChestBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryBlockEntity(MBlockEntities.DEV_CHEST, blockPos, blockState), IItemHandler { + override fun getSlots(): Int { + return cache().size + } + + override fun getStackInSlot(slot: Int): ItemStack { + return cache().getOrNull(slot) ?: ItemStack.EMPTY + } + + override fun insertItem(slot: Int, stack: ItemStack, simulate: Boolean): ItemStack { + return stack + } + + override fun extractItem(slot: Int, amount: Int, simulate: Boolean): ItemStack { + return getStackInSlot(slot).copyWithCount(amount) + } + + override fun getSlotLimit(slot: Int): Int { + return getStackInSlot(slot).maxStackSize + } + + override fun isItemValid(slot: Int, stack: ItemStack): Boolean { + return false + } + + init { + exposeGlobally(ForgeCapabilities.ITEM_HANDLER, this) + } + + companion object { + private val cache = ArrayList() + + @Suppress("SameReturnValue") + private fun cache(): List { + if (cache.isNotEmpty()) { + return cache + } + + val sorted = Int2ObjectAVLTreeMap() + + for (item in ForgeRegistries.ITEMS.values) { + check(sorted.put(ForgeRegistries.ITEMS.getID(item), ItemStack(item, 1).also { it.count = item.getMaxStackSize(it) }) == null) + } + + cache.addAll(sorted.values) + return cache + } + + fun mappingsChanged(event: IdMappingEvent) { + cache.clear() + } + } +} 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 1094cc4a6..46cfaf0c5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt @@ -13,6 +13,7 @@ import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity import ru.dbotthepony.mc.otm.block.entity.blackhole.BlockEntityExplosionDebugger import ru.dbotthepony.mc.otm.block.entity.blackhole.BlockEntitySphereDebugger import ru.dbotthepony.mc.otm.block.entity.decorative.CargoCrateBlockEntity +import ru.dbotthepony.mc.otm.block.entity.decorative.DevChestBlockEntity import ru.dbotthepony.mc.otm.block.entity.decorative.FluidTankBlockEntity import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity import ru.dbotthepony.mc.otm.block.entity.decorative.InfiniteWaterSourceBlockEntity @@ -60,6 +61,7 @@ object MBlockEntities { val ANDROID_CHARGER_MIDDLE: BlockEntityType by registry.register(MNames.ANDROID_CHARGER + "_middle") { BlockEntityType.Builder.of(::AndroidChargerMiddleBlockEntity, MBlocks.ANDROID_CHARGER).build(null) } val ANDROID_CHARGER_TOP: BlockEntityType by registry.register(MNames.ANDROID_CHARGER + "_top") { BlockEntityType.Builder.of(::AndroidChargerTopBlockEntity, MBlocks.ANDROID_CHARGER).build(null) } val INFINITE_WATER_SOURCE: BlockEntityType by registry.register(MNames.INFINITE_WATER_SOURCE) { BlockEntityType.Builder.of(::InfiniteWaterSourceBlockEntity, MBlocks.INFINITE_WATER_SOURCE).build(null) } + val DEV_CHEST: BlockEntityType by registry.register(MNames.DEV_CHEST) { BlockEntityType.Builder.of(::DevChestBlockEntity, MBlocks.DEV_CHEST).build(null) } val POWERED_FURNACE: BlockEntityType by registry.register(MNames.POWERED_FURNACE) { BlockEntityType.Builder.of({ a, b -> MBlocks.POWERED_FURNACE.newBlockEntity(a, b) }, MBlocks.POWERED_FURNACE).build(null) } val POWERED_BLAST_FURNACE: BlockEntityType by registry.register(MNames.POWERED_BLAST_FURNACE) { BlockEntityType.Builder.of({ a, b -> MBlocks.POWERED_BLAST_FURNACE.newBlockEntity(a, b) }, MBlocks.POWERED_BLAST_FURNACE).build(null) } 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 a437245d5..9aea56fdd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -39,6 +39,7 @@ import ru.dbotthepony.mc.otm.block.MatterCableBlock import ru.dbotthepony.mc.otm.block.tech.PhantomAttractorBlock import ru.dbotthepony.mc.otm.block.tech.PlatePressBlock import ru.dbotthepony.mc.otm.block.StorageCableBlock +import ru.dbotthepony.mc.otm.block.decorative.DevChestBlock import ru.dbotthepony.mc.otm.block.decorative.EngineBlock import ru.dbotthepony.mc.otm.block.decorative.FluidTankBlock import ru.dbotthepony.mc.otm.block.decorative.HoloSignBlock @@ -119,6 +120,7 @@ object MBlocks { val PHANTOM_ATTRACTOR: Block by registry.register(MNames.PHANTOM_ATTRACTOR) { PhantomAttractorBlock() } val FLUID_TANK: FluidTankBlock by registry.register(MNames.FLUID_TANK) { FluidTankBlock() } + val DEV_CHEST: DevChestBlock by registry.register(MNames.DEV_CHEST) { DevChestBlock() } val TRITANIUM_ORE: Block by registry.register(MNames.TRITANIUM_ORE) { DropExperienceBlock( BlockBehaviour.Properties.of() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt index e5b562685..b31328a25 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt @@ -133,6 +133,7 @@ private fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { accept(MItems.CreativeUpgrades.LIST) accept(MRegistry.CARGO_CRATES.item) + accept(MItems.DEV_CHEST) accept(MItems.HOLO_SIGN) base(MItems.TRITANIUM_DOOR) 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 443b08dbd..98aefba09 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -142,6 +142,15 @@ object MItems { } } + val DEV_CHEST: BlockItem by registry.register(MNames.DEV_CHEST) { + object : BlockItem(MBlocks.DEV_CHEST, DEFAULT_PROPERTIES) { + override fun appendHoverText(p_40572_: ItemStack, p_40573_: Level?, p_40574_: MutableList, p_40575_: TooltipFlag) { + super.appendHoverText(p_40572_, p_40573_, p_40574_, p_40575_) + p_40574_.add(TranslatableComponent("$descriptionId.desc").withStyle(ChatFormatting.GRAY)) + } + } + } + val MACHINES = SupplierList( ::ANDROID_STATION, ::ANDROID_CHARGER, ::BATTERY_BANK, ::MATTER_DECOMPOSER, ::MATTER_CAPACITOR_BANK, ::MATTER_CABLE, ::PATTERN_STORAGE, ::MATTER_SCANNER, ::MATTER_PANEL, ::MATTER_REPLICATOR, ::MATTER_BOTTLER, ::ENERGY_COUNTER, ::CHEMICAL_GENERATOR, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index 633047e10..6d80d71bc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -14,6 +14,7 @@ object MNames { const val FLUID_TANK = "fluid_tank" const val ANDROID_CHARGER = "android_charger" const val INFINITE_WATER_SOURCE = "infinite_water_source" + const val DEV_CHEST = "dev_chest" // blocks const val ANDROID_STATION = "android_station" From 48d367b705e5ff6a204d9d3f0369d4319fe21ee8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 6 Aug 2023 12:27:51 +0700 Subject: [PATCH 0944/1199] Remove Mekanism from runtime --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 2ab4fae77..4c37160bd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -172,7 +172,7 @@ dependencies { // runtimeOnly(fg.deobf("curse.maven:worldedit-225608:${worldedit_fileid}")) // runtimeOnly(fg.deobf("at.ridgo8.moreoverlays:MoreOverlays-updated:${more_overlays_version}")) - implementation(fg.deobf("mekanism:Mekanism:${mekanism_version}:all")) + compileOnly(fg.deobf("mekanism:Mekanism:${mekanism_version}:all")) // runtimeOnly(fg.deobf("curse.maven:cyclops-core-232758:4392602")) // runtimeOnly(fg.deobf("curse.maven:integrated-dynamics-236307:4391535")) From 64d5f1b33680294594535f260b54468354ea8ae0 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 6 Aug 2023 23:13:15 +0700 Subject: [PATCH 0945/1199] Refine storage api, make it compile --- .../mc/otm/OverdriveThatMatters.java | 9 - .../mc/otm/capability/MatteryCapability.java | 2 +- .../entity/storage/DriveRackBlockEntity.kt | 19 +- .../entity/storage/DriveViewerBlockEntity.kt | 3 +- .../entity/storage/ItemMonitorBlockEntity.kt | 32 +- .../entity/storage/StorageBusBlockEntity.kt | 324 ++++++------------ .../block/entity/storage/StorageInterfaces.kt | 155 ++++----- .../mc/otm/capability/drive/API.kt | 12 +- .../capability/drive/AbstractMatteryDrive.kt | 82 ++--- .../otm/capability/drive/ItemMatteryDrive.kt | 58 ++-- .../screen/storage/DriveViewerScreen.kt | 2 +- .../screen/storage/ItemMonitorScreen.kt | 8 +- .../dbotthepony/mc/otm/compat/mekanism/QIO.kt | 65 ++-- .../mc/otm/core/collect/StreamyIterator.kt | 13 + .../mc/otm/graph/storage/StorageGraph.kt | 21 +- .../mc/otm/graph/storage/StorageNode.kt | 79 ++--- .../mc/otm/matter/MatterManager.kt | 9 +- .../mc/otm/menu/data/NetworkedItemView.kt | 61 ++-- .../mc/otm/menu/storage/DriveViewerMenu.kt | 20 +- .../mc/otm/menu/storage/ItemMonitorMenu.kt | 16 +- .../dbotthepony/mc/otm/registry/MRegistry.kt | 2 + .../ru/dbotthepony/mc/otm/storage/API.kt | 160 +++------ .../ru/dbotthepony/mc/otm/storage/Helpers.kt | 25 ++ .../mc/otm/storage/ItemStackWrapper.kt | 107 ------ .../mc/otm/storage/ItemStorageStack.kt | 60 ++++ .../ru/dbotthepony/mc/otm/storage/Registry.kt | 60 ---- .../mc/otm/storage/StorageStack.kt | 127 +++++++ .../mc/otm/storage/VirtualComponent.kt | 302 ++++------------ .../otm/storage/powered/PoweredComponent.kt | 16 + .../storage/powered/PoweredStorageAcceptor.kt | 34 ++ .../storage/powered/PoweredStorageProvider.kt | 36 ++ .../powered/PoweredVirtualComponent.kt | 25 ++ 32 files changed, 824 insertions(+), 1120 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/storage/Helpers.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/storage/ItemStackWrapper.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/storage/ItemStorageStack.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/storage/Registry.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/storage/StorageStack.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredComponent.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredStorageAcceptor.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredStorageProvider.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredVirtualComponent.kt diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index b034e27e3..f729571bb 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -75,13 +75,6 @@ public final class OverdriveThatMatters { private static final Logger LOGGER = LogManager.getLogger(); public static OverdriveThatMatters INSTANCE; - private StorageStackType ITEM_STORAGE; - - @NotNull - public StorageStackType ITEM_STORAGE() { - return Objects.requireNonNull(ITEM_STORAGE); - } - public static ResourceLocation loc(String path) { return new ResourceLocation(MOD_ID, path); } @@ -206,8 +199,6 @@ public final class OverdriveThatMatters { WeaponNetworkChannel.INSTANCE.register(); GenericNetworkChannel.INSTANCE.register(); - ITEM_STORAGE = StorageRegistry.register(ItemStackWrapper.class, ItemStackWrapper.EMPTY, new Decimal("3.125")); - if (ModList.get().isLoaded("mekanism")) { EVENT_BUS.addGenericListener(BlockEntity.class, EventPriority.NORMAL, QIOKt::attachCapabilities); } diff --git a/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java b/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java index 37a8aba97..93c227c62 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java +++ b/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java @@ -45,7 +45,7 @@ public class MatteryCapability { @Nonnull @NotNull - public static final Capability DRIVE = CapabilityManager.get(new CapabilityToken<>() {}); + public static final Capability> DRIVE = CapabilityManager.get(new CapabilityToken<>() {}); @Nonnull @NotNull diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt index ab72fdbbc..c46d9cd0a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.block.entity.storage import net.minecraft.core.BlockPos -import net.minecraft.server.level.ServerLevel import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu @@ -11,13 +10,14 @@ import net.minecraft.world.level.block.state.BlockState import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.graph.storage.StorageNode import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.drive.IMatteryDrive import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.menu.storage.DriveRackMenu -import ru.dbotthepony.mc.otm.graph.storage.StorageGraph import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.storage.* +import ru.dbotthepony.mc.otm.storage.powered.PoweredVirtualComponent class DriveRackBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.DRIVE_RACK, p_155229_, p_155230_) { @@ -27,16 +27,19 @@ class DriveRackBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { super.setChanged(slot, new, old) + // generics is going apeshit since storage types are invariant, + // but since we don't know generics of upvalue mattery drive, its storage type + // is defined as out variant old.getCapability(MatteryCapability.DRIVE).ifPresent { - cell.computeIfAbsent(it.storageType) { - PoweredVirtualComponent(it, energy) - }.remove(it) + cell.computeIfAbsent(it.storageType as StorageStack.Type) { + PoweredVirtualComponent(VirtualComponent(it), ::energy) + }.remove(it as IMatteryDrive) } new.getCapability(MatteryCapability.DRIVE).ifPresent { - cell.computeIfAbsent(it.storageType) { - PoweredVirtualComponent(it, energy) - }.add(it) + cell.computeIfAbsent(it.storageType as StorageStack.Type) { + PoweredVirtualComponent(VirtualComponent(it), ::energy) + }.add(it as IMatteryDrive) } } }.also(::addDroppableContainer) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt index 62e7060dc..1dd82c294 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt @@ -18,6 +18,7 @@ import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.menu.storage.DriveViewerMenu +import ru.dbotthepony.mc.otm.storage.StorageStack class DriveViewerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.DRIVE_VIEWER, p_155229_, p_155230_) { override fun setChanged() { @@ -28,7 +29,7 @@ class DriveViewerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte tickList.once { var state = blockState - if (container.getItem(0).getCapability(MatteryCapability.DRIVE).isPresent && energy.batteryLevel >= OverdriveThatMatters.INSTANCE.ITEM_STORAGE().energyPerOperation) { + if (container.getItem(0).getCapability(MatteryCapability.DRIVE).isPresent) { state = state.setValue(WorkerState.SEMI_WORKER_STATE, WorkerState.WORKING) } else { state = state.setValue(WorkerState.SEMI_WORKER_STATE, WorkerState.IDLE) 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 7934932b4..2f33be061 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 @@ -6,13 +6,11 @@ import net.minecraft.core.NonNullList import net.minecraft.nbt.CompoundTag import net.minecraft.network.FriendlyByteBuf import net.minecraft.network.chat.Component -import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerPlayer import net.minecraft.world.Container import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu -import net.minecraft.world.inventory.CraftingContainer import net.minecraft.world.inventory.TransientCraftingContainer import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.CraftingRecipe @@ -40,6 +38,7 @@ import ru.dbotthepony.mc.otm.core.nbt.mapString import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.menu.storage.ItemMonitorMenu import ru.dbotthepony.mc.otm.storage.* +import ru.dbotthepony.mc.otm.storage.powered.PoweredVirtualComponent import java.math.BigInteger import java.util.* import java.util.function.Supplier @@ -165,7 +164,7 @@ private fun takeOne(inventory: Inventory, item: ItemStack): Boolean { return false } -private fun takeOne(id: UUID?, view: IStorageProvider): Boolean { +private fun takeOne(id: UUID?, view: IStorageProvider): Boolean { val extracted = view.extractStack(id ?: return false, BigInteger.ONE, false) if (!extracted.isEmpty) { @@ -175,10 +174,7 @@ private fun takeOne(id: UUID?, view: IStorageProvider): Boolea return false } -class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : - MatteryPoweredBlockEntity(MBlockEntities.ITEM_MONITOR, p_155229_, p_155230_), - IStorageEventConsumer { - +class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.ITEM_MONITOR, blockPos, blockState), IStorageEventConsumer { val energy = WorkerEnergyStorage(this::setChangedLight, MachinesConfig.ITEM_MONITOR) init { @@ -186,18 +182,18 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : savetable(::energy, ENERGY_KEY) } - var poweredView: PoweredVirtualComponent? = null + var poweredView: PoweredVirtualComponent? = null private set val cell = object : StorageNode(energy) { override fun attachComponents(to: StorageGraph) { super.attachComponents(to) - poweredView = PoweredVirtualComponent(to.getVirtualComponent(ITEM_STORAGE), energy) + poweredView = PoweredVirtualComponent(to.getVirtualComponent(StorageStack.ITEMS), ::energy) } override fun removeComponents(from: StorageGraph) { super.removeComponents(from) - poweredView?.removeListeners() + // poweredView?.removeListeners() poweredView = null } } @@ -248,7 +244,7 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val item = craftingGrid[i] if (!item.isEmpty) { - craftingGridTuples[i] = poweredView[ItemStackWrapper(item).key()] + craftingGridTuples[i] = poweredView[ItemStorageStack.unsafe(item)] } } } @@ -269,18 +265,18 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : private val craftingGridDummy = TransientCraftingContainer(craftingMenu, 3, 3) - override val storageType: StorageStackType - get() = ITEM_STORAGE + override val storageType: StorageStack.Type + get() = StorageStack.ITEMS - override fun addStack(stack: ItemStackWrapper, id: UUID, provider: IStorageProvider) { + override fun onStackAdded(stack: ItemStorageStack, id: UUID, provider: IStorageProvider) { // no op } - override fun changeStack(stack: ItemStackWrapper, id: UUID, oldCount: BigInteger) { + override fun onStackChanged(stack: ItemStorageStack, id: UUID) { // no op } - override fun removeStack(stack: ItemStackWrapper, id: UUID) { + override fun onStackRemoved(id: UUID) { for (i in craftingGridTuples.indices) { if (craftingGridTuples[i] == id) { craftingGridTuples[i] = null @@ -393,7 +389,7 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : if (!remainder.isEmpty) { when (settings.resultTarget) { ItemMonitorPlayerSettings.ResultTarget.ALL_SYSTEM, ItemMonitorPlayerSettings.ResultTarget.MIXED -> { - val remaining = poweredView?.insertStack(ItemStackWrapper(remainder), false)?.stack ?: remainder + val remaining = poweredView?.insertStack(ItemStorageStack(remainder), false)?.toItemStack() ?: remainder if (!remaining.isEmpty) { if (newItem.isEmpty) { @@ -409,7 +405,7 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : ItemMonitorPlayerSettings.ResultTarget.ALL_INVENTORY -> { if (!craftingPlayer.inventory.add(remainder)) { - val remaining = poweredView?.insertStack(ItemStackWrapper(remainder), false)?.stack ?: remainder + val remaining = poweredView?.insertStack(ItemStorageStack(remainder), false)?.toItemStack() ?: remainder if (!remaining.isEmpty) { if (newItem.isEmpty) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt index a352411dc..57a8530ca 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt @@ -2,8 +2,8 @@ package ru.dbotthepony.mc.otm.block.entity.storage import it.unimi.dsi.fastutil.ints.Int2ObjectAVLTreeMap import it.unimi.dsi.fastutil.ints.IntAVLTreeSet +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap import net.minecraft.core.BlockPos -import net.minecraft.core.Direction import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu @@ -12,7 +12,6 @@ import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.capabilities.ForgeCapabilities -import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.items.IItemHandler import ru.dbotthepony.mc.otm.* import ru.dbotthepony.mc.otm.block.CableBlock @@ -23,23 +22,20 @@ import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.core.* -import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.math.RelativeSide -import ru.dbotthepony.mc.otm.core.math.getCapability import ru.dbotthepony.mc.otm.core.math.isPositive -import ru.dbotthepony.mc.otm.core.math.isZero -import ru.dbotthepony.mc.otm.core.math.plus +import ru.dbotthepony.mc.otm.core.math.toIntSafe import ru.dbotthepony.mc.otm.graph.storage.StorageNode import ru.dbotthepony.mc.otm.menu.storage.StorageBusMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.storage.* -import java.lang.ref.WeakReference import java.math.BigInteger import java.util.* import java.util.stream.Stream -private class SlotTuple(val slot: Int, val stack: ItemStack) -private class TrackedTuple(override val stack: ItemStackWrapper, override val id: UUID) : IStorageTuple { +private data class SlotTuple(val slot: Int, val stack: ItemStack) + +private class TrackedTuple(override var stack: ItemStorageStack, override val id: UUID) : IStorageTuple { // do not use hash map because we need keys to be iterated in natural order val children = Int2ObjectAVLTreeMap() @@ -128,51 +124,21 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter const val MAX_FILTERS = 6 * 3 } - private inner class ItemHandlerComponent(private val parent: IItemHandler) : IStorageComponent { - private inner class EventsSnapshot { - val index = HashMap() + private inner class ItemHandlerComponent(private val parent: IItemHandler) : IStorageComponent { + private fun updateTuple(tuple: TrackedTuple, diff: BigInteger) { + tuple.stack = tuple.stack.grow(diff) - fun change(key: UUID, diff: BigInteger) { - if (diff.isZero) - return - - val value = index[key] - - if (value == null) { - index[key] = diff - } else { - val newvalue = value + diff - - if (newvalue.isZero) { - index.remove(key) - } else { - index[key] = newvalue - } + if (tuple.stack.isNotEmpty) { + for (listener in listeners) { + listener.onStackChanged(tuple) } - } - - fun apply() { - for ((key, value) in index) { - val tuple = checkNotNull(this@ItemHandlerComponent.index[key]) { "Tuple with ID $key is missing!" } - - val count = tuple.stack.count - tuple.stack.count += value - - if (tuple.stack.count.isPositive) { - for (listener in listeners) { - listener.changeStack(tuple, count) - } - } else { - for (listener in listeners) { - listener.removeStack(tuple) - } - - this@ItemHandlerComponent.index.remove(tuple.id) - - val tuplekey = tuple.stack.key() - tuples.remove(tuplekey) ?: throw IllegalStateException("Cross-reference integrity check failed for $tuple") - } + } else { + for (listener in listeners) { + listener.onStackRemoved(tuple) } + + id2tuples.remove(tuple.id) + items2tuples.remove(tuple.stack) ?: throw IllegalStateException("Cross-reference integrity check failed for $tuple") } } @@ -240,14 +206,12 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter } } - private var snapshot: EventsSnapshot? = null + override val storageType: StorageStack.Type + get() = StorageStack.ITEMS - override val storageType: StorageStackType - get() = ITEM_STORAGE + private val listeners = ArrayList>() - private val listeners = ArrayList>() - - override fun addListener(listener: IStorageEventConsumer): Boolean { + override fun addListener(listener: IStorageEventConsumer): Boolean { if (!listeners.contains(listener)) { listeners.add(listener) return true @@ -256,139 +220,92 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter return false } - override fun removeListener(listener: IStorageEventConsumer): Boolean { + override fun removeListener(listener: IStorageEventConsumer): Boolean { return listeners.remove(listener) } - private var scanned = arrayOfNulls(0) - private var scannedMap = arrayOfNulls(0) - private val tuples = HashMap() - private val index = HashMap() + private var slot2itemStack = arrayOfNulls(0) + private var slot2tuple = arrayOfNulls(0) + private val items2tuples = Object2ObjectOpenCustomHashMap(StorageStack.Companion) + private val id2tuples = HashMap() private fun removeTracked(slot: Int) { - scanned[slot] = null - val scannedMap = checkNotNull(scannedMap[slot]) { "Not tracking slot $slot" } - this.scannedMap[slot] = null + slot2itemStack[slot] = null + val tuple = checkNotNull(slot2tuple[slot]) { "Not tracking slot $slot" } + slot2tuple[slot] = null - val item = scannedMap.children[slot] ?: throw IllegalStateException("${scannedMap.id} does not track $slot") - scannedMap.children.remove(slot) - val count = scannedMap.stack.count - - val snapshot = snapshot - - if (snapshot != null) { - snapshot.change(scannedMap.id, -item.stack.count.toBigInteger()) - } else { - scannedMap.stack.count -= item.stack.count.toBigInteger() - - if (scannedMap.stack.count.isPositive) { - for (listener in listeners) { - listener.changeStack(scannedMap, count) - } - } else { - for (listener in listeners) { - listener.removeStack(scannedMap) - } - - index.remove(scannedMap.id) - - val key = scannedMap.stack.key() - tuples.remove(key) ?: throw IllegalStateException("Item tuple is not present for slot $slot at ${scannedMap.stack}") - } - } + val slotTuple = tuple.children[slot] ?: throw IllegalStateException("${tuple.id} does not track $slot") + tuple.children.remove(slot) + updateTuple(tuple, -slotTuple.stack.count.toBigInteger()) } private fun diffTracked(slot: Int, diff: Int) { - val scannedMap = checkNotNull(scannedMap[slot]) { "Not tracking slot $slot" } - val item = checkNotNull(scannedMap.children[slot]) { "${scannedMap.id} does not track $slot" } - - val oldCount = scannedMap.stack.count - item.stack.count += diff - - val snapshot = snapshot - - if (snapshot != null) { - snapshot.change(scannedMap.id, diff.toBigInteger()) - } else { - scannedMap.stack.count += diff.toBigInteger() - - for (listener in listeners) { - listener.changeStack(scannedMap.stack, scannedMap.id, oldCount) - } - } + val tuple = checkNotNull(slot2tuple[slot]) { "Not tracking slot $slot" } + val slotTuple = checkNotNull(tuple.children[slot]) { "${tuple.id} does not track $slot" } + slotTuple.stack.count += diff + updateTuple(tuple, diff.toBigInteger()) } private fun addTracked(slot: Int, stack: ItemStack) { - check(scannedMap[slot] == null) { "Already tracking slot $slot" } + check(slot2tuple[slot] == null) { "Already tracking slot $slot" } - val storageStack = ItemStackWrapper(stack) - val key = storageStack.key() - var tuple: TrackedTuple? = tuples[key] + val storageStack = ItemStorageStack(stack) + var tuple = items2tuples[storageStack] val added = tuple == null - var oldCount = BigInteger.ZERO - if (added) { + if (tuple == null) { tuple = TrackedTuple(storageStack, UUID.randomUUID()) - index[tuple.id] = tuple - tuples[key] = tuple + id2tuples[tuple.id] = tuple + items2tuples[storageStack] = tuple } else { - oldCount = tuple!!.stack.count - - if (snapshot == null) - tuple.stack.count += stack.count.toBigInteger() + tuple.stack = tuple.stack.grow(stack.count.toBigInteger()) } tuple.children[slot] = SlotTuple(slot, stack.copy()) - scanned[slot] = tuple.children[slot].stack - scannedMap[slot] = tuple + slot2itemStack[slot] = tuple.children[slot].stack + slot2tuple[slot] = tuple if (added) { for (listener in listeners) { - listener.addStack(tuple.stack, tuple.id, this) + listener.onStackAdded(tuple.stack, tuple.id, this) } } else { - val snapshot = snapshot - - if (snapshot != null) { - snapshot.change(tuple.id, stack.count.toBigInteger()) - } else { - for (listener in listeners) { - listener.changeStack(tuple.stack, tuple.id, oldCount) - } + for (listener in listeners) { + listener.onStackChanged(tuple.stack, tuple.id) } } } private fun sizeScan() { - if (scanned.size != parent.slots) { - val old = scanned - val oldMap = scannedMap + if (slot2itemStack.size != parent.slots) { + val old = slot2itemStack + val oldMap = slot2tuple - if (scanned.size < parent.slots) { + if (slot2itemStack.size < parent.slots) { // grow - scanned = arrayOfNulls(parent.slots) - scannedMap = arrayOfNulls(parent.slots) + slot2itemStack = arrayOfNulls(parent.slots) + slot2tuple = arrayOfNulls(parent.slots) for ((i, item) in old.withIndex()) { - scanned[i] = item + slot2itemStack[i] = item } for ((i, item) in oldMap.withIndex()) { - scannedMap[i] = item + slot2tuple[i] = item } } else { // shrink - for (i in parent.slots until scanned.size) { - if (scannedMap[i] != null) + for (i in parent.slots until slot2itemStack.size) { + if (slot2tuple[i] != null) removeTracked(i) } - scanned = arrayOfNulls(parent.slots) - scannedMap = arrayOfNulls(parent.slots) + slot2itemStack = arrayOfNulls(parent.slots) + slot2tuple = arrayOfNulls(parent.slots) for (i in 0 until parent.slots) { - scanned[i] = old[i] - scannedMap[i] = oldMap[i] + slot2itemStack[i] = old[i] + slot2tuple[i] = oldMap[i] } } } @@ -396,7 +313,7 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter fun scan(slot: Int) { val current = parent[slot].let { if (it.isEmpty || !filter.match(it)) null else it } - val last = scanned[slot] + val last = slot2itemStack[slot] if (current == null && last != null) { removeTracked(slot) @@ -415,42 +332,27 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter fun scan() { sizeScan() - snapshot = EventsSnapshot() - for (slot in 0 until parent.slots) { scan(slot) } - - snapshot!!.apply() - snapshot = null } - override fun insertStack(stack: ItemStackWrapper, simulate: Boolean): ItemStackWrapper { - if (redstoneControl.isBlockedByRedstone || energy.batteryLevel.isZero || !filter.match(stack.item)) + override fun insertStack(stack: ItemStorageStack, simulate: Boolean): ItemStorageStack { + if (redstoneControl.isBlockedByRedstone || energy.batteryLevel.isZero || !filter.match(stack.toItemStack())) return stack - val maxPossibleDemand = ITEM_STORAGE.energyPerOperation * stack.count - val maxExtractEnergy = energy.extractEnergy(maxPossibleDemand, true) + val required = StorageStack.ITEMS.energyPerInsert(stack) + if (energy.extractEnergy(required, true) != required) return stack - var leftover: ItemStackWrapper = stack.copy() - var additional: BigInteger = BigInteger.ZERO + var leftover = stack - if (maxExtractEnergy != maxPossibleDemand) { - additional = (maxExtractEnergy / ITEM_STORAGE.energyPerOperation).whole - leftover.count -= additional - } - - for (slot in PrioritizedSlotIterator(tuples[stack.key()])) { + for (slot in PrioritizedSlotIterator(items2tuples[stack])) { val oldCount = leftover.count - leftover = ItemStackWrapper(parent.insertItem(slot, leftover.stack, simulate)) + leftover = ItemStorageStack.unsafe(parent.insertItem(slot, leftover.toItemStack(), simulate)) if (oldCount != leftover.count && !simulate) { - energy.extractEnergy(ITEM_STORAGE.energyPerOperation * (oldCount - leftover.count), false) - - if (scanned.size <= slot) { - sizeScan() - } - + energy.extractEnergy(StorageStack.ITEMS.energyPerInsert(stack.copy(oldCount - leftover.count)), false) + if (slot2itemStack.size <= slot) sizeScan() scan(slot) } @@ -459,74 +361,52 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter } } - return leftover.also { - if (additional != BigInteger.ZERO) { - it.count += additional - } - } + return leftover } - override fun get(id: UUID): ItemStackWrapper { - return index[id]?.stack ?: ItemStackWrapper.EMPTY + override fun get(id: UUID): ItemStorageStack { + return id2tuples[id]?.stack ?: ItemStorageStack.EMPTY } - override fun extractStack(id: UUID, amount: BigInteger, simulate: Boolean): ItemStackWrapper { - if (redstoneControl.isBlockedByRedstone || !amount.isPositive) - return ItemStackWrapper.EMPTY + override fun extractStack(id: UUID, amount: BigInteger, simulate: Boolean): ItemStorageStack { + if (redstoneControl.isBlockedByRedstone || !amount.isPositive || !energy.batteryLevel.isPositive) + return ItemStorageStack.EMPTY - val maxPossibleDemand = ITEM_STORAGE.energyPerOperation * amount - val maxExtractEnergy = energy.extractEnergy(maxPossibleDemand, true) + var total = BigInteger.ZERO + val tuple = id2tuples[id] ?: return ItemStorageStack.EMPTY + val slots = tuple.children.values.iterator() + val lstack = tuple.stack - @Suppress("NAME_SHADOWING") - var amount = amount + while (amount < total && slots.hasNext() && energy.batteryLevel.isPositive) { + val (slot, stack) = slots.next() + val extracted = parent.extractItem(slot, stack.count.coerceAtMost(amount.toIntSafe()), true) + val required = StorageStack.ITEMS.energyPerExtract(ItemStorageStack.unsafe(extracted)) - if (maxPossibleDemand != maxExtractEnergy) { - amount = (maxExtractEnergy / ITEM_STORAGE.energyPerOperation).whole - } + if (extracted.isNotEmpty && tuple.stack.equalsWithoutCount(ItemStorageStack.unsafe(extracted)) && energy.extractEnergy(required, true) == required) { + if (simulate) { + total += extracted.count.toBigInteger() + } else { + val extracted2 = parent.extractItem(slot, extracted.count, false) - val intAmount = amount.toLong() - val tuple = index[id] ?: return ItemStackWrapper.EMPTY - var totalExtracted = 0L + if (extracted2.count == extracted.count) { + energy.extractEnergy(required, false) + } else { + energy.extractEnergy(StorageStack.ITEMS.energyPerExtract(ItemStorageStack.unsafe(extracted2)), false) + } - val copy = tuple.stack.copy() - - for (stack in tuple.children.values) { - val extracted = parent.extractItem(stack.slot, stack.stack.count.coerceAtMost((intAmount - totalExtracted).clamp()), true) - - if (!extracted.isEmpty && tuple.stack.sameItem(extracted)) { - if (!simulate) { - parent.extractItem(stack.slot, extracted.count, false) - } - - totalExtracted += extracted.count - - if (extracted.count != 0 && !simulate) { - energy.extractEnergy(ITEM_STORAGE.energyPerOperation * extracted.count, false) - } - - if (totalExtracted >= intAmount) { - break + total += extracted2.count.toBigInteger() } } } - if (totalExtracted == 0L) { - return ItemStackWrapper.EMPTY - } - - if (!simulate) { - scan() - } - - copy.count = totalExtracted.toBigInteger() - return copy + return lstack.copy(total) } - override val stacks: Stream> get() { - val listing = ArrayList>(index.size) + override val stacks: Stream> get() { + val listing = ArrayList>(id2tuples.size) - for (tuple in index.values) { - listing.add(StorageTuple(tuple.id, tuple.stack)) + for (tuple in id2tuples.values) { + listing.add(IStorageTuple.I(tuple.id, tuple.stack)) } return listing.stream() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt index a2dc766ca..e5348811e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.block.entity.storage import net.minecraft.core.BlockPos -import net.minecraft.core.Direction import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player @@ -20,13 +19,12 @@ import ru.dbotthepony.mc.otm.block.CableBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage -import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.config.EnergyBalanceValues import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.core.math.RelativeSide -import ru.dbotthepony.mc.otm.core.math.toIntSafe import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.graph.storage.StorageNode import ru.dbotthepony.mc.otm.menu.storage.StorageExporterMenu @@ -36,10 +34,8 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.storage.IStorageEventConsumer import ru.dbotthepony.mc.otm.storage.IStorageProvider -import ru.dbotthepony.mc.otm.storage.ITEM_STORAGE -import ru.dbotthepony.mc.otm.storage.ItemStackWrapper -import ru.dbotthepony.mc.otm.storage.StorageStackType -import ru.dbotthepony.mc.otm.storage.addStack +import ru.dbotthepony.mc.otm.storage.ItemStorageStack +import ru.dbotthepony.mc.otm.storage.StorageStack import java.math.BigInteger import java.util.* import java.util.stream.Stream @@ -112,7 +108,9 @@ abstract class AbstractStorageImportExport( } } -class StorageImporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : AbstractStorageImportExport(MBlockEntities.STORAGE_IMPORTER, blockPos, blockState), IItemHandler { +class StorageImporterBlockEntity( + blockPos: BlockPos, blockState: BlockState +) : AbstractStorageImportExport(MBlockEntities.STORAGE_IMPORTER, blockPos, blockState), IItemHandler { override val filter = ItemFilter(MAX_FILTERS) { _, _, _ -> setChangedLight() } @@ -124,8 +122,6 @@ class StorageImporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : A private var lastSlot = 0 private var nextTick = INTERVAL - private val enoughEnergy get() = energy.batteryLevel >= ITEM_STORAGE.energyPerOperation - override val targetCapability: Capability get() = ForgeCapabilities.ITEM_HANDLER @@ -141,23 +137,39 @@ class StorageImporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : A return ItemStack.EMPTY } + private fun acceptItem(stack: ItemStack, simulate: Boolean): ItemStack { + val wrapped = ItemStorageStack(stack) + + val view = cell.graph.getVirtualComponent(StorageStack.ITEMS) + val inserted = view.insertStack(wrapped, true) + if (inserted == wrapped) return stack + + val required = StorageStack.ITEMS.energyPerInsert(wrapped) + + if (energy.extractEnergy(required, true) == required) { + if (!simulate) { + val inserted2 = view.insertStack(wrapped, false) + + if (inserted == inserted2) { + energy.extractEnergy(required, false) + return inserted.toItemStack() + } else { + energy.extractEnergy(StorageStack.ITEMS.energyPerInsert(inserted2), false) + return inserted2.toItemStack() + } + } + + return inserted.toItemStack() + } + + return stack + } + override fun insertItem(slot: Int, stack: ItemStack, simulate: Boolean): ItemStack { if (redstoneControl.isBlockedByRedstone || !filter.match(stack)) return stack - val view = cell.graph.getVirtualComponent(ITEM_STORAGE) - val maxMove = energy.extractEnergyExact(ITEM_STORAGE.energyPerOperation, stack.count.toBigInteger(), true) - - if (maxMove == BigInteger.ZERO) - return stack - - val leftover = view.insertStack(ItemStackWrapper(stack).also { it.count = maxMove }, simulate) - - if (simulate) - return leftover.stack - - energy.extractEnergyExact(ITEM_STORAGE.energyPerOperation, maxMove - leftover.count, false) - return leftover.stack + return acceptItem(stack, simulate) } override fun extractItem(slot: Int, amount: Int, simulate: Boolean): ItemStack { @@ -184,28 +196,20 @@ class StorageImporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : A val target = target.get().orNull() - if (nextTick <= 0 && target != null && enoughEnergy) { - val items = cell.graph.getVirtualComponent(ITEM_STORAGE) - + if (nextTick <= 0 && target != null) { if (lastSlot >= target.slots) { lastSlot = 0 } - val maxMove = energy.extractEnergyExact(ITEM_STORAGE.energyPerOperation, MAX_MOVE_PER_OPERATION, true) - var extracted = target.extractItem(lastSlot, maxMove, true) + val extracted = target.extractItem(lastSlot, MAX_MOVE_PER_OPERATION, true) if (extracted.isEmpty || !filter.match(extracted)) { lastSlot++ } else { - val leftOver = items.insertStack(ItemStackWrapper(extracted), true) - - if (leftOver.count.toInt() != extracted.count) { - extracted = target.extractItem(lastSlot, extracted.count - leftOver.count.toInt(), false) - energy.extractEnergyExact(ITEM_STORAGE.energyPerOperation, extracted.count, false) - items.insertStack(ItemStackWrapper(extracted), false) - } else { - nextTick += INTERVAL * 4 - } + val accepted = acceptItem(extracted, true) + val extracted2 = target.extractItem(lastSlot, accepted.count, false) + acceptItem(extracted2, false) + nextTick += INTERVAL * 4 } } @@ -223,7 +227,7 @@ class StorageImporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : A class StorageExporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : AbstractStorageImportExport(MBlockEntities.STORAGE_EXPORTER, blockPos, blockState), - IStorageEventConsumer { + IStorageEventConsumer { override val defaultDisplayName: Component get() = MACHINE_NAME @@ -233,36 +237,36 @@ class StorageExporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : private val relevantTuples = HashSet() - override val storageType: StorageStackType - get() = ITEM_STORAGE + override val storageType: StorageStack.Type + get() = StorageStack.ITEMS init { cell.addStorageComponent(this) } - override fun addStack(stack: ItemStackWrapper, id: UUID, provider: IStorageProvider) { - if (!filter.match(stack.item)) { + override fun onStackAdded(stack: ItemStorageStack, id: UUID, provider: IStorageProvider) { + if (!filter.match(stack.toItemStack())) { return } relevantTuples.add(id) } - override fun changeStack(stack: ItemStackWrapper, id: UUID, oldCount: BigInteger) { + override fun onStackChanged(stack: ItemStorageStack, id: UUID) { // no-op } - override fun removeStack(stack: ItemStackWrapper, id: UUID) { + override fun onStackRemoved(id: UUID) { relevantTuples.remove(id) } override val filter = ItemFilter(MAX_FILTERS) { _, _, _ -> relevantTuples.clear() - val component = cell.graph.getVirtualComponent(ITEM_STORAGE) + val component = cell.graph.getVirtualComponent(StorageStack.ITEMS) for (tuple in component.stacks) { - addStack(tuple, component) + onStackAdded(tuple, component) } lastSlot = 0 @@ -272,14 +276,13 @@ class StorageExporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : private var lastSlot = 0 private var nextTick = INTERVAL - private val enoughEnergy get() = energy.batteryLevel >= ITEM_STORAGE.energyPerOperation override val targetCapability: Capability get() = ForgeCapabilities.ITEM_HANDLER - private val exportStacks: Stream> + private val exportStacks: Stream> get() { - val view = cell.graph.getVirtualComponent(ITEM_STORAGE) + val view = cell.graph.getVirtualComponent(StorageStack.ITEMS) return relevantTuples.stream().map { it to view[it] } } @@ -295,53 +298,43 @@ class StorageExporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : val target = target.get().orNull() - if (nextTick <= 0 && target != null && enoughEnergy) { - val items = cell.graph.getVirtualComponent(ITEM_STORAGE) + if (nextTick <= 0 && target != null) { + val items = cell.graph.getVirtualComponent(StorageStack.ITEMS) if (lastSlot >= target.slots) { lastSlot = 0 } - var hit = false + val any = exportStacks.anyMatch { + val (id, stack) = it - for (stack in exportStacks) { - if (!target.isItemValid(lastSlot, stack.second.item)) { - continue - } + if (!target.isItemValid(lastSlot, stack.toItemStack())) return@anyMatch false - val exportAmountA = items.extractStack( - stack.first, stack.second.count.coerceAtMost( - MAX_MOVE_PER_OPERATION - ), true - ).count + val extracted = items.extractStack(id, stack.count.coerceAtMost(MAX_MOVE_PER_OPERATION), true) + if (extracted.isEmpty) return@anyMatch false - if (exportAmountA == BigInteger.ZERO) { - continue - } + val required = StorageStack.ITEMS.energyPerOperation(extracted) + if (energy.extractEnergy(required, true) != required) return@anyMatch false - var exportAmount = - energy.extractEnergyExact(ITEM_STORAGE.energyPerOperation, exportAmountA, true).toIntSafe() + val toInsert = extracted.toItemStack() + val leftover = target.insertItem(lastSlot, toInsert, true) - if (exportAmount == 0) { - break - } + if (leftover.count != toInsert.count) { + val extracted2 = items.extractStack(id, (toInsert.count - leftover.count).toBigInteger(), false) + energy.extractEnergy(StorageStack.ITEMS.energyPerOperation(extracted2), false) + val leftover2 = target.insertItem(lastSlot, extracted2.toItemStack(), false) - val leftover = target.insertItem(lastSlot, stack.second.stack.also { it.count = exportAmount }, true) + if (leftover2.isNotEmpty) { + items.insertStack(ItemStorageStack.unsafe(leftover2), false) + } - if (leftover.count != exportAmount) { - hit = true - exportAmount = items.extractStack( - stack.first, - (exportAmount - leftover.count).toBigInteger(), - false - ).count.toInt() - target.insertItem(lastSlot, stack.second.stack.also { it.count = exportAmount }, false) - energy.extractEnergyExact(ITEM_STORAGE.energyPerOperation, exportAmount, false) - break + true + } else { + false } } - if (!hit) { + if (!any) { lastSlot++ } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/API.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/API.kt index 2c31379ba..689056cb4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/API.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/API.kt @@ -4,27 +4,27 @@ import net.minecraft.nbt.CompoundTag import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.storage.IStorageComponent -import ru.dbotthepony.mc.otm.storage.IStorageStack import ru.dbotthepony.mc.otm.storage.IStorageTuple -import ru.dbotthepony.mc.otm.storage.ItemStackWrapper +import ru.dbotthepony.mc.otm.storage.ItemStorageStack +import ru.dbotthepony.mc.otm.storage.StorageStack import java.math.BigInteger import java.util.* -interface IItemMatteryDrive : IMatteryDrive { +interface IItemMatteryDrive : IMatteryDrive { /** * @param item * @return all items belonging to passed class */ - fun findItems(item: Item): Collection> + fun findItems(item: Item): Collection> /** * @param stack * @return [ItemStack] that match specified [stack] (item type, nbt tag) */ - fun findItems(stack: ItemStack): IStorageTuple? + fun findItems(stack: ItemStack): IStorageTuple? } -interface IMatteryDrive : IStorageComponent { +interface IMatteryDrive> : IStorageComponent { val uuid: UUID var isDirty: Boolean diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/AbstractMatteryDrive.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/AbstractMatteryDrive.kt index fec2c6b25..f8e72f168 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/AbstractMatteryDrive.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/AbstractMatteryDrive.kt @@ -1,5 +1,7 @@ package ru.dbotthepony.mc.otm.capability.drive +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.ObjectArraySet import kotlin.jvm.JvmOverloads import java.util.UUID @@ -18,13 +20,13 @@ import java.math.BigInteger import java.util.ArrayList import java.util.stream.Stream -abstract class AbstractMatteryDrive @JvmOverloads constructor( +abstract class AbstractMatteryDrive> @JvmOverloads constructor( override var driveCapacity: BigInteger, override val uuid: UUID = UUID.randomUUID(), var maxDifferentStacks: Int = 0xFFFF ) : IMatteryDrive { - protected val tuples = HashMap>() - protected val tuplesByID: MutableMap> = HashMap() + protected val stack2tuples = Object2ObjectOpenCustomHashMap>(StorageStack.Companion) + protected val id2tuples = Object2ObjectOpenHashMap>() override var isDirty = false set(value) { @@ -41,30 +43,25 @@ abstract class AbstractMatteryDrive @JvmOverloads constructor override var storedCount: BigInteger = BigInteger.ZERO protected set - @Suppress("unchecked_cast") override fun insertStack(stack: T, simulate: Boolean): T { val maxInsert = driveCapacity.minus(storedCount).coerceAtMost(stack.count) if (maxInsert <= BigInteger.ZERO) return stack - val key = stack.key() - val tuple = tuples[key] + val tuple = stack2tuples[stack] if (tuple != null) { if (!simulate) { - val oldCount = tuple.stack.count - tuple.stack.grow(maxInsert) + tuple.grow(maxInsert) storedCount += maxInsert for (listener in listeners) { - listener.changeStack(tuple.stack, tuple.id, oldCount) + listener.onStackChanged(tuple.stack, tuple.id) } isDirty = true } - val copy = stack.copy() as T - copy.shrink(maxInsert) - return copy + return stack.shrink(maxInsert) } if (storedDifferentStacks >= maxDifferentStacks) { @@ -75,28 +72,22 @@ abstract class AbstractMatteryDrive @JvmOverloads constructor storedDifferentStacks++ storedCount = storedCount.plus(maxInsert) - val copy = stack.copy() as T - copy.count = maxInsert - - val state = StorageTuple(UUID.randomUUID(), copy) - tuples[key] = state - tuplesByID[state.id] = state + val state = IStorageTuple.M(UUID.randomUUID(), stack.copy(maxInsert)) + stack2tuples[stack] = state + id2tuples[state.id] = state for (listener in listeners) { - listener.addStack(state.stack, state.id, this) + listener.onStackAdded(state.stack, state.id, this) } isDirty = true } - val copy = stack.copy() as T - copy.shrink(maxInsert) - return copy + return stack.shrink(maxInsert) } - @Suppress("unchecked_cast") override fun extractStack(id: UUID, amount: BigInteger, simulate: Boolean): T { - val get = tuplesByID[id] ?: return storageType.empty + val get = id2tuples[id] ?: return storageType.empty @Suppress("NAME_SHADOWING") var amount = amount @@ -109,28 +100,25 @@ abstract class AbstractMatteryDrive @JvmOverloads constructor if (amount <= BigInteger.ZERO) return storageType.empty - val copy = get.stack.copy() as T - copy.count = amount + val copy = get.stack.copy(amount) if (!simulate) { if (amount == get.stack.count) { - val key = get.stack.key() - tuples.remove(key) ?: throw IllegalStateException("Can't find storage key for ${get.stack}") + stack2tuples.remove(get.stack) ?: throw IllegalStateException("Can't find storage key for ${get.stack}") storedDifferentStacks-- for (listener in listeners) { - listener.removeStack(get.stack, get.id) + listener.onStackRemoved(get.id) } } storedCount -= amount - val oldCount = get.stack.count - get.stack.shrink(amount) + get.shrink(amount) if (get.stack.count.isPositive) { for (listener in listeners) { - listener.changeStack(get.stack, get.id, oldCount) + listener.onStackChanged(get.stack, get.id) } } @@ -140,7 +128,7 @@ abstract class AbstractMatteryDrive @JvmOverloads constructor return copy } - protected abstract fun serializeStack(item: IStorageTuple): CompoundTag? + protected abstract fun serializeStack(item: T): CompoundTag? protected abstract fun deserializeStack(tag: CompoundTag): T? override fun serializeNBT(): CompoundTag { @@ -152,8 +140,8 @@ abstract class AbstractMatteryDrive @JvmOverloads constructor val list = ListTag() compound["items"] = list - for (stack in tuples.values) { - val serialized = serializeStack(stack) + for (tuple in stack2tuples.values) { + val serialized = serializeStack(tuple.stack) if (serialized != null) { list.add(serialized) @@ -165,13 +153,13 @@ abstract class AbstractMatteryDrive @JvmOverloads constructor override fun deserializeNBT(nbt: CompoundTag) { for (listener in listeners) { - for (get in tuples.values) { - listener.removeStack(get.stack, get.id) + for (get in stack2tuples.values) { + listener.onStackRemoved(get.id) } } - tuples.clear() - tuplesByID.clear() + stack2tuples.clear() + id2tuples.clear() storedCount = BigInteger.ZERO storedDifferentStacks = 0 // nextID = 0L @@ -183,23 +171,23 @@ abstract class AbstractMatteryDrive @JvmOverloads constructor if (entry is CompoundTag) { val stack = deserializeStack(entry) - if (stack != null) { + if (stack != null && stack.isNotEmpty) { storedCount += stack.count storedDifferentStacks++ - val tuple = StorageTuple(UUID.randomUUID(), stack) - tuples[tuple.stack.key()] = tuple - tuplesByID[tuple.id] = tuple + val tuple = IStorageTuple.M(UUID.randomUUID(), stack) + stack2tuples[tuple.stack] = tuple + id2tuples[tuple.id] = tuple } } } } override fun get(id: UUID): T { - return tuplesByID[id]?.stack ?: storageType.empty + return id2tuples[id]?.stack ?: storageType.empty } override val stacks: Stream> get() { - return ArrayList>(tuples.size).also { it.addAll(tuples.values) }.stream() + return ArrayList>(stack2tuples.size).also { it.addAll(stack2tuples.values) }.stream() } protected val listeners = ObjectArraySet>() @@ -211,8 +199,4 @@ abstract class AbstractMatteryDrive @JvmOverloads constructor override fun removeListener(listener: IStorageEventConsumer): Boolean { return listeners.remove(listener) } - - companion object { - private val LOGGER = LogManager.getLogger() - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/ItemMatteryDrive.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/ItemMatteryDrive.kt index 4ff1b972b..a5fb59159 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/ItemMatteryDrive.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/ItemMatteryDrive.kt @@ -1,69 +1,51 @@ package ru.dbotthepony.mc.otm.capability.drive import net.minecraft.nbt.CompoundTag -import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.Items -import net.minecraftforge.registries.ForgeRegistries -import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.core.math.BigInteger import ru.dbotthepony.mc.otm.core.math.serializeNBT import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.storage.IStorageTuple -import ru.dbotthepony.mc.otm.storage.ItemStackWrapper -import ru.dbotthepony.mc.otm.storage.StorageStackType -import ru.dbotthepony.mc.otm.storage.key +import ru.dbotthepony.mc.otm.storage.ItemStorageStack +import ru.dbotthepony.mc.otm.storage.StorageStack import java.math.BigInteger import java.util.* -import kotlin.collections.ArrayList -class ItemMatteryDrive : AbstractMatteryDrive, IItemMatteryDrive { - constructor(capacity: BigInteger, max_different_stacks: Int) : super(capacity, maxDifferentStacks = max_different_stacks) - constructor(capacity: BigInteger, uuid: UUID, max_different_stacks: Int) : super(capacity, uuid, max_different_stacks) +class ItemMatteryDrive : AbstractMatteryDrive, IItemMatteryDrive { + constructor(capacity: BigInteger, maxDifferentStacks: Int) : super(capacity, maxDifferentStacks = maxDifferentStacks) + constructor(capacity: BigInteger, uuid: UUID, maxDifferentStacks: Int) : super(capacity, uuid, maxDifferentStacks) constructor(capacity: BigInteger, uuid: UUID) : super(capacity, uuid) constructor(capacity: BigInteger) : super(capacity) - override val storageType: StorageStackType = OverdriveThatMatters.INSTANCE.ITEM_STORAGE() + override val storageType: StorageStack.Type = StorageStack.ITEMS fun insertStack(item: ItemStack, simulate: Boolean): ItemStack { - return insertStack(ItemStackWrapper(item), simulate).stack + return insertStack(ItemStorageStack(item), simulate).toItemStack() } - override fun serializeStack(item: IStorageTuple): CompoundTag? { + override fun serializeStack(item: ItemStorageStack): CompoundTag { val tag = CompoundTag() - val location = item.stack.registryName.toString() - - tag["item"] = location - tag["count"] = item.stack.count.serializeNBT() - - val itag = item.stack.item.tag - - if (itag != null) { - tag["data"] = itag - } - + tag["item"] = item.toItemStack(1).serializeNBT() + tag["count"] = item.count.serializeNBT() return tag } - override fun deserializeStack(tag: CompoundTag): ItemStackWrapper? { - val item = ForgeRegistries.ITEMS.getValue(ResourceLocation(tag.getString("item"))) - - if (item != null && item !== Items.AIR) { + override fun deserializeStack(tag: CompoundTag): ItemStorageStack? { + if ("item" in tag && "count" in tag) { + val item = tag["item"] as? CompoundTag ?: return null val count = BigInteger(tag["count"]) - val itemstack = ItemStack(item, 1) - itemstack.tag = tag["data"] as? CompoundTag - return ItemStackWrapper(itemstack, copy = false).also { it.count = count } + return ItemStorageStack.unsafe(ItemStack.of(item), count) } return null } - override fun findItems(item: Item): List> { - val list = ArrayList>() + override fun findItems(item: Item): List> { + val list = ArrayList>() - for ((key, value) in tuples.entries) { - if (key.item.item === item) { + for ((key, value) in stack2tuples.entries) { + if (key.item === item) { list.add(value) } } @@ -71,8 +53,8 @@ class ItemMatteryDrive : AbstractMatteryDrive, IItemMatteryDri return list } - override fun findItems(stack: ItemStack): IStorageTuple? { - return tuples[ItemStackWrapper(stack).key()] + override fun findItems(stack: ItemStack): IStorageTuple? { + return stack2tuples[ItemStorageStack.unsafe(stack)] } companion object { 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 f08354adb..29ceb9604 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 @@ -68,7 +68,7 @@ class DriveViewerScreen(menu: DriveViewerMenu, inventory: Inventory, title: Comp object : AbstractSlotPanel(this@DriveViewerScreen, grid, 0f, 0f) { override val itemStack: ItemStack get() { val index = i + scrollBar.scroll * GRID_WIDTH - return menu.networkedItemView.sortedView.getOrNull(index)?.stack?.item ?: ItemStack.EMPTY + return menu.networkedItemView.sortedView.getOrNull(index)?.stack?.toItemStack() ?: ItemStack.EMPTY } override fun mouseScrolledInner(x: Double, y: Double, scroll: Double): Boolean { 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 f139c43da..4215dc9cf 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 @@ -32,7 +32,7 @@ import ru.dbotthepony.mc.otm.core.math.integerDivisionDown import ru.dbotthepony.mc.otm.core.util.formatReadableNumber import ru.dbotthepony.mc.otm.core.util.formatSiComponent import ru.dbotthepony.mc.otm.menu.storage.ItemMonitorMenu -import ru.dbotthepony.mc.otm.storage.ITEM_STORAGE +import ru.dbotthepony.mc.otm.storage.StorageStack import yalter.mousetweaks.api.MouseTweaksDisableWheelTweak @MouseTweaksDisableWheelTweak @@ -73,7 +73,7 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp private val index get() = i + viewScrollBar.scroll * ITEM_GRID_WIDTH override val itemStack: ItemStack get() { - return menu.networkedItemView.sortedView.getOrNull(index)?.stack?.item ?: ItemStack.EMPTY + return menu.networkedItemView.sortedView.getOrNull(index)?.stack?.toItemStack() ?: ItemStack.EMPTY } override fun mouseScrolledInner(x: Double, y: Double, scroll: Double): Boolean { @@ -88,10 +88,10 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { renderSlotBackground(graphics, mouseX, mouseY, partialTick) - val itemstack = menu.networkedItemView.sortedView.getOrNull(index)?.stack ?: ITEM_STORAGE.empty + val itemstack = menu.networkedItemView.sortedView.getOrNull(index)?.stack ?: StorageStack.ITEMS.empty val stack = graphics.pose() - renderRegular(graphics, itemstack.stack, "") + renderRegular(graphics, itemstack.toItemStack(), "") if (!itemstack.isEmpty) { stack.pushPose() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/QIO.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/QIO.kt index b63a601e7..d05f2bf3a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/QIO.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/QIO.kt @@ -33,43 +33,43 @@ private val QIO_LOCATION = ResourceLocation(OverdriveThatMatters.MOD_ID, "item_s private class QIOTuple( val mekanismItem: HashedItem, - override val stack: ItemStackWrapper, + override var stack: ItemStorageStack, override val id: UUID, var mark: Long -) : IStorageTuple +) : IStorageTuple.IMutable -private class QIOFrequencyAccess(val parent: QIOFrequency) : IStorageComponent { +private class QIOFrequencyAccess(val parent: QIOFrequency) : IStorageComponent { private var mark = 0L - override val storageType: StorageStackType - get() = OverdriveThatMatters.INSTANCE.ITEM_STORAGE() + override val storageType: StorageStack.Type + get() = StorageStack.ITEMS private val index = HashMap() private val tracked = HashMap() - private val listeners = ArrayList>() + private val listeners = ArrayList>() - override fun get(id: UUID): ItemStackWrapper { - return index[id]?.stack ?: ItemStackWrapper.EMPTY + override fun get(id: UUID): ItemStorageStack { + return index[id]?.stack ?: ItemStorageStack.EMPTY } - override val stacks: Stream> get() { - return ArrayList>(index.size).also { it.addAll(index.values) }.stream() + override val stacks: Stream> get() { + return ArrayList>(index.size).also { it.addAll(index.values) }.stream() } - override fun insertStack(stack: ItemStackWrapper, simulate: Boolean): ItemStackWrapper { + override fun insertStack(stack: ItemStorageStack, simulate: Boolean): ItemStorageStack { // Because there is no simulate method on QIO array, we have to simulate it by ourselves. - val hash = HashedItem.create(stack.item) + val hash = HashedItem.create(stack.toItemStack()) if (!simulate) { //val used = TransporterManager.getToUse(stack.stack, parent.addItem(stack.stack)) - val used = parent.addItem(stack.stack) + val used = parent.addItem(stack.toItemStack()) if (used.count == stack.count.toInt()) { return stack } scan(hash) - return ItemStackWrapper(used) + return ItemStorageStack(used) } if (parent.totalItemCount >= parent.totalItemCountCapacity) { @@ -80,33 +80,31 @@ private class QIOFrequencyAccess(val parent: QIOFrequency) : IStorageComponent copy.count) { // expecting stack to be still present in QIO storage grid @@ -118,7 +116,7 @@ private class QIOFrequencyAccess(val parent: QIOFrequency) : IStorageComponent): Boolean { + override fun addListener(listener: IStorageEventConsumer): Boolean { if (!listeners.contains(listener)) { listeners.add(listener) return true @@ -137,30 +135,29 @@ private class QIOFrequencyAccess(val parent: QIOFrequency) : IStorageComponent): Boolean { + override fun removeListener(listener: IStorageEventConsumer): Boolean { return listeners.remove(listener) } - private fun scan(at: HashedItem, value: QIOItemTypeData = parent.itemDataMap[at] ?: throw IllegalArgumentException("$parent does not have item $at (${at.stack})")) { + private fun scan(at: HashedItem, value: QIOItemTypeData = parent.itemDataMap[at] ?: throw IllegalArgumentException("$parent does not have item $at (${at.internalStack})")) { val local = tracked[at] if (local != null) { local.mark = mark if (local.stack.count.toLong() != value.count) { - val oldCount = local.stack.count - local.stack.count = value.count.toBigInteger() + local.stack = local.stack.copy(value.count.toBigInteger()) for (listener in listeners) { - listener.changeStack(local, oldCount) + listener.onStackChanged(local) } } } else { - val tuple = QIOTuple(at, ItemStackWrapper(at.stack).also { it.count = value.count.toBigInteger() }, UUID.randomUUID(), mark) + val tuple = QIOTuple(at, ItemStorageStack(at.internalStack, value.count.toBigInteger()), UUID.randomUUID(), mark) index[tuple.id] = tuple for (listener in listeners) { - listener.addStack(tuple, this) + listener.onStackAdded(tuple, this) } tracked[at] = tuple @@ -192,7 +189,7 @@ private class QIOFrequencyAccess(val parent: QIOFrequency) : IStorageComponent(private val parent: Iterator, private val map } } +fun concatIterators(): MutableIterator { + return ObjectIterators.EMPTY_ITERATOR as MutableIterator +} + +fun concatIterators(a: Iterator): MutableIterator { + return a as MutableIterator +} + +fun concatIterators(vararg iterators: Iterator): MutableIterator { + return iterators.iterator().flatMap { it } +} + /** * Limits amount of values returned by [parent] iterator to return at most [limit] values * diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageGraph.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageGraph.kt index 11ce5f853..ab8221d28 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageGraph.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageGraph.kt @@ -8,32 +8,22 @@ import ru.dbotthepony.mc.otm.storage.* import java.util.LinkedList class StorageGraph : GraphNodeList() { - private val virtualComponents = Object2ObjectArrayMap, VirtualComponent<*>>() + private val virtualComponents = Object2ObjectArrayMap, VirtualComponent<*>>() val powerDemandingNodes = LinkedList() - /** - * Returns a [VirtualComponent] representing [type] storage - */ - fun getVirtualComponent(type: StorageStackType): VirtualComponent { + fun > getVirtualComponent(type: StorageStack.Type): VirtualComponent { return virtualComponents.computeIfAbsent(type, Object2ObjectFunction { VirtualComponent(type) }) as VirtualComponent } - /** - * Returns a [VirtualComponent] representing [type] storage - */ - fun getVirtualComponent(type: Class): VirtualComponent { - return virtualComponents.computeIfAbsent(StorageRegistry.get(type), Object2ObjectFunction { VirtualComponent(type) }) as VirtualComponent - } - - fun add(storage: IStorage) { + fun > add(storage: IStorage) { getVirtualComponent(storage.storageType).add(storage) } - fun remove(storage: IStorage) { + fun > remove(storage: IStorage) { getVirtualComponent(storage.storageType).remove(storage) } - fun contains(storage: IStorage): Boolean { + fun > contains(storage: IStorage): Boolean { val virtual = virtualComponents[storage.storageType] ?: return false return (virtual as VirtualComponent).contains(storage) } @@ -45,5 +35,4 @@ class StorageGraph : GraphNodeList() { override fun onNodeRemoved(node: StorageNode) { node.removeComponents(this) } - } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNode.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNode.kt index b06493c0c..bc0f21f30 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNode.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNode.kt @@ -5,9 +5,12 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.graph.GraphNode import ru.dbotthepony.mc.otm.storage.IStorage -import ru.dbotthepony.mc.otm.storage.IStorageStack -import ru.dbotthepony.mc.otm.storage.StorageStackType +import ru.dbotthepony.mc.otm.storage.IVirtualStorageComponent +import ru.dbotthepony.mc.otm.storage.StorageStack +import ru.dbotthepony.mc.otm.storage.VirtualComponent +import ru.dbotthepony.mc.otm.storage.powered.PoweredVirtualComponent import java.util.* +import java.util.function.Supplier open class StorageNode(private val energyDemander: IMatteryEnergyStorage? = null) : GraphNode(::StorageGraph) { protected val components = ArrayList>() @@ -72,71 +75,31 @@ open class StorageNode(private val energyDemander: IMatteryEnergyStorage? = null } @Suppress("unchecked_cast") - fun > computeIfAbsent(identity: StorageStackType, provider: (StorageStackType) -> U): U { - for (component in components) { - if (component.storageType === identity) { - return component as U - } - } - - val factory = provider(identity) - addStorageComponent(factory) - return factory + fun , U : IStorage> computeIfAbsent(type: StorageStack.Type, provider: (StorageStack.Type) -> U): U { + return components.firstOrNull { it.storageType == type } as U? ?: provider(type).also { addStorageComponent(it) } } fun addStorageComponent(component: IStorage<*>) { - for (component1 in components) { - if (component === component1 || component1.storageType === component.storageType) { - return - } + if (!components.any { component === it || it.storageType === component.storageType }) { + components.add(component) + + if (isValid && !manualAttaching) + graph.add(component) } - - components.add(component) - - if (isValid && !manualAttaching) - graph.add(component) } fun removeStorageComponent(component: IStorage<*>) { - var indexOf = -1 - - for ((i, component1) in components.withIndex()) { - if (component === component1 || component1.storageType === component.storageType) { - indexOf = i - break - } - } - - if (indexOf == -1) { - return - } - - val self = components[indexOf] - components.removeAt(indexOf) - - if (isValid) - graph.remove(self) + val indexOf = components.indexOfFirst { component === it || it.storageType === component.storageType } + if (indexOf == -1) return + val self = components.removeAt(indexOf) + if (isValid) graph.remove(self) } - fun removeStorageComponent(component: StorageStackType<*>) { - var indexOf = -1 - - for ((i, component1) in components.withIndex()) { - if (component1.storageType === component) { - indexOf = i - break - } - } - - if (indexOf == -1) { - return - } - - val self = components[indexOf] - components.removeAt(indexOf) - - if (isValid && !manualAttaching) - graph.remove(self) + fun removeStorageComponent(component: StorageStack.Type<*>) { + val indexOf = components.indexOfFirst { it.storageType === component } + if (indexOf == -1) return + val self = components.removeAt(indexOf) + if (isValid) graph.remove(self) } override fun invalidate() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 298cf1383..eb7598029 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -97,7 +97,8 @@ import ru.dbotthepony.mc.otm.network.GenericNetworkChannel import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.registry.RegistryDelegate import ru.dbotthepony.mc.otm.secondTime -import ru.dbotthepony.mc.otm.storage.ItemStackWrapper +import ru.dbotthepony.mc.otm.storage.ItemStorageStack +import ru.dbotthepony.mc.otm.storage.StorageStack import java.io.DataInputStream import java.io.DataOutputStream import java.io.File @@ -1202,9 +1203,9 @@ object MatterManager { val drive = value.getCapability(MatteryCapability.DRIVE).orNull() - if (drive != null && drive.storageType == OverdriveThatMatters.INSTANCE.ITEM_STORAGE()) { - (drive as IMatteryDrive).stacks - .map { it.stack.stack } + if (drive != null && drive.storageType == StorageStack.ITEMS) { + (drive as IMatteryDrive).stacks + .map { it.stack.toItemStack() } .filter { !it.isEmpty } .map { get(it, level + 1, true) } .reduce(::reduce) 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 251540c89..ec1205e43 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 @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.menu.data import com.mojang.blaze3d.platform.InputConstants -import it.unimi.dsi.fastutil.ints.Int2ObjectAVLTreeMap import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import net.minecraft.client.Minecraft import net.minecraft.client.gui.screens.Screen @@ -75,11 +74,11 @@ object ClearItemViewPacket : MatteryPacket { } } -class StackAddPacket(val containerId: Int, val id: Int, val stack: ItemStackWrapper) : MatteryPacket { +class StackAddPacket(val containerId: Int, val id: Int, val stack: ItemStorageStack) : MatteryPacket { override fun write(buff: FriendlyByteBuf) { buff.writeInt(containerId) buff.writeInt(id) - buff.writeBigItem(stack) + stack.write(buff) } override fun play(context: Supplier) { @@ -127,7 +126,7 @@ class StackAddPacket(val containerId: Int, val id: Int, val stack: ItemStackWrap fun read(buffer: FriendlyByteBuf): StackAddPacket { val containerId = buffer.readInt() val id = buffer.readInt() - val item = buffer.readBigItem() + val item = StorageStack.ITEMS.read(buffer) return StackAddPacket(containerId, id, item) } } @@ -151,7 +150,7 @@ class StackChangePacket(val id: Int, val stackID: Int, val newCount: BigInteger) val view = (get as? INetworkedItemViewProvider)?.networkedItemView ?: throw IllegalStateException("No such item tracker with id $id") val state = view.localState[stackID] ?: throw IllegalStateException("No such stack with id $stackID in $view") - state.stack.count = newCount + state.stack = state.stack.copy(newCount) view.resort() } } @@ -199,11 +198,11 @@ class StackRemovePacket(val id: Int, val stackID: Int) : MatteryPacket { /** * Creates a virtual, slotless container for Player to interaction with. */ -open class NetworkedItemView(val ply: Player, val menu: MatteryMenu, val remote: Boolean) : IStorageEventConsumer { - data class NetworkedItem constructor(val id: Int, val stack: ItemStackWrapper, val upstreamId: UUID? = null) +open class NetworkedItemView(val ply: Player, val menu: MatteryMenu, val remote: Boolean) : IStorageEventConsumer { + data class NetworkedItem(val id: Int, var stack: ItemStorageStack, val upstreamId: UUID? = null) - override val storageType: StorageStackType - get() = ITEM_STORAGE + override val storageType: StorageStack.Type + get() = StorageStack.ITEMS // this (how client see and interact with) val localState = Int2ObjectOpenHashMap() @@ -233,7 +232,7 @@ open class NetworkedItemView(val ply: Player, val menu: MatteryMenu, val remote: fun resort() { sortedView.sortWith { a, b -> - return@sortWith sorter.compare(a.stack.item, b.stack.item) + return@sortWith sorter.compare(a.stack.toItemStack(), b.stack.toItemStack()) } } @@ -243,7 +242,7 @@ open class NetworkedItemView(val ply: Player, val menu: MatteryMenu, val remote: operator fun get(id: Int): NetworkedItem? = localState[id] - var provider: IStorageComponent? = null + var provider: IStorageComponent? = null private set fun mouseClick(index: Int, mouseButton: Int) { @@ -264,33 +263,33 @@ open class NetworkedItemView(val ply: Player, val menu: MatteryMenu, val remote: ) } - fun setComponent(provider: IStorageComponent?) { + fun setComponent(provider: IStorageComponent?) { if (provider === this.provider) return - this.provider?.removeListenerAuto(this) + this.provider?.removeListenerAndNotify(this) this.provider = provider - provider?.addListenerAuto(this) + provider?.addListenerAndNotify(this) } fun removed() { - provider?.removeListenerAuto(this) + provider?.removeListenerAndNotify(this) } val itemCount get() = localState.values.size - override fun addStack(stack: ItemStackWrapper, id: UUID, provider: IStorageProvider) { + override fun onStackAdded(stack: ItemStorageStack, id: UUID, provider: IStorageProvider) { check(!upstreamState.containsKey(id)) { "Already tracking ItemStack with upstream id $id!" } - val state = NetworkedItem(nextItemID++, stack.copy(), id) + val state = NetworkedItem(nextItemID++, stack, id) this.localState[state.id] = state upstreamState[id] = state network { StackAddPacket(menu.containerId, state.id, state.stack) } } - override fun changeStack(stack: ItemStackWrapper, id: UUID, oldCount: BigInteger) { + override fun onStackChanged(stack: ItemStorageStack, id: UUID) { val get = upstreamState[id] ?: throw IllegalStateException("Unknown ItemStack with upstream id $id!") - get.stack.count = stack.count + get.stack = stack network { StackChangePacket(menu.containerId, get.id, stack.count) } } @@ -300,7 +299,7 @@ open class NetworkedItemView(val ply: Player, val menu: MatteryMenu, val remote: } } - override fun removeStack(stack: ItemStackWrapper, id: UUID) { + override fun onStackRemoved(id: UUID) { val get = upstreamState[id] ?: throw IllegalStateException("Unknown ItemStack with upstream id $id!") upstreamState.remove(id) localState.remove(get.id) @@ -342,7 +341,7 @@ open class NetworkedItemView(val ply: Player, val menu: MatteryMenu, val remote: if (stackId < 0 || !ply.abilities.instabuild) return val state = get(stackId) ?: return - val copy = state.stack.stack.also { it.count = it.maxStackSize } + val copy = state.stack.toItemStack().also { it.count = it.maxStackSize } ply.containerMenu.carried = copy MenuNetworkChannel.send(ply as ServerPlayer, SetCarriedPacket(ply.containerMenu.carried)) @@ -353,17 +352,18 @@ open class NetworkedItemView(val ply: Player, val menu: MatteryMenu, val remote: if (click == ClickType.QUICK_MOVE && stackId > -1) { val state = get(stackId) ?: return + val stack = state.stack.toItemStack() val amount = if (action == ClickAction.PRIMARY) - state.stack.item.maxStackSize + stack.maxStackSize else - 1.coerceAtLeast(state.stack.item.maxStackSize / 2) + 1.coerceAtLeast(stack.maxStackSize / 2) val extracted = provider.extractStack(state.upstreamId!!, amount.toBigInteger(), true) if (!extracted.isEmpty) { - val remaining = menu.quickMoveToInventory(extracted.stack, false) + val remaining = menu.quickMoveToInventory(extracted.toItemStack(), false) if (remaining.count != extracted.count.toInt()) { provider.extractStack(state.upstreamId, (extracted.count.toInt() - remaining.count).toBigInteger(), false) @@ -380,8 +380,7 @@ open class NetworkedItemView(val ply: Player, val menu: MatteryMenu, val remote: val amount = carried.count if (amount == carried.count) { - val stack = provider.insertStack(ItemStackWrapper(menu.carried), false).stack - menu.carried = stack + menu.carried = provider.insertStack(ItemStorageStack(menu.carried), false).toItemStack() MenuNetworkChannel.send(ply as ServerPlayer, SetCarriedPacket(menu.carried)) menu.setRemoteCarried(menu.carried.copy()) } @@ -389,7 +388,7 @@ open class NetworkedItemView(val ply: Player, val menu: MatteryMenu, val remote: val copy = menu.carried.copy() copy.count = 1 - if (provider.insertStack(ItemStackWrapper(copy), false).isEmpty) { + if (provider.insertStack(ItemStorageStack(copy), false).isEmpty) { menu.carried.shrink(1) MenuNetworkChannel.send(ply as ServerPlayer, SetCarriedPacket(menu.carried)) menu.setRemoteCarried(menu.carried.copy()) @@ -397,15 +396,15 @@ open class NetworkedItemView(val ply: Player, val menu: MatteryMenu, val remote: } } else if (stackId > -1) { val state = get(stackId) ?: return + val stack = state.stack.toItemStack() val amount = if (action == ClickAction.PRIMARY) - state.stack.item.maxStackSize + stack.maxStackSize else - (state.stack.stack.count / 2).coerceAtMost(state.stack.item.maxStackSize / 2).coerceAtLeast(1) + (stack.count / 2).coerceAtMost(stack.maxStackSize / 2).coerceAtLeast(1) - val extracted = provider.extractStack(state.upstreamId!!, amount.toBigInteger(), false) - menu.carried = extracted.stack + menu.carried = provider.extractStack(state.upstreamId!!, amount.toBigInteger(), false).toItemStack() MenuNetworkChannel.send(ply as ServerPlayer, SetCarriedPacket(menu.carried)) menu.setRemoteCarried(menu.carried.copy()) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt index bd39f67dd..89e4e664c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt @@ -19,9 +19,9 @@ import ru.dbotthepony.mc.otm.menu.data.INetworkedItemViewProvider import ru.dbotthepony.mc.otm.menu.data.NetworkedItemView import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback import ru.dbotthepony.mc.otm.registry.MMenus -import ru.dbotthepony.mc.otm.storage.ITEM_STORAGE -import ru.dbotthepony.mc.otm.storage.ItemStackWrapper -import ru.dbotthepony.mc.otm.storage.PoweredVirtualComponent +import ru.dbotthepony.mc.otm.storage.ItemStorageStack +import ru.dbotthepony.mc.otm.storage.StorageStack +import ru.dbotthepony.mc.otm.storage.powered.PoweredVirtualComponent class DriveViewerMenu @JvmOverloads constructor( containerID: Int, @@ -33,8 +33,8 @@ class DriveViewerMenu @JvmOverloads constructor( override val networkedItemView = NetworkedItemView(inventory.player, this, tile == null) val driveSlot: MatterySlot - private val powered: PoweredVirtualComponent? - private var lastDrive: IMatteryDrive? = null + private val powered: PoweredVirtualComponent? + private var lastDrive: IMatteryDrive? = null init { val container = tile?.container ?: SimpleContainer(1) @@ -47,8 +47,8 @@ class DriveViewerMenu @JvmOverloads constructor( if (tile != null) { powered = PoweredVirtualComponent( - ItemStackWrapper::class.java, - tile.getCapability(MatteryCapability.ENERGY).resolve().get() + StorageStack.ITEMS, + tile.getCapability(MatteryCapability.ENERGY).resolve()::get ) this.networkedItemView.setComponent(powered) @@ -83,8 +83,8 @@ class DriveViewerMenu @JvmOverloads constructor( if (!itemStack.isEmpty) { itemStack.getCapability(MatteryCapability.DRIVE).ifPresentK { - if (it.storageType === ITEM_STORAGE) { - lastDrive = it as IMatteryDrive + if (it.storageType == StorageStack.ITEMS) { + lastDrive = it as IMatteryDrive } } } @@ -146,7 +146,7 @@ class DriveViewerMenu @JvmOverloads constructor( if (lastDrive == null || powered == null) return ItemStack.EMPTY - val remaining = powered.insertStack(ItemStackWrapper(item), false) + val remaining = powered.insertStack(ItemStorageStack(item), false) if (remaining.count.toInt() == item.count) return ItemStack.EMPTY diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt index c5941db23..d7714883c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt @@ -139,7 +139,7 @@ class ItemMonitorMenu @JvmOverloads constructor( return ItemStack.EMPTY } - val leftover = networkedItemView.provider?.insertStack(ItemStackWrapper(slot.item), false)?.stack ?: slot.item + val leftover = networkedItemView.provider?.insertStack(ItemStorageStack(slot.item), false)?.toItemStack() ?: slot.item if (leftover.count == slot.item.count) { return ItemStack.EMPTY @@ -163,7 +163,7 @@ class ItemMonitorMenu @JvmOverloads constructor( return item } - remainder = networkedItemView.provider?.insertStack(ItemStackWrapper(remainder), false)?.stack ?: remainder + remainder = networkedItemView.provider?.insertStack(ItemStorageStack(remainder), false)?.toItemStack() ?: remainder slots[slotIndex].set(remainder) if (remainder.isEmpty) { @@ -229,8 +229,8 @@ class ItemMonitorMenu @JvmOverloads constructor( try { when (settings.resultTarget) { ItemMonitorPlayerSettings.ResultTarget.ALL_SYSTEM -> { - val wrapper = ItemStackWrapper(item) - var remaining = tile.poweredView?.insertStack(wrapper, true)?.stack ?: return ItemStack.EMPTY + val wrapper = ItemStorageStack(item) + var remaining = tile.poweredView?.insertStack(wrapper, true)?.toItemStack() ?: return ItemStack.EMPTY if (remaining.isEmpty) { tile.poweredView!!.insertStack(wrapper, false) @@ -241,7 +241,7 @@ class ItemMonitorMenu @JvmOverloads constructor( remaining = moveItemStackToSlots(remaining, playerInventorySlots, simulate = true) if (remaining.isEmpty) { - remaining = tile.poweredView!!.insertStack(wrapper, false).stack + remaining = tile.poweredView!!.insertStack(wrapper, false).toItemStack() moveItemStackToSlots(remaining, playerInventorySlots, simulate = false) craftingResult.remove(item.count) return item @@ -259,12 +259,12 @@ class ItemMonitorMenu @JvmOverloads constructor( return item } - val wrapper = ItemStackWrapper(remaining) - remaining = tile.poweredView?.insertStack(wrapper, true)?.stack ?: return ItemStack.EMPTY + val wrapper = ItemStorageStack(remaining) + remaining = tile.poweredView?.insertStack(wrapper, true)?.toItemStack() ?: return ItemStack.EMPTY if (remaining.isEmpty) { moveItemStackToSlots(item, playerInventorySlots, simulate = false) - tile.poweredView!!.insertStack(wrapper, false).stack + tile.poweredView!!.insertStack(wrapper, false) craftingResult.remove(item.count) return item } 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 fd51b3838..2101c8ab0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -43,6 +43,7 @@ import ru.dbotthepony.mc.otm.matter.IMatterFunction import ru.dbotthepony.mc.otm.registry.objects.ColoredDecorativeBlock import ru.dbotthepony.mc.otm.registry.objects.DecorativeBlock import ru.dbotthepony.mc.otm.registry.objects.StripedColoredDecorativeBlock +import ru.dbotthepony.mc.otm.storage.StorageStack import ru.dbotthepony.mc.otm.triggers.AndroidBatteryTrigger import ru.dbotthepony.mc.otm.triggers.KillAsAndroidTrigger import ru.dbotthepony.mc.otm.triggers.AndroidResearchTrigger @@ -274,6 +275,7 @@ object MRegistry { MItemFunctionTypes.register(bus) MLootItemConditions.register(bus) MRecipes.register(bus) + StorageStack.register(bus) if (FMLEnvironment.dist == Dist.CLIENT) { MBlockColors.register(bus) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/API.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/API.kt index 6081246ed..8c5b0953a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/API.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/API.kt @@ -4,69 +4,20 @@ import java.math.BigInteger import java.util.* import java.util.stream.Stream -/** - * Represents a stack in storage system. - * - * In general there are next rules: - * 1. Once created, stack is immutable, except for it's [count], therefore [copy] is expected to do - * "shallow" copies (not performance taxing). - * 2. Due to condition above, and due to sublying storage most of time being - * mutable, it is expected you do defensive copies. Examples of when you should do - * them are described on related interfaces. - * 3. For storing stacks as [Map] keys, a stack with size of 1 is utilized (requiring [equals] and [hashCode] to return meaningful results, see [IStorageStack.key]). - * 4. For equality (INCLUDING count), regular [equals] is utilized. - */ -interface IStorageStack { - fun copy(): IStorageStack - - /** - * Size of this storage stack - * - * This is overriden in subclasses - */ - var count: BigInteger - val isEmpty: Boolean - - /** - * @return max stack size for this stack object, - * null if unlimited (default) - */ - val maxStackSize: BigInteger? get() = null - - /** - * Increase [count] by [amount] - */ - fun grow(amount: BigInteger) { - count += amount - } - - /** - * Decrease [count] by [amount] - */ - fun shrink(amount: BigInteger) { - count -= amount - } -} - -@Suppress("UNCHECKED_CAST") -fun T.key(): T { - return copy().also { it.count = BigInteger.ONE } as T -} - /** * Storage system root, along IStorageStack interface */ -interface IStorage { +interface IStorage> { /** * @return Identity of this virtual component */ - val storageType: StorageStackType + val storageType: StorageStack.Type } /** * Generates events for [IStorageEventConsumer] */ -interface IStorageEventProducer : IStorage { +interface IStorageEventProducer> : IStorage { /** * [listener] is [IStorageEventConsumer] which want to subscribe to our events */ @@ -81,27 +32,39 @@ interface IStorageEventProducer : IStorage { /** * Consumes events produced by [IStorageEventConsumer] */ -interface IStorageEventConsumer : IStorage { +interface IStorageEventConsumer> : IStorage { /** * Fired on whenever an object is added (to listener) we subscribed to */ - fun addStack(stack: T, id: UUID, provider: IStorageProvider) + fun onStackAdded(stack: T, id: UUID, provider: IStorageProvider) /** * Fired on whenever an object is changes on listener we subscribed to */ - fun changeStack(stack: T, id: UUID, oldCount: BigInteger) + fun onStackChanged(stack: T, id: UUID) /** * Fired on whenever an object is removed from listener we subscribed to */ - fun removeStack(stack: T, id: UUID) + fun onStackRemoved(id: UUID) + + fun onStackChanged(tuple: IStorageTuple) { + onStackChanged(tuple.stack, tuple.id) + } + + fun onStackAdded(tuple: IStorageTuple, provider: IStorageProvider) { + onStackAdded(tuple.stack, tuple.id, provider) + } + + fun onStackRemoved(tuple: IStorageTuple) { + onStackRemoved(tuple.id) + } } /** * Storage acceptor, accepts (insert only) stacks provided via [insertStack] method. */ -interface IStorageAcceptor : IStorage { +interface IStorageAcceptor> : IStorage { /** * Inserts an item into system. * @return leftover, might equal to [stack] if no items were inserted @@ -112,10 +75,7 @@ interface IStorageAcceptor : IStorage { /** * Storage provider, provides (extract only) stacks to whoever needs them (the "warehouse"). * - * [get] methods work as in bidirectional map. - * - * It is **required** for storage having **exactly one or none** of mappings of one stack [T] - * to one [UUID] (exactly one *UUID -> stack* and exactly one *stack -> UUID*). + * [get] methods work as in bidirectional map, with each stack mapping to unique [UUID] * * What this means is that [get] with [T] as an argument shall never experience a situation where * two stacks match provided key. @@ -126,15 +86,14 @@ interface IStorageAcceptor : IStorage { * which may or may not produce performance hit; [UUID]s are lightweight, semantically not bound to anything and are * very good for distributed ID generation (so nothing in game has to be bound to one sequential number generator). */ -interface IStorageProvider : IStorageEventProducer { +interface IStorageProvider> : IStorageEventProducer { /** * Attempts to retrieve stored stack by its [id]. * - * Returns stored stack as-is. If no stack with [id] exists, then - * "empty stack" is returned. + * If no stack with [id] exists, then "empty stack" is returned. * * @param id identifier of stack - * @return stored object (not a copy). Do not edit it. + * @return stored object */ operator fun get(id: UUID): T @@ -148,21 +107,13 @@ interface IStorageProvider : IStorageEventProducer { * @return UUID of stack if present */ operator fun get(key: T): UUID? { - val key1 = key.let { if (it.count == BigInteger.ONE) it else it.key() } - - return stacks.filter { - if (it.stack.count == BigInteger.ONE) { - return@filter it.stack == key1 - } else { - return@filter it.stack.key() == key1 - } - }.findFirst().orElse(null)?.id + return stacks.filter { it.stack.equalsWithoutCount(key) }.findFirst().orElse(null)?.id } val stacks: Stream> /** - * If tuple does not exist, returns empty stack + * If storage has no such stack, returns empty stack * * @param id identifier of stack to extract * @param amount amount of units to extract @@ -172,58 +123,35 @@ interface IStorageProvider : IStorageEventProducer { fun extractStack(id: UUID, amount: BigInteger, simulate: Boolean): T } -fun IStorageProvider.removeListenerAuto(listener: IStorageEventConsumer): Boolean { - if (removeListener(listener)) { - for (stack in stacks) { - listener.removeStack(stack.stack, stack.id) - } - - return true - } - - return false -} - -fun IStorageProvider.addListenerAuto(listener: IStorageEventConsumer): Boolean { - if (addListener(listener)) { - for (stack in stacks) { - listener.addStack(stack.stack, stack.id, this) - } - - return true - } - - return false -} - /** * Storage component, which basically implement Input and Output */ -interface IStorageComponent : IStorageProvider, IStorageAcceptor +interface IStorageComponent> : IStorageProvider, IStorageAcceptor -fun IStorageEventConsumer.changeStack(tuple: IStorageTuple, oldCount: BigInteger) { - changeStack(tuple.stack, tuple.id, oldCount) -} - -fun IStorageEventConsumer.addStack(tuple: IStorageTuple, provider: IStorageProvider) { - addStack(tuple.stack, tuple.id, provider) -} - -fun IStorageEventConsumer.removeStack(tuple: IStorageTuple) { - removeStack(tuple.stack, tuple.id) -} - -interface IStorageTuple { +interface IStorageTuple> { val id: UUID val stack: T -} -class StorageTuple(override val id: UUID, override val stack: T) : IStorageTuple + interface IMutable> : IStorageTuple { + override var stack: T + + fun grow(amount: BigInteger) { + stack = stack.grow(amount) + } + + fun shrink(amount: BigInteger) { + stack = stack.shrink(amount) + } + } + + data class I>(override val id: UUID, override val stack: T) : IStorageTuple + data class M>(override val id: UUID, override var stack: T) : IMutable +} /** * Component which (most time) proxy other components (combine their contents into single view) */ -interface IVirtualStorageComponent : IStorageComponent, IStorageEventConsumer { +interface IVirtualStorageComponent> : IStorageComponent, IStorageEventConsumer { fun add(identity: IStorage) fun remove(identity: IStorage) fun contains(identity: IStorage): Boolean diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/Helpers.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/Helpers.kt new file mode 100644 index 000000000..a19e4bb61 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/Helpers.kt @@ -0,0 +1,25 @@ +package ru.dbotthepony.mc.otm.storage + +fun > IStorageProvider.removeListenerAndNotify(listener: IStorageEventConsumer): Boolean { + if (removeListener(listener)) { + for (stack in stacks) { + listener.onStackRemoved(stack.id) + } + + return true + } + + return false +} + +fun > IStorageProvider.addListenerAndNotify(listener: IStorageEventConsumer): Boolean { + if (addListener(listener)) { + for (stack in stacks) { + listener.onStackAdded(stack.stack, stack.id, this) + } + + return true + } + + return false +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/ItemStackWrapper.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/ItemStackWrapper.kt deleted file mode 100644 index 0c9402dd4..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/ItemStackWrapper.kt +++ /dev/null @@ -1,107 +0,0 @@ -package ru.dbotthepony.mc.otm.storage - -import net.minecraft.network.FriendlyByteBuf -import net.minecraft.world.item.ItemStack -import org.jetbrains.annotations.ApiStatus -import ru.dbotthepony.mc.otm.core.* -import ru.dbotthepony.mc.otm.core.math.isPositive -import ru.dbotthepony.mc.otm.core.math.toIntSafe -import ru.dbotthepony.mc.otm.core.registryName -import java.math.BigInteger - -/** - * constructors always copy its input. - */ -class ItemStackWrapper : IStorageStack { - /** - * [ItemStack] representing what item is this. - * - * In most cases you want to use [stack] instead. - */ - @ApiStatus.Internal - val item: ItemStack - val registryName get() = item.item.registryName!! - private val hash: Int - - override var count: BigInteger - - /** - * [copy] as false is used internally for fast index construction, do not specify - * it unless you know what you are doing! - */ - @JvmOverloads - constructor(item: ItemStack, copy: Boolean = true) { - if (copy) { - this.item = item.copy() - } else { - this.item = item - } - - this.count = BigInteger.valueOf(item.count.toLong()) - - if (copy) { - this.item.count = 1 - } - - this.hash = item.tag.hashCode() xor item.item.hashCode() - } - - constructor(item: ItemStackWrapper) { - this.item = item.item - this.count = item.count - this.item.count = 1 - this.hash = item.hash - } - - override fun copy(): ItemStackWrapper { - return ItemStackWrapper(this) - } - - fun sameItem(other: ItemStack) = ItemStack.isSameItemSameTags(item, other) - - override fun equals(other: Any?): Boolean { - if (other === this) - return true - - if (other is ItemStackWrapper) - return other.hash == hash && count == other.count && ItemStack.isSameItemSameTags(item, other.item) - - return false - } - - override fun hashCode(): Int { - return hash * 31 + count.hashCode() - } - - override val maxStackSize: BigInteger get() = BigInteger.valueOf(item.maxStackSize.toLong()) - - override val isEmpty: Boolean get() = item.isEmpty || !count.isPositive - - /** - * [ItemStack] with valid amount and which can be modified after - */ - val stack: ItemStack get() = item.copy().also { it.count = count.toIntSafe() } - - override fun toString(): String { - return "ItemStackWrapper[$count $registryName]" - } - - fun write(buff: FriendlyByteBuf) { - buff.writeItem(item) - buff.writeBigInteger(count) - } - - companion object { - @JvmField - val EMPTY = ItemStackWrapper(ItemStack.EMPTY) - - fun read(buff: FriendlyByteBuf): ItemStackWrapper { - val item = buff.readItem() - val count = buff.readBigInteger() - return ItemStackWrapper(item, copy = false).also { it.count = count } - } - } -} - -fun FriendlyByteBuf.writeBigItem(value: ItemStackWrapper) = value.write(this) -fun FriendlyByteBuf.readBigItem() = ItemStackWrapper.read(this) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/ItemStorageStack.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/ItemStorageStack.kt new file mode 100644 index 000000000..a76046db9 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/ItemStorageStack.kt @@ -0,0 +1,60 @@ +package ru.dbotthepony.mc.otm.storage + +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.core.math.toIntSafe +import java.math.BigInteger + +class ItemStorageStack private constructor(private val stack: ItemStack, count: BigInteger, mark: Nothing?) : StorageStack(count) { + constructor(stack: ItemStack) : this(stack.copy(), BigInteger.valueOf(stack.count.toLong()), null) + constructor(stack: ItemStack, count: Int) : this(stack.copy(), BigInteger.valueOf(count.toLong()), null) + constructor(stack: ItemStack, count: Long) : this(stack.copy(), BigInteger.valueOf(count), null) + constructor(stack: ItemStack, count: BigInteger) : this(stack.copy(), count, null) + + override val type: Type + get() = ITEMS + + override fun copy(newCount: BigInteger): ItemStorageStack { + if (isEmpty) + return ITEMS.empty + + if (newCount == count) + return this + + return ItemStorageStack(stack, newCount, null) + } + + override fun equals(other: Any?): Boolean { + return other is ItemStorageStack && other.count == count && ItemStack.isSameItemSameTags(stack, other.stack) + } + + override fun hashCode(): Int { + return Integer.rotateLeft(count.hashCode(), 12) xor (stack.item.hashCode() * 31 + stack.tag.hashCode()) + } + + override fun equalsWithoutCount(other: StorageStack<*>): Boolean { + return other is ItemStorageStack && ItemStack.isSameItemSameTags(stack, other.stack) + } + + override fun hashCodeWithoutCount(): Int { + return stack.item.hashCode() * 31 + stack.tag.hashCode() + } + + override val isEmpty: Boolean = stack.isEmpty || super.isEmpty + override val maxStackSize: BigInteger = BigInteger.valueOf(stack.maxStackSize.toLong()) + + fun toItemStack(count: Int = this.count.toIntSafe()): ItemStack { + return stack.copyWithCount(count) + } + + val item: Item get() = stack.item + + companion object { + val EMPTY get() = ITEMS.empty + + fun unsafe(stack: ItemStack) = ItemStorageStack(stack, BigInteger.valueOf(stack.count.toLong()), null) + fun unsafe(stack: ItemStack, count: Int) = ItemStorageStack(stack, BigInteger.valueOf(count.toLong()), null) + fun unsafe(stack: ItemStack, count: Long) = ItemStorageStack(stack, BigInteger.valueOf(count), null) + fun unsafe(stack: ItemStack, count: BigInteger) = ItemStorageStack(stack, count, null) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/Registry.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/Registry.kt deleted file mode 100644 index c8e6c54a0..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/Registry.kt +++ /dev/null @@ -1,60 +0,0 @@ -package ru.dbotthepony.mc.otm.storage - -import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.core.math.Decimal -import java.util.IdentityHashMap - -open class StorageStackType( - val identity: Class, - open val empty: T, - - /** - * Speculated energy required per operation on stack with size of 1 - */ - open val energyPerOperation: Decimal, -) { - open fun energyPerOperation(stack: T): Decimal { - return energyPerOperation * stack.count - } - - open fun energyPerStorage(stack: T) = energyPerOperation(stack) - open fun energyPerExtraction(stack: T) = energyPerOperation(stack) - open fun energyForUpkeep(stack: T) = Decimal.ZERO -} - -@Suppress("unchecked_cast") -object StorageRegistry { - private val REGISTRY = IdentityHashMap, StorageStackType<*>>() - - @JvmStatic - fun register(type: StorageStackType<*>): StorageStackType<*> { - check(!REGISTRY.containsKey(type.identity)) { "Already have storage stack type for ${type.identity}" } - REGISTRY[type.identity] = type - return type - } - - /** - * Refer to [StorageStackType] for explanation of flags. - */ - @JvmStatic - fun register( - identity: Class, - empty: T, - energyPerOperation: Decimal - ): StorageStackType { - return register(StorageStackType(identity, empty, energyPerOperation)) as StorageStackType - } - - @JvmStatic - fun get(identity: Class): StorageStackType { - val get = REGISTRY[identity] ?: throw NoSuchElementException("Registry does not contain $identity") - return get as StorageStackType - } - - @JvmStatic - fun getOrNull(identity: Class): StorageStackType? { - return REGISTRY[identity] as StorageStackType? - } -} - -inline val ITEM_STORAGE: StorageStackType get() = OverdriveThatMatters.INSTANCE.ITEM_STORAGE() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/StorageStack.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/StorageStack.kt new file mode 100644 index 000000000..501ff399b --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/StorageStack.kt @@ -0,0 +1,127 @@ +package ru.dbotthepony.mc.otm.storage + +import it.unimi.dsi.fastutil.Hash +import net.minecraft.network.FriendlyByteBuf +import net.minecraft.world.item.ItemStack +import net.minecraftforge.eventbus.api.IEventBus +import net.minecraftforge.registries.DeferredRegister +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.core.getValue +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.readBigInteger +import ru.dbotthepony.mc.otm.core.writeBigInteger +import ru.dbotthepony.mc.otm.core.writeItemType +import ru.dbotthepony.mc.otm.registry.RegistryDelegate +import java.math.BigInteger + +abstract class StorageStack>(val count: BigInteger) { + init { + require(count >= BigInteger.ZERO) { "Negative amount of things in stack: $count" } + } + + abstract val type: Type + abstract fun copy(newCount: BigInteger): S + + abstract fun equalsWithoutCount(other: StorageStack<*>): Boolean + abstract fun hashCodeWithoutCount(): Int + + open val isEmpty: Boolean get() = count == BigInteger.ZERO + inline val isNotEmpty get() = !isEmpty + + open val maxStackSize: BigInteger? get() = null + + abstract override fun equals(other: Any?): Boolean + abstract override fun hashCode(): Int + + fun grow(amount: BigInteger): S { + if (amount == BigInteger.ZERO) return this as S + val newCount = count + amount + + if (newCount <= BigInteger.ZERO) + return type.empty + + return copy(newCount) + } + + fun shrink(amount: BigInteger): S { + if (amount == BigInteger.ZERO) return this as S + val newCount = count - amount + + if (newCount <= BigInteger.ZERO) + return type.empty + + return copy(newCount) + } + + fun write(buff: FriendlyByteBuf) { + type.write(buff, this as S) + } + + interface Type> { + val empty: T + + fun read(buff: FriendlyByteBuf): T + fun write(buff: FriendlyByteBuf, value: T) + + fun energyPerUpkeep(stack: T): Decimal = Decimal.ZERO + fun energyPerInsert(stack: T): Decimal = energyPerOperation(stack) + fun energyPerExtract(stack: T): Decimal = energyPerOperation(stack) + fun energyPerOperation(stack: T): Decimal + } + + class SimpleType>( + val energyPerOperation: Decimal, + override val empty: T, + private val read: (FriendlyByteBuf) -> T, + private val write: (FriendlyByteBuf, T) -> Unit + ) : Type { + override fun read(buff: FriendlyByteBuf): T { + return read.invoke(buff) + } + + override fun write(buff: FriendlyByteBuf, value: T) { + write.invoke(buff, value) + } + + override fun energyPerOperation(stack: T): Decimal { + return energyPerOperation * stack.count + } + } + + companion object : Hash.Strategy?> { + override fun equals(a: StorageStack<*>?, b: StorageStack<*>?): Boolean { + if (a == null && b == null) return true + if (a != null && b != null) return a.equalsWithoutCount(b) + return false + } + + override fun hashCode(o: StorageStack<*>?): Int { + return o?.hashCodeWithoutCount() ?: 0 + } + + private val delegate = RegistryDelegate>("stack_type") { disableSaving() } + val REGISTRY by delegate + val REGISTRY_KEY by delegate::key + + private val registrar = DeferredRegister.create(REGISTRY_KEY, OverdriveThatMatters.MOD_ID) + + val ITEMS: Type by registrar.register("items") { + SimpleType( + Decimal("4"), + ItemStorageStack(ItemStack.EMPTY), + { + ItemStorageStack.unsafe(it.readItem(), it.readBigInteger()) + }, + { buff, v -> + buff.writeItem(v.toItemStack()) + buff.writeBigInteger(v.count) + } + ) + } + + internal fun register(bus: IEventBus) { + bus.addListener(delegate::build) + registrar.register(bus) + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/VirtualComponent.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/VirtualComponent.kt index a8dd38f74..2742d6b09 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/VirtualComponent.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/VirtualComponent.kt @@ -1,23 +1,23 @@ package ru.dbotthepony.mc.otm.storage +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.ObjectArraySet -import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.core.math.isPositive import ru.dbotthepony.mc.otm.core.math.isZero import java.math.BigInteger import java.util.* import java.util.stream.Stream -import kotlin.collections.HashMap -import kotlin.reflect.full.isSubclassOf +import kotlin.collections.ArrayList -class RemoteTuple( - override val stack: T, +class RemoteTuple>( + override var stack: T, override val id: UUID, - val provider: IStorageProvider, + val parent: IStorageProvider, val local: LocalTuple ) : IStorageTuple { fun extract(amount: BigInteger, simulate: Boolean): T { - return provider.extractStack(id, amount, simulate) + return parent.extractStack(id, amount, simulate) } override fun equals(other: Any?): Boolean { @@ -29,21 +29,27 @@ class RemoteTuple( } } -class LocalTuple(override val stack: T, override val id: UUID, val tuples: ArrayList>) : IStorageTuple +class LocalTuple>(override var stack: T, override val id: UUID) : IStorageTuple { + val tuples = ArrayList>(1) -open class VirtualComponent(type: StorageStackType) : IVirtualStorageComponent { - constructor(type: Class) : this(StorageRegistry.get(type)) + fun grow(amount: BigInteger) { + stack = stack.grow(amount) + } - override val storageType: StorageStackType = type + fun shrink(amount: BigInteger) { + stack = stack.shrink(amount) + } +} +open class VirtualComponent>(override val storageType: StorageStack.Type) : IVirtualStorageComponent { // удаленный UUID -> Кортеж - protected val remoteTuples = HashMap>() + protected val remoteTuples = Object2ObjectOpenHashMap>() // локальный UUID -> Локальный кортеж - protected val localTuples = HashMap>() + protected val localTuples = Object2ObjectOpenHashMap>() // Стак -> Локальный кортеж стака - protected val hashedTuples = HashMap>() + protected val item2tuple = Object2ObjectOpenCustomHashMap>(StorageStack.Companion) // ArrayList для скорости работы protected val listeners: MutableSet> = ObjectArraySet() @@ -54,18 +60,17 @@ open class VirtualComponent(type: StorageStackType) : IVir protected open fun onRemove(identity: IStorage) {} override fun add(identity: IStorage) { - if (!(identity.storageType::class.isSubclassOf(storageType::class))) - throw ClassCastException("Reified Generics: ${identity.storageType::class.qualifiedName} can not be cast into ${storageType::class.qualifiedName}") + require(identity.storageType == storageType) { "Attempt to add component of type ${identity.storageType} to virtual component of type $storageType" } if (children.add(identity)) { if (identity is IStorageProvider) { - identity.addListenerAuto(this) + identity.addListenerAndNotify(this) } else if (identity is IStorageEventProducer) { identity.addListener(this) } if (identity is IStorageEventConsumer) { - addListenerAuto(identity) + addListenerAndNotify(identity) } if (identity is IStorageAcceptor) { @@ -77,18 +82,17 @@ open class VirtualComponent(type: StorageStackType) : IVir } override fun remove(identity: IStorage) { - if (!(identity.storageType::class.isSubclassOf(storageType::class))) - throw ClassCastException("Reified Generics: ${identity.storageType::class.qualifiedName} can not be cast into ${storageType::class.qualifiedName}") + require(identity.storageType == storageType) { "Attempt to remove component of type ${identity.storageType} from virtual component of type $storageType" } if (children.remove(identity)) { if (identity is IStorageProvider) { - identity.removeListenerAuto(this) + identity.removeListenerAndNotify(this) } else if (identity is IStorageEventProducer) { identity.removeListener(this) } if (identity is IStorageEventConsumer) { - removeListenerAuto(identity) + removeListenerAndNotify(identity) } if (identity is IStorageAcceptor) { @@ -99,101 +103,85 @@ open class VirtualComponent(type: StorageStackType) : IVir } } - override fun contains(identity: IStorage): Boolean { - return children.contains(identity) - } - - override fun addListener(listener: IStorageEventConsumer): Boolean { - if (listeners.add(listener)) { - return true - } - - return false - } - - override fun removeListener(listener: IStorageEventConsumer): Boolean { - return listeners.remove(listener) - } + override fun contains(identity: IStorage) = children.contains(identity) + override fun addListener(listener: IStorageEventConsumer) = listeners.add(listener) + override fun removeListener(listener: IStorageEventConsumer) = listeners.remove(listener) override fun get(id: UUID): T { return localTuples[id]?.stack ?: this.storageType.empty } override val stacks: Stream> get() { - return ArrayList>(hashedTuples.size).also { it.addAll(hashedTuples.values) }.stream() + return ArrayList>(item2tuple.size).also { it.addAll(item2tuple.values) }.stream() } override fun get(key: T): UUID? { - return hashedTuples[key.key()]?.id + return item2tuple[key]?.id } - @Suppress("unchecked_cast") - override fun addStack(stack: T, id: UUID, provider: IStorageProvider) { + override fun onStackAdded(stack: T, id: UUID, provider: IStorageProvider) { check(!remoteTuples.containsKey(id)) { "Already tracking tuple with id $id" } - val key = stack.key() - var local: LocalTuple? = hashedTuples[key] - var oldCount = BigInteger.ZERO + var local = item2tuple[stack] val added = local == null if (local == null) { - local = LocalTuple(stack.copy() as T, UUID.randomUUID(), ArrayList>(1)) + local = LocalTuple(stack, UUID.randomUUID()) localTuples[local.id] = local - hashedTuples[key] = local + item2tuple[stack] = local } else { - oldCount = local.stack.count - local.stack.grow(stack.count) + local.grow(stack.count) } - val remote = RemoteTuple(stack.copy() as T, id, provider, local) + val remote = RemoteTuple(stack, id, provider, local) local.tuples.add(remote) remoteTuples[id] = remote if (added) { for (listener in listeners) { - listener.addStack(local.stack, local.id, this) + listener.onStackAdded(local.stack, local.id, this) } } else { for (listener in listeners) { - listener.changeStack(local.stack, local.id, oldCount) + listener.onStackChanged(local.stack, local.id) } } } - override fun changeStack(stack: T, id: UUID, oldCount: BigInteger) { + override fun onStackChanged(stack: T, id: UUID) { require(stack.count.isPositive) + val tuple = remoteTuples[id] ?: throw IllegalStateException("No such tuple with id $id") - val diff = stack.count - tuple.stack.count - tuple.stack.count = stack.count - - @Suppress("NAME_SHADOWING") val oldCount = tuple.local.stack.count - tuple.local.stack.grow(diff) + tuple.stack = stack + tuple.local.grow(diff) for (listener in listeners) { - listener.changeStack(tuple.local.stack, tuple.local.id, oldCount) + listener.onStackChanged(tuple.local.stack, tuple.local.id) } } - override fun removeStack(stack: T, id: UUID) { - val tuple = remoteTuples[id] ?: throw IllegalStateException("No such tuple with id $id") + override fun onStackRemoved(id: UUID) { + val remote = remoteTuples.remove(id) ?: throw IllegalStateException("No such tuple with id $id") + val local = remote.local - tuple.local.stack.shrink(tuple.stack.count) - tuple.local.tuples.remove(tuple) + local.shrink(remote.stack.count) + check(local.tuples.remove(remote)) - remoteTuples.remove(id) - - val a = tuple.local.stack.count <= BigInteger.ZERO - val b = tuple.local.tuples.size == 0 + val a = local.stack.isEmpty + val b = local.tuples.isEmpty() if (a || b) { - check(a && b) { "View object is empty, but tuple list is not!" } - localTuples.remove(tuple.local.id) - val key = stack.key() - checkNotNull(hashedTuples.remove(key)) { "No such stack $key" } + check(a && b) { "View stack is empty, but remote tuple list is not!" } + localTuples.remove(local.id) + checkNotNull(item2tuple.remove(remote.stack)) { "No such stack ${remote.stack}" } for (listener in listeners) { - listener.removeStack(tuple.local.stack, tuple.local.id) + listener.onStackRemoved(local.id) + } + } else { + for (listener in listeners) { + listener.onStackChanged(local.stack, local.id) } } } @@ -212,14 +200,13 @@ open class VirtualComponent(type: StorageStackType) : IVir return leftover } - @Suppress("unchecked_cast") override fun extractStack(id: UUID, amount: BigInteger, simulate: Boolean): T { if (!amount.isPositive) return this.storageType.empty @Suppress("name_shadowing") var amount = amount - val tuple: LocalTuple? = localTuples[id] + val tuple = localTuples[id] if (tuple == null || amount.isZero) return this.storageType.empty @@ -229,180 +216,19 @@ open class VirtualComponent(type: StorageStackType) : IVir val toExtract = tuple.stack.count.coerceAtMost(amount) var extracted = BigInteger.ZERO - val copy = tuple.stack.copy() as T + val copy = tuple.stack - for (remote_tuple in tuple.tuples.let { Array(it.size) { i -> it[i] } }) { - val extractedStack = remote_tuple.extract(toExtract - extracted, simulate) - extracted += extractedStack.count + for (remote in ArrayList(tuple.tuples)) { + extracted += remote.extract(toExtract - extracted, simulate).count if (extracted >= toExtract) break } if (extracted.isPositive) { - copy.count = extracted - return copy + return copy.copy(extracted) } return this.storageType.empty } } - -/** - * Adds energy demand to operations over [parent] - */ -open class PoweredComponent(open val parent: IStorageComponent, val energyProvider: () -> IMatteryEnergyStorage) : IStorageComponent { - override val storageType: StorageStackType - get() = parent.storageType - - private val subscribedThrough = ObjectArraySet>() - - final override fun addListener(listener: IStorageEventConsumer): Boolean { - if (parent.addListener(listener)) { - subscribedThrough.add(listener) - return true - } - - return false - } - - final override fun removeListener(listener: IStorageEventConsumer): Boolean { - subscribedThrough.remove(listener) - return parent.removeListener(listener) - } - - fun removeListeners() { - for (child in subscribedThrough) { - parent.removeListener(child) - } - - subscribedThrough.clear() - } - - override fun get(key: T) = parent[key] - - @Suppress("unchecked_cast") - override fun insertStack(stack: T, simulate: Boolean): T { - val required = storageType.energyPerOperation * stack.count - val energy = energyProvider.invoke() - val extracted = energy.extractEnergy(required, true) - - if (extracted.isZero) { - return stack.copy() as T - } - - if (extracted == required) { - val leftover = parent.insertStack(stack, simulate) - - if (leftover.isEmpty) { - if (!simulate) { - energy.extractEnergy(required, false) - } - - return leftover - } - - if (!simulate) { - val requiredNew = storageType.energyPerOperation * (stack.count - leftover.count) - energy.extractEnergy(requiredNew, false) - } - - return leftover - } - - @Suppress("name_shadowing") - val stack = stack.copy() as T - val oldCount = stack.count - stack.count = (extracted / storageType.energyPerOperation).whole - val diff = oldCount - stack.count - val newRequired = storageType.energyPerOperation * stack.count - val newExtracted = energy.extractEnergy(newRequired, true) - - if (newExtracted == newRequired) { - val leftover = parent.insertStack(stack, simulate) - - if (leftover.isEmpty) { - if (!simulate) { - energy.extractEnergy(newRequired, false) - } - - leftover.count = diff - return leftover - } - - if (!simulate) { - val requiredNew = storageType.energyPerOperation * (stack.count - leftover.count) - energy.extractEnergy(requiredNew, false) - } - - leftover.count += diff - return leftover - } - - return stack - } - - override fun get(id: UUID) = parent[id] - - override fun extractStack(id: UUID, amount: BigInteger, simulate: Boolean): T { - val required = storageType.energyPerOperation * amount - val energy = energyProvider.invoke() - val extracted = energy.extractEnergy(required, true) - - if (extracted.isZero) { - return storageType.empty - } - - if (extracted == required) { - val extractedStack = parent.extractStack(id, amount, simulate) - - if (extractedStack.isEmpty) { - return extractedStack - } - - if (!simulate) { - if (extractedStack.count == amount) { - energy.extractEnergy(required, false) - } else { - energy.extractEnergy(storageType.energyPerOperation * extractedStack.count, false) - } - } - - return extractedStack - } - - @Suppress("name_shadowing") - val amount = (required / storageType.energyPerOperation).whole - val extractedStack = parent.extractStack(id, amount, simulate) - - if (extractedStack.isEmpty) { - return extractedStack - } - - if (!simulate) { - energy.extractEnergy(storageType.energyPerOperation * extractedStack.count, false) - } - - return extractedStack - } - - override val stacks get() = parent.stacks -} - -/** - * Adds energy demand to virtual component [parent] - */ -open class PoweredVirtualComponent(override val parent: IVirtualStorageComponent, energyProvider: () -> IMatteryEnergyStorage) - : PoweredComponent(parent, energyProvider), IVirtualStorageComponent { - constructor(parent: IVirtualStorageComponent, energy: IMatteryEnergyStorage) : this(parent, { energy }) - constructor(parent: Class, energy: IMatteryEnergyStorage) : this(VirtualComponent(parent), { energy }) - constructor(parent: StorageStackType, energy: IMatteryEnergyStorage) : this(VirtualComponent(parent), { energy }) - - override fun addStack(stack: T, id: UUID, provider: IStorageProvider) = parent.addStack(stack, id, provider) - override fun changeStack(stack: T, id: UUID, oldCount: BigInteger) = parent.changeStack(stack, id, oldCount) - override fun removeStack(stack: T, id: UUID) = parent.removeStack(stack, id) - - override fun add(identity: IStorage) = parent.add(identity) - override fun remove(identity: IStorage) = parent.remove(identity) - override fun contains(identity: IStorage) = parent.contains(identity) -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredComponent.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredComponent.kt new file mode 100644 index 000000000..eb5f65ab8 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredComponent.kt @@ -0,0 +1,16 @@ +package ru.dbotthepony.mc.otm.storage.powered + +import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage +import ru.dbotthepony.mc.otm.storage.IStorageAcceptor +import ru.dbotthepony.mc.otm.storage.IStorageComponent +import ru.dbotthepony.mc.otm.storage.IStorageProvider +import ru.dbotthepony.mc.otm.storage.StorageStack +import java.util.function.Supplier + +class PoweredComponent>( + val parent: IStorageComponent, + energy: Supplier +) : IStorageComponent, IStorageProvider by PoweredStorageProvider(parent, energy), IStorageAcceptor by PoweredStorageAcceptor(parent, energy) { + override val storageType: StorageStack.Type + get() = parent.storageType +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredStorageAcceptor.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredStorageAcceptor.kt new file mode 100644 index 000000000..c058020c7 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredStorageAcceptor.kt @@ -0,0 +1,34 @@ +package ru.dbotthepony.mc.otm.storage.powered + +import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage +import ru.dbotthepony.mc.otm.storage.IStorageAcceptor +import ru.dbotthepony.mc.otm.storage.StorageStack +import java.util.function.Supplier + +class PoweredStorageAcceptor>(val parent: IStorageAcceptor, val energy: Supplier) : IStorageAcceptor by parent { + override fun insertStack(stack: T, simulate: Boolean): T { + val leftover = parent.insertStack(stack, true) + if (leftover == stack) return stack + + val energy = energy.get() + val required = storageType.energyPerInsert(stack.shrink(leftover.count)) + + if (energy.extractEnergy(required, true) == required) { + if (!simulate) { + val leftover2 = parent.insertStack(stack, false) + + if (leftover2.count != leftover.count) { + energy.extractEnergy(storageType.energyPerInsert(stack.shrink(leftover2.count)), false) + } else { + energy.extractEnergy(required, false) + } + + return leftover2 + } + + return leftover + } + + return stack + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredStorageProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredStorageProvider.kt new file mode 100644 index 000000000..bae9d933d --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredStorageProvider.kt @@ -0,0 +1,36 @@ +package ru.dbotthepony.mc.otm.storage.powered + +import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage +import ru.dbotthepony.mc.otm.storage.IStorageProvider +import ru.dbotthepony.mc.otm.storage.StorageStack +import java.math.BigInteger +import java.util.* +import java.util.function.Supplier + +class PoweredStorageProvider>(val parent: IStorageProvider, val energy: Supplier) : IStorageProvider by parent { + override fun extractStack(id: UUID, amount: BigInteger, simulate: Boolean): T { + val extracted = parent.extractStack(id, amount, simulate) + if (extracted.isEmpty) return extracted + + val energy = energy.get() + val required = storageType.energyPerExtract(extracted) + + if (energy.extractEnergy(required, true) == required) { + if (!simulate) { + val extracted2 = parent.extractStack(id, amount, false) + + if (extracted.count != extracted2.count) { + energy.extractEnergy(storageType.energyPerExtract(extracted2), false) + } else { + energy.extractEnergy(required, false) + } + + return extracted2 + } + + return extracted + } + + return storageType.empty + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredVirtualComponent.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredVirtualComponent.kt new file mode 100644 index 000000000..5f2391019 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredVirtualComponent.kt @@ -0,0 +1,25 @@ +package ru.dbotthepony.mc.otm.storage.powered + +import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage +import ru.dbotthepony.mc.otm.storage.IStorage +import ru.dbotthepony.mc.otm.storage.IStorageComponent +import ru.dbotthepony.mc.otm.storage.IStorageProvider +import ru.dbotthepony.mc.otm.storage.IVirtualStorageComponent +import ru.dbotthepony.mc.otm.storage.StorageStack +import ru.dbotthepony.mc.otm.storage.VirtualComponent +import java.util.* +import java.util.function.Supplier + +class PoweredVirtualComponent>( + val parent: IVirtualStorageComponent, + energy: Supplier +) : IVirtualStorageComponent, IStorageComponent by PoweredComponent(parent, energy) { + constructor(type: StorageStack.Type, energy: Supplier) : this(VirtualComponent(type), energy) + + override fun onStackAdded(stack: T, id: UUID, provider: IStorageProvider) = parent.onStackAdded(stack, id, provider) + override fun onStackChanged(stack: T, id: UUID) = parent.onStackChanged(stack, id) + override fun onStackRemoved(id: UUID) = parent.onStackRemoved(id) + override fun add(identity: IStorage) = parent.add(identity) + override fun remove(identity: IStorage) = parent.remove(identity) + override fun contains(identity: IStorage) = parent.contains(identity) +} From 0754cf55ebced12c23961267a4e27ade7b6f4453 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 7 Aug 2023 14:18:55 +0700 Subject: [PATCH 0946/1199] Don't throw actual exception when custom tex color shader fails to load --- .../ru/dbotthepony/mc/otm/client/render/RenderHelper.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt index 7421ec99f..b64a244e0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt @@ -12,6 +12,7 @@ import net.minecraft.client.renderer.ShaderInstance import net.minecraft.client.renderer.texture.TextureAtlasSprite import net.minecraft.resources.ResourceLocation import net.minecraft.server.packs.resources.ResourceProvider +import org.apache.logging.log4j.LogManager import org.joml.Matrix4f import org.lwjgl.opengl.GL11.GL_ALWAYS import org.lwjgl.opengl.GL11.GL_LESS @@ -39,11 +40,16 @@ var lockBlendFunc = false private val defaultUV = UVCoords(0f, 0f, 1f, 1f) +private val LOGGER = LogManager.getLogger() var customTexColorShader: ShaderInstance by Delegates.notNull() private set fun reloadShaders(provider: ResourceProvider) { - customTexColorShader = ShaderInstance(provider, ResourceLocation(OverdriveThatMatters.MOD_ID, "position_tex_color"), DefaultVertexFormat.POSITION_TEX_COLOR) + try { + customTexColorShader = ShaderInstance(provider, ResourceLocation(OverdriveThatMatters.MOD_ID, "position_tex_color"), DefaultVertexFormat.POSITION_TEX_COLOR) + } catch (err: Throwable) { + LOGGER.error("Failed to load custom tex color shader, this gonna result in uninitialized property exception later", err) + } } fun renderRect( From 81a25973efc53065614cf23683419400a45f6eae Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Mon, 7 Aug 2023 16:26:54 +0300 Subject: [PATCH 0947/1199] =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0?= =?UTF-8?q?=D1=8E=D1=89=D0=B8=D0=B5=20=D0=BA=D0=B0=D0=BF=D1=81=D1=83=D0=BB?= =?UTF-8?q?=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DBot — 06.05.2023 15:04 Не поспорю что увы пока что вся проблема знаешь в чём? что взаимодействие ведра с блоками не в предмете ведра а в самих блоках. за исключением waterlogging, оно в самом ведре --- .../mc/otm/item/FluidCapsuleItem.kt | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) 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 533a6c29a..553bc6630 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt @@ -8,23 +8,29 @@ import net.minecraft.server.level.ServerLevel import net.minecraft.sounds.SoundEvent import net.minecraft.sounds.SoundEvents import net.minecraft.sounds.SoundSource +import net.minecraft.world.InteractionHand import net.minecraft.world.InteractionResult +import net.minecraft.world.InteractionResultHolder import net.minecraft.world.entity.player.Player import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag import net.minecraft.world.item.context.UseOnContext +import net.minecraft.world.level.ClipContext import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.LayeredCauldronBlock +import net.minecraft.world.level.block.LiquidBlockContainer import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.material.Fluid import net.minecraft.world.level.material.Fluids +import net.minecraft.world.phys.HitResult import net.minecraftforge.common.SoundActions import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.capabilities.ICapabilityProvider import net.minecraftforge.fluids.FluidStack +import net.minecraftforge.fluids.FluidUtil import net.minecraftforge.fluids.capability.IFluidHandler import ru.dbotthepony.mc.otm.capability.fluid.ItemMatteryFluidHandler import ru.dbotthepony.mc.otm.capability.fluidLevel @@ -35,6 +41,7 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.immutableMap +import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.core.orNull import java.util.function.IntSupplier @@ -76,6 +83,51 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6 return ItemMatteryFluidHandler(stack, capacity) } + override fun use(level: Level, player: Player, hand: InteractionHand): InteractionResultHolder { + val item = player.getItemInHand(hand) + var targetItem = item.copyWithCount(1) + val cap = targetItem.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).orNull() ?: return InteractionResultHolder.fail(item) + val fluid = cap.getFluidInTank(0) + if (fluid.isNotEmpty && fluid.amount != 1000) return InteractionResultHolder.pass(item) + + val hitResult = getPlayerPOVHitResult(level, player, if (fluid.isEmpty) ClipContext.Fluid.SOURCE_ONLY else ClipContext.Fluid.NONE) + if (hitResult.type != HitResult.Type.BLOCK) return InteractionResultHolder.pass(item) + + val hitPos = hitResult.blockPos + val hitDir = hitResult.direction + val nextPos = hitPos.relative(hitDir) + + if (level.mayInteract(player, hitPos) && player.mayUseItemAt(nextPos, hitDir, item)) { + targetItem = if (fluid.isEmpty) { + val actionResult = FluidUtil.tryPickUpFluid(item, player, level, hitPos, hitDir) + if (!actionResult.isSuccess) return InteractionResultHolder.pass(item) + + actionResult.result + } else { + val state = level.getBlockState(hitPos) + val placePos = if (state.block is LiquidBlockContainer && (state.block as LiquidBlockContainer).canPlaceLiquid(level, hitPos, state, fluid.fluid)) hitPos else nextPos + + val actionResult = FluidUtil.tryPlaceFluid(player, level, hand, placePos, targetItem, fluid) + if (!actionResult.isSuccess) return InteractionResultHolder.pass(item) + + actionResult.result + } + + if (!player.abilities.instabuild && !player.level().isClientSide) { + item.shrink(1) + + if (item.isEmpty) return InteractionResultHolder.sidedSuccess(targetItem, player.level().isClientSide) + if (!player.inventory.add(targetItem)) { + player.spawnAtLocation(targetItem) + } + } + + return InteractionResultHolder.sidedSuccess(item, player.level().isClientSide) + } + + return InteractionResultHolder.pass(item) + } + interface Interaction { fun canInteract(item: ItemStack, player: Player, context: Context): Boolean fun interact(item: ItemStack, player: Player, context: Context): InteractionResult From 506017f0559632f763c95203a24a50d75cce95f9 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 10 Aug 2023 12:55:45 +0700 Subject: [PATCH 0948/1199] Bring storage system back to functional state Add ISubscriptable, which is implemented by networked fields and networked inputs Unify storage grid code Add itemstack and itemstoragestack sorters --- .../mc/otm/datagen/lang/English.kt | 23 +- .../mc/otm/datagen/lang/Russian.kt | 20 + .../mc/otm/OverdriveThatMatters.java | 1 - .../mc/otm/block/entity/MatteryBlockEntity.kt | 2 - .../block/entity/MatteryDeviceBlockEntity.kt | 1 - .../entity/decorative/FluidTankBlockEntity.kt | 1 - .../entity/matter/MatterBottlerBlockEntity.kt | 3 - .../entity/storage/DriveRackBlockEntity.kt | 15 +- .../entity/storage/DriveViewerBlockEntity.kt | 97 ++-- .../entity/storage/ItemMonitorBlockEntity.kt | 506 ++++++++---------- .../entity/storage/StorageBusBlockEntity.kt | 17 +- .../entity/tech/AndroidStationBlockEntity.kt | 5 - .../tech/ChemicalGeneratorBlockEntity.kt | 9 - .../entity/tech/EnergyServoBlockEntity.kt | 1 - .../entity/tech/EssenceStorageBlockEntity.kt | 1 - .../capability/drive/AbstractMatteryDrive.kt | 31 +- .../mc/otm/capability/drive/DrivePool.kt | 299 ++++------- .../client/screen/matter/MatterPanelScreen.kt | 29 +- .../mc/otm/client/screen/panels/FramePanel.kt | 20 +- .../screen/panels/NetworkedItemGridPanel.kt | 110 ++++ .../client/screen/panels/button/Buttons.kt | 36 +- .../screen/panels/slot/AbstractSlotPanel.kt | 2 +- .../client/screen/panels/util/GridPanel.kt | 22 +- .../screen/storage/DriveViewerScreen.kt | 129 ++--- .../screen/storage/ItemMonitorScreen.kt | 134 ++--- .../mc/otm/config/MachinesConfig.kt | 8 +- .../mc/otm/container/CombinedContainer.kt | 5 +- .../mc/otm/container/ContainerIterator.kt | 30 ++ .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 18 +- .../dbotthepony/mc/otm/core/GetterSetter.kt | 13 +- .../dbotthepony/mc/otm/core/ISubscripable.kt | 213 ++++++++ .../mc/otm/core/collect/StreamyIterator.kt | 6 +- .../mc/otm/core/nbt/CompoundTagExt.kt | 7 +- .../mc/otm/core/util/Formatting.kt | 5 +- .../mc/otm/core/util/ItemSorter.kt | 101 +++- .../dbotthepony/mc/otm/core/util/SiPrefix.kt | 1 + .../dbotthepony/mc/otm/core/util/TickList.kt | 16 + .../mc/otm/graph/storage/StorageNode.kt | 26 +- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 15 +- .../ru/dbotthepony/mc/otm/menu/Slots.kt | 7 +- .../mc/otm/menu/data/NetworkedItemView.kt | 355 +++++------- .../input/AbstractPlayerInputWithFeedback.kt | 43 +- .../menu/input/BooleanInputWithFeedback.kt | 26 +- .../otm/menu/input/EnumInputWithFeedback.kt | 28 +- .../otm/menu/input/StringInputWithFeedback.kt | 2 +- .../mc/otm/menu/matter/MatterPanelMenu.kt | 4 +- .../mc/otm/menu/storage/DriveViewerMenu.kt | 55 +- .../mc/otm/menu/storage/ItemMonitorMenu.kt | 212 +++----- .../mc/otm/network/MenuNetworkChannel.kt | 7 +- .../network/synchronizer/FieldSynchronizer.kt | 230 ++++++-- .../mc/otm/network/synchronizer/Fields.kt | 18 +- .../otm/network/synchronizer/MutableFields.kt | 3 +- .../mc/otm/registry/MCreativeTabs.kt | 7 +- .../ru/dbotthepony/mc/otm/registry/MItems.kt | 4 +- .../ru/dbotthepony/mc/otm/storage/API.kt | 4 + .../mc/otm/storage/ItemStorageStack.kt | 5 + .../mc/otm/storage/StorageStack.kt | 14 +- .../mc/otm/storage/VirtualComponent.kt | 27 +- .../otm/storage/powered/PoweredComponent.kt | 12 + .../storage/powered/PoweredStorageAcceptor.kt | 12 + .../storage/powered/PoweredStorageProvider.kt | 55 +- .../powered/PoweredVirtualComponent.kt | 12 + 62 files changed, 1783 insertions(+), 1337 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/NetworkedItemGridPanel.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/ISubscripable.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 3cdaf9e97..46d65a59f 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -213,6 +213,27 @@ private fun misc(provider: MatteryLanguageProvider) { misc("suffix.zepto", "%s z%s") misc("suffix.yocto", "%s y%s") + misc("suffix_concise.none", "%s") + misc("suffix_concise.kilo", "%sk") + misc("suffix_concise.mega", "%sM") + misc("suffix_concise.giga", "%sG") + misc("suffix_concise.tera", "%sT") + misc("suffix_concise.peta", "%sP") + misc("suffix_concise.exa", "%sE") + misc("suffix_concise.zetta", "%sZ") + misc("suffix_concise.yotta", "%sY") + + misc("suffix_concise.deci", "%sd") + misc("suffix_concise.centi", "%sc") + misc("suffix_concise.milli", "%sm") + misc("suffix_concise.micro", "%sμ") + misc("suffix_concise.nano", "%sn") + misc("suffix_concise.pico", "%sp") + misc("suffix_concise.femto", "%sf") + misc("suffix_concise.atto", "%sa") + misc("suffix_concise.zepto", "%sz") + misc("suffix_concise.yocto", "%sy") + misc("suffix_raw.kilo", "k") misc("suffix_raw.mega", "M") misc("suffix_raw.giga", "G") @@ -776,7 +797,7 @@ private fun gui(provider: MatteryLanguageProvider) { gui("sorting.name", "Sort by name") gui("sorting.id", "Sort by ID") gui("sorting.modid", "Sort by Namespace (mod) ID") - gui("sorting.count", "Sort by amount") + gui("sorting.count", "Sort by quantity") gui("sorting.ascending", "Ascending") gui("sorting.descending", "Descending") gui("sorting.matter_value", "Matter value") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 0db712185..22f20e08a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -221,6 +221,26 @@ private fun misc(provider: MatteryLanguageProvider) { misc("suffix.zepto", "%s з%s") misc("suffix.yocto", "%s и%s") + misc("suffix_concise.none", "%s") + misc("suffix_concise.kilo", "%sк") + misc("suffix_concise.mega", "%sМ") + misc("suffix_concise.giga", "%sГ") + misc("suffix_concise.tera", "%sТ") + misc("suffix_concise.peta", "%sП") + misc("suffix_concise.exa", "%sЭ") + misc("suffix_concise.zetta", "%sЗ") + misc("suffix_concise.yotta", "%sИ") + misc("suffix_concise.deci", "%sд") + misc("suffix_concise.centi", "%sс") + misc("suffix_concise.milli", "%sм") + misc("suffix_concise.micro", "%s к") + misc("suffix_concise.nano", "%sн") + misc("suffix_concise.pico", "%sп") + misc("suffix_concise.femto", "%sф") + misc("suffix_concise.atto", "%sа") + misc("suffix_concise.zepto", "%sз") + misc("suffix_concise.yocto", "%sи") + misc("suffix_raw.kilo", "к") misc("suffix_raw.mega", "М") misc("suffix_raw.giga", "Г") diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index f729571bb..0dbfa6ced 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -142,7 +142,6 @@ public final class OverdriveThatMatters { } private void setup(final FMLCommonSetupEvent event) { - EVENT_BUS.addListener(EventPriority.LOWEST, DrivePool.INSTANCE::onServerPostTick); EVENT_BUS.addListener(EventPriority.HIGHEST, DrivePool.INSTANCE::serverStopEvent); EVENT_BUS.addListener(EventPriority.LOWEST, DrivePool.INSTANCE::serverStartEvent); EVENT_BUS.addListener(EventPriority.NORMAL, DrivePool.INSTANCE::onWorldSave); 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 460a3b3b0..ec716f8fa 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 @@ -37,7 +37,6 @@ import net.minecraftforge.event.entity.player.PlayerEvent import net.minecraftforge.event.level.ChunkWatchEvent import net.minecraftforge.event.level.LevelEvent import net.minecraftforge.event.server.ServerStoppingEvent -import net.minecraftforge.items.IItemHandler import ru.dbotthepony.mc.otm.SERVER_IS_LIVE import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.capability.MatteryCapability @@ -45,7 +44,6 @@ import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.isMekanismLoaded import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper import ru.dbotthepony.mc.otm.compat.mekanism.Mekanism2MatteryEnergyWrapper -import ru.dbotthepony.mc.otm.core.collect.SupplierList import ru.dbotthepony.mc.otm.core.collect.WeakHashSet import ru.dbotthepony.mc.otm.core.forValidRefs import ru.dbotthepony.mc.otm.core.get diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index de41cc61a..9e9b368e1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.block.entity import com.google.common.collect.ImmutableSet -import mekanism.common.tile.interfaces.IRedstoneControl import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.core.BlockPos import net.minecraft.world.level.block.state.BlockState 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 ce5f0ac78..a5daaf14a 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,7 +20,6 @@ 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.ifPresentK 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/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index d1d3a52db..5e622489b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -9,17 +9,14 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState -import net.minecraftforge.items.IItemHandler import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState -import ru.dbotthepony.mc.otm.capability.CombinedItemHandler import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.ProxiedItemHandler import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage -import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage import ru.dbotthepony.mc.otm.config.MachinesConfig diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt index c46d9cd0a..c2711da3e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt @@ -17,11 +17,12 @@ import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.menu.storage.DriveRackMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.storage.* +import ru.dbotthepony.mc.otm.storage.powered.PoweredComponent import ru.dbotthepony.mc.otm.storage.powered.PoweredVirtualComponent -class DriveRackBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : - MatteryPoweredBlockEntity(MBlockEntities.DRIVE_RACK, p_155229_, p_155230_) { +class DriveRackBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.DRIVE_RACK, blockPos, blockState) { val energy = WorkerEnergyStorage(this::setChangedLight, MachinesConfig.DRIVE_RACK) + val cell = StorageNode(energy) val container: MatteryContainer = object : MatteryContainer(this::setChanged, 4) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { @@ -31,21 +32,15 @@ class DriveRackBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : // but since we don't know generics of upvalue mattery drive, its storage type // is defined as out variant old.getCapability(MatteryCapability.DRIVE).ifPresent { - cell.computeIfAbsent(it.storageType as StorageStack.Type) { - PoweredVirtualComponent(VirtualComponent(it), ::energy) - }.remove(it as IMatteryDrive) + cell.removeStorageComponent(PoweredComponent(it, ::energy)) } new.getCapability(MatteryCapability.DRIVE).ifPresent { - cell.computeIfAbsent(it.storageType as StorageStack.Type) { - PoweredVirtualComponent(VirtualComponent(it), ::energy) - }.add(it as IMatteryDrive) + cell.addStorageComponent(PoweredComponent(it, ::energy)) } } }.also(::addDroppableContainer) - val cell = StorageNode(energy) - init { savetable(::energy, ENERGY_KEY) savetable(::container, INVENTORY_KEY) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt index 1dd82c294..fbe4d849c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt @@ -1,5 +1,7 @@ package ru.dbotthepony.mc.otm.block.entity.storage +import it.unimi.dsi.fastutil.objects.Object2ObjectFunction +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap import net.minecraft.core.BlockPos import net.minecraft.server.level.ServerLevel import net.minecraft.world.entity.player.Inventory @@ -8,71 +10,88 @@ import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState -import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity -import ru.dbotthepony.mc.otm.block.storage.DriveViewerBlock import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.block.storage.DriveViewerBlock import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.MatteryContainer +import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.util.ItemStorageStackSorter import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.menu.storage.DriveViewerMenu -import ru.dbotthepony.mc.otm.storage.StorageStack +import java.util.UUID -class DriveViewerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.DRIVE_VIEWER, p_155229_, p_155230_) { - override fun setChanged() { - super.setChanged() +class DriveViewerBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.DRIVE_VIEWER, blockPos, blockState) { + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::energyUpdated, MachinesConfig.DRIVE_VIEWER)) + val energyConfig = ConfigurableEnergy(energy) - val level = level - if (level is ServerLevel) - tickList.once { - var state = blockState - - if (container.getItem(0).getCapability(MatteryCapability.DRIVE).isPresent) { - state = state.setValue(WorkerState.SEMI_WORKER_STATE, WorkerState.WORKING) - } else { - state = state.setValue(WorkerState.SEMI_WORKER_STATE, WorkerState.IDLE) - } - - if (state !== blockState) { - level.setBlock(blockPos, state, Block.UPDATE_CLIENTS) - } - } - } - - val energy = WorkerEnergyStorage(this::setChangedLight, MachinesConfig.DRIVE_VIEWER) - - val container: MatteryContainer = object : MatteryContainer(this::setChanged, 1) { + val container: MatteryContainer = object : MatteryContainer(this::setChangedLight, 1) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { super.setChanged(slot, new, old) val level = level - if (level is ServerLevel) + if (level is ServerLevel) { tickList.once { - if (!isRemoved) { - var state = blockState + val isPresent = new.getCapability(MatteryCapability.DRIVE).isPresent + var state = this@DriveViewerBlockEntity.blockState.setValue(DriveViewerBlock.DRIVE_PRESENT, isPresent) - if (new.getCapability(MatteryCapability.DRIVE).isPresent) { - state = state.setValue(DriveViewerBlock.DRIVE_PRESENT, true) - } else { - state = state.setValue(DriveViewerBlock.DRIVE_PRESENT, false) - } + if (!isPresent) { + state = state.setValue(WorkerState.SEMI_WORKER_STATE, WorkerState.IDLE) + } else if (energy.batteryLevel >= Decimal.TEN && !redstoneControl.isBlockedByRedstone) { + state = state.setValue(WorkerState.SEMI_WORKER_STATE, WorkerState.WORKING) + } - if (state !== blockState) { - level.setBlock(blockPos, state, Block.UPDATE_CLIENTS) - } + if (state !== this@DriveViewerBlockEntity.blockState) { + level.setBlock(this@DriveViewerBlockEntity.blockPos, state, Block.UPDATE_CLIENTS) } } + } } }.also(::addDroppableContainer) + interface ISettings { + var sorting: ItemStorageStackSorter + var isAscending: Boolean + } + + inner class Settings : ISettings { + override var sorting: ItemStorageStackSorter = ItemStorageStackSorter.DEFAULT + set(value) { + field = value + setChangedLight() + } + + override var isAscending: Boolean = true + set(value) { + field = value + setChangedLight() + } + } + + val settings = Object2ObjectOpenHashMap() + + fun getSettingsFor(player: Player): ISettings { + return settings.computeIfAbsent(player.uuid, Object2ObjectFunction { Settings() }) + } + + private fun energyUpdated() { + val state = blockState.setValue(WorkerState.SEMI_WORKER_STATE, if (energy.batteryLevel >= Decimal.TEN && !redstoneControl.isBlockedByRedstone && blockState[DriveViewerBlock.DRIVE_PRESENT]) WorkerState.WORKING else WorkerState.IDLE) + + if (state != blockState) { + level?.setBlock(blockPos, state, Block.UPDATE_CLIENTS) + } else { + setChangedLight() + } + } + init { savetable(::energy, ENERGY_KEY) savetable(::container, INVENTORY_KEY) - - exposeEnergyGlobally(energy) } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { 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 2f33be061..b95bb3dfe 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 @@ -1,10 +1,10 @@ package ru.dbotthepony.mc.otm.block.entity.storage +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap import net.minecraft.core.BlockPos import net.minecraft.core.NonNullList import net.minecraft.nbt.CompoundTag -import net.minecraft.network.FriendlyByteBuf import net.minecraft.network.chat.Component import net.minecraft.server.level.ServerPlayer import net.minecraft.world.Container @@ -19,19 +19,18 @@ import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.ForgeHooks import net.minecraftforge.common.util.INBTSerializable -import net.minecraftforge.network.NetworkEvent -import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage -import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.client.render.IGUIRenderable +import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.MatteryContainer -import ru.dbotthepony.mc.otm.container.get import ru.dbotthepony.mc.otm.graph.storage.StorageNode import ru.dbotthepony.mc.otm.graph.storage.StorageGraph -import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.container.set import ru.dbotthepony.mc.otm.core.nbt.mapString @@ -41,122 +40,32 @@ import ru.dbotthepony.mc.otm.storage.* import ru.dbotthepony.mc.otm.storage.powered.PoweredVirtualComponent import java.math.BigInteger import java.util.* -import java.util.function.Supplier import kotlin.collections.HashMap +import ru.dbotthepony.mc.otm.client.render.Widgets8 +import ru.dbotthepony.mc.otm.container.CombinedContainer +import ru.dbotthepony.mc.otm.container.addItem +import ru.dbotthepony.mc.otm.container.fullIterator +import ru.dbotthepony.mc.otm.container.iterator +import ru.dbotthepony.mc.otm.core.collect.map +import ru.dbotthepony.mc.otm.core.collect.toList +import ru.dbotthepony.mc.otm.core.isNotEmpty +import ru.dbotthepony.mc.otm.core.util.ItemStorageStackSorter -class ItemMonitorPlayerSettings : INBTSerializable, MatteryPacket { - enum class IngredientPriority(val component: Component) { - // Refill everything from system - SYSTEM(TranslatableComponent("otm.gui.item_monitor.refill_source.system")), - - // Refill everything from player's inventory - INVENTORY(TranslatableComponent("otm.gui.item_monitor.refill_source.inventory")), - - // Refill everything from system, if can't refill from player's inventory - SYSTEM_FIRST(TranslatableComponent("otm.gui.item_monitor.refill_source.system_first")), - - // Refill everything from player's inventory, if can't refill from system - INVENTORY_FIRST(TranslatableComponent("otm.gui.item_monitor.refill_source.inventory_first")), - - // Do not refill (?) - DO_NOT(TranslatableComponent("otm.gui.item_monitor.refill_source.do_not")), - } - - enum class ResultTarget(val component: Component) { - // Everything goes into storage system - ALL_SYSTEM(TranslatableComponent("otm.gui.item_monitor.result_target.all_system")), - - // Result goes to player inventory - // Crafting remainder goes to storage system - MIXED(TranslatableComponent("otm.gui.item_monitor.result_target.mixed")), - - // Everything goes into player inventory - ALL_INVENTORY(TranslatableComponent("otm.gui.item_monitor.result_target.all_inventory")), - } - - enum class Amount(val component: Component) { - ONE(TranslatableComponent("otm.gui.item_monitor.amount.one")), - STACK(TranslatableComponent("otm.gui.item_monitor.amount.stack")), - FULL(TranslatableComponent("otm.gui.item_monitor.amount.full")) - } - - var ingredientPriority = IngredientPriority.SYSTEM - var resultTarget = ResultTarget.MIXED - var craftingAmount = Amount.STACK - - override fun serializeNBT(): CompoundTag { - return CompoundTag().also { - it[INGREDIENT_PRIORITY_KEY] = ingredientPriority.name - it[RESULT_TARGET_KEY] = resultTarget.name - it[QUICK_CRAFT_AMOUNT_KEY] = craftingAmount.name - } - } - - override fun deserializeNBT(nbt: CompoundTag) { - ingredientPriority = nbt.mapString(INGREDIENT_PRIORITY_KEY, IngredientPriority::valueOf, IngredientPriority.SYSTEM) - resultTarget = nbt.mapString(RESULT_TARGET_KEY, ResultTarget::valueOf, ResultTarget.MIXED) - craftingAmount = nbt.mapString(QUICK_CRAFT_AMOUNT_KEY, Amount::valueOf, Amount.STACK) - } - - fun read(buff: FriendlyByteBuf) { - ingredientPriority = buff.readEnum(IngredientPriority::class.java) - resultTarget = buff.readEnum(ResultTarget::class.java) - craftingAmount = buff.readEnum(Amount::class.java) - } - - fun read(other: ItemMonitorPlayerSettings) { - ingredientPriority = other.ingredientPriority - resultTarget = other.resultTarget - craftingAmount = other.craftingAmount - } - - override fun write(buff: FriendlyByteBuf) { - buff.writeEnum(ingredientPriority) - buff.writeEnum(resultTarget) - buff.writeEnum(craftingAmount) - } - - private fun playClient() { - val ply = minecraft.player ?: throw IllegalStateException("Player is missing") - val container = ply.containerMenu as? ItemMonitorMenu ?: return LOGGER.error("Received ItemMonitorPlayerSettings but container is missing or not of right type ({})!", ply.containerMenu) - - container.settings.read(this) - } - - // spectators are allowed because they change their own setting which is invisible to everyone else - private fun playServer(ply: ServerPlayer) { - val container = ply.containerMenu as? ItemMonitorMenu ?: return LOGGER.error("Received ItemMonitorPlayerSettings from {} but container is missing or not of right type ({})!", ply, ply.containerMenu) - container.settings.read(this) - (container.tile as ItemMonitorBlockEntity).setChangedLight() - } - - override fun play(context: Supplier) { - context.get().packetHandled = true - val ply = context.get().sender - - if (ply != null) { - playServer(ply) - } else { - playClient() - } - } - - companion object { - fun read(buff: FriendlyByteBuf): ItemMonitorPlayerSettings { - return ItemMonitorPlayerSettings().also { it.read(buff) } - } - - private val LOGGER = LogManager.getLogger() - const val INGREDIENT_PRIORITY_KEY = "ingredientPriority" - const val RESULT_TARGET_KEY = "resultTarget" - const val QUICK_CRAFT_AMOUNT_KEY = "quickCraftAmount" - } +interface IItemMonitorPlayerSettings { + var ingredientPriority: ItemMonitorPlayerSettings.IngredientPriority + var resultTarget: ItemMonitorPlayerSettings.ResultTarget + var craftingAmount: ItemMonitorPlayerSettings.Amount + var sorting: ItemStorageStackSorter + var ascendingSort: Boolean } -private fun takeOne(inventory: Inventory, item: ItemStack): Boolean { - for (i in 0 until inventory.containerSize) { - if (!inventory[i].isEmpty && ItemStack.isSameItemSameTags(inventory[i], item)) { - inventory.removeItem(i, 1) +private fun takeOne(inventory: CombinedContainer?, item: ItemStack): Boolean { + val iterator = inventory?.optimizedIterator() ?: return false + + for (stack in iterator) { + if (stack.equals(item, false)) { + stack.shrink(1) + inventory.setChanged() return true } } @@ -164,21 +73,110 @@ private fun takeOne(inventory: Inventory, item: ItemStack): Boolean { return false } -private fun takeOne(id: UUID?, view: IStorageProvider): Boolean { - val extracted = view.extractStack(id ?: return false, BigInteger.ONE, false) +private fun takeOne(id: UUID?, view: IStorageProvider?): Boolean { + return view?.extractStack(id ?: return false, BigInteger.ONE, false)?.isNotEmpty == true +} - if (!extracted.isEmpty) { - return true +class ItemMonitorPlayerSettings : INBTSerializable, IItemMonitorPlayerSettings { + interface Setting { + val component: Component + val icon: IGUIRenderable + val winding: UVWindingOrder } - return false + enum class IngredientPriority(override val component: Component, icon: Lazy, override val winding: UVWindingOrder = UVWindingOrder.NORMAL) : Setting { + // Refill everything from system + SYSTEM(TranslatableComponent("otm.gui.item_monitor.refill_source.system"), lazy { Widgets8.WHITE_ARROW_DOWN }, UVWindingOrder.FLIP) { + override fun takeOne(item: ItemStack, view: IStorageProvider?, inventory: CombinedContainer?, id: UUID?): Boolean { + return takeOne(id, view) + } + }, + + // Refill everything from player's inventory + INVENTORY(TranslatableComponent("otm.gui.item_monitor.refill_source.inventory"), lazy { Widgets8.WHITE_ARROW_DOWN }) { + override fun takeOne(item: ItemStack, view: IStorageProvider?, inventory: CombinedContainer?, id: UUID?): Boolean { + return takeOne(inventory, item) + } + }, + + // Refill everything from system, if can't refill from player's inventory + SYSTEM_FIRST(TranslatableComponent("otm.gui.item_monitor.refill_source.system_first"), lazy { Widgets8.ARROW_SIDEWAYS }, UVWindingOrder.FLIP) { + override fun takeOne(item: ItemStack, view: IStorageProvider?, inventory: CombinedContainer?, id: UUID?): Boolean { + return takeOne(id, view) || takeOne(inventory, item) + } + }, + + // Refill everything from player's inventory, if can't refill from system + INVENTORY_FIRST(TranslatableComponent("otm.gui.item_monitor.refill_source.inventory_first"), lazy { Widgets8.ARROW_SIDEWAYS }) { + override fun takeOne(item: ItemStack, view: IStorageProvider?, inventory: CombinedContainer?, id: UUID?): Boolean { + return takeOne(inventory, item) || takeOne(id, view) + } + }, + + // Do not refill (?) + DO_NOT(TranslatableComponent("otm.gui.item_monitor.refill_source.do_not"), lazy { Widgets8.MINUS }) { + override fun takeOne(item: ItemStack, view: IStorageProvider?, inventory: CombinedContainer?, id: UUID?): Boolean { + return false + } + }; + + override val icon: IGUIRenderable by icon + + abstract fun takeOne(item: ItemStack, view: IStorageProvider?, inventory: CombinedContainer?, id: UUID?): Boolean + } + + enum class ResultTarget(override val component: Component, icon: Lazy, override val winding: UVWindingOrder = UVWindingOrder.NORMAL) : Setting { + // Everything goes into storage system + ALL_SYSTEM(TranslatableComponent("otm.gui.item_monitor.result_target.all_system"), lazy { Widgets8.ARROW_PAINTED_UP }), + + // Result goes to player inventory + // Crafting remainder goes to storage system + MIXED(TranslatableComponent("otm.gui.item_monitor.result_target.mixed"), lazy { Widgets8.ARROW_SIDEWAYS }), + + // Everything goes into player inventory + ALL_INVENTORY(TranslatableComponent("otm.gui.item_monitor.result_target.all_inventory"), lazy { Widgets8.ARROW_PAINTED_UP }, UVWindingOrder.FLIP); + + override val icon: IGUIRenderable by icon + } + + enum class Amount(override val component: Component, icon: Lazy, override val winding: UVWindingOrder = UVWindingOrder.NORMAL) : Setting { + ONE(TranslatableComponent("otm.gui.item_monitor.amount.one"), lazy { Widgets8.ONE }), + STACK(TranslatableComponent("otm.gui.item_monitor.amount.stack"), lazy { Widgets8.S }), + FULL(TranslatableComponent("otm.gui.item_monitor.amount.full"), lazy { Widgets8.F }); + + override val icon: IGUIRenderable by icon + } + + override var ingredientPriority = IngredientPriority.SYSTEM + override var resultTarget = ResultTarget.MIXED + override var craftingAmount = Amount.STACK + override var sorting: ItemStorageStackSorter = ItemStorageStackSorter.DEFAULT + override var ascendingSort: Boolean = false + + override fun serializeNBT(): CompoundTag { + return CompoundTag().also { + it["ingredientPriority"] = ingredientPriority.name + it["resultTarget"] = resultTarget.name + it["quickCraftAmount"] = craftingAmount.name + it["sorting"] = sorting.name + it["ascendingSort"] = ascendingSort + } + } + + override fun deserializeNBT(nbt: CompoundTag) { + ingredientPriority = nbt.mapString("ingredientPriority", IngredientPriority::valueOf, IngredientPriority.SYSTEM) + resultTarget = nbt.mapString("resultTarget", ResultTarget::valueOf, ResultTarget.MIXED) + craftingAmount = nbt.mapString("quickCraftAmount", Amount::valueOf, Amount.STACK) + sorting = nbt.mapString("sorting", ItemStorageStackSorter::valueOf, ItemStorageStackSorter.DEFAULT) + ascendingSort = nbt.getBoolean("ascendingSort") + } } class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.ITEM_MONITOR, blockPos, blockState), IStorageEventConsumer { - val energy = WorkerEnergyStorage(this::setChangedLight, MachinesConfig.ITEM_MONITOR) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::setChangedLight, MachinesConfig.ITEM_MONITOR)) + val energyConfig = ConfigurableEnergy(energy) init { - exposeEnergyGlobally(energy) savetable(::energy, ENERGY_KEY) } @@ -203,79 +201,74 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte } private val settings = HashMap() - private val craftingAmount = Object2ObjectArrayMap() + private val craftingAmount = Object2IntOpenHashMap() private val lastCraftingRecipe = Object2ObjectArrayMap() + private var inProcessOfCraft = false + private val craftingGridTuples = arrayOfNulls(3 * 3) - fun howMuchPlayerCrafted(ply: Player): Int = craftingAmount[ply] ?: 0 + fun howMuchPlayerCrafted(ply: Player): Int = craftingAmount.getInt(ply) fun lastCraftingRecipe(ply: Player) = lastCraftingRecipe[ply] // a lot of code is hardcoded to take CraftingContainer as it's input // hence we are forced to work around this by providing proxy container - val craftingGrid = object : MatteryContainer(::setChangedLight, 3 * 3) { + val craftingGrid = object : MatteryContainer(3 * 3) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { - super.setChanged(slot, new, old) - craftingGridDummy[slot] = new + setChangedLight() + craftingGridVanilla[slot] = new - if (!inProcessOfCraft) - scanCraftingGrid() + if (!inProcessOfCraft) { + scanCraftingGrid(false) + } } }.also(::addDroppableContainer) - private var inProcessOfCraft = false + private val craftingGridVanilla = TransientCraftingContainer(object : AbstractContainerMenu(null, Int.MIN_VALUE) { + override fun stillValid(p_38874_: Player) = true + override fun quickMoveStack(p_38941_: Player, p_38942_: Int) = ItemStack.EMPTY + }, 3, 3) - private fun scanCraftingGrid() { - val server = level?.server ?: return - val oldRecipe = craftingRecipe + private fun scanCraftingGrid(justCheckForRecipeChange: Boolean): Boolean { + val level = level ?: return false + val server = level.server ?: return false - if (oldRecipe != null && oldRecipe.matches(craftingGridDummy, level!!)) { - return - } + var craftingRecipe = craftingRecipe + if (craftingRecipe != null && craftingRecipe.matches(craftingGridVanilla, level)) return true + if (justCheckForRecipeChange) return false - craftingRecipe = server.recipeManager.getRecipeFor(RecipeType.CRAFTING, craftingGridDummy, level!!).orElse(null) - val craftingRecipe = craftingRecipe + craftingRecipe = server.recipeManager.getRecipeFor(RecipeType.CRAFTING, craftingGridVanilla, level).orElse(null) + Arrays.fill(craftingGridTuples, null) + val poweredView = poweredView - if (oldRecipe != craftingRecipe) { - Arrays.fill(craftingGridTuples, null) + if (craftingRecipe != null && poweredView != null) { + for (i in craftingGridTuples.indices) { + val item = craftingGrid[i] - val poweredView = poweredView - - if (craftingRecipe != null && poweredView != null) { - for (i in craftingGridTuples.indices) { - val item = craftingGrid[i] - - if (!item.isEmpty) { - craftingGridTuples[i] = poweredView[ItemStorageStack.unsafe(item)] - } + if (!item.isEmpty) { + craftingGridTuples[i] = poweredView[ItemStorageStack.unsafe(item)] } } } + + this.craftingRecipe = craftingRecipe + return false } - private val craftingGridTuples = arrayOfNulls(3 * 3) - - private val craftingMenu = object : AbstractContainerMenu(null, Int.MIN_VALUE) { - override fun stillValid(p_38874_: Player): Boolean { - return true - } - - override fun quickMoveStack(p_38941_: Player, p_38942_: Int): ItemStack { - return ItemStack.EMPTY - } - } - - private val craftingGridDummy = TransientCraftingContainer(craftingMenu, 3, 3) - override val storageType: StorageStack.Type get() = StorageStack.ITEMS override fun onStackAdded(stack: ItemStorageStack, id: UUID, provider: IStorageProvider) { - // no op - } - - override fun onStackChanged(stack: ItemStorageStack, id: UUID) { - // no op + if (craftingRecipe != null) { + for (i in craftingGridTuples.indices) { + val item = craftingGrid[i] + + if (!item.isEmpty && stack.equalsWithoutCount(ItemStorageStack.unsafe(item))) { + craftingGridTuples[i] = id + } + } + } } + override fun onStackChanged(stack: ItemStorageStack, id: UUID) {} override fun onStackRemoved(id: UUID) { for (i in craftingGridTuples.indices) { if (craftingGridTuples[i] == id) { @@ -300,137 +293,112 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte override fun getContainerSize() = 1 override fun isEmpty() = craftingRecipe == null - override fun stillValid(p_18946_: Player) = true + override fun stillValid(player: Player) = true - override fun getItem(p_18941_: Int): ItemStack { - require(p_18941_ == 0) { "Invalid slot ID: $p_18941_" } + override fun getItem(slot: Int): ItemStack { + require(slot == 0) { "Invalid slot: $slot" } return craftingRecipe?.getResultItem(level?.registryAccess() ?: return ItemStack.EMPTY)?.copy() ?: ItemStack.EMPTY } override fun removeItem(index: Int, amount: Int): ItemStack { require(index == 0) { "Invalid index $index" } - val craftingRecipe = craftingRecipe - val craftingPlayer = craftingPlayer + val level = level ?: return ItemStack.EMPTY + val craftingRecipe = craftingRecipe ?: return ItemStack.EMPTY + val craftingPlayer = craftingPlayer ?: return ItemStack.EMPTY - if (craftingRecipe == null || craftingPlayer == null || craftingRecipe.getResultItem(level?.registryAccess() ?: return ItemStack.EMPTY).count != amount) { - return ItemStack.EMPTY + try { + ForgeHooks.setCraftingPlayer(craftingPlayer) + + if (craftingRecipe.getResultItem(level.registryAccess()).count != amount) { + return ItemStack.EMPTY + } + } finally { + ForgeHooks.setCraftingPlayer(null) } - var crafts = craftingAmount[craftingPlayer] ?: 0 - crafts++ - craftingAmount[craftingPlayer] = crafts + craftingAmount[craftingPlayer] = craftingAmount.getInt(craftingPlayer) + 1 lastCraftingRecipe[craftingPlayer] = craftingRecipe + tickList.namedTimer(craftingPlayer, 4) { + craftingAmount.removeInt(craftingPlayer) + lastCraftingRecipe.remove(craftingPlayer) + } + val settings = getSettings(craftingPlayer) inProcessOfCraft = true try { ForgeHooks.setCraftingPlayer(craftingPlayer) - val remainingItems: NonNullList = craftingRecipe.getRemainingItems(craftingGridDummy) - ForgeHooks.setCraftingPlayer(null) + val residue: NonNullList + val result: ItemStack - check(remainingItems.size == craftingGrid.containerSize) { "${remainingItems.size} != ${craftingGrid.containerSize} !!!" } + try { + residue = craftingRecipe.getRemainingItems(craftingGridVanilla) + result = craftingRecipe.getResultItem(level.registryAccess()) + } finally { + ForgeHooks.setCraftingPlayer(null) + } + check(residue.size == craftingGrid.containerSize) { "Container and residue list sizes mismatch: ${residue.size} != ${craftingGrid.containerSize}" } + + val combinedInventory = craftingPlayer.matteryPlayer?.combinedInventory + val copy = craftingGrid.fullIterator().map { it.copy() }.toList() + + // удаляем по одному предмету из сетки крафта for (slot in 0 until craftingGrid.containerSize) { - val oldItem = craftingGrid[slot].let { if (!it.isEmpty || it.count < 2) it.copy() else it } + craftingGrid.removeItem(slot, 1) - if (!craftingGrid[slot].isEmpty) { - craftingGrid.removeItem(slot, 1) + if (residue[slot].isNotEmpty) { + craftingGrid[slot] = residue[slot] } + } - var newItem = craftingGrid[slot] - - if (newItem.isEmpty) { - when (settings.ingredientPriority) { - ItemMonitorPlayerSettings.IngredientPriority.SYSTEM -> { - if (poweredView != null && takeOne(craftingGridTuples[slot], poweredView!!)) { - newItem = oldItem - craftingGrid[slot] = newItem - } - } - - ItemMonitorPlayerSettings.IngredientPriority.INVENTORY -> { - if (takeOne(craftingPlayer.inventory, oldItem)) { - newItem = oldItem - craftingGrid[slot] = newItem - } - } - - ItemMonitorPlayerSettings.IngredientPriority.SYSTEM_FIRST -> { - if (poweredView != null && takeOne(craftingGridTuples[slot], poweredView!!)) { - newItem = oldItem - craftingGrid[slot] = newItem - } - - if (newItem.isEmpty && takeOne(craftingPlayer.inventory, oldItem)) { - newItem = oldItem - craftingGrid[slot] = newItem - } - } - - ItemMonitorPlayerSettings.IngredientPriority.INVENTORY_FIRST -> { - if (takeOne(craftingPlayer.inventory, oldItem)) { - newItem = oldItem - craftingGrid[slot] = newItem - } else if (poweredView != null && takeOne(craftingGridTuples[slot], poweredView!!)) { - newItem = oldItem - craftingGrid[slot] = newItem - } - } - - ItemMonitorPlayerSettings.IngredientPriority.DO_NOT -> { /* no op */ } + if (!scanCraftingGrid(true)) { + // заполняем опустевшие слоты + for (slot in 0 until craftingGrid.containerSize) { + if ( + craftingGrid[slot].isEmpty && + copy[slot].isNotEmpty && + settings.ingredientPriority.takeOne(copy[slot], poweredView, combinedInventory, craftingGridTuples[slot]) + ) { + craftingGrid[slot] = copy[slot].copyWithCount(1) } } + } - val remainder = remainingItems[slot] + if (!scanCraftingGrid(true)) { + // избавляемся от остатков, если они мешают + for (slot in 0 until craftingGrid.containerSize) { + if (residue[slot].isNotEmpty) { + var remaining = residue[slot] - if (!remainder.isEmpty) { - when (settings.resultTarget) { - ItemMonitorPlayerSettings.ResultTarget.ALL_SYSTEM, ItemMonitorPlayerSettings.ResultTarget.MIXED -> { - val remaining = poweredView?.insertStack(ItemStorageStack(remainder), false)?.toItemStack() ?: remainder - - if (!remaining.isEmpty) { - if (newItem.isEmpty) { - craftingGrid[slot] = remaining - } else if (ItemStack.isSameItemSameTags(newItem, remaining)) { - newItem.grow(remaining.count) - craftingGrid.setChanged(slot) - } else if (!craftingPlayer.inventory.add(remaining)) { - craftingPlayer.drop(remaining, false) - } - } + if (settings.resultTarget != ItemMonitorPlayerSettings.ResultTarget.ALL_INVENTORY) { + remaining = poweredView?.insertStack(ItemStorageStack(remaining), false)?.toItemStack() ?: remaining } - ItemMonitorPlayerSettings.ResultTarget.ALL_INVENTORY -> { - if (!craftingPlayer.inventory.add(remainder)) { - val remaining = poweredView?.insertStack(ItemStorageStack(remainder), false)?.toItemStack() ?: remainder + remaining = combinedInventory?.addItem(remaining, false) ?: remaining - if (!remaining.isEmpty) { - if (newItem.isEmpty) { - craftingGrid[slot] = remaining - } else if (ItemStack.isSameItemSameTags(newItem, remaining)) { - newItem.grow(remaining.count) - craftingGrid.setChanged(slot) - } else { - craftingPlayer.drop(remaining, false) - } - } - } + if (remaining.isNotEmpty) { + craftingPlayer.spawnAtLocation(remaining) + } + + if (copy[slot].isNotEmpty && settings.ingredientPriority.takeOne(copy[slot], poweredView, combinedInventory, craftingGridTuples[slot])) { + craftingGrid[slot] = copy[slot].copyWithCount(1) } } } } + + return result.copy() } finally { inProcessOfCraft = false - scanCraftingGrid() + scanCraftingGrid(false) } - - return craftingRecipe.getResultItem(level?.registryAccess() ?: return ItemStack.EMPTY).copy() } - override fun removeItemNoUpdate(p_18951_: Int): ItemStack { + override fun removeItemNoUpdate(slot: Int): ItemStack { throw UnsupportedOperationException() } @@ -464,11 +432,7 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte val settings = nbt.getCompound("player_settings") for (key in settings.allKeys) { - val uuid = UUID.fromString(key) - val deserialized = ItemMonitorPlayerSettings() - deserialized.deserializeNBT(settings.getCompound(key)) - - check(this.settings.put(uuid, deserialized) == null) { "Duplicate UUID??? $uuid" } + check(this.settings.put(UUID.fromString(key), ItemMonitorPlayerSettings().also { it.deserializeNBT(settings.getCompound(key)) }) == null) } craftingGrid.deserializeNBT(nbt["crafting_grid"]) @@ -480,14 +444,7 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte override fun tick() { super.tick() - cell.tickEnergyDemanding() - - if (craftingAmount.size != 0) - craftingAmount.clear() - - if (lastCraftingRecipe.size != 0) - lastCraftingRecipe.clear() } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { @@ -497,6 +454,7 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte override fun setLevel(level: Level) { super.setLevel(level) cell.discover(this) + scanCraftingGrid(false) } override fun setRemoved() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt index 57a8530ca..0071f5dbc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.block.entity.storage import it.unimi.dsi.fastutil.ints.Int2ObjectAVLTreeMap import it.unimi.dsi.fastutil.ints.IntAVLTreeSet +import it.unimi.dsi.fastutil.ints.IntArrayList import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap import net.minecraft.core.BlockPos import net.minecraft.world.entity.player.Inventory @@ -126,6 +127,7 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter private inner class ItemHandlerComponent(private val parent: IItemHandler) : IStorageComponent { private fun updateTuple(tuple: TrackedTuple, diff: BigInteger) { + val stack = tuple.stack tuple.stack = tuple.stack.grow(diff) if (tuple.stack.isNotEmpty) { @@ -138,7 +140,7 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter } id2tuples.remove(tuple.id) - items2tuples.remove(tuple.stack) ?: throw IllegalStateException("Cross-reference integrity check failed for $tuple") + items2tuples.remove(stack) ?: throw IllegalStateException("Cross-reference integrity check failed for $tuple") } } @@ -376,29 +378,32 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter val tuple = id2tuples[id] ?: return ItemStorageStack.EMPTY val slots = tuple.children.values.iterator() val lstack = tuple.stack + val affectedSlots = IntArrayList() - while (amount < total && slots.hasNext() && energy.batteryLevel.isPositive) { + while (amount > total && slots.hasNext() && energy.batteryLevel.isPositive) { val (slot, stack) = slots.next() - val extracted = parent.extractItem(slot, stack.count.coerceAtMost(amount.toIntSafe()), true) + val extracted = parent.extractItem(slot, stack.count.coerceAtMost((amount - total).toIntSafe()), true) val required = StorageStack.ITEMS.energyPerExtract(ItemStorageStack.unsafe(extracted)) - if (extracted.isNotEmpty && tuple.stack.equalsWithoutCount(ItemStorageStack.unsafe(extracted)) && energy.extractEnergy(required, true) == required) { + if (extracted.isNotEmpty && lstack.equalsWithoutCount(ItemStorageStack.unsafe(extracted)) && energy.extractEnergy(required, true) == required) { if (simulate) { total += extracted.count.toBigInteger() } else { + affectedSlots.add(slot) val extracted2 = parent.extractItem(slot, extracted.count, false) + total += extracted2.count.toBigInteger() if (extracted2.count == extracted.count) { energy.extractEnergy(required, false) } else { energy.extractEnergy(StorageStack.ITEMS.energyPerExtract(ItemStorageStack.unsafe(extracted2)), false) } - - total += extracted2.count.toBigInteger() } } } + val i = affectedSlots.intIterator() + while (i.hasNext()) scan(i.nextInt()) return lstack.copy(total) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt index 4a918c9b1..878e8a789 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt @@ -9,7 +9,6 @@ import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.phys.AABB -import net.minecraftforge.common.ForgeConfigSpec import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.capability.MatteryCapability @@ -18,13 +17,9 @@ import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.moveEnergy import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue -import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.menu.tech.AndroidStationMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities -import ru.dbotthepony.mc.otm.registry.MNames -import ru.dbotthepony.mc.otm.core.util.WriteOnce class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.ANDROID_STATION, p_155229_, p_155230_), MenuProvider { 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 7b359587c..04cf52774 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 @@ -4,13 +4,9 @@ import net.minecraft.core.BlockPos import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu -import net.minecraft.world.item.ItemStack import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState -import net.minecraftforge.common.ForgeConfigSpec import net.minecraftforge.common.ForgeHooks -import net.minecraftforge.common.capabilities.ForgeCapabilities -import net.minecraftforge.energy.IEnergyStorage import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.capability.* @@ -19,14 +15,9 @@ 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.* import ru.dbotthepony.mc.otm.menu.tech.ChemicalGeneratorMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities -import ru.dbotthepony.mc.otm.registry.MNames -import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue -import ru.dbotthepony.mc.otm.core.math.defineDecimal class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.CHEMICAL_GENERATOR, pos, state) { override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt index 74f2edd4f..9d6c16322 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt @@ -4,7 +4,6 @@ import net.minecraft.core.BlockPos import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu -import net.minecraft.world.item.ItemStack import net.minecraft.world.level.block.state.BlockState import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt index b255cef0c..0bac233a6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.block.entity.tech import net.minecraft.core.BlockPos -import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/AbstractMatteryDrive.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/AbstractMatteryDrive.kt index f8e72f168..1bce3faba 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/AbstractMatteryDrive.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/AbstractMatteryDrive.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.capability.drive import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.ObjectArraySet +import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet import kotlin.jvm.JvmOverloads import java.util.UUID import net.minecraft.nbt.CompoundTag @@ -30,7 +31,7 @@ abstract class AbstractMatteryDrive> @JvmOverloads construct override var isDirty = false set(value) { - if (value != field && value && DrivePool.isLegalAccess()) { + if (value != field && value) { DrivePool.markDirty(uuid) } @@ -43,6 +44,24 @@ abstract class AbstractMatteryDrive> @JvmOverloads construct override var storedCount: BigInteger = BigInteger.ZERO protected set + protected val listeners = ObjectLinkedOpenHashSet>() + + override fun addListener(listener: IStorageEventConsumer): Boolean { + return listeners.add(listener) + } + + override fun removeListener(listener: IStorageEventConsumer): Boolean { + return listeners.remove(listener) + } + + override fun equals(other: Any?): Boolean { + return other is AbstractMatteryDrive<*> && storageType == other.storageType && uuid == other.uuid + } + + override fun hashCode(): Int { + return (uuid.hashCode() * 31) xor storageType.hashCode() + } + override fun insertStack(stack: T, simulate: Boolean): T { val maxInsert = driveCapacity.minus(storedCount).coerceAtMost(stack.count) if (maxInsert <= BigInteger.ZERO) return stack @@ -189,14 +208,4 @@ abstract class AbstractMatteryDrive> @JvmOverloads construct override val stacks: Stream> get() { return ArrayList>(stack2tuples.size).also { it.addAll(stack2tuples.values) }.stream() } - - protected val listeners = ObjectArraySet>() - - override fun addListener(listener: IStorageEventConsumer): Boolean { - return listeners.add(listener) - } - - override fun removeListener(listener: IStorageEventConsumer): Boolean { - return listeners.remove(listener) - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/DrivePool.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/DrivePool.kt index 098f4d27d..2909d1951 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/DrivePool.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/DrivePool.kt @@ -1,15 +1,13 @@ package ru.dbotthepony.mc.otm.capability.drive -import it.unimi.dsi.fastutil.objects.Object2ObjectAVLTreeMap import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap import java.util.UUID import net.minecraft.ReportedException import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.NbtIo import net.minecraft.CrashReport +import net.minecraft.world.level.storage.LevelResource import java.util.concurrent.locks.LockSupport -import net.minecraftforge.event.TickEvent.ServerTickEvent -import net.minecraftforge.event.TickEvent import net.minecraftforge.event.server.ServerAboutToStartEvent import net.minecraftforge.event.server.ServerStoppingEvent import net.minecraftforge.event.level.LevelEvent @@ -19,51 +17,82 @@ import ru.dbotthepony.mc.otm.SERVER_IS_LIVE import java.io.File import java.lang.ref.WeakReference import java.util.ArrayList +import java.util.concurrent.ConcurrentLinkedQueue + +private class WeakDriveReference(drive: IMatteryDrive<*>) { + private var drive: IMatteryDrive<*>? = drive + private val weak = WeakReference(drive) + + val isValid: Boolean get() { + return drive != null || weak.get() != null + } + + fun drive(): IMatteryDrive<*>? { + return drive ?: weak.get() + } + + fun sync(): CompoundTag? { + val drive = drive() ?: return null + + if (!drive.isDirty) { + this.drive = null + return null + } + + val tag = drive.serializeNBT() + drive.isDirty = false + this.drive = null + + return tag + } + + fun access(): IMatteryDrive<*>? { + this.drive = weak.get() + return drive + } +} + +private data class BacklogLine(val uuid: UUID, val tag: CompoundTag) /** - * Let me answer everyone's questions about: - * - * Why? - * - * There are several reasons: - * 1. This data can get very large very quickly, even when playing singleplayer (and much quicker and bigger when hosting a dedicated server) - * 2. This data can not be stored inside ItemStack.ForgeCaps due to it's size - * 3. This data can not be stored inside unshared (server only) nbt tag because, again, mods prone to use and interact with - * it wrong, causing loss of stored data or mods exposing full content of a drive inside their own tag (which cause very real "NBT size too large" - * network kicks, often locking players out of server/singleplayer worlds - * 4. [net.minecraft.world.level.saveddata.SavedData] is for storing everything inside one dat file, which - * is performance tanking, because we have to write *entire* NBT on each save, not the data of Drives that are dirty - * 5. Mods which check items for being stack-able even with stack size of 1 gonna compare nbt tag, - * which will be performance tanking due to clause 1. + * Separate thread and separate files are way faster for enormous volumes of data (if mod is being run on public dedicated server) */ object DrivePool { + private val resource = LevelResource("otm_drives") private val LOGGER = LogManager.getLogger() private val pool = Object2ObjectOpenHashMap() private var thread: Thread? = null private var stopping = false - private var exception: ReportedException? = null - private const val DATA_PATH = "data/otm_drives" - @JvmStatic - operator fun > get( - id: UUID, - deserializer: (CompoundTag) -> T, - factory: () -> T - ): T { + private val backlog = ConcurrentLinkedQueue() + private var knownBaseDirectory: File? = null + + private var serverThread: Thread? = null + + private val baseDirectory: File? get() { + val server = NULLABLE_MINECRAFT_SERVER ?: return null + + val baseDirectory = server.storageSource.getLevelPath(resource).toFile() + + if (knownBaseDirectory != baseDirectory) { + baseDirectory.mkdirs() + knownBaseDirectory = baseDirectory + } + + return baseDirectory + } + + operator fun > get(id: UUID, deserializer: (CompoundTag) -> T, factory: () -> T): T { if (!isLegalAccess()) throw IllegalAccessException("Can not access drive pool from outside of server thread.") if (!SERVER_IS_LIVE) - throw IllegalStateException("Fail-fast: Server is shutting down") + throw IllegalStateException("Server is not running") - val get = pool[id] + val get = pool[id]?.access() if (get != null) { - val accessed = get.access() - - if (accessed != null) { - return accessed as T - } + return get as T } val file = File(baseDirectory, "$id.dat") @@ -85,69 +114,9 @@ object DrivePool { return factory().also { pool[id] = WeakDriveReference(it) } } - @JvmStatic - fun put(id: UUID, drive: IMatteryDrive<*>) { - if (!isLegalAccess()) - throw IllegalAccessException("Can not access drive pool from outside of server thread.") - - if (!SERVER_IS_LIVE) - throw IllegalStateException("Fail-fast: Server is shutting down") - - pool[id] = WeakDriveReference(drive) - } - - @JvmStatic fun markDirty(id: UUID) { - if (!isLegalAccess()) - throw IllegalAccessException("Can not access drive pool from outside of server thread.") - - if (!SERVER_IS_LIVE) - throw IllegalStateException("Fail-fast: Server is shutting down") - - pool[id]?.access() - } - - private var backlog = ArrayList() - private var knownBaseDirectory: File? = null - - private val baseDirectory: File? get() { - val server = NULLABLE_MINECRAFT_SERVER ?: return null - - val baseDirectory = File(server.storageSource.worldDir.toFile(), DATA_PATH) - - if (knownBaseDirectory != baseDirectory) { - baseDirectory.mkdirs() - knownBaseDirectory = baseDirectory - } - - return baseDirectory - } - - private var serverThread: Thread? = null - - private fun thread() { - while (true) { - LockSupport.park() - - if (stopping) { - return - } - - try { - // TODO: Syncing status with main thread, since server stop can occur during work. - sync() - } catch (error: ReportedException) { - exception = error - return - } - } - } - - fun onServerPostTick(event: ServerTickEvent) { - if (event.phase == TickEvent.Phase.END) { - if (exception != null) { - throw exception!! - } + if (isLegalAccess()) { + pool[id]?.access() } } @@ -156,12 +125,8 @@ object DrivePool { * * If you are making your own drive for your own storage stack, feed code outside of server thread (e.g. client code) dummy disk. */ - @JvmStatic fun isLegalAccess(): Boolean { - if (serverThread == null) - return false - - return Thread.currentThread() === serverThread + return serverThread != null && Thread.currentThread() === serverThread } fun serverStartEvent(event: ServerAboutToStartEvent) { @@ -175,7 +140,7 @@ object DrivePool { serverThread = Thread.currentThread() stopping = false - thread = Thread(null, this::thread, "Overdrive That Matters DrivePool IO").also { it.start() } + thread = Thread(null, this::run, "Overdrive That Matters DrivePool IO").also { it.start() } } fun serverStopEvent(event: ServerStoppingEvent) { @@ -186,11 +151,8 @@ object DrivePool { LockSupport.unpark(thread) } - if (exception == null) { - writeBacklog() - sync() - } - + writeBacklog() + sync() pool.clear() } @@ -200,34 +162,26 @@ object DrivePool { private fun writeBacklog() { var needsSync = false - var removeKeys: ArrayList? = null + val removeKeys = ArrayList() for ((key, value) in pool) { - val tag = value.sync() + try { + val tag = value.sync() - if (tag != null) { - LOGGER.info("Serializing OTM Drive {}", key) - val index = backlog.indexOf(key) - - if (index != -1) { - backlog[index] = BacklogLine(key, tag, value.drive()!!) - } else { - backlog.add(BacklogLine(key, tag, value.drive()!!)) + if (tag != null) { + LOGGER.debug("Serializing OTM Drive {}", key) + backlog.add(BacklogLine(key, tag)) + needsSync = true + } else if (!value.isValid) { + removeKeys.add(key) } - - needsSync = true - } else if (!value.valid()) { - if (removeKeys == null) - removeKeys = ArrayList() - - removeKeys.add(key) + } catch (err: Throwable) { + LOGGER.error("Failed to serialize OTM Drive for persistent storage with ID $key", err) } } - if (removeKeys != null) { - for (key in removeKeys) { - pool.remove(key) - } + for (key in removeKeys) { + pool.remove(key) } if (needsSync) { @@ -235,90 +189,31 @@ object DrivePool { } } + private fun run() { + while (!stopping) { + sync() + LockSupport.park() + } + } + private fun sync() { - val copy = backlog - backlog = ArrayList() + while (true) { + val next = backlog.poll() ?: return + val (uuid, tag) = next - for (entry in copy) { try { - LOGGER.info("Syncing OTM Drive {}", entry.file) + LOGGER.debug("Syncing OTM Drive {}", uuid) - val oldFile = File(baseDirectory, entry.file.toString() + ".dat_old") + val oldFile = File(baseDirectory, "$uuid.dat_old") + val newFile = File(baseDirectory, "$uuid.dat") - if (oldFile.exists()) { - check(oldFile.delete()) { "Unable to delete old dat file" } - } + if (oldFile.exists()) check(oldFile.delete()) { "Unable to delete old dat file" } + if (newFile.exists()) check(newFile.renameTo(oldFile)) { "Unable to move old dat file" } - val newFile = File(baseDirectory, entry.file.toString() + ".dat") - - if (newFile.exists()) { - check(newFile.renameTo(oldFile)) { "Unable to move old dat file" } - } - - NbtIo.writeCompressed(entry.tag, newFile) + NbtIo.writeCompressed(tag, newFile) } catch (error: Throwable) { - val report = CrashReport("Syncing OTM Drives state to disk", error) - val category = report.addCategory("Corrupt drive") - category.setDetail("UUID", entry.file.toString()) - category.setDetail("Stored item count", entry.drive.storedCount) - category.setDetail("Capacity", entry.drive.driveCapacity) - throw ReportedException(report) + LOGGER.error("Failed to sync OTM Drive to persistent storage with ID $uuid", error) } } } } - -private class WeakDriveReference(drive: IMatteryDrive<*>) { - private var drive: IMatteryDrive<*>? = drive - private val weak = WeakReference(drive) - - fun valid(): Boolean { - return drive != null || weak.get() != null - } - - fun drive(): IMatteryDrive<*>? { - return drive ?: weak.get() - } - - fun sync(): CompoundTag? { - var drive = drive - - if (drive == null) { - drive = weak.get() - - if (drive == null) - return null - } - - if (!drive.isDirty) { - this.drive = null - return null - } - - val tag = drive.serializeNBT() - drive.isDirty = false - this.drive = null - - return tag - } - - fun access(): IMatteryDrive<*>? { - this.drive = weak.get() - return drive - } -} - -@Suppress("EqualsOrHashCode") -private data class BacklogLine(val file: UUID, val tag: CompoundTag, val drive: IMatteryDrive<*>) { - override fun equals(other: Any?): Boolean { - if (other is BacklogLine) { - return other.file == file - } - - if (other is UUID) { - return other == file - } - - return false - } -} 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 c38dc7764..6b03bc50e 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 @@ -54,27 +54,10 @@ class MatterPanelScreen( val controls = DeviceControls(this, frame) - LargeBooleanRectangleButtonPanel( - this, - controls, - prop = menu.isAscendingGS, - skinElementActive = Widgets18.ARROW_UP, - skinElementInactive = Widgets18.ARROW_DOWN, - tooltipActive = TranslatableComponent("otm.gui.sorting.ascending"), - tooltipInactive = TranslatableComponent("otm.gui.sorting.descending"), - ).also { - controls.addButton(it) - } - - LargeEnumRectangleButtonPanel(this, controls, enum = ItemSorter::class.java, prop = menu.sortingGS, defaultValue = ItemSorter.DEFAULT).also { - controls.addButton(it) - it.add(ItemSorter.DEFAULT, skinElement = Widgets18.SORT_DEFAULT, tooltip = ItemSorter.DEFAULT.title) - it.add(ItemSorter.NAME, skinElement = Widgets18.SORT_ALPHABET, tooltip = ItemSorter.NAME.title) - it.add(ItemSorter.ID, skinElement = Widgets18.SORT_ID, tooltip = ItemSorter.ID.title) - it.add(ItemSorter.MOD, skinElement = Widgets18.SORT_MODID, tooltip = ItemSorter.MOD.title) - it.add(ItemSorter.MATTER_VALUE, skinElement = Widgets18.SORT_MATTER_VALUE, tooltip = ItemSorter.MATTER_VALUE.title) - it.add(ItemSorter.MATTER_COMPLEXITY, skinElement = Widgets18.SORT_MATTER_COMPLEXITY, tooltip = ItemSorter.MATTER_COMPLEXITY.title) - it.finish() + controls.sortingButtons(menu.isAscendingGS, menu.sortingGS, ItemSorter.DEFAULT) { + for (v in ItemSorter.entries) { + add(v, skinElement = v.icon, tooltip = v.title) + } } val scrollBar = DiscreteScrollBarPanel(this, frame, { @@ -156,7 +139,7 @@ class MatterPanelScreen( } } - override fun getItemStackTooltip(stack: ItemStack): List { + override fun getItemStackTooltip(stack: ItemStack): MutableList { val list = super.getItemStackTooltip(stack).toMutableList() if (isPatternView) { @@ -326,7 +309,7 @@ class MatterPanelScreen( return pattern.stack() } - override fun getItemStackTooltip(stack: ItemStack): List { + override fun getItemStackTooltip(stack: ItemStack): MutableList { return super.getItemStackTooltip(stack).toMutableList().also { it.add(TranslatableComponent( "otm.item.pattern.research", diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index 5dd1b028c..79ae5fc49 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -31,8 +31,26 @@ open class FramePanel( var onOpen: Runnable? = null, var onClose: Runnable? = null, var activeIcon: IGUIRenderable? = null, - var inactiveIcon: IGUIRenderable? = null, + var inactiveIcon: IGUIRenderable? = activeIcon, ) : AbstractButtonPanel(this@FramePanel.screen, this@FramePanel, 0f, 0f, 26f, 28f) { + constructor(panels: List>, activeIcon: IGUIRenderable? = null, inactiveIcon: IGUIRenderable? = activeIcon) : this(activeIcon = activeIcon, inactiveIcon = inactiveIcon) { + onOpen = Runnable { + for (panel in panels) { + panel.visible = true + } + } + + onClose = Runnable { + for (panel in panels) { + panel.visible = false + } + } + + if (!isActive) { + onClose!!.run() + } + } + var isActive = tabs.isEmpty() protected set diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/NetworkedItemGridPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/NetworkedItemGridPanel.kt new file mode 100644 index 000000000..d394b347d --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/NetworkedItemGridPanel.kt @@ -0,0 +1,110 @@ +package ru.dbotthepony.mc.otm.client.screen.panels + +import net.minecraft.ChatFormatting +import net.minecraft.client.gui.GuiGraphics +import net.minecraft.network.chat.Component +import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.client.render.RenderGravity +import ru.dbotthepony.mc.otm.client.render.draw +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.ScrollBarConstants +import ru.dbotthepony.mc.otm.client.screen.storage.ItemMonitorScreen +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.math.integerDivisionDown +import ru.dbotthepony.mc.otm.core.util.formatReadableNumber +import ru.dbotthepony.mc.otm.core.util.formatSiComponent +import ru.dbotthepony.mc.otm.menu.data.NetworkedItemView +import ru.dbotthepony.mc.otm.storage.StorageStack + +open class NetworkedItemGridPanel>( + screen: S, + parent: EditablePanel<*>, + val view: NetworkedItemView, + x: Float = 0f, + y: Float = 0f, + width: Float = 40f, + height: Float = 40f, +) : EditablePanel(screen, parent, x, y, width, height) { + constructor( + screen: S, + parent: EditablePanel<*>, + view: NetworkedItemView, + x: Float = 0f, + y: Float = 0f, + width: Int, + height: Int + ) : this(screen, parent, view, x, y, width * AbstractSlotPanel.SIZE + ScrollBarConstants.WIDTH, height * AbstractSlotPanel.SIZE) + + private val slots = ArrayList() + + val canvas = object : GridPanel(screen, this@NetworkedItemGridPanel, 0f, 0f, 0f, 0f, 0, 0) { + override fun performLayout() { + super.performLayout() + + val count = columns * rows + + while (slots.size < count) { + slots.add(Slot(slots.size)) + } + + while (slots.size > count) { + slots.removeLast().remove() + } + } + } + + val scrollbar = DiscreteScrollBarPanel( + screen, + this, + { integerDivisionDown(view.itemCount, canvas.columns) }, + { _, _, _ -> } + ) + + inner class Slot(private val i: Int) : AbstractSlotPanel(screen, canvas) { + private val index get() = i + scrollbar.scroll * canvas.columns + + override val itemStack: ItemStack get() { + return view.sortedView.getOrNull(index)?.stack?.toItemStack() ?: ItemStack.EMPTY + } + + override fun mouseScrolledInner(x: Double, y: Double, scroll: Double): Boolean { + return scrollbar.mouseScrolledInner(x, y, scroll) + } + + override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { + view.mouseClick(index, button) + return true + } + + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + renderSlotBackground(graphics, mouseX, mouseY, partialTick) + val itemStack = view.sortedView.getOrNull(index)?.stack ?: StorageStack.ITEMS.empty + renderRegular(graphics, itemStack.toItemStack(), "") + + if (!itemStack.isEmpty) { + graphics.draw(font, itemStack.count.formatSiComponent(decimalPlaces = 1), x = width - 1f, y = height - 1f, gravity = RenderGravity.BOTTOM_RIGHT, scale = 0.75f, drawShadow = true) + } + } + + override fun getItemStackTooltip(stack: ItemStack): MutableList { + return super.getItemStackTooltip(stack).also { + it.add(TranslatableComponent("otm.gui.stored_amount", view.sortedView[index].stack.count.formatReadableNumber()).withStyle(ChatFormatting.DARK_GRAY)) + } + } + } + + init { + canvas.dock = Dock.FILL + scrollbar.dock = Dock.RIGHT + } + + override fun performLayout() { + super.performLayout() + + canvas.rows = (canvas.height / AbstractSlotPanel.SIZE).toInt() + canvas.columns = (canvas.width / AbstractSlotPanel.SIZE).toInt() + } +} 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 1bbb21a57..3d18a1491 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 @@ -29,6 +29,7 @@ import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.RelativeSide +import ru.dbotthepony.mc.otm.core.util.ItemSorter import ru.dbotthepony.mc.otm.core.value import ru.dbotthepony.mc.otm.menu.UpgradeSlots import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback @@ -315,7 +316,6 @@ class DeviceControls>( val upgradesButton: LargeRectangleButtonPanel? private var upgradeWindow: FramePanel? = null - private var nextY = 0f fun

> addButton(button: P): P { @@ -328,6 +328,40 @@ class DeviceControls>( return button } + fun

> prependButton(button: P): P { + for (child in children) { + child.y += button.height + 2f + } + + button.parent = this + button.x = 0f + button.y = 0f + nextY += button.height + 2f + height = nextY - 2f + width = button.width.coerceAtLeast(width) + return button + } + + inline fun > sortingButtons(ascending: GetterSetter, sorting: GetterSetter, default: T, configurator: LargeEnumRectangleButtonPanel.() -> Unit) { + LargeBooleanRectangleButtonPanel( + screen, + this, + prop = ascending, + skinElementActive = Widgets18.ARROW_UP, + skinElementInactive = Widgets18.ARROW_DOWN, + tooltipActive = TranslatableComponent("otm.gui.sorting.ascending"), + tooltipInactive = TranslatableComponent("otm.gui.sorting.descending"), + ).also { + prependButton(it) + } + + LargeEnumRectangleButtonPanel(screen, this, enum = T::class.java, prop = sorting, defaultValue = default).also { + prependButton(it) + configurator.invoke(it) + it.finish() + } + } + init { for (button in extra) { addButton(button) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt index 2b6bb7c4a..f98bbd7fe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt @@ -42,7 +42,7 @@ abstract class AbstractSlotPanel> @JvmOverloads constru } } - protected open fun getItemStackTooltip(stack: ItemStack): List { + protected open fun getItemStackTooltip(stack: ItemStack): MutableList { return getTooltipFromItem(ru.dbotthepony.mc.otm.client.minecraft, stack) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/GridPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/GridPanel.kt index 62c17e32d..a9de349d6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/GridPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/GridPanel.kt @@ -4,16 +4,28 @@ import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel -open class GridPanel @JvmOverloads constructor( +open class GridPanel( screen: S, parent: EditablePanel<*>?, x: Float = 0f, y: Float = 0f, - width: Float, - height: Float, - protected var columns: Int, - protected var rows: Int + width: Float = 0f, + height: Float = 0f, + columns: Int, + rows: Int ) : EditablePanel(screen, parent, x, y, width, height) { + var columns: Int = columns + set(value) { + field = value + invalidateLayout() + } + + var rows: Int = rows + set(value) { + field = value + invalidateLayout() + } + override fun performLayout() { var currentX = 0f var currentY = 0f 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 29ceb9604..c82f8b38e 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 @@ -1,23 +1,26 @@ package ru.dbotthepony.mc.otm.client.screen.storage -import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.Items +import ru.dbotthepony.mc.otm.client.render.ItemStackIcon import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.button.CheckBoxLabelInputPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.DeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.FilterSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel -import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel -import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel -import ru.dbotthepony.mc.otm.core.math.integerDivisionDown +import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel +import ru.dbotthepony.mc.otm.core.asGetterSetter +import ru.dbotthepony.mc.otm.core.util.ItemStorageStackSorter import ru.dbotthepony.mc.otm.item.PortableCondensationDriveItem import ru.dbotthepony.mc.otm.menu.storage.DriveViewerMenu +import ru.dbotthepony.mc.otm.registry.MItems import yalter.mousetweaks.api.MouseTweaksDisableWheelTweak @MouseTweaksDisableWheelTweak @@ -25,106 +28,58 @@ class DriveViewerScreen(menu: DriveViewerMenu, inventory: Inventory, title: Comp MatteryScreen(menu, inventory, title) { override fun makeMainFrame(): FramePanel> { - val frame = FramePanel(this, null, 0f, 0f, FRAME_WIDTH, FRAME_HEIGHT, getTitle()) + val frame = FramePanel(this, null, 0f, 0f, 200f, 114f, getTitle()) frame.makeCloseButton() frame.onClose { onClose() } - val views = ArrayList>() + 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) { + add(v, v.icon, v.title) + } + } + + val view = ArrayList>() val settings = ArrayList>() - frame.Tab(onOpen = { - for (panel in views) { - panel.visible = true - } - }, onClose = { - for (panel in views) { - panel.visible = false + view.add(EditablePanel(this, frame, width = AbstractSlotPanel.SIZE).also { + it.dock = Dock.LEFT + WideProfiledPowerGaugePanel(this, it, menu.profiledEnergy).also { + it.dock = Dock.TOP + it.dockBottom = 6f } + + BatterySlotPanel(this, it, menu.batterySlot).dock = Dock.TOP + SlotPanel(this, it, menu.driveSlot).dock = Dock.TOP }) - frame.Tab(onOpen = { - for (panel in settings) { - panel.visible = true - } - }, onClose = { - for (panel in settings) { - panel.visible = false - } + view.add(NetworkedItemGridPanel(this, frame, menu.networkedItemView).also { + it.dock = Dock.FILL + it.setDockMargin(4f, 0f, 0f, 0f) }) - views.add(PowerGaugePanel(this, frame, menu.energyWidget, 8f, 16f)) - views.add(BatterySlotPanel(this, frame, menu.batterySlot, 8f, 67f)) - views.add(SlotPanel(this, frame, menu.driveSlot, 8f, 85f)) - - val grid = GridPanel(this, frame, 28f, 16f, GRID_WIDTH * 18f, GRID_HEIGHT * 18f, GRID_WIDTH, GRID_HEIGHT) - - val scrollBar = DiscreteScrollBarPanel(this, frame, { integerDivisionDown(menu.networkedItemView.itemCount, GRID_WIDTH) }, { _, _, _ -> }, 192f, 14f, 92f) - - views.add(grid) - views.add(scrollBar) - - for (i in 0 until GRID_WIDTH * GRID_HEIGHT) { - object : AbstractSlotPanel(this@DriveViewerScreen, grid, 0f, 0f) { - override val itemStack: ItemStack get() { - val index = i + scrollBar.scroll * GRID_WIDTH - return menu.networkedItemView.sortedView.getOrNull(index)?.stack?.toItemStack() ?: ItemStack.EMPTY - } - - override fun mouseScrolledInner(x: Double, y: Double, scroll: Double): Boolean { - return scrollBar.mouseScrolledInner(x, y, scroll) - } - - override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { - val index = i + scrollBar.scroll * GRID_WIDTH - menu.networkedItemView.mouseClick(index, button) - return true - } - - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { - renderSlotBackground(graphics, mouseX, mouseY, partialTick) - renderRegular(graphics, itemStack, "") - } - - override fun getItemStackTooltip(stack: ItemStack): List { - return super.getItemStackTooltip(stack).also { - it as MutableList - val index = i + scrollBar.scroll * GRID_WIDTH - val realStack = menu.networkedItemView.sortedView.getOrNull(index)!!.stack - it.add(TranslatableComponent("otm.gui.item_amount", realStack.count.toString())) - } - } - } - } - - val dock_left = FlexGridPanel(this, frame, 0f, 0f, 90f, 0f) - dock_left.dock = Dock.LEFT - dock_left.setDockMargin(4f, 0f, 4f, 0f) - - val grid_filter = FlexGridPanel(this, frame) - grid_filter.dock = Dock.FILL - settings.add(dock_left) - settings.add(grid_filter) + val filterGrid = GridPanel(this, frame, width = AbstractSlotPanel.SIZE * 3f, height = AbstractSlotPanel.SIZE * 4f, rows = 3, columns = 4) + filterGrid.dock = Dock.FILL + filterGrid.dockResize = DockResizeMode.NONE + filterGrid.dockTop = 20f + settings.add(filterGrid) for (i in 0 until PortableCondensationDriveItem.MAX_FILTERS) { - FilterSlotPanel(this, grid_filter, menu.driveFilterSlots[i], 0f, 0f) + FilterSlotPanel(this, filterGrid, menu.driveFilterSlots[i], 0f, 0f) } - CheckBoxLabelInputPanel(this, dock_left, menu.isWhitelist, TranslatableComponent("otm.gui.filter.is_whitelist"), width = 90f, height = 20f).also { it.setDockMargin(0f, 4f, 0f, 0f) } - CheckBoxLabelInputPanel(this, dock_left, menu.matchTag, TranslatableComponent("otm.gui.filter.match_tag"), width = 90f, height = 20f).also { it.setDockMargin(0f, 4f, 0f, 0f) } - CheckBoxLabelInputPanel(this, dock_left, menu.matchNBT, TranslatableComponent("otm.gui.filter.match_nbt"), width = 90f, height = 20f).also { it.setDockMargin(0f, 4f, 0f, 0f) } + settings.add(EditablePanel(this, frame, width = 90f).also { + it.dock = Dock.LEFT + CheckBoxLabelInputPanel(this, it, menu.isWhitelist, TranslatableComponent("otm.gui.filter.is_whitelist")).also { it.dockTop = 20f; it.dock = Dock.TOP } + CheckBoxLabelInputPanel(this, it, menu.matchTag, TranslatableComponent("otm.gui.filter.match_tag")).also { it.dockTop = 4f; it.dock = Dock.TOP } + CheckBoxLabelInputPanel(this, it, menu.matchNBT, TranslatableComponent("otm.gui.filter.match_nbt")).also { it.dockTop = 4f; it.dock = Dock.TOP } + }) - for (panel in settings) { - panel.visible = false - } + frame.Tab(view, activeIcon = ItemStackIcon(ItemStack(MItems.PORTABLE_CONDENSATION_DRIVE))) + frame.Tab(settings, activeIcon = ItemStackIcon(ItemStack(Items.HOPPER))) return frame } - - companion object { - const val FRAME_WIDTH = 210f - const val FRAME_HEIGHT = 110f - const val GRID_WIDTH = 9 - const val GRID_HEIGHT = 5 - } } 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 4215dc9cf..d1cfbde67 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 @@ -1,23 +1,21 @@ package ru.dbotthepony.mc.otm.client.screen.storage -import com.mojang.blaze3d.systems.RenderSystem -import com.mojang.blaze3d.vertex.PoseStack -import net.minecraft.ChatFormatting import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items -import org.lwjgl.opengl.GL11 -import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorPlayerSettings -import ru.dbotthepony.mc.otm.client.render.UVWindingOrder -import ru.dbotthepony.mc.otm.client.render.Widgets8 +import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.NetworkedItemGridPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.DeviceControls +import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeBooleanRectangleButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeEnumRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.SmallEnumRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel @@ -27,12 +25,10 @@ import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel +import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.asGetterSetter -import ru.dbotthepony.mc.otm.core.math.integerDivisionDown -import ru.dbotthepony.mc.otm.core.util.formatReadableNumber -import ru.dbotthepony.mc.otm.core.util.formatSiComponent +import ru.dbotthepony.mc.otm.core.util.ItemStorageStackSorter import ru.dbotthepony.mc.otm.menu.storage.ItemMonitorMenu -import ru.dbotthepony.mc.otm.storage.StorageStack import yalter.mousetweaks.api.MouseTweaksDisableWheelTweak @MouseTweaksDisableWheelTweak @@ -57,71 +53,17 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp frame.height = topPanel.height + bottomPanel.height + frame.dockPadding.top + frame.dockPadding.bottom + 3f frame.width = 178f + frame.dockPadding.left + frame.dockPadding.right - val viewScrollBar = DiscreteScrollBarPanel(this, topPanel, - { integerDivisionDown(menu.networkedItemView.itemCount, ITEM_GRID_WIDTH) }, - { _, _, _ -> }, - 28f + ITEM_GRID_WIDTH * 18f + 2f, 16f, ITEM_GRID_HEIGHT * 18f) + val controls = DeviceControls(this, frame) - viewScrollBar.dock = Dock.RIGHT - viewScrollBar.setDockMargin(left = 2f) - - val gridPanel = GridPanel(this, topPanel, width = ITEM_GRID_WIDTH * 18f, height = ITEM_GRID_HEIGHT * 18f, columns = ITEM_GRID_WIDTH, rows = ITEM_GRID_HEIGHT) - gridPanel.dock = Dock.FILL - - for (i in 0 until ITEM_GRID_WIDTH * ITEM_GRID_HEIGHT) { - object : AbstractSlotPanel(this@ItemMonitorScreen, gridPanel) { - private val index get() = i + viewScrollBar.scroll * ITEM_GRID_WIDTH - - override val itemStack: ItemStack get() { - return menu.networkedItemView.sortedView.getOrNull(index)?.stack?.toItemStack() ?: ItemStack.EMPTY - } - - override fun mouseScrolledInner(x: Double, y: Double, scroll: Double): Boolean { - return viewScrollBar.mouseScrolledInner(x, y, scroll) - } - - override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { - menu.networkedItemView.mouseClick(index, button) - return true - } - - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { - renderSlotBackground(graphics, mouseX, mouseY, partialTick) - - val itemstack = menu.networkedItemView.sortedView.getOrNull(index)?.stack ?: StorageStack.ITEMS.empty - val stack = graphics.pose() - - renderRegular(graphics, itemstack.toItemStack(), "") - - if (!itemstack.isEmpty) { - stack.pushPose() - - val text = itemstack.count.formatSiComponent(decimalPlaces = 1) - val textWidth = font.width(text) - - stack.translate((width - textWidth * FONT_SCALE).toDouble(), (height - font.lineHeight * FONT_SCALE).toDouble(), 103.0) - - stack.scale(FONT_SCALE, FONT_SCALE, 1f) - - RenderSystem.depthFunc(GL11.GL_ALWAYS) - - graphics.drawString(font, text, 1, 1, 0x0) - graphics.drawString(font, text, 0, 0, 16777215) - - stack.popPose() - } - } - - override fun getItemStackTooltip(stack: ItemStack): List { - return super.getItemStackTooltip(stack).also { - it as MutableList - val realStack = menu.networkedItemView.sortedView.getOrNull(index)!!.stack - it.add(TranslatableComponent("otm.gui.stored_amount", realStack.count.formatReadableNumber()).withStyle(ChatFormatting.DARK_GRAY)) - } - } + controls.sortingButtons(menu.settings::ascendingSort.asGetterSetter(), menu.settings::sorting.asGetterSetter(), ItemStorageStackSorter.DEFAULT) { + for (v in ItemStorageStackSorter.entries) { + add(v, skinElement = v.icon, tooltip = v.title) } } + val grid = NetworkedItemGridPanel(this, topPanel, menu.networkedItemView) + grid.dock = Dock.FILL + val craftingGrid = GridPanel(this, bottomPanel, width = 3 * 18f, height = 3 * 18f, columns = 3, rows = 3) craftingGrid.dock = Dock.LEFT @@ -142,19 +84,19 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp val arrowLine = EditablePanel(this, arrowAndButtons, y = 38f, height = 8f, width = arrowAndButtons.width) - val refillPriority = SmallEnumRectangleButtonPanel(this, arrowLine, + SmallEnumRectangleButtonPanel(this, arrowLine, enum = ItemMonitorPlayerSettings.IngredientPriority::class.java, - prop = menu.settings::ingredientPriority.asGetterSetter(watch = { _, _ -> menu.sendSettingsToServer() }), + prop = menu.settings::ingredientPriority.asGetterSetter(), defaultValue = ItemMonitorPlayerSettings.IngredientPriority.SYSTEM) + .also { + it.tooltips.add(TranslatableComponent("otm.gui.item_monitor.refill_source.desc")) - refillPriority.tooltips.add(TranslatableComponent("otm.gui.item_monitor.refill_source.desc")) - refillPriority.add(ItemMonitorPlayerSettings.IngredientPriority.SYSTEM, tooltip = ItemMonitorPlayerSettings.IngredientPriority.SYSTEM.component, skinElement = Widgets8.WHITE_ARROW_DOWN, winding = UVWindingOrder.FLIP) - refillPriority.add(ItemMonitorPlayerSettings.IngredientPriority.INVENTORY, tooltip = ItemMonitorPlayerSettings.IngredientPriority.INVENTORY.component, skinElement = Widgets8.WHITE_ARROW_DOWN) - refillPriority.add(ItemMonitorPlayerSettings.IngredientPriority.INVENTORY_FIRST, tooltip = ItemMonitorPlayerSettings.IngredientPriority.INVENTORY_FIRST.component, skinElement = Widgets8.ARROW_SIDEWAYS, winding = UVWindingOrder.FLIP) - refillPriority.add(ItemMonitorPlayerSettings.IngredientPriority.SYSTEM_FIRST, tooltip = ItemMonitorPlayerSettings.IngredientPriority.SYSTEM_FIRST.component, skinElement = Widgets8.ARROW_SIDEWAYS) - refillPriority.add(ItemMonitorPlayerSettings.IngredientPriority.DO_NOT, tooltip = ItemMonitorPlayerSettings.IngredientPriority.DO_NOT.component, skinElement = Widgets8.MINUS) + for (setting in ItemMonitorPlayerSettings.IngredientPriority.entries) { + it.add(setting, setting.icon, setting.component, setting.winding) + } - refillPriority.dock = Dock.LEFT + it.dock = Dock.LEFT + } val resultAndButtons = EditablePanel(this, bottomPanel, width = 18f) @@ -163,25 +105,29 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp SlotPanel(this, resultAndButtons, menu.craftingResult, y = 18f) - val resultTarget = SmallEnumRectangleButtonPanel(this, resultAndButtons, y = 38f, + SmallEnumRectangleButtonPanel(this, resultAndButtons, y = 38f, enum = ItemMonitorPlayerSettings.ResultTarget::class.java, - prop = menu.settings::resultTarget.asGetterSetter(watch = { _, _ -> menu.sendSettingsToServer() }), + prop = menu.settings::resultTarget.asGetterSetter(), defaultValue = ItemMonitorPlayerSettings.ResultTarget.MIXED) + .also { + it.tooltips.add(TranslatableComponent("otm.gui.item_monitor.result_target.desc")) - resultTarget.tooltips.add(TranslatableComponent("otm.gui.item_monitor.result_target.desc")) - resultTarget.add(ItemMonitorPlayerSettings.ResultTarget.MIXED, tooltip = ItemMonitorPlayerSettings.ResultTarget.MIXED.component, skinElement = Widgets8.ARROW_SIDEWAYS) - resultTarget.add(ItemMonitorPlayerSettings.ResultTarget.ALL_INVENTORY, tooltip = ItemMonitorPlayerSettings.ResultTarget.ALL_INVENTORY.component, skinElement = Widgets8.ARROW_PAINTED_UP, winding = UVWindingOrder.FLIP) - resultTarget.add(ItemMonitorPlayerSettings.ResultTarget.ALL_SYSTEM, tooltip = ItemMonitorPlayerSettings.ResultTarget.ALL_SYSTEM.component, skinElement = Widgets8.ARROW_PAINTED_UP) + for (setting in ItemMonitorPlayerSettings.ResultTarget.entries) { + it.add(setting, setting.icon, setting.component, setting.winding) + } + } - val craftingAmount = SmallEnumRectangleButtonPanel(this, resultAndButtons, x = 10f, y = 38f, + SmallEnumRectangleButtonPanel(this, resultAndButtons, x = 10f, y = 38f, enum = ItemMonitorPlayerSettings.Amount::class.java, - prop = menu.settings::craftingAmount.asGetterSetter(watch = { _, _ -> menu.sendSettingsToServer() }), + prop = menu.settings::craftingAmount.asGetterSetter(), defaultValue = ItemMonitorPlayerSettings.Amount.STACK) + .also { + it.tooltips.add(TranslatableComponent("otm.gui.item_monitor.amount.desc")) - craftingAmount.tooltips.add(TranslatableComponent("otm.gui.item_monitor.amount.desc")) - craftingAmount.add(ItemMonitorPlayerSettings.Amount.ONE, tooltip = ItemMonitorPlayerSettings.Amount.ONE.component, skinElement = Widgets8.ONE) - craftingAmount.add(ItemMonitorPlayerSettings.Amount.STACK, tooltip = ItemMonitorPlayerSettings.Amount.STACK.component, skinElement = Widgets8.S) - craftingAmount.add(ItemMonitorPlayerSettings.Amount.FULL, tooltip = ItemMonitorPlayerSettings.Amount.FULL.component, skinElement = Widgets8.F) + for (setting in ItemMonitorPlayerSettings.Amount.entries) { + it.add(setting, setting.icon, setting.component, setting.winding) + } + } val craftingHistory = GridPanel(this, bottomPanel, width = 3 * 18f, height = 3 * 18f, columns = 3, rows = 3) craftingHistory.dock = Dock.LEFT @@ -227,7 +173,5 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp companion object { const val ITEM_GRID_WIDTH = 9 const val ITEM_GRID_HEIGHT = 5 - - const val FONT_SCALE = 0.6f } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt index 583b1acb0..4653d9e97 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt @@ -139,10 +139,10 @@ object MachinesConfig : AbstractConfig("machines") { } val STORAGE_POWER_SUPPLIER = conciseValues(MNames.STORAGE_POWER_SUPPLIER, Decimal(80_000), Decimal(2_000)) - val STORAGE_INTERFACES = conciseValues("STORAGE_INTERFACES", Decimal(10_000), Decimal(100)) - val ITEM_MONITOR = conciseValues(MNames.ITEM_MONITOR, Decimal(10_000), Decimal(100)) - val DRIVE_VIEWER = conciseValues(MNames.DRIVE_VIEWER, Decimal(10_000), Decimal(100)) - val DRIVE_RACK = conciseValues(MNames.DRIVE_RACK, Decimal(10_000), Decimal(100)) + val STORAGE_INTERFACES = conciseValues("STORAGE_INTERFACES", Decimal(10_000), Decimal(10_000)) + val ITEM_MONITOR = conciseValues(MNames.ITEM_MONITOR, Decimal(10_000), Decimal(10_000)) + val DRIVE_VIEWER = conciseValues(MNames.DRIVE_VIEWER, Decimal(10_000), Decimal(10_000)) + val DRIVE_RACK = conciseValues(MNames.DRIVE_RACK, Decimal(10_000), Decimal(10_000)) object AndroidCharger { val RADIUS_WIDTH: Double by builder diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/CombinedContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/CombinedContainer.kt index 90c253d10..7d372b6ca 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/CombinedContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/CombinedContainer.kt @@ -12,6 +12,7 @@ import net.minecraft.world.Container import net.minecraft.world.entity.player.Player import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.core.GetterSetter +import ru.dbotthepony.mc.otm.core.collect.concatIterators import ru.dbotthepony.mc.otm.core.collect.filter import ru.dbotthepony.mc.otm.core.collect.flatMap import ru.dbotthepony.mc.otm.core.collect.map @@ -167,10 +168,10 @@ class CombinedContainer(containers: Stream>>) : Co } fun optimizedIterator(): Iterator { - return listOf( + return concatIterators( fullCoverage.iterator().flatMap { it.iterator() }, notFullCoverage.values.iterator().flatMap { it.iterator() }.map { it.item }.filter { it.isNotEmpty } - ).iterator().flatMap { it } + ) } class Builder { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerIterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerIterator.kt index 1269f480a..fcf660f9c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerIterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerIterator.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.container +import it.unimi.dsi.fastutil.objects.ObjectIterators import net.minecraft.world.Container import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.core.isNotEmpty @@ -50,3 +51,32 @@ fun Container.iterator(): IContainerIterator { ContainerIterator(this) } } + +class FullContainerIterator(val container: Container, initialPos: Int = 0) : MutableIterator, ObjectIterators.AbstractIndexBasedListIterator(0, initialPos), IContainerIterator { + override fun remove(location: Int) { + pos++ + container[location] = ItemStack.EMPTY + } + + override fun get(location: Int): ItemStack { + return container[location] + } + + override fun getMaxPos(): Int { + return container.containerSize + } + + override fun add(location: Int, k: ItemStack?) { + throw UnsupportedOperationException() + } + + override fun set(location: Int, k: ItemStack) { + container[location] = k + } + + override fun setChanged() { + container.setChanged() + } +} + +fun Container.fullIterator() = FullContainerIterator(this) 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 17ad146f5..239d59990 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -53,6 +53,7 @@ import java.util.Arrays import java.util.Spliterators import java.util.UUID import java.util.function.Consumer +import java.util.function.Supplier import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.reflect.KProperty @@ -367,12 +368,20 @@ fun Comparator.nullsLast(): Comparator { return Comparator.nullsLast(this as Comparator) } +fun Comparator.map(mapper: (B) -> A): Comparator { + return Comparator { a, b -> this@map.compare(mapper.invoke(a), mapper.invoke(b)) } +} + +fun Comparator.suppliers(): Comparator> { + return Comparator { o1, o2 -> this@suppliers.compare(o1.get(), o2.get()) } +} + /** * Returns applicable index to put [element] into [List] determined by [comparator], optionally specifying ranges as [fromIndex] and [toIndex] * * If [List] is not sorted, result of this function is undefined */ -fun List.searchInsertionIndex(element: E, comparator: Comparator, fromIndex: Int = 0, toIndex: Int = size): Int { +fun List.searchInsertionIndex(element: E, comparator: Comparator, fromIndex: Int = 0, toIndex: Int = size): Int { require(toIndex >= fromIndex) { "Invalid range: to $toIndex >= from $fromIndex" } require(fromIndex >= 0) { "Invalid from index: $fromIndex" } require(toIndex >= 0) { "Invalid to index: $toIndex" } @@ -421,7 +430,7 @@ fun List.searchInsertionIndex(element: E, comparator: Comparator, from * * If [MutableList] is not sorted, result of this function is undefined */ -fun MutableList.addSorted(element: E, comparator: Comparator) { +fun MutableList.addSorted(element: E, comparator: Comparator) { add(searchInsertionIndex(element, comparator), element) } @@ -433,3 +442,8 @@ fun MutableList.addSorted(element: E, comparator: Comparator) { fun > MutableList.addSorted(element: E) { add(searchInsertionIndex(element, ObjectComparators.NATURAL_COMPARATOR), element) } + +fun lazy2(a: () -> A, b: A.() -> B): Supplier { + val first = lazy(a) + return Supplier { b.invoke(first.value) } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt index 700b2c868..258840f95 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt @@ -93,8 +93,14 @@ interface GetterSetter : Supplier, Consumer, ReadWriteProperty } } - fun box(value: V): GetterSetter { - return object : GetterSetter { + fun box(value: V): SentientGetterSetter { + return object : SentientGetterSetter { + private val subs = ISubscriptable.Impl() + + override fun addListener(listener: Consumer): ISubscriptable.L { + return subs.addListener(listener) + } + private var value = value override fun get(): V { @@ -103,12 +109,15 @@ interface GetterSetter : Supplier, Consumer, ReadWriteProperty override fun accept(t: V) { this.value = t + subs.accept(t) } } } } } +interface SentientGetterSetter : GetterSetter, ISubscriptable + operator fun Supplier.getValue(thisRef: Any?, property: KProperty<*>): T { return get() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/ISubscripable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/ISubscripable.kt new file mode 100644 index 000000000..ff17bd269 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/ISubscripable.kt @@ -0,0 +1,213 @@ +package ru.dbotthepony.mc.otm.core + +import it.unimi.dsi.fastutil.booleans.BooleanConsumer +import it.unimi.dsi.fastutil.floats.FloatConsumer +import it.unimi.dsi.fastutil.objects.ReferenceLinkedOpenHashSet +import java.util.function.Consumer +import java.util.function.DoubleConsumer +import java.util.function.IntConsumer +import java.util.function.LongConsumer + +interface ISubscriptable { + /** + * Listener token, allows to remove listener from subscriber list + */ + fun interface L { + /** + * Removes this listener + */ + fun remove() + } + + fun addListener(listener: Consumer): L + + class Impl : ISubscriptable, Consumer { + private inner class L(val callback: Consumer) : ISubscriptable.L { + init { + subscribers.add(this) + } + + override fun remove() { + subscribers.remove(this) + } + } + + private val subscribers = ReferenceLinkedOpenHashSet(0) + + override fun addListener(listener: Consumer): ISubscriptable.L { + return L(listener) + } + + override fun accept(t: V) { + subscribers.forEach { it.callback.accept(t) } + } + } + + companion object : ISubscriptable, L { + @Suppress("unchecked_cast") + fun empty(): ISubscriptable { + return this as ISubscriptable + } + + override fun remove() {} + + override fun addListener(listener: Consumer): L { + return this + } + } +} + +interface IFloatSubcripable : ISubscriptable { + @Deprecated("Use type specific listener") + override fun addListener(listener: Consumer): ISubscriptable.L { + return addListener(listener::accept) + } + + fun addListener(listener: FloatConsumer): ISubscriptable.L + + class Impl : IFloatSubcripable, Consumer, FloatConsumer { + private inner class L(val callback: FloatConsumer) : ISubscriptable.L { + init { + subscribers.add(this) + } + + override fun remove() { + subscribers.remove(this) + } + } + + private val subscribers = ReferenceLinkedOpenHashSet(0) + + override fun addListener(listener: FloatConsumer): ISubscriptable.L { + return L(listener) + } + + override fun accept(t: Float) { + subscribers.forEach { it.callback.accept(t) } + } + } +} + +interface IDoubleSubcripable : ISubscriptable { + @Deprecated("Use type specific listener") + override fun addListener(listener: Consumer): ISubscriptable.L { + return addListener(DoubleConsumer { listener.accept(it) }) + } + + fun addListener(listener: DoubleConsumer): ISubscriptable.L + + class Impl : IDoubleSubcripable, Consumer, DoubleConsumer { + private inner class L(val callback: DoubleConsumer) : ISubscriptable.L { + init { + subscribers.add(this) + } + + override fun remove() { + subscribers.remove(this) + } + } + + private val subscribers = ReferenceLinkedOpenHashSet(0) + + override fun addListener(listener: DoubleConsumer): ISubscriptable.L { + return L(listener) + } + + override fun accept(t: Double) { + subscribers.forEach { it.callback.accept(t) } + } + } +} + +interface IIntSubcripable : ISubscriptable { + @Deprecated("Use type specific listener") + override fun addListener(listener: Consumer): ISubscriptable.L { + return addListener(IntConsumer { listener.accept(it) }) + } + + fun addListener(listener: IntConsumer): ISubscriptable.L + + class Impl : IIntSubcripable, Consumer, IntConsumer { + private inner class L(val callback: IntConsumer) : ISubscriptable.L { + init { + subscribers.add(this) + } + + override fun remove() { + subscribers.remove(this) + } + } + + private val subscribers = ReferenceLinkedOpenHashSet(0) + + override fun addListener(listener: IntConsumer): ISubscriptable.L { + return L(listener) + } + + override fun accept(t: Int) { + subscribers.forEach { it.callback.accept(t) } + } + } +} + +interface ILongSubcripable : ISubscriptable { + @Deprecated("Use type specific listener") + override fun addListener(listener: Consumer): ISubscriptable.L { + return addListener(LongConsumer { listener.accept(it) }) + } + + fun addListener(listener: LongConsumer): ISubscriptable.L + + class Impl : ILongSubcripable, Consumer, LongConsumer { + private inner class L(val callback: LongConsumer) : ISubscriptable.L { + init { + subscribers.add(this) + } + + override fun remove() { + subscribers.remove(this) + } + } + + private val subscribers = ReferenceLinkedOpenHashSet(0) + + override fun addListener(listener: LongConsumer): ISubscriptable.L { + return L(listener) + } + + override fun accept(t: Long) { + subscribers.forEach { it.callback.accept(t) } + } + } +} + +interface IBooleanSubscriptable : ISubscriptable { + @Deprecated("Use type specific listener") + override fun addListener(listener: Consumer): ISubscriptable.L { + return addListener(listener::accept) + } + + fun addListener(listener: BooleanConsumer): ISubscriptable.L + + class Impl : IBooleanSubscriptable, Consumer, BooleanConsumer { + private inner class L(val callback: BooleanConsumer) : ISubscriptable.L { + init { + subscribers.add(this) + } + + override fun remove() { + subscribers.remove(this) + } + } + + private val subscribers = ReferenceLinkedOpenHashSet(0) + + override fun addListener(listener: BooleanConsumer): ISubscriptable.L { + return L(listener) + } + + override fun accept(t: Boolean) { + subscribers.forEach { it.callback.accept(t) } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt index f8cbb49af..4b11f9329 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt @@ -251,7 +251,7 @@ fun Iterator.mapToDouble(mapper: O2DFunction): it.unimi.dsi.fastutil.d } override fun remove() { - throw UnsupportedOperationException() + (this@mapToDouble as MutableIterator).remove() } override fun nextDouble(): Double { @@ -267,7 +267,7 @@ fun Iterator.mapToInt(mapper: O2IFunction): it.unimi.dsi.fastutil.ints } override fun remove() { - throw UnsupportedOperationException() + (this@mapToInt as MutableIterator).remove() } override fun nextInt(): Int { @@ -362,7 +362,7 @@ fun Iterator.collect(collector: Collector): R { return collector.finisher().apply(instance) } -fun Iterator.toList(): List { +fun Iterator.toList(): MutableList { val result = ArrayList() result.addAll(this) return result diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt index 538382561..277b58bf5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt @@ -71,7 +71,12 @@ inline fun CompoundTag.mapPresent(key: String, consumer: (T fun CompoundTag.mapString(index: String, mapper: (String) -> T, orElse: T): T { val tag = this[index] as? StringTag ?: return orElse - return mapper.invoke(tag.asString) + + return try { + mapper.invoke(tag.asString) + } catch (err: NoSuchElementException) { + orElse + } } fun CompoundTag.getItemStack(key: String): ItemStack = map(key, ItemStack::of) ?: ItemStack.EMPTY diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt index 49aee5756..a773fb4d1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt @@ -96,7 +96,10 @@ fun BigInteger.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 3, forma buffer[add + i + divided.length + 1] = prefix.paddedIndex(remainder, i) } - return TranslatableComponent(prefix.formatLocaleKey, String(buffer), suffix) + if (suffix == "") + return TranslatableComponent(prefix.conciseFormatLocaleKey, String(buffer)) + else + return TranslatableComponent(prefix.formatLocaleKey, String(buffer), suffix) } private val never = BooleanSupplier { false } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt index a2034d840..3cf948b94 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt @@ -3,17 +3,31 @@ package ru.dbotthepony.mc.otm.core.util import it.unimi.dsi.fastutil.objects.Reference2IntFunction import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap import net.minecraft.network.chat.Component +import net.minecraft.network.chat.MutableComponent import net.minecraft.world.item.CreativeModeTabs import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack import net.minecraftforge.common.CreativeModeTabRegistry import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.nullsFirst import ru.dbotthepony.mc.otm.core.nullsLast import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.core.suppliers import ru.dbotthepony.mc.otm.matter.MatterManager +import ru.dbotthepony.mc.otm.storage.ItemStorageStack +import ru.dbotthepony.mc.otm.client.render.Widgets18 -object CreativeMenuComparator : Comparator { +private fun Comparator.stacks(): Comparator { + return Comparator { o1, o2 -> this@stacks.compare(o1.item, o2.item) }.nullsFirst() +} + +private fun Comparator.storage(): Comparator { + return Comparator { o1, o2 -> this@storage.compare(o1.item, o2.item) }.nullsFirst() +} + +object CreativeMenuItemComparator : Comparator { override fun compare(o1: Item, o2: Item): Int { rebuild() return item2index.getInt(o1).compareTo(item2index.getInt(o2)) @@ -84,6 +98,24 @@ object ItemLocalizedNameComparator : Comparator { val NullsLast = nullsLast() } +object ItemStackNameComparator : Comparator { + override fun compare(o1: ItemStack, o2: ItemStack): Int { + return o1.hoverName.string.compareTo(o2.hoverName.string) + } + + val NullsFirst = nullsFirst() + val NullsLast = nullsLast() +} + +object ItemStorageStackNameComparator : Comparator { + override fun compare(o1: ItemStorageStack, o2: ItemStorageStack): Int { + return o1.hoverName.string.compareTo(o2.hoverName.string) + } + + val NullsFirst = nullsFirst() + val NullsLast = nullsLast() +} + object ItemModComparator : Comparator { override fun compare(o1: Item, o2: Item): Int { val a = o1.registryName?.namespace ?: return 0 @@ -106,14 +138,65 @@ object ItemIDComparator : Comparator { val NullsLast = nullsLast() } -enum class ItemSorter(val comparator: Comparator, private val sTitle: Component) { - DEFAULT(CreativeMenuComparator.NullsFirst, TranslatableComponent("otm.gui.sorting.default")), - NAME(ItemLocalizedNameComparator.NullsFirst.thenComparing(CreativeMenuComparator.NullsFirst), TranslatableComponent("otm.gui.sorting.name")), - ID(ItemIDComparator.NullsFirst.thenComparing(CreativeMenuComparator.NullsFirst), TranslatableComponent("otm.gui.sorting.id")), - MOD(ItemModComparator.NullsFirst.thenComparing(CreativeMenuComparator.NullsFirst), TranslatableComponent("otm.gui.sorting.modid")), - MATTER_VALUE(MatterValueComparator.NullsFirst.thenComparing(MatterComplexityComparator.NullsFirst).thenComparing(CreativeMenuComparator.NullsFirst), TranslatableComponent("otm.gui.sorting.matter_value")), - MATTER_COMPLEXITY(MatterComplexityComparator.NullsFirst.thenComparing(MatterValueComparator.NullsFirst).thenComparing(CreativeMenuComparator.NullsFirst), TranslatableComponent("otm.gui.sorting.matter_complexity")), +object ItemStackCountComparator : Comparator { + override fun compare(o1: ItemStack, o2: ItemStack): Int { + return o1.count.compareTo(o2.count) + } + + val NullsFirst = nullsFirst() + val NullsLast = nullsLast() +} + +object ItemStorageStackCountComparator : Comparator { + override fun compare(o1: ItemStorageStack, o2: ItemStorageStack): Int { + return o1.count.compareTo(o2.count) + } + + val NullsFirst = nullsFirst() + val NullsLast = nullsLast() +} + +enum class ItemSorter(comparator: Comparator, private val sTitle: Component, icon: Lazy) : Comparator by comparator.nullsFirst() { + DEFAULT(CreativeMenuItemComparator, TranslatableComponent("otm.gui.sorting.default"), lazy { Widgets18.SORT_DEFAULT }), + NAME(ItemLocalizedNameComparator.thenComparing(CreativeMenuItemComparator), TranslatableComponent("otm.gui.sorting.name"), lazy { Widgets18.SORT_ALPHABET }), + ID(ItemIDComparator.thenComparing(CreativeMenuItemComparator), TranslatableComponent("otm.gui.sorting.id"), lazy { Widgets18.SORT_ID }), + MOD(ItemModComparator.thenComparing(CreativeMenuItemComparator), TranslatableComponent("otm.gui.sorting.modid"), lazy { Widgets18.SORT_MODID }), + MATTER_VALUE(MatterValueComparator.thenComparing(MatterComplexityComparator).thenComparing(CreativeMenuItemComparator), TranslatableComponent("otm.gui.sorting.matter_value"), lazy { Widgets18.SORT_MATTER_VALUE }), + MATTER_COMPLEXITY(MatterComplexityComparator.thenComparing(MatterValueComparator).thenComparing(CreativeMenuItemComparator), TranslatableComponent("otm.gui.sorting.matter_complexity"), lazy { Widgets18.SORT_MATTER_COMPLEXITY }), ; - val title: Component get() = sTitle.copy() + val icon: IGUIRenderable by icon + val title: MutableComponent get() = sTitle.copy() + val suppliers = suppliers() + val reversed: Comparator = reversed() +} + +enum class ItemStackSorter(comparator: Comparator, private val sTitle: Component, icon: Lazy) : Comparator by comparator { + DEFAULT(ItemSorter.DEFAULT.stacks(), ItemSorter.DEFAULT.title, lazy { Widgets18.SORT_DEFAULT }), + COUNT(ItemStackCountComparator.NullsFirst.thenComparing(ItemSorter.DEFAULT.stacks()), TranslatableComponent("otm.gui.sorting.count"), lazy { Widgets18.SORT_COUNT }), + NAME(ItemStackNameComparator.NullsFirst.thenComparing(ItemSorter.DEFAULT.stacks()), ItemSorter.NAME.title, lazy { Widgets18.SORT_ALPHABET }), + ID(ItemSorter.ID.stacks(), ItemSorter.ID.title, lazy { Widgets18.SORT_ID }), + MOD(ItemSorter.MOD.stacks(), ItemSorter.MOD.title, lazy { Widgets18.SORT_MODID }), + MATTER_VALUE(ItemSorter.MATTER_VALUE.stacks(), ItemSorter.MATTER_VALUE.title, lazy { Widgets18.SORT_MATTER_VALUE }), + MATTER_COMPLEXITY(ItemSorter.MATTER_COMPLEXITY.stacks(), ItemSorter.MATTER_COMPLEXITY.title, lazy { Widgets18.SORT_MATTER_COMPLEXITY }); + + val icon: IGUIRenderable by icon + val title: MutableComponent get() = sTitle.copy() + val suppliers = suppliers() + val reversed: Comparator = reversed() +} + +enum class ItemStorageStackSorter(comparator: Comparator, private val sTitle: Component, icon: Lazy) : Comparator by comparator { + DEFAULT(ItemSorter.DEFAULT.storage(), ItemSorter.DEFAULT.title, lazy { Widgets18.SORT_DEFAULT }), + COUNT(ItemStorageStackCountComparator.NullsFirst.thenComparing(ItemSorter.DEFAULT.storage()), TranslatableComponent("otm.gui.sorting.count"), lazy { Widgets18.SORT_COUNT }), + NAME(ItemStorageStackNameComparator.NullsFirst.thenComparing(ItemSorter.DEFAULT.storage()), ItemSorter.NAME.title, lazy { Widgets18.SORT_ALPHABET }), + ID(ItemSorter.ID.storage(), ItemSorter.ID.title, lazy { Widgets18.SORT_ID }), + MOD(ItemSorter.MOD.storage(), ItemSorter.MOD.title, lazy { Widgets18.SORT_MODID }), + MATTER_VALUE(ItemSorter.MATTER_VALUE.storage(), ItemSorter.MATTER_VALUE.title, lazy { Widgets18.SORT_MATTER_VALUE }), + MATTER_COMPLEXITY(ItemSorter.MATTER_COMPLEXITY.storage(), ItemSorter.MATTER_COMPLEXITY.title, lazy { Widgets18.SORT_MATTER_COMPLEXITY }); + + val icon: IGUIRenderable by icon + val title: MutableComponent get() = sTitle.copy() + val suppliers = suppliers() + val reversed: Comparator = reversed() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/SiPrefix.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/SiPrefix.kt index c044c136f..2789e4ebf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/SiPrefix.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/SiPrefix.kt @@ -33,6 +33,7 @@ enum class SiPrefix(val power: Int, val symbol: String) { open val isEmpty: Boolean get() = false val formatLocaleKey = "otm.suffix.${name.lowercase()}".intern() + val conciseFormatLocaleKey = "otm.suffix_concise.${name.lowercase()}".intern() val rawLocaleKey = "otm.suffix_raw.${name.lowercase()}".intern() val string: String diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt index 13df85dc2..7062a7054 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.core.util +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.core.addSorted @@ -15,6 +16,7 @@ class TickList : ITickable { private val toRemoveFromAlways = ArrayList() private val timers = ArrayDeque() + private val namedTimers = Object2ObjectOpenHashMap(0) var inTicker = false private set @@ -42,6 +44,20 @@ class TickList : ITickable { } } + /** + * Calling this method while timer already exists removes old timer + */ + fun namedTimer(name: Any?, ticks: Int, callback: Runnable): Timer { + val remove = namedTimers.remove(name) + + if (remove != null) + timers.remove(remove) + + val timer = Timer(ticks, callback) + namedTimers[name] = timer + return timer + } + inner class Ticker(parent: ITickable) : ITickable by parent { init { add(this, always, alwaysQueued) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNode.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNode.kt index bc0f21f30..d00cf71db 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNode.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNode.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.graph.storage +import it.unimi.dsi.fastutil.objects.ObjectArraySet import net.minecraft.world.level.block.entity.BlockEntity import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage @@ -13,7 +14,7 @@ import java.util.* import java.util.function.Supplier open class StorageNode(private val energyDemander: IMatteryEnergyStorage? = null) : GraphNode(::StorageGraph) { - protected val components = ArrayList>() + protected val components = ObjectArraySet>() /** * Setting this to true will render non functional default [attachComponents], @@ -74,32 +75,15 @@ open class StorageNode(private val energyDemander: IMatteryEnergyStorage? = null } } - @Suppress("unchecked_cast") - fun , U : IStorage> computeIfAbsent(type: StorageStack.Type, provider: (StorageStack.Type) -> U): U { - return components.firstOrNull { it.storageType == type } as U? ?: provider(type).also { addStorageComponent(it) } - } - fun addStorageComponent(component: IStorage<*>) { - if (!components.any { component === it || it.storageType === component.storageType }) { - components.add(component) - + if (components.add(component)) if (isValid && !manualAttaching) graph.add(component) - } } fun removeStorageComponent(component: IStorage<*>) { - val indexOf = components.indexOfFirst { component === it || it.storageType === component.storageType } - if (indexOf == -1) return - val self = components.removeAt(indexOf) - if (isValid) graph.remove(self) - } - - fun removeStorageComponent(component: StorageStack.Type<*>) { - val indexOf = components.indexOfFirst { it.storageType === component } - if (indexOf == -1) return - val self = components.removeAt(indexOf) - if (isValid) graph.remove(self) + if (components.remove(component) && isValid) + graph.remove(component) } override fun invalidate() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index db3244d76..5a0bc74e8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -54,6 +54,7 @@ import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.MenuFieldPacket import ru.dbotthepony.mc.otm.network.MenuNetworkChannel +import ru.dbotthepony.mc.otm.network.SetCarriedPacket import ru.dbotthepony.mc.otm.network.enqueueWork import ru.dbotthepony.mc.otm.network.packetHandled import ru.dbotthepony.mc.otm.network.sender @@ -461,6 +462,16 @@ abstract class MatteryMenu @JvmOverloads protected constructor( return player.distanceToSqr(pos.x.toDouble() + 0.5, pos.y.toDouble() + 0.5, pos.z.toDouble() + 0.5) <= 64.0 } + fun syncCarried() { + setRemoteCarried(carried.copy()) + MenuNetworkChannel.send(ply as ServerPlayer, SetCarriedPacket(carried)) + } + + fun syncCarried(stack: ItemStack) { + carried = stack + syncCarried() + } + private val externalSlots = ConditionalSet() private val quickMoveMapping = Reference2ObjectOpenHashMap>>() @@ -655,9 +666,9 @@ abstract class MatteryMenu @JvmOverloads protected constructor( // first pass - stack with existing slots if (copy.isStackable) { for (slot in slots) { - if (onlyFiltered && (slot !is UserFilteredSlot || slot.filter == null || slot.filter!!.get() != item.item)) { + if (onlyFiltered && (slot !is UserFilteredSlot || !slot.test(item))) { continue - } else if (!onlyFiltered && slot is UserFilteredSlot && slot.filter != null && slot.filter!!.get() != null && slot.filter!!.get() != item.item) { + } else if (!onlyFiltered && slot is UserFilteredSlot && !slot.test(item)) { continue } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt index 5ba1b1ccf..2a4c59ed0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt @@ -15,6 +15,7 @@ import ru.dbotthepony.mc.otm.container.UpgradeContainer import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.runOnClient +import java.util.function.Predicate /** * Make slots for single container @@ -46,7 +47,7 @@ open class MatterySlot(container: Container, index: Int, x: Int = 0, y: Int = 0) } } -open class UserFilteredSlot(container: Container, index: Int, x: Int = 0, y: Int = 0) : MatterySlot(container, index, x, y) { +open class UserFilteredSlot(container: Container, index: Int, x: Int = 0, y: Int = 0) : MatterySlot(container, index, x, y), Predicate { var hasSetFilter = false private set @@ -60,6 +61,10 @@ open class UserFilteredSlot(container: Container, index: Int, x: Int = 0, y: Int return filter?.get() == null } + override fun test(t: ItemStack): Boolean { + return filter?.get() == null || filter?.get() == t.item + } + fun isSameFilter(other: Slot): Boolean { if (other !is UserFilteredSlot) return filter?.get() == null 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 ec1205e43..08aeb6c19 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 @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.menu.data import com.mojang.blaze3d.platform.InputConstants import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap import net.minecraft.client.Minecraft import net.minecraft.client.gui.screens.Screen import net.minecraft.network.FriendlyByteBuf @@ -13,21 +14,28 @@ import net.minecraft.world.item.ItemStack import net.minecraftforge.network.NetworkEvent 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.isNotEmpty +import ru.dbotthepony.mc.otm.core.map import ru.dbotthepony.mc.otm.core.readBigInteger import ru.dbotthepony.mc.otm.core.writeBigInteger import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.network.* -import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.core.util.ItemStorageStackSorter import ru.dbotthepony.mc.otm.storage.* import java.math.BigInteger import java.util.* import java.util.function.Supplier +import kotlin.collections.ArrayList interface INetworkedItemViewProvider { val networkedItemView: NetworkedItemView } -class ItemViewInteractPacket(val stackID: Int, val type: ClickType, val action: ClickAction) : MatteryPacket { +private fun all(stack: ItemStack): Int = stack.maxStackSize.coerceAtMost(stack.count) +private fun half(stack: ItemStack): Int = (stack.maxStackSize.coerceAtMost(stack.count) / 2).coerceAtLeast(1) + +data class ItemViewInteractPacket(val stackID: Int, val type: ClickType, val action: ClickAction) : MatteryPacket { override fun write(buff: FriendlyByteBuf) { buff.writeInt(stackID) buff.writeEnum(type) @@ -53,144 +61,88 @@ class ItemViewInteractPacket(val stackID: Int, val type: ClickType, val action: } } -object ClearItemViewPacket : MatteryPacket { - override fun write(buff: FriendlyByteBuf) { - // NO-OP - } - - override fun play(context: Supplier) { +abstract class NetworkedItemViewPacket : MatteryPacket { + final override fun play(context: Supplier) { context.packetHandled = true context.enqueueWork { - (minecraft.player?.containerMenu as? INetworkedItemViewProvider)?.networkedItemView?.clear() + val get = Minecraft.getInstance().player?.containerMenu ?: return@enqueueWork + val view = (get as? INetworkedItemViewProvider)?.networkedItemView ?: throw IllegalStateException("No NetworkedItemView is present in currently open menu") + action(view) } } - fun read(buff: FriendlyByteBuf): ClearItemViewPacket { - return ClearItemViewPacket - } + protected abstract fun action(view: NetworkedItemView) +} - fun send(ply: ServerPlayer) { - MenuNetworkChannel.send(ply, this) +object ClearItemViewPacket : NetworkedItemViewPacket() { + override fun write(buff: FriendlyByteBuf) {} + + override fun action(view: NetworkedItemView) { + view.clear() } } -class StackAddPacket(val containerId: Int, val id: Int, val stack: ItemStorageStack) : MatteryPacket { +class StackAddPacket(val stackId: Int, val stack: ItemStorageStack) : NetworkedItemViewPacket() { override fun write(buff: FriendlyByteBuf) { - buff.writeInt(containerId) - buff.writeInt(id) + buff.writeInt(stackId) stack.write(buff) } - override fun play(context: Supplier) { - context.get().packetHandled = true - context.get().enqueueWork { - val get = Minecraft.getInstance().player?.containerMenu ?: return@enqueueWork - - if (get.containerId != containerId) - return@enqueueWork - - val view = (get as? INetworkedItemViewProvider)?.networkedItemView ?: throw IllegalStateException("No such item tracker with id $containerId") - - if (view.localState.containsKey(id)) { - throw IllegalStateException("Item tracker $containerId already has stack with id of $id") - } - - val state = NetworkedItemView.NetworkedItem(id, stack) - view.localState[id] = state - - /*val iterator = view.sortedView.iterator().withIndex() - var lastCompare = 0 - var hit = false - - while (iterator.hasNext()) { - val (i, existing) = iterator.next() - val cmp = view.sorter.compare(existing.stack, stack) - - if (cmp != lastCompare && lastCompare != 0) { - hit = true - view.sortedView.add(i, state) - } else if (cmp != lastCompare) { - lastCompare = cmp - } - } - - if (!hit) {*/ - view.sortedView.add(state) - //} - - view.resort() + override fun action(view: NetworkedItemView) { + if (view.id2tuple.containsKey(stackId)) { + throw IllegalStateException("NetworkedItemView $view already contains stack with id $stackId") } + + val tuple = NetworkedItemView.Tuple(stackId, stack) + view.id2tuple[stackId] = tuple + view.sortedView.addSorted(tuple, view.sorter.map(NetworkedItemView.Tuple::stack)) } companion object { fun read(buffer: FriendlyByteBuf): StackAddPacket { - val containerId = buffer.readInt() val id = buffer.readInt() val item = StorageStack.ITEMS.read(buffer) - return StackAddPacket(containerId, id, item) + return StackAddPacket(id, item) } } } -class StackChangePacket(val id: Int, val stackID: Int, val newCount: BigInteger) : MatteryPacket { +class StackChangePacket(val stackId: Int, val newCount: BigInteger) : NetworkedItemViewPacket() { override fun write(buff: FriendlyByteBuf) { - buff.writeInt(id) - buff.writeInt(stackID) + buff.writeInt(stackId) buff.writeBigInteger(newCount) } - override fun play(context: Supplier) { - context.get().packetHandled = true - context.get().enqueueWork { - val get = Minecraft.getInstance().player?.containerMenu ?: return@enqueueWork - - if (get.containerId != id) - return@enqueueWork - - val view = (get as? INetworkedItemViewProvider)?.networkedItemView ?: throw IllegalStateException("No such item tracker with id $id") - val state = view.localState[stackID] ?: throw IllegalStateException("No such stack with id $stackID in $view") - - state.stack = state.stack.copy(newCount) - view.resort() - } + override fun action(view: NetworkedItemView) { + val tuple = view.id2tuple[stackId] ?: throw IllegalStateException("No such stack with id $stackId in $view") + tuple.stack = tuple.stack.copy(newCount) + view.resort() } companion object { fun read(buffer: FriendlyByteBuf): StackChangePacket { - val id = buffer.readInt() val stackID = buffer.readInt() val newCount = buffer.readBigInteger() - return StackChangePacket(id, stackID, newCount) + return StackChangePacket(stackID, newCount) } } } -class StackRemovePacket(val id: Int, val stackID: Int) : MatteryPacket { +class StackRemovePacket(val stackId: Int) : NetworkedItemViewPacket() { override fun write(buff: FriendlyByteBuf) { - buff.writeInt(id) - buff.writeInt(stackID) + buff.writeInt(stackId) } - override fun play(context: Supplier) { - context.get().packetHandled = true - context.get().enqueueWork { - val get = Minecraft.getInstance().player?.containerMenu ?: return@enqueueWork - - if (get.containerId != id) - return@enqueueWork - - val view = (get as? INetworkedItemViewProvider)?.networkedItemView ?: throw IllegalStateException("No such item tracker with id $id") - val obj = view.localState.remove(stackID) ?: throw IllegalStateException("No such stack with id $stackID in $view") - view.sortedView.remove(obj) - view.resort() - } + override fun action(view: NetworkedItemView) { + val obj = view.id2tuple.remove(stackId) ?: throw IllegalStateException("No such stack with id $stackId in $view") + view.sortedView.remove(obj) + view.resort() } companion object { fun read(buffer: FriendlyByteBuf): StackRemovePacket { - val id = buffer.readInt() val stackID = buffer.readInt() - return StackRemovePacket(id, stackID) + return StackRemovePacket(stackID) } } } @@ -198,129 +150,105 @@ class StackRemovePacket(val id: Int, val stackID: Int) : MatteryPacket { /** * Creates a virtual, slotless container for Player to interaction with. */ -open class NetworkedItemView(val ply: Player, val menu: MatteryMenu, val remote: Boolean) : IStorageEventConsumer { - data class NetworkedItem(val id: Int, var stack: ItemStorageStack, val upstreamId: UUID? = null) +class NetworkedItemView(val ply: Player, val menu: MatteryMenu, val isRemote: Boolean) : IStorageEventConsumer { + data class Tuple(val networkId: Int, var stack: ItemStorageStack, val upstreamId: UUID? = null) : Supplier { + override fun get(): ItemStorageStack { + return stack + } + } override val storageType: StorageStack.Type get() = StorageStack.ITEMS - // this (how client see and interact with) - val localState = Int2ObjectOpenHashMap() - - val sortedView = LinkedList() - var sorter: Comparator = NAME_SORTER - - companion object { - val NAME_SORTER = Comparator { o1, o2 -> - val cmp = o1.displayName.string.compareTo(o2.displayName.string) - - if (cmp != 0) - return@Comparator cmp - - return@Comparator o1.item.registryName.toString().compareTo(o2.item.registryName.toString()) + val id2tuple = Int2ObjectOpenHashMap() + val sortedView = ArrayList() + var sorter: Comparator = ItemStorageStackSorter.DEFAULT + set(value) { + if (field != value) { + field = value + resort() + } } - val COUNT_SORTER = Comparator { o1, o2 -> - val cmp = o1.count.compareTo(o2.count) + val itemCount get() = id2tuple.size - if (cmp != 0) - return@Comparator cmp + private var nextItemID = 0 + private val uuid2tuple = Object2ObjectOpenHashMap() + private val networkBacklog = ArrayList() - return@Comparator o1.item.registryName.toString().compareTo(o2.item.registryName.toString()) - } - } + operator fun get(id: Int): Tuple? = id2tuple[id] fun resort() { - sortedView.sortWith { a, b -> - return@sortWith sorter.compare(a.stack.toItemStack(), b.stack.toItemStack()) + if (isRemote) { + sortedView.sortWith(sorter.map(Tuple::stack)) } } - // parent (e.g. VirtualComponent) - protected val upstreamState = HashMap() - protected val networkBacklog = ArrayList() + var component: IStorageComponent? = null + set(provider) { + if (provider === field) return - operator fun get(id: Int): NetworkedItem? = localState[id] - - var provider: IStorageComponent? = null - private set + field?.removeListenerAndNotify(this) + field = provider + provider?.addListenerAndNotify(this) + } fun mouseClick(index: Int, mouseButton: Int) { - if (minecraft.player?.isSpectator == true) { - return - } + if (minecraft.player?.isSpectator == true) return - val list = sortedView - - val action = + MenuNetworkChannel.sendToServer(ItemViewInteractPacket( + sortedView.getOrNull(index)?.networkId ?: -1, + if (mouseButton == InputConstants.MOUSE_BUTTON_MIDDLE) ClickType.CLONE else if (Screen.hasShiftDown()) ClickType.QUICK_MOVE else ClickType.PICKUP, if (mouseButton == InputConstants.MOUSE_BUTTON_LEFT) ClickAction.PRIMARY else ClickAction.SECONDARY - - val type = - if (mouseButton == InputConstants.MOUSE_BUTTON_MIDDLE) ClickType.CLONE else if (Screen.hasShiftDown()) ClickType.QUICK_MOVE else ClickType.PICKUP - - MenuNetworkChannel.sendToServer( - ItemViewInteractPacket(if (index >= list.size) -1 else list[index].id, type, action) - ) - } - - fun setComponent(provider: IStorageComponent?) { - if (provider === this.provider) return - - this.provider?.removeListenerAndNotify(this) - this.provider = provider - provider?.addListenerAndNotify(this) + )) } fun removed() { - provider?.removeListenerAndNotify(this) + component?.removeListenerAndNotify(this) } - val itemCount get() = localState.values.size - override fun onStackAdded(stack: ItemStorageStack, id: UUID, provider: IStorageProvider) { - check(!upstreamState.containsKey(id)) { "Already tracking ItemStack with upstream id $id!" } + check(!uuid2tuple.containsKey(id)) { "Already tracking ItemStack with upstream id $id!" } - val state = NetworkedItem(nextItemID++, stack, id) + val state = Tuple(nextItemID++, stack, id) - this.localState[state.id] = state - upstreamState[id] = state - network { StackAddPacket(menu.containerId, state.id, state.stack) } + this.id2tuple[state.networkId] = state + uuid2tuple[id] = state + network { StackAddPacket(state.networkId, state.stack) } } override fun onStackChanged(stack: ItemStorageStack, id: UUID) { - val get = upstreamState[id] ?: throw IllegalStateException("Unknown ItemStack with upstream id $id!") + val get = uuid2tuple[id] ?: throw IllegalStateException("Unknown ItemStack with upstream id $id!") get.stack = stack - network { StackChangePacket(menu.containerId, get.id, stack.count) } + network { StackChangePacket(get.networkId, stack.count) } } - protected fun network(fn: () -> Any) { - if (!remote) { + override fun onStackRemoved(id: UUID) { + val get = uuid2tuple[id] ?: throw IllegalStateException("Unknown ItemStack with upstream id $id!") + uuid2tuple.remove(id) + id2tuple.remove(get.networkId) + network { StackRemovePacket(get.networkId) } + } + + private inline fun network(fn: () -> Any) { + if (!isRemote) { networkBacklog.add(fn()) } } - override fun onStackRemoved(id: UUID) { - val get = upstreamState[id] ?: throw IllegalStateException("Unknown ItemStack with upstream id $id!") - upstreamState.remove(id) - localState.remove(get.id) - network { StackRemovePacket(menu.containerId, get.id) } - } - - protected var nextItemID = 0 - fun clear() { sortedView.clear() - upstreamState.clear() - localState.clear() + uuid2tuple.clear() + id2tuple.clear() - if (!remote) { + if (!isRemote) { networkBacklog.clear() networkBacklog.add(ClearItemViewPacket) } } fun network() { - check(!remote) { "Not a server" } + check(!isRemote) { "Not a server" } val consumer = PacketDistributor.PLAYER.with { ply as ServerPlayer } for (packet in networkBacklog) { @@ -331,82 +259,41 @@ open class NetworkedItemView(val ply: Player, val menu: MatteryMenu, val remote: } fun playerInteract(packet: ItemViewInteractPacket) { - val provider = provider ?: return - - val click = packet.type - val action = packet.action - val stackId = packet.stackID - - if (click == ClickType.CLONE) { - if (stackId < 0 || !ply.abilities.instabuild) return - - val state = get(stackId) ?: return - val copy = state.stack.toItemStack().also { it.count = it.maxStackSize } - - ply.containerMenu.carried = copy - MenuNetworkChannel.send(ply as ServerPlayer, SetCarriedPacket(ply.containerMenu.carried)) - ply.containerMenu.setRemoteCarried(ply.containerMenu.carried.copy()) + val component = component ?: return + val (stackId, type, action) = packet + if (type == ClickType.CLONE) { + if (!ply.abilities.instabuild) return + menu.syncCarried((get(stackId) ?: return).stack.toItemStack().also { it.count = it.maxStackSize }) return } - if (click == ClickType.QUICK_MOVE && stackId > -1) { - val state = get(stackId) ?: return - val stack = state.stack.toItemStack() + // забираем из системы с зажатым shift + if (type == ClickType.QUICK_MOVE) { + val tuple = get(stackId) ?: return + val stack = tuple.stack.toItemStack() - val amount = - if (action == ClickAction.PRIMARY) - stack.maxStackSize - else - 1.coerceAtLeast(stack.maxStackSize / 2) - - val extracted = provider.extractStack(state.upstreamId!!, amount.toBigInteger(), true) - - if (!extracted.isEmpty) { - val remaining = menu.quickMoveToInventory(extracted.toItemStack(), false) - - if (remaining.count != extracted.count.toInt()) { - provider.extractStack(state.upstreamId, (extracted.count.toInt() - remaining.count).toBigInteger(), false) - } - } + var amount = if (action == ClickAction.PRIMARY) all(stack) else half(stack) + amount -= menu.quickMoveToInventory(tuple.stack.toItemStack(amount), true).count + if (amount == 0) return + menu.quickMoveToInventory(component.extractStack(tuple.upstreamId!!, amount.toBigInteger(), false).toItemStack(), false) return } - if (!menu.carried.isEmpty && click != ClickType.QUICK_MOVE) { - // try to put + if (menu.carried.isNotEmpty) { if (action == ClickAction.PRIMARY) { - val carried = menu.carried - val amount = carried.count - - if (amount == carried.count) { - menu.carried = provider.insertStack(ItemStorageStack(menu.carried), false).toItemStack() - MenuNetworkChannel.send(ply as ServerPlayer, SetCarriedPacket(menu.carried)) - menu.setRemoteCarried(menu.carried.copy()) - } - } else { - val copy = menu.carried.copy() - copy.count = 1 - - if (provider.insertStack(ItemStorageStack(copy), false).isEmpty) { - menu.carried.shrink(1) - MenuNetworkChannel.send(ply as ServerPlayer, SetCarriedPacket(menu.carried)) - menu.setRemoteCarried(menu.carried.copy()) - } + menu.syncCarried(component.insertStack(ItemStorageStack(menu.carried), false).toItemStack()) + } else if (component.insertStack(ItemStorageStack(menu.carried.copyWithCount(1)), false).isEmpty) { + menu.carried.shrink(1) + menu.syncCarried() } } else if (stackId > -1) { val state = get(stackId) ?: return val stack = state.stack.toItemStack() - - val amount = - if (action == ClickAction.PRIMARY) - stack.maxStackSize - else - (stack.count / 2).coerceAtMost(stack.maxStackSize / 2).coerceAtLeast(1) - - menu.carried = provider.extractStack(state.upstreamId!!, amount.toBigInteger(), false).toItemStack() - MenuNetworkChannel.send(ply as ServerPlayer, SetCarriedPacket(menu.carried)) - menu.setRemoteCarried(menu.carried.copy()) + val amount = if (action == ClickAction.PRIMARY) all(stack) else half(stack) + menu.carried = component.extractStack(state.upstreamId!!, amount.toBigInteger(), false).toItemStack() + menu.syncCarried() } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt index 8a4893d75..12480f58e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt @@ -3,7 +3,10 @@ package ru.dbotthepony.mc.otm.menu.input import net.minecraft.world.entity.player.Player import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.GetterSetter +import ru.dbotthepony.mc.otm.core.ISubscriptable +import ru.dbotthepony.mc.otm.core.SentientGetterSetter import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.network.synchronizer.IField import java.util.function.Consumer import java.util.function.Predicate import java.util.function.Supplier @@ -14,33 +17,7 @@ import kotlin.reflect.KMutableProperty0 * * Getting and setting values should ONLY be done clientside */ -interface IPlayerInputWithFeedback : GetterSetter, Predicate { - companion object { - fun of(getterSetter: GetterSetter): IPlayerInputWithFeedback { - return object : IPlayerInputWithFeedback, GetterSetter by getterSetter { - override fun test(t: Player?): Boolean { - return true - } - } - } - - fun of(getterSetter: GetterSetter, filter: Predicate): IPlayerInputWithFeedback { - return object : IPlayerInputWithFeedback, GetterSetter by getterSetter, Predicate by filter {} - } - - fun validPlayer(getterSetter: GetterSetter): IPlayerInputWithFeedback { - return object : IPlayerInputWithFeedback, GetterSetter by getterSetter { - override fun test(t: Player?): Boolean { - return t != null - } - } - } - } -} - -fun GetterSetter.wrapAsPlayerInput(filter: Predicate = Predicate { it != null }): IPlayerInputWithFeedback { - return IPlayerInputWithFeedback.of(this, filter) -} +interface IPlayerInputWithFeedback : SentientGetterSetter, Predicate /** * Represents Server to Client synchronization and Client to Server input @@ -49,13 +26,19 @@ fun GetterSetter.wrapAsPlayerInput(filter: Predicate = Predicate */ abstract class AbstractPlayerInputWithFeedback : IPlayerInputWithFeedback { abstract val input: MatteryMenu.PlayerInput - abstract val value: V + abstract val field: IField - override fun get(): V { + final override fun addListener(listener: Consumer): ISubscriptable.L { + return field.addListener(listener) + } + + val value: V get() = this.field.value + + final override fun get(): V { return value } - override fun accept(t: V) { + final override fun accept(t: V) { input.input(t) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/BooleanInputWithFeedback.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/BooleanInputWithFeedback.kt index 21d71fca9..b90ab2934 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/BooleanInputWithFeedback.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/BooleanInputWithFeedback.kt @@ -5,16 +5,28 @@ import ru.dbotthepony.mc.otm.menu.MatteryMenu import java.util.function.BooleanSupplier import kotlin.reflect.KMutableProperty0 -class BooleanInputWithFeedback(menu: MatteryMenu) : AbstractPlayerInputWithFeedback() { - override val input = menu.booleanInput { consumer?.invoke(it) } - override val value by menu.mSynchronizer.computedBool(BooleanSupplier { supplier?.invoke() ?: false }).property +class BooleanInputWithFeedback(menu: MatteryMenu, allowSpectators: Boolean = false) : AbstractPlayerInputWithFeedback() { + override val input = menu.booleanInput(allowSpectators) { consumer?.invoke(it) } + override val field = menu.mSynchronizer.computedBool(BooleanSupplier { supplier?.invoke() ?: false }) - constructor(menu: MatteryMenu, state: KMutableProperty0) : this(menu) { - with(state) + constructor(menu: MatteryMenu, allowSpectators: Boolean, state: KMutableProperty0?) : this(menu, allowSpectators) { + if (state != null) + with(state) } - constructor(menu: MatteryMenu, state: GetterSetter) : this(menu) { - with(state) + constructor(menu: MatteryMenu, allowSpectators: Boolean, state: GetterSetter?) : this(menu, allowSpectators) { + if (state != null) + with(state) + } + + constructor(menu: MatteryMenu, state: KMutableProperty0?) : this(menu) { + if (state != null) + with(state) + } + + constructor(menu: MatteryMenu, state: GetterSetter?) : this(menu) { + if (state != null) + with(state) } fun switchValue() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt index 61df43a35..4c5877a1a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt @@ -9,12 +9,16 @@ inline fun > EnumInputWithFeedback(menu: MatteryMenu) = Enum inline fun > EnumInputWithFeedback(menu: MatteryMenu, state: KMutableProperty0?) = EnumInputWithFeedback(menu, E::class.java, state) inline fun > EnumInputWithFeedback(menu: MatteryMenu, state: GetterSetter) = EnumInputWithFeedback(menu, E::class.java, state) -class EnumInputWithFeedback>(menu: MatteryMenu, clazz: Class) : AbstractPlayerInputWithFeedback() { +inline fun > EnumInputWithFeedback(menu: MatteryMenu, allowSpectators: Boolean) = EnumInputWithFeedback(menu, E::class.java, allowSpectators) +inline fun > EnumInputWithFeedback(menu: MatteryMenu, allowSpectators: Boolean, state: KMutableProperty0?) = EnumInputWithFeedback(menu, E::class.java, allowSpectators, state) +inline fun > EnumInputWithFeedback(menu: MatteryMenu, allowSpectators: Boolean, state: GetterSetter) = EnumInputWithFeedback(menu, E::class.java, allowSpectators, state) + +class EnumInputWithFeedback>(menu: MatteryMenu, clazz: Class, allowSpectators: Boolean = false) : AbstractPlayerInputWithFeedback() { val codec = EnumValueCodec(clazz) private val default = codec.values.first() - override val input = menu.PlayerInput(codec, false) { consumer?.invoke(it) } - override val value by menu.mSynchronizer.ComputedField(getter = { supplier?.invoke() ?: default }, codec) + override val input = menu.PlayerInput(codec, allowSpectators) { consumer?.invoke(it) } + override val field = menu.mSynchronizer.ComputedField(getter = { supplier?.invoke() ?: default }, codec) constructor(menu: MatteryMenu, clazz: Class, state: KMutableProperty0?) : this(menu, clazz) { if (state != null) { @@ -22,7 +26,21 @@ class EnumInputWithFeedback>(menu: MatteryMenu, clazz: Class) : A } } - constructor(menu: MatteryMenu, clazz: Class, state: GetterSetter) : this(menu, clazz) { - with(state) + constructor(menu: MatteryMenu, clazz: Class, state: GetterSetter?) : this(menu, clazz) { + if (state != null) { + with(state) + } + } + + constructor(menu: MatteryMenu, clazz: Class, allowSpectators: Boolean, state: KMutableProperty0?) : this(menu, clazz, allowSpectators) { + if (state != null) { + with(state) + } + } + + constructor(menu: MatteryMenu, clazz: Class, allowSpectators: Boolean, state: GetterSetter?) : this(menu, clazz, allowSpectators) { + if (state != null) { + with(state) + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/StringInputWithFeedback.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/StringInputWithFeedback.kt index 9d918dd2d..617bd9dfc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/StringInputWithFeedback.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/StringInputWithFeedback.kt @@ -6,7 +6,7 @@ import kotlin.reflect.KMutableProperty0 class StringInputWithFeedback(menu: MatteryMenu) : AbstractPlayerInputWithFeedback() { override val input = menu.stringInput { consumer?.invoke(it.replace('\u0000', ' ')) } - override val value by menu.mSynchronizer.computedString { supplier?.invoke() ?: "" } + override val field = menu.mSynchronizer.computedString { supplier?.invoke() ?: "" } constructor(menu: MatteryMenu, state: KMutableProperty0) : this(menu) { with(state) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt index fb69a94a1..67fdf18e4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt @@ -190,8 +190,8 @@ class MatterPanelMenu( val sortingGS = GetterSetter.of(::sorting, changeSorting::input) val isAscendingGS = GetterSetter.of(::isAscending, changeIsAscending::input) - private val actualComparator = Comparator { o1, o2 -> sorting.comparator.compare(o1.item, o2.item) * (if (isAscending) 1 else -1) } - private val actualTaskComparator = Comparator { o1, o2 -> sorting.comparator.compare(o1.item, o2.item) * (if (isAscending) 1 else -1) } + private val actualComparator = Comparator { o1, o2 -> sorting.compare(o1.item, o2.item) * (if (isAscending) 1 else -1) } + private val actualTaskComparator = Comparator { o1, o2 -> sorting.compare(o1.item, o2.item) * (if (isAscending) 1 else -1) } private val patterns = ArrayList() private val tasks = ArrayList() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt index 89e4e664c..ebad3143d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt @@ -1,57 +1,67 @@ package ru.dbotthepony.mc.otm.menu.storage -import com.google.common.collect.ImmutableList import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player -import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack import net.minecraftforge.common.capabilities.ForgeCapabilities import ru.dbotthepony.mc.otm.block.entity.storage.DriveViewerBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.drive.IMatteryDrive +import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.core.ifPresentK +import ru.dbotthepony.mc.otm.core.util.ItemStorageStackSorter import ru.dbotthepony.mc.otm.item.PortableCondensationDriveItem import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.data.INetworkedItemViewProvider import ru.dbotthepony.mc.otm.menu.data.NetworkedItemView import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput +import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback +import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus import ru.dbotthepony.mc.otm.storage.ItemStorageStack import ru.dbotthepony.mc.otm.storage.StorageStack import ru.dbotthepony.mc.otm.storage.powered.PoweredVirtualComponent -class DriveViewerMenu @JvmOverloads constructor( +class DriveViewerMenu( containerID: Int, inventory: Inventory, tile: DriveViewerBlockEntity? = null -) : MatteryPoweredMenu( - MMenus.DRIVE_VIEWER, containerID, inventory, tile -), INetworkedItemViewProvider { +) : MatteryPoweredMenu(MMenus.DRIVE_VIEWER, containerID, inventory, tile), INetworkedItemViewProvider { override val networkedItemView = NetworkedItemView(inventory.player, this, tile == null) - val driveSlot: MatterySlot + + val driveSlot = object : MatterySlot(tile?.container ?: SimpleContainer(1), 0) { + override fun mayPlace(itemStack: ItemStack): Boolean { + return itemStack.getCapability(MatteryCapability.DRIVE).isPresent + } + } private val powered: PoweredVirtualComponent? private var lastDrive: IMatteryDrive? = null + val profiledEnergy = ProfiledLevelGaugeWidget>(this, energyWidget) + val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) - init { - val container = tile?.container ?: SimpleContainer(1) + val settings = object : DriveViewerBlockEntity.ISettings { + override var sorting: ItemStorageStackSorter by EnumInputWithFeedback(this@DriveViewerMenu, true, tile?.let { it.getSettingsFor(ply)::sorting }).also { it.addListener { changes() } } + override var isAscending: Boolean by BooleanInputWithFeedback(this@DriveViewerMenu, true, tile?.let { it.getSettingsFor(ply)::isAscending }).also { it.addListener { changes() } } - driveSlot = object : MatterySlot(container, 0) { - override fun mayPlace(itemStack: ItemStack): Boolean { - return itemStack.getCapability(MatteryCapability.DRIVE).isPresent + private fun changes() { + if (isAscending) { + networkedItemView.sorter = sorting + } else { + networkedItemView.sorter = sorting.reversed } } + } + init { if (tile != null) { - powered = PoweredVirtualComponent( - StorageStack.ITEMS, - tile.getCapability(MatteryCapability.ENERGY).resolve()::get - ) - - this.networkedItemView.setComponent(powered) + profiledEnergy.with(tile.energy) + powered = PoweredVirtualComponent(StorageStack.ITEMS, tile::energy) + this.networkedItemView.component = powered } else { powered = null } @@ -126,12 +136,9 @@ class DriveViewerMenu @JvmOverloads constructor( } } - override fun removed(p_38940_: Player) { - super.removed(p_38940_) - - if (lastDrive != null) - powered?.remove(lastDrive!!) - + override fun removed(player: Player) { + super.removed(player) + lastDrive?.let { powered?.remove(it) } this.networkedItemView.removed() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt index d7714883c..373f7390e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt @@ -6,15 +6,20 @@ import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.item.ItemStack -import net.minecraftforge.network.PacketDistributor +import ru.dbotthepony.mc.otm.block.entity.storage.IItemMonitorPlayerSettings import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorPlayerSettings import ru.dbotthepony.mc.otm.container.get +import ru.dbotthepony.mc.otm.core.collect.mapToInt +import ru.dbotthepony.mc.otm.core.collect.reduce +import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.data.INetworkedItemViewProvider import ru.dbotthepony.mc.otm.menu.data.NetworkedItemView -import ru.dbotthepony.mc.otm.network.MenuNetworkChannel +import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback +import ru.dbotthepony.mc.otm.menu.makeSlots import ru.dbotthepony.mc.otm.registry.MMenus import ru.dbotthepony.mc.otm.storage.* import java.util.* @@ -73,73 +78,85 @@ private class ResultSlot(container: Container) : MatterySlot(container, 0) { } } -class ItemMonitorMenu @JvmOverloads constructor( +class ItemMonitorMenu( containerId: Int, inventory: Inventory, tile: ItemMonitorBlockEntity? = null ) : MatteryPoweredMenu(MMenus.ITEM_MONITOR, containerId, inventory, tile), INetworkedItemViewProvider { override val networkedItemView = NetworkedItemView(inventory.player, this, tile == null) - val settings: ItemMonitorPlayerSettings = tile?.getSettings(inventory.player as ServerPlayer) ?: ItemMonitorPlayerSettings() - private var settingsNetworked = false + + val settings = object : IItemMonitorPlayerSettings { + override var ingredientPriority by EnumInputWithFeedback(this@ItemMonitorMenu, true, tile?.let { it.getSettings(ply as ServerPlayer)::ingredientPriority }) + override var resultTarget by EnumInputWithFeedback(this@ItemMonitorMenu, true, tile?.let { it.getSettings(ply as ServerPlayer)::resultTarget }) + override var craftingAmount by EnumInputWithFeedback(this@ItemMonitorMenu, true, tile?.let { it.getSettings(ply as ServerPlayer)::craftingAmount }) + override var sorting by EnumInputWithFeedback(this@ItemMonitorMenu, true, tile?.let { it.getSettings(ply as ServerPlayer)::sorting }).also { it.addListener { changes() } } + override var ascendingSort by BooleanInputWithFeedback(this@ItemMonitorMenu, true, tile?.let { it.getSettings(ply as ServerPlayer)::ascendingSort }).also { it.addListener { changes() } } + + private fun changes() { + if (ascendingSort) { + networkedItemView.sorter = sorting + } else { + networkedItemView.sorter = sorting.reversed + } + } + } val craftingResult: MatterySlot val craftingSlots: List init { if (tile != null) { - networkedItemView.setComponent(tile.poweredView) - craftingResult = ResultSlot(tile.craftingResultContainer) - craftingSlots = Collections.unmodifiableList(Array(9) { MatterySlot(tile.craftingGrid, it) }.asList()) - } else { - craftingResult = ResultSlot(SimpleContainer(1)) - val container = SimpleContainer(9) - craftingSlots = Collections.unmodifiableList(Array(9) { MatterySlot(container, it) }.asList()) + networkedItemView.component = tile.poweredView } - val slots = craftingSlots.map(this::addSlot) + craftingResult = ResultSlot(tile?.craftingResultContainer ?: SimpleContainer(1)) + craftingSlots = makeSlots(tile?.craftingGrid ?: SimpleContainer(9), ::MatterySlot) + craftingSlots.forEach(this::addSlot) addSlot(craftingResult) addInventorySlots() } - override fun broadcastFullState() { - super.broadcastFullState() - MenuNetworkChannel.send(PacketDistributor.PLAYER.with { ply as ServerPlayer }, settings) - settingsNetworked = true - } - - fun sendSettingsToServer() { - MenuNetworkChannel.sendToServer(settings) - } - - override fun removed(p_38940_: Player) { - super.removed(p_38940_) + override fun removed(player: Player) { + super.removed(player) networkedItemView.removed() } override fun broadcastChanges() { super.broadcastChanges() networkedItemView.network() + } - if (!settingsNetworked) { - MenuNetworkChannel.send(PacketDistributor.PLAYER.with { ply as ServerPlayer }, settings) - settingsNetworked = true + private fun moveCrafting(view: IStorageComponent, simulate: Boolean): Boolean { + val itemStack = craftingResult.item + var remaining: ItemStack + + if (settings.resultTarget == ItemMonitorPlayerSettings.ResultTarget.ALL_SYSTEM) { + remaining = view.insertStack(ItemStorageStack(itemStack), simulate).toItemStack() + remaining = moveItemStackToSlots(remaining, playerInventorySlots, simulate) + } else { + remaining = moveItemStackToSlots(itemStack, playerInventorySlots, simulate) + remaining = view.insertStack(ItemStorageStack(remaining), simulate).toItemStack() } + + if (!simulate && remaining.isNotEmpty) { + ply.spawnAtLocation(remaining) + } + + if (!simulate) { + craftingResult.remove(itemStack.count) + } + + return remaining.count != itemStack.count } override fun quickMoveStack(ply: Player, slotIndex: Int): ItemStack { if (playerInventorySlots.any { it.index == slotIndex }) { - if (tile == null) { - return ItemStack.EMPTY - } - + if (tile == null) return ItemStack.EMPTY val slot = slots[slotIndex] + if (slot.item.isEmpty) return ItemStack.EMPTY - if (slot.item.isEmpty) { - return ItemStack.EMPTY - } - - val leftover = networkedItemView.provider?.insertStack(ItemStorageStack(slot.item), false)?.toItemStack() ?: slot.item + val leftover = networkedItemView.component?.insertStack(ItemStorageStack(slot.item), false)?.toItemStack() ?: slot.item if (leftover.count == slot.item.count) { return ItemStack.EMPTY @@ -148,77 +165,48 @@ class ItemMonitorMenu @JvmOverloads constructor( val old = slot.item.copy() slot.item.count = leftover.count return old - } else if (slotIndex in craftingSlots[0].index .. craftingSlots[craftingSlots.size - 1].index) { + } else if (craftingSlots.any { it.index == slotIndex }) { // from crafting grid to inventory val item = slots[slotIndex].item + if (item.isEmpty) return ItemStack.EMPTY - if (item.isEmpty) { - return ItemStack.EMPTY + var remainder = item + + when (settings.ingredientPriority) { + ItemMonitorPlayerSettings.IngredientPriority.SYSTEM, ItemMonitorPlayerSettings.IngredientPriority.SYSTEM_FIRST -> { + remainder = networkedItemView.component?.insertStack(ItemStorageStack(remainder), false)?.toItemStack() ?: remainder + } + + else -> {} } - var remainder = moveItemStackToSlots(item, playerInventorySlots) + remainder = moveItemStackToSlots(remainder, playerInventorySlots) + slots[slotIndex].set(remainder) - - if (remainder.isEmpty) { - return item - } - - remainder = networkedItemView.provider?.insertStack(ItemStorageStack(remainder), false)?.toItemStack() ?: remainder - slots[slotIndex].set(remainder) - - if (remainder.isEmpty) { - return item - } - return if (remainder.count != item.count) item else ItemStack.EMPTY } else if (slotIndex == craftingResult.index) { - // quickcraft... god damn it - if (!craftingResult.hasItem()) { - return ItemStack.EMPTY - } - - val item = craftingResult.item - + var item = craftingResult.item + if (item.isEmpty) return ItemStack.EMPTY val tile = tile as ItemMonitorBlockEntity? ?: return ItemStack.EMPTY if (tile.lastCraftingRecipe(ply) != null && tile.craftingRecipe != tile.lastCraftingRecipe(ply)) { - // recipe has changed + // рецепт изменился return ItemStack.EMPTY } + val crafted = tile.howMuchPlayerCrafted(ply) + if (settings.craftingAmount == ItemMonitorPlayerSettings.Amount.ONE) { - if (tile.howMuchPlayerCrafted(ply) > 0) { + if (crafted > 0) { return ItemStack.EMPTY } } else { - var hasUnstackables = false - var maxStack = 64 - - if (settings.craftingAmount == ItemMonitorPlayerSettings.Amount.FULL) { - for (gridItem in tile.craftingGrid.iterator()) { - if (!gridItem.isStackable) { - hasUnstackables = true - break - } - } - } else { - maxStack = 0 - - for (gridItem in tile.craftingGrid.iterator()) { - maxStack = maxStack.coerceAtLeast(gridItem.maxStackSize) - } - } - - if (settings.craftingAmount == ItemMonitorPlayerSettings.Amount.STACK || hasUnstackables) { - val count = tile.howMuchPlayerCrafted(ply) - - if (count > 0 && (count + 1) * craftingResult.item.count > craftingResult.item.maxStackSize) { + if (settings.craftingAmount == ItemMonitorPlayerSettings.Amount.STACK || tile.craftingGrid.any { !it.isStackable }) { + if (crafted > 0 && (crafted + 1) * item.count > item.maxStackSize) { return ItemStack.EMPTY } } else { - val count = tile.howMuchPlayerCrafted(ply) - - if (count > 0 && count >= maxStack) { + if (crafted > 0 && crafted >= tile.craftingGrid.iterator().mapToInt { it.maxStackSize }.reduce(Int.MAX_VALUE, Int::coerceAtMost)) { return ItemStack.EMPTY } } @@ -227,50 +215,12 @@ class ItemMonitorMenu @JvmOverloads constructor( tile.craftingResultContainer.craftingPlayer = ply as ServerPlayer try { - when (settings.resultTarget) { - ItemMonitorPlayerSettings.ResultTarget.ALL_SYSTEM -> { - val wrapper = ItemStorageStack(item) - var remaining = tile.poweredView?.insertStack(wrapper, true)?.toItemStack() ?: return ItemStack.EMPTY - - if (remaining.isEmpty) { - tile.poweredView!!.insertStack(wrapper, false) - craftingResult.remove(item.count) - return item - } - - remaining = moveItemStackToSlots(remaining, playerInventorySlots, simulate = true) - - if (remaining.isEmpty) { - remaining = tile.poweredView!!.insertStack(wrapper, false).toItemStack() - moveItemStackToSlots(remaining, playerInventorySlots, simulate = false) - craftingResult.remove(item.count) - return item - } - - return ItemStack.EMPTY - } - - ItemMonitorPlayerSettings.ResultTarget.MIXED, ItemMonitorPlayerSettings.ResultTarget.ALL_INVENTORY -> { - var remaining = moveItemStackToSlots(item, playerInventorySlots, simulate = true) - - if (remaining.isEmpty) { - moveItemStackToSlots(item, playerInventorySlots, simulate = false) - craftingResult.remove(item.count) - return item - } - - val wrapper = ItemStorageStack(remaining) - remaining = tile.poweredView?.insertStack(wrapper, true)?.toItemStack() ?: return ItemStack.EMPTY - - if (remaining.isEmpty) { - moveItemStackToSlots(item, playerInventorySlots, simulate = false) - tile.poweredView!!.insertStack(wrapper, false) - craftingResult.remove(item.count) - return item - } - - return ItemStack.EMPTY - } + if (moveCrafting(tile.poweredView ?: return ItemStack.EMPTY, true)) { + item = item.copy() + moveCrafting(tile.poweredView ?: return ItemStack.EMPTY, false) + return item + } else { + return ItemStack.EMPTY } } finally { tile.craftingResultContainer.craftingPlayer = null diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt index 84a72b312..829d0fc6d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt @@ -81,8 +81,8 @@ object MenuNetworkChannel : MatteryNetworkChannel( add(SetCarriedPacket::class.java, SetCarriedPacket.Companion::read, NetworkDirection.PLAY_TO_CLIENT) add(ItemFilterSlotPacket::class.java, ItemFilterSlotPacket.Companion::read) - // networked view - add(ClearItemViewPacket::class.java, ClearItemViewPacket::read, NetworkDirection.PLAY_TO_CLIENT) + // networked item view + add(ClearItemViewPacket::class.java, { ClearItemViewPacket }, NetworkDirection.PLAY_TO_CLIENT) add(ItemViewInteractPacket::class.java, ItemViewInteractPacket.Companion::read, NetworkDirection.PLAY_TO_SERVER) add(StackAddPacket::class.java, StackAddPacket.Companion::read, NetworkDirection.PLAY_TO_CLIENT) add(StackChangePacket::class.java, StackChangePacket.Companion::read, NetworkDirection.PLAY_TO_CLIENT) @@ -94,9 +94,6 @@ object MenuNetworkChannel : MatteryNetworkChannel( // Client->Server add(MatteryMenu.PlayerInputPacket::class.java, MatteryMenu::PlayerInputPacket, NetworkDirection.PLAY_TO_SERVER) - // Item monitor - add(ItemMonitorPlayerSettings::class.java, ItemMonitorPlayerSettings.Companion::read) - // matter panel menu add(CancelTaskPacket::class.java, CancelTaskPacket.Companion::read, NetworkDirection.PLAY_TO_SERVER) add(PatternsChangePacket::class.java, PatternsChangePacket.Companion::read, NetworkDirection.PLAY_TO_CLIENT) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt index 4df86bf24..523b28c8b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt @@ -33,6 +33,7 @@ import java.lang.ref.WeakReference import java.math.BigDecimal import java.util.* import java.util.function.BooleanSupplier +import java.util.function.Consumer import java.util.function.DoubleConsumer import java.util.function.DoubleSupplier import java.util.function.IntConsumer @@ -529,6 +530,11 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa isObserver: Boolean = false, ) : AbstractField(), IMutableField { private var remote: V = codec.copy(field) + private val subs = ISubscriptable.Impl() + + override fun addListener(listener: Consumer): ISubscriptable.L { + return subs.addListener(listener) + } init { if (isObserver) { @@ -548,6 +554,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } this@Field.field = value + subs.accept(value) } } @@ -577,15 +584,15 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa if (setter != null) { setter.invoke(value, access, false) - return - } + } else { + if (!isDirty && !codec.compare(remote, value)) { + notifyEndpoints(this@Field) + isDirty = true + } - if (!isDirty && !codec.compare(remote, value)) { - notifyEndpoints(this@Field) - isDirty = true + this.field = value + subs.accept(value) } - - this.field = value } override fun write(stream: DataOutputStream, endpoint: Endpoint) { @@ -602,10 +609,10 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa if (setter != null) { setter.invoke(value, access, true) - return + } else { + this.field = value + subs.accept(value) } - - this.field = value } } @@ -619,7 +626,21 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa /** * Type specific field, storing primitive [Float] directly */ - inner class FloatField(private var field: Float, private val getter: FloatFieldGetter? = null, private val setter: FloatFieldSetter? = null) : PrimitiveField(), IMutableFloatField { + inner class FloatField(field: Float, private val getter: FloatFieldGetter? = null, private val setter: FloatFieldSetter? = null) : PrimitiveField(), IMutableFloatField { + private val subs = IFloatSubcripable.Impl() + + override fun addListener(listener: FloatConsumer): ISubscriptable.L { + return subs.addListener(listener) + } + + private var field = field + set(value) { + if (field != value) { + field = value + subs.accept(value) + } + } + override val property = object : IMutableFloatProperty { override fun getValue(thisRef: Any?, property: KProperty<*>): Float { return this@FloatField.float @@ -686,7 +707,21 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa /** * Type specific field, storing primitive [Double] directly */ - inner class DoubleField(private var field: Double, private val getter: DoubleFieldGetter? = null, private val setter: DoubleFieldSetter? = null) : PrimitiveField(), IMutableDoubleField { + inner class DoubleField(field: Double, private val getter: DoubleFieldGetter? = null, private val setter: DoubleFieldSetter? = null) : PrimitiveField(), IMutableDoubleField { + private val subs = IDoubleSubcripable.Impl() + + override fun addListener(listener: DoubleConsumer): ISubscriptable.L { + return subs.addListener(listener) + } + + private var field = field + set(value) { + if (field != value) { + field = value + subs.accept(value) + } + } + override val property = object : IMutableDoubleProperty { override fun getValue(thisRef: Any?, property: KProperty<*>): Double { return this@DoubleField.double @@ -750,7 +785,21 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } } - abstract inner class AbstractIntField(protected var field: Int, private val getter: IntFieldGetter? = null, protected val setter: IntFieldSetter? = null) : PrimitiveField(), IMutableIntField { + abstract inner class AbstractIntField(field: Int, private val getter: IntFieldGetter? = null, protected val setter: IntFieldSetter? = null) : PrimitiveField(), IMutableIntField { + private val subs = IIntSubcripable.Impl() + + override fun addListener(listener: IntConsumer): ISubscriptable.L { + return subs.addListener(listener) + } + + protected var field = field + set(value) { + if (field != value) { + field = value + subs.accept(value) + } + } + final override val property = object : IMutableIntProperty { override fun getValue(thisRef: Any?, property: KProperty<*>): Int { return this@AbstractIntField.int @@ -845,7 +894,21 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa /** * Type specific field, storing primitive [Long] directly */ - abstract inner class AbstractLongField(protected var field: Long, private val getter: LongFieldGetter? = null, protected val setter: LongFieldSetter? = null) : PrimitiveField(), IMutableLongField { + abstract inner class AbstractLongField(field: Long, private val getter: LongFieldGetter? = null, protected val setter: LongFieldSetter? = null) : PrimitiveField(), IMutableLongField { + private val subs = ILongSubcripable.Impl() + + override fun addListener(listener: LongConsumer): ISubscriptable.L { + return subs.addListener(listener) + } + + protected var field = field + set(value) { + if (field != value) { + field = value + subs.accept(value) + } + } + final override val property = object : IMutableLongProperty { override fun getValue(thisRef: Any?, property: KProperty<*>): Long { return this@AbstractLongField.long @@ -940,7 +1003,21 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa /** * Type specific field, storing primitive [Boolean] directly */ - inner class BooleanField(private var field: Boolean, private val getter: BooleanFieldGetter? = null, private val setter: BooleanFieldSetter? = null) : PrimitiveField(), IMutableBooleanField { + inner class BooleanField(field: Boolean, private val getter: BooleanFieldGetter? = null, private val setter: BooleanFieldSetter? = null) : PrimitiveField(), IMutableBooleanField { + private val subs = IBooleanSubscriptable.Impl() + + override fun addListener(listener: BooleanConsumer): ISubscriptable.L { + return subs.addListener(listener) + } + + private var field = field + set(value) { + if (field != value) { + field = value + subs.accept(value) + } + } + override val property = object : IMutableBooleanProperty { override fun getValue(thisRef: Any?, property: KProperty<*>): Boolean { return this@BooleanField.boolean @@ -1014,6 +1091,11 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa ) : AbstractField(), IField { private var remote: Any? = Mark private var clientValue: Any? = Mark + private val subs = ISubscriptable.Impl() + + override fun addListener(listener: Consumer): ISubscriptable.L { + return subs.addListener(listener) + } init { observers.add(this) @@ -1055,6 +1137,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa val newValue = codec.read(stream) clientValue = newValue observer.invoke(newValue) + subs.accept(newValue) } } @@ -1063,11 +1146,22 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa * * This class has concrete implementation for [Float] primitive */ - inner class ComputedFloatField(private val getter: FloatSupplier, private val observer: FloatConsumer = FloatConsumer {}) : AbstractField(), IFloatField { + inner class ComputedFloatField(private val getter: FloatSupplier, observer: FloatConsumer? = null) : AbstractField(), IFloatField { private var remote: Float = 0f private var isRemoteSet = false private var clientValue: Float = 0f private var isClientValue = false + private val subs = IFloatSubcripable.Impl() + + init { + if (observer != null) { + subs.addListener(observer) + } + } + + override fun addListener(listener: FloatConsumer): ISubscriptable.L { + return subs.addListener(listener) + } override val property = object : IFloatProperty { override fun getValue(thisRef: Any?, property: KProperty<*>): Float { @@ -1120,7 +1214,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa val newValue = stream.readFloat() clientValue = newValue isClientValue = true - observer.accept(newValue) + subs.accept(newValue) } @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) @@ -1134,11 +1228,22 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa * * This class has concrete implementation for [Double] primitive */ - inner class ComputedDoubleField(private val getter: DoubleSupplier, private val observer: DoubleConsumer = DoubleConsumer {}) : AbstractField(), IDoubleField { + inner class ComputedDoubleField(private val getter: DoubleSupplier, observer: DoubleConsumer? = null) : AbstractField(), IDoubleField { private var remote: Double = 0.0 private var isRemoteSet = false private var clientValue: Double = 0.0 private var isClientValue = false + private val subs = IDoubleSubcripable.Impl() + + init { + if (observer != null) { + subs.addListener(observer) + } + } + + override fun addListener(listener: DoubleConsumer): ISubscriptable.L { + return subs.addListener(listener) + } override val property = object : IDoubleProperty { override fun getValue(thisRef: Any?, property: KProperty<*>): Double { @@ -1185,7 +1290,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa val newValue = stream.readDouble() clientValue = newValue isClientValue = true - observer.accept(newValue) + subs.accept(newValue) } @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) @@ -1199,11 +1304,29 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa * * This class has concrete implementation for [Int] primitive */ - abstract inner class AbstractComputedIntField(protected val getter: IntSupplier, protected val observer: IntConsumer = IntConsumer {}) : AbstractField(), IIntField { + abstract inner class AbstractComputedIntField(protected val getter: IntSupplier, observer: IntConsumer? = null) : AbstractField(), IIntField { private var remote: Int = 0 private var isRemoteSet = false protected var clientValue: Int = 0 + set(value) { + if (field != value) { + field = value + subs.accept(value) + } + } + protected var isClientValue = false + private val subs = IIntSubcripable.Impl() + + init { + if (observer != null) { + subs.addListener(observer) + } + } + + override fun addListener(listener: IntConsumer): ISubscriptable.L { + return subs.addListener(listener) + } final override val property = object : IIntProperty { override fun getValue(thisRef: Any?, property: KProperty<*>): Int { @@ -1259,10 +1382,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa override fun read(stream: DataInputStream) { check(!isRemoved) { "Field was removed" } - val newValue = stream.readVarIntLE() - clientValue = newValue - isClientValue = true - observer.accept(newValue) + clientValue = stream.readVarIntLE() } } @@ -1280,10 +1400,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa override fun read(stream: DataInputStream) { check(!isRemoved) { "Field was removed" } - val newValue = stream.readInt() - clientValue = newValue - isClientValue = true - observer.accept(newValue) + clientValue = stream.readInt() } } @@ -1292,11 +1409,31 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa * * This class has concrete implementation for [Long] primitive */ - abstract inner class AbstractComputedLongField(protected val getter: LongSupplier, protected val observer: LongConsumer = LongConsumer {}) : AbstractField(), ILongField { + abstract inner class AbstractComputedLongField(protected val getter: LongSupplier, observer: LongConsumer? = null) : AbstractField(), ILongField { private var remote: Long = 0L private var isRemoteSet = false protected var clientValue: Long = 0L + set(value) { + isClientValue = true + + if (field != value) { + field = value + subs.accept(value) + } + } + protected var isClientValue = false + private val subs = ILongSubcripable.Impl() + + init { + if (observer != null) { + subs.addListener(observer) + } + } + + override fun addListener(listener: LongConsumer): ISubscriptable.L { + return subs.addListener(listener) + } final override val property = object : ILongProperty { override fun getValue(thisRef: Any?, property: KProperty<*>): Long { @@ -1352,10 +1489,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa override fun read(stream: DataInputStream) { check(!isRemoved) { "Field was removed" } - val newValue = stream.readVarLongLE() - clientValue = newValue - isClientValue = true - observer.accept(newValue) + clientValue = stream.readVarLongLE() } } @@ -1373,10 +1507,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa override fun read(stream: DataInputStream) { check(!isRemoved) { "Field was removed" } - val newValue = stream.readLong() - clientValue = newValue - isClientValue = true - observer.accept(newValue) + clientValue = stream.readLong() } } @@ -1385,11 +1516,22 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa * * This class has concrete implementation for [Boolean] primitive */ - inner class ComputedBooleanField(private val getter: BooleanSupplier, private val observer: BooleanConsumer = BooleanConsumer {}) : AbstractField(), IBooleanField { + inner class ComputedBooleanField(private val getter: BooleanSupplier, observer: BooleanConsumer? = null) : AbstractField(), IBooleanField { private var remote: Boolean = false private var isRemoteSet = false private var clientValue: Boolean = false private var isClientValue = false + private val subs = IBooleanSubscriptable.Impl() + + init { + if (observer != null) { + subs.addListener(observer) + } + } + + override fun addListener(listener: BooleanConsumer): ISubscriptable.L { + return subs.addListener(listener) + } override val property = object : IBooleanProperty { override fun getValue(thisRef: Any?, property: KProperty<*>): Boolean { @@ -1436,7 +1578,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa val newValue = stream.readBoolean() clientValue = newValue isClientValue = true - observer.accept(newValue) + subs.accept(newValue) } @Deprecated("Use type specific property", replaceWith = ReplaceWith("this.property")) @@ -1453,6 +1595,11 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa private val getter: () -> V private val setter: (V) -> Unit private var remote: V + private val subs = ISubscriptable.Impl() + + override fun addListener(listener: Consumer): ISubscriptable.L { + return subs.addListener(listener) + } override var value: V get() = getter.invoke() @@ -1499,6 +1646,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa override fun read(stream: DataInputStream) { check(!isRemoved) { "Field was removed" } this.value = codec.read(stream) + subs.accept(this.value) } } @@ -1506,7 +1654,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa private val codec: IStreamCodec, private val backingSet: MutableSet, private val callback: ((changes: Collection>) -> Unit)? = null, - ) : AbstractField>() { + ) : AbstractField>(), ISubscriptable> by ISubscriptable.empty() { private var isRemote = false private fun pushBacklog(element: E, action: (DataOutputStream) -> Unit) { @@ -1745,7 +1893,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa private val valueCodec: IStreamCodec, private val backingMap: MutableMap, private val callback: ((changes: Collection>) -> Unit)? = null, - ) : AbstractField>(), IField> { + ) : AbstractField>(), IField>, ISubscriptable> by ISubscriptable.empty() { private var sentAllValues = false private var isRemote = false diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/Fields.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/Fields.kt index 3cbfeb41b..c3276c8cd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/Fields.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/Fields.kt @@ -1,6 +1,12 @@ package ru.dbotthepony.mc.otm.network.synchronizer import ru.dbotthepony.mc.otm.core.FloatSupplier +import ru.dbotthepony.mc.otm.core.IBooleanSubscriptable +import ru.dbotthepony.mc.otm.core.IDoubleSubcripable +import ru.dbotthepony.mc.otm.core.IFloatSubcripable +import ru.dbotthepony.mc.otm.core.IIntSubcripable +import ru.dbotthepony.mc.otm.core.ILongSubcripable +import ru.dbotthepony.mc.otm.core.ISubscriptable import java.io.DataInputStream import java.io.DataOutputStream import java.util.function.BooleanSupplier @@ -11,7 +17,7 @@ import java.util.function.Supplier import kotlin.properties.ReadOnlyProperty import kotlin.reflect.KProperty -sealed interface IField : ReadOnlyProperty, Supplier, () -> V { +sealed interface IField : ReadOnlyProperty, Supplier, () -> V, ISubscriptable { fun observe(): Boolean fun markDirty() fun markDirty(endpoint: FieldSynchronizer.Endpoint) @@ -40,7 +46,7 @@ interface IFloatProperty { operator fun getValue(thisRef: Any?, property: KProperty<*>): Float } -sealed interface IFloatField : IField, FloatSupplier { +sealed interface IFloatField : IField, FloatSupplier, IFloatSubcripable { val float: Float val property: IFloatProperty @@ -66,7 +72,7 @@ interface IDoubleProperty { operator fun getValue(thisRef: Any?, property: KProperty<*>): Double } -sealed interface IDoubleField : IField, DoubleSupplier { +sealed interface IDoubleField : IField, DoubleSupplier, IDoubleSubcripable { val double: Double val property: IDoubleProperty @@ -92,7 +98,7 @@ interface IIntProperty { operator fun getValue(thisRef: Any?, property: KProperty<*>): Int } -sealed interface IIntField : IField, IntSupplier { +sealed interface IIntField : IField, IntSupplier, IIntSubcripable { val int: Int val property: IIntProperty @@ -118,7 +124,7 @@ interface ILongProperty { operator fun getValue(thisRef: Any?, property: KProperty<*>): Long } -sealed interface ILongField : IField, LongSupplier { +sealed interface ILongField : IField, LongSupplier, ILongSubcripable { val long: Long val property: ILongProperty @@ -144,7 +150,7 @@ interface IBooleanProperty { operator fun getValue(thisRef: Any?, property: KProperty<*>): Boolean } -sealed interface IBooleanField : IField, BooleanSupplier { +sealed interface IBooleanField : IField, BooleanSupplier, IBooleanSubscriptable { val boolean: Boolean val property: IBooleanProperty diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/MutableFields.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/MutableFields.kt index a6937cf89..4f385ad01 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/MutableFields.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/MutableFields.kt @@ -3,12 +3,13 @@ package ru.dbotthepony.mc.otm.network.synchronizer import it.unimi.dsi.fastutil.booleans.BooleanConsumer import it.unimi.dsi.fastutil.floats.FloatConsumer import ru.dbotthepony.mc.otm.core.GetterSetter +import ru.dbotthepony.mc.otm.core.SentientGetterSetter import java.util.function.DoubleConsumer import java.util.function.IntConsumer import java.util.function.LongConsumer import kotlin.reflect.KProperty -sealed interface IMutableField : IField, GetterSetter { +sealed interface IMutableField : IField, SentientGetterSetter { override fun getValue(thisRef: Any?, property: KProperty<*>): V { return this.value } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt index b31328a25..6f10f057f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt @@ -18,7 +18,7 @@ import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.capability.matter.matter import ru.dbotthepony.mc.otm.capability.matteryEnergy -import ru.dbotthepony.mc.otm.core.util.CreativeMenuComparator +import ru.dbotthepony.mc.otm.core.util.CreativeMenuItemComparator import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.registryName @@ -177,6 +177,9 @@ private fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { accept(MItems.PATTERN_DRIVE_CREATIVE) accept(MItems.PATTERN_DRIVE_CREATIVE2) + accept(MItems.PORTABLE_CONDENSATION_DRIVE) + accept(MItems.PORTABLE_DENSE_CONDENSATION_DRIVE) + fluids(MItems.FLUID_CAPSULE) fluids(MItems.FLUID_TANK) @@ -285,7 +288,7 @@ object MCreativeTabs { } fun register(event: BuildCreativeModeTabContentsEvent) { - CreativeMenuComparator.invalidate() + CreativeMenuItemComparator.invalidate() when (event.tab) { MAIN -> addMainCreativeTabItems(event) 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 98aefba09..a7b653932 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -156,8 +156,8 @@ object MItems { ::MATTER_SCANNER, ::MATTER_PANEL, ::MATTER_REPLICATOR, ::MATTER_BOTTLER, ::ENERGY_COUNTER, ::CHEMICAL_GENERATOR, ::MATTER_RECYCLER, ::PLATE_PRESS, ::TWIN_PLATE_PRESS, ::POWERED_FURNACE, ::POWERED_BLAST_FURNACE, ::POWERED_SMOKER, - // ::STORAGE_BUS, ::STORAGE_IMPORTER, ::STORAGE_EXPORTER, ::DRIVE_VIEWER, - // ::DRIVE_RACK, ::ITEM_MONITOR, ::STORAGE_CABLE, ::STORAGE_POWER_SUPPLIER, + ::STORAGE_BUS, ::STORAGE_IMPORTER, ::STORAGE_EXPORTER, ::DRIVE_VIEWER, + ::DRIVE_RACK, ::ITEM_MONITOR, ::STORAGE_CABLE, ::STORAGE_POWER_SUPPLIER, ::ENERGY_SERVO, ::PHANTOM_ATTRACTOR, ::GRAVITATION_STABILIZER, ::COBBLESTONE_GENERATOR, ::INFINITE_WATER_SOURCE, ::ESSENCE_STORAGE, ::MATTER_RECONSTRUCTOR diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/API.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/API.kt index 8c5b0953a..c9f82926f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/API.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/API.kt @@ -121,6 +121,10 @@ interface IStorageProvider> : IStorageEventProducer { * @return copy of object, with amount of units actually extracted */ fun extractStack(id: UUID, amount: BigInteger, simulate: Boolean): T + + fun extractStack(id: T, amount: BigInteger, simulate: Boolean): T { + return extractStack(get(id) ?: return storageType.empty, amount, simulate) + } } /** 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 a76046db9..260ca07bc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/ItemStorageStack.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/ItemStorageStack.kt @@ -1,7 +1,10 @@ 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.getValue +import ru.dbotthepony.mc.otm.core.lazy2 import ru.dbotthepony.mc.otm.core.math.toIntSafe import java.math.BigInteger @@ -43,6 +46,8 @@ class ItemStorageStack private constructor(private val stack: ItemStack, count: override val isEmpty: Boolean = stack.isEmpty || super.isEmpty override val maxStackSize: BigInteger = BigInteger.valueOf(stack.maxStackSize.toLong()) + val hoverName: Component by lazy2({ toItemStack().hoverName }, { copy() }) + fun toItemStack(count: Int = this.count.toIntSafe()): ItemStack { return stack.copyWithCount(count) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/StorageStack.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/StorageStack.kt index 501ff399b..75081b50e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/StorageStack.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/StorageStack.kt @@ -63,9 +63,19 @@ abstract class StorageStack>(val count: BigInteger) { fun read(buff: FriendlyByteBuf): T fun write(buff: FriendlyByteBuf, value: T) - fun energyPerUpkeep(stack: T): Decimal = Decimal.ZERO + /** + * If there is not enough energy for operation, it is completely cancelled + */ fun energyPerInsert(stack: T): Decimal = energyPerOperation(stack) + + /** + * If there is not enough energy for operation, it is completely cancelled + */ fun energyPerExtract(stack: T): Decimal = energyPerOperation(stack) + + /** + * If there is not enough energy for operation, it is completely cancelled + */ fun energyPerOperation(stack: T): Decimal } @@ -113,7 +123,7 @@ abstract class StorageStack>(val count: BigInteger) { ItemStorageStack.unsafe(it.readItem(), it.readBigInteger()) }, { buff, v -> - buff.writeItem(v.toItemStack()) + buff.writeItem(v.toItemStack(1)) buff.writeBigInteger(v.count) } ) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/VirtualComponent.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/VirtualComponent.kt index 2742d6b09..62805ae1b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/VirtualComponent.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/VirtualComponent.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.storage import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.ObjectArraySet +import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet import ru.dbotthepony.mc.otm.core.math.isPositive import ru.dbotthepony.mc.otm.core.math.isZero import java.math.BigInteger @@ -41,23 +42,19 @@ class LocalTuple>(override var stack: T, override val id: UU } } -open class VirtualComponent>(override val storageType: StorageStack.Type) : IVirtualStorageComponent { +class VirtualComponent>(override val storageType: StorageStack.Type) : IVirtualStorageComponent { // удаленный UUID -> Кортеж - protected val remoteTuples = Object2ObjectOpenHashMap>() + private val remoteTuples = Object2ObjectOpenHashMap>() // локальный UUID -> Локальный кортеж - protected val localTuples = Object2ObjectOpenHashMap>() + private val localTuples = Object2ObjectOpenHashMap>() // Стак -> Локальный кортеж стака - protected val item2tuple = Object2ObjectOpenCustomHashMap>(StorageStack.Companion) + private val item2tuple = Object2ObjectOpenCustomHashMap>(StorageStack.Companion) - // ArrayList для скорости работы - protected val listeners: MutableSet> = ObjectArraySet() - protected val children: MutableSet> = ObjectArraySet() - protected val consumers: MutableSet> = ObjectArraySet() - - protected open fun onAdd(identity: IStorage) {} - protected open fun onRemove(identity: IStorage) {} + private val listeners = ObjectLinkedOpenHashSet>() + private val children = ObjectLinkedOpenHashSet>() + private val consumers = ObjectLinkedOpenHashSet>() override fun add(identity: IStorage) { require(identity.storageType == storageType) { "Attempt to add component of type ${identity.storageType} to virtual component of type $storageType" } @@ -76,8 +73,6 @@ open class VirtualComponent>(override val storageType: Stora if (identity is IStorageAcceptor) { consumers.add(identity) } - - onAdd(identity) } } @@ -98,8 +93,6 @@ open class VirtualComponent>(override val storageType: Stora if (identity is IStorageAcceptor) { consumers.remove(identity) } - - onRemove(identity) } } @@ -231,4 +224,8 @@ open class VirtualComponent>(override val storageType: Stora return this.storageType.empty } + + override fun toString(): String { + return "VirtualComponent[$storageType; listeners: ${listeners.size}; size: ${localTuples.size}]" + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredComponent.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredComponent.kt index eb5f65ab8..6fe2403f0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredComponent.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredComponent.kt @@ -13,4 +13,16 @@ class PoweredComponent>( ) : IStorageComponent, IStorageProvider by PoweredStorageProvider(parent, energy), IStorageAcceptor by PoweredStorageAcceptor(parent, energy) { override val storageType: StorageStack.Type get() = parent.storageType + + override fun equals(other: Any?): Boolean { + return other is PoweredComponent<*> && parent == other.parent + } + + override fun hashCode(): Int { + return parent.hashCode() + } + + override fun toString(): String { + return "PoweredComponent[$parent]" + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredStorageAcceptor.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredStorageAcceptor.kt index c058020c7..bc856176a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredStorageAcceptor.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredStorageAcceptor.kt @@ -6,6 +6,18 @@ import ru.dbotthepony.mc.otm.storage.StorageStack import java.util.function.Supplier class PoweredStorageAcceptor>(val parent: IStorageAcceptor, val energy: Supplier) : IStorageAcceptor by parent { + override fun equals(other: Any?): Boolean { + return other is PoweredStorageAcceptor<*> && parent == other.parent + } + + override fun hashCode(): Int { + return parent.hashCode() + } + + override fun toString(): String { + return "PoweredStorageAcceptor[$parent]" + } + override fun insertStack(stack: T, simulate: Boolean): T { val leftover = parent.insertStack(stack, true) if (leftover == stack) return stack diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredStorageProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredStorageProvider.kt index bae9d933d..417b3ffdf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredStorageProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredStorageProvider.kt @@ -1,6 +1,10 @@ package ru.dbotthepony.mc.otm.storage.powered +import it.unimi.dsi.fastutil.HashCommon.mix +import it.unimi.dsi.fastutil.objects.ObjectArraySet +import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage +import ru.dbotthepony.mc.otm.storage.IStorageEventConsumer import ru.dbotthepony.mc.otm.storage.IStorageProvider import ru.dbotthepony.mc.otm.storage.StorageStack import java.math.BigInteger @@ -8,8 +12,57 @@ import java.util.* import java.util.function.Supplier class PoweredStorageProvider>(val parent: IStorageProvider, val energy: Supplier) : IStorageProvider by parent { + override fun equals(other: Any?): Boolean { + return other is PoweredStorageProvider<*> && other.parent == parent + } + + override fun hashCode(): Int { + return parent.hashCode() + } + + override fun toString(): String { + return "PoweredStorageProvider[$parent]" + } + + private class Proxy>(private val parent: IStorageEventConsumer, private val powered: PoweredStorageProvider) : IStorageEventConsumer { + override val storageType: StorageStack.Type + get() = parent.storageType + + override fun onStackAdded(stack: T, id: UUID, provider: IStorageProvider) { + parent.onStackAdded(stack, id, powered) + } + + override fun onStackChanged(stack: T, id: UUID) { + parent.onStackChanged(stack, id) + } + + override fun onStackRemoved(id: UUID) { + parent.onStackRemoved(id) + } + + override fun toString(): String { + return "PoweredStorageProvider.Proxy[$parent with $powered]" + } + + override fun equals(other: Any?): Boolean { + return other is Proxy<*> && parent == other.parent && powered == other.powered + } + + override fun hashCode(): Int { + return mix(parent.hashCode() * 31 + powered.hashCode()) + } + } + + override fun addListener(listener: IStorageEventConsumer): Boolean { + return parent.addListener(Proxy(listener, this)) + } + + override fun removeListener(listener: IStorageEventConsumer): Boolean { + return parent.removeListener(Proxy(listener, this)) + } + override fun extractStack(id: UUID, amount: BigInteger, simulate: Boolean): T { - val extracted = parent.extractStack(id, amount, simulate) + val extracted = parent.extractStack(id, amount, true) if (extracted.isEmpty) return extracted val energy = energy.get() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredVirtualComponent.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredVirtualComponent.kt index 5f2391019..9975847cf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredVirtualComponent.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredVirtualComponent.kt @@ -16,6 +16,18 @@ class PoweredVirtualComponent>( ) : IVirtualStorageComponent, IStorageComponent by PoweredComponent(parent, energy) { constructor(type: StorageStack.Type, energy: Supplier) : this(VirtualComponent(type), energy) + override fun equals(other: Any?): Boolean { + return other is PoweredVirtualComponent<*> && parent == other.parent + } + + override fun hashCode(): Int { + return parent.hashCode() + } + + override fun toString(): String { + return "PoweredVirtualComponent[$parent]" + } + override fun onStackAdded(stack: T, id: UUID, provider: IStorageProvider) = parent.onStackAdded(stack, id, provider) override fun onStackChanged(stack: T, id: UUID) = parent.onStackChanged(stack, id) override fun onStackRemoved(id: UUID) = parent.onStackRemoved(id) From 834b05a697c0bb1421c117ded0bd2131a51f27d3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 10 Aug 2023 13:15:43 +0700 Subject: [PATCH 0949/1199] Fix very obscure (undetected by HashSet) concurrent modification --- .../block/entity/storage/StorageInterfaces.kt | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt index e5348811e..2a5db7efc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.block.entity.storage +import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet import net.minecraft.core.BlockPos import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory @@ -39,6 +40,7 @@ import ru.dbotthepony.mc.otm.storage.StorageStack import java.math.BigInteger import java.util.* import java.util.stream.Stream +import kotlin.collections.ArrayList abstract class AbstractStorageImportExport( blockType: BlockEntityType<*>, @@ -235,7 +237,7 @@ class StorageExporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : return StorageExporterMenu(containerID, inventory, this) } - private val relevantTuples = HashSet() + private val relevantTuples = ObjectOpenHashSet() override val storageType: StorageStack.Type get() = StorageStack.ITEMS @@ -280,12 +282,6 @@ class StorageExporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : override val targetCapability: Capability get() = ForgeCapabilities.ITEM_HANDLER - private val exportStacks: Stream> - get() { - val view = cell.graph.getVirtualComponent(StorageStack.ITEMS) - return relevantTuples.stream().map { it to view[it] } - } - override fun tick() { super.tick() @@ -305,16 +301,16 @@ class StorageExporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : lastSlot = 0 } - val any = exportStacks.anyMatch { - val (id, stack) = it + val any = ArrayList(relevantTuples).any { id -> + val stack = items[id] - if (!target.isItemValid(lastSlot, stack.toItemStack())) return@anyMatch false + if (stack.isEmpty || !target.isItemValid(lastSlot, stack.toItemStack())) return@any false val extracted = items.extractStack(id, stack.count.coerceAtMost(MAX_MOVE_PER_OPERATION), true) - if (extracted.isEmpty) return@anyMatch false + if (extracted.isEmpty) return@any false val required = StorageStack.ITEMS.energyPerOperation(extracted) - if (energy.extractEnergy(required, true) != required) return@anyMatch false + if (energy.extractEnergy(required, true) != required) return@any false val toInsert = extracted.toItemStack() val leftover = target.insertItem(lastSlot, toInsert, true) From 62fdff4a343f3871db878b8b599e6d37d27deaf8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 10 Aug 2023 16:39:07 +0700 Subject: [PATCH 0950/1199] Fix hasExopack change does not invalidate current exopack menu --- .../ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 61eefa3a2..b77723d34 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -210,6 +210,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial */ var hasExopack by publicSynchronizer.bool(setter = setter@{ value, access, _ -> access.write(value) + _exoPackMenu = null if (value && ply is ServerPlayer) { tickList.once { From abe82d456c154c5872f7702ff1560f0a118eb7f1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 10 Aug 2023 17:30:21 +0700 Subject: [PATCH 0951/1199] Fix computed int not returning proper value clientside --- .../mc/otm/network/synchronizer/FieldSynchronizer.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt index 523b28c8b..dc52d38c9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt @@ -1309,6 +1309,8 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa private var isRemoteSet = false protected var clientValue: Int = 0 set(value) { + isClientValue = true + if (field != value) { field = value subs.accept(value) From 5784b3346fa327ff34ea5dbc00d4d69b5efba893 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 10 Aug 2023 17:36:07 +0700 Subject: [PATCH 0952/1199] More precise filters in textinputpanel --- .../screen/panels/input/TextInputPanel.kt | 86 +++++++++++++++---- 1 file changed, 71 insertions(+), 15 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt index ad74f87d4..c88a4eec4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt @@ -27,8 +27,11 @@ import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.addAll +import ru.dbotthepony.mc.otm.core.collect.mapToInt +import ru.dbotthepony.mc.otm.core.collect.reduce import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.milliTime +import java.util.function.Predicate import kotlin.math.roundToInt open class TextInputPanel( @@ -179,7 +182,7 @@ open class TextInputPanel( textCache = null val old = oldText.joinToString("\n") oldText = ArrayList(lines) - onTextChanged(old, textCache()) + onTextChanged(textCache(), old) } } @@ -650,8 +653,10 @@ open class TextInputPanel( return true } - open fun onEnter() { + var onEnter: Runnable? = null + open fun onEnter() { + onEnter?.run() } override fun keyPressedInternal(key: Int, scancode: Int, mods: Int): Boolean { @@ -899,7 +904,8 @@ open class TextInputPanel( pushbackSnapshot() if (multiLine) { - val insert = minecraft.keyboardHandler.clipboard.replace("\t", " ").filter { acceptsCharacter(it) }.split(NEWLINES).toMutableList() + var index = cursorRow + (0 until cursorLine).iterator().mapToInt { this[it]?.length ?: 0 }.reduce(0, Int::plus) + val insert = minecraft.keyboardHandler.clipboard.replace("\t", " ").filter { acceptsCharacter(it, 0, index++) }.split(NEWLINES).toMutableList() val actualLastSize = insert.lastOrNull()?.length ?: 0 val line = this[cursorLine] @@ -938,7 +944,8 @@ open class TextInputPanel( cursorRow = actualLastSize } } else { - val insert = minecraft.keyboardHandler.clipboard.replace("\t", " ").replace(NEWLINES, "").filter { acceptsCharacter(it) } + var index = cursorRow + (0 until cursorLine).iterator().mapToInt { this[it]?.length ?: 0 }.reduce(0, Int::plus) + val insert = minecraft.keyboardHandler.clipboard.replace("\t", " ").replace(NEWLINES, "").filter { acceptsCharacter(it, 0, index++) } val line = this[cursorLine] if (line == null) { @@ -1017,8 +1024,38 @@ open class TextInputPanel( return true } - open fun acceptsCharacter(codepoint: Char, mods: Int = 0): Boolean { - return true + fun interface CharacterFilter : Predicate { + fun acceptsCharacter(codepoint: Char, mods: Int, index: Int): Boolean + + override fun test(t: Char): Boolean { + return acceptsCharacter(t, 0, 0) + } + } + + var characterFilter: CharacterFilter? = null + + fun allowEverything() { + characterFilter = null + } + + fun allowNumbersAndSign() { + characterFilter = CharacterFilter { it, _, i -> if (i == 0) it in SIGNS || it in NUMBERS else it in NUMBERS } + } + + fun allowNumbers() { + characterFilter = CharacterFilter { it, _, _ -> it in NUMBERS } + } + + fun allowHexNumbersAndSign() { + characterFilter = CharacterFilter { it, _, i -> if (i == 0) it in SIGNS || it in HEX else it in HEX } + } + + fun allowHexNumbers() { + characterFilter = CharacterFilter { it, _, _ -> it in HEX } + } + + open fun acceptsCharacter(codepoint: Char, mods: Int = 0, index: Int): Boolean { + return characterFilter?.acceptsCharacter(codepoint, mods, index) ?: true } override fun charTypedInternal(codepoint: Char, mods: Int): Boolean { @@ -1027,11 +1064,6 @@ open class TextInputPanel( return true } - if (!acceptsCharacter(codepoint, mods)) { - playGuiClickSound() - return true - } - wipeSelection() if (!multiLine) @@ -1045,6 +1077,15 @@ open class TextInputPanel( cursorRow = 0 } + var index = 0 + for (i in 0 until cursorLine) index += this[i]?.length ?: 0 + index += cursorRow + + if (!acceptsCharacter(codepoint, mods, index)) { + playGuiClickSound() + return true + } + if (cursorRow >= line.length) line += codepoint else @@ -1349,13 +1390,13 @@ open class TextInputPanel( return true } - protected open fun onTextChanged(old: String, new: String) { - changeCallback?.invoke(old, new) + protected open fun onTextChanged(new: String, old: String) { + changeCallback?.invoke(new, old) } - protected var changeCallback: ((old: String, new: String) -> Unit)? = null + protected var changeCallback: ((new: String, old: String) -> Unit)? = null - fun onTextChange(callback: (old: String, new: String) -> Unit) { + fun onTextChange(callback: (new: String, old: String) -> Unit) { changeCallback = callback } @@ -1420,6 +1461,21 @@ open class TextInputPanel( it.add(char) } + private val NUMBERS = CharOpenHashSet().also { + for (char in "0123456789-+") + it.add(char) + } + + private val SIGNS = CharOpenHashSet().also { + for (char in "-+") + it.add(char) + } + + private val HEX = CharOpenHashSet().also { + for (char in "0123456789ABCDEFabcdef") + it.add(char) + } + private fun greedyAdvanceLeft(input: String, position: Int): Int { if (position <= 1) return -1 From b3249cdcd7c39a7b49e6a343ba7e9068ebda35e6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 10 Aug 2023 17:36:31 +0700 Subject: [PATCH 0953/1199] Insert and extract priorities in storage system --- .../entity/storage/DriveRackBlockEntity.kt | 32 +++++--- .../entity/storage/StorageBusBlockEntity.kt | 19 +++++ .../client/screen/storage/StorageBusScreen.kt | 23 ++++++ .../mc/otm/menu/input/IntInputWithFeedback.kt | 31 ++++++++ .../mc/otm/menu/storage/StorageBusMenu.kt | 14 ++-- .../ru/dbotthepony/mc/otm/storage/API.kt | 42 +++++++++- .../mc/otm/storage/VirtualComponent.kt | 15 +++- .../mc/otm/storage/optics/ExtractPriority.kt | 31 ++++++++ .../mc/otm/storage/optics/InsertPriority.kt | 22 ++++++ .../mc/otm/storage/optics/ListenerProxy.kt | 29 +++++++ .../mc/otm/storage/optics/ModifyPriority.kt | 28 +++++++ .../mc/otm/storage/optics/Optics.kt | 78 +++++++++++++++++++ .../otm/storage/powered/PoweredComponent.kt | 3 + .../storage/powered/PoweredStorageProvider.kt | 37 +-------- 14 files changed, 351 insertions(+), 53 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/IntInputWithFeedback.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/ExtractPriority.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/InsertPriority.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/ListenerProxy.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/ModifyPriority.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/Optics.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt index c2711da3e..4b405990f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt @@ -10,33 +10,41 @@ import net.minecraft.world.level.block.state.BlockState import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.graph.storage.StorageNode import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.capability.drive.IMatteryDrive import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.MatteryContainer +import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.menu.storage.DriveRackMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities -import ru.dbotthepony.mc.otm.storage.* -import ru.dbotthepony.mc.otm.storage.powered.PoweredComponent -import ru.dbotthepony.mc.otm.storage.powered.PoweredVirtualComponent +import ru.dbotthepony.mc.otm.storage.optics.priority +import ru.dbotthepony.mc.otm.storage.optics.powered class DriveRackBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.DRIVE_RACK, blockPos, blockState) { val energy = WorkerEnergyStorage(this::setChangedLight, MachinesConfig.DRIVE_RACK) val cell = StorageNode(energy) + var insertPriority = 0 + set(value) { + field = value + setChangedLight() + } + + var extractPriority = 0 + set(value) { + field = value + setChangedLight() + } + val container: MatteryContainer = object : MatteryContainer(this::setChanged, 4) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { super.setChanged(slot, new, old) - // generics is going apeshit since storage types are invariant, - // but since we don't know generics of upvalue mattery drive, its storage type - // is defined as out variant - old.getCapability(MatteryCapability.DRIVE).ifPresent { - cell.removeStorageComponent(PoweredComponent(it, ::energy)) + old.getCapability(MatteryCapability.DRIVE).ifPresentK { + cell.removeStorageComponent(it.priority(::insertPriority, ::extractPriority).powered(energy)) } - new.getCapability(MatteryCapability.DRIVE).ifPresent { - cell.addStorageComponent(PoweredComponent(it, ::energy)) + new.getCapability(MatteryCapability.DRIVE).ifPresentK { + cell.addStorageComponent(it.priority(::insertPriority, ::extractPriority).powered(energy)) } } }.also(::addDroppableContainer) @@ -46,6 +54,8 @@ class DriveRackBlockEntity(blockPos: BlockPos, blockState: BlockState) : Mattery savetable(::container, INVENTORY_KEY) exposeEnergyGlobally(energy) exposeGlobally(MatteryCapability.STORAGE_NODE, cell) + savetables.int(::insertPriority) + savetables.int(::extractPriority) } override fun setLevel(level: Level) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt index 0071f5dbc..3604c5111 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt @@ -81,9 +81,23 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter private var component: ItemHandlerComponent? = null + var insertPriority = 0 + set(value) { + field = value + setChangedLight() + } + + var extractPriority = 0 + set(value) { + field = value + setChangedLight() + } + init { exposeEnergyGlobally(energy) savetable(::energy, ENERGY_KEY) + savetables.int(::insertPriority) + savetables.int(::extractPriority) exposeGlobally(MatteryCapability.STORAGE_NODE, cell) { it != RelativeSide.FRONT } side(RelativeSide.FRONT).track(ForgeCapabilities.ITEM_HANDLER).addListener { @@ -213,6 +227,11 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter private val listeners = ArrayList>() + override val insertPriority: Int + get() = this@StorageBusBlockEntity.insertPriority + override val extractPriority: Int + get() = this@StorageBusBlockEntity.extractPriority + override fun addListener(listener: IStorageEventConsumer): Boolean { if (!listeners.contains(listener)) { listeners.add(listener) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt index 17eddc453..8cfff6a10 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt @@ -7,6 +7,7 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.button.CheckBoxLabelInputPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls +import ru.dbotthepony.mc.otm.client.screen.panels.input.TextInputPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.FilterSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel @@ -31,6 +32,28 @@ class StorageBusScreen(menu: StorageBusMenu, inventory: Inventory, title: Compon makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig) + /*object : TextInputPanel(this@StorageBusScreen, frame) { + init { + allowNumbersAndSign() + dock = Dock.BOTTOM + } + + override fun tickInner() { + super.tickInner() + + if (!hasHierarchicalFocus()) { + text = menu.insertPriority.value.toString() + } + } + + override fun onTextChanged(new: String, old: String) { + if (hasHierarchicalFocus()) { + val i = new.toIntOrNull() + if (i != null) menu.insertPriority.accept(i) + } + } + }*/ + return frame } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/IntInputWithFeedback.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/IntInputWithFeedback.kt new file mode 100644 index 000000000..5f1e9bfcd --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/IntInputWithFeedback.kt @@ -0,0 +1,31 @@ +package ru.dbotthepony.mc.otm.menu.input + +import ru.dbotthepony.mc.otm.core.GetterSetter +import ru.dbotthepony.mc.otm.menu.MatteryMenu +import java.util.function.IntSupplier +import kotlin.reflect.KMutableProperty0 + +class IntInputWithFeedback(menu: MatteryMenu, allowSpectators: Boolean = false) : AbstractPlayerInputWithFeedback() { + override val input = menu.intInput(allowSpectators) { consumer?.invoke(it) } + override val field = menu.mSynchronizer.computedInt(IntSupplier { supplier?.invoke() ?: 0 }) + + constructor(menu: MatteryMenu, allowSpectators: Boolean, state: KMutableProperty0?) : this(menu, allowSpectators) { + if (state != null) + with(state) + } + + constructor(menu: MatteryMenu, allowSpectators: Boolean, state: GetterSetter?) : this(menu, allowSpectators) { + if (state != null) + with(state) + } + + constructor(menu: MatteryMenu, state: KMutableProperty0?) : this(menu) { + if (state != null) + with(state) + } + + constructor(menu: MatteryMenu, state: GetterSetter?) : this(menu) { + if (state != null) + with(state) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageBusMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageBusMenu.kt index f7a918788..e35fa3867 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageBusMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageBusMenu.kt @@ -1,30 +1,34 @@ package ru.dbotthepony.mc.otm.menu.storage import net.minecraft.world.entity.player.Inventory -import net.minecraft.world.inventory.Slot import ru.dbotthepony.mc.otm.block.entity.storage.StorageBusBlockEntity import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.IntInputWithFeedback import ru.dbotthepony.mc.otm.registry.MMenus class StorageBusMenu @JvmOverloads constructor( - p_38852_: Int, + containerId: Int, inventory: Inventory, tile: StorageBusBlockEntity? = null -) : MatteryPoweredMenu( - MMenus.STORAGE_BUS, p_38852_, inventory, tile -) { +) : MatteryPoweredMenu(MMenus.STORAGE_BUS, containerId, inventory, tile) { val busFilterSlots: List val busFilterState: BooleanInputWithFeedback + val insertPriority: IntInputWithFeedback + val extractPriority: IntInputWithFeedback init { if (tile != null) { busFilterSlots = addFilterSlots(tile.filter) busFilterState = BooleanInputWithFeedback(this, tile.filter::isWhitelist) + insertPriority = IntInputWithFeedback(this, tile::insertPriority) + extractPriority = IntInputWithFeedback(this, tile::extractPriority) } else { busFilterSlots = addFilterSlots(StorageBusBlockEntity.MAX_FILTERS) busFilterState = BooleanInputWithFeedback(this) + insertPriority = IntInputWithFeedback(this) + extractPriority = IntInputWithFeedback(this) } addStorageSlot(batterySlot) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/API.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/API.kt index c9f82926f..4c4d9a099 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/API.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/API.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.storage import java.math.BigInteger import java.util.* import java.util.stream.Stream +import kotlin.Comparator /** * Storage system root, along IStorageStack interface @@ -70,6 +71,14 @@ interface IStorageAcceptor> : IStorage { * @return leftover, might equal to [stack] if no items were inserted */ fun insertStack(stack: T, simulate: Boolean): T + + val insertPriority: Int get() = 0 + + companion object : Comparator> { + override fun compare(o1: IStorageAcceptor<*>, o2: IStorageAcceptor<*>): Int { + return o2.insertPriority.compareTo(o1.insertPriority) + } + } } /** @@ -125,12 +134,43 @@ interface IStorageProvider> : IStorageEventProducer { fun extractStack(id: T, amount: BigInteger, simulate: Boolean): T { return extractStack(get(id) ?: return storageType.empty, amount, simulate) } + + val extractPriority: Int get() = 0 + + companion object : Comparator> { + override fun compare(o1: IStorageProvider<*>, o2: IStorageProvider<*>): Int { + return o2.extractPriority.compareTo(o1.extractPriority) + } + } } /** * Storage component, which basically implement Input and Output */ -interface IStorageComponent> : IStorageProvider, IStorageAcceptor +interface IStorageComponent> : IStorageProvider, IStorageAcceptor { + class C>(private val provider: IStorageProvider, private val acceptor: IStorageAcceptor) : IStorageComponent, IStorageProvider by provider, IStorageAcceptor by acceptor { + constructor(acceptor: IStorageAcceptor, provider: IStorageProvider) : this(provider, acceptor) + + init { + require(provider.storageType == acceptor.storageType) { "Provider and Accept have different storage types: ${provider.storageType} != ${acceptor.storageType}" } + } + + override val storageType: StorageStack.Type + get() = provider.storageType + + override fun equals(other: Any?): Boolean { + return other is C<*> && provider == other.provider && acceptor == other.acceptor + } + + override fun hashCode(): Int { + return (provider.hashCode() * 31) xor acceptor.hashCode() + } + + override fun toString(): String { + return "IStorageComponent[$provider; $acceptor]" + } + } +} interface IStorageTuple> { val id: UUID diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/VirtualComponent.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/VirtualComponent.kt index 62805ae1b..a363a609f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/VirtualComponent.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/VirtualComponent.kt @@ -1,7 +1,10 @@ package ru.dbotthepony.mc.otm.storage +import it.unimi.dsi.fastutil.ints.Int2ObjectAVLTreeMap import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap +import it.unimi.dsi.fastutil.objects.ObjectAVLTreeSet +import it.unimi.dsi.fastutil.objects.ObjectArrayList import it.unimi.dsi.fastutil.objects.ObjectArraySet import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet import ru.dbotthepony.mc.otm.core.math.isPositive @@ -16,7 +19,11 @@ class RemoteTuple>( override val id: UUID, val parent: IStorageProvider, val local: LocalTuple -) : IStorageTuple { +) : IStorageTuple, Comparable> { + override fun compareTo(other: RemoteTuple): Int { + return parent.extractPriority.compareTo(other.parent.extractPriority) + } + fun extract(amount: BigInteger, simulate: Boolean): T { return parent.extractStack(id, amount, simulate) } @@ -181,6 +188,8 @@ class VirtualComponent>(override val storageType: StorageSta override fun insertStack(stack: T, simulate: Boolean): T { var leftover = stack + val consumers = ObjectArrayList(consumers) + consumers.sortWith(IStorageAcceptor.Companion) for (consumer in consumers) { leftover = consumer.insertStack(leftover, simulate) @@ -210,8 +219,10 @@ class VirtualComponent>(override val storageType: StorageSta val toExtract = tuple.stack.count.coerceAtMost(amount) var extracted = BigInteger.ZERO val copy = tuple.stack + val tuples = ArrayList(tuple.tuples) + tuples.sort() - for (remote in ArrayList(tuple.tuples)) { + for (remote in tuples) { extracted += remote.extract(toExtract - extracted, simulate).count if (extracted >= toExtract) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/ExtractPriority.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/ExtractPriority.kt new file mode 100644 index 000000000..f92b8030b --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/ExtractPriority.kt @@ -0,0 +1,31 @@ +package ru.dbotthepony.mc.otm.storage.optics + +import ru.dbotthepony.mc.otm.storage.IStorageEventConsumer +import ru.dbotthepony.mc.otm.storage.IStorageProvider +import ru.dbotthepony.mc.otm.storage.StorageStack +import java.util.function.IntSupplier + +class ExtractPriority>(private val parent: IStorageProvider, private val priority: IntSupplier) : IStorageProvider by parent { + override val extractPriority: Int + get() = priority.asInt + + override fun addListener(listener: IStorageEventConsumer): Boolean { + return parent.addListener(ListenerProxy(listener, this)) + } + + override fun removeListener(listener: IStorageEventConsumer): Boolean { + return parent.removeListener(ListenerProxy(listener, this)) + } + + override fun equals(other: Any?): Boolean { + return other is ExtractPriority<*> && parent == other.parent + } + + override fun hashCode(): Int { + return parent.hashCode() + } + + override fun toString(): String { + return "ExtractPriority[$parent with $priority]" + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/InsertPriority.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/InsertPriority.kt new file mode 100644 index 000000000..e98b35f2f --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/InsertPriority.kt @@ -0,0 +1,22 @@ +package ru.dbotthepony.mc.otm.storage.optics + +import ru.dbotthepony.mc.otm.storage.IStorageAcceptor +import ru.dbotthepony.mc.otm.storage.StorageStack +import java.util.function.IntSupplier + +class InsertPriority>(private val parent: IStorageAcceptor, private val priority: IntSupplier) : IStorageAcceptor by parent { + override val insertPriority: Int + get() = priority.asInt + + override fun equals(other: Any?): Boolean { + return other is InsertPriority<*> && parent == other.parent + } + + override fun hashCode(): Int { + return parent.hashCode() + } + + override fun toString(): String { + return "InsertPriority[$parent with $priority]" + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/ListenerProxy.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/ListenerProxy.kt new file mode 100644 index 000000000..ffca4ea33 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/ListenerProxy.kt @@ -0,0 +1,29 @@ +package ru.dbotthepony.mc.otm.storage.optics + +import it.unimi.dsi.fastutil.HashCommon +import ru.dbotthepony.mc.otm.storage.IStorageEventConsumer +import ru.dbotthepony.mc.otm.storage.IStorageProvider +import ru.dbotthepony.mc.otm.storage.StorageStack +import java.util.* + +class ListenerProxy>(private val consumer: IStorageEventConsumer, private val provider: IStorageProvider) : IStorageEventConsumer by consumer { + init { + require(consumer.storageType == provider.storageType) { "Consumer storage type does not match provider's: ${consumer.storageType} != ${provider.storageType}" } + } + + override fun onStackAdded(stack: T, id: UUID, provider: IStorageProvider) { + consumer.onStackAdded(stack, id, this.provider) + } + + override fun toString(): String { + return "ListenerProxy[$consumer from $provider]" + } + + override fun equals(other: Any?): Boolean { + return other is ListenerProxy<*> && consumer == other.consumer && provider == other.provider + } + + override fun hashCode(): Int { + return HashCommon.mix(consumer.hashCode() * 31 + provider.hashCode()) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/ModifyPriority.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/ModifyPriority.kt new file mode 100644 index 000000000..97a1f6a5a --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/ModifyPriority.kt @@ -0,0 +1,28 @@ +package ru.dbotthepony.mc.otm.storage.optics + +import ru.dbotthepony.mc.otm.storage.IStorageAcceptor +import ru.dbotthepony.mc.otm.storage.IStorageComponent +import ru.dbotthepony.mc.otm.storage.IStorageProvider +import ru.dbotthepony.mc.otm.storage.StorageStack +import java.util.function.IntSupplier + +class ModifyPriority>( + private val parent: IStorageComponent, + insertPriority: IntSupplier, + extractPriority: IntSupplier +) : IStorageComponent, IStorageAcceptor by InsertPriority(parent, insertPriority), IStorageProvider by ExtractPriority(parent, extractPriority) { + override fun equals(other: Any?): Boolean { + return other is ModifyPriority<*> && parent == other.parent + } + + override fun hashCode(): Int { + return parent.hashCode() + } + + override fun toString(): String { + return "ModifyPriority[$parent with $insertPriority and $extractPriority]" + } + + override val storageType: StorageStack.Type + get() = parent.storageType +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/Optics.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/Optics.kt new file mode 100644 index 000000000..b76371daf --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/Optics.kt @@ -0,0 +1,78 @@ +package ru.dbotthepony.mc.otm.storage.optics + +import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage +import ru.dbotthepony.mc.otm.storage.IStorageAcceptor +import ru.dbotthepony.mc.otm.storage.IStorageComponent +import ru.dbotthepony.mc.otm.storage.IStorageProvider +import ru.dbotthepony.mc.otm.storage.IVirtualStorageComponent +import ru.dbotthepony.mc.otm.storage.StorageStack +import ru.dbotthepony.mc.otm.storage.powered.PoweredComponent +import ru.dbotthepony.mc.otm.storage.powered.PoweredStorageAcceptor +import ru.dbotthepony.mc.otm.storage.powered.PoweredStorageProvider +import ru.dbotthepony.mc.otm.storage.powered.PoweredVirtualComponent +import java.util.function.IntSupplier +import java.util.function.Supplier + +fun > IStorageAcceptor.insertPriority(priority: IntSupplier): IStorageAcceptor { + return InsertPriority(this, priority) +} + +fun > IStorageAcceptor.insertPriority(priority: Int): IStorageAcceptor { + return InsertPriority(this) { priority } +} + +fun > IStorageProvider.extractPriority(priority: IntSupplier): IStorageProvider { + return ExtractPriority(this, priority) +} + +fun > IStorageProvider.extractPriority(priority: Int): IStorageProvider { + return ExtractPriority(this) { priority } +} + +fun > IStorageComponent.priority(priority: IntSupplier): IStorageComponent { + return ModifyPriority(this, priority, priority) +} + +fun > IStorageComponent.priority(priority: Int): IStorageComponent { + return ModifyPriority(this, { priority }, { priority }) +} + +fun > IStorageComponent.priority(insertPriority: IntSupplier, extractPriority: IntSupplier): IStorageComponent { + return ModifyPriority(this, insertPriority, extractPriority) +} + +fun > IStorageComponent.priority(insertPriority: Int, extractPriority: Int): IStorageComponent { + return ModifyPriority(this, { insertPriority }, { extractPriority }) +} + +fun > IStorageAcceptor.powered(energy: Supplier): IStorageAcceptor { + return PoweredStorageAcceptor(this, energy) +} + +fun > IStorageAcceptor.powered(energy: IMatteryEnergyStorage): IStorageAcceptor { + return PoweredStorageAcceptor(this) { energy } +} + +fun > IStorageProvider.powered(energy: Supplier): IStorageProvider { + return PoweredStorageProvider(this, energy) +} + +fun > IStorageProvider.powered(energy: IMatteryEnergyStorage): IStorageProvider { + return PoweredStorageProvider(this) { energy } +} + +fun > IStorageComponent.powered(energy: Supplier): IStorageComponent { + return PoweredComponent(this, energy) +} + +fun > IStorageComponent.powered(energy: IMatteryEnergyStorage): IStorageComponent { + return PoweredComponent(this) { energy } +} + +fun > IVirtualStorageComponent.powered(energy: Supplier): IVirtualStorageComponent { + return PoweredVirtualComponent(this, energy) +} + +fun > IVirtualStorageComponent.powered(energy: IMatteryEnergyStorage): IVirtualStorageComponent { + return PoweredVirtualComponent(this) { energy } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredComponent.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredComponent.kt index 6fe2403f0..a692bea46 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredComponent.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredComponent.kt @@ -11,6 +11,9 @@ class PoweredComponent>( val parent: IStorageComponent, energy: Supplier ) : IStorageComponent, IStorageProvider by PoweredStorageProvider(parent, energy), IStorageAcceptor by PoweredStorageAcceptor(parent, energy) { + constructor(provider: IStorageProvider, acceptor: IStorageAcceptor, energy: Supplier) : this(IStorageComponent.C(provider, acceptor), energy) + constructor(acceptor: IStorageAcceptor, provider: IStorageProvider, energy: Supplier) : this(IStorageComponent.C(provider, acceptor), energy) + override val storageType: StorageStack.Type get() = parent.storageType diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredStorageProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredStorageProvider.kt index 417b3ffdf..19b3c8850 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredStorageProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/powered/PoweredStorageProvider.kt @@ -1,12 +1,10 @@ package ru.dbotthepony.mc.otm.storage.powered -import it.unimi.dsi.fastutil.HashCommon.mix -import it.unimi.dsi.fastutil.objects.ObjectArraySet -import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.storage.IStorageEventConsumer import ru.dbotthepony.mc.otm.storage.IStorageProvider import ru.dbotthepony.mc.otm.storage.StorageStack +import ru.dbotthepony.mc.otm.storage.optics.ListenerProxy import java.math.BigInteger import java.util.* import java.util.function.Supplier @@ -24,41 +22,12 @@ class PoweredStorageProvider>(val parent: IStorageProvider>(private val parent: IStorageEventConsumer, private val powered: PoweredStorageProvider) : IStorageEventConsumer { - override val storageType: StorageStack.Type - get() = parent.storageType - - override fun onStackAdded(stack: T, id: UUID, provider: IStorageProvider) { - parent.onStackAdded(stack, id, powered) - } - - override fun onStackChanged(stack: T, id: UUID) { - parent.onStackChanged(stack, id) - } - - override fun onStackRemoved(id: UUID) { - parent.onStackRemoved(id) - } - - override fun toString(): String { - return "PoweredStorageProvider.Proxy[$parent with $powered]" - } - - override fun equals(other: Any?): Boolean { - return other is Proxy<*> && parent == other.parent && powered == other.powered - } - - override fun hashCode(): Int { - return mix(parent.hashCode() * 31 + powered.hashCode()) - } - } - override fun addListener(listener: IStorageEventConsumer): Boolean { - return parent.addListener(Proxy(listener, this)) + return parent.addListener(ListenerProxy(listener, this)) } override fun removeListener(listener: IStorageEventConsumer): Boolean { - return parent.removeListener(Proxy(listener, this)) + return parent.removeListener(ListenerProxy(listener, this)) } override fun extractStack(id: UUID, amount: BigInteger, simulate: Boolean): T { From f8c2be4d4c05b6e4727860ca7798041860568ac5 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 12 Aug 2023 01:08:42 +0700 Subject: [PATCH 0954/1199] Storage bus insert/extract priorities configuration, operation mode, small refactorings --- .../mc/otm/datagen/lang/English.kt | 5 + .../mc/otm/datagen/lang/Russian.kt | 5 + .../mc/otm/block/entity/MatteryBlockEntity.kt | 27 ++- .../mc/otm/block/entity/RedstoneControl.kt | 18 +- .../entity/storage/StorageBusBlockEntity.kt | 37 +-- .../entity/tech/PlatePressBlockEntity.kt | 6 +- .../mc/otm/capability/FlowDirection.kt | 5 +- .../mc/otm/client/render/RenderGravity.kt | 53 +++++ .../mc/otm/client/render/WidgetLocation.kt | 2 +- .../mc/otm/client/render/Widgets18.kt | 5 +- .../mc/otm/client/screen/MatteryScreen.kt | 63 +++++ .../otm/client/screen/panels/ColorPicker.kt | 2 +- .../otm/client/screen/panels/EditablePanel.kt | 63 ++++- .../mc/otm/client/screen/panels/Label.kt | 4 +- .../screen/panels/button/ButtonPanel.kt | 4 +- .../panels/input/NetworkedStringInputPanel.kt | 7 +- .../screen/panels/input/NumberInputPanel.kt | 215 ++++++++++++++++++ .../screen/panels/input/TextInputPanel.kt | 8 +- .../client/screen/panels/util/GridPanel.kt | 79 ++++--- .../screen/panels/util/HeightControls.kt | 12 +- .../panels/util/HorizontalStripPanel.kt | 14 +- .../client/screen/storage/StorageBusScreen.kt | 71 +++--- .../mc/otm/container/UpgradeContainer.kt | 11 +- .../dbotthepony/mc/otm/core/ByteSupplier.kt | 5 + .../dbotthepony/mc/otm/core/ShortSupplier.kt | 5 + ...StreamyIterator.kt => StreamyIterators.kt} | 130 +++-------- .../otm/menu/input/EnumInputWithFeedback.kt | 24 +- .../mc/otm/menu/storage/ItemMonitorMenu.kt | 4 +- .../mc/otm/menu/storage/StorageBusMenu.kt | 19 +- .../textures/gui/widgets/storage_controls.png | Bin 847 -> 981 bytes .../textures/gui/widgets/storage_controls.xcf | Bin 5791 -> 7924 bytes 31 files changed, 638 insertions(+), 265 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NumberInputPanel.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/ByteSupplier.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/ShortSupplier.kt rename src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/{StreamyIterator.kt => StreamyIterators.kt} (76%) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 46d65a59f..447e72d02 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -709,6 +709,11 @@ private fun gui(provider: MatteryLanguageProvider) { with(provider.english) { gui("quicksearch", "Quick search...") + gui("insert_priority", "Insert priority") + gui("extract_priority", "Extract priority") + gui("increase", "Increase") + gui("decrease", "Decrease") + gui("color_picker", "Color Picker") gui("color.short.red", "R") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 22f20e08a..206dc139c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -711,6 +711,11 @@ private fun gui(provider: MatteryLanguageProvider) { with(provider.russian) { gui("quicksearch", "Быстрый поиск...") + gui("insert_priority", "Приоритет вставки") + gui("extract_priority", "Приоритет забора") + gui("increase", "Увеличить") + gui("decrease", "Уменьшить") + gui("color_picker", "Выбор цвета") gui("color.short.red", "К") 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 ec716f8fa..7c3b27a5a 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 @@ -44,6 +44,7 @@ import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.isMekanismLoaded import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper import ru.dbotthepony.mc.otm.compat.mekanism.Mekanism2MatteryEnergyWrapper +import ru.dbotthepony.mc.otm.core.ISubscriptable import ru.dbotthepony.mc.otm.core.collect.WeakHashSet import ru.dbotthepony.mc.otm.core.forValidRefs import ru.dbotthepony.mc.otm.core.get @@ -175,9 +176,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } } - interface SideListener : Supplier> { - fun addListener(listener: Consumer>) - } + interface SideListener : Supplier>, ISubscriptable> inner class Side(val side: RelativeSide) { init { @@ -194,17 +193,16 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc set(value) { if (value !== field) { field = value - - for (tracker in listeners) - tracker.accept(value) + listeners.accept(value) } } - private val listeners = ArrayList>>(0) + private val listeners = ISubscriptable.Impl>() - override fun addListener(listener: Consumer>) { - listeners.add(listener) + override fun addListener(listener: Consumer>): ISubscriptable.L { + val l = listeners.addListener(listener) listener.accept(value) + return l } override fun get(): LazyOptional { @@ -234,15 +232,16 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc private val mekanism: SubRef? private var actualMekanism: LazyOptional? = null - private val listeners = ArrayList>>() + private val listeners = ISubscriptable.Impl>() - override fun addListener(listener: Consumer>) { - listeners.add(listener) + override fun addListener(listener: Consumer>): ISubscriptable.L { + val l = listeners.addListener(listener) listener.accept(get()) + return l } init { - regular.addListener { a -> listeners.forEach { it.accept(a) } } + regular.addListener { listeners.accept(it) } if (isMekanismLoaded) { mekanism = track(MatteryCapability.MEKANISM_ENERGY) as SubRef @@ -256,7 +255,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc actualMekanism = null } - listeners.forEach { it.accept(get()) } + listeners.accept(get()) } } else { mekanism = null diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt index 4f311198a..04ff7785f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/RedstoneControl.kt @@ -3,6 +3,8 @@ package ru.dbotthepony.mc.otm.block.entity import it.unimi.dsi.fastutil.booleans.BooleanConsumer import net.minecraft.nbt.CompoundTag import net.minecraftforge.common.util.INBTSerializable +import ru.dbotthepony.mc.otm.core.IBooleanSubscriptable +import ru.dbotthepony.mc.otm.core.ISubscriptable import ru.dbotthepony.mc.otm.core.nbt.mapString import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer @@ -11,15 +13,15 @@ interface IRedstoneControlled { val redstoneControl: AbstractRedstoneControl } -abstract class AbstractRedstoneControl : INBTSerializable { +abstract class AbstractRedstoneControl : INBTSerializable, IBooleanSubscriptable { abstract var redstoneSetting: RedstoneSetting abstract var redstoneSignal: Int - protected val listeners = ArrayList() + protected val listeners = IBooleanSubscriptable.Impl() val isBlockedByRedstone: Boolean get() = !redstoneSetting.test(redstoneSignal) - fun addListener(callback: BooleanConsumer) { - listeners.add(callback) + final override fun addListener(listener: BooleanConsumer): ISubscriptable.L { + return listeners.addListener(listener) } override fun serializeNBT(): CompoundTag { @@ -56,7 +58,7 @@ class RedstoneControl(private val valueChanges: (new: Boolean, old: Boolean) -> if (state != old) { valueChanges.invoke(state, old) - listeners.forEach { it.accept(state) } + listeners.accept(state) } } @@ -69,7 +71,7 @@ class RedstoneControl(private val valueChanges: (new: Boolean, old: Boolean) -> if (state != old) { valueChanges.invoke(state, old) - listeners.forEach { it.accept(state) } + listeners.accept(state) } } } @@ -89,7 +91,7 @@ class SynchronizedRedstoneControl( if (state != old) { valueChanges.invoke(state, old) - listeners.forEach { it.accept(state) } + listeners.accept(state) } } }) @@ -105,7 +107,7 @@ class SynchronizedRedstoneControl( if (state != old) { valueChanges.invoke(state, old) - listeners.forEach { it.accept(state) } + listeners.accept(state) } } }).property diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt index 3604c5111..45d3a1716 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt @@ -18,7 +18,9 @@ import ru.dbotthepony.mc.otm.* import ru.dbotthepony.mc.otm.block.CableBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.AbstractStorageImportExport.Companion.FILTER_KEY +import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.ItemFilter @@ -45,20 +47,14 @@ private class TrackedTuple(override var stack: ItemStorageStack, override val id } } -private fun Long.clamp(): Int { - if (this > Int.MAX_VALUE) { - return Int.MAX_VALUE - } - - return this.toInt() -} - class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.STORAGE_BUS, blockPos, blockState) { override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { return StorageBusMenu(containerID, inventory, this) } - val energy = WorkerEnergyStorage(this::setChangedLight, MachinesConfig.STORAGE_INTERFACES) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::setChangedLight, MachinesConfig.STORAGE_INTERFACES)) + val energyConfig = ConfigurableEnergy(energy, modesFront = FlowDirection.NONE) + val cell: StorageNode = object : StorageNode(energy) { override fun onNeighbour(link: Link) { if (link is DirectionLink) { @@ -93,8 +89,13 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter setChangedLight() } + var mode: FlowDirection = FlowDirection.BI_DIRECTIONAL + set(value) { + field = value + setChangedLight() + } + init { - exposeEnergyGlobally(energy) savetable(::energy, ENERGY_KEY) savetables.int(::insertPriority) savetables.int(::extractPriority) @@ -103,11 +104,21 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter side(RelativeSide.FRONT).track(ForgeCapabilities.ITEM_HANDLER).addListener { component?.let(cell::removeStorageComponent) component = if (it.isPresent) { - ItemHandlerComponent(it.orThrow()).also(cell::addStorageComponent) + ItemHandlerComponent(it.orThrow()).also { if (!redstoneControl.isBlockedByRedstone) cell.addStorageComponent(it) } } else { null } } + + redstoneControl.addListener { + val component = component ?: return@addListener + + if (it) { + cell.removeStorageComponent(component) + } else { + cell.addStorageComponent(component) + } + } } val filter = ItemFilter(MAX_FILTERS) { _, _, _ -> @@ -359,7 +370,7 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter } override fun insertStack(stack: ItemStorageStack, simulate: Boolean): ItemStorageStack { - if (redstoneControl.isBlockedByRedstone || energy.batteryLevel.isZero || !filter.match(stack.toItemStack())) + if (redstoneControl.isBlockedByRedstone || energy.batteryLevel.isZero || !filter.match(stack.toItemStack()) || !mode.input) return stack val required = StorageStack.ITEMS.energyPerInsert(stack) @@ -390,7 +401,7 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter } override fun extractStack(id: UUID, amount: BigInteger, simulate: Boolean): ItemStorageStack { - if (redstoneControl.isBlockedByRedstone || !amount.isPositive || !energy.batteryLevel.isPositive) + if (redstoneControl.isBlockedByRedstone || !amount.isPositive || !energy.batteryLevel.isPositive || !mode.output) return ItemStorageStack.EMPTY var total = BigInteger.ZERO 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 484df1610..30b72f565 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 @@ -21,7 +21,8 @@ import ru.dbotthepony.mc.otm.container.HandlerFilter 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.findAny +import ru.dbotthepony.mc.otm.core.collect.find +import ru.dbotthepony.mc.otm.core.collect.maybe import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities @@ -92,8 +93,7 @@ class PlatePressBlockEntity( .values .iterator() .filter { it.matches(inputContainer, id) } - .findAny() - .orElse(null) ?: return JobContainer.noItem() + .maybe() ?: return JobContainer.noItem() val toProcess = inputContainer[id].count.coerceAtMost(1 + upgrades.processingItems) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt index ae15a5428..d11df0163 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FlowDirection.kt @@ -64,7 +64,7 @@ enum class FlowDirection(val input: Boolean, val output: Boolean, val translatio }.build() } - val translation: Component + val title: Component get() = TranslatableComponent(translationKey) /** @@ -105,6 +105,9 @@ enum class FlowDirection(val input: Boolean, val output: Boolean, val translatio } companion object { + @JvmField + val WITHOUT_NONE: ImmutableSet = ImmutableSet.of(INPUT, OUTPUT, BI_DIRECTIONAL) + @JvmStatic fun of(input: Boolean, output: Boolean): FlowDirection { if (input && output) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderGravity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderGravity.kt index f67ee6051..33a72244a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderGravity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderGravity.kt @@ -30,6 +30,10 @@ enum class GravityRounding { return base - subtraction } } + + override fun round(base: Float): Float { + return base + } }, /** @@ -39,6 +43,10 @@ enum class GravityRounding { override fun round(base: Float, subtraction: Float): Float { return (base - subtraction).roundToInt().toFloat() } + + override fun round(base: Float): Float { + return base.roundToInt().toFloat() + } }, /** @@ -48,9 +56,14 @@ enum class GravityRounding { override fun round(base: Float, subtraction: Float): Float { return base - subtraction } + + override fun round(base: Float): Float { + return base + } }; abstract fun round(base: Float, subtraction: Float): Float + abstract fun round(base: Float): Float } interface IXGravity { @@ -60,6 +73,8 @@ interface IXGravity { fun x(x: Float, width: FloatSupplier): Float = x(x, width, 1f) fun x(x: Float, width: Float): Float = x(x, width, 1f) + fun repositionX(outer: Float, inner: Float, rounding: GravityRounding = GravityRounding.YES): Float + fun x(x: Float, font: Font, text: Component): Float = x(x, font, text, 1f) fun x(x: Float, font: Font, text: Component, scale: Float = 1f, rounding: GravityRounding = GravityRounding.DEFAULT): Float @@ -80,6 +95,8 @@ interface IYGravity { fun y(y: Float, height: Float, scale: Float = 1f, rounding: GravityRounding = GravityRounding.DEFAULT): Float fun y(y: Float, height: Float): Float = y(y, height, 1f) + fun repositionY(outer: Float, inner: Float, rounding: GravityRounding = GravityRounding.YES): Float + fun y(y: Float, height: Int, scale: Float = 1f): Float { return y(y, height.toFloat(), scale).roundToInt().toFloat() } @@ -106,6 +123,10 @@ enum class XGravity : IXGravity { override fun x(x: Float, font: Font, text: FormattedCharSequence, scale: Float, rounding: GravityRounding): Float { return x } + + override fun repositionX(outer: Float, inner: Float, rounding: GravityRounding): Float { + return 0f + } }, CENTER { override fun x(x: Float, width: FloatSupplier, scale: Float, rounding: GravityRounding): Float { @@ -127,6 +148,13 @@ enum class XGravity : IXGravity { override fun x(x: Float, font: Font, text: FormattedCharSequence, scale: Float, rounding: GravityRounding): Float { return rounding.round(x, font.width(text) / 2f * scale) } + + override fun repositionX(outer: Float, inner: Float, rounding: GravityRounding): Float { + if (outer <= inner) + return 0f + else + return rounding.round((outer - inner) / 2f, 0f) + } }, RIGHT { override fun x(x: Float, width: FloatSupplier, scale: Float, rounding: GravityRounding): Float { @@ -148,6 +176,13 @@ enum class XGravity : IXGravity { override fun x(x: Float, font: Font, text: FormattedCharSequence, scale: Float, rounding: GravityRounding): Float { return rounding.round(x, font.width(text) * scale) } + + override fun repositionX(outer: Float, inner: Float, rounding: GravityRounding): Float { + if (outer <= inner) + return 0f + else + return rounding.round(outer - inner, 0f) + } }; } @@ -160,6 +195,10 @@ enum class YGravity : IYGravity { override fun y(y: Float, height: Float, scale: Float, rounding: GravityRounding): Float { return y } + + override fun repositionY(outer: Float, inner: Float, rounding: GravityRounding): Float { + return 0f + } }, CENTER { @@ -170,6 +209,13 @@ enum class YGravity : IYGravity { override fun y(y: Float, height: Float, scale: Float, rounding: GravityRounding): Float { return rounding.round(y, height / 2f * scale) } + + override fun repositionY(outer: Float, inner: Float, rounding: GravityRounding): Float { + if (outer <= inner) + return 0f + else + return rounding.round((outer - inner) / 2f, 0f) + } }, BOTTOM { @@ -180,6 +226,13 @@ enum class YGravity : IYGravity { override fun y(y: Float, height: Float, scale: Float, rounding: GravityRounding): Float { return rounding.round(y, height * scale) } + + override fun repositionY(outer: Float, inner: Float, rounding: GravityRounding): Float { + if (outer <= inner) + return 0f + else + return rounding.round(outer - inner, 0f) + } }; } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt index 7c9ca1069..9da40a685 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt @@ -6,7 +6,7 @@ import ru.dbotthepony.mc.otm.client.render.sprites.MatteryAtlas object WidgetLocation { val LARGE_BUTTON = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/large_button.png"), 72f, 18f) - val STORAGE_CONTROLS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/storage_controls.png"), 90f, 36f) + val STORAGE_CONTROLS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/storage_controls.png"), 90f, 54f) val MISC_18 = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/misc18.png"), 72f, 72f) val SLOT_BACKGROUNDS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/slot_backgrounds.png"), 72f, 72f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt index e6cea1252..82d7bb6eb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt @@ -37,7 +37,7 @@ object Widgets18 { val BUTTON_DISABLED_STRETCHABLE = makeButton(buttonGrids) val BUTTON_DISABLED = buttonGrids.next() - private val storageGrid = WidgetLocation.STORAGE_CONTROLS.grid(rows = 2, columns = 5) + private val storageGrid = WidgetLocation.STORAGE_CONTROLS.grid(rows = 3, columns = 5) val ARROW_DOWN = storageGrid.next() val ARROW_UP = storageGrid.next() val SORT_DEFAULT = storageGrid.next() @@ -47,6 +47,9 @@ object Widgets18 { val SORT_ID = storageGrid.next() val SORT_MATTER_VALUE = storageGrid.next() val SORT_MATTER_COMPLEXITY = storageGrid.next() + val ONLY_STORE = storageGrid.next() + val ONLY_EXTRACT = storageGrid.next() + val STORE_EXTRACT = storageGrid.next() private val miscGrid = WidgetLocation.MISC_18.grid(4, 4) 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 ad038b27c..d55ed476c 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 @@ -19,6 +19,7 @@ import net.minecraftforge.common.MinecraftForge import org.lwjgl.opengl.GL11 import ru.dbotthepony.mc.otm.capability.matteryPlayer 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.translation import ru.dbotthepony.mc.otm.client.screen.panels.* @@ -31,14 +32,23 @@ import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.HeightControls import ru.dbotthepony.mc.otm.client.screen.panels.util.ScrollBarConstants import ru.dbotthepony.mc.otm.client.screen.widget.HorizontalPowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.PatternGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.ProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalProfiledPowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.config.ClientConfig import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.component1 import ru.dbotthepony.mc.otm.core.math.component2 import ru.dbotthepony.mc.otm.core.math.integerDivisionDown import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import java.util.* import kotlin.collections.ArrayDeque import kotlin.collections.List @@ -374,6 +384,59 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit return true } + protected fun makeBars( + parent: EditablePanel<*>, + energy: LevelGaugeWidget? = null, + profiledEnergy: ProfiledLevelGaugeWidget<*>? = null, + matter: LevelGaugeWidget? = null, + profiledMatter: ProfiledLevelGaugeWidget<*>? = null, + patterns: LevelGaugeWidget? = null, + batterySlot: MatterySlot? = null, + ) { + var bars = 0 + if (energy != null) bars++ + if (profiledEnergy != null) bars++ + if (matter != null) bars++ + if (patterns != null) bars++ + if (profiledMatter != null) bars++ + + val canvas = EditablePanel(this, parent, width = AbstractSlotPanel.SIZE.coerceAtLeast(9f * bars)) + canvas.dock = Dock.LEFT + canvas.childrenOrder = -1000 + + val gauges = EditablePanel(this, canvas, height = WidgetLocation.VERTICAL_GAUGES.height) + gauges.dock = Dock.TOP + + if (profiledEnergy != null) { + if (bars == 1) { + WideProfiledPowerGaugePanel(this, gauges, profiledEnergy).dock = Dock.TOP + } else { + ProfiledPowerGaugePanel(this, gauges, profiledEnergy).dock = Dock.LEFT + } + } else if (energy != null) { + if (bars == 1) { + WidePowerGaugePanel(this, gauges, energy).dock = Dock.TOP + } else { + PowerGaugePanel(this, gauges, energy).dock = Dock.LEFT + } + } + + if (matter != null) { + MatterGaugePanel(this, gauges, matter).dock = Dock.LEFT + } + + if (patterns != null) { + PatternGaugePanel(this, gauges, patterns).dock = Dock.LEFT + } + + if (batterySlot != null) { + BatterySlotPanel(this, canvas, batterySlot).also { + it.dock = Dock.BOTTOM + it.dockResize = DockResizeMode.NONE + } + } + } + /** * Safely to be overriden. By default, creates well-known dimensions window * diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt index 97810e9d7..5bc85ec98 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt @@ -580,7 +580,7 @@ open class ColorPickerPanel( } } - override fun acceptsCharacter(codepoint: Char, mods: Int): Boolean { + override fun acceptsCharacter(codepoint: Char, mods: Int, index: Int): Boolean { return RGBAColor.isHexCharacter(codepoint) } } 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 cad6d06bb..d7d9673ae 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 @@ -33,6 +33,8 @@ data class ScreenPos(val x: Float, val y: Float) data class DockProperty(val left: Float = 0f, val top: Float = 0f, val right: Float = 0f, val bottom: Float = 0f) { val isEmpty get() = left == 0f && right == 0f && top == 0f && bottom == 0f + val horizontal get() = left + right + val vertical get() = top + bottom companion object { val EMPTY = DockProperty() @@ -73,7 +75,6 @@ open class EditablePanel @JvmOverloads constructor( height: Float = 10f, ) : Comparable> { // layout engine does not support navigation using keyboard - // fuck off val listener: GuiEventListener = object : GuiEventListener { override fun setFocused(p_265728_: Boolean) { if (p_265728_) { @@ -138,6 +139,9 @@ open class EditablePanel @JvmOverloads constructor( } } + /** + * Bigger values means lesser priority while docking + */ var childrenOrder = 0 set(value) { if (field != value) { @@ -235,17 +239,21 @@ open class EditablePanel @JvmOverloads constructor( } /** - * Width to be utilized in docking code. + * Width of this panel as considered by docking code, updated inside [performLayout] * - * Can only differ from [width] if [dockResize] is not [DockResizeMode.ALL] and not [DockResizeMode.WIDTH] + * If panel is not docked ([dock] is [Dock.NONE]), this value equals to [width] plus [DockProperty.horizontal] of [dockMargin] + * + * If panel is docked, this value will be equal to [width], if [dockResize] allows resizing [width], or could-have value, if [dockResize] doesn't */ var dockedWidth: Float = 0f private set /** - * Height to be utilized in docking code. + * Height of this panel as considered by docking code, updated inside [performLayout] * - * Can only differ from [height] if [dockResize] is not [DockResizeMode.ALL] and not [DockResizeMode.HEIGHT] + * If panel is not docked ([dock] is [Dock.NONE]), this value equals to [height] plus [DockProperty.vertical] of [dockMargin] + * + * If panel is docked, this value will be equal to [height], if [dockResize] allows resizing [height], or could-have value, if [dockResize] doesn't */ var dockedHeight: Float = 0f private set @@ -362,6 +370,38 @@ open class EditablePanel @JvmOverloads constructor( } } + var dockPaddingLeft: Float + get() = dockPadding.left + set(value) { + if (value != dockPadding.left) { + dockPadding = dockPadding.copy(left = value) + } + } + + var dockPaddingRight: Float + get() = dockPadding.right + set(value) { + if (value != dockPadding.right) { + dockPadding = dockPadding.copy(right = value) + } + } + + var dockPaddingTop: Float + get() = dockPadding.top + set(value) { + if (value != dockPadding.top) { + dockPadding = dockPadding.copy(top = value) + } + } + + var dockPaddingBottom: Float + get() = dockPadding.bottom + set(value) { + if (value != dockPadding.bottom) { + dockPadding = dockPadding.copy(bottom = value) + } + } + var acceptMouseInput = true var acceptKeyboardInput = true var grabMouseInput = false @@ -1060,7 +1100,11 @@ open class EditablePanel @JvmOverloads constructor( for (child in visibleChildrenInternal) { when (child.dock) { - Dock.NONE -> {} + Dock.NONE -> { + child.dockedWidth = child.width + child.dockMargin.horizontal + child.dockedHeight = child.height + child.dockMargin.vertical + } + Dock.FILL -> {} Dock.LEFT -> { @@ -1192,8 +1236,8 @@ open class EditablePanel @JvmOverloads constructor( * * Performs layout if required */ - open fun sizeToContents() { - if (layoutInvalidated) { + open fun sizeToContents(performLayout: Boolean = true) { + if (layoutInvalidated && performLayout) { performLayout() } @@ -1398,8 +1442,7 @@ open class EditablePanel @JvmOverloads constructor( } fun getChildren(index: Int): EditablePanel<*>? { - if (index < 0 || index >= childrenInternal.size) return null - return childrenInternal[index] + return childrenInternal.getOrNull(index) } fun isGrabbingMouseInput(): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt index 797f88dd3..aa1cba389 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt @@ -61,8 +61,8 @@ open class Label @JvmOverloads constructor( } } - override fun sizeToContents() { - super.sizeToContents() + override fun sizeToContents(performLayout: Boolean) { + super.sizeToContents(performLayout) val w = font.width(text) val h = font.lineHeight + 2 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt index 53965c468..67a0c546f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt @@ -56,8 +56,8 @@ open class ButtonPanel( graphics.draw(font, label, width / 2f, height / 2f, color = textColor, gravity = RenderGravity.CENTER_CENTER) } - override fun sizeToContents() { - super.sizeToContents() + override fun sizeToContents(performLayout: Boolean) { + super.sizeToContents(performLayout) height = height.coerceAtLeast(HEIGHT).coerceAtLeast(font.lineHeight.toFloat() + 2f) width = width.coerceAtLeast(HEIGHT).coerceAtLeast(font.width(label) + 4f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt index be566b427..c5ad5d7d8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkedStringInputPanel.kt @@ -4,12 +4,13 @@ import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.menu.input.AbstractPlayerInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.IPlayerInputWithFeedback import ru.dbotthepony.mc.otm.milliTime open class NetworkedStringInputPanel( screen: S, parent: EditablePanel<*>?, - val backend: AbstractPlayerInputWithFeedback, + val backend: IPlayerInputWithFeedback, x: Float = 0f, y: Float = 0f, width: Float = 60f, @@ -29,7 +30,7 @@ open class NetworkedStringInputPanel( private var lastChanges = 0L - override fun onTextChanged(old: String, new: String) { + override fun onTextChanged(new: String, old: String) { lastChanges = milliTime + 1000L backend.accept(new) } @@ -38,7 +39,7 @@ open class NetworkedStringInputPanel( super.tickInner() if (milliTime >= lastChanges) { - text = backend.value + text = backend.get() } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NumberInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NumberInputPanel.kt new file mode 100644 index 000000000..b96963ee7 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NumberInputPanel.kt @@ -0,0 +1,215 @@ +package ru.dbotthepony.mc.otm.client.screen.panels.input + +import com.mojang.blaze3d.platform.InputConstants +import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.render.Widgets +import ru.dbotthepony.mc.otm.client.screen.panels.Dock +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.RectangleButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.HeightControls +import ru.dbotthepony.mc.otm.core.GetterSetter +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.math.Decimal + +abstract class NumberInputPanel( + screen: S, + parent: EditablePanel<*>, + val prop: GetterSetter, + x: Float = 0f, + y: Float = 0f, + width: Float = WIDTH, + height: Float = HeightControls.BUTTON_HEIGHT * 2f, + var min: N? = null, + var max: N? = null, +) : EditablePanel(screen, parent, x, y, width, height) { + abstract fun toNumber(input: String): N? + abstract fun increase(input: N): N + abstract fun decrease(input: N): N + abstract val isFractional: Boolean + + fun clamp(value: N): N { + val min = min + val max = max + if (min != null && (value as Comparable) < min) return min + if (max != null && (value as Comparable) > max) return max + return value + } + + fun increase() { + prop.accept(clamp(increase(prop.get()))) + } + + fun decrease() { + prop.accept(clamp(decrease(prop.get()))) + } + + val textInput = object : TextInputPanel(screen, this@NumberInputPanel) { + init { + allowNumbersAndSign() + dock = Dock.FILL + text = prop.get().toString() + } + + override fun acceptsCharacter(codepoint: Char, mods: Int, index: Int): Boolean { + if (!isFractional && codepoint == '.') return false + return super.acceptsCharacter(codepoint, mods, index) + } + + override fun tickInner() { + super.tickInner() + + if (!hasHierarchicalFocus()) { + text = prop.get().toString() + } + } + + override fun onTextChanged(new: String, old: String) { + if (hasHierarchicalFocus()) { + val i = toNumber(new) + if (i != null) prop.accept(i) + } + } + } + + val controls = EditablePanel(screen, this, width = HeightControls.BUTTON_WIDTH, height = HeightControls.BUTTON_HEIGHT) + val increaseControl = Control(true) + val decreaseControl = Control(false) + + init { + increaseControl.childrenOrder = 1 + decreaseControl.childrenOrder = 2 + textInput.dockRight = 2f + } + + init { + controls.dock = Dock.RIGHT + } + + inner class Control(val isIncrease: Boolean) : RectangleButtonPanel(screen, controls, width = HeightControls.BUTTON_WIDTH, height = HeightControls.BUTTON_HEIGHT) { + override val PRESSED = if (!isIncrease) Widgets.ARROW_DOWN_BUTTON_PRESSED else Widgets.ARROW_UP_BUTTON_PRESSED + override val HOVERED = if (!isIncrease) Widgets.ARROW_DOWN_BUTTON_HOVERED else Widgets.ARROW_UP_BUTTON_HOVERED + override val IDLE = if (!isIncrease) Widgets.ARROW_DOWN_BUTTON_IDLE else Widgets.ARROW_UP_BUTTON_IDLE + override val DISABLED = if (!isIncrease) Widgets.ARROW_DOWN_BUTTON_DISABLED else Widgets.ARROW_UP_BUTTON_DISABLED + + init { + dock = Dock.TOP + + if (isIncrease) + tooltips.add(TranslatableComponent("otm.gui.increase")) + else + tooltips.add(TranslatableComponent("otm.gui.decrease")) + } + + override fun test(value: Int): Boolean { + return value == InputConstants.MOUSE_BUTTON_LEFT || value == InputConstants.MOUSE_BUTTON_RIGHT + } + + override fun onClick(mouseButton: Int) { + if (mouseButton == InputConstants.MOUSE_BUTTON_LEFT) { + if (isIncrease) { + increase() + } else { + decrease() + } + } else if (mouseButton == InputConstants.MOUSE_BUTTON_RIGHT) { + if (isIncrease) { + decrease() + } else { + increase() + } + } + } + } + + companion object { + const val WIDTH = 50f + } +} + +abstract class LNumberInputPanel( + screen: S, + parent: EditablePanel<*>, + prop: GetterSetter, + x: Float = 0f, + y: Float = 0f, + width: Float = WIDTH, + height: Float = HeightControls.BUTTON_HEIGHT * 2f, + min: N? = null, + max: N? = null, + val toNumber: (String) -> N?, + val increase: (N) -> N, + val decrease: (N) -> N, + final override val isFractional: Boolean +) : NumberInputPanel(screen, parent, prop, x, y, width, height, min, max) { + final override fun toNumber(input: String): N? { + return toNumber.invoke(input) + } + + final override fun increase(input: N): N { + return increase.invoke(input) + } + + final override fun decrease(input: N): N { + return decrease.invoke(input) + } +} + +open class IntInputPanel( + screen: S, + parent: EditablePanel<*>, + prop: GetterSetter, + x: Float = 0f, + y: Float = 0f, + width: Float = WIDTH, + height: Float = HeightControls.BUTTON_HEIGHT * 2f, + var step: Int = 1, + min: Int? = null, + max: Int? = null, +) : NumberInputPanel(screen, parent, prop, x, y, width, height, min, max) { + final override fun toNumber(input: String): Int? { + return input.toIntOrNull() + } + + final override fun increase(input: Int): Int { + return input + step + } + + final override fun decrease(input: Int): Int { + return input - step + } + + final override val isFractional: Boolean + get() = false +} + +open class DecimalInputPanel( + screen: S, + parent: EditablePanel<*>, + prop: GetterSetter, + x: Float = 0f, + y: Float = 0f, + width: Float = WIDTH, + height: Float = HeightControls.BUTTON_HEIGHT * 2f, + var step: Decimal = Decimal.ONE, + min: Decimal? = null, + max: Decimal? = null, +) : NumberInputPanel(screen, parent, prop, x, y, width, height, min, max) { + final override fun toNumber(input: String): Decimal? { + return try { + Decimal(input) + } catch (err: NumberFormatException) { + null + } + } + + final override fun increase(input: Decimal): Decimal { + return input + step + } + + final override fun decrease(input: Decimal): Decimal { + return input - step + } + + final override val isFractional: Boolean + get() = true +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt index c88a4eec4..328a0d943 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt @@ -27,7 +27,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.addAll -import ru.dbotthepony.mc.otm.core.collect.mapToInt +import ru.dbotthepony.mc.otm.core.collect.map import ru.dbotthepony.mc.otm.core.collect.reduce import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.milliTime @@ -904,7 +904,7 @@ open class TextInputPanel( pushbackSnapshot() if (multiLine) { - var index = cursorRow + (0 until cursorLine).iterator().mapToInt { this[it]?.length ?: 0 }.reduce(0, Int::plus) + var index = cursorRow + (0 until cursorLine).iterator().map { this[it]?.length ?: 0 }.reduce(0, Int::plus) val insert = minecraft.keyboardHandler.clipboard.replace("\t", " ").filter { acceptsCharacter(it, 0, index++) }.split(NEWLINES).toMutableList() val actualLastSize = insert.lastOrNull()?.length ?: 0 val line = this[cursorLine] @@ -944,7 +944,7 @@ open class TextInputPanel( cursorRow = actualLastSize } } else { - var index = cursorRow + (0 until cursorLine).iterator().mapToInt { this[it]?.length ?: 0 }.reduce(0, Int::plus) + var index = cursorRow + (0 until cursorLine).iterator().map { this[it]?.length ?: 0 }.reduce(0, Int::plus) val insert = minecraft.keyboardHandler.clipboard.replace("\t", " ").replace(NEWLINES, "").filter { acceptsCharacter(it, 0, index++) } val line = this[cursorLine] @@ -1462,7 +1462,7 @@ open class TextInputPanel( } private val NUMBERS = CharOpenHashSet().also { - for (char in "0123456789-+") + for (char in "0123456789.") it.add(char) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/GridPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/GridPanel.kt index a9de349d6..782189a60 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/GridPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/GridPanel.kt @@ -1,8 +1,12 @@ package ru.dbotthepony.mc.otm.client.screen.panels.util import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.core.collect.filter +import ru.dbotthepony.mc.otm.core.collect.map +import ru.dbotthepony.mc.otm.core.collect.maybe open class GridPanel( screen: S, @@ -26,37 +30,54 @@ open class GridPanel( invalidateLayout() } - override fun performLayout() { - var currentX = 0f - var currentY = 0f - var lineY = 0f - var index = 0 - - for (row in 0 until rows) { - var column = 0 - - while (column < columns) { - val child = getChildren(index) ?: break - - if (child.visible && child.dock === Dock.NONE) { - lineY = lineY.coerceAtLeast(child.height + child.dockMargin.top + child.dockMargin.bottom) - child.setPos(currentX + child.dockMargin.left, currentY + child.dockMargin.top) - currentX += child.width + child.dockMargin.left + child.dockMargin.right - } else { - column-- - } - - index++ - column++ - } - - currentY += lineY - currentX = 0f - lineY = 0f - - getChildren(index) ?: break + var gravity: RenderGravity = RenderGravity.CENTER_CENTER + set(value) { + field = value + invalidateLayout() } + override fun performLayout() { super.performLayout() + var children = visibleChildren.iterator().filter { it.dock == Dock.NONE } + + var totalWidth = 0f + var totalHeight = 0f + + for (row in 0 until rows) { + var maxHeight = 0f + var width = 0f + + for (column in 0 until columns) { + val child = children.maybe() ?: break + width += child.dockedWidth + maxHeight = maxHeight.coerceAtLeast(child.dockedHeight) + } + + totalWidth = totalWidth.coerceAtLeast(width) + totalHeight += maxHeight + } + + val alignX = gravity.repositionX(width, totalWidth) + val alignY = gravity.repositionY(height, totalHeight) + children = visibleChildren.iterator().filter { it.dock == Dock.NONE } + + totalWidth = 0f + totalHeight = 0f + + for (row in 0 until rows) { + var maxHeight = 0f + var width = 0f + + for (column in 0 until columns) { + val child = children.maybe() ?: break + child.x = alignX + width + child.y = alignY + totalHeight + width += child.dockedWidth + maxHeight = maxHeight.coerceAtLeast(child.dockedHeight) + } + + totalWidth = totalWidth.coerceAtLeast(width) + totalHeight += maxHeight + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/HeightControls.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/HeightControls.kt index 9eeaae48a..653bfe9f5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/HeightControls.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/HeightControls.kt @@ -46,7 +46,7 @@ open class HeightControls( decrease.isDisabled = !value.canDecrease } - open inner class Control(val isIncrease: Boolean) : RectangleButtonPanel(screen, this@HeightControls, width = BUTTON_WIDTH, height = BUTTON_HEIGHT) { + inner class Control(val isIncrease: Boolean) : RectangleButtonPanel(screen, this@HeightControls, width = BUTTON_WIDTH, height = BUTTON_HEIGHT) { override val PRESSED: AbstractMatterySprite = if (isIncrease) Widgets.ARROW_DOWN_BUTTON_PRESSED else Widgets.ARROW_UP_BUTTON_PRESSED override val HOVERED: AbstractMatterySprite = if (isIncrease) Widgets.ARROW_DOWN_BUTTON_HOVERED else Widgets.ARROW_UP_BUTTON_HOVERED override val IDLE: AbstractMatterySprite = if (isIncrease) Widgets.ARROW_DOWN_BUTTON_IDLE else Widgets.ARROW_UP_BUTTON_IDLE @@ -57,10 +57,14 @@ open class HeightControls( dockBottom = 2f } - override fun onClick(clickButton: Int) { - if (clickButton == InputConstants.MOUSE_BUTTON_LEFT) { + override fun test(value: Int): Boolean { + return value == InputConstants.MOUSE_BUTTON_LEFT || value == InputConstants.MOUSE_BUTTON_RIGHT + } + + override fun onClick(mouseButton: Int) { + if (mouseButton == InputConstants.MOUSE_BUTTON_LEFT) { this@HeightControls.onClick(isIncrease) - } else if (clickButton == InputConstants.MOUSE_BUTTON_RIGHT) { + } else if (mouseButton == InputConstants.MOUSE_BUTTON_RIGHT) { this@HeightControls.onClick(!isIncrease) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/HorizontalStripPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/HorizontalStripPanel.kt index 64c81c1fa..fa8b8e496 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/HorizontalStripPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/HorizontalStripPanel.kt @@ -13,13 +13,13 @@ class HorizontalStripPanel( width: Float = 0f, height: Float = 0f, ) : EditablePanel(screen, parent, x, y, width, height) { - override fun sizeToContents() { + override fun sizeToContents(performLayout: Boolean) { var w = 0f var h = 0f - for (child in children) { + for (child in visibleChildren) { if (child.dock == Dock.NONE) { - w += child.width + child.dockMargin.left + child.dockMargin.right + w += child.width + child.dockMargin.horizontal h = h.coerceAtLeast(child.height) } } @@ -33,19 +33,19 @@ class HorizontalStripPanel( var w = 0f - for (child in children) { + for (child in visibleChildren) { if (child.dock == Dock.NONE) { - w += child.width + child.dockMargin.left + child.dockMargin.right + w += child.width + child.dockMargin.horizontal } } w = width / 2f - w / 2f - for (child in children) { + for (child in visibleChildren) { if (child.dock == Dock.NONE) { child.y = (height / 2f - child.height / 2f).roundToInt().toFloat() child.x = (w + child.dockMargin.left).roundToInt().toFloat() - w += child.dockMargin.left + child.width + child.dockMargin.right + w += child.dockMargin.horizontal + child.width } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt index 8cfff6a10..2e52a31b3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt @@ -2,57 +2,64 @@ package ru.dbotthepony.mc.otm.client.screen.storage import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.button.CheckBoxLabelInputPanel -import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls -import ru.dbotthepony.mc.otm.client.screen.panels.input.TextInputPanel -import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.DeviceControls +import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeEnumRectangleButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.input.IntInputPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.FilterSlotPanel -import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel import ru.dbotthepony.mc.otm.menu.storage.StorageBusMenu class StorageBusScreen(menu: StorageBusMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { override fun makeMainFrame(): FramePanel> { - val frame = super.makeMainFrame()!! + val frame = FramePanel(this, 150f, 126f, title) - WidePowerGaugePanel(this, frame, menu.energyWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) - BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) + makeBars(frame, profiledEnergy = menu.profiledEnergy, batterySlot = menu.batterySlot) + val right = EditablePanel(this, frame, width = AbstractSlotPanel.SIZE * 6f) + right.dock = Dock.RIGHT + val grid = GridPanel(this, right, columns = 6, rows = 3, height = AbstractSlotPanel.SIZE * 3f) + grid.dock = Dock.TOP + grid.dockBottom = 2f - for (row in 0 .. 2) { - for (column in 0 .. 5) { - FilterSlotPanel(this, frame, menu.busFilterSlots[row + column * 3], 55f + 18f * column, 17f + 18f * row) - } + for (slot in menu.busFilterSlots) + FilterSlotPanel(this, grid, slot) + + IntInputPanel(this, right, menu.insertPriority).also { + it.dock = Dock.BOTTOM + it.dockBottom = 2f + it.tooltips.add(TranslatableComponent("otm.gui.insert_priority")) + it.childrenOrder = -1 } - CheckBoxLabelInputPanel(this, frame, menu.busFilterState, TranslatableComponent("otm.gui.filter.is_whitelist"), 59f, 78f, width = 170f) + IntInputPanel(this, right, menu.extractPriority).also { + it.dock = Dock.BOTTOM + it.dockBottom = 2f + it.tooltips.add(TranslatableComponent("otm.gui.extract_priority")) + it.childrenOrder = -2 + } - makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig) + CheckBoxLabelInputPanel(this, right, menu.busFilterState, TranslatableComponent("otm.gui.filter.is_whitelist")).also { + it.dock = Dock.BOTTOM + it.childrenOrder = -3 + } - /*object : TextInputPanel(this@StorageBusScreen, frame) { - init { - allowNumbersAndSign() - dock = Dock.BOTTOM - } + val controls = DeviceControls(this, frame, redstoneConfig = menu.redstoneConfig) + val mode = LargeEnumRectangleButtonPanel(this, frame, prop = menu.mode, defaultValue = FlowDirection.BI_DIRECTIONAL, enum = FlowDirection::class.java) - override fun tickInner() { - super.tickInner() + mode.add(FlowDirection.INPUT, Widgets18.ONLY_STORE, FlowDirection.INPUT.title) + mode.add(FlowDirection.OUTPUT, Widgets18.ONLY_EXTRACT, FlowDirection.OUTPUT.title) + mode.add(FlowDirection.BI_DIRECTIONAL, Widgets18.STORE_EXTRACT, FlowDirection.BI_DIRECTIONAL.title) + mode.finish() - if (!hasHierarchicalFocus()) { - text = menu.insertPriority.value.toString() - } - } - - override fun onTextChanged(new: String, old: String) { - if (hasHierarchicalFocus()) { - val i = new.toIntOrNull() - if (i != null) menu.insertPriority.accept(i) - } - } - }*/ + controls.addButton(mode) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt index db3e843ec..a8fa5095e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt @@ -5,13 +5,8 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.UpgradeType import ru.dbotthepony.mc.otm.config.EnergyBalanceValues import ru.dbotthepony.mc.otm.config.VerboseEnergyBalanceValues -import ru.dbotthepony.mc.otm.core.collect.filter import ru.dbotthepony.mc.otm.core.collect.map -import ru.dbotthepony.mc.otm.core.collect.mapToDouble -import ru.dbotthepony.mc.otm.core.collect.mapToInt import ru.dbotthepony.mc.otm.core.collect.reduce -import ru.dbotthepony.mc.otm.core.collect.sum -import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.core.math.Decimal import kotlin.math.pow @@ -28,9 +23,9 @@ open class UpgradeContainer(slotCount: Int, open val allowedUpgrades: Set a + b } override val processingItems: Int - get() = iterator().mapToInt { it.getCapability(MatteryCapability.UPGRADE).map { it.processingItems }.orElse(0).coerceAtLeast(0) * it.count }.reduce(0) { a, b -> a + b } + get() = iterator().map { it.getCapability(MatteryCapability.UPGRADE).map { it.processingItems }.orElse(0).coerceAtLeast(0) * it.count }.reduce(0) { a, b -> a + b } override val energyStorageFlat: Decimal get() = decimals(IMatteryUpgrade::energyStorageFlat, Decimal::plus) override val energyStorage: Decimal @@ -42,7 +37,7 @@ open class UpgradeContainer(slotCount: Int, open val allowedUpgrades: Set a * b } + get() = iterator().map { it.getCapability(MatteryCapability.UPGRADE).map { it.failureMultiplier }.orElse(1.0).coerceAtLeast(0.0).pow(it.count.toDouble()) }.reduce(1.0) { a, b -> a * b } override val energyThroughputFlat: Decimal get() = decimals(IMatteryUpgrade::energyThroughputFlat, Decimal::plus) override val energyThroughput: Decimal diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/ByteSupplier.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/ByteSupplier.kt new file mode 100644 index 000000000..77714b552 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/ByteSupplier.kt @@ -0,0 +1,5 @@ +package ru.dbotthepony.mc.otm.core + +interface ByteSupplier { + fun getAsByte(): Byte +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/ShortSupplier.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/ShortSupplier.kt new file mode 100644 index 000000000..e8952d63a --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/ShortSupplier.kt @@ -0,0 +1,5 @@ +package ru.dbotthepony.mc.otm.core + +interface ShortSupplier { + fun getAsShort(): Short +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt similarity index 76% rename from src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt index 4b11f9329..8580dbb75 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt @@ -21,7 +21,7 @@ import java.util.stream.Collector * * Resulting [Iterator] is [MutableIterator] if [parent] is */ -class FilteredIterator(private val parent: Iterator, private val predicate: Predicate) : MutableIterator { +class FilteringIterator(private val parent: Iterator, private val predicate: Predicate) : MutableIterator { private var foundValue: Any? = Companion override fun hasNext(): Boolean { @@ -124,18 +124,6 @@ class FlatMappingIterator(private val parent: Iterator, private val map } } -fun concatIterators(): MutableIterator { - return ObjectIterators.EMPTY_ITERATOR as MutableIterator -} - -fun concatIterators(a: Iterator): MutableIterator { - return a as MutableIterator -} - -fun concatIterators(vararg iterators: Iterator): MutableIterator { - return iterators.iterator().flatMap { it } -} - /** * Limits amount of values returned by [parent] iterator to return at most [limit] values * @@ -201,12 +189,24 @@ class SkippingIterator(private val parent: Iterator, skip: Long) : Mutable } } +fun concatIterators(): MutableIterator { + return ObjectIterators.EMPTY_ITERATOR as MutableIterator +} + +fun concatIterators(a: Iterator): MutableIterator { + return a as MutableIterator +} + +fun concatIterators(vararg iterators: Iterator): MutableIterator { + return iterators.iterator().flatMap { it } +} + /** * Filters elements of [this] iterator * * Resulting [Iterator] is [MutableIterator] if [this] is */ -fun Iterator.filter(condition: Predicate) = FilteredIterator(this, condition) +fun Iterator.filter(condition: Predicate) = FilteringIterator(this, condition) /** * Maps elements of [this] iterator from values of [T] to [R] using function [mapper] @@ -236,92 +236,16 @@ fun Iterator.flatMap(mapper: (T) -> Iterator) = FlatMappingIterator */ fun Iterator.flatMap(mapper: java.util.function.Function>) = FlatMappingIterator(this, mapper::apply) -fun interface O2DFunction { - fun apply(value: T): Double -} - -fun interface O2IFunction { - fun apply(value: T): Int -} - -fun Iterator.mapToDouble(mapper: O2DFunction): it.unimi.dsi.fastutil.doubles.DoubleIterator { - return object : it.unimi.dsi.fastutil.doubles.DoubleIterator { - override fun hasNext(): Boolean { - return this@mapToDouble.hasNext() - } - - override fun remove() { - (this@mapToDouble as MutableIterator).remove() - } - - override fun nextDouble(): Double { - return mapper.apply(this@mapToDouble.next()) - } - } -} - -fun Iterator.mapToInt(mapper: O2IFunction): it.unimi.dsi.fastutil.ints.IntIterator { - return object : it.unimi.dsi.fastutil.ints.IntIterator { - override fun hasNext(): Boolean { - return this@mapToInt.hasNext() - } - - override fun remove() { - (this@mapToInt as MutableIterator).remove() - } - - override fun nextInt(): Int { - return mapper.apply(this@mapToInt.next()) - } - } -} - -fun it.unimi.dsi.fastutil.doubles.DoubleIterator.sum(): Double { - var value = 0.0 - while (hasNext()) value += nextDouble() - return value -} - -fun it.unimi.dsi.fastutil.ints.IntIterator.sum(): Int { - var value = 0 - while (hasNext()) value += nextInt() - return value -} - -fun interface DD2DFunction { - fun apply(a: Double, b: Double): Double -} - -fun interface II2IFunction { - fun apply(a: Int, b: Int): Int -} - -fun it.unimi.dsi.fastutil.doubles.DoubleIterator.reduce(identity: Double, reducer: DD2DFunction): Double { - var result = identity - while (hasNext()) result = reducer.apply(result, nextDouble()) - return result -} - -fun it.unimi.dsi.fastutil.ints.IntIterator.reduce(identity: Int, reducer: II2IFunction): Int { - var result = identity - while (hasNext()) result = reducer.apply(result, nextInt()) - return result -} - fun Iterator.reduce(identity: T, reducer: (T, T) -> T): T { var result = identity - - for (value in this) { - result = reducer.invoke(result, value) - } - + for (value in this) result = reducer.invoke(result, value) return result } fun Iterator.reduce(identity: T, reducer: BinaryOperator): T = reduce(identity, reducer::apply) fun Iterator.filterNotNull(): Iterator = filter { it != null } as Iterator -fun Iterator.anyMatch(predicate: Predicate): Boolean { +fun Iterator.any(predicate: Predicate): Boolean { for (value in this) { if (predicate.test(value)) { return true @@ -331,7 +255,7 @@ fun Iterator.anyMatch(predicate: Predicate): Boolean { return false } -fun Iterator.allMatch(predicate: Predicate): Boolean { +fun Iterator.all(predicate: Predicate): Boolean { for (value in this) { if (!predicate.test(value)) { return false @@ -341,7 +265,7 @@ fun Iterator.allMatch(predicate: Predicate): Boolean { return true } -fun Iterator.noneMatch(predicate: Predicate): Boolean { +fun Iterator.none(predicate: Predicate): Boolean { for (value in this) { if (predicate.test(value)) { return false @@ -368,7 +292,7 @@ fun Iterator.toList(): MutableList { return result } -fun Iterator.findFirst(): Optional { +fun Iterator.find(): Optional { if (hasNext()) { return Optional.of(next()) } @@ -376,7 +300,6 @@ fun Iterator.findFirst(): Optional { return Optional.empty() } -fun Iterator.findAny() = findFirst() fun Iterator.limit(limit: Long) = LimitingIterator(this, limit) fun Iterator.skip(skip: Long) = if (skip == 0L) this else SkippingIterator(this, skip) @@ -418,8 +341,8 @@ fun Iterator.max(comparator: Comparator): Optional { return Optional.of(max) } -fun Iterator.peek(peeker: (T) -> Unit): Iterator { - return object : Iterator { +fun Iterator.peek(peeker: (T) -> Unit): MutableIterator { + return object : MutableIterator { override fun hasNext(): Boolean { return this@peek.hasNext() } @@ -427,5 +350,16 @@ fun Iterator.peek(peeker: (T) -> Unit): Iterator { override fun next(): T { return this@peek.next().also(peeker) } + + override fun remove() { + (this@peek as MutableIterator).remove() + } } } + +fun Iterator.maybe(): T? { + return if (hasNext()) + next() + else + null +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt index 4c5877a1a..8d26f352e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/EnumInputWithFeedback.kt @@ -5,40 +5,40 @@ import ru.dbotthepony.mc.otm.core.util.EnumValueCodec import ru.dbotthepony.mc.otm.menu.MatteryMenu import kotlin.reflect.KMutableProperty0 -inline fun > EnumInputWithFeedback(menu: MatteryMenu) = EnumInputWithFeedback(menu, E::class.java) -inline fun > EnumInputWithFeedback(menu: MatteryMenu, state: KMutableProperty0?) = EnumInputWithFeedback(menu, E::class.java, state) -inline fun > EnumInputWithFeedback(menu: MatteryMenu, state: GetterSetter) = EnumInputWithFeedback(menu, E::class.java, state) +inline fun > EnumInputWithFeedback(menu: MatteryMenu, allowedValues: Set? = null) = EnumInputWithFeedback(menu, E::class.java, allowedValues = allowedValues) +inline fun > EnumInputWithFeedback(menu: MatteryMenu, state: KMutableProperty0?, allowedValues: Set? = null) = EnumInputWithFeedback(menu, E::class.java, state, allowedValues = allowedValues) +inline fun > EnumInputWithFeedback(menu: MatteryMenu, state: GetterSetter?, allowedValues: Set? = null) = EnumInputWithFeedback(menu, E::class.java, state, allowedValues = allowedValues) -inline fun > EnumInputWithFeedback(menu: MatteryMenu, allowSpectators: Boolean) = EnumInputWithFeedback(menu, E::class.java, allowSpectators) -inline fun > EnumInputWithFeedback(menu: MatteryMenu, allowSpectators: Boolean, state: KMutableProperty0?) = EnumInputWithFeedback(menu, E::class.java, allowSpectators, state) -inline fun > EnumInputWithFeedback(menu: MatteryMenu, allowSpectators: Boolean, state: GetterSetter) = EnumInputWithFeedback(menu, E::class.java, allowSpectators, state) +inline fun > EnumInputWithFeedback(menu: MatteryMenu, allowSpectators: Boolean, allowedValues: Set? = null) = EnumInputWithFeedback(menu, E::class.java, allowSpectators, allowedValues = allowedValues) +inline fun > EnumInputWithFeedback(menu: MatteryMenu, allowSpectators: Boolean, state: KMutableProperty0?, allowedValues: Set? = null) = EnumInputWithFeedback(menu, E::class.java, allowSpectators, state, allowedValues = allowedValues) +inline fun > EnumInputWithFeedback(menu: MatteryMenu, allowSpectators: Boolean, state: GetterSetter?, allowedValues: Set? = null) = EnumInputWithFeedback(menu, E::class.java, allowSpectators, state, allowedValues = allowedValues) -class EnumInputWithFeedback>(menu: MatteryMenu, clazz: Class, allowSpectators: Boolean = false) : AbstractPlayerInputWithFeedback() { +class EnumInputWithFeedback>(menu: MatteryMenu, clazz: Class, allowSpectators: Boolean = false, val allowedValues: Set? = null) : AbstractPlayerInputWithFeedback() { val codec = EnumValueCodec(clazz) private val default = codec.values.first() - override val input = menu.PlayerInput(codec, allowSpectators) { consumer?.invoke(it) } + override val input = menu.PlayerInput(codec, allowSpectators) { if (allowedValues == null || it in allowedValues) consumer?.invoke(it) } override val field = menu.mSynchronizer.ComputedField(getter = { supplier?.invoke() ?: default }, codec) - constructor(menu: MatteryMenu, clazz: Class, state: KMutableProperty0?) : this(menu, clazz) { + constructor(menu: MatteryMenu, clazz: Class, state: KMutableProperty0?, allowedValues: Set? = null) : this(menu, clazz, allowedValues = allowedValues) { if (state != null) { with(state) } } - constructor(menu: MatteryMenu, clazz: Class, state: GetterSetter?) : this(menu, clazz) { + constructor(menu: MatteryMenu, clazz: Class, state: GetterSetter?, allowedValues: Set? = null) : this(menu, clazz, allowedValues = allowedValues) { if (state != null) { with(state) } } - constructor(menu: MatteryMenu, clazz: Class, allowSpectators: Boolean, state: KMutableProperty0?) : this(menu, clazz, allowSpectators) { + constructor(menu: MatteryMenu, clazz: Class, allowSpectators: Boolean, state: KMutableProperty0?, allowedValues: Set? = null) : this(menu, clazz, allowSpectators, allowedValues = allowedValues) { if (state != null) { with(state) } } - constructor(menu: MatteryMenu, clazz: Class, allowSpectators: Boolean, state: GetterSetter?) : this(menu, clazz, allowSpectators) { + constructor(menu: MatteryMenu, clazz: Class, allowSpectators: Boolean, state: GetterSetter?, allowedValues: Set? = null) : this(menu, clazz, allowSpectators, allowedValues = allowedValues) { if (state != null) { with(state) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt index 373f7390e..3cebf19d1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt @@ -10,7 +10,7 @@ import ru.dbotthepony.mc.otm.block.entity.storage.IItemMonitorPlayerSettings import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorBlockEntity import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorPlayerSettings import ru.dbotthepony.mc.otm.container.get -import ru.dbotthepony.mc.otm.core.collect.mapToInt +import ru.dbotthepony.mc.otm.core.collect.map import ru.dbotthepony.mc.otm.core.collect.reduce import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu @@ -206,7 +206,7 @@ class ItemMonitorMenu( return ItemStack.EMPTY } } else { - if (crafted > 0 && crafted >= tile.craftingGrid.iterator().mapToInt { it.maxStackSize }.reduce(Int.MAX_VALUE, Int::coerceAtMost)) { + if (crafted > 0 && crafted >= tile.craftingGrid.iterator().map { it.maxStackSize }.reduce(Int.MAX_VALUE, Int::coerceAtMost)) { return ItemStack.EMPTY } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageBusMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageBusMenu.kt index e35fa3867..f4efb96b0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageBusMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageBusMenu.kt @@ -2,33 +2,32 @@ package ru.dbotthepony.mc.otm.menu.storage import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.block.entity.storage.StorageBusBlockEntity +import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.IntInputWithFeedback +import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus -class StorageBusMenu @JvmOverloads constructor( +class StorageBusMenu( containerId: Int, inventory: Inventory, tile: StorageBusBlockEntity? = null ) : MatteryPoweredMenu(MMenus.STORAGE_BUS, containerId, inventory, tile) { val busFilterSlots: List - val busFilterState: BooleanInputWithFeedback - val insertPriority: IntInputWithFeedback - val extractPriority: IntInputWithFeedback + val busFilterState = BooleanInputWithFeedback(this, tile?.let { it.filter::isWhitelist }) + val insertPriority = IntInputWithFeedback(this, tile?.let { it::insertPriority }) + val extractPriority = IntInputWithFeedback(this, tile?.let { it::extractPriority }) + val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) + val mode = EnumInputWithFeedback(this, tile?.let { it::mode }, FlowDirection.WITHOUT_NONE) init { if (tile != null) { busFilterSlots = addFilterSlots(tile.filter) - busFilterState = BooleanInputWithFeedback(this, tile.filter::isWhitelist) - insertPriority = IntInputWithFeedback(this, tile::insertPriority) - extractPriority = IntInputWithFeedback(this, tile::extractPriority) } else { busFilterSlots = addFilterSlots(StorageBusBlockEntity.MAX_FILTERS) - busFilterState = BooleanInputWithFeedback(this) - insertPriority = IntInputWithFeedback(this) - extractPriority = IntInputWithFeedback(this) } addStorageSlot(batterySlot) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/storage_controls.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/storage_controls.png index 5955c8eff8e2a38ed3a539a9918b665f847bfee1..d12fd2d82aeeed5f03e5e0b35b1ae681c3cb7ba2 100644 GIT binary patch delta 972 zcmV;-12g>32Gs|U7k@Sg1^@s6N1l!&0004nX+uL$Nkc;*aB^>EX>4Tx04R}tkv&Mm zKp2MKri!JsIM_kNAxL$yi;6gwDi*;)X)CnqU~=gnG-*guTpR`0f`dPcRRY3ZEzi6g8cDa7Z*lLlRo z_>t?f%Ws^^4huXpV&pRO#1Ue#+{1DYvx=b-&k#oyRik_%@3O*qi?dp5u+BaC3qwV1 zCChc1qex;2DSxCPLPi5s)Lo3{OZY}@Sg;(sB85bAY75CqvP#`we-pRd^YSGiT4RXPUfNsy(m(b4lg}e>30tN*5?-F{QjvEM@CxfxYQm$ z)1zAesAp+9vGsu5up#O6{Jy1QmPd1L$T^48=zkG!9`$H?9`(f0wx~i!>&Clf4I_|E zLPslpa);>bSa02q9F}AxNTw5A}gDX7zHv?W!oolkpoUT7ZypYNh@K-SLV*wH#wPo4|Q8a}tC zO@Ftaq?I}YptFc})Bb&?L4IvMT+u@?U5HMP;;S2UQ$Kg-y! z+2pO+;qJ0n*6X3p$mV|UfzWoc9!~EdS^UNl9D*PSf~@n$x9t3@95Z#klN$9jAM?$LepB7!5(tj`{)j{VM{B6#yLo0000EX>4Tx04R}tkv&Mm zP!xqvQ>7v;9qb??n4vmZ5EXHhDi*;)X)CnqVDi#GXws0RxHt-~1qXi?s}3&Cx;nTD zg5VE`tBaGOi(b z_>t?f%Ws@Z4huXpVr0|v#1Ue#)Wvcav$CNQPZLKKRik_%=d!|ii?dp-vv!~Sg~5Wh zlHoelFcMfo5`QU(kWohkRal78u90FQP3LhB|B&NPkxM351&kaEs6mC~_`(0+_iWAL z)TEmfj03$dw*4^*1a^T|!?wSVZM$^>_@99*t>dpXf!R;e8yzir1cbMNi|dXi?*W%P zz~GZE8ImLUsf1z?ct4|W$^!$pK>wOMxAr+sAAl^)YJd3#I5-5xN|e3s@$SCvx&3>m zJ-;6`5^|0*NWB37000JJOGiWi000000Qp0^e*gdg32;bRa{vGf6951U69E94oEQKA z00(qQO+^Ri0}TTg8~^{%v;Y7BOi4sRRA}DqnqdyZAP9xqrpMy=+^hR#Vu%_*aCUoN zvZPro$bS>a)Ex%^0K~)04>Lcz*m*10s>NzOL+B)ttzwrdh+G_LtM*~_Wl5lGg~&v7 zmhZ~5HXtH8iRdijr63l8nE9z~)%MFLON)D@$aQc<98Yla9gU6JSMe|3)6S=t$)lL> z%#0pQT4vVFB8~#owk*q{*M3{is*Kh+)Qr(g+J9TBo{W~`WF}^|jc!Jd9RJ#{29L-g ztz*!ar(lSf;vmez4v`S{lvq`l@MOZ}Xi8H#&8rh7pvvo#C zRz5|qN;2$Zoa{v%NujdPKt%PlK4TFsTp0?an4BDcXZh> zs>?&4>$3S-UAFw9%eJe!e0WorN6d4&W^%3+i8gBsu7vLeE5WsVu#^uL!ppkGmRuU9 z8W5L5f*vLR+#GT&8HjRrQ)_q>;xUIm;_!72pLh6-!)F~n=kN{S`92Q23zP!!-R%FU z;ZZ1ELLz~GoN~ikNF8RQQu1z>c-1%iXTL~sQ>uzJ8RdMZN>7QHUoYZ*RwVs8@Tq&e+k6_t4!E&&& z4c65JXO6oIR4JU>*+D5KZEcW4;;?^ryr++GJJr950I;XEWYpo z3dKM&!QHTp_5|kE?O;~^nyXe#P(F$A&`VYdJl+u?<{B|g(zlzX7l)i4|gfeWt zgYJtj-gh1EfFI$QEg_U>G`Ot;jI;2#X^8gVZNG+>4KD^a;dHMDKLsn{#qd(F#MP)K zh%#)w7l<-Wby7xcJ4Rpw1mkTpFE|aY4x-GfR(?t(RCpi}3nT#51j-HJBP!6rLZ+;g zB8z&$m!gKP{5Qpee_l$@*{730OhT-}`QhWqHHM3T5F6bki*HRt?T*oHHD0Fx0gxQ0 zrL5_=sW%6NS#T?u2e=l)xnQaKAjZx7ULeM2os|2)saRVWh~>VI&_R^DW#y-YL?|g0 z%m|u#>FbaRD3*t4LJpDcZaP0{#SwO&O<+Afa8IER~gJf(TqDn%1-6`a(x>{h_jN(N0$zeVWS zb{=+X&)*dOq}WG&;v}OE-v(uvyTYP!fS9|g zXaH_gm9_J5miOeQkdrj4i_&_#gX6v_e3#m4LZTgQrAXv+PHH*fRIC*Y5?cl$bP%=7 zTKS+ky}aa{Vg|(?r7G}852~DI*LEEA8He?1;D!W&`%?HmVk(C13)QzWJX@QrII@sPK=H z0glejhU?p?*LMjK^CC8csyvQy%$2UHSuu9O)P7BuDz|npZQ6qf9iO>v<)`sG^Kii8 zbu4aZv1j-=(I~IaXt)N8takw3)JojkQireuFd(<-qMcq5~i>mA> z>PnPXN|>4=jmDTlA*QDGCtgaq)K61cyAplf!FR!r;bnxe`wMq=$t%TO+;*VL&M%$1 zwU5DFr*iT}Z*{14ZuvjLB??Fxb$-`iOF1AUAkF_;+~{yO2-wDajk~Jrs0=_BOqd#g Uroo1(ZGn)0+;;7WsmXrvH-lyp`~Uy| delta 410 zcmexjJ70H#sFVr=1WW@`fHP6R^gIiVFHRwz9=|h@)<6FCZ;o!A23NVF};}FARxxX z%&<9-TbGH6RUa(M>J1iUP2RkPcO4TGhcH-_Lmw>4;l6o>fCLj0S0Y%Hs}>~6$u$*X zAH!rv;We9Q3NK`2;(0x}fmfQ59juF2esh6n3L_I=D_9rbLa->`&dprn3mBOMqQRm9 zw!#{S6eL^z(||9>V1mjCPwfB!T52de$gHu Date: Sat, 12 Aug 2023 01:13:42 +0700 Subject: [PATCH 0955/1199] Allow to remove subscribers while iterating them --- .../dbotthepony/mc/otm/core/ISubscripable.kt | 49 ++++++++++++++++--- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/ISubscripable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/ISubscripable.kt index ff17bd269..2dabdfb28 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/ISubscripable.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/ISubscripable.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.core import it.unimi.dsi.fastutil.booleans.BooleanConsumer import it.unimi.dsi.fastutil.floats.FloatConsumer +import it.unimi.dsi.fastutil.objects.ReferenceArraySet import it.unimi.dsi.fastutil.objects.ReferenceLinkedOpenHashSet import java.util.function.Consumer import java.util.function.DoubleConsumer @@ -23,22 +24,28 @@ interface ISubscriptable { class Impl : ISubscriptable, Consumer { private inner class L(val callback: Consumer) : ISubscriptable.L { + private var isRemoved = false + init { subscribers.add(this) } override fun remove() { - subscribers.remove(this) + isRemoved = true + queue.add(this) } } private val subscribers = ReferenceLinkedOpenHashSet(0) + private val queue = ReferenceArraySet(0) override fun addListener(listener: Consumer): ISubscriptable.L { return L(listener) } override fun accept(t: V) { + queue.forEach { subscribers.remove(it) } + queue.clear() subscribers.forEach { it.callback.accept(t) } } } @@ -67,22 +74,28 @@ interface IFloatSubcripable : ISubscriptable { class Impl : IFloatSubcripable, Consumer, FloatConsumer { private inner class L(val callback: FloatConsumer) : ISubscriptable.L { + private var isRemoved = false + init { subscribers.add(this) } override fun remove() { - subscribers.remove(this) + isRemoved = true + queue.add(this) } } private val subscribers = ReferenceLinkedOpenHashSet(0) + private val queue = ReferenceArraySet(0) override fun addListener(listener: FloatConsumer): ISubscriptable.L { return L(listener) } override fun accept(t: Float) { + queue.forEach { subscribers.remove(it) } + queue.clear() subscribers.forEach { it.callback.accept(t) } } } @@ -98,22 +111,28 @@ interface IDoubleSubcripable : ISubscriptable { class Impl : IDoubleSubcripable, Consumer, DoubleConsumer { private inner class L(val callback: DoubleConsumer) : ISubscriptable.L { + private var isRemoved = false + init { subscribers.add(this) } override fun remove() { - subscribers.remove(this) + isRemoved = true + queue.add(this) } } private val subscribers = ReferenceLinkedOpenHashSet(0) + private val queue = ReferenceArraySet(0) override fun addListener(listener: DoubleConsumer): ISubscriptable.L { return L(listener) } override fun accept(t: Double) { + queue.forEach { subscribers.remove(it) } + queue.clear() subscribers.forEach { it.callback.accept(t) } } } @@ -129,22 +148,28 @@ interface IIntSubcripable : ISubscriptable { class Impl : IIntSubcripable, Consumer, IntConsumer { private inner class L(val callback: IntConsumer) : ISubscriptable.L { + private var isRemoved = false + init { subscribers.add(this) } override fun remove() { - subscribers.remove(this) + isRemoved = true + queue.add(this) } } private val subscribers = ReferenceLinkedOpenHashSet(0) + private val queue = ReferenceArraySet(0) override fun addListener(listener: IntConsumer): ISubscriptable.L { return L(listener) } override fun accept(t: Int) { + queue.forEach { subscribers.remove(it) } + queue.clear() subscribers.forEach { it.callback.accept(t) } } } @@ -160,22 +185,28 @@ interface ILongSubcripable : ISubscriptable { class Impl : ILongSubcripable, Consumer, LongConsumer { private inner class L(val callback: LongConsumer) : ISubscriptable.L { + private var isRemoved = false + init { subscribers.add(this) } override fun remove() { - subscribers.remove(this) + isRemoved = true + queue.add(this) } } private val subscribers = ReferenceLinkedOpenHashSet(0) + private val queue = ReferenceArraySet(0) override fun addListener(listener: LongConsumer): ISubscriptable.L { return L(listener) } override fun accept(t: Long) { + queue.forEach { subscribers.remove(it) } + queue.clear() subscribers.forEach { it.callback.accept(t) } } } @@ -191,22 +222,28 @@ interface IBooleanSubscriptable : ISubscriptable { class Impl : IBooleanSubscriptable, Consumer, BooleanConsumer { private inner class L(val callback: BooleanConsumer) : ISubscriptable.L { + private var isRemoved = false + init { subscribers.add(this) } override fun remove() { - subscribers.remove(this) + isRemoved = true + queue.add(this) } } private val subscribers = ReferenceLinkedOpenHashSet(0) + private val queue = ReferenceArraySet(0) override fun addListener(listener: BooleanConsumer): ISubscriptable.L { return L(listener) } override fun accept(t: Boolean) { + queue.forEach { subscribers.remove(it) } + queue.clear() subscribers.forEach { it.callback.accept(t) } } } From 1afa8e3d215a3192543795f9e8985252a8bdc231 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 12 Aug 2023 11:44:49 +0700 Subject: [PATCH 0956/1199] Flatten filter slots to just gettersetter --- .../entity/storage/StorageBusBlockEntity.kt | 2 +- .../block/entity/storage/StorageInterfaces.kt | 4 +- .../panels/input/NetworkNumberInputPanel.kt | 2 +- .../screen/panels/slot/FilterSlotPanel.kt | 15 +-- .../screen/storage/DriveViewerScreen.kt | 1 - .../client/screen/tech/EnergyCounterScreen.kt | 3 +- .../screen/tech/EssenceStorageScreen.kt | 28 ++--- .../mc/otm/container/ItemFilter.kt | 119 ++---------------- .../otm/core/collect/JsonArraySpliterator.kt | 2 +- .../otm/item/PortableCondensationDriveItem.kt | 6 +- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 65 +++++----- .../input/AbstractPlayerInputWithFeedback.kt | 3 +- .../mc/otm/menu/input/InstantBooleanInput.kt | 2 +- .../mc/otm/menu/matter/MatterPanelMenu.kt | 4 +- .../mc/otm/menu/storage/DriveViewerMenu.kt | 61 ++++----- .../mc/otm/menu/storage/StorageBusMenu.kt | 9 +- .../otm/menu/storage/StorageExporterMenu.kt | 16 +-- .../otm/menu/storage/StorageImporterMenu.kt | 24 +--- .../mc/otm/network/MenuNetworkChannel.kt | 5 +- 19 files changed, 108 insertions(+), 263 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt index 45d3a1716..dd37cadf8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt @@ -121,7 +121,7 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter } } - val filter = ItemFilter(MAX_FILTERS) { _, _, _ -> + val filter = ItemFilter(MAX_FILTERS) { component?.scan() setChangedLight() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt index 2a5db7efc..1b2ed459e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt @@ -113,7 +113,7 @@ abstract class AbstractStorageImportExport( class StorageImporterBlockEntity( blockPos: BlockPos, blockState: BlockState ) : AbstractStorageImportExport(MBlockEntities.STORAGE_IMPORTER, blockPos, blockState), IItemHandler { - override val filter = ItemFilter(MAX_FILTERS) { _, _, _ -> + override val filter = ItemFilter(MAX_FILTERS) { setChangedLight() } @@ -262,7 +262,7 @@ class StorageExporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : relevantTuples.remove(id) } - override val filter = ItemFilter(MAX_FILTERS) { _, _, _ -> + override val filter = ItemFilter(MAX_FILTERS) { relevantTuples.clear() val component = cell.graph.getVirtualComponent(StorageStack.ITEMS) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkNumberInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkNumberInputPanel.kt index 53d3ac70d..f37fc4501 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkNumberInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/NetworkNumberInputPanel.kt @@ -34,7 +34,7 @@ open class NetworkNumberInputPanel @JvmOverloads constructor( ) : this( screen = screen, parent = parent, - callback = widget::input, + callback = widget::accept, isAvailable = { widget.allowSpectators || minecraft.player?.isSpectator != true }, networkValue = networkValue, x = x, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/FilterSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/FilterSlotPanel.kt index 5cb0b7ef5..e3f67d5ea 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/FilterSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/FilterSlotPanel.kt @@ -3,14 +3,12 @@ package ru.dbotthepony.mc.otm.client.screen.panels.slot import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel -import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot -import ru.dbotthepony.mc.otm.container.ItemFilterSlotPacket -import ru.dbotthepony.mc.otm.network.MenuNetworkChannel +import ru.dbotthepony.mc.otm.core.GetterSetter open class FilterSlotPanel> @JvmOverloads constructor( screen: S, parent: EditablePanel<*>?, - val slot: ItemFilterNetworkSlot, + val slot: GetterSetter, x: Float = 0f, y: Float = 0f, width: Float = SIZE, @@ -21,14 +19,7 @@ open class FilterSlotPanel> @JvmOverloads constructor( } override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { - if (!screen.menu.ply.isSpectator) { - if (screen.menu.carried.isEmpty) { - MenuNetworkChannel.sendToServer(ItemFilterSlotPacket(slot.networkID, ItemStack.EMPTY)) - } else { - MenuNetworkChannel.sendToServer(ItemFilterSlotPacket(slot.networkID, screen.menu.carried)) - } - } - + slot.accept(screen.menu.carried) return true } } 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 c82f8b38e..95769454c 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 @@ -63,7 +63,6 @@ class DriveViewerScreen(menu: DriveViewerMenu, inventory: Inventory, title: Comp val filterGrid = GridPanel(this, frame, width = AbstractSlotPanel.SIZE * 3f, height = AbstractSlotPanel.SIZE * 4f, rows = 3, columns = 4) filterGrid.dock = Dock.FILL filterGrid.dockResize = DockResizeMode.NONE - filterGrid.dockTop = 20f settings.add(filterGrid) for (i in 0 until PortableCondensationDriveItem.MAX_FILTERS) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt index b21634eb0..b8a2c2060 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt @@ -11,7 +11,6 @@ import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.input.NetworkNumberInputPanel import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.menu.tech.EnergyCounterMenu -import java.util.function.Supplier class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { override fun makeMainFrame(): FramePanel> { @@ -43,7 +42,7 @@ class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title: } if (!menu.ply.isSpectator) { - val button = ButtonPanel(this, frame, 0f, 0f, 0f, 20f, TranslatableComponent("block.overdrive_that_matters.energy_counter.switch"), onPress = Runnable { menu.switchDirection.input(null) }) + val button = ButtonPanel(this, frame, 0f, 0f, 0f, 20f, TranslatableComponent("block.overdrive_that_matters.energy_counter.switch"), onPress = Runnable { menu.switchDirection.accept(null) }) button.dock = Dock.TOP button.setDockMargin(4f, 5f, 4f, 0f) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt index f1bd75821..b7d3b7a2e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt @@ -100,7 +100,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title } override fun onClick(mouseButton: Int) { - menu.storeLevels.input(1) + menu.storeLevels.accept(1) } override var isDisabled: Boolean @@ -115,7 +115,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title } override fun onClick(mouseButton: Int) { - menu.storeLevels.input(10) + menu.storeLevels.accept(10) } override var isDisabled: Boolean @@ -130,7 +130,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title } override fun onClick(mouseButton: Int) { - menu.storeLevels.input((minecraft?.player?.experienceLevel ?: 0) + 1) + menu.storeLevels.accept((minecraft?.player?.experienceLevel ?: 0) + 1) } override var isDisabled: Boolean @@ -145,7 +145,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title } override fun onClick(mouseButton: Int) { - menu.dispenseLevels.input(1) + menu.dispenseLevels.accept(1) } override var isDisabled: Boolean @@ -160,7 +160,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title } override fun onClick(mouseButton: Int) { - menu.dispenseLevels.input(10) + menu.dispenseLevels.accept(10) } override var isDisabled: Boolean @@ -175,7 +175,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title } override fun onClick(mouseButton: Int) { - menu.dispenseLevels.input(getLevelFromXp(menu.experienceStored) + 1) + menu.dispenseLevels.accept(getLevelFromXp(menu.experienceStored) + 1) } override var isDisabled: Boolean @@ -192,7 +192,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title } override fun onClick(mouseButton: Int) { - menu.storeLevels.input(customDispense) + menu.storeLevels.accept(customDispense) } override var isDisabled: Boolean @@ -211,12 +211,12 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title if (player.experienceLevel == customDispense) { if (player.experienceProgress > 0f) { - menu.storeLevels.input(1) + menu.storeLevels.accept(1) } } else if (player.experienceLevel > customDispense) { - menu.storeLevels.input(player.experienceLevel - customDispense) + menu.storeLevels.accept(player.experienceLevel - customDispense) } else { - menu.dispenseLevels.input(customDispense - player.experienceLevel) + menu.dispenseLevels.accept(customDispense - player.experienceLevel) } playGuiClickSound() @@ -233,7 +233,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title } override fun onClick(mouseButton: Int) { - menu.dispenseLevels.input(customDispense) + menu.dispenseLevels.accept(customDispense) } override var isDisabled: Boolean @@ -253,12 +253,12 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title if (player.experienceLevel == customDispense) { if (player.experienceProgress > 0f) { - menu.storeLevels.input(1) + menu.storeLevels.accept(1) } } else if (player.experienceLevel > customDispense) { - menu.storeLevels.input(player.experienceLevel - customDispense) + menu.storeLevels.accept(player.experienceLevel - customDispense) } else { - menu.dispenseLevels.input(customDispense - player.experienceLevel) + menu.dispenseLevels.accept(customDispense - player.experienceLevel) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemFilter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemFilter.kt index 668f7d1c5..da7ab048f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemFilter.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemFilter.kt @@ -17,98 +17,13 @@ import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.core.nbt.set import java.util.Arrays import java.util.LinkedList +import java.util.function.Consumer import java.util.function.Supplier -data class ItemFilterSlotPacket(val slotID: Int, val newValue: ItemStack) : MatteryPacket { - override fun write(buff: FriendlyByteBuf) { - buff.writeInt(slotID) - buff.writeItemStack(newValue, true) - } - - override fun play(context: Supplier) { - context.get().packetHandled = true - - if (context.get().sender != null) { - context.get().enqueueWork { - playServer(context.get().sender!!) - } - } else { - context.get().enqueueWork { - playClient() - } - } - } - - fun playClient() { - val menu = minecraft.player?.containerMenu as? MatteryMenu ?: throw IllegalStateException("No MatteryMenu is open right now, can't handle ItemFilterSlotReplicaPacket") - menu.filterSlots[slotID].set(newValue) - } - - fun playServer(player: ServerPlayer) { - if (player.isSpectator) { - return - } - - val menu = player.containerMenu as? MatteryMenu ?: return LOGGER.error("No MatteryMenu is open right now, can't handle ItemFilterSlotReplicaPacket from $player") - val slot = menu.filterSlots.getOrNull(slotID) ?: return LOGGER.error("ItemFilterSlotReplicaPacket: unknown slot $slotID from $player in $menu!") - - if (slot.filter?.isLocked == true) - return - - slot.set(newValue) - } - - companion object { - fun read(buff: FriendlyByteBuf): ItemFilterSlotPacket { - return ItemFilterSlotPacket(buff.readInt(), buff.readItem()) - } - - private val LOGGER = LogManager.getLogger() - } -} - -data class ItemFilterNetworkSlot(val slotID: Int, val networkID: Int, var filter: ItemFilter?) { - fun get() = filter?.get(slotID) ?: remote - fun set(value: ItemStack) { - if (filter != null) - filter!![slotID] = value - else - remote = value - } - - private var remote: ItemStack = ItemStack.EMPTY - - fun sendChanges(full: Boolean = false): ItemFilterSlotPacket? { - requireNotNull(filter) { "Invalid side" } - - if (full || !ItemStack.isSameItemSameTags(remote, get())) { - remote = get() - return ItemFilterSlotPacket(networkID, get()) - } - - return null - } -} - -fun interface ItemFilterCallback { - fun invoke(slot: Int?, oldValue: ItemStack?, newValue: ItemStack?) -} - -fun interface ItemFilterFullCallback { - fun invoke(self: ItemFilter, slot: Int?, oldValue: ItemStack?, newValue: ItemStack?) -} - class ItemFilter( val size: Int, - private val modified: ItemFilterFullCallback? = null + private val modified: Consumer? = null ) : INBTSerializable { - constructor(size: Int, modified: ItemFilterCallback?) : - this(size, - modified?.let { - fn -> - return@let ItemFilterFullCallback { _: ItemFilter, slot: Int?, oldValue: ItemStack?, newValue: ItemStack? -> fn.invoke(slot, oldValue, newValue) } - }) - private val filter = Array(size) { ItemStack.EMPTY } private val linkedFilter = LinkedList() @@ -118,7 +33,7 @@ class ItemFilter( set(value) { if (value != field) { field = value - modified?.invoke(this, null, null, null) + modified?.accept(this) } } @@ -126,7 +41,7 @@ class ItemFilter( set(value) { if (value != field) { field = value - modified?.invoke(this, null, null, null) + modified?.accept(this) } } @@ -134,7 +49,7 @@ class ItemFilter( set(value) { if (value != field) { field = value - modified?.invoke(this, null, null, null) + modified?.accept(this) } } @@ -146,27 +61,7 @@ class ItemFilter( Arrays.fill(filter, ItemStack.EMPTY) linkedFilter.clear() - modified?.invoke(this, null, null, null) - } - - fun copyFrom(other: ItemFilter) { - require(other.size == size) { "Size differs (this filter has size of $size, other has size of ${other.size})" } - - linkedFilter.clear() - - for (i in 0 until size) { - filter[i] = other.filter[i] - - if (!filter[i].isEmpty) { - linkedFilter.add(filter[i]) - } - } - - isWhitelist = other.isWhitelist - matchTag = other.matchTag - matchNBT = other.matchNBT - - modified?.invoke(this, null, null, null) + modified?.accept(this) } operator fun set(index: Int, value: ItemStack) { @@ -187,7 +82,7 @@ class ItemFilter( if (!filter[index].isEmpty) linkedFilter.add(filter[index]) - modified?.invoke(this, index, old, filter[index]) + modified?.accept(this) } operator fun get(index: Int): ItemStack = filter[index].copy() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/JsonArraySpliterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/JsonArraySpliterator.kt index c6ac299d3..86eda1eb5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/JsonArraySpliterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/JsonArraySpliterator.kt @@ -27,4 +27,4 @@ class JsonArraySpliterator(private val obj: JsonArray, offset: Int = 0, private } fun JsonArray.elementSpliterator() = JsonArraySpliterator(this) -fun JsonArray.stream(): Stream = StreamSupport.stream(elementSpliterator(), false) +fun JsonArray.stream(): Stream = StreamSupport.stream(elementSpliterator(), false) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableCondensationDriveItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableCondensationDriveItem.kt index 4a4823dfe..74e64c601 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableCondensationDriveItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableCondensationDriveItem.kt @@ -22,6 +22,8 @@ import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.capability.drive.DrivePool import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.core.nbt.map +import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.core.tagNotNull import java.math.BigInteger import java.util.* @@ -86,9 +88,11 @@ class PortableCondensationDriveItem(capacity: Int) : } fun getFilterSettings(drive: ItemStack): ItemFilter { - val filter = ItemFilter(MAX_FILTERS) + var ignore = true + val filter = ItemFilter(MAX_FILTERS) { if (!ignore) drive.tagNotNull[FILTER_PATH] = it.serializeNBT() } filter.isWhitelist = true drive.tag?.map(FILTER_PATH, filter::deserializeNBT) + ignore = false return filter } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 5a0bc74e8..99dffd41f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -34,7 +34,6 @@ import ru.dbotthepony.mc.otm.compat.cos.cosmeticArmorSlots import ru.dbotthepony.mc.otm.compat.curios.curiosSlots import ru.dbotthepony.mc.otm.compat.curios.isCurioSlot import ru.dbotthepony.mc.otm.container.ItemFilter -import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.UpgradeContainer import ru.dbotthepony.mc.otm.core.GetterSetter @@ -46,6 +45,7 @@ import ru.dbotthepony.mc.otm.core.util.BigDecimalValueCodec import ru.dbotthepony.mc.otm.core.util.BinaryStringCodec import ru.dbotthepony.mc.otm.core.util.BooleanValueCodec import ru.dbotthepony.mc.otm.core.util.IStreamCodec +import ru.dbotthepony.mc.otm.core.util.ItemStackValueCodec import ru.dbotthepony.mc.otm.core.util.ItemValueCodec import ru.dbotthepony.mc.otm.core.util.NullValueCodec import ru.dbotthepony.mc.otm.core.util.VarIntValueCodec @@ -66,6 +66,7 @@ import java.io.DataOutputStream import java.math.BigDecimal import java.util.* import java.util.function.BooleanSupplier +import java.util.function.Consumer import java.util.function.DoubleSupplier import java.util.function.IntSupplier import java.util.function.Predicate @@ -90,7 +91,7 @@ data class UpgradeSlots( val currentStats: IMatteryUpgrade ) -abstract class MatteryMenu @JvmOverloads protected constructor( +abstract class MatteryMenu( menuType: MenuType<*>?, containerId: Int, val inventory: Inventory, @@ -137,7 +138,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( /** * Client->Server input */ - inner class PlayerInput(val codec: IStreamCodec, allowSpectators: Boolean = false, val handler: (V) -> Unit) : Predicate { + inner class PlayerInput(val codec: IStreamCodec, allowSpectators: Boolean = false, val handler: (V) -> Unit) : Consumer, Predicate { val id = playerInputs.size var allowSpectators by mSynchronizer.bool(allowSpectators).property @@ -161,7 +162,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( return filters.all { it.test(player) } } - fun input(value: V) { + override fun accept(value: V) { if (test(minecraft.player as Player?)) { val stream = FastByteArrayOutputStream() codec.write(DataOutputStream(stream), value) @@ -183,6 +184,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( fun bigDecimalInput(allowSpectators: Boolean = false, handler: (BigDecimal) -> Unit) = PlayerInput(BigDecimalValueCodec, allowSpectators, handler) fun booleanInput(allowSpectators: Boolean = false, handler: (Boolean) -> Unit) = PlayerInput(BooleanValueCodec, allowSpectators, handler) fun itemInput(allowSpectators: Boolean = false, handler: (Item) -> Unit) = PlayerInput(ItemValueCodec, allowSpectators, handler) + fun itemStackInput(allowSpectators: Boolean = false, handler: (ItemStack) -> Unit) = PlayerInput(ItemStackValueCodec, allowSpectators, handler) fun nullableItemInput(allowSpectators: Boolean = false, handler: (Item?) -> Unit) = PlayerInput(ItemValueCodec.nullable, allowSpectators, handler) fun stringInput(allowSpectators: Boolean = false, handler: (String) -> Unit) = PlayerInput(BinaryStringCodec, allowSpectators, handler) fun intInput(allowSpectators: Boolean = false, handler: (Int) -> Unit) = PlayerInput(VarIntValueCodec, allowSpectators, handler) @@ -230,34 +232,47 @@ abstract class MatteryMenu @JvmOverloads protected constructor( protected val lockedInventorySlots: MutableSet = HashSet() protected open fun isInventorySlotLocked(index: Int): Boolean = lockedInventorySlots.contains(index) - private val _filterSlots = ArrayList() - val filterSlots: List = Collections.unmodifiableList(_filterSlots) - protected var inventorySlotIndexStart = 0 protected var inventorySlotIndexEnd = 0 private val playerPacketDistributor = PacketDistributor.PLAYER.with { ply as ServerPlayer } - fun addFilterSlots(slots: ItemFilter): List { - val result = ArrayList(slots.size) + fun addFilterSlots(slots: ItemFilter): List> { + val result = ArrayList>(slots.size) for (i in 0 until slots.size) { - _filterSlots.add(ItemFilterNetworkSlot(i, _filterSlots.size, slots).also(result::add)) + result.add(GetterSetter.of( + mSynchronizer.computedItem { slots[i] }, + itemStackInput { slots[i] = it } + )) } return result } - fun addFilterSlots(amount: Int): List { - val result = ArrayList(amount) + fun addFilterSlots(amount: Int): List> { + val result = ArrayList>(amount) for (i in 0 until amount) { - _filterSlots.add(ItemFilterNetworkSlot(i, _filterSlots.size, null).also(result::add)) + result.add(GetterSetter.of( + mSynchronizer.computedItem { ItemStack.EMPTY }, + itemStackInput { throw UnsupportedOperationException() } + )) } return result } + fun addFilterSlots(slots: ItemFilter?, amount: Int): List> { + if (slots != null && amount != slots.size) + throw IllegalStateException("Provided ItemFiler has different amount of slots than expected: ${slots.size} != $amount") + + if (slots == null) + return addFilterSlots(amount) + else + return addFilterSlots(slots) + } + open inner class InventorySlot(container: Container, index: Int, x: Int = 0, y: Int = 0) : UserFilteredSlot(container, index, x, y) { override fun mayPlace(itemStack: ItemStack): Boolean { return !isInventorySlotLocked(index) && super.mayPlace(itemStack) @@ -285,7 +300,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( if (slotIndex in mattery.regularSlotFilters.indices) { filter = GetterSetter.of( getter = { mattery.regularSlotFilters[slotIndex].value }, - setter = nullableItemInput(true) { mattery.regularSlotFilters[slotIndex].value = it }::input + setter = nullableItemInput(true) { mattery.regularSlotFilters[slotIndex].value = it }::accept ) } @@ -294,20 +309,20 @@ abstract class MatteryMenu @JvmOverloads protected constructor( chargeFlag = GetterSetter.of( getter = { mattery.regularSlotChargeFlag[slotIndex].boolean }, - setter = input::input + setter = input::accept ) } } else if (container === mattery.exopackContainer) { filter = GetterSetter.of( getter = { mattery.exopackContainer.getSlotFilter(slotIndex) }, - setter = nullableItemInput(true) { mattery.exopackContainer.setSlotFilter(slotIndex, it) }::input + setter = nullableItemInput(true) { mattery.exopackContainer.setSlotFilter(slotIndex, it) }::accept ) val input = booleanInput(true) { if (it) mattery.exoPackSlotsChargeFlag.add(slotIndex) else mattery.exoPackSlotsChargeFlag.remove(slotIndex) } chargeFlag = GetterSetter.of( getter = { slotIndex in mattery.exoPackSlotsChargeFlag }, - setter = input::input + setter = input::accept ) } else { filter = null @@ -422,20 +437,6 @@ abstract class MatteryMenu @JvmOverloads protected constructor( } } - val consumer = PacketDistributor.PLAYER.with { ply as ServerPlayer } - - for (slot in _filterSlots) { - val packet = slot.sendChanges() - - if (packet != null) { - if (broadcastOnce) { - MenuNetworkChannel.send(consumer, packet) - } else { - MenuNetworkChannel.sendNow(consumer, packet) - } - } - } - broadcastOnce = true } @@ -494,7 +495,7 @@ abstract class MatteryMenu @JvmOverloads protected constructor( field = mSynchronizer.ComputedField(getter = { null }, ItemValueCodec.nullable) } - pSlot.filter = GetterSetter.of(getter = field::value, setter = input::input) + pSlot.filter = GetterSetter.of(getter = field::value, setter = input::accept) } return super.addSlot(pSlot) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt index 12480f58e..66c9fbfc8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/AbstractPlayerInputWithFeedback.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.menu.input import net.minecraft.world.entity.player.Player -import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.ISubscriptable import ru.dbotthepony.mc.otm.core.SentientGetterSetter @@ -39,7 +38,7 @@ abstract class AbstractPlayerInputWithFeedback : IPlayerInputWithFeedback } final override fun accept(t: V) { - input.input(t) + input.accept(t) } override fun test(player: Player?) = input.test(player) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/InstantBooleanInput.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/InstantBooleanInput.kt index 49204ce6b..2b1b7e85c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/InstantBooleanInput.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/input/InstantBooleanInput.kt @@ -20,6 +20,6 @@ class InstantBooleanInput(menu: MatteryMenu) : GetterSetter, BooleanSup override fun accept(t: Boolean) { value = t - input.input(t) + input.accept(t) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt index 67fdf18e4..44a315958 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt @@ -187,8 +187,8 @@ class MatterPanelMenu( val changeIsAscending = booleanInput(allowSpectators = true) { tile?.getPlayerSettings(ply)?.ascending = it } val changeSorting = PlayerInput(ItemSorter::class.codec(), allowSpectators = true) { tile?.getPlayerSettings(ply)?.sorter = it } - val sortingGS = GetterSetter.of(::sorting, changeSorting::input) - val isAscendingGS = GetterSetter.of(::isAscending, changeIsAscending::input) + val sortingGS = GetterSetter.of(::sorting, changeSorting::accept) + val isAscendingGS = GetterSetter.of(::isAscending, changeIsAscending::accept) private val actualComparator = Comparator { o1, o2 -> sorting.compare(o1.item, o2.item) * (if (isAscending) 1 else -1) } private val actualTaskComparator = Comparator { o1, o2 -> sorting.compare(o1.item, o2.item) * (if (isAscending) 1 else -1) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt index ebad3143d..9a5e139e9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt @@ -10,7 +10,10 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.drive.IMatteryDrive import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.container.ItemFilter +import ru.dbotthepony.mc.otm.core.GetterSetter +import ru.dbotthepony.mc.otm.core.asGetterSetter import ru.dbotthepony.mc.otm.core.ifPresentK +import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.util.ItemStorageStackSorter import ru.dbotthepony.mc.otm.item.PortableCondensationDriveItem import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu @@ -70,17 +73,30 @@ class DriveViewerMenu( addInventorySlots() } - val driveFilter = ItemFilter(PortableCondensationDriveItem.MAX_FILTERS) { self, _, _, _ -> - if (tile?.container?.get(0)?.item is PortableCondensationDriveItem) { - tile.container[0].getOrCreateTag().put(PortableCondensationDriveItem.FILTER_PATH, self.serializeNBT()) - } + var drivePresent by mSynchronizer.bool().property + + private fun getFilter(): ItemFilter? { + val stack = (tile as? DriveViewerBlockEntity)?.container?.getItem(0) + return (stack?.item as? PortableCondensationDriveItem)?.getFilterSettings(stack) } - val driveFilterSlots = addFilterSlots(driveFilter) + val driveFilterSlots = immutableList(PortableCondensationDriveItem.MAX_FILTERS) { i -> + GetterSetter.of( + mSynchronizer.computedItem { getFilter()?.get(i) ?: ItemStack.EMPTY }, + itemStackInput { getFilter()?.set(i, it) } + ) + } - val isWhitelist = BooleanInputWithFeedback(this) - val matchTag = BooleanInputWithFeedback(this) - val matchNBT = BooleanInputWithFeedback(this) + private fun make(mapper: (ItemFilter) -> GetterSetter): GetterSetter { + return GetterSetter.of( + { getFilter()?.let(mapper)?.get() ?: false }, + { getFilter()?.let(mapper)?.accept(it) } + ) + } + + val isWhitelist = BooleanInputWithFeedback(this, make { it::isWhitelist.asGetterSetter() }).also { it.filter { drivePresent } } + val matchTag = BooleanInputWithFeedback(this, make { it::matchTag.asGetterSetter() }).also { it.filter { drivePresent } } + val matchNBT = BooleanInputWithFeedback(this, make { it::matchNBT.asGetterSetter() }).also { it.filter { drivePresent } } override fun broadcastChanges() { super.broadcastChanges() @@ -99,37 +115,12 @@ class DriveViewerMenu( } } + drivePresent = lastDrive != null + if (prev != lastDrive) { prev?.let(powered!!::remove) this.networkedItemView.clear() lastDrive?.let(powered!!::add) - - if (lastDrive != null) { - val filter = (itemStack.item as? PortableCondensationDriveItem)?.getFilterSettings(itemStack) - - if (filter != null) { - driveFilter.copyFrom(filter) - driveFilter.isLocked = false - - isWhitelist.with(driveFilter::isWhitelist) - matchTag.with(driveFilter::matchTag) - matchNBT.with(driveFilter::matchNBT) - } else { - driveFilter.clear() - driveFilter.isLocked = true - - isWhitelist.clear() - matchTag.clear() - matchNBT.clear() - } - } else { - driveFilter.clear() - driveFilter.isLocked = true - - isWhitelist.clear() - matchTag.clear() - matchNBT.clear() - } } this.networkedItemView.network() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageBusMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageBusMenu.kt index f4efb96b0..c4fe3c48d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageBusMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageBusMenu.kt @@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.menu.storage import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.block.entity.storage.StorageBusBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection -import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback @@ -16,7 +15,7 @@ class StorageBusMenu( inventory: Inventory, tile: StorageBusBlockEntity? = null ) : MatteryPoweredMenu(MMenus.STORAGE_BUS, containerId, inventory, tile) { - val busFilterSlots: List + val busFilterSlots = addFilterSlots(tile?.filter, StorageBusBlockEntity.MAX_FILTERS) val busFilterState = BooleanInputWithFeedback(this, tile?.let { it.filter::isWhitelist }) val insertPriority = IntInputWithFeedback(this, tile?.let { it::insertPriority }) val extractPriority = IntInputWithFeedback(this, tile?.let { it::extractPriority }) @@ -24,12 +23,6 @@ class StorageBusMenu( val mode = EnumInputWithFeedback(this, tile?.let { it::mode }, FlowDirection.WITHOUT_NONE) init { - if (tile != null) { - busFilterSlots = addFilterSlots(tile.filter) - } else { - busFilterSlots = addFilterSlots(StorageBusBlockEntity.MAX_FILTERS) - } - addStorageSlot(batterySlot) addInventorySlots() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageExporterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageExporterMenu.kt index 168a26c07..b669facf2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageExporterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageExporterMenu.kt @@ -1,32 +1,22 @@ package ru.dbotthepony.mc.otm.menu.storage import net.minecraft.world.entity.player.Inventory -import net.minecraft.world.inventory.Slot import ru.dbotthepony.mc.otm.block.entity.storage.StorageExporterBlockEntity -import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback import ru.dbotthepony.mc.otm.registry.MMenus -class StorageExporterMenu @JvmOverloads constructor( +class StorageExporterMenu( p_38852_: Int, inventory: Inventory, tile: StorageExporterBlockEntity? = null ) : MatteryPoweredMenu( MMenus.STORAGE_EXPORTER, p_38852_, inventory, tile ) { - val busFilterSlots: List - val busFilterState: BooleanInputWithFeedback + val busFilterSlots = addFilterSlots(tile?.filter, StorageExporterBlockEntity.MAX_FILTERS) + val busFilterState = BooleanInputWithFeedback(this, tile?.let { it.filter::isWhitelist }) init { - if (tile != null) { - busFilterSlots = addFilterSlots(tile.filter) - busFilterState = BooleanInputWithFeedback(this, tile.filter::isWhitelist) - } else { - busFilterSlots = addFilterSlots(StorageExporterBlockEntity.MAX_FILTERS) - busFilterState = BooleanInputWithFeedback(this) - } - addInventorySlots() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageImporterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageImporterMenu.kt index 36415e95a..401bf92e6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageImporterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageImporterMenu.kt @@ -1,32 +1,18 @@ package ru.dbotthepony.mc.otm.menu.storage import net.minecraft.world.entity.player.Inventory -import net.minecraft.world.inventory.Slot import ru.dbotthepony.mc.otm.block.entity.storage.StorageImporterBlockEntity -import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback import ru.dbotthepony.mc.otm.registry.MMenus -class StorageImporterMenu @JvmOverloads constructor( - p_38852_: Int, - inventory: Inventory, - tile: StorageImporterBlockEntity? = null -) : MatteryPoweredMenu( - MMenus.STORAGE_IMPORTER, p_38852_, inventory, tile -) { - val busFilterSlots: List - val busFilterState: BooleanInputWithFeedback +class StorageImporterMenu( + containerId: Int, inventory: Inventory, tile: StorageImporterBlockEntity? = null +) : MatteryPoweredMenu(MMenus.STORAGE_IMPORTER, containerId, inventory, tile) { + val busFilterSlots = addFilterSlots(tile?.filter, StorageImporterBlockEntity.MAX_FILTERS) + val busFilterState = BooleanInputWithFeedback(this, tile?.let { it.filter::isWhitelist }) init { - if (tile != null) { - busFilterSlots = addFilterSlots(tile.filter) - busFilterState = BooleanInputWithFeedback(this, tile.filter::isWhitelist) - } else { - busFilterSlots = addFilterSlots(StorageImporterBlockEntity.MAX_FILTERS) - busFilterState = BooleanInputWithFeedback(this) - } - addInventorySlots() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt index 829d0fc6d..c49564815 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt @@ -5,11 +5,9 @@ import net.minecraft.network.FriendlyByteBuf import net.minecraft.world.item.ItemStack import net.minecraftforge.network.NetworkDirection import net.minecraftforge.network.NetworkEvent -import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorPlayerSettings import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.compat.InventoryScrollPacket -import ru.dbotthepony.mc.otm.container.ItemFilterSlotPacket import ru.dbotthepony.mc.otm.menu.ExopackInventoryMenu import ru.dbotthepony.mc.otm.menu.matter.CancelTaskPacket import ru.dbotthepony.mc.otm.menu.MatteryMenu @@ -74,12 +72,11 @@ class SetCarriedPacket(val item: ItemStack) : MatteryPacket { } object MenuNetworkChannel : MatteryNetworkChannel( - version = "3", + version = "4", name = "menu" ) { fun register() { add(SetCarriedPacket::class.java, SetCarriedPacket.Companion::read, NetworkDirection.PLAY_TO_CLIENT) - add(ItemFilterSlotPacket::class.java, ItemFilterSlotPacket.Companion::read) // networked item view add(ClearItemViewPacket::class.java, { ClearItemViewPacket }, NetworkDirection.PLAY_TO_CLIENT) From dba7f3ad8dac584831e6cb70b4bd0ab205b94693 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 12 Aug 2023 11:47:56 +0700 Subject: [PATCH 0957/1199] forgor --- .../dbotthepony/mc/otm/core/ISubscripable.kt | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/ISubscripable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/ISubscripable.kt index 2dabdfb28..5bbd7b52e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/ISubscripable.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/ISubscripable.kt @@ -31,8 +31,10 @@ interface ISubscriptable { } override fun remove() { - isRemoved = true - queue.add(this) + if (!isRemoved) { + isRemoved = true + queue.add(this) + } } } @@ -81,8 +83,10 @@ interface IFloatSubcripable : ISubscriptable { } override fun remove() { - isRemoved = true - queue.add(this) + if (!isRemoved) { + isRemoved = true + queue.add(this) + } } } @@ -118,8 +122,10 @@ interface IDoubleSubcripable : ISubscriptable { } override fun remove() { - isRemoved = true - queue.add(this) + if (!isRemoved) { + isRemoved = true + queue.add(this) + } } } @@ -155,8 +161,10 @@ interface IIntSubcripable : ISubscriptable { } override fun remove() { - isRemoved = true - queue.add(this) + if (!isRemoved) { + isRemoved = true + queue.add(this) + } } } @@ -192,8 +200,10 @@ interface ILongSubcripable : ISubscriptable { } override fun remove() { - isRemoved = true - queue.add(this) + if (!isRemoved) { + isRemoved = true + queue.add(this) + } } } @@ -229,8 +239,10 @@ interface IBooleanSubscriptable : ISubscriptable { } override fun remove() { - isRemoved = true - queue.add(this) + if (!isRemoved) { + isRemoved = true + queue.add(this) + } } } From d3ea51928fd006a2000c040750024df738f63df6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 12 Aug 2023 12:16:31 +0700 Subject: [PATCH 0958/1199] Fix storage importer --- .../block/entity/storage/StorageInterfaces.kt | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt index 1b2ed459e..879dad5d7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt @@ -39,7 +39,6 @@ import ru.dbotthepony.mc.otm.storage.ItemStorageStack import ru.dbotthepony.mc.otm.storage.StorageStack import java.math.BigInteger import java.util.* -import java.util.stream.Stream import kotlin.collections.ArrayList abstract class AbstractStorageImportExport( @@ -143,25 +142,25 @@ class StorageImporterBlockEntity( val wrapped = ItemStorageStack(stack) val view = cell.graph.getVirtualComponent(StorageStack.ITEMS) - val inserted = view.insertStack(wrapped, true) - if (inserted == wrapped) return stack + val leftover = view.insertStack(wrapped, true) + if (leftover == wrapped) return stack val required = StorageStack.ITEMS.energyPerInsert(wrapped) if (energy.extractEnergy(required, true) == required) { if (!simulate) { - val inserted2 = view.insertStack(wrapped, false) + val leftover2 = view.insertStack(wrapped, false) - if (inserted == inserted2) { + if (leftover == leftover2) { energy.extractEnergy(required, false) - return inserted.toItemStack() + return leftover.toItemStack() } else { - energy.extractEnergy(StorageStack.ITEMS.energyPerInsert(inserted2), false) - return inserted2.toItemStack() + energy.extractEnergy(StorageStack.ITEMS.energyPerInsert(leftover2), false) + return leftover2.toItemStack() } } - return inserted.toItemStack() + return leftover.toItemStack() } return stack @@ -208,10 +207,13 @@ class StorageImporterBlockEntity( if (extracted.isEmpty || !filter.match(extracted)) { lastSlot++ } else { - val accepted = acceptItem(extracted, true) - val extracted2 = target.extractItem(lastSlot, accepted.count, false) - acceptItem(extracted2, false) - nextTick += INTERVAL * 4 + val leftover = acceptItem(extracted, true) + + if (leftover.count != extracted.count) { + val extracted2 = target.extractItem(lastSlot, extracted.count - leftover.count, false) + acceptItem(extracted2, false) + nextTick += INTERVAL * 4 + } } } From 6c7f2226a6abc821375b3ccb27af3df84eae518e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 12 Aug 2023 14:49:24 +0700 Subject: [PATCH 0959/1199] Unify storage exportert/importer menus, profile their energy and add energy config --- .../block/entity/storage/StorageInterfaces.kt | 45 +++++---------- .../client/screen/storage/StorageBusScreen.kt | 2 +- .../screen/storage/StorageExporterScreen.kt | 36 ------------ .../storage/StorageImporterExporterScreen.kt | 55 +++++++++++++++++++ .../screen/storage/StorageImporterScreen.kt | 36 ------------ .../mc/otm/menu/storage/StorageBusMenu.kt | 2 + .../otm/menu/storage/StorageExporterMenu.kt | 22 -------- .../storage/StorageImporterExporterMenu.kt | 24 ++++++++ .../otm/menu/storage/StorageImporterMenu.kt | 18 ------ .../ru/dbotthepony/mc/otm/registry/MMenus.kt | 13 ++--- 10 files changed, 101 insertions(+), 152 deletions(-) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterExporterScreen.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageExporterMenu.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageImporterExporterMenu.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageImporterMenu.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt index 879dad5d7..da0082640 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt @@ -11,14 +11,15 @@ import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState -import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.items.IItemHandler import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.SERVER_IS_LIVE import ru.dbotthepony.mc.otm.block.CableBlock import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity +import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.config.EnergyBalanceValues import ru.dbotthepony.mc.otm.config.MachinesConfig @@ -28,8 +29,7 @@ import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.graph.storage.StorageNode -import ru.dbotthepony.mc.otm.menu.storage.StorageExporterMenu -import ru.dbotthepony.mc.otm.menu.storage.StorageImporterMenu +import ru.dbotthepony.mc.otm.menu.storage.StorageImporterExporterMenu import ru.dbotthepony.mc.otm.once import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MNames @@ -41,13 +41,15 @@ import java.math.BigInteger import java.util.* import kotlin.collections.ArrayList -abstract class AbstractStorageImportExport( +abstract class AbstractStorageImportExport( blockType: BlockEntityType<*>, blockPos: BlockPos, blockState: BlockState, energyValues: EnergyBalanceValues = MachinesConfig.STORAGE_INTERFACES ) : MatteryPoweredBlockEntity(blockType, blockPos, blockState) { - val energy = WorkerEnergyStorage(::setChangedLight, energyValues) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::setChangedLight, energyValues)) + val energyConfig = ConfigurableEnergy(energy, modesFront = FlowDirection.NONE) + val cell: StorageNode = object : StorageNode(energy) { override fun onNeighbour(link: Link) { if (link is DirectionLink) { @@ -76,8 +78,11 @@ abstract class AbstractStorageImportExport( } } + override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { + return StorageImporterExporterMenu(containerID, inventory, this) + } + init { - exposeEnergyGlobally(energy) savetable(::energy, ENERGY_KEY) exposeGlobally(MatteryCapability.STORAGE_NODE, cell) { it != RelativeSide.FRONT } } @@ -92,11 +97,7 @@ abstract class AbstractStorageImportExport( cell.discover(this) } - protected abstract val targetCapability: Capability - - protected val target by lazy { - front.track(targetCapability) - } + protected val target = front.track(ForgeCapabilities.ITEM_HANDLER) abstract val filter: ItemFilter @@ -106,26 +107,20 @@ abstract class AbstractStorageImportExport( companion object { const val FILTER_KEY = "filter" + const val MAX_FILTERS = 6 * 3 } } class StorageImporterBlockEntity( blockPos: BlockPos, blockState: BlockState -) : AbstractStorageImportExport(MBlockEntities.STORAGE_IMPORTER, blockPos, blockState), IItemHandler { +) : AbstractStorageImportExport(MBlockEntities.STORAGE_IMPORTER, blockPos, blockState), IItemHandler { override val filter = ItemFilter(MAX_FILTERS) { setChangedLight() } - override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { - return StorageImporterMenu(containerID, inventory, this) - } - private var lastSlot = 0 private var nextTick = INTERVAL - override val targetCapability: Capability - get() = ForgeCapabilities.ITEM_HANDLER - init { front.Cap(ForgeCapabilities.ITEM_HANDLER, this) } @@ -212,7 +207,6 @@ class StorageImporterBlockEntity( if (leftover.count != extracted.count) { val extracted2 = target.extractItem(lastSlot, extracted.count - leftover.count, false) acceptItem(extracted2, false) - nextTick += INTERVAL * 4 } } } @@ -225,20 +219,15 @@ class StorageImporterBlockEntity( companion object { const val MAX_MOVE_PER_OPERATION = 4 private const val INTERVAL = 5 - const val MAX_FILTERS = 6 * 3 } } class StorageExporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : - AbstractStorageImportExport(MBlockEntities.STORAGE_EXPORTER, blockPos, blockState), + AbstractStorageImportExport(MBlockEntities.STORAGE_EXPORTER, blockPos, blockState), IStorageEventConsumer { override val defaultDisplayName: Component get() = MACHINE_NAME - override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { - return StorageExporterMenu(containerID, inventory, this) - } - private val relevantTuples = ObjectOpenHashSet() override val storageType: StorageStack.Type @@ -281,9 +270,6 @@ class StorageExporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : private var lastSlot = 0 private var nextTick = INTERVAL - override val targetCapability: Capability - get() = ForgeCapabilities.ITEM_HANDLER - override fun tick() { super.tick() @@ -346,6 +332,5 @@ class StorageExporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : val MAX_MOVE_PER_OPERATION: BigInteger = BigInteger.valueOf(4L) private val MACHINE_NAME = TranslatableComponent("block.${OverdriveThatMatters.MOD_ID}.${MNames.STORAGE_EXPORTER}") private const val INTERVAL = 5 - const val MAX_FILTERS = 6 * 3 } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt index 2e52a31b3..9097f7aba 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt @@ -51,7 +51,7 @@ class StorageBusScreen(menu: StorageBusMenu, inventory: Inventory, title: Compon it.childrenOrder = -3 } - val controls = DeviceControls(this, frame, redstoneConfig = menu.redstoneConfig) + val controls = DeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig) val mode = LargeEnumRectangleButtonPanel(this, frame, prop = menu.mode, defaultValue = FlowDirection.BI_DIRECTIONAL, enum = FlowDirection::class.java) mode.add(FlowDirection.INPUT, Widgets18.ONLY_STORE, FlowDirection.INPUT.title) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt deleted file mode 100644 index 6b4b7dbdc..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageExporterScreen.kt +++ /dev/null @@ -1,36 +0,0 @@ -package ru.dbotthepony.mc.otm.client.screen.storage - -import net.minecraft.network.chat.Component -import net.minecraft.world.entity.player.Inventory -import ru.dbotthepony.mc.otm.client.screen.MatteryScreen -import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.client.screen.panels.* -import ru.dbotthepony.mc.otm.client.screen.panels.button.CheckBoxLabelInputPanel -import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls -import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel -import ru.dbotthepony.mc.otm.client.screen.panels.slot.FilterSlotPanel -import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel - -import ru.dbotthepony.mc.otm.menu.storage.StorageExporterMenu - -class StorageExporterScreen(menu: StorageExporterMenu, inventory: Inventory, title: Component) : - MatteryScreen(menu, inventory, title) { - override fun makeMainFrame(): FramePanel> { - val frame = super.makeMainFrame()!! - - WidePowerGaugePanel(this, frame, menu.energyWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) - BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) - - for (row in 0 .. 2) { - for (column in 0 .. 5) { - FilterSlotPanel(this, frame, menu.busFilterSlots[row + column * 3], 55f + 18f * column, 17f + 18f * row) - } - } - - CheckBoxLabelInputPanel(this, frame, menu.busFilterState, TranslatableComponent("otm.gui.filter.is_whitelist"), 59f, 78f, width = 170f) - - makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig) - - return frame - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterExporterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterExporterScreen.kt new file mode 100644 index 000000000..75f24ef60 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterExporterScreen.kt @@ -0,0 +1,55 @@ +package ru.dbotthepony.mc.otm.client.screen.storage + +import net.minecraft.network.chat.Component +import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.client.screen.panels.* +import ru.dbotthepony.mc.otm.client.screen.panels.button.CheckBoxLabelInputPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls +import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.FilterSlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel +import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel + +import ru.dbotthepony.mc.otm.menu.storage.StorageImporterExporterMenu + +class StorageImporterExporterScreen(menu: StorageImporterExporterMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { + override fun makeMainFrame(): FramePanel> { + val frame = FramePanel(this, 148f, 130f, title) + + makeBars(frame, profiledEnergy = menu.profiledEnergy, batterySlot = menu.batterySlot) + + val right = EditablePanel(this, frame, width = AbstractSlotPanel.SIZE * 6f) + right.dock = Dock.RIGHT + val grid = GridPanel(this, right, columns = 6, rows = 3, height = AbstractSlotPanel.SIZE * 3f) + grid.dock = Dock.TOP + + for (slot in menu.filterSlots) { + FilterSlotPanel(this, grid, slot) + } + + CheckBoxLabelInputPanel(this, right, menu.isWhitelist, TranslatableComponent("otm.gui.filter.is_whitelist")).also { + it.dock = Dock.BOTTOM + it.dockTop = 2f + it.childrenOrder = -1 + } + + CheckBoxLabelInputPanel(this, right, menu.matchNBT, TranslatableComponent("otm.gui.filter.match_nbt")).also { + it.dock = Dock.BOTTOM + it.dockTop = 2f + it.childrenOrder = -2 + } + + CheckBoxLabelInputPanel(this, right, menu.matchTag, TranslatableComponent("otm.gui.filter.match_tag")).also { + it.dock = Dock.BOTTOM + it.dockTop = 2f + it.childrenOrder = -3 + } + + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig) + + return frame + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt deleted file mode 100644 index ecbb2f538..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageImporterScreen.kt +++ /dev/null @@ -1,36 +0,0 @@ -package ru.dbotthepony.mc.otm.client.screen.storage - -import net.minecraft.network.chat.Component -import net.minecraft.world.entity.player.Inventory -import ru.dbotthepony.mc.otm.client.screen.MatteryScreen -import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.client.screen.panels.* -import ru.dbotthepony.mc.otm.client.screen.panels.button.CheckBoxLabelInputPanel -import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls -import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel -import ru.dbotthepony.mc.otm.client.screen.panels.slot.FilterSlotPanel -import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel - -import ru.dbotthepony.mc.otm.menu.storage.StorageImporterMenu - -class StorageImporterScreen(menu: StorageImporterMenu, inventory: Inventory, title: Component) : - MatteryScreen(menu, inventory, title) { - override fun makeMainFrame(): FramePanel> { - val frame = super.makeMainFrame()!! - - WidePowerGaugePanel(this, frame, menu.energyWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) - BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) - - for (row in 0 .. 2) { - for (column in 0 .. 5) { - FilterSlotPanel(this, frame, menu.busFilterSlots[row + column * 3], 55f + 18f * column, 17f + 18f * row) - } - } - - CheckBoxLabelInputPanel(this, frame, menu.busFilterState, TranslatableComponent("otm.gui.filter.is_whitelist"), 59f, 78f, width = 170f) - - makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig) - - return frame - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageBusMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageBusMenu.kt index c4fe3c48d..fa06e69be 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageBusMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageBusMenu.kt @@ -5,6 +5,7 @@ import ru.dbotthepony.mc.otm.block.entity.storage.StorageBusBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.IntInputWithFeedback import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget @@ -20,6 +21,7 @@ class StorageBusMenu( val insertPriority = IntInputWithFeedback(this, tile?.let { it::insertPriority }) val extractPriority = IntInputWithFeedback(this, tile?.let { it::extractPriority }) val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) + val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) val mode = EnumInputWithFeedback(this, tile?.let { it::mode }, FlowDirection.WITHOUT_NONE) init { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageExporterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageExporterMenu.kt deleted file mode 100644 index b669facf2..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageExporterMenu.kt +++ /dev/null @@ -1,22 +0,0 @@ -package ru.dbotthepony.mc.otm.menu.storage - -import net.minecraft.world.entity.player.Inventory -import ru.dbotthepony.mc.otm.block.entity.storage.StorageExporterBlockEntity -import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu -import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback -import ru.dbotthepony.mc.otm.registry.MMenus - -class StorageExporterMenu( - p_38852_: Int, - inventory: Inventory, - tile: StorageExporterBlockEntity? = null -) : MatteryPoweredMenu( - MMenus.STORAGE_EXPORTER, p_38852_, inventory, tile -) { - val busFilterSlots = addFilterSlots(tile?.filter, StorageExporterBlockEntity.MAX_FILTERS) - val busFilterState = BooleanInputWithFeedback(this, tile?.let { it.filter::isWhitelist }) - - init { - addInventorySlots() - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageImporterExporterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageImporterExporterMenu.kt new file mode 100644 index 000000000..f0573601a --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageImporterExporterMenu.kt @@ -0,0 +1,24 @@ +package ru.dbotthepony.mc.otm.menu.storage + +import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.block.entity.storage.AbstractStorageImportExport +import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu +import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput +import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget +import ru.dbotthepony.mc.otm.registry.MMenus + +class StorageImporterExporterMenu( + containerId: Int, inventory: Inventory, tile: AbstractStorageImportExport? = null +) : MatteryPoweredMenu(MMenus.STORAGE_IMPORTER_EXPORTER, containerId, inventory, tile) { + val filterSlots = addFilterSlots(tile?.filter, AbstractStorageImportExport.MAX_FILTERS) + val isWhitelist = BooleanInputWithFeedback(this, tile?.let { it.filter::isWhitelist }) + val matchNBT = BooleanInputWithFeedback(this, tile?.let { it.filter::matchNBT }) + val matchTag = BooleanInputWithFeedback(this, tile?.let { it.filter::matchTag }) + val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) + val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) + + init { + addInventorySlots() + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageImporterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageImporterMenu.kt deleted file mode 100644 index 401bf92e6..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/StorageImporterMenu.kt +++ /dev/null @@ -1,18 +0,0 @@ -package ru.dbotthepony.mc.otm.menu.storage - -import net.minecraft.world.entity.player.Inventory -import ru.dbotthepony.mc.otm.block.entity.storage.StorageImporterBlockEntity -import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu -import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback -import ru.dbotthepony.mc.otm.registry.MMenus - -class StorageImporterMenu( - containerId: Int, inventory: Inventory, tile: StorageImporterBlockEntity? = null -) : MatteryPoweredMenu(MMenus.STORAGE_IMPORTER, containerId, inventory, tile) { - val busFilterSlots = addFilterSlots(tile?.filter, StorageImporterBlockEntity.MAX_FILTERS) - val busFilterState = BooleanInputWithFeedback(this, tile?.let { it.filter::isWhitelist }) - - init { - addInventorySlots() - } -} 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 185878fd5..e6dc21401 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt @@ -26,8 +26,7 @@ import ru.dbotthepony.mc.otm.client.screen.storage.DriveRackScreen import ru.dbotthepony.mc.otm.client.screen.storage.DriveViewerScreen import ru.dbotthepony.mc.otm.client.screen.storage.ItemMonitorScreen import ru.dbotthepony.mc.otm.client.screen.storage.StorageBusScreen -import ru.dbotthepony.mc.otm.client.screen.storage.StorageExporterScreen -import ru.dbotthepony.mc.otm.client.screen.storage.StorageImporterScreen +import ru.dbotthepony.mc.otm.client.screen.storage.StorageImporterExporterScreen import ru.dbotthepony.mc.otm.client.screen.storage.StoragePowerSupplierScreen import ru.dbotthepony.mc.otm.client.screen.tech.AndroidChargerScreen import ru.dbotthepony.mc.otm.client.screen.tech.AndroidStationScreen @@ -57,8 +56,7 @@ import ru.dbotthepony.mc.otm.menu.storage.DriveRackMenu import ru.dbotthepony.mc.otm.menu.storage.DriveViewerMenu import ru.dbotthepony.mc.otm.menu.storage.ItemMonitorMenu import ru.dbotthepony.mc.otm.menu.storage.StorageBusMenu -import ru.dbotthepony.mc.otm.menu.storage.StorageExporterMenu -import ru.dbotthepony.mc.otm.menu.storage.StorageImporterMenu +import ru.dbotthepony.mc.otm.menu.storage.StorageImporterExporterMenu import ru.dbotthepony.mc.otm.menu.storage.StoragePowerSupplierMenu import ru.dbotthepony.mc.otm.menu.tech.AndroidChargerMenu import ru.dbotthepony.mc.otm.menu.tech.AndroidStationMenu @@ -104,8 +102,7 @@ object MMenus { val FLUID_TANK: MenuType by registry.register(MNames.FLUID_TANK) { MenuType(::FluidTankMenu, FeatureFlags.VANILLA_SET) } val STORAGE_BUS: MenuType by registry.register(MNames.STORAGE_BUS) { MenuType(::StorageBusMenu, FeatureFlags.VANILLA_SET) } - val STORAGE_EXPORTER: MenuType by registry.register(MNames.STORAGE_EXPORTER) { MenuType(::StorageExporterMenu, FeatureFlags.VANILLA_SET) } - val STORAGE_IMPORTER: MenuType by registry.register(MNames.STORAGE_IMPORTER) { MenuType(::StorageImporterMenu, FeatureFlags.VANILLA_SET) } + val STORAGE_IMPORTER_EXPORTER: MenuType by registry.register(MNames.STORAGE_IMPORTER) { MenuType(::StorageImporterExporterMenu, FeatureFlags.VANILLA_SET) } val STORAGE_POWER_SUPPLIER: MenuType by registry.register(MNames.STORAGE_POWER_SUPPLIER) { MenuType(::StoragePowerSupplierMenu, FeatureFlags.VANILLA_SET) } internal fun register(bus: IEventBus) { @@ -113,7 +110,6 @@ object MMenus { bus.addListener(this::registerClient) } - @Suppress("unchecked_cast") private fun registerClient(event: FMLClientSetupEvent) { event.enqueueWork { MenuScreens.register(ANDROID_STATION, ::AndroidStationScreen) @@ -137,8 +133,7 @@ object MMenus { MenuScreens.register(TWIN_PLATE_PRESS, ::TwinPlatePressScreen) MenuScreens.register(MATTER_RECYCLER, ::MatterRecyclerScreen) MenuScreens.register(STORAGE_BUS, ::StorageBusScreen) - MenuScreens.register(STORAGE_EXPORTER, ::StorageExporterScreen) - MenuScreens.register(STORAGE_IMPORTER, ::StorageImporterScreen) + MenuScreens.register(STORAGE_IMPORTER_EXPORTER, ::StorageImporterExporterScreen) MenuScreens.register(STORAGE_POWER_SUPPLIER, ::StoragePowerSupplierScreen) MenuScreens.register(ENERGY_SERVO, ::EnergyServoScreen) MenuScreens.register(HOLO_SIGN, ::HoloSignScreen) From 71c5e788c6bd43126aee9d687ee85d3b47fd3a66 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 12 Aug 2023 14:55:37 +0700 Subject: [PATCH 0960/1199] Update storage power supplier menu --- .../storage/StoragePowerSupplierScreen.kt | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt index f9eb3e7ce..f6cd39c54 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StoragePowerSupplierScreen.kt @@ -2,13 +2,15 @@ package ru.dbotthepony.mc.otm.client.screen.storage import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel -import ru.dbotthepony.mc.otm.client.screen.widget.HorizontalPowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalPowerGaugePanel import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.menu.storage.StoragePowerSupplierMenu @@ -16,29 +18,35 @@ import ru.dbotthepony.mc.otm.menu.storage.StoragePowerSupplierMenu class StoragePowerSupplierScreen(menu: StoragePowerSupplierMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { override fun makeMainFrame(): FramePanel> { - val frame = FramePanel(this, width = 200f, height = 60f, title) + val frame = FramePanel(this, width = 200f, height = 68f, title) frame.makeCloseButton() frame.onClose { onClose() } - HorizontalPowerGaugePanel(this, frame, menu.energyWidget).also { - it.dock = Dock.BOTTOM - it.dockResize = DockResizeMode.NONE - } + val strip = EditablePanel(this, frame, height = AbstractSlotPanel.SIZE) - val topStrip = EditablePanel(this, frame, height = AbstractSlotPanel.SIZE) + strip.dock = Dock.BOTTOM + strip.dockTop = 3f - topStrip.dock = Dock.TOP - topStrip.dockTop = 3f - - BatterySlotPanel(this, topStrip, menu.batterySlot).also { + BatterySlotPanel(this, strip, menu.batterySlot).also { it.dock = Dock.LEFT it.dockRight = 3f } - val labels = EditablePanel(this, topStrip) + SpritePanel(this, strip, ProgressGaugePanel.GAUGE_BACKGROUND).also { + it.dock = Dock.LEFT + it.dockRight = 3f + it.dockResize = DockResizeMode.NONE + } + TallHorizontalPowerGaugePanel(this, strip, menu.energyWidget).also { + it.dock = Dock.LEFT + it.dockResize = DockResizeMode.NONE + } + + val labels = EditablePanel(this, frame) labels.dock = Dock.FILL + labels.dockTop = 4f object : Label(this@StoragePowerSupplierScreen, labels) { init { @@ -50,7 +58,7 @@ class StoragePowerSupplierScreen(menu: StoragePowerSupplierMenu, inventory: Inve text = TranslatableComponent( "otm.item.power.passed", - menu.totalTransferred.formatPower() + menu.totalTransferred.formatPower(formatAsReadable = ShiftPressedCond) ) } } From 0c23e53bbc27cbf551d9dfbc7451b46cdb18b01b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 12 Aug 2023 15:01:41 +0700 Subject: [PATCH 0961/1199] Swap color palette for side controls --- .../textures/gui/widgets/side_controls.png | Bin 2953 -> 2972 bytes .../textures/gui/widgets/side_controls.xcf | Bin 73073 -> 73205 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/side_controls.png index 54effb4a70e92979c02510d7900df312682508c1..9199ba51e8518d35cd735374293a5faeb4a01597 100644 GIT binary patch delta 2921 zcmYLL2{_bS8y^%#;u?f&Uq%MWzC=xCNHZ~N%tY?E$u1P*Gw#juFImSv23fLYY=!J3 zZI)@Q(}%3l4OxfmiN-h8eV*?;=RD6j?|I*I-uJw}-#I5vB3B|s1&H!SA}^zmNCki5 zZ4Yl>cMwP|H7xb)#rE@((bFYlTD|e8d57Y~pxSt{afbSd*9dQo`Xy)LqP)KMMJz$) z=t#tUcs!m@!qZ8XaMb(@U&nAK>YXL}KnqqMyZ&)iZfbujvvmzrhFP2f zADn(d=Begah}EtHTp@bfIFb(EzAB46Zgz;c)J(P$h3m+Lkb&Q<#PN?p71wIt z{2gEC=<~Gy?A|e?r605>DErYx7ci_?5pjVBKjf@ojYqfD*b ze5dT}FWua{dUHe0zlBE-zDQ9tq2!lbR_9vt+_E|9yl{fQswHeWcV>(0?Um|`+js9H zor|o;mgUxjM7DNV)7hBAa8N)tv4p=UK0mF7O9$W=u_?QE@1cr$daSKot{qc~k|t!x)VO_=w9qxF)zNNp^C$Pu#*W=h zRl3B>wXAUI7)C(bC=XO>#KHg-&wM=YkfxQJrk_=08x0SCxb2b7eV6;Ptm7-c2~yRF zEe61-GjAlvE|@ZP{NoA^g||a+FNM-mB|LX^H2xvBfAAL` zI<$4~@9V@Z&t|Z1c8MLjywl|hP3Eu77A!ieng${JSOHdtviB3xZ8{{HrYLO2;`Z5- zB6b>hwEIkGY4U)f&7e1Tc5*r2l%-@2P*6Vmd0Z##+s<5%Q#dQ_T!yrLYQbpM*f2}T zWaT6Sk1K+ph36*KeME29IN)%)T1GkDPY|j%GIDITw-(Am8b5g89g<{a_otKPVBhW2 zQUi;KM6ZdgmUCP4``24dgY$8dy9kUEfe?yf5>1T3&^rziU?*{%%!F?`F$uso(-x9- zzCNsv5cth^zax399NDh5+Xm54401q8C9%j}S1&Bx+ubG&G)^onzPmy%k0e>nj@HDu zhcvH-aGzO@H)|AqJlt)f-_@_X|9x^UQ$}gOLas@7T)Y=A6$Cwo*SCjS*UWS$R|hTl zh!=MWoRBwsO-N6*6LCsU9R!reEp+k&L;5Z^tcvQj9`0`}RAO7{hU}2Ft!#Gk`{f`k zLM?G!(g!H4kZg|`$PZ2qq6yeI8=<6BS+kAyFI){6WaAUyKK5yxxNEWgzG0f? zWcNayE8G_9KGFDaOm7LCpbvhy9DA<$y@YM`nvIKWYF#L@W>Hxg2o9LADq@~drYEg! zJIJp(?&_fyHsf6AM&o_G1|4ZeYpt9lRtzqObhAU=rZY#B$Lm~ISIMfeCXa2TN}Nc> z-)|&n-!ZIY{Im)_@JiyXpj9iO2WnL=N^Vxxhked8W~?!82|eNxzxTrtci63F1* zP7DQ%ie*6n=x6!zX@2iH2TJhO=>bP?cNCoA$ zYIDLlv2ZzAmK*>C;aPvwns)^plpDwCp}yW}#iL={6EVW+k&otg4=Yq4yZg3ys5!r> z7R;13S1Ja)6@O=m0Httydl`h7r$z3J^q}r|bE6ZRV zo=)au)59~37RowiNq#5i6{4aa)qIDY;`nZ=o6*>ZA17VA2_MSj7((6oejOW#qAJu< z|a*GQU8(bJ@$ade6tXI?IDkz^{Nmp@i8LzNO8!c85Q+ zk7}e!rW0>q0B;wk?$;Cu9lN0nt)+1yqBq*zk5u?)ROMirxgts@deWP|>S^C(ig8`312#EX4*1=5`fz(}_n(=)=Yfp8W>P5Ie{*Kv z%n1IXxtaZSCGr5gYOqg1U-7bA@%Jnzn{7r>VW+$Lg2`G zd9O`_rJd`&LgH9buM13Mi#(>aZ<5=Tpo&$| zEnbT9l}xhF^-a5M_^n00n$^VB=R zN(U{QJ(<>cuI=Cdg#Ez%2*yv&VLEY=epxfKBvc4W2~=$Ph5M5gOgXz6LiWZOz=^%} z?Ce)NM}i3{LVyJk>!HE&`#L@!s6PCm`+ulAd{nOw`=}nyX({_V^iu1*JK@Ej1jeK| zKnw8^o*5Wgtvp+XkluYS*Od>O`XfX;%8(;TfZMe-8MYLm&~J!hFG<41IQA*c;sZtt zUl3z2l?-UO{UpcGP#j7Cysp5i65~tEe}w(Ch$AmmD3|=8UBJ_yZ1J?}3iIpM@y^QlH@TpXzFn@zO)SNZL3ipm z^dcb>F(3b|OHL4rGNg{Sf7LU98pg$n&FQ(nlSZ%HILIo3n4&Gn8z$+IFqH^Mh-1Lq zIGDniL|q(X-{%bXq!4j7t0JzVqLZgZ7I+LYBS+cNUHyfAz#;Sl^2fbF`;K}MWB8U| z7yZqyQ~icDgtvht8B_M2{nxp*P;Q5Oc#sg7>s1up$Y^P=)b)Mvr~oSr4?}jIt%3(F zLHb@)q!)hHdL_SfuIx%*5l|xG#K;KQHmd4eFPX&sUcb@U}1- z27{?6@gAC+b1$W0h2_l3PQ-WGuPKM!74s-W2mk%|SmlV1O>@7>>dgl1^7ijiM`mL@ z+6a#x7bcc?lhT=laV}5|dEs&Nw{5^$L%BkUc{_Pw@wkT5o|cxDIt>@|r^rH^RsG`| uoVQaod%f8%As@p7A|>;K6qJ5Og)Rp`@7DFZ6UDi3KLjXCj71f~IpTjv+=X!f delta 2902 zcmXw52{hDg7oUol_r=H9QYPEjmylgU7|W2IEEzGjK~shd75=3%MnYprw#gpVh#4di zuYIWO#`X$HG?FPxw!Tr{_ndRjdG2$b-+k`=-TOP|$rB}tron(a!DeO-NHa6Zu<$E^ z!IuI+AcY6958zg9XT>`%4q3Y@N#pr(-46N8BI%UUB=Z*z6MsE7$oAUiv^`D|618lt z{qUg+J<{6Y;l|}=!oLf`MdF;UK7jmsDCF559X6F3wRtjX6;$XEP$`yps4`G&3E|bZ z;MVa$Ii6ecju8)l>>Eyh)S+^wYYZL}({zuevKj%T94htEY>|g_WnXr0KhaLj&3bo@ ztk*{;na0?i3GU}4N;If7?shhOe9>~c%|ZumFD@rygHnmoP(Gow#)CsRYSTr-)s*w< z^`4FxgwCYDQFrM-ujy5;pTLoohWJa`f7sDPSfq#+Qj!f=4aH5h882@+e=#yYjp#b%;yS2BkU!;v%#l zh&5yIf2Sw;rzhV8P3-M~v}xffGUgBG(`ycC09+irGMaaAz!eY(oPb1_xI|B^pbAsO zE%~2|t>|Wp^zni8_ynNQr1SuOMIcNJjqYjDO!N=;pEG{p?_;i`k4E$ADYi@c zK>dSTH6rH0-EYf=bf-}xsG%Y1&dG-9@upXmIl3bw(^ozvf*ylh2qIxaT6>JOIxL{v z@0*(V*7tU(#_M(rU8cE5V;{ySF1@WGV2OReodKJ}-m$ zX%p2W)+}S|GZqOK7`Wa*6bm&na6v zRfWWm96c9c`m~j2oy|YS7H75_Hw)Yb-^bYH7ZgAQ26i@Asp$^I1gH!!>u!EdcK(~E zY3FQ|(+VTAx;9*OiMsN)v443MUt^(E1I@Y{dj2KewrE^<;92sN;Og><_vQM7C%v7( zD@h8~)Dyz@t@XCF%$sk+i$pHT+u7S&5<2@`bw(pfIPy*X-A2;STQtVsckL`B{ZyK8 zmrbtrTP%_|&6 zxS>~9JXcNATC^So(-Qy24vaFwF<)9VW;P^5|7u&@UtdYRieFD- zk_ld56gB~Fm{lin#H7yy+oui>v>cR3;6B|~#-;fxW{!c&H_j?<4q2*9oS>@kLK0$> zv1I*#hvwgbe{{b?=F>5lf}#*xlXjPyv$4f9GYhmMpg+rQ_j=5fpupbG&yIt2?}zRg zDot9X&irT!^eSa2sv0}*2-Z?H)A;>4#AJRxoKmZdwbAL;OEu1f;pD(G zm+KLTA3G0EWhN9artVX;Ae&vMTuV*34b@Zu!_tLvA%G!_OTGho%sJX0vJo!_UU>?y zYoBy;yF{$7+F%rF$*QTc?*)Yb%MO~hkQ}&_d{5qNvY=2GAA94QC^$Cu-A~w19MJnY z%b5L05ESi_NP$k0kHa{?i*ki<4=L$oDBO1ex!uYW5l8}}4c-`+c4VT1u8smKkFw8c zH>zN>=naEiK4gAX!1|u@h~52h4Tq^`<0FFTqe+F=LJT7@L<_&@yh%GclErHovE%IN z<%!4pt6+1V(pG91aTp~w&Zd{|f3zWN#huKnv%7ty{m|#{>U48!S_nE`DCE_QPeuqT z(5lCF0iUWzL0o?U*vH&`W&NFTS5E?2H4^X&(+f7q^ahP`t!lMJ|6rn@{?7r(c=+7h zmfvKBiD_EcWyrtBa!_;bOUz@s7OKj|vRlQJ{?6F9y>$EPO>I9sPoGifs1wEy)7h`G z9t62tmlduj+c4O3&hCI|Enrx9BD!U;hUJ`Ne2^=^HuZ_*RPB$Sa48C-0gFo=`QC%a z8kuL}hBir^jP)qg25Rei+*E2$K?&Y#-|GAPcC(f-nKOXk+@+E?vH65SCK!L$l` zqKNN9l=bnwv#zD?=r(+!w1ySE^_yCGlLl3zF|!+wwtMKaw@y<+rh7Ok^y2sQNwNW;rLiXKRFgLs;Z?)@U{iv~t`Ht;{v=;-ta5k5-PC#P z2Rfd`DO$`o`WrDsp7_d%f)_qw2=%-cvr0lt^T5oDCFs^h0tVCOMQF&MvbJ7O0Jap3Opo>C=-goifq=mtZ_kn2Vefj(>ws=Ydxc*cN zLZm6tP-#kWY)dQO=qf$ueLapg#~SZpk0rJC`xccJ6dL4;nIE6Hw(BuRt)(i`)-J7_ z*;iQ~pI{~dWr|=M$K44yzvH%y3T+p8?Pz4r&w->~wl>((7@i^`dBAH|!XIXm_4g_o zV8bsXh1jb0KyZLf{%P2)(4+dDFcMCNDO^0Q2BwcChyIj#q_~~4J;*8+79AtI&Dce! zXYzv&Ns3f8=l4@DoB+&+y^4qro)IWD8M2Alzy+Q%nzLt|^*6#g4_47>?2Q(w7c2Ye z#lhM4Aj{5JEL|hmBkQ+V{%D18JUm4~#F`nfAWwiya;|z)?&t=Unj=zJ zkEow{W$|o9KWXQKJSdJyk@e*vK5q9u?^S_+?XMXHLD&5{aO1)Oh3auQ8iS5sls)YH zIE%zT30z}}Pi$NqK20;RNOPPde-6UjPL?b#Gj@FfNr3q}gzn%HLsqI5yP9l3Us&aK zQc|Gg+41MRP1|_sZD_UWjf<{y2i*HF_RvNIwJIdwNyFdY2s`gvG?1;ZfXn}%(LF-c z(P1rK0brot>pXT++V8Blv?mOfCXfv=8Zfg*4A)^t>aYPPkK9y2yrv|;_IN-v2Ksd*E3$mT7C`V(vpv z!nn1aXw#~cR#y~2jl2jx9+H#5j^ZV}W}$7MB~rU{>*|xFvy>h>m0=!31Sux`jw3q9aLToz#dtih~MnbfW~4w%d?Q zD>@c>?m0`UeT?Z?EHih% zd%o|#=lu8k&%OUH1I=#3Ep83_gxwPq`tw@I==&&RKq{m80AqxKaqjbs_hm6Ic#bj7 zi}B$Y#uZB#AKA|My`M8CKEk-lL}*u5f1impR>rkejO!B^H(g*%A7jj%X3SZ^n7f8? zhwDc2&vCp(1T?r^4er5yHTh3h&oA_PxRwzy(C$L5@v- zVGLQs7|PCxaM#i)ifZ(mBd_Zcg?-ZMa9Dj5r&Z^0TD=wF5O{bgqev?XN(Kydcz7x! z8r9mWk$NOXl~$`&i#(JeO+j<4n&yt$2x=H=s+)3?RjZYCE!mKEEsnLe+HnXocrg~F zF?S|nlu$)j{gk_&z5VW{f7i3O|3A&g**|n=um5F)T&RCf2!m=&HK`48dN3?k2kr|7 z!+IHD7#1QKn=1^wGd0rgT}Um6AF+zl5rAv&tGGFwiVl5uM|5*&{W3+3BItZtA<$^8 z&2B|E*HDeqW~H^NJEn3f9+(ag-5oy2X=P%mp#7d#yuD!htlpzq^5%n9EvAToenijj-y3613a8kc@C?_j>#qT?=% z3yga(IKb+KpE}%p`O`qHft(d^Z~o^`+_jO%>#V}DSvyd7{wPmL_3576kR;7u1! ztG_J_4vhJf!v{WLT-qXk7_-I)mc>$@Wk1l?4wj|M&bZG3;vXY6ehabj1!`wpij0dd z0Z4e9l!P2o5`HTCS4;t{e396d6~wN5R~=1EmbojBfGE`jVNq*#g@ENG=1G<>SRMyR zdV;P<%BL%mUXi1TRRGBgh)qr;Hu-6_e}zeYw(1f<%2TAIJWEQ-ujIt)F@V%!VpFS# zO>LBM-6o-0)((i@ld!IrgmwKgXI&OR+EZ%cxv;=A?Uw=mZTh1Nd&r`+cR1Wo#Q5~D zWq8_;e8d!`+8j!$Hpi*cxfc2PGj9Q8%poP?yQE~KkTSOAHGu43QnHtklAS6~WQ_xC zT}|xPY+|>*Ap3I818mz!>^2**+xE-pT=Y3Fh}gV1V)NFheK{66v11E}%OqHV1Z$Wq z-8llVJCNAjONrgR8i$+ZC%Y~H>`5YJPdX`k_OeA&d-|b(7p;I7t>9fbzaSl;$d5cK za{ZPpaqV&?-Q-bGHhc36PsU#+s+Rg#=`74Qicu|A#@43M*xFpS6WQH_vt91LR8mX$~8H6K(R*6Gold`7nPW|6qjZlYX-JgAg5@T110Sts?f+GxB2xn$ng}Y}-C!+p49h z4R62QMr?a2vF*oXSUa*Eg~WE05!>+_Ij;jv>9iBuSxIcCl#4oh0Pk7*`rmz&$nN9l zi93it5P9~mM4tUx=AG>Z@e$e)ZXD&?y%_AmXmaEHJPtqAegNa&-~43Rxdq;EiQE4Y zxBn$<|BDMj)KK~>$JMwiA)-g^yEtFwU(tb>B>qb?mHqO;iW>$IAzQEd0bJWm(zQa8 zt{r4)-Zedl_ekkGLrUKll+E5ZEMNdg8JJ7Tz;e1qZM~{5H)EwYAJeO62Kr%;*K3g1 zYp}Q?D?&u58N+%RI*7lHDk;Zs6Xh8Gm{gfD>=fcFQbzTpj7D)Yy))Vm<1wU+Cy_G# z<9}rA9~&1iSx9X)SxZI$s zI5>}S$W_LlHZl(TgmJ{Xgf8v*gG`LR$(R(%IPPP{l2}Sc+ccpIY(5$wf^NlY6Shux-K4qQ2;LaBY9@EH zrt4l9H)?JT|3J5(P_O!^rt4;;?xUdVq^en(Q8DR)hN`$$$r}E-HJ46#+A)tHqP1=~ z%1`TnwYt8~Vjr=z|JaVMf6ujI{*E#Be_LxGnd*H&K&LBM5TRhz49B#tU=5Lp);b~l zh_pSeNSAE{)e^q-)>?IcJP%*ZtO^2)!GdU}I#9)7Mora3i$)fU^M>Y}}i zHGFkj$Ee0yu-L8i5Nu6{Opyy%;LUn^I;28+b7ne5_=J726(gnCsQg=VEqZf0-?308 zavx--d!qWX*0S8(w$PY zIqI%%x7h#B>RgXwUi; z@&NJSYl|-27UbFx^*rImM*Z4fw|$j(G;*G34KuoM=o3!)P{x-!dY7`fXNrJ`i{yDk zgYq0A9db=%EeJ1TK~rczbbmg982ommUNOs!s`9P@(J350J)W^|tSpUw!4CaCpsD&D zp{e?n8~UJ8a!da$00R#zMGQ2Gj|5q8(7+n04>|`BTSy~fFVTqD`^LnCAoVUh&d5;q!P_$g9`UneDAlds2b0~oo3*pY{b z9a$nLCNuyfo+UQ1g4j_e=^BOX3oVKjV+@CtmN}-sOx+bEjH5}_;yD^H_C*>ncD}qm zHVt6>S@LQ812!V%c@HL&PZOdzoK(m73qQGi!eqNxMpI4QNK;MSXADanF6T_!0Wf17 zDKqwxGUJ#WmU?LA`C{z`1x=W@i$jR3Qb5QBK`6s@b8Hi>hD|AK79)vc-Mmp2gEaEHzd}I|G(_e#WgzU@KNlB!`xM z&7tdejK4o5QGBV}1{S&{ck2NZlk(-nM6NeWuz@`Jc}e zsGKD)RfYgmtsu54o7k$4@^Pjf!WdU`4{G?BYWSFHT8!kzD7p16{(1?fF?9oIOkI)^ zvMK{blhHTFW>nW#i`mrS-ka3n-exwfPeT?Eb(Gg2BZ$mGUwfCsf`o72&gY!O~@ z9vnliHI3#_<9~7p^I%!n6loLlvJQlaQ1JdEPSwREytn5&JBdgD>oFFr|6;*UxbZa3& lgnAy}BDBAex~nyRpHrBG7^Fm}NajIdb1+?4mIxQM{|5f~$`Jqn From 7f1971cd8192c3ce4714023c4d4e67d18d9174ba Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 13 Aug 2023 12:07:16 +0700 Subject: [PATCH 0962/1199] Add particle collider to runtime --- build.gradle.kts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index 4c37160bd..f0cf78496 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -161,6 +161,8 @@ dependencies { compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge-api:${jei_version}")) runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}")) + runtimeOnly(fg.deobf("ru.dbotthepony:particle-collider:0.2.0")) + implementation(fg.deobf("curse.maven:jade-324717:${jade_id}")) //runtimeOnly(fg.deobf("curse.maven:configured-457570:${configured_id}")) @@ -275,6 +277,7 @@ repositories { includeGroup("mekanism") includeGroup("lain.mods.cos") includeGroup("at.ridgo8.moreoverlays") + includeGroup("ru.dbotthepony") } } From 615912de8b0790e302ac523b5d1c79b5e0bb71a7 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 15 Aug 2023 10:52:49 +0700 Subject: [PATCH 0963/1199] Rename block rotation freedom once again --- .../mc/otm/datagen/DecorativeData.kt | 8 ++--- .../mc/otm/datagen/blocks/Banks.kt | 2 +- .../mc/otm/datagen/blocks/BlockStates.kt | 32 +++++++++---------- .../otm/datagen/blocks/ComplexBlockStates.kt | 12 +++---- .../blocks/MatteryBlockStateProvider.kt | 6 ++-- .../dbotthepony/mc/otm/block/MatteryBlock.kt | 6 ++-- .../mc/otm/block/RotatableMatteryBlock.kt | 12 +++---- .../mc/otm/block/decorative/EngineBlock.kt | 2 +- .../mc/otm/block/decorative/HoloSignBlock.kt | 2 +- .../mc/otm/block/decorative/LaboratoryLamp.kt | 2 +- .../tech/GravitationStabilizerBlockEntity.kt | 2 +- .../mc/otm/block/matter/MatterPanelBlock.kt | 8 ++--- .../mc/otm/block/storage/StorageBusBlock.kt | 5 ++- .../mc/otm/block/storage/StorageInterfaces.kt | 8 ++--- .../block/tech/GravitationStabilizerBlock.kt | 22 ++++++------- .../client/render/blockentity/BankRenderer.kt | 4 +-- .../GravitationStabilizerRenderer.kt | 4 +-- .../render/blockentity/HoloSignRenderer.kt | 2 +- .../mc/otm/core/math/BlockRotationFreedom.kt | 8 ++--- 19 files changed, 73 insertions(+), 74 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt index c104e939d..4a13dd03c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DecorativeData.kt @@ -230,16 +230,16 @@ fun addDecorativeData(blockStateProvider: MatteryBlockStateProvider, itemModelPr blockStateProvider.getVariantBuilder(MBlocks.LABORATORY_LAMP).forAllStates { return@forAllStates ConfiguredModel.builder() .modelFile(if (it[BlockStateProperties.LIT]) labLampOn!! else labLampOff!!) - .rotationX(it[BlockRotationFreedom.XZ_XY.property].front.xRotationBlockstateNorth()) - .rotationY(it[BlockRotationFreedom.XZ_XY.property].front.yRotationBlockstateNorth()) + .rotationX(it[BlockRotationFreedom.DIRECTIONAL.property].front.xRotationBlockstateNorth()) + .rotationY(it[BlockRotationFreedom.DIRECTIONAL.property].front.yRotationBlockstateNorth()) .build() } blockStateProvider.getVariantBuilder(MBlocks.LABORATORY_LAMP_INVERTED).forAllStates { return@forAllStates ConfiguredModel.builder() .modelFile(if (it[BlockStateProperties.LIT]) labLampOn!! else labLampOff!!) - .rotationX(it[BlockRotationFreedom.XZ_XY.property].front.xRotationBlockstateNorth()) - .rotationY(it[BlockRotationFreedom.XZ_XY.property].front.yRotationBlockstateNorth()) + .rotationX(it[BlockRotationFreedom.DIRECTIONAL.property].front.xRotationBlockstateNorth()) + .rotationY(it[BlockRotationFreedom.DIRECTIONAL.property].front.yRotationBlockstateNorth()) .build() } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt index a225b8566..7302eeb0c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/Banks.kt @@ -28,7 +28,7 @@ open class BatteryBankProvider(event: GatherDataEvent) : BlockStateProvider(even forAllStates { ConfiguredModel.builder() .modelFile(models().getExistingFile(modLocation("block/$block"))) - .rotationY(it[BlockRotationFreedom.XZ.property].front.yRotationBlockstateNorth()) + .rotationY(it[BlockRotationFreedom.HORIZONTAL.property].front.yRotationBlockstateNorth()) .build() } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt index 96e676f1a..780b7f7ac 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/BlockStates.kt @@ -36,54 +36,54 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { provider.exec { with(provider.getMultipartBuilder(MBlocks.PHANTOM_ATTRACTOR)) { - for (dir in BlockRotationFreedom.XZ.possibleValues) { + for (dir in BlockRotationFreedom.HORIZONTAL.possibleValues) { part().modelFile(provider.models().getExistingFile(modLocation("block/${MNames.PHANTOM_ATTRACTOR}"))) .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() .condition(BlockStateProperties.DOUBLE_BLOCK_HALF, DoubleBlockHalf.LOWER) - .condition(BlockRotationFreedom.XZ.property, dir) + .condition(BlockRotationFreedom.HORIZONTAL.property, dir) .end() } } with(provider.getMultipartBuilder(MBlocks.ANDROID_CHARGER)) { - for (dir in BlockRotationFreedom.XZ.possibleValues) { + for (dir in BlockRotationFreedom.HORIZONTAL.possibleValues) { for (part in AndroidChargerBlock.PART.possibleValues) { part().modelFile(provider.models().getExistingFile(modLocation("block/${MNames.ANDROID_CHARGER}_${part.serializedName}"))) .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() .condition(AndroidChargerBlock.PART, part) - .condition(BlockRotationFreedom.XZ.property, dir) + .condition(BlockRotationFreedom.HORIZONTAL.property, dir) .end() } } } with(provider.getMultipartBuilder(MBlocks.MATTER_BOTTLER)) { - for (dir in BlockRotationFreedom.XZ.possibleValues) { + for (dir in BlockRotationFreedom.HORIZONTAL.possibleValues) { for (enum in WorkerState.SEMI_WORKER_STATE.possibleValues) { part().modelFile(provider.models().getExistingFile(modLocation("matter_bottler_${enum.name.lowercase()}"))) .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() - .condition(BlockRotationFreedom.XZ.property, dir) + .condition(BlockRotationFreedom.HORIZONTAL.property, dir) .condition(WorkerState.WORKER_STATE, enum) .end() } } - for (dir in BlockRotationFreedom.XZ.possibleValues) { + for (dir in BlockRotationFreedom.HORIZONTAL.possibleValues) { for (enum in MatterBottlerBlock.SLOT_PROPERTIES) { part().modelFile(provider.models().getExistingFile(modLocation("matter_bottler_${enum.name}_open"))) .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() - .condition(BlockRotationFreedom.XZ.property, dir) + .condition(BlockRotationFreedom.HORIZONTAL.property, dir) .condition(enum, false) .end() part().modelFile(provider.models().getExistingFile(modLocation("matter_bottler_${enum.name}_closed"))) .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() - .condition(BlockRotationFreedom.XZ.property, dir) + .condition(BlockRotationFreedom.HORIZONTAL.property, dir) .condition(enum, true) .end() } @@ -116,19 +116,19 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { modLocation("${crate.registryName!!.path}_${if (it.getValue( CargoCrateBlock.IS_OPEN)) "open" else "closed"}") )) - .rotationY(it.getValue(BlockRotationFreedom.XZ.property).front.yRotationBlockstateNorth()) + .rotationY(it.getValue(BlockRotationFreedom.HORIZONTAL.property).front.yRotationBlockstateNorth()) .buildLast() ) } } with(provider.getMultipartBuilder(MBlocks.STORAGE_BUS)) { - for (dir in BlockRotationFreedom.XZ_XY.possibleValues) { + for (dir in BlockRotationFreedom.DIRECTIONAL.possibleValues) { part().modelFile(provider.models().getExistingFile(modLocation("storage_bus"))) .rotationX(dir.front.xRotationBlockstateNorth()) .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() - .condition(BlockRotationFreedom.XZ_XY.property, dir) + .condition(BlockRotationFreedom.DIRECTIONAL.property, dir) .end() part().modelFile(provider.models().getExistingFile(modLocation("storage_cable_connection"))) @@ -144,12 +144,12 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { } with(provider.getMultipartBuilder(MBlocks.STORAGE_IMPORTER)) { - for (dir in BlockRotationFreedom.XZ_XY.possibleValues) { + for (dir in BlockRotationFreedom.DIRECTIONAL.possibleValues) { part().modelFile(provider.models().getExistingFile(modLocation("storage_importer"))) .rotationX(dir.front.xRotationBlockstateNorth()) .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() - .condition(BlockRotationFreedom.XZ_XY.property, dir) + .condition(BlockRotationFreedom.DIRECTIONAL.property, dir) .end() part().modelFile(provider.models().getExistingFile(modLocation("storage_cable_connection"))) @@ -165,12 +165,12 @@ fun addBlockStates(provider: MatteryBlockStateProvider) { } with(provider.getMultipartBuilder(MBlocks.STORAGE_EXPORTER)) { - for (dir in BlockRotationFreedom.XZ_XY.possibleValues) { + for (dir in BlockRotationFreedom.DIRECTIONAL.possibleValues) { part().modelFile(provider.models().getExistingFile(modLocation("storage_exporter"))) .rotationX(dir.front.xRotationBlockstateNorth()) .rotationY(dir.front.yRotationBlockstateNorth()) .addModel() - .condition(BlockRotationFreedom.XZ_XY.property, dir) + .condition(BlockRotationFreedom.DIRECTIONAL.property, dir) .end() part().modelFile(provider.models().getExistingFile(modLocation("storage_cable_connection"))) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt index 05e00e779..dbadd096c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/ComplexBlockStates.kt @@ -12,12 +12,12 @@ import ru.dbotthepony.mc.otm.registry.MBlocks fun addComplexBlockStates(provider: MatteryBlockStateProvider) { with(provider.getMultipartBuilder(MBlocks.DRIVE_VIEWER)) { - for (facing in BlockRotationFreedom.XZ.possibleValues) { + for (facing in BlockRotationFreedom.HORIZONTAL.possibleValues) { part() .modelFile(provider.models().getExistingFile(modLocation("block/drive_viewer_drive_part"))) .rotationY(facing.front.yRotationBlockstateNorth()) .addModel() - .condition(BlockRotationFreedom.XZ.property, facing) + .condition(BlockRotationFreedom.HORIZONTAL.property, facing) .condition(DriveViewerBlock.DRIVE_PRESENT, true) for (workState in WorkerState.SEMI_WORKER_STATE.possibleValues) { @@ -26,25 +26,25 @@ fun addComplexBlockStates(provider: MatteryBlockStateProvider) { .rotationY(facing.front.yRotationBlockstateNorth()) .addModel() .condition(WorkerState.SEMI_WORKER_STATE, workState) - .condition(BlockRotationFreedom.XZ.property, facing) + .condition(BlockRotationFreedom.HORIZONTAL.property, facing) } } } with(provider.getMultipartBuilder(MBlocks.PATTERN_STORAGE)) { - for (facing in BlockRotationFreedom.XZ.possibleValues) { + for (facing in BlockRotationFreedom.HORIZONTAL.possibleValues) { part() .modelFile(provider.models().getExistingFile(modLocation("block/pattern_storage"))) .rotationY(facing.front.yRotationBlockstateNorth()) .addModel() - .condition(BlockRotationFreedom.XZ.property, facing) + .condition(BlockRotationFreedom.HORIZONTAL.property, facing) for (i in 0 .. 7) { part() .modelFile(provider.models().getExistingFile(modLocation("block/pattern/model$i"))) .rotationY(facing.front.yRotationBlockstateNorth()) .addModel() - .condition(BlockRotationFreedom.XZ.property, facing) + .condition(BlockRotationFreedom.HORIZONTAL.property, facing) .condition(PatternStorageBlock.PATTERN_STORAGE_DISKS_PROPS[i], true) } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt index 2b2724bbf..4aa2544be 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/blocks/MatteryBlockStateProvider.kt @@ -21,16 +21,16 @@ private val EMPTY: BlockStateTransform = { _, _, _ -> null } private fun initialTransform(it: BlockState, modelPath: String, builder: ConfiguredModel.Builder<*>): String { @Suppress("NAME_SHADOWING") var modelPath = modelPath - it.getValueNullable(BlockRotationFreedom.XZ.property)?.let { + it.getValueNullable(BlockRotationFreedom.HORIZONTAL.property)?.let { builder.rotationY(it.front.yRotationBlockstateNorth()) } - it.getValueNullable(BlockRotationFreedom.XZ_XY.property)?.let { + it.getValueNullable(BlockRotationFreedom.DIRECTIONAL.property)?.let { builder.rotationY(it.front.yRotationBlockstateNorth()) builder.rotationX(it.front.xRotationBlockstateNorth()) } - it.getValueNullable(BlockRotationFreedom.XZ_XY_ZY.property)?.let { + it.getValueNullable(BlockRotationFreedom.DIRECTIONAL_WITH_ROTATION.property)?.let { builder.rotationY(it.front.yRotationBlockstateNorth() + it.top.yRotationBlockstateNorth()) builder.rotationX(it.front.xRotationBlockstateNorth()) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt index c30bdb301..e234863ad 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt @@ -115,9 +115,9 @@ abstract class MatteryBlock @JvmOverloads constructor( val state = blockState.getOptionalValue(WorkerState.WORKER_STATE).or { blockState.getOptionalValue(WorkerState.SEMI_WORKER_STATE) } if (state.isPresent && state.get() == WorkerState.WORKING) { - val state2 = blockState.getOptionalValue(BlockRotationFreedom.XZ.property) - .or { blockState.getOptionalValue(BlockRotationFreedom.XZ_XY.property) } - .or { blockState.getOptionalValue(BlockRotationFreedom.XZ_XY_ZY.property) } + val state2 = blockState.getOptionalValue(BlockRotationFreedom.HORIZONTAL.property) + .or { blockState.getOptionalValue(BlockRotationFreedom.DIRECTIONAL.property) } + .or { blockState.getOptionalValue(BlockRotationFreedom.DIRECTIONAL_WITH_ROTATION.property) } if (state2.isPresent) { val direction = state2.get() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/RotatableMatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/RotatableMatteryBlock.kt index 652634be9..602ec1b99 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/RotatableMatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/RotatableMatteryBlock.kt @@ -10,7 +10,7 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom -abstract class RotatableMatteryBlock @JvmOverloads constructor(properties: Properties = DEFAULT_PROPERTIES) : MatteryBlock(properties) { +abstract class RotatableMatteryBlock(properties: Properties = DEFAULT_PROPERTIES) : MatteryBlock(properties) { init { @Suppress("LeakingThis") registerDefaultState(getStateDefinition().any().setValue(rotationProperty, BlockRotation.SOUTH)) @@ -22,17 +22,17 @@ abstract class RotatableMatteryBlock @JvmOverloads constructor(properties: Prope override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { return when (val freedom = rotationFreedom()) { - BlockRotationFreedom.XZ -> defaultBlockState().setValue( + BlockRotationFreedom.HORIZONTAL -> defaultBlockState().setValue( freedom.property, freedom.of(if (faceToPlayer(context)) context.horizontalDirection.opposite else context.horizontalDirection) ) - BlockRotationFreedom.XZ_XY -> defaultBlockState().setValue( + BlockRotationFreedom.DIRECTIONAL -> defaultBlockState().setValue( freedom.property, freedom.of(if (faceToPlayer(context)) context.nearestLookingDirection.opposite else context.nearestLookingDirection) ) - BlockRotationFreedom.XZ_XY_ZY -> { + BlockRotationFreedom.DIRECTIONAL_WITH_ROTATION -> { val primary = if (faceToPlayer(context)) context.nearestLookingDirection.opposite else context.nearestLookingDirection var secondary = if (faceToPlayer(context)) context.horizontalDirection else context.horizontalDirection.opposite @@ -46,7 +46,7 @@ abstract class RotatableMatteryBlock @JvmOverloads constructor(properties: Prope ) } - BlockRotationFreedom.FOUR -> TODO("Can't rotate with four rotation freedom yet") + BlockRotationFreedom.FULL -> TODO("Can't rotate with four rotation freedom yet") } } @@ -59,7 +59,7 @@ abstract class RotatableMatteryBlock @JvmOverloads constructor(properties: Prope val rotationProperty get() = rotationFreedom().property open fun rotationFreedom(): BlockRotationFreedom { - return BlockRotationFreedom.XZ + return BlockRotationFreedom.HORIZONTAL } open fun faceToPlayer(context: BlockPlaceContext): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt index 44ea148ab..d879d13a3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt @@ -29,7 +29,7 @@ class EngineBlock : RotatableMatteryBlock(Properties.of().mapColor(MapColor.COLO } override fun rotationFreedom(): BlockRotationFreedom { - return BlockRotationFreedom.XZ_XY + return BlockRotationFreedom.DIRECTIONAL } private val shapes = getShapeForEachState { BlockShapes.ENGINE.rotateFromNorth(it[rotationProperty]).computeShape() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt index 2d7f0998f..b784c2f1d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt @@ -15,7 +15,7 @@ import ru.dbotthepony.mc.otm.shapes.BlockShapes class HoloSignBlock : RotatableMatteryBlock(), EntityBlock { override fun rotationFreedom(): BlockRotationFreedom { - return BlockRotationFreedom.XZ_XY_ZY + return BlockRotationFreedom.DIRECTIONAL_WITH_ROTATION } override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt index 4b942fb23..3dc4aa81c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt @@ -26,7 +26,7 @@ import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.once import ru.dbotthepony.mc.otm.registry.MBlocks -private val FACING_FULL = BlockRotationFreedom.XZ_XY.property +private val FACING_FULL = BlockRotationFreedom.DIRECTIONAL.property class LaboratoryLampLight : Block(Properties.of().strength(-1.0F, 3600000.8F).noCollission().noLootTable().replaceable().lightLevel { 15 }) { override fun createBlockStateDefinition(builder: StateDefinition.Builder) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/GravitationStabilizerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/GravitationStabilizerBlockEntity.kt index d5f6e1bc4..5e119bf06 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/GravitationStabilizerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/GravitationStabilizerBlockEntity.kt @@ -26,7 +26,7 @@ class GravitationStabilizerBlockEntity(p_155229_: BlockPos, p_155230_: BlockStat fun tick(level: Level) { var findBlackHole: BlackHoleBlockEntity? = null - val dir = blockState[BlockRotationFreedom.XZ_XY].normal + val dir = blockState[BlockRotationFreedom.DIRECTIONAL].normal for (i in 2 .. RANGE) { val pos = blockPos + dir * i diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterPanelBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterPanelBlock.kt index ca4502941..00cc3a746 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterPanelBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterPanelBlock.kt @@ -25,10 +25,10 @@ class MatterPanelBlock : RotatableMatteryBlock(), EntityBlock { private val shapes: ImmutableMap init { - registerDefaultState(getStateDefinition().any().setValue(BlockRotationFreedom.XZ_XY.property, BlockRotation.SOUTH)) + registerDefaultState(getStateDefinition().any().setValue(BlockRotationFreedom.DIRECTIONAL.property, BlockRotation.SOUTH)) shapes = getShapeForEachState { - when (it[BlockRotationFreedom.XZ_XY.property].front) { + when (it[BlockRotationFreedom.DIRECTIONAL.property].front) { Direction.NORTH -> Shapes.box( 0.0, 0.0, @@ -91,10 +91,10 @@ class MatterPanelBlock : RotatableMatteryBlock(), EntityBlock { } override fun rotationFreedom(): BlockRotationFreedom { - return BlockRotationFreedom.XZ_XY + return BlockRotationFreedom.DIRECTIONAL } override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { - return defaultBlockState().setValue(BlockRotationFreedom.XZ_XY.property, BlockRotation.of(context.clickedFace)) + return defaultBlockState().setValue(BlockRotationFreedom.DIRECTIONAL.property, BlockRotation.of(context.clickedFace)) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt index 1894edeca..1fb0b65d7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt @@ -30,11 +30,10 @@ import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes import ru.dbotthepony.mc.otm.core.math.unaryMinus -import ru.dbotthepony.mc.otm.oncePre class StorageBusBlock : RotatableMatteryBlock(), EntityBlock { override fun rotationFreedom(): BlockRotationFreedom { - return BlockRotationFreedom.XZ_XY + return BlockRotationFreedom.DIRECTIONAL } init { @@ -52,7 +51,7 @@ class StorageBusBlock : RotatableMatteryBlock(), EntityBlock { } override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { - return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.XZ_XY.property, BlockRotation.of(-context.clickedFace)) + return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.DIRECTIONAL.property, BlockRotation.of(-context.clickedFace)) } override fun appendHoverText( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt index 331dfe24a..54ee44c87 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt @@ -34,7 +34,7 @@ import ru.dbotthepony.mc.otm.core.math.unaryMinus class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock { override fun rotationFreedom(): BlockRotationFreedom { - return BlockRotationFreedom.XZ_XY + return BlockRotationFreedom.DIRECTIONAL } override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { @@ -76,7 +76,7 @@ class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock { } override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { - return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.XZ_XY.property, BlockRotation.of(-context.clickedFace)) + return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.DIRECTIONAL.property, BlockRotation.of(-context.clickedFace)) } override fun appendHoverText( @@ -116,7 +116,7 @@ class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock { class StorageExporterBlock : RotatableMatteryBlock(), EntityBlock { override fun rotationFreedom(): BlockRotationFreedom { - return BlockRotationFreedom.XZ_XY + return BlockRotationFreedom.DIRECTIONAL } override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { @@ -169,7 +169,7 @@ class StorageExporterBlock : RotatableMatteryBlock(), EntityBlock { } override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { - return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.XZ_XY.property, BlockRotation.of(-context.clickedFace)) + return super.getStateForPlacement(context)?.setValue(BlockRotationFreedom.DIRECTIONAL.property, BlockRotation.of(-context.clickedFace)) } private val shapes = getShapeForEachState { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt index 3e647b0e2..e2f33127e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt @@ -55,7 +55,7 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock { } override fun rotationFreedom(): BlockRotationFreedom { - return BlockRotationFreedom.XZ_XY + return BlockRotationFreedom.DIRECTIONAL } override fun createBlockStateDefinition(builder: StateDefinition.Builder) { @@ -68,7 +68,7 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock { val blockPos = context.clickedPos val level = context.level - for (face in BlockRotationFreedom.XZ_XY.possibleValues) { + for (face in BlockRotationFreedom.DIRECTIONAL.possibleValues) { val dir = face.normal for (i in 1 ..GravitationStabilizerBlockEntity.RANGE) { @@ -78,14 +78,14 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock { if (!getState.isAir) { if (chunk.getBlockEntity(pos) is BlackHoleBlockEntity) { - state = state.setValue(BlockRotationFreedom.XZ_XY.property, face) + state = state.setValue(BlockRotationFreedom.DIRECTIONAL.property, face) break } } } } - val bbPos = blockPos + state.getValue(BlockRotationFreedom.XZ_XY.property).normal + val bbPos = blockPos + state.getValue(BlockRotationFreedom.DIRECTIONAL.property).normal if (!context.level.isInWorldBounds(bbPos)) return null if (!level.getBlockState(bbPos).canBeReplaced(context)) return null @@ -103,9 +103,9 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock { super.setPlacedBy(level, blockPos, blockState, entity, itemStack) if (!level.isClientSide) { - val bbPos = blockPos + blockState.getValue(BlockRotationFreedom.XZ_XY.property).normal + val bbPos = blockPos + blockState.getValue(BlockRotationFreedom.DIRECTIONAL.property).normal val newState = MBlocks.GRAVITATION_STABILIZER_LENS.defaultBlockState() - .setValue(BlockRotationFreedom.XZ_XY.property, blockState.getValue(BlockRotationFreedom.XZ_XY.property)) + .setValue(BlockRotationFreedom.DIRECTIONAL.property, blockState.getValue(BlockRotationFreedom.DIRECTIONAL.property)) level.setBlock(bbPos, newState, UPDATE_ALL) } @@ -137,7 +137,7 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock { p_60557_: BlockPos, p_60558_: CollisionContext ): VoxelShape { - return SHAPES[p_60555_[BlockRotationFreedom.XZ_XY].ordinal] + return SHAPES[p_60555_[BlockRotationFreedom.DIRECTIONAL].ordinal] } companion object { @@ -155,14 +155,14 @@ class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock { } fun getBoundingBlockPos(blockState: BlockState, blockPos: BlockPos): BlockPos { - return blockPos + blockState.getValue(BlockRotationFreedom.XZ_XY.property).normal + return blockPos + blockState.getValue(BlockRotationFreedom.DIRECTIONAL.property).normal } } } class BlockGravitationStabilizerLens : RotatableMatteryBlock(props) { override fun rotationFreedom(): BlockRotationFreedom { - return BlockRotationFreedom.XZ_XY + return BlockRotationFreedom.DIRECTIONAL } override fun createBlockStateDefinition(builder: StateDefinition.Builder) { @@ -196,7 +196,7 @@ class BlockGravitationStabilizerLens : RotatableMatteryBlock(props) { p_60557_: BlockPos, p_60558_: CollisionContext ): VoxelShape { - return SHAPES[p_60555_[BlockRotationFreedom.XZ_XY].front.ordinal] + return SHAPES[p_60555_[BlockRotationFreedom.DIRECTIONAL].front.ordinal] } companion object { @@ -205,7 +205,7 @@ class BlockGravitationStabilizerLens : RotatableMatteryBlock(props) { } fun getBoundingBlockPos(blockState: BlockState, blockPos: BlockPos): BlockPos { - return blockPos + blockState.getValue(BlockRotationFreedom.XZ_XY.property).front.opposite.normal + return blockPos + blockState.getValue(BlockRotationFreedom.DIRECTIONAL.property).front.opposite.normal } private val SHAPES = arrayOf( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt index 9da03e508..07969b2b0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt @@ -49,7 +49,7 @@ abstract class BankRenderer(private val context: B stack.pushPose() stack.translate(0.5f, 0.5f, 0.5f) - stack.rotate(blockEntity.blockState[BlockRotationFreedom.XZ.property].front) + stack.rotate(blockEntity.blockState[BlockRotationFreedom.HORIZONTAL.property].front) stack.translate(-0.5f, -0.5f, -0.5f) for ((i, model) in models.withIndex()) { @@ -73,7 +73,7 @@ abstract class BankRenderer(private val context: B stack.pushPose() - val facing = blockEntity.blockState[BlockRotationFreedom.XZ].front + val facing = blockEntity.blockState[BlockRotationFreedom.HORIZONTAL].front val rotateFacing = facing == Direction.NORTH || facing == Direction.SOUTH if (rotateFacing) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt index b57b863b4..60e1b97f4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/GravitationStabilizerRenderer.kt @@ -47,7 +47,7 @@ class GravitationStabilizerRenderer(private val context: BlockEntityRendererProv var len = 64.0 var lenI = 64 - val normal = tile.blockState[BlockRotationFreedom.XZ_XY].normal + val normal = tile.blockState[BlockRotationFreedom.DIRECTIONAL].normal val level = tile.level var bhTile: BlackHoleBlockEntity? = null @@ -68,7 +68,7 @@ class GravitationStabilizerRenderer(private val context: BlockEntityRendererProv poseStack.pushPose() poseStack.translate(0.5, 0.5, 0.5) - val facing = tile.blockState[BlockRotationFreedom.XZ_XY].front + val facing = tile.blockState[BlockRotationFreedom.DIRECTIONAL].front val rotateZ: Double val rotateY: Double 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 015b6f26c..4e1be4a88 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 @@ -27,7 +27,7 @@ class HoloSignRenderer(private val context: BlockEntityRendererProvider.Context) return poseStack.pushPose() - poseStack.rotateWithBlockFacing(tile.blockState[BlockRotationFreedom.XZ_XY_ZY]) + poseStack.rotateWithBlockFacing(tile.blockState[BlockRotationFreedom.DIRECTIONAL_WITH_ROTATION]) poseStack.translate(0.5f, 0.5f, 0.5f) poseStack.scale(0.01f, 0.01f, 0.01f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotationFreedom.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotationFreedom.kt index 405446d33..8a7328ca5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotationFreedom.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/BlockRotationFreedom.kt @@ -8,13 +8,13 @@ import java.util.EnumMap * Controls the rotational freedom of block in space, employing [property] and [of] to get valid value from set of possible values */ enum class BlockRotationFreedom(vararg values: BlockRotation) { - XZ( + HORIZONTAL( BlockRotation.NORTH, BlockRotation.SOUTH, BlockRotation.WEST, BlockRotation.EAST, ), - XZ_XY( + DIRECTIONAL( BlockRotation.DOWN, BlockRotation.UP, BlockRotation.NORTH, @@ -22,7 +22,7 @@ enum class BlockRotationFreedom(vararg values: BlockRotation) { BlockRotation.WEST, BlockRotation.EAST, ), - XZ_XY_ZY( + DIRECTIONAL_WITH_ROTATION( BlockRotation.DOWN, BlockRotation.UP, BlockRotation.NORTH, @@ -40,7 +40,7 @@ enum class BlockRotationFreedom(vararg values: BlockRotation) { /** * These rotations are impossible to achieve using blockstates because blockstate def can't rotate models in XY plane (z axis) */ - FOUR( + FULL( BlockRotation.DOWN, BlockRotation.UP, BlockRotation.NORTH, From 61b83d5f5a91a89c4e692d316e4517e4968a889b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 15 Aug 2023 20:04:27 +0700 Subject: [PATCH 0964/1199] Painter table --- .../ru/dbotthepony/mc/otm/datagen/DataGen.kt | 2 + .../mc/otm/datagen/lang/English.kt | 4 + .../mc/otm/datagen/lang/Russian.kt | 4 + .../mc/otm/datagen/loot/LootTablesData.kt | 1 + .../datagen/recipes/CraftingTableRecipes.kt | 7 + .../mc/otm/datagen/recipes/PainterRecipes.kt | 296 ++++++++++++++++++ .../dbotthepony/mc/otm/datagen/tags/Tags.kt | 1 + .../block/entity/tech/PainterBlockEntity.kt | 197 ++++++++++++ .../mc/otm/block/tech/PainterBlock.kt | 22 ++ .../mc/otm/client/render/IGUIRenderable.kt | 36 ++- .../otm/client/screen/panels/EditablePanel.kt | 2 +- .../panels/util/ScrollableCanvasPanel.kt | 72 +++++ .../otm/client/screen/tech/PainterScreen.kt | 152 +++++++++ .../compat/jei/IGUIRenderable2IDrawable.kt | 19 ++ .../mc/otm/compat/jei/JEIPlugin.kt | 3 + .../otm/compat/jei/PainterRecipeCategory.kt | 82 +++++ .../mc/otm/compat/jei/SkinDrawable.kt | 19 -- .../mc/otm/compat/jei/StretchingDrawable.kt | 19 -- .../mc/otm/container/ContainerHandler.kt | 23 +- .../mc/otm/container/HandlerFilter.kt | 8 + .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 7 + .../mc/otm/core/util/FriendlyStreams.kt | 10 + .../mc/otm/core/util/StreamCodecs.kt | 1 + .../mc/otm/menu/tech/PainterMenu.kt | 119 +++++++ .../mc/otm/recipe/PainterRecipe.kt | 135 ++++++++ .../mc/otm/registry/MBlockEntities.kt | 73 +++-- .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 2 + .../ru/dbotthepony/mc/otm/registry/MItems.kt | 4 +- .../ru/dbotthepony/mc/otm/registry/MMenus.kt | 4 + .../ru/dbotthepony/mc/otm/registry/MNames.kt | 1 + .../dbotthepony/mc/otm/registry/MRecipes.kt | 3 + 31 files changed, 1233 insertions(+), 95 deletions(-) create mode 100644 src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PainterBlockEntity.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PainterBlock.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/ScrollableCanvasPanel.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PainterScreen.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/IGUIRenderable2IDrawable.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PainterRecipeCategory.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/SkinDrawable.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/StretchingDrawable.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PainterMenu.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt index 47ffc4fdc..4f9fb145e 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -51,6 +51,7 @@ import ru.dbotthepony.mc.otm.datagen.recipes.addDecorativesRecipes import ru.dbotthepony.mc.otm.datagen.recipes.addPlatePressRecipes import ru.dbotthepony.mc.otm.datagen.recipes.addShapelessRecipes import ru.dbotthepony.mc.otm.datagen.recipes.addOreSmeltingRecipes +import ru.dbotthepony.mc.otm.datagen.recipes.addPainterRecipes import ru.dbotthepony.mc.otm.datagen.tags.TagsProvider import ru.dbotthepony.mc.otm.datagen.tags.addTags import ru.dbotthepony.mc.otm.matter.MatterDataProvider @@ -562,6 +563,7 @@ object DataGen { addDecorativesRecipes(recipeProvider, consumer) addShapelessRecipes(consumer) addOreSmeltingRecipes(consumer) + addPainterRecipes(consumer) } addPlatePressRecipes(recipeProvider) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 447e72d02..b8efe97d4 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -120,6 +120,9 @@ private fun misc(provider: MatteryLanguageProvider) { gui("help.slot_filters", "Hold CTRL to setup slot filters") gui("help.slot_charging", "Hold ALT to switch slot charging") + gui("needs", "Needs %s") + gui("needs_x", "Needs %s x%d") + misc("needs_no_power", "Requires no power to operate") gui("lock_holo_screen", "Lock contents") @@ -428,6 +431,7 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.MATTER_RECONSTRUCTOR, "desc", "Repairs tools using matter") add(MBlocks.DEV_CHEST, "Dev Chest") add(MBlocks.DEV_CHEST, "desc", "Contains all items present in game") + add(MBlocks.PAINTER, "Painting Table") add(MBlocks.FLUID_TANK, "Fluid Tank") add(MBlocks.FLUID_TANK, "named", "Fluid Tank (%s)") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 206dc139c..6bc478530 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -128,6 +128,9 @@ private fun misc(provider: MatteryLanguageProvider) { gui("help.slot_filters", "Удерживайте CTRL для настройки фильтрации слотов") gui("help.slot_charging", "Удерживайте ALT для переключения зарядки слотов") + gui("needs", "Требуется %s") + gui("needs_x", "Требуется %s x%d") + misc("needs_no_power", "Не требует энергии для работы") gui("lock_holo_screen", "Заблокировать содержимое") @@ -430,6 +433,7 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.MATTER_RECONSTRUCTOR, "desc", "Чинит инструменты используя материю") add(MBlocks.DEV_CHEST, "Сундук разработчика") add(MBlocks.DEV_CHEST, "desc", "Хранит все предметы, которые есть в игре") + add(MBlocks.PAINTER, "Стол маляра") add(MBlocks.FLUID_TANK, "Жидкостный бак") add(MBlocks.FLUID_TANK, "named", "Жидкостный бак (%s)") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index e5c1b8f4c..b21b8f15a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -133,6 +133,7 @@ fun addLootTables(lootTables: LootTables) { lootTables.tile(MBlocks.ESSENCE_STORAGE) lootTables.tile(MBlocks.MATTER_RECONSTRUCTOR) lootTables.tile(MBlocks.FLUID_TANK) + lootTables.tile(MBlocks.PAINTER) lootTables.tile(MBlocks.ENERGY_SERVO) lootTables.tile(MBlocks.ENERGY_COUNTER) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index be441943c..6741a9151 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -433,4 +433,11 @@ fun addCraftingTableRecipes(consumer: Consumer) { .row(MItemTags.IRON_PLATES, MItemTags.IRON_PLATES, MItemTags.IRON_PLATES) .unlockedBy(Items.WATER_BUCKET) .build(consumer) + + MatteryRecipe(MItems.PAINTER, category = machinesCategory) + .row(Items.BRUSH, Items.BUCKET, Items.WATER_BUCKET) + .row(MItemTags.IRON_PLATES, Items.BUCKET, MItemTags.IRON_PLATES) + .row(MItemTags.IRON_PLATES, MItemTags.CRAFTING_TABLES, MItemTags.IRON_PLATES) + .unlockedBy(Tags.Items.DYES) + .build(consumer) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt new file mode 100644 index 000000000..f700cb50d --- /dev/null +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt @@ -0,0 +1,296 @@ +package ru.dbotthepony.mc.otm.datagen.recipes + +import net.minecraft.data.recipes.FinishedRecipe +import net.minecraft.world.item.DyeColor +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.Items +import net.minecraft.world.item.crafting.Ingredient +import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.datagen.modLocation +import ru.dbotthepony.mc.otm.recipe.PainterRecipe +import ru.dbotthepony.mc.otm.registry.MItems +import ru.dbotthepony.mc.otm.registry.MRegistry +import java.util.function.Consumer + +private val Item.recipeName get() = registryName!!.namespace + "/" + registryName!!.path + +private fun generate(consumer: Consumer, items: Map, amount: Int = 1) { + for ((k1, v1) in items) { + if (k1 == null) continue + for ((k2, v2) in items) { + if (k2 == null || k1 == k2) continue + + consumer.accept(PainterRecipe( + modLocation("painter/" + v2.recipeName + "/" + v1.recipeName), + Ingredient.of(v1), + ItemStack(v2), + //if (k1 == DyeColor.WHITE || k2 == DyeColor.BLACK) setOf(k2) else setOf(DyeColor.BLACK, k2) + mapOf(k2 to amount) + ).toFinished()) + } + } +} + +private fun generate(consumer: Consumer, default: Item, items: Map, amount: Int = 1, cleaning: Boolean = true) { + generate(consumer, items) + + if (cleaning) + cleaning(consumer, default, items) + + for ((k1, v1) in items) { + if (k1 == null) continue + + consumer.accept(PainterRecipe( + modLocation("painter/" + default.recipeName + "/" + v1.recipeName), + Ingredient.of(default), + ItemStack(v1), + mapOf(k1 to amount) + ).toFinished()) + } +} + +private fun cleaning(consumer: Consumer, to: Item, from: Map) { + for ((k1, v1) in from) { + if (k1 == null) continue + + consumer.accept(PainterRecipe( + modLocation("painter/cleaning/" + to.recipeName + "/" + v1.recipeName), + Ingredient.of(v1), + ItemStack(to), + setOf() + ).toFinished()) + } +} + +private fun striped(consumer: Consumer, name: String, items: List>>, base: Map) { + for ((stripeItem, colors) in items) { + val (baseColor, stripe) = colors + + consumer.accept(PainterRecipe( + modLocation("painter/stripes_$name/${baseColor.getName()}/${stripe.getName()}"), + Ingredient.of(base[baseColor]), + ItemStack(stripeItem), + setOf(stripe) + ).toFinished()) + } +} + +fun addPainterRecipes(consumer: Consumer) { + generate(consumer, mapOf( + DyeColor.WHITE to Items.WHITE_WOOL, + DyeColor.ORANGE to Items.ORANGE_WOOL, + DyeColor.MAGENTA to Items.MAGENTA_WOOL, + DyeColor.LIGHT_BLUE to Items.LIGHT_BLUE_WOOL, + DyeColor.YELLOW to Items.YELLOW_WOOL, + DyeColor.LIME to Items.LIME_WOOL, + DyeColor.PINK to Items.PINK_WOOL, + DyeColor.GRAY to Items.GRAY_WOOL, + DyeColor.LIGHT_GRAY to Items.LIGHT_GRAY_WOOL, + DyeColor.CYAN to Items.CYAN_WOOL, + DyeColor.PURPLE to Items.PURPLE_WOOL, + DyeColor.BLUE to Items.BLUE_WOOL, + DyeColor.BROWN to Items.BROWN_WOOL, + DyeColor.GREEN to Items.GREEN_WOOL, + DyeColor.RED to Items.RED_WOOL, + DyeColor.BLACK to Items.BLACK_WOOL, + )) + + generate(consumer, mapOf( + DyeColor.WHITE to Items.WHITE_CARPET, + DyeColor.ORANGE to Items.ORANGE_CARPET, + DyeColor.MAGENTA to Items.MAGENTA_CARPET, + DyeColor.LIGHT_BLUE to Items.LIGHT_BLUE_CARPET, + DyeColor.YELLOW to Items.YELLOW_CARPET, + DyeColor.LIME to Items.LIME_CARPET, + DyeColor.PINK to Items.PINK_CARPET, + DyeColor.GRAY to Items.GRAY_CARPET, + DyeColor.LIGHT_GRAY to Items.LIGHT_GRAY_CARPET, + DyeColor.CYAN to Items.CYAN_CARPET, + DyeColor.PURPLE to Items.PURPLE_CARPET, + DyeColor.BLUE to Items.BLUE_CARPET, + DyeColor.BROWN to Items.BROWN_CARPET, + DyeColor.GREEN to Items.GREEN_CARPET, + DyeColor.RED to Items.RED_CARPET, + DyeColor.BLACK to Items.BLACK_CARPET, + )) + + generate(consumer, mapOf( + DyeColor.WHITE to Items.WHITE_BED, + DyeColor.ORANGE to Items.ORANGE_BED, + DyeColor.MAGENTA to Items.MAGENTA_BED, + DyeColor.LIGHT_BLUE to Items.LIGHT_BLUE_BED, + DyeColor.YELLOW to Items.YELLOW_BED, + DyeColor.LIME to Items.LIME_BED, + DyeColor.PINK to Items.PINK_BED, + DyeColor.GRAY to Items.GRAY_BED, + DyeColor.LIGHT_GRAY to Items.LIGHT_GRAY_BED, + DyeColor.CYAN to Items.CYAN_BED, + DyeColor.PURPLE to Items.PURPLE_BED, + DyeColor.BLUE to Items.BLUE_BED, + DyeColor.BROWN to Items.BROWN_BED, + DyeColor.GREEN to Items.GREEN_BED, + DyeColor.RED to Items.RED_BED, + DyeColor.BLACK to Items.BLACK_BED, + ), 3) + + generate(consumer, mapOf( + DyeColor.WHITE to Items.WHITE_CANDLE, + DyeColor.ORANGE to Items.ORANGE_CANDLE, + DyeColor.MAGENTA to Items.MAGENTA_CANDLE, + DyeColor.LIGHT_BLUE to Items.LIGHT_BLUE_CANDLE, + DyeColor.YELLOW to Items.YELLOW_CANDLE, + DyeColor.LIME to Items.LIME_CANDLE, + DyeColor.PINK to Items.PINK_CANDLE, + DyeColor.GRAY to Items.GRAY_CANDLE, + DyeColor.LIGHT_GRAY to Items.LIGHT_GRAY_CANDLE, + DyeColor.CYAN to Items.CYAN_CANDLE, + DyeColor.PURPLE to Items.PURPLE_CANDLE, + DyeColor.BLUE to Items.BLUE_CANDLE, + DyeColor.BROWN to Items.BROWN_CANDLE, + DyeColor.GREEN to Items.GREEN_CANDLE, + DyeColor.RED to Items.RED_CANDLE, + DyeColor.BLACK to Items.BLACK_CANDLE, + )) + + generate(consumer, mapOf( + DyeColor.WHITE to Items.WHITE_CONCRETE, + DyeColor.ORANGE to Items.ORANGE_CONCRETE, + DyeColor.MAGENTA to Items.MAGENTA_CONCRETE, + DyeColor.LIGHT_BLUE to Items.LIGHT_BLUE_CONCRETE, + DyeColor.YELLOW to Items.YELLOW_CONCRETE, + DyeColor.LIME to Items.LIME_CONCRETE, + DyeColor.PINK to Items.PINK_CONCRETE, + DyeColor.GRAY to Items.GRAY_CONCRETE, + DyeColor.LIGHT_GRAY to Items.LIGHT_GRAY_CONCRETE, + DyeColor.CYAN to Items.CYAN_CONCRETE, + DyeColor.PURPLE to Items.PURPLE_CONCRETE, + DyeColor.BLUE to Items.BLUE_CONCRETE, + DyeColor.BROWN to Items.BROWN_CONCRETE, + DyeColor.GREEN to Items.GREEN_CONCRETE, + DyeColor.RED to Items.RED_CONCRETE, + DyeColor.BLACK to Items.BLACK_CONCRETE, + )) + + generate(consumer, mapOf( + DyeColor.WHITE to Items.WHITE_CONCRETE_POWDER, + DyeColor.ORANGE to Items.ORANGE_CONCRETE_POWDER, + DyeColor.MAGENTA to Items.MAGENTA_CONCRETE_POWDER, + DyeColor.LIGHT_BLUE to Items.LIGHT_BLUE_CONCRETE_POWDER, + DyeColor.YELLOW to Items.YELLOW_CONCRETE_POWDER, + DyeColor.LIME to Items.LIME_CONCRETE_POWDER, + DyeColor.PINK to Items.PINK_CONCRETE_POWDER, + DyeColor.GRAY to Items.GRAY_CONCRETE_POWDER, + DyeColor.LIGHT_GRAY to Items.LIGHT_GRAY_CONCRETE_POWDER, + DyeColor.CYAN to Items.CYAN_CONCRETE_POWDER, + DyeColor.PURPLE to Items.PURPLE_CONCRETE_POWDER, + DyeColor.BLUE to Items.BLUE_CONCRETE_POWDER, + DyeColor.BROWN to Items.BROWN_CONCRETE_POWDER, + DyeColor.GREEN to Items.GREEN_CONCRETE_POWDER, + DyeColor.RED to Items.RED_CONCRETE_POWDER, + DyeColor.BLACK to Items.BLACK_CONCRETE_POWDER, + )) + + generate(consumer, MRegistry.CARGO_CRATES.item, MRegistry.CARGO_CRATES.items) + generate(consumer, MRegistry.TRITANIUM_BLOCK.item, MRegistry.TRITANIUM_BLOCK.items) + generate(consumer, MRegistry.TRITANIUM_STAIRS.item, MRegistry.TRITANIUM_STAIRS.items) + generate(consumer, MRegistry.TRITANIUM_SLAB.item, MRegistry.TRITANIUM_SLAB.items) + generate(consumer, MRegistry.TRITANIUM_WALL.item, MRegistry.TRITANIUM_WALL.items) + + generate(consumer, Items.TERRACOTTA, mapOf( + DyeColor.WHITE to Items.WHITE_TERRACOTTA, + DyeColor.ORANGE to Items.ORANGE_TERRACOTTA, + DyeColor.MAGENTA to Items.MAGENTA_TERRACOTTA, + DyeColor.LIGHT_BLUE to Items.LIGHT_BLUE_TERRACOTTA, + DyeColor.YELLOW to Items.YELLOW_TERRACOTTA, + DyeColor.LIME to Items.LIME_TERRACOTTA, + DyeColor.PINK to Items.PINK_TERRACOTTA, + DyeColor.GRAY to Items.GRAY_TERRACOTTA, + DyeColor.LIGHT_GRAY to Items.LIGHT_GRAY_TERRACOTTA, + DyeColor.CYAN to Items.CYAN_TERRACOTTA, + DyeColor.PURPLE to Items.PURPLE_TERRACOTTA, + DyeColor.BLUE to Items.BLUE_TERRACOTTA, + DyeColor.BROWN to Items.BROWN_TERRACOTTA, + DyeColor.GREEN to Items.GREEN_TERRACOTTA, + DyeColor.RED to Items.RED_TERRACOTTA, + DyeColor.BLACK to Items.BLACK_TERRACOTTA, + ), cleaning = false) + + generate(consumer, Items.SHULKER_BOX, mapOf( + DyeColor.WHITE to Items.WHITE_SHULKER_BOX, + DyeColor.ORANGE to Items.ORANGE_SHULKER_BOX, + DyeColor.MAGENTA to Items.MAGENTA_SHULKER_BOX, + DyeColor.LIGHT_BLUE to Items.LIGHT_BLUE_SHULKER_BOX, + DyeColor.YELLOW to Items.YELLOW_SHULKER_BOX, + DyeColor.LIME to Items.LIME_SHULKER_BOX, + DyeColor.PINK to Items.PINK_SHULKER_BOX, + DyeColor.GRAY to Items.GRAY_SHULKER_BOX, + DyeColor.LIGHT_GRAY to Items.LIGHT_GRAY_SHULKER_BOX, + DyeColor.CYAN to Items.CYAN_SHULKER_BOX, + DyeColor.PURPLE to Items.PURPLE_SHULKER_BOX, + DyeColor.BLUE to Items.BLUE_SHULKER_BOX, + DyeColor.BROWN to Items.BROWN_SHULKER_BOX, + DyeColor.GREEN to Items.GREEN_SHULKER_BOX, + DyeColor.RED to Items.RED_SHULKER_BOX, + DyeColor.BLACK to Items.BLACK_SHULKER_BOX, + )) + + generate(consumer, Items.GLASS, mapOf( + DyeColor.WHITE to Items.WHITE_STAINED_GLASS, + DyeColor.ORANGE to Items.ORANGE_STAINED_GLASS, + DyeColor.MAGENTA to Items.MAGENTA_STAINED_GLASS, + DyeColor.LIGHT_BLUE to Items.LIGHT_BLUE_STAINED_GLASS, + DyeColor.YELLOW to Items.YELLOW_STAINED_GLASS, + DyeColor.LIME to Items.LIME_STAINED_GLASS, + DyeColor.PINK to Items.PINK_STAINED_GLASS, + DyeColor.GRAY to Items.GRAY_STAINED_GLASS, + DyeColor.LIGHT_GRAY to Items.LIGHT_GRAY_STAINED_GLASS, + DyeColor.CYAN to Items.CYAN_STAINED_GLASS, + DyeColor.PURPLE to Items.PURPLE_STAINED_GLASS, + DyeColor.BLUE to Items.BLUE_STAINED_GLASS, + DyeColor.BROWN to Items.BROWN_STAINED_GLASS, + DyeColor.GREEN to Items.GREEN_STAINED_GLASS, + DyeColor.RED to Items.RED_STAINED_GLASS, + DyeColor.BLACK to Items.BLACK_STAINED_GLASS, + )) + + generate(consumer, Items.GLASS_PANE, mapOf( + DyeColor.WHITE to Items.WHITE_STAINED_GLASS_PANE, + DyeColor.ORANGE to Items.ORANGE_STAINED_GLASS_PANE, + DyeColor.MAGENTA to Items.MAGENTA_STAINED_GLASS_PANE, + DyeColor.LIGHT_BLUE to Items.LIGHT_BLUE_STAINED_GLASS_PANE, + DyeColor.YELLOW to Items.YELLOW_STAINED_GLASS_PANE, + DyeColor.LIME to Items.LIME_STAINED_GLASS_PANE, + DyeColor.PINK to Items.PINK_STAINED_GLASS_PANE, + DyeColor.GRAY to Items.GRAY_STAINED_GLASS_PANE, + DyeColor.LIGHT_GRAY to Items.LIGHT_GRAY_STAINED_GLASS_PANE, + DyeColor.CYAN to Items.CYAN_STAINED_GLASS_PANE, + DyeColor.PURPLE to Items.PURPLE_STAINED_GLASS_PANE, + DyeColor.BLUE to Items.BLUE_STAINED_GLASS_PANE, + DyeColor.BROWN to Items.BROWN_STAINED_GLASS_PANE, + DyeColor.GREEN to Items.GREEN_STAINED_GLASS_PANE, + DyeColor.RED to Items.RED_STAINED_GLASS_PANE, + DyeColor.BLACK to Items.BLACK_STAINED_GLASS_PANE, + )) + + generate(consumer, MRegistry.INDUSTRIAL_GLASS.item, MRegistry.INDUSTRIAL_GLASS.items) + generate(consumer, MRegistry.INDUSTRIAL_GLASS_PANE.item, MRegistry.INDUSTRIAL_GLASS_PANE.items) + generate(consumer, MRegistry.DECORATIVE_CRATE.item, MRegistry.DECORATIVE_CRATE.items) + generate(consumer, MRegistry.TRITANIUM_PRESSURE_PLATE.item, MRegistry.TRITANIUM_PRESSURE_PLATE.items) + generate(consumer, MItems.TRITANIUM_DOOR[null]!!, MItems.TRITANIUM_DOOR) + generate(consumer, MItems.TRITANIUM_TRAPDOOR[null]!!, MItems.TRITANIUM_TRAPDOOR) + + generate(consumer, MRegistry.VENT.item, MRegistry.VENT.items) + generate(consumer, MRegistry.VENT_ALTERNATIVE.item, MRegistry.VENT_ALTERNATIVE.items) + generate(consumer, MItems.CARGO_CRATE_MINECARTS[null]!!, MItems.CARGO_CRATE_MINECARTS) + + generate(consumer, MRegistry.UNREFINED_FLOOR_TILES.items) + generate(consumer, MRegistry.FLOOR_TILES.items) + generate(consumer, MRegistry.FLOOR_TILES_SLAB.items) + generate(consumer, MRegistry.FLOOR_TILES_STAIRS.items) + + striped(consumer, "full", MRegistry.TRITANIUM_STRIPED_BLOCK.itemsWithColor, MRegistry.TRITANIUM_BLOCK.items) + striped(consumer, "stairs", MRegistry.TRITANIUM_STRIPED_STAIRS.itemsWithColor, MRegistry.TRITANIUM_STAIRS.items) + striped(consumer, "walls", MRegistry.TRITANIUM_STRIPED_WALL.itemsWithColor, MRegistry.TRITANIUM_WALL.items) + striped(consumer, "slabs", MRegistry.TRITANIUM_STRIPED_SLAB.itemsWithColor, MRegistry.TRITANIUM_SLAB.items) +} diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index c266a923c..26236c319 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -145,6 +145,7 @@ fun addTags(tagsProvider: TagsProvider) { tagsProvider.requiresPickaxe(MBlocks.TRITANIUM_DOOR.values, Tiers.IRON) tagsProvider.requiresPickaxe(MBlocks.TRITANIUM_TRAPDOOR.values, Tiers.IRON) + tagsProvider.requiresPickaxe(MBlocks.PAINTER, Tiers.STONE) tagsProvider.requiresPickaxe(listOf( MBlocks.ANDROID_STATION, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PainterBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PainterBlockEntity.kt new file mode 100644 index 000000000..46e00a325 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PainterBlockEntity.kt @@ -0,0 +1,197 @@ +package ru.dbotthepony.mc.otm.block.entity.tech + +import com.google.common.collect.ImmutableList +import net.minecraft.core.BlockPos +import net.minecraft.nbt.CompoundTag +import net.minecraft.nbt.IntTag +import net.minecraft.world.entity.player.Inventory +import net.minecraft.world.entity.player.Player +import net.minecraft.world.inventory.AbstractContainerMenu +import net.minecraft.world.item.DyeColor +import net.minecraft.world.item.ItemStack +import net.minecraft.world.level.block.state.BlockState +import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity +import ru.dbotthepony.mc.otm.container.HandlerFilter +import ru.dbotthepony.mc.otm.container.MatteryContainer +import ru.dbotthepony.mc.otm.core.immutableList +import ru.dbotthepony.mc.otm.core.immutableMap +import ru.dbotthepony.mc.otm.core.nbt.mapPresent +import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.menu.tech.PainterMenu +import ru.dbotthepony.mc.otm.registry.MBlockEntities +import java.util.* + +class PainterBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.PAINTER, blockPos, blockState) { + override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { + return PainterMenu(containerID, inventory, this) + } + + val dyeInput = MatteryContainer(this::setChangedLight, 1) + private val dyeStored = EnumMap(DyeColor::class.java) + val dyeStoredView: Map = Collections.unmodifiableMap(dyeStored) + + init { + addDroppableContainer(dyeInput) + savetables.stateful(dyeInput, INVENTORY_KEY) + } + + fun takeDyes(dyes: Map) { + for ((dye, amount) in dyes) { + for (i in 0 until amount) { + mixer(dye).mix(dyeStored) + + if (dyeStored(dye) > 0) { + dyeStored[dye] = dyeStored(dye) - 1 + } + } + } + + setChangedLight() + } + + val config = ConfigurableItemHandler(input = dyeInput.handler(object : HandlerFilter { + override fun canInsert(slot: Int, stack: ItemStack): Boolean { + val dye = DyeColor.entries.firstOrNull { stack.`is`(it.tag) } ?: return false + return dyeStored(dye) + HUE_PER_ITEM <= MAX_STORAGE + } + + override fun modifyInsertCount(slot: Int, stack: ItemStack, existing: ItemStack, simulate: Boolean): Int { + if (!stack.equals(existing, false)) + return super.modifyInsertCount(slot, stack, existing, simulate) + + val dye = DyeColor.entries.firstOrNull { stack.`is`(it.tag) } ?: return 0 + return stack.count.coerceAtMost((MAX_STORAGE - dyeStored(dye)) / HUE_PER_ITEM - existing.count) + } + + override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { + return false + } + })) + + fun dyeStored(dye: DyeColor): Int { + return dyeStored[dye]!! + } + + init { + for (dye in DyeColor.entries) { + dyeStored[dye] = 0 + } + } + + override fun saveShared(nbt: CompoundTag) { + super.saveShared(nbt) + + nbt["dyes"] = CompoundTag().also { + for ((k, v) in dyeStored) { + it[k.getName()] = v + } + } + } + + override fun load(nbt: CompoundTag) { + super.load(nbt) + + for (dye in DyeColor.entries) { + dyeStored[dye] = 0 + } + + nbt.mapPresent("dyes") { it: CompoundTag -> + for (k in it.allKeys) { + dyeStored[DyeColor.entries.firstOrNull { it.getName() == k } ?: continue] = it.getInt(k) + } + } + } + + override fun tick() { + super.tick() + + val i = dyeInput.iterator() + + for (item in i) { + val dye = DyeColor.entries.firstOrNull { item.`is`(it.tag) } ?: continue + val stored = dyeStored(dye) + + if (stored + HUE_PER_ITEM <= MAX_STORAGE) { + item.shrink(1) + i.setChanged() + dyeStored[dye] = stored + HUE_PER_ITEM + } + } + } + + class Mixer(val color: DyeColor, vararg mixing: ImmutableList) : Map.Entry { + val mixing: ImmutableList> = ImmutableList.copyOf(mixing) + + override val key: DyeColor + get() = color + override val value: Mixer + get() = this + + private fun mix(input: MutableMap, seen: MutableSet, stack: MutableSet) { + if (input[color]!! > 0 || color in seen || color in stack) return + stack.add(color) + + for (ingredients in mixing) { + val copy = EnumMap(input) + ingredients.forEach { mixer(it).mix(copy, seen, stack) } + + if (ingredients.all { copy[it]!! > 0 }) { + ingredients.forEach { copy[it] = copy[it]!! - 1 } + copy[color] = ingredients.size + + input.putAll(copy) + stack.remove(color) + return + } + } + + stack.remove(color) + seen.add(color) + } + + fun mix(input: MutableMap) { + mix(input, EnumSet.noneOf(DyeColor::class.java), EnumSet.noneOf(DyeColor::class.java)) + } + + fun isAvailable(input: Map): Boolean { + if (input[color]!! > 0) return true + return EnumMap(input).also(::mix)[color]!! > 0 + } + } + + companion object { + fun mixer(color: DyeColor): Mixer { + return MIXING[color]!! + } + + val MIXING = immutableMap { + put(Mixer(DyeColor.WHITE, immutableList(DyeColor.RED, DyeColor.GREEN, DyeColor.BLUE))) + put(Mixer(DyeColor.LIGHT_GRAY, immutableList(DyeColor.BLACK, DyeColor.WHITE, DyeColor.WHITE))) + put(Mixer(DyeColor.GRAY, immutableList(DyeColor.BLACK, DyeColor.WHITE))) + put(Mixer(DyeColor.ORANGE, immutableList(DyeColor.YELLOW, DyeColor.RED))) + put(Mixer(DyeColor.LIME, immutableList(DyeColor.GREEN, DyeColor.WHITE))) + put(Mixer(DyeColor.LIGHT_BLUE, immutableList(DyeColor.BLUE, DyeColor.WHITE))) + put(Mixer(DyeColor.CYAN, immutableList(DyeColor.BLUE, DyeColor.GREEN))) + put(Mixer(DyeColor.PURPLE, immutableList(DyeColor.BLUE, DyeColor.RED))) + + put(Mixer( + DyeColor.MAGENTA, + immutableList(DyeColor.PURPLE, DyeColor.PINK), + immutableList(DyeColor.RED, DyeColor.RED, DyeColor.BLUE, DyeColor.WHITE), + immutableList(DyeColor.PINK, DyeColor.RED, DyeColor.BLUE) + )) + + put(Mixer(DyeColor.PINK, immutableList(DyeColor.RED, DyeColor.WHITE))) + + put(Mixer(DyeColor.RED, immutableList(DyeColor.MAGENTA, DyeColor.YELLOW))) + put(Mixer(DyeColor.GREEN, immutableList(DyeColor.CYAN, DyeColor.YELLOW))) + put(Mixer(DyeColor.BLUE, immutableList(DyeColor.CYAN, DyeColor.MAGENTA))) + put(Mixer(DyeColor.BLACK, immutableList(DyeColor.CYAN, DyeColor.MAGENTA, DyeColor.YELLOW))) + put(Mixer(DyeColor.YELLOW, immutableList(DyeColor.RED, DyeColor.GREEN))) + put(Mixer(DyeColor.BROWN, immutableList(DyeColor.MAGENTA, DyeColor.YELLOW, DyeColor.BLACK))) + } + + const val MAX_STORAGE = 256 + const val HUE_PER_ITEM = 32 + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PainterBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PainterBlock.kt new file mode 100644 index 000000000..391f7504e --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PainterBlock.kt @@ -0,0 +1,22 @@ +package ru.dbotthepony.mc.otm.block.tech + +import net.minecraft.core.BlockPos +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.EntityBlock +import net.minecraft.world.level.block.entity.BlockEntity +import net.minecraft.world.level.block.entity.BlockEntityTicker +import net.minecraft.world.level.block.entity.BlockEntityType +import net.minecraft.world.level.block.state.BlockState +import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.entity.tech.PainterBlockEntity + +class PainterBlock : RotatableMatteryBlock(), EntityBlock { + override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { + return PainterBlockEntity(p_153215_, p_153216_) + } + + override fun getTicker(p_153212_: Level, p_153213_: BlockState, p_153214_: BlockEntityType): BlockEntityTicker? { + if (p_153212_.isClientSide) return null + return BlockEntityTicker { p_155253_, p_155254_, p_155255_, p_155256_ -> if (p_155256_ is PainterBlockEntity) p_155256_.tick() } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt index 0f3da165c..eb41d2bac 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt @@ -3,6 +3,8 @@ package ru.dbotthepony.mc.otm.client.render import net.minecraft.client.gui.GuiGraphics import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.core.math.RGBAColor +import ru.dbotthepony.mc.otm.systemTime +import kotlin.math.sin interface IGUIRenderable { /** @@ -76,14 +78,14 @@ interface IGUIRenderable { } /** - * Locks argument values to default ones and aligns render position to center of render rectangle + * Locks argument values to default ones and aligns render position to center of render rectangle (or specified [gravity]) * * e.g. for example, if we want [ItemStackIcon] to always render as 16x16 pixels icon, even if required render * dimensions are bigger (e.g. 18x18), after calling [fix] on [ItemStackIcon] it will always render as 16x16 icon, * positioned on center of render canvas (e.g. rendering on +0+0 with 18x18 size will put icon at +1+1 and render as 16x16; * rendering on +0+0 with 32x32 canvas will put icon at +8+8 and render as 16x16) */ - fun fixed(fixedWidth: Boolean = true, fixedHeight: Boolean = true, fixedWinding: Boolean = true): IGUIRenderable { + fun fixed(fixedWidth: Boolean = true, fixedHeight: Boolean = true, fixedWinding: Boolean = true, gravity: RenderGravity = RenderGravity.CENTER_CENTER): IGUIRenderable { if (!fixedHeight && !fixedWidth && !fixedWinding) return this return object : IGUIRenderable { @@ -97,11 +99,11 @@ interface IGUIRenderable { var realY = y if (fixedWidth && width > this.width) { - realX += (width - this.width) / 2f + realX += gravity.repositionX(width, this.width) } if (fixedHeight && height > this.height) { - realY += (height - this.height) / 2f + realY += gravity.repositionY(height, this.height) } this@IGUIRenderable.render(guiGraphics, realX, realY, if (fixedWidth) this.width else width, if (fixedHeight) this.height else height, if (fixedWinding) this.winding else winding, color) @@ -122,22 +124,22 @@ interface IGUIRenderable { data class ItemStackIcon(private val itemStack: ItemStack, override val width: Float = 16f, override val height: Float = 16f) : IGUIRenderable { override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder, color: RGBAColor) { - if (x % 1f == 0f && y % 1f == 0f && width == 16f && height == 16f) { - guiGraphics.renderFakeItem(itemStack, x.toInt(), y.toInt()) - clearDepth(guiGraphics.pose(), x, y, width, height) - } else { - val pose = guiGraphics.pose() + val pose = guiGraphics.pose() - pose.pushPose() - pose.translate(x % 1f, y % 1f, 0f) + pose.pushPose() + pose.translate(x, y, 0f) - if (width != 16f || height != 16f) - pose.scale(width / 16f, height / 16f, 1f) + pose.scale(width / 16f, height / 16f, 1f) - guiGraphics.renderFakeItem(itemStack, x.toInt(), y.toInt()) - pose.popPose() + guiGraphics.renderFakeItem(itemStack, 0, 0) + pose.popPose() - clearDepth(pose, x, y, width, height) - } + clearDepth(pose, x, y, width, height) + } +} + +data class FlatRectangleIcon(override val width: Float = 1f, override val height: Float = 1f, val color: RGBAColor) : IGUIRenderable { + override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder, color: RGBAColor) { + guiGraphics.renderRect(x, y, width, height, color = this.color) } } 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 d7d9673ae..e8207d83c 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 @@ -1608,7 +1608,7 @@ open class EditablePanel @JvmOverloads constructor( } protected open fun mouseScrolledInner(x: Double, y: Double, scroll: Double): Boolean { - return true + return false } fun mouseScrolled(x: Double, y: Double, scroll: Double): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/ScrollableCanvasPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/ScrollableCanvasPanel.kt new file mode 100644 index 000000000..4a9f266a0 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/ScrollableCanvasPanel.kt @@ -0,0 +1,72 @@ +package ru.dbotthepony.mc.otm.client.screen.panels.util + +import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.screen.panels.Dock +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel + +class ScrollableCanvasPanel( + screen: S, + parent: EditablePanel<*>, + x: Float = 0f, + y: Float = 0f, + width: Float = 40f, + height: Float = 40f, + slimScrollbar: Boolean = false +) : EditablePanel(screen, parent, x, y, width, height) { + val canvas = object : EditablePanel(screen, this@ScrollableCanvasPanel) { + init { + dock = Dock.FILL + dockRight = 1f + scissor = true + } + + override fun mouseScrolledInner(x: Double, y: Double, scroll: Double): Boolean { + return scrollbar.mouseScrolledInner(x, y, scroll) + } + + override fun performLayout() { + super.performLayout() + + var y = 0f + var maxHeight = 0f + var x = 0f + + for (child in visibleChildren.filter { it.dock == Dock.NONE }) { + if (x > 0f && x + child.width > this.width) { + y += maxHeight + x = 0f + maxHeight = 0f + } + + child.x = child.dockLeft + x + child.y = child.dockTop + y + x += child.width + child.dockMargin.horizontal + maxHeight = maxHeight.coerceAtLeast(child.height + child.dockMargin.vertical) + } + + updateBounds() + + if (getMaxScroll(scrollbar) <= scrollbar.scroll) { + scrollbar.scroll = getMaxScroll(scrollbar) + } + } + } + + val scrollbar = AnalogScrollBarPanel(screen, this, maxScroll = ::getMaxScroll, smoothScrollCallback = ::onScrollUpdate, isSlim = slimScrollbar) + + init { + scrollbar.dock = Dock.RIGHT + } + + override fun mouseScrolledInner(x: Double, y: Double, scroll: Double): Boolean { + return scrollbar.mouseScrolledInner(x, y, scroll) + } + + private fun getMaxScroll(it: AnalogScrollBarPanel<*>): Float { + return (canvas.childrenRectHeight - canvas.height).coerceAtLeast(0f) + } + + private fun onScrollUpdate(it: AnalogScrollBarPanel<*>, old: Float, new: Float) { + this.canvas.yOffset = -new + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PainterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PainterScreen.kt new file mode 100644 index 000000000..9882c3e27 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PainterScreen.kt @@ -0,0 +1,152 @@ +package ru.dbotthepony.mc.otm.client.screen.tech + +import net.minecraft.client.gui.GuiGraphics +import net.minecraft.network.chat.Component +import net.minecraft.util.RandomSource +import net.minecraft.world.entity.player.Inventory +import net.minecraft.world.item.DyeColor +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.Items +import net.minecraftforge.common.Tags +import net.minecraftforge.registries.ForgeRegistries +import ru.dbotthepony.mc.otm.block.entity.tech.PainterBlockEntity +import ru.dbotthepony.mc.otm.client.render.FlatRectangleIcon +import ru.dbotthepony.mc.otm.client.render.ItemStackIcon +import ru.dbotthepony.mc.otm.client.render.renderRect +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.Dock +import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.DeviceControls +import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeRectangleButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.RectangleButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.ScrollableCanvasPanel +import ru.dbotthepony.mc.otm.core.TextComponent +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.math.RGBAColor +import ru.dbotthepony.mc.otm.menu.tech.PainterMenu +import ru.dbotthepony.mc.otm.registry.MItems + +class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { + inner class Bar(parent: EditablePanel<*>, val dye: DyeColor) : EditablePanel(this@PainterScreen, parent, width = 5f) { + init { + dock = Dock.RIGHT + dockLeft = 1f + tooltips.add(TranslatableComponent("item.minecraft.${dye.getName()}_dye")) + tooltips.add(TextComponent("")) + tooltips.add(TextComponent("")) + } + + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + graphics.renderRect(0f, 0f, width, height, color = RGBAColor.DARK_GRAY) + + val color = RGBAColor.rgb(dye.textColor) + graphics.renderRect(0f, 0f, width, height, color = color.copy(alpha = 0.4f)) + + val multiplier = menu.dyeStoredDirect[dye]!!.toFloat() / PainterBlockEntity.MAX_STORAGE.toFloat() + graphics.renderRect(0f, height * (1f - multiplier), width, height * multiplier, color = color) + + tooltips[tooltips.size - 1] = TextComponent("${menu.dyeStoredDirect[dye]} (${(multiplier * 100f).toInt()}%)") + } + } + + override fun makeMainFrame(): FramePanel> { + val frame = FramePanel(this, 200f, 120f, title) + + val strip = EditablePanel(this, frame, width = AbstractSlotPanel.SIZE) + strip.dock = Dock.LEFT + strip.dockRight = 4f + + SlotPanel(this, strip, menu.inputSlot).also { + it.dock = Dock.TOP + it.dockTop = 4f + } + + EditablePanel(this, frame, width = 6f * DyeColor.entries.size / 2f).also { + it.dock = Dock.RIGHT + it.dockLeft = 4f + + EditablePanel(this, it, height = 46f).also { + it.dock = Dock.TOP + + for (i in 0 until DyeColor.entries.size / 2) { + Bar(it, DyeColor.entries[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]) + } + } + } + + SlotPanel(this, strip, menu.outputSlot).also { + it.dock = Dock.BOTTOM + it.dockBottom = 4f + } + + SlotPanel(this, strip, menu.dyeSlot).also { + it.dock = Dock.FILL + it.dockResize = DockResizeMode.NONE + it.slotBackgroundEmpty = + ItemStackIcon(ItemStack(ForgeRegistries.ITEMS.tags()!!.getTag(Tags.Items.DYES).getRandomElement(RandomSource.create()).orElse(Items.AIR)), 16f, 16f) + .fixed() + .composeBefore(FlatRectangleIcon(16f, 16f, RGBAColor.rgb(0x8b8b8b).copy(alpha = 0.6f))) + .fixed() + } + + val canvas = ScrollableCanvasPanel(this, frame) + canvas.dock = Dock.FILL + + val buttons = ArrayList>() + + menu.listeners.addListener { + buttons.forEach { it.remove() } + buttons.clear() + + for (recipe in menu.possibleRecipes) { + object : LargeRectangleButtonPanel(this@PainterScreen, canvas.canvas, skinElement = ItemStackIcon(recipe.output, 14f, 14f).fixed()) { + init { + buttons.add(this) + dockRight = 1f + dockBottom = 1f + } + + override var isDisabled: Boolean + get() = !recipe.canCraft(menu.dyeStoredDirect) + set(value) {} + + override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + val list = getTooltipFromItem(minecraft!!, recipe.output) + + recipe.dyes.forEach { + val (dye, amount) = it + + if (amount == 1) + list.add(TranslatableComponent("otm.gui.needs", TranslatableComponent("item.minecraft.${dye.getName()}_dye"))) + else if (amount > 1) + list.add(TranslatableComponent("otm.gui.needs_x", TranslatableComponent("item.minecraft.${dye.getName()}_dye"), amount)) + } + + graphics.renderComponentTooltip(font, list, mouseX.toInt(), mouseY.toInt()) + return true + } + + override fun onClick(mouseButton: Int) { + menu.selectRecipe.accept(recipe.id) + } + } + } + } + + DeviceControls(this, frame, itemConfig = menu.itemConfig) + + return frame + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/IGUIRenderable2IDrawable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/IGUIRenderable2IDrawable.kt new file mode 100644 index 000000000..7b168ca96 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/IGUIRenderable2IDrawable.kt @@ -0,0 +1,19 @@ +package ru.dbotthepony.mc.otm.compat.jei + +import mezz.jei.api.gui.drawable.IDrawable +import net.minecraft.client.gui.GuiGraphics +import ru.dbotthepony.mc.otm.client.render.IGUIRenderable + +class IGUIRenderable2IDrawable(val parent: IGUIRenderable) : IDrawable { + override fun getWidth(): Int { + return parent.width.toInt() + } + + override fun getHeight(): Int { + return parent.height.toInt() + } + + override fun draw(guiGraphics: GuiGraphics, xOffset: Int, yOffset: Int) { + parent.render(guiGraphics, xOffset.toFloat(), yOffset.toFloat()) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt index 3c73c955c..bec5cb7fb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt @@ -70,17 +70,20 @@ class JEIPlugin : IModPlugin { registration.addRecipeCatalyst(ItemStack(MItems.POWERED_SMOKER), RecipeTypes.SMOKING) registration.addRecipeCatalyst(ItemStack(MItems.ExopackUpgrades.CRAFTING_UPGRADE), RecipeTypes.CRAFTING) registration.addRecipeCatalyst(ItemStack(MItems.PLATE_PRESS), PlatePressRecipeCategory.recipeType) + registration.addRecipeCatalyst(ItemStack(MItems.PAINTER), PainterRecipeCategory.recipeType) } override fun registerCategories(registration: IRecipeCategoryRegistration) { helpers = registration.jeiHelpers registration.addRecipeCategories(PlatePressRecipeCategory) + registration.addRecipeCategories(PainterRecipeCategory) } override fun registerRecipes(registration: IRecipeRegistration) { val level = minecraft.level ?: throw NullPointerException("No ClientLevel. OLOLOLOLOLOLO") registration.addRecipes(PlatePressRecipeCategory.recipeType, level.recipeManager.getAllRecipesFor(MRecipes.PLATE_PRESS).filter { !it.isIncomplete }) + registration.addRecipes(PainterRecipeCategory.recipeType, level.recipeManager.getAllRecipesFor(MRecipes.PAINTER).filter { !it.isIncomplete }) } override fun registerRecipeTransferHandlers(registration: IRecipeTransferRegistration) { 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 new file mode 100644 index 000000000..f5d937bf8 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PainterRecipeCategory.kt @@ -0,0 +1,82 @@ +package ru.dbotthepony.mc.otm.compat.jei + +import mezz.jei.api.constants.VanillaTypes +import mezz.jei.api.gui.builder.IRecipeLayoutBuilder +import mezz.jei.api.gui.drawable.IDrawable +import mezz.jei.api.recipe.IFocusGroup +import mezz.jei.api.recipe.RecipeIngredientRole +import mezz.jei.api.recipe.RecipeType +import mezz.jei.api.recipe.category.IRecipeCategory +import net.minecraft.client.gui.GuiGraphics +import net.minecraft.network.chat.Component +import net.minecraft.resources.ResourceLocation +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.crafting.Ingredient +import ru.dbotthepony.mc.otm.OverdriveThatMatters +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.recipe.PainterRecipe +import ru.dbotthepony.mc.otm.registry.MItems +import ru.dbotthepony.mc.otm.registry.MNames + +object PainterRecipeCategory : IRecipeCategory, IDrawable { + private val type = RecipeType(ResourceLocation(OverdriveThatMatters.MOD_ID, MNames.PAINTER), PainterRecipe::class.java) + + override fun getRecipeType(): RecipeType { + return type + } + + override fun getTitle(): Component { + return MItems.PAINTER.description + } + + override fun getBackground(): IDrawable { + return this + } + + override fun getWidth(): Int { + return 120 + } + + override fun getHeight(): Int { + return 56 + } + + override fun getIcon(): IDrawable { + return IGUIRenderable2IDrawable(ItemStackIcon(ItemStack(MItems.PAINTER))) + } + + override fun setRecipe(builder: IRecipeLayoutBuilder, recipe: PainterRecipe, focuses: IFocusGroup) { + var x = 0 + var y = 0 + + for ((dye, count) in recipe.dyes) { + builder.addSlot(RecipeIngredientRole.INPUT, 1 + x * 18, 1 + y * 18) + .addIngredients(VanillaTypes.ITEM_STACK, Ingredient.of(dye.tag).items.map { it.copyWithCount(count) }) + + y++ + + if (y >= 3) { + x++ + y = 0 + } + } + + builder.addSlot(RecipeIngredientRole.INPUT, 50, 22).addIngredients(recipe.input) + builder.addSlot(RecipeIngredientRole.OUTPUT, 100, 22).addIngredients(VanillaTypes.ITEM_STACK, listOf(recipe.output)) + } + + override fun draw(guiGraphics: GuiGraphics, xOffset: Int, yOffset: Int) { + for (x in 0 .. 1) { + for (y in 0 .. 2) { + AbstractSlotPanel.SLOT_BACKGROUND.render(guiGraphics, xOffset.toFloat() + x * 18f, yOffset.toFloat() + y * 18f) + } + } + + AbstractSlotPanel.SLOT_BACKGROUND.render(guiGraphics, xOffset.toFloat() + 49f, yOffset.toFloat() + 21f) + AbstractSlotPanel.SLOT_BACKGROUND.render(guiGraphics, xOffset.toFloat() + 99f, yOffset.toFloat() + 21f) + + ProgressGaugePanel.GAUGE_BACKGROUND.render(guiGraphics, xOffset.toFloat() + 73f, yOffset.toFloat() + 22f) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/SkinDrawable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/SkinDrawable.kt deleted file mode 100644 index 6ac46e51f..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/SkinDrawable.kt +++ /dev/null @@ -1,19 +0,0 @@ -package ru.dbotthepony.mc.otm.compat.jei - -import mezz.jei.api.gui.drawable.IDrawable -import net.minecraft.client.gui.GuiGraphics -import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite - -class SkinDrawable(val element: MatterySprite) : IDrawable { - override fun getWidth(): Int { - return element.width.toInt() - } - - override fun getHeight(): Int { - return element.height.toInt() - } - - override fun draw(graphics: GuiGraphics, xOffset: Int, yOffset: Int) { - element.render(graphics, xOffset.toFloat(), yOffset.toFloat()) - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/StretchingDrawable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/StretchingDrawable.kt deleted file mode 100644 index 72c2c96eb..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/StretchingDrawable.kt +++ /dev/null @@ -1,19 +0,0 @@ -package ru.dbotthepony.mc.otm.compat.jei - -import mezz.jei.api.gui.drawable.IDrawable -import net.minecraft.client.gui.GuiGraphics -import ru.dbotthepony.mc.otm.client.render.sprites.StretchingRectangleElement - -class StretchingDrawable(val element: StretchingRectangleElement, val rectWidth: Int, val rectHeight: Int) : IDrawable { - override fun getWidth(): Int { - return rectWidth - } - - override fun getHeight(): Int { - return rectHeight - } - - override fun draw(graphics: GuiGraphics, xOffset: Int, yOffset: Int) { - element.render(graphics, xOffset.toFloat(), yOffset.toFloat(), rectWidth.toFloat(), rectHeight.toFloat()) - } -} 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 6a3a4f457..c4fd2a636 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHandler.kt @@ -16,20 +16,27 @@ class ContainerHandler @JvmOverloads internal constructor( return stack filter.preInsert(slot, stack, simulate) + val localStack = container[slot] + var amount = filter.modifyInsertCount(slot, stack, localStack, simulate) + + if (amount <= 0) + return stack if (localStack.isEmpty) { + amount = stack.count.coerceAtMost(container.getMaxStackSize(slot, stack)).coerceAtMost(amount) + if (!simulate) { - container.setItem(slot, stack.copyWithCount(stack.count.coerceAtMost(container.getMaxStackSize(slot, stack)))) + container.setItem(slot, stack.copyWithCount(amount)) } - if (stack.count <= container.getMaxStackSize(slot, stack)) { + if (stack.count <= amount) { return ItemStack.EMPTY } else { - return stack.copyWithCount(container.getMaxStackSize(slot, stack)) + return stack.copyWithCount(stack.count - amount) } } else if (localStack.isStackable && container.getMaxStackSize(slot, localStack) > localStack.count && ItemStack.isSameItemSameTags(localStack, stack)) { - val newCount = container.getMaxStackSize(slot, localStack).coerceAtMost(localStack.count + stack.count) + val newCount = container.getMaxStackSize(slot, localStack).coerceAtMost(localStack.count + stack.count.coerceAtMost(amount)) val diff = newCount - localStack.count if (diff != 0) { @@ -51,12 +58,16 @@ class ContainerHandler @JvmOverloads internal constructor( if (amount <= 0 || container.isSlotForbiddenForAutomation(slot)) return ItemStack.EMPTY - filter.preExtract(slot, amount, simulate) - val localStack = container.getItem(slot) if (localStack.isEmpty) return ItemStack.EMPTY + + @Suppress("name_shadowing") + val amount = filter.modifyExtractCount(slot, amount, simulate) + if (amount <= 0) return ItemStack.EMPTY if (!filter.canExtract(slot, amount, localStack)) return ItemStack.EMPTY + filter.preExtract(slot, amount, simulate) + val minimal = amount.coerceAtMost(localStack.count) val copy = localStack.copy() copy.count = minimal diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt index ce8051302..c540621f0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt @@ -19,6 +19,14 @@ interface HandlerFilter { fun preInsert(slot: Int, stack: ItemStack, simulate: Boolean) {} fun preExtract(slot: Int, amount: Int, simulate: Boolean) {} + fun modifyInsertCount(slot: Int, stack: ItemStack, existing: ItemStack, simulate: Boolean): Int { + return stack.count + } + + fun modifyExtractCount(slot: Int, amount: Int, simulate: Boolean): Int { + return amount + } + fun and(other: HandlerFilter): HandlerFilter { return object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { 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 239d59990..af897288a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -175,6 +175,13 @@ inline fun immutableList(initializer: Consumer.() -> Unit): Immutab return builder.build() } +fun immutableList(a: V, vararg values: V): ImmutableList { + val builder = ImmutableList.Builder() + builder.add(a) + builder.addAll(values.iterator()) + return builder.build() +} + fun IForgeRegistry.getID(value: T): Int { return (this as ForgeRegistry).getID(value) } 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 246401c95..ac4fbba42 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 @@ -5,6 +5,7 @@ import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.NbtAccounter import net.minecraft.nbt.NbtIo import net.minecraft.network.chat.Component +import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.level.material.Fluid @@ -327,3 +328,12 @@ fun OutputStream.writeBinaryString(input: String) { writeVarIntLE(bytes.size) write(bytes) } + +fun InputStream.readResourceLocation(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 KiB */)): ResourceLocation { + return ResourceLocation(readBinaryString(sizeLimit), readBinaryString(sizeLimit)) +} + +fun OutputStream.writeResourceLocation(value: ResourceLocation) { + writeBinaryString(value.namespace) + writeBinaryString(value.path) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt index 5b15f435d..55148826b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt @@ -122,6 +122,7 @@ val UUIDValueCodec = StreamCodec({ s, a -> a.accountBytes(8L); UUID(s.readLong() val VarIntValueCodec = StreamCodec(DataInputStream::readVarIntLE, DataOutputStream::writeVarIntLE) { a, b -> a == b } val VarLongValueCodec = StreamCodec(DataInputStream::readVarLongLE, DataOutputStream::writeVarLongLE) { a, b -> a == b } val BinaryStringCodec = StreamCodec(DataInputStream::readBinaryString, DataOutputStream::writeBinaryString) +val ResourceLocationValueCodec = StreamCodec(DataInputStream::readResourceLocation, DataOutputStream::writeResourceLocation) val RGBCodec: StreamCodec = StreamCodec( { s, a -> a.accountBytes(12L); RGBAColor(s.readFloat(), s.readFloat(), s.readFloat()) }, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PainterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PainterMenu.kt new file mode 100644 index 000000000..55466ffd1 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PainterMenu.kt @@ -0,0 +1,119 @@ +package ru.dbotthepony.mc.otm.menu.tech + +import net.minecraft.world.SimpleContainer +import net.minecraft.world.entity.player.Inventory +import net.minecraft.world.entity.player.Player +import net.minecraft.world.item.DyeColor +import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.block.entity.tech.PainterBlockEntity +import ru.dbotthepony.mc.otm.container.MatteryContainer +import ru.dbotthepony.mc.otm.core.ISubscriptable +import ru.dbotthepony.mc.otm.core.addAll +import ru.dbotthepony.mc.otm.core.collect.SupplierMap +import ru.dbotthepony.mc.otm.core.collect.filter +import ru.dbotthepony.mc.otm.core.isNotEmpty +import ru.dbotthepony.mc.otm.core.map +import ru.dbotthepony.mc.otm.core.util.CreativeMenuItemComparator +import ru.dbotthepony.mc.otm.core.util.ResourceLocationValueCodec +import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput +import ru.dbotthepony.mc.otm.recipe.PainterRecipe +import ru.dbotthepony.mc.otm.registry.MMenus +import ru.dbotthepony.mc.otm.registry.MRecipes +import java.util.* +import java.util.function.IntConsumer +import kotlin.collections.ArrayList + +class PainterMenu( + containerId: Int, inventory: Inventory, tile: PainterBlockEntity? = null +) : MatteryMenu(MMenus.PAINTER, containerId, inventory, tile) { + val dyeStored = DyeColor.entries.associateWith { dye -> + mSynchronizer.ComputedIntField({ tile?.dyeStored(dye) ?: 0 }).also { it.addListener(IntConsumer { rescan() }) } + } + + val dyeStoredDirect = SupplierMap(dyeStored) + val itemConfig = ItemConfigPlayerInput(this, tile?.config) + + val inputContainer = MatteryContainer(::rescan, 1) + val outputContainer = MatteryContainer(1) + private var lastRecipe: PainterRecipe? = null + var selectedRecipe by mSynchronizer.Field(null, ResourceLocationValueCodec.nullable).also { it.addListener { rescan() } } + + val selectRecipe = PlayerInput(ResourceLocationValueCodec) { + selectedRecipe = it + } + + val inputSlot = object : MatterySlot(inputContainer, 0) { + override fun mayPlace(itemStack: ItemStack): Boolean { + return super.mayPlace(itemStack) && inventory.player.level().recipeManager.byType(MRecipes.PAINTER).values.any { it.input.test(itemStack) } + } + } + + val outputSlot = object : MatterySlot(outputContainer, 0) { + override fun tryRemove(p_150642_: Int, p_150643_: Int, p_150644_: Player): Optional { + rescan() + return super.tryRemove(p_150642_, p_150643_, p_150644_) + } + + override fun onTake(p_150645_: Player, p_150646_: ItemStack) { + if (p_150646_.isNotEmpty) { + lastRecipe?.dyes?.let { tile?.takeDyes(it) } + inputContainer.removeItem(0, 1) + } + + super.onTake(p_150645_, p_150646_) + } + + override fun mayPlace(itemStack: ItemStack): Boolean { + return false + } + } + + val dyeSlot = object : MatterySlot(tile?.dyeInput ?: SimpleContainer(1), 0) { + override fun mayPlace(itemStack: ItemStack): Boolean { + return super.mayPlace(itemStack) && (DyeColor.getColor(itemStack)?.let { dyeStoredDirect[it]!! + PainterBlockEntity.HUE_PER_ITEM <= PainterBlockEntity.MAX_STORAGE } ?: false) + } + } + + init { + addSlot(outputSlot) + addSlot(dyeSlot) + + addStorageSlot(dyeSlot) + addStorageSlot(inputSlot) + mapQuickMoveToInventory(outputSlot) + mapQuickMoveToInventory(dyeSlot) + + addInventorySlots() + } + + override fun removed(p_38940_: Player) { + super.removed(p_38940_) + clearContainer(p_38940_, inputContainer) + } + + val listeners = ISubscriptable.Impl() + val possibleRecipes = ArrayList() + + private fun rescan() { + possibleRecipes.clear() + possibleRecipes.addAll(inventory.player.level().recipeManager.byType(MRecipes.PAINTER).values.iterator().filter { it.input.test(inputContainer[0]) }) + possibleRecipes.sortWith(CreativeMenuItemComparator.map { it.output.item }) + listeners.accept(Unit) + if (tile !is PainterBlockEntity) return + + if (inputContainer.isEmpty || selectedRecipe == null) { + outputContainer.clearContent() + } else { + val recipe = inventory.player.level().recipeManager.byType(MRecipes.PAINTER)[selectedRecipe] + + if (recipe == null || !recipe.canCraft(dyeStoredDirect) || !recipe.matches(inputContainer, inventory.player.level())) { + outputContainer.clearContent() + } else { + outputContainer[0] = recipe.assemble(inputContainer, inventory.player.level().registryAccess()) + lastRecipe = recipe + } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt new file mode 100644 index 000000000..158cab1df --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt @@ -0,0 +1,135 @@ +package ru.dbotthepony.mc.otm.recipe + +import com.google.common.collect.ImmutableSet +import com.mojang.datafixers.util.Either +import com.mojang.serialization.Codec +import com.mojang.serialization.codecs.RecordCodecBuilder +import net.minecraft.core.NonNullList +import net.minecraft.core.RegistryAccess +import net.minecraft.data.recipes.FinishedRecipe +import net.minecraft.resources.ResourceLocation +import net.minecraft.world.Container +import net.minecraft.world.item.DyeColor +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.crafting.Ingredient +import net.minecraft.world.item.crafting.Recipe +import net.minecraft.world.item.crafting.RecipeSerializer +import net.minecraft.world.item.crafting.RecipeType +import net.minecraft.world.level.Level +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.block.entity.tech.PainterBlockEntity +import ru.dbotthepony.mc.otm.container.get +import ru.dbotthepony.mc.otm.core.isActuallyEmpty +import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.core.tagNotNull +import ru.dbotthepony.mc.otm.data.Codec2RecipeSerializer +import ru.dbotthepony.mc.otm.data.CodecList +import ru.dbotthepony.mc.otm.data.IngredientCodec +import ru.dbotthepony.mc.otm.data.PredicatedCodecList +import ru.dbotthepony.mc.otm.data.minRange +import ru.dbotthepony.mc.otm.registry.MRecipes +import java.util.EnumMap +import java.util.function.Predicate + +class PainterRecipe( + private val id: ResourceLocation, + val input: Ingredient, + val output: ItemStack, + val dyes: Map +) : Recipe { + constructor( + id: ResourceLocation, + input: Ingredient, + output: ItemStack, + dyes: Set + ) : this(id, input, output, dyes.associateWith { 1 }) + + fun canCraft(storedDyes: Map): Boolean { + if (isIncomplete) return false + if (dyes.isEmpty() || dyes.values.none { it > 0 }) return true + val copy = EnumMap(storedDyes) + + for ((dye, amount) in dyes) { + for (i in 0 until amount) { + PainterBlockEntity.mixer(dye).mix(copy) + if (copy[dye]!! <= 0) return false + copy[dye] = copy[dye]!! - 1 + } + } + + return true + } + + override fun matches(p_44002_: Container, p_44003_: Level): Boolean { + if (isIncomplete) return false + return input.test(p_44002_[0]) + } + + override fun isIncomplete(): Boolean { + return input.isActuallyEmpty || output.isEmpty + } + + override fun getIngredients(): NonNullList { + return NonNullList.of(Ingredient.EMPTY, input) + } + + override fun assemble(p_44001_: Container, p_267165_: RegistryAccess): ItemStack { + return output.copy().also { o -> + p_44001_[0].tag?.let { + if (o.tag == null) { + o.tag = it.copy() + } else { + for (k in it.allKeys) + if (k !in o.tagNotNull) + o.tagNotNull[k] = it[k]!!.copy() + } + } + } + } + + override fun canCraftInDimensions(p_43999_: Int, p_44000_: Int): Boolean { + return true + } + + override fun isSpecial(): Boolean { + return true + } + + override fun getResultItem(p_267052_: RegistryAccess): ItemStack { + return output + } + + override fun getId(): ResourceLocation { + return id + } + + override fun getSerializer(): RecipeSerializer<*> { + return SERIALIZER + } + + override fun getType(): RecipeType<*> { + return MRecipes.PAINTER + } + + fun toFinished(): FinishedRecipe { + return SERIALIZER.toFinished(this) + } + + companion object { + val SERIALIZER = Codec2RecipeSerializer( + PainterRecipe(ResourceLocation(OverdriveThatMatters.MOD_ID, "empty"), Ingredient.EMPTY, ItemStack.EMPTY, setOf()) + ) { context -> + RecordCodecBuilder.create { + it.group( + IngredientCodec.fieldOf("input").forGetter(PainterRecipe::input), + ItemStack.CODEC.fieldOf("output").forGetter(PainterRecipe::output), + PredicatedCodecList>( + DyeColor.CODEC.xmap({ mapOf(it to 1) }, { it.keys.first() }) to Predicate { it.keys.size == 1 && it.values.first() == 1 }, + Codec.list(DyeColor.CODEC).xmap({ it.associateWith { 1 } }, { ArrayList(it.keys) }) to Predicate { it.values.all { it == 1 } }, + Codec.unboundedMap(DyeColor.CODEC, Codec.INT.minRange(1)) to Predicate { true } + ).fieldOf("dyes").forGetter(PainterRecipe::dyes), + ).apply(it) { a, b, c -> PainterRecipe(context.invoke(), a, b, c) } + } + } + } +} 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 46cfaf0c5..4dfd27172 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt @@ -1,11 +1,14 @@ package ru.dbotthepony.mc.otm.registry import net.minecraft.client.renderer.blockentity.BlockEntityRenderers +import net.minecraft.world.level.block.Block +import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.ForgeRegistries +import net.minecraftforge.registries.RegistryObject import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.block.entity.* import ru.dbotthepony.mc.otm.block.entity.tech.* @@ -25,43 +28,49 @@ import ru.dbotthepony.mc.otm.block.entity.tech.EnergyServoBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.GravitationStabilizerBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity import ru.dbotthepony.mc.otm.client.render.blockentity.* +import java.util.function.Supplier @Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") // Type<*> is unused in BlockEntityType.Builder object MBlockEntities { private val registry = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, OverdriveThatMatters.MOD_ID) - val ANDROID_STATION: BlockEntityType by registry.register(MNames.ANDROID_STATION) { BlockEntityType.Builder.of(::AndroidStationBlockEntity, MBlocks.ANDROID_STATION).build(null) } - val BATTERY_BANK: BlockEntityType by registry.register(MNames.BATTERY_BANK) { BlockEntityType.Builder.of(::BatteryBankBlockEntity, MBlocks.BATTERY_BANK).build(null) } - val MATTER_DECOMPOSER: BlockEntityType by registry.register(MNames.MATTER_DECOMPOSER) { BlockEntityType.Builder.of(::MatterDecomposerBlockEntity, MBlocks.MATTER_DECOMPOSER).build(null) } - val MATTER_CAPACITOR_BANK: BlockEntityType by registry.register(MNames.MATTER_CAPACITOR_BANK) { BlockEntityType.Builder.of(::MatterCapacitorBankBlockEntity, MBlocks.MATTER_CAPACITOR_BANK).build(null) } - val MATTER_CABLE: BlockEntityType by registry.register(MNames.MATTER_CABLE) { BlockEntityType.Builder.of(::MatterCableBlockEntity, MBlocks.MATTER_CABLE).build(null) } - val STORAGE_CABLE: BlockEntityType by registry.register(MNames.STORAGE_CABLE) { BlockEntityType.Builder.of(::StorageCableBlockEntity, MBlocks.STORAGE_CABLE).build(null) } - val PATTERN_STORAGE: BlockEntityType by registry.register(MNames.PATTERN_STORAGE) { BlockEntityType.Builder.of(::PatternStorageBlockEntity, MBlocks.PATTERN_STORAGE).build(null) } - val MATTER_SCANNER: BlockEntityType by registry.register(MNames.MATTER_SCANNER) { BlockEntityType.Builder.of(::MatterScannerBlockEntity, MBlocks.MATTER_SCANNER).build(null) } - val MATTER_PANEL: BlockEntityType by registry.register(MNames.MATTER_PANEL) { BlockEntityType.Builder.of(::MatterPanelBlockEntity, MBlocks.MATTER_PANEL).build(null) } - val MATTER_REPLICATOR: BlockEntityType by registry.register(MNames.MATTER_REPLICATOR) { BlockEntityType.Builder.of(::MatterReplicatorBlockEntity, MBlocks.MATTER_REPLICATOR).build(null) } - val MATTER_BOTTLER: BlockEntityType by registry.register(MNames.MATTER_BOTTLER) { BlockEntityType.Builder.of(::MatterBottlerBlockEntity, MBlocks.MATTER_BOTTLER).build(null) } - val DRIVE_VIEWER: BlockEntityType by registry.register(MNames.DRIVE_VIEWER) { BlockEntityType.Builder.of(::DriveViewerBlockEntity, MBlocks.DRIVE_VIEWER).build(null) } - val BLACK_HOLE: BlockEntityType by registry.register(MNames.BLACK_HOLE) { BlockEntityType.Builder.of(::BlackHoleBlockEntity, MBlocks.BLACK_HOLE).build(null) } - val CARGO_CRATE: BlockEntityType by registry.register(MNames.CARGO_CRATE) { BlockEntityType.Builder.of(::CargoCrateBlockEntity, *MRegistry.CARGO_CRATES.blocks.values.toTypedArray()).build(null) } - val DRIVE_RACK: BlockEntityType by registry.register(MNames.DRIVE_RACK) { BlockEntityType.Builder.of(::DriveRackBlockEntity, MBlocks.DRIVE_RACK).build(null) } - val ITEM_MONITOR: BlockEntityType by registry.register(MNames.ITEM_MONITOR) { BlockEntityType.Builder.of(::ItemMonitorBlockEntity, MBlocks.ITEM_MONITOR).build(null) } - val ENERGY_COUNTER: BlockEntityType by registry.register(MNames.ENERGY_COUNTER) { BlockEntityType.Builder.of(::EnergyCounterBlockEntity, MBlocks.ENERGY_COUNTER).build(null) } - val CHEMICAL_GENERATOR: BlockEntityType by registry.register(MNames.CHEMICAL_GENERATOR) { BlockEntityType.Builder.of(::ChemicalGeneratorBlockEntity, MBlocks.CHEMICAL_GENERATOR).build(null) } - val PLATE_PRESS: BlockEntityType by registry.register(MNames.PLATE_PRESS) { BlockEntityType.Builder.of(::PlatePressBlockEntity, MBlocks.PLATE_PRESS).build(null) } - val TWIN_PLATE_PRESS: BlockEntityType by registry.register(MNames.TWIN_PLATE_PRESS) { BlockEntityType.Builder.of({ a, b -> PlatePressBlockEntity(a, b, true) }, MBlocks.TWIN_PLATE_PRESS).build(null) } - val GRAVITATION_STABILIZER: BlockEntityType by registry.register(MNames.GRAVITATION_STABILIZER) { BlockEntityType.Builder.of(::GravitationStabilizerBlockEntity, MBlocks.GRAVITATION_STABILIZER).build(null) } - val MATTER_RECYCLER: BlockEntityType by registry.register(MNames.MATTER_RECYCLER) { BlockEntityType.Builder.of(::MatterRecyclerBlockEntity, MBlocks.MATTER_RECYCLER).build(null) } - val ENERGY_SERVO: BlockEntityType by registry.register(MNames.ENERGY_SERVO) { BlockEntityType.Builder.of(::EnergyServoBlockEntity, MBlocks.ENERGY_SERVO).build(null) } - val COBBLESTONE_GENERATOR: BlockEntityType by registry.register(MNames.COBBLESTONE_GENERATOR) { BlockEntityType.Builder.of(::CobblerBlockEntity, MBlocks.COBBLESTONE_GENERATOR).build(null) } - val ESSENCE_STORAGE: BlockEntityType by registry.register(MNames.ESSENCE_STORAGE) { BlockEntityType.Builder.of(::EssenceStorageBlockEntity, MBlocks.ESSENCE_STORAGE).build(null) } - val MATTER_RECONSTRUCTOR: BlockEntityType by registry.register(MNames.MATTER_RECONSTRUCTOR) { BlockEntityType.Builder.of(::MatterReconstructorBlockEntity, MBlocks.MATTER_RECONSTRUCTOR).build(null) } - val FLUID_TANK: BlockEntityType by registry.register(MNames.FLUID_TANK) { BlockEntityType.Builder.of(::FluidTankBlockEntity, MBlocks.FLUID_TANK).build(null) } - val ANDROID_CHARGER: BlockEntityType by registry.register(MNames.ANDROID_CHARGER) { BlockEntityType.Builder.of(::AndroidChargerBlockEntity, MBlocks.ANDROID_CHARGER).build(null) } - val ANDROID_CHARGER_MIDDLE: BlockEntityType by registry.register(MNames.ANDROID_CHARGER + "_middle") { BlockEntityType.Builder.of(::AndroidChargerMiddleBlockEntity, MBlocks.ANDROID_CHARGER).build(null) } - val ANDROID_CHARGER_TOP: BlockEntityType by registry.register(MNames.ANDROID_CHARGER + "_top") { BlockEntityType.Builder.of(::AndroidChargerTopBlockEntity, MBlocks.ANDROID_CHARGER).build(null) } - val INFINITE_WATER_SOURCE: BlockEntityType by registry.register(MNames.INFINITE_WATER_SOURCE) { BlockEntityType.Builder.of(::InfiniteWaterSourceBlockEntity, MBlocks.INFINITE_WATER_SOURCE).build(null) } - val DEV_CHEST: BlockEntityType by registry.register(MNames.DEV_CHEST) { BlockEntityType.Builder.of(::DevChestBlockEntity, MBlocks.DEV_CHEST).build(null) } + private fun register(name: String, factory: BlockEntityType.BlockEntitySupplier, vararg blocks: Supplier): RegistryObject> { + return registry.register(name) { BlockEntityType.Builder.of(factory, *blocks.map { it.get() }.toTypedArray()).build(null) } + } + + val ANDROID_STATION by register(MNames.ANDROID_STATION, ::AndroidStationBlockEntity, MBlocks::ANDROID_STATION) + val BATTERY_BANK by register(MNames.BATTERY_BANK, ::BatteryBankBlockEntity, MBlocks::BATTERY_BANK) + val MATTER_DECOMPOSER by register(MNames.MATTER_DECOMPOSER, ::MatterDecomposerBlockEntity, MBlocks::MATTER_DECOMPOSER) + val MATTER_CAPACITOR_BANK by register(MNames.MATTER_CAPACITOR_BANK, ::MatterCapacitorBankBlockEntity, MBlocks::MATTER_CAPACITOR_BANK) + val MATTER_CABLE by register(MNames.MATTER_CABLE, ::MatterCableBlockEntity, MBlocks::MATTER_CABLE) + val STORAGE_CABLE by register(MNames.STORAGE_CABLE, ::StorageCableBlockEntity, MBlocks::STORAGE_CABLE) + val PATTERN_STORAGE by register(MNames.PATTERN_STORAGE, ::PatternStorageBlockEntity, MBlocks::PATTERN_STORAGE) + val MATTER_SCANNER by register(MNames.MATTER_SCANNER, ::MatterScannerBlockEntity, MBlocks::MATTER_SCANNER) + val MATTER_PANEL by register(MNames.MATTER_PANEL, ::MatterPanelBlockEntity, MBlocks::MATTER_PANEL) + val MATTER_REPLICATOR by register(MNames.MATTER_REPLICATOR, ::MatterReplicatorBlockEntity, MBlocks::MATTER_REPLICATOR) + val MATTER_BOTTLER by register(MNames.MATTER_BOTTLER, ::MatterBottlerBlockEntity, MBlocks::MATTER_BOTTLER) + val DRIVE_VIEWER by register(MNames.DRIVE_VIEWER, ::DriveViewerBlockEntity, MBlocks::DRIVE_VIEWER) + val BLACK_HOLE by register(MNames.BLACK_HOLE, ::BlackHoleBlockEntity, MBlocks::BLACK_HOLE) + val CARGO_CRATE by registry.register(MNames.CARGO_CRATE) { BlockEntityType.Builder.of(::CargoCrateBlockEntity, *MRegistry.CARGO_CRATES.blocks.values.toTypedArray()).build(null) } + val DRIVE_RACK by register(MNames.DRIVE_RACK, ::DriveRackBlockEntity, MBlocks::DRIVE_RACK) + val ITEM_MONITOR by register(MNames.ITEM_MONITOR, ::ItemMonitorBlockEntity, MBlocks::ITEM_MONITOR) + val ENERGY_COUNTER by register(MNames.ENERGY_COUNTER, ::EnergyCounterBlockEntity, MBlocks::ENERGY_COUNTER) + val CHEMICAL_GENERATOR by register(MNames.CHEMICAL_GENERATOR, ::ChemicalGeneratorBlockEntity, MBlocks::CHEMICAL_GENERATOR) + val PLATE_PRESS by register(MNames.PLATE_PRESS, ::PlatePressBlockEntity, MBlocks::PLATE_PRESS) + val TWIN_PLATE_PRESS by register(MNames.TWIN_PLATE_PRESS, { a, b -> PlatePressBlockEntity(a, b, true) }, MBlocks::TWIN_PLATE_PRESS) + val GRAVITATION_STABILIZER by register(MNames.GRAVITATION_STABILIZER, ::GravitationStabilizerBlockEntity, MBlocks::GRAVITATION_STABILIZER) + val MATTER_RECYCLER by register(MNames.MATTER_RECYCLER, ::MatterRecyclerBlockEntity, MBlocks::MATTER_RECYCLER) + val ENERGY_SERVO by register(MNames.ENERGY_SERVO, ::EnergyServoBlockEntity, MBlocks::ENERGY_SERVO) + val COBBLESTONE_GENERATOR by register(MNames.COBBLESTONE_GENERATOR, ::CobblerBlockEntity, MBlocks::COBBLESTONE_GENERATOR) + val ESSENCE_STORAGE by register(MNames.ESSENCE_STORAGE, ::EssenceStorageBlockEntity, MBlocks::ESSENCE_STORAGE) + val MATTER_RECONSTRUCTOR by register(MNames.MATTER_RECONSTRUCTOR, ::MatterReconstructorBlockEntity, MBlocks::MATTER_RECONSTRUCTOR) + val FLUID_TANK by register(MNames.FLUID_TANK, ::FluidTankBlockEntity, MBlocks::FLUID_TANK) + val ANDROID_CHARGER by register(MNames.ANDROID_CHARGER, ::AndroidChargerBlockEntity, MBlocks::ANDROID_CHARGER) + val ANDROID_CHARGER_MIDDLE by register(MNames.ANDROID_CHARGER + "_middle", ::AndroidChargerMiddleBlockEntity, MBlocks::ANDROID_CHARGER) + val ANDROID_CHARGER_TOP by register(MNames.ANDROID_CHARGER + "_top", ::AndroidChargerTopBlockEntity, MBlocks::ANDROID_CHARGER) + val INFINITE_WATER_SOURCE by register(MNames.INFINITE_WATER_SOURCE, ::InfiniteWaterSourceBlockEntity, MBlocks::INFINITE_WATER_SOURCE) + val DEV_CHEST by register(MNames.DEV_CHEST, ::DevChestBlockEntity, MBlocks::DEV_CHEST) + val PAINTER by register(MNames.PAINTER, ::PainterBlockEntity, MBlocks::PAINTER) val POWERED_FURNACE: BlockEntityType by registry.register(MNames.POWERED_FURNACE) { BlockEntityType.Builder.of({ a, b -> MBlocks.POWERED_FURNACE.newBlockEntity(a, b) }, MBlocks.POWERED_FURNACE).build(null) } val POWERED_BLAST_FURNACE: BlockEntityType by registry.register(MNames.POWERED_BLAST_FURNACE) { BlockEntityType.Builder.of({ a, b -> MBlocks.POWERED_BLAST_FURNACE.newBlockEntity(a, b) }, MBlocks.POWERED_BLAST_FURNACE).build(null) } 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 9aea56fdd..34658df9d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -63,6 +63,7 @@ import ru.dbotthepony.mc.otm.block.storage.StoragePowerSupplierBlock import ru.dbotthepony.mc.otm.block.tech.AndroidChargerBlock import ru.dbotthepony.mc.otm.block.tech.CobblerBlock import ru.dbotthepony.mc.otm.block.tech.EssenceStorageBlock +import ru.dbotthepony.mc.otm.block.tech.PainterBlock import ru.dbotthepony.mc.otm.block.tech.PoweredFurnaceBlock import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.core.TranslatableComponent @@ -100,6 +101,7 @@ object MBlocks { val INFINITE_WATER_SOURCE: Block by registry.register(MNames.INFINITE_WATER_SOURCE) { InfiniteWaterSourceBlock() } val ESSENCE_STORAGE: EssenceStorageBlock by registry.register(MNames.ESSENCE_STORAGE) { EssenceStorageBlock() } val MATTER_RECONSTRUCTOR: MatterReconstructorBlock by registry.register(MNames.MATTER_RECONSTRUCTOR) { MatterReconstructorBlock() } + val PAINTER: PainterBlock by registry.register(MNames.PAINTER) { PainterBlock() } val STORAGE_BUS: Block by registry.register(MNames.STORAGE_BUS) { StorageBusBlock() } val STORAGE_IMPORTER: Block by registry.register(MNames.STORAGE_IMPORTER) { StorageImporterBlock() } 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 a7b653932..8c004d6c5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -151,6 +151,8 @@ object MItems { } } + val PAINTER: BlockItem by registry.register(MNames.PAINTER) { BlockItem(MBlocks.PAINTER, DEFAULT_PROPERTIES) } + val MACHINES = SupplierList( ::ANDROID_STATION, ::ANDROID_CHARGER, ::BATTERY_BANK, ::MATTER_DECOMPOSER, ::MATTER_CAPACITOR_BANK, ::MATTER_CABLE, ::PATTERN_STORAGE, ::MATTER_SCANNER, ::MATTER_PANEL, ::MATTER_REPLICATOR, ::MATTER_BOTTLER, ::ENERGY_COUNTER, ::CHEMICAL_GENERATOR, @@ -158,7 +160,7 @@ object MItems { ::POWERED_SMOKER, ::STORAGE_BUS, ::STORAGE_IMPORTER, ::STORAGE_EXPORTER, ::DRIVE_VIEWER, ::DRIVE_RACK, ::ITEM_MONITOR, ::STORAGE_CABLE, ::STORAGE_POWER_SUPPLIER, - ::ENERGY_SERVO, + ::ENERGY_SERVO, ::PAINTER, ::PHANTOM_ATTRACTOR, ::GRAVITATION_STABILIZER, ::COBBLESTONE_GENERATOR, ::INFINITE_WATER_SOURCE, ::ESSENCE_STORAGE, ::MATTER_RECONSTRUCTOR ) 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 e6dc21401..fbc7042df 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt @@ -36,6 +36,7 @@ import ru.dbotthepony.mc.otm.client.screen.tech.CobblerScreen import ru.dbotthepony.mc.otm.client.screen.tech.EnergyCounterScreen import ru.dbotthepony.mc.otm.client.screen.tech.EnergyServoScreen import ru.dbotthepony.mc.otm.client.screen.tech.EssenceStorageScreen +import ru.dbotthepony.mc.otm.client.screen.tech.PainterScreen import ru.dbotthepony.mc.otm.client.screen.tech.PlatePressScreen import ru.dbotthepony.mc.otm.client.screen.tech.PoweredFurnaceScreen import ru.dbotthepony.mc.otm.client.screen.tech.TwinPlatePressScreen @@ -66,6 +67,7 @@ import ru.dbotthepony.mc.otm.menu.tech.CobblerMenu import ru.dbotthepony.mc.otm.menu.tech.EnergyCounterMenu import ru.dbotthepony.mc.otm.menu.tech.EnergyServoMenu import ru.dbotthepony.mc.otm.menu.tech.EssenceStorageMenu +import ru.dbotthepony.mc.otm.menu.tech.PainterMenu import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu @@ -100,6 +102,7 @@ object MMenus { val ESSENCE_STORAGE: MenuType by registry.register(MNames.ESSENCE_STORAGE) { MenuType(::EssenceStorageMenu, FeatureFlags.VANILLA_SET) } val ITEM_REPAIER: MenuType by registry.register(MNames.MATTER_RECONSTRUCTOR) { MenuType(::MatterReconstructorMenu, FeatureFlags.VANILLA_SET) } val FLUID_TANK: MenuType by registry.register(MNames.FLUID_TANK) { MenuType(::FluidTankMenu, FeatureFlags.VANILLA_SET) } + val PAINTER: MenuType by registry.register(MNames.PAINTER) { MenuType(::PainterMenu, FeatureFlags.VANILLA_SET) } val STORAGE_BUS: MenuType by registry.register(MNames.STORAGE_BUS) { MenuType(::StorageBusMenu, FeatureFlags.VANILLA_SET) } val STORAGE_IMPORTER_EXPORTER: MenuType by registry.register(MNames.STORAGE_IMPORTER) { MenuType(::StorageImporterExporterMenu, FeatureFlags.VANILLA_SET) } @@ -142,6 +145,7 @@ object MMenus { MenuScreens.register(ITEM_REPAIER, ::MatterReconstructorScreen) MenuScreens.register(FLUID_TANK, ::FluidTankScreen) MenuScreens.register(POWERED_FURNACE, ::PoweredFurnaceScreen) + MenuScreens.register(PAINTER, ::PainterScreen) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index 6d80d71bc..cc48bc828 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -15,6 +15,7 @@ object MNames { const val ANDROID_CHARGER = "android_charger" const val INFINITE_WATER_SOURCE = "infinite_water_source" const val DEV_CHEST = "dev_chest" + const val PAINTER = "painter" // blocks const val ANDROID_STATION = "android_station" diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt index 216531d73..3894c5b2e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt @@ -10,6 +10,7 @@ import net.minecraftforge.registries.RegistryObject import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.recipe.EnergyContainerRecipe import ru.dbotthepony.mc.otm.recipe.ExplosiveHammerPrimingRecipe +import ru.dbotthepony.mc.otm.recipe.PainterRecipe import ru.dbotthepony.mc.otm.recipe.PlatePressRecipe import ru.dbotthepony.mc.otm.recipe.UpgradeRecipe @@ -36,11 +37,13 @@ object MRecipes { } val PLATE_PRESS by register("plate_press") + val PAINTER by register("painter") init { serializers.register("plate_press") { PlatePressRecipe.SERIALIZER } serializers.register("energy_container") { EnergyContainerRecipe.Companion } serializers.register("upgrade") { UpgradeRecipe.Companion } serializers.register("hammer_priming") { ExplosiveHammerPrimingRecipe.Companion } + serializers.register("painter") { PainterRecipe.SERIALIZER } } } From 320f0655d67675d597005cd58550be77351805d7 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 15 Aug 2023 20:48:24 +0700 Subject: [PATCH 0965/1199] Move painter table to decorations subpackage --- .../mc/otm/block/{tech => decorative}/PainterBlock.kt | 4 ++-- .../block/entity/{tech => decorative}/PainterBlockEntity.kt | 3 +-- .../dbotthepony/mc/otm/client/screen/tech/PainterScreen.kt | 3 +-- .../kotlin/ru/dbotthepony/mc/otm/menu/tech/PainterMenu.kt | 2 +- .../kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt | 5 +---- .../kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt | 1 + src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt | 2 +- 7 files changed, 8 insertions(+), 12 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/block/{tech => decorative}/PainterBlock.kt (88%) rename src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/{tech => decorative}/PainterBlockEntity.kt (98%) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PainterBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/PainterBlock.kt similarity index 88% rename from src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PainterBlock.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/PainterBlock.kt index 391f7504e..0e8ffdaa6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PainterBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/PainterBlock.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.block.tech +package ru.dbotthepony.mc.otm.block.decorative import net.minecraft.core.BlockPos import net.minecraft.world.level.Level @@ -8,7 +8,7 @@ import net.minecraft.world.level.block.entity.BlockEntityTicker import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock -import ru.dbotthepony.mc.otm.block.entity.tech.PainterBlockEntity +import ru.dbotthepony.mc.otm.block.entity.decorative.PainterBlockEntity class PainterBlock : RotatableMatteryBlock(), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PainterBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/PainterBlockEntity.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PainterBlockEntity.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/PainterBlockEntity.kt index 46e00a325..02c980166 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PainterBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/PainterBlockEntity.kt @@ -1,9 +1,8 @@ -package ru.dbotthepony.mc.otm.block.entity.tech +package ru.dbotthepony.mc.otm.block.entity.decorative import com.google.common.collect.ImmutableList import net.minecraft.core.BlockPos import net.minecraft.nbt.CompoundTag -import net.minecraft.nbt.IntTag import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PainterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PainterScreen.kt index 9882c3e27..b85fe86df 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PainterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PainterScreen.kt @@ -9,7 +9,7 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraftforge.common.Tags import net.minecraftforge.registries.ForgeRegistries -import ru.dbotthepony.mc.otm.block.entity.tech.PainterBlockEntity +import ru.dbotthepony.mc.otm.block.entity.decorative.PainterBlockEntity import ru.dbotthepony.mc.otm.client.render.FlatRectangleIcon import ru.dbotthepony.mc.otm.client.render.ItemStackIcon import ru.dbotthepony.mc.otm.client.render.renderRect @@ -28,7 +28,6 @@ import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.menu.tech.PainterMenu -import ru.dbotthepony.mc.otm.registry.MItems class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { inner class Bar(parent: EditablePanel<*>, val dye: DyeColor) : EditablePanel(this@PainterScreen, parent, width = 5f) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PainterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PainterMenu.kt index 55466ffd1..5d93bddb0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PainterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PainterMenu.kt @@ -5,7 +5,7 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack -import ru.dbotthepony.mc.otm.block.entity.tech.PainterBlockEntity +import ru.dbotthepony.mc.otm.block.entity.decorative.PainterBlockEntity import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.core.ISubscriptable import ru.dbotthepony.mc.otm.core.addAll 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 158cab1df..61cda92bd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt @@ -1,7 +1,5 @@ package ru.dbotthepony.mc.otm.recipe -import com.google.common.collect.ImmutableSet -import com.mojang.datafixers.util.Either import com.mojang.serialization.Codec import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.core.NonNullList @@ -17,13 +15,12 @@ import net.minecraft.world.item.crafting.RecipeSerializer import net.minecraft.world.item.crafting.RecipeType import net.minecraft.world.level.Level import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.block.entity.tech.PainterBlockEntity +import ru.dbotthepony.mc.otm.block.entity.decorative.PainterBlockEntity import ru.dbotthepony.mc.otm.container.get import ru.dbotthepony.mc.otm.core.isActuallyEmpty import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.tagNotNull import ru.dbotthepony.mc.otm.data.Codec2RecipeSerializer -import ru.dbotthepony.mc.otm.data.CodecList import ru.dbotthepony.mc.otm.data.IngredientCodec import ru.dbotthepony.mc.otm.data.PredicatedCodecList import ru.dbotthepony.mc.otm.data.minRange 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 4dfd27172..0a88fdb2a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt @@ -20,6 +20,7 @@ import ru.dbotthepony.mc.otm.block.entity.decorative.DevChestBlockEntity import ru.dbotthepony.mc.otm.block.entity.decorative.FluidTankBlockEntity import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity import ru.dbotthepony.mc.otm.block.entity.decorative.InfiniteWaterSourceBlockEntity +import ru.dbotthepony.mc.otm.block.entity.decorative.PainterBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.* import ru.dbotthepony.mc.otm.block.entity.storage.* import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity 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 34658df9d..4772c75de 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -63,7 +63,7 @@ import ru.dbotthepony.mc.otm.block.storage.StoragePowerSupplierBlock import ru.dbotthepony.mc.otm.block.tech.AndroidChargerBlock import ru.dbotthepony.mc.otm.block.tech.CobblerBlock import ru.dbotthepony.mc.otm.block.tech.EssenceStorageBlock -import ru.dbotthepony.mc.otm.block.tech.PainterBlock +import ru.dbotthepony.mc.otm.block.decorative.PainterBlock import ru.dbotthepony.mc.otm.block.tech.PoweredFurnaceBlock import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.core.TranslatableComponent From 840b103ee16a695625cab5a2756d30b90d788fd0 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 15 Aug 2023 21:02:00 +0700 Subject: [PATCH 0966/1199] Fix painter table sometimes being unable to mix colors when it is clearly capable to do --- .../entity/decorative/PainterBlockEntity.kt | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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 02c980166..d354bf5e9 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 @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.block.entity.decorative import com.google.common.collect.ImmutableList +import it.unimi.dsi.fastutil.ints.Int2IntArrayMap import net.minecraft.core.BlockPos import net.minecraft.nbt.CompoundTag import net.minecraft.world.entity.player.Inventory @@ -132,7 +133,24 @@ class PainterBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDe for (ingredients in mixing) { val copy = EnumMap(input) - ingredients.forEach { mixer(it).mix(copy, seen, stack) } + var i = 0 + val volumes = Int2IntArrayMap() + + // страховка от взаимной блокировки когда последующий ингредиент требует предыдущий. + // создаёт горку из значений + for (i2 in ingredients.indices) + volumes[i2] = 1 + + while (!ingredients.all { copy[it]!! > 0 } && i++ < 20) { + ingredients.withIndex().forEach { for (t in 0 until volumes[it.index]) mixer(it.value).mix(copy, seen, stack) } + + var increase = i + val iter = ingredients.indices.iterator() + + while (iter.hasNext() && increase-- > 0) { + volumes[iter.nextInt()]++ + } + } if (ingredients.all { copy[it]!! > 0 }) { ingredients.forEach { copy[it] = copy[it]!! - 1 } From e08e6d783010944a5f1459c36d7037c5fabd8da1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 16 Aug 2023 01:43:11 +0700 Subject: [PATCH 0967/1199] Reduce file count of painter recipes --- .../mc/otm/datagen/recipes/PainterRecipes.kt | 37 ++++++++----------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt index f700cb50d..2f290aa1e 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt @@ -7,6 +7,7 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.item.crafting.Ingredient import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.core.stream import ru.dbotthepony.mc.otm.datagen.modLocation import ru.dbotthepony.mc.otm.recipe.PainterRecipe import ru.dbotthepony.mc.otm.registry.MItems @@ -16,19 +17,15 @@ import java.util.function.Consumer private val Item.recipeName get() = registryName!!.namespace + "/" + registryName!!.path private fun generate(consumer: Consumer, items: Map, amount: Int = 1) { - for ((k1, v1) in items) { - if (k1 == null) continue - for ((k2, v2) in items) { - if (k2 == null || k1 == k2) continue + for ((targetColor, targetItem) in items) { + if (targetColor == null) continue - consumer.accept(PainterRecipe( - modLocation("painter/" + v2.recipeName + "/" + v1.recipeName), - Ingredient.of(v1), - ItemStack(v2), - //if (k1 == DyeColor.WHITE || k2 == DyeColor.BLACK) setOf(k2) else setOf(DyeColor.BLACK, k2) - mapOf(k2 to amount) - ).toFinished()) - } + consumer.accept(PainterRecipe( + modLocation("painter/" + targetItem.recipeName), + Ingredient.of(items.entries.stream().filter { it.key != null && it.key != targetColor }.map { ItemStack(it.value) }), + ItemStack(targetItem), + mapOf(targetColor to amount) + ).toFinished()) } } @@ -51,16 +48,12 @@ private fun generate(consumer: Consumer, default: Item, items: M } private fun cleaning(consumer: Consumer, to: Item, from: Map) { - for ((k1, v1) in from) { - if (k1 == null) continue - - consumer.accept(PainterRecipe( - modLocation("painter/cleaning/" + to.recipeName + "/" + v1.recipeName), - Ingredient.of(v1), - ItemStack(to), - setOf() - ).toFinished()) - } + consumer.accept(PainterRecipe( + modLocation("painter/cleaning/" + to.recipeName), + Ingredient.of(from.entries.stream().filter { it.key != null }.map { ItemStack(it.value) }), + ItemStack(to), + setOf() + ).toFinished()) } private fun striped(consumer: Consumer, name: String, items: List>>, base: Map) { From 8e2c1f25dcb0733986f46fb430f05deb18834fad Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 16 Aug 2023 14:26:33 +0700 Subject: [PATCH 0968/1199] lol --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c702f104a..50a8b01e7 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,14 @@ Minecraft mod with science fiction style, about matter, and energy, combined. ### Required mods * [Kotlin for Forge](https://www.curseforge.com/minecraft/mc-mods/kotlin-for-forge) or have Kotlin standard library in classpath (at least 1.8.0 is required) -* [Koremods](https://beta.curseforge.com/minecraft/mc-mods/koremods) ### Recommended mods * [Ferrite Core](https://www.curseforge.com/minecraft/mc-mods/ferritecore), reduces memory usage * In case of Overdrive That Matters, ***greatly*** reduces JVM heap bloat caused by model data being duplicated +* Particle Collider, reduces world join time + ### Mods with special compatibility code * [JEI](https://www.curseforge.com/minecraft/mc-mods/jei) From 8e03b4363d11ce065b6719fd4364b58f8182c06c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 16 Aug 2023 18:15:14 +0700 Subject: [PATCH 0969/1199] Revisit quantum battery code and clean it up --- .../dbotthepony/mc/otm/GlobalEventHandler.kt | 50 +- .../ru/dbotthepony/mc/otm/capability/Ext.kt | 32 +- .../mc/otm/compat/cos/CosmeticArmorCompat.kt | 12 +- .../mc/otm/compat/curios/CuriosCompat.kt | 21 +- .../otm/container/ItemHandlerSpliterator.kt | 4 +- .../otm/core/collect/ReferenceHashStrategy.kt | 31 ++ .../mc/otm/core/collect/StreamyIterators.kt | 19 +- .../mc/otm/core/collect/WeakHashSet.kt | 53 +- .../dbotthepony/mc/otm/core/math/Decimal.kt | 2 +- .../core/util/AtomicallyInvalidatedLazy.kt | 42 ++ .../mc/otm/core/util/HashedWeakReference.kt | 28 + .../condition/ItemInInventoryCondition.kt | 5 +- .../mc/otm/item/QuantumBatteryItem.kt | 504 ++++++++---------- .../ru/dbotthepony/mc/otm/registry/MItems.kt | 2 +- 14 files changed, 439 insertions(+), 366 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ReferenceHashStrategy.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/util/AtomicallyInvalidatedLazy.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/util/HashedWeakReference.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt index 2d66cbc24..24a73bf1c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt @@ -17,18 +17,37 @@ import net.minecraftforge.fml.loading.FMLLoader import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.capability.AbstractProfiledStorage import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.core.collect.WeakHashSet +import ru.dbotthepony.mc.otm.core.util.AtomicallyInvalidatedLazy import ru.dbotthepony.mc.otm.core.util.IConditionalTickable import ru.dbotthepony.mc.otm.core.util.ITickable import ru.dbotthepony.mc.otm.core.util.TickList import ru.dbotthepony.mc.otm.graph.GraphNodeList import ru.dbotthepony.mc.otm.network.MatteryNetworkChannel import java.util.* +import java.util.concurrent.atomic.AtomicInteger private val preServerTick = TickList() private val postServerTick = TickList() private val preWorldTick = WeakHashMap() private val postWorldTick = WeakHashMap() +private val clientThreads = WeakHashSet() +private val serverThreads = WeakHashSet() + +private val serverCounter = AtomicInteger() +private var _server: MinecraftServer? = null +val isClient: Boolean by lazy { FMLLoader.getDist() == Dist.CLIENT } + +fun lazyPerServer(fn: (MinecraftServer) -> V): Lazy { + return AtomicallyInvalidatedLazy(serverCounter) { + if (!SERVER_IS_LIVE) + throw IllegalStateException("No server is running") + + fn.invoke(_server!!) + } +} + fun onceServerPre(inTicks: Int, callback: Runnable): TickList.Timer? { if (!SERVER_IS_LIVE) { LOGGER.error("Refusing to add timer $callback in ticks $inTicks while server is dying", IllegalStateException("Server is stopping")) @@ -47,12 +66,6 @@ fun onceServer(inTicks: Int, callback: Runnable): TickList.Timer? { return postServerTick.Timer(inTicks, callback) } -private var _server: MinecraftServer? = null -private var _serverThread: Thread? = null -private var _clientThread: Thread? = null - -val isClient: Boolean by lazy { FMLLoader.getDist() == Dist.CLIENT } - private val isPausedImpl: Boolean get() { val server = _server @@ -64,7 +77,7 @@ private val isPausedImpl: Boolean get() { } val isPaused: Boolean get() { - if (_clientThread === null) { + if (clientThreads.isEmpty()) { return false } @@ -72,11 +85,7 @@ val isPaused: Boolean get() { } fun recordClientThread() { - if (_clientThread != null) { - throw IllegalStateException("Already have client channel") - } - - _clientThread = Thread.currentThread() + clientThreads.add(Thread.currentThread()) } fun runIfClient(lambda: () -> Unit) { @@ -119,11 +128,11 @@ fun runOnClient(value: V, lambda: () -> V): V { } fun isServerThread(): Boolean { - return Thread.currentThread() === _serverThread + return Thread.currentThread() in serverThreads } fun isClientThread(): Boolean { - return Thread.currentThread() === _clientThread + return Thread.currentThread() in clientThreads } val MINECRAFT_SERVER: MinecraftServer @@ -146,6 +155,7 @@ private val LOGGER = LogManager.getLogger() fun onServerTick(event: ServerTickEvent) { if (event.phase === TickEvent.Phase.START) { preServerTick.tick() + serverThreads.add(Thread.currentThread()) } else { postServerTick.tick() // чтоб не плодить кучу подписчиков, вызовем напрямую отсюда @@ -158,6 +168,12 @@ fun onServerTick(event: ServerTickEvent) { fun onWorldTick(event: LevelTickEvent) { if (event.phase === TickEvent.Phase.START) { preWorldTick[event.level]?.tick() + + if (event.side.isClient) { + clientThreads.add(Thread.currentThread()) + } else if (event.side.isServer) { + serverThreads.add(Thread.currentThread()) + } } else { postWorldTick[event.level]?.tick() } @@ -254,13 +270,15 @@ fun onServerStarting(event: ServerAboutToStartEvent) { clear() SERVER_IS_LIVE = true _server = event.server - _serverThread = Thread.currentThread() + serverThreads.add(Thread.currentThread()) + serverCounter.incrementAndGet() MatteryNetworkChannel.onServerStarting() } fun onServerStopping(event: ServerStoppingEvent) { clear() SERVER_IS_LIVE = false + serverCounter.incrementAndGet() MatteryNetworkChannel.onServerStopping() } @@ -273,6 +291,6 @@ fun onServerStopped(event: ServerStoppedEvent) { } _server = null - _serverThread = null + serverCounter.incrementAndGet() MatteryNetworkChannel.onServerStopped() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt index c81c4c3bc..c0bde449d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.capability import com.google.common.collect.Streams +import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet import net.minecraft.ChatFormatting import net.minecraft.core.Direction import net.minecraft.network.chat.Component @@ -30,6 +31,9 @@ import ru.dbotthepony.mc.otm.container.iterator import ru.dbotthepony.mc.otm.container.stream import ru.dbotthepony.mc.otm.core.collect.AwareItemStack import ru.dbotthepony.mc.otm.core.collect.ContainerItemStackEntry +import ru.dbotthepony.mc.otm.core.collect.concatIterators +import ru.dbotthepony.mc.otm.core.collect.filter +import ru.dbotthepony.mc.otm.core.collect.map import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.orNull @@ -219,25 +223,25 @@ fun ICapabilityProvider.getMatteryEnergySided(side: Direction? = null): LazyOpti * * Contains all items that player might carry */ -fun Player.itemsStream(includeCosmetics: Boolean = true): Stream { - val streams = ArrayList>() - streams.add(inventory.stream()) +fun Player.items(includeCosmetics: Boolean = true): Iterator { + val iterators = ArrayList>() + iterators.add(inventory.iterator()) matteryPlayer?.let { if (it.hasExopack) { - streams.add(it.exopackContainer.stream()) + iterators.add(it.exopackContainer.iterator()) } } if (isCuriosLoaded) { - streams.add(curiosStream(includeCosmetics)) + iterators.add(curiosStream(includeCosmetics)) } if (includeCosmetics && isCosmeticArmorLoaded) { - streams.add(cosmeticArmorStream()) + iterators.add(cosmeticArmorStream()) } - return streams.stream().flatMap { it } + return concatIterators(iterators) } /** @@ -245,20 +249,20 @@ fun Player.itemsStream(includeCosmetics: Boolean = true): Stream * * Contains all items that player might see/access ([itemsStream] + open container's items) */ -fun Player.allItemsStream(includeCosmetics: Boolean = true): Stream { +fun Player.allItems(includeCosmetics: Boolean = true): Iterator { if (containerMenu == inventoryMenu || containerMenu == matteryPlayer?.exoPackMenu) { - return itemsStream(includeCosmetics) + return items(includeCosmetics) } - val seen = IdentityHashMap(containerMenu.slots.size) + val seen = ReferenceOpenHashSet(containerMenu.slots.size) for (slot in containerMenu.slots) { - seen[slot.item] = Unit + seen.add(slot.item) } - return Streams.concat( - itemsStream(includeCosmetics).filter { it.isEmpty || it !in seen }, - containerMenu.slots.stream().map { it.item }) + return concatIterators( + items(includeCosmetics).filter { it.isNotEmpty && it !in seen }, + containerMenu.slots.iterator().map { it.item }) } /** diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt index d21277685..17cf76090 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt @@ -24,8 +24,10 @@ import ru.dbotthepony.mc.otm.client.screen.panels.button.RectangleButtonPanel import ru.dbotthepony.mc.otm.compat.cos.CosmeticToggleButton.Companion.BUTTON_ACTIVE import ru.dbotthepony.mc.otm.compat.cos.CosmeticToggleButton.Companion.BUTTON_INACTIVE import ru.dbotthepony.mc.otm.container.awareStream +import ru.dbotthepony.mc.otm.container.iterator import ru.dbotthepony.mc.otm.container.stream import ru.dbotthepony.mc.otm.core.collect.AwareItemStack +import ru.dbotthepony.mc.otm.core.collect.emptyIterator import ru.dbotthepony.mc.otm.menu.MatterySlot import java.util.stream.Stream @@ -71,16 +73,16 @@ private class CosmeticSlot(container: Container, private val slot: EquipmentSlot } } -fun Player.cosmeticArmorStream(): Stream { +fun Player.cosmeticArmorStream(): Iterator { if (!isCosmeticArmorLoaded) { - return Stream.empty() + return emptyIterator() } return cosmeticArmorStreamImpl() } -private fun Player.cosmeticArmorStreamImpl(): Stream { - val manager = ModObjects.invMan ?: return Stream.empty() +private fun Player.cosmeticArmorStreamImpl(): Iterator { + val manager = ModObjects.invMan ?: return emptyIterator() val container = if (this !is ServerPlayer) { manager.getCosArmorInventoryClient(uuid) @@ -88,7 +90,7 @@ private fun Player.cosmeticArmorStreamImpl(): Stream { manager.getCosArmorInventory(uuid) } - return (container as Container).stream() + return (container as Container).iterator() } fun Player.cosmeticArmorAwareStream(): Stream { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt index 50802c1be..4904edad6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt @@ -11,8 +11,11 @@ import net.minecraftforge.network.PacketDistributor import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.container.awareStream +import ru.dbotthepony.mc.otm.container.iterator import ru.dbotthepony.mc.otm.container.stream import ru.dbotthepony.mc.otm.core.collect.AwareItemStack +import ru.dbotthepony.mc.otm.core.collect.concatIterators +import ru.dbotthepony.mc.otm.core.collect.emptyIterator import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.menu.PlayerSlot import top.theillusivec4.curios.api.CuriosApi @@ -85,27 +88,27 @@ val Player.curiosSlots: List> get() { return getCuriosSlotsImpl() } -private fun Player.curiosStreamImpl(includeCosmetics: Boolean): Stream { - val handler = getCapability(MatteryCapability.CURIOS_INVENTORY).orNull() ?: return Stream.empty() +private fun Player.curiosStreamImpl(includeCosmetics: Boolean): Iterator { + val handler = getCapability(MatteryCapability.CURIOS_INVENTORY).orNull() ?: return emptyIterator() - val result = ArrayList>() + val result = ArrayList>() for ((identifier, curio) in handler.curios) { - result.add(curio.stacks.stream()) + result.add(curio.stacks.iterator()) if (includeCosmetics && curio.hasCosmetic()) { - result.add(curio.cosmeticStacks.stream()) + result.add(curio.cosmeticStacks.iterator()) } } - return result.stream().flatMap { it } + return concatIterators(result) } -fun Player.curiosStream(includeCosmetics: Boolean = true): Stream { - return Stream.empty() +fun Player.curiosStream(includeCosmetics: Boolean = true): Iterator { + return emptyIterator() if (!isCuriosLoaded) { - return Stream.empty() + return emptyIterator() } return curiosStreamImpl(includeCosmetics) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemHandlerSpliterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemHandlerSpliterator.kt index 25fc780fb..862c25e43 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemHandlerSpliterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemHandlerSpliterator.kt @@ -6,6 +6,8 @@ import net.minecraft.world.item.ItemStack import net.minecraftforge.items.IItemHandler import ru.dbotthepony.mc.otm.core.collect.AwareItemStack import ru.dbotthepony.mc.otm.core.collect.ItemHandlerItemStackEntry +import ru.dbotthepony.mc.otm.core.collect.filter +import ru.dbotthepony.mc.otm.core.isNotEmpty import java.util.* import java.util.stream.Stream import java.util.stream.StreamSupport @@ -48,7 +50,7 @@ class ItemHandlerAwareSpliterator(private val handler: IItemHandler, offset: Int } } -fun IItemHandler.iterator(): Iterator = Spliterators.iterator(spliterator()) +fun IItemHandler.iterator(): Iterator = Spliterators.iterator(spliterator()).filter { it.isNotEmpty } fun IItemHandler.spliterator(): Spliterator = ItemHandlerSpliterator(this) fun IItemHandler.awareSpliterator(): Spliterator = ItemHandlerAwareSpliterator(this) fun IItemHandler.stream(): Stream = StreamSupport.stream(spliterator(), false) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ReferenceHashStrategy.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ReferenceHashStrategy.kt new file mode 100644 index 000000000..76c362060 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ReferenceHashStrategy.kt @@ -0,0 +1,31 @@ +package ru.dbotthepony.mc.otm.core.collect + +import it.unimi.dsi.fastutil.Hash +import java.lang.ref.Reference + +object ReferenceHashStrategy : Hash.Strategy { + @Suppress("UNCHECKED_CAST") + override fun equals(a: Any?, b: Any?): Boolean { + if (a === b) return true + + if (a is Reference<*>) { + if (a.refersTo(null) || b == null) return false + + if (b is Reference<*>) { + if (b.refersTo(null)) return false + return (b as Reference).refersTo(a.get() ?: return false) + } else { + return (a as Reference).refersTo(b) + } + } else if (b is Reference<*>) { + if (b.refersTo(null) || a == null) return false + return (b as Reference).refersTo(a) + } + + return a == b + } + + override fun hashCode(o: Any?): Int { + return o.hashCode() + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt index 8580dbb75..5711b8ec5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt @@ -23,6 +23,7 @@ import java.util.stream.Collector */ class FilteringIterator(private val parent: Iterator, private val predicate: Predicate) : MutableIterator { private var foundValue: Any? = Companion + private var returned = false override fun hasNext(): Boolean { if (foundValue === Companion) { @@ -58,16 +59,14 @@ class FilteringIterator(private val parent: Iterator, private val predicat } this.foundValue = Companion + returned = true return foundValue as T } override fun remove() { - if (foundValue === Companion) { - throw NoSuchElementException() - } - + if (!returned) throw NoSuchElementException() (parent as MutableIterator).remove() - foundValue = Companion + returned = false } private companion object @@ -197,6 +196,10 @@ fun concatIterators(a: Iterator): MutableIterator { return a as MutableIterator } +fun concatIterators(iterators: Iterable>): MutableIterator { + return iterators.iterator().flatMap { it } +} + fun concatIterators(vararg iterators: Iterator): MutableIterator { return iterators.iterator().flatMap { it } } @@ -243,7 +246,7 @@ fun Iterator.reduce(identity: T, reducer: (T, T) -> T): T { } fun Iterator.reduce(identity: T, reducer: BinaryOperator): T = reduce(identity, reducer::apply) -fun Iterator.filterNotNull(): Iterator = filter { it != null } as Iterator +fun Iterator.filterNotNull(): MutableIterator = filter { it != null } as MutableIterator fun Iterator.any(predicate: Predicate): Boolean { for (value in this) { @@ -363,3 +366,7 @@ fun Iterator.maybe(): T? { else null } + +fun emptyIterator(): MutableIterator { + return ObjectIterators.emptyIterator() +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/WeakHashSet.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/WeakHashSet.kt index b00538f52..34c18d641 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/WeakHashSet.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/WeakHashSet.kt @@ -1,53 +1,76 @@ package ru.dbotthepony.mc.otm.core.collect -import java.util.WeakHashMap +import it.unimi.dsi.fastutil.objects.ObjectOpenCustomHashSet +import ru.dbotthepony.mc.otm.core.util.HashedWeakReference +import java.lang.ref.ReferenceQueue -/** - * Wrapper around [WeakHashMap] to behave like set - */ class WeakHashSet : MutableSet { - private val backing = WeakHashMap() + private val queue = ReferenceQueue() + private val backing = ObjectOpenCustomHashSet(ReferenceHashStrategy) + + private fun purge() { + var next = queue.poll() + + while (next != null) { + backing.remove(next) + next = queue.poll() + } + } override fun add(element: E): Boolean { - return backing.put(element, Unit) == null + purge() + if (element in backing) return false + return backing.add(HashedWeakReference(element, queue)) } override fun addAll(elements: Collection): Boolean { - return elements.count(::add) > 0 + var any = false + elements.forEach { any = add(it) || any } + return any } override fun clear() { backing.clear() + while (queue.poll() != null) {} } override fun iterator(): MutableIterator { - return backing.keys.iterator() + purge() + return backing.iterator().map { (it as HashedWeakReference).get() }.filterNotNull() } override fun remove(element: E): Boolean { - return backing.remove(element) != null + purge() + return backing.remove(element) } override fun removeAll(elements: Collection): Boolean { - return backing.keys.removeAll(elements) + purge() + return backing.removeAll(elements) } override fun retainAll(elements: Collection): Boolean { - return backing.keys.retainAll(elements) + purge() + return backing.retainAll(elements) } - override val size: Int - get() = backing.size + override val size: Int get() { + purge() + return backing.size + } override fun contains(element: E): Boolean { - return backing.get(element) === Unit + purge() + return backing.contains(element) } override fun containsAll(elements: Collection): Boolean { - return elements.all(::contains) + purge() + return backing.containsAll(elements) } override fun isEmpty(): Boolean { + purge() return backing.isEmpty() } } 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 3ed4e4750..8635e6610 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 @@ -665,7 +665,7 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe @JvmStatic fun read(buff: FriendlyByteBuf): Decimal { - return Decimal(BigInteger(buff.readByteArray())) + return Decimal(BigInteger(buff.readByteArray()), null) } /** diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/AtomicallyInvalidatedLazy.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/AtomicallyInvalidatedLazy.kt new file mode 100644 index 000000000..239f96bce --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/AtomicallyInvalidatedLazy.kt @@ -0,0 +1,42 @@ +package ru.dbotthepony.mc.otm.core.util + +import java.util.concurrent.atomic.AtomicInteger +import java.util.concurrent.locks.ReentrantLock + +class AtomicallyInvalidatedLazy(private val invalidator: AtomicInteger, private val initializer: () -> V) : Lazy { + @Volatile + private var thisCounter = -1 + @Volatile + private var stored: Any? = Companion + private val lock = ReentrantLock() + + override val value: V get() { + if (thisCounter != invalidator.get()) { + lock.lock() + this.stored = Companion + thisCounter = invalidator.get() + lock.unlock() + } + + var stored = stored + + if (stored !== Companion) + return stored as V + + lock.lock() + + try { + stored = initializer.invoke() + this.stored = stored + return stored + } finally { + lock.unlock() + } + } + + override fun isInitialized(): Boolean { + return stored !== Companion && thisCounter == invalidator.get() + } + + private companion object +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/HashedWeakReference.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/HashedWeakReference.kt new file mode 100644 index 000000000..e73cd4c45 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/HashedWeakReference.kt @@ -0,0 +1,28 @@ +package ru.dbotthepony.mc.otm.core.util + +import java.lang.ref.ReferenceQueue +import java.lang.ref.WeakReference + +/** + * [WeakReference], but with [hashCode] overridden with hash of referent object + */ +@Suppress("EqualsOrHashCode") +class HashedWeakReference : WeakReference { + constructor(value: T) : super(value) { + hash = value.hashCode() + } + + constructor(value: T, queue: ReferenceQueue) : super(value, queue) { + hash = value.hashCode() + } + + private val hash: Int + + override fun hashCode(): Int { + return hash + } + + override fun toString(): String { + return "HashedWeakReference[hash=$hash]" + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ItemInInventoryCondition.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ItemInInventoryCondition.kt index d4f088d3c..a0bf6ca5b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ItemInInventoryCondition.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ItemInInventoryCondition.kt @@ -7,7 +7,8 @@ import net.minecraft.world.level.storage.loot.LootContext import net.minecraft.world.level.storage.loot.parameters.LootContextParams import net.minecraft.world.level.storage.loot.predicates.LootItemCondition import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType -import ru.dbotthepony.mc.otm.capability.itemsStream +import ru.dbotthepony.mc.otm.capability.items +import ru.dbotthepony.mc.otm.core.collect.filter import ru.dbotthepony.mc.otm.data.Codec2Serializer import ru.dbotthepony.mc.otm.data.get import ru.dbotthepony.mc.otm.registry.MLootItemConditions @@ -19,7 +20,7 @@ data class ItemInInventoryCondition( val matchCosmetics: Boolean = true, ) : LootItemCondition, LootItemCondition.Builder { override fun test(t: LootContext): Boolean { - val matches = t[LootContextParams.LAST_DAMAGE_PLAYER]?.itemsStream(matchCosmetics)?.filter { + val matches = t[LootContextParams.LAST_DAMAGE_PLAYER]?.items(matchCosmetics)?.filter { if (it.isEmpty) { return@filter false } 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 4991374b6..d12384485 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt @@ -1,17 +1,18 @@ package ru.dbotthepony.mc.otm.item -import it.unimi.dsi.fastutil.ints.Int2ObjectFunction -import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap -import it.unimi.dsi.fastutil.ints.IntOpenHashSet +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap +import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet import net.minecraft.ChatFormatting import net.minecraft.core.Direction -import net.minecraft.nbt.ByteArrayTag import net.minecraft.nbt.CompoundTag -import net.minecraft.nbt.Tag import net.minecraft.network.FriendlyByteBuf import net.minecraft.network.chat.Component -import net.minecraft.world.item.* +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.Rarity +import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.Level +import net.minecraft.world.level.saveddata.SavedData import net.minecraftforge.client.event.ClientPlayerNetworkEvent import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities @@ -21,63 +22,140 @@ import net.minecraftforge.event.TickEvent import net.minecraftforge.event.TickEvent.ServerTickEvent import net.minecraftforge.network.NetworkEvent import net.minecraftforge.registries.ForgeRegistries -import net.minecraftforge.registries.ForgeRegistry -import ru.dbotthepony.mc.otm.* -import ru.dbotthepony.mc.otm.capability.* +import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.allItems import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.getBarColor import ru.dbotthepony.mc.otm.capability.energy.getBarWidth +import ru.dbotthepony.mc.otm.capability.isMekanismLoaded +import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper import ru.dbotthepony.mc.otm.config.EnergyBalanceValues -import ru.dbotthepony.mc.otm.core.* +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.collect.filter +import ru.dbotthepony.mc.otm.core.getID +import ru.dbotthepony.mc.otm.core.getValue +import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.getDecimal import ru.dbotthepony.mc.otm.core.math.readDecimal +import ru.dbotthepony.mc.otm.core.math.set import ru.dbotthepony.mc.otm.core.math.writeDecimal +import ru.dbotthepony.mc.otm.core.nbt.getUUIDSafe import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.core.orThrow +import ru.dbotthepony.mc.otm.core.tagNotNull import ru.dbotthepony.mc.otm.core.util.formatPower +import ru.dbotthepony.mc.otm.isClientThread +import ru.dbotthepony.mc.otm.isServerThread +import ru.dbotthepony.mc.otm.lazyPerServer import ru.dbotthepony.mc.otm.network.GenericNetworkChannel import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.packetHandled -import ru.dbotthepony.mc.otm.saveddata.SavedCountingMap +import java.util.* +import java.util.function.Function import java.util.function.Supplier +import kotlin.collections.MutableList +import kotlin.collections.component1 +import kotlin.collections.component2 +import kotlin.collections.forEach +import kotlin.collections.iterator +import kotlin.collections.set -class QuantumBatteryItem : Item { - class Data( - val parent: SavedCountingMap?, - val index: Int = -1, - energy: Decimal = Decimal.ZERO, - passed: Decimal = Decimal.ZERO, - received: Decimal = Decimal.ZERO, - ) { - constructor( - energy: Decimal = Decimal.ZERO, - passed: Decimal = Decimal.ZERO, - received: Decimal = Decimal.ZERO, - ) : this(null, -1, energy, passed, received) +class QuantumBatteryItem(val savedataID: String, val balanceValues: EnergyBalanceValues?) : Item(Properties().stacksTo(1).rarity(if (balanceValues == null) Rarity.EPIC else Rarity.UNCOMMON)) { + val isCreative = balanceValues == null - var energy: Decimal = energy - set(value) { - if (field != value) { + interface IValues { + val uuid: UUID + var energy: Decimal + var passed: Decimal + var received: Decimal + val isServer: Boolean + + fun serialize(): CompoundTag { + return CompoundTag().also { + it["energy"] = energy + it["passed"] = passed + it["received"] = received + } + } + + fun deserialize(nbt: CompoundTag) { + energy = nbt.getDecimal("energy") + passed = nbt.getDecimal("passed") + received = nbt.getDecimal("received") + } + } + + class UnboundValues(override val uuid: UUID = UUID.randomUUID()) : IValues { + override var energy: Decimal = Decimal.ZERO + override var passed: Decimal = Decimal.ZERO + override var received: Decimal = Decimal.ZERO + override val isServer: Boolean + get() = false + } + + class Data() : SavedData() { + constructor(nbt: CompoundTag) : this() { + load(nbt) + } + + inner class Values(override val uuid: UUID) : IValues { + override var energy = Decimal.ZERO + set(value) { field = value - parent?.isDirty = true + isDirty = true } + + override var passed = Decimal.ZERO + set(value) { + field = value + isDirty = true + } + + override var received = Decimal.ZERO + set(value) { + field = value + isDirty = true + } + + override val isServer: Boolean + get() = true + } + + private val data = Object2ObjectOpenHashMap() + + fun values(uuid: UUID): Values { + return data.computeIfAbsent(uuid, Function { Values(uuid) }) + } + + fun values(): Values { + return values(UUID.randomUUID()) + } + + override fun save(nbt: CompoundTag): CompoundTag { + for ((key, values) in data) { + nbt[key.toString()] = values.serialize() } - var passed: Decimal = passed - set(value) { - if (field != value) { - field = value - parent?.isDirty = true - } - } + return nbt + } - var received: Decimal = received - set(value) { - if (field != value) { - field = value - parent?.isDirty = true - } + fun load(nbt: CompoundTag) { + data.clear() + + for (key in nbt.allKeys) { + val id = UUID.fromString(key) + data[id] = Values(id).also { it.deserialize(nbt.getCompound(key)) } } + } + } + + val clientData = Object2ObjectOpenHashMap() + + val serverData: Data by lazyPerServer { + it.overworld().dataStorage.computeIfAbsent(::Data, ::Data, "otm_$savedataID") } private inner class Power(private val stack: ItemStack) : IMatteryEnergyStorage, ICapabilityProvider { @@ -87,7 +165,18 @@ class QuantumBatteryItem : Item { override val energyFlow: FlowDirection get() = FlowDirection.BI_DIRECTIONAL - var data = Data() + var values: IValues = UnboundValues() + + fun updateValues() { + if (!values.isServer && isServerThread()) { + values = serverData.values(stack.tag?.getUUIDSafe("id") ?: UUID.randomUUID().also { stack.tagNotNull["id"] = it }) + } else if (isClientThread()) { + val id = stack.tag?.getUUIDSafe("id") ?: return + + if (values.uuid != id) + values = clientData.computeIfAbsent(id, Function { UnboundValues(it) }) + } + } override fun getCapability(cap: Capability, side: Direction?): LazyOptional { if (cap == ForgeCapabilities.ENERGY || cap == MatteryCapability.ENERGY) { @@ -100,253 +189,107 @@ class QuantumBatteryItem : Item { } override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { - if (howMuch.isNegative) { + if (!howMuch.isPositive) return Decimal.ZERO - } - if (data.parent == null && isServerThread()) { - determineQuantumLink() + updateValues() - if (data.parent == null) { - return Decimal.ZERO - } - } + if (!values.isServer && !simulate) + return Decimal.ZERO - if (isCreative) { - val newEnergy = (data.energy - howMuch).moreThanZero() - val diff = data.energy - newEnergy + if (balanceValues == null) { + val newEnergy = (values.energy - howMuch).moreThanZero() + val diff = values.energy - newEnergy if (!simulate) { - data.energy = newEnergy - data.passed += diff + values.energy = newEnergy + values.passed += diff + } + + return diff + } else { + val newEnergy = (values.energy - howMuch.coerceAtMost(balanceValues.energyThroughput)).moreThanZero() + val diff = values.energy - newEnergy + + if (!simulate) { + values.energy = newEnergy + values.passed += diff } return diff } - - val newEnergy = (data.energy - howMuch.coerceAtMost(throughput!!)).moreThanZero() - val diff = data.energy - newEnergy - - if (!simulate) { - data.energy = newEnergy - data.passed += diff - } - - return diff } override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { - if (howMuch.isNegative) { + if (!howMuch.isPositive) return Decimal.ZERO - } - if (data.parent == null && isServerThread()) { - determineQuantumLink() + updateValues() - if (data.parent == null) { - return Decimal.ZERO - } - } + if (!values.isServer && !simulate) + return Decimal.ZERO - if (isCreative) { + if (balanceValues == null) { if (!simulate) { - data.energy += howMuch - data.received += howMuch + values.energy += howMuch + values.received += howMuch } return howMuch - } - - if (data.energy >= capacity!!) { + } else if (values.energy >= balanceValues.energyCapacity) { return Decimal.ZERO + } else { + val newEnergy = (values.energy + howMuch.coerceAtMost(balanceValues.energyThroughput)).coerceAtMost(balanceValues.energyCapacity) + val diff = newEnergy - values.energy + + if (!simulate) { + values.energy = newEnergy + values.received += diff + } + + return diff } - - val newEnergy = (data.energy + howMuch.coerceAtMost(throughput!!)).coerceAtMost(capacity!!) - val diff = newEnergy - data.energy - - if (!simulate) { - data.energy = newEnergy - data.received += diff - } - - return diff } override var batteryLevel: Decimal get() { - if (data.parent == null) { - determineQuantumLink() - } - - if (isClientThread()) { - return clientPowerMap[data.index]?.energy ?: data.energy - } - - return data.energy + updateValues() + return values.energy } set(value) { - if (data.parent == null) { - determineQuantumLink() - } - - if (isClientThread()) { - val energy1 = clientPowerMap[data.index] - - if (energy1 != null) { - energy1.energy = value - } else { - data.energy = value - } - - return - } - - data.energy = value + updateValues() + values.energy = value } - val passed: Decimal - get() { - if (data.parent == null) { - determineQuantumLink() - } - - if (isClientThread()) { - return clientPowerMap[data.index]?.passed ?: data.passed - } - - return data.passed + val passed: Decimal get() { + updateValues() + return values.passed } - val received: Decimal - get() { - if (data.parent == null) { - determineQuantumLink() - } - - if (isClientThread()) { - return clientPowerMap[data.index]?.received ?: data.received - } - - return data.received + val received: Decimal get() { + updateValues() + return values.received } override val maxBatteryLevel: Decimal - get() = capacity ?: (batteryLevel + Decimal.LONG_MAX_VALUE) + get() = balanceValues?.energyCapacity ?: (batteryLevel + Decimal.LONG_MAX_VALUE) override val missingPower: Decimal get() = if (isCreative) Decimal.LONG_MAX_VALUE else super.missingPower - - private fun determineQuantumLink() { - if (data.parent == null && isServerThread()) { - val existing = stack.tag?.getInt("link_id") - - if (existing == null) { - val old = data - data = saveData!!.factorize() - data.energy = old.energy - stack.tagNotNull["link_id"] = data.index - } else { - data = saveData?.computeIfAbsent(existing) ?: Data(null, existing, data.energy, data.passed, data.received) - } - } else if (!isServerThread()) { - // client ? - val existing = stack.tag?.getInt("link_id") ?: return - - if (existing != data.index) { - data = Data(data.parent, existing, data.energy, data.passed, data.received) - } - } - } - - fun determineQuantumLinkWeak() { - if (data.parent == null && isServerThread()) { - val existing = stack.tag?.getInt("link_id") - - if (existing != null) { - data = saveData?.computeIfAbsent(existing) ?: Data(null, existing, data.energy, data.passed, data.received) - } - } else if (!isServerThread()) { - val existing = stack.tag?.getInt("link_id") ?: return - - if (existing != data.index) { - data = Data(data.parent, existing, data.energy, data.passed, data.received) - } - } - } - } - - val isCreative: Boolean - - private val _capacity: () -> Decimal? - private val _throughput: () -> Decimal? - - val capacity get() = _capacity.invoke() - val throughput get() = _throughput.invoke() - - val saveDataID: String - - val saveData: SavedCountingMap? get() { - if (isServerThread()) { - return MINECRAFT_SERVER.overworld().dataStorage.computeIfAbsent({ - SavedCountingMap(Companion::storeValue, Companion::loadValue, ::Data).load(it) - }, { - SavedCountingMap(Companion::storeValue, Companion::loadValue, ::Data) - }, saveDataID) ?: throw NullPointerException("Unable to get save data for $this in ${MINECRAFT_SERVER.overworld()}") - } - - return null - } - - data class ClientData( - var energy: Decimal = Decimal.ZERO, - var passed: Decimal = Decimal.ZERO, - var received: Decimal = Decimal.ZERO, - ) - - val clientPowerMap: Int2ObjectOpenHashMap by lazy { - check(isClient) { "Invalid side" } - Int2ObjectOpenHashMap() - } - - constructor(saveDataID: String) : super(Properties().stacksTo(1).rarity(Rarity.EPIC)) { - isCreative = true - _capacity = { null } - _throughput = { null } - this.saveDataID = "otm_$saveDataID".intern() - } - - constructor(saveDataID: String, capacity: Decimal, io: Decimal) : super(Properties().stacksTo(1)) { - isCreative = false - _capacity = { capacity } - _throughput = { io } - this.saveDataID = "otm_$saveDataID".intern() - } - - constructor(saveDataID: String, values: EnergyBalanceValues) : super(Properties().stacksTo(1)) { - isCreative = false - _capacity = values::energyCapacity - _throughput = values::energyThroughput - this.saveDataID = "otm_$saveDataID".intern() } override fun isBarVisible(p_150899_: ItemStack): Boolean { - if (isCreative) - return false - + if (isCreative) return false return p_150899_.matteryEnergy != null } override fun getBarWidth(p_150900_: ItemStack): Int { - if (isCreative) - return 13 - + if (isCreative) return 13 return p_150900_.matteryEnergy?.getBarWidth() ?: super.getBarWidth(p_150900_) } override fun getBarColor(p_150901_: ItemStack): Int { - if (isCreative) - return 0 - + if (isCreative) return 0 return p_150901_.matteryEnergy?.getBarColor() ?: super.getBarColor(p_150901_) } @@ -354,29 +297,19 @@ class QuantumBatteryItem : Item { return Power(stack) } - override fun appendHoverText( - itemStack: ItemStack, - p_41422_: Level?, - components: MutableList, - p_41424_: TooltipFlag - ) { - super.appendHoverText(itemStack, p_41422_, components, p_41424_) + override fun appendHoverText(itemStack: ItemStack, level: Level?, components: MutableList, flags: TooltipFlag) { + super.appendHoverText(itemStack, level, components, flags) val power = itemStack.getCapability(MatteryCapability.ENERGY).orThrow() as Power + power.updateValues() components.add(TranslatableComponent("otm.item.quantum_description").withStyle(ChatFormatting.DARK_GRAY)) - if (isCreative) { + if (balanceValues == null) { components.add(TranslatableComponent("otm.item.quantum_battery.creative_power", power.batteryLevel.formatPower()).withStyle(ChatFormatting.GRAY)) } else { - components.add(TranslatableComponent("otm.item.power.storage", power.batteryLevel.formatPower(), capacity!!.formatPower()).withStyle(ChatFormatting.GRAY)) - - components.add( - TranslatableComponent( - "otm.item.power.throughput", - throughput!!.formatPower(), - throughput!!.formatPower() - ).withStyle(ChatFormatting.GRAY)) + components.add(TranslatableComponent("otm.item.power.storage", power.batteryLevel.formatPower(), balanceValues.energyCapacity.formatPower()).withStyle(ChatFormatting.GRAY)) + components.add(TranslatableComponent("otm.item.power.throughput_mono", balanceValues.energyThroughput.formatPower()).withStyle(ChatFormatting.GRAY)) } components.add(TranslatableComponent("otm.item.power.passed", power.passed.formatPower()).withStyle(ChatFormatting.GRAY)) @@ -387,18 +320,18 @@ class QuantumBatteryItem : Item { components.add(TranslatableComponent("otm.item.quantum_battery.creative2").withStyle(ChatFormatting.DARK_GRAY)) } - components.add(TranslatableComponent("otm.item.quantum_link_id", power.data.index).withStyle(ChatFormatting.DARK_GRAY)) + components.add(TranslatableComponent("otm.item.quantum_link_id", power.values.uuid).withStyle(ChatFormatting.DARK_GRAY)) } companion object { fun clientDisconnect(event: ClientPlayerNetworkEvent.LoggingOut) { - ForgeRegistries.ITEMS.values.stream().forEach { if (it is QuantumBatteryItem) it.clientPowerMap.clear() } + ForgeRegistries.ITEMS.values.forEach { if (it is QuantumBatteryItem) it.clientData.clear() } } fun readPacket(buff: FriendlyByteBuf): ChargePacket { return ChargePacket( - (ForgeRegistries.ITEMS as ForgeRegistry).getValue(buff.readInt()) as QuantumBatteryItem, - buff.readInt(), + ForgeRegistries.ITEMS.getValue(buff.readInt()) as QuantumBatteryItem, + buff.readUUID(), buff.readDecimal(), buff.readDecimal(), buff.readDecimal(), @@ -408,54 +341,33 @@ class QuantumBatteryItem : Item { fun tick(event: ServerTickEvent) { if (event.phase == TickEvent.Phase.END) { for (ply in event.server.playerList.players) { - val networkedChannels = IntOpenHashSet(0) + val networkedChannels = ObjectOpenHashSet(0) - for (item in ply.allItemsStream().filter { !it.isEmpty && it.item is QuantumBatteryItem }) { + for (item in ply.allItems().filter { it.isNotEmpty && it.item is QuantumBatteryItem }) { val power = item.getCapability(MatteryCapability.ENERGY).orThrow() as Power - - power.determineQuantumLinkWeak() - - if (power.data.index < 0) { - continue - } - - if (networkedChannels.add(power.data.index)) { - GenericNetworkChannel.send(ply, ChargePacket(item.item as QuantumBatteryItem, power.data.index, power.batteryLevel, power.data.passed, power.data.received)) + power.updateValues() + if (power.values.isServer && networkedChannels.add(power.values.uuid)) { + GenericNetworkChannel.send(ply, ChargePacket(item.item as QuantumBatteryItem, power.values.uuid, power.batteryLevel, power.passed, power.received)) } } } } } - - private fun loadValue(parent: SavedCountingMap, tag: Tag, index: Int): Data { - if (tag is ByteArrayTag) { - return Data(parent, index, Decimal.deserializeNBT(tag)) - } else if (tag is CompoundTag) { - return Data(parent, index, Decimal.deserializeNBT(tag["energy"]), Decimal.deserializeNBT(tag["passed"]), Decimal.deserializeNBT(tag["received"])) - } else { - return Data(parent, index) - } - } - - private fun storeValue(parent: SavedCountingMap, value: Data, index: Int): CompoundTag { - return CompoundTag().also { - it["energy"] = value.energy.serializeNBT() - it["passed"] = value.passed.serializeNBT() - it["received"] = value.received.serializeNBT() - } - } } class ChargePacket( val type: QuantumBatteryItem, - val channel: Int, - val energy: Decimal, - val passed: Decimal, - val received: Decimal, - ) : MatteryPacket { + override val uuid: UUID, + override var energy: Decimal, + override var passed: Decimal, + override var received: Decimal, + ) : MatteryPacket, IValues { + override val isServer: Boolean + get() = false + override fun write(buff: FriendlyByteBuf) { - buff.writeInt((ForgeRegistries.ITEMS as ForgeRegistry).getID(type)) - buff.writeInt(channel) + buff.writeInt(ForgeRegistries.ITEMS.getID(type)) + buff.writeUUID(uuid) buff.writeDecimal(energy) buff.writeDecimal(passed) buff.writeDecimal(received) @@ -463,7 +375,7 @@ class QuantumBatteryItem : Item { override fun play(context: Supplier) { context.packetHandled = true - val data = type.clientPowerMap.computeIfAbsent(channel, Int2ObjectFunction { ClientData() }) + val data = type.clientData.computeIfAbsent(uuid, Function { UnboundValues(it) }) data.energy = energy data.passed = passed data.received = received 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 8c004d6c5..42e6ab499 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -351,7 +351,7 @@ object MItems { val QUANTUM_BATTERY: QuantumBatteryItem by registry.register(MNames.QUANTUM_BATTERY) { QuantumBatteryItem(MNames.QUANTUM_BATTERY, ItemsConfig.Batteries.QUANTUM_BATTERY) } val QUANTUM_CAPACITOR: QuantumBatteryItem by registry.register(MNames.QUANTUM_CAPACITOR) { QuantumBatteryItem(MNames.QUANTUM_CAPACITOR, ItemsConfig.Batteries.QUANTUM_CAPACITOR) } - val QUANTUM_BATTERY_CREATIVE: QuantumBatteryItem by registry.register(MNames.QUANTUM_BATTERY_CREATIVE) { QuantumBatteryItem(MNames.QUANTUM_BATTERY_CREATIVE) } + val QUANTUM_BATTERY_CREATIVE: QuantumBatteryItem by registry.register(MNames.QUANTUM_BATTERY_CREATIVE) { QuantumBatteryItem(MNames.QUANTUM_BATTERY_CREATIVE, null) } val ZPM_BATTERY: ZPMItem by registry.register(MNames.ZPM_BATTERY) { ZPMItem() } val PROCEDURAL_BATTERY: ProceduralBatteryItem by registry.register(MNames.PROCEDURAL_BATTERY) { ProceduralBatteryItem() } From 4430fdcb6b813719f296b94d6a137306a1a68989 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 16 Aug 2023 19:39:12 +0700 Subject: [PATCH 0970/1199] Don't use own thread for drive syncing to disk, use Minecraft's background executor instead --- .../mc/otm/OverdriveThatMatters.java | 2 - .../mc/otm/capability/drive/DrivePool.kt | 55 ++----------------- .../otm/item/PortableCondensationDriveItem.kt | 4 +- 3 files changed, 7 insertions(+), 54 deletions(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 0dbfa6ced..218eef4db 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -142,8 +142,6 @@ public final class OverdriveThatMatters { } private void setup(final FMLCommonSetupEvent event) { - EVENT_BUS.addListener(EventPriority.HIGHEST, DrivePool.INSTANCE::serverStopEvent); - EVENT_BUS.addListener(EventPriority.LOWEST, DrivePool.INSTANCE::serverStartEvent); EVENT_BUS.addListener(EventPriority.NORMAL, DrivePool.INSTANCE::onWorldSave); EVENT_BUS.addListener(EventPriority.HIGHEST, GlobalEventHandlerKt::onServerStopped); diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/DrivePool.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/DrivePool.kt index 2909d1951..9794484b9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/DrivePool.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/DrivePool.kt @@ -6,6 +6,7 @@ import net.minecraft.ReportedException import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.NbtIo import net.minecraft.CrashReport +import net.minecraft.Util import net.minecraft.world.level.storage.LevelResource import java.util.concurrent.locks.LockSupport import net.minecraftforge.event.server.ServerAboutToStartEvent @@ -14,6 +15,7 @@ import net.minecraftforge.event.level.LevelEvent import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.NULLABLE_MINECRAFT_SERVER import ru.dbotthepony.mc.otm.SERVER_IS_LIVE +import ru.dbotthepony.mc.otm.isServerThread import java.io.File import java.lang.ref.WeakReference import java.util.ArrayList @@ -61,14 +63,10 @@ object DrivePool { private val resource = LevelResource("otm_drives") private val LOGGER = LogManager.getLogger() private val pool = Object2ObjectOpenHashMap() - private var thread: Thread? = null - private var stopping = false private val backlog = ConcurrentLinkedQueue() private var knownBaseDirectory: File? = null - private var serverThread: Thread? = null - private val baseDirectory: File? get() { val server = NULLABLE_MINECRAFT_SERVER ?: return null @@ -83,7 +81,7 @@ object DrivePool { } operator fun > get(id: UUID, deserializer: (CompoundTag) -> T, factory: () -> T): T { - if (!isLegalAccess()) + if (!isServerThread()) throw IllegalAccessException("Can not access drive pool from outside of server thread.") if (!SERVER_IS_LIVE) @@ -115,47 +113,11 @@ object DrivePool { } fun markDirty(id: UUID) { - if (isLegalAccess()) { + if (isServerThread()) { pool[id]?.access() } } - /** - * Returns whenever running on server thread. Calling [get], [put] or [markDirty] will throw an exception if this returns false. - * - * If you are making your own drive for your own storage stack, feed code outside of server thread (e.g. client code) dummy disk. - */ - fun isLegalAccess(): Boolean { - return serverThread != null && Thread.currentThread() === serverThread - } - - fun serverStartEvent(event: ServerAboutToStartEvent) { - if (thread?.isAlive == true) { - LOGGER.error("FMLServerStartedEvent fired twice.") - LOGGER.error("Attempting to start another DrivePool I/O thread when already running one!") - return - } - - pool.clear() - serverThread = Thread.currentThread() - - stopping = false - thread = Thread(null, this::run, "Overdrive That Matters DrivePool IO").also { it.start() } - } - - fun serverStopEvent(event: ServerStoppingEvent) { - val thread = thread - - if (thread != null && thread.isAlive) { - stopping = true - LockSupport.unpark(thread) - } - - writeBacklog() - sync() - pool.clear() - } - fun onWorldSave(event: LevelEvent.Save) { writeBacklog() } @@ -185,14 +147,7 @@ object DrivePool { } if (needsSync) { - LockSupport.unpark(thread) - } - } - - private fun run() { - while (!stopping) { - sync() - LockSupport.park() + Util.backgroundExecutor().execute(::sync) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableCondensationDriveItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableCondensationDriveItem.kt index 74e64c601..5a36f6891 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableCondensationDriveItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PortableCondensationDriveItem.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.item -import ru.dbotthepony.mc.otm.capability.drive.DrivePool.isLegalAccess import net.minecraft.world.item.ItemStack import net.minecraftforge.common.capabilities.ICapabilityProvider import net.minecraftforge.common.util.LazyOptional @@ -24,6 +23,7 @@ import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.tagNotNull +import ru.dbotthepony.mc.otm.isServerThread import java.math.BigInteger import java.util.* @@ -35,7 +35,7 @@ class PortableCondensationDriveItem(capacity: Int) : private var uuid: UUID? = null private val resolver = LazyOptional.of> { - if (!isLegalAccess()) { + if (!isServerThread()) { return@of ItemMatteryDrive.DUMMY } From 3b6bac1a837528cfe4412baf28f680fc0741a6d3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 16 Aug 2023 20:52:12 +0700 Subject: [PATCH 0971/1199] Follow quickmove slot priorities of vanilla --- .../mc/otm/menu/ExopackInventoryMenu.kt | 4 +-- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 30 +++++-------------- 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt index 6e88d8814..6fbbdb32c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt @@ -195,11 +195,11 @@ class ExopackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen if (slotIndex == craftingResultSlot.index) { val item = craftingResultSlot.item - val leftover = moveItemStackToSlots(item, playerInventorySlots2, simulate = true) + val leftover = moveItemStackToSlots(item, playerInventorySlots, simulate = true) if (leftover.isEmpty) { val copy = item.copy() - moveItemStackToSlots(item, playerInventorySlots2, simulate = false) + moveItemStackToSlots(item, playerInventorySlots, simulate = false) item.count = 0 craftingResultSlot.onTake(ply, copy) return copy diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 99dffd41f..da8c260f3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -104,7 +104,6 @@ abstract class MatteryMenu( val ply: Player get() = inventory.player private val _playerInventorySlots = ArrayList() - private val _playerInventorySlots2 = ArrayList() private val _playerHotbarSlots = ArrayList() private val _playerMainSlots = ArrayList() private val _playerExoSuitSlots = ArrayList() @@ -189,15 +188,10 @@ abstract class MatteryMenu( fun stringInput(allowSpectators: Boolean = false, handler: (String) -> Unit) = PlayerInput(BinaryStringCodec, allowSpectators, handler) fun intInput(allowSpectators: Boolean = false, handler: (Int) -> Unit) = PlayerInput(VarIntValueCodec, allowSpectators, handler) - /** - * inventory + exosuit + hotbar (in this order) - */ - val playerInventorySlots: List = Collections.unmodifiableList(_playerInventorySlots) - /** * hotbar + inventory + exosuit (in this order) */ - val playerInventorySlots2: List = Collections.unmodifiableList(_playerInventorySlots2) + val playerInventorySlots: List = Collections.unmodifiableList(_playerInventorySlots) /** * hotbar only @@ -368,13 +362,16 @@ abstract class MatteryMenu( mapQuickMoveToInventory(offhandSlot!!) addSlot(offhandSlot!!) - for (i in 9 .. 35) { + for (i in 0 .. 35) { val slot = InventorySlot(inventory, i) _playerInventorySlots.add(slot) - _playerInventorySlots2.add(slot) _playerMainSlots.add(slot) - _playerCombinedInventorySlots.add(slot) + + if (i <= 8) + _playerHotbarSlots.add(slot) + else + _playerCombinedInventorySlots.add(slot) mapQuickMove(slot, equipmentSlots) mapQuickMoveToExternal(slot) @@ -388,7 +385,6 @@ abstract class MatteryMenu( val slot = InventorySlot(mattery.exopackContainer, i) _playerInventorySlots.add(slot) - _playerInventorySlots2.add(slot) _playerExoSuitSlots.add(slot) _playerCombinedInventorySlots.add(slot) @@ -404,18 +400,6 @@ abstract class MatteryMenu( exopackPowerLevel.with(mattery.exopackEnergy) } - - for (i in 0..8) { - val slot = InventorySlot(inventory, i) - - _playerInventorySlots2.add(i, slot) - _playerInventorySlots.add(slot) - _playerHotbarSlots.add(slot) - - mapQuickMove(slot, equipmentSlots) - mapQuickMoveToExternal(slot) - addSlot(slot) - } } private var broadcastOnce = false From 10de6eb864d2b52933637f3096110b2de71279d8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 16 Aug 2023 23:44:21 +0700 Subject: [PATCH 0972/1199] Remove flex grid panel since it is no longer utilized, and is flawed in its current state --- .../client/screen/panels/FlexGridPanel.java | 191 ------------------ .../otm/client/screen/panels/EditablePanel.kt | 12 -- 2 files changed, 203 deletions(-) delete mode 100644 src/main/java/ru/dbotthepony/mc/otm/client/screen/panels/FlexGridPanel.java diff --git a/src/main/java/ru/dbotthepony/mc/otm/client/screen/panels/FlexGridPanel.java b/src/main/java/ru/dbotthepony/mc/otm/client/screen/panels/FlexGridPanel.java deleted file mode 100644 index 9c5b42457..000000000 --- a/src/main/java/ru/dbotthepony/mc/otm/client/screen/panels/FlexGridPanel.java +++ /dev/null @@ -1,191 +0,0 @@ -package ru.dbotthepony.mc.otm.client.screen.panels; - -import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; -import ru.dbotthepony.mc.otm.client.screen.MatteryScreen; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public class FlexGridPanel extends EditablePanel { - public enum FlexAlign { - TOP_LEFT, - TOP_CENTER, - TOP_RIGHT, - - MIDDLE_LEFT, - MIDDLE_CENTER, - MIDDLE_RIGHT, - - BOTTOM_LEFT, - BOTTOM_CENTER, - BOTTOM_RIGHT - } - - protected FlexAlign align = FlexAlign.MIDDLE_CENTER; - public int panels_per_row = 1; - - public FlexGridPanel(@Nonnull S screen, @Nullable EditablePanel parent, float x, float y, float width, float height) { - super(screen, parent, x, y, width, height); - } - - public FlexGridPanel(@Nonnull S screen, @Nullable EditablePanel parent, float x, float y) { - super(screen, parent, x, y); - } - - public FlexGridPanel(@Nonnull S screen, @Nullable EditablePanel parent) { - super(screen, parent); - } - - public FlexAlign getAlign() { - return align; - } - - public FlexGridPanel setAlign(FlexAlign align) { - this.align = align; - return this; - } - - @Override - public void performLayout() { - if (align == FlexAlign.MIDDLE_CENTER) { - // список потомков - var children = getUndockedVisibleChildren(); - - if (children.size() == 0) { - return; - } - - // хранит общую ширину всех потомков в ряд - // а так же ограничитель ширины ряда после - // определения количества рядов - float desired_width = 0; - - // минимально допустимая ширина одного ряда - float min_width = getWidth(); - - // "финальная" ширина этой панели - float this_width = getWidth() - getDockPadding().getLeft() - getDockPadding().getRight(); - - if (this_width <= 0) { - return; - } - - for (var child : children) { - min_width = Math.min(min_width, child.getWidth() + child.getDockMargin().getLeft() + child.getDockMargin().getRight()); - desired_width += child.getWidth() + child.getDockMargin().getLeft() + child.getDockMargin().getRight(); - } - - int rows = 1; - - // если общая ширина больше чем ширина панели, делим пополам пока не найдем нужную ширину и количество рядов - while (desired_width > this_width && desired_width > min_width) { - desired_width /= 2; - rows++; - } - - if (desired_width < min_width) { - desired_width = min_width; - } - - int index; - - // определение высоты всех рядов вместе - float total_height = 0; - - // утютю никаких goto - // зато код чище некуда! - while (desired_width <= this_width) { - index = 0; - total_height = 0; - - panels_per_row = 0; - boolean calculate_row_width = true; - - for (int row = 0; row < rows; row++) { - float max_height = 0; - float total_width = 0; - - for (int i = index; i < children.size(); i++) { - var child = children.get(i); - var gain_width = child.getWidth() + child.getDockMargin().getLeft() + child.getDockMargin().getRight(); - - index = i; - - if (gain_width + total_width > desired_width) { - if (calculate_row_width) { - panels_per_row = i + 1; - calculate_row_width = false; - } - - break; - } - - max_height = Math.max(max_height, child.getHeight() + child.getDockMargin().getTop() + child.getDockMargin().getBottom()); - total_width += gain_width; - } - - total_height += max_height; - } - - if (index + 1 < children.size() && desired_width != this_width) { - // не все панели уместились. ну чтож - desired_width = Math.min(desired_width + min_width, this_width); - } else { - break; - } - } - - index = 0; - - // ширину на середину для позиционирования по центру - this_width /= 2; - - // определение точки по середине по высоте - float h_middle = (getHeight() - getDockPadding().getBottom() - getDockPadding().getTop() - total_height) / 2; - - // OverdriveThatMatters.LOGGER.info("Общая высота {}, рядов {}, середина {}", total_height, rows, h_middle); - - for (int row = 0; row < rows; row++) { - float max_height = 0; - float total_width = 0; - - int until = index; - - for (int i = index; i < children.size(); i++) { - var child = children.get(i); - var gain_width = child.getWidth() + child.getDockMargin().getLeft() + child.getDockMargin().getRight(); - - until = i; - - if (gain_width + total_width > desired_width) { - break; - } - - max_height = Math.max(max_height, child.getHeight() + child.getDockMargin().getTop() + child.getDockMargin().getBottom()); - total_width += gain_width; - } - - total_width /= 2; - max_height /= 2; - - // OverdriveThatMatters.LOGGER.info("Ряд {}, общая ширина {}, максимальная высота {}, позиция {}, c {} до {}", row, total_width * 2, max_height * 2, h_middle, index, until); - - float accumulate_width = 0; - - for (int i = index; i <= until; i++) { - var child = children.get(i); - - child.setPos((int) (this_width - total_width + accumulate_width + child.getDockMargin().getLeft()), (int) (h_middle + max_height - child.getHeight() / 2)); - accumulate_width += child.getWidth() + child.getDockMargin().getLeft() + child.getDockMargin().getRight(); - } - - h_middle += max_height * 2; - - index = until; - } - } - - super.performLayout(); - } -} 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 e8207d83c..55fbb498d 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 @@ -1777,18 +1777,6 @@ open class EditablePanel @JvmOverloads constructor( } } - fun asGrid(): FlexGridPanel<*> { - val grid = FlexGridPanel(screen, parent, x, y, width, height) - parent = grid - grid.dock = dock - dock = Dock.NONE - grid.dockPadding = dockPadding - grid.dockMargin = dockMargin - setDockPadding(0f, 0f, 0f, 0f) - setDockMargin(0f, 0f, 0f, 0f) - return grid - } - fun mouseToCenter() { moveMousePosScaled(absoluteX + width / 2f, absoluteY + height / 2f) } From a6eb0ca7f182d3474730b4c126c5cf3ad6223104 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 17 Aug 2023 00:23:36 +0700 Subject: [PATCH 0973/1199] Drive rack insert/extract controls, profiled energy, updated menu, make redstone control of drive rack actually do stuff --- .../entity/storage/DriveRackBlockEntity.kt | 22 +++++++-- .../client/screen/panels/button/Buttons.kt | 32 +++++++++++-- .../client/screen/panels/util/GridPanel.kt | 8 +++- .../client/screen/storage/DriveRackScreen.kt | 38 ++++++++++++--- .../client/screen/storage/StorageBusScreen.kt | 9 +--- .../mc/otm/graph/storage/StorageNode.kt | 19 +++++++- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 4 ++ .../mc/otm/menu/storage/DriveRackMenu.kt | 26 +++++----- .../storage/optics/FlowControlComponent.kt | 47 +++++++++++++++++++ .../mc/otm/storage/optics/Optics.kt | 9 ++++ 10 files changed, 178 insertions(+), 36 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/FlowControlComponent.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt index 4b405990f..8e6c5f6d2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt @@ -8,8 +8,10 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity +import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.graph.storage.StorageNode import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.container.MatteryContainer @@ -18,10 +20,12 @@ import ru.dbotthepony.mc.otm.menu.storage.DriveRackMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.storage.optics.priority import ru.dbotthepony.mc.otm.storage.optics.powered +import ru.dbotthepony.mc.otm.storage.optics.flow class DriveRackBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.DRIVE_RACK, blockPos, blockState) { - val energy = WorkerEnergyStorage(this::setChangedLight, MachinesConfig.DRIVE_RACK) + val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::setChangedLight, MachinesConfig.DRIVE_RACK)) val cell = StorageNode(energy) + val energyConfig = ConfigurableEnergy(energy) var insertPriority = 0 set(value) { @@ -35,16 +39,22 @@ class DriveRackBlockEntity(blockPos: BlockPos, blockState: BlockState) : Mattery setChangedLight() } + var mode = FlowDirection.BI_DIRECTIONAL + set(value) { + field = value + setChangedLight() + } + val container: MatteryContainer = object : MatteryContainer(this::setChanged, 4) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { super.setChanged(slot, new, old) old.getCapability(MatteryCapability.DRIVE).ifPresentK { - cell.removeStorageComponent(it.priority(::insertPriority, ::extractPriority).powered(energy)) + cell.removeStorageComponent(it.priority(::insertPriority, ::extractPriority).powered(energy).flow(::mode)) } new.getCapability(MatteryCapability.DRIVE).ifPresentK { - cell.addStorageComponent(it.priority(::insertPriority, ::extractPriority).powered(energy)) + cell.addStorageComponent(it.priority(::insertPriority, ::extractPriority).powered(energy).flow(::mode)) } } }.also(::addDroppableContainer) @@ -52,10 +62,14 @@ class DriveRackBlockEntity(blockPos: BlockPos, blockState: BlockState) : Mattery init { savetable(::energy, ENERGY_KEY) savetable(::container, INVENTORY_KEY) - exposeEnergyGlobally(energy) exposeGlobally(MatteryCapability.STORAGE_NODE, cell) savetables.int(::insertPriority) savetables.int(::extractPriority) + savetables.enum(::mode, map = FlowDirection::valueOf) + + redstoneControl.addListener { + cell.isDetached = it + } } override fun setLevel(level: Level) { 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 3d18a1491..4bc9763ea 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 @@ -28,6 +28,7 @@ import ru.dbotthepony.mc.otm.config.ClientConfig import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.core.util.ItemSorter import ru.dbotthepony.mc.otm.core.value @@ -342,6 +343,17 @@ class DeviceControls>( return button } + fun addStorageMode(prop: GetterSetter) { + val mode = LargeEnumRectangleButtonPanel(screen, this, prop = prop, defaultValue = FlowDirection.BI_DIRECTIONAL, enum = FlowDirection::class.java) + + mode.add(FlowDirection.INPUT, Widgets18.ONLY_STORE, FlowDirection.INPUT.title) + mode.add(FlowDirection.OUTPUT, Widgets18.ONLY_EXTRACT, FlowDirection.OUTPUT.title) + mode.add(FlowDirection.BI_DIRECTIONAL, Widgets18.STORE_EXTRACT, FlowDirection.BI_DIRECTIONAL.title) + mode.finish() + + addButton(mode) + } + inline fun > sortingButtons(ascending: GetterSetter, sorting: GetterSetter, default: T, configurator: LargeEnumRectangleButtonPanel.() -> Unit) { LargeBooleanRectangleButtonPanel( screen, @@ -415,18 +427,19 @@ class DeviceControls>( upgradeWindow!!.toScreenCenter() upgradeWindow!!.popup() } else { - val square = ceil(upgrades.slots.size.toDouble().pow(0.5)).toInt() - val size = square * AbstractSlotPanel.SIZE + val (columns, rows) = SPECIAL_UPGRADE_CASES.getOrElse(upgrades.slots.size - 1) { + val square = ceil(it.toDouble().pow(0.5)).toInt() + square to square + } - upgradeWindow = FramePanel(screen, (size + 40f).coerceAtLeast(120f), 30f + size, TranslatableComponent("otm.gui.upgrades")).also { frame -> - val grid = GridPanel(screen, frame, width = AbstractSlotPanel.SIZE * square, height = AbstractSlotPanel.SIZE * square, columns = square, rows = square) + upgradeWindow = FramePanel(screen, (columns * AbstractSlotPanel.SIZE + 40f).coerceAtLeast(120f), 30f + rows * AbstractSlotPanel.SIZE, TranslatableComponent("otm.gui.upgrades")).also { frame -> + val grid = GridPanel(screen, frame, columns = columns, rows = rows) for (slot in upgrades.slots) { SlotPanel(screen, grid, slot) } grid.dock = Dock.FILL - grid.dockResize = DockResizeMode.NONE screen.addPanel(frame) @@ -524,6 +537,15 @@ class DeviceControls>( x = (parent?.width ?: 0f) + 3f y = 0f } + + companion object { + val SPECIAL_UPGRADE_CASES = immutableList { + accept(1 to 1) + accept(2 to 1) + accept(3 to 1) + accept(2 to 2) + } + } } fun > makeDeviceControls( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/GridPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/GridPanel.kt index 782189a60..55a550420 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/GridPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/GridPanel.kt @@ -4,8 +4,8 @@ import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.core.collect.filter -import ru.dbotthepony.mc.otm.core.collect.map import ru.dbotthepony.mc.otm.core.collect.maybe open class GridPanel( @@ -80,4 +80,10 @@ open class GridPanel( totalHeight += maxHeight } } + + companion object { + fun slots(screen: S, parent: EditablePanel<*>?, columns: Int, rows: Int): GridPanel { + return GridPanel(screen, parent, width = columns * AbstractSlotPanel.SIZE, height = rows * AbstractSlotPanel.SIZE, rows = rows, columns = columns) + } + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/DriveRackScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/DriveRackScreen.kt index 171e9725c..a153f8e41 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/DriveRackScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/DriveRackScreen.kt @@ -3,11 +3,21 @@ package ru.dbotthepony.mc.otm.client.screen.storage import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.menu.storage.DriveRackMenu import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.Dock +import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.DeviceControls +import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeEnumRectangleButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.input.IntInputPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel +import ru.dbotthepony.mc.otm.core.TranslatableComponent class DriveRackScreen(menu: DriveRackMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { @@ -15,14 +25,30 @@ class DriveRackScreen(menu: DriveRackMenu, inventory: Inventory, title: Componen override fun makeMainFrame(): FramePanel> { val frame = super.makeMainFrame()!! - WidePowerGaugePanel(this, frame, menu.energyWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) - BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) + makeBars(frame, profiledEnergy = menu.profiledEnergy, batterySlot = menu.batterySlot) - SlotPanel(this, frame, menu.storageSlots[0], 71f, 32f) - SlotPanel(this, frame, menu.storageSlots[1], 71f + 18f, 32f) + val grid = GridPanel.slots(this, frame, 2, 2) + grid.dock = Dock.FILL - SlotPanel(this, frame, menu.storageSlots[2], 71f, 32f + 18f) - SlotPanel(this, frame, menu.storageSlots[3], 71f + 18f, 32f + 18f) + for (slot in menu.storageSlots) + SlotPanel(this, grid, slot) + + IntInputPanel(this, frame, menu.insertPriority).also { + it.dock = Dock.BOTTOM + it.tooltips.add(TranslatableComponent("otm.gui.insert_priority")) + it.childrenOrder = -1 + it.dockMargin = DockProperty(left = 20f, right = 10f, bottom = 2f) + } + + IntInputPanel(this, frame, menu.extractPriority).also { + it.dock = Dock.BOTTOM + it.tooltips.add(TranslatableComponent("otm.gui.extract_priority")) + it.childrenOrder = -2 + it.dockMargin = DockProperty(left = 20f, right = 10f, bottom = 2f) + } + + val controls = DeviceControls(this, frame, energyConfig = menu.energyConfig, redstoneConfig = menu.redstoneConfig) + controls.addStorageMode(menu.mode) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt index 9097f7aba..c504cb6a1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/StorageBusScreen.kt @@ -52,14 +52,7 @@ class StorageBusScreen(menu: StorageBusMenu, inventory: Inventory, title: Compon } val controls = DeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig) - val mode = LargeEnumRectangleButtonPanel(this, frame, prop = menu.mode, defaultValue = FlowDirection.BI_DIRECTIONAL, enum = FlowDirection::class.java) - - mode.add(FlowDirection.INPUT, Widgets18.ONLY_STORE, FlowDirection.INPUT.title) - mode.add(FlowDirection.OUTPUT, Widgets18.ONLY_EXTRACT, FlowDirection.OUTPUT.title) - mode.add(FlowDirection.BI_DIRECTIONAL, Widgets18.STORE_EXTRACT, FlowDirection.BI_DIRECTIONAL.title) - mode.finish() - - controls.addButton(mode) + controls.addStorageMode(menu.mode) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNode.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNode.kt index d00cf71db..a176a192c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNode.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/storage/StorageNode.kt @@ -77,7 +77,7 @@ open class StorageNode(private val energyDemander: IMatteryEnergyStorage? = null fun addStorageComponent(component: IStorage<*>) { if (components.add(component)) - if (isValid && !manualAttaching) + if (isValid && !manualAttaching && !isDetached) graph.add(component) } @@ -86,6 +86,23 @@ open class StorageNode(private val energyDemander: IMatteryEnergyStorage? = null graph.remove(component) } + var isDetached = false + set(value) { + if (field != value) { + field = value + + if (value) { + for (component in components) { + graph.remove(component) + } + } else if (!manualAttaching) { + for (component in components) { + graph.add(component) + } + } + } + } + override fun invalidate() { for (component in components) { graph.remove(component) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index da8c260f3..5c20fd3fe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -485,6 +485,10 @@ abstract class MatteryMenu( return super.addSlot(pSlot) } + fun addSlot(slots: Iterable) { + slots.forEach(::addSlot) + } + /** * Adds slot to "storage slots" list (utilized by quick move) and calls [addSlot] * diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveRackMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveRackMenu.kt index 580b7512f..4b46e738c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveRackMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveRackMenu.kt @@ -2,27 +2,31 @@ package ru.dbotthepony.mc.otm.menu.storage import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory -import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.block.entity.storage.DriveRackBlockEntity +import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.menu.DriveSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu -import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput +import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.IntInputWithFeedback +import ru.dbotthepony.mc.otm.menu.makeSlots +import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus class DriveRackMenu @JvmOverloads constructor( - p_38852_: Int, + containerId: Int, inventory: Inventory, tile: DriveRackBlockEntity? = null -) : MatteryPoweredMenu(MMenus.DRIVE_RACK, p_38852_, inventory, tile) { - val storageSlots: List +) : MatteryPoweredMenu(MMenus.DRIVE_RACK, containerId, inventory, tile) { + val storageSlots = makeSlots(tile?.container ?: SimpleContainer(4), ::DriveSlot) + val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) + val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) + val insertPriority = IntInputWithFeedback(this, tile?.let { it::insertPriority }) + val extractPriority = IntInputWithFeedback(this, tile?.let { it::extractPriority }) + val mode = EnumInputWithFeedback(this, tile?.let { it::mode }, FlowDirection.WITHOUT_NONE) init { - val container = tile?.container ?: SimpleContainer(4) - - storageSlots = immutableList(4) { - addStorageSlot(DriveSlot(container, it)) - } - + addStorageSlot(storageSlots) addInventorySlots() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/FlowControlComponent.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/FlowControlComponent.kt new file mode 100644 index 000000000..e5105985b --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/FlowControlComponent.kt @@ -0,0 +1,47 @@ +package ru.dbotthepony.mc.otm.storage.optics + +import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.storage.IStorageComponent +import ru.dbotthepony.mc.otm.storage.IStorageEventConsumer +import ru.dbotthepony.mc.otm.storage.StorageStack +import java.math.BigInteger +import java.util.* +import java.util.function.Supplier + +class FlowControlComponent>(private val parent: IStorageComponent, private val flow: Supplier) : IStorageComponent by parent { + override fun addListener(listener: IStorageEventConsumer): Boolean { + return parent.addListener(ListenerProxy(listener, this)) + } + + override fun removeListener(listener: IStorageEventConsumer): Boolean { + return parent.removeListener(ListenerProxy(listener, this)) + } + + override fun insertStack(stack: S, simulate: Boolean): S { + if (!flow.get().input) { + return storageType.empty + } + + return parent.insertStack(stack, simulate) + } + + override fun extractStack(id: UUID, amount: BigInteger, simulate: Boolean): S { + if (!flow.get().output) { + return storageType.empty + } + + return parent.extractStack(id, amount, simulate) + } + + override fun equals(other: Any?): Boolean { + return other is FlowControlComponent<*> && parent == other.parent + } + + override fun hashCode(): Int { + return parent.hashCode() + } + + override fun toString(): String { + return "FlowControlComponent[flow=${flow.get()}, $parent]" + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/Optics.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/Optics.kt index b76371daf..ad5811e35 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/Optics.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/optics/Optics.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.storage.optics +import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.storage.IStorageAcceptor import ru.dbotthepony.mc.otm.storage.IStorageComponent @@ -76,3 +77,11 @@ fun > IVirtualStorageComponent.powered(energy: Supplier> IVirtualStorageComponent.powered(energy: IMatteryEnergyStorage): IVirtualStorageComponent { return PoweredVirtualComponent(this) { energy } } + +fun > IStorageComponent.flow(flow: Supplier): IStorageComponent { + return FlowControlComponent(this, flow) +} + +fun > IStorageComponent.flow(flow: FlowDirection): IStorageComponent { + return FlowControlComponent(this) { flow } +} From 90348d5789a906c40487b44cc8a722cbc595aa18 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 17 Aug 2023 12:16:59 +0700 Subject: [PATCH 0974/1199] idling machines are now faster than ever Rotate faaaster banan-a --- .../mc/otm/block/entity/MatteryBlockEntity.kt | 15 +++- .../block/entity/MatteryDeviceBlockEntity.kt | 40 ++++++---- .../block/entity/MatteryPoweredBlockEntity.kt | 10 ++- .../block/entity/MatteryWorkerBlockEntity.kt | 44 +++++++--- .../entity/decorative/FluidTankBlockEntity.kt | 8 +- .../entity/decorative/PainterBlockEntity.kt | 4 +- .../entity/matter/MatterBottlerBlockEntity.kt | 10 +-- .../matter/MatterCapacitorBankBlockEntity.kt | 2 +- .../matter/MatterDecomposerBlockEntity.kt | 10 +-- .../matter/MatterReconstructorBlockEntity.kt | 6 +- .../matter/MatterRecyclerBlockEntity.kt | 2 +- .../matter/MatterReplicatorBlockEntity.kt | 4 +- .../entity/matter/MatterScannerBlockEntity.kt | 4 +- .../entity/storage/DriveRackBlockEntity.kt | 8 +- .../entity/storage/DriveViewerBlockEntity.kt | 10 +-- .../entity/storage/ItemMonitorBlockEntity.kt | 5 +- .../entity/storage/StorageBusBlockEntity.kt | 10 +-- .../block/entity/storage/StorageInterfaces.kt | 6 +- .../StoragePowerSupplierBlockEntity.kt | 2 +- .../entity/tech/AndroidChargerBlockEntity.kt | 2 +- .../entity/tech/AndroidStationBlockEntity.kt | 2 +- .../entity/tech/BatteryBankBlockEntity.kt | 2 +- .../tech/ChemicalGeneratorBlockEntity.kt | 16 ++-- .../entity/tech/EnergyServoBlockEntity.kt | 4 +- .../entity/tech/EssenceStorageBlockEntity.kt | 6 +- .../entity/tech/PlatePressBlockEntity.kt | 11 ++- .../entity/tech/PoweredFurnaceBlockEntity.kt | 4 +- .../otm/capability/AbstractProfiledStorage.kt | 24 ++++-- .../core/util/AtomicallyInvalidatedLazy.kt | 14 +++- .../otm/core/util/CounterInvalidatedLazy.kt | 80 +++++++++++++++++++ .../mc/otm/core/util/IntCounter.kt | 59 ++++++++++++++ .../dbotthepony/mc/otm/core/util/TickList.kt | 20 +++++ .../mc/otm/menu/MatteryPoweredMenu.kt | 3 +- 33 files changed, 331 insertions(+), 116 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/util/CounterInvalidatedLazy.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/util/IntCounter.kt 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 7c3b27a5a..5f091b914 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 @@ -54,6 +54,7 @@ import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.core.math.minus import ru.dbotthepony.mc.otm.core.math.plus +import ru.dbotthepony.mc.otm.core.util.IntCounter import ru.dbotthepony.mc.otm.core.util.Savetables import ru.dbotthepony.mc.otm.core.util.TickList import ru.dbotthepony.mc.otm.network.BlockEntitySyncPacket @@ -106,6 +107,8 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc private data class SidelessCap(val cap: T, var optional: LazyOptional) private val sidelessCaps = Reference2ObjectOpenHashMap, SidelessCap<*>>() protected val tickList = TickList() + protected val blockStateChangesCounter = IntCounter() + protected val dirtyListeners = ISubscriptable.Impl() /** * Shared savetables, written both to level storage and to item tag @@ -484,6 +487,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc @Suppress("OVERRIDE_DEPRECATION") override fun setBlockState(pBlockState: BlockState) { + blockStateChangesCounter.increment() val old = blockRotation @Suppress("DEPRECATION") super.setBlockState(pBlockState) @@ -513,14 +517,23 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } } + override fun setChanged() { + super.setChanged() + + dirtyListeners.accept(Unit) + } + // Just to mark chunk unsaved - open fun setChangedLight() { + open fun markDirtyFast() { val level = level + if (level is ServerLevel) { level.chunkSource.getChunkNow( SectionPos.blockToSectionCoord(blockPos.x), SectionPos.blockToSectionCoord(blockPos.z))?.isUnsaved = true } + + dirtyListeners.accept(Unit) } val synchronizer = FieldSynchronizer { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index 9e9b368e1..d728a45ce 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -44,7 +44,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo var customDisplayName: Component? = null override val redstoneControl: AbstractRedstoneControl = RedstoneControl { new, old -> - setChangedLight() + markDirtyFast() if (new != old) redstoneStatusUpdated(new, old) @@ -149,7 +149,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo if (access.read() != value) { access.write(value) - setChangedLight() + markDirtyFast() if (value == FlowDirection.NONE) { controller.close() @@ -166,7 +166,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo var automatePull = false set(value) { field = value - setChangedLight() + markDirtyFast() updateTickerState() } @@ -174,7 +174,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo var automatePush = false set(value) { field = value - setChangedLight() + markDirtyFast() updateTickerState() } @@ -281,6 +281,11 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo val rightDefault: FlowDirection = modesRight, val topDefault: FlowDirection = modesTop, val bottomDefault: FlowDirection = modesBottom, + + /** + * If battery level can update without calling [markDirtyFast]/[setChanged] + */ + val volatileEnergyValues: Boolean = false ) { constructor( energy: T, @@ -291,6 +296,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo rightDefault: FlowDirection = possibleModes, topDefault: FlowDirection = possibleModes, bottomDefault: FlowDirection = possibleModes, + volatileEnergyValues: Boolean = false ) : this( energy, modesFront = possibleModes, frontDefault = frontDefault, @@ -299,6 +305,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo modesRight = possibleModes, rightDefault = rightDefault, modesTop = possibleModes, topDefault = topDefault, modesBottom = possibleModes, bottomDefault = bottomDefault, + volatileEnergyValues = volatileEnergyValues, ) init { @@ -349,14 +356,18 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo private val ticker = tickList.Ticker(this) private fun updateTickerState() { - ticker.isEnabled = (automatePull || automatePush) && energyFlow != FlowDirection.NONE && !redstoneControl.isBlockedByRedstone && neighbour.get().isPresent + ticker.isEnabled = (automatePull || automatePush) && + energyFlow != FlowDirection.NONE && + !redstoneControl.isBlockedByRedstone && + neighbour.get().isPresent && + (volatileEnergyValues || energy.batteryLevel.isPositive) } // var automatePull by synchronizer.bool().property var automatePull = false set(value) { field = value - setChangedLight() + markDirtyFast() updateTickerState() } @@ -364,7 +375,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo var automatePush = false set(value) { field = value - setChangedLight() + markDirtyFast() updateTickerState() } @@ -373,6 +384,10 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo savetables.bool(::automatePull, "energy_${side}_pull") savetables.bool(::automatePush, "energy_${side}_push") + dirtyListeners.addListener { + updateTickerState() + } + tickList.once { redstoneControl.addListener { updateTickerState() @@ -417,9 +432,6 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo } override fun tick() { - if (energyFlow == FlowDirection.NONE || !automatePull && !automatePush || redstoneControl.isBlockedByRedstone) - return - neighbour.get().ifPresentK { if (energyFlow.input && automatePull) { moveEnergy(source = it, destination = energy, simulate = false) @@ -436,7 +448,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo if (access.read() != value) { access.write(value) - setChangedLight() + markDirtyFast() if (value == FlowDirection.NONE) { for (controller in capControllers) @@ -604,7 +616,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo if (access.read() != value) { access.write(value) - setChangedLight() + markDirtyFast() if (value == ItemHandlerMode.DISABLED) { capController.close() @@ -627,7 +639,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo set(value) { if (field != value) { field = value - setChangedLight() + markDirtyFast() if (value) { innerSlotPush = 0 @@ -642,7 +654,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo set(value) { if (field != value) { field = value - setChangedLight() + markDirtyFast() if (value) { innerSlotPush = 0 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt index 92045b5d8..ee7854a35 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryPoweredBlockEntity.kt @@ -12,6 +12,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.capabilities.ForgeCapabilities import ru.dbotthepony.mc.otm.capability.* +import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.ItemEnergyStorageImpl import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer @@ -21,8 +22,10 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.nbt.map abstract class MatteryPoweredBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(p_155228_, p_155229_, p_155230_) { - val batteryContainer = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) + val batteryContainer = MatteryContainer(::markDirtyFast, 1).also(::addDroppableContainer) val batteryItemHandler = batteryContainer.handler(HandlerFilter.Dischargeable) + open val energy: IMatteryEnergyStorage? + get() = null init { savetables.stateful(::batteryContainer, BATTERY_KEY) @@ -31,10 +34,9 @@ abstract class MatteryPoweredBlockEntity(p_155228_: BlockEntityType<*>, p_155229 override fun tick() { super.tick() - val energy = matteryEnergy - if (energy == null || batteryContainer.isEmpty) - return + if (batteryContainer.isEmpty) return + val energy = energy ?: return var demand = energy.receiveEnergy(energy.missingPower, true) if (demand.isZero) return diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt index 90af20413..a89abd728 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryWorkerBlockEntity.kt @@ -16,10 +16,10 @@ import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.capability.IMatteryUpgrade import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage -import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.nbt.getCompoundList import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.core.util.countingLazy /** * Simple machine, which can work on only one job type. @@ -36,7 +36,7 @@ abstract class MatteryWorkerBlockEntity( val jobEventLoops: ImmutableList> = immutableList(maxJobs) { id -> object : MachineJobEventLoop(jobCodec) { override val energy: IMatteryEnergyStorage? - get() = matteryEnergy + get() = this@MatteryWorkerBlockEntity.energy override val isBlockedByRedstone: Boolean get() = redstoneControl.isBlockedByRedstone override val upgrades: IMatteryUpgrade? @@ -55,7 +55,7 @@ abstract class MatteryWorkerBlockEntity( } override fun onJobTick(status: JobStatus) { - super@MatteryWorkerBlockEntity.setChangedLight() + super@MatteryWorkerBlockEntity.markDirtyFast() return this@MatteryWorkerBlockEntity.onJobTick(status, id) } } @@ -105,13 +105,13 @@ abstract class MatteryWorkerBlockEntity( jobEventLoops.forEach { it.isIdling = false } } - override fun setChangedLight() { - super.setChangedLight() + override fun markDirtyFast() { + super.markDirtyFast() jobEventLoops.forEach { it.isIdling = false } } protected fun energyLevelUpdated() { - super.setChangedLight() + super.markDirtyFast() jobEventLoops.forEach { it.notify(MachineJobEventLoop.IdleReason.POWER) } } @@ -121,7 +121,7 @@ abstract class MatteryWorkerBlockEntity( } protected fun matterLevelUpdated() { - super.setChangedLight() + super.markDirtyFast() jobEventLoops.forEach { it.notify(MachineJobEventLoop.IdleReason.MATTER) } } @@ -130,16 +130,34 @@ abstract class MatteryWorkerBlockEntity( jobEventLoops.forEach { it.isIdling = newBlocked } } + private val hasWorkerState by countingLazy(blockStateChangesCounter) { + this.blockState.hasProperty(WorkerState.WORKER_STATE) + } + + private val isWorkingState by countingLazy(blockStateChangesCounter) { + hasWorkerState && this.blockState.getValue(WorkerState.WORKER_STATE) == WorkerState.WORKING + } + + private val isErrorState by countingLazy(blockStateChangesCounter) { + hasWorkerState && this.blockState.getValue(WorkerState.WORKER_STATE) == WorkerState.ERROR + } + + private val isIdleState by countingLazy(blockStateChangesCounter) { + hasWorkerState && this.blockState.getValue(WorkerState.WORKER_STATE) == WorkerState.IDLE + } + override fun tick() { super.tick() jobEventLoops.forEach { it.think() } - if (jobEventLoops.any { it.workingTicksAnim > 20 } && blockState.hasProperty(WorkerState.WORKER_STATE) && blockState.getValue(WorkerState.WORKER_STATE) != WorkerState.WORKING) { - level?.setBlock(blockPos, blockState.setValue(WorkerState.WORKER_STATE, WorkerState.WORKING), Block.UPDATE_CLIENTS) - } else if (jobEventLoops.any { it.errorTicksAnim > 20 } && blockState.hasProperty(WorkerState.WORKER_STATE) && blockState.getValue(WorkerState.WORKER_STATE) != WorkerState.ERROR) { - level?.setBlock(blockPos, blockState.setValue(WorkerState.WORKER_STATE, WorkerState.ERROR), Block.UPDATE_CLIENTS) - } else if (jobEventLoops.all { it.idleTicksAnim > 20 } && blockState.hasProperty(WorkerState.WORKER_STATE) && blockState.getValue(WorkerState.WORKER_STATE) != WorkerState.IDLE) { - level?.setBlock(blockPos, blockState.setValue(WorkerState.WORKER_STATE, WorkerState.IDLE), Block.UPDATE_CLIENTS) + if (hasWorkerState) { + if (jobEventLoops.any { it.workingTicksAnim > 20 } && !isWorkingState) { + level?.setBlock(blockPos, blockState.setValue(WorkerState.WORKER_STATE, WorkerState.WORKING), Block.UPDATE_CLIENTS) + } else if (jobEventLoops.any { it.errorTicksAnim > 20 } && !isErrorState) { + level?.setBlock(blockPos, blockState.setValue(WorkerState.WORKER_STATE, WorkerState.ERROR), Block.UPDATE_CLIENTS) + } else if (jobEventLoops.all { it.idleTicksAnim > 20 } && !isIdleState) { + level?.setBlock(blockPos, blockState.setValue(WorkerState.WORKER_STATE, WorkerState.IDLE), Block.UPDATE_CLIENTS) + } } } 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 a5daaf14a..7eadaf2e3 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 @@ -34,9 +34,9 @@ class FluidTankBlockEntity(blockPos: BlockPos, blockState: BlockState) : Mattery level?.lightEngine?.checkBlock(blockPos) }) - val fillInput = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) - val drainInput = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) - val output = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) + val fillInput = MatteryContainer(::markDirtyFast, 1).also(::addDroppableContainer) + val drainInput = MatteryContainer(::markDirtyFast, 1).also(::addDroppableContainer) + val output = MatteryContainer(::markDirtyFast, 1).also(::addDroppableContainer) val itemConfig = ConfigurableItemHandler( input = CombinedItemHandler( @@ -75,7 +75,7 @@ class FluidTankBlockEntity(blockPos: BlockPos, blockState: BlockState) : Mattery private fun onChanged(new: FluidStack, old: FluidStack) { synchronizedFluid = new.copy() - setChangedLight() + markDirtyFast() } private fun drainItem() { 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 d354bf5e9..19dd30f42 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 @@ -26,7 +26,7 @@ class PainterBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDe return PainterMenu(containerID, inventory, this) } - val dyeInput = MatteryContainer(this::setChangedLight, 1) + val dyeInput = MatteryContainer(this::markDirtyFast, 1) private val dyeStored = EnumMap(DyeColor::class.java) val dyeStoredView: Map = Collections.unmodifiableMap(dyeStored) @@ -46,7 +46,7 @@ class PainterBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDe } } - setChangedLight() + markDirtyFast() } val config = ConfigurableItemHandler(input = dyeInput.handler(object : HandlerFilter { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index 5e622489b..ae2a73a8f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -31,7 +31,7 @@ import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode class MatterBottlerBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.MATTER_BOTTLER, blockPos, blockState) { - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::setChangedLight, MachinesConfig.MatterBottler.VALUES)) + override val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::markDirtyFast, MachinesConfig.MatterBottler.VALUES)) val energyConfig = ConfigurableEnergy(energy) private inner class Container : MatteryContainer(3) { @@ -44,7 +44,7 @@ class MatterBottlerBlockEntity(blockPos: BlockPos, blockState: BlockState) : } override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { - setChangedLight() + markDirtyFast() updateBlockState() } } @@ -57,7 +57,7 @@ class MatterBottlerBlockEntity(blockPos: BlockPos, blockState: BlockState) : field = value initialCapacity = null workProgress = 0f - this.setChangedLight() + this.markDirtyFast() if (value) { inputHandler.parent = bottlingHandler @@ -73,7 +73,7 @@ class MatterBottlerBlockEntity(blockPos: BlockPos, blockState: BlockState) : var spitItemsWhenCantWork = false set(value) { field = value - this.setChangedLight() + this.markDirtyFast() } val bottlingHandler = bottling.handler(object : HandlerFilter { @@ -97,7 +97,7 @@ class MatterBottlerBlockEntity(blockPos: BlockPos, blockState: BlockState) : battery = batteryItemHandler ) - val matter: ProfiledMatterStorage = ProfiledMatterStorage(object : MatterStorageImpl(this::setChangedLight, FlowDirection.BI_DIRECTIONAL, MachinesConfig.MatterBottler.VALUES::matterCapacity) { + val matter: ProfiledMatterStorage = ProfiledMatterStorage(object : MatterStorageImpl(this::markDirtyFast, FlowDirection.BI_DIRECTIONAL, MachinesConfig.MatterBottler.VALUES::matterCapacity) { override val matterFlow: FlowDirection get() { return if (this@MatterBottlerBlockEntity.isBottling) FlowDirection.INPUT else FlowDirection.OUTPUT } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt index a45fd8958..b225e7f1a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterCapacitorBankBlockEntity.kt @@ -120,7 +120,7 @@ class MatterCapacitorBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) override val matterFlow: FlowDirection get() = FlowDirection.BI_DIRECTIONAL - val container = object : MatteryContainer(this::setChangedLight, BatteryBankBlockEntity.CAPACITY) { + val container = object : MatteryContainer(this::markDirtyFast, BatteryBankBlockEntity.CAPACITY) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { super.setChanged(slot, new, old) capacitorStatus[slot].boolean = new.getCapability(MatteryCapability.MATTER).isPresent diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index abab0b27d..4e93fe6be 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -54,15 +54,15 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) } } - override val upgrades = UpgradeContainer(this::setChangedLight, 4, UpgradeType.REPLICATOR) - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::setChangedLight, upgrades.transform(MachinesConfig.MATTER_DECOMPOSER))) + override val upgrades = UpgradeContainer(this::markDirtyFast, 4, UpgradeType.REPLICATOR) + override val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::markDirtyFast, upgrades.transform(MachinesConfig.MATTER_DECOMPOSER))) val energyConfig = ConfigurableEnergy(energy) init { savetables.stateful(::energy, ENERGY_KEY) } - val matter = ProfiledMatterStorage(MatterStorageImpl(::setChangedLight, FlowDirection.OUTPUT, upgrades.matterCapacity(MachinesConfig.MATTER_DECOMPOSER::matterCapacity))) + val matter = ProfiledMatterStorage(MatterStorageImpl(::markDirtyFast, FlowDirection.OUTPUT, upgrades.matterCapacity(MachinesConfig.MATTER_DECOMPOSER::matterCapacity))) val matterNode = SimpleMatterNode(matter = matter) init { @@ -72,8 +72,8 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) } // вход, выход - val inputContainer = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) - val outputContainer = MatteryContainer(::setChangedLight, 2).also(::addDroppableContainer) + val inputContainer = MatteryContainer(::markDirtyFast, 1).also(::addDroppableContainer) + val outputContainer = MatteryContainer(::markDirtyFast, 2).also(::addDroppableContainer) val itemConfig = ConfigurableItemHandler( input = inputContainer.handler(object : HandlerFilter { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt index 3e312cf0b..489a00ccc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReconstructorBlockEntity.kt @@ -52,9 +52,9 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState) var isUnableToProcess = false private set - val upgrades = UpgradeContainer(this::setChangedLight, 3, UpgradeType.REPLICATOR) - val matter = ProfiledMatterStorage(MatterStorageImpl(::setChangedLight, FlowDirection.INPUT, upgrades.matterCapacity(MachinesConfig.MatterReconstructor.VALUES::matterCapacity))) - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::setChangedLight, upgrades.transform(MachinesConfig.MatterReconstructor.VALUES))) + val upgrades = UpgradeContainer(this::markDirtyFast, 3, UpgradeType.REPLICATOR) + val matter = ProfiledMatterStorage(MatterStorageImpl(::markDirtyFast, FlowDirection.INPUT, upgrades.matterCapacity(MachinesConfig.MatterReconstructor.VALUES::matterCapacity))) + override val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::markDirtyFast, upgrades.transform(MachinesConfig.MatterReconstructor.VALUES))) val matterNode = object : MatterNode() { override fun getMatterHandler(): IMatterStorage { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index 2717c81e7..7bf692a9d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -48,7 +48,7 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) val container = MatteryContainer(::itemContainerUpdated, 1).also(::addDroppableContainer) val matterNode = SimpleMatterNode(matter = matter) - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::energyLevelUpdated, MachinesConfig.MatterRecycler.VALUES)) + override val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::energyLevelUpdated, MachinesConfig.MatterRecycler.VALUES)) val itemConfig = ConfigurableItemHandler(input = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index a8a108693..76688494d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -65,8 +65,8 @@ class MatterReplicatorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } - override val upgrades = UpgradeContainer(this::setChangedLight, 3, UpgradeType.REPLICATOR) - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::energyLevelUpdated, upgrades.transform(MachinesConfig.MATTER_REPLICATOR))) + override val upgrades = UpgradeContainer(this::markDirtyFast, 3, UpgradeType.REPLICATOR) + override val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::energyLevelUpdated, upgrades.transform(MachinesConfig.MATTER_REPLICATOR))) val matter = ProfiledMatterStorage(MatterStorageImpl(::matterLevelUpdated, FlowDirection.INPUT, upgrades.matterCapacity(MachinesConfig.MATTER_REPLICATOR::matterCapacity))) val outputContainer = MatteryContainer(::itemContainerUpdated, 3).also(::addDroppableContainer) val dustContainer = MatteryContainer(::itemContainerUpdated, 2).also(::addDroppableContainer) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt index 1c64fd770..bd758bf51 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt @@ -31,9 +31,9 @@ import kotlin.math.pow class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : MatteryWorkerBlockEntity(MBlockEntities.MATTER_SCANNER, p_155229_, p_155230_, ItemJob.CODEC) { - override val upgrades = UpgradeContainer(this::setChangedLight, 2, UpgradeType.BASIC) + override val upgrades = UpgradeContainer(this::markDirtyFast, 2, UpgradeType.BASIC) val container = MatteryContainer(::itemContainerUpdated, 1).also(::addDroppableContainer) - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::energyLevelUpdated, upgrades.transform(MachinesConfig.MATTER_SCANNER))) + override val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::energyLevelUpdated, upgrades.transform(MachinesConfig.MATTER_SCANNER))) val itemConfig = ConfigurableItemHandler(inputOutput = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt index 8e6c5f6d2..90ce6f6d1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt @@ -23,26 +23,26 @@ import ru.dbotthepony.mc.otm.storage.optics.powered import ru.dbotthepony.mc.otm.storage.optics.flow class DriveRackBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.DRIVE_RACK, blockPos, blockState) { - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::setChangedLight, MachinesConfig.DRIVE_RACK)) + override val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::markDirtyFast, MachinesConfig.DRIVE_RACK)) val cell = StorageNode(energy) val energyConfig = ConfigurableEnergy(energy) var insertPriority = 0 set(value) { field = value - setChangedLight() + markDirtyFast() } var extractPriority = 0 set(value) { field = value - setChangedLight() + markDirtyFast() } var mode = FlowDirection.BI_DIRECTIONAL set(value) { field = value - setChangedLight() + markDirtyFast() } val container: MatteryContainer = object : MatteryContainer(this::setChanged, 4) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt index fbe4d849c..87da29344 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt @@ -26,10 +26,10 @@ import ru.dbotthepony.mc.otm.menu.storage.DriveViewerMenu import java.util.UUID class DriveViewerBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.DRIVE_VIEWER, blockPos, blockState) { - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::energyUpdated, MachinesConfig.DRIVE_VIEWER)) + override val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::energyUpdated, MachinesConfig.DRIVE_VIEWER)) val energyConfig = ConfigurableEnergy(energy) - val container: MatteryContainer = object : MatteryContainer(this::setChangedLight, 1) { + val container: MatteryContainer = object : MatteryContainer(this::markDirtyFast, 1) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { super.setChanged(slot, new, old) @@ -63,13 +63,13 @@ class DriveViewerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte override var sorting: ItemStorageStackSorter = ItemStorageStackSorter.DEFAULT set(value) { field = value - setChangedLight() + markDirtyFast() } override var isAscending: Boolean = true set(value) { field = value - setChangedLight() + markDirtyFast() } } @@ -85,7 +85,7 @@ class DriveViewerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte if (state != blockState) { level?.setBlock(blockPos, state, Block.UPDATE_CLIENTS) } else { - setChangedLight() + markDirtyFast() } } 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 b95bb3dfe..c4d3543e7 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 @@ -45,7 +45,6 @@ import ru.dbotthepony.mc.otm.client.render.Widgets8 import ru.dbotthepony.mc.otm.container.CombinedContainer import ru.dbotthepony.mc.otm.container.addItem import ru.dbotthepony.mc.otm.container.fullIterator -import ru.dbotthepony.mc.otm.container.iterator import ru.dbotthepony.mc.otm.core.collect.map import ru.dbotthepony.mc.otm.core.collect.toList import ru.dbotthepony.mc.otm.core.isNotEmpty @@ -173,7 +172,7 @@ class ItemMonitorPlayerSettings : INBTSerializable, IItemMonitorPla } class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.ITEM_MONITOR, blockPos, blockState), IStorageEventConsumer { - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::setChangedLight, MachinesConfig.ITEM_MONITOR)) + override val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::markDirtyFast, MachinesConfig.ITEM_MONITOR)) val energyConfig = ConfigurableEnergy(energy) init { @@ -213,7 +212,7 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte // hence we are forced to work around this by providing proxy container val craftingGrid = object : MatteryContainer(3 * 3) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { - setChangedLight() + markDirtyFast() craftingGridVanilla[slot] = new if (!inProcessOfCraft) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt index dd37cadf8..d15bcee90 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt @@ -52,7 +52,7 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter return StorageBusMenu(containerID, inventory, this) } - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::setChangedLight, MachinesConfig.STORAGE_INTERFACES)) + override val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::markDirtyFast, MachinesConfig.STORAGE_INTERFACES)) val energyConfig = ConfigurableEnergy(energy, modesFront = FlowDirection.NONE) val cell: StorageNode = object : StorageNode(energy) { @@ -80,19 +80,19 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter var insertPriority = 0 set(value) { field = value - setChangedLight() + markDirtyFast() } var extractPriority = 0 set(value) { field = value - setChangedLight() + markDirtyFast() } var mode: FlowDirection = FlowDirection.BI_DIRECTIONAL set(value) { field = value - setChangedLight() + markDirtyFast() } init { @@ -123,7 +123,7 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter val filter = ItemFilter(MAX_FILTERS) { component?.scan() - setChangedLight() + markDirtyFast() } init { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt index da0082640..39907eb94 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt @@ -47,7 +47,7 @@ abstract class AbstractStorageImportExport( blockState: BlockState, energyValues: EnergyBalanceValues = MachinesConfig.STORAGE_INTERFACES ) : MatteryPoweredBlockEntity(blockType, blockPos, blockState) { - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::setChangedLight, energyValues)) + final override val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::markDirtyFast, energyValues)) val energyConfig = ConfigurableEnergy(energy, modesFront = FlowDirection.NONE) val cell: StorageNode = object : StorageNode(energy) { @@ -115,7 +115,7 @@ class StorageImporterBlockEntity( blockPos: BlockPos, blockState: BlockState ) : AbstractStorageImportExport(MBlockEntities.STORAGE_IMPORTER, blockPos, blockState), IItemHandler { override val filter = ItemFilter(MAX_FILTERS) { - setChangedLight() + markDirtyFast() } private var lastSlot = 0 @@ -264,7 +264,7 @@ class StorageExporterBlockEntity(blockPos: BlockPos, blockState: BlockState) : lastSlot = 0 - setChangedLight() + markDirtyFast() }.also { it.isWhitelist = true } private var lastSlot = 0 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt index 64f4fdc01..a2a7214ef 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt @@ -22,7 +22,7 @@ class StoragePowerSupplierBlockEntity(blockPos: BlockPos, blockState: BlockState } val cell = StorageNode() - val energy = WorkerEnergyStorage(this::setChangedLight, MachinesConfig.STORAGE_POWER_SUPPLIER) + override val energy = WorkerEnergyStorage(this::markDirtyFast, MachinesConfig.STORAGE_POWER_SUPPLIER) init { savetable(::energy, ENERGY_KEY) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt index 943589746..88f41a6f2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt @@ -25,7 +25,7 @@ class AndroidChargerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Ma return AndroidChargerMenu(containerID, inventory, this) } - val energyConfig = ConfigurableEnergy(ProfiledEnergyStorage(WorkerEnergyStorage(this::setChangedLight, MachinesConfig.ANDROID_CHARGER)), modesTop = FlowDirection.NONE) + val energyConfig = ConfigurableEnergy(ProfiledEnergyStorage(WorkerEnergyStorage(this::markDirtyFast, MachinesConfig.ANDROID_CHARGER)), modesTop = FlowDirection.NONE) init { savetables.stateful(energyConfig::energy, ENERGY_KEY) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt index 878e8a789..95c323e12 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidStationBlockEntity.kt @@ -28,7 +28,7 @@ class AndroidStationBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : return AndroidStationMenu(containerID, inventory, this) } - val energy: ProfiledEnergyStorage = ProfiledEnergyStorage(object : WorkerEnergyStorage(::setChangedLight, MachinesConfig.AndroidStation.VALUES) { + override val energy: ProfiledEnergyStorage = ProfiledEnergyStorage(object : WorkerEnergyStorage(::markDirtyFast, MachinesConfig.AndroidStation.VALUES) { override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { return super.extractEnergy(howMuch, simulate).also { if (!simulate && this.batteryLevel.isZero) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt index 8e429535c..fa1f08a61 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/BatteryBankBlockEntity.kt @@ -88,7 +88,7 @@ class BatteryBankBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Matte } if (!simulate && !summ.isZero) { - setChangedLight() + markDirtyFast() gaugeLevel = batteryLevel.percentage(maxBatteryLevel) } 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 04cf52774..0ef5e8939 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 @@ -24,15 +24,15 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe return ChemicalGeneratorMenu(containerID, inventory, this) } - val batteryContainer = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) - val residueContainer = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) - val fuelContainer = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) + val batteryContainer = MatteryContainer(::markDirtyFast, 1).also(::addDroppableContainer) + val residueContainer = MatteryContainer(::markDirtyFast, 1).also(::addDroppableContainer) + val fuelContainer = MatteryContainer(::markDirtyFast, 1).also(::addDroppableContainer) val batteryItemHandler = batteryContainer.handler(HandlerFilter.Chargeable) val residueItemHandler = residueContainer.handler(HandlerFilter.OnlyOut) val fuelItemHandler = fuelContainer.handler(HandlerFilter.ChemicalFuel) - val energy = ProfiledEnergyStorage(GeneratorEnergyStorage(::setChangedLight, MachinesConfig.ChemicalGenerator.VALUES::energyCapacity, MachinesConfig.ChemicalGenerator.VALUES::energyThroughput)) + val energy = ProfiledEnergyStorage(GeneratorEnergyStorage(::markDirtyFast, MachinesConfig.ChemicalGenerator.VALUES::energyCapacity, MachinesConfig.ChemicalGenerator.VALUES::energyThroughput)) val itemConfig = ConfigurableItemHandler( input = fuelItemHandler, @@ -55,8 +55,8 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe savetables.int(::workTicksTotal) } - override fun setChangedLight() { - super.setChangedLight() + override fun markDirtyFast() { + super.markDirtyFast() checkFuelSlot = true } @@ -106,9 +106,7 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe } if (energy.batteryLevel.isPositive) { - val item = batteryContainer[0] - - if (!item.isEmpty) { + for (item in batteryContainer) { item.energy?.also { moveEnergy(energy, it, MachinesConfig.ChemicalGenerator.VALUES.energyThroughput, simulate = false) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt index 9d6c16322..693606ea7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyServoBlockEntity.kt @@ -22,8 +22,8 @@ import ru.dbotthepony.mc.otm.menu.tech.EnergyServoMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities class EnergyServoBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.ENERGY_SERVO, blockPos, blockState) { - val discharge = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) - val charge = MatteryContainer(::setChangedLight, 1).also(::addDroppableContainer) + val discharge = MatteryContainer(::markDirtyFast, 1).also(::addDroppableContainer) + val charge = MatteryContainer(::markDirtyFast, 1).also(::addDroppableContainer) val energy: ProfiledEnergyStorage = ProfiledEnergyStorage(object : IMatteryEnergyStorage { override val energyFlow: FlowDirection get() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt index 0bac233a6..5862e0000 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt @@ -18,11 +18,11 @@ class EssenceStorageBlockEntity(blockPos: BlockPos, blockState: BlockState) : Ma set(value) { require(value >= 0L) { "Negative experience: $value" } field = value - setChangedLight() + markDirtyFast() } - val capsuleContainer = MatteryContainer(::setChangedLight, 1) - val servoContainer = MatteryContainer(::setChangedLight, 1) + val capsuleContainer = MatteryContainer(::markDirtyFast, 1) + val servoContainer = MatteryContainer(::markDirtyFast, 1) init { savetables.long(::experienceStored) 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 30b72f565..3c2e7368d 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 @@ -21,7 +21,6 @@ import ru.dbotthepony.mc.otm.container.HandlerFilter 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.find import ru.dbotthepony.mc.otm.core.collect.maybe import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu @@ -29,12 +28,12 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MRecipes class PlatePressBlockEntity( - p_155229_: BlockPos, - p_155230_: BlockState, + blockPos: BlockPos, + blockState: BlockState, val isTwin: Boolean = false, -) : MatteryWorkerBlockEntity(if (isTwin) MBlockEntities.TWIN_PLATE_PRESS else MBlockEntities.PLATE_PRESS, p_155229_, p_155230_, ItemJob.CODEC, if (isTwin) 2 else 1) { - override val upgrades = UpgradeContainer(this::setChangedLight, if (isTwin) 4 else 3, UpgradeType.BASIC_PROCESSING) - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::energyLevelUpdated, upgrades.transform(MachinesConfig.PLATE_PRESS))) +) : MatteryWorkerBlockEntity(if (isTwin) MBlockEntities.TWIN_PLATE_PRESS else MBlockEntities.PLATE_PRESS, blockPos, blockState, ItemJob.CODEC, if (isTwin) 2 else 1) { + override val upgrades = UpgradeContainer(this::markDirtyFast, if (isTwin) 4 else 3, UpgradeType.BASIC_PROCESSING) + override val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::energyLevelUpdated, upgrades.transform(MachinesConfig.PLATE_PRESS))) val inputContainer = MatteryContainer(this::itemContainerUpdated, if (isTwin) 2 else 1).also(::addDroppableContainer) val outputContainer = MatteryContainer(this::itemContainerUpdated, if (isTwin) 2 else 1).also(::addDroppableContainer) 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 ab30d0401..ab5974e82 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 @@ -35,8 +35,8 @@ class PoweredFurnaceBlockEntity( val recipeType: RecipeType, val config: WorkerBalanceValues ) : MatteryWorkerBlockEntity(type, blockPos, blockState, ItemJob.CODEC, 2) { - override val upgrades = UpgradeContainer(this::setChangedLight, 2, UpgradeType.BASIC_PROCESSING) - val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::energyLevelUpdated, upgrades.transform(config))) + override val upgrades = UpgradeContainer(this::markDirtyFast, 2, UpgradeType.BASIC_PROCESSING) + override val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::energyLevelUpdated, upgrades.transform(config))) val inputs = immutableList(2) { MatteryContainer(this::itemContainerUpdated, 1) } val outputs = immutableList(2) { MatteryContainer(this::itemContainerUpdated, 1) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/AbstractProfiledStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/AbstractProfiledStorage.kt index 3d484f6d0..f63328fb4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/AbstractProfiledStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/AbstractProfiledStorage.kt @@ -15,13 +15,18 @@ import java.util.* import kotlin.collections.ArrayList abstract class AbstractProfiledStorage(val parent: P) : INBTSerializable { - init { - storages.add(WeakReference(this)) - } - private val historyReceiveInternal = ArrayList(HISTORY_SIZE) private val historyTransferInternal = ArrayList(HISTORY_SIZE) + private var isTicking = false + + private fun startTicking() { + if (!isTicking) { + isTicking = true + storages.add(this) + } + } + val historyReceive: List = Collections.unmodifiableList(historyReceiveInternal) val historyTransfer: List = Collections.unmodifiableList(historyTransferInternal) @@ -47,6 +52,7 @@ abstract class AbstractProfiledStorage(val parent: P) : INBTSerializable< protected fun recordTransfer(value: Decimal, simulate: Boolean): Decimal { if (!simulate) { thisTickTransfer += value + if (!value.isZero) startTicking() } return value @@ -55,19 +61,23 @@ abstract class AbstractProfiledStorage(val parent: P) : INBTSerializable< protected fun recordReceive(value: Decimal, simulate: Boolean): Decimal { if (!simulate) { thisTickReceive += value + if (!value.isZero) startTicking() } return value } - private fun tick() { + private fun tick(): Boolean { tick = (tick + 1) % HISTORY_SIZE historyReceiveInternal[tick] = thisTickReceive historyTransferInternal[tick] = thisTickTransfer + isTicking = !thisTickReceive.isZero || !thisTickTransfer.isZero || historyReceiveInternal.any { !it.isZero } || historyTransferInternal.any { !it.isZero } thisTickReceive = Decimal.ZERO thisTickTransfer = Decimal.ZERO + + return isTicking } val savedata: INBTSerializable = object : INBTSerializable { @@ -155,7 +165,7 @@ abstract class AbstractProfiledStorage(val parent: P) : INBTSerializable< companion object { const val HISTORY_SIZE = 20 - private val storages = ObjectArrayList>>() + private val storages = ObjectArrayList>() val HISTORY_WEIGHTERS: ImmutableList = ImmutableList.of( Decimal("0.313335967"), @@ -201,7 +211,7 @@ abstract class AbstractProfiledStorage(val parent: P) : INBTSerializable< // разумеется, такое решение может несколько снизить производительность сервера, // но ничего страшного произойти не должно internal fun onServerPostTick() { - storages.forValidRefs { it.tick() } + storages.removeIf { !it.tick() } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/AtomicallyInvalidatedLazy.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/AtomicallyInvalidatedLazy.kt index 239f96bce..76b16fe62 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/AtomicallyInvalidatedLazy.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/AtomicallyInvalidatedLazy.kt @@ -2,8 +2,14 @@ package ru.dbotthepony.mc.otm.core.util import java.util.concurrent.atomic.AtomicInteger import java.util.concurrent.locks.ReentrantLock +import java.util.function.IntSupplier + +/** + * If synchronization is not required, [CounterInvalidatedLazy] should be used instead. + */ +class AtomicallyInvalidatedLazy(private val invalidator: IntSupplier, private val initializer: () -> V) : Lazy { + constructor(invalidator: AtomicInteger, initializer: () -> V) : this(invalidator::get, initializer) -class AtomicallyInvalidatedLazy(private val invalidator: AtomicInteger, private val initializer: () -> V) : Lazy { @Volatile private var thisCounter = -1 @Volatile @@ -11,10 +17,10 @@ class AtomicallyInvalidatedLazy(private val invalidator: AtomicInteger, priva private val lock = ReentrantLock() override val value: V get() { - if (thisCounter != invalidator.get()) { + if (thisCounter != invalidator.asInt) { lock.lock() this.stored = Companion - thisCounter = invalidator.get() + thisCounter = invalidator.asInt lock.unlock() } @@ -35,7 +41,7 @@ class AtomicallyInvalidatedLazy(private val invalidator: AtomicInteger, priva } override fun isInitialized(): Boolean { - return stored !== Companion && thisCounter == invalidator.get() + return stored !== Companion && thisCounter == invalidator.asInt } private companion object diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/CounterInvalidatedLazy.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/CounterInvalidatedLazy.kt new file mode 100644 index 000000000..eb277cdc3 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/CounterInvalidatedLazy.kt @@ -0,0 +1,80 @@ +package ru.dbotthepony.mc.otm.core.util + +import java.util.concurrent.atomic.AtomicInteger +import java.util.function.IntConsumer +import java.util.function.IntSupplier + +/** + * This lazy is not synchronized, so in event of two or more threads accessing value behavior of this implementation is undefined + * + * For synchronized use case, [AtomicallyInvalidatedLazy] should be used + */ +fun countingLazy(invalidator: IntSupplier, initializer: () -> V): Lazy { + if (invalidator is IntCounter) { + return SmartCounterInvalidatedLazy(invalidator, initializer) + } + + return CounterInvalidatedLazy(invalidator, initializer) +} + +/** + * This lazy is not synchronized, so in event of two or more threads accessing value behavior of this implementation is undefined + * + * For synchronized use case, [AtomicallyInvalidatedLazy] should be used + */ +class CounterInvalidatedLazy(private val invalidator: IntSupplier, private val initializer: () -> V) : Lazy { + constructor(invalidator: AtomicInteger, initializer: () -> V) : this(invalidator::get, initializer) + + private var thisCounter = -1 + private var stored: Any? = Companion + + override val value: V get() { + var stored = stored + + if (stored !== Companion && thisCounter == invalidator.asInt) + return stored as V + + stored = initializer.invoke() + this.stored = stored + this.thisCounter = invalidator.asInt + return stored + } + + override fun isInitialized(): Boolean { + return stored !== Companion && thisCounter == invalidator.asInt + } + + private companion object +} + +/** + * This lazy is not synchronized, so in event of two or more threads accessing value behavior of this implementation is undefined + * + * For synchronized use case, [AtomicallyInvalidatedLazy] should be used + */ +class SmartCounterInvalidatedLazy(invalidator: IntCounter, private val initializer: () -> V) : Lazy { + init { + invalidator.addListener(IntConsumer { + stored = Companion + }) + } + + private var stored: Any? = Companion + + override val value: V get() { + var stored = stored + + if (stored !== Companion) + return stored as V + + stored = initializer.invoke() + this.stored = stored + return stored + } + + override fun isInitialized(): Boolean { + return stored !== Companion + } + + private companion object +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/IntCounter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/IntCounter.kt new file mode 100644 index 000000000..0c4c56e23 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/IntCounter.kt @@ -0,0 +1,59 @@ +package ru.dbotthepony.mc.otm.core.util + +import ru.dbotthepony.mc.otm.core.IIntSubcripable +import ru.dbotthepony.mc.otm.core.ISubscriptable +import java.util.function.BooleanSupplier +import java.util.function.IntConsumer +import java.util.function.IntSupplier + +class IntCounter : IntSupplier, IIntSubcripable { + /** + * Doesn't subscribe to counter (counter does not reference this invalidator) + */ + inner class WeakInvalidator : BooleanSupplier { + private var thisValue = value + + override fun getAsBoolean(): Boolean { + if (thisValue != value) { + thisValue = value + return true + } + + return false + } + } + + /** + * Subscribes to counter (counter references this invalidator, can be removed using [remove]) + */ + inner class StrongInvalidator : BooleanSupplier, ISubscriptable.L { + private var isValid = true + private val l = listeners.addListener(IntConsumer { isValid = false }) + + override fun getAsBoolean(): Boolean { + val isValid = isValid + this.isValid = true + return isValid + } + + override fun remove() { + l.remove() + } + } + + private val listeners = IIntSubcripable.Impl() + private var value = 0 + + fun increment() { + value++ + listeners.accept(value) + } + + override fun addListener(listener: IntConsumer): ISubscriptable.L { + return listeners.addListener(listener) + } + + override fun getAsInt(): Int { + return value + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt index 7062a7054..3b74ac44b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt @@ -18,6 +18,8 @@ class TickList : ITickable { private val timers = ArrayDeque() private val namedTimers = Object2ObjectOpenHashMap(0) + private var shouldTick = false + var inTicker = false private set var ticks = 0 @@ -92,6 +94,8 @@ class TickList : ITickable { } private fun add(value: T, regular: MutableList, queue: MutableList) { + shouldTick = true + if (inTicker) { queue.add(value) } else { @@ -148,10 +152,14 @@ class TickList : ITickable { } ticks++ + if (!shouldTick) return + inTicker = true + shouldTick = timers.isNotEmpty() try { if (conditional.isNotEmpty()) { + shouldTick = true val iterator = conditional.iterator() for (ticker in iterator) { @@ -162,6 +170,8 @@ class TickList : ITickable { } if (once.isNotEmpty()) { + shouldTick = true + for (ticker in once) { ticker.tick() } @@ -170,23 +180,31 @@ class TickList : ITickable { } if (toRemoveFromAlways.isNotEmpty()) { + shouldTick = true + for (v in toRemoveFromAlways) always.remove(v) toRemoveFromAlways.clear() } if (always.isNotEmpty()) { + shouldTick = true + for (ticker in always) { ticker.tick() } } if (alwaysQueued.isNotEmpty()) { + shouldTick = true + always.ensureCapacity(always.size + alwaysQueued.size) for (v in alwaysQueued) always.add(v) // avoid toArray() alwaysQueued.clear() } if (conditionalQueued.isNotEmpty()) { + shouldTick = true + for (ticker in conditionalQueued) { conditional.addFirst(ticker) } @@ -195,6 +213,8 @@ class TickList : ITickable { } if (onceQueued.isNotEmpty()) { + shouldTick = true + for (ticker in onceQueued) { once.addFirst(ticker) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt index a9b5cec8a..8f0e8ca81 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryPoweredMenu.kt @@ -6,7 +6,6 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import net.minecraft.world.SimpleContainer import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting -import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback abstract class MatteryPoweredMenu protected constructor( @@ -15,7 +14,7 @@ abstract class MatteryPoweredMenu protected constructor( inventory: Inventory, tile: MatteryPoweredBlockEntity? = null ) : MatteryMenu(menuType, containerID, inventory, tile) { - val energyWidget = LevelGaugeWidget(this, tile?.matteryEnergy) + val energyWidget = LevelGaugeWidget(this, tile?.energy) val batterySlot = BatterySlot(tile?.batteryContainer ?: SimpleContainer(1), 0) val redstoneConfig = EnumInputWithFeedback(this) From 66c356bd4192255d9dad62b1c1873b566c77eb9f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 17 Aug 2023 13:58:01 +0700 Subject: [PATCH 0975/1199] Update chunk map subscribers implementation --- .../mc/otm/OverdriveThatMatters.java | 7 +- .../dbotthepony/mc/otm/GlobalEventHandler.kt | 4 +- .../mc/otm/block/entity/MatteryBlockEntity.kt | 278 ++++++------------ .../mc/otm/core/collect/WeakHashSet.kt | 6 +- .../network/synchronizer/FieldSynchronizer.kt | 17 +- 5 files changed, 106 insertions(+), 206 deletions(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 218eef4db..09e068c58 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -15,7 +15,6 @@ import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.jetbrains.annotations.NotNull; import ru.dbotthepony.mc.otm.android.AndroidResearchManager; import ru.dbotthepony.mc.otm.android.feature.EnderTeleporterFeature; import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity; @@ -47,7 +46,6 @@ import ru.dbotthepony.mc.otm.config.MachinesConfig; import ru.dbotthepony.mc.otm.config.ServerCompatConfig; import ru.dbotthepony.mc.otm.config.ServerConfig; import ru.dbotthepony.mc.otm.config.ToolsConfig; -import ru.dbotthepony.mc.otm.core.math.Decimal; import ru.dbotthepony.mc.otm.item.tool.ExplosiveHammerItem; import ru.dbotthepony.mc.otm.item.armor.TritaniumArmorItem; import ru.dbotthepony.mc.otm.item.QuantumBatteryItem; @@ -56,14 +54,12 @@ import ru.dbotthepony.mc.otm.item.PortableCondensationDriveItem; import ru.dbotthepony.mc.otm.matter.MatterManager; import ru.dbotthepony.mc.otm.network.*; import ru.dbotthepony.mc.otm.registry.*; -import ru.dbotthepony.mc.otm.storage.*; import ru.dbotthepony.mc.otm.triggers.KillAsAndroidTrigger; import top.theillusivec4.curios.api.CuriosApi; import static net.minecraftforge.common.MinecraftForge.EVENT_BUS; import javax.annotation.ParametersAreNonnullByDefault; -import java.util.Objects; // The value here should match an entry in the META-INF/mods.toml file @Mod(OverdriveThatMatters.MOD_ID) @@ -147,7 +143,7 @@ public final class OverdriveThatMatters { EVENT_BUS.addListener(EventPriority.HIGHEST, GlobalEventHandlerKt::onServerStopped); EVENT_BUS.addListener(EventPriority.HIGHEST, GlobalEventHandlerKt::onServerStopping); EVENT_BUS.addListener(EventPriority.HIGHEST, GlobalEventHandlerKt::onServerStarting); - EVENT_BUS.addListener(EventPriority.LOWEST, GlobalEventHandlerKt::onWorldTick); + EVENT_BUS.addListener(EventPriority.LOWEST, GlobalEventHandlerKt::onLevelTick); EVENT_BUS.addListener(EventPriority.LOWEST, GlobalEventHandlerKt::onServerTick); EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayerCapability.Companion::onPlayerTick); @@ -180,7 +176,6 @@ public final class OverdriveThatMatters { EVENT_BUS.addListener(EventPriority.NORMAL, MatteryBlockEntity.Companion::onWatch); EVENT_BUS.addListener(EventPriority.NORMAL, MatteryBlockEntity.Companion::onForget); EVENT_BUS.addListener(EventPriority.NORMAL, MatteryBlockEntity.Companion::playerDisconnected); - EVENT_BUS.addListener(EventPriority.LOWEST, MatteryBlockEntity.Companion::postLevelTick); EVENT_BUS.addListener(EventPriority.LOWEST, KillAsAndroidTrigger.INSTANCE::onKill); diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt index 24a73bf1c..8f63cf0ec 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt @@ -15,6 +15,7 @@ import net.minecraftforge.event.server.ServerStoppedEvent import net.minecraftforge.event.server.ServerStoppingEvent import net.minecraftforge.fml.loading.FMLLoader import org.apache.logging.log4j.LogManager +import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.capability.AbstractProfiledStorage import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.collect.WeakHashSet @@ -165,7 +166,7 @@ fun onServerTick(event: ServerTickEvent) { } } -fun onWorldTick(event: LevelTickEvent) { +fun onLevelTick(event: LevelTickEvent) { if (event.phase === TickEvent.Phase.START) { preWorldTick[event.level]?.tick() @@ -176,6 +177,7 @@ fun onWorldTick(event: LevelTickEvent) { } } else { postWorldTick[event.level]?.tick() + MatteryBlockEntity.postLevelTick(event) } } 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 5f091b914..6bbffcef2 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 @@ -5,6 +5,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import it.unimi.dsi.fastutil.longs.Long2ObjectFunction import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.ObjectArraySet +import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import mekanism.api.energy.IStrictEnergyHandler import net.minecraft.core.BlockPos @@ -31,7 +32,6 @@ import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.INBTSerializable import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.energy.IEnergyStorage -import net.minecraftforge.event.TickEvent import net.minecraftforge.event.TickEvent.LevelTickEvent import net.minecraftforge.event.entity.player.PlayerEvent import net.minecraftforge.event.level.ChunkWatchEvent @@ -46,7 +46,6 @@ import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper import ru.dbotthepony.mc.otm.compat.mekanism.Mekanism2MatteryEnergyWrapper import ru.dbotthepony.mc.otm.core.ISubscriptable import ru.dbotthepony.mc.otm.core.collect.WeakHashSet -import ru.dbotthepony.mc.otm.core.forValidRefs import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.immutableList @@ -69,7 +68,6 @@ import java.util.function.Predicate import java.util.function.Supplier import java.util.stream.Stream import kotlin.NoSuchElementException -import kotlin.collections.ArrayList import kotlin.properties.ReadWriteProperty import kotlin.reflect.KProperty import kotlin.reflect.KProperty0 @@ -120,12 +118,11 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc */ protected val savetablesLevel = Savetables() - private var tickedOnce = false - open fun tick() { tickList.tick() - tickedOnce = true - synchronizeToPlayers(false) + + if (synchronizer.isNotEmpty) + synchronizeToPlayers(false) } /** @@ -537,10 +534,12 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } val synchronizer = FieldSynchronizer { - if (isSynchronizing || tickedOnce) + if (isSynchronizing || tickList.ticks != 0) return@FieldSynchronizer - if (!isRemoved && level?.isClientSide == false && (_subCache == null || (_subCache ?: throw ConcurrentModificationException()).players.isNotEmpty())) { + if (isRemoved) markSynchronizerClean() + + if (level?.isClientSide == false && (_subCache == null || (_subCache ?: throw ConcurrentModificationException()).players.isNotEmpty())) { ru.dbotthepony.mc.otm.onceServer { synchronizeToPlayers(true) } @@ -599,6 +598,8 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } private var _subCache: ChunkSubscribers? = null + private val subscription get() = _subCache ?: subscribe() + private var playerListUpdated = false private fun unsubscribe() { val subCache = _subCache ?: return @@ -611,7 +612,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } } - lastSubscriptionChangeset = -1 + playerListUpdated = false } private fun subscribe(): ChunkSubscribers { @@ -621,171 +622,106 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc val subs = playerMap .computeIfAbsent(level) { Long2ObjectOpenHashMap() } - .computeIfAbsent(ChunkPos(blockPos).toLong(), Long2ObjectFunction { ChunkSubscribers(level = WeakReference(level), chunkPos = ChunkPos(blockPos).toLong()) }) + .computeIfAbsent(ChunkPos(blockPos).toLong(), Long2ObjectFunction { ChunkSubscribers(level, ChunkPos(blockPos).toLong()) }) subs.subscribe(this) _subCache = subs + playerListUpdated = true return subs } - private val subscription get() = _subCache ?: subscribe() - private var lastSubscriptionChangeset = -1 - - fun synchronizeToPlayers() { - synchronizeToPlayers(false) - } - - protected fun synchronizeToPlayers(calledBySynchronizer: Boolean) { + private fun synchronizeToPlayers(calledBySynchronizer: Boolean) { isSynchronizing = true try { - if (synchronizer.isEmpty || isRemoved) { - if (calledBySynchronizer) synchronizer.markClean() - return - } - check(level is ServerLevel) { "Invalid realm or Level is null" } - synchronizer.observe() - val subscription = subscription - if (subscription.players.isEmpty() || lastSubscriptionChangeset == subscription.changeset && !synchronizer.hasChanges) { - if (calledBySynchronizer) synchronizer.markClean() - return - } + if (subscription.players.isNotEmpty() && (playerListUpdated || synchronizer.isDirty)) { + playerListUpdated = false - lastSubscriptionChangeset = subscription.changeset + for (player in subscription.players) { + val payload = synchronizer.computeEndpointFor(player).collectNetworkPayload() - for (player in subscription.players) { - val payload = synchronizer.computeEndpointFor(player).collectNetworkPayload() - - if (payload != null) { - GenericNetworkChannel.send(player, BlockEntitySyncPacket(blockPos, payload.array, payload.length)) + if (payload != null) { + GenericNetworkChannel.send(player, BlockEntitySyncPacket(blockPos, payload.array, payload.length)) + } } - } - synchronizer.markClean() + synchronizer.markClean() + } else if (calledBySynchronizer) { + synchronizer.markClean() + } } finally { isSynchronizing = false } } - private data class ChunkSubscribers( - val blockEntities: ArrayList> = ArrayList(0), - val players: ArrayList = ArrayList(1), - val observingBlockEntities: ArrayList> = ArrayList(0), - val level: WeakReference, - val chunkPos: Long, - var changeset: Int = 0 - ) { - fun cleanUpBlocks() { - val listIterator = blockEntities.listIterator() + private class ChunkSubscribers(level: ServerLevel, val chunkPos: Long) { + val level = WeakReference(level) + val blockEntities = WeakHashSet(linked = true, initialCapacity = 0) + val players = ObjectLinkedOpenHashSet(0) + val blockEntitiesWithObservers = WeakHashSet(linked = true, initialCapacity = 0) - for (block in listIterator) { - if (block.get() == null) { - listIterator.remove() + operator fun component1() = blockEntities + operator fun component2() = players + + val hasObservers: Boolean get() { + return blockEntities.any { it.synchronizer.hasObservers } + } + + fun subscribe(player: ServerPlayer) { + if (players.add(player)) { + blockEntities.forEach { it.playerListUpdated = true } + + onceServer(10) { + if (!player.hasDisconnected() && player in players) { + blockEntities.forEach { + it.synchronizeToPlayers(false) + } + } } } } - val hasObservers: Boolean get() { - val listIterator = blockEntities.listIterator() - - for (value in listIterator) { - val ref = value.get() - - if (ref == null) { - listIterator.remove() - } else if (ref.synchronizer.hasObservers) { - return true + fun unsubscribe(player: ServerPlayer): Boolean { + if (players.remove(player)) { + blockEntities.forEach { + it.synchronizer.removeEndpointFor(player) } + + return true } return false } fun subscribe(blockEntity: MatteryBlockEntity) { - val iterator = blockEntities.listIterator() - - for (value in iterator) { - val ref = value.get() - - if (ref === blockEntity) { - return - } else if (ref == null) { - iterator.remove() - } - } - - val bref = WeakReference(blockEntity) - blockEntities.add(bref) - changeset++ + if (!blockEntities.add(blockEntity)) return onceServer { - blockEntity.synchronizeToPlayers() + blockEntity.synchronizeToPlayers(false) } - if (blockEntity.synchronizer.hasObservers) { - observingBlockEntities.add(bref) - val listing = tickingMap.computeIfAbsent(level.get() ?: throw NullPointerException("Level got GCd!")) { ArrayList(1) } - val tickerIterator = listing.listIterator() + if (blockEntity.synchronizer.hasObservers && blockEntity.tickList.ticks == 0) { + blockEntitiesWithObservers.add(blockEntity) - for (value in tickerIterator) { - val ref = value.get() - - if (ref === this) { - return - } else if (ref == null) { - tickerIterator.remove() - } - } - - listing.add(WeakReference(this)) + tickingMap + .computeIfAbsent(level.get() ?: throw NullPointerException("Level got GCd!")) { WeakHashSet(linked = true, initialCapacity = 2) } + .add(this) } } fun unsubscribe(blockEntity: MatteryBlockEntity): Boolean { - val listIterator = blockEntities.listIterator() + blockEntities.remove(blockEntity) + blockEntitiesWithObservers.remove(blockEntity) - for (value in listIterator) { - if (value.get() === blockEntity) { - listIterator.remove() - changeset++ - break - } - } - - if (blockEntity.synchronizer.hasObservers) { - val tickerIterator = observingBlockEntities.listIterator() - - for (value in tickerIterator) { - val ref = value.get() - - if (ref === blockEntity) { - tickerIterator.remove() - break - } else if (ref == null) { - tickerIterator.remove() - } - } - } - - if (players.isNotEmpty()) { - return false - } - - cleanUpBlocks() - return blockEntities.isEmpty() + return players.isEmpty() && blockEntities.isEmpty() } val isEmpty: Boolean get() { - if (players.isNotEmpty()) { - return false - } - - cleanUpBlocks() - return blockEntities.isEmpty() + return players.isEmpty() && blockEntities.isEmpty() } } @@ -813,7 +749,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc const val LOOT_TABLE_SEED_KEY = RandomizableContainerBlockEntity.LOOT_TABLE_SEED_TAG private val playerMap = WeakHashMap>() - private val tickingMap = WeakHashMap>>() + private val tickingMap = WeakHashMap>() private val vec2Dir = Int2ObjectOpenHashMap() @@ -860,7 +796,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } init { - for (dir in Direction.values()) { + for (dir in Direction.entries) { vec2Dir[vecKey(dir.normal)] = dir } } @@ -877,87 +813,47 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } fun postLevelTick(event: LevelTickEvent) { - if (event.phase == TickEvent.Phase.END) { - val level = event.level as? ServerLevel ?: return - val listing = tickingMap[level] ?: return - val listIterator = listing.listIterator() - var hitAnyObservers = false + val level = event.level as? ServerLevel ?: return + val ticking = tickingMap[level] ?: return - for (value in listIterator) { - val ref = value.get() + ticking.removeIf { + val shouldRemove = it.blockEntitiesWithObservers.isEmpty() - if (ref == null) { - listIterator.remove() - } else if (ref.players.isNotEmpty()) { - var hitObservers = false - - ref.observingBlockEntities.forValidRefs { - hitObservers = true - hitAnyObservers = true - it.synchronizeToPlayers() - } - - if (!hitObservers) { - listIterator.remove() - } + if (!shouldRemove && it.players.isNotEmpty()) { + it.blockEntitiesWithObservers.forEach { + it.synchronizeToPlayers(false) } } - if (!hitAnyObservers) { - tickingMap.remove(level) - } + shouldRemove + } + + if (ticking.isEmpty()) { + tickingMap.remove(level) } } fun onWatch(event: ChunkWatchEvent.Watch) { playerMap .computeIfAbsent(event.level) { Long2ObjectOpenHashMap() } - .computeIfAbsent(event.pos.toLong(), Long2ObjectFunction { ChunkSubscribers(level = WeakReference(event.level), chunkPos = event.pos.toLong()) }) - .let { - val (blocks, players) = it - - if (event.player !in players) { - players.add(event.player) - it.changeset++ - - onceServer(10) { - if (!event.player.hasDisconnected() && event.player in players) { - blocks.forValidRefs { - it.synchronizeToPlayers(false) - } - } - } - } - } + .computeIfAbsent(event.pos.toLong(), Long2ObjectFunction { ChunkSubscribers(event.level, it) }) + .subscribe(event.player) } fun onForget(event: ChunkWatchEvent.UnWatch) { - val subs = playerMap.get(event.level)?.get(event.pos.toLong()) ?: return + val levelMap = playerMap[event.level] ?: return + val subs = levelMap.get(event.pos.toLong()) ?: return - if (subs.players.remove(event.player)) { - if (subs.isEmpty) { - playerMap.get(event.level)?.remove(event.pos.toLong()) - } else { - subs.changeset++ - subs.blockEntities.forValidRefs { - it.synchronizer.removeEndpointFor(event.player) - } - } + if (subs.unsubscribe(event.player) && subs.isEmpty) { + levelMap.remove(event.pos.toLong()) } } fun playerDisconnected(event: PlayerEvent.PlayerLoggedOutEvent) { for (tree in playerMap.values) { - val iterator = tree.iterator() - - for (entry in iterator) { - if (entry.value.players.remove(event.entity)) { - entry.value.changeset++ - - if (entry.value.isEmpty) { - iterator.remove() - } - } + tree.values.removeIf { + it.unsubscribe(event.entity as ServerPlayer) + it.isEmpty } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/WeakHashSet.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/WeakHashSet.kt index 34c18d641..6464b7d87 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/WeakHashSet.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/WeakHashSet.kt @@ -1,12 +1,14 @@ package ru.dbotthepony.mc.otm.core.collect +import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenCustomHashSet import it.unimi.dsi.fastutil.objects.ObjectOpenCustomHashSet +import it.unimi.dsi.fastutil.objects.ObjectSet import ru.dbotthepony.mc.otm.core.util.HashedWeakReference import java.lang.ref.ReferenceQueue -class WeakHashSet : MutableSet { +class WeakHashSet(initialCapacity: Int = 16, loadFactor: Float = 0.75f, linked: Boolean = false) : MutableSet { private val queue = ReferenceQueue() - private val backing = ObjectOpenCustomHashSet(ReferenceHashStrategy) + private val backing: ObjectSet = if (linked) ObjectLinkedOpenCustomHashSet(initialCapacity, loadFactor, ReferenceHashStrategy) else ObjectOpenCustomHashSet(initialCapacity, loadFactor, ReferenceHashStrategy) private fun purge() { var next = queue.poll() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt index dc52d38c9..2e0051b61 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt @@ -66,10 +66,13 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa private var nextFieldID = 0 val hasObservers: Boolean get() = observers.isNotEmpty() - val isEmpty: Boolean get() = fields.isEmpty() - val isNotEmpty: Boolean get() = fields.isNotEmpty() - var hasChanges: Boolean = false + var isEmpty: Boolean = true + private set + + val isNotEmpty: Boolean get() = !isEmpty + + var isDirty: Boolean = false private set(value) { if (value != field) { field = value @@ -85,7 +88,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } fun markClean() { - hasChanges = false + isDirty = false } fun computedByte(getter: () -> Byte) = ComputedField(getter, ByteValueCodec) @@ -301,7 +304,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa private var nextEndpointsCleanup = secondTime private fun notifyEndpoints(dirtyField: AbstractField<*>) { - hasChanges = true + isDirty = true forEachEndpoint { it.addDirtyField(dirtyField) @@ -480,6 +483,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } else { fields.add(this) id = fields.size + isEmpty = false } } @@ -496,6 +500,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa freeSlots++ fields[id - 1] = null observers.remove(this) + isEmpty = fields.all { it == null } while (fields[fields.size - 1] == null) { fields.removeAt(fields.size - 1) @@ -1994,7 +1999,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa } lmarkDirty() - hasChanges = true + this@FieldSynchronizer.isDirty = true } override fun onValueAdded(key: K, value: V) { From f0f1a3cffe972cf8a38e51cb0790834a2e230f2c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 17 Aug 2023 14:15:05 +0700 Subject: [PATCH 0976/1199] Fix adding timers not making ticklist dirty --- src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt index 3b74ac44b..62cfb08f1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt @@ -32,6 +32,7 @@ class TickList : ITickable { private set init { + shouldTick = true timers.addSorted(this) } From 77e6eebe9211eeb777452005569239545c3800bc Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 17 Aug 2023 14:15:27 +0700 Subject: [PATCH 0977/1199] If blockentity is ticking, don't synchronize to newly subscribed players right away --- .../mc/otm/block/entity/MatteryBlockEntity.kt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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 6bbffcef2..1714205fe 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 @@ -642,10 +642,12 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc playerListUpdated = false for (player in subscription.players) { - val payload = synchronizer.computeEndpointFor(player).collectNetworkPayload() + if (player !in subscription.veto) { + val payload = synchronizer.computeEndpointFor(player).collectNetworkPayload() - if (payload != null) { - GenericNetworkChannel.send(player, BlockEntitySyncPacket(blockPos, payload.array, payload.length)) + if (payload != null) { + GenericNetworkChannel.send(player, BlockEntitySyncPacket(blockPos, payload.array, payload.length)) + } } } @@ -662,6 +664,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc val level = WeakReference(level) val blockEntities = WeakHashSet(linked = true, initialCapacity = 0) val players = ObjectLinkedOpenHashSet(0) + val veto = ObjectLinkedOpenHashSet(0) val blockEntitiesWithObservers = WeakHashSet(linked = true, initialCapacity = 0) operator fun component1() = blockEntities @@ -673,9 +676,12 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc fun subscribe(player: ServerPlayer) { if (players.add(player)) { - blockEntities.forEach { it.playerListUpdated = true } + veto.add(player) onceServer(10) { + veto.remove(player) + blockEntities.forEach { it.playerListUpdated = true } + if (!player.hasDisconnected() && player in players) { blockEntities.forEach { it.synchronizeToPlayers(false) @@ -687,6 +693,8 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc fun unsubscribe(player: ServerPlayer): Boolean { if (players.remove(player)) { + veto.remove(player) + blockEntities.forEach { it.synchronizer.removeEndpointFor(player) } From dba1e1e4a5edf279f06e6b5ae0b9c9b798e836ac Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 17 Aug 2023 14:29:38 +0700 Subject: [PATCH 0978/1199] Add weak hash set test --- .../mc/otm/tests/WeakHashSetTests.kt | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/test/kotlin/ru/dbotthepony/mc/otm/tests/WeakHashSetTests.kt diff --git a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/WeakHashSetTests.kt b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/WeakHashSetTests.kt new file mode 100644 index 000000000..38bf57250 --- /dev/null +++ b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/WeakHashSetTests.kt @@ -0,0 +1,57 @@ +package ru.dbotthepony.mc.otm.tests + +import org.junit.jupiter.api.DisplayName +import org.junit.jupiter.api.Test +import ru.dbotthepony.mc.otm.core.collect.WeakHashSet +import ru.dbotthepony.mc.otm.core.collect.forEach + +object WeakHashSetTests { + @Test + @DisplayName("WeakHashSet additions") + fun add() { + val set = WeakHashSet() + + check(set.add(1)) + check(set.add(2)) + check(set.add(3)) + check(!set.add(3)) + check(set.add(10)) + check(set.add(15)) + check(!set.add(15)) + check(!set.add(1)) + } + + @Test + @DisplayName("WeakHashSet removals") + fun remove() { + val set = WeakHashSet() + + check(set.add(1)) + check(set.add(2)) + check(set.add(3)) + + check(set.remove(1)) + check(set.remove(2)) + check(set.remove(3)) + + check(!set.remove(4)) + } + + @Test + @DisplayName("WeakHashSet traversal") + fun traversal() { + val set = WeakHashSet() + + check(set.add(1)) + check(set.add(2)) + check(set.add(3)) + check(set.add(5)) + check(set.add(6)) + check(set.remove(1)) + + val set2 = mutableSetOf(2, 3, 5, 6) + check(set.containsAll(set2)) + + set.iterator().forEach { check(set2.remove(it)) } + } +} From 04524db1a56435ac3fa47d8dfbede5da64d065c4 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 17 Aug 2023 14:33:26 +0700 Subject: [PATCH 0979/1199] TickList tests --- .../{TimerQueueTests.kt => TickListTests.kt} | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) rename src/test/kotlin/ru/dbotthepony/mc/otm/tests/{TimerQueueTests.kt => TickListTests.kt} (66%) diff --git a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/TimerQueueTests.kt b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/TickListTests.kt similarity index 66% rename from src/test/kotlin/ru/dbotthepony/mc/otm/tests/TimerQueueTests.kt rename to src/test/kotlin/ru/dbotthepony/mc/otm/tests/TickListTests.kt index d38e66af7..b489731ef 100644 --- a/src/test/kotlin/ru/dbotthepony/mc/otm/tests/TimerQueueTests.kt +++ b/src/test/kotlin/ru/dbotthepony/mc/otm/tests/TickListTests.kt @@ -5,10 +5,10 @@ import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test import ru.dbotthepony.mc.otm.core.util.TickList -object TimerQueueTests { +object TickListTests { @Test - @DisplayName("TimerQueue test") - fun test() { + @DisplayName("TickList.Timer test") + fun timers() { val queue = TickList() var state = 0 @@ -37,4 +37,27 @@ object TimerQueueTests { queue.tick() // 8 assertEquals(7, state) } + + @Test + @DisplayName("TickList test") + fun ticks() { + val list = TickList() + + var a = false + var b = 0 + var c = 0 + + list.once { a = true } + list.add { ++b < 4 } + list.always { c++ } + + for (i in 0 .. 10) { + list.tick() + } + + assertEquals(11, list.ticks) + assertEquals(11, c) + assertEquals(true, a) + assertEquals(4, b) + } } From e6758f1e271081a39edc6084677654ffc25b997f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 17 Aug 2023 22:26:43 +0700 Subject: [PATCH 0980/1199] Matter entangler, ingredient matrix, shadow containers, quantum battery recipes, more JEI compat --- .../ru/dbotthepony/mc/otm/datagen/DataGen.kt | 2 + .../mc/otm/datagen/lang/English.kt | 3 + .../mc/otm/datagen/lang/Russian.kt | 1 + .../mc/otm/datagen/loot/LootTablesData.kt | 1 + .../datagen/recipes/MatterEntanglerRecipes.kt | 43 +++++ .../dbotthepony/mc/otm/datagen/tags/Tags.kt | 1 + .../dbotthepony/mc/otm/block/entity/Jobs.kt | 9 +- .../entity/decorative/PainterBlockEntity.kt | 2 +- .../matter/MatterEntanglerBlockEntity.kt | 157 ++++++++++++++++ .../otm/block/matter/MatterEntanglerBlock.kt | 22 +++ .../ru/dbotthepony/mc/otm/capability/Ext.kt | 2 + .../client/screen/ExopackInventoryScreen.kt | 3 +- .../mc/otm/client/screen/MatteryScreen.kt | 10 +- .../{tech => decorative}/PainterScreen.kt | 4 +- .../screen/matter/MatterEntanglerScreen.kt | 75 ++++++++ .../otm/client/screen/panels/EditablePanel.kt | 4 + .../client/screen/tech/EnergyCounterScreen.kt | 2 +- .../client/screen/widget/MatterGaugePanel.kt | 42 +++-- .../dbotthepony/mc/otm/compat/jei/Gauges.kt | 50 ++++++ .../mc/otm/compat/jei/JEIPlugin.kt | 4 + .../jei/MatterEntanglerRecipeCategory.kt | 91 ++++++++++ .../otm/compat/jei/PainterRecipeCategory.kt | 4 +- .../mc/otm/config/MachinesConfig.kt | 8 + .../ru/dbotthepony/mc/otm/container/Ext.kt | 12 ++ .../mc/otm/container/MatteryContainer.kt | 68 ++++++- .../otm/container/MatteryCraftingContainer.kt | 22 +++ .../mc/otm/container/ShadowContainer.kt | 48 +++++ .../otm/container/ShadowCraftingContainer.kt | 33 ++++ .../mc/otm/core/collect/StreamyIterators.kt | 31 ++++ .../mc/otm/data/Codec2RecipeSerializer.kt | 109 ++++++----- .../mc/otm/data/IngredientMatrixCodec.kt | 111 ++++++++++++ .../dbotthepony/mc/otm/item/IQuantumLinked.kt | 7 + .../mc/otm/item/QuantumBatteryItem.kt | 10 +- .../mc/otm/menu/ExopackInventoryMenu.kt | 20 +-- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 28 +-- .../ru/dbotthepony/mc/otm/menu/Slots.kt | 3 +- .../mc/otm/menu/decorative/FluidTankMenu.kt | 5 +- .../menu/{tech => decorative}/PainterMenu.kt | 2 +- .../otm/menu/matter/MatterDecomposerMenu.kt | 12 +- .../mc/otm/menu/matter/MatterEntanglerMenu.kt | 130 ++++++++++++++ .../mc/otm/menu/matter/MatterPanelMenu.kt | 8 +- .../otm/menu/matter/MatterReplicatorMenu.kt | 6 +- .../mc/otm/menu/storage/DriveViewerMenu.kt | 4 +- .../mc/otm/menu/storage/ItemMonitorMenu.kt | 12 +- .../mc/otm/menu/tech/AndroidStationMenu.kt | 4 +- .../mc/otm/menu/tech/CobblerMenu.kt | 4 +- .../mc/otm/menu/tech/EssenceStorageMenu.kt | 4 +- .../mc/otm/menu/tech/PlatePressMenu.kt | 4 +- .../mc/otm/menu/tech/PoweredFurnaceMenu.kt | 4 +- .../mc/otm/menu/tech/TwinPlatePressMenu.kt | 4 +- .../mc/otm/recipe/IMatteryRecipe.kt | 41 +++++ .../mc/otm/recipe/IngredientMatrix.kt | 151 ++++++++++++++++ .../mc/otm/recipe/MatterEntanglerRecipe.kt | 170 ++++++++++++++++++ .../mc/otm/recipe/PainterRecipe.kt | 2 +- .../mc/otm/recipe/PlatePressRecipe.kt | 2 +- .../mc/otm/registry/MBlockEntities.kt | 1 + .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 2 + .../ru/dbotthepony/mc/otm/registry/MItems.kt | 3 +- .../ru/dbotthepony/mc/otm/registry/MMenus.kt | 8 +- .../ru/dbotthepony/mc/otm/registry/MNames.kt | 1 + .../dbotthepony/mc/otm/registry/MRecipes.kt | 6 + 61 files changed, 1480 insertions(+), 152 deletions(-) create mode 100644 src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatterEntanglerRecipes.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterEntanglerBlockEntity.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterEntanglerBlock.kt rename src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/{tech => decorative}/PainterScreen.kt (97%) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterEntanglerScreen.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/Gauges.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryCraftingContainer.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowContainer.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowCraftingContainer.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientMatrixCodec.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/item/IQuantumLinked.kt rename src/main/kotlin/ru/dbotthepony/mc/otm/menu/{tech => decorative}/PainterMenu.kt (98%) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterEntanglerMenu.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/recipe/IMatteryRecipe.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/recipe/IngredientMatrix.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt index 4f9fb145e..c148d0f68 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -48,6 +48,7 @@ import ru.dbotthepony.mc.otm.datagen.models.addBlockModels import ru.dbotthepony.mc.otm.datagen.recipes.addBlastingRecipes import ru.dbotthepony.mc.otm.datagen.recipes.addCraftingTableRecipes import ru.dbotthepony.mc.otm.datagen.recipes.addDecorativesRecipes +import ru.dbotthepony.mc.otm.datagen.recipes.addMatterEntanglerRecipes import ru.dbotthepony.mc.otm.datagen.recipes.addPlatePressRecipes import ru.dbotthepony.mc.otm.datagen.recipes.addShapelessRecipes import ru.dbotthepony.mc.otm.datagen.recipes.addOreSmeltingRecipes @@ -564,6 +565,7 @@ object DataGen { addShapelessRecipes(consumer) addOreSmeltingRecipes(consumer) addPainterRecipes(consumer) + addMatterEntanglerRecipes(consumer) } addPlatePressRecipes(recipeProvider) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index b8efe97d4..552ad9e19 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -432,6 +432,7 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.DEV_CHEST, "Dev Chest") add(MBlocks.DEV_CHEST, "desc", "Contains all items present in game") add(MBlocks.PAINTER, "Painting Table") + add(MBlocks.MATTER_ENTANGLER, "Matter Entangler") add(MBlocks.FLUID_TANK, "Fluid Tank") add(MBlocks.FLUID_TANK, "named", "Fluid Tank (%s)") @@ -713,6 +714,8 @@ private fun gui(provider: MatteryLanguageProvider) { with(provider.english) { gui("quicksearch", "Quick search...") + gui("energy_required", "Energy required: %s") + gui("insert_priority", "Insert priority") gui("extract_priority", "Extract priority") gui("increase", "Increase") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 6bc478530..6aea07d4d 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -434,6 +434,7 @@ private fun blocks(provider: MatteryLanguageProvider) { add(MBlocks.DEV_CHEST, "Сундук разработчика") add(MBlocks.DEV_CHEST, "desc", "Хранит все предметы, которые есть в игре") add(MBlocks.PAINTER, "Стол маляра") + add(MBlocks.MATTER_ENTANGLER, "Квантовый запутыватель материи") add(MBlocks.FLUID_TANK, "Жидкостный бак") add(MBlocks.FLUID_TANK, "named", "Жидкостный бак (%s)") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index b21b8f15a..f3a46e108 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -134,6 +134,7 @@ fun addLootTables(lootTables: LootTables) { lootTables.tile(MBlocks.MATTER_RECONSTRUCTOR) lootTables.tile(MBlocks.FLUID_TANK) lootTables.tile(MBlocks.PAINTER) + lootTables.tile(MBlocks.MATTER_ENTANGLER) lootTables.tile(MBlocks.ENERGY_SERVO) lootTables.tile(MBlocks.ENERGY_COUNTER) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatterEntanglerRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatterEntanglerRecipes.kt new file mode 100644 index 000000000..dc20725d1 --- /dev/null +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatterEntanglerRecipes.kt @@ -0,0 +1,43 @@ +package ru.dbotthepony.mc.otm.datagen.recipes + +import net.minecraft.data.recipes.FinishedRecipe +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.crafting.Ingredient +import net.minecraftforge.common.Tags +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.datagen.modLocation +import ru.dbotthepony.mc.otm.recipe.IngredientMatrix +import ru.dbotthepony.mc.otm.recipe.MatterEntanglerRecipe +import ru.dbotthepony.mc.otm.registry.MItemTags +import ru.dbotthepony.mc.otm.registry.MItems +import java.util.function.Consumer + +fun addMatterEntanglerRecipes(consumer: Consumer) { + consumer.accept( + MatterEntanglerRecipe( + modLocation("quantum_capacitor"), + IngredientMatrix.of( + listOf(Ingredient.of(MItems.ELECTRIC_PARTS), Ingredient.of(MItemTags.GOLD_WIRES), Ingredient.of(MItems.ELECTRIC_PARTS)), + listOf(Ingredient.of(MItems.BATTERY_CAPACITOR), Ingredient.of(MItems.QUANTUM_TRANSCEIVER), Ingredient.of(MItems.BATTERY_CAPACITOR)), + listOf(Ingredient.of(MItemTags.TRITANIUM_PLATES), Ingredient.of(MItemTags.TRITANIUM_PLATES), Ingredient.of(MItemTags.TRITANIUM_PLATES)), + ), + Decimal(40), + 400.0, + ItemStack(MItems.QUANTUM_CAPACITOR, 2) + ).energetic().toFinished() + ) + + consumer.accept( + MatterEntanglerRecipe( + modLocation("quantum_battery"), + IngredientMatrix.of( + listOf(Ingredient.of(Tags.Items.STORAGE_BLOCKS_REDSTONE), Ingredient.of(MItemTags.GOLD_WIRES), Ingredient.of(Tags.Items.STORAGE_BLOCKS_REDSTONE)), + listOf(Ingredient.of(MItems.BATTERY_DENSE), Ingredient.of(MItems.QUANTUM_TRANSCEIVER), Ingredient.of(MItems.BATTERY_DENSE)), + listOf(Ingredient.of(MItemTags.TRITANIUM_PLATES), Ingredient.of(MItemTags.TRITANIUM_PLATES), Ingredient.of(MItemTags.TRITANIUM_PLATES)), + ), + Decimal(120), + 600.0, + ItemStack(MItems.QUANTUM_BATTERY, 2) + ).energetic().toFinished() + ) +} diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index 26236c319..1563e0e75 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -162,6 +162,7 @@ fun addTags(tagsProvider: TagsProvider) { MBlocks.PLATE_PRESS, MBlocks.TWIN_PLATE_PRESS, MBlocks.MATTER_RECYCLER, + MBlocks.MATTER_ENTANGLER, MBlocks.POWERED_FURNACE, MBlocks.POWERED_SMOKER, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt index 7ae32ce37..4ec6d1285 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/Jobs.kt @@ -306,8 +306,10 @@ abstract class MachineJobEventLoop(val codec: Codec) : } } + private var lastTickWasError = false + val isUnableToProcess: Boolean - get() = throttleTicks > 0 + get() = throttleTicks > 0 || lastTickWasError val workProgress: Float get() { @@ -392,6 +394,8 @@ abstract class MachineJobEventLoop(val codec: Codec) : isIdling = false } + lastTickWasError = false + if (isIdling) { workingTicksAnim = 0 errorTicksAnim = 0 @@ -430,6 +434,7 @@ abstract class MachineJobEventLoop(val codec: Codec) : idleReason = IdleReason.POWER isIdling = true idleTicksAnim++ + lastTickWasError = true break } @@ -467,6 +472,7 @@ abstract class MachineJobEventLoop(val codec: Codec) : if (!status.success) { throttleTicks += status.throttleTicks + lastTickWasError = true if (status.idleReason != null) { idleReason = status.idleReason @@ -505,6 +511,7 @@ abstract class MachineJobEventLoop(val codec: Codec) : errorTicksAnim = 0 } else { throttleTicks += status.throttleTicks + lastTickWasError = true if (status.idleReason != null) { idleReason = status.idleReason 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 19dd30f42..6b1bee031 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 @@ -17,7 +17,7 @@ import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.immutableMap import ru.dbotthepony.mc.otm.core.nbt.mapPresent import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.menu.tech.PainterMenu +import ru.dbotthepony.mc.otm.menu.decorative.PainterMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import java.util.* diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterEntanglerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterEntanglerBlockEntity.kt new file mode 100644 index 000000000..266eb09a4 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterEntanglerBlockEntity.kt @@ -0,0 +1,157 @@ +package ru.dbotthepony.mc.otm.block.entity.matter + +import com.mojang.serialization.Codec +import com.mojang.serialization.codecs.RecordCodecBuilder +import net.minecraft.core.BlockPos +import net.minecraft.world.entity.player.Inventory +import net.minecraft.world.entity.player.Player +import net.minecraft.world.inventory.AbstractContainerMenu +import net.minecraft.world.item.ItemStack +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.state.BlockState +import ru.dbotthepony.mc.otm.block.entity.ItemJob +import ru.dbotthepony.mc.otm.block.entity.JobContainer +import ru.dbotthepony.mc.otm.block.entity.JobStatus +import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity +import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.UpgradeType +import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage +import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl +import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage +import ru.dbotthepony.mc.otm.config.MachinesConfig +import ru.dbotthepony.mc.otm.container.MatteryCraftingContainer +import ru.dbotthepony.mc.otm.container.HandlerFilter +import ru.dbotthepony.mc.otm.container.MatteryContainer +import ru.dbotthepony.mc.otm.container.ShadowCraftingContainer +import ru.dbotthepony.mc.otm.container.UpgradeContainer +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.data.DecimalCodec +import ru.dbotthepony.mc.otm.data.minRange +import ru.dbotthepony.mc.otm.graph.matter.MatterNode +import ru.dbotthepony.mc.otm.menu.matter.MatterEntanglerMenu +import ru.dbotthepony.mc.otm.registry.MBlockEntities +import ru.dbotthepony.mc.otm.registry.MRecipes + +class MatterEntanglerBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryWorkerBlockEntity(MBlockEntities.MATTER_ENTANGLER, blockPos, blockState, Job.CODEC) { + class Job(itemStack: ItemStack, val matter: Decimal, ticks: Double) : ItemJob(itemStack, ticks, MachinesConfig.MATTER_ENTANGLER.energyConsumption) { + val matterPerTick = matter / ticks + + companion object { + val CODEC: Codec = RecordCodecBuilder.create { + it.group( + ItemStack.CODEC.fieldOf("itemStack").forGetter(ItemJob::itemStack), + DecimalCodec.minRange(Decimal.ZERO).fieldOf("matter").forGetter(Job::matter), + Codec.DOUBLE.minRange(0.0).fieldOf("ticks").forGetter(ItemJob::ticks), + ).apply(it, ::Job) + } + } + } + + override val upgrades = UpgradeContainer(::markDirtyFast, 3, UpgradeType.BASIC_MATTER) + override val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::energyLevelUpdated, upgrades.transform(MachinesConfig.MATTER_ENTANGLER))) + val matter = ProfiledMatterStorage(MatterStorageImpl(::markDirtyFast, FlowDirection.INPUT, upgrades.matterCapacity(MachinesConfig.MATTER_ENTANGLER::matterCapacity))) + val node = MatterNode() + + val energyConfig = ConfigurableEnergy(energy) + + val inputs = object : MatteryCraftingContainer(::itemContainerUpdated, 3, 3) { + override fun getMaxStackSize(): Int { + return 1 + } + } + + val output = object : MatteryContainer(::itemContainerUpdated, 1) { + override fun getMaxStackSize(slot: Int, itemStack: ItemStack): Int { + return Int.MAX_VALUE + } + } + + val itemConfig = ConfigurableItemHandler( + input = inputs.handler(object : HandlerFilter { + override fun canInsert(slot: Int, stack: ItemStack): Boolean { + val shadow = ShadowCraftingContainer.shadow(inputs, slot, stack) + + return (level ?: return false) + .recipeManager + .byType(MRecipes.MATTER_ENTANGLER) + .values + .any { it.preemptivelyMatches(shadow, level!!) } + } + + override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { + return false + } + }), + output = output.handler(HandlerFilter.OnlyOut) + ) + + init { + savetables.stateful(::energy, ENERGY_KEY) + savetables.stateful(::matter, MATTER_STORAGE_KEY) + savetables.stateful(::upgrades) + savetables.stateful(::inputs) + savetables.stateful(::output) + + exposeGlobally(MatteryCapability.MATTER_NODE, node) + exposeGlobally(MatteryCapability.MATTER, matter) + } + + override fun setLevel(level: Level) { + super.setLevel(level) + node.discover(this) + } + + override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu? { + return MatterEntanglerMenu(containerID, inventory, this) + } + + override fun onJobTick(status: JobStatus, id: Int) { + val required = status.job.matterPerTick * status.ticksAdvanced + + if (matter.storedMatter < required) { + matter.receiveMatter(node.graph.extractMatter(status.job.matterPerTick.coerceAtLeast(Decimal.TEN).coerceAtMost(matter.missingMatter), false), false) + } + + status.scale(matter.extractMatter(required, false) / required) + } + + override fun tick() { + super.tick() + + if (jobEventLoops[0].currentJob == null) { + matter.extractMatter(node.graph.receiveMatter(matter.storedMatter, false), false) + } + } + + override fun onJobFinish(status: JobStatus, id: Int) { + if (!output.fullyAddItem(status.job.itemStack)) { + status.noItem() + } + } + + override fun computeNextJob(id: Int): JobContainer { + if (!energy.batteryLevel.isPositive) + return JobContainer.noEnergy() + + val recipe = (level ?: return JobContainer.failure()) + .recipeManager + .byType(MRecipes.MATTER_ENTANGLER) + .values + .firstOrNull { it.matches(inputs, level!!) } ?: return JobContainer.noItem() + + val result = recipe.assemble(inputs, level!!.registryAccess()) + + inputs.forEach { it.shrink(1) } + inputs.setChanged() + + return JobContainer.success( + Job( + result, + recipe.matter, + recipe.ticks * MachinesConfig.MATTER_ENTANGLER.workTimeMultiplier + ) + ) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterEntanglerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterEntanglerBlock.kt new file mode 100644 index 000000000..23427703f --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterEntanglerBlock.kt @@ -0,0 +1,22 @@ +package ru.dbotthepony.mc.otm.block.matter + +import net.minecraft.core.BlockPos +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.EntityBlock +import net.minecraft.world.level.block.entity.BlockEntity +import net.minecraft.world.level.block.entity.BlockEntityTicker +import net.minecraft.world.level.block.entity.BlockEntityType +import net.minecraft.world.level.block.state.BlockState +import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock +import ru.dbotthepony.mc.otm.block.entity.matter.MatterEntanglerBlockEntity + +class MatterEntanglerBlock : RotatableMatteryBlock(), EntityBlock { + override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { + return MatterEntanglerBlockEntity(blockPos, blockState) + } + + override fun getTicker(p_153212_: Level, p_153213_: BlockState, p_153214_: BlockEntityType): BlockEntityTicker? { + if (p_153212_.isClientSide) return null + return BlockEntityTicker { _, _, _, tile -> if (tile is MatterEntanglerBlockEntity) tile.tick() } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt index c0bde449d..5c9af7a51 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt @@ -230,6 +230,8 @@ fun Player.items(includeCosmetics: Boolean = true): Iterator { matteryPlayer?.let { if (it.hasExopack) { iterators.add(it.exopackContainer.iterator()) + iterators.add(it.exopackEnergy.parent.iterator()) + iterators.add(it.exopackChargeSlots.iterator()) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt index b978a9521..2dad7fb4e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.client.screen -import com.mojang.blaze3d.platform.InputConstants import net.minecraft.client.gui.screens.inventory.InventoryScreen import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items @@ -276,7 +275,7 @@ class ExopackInventoryScreen(menu: ExopackInventoryMenu) : MatteryScreen(menu: T, inventory: Inventory, tit if (menu.playerExoSuitSlots.isEmpty()) { inventoryFrame = FramePanel>(this, null, 0f, 0f, INVENTORY_FRAME_WIDTH, INVENTORY_FRAME_HEIGHT, inventory.displayName).also(this::addPanel) inventoryFrame!!.makeHelpButton().addSlotFiltersHelp().also { - if (menu.ply.matteryPlayer?.hasExopack == true) + if (menu.player.matteryPlayer?.hasExopack == true) it.tooltips.add(TranslatableComponent("otm.gui.help.slot_charging")) } @@ -236,7 +236,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } else { inventoryFrame = FramePanel>(this, null, 0f, 0f, INVENTORY_FRAME_WIDTH_EXTENDED, BASE_INVENTORY_FRAME_HEIGHT + AbstractSlotPanel.SIZE * inventoryRows, inventory.displayName).also(this::addPanel) inventoryFrame!!.makeHelpButton().addSlotFiltersHelp().also { - if (menu.ply.matteryPlayer?.hasExopack == true) + if (menu.player.matteryPlayer?.hasExopack == true) it.tooltips.add(TranslatableComponent("otm.gui.help.slot_charging")) } @@ -421,7 +421,9 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } } - if (matter != null) { + if (profiledMatter != null) { + ProfiledMatterGaugePanel(this, gauges, profiledMatter).dock = Dock.LEFT + } else if (matter != null) { MatterGaugePanel(this, gauges, matter).dock = Dock.LEFT } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PainterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/PainterScreen.kt similarity index 97% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PainterScreen.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/PainterScreen.kt index b85fe86df..8ef2980bd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PainterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/PainterScreen.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.client.screen.tech +package ru.dbotthepony.mc.otm.client.screen.decorative import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component @@ -27,7 +27,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.util.ScrollableCanvasPanel import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.RGBAColor -import ru.dbotthepony.mc.otm.menu.tech.PainterMenu +import ru.dbotthepony.mc.otm.menu.decorative.PainterMenu class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { inner class Bar(parent: EditablePanel<*>, val dye: DyeColor) : EditablePanel(this@PainterScreen, parent, width = 5f) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterEntanglerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterEntanglerScreen.kt new file mode 100644 index 000000000..1141205bf --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterEntanglerScreen.kt @@ -0,0 +1,75 @@ +package ru.dbotthepony.mc.otm.client.screen.matter + +import net.minecraft.network.chat.Component +import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.Dock +import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.SpritePanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.DeviceControls +import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel +import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel +import ru.dbotthepony.mc.otm.menu.matter.MatterEntanglerMenu + +class MatterEntanglerScreen(menu: MatterEntanglerMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { + override fun makeMainFrame(): FramePanel> { + val frame = FramePanel(this, DEFAULT_FRAME_WIDTH, 110f, title) + + makeBars(frame, profiledEnergy = menu.profiledEnergy, profiledMatter = menu.profiledMatter, batterySlot = menu.batterySlot) + + GridPanel.slots(this, frame, 3, 3).also { + it.dock = Dock.LEFT + it.dockLeft = 20f + it.dockRight = 4f + it.dockResize = DockResizeMode.NONE + + for (slot in menu.inputs) + SlotPanel(this, it, slot) + } + + ProgressGaugePanel(this, frame, menu.progress).also { + it.dock = Dock.LEFT + it.dockHorizontal(4f) + it.dockResize = DockResizeMode.NONE + } + + SlotPanel(this, frame, menu.outputs[0]).also { + it.dock = Dock.LEFT + it.dockHorizontal(4f) + it.dockResize = DockResizeMode.NONE + } + + val strip = EditablePanel(this, frame, height = AbstractSlotPanel.SIZE) + strip.dock = Dock.BOTTOM + strip.dockTop = 4f + strip.childrenOrder = -1 + + SlotPanel(this, strip, menu.entanglingA).also { + it.dock = Dock.LEFT + it.dockLeft = 20f + } + + SlotPanel(this, strip, menu.entanglingB).also { + it.dock = Dock.LEFT + it.dockLeft = 4f + } + + SpritePanel(this, strip, ProgressGaugePanel.GAUGE_BACKGROUND).also { + it.dock = Dock.FILL + it.dockResize = DockResizeMode.NONE + } + + SlotPanel(this, strip, menu.entanglingC).also { + it.dock = Dock.RIGHT + it.dockRight = 20f + } + + DeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, upgrades = menu.upgrades, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig) + + return frame + } +} 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 55fbb498d..c09da8d5c 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 @@ -346,6 +346,10 @@ open class EditablePanel @JvmOverloads constructor( } } + fun dockHorizontal(value: Float) { + dockMargin = dockMargin.copy(left = value, right = value) + } + var dockTop: Float get() = dockMargin.top set(value) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt index b8a2c2060..838d9e2a6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyCounterScreen.kt @@ -41,7 +41,7 @@ class EnergyCounterScreen(menu: EnergyCounterMenu, inventory: Inventory, title: label.dock = Dock.TOP } - if (!menu.ply.isSpectator) { + if (!menu.player.isSpectator) { val button = ButtonPanel(this, frame, 0f, 0f, 0f, 20f, TranslatableComponent("block.overdrive_that_matters.energy_counter.switch"), onPress = Runnable { menu.switchDirection.accept(null) }) button.dock = Dock.TOP button.setDockMargin(4f, 5f, 4f, 0f) 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 ec764b57e..4a94e9d9c 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 @@ -79,9 +79,28 @@ open class MatterGaugePanel @JvmOverloads constructor( } GAUGE_BACKGROUND.render(graphics) - val height = this.height * (1f - widget.percentage) if (widget.percentage > 0.01f) { + renderLevel(graphics, 0f, 0f, width, height, widget.percentage, wavesStrength) + } + } + + override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + if (isHovered) { + graphics.renderComponentTooltip(font, makeTooltip(), mouseX.toInt(), mouseY.toInt()) + return true + } + + return false + } + + companion object { + val GAUGE_BACKGROUND = WidgetLocation.VERTICAL_GAUGES.sprite(x = 18f, width = 9f) + val GAUGE_FOREGROUND = WidgetLocation.VERTICAL_GAUGES.sprite(x = 27f, width = 9f) + + fun renderLevel(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, percentage: Float, wavesStrength: Float = 0.5f) { + graphics.pose().pushPose() + graphics.pose().translate(x, y, 0f) RenderSystem.setShader(GameRenderer::getPositionTexShader) RenderSystem.enableBlend() RenderSystem.defaultBlendFunc() @@ -98,15 +117,15 @@ open class MatterGaugePanel @JvmOverloads constructor( builder.begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_TEX) - builder.vertex(matrix, 0f, this.height, 0f).uv(u0, v1).endVertex() - builder.vertex(matrix, width, this.height, 0f).uv(u1, v1).endVertex() + builder.vertex(matrix, 0f, height, 0f).uv(u0, v1).endVertex() + builder.vertex(matrix, width, height, 0f).uv(u1, v1).endVertex() for (i in 4 downTo 0) { val sin = sin((System.currentTimeMillis() / 50L + i * 2L).toDouble() / 4.0).toFloat() * wavesStrength.coerceAtMost(4f) val cos = cos((System.currentTimeMillis() / 50L + i * 3L + 27L).toDouble() / 4.0).toFloat() * wavesStrength.coerceAtMost(4f) val thisX = (width * (i / 4f)) - val thisY = (height + sin + cos).coerceAtLeast(0f) + val thisY = (height * (1f - percentage) + sin + cos).coerceAtLeast(0f) builder.vertex(matrix, thisX, thisY, 0f).uv( GAUGE_FOREGROUND.partialU((i / 4f) * GAUGE_FOREGROUND.width), @@ -115,22 +134,9 @@ open class MatterGaugePanel @JvmOverloads constructor( } BufferUploader.drawWithShader(builder.end()) + graphics.pose().popPose() } } - - override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { - if (isHovered) { - graphics.renderComponentTooltip(font, makeTooltip(), mouseX.toInt(), mouseY.toInt()) - return true - } - - return false - } - - companion object { - val GAUGE_BACKGROUND = WidgetLocation.VERTICAL_GAUGES.sprite(x = 18f, width = 9f) - val GAUGE_FOREGROUND = WidgetLocation.VERTICAL_GAUGES.sprite(x = 27f, width = 9f) - } } private fun formatLevel(a: Decimal, b: Decimal): Component { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/Gauges.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/Gauges.kt new file mode 100644 index 000000000..47c690e47 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/Gauges.kt @@ -0,0 +1,50 @@ +package ru.dbotthepony.mc.otm.compat.jei + +import net.minecraft.client.gui.GuiGraphics +import net.minecraft.network.chat.Component +import ru.dbotthepony.mc.otm.client.ShiftPressedCond +import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.util.formatMatter +import ru.dbotthepony.mc.otm.core.util.formatPower +import ru.dbotthepony.mc.otm.systemTime + +fun renderMatterGauge( + guiGraphics: GuiGraphics, + x: Float, + y: Float, + width: Float = MatterGaugePanel.GAUGE_BACKGROUND.width, + height: Float = MatterGaugePanel.GAUGE_BACKGROUND.height, + drainSpeed: Float = 1f, + wavesStrength: Float = drainSpeed * 2f, +) { + MatterGaugePanel.GAUGE_BACKGROUND.render(guiGraphics, x, y, width, height) + MatterGaugePanel.renderLevel(guiGraphics, x, y, width, height, 1f - ((systemTime.secondsF * drainSpeed) % 1f), wavesStrength) +} + +fun renderEnergyGauge( + guiGraphics: GuiGraphics, + x: Float, + y: Float, + width: Float = PowerGaugePanel.GAUGE_BACKGROUND.width, + height: Float = PowerGaugePanel.GAUGE_BACKGROUND.height, + drainSpeed: Float = 1f +) { + val perc = 1f - ((systemTime.secondsF * drainSpeed) % 1f) + PowerGaugePanel.GAUGE_BACKGROUND.render(guiGraphics, x, y, width, height) + PowerGaugePanel.GAUGE_FOREGROUND.renderPartial(guiGraphics, x, y + height * (1f - perc) - 1f, width, height * perc) +} + +fun matterGaugeTooltips(target: MutableList, matter: Decimal, mouseX: Double, mouseY: Double, x: Float, y: Float, width: Float = MatterGaugePanel.GAUGE_BACKGROUND.width, height: Float = MatterGaugePanel.GAUGE_BACKGROUND.height) { + if (mouseX in x .. (x + width - 1) && mouseY in y .. (y + height - 1)) { + target.add(TranslatableComponent("otm.gui.matter_panel.matter_required", matter.formatMatter(formatAsReadable = ShiftPressedCond))) + } +} + +fun energyGaugeTooltips(target: MutableList, energy: Decimal, mouseX: Double, mouseY: Double, x: Float, y: Float, width: Float = PowerGaugePanel.GAUGE_BACKGROUND.width, height: Float = PowerGaugePanel.GAUGE_BACKGROUND.height) { + if (mouseX in x .. (x + width - 1) && mouseY in y .. (y + height - 1)) { + target.add(TranslatableComponent("otm.gui.energy_required", energy.formatPower(formatAsReadable = ShiftPressedCond))) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt index bec5cb7fb..fcc0617eb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt @@ -69,14 +69,17 @@ class JEIPlugin : IModPlugin { registration.addRecipeCatalyst(ItemStack(MItems.POWERED_BLAST_FURNACE), RecipeTypes.BLASTING) registration.addRecipeCatalyst(ItemStack(MItems.POWERED_SMOKER), RecipeTypes.SMOKING) registration.addRecipeCatalyst(ItemStack(MItems.ExopackUpgrades.CRAFTING_UPGRADE), RecipeTypes.CRAFTING) + registration.addRecipeCatalyst(ItemStack(MItems.ITEM_MONITOR), RecipeTypes.CRAFTING) registration.addRecipeCatalyst(ItemStack(MItems.PLATE_PRESS), PlatePressRecipeCategory.recipeType) registration.addRecipeCatalyst(ItemStack(MItems.PAINTER), PainterRecipeCategory.recipeType) + registration.addRecipeCatalyst(ItemStack(MItems.MATTER_ENTANGLER), MatterEntanglerRecipeCategory.recipeType) } override fun registerCategories(registration: IRecipeCategoryRegistration) { helpers = registration.jeiHelpers registration.addRecipeCategories(PlatePressRecipeCategory) registration.addRecipeCategories(PainterRecipeCategory) + registration.addRecipeCategories(MatterEntanglerRecipeCategory) } override fun registerRecipes(registration: IRecipeRegistration) { @@ -84,6 +87,7 @@ class JEIPlugin : IModPlugin { registration.addRecipes(PlatePressRecipeCategory.recipeType, level.recipeManager.getAllRecipesFor(MRecipes.PLATE_PRESS).filter { !it.isIncomplete }) registration.addRecipes(PainterRecipeCategory.recipeType, level.recipeManager.getAllRecipesFor(MRecipes.PAINTER).filter { !it.isIncomplete }) + registration.addRecipes(MatterEntanglerRecipeCategory.recipeType, level.recipeManager.getAllRecipesFor(MRecipes.MATTER_ENTANGLER).filter { !it.isIncomplete }) } override fun registerRecipeTransferHandlers(registration: IRecipeTransferRegistration) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt new file mode 100644 index 000000000..763f17658 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt @@ -0,0 +1,91 @@ +package ru.dbotthepony.mc.otm.compat.jei + +import mezz.jei.api.gui.builder.IRecipeLayoutBuilder +import mezz.jei.api.gui.drawable.IDrawable +import mezz.jei.api.gui.ingredient.IRecipeSlotsView +import mezz.jei.api.recipe.IFocusGroup +import mezz.jei.api.recipe.RecipeIngredientRole +import mezz.jei.api.recipe.RecipeType +import mezz.jei.api.recipe.category.IRecipeCategory +import net.minecraft.client.gui.GuiGraphics +import net.minecraft.network.chat.Component +import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.client.render.ItemStackIcon +import ru.dbotthepony.mc.otm.client.render.draw +import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel +import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel +import ru.dbotthepony.mc.otm.config.MachinesConfig +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.recipe.IMatterEntanglerRecipe +import ru.dbotthepony.mc.otm.registry.MItems +import ru.dbotthepony.mc.otm.registry.MNames + +object MatterEntanglerRecipeCategory : IRecipeCategory, IDrawable { + private val recipeType = RecipeType.create(OverdriveThatMatters.MOD_ID, MNames.MATTER_ENTANGLER, IMatterEntanglerRecipe::class.java) + + override fun getRecipeType(): RecipeType { + return recipeType + } + + override fun getTitle(): Component { + return MItems.MATTER_ENTANGLER.description + } + + override fun getBackground(): IDrawable { + return this + } + + override fun getWidth(): Int { + return 140 + } + + override fun getHeight(): Int { + return 60 + } + + private val icon = IGUIRenderable2IDrawable(ItemStackIcon(ItemStack(MItems.MATTER_ENTANGLER))) + + override fun getIcon(): IDrawable { + return icon + } + + override fun setRecipe(builder: IRecipeLayoutBuilder, recipe: IMatterEntanglerRecipe, focuses: IFocusGroup) { + for (x in 0 until recipe.ingredients.width) { + for (y in 0 until recipe.ingredients.height) { + builder.addSlot(RecipeIngredientRole.INPUT, 30 + x * 18, 4 + y * 18).addIngredients(recipe.ingredients[x, y]) + } + } + + builder.addSlot(RecipeIngredientRole.OUTPUT, 116, 18 + 4).addItemStack(recipe.result) + } + + override fun draw(guiGraphics: GuiGraphics, xOffset: Int, yOffset: Int) { + for (x in 0 until 3) { + for (y in 0 until 3) { + AbstractSlotPanel.SLOT_BACKGROUND.render(guiGraphics, xOffset + x * 18f + 29f, yOffset + y * 18f + 3f) + } + } + + AbstractSlotPanel.SLOT_BACKGROUND.render(guiGraphics, xOffset + 115f, yOffset + 18f + 3f) + ProgressGaugePanel.GAUGE_BACKGROUND.render(guiGraphics, xOffset + 89f, yOffset + 18f + 4f) + } + + override fun draw(recipe: IMatterEntanglerRecipe, recipeSlotsView: IRecipeSlotsView, guiGraphics: GuiGraphics, mouseX: Double, mouseY: Double) { + renderMatterGauge(guiGraphics, 13f, 6f, drainSpeed = (recipe.matter / Decimal(300)).toFloat()) + renderEnergyGauge(guiGraphics, 4f, 6f, drainSpeed = (recipe.ticks / 2000.0).toFloat()) + + guiGraphics.draw(minecraft.font, x = 85f, y = 45f, text = TranslatableComponent("otm.gui.recipe.ticks", recipe.ticks), drawShadow = true) + } + + override fun getTooltipStrings(recipe: IMatterEntanglerRecipe, recipeSlotsView: IRecipeSlotsView, mouseX: Double, mouseY: Double): MutableList { + val result = ArrayList() + + matterGaugeTooltips(result, recipe.matter, mouseX, mouseY, 13f, 6f) + energyGaugeTooltips(result, MachinesConfig.MATTER_ENTANGLER.energyConsumption * recipe.ticks * MachinesConfig.MATTER_ENTANGLER.workTimeMultiplier, mouseX, mouseY, 4f, 6f) + + return result + } +} 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 f5d937bf8..bda128ad6 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 @@ -43,8 +43,10 @@ object PainterRecipeCategory : IRecipeCategory, IDrawable { return 56 } + private val icon = IGUIRenderable2IDrawable(ItemStackIcon(ItemStack(MItems.PAINTER))) + override fun getIcon(): IDrawable { - return IGUIRenderable2IDrawable(ItemStackIcon(ItemStack(MItems.PAINTER))) + return icon } override fun setRecipe(builder: IRecipeLayoutBuilder, recipe: PainterRecipe, focuses: IFocusGroup) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt index 4653d9e97..d0bc04a44 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt @@ -13,6 +13,14 @@ object MachinesConfig : AbstractConfig("machines") { energyConsumption = Decimal(15) ) + val MATTER_ENTANGLER = workerValues( + MNames.MATTER_ENTANGLER, + energyStorage = Decimal(40_000), + energyThroughput = Decimal(400), + energyConsumption = Decimal(120), + matterCapacity = Decimal(60), + ) + val MATTER_DECOMPOSER = workerValues( MNames.MATTER_DECOMPOSER, energyStorage = Decimal(100_000), diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt index 9b79113b9..fc69f47b8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt @@ -7,6 +7,7 @@ import it.unimi.dsi.fastutil.ints.IntSet import it.unimi.dsi.fastutil.objects.Object2ObjectFunction import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap import net.minecraft.world.Container +import net.minecraft.world.inventory.CraftingContainer import net.minecraft.world.item.ItemStack import net.minecraft.world.item.enchantment.EnchantmentHelper.hasVanishingCurse import net.minecraftforge.fluids.capability.IFluidHandler @@ -245,3 +246,14 @@ fun Container.balance() { balance(IntArraySet(containerSize).also { for (i in 0 until containerSize) it.add(i) }, false) } + +operator fun CraftingContainer.get(column: Int, row: Int): ItemStack { + return getItem(column + row * width) +} + +operator fun CraftingContainer.get(column: Int, row: Int, flop: Boolean): ItemStack { + return if (flop) + get(width - column - 1, row) + else + get(column, row) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt index 95d1624d8..43a135ca2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt @@ -4,7 +4,8 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import it.unimi.dsi.fastutil.ints.IntAVLTreeSet import it.unimi.dsi.fastutil.ints.IntArrayList import it.unimi.dsi.fastutil.ints.IntComparators -import it.unimi.dsi.fastutil.objects.ObjectIterators +import it.unimi.dsi.fastutil.ints.IntSpliterator +import it.unimi.dsi.fastutil.objects.ObjectSpliterators import net.minecraft.world.item.ItemStack import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.ListTag @@ -13,11 +14,16 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.world.Container import kotlin.jvm.JvmOverloads import net.minecraft.world.entity.player.Player +import net.minecraft.world.entity.player.StackedContents +import net.minecraft.world.inventory.StackedContentsCompatible import net.minecraft.world.item.Item import net.minecraft.world.item.Items import net.minecraftforge.common.util.INBTSerializable import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.core.addSorted +import ru.dbotthepony.mc.otm.core.collect.any +import ru.dbotthepony.mc.otm.core.collect.count +import ru.dbotthepony.mc.otm.core.collect.filter import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set @@ -26,17 +32,18 @@ import ru.dbotthepony.mc.otm.core.util.ItemValueCodec import ru.dbotthepony.mc.otm.core.util.VarIntValueCodec import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer import ru.dbotthepony.mc.otm.network.synchronizer.IField -import java.lang.ref.PhantomReference -import java.lang.ref.ReferenceQueue import java.lang.ref.WeakReference import java.util.* -import java.util.concurrent.CopyOnWriteArrayList +import java.util.function.Consumer +import java.util.function.Predicate import java.util.function.Supplier +import java.util.stream.Stream +import java.util.stream.StreamSupport import kotlin.NoSuchElementException import kotlin.collections.ArrayList @Suppress("UNUSED") -open class MatteryContainer(protected val watcher: Runnable, private val size: Int) : Container, Iterable, INBTSerializable { +open class MatteryContainer(protected val watcher: Runnable, private val size: Int) : Container, Iterable, INBTSerializable, StackedContentsCompatible { constructor(size: Int) : this({}, size) init { @@ -440,6 +447,12 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I } } + override fun fillStackedContents(contents: StackedContents) { + for (item in iterator()) { + contents.accountStack(item) + } + } + final override fun removeItem(slot: Int, amount: Int): ItemStack { if (amount <= 0 || slot < 0 || slot >= size || slots[slot].isEmpty) return ItemStack.EMPTY @@ -576,6 +589,26 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I } } + private inner class Spliterator(private val parent: IntSpliterator) : java.util.Spliterator { + override fun tryAdvance(action: Consumer): Boolean { + return parent.tryAdvance { + action.accept(getItem(it)) + } + } + + override fun trySplit(): java.util.Spliterator? { + return parent.trySplit()?.let(::Spliterator) + } + + override fun estimateSize(): Long { + return parent.estimateSize() + } + + override fun characteristics(): Int { + return parent.characteristics() + } + } + private object EmptyIterator : IContainerIterator { override fun hasNext(): Boolean { return false @@ -601,4 +634,29 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I return Iterator() } + + final override fun countItem(item: Item): Int { + return iterator().filter { it.item == item }.count().toInt() + } + + final override fun hasAnyOf(set: Set): Boolean { + return iterator().any { it.item in set } + } + + final override fun hasAnyMatching(predicate: Predicate): Boolean { + return iterator().any(predicate) + } + + final override fun spliterator(): java.util.Spliterator { + if (isEmpty) { + return ObjectSpliterators.emptySpliterator() + } + + indicesReferenced = true + return Spliterator(nonEmptyIndices.intSpliterator()) + } + + fun stream(): Stream { + return StreamSupport.stream(spliterator(), false) + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryCraftingContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryCraftingContainer.kt new file mode 100644 index 000000000..b6904f670 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryCraftingContainer.kt @@ -0,0 +1,22 @@ +package ru.dbotthepony.mc.otm.container + +import net.minecraft.world.inventory.CraftingContainer +import net.minecraft.world.item.ItemStack + +open class MatteryCraftingContainer(watcher: Runnable, private val width: Int, private val height: Int) : MatteryContainer(watcher, width * height), CraftingContainer { + constructor(width: Int, height: Int) : this({}, width, height) + final override fun getWidth(): Int { + return width + } + + final override fun getHeight(): Int { + return height + } + + final override fun getItems(): MutableList { + val i = spliterator() + val result = ArrayList(i.estimateSize().toInt()) + i.forEachRemaining { result.add(it) } + return result + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowContainer.kt new file mode 100644 index 000000000..3f506ffec --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowContainer.kt @@ -0,0 +1,48 @@ +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 java.util.Arrays + +class ShadowContainer(private val parent: Container) : Container by parent { + private val shadowed = Int2ObjectArrayMap(0) + + override fun clearContent() { + shadowed.clear() + parent.clearContent() + } + + override fun isEmpty(): Boolean { + return parent.isEmpty && shadowed.isEmpty() + } + + override fun getItem(slot: Int): ItemStack { + return shadowed[slot] ?: parent.getItem(slot) + } + + override fun removeItem(slot: Int, count: Int): ItemStack { + val shadow = shadowed[slot] ?: return parent.removeItem(slot, count) + val copy = shadow.copyWithCount(shadow.count.coerceAtLeast(count)) + shadow.split(count) + if (shadow.isEmpty) shadowed[slot] = ItemStack.EMPTY + return copy + } + + override fun removeItemNoUpdate(slot: Int): ItemStack { + shadowed[slot] ?: return parent.removeItemNoUpdate(slot) + val old = shadowed[slot] + shadowed[slot] = ItemStack.EMPTY + return old!! + } + + override fun setItem(slot: Int, item: ItemStack) { + shadowed[slot] = item + } + + companion object { + fun shadow(container: Container, slot: Int, itemStack: ItemStack): Container { + return ShadowContainer(container).also { it[slot] = itemStack } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowCraftingContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowCraftingContainer.kt new file mode 100644 index 000000000..662d32a3e --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowCraftingContainer.kt @@ -0,0 +1,33 @@ +package ru.dbotthepony.mc.otm.container + +import net.minecraft.world.Container +import net.minecraft.world.entity.player.StackedContents +import net.minecraft.world.inventory.CraftingContainer +import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.core.collect.toList + +class ShadowCraftingContainer(private val parent: CraftingContainer) : Container by ShadowContainer(parent), CraftingContainer { + override fun fillStackedContents(contents: StackedContents) { + for (item in iterator()) { + contents.accountStack(item) + } + } + + override fun getWidth(): Int { + return parent.width + } + + override fun getHeight(): Int { + return parent.height + } + + override fun getItems(): MutableList { + return iterator().toList() + } + + companion object { + fun shadow(container: CraftingContainer, slot: Int, itemStack: ItemStack): CraftingContainer { + return ShadowCraftingContainer(container).also { it[slot] = itemStack } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt index 5711b8ec5..42e4476f5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt @@ -3,9 +3,14 @@ package ru.dbotthepony.mc.otm.core.collect import it.unimi.dsi.fastutil.objects.ObjectIterators import ru.dbotthepony.mc.otm.core.addAll import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators import java.util.function.BinaryOperator import java.util.function.Predicate +import java.util.function.Supplier import java.util.stream.Collector +import java.util.stream.Stream +import java.util.stream.StreamSupport // Purpose of Stream API over Iterators is that it is simple enough for JIT to inline most of it, // unlike actual Streams. @@ -370,3 +375,29 @@ fun Iterator.maybe(): T? { fun emptyIterator(): MutableIterator { return ObjectIterators.emptyIterator() } + +fun Iterator.toStream(): Stream { + return StreamSupport.stream(Spliterators.spliteratorUnknownSize(this, 0), false) +} + +fun Iterator.allEqual(): Boolean { + if (hasNext()) { + val v = next() + + while (hasNext()) { + if (v != next()) { + return false + } + } + + return true + } + + return false +} + +fun Iterator.count(): Long { + var count = 0L + while (hasNext()) count++ + return count +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt index 40ba63af0..bd43dd751 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt @@ -17,19 +17,64 @@ import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.core.util.readBinaryJsonWithCodecIndirect import ru.dbotthepony.mc.otm.core.util.writeBinaryJsonWithCodec -import java.util.* -import kotlin.NoSuchElementException -import kotlin.concurrent.getOrSet +import kotlin.collections.ArrayDeque -class Codec2RecipeSerializer>(val empty: S?, val codec: Codec) : Codec by codec, RecipeSerializer { - constructor(supplier: (() -> ResourceLocation) -> Codec) : this(null, supplier.invoke(::context)) - constructor(empty: S, supplier: (() -> ResourceLocation) -> Codec) : this(empty, supplier.invoke(::context)) +class Codec2RecipeSerializer> private constructor( + val empty: S?, + private val id: ArrayDeque, + codec: (Codec2RecipeSerializer.Context) -> Codec, +) : Codec, RecipeSerializer { + constructor(empty: S?, codec: (Codec2RecipeSerializer.Context) -> Codec) : this(empty, ArrayDeque(), codec) + constructor(supplier: (Codec2RecipeSerializer.Context) -> Codec) : this(null, supplier) - override fun fromJson(p_44103_: ResourceLocation, p_44104_: JsonObject): S { + private val codec = codec.invoke(Context()) + + inner class Context() { + val id: ResourceLocation + get() = checkNotNull(this@Codec2RecipeSerializer.id.lastOrNull()) { "Not currently deserializing recipe" } + + fun > wrap(other: Codec2RecipeSerializer): Codec { + return object : Codec { + override fun encode(input: O, ops: DynamicOps, prefix: T): DataResult { + try { + other.id.addLast(this@Context.id) + return other.encode(input, ops, prefix) + } finally { + other.id.removeLast() + } + } + + override fun decode(ops: DynamicOps, input: T): DataResult> { + try { + other.id.addLast(this@Context.id) + return other.decode(ops, input) + } finally { + other.id.removeLast() + } + } + } + } + } + + override fun encode(input: S, ops: DynamicOps, prefix: T): DataResult { + return codec.encode(input, ops, prefix) + } + + override fun decode(ops: DynamicOps, input: T): DataResult> { + return codec.decode(ops, input) + } + + fun > xmap(to: (S) -> O, from: (O) -> S): Codec2RecipeSerializer { + return Codec2RecipeSerializer(empty?.let(to), id) { _ -> + codec.xmap(to, from) + } + } + + override fun fromJson(id: ResourceLocation, data: JsonObject): S { try { - deck.getOrSet(::LinkedList).addLast(p_44103_) + this.id.addLast(id) - return codec.decode(JsonOps.INSTANCE, p_44104_).get().map( + return decode(JsonOps.INSTANCE, data).get().map( { it.first }, @@ -38,29 +83,29 @@ class Codec2RecipeSerializer>(val empty: S?, val codec: Codec) } ) } finally { - deck.get().removeLast() + this.id.removeLast() } } - override fun fromNetwork(p_44105_: ResourceLocation, p_44106_: FriendlyByteBuf): S? { + override fun fromNetwork(id: ResourceLocation, data: FriendlyByteBuf): S? { try { - deck.getOrSet(::LinkedList).addLast(p_44105_) + this.id.addLast(id) - return p_44106_.readBinaryJsonWithCodecIndirect(codec) - .resultOrPartial { LOGGER.error("Failed to read recipe $p_44105_ from network: $it") }.orElse(null) + return data.readBinaryJsonWithCodecIndirect(this) + .resultOrPartial { LOGGER.error("Failed to read recipe $id from network: $it") }.orElse(null) } finally { - deck.get().removeLast() + this.id.removeLast() } } - override fun toNetwork(p_44101_: FriendlyByteBuf, p_44102_: S) { - p_44101_.writeBinaryJsonWithCodec(codec, p_44102_) + override fun toNetwork(data: FriendlyByteBuf, recipe: S) { + data.writeBinaryJsonWithCodec(this, recipe) } fun toFinished(recipe: S): FinishedRecipe { return object : FinishedRecipe { override fun serializeRecipeData(p_125967_: JsonObject) { - codec.encode(recipe, JsonOps.INSTANCE, p_125967_).get().map( + encode(recipe, JsonOps.INSTANCE, p_125967_).get().map( { it as JsonObject @@ -92,33 +137,7 @@ class Codec2RecipeSerializer>(val empty: S?, val codec: Codec) } } - companion object : Codec { - private val deck = ThreadLocal>() - - private fun context(): ResourceLocation { - val deck = deck.getOrSet(::LinkedList) - - if (deck.isEmpty()) { - throw NoSuchElementException("Context stack is empty") - } else { - return deck.last - } - } - - override fun encode(input: ResourceLocation, ops: DynamicOps, prefix: T): DataResult { - return DataResult.success(ops.empty()) - } - - override fun decode(ops: DynamicOps, input: T): DataResult> { - val deck = deck.getOrSet(::LinkedList) - - if (deck.isEmpty()) { - return DataResult.error { "Attempt to use recipe serializer codec ResourceLocation' hack outside Codec2RecipeSerializer" } - } else { - return DataResult.success(Pair(deck.last, ops.empty())) - } - } - + companion object { private val LOGGER = LogManager.getLogger() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientMatrixCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientMatrixCodec.kt new file mode 100644 index 000000000..f0ff5b1db --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientMatrixCodec.kt @@ -0,0 +1,111 @@ +package ru.dbotthepony.mc.otm.data + +import com.mojang.datafixers.util.Pair +import com.mojang.serialization.Codec +import com.mojang.serialization.DataResult +import com.mojang.serialization.DynamicOps +import com.mojang.serialization.JsonOps +import com.mojang.serialization.codecs.RecordCodecBuilder +import net.minecraft.world.item.crafting.Ingredient +import ru.dbotthepony.mc.otm.core.collect.allEqual +import ru.dbotthepony.mc.otm.core.collect.map +import ru.dbotthepony.mc.otm.core.collect.toStream +import ru.dbotthepony.mc.otm.core.stream +import ru.dbotthepony.mc.otm.recipe.IIngredientMatrix +import ru.dbotthepony.mc.otm.recipe.IngredientMatrix +import java.util.function.Supplier + +object IngredientMatrixCodec : Codec { + private val ingredientList = Codec.list(IngredientCodec) + + override fun encode(input: IIngredientMatrix, ops: DynamicOps, prefix: T): DataResult { + return DataResult.success( + ops.createList( + (0 until input.height).stream().map { row -> + ops.createList((0 until input.width).stream().map { column -> + JsonOps.INSTANCE.convertTo(ops, input[column, row].toJson()) + }) + } + ) + ) + } + + private data class Handwritten(val pattern: List, val key: Map) + + private val handwrittenCodec = RecordCodecBuilder.create { + it.group( + Codec.list(Codec.STRING) + .flatXmap( + { DataResult.success(it) }, + { if (it.iterator().map { it.length }.allEqual()) DataResult.success(it) else DataResult.error { "One or more of patten strings differ in length" } } + ) + .fieldOf("pattern").forGetter(Handwritten::pattern), + Codec.unboundedMap( + Codec.STRING + .flatXmap( + { if (it.length == 1) DataResult.success(it[0]) else DataResult.error { "Ingredient key must be exactly 1 symbol in length, '$it' is invalid" } }, + { DataResult.success(it.toString()) } + ), IngredientCodec).fieldOf("key").forGetter(Handwritten::key) + ).apply(it, ::Handwritten) + } + + override fun decode(ops: DynamicOps, input: T): DataResult> { + return ops.getList(input).get().map( + { + val lines = ArrayList>>() + + it.accept { + lines.add(ingredientList.decode(ops, it).map { it.first }) + } + + val errors = ArrayList>() + val ingredients = ArrayList>() + + lines.withIndex().forEach { + val (line, result) = it + result.get().map({ ingredients.add(it) }, { errors.add { "Line $line: ${it.message()}" } }) + } + + if (errors.isNotEmpty()) { + DataResult.error { "Failed to decode ingredient matrix: ${errors.joinToString { it.get() }}" } + } else if (ingredients.isEmpty()) { + DataResult.error { "Ingredient list is empty" } + } else if (!ingredients.iterator().map { it.size }.allEqual()) { + DataResult.error { "Ingredient list is not a matrix (one or multiple of rows are mismatched size)" } + } else { + val result = IngredientMatrix(ingredients.first().size, ingredients.size) + + for ((row, columns) in ingredients.withIndex()) { + for ((column, ingredient) in columns.withIndex()) { + result[column, row] = ingredient + } + } + + DataResult.success(Pair(result, ops.empty())) + } + }, + { err1 -> + handwrittenCodec.decode(ops, input).get().map( + { + DataResult.success(it) + }, + { + DataResult.error { "Failed to decode ingredients as list: ${err1.message()} and as pattern/dictionary: ${it.message()}" } + } + ).flatMap { + val handwritten = it.first + val result = IngredientMatrix(handwritten.pattern.first().length, handwritten.pattern.size) + + for ((row, pattern) in handwritten.pattern.withIndex()) { + for ((column, symbol) in pattern.withIndex()) { + val ingredient = if (symbol == ' ') handwritten.key[symbol] ?: Ingredient.EMPTY else handwritten.key[symbol] ?: return@flatMap DataResult.error { "Unknown ingredient with index '$symbol'" } + result[column, row] = ingredient + } + } + + DataResult.success(Pair(result, ops.empty())) + } + } + ) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/IQuantumLinked.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/IQuantumLinked.kt new file mode 100644 index 000000000..1049bb407 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/IQuantumLinked.kt @@ -0,0 +1,7 @@ +package ru.dbotthepony.mc.otm.item + +import net.minecraft.world.item.ItemStack + +interface IQuantumLinked { + fun merge(from: ItemStack, into: ItemStack): ItemStack +} 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 d12384485..7a37f586e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt @@ -63,7 +63,7 @@ import kotlin.collections.forEach import kotlin.collections.iterator import kotlin.collections.set -class QuantumBatteryItem(val savedataID: String, val balanceValues: EnergyBalanceValues?) : Item(Properties().stacksTo(1).rarity(if (balanceValues == null) Rarity.EPIC else Rarity.UNCOMMON)) { +class QuantumBatteryItem(val savedataID: String, val balanceValues: EnergyBalanceValues?) : Item(Properties().stacksTo(1).rarity(if (balanceValues == null) Rarity.EPIC else Rarity.UNCOMMON)), IQuantumLinked { val isCreative = balanceValues == null interface IValues { @@ -169,9 +169,9 @@ class QuantumBatteryItem(val savedataID: String, val balanceValues: EnergyBalanc fun updateValues() { if (!values.isServer && isServerThread()) { - values = serverData.values(stack.tag?.getUUIDSafe("id") ?: UUID.randomUUID().also { stack.tagNotNull["id"] = it }) + values = serverData.values(stack.tag?.getUUIDSafe("uuid") ?: UUID.randomUUID().also { stack.tagNotNull["uuid"] = it }) } else if (isClientThread()) { - val id = stack.tag?.getUUIDSafe("id") ?: return + val id = stack.tag?.getUUIDSafe("uuid") ?: return if (values.uuid != id) values = clientData.computeIfAbsent(id, Function { UnboundValues(it) }) @@ -278,6 +278,10 @@ class QuantumBatteryItem(val savedataID: String, val balanceValues: EnergyBalanc get() = if (isCreative) Decimal.LONG_MAX_VALUE else super.missingPower } + override fun merge(from: ItemStack, into: ItemStack): ItemStack { + return from.copyWithCount(from.count + into.count) + } + override fun isBarVisible(p_150899_: ItemStack): Boolean { if (isCreative) return false return p_150899_.matteryEnergy != null diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt index 6fbbdb32c..2a936470f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt @@ -69,7 +69,7 @@ class ExopackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen } val armorSlots = makeArmorSlots() - val curiosSlots: ImmutableList> = ImmutableList.copyOf(ply.curiosSlots) + val curiosSlots: ImmutableList> = ImmutableList.copyOf(player.curiosSlots) init { for ((a, b) in curiosSlots) { @@ -84,10 +84,10 @@ class ExopackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen } private fun popFurnaceExp() { - if (capability.isExopackSmeltingInstalled && capability.exopackSmelterExperience >= 1f && !ply.level().isClientSide) { + if (capability.isExopackSmeltingInstalled && capability.exopackSmelterExperience >= 1f && !player.level().isClientSide) { val whole = capability.exopackSmelterExperience.toInt() capability.exopackSmelterExperience -= whole - ExperienceOrb.award(ply.level() as ServerLevel, ply.position(), whole) + ExperienceOrb.award(player.level() as ServerLevel, player.position(), whole) } } @@ -99,8 +99,8 @@ class ExopackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen } } - val furnaceOutputs: List = capability.smelters.map { - object : MachineOutputSlot(it.output, 0, onTake = { popFurnaceExp() }) { + val furnaceOutputs: List = capability.smelters.map { + object : OutputSlot(it.output, 0, onTake = { popFurnaceExp() }) { override fun mayPickup(player: Player): Boolean { return super.mayPickup(player) && capability.isExopackSmeltingInstalled } @@ -120,7 +120,7 @@ class ExopackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen init { if (capability.isExopackEnderAccessInstalled) { - enderChestSlots = makeSlots(ply.enderChestInventory) { a, b -> + enderChestSlots = makeSlots(player.enderChestInventory) { a, b -> MatterySlot(a, b).also { addStorageSlot(it, condition = enderChestOpenState) } @@ -238,16 +238,16 @@ class ExopackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen } fun sendInitialData(container: ExopackInventoryMenu, itemStacks: NonNullList, carried: ItemStack, remoteDataSlots: IntArray) { - MatteryPlayerNetworkChannel.send(container.ply as ServerPlayer, ExopackMenuInitPacket(itemStacks, carried, container.incrementStateId())) + MatteryPlayerNetworkChannel.send(container.player as ServerPlayer, ExopackMenuInitPacket(itemStacks, carried, container.incrementStateId())) } fun sendSlotChange(container: ExopackInventoryMenu, slotId: Int, itemStack: ItemStack) { - if (container.slots[slotId].container != container.ply.inventory || container.ply.containerMenu is ExopackInventoryMenu) - MatteryPlayerNetworkChannel.send(container.ply as ServerPlayer, ExopackSlotPacket(slotId, itemStack, container.stateId)) + if (container.slots[slotId].container != container.player.inventory || container.player.containerMenu is ExopackInventoryMenu) + MatteryPlayerNetworkChannel.send(container.player as ServerPlayer, ExopackSlotPacket(slotId, itemStack, container.stateId)) } fun sendCarriedChange(container: ExopackInventoryMenu, itemStack: ItemStack) { - MatteryPlayerNetworkChannel.send(container.ply as ServerPlayer, ExopackCarriedPacket(itemStack, container.stateId)) + MatteryPlayerNetworkChannel.send(container.player as ServerPlayer, ExopackCarriedPacket(itemStack, container.stateId)) } fun sendDataChange(container: ExopackInventoryMenu, dataSlotId: Int, shortData: Int) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 5c20fd3fe..fca2c7320 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -101,7 +101,7 @@ abstract class MatteryMenu( * Server->Client synchronizer */ val mSynchronizer = FieldSynchronizer() - val ply: Player get() = inventory.player + val player: Player get() = inventory.player private val _playerInventorySlots = ArrayList() private val _playerHotbarSlots = ArrayList() @@ -229,7 +229,7 @@ abstract class MatteryMenu( protected var inventorySlotIndexStart = 0 protected var inventorySlotIndexEnd = 0 - private val playerPacketDistributor = PacketDistributor.PLAYER.with { ply as ServerPlayer } + private val playerPacketDistributor = PacketDistributor.PLAYER.with { player as ServerPlayer } fun addFilterSlots(slots: ItemFilter): List> { val result = ArrayList>(slots.size) @@ -277,8 +277,8 @@ abstract class MatteryMenu( } override fun isSameInventory(other: Slot): Boolean { - if (container === inventory || container === ply.matteryPlayer?.exopackContainer) - return (other.container === inventory || other.container === ply.matteryPlayer?.exopackContainer) && isSameFilter(other) + if (container === inventory || container === player.matteryPlayer?.exopackContainer) + return (other.container === inventory || other.container === player.matteryPlayer?.exopackContainer) && isSameFilter(other) return super.isSameInventory(other) } @@ -287,7 +287,7 @@ abstract class MatteryMenu( private set init { - val mattery = ply.matteryPlayer + val mattery = player.matteryPlayer if (mattery != null) { if (container === inventory) { @@ -349,7 +349,7 @@ abstract class MatteryMenu( } } - protected fun addInventorySlots(autoFrame: Boolean = !ply.isSpectator) { + protected fun addInventorySlots(autoFrame: Boolean = !player.isSpectator) { check(_playerInventorySlots.isEmpty()) { "Already created inventory slots" } autoCreateInventoryFrame = autoFrame @@ -378,7 +378,7 @@ abstract class MatteryMenu( addSlot(slot) } - val mattery = ply.matteryPlayer + val mattery = player.matteryPlayer if (mattery != null && mattery.hasExopack) { for (i in 0 until mattery.exopackContainer.containerSize) { @@ -415,9 +415,9 @@ abstract class MatteryMenu( if (payload != null) { if (broadcastOnce) { - MenuNetworkChannel.send(ply, MenuFieldPacket(containerId, payload)) + MenuNetworkChannel.send(player, MenuFieldPacket(containerId, payload)) } else { - MenuNetworkChannel.sendNow(ply, MenuFieldPacket(containerId, payload)) + MenuNetworkChannel.sendNow(player, MenuFieldPacket(containerId, payload)) } } @@ -449,7 +449,7 @@ abstract class MatteryMenu( fun syncCarried() { setRemoteCarried(carried.copy()) - MenuNetworkChannel.send(ply as ServerPlayer, SetCarriedPacket(carried)) + MenuNetworkChannel.send(player as ServerPlayer, SetCarriedPacket(carried)) } fun syncCarried(stack: ItemStack) { @@ -635,11 +635,11 @@ abstract class MatteryMenu( if (remainder.isEmpty) { source.set(ItemStack.EMPTY) - source.onTake(ply, copy) + source.onTake(player, copy) } else { copy.count = source.item.count - remainder.count source.item.count = remainder.count - source.onTake(ply, copy) + source.onTake(player, copy) } return true @@ -745,7 +745,7 @@ abstract class MatteryMenu( return armorSlots!! } - val cosmetic = ply.cosmeticArmorSlots + val cosmetic = player.cosmeticArmorSlots return ImmutableList.of( PlayerSlot(EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.HEAD), cosmetic?.get(net.minecraft.world.entity.EquipmentSlot.HEAD)), @@ -780,7 +780,7 @@ abstract class MatteryMenu( fun makeEquipmentSlots(mapMoveToExternal: Boolean = false): EquipmentSlots { return EquipmentSlots( armorSlots = makeArmorSlots(mapMoveToExternal), - curiosSlots = curiosSlots ?: ImmutableList.copyOf(ply.curiosSlots).also { + curiosSlots = curiosSlots ?: ImmutableList.copyOf(player.curiosSlots).also { for ((a, b) in it) { equipmentSlots.add(a) addSlot(a) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt index 2a4c59ed0..ac20239f9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt @@ -11,7 +11,6 @@ import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.container.UpgradeContainer import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.runOnClient @@ -80,7 +79,7 @@ open class UserFilteredSlot(container: Container, index: Int, x: Int = 0, y: Int } } -open class MachineOutputSlot(container: Container, index: Int, x: Int = 0, y: Int = 0, val onTake: (ItemStack) -> Unit = {}) : MatterySlot(container, index, x, y) { +open class OutputSlot(container: Container, index: Int, x: Int = 0, y: Int = 0, val onTake: (ItemStack) -> Unit = {}) : MatterySlot(container, index, x, y) { override fun mayPlace(itemStack: ItemStack): Boolean { return false } 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 cce696644..401057a94 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,8 +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.capability.isNotFull -import ru.dbotthepony.mc.otm.menu.MachineOutputSlot +import ru.dbotthepony.mc.otm.menu.OutputSlot import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback @@ -50,7 +49,7 @@ class FluidTankMenu(containerId: Int, inventory: Inventory, tile: FluidTankBlock } } - val output = MachineOutputSlot(tile?.output ?: SimpleContainer(1), 0) + val output = OutputSlot(tile?.output ?: SimpleContainer(1), 0) init { // сначала слот на заполнение из бака diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PainterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/PainterMenu.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PainterMenu.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/PainterMenu.kt index 5d93bddb0..7dd9dc7f1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PainterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/PainterMenu.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.menu.tech +package ru.dbotthepony.mc.otm.menu.decorative import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt index 29e2a6a21..f2eb883a4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterDecomposerMenu.kt @@ -7,10 +7,8 @@ import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import net.minecraft.world.SimpleContainer import net.minecraft.world.item.ItemStack -import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.matter.MatterManager -import ru.dbotthepony.mc.otm.menu.MachineOutputSlot +import ru.dbotthepony.mc.otm.menu.OutputSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput @@ -27,8 +25,8 @@ class MatterDecomposerMenu @JvmOverloads constructor( override fun mayPlace(itemStack: ItemStack) = MatterManager.canDecompose(itemStack) } - val outputMain: MachineOutputSlot - val outputStacking: MachineOutputSlot + val outputMain: OutputSlot + val outputStacking: OutputSlot val progressWidget = ProgressGaugeWidget(this, tile) val matterWidget = ProfiledLevelGaugeWidget(this, tile?.matter, LevelGaugeWidget(this, tile?.matter)) val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) @@ -40,8 +38,8 @@ class MatterDecomposerMenu @JvmOverloads constructor( val container = tile?.outputContainer ?: SimpleContainer(2) // Выход - outputMain = MachineOutputSlot(container, 0) - outputStacking = MachineOutputSlot(container, 1) + outputMain = OutputSlot(container, 0) + outputStacking = OutputSlot(container, 1) addStorageSlot(outputMain) addStorageSlot(outputStacking) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterEntanglerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterEntanglerMenu.kt new file mode 100644 index 000000000..99f71e491 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterEntanglerMenu.kt @@ -0,0 +1,130 @@ +package ru.dbotthepony.mc.otm.menu.matter + +import net.minecraft.server.level.ServerPlayer +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.item.ItemStack +import ru.dbotthepony.mc.otm.block.entity.matter.MatterEntanglerBlockEntity +import ru.dbotthepony.mc.otm.container.MatteryContainer +import ru.dbotthepony.mc.otm.container.MatteryCraftingContainer +import ru.dbotthepony.mc.otm.container.ShadowCraftingContainer +import ru.dbotthepony.mc.otm.container.get +import ru.dbotthepony.mc.otm.container.set +import ru.dbotthepony.mc.otm.core.isNotEmpty +import ru.dbotthepony.mc.otm.item.IQuantumLinked +import ru.dbotthepony.mc.otm.menu.OutputSlot +import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu +import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput +import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput +import ru.dbotthepony.mc.otm.menu.makeSlots +import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget +import ru.dbotthepony.mc.otm.registry.MMenus +import ru.dbotthepony.mc.otm.registry.MRecipes +import java.util.* + +class MatterEntanglerMenu( + containerId: Int, inventory: Inventory, tile: MatterEntanglerBlockEntity? = null +) : MatteryPoweredMenu(MMenus.MATTER_ENTANGLER, containerId, inventory, tile) { + val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) + val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) + val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy) + val profiledMatter = ProfiledLevelGaugeWidget(this, tile?.matter, LevelGaugeWidget(this, tile?.matter)) + + val progress = ProgressGaugeWidget(this, tile?.jobEventLoops?.get(0)) + + val inputs: List = makeSlots(tile?.inputs ?: object : MatteryCraftingContainer(3, 3) { + override fun getMaxStackSize(): Int { + return 1 + } + }) { it, i -> + object : MatterySlot(it, i) { + override fun mayPlace(itemStack: ItemStack): Boolean { + val shadow = ShadowCraftingContainer.shadow(it, i, itemStack) + val level = player.level() + + return super.mayPlace(itemStack) && (level ?: return false) + .recipeManager + .byType(MRecipes.MATTER_ENTANGLER) + .values + .any { it.preemptivelyMatches(shadow, level) } + } + } + } + + val outputs = makeSlots(tile?.output ?: SimpleContainer(1), ::OutputSlot) + val upgrades = makeUpgradeSlots(3, tile?.upgrades) + + private val entangling: Container = if (tile == null) object : SimpleContainer(2) { + override fun getMaxStackSize(): Int { + return 1 + } + } else object : MatteryContainer(::rescan, 2) { + override fun getMaxStackSize(slot: Int, itemStack: ItemStack): Int { + return 1 + } + } + + private fun rescan() { + if (player is ServerPlayer && entangling[0].item is IQuantumLinked && entangling[1].item == entangling[0].item && entangling[0].isNotEmpty && entangling[1].isNotEmpty) { + entanglingC.container[0] = (entangling[0].item as IQuantumLinked).merge(entangling[0], entangling[1]) + } else if (player is ServerPlayer) { + entanglingC.container[0] = ItemStack.EMPTY + } + } + + private inner class EntanglingInputSlot(index: Int) : MatterySlot(entangling, index) { + override fun mayPlace(itemStack: ItemStack): Boolean { + return super.mayPlace(itemStack) && itemStack.item is IQuantumLinked + } + } + + val entanglingA: MatterySlot = EntanglingInputSlot(0) + val entanglingB: MatterySlot = EntanglingInputSlot(1) + val entanglingC: MatterySlot = object : MatterySlot(SimpleContainer(1), 0) { + override fun mayPlace(itemStack: ItemStack): Boolean { + return false + } + + override fun canTakeItemForPickAll(): Boolean { + return false + } + + override fun tryRemove(p_150642_: Int, p_150643_: Int, p_150644_: Player): Optional { + rescan() + return super.tryRemove(p_150642_, p_150643_, p_150644_) + } + + override fun onTake(p_150645_: Player, p_150646_: ItemStack) { + if (p_150646_.isNotEmpty) { + entangling.removeItem(0, 1) + entangling.removeItem(1, 1) + } + + super.onTake(p_150645_, p_150646_) + } + } + + override fun removed(p_38940_: Player) { + super.removed(p_38940_) + clearContainer(p_38940_, entangling) + } + + init { + addSlot(outputs) + addSlot(entanglingA) + addSlot(entanglingB) + addSlot(entanglingC) + mapQuickMoveToInventory(entanglingA) + mapQuickMoveToInventory(entanglingB) + mapQuickMoveToInventory(entanglingC) + outputs.forEach(::mapQuickMoveToInventory) + addStorageSlot(inputs) + addInventorySlots() + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt index 44a315958..86d586ee0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt @@ -141,7 +141,7 @@ class MatterPanelMenu( } val sorting: ItemSorter by mSynchronizer.ComputedField( - getter = { tile?.getPlayerSettings(ply)?.sorter ?: ItemSorter.DEFAULT }, + getter = { tile?.getPlayerSettings(player)?.sorter ?: ItemSorter.DEFAULT }, codec = ItemSorter::class.codec(), observer = { patterns.sortWith(actualComparator) @@ -151,7 +151,7 @@ class MatterPanelMenu( }) val isAscending: Boolean by mSynchronizer.ComputedField( - getter = { tile?.getPlayerSettings(ply)?.ascending ?: true }, + getter = { tile?.getPlayerSettings(player)?.ascending ?: true }, codec = BooleanValueCodec, observer = { patterns.sortWith(actualComparator) @@ -184,8 +184,8 @@ class MatterPanelMenu( } } - val changeIsAscending = booleanInput(allowSpectators = true) { tile?.getPlayerSettings(ply)?.ascending = it } - val changeSorting = PlayerInput(ItemSorter::class.codec(), allowSpectators = true) { tile?.getPlayerSettings(ply)?.sorter = it } + val changeIsAscending = booleanInput(allowSpectators = true) { tile?.getPlayerSettings(player)?.ascending = it } + val changeSorting = PlayerInput(ItemSorter::class.codec(), allowSpectators = true) { tile?.getPlayerSettings(player)?.sorter = it } val sortingGS = GetterSetter.of(::sorting, changeSorting::accept) val isAscendingGS = GetterSetter.of(::isAscending, changeIsAscending::accept) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt index cc5d52ba9..8c50152b7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterReplicatorMenu.kt @@ -10,7 +10,7 @@ import net.minecraft.world.SimpleContainer import ru.dbotthepony.mc.otm.container.CombinedContainer import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.isNotEmpty -import ru.dbotthepony.mc.otm.menu.MachineOutputSlot +import ru.dbotthepony.mc.otm.menu.OutputSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput @@ -25,7 +25,7 @@ class MatterReplicatorMenu @JvmOverloads constructor( ) : MatteryPoweredMenu(MMenus.MATTER_REPLICATOR, p_38852_, inventory, tile) { val matter = ProfiledLevelGaugeWidget(this, tile?.matter, LevelGaugeWidget(this, tile?.matter)) val progress = ProgressGaugeWidget(this, tile) - val storageSlots: List + val storageSlots: List val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) @@ -36,7 +36,7 @@ class MatterReplicatorMenu @JvmOverloads constructor( val container = CombinedContainer(tile?.outputContainer ?: SimpleContainer(3), tile?.dustContainer ?: SimpleContainer(2)) storageSlots = immutableList(5) { - addStorageSlot(MachineOutputSlot(container, it, onTake = { + addStorageSlot(OutputSlot(container, it, onTake = { if (inventory.player is ServerPlayer && it.isNotEmpty) TakeItemOutOfReplicatorTrigger.trigger(inventory.player as ServerPlayer, it) })) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt index 9a5e139e9..702149d37 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt @@ -48,8 +48,8 @@ class DriveViewerMenu( val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) val settings = object : DriveViewerBlockEntity.ISettings { - override var sorting: ItemStorageStackSorter by EnumInputWithFeedback(this@DriveViewerMenu, true, tile?.let { it.getSettingsFor(ply)::sorting }).also { it.addListener { changes() } } - override var isAscending: Boolean by BooleanInputWithFeedback(this@DriveViewerMenu, true, tile?.let { it.getSettingsFor(ply)::isAscending }).also { it.addListener { changes() } } + override var sorting: ItemStorageStackSorter by EnumInputWithFeedback(this@DriveViewerMenu, true, tile?.let { it.getSettingsFor(player)::sorting }).also { it.addListener { changes() } } + override var isAscending: Boolean by BooleanInputWithFeedback(this@DriveViewerMenu, true, tile?.let { it.getSettingsFor(player)::isAscending }).also { it.addListener { changes() } } private fun changes() { if (isAscending) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt index 3cebf19d1..82c13664c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt @@ -86,11 +86,11 @@ class ItemMonitorMenu( override val networkedItemView = NetworkedItemView(inventory.player, this, tile == null) val settings = object : IItemMonitorPlayerSettings { - override var ingredientPriority by EnumInputWithFeedback(this@ItemMonitorMenu, true, tile?.let { it.getSettings(ply as ServerPlayer)::ingredientPriority }) - override var resultTarget by EnumInputWithFeedback(this@ItemMonitorMenu, true, tile?.let { it.getSettings(ply as ServerPlayer)::resultTarget }) - override var craftingAmount by EnumInputWithFeedback(this@ItemMonitorMenu, true, tile?.let { it.getSettings(ply as ServerPlayer)::craftingAmount }) - override var sorting by EnumInputWithFeedback(this@ItemMonitorMenu, true, tile?.let { it.getSettings(ply as ServerPlayer)::sorting }).also { it.addListener { changes() } } - override var ascendingSort by BooleanInputWithFeedback(this@ItemMonitorMenu, true, tile?.let { it.getSettings(ply as ServerPlayer)::ascendingSort }).also { it.addListener { changes() } } + override var ingredientPriority by EnumInputWithFeedback(this@ItemMonitorMenu, true, tile?.let { it.getSettings(player as ServerPlayer)::ingredientPriority }) + override var resultTarget by EnumInputWithFeedback(this@ItemMonitorMenu, true, tile?.let { it.getSettings(player as ServerPlayer)::resultTarget }) + override var craftingAmount by EnumInputWithFeedback(this@ItemMonitorMenu, true, tile?.let { it.getSettings(player as ServerPlayer)::craftingAmount }) + override var sorting by EnumInputWithFeedback(this@ItemMonitorMenu, true, tile?.let { it.getSettings(player as ServerPlayer)::sorting }).also { it.addListener { changes() } } + override var ascendingSort by BooleanInputWithFeedback(this@ItemMonitorMenu, true, tile?.let { it.getSettings(player as ServerPlayer)::ascendingSort }).also { it.addListener { changes() } } private fun changes() { if (ascendingSort) { @@ -140,7 +140,7 @@ class ItemMonitorMenu( } if (!simulate && remaining.isNotEmpty) { - ply.spawnAtLocation(remaining) + player.spawnAtLocation(remaining) } if (!simulate) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt index 60caf7fcb..301f24d27 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt @@ -24,8 +24,8 @@ class AndroidStationMenu @JvmOverloads constructor( tile: AndroidStationBlockEntity? = null ) : MatteryPoweredMenu(MMenus.ANDROID_STATION, containerID, inventory, tile) { private fun container(target: (MatteryPlayerCapability) -> KMutableProperty0): Container { - if (ply is ServerPlayer) - return PartContainer(target.invoke(ply.matteryPlayer ?: throw NullPointerException("OTM player capability is missing"))) + if (player is ServerPlayer) + return PartContainer(target.invoke(player.matteryPlayer ?: throw NullPointerException("OTM player capability is missing"))) else return SimpleContainer(1) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt index af64aef16..23ed2311a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/CobblerMenu.kt @@ -5,7 +5,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.block.entity.tech.CobblerBlockEntity import ru.dbotthepony.mc.otm.core.immutableList -import ru.dbotthepony.mc.otm.menu.MachineOutputSlot +import ru.dbotthepony.mc.otm.menu.OutputSlot import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput @@ -17,7 +17,7 @@ class CobblerMenu @JvmOverloads constructor( inventory: Inventory, tile: CobblerBlockEntity? = null ) : MatteryMenu(MMenus.COBBLESTONE_GENERATOR, p_38852_, inventory, tile) { - val storageSlots = (tile?.container ?: SimpleContainer(CobblerBlockEntity.CONTAINER_SIZE)).let { c -> immutableList(c.containerSize) { addStorageSlot(MachineOutputSlot(c, it)) } } + val storageSlots = (tile?.container ?: SimpleContainer(CobblerBlockEntity.CONTAINER_SIZE)).let { c -> immutableList(c.containerSize) { addStorageSlot(OutputSlot(c, it)) } } val redstone = EnumInputWithFeedback(this) val itemConfig = ItemConfigPlayerInput(this) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt index 2c36f97dc..128d4f6d7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt @@ -40,7 +40,7 @@ class EssenceStorageMenu @JvmOverloads constructor( val storeLevels = intInput { if (it > 0) { - val ply = ply as ServerPlayer + val ply = player as ServerPlayer tile!! if (it == 1) { @@ -63,7 +63,7 @@ class EssenceStorageMenu @JvmOverloads constructor( val dispenseLevels = intInput { if (it > 0) { - val ply = ply as ServerPlayer + val ply = player as ServerPlayer tile!! if (it == 1) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt index 935922882..2d3bc8512 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt @@ -4,7 +4,7 @@ import net.minecraft.server.level.ServerPlayer import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity -import ru.dbotthepony.mc.otm.menu.MachineOutputSlot +import ru.dbotthepony.mc.otm.menu.OutputSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput @@ -19,7 +19,7 @@ class PlatePressMenu @JvmOverloads constructor( tile: PlatePressBlockEntity? = null ) : MatteryPoweredMenu(MMenus.PLATE_PRESS, containerID, inventory, tile) { val inputSlot = MatterySlot(tile?.inputContainer ?: SimpleContainer(1), 0) - val outputSlot = MachineOutputSlot(tile?.outputContainer ?: SimpleContainer(1), 0) { tile?.popExperience(ply as ServerPlayer) } + val outputSlot = OutputSlot(tile?.outputContainer ?: SimpleContainer(1), 0) { tile?.popExperience(player as ServerPlayer) } val progressGauge = ProgressGaugeWidget(this, tile) val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig, allowPush = true) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PoweredFurnaceMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PoweredFurnaceMenu.kt index c728c159f..b567e9ac3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PoweredFurnaceMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PoweredFurnaceMenu.kt @@ -4,7 +4,7 @@ import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.block.entity.tech.PoweredFurnaceBlockEntity import ru.dbotthepony.mc.otm.core.immutableList -import ru.dbotthepony.mc.otm.menu.MachineOutputSlot +import ru.dbotthepony.mc.otm.menu.OutputSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback @@ -21,7 +21,7 @@ class PoweredFurnaceMenu( tile: PoweredFurnaceBlockEntity? = null ) : MatteryPoweredMenu(MMenus.POWERED_FURNACE, containerID, inventory, tile) { val inputSlots = makeSlots(tile?.inputs, 2, ::MatterySlot) - val outputSlots = makeSlots(tile?.outputs, 2) { c, s -> MachineOutputSlot(c, s) { tile?.popExperience(ply as ServerPlayer) } } + val outputSlots = makeSlots(tile?.outputs, 2) { c, s -> OutputSlot(c, s) { tile?.popExperience(player as ServerPlayer) } } val progressGauge = immutableList(2) { ProgressGaugeWidget(this, tile?.jobEventLoops?.get(it)) } val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig, allowPush = true) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/TwinPlatePressMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/TwinPlatePressMenu.kt index e5168c070..8533dd864 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/TwinPlatePressMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/TwinPlatePressMenu.kt @@ -4,7 +4,7 @@ import net.minecraft.server.level.ServerPlayer import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity -import ru.dbotthepony.mc.otm.menu.MachineOutputSlot +import ru.dbotthepony.mc.otm.menu.OutputSlot import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback @@ -21,7 +21,7 @@ class TwinPlatePressMenu @JvmOverloads constructor( tile: PlatePressBlockEntity? = null ) : MatteryPoweredMenu(MMenus.TWIN_PLATE_PRESS, containerID, inventory, tile) { val inputSlots = makeSlots(tile?.inputContainer ?: SimpleContainer(2), ::MatterySlot) - val outputSlots = makeSlots(tile?.outputContainer ?: SimpleContainer(2)) { a, b -> MachineOutputSlot(a, b) { tile?.popExperience(ply as ServerPlayer) } } + val outputSlots = makeSlots(tile?.outputContainer ?: SimpleContainer(2)) { a, b -> OutputSlot(a, b) { tile?.popExperience(player as ServerPlayer) } } val progressGauge0 = ProgressGaugeWidget(this, tile?.jobEventLoops?.get(0)) val progressGauge1 = ProgressGaugeWidget(this, tile?.jobEventLoops?.get(1)) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/IMatteryRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/IMatteryRecipe.kt new file mode 100644 index 000000000..ec41ae375 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/IMatteryRecipe.kt @@ -0,0 +1,41 @@ +package ru.dbotthepony.mc.otm.recipe + +import net.minecraft.core.NonNullList +import net.minecraft.world.Container +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.crafting.Ingredient +import net.minecraft.world.item.crafting.Recipe +import net.minecraft.world.item.crafting.RecipeSerializer +import ru.dbotthepony.mc.otm.data.Codec2RecipeSerializer + +// overrides all methods to fix Kotlin bug related to implementation delegation (to allow easy optics) +// https://youtrack.jetbrains.com/issue/KT-55080/Change-the-behavior-of-inheritance-delegation-to-delegates-implementing-Java-interfaces-with-default-methods +interface IMatteryRecipe : Recipe { + override fun getRemainingItems(p_44004_: C): NonNullList { + return super.getRemainingItems(p_44004_) + } + + override fun getIngredients(): NonNullList { + return super.getIngredients() + } + + override fun isSpecial(): Boolean { + return super.isSpecial() + } + + override fun showNotification(): Boolean { + return super.showNotification() + } + + override fun getGroup(): String { + return super.getGroup() + } + + override fun getToastSymbol(): ItemStack { + return super.getToastSymbol() + } + + override fun isIncomplete(): Boolean { + return super.isIncomplete() + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/IngredientMatrix.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/IngredientMatrix.kt new file mode 100644 index 000000000..41f9c019a --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/IngredientMatrix.kt @@ -0,0 +1,151 @@ +package ru.dbotthepony.mc.otm.recipe + +import net.minecraft.core.NonNullList +import net.minecraft.world.inventory.CraftingContainer +import net.minecraft.world.item.crafting.Ingredient +import ru.dbotthepony.mc.otm.container.get +import ru.dbotthepony.mc.otm.core.collect.allEqual +import ru.dbotthepony.mc.otm.core.collect.any +import ru.dbotthepony.mc.otm.core.collect.flatMap +import ru.dbotthepony.mc.otm.core.collect.map +import ru.dbotthepony.mc.otm.core.isActuallyEmpty +import ru.dbotthepony.mc.otm.core.isNotEmpty +import java.util.function.Predicate + +interface IIngredientMatrix : Predicate, Iterable { + val width: Int + val height: Int + val isEmpty: Boolean + get() = width == 0 || height == 0 + + val isIncomplete: Boolean + get() = iterator().any { it.isActuallyEmpty } + + operator fun get(column: Int, row: Int): Ingredient + + operator fun get(column: Int, row: Int, flop: Boolean): Ingredient { + return if (flop) + get(width - column - 1, row) + else + get(column, row) + } + + override fun iterator(): Iterator { + return (0 until width).iterator().flatMap { x -> + (0 until height).iterator().map { y -> + get(x, y) + } + } + } + + val ingredients: NonNullList get() { + val result = NonNullList.createWithCapacity(width * height) + + for (x in 0 until width) { + for (y in 0 until height) { + result.add(get(x, y)) + } + } + + return result + } + + fun test(t: CraftingContainer, fromColumn: Int, fromRow: Int, flop: Boolean): Boolean { + if (t.width - fromColumn < width || t.height - fromRow < height) + return false + + for (column in 0 until width) + for (row in 0 until height) + if (!this[column, row, flop].test(t[fromColumn + column, fromRow + row, flop])) + return false + + return true + } + + fun preemptiveTest(t: CraftingContainer, fromColumn: Int, fromRow: Int, flop: Boolean): Boolean { + if (t.width - fromColumn < width || t.height - fromRow < height) + return false + + for (column in 0 until width) { + for (row in 0 until height) { + val item = t[fromColumn + column, fromRow + row, flop] + val ingredient = this[column, row, flop] + + if (!ingredient.test(item) && item.isNotEmpty) { + return false + } + } + } + + return true + } + + override fun test(t: CraftingContainer): Boolean { + if (t.width < width || t.height < height) + return false + + for (column in 0 .. t.width - width) + for (row in 0 .. t.height - height) + if (test(t, column, row, false) || test(t, column, row, true)) + return true + + return false + } + + fun preemptiveTest(t: CraftingContainer): Boolean { + if (t.width < width || t.height < height) + return false + + for (column in 0 .. t.width - width) + for (row in 0 .. t.height - height) + if (preemptiveTest(t, column, row, false) || preemptiveTest(t, column, row, true)) + return true + + return false + } + + companion object : IIngredientMatrix { + override val width: Int + get() = 0 + override val height: Int + get() = 0 + + override fun get(column: Int, row: Int): Ingredient { + return Ingredient.EMPTY + } + } +} + +class IngredientMatrix(override val width: Int, override val height: Int) : IIngredientMatrix { + private val data = Array(width * height) { Ingredient.EMPTY } + + override fun get(column: Int, row: Int): Ingredient { + require(column in 0 until width) { "Column out of bounds: $column (matrix width: $width)" } + require(row in 0 until height) { "Row out of bounds: $row > (matrix height: $height)" } + return data[column + row * width] + } + + operator fun set(column: Int, row: Int, value: Ingredient) { + require(column in 0 until width) { "Column out of bounds: $column (matrix width: $width)" } + require(row in 0 until height) { "Row out of bounds: $row > (matrix height: $height)" } + data[column + row * width] = value + } + + companion object { + fun of(vararg values: Collection): IngredientMatrix { + if (!values.iterator().map { it.size }.allEqual()) { + throw IllegalArgumentException("One or more rows have different number of columns than the rest") + } + + val result = IngredientMatrix(values.first().size, values.size) + + for ((y, l) in values.withIndex()) { + for ((x, i) in l.withIndex()) { + result[x, y] = i + } + } + + return result + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt new file mode 100644 index 000000000..15024b3b1 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt @@ -0,0 +1,170 @@ +package ru.dbotthepony.mc.otm.recipe + +import com.mojang.serialization.Codec +import com.mojang.serialization.codecs.RecordCodecBuilder +import net.minecraft.core.NonNullList +import net.minecraft.core.RegistryAccess +import net.minecraft.core.UUIDUtil +import net.minecraft.data.recipes.FinishedRecipe +import net.minecraft.resources.ResourceLocation +import net.minecraft.world.inventory.CraftingContainer +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.crafting.Ingredient +import net.minecraft.world.item.crafting.Recipe +import net.minecraft.world.item.crafting.RecipeSerializer +import net.minecraft.world.item.crafting.RecipeType +import net.minecraft.world.level.Level +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.capability.matter.matter +import ru.dbotthepony.mc.otm.capability.matteryEnergy +import ru.dbotthepony.mc.otm.container.iterator +import ru.dbotthepony.mc.otm.core.collect.filterNotNull +import ru.dbotthepony.mc.otm.core.collect.forEach +import ru.dbotthepony.mc.otm.core.collect.map +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.nbt.set +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.minRange +import ru.dbotthepony.mc.otm.registry.MRecipes +import java.util.Optional +import java.util.UUID +import kotlin.jvm.optionals.getOrElse + +interface IMatterEntanglerRecipe : IMatteryRecipe { + val matter: Decimal + val ticks: Double + val ingredients: IIngredientMatrix + val result: ItemStack + + fun preemptivelyMatches(container: CraftingContainer, level: Level): Boolean +} + +open class MatterEntanglerRecipe( + private val id: ResourceLocation, + override val ingredients: IIngredientMatrix, + override val matter: Decimal, + override val ticks: Double, + override val result: ItemStack, + val uuidKey: String = "uuid", + val fixedUuid: Optional = Optional.empty() +) : IMatterEntanglerRecipe { + override fun matches(container: CraftingContainer, level: Level): Boolean { + if (isIncomplete) return false + return ingredients.test(container) + } + + override fun preemptivelyMatches(container: CraftingContainer, level: Level): Boolean { + if (isIncomplete) return false + return ingredients.preemptiveTest(container) + } + + override fun assemble(container: CraftingContainer, registry: RegistryAccess): ItemStack { + return result.copy().also { + it.tagNotNull[uuidKey] = fixedUuid.getOrElse { UUID.randomUUID() } + } + } + + override fun canCraftInDimensions(width: Int, height: Int): Boolean { + return width >= ingredients.width && height >= ingredients.height + } + + override fun getResultItem(registry: RegistryAccess): ItemStack { + return result + } + + override fun getId(): ResourceLocation { + return id + } + + override fun getSerializer(): RecipeSerializer<*> { + return SERIALIZER + } + + override fun getType(): RecipeType<*> { + return MRecipes.MATTER_ENTANGLER + } + + override fun getIngredients(): NonNullList { + return ingredients.ingredients + } + + override fun isIncomplete(): Boolean { + return result.isEmpty || ingredients.isIncomplete + } + + override fun isSpecial(): Boolean { + return true + } + + fun toFinished(): FinishedRecipe { + return SERIALIZER.toFinished(this) + } + + fun energetic() = Energy(this) + fun matter() = Matter(this) + + open class Energy(val parent: MatterEntanglerRecipe) : IMatterEntanglerRecipe by parent { + override fun assemble(container: CraftingContainer, registry: RegistryAccess): ItemStack { + return parent.assemble(container, registry).also { result -> + container.iterator().map { it.matteryEnergy }.filterNotNull().forEach { + result.matteryEnergy!!.batteryLevel += it.batteryLevel + } + } + } + + fun toFinished(): FinishedRecipe { + return ENERGY_SERIALIZER.toFinished(this) + } + + override fun getSerializer(): RecipeSerializer<*> { + return ENERGY_SERIALIZER + } + } + + open class Matter(val parent: MatterEntanglerRecipe) : IMatterEntanglerRecipe by parent { + override fun assemble(container: CraftingContainer, registry: RegistryAccess): ItemStack { + return parent.assemble(container, registry).also { result -> + container.iterator().map { it.matter }.filterNotNull().forEach { + result.matter!!.storedMatter += it.storedMatter + } + } + } + + fun toFinished(): FinishedRecipe { + return MATTER_SERIALIZER.toFinished(this) + } + + override fun getSerializer(): RecipeSerializer<*> { + return MATTER_SERIALIZER + } + } + + companion object { + val SERIALIZER = Codec2RecipeSerializer( + MatterEntanglerRecipe( + ResourceLocation(OverdriveThatMatters.MOD_ID, "null"), + IIngredientMatrix.Companion, + Decimal.ZERO, + 0.0, + ItemStack.EMPTY, + ) + ) { context -> + RecordCodecBuilder.create { + it.group( + IngredientMatrixCodec.fieldOf("ingredients").forGetter(MatterEntanglerRecipe::ingredients), + DecimalCodec.minRange(Decimal.ZERO).fieldOf("matter").forGetter(MatterEntanglerRecipe::matter), + Codec.DOUBLE.minRange(0.0).fieldOf("ticks").forGetter(MatterEntanglerRecipe::ticks), + ItemStack.CODEC.fieldOf("result").forGetter(MatterEntanglerRecipe::result), + Codec.STRING.optionalFieldOf("uuidKey", "uuid").forGetter(MatterEntanglerRecipe::uuidKey), + UUIDUtil.STRING_CODEC.optionalFieldOf("fixedUuid").forGetter(MatterEntanglerRecipe::fixedUuid) + ).apply(it) { a, b, c, d, e, f -> MatterEntanglerRecipe(context.id, a, b, c, d, e, f) } + } + } + + val ENERGY_SERIALIZER = SERIALIZER.xmap(::Energy, Energy::parent) + val MATTER_SERIALIZER = SERIALIZER.xmap(::Matter, Matter::parent) + } +} 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 61cda92bd..0e0d4ee77 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt @@ -125,7 +125,7 @@ class PainterRecipe( Codec.list(DyeColor.CODEC).xmap({ it.associateWith { 1 } }, { ArrayList(it.keys) }) to Predicate { it.values.all { it == 1 } }, Codec.unboundedMap(DyeColor.CODEC, Codec.INT.minRange(1)) to Predicate { true } ).fieldOf("dyes").forGetter(PainterRecipe::dyes), - ).apply(it) { a, b, c -> PainterRecipe(context.invoke(), a, b, c) } + ).apply(it) { a, b, c -> PainterRecipe(context.id, a, b, c) } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt index 08bc643f7..49ad6efd3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt @@ -89,7 +89,7 @@ class PlatePressRecipe( Codec.INT.minRange(1).optionalFieldOf("count", 1).forGetter(PlatePressRecipe::count), Codec.INT.minRange(0).optionalFieldOf("workTime", 200).forGetter(PlatePressRecipe::workTime), FloatProvider.CODEC.optionalFieldOf("experience", ConstantFloat.ZERO).forGetter(PlatePressRecipe::experience) - ).apply(it) { a, b, c, d, e -> PlatePressRecipe(context.invoke(), a, b, c, d, e) } + ).apply(it) { a, b, c, d, e -> PlatePressRecipe(context.id, a, b, c, d, e) } } } } 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 0a88fdb2a..8172c022a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt @@ -72,6 +72,7 @@ object MBlockEntities { val INFINITE_WATER_SOURCE by register(MNames.INFINITE_WATER_SOURCE, ::InfiniteWaterSourceBlockEntity, MBlocks::INFINITE_WATER_SOURCE) val DEV_CHEST by register(MNames.DEV_CHEST, ::DevChestBlockEntity, MBlocks::DEV_CHEST) val PAINTER by register(MNames.PAINTER, ::PainterBlockEntity, MBlocks::PAINTER) + val MATTER_ENTANGLER by register(MNames.MATTER_ENTANGLER, ::MatterEntanglerBlockEntity, MBlocks::MATTER_ENTANGLER) val POWERED_FURNACE: BlockEntityType by registry.register(MNames.POWERED_FURNACE) { BlockEntityType.Builder.of({ a, b -> MBlocks.POWERED_FURNACE.newBlockEntity(a, b) }, MBlocks.POWERED_FURNACE).build(null) } val POWERED_BLAST_FURNACE: BlockEntityType by registry.register(MNames.POWERED_BLAST_FURNACE) { BlockEntityType.Builder.of({ a, b -> MBlocks.POWERED_BLAST_FURNACE.newBlockEntity(a, b) }, MBlocks.POWERED_BLAST_FURNACE).build(null) } 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 4772c75de..c4218f292 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -64,6 +64,7 @@ import ru.dbotthepony.mc.otm.block.tech.AndroidChargerBlock import ru.dbotthepony.mc.otm.block.tech.CobblerBlock import ru.dbotthepony.mc.otm.block.tech.EssenceStorageBlock import ru.dbotthepony.mc.otm.block.decorative.PainterBlock +import ru.dbotthepony.mc.otm.block.matter.MatterEntanglerBlock import ru.dbotthepony.mc.otm.block.tech.PoweredFurnaceBlock import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.core.TranslatableComponent @@ -102,6 +103,7 @@ object MBlocks { val ESSENCE_STORAGE: EssenceStorageBlock by registry.register(MNames.ESSENCE_STORAGE) { EssenceStorageBlock() } val MATTER_RECONSTRUCTOR: MatterReconstructorBlock by registry.register(MNames.MATTER_RECONSTRUCTOR) { MatterReconstructorBlock() } val PAINTER: PainterBlock by registry.register(MNames.PAINTER) { PainterBlock() } + val MATTER_ENTANGLER: MatterEntanglerBlock by registry.register(MNames.MATTER_ENTANGLER) { MatterEntanglerBlock() } val STORAGE_BUS: Block by registry.register(MNames.STORAGE_BUS) { StorageBusBlock() } val STORAGE_IMPORTER: Block by registry.register(MNames.STORAGE_IMPORTER) { StorageImporterBlock() } 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 42e6ab499..ea35f1291 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -152,10 +152,11 @@ object MItems { } val PAINTER: BlockItem by registry.register(MNames.PAINTER) { BlockItem(MBlocks.PAINTER, DEFAULT_PROPERTIES) } + val MATTER_ENTANGLER: BlockItem by registry.register(MNames.MATTER_ENTANGLER) { BlockItem(MBlocks.MATTER_ENTANGLER, DEFAULT_PROPERTIES) } val MACHINES = SupplierList( ::ANDROID_STATION, ::ANDROID_CHARGER, ::BATTERY_BANK, ::MATTER_DECOMPOSER, ::MATTER_CAPACITOR_BANK, ::MATTER_CABLE, ::PATTERN_STORAGE, - ::MATTER_SCANNER, ::MATTER_PANEL, ::MATTER_REPLICATOR, ::MATTER_BOTTLER, ::ENERGY_COUNTER, ::CHEMICAL_GENERATOR, + ::MATTER_SCANNER, ::MATTER_PANEL, ::MATTER_REPLICATOR, ::MATTER_BOTTLER, ::MATTER_ENTANGLER, ::ENERGY_COUNTER, ::CHEMICAL_GENERATOR, ::MATTER_RECYCLER, ::PLATE_PRESS, ::TWIN_PLATE_PRESS, ::POWERED_FURNACE, ::POWERED_BLAST_FURNACE, ::POWERED_SMOKER, ::STORAGE_BUS, ::STORAGE_IMPORTER, ::STORAGE_EXPORTER, ::DRIVE_VIEWER, 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 fbc7042df..1c3af7f75 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt @@ -17,6 +17,7 @@ import ru.dbotthepony.mc.otm.client.screen.matter.MatterReconstructorScreen import ru.dbotthepony.mc.otm.client.screen.matter.MatterBottlerScreen import ru.dbotthepony.mc.otm.client.screen.matter.MatterCapacitorBankScreen import ru.dbotthepony.mc.otm.client.screen.matter.MatterDecomposerScreen +import ru.dbotthepony.mc.otm.client.screen.matter.MatterEntanglerScreen import ru.dbotthepony.mc.otm.client.screen.matter.MatterPanelScreen import ru.dbotthepony.mc.otm.client.screen.matter.MatterRecyclerScreen import ru.dbotthepony.mc.otm.client.screen.matter.MatterReplicatorScreen @@ -36,7 +37,7 @@ import ru.dbotthepony.mc.otm.client.screen.tech.CobblerScreen import ru.dbotthepony.mc.otm.client.screen.tech.EnergyCounterScreen import ru.dbotthepony.mc.otm.client.screen.tech.EnergyServoScreen import ru.dbotthepony.mc.otm.client.screen.tech.EssenceStorageScreen -import ru.dbotthepony.mc.otm.client.screen.tech.PainterScreen +import ru.dbotthepony.mc.otm.client.screen.decorative.PainterScreen import ru.dbotthepony.mc.otm.client.screen.tech.PlatePressScreen import ru.dbotthepony.mc.otm.client.screen.tech.PoweredFurnaceScreen import ru.dbotthepony.mc.otm.client.screen.tech.TwinPlatePressScreen @@ -48,6 +49,7 @@ import ru.dbotthepony.mc.otm.menu.matter.MatterReconstructorMenu import ru.dbotthepony.mc.otm.menu.matter.MatterBottlerMenu import ru.dbotthepony.mc.otm.menu.matter.MatterCapacitorBankMenu import ru.dbotthepony.mc.otm.menu.matter.MatterDecomposerMenu +import ru.dbotthepony.mc.otm.menu.matter.MatterEntanglerMenu import ru.dbotthepony.mc.otm.menu.matter.MatterPanelMenu import ru.dbotthepony.mc.otm.menu.matter.MatterRecyclerMenu import ru.dbotthepony.mc.otm.menu.matter.MatterReplicatorMenu @@ -67,7 +69,7 @@ import ru.dbotthepony.mc.otm.menu.tech.CobblerMenu import ru.dbotthepony.mc.otm.menu.tech.EnergyCounterMenu import ru.dbotthepony.mc.otm.menu.tech.EnergyServoMenu import ru.dbotthepony.mc.otm.menu.tech.EssenceStorageMenu -import ru.dbotthepony.mc.otm.menu.tech.PainterMenu +import ru.dbotthepony.mc.otm.menu.decorative.PainterMenu import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu @@ -103,6 +105,7 @@ object MMenus { val ITEM_REPAIER: MenuType by registry.register(MNames.MATTER_RECONSTRUCTOR) { MenuType(::MatterReconstructorMenu, FeatureFlags.VANILLA_SET) } val FLUID_TANK: MenuType by registry.register(MNames.FLUID_TANK) { MenuType(::FluidTankMenu, FeatureFlags.VANILLA_SET) } val PAINTER: MenuType by registry.register(MNames.PAINTER) { MenuType(::PainterMenu, FeatureFlags.VANILLA_SET) } + val MATTER_ENTANGLER: MenuType by registry.register(MNames.MATTER_ENTANGLER) { MenuType(::MatterEntanglerMenu, FeatureFlags.VANILLA_SET) } val STORAGE_BUS: MenuType by registry.register(MNames.STORAGE_BUS) { MenuType(::StorageBusMenu, FeatureFlags.VANILLA_SET) } val STORAGE_IMPORTER_EXPORTER: MenuType by registry.register(MNames.STORAGE_IMPORTER) { MenuType(::StorageImporterExporterMenu, FeatureFlags.VANILLA_SET) } @@ -146,6 +149,7 @@ object MMenus { MenuScreens.register(FLUID_TANK, ::FluidTankScreen) MenuScreens.register(POWERED_FURNACE, ::PoweredFurnaceScreen) MenuScreens.register(PAINTER, ::PainterScreen) + MenuScreens.register(MATTER_ENTANGLER, ::MatterEntanglerScreen) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index cc48bc828..260392508 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -16,6 +16,7 @@ object MNames { const val INFINITE_WATER_SOURCE = "infinite_water_source" const val DEV_CHEST = "dev_chest" const val PAINTER = "painter" + const val MATTER_ENTANGLER = "matter_entangler" // blocks const val ANDROID_STATION = "android_station" diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt index 3894c5b2e..e5f4b98ee 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt @@ -10,6 +10,8 @@ import net.minecraftforge.registries.RegistryObject import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.recipe.EnergyContainerRecipe import ru.dbotthepony.mc.otm.recipe.ExplosiveHammerPrimingRecipe +import ru.dbotthepony.mc.otm.recipe.IMatterEntanglerRecipe +import ru.dbotthepony.mc.otm.recipe.MatterEntanglerRecipe import ru.dbotthepony.mc.otm.recipe.PainterRecipe import ru.dbotthepony.mc.otm.recipe.PlatePressRecipe import ru.dbotthepony.mc.otm.recipe.UpgradeRecipe @@ -38,6 +40,7 @@ object MRecipes { val PLATE_PRESS by register("plate_press") val PAINTER by register("painter") + val MATTER_ENTANGLER by register("matter_entangler") init { serializers.register("plate_press") { PlatePressRecipe.SERIALIZER } @@ -45,5 +48,8 @@ object MRecipes { serializers.register("upgrade") { UpgradeRecipe.Companion } serializers.register("hammer_priming") { ExplosiveHammerPrimingRecipe.Companion } serializers.register("painter") { PainterRecipe.SERIALIZER } + serializers.register("matter_entangler") { MatterEntanglerRecipe.SERIALIZER } + serializers.register("matter_entangler_energetic") { MatterEntanglerRecipe.ENERGY_SERIALIZER } + serializers.register("matter_entangler_matter") { MatterEntanglerRecipe.MATTER_SERIALIZER } } } From 2e4984162b6bf40b492748d64de0659a41c63b7e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 17 Aug 2023 22:55:44 +0700 Subject: [PATCH 0981/1199] Add manual invalidation to counter lazies --- .../core/util/AtomicallyInvalidatedLazy.kt | 14 +++++++---- .../otm/core/util/CounterInvalidatedLazy.kt | 25 ++++++++++++++++--- .../mc/otm/core/util/InvalidableLazy.kt | 5 ++++ 3 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/util/InvalidableLazy.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/AtomicallyInvalidatedLazy.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/AtomicallyInvalidatedLazy.kt index 76b16fe62..d8c7c0593 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/AtomicallyInvalidatedLazy.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/AtomicallyInvalidatedLazy.kt @@ -7,7 +7,7 @@ import java.util.function.IntSupplier /** * If synchronization is not required, [CounterInvalidatedLazy] should be used instead. */ -class AtomicallyInvalidatedLazy(private val invalidator: IntSupplier, private val initializer: () -> V) : Lazy { +class AtomicallyInvalidatedLazy(private val invalidator: IntSupplier, private val initializer: () -> V) : InvalidableLazy { constructor(invalidator: AtomicInteger, initializer: () -> V) : this(invalidator::get, initializer) @Volatile @@ -18,10 +18,7 @@ class AtomicallyInvalidatedLazy(private val invalidator: IntSupplier, private override val value: V get() { if (thisCounter != invalidator.asInt) { - lock.lock() - this.stored = Companion - thisCounter = invalidator.asInt - lock.unlock() + invalidate() } var stored = stored @@ -40,6 +37,13 @@ class AtomicallyInvalidatedLazy(private val invalidator: IntSupplier, private } } + override fun invalidate() { + lock.lock() + this.stored = Companion + thisCounter = invalidator.asInt + lock.unlock() + } + override fun isInitialized(): Boolean { return stored !== Companion && thisCounter == invalidator.asInt } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/CounterInvalidatedLazy.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/CounterInvalidatedLazy.kt index eb277cdc3..aa398a7fd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/CounterInvalidatedLazy.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/CounterInvalidatedLazy.kt @@ -7,9 +7,9 @@ import java.util.function.IntSupplier /** * This lazy is not synchronized, so in event of two or more threads accessing value behavior of this implementation is undefined * - * For synchronized use case, [AtomicallyInvalidatedLazy] should be used + * For thread synchronized use case, [AtomicallyInvalidatedLazy] should be used */ -fun countingLazy(invalidator: IntSupplier, initializer: () -> V): Lazy { +fun countingLazy(invalidator: IntSupplier, initializer: () -> V): InvalidableLazy { if (invalidator is IntCounter) { return SmartCounterInvalidatedLazy(invalidator, initializer) } @@ -17,12 +17,21 @@ fun countingLazy(invalidator: IntSupplier, initializer: () -> V): Lazy { return CounterInvalidatedLazy(invalidator, initializer) } +/** + * This lazy is not synchronized, so in event of two or more threads accessing value behavior of this implementation is undefined + * + * For thread synchronized use case, [AtomicallyInvalidatedLazy] should be used + */ +fun countingLazy(invalidator: AtomicInteger, initializer: () -> V): InvalidableLazy { + return CounterInvalidatedLazy(invalidator, initializer) +} + /** * This lazy is not synchronized, so in event of two or more threads accessing value behavior of this implementation is undefined * * For synchronized use case, [AtomicallyInvalidatedLazy] should be used */ -class CounterInvalidatedLazy(private val invalidator: IntSupplier, private val initializer: () -> V) : Lazy { +class CounterInvalidatedLazy(private val invalidator: IntSupplier, private val initializer: () -> V) : InvalidableLazy { constructor(invalidator: AtomicInteger, initializer: () -> V) : this(invalidator::get, initializer) private var thisCounter = -1 @@ -44,6 +53,10 @@ class CounterInvalidatedLazy(private val invalidator: IntSupplier, private va return stored !== Companion && thisCounter == invalidator.asInt } + override fun invalidate() { + this.stored = Companion + } + private companion object } @@ -52,7 +65,7 @@ class CounterInvalidatedLazy(private val invalidator: IntSupplier, private va * * For synchronized use case, [AtomicallyInvalidatedLazy] should be used */ -class SmartCounterInvalidatedLazy(invalidator: IntCounter, private val initializer: () -> V) : Lazy { +class SmartCounterInvalidatedLazy(invalidator: IntCounter, private val initializer: () -> V) : InvalidableLazy { init { invalidator.addListener(IntConsumer { stored = Companion @@ -72,6 +85,10 @@ class SmartCounterInvalidatedLazy(invalidator: IntCounter, private val initia return stored } + override fun invalidate() { + this.stored = Companion + } + override fun isInitialized(): Boolean { return stored !== Companion } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/InvalidableLazy.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/InvalidableLazy.kt new file mode 100644 index 000000000..f6c16c449 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/InvalidableLazy.kt @@ -0,0 +1,5 @@ +package ru.dbotthepony.mc.otm.core.util + +interface InvalidableLazy : Lazy { + fun invalidate() +} From eff453ed1c961f440a0bcddf0220dfa294aa97a9 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 17 Aug 2023 22:59:30 +0700 Subject: [PATCH 0982/1199] Improve performance of IIngredientMatrix.isIncomplete inside baseline implementation --- .../dbotthepony/mc/otm/OverdriveThatMatters.java | 14 ++++++++++++++ .../dbotthepony/mc/otm/recipe/IngredientMatrix.kt | 13 +++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 09e068c58..350d59128 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -4,6 +4,7 @@ import kotlin.KotlinVersion; import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; +import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.eventbus.api.EventPriority; @@ -13,6 +14,7 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.registries.IdMappingEvent; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import ru.dbotthepony.mc.otm.android.AndroidResearchManager; @@ -60,6 +62,7 @@ import top.theillusivec4.curios.api.CuriosApi; import static net.minecraftforge.common.MinecraftForge.EVENT_BUS; import javax.annotation.ParametersAreNonnullByDefault; +import java.util.concurrent.atomic.AtomicInteger; // The value here should match an entry in the META-INF/mods.toml file @Mod(OverdriveThatMatters.MOD_ID) @@ -69,6 +72,17 @@ public final class OverdriveThatMatters { // Directly reference a log4j logger. public static final String MOD_ID = "overdrive_that_matters"; private static final Logger LOGGER = LogManager.getLogger(); + public static final AtomicInteger INGREDIENT_CACHE_INVALIDATION_COUNTER; + + static { + try { + var f = Ingredient.class.getDeclaredField("INVALIDATION_COUNTER"); + f.setAccessible(true); + INGREDIENT_CACHE_INVALIDATION_COUNTER = (AtomicInteger) f.get(null); + } catch (IllegalAccessException | NoSuchFieldException e) { + throw new RuntimeException(e); + } + } public static OverdriveThatMatters INSTANCE; public static ResourceLocation loc(String path) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/IngredientMatrix.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/IngredientMatrix.kt index 41f9c019a..07a50aad2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/IngredientMatrix.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/IngredientMatrix.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.recipe import net.minecraft.core.NonNullList import net.minecraft.world.inventory.CraftingContainer import net.minecraft.world.item.crafting.Ingredient +import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.container.get import ru.dbotthepony.mc.otm.core.collect.allEqual import ru.dbotthepony.mc.otm.core.collect.any @@ -10,6 +11,7 @@ import ru.dbotthepony.mc.otm.core.collect.flatMap import ru.dbotthepony.mc.otm.core.collect.map import ru.dbotthepony.mc.otm.core.isActuallyEmpty import ru.dbotthepony.mc.otm.core.isNotEmpty +import ru.dbotthepony.mc.otm.core.util.countingLazy import java.util.function.Predicate interface IIngredientMatrix : Predicate, Iterable { @@ -119,6 +121,16 @@ interface IIngredientMatrix : Predicate, Iterable class IngredientMatrix(override val width: Int, override val height: Int) : IIngredientMatrix { private val data = Array(width * height) { Ingredient.EMPTY } + private val lazy = countingLazy(OverdriveThatMatters.INGREDIENT_CACHE_INVALIDATION_COUNTER) { + super.isIncomplete + } + + override val isIncomplete by lazy + + override fun iterator(): Iterator { + return data.iterator() + } + override fun get(column: Int, row: Int): Ingredient { require(column in 0 until width) { "Column out of bounds: $column (matrix width: $width)" } require(row in 0 until height) { "Row out of bounds: $row > (matrix height: $height)" } @@ -129,6 +141,7 @@ class IngredientMatrix(override val width: Int, override val height: Int) : IIng require(column in 0 until width) { "Column out of bounds: $column (matrix width: $width)" } require(row in 0 until height) { "Row out of bounds: $row > (matrix height: $height)" } data[column + row * width] = value + lazy.invalidate() } companion object { From 933521df107b6e33b75f05c06d4dc0e83f9a2168 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 17 Aug 2023 23:05:03 +0700 Subject: [PATCH 0983/1199] Remove unused functions --- .../ru/dbotthepony/mc/otm/recipe/Helpers.kt | 59 ------------------- 1 file changed, 59 deletions(-) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/recipe/Helpers.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/Helpers.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/Helpers.kt deleted file mode 100644 index dee95301c..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/Helpers.kt +++ /dev/null @@ -1,59 +0,0 @@ -package ru.dbotthepony.mc.otm.recipe - -import com.google.gson.JsonElement -import com.google.gson.JsonObject -import com.google.gson.JsonPrimitive -import net.minecraft.resources.ResourceLocation -import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.Items -import net.minecraftforge.registries.ForgeRegistries -import ru.dbotthepony.mc.otm.core.registryName -import ru.dbotthepony.mc.otm.container.set -import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.core.set - -fun stackFromJson(obj: JsonElement, field: String = ""): ItemStack { - if (obj is JsonPrimitive) { - check(obj.isString) { "Field $field is supposed to be an Item, but it is malformed (not a string and not an object)" } - val item = ForgeRegistries.ITEMS.getValue(ResourceLocation(obj.asString)) ?: return ItemStack.EMPTY - - if (item === Items.AIR) { - return ItemStack.EMPTY - } - - return ItemStack(item, 1) - } - - if (obj is JsonObject) { - val name = obj["name"] as? JsonPrimitive ?: throw IllegalStateException("Invalid name of $field") - check(name.isString) { "Invalid name of $field (supposed to be a string)" } - val item = ForgeRegistries.ITEMS.getValue(ResourceLocation(name.asString)) ?: return ItemStack.EMPTY - - val count = (obj["count"] as? JsonPrimitive)?.let { - try { - return@let it.asInt - } catch(err: Throwable) { - throw IllegalStateException("Invalid format of count of $field (supposed to be a number)", err) - } - } ?: 1 - - check(count > 0) { "Field count of $field does not make any sense" } - - return ItemStack(item, count) - } - - throw IllegalStateException("Invalid or missing $field") -} - -fun stackToJson(stack: ItemStack, field: String = ""): JsonElement { - check(stack.count > 0) { "ItemStack $field is empty" } - - if (stack.count == 1) { - return JsonPrimitive(stack.item.registryName!!.toString()) - } - - return JsonObject().also { - it["name"] = JsonPrimitive(stack.item.registryName!!.toString()) - it["count"] = JsonPrimitive(stack.count) - } -} From 182bb4c8ba030137b0e52650f63b8fe2ac051e07 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 18 Aug 2023 13:59:57 +0700 Subject: [PATCH 0984/1199] Make Codec2RecipeSerializer thread safe --- .../mc/otm/data/Codec2RecipeSerializer.kt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt index bd43dd751..16e1830f7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt @@ -18,16 +18,25 @@ import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.core.util.readBinaryJsonWithCodecIndirect import ru.dbotthepony.mc.otm.core.util.writeBinaryJsonWithCodec import kotlin.collections.ArrayDeque +import kotlin.concurrent.getOrSet class Codec2RecipeSerializer> private constructor( val empty: S?, - private val id: ArrayDeque, + + /** + * [ThreadLocal] because optimization mods can (and probably should) parallelize recipe deserialization, + * since RecipeSerializers are expected to be stateless. [Codec2RecipeSerializer], however, is stateful (threading PoV). + * To make it stateless, [ThreadLocal] is used. + */ + private val idStack: ThreadLocal>, codec: (Codec2RecipeSerializer.Context) -> Codec, ) : Codec, RecipeSerializer { - constructor(empty: S?, codec: (Codec2RecipeSerializer.Context) -> Codec) : this(empty, ArrayDeque(), codec) + constructor(empty: S?, codec: (Codec2RecipeSerializer.Context) -> Codec) : this(empty, ThreadLocal(), codec) constructor(supplier: (Codec2RecipeSerializer.Context) -> Codec) : this(null, supplier) private val codec = codec.invoke(Context()) + private val id: ArrayDeque + get() = idStack.getOrSet { ArrayDeque() } inner class Context() { val id: ResourceLocation @@ -65,7 +74,7 @@ class Codec2RecipeSerializer> private constructor( } fun > xmap(to: (S) -> O, from: (O) -> S): Codec2RecipeSerializer { - return Codec2RecipeSerializer(empty?.let(to), id) { _ -> + return Codec2RecipeSerializer(empty?.let(to), idStack) { _ -> codec.xmap(to, from) } } From 0428b60561743af122a23f6be823fee4f81deff1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 18 Aug 2023 21:05:35 +0700 Subject: [PATCH 0985/1199] Update pattern monitor --- .../mc/otm/datagen/lang/English.kt | 4 + .../mc/otm/datagen/lang/Russian.kt | 4 + .../entity/matter/MatterPanelBlockEntity.kt | 66 ++++++++----- .../mc/otm/client/render/Widgets18.kt | 3 + .../client/screen/matter/MatterPanelScreen.kt | 32 ++++++- .../button/BooleanRectangleButtonPanel.kt | 19 ++-- .../client/screen/panels/button/Buttons.kt | 10 +- .../LargeBooleanRectangleButtonPanel.kt | 8 +- .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 22 ++++- .../dbotthepony/mc/otm/core/GetterSetter.kt | 21 +++-- .../otm/graph/matter/IMatterGraphListener.kt | 15 +++ .../mc/otm/menu/matter/MatterPanelMenu.kt | 89 +++++++++++------- .../network/synchronizer/FieldSynchronizer.kt | 9 +- .../textures/gui/widgets/storage_controls.png | Bin 981 -> 1020 bytes .../textures/gui/widgets/storage_controls.xcf | Bin 7924 -> 9801 bytes 15 files changed, 218 insertions(+), 84 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 552ad9e19..cbc045636 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -824,6 +824,10 @@ private fun gui(provider: MatteryLanguageProvider) { gui("matter_panel.label", "Replication request") gui("matter_panel.task", "Ongoing replication task") gui("matter_panel.task_line", "%s: %s | %s / %s") + gui("matter_panel.is_providing_tasks", "Tasks are dispatched to replicators") + gui("matter_panel.not_providing_tasks", "Tasks are NOT dispatched to replicators") + gui("matter_panel.cancel_all", "Cancel all tasks") + gui("matter_panel.cancel_all.desc", "Do you really want to cancel all replication tasks?") gui("matter_panel.tasks", "Tasks") gui("matter_panel.patterns", "Patterns") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 6aea07d4d..0bd7a8786 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -821,6 +821,10 @@ private fun gui(provider: MatteryLanguageProvider) { gui("matter_panel.cancel", "Отмена") gui("matter_panel.label", "Запрос на репликацию") gui("matter_panel.task", "Будущий запрос на репликацию") + gui("matter_panel.is_providing_tasks", "Задачи передаются на репликаторы") + gui("matter_panel.not_providing_tasks", "Задачи НЕ передаются на репликаторы") + gui("matter_panel.cancel_all", "Отменить все задачи") + gui("matter_panel.cancel_all.desc", "Вы действительно хотите отменить все задачи репликации?") gui("matter_panel.tasks", "Задачи") gui("matter_panel.patterns", "Шаблоны") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt index 427dc6b5c..7b96e91f1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt @@ -15,22 +15,32 @@ import net.minecraft.world.level.Level import net.minecraftforge.common.util.INBTSerializable import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.matter.* +import ru.dbotthepony.mc.otm.core.collect.WeakHashSet import ru.dbotthepony.mc.otm.core.nbt.getBoolean import ru.dbotthepony.mc.otm.core.nbt.getCompoundList import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.mapString import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.ItemSorter -import ru.dbotthepony.mc.otm.graph.matter.MatterGraph import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode import ru.dbotthepony.mc.otm.registry.MBlockEntities import java.util.* import java.util.stream.Stream -class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : - MatteryDeviceBlockEntity(MBlockEntities.MATTER_PANEL, p_155229_, p_155230_), IReplicationTaskProvider { +class MatterPanelBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.MATTER_PANEL, blockPos, blockState), IReplicationTaskProvider { + inner class PlayerSettings : INBTSerializable { + var sorter: ItemSorter = ItemSorter.DEFAULT + set(value) { + field = value + markDirtyFast() + } + + var ascending: Boolean = true + set(value) { + field = value + markDirtyFast() + } - class PlayerSettings(var sorter: ItemSorter = ItemSorter.DEFAULT, var ascending: Boolean = true) : INBTSerializable { override fun serializeNBT(): CompoundTag { return CompoundTag().also { it["sorter"] = sorter.name @@ -44,20 +54,35 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } } + var isProvidingTasks = true + set(value) { + if (field != value) { + field = value + + if (value) { + _tasks.values.forEach { matterNode.graph.onMatterTaskCreated(it) } + } else { + _tasks.values.forEach { if (it.inProgress == 0) matterNode.graph.onMatterTaskRemoved(it) } + } + + markDirtyFast() + } + } + private val playerSettings = Object2ObjectOpenHashMap() fun getPlayerSettings(ply: Player): PlayerSettings { return playerSettings.computeIfAbsent(ply.uuid, Object2ObjectFunction { PlayerSettings() }) } - private val listeners = ArrayList() + private val listeners = WeakHashSet() val matterNode = SimpleMatterNode(tasks = this) fun attachMenu(menu: MatterPanelMenu) { listeners.add(menu) } - fun deatachMenu(menu: MatterPanelMenu) { + fun detachMenu(menu: MatterPanelMenu) { listeners.remove(menu) } @@ -91,18 +116,18 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : } override fun allocateTask(simulate: Boolean): ReplicationTaskAllocation? { - val graph = matterNode.graph as MatterGraph? ?: return null + if (!isProvidingTasks) return null for ((key, task) in _tasks) { if (task.required > 0) { - val pattern = task.patternId.map(graph::getPattern).orElse(null) ?: continue + val pattern = task.patternId.map(matterNode.graph::getPattern).orElse(null) ?: continue if (!simulate) { val new = task.allocate() _tasks[key] = new listeners.forEach { it.taskUpdated(new) } - graph.onMatterTaskUpdated(new, task) - setChanged() + matterNode.graph.onMatterTaskUpdated(new, task) + markDirtyFast() } return ReplicationTaskAllocation(task, pattern) @@ -115,23 +140,21 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : override fun notifyTaskCompletion(taskId: UUID): Boolean { var localTask = _tasks[taskId] ?: return false val oldTask = localTask - localTask = localTask.finish() - val graph = matterNode.graph as MatterGraph? // Задача полностью выполнена if (localTask.required <= 0 && localTask.inProgress <= 0) { _tasks.remove(taskId) - graph?.onMatterTaskFinished(localTask) + matterNode.graph.onMatterTaskFinished(localTask) listeners.forEach { it.taskRemoved(localTask) } } else { // Задача обновлена _tasks[taskId] = localTask - graph?.onMatterTaskUpdated(localTask, oldTask) + matterNode.graph.onMatterTaskUpdated(localTask, oldTask) listeners.forEach { it.taskUpdated(localTask) } } - setChanged() + markDirtyFast() return true } @@ -189,27 +212,26 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : matterNode.graph.onMatterTaskRemoved(task) listeners.forEach { it.taskRemoved(task) } - setChanged() + markDirtyFast() } fun addTask(state: PatternState, count: Int): ReplicationTask { val task = ReplicationTask(UUID.randomUUID(), Optional.of(state.id), state.item, 0, 0, count) _tasks[task.id] = task - matterNode.graph.onMatterTaskCreated(task) + if (isProvidingTasks) + matterNode.graph.onMatterTaskCreated(task) listeners.forEach { it.taskUpdated(task) } - setChanged() + markDirtyFast() return task } override fun dropAllTasks() { - val graph = matterNode.graph as MatterGraph? - for (task in _tasks.values) { - graph?.onMatterTaskRemoved(task) - listeners.forEach { menu: MatterPanelMenu -> menu.taskUpdated(task) } + matterNode.graph.onMatterTaskRemoved(task) + listeners.forEach { it.taskRemoved(task) } } _tasks.clear() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt index 82d7bb6eb..d25039af3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt @@ -50,6 +50,9 @@ object Widgets18 { val ONLY_STORE = storageGrid.next() val ONLY_EXTRACT = storageGrid.next() val STORE_EXTRACT = storageGrid.next() + val PAUSE = storageGrid.next() + val PLAY = storageGrid.next() + val STOP = storageGrid.next() private val miscGrid = WidgetLocation.MISC_18.grid(4, 4) 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 6b03bc50e..89829584b 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 @@ -14,13 +14,14 @@ import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.button.ButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.DeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeBooleanRectangleButtonPanel -import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeEnumRectangleButtonPanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.input.TextInputPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.ScrollBarConstants import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.asGetterSetter import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.integerDivisionDown import ru.dbotthepony.mc.otm.core.util.ItemSorter @@ -54,12 +55,39 @@ class MatterPanelScreen( val controls = DeviceControls(this, frame) - controls.sortingButtons(menu.isAscendingGS, menu.sortingGS, ItemSorter.DEFAULT) { + controls.sortingButtons(menu::isAscending.asGetterSetter(), menu::sorting.asGetterSetter(), ItemSorter.DEFAULT) { for (v in ItemSorter.entries) { add(v, skinElement = v.icon, tooltip = v.title) } } + controls.addButton( + LargeBooleanRectangleButtonPanel( + this, + frame, + prop = menu::isProvidingTasks.asGetterSetter(), + iconActive = Widgets18.PLAY, + iconInactive = Widgets18.PAUSE, + tooltipActive = TranslatableComponent("otm.gui.matter_panel.is_providing_tasks"), + tooltipInactive = TranslatableComponent("otm.gui.matter_panel.not_providing_tasks"), + ) + ) + + controls.addButton( + LargeRectangleButtonPanel( + this, + frame, + skinElement = Widgets18.STOP, + onPress = { + frame.queryUser( + TranslatableComponent("otm.gui.matter_panel.cancel_all"), + listOf(TranslatableComponent("otm.gui.matter_panel.cancel_all.desc")), + { menu.cancelAll.accept(null) } + ) + } + ) + ) + val scrollBar = DiscreteScrollBarPanel(this, frame, { if (isPatternView) { integerDivisionDown(menu.patternsFiltered.size, GRID_WIDTH) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt index d6000d0a5..52e2c716d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt @@ -9,6 +9,7 @@ import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.TextComponent +import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.value import ru.dbotthepony.mc.otm.menu.input.IPlayerInputWithFeedback @@ -20,8 +21,8 @@ abstract class BooleanRectangleButtonPanel( width: Float, height: Float, val prop: GetterSetter, - var skinElementActive: IGUIRenderable? = null, - var skinElementInactive: IGUIRenderable? = null, + var iconActive: IGUIRenderable? = null, + var iconInactive: IGUIRenderable? = null, val onChange: ((newValue: Boolean) -> Unit)? = null, var tooltipActive: Component? = null, var tooltipInactive: Component? = null, @@ -48,11 +49,17 @@ abstract class BooleanRectangleButtonPanel( } if (tooltipActive != null) { - tooltips.add(tooltipActive.copy().withStyle(if (prop.get()) ChatFormatting.WHITE else ChatFormatting.GRAY)) + if (prop.get()) + tooltips.add(TranslatableComponent("otm.gui.tooltip.enum.active", tooltipActive.copy().withStyle(ChatFormatting.WHITE))) + else + tooltips.add(tooltipActive.copy().withStyle(ChatFormatting.GRAY)) } if (tooltipInactive != null) { - tooltips.add(tooltipInactive.copy().withStyle(if (!prop.get()) ChatFormatting.WHITE else ChatFormatting.GRAY)) + if (prop.get()) + tooltips.add(tooltipInactive.copy().withStyle(ChatFormatting.GRAY)) + else + tooltips.add(TranslatableComponent("otm.gui.tooltip.enum.active", tooltipInactive.copy().withStyle(ChatFormatting.WHITE))) } graphics.renderComponentTooltip(font, tooltips, mouseX.toInt(), mouseY.toInt()) @@ -76,9 +83,9 @@ abstract class BooleanRectangleButtonPanel( super.innerRender(graphics, mouseX, mouseY, partialTick) if (prop.value) { - skinElementActive?.render(graphics, width = width, height = height) + iconActive?.render(graphics, width = width, height = height) } else { - skinElementInactive?.render(graphics, width = width, height = height) + iconInactive?.render(graphics, width = width, height = height) } } 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 4bc9763ea..08a59178e 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 @@ -18,7 +18,6 @@ import ru.dbotthepony.mc.otm.client.render.ItemStackIcon import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.Dock -import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel @@ -30,7 +29,6 @@ import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.math.RelativeSide -import ru.dbotthepony.mc.otm.core.util.ItemSorter import ru.dbotthepony.mc.otm.core.value import ru.dbotthepony.mc.otm.menu.UpgradeSlots import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback @@ -359,8 +357,8 @@ class DeviceControls>( screen, this, prop = ascending, - skinElementActive = Widgets18.ARROW_UP, - skinElementInactive = Widgets18.ARROW_DOWN, + iconActive = Widgets18.ARROW_UP, + iconInactive = Widgets18.ARROW_DOWN, tooltipActive = TranslatableComponent("otm.gui.sorting.ascending"), tooltipInactive = TranslatableComponent("otm.gui.sorting.descending"), ).also { @@ -466,8 +464,8 @@ class DeviceControls>( balanceInputsButton = addButton(LargeBooleanRectangleButtonPanel( screen, this, prop = balanceInputs, - skinElementActive = Widgets18.BALANCING_ENABLED, - skinElementInactive = Widgets18.BALANCING_DISABLED).also { + iconActive = Widgets18.BALANCING_ENABLED, + iconInactive = Widgets18.BALANCING_DISABLED).also { it.tooltips.add(TranslatableComponent("otm.gui.balance_inputs")) }) } else { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeBooleanRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeBooleanRectangleButtonPanel.kt index fb36e1996..714d701b9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeBooleanRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeBooleanRectangleButtonPanel.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component -import ru.dbotthepony.mc.otm.client.render.sprites.AbstractMatterySprite +import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.GetterSetter @@ -15,12 +15,12 @@ open class LargeBooleanRectangleButtonPanel( width: Float = SIZE, height: Float = SIZE, prop: GetterSetter, - skinElementActive: AbstractMatterySprite? = null, - skinElementInactive: AbstractMatterySprite? = null, + iconActive: IGUIRenderable? = null, + iconInactive: IGUIRenderable? = null, onChange: ((newValue: Boolean) -> Unit)? = null, tooltipActive: Component? = null, tooltipInactive: Component? = null, -) : BooleanRectangleButtonPanel(screen, parent, x, y, width, height, prop, skinElementActive, skinElementInactive, onChange, tooltipActive, tooltipInactive) { +) : BooleanRectangleButtonPanel(screen, parent, x, y, width, height, prop, iconActive, iconInactive, onChange, tooltipActive, tooltipInactive) { final override val IDLE = Widgets18.BUTTON_IDLE final override val HOVERED = Widgets18.BUTTON_HOVERED final override val PRESSED = Widgets18.BUTTON_PRESSED 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 af897288a..5e7847a5c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -375,12 +375,30 @@ fun Comparator.nullsLast(): Comparator { return Comparator.nullsLast(this as Comparator) } +class MappedComparator(private val parent: Comparator, private val mapper: (T) -> O) : Comparator { + override fun compare(o1: T, o2: T): Int { + return parent.compare(mapper.invoke(o1), mapper.invoke(o2)) + } + + override fun equals(other: Any?): Boolean { + return other is MappedComparator<*, *> && parent == other.parent + } + + override fun hashCode(): Int { + return parent.hashCode() + } + + override fun toString(): String { + return "MappedComparator[$parent]" + } +} + fun Comparator.map(mapper: (B) -> A): Comparator { - return Comparator { a, b -> this@map.compare(mapper.invoke(a), mapper.invoke(b)) } + return MappedComparator(this, mapper) } fun Comparator.suppliers(): Comparator> { - return Comparator { o1, o2 -> this@suppliers.compare(o1.get(), o2.get()) } + return MappedComparator(this) { it.get() } } /** diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt index 258840f95..a0bac0048 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/GetterSetter.kt @@ -43,11 +43,7 @@ interface GetterSetter : Supplier, Consumer, ReadWriteProperty fun watch(watch: (old: V, new: V) -> Unit): GetterSetter { val self = this - return object : GetterSetter { - override fun get(): V { - return self.get() - } - + return object : GetterSetter by self { override fun accept(t: V) { val old = get() self.accept(t) @@ -116,7 +112,20 @@ interface GetterSetter : Supplier, Consumer, ReadWriteProperty } } -interface SentientGetterSetter : GetterSetter, ISubscriptable +interface SentientGetterSetter : GetterSetter, ISubscriptable { + override fun watch(watch: (old: V, new: V) -> Unit): SentientGetterSetter { + val self = this + + return object : SentientGetterSetter by self { + override fun accept(t: V) { + val old = get() + self.accept(t) + watch.invoke(old, t) + } + } + } + +} operator fun Supplier.getValue(thisRef: Any?, property: KProperty<*>): T { return get() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/IMatterGraphListener.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/IMatterGraphListener.kt index 171668334..f4aebfb66 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/IMatterGraphListener.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/matter/IMatterGraphListener.kt @@ -7,8 +7,23 @@ interface IMatterGraphListener { fun onPatternRemoved(state: PatternState) {} fun onPatternUpdated(newState: PatternState, oldState: PatternState) {} + /** + * This can be called any amount of times with the same task + */ fun onMatterTaskCreated(task: ReplicationTask) {} + + /** + * This can be called any amount of times with the same task + */ fun onMatterTaskUpdated(newState: ReplicationTask, oldState: ReplicationTask) {} + + /** + * This can be called any amount of times with the same task + */ fun onMatterTaskFinished(state: ReplicationTask) {} + + /** + * This can be called any amount of times with the same task + */ fun onMatterTaskRemoved(state: ReplicationTask) {} } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt index 86d586ee0..98e96e49d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt @@ -13,21 +13,22 @@ import ru.dbotthepony.mc.otm.capability.matter.* import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.addSorted +import ru.dbotthepony.mc.otm.core.map import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.util.BooleanValueCodec import ru.dbotthepony.mc.otm.core.util.DecimalValueCodec import ru.dbotthepony.mc.otm.core.util.ItemSorter +import ru.dbotthepony.mc.otm.core.util.NullValueCodec import ru.dbotthepony.mc.otm.core.util.codec import ru.dbotthepony.mc.otm.core.util.writeCollection import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphListener import ru.dbotthepony.mc.otm.graph.matter.MatterGraph import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback import ru.dbotthepony.mc.otm.network.* import ru.dbotthepony.mc.otm.registry.MMenus import java.util.* import java.util.function.Predicate import java.util.function.Supplier -import kotlin.Comparator import kotlin.collections.ArrayList class CancelTaskPacket(val id: UUID) : MatteryPacket { @@ -128,10 +129,10 @@ class ReplicationRequestPacket(val id: UUID, amount: Int) : MatteryPacket { } class MatterPanelMenu( - p_38852_: Int, + containerId: Int, inventory: Inventory, tile: MatterPanelBlockEntity? = null -) : MatteryMenu(MMenus.MATTER_PANEL, p_38852_, inventory, tile), IMatterGraphListener { +) : MatteryMenu(MMenus.MATTER_PANEL, containerId, inventory, tile), IMatterGraphListener { fun taskUpdated(task: ReplicationTask) { sendNetwork(TasksChangePacket(true, listOf(task))) } @@ -140,25 +141,36 @@ class MatterPanelMenu( sendNetwork(TasksChangePacket(false, listOf(task))) } - val sorting: ItemSorter by mSynchronizer.ComputedField( - getter = { tile?.getPlayerSettings(player)?.sorter ?: ItemSorter.DEFAULT }, - codec = ItemSorter::class.codec(), - observer = { - patterns.sortWith(actualComparator) - patternsFiltered.sortWith(actualComparator) - tasks.sortWith(actualTaskComparator) - tasksFiltered.sortWith(actualTaskComparator) - }) + private fun updateComparators() { + var p = sorting.map(PatternState::item) + var t = sorting.map(ReplicationTask::item) - val isAscending: Boolean by mSynchronizer.ComputedField( - getter = { tile?.getPlayerSettings(player)?.ascending ?: true }, - codec = BooleanValueCodec, - observer = { - patterns.sortWith(actualComparator) - patternsFiltered.sortWith(actualComparator) - tasks.sortWith(actualTaskComparator) - tasksFiltered.sortWith(actualTaskComparator) - }) + if (!isAscending) { + p = p.reversed() + t = t.reversed() + } + + patternComparator = p + taskComparator = t + } + + var sorting: ItemSorter by GetterSetter.of( + mSynchronizer.ComputedField( + getter = { tile?.getPlayerSettings(player)?.sorter ?: ItemSorter.DEFAULT }, + codec = ItemSorter::class.codec(), + observer = { updateComparators() }), + PlayerInput(ItemSorter::class.codec(), allowSpectators = true) { tile?.getPlayerSettings(player)?.sorter = it } + ) + + var isAscending: Boolean by GetterSetter.of( + mSynchronizer.ComputedBooleanField( + getter = { tile?.getPlayerSettings(player)?.ascending ?: true }, + observer = { updateComparators() }), + booleanInput(allowSpectators = true) { tile?.getPlayerSettings(player)?.ascending = it } + ) + + var isProvidingTasks by BooleanInputWithFeedback(this, tile?.let { it::isProvidingTasks }) + val cancelAll = PlayerInput(NullValueCodec) { tile?.dropAllTasks() } val totalMatterStored: Decimal by mSynchronizer.ComputedField( getter = { tile?.matterNode?.graph?.getMatterStorageLevel() ?: Decimal.ZERO }, @@ -184,14 +196,23 @@ class MatterPanelMenu( } } - val changeIsAscending = booleanInput(allowSpectators = true) { tile?.getPlayerSettings(player)?.ascending = it } - val changeSorting = PlayerInput(ItemSorter::class.codec(), allowSpectators = true) { tile?.getPlayerSettings(player)?.sorter = it } + private var patternComparator = sorting.map(PatternState::item) + set(value) { + if (value != field) { + field = value + patterns.sortWith(value) + patternsFiltered.sortWith(value) + } + } - val sortingGS = GetterSetter.of(::sorting, changeSorting::accept) - val isAscendingGS = GetterSetter.of(::isAscending, changeIsAscending::accept) - - private val actualComparator = Comparator { o1, o2 -> sorting.compare(o1.item, o2.item) * (if (isAscending) 1 else -1) } - private val actualTaskComparator = Comparator { o1, o2 -> sorting.compare(o1.item, o2.item) * (if (isAscending) 1 else -1) } + private var taskComparator = sorting.map(ReplicationTask::item) + set(value) { + if (value != field) { + field = value + tasks.sortWith(value) + tasksFiltered.sortWith(value) + } + } private val patterns = ArrayList() private val tasks = ArrayList() @@ -206,7 +227,7 @@ class MatterPanelMenu( if (index != -1) { this.patterns[index] = pattern } else { - this.patterns.addSorted(pattern, actualComparator) + this.patterns.addSorted(pattern, patternComparator) } if (filter.test(pattern.item)) { @@ -215,7 +236,7 @@ class MatterPanelMenu( if (index != -1) { this.patternsFiltered[index] = pattern } else { - this.patternsFiltered.addSorted(pattern, actualComparator) + this.patternsFiltered.addSorted(pattern, patternComparator) } } } @@ -234,7 +255,7 @@ class MatterPanelMenu( if (index != -1) { this.tasks[index] = task } else { - this.tasks.addSorted(task, actualTaskComparator) + this.tasks.addSorted(task, taskComparator) } if (filter.test(task.item)) { @@ -243,7 +264,7 @@ class MatterPanelMenu( if (index != -1) { this.tasksFiltered[index] = task } else { - this.tasksFiltered.addSorted(task, actualTaskComparator) + this.tasksFiltered.addSorted(task, taskComparator) } } } @@ -320,7 +341,7 @@ class MatterPanelMenu( override fun removed(p_38940_: Player) { super.removed(p_38940_) - (tile as MatterPanelBlockEntity?)?.deatachMenu(this) + (tile as MatterPanelBlockEntity?)?.detachMenu(this) listeningGrid?.removeListener(this) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt index 2e0051b61..c8140a121 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt @@ -1092,12 +1092,18 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa inner class ComputedField( private val getter: () -> V, private val codec: IStreamCodec, - private val observer: (new: V) -> Unit = {} + observer: ((new: V) -> Unit)? = null ) : AbstractField(), IField { private var remote: Any? = Mark private var clientValue: Any? = Mark private val subs = ISubscriptable.Impl() + init { + if (observer != null) { + subs.addListener(observer) + } + } + override fun addListener(listener: Consumer): ISubscriptable.L { return subs.addListener(listener) } @@ -1141,7 +1147,6 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa check(!isRemoved) { "Field was removed" } val newValue = codec.read(stream) clientValue = newValue - observer.invoke(newValue) subs.accept(newValue) } } diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/storage_controls.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/storage_controls.png index d12fd2d82aeeed5f03e5e0b35b1ae681c3cb7ba2..6b7c5ba65030166100d8b301f4077f2dad46f020 100644 GIT binary patch delta 548 zcmV+<0^9x72mA-HEr*{77%RXOdi!mnYWxokD+p?{kmj^8Hzf5>M-0 zx5jgiwCElIwPk6P*qb0VY;crbzPEKvvS`W+DfdtYEwN^)Mc4P$mM9&IDs=Q-d|K8Z zA=xB!^x`MgMMuYa>v5E1aXgU|IxcQJlTL1hl4g2?nCKSS8j?;V+N@w{<-Y&`00000 zz^YuDQY{BiwLyO#4NN3j(-7A*)az%oEmf_Ytu4B2v`dIDcTp%rzTHQWqcy58+*Gox z$*1+L6Qr;RFy(;zxBM!z-rxkPZ}Xm@I`7#gQ_90d$r3{N8QE&SEbym`YtW59L% zvyAb4lg}e>34q){MP3d$ub&KhvXI0H|kaI&Clf z4I_|ELPslpa);>bSa02q9F}AxN#G5VWQst|_R~YqTX*t({MMbY5s50iW-pa6s11q?I}YptFc})Bb&?L4IvMT+u@?U5HMP;;S2UQ$ zKg-y!+2pO+;qJ0n*6X3p$mV|UfzWoc9!~EdS^UNl9D;Np2!gEh$G7bKs~k6#v4VtG zD;Pik+ZeRPD-pew)M>DtWNB$x2!cmn{Z}FY`(sP+le3JapaFXk=u;=YS3DZK4g|Dx yZ#klN$9jAM?$LepB7!5(tj`{)j{VM{B6#yLo0000$;~PNDFT)getItlHIEkv99qEkv?ZLM@ks zEt#lRc!dZN-I564-tWZn);!m(BKgZMm9=T}hc4qpc9j)kob-FQk2Qm1UT;r1RS)AM z+jOeVReR2!wI6%gJmMTcoC7{Fp`nt8GX^h8qTE@w!NBLwF^;~l@Y&87JY)H>2=$)*pr)fXd z^<9BFYe=Wef_#`l^bIzNe)2XYsAkTrI|C5AfM#rhpM=|sd(M^@OtEBe&@7^81Yfi?eDP$&bLuMY2WnP$PdrnZuZbvse zf^PPtsV44F$SLUNisT4Ws(R+Sid68Nh&LIfP~}fzVu{5Sph3Li6W9Xu%l}TEq@Qi=Khd;%gwZ z^28*)328uc|Zm#4DVPxWH0!wks14(gnY=fB2z@R<(p_1_A4?tsU1mOgD(wIg<(7_s`N4LwBd^$GUgf&UKb1T;cPqy*GRe*XE0x^= NHbC~mW?5AoMgWg3W>)|J From f56884705aa17fe872eaa2c41c9e1e79488eb796 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 18 Aug 2023 23:43:54 +0700 Subject: [PATCH 0986/1199] Fix ingredients being "empty" when playing multiplayer These changes reflects Forge's PR https://github.com/MinecraftForge/MinecraftForge/pull/9688 --- .../mc/otm/OverdriveThatMatters.java | 7 +++++++ .../mc/otm/mixin/IngredientMixin.java | 19 +++++++++++++++++++ .../mc/otm/data/IngredientCodec.kt | 9 ++++++--- .../mc/otm/recipe/PlatePressRecipe.kt | 3 --- .../overdrive_that_matters.mixins.json | 3 ++- 5 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 src/main/java/ru/dbotthepony/mc/otm/mixin/IngredientMixin.java diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 350d59128..2e6221c8e 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -7,6 +7,7 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.event.TagsUpdatedEvent; import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.ModList; @@ -151,6 +152,10 @@ public final class OverdriveThatMatters { ToolsConfig.INSTANCE.register(); } + private void tagsUpdated(TagsUpdatedEvent event) { + Ingredient.invalidateAll(); + } + private void setup(final FMLCommonSetupEvent event) { EVENT_BUS.addListener(EventPriority.NORMAL, DrivePool.INSTANCE::onWorldSave); @@ -200,6 +205,8 @@ public final class OverdriveThatMatters { EVENT_BUS.addListener(EventPriority.NORMAL, DevChestBlockEntity.Companion::mappingsChanged); + EVENT_BUS.addListener(EventPriority.NORMAL, this::tagsUpdated); + MatteryPlayerNetworkChannel.INSTANCE.register(); MenuNetworkChannel.INSTANCE.register(); WeaponNetworkChannel.INSTANCE.register(); diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/IngredientMixin.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/IngredientMixin.java new file mode 100644 index 000000000..ada9fe9ce --- /dev/null +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/IngredientMixin.java @@ -0,0 +1,19 @@ +package ru.dbotthepony.mc.otm.mixin; + +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(Ingredient.class) +public abstract class IngredientMixin { + @Inject( + method = "getItems()[Lnet/minecraft/world/item/ItemStack;", + at = @At("HEAD") + ) + public void getItemsPatch(CallbackInfoReturnable info) { + ((Ingredient) (Object) this).checkInvalidation(); + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientCodec.kt index 27c18ade8..7eea0a880 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientCodec.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientCodec.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.data +import com.google.gson.JsonParseException import com.google.gson.JsonSyntaxException import com.mojang.datafixers.util.Pair import com.mojang.serialization.Codec @@ -14,10 +15,12 @@ object IngredientCodec : Codec { } override fun decode(ops: DynamicOps, input: T): DataResult> { - try { - return DataResult.success(Pair(Ingredient.fromJson(ops.convertTo(JsonOps.INSTANCE, input)), ops.empty())) + return try { + DataResult.success(Pair(Ingredient.fromJson(ops.convertTo(JsonOps.INSTANCE, input)), ops.empty())) } catch (err: JsonSyntaxException) { - return DataResult.error { "Error decoding Ingredient: ${err.message}" } + DataResult.error { "Error decoding Ingredient: ${err.message}" } + } catch (err: JsonParseException) { + DataResult.error { "Error decoding Ingredient: ${err.message}" } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt index 49ad6efd3..0cb3d373b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt @@ -56,9 +56,6 @@ class PlatePressRecipe( } override fun getIngredients(): NonNullList { - if (isIncomplete) - return super.getIngredients() - return NonNullList.of(Ingredient.EMPTY, input) } diff --git a/src/main/resources/overdrive_that_matters.mixins.json b/src/main/resources/overdrive_that_matters.mixins.json index cc4920e9d..74743f38a 100644 --- a/src/main/resources/overdrive_that_matters.mixins.json +++ b/src/main/resources/overdrive_that_matters.mixins.json @@ -15,7 +15,8 @@ "MixinAbstractHurtingProjectile", "SimpleCriterionTriggerMixin", "InventoryChangeTriggerMixin", - "MixinPlayer" + "MixinPlayer", + "IngredientMixin" ], "client": [ "MixinGameRenderer", From a0b0580bfab52719668797185d49050967075fd0 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 19 Aug 2023 00:18:48 +0700 Subject: [PATCH 0987/1199] Add circuit plating recipe to datagen --- .../mc/otm/datagen/recipes/PlatePressRecipes.kt | 3 +++ .../recipes/plates/circuit_plating.json | 10 ---------- 2 files changed, 3 insertions(+), 10 deletions(-) delete mode 100644 src/main/resources/data/overdrive_that_matters/recipes/plates/circuit_plating.json diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressRecipes.kt index 6843c9c04..c8c9bfffe 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PlatePressRecipes.kt @@ -3,7 +3,9 @@ package ru.dbotthepony.mc.otm.datagen.recipes import net.minecraft.util.valueproviders.ConstantFloat import net.minecraft.world.item.Items import net.minecraft.world.item.crafting.Ingredient +import net.minecraftforge.common.Tags import ru.dbotthepony.mc.otm.registry.MItemTags +import ru.dbotthepony.mc.otm.registry.MItems fun addPlatePressRecipes(provider: MatteryRecipeProvider) { val baselineMetals = arrayOf("iron" to 0.2f, "silver" to 0.3f, "bronze" to 0.3f, "lead" to 0.3f, "constantan" to 0.4f, "brass" to 0.3f) @@ -23,4 +25,5 @@ fun addPlatePressRecipes(provider: MatteryRecipeProvider) { } provider.plate("carbon", result = Ingredient.of(MItemTags.CARBON_PLATES), ingredient = Ingredient.of(Items.COAL), workTicks = 140, experience = ConstantFloat.of(0.3f)) + provider.plate("circuit_plating", result = Ingredient.of(MItems.CIRCUIT_PLATING), ingredient = Ingredient.of(Tags.Items.SAND), workTicks = 120, experience = ConstantFloat.of(0.2f)) } diff --git a/src/main/resources/data/overdrive_that_matters/recipes/plates/circuit_plating.json b/src/main/resources/data/overdrive_that_matters/recipes/plates/circuit_plating.json deleted file mode 100644 index afe37fe11..000000000 --- a/src/main/resources/data/overdrive_that_matters/recipes/plates/circuit_plating.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "type": "overdrive_that_matters:plate_press", - "input": { - "tag": "forge:sand" - }, - "result": { - "item": "overdrive_that_matters:circuit_plating" - }, - "work_time": 120 -} \ No newline at end of file From 260be589512bad5dc4f68600b26ef0c5b8f5acd2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 19 Aug 2023 00:56:03 +0700 Subject: [PATCH 0988/1199] Write ingredients as plain itemstacks if networking --- .../mc/otm/data/Codec2RecipeSerializer.kt | 111 ++++++++++-------- .../mc/otm/data/IngredientMatrixCodec.kt | 24 ++-- .../mc/otm/recipe/MatterEntanglerRecipe.kt | 12 +- .../mc/otm/recipe/PainterRecipe.kt | 6 +- .../mc/otm/recipe/PlatePressRecipe.kt | 6 +- 5 files changed, 81 insertions(+), 78 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt index 16e1830f7..3ddf52bd2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt @@ -11,6 +11,8 @@ import com.mojang.serialization.JsonOps import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.item.crafting.Recipe import net.minecraft.world.item.crafting.RecipeSerializer import org.apache.logging.log4j.LogManager @@ -20,51 +22,26 @@ import ru.dbotthepony.mc.otm.core.util.writeBinaryJsonWithCodec import kotlin.collections.ArrayDeque import kotlin.concurrent.getOrSet -class Codec2RecipeSerializer> private constructor( +class Codec2RecipeSerializer>( val empty: S?, - - /** - * [ThreadLocal] because optimization mods can (and probably should) parallelize recipe deserialization, - * since RecipeSerializers are expected to be stateless. [Codec2RecipeSerializer], however, is stateful (threading PoV). - * To make it stateless, [ThreadLocal] is used. - */ - private val idStack: ThreadLocal>, codec: (Codec2RecipeSerializer.Context) -> Codec, ) : Codec, RecipeSerializer { - constructor(empty: S?, codec: (Codec2RecipeSerializer.Context) -> Codec) : this(empty, ThreadLocal(), codec) constructor(supplier: (Codec2RecipeSerializer.Context) -> Codec) : this(null, supplier) - private val codec = codec.invoke(Context()) - private val id: ArrayDeque - get() = idStack.getOrSet { ArrayDeque() } - - inner class Context() { - val id: ResourceLocation - get() = checkNotNull(this@Codec2RecipeSerializer.id.lastOrNull()) { "Not currently deserializing recipe" } - - fun > wrap(other: Codec2RecipeSerializer): Codec { - return object : Codec { - override fun encode(input: O, ops: DynamicOps, prefix: T): DataResult { - try { - other.id.addLast(this@Context.id) - return other.encode(input, ops, prefix) - } finally { - other.id.removeLast() - } - } - - override fun decode(ops: DynamicOps, input: T): DataResult> { - try { - other.id.addLast(this@Context.id) - return other.decode(ops, input) - } finally { - other.id.removeLast() - } - } - } - } + private class CurrentContext { + val idStack = ArrayDeque() + var isNetwork = 0 } + inner class Context { + val id: ResourceLocation + get() = checkNotNull(context.idStack.lastOrNull()) { "Not currently deserializing recipe" } + + val ingredients: Codec get() = ActualIngredientCodec + } + + private val codec = codec.invoke(Context()) + override fun encode(input: S, ops: DynamicOps, prefix: T): DataResult { return codec.encode(input, ops, prefix) } @@ -74,41 +51,47 @@ class Codec2RecipeSerializer> private constructor( } fun > xmap(to: (S) -> O, from: (O) -> S): Codec2RecipeSerializer { - return Codec2RecipeSerializer(empty?.let(to), idStack) { _ -> + return Codec2RecipeSerializer(empty?.let(to)) { _ -> codec.xmap(to, from) } } override fun fromJson(id: ResourceLocation, data: JsonObject): S { try { - this.id.addLast(id) + context.idStack.addLast(id) return decode(JsonOps.INSTANCE, data).get().map( - { - it.first - }, - { - empty ?: throw JsonSyntaxException("Failed to deserialize recipe from JSON: ${it.message()}") - } + { it.first }, + { empty ?: throw JsonSyntaxException("Failed to deserialize recipe from JSON: ${it.message()}") } ) } finally { - this.id.removeLast() + context.idStack.removeLast() } } override fun fromNetwork(id: ResourceLocation, data: FriendlyByteBuf): S? { try { - this.id.addLast(id) + context.idStack.addLast(id) + context.isNetwork++ return data.readBinaryJsonWithCodecIndirect(this) .resultOrPartial { LOGGER.error("Failed to read recipe $id from network: $it") }.orElse(null) } finally { - this.id.removeLast() + context.isNetwork-- + context.idStack.removeLast() } } override fun toNetwork(data: FriendlyByteBuf, recipe: S) { - data.writeBinaryJsonWithCodec(this, recipe) + try { + context.idStack.addLast(recipe.id) + context.isNetwork++ + + data.writeBinaryJsonWithCodec(this, recipe) + } finally { + context.isNetwork-- + context.idStack.removeLast() + } } fun toFinished(recipe: S): FinishedRecipe { @@ -146,7 +129,35 @@ class Codec2RecipeSerializer> private constructor( } } + private object ActualIngredientCodec : Codec { + override fun encode(input: Ingredient, ops: DynamicOps, prefix: T): DataResult { + return if (context.isNetwork > 0) { + networkIngredientCodec.encode(input, ops, prefix) + } else { + IngredientCodec.encode(input, ops, prefix) + } + } + + override fun decode(ops: DynamicOps, input: T): DataResult> { + return if (context.isNetwork > 0) { + networkIngredientCodec.decode(ops, input) + } else { + IngredientCodec.decode(ops, input) + } + } + } + companion object { private val LOGGER = LogManager.getLogger() + private val networkIngredientCodec = Codec.list(ItemStack.CODEC).xmap({ Ingredient.of(it.stream()) }, { it.items.toMutableList() }) + + /** + * [ThreadLocal] because optimization mods can (and probably should) parallelize recipe deserialization, + * since RecipeSerializers are expected to be stateless. [Codec2RecipeSerializer], however, is stateful (threading PoV). + * To make it stateless, [ThreadLocal] is used. + */ + private val contextHolder = ThreadLocal() + private val context: CurrentContext + get() = contextHolder.getOrSet { CurrentContext() } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientMatrixCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientMatrixCodec.kt index f0ff5b1db..12d7117cd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientMatrixCodec.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientMatrixCodec.kt @@ -9,24 +9,26 @@ import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.world.item.crafting.Ingredient import ru.dbotthepony.mc.otm.core.collect.allEqual import ru.dbotthepony.mc.otm.core.collect.map +import ru.dbotthepony.mc.otm.core.collect.toList import ru.dbotthepony.mc.otm.core.collect.toStream import ru.dbotthepony.mc.otm.core.stream import ru.dbotthepony.mc.otm.recipe.IIngredientMatrix import ru.dbotthepony.mc.otm.recipe.IngredientMatrix import java.util.function.Supplier -object IngredientMatrixCodec : Codec { - private val ingredientList = Codec.list(IngredientCodec) +class IngredientMatrixCodec(ingredientCodec: Codec) : Codec { + private val ingredientList = Codec.list(ingredientCodec) + private val doubleIngredientList = Codec.list(ingredientList) override fun encode(input: IIngredientMatrix, ops: DynamicOps, prefix: T): DataResult { - return DataResult.success( - ops.createList( - (0 until input.height).stream().map { row -> - ops.createList((0 until input.width).stream().map { column -> - JsonOps.INSTANCE.convertTo(ops, input[column, row].toJson()) - }) - } - ) + return doubleIngredientList.encode( + (0 until input.height).iterator().map { row -> + (0 until input.width).iterator().map { column -> + input[column, row] + }.toList() + }.toList(), + ops, + prefix ) } @@ -45,7 +47,7 @@ object IngredientMatrixCodec : Codec { .flatXmap( { if (it.length == 1) DataResult.success(it[0]) else DataResult.error { "Ingredient key must be exactly 1 symbol in length, '$it' is invalid" } }, { DataResult.success(it.toString()) } - ), IngredientCodec).fieldOf("key").forGetter(Handwritten::key) + ), ingredientCodec).fieldOf("key").forGetter(Handwritten::key) ).apply(it, ::Handwritten) } 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 15024b3b1..a836c3e52 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt @@ -143,18 +143,10 @@ open class MatterEntanglerRecipe( } companion object { - val SERIALIZER = Codec2RecipeSerializer( - MatterEntanglerRecipe( - ResourceLocation(OverdriveThatMatters.MOD_ID, "null"), - IIngredientMatrix.Companion, - Decimal.ZERO, - 0.0, - ItemStack.EMPTY, - ) - ) { context -> + val SERIALIZER = Codec2RecipeSerializer { context -> RecordCodecBuilder.create { it.group( - IngredientMatrixCodec.fieldOf("ingredients").forGetter(MatterEntanglerRecipe::ingredients), + IngredientMatrixCodec(context.ingredients).fieldOf("ingredients").forGetter(MatterEntanglerRecipe::ingredients), DecimalCodec.minRange(Decimal.ZERO).fieldOf("matter").forGetter(MatterEntanglerRecipe::matter), Codec.DOUBLE.minRange(0.0).fieldOf("ticks").forGetter(MatterEntanglerRecipe::ticks), ItemStack.CODEC.fieldOf("result").forGetter(MatterEntanglerRecipe::result), 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 0e0d4ee77..cfc89caf4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt @@ -113,12 +113,10 @@ class PainterRecipe( } companion object { - val SERIALIZER = Codec2RecipeSerializer( - PainterRecipe(ResourceLocation(OverdriveThatMatters.MOD_ID, "empty"), Ingredient.EMPTY, ItemStack.EMPTY, setOf()) - ) { context -> + val SERIALIZER = Codec2RecipeSerializer { context -> RecordCodecBuilder.create { it.group( - IngredientCodec.fieldOf("input").forGetter(PainterRecipe::input), + context.ingredients.fieldOf("input").forGetter(PainterRecipe::input), ItemStack.CODEC.fieldOf("output").forGetter(PainterRecipe::output), PredicatedCodecList>( DyeColor.CODEC.xmap({ mapOf(it to 1) }, { it.keys.first() }) to Predicate { it.keys.size == 1 && it.values.first() == 1 }, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt index 0cb3d373b..583231dcc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt @@ -78,11 +78,11 @@ class PlatePressRecipe( fun toFinished() = SERIALIZER.toFinished(this) companion object { - val SERIALIZER = Codec2RecipeSerializer(PlatePressRecipe(ResourceLocation(OverdriveThatMatters.MOD_ID, "empty"), Ingredient.EMPTY, Ingredient.EMPTY, 1)) { context -> + val SERIALIZER = Codec2RecipeSerializer { context -> RecordCodecBuilder.create { it.group( - IngredientCodec.fieldOf("input").forGetter(PlatePressRecipe::input), - IngredientCodec.fieldOf("output").forGetter(PlatePressRecipe::output), + context.ingredients.fieldOf("input").forGetter(PlatePressRecipe::input), + context.ingredients.fieldOf("output").forGetter(PlatePressRecipe::output), Codec.INT.minRange(1).optionalFieldOf("count", 1).forGetter(PlatePressRecipe::count), Codec.INT.minRange(0).optionalFieldOf("workTime", 200).forGetter(PlatePressRecipe::workTime), FloatProvider.CODEC.optionalFieldOf("experience", ConstantFloat.ZERO).forGetter(PlatePressRecipe::experience) From e88c29be5786e85388c8e013e22a5e0c3ea0c685 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 19 Aug 2023 01:13:32 +0700 Subject: [PATCH 0989/1199] Revert "Fix ingredients being "empty" when playing multiplayer" This reverts commit f56884705aa17fe872eaa2c41c9e1e79488eb796. --- .../mc/otm/OverdriveThatMatters.java | 7 ------- .../mc/otm/mixin/IngredientMixin.java | 19 ------------------- .../mc/otm/data/IngredientCodec.kt | 9 +++------ .../mc/otm/recipe/PlatePressRecipe.kt | 3 +++ .../overdrive_that_matters.mixins.json | 3 +-- 5 files changed, 7 insertions(+), 34 deletions(-) delete mode 100644 src/main/java/ru/dbotthepony/mc/otm/mixin/IngredientMixin.java diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 2e6221c8e..350d59128 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -7,7 +7,6 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.event.TagsUpdatedEvent; import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.ModList; @@ -152,10 +151,6 @@ public final class OverdriveThatMatters { ToolsConfig.INSTANCE.register(); } - private void tagsUpdated(TagsUpdatedEvent event) { - Ingredient.invalidateAll(); - } - private void setup(final FMLCommonSetupEvent event) { EVENT_BUS.addListener(EventPriority.NORMAL, DrivePool.INSTANCE::onWorldSave); @@ -205,8 +200,6 @@ public final class OverdriveThatMatters { EVENT_BUS.addListener(EventPriority.NORMAL, DevChestBlockEntity.Companion::mappingsChanged); - EVENT_BUS.addListener(EventPriority.NORMAL, this::tagsUpdated); - MatteryPlayerNetworkChannel.INSTANCE.register(); MenuNetworkChannel.INSTANCE.register(); WeaponNetworkChannel.INSTANCE.register(); diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/IngredientMixin.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/IngredientMixin.java deleted file mode 100644 index ada9fe9ce..000000000 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/IngredientMixin.java +++ /dev/null @@ -1,19 +0,0 @@ -package ru.dbotthepony.mc.otm.mixin; - -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.Ingredient; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(Ingredient.class) -public abstract class IngredientMixin { - @Inject( - method = "getItems()[Lnet/minecraft/world/item/ItemStack;", - at = @At("HEAD") - ) - public void getItemsPatch(CallbackInfoReturnable info) { - ((Ingredient) (Object) this).checkInvalidation(); - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientCodec.kt index 7eea0a880..27c18ade8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientCodec.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientCodec.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.data -import com.google.gson.JsonParseException import com.google.gson.JsonSyntaxException import com.mojang.datafixers.util.Pair import com.mojang.serialization.Codec @@ -15,12 +14,10 @@ object IngredientCodec : Codec { } override fun decode(ops: DynamicOps, input: T): DataResult> { - return try { - DataResult.success(Pair(Ingredient.fromJson(ops.convertTo(JsonOps.INSTANCE, input)), ops.empty())) + try { + return DataResult.success(Pair(Ingredient.fromJson(ops.convertTo(JsonOps.INSTANCE, input)), ops.empty())) } catch (err: JsonSyntaxException) { - DataResult.error { "Error decoding Ingredient: ${err.message}" } - } catch (err: JsonParseException) { - DataResult.error { "Error decoding Ingredient: ${err.message}" } + return DataResult.error { "Error decoding Ingredient: ${err.message}" } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt index 583231dcc..6ad1dcdb8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt @@ -56,6 +56,9 @@ class PlatePressRecipe( } override fun getIngredients(): NonNullList { + if (isIncomplete) + return super.getIngredients() + return NonNullList.of(Ingredient.EMPTY, input) } diff --git a/src/main/resources/overdrive_that_matters.mixins.json b/src/main/resources/overdrive_that_matters.mixins.json index 74743f38a..cc4920e9d 100644 --- a/src/main/resources/overdrive_that_matters.mixins.json +++ b/src/main/resources/overdrive_that_matters.mixins.json @@ -15,8 +15,7 @@ "MixinAbstractHurtingProjectile", "SimpleCriterionTriggerMixin", "InventoryChangeTriggerMixin", - "MixinPlayer", - "IngredientMixin" + "MixinPlayer" ], "client": [ "MixinGameRenderer", From 62df3558e76a1a2037caaa95fe683bbf276983dd Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 19 Aug 2023 01:36:49 +0700 Subject: [PATCH 0990/1199] Bump particle collider version --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index f0cf78496..6568b8d86 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -161,7 +161,7 @@ dependencies { compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge-api:${jei_version}")) runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}")) - runtimeOnly(fg.deobf("ru.dbotthepony:particle-collider:0.2.0")) + runtimeOnly(fg.deobf("ru.dbotthepony:particle-collider:0.3.2")) implementation(fg.deobf("curse.maven:jade-324717:${jade_id}")) //runtimeOnly(fg.deobf("curse.maven:configured-457570:${configured_id}")) From fbc2a400de32ac411d3077b318eae82fa42d5c50 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sat, 19 Aug 2023 08:14:20 +0300 Subject: [PATCH 0991/1199] =?UTF-8?q?YuRaNnNzZZ=20=E2=80=94=20=D0=A1=D0=B5?= =?UTF-8?q?=D0=B3=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=207:46=20=D0=98=D0=B7?= =?UTF-8?q?=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B0?= =?UTF-8?q?=20=D0=BA=D0=B0=D0=BA=D0=BE=D0=B9=20=D0=B8=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=BD=D0=BE=20=D1=81=D1=82=D0=B0=D0=BA=20=D1=82=D0=BE=20=D0=B1?= =?UTF-8?q?=D0=BB=D1=8F=D1=82=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index eb7598029..ace43d303 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -1346,8 +1346,8 @@ object MatterManager { val multiplier: Double = 1.0 ) { init { - require(!multiplier.isNaN()) { "Provided stack cost multiplier is NaN" } - require(!multiplier.isInfinite()) { "Provided stack cost multiplier is infinite" } + require(!multiplier.isNaN()) { "Provided stack (${item.registryName}) cost multiplier is NaN" } + require(!multiplier.isInfinite()) { "Provided stack (${item.registryName}) cost multiplier is infinite" } } constructor(item: Item, count: Int) : this(item, 1.0 / count.toDouble()) From b3863a282043440a1a53044de89bb62fc16e4487 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 19 Aug 2023 13:09:36 +0700 Subject: [PATCH 0992/1199] =?UTF-8?q?YuRaNnNzZZ=20=E2=80=94=20=D0=A1=D0=B5?= =?UTF-8?q?=D0=B3=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=2011:46=20=D0=B0=20?= =?UTF-8?q?=D0=BA=D0=B0=D0=BA=D0=BE=D0=B9=20=D0=B8=D0=BC=D0=B5=D0=BD=D0=BD?= =?UTF-8?q?=D0=BE=20=D1=81=D1=82=D0=B0=D0=BA=20=D1=82=D0=BE=20=D0=B1=D0=BB?= =?UTF-8?q?=D1=8F=D1=82=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/matter/MatterManager.kt | 142 +++++++++--------- 1 file changed, 75 insertions(+), 67 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index eb7598029..4c306f697 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -449,15 +449,19 @@ object MatterManager { } stream.map { - ResolvedRecipe( - it.ingredients.stream() - .filter { !it.isActuallyEmpty } - .map { it.items.stream().map(::RecipeEntry) }, - ImmutableStack(it.getResultItem(server.registryAccess())), - isCritical = isCritical, - name = it.id, - allowBacktrack = allowBacktrack - ) + try { + ResolvedRecipe( + it.ingredients.stream() + .filter { !it.isActuallyEmpty } + .map { it.items.stream().map(::RecipeEntry) }, + ImmutableStack(it.getResultItem(server.registryAccess())), + isCritical = isCritical, + name = it.id, + allowBacktrack = allowBacktrack + ) + } catch(err: Throwable) { + throw RuntimeException("Processing simple recipe ${it.id}", err) + } } .filter { if (it.inputs.isEmpty()) { @@ -491,79 +495,83 @@ object MatterManager { } stream.map { - // avoid reality snap when recipe has no output - val resultItem = it.getResultItem(server.registryAccess()) + try { + // avoid reality snap when recipe has no output + val resultItem = it.getResultItem(server.registryAccess()) - if (resultItem.isEmpty) { - null - } else { - var width: Int - var height: Int - - if (it is IShapedRecipe<*>) { - width = it.recipeWidth - height = it.recipeHeight + if (resultItem.isEmpty) { + null } else { - width = 3 - height = 3 - } + var width: Int + var height: Int - if (width * height < it.ingredients.size) { - width = it.ingredients.size.coerceAtLeast(width) - height = it.ingredients.size.coerceAtLeast(height) - } - - val container = TransientCraftingContainer(object : AbstractContainerMenu(null, 0) { - override fun quickMoveStack(pPlayer: Player, pIndex: Int): ItemStack { - return ItemStack.EMPTY + if (it is IShapedRecipe<*>) { + width = it.recipeWidth + height = it.recipeHeight + } else { + width = 3 + height = 3 } - override fun stillValid(pPlayer: Player): Boolean { - return false - } - }, width, height) - - val realIngredients = ArrayList>() - - for (c in it.ingredients.indices) { - if (it.ingredients[c].isActuallyEmpty) { - continue + if (width * height < it.ingredients.size) { + width = it.ingredients.size.coerceAtLeast(width) + height = it.ingredients.size.coerceAtLeast(height) } - for ((i, ingredient) in it.ingredients.withIndex()) { - if (i != c) { - container[i] = if (ingredient.isActuallyEmpty) ItemStack.EMPTY else ingredient.items.firstOrNull() ?: ItemStack.EMPTY + val container = TransientCraftingContainer(object : AbstractContainerMenu(null, 0) { + override fun quickMoveStack(pPlayer: Player, pIndex: Int): ItemStack { + return ItemStack.EMPTY } - } - val result = ArrayList() + override fun stillValid(pPlayer: Player): Boolean { + return false + } + }, width, height) - for (item in it.ingredients[c].items) { - container[c] = item + val realIngredients = ArrayList>() - if (!it.assemble(container, server.registryAccess()).isEmpty) { - val residue = it.getRemainingItems(container) + for (c in it.ingredients.indices) { + if (it.ingredients[c].isActuallyEmpty) { + continue + } - val thisResidue = residue[c] - - if (thisResidue.isEmpty) { - result.add(RecipeEntry(item)) - } else { - result.add(RecipeEntry(ImmutableStack(item), ImmutableStack(thisResidue))) + for ((i, ingredient) in it.ingredients.withIndex()) { + if (i != c) { + container[i] = if (ingredient.isActuallyEmpty) ItemStack.EMPTY else ingredient.items.firstOrNull() ?: ItemStack.EMPTY } } + + val result = ArrayList() + + for (item in it.ingredients[c].items) { + container[c] = item + + if (!it.assemble(container, server.registryAccess()).isEmpty) { + val residue = it.getRemainingItems(container) + + val thisResidue = residue[c] + + if (thisResidue.isEmpty) { + result.add(RecipeEntry(item)) + } else { + result.add(RecipeEntry(ImmutableStack(item), ImmutableStack(thisResidue))) + } + } + } + + realIngredients.add(result) } - realIngredients.add(result) + ResolvedRecipe( + realIngredients.stream().map { it.stream() }, + ImmutableStack(resultItem), + isCritical = isCritical, + name = it.id, + allowBacktrack = allowBacktrack + ) } - - ResolvedRecipe( - realIngredients.stream().map { it.stream() }, - ImmutableStack(resultItem), - isCritical = isCritical, - name = it.id, - allowBacktrack = allowBacktrack - ) + } catch(err: Throwable) { + throw RuntimeException("Processing crafting table recipe ${it.id}", err) } }.filterNotNull().filter { if (it.inputs.isEmpty()) { @@ -1346,8 +1354,8 @@ object MatterManager { val multiplier: Double = 1.0 ) { init { - require(!multiplier.isNaN()) { "Provided stack cost multiplier is NaN" } - require(!multiplier.isInfinite()) { "Provided stack cost multiplier is infinite" } + require(!multiplier.isNaN()) { "Provided stack cost multiplier is NaN (item: $item)" } + require(!multiplier.isInfinite()) { "Provided stack cost multiplier is infinite (item: $item)" } } constructor(item: Item, count: Int) : this(item, 1.0 / count.toDouble()) From d7b5534bb55a26b32f87773a5503020f69a2c270 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 19 Aug 2023 14:22:23 +0700 Subject: [PATCH 0993/1199] Bump particle collider version --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 6568b8d86..d8f933582 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -161,7 +161,7 @@ dependencies { compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge-api:${jei_version}")) runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}")) - runtimeOnly(fg.deobf("ru.dbotthepony:particle-collider:0.3.2")) + runtimeOnly(fg.deobf("ru.dbotthepony:particle-collider:0.4.1")) implementation(fg.deobf("curse.maven:jade-324717:${jade_id}")) //runtimeOnly(fg.deobf("curse.maven:configured-457570:${configured_id}")) From 37bb00d73e48b62b8d53c782fa850945f4e1f746 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 19 Aug 2023 14:52:06 +0700 Subject: [PATCH 0994/1199] Mmm! mmm. Custom Ingredients with getItems() returning literally minecraft:air --- .../kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 1a7101c93..b4b884750 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -82,6 +82,7 @@ import ru.dbotthepony.mc.otm.core.util.formatSiComponent import ru.dbotthepony.mc.otm.core.util.formatTickDuration import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.isActuallyEmpty +import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.core.math.isZero import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.core.readItemType @@ -453,7 +454,7 @@ object MatterManager { ResolvedRecipe( it.ingredients.stream() .filter { !it.isActuallyEmpty } - .map { it.items.stream().map(::RecipeEntry) }, + .map { it.items.stream().filter { it.isNotEmpty }.map(::RecipeEntry) }, ImmutableStack(it.getResultItem(server.registryAccess())), isCritical = isCritical, name = it.id, @@ -553,8 +554,10 @@ object MatterManager { if (thisResidue.isEmpty) { result.add(RecipeEntry(item)) - } else { + } else if (item.isNotEmpty) { result.add(RecipeEntry(ImmutableStack(item), ImmutableStack(thisResidue))) + } else { + LOGGER.warn("Crafting table recipe ${it.id} has literally minecraft:air as item at $c") } } } From 923f2e8ef69c1d3c5c46352c88d91f0a6f5d9266 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 19 Aug 2023 15:07:36 +0700 Subject: [PATCH 0995/1199] java.lang.RuntimeException: Processing simple recipe skilltree:gem_insertion --- src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index b4b884750..2218f87d4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -449,7 +449,7 @@ object MatterManager { stream = stream.filter { it.ingredients.stream().flatMap { it.items.stream() }.noneMatch { it.isDamageableItem } } } - stream.map { + stream.filter { it.getResultItem(server.registryAccess()).isNotEmpty }.map { try { ResolvedRecipe( it.ingredients.stream() From a6c849ef0481eadd209aa2b275e0bb28993c030d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 19 Aug 2023 15:13:50 +0700 Subject: [PATCH 0996/1199] StrictReferenceHashStrategy --- build.gradle.kts | 2 +- .../otm/core/collect/ReferenceHashStrategy.kt | 20 +++++++++++++++++++ .../mc/otm/core/collect/WeakHashSet.kt | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index d8f933582..118673ea8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -161,7 +161,7 @@ dependencies { compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge-api:${jei_version}")) runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}")) - runtimeOnly(fg.deobf("ru.dbotthepony:particle-collider:0.4.1")) + runtimeOnly(fg.deobf("ru.dbotthepony:particle-collider:0.4.2")) implementation(fg.deobf("curse.maven:jade-324717:${jade_id}")) //runtimeOnly(fg.deobf("curse.maven:configured-457570:${configured_id}")) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ReferenceHashStrategy.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ReferenceHashStrategy.kt index 76c362060..a7888bebf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ReferenceHashStrategy.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ReferenceHashStrategy.kt @@ -29,3 +29,23 @@ object ReferenceHashStrategy : Hash.Strategy { return o.hashCode() } } + +object StrictReferenceHashStrategy : Hash.Strategy { + @Suppress("UNCHECKED_CAST") + override fun equals(a: Any?, b: Any?): Boolean { + if (a === b) return true + + if (a is Reference<*>) { + if (b is Reference<*>) return false + return b != null && (a as Reference).refersTo(b) + } else if (b is Reference<*>) { + return a != null && (b as Reference).refersTo(a) + } else { + return a == b + } + } + + override fun hashCode(o: Any?): Int { + return o.hashCode() + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/WeakHashSet.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/WeakHashSet.kt index 6464b7d87..6279aedfe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/WeakHashSet.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/WeakHashSet.kt @@ -8,7 +8,7 @@ import java.lang.ref.ReferenceQueue class WeakHashSet(initialCapacity: Int = 16, loadFactor: Float = 0.75f, linked: Boolean = false) : MutableSet { private val queue = ReferenceQueue() - private val backing: ObjectSet = if (linked) ObjectLinkedOpenCustomHashSet(initialCapacity, loadFactor, ReferenceHashStrategy) else ObjectOpenCustomHashSet(initialCapacity, loadFactor, ReferenceHashStrategy) + private val backing: ObjectSet = if (linked) ObjectLinkedOpenCustomHashSet(initialCapacity, loadFactor, StrictReferenceHashStrategy) else ObjectOpenCustomHashSet(initialCapacity, loadFactor, StrictReferenceHashStrategy) private fun purge() { var next = queue.poll() From 159c82cadd5e44b3c0c998be0e446ba813da90c6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 19 Aug 2023 17:08:40 +0700 Subject: [PATCH 0997/1199] Bump particle collider version --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 118673ea8..0264f3077 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -161,7 +161,7 @@ dependencies { compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge-api:${jei_version}")) runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}")) - runtimeOnly(fg.deobf("ru.dbotthepony:particle-collider:0.4.2")) + runtimeOnly(fg.deobf("ru.dbotthepony:particle-collider:0.4.5")) implementation(fg.deobf("curse.maven:jade-324717:${jade_id}")) //runtimeOnly(fg.deobf("curse.maven:configured-457570:${configured_id}")) From 9d79e52c433b8094c0994888ebbfa147a5cfe4ac Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 19 Aug 2023 17:38:19 +0700 Subject: [PATCH 0998/1199] Fix ref hash strategy --- .../otm/core/collect/ReferenceHashStrategy.kt | 35 +++---------------- .../mc/otm/core/collect/WeakHashSet.kt | 2 +- 2 files changed, 5 insertions(+), 32 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ReferenceHashStrategy.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ReferenceHashStrategy.kt index a7888bebf..d6b6fdc3c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ReferenceHashStrategy.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ReferenceHashStrategy.kt @@ -4,42 +4,15 @@ import it.unimi.dsi.fastutil.Hash import java.lang.ref.Reference object ReferenceHashStrategy : Hash.Strategy { - @Suppress("UNCHECKED_CAST") override fun equals(a: Any?, b: Any?): Boolean { if (a === b) return true + if (a == null || b == null) return false if (a is Reference<*>) { - if (a.refersTo(null) || b == null) return false - - if (b is Reference<*>) { - if (b.refersTo(null)) return false - return (b as Reference).refersTo(a.get() ?: return false) - } else { - return (a as Reference).refersTo(b) - } + if (b is Reference<*>) return a.get() == b.get() + return a.get() == b } else if (b is Reference<*>) { - if (b.refersTo(null) || a == null) return false - return (b as Reference).refersTo(a) - } - - return a == b - } - - override fun hashCode(o: Any?): Int { - return o.hashCode() - } -} - -object StrictReferenceHashStrategy : Hash.Strategy { - @Suppress("UNCHECKED_CAST") - override fun equals(a: Any?, b: Any?): Boolean { - if (a === b) return true - - if (a is Reference<*>) { - if (b is Reference<*>) return false - return b != null && (a as Reference).refersTo(b) - } else if (b is Reference<*>) { - return a != null && (b as Reference).refersTo(a) + return b.get() == a } else { return a == b } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/WeakHashSet.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/WeakHashSet.kt index 6279aedfe..6464b7d87 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/WeakHashSet.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/WeakHashSet.kt @@ -8,7 +8,7 @@ import java.lang.ref.ReferenceQueue class WeakHashSet(initialCapacity: Int = 16, loadFactor: Float = 0.75f, linked: Boolean = false) : MutableSet { private val queue = ReferenceQueue() - private val backing: ObjectSet = if (linked) ObjectLinkedOpenCustomHashSet(initialCapacity, loadFactor, StrictReferenceHashStrategy) else ObjectOpenCustomHashSet(initialCapacity, loadFactor, StrictReferenceHashStrategy) + private val backing: ObjectSet = if (linked) ObjectLinkedOpenCustomHashSet(initialCapacity, loadFactor, ReferenceHashStrategy) else ObjectOpenCustomHashSet(initialCapacity, loadFactor, ReferenceHashStrategy) private fun purge() { var next = queue.poll() From 67f97dfba6cb74ccbb7a31408a74fbb44a3e3bb4 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 19 Aug 2023 19:51:19 +0700 Subject: [PATCH 0999/1199] Move around and update container apis --- .../decorative/CargoCrateBlockEntity.kt | 2 - .../entity/decorative/PainterBlockEntity.kt | 10 +- .../entity/matter/MatterBottlerBlockEntity.kt | 23 ++-- .../matter/PatternStorageBlockEntity.kt | 3 - .../entity/storage/ItemMonitorBlockEntity.kt | 15 ++- .../ru/dbotthepony/mc/otm/capability/Ext.kt | 7 +- .../FluidHandlerIterator.kt | 3 +- .../FluidHandlerSpliterator.kt | 3 +- .../otm/capability/MatteryPlayerCapability.kt | 14 +- .../mc/otm/compat/cos/CosmeticArmorCompat.kt | 6 +- .../mc/otm/compat/curios/CuriosCompat.kt | 7 +- .../mc/otm/container/CombinedContainer.kt | 44 +++---- .../mc/otm/container/ContainerHandler.kt | 1 - .../container/{Ext.kt => ContainerHelpers.kt} | 11 +- .../mc/otm/container/ContainerIterator.kt | 82 ------------ .../mc/otm/container/HandlerFilter.kt | 2 +- .../mc/otm/container/IContainer.kt | 84 ++++++++++++ .../mc/otm/container/IContainerIterator.kt | 12 -- .../mc/otm/container/MatteryContainer.kt | 82 ++++++------ .../mc/otm/container/ShadowContainer.kt | 3 +- .../otm/container/ShadowCraftingContainer.kt | 4 +- .../{ => util}/ContainerSpliterator.kt | 3 +- .../{ => util}/ItemHandlerSpliterator.kt | 2 +- .../{ => util}/ItemStackHashStrategy.kt | 2 +- .../mc/otm/container/util/Iterators.kt | 123 ++++++++++++++++++ .../mc/otm/item/FluidCapsuleItem.kt | 6 +- .../mc/otm/matter/MatterManager.kt | 2 +- .../mc/otm/menu/ExopackInventoryMenu.kt | 12 +- .../mc/otm/recipe/EnergyContainerRecipe.kt | 7 +- .../recipe/ExplosiveHammerPrimingRecipe.kt | 2 +- .../mc/otm/recipe/IMatteryRecipe.kt | 2 +- .../mc/otm/recipe/MatterEntanglerRecipe.kt | 6 +- .../mc/otm/recipe/UpgradeRecipe.kt | 2 +- .../triggers/MatteryInventoryChangeTrigger.kt | 6 +- 34 files changed, 343 insertions(+), 250 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/{container => capability}/FluidHandlerIterator.kt (90%) rename src/main/kotlin/ru/dbotthepony/mc/otm/{container => capability}/FluidHandlerSpliterator.kt (94%) rename src/main/kotlin/ru/dbotthepony/mc/otm/container/{Ext.kt => ContainerHelpers.kt} (96%) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerIterator.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/container/IContainer.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/container/IContainerIterator.kt rename src/main/kotlin/ru/dbotthepony/mc/otm/container/{ => util}/ContainerSpliterator.kt (96%) rename src/main/kotlin/ru/dbotthepony/mc/otm/container/{ => util}/ItemHandlerSpliterator.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/container/{ => util}/ItemStackHashStrategy.kt (89%) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/container/util/Iterators.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt index f09d23fa8..285a6c7ca 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt @@ -10,7 +10,6 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerPlayer import net.minecraft.sounds.SoundSource -import net.minecraft.world.Container import net.minecraft.world.Containers import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player @@ -20,7 +19,6 @@ import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.gameevent.GameEvent -import net.minecraft.world.level.storage.loot.LootContext import net.minecraft.world.level.storage.loot.LootParams import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets import net.minecraft.world.level.storage.loot.parameters.LootContextParams 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 6b1bee031..248f75ff8 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 @@ -105,15 +105,13 @@ class PainterBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDe override fun tick() { super.tick() - val i = dyeInput.iterator() - - for (item in i) { - val dye = DyeColor.entries.firstOrNull { item.`is`(it.tag) } ?: continue + for (slot in dyeInput.slotIterator()) { + val dye = DyeColor.entries.firstOrNull { slot.item.`is`(it.tag) } ?: continue val stored = dyeStored(dye) if (stored + HUE_PER_ITEM <= MAX_STORAGE) { - item.shrink(1) - i.setChanged() + slot.item.shrink(1) + slot.setChanged() dyeStored[dye] = stored + HUE_PER_ITEM } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index ae2a73a8f..5b29c2dca 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -183,13 +183,13 @@ class MatterBottlerBlockEntity(blockPos: BlockPos, blockState: BlockState) : if (isBottling) { var any = false var idle = false - val iterator = bottling.iterator() - for (item in iterator) { + for (slot in bottling.slotIterator()) { + val item = slot.item item.getCapability(MatteryCapability.MATTER).ifPresentK { if (!it.missingMatter.isPositive) { unbottling.consumeItem(item, false) - iterator.setChanged() + slot.setChanged() } else { any = true initialCapacity = initialCapacity ?: it.storedMatter @@ -215,7 +215,7 @@ class MatterBottlerBlockEntity(blockPos: BlockPos, blockState: BlockState) : if (spitItemsWhenCantWork) { unbottling.consumeItem(item, false) - iterator.setChanged() + slot.setChanged() } } } @@ -237,11 +237,9 @@ class MatterBottlerBlockEntity(blockPos: BlockPos, blockState: BlockState) : if (!matter.missingMatter.isPositive) { if (spitItemsWhenCantWork) { - val iterator = unbottling.iterator() - - for (item in iterator) { - bottling.consumeItem(item, false) - iterator.setChanged() + for (slot in unbottling.slotIterator()) { + bottling.consumeItem(slot.item, false) + slot.setChanged() } } @@ -251,12 +249,13 @@ class MatterBottlerBlockEntity(blockPos: BlockPos, blockState: BlockState) : var any = false - val iterator = unbottling.iterator() - for (item in iterator) { + for (slot in unbottling.slotIterator()) { + val item = slot.item + item.getCapability(MatteryCapability.MATTER).ifPresentK { if (!it.storedMatter.isPositive) { bottling.consumeItem(item, false) - iterator.setChanged() + slot.setChanged() } else { any = true initialCapacity = initialCapacity ?: it.storedMatter diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt index 7c7be1288..af25c1045 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/PatternStorageBlockEntity.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.block.entity.matter -import com.google.common.collect.Streams import javax.annotation.ParametersAreNonnullByDefault import net.minecraft.core.BlockPos import net.minecraft.world.level.block.state.BlockState @@ -18,8 +17,6 @@ import net.minecraft.world.level.block.Block import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.matter.* import ru.dbotthepony.mc.otm.container.HandlerFilter -import ru.dbotthepony.mc.otm.container.iterator -import ru.dbotthepony.mc.otm.container.stream import ru.dbotthepony.mc.otm.core.collect.filterNotNull import ru.dbotthepony.mc.otm.core.collect.map import ru.dbotthepony.mc.otm.core.filterNotNull 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 c4d3543e7..a9a2be2da 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 @@ -44,7 +44,8 @@ import kotlin.collections.HashMap import ru.dbotthepony.mc.otm.client.render.Widgets8 import ru.dbotthepony.mc.otm.container.CombinedContainer import ru.dbotthepony.mc.otm.container.addItem -import ru.dbotthepony.mc.otm.container.fullIterator +import ru.dbotthepony.mc.otm.container.util.iterator +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.isNotEmpty @@ -58,13 +59,15 @@ interface IItemMonitorPlayerSettings { var ascendingSort: Boolean } -private fun takeOne(inventory: CombinedContainer?, item: ItemStack): Boolean { - val iterator = inventory?.optimizedIterator() ?: return false +private fun takeOne(inventory: Container?, item: ItemStack): Boolean { + val iterator = inventory?.slotIterator() ?: return false + + for (slot in iterator) { + val stack = slot.item - for (stack in iterator) { if (stack.equals(item, false)) { stack.shrink(1) - inventory.setChanged() + slot.setChanged() return true } } @@ -343,7 +346,7 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte check(residue.size == craftingGrid.containerSize) { "Container and residue list sizes mismatch: ${residue.size} != ${craftingGrid.containerSize}" } val combinedInventory = craftingPlayer.matteryPlayer?.combinedInventory - val copy = craftingGrid.fullIterator().map { it.copy() }.toList() + val copy = craftingGrid.iterator(true).map { it.copy() }.toList() // удаляем по одному предмету из сетки крафта for (slot in 0 until craftingGrid.containerSize) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt index 5c9af7a51..b22b6cef7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt @@ -26,9 +26,9 @@ import ru.dbotthepony.mc.otm.compat.curios.curiosStream import ru.dbotthepony.mc.otm.compat.curios.isCuriosLoaded import ru.dbotthepony.mc.otm.compat.mekanism.getMekanismEnergySided import ru.dbotthepony.mc.otm.compat.mekanism.mekanismEnergy -import ru.dbotthepony.mc.otm.container.awareStream -import ru.dbotthepony.mc.otm.container.iterator -import ru.dbotthepony.mc.otm.container.stream +import ru.dbotthepony.mc.otm.container.util.awareStream +import ru.dbotthepony.mc.otm.capability.iterator +import ru.dbotthepony.mc.otm.container.util.iterator import ru.dbotthepony.mc.otm.core.collect.AwareItemStack import ru.dbotthepony.mc.otm.core.collect.ContainerItemStackEntry import ru.dbotthepony.mc.otm.core.collect.concatIterators @@ -38,7 +38,6 @@ import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.core.util.formatFluidLevel -import java.util.IdentityHashMap import java.util.stream.Stream private val LOGGER = LogManager.getLogger() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/FluidHandlerIterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FluidHandlerIterator.kt similarity index 90% rename from src/main/kotlin/ru/dbotthepony/mc/otm/container/FluidHandlerIterator.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/capability/FluidHandlerIterator.kt index 65cfcc2d1..77984c858 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/FluidHandlerIterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FluidHandlerIterator.kt @@ -1,8 +1,9 @@ -package ru.dbotthepony.mc.otm.container +package ru.dbotthepony.mc.otm.capability import it.unimi.dsi.fastutil.objects.ObjectIterators.AbstractIndexBasedIterator import net.minecraftforge.fluids.FluidStack import net.minecraftforge.fluids.capability.IFluidHandler +import ru.dbotthepony.mc.otm.container.get class FluidHandlerIterator(private val handler: IFluidHandler, initialPosition: Int = 0) : AbstractIndexBasedIterator(0, initialPosition) { init { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/FluidHandlerSpliterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FluidHandlerSpliterator.kt similarity index 94% rename from src/main/kotlin/ru/dbotthepony/mc/otm/container/FluidHandlerSpliterator.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/capability/FluidHandlerSpliterator.kt index 89d2c15fa..1cf554f60 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/FluidHandlerSpliterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FluidHandlerSpliterator.kt @@ -1,9 +1,10 @@ -package ru.dbotthepony.mc.otm.container +package ru.dbotthepony.mc.otm.capability import it.unimi.dsi.fastutil.objects.ObjectSpliterator import it.unimi.dsi.fastutil.objects.ObjectSpliterators.AbstractIndexBasedSpliterator import net.minecraftforge.fluids.FluidStack import net.minecraftforge.fluids.capability.IFluidHandler +import ru.dbotthepony.mc.otm.container.get import java.util.Spliterator import java.util.stream.Stream import java.util.stream.StreamSupport diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index b77723d34..fc6fc98d5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -82,8 +82,8 @@ import ru.dbotthepony.mc.otm.config.ExopackConfig import ru.dbotthepony.mc.otm.container.CombinedContainer import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.get -import ru.dbotthepony.mc.otm.container.iterator -import ru.dbotthepony.mc.otm.container.stream +import ru.dbotthepony.mc.otm.capability.iterator +import ru.dbotthepony.mc.otm.container.util.slotIterator import ru.dbotthepony.mc.otm.container.vanishCursedItems import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.collect.UUIDIntModifiersMap @@ -130,13 +130,9 @@ import kotlin.collections.ArrayDeque import kotlin.reflect.KMutableProperty1 private fun Player.dropContainer(container: Container, spill: Boolean = true, setThrower: Boolean = false) { - val iterator = container.iterator() - - for (item in iterator) { - if (item.isNotEmpty) { - drop(item, spill, setThrower) - iterator.remove() - } + for (slot in container.slotIterator()) { + drop(slot.item, spill, setThrower) + slot.remove() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt index 17cf76090..845392761 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt @@ -23,9 +23,9 @@ import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.button.RectangleButtonPanel import ru.dbotthepony.mc.otm.compat.cos.CosmeticToggleButton.Companion.BUTTON_ACTIVE import ru.dbotthepony.mc.otm.compat.cos.CosmeticToggleButton.Companion.BUTTON_INACTIVE -import ru.dbotthepony.mc.otm.container.awareStream -import ru.dbotthepony.mc.otm.container.iterator -import ru.dbotthepony.mc.otm.container.stream +import ru.dbotthepony.mc.otm.container.util.awareStream +import ru.dbotthepony.mc.otm.capability.iterator +import ru.dbotthepony.mc.otm.container.util.iterator import ru.dbotthepony.mc.otm.core.collect.AwareItemStack import ru.dbotthepony.mc.otm.core.collect.emptyIterator import ru.dbotthepony.mc.otm.menu.MatterySlot diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt index 4904edad6..97532f820 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt @@ -4,15 +4,14 @@ import com.google.common.collect.Streams import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack -import net.minecraftforge.api.distmarker.Dist import net.minecraftforge.fml.ModList import net.minecraftforge.fml.loading.FMLEnvironment import net.minecraftforge.network.PacketDistributor import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer -import ru.dbotthepony.mc.otm.container.awareStream -import ru.dbotthepony.mc.otm.container.iterator -import ru.dbotthepony.mc.otm.container.stream +import ru.dbotthepony.mc.otm.container.util.awareStream +import ru.dbotthepony.mc.otm.capability.iterator +import ru.dbotthepony.mc.otm.container.util.iterator import ru.dbotthepony.mc.otm.core.collect.AwareItemStack import ru.dbotthepony.mc.otm.core.collect.concatIterators import ru.dbotthepony.mc.otm.core.collect.emptyIterator diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/CombinedContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/CombinedContainer.kt index 7d372b6ca..39f3ae231 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/CombinedContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/CombinedContainer.kt @@ -4,13 +4,16 @@ import com.google.common.collect.ImmutableList import com.google.common.collect.ImmutableMap import com.google.common.collect.ImmutableSet import it.unimi.dsi.fastutil.ints.IntAVLTreeSet -import it.unimi.dsi.fastutil.ints.IntOpenHashSet import it.unimi.dsi.fastutil.ints.IntSet import it.unimi.dsi.fastutil.objects.Object2ObjectFunction import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import net.minecraft.world.Container import net.minecraft.world.entity.player.Player import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.container.util.ContainerSlot +import ru.dbotthepony.mc.otm.container.util.IContainerSlot +import ru.dbotthepony.mc.otm.container.util.IIterableContainer +import ru.dbotthepony.mc.otm.container.util.iterator import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.collect.concatIterators import ru.dbotthepony.mc.otm.core.collect.filter @@ -21,26 +24,10 @@ import ru.dbotthepony.mc.otm.core.stream import java.util.LinkedList import java.util.stream.Stream -class CombinedContainer(containers: Stream>>) : Container { +class CombinedContainer(containers: Stream>>) : Container, IIterableContainer { constructor(vararg containers: Container) : this(containers.stream().map { it to (0 until it.containerSize).iterator() }) constructor(containers: Collection) : this(containers.stream().map { it to (0 until it.containerSize).iterator() }) - class ContainerSlot(val container: Container, val containerIndex: Int) : GetterSetter { - var item: ItemStack - get() = container[containerIndex] - set(value) { container[containerIndex] = value } - - override fun get(): ItemStack { - return item - } - - override fun accept(t: ItemStack) { - item = t - } - - val isEmpty: Boolean get() = item.isEmpty - } - private val slots: List private val slotsMap: Map> private val containers: Set @@ -60,7 +47,7 @@ class CombinedContainer(containers: Stream>>) : Co for (slot in slots) { if (validator.add(slot)) { i++ - val slotObj = ContainerSlot(container, slot) + val slotObj = ContainerSlot(slot, container) list.add(slotObj) slotList.add(slotObj) } else { @@ -131,12 +118,12 @@ class CombinedContainer(containers: Stream>>) : Co override fun removeItem(index: Int, count: Int): ItemStack { val data = slots.getOrNull(index) ?: return ItemStack.EMPTY - return data.container.removeItem(data.containerIndex, count) + return data.container.removeItem(data.slot, count) } override fun removeItemNoUpdate(index: Int): ItemStack { val data = slots.getOrNull(index) ?: return ItemStack.EMPTY - return data.container.removeItemNoUpdate(data.containerIndex) + return data.container.removeItemNoUpdate(data.slot) } override fun setItem(index: Int, value: ItemStack) { @@ -153,7 +140,7 @@ class CombinedContainer(containers: Stream>>) : Co val data = slots.getOrNull(index) ?: return if (data.container is MatteryContainer) { - data.container.setChanged(data.containerIndex) + data.container.setChanged(data.slot) } else { data.container.setChanged() } @@ -167,13 +154,20 @@ class CombinedContainer(containers: Stream>>) : Co return true } - fun optimizedIterator(): Iterator { + override fun iterator(nonEmpty: Boolean): Iterator { return concatIterators( - fullCoverage.iterator().flatMap { it.iterator() }, - notFullCoverage.values.iterator().flatMap { it.iterator() }.map { it.item }.filter { it.isNotEmpty } + fullCoverage.iterator().flatMap { it.iterator(nonEmpty) }, + notFullCoverage.values.iterator().flatMap { it.iterator() }.map { it.item }.let { if (nonEmpty) it.filter { it.isNotEmpty } else it } ) } + override fun slotIterator(nonEmpty: Boolean): Iterator { + if (nonEmpty) + return slots.iterator().filter { it.isNotEmpty } + + return slots.iterator() + } + class Builder { private var built = false private val values = LinkedList>>() 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 c4fd2a636..25fe04cda 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHandler.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.container import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.Items import net.minecraftforge.items.IItemHandler class ContainerHandler @JvmOverloads internal constructor( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHelpers.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHelpers.kt index fc69f47b8..14d286ec9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHelpers.kt @@ -11,8 +11,11 @@ import net.minecraft.world.inventory.CraftingContainer import net.minecraft.world.item.ItemStack import net.minecraft.world.item.enchantment.EnchantmentHelper.hasVanishingCurse import net.minecraftforge.fluids.capability.IFluidHandler +import ru.dbotthepony.mc.otm.container.util.ItemStackHashStrategy +import ru.dbotthepony.mc.otm.container.util.slotIterator import ru.dbotthepony.mc.otm.core.addAll import ru.dbotthepony.mc.otm.core.isNotEmpty +import ru.dbotthepony.mc.otm.core.util.ItemStackSorter import kotlin.math.roundToInt @Suppress("nothing_to_inline") @@ -87,11 +90,9 @@ fun Container.addItem(stack: ItemStack, range: IntRange, simulate: Boolean = fal fun Container.addItem(stack: ItemStack, simulate: Boolean): ItemStack = addItem(stack, 0 until containerSize, simulate) fun Container.vanishCursedItems() { - val iterator = iterator() - - for (item in iterator) { - if (item.isNotEmpty && hasVanishingCurse(item)) { - iterator.remove() + for (slot in slotIterator()) { + if (hasVanishingCurse(slot.item)) { + slot.remove() } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerIterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerIterator.kt deleted file mode 100644 index fcf660f9c..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerIterator.kt +++ /dev/null @@ -1,82 +0,0 @@ -package ru.dbotthepony.mc.otm.container - -import it.unimi.dsi.fastutil.objects.ObjectIterators -import net.minecraft.world.Container -import net.minecraft.world.item.ItemStack -import ru.dbotthepony.mc.otm.core.isNotEmpty - -class ContainerIterator(private val container: Container) : IContainerIterator { - private var index = 0 - private var lastIndex = -1 - - override fun hasNext(): Boolean { - while (index < container.containerSize) { - if (container[index].isNotEmpty) { - return true - } - - index++ - } - - return false - } - - override fun next(): ItemStack { - if (!hasNext()) { - throw NoSuchElementException() - } - - lastIndex = index - return container[index++] - } - - override fun remove() { - if (lastIndex == -1) { - throw NoSuchElementException() - } - - container[lastIndex] = ItemStack.EMPTY - lastIndex = -1 - } - - override fun setChanged() { - container.setChanged() - } -} - -fun Container.iterator(): IContainerIterator { - return if (this is MatteryContainer) { - iterator() - } else { - ContainerIterator(this) - } -} - -class FullContainerIterator(val container: Container, initialPos: Int = 0) : MutableIterator, ObjectIterators.AbstractIndexBasedListIterator(0, initialPos), IContainerIterator { - override fun remove(location: Int) { - pos++ - container[location] = ItemStack.EMPTY - } - - override fun get(location: Int): ItemStack { - return container[location] - } - - override fun getMaxPos(): Int { - return container.containerSize - } - - override fun add(location: Int, k: ItemStack?) { - throw UnsupportedOperationException() - } - - override fun set(location: Int, k: ItemStack) { - container[location] = k - } - - override fun setChanged() { - container.setChanged() - } -} - -fun Container.fullIterator() = FullContainerIterator(this) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt index c540621f0..1d2ca7c8e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt @@ -4,7 +4,7 @@ import net.minecraft.world.item.ItemStack import net.minecraftforge.common.ForgeHooks import net.minecraftforge.common.capabilities.ForgeCapabilities import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.core.ifPresentK +import ru.dbotthepony.mc.otm.capability.stream import ru.dbotthepony.mc.otm.core.isNotEmpty interface HandlerFilter { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/IContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/IContainer.kt new file mode 100644 index 000000000..71e7c696c --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/IContainer.kt @@ -0,0 +1,84 @@ +package ru.dbotthepony.mc.otm.container + +import net.minecraft.world.Container +import net.minecraft.world.entity.player.Player +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import java.util.function.Predicate + +// passthrough all default methods to fix Kotlin bug related to implementation delegation not properly working on Java interfaces +// https://youtrack.jetbrains.com/issue/KT-55080/Change-the-behavior-of-inheritance-delegation-to-delegates-implementing-Java-interfaces-with-default-methods +interface IContainer : Container { + override fun getMaxStackSize(): Int { + return super.getMaxStackSize() + } + + override fun startOpen(player: Player) { + super.startOpen(player) + } + + override fun stopOpen(player: Player) { + super.stopOpen(player) + } + + override fun canPlaceItem(slot: Int, itemStack: ItemStack): Boolean { + return super.canPlaceItem(slot, itemStack) + } + + override fun canTakeItem(container: Container, slot: Int, itemStack: ItemStack): Boolean { + return super.canTakeItem(container, slot, itemStack) + } + + override fun countItem(item: Item): Int { + return super.countItem(item) + } + + override fun hasAnyOf(items: Set): Boolean { + return super.hasAnyOf(items) + } + + override fun hasAnyMatching(predicate: Predicate): Boolean { + return super.hasAnyMatching(predicate) + } + + companion object { + fun wrap(container: Container): IContainer { + if (container is IContainer) + return container + else + return object : IContainer, Container by container { + override fun getMaxStackSize(): Int { + return container.getMaxStackSize() + } + + override fun startOpen(player: Player) { + container.startOpen(player) + } + + override fun stopOpen(player: Player) { + container.stopOpen(player) + } + + override fun canPlaceItem(slot: Int, itemStack: ItemStack): Boolean { + return container.canPlaceItem(slot, itemStack) + } + + override fun canTakeItem(container: Container, slot: Int, itemStack: ItemStack): Boolean { + return container.canTakeItem(container, slot, itemStack) + } + + override fun countItem(item: Item): Int { + return container.countItem(item) + } + + override fun hasAnyOf(items: Set): Boolean { + return container.hasAnyOf(items) + } + + override fun hasAnyMatching(predicate: Predicate): Boolean { + return container.hasAnyMatching(predicate) + } + } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/IContainerIterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/IContainerIterator.kt deleted file mode 100644 index cc9fe4b51..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/IContainerIterator.kt +++ /dev/null @@ -1,12 +0,0 @@ -package ru.dbotthepony.mc.otm.container - -import net.minecraft.world.item.ItemStack - -interface IContainerIterator : MutableIterator { - /** - * Notifies underlying container that last returned [ItemStack] was modified - * - * @throws NoSuchElementException - */ - fun setChanged() -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt index 43a135ca2..ea8e4f840 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt @@ -11,7 +11,6 @@ import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.ListTag import net.minecraft.nbt.Tag import net.minecraft.resources.ResourceLocation -import net.minecraft.world.Container import kotlin.jvm.JvmOverloads import net.minecraft.world.entity.player.Player import net.minecraft.world.entity.player.StackedContents @@ -20,10 +19,15 @@ import net.minecraft.world.item.Item import net.minecraft.world.item.Items import net.minecraftforge.common.util.INBTSerializable import net.minecraftforge.registries.ForgeRegistries +import ru.dbotthepony.mc.otm.container.util.ContainerSlot +import ru.dbotthepony.mc.otm.container.util.IContainerSlot +import ru.dbotthepony.mc.otm.container.util.IIterableContainer import ru.dbotthepony.mc.otm.core.addSorted import ru.dbotthepony.mc.otm.core.collect.any import ru.dbotthepony.mc.otm.core.collect.count +import ru.dbotthepony.mc.otm.core.collect.emptyIterator import ru.dbotthepony.mc.otm.core.collect.filter +import ru.dbotthepony.mc.otm.core.collect.map import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set @@ -39,11 +43,11 @@ import java.util.function.Predicate import java.util.function.Supplier import java.util.stream.Stream import java.util.stream.StreamSupport -import kotlin.NoSuchElementException import kotlin.collections.ArrayList +import kotlin.collections.Iterator @Suppress("UNUSED") -open class MatteryContainer(protected val watcher: Runnable, private val size: Int) : Container, Iterable, INBTSerializable, StackedContentsCompatible { +open class MatteryContainer(protected val watcher: Runnable, private val size: Int) : IContainer, IIterableContainer, Iterable, INBTSerializable, StackedContentsCompatible { constructor(size: Int) : this({}, size) init { @@ -553,7 +557,7 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I } } - private inner class Iterator : IContainerIterator { + private inner class Iterator : kotlin.collections.Iterator { init { indicesReferenced = true } @@ -569,24 +573,6 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I lastIndex = parent.nextInt() return getItem(lastIndex) } - - override fun remove() { - if (lastIndex == -1) { - throw NoSuchElementException() - } - - parent.remove() - setItem(lastIndex, ItemStack.EMPTY) - lastIndex = -1 - } - - override fun setChanged() { - if (lastIndex == -1) { - throw NoSuchElementException() - } - - setChanged(lastIndex) - } } private inner class Spliterator(private val parent: IntSpliterator) : java.util.Spliterator { @@ -609,38 +595,46 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I } } - private object EmptyIterator : IContainerIterator { - override fun hasNext(): Boolean { - return false - } - - override fun next(): ItemStack { - throw NoSuchElementException() - } - - override fun remove() { - throw NoSuchElementException() - } - - override fun setChanged() { - throw NoSuchElementException() - } - } - - final override fun iterator(): IContainerIterator { + final override fun iterator(): kotlin.collections.Iterator { if (isEmpty) { - return EmptyIterator + return emptyIterator() } return Iterator() } + final override fun iterator(nonEmpty: Boolean): kotlin.collections.Iterator { + if (!nonEmpty) { + return (0 until size).iterator().map { slots[it] } + } else if (isEmpty) { + return emptyIterator() + } else { + return Iterator() + } + } + + final override fun slotIterator(): kotlin.collections.Iterator { + indicesReferenced = true + return nonEmptyIndices.iterator().map { ContainerSlot(it, this) } + } + + final override fun slotIterator(nonEmpty: Boolean): kotlin.collections.Iterator { + if (!nonEmpty) { + return (0 until size).iterator().map { ContainerSlot(it, this) } + } else if (isEmpty) { + return emptyIterator() + } else { + indicesReferenced = true + return nonEmptyIndices.iterator().map { ContainerSlot(it, this) } + } + } + final override fun countItem(item: Item): Int { return iterator().filter { it.item == item }.count().toInt() } - final override fun hasAnyOf(set: Set): Boolean { - return iterator().any { it.item in set } + final override fun hasAnyOf(items: Set): Boolean { + return iterator().any { it.item in items } } final override fun hasAnyMatching(predicate: Predicate): Boolean { 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 3f506ffec..93c85355e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowContainer.kt @@ -3,9 +3,8 @@ 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 java.util.Arrays -class ShadowContainer(private val parent: Container) : Container by parent { +class ShadowContainer(private val parent: Container) : IContainer by IContainer.wrap(parent) { private val shadowed = Int2ObjectArrayMap(0) override fun clearContent() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowCraftingContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowCraftingContainer.kt index 662d32a3e..95123a710 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowCraftingContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowCraftingContainer.kt @@ -1,12 +1,12 @@ package ru.dbotthepony.mc.otm.container -import net.minecraft.world.Container import net.minecraft.world.entity.player.StackedContents import net.minecraft.world.inventory.CraftingContainer import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.container.util.iterator import ru.dbotthepony.mc.otm.core.collect.toList -class ShadowCraftingContainer(private val parent: CraftingContainer) : Container by ShadowContainer(parent), CraftingContainer { +class ShadowCraftingContainer(private val parent: CraftingContainer) : IContainer by ShadowContainer(parent), CraftingContainer { override fun fillStackedContents(contents: StackedContents) { for (item in iterator()) { contents.accountStack(item) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerSpliterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/util/ContainerSpliterator.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerSpliterator.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/container/util/ContainerSpliterator.kt index 6ed9cea8f..e3f7c6216 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerSpliterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/util/ContainerSpliterator.kt @@ -1,9 +1,10 @@ -package ru.dbotthepony.mc.otm.container +package ru.dbotthepony.mc.otm.container.util import it.unimi.dsi.fastutil.objects.ObjectSpliterator import it.unimi.dsi.fastutil.objects.ObjectSpliterators import net.minecraft.world.Container import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.container.get import ru.dbotthepony.mc.otm.core.collect.AwareItemStack import ru.dbotthepony.mc.otm.core.collect.ContainerItemStackEntry import java.util.stream.Stream diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemHandlerSpliterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/util/ItemHandlerSpliterator.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemHandlerSpliterator.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/container/util/ItemHandlerSpliterator.kt index 862c25e43..9d7c27669 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemHandlerSpliterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/util/ItemHandlerSpliterator.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.container +package ru.dbotthepony.mc.otm.container.util import it.unimi.dsi.fastutil.objects.ObjectSpliterator import it.unimi.dsi.fastutil.objects.ObjectSpliterators diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemStackHashStrategy.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/util/ItemStackHashStrategy.kt similarity index 89% rename from src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemStackHashStrategy.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/container/util/ItemStackHashStrategy.kt index cd9c7e5ff..5d635e5af 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemStackHashStrategy.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/util/ItemStackHashStrategy.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.container +package ru.dbotthepony.mc.otm.container.util import it.unimi.dsi.fastutil.Hash import net.minecraft.world.item.ItemStack diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/util/Iterators.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/util/Iterators.kt new file mode 100644 index 000000000..94bdfeaba --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/util/Iterators.kt @@ -0,0 +1,123 @@ +package ru.dbotthepony.mc.otm.container.util + +import net.minecraft.world.Container +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.container.MatteryContainer +import ru.dbotthepony.mc.otm.container.get +import ru.dbotthepony.mc.otm.container.set +import ru.dbotthepony.mc.otm.core.GetterSetter +import ru.dbotthepony.mc.otm.core.collect.filter +import ru.dbotthepony.mc.otm.core.collect.map +import ru.dbotthepony.mc.otm.core.isNotEmpty + +interface IContainerSlot : GetterSetter { + val slot: Int + val container: Container + + operator fun component1() = slot + operator fun component2() = item + + val isForbiddenForAutomation: Boolean get() { + val container = container + + if (container is MatteryContainer) { + return container.isSlotForbiddenForAutomation(slot) + } else { + return false + } + } + + val filter: Item? get() { + val container = container + + if (container is MatteryContainer) { + return container.getSlotFilter(slot) + } else { + return null + } + } + + val hasFilter: Boolean + get() = filter != null + + fun remove() { + container[slot] = ItemStack.EMPTY + } + + override fun get(): ItemStack { + return container[slot] + } + + override fun accept(t: ItemStack) { + container[slot] = t + } + + fun setChanged() { + val container = container + + if (container is MatteryContainer) { + container.setChanged(slot) + } else { + container.setChanged() + } + } + + var item: ItemStack + get() = container[slot] + set(value) { container[slot] = value } + + val isEmpty: Boolean + get() = container[slot].isEmpty + + val isNotEmpty: Boolean + get() = container[slot].isNotEmpty +} + +class ContainerSlot(override val slot: Int, override val container: Container) : IContainerSlot { + init { + require(slot in 0 until container.containerSize) { "Slot out of bounds: $slot (container: $container with size ${container.containerSize})" } + } +} + +interface IIterableContainer : Iterable { + /** + * Iterates over non-empty itemstacks of this container + */ + override fun iterator(): Iterator { + return iterator(true) + } + + fun iterator(nonEmpty: Boolean): Iterator + + /** + * Iterates non-empty slots of this container + */ + fun slotIterator(): Iterator { + return slotIterator(true) + } + + fun slotIterator(nonEmpty: Boolean): Iterator +} + +operator fun Container.iterator() = iterator(true) + +fun Container.iterator(nonEmpty: Boolean): Iterator { + if (this is IIterableContainer) { + return iterator(nonEmpty) + } else if (nonEmpty) { + return (0 until containerSize).iterator().map { this[it] }.filter { it.isNotEmpty } + } else { + return (0 until containerSize).iterator().map { this[it] } + } +} + +fun Container.slotIterator(nonEmpty: Boolean = true): Iterator { + if (this is IIterableContainer) { + return slotIterator(nonEmpty) + } else if (nonEmpty) { + return (0 until containerSize).iterator().filter { this[it].isNotEmpty }.map { ContainerSlot(it, this) } + } else { + return (0 until containerSize).iterator().map { ContainerSlot(it, this) } + } +} 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 553bc6630..fdbfa0c23 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt @@ -34,10 +34,12 @@ import net.minecraftforge.fluids.FluidUtil import net.minecraftforge.fluids.capability.IFluidHandler import ru.dbotthepony.mc.otm.capability.fluid.ItemMatteryFluidHandler import ru.dbotthepony.mc.otm.capability.fluidLevel +import ru.dbotthepony.mc.otm.capability.iterator import ru.dbotthepony.mc.otm.capability.moveFluid import ru.dbotthepony.mc.otm.container.get -import ru.dbotthepony.mc.otm.container.stream +import ru.dbotthepony.mc.otm.container.util.stream import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.collect.any import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.immutableMap @@ -223,7 +225,7 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6 override fun canInteract(item: ItemStack, player: Player, context: Context): Boolean { val target = player.level().getBlockEntity(context.blockPos)?.getCapability(ForgeCapabilities.FLUID_HANDLER, context.side)?.orNull() ?: return false val cap = item.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).orNull() ?: return false - return target.stream().anyMatch { !it.isEmpty } || cap.stream().anyMatch { !it.isEmpty } + return target.iterator().any { !it.isEmpty } || cap.iterator().any { !it.isEmpty } } override fun interact(item: ItemStack, player: Player, context: Context): InteractionResult { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 2218f87d4..4fffe1a0e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -71,7 +71,7 @@ import ru.dbotthepony.mc.otm.capability.drive.IMatteryDrive import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.container.set -import ru.dbotthepony.mc.otm.container.stream +import ru.dbotthepony.mc.otm.container.util.stream import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt index 2a936470f..21d2562cf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt @@ -11,7 +11,9 @@ import net.minecraft.world.inventory.* import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.compat.curios.curiosSlots -import ru.dbotthepony.mc.otm.container.iterator +import ru.dbotthepony.mc.otm.capability.iterator +import ru.dbotthepony.mc.otm.container.util.iterator +import ru.dbotthepony.mc.otm.container.util.slotIterator import ru.dbotthepony.mc.otm.menu.input.InstantBooleanInput import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.network.ExopackCarriedPacket @@ -164,16 +166,14 @@ class ExopackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen craftingResultContainer.clearContent() if (!player.level().isClientSide) { - val iterator = craftingGrid.iterator() - - for (itemStack in iterator) { - val leftover = moveItemStackToSlots(itemStack, playerInventorySlots) + for (slot in craftingGrid.slotIterator()) { + val leftover = moveItemStackToSlots(slot.item, playerInventorySlots) if (!leftover.isEmpty) { player.drop(leftover, true) } - iterator.remove() + slot.remove() } } } 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 e9a7ca4dc..0a39fa492 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/EnergyContainerRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/EnergyContainerRecipe.kt @@ -16,8 +16,9 @@ import net.minecraft.world.item.crafting.ShapedRecipe import net.minecraft.world.level.Level import net.minecraftforge.common.crafting.IShapedRecipe import ru.dbotthepony.mc.otm.capability.matteryEnergy -import ru.dbotthepony.mc.otm.container.iterator -import ru.dbotthepony.mc.otm.container.stream +import ru.dbotthepony.mc.otm.capability.iterator +import ru.dbotthepony.mc.otm.container.util.iterator +import ru.dbotthepony.mc.otm.container.util.stream import ru.dbotthepony.mc.otm.core.filterNotNull class EnergyContainerRecipe(val parent: ShapedRecipe) : CraftingRecipe, IShapedRecipe by parent { @@ -84,7 +85,7 @@ class EnergyContainerRecipe(val parent: ShapedRecipe) : CraftingRecipe, IShapedR if (itemStack.isEnchantable) { for (it in container.iterator()) { - if (!it.isEmpty && it.isEnchanted) { + if (it.isEnchanted) { for ((key, value) in it.allEnchantments) { itemStack.enchant(key, value) } 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 ad4687512..fdc09fba8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/ExplosiveHammerPrimingRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/ExplosiveHammerPrimingRecipe.kt @@ -15,7 +15,7 @@ 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.stream +import ru.dbotthepony.mc.otm.container.util.stream import ru.dbotthepony.mc.otm.core.isActuallyEmpty import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.core.set diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/IMatteryRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/IMatteryRecipe.kt index ec41ae375..3e5ac763e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/IMatteryRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/IMatteryRecipe.kt @@ -8,7 +8,7 @@ import net.minecraft.world.item.crafting.Recipe import net.minecraft.world.item.crafting.RecipeSerializer import ru.dbotthepony.mc.otm.data.Codec2RecipeSerializer -// overrides all methods to fix Kotlin bug related to implementation delegation (to allow easy optics) +// passthrough all default methods to fix Kotlin bug related to implementation delegation not properly working on Java interfaces // https://youtrack.jetbrains.com/issue/KT-55080/Change-the-behavior-of-inheritance-delegation-to-delegates-implementing-Java-interfaces-with-default-methods interface IMatteryRecipe : Recipe { override fun getRemainingItems(p_44004_: C): NonNullList { 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 a836c3e52..375ed8c4e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt @@ -10,16 +10,14 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.world.inventory.CraftingContainer import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Ingredient -import net.minecraft.world.item.crafting.Recipe import net.minecraft.world.item.crafting.RecipeSerializer import net.minecraft.world.item.crafting.RecipeType import net.minecraft.world.level.Level -import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.capability.matter.matter import ru.dbotthepony.mc.otm.capability.matteryEnergy -import ru.dbotthepony.mc.otm.container.iterator +import ru.dbotthepony.mc.otm.capability.iterator +import ru.dbotthepony.mc.otm.container.util.iterator import ru.dbotthepony.mc.otm.core.collect.filterNotNull -import ru.dbotthepony.mc.otm.core.collect.forEach import ru.dbotthepony.mc.otm.core.collect.map import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.nbt.set 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 71ae269d2..5b55ed793 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt @@ -19,7 +19,7 @@ import net.minecraft.world.item.crafting.RecipeType import net.minecraft.world.item.crafting.ShapedRecipe import net.minecraft.world.level.Level import net.minecraftforge.common.crafting.IShapedRecipe -import ru.dbotthepony.mc.otm.container.stream +import ru.dbotthepony.mc.otm.container.util.stream import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.core.set diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MatteryInventoryChangeTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MatteryInventoryChangeTrigger.kt index d135c63ba..dd1c4ab84 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MatteryInventoryChangeTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MatteryInventoryChangeTrigger.kt @@ -23,7 +23,8 @@ import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.container.CombinedContainer import ru.dbotthepony.mc.otm.container.get -import ru.dbotthepony.mc.otm.container.iterator +import ru.dbotthepony.mc.otm.capability.iterator +import ru.dbotthepony.mc.otm.container.util.iterator import ru.dbotthepony.mc.otm.core.collect.flatMap import ru.dbotthepony.mc.otm.core.collect.toList import ru.dbotthepony.mc.otm.core.isNotEmpty @@ -178,9 +179,8 @@ object MatteryInventoryChangeTrigger : CriterionTrigger 1) { val unsatisfied = ObjectArrayList(this.predicates) unsatisfied.removeIf { it.matches(ItemStack.EMPTY) } - val iterator = if (inventory is CombinedContainer) inventory.optimizedIterator() else inventory.iterator() - for (inventoryItem in iterator) { + for (inventoryItem in inventory) { unsatisfied.removeIf { it.matches(inventoryItem) } if (unsatisfied.isEmpty) break } From d4c029f27d5249f9178228715ce27885962ee4cf Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 20 Aug 2023 15:39:20 +0700 Subject: [PATCH 1000/1199] Slice container APIs and decouple interface from implementation, container sorting test --- .../mc/otm/datagen/lang/English.kt | 1 + .../mc/otm/datagen/lang/Russian.kt | 1 + .../entity/storage/ItemMonitorBlockEntity.kt | 4 +- .../entity/tech/PlatePressBlockEntity.kt | 3 +- .../ru/dbotthepony/mc/otm/capability/Ext.kt | 41 +-- .../otm/capability/MatteryPlayerCapability.kt | 262 +++++------------- .../mc/otm/client/ClientEventHandler.kt | 10 +- .../mc/otm/client/render/WidgetLocation.kt | 2 +- .../mc/otm/client/render/Widgets18.kt | 3 +- .../client/screen/ExopackInventoryScreen.kt | 21 +- .../mc/otm/client/screen/MatteryScreen.kt | 25 +- .../screen/decorative/CargoCrateScreen.kt | 8 + .../client/screen/decorative/PainterScreen.kt | 2 +- .../client/screen/matter/MatterPanelScreen.kt | 2 +- .../client/screen/panels/button/Buttons.kt | 28 +- .../button/LargeRectangleButtonPanel.kt | 34 ++- .../screen/tech/EssenceStorageScreen.kt | 18 +- .../mc/otm/container/CombinedContainer.kt | 130 +++++---- .../mc/otm/container/ContainerHandler.kt | 4 +- .../mc/otm/container/ContainerHelpers.kt | 77 ++++- .../container/DynamicallyProxiedContainer.kt | 81 ++++++ .../mc/otm/container/IContainer.kt | 11 + .../mc/otm/container/IMatteryContainer.kt | 217 +++++++++++++++ .../mc/otm/container/MatteryContainer.kt | 199 ++++--------- .../mc/otm/container/util/Iterators.kt | 75 +++-- .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 13 +- .../mc/otm/core/collect/Iterables.kt | 24 ++ .../mc/otm/core/collect/StreamyIterators.kt | 4 +- .../mc/otm/core/util/ItemSorter.kt | 28 +- .../mc/otm/item/QuantumBatteryItem.kt | 4 +- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 114 +++----- .../ru/dbotthepony/mc/otm/menu/Slots.kt | 22 ++ .../mc/otm/menu/data/NetworkedItemView.kt | 2 +- .../mc/otm/menu/decorative/CargoCrateMenu.kt | 7 +- .../mc/otm/menu/storage/DriveViewerMenu.kt | 2 +- .../mc/otm/menu/storage/ItemMonitorMenu.kt | 2 +- .../textures/gui/widgets/storage_controls.png | Bin 1020 -> 1063 bytes .../textures/gui/widgets/storage_controls.xcf | Bin 9801 -> 10269 bytes 38 files changed, 845 insertions(+), 636 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/container/DynamicallyProxiedContainer.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/container/IMatteryContainer.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/Iterables.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index cbc045636..980212cbc 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -805,6 +805,7 @@ private fun gui(provider: MatteryLanguageProvider) { gui("balance_inputs", "Balance input slots") + gui("sorting.sort_now", "Sort") gui("sorting.default", "Default sorting") gui("sorting.name", "Sort by name") gui("sorting.id", "Sort by ID") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 0bd7a8786..f9711bcfb 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -805,6 +805,7 @@ private fun gui(provider: MatteryLanguageProvider) { gui("balance_inputs", "Балансировать входные слоты") + gui("sorting.sort_now", "Отсортировать") gui("sorting.default", "Сортировка по умолчанию") gui("sorting.name", "Сортировка по имени") gui("sorting.id", "Сортировка по ID") 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 a9a2be2da..7f3a1aace 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 @@ -43,8 +43,6 @@ import java.util.* import kotlin.collections.HashMap import ru.dbotthepony.mc.otm.client.render.Widgets8 import ru.dbotthepony.mc.otm.container.CombinedContainer -import ru.dbotthepony.mc.otm.container.addItem -import ru.dbotthepony.mc.otm.container.util.iterator import ru.dbotthepony.mc.otm.container.util.slotIterator import ru.dbotthepony.mc.otm.core.collect.map import ru.dbotthepony.mc.otm.core.collect.toList @@ -345,7 +343,7 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte check(residue.size == craftingGrid.containerSize) { "Container and residue list sizes mismatch: ${residue.size} != ${craftingGrid.containerSize}" } - val combinedInventory = craftingPlayer.matteryPlayer?.combinedInventory + val combinedInventory = craftingPlayer.matteryPlayer?.inventoryAndExopack val copy = craftingGrid.iterator(true).map { it.copy() }.toList() // удаляем по одному предмету из сетки крафта 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 3c2e7368d..5dcf9e6e0 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 @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.block.entity.tech +import it.unimi.dsi.fastutil.ints.IntArrayList import net.minecraft.core.BlockPos import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerPlayer @@ -74,7 +75,7 @@ class PlatePressBlockEntity( if (status.job.itemStack.isEmpty) return status.success() - if (!outputContainer.fullyAddItem(status.job.itemStack, start = id, end = id) && !outputContainer.fullyAddItem(status.job.itemStack)) + if (!outputContainer.fullyAddItem(status.job.itemStack, slots = IntArrayList.of(id)) && !outputContainer.fullyAddItem(status.job.itemStack)) return status.noItem() experience = (experience + status.experience).coerceAtMost(100.0) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt index b22b6cef7..55e10351a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.capability import com.google.common.collect.Streams -import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet import net.minecraft.ChatFormatting import net.minecraft.core.Direction import net.minecraft.network.chat.Component @@ -27,11 +26,11 @@ import ru.dbotthepony.mc.otm.compat.curios.isCuriosLoaded import ru.dbotthepony.mc.otm.compat.mekanism.getMekanismEnergySided import ru.dbotthepony.mc.otm.compat.mekanism.mekanismEnergy import ru.dbotthepony.mc.otm.container.util.awareStream -import ru.dbotthepony.mc.otm.capability.iterator import ru.dbotthepony.mc.otm.container.util.iterator import ru.dbotthepony.mc.otm.core.collect.AwareItemStack import ru.dbotthepony.mc.otm.core.collect.ContainerItemStackEntry import ru.dbotthepony.mc.otm.core.collect.concatIterators +import ru.dbotthepony.mc.otm.core.collect.emptyIterator import ru.dbotthepony.mc.otm.core.collect.filter import ru.dbotthepony.mc.otm.core.collect.map import ru.dbotthepony.mc.otm.core.isNotEmpty @@ -217,21 +216,16 @@ fun ICapabilityProvider.getMatteryEnergySided(side: Direction? = null): LazyOpti return LazyOptional.empty() } -/** - * DO NOT modify returned ItemStacks! - * - * Contains all items that player might carry - */ fun Player.items(includeCosmetics: Boolean = true): Iterator { - val iterators = ArrayList>() - iterators.add(inventory.iterator()) + val matteryPlayer = matteryPlayer ?: return emptyIterator() - matteryPlayer?.let { - if (it.hasExopack) { - iterators.add(it.exopackContainer.iterator()) - iterators.add(it.exopackEnergy.parent.iterator()) - iterators.add(it.exopackChargeSlots.iterator()) - } + val iterators = ArrayList>() + iterators.add(matteryPlayer.wrappedInventory.slotIterator().filter { !it.isForbiddenForAutomation }.map { it.item }) + + if (matteryPlayer.hasExopack) { + iterators.add(matteryPlayer.exopackContainer.slotIterator().filter { !it.isForbiddenForAutomation }.map { it.item }) + iterators.add(matteryPlayer.exopackEnergy.parent.iterator()) + iterators.add(matteryPlayer.exopackChargeSlots.iterator()) } if (isCuriosLoaded) { @@ -245,25 +239,12 @@ fun Player.items(includeCosmetics: Boolean = true): Iterator { return concatIterators(iterators) } -/** - * DO NOT modify returned ItemStacks! - * - * Contains all items that player might see/access ([itemsStream] + open container's items) - */ -fun Player.allItems(includeCosmetics: Boolean = true): Iterator { +fun Player.trackedItems(includeCosmetics: Boolean = true): Iterator { if (containerMenu == inventoryMenu || containerMenu == matteryPlayer?.exoPackMenu) { return items(includeCosmetics) } - val seen = ReferenceOpenHashSet(containerMenu.slots.size) - - for (slot in containerMenu.slots) { - seen.add(slot.item) - } - - return concatIterators( - items(includeCosmetics).filter { it.isNotEmpty && it !in seen }, - containerMenu.slots.iterator().map { it.item }) + return concatIterators(items(includeCosmetics), containerMenu.slots.iterator().map { it.item }.filter { it.isNotEmpty }) } /** diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index fc6fc98d5..423738677 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -10,7 +10,6 @@ import net.minecraft.client.player.AbstractClientPlayer import net.minecraft.commands.Commands import net.minecraft.commands.arguments.EntityArgument import net.minecraft.core.Direction -import net.minecraft.nbt.ByteTag import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.IntTag import net.minecraft.nbt.ListTag @@ -31,6 +30,7 @@ import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.boss.wither.WitherBoss import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player +import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.item.ProjectileWeaponItem @@ -82,7 +82,9 @@ import ru.dbotthepony.mc.otm.config.ExopackConfig import ru.dbotthepony.mc.otm.container.CombinedContainer import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.get -import ru.dbotthepony.mc.otm.capability.iterator +import ru.dbotthepony.mc.otm.container.DynamicallyProxiedContainer +import ru.dbotthepony.mc.otm.container.IContainer +import ru.dbotthepony.mc.otm.container.IMatteryContainer import ru.dbotthepony.mc.otm.container.util.slotIterator import ru.dbotthepony.mc.otm.container.vanishCursedItems import ru.dbotthepony.mc.otm.core.* @@ -91,7 +93,6 @@ import ru.dbotthepony.mc.otm.core.collect.filter import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.minus -import ru.dbotthepony.mc.otm.core.nbt.getByteList import ru.dbotthepony.mc.otm.core.nbt.getCompoundList import ru.dbotthepony.mc.otm.core.nbt.getIntList import ru.dbotthepony.mc.otm.core.nbt.getStringList @@ -258,27 +259,23 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial synchronizer.Field(null, ItemValueCodec.nullable) } - val regularSlotChargeFlag = immutableList(Inventory.INVENTORY_SIZE + 5) { - synchronizer.bool() - } + val slotsChargeFlag by synchronizer.Set( + codec = VarIntValueCodec, + backingSet = IntAVLTreeSet(), + ) private fun slotChargeToDefault() { // броня - regularSlotChargeFlag[36].boolean = true - regularSlotChargeFlag[37].boolean = true - regularSlotChargeFlag[38].boolean = true - regularSlotChargeFlag[39].boolean = true + slotsChargeFlag.add(36) + slotsChargeFlag.add(37) + slotsChargeFlag.add(38) + slotsChargeFlag.add(39) } init { slotChargeToDefault() } - val exoPackSlotsChargeFlag by synchronizer.Set( - codec = VarIntValueCodec, - backingSet = IntAVLTreeSet(), - ) - /** * Exopack container, which actually store items inside Exopack */ @@ -303,19 +300,60 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial value.addFilterSynchronizer(synchronizer) field = value - _combinedInventory = CombinedContainer(ply.inventory, exopackContainer) + _combinedInventory = CombinedContainer(wrappedInventory, exopackContainer) + _combinedInventory2 = CombinedContainer(wrappedItemInventory, exopackContainer) + _combinedInventory3 = CombinedContainer.Builder().add(wrappedItemInventory, 9 .. 35).add(exopackContainer).build() } private var _combinedInventory: CombinedContainer? = null + private var _combinedInventory2: CombinedContainer? = null + private var _combinedInventory3: CombinedContainer? = null + + val wrappedInventory: IMatteryContainer = object : IMatteryContainer, IContainer by DynamicallyProxiedContainer(ply::getInventory) { + override fun getSlotFilter(slot: Int): Item? { + return regularSlotFilters.getOrNull(slot)?.get() + } + + override fun setSlotFilter(slot: Int, filter: Item?): Boolean { + regularSlotFilters.getOrNull(slot)?.accept(filter) + return true + } + + override fun setChanged(slot: Int) { + ply.inventory.setChanged() + } + } + + val wrappedItemInventory: IMatteryContainer = object : IMatteryContainer by wrappedInventory { + override fun getContainerSize(): Int { + return 36 + } + } val combinedInventory: CombinedContainer get() { if (_combinedInventory == null) - _combinedInventory = CombinedContainer(ply.inventory, exopackContainer) + _combinedInventory = CombinedContainer(wrappedInventory, exopackContainer) return _combinedInventory!! } + val inventoryAndExopack: CombinedContainer + get() { + if (_combinedInventory2 == null) + _combinedInventory2 = CombinedContainer(wrappedItemInventory, exopackContainer) + + return _combinedInventory2!! + } + + val inventoryAndExopackNoHotbar: CombinedContainer + get() { + if (_combinedInventory3 == null) + _combinedInventory3 = CombinedContainer.Builder().add(wrappedItemInventory, 9 .. 35).add(exopackContainer).build() + + return _combinedInventory3!! + } + /** * Whenever Exopack has 3x3 crafting grid upgrade installed */ @@ -914,14 +952,8 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } } - tag["regularSlotChargeFlag"] = ListTag().also { - for (flag in regularSlotChargeFlag) { - it.add(ByteTag.valueOf(flag.boolean)) - } - } - - tag["exoPackSlotsChargeFlag"] = ListTag().also { - for (value in exoPackSlotsChargeFlag) { + tag["slotsChargeFlag"] = ListTag().also { + for (value in slotsChargeFlag) { it.add(IntTag.valueOf(value)) } } @@ -945,12 +977,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial filter.value = null } - for (flag in regularSlotChargeFlag) { - flag.boolean = false - } - - exoPackSlotsChargeFlag.clear() - + slotsChargeFlag.clear() slotChargeToDefault() val regularSlotFilters = tag.getStringList("regularSlotFilters") @@ -961,14 +988,8 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial this.regularSlotFilters[i].value = ForgeRegistries.ITEMS.getValue(ResourceLocation.tryParse(path) ?: continue) ?: Items.AIR } - val regularSlotChargeFlag = tag.getByteList("regularSlotChargeFlag") - - for (i in 0 until regularSlotChargeFlag.size.coerceAtMost(this.regularSlotChargeFlag.size)) { - this.regularSlotChargeFlag[i].boolean = regularSlotChargeFlag[i].asInt > 0 - } - - for (v in tag.getIntList("exoPackSlotsChargeFlag")) { - this.exoPackSlotsChargeFlag.add(v.asInt) + for (v in tag.getIntList("slotsChargeFlag")) { + this.slotsChargeFlag.add(v.asInt) } // iterations @@ -1128,25 +1149,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } if (available.isPositive) { - for ((i, flag) in regularSlotChargeFlag.withIndex()) { - if (flag.boolean) { - val item = ply.inventory[i] - - if (item.isNotEmpty) { - item.energy?.let { - available -= exopackEnergy.extractEnergy(it.receiveEnergy(available, false), false) - } - - if (!available.isPositive) break - } - } - } - } - - if (available.isPositive) { - for (slot in exoPackSlotsChargeFlag) { - if (slot in 0 until exopackContainer.containerSize) { - val item = exopackContainer[slot] + for (slot in slotsChargeFlag) { + if (slot in 0 until combinedInventory.containerSize) { + val item = combinedInventory[slot] if (item.isNotEmpty) { item.energy?.let { @@ -1364,127 +1369,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial * This re-implement [Inventory.add] logic (original method is redirected to this) */ fun inventoryAddImpl(stack: ItemStack): Boolean { - val items = ply.inventory.items - val exoPackContainer = exopackContainer - - if (!stack.isStackable) { - // двигаем в отфильтрованные слоты - for (i in items.indices) { - if (items[i].isEmpty && regularSlotFilters[i].value === stack.item) { - items[i] = stack.copy() - items[i].popTime = 5 - stack.count = 0 - return true - } - } - - for (i in 0 until exoPackContainer.containerSize) { - if (exoPackContainer[i].isEmpty && exoPackContainer.hasSlotFilter(i) && exoPackContainer.testSlotFilter(i, stack)) { - exoPackContainer[i] = stack.copy() - exoPackContainer[i].popTime = 5 - stack.count = 0 - return true - } - } - - // двигаем в обычные слоты - for (i in items.indices) { - if (items[i].isEmpty && regularSlotFilters[i].value === null) { - items[i] = stack.copy() - items[i].popTime = 5 - stack.count = 0 - return true - } - } - - for (i in 0 until exoPackContainer.containerSize) { - if (exoPackContainer[i].isEmpty && !exoPackContainer.hasSlotFilter(i)) { - exoPackContainer[i] = stack.copy() - exoPackContainer[i].popTime = 5 - stack.count = 0 - return true - } - } - - MinecraftForge.EVENT_BUS.post(ItemStackLeftoverEvent(stack, this)) - - if (ply.abilities.instabuild) { - stack.count = 0 - } - - return stack.isEmpty - } - - // двигаем в существующие слоты - items[ply.inventory.selected].also { stackStacks(it, stack) } - if (stack.isEmpty) return true - ply.inventory.offhand[0].also { stackStacks(it, stack) } - if (stack.isEmpty) return true - - for (i in items.indices) { - if (stackStacks(items[i], stack) && stack.isEmpty) { - return true - } - } - - for (i in 0 until exoPackContainer.containerSize) { - if (stackStacks(exoPackContainer[i], stack)) { - exoPackContainer.setChanged(i) - - if (stack.isEmpty) { - return true - } - } - } - - // двигаем в пустые слоты - - // двигаем в отфильтрованные слоты - for (i in items.indices) { - if (items[i].isEmpty && regularSlotFilters[i].value === stack.item) { - items[i] = stack.split(stack.count.coerceAtMost(stack.maxStackSize)) - items[i].popTime = 5 - - if (stack.isEmpty) { - return true - } - } - } - - for (i in 0 until exoPackContainer.containerSize) { - if (exoPackContainer[i].isEmpty && exoPackContainer.hasSlotFilter(i) && exoPackContainer.testSlotFilter(i, stack)) { - exoPackContainer[i] = stack.split(stack.count.coerceAtMost(stack.maxStackSize)) - exoPackContainer[i].popTime = 5 - - if (stack.isEmpty) { - return true - } - } - } - - // двигаем в обычные слоты - for (i in items.indices) { - if (items[i].isEmpty && regularSlotFilters[i].value === null) { - items[i] = stack.split(stack.count.coerceAtMost(stack.maxStackSize)) - items[i].popTime = 5 - - if (stack.isEmpty) { - return true - } - } - } - - for (i in 0 until exoPackContainer.containerSize) { - if (exoPackContainer[i].isEmpty && !exoPackContainer.hasSlotFilter(i)) { - exoPackContainer[i] = stack.split(stack.count.coerceAtMost(stack.maxStackSize)) - exoPackContainer[i].popTime = 5 - - if (stack.isEmpty) { - return true - } - } - } - + inventoryAndExopack.consumeItem(stack, false, popTime = 5) MinecraftForge.EVENT_BUS.post(ItemStackLeftoverEvent(stack, this)) if (ply.abilities.instabuild) { @@ -1587,25 +1472,6 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial ) } - private fun stackStacks(it: ItemStack, stack: ItemStack): Boolean { - if ( - !it.isEmpty && - it.maxStackSize > it.count && - it.isStackable && - ItemStack.isSameItemSameTags(it, stack) - ) { - val new = (it.count + stack.count).coerceAtMost(it.maxStackSize) - val diff = new - it.count - it.count = new - stack.count -= diff - it.popTime = 5 - - return true - } - - return false - } - init { WitherBoss.TARGETING_CONDITIONS.selector(WitherBoss.TARGETING_CONDITIONS.selector!!.and { it.matteryPlayer?.isAndroid != true }) WitherBoss.LIVING_ENTITY_SELECTOR = WitherBoss.LIVING_ENTITY_SELECTOR.and { it.matteryPlayer?.isAndroid != true } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt index 10cdb96b9..ae7c9b1de 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt @@ -85,11 +85,11 @@ private fun inventoryLogic(event: ScreenEvent.Init.Post) { val screen = if (eventScreen is AbstractContainerScreen<*> && (eventScreen.menu is InventoryMenu || eventScreen.isCosmeticArmorScreen)) eventScreen else return val widget = Panel2Widget(LargeRectangleButtonPanel(screen, null, - x = screen.guiLeft + screen.xSize - 2f - LargeRectangleButtonPanel.SIZE, - y = screen.guiTop.toFloat() - LargeRectangleButtonPanel.SIZE - 2, - skinElement = Widgets18.RETURN_ARROW_LEFT, - skinElementWinding = UVWindingOrder.FLOP, - onPress = { + x = screen.guiLeft + screen.xSize - 2f - LargeRectangleButtonPanel.SIZE, + y = screen.guiTop.toFloat() - LargeRectangleButtonPanel.SIZE - 2, + icon = Widgets18.RETURN_ARROW_LEFT, + iconWinding = UVWindingOrder.FLOP, + onPress = { shouldOpenVanillaInventory = false val mouseX = minecraft.mouseHandler.xpos() val mouseY = minecraft.mouseHandler.ypos() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt index 9da40a685..7929fc86c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt @@ -6,7 +6,7 @@ import ru.dbotthepony.mc.otm.client.render.sprites.MatteryAtlas object WidgetLocation { val LARGE_BUTTON = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/large_button.png"), 72f, 18f) - val STORAGE_CONTROLS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/storage_controls.png"), 90f, 54f) + val STORAGE_CONTROLS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/storage_controls.png"), 90f, 72f) val MISC_18 = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/misc18.png"), 72f, 72f) val SLOT_BACKGROUNDS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/slot_backgrounds.png"), 72f, 72f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt index d25039af3..60849bf3a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt @@ -37,7 +37,7 @@ object Widgets18 { val BUTTON_DISABLED_STRETCHABLE = makeButton(buttonGrids) val BUTTON_DISABLED = buttonGrids.next() - private val storageGrid = WidgetLocation.STORAGE_CONTROLS.grid(rows = 3, columns = 5) + private val storageGrid = WidgetLocation.STORAGE_CONTROLS.grid(rows = 4, columns = 5) val ARROW_DOWN = storageGrid.next() val ARROW_UP = storageGrid.next() val SORT_DEFAULT = storageGrid.next() @@ -53,6 +53,7 @@ object Widgets18 { val PAUSE = storageGrid.next() val PLAY = storageGrid.next() val STOP = storageGrid.next() + val SORT_NOW = storageGrid.next() private val miscGrid = WidgetLocation.MISC_18.grid(4, 4) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt index 2dad7fb4e..5a43c252d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt @@ -10,6 +10,7 @@ import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.render.sprites.sprite 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.button.LargeRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.InventorySlotPanel @@ -243,7 +244,7 @@ class ExopackInventoryScreen(menu: ExopackInventoryMenu) : MatteryScreen + val controls = DeviceControls(this, frame) + + controls.dockTop = 85f + + controls.addButton(makeInventoryRowsControls(frame) { movePixels -> frame.y += movePixels moveMousePosScaled(y = movePixels) + } as EditablePanel) + + + if (menu.sortInventoryInput != null) { + controls.addButton(LargeRectangleButtonPanel.input( + this, + controls, + menu.sortInventoryInput!!, + icon = Widgets18.SORT_NOW + ).also { it.tooltips.add(TranslatableComponent("otm.gui.sorting.sort_now")) }) } var x = -4f 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 a3803ee63..df07050f1 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,8 @@ import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.render.translation 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.button.LargeRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.InventorySlotPanel @@ -157,7 +159,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit inventoryScrollbar.scroll = inventoryScrollbar.scroll } - protected fun makeInventoryRowsControls(parent: EditablePanel<*>, x: Float, y: Float, callback: (Float) -> Unit): HeightControls<*> { + protected fun makeInventoryRowsControls(parent: EditablePanel<*>, x: Float = 0f, y: Float = 0f, callback: (Float) -> Unit): HeightControls> { return HeightControls(this, parent, x, y) { inventoryRows += if (it) 1 else -1 callback.invoke(if (it) -AbstractSlotPanel.SIZE / 2f else AbstractSlotPanel.SIZE / 2f) @@ -206,13 +208,17 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit init { if (menu.playerInventorySlots.isNotEmpty() && menu.autoCreateInventoryFrame) { - if (menu.playerExoSuitSlots.isEmpty()) { + val deviceControls: DeviceControls> + + if (menu.playerCombinedInventorySlots.size <= 27) { inventoryFrame = FramePanel>(this, null, 0f, 0f, INVENTORY_FRAME_WIDTH, INVENTORY_FRAME_HEIGHT, inventory.displayName).also(this::addPanel) inventoryFrame!!.makeHelpButton().addSlotFiltersHelp().also { if (menu.player.matteryPlayer?.hasExopack == true) it.tooltips.add(TranslatableComponent("otm.gui.help.slot_charging")) } + deviceControls = DeviceControls(this, inventoryFrame!!) + val hotbarStrip = EditablePanel(this, inventoryFrame, height = AbstractSlotPanel.SIZE) hotbarStrip.dock = Dock.BOTTOM @@ -240,6 +246,8 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit it.tooltips.add(TranslatableComponent("otm.gui.help.slot_charging")) } + deviceControls = DeviceControls(this, inventoryFrame!!) + inventoryScrollbar = DiscreteScrollBarPanel(this, inventoryFrame, { integerDivisionDown(menu.playerCombinedInventorySlots.size, 9) }, { _, old, new -> @@ -292,11 +300,20 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } } - makeInventoryRowsControls(inventoryFrame!!, inventoryFrame!!.width + 2f, 0f) { movePixels -> + deviceControls.addButton(makeInventoryRowsControls(inventoryFrame!!) { movePixels -> mainFrame?.let { it.y += movePixels } inventoryFrame?.let { it.y += movePixels } moveMousePosScaled(y = movePixels) - } + }) + } + + if (menu.sortInventoryInput != null) { + deviceControls.addButton(LargeRectangleButtonPanel.input( + this, + deviceControls, + menu.sortInventoryInput!!, + icon = Widgets18.SORT_NOW + ).also { it.tooltips.add(TranslatableComponent("otm.gui.sorting.sort_now")) }) } if (menu.exopackChargeSlots.isNotEmpty()) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt index 6aeaa70e4..99d4e560d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt @@ -2,11 +2,15 @@ package ru.dbotthepony.mc.otm.client.screen.decorative import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.DeviceControls +import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.UserFilteredSlotPanel +import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.menu.decorative.CargoCrateMenu class CargoCrateScreen(menu: CargoCrateMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { @@ -22,6 +26,10 @@ class CargoCrateScreen(menu: CargoCrateMenu, inventory: Inventory, title: Compon for (slot in menu.storageSlots) UserFilteredSlotPanel.of(this, grid, slot) + val controls = DeviceControls(this, frame) + + controls.addButton(LargeRectangleButtonPanel.input(this, frame, menu.sort, icon = Widgets18.SORT_NOW).also { it.tooltips.add(TranslatableComponent("otm.gui.sorting.sort_now")) }) + return frame } } 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 8ef2980bd..11e2820ea 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 @@ -110,7 +110,7 @@ class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : buttons.clear() for (recipe in menu.possibleRecipes) { - object : LargeRectangleButtonPanel(this@PainterScreen, canvas.canvas, skinElement = ItemStackIcon(recipe.output, 14f, 14f).fixed()) { + object : LargeRectangleButtonPanel(this@PainterScreen, canvas.canvas, icon = ItemStackIcon(recipe.output, 14f, 14f).fixed()) { init { buttons.add(this) dockRight = 1f 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 89829584b..b4b4a2127 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 @@ -77,7 +77,7 @@ class MatterPanelScreen( LargeRectangleButtonPanel( this, frame, - skinElement = Widgets18.STOP, + icon = Widgets18.STOP, onPress = { frame.queryUser( TranslatableComponent("otm.gui.matter_panel.cancel_all"), 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 08a59178e..853c876a1 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 @@ -386,7 +386,7 @@ class DeviceControls>( if (upgrades != null) { upgradesButton = addButton(object : LargeRectangleButtonPanel( screen, this@DeviceControls, - skinElement = Widgets18.UPGRADES + icon = Widgets18.UPGRADES ) { init { tooltips.add(TranslatableComponent("otm.gui.upgrades")) @@ -473,7 +473,7 @@ class DeviceControls>( } if (itemConfig != null) { - itemConfigButton = addButton(object : LargeRectangleButtonPanel(screen, this@DeviceControls, skinElement = Widgets18.ITEMS_CONFIGURATION) { + itemConfigButton = addButton(object : LargeRectangleButtonPanel(screen, this@DeviceControls, icon = Widgets18.ITEMS_CONFIGURATION) { init { tooltips.add(TranslatableComponent("otm.gui.sides.item_config")) } @@ -492,7 +492,7 @@ class DeviceControls>( } if (energyConfig != null) { - energyConfigButton = addButton(object : LargeRectangleButtonPanel(screen, this@DeviceControls, y = nextY, skinElement = Widgets18.ENERGY_CONFIGURATION) { + energyConfigButton = addButton(object : LargeRectangleButtonPanel(screen, this@DeviceControls, y = nextY, icon = Widgets18.ENERGY_CONFIGURATION) { init { tooltips.add(TranslatableComponent("otm.gui.sides.energy_config")) } @@ -511,7 +511,7 @@ class DeviceControls>( } if (fluidConfig != null) { - fluidConfigButton = addButton(object : LargeRectangleButtonPanel(screen, this@DeviceControls, y = nextY, skinElement = Widgets18.FLUID_CONFIGURATION) { + fluidConfigButton = addButton(object : LargeRectangleButtonPanel(screen, this@DeviceControls, y = nextY, icon = Widgets18.FLUID_CONFIGURATION) { init { tooltips.add(TranslatableComponent("otm.gui.sides.fluid_config")) } @@ -530,10 +530,28 @@ class DeviceControls>( } } + override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + x = (parent?.width ?: 0f) + 3f + y = dockTop + } + override fun tickInner() { super.tickInner() x = (parent?.width ?: 0f) + 3f - y = 0f + y = dockTop + } + + // не съедаем ввод мыши + override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { + return false + } + + override fun mouseReleasedInner(x: Double, y: Double, button: Int): Boolean { + return false + } + + override fun mouseDraggedInner(x: Double, y: Double, button: Int, xDelta: Double, yDelta: Double): Boolean { + return false } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt index 20d14a49f..5c1e22d90 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt @@ -2,10 +2,12 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.menu.MatteryMenu open class LargeRectangleButtonPanel( screen: S, @@ -15,8 +17,8 @@ open class LargeRectangleButtonPanel( width: Float = SIZE, height: Float = SIZE, onPress: ((clickButton: Int) -> Unit)? = null, - var skinElement: IGUIRenderable? = null, - var skinElementWinding: UVWindingOrder? = null, + var icon: IGUIRenderable? = null, + var iconWinding: UVWindingOrder? = null, ) : RectangleButtonPanel(screen, parent, x, y, width, height, onPress) { final override val IDLE = Widgets18.BUTTON_IDLE final override val HOVERED = Widgets18.BUTTON_HOVERED @@ -26,14 +28,36 @@ open class LargeRectangleButtonPanel( override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { super.innerRender(graphics, mouseX, mouseY, partialTick) - if (skinElementWinding != null) { - skinElement?.render(graphics, width = width, height = height, winding = skinElementWinding!!) + if (iconWinding != null) { + icon?.render(graphics, width = width, height = height, winding = iconWinding!!) } else { - skinElement?.render(graphics, width = width, height = height) + icon?.render(graphics, width = width, height = height) } } companion object { const val SIZE = 18f + + fun input( + screen: S, + parent: EditablePanel<*>?, + input: MatteryMenu.PlayerInput, + x: Float = 0f, + y: Float = 0f, + width: Float = SIZE, + height: Float = SIZE, + icon: IGUIRenderable? = null, + iconWinding: UVWindingOrder? = null, + ): LargeRectangleButtonPanel { + return object : LargeRectangleButtonPanel(screen, parent, x, y, width, height, null, icon, iconWinding) { + override fun onClick(mouseButton: Int) { + input.accept(null) + } + + override var isDisabled: Boolean + get() = !input.test(minecraft.player) + set(value) {} + } + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt index b7d3b7a2e..1fe7a1f46 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt @@ -93,7 +93,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title outputs.dockResize = DockResizeMode.NONE outputs.dockMargin = DockProperty(bottom = 3f) - object : LargeRectangleButtonPanel(this@EssenceStorageScreen, inputs, skinElement = STORE_1) { + object : LargeRectangleButtonPanel(this@EssenceStorageScreen, inputs, icon = STORE_1) { init { dockRight = 3f tooltips.add(TranslatableComponent("otm.gui.experience.store", 1)) @@ -108,7 +108,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title set(value) {} } - object : LargeRectangleButtonPanel(this@EssenceStorageScreen, inputs, skinElement = STORE_10) { + object : LargeRectangleButtonPanel(this@EssenceStorageScreen, inputs, icon = STORE_10) { init { dockRight = 3f tooltips.add(TranslatableComponent("otm.gui.experience.store", 10)) @@ -123,7 +123,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title set(value) {} } - object : LargeRectangleButtonPanel(this@EssenceStorageScreen, inputs, skinElement = STORE_ALL) { + object : LargeRectangleButtonPanel(this@EssenceStorageScreen, inputs, icon = STORE_ALL) { init { dockRight = 3f tooltips.add(TranslatableComponent("otm.gui.experience.store_all")) @@ -138,7 +138,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title set(value) {} } - object : LargeRectangleButtonPanel(this@EssenceStorageScreen, outputs, skinElement = DISPENSE_1) { + object : LargeRectangleButtonPanel(this@EssenceStorageScreen, outputs, icon = DISPENSE_1) { init { dockRight = 3f tooltips.add(TranslatableComponent("otm.gui.experience.dispense", 1)) @@ -153,7 +153,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title set(value) {} } - object : LargeRectangleButtonPanel(this@EssenceStorageScreen, outputs, skinElement = DISPENSE_10) { + object : LargeRectangleButtonPanel(this@EssenceStorageScreen, outputs, icon = DISPENSE_10) { init { dockRight = 3f tooltips.add(TranslatableComponent("otm.gui.experience.dispense", 10)) @@ -168,7 +168,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title set(value) {} } - object : LargeRectangleButtonPanel(this@EssenceStorageScreen, outputs, skinElement = DISPENSE_ALL) { + object : LargeRectangleButtonPanel(this@EssenceStorageScreen, outputs, icon = DISPENSE_ALL) { init { dockRight = 3f tooltips.add(TranslatableComponent("otm.gui.experience.dispense_all")) @@ -186,7 +186,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title val customBar = HorizontalStripPanel(this, frame, height = 18f) customBar.dock = Dock.TOP - object : LargeRectangleButtonPanel(this@EssenceStorageScreen, customBar, skinElement = STORE_CUSTOM) { + object : LargeRectangleButtonPanel(this@EssenceStorageScreen, customBar, icon = STORE_CUSTOM) { init { tooltips.add(TranslatableComponent("otm.gui.experience.store", customDispense)) } @@ -227,7 +227,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title } } - object : LargeRectangleButtonPanel(this@EssenceStorageScreen, customBar, skinElement = DISPENSE_CUSTOM) { + object : LargeRectangleButtonPanel(this@EssenceStorageScreen, customBar, icon = DISPENSE_CUSTOM) { init { tooltips.add(TranslatableComponent("otm.gui.experience.dispense", customDispense)) } @@ -241,7 +241,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title set(value) {} } - object : LargeRectangleButtonPanel(this@EssenceStorageScreen, customBar, skinElement = SET_EXACT) { + object : LargeRectangleButtonPanel(this@EssenceStorageScreen, customBar, icon = SET_EXACT) { init { tooltips.add(TranslatableComponent("otm.gui.experience.set_exact", customDispense)) dock = Dock.RIGHT diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/CombinedContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/CombinedContainer.kt index 39f3ae231..36e2aa9d8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/CombinedContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/CombinedContainer.kt @@ -4,17 +4,18 @@ import com.google.common.collect.ImmutableList import com.google.common.collect.ImmutableMap import com.google.common.collect.ImmutableSet import it.unimi.dsi.fastutil.ints.IntAVLTreeSet +import it.unimi.dsi.fastutil.ints.IntArrayList import it.unimi.dsi.fastutil.ints.IntSet import it.unimi.dsi.fastutil.objects.Object2ObjectFunction import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import net.minecraft.world.Container import net.minecraft.world.entity.player.Player +import net.minecraft.world.inventory.Slot +import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack -import ru.dbotthepony.mc.otm.container.util.ContainerSlot import ru.dbotthepony.mc.otm.container.util.IContainerSlot -import ru.dbotthepony.mc.otm.container.util.IIterableContainer +import ru.dbotthepony.mc.otm.container.util.containerSlot import ru.dbotthepony.mc.otm.container.util.iterator -import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.collect.concatIterators import ru.dbotthepony.mc.otm.core.collect.filter import ru.dbotthepony.mc.otm.core.collect.flatMap @@ -24,21 +25,34 @@ import ru.dbotthepony.mc.otm.core.stream import java.util.LinkedList import java.util.stream.Stream -class CombinedContainer(containers: Stream>>) : Container, IIterableContainer { - constructor(vararg containers: Container) : this(containers.stream().map { it to (0 until it.containerSize).iterator() }) - constructor(containers: Collection) : this(containers.stream().map { it to (0 until it.containerSize).iterator() }) +class CombinedContainer(containers: Stream>>) : IMatteryContainer { + constructor(vararg containers: Container) : this(containers.stream().map { it to (0 until it.containerSize) }) + constructor(containers: Collection) : this(containers.stream().map { it to (0 until it.containerSize) }) - private val slots: List - private val slotsMap: Map> + private inner class Slot(override val slot: Int, val outer: IContainerSlot) : IContainerSlot by outer { + override val container: Container + get() = this@CombinedContainer + + override fun component1(): Int { + return super.component1() + } + + override fun component2(): ItemStack { + return super.component2() + } + } + + private val slots: List + private val slotsMap: Map> private val containers: Set private val fullCoverage: List - private val notFullCoverage: Map> + private val notFullCoverage: Map> init { - val list = ImmutableList.Builder() + val list = ImmutableList.Builder() var i = 0 val validationMap = Reference2ObjectOpenHashMap() - val slotsMap = Reference2ObjectOpenHashMap>() + val slotsMap = Reference2ObjectOpenHashMap>() for ((container, slots) in containers) { val validator = validationMap.computeIfAbsent(container, Object2ObjectFunction { IntAVLTreeSet() }) @@ -46,9 +60,8 @@ class CombinedContainer(containers: Stream>>) : Co for (slot in slots) { if (validator.add(slot)) { - i++ - val slotObj = ContainerSlot(slot, container) - list.add(slotObj) + val slotObj = container.containerSlot(slot) + list.add(Slot(i++, slotObj)) slotList.add(slotObj) } else { throw IllegalArgumentException("Duplicate mapping for $container at $i for slot $slot") @@ -107,27 +120,23 @@ class CombinedContainer(containers: Stream>>) : Co return true } - fun slotAt(index: Int): ContainerSlot { - return slots[index] - } - - override fun getItem(index: Int): ItemStack { + override fun getItem(slot: Int): ItemStack { // do not violate contract of getItem not throwing exceptions when index is invalid - return slots.getOrNull(index)?.item ?: ItemStack.EMPTY + return slots.getOrNull(slot)?.item ?: ItemStack.EMPTY } - override fun removeItem(index: Int, count: Int): ItemStack { - val data = slots.getOrNull(index) ?: return ItemStack.EMPTY - return data.container.removeItem(data.slot, count) + override fun removeItem(slot: Int, amount: Int): ItemStack { + val data = slots.getOrNull(slot) ?: return ItemStack.EMPTY + return data.outer.container.removeItem(data.outer.slot, amount) } - override fun removeItemNoUpdate(index: Int): ItemStack { - val data = slots.getOrNull(index) ?: return ItemStack.EMPTY - return data.container.removeItemNoUpdate(data.slot) + override fun removeItemNoUpdate(slot: Int): ItemStack { + val data = slots.getOrNull(slot) ?: return ItemStack.EMPTY + return data.outer.container.removeItemNoUpdate(data.outer.slot) } - override fun setItem(index: Int, value: ItemStack) { - slots.getOrNull(index)?.item = value + override fun setItem(slot: Int, itemStack: ItemStack) { + slots.getOrNull(slot)?.item = itemStack } override fun setChanged() { @@ -136,16 +145,6 @@ class CombinedContainer(containers: Stream>>) : Co } } - fun setChanged(index: Int) { - val data = slots.getOrNull(index) ?: return - - if (data.container is MatteryContainer) { - data.container.setChanged(data.slot) - } else { - data.container.setChanged() - } - } - override fun stillValid(player: Player): Boolean { for (container in containers) if (!container.stillValid(player)) @@ -168,33 +167,64 @@ class CombinedContainer(containers: Stream>>) : Co return slots.iterator() } + override fun containerSlot(slot: Int): IContainerSlot { + return slots[slot] + } + + override fun getSlotFilter(slot: Int): Item? { + return slots[slot].getFilter() + } + + override fun setChanged(slot: Int) { + slots[slot].setChanged() + } + + override fun setSlotFilter(slot: Int, filter: Item?): Boolean { + return slots[slot].setFilter(filter) + } + class Builder { - private var built = false - private val values = LinkedList>>() + private val values = ArrayList>>() fun add(container: Container): Builder { - check(!built) { "Already built!" } - values.add(container to (0 until container.containerSize).iterator()) + values.add(container to container.slotRange) return this } fun add(container: Container, slots: Iterator): Builder { - check(!built) { "Already built!" } - values.add(container to slots) + values.add(container to IntArrayList(slots)) + return this + } + + fun add(container: Container, slot: Int): Builder { + values.add(container to intArrayOf(slot).asIterable()) + return this + } + + fun add(container: Container, from: Int, to: Int): Builder { + values.add(container to (from .. to)) return this } fun add(container: Container, slots: Iterable): Builder { - check(!built) { "Already built!" } - values.add(container to slots.iterator()) + values.add(container to slots) return this } fun build(): CombinedContainer { - check(!built) { "Already built!" } - val value = CombinedContainer(values.stream()) - values.clear() - return value + return CombinedContainer(values.stream()) + } + } + + companion object { + fun fromMenuSlots(slots: Iterator): CombinedContainer { + val builder = Builder() + + for (slot in slots) { + builder.add(slot.container, slot.slotIndex) + } + + return builder.build() } } } 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 25fe04cda..eefa76b79 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHandler.kt @@ -3,8 +3,8 @@ package ru.dbotthepony.mc.otm.container import net.minecraft.world.item.ItemStack import net.minecraftforge.items.IItemHandler -class ContainerHandler @JvmOverloads internal constructor( - private val container: MatteryContainer, +class ContainerHandler( + private val container: IMatteryContainer, private val filter: HandlerFilter = HandlerFilter.Both, ) : IItemHandler { override fun getSlots() = container.containerSize 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 14d286ec9..9a2a0e79e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHelpers.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHelpers.kt @@ -3,6 +3,8 @@ package ru.dbotthepony.mc.otm.container import it.unimi.dsi.fastutil.ints.IntAVLTreeSet import it.unimi.dsi.fastutil.ints.IntArrayList import it.unimi.dsi.fastutil.ints.IntArraySet +import it.unimi.dsi.fastutil.ints.IntIterable +import it.unimi.dsi.fastutil.ints.IntIterator import it.unimi.dsi.fastutil.ints.IntSet import it.unimi.dsi.fastutil.objects.Object2ObjectFunction import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap @@ -11,10 +13,14 @@ import net.minecraft.world.inventory.CraftingContainer import net.minecraft.world.item.ItemStack import net.minecraft.world.item.enchantment.EnchantmentHelper.hasVanishingCurse import net.minecraftforge.fluids.capability.IFluidHandler +import ru.dbotthepony.mc.otm.container.util.IContainerSlot import ru.dbotthepony.mc.otm.container.util.ItemStackHashStrategy 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.isNotEmpty +import ru.dbotthepony.mc.otm.core.map import ru.dbotthepony.mc.otm.core.util.ItemStackSorter import kotlin.math.roundToInt @@ -27,13 +33,30 @@ inline operator fun Container.get(index: Int): ItemStack = getItem(index) @Suppress("nothing_to_inline") inline operator fun IFluidHandler.get(index: Int) = getFluidInTank(index) -fun Container.addItem(stack: ItemStack, range: IntRange, simulate: Boolean = false): ItemStack { - if (this is MatteryContainer) { - return this.addItem(stack, range, simulate) - } +val Container.slotRange: IntIterable get() { + return IntIterable { + val i = (0 until containerSize).iterator() - if (range.last >= containerSize || range.first < 0) - throw IllegalArgumentException("Invalid range: $range") + object : IntIterator { + override fun hasNext(): Boolean { + return i.hasNext() + } + + override fun remove() { + throw UnsupportedOperationException() + } + + override fun nextInt(): Int { + return i.nextInt() + } + } + } +} + +fun Container.addItem(stack: ItemStack, simulate: Boolean, slots: IntIterable = slotRange): ItemStack { + if (this is IMatteryContainer) { + return this.addItem(stack, simulate, slots) + } if (stack.isEmpty) return stack @@ -41,7 +64,11 @@ fun Container.addItem(stack: ItemStack, range: IntRange, simulate: Boolean = fal val copy = stack.copy() // двигаем в одинаковые слоты - for (slot in range) { + var i = slots.intIterator() + + while (i.hasNext()) { + val slot = i.nextInt() + if (ItemStack.isSameItemSameTags(this[slot], copy)) { val slotStack = this[slot] val slotLimit = maxStackSize.coerceAtMost(slotStack.maxStackSize) @@ -65,7 +92,11 @@ fun Container.addItem(stack: ItemStack, range: IntRange, simulate: Boolean = fal } // двигаем в пустые слоты - for (slot in range) { + i = slots.intIterator() + + while (i.hasNext()) { + val slot = i.nextInt() + if (this[slot].isEmpty) { val diff = copy.count.coerceAtMost(maxStackSize.coerceAtMost(copy.maxStackSize)) @@ -87,8 +118,6 @@ fun Container.addItem(stack: ItemStack, range: IntRange, simulate: Boolean = fal return copy } -fun Container.addItem(stack: ItemStack, simulate: Boolean): ItemStack = addItem(stack, 0 until containerSize, simulate) - fun Container.vanishCursedItems() { for (slot in slotIterator()) { if (hasVanishingCurse(slot.item)) { @@ -258,3 +287,31 @@ operator fun CraftingContainer.get(column: Int, row: Int, flop: Boolean): ItemSt else get(column, row) } + +private object FilteredFirst : Comparator { + override fun compare(o1: IContainerSlot, o2: IContainerSlot): Int { + if (o1.hasFilter && o2.hasFilter) + return 0 + else if (o2.hasFilter) + return -1 + else if (o1.hasFilter) + return 1 + else + return 0 + } +} + +fun Container.sort(comparator: Comparator = ItemStackSorter.DEFAULT) { + if (isEmpty) + return + + val slots = slotIterator().filter { !it.isForbiddenForAutomation && it.getMaxStackSize() >= it.item.count }.toList() + + if (slots.isEmpty()) + return + + slots.sortWith(FilteredFirst.thenComparing(comparator.map(IContainerSlot::item))) + val items = slots.map { it.item.copy() } + slots.forEach { it.remove() } + items.forEach { addItem(it, false) } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/DynamicallyProxiedContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/DynamicallyProxiedContainer.kt new file mode 100644 index 000000000..b2e400392 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/DynamicallyProxiedContainer.kt @@ -0,0 +1,81 @@ +package ru.dbotthepony.mc.otm.container + +import net.minecraft.world.Container +import net.minecraft.world.entity.player.Player +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import java.util.function.Predicate +import java.util.function.Supplier + +/** + * because mods tend to do crazy shit + */ +class DynamicallyProxiedContainer(private val toProxy: Supplier) : IContainer { + override fun clearContent() { + return toProxy.get().clearContent() + } + + override fun getContainerSize(): Int { + return toProxy.get().containerSize + } + + override fun isEmpty(): Boolean { + return toProxy.get().isEmpty + } + + override fun getItem(slot: Int): ItemStack { + return toProxy.get().getItem(slot) + } + + override fun removeItem(slot: Int, amount: Int): ItemStack { + return toProxy.get().removeItem(slot, amount) + } + + override fun removeItemNoUpdate(slot: Int): ItemStack { + return toProxy.get().removeItemNoUpdate(slot) + } + + override fun setItem(slot: Int, itemStack: ItemStack) { + return toProxy.get().setItem(slot, itemStack) + } + + override fun setChanged() { + return toProxy.get().setChanged() + } + + override fun stillValid(player: Player): Boolean { + return toProxy.get().stillValid(player) + } + + override fun getMaxStackSize(): Int { + return toProxy.get().getMaxStackSize() + } + + override fun startOpen(player: Player) { + toProxy.get().startOpen(player) + } + + override fun stopOpen(player: Player) { + toProxy.get().stopOpen(player) + } + + override fun canPlaceItem(slot: Int, itemStack: ItemStack): Boolean { + return toProxy.get().canPlaceItem(slot, itemStack) + } + + override fun canTakeItem(container: Container, slot: Int, itemStack: ItemStack): Boolean { + return toProxy.get().canTakeItem(container, slot, itemStack) + } + + override fun countItem(item: Item): Int { + return toProxy.get().countItem(item) + } + + override fun hasAnyOf(items: Set): Boolean { + return toProxy.get().hasAnyOf(items) + } + + override fun hasAnyMatching(predicate: Predicate): Boolean { + return toProxy.get().hasAnyMatching(predicate) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/IContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/IContainer.kt index 71e7c696c..3afa4ab72 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/IContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/IContainer.kt @@ -7,6 +7,7 @@ import net.minecraft.world.item.ItemStack import java.util.function.Predicate // passthrough all default methods to fix Kotlin bug related to implementation delegation not properly working on Java interfaces +// and also to give params proper names // https://youtrack.jetbrains.com/issue/KT-55080/Change-the-behavior-of-inheritance-delegation-to-delegates-implementing-Java-interfaces-with-default-methods interface IContainer : Container { override fun getMaxStackSize(): Int { @@ -41,6 +42,16 @@ interface IContainer : Container { return super.hasAnyMatching(predicate) } + override fun clearContent() + override fun getContainerSize(): Int + override fun isEmpty(): Boolean + override fun getItem(slot: Int): ItemStack + override fun removeItem(slot: Int, amount: Int): ItemStack + override fun removeItemNoUpdate(slot: Int): ItemStack + override fun setItem(slot: Int, itemStack: ItemStack) + override fun setChanged() + + override fun stillValid(player: Player): Boolean companion object { fun wrap(container: Container): IContainer { if (container is IContainer) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/IMatteryContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/IMatteryContainer.kt new file mode 100644 index 000000000..b1d30a73f --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/IMatteryContainer.kt @@ -0,0 +1,217 @@ +package ru.dbotthepony.mc.otm.container + +import it.unimi.dsi.fastutil.ints.IntIterable +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.Items +import ru.dbotthepony.mc.otm.container.util.IContainerSlot +import ru.dbotthepony.mc.otm.core.collect.filter +import ru.dbotthepony.mc.otm.core.collect.map +import ru.dbotthepony.mc.otm.core.isNotEmpty + +interface IMatteryContainer : IContainer, Iterable { + fun getSlotFilter(slot: Int): Item? + + /** + * @return whenever the filter was set. Returns false only if container can't be filtered. + */ + fun setSlotFilter(slot: Int, filter: Item? = null): Boolean { + return false + } + + fun setChanged(slot: Int) + + /** + * Iterates over non-empty itemstacks of this container + */ + override fun iterator(): Iterator { + return iterator(true) + } + + /** + * Iterates non-empty slots of this container + */ + fun slotIterator(): Iterator { + return slotIterator(true) + } + + fun iterator(nonEmpty: Boolean): Iterator { + if (nonEmpty) { + return (0 until containerSize).iterator().map { this[it] }.filter { it.isNotEmpty } + } else { + return (0 until containerSize).iterator().map { this[it] } + } + } + + open class ContainerSlot(override val slot: Int, override val container: IMatteryContainer) : IContainerSlot { + override val isForbiddenForAutomation: Boolean + get() = container.isSlotForbiddenForAutomation(slot) + + override fun getFilter(): Item? { + return container.getSlotFilter(slot) + } + + override fun setFilter(filter: Item?): Boolean { + return container.setSlotFilter(slot, filter) + } + + override fun getMaxStackSize(item: ItemStack): Int { + return container.getMaxStackSize(slot, item) + } + + override fun setChanged() { + container.setChanged(slot) + } + } + + fun slotIterator(nonEmpty: Boolean): Iterator { + if (nonEmpty) { + return (0 until containerSize).iterator().filter { this[it].isNotEmpty }.map { containerSlot(it) } + } else { + return (0 until containerSize).iterator().map { containerSlot(it) } + } + } + + fun containerSlot(slot: Int): IContainerSlot { + return ContainerSlot(slot, this) + } + + fun hasSlotFilter(slot: Int) = getSlotFilter(slot) !== null + fun isSlotForbiddenForAutomation(slot: Int) = getSlotFilter(slot) === Items.AIR + + fun testSlotFilter(slot: Int, itemStack: ItemStack): Boolean { + return testSlotFilter(slot, itemStack.item) + } + + fun testSlotFilter(slot: Int, item: Item): Boolean { + if (getSlotFilter(slot) == null) { + return true + } else { + return getSlotFilter(slot) === item + } + } + + fun getMaxStackSize(slot: Int, itemStack: ItemStack) = maxStackSize.coerceAtMost(itemStack.maxStackSize) + + private fun addItem(stack: ItemStack, simulate: Boolean, filterPass: Boolean, slots: IntIterable, onlyIntoExisting: Boolean, popTime: Int?, ignoreFilters: Boolean): ItemStack { + if (stack.isEmpty) + return stack + + // двигаем в одинаковые слоты + var i = slots.intIterator() + + while (i.hasNext()) { + val slot = i.nextInt() + + if ( + (ignoreFilters || !isSlotForbiddenForAutomation(slot)) && + ItemStack.isSameItemSameTags(getItem(slot), stack) && + (ignoreFilters || !filterPass && !hasSlotFilter(slot) || filterPass && hasSlotFilter(slot) && testSlotFilter(slot, stack)) + ) { + val slotStack = getItem(slot) + val slotLimit = getMaxStackSize(slot, slotStack) + + if (slotStack.count < slotLimit) { + val newCount = (slotStack.count + stack.count).coerceAtMost(slotLimit) + val diff = newCount - slotStack.count + + if (!simulate) { + slotStack.count = newCount + setChanged(slot) + + if (popTime != null) { + slotStack.popTime = popTime + } + } + + stack.shrink(diff) + + if (stack.isEmpty) { + return stack + } + } + } + } + + if (!onlyIntoExisting) { + i = slots.intIterator() + + // двигаем в пустые слоты + while (i.hasNext()) { + val slot = i.nextInt() + + if ( + getItem(slot).isEmpty && + (ignoreFilters || !isSlotForbiddenForAutomation(slot)) && + (ignoreFilters || !filterPass && !hasSlotFilter(slot) || filterPass && hasSlotFilter(slot) && testSlotFilter(slot, stack)) + ) { + val diff = stack.count.coerceAtMost(getMaxStackSize(slot, stack)) + + if (!simulate) { + val copyToPut = stack.copy() + copyToPut.count = diff + setItem(slot, copyToPut) + + if (popTime != null) { + copyToPut.popTime = popTime + } + } + + stack.shrink(diff) + + if (stack.isEmpty) { + return stack + } + } + } + } + + return stack + } + + fun addItem(stack: ItemStack, simulate: Boolean, slots: IntIterable = slotRange, onlyIntoExisting: Boolean = false, popTime: Int? = null, ignoreFilters: Boolean = false): ItemStack { + if (stack.isEmpty) + return stack + + if (ignoreFilters) { + return addItem(stack.copy(), simulate, true, slots, onlyIntoExisting, popTime, true) + } else { + var copy = addItem(stack.copy(), simulate, true, slots, onlyIntoExisting, popTime, false) + copy = addItem(copy, simulate, false, slots, onlyIntoExisting, popTime, false) + return copy + } + } + + fun handler(filter: HandlerFilter = HandlerFilter.Both): ContainerHandler { + return ContainerHandler(this, filter) + } + + /** + * Unlike [addItem], modifies original [stack] + * + * @return Whenever [stack] was modified + */ + fun consumeItem(stack: ItemStack, simulate: Boolean, slots: IntIterable = slotRange, onlyIntoExisting: Boolean = false, popTime: Int? = null, ignoreFilters: Boolean = false): Boolean { + if (stack.isEmpty) + return false + + val result = addItem(stack, simulate, slots, onlyIntoExisting, popTime, ignoreFilters) + + if (result.count != stack.count) { + if (!simulate) { + stack.count = result.count + } + + return true + } + + return false + } + + fun fullyAddItem(stack: ItemStack, slots: IntIterable = slotRange, ignoreFilters: Boolean = false): Boolean { + if (!addItem(stack, true, slots, ignoreFilters).isEmpty) + return false + + return addItem(stack, false, slots, ignoreFilters).isEmpty + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt index ea8e4f840..9061de489 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt @@ -11,7 +11,7 @@ import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.ListTag import net.minecraft.nbt.Tag import net.minecraft.resources.ResourceLocation -import kotlin.jvm.JvmOverloads +import net.minecraft.world.Container import net.minecraft.world.entity.player.Player import net.minecraft.world.entity.player.StackedContents import net.minecraft.world.inventory.StackedContentsCompatible @@ -19,9 +19,7 @@ import net.minecraft.world.item.Item import net.minecraft.world.item.Items import net.minecraftforge.common.util.INBTSerializable import net.minecraftforge.registries.ForgeRegistries -import ru.dbotthepony.mc.otm.container.util.ContainerSlot import ru.dbotthepony.mc.otm.container.util.IContainerSlot -import ru.dbotthepony.mc.otm.container.util.IIterableContainer import ru.dbotthepony.mc.otm.core.addSorted import ru.dbotthepony.mc.otm.core.collect.any import ru.dbotthepony.mc.otm.core.collect.count @@ -44,10 +42,9 @@ import java.util.function.Supplier import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.collections.ArrayList -import kotlin.collections.Iterator @Suppress("UNUSED") -open class MatteryContainer(protected val watcher: Runnable, private val size: Int) : IContainer, IIterableContainer, Iterable, INBTSerializable, StackedContentsCompatible { +open class MatteryContainer(protected val watcher: Runnable, private val size: Int) : IMatteryContainer, INBTSerializable, StackedContentsCompatible { constructor(size: Int) : this({}, size) init { @@ -134,7 +131,7 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I return field } - fun setSlotFilter(slot: Int, filter: Item? = null) { + final override fun setSlotFilter(slot: Int, filter: Item?): Boolean { if (filters[slot] !== filter) { filters[slot] = filter @@ -146,17 +143,19 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I } } } + + return true } - fun getSlotFilter(slot: Int) = filters[slot] - fun hasSlotFilter(slot: Int) = filters[slot] !== null - fun isSlotForbiddenForAutomation(slot: Int) = filters[slot] === Items.AIR + final override fun getSlotFilter(slot: Int) = filters[slot] + final override fun hasSlotFilter(slot: Int) = filters[slot] !== null + final override fun isSlotForbiddenForAutomation(slot: Int) = filters[slot] === Items.AIR - fun testSlotFilter(slot: Int, itemStack: ItemStack): Boolean { + final override fun testSlotFilter(slot: Int, itemStack: ItemStack): Boolean { return testSlotFilter(slot, itemStack.item) } - fun testSlotFilter(slot: Int, item: Item): Boolean { + final override fun testSlotFilter(slot: Int, item: Item): Boolean { if (filters[slot] == null) { return true } else { @@ -283,137 +282,7 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I } } - fun hasEmptySlot(): Boolean { - for (i in 0 until size) { - if (this[i].isEmpty) { - return true - } - } - - return false - } - - fun handler(filter: HandlerFilter = HandlerFilter.Both): ContainerHandler { - return ContainerHandler(this, filter) - } - - open fun getMaxStackSize(slot: Int, itemStack: ItemStack) = maxStackSize.coerceAtMost(itemStack.maxStackSize) - - /** - * @return Leftover [ItemStack] - */ - @JvmOverloads - fun addItem(stack: ItemStack, range: IntRange, simulate: Boolean = false, onlyIntoExisting: Boolean = false, popTime: Int? = null): ItemStack { - if (range.last >= size || range.first < 0) - throw IllegalArgumentException("Invalid range: $range") - - if (stack.isEmpty) - return stack - - val copy = stack.copy() - - // двигаем в одинаковые слоты - for (slot in range) { - if (ItemStack.isSameItemSameTags(slots[slot], copy)) { - val slotStack = slots[slot] - val slotLimit = getMaxStackSize(slot, slotStack) - - if (slotStack.count < slotLimit) { - val newCount = (slotStack.count + copy.count).coerceAtMost(slotLimit) - val diff = newCount - slotStack.count - - if (!simulate) { - val old = slotStack.copy() - slotStack.count = newCount - trackedSlots[slot] = slotStack.copy() - changeset++ - internalSetChanged(slot, slotStack, old) - - if (popTime != null) { - slotStack.popTime = popTime - } - } - - copy.shrink(diff) - - if (copy.isEmpty) { - return copy - } - } - } - } - - if (!onlyIntoExisting) { - // двигаем в пустые слоты - for (slot in range) { - if (slots[slot].isEmpty) { - val diff = copy.count.coerceAtMost(getMaxStackSize(slot, copy)) - - if (!simulate) { - val copyToPut = copy.copy() - copyToPut.count = diff - slots[slot] = copyToPut - trackedSlots[slot] = copyToPut.copy() - updateEmptyFlag(slot) - changeset++ - internalSetChanged(slot, copyToPut, ItemStack.EMPTY) - - if (popTime != null) { - copyToPut.popTime = popTime - } - } - - copy.shrink(diff) - - if (copy.isEmpty) { - return copy - } - } - } - } - - return copy - } - - fun addItem(stack: ItemStack, simulate: Boolean, onlyIntoExisting: Boolean = false, popTime: Int? = null): ItemStack { - return addItem(stack, 0 until size, simulate, onlyIntoExisting = onlyIntoExisting, popTime = popTime) - } - - /** - * Unlike [addItem], modifies original [stack] - * - * @return Whenever [stack] was modified - */ - fun consumeItem(stack: ItemStack, simulate: Boolean, onlyIntoExisting: Boolean = false, popTime: Int? = null): Boolean { - if (stack.isEmpty) - return false - - val result = addItem(stack, 0 until size, simulate, onlyIntoExisting = onlyIntoExisting, popTime = popTime) - - if (result.count != stack.count) { - if (!simulate) { - stack.count = result.count - } - - return true - } - - return false - } - - @JvmOverloads - fun fullyAddItem(stack: ItemStack, start: Int = 0, end: Int = size - 1): Boolean { - return fullyAddItem(stack, start .. end) - } - - fun fullyAddItem(stack: ItemStack, range: IntRange): Boolean { - if (!addItem(stack, range, true).isEmpty) - return false - - return addItem(stack, range, false).isEmpty - } - - override fun isEmpty(): Boolean { + final override fun isEmpty(): Boolean { return nonEmptyIndices.isEmpty } @@ -484,17 +353,17 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I return old } - final override fun setItem(slot: Int, stack: ItemStack) { - if (slots[slot].isEmpty && stack.isEmpty || stack === slots[slot]) + final override fun setItem(slot: Int, itemStack: ItemStack) { + if (slots[slot].isEmpty && itemStack.isEmpty || itemStack === slots[slot]) return val old = slots[slot] - slots[slot] = if (stack.isEmpty) ItemStack.EMPTY else stack - trackedSlots[slot] = if (stack.isEmpty) ItemStack.EMPTY else stack.copy() + slots[slot] = if (itemStack.isEmpty) ItemStack.EMPTY else itemStack + trackedSlots[slot] = if (itemStack.isEmpty) ItemStack.EMPTY else itemStack.copy() updateEmptyFlag(slot) changeset++ - internalSetChanged(slot, stack, old) + internalSetChanged(slot, itemStack, old) } final override fun setChanged() { @@ -512,7 +381,7 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I } } - fun setChanged(slot: Int) { + final override fun setChanged(slot: Int) { if (!slots[slot].equals(trackedSlots[slot], false)) { trackedSlots[slot] = slots[slot].copy() updateEmptyFlag(slot) @@ -613,22 +482,50 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I } } + private inner class Slot(override val slot: Int) : IContainerSlot { + override val container: Container + get() = this@MatteryContainer + + override val isForbiddenForAutomation: Boolean + get() = isSlotForbiddenForAutomation(slot) + + override fun getFilter(): Item? { + return getSlotFilter(slot) + } + + override fun setFilter(filter: Item?): Boolean { + return setSlotFilter(slot, filter) + } + + override fun getMaxStackSize(item: ItemStack): Int { + return getMaxStackSize(slot, item) + } + + override fun setChanged() { + setChanged(slot) + } + } + final override fun slotIterator(): kotlin.collections.Iterator { indicesReferenced = true - return nonEmptyIndices.iterator().map { ContainerSlot(it, this) } + return nonEmptyIndices.iterator().map { Slot(it) } } final override fun slotIterator(nonEmpty: Boolean): kotlin.collections.Iterator { if (!nonEmpty) { - return (0 until size).iterator().map { ContainerSlot(it, this) } + return (0 until size).iterator().map { Slot(it) } } else if (isEmpty) { return emptyIterator() } else { indicesReferenced = true - return nonEmptyIndices.iterator().map { ContainerSlot(it, this) } + return nonEmptyIndices.iterator().map { Slot(it) } } } + final override fun containerSlot(slot: Int): IContainerSlot { + return Slot(slot) + } + final override fun countItem(item: Item): Int { return iterator().filter { it.item == item }.count().toInt() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/util/Iterators.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/util/Iterators.kt index 94bdfeaba..a0063258e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/util/Iterators.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/util/Iterators.kt @@ -3,6 +3,8 @@ package ru.dbotthepony.mc.otm.container.util import net.minecraft.world.Container import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.Items +import ru.dbotthepony.mc.otm.container.IMatteryContainer import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.get import ru.dbotthepony.mc.otm.container.set @@ -11,6 +13,10 @@ import ru.dbotthepony.mc.otm.core.collect.filter import ru.dbotthepony.mc.otm.core.collect.map import ru.dbotthepony.mc.otm.core.isNotEmpty +/** + * While this somewhat similar to [net.minecraft.world.inventory.Slot], this slot is not meant + * for Player interaction. + */ interface IContainerSlot : GetterSetter { val slot: Int val container: Container @@ -18,28 +24,23 @@ interface IContainerSlot : GetterSetter { operator fun component1() = slot operator fun component2() = item + fun getMaxStackSize(item: ItemStack = this.item): Int { + return container.maxStackSize + } + val isForbiddenForAutomation: Boolean get() { - val container = container - - if (container is MatteryContainer) { - return container.isSlotForbiddenForAutomation(slot) - } else { - return false - } + return getFilter() === Items.AIR } - val filter: Item? get() { - val container = container + fun getFilter(): Item? - if (container is MatteryContainer) { - return container.getSlotFilter(slot) - } else { - return null - } - } + /** + * @return whenever the filter was set. Returns false only if container can't be filtered. + */ + fun setFilter(filter: Item? = null): Boolean val hasFilter: Boolean - get() = filter != null + get() = getFilter() != null fun remove() { container[slot] = ItemStack.EMPTY @@ -54,13 +55,7 @@ interface IContainerSlot : GetterSetter { } fun setChanged() { - val container = container - - if (container is MatteryContainer) { - container.setChanged(slot) - } else { - container.setChanged() - } + container.setChanged() } var item: ItemStack @@ -78,32 +73,28 @@ class ContainerSlot(override val slot: Int, override val container: Container) : init { require(slot in 0 until container.containerSize) { "Slot out of bounds: $slot (container: $container with size ${container.containerSize})" } } + + override fun getFilter(): Item? { + return null + } + + override fun setFilter(filter: Item?): Boolean { + return false + } } -interface IIterableContainer : Iterable { - /** - * Iterates over non-empty itemstacks of this container - */ - override fun iterator(): Iterator { - return iterator(true) +fun Container.containerSlot(slot: Int): IContainerSlot { + if (this is IMatteryContainer) { + return containerSlot(slot) + } else { + return ContainerSlot(slot, this) } - - fun iterator(nonEmpty: Boolean): Iterator - - /** - * Iterates non-empty slots of this container - */ - fun slotIterator(): Iterator { - return slotIterator(true) - } - - fun slotIterator(nonEmpty: Boolean): Iterator } operator fun Container.iterator() = iterator(true) fun Container.iterator(nonEmpty: Boolean): Iterator { - if (this is IIterableContainer) { + if (this is IMatteryContainer) { return iterator(nonEmpty) } else if (nonEmpty) { return (0 until containerSize).iterator().map { this[it] }.filter { it.isNotEmpty } @@ -113,7 +104,7 @@ fun Container.iterator(nonEmpty: Boolean): Iterator { } fun Container.slotIterator(nonEmpty: Boolean = true): Iterator { - if (this is IIterableContainer) { + if (this is IMatteryContainer) { return slotIterator(nonEmpty) } else if (nonEmpty) { return (0 until containerSize).iterator().filter { this[it].isNotEmpty }.map { ContainerSlot(it, this) } 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 5e7847a5c..41d38d12a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -362,17 +362,12 @@ fun Stream.asIterable(): Iterable { } } -// Kotlin type safety: -// since Java generics are invariant, -// and can not distinguish between null and non-null type parameters -// we need to tell compiler that Comparator.nullsFirst actually has next signature: -// fun Comparator.nullsFirst(original: Comparator): Comparator -fun Comparator.nullsFirst(): Comparator { - return Comparator.nullsFirst(this as Comparator) +fun Comparator.nullsFirst(): Comparator { + return Comparator.nullsFirst(this) } -fun Comparator.nullsLast(): Comparator { - return Comparator.nullsLast(this as Comparator) +fun Comparator.nullsLast(): Comparator { + return Comparator.nullsLast(this) } class MappedComparator(private val parent: Comparator, private val mapper: (T) -> O) : Comparator { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/Iterables.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/Iterables.kt new file mode 100644 index 000000000..469b95915 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/Iterables.kt @@ -0,0 +1,24 @@ +package ru.dbotthepony.mc.otm.core.collect + +import it.unimi.dsi.fastutil.ints.IntIterable +import it.unimi.dsi.fastutil.ints.IntIterator + +fun IntRange.asIterable(): IntIterable { + return IntIterable { + val i = this@asIterable.iterator() + + object : IntIterator { + override fun hasNext(): Boolean { + return i.hasNext() + } + + override fun remove() { + throw UnsupportedOperationException() + } + + override fun nextInt(): Int { + return i.nextInt() + } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt index 42e4476f5..5377de346 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt @@ -294,8 +294,8 @@ fun Iterator.collect(collector: Collector): R { return collector.finisher().apply(instance) } -fun Iterator.toList(): MutableList { - val result = ArrayList() +fun Iterator.toList(expectedSize: Int = 16): MutableList { + val result = ArrayList(expectedSize) result.addAll(this) return result } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt index 3cf948b94..6319572f0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt @@ -19,12 +19,12 @@ import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.storage.ItemStorageStack import ru.dbotthepony.mc.otm.client.render.Widgets18 -private fun Comparator.stacks(): Comparator { - return Comparator { o1, o2 -> this@stacks.compare(o1.item, o2.item) }.nullsFirst() +private fun Comparator.stacks(): Comparator { + return Comparator { o1, o2 -> this@stacks.compare(o1.item, o2.item) } } -private fun Comparator.storage(): Comparator { - return Comparator { o1, o2 -> this@storage.compare(o1.item, o2.item) }.nullsFirst() +private fun Comparator.storage(): Comparator { + return Comparator { o1, o2 -> this@storage.compare(o1.item, o2.item) } } object CreativeMenuItemComparator : Comparator { @@ -156,7 +156,7 @@ object ItemStorageStackCountComparator : Comparator { val NullsLast = nullsLast() } -enum class ItemSorter(comparator: Comparator, private val sTitle: Component, icon: Lazy) : Comparator by comparator.nullsFirst() { +enum class ItemSorter(comparator: Comparator, private val sTitle: Component, icon: Lazy) : Comparator by comparator { DEFAULT(CreativeMenuItemComparator, TranslatableComponent("otm.gui.sorting.default"), lazy { Widgets18.SORT_DEFAULT }), NAME(ItemLocalizedNameComparator.thenComparing(CreativeMenuItemComparator), TranslatableComponent("otm.gui.sorting.name"), lazy { Widgets18.SORT_ALPHABET }), ID(ItemIDComparator.thenComparing(CreativeMenuItemComparator), TranslatableComponent("otm.gui.sorting.id"), lazy { Widgets18.SORT_ID }), @@ -167,14 +167,12 @@ enum class ItemSorter(comparator: Comparator, private val sTitle: Componen val icon: IGUIRenderable by icon val title: MutableComponent get() = sTitle.copy() - val suppliers = suppliers() - val reversed: Comparator = reversed() } -enum class ItemStackSorter(comparator: Comparator, private val sTitle: Component, icon: Lazy) : Comparator by comparator { +enum class ItemStackSorter(comparator: Comparator, private val sTitle: Component, icon: Lazy) : Comparator by comparator { DEFAULT(ItemSorter.DEFAULT.stacks(), ItemSorter.DEFAULT.title, lazy { Widgets18.SORT_DEFAULT }), - COUNT(ItemStackCountComparator.NullsFirst.thenComparing(ItemSorter.DEFAULT.stacks()), TranslatableComponent("otm.gui.sorting.count"), lazy { Widgets18.SORT_COUNT }), - NAME(ItemStackNameComparator.NullsFirst.thenComparing(ItemSorter.DEFAULT.stacks()), ItemSorter.NAME.title, lazy { Widgets18.SORT_ALPHABET }), + COUNT(ItemStackCountComparator.thenComparing(ItemSorter.DEFAULT.stacks()), TranslatableComponent("otm.gui.sorting.count"), lazy { Widgets18.SORT_COUNT }), + NAME(ItemStackNameComparator.thenComparing(ItemSorter.DEFAULT.stacks()), ItemSorter.NAME.title, lazy { Widgets18.SORT_ALPHABET }), ID(ItemSorter.ID.stacks(), ItemSorter.ID.title, lazy { Widgets18.SORT_ID }), MOD(ItemSorter.MOD.stacks(), ItemSorter.MOD.title, lazy { Widgets18.SORT_MODID }), MATTER_VALUE(ItemSorter.MATTER_VALUE.stacks(), ItemSorter.MATTER_VALUE.title, lazy { Widgets18.SORT_MATTER_VALUE }), @@ -182,14 +180,12 @@ enum class ItemStackSorter(comparator: Comparator, private val sTitl val icon: IGUIRenderable by icon val title: MutableComponent get() = sTitle.copy() - val suppliers = suppliers() - val reversed: Comparator = reversed() } -enum class ItemStorageStackSorter(comparator: Comparator, private val sTitle: Component, icon: Lazy) : Comparator by comparator { +enum class ItemStorageStackSorter(comparator: Comparator, private val sTitle: Component, icon: Lazy) : Comparator by comparator { DEFAULT(ItemSorter.DEFAULT.storage(), ItemSorter.DEFAULT.title, lazy { Widgets18.SORT_DEFAULT }), - COUNT(ItemStorageStackCountComparator.NullsFirst.thenComparing(ItemSorter.DEFAULT.storage()), TranslatableComponent("otm.gui.sorting.count"), lazy { Widgets18.SORT_COUNT }), - NAME(ItemStorageStackNameComparator.NullsFirst.thenComparing(ItemSorter.DEFAULT.storage()), ItemSorter.NAME.title, lazy { Widgets18.SORT_ALPHABET }), + COUNT(ItemStorageStackCountComparator.thenComparing(ItemSorter.DEFAULT.storage()), TranslatableComponent("otm.gui.sorting.count"), lazy { Widgets18.SORT_COUNT }), + NAME(ItemStorageStackNameComparator.thenComparing(ItemSorter.DEFAULT.storage()), ItemSorter.NAME.title, lazy { Widgets18.SORT_ALPHABET }), ID(ItemSorter.ID.storage(), ItemSorter.ID.title, lazy { Widgets18.SORT_ID }), MOD(ItemSorter.MOD.storage(), ItemSorter.MOD.title, lazy { Widgets18.SORT_MODID }), MATTER_VALUE(ItemSorter.MATTER_VALUE.storage(), ItemSorter.MATTER_VALUE.title, lazy { Widgets18.SORT_MATTER_VALUE }), @@ -197,6 +193,4 @@ enum class ItemStorageStackSorter(comparator: Comparator, pri val icon: IGUIRenderable by icon val title: MutableComponent get() = sTitle.copy() - val suppliers = suppliers() - val reversed: Comparator = reversed() } 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 7a37f586e..d1c408685 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt @@ -24,7 +24,7 @@ import net.minecraftforge.network.NetworkEvent import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.capability.allItems +import ru.dbotthepony.mc.otm.capability.trackedItems import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.getBarColor import ru.dbotthepony.mc.otm.capability.energy.getBarWidth @@ -347,7 +347,7 @@ class QuantumBatteryItem(val savedataID: String, val balanceValues: EnergyBalanc for (ply in event.server.playerList.players) { val networkedChannels = ObjectOpenHashSet(0) - for (item in ply.allItems().filter { it.isNotEmpty && it.item is QuantumBatteryItem }) { + for (item in ply.trackedItems().filter { it.isNotEmpty && it.item is QuantumBatteryItem }) { val power = item.getCapability(MatteryCapability.ENERGY).orThrow() as Power power.updateValues() if (power.values.isServer && networkedChannels.add(power.values.uuid)) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index fca2c7320..0ad8e4d61 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -33,9 +33,10 @@ import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.compat.cos.cosmeticArmorSlots import ru.dbotthepony.mc.otm.compat.curios.curiosSlots import ru.dbotthepony.mc.otm.compat.curios.isCurioSlot +import ru.dbotthepony.mc.otm.container.IMatteryContainer import ru.dbotthepony.mc.otm.container.ItemFilter -import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.UpgradeContainer +import ru.dbotthepony.mc.otm.container.sort import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.collect.ConditionalEnumSet import ru.dbotthepony.mc.otm.core.collect.ConditionalSet @@ -105,8 +106,6 @@ abstract class MatteryMenu( private val _playerInventorySlots = ArrayList() private val _playerHotbarSlots = ArrayList() - private val _playerMainSlots = ArrayList() - private val _playerExoSuitSlots = ArrayList() private val _playerCombinedInventorySlots = ArrayList() private val _exopackChargeSlots = ArrayList() @@ -189,7 +188,7 @@ abstract class MatteryMenu( fun intInput(allowSpectators: Boolean = false, handler: (Int) -> Unit) = PlayerInput(VarIntValueCodec, allowSpectators, handler) /** - * hotbar + inventory + exosuit (in this order) + * hotbar + inventory + Exopack (in this order) */ val playerInventorySlots: List = Collections.unmodifiableList(_playerInventorySlots) @@ -199,17 +198,7 @@ abstract class MatteryMenu( val playerHotbarSlots: List = Collections.unmodifiableList(_playerHotbarSlots) /** - * inventory only - */ - val playerMainSlots: List = Collections.unmodifiableList(_playerMainSlots) - - /** - * exosuit only - */ - val playerExoSuitSlots: List = Collections.unmodifiableList(_playerExoSuitSlots) - - /** - * inventory + exosuit (in this order) + * inventory + Exopack (in this order) */ val playerCombinedInventorySlots: List = Collections.unmodifiableList(_playerCombinedInventorySlots) @@ -217,6 +206,9 @@ abstract class MatteryMenu( val exopackPowerLevel = ProfiledLevelGaugeWidget>(mSynchronizer) + var sortInventoryInput: PlayerInput? = null + private set + var offhandSlot: InventorySlot? = null protected set @@ -267,7 +259,7 @@ abstract class MatteryMenu( return addFilterSlots(slots) } - open inner class InventorySlot(container: Container, index: Int, x: Int = 0, y: Int = 0) : UserFilteredSlot(container, index, x, y) { + open inner class InventorySlot(container: Container, index: Int, addFilter: Boolean = false) : UserFilteredSlot(container, index, 0, 0) { override fun mayPlace(itemStack: ItemStack): Boolean { return !isInventorySlotLocked(index) && super.mayPlace(itemStack) } @@ -276,61 +268,30 @@ abstract class MatteryMenu( return !isInventorySlotLocked(index) && super.mayPickup(player) } - override fun isSameInventory(other: Slot): Boolean { - if (container === inventory || container === player.matteryPlayer?.exopackContainer) - return (other.container === inventory || other.container === player.matteryPlayer?.exopackContainer) && isSameFilter(other) - - return super.isSameInventory(other) - } - var chargeFlag: GetterSetter? = null private set init { - val mattery = player.matteryPlayer + val mattery = player.matteryPlayer!! - if (mattery != null) { - if (container === inventory) { - if (slotIndex in mattery.regularSlotFilters.indices) { - filter = GetterSetter.of( - getter = { mattery.regularSlotFilters[slotIndex].value }, - setter = nullableItemInput(true) { mattery.regularSlotFilters[slotIndex].value = it }::accept - ) - } + if (addFilter) { + val mContainer = container as IMatteryContainer - if (slotIndex in mattery.regularSlotChargeFlag.indices) { - val input = booleanInput(true) { mattery.regularSlotChargeFlag[slotIndex].boolean = it } - - chargeFlag = GetterSetter.of( - getter = { mattery.regularSlotChargeFlag[slotIndex].boolean }, - setter = input::accept - ) - } - } else if (container === mattery.exopackContainer) { - filter = GetterSetter.of( - getter = { mattery.exopackContainer.getSlotFilter(slotIndex) }, - setter = nullableItemInput(true) { mattery.exopackContainer.setSlotFilter(slotIndex, it) }::accept - ) - - val input = booleanInput(true) { if (it) mattery.exoPackSlotsChargeFlag.add(slotIndex) else mattery.exoPackSlotsChargeFlag.remove(slotIndex) } - - chargeFlag = GetterSetter.of( - getter = { slotIndex in mattery.exoPackSlotsChargeFlag }, - setter = input::accept - ) - } else { - filter = null - } - } else { - filter = null + filter = GetterSetter.of( + getter = { mContainer.getSlotFilter(slotIndex) }, + setter = nullableItemInput(true) { mContainer.setSlotFilter(slotIndex, it) }::accept + ) } + + chargeFlag = GetterSetter.of( + getter = { slotIndex in mattery.slotsChargeFlag }, + setter = booleanInput(true) { if (it) mattery.slotsChargeFlag.add(slotIndex) else mattery.slotsChargeFlag.remove(slotIndex) }::accept + ) } } - open inner class EquipmentSlot(container: Container, index: Int, val type: net.minecraft.world.entity.EquipmentSlot, x: Int = 0, y: Int = 0) : InventorySlot(container, index, x, y) { - constructor(type: net.minecraft.world.entity.EquipmentSlot, x: Int = 0, y: Int = 0) : this( - inventory, 34 + type.ordinal, type, x, y - ) + open inner class EquipmentSlot(container: Container, index: Int, val type: net.minecraft.world.entity.EquipmentSlot) : InventorySlot(container, index) { + constructor(type: net.minecraft.world.entity.EquipmentSlot) : this(inventory, 34 + type.ordinal, type) override fun mayPlace(itemStack: ItemStack): Boolean { return super.mayPlace(itemStack) && itemStack.canEquip(type, inventory.player) @@ -351,6 +312,8 @@ abstract class MatteryMenu( protected fun addInventorySlots(autoFrame: Boolean = !player.isSpectator) { check(_playerInventorySlots.isEmpty()) { "Already created inventory slots" } + val mattery = player.matteryPlayer ?: return + autoCreateInventoryFrame = autoFrame offhandSlot = object : InventorySlot(inventory, 40) { @@ -362,11 +325,12 @@ abstract class MatteryMenu( mapQuickMoveToInventory(offhandSlot!!) addSlot(offhandSlot!!) - for (i in 0 .. 35) { - val slot = InventorySlot(inventory, i) + for (i in 0 until mattery.combinedInventory.containerSize) { + if (i in Inventory.INVENTORY_SIZE .. player.inventory.containerSize) continue + + val slot = InventorySlot(mattery.combinedInventory, i, true) _playerInventorySlots.add(slot) - _playerMainSlots.add(slot) if (i <= 8) _playerHotbarSlots.add(slot) @@ -378,21 +342,7 @@ abstract class MatteryMenu( addSlot(slot) } - val mattery = player.matteryPlayer - - if (mattery != null && mattery.hasExopack) { - for (i in 0 until mattery.exopackContainer.containerSize) { - val slot = InventorySlot(mattery.exopackContainer, i) - - _playerInventorySlots.add(slot) - _playerExoSuitSlots.add(slot) - _playerCombinedInventorySlots.add(slot) - - mapQuickMove(slot, equipmentSlots) - mapQuickMoveToExternal(slot) - addSlot(slot) - } - + if (mattery.hasExopack) { _exopackChargeSlots.add(BatterySlot(mattery.exopackEnergy.parent, 0).also { mapQuickMoveToExternal(it); mapQuickMoveToInventory(it); addSlot(it) }) for (i in 0 until mattery.exopackChargeSlots.containerSize) @@ -400,6 +350,10 @@ abstract class MatteryMenu( exopackPowerLevel.with(mattery.exopackEnergy) } + + sortInventoryInput = PlayerInput(NullValueCodec) { + mattery.inventoryAndExopackNoHotbar.sort() + } } private var broadcastOnce = false @@ -471,7 +425,7 @@ abstract class MatteryMenu( val input: PlayerInput val field: IField - if (container is MatteryContainer) { + if (container is IMatteryContainer) { input = PlayerInput(ItemValueCodec.nullable, handler = { container.setSlotFilter(pSlot.slotIndex, it) }) field = mSynchronizer.ComputedField(getter = { container.getSlotFilter(pSlot.slotIndex) }, ItemValueCodec.nullable) } else { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt index ac20239f9..be03785a9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt @@ -11,6 +11,8 @@ import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.container.IMatteryContainer +import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.runOnClient @@ -44,6 +46,26 @@ open class MatterySlot(container: Container, index: Int, x: Int = 0, y: Int = 0) open fun canTakeItemForPickAll(): Boolean { return true } + + override fun getMaxStackSize(): Int { + val container = container + + if (container is IMatteryContainer) { + return container.getMaxStackSize(slotIndex, ItemStack.EMPTY) + } else { + return super.getMaxStackSize() + } + } + + override fun getMaxStackSize(itemStack: ItemStack): Int { + val container = container + + if (container is IMatteryContainer) { + return container.getMaxStackSize(slotIndex, itemStack) + } else { + return super.getMaxStackSize(itemStack) + } + } } open class UserFilteredSlot(container: Container, index: Int, x: Int = 0, y: Int = 0) : MatterySlot(container, index, x, y), Predicate { 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 08aeb6c19..fc10bffc0 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 @@ -162,7 +162,7 @@ class NetworkedItemView(val ply: Player, val menu: MatteryMenu, val isRemote: Bo val id2tuple = Int2ObjectOpenHashMap() val sortedView = ArrayList() - var sorter: Comparator = ItemStorageStackSorter.DEFAULT + var sorter: Comparator = ItemStorageStackSorter.DEFAULT set(value) { if (field != value) { field = value diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt index df4e05718..159d23324 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt @@ -5,6 +5,8 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.block.entity.decorative.CargoCrateBlockEntity +import ru.dbotthepony.mc.otm.container.sort +import ru.dbotthepony.mc.otm.core.util.NullValueCodec import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.UserFilteredSlot @@ -16,9 +18,12 @@ class CargoCrateMenu @JvmOverloads constructor( tile: CargoCrateBlockEntity? = null ) : MatteryMenu(MMenus.CARGO_CRATE, p_38852_, inventory, tile) { val storageSlots: List - private val trackedPlayerOpen = !inventory.player.isSpectator + val sort = PlayerInput(NullValueCodec) { + tile?.container?.sort() + } + init { val container = tile?.container ?: SimpleContainer(CargoCrateBlockEntity.CAPACITY) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt index 702149d37..9a24e4021 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/DriveViewerMenu.kt @@ -55,7 +55,7 @@ class DriveViewerMenu( if (isAscending) { networkedItemView.sorter = sorting } else { - networkedItemView.sorter = sorting.reversed + networkedItemView.sorter = sorting.reversed() } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt index 82c13664c..0145d626b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt @@ -96,7 +96,7 @@ class ItemMonitorMenu( if (ascendingSort) { networkedItemView.sorter = sorting } else { - networkedItemView.sorter = sorting.reversed + networkedItemView.sorter = sorting.reversed() } } } diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/storage_controls.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/storage_controls.png index 6b7c5ba65030166100d8b301f4077f2dad46f020..fb22863c896707a6e8ab7444a05852b50448940b 100644 GIT binary patch delta 605 zcmV-j0;2u=2d4;-7YaxS1^@s6cDCY@u_40&e-sD`0Ni4;p#T5^BS}O-RCwC$o8hj5 zAPhzw@v(e--)sA|gb);3N(DS$a+AA78$6T`3U1pFLP)Gn{NX&$ujJC!?m)?-gsnK#_SQR6gLI^wE$VNAjyNK50b){bVeK_j_YA@yRs*@<2W80 ze}*ZH8aOfB7}{ zy^~|#UM>yfC9NaZ_*$#zwYt$*M@_-7M3;q zn(fK>BqRq*vJYK~BiSHY(xb07`K2HvaavDmm<)}Vb&?L~IvK76@yhTD`nOGXJIoM+hN=tk;iE#hF#1b}3^8f2nnE zyS3w<>hK@|@-*xb*2AWtb2b0fPZ6}0)XcEs1B~3CD5Ev|wAN+oN|_y`Ab{OrGF-un zM`>$VWoS;lytA^08DRIevM~Dt%+ki7UC2vL9PS?E>59=S5!~ME7%{W0e&?tHy;Aiz zQpZnol%@T(?2K~;LI@%BE?J#uM<8Vh4s0jTz;*-;YzNR(R*o4B>_*TMI{b_-7Ya5A1^@s6N1l!&u_40&e-Z>56rc;!H2?qs_(?=TRCwC$TS*SX zAPj6!p2hR|S9(H1h!AfqMl+|hO&l06*rxn`0002?NGUxjrDqp8UJ+&~t91>c2a(Jr zJ9~kpaz@Gek{f1_9Amulclnw+;TYo;W4!YHHTfK6q?DdgR{i`)Z@XubT#}b3*7}`7 ze}3s`0TbC0y>9s#vwX_VNTAT?}olwQ8KbxpEp$_pv?PzEirW~oKj z_tlmt9g8Y-^j>^g)*vC-By{xRC)Gtq$9n5=lw@%{krO&DZakAtZiSL&dV`qg7TFq- zP9)l_U}@#Q00000006+MT$)lX2T-*^e;y4?BwEuD*EH1YXS6Lhbx@@#dh%a|h zC`7*9N0Fm7sxRDBvaHFc_O$EmCvK;WDu>e`Ixie*gf0 zb^f?Yj#mU~Dq}^GwzsWS+$x0!4k4?_-XR}0CEDUh#8)Ndne6&F2IY80;FOk@jUexp zo{2?&9f<(ho0Z_6vW(GV4X3!K>-5elJa`~`bSMknC*Wm_L7K>Ob{u*WSzR&CGK6XW z>)6q;M1&07*qoM6N<$f~^h) A%>V!Z diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/storage_controls.xcf b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/storage_controls.xcf index 1a198317e90923ab36dde4eea5886a4151261e5e..96fc5f0f62dc8aad9d610b947921602e7f091fa2 100644 GIT binary patch delta 1356 zcmbtTJ!lj`6rOpzo4wt;OL7-4Yi=*QmkTk9h*%^_Lcm~S#GsKV*qFvB78WTif`*I1 zMo8f?8ch*U3&A2GI3R)$EHe+o547~jm?MYNJ+;Ja_;oA=($H}m$@ z@r9GOa^X>;#~e}yK`H)Z5eE^yw6cGgo~ulKD*wPG4s%j-!$ZxEuQ~ZtbK?!onGww` z-!-?M)!a6u*}tMWsO5)`^}6Gx=Faz;cgZv1U~9C^^Wq2bN_DzA6F;j?$1CxZc)2=L zon;j6vBL$E_OiA1{!HDGP9#Q}RSJ19_OKDRwQLO5WU`wyLZLgDEa7@>39G z2^qA$IX6{7hZu@o0xWa__KT+3oy;tohZEFd6ImauIeDdEE%CrG0Bo)<+J384`y&gC zR({zE0o*|CxP7?eB~H~|fQ5-gR!p4XZxRVwKot@BInJV4WJr8X@qwdp0Q zgOpD;j#9{usjci)xs}Ya`n&FBA4)CkYsqBSniu$s=4A>wP@%biecR#DUj8V%55OB& zqIX@D_U5^hTLQ=rDK$T?)ch3x?Ck_7+(p%=T#1F(ygxq*5O%20a6qZyX}(%GPoemn z(V|b^DY5v4j|KNBlqzhZIM#BW4gqSQrKj&L2aDN z=Cg^2fKY_Mrj@#bF%)BUqvFd)17wTY7qHAW(l@hBks_uDh>Z})(o4^oKOYYGQDEdtv_ut;SUQj4Ux1Pg;WdHd#K@(<`RZ@xR9H;?yy`+8w>_IWwH z%Jk}?co>}H;bUCtUY_IA-PIo}-|>bk6KWk2TC=;%UYcO?W9Ha~@z%%!DBrc@Y@_9~V1TMSe1OIhYfa zFmGX^0_J_WV_gBTdPJ=cM6ECKw%q}+W1{vwqIO62b87%@j;MQ%sCymh442%y%c1a% zQiXj=6&?A^Ujpunj#&l2N6=rFljZXOBir<}sBHEazvc{vMvSM^oPDSXpnWYEK zHkCDF`MGrsptVf2^(v)K>;2I$j>QAFa%!0Igb%`EDgpckR7dpv(u-2Yh}pk*_@_v% z6}G0p)(Tr=DCLMZrGUq>I392~(ZdjqH|(AwE1^zw5bj-hZ}7ww5iahirFDhAlJG8 From 1ab252e57a4b47fa944f85feff7a54ab357cf746 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 20 Aug 2023 15:42:49 +0700 Subject: [PATCH 1001/1199] Move sorting order button sprite 1 pixel down --- .../textures/gui/widgets/storage_controls.png | Bin 1063 -> 1079 bytes .../textures/gui/widgets/storage_controls.xcf | Bin 10269 -> 10257 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/storage_controls.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/storage_controls.png index fb22863c896707a6e8ab7444a05852b50448940b..b5dc14305f7b9049b8302354034360c8416574e7 100644 GIT binary patch delta 605 zcmV-j0;2t=2)78Z<^g{yBz5I;(f|MgGf6~2RCwC$n_;TNAPj`J;<0*s@74WP5V38d z(W?Ch7G57~h?6)b+Wq|i06>i`eh49`2Jib0gF^V^`KSq06tE)`lAspw& z(q;==PjnK>5x_#tv9}sj84CoW@2lfwbHR^ zm)4sBk@~9jV@c`AIWLup65=E_OQb{Gu+W^`uLdpA$JKW1aPE5F zN(0kZ4lL|QZ&`Z1sz3**_`ioj+s(STyaPJ@rUeH8004ii>&Lh3%nBzhWvoc5J=?Ag z+*<*68baPCdxUz}l;~W~fAv#@(oSk-vf~Sk+((tsCFiu(ZR<*z?X*Ndc7x4u1uY)M zSGUU2oVvWTl7|_{ZY^bQ_6f}5qbn`sH8&1-6M4I1?3D=J-s>1KvrBy{8Ru8-{zeM? zG*?-rzm`>40ni02l&)`vgL$vR;cs00000NkvXXu0mjf=zk@A delta 589 zcmV-T0C!?m)?-gsnK z#_SQR6gLI^wE$VNAjyNK50b){bVeK_j_YA@yRs*@<2W80hADrH8aOfB7}{y^~|#UM>yfC9NaZ_*$#z zwYt$*M@_-7M3;qn(fK>BqRq*vJYK~BiSHY z(xb07`K2HvaavDmm<)}Vb&?L~IvK76@yhTD`nOGXJIoM+hN=tk;iE#hF#1b}3^8sdayEyS3w<>hK@|@-*xb*2AWt zb2b0fPZ6}0)XcEs1B~3CD5Ev|wAN+oN|_y`Ab{OrGF-unM`>$VWoS;lytA^08DRIe zvM~Dt%+ki7UC2vL9PS?E>59=S5!~ME7%{W0e&?tHy;AizQpZnol%@T(?2K~;LI@%B zE?J#uAZ0}f4s0jTz;*-;YzNR(R*o4B>_*TMI{4h=n#R`p)7GZ;N7GbmoH{5}~-Ttg25L-WlAt&2*wr!dw%=sk(g@*!QMx~eo3(LXS%DE0ae+4Q;A*EEJ)0V zMyX3ozW z^gW^U)p*TUrcgrJeulFB){zEq@J|EGU=motBv9nVzyhV6A811g+EALOLum>*l;L%h zVT)VgD+-1qV@^~*aCDWgMk5qi!lP6e8R(K^j2P{GN*juEDUG!Ob4{5fWiN}_SY=05kb~^;} z?Xd0|qs5kp7#WfwZrkgu`j_UwA2&7GTS|ot@96IWNa3Y)123h|vYdVhCi~P?I!1l~ D{*RjI delta 744 zcmbu5ziSgw9KhfAUroX5eob`uq^nQ3lbL2>~lGZ$b z3LNx~3t4SX%omt*_WM zbM)ORNeDRMTsuwJ&aJcK@VT>tFPu9xotg*O;~Mvis`222zPV2&Y_c2Z@xXykN=^Ws zTxy?N2di3$CE6nJEup>)Y(H{{h#*q}DB94;m?Z{PoN2DTCg`?Kvq9&4RWvR@6 zcHjP|!;RP#MjQw$wpIATjx7~=k&4w7<0&#KLjYs^E2=m7v#Tv^RJ%~apVd${#9x8S Bv_Jp= From b93e007388f5bc12b7360f1270c5a49d0c03deb3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 20 Aug 2023 15:43:18 +0700 Subject: [PATCH 1002/1199] Fix pattern panel not saving pause state --- .../mc/otm/block/entity/matter/MatterPanelBlockEntity.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt index 7b96e91f1..1c2bcda70 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt @@ -93,6 +93,8 @@ class MatterPanelBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte init { exposeGlobally(MatteryCapability.MATTER_NODE, matterNode) exposeGlobally(MatteryCapability.TASK, this) + + savetables.bool(::isProvidingTasks) } override fun setLevel(level: Level) { From 35b186556ebd9908d417032240461d8193ef6b77 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 20 Aug 2023 15:44:20 +0700 Subject: [PATCH 1003/1199] Add "cancel all task" to button tooltip --- .../mc/otm/client/screen/matter/MatterPanelScreen.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 b4b4a2127..334ab37ff 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 @@ -85,7 +85,7 @@ class MatterPanelScreen( { menu.cancelAll.accept(null) } ) } - ) + ).also { it.tooltips.add(TranslatableComponent("otm.gui.matter_panel.cancel_all")) } ) val scrollBar = DiscreteScrollBarPanel(this, frame, { From e7c9abcebb141c825a8669315ed208080bf708fc Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 20 Aug 2023 17:35:39 +0700 Subject: [PATCH 1004/1199] Proper sorting inputs in regular storage menus --- .../mc/otm/datagen/lang/English.kt | 1 + .../mc/otm/datagen/lang/Russian.kt | 1 + .../entity/matter/MatterPanelBlockEntity.kt | 19 +-- .../otm/capability/MatteryPlayerCapability.kt | 9 ++ .../mc/otm/client/render/Widgets18.kt | 4 +- .../mc/otm/client/screen/MatteryScreen.kt | 7 +- .../screen/decorative/CargoCrateScreen.kt | 2 +- .../decorative/MinecartCargoCrateScreen.kt | 5 + .../client/screen/matter/MatterPanelScreen.kt | 2 +- .../otm/client/screen/panels/EditablePanel.kt | 4 +- .../client/screen/panels/button/Buttons.kt | 122 +++++++++++++++--- .../mc/otm/container/ContainerHelpers.kt | 35 ++--- .../mc/otm/menu/ISortingSettings.kt | 114 ++++++++++++++++ .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 4 +- .../mc/otm/menu/decorative/CargoCrateMenu.kt | 20 ++- .../menu/decorative/MinecartCargoCrateMenu.kt | 23 ++-- .../mc/otm/menu/matter/MatterPanelMenu.kt | 26 +--- 17 files changed, 291 insertions(+), 107 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/menu/ISortingSettings.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 980212cbc..9c54129d6 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -806,6 +806,7 @@ private fun gui(provider: MatteryLanguageProvider) { gui("balance_inputs", "Balance input slots") gui("sorting.sort_now", "Sort") + gui("sorting.sort_settings", "Right click to show settings") gui("sorting.default", "Default sorting") gui("sorting.name", "Sort by name") gui("sorting.id", "Sort by ID") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index f9711bcfb..f786f55dd 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -806,6 +806,7 @@ private fun gui(provider: MatteryLanguageProvider) { gui("balance_inputs", "Балансировать входные слоты") gui("sorting.sort_now", "Отсортировать") + gui("sorting.sort_settings", "Нажмите правую кнопку мыши для настроек") gui("sorting.default", "Сортировка по умолчанию") gui("sorting.name", "Сортировка по имени") gui("sorting.id", "Сортировка по ID") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt index 1c2bcda70..ae73612fd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt @@ -23,35 +23,24 @@ import ru.dbotthepony.mc.otm.core.nbt.mapString import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.ItemSorter import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode +import ru.dbotthepony.mc.otm.menu.IItemSortingSettings import ru.dbotthepony.mc.otm.registry.MBlockEntities import java.util.* import java.util.stream.Stream class MatterPanelBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.MATTER_PANEL, blockPos, blockState), IReplicationTaskProvider { - inner class PlayerSettings : INBTSerializable { - var sorter: ItemSorter = ItemSorter.DEFAULT + inner class PlayerSettings : IItemSortingSettings { + override var sorting: ItemSorter = ItemSorter.DEFAULT set(value) { field = value markDirtyFast() } - var ascending: Boolean = true + override var isAscending: Boolean = true set(value) { field = value markDirtyFast() } - - override fun serializeNBT(): CompoundTag { - return CompoundTag().also { - it["sorter"] = sorter.name - it["ascending"] = ascending - } - } - - override fun deserializeNBT(nbt: CompoundTag) { - sorter = nbt.mapString("sorter", ItemSorter::valueOf, ItemSorter.DEFAULT) - ascending = nbt.getBoolean("ascending", true) - } } var isProvidingTasks = true diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 423738677..157a5b1ea 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -98,6 +98,7 @@ import ru.dbotthepony.mc.otm.core.nbt.getIntList import ru.dbotthepony.mc.otm.core.nbt.getStringList import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.IntValueCodec +import ru.dbotthepony.mc.otm.core.util.ItemStackSorter import ru.dbotthepony.mc.otm.core.util.ItemValueCodec import ru.dbotthepony.mc.otm.core.util.RGBCodec import ru.dbotthepony.mc.otm.core.util.Savetables @@ -105,6 +106,7 @@ import ru.dbotthepony.mc.otm.core.util.TickList import ru.dbotthepony.mc.otm.core.util.UUIDValueCodec import ru.dbotthepony.mc.otm.core.util.VarIntValueCodec import ru.dbotthepony.mc.otm.menu.ExopackInventoryMenu +import ru.dbotthepony.mc.otm.menu.IItemStackSortingSettings import ru.dbotthepony.mc.otm.network.* import ru.dbotthepony.mc.otm.network.SmokeParticlesPacket.Companion.makeSmoke import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer @@ -402,6 +404,11 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial return _exoPackMenu!! } + val sortingSettings = object : IItemStackSortingSettings { + override var isAscending: Boolean = true + override var sorting: ItemStackSorter = ItemStackSorter.DEFAULT + } + fun recreateExoPackMenu() { _exoPackMenu = ExopackInventoryMenu(this) } @@ -591,6 +598,8 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial savetables.codecNullable(::exopackColor, RGBAColor.CODECRGB) savetables.bool(::exopackGlows) + + savetables.stateful(::sortingSettings) } fun invalidateNetworkState() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt index 60849bf3a..8999e8f91 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets18.kt @@ -38,8 +38,8 @@ object Widgets18 { val BUTTON_DISABLED = buttonGrids.next() private val storageGrid = WidgetLocation.STORAGE_CONTROLS.grid(rows = 4, columns = 5) - val ARROW_DOWN = storageGrid.next() - val ARROW_UP = storageGrid.next() + val SORT_DESCENDING = storageGrid.next() + val SORT_ASCENDING = storageGrid.next() val SORT_DEFAULT = storageGrid.next() val SORT_ALPHABET = storageGrid.next() val SORT_COUNT = storageGrid.next() 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 df07050f1..ef2495a9f 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 @@ -308,12 +308,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } if (menu.sortInventoryInput != null) { - deviceControls.addButton(LargeRectangleButtonPanel.input( - this, - deviceControls, - menu.sortInventoryInput!!, - icon = Widgets18.SORT_NOW - ).also { it.tooltips.add(TranslatableComponent("otm.gui.sorting.sort_now")) }) + deviceControls.customSortingButtons(menu.playerSortSettings, menu.sortInventoryInput!!) } if (menu.exopackChargeSlots.isNotEmpty()) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt index 99d4e560d..55967a4c6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt @@ -28,7 +28,7 @@ class CargoCrateScreen(menu: CargoCrateMenu, inventory: Inventory, title: Compon val controls = DeviceControls(this, frame) - controls.addButton(LargeRectangleButtonPanel.input(this, frame, menu.sort, icon = Widgets18.SORT_NOW).also { it.tooltips.add(TranslatableComponent("otm.gui.sorting.sort_now")) }) + controls.customSortingButtons(menu.playerSortSettings, menu.sort) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/MinecartCargoCrateScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/MinecartCargoCrateScreen.kt index c274f233a..30b8af8cd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/MinecartCargoCrateScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/MinecartCargoCrateScreen.kt @@ -4,6 +4,7 @@ import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.DeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.menu.decorative.MinecartCargoCrateMenu @@ -20,6 +21,10 @@ class MinecartCargoCrateScreen(menu: MinecartCargoCrateMenu, inventory: Inventor for (slot in menu.storageSlots) SlotPanel(this, grid, slot) + val controls = DeviceControls(this, frame) + + controls.customSortingButtons(menu.playerSortSettings, menu.sort) + return frame } } 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 334ab37ff..ee098227c 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 @@ -55,7 +55,7 @@ class MatterPanelScreen( val controls = DeviceControls(this, frame) - controls.sortingButtons(menu::isAscending.asGetterSetter(), menu::sorting.asGetterSetter(), ItemSorter.DEFAULT) { + controls.sortingButtons(menu.settings::isAscending.asGetterSetter(), menu.settings::sorting.asGetterSetter(), ItemSorter.DEFAULT) { for (v in ItemSorter.entries) { 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 c09da8d5c..3742af760 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 @@ -140,7 +140,7 @@ open class EditablePanel @JvmOverloads constructor( } /** - * Bigger values means lesser priority while docking + * Bigger values means lesser priority while docking, rendering and processing inputs. */ var childrenOrder = 0 set(value) { @@ -881,7 +881,7 @@ open class EditablePanel @JvmOverloads constructor( poseStack.popPose() } - for (child in visibleChildrenInternal) { + for (child in visibleChildrenInternal.asReversed()) { child.absoluteX = absoluteX + child.x + xOffset child.absoluteY = absoluteY + child.y + yOffset 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 853c876a1..4abe11ac9 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 @@ -27,9 +27,13 @@ import ru.dbotthepony.mc.otm.config.ClientConfig import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.asGetterSetter import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.math.RelativeSide +import ru.dbotthepony.mc.otm.core.util.ItemStackSorter import ru.dbotthepony.mc.otm.core.value +import ru.dbotthepony.mc.otm.menu.IItemStackSortingSettings +import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.UpgradeSlots import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput @@ -314,33 +318,61 @@ class DeviceControls>( val balanceInputsButton: LargeBooleanRectangleButtonPanel? val upgradesButton: LargeRectangleButtonPanel? + init { + childrenOrder = -1000 + } + private var upgradeWindow: FramePanel? = null - private var nextY = 0f + + private val buttons = ArrayList>() + + fun alignButtons() { + buttons.removeIf { it.isRemoved || it.parent != this } + + var y = 0f + + for (button in buttons) { + button.setPos(button.dockLeft, y + button.dockTop) + y += button.height + button.dockMargin.vertical + 2f + width = width.coerceAtLeast(button.width + button.dockMargin.horizontal) + } + + height = height.coerceAtLeast(y - 2f) + } + + fun removeButton(button: EditablePanel<*>) { + buttons.remove(button) + alignButtons() + } fun

> addButton(button: P): P { + buttons.add(button) button.parent = this - button.x = 0f - button.y = nextY - nextY += button.height + 2f - height = nextY - 2f - width = button.width.coerceAtLeast(width) + alignButtons() + return button + } + + fun

> addButton(button: P, after: EditablePanel<*>): P { + val index = buttons.indexOf(after) + if (index == -1) throw NoSuchElementException("Unknown panel to add button after: $after") + buttons.add(index + 1, button) + button.parent = this + alignButtons() return button } fun

> prependButton(button: P): P { - for (child in children) { - child.y += button.height + 2f - } - + buttons.add(0, button) button.parent = this - button.x = 0f - button.y = 0f - nextY += button.height + 2f - height = nextY - 2f - width = button.width.coerceAtLeast(width) + alignButtons() return button } + override fun performLayout() { + super.performLayout() + alignButtons() + } + fun addStorageMode(prop: GetterSetter) { val mode = LargeEnumRectangleButtonPanel(screen, this, prop = prop, defaultValue = FlowDirection.BI_DIRECTIONAL, enum = FlowDirection::class.java) @@ -352,24 +384,74 @@ class DeviceControls>( addButton(mode) } - inline fun > sortingButtons(ascending: GetterSetter, sorting: GetterSetter, default: T, configurator: LargeEnumRectangleButtonPanel.() -> Unit) { + inline fun > sortingButtons(ascending: GetterSetter, sorting: GetterSetter, default: T, configurator: LargeEnumRectangleButtonPanel.() -> Unit): List> { + val result = ArrayList>() + LargeBooleanRectangleButtonPanel( screen, this, prop = ascending, - iconActive = Widgets18.ARROW_UP, - iconInactive = Widgets18.ARROW_DOWN, + iconActive = Widgets18.SORT_ASCENDING, + iconInactive = Widgets18.SORT_DESCENDING, tooltipActive = TranslatableComponent("otm.gui.sorting.ascending"), tooltipInactive = TranslatableComponent("otm.gui.sorting.descending"), ).also { prependButton(it) + result.add(it) } LargeEnumRectangleButtonPanel(screen, this, enum = T::class.java, prop = sorting, defaultValue = default).also { prependButton(it) configurator.invoke(it) it.finish() + result.add(it) } + + return result + } + + fun customSortingButtons(settings: IItemStackSortingSettings, input: MatteryMenu.PlayerInput) { + addButton(object : LargeRectangleButtonPanel(screen, this@DeviceControls) { + var buttons: List>? = null + + init { + tooltips.add(TranslatableComponent("otm.gui.sorting.sort_now")) + tooltips.add(TextComponent("")) + tooltips.add(TranslatableComponent("otm.gui.sorting.sort_settings").withStyle(ChatFormatting.GRAY)) + + icon = Widgets18.SORT_NOW + } + + override fun test(value: Int): Boolean { + return value == InputConstants.MOUSE_BUTTON_LEFT || value == InputConstants.MOUSE_BUTTON_RIGHT + } + + override var isDisabled: Boolean + get() = !input.test(minecraft.player) + set(value) {} + + override fun onClick(mouseButton: Int) { + if (mouseButton == InputConstants.MOUSE_BUTTON_LEFT) { + input.accept(null) + } else { + if (buttons == null) { + buttons = sortingButtons(settings::isAscending.asGetterSetter(), settings::sorting.asGetterSetter(), ItemStackSorter.DEFAULT) { + for (v in ItemStackSorter.entries) { + add(v, v.icon, v.title) + } + + finish() + } + + buttons!!.forEach { removeButton(it) } + buttons!!.forEach { addButton(it as EditablePanel, this) } + } else { + buttons!!.forEach { it.remove() } + buttons = null + } + } + } + }) } init { @@ -492,7 +574,7 @@ class DeviceControls>( } if (energyConfig != null) { - energyConfigButton = addButton(object : LargeRectangleButtonPanel(screen, this@DeviceControls, y = nextY, icon = Widgets18.ENERGY_CONFIGURATION) { + energyConfigButton = addButton(object : LargeRectangleButtonPanel(screen, this@DeviceControls, icon = Widgets18.ENERGY_CONFIGURATION) { init { tooltips.add(TranslatableComponent("otm.gui.sides.energy_config")) } @@ -511,7 +593,7 @@ class DeviceControls>( } if (fluidConfig != null) { - fluidConfigButton = addButton(object : LargeRectangleButtonPanel(screen, this@DeviceControls, y = nextY, icon = Widgets18.FLUID_CONFIGURATION) { + fluidConfigButton = addButton(object : LargeRectangleButtonPanel(screen, this@DeviceControls, icon = Widgets18.FLUID_CONFIGURATION) { init { tooltips.add(TranslatableComponent("otm.gui.sides.fluid_config")) } 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 9a2a0e79e..627492193 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHelpers.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHelpers.kt @@ -8,6 +8,7 @@ import it.unimi.dsi.fastutil.ints.IntIterator import it.unimi.dsi.fastutil.ints.IntSet import it.unimi.dsi.fastutil.objects.Object2ObjectFunction import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap +import it.unimi.dsi.fastutil.objects.ObjectArrayList import net.minecraft.world.Container import net.minecraft.world.inventory.CraftingContainer import net.minecraft.world.item.ItemStack @@ -18,6 +19,8 @@ import ru.dbotthepony.mc.otm.container.util.ItemStackHashStrategy 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.map +import ru.dbotthepony.mc.otm.core.collect.max import ru.dbotthepony.mc.otm.core.collect.toList import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.core.map @@ -288,19 +291,6 @@ operator fun CraftingContainer.get(column: Int, row: Int, flop: Boolean): ItemSt get(column, row) } -private object FilteredFirst : Comparator { - override fun compare(o1: IContainerSlot, o2: IContainerSlot): Int { - if (o1.hasFilter && o2.hasFilter) - return 0 - else if (o2.hasFilter) - return -1 - else if (o1.hasFilter) - return 1 - else - return 0 - } -} - fun Container.sort(comparator: Comparator = ItemStackSorter.DEFAULT) { if (isEmpty) return @@ -310,8 +300,21 @@ fun Container.sort(comparator: Comparator = ItemStackSorter.DEFAULT) if (slots.isEmpty()) return - slots.sortWith(FilteredFirst.thenComparing(comparator.map(IContainerSlot::item))) - val items = slots.map { it.item.copy() } + val items = Object2ObjectOpenCustomHashMap(ItemStackHashStrategy) + + slots.forEach { + val get = items[it.item] + + if (get == null) { + items[it.item] = it.item.copy() + } else { + get.count += it.item.count + } + } + + val sortedItems = ObjectArrayList(items.values) + sortedItems.sortWith(comparator) + slots.forEach { it.remove() } - items.forEach { addItem(it, false) } + sortedItems.forEach { addItem(it, false) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ISortingSettings.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ISortingSettings.kt new file mode 100644 index 000000000..fa9a9552d --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ISortingSettings.kt @@ -0,0 +1,114 @@ +package ru.dbotthepony.mc.otm.menu + +import net.minecraft.nbt.CompoundTag +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import net.minecraftforge.common.util.INBTSerializable +import ru.dbotthepony.mc.otm.core.nbt.getBoolean +import ru.dbotthepony.mc.otm.core.nbt.mapString +import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.core.util.ItemSorter +import ru.dbotthepony.mc.otm.core.util.ItemStackSorter +import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback +import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback + +interface IBaseSortingSettings : INBTSerializable { + var isAscending: Boolean + + override fun serializeNBT(): CompoundTag { + return CompoundTag().also { + it["isAscending"] = isAscending + } + } + + override fun deserializeNBT(nbt: CompoundTag?) { + nbt ?: return + isAscending = nbt.getBoolean("isAscending", true) + } +} + +interface IItemStackSortingSettings : IBaseSortingSettings { + var sorting: ItemStackSorter + + override fun serializeNBT(): CompoundTag { + return super.serializeNBT().also { + it["sorting"] = sorting.name + } + } + + override fun deserializeNBT(nbt: CompoundTag?) { + nbt ?: return + super.deserializeNBT(nbt) + sorting = nbt.mapString("sorting", ItemStackSorter::valueOf, ItemStackSorter.DEFAULT) + } + + val actualComparator: Comparator get() { + if (isAscending) { + return sorting + } else { + return sorting.reversed() + } + } + + companion object { + fun inputs(menu: MatteryMenu, observer: Runnable? = null) : IItemStackSortingSettings { + return object : IItemStackSortingSettings { + override var isAscending: Boolean by BooleanInputWithFeedback(menu).also { if (observer != null) it.addListener { observer.run() } } + override var sorting: ItemStackSorter by EnumInputWithFeedback(menu).also { if (observer != null) it.addListener { observer.run() } } + } + } + + fun inputs(menu: MatteryMenu, parent: IItemStackSortingSettings?, observer: Runnable? = null) : IItemStackSortingSettings { + if (parent == null) + return inputs(menu) + + return object : IItemStackSortingSettings { + override var isAscending: Boolean by BooleanInputWithFeedback(menu, parent::isAscending).also { if (observer != null) it.addListener { observer.run() } } + override var sorting: ItemStackSorter by EnumInputWithFeedback(menu, parent::sorting).also { if (observer != null) it.addListener { observer.run() } } + } + } + } +} + +interface IItemSortingSettings : IBaseSortingSettings { + var sorting: ItemSorter + + override fun serializeNBT(): CompoundTag { + return super.serializeNBT().also { + it["sorting"] = sorting.name + } + } + + override fun deserializeNBT(nbt: CompoundTag?) { + nbt ?: return + super.deserializeNBT(nbt) + sorting = nbt.mapString("sorting", ItemSorter::valueOf, ItemSorter.DEFAULT) + } + + val actualComparator: Comparator get() { + if (isAscending) { + return sorting + } else { + return sorting.reversed() + } + } + + companion object { + fun inputs(menu: MatteryMenu, observer: Runnable? = null) : IItemSortingSettings { + return object : IItemSortingSettings { + override var isAscending: Boolean by BooleanInputWithFeedback(menu).also { if (observer != null) it.addListener { observer.run() } } + override var sorting: ItemSorter by EnumInputWithFeedback(menu).also { if (observer != null) it.addListener { observer.run() } } + } + } + + fun inputs(menu: MatteryMenu, parent: IItemSortingSettings?, observer: Runnable? = null) : IItemSortingSettings { + if (parent == null) + return inputs(menu) + + return object : IItemSortingSettings { + override var isAscending: Boolean by BooleanInputWithFeedback(menu, parent::isAscending).also { if (observer != null) it.addListener { observer.run() } } + override var sorting: ItemSorter by EnumInputWithFeedback(menu, parent::sorting).also { if (observer != null) it.addListener { observer.run() } } + } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 0ad8e4d61..8f8e31ef9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -209,6 +209,8 @@ abstract class MatteryMenu( var sortInventoryInput: PlayerInput? = null private set + val playerSortSettings = IItemStackSortingSettings.inputs(this, player.matteryPlayer?.sortingSettings) + var offhandSlot: InventorySlot? = null protected set @@ -352,7 +354,7 @@ abstract class MatteryMenu( } sortInventoryInput = PlayerInput(NullValueCodec) { - mattery.inventoryAndExopackNoHotbar.sort() + mattery.inventoryAndExopackNoHotbar.sort(playerSortSettings.actualComparator) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt index 159d23324..d02b2af7b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt @@ -5,32 +5,28 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.block.entity.decorative.CargoCrateBlockEntity +import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.container.sort import ru.dbotthepony.mc.otm.core.util.NullValueCodec +import ru.dbotthepony.mc.otm.menu.IItemStackSortingSettings import ru.dbotthepony.mc.otm.menu.MatteryMenu -import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.UserFilteredSlot +import ru.dbotthepony.mc.otm.menu.makeSlots import ru.dbotthepony.mc.otm.registry.MMenus -class CargoCrateMenu @JvmOverloads constructor( - p_38852_: Int, +class CargoCrateMenu( + containerId: Int, inventory: Inventory, tile: CargoCrateBlockEntity? = null -) : MatteryMenu(MMenus.CARGO_CRATE, p_38852_, inventory, tile) { - val storageSlots: List +) : MatteryMenu(MMenus.CARGO_CRATE, containerId, inventory, tile) { + val storageSlots = makeSlots(tile?.container ?: SimpleContainer(CargoCrateBlockEntity.CAPACITY), ::UserFilteredSlot) private val trackedPlayerOpen = !inventory.player.isSpectator val sort = PlayerInput(NullValueCodec) { - tile?.container?.sort() + tile?.container?.sort(playerSortSettings.actualComparator) } init { - val container = tile?.container ?: SimpleContainer(CargoCrateBlockEntity.CAPACITY) - - storageSlots = immutableList(CargoCrateBlockEntity.CAPACITY) { - addStorageSlot(UserFilteredSlot(container, it)) - } - if (trackedPlayerOpen) { tile?.onPlayerOpen() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt index 6b1f0253e..0968010bd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt @@ -1,32 +1,31 @@ package ru.dbotthepony.mc.otm.menu.decorative -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 ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.block.entity.decorative.CargoCrateBlockEntity +import ru.dbotthepony.mc.otm.container.sort +import ru.dbotthepony.mc.otm.core.util.NullValueCodec import ru.dbotthepony.mc.otm.entity.MinecartCargoCrate import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.makeSlots import ru.dbotthepony.mc.otm.registry.MMenus -class MinecartCargoCrateMenu @JvmOverloads constructor( - p_38852_: Int, +class MinecartCargoCrateMenu( + containerId: Int, inventory: Inventory, val cart: MinecartCargoCrate? = null -) : MatteryMenu(MMenus.CARGO_CRATE, p_38852_, inventory) { - val storageSlots: List +) : MatteryMenu(MMenus.CARGO_CRATE, containerId, inventory) { + val storageSlots = makeSlots(cart ?: SimpleContainer(CargoCrateBlockEntity.CAPACITY), ::MatterySlot) private val trackedPlayerOpen = !inventory.player.isSpectator + val sort = PlayerInput(NullValueCodec) { + cart?.sort(playerSortSettings.actualComparator) + } + init { - val container = cart as Container? ?: SimpleContainer(CargoCrateBlockEntity.CAPACITY) - - storageSlots = immutableList(CargoCrateBlockEntity.CAPACITY) { - addStorageSlot(MatterySlot(container, it)) - } - if (trackedPlayerOpen) { cart?.onPlayerOpen() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt index 98e96e49d..95216979a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt @@ -22,6 +22,7 @@ import ru.dbotthepony.mc.otm.core.util.codec import ru.dbotthepony.mc.otm.core.util.writeCollection import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphListener import ru.dbotthepony.mc.otm.graph.matter.MatterGraph +import ru.dbotthepony.mc.otm.menu.IItemSortingSettings import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback import ru.dbotthepony.mc.otm.network.* @@ -142,10 +143,10 @@ class MatterPanelMenu( } private fun updateComparators() { - var p = sorting.map(PatternState::item) - var t = sorting.map(ReplicationTask::item) + var p = settings.sorting.map(PatternState::item) + var t = settings.sorting.map(ReplicationTask::item) - if (!isAscending) { + if (!settings.isAscending) { p = p.reversed() t = t.reversed() } @@ -154,20 +155,7 @@ class MatterPanelMenu( taskComparator = t } - var sorting: ItemSorter by GetterSetter.of( - mSynchronizer.ComputedField( - getter = { tile?.getPlayerSettings(player)?.sorter ?: ItemSorter.DEFAULT }, - codec = ItemSorter::class.codec(), - observer = { updateComparators() }), - PlayerInput(ItemSorter::class.codec(), allowSpectators = true) { tile?.getPlayerSettings(player)?.sorter = it } - ) - - var isAscending: Boolean by GetterSetter.of( - mSynchronizer.ComputedBooleanField( - getter = { tile?.getPlayerSettings(player)?.ascending ?: true }, - observer = { updateComparators() }), - booleanInput(allowSpectators = true) { tile?.getPlayerSettings(player)?.ascending = it } - ) + val settings = IItemSortingSettings.inputs(this, tile?.getPlayerSettings(player), ::updateComparators) var isProvidingTasks by BooleanInputWithFeedback(this, tile?.let { it::isProvidingTasks }) val cancelAll = PlayerInput(NullValueCodec) { tile?.dropAllTasks() } @@ -196,7 +184,7 @@ class MatterPanelMenu( } } - private var patternComparator = sorting.map(PatternState::item) + private var patternComparator = settings.sorting.map(PatternState::item) set(value) { if (value != field) { field = value @@ -205,7 +193,7 @@ class MatterPanelMenu( } } - private var taskComparator = sorting.map(ReplicationTask::item) + private var taskComparator = settings.sorting.map(ReplicationTask::item) set(value) { if (value != field) { field = value From 48f933920c2de661ce99c569a2f5ae6685dbba8f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 20 Aug 2023 17:44:09 +0700 Subject: [PATCH 1005/1199] Don't pickup items into exopack inventory if we somehow have no exopack --- .../mc/otm/capability/MatteryPlayerCapability.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 157a5b1ea..5fa18e795 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -1378,7 +1378,12 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial * This re-implement [Inventory.add] logic (original method is redirected to this) */ fun inventoryAddImpl(stack: ItemStack): Boolean { - inventoryAndExopack.consumeItem(stack, false, popTime = 5) + if (hasExopack) { + inventoryAndExopack.consumeItem(stack, false, popTime = 5) + } else { + wrappedItemInventory.consumeItem(stack, false, popTime = 5) + } + MinecraftForge.EVENT_BUS.post(ItemStackLeftoverEvent(stack, this)) if (ply.abilities.instabuild) { From b31114ba0912cafbf451647d8af9666325468f05 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 20 Aug 2023 17:45:39 +0700 Subject: [PATCH 1006/1199] Also don't add exopack slots to menus if we don't have exopack --- src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 8f8e31ef9..0c3dc50d4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -327,7 +327,7 @@ abstract class MatteryMenu( mapQuickMoveToInventory(offhandSlot!!) addSlot(offhandSlot!!) - for (i in 0 until mattery.combinedInventory.containerSize) { + for (i in 0 until if (mattery.hasExopack) mattery.combinedInventory.containerSize else mattery.wrappedItemInventory.containerSize) { if (i in Inventory.INVENTORY_SIZE .. player.inventory.containerSize) continue val slot = InventorySlot(mattery.combinedInventory, i, true) From 7d05332a90aedce9e4b8eb24cd962e1ae172fd7b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 20 Aug 2023 20:19:54 +0700 Subject: [PATCH 1007/1199] Update hover check code to properly determine hover status in case of overlapping panels --- .../mc/otm/client/screen/MatteryScreen.kt | 10 +-- .../otm/client/screen/panels/EditablePanel.kt | 85 ++++++++++++------- 2 files changed, 61 insertions(+), 34 deletions(-) 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 ef2495a9f..cdb1be997 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 @@ -104,7 +104,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit RenderSystem.depthFunc(GL11.GL_ALWAYS) graphics.renderItemDecorations( - font, + super.font, itemstack, 1, 1, @@ -533,7 +533,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit override fun mouseReleased(p_97812_: Double, p_97813_: Double, p_97814_: Int): Boolean { if (lastDragSlot != null) { - if (isQuickCrafting) { + if (super.isQuickCrafting) { returnSlot = lastDragSlot val ret = super.mouseReleased(p_97812_, p_97813_, p_97814_) returnSlot = null @@ -644,7 +644,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit // dark background this.renderBackground(graphics) - hoveredSlot = null + super.hoveredSlot = null var hovered = false for (panel in panels) { @@ -692,7 +692,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit val i2 = if (draggingItem.isEmpty) 8 else 16 var overrideCount: String? = null - if (isQuickCrafting && quickCraftSlots.size > 1) { + if (super.isQuickCrafting && super.quickCraftSlots.size > 1) { itemstack = itemstack.copy() itemstack.count = quickCraftingRemainder @@ -706,7 +706,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } if (menu.carried.isEmpty) { - val hoveredSlot = hoveredSlot + val hoveredSlot = super.hoveredSlot if (hoveredSlot != null && hoveredSlot.hasItem()) { this.renderTooltip(graphics, mouseX, mouseY) 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 3742af760..d8360abcd 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 @@ -25,6 +25,9 @@ import ru.dbotthepony.mc.otm.client.render.popScissorRect import ru.dbotthepony.mc.otm.client.render.pushScissorRect import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.input.QueryUserPanel +import ru.dbotthepony.mc.otm.core.collect.any +import ru.dbotthepony.mc.otm.core.collect.concatIterators +import ru.dbotthepony.mc.otm.core.collect.flatMap import java.util.* import kotlin.collections.ArrayList import kotlin.math.roundToInt @@ -260,9 +263,18 @@ open class EditablePanel @JvmOverloads constructor( private val childrenInternal = ArrayList>() private val visibleChildrenInternal = ArrayList>() + val children: List> = Collections.unmodifiableList(childrenInternal) val visibleChildren: List> = Collections.unmodifiableList(visibleChildrenInternal) + val allPanels: Iterator> get() { + return concatIterators(listOf(this).iterator(), childrenInternal.iterator().flatMap { it.allPanels }) + } + + val allVisiblePanels: Iterator> get() { + return concatIterators(listOf(this).iterator(), visibleChildrenInternal.iterator().flatMap { it.allVisiblePanels }) + } + var layoutInvalidated = true private set var boundsInvalidated = true @@ -649,6 +661,9 @@ open class EditablePanel @JvmOverloads constructor( var absoluteY = 0f private set + /** + * If this exact panel is hovered. Panel is not considered hovered if any of its children are hovered + */ var isHovered = false private set(value) { if (value == field) { @@ -661,6 +676,13 @@ open class EditablePanel @JvmOverloads constructor( onHoverUpdate(old, value) } + /** + * If this panel or any of its children are hovered + */ + val isEverHovered: Boolean get() { + return isHovered || visibleChildrenInternal.any { it.isEverHovered } + } + fun unsetHovered() { isHovered = false @@ -772,7 +794,7 @@ open class EditablePanel @JvmOverloads constructor( } protected open fun shouldRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { - return isHovered || isGrabbingMouseInput() + return isEverHovered || isGrabbingMouseInput() } fun isVisible(): Boolean { @@ -835,16 +857,6 @@ open class EditablePanel @JvmOverloads constructor( if (parent == null) { absoluteX = x absoluteY = y - } else { - if ((x < 0f || y < 0f || x + width > parent.width || y + height > parent.height) && parent.parent == null) { - // no op - we updated ourselves in tickHover - } else { - isHovered = parent.isHovered && - mouseX >= absoluteX && - mouseX < absoluteX + width && - mouseY >= absoluteY && - mouseY < absoluteY + height - } } } @@ -893,35 +905,50 @@ open class EditablePanel @JvmOverloads constructor( } } - open fun tickHover(mouseX: Float, mouseY: Float): Boolean { - if (isRemoved) { - return false + fun updateAbsolutePosition() { + val parent = parent + + if (parent == null) { + absoluteX = x + absoluteY = y + } else { + absoluteX = parent.absoluteX + x + parent.xOffset + absoluteY = parent.absoluteY + y + parent.yOffset } - if ((childrenRectHeight > height || childrenRectWidth > width || childrenRectX < 0 || childrenRectY < 0) && parent == null) { + for (child in visibleChildrenInternal) { + child.updateAbsolutePosition() + } + } + + fun tickHover(mouseX: Float, mouseY: Float): Boolean { + if (isRemoved) + return false + + if (parent == null) + updateAbsolutePosition() + + if (mouseX in absoluteX ..< absoluteX + childrenRectWidth.coerceAtLeast(width) && mouseY in absoluteY ..< absoluteY + childrenRectHeight.coerceAtLeast(height)) { var hit = false - for (child in childrenInternal) { - if (child.tickHover(mouseX, mouseY)) { + for (child in visibleChildrenInternal) { + if (hit) { + child.unsetHovered() + } else if (child.tickHover(mouseX, mouseY)) { hit = true } } - isHovered = mouseX >= absoluteX && - mouseX <= absoluteX + width && - mouseY >= absoluteY && - mouseY <= absoluteY + height + isHovered = + !hit && + mouseX in absoluteX ..< absoluteX + width && + mouseY in absoluteY ..< absoluteY + height return hit || isHovered + } else { + unsetHovered() + return false } - - isHovered = - mouseX >= absoluteX && - mouseX <= absoluteX + width && - mouseY >= absoluteY && - mouseY <= absoluteY + height - - return isHovered } fun findSlot(mouseX: Float, mouseY: Float): Pair { From f26e336785aed17d79da7deb30d96c68e19400ed Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 20 Aug 2023 20:29:15 +0700 Subject: [PATCH 1008/1199] Fix off by one error --- src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 0c3dc50d4..c114b676b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -328,7 +328,7 @@ abstract class MatteryMenu( addSlot(offhandSlot!!) for (i in 0 until if (mattery.hasExopack) mattery.combinedInventory.containerSize else mattery.wrappedItemInventory.containerSize) { - if (i in Inventory.INVENTORY_SIZE .. player.inventory.containerSize) continue + if (i in Inventory.INVENTORY_SIZE until player.inventory.containerSize) continue val slot = InventorySlot(mattery.combinedInventory, i, true) From 464e1aa57993cd1dbe2b097ee1613e853146412e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 20 Aug 2023 20:35:20 +0700 Subject: [PATCH 1009/1199] Fix root frame children outside frame bounds not receiving isHovered flag --- .../mc/otm/client/screen/panels/EditablePanel.kt | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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 d8360abcd..b18ff638d 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 @@ -925,10 +925,20 @@ open class EditablePanel @JvmOverloads constructor( if (isRemoved) return false - if (parent == null) - updateAbsolutePosition() + val potentiallyHovered: Boolean - if (mouseX in absoluteX ..< absoluteX + childrenRectWidth.coerceAtLeast(width) && mouseY in absoluteY ..< absoluteY + childrenRectHeight.coerceAtLeast(height)) { + if (parent == null) { + updateAbsolutePosition() + potentiallyHovered = + mouseX in absoluteX + childrenRectX.coerceAtMost(0f) ..< absoluteX + childrenRectWidth.coerceAtLeast(width) && + mouseY in absoluteY + childrenRectY.coerceAtMost(0f) ..< absoluteY + childrenRectHeight.coerceAtLeast(height) + } else { + potentiallyHovered = + mouseX in absoluteX ..< absoluteX + width && + mouseY in absoluteY ..< absoluteY + height + } + + if (potentiallyHovered) { var hit = false for (child in visibleChildrenInternal) { From bd8e350d103d27618714750d5683e7cbd77a3edb Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 20 Aug 2023 20:40:22 +0700 Subject: [PATCH 1010/1199] Move expanded inventory patches to vanilla compat subpackage --- .../kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt | 2 +- .../mc/otm/compat/{ => vanilla}/ExtendedInventoryHandler.kt | 2 +- .../kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/compat/{ => vanilla}/ExtendedInventoryHandler.kt (99%) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt index ae7c9b1de..35038c0c6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt @@ -24,7 +24,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.Panel2Widget -import ru.dbotthepony.mc.otm.compat.InventoryScrollPacket +import ru.dbotthepony.mc.otm.compat.vanilla.InventoryScrollPacket import ru.dbotthepony.mc.otm.compat.cos.isCosmeticArmorScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.integerDivisionUp diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/ExtendedInventoryHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/ExtendedInventoryHandler.kt similarity index 99% rename from src/main/kotlin/ru/dbotthepony/mc/otm/compat/ExtendedInventoryHandler.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/ExtendedInventoryHandler.kt index 6c3a612cc..f231b30a0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/ExtendedInventoryHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/ExtendedInventoryHandler.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.compat +package ru.dbotthepony.mc.otm.compat.vanilla import it.unimi.dsi.fastutil.ints.Int2ObjectAVLTreeMap import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt index c49564815..0cd9cfa71 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt @@ -7,7 +7,7 @@ import net.minecraftforge.network.NetworkDirection import net.minecraftforge.network.NetworkEvent import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.compat.InventoryScrollPacket +import ru.dbotthepony.mc.otm.compat.vanilla.InventoryScrollPacket import ru.dbotthepony.mc.otm.menu.ExopackInventoryMenu import ru.dbotthepony.mc.otm.menu.matter.CancelTaskPacket import ru.dbotthepony.mc.otm.menu.MatteryMenu From 4c94e92b90cd7f46e0145c0f2a577f09a28cc22e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 20 Aug 2023 21:20:56 +0700 Subject: [PATCH 1011/1199] Add missing addStorageSlot call --- .../ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt | 1 + .../dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt index d02b2af7b..2e51dcd82 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt @@ -31,6 +31,7 @@ class CargoCrateMenu( tile?.onPlayerOpen() } + addStorageSlot(storageSlots) addInventorySlots() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt index 0968010bd..a8d86e87c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt @@ -30,6 +30,7 @@ class MinecartCargoCrateMenu( cart?.onPlayerOpen() } + addStorageSlot(storageSlots) addInventorySlots() } From e94a267ac150f637156280b92e61e6d21aa4b190 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 20 Aug 2023 22:31:52 +0700 Subject: [PATCH 1012/1199] Make sorting be performed on client, and sorted slot list be sent to server --- .../client/screen/ExopackInventoryScreen.kt | 8 +-- .../mc/otm/client/screen/MatteryScreen.kt | 2 +- .../screen/decorative/CargoCrateScreen.kt | 2 +- .../decorative/MinecartCargoCrateScreen.kt | 2 +- .../client/screen/panels/button/Buttons.kt | 8 +-- .../mc/otm/container/ContainerHelpers.kt | 64 ++++++++++++++++++- .../mc/otm/core/util/StreamCodecs.kt | 29 +++++++++ .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 24 +++++-- .../mc/otm/menu/decorative/CargoCrateMenu.kt | 8 +-- .../menu/decorative/MinecartCargoCrateMenu.kt | 8 +-- 10 files changed, 127 insertions(+), 28 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt index 5a43c252d..7b4ba00f9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt @@ -271,14 +271,8 @@ class ExopackInventoryScreen(menu: ExopackInventoryMenu) : MatteryScreen) - if (menu.sortInventoryInput != null) { - controls.addButton(LargeRectangleButtonPanel.input( - this, - controls, - menu.sortInventoryInput!!, - icon = Widgets18.SORT_NOW - ).also { it.tooltips.add(TranslatableComponent("otm.gui.sorting.sort_now")) }) + controls.customSortingButtons(menu.sortInventoryInput!!) } var x = -4f 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 cdb1be997..051719dfa 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 @@ -308,7 +308,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } if (menu.sortInventoryInput != null) { - deviceControls.customSortingButtons(menu.playerSortSettings, menu.sortInventoryInput!!) + deviceControls.customSortingButtons(menu.sortInventoryInput!!) } if (menu.exopackChargeSlots.isNotEmpty()) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt index 55967a4c6..642fc76eb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt @@ -28,7 +28,7 @@ class CargoCrateScreen(menu: CargoCrateMenu, inventory: Inventory, title: Compon val controls = DeviceControls(this, frame) - controls.customSortingButtons(menu.playerSortSettings, menu.sort) + controls.customSortingButtons(menu.sort) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/MinecartCargoCrateScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/MinecartCargoCrateScreen.kt index 30b8af8cd..3b9cfbc8f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/MinecartCargoCrateScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/MinecartCargoCrateScreen.kt @@ -23,7 +23,7 @@ class MinecartCargoCrateScreen(menu: MinecartCargoCrateMenu, inventory: Inventor val controls = DeviceControls(this, frame) - controls.customSortingButtons(menu.playerSortSettings, menu.sort) + controls.customSortingButtons(menu.sort) return frame } 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 4abe11ac9..0a3b3a331 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 @@ -410,7 +410,7 @@ class DeviceControls>( return result } - fun customSortingButtons(settings: IItemStackSortingSettings, input: MatteryMenu.PlayerInput) { + fun customSortingButtons(input: MatteryMenu.SortInput) { addButton(object : LargeRectangleButtonPanel(screen, this@DeviceControls) { var buttons: List>? = null @@ -427,15 +427,15 @@ class DeviceControls>( } override var isDisabled: Boolean - get() = !input.test(minecraft.player) + get() = !input.input.test(minecraft.player) set(value) {} override fun onClick(mouseButton: Int) { if (mouseButton == InputConstants.MOUSE_BUTTON_LEFT) { - input.accept(null) + input.clientInput() } else { if (buttons == null) { - buttons = sortingButtons(settings::isAscending.asGetterSetter(), settings::sorting.asGetterSetter(), ItemStackSorter.DEFAULT) { + buttons = sortingButtons(input.settings::isAscending.asGetterSetter(), input.settings::sorting.asGetterSetter(), ItemStackSorter.DEFAULT) { for (v in ItemStackSorter.entries) { add(v, v.icon, v.title) } 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 627492193..ad2c35539 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHelpers.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHelpers.kt @@ -3,8 +3,10 @@ package ru.dbotthepony.mc.otm.container import it.unimi.dsi.fastutil.ints.IntAVLTreeSet import it.unimi.dsi.fastutil.ints.IntArrayList import it.unimi.dsi.fastutil.ints.IntArraySet +import it.unimi.dsi.fastutil.ints.IntCollection import it.unimi.dsi.fastutil.ints.IntIterable import it.unimi.dsi.fastutil.ints.IntIterator +import it.unimi.dsi.fastutil.ints.IntList import it.unimi.dsi.fastutil.ints.IntSet import it.unimi.dsi.fastutil.objects.Object2ObjectFunction import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap @@ -16,11 +18,10 @@ import net.minecraft.world.item.enchantment.EnchantmentHelper.hasVanishingCurse import net.minecraftforge.fluids.capability.IFluidHandler import ru.dbotthepony.mc.otm.container.util.IContainerSlot import ru.dbotthepony.mc.otm.container.util.ItemStackHashStrategy +import ru.dbotthepony.mc.otm.container.util.containerSlot 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.map -import ru.dbotthepony.mc.otm.core.collect.max import ru.dbotthepony.mc.otm.core.collect.toList import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.core.map @@ -318,3 +319,62 @@ fun Container.sort(comparator: Comparator = ItemStackSorter.DEFAULT) slots.forEach { it.remove() } sortedItems.forEach { addItem(it, false) } } + +fun Container.sortWithIndices(sortedSlots: IntCollection) { + if (sortedSlots.isEmpty() || isEmpty) + return + + val seen = IntAVLTreeSet() + val valid = ArrayList() + + val iterator = sortedSlots.intIterator() + + while (iterator.hasNext()) { + val value = iterator.nextInt() + + if (value in 0 until containerSize && seen.add(value)) { + val slot = containerSlot(value) + + if (slot.isNotEmpty && !slot.isForbiddenForAutomation && slot.item.count <= slot.getMaxStackSize()) { + valid.add(slot) + } + } + } + + if (valid.isEmpty()) + return + + val items = valid.map { it.item.copy() } + valid.forEach { it.remove() } + items.forEach { addItem(it, false) } +} + +fun Container.computeSortedIndices(comparator: Comparator = ItemStackSorter.DEFAULT): IntList { + if (isEmpty) + return IntList.of() + + val slots = slotIterator().filter { !it.isForbiddenForAutomation && it.getMaxStackSize() >= it.item.count }.toList() + + if (slots.isEmpty()) + return IntList.of() + + val items = Object2ObjectOpenCustomHashMap>(ItemStackHashStrategy) + + slots.forEach { + val get = items[it.item] + + if (get == null) { + items[it.item] = it.item.copy() to IntArrayList().also { s -> s.add(it.slot) } + } else { + get.first.count += it.item.count + get.second.add(it.slot) + } + } + + val sortedItems = ObjectArrayList(items.values) + sortedItems.sortWith(comparator.map { it.first }) + + val result = IntArrayList() + sortedItems.forEach { result.addAll(it.second) } + return result +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt index 55148826b..b7b55910e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt @@ -105,6 +105,35 @@ class StreamCodec( } } +class CollectionStreamCodec>(val elementCodec: IStreamCodec, val collectionFactory: (Int) -> C) : IStreamCodec { + override fun read(stream: DataInputStream, sizeLimit: NbtAccounter): C { + val size = stream.readVarIntLE(sizeLimit) + + if (size <= 0) { + return collectionFactory.invoke(0) + } + + val collection = collectionFactory.invoke(size) + + for (i in 0 until size) { + collection.add(elementCodec.read(stream, sizeLimit)) + } + + return collection + } + + override fun write(stream: DataOutputStream, value: C) { + stream.writeVarIntLE(value.size) + value.forEach { elementCodec.write(stream, it) } + } + + override fun copy(value: C): C { + val new = collectionFactory.invoke(value.size) + value.forEach { new.add(elementCodec.copy(it)) } + return new + } +} + val NullValueCodec = StreamCodec({ _, _ -> null }, { _, _ -> }) val BooleanValueCodec = StreamCodec(DataInputStream::readBoolean, 1L, DataOutputStream::writeBoolean) { a, b -> a == b } val ByteValueCodec = StreamCodec(DataInputStream::readByte, 1L, { s, v -> s.writeByte(v.toInt()) }) { a, b -> a == b } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index c114b676b..11dda4464 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -2,6 +2,9 @@ package ru.dbotthepony.mc.otm.menu import com.google.common.collect.ImmutableList import com.mojang.datafixers.util.Pair +import it.unimi.dsi.fastutil.ints.IntArrayList +import it.unimi.dsi.fastutil.ints.IntCollection +import it.unimi.dsi.fastutil.ints.IntList import it.unimi.dsi.fastutil.io.FastByteArrayInputStream import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream import it.unimi.dsi.fastutil.objects.Reference2ObjectFunction @@ -36,7 +39,9 @@ import ru.dbotthepony.mc.otm.compat.curios.isCurioSlot import ru.dbotthepony.mc.otm.container.IMatteryContainer import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.container.UpgradeContainer +import ru.dbotthepony.mc.otm.container.computeSortedIndices import ru.dbotthepony.mc.otm.container.sort +import ru.dbotthepony.mc.otm.container.sortWithIndices import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.collect.ConditionalEnumSet import ru.dbotthepony.mc.otm.core.collect.ConditionalSet @@ -45,6 +50,7 @@ import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.util.BigDecimalValueCodec import ru.dbotthepony.mc.otm.core.util.BinaryStringCodec import ru.dbotthepony.mc.otm.core.util.BooleanValueCodec +import ru.dbotthepony.mc.otm.core.util.CollectionStreamCodec import ru.dbotthepony.mc.otm.core.util.IStreamCodec import ru.dbotthepony.mc.otm.core.util.ItemStackValueCodec import ru.dbotthepony.mc.otm.core.util.ItemValueCodec @@ -173,6 +179,18 @@ abstract class MatteryMenu( } } + inner class SortInput(val container: Container, settings: IItemStackSortingSettings?) { + val settings = IItemStackSortingSettings.inputs(this@MatteryMenu, settings) + + val input = PlayerInput(CollectionStreamCodec(VarIntValueCodec, ::IntArrayList) as IStreamCodec) { + container.sortWithIndices(it) + } + + fun clientInput() { + input.accept(container.computeSortedIndices(settings.actualComparator)) + } + } + fun oneWayInput(allowSpectators: Boolean = false, handler: () -> Unit): PlayerInput { return PlayerInput(NullValueCodec, allowSpectators) { handler.invoke() @@ -206,7 +224,7 @@ abstract class MatteryMenu( val exopackPowerLevel = ProfiledLevelGaugeWidget>(mSynchronizer) - var sortInventoryInput: PlayerInput? = null + var sortInventoryInput: SortInput? = null private set val playerSortSettings = IItemStackSortingSettings.inputs(this, player.matteryPlayer?.sortingSettings) @@ -353,9 +371,7 @@ abstract class MatteryMenu( exopackPowerLevel.with(mattery.exopackEnergy) } - sortInventoryInput = PlayerInput(NullValueCodec) { - mattery.inventoryAndExopackNoHotbar.sort(playerSortSettings.actualComparator) - } + sortInventoryInput = SortInput(mattery.inventoryAndExopackNoHotbar, playerSortSettings) } private var broadcastOnce = false diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt index 2e51dcd82..eb438a19b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/CargoCrateMenu.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.menu.decorative +import net.minecraft.world.Container import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player @@ -19,12 +20,11 @@ class CargoCrateMenu( inventory: Inventory, tile: CargoCrateBlockEntity? = null ) : MatteryMenu(MMenus.CARGO_CRATE, containerId, inventory, tile) { - val storageSlots = makeSlots(tile?.container ?: SimpleContainer(CargoCrateBlockEntity.CAPACITY), ::UserFilteredSlot) + val actualContainer: Container = tile?.container ?: SimpleContainer(CargoCrateBlockEntity.CAPACITY) + val storageSlots = makeSlots(actualContainer, ::UserFilteredSlot) private val trackedPlayerOpen = !inventory.player.isSpectator - val sort = PlayerInput(NullValueCodec) { - tile?.container?.sort(playerSortSettings.actualComparator) - } + val sort = SortInput(actualContainer, playerSortSettings) init { if (trackedPlayerOpen) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt index a8d86e87c..7ce6c9f23 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.menu.decorative +import net.minecraft.world.Container import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player @@ -17,13 +18,12 @@ class MinecartCargoCrateMenu( inventory: Inventory, val cart: MinecartCargoCrate? = null ) : MatteryMenu(MMenus.CARGO_CRATE, containerId, inventory) { - val storageSlots = makeSlots(cart ?: SimpleContainer(CargoCrateBlockEntity.CAPACITY), ::MatterySlot) + val actualContainer: Container = cart ?: SimpleContainer(CargoCrateBlockEntity.CAPACITY) + val storageSlots = makeSlots(actualContainer, ::MatterySlot) private val trackedPlayerOpen = !inventory.player.isSpectator - val sort = PlayerInput(NullValueCodec) { - cart?.sort(playerSortSettings.actualComparator) - } + val sort = SortInput(actualContainer, playerSortSettings) init { if (trackedPlayerOpen) { From 9244de0ac27372e46c4fecf078d694cbfeeae1a6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 20 Aug 2023 23:36:13 +0700 Subject: [PATCH 1013/1199] Vanilla chests with OTM gui --- .../client/screen/ExopackInventoryScreen.kt | 2 +- .../mc/otm/client/screen/MatteryScreen.kt | 3 +- .../screen/decorative/CargoCrateScreen.kt | 6 +- .../decorative/MinecartCargoCrateScreen.kt | 2 +- .../client/screen/panels/button/Buttons.kt | 3 +- .../mc/otm/compat/vanilla/MatteryChestMenu.kt | 105 ++++++++++++++++++ .../otm/compat/vanilla/MatteryChestScreen.kt | 31 ++++++ .../dbotthepony/mc/otm/registry/MRegistry.kt | 2 + src/main/resources/META-INF/coremods.json | 3 +- src/main/resources/coremods/chest_menus.js | 104 +++++++++++++++++ 10 files changed, 249 insertions(+), 12 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/MatteryChestMenu.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/MatteryChestScreen.kt create mode 100644 src/main/resources/coremods/chest_menus.js diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt index 7b4ba00f9..ad9426d39 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt @@ -272,7 +272,7 @@ class ExopackInventoryScreen(menu: ExopackInventoryMenu) : MatteryScreen) if (menu.sortInventoryInput != null) { - controls.customSortingButtons(menu.sortInventoryInput!!) + controls.sortingButtons(menu.sortInventoryInput!!) } var x = -4f 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 051719dfa..02a671a0b 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 @@ -23,7 +23,6 @@ import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.render.translation 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.button.LargeRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.InventorySlotPanel @@ -308,7 +307,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } if (menu.sortInventoryInput != null) { - deviceControls.customSortingButtons(menu.sortInventoryInput!!) + deviceControls.sortingButtons(menu.sortInventoryInput!!) } if (menu.exopackChargeSlots.isNotEmpty()) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt index 642fc76eb..26bb90d13 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt @@ -2,15 +2,11 @@ package ru.dbotthepony.mc.otm.client.screen.decorative import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory -import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.button.DeviceControls -import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel -import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.UserFilteredSlotPanel -import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.menu.decorative.CargoCrateMenu class CargoCrateScreen(menu: CargoCrateMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { @@ -28,7 +24,7 @@ class CargoCrateScreen(menu: CargoCrateMenu, inventory: Inventory, title: Compon val controls = DeviceControls(this, frame) - controls.customSortingButtons(menu.sort) + controls.sortingButtons(menu.sort) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/MinecartCargoCrateScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/MinecartCargoCrateScreen.kt index 3b9cfbc8f..6a65c2e0f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/MinecartCargoCrateScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/MinecartCargoCrateScreen.kt @@ -23,7 +23,7 @@ class MinecartCargoCrateScreen(menu: MinecartCargoCrateMenu, inventory: Inventor val controls = DeviceControls(this, frame) - controls.customSortingButtons(menu.sort) + controls.sortingButtons(menu.sort) return frame } 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 0a3b3a331..6775e708b 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 @@ -32,7 +32,6 @@ import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.core.util.ItemStackSorter import ru.dbotthepony.mc.otm.core.value -import ru.dbotthepony.mc.otm.menu.IItemStackSortingSettings import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.UpgradeSlots import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback @@ -410,7 +409,7 @@ class DeviceControls>( return result } - fun customSortingButtons(input: MatteryMenu.SortInput) { + fun sortingButtons(input: MatteryMenu.SortInput) { addButton(object : LargeRectangleButtonPanel(screen, this@DeviceControls) { var buttons: List>? = null 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 new file mode 100644 index 000000000..9092f3e61 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/MatteryChestMenu.kt @@ -0,0 +1,105 @@ +package ru.dbotthepony.mc.otm.compat.vanilla + +import net.minecraft.client.gui.screens.MenuScreens +import net.minecraft.core.registries.Registries +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 +import net.minecraftforge.registries.DeferredRegister +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.core.getValue +import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.makeSlots + +class MatteryChestMenu( + type: MenuType<*>, containerId: Int, + inventory: Inventory, val rows: Int, + val container: Container = SimpleContainer(rows * 9) +) : MatteryMenu(type, containerId, inventory) { + val chestSlots = makeSlots(container, ::MatterySlot) + val sort = SortInput(container, playerSortSettings) + + init { + container.startOpen(player) + addStorageSlot(chestSlots) + addInventorySlots() + } + + override fun stillValid(player: Player): Boolean { + return container.stillValid(player) + } + + override fun removed(player: Player) { + super.removed(player) + container.stopOpen(player) + } + + companion object { + private val registrar = DeferredRegister.create(Registries.MENU, OverdriveThatMatters.MOD_ID) + + private val GENERIC_9x1 by registrar.register("generic_9x1") { MenuType(::c9x1, FeatureFlags.VANILLA_SET) } + private val GENERIC_9x2 by registrar.register("generic_9x2") { MenuType(::c9x2, FeatureFlags.VANILLA_SET) } + private val GENERIC_9x3 by registrar.register("generic_9x3") { MenuType(::c9x3, FeatureFlags.VANILLA_SET) } + private val GENERIC_9x4 by registrar.register("generic_9x4") { MenuType(::c9x4, FeatureFlags.VANILLA_SET) } + private val GENERIC_9x5 by registrar.register("generic_9x5") { MenuType(::c9x5, FeatureFlags.VANILLA_SET) } + private val GENERIC_9x6 by registrar.register("generic_9x6") { MenuType(::c9x6, FeatureFlags.VANILLA_SET) } + + @JvmStatic + @JvmOverloads + fun c9x1(containerId: Int, inventory: Inventory, container: Container = SimpleContainer(9)): MatteryChestMenu { + return MatteryChestMenu(GENERIC_9x1, containerId, inventory, 1, container) + } + + @JvmStatic + @JvmOverloads + fun c9x2(containerId: Int, inventory: Inventory, container: Container = SimpleContainer(9 * 2)): MatteryChestMenu { + return MatteryChestMenu(GENERIC_9x2, containerId, inventory, 2, container) + } + + @JvmStatic + @JvmOverloads + fun c9x3(containerId: Int, inventory: Inventory, container: Container = SimpleContainer(9 * 3)): MatteryChestMenu { + return MatteryChestMenu(GENERIC_9x3, containerId, inventory, 3, container) + } + + @JvmStatic + @JvmOverloads + fun c9x4(containerId: Int, inventory: Inventory, container: Container = SimpleContainer(9 * 4)): MatteryChestMenu { + return MatteryChestMenu(GENERIC_9x4, containerId, inventory, 4, container) + } + + @JvmStatic + @JvmOverloads + fun c9x5(containerId: Int, inventory: Inventory, container: Container = SimpleContainer(9 * 5)): MatteryChestMenu { + return MatteryChestMenu(GENERIC_9x5, containerId, inventory, 5, container) + } + + @JvmStatic + @JvmOverloads + fun c9x6(containerId: Int, inventory: Inventory, container: Container = SimpleContainer(9 * 6)): MatteryChestMenu { + return MatteryChestMenu(GENERIC_9x6, containerId, inventory, 6, container) + } + + internal fun register(bus: IEventBus) { + registrar.register(bus) + bus.addListener(this::registerClient) + } + + private fun registerClient(event: FMLClientSetupEvent) { + event.enqueueWork { + MenuScreens.register(GENERIC_9x1, ::MatteryChestScreen) + MenuScreens.register(GENERIC_9x2, ::MatteryChestScreen) + MenuScreens.register(GENERIC_9x3, ::MatteryChestScreen) + MenuScreens.register(GENERIC_9x4, ::MatteryChestScreen) + MenuScreens.register(GENERIC_9x5, ::MatteryChestScreen) + MenuScreens.register(GENERIC_9x6, ::MatteryChestScreen) + } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/MatteryChestScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/MatteryChestScreen.kt new file mode 100644 index 000000000..6441ec5ed --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/MatteryChestScreen.kt @@ -0,0 +1,31 @@ +package ru.dbotthepony.mc.otm.compat.vanilla + +import net.minecraft.network.chat.Component +import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.Dock +import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.DeviceControls +import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel + +class MatteryChestScreen(menu: MatteryChestMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { + override fun makeMainFrame(): FramePanel> { + val frame = FramePanel.padded(this, AbstractSlotPanel.SIZE * 9f, AbstractSlotPanel.SIZE * menu.rows, title) + + frame.makeCloseButton() + frame.onClose { onClose() } + + val grid = GridPanel.slots(this, frame, 9, menu.rows) + grid.dock = Dock.FILL + + for (slot in menu.chestSlots) + SlotPanel(this, grid, slot) + + val controls = DeviceControls(this, frame) + controls.sortingButtons(menu.sort) + + return frame + } +} 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 2101c8ab0..b13877590 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -35,6 +35,7 @@ import ru.dbotthepony.mc.otm.android.feature.NanobotsArmorFeature import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock import ru.dbotthepony.mc.otm.block.decorative.TritaniumPressurePlate import ru.dbotthepony.mc.otm.capability.matteryEnergy +import ru.dbotthepony.mc.otm.compat.vanilla.MatteryChestMenu import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.data.DecimalProvider import ru.dbotthepony.mc.otm.item.weapon.EnergySwordItem @@ -276,6 +277,7 @@ object MRegistry { MLootItemConditions.register(bus) MRecipes.register(bus) StorageStack.register(bus) + MatteryChestMenu.register(bus) if (FMLEnvironment.dist == Dist.CLIENT) { MBlockColors.register(bus) diff --git a/src/main/resources/META-INF/coremods.json b/src/main/resources/META-INF/coremods.json index 0f2a0791b..5ce1ea71b 100644 --- a/src/main/resources/META-INF/coremods.json +++ b/src/main/resources/META-INF/coremods.json @@ -1,3 +1,4 @@ { - "code_injector": "coremods/code_injector.js" + "code_injector": "coremods/code_injector.js", + "chest_menus": "coremods/chest_menus.js" } \ No newline at end of file diff --git a/src/main/resources/coremods/chest_menus.js b/src/main/resources/coremods/chest_menus.js new file mode 100644 index 000000000..588fd0068 --- /dev/null +++ b/src/main/resources/coremods/chest_menus.js @@ -0,0 +1,104 @@ + +var ASMAPI = Java.type('net.minecraftforge.coremod.api.ASMAPI') +var Opcodes = Java.type('org.objectweb.asm.Opcodes') +var MethodNode = Java.type('org.objectweb.asm.tree.MethodNode') +var VarInsnNode = Java.type('org.objectweb.asm.tree.VarInsnNode') +var MethodInsnNode = Java.type('org.objectweb.asm.tree.MethodInsnNode') +var InsnNode = Java.type('org.objectweb.asm.tree.InsnNode') +var TypeInsnNode = Java.type('org.objectweb.asm.tree.TypeInsnNode') + +var classesToPatch = [ + 'net.minecraft.world.entity.vehicle.ChestBoat', + 'net.minecraft.world.level.block.entity.BarrelBlockEntity', + 'net.minecraft.world.level.block.entity.ChestBlockEntity', + 'net.minecraft.world.level.block.EnderChestBlock', + 'net.minecraft.world.entity.vehicle.MinecartChest', + 'net.minecraft.world.level.block.ChestBlock$2$1' +] + +var isOwnPatches = [ + 'net.minecraft.world.level.block.entity.BarrelBlockEntity$1', + 'net.minecraft.world.level.block.entity.ChestBlockEntity$1', +] + +function patchMethod(node) { + if (node.desc.endsWith('AbstractContainerMenu;')) { + var threeRows = ASMAPI.mapMethod('m_39237_') + var sixRows = ASMAPI.mapMethod('m_39246_') + + for (var i = 0; i < node.instructions.size(); i++) { + var instr = node.instructions.get(i) + + if (instr.getOpcode() == Opcodes.INVOKESTATIC && instr.name == threeRows && instr.owner == 'net/minecraft/world/inventory/ChestMenu') { + node.instructions.set(instr, new MethodInsnNode( + Opcodes.INVOKESTATIC, + 'ru/dbotthepony/mc/otm/compat/vanilla/MatteryChestMenu', + 'c9x3', + '(ILnet/minecraft/world/entity/player/Inventory;Lnet/minecraft/world/Container;)Lru/dbotthepony/mc/otm/compat/vanilla/MatteryChestMenu;' + )) + + break + } else if (instr.getOpcode() == Opcodes.INVOKESTATIC && instr.name == sixRows && instr.owner == 'net/minecraft/world/inventory/ChestMenu') { + node.instructions.set(instr, new MethodInsnNode( + Opcodes.INVOKESTATIC, + 'ru/dbotthepony/mc/otm/compat/vanilla/MatteryChestMenu', + 'c9x6', + '(ILnet/minecraft/world/entity/player/Inventory;Lnet/minecraft/world/Container;)Lru/dbotthepony/mc/otm/compat/vanilla/MatteryChestMenu;' + )) + + break + } + } + } +} + +function initializeCoreMod() { + var result = {} + + for (i in classesToPatch) { + var clazz = classesToPatch[i] + + result[clazz] = { + 'target': { + 'type': 'CLASS', + 'name': clazz + }, + 'transformer': function(classNode) { + for (var i = 0; i < classNode.methods.size(); i++) { + patchMethod(classNode.methods.get(i)) + } + + return classNode + } + } + } + + for (i in isOwnPatches) { + var clazz = isOwnPatches[i] + + result[clazz] = { + 'target': { + 'type': 'METHOD', + 'class': clazz, + 'methodName': ASMAPI.mapMethod('m_142718_'), + 'methodDesc': '(Lnet/minecraft/world/entity/player/Player;)Z' + }, + 'transformer': function(node) { + for (var i = 0; i < node.instructions.size(); i++) { + var instr = node.instructions.get(i) + + if ((instr.getOpcode() == Opcodes.INSTANCEOF || instr.getOpcode() == Opcodes.CHECKCAST) && instr.desc == 'net/minecraft/world/inventory/ChestMenu') { + instr.desc = 'ru/dbotthepony/mc/otm/compat/vanilla/MatteryChestMenu' + } else if (instr.getOpcode() == Opcodes.INVOKEVIRTUAL && instr.owner == 'net/minecraft/world/inventory/ChestMenu' && instr.name == ASMAPI.mapMethod('m_39261_')) { + instr.owner = 'ru/dbotthepony/mc/otm/compat/vanilla/MatteryChestMenu' + instr.name = 'getContainer' + } + } + + return node + } + } + } + + return result +} From 7569b3fe0ad822adf25b416ee193cd7374a2e1b1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 20 Aug 2023 23:41:42 +0700 Subject: [PATCH 1014/1199] Display offhand slot even when have no extra slots in exopack --- .../ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt | 6 ++++++ 1 file changed, 6 insertions(+) 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 02a671a0b..64abf7566 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 @@ -238,6 +238,12 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit it.parent = canvas } } + + InventorySlotPanel( + this, + BackgroundPanel.padded(this, inventoryFrame, inventoryFrame!!.width + 2f, inventoryFrame!!.height - 11f - AbstractSlotPanel.SIZE, AbstractSlotPanel.SIZE, AbstractSlotPanel.SIZE), + menu.offhandSlot!! + ).dock = Dock.FILL } else { inventoryFrame = FramePanel>(this, null, 0f, 0f, INVENTORY_FRAME_WIDTH_EXTENDED, BASE_INVENTORY_FRAME_HEIGHT + AbstractSlotPanel.SIZE * inventoryRows, inventory.displayName).also(this::addPanel) inventoryFrame!!.makeHelpButton().addSlotFiltersHelp().also { From 74cf2b42d0a6aedbd70a5078207d3b6ee56bac28 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 20 Aug 2023 23:44:29 +0700 Subject: [PATCH 1015/1199] Add 4 pixel padding on top of chest frames --- .../dbotthepony/mc/otm/compat/vanilla/MatteryChestScreen.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/MatteryChestScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/MatteryChestScreen.kt index 6441ec5ed..e06a76a44 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/MatteryChestScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/MatteryChestScreen.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.compat.vanilla import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel @@ -12,13 +13,14 @@ import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel class MatteryChestScreen(menu: MatteryChestMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { override fun makeMainFrame(): FramePanel> { - val frame = FramePanel.padded(this, AbstractSlotPanel.SIZE * 9f, AbstractSlotPanel.SIZE * menu.rows, title) + val frame = FramePanel.padded(this, AbstractSlotPanel.SIZE * 9f, AbstractSlotPanel.SIZE * menu.rows + 4f, title) frame.makeCloseButton() frame.onClose { onClose() } val grid = GridPanel.slots(this, frame, 9, menu.rows) grid.dock = Dock.FILL + grid.gravity = RenderGravity.BOTTOM_CENTER for (slot in menu.chestSlots) SlotPanel(this, grid, slot) From c760348f724db356c9c37f96e17d1c1a9484f3a9 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 20 Aug 2023 23:49:59 +0700 Subject: [PATCH 1016/1199] Remove unnecessary unchecked cast --- src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 11dda4464..66f71ec48 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -182,7 +182,7 @@ abstract class MatteryMenu( inner class SortInput(val container: Container, settings: IItemStackSortingSettings?) { val settings = IItemStackSortingSettings.inputs(this@MatteryMenu, settings) - val input = PlayerInput(CollectionStreamCodec(VarIntValueCodec, ::IntArrayList) as IStreamCodec) { + val input = PlayerInput(CollectionStreamCodec(VarIntValueCodec, ::IntArrayList)) { container.sortWithIndices(it) } From dd91bd2f178aadbabc533493fd364e7423180247 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 21 Aug 2023 00:10:31 +0700 Subject: [PATCH 1017/1199] Add sorting buttons to ender chest inside exopack menu --- .../otm/capability/MatteryPlayerCapability.kt | 7 +-- .../client/screen/ExopackInventoryScreen.kt | 26 ++++---- .../client/screen/panels/button/Buttons.kt | 60 ++++++++++++------- .../mc/otm/menu/ExopackInventoryMenu.kt | 7 ++- .../mc/otm/menu/ISortingSettings.kt | 10 ++++ 5 files changed, 71 insertions(+), 39 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 5fa18e795..94965416b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -404,10 +404,8 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial return _exoPackMenu!! } - val sortingSettings = object : IItemStackSortingSettings { - override var isAscending: Boolean = true - override var sorting: ItemStackSorter = ItemStackSorter.DEFAULT - } + val sortingSettings = IItemStackSortingSettings.Impl() + val enderSortingSettings = IItemStackSortingSettings.Impl() fun recreateExoPackMenu() { _exoPackMenu = ExopackInventoryMenu(this) @@ -600,6 +598,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial savetables.bool(::exopackGlows) savetables.stateful(::sortingSettings) + savetables.stateful(::enderSortingSettings) } fun invalidateNetworkState() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt index ad9426d39..ca3de74ea 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt @@ -6,6 +6,7 @@ import net.minecraft.world.item.Items import ru.dbotthepony.mc.otm.client.mousePos import ru.dbotthepony.mc.otm.client.moveMousePosScaled import ru.dbotthepony.mc.otm.client.render.ItemStackIcon +import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.render.sprites.sprite @@ -16,6 +17,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.InventorySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.setMousePos import ru.dbotthepony.mc.otm.client.shouldOpenVanillaInventory @@ -205,11 +207,9 @@ class ExopackInventoryScreen(menu: ExopackInventoryMenu) : MatteryScreen> makeFluidConfigPanel( class DeviceControls>( screen: S, - parent: FramePanel, + parent: EditablePanel<*>, extra: Iterable> = listOf(), val redstoneConfig: IPlayerInputWithFeedback? = null, val itemConfig: ItemConfigPlayerInput? = null, @@ -409,48 +409,61 @@ class DeviceControls>( return result } - fun sortingButtons(input: MatteryMenu.SortInput) { - addButton(object : LargeRectangleButtonPanel(screen, this@DeviceControls) { + fun sortingButtons(input: MatteryMenu.SortInput, unfoldableSettings: Boolean = true) { + object : LargeRectangleButtonPanel(screen, this@DeviceControls) { var buttons: List>? = null init { tooltips.add(TranslatableComponent("otm.gui.sorting.sort_now")) - tooltips.add(TextComponent("")) - tooltips.add(TranslatableComponent("otm.gui.sorting.sort_settings").withStyle(ChatFormatting.GRAY)) + + if (unfoldableSettings) { + tooltips.add(TextComponent("")) + tooltips.add(TranslatableComponent("otm.gui.sorting.sort_settings").withStyle(ChatFormatting.GRAY)) + } icon = Widgets18.SORT_NOW + + addButton(this) + + if (!unfoldableSettings) { + makeButtons() + } } override fun test(value: Int): Boolean { - return value == InputConstants.MOUSE_BUTTON_LEFT || value == InputConstants.MOUSE_BUTTON_RIGHT + return value == InputConstants.MOUSE_BUTTON_LEFT || unfoldableSettings && value == InputConstants.MOUSE_BUTTON_RIGHT } override var isDisabled: Boolean get() = !input.input.test(minecraft.player) set(value) {} + private fun makeButtons() { + buttons = sortingButtons(input.settings::isAscending.asGetterSetter(), input.settings::sorting.asGetterSetter(), ItemStackSorter.DEFAULT) { + for (v in ItemStackSorter.entries) { + add(v, v.icon, v.title) + } + + finish() + } + + buttons!!.forEach { removeButton(it) } + buttons!!.forEach { addButton(it as EditablePanel, this) } + } + override fun onClick(mouseButton: Int) { if (mouseButton == InputConstants.MOUSE_BUTTON_LEFT) { input.clientInput() } else { if (buttons == null) { - buttons = sortingButtons(input.settings::isAscending.asGetterSetter(), input.settings::sorting.asGetterSetter(), ItemStackSorter.DEFAULT) { - for (v in ItemStackSorter.entries) { - add(v, v.icon, v.title) - } - - finish() - } - - buttons!!.forEach { removeButton(it) } - buttons!!.forEach { addButton(it as EditablePanel, this) } + makeButtons() } else { buttons!!.forEach { it.remove() } buttons = null } } } - }) + } } init { @@ -612,14 +625,19 @@ class DeviceControls>( } override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { - x = (parent?.width ?: 0f) + 3f - y = dockTop + if (parent is FramePanel<*>) { + x = parent!!.width + 3f + y = dockTop + } } override fun tickInner() { super.tickInner() - x = (parent?.width ?: 0f) + 3f - y = dockTop + + if (parent is FramePanel<*>) { + x = parent!!.width + 3f + y = dockTop + } } // не съедаем ввод мыши diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt index 21d2562cf..d93732cb3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt @@ -11,8 +11,6 @@ import net.minecraft.world.inventory.* import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.compat.curios.curiosSlots -import ru.dbotthepony.mc.otm.capability.iterator -import ru.dbotthepony.mc.otm.container.util.iterator import ru.dbotthepony.mc.otm.container.util.slotIterator import ru.dbotthepony.mc.otm.menu.input.InstantBooleanInput import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget @@ -119,6 +117,8 @@ class ExopackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen val enderChestSlots: List val enderChestOpenState = InstantBooleanInput(this) + val playerEnderSortSettings = IItemStackSortingSettings.inputs(this, capability.enderSortingSettings) + val sortEnderChest: SortInput? init { if (capability.isExopackEnderAccessInstalled) { @@ -127,8 +127,11 @@ class ExopackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen addStorageSlot(it, condition = enderChestOpenState) } } + + sortEnderChest = SortInput(player.enderChestInventory, playerEnderSortSettings) } else { enderChestSlots = listOf() + sortEnderChest = null } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ISortingSettings.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ISortingSettings.kt index fa9a9552d..8a6a4fe87 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ISortingSettings.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ISortingSettings.kt @@ -28,6 +28,11 @@ interface IBaseSortingSettings : INBTSerializable { } interface IItemStackSortingSettings : IBaseSortingSettings { + data class Impl( + override var isAscending: Boolean = true, + override var sorting: ItemStackSorter = ItemStackSorter.DEFAULT, + ) : IItemStackSortingSettings + var sorting: ItemStackSorter override fun serializeNBT(): CompoundTag { @@ -71,6 +76,11 @@ interface IItemStackSortingSettings : IBaseSortingSettings { } interface IItemSortingSettings : IBaseSortingSettings { + data class Impl( + override var isAscending: Boolean = true, + override var sorting: ItemSorter = ItemSorter.DEFAULT, + ) : IItemSortingSettings + var sorting: ItemSorter override fun serializeNBT(): CompoundTag { From 15b718f28ad739a99c3f5cf5e04858ed2ea4cd82 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 21 Aug 2023 00:27:32 +0700 Subject: [PATCH 1018/1199] Enable inventory scrollbar when having exopack installed, and not having at least 1 extra slot in it --- .../dbotthepony/mc/otm/client/screen/MatteryScreen.kt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) 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 64abf7566..e51b3e857 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 @@ -209,12 +209,9 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit if (menu.playerInventorySlots.isNotEmpty() && menu.autoCreateInventoryFrame) { val deviceControls: DeviceControls> - if (menu.playerCombinedInventorySlots.size <= 27) { + if (menu.player.matteryPlayer?.hasExopack != true) { inventoryFrame = FramePanel>(this, null, 0f, 0f, INVENTORY_FRAME_WIDTH, INVENTORY_FRAME_HEIGHT, inventory.displayName).also(this::addPanel) - inventoryFrame!!.makeHelpButton().addSlotFiltersHelp().also { - if (menu.player.matteryPlayer?.hasExopack == true) - it.tooltips.add(TranslatableComponent("otm.gui.help.slot_charging")) - } + inventoryFrame!!.makeHelpButton().addSlotFiltersHelp() deviceControls = DeviceControls(this, inventoryFrame!!) @@ -247,8 +244,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } else { inventoryFrame = FramePanel>(this, null, 0f, 0f, INVENTORY_FRAME_WIDTH_EXTENDED, BASE_INVENTORY_FRAME_HEIGHT + AbstractSlotPanel.SIZE * inventoryRows, inventory.displayName).also(this::addPanel) inventoryFrame!!.makeHelpButton().addSlotFiltersHelp().also { - if (menu.player.matteryPlayer?.hasExopack == true) - it.tooltips.add(TranslatableComponent("otm.gui.help.slot_charging")) + it.tooltips.add(TranslatableComponent("otm.gui.help.slot_charging")) } deviceControls = DeviceControls(this, inventoryFrame!!) From 4356117f7da01dce714da0f2a84021beb14d0af1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 21 Aug 2023 00:59:54 +0700 Subject: [PATCH 1019/1199] JEI Transfer handler for matter entangler, plate press and painting table --- .../jei/ExopackInventoryTransferHandler.kt | 154 +++++++++++++++++ .../mc/otm/compat/jei/JEIPlugin.kt | 157 +----------------- .../jei/MatterEntanglerRecipeCategory.kt | 4 +- .../otm/compat/jei/PainterRecipeCategory.kt | 2 +- .../mc/otm/compat/jei/SimpleTransferInfo.kt | 41 +++++ 5 files changed, 207 insertions(+), 151 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/ExopackInventoryTransferHandler.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/SimpleTransferInfo.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/ExopackInventoryTransferHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/ExopackInventoryTransferHandler.kt new file mode 100644 index 000000000..3572f1770 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/ExopackInventoryTransferHandler.kt @@ -0,0 +1,154 @@ +package ru.dbotthepony.mc.otm.compat.jei + +import it.unimi.dsi.fastutil.ints.Int2IntArrayMap +import it.unimi.dsi.fastutil.ints.IntArraySet +import mezz.jei.api.constants.RecipeTypes +import mezz.jei.api.gui.ingredient.IRecipeSlotView +import mezz.jei.api.gui.ingredient.IRecipeSlotsView +import mezz.jei.api.recipe.RecipeIngredientRole +import mezz.jei.api.recipe.transfer.IRecipeTransferError +import mezz.jei.api.recipe.transfer.IRecipeTransferHandler +import mezz.jei.api.recipe.transfer.IRecipeTransferHandlerHelper +import mezz.jei.api.recipe.transfer.IRecipeTransferInfo +import net.minecraft.world.entity.player.Player +import net.minecraft.world.inventory.MenuType +import net.minecraft.world.inventory.Slot +import net.minecraft.world.item.crafting.CraftingRecipe +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.toImmutableList +import ru.dbotthepony.mc.otm.menu.ExopackInventoryMenu +import java.util.* +import kotlin.collections.ArrayList + +class ExopackInventoryTransferHandler(private val helper: IRecipeTransferHandlerHelper) : IRecipeTransferHandler { + private val transfer = helper.createUnregisteredRecipeTransferHandler(object : IRecipeTransferInfo { + override fun getContainerClass(): Class { + return ExopackInventoryMenu::class.java + } + + override fun getMenuType(): Optional> { + return Optional.empty() + } + + override fun getRecipeType(): mezz.jei.api.recipe.RecipeType { + return RecipeTypes.CRAFTING + } + + override fun canHandle(container: ExopackInventoryMenu, recipe: CraftingRecipe): Boolean { + return true + } + + override fun getRecipeSlots( + container: ExopackInventoryMenu, + recipe: CraftingRecipe + ): List { + return container.craftingSlots + } + + override fun getInventorySlots( + container: ExopackInventoryMenu, + recipe: CraftingRecipe + ): List { + return container.playerInventorySlots + } + }) + + override fun getContainerClass(): Class { + return ExopackInventoryMenu::class.java + } + + override fun getMenuType(): Optional> { + return Optional.empty() + } + + override fun getRecipeType(): mezz.jei.api.recipe.RecipeType { + return RecipeTypes.CRAFTING + } + + private val validSlots = IntArraySet().also { + it.add(0) + it.add(1) + it.add(3) + it.add(4) + } + + private val directMap = Int2IntArrayMap().also { + for (i in 0 .. 8) { + it.put(i, i) + } + } + + private val smallMap = Int2IntArrayMap().also { + var i = 0 + it.put(0, i++) + it.put(1, i++) + it.put(3, i++) + it.put(4, i) + } + + override fun transferRecipe( + container: ExopackInventoryMenu, + recipe: CraftingRecipe, + recipeSlots: IRecipeSlotsView, + player: Player, + maxTransfer: Boolean, + doTransfer: Boolean + ): IRecipeTransferError? { + val inputs = recipeSlots.getSlotViews(RecipeIngredientRole.INPUT) + + if (inputs.size != 9) { + return IRecipeTransferError { IRecipeTransferError.Type.INTERNAL } + } + + if (container.craftingSlots.size != 9) { + for ((i, ingredient) in inputs.withIndex()) { + if (!ingredient.isEmpty && i !in validSlots) { + return helper.createUserErrorWithTooltip(TranslatableComponent("jei.tooltip.error.recipe.transfer.too.large.player.inventory")) + } + } + + val filteredInputs = ArrayList() + + for ((i, ingredient) in inputs.withIndex()) { + if (i in validSlots) { + filteredInputs.add(ingredient) + } + } + + val outputs = recipeSlots.getSlotViews(RecipeIngredientRole.OUTPUT).toImmutableList() + val catalysts = recipeSlots.getSlotViews(RecipeIngredientRole.CATALYST).toImmutableList() + val render = recipeSlots.getSlotViews(RecipeIngredientRole.RENDER_ONLY).toImmutableList() + + val combine = ArrayList(filteredInputs.size + outputs.size + render.size) + + combine.addAll(filteredInputs) + combine.addAll(outputs) + combine.addAll(render) + + val combined = combine.toImmutableList() + + val newView = object : IRecipeSlotsView { + override fun getSlotViews(): List { + return combined + } + + override fun getSlotViews(role: RecipeIngredientRole): List { + return when (role) { + RecipeIngredientRole.INPUT -> filteredInputs + RecipeIngredientRole.OUTPUT -> outputs + RecipeIngredientRole.CATALYST -> catalysts + RecipeIngredientRole.RENDER_ONLY -> render + } + } + + override fun findSlotByName(slotName: String): Optional { + return combined.stream().filter { it.slotName.orElse(null) == slotName }.findAny() + } + } + + return this.transfer.transferRecipe(container, recipe, newView, player, maxTransfer, doTransfer) + } + + return this.transfer.transferRecipe(container, recipe, recipeSlots, player, maxTransfer, doTransfer) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt index fcc0617eb..70ada7c72 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt @@ -1,20 +1,12 @@ package ru.dbotthepony.mc.otm.compat.jei -import it.unimi.dsi.fastutil.ints.Int2IntArrayMap -import it.unimi.dsi.fastutil.ints.IntArraySet import mezz.jei.api.IModPlugin import mezz.jei.api.JeiPlugin import mezz.jei.api.constants.RecipeTypes import mezz.jei.api.constants.VanillaTypes import mezz.jei.api.gui.handlers.IGuiContainerHandler -import mezz.jei.api.gui.ingredient.IRecipeSlotView -import mezz.jei.api.gui.ingredient.IRecipeSlotsView import mezz.jei.api.helpers.IJeiHelpers import mezz.jei.api.ingredients.ITypedIngredient -import mezz.jei.api.recipe.RecipeIngredientRole -import mezz.jei.api.recipe.transfer.IRecipeTransferError -import mezz.jei.api.recipe.transfer.IRecipeTransferHandler -import mezz.jei.api.recipe.transfer.IRecipeTransferInfo import mezz.jei.api.registration.IGuiHandlerRegistration import mezz.jei.api.registration.IRecipeCatalystRegistration import mezz.jei.api.registration.IRecipeCategoryRegistration @@ -23,22 +15,18 @@ import mezz.jei.api.registration.IRecipeTransferRegistration import mezz.jei.api.runtime.IClickableIngredient import net.minecraft.client.renderer.Rect2i import net.minecraft.resources.ResourceLocation -import net.minecraft.world.entity.player.Player -import net.minecraft.world.inventory.MenuType -import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.crafting.CraftingRecipe import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.screen.MatteryScreen -import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.core.toImmutableList -import ru.dbotthepony.mc.otm.menu.ExopackInventoryMenu +import ru.dbotthepony.mc.otm.menu.decorative.PainterMenu +import ru.dbotthepony.mc.otm.menu.matter.MatterEntanglerMenu +import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu +import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRecipes import java.util.* import java.util.stream.Collectors -import kotlin.collections.ArrayList import kotlin.properties.Delegates var isJeiLoaded = false @@ -93,138 +81,11 @@ class JEIPlugin : IModPlugin { override fun registerRecipeTransferHandlers(registration: IRecipeTransferRegistration) { val helper = registration.transferHelper - registration.addRecipeTransferHandler(object : IRecipeTransferHandler { - private val transfer = helper.createUnregisteredRecipeTransferHandler(object : IRecipeTransferInfo { - override fun getContainerClass(): Class { - return ExopackInventoryMenu::class.java - } - - override fun getMenuType(): Optional> { - return Optional.empty() - } - - override fun getRecipeType(): mezz.jei.api.recipe.RecipeType { - return RecipeTypes.CRAFTING - } - - override fun canHandle(container: ExopackInventoryMenu, recipe: CraftingRecipe): Boolean { - return true - } - - override fun getRecipeSlots( - container: ExopackInventoryMenu, - recipe: CraftingRecipe - ): List { - return container.craftingSlots - } - - override fun getInventorySlots( - container: ExopackInventoryMenu, - recipe: CraftingRecipe - ): List { - return container.playerInventorySlots - } - }) - - override fun getContainerClass(): Class { - return ExopackInventoryMenu::class.java - } - - override fun getMenuType(): Optional> { - return Optional.empty() - } - - override fun getRecipeType(): mezz.jei.api.recipe.RecipeType { - return RecipeTypes.CRAFTING - } - - private val validSlots = IntArraySet().also { - it.add(0) - it.add(1) - it.add(3) - it.add(4) - } - - private val directMap = Int2IntArrayMap().also { - for (i in 0 .. 8) { - it.put(i, i) - } - } - - private val smallMap = Int2IntArrayMap().also { - var i = 0 - it.put(0, i++) - it.put(1, i++) - it.put(3, i++) - it.put(4, i) - } - - override fun transferRecipe( - container: ExopackInventoryMenu, - recipe: CraftingRecipe, - recipeSlots: IRecipeSlotsView, - player: Player, - maxTransfer: Boolean, - doTransfer: Boolean - ): IRecipeTransferError? { - val inputs = recipeSlots.getSlotViews(RecipeIngredientRole.INPUT) - - if (inputs.size != 9) { - return IRecipeTransferError { IRecipeTransferError.Type.INTERNAL } - } - - if (container.craftingSlots.size != 9) { - for ((i, ingredient) in inputs.withIndex()) { - if (!ingredient.isEmpty && i !in validSlots) { - return helper.createUserErrorWithTooltip(TranslatableComponent("jei.tooltip.error.recipe.transfer.too.large.player.inventory")) - } - } - - val filteredInputs = ArrayList() - - for ((i, ingredient) in inputs.withIndex()) { - if (i in validSlots) { - filteredInputs.add(ingredient) - } - } - - val outputs = recipeSlots.getSlotViews(RecipeIngredientRole.OUTPUT).toImmutableList() - val catalysts = recipeSlots.getSlotViews(RecipeIngredientRole.CATALYST).toImmutableList() - val render = recipeSlots.getSlotViews(RecipeIngredientRole.RENDER_ONLY).toImmutableList() - - val combine = ArrayList(filteredInputs.size + outputs.size + render.size) - - combine.addAll(filteredInputs) - combine.addAll(outputs) - combine.addAll(render) - - val combined = combine.toImmutableList() - - val newView = object : IRecipeSlotsView { - override fun getSlotViews(): List { - return combined - } - - override fun getSlotViews(role: RecipeIngredientRole): List { - return when (role) { - RecipeIngredientRole.INPUT -> filteredInputs - RecipeIngredientRole.OUTPUT -> outputs - RecipeIngredientRole.CATALYST -> catalysts - RecipeIngredientRole.RENDER_ONLY -> render - } - } - - override fun findSlotByName(slotName: String): Optional { - return combined.stream().filter { it.slotName.orElse(null) == slotName }.findAny() - } - } - - return this.transfer.transferRecipe(container, recipe, newView, player, maxTransfer, doTransfer) - } - - return this.transfer.transferRecipe(container, recipe, recipeSlots, player, maxTransfer, doTransfer) - } - }, RecipeTypes.CRAFTING) + registration.addRecipeTransferHandler(ExopackInventoryTransferHandler(helper), RecipeTypes.CRAFTING) + registration.addRecipeTransferHandler(simpleTransferInfo(MatterEntanglerRecipeCategory.recipeType, MatterEntanglerMenu::inputs)) + registration.addRecipeTransferHandler(simpleTransferInfo0(PainterRecipeCategory.recipeType, PainterMenu::inputSlot)) + registration.addRecipeTransferHandler(simpleTransferInfo0(PlatePressRecipeCategory.recipeType, PlatePressMenu::inputSlot)) + registration.addRecipeTransferHandler(simpleTransferInfo(PlatePressRecipeCategory.recipeType, TwinPlatePressMenu::inputSlots)) } override fun registerGuiHandlers(registration: IGuiHandlerRegistration) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt index 763f17658..c01c26672 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt @@ -53,8 +53,8 @@ object MatterEntanglerRecipeCategory : IRecipeCategory, } override fun setRecipe(builder: IRecipeLayoutBuilder, recipe: IMatterEntanglerRecipe, focuses: IFocusGroup) { - for (x in 0 until recipe.ingredients.width) { - for (y in 0 until recipe.ingredients.height) { + for (y in 0 until recipe.ingredients.height) { + for (x in 0 until recipe.ingredients.width) { builder.addSlot(RecipeIngredientRole.INPUT, 30 + x * 18, 4 + y * 18).addIngredients(recipe.ingredients[x, y]) } } 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 bda128ad6..a948eae2f 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 @@ -54,7 +54,7 @@ object PainterRecipeCategory : IRecipeCategory, IDrawable { var y = 0 for ((dye, count) in recipe.dyes) { - builder.addSlot(RecipeIngredientRole.INPUT, 1 + x * 18, 1 + y * 18) + builder.addSlot(RecipeIngredientRole.CATALYST, 1 + x * 18, 1 + y * 18) .addIngredients(VanillaTypes.ITEM_STACK, Ingredient.of(dye.tag).items.map { it.copyWithCount(count) }) y++ diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/SimpleTransferInfo.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/SimpleTransferInfo.kt new file mode 100644 index 000000000..1e6d6c465 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/SimpleTransferInfo.kt @@ -0,0 +1,41 @@ +package ru.dbotthepony.mc.otm.compat.jei + +import mezz.jei.api.recipe.RecipeType +import mezz.jei.api.recipe.transfer.IRecipeTransferInfo +import net.minecraft.world.inventory.MenuType +import net.minecraft.world.inventory.Slot +import net.minecraft.world.item.crafting.Recipe +import ru.dbotthepony.mc.otm.menu.MatteryMenu +import java.util.* + +inline fun > simpleTransferInfo(type: RecipeType, crossinline slots: (M) -> List): IRecipeTransferInfo { + return object : IRecipeTransferInfo { + override fun getContainerClass(): Class { + return M::class.java + } + + override fun getMenuType(): Optional> { + return Optional.empty() + } + + override fun getRecipeType(): RecipeType { + return type + } + + override fun canHandle(container: M, recipe: R): Boolean { + return true + } + + override fun getRecipeSlots(container: M, recipe: R): List { + return slots.invoke(container) + } + + override fun getInventorySlots(container: M, recipe: R): List { + return container.playerInventorySlots + } + } +} + +inline fun > simpleTransferInfo0(type: RecipeType, crossinline slot: (M) -> Slot): IRecipeTransferInfo { + return simpleTransferInfo(type) { listOf(slot.invoke(it)) } +} From 6fc06a620ff3094601b15ed7474f1f477e6aaf66 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 21 Aug 2023 11:08:39 +0700 Subject: [PATCH 1020/1199] Call setByPlayer instead of set on slots when quickmoving --- src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 66f71ec48..e3299f78e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -606,7 +606,7 @@ abstract class MatteryMenu( val copy = source.item.copy() if (remainder.isEmpty) { - source.set(ItemStack.EMPTY) + source.setByPlayer(ItemStack.EMPTY) source.onTake(player, copy) } else { copy.count = source.item.count - remainder.count @@ -666,7 +666,7 @@ abstract class MatteryMenu( val newCount = copy.count.coerceAtMost(limit) if (!simulate) { - slot.set(copy.copy().also { it.count = newCount }) + slot.setByPlayer(copy.copy().also { it.count = newCount }) slot.setChanged() } From af2d621cee44563a116d0f7fbea770668e7959e0 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 21 Aug 2023 11:13:48 +0700 Subject: [PATCH 1021/1199] Hopper and dispenser/dropper menus? --- .../otm/mixin/DispenserBlockEntityMixin.java | 16 +++++++++ .../mc/otm/mixin/HopperBlockEntityMixin.java | 16 +++++++++ .../mc/otm/compat/vanilla/MatteryChestMenu.kt | 33 ++++++++++++++----- .../otm/compat/vanilla/MatteryChestScreen.kt | 4 +-- .../overdrive_that_matters.mixins.json | 4 ++- 5 files changed, 62 insertions(+), 11 deletions(-) create mode 100644 src/main/java/ru/dbotthepony/mc/otm/mixin/DispenserBlockEntityMixin.java create mode 100644 src/main/java/ru/dbotthepony/mc/otm/mixin/HopperBlockEntityMixin.java diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/DispenserBlockEntityMixin.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/DispenserBlockEntityMixin.java new file mode 100644 index 000000000..7cba3efe4 --- /dev/null +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/DispenserBlockEntityMixin.java @@ -0,0 +1,16 @@ +package ru.dbotthepony.mc.otm.mixin; + +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.level.block.entity.DispenserBlockEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import ru.dbotthepony.mc.otm.compat.vanilla.MatteryChestMenu; + +@Mixin(DispenserBlockEntity.class) +public abstract class DispenserBlockEntityMixin { + @Overwrite + public AbstractContainerMenu createMenu(int p_59312_, Inventory p_59313_) { + return MatteryChestMenu.c3x3(p_59312_, p_59313_, (DispenserBlockEntity) (Object) this); + } +} diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/HopperBlockEntityMixin.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/HopperBlockEntityMixin.java new file mode 100644 index 000000000..9c1af9bfd --- /dev/null +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/HopperBlockEntityMixin.java @@ -0,0 +1,16 @@ +package ru.dbotthepony.mc.otm.mixin; + +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.level.block.entity.HopperBlockEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import ru.dbotthepony.mc.otm.compat.vanilla.MatteryChestMenu; + +@Mixin(HopperBlockEntity.class) +public abstract class HopperBlockEntityMixin { + @Overwrite + public AbstractContainerMenu createMenu(int p_59312_, Inventory p_59313_) { + return MatteryChestMenu.hopper(p_59312_, p_59313_, (HopperBlockEntity) (Object) this); + } +} 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 9092f3e61..6ed91b59f 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 @@ -19,13 +19,14 @@ import ru.dbotthepony.mc.otm.menu.makeSlots class MatteryChestMenu( type: MenuType<*>, containerId: Int, - inventory: Inventory, val rows: Int, - val container: Container = SimpleContainer(rows * 9) + inventory: Inventory, val rows: Int, val columns: Int, + val container: Container = SimpleContainer(rows * columns) ) : MatteryMenu(type, containerId, inventory) { val chestSlots = makeSlots(container, ::MatterySlot) val sort = SortInput(container, playerSortSettings) init { + require(rows * columns == container.containerSize) { "Provided container $container has different dimensions than specified rows x columns: ${container.containerSize} vs $rows x $columns (${rows * columns})" } container.startOpen(player) addStorageSlot(chestSlots) addInventorySlots() @@ -49,41 +50,55 @@ class MatteryChestMenu( private val GENERIC_9x4 by registrar.register("generic_9x4") { MenuType(::c9x4, FeatureFlags.VANILLA_SET) } private val GENERIC_9x5 by registrar.register("generic_9x5") { MenuType(::c9x5, FeatureFlags.VANILLA_SET) } private val GENERIC_9x6 by registrar.register("generic_9x6") { MenuType(::c9x6, FeatureFlags.VANILLA_SET) } + private val GENERIC_3x3 by registrar.register("generic_3x3") { MenuType(::c3x3, FeatureFlags.VANILLA_SET) } + private val HOPPER by registrar.register("hopper") { MenuType(::hopper, FeatureFlags.VANILLA_SET) } @JvmStatic @JvmOverloads fun c9x1(containerId: Int, inventory: Inventory, container: Container = SimpleContainer(9)): MatteryChestMenu { - return MatteryChestMenu(GENERIC_9x1, containerId, inventory, 1, container) + return MatteryChestMenu(GENERIC_9x1, containerId, inventory, 1, 9, container) } @JvmStatic @JvmOverloads fun c9x2(containerId: Int, inventory: Inventory, container: Container = SimpleContainer(9 * 2)): MatteryChestMenu { - return MatteryChestMenu(GENERIC_9x2, containerId, inventory, 2, container) + return MatteryChestMenu(GENERIC_9x2, containerId, inventory, 2, 9, container) } @JvmStatic @JvmOverloads fun c9x3(containerId: Int, inventory: Inventory, container: Container = SimpleContainer(9 * 3)): MatteryChestMenu { - return MatteryChestMenu(GENERIC_9x3, containerId, inventory, 3, container) + return MatteryChestMenu(GENERIC_9x3, containerId, inventory, 3, 9, container) } @JvmStatic @JvmOverloads fun c9x4(containerId: Int, inventory: Inventory, container: Container = SimpleContainer(9 * 4)): MatteryChestMenu { - return MatteryChestMenu(GENERIC_9x4, containerId, inventory, 4, container) + return MatteryChestMenu(GENERIC_9x4, containerId, inventory, 4, 9, container) } @JvmStatic @JvmOverloads fun c9x5(containerId: Int, inventory: Inventory, container: Container = SimpleContainer(9 * 5)): MatteryChestMenu { - return MatteryChestMenu(GENERIC_9x5, containerId, inventory, 5, container) + return MatteryChestMenu(GENERIC_9x5, containerId, inventory, 5, 9, container) } @JvmStatic @JvmOverloads fun c9x6(containerId: Int, inventory: Inventory, container: Container = SimpleContainer(9 * 6)): MatteryChestMenu { - return MatteryChestMenu(GENERIC_9x6, containerId, inventory, 6, container) + return MatteryChestMenu(GENERIC_9x6, containerId, inventory, 6, 9, container) + } + + @JvmStatic + @JvmOverloads + fun c3x3(containerId: Int, inventory: Inventory, container: Container = SimpleContainer(3 * 3)): MatteryChestMenu { + return MatteryChestMenu(GENERIC_3x3, containerId, inventory, 3, 3, container) + } + + @JvmStatic + @JvmOverloads + fun hopper(containerId: Int, inventory: Inventory, container: Container = SimpleContainer(5)): MatteryChestMenu { + return MatteryChestMenu(HOPPER, containerId, inventory, 1, 5, container) } internal fun register(bus: IEventBus) { @@ -99,6 +114,8 @@ class MatteryChestMenu( MenuScreens.register(GENERIC_9x4, ::MatteryChestScreen) MenuScreens.register(GENERIC_9x5, ::MatteryChestScreen) MenuScreens.register(GENERIC_9x6, ::MatteryChestScreen) + MenuScreens.register(GENERIC_3x3, ::MatteryChestScreen) + MenuScreens.register(HOPPER, ::MatteryChestScreen) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/MatteryChestScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/MatteryChestScreen.kt index e06a76a44..316a948c9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/MatteryChestScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/MatteryChestScreen.kt @@ -13,12 +13,12 @@ import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel class MatteryChestScreen(menu: MatteryChestMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { override fun makeMainFrame(): FramePanel> { - val frame = FramePanel.padded(this, AbstractSlotPanel.SIZE * 9f, AbstractSlotPanel.SIZE * menu.rows + 4f, title) + val frame = FramePanel.padded(this, AbstractSlotPanel.SIZE * menu.columns.coerceAtLeast(9), AbstractSlotPanel.SIZE * menu.rows + 4f, title) frame.makeCloseButton() frame.onClose { onClose() } - val grid = GridPanel.slots(this, frame, 9, menu.rows) + val grid = GridPanel.slots(this, frame, menu.columns, menu.rows) grid.dock = Dock.FILL grid.gravity = RenderGravity.BOTTOM_CENTER diff --git a/src/main/resources/overdrive_that_matters.mixins.json b/src/main/resources/overdrive_that_matters.mixins.json index cc4920e9d..b812f9335 100644 --- a/src/main/resources/overdrive_that_matters.mixins.json +++ b/src/main/resources/overdrive_that_matters.mixins.json @@ -15,7 +15,9 @@ "MixinAbstractHurtingProjectile", "SimpleCriterionTriggerMixin", "InventoryChangeTriggerMixin", - "MixinPlayer" + "MixinPlayer", + "HopperBlockEntityMixin", + "DispenserBlockEntityMixin" ], "client": [ "MixinGameRenderer", From 4a606e78b0305dd8ea3aeaa57b995eb5cd0165dc Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 21 Aug 2023 11:21:59 +0700 Subject: [PATCH 1022/1199] Use MatteryCraftingContainer in item monitor --- .../entity/storage/ItemMonitorBlockEntity.kt | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) 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 7f3a1aace..312d24e96 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 @@ -43,6 +43,7 @@ import java.util.* import kotlin.collections.HashMap import ru.dbotthepony.mc.otm.client.render.Widgets8 import ru.dbotthepony.mc.otm.container.CombinedContainer +import ru.dbotthepony.mc.otm.container.MatteryCraftingContainer import ru.dbotthepony.mc.otm.container.util.slotIterator import ru.dbotthepony.mc.otm.core.collect.map import ru.dbotthepony.mc.otm.core.collect.toList @@ -211,10 +212,9 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte // a lot of code is hardcoded to take CraftingContainer as it's input // hence we are forced to work around this by providing proxy container - val craftingGrid = object : MatteryContainer(3 * 3) { + val craftingGrid = object : MatteryCraftingContainer(::markDirtyFast, 3, 3) { override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { markDirtyFast() - craftingGridVanilla[slot] = new if (!inProcessOfCraft) { scanCraftingGrid(false) @@ -222,20 +222,15 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte } }.also(::addDroppableContainer) - private val craftingGridVanilla = TransientCraftingContainer(object : AbstractContainerMenu(null, Int.MIN_VALUE) { - override fun stillValid(p_38874_: Player) = true - override fun quickMoveStack(p_38941_: Player, p_38942_: Int) = ItemStack.EMPTY - }, 3, 3) - private fun scanCraftingGrid(justCheckForRecipeChange: Boolean): Boolean { val level = level ?: return false val server = level.server ?: return false var craftingRecipe = craftingRecipe - if (craftingRecipe != null && craftingRecipe.matches(craftingGridVanilla, level)) return true + if (craftingRecipe != null && craftingRecipe.matches(craftingGrid, level)) return true if (justCheckForRecipeChange) return false - craftingRecipe = server.recipeManager.getRecipeFor(RecipeType.CRAFTING, craftingGridVanilla, level).orElse(null) + craftingRecipe = server.recipeManager.getRecipeFor(RecipeType.CRAFTING, craftingGrid, level).orElse(null) Arrays.fill(craftingGridTuples, null) val poweredView = poweredView @@ -335,7 +330,7 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte val result: ItemStack try { - residue = craftingRecipe.getRemainingItems(craftingGridVanilla) + residue = craftingRecipe.getRemainingItems(craftingGrid) result = craftingRecipe.getResultItem(level.registryAccess()) } finally { ForgeHooks.setCraftingPlayer(null) @@ -344,7 +339,7 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte check(residue.size == craftingGrid.containerSize) { "Container and residue list sizes mismatch: ${residue.size} != ${craftingGrid.containerSize}" } val combinedInventory = craftingPlayer.matteryPlayer?.inventoryAndExopack - val copy = craftingGrid.iterator(true).map { it.copy() }.toList() + val copy = craftingGrid.iterator(false).map { it.copy() }.toList() // удаляем по одному предмету из сетки крафта for (slot in 0 until craftingGrid.containerSize) { From 4e17c000995ac9c926306c21672ccb2688dd42e1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 21 Aug 2023 11:23:06 +0700 Subject: [PATCH 1023/1199] Add profiled gauge widget to item monitor menu --- .../mc/otm/client/screen/storage/ItemMonitorScreen.kt | 3 ++- .../ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) 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 d1cfbde67..028c70702 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 @@ -25,6 +25,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.asGetterSetter import ru.dbotthepony.mc.otm.core.util.ItemStorageStackSorter @@ -156,7 +157,7 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp leftStrip.height += it.height } - WidePowerGaugePanel(this, leftStrip, menu.energyWidget).also { + WideProfiledPowerGaugePanel(this, leftStrip, menu.profiledEnergy).also { it.dock = Dock.FILL it.dockResize = DockResizeMode.NONE leftStrip.height += it.height diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt index 0145d626b..512424acd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/storage/ItemMonitorMenu.kt @@ -20,6 +20,7 @@ import ru.dbotthepony.mc.otm.menu.data.NetworkedItemView import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback import ru.dbotthepony.mc.otm.menu.makeSlots +import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus import ru.dbotthepony.mc.otm.storage.* import java.util.* @@ -84,6 +85,7 @@ class ItemMonitorMenu( tile: ItemMonitorBlockEntity? = null ) : MatteryPoweredMenu(MMenus.ITEM_MONITOR, containerId, inventory, tile), INetworkedItemViewProvider { override val networkedItemView = NetworkedItemView(inventory.player, this, tile == null) + val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) val settings = object : IItemMonitorPlayerSettings { override var ingredientPriority by EnumInputWithFeedback(this@ItemMonitorMenu, true, tile?.let { it.getSettings(player as ServerPlayer)::ingredientPriority }) From 2e94245d7c98d5f884224682584b1d6da08c9db1 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 21 Aug 2023 11:25:14 +0700 Subject: [PATCH 1024/1199] =?UTF-8?q?YuRaNnNzZZ=20=E2=80=94=20=D0=A1=D0=B5?= =?UTF-8?q?=D0=B3=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=2011:20=20=D1=81=D0=BB?= =?UTF-8?q?=D0=BE=D1=82=D1=8B=20=D0=B1=D1=80=D0=BE=D0=BD=D0=B8=20=D1=81?= =?UTF-8?q?=D0=B1=D1=80=D0=B0=D1=81=D1=8B=D0=B2=D0=B0=D1=8E=D1=82=D1=81?= =?UTF-8?q?=D1=8F=20=D0=BD=D0=B0=20=D0=B7=D0=B0=D1=80=D1=8F=D0=B4=D0=BA?= =?UTF-8?q?=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/capability/MatteryPlayerCapability.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 94965416b..0206cddda 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -986,7 +986,6 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } slotsChargeFlag.clear() - slotChargeToDefault() val regularSlotFilters = tag.getStringList("regularSlotFilters") @@ -996,8 +995,12 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial this.regularSlotFilters[i].value = ForgeRegistries.ITEMS.getValue(ResourceLocation.tryParse(path) ?: continue) ?: Items.AIR } - for (v in tag.getIntList("slotsChargeFlag")) { - this.slotsChargeFlag.add(v.asInt) + if ("slotsChargeFlag" in tag) { + for (v in tag.getIntList("slotsChargeFlag")) { + this.slotsChargeFlag.add(v.asInt) + } + } else { + slotChargeToDefault() } // iterations From c7442e4ad2cd5b7f86a5eae5b00fe0b7ffce7b77 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 21 Aug 2023 13:29:24 +0700 Subject: [PATCH 1025/1199] JEI recipes button inside machines GUI --- .../entity/tech/PoweredFurnaceBlockEntity.kt | 10 ++++-- .../screen/matter/MatterEntanglerScreen.kt | 3 ++ .../screen/tech/ChemicalGeneratorScreen.kt | 4 +++ .../client/screen/tech/PlatePressScreen.kt | 3 +- .../screen/tech/PoweredFurnaceScreen.kt | 23 ++++++++++-- .../screen/tech/TwinPlatePressScreen.kt | 5 +-- .../screen/widget/ProgressGaugePanel.kt | 36 +++++++++++++++++-- .../mc/otm/compat/jei/JEIPlugin.kt | 14 ++++++++ .../mc/otm/menu/tech/PoweredFurnaceMenu.kt | 30 +++++++++++++++- .../ru/dbotthepony/mc/otm/registry/MMenus.kt | 6 +++- 10 files changed, 123 insertions(+), 11 deletions(-) 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 ab5974e82..ecbd85b62 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 @@ -27,6 +27,7 @@ import ru.dbotthepony.mc.otm.container.UpgradeContainer import ru.dbotthepony.mc.otm.container.balance import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu +import ru.dbotthepony.mc.otm.registry.MBlockEntities class PoweredFurnaceBlockEntity( type: BlockEntityType, @@ -80,8 +81,13 @@ class PoweredFurnaceBlockEntity( super.tick() } - override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { - return PoweredFurnaceMenu(containerID, inventory, this) + override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu? { + return when (type) { + MBlockEntities.POWERED_FURNACE -> PoweredFurnaceMenu.furnace(containerID, inventory, this) + MBlockEntities.POWERED_BLAST_FURNACE -> PoweredFurnaceMenu.blasting(containerID, inventory, this) + MBlockEntities.POWERED_SMOKER -> PoweredFurnaceMenu.smoking(containerID, inventory, this) + else -> null + } } override fun onJobFinish(status: JobStatus, id: Int) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterEntanglerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterEntanglerScreen.kt index 1141205bf..b706d73ed 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterEntanglerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterEntanglerScreen.kt @@ -13,6 +13,8 @@ import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel +import ru.dbotthepony.mc.otm.compat.jei.MatterEntanglerRecipeCategory +import ru.dbotthepony.mc.otm.compat.jei.PlatePressRecipeCategory import ru.dbotthepony.mc.otm.menu.matter.MatterEntanglerMenu class MatterEntanglerScreen(menu: MatterEntanglerMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { @@ -35,6 +37,7 @@ class MatterEntanglerScreen(menu: MatterEntanglerMenu, inventory: Inventory, tit it.dock = Dock.LEFT it.dockHorizontal(4f) it.dockResize = DockResizeMode.NONE + it.setRecipeType { listOf(MatterEntanglerRecipeCategory.recipeType) } } SlotPanel(this, frame, menu.outputs[0]).also { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt index 2f84ddd7e..c56e2283c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/ChemicalGeneratorScreen.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.client.screen.tech +import mezz.jei.api.constants.RecipeTypes import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen @@ -30,6 +31,9 @@ class ChemicalGeneratorScreen(menu: ChemicalGeneratorMenu, inventory: Inventory, } progress.flop = true + + progress.setRecipeType { listOf(RecipeTypes.FUELING) } + SlotPanel(this, frame, menu.residueSlot, 56f, PROGRESS_SLOT_TOP) SlotPanel(this, frame, menu.fuelSlot, 104f, PROGRESS_SLOT_TOP) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt index 3a3d28b6e..8fd28ea77 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PlatePressScreen.kt @@ -9,6 +9,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel +import ru.dbotthepony.mc.otm.compat.jei.PlatePressRecipeCategory import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu class PlatePressScreen(menu: PlatePressMenu, inventory: Inventory, title: Component) : @@ -20,7 +21,7 @@ class PlatePressScreen(menu: PlatePressMenu, inventory: Inventory, title: Compon BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) SlotPanel(this, frame, menu.inputSlot, 56f, PROGRESS_SLOT_TOP) - ProgressGaugePanel(this, frame, menu.progressGauge, 78f, PROGRESS_ARROW_TOP) + ProgressGaugePanel(this, frame, menu.progressGauge, 78f, PROGRESS_ARROW_TOP).setRecipeType { listOf(PlatePressRecipeCategory.recipeType) } SlotPanel(this, frame, menu.outputSlot, 104f, PROGRESS_SLOT_TOP) makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig, upgrades = menu.upgrades) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PoweredFurnaceScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PoweredFurnaceScreen.kt index 2f124d235..35f43914b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PoweredFurnaceScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PoweredFurnaceScreen.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.client.screen.tech +import mezz.jei.api.constants.RecipeTypes import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.MatteryScreen @@ -11,6 +12,7 @@ import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu +import ru.dbotthepony.mc.otm.registry.MMenus class PoweredFurnaceScreen(menu: PoweredFurnaceMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { @@ -21,15 +23,32 @@ class PoweredFurnaceScreen(menu: PoweredFurnaceMenu, inventory: Inventory, title BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) SlotPanel(this, frame, menu.inputSlots[0], 56f, PROGRESS_SLOT_TOP - 10f) - ProgressGaugePanel(this, frame, menu.progressGauge[0], 78f, PROGRESS_ARROW_TOP - 10f) + val a = ProgressGaugePanel(this, frame, menu.progressGauge[0], 78f, PROGRESS_ARROW_TOP - 10f) SlotPanel(this, frame, menu.outputSlots[0], 104f, PROGRESS_SLOT_TOP - 10f) SlotPanel(this, frame, menu.inputSlots[1], 56f, PROGRESS_SLOT_TOP + 10f) - ProgressGaugePanel(this, frame, menu.progressGauge[1], 78f, PROGRESS_ARROW_TOP + 10f) + val b = ProgressGaugePanel(this, frame, menu.progressGauge[1], 78f, PROGRESS_ARROW_TOP + 10f) SlotPanel(this, frame, menu.outputSlots[1], 104f, PROGRESS_SLOT_TOP + 10f) makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig, balanceInputs = menu.balanceInputs, upgrades = menu.upgrades) + when (menu.type) { + MMenus.POWERED_FURNACE -> { + a.setRecipeType { listOf(RecipeTypes.SMELTING) } + b.setRecipeType { listOf(RecipeTypes.SMELTING) } + } + + MMenus.POWERED_BLAST_FURNACE -> { + a.setRecipeType { listOf(RecipeTypes.BLASTING) } + b.setRecipeType { listOf(RecipeTypes.BLASTING) } + } + + MMenus.POWERED_SMOKER -> { + a.setRecipeType { listOf(RecipeTypes.SMOKING) } + b.setRecipeType { listOf(RecipeTypes.SMOKING) } + } + } + return frame } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/TwinPlatePressScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/TwinPlatePressScreen.kt index 946201340..a762523c2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/TwinPlatePressScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/TwinPlatePressScreen.kt @@ -9,6 +9,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel +import ru.dbotthepony.mc.otm.compat.jei.PlatePressRecipeCategory import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu class TwinPlatePressScreen(menu: TwinPlatePressMenu, inventory: Inventory, title: Component) : @@ -20,11 +21,11 @@ class TwinPlatePressScreen(menu: TwinPlatePressMenu, inventory: Inventory, title BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) SlotPanel(this, frame, menu.inputSlots[0], 56f, PROGRESS_SLOT_TOP - 10f) - ProgressGaugePanel(this, frame, menu.progressGauge0, 78f, PROGRESS_ARROW_TOP - 10f) + ProgressGaugePanel(this, frame, menu.progressGauge0, 78f, PROGRESS_ARROW_TOP - 10f).setRecipeType { listOf(PlatePressRecipeCategory.recipeType) } SlotPanel(this, frame, menu.outputSlots[0], 104f, PROGRESS_SLOT_TOP - 10f) SlotPanel(this, frame, menu.inputSlots[1], 56f, PROGRESS_SLOT_TOP + 10f) - ProgressGaugePanel(this, frame, menu.progressGauge1, 78f, PROGRESS_ARROW_TOP + 10f) + ProgressGaugePanel(this, frame, menu.progressGauge1, 78f, PROGRESS_ARROW_TOP + 10f).setRecipeType { listOf(PlatePressRecipeCategory.recipeType) } SlotPanel(this, frame, menu.outputSlots[1], 104f, PROGRESS_SLOT_TOP + 10f) makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig, itemConfig = menu.itemConfig, balanceInputs = menu.balanceInputs, upgrades = menu.upgrades) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt index eb1b4db49..3bb7a8b89 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt @@ -1,7 +1,9 @@ package ru.dbotthepony.mc.otm.client.screen.widget +import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack +import mezz.jei.api.recipe.RecipeType import net.minecraft.ChatFormatting import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen @@ -9,22 +11,28 @@ import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.AbstractButtonPanel +import ru.dbotthepony.mc.otm.compat.jei.JEIPlugin +import ru.dbotthepony.mc.otm.compat.jei.isJeiLoaded +import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget +import java.util.function.Supplier import kotlin.math.roundToInt -open class ProgressGaugePanel @JvmOverloads constructor( +open class ProgressGaugePanel( screen: S, parent: EditablePanel<*>? = null, val widget: ProgressGaugeWidget, x: Float = 0f, y: Float = 0f -): EditablePanel(screen, parent, x, y, width = GAUGE_BACKGROUND.width, height = GAUGE_BACKGROUND.height) { +): AbstractButtonPanel(screen, parent, x, y, width = GAUGE_BACKGROUND.width, height = GAUGE_BACKGROUND.height) { init { scissor = true } var flop = false + private var recipeTypeSupplier: Supplier>>? = null protected open fun makeTooltip(): MutableList { val tooltip: MutableList @@ -46,6 +54,11 @@ open class ProgressGaugePanel @JvmOverloads constructor( ) } + if (recipeTypeSupplier != null) { + tooltip.add(TextComponent("")) + tooltip.add(TranslatableComponent("jei.tooltip.show.recipes").withStyle(ChatFormatting.GRAY)) + } + return tooltip } @@ -78,6 +91,25 @@ open class ProgressGaugePanel @JvmOverloads constructor( return false } + override fun test(value: Int): Boolean { + return recipeTypeSupplier != null && value == InputConstants.MOUSE_BUTTON_LEFT + } + + override fun onClick(mouseButton: Int) { + val recipeTypeSupplier = recipeTypeSupplier ?: return + JEIPlugin.RUNTIME.recipesGui.showTypes(recipeTypeSupplier.get()) + } + + private fun setRecipeType0(provider: Supplier>>) { + recipeTypeSupplier = provider + } + + fun setRecipeType(provider: Supplier>>) { + if (isJeiLoaded) { + setRecipeType0(provider) + } + } + companion object { val GAUGE_BACKGROUND = WidgetLocation.PROGRESS_ARROWS.sprite(y = 0f, width = 22f, height = 15f) val GAUGE_FOREGROUND = WidgetLocation.PROGRESS_ARROWS.sprite(y = 15f, width = 22f, height = 15f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt index 70ada7c72..93fc4db5d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt @@ -13,6 +13,7 @@ import mezz.jei.api.registration.IRecipeCategoryRegistration import mezz.jei.api.registration.IRecipeRegistration import mezz.jei.api.registration.IRecipeTransferRegistration import mezz.jei.api.runtime.IClickableIngredient +import mezz.jei.api.runtime.IJeiRuntime import net.minecraft.client.renderer.Rect2i import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.ItemStack @@ -40,6 +41,11 @@ class JEIPlugin : IModPlugin { var helpers: IJeiHelpers by Delegates.notNull() private set + + private var _RUNTIME: IJeiRuntime? = null + + val RUNTIME: IJeiRuntime + get() = checkNotNull(_RUNTIME) { "JEI runtime is unavailable" } } init { @@ -63,6 +69,14 @@ class JEIPlugin : IModPlugin { registration.addRecipeCatalyst(ItemStack(MItems.MATTER_ENTANGLER), MatterEntanglerRecipeCategory.recipeType) } + override fun onRuntimeAvailable(jeiRuntime: IJeiRuntime) { + _RUNTIME = jeiRuntime + } + + override fun onRuntimeUnavailable() { + _RUNTIME = null + } + override fun registerCategories(registration: IRecipeCategoryRegistration) { helpers = registration.jeiHelpers registration.addRecipeCategories(PlatePressRecipeCategory) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PoweredFurnaceMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PoweredFurnaceMenu.kt index b567e9ac3..a39411c6c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PoweredFurnaceMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PoweredFurnaceMenu.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.menu.tech import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.player.Inventory +import net.minecraft.world.inventory.MenuType import ru.dbotthepony.mc.otm.block.entity.tech.PoweredFurnaceBlockEntity import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.menu.OutputSlot @@ -16,10 +17,11 @@ import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus class PoweredFurnaceMenu( + type: MenuType, containerID: Int, inventory: Inventory, tile: PoweredFurnaceBlockEntity? = null -) : MatteryPoweredMenu(MMenus.POWERED_FURNACE, containerID, inventory, tile) { +) : MatteryPoweredMenu(type, containerID, inventory, tile) { val inputSlots = makeSlots(tile?.inputs, 2, ::MatterySlot) val outputSlots = makeSlots(tile?.outputs, 2) { c, s -> OutputSlot(c, s) { tile?.popExperience(player as ServerPlayer) } } @@ -38,4 +40,30 @@ class PoweredFurnaceMenu( addStorageSlot(outputSlots) addInventorySlots() } + + companion object { + fun furnace( + containerID: Int, + inventory: Inventory, + tile: PoweredFurnaceBlockEntity? = null + ) : PoweredFurnaceMenu { + return PoweredFurnaceMenu(MMenus.POWERED_FURNACE, containerID, inventory, tile) + } + + fun blasting( + containerID: Int, + inventory: Inventory, + tile: PoweredFurnaceBlockEntity? = null + ) : PoweredFurnaceMenu { + return PoweredFurnaceMenu(MMenus.POWERED_BLAST_FURNACE, containerID, inventory, tile) + } + + fun smoking( + containerID: Int, + inventory: Inventory, + tile: PoweredFurnaceBlockEntity? = null + ) : PoweredFurnaceMenu { + return PoweredFurnaceMenu(MMenus.POWERED_SMOKER, containerID, inventory, tile) + } + } } 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 1c3af7f75..25f1c43ab 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt @@ -95,7 +95,9 @@ object MMenus { val ENERGY_COUNTER: MenuType by registry.register(MNames.ENERGY_COUNTER) { MenuType(::EnergyCounterMenu, FeatureFlags.VANILLA_SET) } val CHEMICAL_GENERATOR: MenuType by registry.register(MNames.CHEMICAL_GENERATOR) { MenuType(::ChemicalGeneratorMenu, FeatureFlags.VANILLA_SET) } val PLATE_PRESS: MenuType by registry.register(MNames.PLATE_PRESS) { MenuType(::PlatePressMenu, FeatureFlags.VANILLA_SET) } - val POWERED_FURNACE: MenuType by registry.register(MNames.POWERED_FURNACE) { MenuType(::PoweredFurnaceMenu, FeatureFlags.VANILLA_SET) } + val POWERED_FURNACE: MenuType by registry.register(MNames.POWERED_FURNACE) { MenuType(PoweredFurnaceMenu::furnace, FeatureFlags.VANILLA_SET) } + val POWERED_BLAST_FURNACE: MenuType by registry.register(MNames.POWERED_BLAST_FURNACE) { MenuType(PoweredFurnaceMenu::blasting, FeatureFlags.VANILLA_SET) } + val POWERED_SMOKER: MenuType by registry.register(MNames.POWERED_SMOKER) { MenuType(PoweredFurnaceMenu::smoking, FeatureFlags.VANILLA_SET) } val TWIN_PLATE_PRESS: MenuType by registry.register(MNames.TWIN_PLATE_PRESS) { MenuType(::TwinPlatePressMenu, FeatureFlags.VANILLA_SET) } val MATTER_RECYCLER: MenuType by registry.register(MNames.MATTER_RECYCLER) { MenuType(::MatterRecyclerMenu, FeatureFlags.VANILLA_SET) } val ENERGY_SERVO: MenuType by registry.register(MNames.ENERGY_SERVO) { MenuType(::EnergyServoMenu, FeatureFlags.VANILLA_SET) } @@ -148,6 +150,8 @@ object MMenus { MenuScreens.register(ITEM_REPAIER, ::MatterReconstructorScreen) MenuScreens.register(FLUID_TANK, ::FluidTankScreen) MenuScreens.register(POWERED_FURNACE, ::PoweredFurnaceScreen) + MenuScreens.register(POWERED_BLAST_FURNACE, ::PoweredFurnaceScreen) + MenuScreens.register(POWERED_SMOKER, ::PoweredFurnaceScreen) MenuScreens.register(PAINTER, ::PainterScreen) MenuScreens.register(MATTER_ENTANGLER, ::MatterEntanglerScreen) } From 93783a42107a7cba08138ca23e64cddfe2363655 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 21 Aug 2023 13:32:01 +0700 Subject: [PATCH 1026/1199] Proper shouldRenderTooltips call --- .../mc/otm/client/screen/widget/ProgressGaugePanel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt index 3bb7a8b89..790691806 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt @@ -83,7 +83,7 @@ open class ProgressGaugePanel( } override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { - if (isHovered) { + if (shouldRenderTooltips(graphics, mouseX, mouseY, partialTick)) { graphics.renderComponentTooltip(font, makeTooltip(), mouseX.toInt(), mouseY.toInt()) return true } From dd2dab37a7e08a39fedbe14bda32454dd4b1bb83 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 21 Aug 2023 15:49:04 +0700 Subject: [PATCH 1027/1199] Account for case when both references refer to null --- .../ru/dbotthepony/mc/otm/core/collect/ReferenceHashStrategy.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ReferenceHashStrategy.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ReferenceHashStrategy.kt index d6b6fdc3c..eb3e61200 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ReferenceHashStrategy.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ReferenceHashStrategy.kt @@ -9,7 +9,7 @@ object ReferenceHashStrategy : Hash.Strategy { if (a == null || b == null) return false if (a is Reference<*>) { - if (b is Reference<*>) return a.get() == b.get() + if (b is Reference<*>) return a.get() != null && a.get() == b.get() return a.get() == b } else if (b is Reference<*>) { return b.get() == a From 6fbdb04ee43c4621a2435c58210cd63f51d36abe Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 21 Aug 2023 17:09:20 +0700 Subject: [PATCH 1028/1199] Micro optimizations regarding mattery network channel --- .../dbotthepony/mc/otm/network/MatteryNetworkChannel.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt index 86fd7f0df..bda3984b9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt @@ -23,6 +23,7 @@ import java.math.BigInteger import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.ConcurrentLinkedDeque +import java.util.concurrent.ConcurrentLinkedQueue import java.util.concurrent.locks.LockSupport import java.util.function.BiConsumer import java.util.function.Supplier @@ -127,7 +128,7 @@ abstract class MatteryNetworkChannel(val version: String, val name: String) { private val logger = LogManager.getLogger() private var thread: Thread? = null - private val queue = ConcurrentLinkedDeque() + private val queue = ConcurrentLinkedQueue() @Volatile private var interrupt = false @@ -143,7 +144,7 @@ abstract class MatteryNetworkChannel(val version: String, val name: String) { */ private fun run() { while (!interrupt) { - val task = queue.pollFirst() + val task = queue.poll() if (task == null) { LockSupport.park() @@ -160,7 +161,9 @@ abstract class MatteryNetworkChannel(val version: String, val name: String) { } internal fun onServerPostTick() { - LockSupport.unpark(thread) + if (queue.isNotEmpty()) { + LockSupport.unpark(thread) + } } internal fun onServerStarting() { From 2935b3c2adcb2f1dedb663d1c4edcbe2a4cbb0db Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 22 Aug 2023 11:34:41 +0700 Subject: [PATCH 1029/1199] More concise savetables internals --- .../mc/otm/core/util/Savetables.kt | 93 +++++++++---------- 1 file changed, 42 insertions(+), 51 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt index ba1e29b5f..bd8a2b099 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Savetables.kt @@ -15,6 +15,7 @@ import net.minecraft.nbt.StringTag import net.minecraft.nbt.Tag import net.minecraft.resources.ResourceLocation import net.minecraftforge.common.util.INBTSerializable +import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.asGetterSetter import ru.dbotthepony.mc.otm.core.immutableList @@ -90,10 +91,7 @@ class Savetables : INBTSerializable { } fun decimal(prop: KMutableProperty0, name: String = prop.name, default: Decimal = Decimal.ZERO): Stateless { - return Stateless(prop, name, Tag::class.java) - .withDeserializer { Decimal.deserializeNBT(it) } - .withSerializer { it.serializeNBT() } - .withDefault { default } + return decimal(prop.asGetterSetter(), name, default) } fun decimalNullable(prop: KMutableProperty0, name: String = prop.name, default: Decimal = Decimal.ZERO): Stateless { @@ -110,9 +108,7 @@ class Savetables : INBTSerializable { } fun float(prop: KMutableProperty0, name: String = prop.name): Stateless { - return Stateless(prop, name, NumericTag::class.java) - .withSerializer { FloatTag.valueOf(it) } - .withDeserializer { it.asFloat } + return float(prop.asGetterSetter(), name) } fun double(prop: GetterSetter, name: String): Stateless { @@ -122,9 +118,7 @@ class Savetables : INBTSerializable { } fun double(prop: KMutableProperty0, name: String = prop.name): Stateless { - return Stateless(prop, name, NumericTag::class.java) - .withSerializer { DoubleTag.valueOf(it) } - .withDeserializer { it.asDouble } + return double(prop.asGetterSetter(), name) } fun int(prop: GetterSetter, name: String): Stateless { @@ -134,9 +128,7 @@ class Savetables : INBTSerializable { } fun int(prop: KMutableProperty0, name: String = prop.name): Stateless { - return Stateless(prop, name, NumericTag::class.java) - .withSerializer { IntTag.valueOf(it) } - .withDeserializer { it.asInt } + return int(prop.asGetterSetter(), name) } fun long(prop: GetterSetter, name: String): Stateless { @@ -146,9 +138,7 @@ class Savetables : INBTSerializable { } fun long(prop: KMutableProperty0, name: String = prop.name): Stateless { - return Stateless(prop, name, NumericTag::class.java) - .withSerializer { LongTag.valueOf(it) } - .withDeserializer { it.asLong } + return long(prop.asGetterSetter(), name) } fun bool(prop: GetterSetter, name: String): Stateless { @@ -158,9 +148,7 @@ class Savetables : INBTSerializable { } fun bool(prop: KMutableProperty0, name: String = prop.name): Stateless { - return Stateless(prop, name, NumericTag::class.java) - .withSerializer { ByteTag.valueOf(it) } - .withDeserializer { it.asByte > 0 } + return bool(prop.asGetterSetter(), name) } fun string(prop: GetterSetter, name: String): Stateless { @@ -170,9 +158,7 @@ class Savetables : INBTSerializable { } fun string(prop: KMutableProperty0, name: String = prop.name): Stateless { - return Stateless(prop, name, StringTag::class.java) - .withSerializer { StringTag.valueOf(it) } - .withDeserializer { it.asString } + return string(prop.asGetterSetter(), name) } fun > enum(prop: GetterSetter, name: String, map: (String) -> E): Stateless { @@ -182,9 +168,7 @@ class Savetables : INBTSerializable { } fun > enum(prop: KMutableProperty0, name: String = prop.name, map: (String) -> E): Stateless { - return Stateless(prop, name, StringTag::class.java) - .withSerializer { StringTag.valueOf(it.name) } - .withDeserializer { map.invoke(it.asString) } + return enum(prop.asGetterSetter(), name, map) } fun codecNullable(prop: GetterSetter, codec: Codec, name: String): Stateless { @@ -197,49 +181,52 @@ class Savetables : INBTSerializable { return codecNullable(prop.asGetterSetter(), codec, name) } + fun codecNullable(prop: GetterSetter, codec: Codec, name: String, default: T?): Stateless { + return Stateless(prop, name, Tag::class.java) + .withSerializer { prop.get()?.let { codec.encode(it, NbtOps.INSTANCE, NbtOps.INSTANCE.empty()).getOrThrow(false) { throw IllegalStateException("Failed to write NBT data for $name: $it") } } } + .withDeserializer { codec.decode(NbtOps.INSTANCE, it).get().map({ it.first }, { LOGGER.error("Failed to read NBT data for $name", RuntimeException(it.message())); default }) } + .withDefault { default } + } + + fun codecNullable(prop: KMutableProperty0, codec: Codec, name: String = prop.name, default: T?): Stateless { + return codecNullable(prop.asGetterSetter(), codec, name, default) + } + fun codec(prop: GetterSetter, codec: Codec, name: String): Stateless { return Stateless(prop, name, Tag::class.java) .withSerializer { codec.encode(prop.get(), NbtOps.INSTANCE, NbtOps.INSTANCE.empty()).getOrThrow(false) { throw IllegalStateException("Failed to write NBT data for $name: $it") } } .withDeserializer { codec.decode(NbtOps.INSTANCE, it).getOrThrow(false) { throw IllegalStateException("Failed to read NBT data for $name: $it") }.first } } + fun codec(prop: GetterSetter, codec: Codec, name: String, default: T): Stateless { + return Stateless(prop, name, Tag::class.java) + .withSerializer { codec.encode(prop.get(), NbtOps.INSTANCE, NbtOps.INSTANCE.empty()).getOrThrow(false) { throw IllegalStateException("Failed to write NBT data for $name: $it") } } + .withDeserializer { codec.decode(NbtOps.INSTANCE, it).get().map({ it.first }, { LOGGER.error("Failed to read NBT data for $name", RuntimeException(it.message())); default }) } + .withDefault { default } + } + fun codec(prop: KMutableProperty0, codec: Codec, name: String = prop.name): Stateless { return codec(prop.asGetterSetter(), codec, name) } - fun vector(prop: GetterSetter, name: String, default: Vector = Vector.ZERO): Stateless { - return Stateless(prop, name, ListTag::class.java) - .withSerializer { ListTag().also { l -> - l.add(DoubleTag.valueOf(it.x)) - l.add(DoubleTag.valueOf(it.y)) - l.add(DoubleTag.valueOf(it.z)) - } } - .withDeserializer { - if (it.size < 3) { - default - } else { - val x = it[0] as? NumericTag ?: return@withDeserializer default - val y = it[1] as? NumericTag ?: return@withDeserializer default - val z = it[2] as? NumericTag ?: return@withDeserializer default - Vector(x.asDouble, y.asDouble, z.asDouble) - } - } + fun codec(prop: KMutableProperty0, codec: Codec, name: String = prop.name, default: T): Stateless { + return codec(prop.asGetterSetter(), codec, name, default) } - fun vector(prop: KMutableProperty0, name: String = prop.name, default: Vector = Vector.ZERO): Stateless { + fun vector(prop: GetterSetter, name: String, default: Vector = Vector.ZERO): Stateless { + return codec(prop, Vector.CODEC, name, default) + } + + fun vector(prop: KMutableProperty0, name: String = prop.name, default: Vector = Vector.ZERO): Stateless { return vector(prop.asGetterSetter(), name, default) } - fun location(prop: GetterSetter, name: String): Stateless { - return Stateless(prop, name, StringTag::class.java) - .withSerializer { StringTag.valueOf(it.toString()) } - .withDeserializer { ResourceLocation(it.asString) } + fun location(prop: GetterSetter, name: String): Stateless { + return codec(prop, ResourceLocation.CODEC, name) } - fun location(prop: KMutableProperty0, name: String = prop.name): Stateless { - return Stateless(prop, name, StringTag::class.java) - .withSerializer { StringTag.valueOf(it.toString()) } - .withDeserializer { ResourceLocation(it.asString) } + fun location(prop: KMutableProperty0, name: String = prop.name): Stateless { + return location(prop.asGetterSetter(), name) } override fun serializeNBT(): CompoundTag { @@ -381,4 +368,8 @@ class Savetables : INBTSerializable { } } } + + companion object { + private val LOGGER = LogManager.getLogger() + } } From 218bb17cc456772cf28cf15700ee32c7e8e819f7 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 22 Aug 2023 11:35:00 +0700 Subject: [PATCH 1030/1199] Faster filtering and flatmapping iterators --- .../mc/otm/core/collect/StreamyIterators.kt | 189 +++++++++--------- 1 file changed, 89 insertions(+), 100 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt index 5377de346..3a925efff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt @@ -1,11 +1,15 @@ package ru.dbotthepony.mc.otm.core.collect +import it.unimi.dsi.fastutil.ints.Int2IntFunction +import it.unimi.dsi.fastutil.ints.IntIterator +import it.unimi.dsi.fastutil.ints.IntIterators import it.unimi.dsi.fastutil.objects.ObjectIterators import ru.dbotthepony.mc.otm.core.addAll import java.util.Optional import java.util.Spliterator import java.util.Spliterators import java.util.function.BinaryOperator +import java.util.function.IntPredicate import java.util.function.Predicate import java.util.function.Supplier import java.util.stream.Collector @@ -21,68 +25,43 @@ import java.util.stream.StreamSupport // Aside parallel work, unimplemented Stream API elements can be easily implemented when required -/** - * Filters elements of [parent] iterator - * - * Resulting [Iterator] is [MutableIterator] if [parent] is - */ -class FilteringIterator(private val parent: Iterator, private val predicate: Predicate) : MutableIterator { - private var foundValue: Any? = Companion +private class FilteringIterator(private val parent: Iterator, private val predicate: Predicate) : MutableIterator { + private var value: T = parent.next() + private var hasValue = true private var returned = false override fun hasNext(): Boolean { - if (foundValue === Companion) { - while (parent.hasNext()) { - val next = parent.next() - - if (predicate.test(next)) { - foundValue = next - return true - } - } - - return false - } - - return true + return hasValue } - @Suppress("unchecked_cast") override fun next(): T { - var foundValue = foundValue + if (!hasValue) throw NoSuchElementException() + hasValue = false + returned = true - if (foundValue === Companion) { - if (!hasNext()) { - throw NoSuchElementException() - } + val value = this.value - foundValue = this.foundValue + while (parent.hasNext()) { + val next = parent.next() - if (foundValue === Companion) { - throw ConcurrentModificationException() + if (predicate.test(next)) { + hasValue = true + this.value = next + break } } - this.foundValue = Companion - returned = true - return foundValue as T + return value } override fun remove() { if (!returned) throw NoSuchElementException() - (parent as MutableIterator).remove() returned = false + (parent as MutableIterator).remove() } - - private companion object } -/** - * Maps elements of [parent] iterator from values of [T] to [R] using function [mapper] - * - * Resulting [Iterator] is [MutableIterator] if [parent] is - */ -class MappingIterator(private val parent: Iterator, private val mapper: (T) -> R) : MutableIterator { +private class MappingIterator(private val parent: Iterator, private val mapper: (T) -> R) : MutableIterator { override fun hasNext(): Boolean { return parent.hasNext() } @@ -96,29 +75,28 @@ class MappingIterator(private val parent: Iterator, private val mapper: } } -/** - * Maps elements of [parent] iterator from type [T] to other iterators of type [R] using function [mapper] - * - * Resulting [Iterator] is [MutableIterator] if [parent] is - */ -class FlatMappingIterator(private val parent: Iterator, private val mapper: (T) -> Iterator) : MutableIterator { - private var current: Iterator? = null +private class FlatMappingIterator(private val parent: Iterator, private val mapper: (T) -> Iterator) : MutableIterator { + private var current: Iterator = mapper.invoke(parent.next()) private var last: Iterator? = null + private var hasNext = current.hasNext() override fun hasNext(): Boolean { - while (current?.hasNext() != true && parent.hasNext()) { - current = mapper.invoke(parent.next()) - } - - return current?.hasNext() == true + return hasNext } override fun next(): R { - if (!hasNext()) + if (!hasNext) throw NoSuchElementException() - val v = current!!.next() + val v = current.next() last = current + hasNext = false + + while (!hasNext && parent.hasNext()) { + current = mapper.invoke(parent.next()) + hasNext = current.hasNext() + } + return v } @@ -128,12 +106,7 @@ class FlatMappingIterator(private val parent: Iterator, private val map } } -/** - * Limits amount of values returned by [parent] iterator to return at most [limit] values - * - * Resulting [Iterator] is [MutableIterator] if [parent] is - */ -class LimitingIterator(private val parent: Iterator, private val limit: Long) : Iterator { +private class LimitingIterator(private val parent: Iterator, private val limit: Long) : Iterator { init { require(limit > 0) { "Invalid limit $limit" } } @@ -152,12 +125,7 @@ class LimitingIterator(private val parent: Iterator, private val limit: Lo } } -/** - * Skips (discards) up to [skip] values returned by [parent] iterator - * - * Resulting [Iterator] is [MutableIterator] if [parent] is - */ -class SkippingIterator(private val parent: Iterator, skip: Long) : MutableIterator { +private class SkippingIterator(private val parent: Iterator, skip: Long) : MutableIterator { init { require(skip >= 0) { "Invalid skip amount $skip" } } @@ -214,71 +182,92 @@ fun concatIterators(vararg iterators: Iterator): MutableIterator { * * Resulting [Iterator] is [MutableIterator] if [this] is */ -fun Iterator.filter(condition: Predicate) = FilteringIterator(this, condition) +fun Iterator.filter(condition: Predicate): MutableIterator { + if (!hasNext()) { + return emptyIterator() + } + + return FilteringIterator(this, condition) +} /** * Maps elements of [this] iterator from values of [T] to [R] using function [mapper] * * Resulting [Iterator] is [MutableIterator] if [this] is */ -fun Iterator.map(mapper: (T) -> R) = MappingIterator(this, mapper) +fun Iterator.map(mapper: (T) -> R): MutableIterator { + if (!hasNext()) { + return emptyIterator() + } -/** - * Maps elements of [this] iterator from values of [T] to [R] using function [mapper] - * - * Resulting [Iterator] is [MutableIterator] if [this] is - */ -fun Iterator.map(mapper: java.util.function.Function) = MappingIterator(this, mapper::apply) + return MappingIterator(this, mapper) +} /** * Maps elements of [this] iterator from type [T] to other iterators of type [R] using function [mapper] * * Resulting [Iterator] is [MutableIterator] if [this] is */ -fun Iterator.flatMap(mapper: (T) -> Iterator) = FlatMappingIterator(this, mapper) +fun Iterator.flatMap(mapper: (T) -> Iterator): MutableIterator { + if (!hasNext()) { + return emptyIterator() + } -/** - * Maps elements of [this] iterator from type [T] to other iterators of type [R] using function [mapper] - * - * Resulting [Iterator] is [MutableIterator] if [this] is - */ -fun Iterator.flatMap(mapper: java.util.function.Function>) = FlatMappingIterator(this, mapper::apply) + return FlatMappingIterator(this, mapper) +} -fun Iterator.reduce(identity: T, reducer: (T, T) -> T): T { +inline fun Iterator.reduce(identity: T, reducer: (T, T) -> T): T { var result = identity - for (value in this) result = reducer.invoke(result, value) + while (hasNext()) result = reducer.invoke(result, next()) return result } -fun Iterator.reduce(identity: T, reducer: BinaryOperator): T = reduce(identity, reducer::apply) fun Iterator.filterNotNull(): MutableIterator = filter { it != null } as MutableIterator fun Iterator.any(predicate: Predicate): Boolean { - for (value in this) { - if (predicate.test(value)) { + while (hasNext()) + if (predicate.test(next())) + return true + + return false +} + +inline fun Iterator.any(predicate: (T) -> Boolean): Boolean { + while (hasNext()) + if (predicate.invoke(next())) return true - } - } return false } fun Iterator.all(predicate: Predicate): Boolean { - for (value in this) { - if (!predicate.test(value)) { + while (hasNext()) + if (!predicate.test(next())) + return false + + return true +} + +inline fun Iterator.all(predicate: (T) -> Boolean): Boolean { + while (hasNext()) + if (!predicate.invoke(next())) return false - } - } return true } fun Iterator.none(predicate: Predicate): Boolean { - for (value in this) { - if (predicate.test(value)) { + while (hasNext()) + if (predicate.test(next())) + return false + + return true +} + +inline fun Iterator.none(predicate: (T) -> Boolean): Boolean { + while (hasNext()) + if (predicate.invoke(next())) return false - } - } return true } @@ -308,8 +297,8 @@ fun Iterator.find(): Optional { return Optional.empty() } -fun Iterator.limit(limit: Long) = LimitingIterator(this, limit) -fun Iterator.skip(skip: Long) = if (skip == 0L) this else SkippingIterator(this, skip) +fun Iterator.limit(limit: Long): Iterator = LimitingIterator(this, limit) +fun Iterator.skip(skip: Long): Iterator = if (skip == 0L) this else SkippingIterator(this, skip) inline fun Iterator.forEach(action: (T) -> Unit) { for (value in this) { From 98e7ea96b2ea140bdbbb9d5bf36ca022e1dcee0e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 22 Aug 2023 11:50:43 +0700 Subject: [PATCH 1031/1199] a --- .../mc/otm/core/collect/StreamyIterators.kt | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt index 3a925efff..572e0cb10 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt @@ -25,8 +25,7 @@ import java.util.stream.StreamSupport // Aside parallel work, unimplemented Stream API elements can be easily implemented when required -private class FilteringIterator(private val parent: Iterator, private val predicate: Predicate) : MutableIterator { - private var value: T = parent.next() +private class FilteringIterator(private val parent: Iterator, private val predicate: Predicate, private var value: T) : MutableIterator { private var hasValue = true private var returned = false @@ -78,23 +77,26 @@ private class MappingIterator(private val parent: Iterator, private val private class FlatMappingIterator(private val parent: Iterator, private val mapper: (T) -> Iterator) : MutableIterator { private var current: Iterator = mapper.invoke(parent.next()) private var last: Iterator? = null - private var hasNext = current.hasNext() + + init { + while (!current.hasNext() && parent.hasNext()) { + current = mapper.invoke(parent.next()) + } + } override fun hasNext(): Boolean { - return hasNext + return current.hasNext() } override fun next(): R { - if (!hasNext) + if (!current.hasNext()) throw NoSuchElementException() val v = current.next() last = current - hasNext = false - while (!hasNext && parent.hasNext()) { + while (!current.hasNext() && parent.hasNext()) { current = mapper.invoke(parent.next()) - hasNext = current.hasNext() } return v @@ -183,11 +185,15 @@ fun concatIterators(vararg iterators: Iterator): MutableIterator { * Resulting [Iterator] is [MutableIterator] if [this] is */ fun Iterator.filter(condition: Predicate): MutableIterator { - if (!hasNext()) { - return emptyIterator() + while (hasNext()) { + val v = next() + + if (condition.test(v)) { + return FilteringIterator(this, condition, v) + } } - return FilteringIterator(this, condition) + return emptyIterator() } /** From e61d98e54decb678ec85eefe1c314e02f783e98c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 22 Aug 2023 11:58:56 +0700 Subject: [PATCH 1032/1199] Bulk painting --- .../mc/otm/datagen/lang/English.kt | 4 +++ .../mc/otm/datagen/lang/Russian.kt | 6 ++++ .../otm/capability/MatteryPlayerCapability.kt | 13 ++++----- .../client/screen/decorative/PainterScreen.kt | 16 ++++++++-- .../mc/otm/container/util/Iterators.kt | 4 +++ .../mc/otm/menu/decorative/PainterMenu.kt | 29 ++++++++++++++++--- 6 files changed, 58 insertions(+), 14 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 9c54129d6..0933e3658 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -714,6 +714,10 @@ private fun gui(provider: MatteryLanguageProvider) { with(provider.english) { gui("quicksearch", "Quick search...") + gui("painter.is_bulk", "Bulk painting") + gui("painter.is_bulk.desc", "Input slot will be automatically refilled from your inventory") + gui("painter.is_bulk.desc2", "Quick moving result will paint as many items as possible from your inventory") + gui("energy_required", "Energy required: %s") gui("insert_priority", "Insert priority") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index f786f55dd..1bd3e87b8 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -716,6 +716,12 @@ private fun gui(provider: MatteryLanguageProvider) { with(provider.russian) { gui("quicksearch", "Быстрый поиск...") + gui("painter.is_bulk", "Массовая покраска") + gui("painter.is_bulk.desc", "Слот покраски будет автоматически наполняться из вашего инвентаря") + gui("painter.is_bulk.desc2", "Быстрое перемещение покрасит максимальное количество предметов из вашего инвентаря") + + gui("energy_required", "Требуется энергии: %s") + gui("insert_priority", "Приоритет вставки") gui("extract_priority", "Приоритет забора") gui("increase", "Увеличить") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 0206cddda..47f9e8b4a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -413,14 +413,8 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial private var shouldSendIteration = false - /** - * Android' iteration counter (death counter, updating only when Android) - */ - var iteration = 0 - private set - + private var iteration = 0 private var lastDeathTick = 0 - private val deathLog = ArrayDeque>() private val featureMap = IdentityHashMap, AndroidFeature>() @@ -433,6 +427,8 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial private var nextDischargeHurt = 20 private var nextHealTick = 0 + var painterBulkCrafting = false + // players tracking us // stored separately because EntityTracker and ChunkMup, etc are buried deep and // getting them unburied will be a very work intense task @@ -572,6 +568,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial savetables.int(::ticksIExist) savetables.int(::iteration) + savetables.bool(::painterBulkCrafting) savetables.bool(::shouldSendIteration) savetables.bool(::wasInLiquid) savetables.bool(::isAndroid) @@ -584,7 +581,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial savetables.int(::nextHealTick) savetables.vector(::lastOutsideLiquid) - savetables.location(::lastDimension) + savetables.codec(::lastDimension, ResourceLocation.CODEC) savetables.stateful(::exopackSlotModifier, "exoSuitSlotCountModifiers") savetables.stateful(::exopackContainer, "exoSuitContainer") 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 11e2820ea..e8f329b00 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 @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.client.screen.decorative +import net.minecraft.ChatFormatting import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component import net.minecraft.util.RandomSource @@ -18,6 +19,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.button.CheckBoxLabelInputPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.DeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.RectangleButtonPanel @@ -30,7 +32,7 @@ import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.menu.decorative.PainterMenu class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { - inner class Bar(parent: EditablePanel<*>, val dye: DyeColor) : EditablePanel(this@PainterScreen, parent, width = 5f) { + private inner class Bar(parent: EditablePanel<*>, val dye: DyeColor) : EditablePanel(this@PainterScreen, parent, width = 5f) { init { dock = Dock.RIGHT dockLeft = 1f @@ -100,12 +102,22 @@ class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : .fixed() } - val canvas = ScrollableCanvasPanel(this, frame) + val column = EditablePanel(this, frame) + column.dock = Dock.FILL + + val bulk = CheckBoxLabelInputPanel(this, column, menu.isBulk, TranslatableComponent("otm.gui.painter.is_bulk")) + bulk.dock = Dock.BOTTOM + bulk.tooltips.add(TranslatableComponent("otm.gui.painter.is_bulk.desc")) + bulk.tooltips.add(TranslatableComponent("otm.gui.painter.is_bulk.desc2").withStyle(ChatFormatting.GRAY)) + bulk.dockBottom = 4f + + val canvas = ScrollableCanvasPanel(this, column) canvas.dock = Dock.FILL val buttons = ArrayList>() menu.listeners.addListener { + if (frame.isRemoved) return@addListener buttons.forEach { it.remove() } buttons.clear() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/util/Iterators.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/util/Iterators.kt index a0063258e..e2cb1ed31 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/util/Iterators.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/util/Iterators.kt @@ -46,6 +46,10 @@ interface IContainerSlot : GetterSetter { container[slot] = ItemStack.EMPTY } + fun remove(count: Int): ItemStack { + return container.removeItem(slot, count) + } + override fun get(): ItemStack { return container[slot] } 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 7dd9dc7f1..dcae8129a 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 @@ -6,17 +6,21 @@ import net.minecraft.world.entity.player.Player import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.block.entity.decorative.PainterBlockEntity +import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.core.ISubscriptable import ru.dbotthepony.mc.otm.core.addAll import ru.dbotthepony.mc.otm.core.collect.SupplierMap import ru.dbotthepony.mc.otm.core.collect.filter +import ru.dbotthepony.mc.otm.core.collect.find +import ru.dbotthepony.mc.otm.core.collect.maybe import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.core.map import ru.dbotthepony.mc.otm.core.util.CreativeMenuItemComparator import ru.dbotthepony.mc.otm.core.util.ResourceLocationValueCodec import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput import ru.dbotthepony.mc.otm.recipe.PainterRecipe import ru.dbotthepony.mc.otm.registry.MMenus @@ -40,6 +44,8 @@ class PainterMenu( private var lastRecipe: PainterRecipe? = null var selectedRecipe by mSynchronizer.Field(null, ResourceLocationValueCodec.nullable).also { it.addListener { rescan() } } + val isBulk = BooleanInputWithFeedback(this, true, player.matteryPlayer!!::painterBulkCrafting) + val selectRecipe = PlayerInput(ResourceLocationValueCodec) { selectedRecipe = it } @@ -56,13 +62,28 @@ class PainterMenu( return super.tryRemove(p_150642_, p_150643_, p_150644_) } - override fun onTake(p_150645_: Player, p_150646_: ItemStack) { - if (p_150646_.isNotEmpty) { + override fun onTake(player: Player, itemStack: ItemStack) { + if (itemStack.isNotEmpty) { lastRecipe?.dyes?.let { tile?.takeDyes(it) } - inputContainer.removeItem(0, 1) + + if (isBulk.value) { + val found = player.matteryPlayer!!.inventoryAndExopack + .slotIterator() + .filter { !it.isForbiddenForAutomation && ItemStack.isSameItemSameTags(it.item, inputSlot.item) } + .maybe() + + if (found != null) { + found.remove(1) + rescan() + } else { + inputContainer.removeItem(0, 1) + } + } else { + inputContainer.removeItem(0, 1) + } } - super.onTake(p_150645_, p_150646_) + super.onTake(player, itemStack) } override fun mayPlace(itemStack: ItemStack): Boolean { From edd16768e3d0f0ce13643a54d8f65eb3510bb9ea Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 22 Aug 2023 12:16:24 +0700 Subject: [PATCH 1033/1199] Store "is bulk" flag inside painting table itself --- .../mc/otm/block/entity/decorative/PainterBlockEntity.kt | 7 +++++++ .../mc/otm/capability/MatteryPlayerCapability.kt | 3 --- .../ru/dbotthepony/mc/otm/menu/decorative/PainterMenu.kt | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) 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 248f75ff8..c5272967c 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 @@ -30,9 +30,16 @@ class PainterBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDe private val dyeStored = EnumMap(DyeColor::class.java) val dyeStoredView: Map = Collections.unmodifiableMap(dyeStored) + var isBulk = false + set(value) { + field = value + markDirtyFast() + } + init { addDroppableContainer(dyeInput) savetables.stateful(dyeInput, INVENTORY_KEY) + savetables.bool(::isBulk) } fun takeDyes(dyes: Map) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 47f9e8b4a..6d7ed4b3b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -427,8 +427,6 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial private var nextDischargeHurt = 20 private var nextHealTick = 0 - var painterBulkCrafting = false - // players tracking us // stored separately because EntityTracker and ChunkMup, etc are buried deep and // getting them unburied will be a very work intense task @@ -568,7 +566,6 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial savetables.int(::ticksIExist) savetables.int(::iteration) - savetables.bool(::painterBulkCrafting) savetables.bool(::shouldSendIteration) savetables.bool(::wasInLiquid) savetables.bool(::isAndroid) 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 dcae8129a..4bea5d4dd 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 @@ -44,7 +44,7 @@ class PainterMenu( private var lastRecipe: PainterRecipe? = null var selectedRecipe by mSynchronizer.Field(null, ResourceLocationValueCodec.nullable).also { it.addListener { rescan() } } - val isBulk = BooleanInputWithFeedback(this, true, player.matteryPlayer!!::painterBulkCrafting) + val isBulk = BooleanInputWithFeedback(this, tile?.let { it::isBulk }) val selectRecipe = PlayerInput(ResourceLocationValueCodec) { selectedRecipe = it From 51ec99d8ddc56cde88535ed0da7bef2275b87d6b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 22 Aug 2023 15:47:50 +0700 Subject: [PATCH 1034/1199] Actually account for case when both references refer to null --- .../dbotthepony/mc/otm/core/collect/ReferenceHashStrategy.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ReferenceHashStrategy.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ReferenceHashStrategy.kt index eb3e61200..a8ed01173 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ReferenceHashStrategy.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/ReferenceHashStrategy.kt @@ -9,8 +9,9 @@ object ReferenceHashStrategy : Hash.Strategy { if (a == null || b == null) return false if (a is Reference<*>) { - if (b is Reference<*>) return a.get() != null && a.get() == b.get() - return a.get() == b + val ref = a.get() + if (b is Reference<*>) return ref != null && ref == b.get() + return ref == b } else if (b is Reference<*>) { return b.get() == a } else { From 87d35eb4afe24852ddda195af58e57074dfcf70d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 22 Aug 2023 16:31:22 +0700 Subject: [PATCH 1035/1199] Fix double wrapping sort settings into player input --- src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index e3299f78e..c86d38b2c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -179,9 +179,7 @@ abstract class MatteryMenu( } } - inner class SortInput(val container: Container, settings: IItemStackSortingSettings?) { - val settings = IItemStackSortingSettings.inputs(this@MatteryMenu, settings) - + inner class SortInput(val container: Container, val settings: IItemStackSortingSettings) { val input = PlayerInput(CollectionStreamCodec(VarIntValueCodec, ::IntArrayList)) { container.sortWithIndices(it) } From 967b8c71d884aa30c212cbe2336c65c1f1696f85 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 22 Aug 2023 17:46:07 +0700 Subject: [PATCH 1036/1199] Use hash set since we don't need sorting --- .../kotlin/ru/dbotthepony/mc/otm/container/ContainerHelpers.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 ad2c35539..c50cd7b5c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHelpers.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHelpers.kt @@ -7,6 +7,7 @@ import it.unimi.dsi.fastutil.ints.IntCollection import it.unimi.dsi.fastutil.ints.IntIterable import it.unimi.dsi.fastutil.ints.IntIterator import it.unimi.dsi.fastutil.ints.IntList +import it.unimi.dsi.fastutil.ints.IntOpenHashSet import it.unimi.dsi.fastutil.ints.IntSet import it.unimi.dsi.fastutil.objects.Object2ObjectFunction import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap @@ -324,7 +325,7 @@ fun Container.sortWithIndices(sortedSlots: IntCollection) { if (sortedSlots.isEmpty() || isEmpty) return - val seen = IntAVLTreeSet() + val seen = IntOpenHashSet() val valid = ArrayList() val iterator = sortedSlots.intIterator() From 9bebe7428208f610e87febaef15f9f3a1466ca46 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 23 Aug 2023 00:37:24 +0700 Subject: [PATCH 1037/1199] Restore vanilla behavior regarding picking up items --- .../otm/capability/MatteryPlayerCapability.kt | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 6d7ed4b3b..20d101fd9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.capability import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack import it.unimi.dsi.fastutil.ints.IntAVLTreeSet +import it.unimi.dsi.fastutil.ints.IntSet import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import net.minecraft.ChatFormatting import net.minecraft.client.model.PlayerModel @@ -98,7 +99,6 @@ import ru.dbotthepony.mc.otm.core.nbt.getIntList import ru.dbotthepony.mc.otm.core.nbt.getStringList import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.util.IntValueCodec -import ru.dbotthepony.mc.otm.core.util.ItemStackSorter import ru.dbotthepony.mc.otm.core.util.ItemValueCodec import ru.dbotthepony.mc.otm.core.util.RGBCodec import ru.dbotthepony.mc.otm.core.util.Savetables @@ -302,9 +302,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial value.addFilterSynchronizer(synchronizer) field = value - _combinedInventory = CombinedContainer(wrappedInventory, exopackContainer) - _combinedInventory2 = CombinedContainer(wrappedItemInventory, exopackContainer) - _combinedInventory3 = CombinedContainer.Builder().add(wrappedItemInventory, 9 .. 35).add(exopackContainer).build() + _combinedInventory = null + _combinedInventory2 = null + _combinedInventory3 = null } private var _combinedInventory: CombinedContainer? = null @@ -351,7 +351,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial val inventoryAndExopackNoHotbar: CombinedContainer get() { if (_combinedInventory3 == null) - _combinedInventory3 = CombinedContainer.Builder().add(wrappedItemInventory, 9 .. 35).add(exopackContainer).build() + _combinedInventory3 = CombinedContainer.Builder() + .add(wrappedItemInventory, 9 .. 35) + .add(exopackContainer).build() return _combinedInventory3!! } @@ -1375,9 +1377,13 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial */ fun inventoryAddImpl(stack: ItemStack): Boolean { if (hasExopack) { - inventoryAndExopack.consumeItem(stack, false, popTime = 5) + combinedInventory.consumeItem(stack, false, slots = IntSet.of(ply.inventory.selected), onlyIntoExisting = true, popTime = 5) + combinedInventory.consumeItem(stack, false, slots = offhandSlotRange, onlyIntoExisting = true, popTime = 5) + inventoryAndExopack.consumeItem(stack, false, onlyIntoExisting = false, popTime = 5) } else { - wrappedItemInventory.consumeItem(stack, false, popTime = 5) + wrappedInventory.consumeItem(stack, false, slots = IntSet.of(ply.inventory.selected), onlyIntoExisting = false, popTime = 5) + wrappedInventory.consumeItem(stack, false, slots = offhandSlotRange, onlyIntoExisting = false, popTime = 5) + wrappedItemInventory.consumeItem(stack, false, onlyIntoExisting = false, popTime = 5) } MinecraftForge.EVENT_BUS.post(ItemStackLeftoverEvent(stack, this)) @@ -1412,6 +1418,8 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial @Suppress("unused") companion object { + private val offhandSlotRange = IntSet.of(40) + private fun setExoPack(players: Collection, hasExoPack: Boolean): Int { for (player in players) { player.matteryPlayer?.hasExopack = hasExoPack From 51f7fc264c863d8c409384e20a57bef9d8a86836 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Wed, 23 Aug 2023 03:24:06 +0300 Subject: [PATCH 1038/1199] armor trims for simple tritanium armor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit я хочу убивать --- .../mc/otm/datagen/items/ItemModels.kt | 2 +- .../datagen/items/MatteryItemModelProvider.kt | 37 ++++++++++++++++++- .../dbotthepony/mc/otm/datagen/tags/Tags.kt | 2 + 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index 59a70b3fa..8de978077 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -88,7 +88,7 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.handheld(MItems.TRITANIUM_TOOLS) provider.generated(MItems.TRITANIUM_ARMOR) - provider.generated(MItems.SIMPLE_TRITANIUM_ARMOR) + provider.armorWithTrims(MItems.SIMPLE_TRITANIUM_ARMOR) provider.generatedTiered(MItems.BATTERIES, "battery_tier") provider.generated(MItems.BATTERY_CREATIVE) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt index 643c6e77b..915de8993 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt @@ -1,12 +1,15 @@ package ru.dbotthepony.mc.otm.datagen.items +import net.minecraft.data.models.ItemModelGenerators import net.minecraft.resources.ResourceLocation +import net.minecraft.world.item.ArmorItem import net.minecraft.world.item.Item import net.minecraftforge.client.model.generators.ItemModelProvider +import net.minecraftforge.client.model.generators.ModelBuilder import net.minecraftforge.data.event.GatherDataEvent import org.apache.logging.log4j.LogManager -import ru.dbotthepony.mc.otm.datagen.DataGen import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.datagen.DataGen import ru.dbotthepony.mc.otm.datagen.modLocation import java.util.LinkedList @@ -78,7 +81,39 @@ class MatteryItemModelProvider(event: GatherDataEvent) : ItemModelProvider(event } } + fun armorWithTrims(item: Item, texture: ResourceLocation) = exec { + val mainModel = withExistingParent(item.registryName!!.path, GENERATED).texture("layer0", texture) + + if (item is ArmorItem) { + for (i in 0 until ARMOR_TRIM_MATERIALS.size) { + val material = ARMOR_TRIM_MATERIALS[i] + + val overrideModel = withExistingParent("${item.registryName!!.path}_${material}_trim", GENERATED) + .texture("layer0", texture) +// .texture("layer1", mcLoc("trims/items/${item.type.getName()}_trim_${material}")) + + // спасибо за проверку наличия файлов КОТОРЫЕ ГЕНЕРИРУЮТСЯ В РАНТАЙМЕ И В ДАТАГЕНЕ НЕ СУЩЕСТВУЮТ + val texturesField = ModelBuilder::class.java.getDeclaredField("textures") + texturesField.trySetAccessible() + + // произошёл троллинг + val textures = texturesField.get(overrideModel) as LinkedHashMap + textures["layer1"] = "minecraft:trims/items/${item.type.getName()}_trim_${material}" + + mainModel.override() + .predicate(ItemModelGenerators.TRIM_TYPE_PREDICATE_ID, (i + 1).toFloat() / ARMOR_TRIM_MATERIALS.size.toFloat()) + .model(overrideModel) + .end() + } + } + + } + + fun armorWithTrims(vararg items: Item) = items.forEach { armorWithTrims(it, modLocation("item/${it.registryName!!.path}")) } + fun armorWithTrims(items: Collection) = items.forEach { armorWithTrims(it, modLocation("item/${it.registryName!!.path}")) } + companion object { + val ARMOR_TRIM_MATERIALS = listOf("quartz", "iron", "netherite", "redstone", "copper", "gold", "emerald", "diamond", "lapis", "amethyst") val GENERATED = ResourceLocation("minecraft", "item/generated") val HANDHELD = ResourceLocation("minecraft", "item/handheld") private val LOGGER = LogManager.getLogger() diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index 1563e0e75..a75c50d42 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -105,6 +105,8 @@ fun addTags(tagsProvider: TagsProvider) { .add("leggings", MItems.SIMPLE_TRITANIUM_PANTS) .add("boots", MItems.SIMPLE_TRITANIUM_BOOTS) + tagsProvider.items.minecraft("trimmable_armor").add(MItems.SIMPLE_TRITANIUM_ARMOR) + tagsProvider.items.minecraft("swords").add(MItems.TRITANIUM_SWORD) tagsProvider.items.minecraft("axes").add(MItems.TRITANIUM_AXE) tagsProvider.items.minecraft("pickaxes").add(MItems.TRITANIUM_PICKAXE) From 61d799fb2916b03a72bf617aeaacabf6d071f54f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 23 Aug 2023 13:13:16 +0700 Subject: [PATCH 1039/1199] Don't check for null multiple times --- .../mc/otm/block/entity/MatteryBlockEntity.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 1714205fe..3bbc3582d 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 @@ -287,8 +287,10 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc ?.chunkSource ?.getChunkNow(SectionPos.blockToSectionCoord(targetPos.x), SectionPos.blockToSectionCoord(targetPos.z)) + val subref = subscriptions[capability] as SubRef + if (chunk == null) { - subscriptions[capability]!!.unset() + subref.unset() level?.once { updateTracked(capability) } return } @@ -296,19 +298,17 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc val entity = chunk.getBlockEntity(targetPos) if (entity == null) { - subscriptions[capability]!!.unset() + subref.unset() return } val new = entity.getCapability(capability, dir.opposite) if (!new.isPresent) { - subscriptions[capability]!!.unset() + subref.unset() return } - val subref = subscriptions[capability] as SubRef - if (subref.value !== new) { if (knownLOs.add(new)) { val ref = WeakReference(this) From 313f9cb39dcd35ac9eae4ce7f926db5c34d5b305 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 23 Aug 2023 14:24:43 +0700 Subject: [PATCH 1040/1199] Swim Boosters android feature, electromotor crafting component --- .../mc/otm/datagen/ResearchData.kt | 70 ++++++++++++++++-- .../mc/otm/datagen/lang/English.kt | 2 + .../mc/otm/datagen/lang/Russian.kt | 2 + .../datagen/recipes/CraftingTableRecipes.kt | 9 ++- .../otm/android/AndroidResearchDescription.kt | 8 ++ .../android/feature/SwimBoostersFeature.kt | 39 ++++++++++ .../mc/otm/config/AndroidConfig.kt | 4 + .../mc/otm/registry/AndroidFeatures.kt | 1 + .../ru/dbotthepony/mc/otm/registry/MItems.kt | 3 + .../ru/dbotthepony/mc/otm/registry/MNames.kt | 1 + .../textures/item/component/electromotor.png | Bin 0 -> 2437 bytes 11 files changed, 130 insertions(+), 9 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/SwimBoostersFeature.kt create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/component/electromotor.png diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt index 84b4d166a..c2397a2ec 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt @@ -43,6 +43,45 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang serializer.accept(IMPROVED_LIMBS) + val SWIM_BOOSTERS = AndroidResearchType.Builder(modLocation(MNames.SWIM_BOOSTERS)) + .withExperience(26) + .withDescription(AndroidResearchDescriptions.SWIM_BOOSTERS.Instance(0)) + .addPrerequisite(IMPROVED_LIMBS) + .addPrerequisite(AIR_BAGS) + .addFeatureResult(AndroidFeatures.SWIM_BOOSTERS) + .withIcon(ResearchIcons.ICON_LIMB_OVERCLOCKING) + .addItem(MItemTags.TRITANIUM_PLATES, 2) + .addItem(MItemTags.COPPER_WIRES, 2) + .addItem(MItems.ELECTROMOTOR, 2) + .build() + + serializer.accept(SWIM_BOOSTERS) + + val SWIM_BOOSTERS_2 = AndroidResearchType.Builder(modLocation(MNames.SWIM_BOOSTERS + "_2")) + .withExperience(30) + .withDescription(AndroidResearchDescriptions.SWIM_BOOSTERS.Instance(1)) + .addPrerequisite(SWIM_BOOSTERS) + .addFeatureLevel(AndroidFeatures.SWIM_BOOSTERS) + .withIcon(ResearchIcons.ICON_LIMB_OVERCLOCKING) + .addItem(MItemTags.GOLD_WIRES, 8) + .addItem(MItems.ELECTROMOTOR, 2) + .build() + + serializer.accept(SWIM_BOOSTERS_2) + + val SWIM_BOOSTERS_3 = AndroidResearchType.Builder(modLocation(MNames.SWIM_BOOSTERS + "_3")) + .withExperience(30) + .withDescription(AndroidResearchDescriptions.SWIM_BOOSTERS.Instance(2)) + .addPrerequisite(SWIM_BOOSTERS_2) + .addFeatureLevel(AndroidFeatures.SWIM_BOOSTERS) + .withIcon(ResearchIcons.ICON_LIMB_OVERCLOCKING) + .addItem(MItemTags.CARBON_PLATES, 8) + .addItem(MItemTags.TRITANIUM_NUGGETS, 4) + .addItem(MItemTags.COPPER_WIRES, 2) + .build() + + serializer.accept(SWIM_BOOSTERS_3) + val STEP_ASSIST = AndroidResearchType.Builder(modLocation(MNames.STEP_ASSIST)) .withExperience(24) .addFeatureResult(AndroidFeatures.STEP_ASSIST) @@ -384,7 +423,7 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang } add(limbList[0], "Limb Overclocking %s") { - russian("Разгон Конечностей %s") + russian("Разгон конечностей %s") } add(limbList[0], "description", "Boosts mobility by %s%% and attack speed by %s%%") { @@ -392,7 +431,7 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang } add(AIR_BAGS, "Air Bags") { - russian("Воздушные Мешки") + russian("Воздушные мешки") } add(NANOBOTS, "Nanobots") { russian("Наноботы") @@ -415,7 +454,7 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang } add(NANOBOTS_ARMOR, "Nanobots Armor") { - russian("Броня из Наноботов") + russian("Броня из наноботов") } add(NANOBOTS_ARMOR, "description", "Allows nanobots to align themselves in cell shape, reducing incoming damage by a %% by absorbing impacts") { russian("Позволяет наноботам выстраиваться в клеточную структуру, уменьшая внешний урон на определённый проект путём поглощения ударов") @@ -429,35 +468,50 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang } add(armorStrengthList[0], "Nanobots Armor Strength %s") { - russian("Сила Слоя Брони Наноботов %s") + russian("Сила слоя брони наноботов %s") } add(armorStrengthList[0], "description", "Increases impact absorption strength of nanobots") { russian("Увеличивает поглощающею силу брони наноботов") } add(EXTENDED_REACH, "Extended Reach") { - russian("Удлинённые Манипуляторы") + russian("Удлинённые манипуляторы") } add(EXTENDED_REACH, "description", "Increases block interaction distance") { russian("Увеличивает радиус взаимодействия с блоками") } add(IMPROVED_LIMBS, "Improved Limbs") { - russian("Улучшенные Конечности") + russian("Улучшенные конечности") } add(IMPROVED_LIMBS, "description", "Allows limbs to be upgraded") { russian("Позволяет улучшать конечности") } + add(SWIM_BOOSTERS, "Swim Boosters") { + russian("Плавательные лопасти") + } + add(SWIM_BOOSTERS, "description", "Increases swimming speed by %s%%") { + russian("Ускоряет скорость плавания на %s%%") + } + + add(SWIM_BOOSTERS_2, "Swim Boosters 2") { + russian("Плавательные Лопасти 2") + } + + add(SWIM_BOOSTERS_3, "Swim Boosters 3") { + russian("Плавательные Лопасти 3") + } + add(STEP_ASSIST, "Step Assist") { - russian("Помощь Подъёма") + russian("Помощь подъёма") } add(STEP_ASSIST, "description", "Allows unit to step up whole blocks") { russian("Позволяет переступать полные блоки") } add(ITEM_MAGNET, "Item Magnet") { - russian("Предметный Магнит") + russian("Предметный магнит") } add(ITEM_MAGNET, "description0", "Pulls nearby items while active") { russian("Притягивает ближайшие предметы пока активен") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 0933e3658..c7cdbd1d1 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -605,6 +605,7 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.ADVANCED_CONTROL_CIRCUIT, "Advanced Control Circuit") add(MItems.QUANTUM_TRANSCEIVER, "Quantum Transceiver") add(MItems.ELECTROMAGNET, "Electromagnet") + add(MItems.ELECTROMOTOR, "Electromotor") add(MItems.MIRROR_COMPOUND, "Mirror Compound") add(MItems.MIRROR, "Mirror") add(MItems.MIRROR, "description", "I can clearly see my own reflection in this mirror") @@ -704,6 +705,7 @@ private fun androidFeatures(provider: MatteryLanguageProvider) { add(AndroidFeatures.NIGHT_VISION, "Night Vision") add(AndroidFeatures.NANOBOTS_ARMOR, "Nanobots Armor") add(AndroidFeatures.ITEM_MAGNET, "Item Magnet") + add(AndroidFeatures.SWIM_BOOSTERS, "Swim Boosters") add(AndroidFeatures.STEP_ASSIST, "Step Assist") add(AndroidFeatures.JUMP_BOOST, "Jump Boost") add(AndroidFeatures.ENDER_TELEPORTER, "Ender Teleporter") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 1bd3e87b8..228ad6d08 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -607,6 +607,7 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.ADVANCED_CONTROL_CIRCUIT, "Продвинутая схема управления") add(MItems.QUANTUM_TRANSCEIVER, "Квантовый передатчик") add(MItems.ELECTROMAGNET, "Электромагнит") + add(MItems.ELECTROMOTOR, "Электромотор") add(MItems.MIRROR_COMPOUND, "Набор выплавки зеркала") add(MItems.MIRROR, "Зеркало") add(MItems.MIRROR, "description", "Я могу очень отчётливо видеть своё отражение в этом зеркале") @@ -706,6 +707,7 @@ private fun androidFeatures(provider: MatteryLanguageProvider) { add(AndroidFeatures.NIGHT_VISION, "Ночное зрение") add(AndroidFeatures.NANOBOTS_ARMOR, "Броня из наноботов") add(AndroidFeatures.ITEM_MAGNET, "Предметный магнит") + add(AndroidFeatures.SWIM_BOOSTERS, "Плавательные лопасти") add(AndroidFeatures.STEP_ASSIST, "Помощник подъёма") add(AndroidFeatures.JUMP_BOOST, "Усилитель прыжка") add(AndroidFeatures.ENDER_TELEPORTER, "Телепортатор края") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index 6741a9151..889871d11 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -161,7 +161,14 @@ fun addCraftingTableRecipes(consumer: Consumer) { MatteryRecipe(MItems.ELECTROMAGNET, category = RecipeCategory.MISC) .row(MItemTags.COPPER_WIRES, Tags.Items.INGOTS_IRON, MItemTags.COPPER_WIRES) - .unlockedBy(Tags.Items.ENDER_PEARLS) + .unlockedBy(Tags.Items.INGOTS_IRON) + .build(consumer) + + MatteryRecipe(MItems.ELECTROMOTOR, category = RecipeCategory.MISC) + .rowB(MItems.ELECTROMAGNET) + .row(MItems.ELECTROMAGNET, Tags.Items.INGOTS_IRON, MItems.ELECTROMAGNET) + .row(MItemTags.COPPER_WIRES, Tags.Items.INGOTS_IRON, MItemTags.COPPER_WIRES) + .unlockedBy(MItems.ELECTROMAGNET) .build(consumer) MatteryRecipe(MItems.ENERGY_SERVO, category = RecipeCategory.MISC) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDescription.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDescription.kt index 402c46eac..5c071f633 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDescription.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchDescription.kt @@ -43,6 +43,14 @@ object AndroidResearchDescriptions { )) } } + val SWIM_BOOSTERS: AndroidResearchDescription.Leveled by registrar.register("swim_boosters") { + AndroidResearchDescription.Leveled { _, list, level -> + list.add(TranslatableComponent( + "android_research.overdrive_that_matters.swim_boosters.description", + TextComponent("%.1f".format(AndroidConfig.SWIM_BOOSTERS * (1 + level) * 100.0)).withStyle(ChatFormatting.YELLOW) + )) } + } + val ITEM_MAGNET: AndroidResearchDescription.Singleton by registrar.register("item_magnet") { AndroidResearchDescription.singleton { TranslatableComponent("otm.gui.power_cost_per_tick", AndroidConfig.Magnet.POWER_DRAW.formatPower(formatAsReadable = ShiftPressedCond).copy().withStyle(ChatFormatting.YELLOW)) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/SwimBoostersFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/SwimBoostersFeature.kt new file mode 100644 index 000000000..24aaebbce --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/SwimBoostersFeature.kt @@ -0,0 +1,39 @@ +package ru.dbotthepony.mc.otm.android.feature + +import net.minecraft.client.gui.GuiGraphics +import net.minecraft.world.entity.ai.attributes.AttributeModifier +import net.minecraftforge.common.ForgeMod +import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature +import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability +import ru.dbotthepony.mc.otm.client.render.ResearchIcons +import ru.dbotthepony.mc.otm.config.AndroidConfig +import ru.dbotthepony.mc.otm.core.math.RGBAColor +import ru.dbotthepony.mc.otm.registry.AndroidFeatures +import java.util.* + +class SwimBoostersFeature(android: MatteryPlayerCapability) : AndroidSwitchableFeature(AndroidFeatures.SWIM_BOOSTERS, android) { + override fun applyModifiers() { + if (!ForgeMod.SWIM_SPEED.isPresent || !isActive) + return + + val attr = ply.getAttribute(ForgeMod.SWIM_SPEED.get()) ?: return + + attr.removeModifier(MODIFIER_ID) + attr.addPermanentModifier(AttributeModifier(MODIFIER_ID, type.displayName.toString(), (level + 1) * AndroidConfig.SWIM_BOOSTERS, AttributeModifier.Operation.ADDITION)) + } + + override fun removeModifiers() { + if (!ForgeMod.SWIM_SPEED.isPresent) + return + + ply.getAttribute(ForgeMod.SWIM_SPEED.get())?.removeModifier(MODIFIER_ID) + } + + override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { + ResearchIcons.ICON_LIMB_OVERCLOCKING.render(graphics, x, y, width, height, color = color) + } + + companion object { + private val MODIFIER_ID = UUID.fromString("4a3ffa46-47a8-a03f-857d-f5c2b2c8f2f6") + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt index 73d1b105e..09bcdb1c5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AndroidConfig.kt @@ -68,6 +68,10 @@ object AndroidConfig : AbstractConfig("androids") { .comment("First, fall damage is reduced by flat resistance (this), then reduced by percentage resistance") .defineInRange("FALL_DAMAGE_REDUCTION_PER_LEVEL_F", 1.5, 0.0, Float.MAX_VALUE.toDouble()) + val SWIM_BOOSTERS: Double by builder + .comment("Increase per level") + .defineInRange("SWIM_BOOSTERS", 0.25, 0.0, Float.MAX_VALUE.toDouble()) + object EnderTeleporter { init { builder.comment("Ender Teleporter ability").push("EnderTeleporter") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/AndroidFeatures.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/AndroidFeatures.kt index bfaf0ed4b..eb4b7cb9c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/AndroidFeatures.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/AndroidFeatures.kt @@ -12,6 +12,7 @@ object AndroidFeatures { val AIR_BAGS: AndroidFeatureType by registry.register(MNames.AIR_BAGS) { AndroidFeatureType(::DummyAndroidFeature) } val STEP_ASSIST: AndroidFeatureType by registry.register(MNames.STEP_ASSIST) { AndroidFeatureType(::StepAssistFeature) } + val SWIM_BOOSTERS: AndroidFeatureType by registry.register(MNames.SWIM_BOOSTERS) { AndroidFeatureType(::SwimBoostersFeature) } val LIMB_OVERCLOCKING: AndroidFeatureType by registry.register(MNames.LIMB_OVERCLOCKING) { AndroidFeatureType(::LimbOverclockingFeature) } val ATTACK_BOOST: AndroidFeatureType by registry.register(MNames.ATTACK_BOOST) { AndroidFeatureType(::AttackBoostFeature) } val NANOBOTS_REGENERATION: AndroidFeatureType by registry.register(MNames.NANOBOTS_REGENERATION) { AndroidFeatureType(::NanobotsRegenerationFeature) } 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 ea35f1291..29da8121d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -452,6 +452,7 @@ object MItems { val QUANTUM_TRANSCEIVER: Item by registry.register("quantum_transceiver") { Item(DEFAULT_PROPERTIES) } val ELECTROMAGNET: Item by registry.register("electromagnet") { Item(DEFAULT_PROPERTIES) } + val ELECTROMOTOR: Item by registry.register("electromotor") { Item(DEFAULT_PROPERTIES) } val MIRROR_COMPOUND: Item by registry.register("mirror_compound") { Item(DEFAULT_PROPERTIES) } val MIRROR: Item by registry.register("mirror") { object : Item(DEFAULT_PROPERTIES) { override fun appendHoverText( @@ -488,6 +489,7 @@ object MItems { ::QUANTUM_TRANSCEIVER, ::ELECTROMAGNET, + ::ELECTROMOTOR, ::MIRROR_COMPOUND, ::MIRROR, @@ -514,6 +516,7 @@ object MItems { ::MATTER_TRANSFORM_MATRIX, ::QUANTUM_TRANSCEIVER, ::ELECTROMAGNET, + ::ELECTROMOTOR, ::MIRROR_COMPOUND, ::MIRROR, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index 260392508..8fac6557d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -196,6 +196,7 @@ object MNames { // android features and research const val AIR_BAGS = "air_bags" const val STEP_ASSIST = "step_assist" + const val SWIM_BOOSTERS = "swim_boosters" const val LIMB_OVERCLOCKING = "limb_overclocking" const val LIMB_OVERCLOCKING_1 = "limb_overclocking_1" diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/component/electromotor.png b/src/main/resources/assets/overdrive_that_matters/textures/item/component/electromotor.png new file mode 100644 index 0000000000000000000000000000000000000000..d36635b4d3d72a5dd2644f4bd55341d6da866d5b GIT binary patch literal 2437 zcmV;033~R4P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGizyJUazyWI3i3tDz2^vX6K~zXfC00vs zB-ItZ&w5u^_1o=s`!Sv|69|G4pg@8KG$8_{NP$K2WB3W#Wt~+vStU{yStQB^wh=-M z5Qc#Za?}}@2Yz%Upb|=-M)42x#xW6JKs6zYd`g%BkkQV~@VUGD8nrn9+annhN)EiW(2EG_GrV4IL;%VOge-yd}} zwG3gfM_+$F8MoJqSy@Dz&1SMQ$;)DXd3CXlV4X2m*L9xfTI;%0jFO%qkM?#rso;&@ zaP_B99&}1txdV{{Q12<@|Q^k6nph&VO-yL_tHqK;OD!6<$JynX}QA)ve z{Kie3Qs3hDUc9@yoKs5tRtsAyrE5(o8mBM@BST?Twv<+sO=GpoAcxSKM>Bn&lC_erC;cPZ1gx0$84G&PlV@rMa_I{q1Cl}|sCWdKH zgjrXDQ&)De+fcU0*AhM08RNhJ657s%p7GJ_uHSJiD}fmjbxMp?CY}C!X6r zzqo*#|NPe{i**7#di~zz^#aI%MNKvcX$QgS+1czGnG>pJwrK(%%dv|hkD`>(8UWQb z18$3D#0_J5a{A@h|6#X|?#yPhaL_Ug>)G^d9Y>?_7{C`rAq3JuaEda;MO~w?|$=+WBb4WDE;N{|45T`vs`Qq z22q-TKsVqc6Sbh^rRNSgQ?Bdlx=P}>-y0%-Ntz)aHSUrOuD~bYX-J`USr&Ok89RA) z+V2mer2OG@9_MP6Wz+z}3axU+2y8V`C=F1mWPR^wukY}_Z#ky0ZLwG^OvBW)rh+P6 zX^mK#XiBX(Qe(NLuG!(8BV;nlvX4Lh1bjDz>~#lmyn!24Rk=18Xb3_*+t?e1MxCpC zWis9C`mPNUQqDB5D^fS6!I3P>@CC#JWNBHLoG{<_vHHzdU-_QdYdN9glz^!yuU9GR zF3sZg^}>?+&i=sl`FuVbj|K-j+oH&1oj4K>Da$krA@RX}R8?Koy3|Mts??H+6e$pM9!x)eb_(b#31_Obem}Xi)-E8ohSwjn`hN^JJ?(^aAhU7hkkOKlJ_W?Ll5D z$8;15x~hf-SBt;uM( zf3S1+_U_4dPx^z7!C9Fld*kt_-w{;Dn^M)939~>MH*5h)X;_0!H}J!gr%y*)!|k@eGu$2wyOw1FY2PuC0+VY}6oJe4wnmeF&l0jG z8EV?GP2|j$@^EJ&DdBIu`dpQ4%5<%C9(aDQ9TZg!v5Z$s!Z=cVYj^A2Uq0|WGs|NX z-ST1%l--t_W(BgDmo(25RJX{IEYE;yryW{Ub6vJW4{`8=frK-b$#kU*0m~!{mxtW-vDO}Q*2gi%dotbpBDLioql_IIlWq4EtZ^==^w7O|Q88^LF@8ID1qdRv8-9ayC zyJ$zGoQy{=-+M7hV~AR&Rd2MtxLo9E5rn;(K=-Azd%fZA)zzZi^7p#I!4`nwd6cAS z8U$_A^!R%Zei62O!?HD_Uf92N=jgRpUfJE7kUV>E|BZJaybXL&{~#;k@I2@7SKm06 z`|ab$I|qkxlAs&tJYz&nM*V)<4m`^g%yYpWYTK@5+x(q3f9CprcWV%KL7Yy|>h$~F z@v!&uPhXI%MwY?=jQ4~vQK!h{_s37sBlq|APk(rFc(`3>o4}?A{a~^+2t0v`0TodT z1=_T(q@eu4&+joPiPG><8YU`ILD$O?O)*)=j_qK{5CZ=edBQ0lPbL%`w=KtDtIG@c zJ|47pCnKhE%ano>$7+hfuo~lp5oTKgWx@`gS&4lmzL8sk@IRjOOHm6BxT4q@kjB3@iKZXGhfneCd zc#y;y3e8ZN21LL8@Et_g1k-@iyoYtjA=)LX%WQdu1;&Xuf*KO!NofV%TBg%93v6Z* z4U-8e3=?OYMO}l&P%bKMX}C;PSjTWCkm{RkH;svabHMUuDDp5;+F{V^5KB;i2@R`@ zyi6)xz!eN1*wf?>)^8r1!W2Sivk2vHOx&zvFl(l0+;FplF-!)G;tRSardmH7gkFeR ztBL~Y!BKo*9o{tiDTO(-bfgW_YzFDh(03zjVSoWUun>6D)!-O~><4V*mu8 Date: Wed, 23 Aug 2023 14:51:39 +0700 Subject: [PATCH 1041/1199] Fix using clientside only sorting on server --- .../mc/otm/client/screen/decorative/PainterScreen.kt | 4 +++- .../ru/dbotthepony/mc/otm/menu/decorative/PainterMenu.kt | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) 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 e8f329b00..6ef67f5e9 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 @@ -28,7 +28,9 @@ import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.ScrollableCanvasPanel import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.map import ru.dbotthepony.mc.otm.core.math.RGBAColor +import ru.dbotthepony.mc.otm.core.util.CreativeMenuItemComparator import ru.dbotthepony.mc.otm.menu.decorative.PainterMenu class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { @@ -121,7 +123,7 @@ class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : buttons.forEach { it.remove() } buttons.clear() - for (recipe in menu.possibleRecipes) { + for (recipe in menu.possibleRecipes.sortedWith(CreativeMenuItemComparator.map { it.output.item })) { object : LargeRectangleButtonPanel(this@PainterScreen, canvas.canvas, icon = ItemStackIcon(recipe.output, 14f, 14f).fixed()) { init { buttons.add(this) 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 4bea5d4dd..c59978c25 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 @@ -18,6 +18,7 @@ import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.core.map import ru.dbotthepony.mc.otm.core.util.CreativeMenuItemComparator import ru.dbotthepony.mc.otm.core.util.ResourceLocationValueCodec +import ru.dbotthepony.mc.otm.isClientThread import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback @@ -120,7 +121,6 @@ class PainterMenu( private fun rescan() { possibleRecipes.clear() possibleRecipes.addAll(inventory.player.level().recipeManager.byType(MRecipes.PAINTER).values.iterator().filter { it.input.test(inputContainer[0]) }) - possibleRecipes.sortWith(CreativeMenuItemComparator.map { it.output.item }) listeners.accept(Unit) if (tile !is PainterBlockEntity) return From 8f983b73d68c0b8252981655becc9ff36e31f602 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 23 Aug 2023 15:26:14 +0700 Subject: [PATCH 1042/1199] Non reflective armorWithTrims --- .../datagen/items/MatteryItemModelProvider.kt | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt index 915de8993..f06049371 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.datagen.items import net.minecraft.data.models.ItemModelGenerators import net.minecraft.resources.ResourceLocation +import net.minecraft.server.packs.PackType import net.minecraft.world.item.ArmorItem import net.minecraft.world.item.Item import net.minecraftforge.client.model.generators.ItemModelProvider @@ -85,20 +86,13 @@ class MatteryItemModelProvider(event: GatherDataEvent) : ItemModelProvider(event val mainModel = withExistingParent(item.registryName!!.path, GENERATED).texture("layer0", texture) if (item is ArmorItem) { - for (i in 0 until ARMOR_TRIM_MATERIALS.size) { - val material = ARMOR_TRIM_MATERIALS[i] + for ((i, material) in ARMOR_TRIM_MATERIALS.withIndex()) { + val trimLocation = ResourceLocation("trims/items/${item.type.getName()}_trim_${material}") + existingFileHelper.trackGenerated(trimLocation, PackType.CLIENT_RESOURCES, ".png", "textures") val overrideModel = withExistingParent("${item.registryName!!.path}_${material}_trim", GENERATED) .texture("layer0", texture) -// .texture("layer1", mcLoc("trims/items/${item.type.getName()}_trim_${material}")) - - // спасибо за проверку наличия файлов КОТОРЫЕ ГЕНЕРИРУЮТСЯ В РАНТАЙМЕ И В ДАТАГЕНЕ НЕ СУЩЕСТВУЮТ - val texturesField = ModelBuilder::class.java.getDeclaredField("textures") - texturesField.trySetAccessible() - - // произошёл троллинг - val textures = texturesField.get(overrideModel) as LinkedHashMap - textures["layer1"] = "minecraft:trims/items/${item.type.getName()}_trim_${material}" + .texture("layer1", trimLocation) mainModel.override() .predicate(ItemModelGenerators.TRIM_TYPE_PREDICATE_ID, (i + 1).toFloat() / ARMOR_TRIM_MATERIALS.size.toFloat()) @@ -106,7 +100,6 @@ class MatteryItemModelProvider(event: GatherDataEvent) : ItemModelProvider(event .end() } } - } fun armorWithTrims(vararg items: Item) = items.forEach { armorWithTrims(it, modLocation("item/${it.registryName!!.path}")) } From 82d46f4cf4245866349812d536e9168022720236 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 23 Aug 2023 16:21:03 +0700 Subject: [PATCH 1043/1199] Update locale casing --- .../mc/otm/datagen/ResearchData.kt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt index c2397a2ec..6dfc9f6ef 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt @@ -461,7 +461,7 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang } add(armorSpeedList[0], "Nanobots Armor Build Speed %s") { - russian("Скорость Построения Слоя Брони Наноботов %s") + russian("Скорость аостроения слоя брони наноботов %s") } add(armorSpeedList[0], "description", "Reduces time required for nanobots to form protection layer") { russian("Уменьшает время необходимое наноботам для формирования защитного слоя") @@ -496,11 +496,11 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang } add(SWIM_BOOSTERS_2, "Swim Boosters 2") { - russian("Плавательные Лопасти 2") + russian("Плавательные лопасти 2") } add(SWIM_BOOSTERS_3, "Swim Boosters 3") { - russian("Плавательные Лопасти 3") + russian("Плавательные лопасти 3") } add(STEP_ASSIST, "Step Assist") { @@ -521,21 +521,21 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang } add(FALL_DAMPENERS_1, "Fall Dampeners") { - russian("Поглотители Инерции") + russian("Поглотители инерции") } add(FALL_DAMPENERS_1, "description", "Installs basic equipment in limbs to negate some fall damage") { russian("Обустраивает конечности примитивными деталями для небольшого смягчения падения") } add(FALL_DAMPENERS_2, "Fall Dampeners 2") { - russian("Поглотители Инерции 2") + russian("Поглотители инерции 2") } add(FALL_DAMPENERS_2, "description", "Installs micro displacing and dampening equipment in limbs to negate great deal of fall damage") { russian("Оборудует конечности микро смещающимися и смягчающим оборудованием, которое поглощает значительный урон от падения") } add(FALL_DAMPENERS_3, "Fall Dampeners 3") { - russian("Поглотители Инерции 3") + russian("Поглотители инерции 3") } add(FALL_DAMPENERS_3, "description0", "Installs autonomous fall damage avoidance calculation matrices and hardening to crucial parts") { russian("Устанавливает автономные матрицы калькуляции избегания урона от падения, а так же усиливает защиту важных деталей") @@ -545,7 +545,7 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang } add(SHOCKWAVE, "Shockwave Pulsator") { - russian("Генератор Ударных Волн") + russian("Генератор ударных волн") } add(SHOCKWAVE, "description0", "Releases a shockwave, damaging everything in small radius, as you quickly land on ground") { russian("Вызывает ударную волну при стремительном падении на землю, нанося урон всему, что вас окружает") @@ -555,7 +555,7 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang } add(JUMP_BOOST_1, "Jump Boost") { - russian("Усилитель Прыжка") + russian("Усилитель прыжка") } add(JUMP_BOOST_1, "description0", "Allows to perform higher jump") { russian("Позволяет совершить высокий прыжок") @@ -565,7 +565,7 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang } add(JUMP_BOOST_2, "Jump Boost 2") { - russian("Усилитель Прыжка 2") + russian("Усилитель прыжка 2") } add(JUMP_BOOST_2, "description", "Allows to perform extra higher jump") { russian("Позволяет совершить ещё более высокий прыжок") @@ -579,14 +579,14 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang } add(NIGHT_VISION, "Night Vision") { - russian("Ночное Зрение") + russian("Ночное зрение") } add(NIGHT_VISION, "description", "Allows to clearly see in the dark") { russian("Позволяет видеть в темноте") } add(attackBoostList[0], "Attack Boost %s") { - russian("Усиление Атаки %s") + russian("Усиление атаки %s") } add(attackBoostList[0], "description", "Increases total melee attack strength by %s%%") { russian("Увеличивает урон в ближнем бою на %s%%") From 2766a444d6c2b22d3eb6b5149eef88a070506188 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 23 Aug 2023 16:42:04 +0700 Subject: [PATCH 1044/1199] Mark panels removed when screen is removed --- .../ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt | 5 +++++ .../mc/otm/client/screen/panels/EditablePanel.kt | 8 ++++++++ 2 files changed, 13 insertions(+) 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 e51b3e857..1599f9f19 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 @@ -466,6 +466,11 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } } + override fun onClose() { + super.onClose() + panels.forEach { it.markRemoved() } + } + public override fun recalculateQuickCraftRemaining() { super.recalculateQuickCraftRemaining() } 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 b18ff638d..cccf0c93e 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 @@ -1782,6 +1782,14 @@ open class EditablePanel @JvmOverloads constructor( protected open fun beforeRemoved() {} protected open fun onRemoved() {} + internal fun markRemoved() { + if (!isRemoved) { + isRemoved = true + onRemoved() + children.forEach { it.markRemoved() } + } + } + fun remove() { if (isRemoved) { return From 8e962f69ffb2395c192a5f7e2c3ac3038995f985 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 23 Aug 2023 16:57:59 +0700 Subject: [PATCH 1045/1199] Add preRender protected hook to panels, and remove unused postrender hook --- .../mc/otm/client/screen/MatteryScreen.kt | 12 ++------ .../otm/client/screen/panels/EditablePanel.kt | 28 ++++++++----------- .../otm/client/screen/panels/Panel2Widget.kt | 3 +- .../client/screen/panels/button/Buttons.kt | 11 +------- 4 files changed, 15 insertions(+), 39 deletions(-) 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 1599f9f19..ede81d6aa 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 @@ -665,18 +665,10 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit RenderSystem.enableBlend() RenderSystem.enableDepthTest() - for (i in panels.indices.reversed()) { - val panel = panels[i] + for (panel in panels.asReversed()) { RenderSystem.depthFunc(GL11.GL_ALWAYS) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) - panel.render(graphics, false, mouseXf, mouseYf, partialTick) - } - - for (i in panels.indices.reversed()) { - val panel = panels[i] - RenderSystem.depthFunc(GL11.GL_ALWAYS) - RenderSystem.setShaderColor(1f, 1f, 1f, 1f) - panel.render(graphics, true, mouseXf, mouseYf, partialTick) + panel.render(graphics, mouseXf, mouseYf, partialTick) } RenderSystem.depthFunc(GL11.GL_LESS) 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 cccf0c93e..fb1c093ac 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 @@ -422,8 +422,6 @@ open class EditablePanel @JvmOverloads constructor( var acceptKeyboardInput = true var grabMouseInput = false - open val needsPostRender: Boolean get() = false - fun tryToGrabMouseInput(): Boolean { if (grabMouseInput) { return true @@ -788,6 +786,7 @@ open class EditablePanel @JvmOverloads constructor( } protected open fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {} + protected open fun preRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {} protected open fun innerRenderPost(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {} protected open fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { return false @@ -840,7 +839,7 @@ open class EditablePanel @JvmOverloads constructor( } } - fun render(graphics: GuiGraphics, post: Boolean, mouseX: Float, mouseY: Float, partialTick: Float) { + fun render(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { once = true if (!isVisible()) { @@ -849,15 +848,12 @@ open class EditablePanel @JvmOverloads constructor( val poseStack = graphics.pose() - if (!post) { - performLayoutIfNeeded() + performLayoutIfNeeded() - val parent = this.parent - - if (parent == null) { - absoluteX = x - absoluteY = y - } + if (parent == null) { + preRender(graphics, mouseX, mouseY, partialTick) + absoluteX = x + absoluteY = y } val scissor = this.scissor @@ -877,27 +873,25 @@ open class EditablePanel @JvmOverloads constructor( val currentScissorRect = currentScissorRect - if ((!post || needsPostRender) && (currentScissorRect == null || currentScissorRect.crossScaled(absoluteX, absoluteY, width, height))) { + if (currentScissorRect == null || currentScissorRect.crossScaled(absoluteX, absoluteY, width, height)) { // do not render if we are getting cut off by screen scissor clearDepth(graphics, absoluteX, absoluteY, width, height) poseStack.pushPose() poseStack.translate(absoluteX.toDouble(), absoluteY.toDouble(), 10.0) RenderSystem.setShaderColor(1f, 1f, 1f, if (isFlashFrameRecursive) 0.5f else 1f) - if (post) - innerRenderPost(graphics, mouseX, mouseY, partialTick) - else - innerRender(graphics, mouseX, mouseY, partialTick) + innerRender(graphics, mouseX, mouseY, partialTick) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) poseStack.popPose() } for (child in visibleChildrenInternal.asReversed()) { + child.preRender(graphics, mouseX, mouseY, partialTick) child.absoluteX = absoluteX + child.x + xOffset child.absoluteY = absoluteY + child.y + yOffset - child.render(graphics, post, mouseX, mouseY, partialTick) + child.render(graphics, mouseX, mouseY, partialTick) } if (scissor) { 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 65ce9462e..7610be9bd 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 @@ -20,8 +20,7 @@ class Panel2Widget>( val yFloat = mouseY.toFloat() panel.tickHover(xFloat, yFloat) - panel.render(graphics, false, xFloat, yFloat, partialTick) - panel.render(graphics, true, xFloat, yFloat, partialTick) + panel.render(graphics, xFloat, yFloat, partialTick) panel.renderTooltips(graphics, xFloat, yFloat, partialTick) } 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 bc1466742..298603b00 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 @@ -624,16 +624,7 @@ class DeviceControls>( } } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { - if (parent is FramePanel<*>) { - x = parent!!.width + 3f - y = dockTop - } - } - - override fun tickInner() { - super.tickInner() - + override fun preRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (parent is FramePanel<*>) { x = parent!!.width + 3f y = dockTop From 16ca531a76cf0df48edf1e0b93388e6872521f73 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 26 Aug 2023 18:39:21 +0700 Subject: [PATCH 1046/1199] Avoid leaving "empty" tags of fluid containers --- .../fluid/BlockMatteryFluidHandler.kt | 33 +++++++++++++++---- .../fluid/ItemMatteryFluidHandler.kt | 16 ++++++++- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/BlockMatteryFluidHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/BlockMatteryFluidHandler.kt index 6d836f859..ac675dac6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/BlockMatteryFluidHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/BlockMatteryFluidHandler.kt @@ -41,14 +41,35 @@ class BlockMatteryFluidHandler(val onChanged: (new: FluidStack, old: FluidStack) return FluidStack.loadFluidStackFromNBT(sub[nbtName] as? CompoundTag ?: return FluidStack.EMPTY) } set(value) { - var sub = itemStack.tagNotNull.get(BlockItem.BLOCK_ENTITY_TAG) as? CompoundTag + if (value.isEmpty) { + val tag = itemStack.tag ?: return + val subTag = tag.get(BlockItem.BLOCK_ENTITY_TAG) as? CompoundTag - if (sub == null) { - sub = CompoundTag() - itemStack.tagNotNull[BlockItem.BLOCK_ENTITY_TAG] = sub + if (subTag == null) { + if (tag.isEmpty) { + itemStack.tag = null + } + } else { + subTag.remove(nbtName) + + if (subTag.isEmpty) { + tag.remove(BlockItem.BLOCK_ENTITY_TAG) + + if (tag.isEmpty) { + itemStack.tag = null + } + } + } + } else { + var sub = itemStack.tagNotNull.get(BlockItem.BLOCK_ENTITY_TAG) as? CompoundTag + + if (sub == null) { + sub = CompoundTag() + itemStack.tagNotNull[BlockItem.BLOCK_ENTITY_TAG] = sub + } + + sub[nbtName] = value.writeToNBT(CompoundTag()) } - - sub[nbtName] = value.writeToNBT(CompoundTag()) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/ItemMatteryFluidHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/ItemMatteryFluidHandler.kt index 21c087662..fcde61b2b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/ItemMatteryFluidHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/ItemMatteryFluidHandler.kt @@ -23,7 +23,21 @@ open class ItemMatteryFluidHandler(val itemStack: ItemStack, private val _capaci override var fluid: FluidStack get() { return FluidStack.loadFluidStackFromNBT(itemStack.tag?.get("fluid") as? CompoundTag ?: return FluidStack.EMPTY) } - set(value) { itemStack.tagNotNull["fluid"] = value.writeToNBT(CompoundTag()) } + set(value) { + if (value.isEmpty) { + val tag = itemStack.tag + + if (tag != null) { + tag.remove("fluid") + + if (tag.isEmpty) { + itemStack.tag = null + } + } + } else { + itemStack.tagNotNull["fluid"] = value.writeToNBT(CompoundTag()) + } + } final override val capacity: Int get() = _capacity.asInt From 1f4292012b81e8cbe47090420be28d06a1fb3bd6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 29 Sep 2023 15:40:13 +0700 Subject: [PATCH 1047/1199] Bump minecraft version to 1.20.2 --- build.gradle.kts | 2 +- gradle.properties | 8 ++++---- gradlew | 28 +++++++++++++++++++--------- gradlew.bat | 15 +++++++++------ 4 files changed, 33 insertions(+), 20 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 0264f3077..7d0ec910c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -163,7 +163,7 @@ dependencies { runtimeOnly(fg.deobf("ru.dbotthepony:particle-collider:0.4.5")) - implementation(fg.deobf("curse.maven:jade-324717:${jade_id}")) + compileOnly(fg.deobf("curse.maven:jade-324717:${jade_id}")) //runtimeOnly(fg.deobf("curse.maven:configured-457570:${configured_id}")) compileOnly(fg.deobf("curse.maven:resourceful-lib-570073:${resourceful_lib_id}")) diff --git a/gradle.properties b/gradle.properties index 7319d4a08..ddb7099df 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,17 +10,17 @@ mod_version=1.3 use_commit_hash_in_version=true -mc_version=1.20.1 +mc_version=1.20.2 use_parchment=false -jei_mc_version=1.20.1 +jei_mc_version=1.20.2 curios_mc_version=1.20 forge_gradle_version=[6.0,6.2) -forge_version=47.1.0 +forge_version=48.0.13 mixingradle_version=0.7.33 mixin_version=0.8.5 -jei_version=15.2.0.23 +jei_version=16.0.0.28 jupiter_version=5.9.2 mekanism_version=1.20.1-10.3.9.homebaked curios_version=5.2.0-beta.2 diff --git a/gradlew b/gradlew index c53aefaa5..65dcd68d6 100644 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright 2015-2021 the original authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -32,10 +32,10 @@ # Busybox and similar reduced shells will NOT work, because this script # requires all of these POSIX shell features: # * functions; -# * expansions $var, ${var}, ${var:-default}, ${var+SET}, -# ${var#prefix}, ${var%suffix}, and $( cmd ); -# * compound commands having a testable exit status, especially case; -# * various built-in commands including command, set, and ulimit. +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». # # Important for patching: # @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,10 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' @@ -143,12 +143,16 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -205,6 +209,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index 107acd32c..93e3f59f1 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal From c32a5bf71ba9d69cfcc009bbed7540bf39864186 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 7 Oct 2023 22:23:52 +0700 Subject: [PATCH 1048/1199] Mod now compiles on 1.20.2 --- build.gradle.kts | 21 +- gradle.properties | 4 +- .../ru/dbotthepony/mc/otm/datagen/DataGen.kt | 4 +- .../datagen/advancements/AdvancementData.kt | 120 +++---- .../advancements/AndroidAdvancementsData.kt | 114 +++---- .../advancements/ExopackAdvancementsData.kt | 67 ++-- .../mc/otm/datagen/advancements/Helpers.kt | 5 +- .../advancements/MachineAdvancementsData.kt | 60 ++-- .../mc/otm/datagen/recipes/BlastingRecipes.kt | 5 +- .../datagen/recipes/CraftingTableRecipes.kt | 5 +- .../otm/datagen/recipes/DecorativesRecipes.kt | 16 +- .../datagen/recipes/MatterEntanglerRecipes.kt | 11 +- .../mc/otm/datagen/recipes/MatteryRecipe.kt | 57 ++-- .../datagen/recipes/MatteryRecipeProvider.kt | 31 +- .../mc/otm/datagen/recipes/OreRecipes.kt | 3 +- .../mc/otm/datagen/recipes/PainterRecipes.kt | 23 +- .../otm/datagen/recipes/ShapelessRecipes.kt | 5 +- .../mc/otm/mixin/GuiGraphicsMixin.java | 23 ++ .../mc/otm/android/AndroidResearchManager.kt | 7 +- .../mc/otm/android/AndroidResearchType.kt | 3 +- .../otm/android/feature/ItemMagnetFeature.kt | 7 +- .../otm/android/feature/JumpBoostFeature.kt | 47 +-- .../otm/android/feature/ShockwaveFeature.kt | 44 +-- .../otm/block/entity/blackhole/Explosions.kt | 5 +- .../matter/MatterEntanglerBlockEntity.kt | 10 +- .../entity/storage/ItemMonitorBlockEntity.kt | 2 +- .../entity/tech/PlatePressBlockEntity.kt | 4 +- .../entity/tech/PoweredFurnaceBlockEntity.kt | 4 +- .../otm/capability/MatteryPlayerCapability.kt | 6 +- .../mc/otm/client/ClientEventHandler.kt | 4 +- .../mc/otm/client/screen/MatteryScreen.kt | 7 +- .../client/screen/decorative/PainterScreen.kt | 10 +- .../otm/client/screen/panels/EditablePanel.kt | 4 +- .../screen/panels/EntityRendererPanel.kt | 6 +- .../otm/client/screen/panels/Panel2Widget.kt | 4 +- .../screen/panels/input/EditBoxPanel.kt | 5 - .../mc/otm/compat/curios/CuriosCompat.kt | 3 +- .../jei/ExopackInventoryTransferHandler.kt | 17 +- .../mc/otm/compat/jei/JEIPlugin.kt | 6 +- .../vanilla/ExtendedInventoryHandler.kt | 7 +- .../mc/otm/container/ItemFilter.kt | 11 +- .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 4 +- .../dbotthepony/mc/otm/core/math/Decimal.kt | 5 +- .../mc/otm/core/nbt/CompoundTagExt.kt | 4 +- .../mc/otm/core/util/BinaryJson.kt | 60 ++-- .../mc/otm/core/util/ByteBufExtensions.kt | 12 +- .../mc/otm/core/util/FriendlyStreams.kt | 31 +- .../mc/otm/core/util/StreamCodecs.kt | 33 +- .../mc/otm/data/Codec2RecipeSerializer.kt | 102 +++--- .../mc/otm/data/Codec2Serializer.kt | 37 --- .../mc/otm/data/Codec2TriggerSerializer.kt | 100 ++++++ .../ru/dbotthepony/mc/otm/data/Codecs.kt | 21 ++ .../mc/otm/data/IngredientCodec.kt | 23 -- .../mc/otm/data/ItemPredicateCodec.kt | 27 -- .../mc/otm/data/condition/ChanceCondition.kt | 9 +- .../condition/ChanceWithPlaytimeCondition.kt | 5 +- .../otm/data/condition/HasExoPackCondition.kt | 13 +- .../condition/ItemInInventoryCondition.kt | 5 +- .../otm/data/condition/KilledByRealPlayer.kt | 13 +- .../KilledByRealPlayerOrIndirectly.kt | 13 +- .../mc/otm/data/loot/CopyTileNbtFunction.kt | 37 +-- .../mc/otm/data/loot/LootPoolAppender.kt | 54 +--- .../mc/otm/item/FluidCapsuleItem.kt | 2 +- .../mc/otm/item/MinecartCargoCrateItem.kt | 10 +- .../mc/otm/item/ProceduralBatteryItem.kt | 22 +- .../mc/otm/item/QuantumBatteryItem.kt | 9 +- .../ProceduralExopackSlotUpgradeItem.kt | 16 +- .../mc/otm/item/weapon/AbstractWeaponItem.kt | 48 ++- .../mc/otm/matter/MatterManager.kt | 47 ++- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 27 +- .../mc/otm/menu/data/NetworkedItemView.kt | 28 +- .../mc/otm/menu/decorative/PainterMenu.kt | 15 +- .../mc/otm/menu/matter/MatterEntanglerMenu.kt | 2 +- .../mc/otm/menu/matter/MatterPanelMenu.kt | 58 ++-- .../mc/otm/network/GenericNetworkChannel.kt | 28 +- .../mc/otm/network/MatteryNetworkChannel.kt | 85 +++-- .../network/MatteryPlayerNetworkChannel.kt | 301 ++++++++---------- .../mc/otm/network/MenuNetworkChannel.kt | 28 +- .../mc/otm/network/WeaponNetworkChannel.kt | 2 +- .../mc/otm/recipe/EnergyContainerRecipe.kt | 19 +- .../recipe/ExplosiveHammerPrimingRecipe.kt | 50 +-- .../mc/otm/recipe/MatterEntanglerRecipe.kt | 19 +- .../mc/otm/recipe/PainterRecipe.kt | 16 +- .../mc/otm/recipe/PlatePressRecipe.kt | 8 +- .../mc/otm/recipe/UpgradeRecipe.kt | 101 +++--- .../mc/otm/registry/MItemFunctionTypes.kt | 6 +- .../mc/otm/registry/MLootItemConditions.kt | 13 +- .../dbotthepony/mc/otm/registry/MRecipes.kt | 4 +- .../dbotthepony/mc/otm/registry/MRegistry.kt | 44 +-- .../mc/otm/triggers/AndroidResearchTrigger.kt | 19 +- .../otm/triggers/AndroidTravelUnderwater.kt | 36 ++- .../mc/otm/triggers/ExopackTriggers.kt | 17 +- .../mc/otm/triggers/HurtTrigger.kt | 56 ++-- .../mc/otm/triggers/ItemTrigger.kt | 46 +-- .../mc/otm/triggers/KillAsAndroidTrigger.kt | 26 +- .../triggers/MatteryInventoryChangeTrigger.kt | 20 +- .../mc/otm/triggers/NailedEntityTrigger.kt | 2 +- .../mc/otm/triggers/NanobotsArmorTrigger.kt | 37 ++- .../otm/triggers/ShockwaveDamageMobTrigger.kt | 2 +- .../mc/otm/triggers/SingletonTrigger.kt | 33 +- .../resources/META-INF/accesstransformer.cfg | 36 --- .../overdrive_that_matters.mixins.json | 3 +- 102 files changed, 1251 insertions(+), 1495 deletions(-) create mode 100644 src/main/java/ru/dbotthepony/mc/otm/mixin/GuiGraphicsMixin.java delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2TriggerSerializer.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientCodec.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/ItemPredicateCodec.kt diff --git a/build.gradle.kts b/build.gradle.kts index 7d0ec910c..5c8c9131f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -142,7 +142,6 @@ dependencies { if (handleDeps) { val jei_version: String by project - val mekanism_version: String by project val cosmetic_armor_reworked_id: String by project val jade_id: String by project val configured_id: String by project @@ -174,7 +173,7 @@ dependencies { // runtimeOnly(fg.deobf("curse.maven:worldedit-225608:${worldedit_fileid}")) // runtimeOnly(fg.deobf("at.ridgo8.moreoverlays:MoreOverlays-updated:${more_overlays_version}")) - compileOnly(fg.deobf("mekanism:Mekanism:${mekanism_version}:all")) + compileOnly(fg.deobf("mekanism:Mekanism:1.20.1-10.3.9.homebaked:all")) // runtimeOnly(fg.deobf("curse.maven:cyclops-core-232758:4392602")) // runtimeOnly(fg.deobf("curse.maven:integrated-dynamics-236307:4391535")) @@ -395,21 +394,3 @@ if (project.hasProperty("mavenUser") && project.hasProperty("mavenPassword") && } } } - -// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing -// publish.dependsOn("reobfJar") - -/* -publishing { - publications { - mavenJava(MavenPublication) { - artifact jar - } - } - repositories { - maven { - url "file://${project.projectDir}/mcmodsrepo" - } - } -} -*/ diff --git a/gradle.properties b/gradle.properties index ddb7099df..e1d06d4ee 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,12 +6,11 @@ kotlin.stdlib.default.dependency=false org.gradle.vfs.watch=true mod_id=overdrive_that_matters -mod_version=1.3 +mod_version=1.4 use_commit_hash_in_version=true mc_version=1.20.2 -use_parchment=false jei_mc_version=1.20.2 curios_mc_version=1.20 @@ -22,7 +21,6 @@ mixin_version=0.8.5 jei_version=16.0.0.28 jupiter_version=5.9.2 -mekanism_version=1.20.1-10.3.9.homebaked curios_version=5.2.0-beta.2 cosmetic_armor_reworked_id=4575609 ad_astra_id=4594155 diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt index c148d0f68..34bf066b0 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -508,8 +508,8 @@ object DataGen { val tagsProvider = TagsProvider(event) val advancementProvider = object : ForgeAdvancementProvider(event.generator.packOutput, event.lookupProvider, event.existingFileHelper, listOf( AdvancementGenerator { registries, saver, existingFileHelper -> - addAdvancements(saver, existingFileHelper, languageProvider) - addAndroidAdvancements(saver, existingFileHelper, languageProvider) + addAdvancements(saver, languageProvider) + addAndroidAdvancements(saver, languageProvider) } )) {} diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt index 0bc661bff..a220c1843 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt @@ -1,9 +1,11 @@ package ru.dbotthepony.mc.otm.datagen.advancements import net.minecraft.advancements.Advancement +import net.minecraft.advancements.AdvancementHolder +import net.minecraft.advancements.AdvancementRequirements import net.minecraft.advancements.AdvancementRewards import net.minecraft.advancements.FrameType -import net.minecraft.advancements.RequirementsStrategy +import net.minecraft.advancements.AdvancementRequirements.Strategy import net.minecraft.advancements.critereon.InventoryChangeTrigger import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack @@ -18,11 +20,11 @@ import ru.dbotthepony.mc.otm.triggers.BlackHoleTrigger import ru.dbotthepony.mc.otm.triggers.NailedEntityTrigger import java.util.function.Consumer -fun addAdvancements(serializer: Consumer, existingFileHelper: ExistingFileHelper, lang: MatteryLanguageProvider) { +fun addAdvancements(serializer: Consumer, lang: MatteryLanguageProvider) { val translation = lang.MultiBuilder("otm.advancements.regular") val root = AdvancementBuilder() - .requirements(RequirementsStrategy.OR) + .requirements(Strategy.OR) .display( itemStack = ItemStack(MItems.TRITANIUM_INGOT), title = translation.add("root", "Overdrive That Matters"), @@ -36,9 +38,9 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist .addCriterion("has_tritanium_ore", criterion(MItemTags.TRITANIUM_ORES)) .addCriterion("has_tritanium_ore_clump", criterion(MItemTags.TRITANIUM_ORE_CLUMPS)) .addCriterion("has_tritanium_ingot", InventoryChangeTrigger.TriggerInstance.hasItems(MItems.TRITANIUM_INGOT)) - .save(serializer, modLocation("regular/root"), existingFileHelper) + .save(serializer, modLocation("regular/root")) - addMachineAdvancements(serializer, existingFileHelper, lang, root) + addMachineAdvancements(serializer, lang, root) val crude = AdvancementBuilder() .parent(root) @@ -52,7 +54,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist }, ) .addCriterion("has_item", criterion(MItems.BATTERY_CRUDE)) - .save(serializer, modLocation("regular/crude_battery"), existingFileHelper) + .save(serializer, modLocation("regular/crude_battery")) val normal = AdvancementBuilder() .parent(crude) @@ -66,7 +68,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist }, ) .addCriterion("has_item", criterion(MItems.BATTERY_NORMAL)) - .save(serializer, modLocation("regular/normal_battery"), existingFileHelper) + .save(serializer, modLocation("regular/normal_battery")) AdvancementBuilder() .parent(normal) @@ -80,7 +82,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist }, ) .addCriterion("has_item", criterion(MItems.BATTERY_DENSE)) - .save(serializer, modLocation("regular/dense_battery"), existingFileHelper) + .save(serializer, modLocation("regular/dense_battery")) val capacitor = AdvancementBuilder() .parent(normal) @@ -94,7 +96,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist }, ) .addCriterion("has_item", criterion(MItems.BATTERY_CAPACITOR)) - .save(serializer, modLocation("regular/capacitor_battery"), existingFileHelper) + .save(serializer, modLocation("regular/capacitor_battery")) AdvancementBuilder() .parent(capacitor) @@ -109,7 +111,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist frameType = FrameType.GOAL ) .addCriterion("has_item", criterion(MItems.ENERGY_SWORD)) - .save(serializer, modLocation("regular/energy_sword"), existingFileHelper) + .save(serializer, modLocation("regular/energy_sword")) AdvancementBuilder() .parent(normal) @@ -124,10 +126,10 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist frameType = FrameType.GOAL ) .rewards(AdvancementRewards.Builder.experience(50)) - .requirements(RequirementsStrategy.OR) + .requirements(Strategy.OR) .addCriterion("has_item0", criterion(MItems.QUANTUM_BATTERY)) .addCriterion("has_item1", criterion(MItems.QUANTUM_CAPACITOR)) - .save(serializer, modLocation("regular/quantum_battery"), existingFileHelper) + .save(serializer, modLocation("regular/quantum_battery")) val zpm = AdvancementBuilder() .parent(root) @@ -144,9 +146,9 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist ) .rewards(AdvancementRewards.Builder.experience(800)) .addCriterion("has_item", criterion(MItems.ZPM_BATTERY)) - .save(serializer, modLocation("regular/zpm_battery"), existingFileHelper) + .save(serializer, modLocation("regular/zpm_battery")) - addExopackAdvancements(serializer, existingFileHelper, lang, root, zpm) + addExopackAdvancements(serializer, lang, root, zpm) val blackhole = AdvancementBuilder() .parent(root) @@ -160,8 +162,8 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist }, hidden = true ) - .addCriterion("pulled_by_black_hole", BlackHoleTrigger.instance) - .save(serializer, modLocation("regular/black_hole"), existingFileHelper) + .addCriterion("pulled_by_black_hole", BlackHoleTrigger.criterion) + .save(serializer, modLocation("regular/black_hole")) AdvancementBuilder() .parent(blackhole) @@ -175,7 +177,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist }, ) .addCriterion("has_item", criterion(MItems.BLACK_HOLE_SCANNER)) - .save(serializer, modLocation("regular/black_hole_scanner"), existingFileHelper) + .save(serializer, modLocation("regular/black_hole_scanner")) AdvancementBuilder() .parent(blackhole) @@ -189,7 +191,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist }, ) .addCriterion("has_item", criterion(MItems.GRAVITATION_STABILIZER)) - .save(serializer, modLocation("regular/stabilizer"), existingFileHelper) + .save(serializer, modLocation("regular/stabilizer")) AdvancementBuilder() .parent(blackhole) @@ -203,11 +205,11 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist }, ) .addCriterion("has_item", criterion(MItems.PORTABLE_GRAVITATION_STABILIZER)) - .save(serializer, modLocation("regular/portable_stabilizer"), existingFileHelper) + .save(serializer, modLocation("regular/portable_stabilizer")) val ore = AdvancementBuilder() .parent(root) - .requirements(RequirementsStrategy.OR) + .requirements(Strategy.OR) .display( itemStack = ItemStack(MItems.TRITANIUM_ORE_CLUMP), title = translation.add("ore", "Blue Metal Discovery") { @@ -219,7 +221,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist ) .addCriterion("has_tritanium_ore", criterion(MItemTags.TRITANIUM_ORES)) .addCriterion("has_tritanium_ore_clump", criterion(MItemTags.TRITANIUM_ORE_CLUMPS)) - .save(serializer, modLocation("regular/ore"), existingFileHelper) + .save(serializer, modLocation("regular/ore")) val ingot = AdvancementBuilder() .parent(ore) @@ -233,7 +235,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist }, ) .addCriterion("has_tritanium_ingot", criterion(MItemTags.TRITANIUM_INGOTS)) - .save(serializer, modLocation("regular/ingot"), existingFileHelper) + .save(serializer, modLocation("regular/ingot")) AdvancementBuilder() .parent(ingot) @@ -247,7 +249,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist }, ) .addCriterion("has_tritanium_pickaxe", criterion(MItems.TRITANIUM_PICKAXE)) - .save(serializer, modLocation("regular/pickaxe"), existingFileHelper) + .save(serializer, modLocation("regular/pickaxe")) AdvancementBuilder() .parent(ingot) @@ -262,7 +264,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist hidden = true ) .addCriterion("hoe", criterion(MItems.TRITANIUM_HOE)) - .save(serializer, modLocation("regular/hoe"), existingFileHelper) + .save(serializer, modLocation("regular/hoe")) val plate = AdvancementBuilder() .parent(ingot) @@ -276,7 +278,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist } ) .addCriterion("has_item", criterion(MItemTags.TRITANIUM_PLATES)) - .save(serializer, modLocation("regular/plate"), existingFileHelper) + .save(serializer, modLocation("regular/plate")) AdvancementBuilder() .parent(plate) @@ -289,12 +291,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist russian("Согните немного тритановых пластин вместе с углеродной сеткой в невероятно прочную броню") } ) - .requirements(RequirementsStrategy.OR) + .requirements(Strategy.OR) .addCriterion("has_item0", criterion(MItems.TRITANIUM_HELMET)) .addCriterion("has_item1", criterion(MItems.TRITANIUM_CHESTPLATE)) .addCriterion("has_item2", criterion(MItems.TRITANIUM_PANTS)) .addCriterion("has_item3", criterion(MItems.TRITANIUM_BOOTS)) - .save(serializer, modLocation("regular/armor"), existingFileHelper) + .save(serializer, modLocation("regular/armor")) AdvancementBuilder() .parent(ingot) @@ -307,12 +309,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist russian("Создайте простую тритановую броню из слитков, просто и эффективно") } ) - .requirements(RequirementsStrategy.OR) + .requirements(Strategy.OR) .addCriterion("has_item0", criterion(MItems.SIMPLE_TRITANIUM_HELMET)) .addCriterion("has_item1", criterion(MItems.SIMPLE_TRITANIUM_CHESTPLATE)) .addCriterion("has_item2", criterion(MItems.SIMPLE_TRITANIUM_PANTS)) .addCriterion("has_item3", criterion(MItems.SIMPLE_TRITANIUM_BOOTS)) - .save(serializer, modLocation("regular/simple_armor"), existingFileHelper) + .save(serializer, modLocation("regular/simple_armor")) val glass = AdvancementBuilder() .parent(plate) @@ -325,11 +327,11 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist russian("В инструкции указано что оно должно быть пуленепробиваемо.") } ) - .requirements(RequirementsStrategy.OR) + .requirements(Strategy.OR) .also { advancement -> MRegistry.INDUSTRIAL_GLASS.allItems.values.forEach { advancement.addCriterion(it.registryName!!.path, criterion(it)) } } - .save(serializer, modLocation("regular/industrial_glass"), existingFileHelper) + .save(serializer, modLocation("regular/industrial_glass")) AdvancementBuilder() .parent(glass) @@ -343,11 +345,11 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist }, frameType = FrameType.GOAL ) - .requirements(RequirementsStrategy.AND) + .requirements(Strategy.AND) .also { advancement -> MRegistry.INDUSTRIAL_GLASS.allItems.values.forEach { advancement.addCriterion(it.registryName!!.path, criterion(it)) } } - .save(serializer, modLocation("regular/industrial_glass2"), existingFileHelper) + .save(serializer, modLocation("regular/industrial_glass2")) val cargoCrate = AdvancementBuilder() .parent(plate) @@ -360,11 +362,11 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist russian("Грузовые ящики, будто двойные сундуки, но одинарные.") } ) - .requirements(RequirementsStrategy.OR) + .requirements(Strategy.OR) .also { advancement -> MRegistry.CARGO_CRATES.allItems.values.forEach { advancement.addCriterion(it.registryName!!.path, criterion(it)) } } - .save(serializer, modLocation("regular/cargo_crate"), existingFileHelper) + .save(serializer, modLocation("regular/cargo_crate")) val cargoCrateInMinecart = AdvancementBuilder() .parent(cargoCrate) @@ -377,11 +379,11 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist russian("Сбросьте грузовой ящик в вагонетку и посмотрите, что получится") } ) - .requirements(RequirementsStrategy.OR) + .requirements(Strategy.OR) .also { advancement -> MItems.CARGO_CRATE_MINECARTS.values.forEach { advancement.addCriterion(it.registryName!!.path, criterion(it)) } } - .save(serializer, modLocation("regular/cargo_crate_minecart"), existingFileHelper) + .save(serializer, modLocation("regular/cargo_crate_minecart")) AdvancementBuilder() .parent(cargoCrateInMinecart) @@ -395,11 +397,11 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist }, frameType = FrameType.GOAL ) - .requirements(RequirementsStrategy.AND) + .requirements(Strategy.AND) .also { advancement -> MItems.CARGO_CRATE_MINECARTS.values.forEach { advancement.addCriterion(it.registryName!!.path, criterion(it)) } } - .save(serializer, modLocation("regular/cargo_crate_minecart2"), existingFileHelper) + .save(serializer, modLocation("regular/cargo_crate_minecart2")) AdvancementBuilder() .parent(cargoCrate) @@ -413,11 +415,11 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist }, frameType = FrameType.GOAL ) - .requirements(RequirementsStrategy.AND) + .requirements(Strategy.AND) .also { advancement -> MRegistry.CARGO_CRATES.allItems.values.forEach { advancement.addCriterion(it.registryName!!.path, criterion(it)) } } - .save(serializer, modLocation("regular/cargo_crate2"), existingFileHelper) + .save(serializer, modLocation("regular/cargo_crate2")) val tritaniumBlock = AdvancementBuilder() .parent(ingot) @@ -430,7 +432,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist russian("Покройте булыжник в тритане, дешёвый, но невероятно прочный материал") } ) - .requirements(RequirementsStrategy.OR) + .requirements(Strategy.OR) .also { advancement -> MRegistry.TRITANIUM_BLOCK.allItems.values.forEach { advancement.addCriterion(it.registryName!!.path, criterion(it)) } MRegistry.TRITANIUM_STRIPED_BLOCK.flatItems.forEach { advancement.addCriterion(it.registryName!!.path, criterion(it)) } @@ -439,7 +441,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist MItems.TRITANIUM_STRIPED_BLOCK.also { advancement.addCriterion(it.registryName!!.path, criterion(it)) } MItems.TRITANIUM_STRIPED_STAIRS.also { advancement.addCriterion(it.registryName!!.path, criterion(it)) } } - .save(serializer, modLocation("regular/tritanium_block"), existingFileHelper) + .save(serializer, modLocation("regular/tritanium_block")) AdvancementBuilder() .parent(tritaniumBlock) @@ -452,12 +454,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist russian("Бледно синяя покраска с жёлтой полоской, я готов поспорить вы знаете чей это дизайн") } ) - .requirements(RequirementsStrategy.OR) + .requirements(Strategy.OR) .addCriterion("has_item", criterion(MItems.TRITANIUM_STRIPED_BLOCK)) .addCriterion("has_item1", criterion(MItems.TRITANIUM_STRIPED_STAIRS)) .addCriterion("has_item2", criterion(MItems.TRITANIUM_STRIPED_SLAB)) .addCriterion("has_item3", criterion(MItems.TRITANIUM_STRIPED_WALL)) - .save(serializer, modLocation("regular/striped_tritanium_block"), existingFileHelper) + .save(serializer, modLocation("regular/striped_tritanium_block")) val colorTritaniumBlock = AdvancementBuilder() .parent(tritaniumBlock) @@ -470,7 +472,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist russian("Покрасьте тритановый блок для придания ему сказочных оттенков") } ) - .requirements(RequirementsStrategy.OR) + .requirements(Strategy.OR) .also { advancement -> MRegistry.TRITANIUM_BLOCK.items.values.forEach { advancement.addCriterion(it.registryName!!.path, criterion(it)) } MRegistry.TRITANIUM_STAIRS.items.values.forEach { advancement.addCriterion(it.registryName!!.path, criterion(it)) } @@ -479,7 +481,7 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist MItems.TRITANIUM_STRIPED_BLOCK.also { advancement.addCriterion(it.registryName!!.path, criterion(it)) } MItems.TRITANIUM_STRIPED_STAIRS.also { advancement.addCriterion(it.registryName!!.path, criterion(it)) } } - .save(serializer, modLocation("regular/tritanium_block2"), existingFileHelper) + .save(serializer, modLocation("regular/tritanium_block2")) val colorfulTritaniumBlock = AdvancementBuilder() .parent(colorTritaniumBlock) @@ -494,11 +496,11 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist frameType = FrameType.GOAL ) .rewards(AdvancementRewards.Builder.loot(modLocation("tritanium_block3")).addExperience(100)) - .requirements(RequirementsStrategy.AND) + .requirements(Strategy.AND) .also { advancement -> MRegistry.TRITANIUM_BLOCK.items.values.forEach { advancement.addCriterion(it.registryName!!.path, criterion(it)) } } - .save(serializer, modLocation("regular/tritanium_block3"), existingFileHelper) + .save(serializer, modLocation("regular/tritanium_block3")) AdvancementBuilder() .parent(colorfulTritaniumBlock) @@ -513,13 +515,13 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist frameType = FrameType.CHALLENGE ) .rewards(AdvancementRewards.Builder.loot(modLocation("tritanium_block4")).addExperience(400)) - .requirements(RequirementsStrategy.AND) + .requirements(Strategy.AND) .also { advancement -> MRegistry.TRITANIUM_BLOCK.items.values.forEach { advancement.addCriterion(it.registryName!!.path, criterion(it)) } MRegistry.TRITANIUM_STRIPED_BLOCK.flatItems.forEach { advancement.addCriterion(it.registryName!!.path, criterion(it)) } MItems.TRITANIUM_STRIPED_BLOCK.also { advancement.addCriterion(it.registryName!!.path, criterion(it)) } } - .save(serializer, modLocation("regular/tritanium_block4"), existingFileHelper) + .save(serializer, modLocation("regular/tritanium_block4")) val pill = AdvancementBuilder() .parent(root) @@ -532,12 +534,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist russian("Найдите одну из этих ваших мистических пилюль") }, ) - .requirements(RequirementsStrategy.OR) + .requirements(Strategy.OR) .addCriterion("pill1", criterion(MItems.PILL_ANDROID)) .addCriterion("pill2", criterion(MItems.PILL_HEAL)) .addCriterion("pill3", criterion(MItems.PILL_HUMANE)) .addCriterion("pill4", criterion(MItems.PILL_OBLIVION)) - .save(serializer, modLocation("regular/pill"), existingFileHelper) + .save(serializer, modLocation("regular/pill")) AdvancementBuilder() .parent(pill) @@ -553,12 +555,12 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist hidden = true ) .rewards(AdvancementRewards.Builder.experience(200)) - .requirements(RequirementsStrategy.AND) + .requirements(Strategy.AND) .addCriterion("pill1", criterion(MItems.PILL_ANDROID)) .addCriterion("pill2", criterion(MItems.PILL_HEAL)) .addCriterion("pill3", criterion(MItems.PILL_HUMANE)) .addCriterion("pill4", criterion(MItems.PILL_OBLIVION)) - .save(serializer, modLocation("regular/all_pills"), existingFileHelper) + .save(serializer, modLocation("regular/all_pills")) AdvancementBuilder() .parent(root) @@ -571,10 +573,10 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist russian("Верните капсулу эссенции. Воспоминания...") }, ) - .requirements(RequirementsStrategy.OR) + .requirements(Strategy.OR) .addCriterion("essence1", criterion(MItems.ESSENCE_CAPSULE)) .addCriterion("essence2", criterion(MItems.ESSENCE_DRIVE)) - .save(serializer, modLocation("regular/essence_capsule"), existingFileHelper) + .save(serializer, modLocation("regular/essence_capsule")) AdvancementBuilder() .parent(root) @@ -587,6 +589,6 @@ fun addAdvancements(serializer: Consumer, existingFileHelper: Exist russian("Пригвоздите что-либо (или кого-либо)") } ) - .addCriterion("damage", NailedEntityTrigger.Instance()) - .save(serializer, modLocation("regular/explosive_hammer"), existingFileHelper) + .addCriterion("damage", NailedEntityTrigger.Instance().criterion()) + .save(serializer, modLocation("regular/explosive_hammer")) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt index f84f15be1..83b58e530 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt @@ -1,9 +1,10 @@ package ru.dbotthepony.mc.otm.datagen.advancements import net.minecraft.advancements.Advancement +import net.minecraft.advancements.AdvancementHolder +import net.minecraft.advancements.AdvancementRequirements.Strategy import net.minecraft.advancements.AdvancementRewards import net.minecraft.advancements.FrameType -import net.minecraft.advancements.RequirementsStrategy import net.minecraft.advancements.critereon.EntityPredicate import net.minecraft.advancements.critereon.ItemPredicate import net.minecraft.advancements.critereon.MinMaxBounds.Doubles @@ -30,9 +31,10 @@ import ru.dbotthepony.mc.otm.triggers.KillAsAndroidTrigger import ru.dbotthepony.mc.otm.triggers.NanobotsArmorTrigger import ru.dbotthepony.mc.otm.triggers.ShockwaveDamageMobTrigger import ru.dbotthepony.mc.otm.triggers.ShockwaveTrigger +import java.util.* import java.util.function.Consumer -fun addAndroidAdvancements(serializer: Consumer, existingFileHelper: ExistingFileHelper, lang: MatteryLanguageProvider) { +fun addAndroidAdvancements(serializer: Consumer, lang: MatteryLanguageProvider) { val translation = lang.MultiBuilder("otm.advancements.android") val root = AdvancementBuilder() @@ -48,8 +50,8 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper announceChat = false, background = modLocation("textures/block/decorative/metal_beam_top.png") ) - .addCriterion("became_android", BecomeAndroidTrigger.instance) - .save(serializer, modLocation("android/root"), existingFileHelper) + .addCriterion("became_android", BecomeAndroidTrigger.criterion) + .save(serializer, modLocation("android/root")) AdvancementBuilder() .parent(root) @@ -64,8 +66,8 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper hidden = true, frameType = FrameType.CHALLENGE ) - .addCriterion("item", AndroidBatteryTrigger.Instance(ItemPredicate.Builder.item().of(MItems.ZPM_BATTERY).build())) - .save(serializer, modLocation("android/zpm"), existingFileHelper) + .addCriterion("item", AndroidBatteryTrigger.Instance(ItemPredicate.Builder.item().of(MItems.ZPM_BATTERY).build()).criterion()) + .save(serializer, modLocation("android/zpm")) AdvancementBuilder() .parent(root) @@ -80,10 +82,10 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper hidden = true, frameType = FrameType.GOAL ) - .requirements(RequirementsStrategy.OR) - .addCriterion("item0", AndroidBatteryTrigger.Instance(ItemPredicate.Builder.item().of(MItems.QUANTUM_BATTERY).build())) - .addCriterion("item1", AndroidBatteryTrigger.Instance(ItemPredicate.Builder.item().of(MItems.QUANTUM_CAPACITOR).build())) - .save(serializer, modLocation("android/quantum_battery"), existingFileHelper) + .requirements(Strategy.OR) + .addCriterion("item0", AndroidBatteryTrigger.Instance(ItemPredicate.Builder.item().of(MItems.QUANTUM_BATTERY).build()).criterion()) + .addCriterion("item1", AndroidBatteryTrigger.Instance(ItemPredicate.Builder.item().of(MItems.QUANTUM_CAPACITOR).build()).criterion()) + .save(serializer, modLocation("android/quantum_battery")) AdvancementBuilder() .parent(root) @@ -97,8 +99,8 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper }, hidden = true, ) - .addCriterion("became_android", BecomeAndroidSleepTrigger.instance) - .save(serializer, modLocation("android/become_thru_sleep"), existingFileHelper) + .addCriterion("became_android", BecomeAndroidSleepTrigger.criterion) + .save(serializer, modLocation("android/become_thru_sleep")) AdvancementBuilder() .parent(root) @@ -112,8 +114,8 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper }, hidden = true, ) - .addCriterion("became_android", BecomeAndroidDeathTrigger.instance) - .save(serializer, modLocation("android/become_thru_death"), existingFileHelper) + .addCriterion("became_android", BecomeAndroidDeathTrigger.criterion) + .save(serializer, modLocation("android/become_thru_death")) AdvancementBuilder() .parent(root) @@ -128,8 +130,8 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper hidden = true, frameType = FrameType.GOAL ) - .addCriterion("become_humane", BecomeHumaneTrigger.instance) - .save(serializer, modLocation("android/become_humane"), existingFileHelper) + .addCriterion("become_humane", BecomeHumaneTrigger.criterion) + .save(serializer, modLocation("android/become_humane")) val attractor = AdvancementBuilder() .parent(root) @@ -143,7 +145,7 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper }, ) .addCriterion("has_item", criterion(MItems.PHANTOM_ATTRACTOR)) - .save(serializer, modLocation("regular/phantom_attractor"), existingFileHelper) + .save(serializer, modLocation("regular/phantom_attractor")) val researchAnything = AdvancementBuilder() .parent(root) @@ -156,8 +158,8 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper russian("Исследуйте что либо за андроида") }, ) - .addCriterion("research_anything", AndroidResearchTrigger.Instance(null)) - .save(serializer, modLocation("android/research_anything"), existingFileHelper) + .addCriterion("research_anything", AndroidResearchTrigger.Instance(null).criterion()) + .save(serializer, modLocation("android/research_anything")) AdvancementBuilder() .parent(researchAnything) @@ -170,8 +172,8 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper russian("Исследуйте воздушные мешки, дабы быть вновь поплавком в воде") }, ) - .addCriterion("air_bags", AndroidResearchTrigger.Instance(modLocation(MNames.AIR_BAGS))) - .save(serializer, modLocation("android/research_air_bags"), existingFileHelper) + .addCriterion("air_bags", AndroidResearchTrigger.Instance(modLocation(MNames.AIR_BAGS)).criterion()) + .save(serializer, modLocation("android/research_air_bags")) AdvancementBuilder() .parent(researchAnything) @@ -184,8 +186,8 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper russian("Исследуйте ночное зрение за андроида, дабы видеть во темноте") }, ) - .addCriterion("night_vision", AndroidResearchTrigger.Instance(modLocation(MNames.NIGHT_VISION))) - .save(serializer, modLocation("android/research_night_vision"), existingFileHelper) + .addCriterion("night_vision", AndroidResearchTrigger.Instance(modLocation(MNames.NIGHT_VISION)).criterion()) + .save(serializer, modLocation("android/research_night_vision")) val nanobots = AdvancementBuilder() .parent(researchAnything) @@ -199,8 +201,8 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper }, hidden = true ) - .addCriterion("nanobots", AndroidResearchTrigger.Instance(modLocation(MNames.NANOBOTS))) - .save(serializer, modLocation("android/research_nanobots"), existingFileHelper) + .addCriterion("nanobots", AndroidResearchTrigger.Instance(modLocation(MNames.NANOBOTS)).criterion()) + .save(serializer, modLocation("android/research_nanobots")) val shielding = AdvancementBuilder() .parent(nanobots) @@ -215,8 +217,8 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper hidden = true, frameType = FrameType.GOAL ) - .addCriterion("damage", NanobotsArmorTrigger.Instance(Doubles.atLeast(10.0))) - .save(serializer, modLocation("android/nanobots_armor_deflect"), existingFileHelper) + .addCriterion("damage", NanobotsArmorTrigger.Instance(Doubles.atLeast(10.0)).criterion()) + .save(serializer, modLocation("android/nanobots_armor_deflect")) AdvancementBuilder() .parent(shielding) @@ -231,8 +233,8 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper hidden = true, frameType = FrameType.CHALLENGE ) - .addCriterion("damage", NanobotsArmorTrigger.Instance(Doubles.atLeast(20.0))) - .save(serializer, modLocation("android/nanobots_armor_deflect2"), existingFileHelper) + .addCriterion("damage", NanobotsArmorTrigger.Instance(Doubles.atLeast(20.0)).criterion()) + .save(serializer, modLocation("android/nanobots_armor_deflect2")) AdvancementBuilder() .parent(researchAnything) @@ -246,8 +248,8 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper }, frameType = FrameType.GOAL ) - .addCriterion("saved", FallDampenersSaveTrigger.instance) - .save(serializer, modLocation("android/fall_dampeners_save"), existingFileHelper) + .addCriterion("saved", FallDampenersSaveTrigger.criterion) + .save(serializer, modLocation("android/fall_dampeners_save")) AdvancementBuilder() .parent(researchAnything) @@ -262,8 +264,8 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper frameType = FrameType.GOAL, hidden = true ) - .addCriterion("death", EnderTeleporterFallDeathTrigger.instance) - .save(serializer, modLocation("android/ender_teleport_fall_death"), existingFileHelper) + .addCriterion("death", EnderTeleporterFallDeathTrigger.criterion) + .save(serializer, modLocation("android/ender_teleport_fall_death")) val regen = AdvancementBuilder() .parent(nanobots) @@ -276,8 +278,8 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper russian("Исследуйте регенерацию наноботов за андроида") }, ) - .addCriterion("regen0", AndroidResearchTrigger.Instance(modLocation(MNames.NANOBOTS_REGENERATION_1))) - .save(serializer, modLocation("android/regen"), existingFileHelper) + .addCriterion("regen0", AndroidResearchTrigger.Instance(modLocation(MNames.NANOBOTS_REGENERATION_1)).criterion()) + .save(serializer, modLocation("android/regen")) AdvancementBuilder() .parent(regen) @@ -291,11 +293,11 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper }, frameType = FrameType.GOAL, ) - .addCriterion("regen0", AndroidResearchTrigger.Instance(modLocation(MNames.NANOBOTS_REGENERATION_1))) - .addCriterion("regen1", AndroidResearchTrigger.Instance(modLocation(MNames.NANOBOTS_REGENERATION_2))) - .addCriterion("regen2", AndroidResearchTrigger.Instance(modLocation(MNames.NANOBOTS_REGENERATION_3))) - .addCriterion("regen3", AndroidResearchTrigger.Instance(modLocation(MNames.NANOBOTS_REGENERATION_4))) - .save(serializer, modLocation("android/regen_all"), existingFileHelper) + .addCriterion("regen0", AndroidResearchTrigger.Instance(modLocation(MNames.NANOBOTS_REGENERATION_1)).criterion()) + .addCriterion("regen1", AndroidResearchTrigger.Instance(modLocation(MNames.NANOBOTS_REGENERATION_2)).criterion()) + .addCriterion("regen2", AndroidResearchTrigger.Instance(modLocation(MNames.NANOBOTS_REGENERATION_3)).criterion()) + .addCriterion("regen3", AndroidResearchTrigger.Instance(modLocation(MNames.NANOBOTS_REGENERATION_4)).criterion()) + .save(serializer, modLocation("android/regen_all")) AdvancementBuilder() .parent(researchAnything) @@ -314,10 +316,10 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper DataGen.researchProvider.generatedView.stream() .filter { it.allBlockedBy.isEmpty() && it.allBlocking.isEmpty() } .forEach { - advancement.addCriterion(it.id.toString(), AndroidResearchTrigger.Instance(it)) + advancement.addCriterion(it.id.toString(), AndroidResearchTrigger.Instance(it).criterion()) } } - .save(serializer, modLocation("android/research_everything"), existingFileHelper) + .save(serializer, modLocation("android/research_everything")) val shockwave = AdvancementBuilder() .parent(researchAnything) @@ -330,8 +332,8 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper russian("Вызовите ударную волну при приземлении") }, ) - .addCriterion("shockwave", ShockwaveTrigger.instance) - .save(serializer, modLocation("android/shockwave"), existingFileHelper) + .addCriterion("shockwave", ShockwaveTrigger.criterion) + .save(serializer, modLocation("android/shockwave")) AdvancementBuilder() .parent(shockwave) @@ -345,8 +347,8 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper }, frameType = FrameType.GOAL ) - .addCriterion("shockwave_warden", ShockwaveDamageMobTrigger.Instance(EntityPredicate.Builder.entity().of(EntityType.WARDEN).build().wrap())) - .save(serializer, modLocation("android/shockwave_warden"), existingFileHelper) + .addCriterion("shockwave_warden", ShockwaveDamageMobTrigger.Instance(Optional.of(EntityPredicate.Builder.entity().of(EntityType.WARDEN).build().wrap())).criterion()) + .save(serializer, modLocation("android/shockwave_warden")) AdvancementBuilder() .parent(root) @@ -362,9 +364,9 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper hidden = true ) .addCriterion("kill_wither", KillAsAndroidTrigger.Instance( - predicate = EntityPredicate.Builder.entity().of(EntityType.WITHER).build().wrap(), - )) - .save(serializer, modLocation("android/wither"), existingFileHelper) + predicate = Optional.of(EntityPredicate.Builder.entity().of(EntityType.WITHER).build().wrap()), + ).criterion()) + .save(serializer, modLocation("android/wither")) val underwater = AdvancementBuilder() .parent(root) @@ -379,8 +381,8 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper frameType = FrameType.GOAL, hidden = true ) - .addCriterion("travel", AndroidTravelUnderwater.Instance(200.0)) - .save(serializer, modLocation("android/underwater"), existingFileHelper) + .addCriterion("travel", AndroidTravelUnderwater.Instance(200.0).criterion()) + .save(serializer, modLocation("android/underwater")) AdvancementBuilder() .parent(underwater) @@ -395,8 +397,8 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper frameType = FrameType.CHALLENGE, hidden = true ) - .addCriterion("travel", AndroidTravelUnderwater.Instance(1046.0)) - .save(serializer, modLocation("android/underwater2"), existingFileHelper) + .addCriterion("travel", AndroidTravelUnderwater.Instance(1046.0).criterion()) + .save(serializer, modLocation("android/underwater2")) AdvancementBuilder() .parent(root) @@ -412,8 +414,8 @@ fun addAndroidAdvancements(serializer: Consumer, existingFileHelper hidden = true ) .addCriterion("kill_elder_guardian", KillAsAndroidTrigger.Instance( - predicate = EntityPredicate.Builder.entity().of(EntityType.ELDER_GUARDIAN).build().wrap(), + predicate = Optional.of(EntityPredicate.Builder.entity().of(EntityType.ELDER_GUARDIAN).build().wrap()), featurePredicate = KillAsAndroidTrigger.Not(KillAsAndroidTrigger.Has(AndroidFeatures.AIR_BAGS.registryName!!)) - )) - .save(serializer, modLocation("android/elder_guardian"), existingFileHelper) + ).criterion()) + .save(serializer, modLocation("android/elder_guardian")) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/ExopackAdvancementsData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/ExopackAdvancementsData.kt index fa1efb751..5e15965ce 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/ExopackAdvancementsData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/ExopackAdvancementsData.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.datagen.advancements import net.minecraft.advancements.Advancement +import net.minecraft.advancements.AdvancementHolder import net.minecraft.advancements.FrameType import net.minecraft.advancements.critereon.ItemPredicate import net.minecraft.world.item.ItemStack @@ -17,7 +18,7 @@ import ru.dbotthepony.mc.otm.triggers.ExopackObtainedTrigger import ru.dbotthepony.mc.otm.triggers.ExopackSlotsExpandedTrigger import java.util.function.Consumer -fun addExopackAdvancements(serializer: Consumer, existingFileHelper: ExistingFileHelper, lang: MatteryLanguageProvider, root: Advancement, zpm: Advancement) { +fun addExopackAdvancements(serializer: Consumer, lang: MatteryLanguageProvider, root: AdvancementHolder, zpm: AdvancementHolder) { val translation = lang.MultiBuilder("otm.advancements.exopack") AdvancementBuilder() @@ -33,8 +34,8 @@ fun addExopackAdvancements(serializer: Consumer, existingFileHelper }, frameType = FrameType.GOAL ) - .addCriterion("zpm_battery", ExopackBatterySlotTrigger.Instance(ItemPredicate.Builder.item().of(MItems.ZPM_BATTERY).build())) - .save(serializer, modLocation("exopack/zpm_battery"), existingFileHelper) + .addCriterion("zpm_battery", ExopackBatterySlotTrigger.Instance(ItemPredicate.Builder.item().of(MItems.ZPM_BATTERY).build()).criterion()) + .save(serializer, modLocation("exopack/zpm_battery")) val obtained = AdvancementBuilder() .parent(root) @@ -48,8 +49,8 @@ fun addExopackAdvancements(serializer: Consumer, existingFileHelper }, frameType = FrameType.GOAL ) - .addCriterion("obtained", ExopackObtainedTrigger.instance) - .save(serializer, modLocation("exopack/obtained"), existingFileHelper) + .addCriterion("obtained", ExopackObtainedTrigger.criterion) + .save(serializer, modLocation("exopack/obtained")) AdvancementBuilder() .parent(obtained) @@ -62,8 +63,8 @@ fun addExopackAdvancements(serializer: Consumer, existingFileHelper russian("Установите улучшение сетки крафта в ваш Экзопаке, который позволяет создавать предметы, требующие сетку крафта рабочего стола") }, ) - .addCriterion("crafting", ExopackGainedCraftingTrigger.instance) - .save(serializer, modLocation("exopack/crafting"), existingFileHelper) + .addCriterion("crafting", ExopackGainedCraftingTrigger.criterion) + .save(serializer, modLocation("exopack/crafting")) AdvancementBuilder() .parent(obtained) @@ -76,8 +77,8 @@ fun addExopackAdvancements(serializer: Consumer, existingFileHelper russian("Установите модуль переплавки в ваш Экзопак, позволяющий переплавлять предметы прямо у вас в инвентаре") }, ) - .addCriterion("smelting", ExopackGainedSmeltingTrigger.instance) - .save(serializer, modLocation("exopack/smelting"), existingFileHelper) + .addCriterion("smelting", ExopackGainedSmeltingTrigger.criterion) + .save(serializer, modLocation("exopack/smelting")) AdvancementBuilder() .parent(obtained) @@ -90,8 +91,8 @@ fun addExopackAdvancements(serializer: Consumer, existingFileHelper russian("Получите прямой доступ к содержимому вашего сундука края прямо из Экзопака") }, ) - .addCriterion("ender_access", ExopackGainedEnderAccessTrigger.instance) - .save(serializer, modLocation("ender_access/smelting"), existingFileHelper) + .addCriterion("ender_access", ExopackGainedEnderAccessTrigger.criterion) + .save(serializer, modLocation("ender_access/smelting")) var size = AdvancementBuilder() .parent(obtained) @@ -104,8 +105,8 @@ fun addExopackAdvancements(serializer: Consumer, existingFileHelper russian("Улучшите размер инвентаря Экзопака") }, ) - .addCriterion("size0", ExopackSlotsExpandedTrigger.Instance(minTotal = 1)) - .save(serializer, modLocation("exopack/size0"), existingFileHelper) + .addCriterion("size0", ExopackSlotsExpandedTrigger.Instance(minTotal = 1).criterion()) + .save(serializer, modLocation("exopack/size0")) val size0 = size @@ -120,8 +121,8 @@ fun addExopackAdvancements(serializer: Consumer, existingFileHelper russian("Достигните 27 слотов хранилища Экзопака") }, ) - .addCriterion("size1", ExopackSlotsExpandedTrigger.Instance(minTotal = 27)) - .save(serializer, modLocation("exopack/size1"), existingFileHelper) + .addCriterion("size1", ExopackSlotsExpandedTrigger.Instance(minTotal = 27).criterion()) + .save(serializer, modLocation("exopack/size1")) size = AdvancementBuilder() .parent(size) @@ -135,8 +136,8 @@ fun addExopackAdvancements(serializer: Consumer, existingFileHelper russian("Достигните 54 слотов хранилища Экзопака") }, ) - .addCriterion("size2", ExopackSlotsExpandedTrigger.Instance(minTotal = 54)) - .save(serializer, modLocation("exopack/size2"), existingFileHelper) + .addCriterion("size2", ExopackSlotsExpandedTrigger.Instance(minTotal = 54).criterion()) + .save(serializer, modLocation("exopack/size2")) size = AdvancementBuilder() .parent(size) @@ -151,8 +152,8 @@ fun addExopackAdvancements(serializer: Consumer, existingFileHelper }, frameType = FrameType.GOAL ) - .addCriterion("size3", ExopackSlotsExpandedTrigger.Instance(minTotal = 108)) - .save(serializer, modLocation("exopack/size3"), existingFileHelper) + .addCriterion("size3", ExopackSlotsExpandedTrigger.Instance(minTotal = 108).criterion()) + .save(serializer, modLocation("exopack/size3")) size = AdvancementBuilder() .parent(size) @@ -167,8 +168,8 @@ fun addExopackAdvancements(serializer: Consumer, existingFileHelper }, frameType = FrameType.CHALLENGE ) - .addCriterion("size4", ExopackSlotsExpandedTrigger.Instance(minTotal = 432)) - .save(serializer, modLocation("exopack/size4"), existingFileHelper) + .addCriterion("size4", ExopackSlotsExpandedTrigger.Instance(minTotal = 432).criterion()) + .save(serializer, modLocation("exopack/size4")) AdvancementBuilder() .parent(size) @@ -183,8 +184,8 @@ fun addExopackAdvancements(serializer: Consumer, existingFileHelper }, frameType = FrameType.CHALLENGE ) - .addCriterion("size5", ExopackSlotsExpandedTrigger.Instance(minTotal = 1728)) - .save(serializer, modLocation("exopack/size5"), existingFileHelper) + .addCriterion("size5", ExopackSlotsExpandedTrigger.Instance(minTotal = 1728).criterion()) + .save(serializer, modLocation("exopack/size5")) var once = AdvancementBuilder() .parent(size0) @@ -197,8 +198,8 @@ fun addExopackAdvancements(serializer: Consumer, existingFileHelper russian("Улучшите хранилище Экзопака модулем на 9 слотов") }, ) - .addCriterion("once0", ExopackSlotsExpandedTrigger.Instance(minGained = 9)) - .save(serializer, modLocation("exopack/once0"), existingFileHelper) + .addCriterion("once0", ExopackSlotsExpandedTrigger.Instance(minGained = 9).criterion()) + .save(serializer, modLocation("exopack/once0")) once = AdvancementBuilder() .parent(once) @@ -211,8 +212,8 @@ fun addExopackAdvancements(serializer: Consumer, existingFileHelper russian("Улучшите хранилище Экзопака модулем на 27 слотов") }, ) - .addCriterion("once1", ExopackSlotsExpandedTrigger.Instance(minGained = 27)) - .save(serializer, modLocation("exopack/once1"), existingFileHelper) + .addCriterion("once1", ExopackSlotsExpandedTrigger.Instance(minGained = 27).criterion()) + .save(serializer, modLocation("exopack/once1")) once = AdvancementBuilder() .parent(once) @@ -227,8 +228,8 @@ fun addExopackAdvancements(serializer: Consumer, existingFileHelper }, frameType = FrameType.GOAL ) - .addCriterion("once2", ExopackSlotsExpandedTrigger.Instance(minGained = 54)) - .save(serializer, modLocation("exopack/once2"), existingFileHelper) + .addCriterion("once2", ExopackSlotsExpandedTrigger.Instance(minGained = 54).criterion()) + .save(serializer, modLocation("exopack/once2")) once = AdvancementBuilder() .parent(once) @@ -243,8 +244,8 @@ fun addExopackAdvancements(serializer: Consumer, existingFileHelper }, frameType = FrameType.GOAL ) - .addCriterion("once3", ExopackSlotsExpandedTrigger.Instance(minGained = 90)) - .save(serializer, modLocation("exopack/once3"), existingFileHelper) + .addCriterion("once3", ExopackSlotsExpandedTrigger.Instance(minGained = 90).criterion()) + .save(serializer, modLocation("exopack/once3")) AdvancementBuilder() .parent(once) @@ -259,6 +260,6 @@ fun addExopackAdvancements(serializer: Consumer, existingFileHelper }, frameType = FrameType.CHALLENGE ) - .addCriterion("once4", ExopackSlotsExpandedTrigger.Instance(minGained = 150)) - .save(serializer, modLocation("exopack/once4"), existingFileHelper) + .addCriterion("once4", ExopackSlotsExpandedTrigger.Instance(minGained = 150).criterion()) + .save(serializer, modLocation("exopack/once4")) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/Helpers.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/Helpers.kt index 7ff42e320..83a4eef59 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/Helpers.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/Helpers.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.datagen.advancements import net.minecraft.advancements.Advancement +import net.minecraft.advancements.Criterion import net.minecraft.advancements.CriterionTriggerInstance import net.minecraft.advancements.DisplayInfo import net.minecraft.advancements.FrameType @@ -57,7 +58,7 @@ fun predicate(tag: TagKey): ItemPredicate { return ItemPredicate.Builder.item().of(tag).build() } -fun criterion(tag: TagKey): CriterionTriggerInstance { +fun criterion(tag: TagKey): Criterion<*> { return InventoryChangeTrigger.TriggerInstance.hasItems(predicate(tag)) } @@ -65,7 +66,7 @@ fun predicate(item: ItemLike): ItemPredicate { return ItemPredicate.Builder.item().of(item).build() } -fun criterion(item: ItemLike): CriterionTriggerInstance { +fun criterion(item: ItemLike): Criterion<*> { return InventoryChangeTrigger.TriggerInstance.hasItems(predicate(item)) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt index 98f922329..36cdb7ff2 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt @@ -1,20 +1,16 @@ package ru.dbotthepony.mc.otm.datagen.advancements -import net.minecraft.advancements.Advancement +import net.minecraft.advancements.AdvancementHolder import net.minecraft.advancements.FrameType -import net.minecraft.advancements.RequirementsStrategy import net.minecraft.advancements.critereon.ItemPredicate -import net.minecraft.network.chat.contents.TranslatableContents import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items -import net.minecraftforge.common.data.ExistingFileHelper import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.key import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.datagen.lang.MatteryLanguageProvider import ru.dbotthepony.mc.otm.datagen.modLocation -import ru.dbotthepony.mc.otm.registry.MItemTags import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.triggers.TakeItemOutOfReplicatorTrigger import java.util.function.Consumer @@ -27,7 +23,7 @@ private data class CraftEntry( val russianName: String? = null, val russianSuffix: String? = null, ) { - fun make(serializer: Consumer, existingFileHelper: ExistingFileHelper, parent: Advancement, translation: MatteryLanguageProvider.MultiBuilder): Advancement { + fun make(serializer: Consumer, parent: AdvancementHolder, translation: MatteryLanguageProvider.MultiBuilder): AdvancementHolder { val path = item.registryName!!.path val translated = translation.add("$path.desc", "Craft a %s%s") { @@ -50,11 +46,11 @@ private data class CraftEntry( description = TranslatableComponent(translated.contents.key, item.description, translatedSuffix), ) .addCriterion("has_machine", criterion(item)) - .save(serializer, modLocation("machines/$path"), existingFileHelper) + .save(serializer, modLocation("machines/$path")) } } -fun addMachineAdvancements(serializer: Consumer, existingFileHelper: ExistingFileHelper, lang: MatteryLanguageProvider, root: Advancement) { +fun addMachineAdvancements(serializer: Consumer, lang: MatteryLanguageProvider, root: AdvancementHolder) { val translation = lang.MultiBuilder("otm.advancements.machine") val chem = AdvancementBuilder() @@ -69,7 +65,7 @@ fun addMachineAdvancements(serializer: Consumer, existingFileHelper }, ) .addCriterion("has_machine", criterion(MItems.CHEMICAL_GENERATOR)) - .save(serializer, modLocation("machines/chemical_generator"), existingFileHelper) + .save(serializer, modLocation("machines/chemical_generator")) val press = AdvancementBuilder() .parent(chem) @@ -83,10 +79,10 @@ fun addMachineAdvancements(serializer: Consumer, existingFileHelper }, ) .addCriterion("has_machine", criterion(MItems.PLATE_PRESS)) - .save(serializer, modLocation("machines/plate_press"), existingFileHelper) + .save(serializer, modLocation("machines/plate_press")) CraftEntry(MItems.TWIN_PLATE_PRESS, "Twice the Thud", - russianName = "Двойной стук").make(serializer, existingFileHelper, press, translation) + russianName = "Двойной стук").make(serializer, press, translation) val scanner = CraftEntry(MItems.MATTER_SCANNER, "Scanning Things that Matter", russianName = "Сканируем вещи которые материальны") @@ -114,12 +110,12 @@ fun addMachineAdvancements(serializer: Consumer, existingFileHelper val reconstructor = CraftEntry(MItems.MATTER_RECONSTRUCTOR, "Flipping Hourglass", russianName = "Переворачиваем песочные часы") - decomposer.make(serializer, existingFileHelper, press, translation).also { - pattern.make(serializer, existingFileHelper, it, translation).also { - scanner.make(serializer, existingFileHelper, it, translation) - panel.make(serializer, existingFileHelper, it, translation) + decomposer.make(serializer, press, translation).also { + pattern.make(serializer, it, translation).also { + scanner.make(serializer, it, translation) + panel.make(serializer, it, translation) - replicator.make(serializer, existingFileHelper, it, translation).also { + replicator.make(serializer, it, translation).also { AdvancementBuilder() .parent(it) .display( @@ -132,8 +128,8 @@ fun addMachineAdvancements(serializer: Consumer, existingFileHelper }, frameType = FrameType.GOAL ) - .addCriterion("replicate_something", TakeItemOutOfReplicatorTrigger.Instance(ItemPredicate.Builder.item().of(MItems.MATTER_DUST).build(), true)) - .save(serializer, modLocation("machines/replicate_something"), existingFileHelper) + .addCriterion("replicate_something", TakeItemOutOfReplicatorTrigger.Instance(ItemPredicate.Builder.item().of(MItems.MATTER_DUST).build(), true).criterion()) + .save(serializer, modLocation("machines/replicate_something")) AdvancementBuilder() .parent(it) @@ -147,20 +143,20 @@ fun addMachineAdvancements(serializer: Consumer, existingFileHelper russian("Наблюдайте неудачный результат репликации, где ваш заказ рассыпался в материальную труху") }, ) - .addCriterion("replicate_failure", TakeItemOutOfReplicatorTrigger.Instance(ItemPredicate.Builder.item().of(MItems.MATTER_DUST).build())) - .save(serializer, modLocation("machines/replicate_failure"), existingFileHelper) + .addCriterion("replicate_failure", TakeItemOutOfReplicatorTrigger.Instance(ItemPredicate.Builder.item().of(MItems.MATTER_DUST).build()).criterion()) + .save(serializer, modLocation("machines/replicate_failure")) } - reconstructor.make(serializer, existingFileHelper, it, translation) + reconstructor.make(serializer, it, translation) } - bottler.make(serializer, existingFileHelper, it, translation) - recycler.make(serializer, existingFileHelper, it, translation) - capacitor.make(serializer, existingFileHelper, it, translation) + bottler.make(serializer, it, translation) + recycler.make(serializer, it, translation) + capacitor.make(serializer, it, translation) } - counter.make(serializer, existingFileHelper, press, translation).also { - battery.make(serializer, existingFileHelper, it, translation) + counter.make(serializer, press, translation).also { + battery.make(serializer, it, translation) } val station = CraftEntry(MItems.ANDROID_STATION, "Android Home Page", @@ -171,25 +167,25 @@ fun addMachineAdvancements(serializer: Consumer, existingFileHelper val charger = CraftEntry(MItems.ANDROID_CHARGER, "Android Home Router", russianName = "Домашняя страница андроидов") - station.make(serializer, existingFileHelper, press, translation).also { - charger.make(serializer, existingFileHelper, it, translation) + station.make(serializer, press, translation).also { + charger.make(serializer, it, translation) } CraftEntry(MItems.COBBLESTONE_GENERATOR, "Cobblestone: Infinity + 1", russianName = "Булыжник: бесконечность + 1", russianSuffix = "Смотрите, чтоб он не просыпался во все сундуки", - englishSuffix = "Watch for not to spill it over all your chests").make(serializer, existingFileHelper, press, translation) + englishSuffix = "Watch for not to spill it over all your chests").make(serializer, press, translation) CraftEntry(MItems.POWERED_FURNACE, "One Big Resistor", russianName = "Один большой резистор", russianSuffix = "Каждый элемент электрической цепи способен испускать свет и тепло, единожды.", englishSuffix = "Any electrical element can emit light and heat, once.") - .make(serializer, existingFileHelper, press, translation) + .make(serializer, press, translation) .also { CraftEntry(MItems.POWERED_BLAST_FURNACE, "Big Microwave Oven", - russianName = "Большая микроволновая печь").make(serializer, existingFileHelper, it, translation) + russianName = "Большая микроволновая печь").make(serializer, it, translation) CraftEntry(MItems.POWERED_SMOKER, "Small Microwave Oven", - russianName = "Маленькая микроволновая печь").make(serializer, existingFileHelper, it, translation) + russianName = "Маленькая микроволновая печь").make(serializer, it, translation) } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt index 9ebe10482..09e92456c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.datagen.recipes import com.google.common.collect.Lists import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.data.recipes.RecipeCategory +import net.minecraft.data.recipes.RecipeOutput import net.minecraft.data.recipes.SimpleCookingRecipeBuilder import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack @@ -14,7 +15,7 @@ import ru.dbotthepony.mc.otm.registry.MItems import java.util.* import java.util.function.Consumer -private fun Consumer.addRecyclingRecipe(inputs: Collection, result: Item, name: String) { +private fun RecipeOutput.addRecyclingRecipe(inputs: Collection, result: Item, name: String) { val inputStacks = inputs.map(::ItemStack) SimpleCookingRecipeBuilder.smelting( @@ -28,7 +29,7 @@ private fun Consumer.addRecyclingRecipe(inputs: Collection inputs.forEach { r.unlockedBy(it) } }.save(this, modLocation("blasting/${name}")) } -fun addBlastingRecipes(consumer: Consumer) { +fun addBlastingRecipes(consumer: RecipeOutput) { SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItems.MIRROR_COMPOUND), RecipeCategory.MISC, MItems.MIRROR, 0.1f, 100).unlockedBy(MItems.MIRROR_COMPOUND).save(consumer) SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_PLATES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 100).unlockedBy(MItemTags.TRITANIUM_PLATES).save(consumer, modLocation("tritanium_ingot_from_plates")) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index 889871d11..f5d871ded 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.datagen.recipes import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.data.recipes.RecipeCategory +import net.minecraft.data.recipes.RecipeOutput import net.minecraft.data.recipes.ShapelessRecipeBuilder import net.minecraft.tags.ItemTags import net.minecraft.world.item.ItemStack @@ -19,7 +20,7 @@ import ru.dbotthepony.mc.otm.recipe.ExplosiveHammerPrimingRecipe import ru.dbotthepony.mc.otm.recipe.UpgradeRecipe import java.util.function.Consumer -fun addCraftingTableRecipes(consumer: Consumer) { +fun addCraftingTableRecipes(consumer: RecipeOutput) { val machinesCategory = RecipeCategory.DECORATIONS MatteryRecipe(MRegistry.CARGO_CRATES.item, category = RecipeCategory.DECORATIONS) @@ -407,7 +408,7 @@ fun addCraftingTableRecipes(consumer: Consumer) { .unlockedBy(MItemTags.TRITANIUM_INGOTS) .build(consumer) - consumer.accept(ExplosiveHammerPrimingRecipe(modLocation("hammer_priming"), Ingredient.of(Tags.Items.NUGGETS_IRON)).finishedRecipe) + consumer.accept(ExplosiveHammerPrimingRecipe(Ingredient.of(Tags.Items.NUGGETS_IRON)).toFinished(modLocation("hammer_priming"))) MatteryRecipe(MItems.EXPLOSIVE_HAMMER, category = RecipeCategory.COMBAT) .rowB(Tags.Items.INGOTS_IRON) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt index f126765f7..ef69bdd76 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/DecorativesRecipes.kt @@ -15,7 +15,7 @@ import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRegistry import java.util.function.Consumer -private fun stairs(base: ItemLike, result: ItemLike, consumer: Consumer) { +private fun stairs(base: ItemLike, result: ItemLike, consumer: RecipeOutput) { MatteryRecipe(result, 4, category = RecipeCategory.BUILDING_BLOCKS) .rowA(base) .rowAB(base, base) @@ -24,14 +24,14 @@ private fun stairs(base: ItemLike, result: ItemLike, consumer: Consumer) { +private fun slab(base: ItemLike, result: ItemLike, consumer: RecipeOutput) { MatteryRecipe(result, 6, category = RecipeCategory.BUILDING_BLOCKS) .row(base, base, base) .unlockedBy(base) .build(consumer, modLocation("decorative/slabs/${base.asItem().registryName!!.path}")) } -private fun wall(base: ItemLike, result: ItemLike, consumer: Consumer) { +private fun wall(base: ItemLike, result: ItemLike, consumer: RecipeOutput) { MatteryRecipe(result, 6, category = RecipeCategory.BUILDING_BLOCKS) .row(base, base, base) .row(base, base, base) @@ -39,29 +39,29 @@ private fun wall(base: ItemLike, result: ItemLike, consumer: Consumer) { +private fun cut(base: ItemLike, result: ItemLike, amount: Int, consumer: RecipeOutput) { SingleItemRecipeBuilder .stonecutting(Ingredient.of(base), RecipeCategory.BUILDING_BLOCKS, result, amount) .unlockedBy(base) .save(consumer, modLocation("stonecutting/${result.asItem().registryName!!.path}_from_${base.asItem().registryName!!.path}")) } -private fun stairsWithCut(base: ItemLike, result: ItemLike, consumer: Consumer) { +private fun stairsWithCut(base: ItemLike, result: ItemLike, consumer: RecipeOutput) { stairs(base, result, consumer) cut(base, result, 1, consumer) } -private fun slabWithCut(base: ItemLike, result: ItemLike, consumer: Consumer) { +private fun slabWithCut(base: ItemLike, result: ItemLike, consumer: RecipeOutput) { slab(base, result, consumer) cut(base, result, 2, consumer) } -private fun wallWithCut(base: ItemLike, result: ItemLike, consumer: Consumer) { +private fun wallWithCut(base: ItemLike, result: ItemLike, consumer: RecipeOutput) { wall(base, result, consumer) cut(base, result, 1, consumer) } -fun addDecorativesRecipes(provider: MatteryRecipeProvider, consumer: Consumer) { +fun addDecorativesRecipes(provider: MatteryRecipeProvider, consumer: RecipeOutput) { // Напольная плитка for ((color, unrefinedItem) in MRegistry.UNREFINED_FLOOR_TILES.items) { MatteryRecipe(unrefinedItem, 24) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatterEntanglerRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatterEntanglerRecipes.kt index dc20725d1..9dbf0ec82 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatterEntanglerRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatterEntanglerRecipes.kt @@ -1,6 +1,6 @@ package ru.dbotthepony.mc.otm.datagen.recipes -import net.minecraft.data.recipes.FinishedRecipe +import net.minecraft.data.recipes.RecipeOutput import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Ingredient import net.minecraftforge.common.Tags @@ -10,12 +10,10 @@ import ru.dbotthepony.mc.otm.recipe.IngredientMatrix import ru.dbotthepony.mc.otm.recipe.MatterEntanglerRecipe import ru.dbotthepony.mc.otm.registry.MItemTags import ru.dbotthepony.mc.otm.registry.MItems -import java.util.function.Consumer -fun addMatterEntanglerRecipes(consumer: Consumer) { +fun addMatterEntanglerRecipes(consumer: RecipeOutput) { consumer.accept( MatterEntanglerRecipe( - modLocation("quantum_capacitor"), IngredientMatrix.of( listOf(Ingredient.of(MItems.ELECTRIC_PARTS), Ingredient.of(MItemTags.GOLD_WIRES), Ingredient.of(MItems.ELECTRIC_PARTS)), listOf(Ingredient.of(MItems.BATTERY_CAPACITOR), Ingredient.of(MItems.QUANTUM_TRANSCEIVER), Ingredient.of(MItems.BATTERY_CAPACITOR)), @@ -24,12 +22,11 @@ fun addMatterEntanglerRecipes(consumer: Consumer) { Decimal(40), 400.0, ItemStack(MItems.QUANTUM_CAPACITOR, 2) - ).energetic().toFinished() + ).energetic().toFinished(modLocation("quantum_capacitor")) ) consumer.accept( MatterEntanglerRecipe( - modLocation("quantum_battery"), IngredientMatrix.of( listOf(Ingredient.of(Tags.Items.STORAGE_BLOCKS_REDSTONE), Ingredient.of(MItemTags.GOLD_WIRES), Ingredient.of(Tags.Items.STORAGE_BLOCKS_REDSTONE)), listOf(Ingredient.of(MItems.BATTERY_DENSE), Ingredient.of(MItems.QUANTUM_TRANSCEIVER), Ingredient.of(MItems.BATTERY_DENSE)), @@ -38,6 +35,6 @@ fun addMatterEntanglerRecipes(consumer: Consumer) { Decimal(120), 600.0, ItemStack(MItems.QUANTUM_BATTERY, 2) - ).energetic().toFinished() + ).energetic().toFinished(modLocation("quantum_battery")) ) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt index df82b17aa..679c92fb2 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt @@ -2,9 +2,12 @@ package ru.dbotthepony.mc.otm.datagen.recipes import com.google.gson.JsonObject +import net.minecraft.advancements.Advancement +import net.minecraft.advancements.Criterion import net.minecraft.advancements.CriterionTriggerInstance import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.data.recipes.RecipeCategory +import net.minecraft.data.recipes.RecipeOutput import net.minecraft.data.recipes.ShapedRecipeBuilder import net.minecraft.resources.ResourceLocation import net.minecraft.tags.TagKey @@ -13,9 +16,9 @@ import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.item.crafting.RecipeSerializer import net.minecraft.world.level.ItemLike import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.core.collect.JsonArrayCollector import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.toJsonStrict import ru.dbotthepony.mc.otm.datagen.modLocation import ru.dbotthepony.mc.otm.recipe.EnergyContainerRecipe import ru.dbotthepony.mc.otm.recipe.UpgradeRecipe @@ -54,6 +57,18 @@ private data class RecipeRow( val c: RecipeCell?, ) +private fun RecipeOutput.map(mapper: (FinishedRecipe) -> FinishedRecipe): RecipeOutput { + return object : RecipeOutput { + override fun accept(recipe: FinishedRecipe) { + this@map.accept(mapper(recipe)) + } + + override fun advancement(): Advancement.Builder { + return this@map.advancement() + } + } +} + /** * [ShapedRecipeBuilder] that doesn't suck */ @@ -62,11 +77,11 @@ class MatteryRecipe(val result: ItemLike, val count: Int = 1, val category: Reci private val rows = arrayOfNulls(3) private var index = 0 - private val unlockedBy = ArrayList>().also { + private val unlockedBy = ArrayList>>().also { it.add("has_result" to has(result)) } - fun unlockedBy(name: String, trigger: CriterionTriggerInstance): MatteryRecipe { + fun unlockedBy(name: String, trigger: Criterion<*>): MatteryRecipe { unlockedBy.add(name to trigger) return this } @@ -163,55 +178,55 @@ class MatteryRecipe(val result: ItemLike, val count: Int = 1, val category: Reci return this } - private fun filter(consumer: Consumer): Consumer { + private fun filter(): (FinishedRecipe) -> FinishedRecipe { if (upgradeSource != null) { check(copyPaths.isNotEmpty()) { "Defined upgrade recipe without nbt migration operations" } - return Consumer { - consumer.accept(object : FinishedRecipe by it { + return { + object : FinishedRecipe by it { override fun serializeRecipeData(pJson: JsonObject) { it.serializeRecipeData(pJson) - pJson["copyPaths"] = copyPaths.stream().map { it.serialize() }.collect(JsonArrayCollector) + pJson["copyPaths"] = UpgradeRecipe.COPY_PATHS_CODEC.toJsonStrict(copyPaths) pJson["source"] = upgradeSource!!.toString() } - override fun getType(): RecipeSerializer<*> { - return UpgradeRecipe.Companion + override fun type(): RecipeSerializer<*> { + return UpgradeRecipe.CODEC } - }) + } } } - return consumer + return { it } } - fun build(consumer: Consumer, name: String? = null) { + fun build(consumer: RecipeOutput, name: String? = null) { val builder = buildRegular() if (name != null) { - builder.save(filter(consumer), modLocation( + builder.save(consumer.map(filter()), modLocation( if (result.asItem().registryName!!.namespace == OverdriveThatMatters.MOD_ID) "${result.asItem().registryName!!.path}_$name" else "${result.asItem().registryName!!.namespace}_${result.asItem().registryName!!.path}_$name" )) } else { - builder.save(filter(consumer)) + builder.save(consumer.map(filter())) } } - fun build(consumer: Consumer, name: ResourceLocation) { - buildRegular().save(filter(consumer), name) + fun build(consumer: RecipeOutput, name: ResourceLocation) { + buildRegular().save(consumer.map(filter()), name) } - fun buildEnergetic(consumer: Consumer, name: String? = null) { - build({ - consumer.accept(object : FinishedRecipe by it { - override fun getType(): RecipeSerializer<*> { + fun buildEnergetic(consumer: RecipeOutput, name: String? = null) { + build(consumer.map { + object : FinishedRecipe by it { + override fun type(): RecipeSerializer<*> { return EnergyContainerRecipe.Companion } - }) + } }, name) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt index bfefe5ca1..60ca7a37a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt @@ -1,5 +1,8 @@ package ru.dbotthepony.mc.otm.datagen.recipes +import com.google.common.collect.ImmutableList +import net.minecraft.advancements.CriteriaTriggers +import net.minecraft.advancements.Criterion import net.minecraft.advancements.critereon.ContextAwarePredicate import net.minecraft.advancements.critereon.EntityPredicate import net.minecraft.advancements.critereon.InventoryChangeTrigger @@ -8,6 +11,7 @@ import net.minecraft.advancements.critereon.MinMaxBounds import net.minecraft.data.DataGenerator import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.data.recipes.RecipeBuilder +import net.minecraft.data.recipes.RecipeOutput import net.minecraft.data.recipes.RecipeProvider import net.minecraft.resources.ResourceLocation import net.minecraft.tags.ItemTags @@ -20,32 +24,32 @@ import net.minecraft.world.level.ItemLike import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.datagen.modLocation import ru.dbotthepony.mc.otm.recipe.PlatePressRecipe -import java.util.LinkedList +import java.util.* import java.util.function.Consumer import java.util.stream.Stream -private typealias RecipeBuilderCallback = (MatteryRecipeProvider, consumer: Consumer) -> Unit +private typealias RecipeBuilderCallback = (MatteryRecipeProvider, consumer: RecipeOutput) -> Unit -fun has(p_176521_: MinMaxBounds.Ints, p_176522_: ItemLike): InventoryChangeTrigger.TriggerInstance { +fun has(p_176521_: MinMaxBounds.Ints, p_176522_: ItemLike): Criterion { return inventoryTrigger(ItemPredicate.Builder.item().of(p_176522_).withCount(p_176521_).build()) } -fun has(p_125978_: ItemLike): InventoryChangeTrigger.TriggerInstance { +fun has(p_125978_: ItemLike): Criterion { return inventoryTrigger(ItemPredicate.Builder.item().of(p_125978_).build()) } -fun has(p_125976_: TagKey): InventoryChangeTrigger.TriggerInstance { +fun has(p_125976_: TagKey): Criterion { return inventoryTrigger(ItemPredicate.Builder.item().of(p_125976_).build()) } -fun inventoryTrigger(vararg p_126012_: ItemPredicate): InventoryChangeTrigger.TriggerInstance { - return InventoryChangeTrigger.TriggerInstance( - ContextAwarePredicate.ANY, +fun inventoryTrigger(vararg p_126012_: ItemPredicate): Criterion { + return CriteriaTriggers.INVENTORY_CHANGED.createCriterion(InventoryChangeTrigger.TriggerInstance( + Optional.empty(), MinMaxBounds.Ints.ANY, MinMaxBounds.Ints.ANY, MinMaxBounds.Ints.ANY, - p_126012_ - ) + ImmutableList.copyOf(p_126012_) + )) } fun T.unlockedBy(item: ItemLike): T { @@ -75,7 +79,7 @@ class MatteryRecipeProvider(generatorIn: DataGenerator) : RecipeProvider(generat return this } - override fun buildRecipes(callback: Consumer) { + override fun buildRecipes(callback: RecipeOutput) { for (lambda in callbacks) { lambda(this, callback) } @@ -84,19 +88,18 @@ class MatteryRecipeProvider(generatorIn: DataGenerator) : RecipeProvider(generat fun plate(id: String, count: Int = 1, workTicks: Int = 200, experience: FloatProvider = ConstantFloat.ZERO) { exec { _, consumer -> consumer.accept(PlatePressRecipe( - modLocation("plates/$id"), Ingredient.of(ItemTags.create(ResourceLocation("forge", "ingots/$id"))), Ingredient.of(ItemTags.create(ResourceLocation("forge", "plates/$id"))), count, workTicks, experience = experience - ).toFinished()) + ).toFinished(modLocation("plates/$id"))) } } fun plate(id: String, ingredient: Ingredient, result: Ingredient, count: Int = 1, workTicks: Int = 200, experience: FloatProvider = ConstantFloat.ZERO) { exec { it, callback -> - callback.accept(PlatePressRecipe(modLocation("plate_$id"), ingredient, result, count, workTicks, experience = experience).toFinished()) + callback.accept(PlatePressRecipe(ingredient, result, count, workTicks, experience = experience).toFinished(modLocation("plate_$id"))) } } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/OreRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/OreRecipes.kt index 977a208a3..b2afd6a0f 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/OreRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/OreRecipes.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.datagen.recipes import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.data.recipes.RecipeCategory +import net.minecraft.data.recipes.RecipeOutput import net.minecraft.data.recipes.SimpleCookingRecipeBuilder import net.minecraft.world.item.crafting.Ingredient import ru.dbotthepony.mc.otm.datagen.modLocation @@ -9,7 +10,7 @@ import ru.dbotthepony.mc.otm.registry.MItemTags import ru.dbotthepony.mc.otm.registry.MItems import java.util.function.Consumer -fun addOreSmeltingRecipes(consumer: Consumer) { +fun addOreSmeltingRecipes(consumer: RecipeOutput) { SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_ORES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 200).unlockedBy(MItemTags.TRITANIUM_ORES).save(consumer, modLocation("smelting/tritanium_ingot_from_ore_block")) SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_ORES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 100).unlockedBy(MItemTags.TRITANIUM_ORES).save(consumer, modLocation("blasting/tritanium_ingot_from_ore_block")) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt index 2f290aa1e..7891470df 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.datagen.recipes import net.minecraft.data.recipes.FinishedRecipe +import net.minecraft.data.recipes.RecipeOutput import net.minecraft.world.item.DyeColor import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack @@ -16,20 +17,19 @@ import java.util.function.Consumer private val Item.recipeName get() = registryName!!.namespace + "/" + registryName!!.path -private fun generate(consumer: Consumer, items: Map, amount: Int = 1) { +private fun generate(consumer: RecipeOutput, items: Map, amount: Int = 1) { for ((targetColor, targetItem) in items) { if (targetColor == null) continue consumer.accept(PainterRecipe( - modLocation("painter/" + targetItem.recipeName), Ingredient.of(items.entries.stream().filter { it.key != null && it.key != targetColor }.map { ItemStack(it.value) }), ItemStack(targetItem), mapOf(targetColor to amount) - ).toFinished()) + ).toFinished(modLocation("painter/" + targetItem.recipeName))) } } -private fun generate(consumer: Consumer, default: Item, items: Map, amount: Int = 1, cleaning: Boolean = true) { +private fun generate(consumer: RecipeOutput, default: Item, items: Map, amount: Int = 1, cleaning: Boolean = true) { generate(consumer, items) if (cleaning) @@ -39,37 +39,34 @@ private fun generate(consumer: Consumer, default: Item, items: M if (k1 == null) continue consumer.accept(PainterRecipe( - modLocation("painter/" + default.recipeName + "/" + v1.recipeName), Ingredient.of(default), ItemStack(v1), mapOf(k1 to amount) - ).toFinished()) + ).toFinished(modLocation("painter/" + default.recipeName + "/" + v1.recipeName))) } } -private fun cleaning(consumer: Consumer, to: Item, from: Map) { +private fun cleaning(consumer: RecipeOutput, to: Item, from: Map) { consumer.accept(PainterRecipe( - modLocation("painter/cleaning/" + to.recipeName), Ingredient.of(from.entries.stream().filter { it.key != null }.map { ItemStack(it.value) }), ItemStack(to), setOf() - ).toFinished()) + ).toFinished(modLocation("painter/cleaning/" + to.recipeName))) } -private fun striped(consumer: Consumer, name: String, items: List>>, base: Map) { +private fun striped(consumer: RecipeOutput, name: String, items: List>>, base: Map) { for ((stripeItem, colors) in items) { val (baseColor, stripe) = colors consumer.accept(PainterRecipe( - modLocation("painter/stripes_$name/${baseColor.getName()}/${stripe.getName()}"), Ingredient.of(base[baseColor]), ItemStack(stripeItem), setOf(stripe) - ).toFinished()) + ).toFinished(modLocation("painter/stripes_$name/${baseColor.getName()}/${stripe.getName()}"))) } } -fun addPainterRecipes(consumer: Consumer) { +fun addPainterRecipes(consumer: RecipeOutput) { generate(consumer, mapOf( DyeColor.WHITE to Items.WHITE_WOOL, DyeColor.ORANGE to Items.ORANGE_WOOL, diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/ShapelessRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/ShapelessRecipes.kt index 08f55b308..62347854a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/ShapelessRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/ShapelessRecipes.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.datagen.recipes import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.data.recipes.RecipeCategory +import net.minecraft.data.recipes.RecipeOutput import net.minecraft.data.recipes.ShapelessRecipeBuilder import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack @@ -14,8 +15,8 @@ import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRegistry import java.util.function.Consumer -fun addShapelessRecipes(consumer: Consumer) { - for (color in DyeColor.values()) { +fun addShapelessRecipes(consumer: RecipeOutput) { + for (color in DyeColor.entries) { ShapelessRecipeBuilder(RecipeCategory.TRANSPORTATION, MItems.CARGO_CRATE_MINECARTS[color]!!, 1) .requires(Items.MINECART) .requires(MRegistry.CARGO_CRATES.items[color]!!) diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/GuiGraphicsMixin.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/GuiGraphicsMixin.java new file mode 100644 index 000000000..92ab70446 --- /dev/null +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/GuiGraphicsMixin.java @@ -0,0 +1,23 @@ +package ru.dbotthepony.mc.otm.mixin; + +import net.minecraft.client.gui.GuiGraphics; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; + +import static ru.dbotthepony.mc.otm.client.render.RenderHelperKt.popScissorRect; +import static ru.dbotthepony.mc.otm.client.render.RenderHelperKt.pushScissorRect; + +// because scissor stack fucking sucks. +// mostly because it is not a stack at all. +@Mixin(GuiGraphics.class) +public abstract class GuiGraphicsMixin { + @Overwrite + public void enableScissor(int x0, int y0, int x1, int y1) { + pushScissorRect(x0, y0, x1 - x0, y1 - y0); + } + + @Overwrite + public void disableScissor() { + popScissorRect(); + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchManager.kt index 654d97ca4..a7713349c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchManager.kt @@ -13,7 +13,7 @@ import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener import net.minecraft.util.profiling.ProfilerFiller import net.minecraftforge.event.AddReloadListenerEvent import net.minecraftforge.event.OnDatapackSyncEvent -import net.minecraftforge.network.NetworkEvent +import net.minecraftforge.event.network.CustomPayloadEvent import net.minecraftforge.network.PacketDistributor import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.MINECRAFT_SERVER @@ -27,11 +27,8 @@ import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.core.toNetwork import ru.dbotthepony.mc.otm.network.GenericNetworkChannel import ru.dbotthepony.mc.otm.network.MatteryPacket -import ru.dbotthepony.mc.otm.network.enqueueWork -import ru.dbotthepony.mc.otm.network.packetHandled import ru.dbotthepony.mc.otm.onceServer import java.util.LinkedList -import java.util.function.Supplier object AndroidResearchManager : SimpleJsonResourceReloadListener(GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(), "otm_android_research"), Iterable { const val DIRECTORY = "otm_android_research" @@ -114,7 +111,7 @@ object AndroidResearchManager : SimpleJsonResourceReloadListener(GsonBuilder().s LOGGER.debug("Constructed android research registry packet, ${buff.writerIndex()} bytes in size") } - override fun play(context: Supplier) { + override fun play(context: CustomPayloadEvent.Context) { context.packetHandled = true if (NULLABLE_MINECRAFT_SERVER is IntegratedServer) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt index f4eb7a76a..ad2610563 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt @@ -25,7 +25,6 @@ import ru.dbotthepony.mc.otm.core.collect.ListSet import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.isActuallyEmpty import ru.dbotthepony.mc.otm.data.ComponentCodec -import ru.dbotthepony.mc.otm.data.IngredientCodec import ru.dbotthepony.mc.otm.data.JsonElementCodec import ru.dbotthepony.mc.otm.isClient import java.util.Optional @@ -393,7 +392,7 @@ class AndroidResearchType( ListCodec( RecordCodecBuilder.create> { it.group( - IngredientCodec.fieldOf("item").forGetter { it.first }, + Ingredient.CODEC.fieldOf("item").forGetter { it.first }, Codec.intRange(1, Int.MAX_VALUE).optionalFieldOf("count", 1).forGetter { it.second } ).apply(it, ::Pair) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt index 066ccb6fb..77741942c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt @@ -5,7 +5,7 @@ import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.network.FriendlyByteBuf import net.minecraft.world.entity.Entity import net.minecraft.world.entity.item.ItemEntity -import net.minecraftforge.network.NetworkEvent +import net.minecraftforge.event.network.CustomPayloadEvent import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability @@ -21,12 +21,10 @@ import ru.dbotthepony.mc.otm.core.position import ru.dbotthepony.mc.otm.core.math.times import ru.dbotthepony.mc.otm.network.GenericNetworkChannel import ru.dbotthepony.mc.otm.network.MatteryPacket -import ru.dbotthepony.mc.otm.network.packetHandled import ru.dbotthepony.mc.otm.registry.AndroidFeatures import java.util.UUID import java.util.WeakHashMap import java.util.function.Predicate -import java.util.function.Supplier private data class SharedItemEntityData(val owner: UUID? = null, val age: Int = 0, val lifespan: Int = 0, val hasPickupDelay: Boolean = true) { companion object { @@ -46,8 +44,7 @@ class ItemEntityDataPacket(val itemUUID: Int, val owner: UUID? = null, val age: buff.writeBoolean(hasPickupDelay) } - override fun play(context: Supplier) { - context.packetHandled = true + override fun play(context: CustomPayloadEvent.Context) { val level = minecraft.player?.level() as ClientLevel? ?: return val entity = level.getEntity(itemUUID) as ItemEntity? ?: return datatable[entity] = SharedItemEntityData(owner, age, lifespan, hasPickupDelay) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt index ad4205e90..1c38e41ca 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt @@ -1,23 +1,17 @@ package ru.dbotthepony.mc.otm.android.feature import net.minecraft.client.gui.GuiGraphics -import net.minecraft.core.particles.ParticleTypes import net.minecraft.network.FriendlyByteBuf import net.minecraft.server.level.ServerPlayer import net.minecraft.sounds.SoundSource -import net.minecraft.util.RandomSource -import net.minecraft.world.level.Level -import net.minecraftforge.network.NetworkEvent -import net.minecraftforge.network.PacketDistributor -import net.minecraftforge.network.PacketDistributor.TargetPoint -import ru.dbotthepony.mc.otm.config.ClientConfig -import ru.dbotthepony.mc.otm.config.AndroidConfig +import net.minecraftforge.event.network.CustomPayloadEvent import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.capability.matteryPlayer -import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.ResearchIcons +import ru.dbotthepony.mc.otm.config.AndroidConfig +import ru.dbotthepony.mc.otm.config.ClientConfig import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.math.plus @@ -25,9 +19,6 @@ import ru.dbotthepony.mc.otm.network.GenericNetworkChannel import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel import ru.dbotthepony.mc.otm.network.SmokeParticlesPacket -import ru.dbotthepony.mc.otm.network.enqueueWork -import ru.dbotthepony.mc.otm.network.packetHandled -import ru.dbotthepony.mc.otm.network.sender import ru.dbotthepony.mc.otm.registry.AndroidFeatures import ru.dbotthepony.mc.otm.registry.MSoundEvents import java.util.function.Supplier @@ -37,29 +28,25 @@ object TriggerJumpBoostPacket : MatteryPacket { // no op } - override fun play(context: Supplier) { - context.packetHandled = true + override fun play(context: CustomPayloadEvent.Context) { + val mattery = context.sender?.matteryPlayer ?: return - context.enqueueWork { - val mattery = context.sender?.matteryPlayer ?: return@enqueueWork + if (!mattery.isAndroid) + return - if (!mattery.isAndroid) - return@enqueueWork + val feature = mattery.getFeature(AndroidFeatures.JUMP_BOOST) ?: return - val feature = mattery.getFeature(AndroidFeatures.JUMP_BOOST) ?: return@enqueueWork + if (feature.isActive && feature.cooldown <= 4 && mattery.androidEnergy.extractEnergyExact(AndroidConfig.JumpBoost.ENERGY_COST, false)) { + feature.putOnCooldown() - if (feature.isActive && feature.cooldown <= 4 && mattery.androidEnergy.extractEnergyExact(AndroidConfig.JumpBoost.ENERGY_COST, false)) { - feature.putOnCooldown() + context.sender?.let { + it.level().playSound( + it, it, + MSoundEvents.ANDROID_JUMP_BOOST, SoundSource.PLAYERS, + 1f, 1f + ) - context.sender?.let { - it.level().playSound( - it, it, - MSoundEvents.ANDROID_JUMP_BOOST, SoundSource.PLAYERS, - 1f, 1f - ) - - GenericNetworkChannel.makeSmoke(it, it.x, it.y, it.z) - } + GenericNetworkChannel.makeSmoke(it, it.x, it.y, it.z) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt index faad7ecd9..02289c405 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt @@ -1,54 +1,41 @@ package ru.dbotthepony.mc.otm.android.feature -import com.mojang.blaze3d.systems.RenderSystem -import com.mojang.blaze3d.vertex.PoseStack import it.unimi.dsi.fastutil.objects.ReferenceArraySet -import net.minecraft.ChatFormatting import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.FriendlyByteBuf -import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import net.minecraft.sounds.SoundSource import net.minecraft.world.entity.Entity import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.monster.warden.Warden -import net.minecraftforge.network.NetworkEvent -import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.config.AndroidConfig -import ru.dbotthepony.mc.otm.android.AndroidResearchManager +import net.minecraftforge.event.network.CustomPayloadEvent import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact +import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.render.ResearchIcons -import ru.dbotthepony.mc.otm.core.math.Vector -import ru.dbotthepony.mc.otm.core.util.formatPower -import ru.dbotthepony.mc.otm.core.math.getEllipsoidBlockPositions +import ru.dbotthepony.mc.otm.config.AndroidConfig +import ru.dbotthepony.mc.otm.core.damageType import ru.dbotthepony.mc.otm.core.getEntitiesInEllipsoid import ru.dbotthepony.mc.otm.core.getExplosionResistance +import ru.dbotthepony.mc.otm.core.math.RGBAColor +import ru.dbotthepony.mc.otm.core.math.Vector +import ru.dbotthepony.mc.otm.core.math.getEllipsoidBlockPositions import ru.dbotthepony.mc.otm.core.math.minus import ru.dbotthepony.mc.otm.core.math.plus -import ru.dbotthepony.mc.otm.core.position import ru.dbotthepony.mc.otm.core.math.roundToIntVector import ru.dbotthepony.mc.otm.core.math.times -import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel -import ru.dbotthepony.mc.otm.capability.matteryPlayer -import ru.dbotthepony.mc.otm.client.ShiftPressedCond -import ru.dbotthepony.mc.otm.core.damageType -import ru.dbotthepony.mc.otm.core.math.RGBAColor +import ru.dbotthepony.mc.otm.core.position import ru.dbotthepony.mc.otm.network.MatteryPacket +import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel import ru.dbotthepony.mc.otm.network.ShockwaveEffectPacket -import ru.dbotthepony.mc.otm.network.enqueueWork -import ru.dbotthepony.mc.otm.network.packetHandled -import ru.dbotthepony.mc.otm.network.sender import ru.dbotthepony.mc.otm.onceServer import ru.dbotthepony.mc.otm.registry.AndroidFeatures import ru.dbotthepony.mc.otm.registry.MDamageTypes -import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.registry.MSoundEvents import ru.dbotthepony.mc.otm.registry.MatteryDamageSource import ru.dbotthepony.mc.otm.triggers.ShockwaveDamageMobTrigger import ru.dbotthepony.mc.otm.triggers.ShockwaveTrigger -import java.util.function.Supplier import kotlin.math.pow import kotlin.math.roundToInt @@ -57,15 +44,12 @@ object TriggerShockwavePacket : MatteryPacket { // no op } - override fun play(context: Supplier) { - context.packetHandled = true - context.enqueueWork { - val shockwave = context.sender?.matteryPlayer?.getFeature(AndroidFeatures.SHOCKWAVE) as ShockwaveFeature? ?: return@enqueueWork + override fun play(context: CustomPayloadEvent.Context) { + val shockwave = context.sender?.matteryPlayer?.getFeature(AndroidFeatures.SHOCKWAVE) ?: return - if (!shockwave.isOnCooldown && shockwave.isActive && shockwave.airTicks > 0) { - onceServer { // delay by one tick so player update its position as well - shockwave.shockwave() - } + if (!shockwave.isOnCooldown && shockwave.isActive && shockwave.airTicks > 0) { + onceServer { // delay by one tick so player update its position as well + shockwave.shockwave() } } } 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 cbb834cf4..44d9aa00e 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 @@ -667,12 +667,11 @@ class ExplosionQueue(private val level: ServerLevel) : SavedData() { @JvmStatic fun queueForLevel(level: ServerLevel): ExplosionQueue { return level.dataStorage.computeIfAbsent( - { + Factory({ ExplosionQueue(level) }, { val factory = ExplosionQueue(level) factory.load(it) factory - }, - { ExplosionQueue(level) }, + }, TODO()), "otm_blackhole_explosion_queue" ) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterEntanglerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterEntanglerBlockEntity.kt index 266eb09a4..bcd29a5e4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterEntanglerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterEntanglerBlockEntity.kt @@ -77,7 +77,7 @@ class MatterEntanglerBlockEntity(blockPos: BlockPos, blockState: BlockState) : M .recipeManager .byType(MRecipes.MATTER_ENTANGLER) .values - .any { it.preemptivelyMatches(shadow, level!!) } + .any { it.value.preemptivelyMatches(shadow, level!!) } } override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { @@ -139,9 +139,9 @@ class MatterEntanglerBlockEntity(blockPos: BlockPos, blockState: BlockState) : M .recipeManager .byType(MRecipes.MATTER_ENTANGLER) .values - .firstOrNull { it.matches(inputs, level!!) } ?: return JobContainer.noItem() + .firstOrNull { it.value.matches(inputs, level!!) } ?: return JobContainer.noItem() - val result = recipe.assemble(inputs, level!!.registryAccess()) + val result = recipe.value.assemble(inputs, level!!.registryAccess()) inputs.forEach { it.shrink(1) } inputs.setChanged() @@ -149,8 +149,8 @@ class MatterEntanglerBlockEntity(blockPos: BlockPos, blockState: BlockState) : M return JobContainer.success( Job( result, - recipe.matter, - recipe.ticks * MachinesConfig.MATTER_ENTANGLER.workTimeMultiplier + recipe.value.matter, + recipe.value.ticks * MachinesConfig.MATTER_ENTANGLER.workTimeMultiplier ) ) } 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 312d24e96..2a63e5a86 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 @@ -230,7 +230,7 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte if (craftingRecipe != null && craftingRecipe.matches(craftingGrid, level)) return true if (justCheckForRecipeChange) return false - craftingRecipe = server.recipeManager.getRecipeFor(RecipeType.CRAFTING, craftingGrid, level).orElse(null) + craftingRecipe = server.recipeManager.getRecipeFor(RecipeType.CRAFTING, craftingGrid, level).orElse(null)?.value Arrays.fill(craftingGridTuples, null) val poweredView = poweredView 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 5dcf9e6e0..27823bfcf 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 @@ -92,8 +92,8 @@ class PlatePressBlockEntity( .byType(MRecipes.PLATE_PRESS) .values .iterator() - .filter { it.matches(inputContainer, id) } - .maybe() ?: return JobContainer.noItem() + .filter { it.value.matches(inputContainer, id) } + .maybe()?.value ?: return JobContainer.noItem() val toProcess = inputContainer[id].count.coerceAtMost(1 + upgrades.processingItems) 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 ecbd85b62..faded59a3 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 @@ -108,12 +108,12 @@ class PoweredFurnaceBlockEntity( val level = level as? ServerLevel ?: return JobContainer.failure() return level.recipeManager.getRecipeFor(recipeType as RecipeType, inputs[id], level).map { - val output = it.assemble(inputs[id], level.registryAccess()) + val output = it.value.assemble(inputs[id], level.registryAccess()) val toProcess = inputs[id][0].count.coerceAtMost(upgrades.processingItems + 1) inputs[id][0].shrink(toProcess) JobContainer.success(ItemJob( - output.copyWithCount(toProcess), it.cookingTime * config.workTimeMultiplier, config.energyConsumption * toProcess, it.experience * toProcess + output.copyWithCount(toProcess), it.value.cookingTime * config.workTimeMultiplier, config.energyConsumption * toProcess, it.value.experience * toProcess )) }.orElse(JobContainer.noItem()) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 20d101fd9..fd72e1114 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -520,10 +520,10 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial return JobContainer.noItem() } else { val actual = recipe.get() - val item = actual.assemble(input, level.registryAccess()) + val item = actual.value.assemble(input, level.registryAccess()) input[0].shrink(1) input.setChanged(0) - return JobContainer.success(ItemJob(item, actual.cookingTime.toDouble(), ExopackConfig.FURNACE_POWER_CONSUMPTION, actual.experience)) + return JobContainer.success(ItemJob(item, actual.value.cookingTime.toDouble(), ExopackConfig.FURNACE_POWER_CONSUMPTION, actual.value.experience)) } } @@ -531,7 +531,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial super.onJobTick(status) if (isExopackVisible && ply.level().random.nextFloat() <= 0.05f) { - MatteryPlayerNetworkChannel.send(PacketDistributor.TRACKING_ENTITY_AND_SELF.with { ply as ServerPlayer }, ExopackSmokePacket(ply.uuid)) + MatteryPlayerNetworkChannel.send(PacketDistributor.TRACKING_ENTITY_AND_SELF.with(ply as ServerPlayer), ExopackSmokePacket(ply.uuid)) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt index 35038c0c6..9f9b08fb0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt @@ -217,7 +217,7 @@ fun onMouseScrolled(event: MouseScrolled.Pre) { for (widget in screen.renderables) { if (widget is Panel2Widget<*, *>) { - if (widget.panel.mouseScrolledChecked(event.mouseX, event.mouseY, event.scrollDelta)) { + if (widget.panel.mouseScrolledChecked(event.mouseX, event.mouseY, event.deltaX)) { event.isCanceled = true return } @@ -226,7 +226,7 @@ fun onMouseScrolled(event: MouseScrolled.Pre) { val slot = screen.slotUnderMouse if (slot != null && (slot.container == minecraft.player?.inventory && slot.containerSlot in 9 .. 35 || slot.container == minecraft.player?.matteryPlayer?.exopackContainer)) { - widget.panel.mouseScrolledInner(event.mouseX, event.mouseY, event.scrollDelta) + widget.panel.mouseScrolledInner(event.mouseX, event.mouseY, event.deltaX) event.isCanceled = true return } 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 ede81d6aa..3105d5426 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 @@ -54,7 +54,6 @@ import java.util.* import kotlin.collections.ArrayDeque import kotlin.collections.List import kotlin.collections.MutableSet -import kotlin.collections.indices import kotlin.collections.isNotEmpty import kotlin.collections.withIndex @@ -565,9 +564,9 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit return super.mouseReleased(p_97812_, p_97813_, p_97814_) } - override fun mouseScrolled(p_94686_: Double, p_94687_: Double, p_94688_: Double): Boolean { + override fun mouseScrolled(mouseX: Double, mouseY: Double, scrollX: Double, scrollY: Double): Boolean { for (panel in panels) { - if (panel.mouseScrolledChecked(p_94686_, p_94687_, p_94688_)) { + if (panel.mouseScrolledChecked(mouseX, mouseY, scrollY)) { return true } } @@ -648,7 +647,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit val mouseYf = mouseY.toFloat() // dark background - this.renderBackground(graphics) + this.renderBackground(graphics, mouseX, mouseY, partialTick) super.hoveredSlot = null var hovered = false 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 6ef67f5e9..792b6cfde 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 @@ -123,8 +123,8 @@ class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : buttons.forEach { it.remove() } buttons.clear() - for (recipe in menu.possibleRecipes.sortedWith(CreativeMenuItemComparator.map { it.output.item })) { - object : LargeRectangleButtonPanel(this@PainterScreen, canvas.canvas, icon = ItemStackIcon(recipe.output, 14f, 14f).fixed()) { + for (recipe in menu.possibleRecipes.sortedWith(CreativeMenuItemComparator.map { it.value.output.item })) { + object : LargeRectangleButtonPanel(this@PainterScreen, canvas.canvas, icon = ItemStackIcon(recipe.value.output, 14f, 14f).fixed()) { init { buttons.add(this) dockRight = 1f @@ -132,13 +132,13 @@ class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : } override var isDisabled: Boolean - get() = !recipe.canCraft(menu.dyeStoredDirect) + get() = !recipe.value.canCraft(menu.dyeStoredDirect) set(value) {} override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { - val list = getTooltipFromItem(minecraft!!, recipe.output) + val list = getTooltipFromItem(minecraft!!, recipe.value.output) - recipe.dyes.forEach { + recipe.value.dyes.forEach { val (dye, amount) = it if (amount == 1) 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 fb1c093ac..ca4f83484 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 @@ -108,8 +108,8 @@ open class EditablePanel @JvmOverloads constructor( return this@EditablePanel.mouseDragged(p_94740_, p_94741_, p_94742_, p_94743_, p_94744_) } - override fun mouseScrolled(p_94734_: Double, p_94735_: Double, p_94736_: Double): Boolean { - return this@EditablePanel.mouseScrolled(p_94734_, p_94735_, p_94736_) + override fun mouseScrolled(mouseX: Double, mouseY: Double, scrollX: Double, scrollY: Double): Boolean { + return this@EditablePanel.mouseScrolled(mouseX, mouseY, scrollY) } override fun keyPressed(p_94745_: Int, p_94746_: Int, p_94747_: Int): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt index 06ed18d7f..a5da55b6c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt @@ -169,14 +169,16 @@ class EntityRendererPanel @JvmOverloads constructor( return } - val renderX = width.toInt() / 2 - val renderY = (height * 0.9f).toInt() + val renderX = this.width.toInt() / 2 + val renderY = (this.height * 0.9f).toInt() InventoryScreen.renderEntityInInventoryFollowsMouse( graphics, renderX, renderY, + this.width.toInt(), this.height.toInt(), renderScale, + 0f, absoluteX.toInt() + renderX - mouseX, absoluteY + height * 0.15f - mouseY, entity 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 7610be9bd..7fb05715d 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 @@ -46,8 +46,8 @@ class Panel2Widget>( return panel.mouseDraggedChecked(p_94740_, p_94741_, p_94742_, p_94743_, p_94744_) } - override fun mouseScrolled(p_94734_: Double, p_94735_: Double, p_94736_: Double): Boolean { - return panel.mouseScrolledChecked(p_94734_, p_94735_, p_94736_) + override fun mouseScrolled(mouseX: Double, mouseY: Double, scrollX: Double, scrollY: Double): Boolean { + return panel.mouseScrolledChecked(mouseX, mouseY, scrollY) } override fun keyPressed(p_94745_: Int, p_94746_: Int, p_94747_: Int): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/EditBoxPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/EditBoxPanel.kt index 1a6823caf..5ddbc95f2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/EditBoxPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/EditBoxPanel.kt @@ -33,11 +33,6 @@ open class EditBoxPanel( new_widget.value = old_widget.value } - override fun tickInner() { - super.tickInner() - widget?.tick() - } - override fun configureNew(widget: EditBox, recreation: Boolean) { widget.isFocused = isFocusedThis } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt index 97532f820..b91549300 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt @@ -36,7 +36,8 @@ fun onCuriosSlotModifiersUpdated(event: SlotModifiersUpdatedEvent) { } fun openCuriosScreen(carriedStack: ItemStack = ItemStack.EMPTY) { - if (FMLEnvironment.dist.isClient) NetworkHandler.INSTANCE.send(PacketDistributor.SERVER.noArg(), CPacketOpenCurios(carriedStack)) + TODO() + // if (FMLEnvironment.dist.isClient) NetworkHandler.INSTANCE.send(PacketDistributor.SERVER.noArg(), CPacketOpenCurios(carriedStack)) } private fun Player.getCuriosSlotsImpl(): List> { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/ExopackInventoryTransferHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/ExopackInventoryTransferHandler.kt index 3572f1770..894507bcc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/ExopackInventoryTransferHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/ExopackInventoryTransferHandler.kt @@ -14,14 +14,15 @@ import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.MenuType import net.minecraft.world.inventory.Slot import net.minecraft.world.item.crafting.CraftingRecipe +import net.minecraft.world.item.crafting.RecipeHolder import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.toImmutableList import ru.dbotthepony.mc.otm.menu.ExopackInventoryMenu import java.util.* import kotlin.collections.ArrayList -class ExopackInventoryTransferHandler(private val helper: IRecipeTransferHandlerHelper) : IRecipeTransferHandler { - private val transfer = helper.createUnregisteredRecipeTransferHandler(object : IRecipeTransferInfo { +class ExopackInventoryTransferHandler(private val helper: IRecipeTransferHandlerHelper) : IRecipeTransferHandler> { + private val transfer = helper.createUnregisteredRecipeTransferHandler(object : IRecipeTransferInfo> { override fun getContainerClass(): Class { return ExopackInventoryMenu::class.java } @@ -30,24 +31,24 @@ class ExopackInventoryTransferHandler(private val helper: IRecipeTransferHandler return Optional.empty() } - override fun getRecipeType(): mezz.jei.api.recipe.RecipeType { + override fun getRecipeType(): mezz.jei.api.recipe.RecipeType> { return RecipeTypes.CRAFTING } - override fun canHandle(container: ExopackInventoryMenu, recipe: CraftingRecipe): Boolean { + override fun canHandle(container: ExopackInventoryMenu, recipe: RecipeHolder): Boolean { return true } override fun getRecipeSlots( container: ExopackInventoryMenu, - recipe: CraftingRecipe + recipe: RecipeHolder ): List { return container.craftingSlots } override fun getInventorySlots( container: ExopackInventoryMenu, - recipe: CraftingRecipe + recipe: RecipeHolder ): List { return container.playerInventorySlots } @@ -61,7 +62,7 @@ class ExopackInventoryTransferHandler(private val helper: IRecipeTransferHandler return Optional.empty() } - override fun getRecipeType(): mezz.jei.api.recipe.RecipeType { + override fun getRecipeType(): mezz.jei.api.recipe.RecipeType> { return RecipeTypes.CRAFTING } @@ -88,7 +89,7 @@ class ExopackInventoryTransferHandler(private val helper: IRecipeTransferHandler override fun transferRecipe( container: ExopackInventoryMenu, - recipe: CraftingRecipe, + recipe: RecipeHolder, recipeSlots: IRecipeSlotsView, player: Player, maxTransfer: Boolean, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt index 93fc4db5d..93edbbafd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt @@ -87,9 +87,9 @@ class JEIPlugin : IModPlugin { override fun registerRecipes(registration: IRecipeRegistration) { val level = minecraft.level ?: throw NullPointerException("No ClientLevel. OLOLOLOLOLOLO") - registration.addRecipes(PlatePressRecipeCategory.recipeType, level.recipeManager.getAllRecipesFor(MRecipes.PLATE_PRESS).filter { !it.isIncomplete }) - registration.addRecipes(PainterRecipeCategory.recipeType, level.recipeManager.getAllRecipesFor(MRecipes.PAINTER).filter { !it.isIncomplete }) - registration.addRecipes(MatterEntanglerRecipeCategory.recipeType, level.recipeManager.getAllRecipesFor(MRecipes.MATTER_ENTANGLER).filter { !it.isIncomplete }) + registration.addRecipes(PlatePressRecipeCategory.recipeType, level.recipeManager.getAllRecipesFor(MRecipes.PLATE_PRESS).filter { !it.value.isIncomplete }.map { it.value }) + registration.addRecipes(PainterRecipeCategory.recipeType, level.recipeManager.getAllRecipesFor(MRecipes.PAINTER).filter { !it.value.isIncomplete }.map { it.value }) + registration.addRecipes(MatterEntanglerRecipeCategory.recipeType, level.recipeManager.getAllRecipesFor(MRecipes.MATTER_ENTANGLER).filter { !it.value.isIncomplete }.map { it.value }) } override fun registerRecipeTransferHandlers(registration: IRecipeTransferRegistration) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/ExtendedInventoryHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/ExtendedInventoryHandler.kt index f231b30a0..a950b227e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/ExtendedInventoryHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/ExtendedInventoryHandler.kt @@ -13,15 +13,13 @@ import net.minecraft.world.inventory.InventoryMenu import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items -import net.minecraftforge.network.NetworkEvent +import net.minecraftforge.event.network.CustomPayloadEvent import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.network.MatteryPacket -import ru.dbotthepony.mc.otm.network.packetHandled -import ru.dbotthepony.mc.otm.network.sender import java.util.* import java.util.function.Supplier @@ -226,8 +224,7 @@ class InventoryScrollPacket(val scroll: Int) : MatteryPacket { }.scroll = scroll } - override fun play(context: Supplier) { - context.packetHandled = true + override fun play(context: CustomPayloadEvent.Context) { play(context.sender ?: throw IllegalStateException("Illegal side")) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemFilter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemFilter.kt index da7ab048f..5bd791cb2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemFilter.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ItemFilter.kt @@ -2,23 +2,14 @@ package ru.dbotthepony.mc.otm.container import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.ListTag -import net.minecraft.network.FriendlyByteBuf -import net.minecraft.server.level.ServerPlayer import net.minecraft.tags.TagKey import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraftforge.common.util.INBTSerializable -import net.minecraftforge.network.NetworkEvent -import org.apache.logging.log4j.LogManager -import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.nbt.map -import ru.dbotthepony.mc.otm.menu.MatteryMenu -import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.core.nbt.set -import java.util.Arrays -import java.util.LinkedList +import java.util.* import java.util.function.Consumer -import java.util.function.Supplier class ItemFilter( val size: Int, 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 41d38d12a..bc23bfbce 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -206,8 +206,8 @@ fun FriendlyByteBuf.readItemType(): Item { return ForgeRegistries.ITEMS.getValue(readInt()) ?: Items.AIR } -fun InputStream.readItemType(sizeLimit: NbtAccounter? = null): Item { - return ForgeRegistries.ITEMS.getValue(readVarIntLE(sizeLimit)) ?: Items.AIR +fun InputStream.readItemType(): Item { + return ForgeRegistries.ITEMS.getValue(readVarIntLE()) ?: Items.AIR } operator fun > StateHolder<*, *>.get(property: Property): T { 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 8635e6610..2794c2565 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 @@ -699,10 +699,9 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe fun FriendlyByteBuf.readDecimal() = Decimal.read(this) fun FriendlyByteBuf.writeDecimal(value: Decimal) = value.write(this) -fun InputStream.readDecimal(sizeLimit: NbtAccounter = NbtAccounter(512L)): Decimal { - val size = readVarIntLE(sizeLimit) +fun InputStream.readDecimal(): Decimal { + val size = readVarIntLE() require(size >= 0) { "Negative payload size: $size" } - sizeLimit.accountBytes(size.toLong()) val bytes = ByteArray(size) read(bytes) return Decimal.fromByteArray(bytes) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt index 277b58bf5..f3ff05318 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt @@ -117,13 +117,13 @@ fun CompoundTag.putJson(key: String, json: JsonElement) { putByteArray(key, bytes.array.copyOfRange(0, bytes.length)) } -fun CompoundTag.getJson(key: String, sizeLimit: NbtAccounter = NbtAccounter.UNLIMITED): JsonElement? { +fun CompoundTag.getJson(key: String, sizeLimit: NbtAccounter = NbtAccounter(1 shl 18, 512)): JsonElement? { val bytes = getByteArray(key) if (bytes.isEmpty()) return null - return FastByteArrayInputStream(bytes).readBinaryJson(sizeLimit) + return FastByteArrayInputStream(bytes).readBinaryJson() } fun CompoundTag.getBoolean(index: String, orElse: Boolean): Boolean { 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 053228d31..bd2ae665c 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 @@ -19,7 +19,7 @@ private enum class BinaryElementType(private val predicate: Predicate 0) } }, @@ -56,8 +54,8 @@ private enum class BinaryElementType(private val predicate: Predicate JsonElement): JsonArray { - val count = stream.readVarIntLE(accounter) + protected fun readArray(stream: InputStream, reader: (InputStream) -> JsonElement): JsonArray { + val count = stream.readVarIntLE() if (count == 0) return JsonArray() if (count < 0) throw JsonSyntaxException("Tried to read json array with $count elements in it") return JsonArray(count).also { - for (i in 0 until count) it.add(reader.invoke(stream, accounter)) + for (i in 0 until count) it.add(reader.invoke(stream)) } } abstract fun write(stream: OutputStream, element: JsonElement) - abstract fun read(stream: InputStream, accounter: NbtAccounter): JsonElement + abstract fun read(stream: InputStream): JsonElement companion object { val cached: ImmutableList = ImmutableList.of( NULL, DOUBLE, BOOLEAN, INT, STRING, OBJECT, DOUBLE_ARRAY, INT_ARRAY, BOOLEAN_ARRAY, ARRAY) - val ordered: ImmutableList = ImmutableList.copyOf(values()) } } @@ -208,9 +205,8 @@ fun OutputStream.writeBinaryJson(element: JsonElement) { /** * Reads json in binary form from stream */ -fun InputStream.readBinaryJson(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 KiB */)): JsonElement { - sizeLimit.accountBytes(1L) +fun InputStream.readBinaryJson(): JsonElement { val id = read() - 1 - val reader = BinaryElementType.ordered.getOrNull(id) ?: throw JsonParseException("Unknown element type ${id + 1}") - return reader.read(this, sizeLimit) + val reader = BinaryElementType.entries.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/ByteBufExtensions.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ByteBufExtensions.kt index eaff47fd6..3949f9121 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ByteBufExtensions.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ByteBufExtensions.kt @@ -12,8 +12,8 @@ import net.minecraft.nbt.NbtAccounter import net.minecraft.network.FriendlyByteBuf import net.minecraft.network.chat.Component -fun FriendlyByteBuf.readBinaryJson(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18)): JsonElement { - return ByteBufInputStream(this).readBinaryJson(sizeLimit) +fun FriendlyByteBuf.readBinaryJson(): JsonElement { + return ByteBufInputStream(this).readBinaryJson() } fun FriendlyByteBuf.writeBinaryJson(value: JsonElement) { @@ -25,13 +25,13 @@ fun FriendlyByteBuf.writeBinaryJsonWithCodec(codec: Codec, value: S) { .get().map({ it }, { throw EncoderException("Failed to encode input data: ${it.message()}") })) } -fun FriendlyByteBuf.readBinaryJsonWithCodec(codec: Codec, sizeLimit: NbtAccounter = NbtAccounter(1L shl 18)): S { - return codec.decode(JsonOps.INSTANCE, readBinaryJson(sizeLimit)) +fun FriendlyByteBuf.readBinaryJsonWithCodec(codec: Codec): S { + return codec.decode(JsonOps.INSTANCE, readBinaryJson()) .get().map({ it.first }, { throw DecoderException("Failed to decode data from network: ${it.message()}") }) } -fun FriendlyByteBuf.readBinaryJsonWithCodecIndirect(codec: Codec, sizeLimit: NbtAccounter = NbtAccounter(1L shl 18)): DataResult { - return codec.decode(JsonOps.INSTANCE, readBinaryJson(sizeLimit)).map { it.first } +fun FriendlyByteBuf.readBinaryJsonWithCodecIndirect(codec: Codec): DataResult { + return codec.decode(JsonOps.INSTANCE, readBinaryJson()).map { it.first } } fun FriendlyByteBuf.readBinaryComponent(): Component { 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 ac4fbba42..38c7b6e0a 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 @@ -30,9 +30,9 @@ fun OutputStream.writeNbt(value: CompoundTag) { } } -fun InputStream.readNbt(accounter: NbtAccounter = NbtAccounter(1L shl 18 /* 256 KiB */)): CompoundTag { +fun InputStream.readNbt(): CompoundTag { return try { - NbtIo.read(if (this is DataInputStream) this else DataInputStream(this), accounter) + NbtIo.read(if (this is DataInputStream) this else DataInputStream(this)) } catch (ioexception: IOException) { throw EncoderException(ioexception) } @@ -62,19 +62,16 @@ fun OutputStream.writeItem(itemStack: ItemStack, limitedTag: Boolean = true) { } } -fun InputStream.readItem(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 KiB */)): ItemStack { - sizeLimit.accountBytes(1L) - +fun InputStream.readItem(): ItemStack { if (read() == 0) { return ItemStack.EMPTY } - sizeLimit.accountBytes(9L) val item = (ForgeRegistries.ITEMS as ForgeRegistry).getValue(readInt()) val itemStack = ItemStack(item, readInt()) if (read() != 0) { - itemStack.readShareTag(readNbt(sizeLimit)) + itemStack.readShareTag(readNbt()) } return itemStack @@ -99,7 +96,7 @@ fun OutputStream.writeFluidStack(value: FluidStack) { } } -fun InputStream.readFluidStack(sizeLimit: NbtAccounter = NbtAccounter(1L shl 14 /* 16 KiB */)): FluidStack { +fun InputStream.readFluidStack(): FluidStack { if (read() == 0) { return FluidStack.EMPTY } else { @@ -108,7 +105,7 @@ fun InputStream.readFluidStack(sizeLimit: NbtAccounter = NbtAccounter(1L shl 14 val amount = readInt() if (read() > 0) { - return FluidStack(fluid, amount, readNbt(sizeLimit)) + return FluidStack(fluid, amount, readNbt()) } else { return FluidStack(fluid, amount) } @@ -122,11 +119,10 @@ fun OutputStream.writeBigDecimal(value: BigDecimal) { write(bytes) } -fun InputStream.readBigDecimal(sizeLimit: NbtAccounter = NbtAccounter(512L)): BigDecimal { +fun InputStream.readBigDecimal(): BigDecimal { val scale = readInt() - val size = readVarIntLE(sizeLimit) + val size = readVarIntLE() require(size >= 0) { "Negative payload size: $size" } - sizeLimit.accountBytes(size.toLong() + 4L) val bytes = ByteArray(size) read(bytes) return BigDecimal(BigInteger(bytes), scale) @@ -215,8 +211,7 @@ fun InputStream.readFloat() = Float.fromBits(readInt()) fun OutputStream.writeDouble(value: Double) = writeLong(value.toBits()) fun InputStream.readDouble() = Double.fromBits(readLong()) -fun InputStream.readVarIntLE(sizeLimit: NbtAccounter? = null): Int { - sizeLimit?.accountBytes(1L) +fun InputStream.readVarIntLE(): Int { val readFirst = read() if (readFirst < 0) { @@ -234,7 +229,6 @@ fun InputStream.readVarIntLE(sizeLimit: NbtAccounter? = null): Int { while (nextBit != 0) { result = result or (read shl i) - sizeLimit?.accountBytes(1L) read = read() if (read < 0) { @@ -314,10 +308,9 @@ fun OutputStream.writeVarLongLE(value: Long) { } } -fun InputStream.readBinaryString(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 KiB */)): String { +fun InputStream.readBinaryString(): String { val size = readVarIntLE() require(size >= 0) { "Negative payload size: $size" } - sizeLimit.accountBytes(size.toLong()) val bytes = ByteArray(size) read(bytes) return bytes.decodeToString() @@ -329,8 +322,8 @@ fun OutputStream.writeBinaryString(input: String) { write(bytes) } -fun InputStream.readResourceLocation(sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 KiB */)): ResourceLocation { - return ResourceLocation(readBinaryString(sizeLimit), readBinaryString(sizeLimit)) +fun InputStream.readResourceLocation(): ResourceLocation { + return ResourceLocation(readBinaryString(), readBinaryString()) } fun OutputStream.writeResourceLocation(value: ResourceLocation) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt index b7b55910e..961847d1e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt @@ -32,7 +32,7 @@ import kotlin.reflect.KClass * Also provides [copy] and [compare] methods */ interface IStreamCodec { - fun read(stream: DataInputStream, sizeLimit: NbtAccounter = NbtAccounter(1L shl 18 /* 256 KiB */)): V + fun read(stream: DataInputStream): V fun write(stream: DataOutputStream, value: V) /** @@ -51,7 +51,7 @@ interface IStreamCodec { } class StreamCodec( - private val reader: (stream: DataInputStream, sizeLimit: NbtAccounter) -> V, + private val reader: (stream: DataInputStream) -> V, private val writer: (stream: DataOutputStream, value: V) -> Unit, private val copier: ((value: V) -> V) = { it }, private val comparator: ((a: V, b: V) -> Boolean) = { a, b -> a == b } @@ -62,12 +62,11 @@ class StreamCodec( writer: (stream: DataOutputStream, value: V) -> Unit, copier: ((value: V) -> V) = { it }, comparator: ((a: V, b: V) -> Boolean) = { a, b -> a == b } - ) : this({ stream, sizeLimit -> sizeLimit.accountBytes(payloadSize); reader.invoke(stream) }, writer, copier, comparator) + ) : this({ stream -> reader.invoke(stream) }, writer, copier, comparator) val nullable = object : IStreamCodec { - override fun read(stream: DataInputStream, sizeLimit: NbtAccounter): V? { - sizeLimit.accountBytes(1L) - return if (stream.read() == 0) null else reader.invoke(stream, sizeLimit) + override fun read(stream: DataInputStream): V? { + return if (stream.read() == 0) null else reader.invoke(stream) } override fun write(stream: DataOutputStream, value: V?) { @@ -88,8 +87,8 @@ class StreamCodec( } } - override fun read(stream: DataInputStream, sizeLimit: NbtAccounter): V { - return reader.invoke(stream, sizeLimit) + override fun read(stream: DataInputStream): V { + return reader.invoke(stream) } override fun write(stream: DataOutputStream, value: V) { @@ -106,8 +105,8 @@ class StreamCodec( } class CollectionStreamCodec>(val elementCodec: IStreamCodec, val collectionFactory: (Int) -> C) : IStreamCodec { - override fun read(stream: DataInputStream, sizeLimit: NbtAccounter): C { - val size = stream.readVarIntLE(sizeLimit) + override fun read(stream: DataInputStream): C { + val size = stream.readVarIntLE() if (size <= 0) { return collectionFactory.invoke(0) @@ -116,7 +115,7 @@ class CollectionStreamCodec>(val elementCodec: IStre val collection = collectionFactory.invoke(size) for (i in 0 until size) { - collection.add(elementCodec.read(stream, sizeLimit)) + collection.add(elementCodec.read(stream)) } return collection @@ -134,7 +133,7 @@ class CollectionStreamCodec>(val elementCodec: IStre } } -val NullValueCodec = StreamCodec({ _, _ -> null }, { _, _ -> }) +val NullValueCodec = StreamCodec({ _ -> null }, { _, _ -> }) val BooleanValueCodec = StreamCodec(DataInputStream::readBoolean, 1L, DataOutputStream::writeBoolean) { a, b -> a == b } val ByteValueCodec = StreamCodec(DataInputStream::readByte, 1L, { s, v -> s.writeByte(v.toInt()) }) { a, b -> a == b } val ShortValueCodec = StreamCodec(DataInputStream::readShort, 2L, { s, v -> s.writeShort(v.toInt()) }) { a, b -> a == b } @@ -147,18 +146,18 @@ val FluidStackValueCodec = StreamCodec(DataInputStream::readFluidStack, DataOutp val ItemValueCodec = StreamCodec(DataInputStream::readItemType, DataOutputStream::writeItemType) { a, b -> a === b } val DecimalValueCodec = StreamCodec(DataInputStream::readDecimal, DataOutputStream::writeDecimal) val BigDecimalValueCodec = StreamCodec(DataInputStream::readBigDecimal, DataOutputStream::writeBigDecimal) -val UUIDValueCodec = StreamCodec({ s, a -> a.accountBytes(8L); UUID(s.readLong(), s.readLong()) }, { s, v -> s.writeLong(v.mostSignificantBits); s.writeLong(v.leastSignificantBits) }) +val UUIDValueCodec = StreamCodec({ s -> UUID(s.readLong(), s.readLong()) }, { s, v -> s.writeLong(v.mostSignificantBits); s.writeLong(v.leastSignificantBits) }) val VarIntValueCodec = StreamCodec(DataInputStream::readVarIntLE, DataOutputStream::writeVarIntLE) { a, b -> a == b } val VarLongValueCodec = StreamCodec(DataInputStream::readVarLongLE, DataOutputStream::writeVarLongLE) { a, b -> a == b } val BinaryStringCodec = StreamCodec(DataInputStream::readBinaryString, DataOutputStream::writeBinaryString) val ResourceLocationValueCodec = StreamCodec(DataInputStream::readResourceLocation, DataOutputStream::writeResourceLocation) val RGBCodec: StreamCodec = StreamCodec( - { s, a -> a.accountBytes(12L); RGBAColor(s.readFloat(), s.readFloat(), s.readFloat()) }, + { s -> RGBAColor(s.readFloat(), s.readFloat(), s.readFloat()) }, { s, v -> s.writeFloat(v.red); s.writeFloat(v.green); s.writeFloat(v.blue) }) val RGBACodec: StreamCodec = StreamCodec( - { s, a -> a.accountBytes(16L); RGBAColor(s.readFloat(), s.readFloat(), s.readFloat(), s.readFloat()) }, + { s -> RGBAColor(s.readFloat(), s.readFloat(), s.readFloat(), s.readFloat()) }, { s, v -> s.writeFloat(v.red); s.writeFloat(v.green); s.writeFloat(v.blue); s.writeFloat(v.alpha) }) class EnumValueCodec>(clazz: Class) : IStreamCodec, Codec { @@ -168,8 +167,8 @@ class EnumValueCodec>(clazz: Class) : IStreamCodec, Codec< for (v in values) put(v.name, v) } - override fun read(stream: DataInputStream, sizeLimit: NbtAccounter): V { - val id = stream.readVarIntLE(sizeLimit) + override fun read(stream: DataInputStream): V { + val id = stream.readVarIntLE() return values.getOrNull(id) ?: throw NoSuchElementException("No such enum with index $id") } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt index 3ddf52bd2..b32702611 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt @@ -8,6 +8,9 @@ import com.mojang.serialization.Codec import com.mojang.serialization.DataResult import com.mojang.serialization.DynamicOps import com.mojang.serialization.JsonOps +import io.netty.buffer.ByteBuf +import io.netty.buffer.Unpooled +import net.minecraft.advancements.AdvancementHolder import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation @@ -21,7 +24,15 @@ import ru.dbotthepony.mc.otm.core.util.readBinaryJsonWithCodecIndirect import ru.dbotthepony.mc.otm.core.util.writeBinaryJsonWithCodec import kotlin.collections.ArrayDeque import kotlin.concurrent.getOrSet +import kotlin.reflect.KProperty +/** + * 1.20.2: Mojang FINALLY moved json IO of recipes to codecs + * + * ...but they forgot to do the same for Networking them, Ingredient does not have codec for network. + * + * Mojang.... Mojang never changes. + */ class Codec2RecipeSerializer>( val empty: S?, codec: (Codec2RecipeSerializer.Context) -> Codec, @@ -29,15 +40,45 @@ class Codec2RecipeSerializer>( constructor(supplier: (Codec2RecipeSerializer.Context) -> Codec) : this(null, supplier) private class CurrentContext { - val idStack = ArrayDeque() var isNetwork = 0 } inner class Context { - val id: ResourceLocation - get() = checkNotNull(context.idStack.lastOrNull()) { "Not currently deserializing recipe" } - val ingredients: Codec get() = ActualIngredientCodec + + fun

> wrap(serializer: RecipeSerializer

): Codec

{ + return object : Codec

{ + override fun encode(input: P, ops: DynamicOps, prefix: T): DataResult { + if (context.isNetwork > 0) { + val parent = Unpooled.buffer() + val buff = FriendlyByteBuf(parent) + serializer.toNetwork(buff, input) + return DataResult.success(ops.createByteList(parent.nioBuffer())) + } else { + return serializer.codec().encode(input, ops, prefix) + } + } + + override fun decode(ops: DynamicOps, input: T): DataResult> { + if (context.isNetwork > 0) { + return ops.getByteBuffer(input).flatMap { + val parent = Unpooled.buffer() + val buff = FriendlyByteBuf(parent) + parent.writeBytes(it) + parent.setIndex(0, 0) + val read = serializer.fromNetwork(buff) + + if (read == null) + DataResult.error { "Unable to read parent recipe from network" } + else + DataResult.success(Pair(read, ops.empty())) + } + } else { + return serializer.codec().decode(ops, input) + } + } + } + } } private val codec = codec.invoke(Context()) @@ -56,45 +97,30 @@ class Codec2RecipeSerializer>( } } - override fun fromJson(id: ResourceLocation, data: JsonObject): S { - try { - context.idStack.addLast(id) - - return decode(JsonOps.INSTANCE, data).get().map( - { it.first }, - { empty ?: throw JsonSyntaxException("Failed to deserialize recipe from JSON: ${it.message()}") } - ) - } finally { - context.idStack.removeLast() - } + override fun codec(): Codec { + return this } - override fun fromNetwork(id: ResourceLocation, data: FriendlyByteBuf): S? { + override fun fromNetwork(data: FriendlyByteBuf): S? { try { - context.idStack.addLast(id) context.isNetwork++ - return data.readBinaryJsonWithCodecIndirect(this) - .resultOrPartial { LOGGER.error("Failed to read recipe $id from network: $it") }.orElse(null) + .resultOrPartial { LOGGER.error("Failed to read recipe from network: $it") }.orElse(null) } finally { context.isNetwork-- - context.idStack.removeLast() } } override fun toNetwork(data: FriendlyByteBuf, recipe: S) { try { - context.idStack.addLast(recipe.id) context.isNetwork++ - data.writeBinaryJsonWithCodec(this, recipe) } finally { context.isNetwork-- - context.idStack.removeLast() } } - fun toFinished(recipe: S): FinishedRecipe { + fun toFinished(recipe: S, id: ResourceLocation): FinishedRecipe { return object : FinishedRecipe { override fun serializeRecipeData(p_125967_: JsonObject) { encode(recipe, JsonOps.INSTANCE, p_125967_).get().map( @@ -111,19 +137,15 @@ class Codec2RecipeSerializer>( ) } - override fun getId(): ResourceLocation { - return recipe.id + override fun id(): ResourceLocation { + return id } - override fun getType(): RecipeSerializer<*> { + override fun type(): RecipeSerializer<*> { return this@Codec2RecipeSerializer } - override fun serializeAdvancement(): JsonObject? { - return null - } - - override fun getAdvancementId(): ResourceLocation? { + override fun advancement(): AdvancementHolder? { return null } } @@ -134,7 +156,7 @@ class Codec2RecipeSerializer>( return if (context.isNetwork > 0) { networkIngredientCodec.encode(input, ops, prefix) } else { - IngredientCodec.encode(input, ops, prefix) + Ingredient.CODEC.encode(input, ops, prefix) } } @@ -142,7 +164,7 @@ class Codec2RecipeSerializer>( return if (context.isNetwork > 0) { networkIngredientCodec.decode(ops, input) } else { - IngredientCodec.decode(ops, input) + Ingredient.CODEC.decode(ops, input) } } } @@ -156,8 +178,14 @@ class Codec2RecipeSerializer>( * since RecipeSerializers are expected to be stateless. [Codec2RecipeSerializer], however, is stateful (threading PoV). * To make it stateless, [ThreadLocal] is used. */ - private val contextHolder = ThreadLocal() - private val context: CurrentContext - get() = contextHolder.getOrSet { CurrentContext() } + private val context by object : ThreadLocal() { + override fun initialValue(): CurrentContext { + return CurrentContext() + } + } } } + +private operator fun ThreadLocal.getValue(companion: Codec2RecipeSerializer.Companion, property: KProperty<*>): T { + return get() +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt deleted file mode 100644 index 10d9550bd..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt +++ /dev/null @@ -1,37 +0,0 @@ -package ru.dbotthepony.mc.otm.data - -import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonObject -import com.google.gson.JsonSerializationContext -import com.google.gson.JsonSyntaxException -import com.mojang.serialization.Codec -import net.minecraft.world.level.storage.loot.Serializer -import ru.dbotthepony.mc.otm.core.fromJsonStrict -import ru.dbotthepony.mc.otm.core.set -import ru.dbotthepony.mc.otm.core.toJsonStrict - -class Codec2Serializer(val codec: Codec, val embed: Boolean = true) : Serializer { - override fun serialize(data: JsonObject, value: T, context: JsonSerializationContext) { - if (embed) { - val result = codec.toJsonStrict(value, data) - - if (result !is JsonObject) { - throw RuntimeException("Expected JsonObject from codec, got ${result::class.qualifiedName}") - } - - val keys = ArrayList(data.keySet()) - for (k in keys) data.remove(k) - for ((k, v) in result.entrySet()) data[k] = v - } else { - data["value"] = codec.toJsonStrict(value) - } - } - - override fun deserialize(data: JsonObject, context: JsonDeserializationContext): T { - if (embed) { - return codec.fromJsonStrict(data) - } else { - return codec.fromJsonStrict(data["value"] ?: throw JsonSyntaxException("Missing 'value' element")) - } - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2TriggerSerializer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2TriggerSerializer.kt new file mode 100644 index 000000000..9f4319439 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2TriggerSerializer.kt @@ -0,0 +1,100 @@ +package ru.dbotthepony.mc.otm.data + +import com.google.gson.JsonObject +import com.mojang.datafixers.util.Pair +import com.mojang.serialization.Codec +import com.mojang.serialization.DataResult +import com.mojang.serialization.DynamicOps +import com.mojang.serialization.JsonOps +import com.mojang.serialization.MapCodec +import com.mojang.serialization.MapLike +import com.mojang.serialization.RecordBuilder +import net.minecraft.advancements.critereon.ContextAwarePredicate +import net.minecraft.advancements.critereon.DeserializationContext +import net.minecraft.advancements.critereon.EntityPredicate +import ru.dbotthepony.mc.otm.core.fromJsonStrict +import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.toJsonStrict +import java.util.Optional +import java.util.stream.Stream + +class Codec2TriggerSerializer(supplier: (Codec2TriggerSerializer.Context) -> Codec) : Codec { + private val codec = supplier.invoke(Context()) + + override fun encode(input: S, ops: DynamicOps, prefix: T): DataResult { + return codec.encode(input, ops, prefix) + } + + override fun decode(ops: DynamicOps, input: T): DataResult> { + return codec.decode(ops, input) + } + + fun fromJson(element: JsonObject, player: Optional, context: DeserializationContext): S { + try { + Companion.context.get().addLast(ThreadContext(player, context)) + return codec.fromJsonStrict(element) + } finally { + Companion.context.get().removeLast() + } + } + + fun toJson(value: S): JsonObject { + return codec.toJsonStrict(value) as JsonObject + } + + inner class Context { + val playerPredicate: MapCodec> + get() = CAPPredicate + + val awareContextCodec: Codec + get() = ActualCAPPredicate + } + + private data class ThreadContext(val player: Optional, val context: DeserializationContext) + + private object ActualCAPPredicate : Codec { + override fun encode(input: ContextAwarePredicate, ops: DynamicOps, prefix: T): DataResult { + return try { + DataResult.success(JsonOps.INSTANCE.convertTo(ops, input.toJson())) + } catch (err: Exception) { + DataResult.error { "Failed to serialize ContextAwarePredicate: " + err.message } + } + } + + override fun decode(ops: DynamicOps, input: T): DataResult> { + val context = context.get().lastOrNull() ?: return DataResult.error { "Not current deserializing trigger instance" } + + return try { + DataResult.success(Pair(EntityPredicate.fromJson(JsonObject().also { it["a"] = ops.convertTo(JsonOps.INSTANCE, input) }, "a", context.context).get(), ops.empty())) + } catch (err: Exception) { + DataResult.error { "Failed to deserialize ContextAwarePredicate: " + err.message } + } + } + } + + private object CAPPredicate : MapCodec>() { + override fun keys(ops: DynamicOps): Stream { + return Stream.of(ops.createString("player")) + } + + override fun decode(ops: DynamicOps, input: MapLike): DataResult> { + return DataResult.success(context.get().lastOrNull()?.player ?: return DataResult.error { "Not currently deserializing trigger instance" }) + } + + override fun encode(input: Optional, ops: DynamicOps, prefix: RecordBuilder): RecordBuilder { + if (input.isPresent) { + return prefix.add("player", JsonOps.INSTANCE.convertTo(ops, input.get().toJson())) + } else { + return prefix + } + } + } + + companion object { + private val context = object : ThreadLocal>() { + override fun initialValue(): ArrayDeque { + return ArrayDeque() + } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codecs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codecs.kt index ef688c49c..6b4f17f3b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codecs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codecs.kt @@ -1,9 +1,30 @@ package ru.dbotthepony.mc.otm.data import com.mojang.serialization.Codec +import com.mojang.serialization.Dynamic +import com.mojang.serialization.JsonOps import com.mojang.serialization.codecs.RecordCodecBuilder +import net.minecraft.advancements.critereon.DamagePredicate +import net.minecraft.advancements.critereon.DamageSourcePredicate +import net.minecraft.advancements.critereon.EntityPredicate +import net.minecraft.advancements.critereon.MinMaxBounds import kotlin.reflect.KProperty1 +private val dealtReceived: Codec> = RecordCodecBuilder.create { + it.group( + MinMaxBounds.Doubles.CODEC.fieldOf("dealt").forGetter { it.first }, + MinMaxBounds.Doubles.CODEC.fieldOf("taken").forGetter { it.second }, + ).apply(it, ::Pair) +} + +val DamagePredicateCodec: Codec = RecordCodecBuilder.create { + it.group( + dealtReceived.fieldOf("damage").forGetter { it.dealtDamage to it.takenDamage }, + Codec.BOOL.optionalFieldOf("blocked").forGetter { it.blocked }, + EntityPredicate.CODEC.optionalFieldOf("source_entity").forGetter { it.sourceEntity }, + DamageSourcePredicate.CODEC.optionalFieldOf("type").forGetter { it.type }, + ).apply(it) { damage, blocked, source, type -> DamagePredicate(damage.first, damage.second, source, blocked, type) } +} fun simpleCodec(factory: (T1) -> V, field1: KProperty1, codec1: Codec): Codec { return RecordCodecBuilder.create { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientCodec.kt deleted file mode 100644 index 27c18ade8..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientCodec.kt +++ /dev/null @@ -1,23 +0,0 @@ -package ru.dbotthepony.mc.otm.data - -import com.google.gson.JsonSyntaxException -import com.mojang.datafixers.util.Pair -import com.mojang.serialization.Codec -import com.mojang.serialization.DataResult -import com.mojang.serialization.DynamicOps -import com.mojang.serialization.JsonOps -import net.minecraft.world.item.crafting.Ingredient - -object IngredientCodec : Codec { - override fun encode(input: Ingredient, ops: DynamicOps, prefix: T): DataResult { - return DataResult.success(JsonOps.INSTANCE.convertTo(ops, input.toJson())) - } - - override fun decode(ops: DynamicOps, input: T): DataResult> { - try { - return DataResult.success(Pair(Ingredient.fromJson(ops.convertTo(JsonOps.INSTANCE, input)), ops.empty())) - } catch (err: JsonSyntaxException) { - return DataResult.error { "Error decoding Ingredient: ${err.message}" } - } - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/ItemPredicateCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/ItemPredicateCodec.kt deleted file mode 100644 index b37fb23a9..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/ItemPredicateCodec.kt +++ /dev/null @@ -1,27 +0,0 @@ -package ru.dbotthepony.mc.otm.data - -import com.google.gson.JsonObject -import com.google.gson.JsonParseException -import com.google.gson.JsonSyntaxException -import com.mojang.datafixers.util.Pair -import com.mojang.serialization.Codec -import com.mojang.serialization.DataResult -import com.mojang.serialization.DynamicOps -import com.mojang.serialization.JsonOps -import net.minecraft.advancements.critereon.ItemPredicate - -object ItemPredicateCodec : Codec { - override fun encode(input: ItemPredicate, ops: DynamicOps, prefix: T): DataResult { - return DataResult.success(JsonOps.INSTANCE.convertTo(ops, input.serializeToJson().let { if (it is JsonObject) it.getRidOfNulls() else it })) - } - - override fun decode(ops: DynamicOps, input: T): DataResult> { - return try { - DataResult.success(Pair(ItemPredicate.fromJson(ops.convertTo(JsonOps.INSTANCE, input)), ops.empty())) - } catch (err: JsonSyntaxException) { - DataResult.error { "Failed to deserialize ItemPredicate: ${err.message}" } - } catch (err: JsonParseException) { - DataResult.error { "Failed to deserialize ItemPredicate: ${err.message}" } - } - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceCondition.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceCondition.kt index 4380d963a..4f8316e44 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceCondition.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceCondition.kt @@ -5,7 +5,6 @@ import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.world.level.storage.loot.LootContext import net.minecraft.world.level.storage.loot.predicates.LootItemCondition import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType -import ru.dbotthepony.mc.otm.data.Codec2Serializer import ru.dbotthepony.mc.otm.registry.MLootItemConditions /** @@ -29,6 +28,12 @@ data class ChanceCondition(val chance: Double) : LootItemCondition, LootItemCond } companion object { - val SERIALIZER = Codec2Serializer(RecordCodecBuilder.create { it.group(Codec.doubleRange(0.0, 1.0).fieldOf("chance").forGetter(ChanceCondition::chance)).apply(it, ::ChanceCondition) }) + val CODEC: Codec by lazy { + RecordCodecBuilder.create { + it.group( + Codec.doubleRange(0.0, 1.0).fieldOf("chance").forGetter(ChanceCondition::chance) + ).apply(it, ::ChanceCondition) + } + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceWithPlaytimeCondition.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceWithPlaytimeCondition.kt index 2a2b19d08..92e501c6d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceWithPlaytimeCondition.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ChanceWithPlaytimeCondition.kt @@ -7,7 +7,6 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParams import net.minecraft.world.level.storage.loot.predicates.LootItemCondition import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType import ru.dbotthepony.mc.otm.capability.matteryPlayer -import ru.dbotthepony.mc.otm.data.Codec2Serializer import ru.dbotthepony.mc.otm.data.get import ru.dbotthepony.mc.otm.registry.MLootItemConditions @@ -49,7 +48,7 @@ data class ChanceWithPlaytimeCondition( } companion object { - val SERIALIZER = Codec2Serializer( + val CODEC: Codec by lazy { RecordCodecBuilder.create { it.group( Codec.INT.optionalFieldOf("minPlaytime", 0).forGetter(ChanceWithPlaytimeCondition::minPlaytime), @@ -58,6 +57,6 @@ data class ChanceWithPlaytimeCondition( Codec.DOUBLE.fieldOf("maxProbability").forGetter(ChanceWithPlaytimeCondition::maxProbability), ).apply(it, ::ChanceWithPlaytimeCondition) } - ) + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/HasExoPackCondition.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/HasExoPackCondition.kt index 9f1ba1258..3fd16037f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/HasExoPackCondition.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/HasExoPackCondition.kt @@ -1,10 +1,6 @@ package ru.dbotthepony.mc.otm.data.condition -import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonObject -import com.google.gson.JsonSerializationContext import net.minecraft.world.level.storage.loot.LootContext -import net.minecraft.world.level.storage.loot.Serializer import net.minecraft.world.level.storage.loot.parameters.LootContextParams import net.minecraft.world.level.storage.loot.predicates.InvertedLootItemCondition import net.minecraft.world.level.storage.loot.predicates.LootItemCondition @@ -13,7 +9,7 @@ import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.data.get import ru.dbotthepony.mc.otm.registry.MLootItemConditions -object HasExoPackCondition : LootItemCondition, Serializer, LootItemCondition.Builder { +object HasExoPackCondition : LootItemCondition, LootItemCondition.Builder { override fun test(t: LootContext): Boolean { t[LootContextParams.LAST_DAMAGE_PLAYER]?.matteryPlayer?.let { return it.hasExopack @@ -26,13 +22,6 @@ object HasExoPackCondition : LootItemCondition, Serializer, return MLootItemConditions.HAS_EXOPACK } - override fun serialize(p_79325_: JsonObject, p_79326_: HasExoPackCondition, p_79327_: JsonSerializationContext) { - } - - override fun deserialize(p_79323_: JsonObject, p_79324_: JsonDeserializationContext): HasExoPackCondition { - return this - } - override fun build(): LootItemCondition { return this } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ItemInInventoryCondition.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ItemInInventoryCondition.kt index a0bf6ca5b..f25f12e7d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ItemInInventoryCondition.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/ItemInInventoryCondition.kt @@ -9,7 +9,6 @@ import net.minecraft.world.level.storage.loot.predicates.LootItemCondition import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType import ru.dbotthepony.mc.otm.capability.items import ru.dbotthepony.mc.otm.core.collect.filter -import ru.dbotthepony.mc.otm.data.Codec2Serializer import ru.dbotthepony.mc.otm.data.get import ru.dbotthepony.mc.otm.registry.MLootItemConditions @@ -58,7 +57,7 @@ data class ItemInInventoryCondition( } companion object { - val SERIALIZER = Codec2Serializer( + val CODEC: Codec by lazy { RecordCodecBuilder.create { it.group( ItemStack.CODEC.fieldOf("item").forGetter(ItemInInventoryCondition::item), @@ -67,6 +66,6 @@ data class ItemInInventoryCondition( Codec.BOOL.optionalFieldOf("matchCosmetics", false).forGetter(ItemInInventoryCondition::matchCosmetics), ).apply(it, ::ItemInInventoryCondition) } - ) + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/KilledByRealPlayer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/KilledByRealPlayer.kt index d4354c2a7..281edcf4a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/KilledByRealPlayer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/KilledByRealPlayer.kt @@ -1,10 +1,6 @@ package ru.dbotthepony.mc.otm.data.condition -import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonObject -import com.google.gson.JsonSerializationContext import net.minecraft.world.level.storage.loot.LootContext -import net.minecraft.world.level.storage.loot.Serializer import net.minecraft.world.level.storage.loot.parameters.LootContextParams import net.minecraft.world.level.storage.loot.predicates.InvertedLootItemCondition import net.minecraft.world.level.storage.loot.predicates.LootItemCondition @@ -13,7 +9,7 @@ import net.minecraftforge.common.util.FakePlayer import ru.dbotthepony.mc.otm.data.get import ru.dbotthepony.mc.otm.registry.MLootItemConditions -object KilledByRealPlayer : LootItemCondition, Serializer, LootItemCondition.Builder { +object KilledByRealPlayer : LootItemCondition, LootItemCondition.Builder { override fun test(t: LootContext): Boolean { return t.hasParam(LootContextParams.LAST_DAMAGE_PLAYER) && t[LootContextParams.LAST_DAMAGE_PLAYER] !is FakePlayer } @@ -22,13 +18,6 @@ object KilledByRealPlayer : LootItemCondition, Serializer, L return MLootItemConditions.KILLED_BY_REAL_PLAYER } - override fun serialize(p_79325_: JsonObject, p_79326_: KilledByRealPlayer, p_79327_: JsonSerializationContext) { - } - - override fun deserialize(p_79323_: JsonObject, p_79324_: JsonDeserializationContext): KilledByRealPlayer { - return this - } - override fun build(): LootItemCondition { return this } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/KilledByRealPlayerOrIndirectly.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/KilledByRealPlayerOrIndirectly.kt index df3d9dd14..7fe2d7340 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/KilledByRealPlayerOrIndirectly.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/KilledByRealPlayerOrIndirectly.kt @@ -1,11 +1,7 @@ package ru.dbotthepony.mc.otm.data.condition -import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonObject -import com.google.gson.JsonSerializationContext import net.minecraft.world.entity.OwnableEntity import net.minecraft.world.level.storage.loot.LootContext -import net.minecraft.world.level.storage.loot.Serializer import net.minecraft.world.level.storage.loot.parameters.LootContextParams import net.minecraft.world.level.storage.loot.predicates.InvertedLootItemCondition import net.minecraft.world.level.storage.loot.predicates.LootItemCondition @@ -15,7 +11,7 @@ import ru.dbotthepony.mc.otm.NULLABLE_MINECRAFT_SERVER import ru.dbotthepony.mc.otm.data.get import ru.dbotthepony.mc.otm.registry.MLootItemConditions -object KilledByRealPlayerOrIndirectly : LootItemCondition, Serializer, LootItemCondition.Builder { +object KilledByRealPlayerOrIndirectly : LootItemCondition, LootItemCondition.Builder { override fun test(t: LootContext): Boolean { if (t.hasParam(LootContextParams.LAST_DAMAGE_PLAYER) && t[LootContextParams.LAST_DAMAGE_PLAYER] !is FakePlayer) { return true @@ -43,13 +39,6 @@ object KilledByRealPlayerOrIndirectly : LootItemCondition, Serializer = Stream.empty()) : LootItemFunction, LootItemFunction.Builder { @@ -77,20 +72,16 @@ class CopyTileNbtFunction(filter: Stream = Stream.empty()) : LootIte return this } - companion object : Serializer { - override fun serialize( - pJson: JsonObject, - pValue: CopyTileNbtFunction, - pSerializationContext: JsonSerializationContext - ) { - pJson["filter"] = JsonArray().also { for (v in pValue.filter) it.add(v) } - } - - override fun deserialize( - pJson: JsonObject, - pSerializationContext: JsonDeserializationContext - ): CopyTileNbtFunction { - return CopyTileNbtFunction((pJson["filter"] as? JsonArray)?.stream()?.filter { it is JsonPrimitive }?.map { it.asString!! } ?: Stream.empty()) + companion object { + val CODEC: Codec by lazy { + RecordCodecBuilder.create { + it.group( + Codec.STRING.listOf() + .optionalFieldOf("filter") + .xmap({ it.orElseGet { listOf() } }, { if (it.isEmpty()) Optional.empty() else Optional.of(it) }) + .forGetter(CopyTileNbtFunction::filter), + ).apply(it, ::CopyTileNbtFunction) + } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt index 1b473af22..99556a944 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt @@ -1,24 +1,16 @@ package ru.dbotthepony.mc.otm.data.loot import com.google.common.collect.ImmutableList -import com.google.gson.* import com.mojang.serialization.Codec -import com.mojang.serialization.DataResult -import com.mojang.serialization.Dynamic -import com.mojang.serialization.JsonOps import com.mojang.serialization.codecs.RecordCodecBuilder import it.unimi.dsi.fastutil.objects.ObjectArrayList -import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.ItemStack -import net.minecraft.world.level.storage.loot.Deserializers import net.minecraft.world.level.storage.loot.LootContext import net.minecraft.world.level.storage.loot.LootPool import net.minecraft.world.level.storage.loot.predicates.LootItemCondition -import net.minecraftforge.common.ForgeHooks import net.minecraftforge.common.loot.IGlobalLootModifier import net.minecraftforge.common.loot.LootModifier -import java.util.Arrays -import java.util.Deque +import java.util.* import java.util.stream.Stream class LootPoolAppender(conditions: Array, pools: Stream) : LootModifier(conditions) { @@ -39,53 +31,11 @@ class LootPoolAppender(conditions: Array, pools: Stream> - - private val forgeHooksLootContext by lazy { - val field = ForgeHooks::class.java.getDeclaredField("lootContext") - field.isAccessible = true - field - } - - private val lootTableContextConstructor by lazy { - val clazz = ForgeHooks::class.java.declaredClasses.firstOrNull { it.name.contains("LootTableContext") } ?: throw NoSuchElementException("Unable to find ForgeHooks\$LootTableContext!") - val constructor = clazz.getDeclaredConstructor(ResourceLocation::class.java, Boolean::class.java) - constructor.isAccessible = true - constructor - } - - init { - val serializer = Deserializers.createLootTableSerializer().create() - val notExistingLocation = ResourceLocation("null", "null") - - lootPoolCodec = Codec.list(Codec.PASSTHROUGH.flatXmap({ - val dequeueHolder = forgeHooksLootContext.get(null) as ThreadLocal> - val deque = dequeueHolder.get() ?: java.util.ArrayDeque() - dequeueHolder.set(deque) - - try { - deque.push(lootTableContextConstructor.newInstance(notExistingLocation, true)) - DataResult.success(serializer.fromJson(it.convert(JsonOps.INSTANCE).value, LootPool::class.java)) - } catch(err: JsonSyntaxException) { - DataResult.error { err.message } - } finally { - deque.pop() - } - }, { - try { - DataResult.success(Dynamic(JsonOps.INSTANCE, serializer.toJsonTree(it))) - } catch(err: JsonSyntaxException) { - DataResult.error { err.message } - } - })) - } - val CODEC: Codec = RecordCodecBuilder.create { codecStart(it).and( - lootPoolCodec.fieldOf("pools").forGetter(LootPoolAppender::pools) + LootPool.CODEC.listOf().fieldOf("pools").forGetter(LootPoolAppender::pools) ).apply(it, ::LootPoolAppender) } } 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 fdbfa0c23..7875dbb13 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt @@ -107,7 +107,7 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6 actionResult.result } else { val state = level.getBlockState(hitPos) - val placePos = if (state.block is LiquidBlockContainer && (state.block as LiquidBlockContainer).canPlaceLiquid(level, hitPos, state, fluid.fluid)) hitPos else nextPos + val placePos = if (state.block is LiquidBlockContainer && (state.block as LiquidBlockContainer).canPlaceLiquid(player, level, hitPos, state, fluid.fluid)) hitPos else nextPos val actionResult = FluidUtil.tryPlaceFluid(player, level, hand, placePos, targetItem, fluid) if (!actionResult.isSuccess) return InteractionResultHolder.pass(item) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MinecartCargoCrateItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MinecartCargoCrateItem.kt index 977ea270d..9df929a39 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MinecartCargoCrateItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MinecartCargoCrateItem.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.mc.otm.item -import net.minecraft.core.BlockSource import net.minecraft.core.Direction +import net.minecraft.core.dispenser.BlockSource import net.minecraft.core.dispenser.DefaultDispenseItemBehavior import net.minecraft.core.dispenser.DispenseItemBehavior import net.minecraft.tags.BlockTags @@ -67,11 +67,11 @@ class MinecartCargoCrateItem(val color: DyeColor?) : Item(Properties().stacksTo( private val default = DefaultDispenseItemBehavior() override fun dispense(blockSource: BlockSource, itemStack: ItemStack): ItemStack { - val direction = blockSource.blockState.getValue(DispenserBlock.FACING) + val direction = blockSource.state.getValue(DispenserBlock.FACING) val level: Level = blockSource.level - val x = blockSource.x() + direction.stepX.toDouble() * 1.125 - val y = floor(blockSource.y()) + direction.stepY.toDouble() - val z = blockSource.z() + direction.stepZ.toDouble() * 1.125 + val x = blockSource.pos.x + direction.stepX.toDouble() * 1.125 + val y = blockSource.pos.y + direction.stepY.toDouble() + val z = blockSource.pos.z + direction.stepZ.toDouble() * 1.125 val blockpos = blockSource.pos.relative(direction) val blockstate = level.getBlockState(blockpos) val railshape = diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralBatteryItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralBatteryItem.kt index 19445751b..1eb81c524 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralBatteryItem.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.item +import com.mojang.serialization.Codec import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.ChatFormatting import net.minecraft.nbt.CompoundTag @@ -23,7 +24,6 @@ import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.set import ru.dbotthepony.mc.otm.core.nbt.mapPresent import ru.dbotthepony.mc.otm.core.tagNotNull -import ru.dbotthepony.mc.otm.data.Codec2Serializer import ru.dbotthepony.mc.otm.data.DecimalProvider import ru.dbotthepony.mc.otm.registry.MItemFunctionTypes import java.util.Optional @@ -119,17 +119,15 @@ class ProceduralBatteryItem : Item(Properties().stacksTo(1)) { } companion object { - val SERIALIZER by lazy { - Codec2Serializer( - RecordCodecBuilder.create { - it.group( - DecimalProvider.CODEC.fieldOf("maxBatteryLevel").forGetter(Randomizer::maxBatteryLevel), - DecimalProvider.CODEC.optionalFieldOf("batteryLevel").forGetter(Randomizer::batteryLevel), - DecimalProvider.CODEC.fieldOf("maxInput").forGetter(Randomizer::maxInput), - DecimalProvider.CODEC.optionalFieldOf("maxOutput").forGetter(Randomizer::maxOutput), - ).apply(it, ::Randomizer) - } - ) + val CODEC: Codec by lazy { + RecordCodecBuilder.create { + it.group( + DecimalProvider.CODEC.fieldOf("maxBatteryLevel").forGetter(Randomizer::maxBatteryLevel), + DecimalProvider.CODEC.optionalFieldOf("batteryLevel").forGetter(Randomizer::batteryLevel), + DecimalProvider.CODEC.fieldOf("maxInput").forGetter(Randomizer::maxInput), + DecimalProvider.CODEC.optionalFieldOf("maxOutput").forGetter(Randomizer::maxOutput), + ).apply(it, ::Randomizer) + } } } } 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 d1c408685..4a141d219 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt @@ -7,6 +7,7 @@ import net.minecraft.core.Direction import net.minecraft.nbt.CompoundTag import net.minecraft.network.FriendlyByteBuf import net.minecraft.network.chat.Component +import net.minecraft.util.datafix.DataFixTypes import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Rarity @@ -20,7 +21,7 @@ import net.minecraftforge.common.capabilities.ICapabilityProvider import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.event.TickEvent import net.minecraftforge.event.TickEvent.ServerTickEvent -import net.minecraftforge.network.NetworkEvent +import net.minecraftforge.event.network.CustomPayloadEvent import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability @@ -52,7 +53,6 @@ import ru.dbotthepony.mc.otm.isServerThread import ru.dbotthepony.mc.otm.lazyPerServer import ru.dbotthepony.mc.otm.network.GenericNetworkChannel import ru.dbotthepony.mc.otm.network.MatteryPacket -import ru.dbotthepony.mc.otm.network.packetHandled import java.util.* import java.util.function.Function import java.util.function.Supplier @@ -155,7 +155,7 @@ class QuantumBatteryItem(val savedataID: String, val balanceValues: EnergyBalanc val clientData = Object2ObjectOpenHashMap() val serverData: Data by lazyPerServer { - it.overworld().dataStorage.computeIfAbsent(::Data, ::Data, "otm_$savedataID") + it.overworld().dataStorage.computeIfAbsent(SavedData.Factory(::Data, ::Data, DataFixTypes.SAVED_DATA_MAP_DATA), "otm_$savedataID") } private inner class Power(private val stack: ItemStack) : IMatteryEnergyStorage, ICapabilityProvider { @@ -377,8 +377,7 @@ class QuantumBatteryItem(val savedataID: String, val balanceValues: EnergyBalanc buff.writeDecimal(received) } - override fun play(context: Supplier) { - context.packetHandled = true + override fun play(context: CustomPayloadEvent.Context) { val data = type.clientData.computeIfAbsent(uuid, Function { UnboundValues(it) }) data.energy = energy data.passed = passed diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ProceduralExopackSlotUpgradeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ProceduralExopackSlotUpgradeItem.kt index f72bb1884..1a0188d3d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ProceduralExopackSlotUpgradeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ProceduralExopackSlotUpgradeItem.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.item.exopack +import com.mojang.serialization.Codec import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.ChatFormatting import net.minecraft.network.chat.Component @@ -14,7 +15,6 @@ import net.minecraft.world.level.storage.loot.functions.LootItemFunctionType import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.tagNotNull -import ru.dbotthepony.mc.otm.data.Codec2Serializer import ru.dbotthepony.mc.otm.registry.MItemFunctionTypes import java.util.* @@ -34,14 +34,12 @@ class ProceduralExopackSlotUpgradeItem : AbstractExopackSlotUpgradeItem(defaultP } companion object { - val SERIALIZER = Codec2Serializer( - RecordCodecBuilder.create { - it.group( - IntProvider.CODEC.fieldOf("slots").forGetter(Randomizer::slots), - IntProvider.CODEC.optionalFieldOf("luck_bias", ConstantInt.ZERO).forGetter(Randomizer::luckBias), - ).apply(it, ::Randomizer) - } - ) + val CODEC: Codec = RecordCodecBuilder.create { + it.group( + IntProvider.CODEC.fieldOf("slots").forGetter(Randomizer::slots), + IntProvider.CODEC.optionalFieldOf("luck_bias", ConstantInt.ZERO).forGetter(Randomizer::luckBias), + ).apply(it, ::Randomizer) + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt index 18d1b193d..31cf99e7e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt @@ -18,15 +18,12 @@ import net.minecraftforge.client.event.RenderHandEvent import net.minecraftforge.client.event.RenderPlayerEvent import net.minecraftforge.client.event.ViewportEvent import net.minecraftforge.event.TickEvent +import net.minecraftforge.event.network.CustomPayloadEvent import net.minecraftforge.fml.LogicalSide -import net.minecraftforge.network.NetworkEvent -import ru.dbotthepony.mc.otm.* import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.client.font -import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.draw import ru.dbotthepony.mc.otm.client.render.renderRect -import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.math.Angle import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.Vector @@ -42,11 +39,12 @@ import ru.dbotthepony.mc.otm.core.nbt.EMPTY_UUID import ru.dbotthepony.mc.otm.core.nbt.booleans import ru.dbotthepony.mc.otm.core.nbt.ints import ru.dbotthepony.mc.otm.core.nbt.uuids +import ru.dbotthepony.mc.otm.core.tagNotNull import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.WeaponNetworkChannel import java.util.* -import java.util.function.Supplier +import kotlin.collections.set import kotlin.math.PI import kotlin.math.abs import kotlin.reflect.KClass @@ -62,16 +60,12 @@ enum class WeaponScopePacket(val scope: Boolean) : MatteryPacket { buff.writeBoolean(scope) } - override fun play(context: Supplier) { - context.get().packetHandled = true - + override fun play(context: CustomPayloadEvent.Context){ // TODO: Manual synchronization - context.get().enqueueWork { - val stack = context.get().sender!!.mainHandItem - val item = stack.item as? AbstractWeaponItem<*> ?: return@enqueueWork + val stack = context.sender!!.mainHandItem + val item = stack.item as? AbstractWeaponItem<*> ?: return - item.dataTable(stack).wantsToScope = scope - } + item.dataTable(stack).wantsToScope = scope } companion object { @@ -86,26 +80,22 @@ enum class WeaponFireInputPacket(val primary: Boolean) : MatteryPacket { buff.writeBoolean(primary) } - override fun play(context: Supplier) { - context.get().packetHandled = true - + override fun play(context: CustomPayloadEvent.Context){ // TODO: Manual synchronization - context.get().enqueueWork { - val stack = context.get().sender!!.mainHandItem - val item = stack.item as? AbstractWeaponItem<*> ?: return@enqueueWork + val stack = context.sender!!.mainHandItem + val item = stack.item as? AbstractWeaponItem<*> ?: return - // Listen server: client and server thread compete for lock - // so it is very likely item is being in predicted context - val predictedData = item.dataTable - item.dataTable = null + // Listen server: client and server thread compete for lock + // so it is very likely item is being in predicted context + val predictedData = item.dataTable + item.dataTable = null - if (primary) - item.tryPrimaryFire(stack, context.get().sender!!) - else - item.trySecondaryFire(stack, context.get().sender!!) + if (primary) + item.tryPrimaryFire(stack, context.sender!!) + else + item.trySecondaryFire(stack, context.sender!!) - (item as AbstractWeaponItem).dataTable = predictedData - } + (item as AbstractWeaponItem).dataTable = predictedData } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 4fffe1a0e..dd5d25f12 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -51,10 +51,10 @@ import net.minecraftforge.event.AddReloadListenerEvent import net.minecraftforge.event.OnDatapackSyncEvent import net.minecraftforge.event.RegisterCommandsEvent import net.minecraftforge.event.entity.player.ItemTooltipEvent +import net.minecraftforge.event.network.CustomPayloadEvent import net.minecraftforge.event.server.ServerStartedEvent import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.fml.ModList -import net.minecraftforge.network.NetworkEvent import net.minecraftforge.network.PacketDistributor import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.ForgeRegistries @@ -107,7 +107,6 @@ import java.io.OutputStream import java.math.BigInteger import java.util.* import java.util.function.BooleanSupplier -import java.util.function.Supplier import java.util.stream.Stream import java.util.zip.Deflater import java.util.zip.Inflater @@ -443,19 +442,19 @@ object MatterManager { val ignoreDamageables = data["ignore_damageables"]?.asBoolean ?: false val allowBacktrack = data["allow_backtrack"]?.asBoolean ?: true - var stream = server.recipeManager.byType(findRecipeType).values.stream().filter { !it.isIncomplete } + var stream = server.recipeManager.byType(findRecipeType).values.stream().filter { !it.value.isIncomplete } if (ignoreDamageables) { - stream = stream.filter { it.ingredients.stream().flatMap { it.items.stream() }.noneMatch { it.isDamageableItem } } + stream = stream.filter { it.value.ingredients.stream().flatMap { it.items.stream() }.noneMatch { it.isDamageableItem } } } - stream.filter { it.getResultItem(server.registryAccess()).isNotEmpty }.map { + stream.filter { it.value.getResultItem(server.registryAccess()).isNotEmpty }.map { try { ResolvedRecipe( - it.ingredients.stream() + it.value.ingredients.stream() .filter { !it.isActuallyEmpty } .map { it.items.stream().filter { it.isNotEmpty }.map(::RecipeEntry) }, - ImmutableStack(it.getResultItem(server.registryAccess())), + ImmutableStack(it.value.getResultItem(server.registryAccess())), isCritical = isCritical, name = it.id, allowBacktrack = allowBacktrack @@ -489,16 +488,16 @@ object MatterManager { val allowBacktrack = data["allow_backtrack"]?.asBoolean ?: true val ignoreDamageables = data["ignore_damageables"]?.asBoolean ?: false val isCritical = data["is_critical"]?.asBoolean ?: true - var stream = server.recipeManager.byType(findRecipeType).values.stream().filter { !it.isIncomplete } + var stream = server.recipeManager.byType(findRecipeType).values.stream().filter { !it.value.isIncomplete } if (ignoreDamageables) { - stream = stream.filter { it.ingredients.stream().flatMap { it.items.stream() }.noneMatch { it.isDamageableItem } } + stream = stream.filter { it.value.ingredients.stream().flatMap { it.items.stream() }.noneMatch { it.isDamageableItem } } } stream.map { try { // avoid reality snap when recipe has no output - val resultItem = it.getResultItem(server.registryAccess()) + val resultItem = it.value.getResultItem(server.registryAccess()) if (resultItem.isEmpty) { null @@ -506,17 +505,17 @@ object MatterManager { var width: Int var height: Int - if (it is IShapedRecipe<*>) { - width = it.recipeWidth - height = it.recipeHeight + if (it.value is IShapedRecipe<*>) { + width = (it.value as IShapedRecipe<*>).recipeWidth + height = (it.value as IShapedRecipe<*>).recipeHeight } else { width = 3 height = 3 } - if (width * height < it.ingredients.size) { - width = it.ingredients.size.coerceAtLeast(width) - height = it.ingredients.size.coerceAtLeast(height) + if (width * height < it.value.ingredients.size) { + width = it.value.ingredients.size.coerceAtLeast(width) + height = it.value.ingredients.size.coerceAtLeast(height) } val container = TransientCraftingContainer(object : AbstractContainerMenu(null, 0) { @@ -531,12 +530,12 @@ object MatterManager { val realIngredients = ArrayList>() - for (c in it.ingredients.indices) { - if (it.ingredients[c].isActuallyEmpty) { + for (c in it.value.ingredients.indices) { + if (it.value.ingredients[c].isActuallyEmpty) { continue } - for ((i, ingredient) in it.ingredients.withIndex()) { + for ((i, ingredient) in it.value.ingredients.withIndex()) { if (i != c) { container[i] = if (ingredient.isActuallyEmpty) ItemStack.EMPTY else ingredient.items.firstOrNull() ?: ItemStack.EMPTY } @@ -544,11 +543,11 @@ object MatterManager { val result = ArrayList() - for (item in it.ingredients[c].items) { + for (item in it.value.ingredients[c].items) { container[c] = item - if (!it.assemble(container, server.registryAccess()).isEmpty) { - val residue = it.getRemainingItems(container) + if (!it.value.assemble(container, server.registryAccess()).isEmpty) { + val residue = it.value.getRemainingItems(container) val thisResidue = residue[c] @@ -1640,7 +1639,7 @@ object MatterManager { if (event.player == null) { syncRegistry(PacketDistributor.ALL.noArg()) } else { - syncRegistry(PacketDistributor.PLAYER.with { event.player ?: throw ConcurrentModificationException() }) + syncRegistry(PacketDistributor.PLAYER.with(event.player!!)) } } @@ -1826,7 +1825,7 @@ object MatterManager { buff.writeBytes(payload, 0, length) } - override fun play(context: Supplier) { + override fun play(context: CustomPayloadEvent.Context) { if (SERVER_IS_LIVE) return // singleplayer or LAN host diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index c86d38b2c..ca497bbfe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -4,7 +4,6 @@ import com.google.common.collect.ImmutableList import com.mojang.datafixers.util.Pair import it.unimi.dsi.fastutil.ints.IntArrayList import it.unimi.dsi.fastutil.ints.IntCollection -import it.unimi.dsi.fastutil.ints.IntList import it.unimi.dsi.fastutil.io.FastByteArrayInputStream import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream import it.unimi.dsi.fastutil.objects.Reference2ObjectFunction @@ -25,7 +24,7 @@ import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.enchantment.EnchantmentHelper.hasBindingCurse import net.minecraft.world.level.block.entity.BlockEntity -import net.minecraftforge.network.NetworkEvent +import net.minecraftforge.event.network.CustomPayloadEvent import net.minecraftforge.network.PacketDistributor import ru.dbotthepony.mc.otm.capability.IMatteryUpgrade import ru.dbotthepony.mc.otm.capability.MatteryCapability @@ -40,7 +39,6 @@ import ru.dbotthepony.mc.otm.container.IMatteryContainer import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.container.UpgradeContainer import ru.dbotthepony.mc.otm.container.computeSortedIndices -import ru.dbotthepony.mc.otm.container.sort import ru.dbotthepony.mc.otm.container.sortWithIndices import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.collect.ConditionalEnumSet @@ -62,9 +60,6 @@ import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.MenuFieldPacket import ru.dbotthepony.mc.otm.network.MenuNetworkChannel import ru.dbotthepony.mc.otm.network.SetCarriedPacket -import ru.dbotthepony.mc.otm.network.enqueueWork -import ru.dbotthepony.mc.otm.network.packetHandled -import ru.dbotthepony.mc.otm.network.sender import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer import ru.dbotthepony.mc.otm.network.synchronizer.IField import ru.dbotthepony.mc.otm.network.synchronizer.IMutableBooleanField @@ -77,8 +72,6 @@ import java.util.function.Consumer import java.util.function.DoubleSupplier import java.util.function.IntSupplier import java.util.function.Predicate -import java.util.function.Supplier -import kotlin.collections.ArrayList data class PlayerSlot(val functional: A, val cosmetic: B? = null) @@ -126,16 +119,12 @@ abstract class MatteryMenu( buff.writeBytes(payload) } - override fun play(context: Supplier) { - context.packetHandled = true - - context.enqueueWork { - val menu = context.sender?.containerMenu as? MatteryMenu ?: return@enqueueWork - if (menu.containerId != containerId || !menu.stillValid(context.sender!!)) return@enqueueWork - val input = menu.playerInputs.getOrNull(inputId) ?: return@enqueueWork - if (!input.test(context.sender)) return@enqueueWork - input.invoke(input.codec.read(DataInputStream(FastByteArrayInputStream(payload)))) - } + override fun play(context: CustomPayloadEvent.Context) { + val menu = context.sender?.containerMenu as? MatteryMenu ?: return + if (menu.containerId != containerId || !menu.stillValid(context.sender!!)) return + val input = menu.playerInputs.getOrNull(inputId) ?: return + if (!input.test(context.sender)) return + input.invoke(input.codec.read(DataInputStream(FastByteArrayInputStream(payload)))) } } @@ -239,8 +228,6 @@ abstract class MatteryMenu( protected var inventorySlotIndexStart = 0 protected var inventorySlotIndexEnd = 0 - private val playerPacketDistributor = PacketDistributor.PLAYER.with { player as ServerPlayer } - fun addFilterSlots(slots: ItemFilter): List> { val result = ArrayList>(slots.size) 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 fc10bffc0..12dda814a 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 @@ -11,7 +11,7 @@ import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.ClickAction import net.minecraft.world.inventory.ClickType import net.minecraft.world.item.ItemStack -import net.minecraftforge.network.NetworkEvent +import net.minecraftforge.event.network.CustomPayloadEvent import net.minecraftforge.network.PacketDistributor import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.addSorted @@ -42,15 +42,12 @@ data class ItemViewInteractPacket(val stackID: Int, val type: ClickType, val act buff.writeEnum(action) } - override fun play(context: Supplier) { - context.packetHandled = true - context.enqueueWork { - val sender = context.sender ?: return@enqueueWork + override fun play(context: CustomPayloadEvent.Context) { + val sender = context.sender ?: return - if (!sender.isSpectator) { - sender.resetLastActionTime() - (sender.containerMenu as? INetworkedItemViewProvider)?.networkedItemView?.playerInteract(this) - } + if (!sender.isSpectator) { + sender.resetLastActionTime() + (sender.containerMenu as? INetworkedItemViewProvider)?.networkedItemView?.playerInteract(this) } } @@ -62,13 +59,10 @@ data class ItemViewInteractPacket(val stackID: Int, val type: ClickType, val act } abstract class NetworkedItemViewPacket : MatteryPacket { - final override fun play(context: Supplier) { - context.packetHandled = true - context.enqueueWork { - val get = Minecraft.getInstance().player?.containerMenu ?: return@enqueueWork - val view = (get as? INetworkedItemViewProvider)?.networkedItemView ?: throw IllegalStateException("No NetworkedItemView is present in currently open menu") - action(view) - } + final override fun play(context: CustomPayloadEvent.Context) { + val get = Minecraft.getInstance().player?.containerMenu ?: return + val view = (get as? INetworkedItemViewProvider)?.networkedItemView ?: throw IllegalStateException("No NetworkedItemView is present in currently open menu") + action(view) } protected abstract fun action(view: NetworkedItemView) @@ -249,7 +243,7 @@ class NetworkedItemView(val ply: Player, val menu: MatteryMenu, val isRemote: Bo fun network() { check(!isRemote) { "Not a server" } - val consumer = PacketDistributor.PLAYER.with { ply as ServerPlayer } + val consumer = PacketDistributor.PLAYER.with(ply as ServerPlayer) for (packet in networkBacklog) { MenuNetworkChannel.send(consumer, packet) 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 c59978c25..2a7966860 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 @@ -5,6 +5,7 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.crafting.RecipeHolder import ru.dbotthepony.mc.otm.block.entity.decorative.PainterBlockEntity import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.container.MatteryContainer @@ -42,7 +43,7 @@ class PainterMenu( val inputContainer = MatteryContainer(::rescan, 1) val outputContainer = MatteryContainer(1) - private var lastRecipe: PainterRecipe? = null + private var lastRecipe: RecipeHolder? = null var selectedRecipe by mSynchronizer.Field(null, ResourceLocationValueCodec.nullable).also { it.addListener { rescan() } } val isBulk = BooleanInputWithFeedback(this, tile?.let { it::isBulk }) @@ -53,7 +54,7 @@ class PainterMenu( val inputSlot = object : MatterySlot(inputContainer, 0) { override fun mayPlace(itemStack: ItemStack): Boolean { - return super.mayPlace(itemStack) && inventory.player.level().recipeManager.byType(MRecipes.PAINTER).values.any { it.input.test(itemStack) } + return super.mayPlace(itemStack) && inventory.player.level().recipeManager.byType(MRecipes.PAINTER).values.any { it.value.input.test(itemStack) } } } @@ -65,7 +66,7 @@ class PainterMenu( override fun onTake(player: Player, itemStack: ItemStack) { if (itemStack.isNotEmpty) { - lastRecipe?.dyes?.let { tile?.takeDyes(it) } + lastRecipe?.value?.dyes?.let { tile?.takeDyes(it) } if (isBulk.value) { val found = player.matteryPlayer!!.inventoryAndExopack @@ -116,11 +117,11 @@ class PainterMenu( } val listeners = ISubscriptable.Impl() - val possibleRecipes = ArrayList() + val possibleRecipes = ArrayList>() private fun rescan() { possibleRecipes.clear() - possibleRecipes.addAll(inventory.player.level().recipeManager.byType(MRecipes.PAINTER).values.iterator().filter { it.input.test(inputContainer[0]) }) + possibleRecipes.addAll(inventory.player.level().recipeManager.byType(MRecipes.PAINTER).values.iterator().filter { it.value.input.test(inputContainer[0]) }) listeners.accept(Unit) if (tile !is PainterBlockEntity) return @@ -129,10 +130,10 @@ class PainterMenu( } else { val recipe = inventory.player.level().recipeManager.byType(MRecipes.PAINTER)[selectedRecipe] - if (recipe == null || !recipe.canCraft(dyeStoredDirect) || !recipe.matches(inputContainer, inventory.player.level())) { + if (recipe == null || !recipe.value.canCraft(dyeStoredDirect) || !recipe.value.matches(inputContainer, inventory.player.level())) { outputContainer.clearContent() } else { - outputContainer[0] = recipe.assemble(inputContainer, inventory.player.level().registryAccess()) + outputContainer[0] = recipe.value.assemble(inputContainer, inventory.player.level().registryAccess()) lastRecipe = recipe } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterEntanglerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterEntanglerMenu.kt index 99f71e491..2c452c85f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterEntanglerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterEntanglerMenu.kt @@ -52,7 +52,7 @@ class MatterEntanglerMenu( .recipeManager .byType(MRecipes.MATTER_ENTANGLER) .values - .any { it.preemptivelyMatches(shadow, level) } + .any { it.value.preemptivelyMatches(shadow, level) } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt index 95216979a..8a08a7dfa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt @@ -5,20 +5,17 @@ import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.item.Item -import net.minecraftforge.network.NetworkEvent +import net.minecraftforge.event.network.CustomPayloadEvent import net.minecraftforge.network.PacketDistributor import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.block.entity.matter.MatterPanelBlockEntity import ru.dbotthepony.mc.otm.capability.matter.* import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.addSorted import ru.dbotthepony.mc.otm.core.map import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.util.DecimalValueCodec -import ru.dbotthepony.mc.otm.core.util.ItemSorter import ru.dbotthepony.mc.otm.core.util.NullValueCodec -import ru.dbotthepony.mc.otm.core.util.codec import ru.dbotthepony.mc.otm.core.util.writeCollection import ru.dbotthepony.mc.otm.graph.matter.IMatterGraphListener import ru.dbotthepony.mc.otm.graph.matter.MatterGraph @@ -30,19 +27,15 @@ import ru.dbotthepony.mc.otm.registry.MMenus import java.util.* import java.util.function.Predicate import java.util.function.Supplier -import kotlin.collections.ArrayList class CancelTaskPacket(val id: UUID) : MatteryPacket { override fun write(buff: FriendlyByteBuf) { buff.writeUUID(id) } - override fun play(context: Supplier) { - context.packetHandled = true - context.enqueueWork { - val sender = context.sender!! - (sender.containerMenu as? MatterPanelMenu)?.receiveTaskCancel(sender, id) - } + override fun play(context: CustomPayloadEvent.Context) { + val sender = context.sender!! + (sender.containerMenu as? MatterPanelMenu)?.receiveTaskCancel(sender, id) } companion object { @@ -58,16 +51,13 @@ class PatternsChangePacket(val isUpdate: Boolean, val patterns: Collection) { - context.packetHandled = true - context.enqueueWork { - val menu = minecraft.player?.containerMenu as? MatterPanelMenu ?: return@enqueueWork + override fun play(context: CustomPayloadEvent.Context) { + val menu = minecraft.player?.containerMenu as? MatterPanelMenu ?: return - if (isUpdate) { - menu.networkPatternsUpdated(patterns) - } else { - menu.networkPatternsRemoved(patterns) - } + if (isUpdate) { + menu.networkPatternsUpdated(patterns) + } else { + menu.networkPatternsRemoved(patterns) } } @@ -84,16 +74,13 @@ class TasksChangePacket(val isUpdate: Boolean, val tasks: Collection) { - context.packetHandled = true - context.enqueueWork { - val menu = minecraft.player?.containerMenu as? MatterPanelMenu ?: return@enqueueWork + override fun play(context: CustomPayloadEvent.Context) { + val menu = minecraft.player?.containerMenu as? MatterPanelMenu ?: return - if (isUpdate) { - menu.networkTasksUpdated(tasks) - } else { - menu.networkTasksRemoved(tasks) - } + if (isUpdate) { + menu.networkTasksUpdated(tasks) + } else { + menu.networkTasksRemoved(tasks) } } @@ -112,14 +99,11 @@ class ReplicationRequestPacket(val id: UUID, amount: Int) : MatteryPacket { buff.writeInt(amount) } - override fun play(context: Supplier) { - context.packetHandled = true - context.enqueueWork { - val sender = context.sender ?: return@enqueueWork - val menu = sender.containerMenu as? MatterPanelMenu ?: return@enqueueWork + override fun play(context: CustomPayloadEvent.Context) { + val sender = context.sender ?: return + val menu = sender.containerMenu as? MatterPanelMenu ?: return - menu.requestReplication(sender, id, amount) - } + menu.requestReplication(sender, id, amount) } companion object { @@ -339,7 +323,7 @@ class MatterPanelMenu( } private fun sendNetwork(packet: Any) { - MenuNetworkChannel.send(PacketDistributor.PLAYER.with { inventory.player as ServerPlayer }, packet) + MenuNetworkChannel.send(inventory.player, packet) } fun fullPatternBroadcast() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt index c27a9be9e..7887ab392 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt @@ -9,8 +9,8 @@ import net.minecraft.network.FriendlyByteBuf import net.minecraft.server.level.ServerPlayer import net.minecraft.util.RandomSource import net.minecraft.world.level.Level +import net.minecraftforge.event.network.CustomPayloadEvent import net.minecraftforge.network.NetworkDirection -import net.minecraftforge.network.NetworkEvent import net.minecraftforge.network.PacketDistributor import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.android.AndroidResearchManager @@ -21,7 +21,6 @@ import ru.dbotthepony.mc.otm.client.onceClient import ru.dbotthepony.mc.otm.item.QuantumBatteryItem import ru.dbotthepony.mc.otm.matter.MatterManager import java.util.* -import java.util.function.Supplier import kotlin.collections.ArrayList class SmokeParticlesPacket(val x: Double, val y: Double, val z: Double) : MatteryPacket { @@ -31,12 +30,9 @@ class SmokeParticlesPacket(val x: Double, val y: Double, val z: Double) : Matter buff.writeDouble(z) } - override fun play(context: Supplier) { - context.packetHandled = true - context.enqueueWork { - minecraft.player?.level()?.let { - makeSmoke(x, y, z, it.random, it) - } + override fun play(context: CustomPayloadEvent.Context) { + minecraft.player?.level()?.let { + makeSmoke(x, y, z, it.random, it) } } @@ -104,12 +100,8 @@ class BlockEntitySyncPacket(val position: BlockPos, val buffer: ByteArray, val v } } - override fun play(context: Supplier) { - context.packetHandled = true - - context.enqueueWork { - execute() - } + override fun play(context: CustomPayloadEvent.Context) { + execute() } companion object { @@ -128,15 +120,15 @@ class BlockEntitySyncPacket(val position: BlockPos, val buffer: ByteArray, val v } object GenericNetworkChannel : MatteryNetworkChannel( - version = "4", + version = 5, name = "generic" ) { fun makeSmoke(x: Double, y: Double, z: Double, level: Level) { - send(PacketDistributor.NEAR.with { PacketDistributor.TargetPoint(x, y, z, 64.0, level.dimension()) }, SmokeParticlesPacket(x, y, z)) + send(PacketDistributor.NEAR.with(PacketDistributor.TargetPoint(x, y, z, 64.0, level.dimension())), SmokeParticlesPacket(x, y, z)) } fun makeSmoke(excluded: ServerPlayer, x: Double, y: Double, z: Double) { - send(PacketDistributor.NEAR.with { PacketDistributor.TargetPoint(excluded, x, y, z, 64.0, excluded.level().dimension()) }, SmokeParticlesPacket(x, y, z)) + send(PacketDistributor.NEAR.with(PacketDistributor.TargetPoint(excluded, x, y, z, 64.0, excluded.level().dimension())), SmokeParticlesPacket(x, y, z)) } fun register() { @@ -145,7 +137,7 @@ object GenericNetworkChannel : MatteryNetworkChannel( add(BlockEntitySyncPacket::class.java, BlockEntitySyncPacket.Companion::read, NetworkDirection.PLAY_TO_CLIENT) add(ItemEntityDataPacket::class.java, ItemEntityDataPacket.Companion::read, NetworkDirection.PLAY_TO_CLIENT) - add(AndroidResearchManager.SyncPacket::class.java, AndroidResearchManager::readSyncPacket, NetworkDirection.PLAY_TO_CLIENT) + add(AndroidResearchManager.SyncPacket::class.java, AndroidResearchManager::readSyncPacket, NetworkDirection.PLAY_TO_CLIENT, handleOnMainThread = false) add(MatterManager.SyncPacket::class.java, MatterManager::readSyncPacket, NetworkDirection.PLAY_TO_CLIENT) add(SmokeParticlesPacket::class, SmokeParticlesPacket.Companion::read, NetworkDirection.PLAY_TO_CLIENT) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt index bda3984b9..bebbcb246 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt @@ -1,67 +1,48 @@ package ru.dbotthepony.mc.otm.network -import java.util.function.Function import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.Entity import net.minecraft.world.entity.player.Player -import net.minecraftforge.event.TickEvent -import net.minecraftforge.event.TickEvent.ServerTickEvent -import net.minecraftforge.event.server.ServerStoppedEvent -import net.minecraftforge.event.server.ServerStoppingEvent +import net.minecraftforge.event.network.CustomPayloadEvent +import net.minecraftforge.network.Channel +import net.minecraftforge.network.ChannelBuilder import net.minecraftforge.network.NetworkDirection -import net.minecraftforge.network.NetworkEvent -import net.minecraftforge.network.NetworkRegistry import net.minecraftforge.network.PacketDistributor -import net.minecraftforge.network.simple.SimpleChannel +import net.minecraftforge.network.SimpleChannel import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.NULLABLE_MINECRAFT_SERVER import ru.dbotthepony.mc.otm.OverdriveThatMatters -import java.math.BigDecimal -import java.math.BigInteger -import java.util.Optional -import java.util.concurrent.CompletableFuture -import java.util.concurrent.ConcurrentLinkedDeque import java.util.concurrent.ConcurrentLinkedQueue import java.util.concurrent.locks.LockSupport import java.util.function.BiConsumer -import java.util.function.Supplier +import java.util.function.Function import kotlin.reflect.KClass -fun Supplier.enqueueWork(lambda: Runnable): CompletableFuture = get().enqueueWork(lambda) -fun Supplier.enqueueWork(lambda: () -> Unit): CompletableFuture = get().enqueueWork(lambda) -var Supplier.packetHandled: Boolean - get() = get().packetHandled - set(value) { get().packetHandled = value } - -val Supplier.sender: ServerPlayer? - get() = get().sender - interface MatteryPacket { fun write(buff: FriendlyByteBuf) - fun play(context: Supplier) + fun play(context: CustomPayloadEvent.Context) } -abstract class MatteryNetworkChannel(val version: String, val name: String) { - val channel: SimpleChannel = NetworkRegistry.newSimpleChannel( - ResourceLocation(OverdriveThatMatters.MOD_ID, name), - { version }, - { it == version }, - { it == version }, - ) +abstract class MatteryNetworkChannel(val version: Int, val name: String) { + val channel: SimpleChannel = ChannelBuilder + .named(ResourceLocation(OverdriveThatMatters.MOD_ID, name)) + .acceptedVersions(Channel.VersionTest.exact(version)) + .networkProtocolVersion(version) + .simpleChannel() - fun sendToServer(packet: Any) = channel.sendToServer(packet) + fun sendToServer(packet: Any) = channel.send(packet, PacketDistributor.SERVER.noArg()) fun send(ply: Player, packet: Any) { if (ply is ServerPlayer) { - queue.add(Task(channel, PacketDistributor.PLAYER.with { ply }, packet)) + queue.add(Task(channel, PacketDistributor.PLAYER.with(ply), packet)) } } fun sendNow(ply: Player, packet: Any) { if (ply is ServerPlayer) { - channel.send(PacketDistributor.PLAYER.with { ply }, packet) + channel.send(packet, PacketDistributor.PLAYER.with(ply)) } } @@ -70,7 +51,7 @@ abstract class MatteryNetworkChannel(val version: String, val name: String) { return } - queue.add(Task(channel, PacketDistributor.TRACKING_ENTITY.with { entity }, packet)) + queue.add(Task(channel, PacketDistributor.TRACKING_ENTITY.with(entity), packet)) } fun sendTrackingAndSelf(entity: Entity, packet: Any) { @@ -78,7 +59,7 @@ abstract class MatteryNetworkChannel(val version: String, val name: String) { return } - queue.add(Task(channel, PacketDistributor.TRACKING_ENTITY_AND_SELF.with { entity }, packet)) + queue.add(Task(channel, PacketDistributor.TRACKING_ENTITY_AND_SELF.with(entity), packet)) } fun send(distributor: PacketDistributor.PacketTarget, packet: Any) { @@ -86,7 +67,7 @@ abstract class MatteryNetworkChannel(val version: String, val name: String) { } fun sendNow(distributor: PacketDistributor.PacketTarget, packet: Any) { - channel.send(distributor, packet) + channel.send(packet, distributor) } private var nextNetworkPacketID = 0 @@ -95,31 +76,43 @@ abstract class MatteryNetworkChannel(val version: String, val name: String) { packetClass: Class, writer: BiConsumer, reader: Function, - handler: BiConsumer>, - direction: NetworkDirection? = null + handler: BiConsumer, + direction: NetworkDirection? = null, + handleOnMainThread: Boolean = true, ) { if (nextNetworkPacketID >= 256) { throw IndexOutOfBoundsException("Network message ID overflow!") } - @Suppress("INACCESSIBLE_TYPE") - channel.registerMessage(nextNetworkPacketID++, packetClass, writer, reader, handler, if (direction == null) Optional.empty() else Optional.of(direction)) + val builder = channel.messageBuilder(packetClass, direction) + + if (handleOnMainThread) { + builder.consumerMainThread(handler) + } else { + builder.consumerNetworkThread(handler) + } + + builder.encoder(writer) + builder.decoder(reader) + builder.add() } fun add( packetClass: Class, reader: Function, - direction: NetworkDirection? = null + direction: NetworkDirection? = null, + handleOnMainThread: Boolean = true, ) { - add(packetClass, MatteryPacket::write, reader, MatteryPacket::play, direction) + add(packetClass, MatteryPacket::write, reader, MatteryPacket::play, direction, handleOnMainThread) } fun add( packetClass: KClass, reader: Function, - direction: NetworkDirection? = null + direction: NetworkDirection? = null, + handleOnMainThread: Boolean = true, ) { - add(packetClass.java, MatteryPacket::write, reader, MatteryPacket::play, direction) + add(packetClass.java, MatteryPacket::write, reader, MatteryPacket::play, direction, handleOnMainThread) } private data class Task(val channel: SimpleChannel, val target: PacketDistributor.PacketTarget, val packet: Any) @@ -150,7 +143,7 @@ abstract class MatteryNetworkChannel(val version: String, val name: String) { LockSupport.park() } else { try { - task.channel.send(task.target, task.packet) + task.channel.send(task.packet, task.target) } catch(err: Throwable) { logger.error("Error executing network dispatcher task", err) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt index 067fb58a3..e07e301c1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt @@ -8,9 +8,9 @@ import net.minecraft.network.protocol.game.ClientboundSetCarriedItemPacket import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack +import net.minecraftforge.event.network.CustomPayloadEvent import net.minecraftforge.network.NetworkDirection.PLAY_TO_CLIENT import net.minecraftforge.network.NetworkDirection.PLAY_TO_SERVER -import net.minecraftforge.network.NetworkEvent import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.android.AndroidActiveFeature import ru.dbotthepony.mc.otm.android.AndroidFeatureType @@ -40,7 +40,6 @@ import ru.dbotthepony.mc.otm.registry.AndroidFeatures import ru.dbotthepony.mc.otm.registry.MRegistry import java.io.ByteArrayInputStream import java.util.UUID -import java.util.function.Supplier class MatteryPlayerFieldPacket(val bytes: ByteArray, val length: Int, val isPublic: Boolean, val target: UUID? = null) : MatteryPacket { constructor(stream: FastByteArrayOutputStream, isPublic: Boolean, target: UUID? = null) : this(stream.array, stream.length, isPublic, target) @@ -55,22 +54,19 @@ class MatteryPlayerFieldPacket(val bytes: ByteArray, val length: Int, val isPubl buff.writeBytes(bytes, 0, length) } - override fun play(context: Supplier) { - context.packetHandled = true - context.get().enqueueWork { - val player: MatteryPlayerCapability + override fun play(context: CustomPayloadEvent.Context) { + val player: MatteryPlayerCapability - if (target != null) { - player = minecraft.level?.players()?.firstOrNull { it.uuid == target }?.matteryPlayer ?: return@enqueueWork - } else { - player = minecraft.player?.matteryPlayer ?: return@enqueueWork - } + if (target != null) { + player = minecraft.level?.players()?.firstOrNull { it.uuid == target }?.matteryPlayer ?: return + } else { + player = minecraft.player?.matteryPlayer ?: return + } - if (isPublic) { - player.publicSynchronizer.read(ByteArrayInputStream(bytes, 0, length)) - } else { - player.synchronizer.read(ByteArrayInputStream(bytes, 0, length)) - } + if (isPublic) { + player.publicSynchronizer.read(ByteArrayInputStream(bytes, 0, length)) + } else { + player.synchronizer.read(ByteArrayInputStream(bytes, 0, length)) } } @@ -93,18 +89,15 @@ class AndroidResearchRequestPacket(val type: AndroidResearchType) : MatteryPacke buff.writeUtf(type.id.toString()) } - override fun play(context: Supplier) { - context.packetHandled = true - context.enqueueWork { - val ply = context.get().sender ?: return@enqueueWork - if (ply.isSpectator) return@enqueueWork - val android = ply.matteryPlayer ?: return@enqueueWork + override fun play(context: CustomPayloadEvent.Context) { + val ply = context.sender ?: return + if (ply.isSpectator) return + val android = ply.matteryPlayer ?: return - if (!android.isAndroid || ply.containerMenu !is AndroidStationMenu) - return@enqueueWork + if (!android.isAndroid || ply.containerMenu !is AndroidStationMenu) + return - android.getResearch(type).research() - } + android.getResearch(type).research() } companion object { @@ -121,15 +114,10 @@ class AndroidResearchSyncPacket(val type: AndroidResearchType, val dataList: Fas buff.writeBytes(dataList.array, 0, dataList.length) } - override fun play(context: Supplier) { + override fun play(context: CustomPayloadEvent.Context) { dataBytes ?: throw NullPointerException("No data bytes array is present") - - context.get().packetHandled = true - context.get().enqueueWork { - val android = minecraft.player?.matteryPlayer ?: return@enqueueWork - - android.getResearch(type).applyNetworkPayload(ByteArrayInputStream(dataBytes)) - } + val android = minecraft.player?.matteryPlayer ?: return + android.getResearch(type).applyNetworkPayload(ByteArrayInputStream(dataBytes)) } companion object { @@ -149,15 +137,10 @@ class AndroidFeatureSyncPacket(val type: AndroidFeatureType<*>, val dataList: Fa buff.writeBytes(dataList.array, 0, dataList.length) } - override fun play(context: Supplier) { + override fun play(context: CustomPayloadEvent.Context) { dataBytes ?: throw NullPointerException("No data bytes array is present") - - context.get().packetHandled = true - context.get().enqueueWork { - val android = minecraft.player?.matteryPlayer ?: return@enqueueWork - - android.computeIfAbsent(type).applyNetworkPayload(ByteArrayInputStream(dataBytes)) - } + val android = minecraft.player?.matteryPlayer ?: return + android.computeIfAbsent(type).applyNetworkPayload(ByteArrayInputStream(dataBytes)) } companion object { @@ -175,13 +158,9 @@ class AndroidFeatureRemovePacket(val type: AndroidFeatureType<*>) : MatteryPacke buff.writeInt(MRegistry.ANDROID_FEATURES.getID(type)) } - override fun play(context: Supplier) { - context.get().packetHandled = true - context.get().enqueueWork { - val android = minecraft.player?.matteryPlayer ?: return@enqueueWork - - android.removeFeature(type) - } + override fun play(context: CustomPayloadEvent.Context) { + val android = minecraft.player?.matteryPlayer ?: return + android.removeFeature(type) } companion object { @@ -202,7 +181,7 @@ class PlayerIterationPacket(val iteration: Int, val deathLog: List) { + override fun play(context: CustomPayloadEvent.Context) { context.packetHandled = true MatteryGUI.iteration = iteration @@ -234,15 +213,12 @@ class ExopackCarriedPacket(val itemStack: ItemStack, val containerState: Int) : buff.writeInt(containerState) } - override fun play(context: Supplier) { - context.packetHandled = true - context.enqueueWork { - val mattery = minecraft.player?.matteryPlayer ?: return@enqueueWork + override fun play(context: CustomPayloadEvent.Context) { + val mattery = minecraft.player?.matteryPlayer ?: return - if (mattery.hasExopack) { - mattery.exoPackMenu.carried = itemStack - mattery.exoPackMenu.stateId = containerState - } + if (mattery.hasExopack) { + mattery.exoPackMenu.carried = itemStack + mattery.exoPackMenu.stateId = containerState } } @@ -260,31 +236,27 @@ class ExopackSlotPacket(val slotId: Int, val itemStack: ItemStack, val container buff.writeInt(containerState) } - override fun play(context: Supplier) { - context.packetHandled = true - + override fun play(context: CustomPayloadEvent.Context) { if (slotId < 0) { LOGGER.error("Unknown slot with ID {} in exosuit menu", slotId) return } - context.enqueueWork { - val mattery = minecraft.player?.matteryPlayer ?: return@enqueueWork + val mattery = minecraft.player?.matteryPlayer ?: return - if (mattery.hasExopack) { - if (slotId >= mattery.exoPackMenu.slots.size) { - LOGGER.error("Unknown slot with ID {} in exosuit menu", slotId) - return@enqueueWork - } - - // don't duplicate data - // really. - if (mattery.exoPackMenu.slots[slotId].container == minecraft.player?.inventory && minecraft.player?.containerMenu !is ExopackInventoryMenu) - return@enqueueWork - - mattery.exoPackMenu.slots[slotId].set(itemStack) - mattery.exoPackMenu.stateId = containerState + if (mattery.hasExopack) { + if (slotId >= mattery.exoPackMenu.slots.size) { + LOGGER.error("Unknown slot with ID {} in exosuit menu", slotId) + return } + + // don't duplicate data + // really. + if (mattery.exoPackMenu.slots[slotId].container == minecraft.player?.inventory && minecraft.player?.containerMenu !is ExopackInventoryMenu) + return + + mattery.exoPackMenu.slots[slotId].set(itemStack) + mattery.exoPackMenu.stateId = containerState } } @@ -309,14 +281,11 @@ class ExopackMenuInitPacket(val slots: List, val carried: ItemStack, buff.writeInt(containerState) } - override fun play(context: Supplier) { - context.packetHandled = true - context.enqueueWork { - val mattery = minecraft.player?.matteryPlayer ?: return@enqueueWork + override fun play(context: CustomPayloadEvent.Context) { + val mattery = minecraft.player?.matteryPlayer ?: return - if (mattery.hasExopack) { - mattery.exoPackMenu.initializeContents(containerState, slots, carried) - } + if (mattery.hasExopack) { + mattery.exoPackMenu.initializeContents(containerState, slots, carried) } } @@ -340,15 +309,12 @@ class ExopackMenuInitPacket(val slots: List, val carried: ItemStack, object ExopackMenuOpen : MatteryPacket { override fun write(buff: FriendlyByteBuf) {} - override fun play(context: Supplier) { - context.packetHandled = true - context.enqueueWork { - val player = context.sender ?: return@enqueueWork - val mattery = player.matteryPlayer ?: return@enqueueWork + override fun play(context: CustomPayloadEvent.Context) { + val player = context.sender ?: return + val mattery = player.matteryPlayer ?: return - if (mattery.hasExopack) { - player.containerMenu = mattery.exoPackMenu - } + if (mattery.hasExopack) { + player.containerMenu = mattery.exoPackMenu } } } @@ -359,28 +325,24 @@ class SwitchAndroidFeaturePacket(val type: AndroidFeatureType<*>, val newState: buff.writeBoolean(newState) } - override fun play(context: Supplier) { - context.packetHandled = true + override fun play(context: CustomPayloadEvent.Context) { + val matteryPlayer = context.sender?.matteryPlayer ?: return - context.enqueueWork { - val matteryPlayer = context.sender?.matteryPlayer ?: return@enqueueWork + if (!matteryPlayer.isAndroid) { + return + } - if (!matteryPlayer.isAndroid) { - return@enqueueWork - } + val feature = matteryPlayer.getFeature(type) ?: return - val feature = matteryPlayer.getFeature(type) ?: return@enqueueWork - - if (feature is AndroidActiveFeature && feature.allowToSwitchByPlayer && (!matteryPlayer.ply.isSpectator || feature.allowToSwitchByPlayerWhileSpectator)) { - matteryPlayer.features - .map { it as? AndroidActiveFeature } - .filter { it != null } - .filter { it !== feature && it!!.allowToSwitchByPlayer && (!matteryPlayer.ply.isSpectator || it.allowToSwitchByPlayerWhileSpectator) } - .forEach { it!!.isActive = false } - feature.isActive = newState - } else if (feature is AndroidSwitchableFeature && feature.allowToSwitchByPlayer && (!matteryPlayer.ply.isSpectator || feature.allowToSwitchByPlayerWhileSpectator)) { - feature.isActive = newState - } + if (feature is AndroidActiveFeature && feature.allowToSwitchByPlayer && (!matteryPlayer.ply.isSpectator || feature.allowToSwitchByPlayerWhileSpectator)) { + matteryPlayer.features + .map { it as? AndroidActiveFeature } + .filter { it != null } + .filter { it !== feature && it!!.allowToSwitchByPlayer && (!matteryPlayer.ply.isSpectator || it.allowToSwitchByPlayerWhileSpectator) } + .forEach { it!!.isActive = false } + feature.isActive = newState + } else if (feature is AndroidSwitchableFeature && feature.allowToSwitchByPlayer && (!matteryPlayer.ply.isSpectator || feature.allowToSwitchByPlayerWhileSpectator)) { + feature.isActive = newState } } @@ -396,21 +358,17 @@ class ActivateAndroidFeaturePacket(val type: AndroidFeatureType<*>) : MatteryPac buff.writeInt(MRegistry.ANDROID_FEATURES.getID(type)) } - override fun play(context: Supplier) { - context.packetHandled = true + override fun play(context: CustomPayloadEvent.Context) { + val matteryPlayer = context.sender?.matteryPlayer ?: return - context.enqueueWork { - val matteryPlayer = context.sender?.matteryPlayer ?: return@enqueueWork + if (!matteryPlayer.isAndroid || matteryPlayer.ply.isSpectator) { + return + } - if (!matteryPlayer.isAndroid || matteryPlayer.ply.isSpectator) { - return@enqueueWork - } + val feature = matteryPlayer.getFeature(type) as? AndroidActiveFeature ?: return - val feature = matteryPlayer.getFeature(type) as? AndroidActiveFeature ?: return@enqueueWork - - if (feature.isActive || feature.allowToSwitchByPlayer) { - feature.activate(false) - } + if (feature.isActive || feature.allowToSwitchByPlayer) { + feature.activate(false) } } @@ -430,30 +388,26 @@ class PickItemFromInventoryPacket( buff.writeVarInt(sourceExosuitSlot) } - override fun play(context: Supplier) { - context.packetHandled = true + override fun play(context: CustomPayloadEvent.Context) { + val player = context.sender ?: return + val mattery = player.matteryPlayer ?: return - context.enqueueWork { - val player = context.sender ?: return@enqueueWork - val mattery = player.matteryPlayer ?: return@enqueueWork - - if (!mattery.hasExopack || sourceExosuitSlot !in 0 until mattery.exopackContainer.containerSize) { - return@enqueueWork - } - - if (!Inventory.isHotbarSlot(targetHotbarSlot)) { - return@enqueueWork - } - - player.inventory.selected = targetHotbarSlot - val existingItem = player.inventory[targetHotbarSlot].copy() - val inventoryItem = mattery.exopackContainer[sourceExosuitSlot].copy() - - player.inventory[targetHotbarSlot] = if (inventoryItem.isEmpty) ItemStack.EMPTY else inventoryItem - mattery.exopackContainer[sourceExosuitSlot] = if (existingItem.isEmpty) ItemStack.EMPTY else existingItem - - player.connection.send(ClientboundSetCarriedItemPacket(targetHotbarSlot)) + if (!mattery.hasExopack || sourceExosuitSlot !in 0 until mattery.exopackContainer.containerSize) { + return } + + if (!Inventory.isHotbarSlot(targetHotbarSlot)) { + return + } + + player.inventory.selected = targetHotbarSlot + val existingItem = player.inventory[targetHotbarSlot].copy() + val inventoryItem = mattery.exopackContainer[sourceExosuitSlot].copy() + + player.inventory[targetHotbarSlot] = if (inventoryItem.isEmpty) ItemStack.EMPTY else inventoryItem + mattery.exopackContainer[sourceExosuitSlot] = if (existingItem.isEmpty) ItemStack.EMPTY else existingItem + + player.connection.send(ClientboundSetCarriedItemPacket(targetHotbarSlot)) } companion object { @@ -468,7 +422,7 @@ class GlitchPacket(val millis: Long) : MatteryPacket { buff.writeVarLong(millis) } - override fun play(context: Supplier) { + override fun play(context: CustomPayloadEvent.Context) { context.packetHandled = true GlitchRenderer.glitchFor(millis) } @@ -487,7 +441,7 @@ class ShockwaveEffectPacket(val pos: Vector) : MatteryPacket { buff.writeDouble(pos.z) } - override fun play(context: Supplier) { + override fun play(context: CustomPayloadEvent.Context) { context.packetHandled = true ShockwaveRenderer.handle(this) } @@ -502,7 +456,7 @@ class ShockwaveEffectPacket(val pos: Vector) : MatteryPacket { object DisplayExopackPacket : MatteryPacket { override fun write(buff: FriendlyByteBuf) {} - override fun play(context: Supplier) { + override fun play(context: CustomPayloadEvent.Context) { context.packetHandled = true context.sender?.matteryPlayer?.isExopackVisible = true } @@ -511,7 +465,7 @@ object DisplayExopackPacket : MatteryPacket { object HideExopackPacket : MatteryPacket { override fun write(buff: FriendlyByteBuf) {} - override fun play(context: Supplier) { + override fun play(context: CustomPayloadEvent.Context) { context.packetHandled = true context.sender?.matteryPlayer?.isExopackVisible = false } @@ -520,7 +474,7 @@ object HideExopackPacket : MatteryPacket { object EnableExopackGlowPacket : MatteryPacket { override fun write(buff: FriendlyByteBuf) {} - override fun play(context: Supplier) { + override fun play(context: CustomPayloadEvent.Context) { context.packetHandled = true context.sender?.matteryPlayer?.exopackGlows = true } @@ -529,7 +483,7 @@ object EnableExopackGlowPacket : MatteryPacket { object DisableExopackGlowPacket : MatteryPacket { override fun write(buff: FriendlyByteBuf) {} - override fun play(context: Supplier) { + override fun play(context: CustomPayloadEvent.Context) { context.packetHandled = true context.sender?.matteryPlayer?.exopackGlows = false } @@ -538,7 +492,7 @@ object DisableExopackGlowPacket : MatteryPacket { object ResetExopackColorPacket : MatteryPacket { override fun write(buff: FriendlyByteBuf) {} - override fun play(context: Supplier) { + override fun play(context: CustomPayloadEvent.Context) { context.packetHandled = true context.sender?.matteryPlayer?.exopackColor = null } @@ -551,7 +505,7 @@ data class SetExopackColorPacket(val color: RGBAColor) : MatteryPacket { buff.writeFloat(color.blue) } - override fun play(context: Supplier) { + override fun play(context: CustomPayloadEvent.Context) { context.packetHandled = true context.sender?.matteryPlayer?.exopackColor = color } @@ -568,37 +522,34 @@ data class ExopackSmokePacket(val player: UUID) : MatteryPacket { buff.writeUUID(player) } - override fun play(context: Supplier) { + override fun play(context: CustomPayloadEvent.Context) { context.packetHandled = true // minecraft.player?.level()?.getPlayerByUUID(player)?.matteryPlayer?.spawnExopackSmoke = true - context.enqueueWork { - minecraft.player?.level()?.getPlayerByUUID(player)?.let { ply -> - if (ply != minecraft.player || minecraft.gameRenderer.mainCamera.isDetached) { - var (x, y, z) = ply.position + minecraft.player?.level()?.getPlayerByUUID(player)?.let { ply -> + if (ply != minecraft.player || minecraft.gameRenderer.mainCamera.isDetached) { + var (x, y, z) = ply.position - y += 1.5 - val deg = toRadians(ply.yBodyRot + 90f) + y += 1.5 + val deg = toRadians(ply.yBodyRot + 90f) - x += kotlin.math.cos(deg) * -0.4 - z += kotlin.math.sin(deg) * -0.4 + x += kotlin.math.cos(deg) * -0.4 + z += kotlin.math.sin(deg) * -0.4 - val level = ply.level() - val random = level.random + val level = ply.level() + val random = level.random - for (i in 0 .. random.nextInt(2, 4)) - level.addParticle( - ParticleTypes.SMOKE, - x + random.nextDouble() * 0.4 - 0.2, - y + random.nextDouble() * 0.4 - 0.2, - z + random.nextDouble() * 0.4 - 0.2, - random.nextGaussian() * 0.02, - random.nextGaussian() * 0.02, - random.nextGaussian() * 0.02) - } + for (i in 0 .. random.nextInt(2, 4)) + level.addParticle( + ParticleTypes.SMOKE, + x + random.nextDouble() * 0.4 - 0.2, + y + random.nextDouble() * 0.4 - 0.2, + z + random.nextDouble() * 0.4 - 0.2, + random.nextGaussian() * 0.02, + random.nextGaussian() * 0.02, + random.nextGaussian() * 0.02) } } - } companion object { @@ -609,7 +560,7 @@ data class ExopackSmokePacket(val player: UUID) : MatteryPacket { } object MatteryPlayerNetworkChannel : MatteryNetworkChannel( - version = "6", + version = 7, name = "player" ) { fun register() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt index 0cd9cfa71..d85d4defe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt @@ -3,8 +3,8 @@ package ru.dbotthepony.mc.otm.network import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream import net.minecraft.network.FriendlyByteBuf import net.minecraft.world.item.ItemStack +import net.minecraftforge.event.network.CustomPayloadEvent import net.minecraftforge.network.NetworkDirection -import net.minecraftforge.network.NetworkEvent import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.compat.vanilla.InventoryScrollPacket @@ -20,7 +20,6 @@ import ru.dbotthepony.mc.otm.menu.data.StackAddPacket import ru.dbotthepony.mc.otm.menu.data.StackChangePacket import ru.dbotthepony.mc.otm.menu.data.StackRemovePacket import java.io.ByteArrayInputStream -import java.util.function.Supplier class MenuFieldPacket(val containerId: Int, val bytes: ByteArray, val length: Int) : MatteryPacket { constructor(containerId: Int, stream: FastByteArrayOutputStream) : this(containerId, stream.array, stream.length) @@ -30,18 +29,14 @@ class MenuFieldPacket(val containerId: Int, val bytes: ByteArray, val length: In buff.writeBytes(bytes, 0, length) } - override fun play(context: Supplier) { - context.packetHandled = true + override fun play(context: CustomPayloadEvent.Context) { + if (containerId == ExopackInventoryMenu.CONTAINER_ID) { + minecraft.player?.matteryPlayer?.exoPackMenu?.mSynchronizer?.read(ByteArrayInputStream(bytes, 0, length)) + } else { + val menu = minecraft.player?.containerMenu as? MatteryMenu ?: return - context.enqueueWork { - if (containerId == ExopackInventoryMenu.CONTAINER_ID) { - minecraft.player?.matteryPlayer?.exoPackMenu?.mSynchronizer?.read(ByteArrayInputStream(bytes, 0, length)) - } else { - val menu = minecraft.player?.containerMenu as? MatteryMenu ?: return@enqueueWork - - if (menu.containerId == containerId) - menu.mSynchronizer.read(ByteArrayInputStream(bytes, 0, length)) - } + if (menu.containerId == containerId) + menu.mSynchronizer.read(ByteArrayInputStream(bytes, 0, length)) } } @@ -59,9 +54,8 @@ class SetCarriedPacket(val item: ItemStack) : MatteryPacket { buff.writeItem(item) } - override fun play(context: Supplier) { - context.get().packetHandled = true - context.get().enqueueWork { minecraft.player?.containerMenu?.carried = item } + override fun play(context: CustomPayloadEvent.Context) { + minecraft.player?.containerMenu?.carried = item } companion object { @@ -72,7 +66,7 @@ class SetCarriedPacket(val item: ItemStack) : MatteryPacket { } object MenuNetworkChannel : MatteryNetworkChannel( - version = "4", + version = 5, name = "menu" ) { fun register() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/WeaponNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/WeaponNetworkChannel.kt index d879bed32..6c54049f6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/WeaponNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/WeaponNetworkChannel.kt @@ -5,7 +5,7 @@ import ru.dbotthepony.mc.otm.item.weapon.WeaponFireInputPacket import ru.dbotthepony.mc.otm.item.weapon.WeaponScopePacket object WeaponNetworkChannel : MatteryNetworkChannel( - version = "2", + version = 3, name = "weapon" ) { fun register() { 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 0a39fa492..5884c0dc7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/EnergyContainerRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/EnergyContainerRecipe.kt @@ -1,6 +1,7 @@ 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 @@ -20,6 +21,8 @@ import ru.dbotthepony.mc.otm.capability.iterator import ru.dbotthepony.mc.otm.container.util.iterator import ru.dbotthepony.mc.otm.container.util.stream import ru.dbotthepony.mc.otm.core.filterNotNull +import ru.dbotthepony.mc.otm.core.fromJson +import ru.dbotthepony.mc.otm.core.fromJsonStrict class EnergyContainerRecipe(val parent: ShapedRecipe) : CraftingRecipe, IShapedRecipe by parent { override fun canCraftInDimensions(p_43999_: Int, p_44000_: Int): Boolean { @@ -30,10 +33,6 @@ class EnergyContainerRecipe(val parent: ShapedRecipe) : CraftingRecipe, IShapedR return parent.getResultItem(p_267052_) } - override fun getId(): ResourceLocation { - return parent.id - } - override fun category(): CraftingBookCategory { return parent.category() } @@ -105,12 +104,16 @@ class EnergyContainerRecipe(val parent: ShapedRecipe) : CraftingRecipe, IShapedR } companion object : RecipeSerializer { - override fun fromJson(id: ResourceLocation, data: JsonObject): EnergyContainerRecipe { - return EnergyContainerRecipe(ShapedRecipe.Serializer.SHAPED_RECIPE.fromJson(id, data)) + private val codec by lazy { + RecipeSerializer.SHAPED_RECIPE.codec().xmap(::EnergyContainerRecipe, EnergyContainerRecipe::parent) } - override fun fromNetwork(id: ResourceLocation, data: FriendlyByteBuf): EnergyContainerRecipe? { - return ShapedRecipe.Serializer.SHAPED_RECIPE.fromNetwork(id, data)?.let(::EnergyContainerRecipe) + override fun codec(): Codec { + return codec + } + + override fun fromNetwork(data: FriendlyByteBuf): EnergyContainerRecipe? { + return ShapedRecipe.Serializer.SHAPED_RECIPE.fromNetwork(data)?.let(::EnergyContainerRecipe) } override fun toNetwork(buff: FriendlyByteBuf, value: EnergyContainerRecipe) { 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 fdc09fba8..884138e00 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/ExplosiveHammerPrimingRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/ExplosiveHammerPrimingRecipe.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.recipe import com.google.gson.JsonObject import com.google.gson.JsonSyntaxException +import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.core.NonNullList import net.minecraft.core.RegistryAccess import net.minecraft.data.recipes.FinishedRecipe @@ -19,18 +20,15 @@ import ru.dbotthepony.mc.otm.container.util.stream import ru.dbotthepony.mc.otm.core.isActuallyEmpty import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.data.Codec2RecipeSerializer import ru.dbotthepony.mc.otm.item.tool.ExplosiveHammerItem import ru.dbotthepony.mc.otm.registry.MItems -class ExplosiveHammerPrimingRecipe(private val _id: ResourceLocation, val payload: Ingredient) : CraftingRecipe { +class ExplosiveHammerPrimingRecipe(val payload: Ingredient) : CraftingRecipe { override fun isIncomplete(): Boolean { return payload.isActuallyEmpty } - override fun getId(): ResourceLocation { - return _id - } - override fun isSpecial(): Boolean { return true } @@ -61,7 +59,7 @@ class ExplosiveHammerPrimingRecipe(private val _id: ResourceLocation, val payloa } override fun getSerializer(): RecipeSerializer<*> { - return Companion + return CODEC } override fun category(): CraftingBookCategory { @@ -72,39 +70,15 @@ class ExplosiveHammerPrimingRecipe(private val _id: ResourceLocation, val payloa return NonNullList.of(Ingredient.of(), Ingredient.of(MItems.EXPLOSIVE_HAMMER), Ingredient.of(Tags.Items.GUNPOWDER), payload) } - val finishedRecipe = object : FinishedRecipe { - override fun serializeRecipeData(pJson: JsonObject) { - pJson["payload"] = payload.toJson() - } + fun toFinished(id: ResourceLocation) = CODEC.toFinished(this, id) - override fun getId(): ResourceLocation { - return _id - } - - override fun getType(): RecipeSerializer<*> { - return Companion - } - - override fun serializeAdvancement(): JsonObject? { - return null - } - - override fun getAdvancementId(): ResourceLocation? { - return null - } - } - - companion object : RecipeSerializer { - override fun fromJson(pRecipeId: ResourceLocation, pSerializedRecipe: JsonObject): ExplosiveHammerPrimingRecipe { - return ExplosiveHammerPrimingRecipe(pRecipeId, Ingredient.fromJson(pSerializedRecipe["payload"] ?: throw JsonSyntaxException("Missing `payload` from hammer priming recipe in $pRecipeId"))) - } - - override fun fromNetwork(pRecipeId: ResourceLocation, pBuffer: FriendlyByteBuf): ExplosiveHammerPrimingRecipe { - return ExplosiveHammerPrimingRecipe(pRecipeId, Ingredient.fromNetwork(pBuffer)) - } - - override fun toNetwork(pBuffer: FriendlyByteBuf, pRecipe: ExplosiveHammerPrimingRecipe) { - pRecipe.payload.toNetwork(pBuffer) + companion object { + val CODEC = Codec2RecipeSerializer { p -> + RecordCodecBuilder.create { + it.group( + p.ingredients.fieldOf("payload").forGetter(ExplosiveHammerPrimingRecipe::payload) + ).apply(it, ::ExplosiveHammerPrimingRecipe) + } } } } 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 375ed8c4e..c038932a2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt @@ -41,7 +41,6 @@ interface IMatterEntanglerRecipe : IMatteryRecipe { } open class MatterEntanglerRecipe( - private val id: ResourceLocation, override val ingredients: IIngredientMatrix, override val matter: Decimal, override val ticks: Double, @@ -73,10 +72,6 @@ open class MatterEntanglerRecipe( return result } - override fun getId(): ResourceLocation { - return id - } - override fun getSerializer(): RecipeSerializer<*> { return SERIALIZER } @@ -97,8 +92,8 @@ open class MatterEntanglerRecipe( return true } - fun toFinished(): FinishedRecipe { - return SERIALIZER.toFinished(this) + fun toFinished(id: ResourceLocation): FinishedRecipe { + return SERIALIZER.toFinished(this, id) } fun energetic() = Energy(this) @@ -113,8 +108,8 @@ open class MatterEntanglerRecipe( } } - fun toFinished(): FinishedRecipe { - return ENERGY_SERIALIZER.toFinished(this) + fun toFinished(id: ResourceLocation): FinishedRecipe { + return ENERGY_SERIALIZER.toFinished(this, id) } override fun getSerializer(): RecipeSerializer<*> { @@ -131,8 +126,8 @@ open class MatterEntanglerRecipe( } } - fun toFinished(): FinishedRecipe { - return MATTER_SERIALIZER.toFinished(this) + fun toFinished(id: ResourceLocation): FinishedRecipe { + return MATTER_SERIALIZER.toFinished(this, id) } override fun getSerializer(): RecipeSerializer<*> { @@ -150,7 +145,7 @@ open class MatterEntanglerRecipe( ItemStack.CODEC.fieldOf("result").forGetter(MatterEntanglerRecipe::result), Codec.STRING.optionalFieldOf("uuidKey", "uuid").forGetter(MatterEntanglerRecipe::uuidKey), UUIDUtil.STRING_CODEC.optionalFieldOf("fixedUuid").forGetter(MatterEntanglerRecipe::fixedUuid) - ).apply(it) { a, b, c, d, e, f -> MatterEntanglerRecipe(context.id, a, b, c, d, e, f) } + ).apply(it, ::MatterEntanglerRecipe) } } 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 cfc89caf4..8adc962ed 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt @@ -14,14 +14,12 @@ import net.minecraft.world.item.crafting.Recipe import net.minecraft.world.item.crafting.RecipeSerializer import net.minecraft.world.item.crafting.RecipeType import net.minecraft.world.level.Level -import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.block.entity.decorative.PainterBlockEntity import ru.dbotthepony.mc.otm.container.get import ru.dbotthepony.mc.otm.core.isActuallyEmpty import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.tagNotNull import ru.dbotthepony.mc.otm.data.Codec2RecipeSerializer -import ru.dbotthepony.mc.otm.data.IngredientCodec import ru.dbotthepony.mc.otm.data.PredicatedCodecList import ru.dbotthepony.mc.otm.data.minRange import ru.dbotthepony.mc.otm.registry.MRecipes @@ -29,17 +27,15 @@ import java.util.EnumMap import java.util.function.Predicate class PainterRecipe( - private val id: ResourceLocation, val input: Ingredient, val output: ItemStack, val dyes: Map ) : Recipe { constructor( - id: ResourceLocation, input: Ingredient, output: ItemStack, dyes: Set - ) : this(id, input, output, dyes.associateWith { 1 }) + ) : this(input, output, dyes.associateWith { 1 }) fun canCraft(storedDyes: Map): Boolean { if (isIncomplete) return false @@ -96,10 +92,6 @@ class PainterRecipe( return output } - override fun getId(): ResourceLocation { - return id - } - override fun getSerializer(): RecipeSerializer<*> { return SERIALIZER } @@ -108,8 +100,8 @@ class PainterRecipe( return MRecipes.PAINTER } - fun toFinished(): FinishedRecipe { - return SERIALIZER.toFinished(this) + fun toFinished(id: ResourceLocation): FinishedRecipe { + return SERIALIZER.toFinished(this, id) } companion object { @@ -123,7 +115,7 @@ class PainterRecipe( Codec.list(DyeColor.CODEC).xmap({ it.associateWith { 1 } }, { ArrayList(it.keys) }) to Predicate { it.values.all { it == 1 } }, Codec.unboundedMap(DyeColor.CODEC, Codec.INT.minRange(1)) to Predicate { true } ).fieldOf("dyes").forGetter(PainterRecipe::dyes), - ).apply(it) { a, b, c -> PainterRecipe(context.id, a, b, c) } + ).apply(it, ::PainterRecipe) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt index 6ad1dcdb8..5bf5eca8b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt @@ -20,11 +20,9 @@ import ru.dbotthepony.mc.otm.core.isActuallyEmpty import ru.dbotthepony.mc.otm.registry.MRecipes import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.data.Codec2RecipeSerializer -import ru.dbotthepony.mc.otm.data.IngredientCodec import ru.dbotthepony.mc.otm.data.minRange class PlatePressRecipe( - private val id: ResourceLocation, val input: Ingredient, val output: Ingredient, val count: Int = 1, @@ -70,15 +68,13 @@ class PlatePressRecipe( override fun canCraftInDimensions(p_43999_: Int, p_44000_: Int) = true override fun getResultItem(registry: RegistryAccess): ItemStack = outputStack - override fun getId() = id - override fun getSerializer(): RecipeSerializer<*> { return SERIALIZER } override fun getType(): RecipeType = MRecipes.PLATE_PRESS - fun toFinished() = SERIALIZER.toFinished(this) + fun toFinished(id: ResourceLocation) = SERIALIZER.toFinished(this, id) companion object { val SERIALIZER = Codec2RecipeSerializer { context -> @@ -89,7 +85,7 @@ class PlatePressRecipe( Codec.INT.minRange(1).optionalFieldOf("count", 1).forGetter(PlatePressRecipe::count), Codec.INT.minRange(0).optionalFieldOf("workTime", 200).forGetter(PlatePressRecipe::workTime), FloatProvider.CODEC.optionalFieldOf("experience", ConstantFloat.ZERO).forGetter(PlatePressRecipe::experience) - ).apply(it) { a, b, c, d, e -> PlatePressRecipe(context.id, a, b, c, d, e) } + ).apply(it, ::PlatePressRecipe) } } } 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 5b55ed793..c5f969c7a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt @@ -3,12 +3,15 @@ package ru.dbotthepony.mc.otm.recipe import com.google.common.collect.ImmutableList import com.google.gson.JsonObject import com.google.gson.JsonPrimitive +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.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation import net.minecraft.util.GsonHelper +import net.minecraft.util.StringRepresentable import net.minecraft.world.inventory.CraftingContainer import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.CraftingBookCategory @@ -27,6 +30,7 @@ import ru.dbotthepony.mc.otm.core.tagNotNull import ru.dbotthepony.mc.otm.core.util.readBinaryJson import ru.dbotthepony.mc.otm.core.util.writeBinaryJson import ru.dbotthepony.mc.otm.core.collect.stream +import ru.dbotthepony.mc.otm.data.Codec2RecipeSerializer import java.util.stream.Stream class UpgradeRecipe( @@ -34,6 +38,8 @@ class UpgradeRecipe( copyPaths: Stream, val source: ResourceLocation, ) : CraftingRecipe, IShapedRecipe by parent { + constructor(parent: ShapedRecipe, copyPaths: Collection, source: ResourceLocation) : this(parent, copyPaths.stream(), source) + override fun matches(p_44002_: CraftingContainer, p_44003_: Level): Boolean { return parent.matches(p_44002_, p_44003_) } @@ -70,10 +76,6 @@ class UpgradeRecipe( return parent.toastSymbol } - override fun getId(): ResourceLocation { - return parent.id - } - override fun isIncomplete(): Boolean { return parent.isIncomplete } @@ -86,42 +88,39 @@ class UpgradeRecipe( return parent.category() } - enum class OpType { + enum class OpType : StringRepresentable { DIRECT { - override fun deserialize(obj: JsonObject): Op { - return Direct(GsonHelper.getAsString(obj, "path")) + override val codec: Codec = RecordCodecBuilder.create { + it.group( + Codec.STRING.fieldOf("path").forGetter(Direct::path) + ).apply(it, ::Direct) } }, INDIRECT { - override fun deserialize(obj: JsonObject): Op { - return Indirect(GsonHelper.getAsString(obj, "source"), GsonHelper.getAsString(obj, "destination")) + override val codec: Codec = RecordCodecBuilder.create { + it.group( + Codec.STRING.fieldOf("source").forGetter(Indirect::pathSource), + Codec.STRING.fieldOf("destination").forGetter(Indirect::pathDestination), + ).apply(it, ::Indirect) } }; - abstract fun deserialize(obj: JsonObject): Op - } - - interface Op { - val type: OpType - fun apply(source: CompoundTag, destination: CompoundTag) - fun serialize(json: JsonObject) - - fun serialize(): JsonObject { - return JsonObject().also { - it["type"] = JsonPrimitive(type.name) - serialize(it) - } + override fun getSerializedName(): String { + return name.lowercase() } + + abstract val codec: Codec } - data class Direct(val path: String) : Op { + sealed class Op { + abstract val type: OpType + abstract fun apply(source: CompoundTag, destination: CompoundTag) + } + + data class Direct(val path: String) : Op() { private val split = path.split('.') override val type: OpType get() = OpType.DIRECT - override fun serialize(json: JsonObject) { - json["path"] = JsonPrimitive("path") - } - override fun apply(source: CompoundTag, destination: CompoundTag) { var a = source var b = destination @@ -149,18 +148,13 @@ class UpgradeRecipe( } } - data class Indirect(val pathSource: String, val pathDestination: String) : Op { + data class Indirect(val pathSource: String, val pathDestination: String) : Op() { private val splitSource = pathSource.split('.') private val splitDestination = pathDestination.split('.') override val type: OpType get() = OpType.INDIRECT - override fun serialize(json: JsonObject) { - json["source"] = JsonPrimitive(pathSource) - json["destination"] = JsonPrimitive(pathDestination) - } - override fun apply(source: CompoundTag, destination: CompoundTag) { var a = source var b = destination @@ -219,36 +213,23 @@ class UpgradeRecipe( } override fun getSerializer(): RecipeSerializer { - return Companion + return CODEC } - companion object : RecipeSerializer { - fun deserializeOp(json: JsonObject): Op { - return OpType.valueOf(GsonHelper.getAsString(json, "type")).deserialize(json) - } + companion object { + val COPY_PATHS_CODEC: Codec> = StringRepresentable + .fromEnum(OpType::values) + .dispatch({ it.type }, { it.codec }) + .listOf() - override fun fromJson(id: ResourceLocation, data: JsonObject): UpgradeRecipe { - return UpgradeRecipe( - ShapedRecipe.Serializer.SHAPED_RECIPE.fromJson(id, data), - GsonHelper.getAsJsonArray(data, "copyPaths").stream().map { deserializeOp(it as JsonObject) }, - ResourceLocation(GsonHelper.getAsString(data, "source")) - ) - } - - override fun fromNetwork(id: ResourceLocation, buff: FriendlyByteBuf): UpgradeRecipe? { - val recipe = ShapedRecipe.Serializer.SHAPED_RECIPE.fromNetwork(id, buff) ?: return null - - return UpgradeRecipe( - recipe, - buff.readCollection({ ArrayList(it) }, { deserializeOp(it.readBinaryJson() as JsonObject) }).stream(), - buff.readResourceLocation() - ) - } - - override fun toNetwork(buff: FriendlyByteBuf, value: UpgradeRecipe) { - ShapedRecipe.Serializer.SHAPED_RECIPE.toNetwork(buff, value.parent) - buff.writeCollection(value.copyPaths) { it, v -> it.writeBinaryJson(v.serialize()) } - buff.writeResourceLocation(value.source) + val CODEC = Codec2RecipeSerializer { p -> + RecordCodecBuilder.create { + it.group( + p.wrap(ShapedRecipe.Serializer.SHAPED_RECIPE).fieldOf("parent").forGetter(UpgradeRecipe::parent), + COPY_PATHS_CODEC.fieldOf("copyPaths").forGetter(UpgradeRecipe::copyPaths), + ResourceLocation.CODEC.fieldOf("source").forGetter(UpgradeRecipe::source) + ).apply(it, ::UpgradeRecipe) + } } } } 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 10c680a92..16a3b4d89 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItemFunctionTypes.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItemFunctionTypes.kt @@ -12,9 +12,9 @@ import ru.dbotthepony.mc.otm.item.exopack.ProceduralExopackSlotUpgradeItem object MItemFunctionTypes { private val registry = DeferredRegister.create(Registries.LOOT_FUNCTION_TYPE, OverdriveThatMatters.MOD_ID) - val COPY_TILE_NBT: LootItemFunctionType by registry.register("copy_tile_nbt") { LootItemFunctionType(CopyTileNbtFunction.Companion) } - val PROCEDURAL_BATTERY: LootItemFunctionType by registry.register(MNames.PROCEDURAL_BATTERY) { LootItemFunctionType(ProceduralBatteryItem.Randomizer.SERIALIZER) } - val PROCEDURAL_EXOPACK_UPGRADE: LootItemFunctionType by registry.register("exopack_upgrade") { LootItemFunctionType(ProceduralExopackSlotUpgradeItem.Randomizer.SERIALIZER) } + 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) } + val PROCEDURAL_EXOPACK_UPGRADE: LootItemFunctionType by registry.register("exopack_upgrade") { LootItemFunctionType(ProceduralExopackSlotUpgradeItem.Randomizer.CODEC) } internal fun register(bus: IEventBus) { registry.register(bus) 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 9aac91ee7..0081a28ac 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MLootItemConditions.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MLootItemConditions.kt @@ -6,6 +6,7 @@ import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.registries.DeferredRegister import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.data.SingletonCodec import ru.dbotthepony.mc.otm.data.condition.ChanceWithPlaytimeCondition import ru.dbotthepony.mc.otm.data.condition.HasExoPackCondition import ru.dbotthepony.mc.otm.data.condition.ItemInInventoryCondition @@ -16,12 +17,12 @@ import ru.dbotthepony.mc.otm.data.condition.ChanceCondition object MLootItemConditions { private val registry = DeferredRegister.create(Registries.LOOT_CONDITION_TYPE, OverdriveThatMatters.MOD_ID) - val HAS_EXOPACK: LootItemConditionType by registry.register("has_exopack") { LootItemConditionType(HasExoPackCondition) } - val CHANCE_WITH_PLAYTIME: LootItemConditionType by registry.register("chance_with_playtime") { LootItemConditionType(ChanceWithPlaytimeCondition.SERIALIZER) } - val ITEM_IN_INVENTORY: LootItemConditionType by registry.register("item_in_inventory") { LootItemConditionType(ItemInInventoryCondition.SERIALIZER) } - val KILLED_BY_REAL_PLAYER: LootItemConditionType by registry.register("killed_by_real_player") { LootItemConditionType(KilledByRealPlayer) } - val KILLED_BY_REAL_PLAYER_OR_INDIRECTLY: LootItemConditionType by registry.register("killed_by_real_player_or_indirectly") { LootItemConditionType(KilledByRealPlayerOrIndirectly) } - val CHANCE: LootItemConditionType by registry.register("chance") { LootItemConditionType(ChanceCondition.SERIALIZER) } + val HAS_EXOPACK: LootItemConditionType by registry.register("has_exopack") { LootItemConditionType(SingletonCodec(HasExoPackCondition)) } + val CHANCE_WITH_PLAYTIME: LootItemConditionType by registry.register("chance_with_playtime") { LootItemConditionType(ChanceWithPlaytimeCondition.CODEC) } + val ITEM_IN_INVENTORY: LootItemConditionType by registry.register("item_in_inventory") { LootItemConditionType(ItemInInventoryCondition.CODEC) } + val KILLED_BY_REAL_PLAYER: LootItemConditionType by registry.register("killed_by_real_player") { LootItemConditionType(SingletonCodec(KilledByRealPlayer)) } + val KILLED_BY_REAL_PLAYER_OR_INDIRECTLY: LootItemConditionType by registry.register("killed_by_real_player_or_indirectly") { LootItemConditionType(SingletonCodec(KilledByRealPlayerOrIndirectly)) } + val CHANCE: LootItemConditionType by registry.register("chance") { LootItemConditionType(ChanceCondition.CODEC) } internal fun register(bus: IEventBus) { registry.register(bus) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt index e5f4b98ee..a9aae3183 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt @@ -45,8 +45,8 @@ object MRecipes { init { serializers.register("plate_press") { PlatePressRecipe.SERIALIZER } serializers.register("energy_container") { EnergyContainerRecipe.Companion } - serializers.register("upgrade") { UpgradeRecipe.Companion } - serializers.register("hammer_priming") { ExplosiveHammerPrimingRecipe.Companion } + serializers.register("upgrade") { UpgradeRecipe.CODEC } + serializers.register("hammer_priming") { ExplosiveHammerPrimingRecipe.CODEC } serializers.register("painter") { PainterRecipe.SERIALIZER } serializers.register("matter_entangler") { MatterEntanglerRecipe.SERIALIZER } serializers.register("matter_entangler_energetic") { MatterEntanglerRecipe.ENERGY_SERIALIZER } 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 b13877590..c99cc71ab 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -290,28 +290,28 @@ object MRegistry { private fun initializeCommon(event: FMLCommonSetupEvent) { event.enqueueWork { - CriteriaTriggers.register(BlackHoleTrigger) - CriteriaTriggers.register(BecomeAndroidTrigger) - CriteriaTriggers.register(BecomeAndroidDeathTrigger) - CriteriaTriggers.register(BecomeAndroidSleepTrigger) - CriteriaTriggers.register(BecomeHumaneTrigger) - CriteriaTriggers.register(AndroidResearchTrigger) - CriteriaTriggers.register(ShockwaveDamageMobTrigger) - CriteriaTriggers.register(ShockwaveTrigger) - CriteriaTriggers.register(AndroidBatteryTrigger) - CriteriaTriggers.register(NanobotsArmorTrigger) - CriteriaTriggers.register(FallDampenersSaveTrigger) - CriteriaTriggers.register(EnderTeleporterFallDeathTrigger) - CriteriaTriggers.register(KillAsAndroidTrigger) - CriteriaTriggers.register(AndroidTravelUnderwater) - CriteriaTriggers.register(NailedEntityTrigger) - CriteriaTriggers.register(ExopackObtainedTrigger) - CriteriaTriggers.register(ExopackGainedSmeltingTrigger) - CriteriaTriggers.register(ExopackGainedCraftingTrigger) - CriteriaTriggers.register(ExopackGainedEnderAccessTrigger) - CriteriaTriggers.register(ExopackSlotsExpandedTrigger) - CriteriaTriggers.register(ExopackBatterySlotTrigger) - CriteriaTriggers.register(TakeItemOutOfReplicatorTrigger) + CriteriaTriggers.register(BlackHoleTrigger.id.toString(), BlackHoleTrigger) + CriteriaTriggers.register(BecomeAndroidTrigger.id.toString(), BecomeAndroidTrigger) + CriteriaTriggers.register(BecomeAndroidDeathTrigger.id.toString(), BecomeAndroidDeathTrigger) + CriteriaTriggers.register(BecomeAndroidSleepTrigger.id.toString(), BecomeAndroidSleepTrigger) + CriteriaTriggers.register(BecomeHumaneTrigger.id.toString(), BecomeHumaneTrigger) + CriteriaTriggers.register(AndroidResearchTrigger.id.toString(), AndroidResearchTrigger) + CriteriaTriggers.register(ShockwaveDamageMobTrigger.id.toString(), ShockwaveDamageMobTrigger) + CriteriaTriggers.register(ShockwaveTrigger.id.toString(), ShockwaveTrigger) + CriteriaTriggers.register(AndroidBatteryTrigger.id.toString(), AndroidBatteryTrigger) + CriteriaTriggers.register(NanobotsArmorTrigger.id.toString(), NanobotsArmorTrigger) + CriteriaTriggers.register(FallDampenersSaveTrigger.id.toString(), FallDampenersSaveTrigger) + CriteriaTriggers.register(EnderTeleporterFallDeathTrigger.id.toString(), EnderTeleporterFallDeathTrigger) + CriteriaTriggers.register(KillAsAndroidTrigger.id.toString(), KillAsAndroidTrigger) + CriteriaTriggers.register(AndroidTravelUnderwater.id.toString(), AndroidTravelUnderwater) + CriteriaTriggers.register(NailedEntityTrigger.id.toString(), NailedEntityTrigger) + CriteriaTriggers.register(ExopackObtainedTrigger.id.toString(), ExopackObtainedTrigger) + CriteriaTriggers.register(ExopackGainedSmeltingTrigger.id.toString(), ExopackGainedSmeltingTrigger) + CriteriaTriggers.register(ExopackGainedCraftingTrigger.id.toString(), ExopackGainedCraftingTrigger) + CriteriaTriggers.register(ExopackGainedEnderAccessTrigger.id.toString(), ExopackGainedEnderAccessTrigger) + CriteriaTriggers.register(ExopackSlotsExpandedTrigger.id.toString(), ExopackSlotsExpandedTrigger) + CriteriaTriggers.register(ExopackBatterySlotTrigger.id.toString(), ExopackBatterySlotTrigger) + CriteriaTriggers.register(TakeItemOutOfReplicatorTrigger.id.toString(), TakeItemOutOfReplicatorTrigger) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidResearchTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidResearchTrigger.kt index 70086120d..33b43ba4c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidResearchTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidResearchTrigger.kt @@ -2,25 +2,22 @@ package ru.dbotthepony.mc.otm.triggers import com.google.gson.JsonObject import com.google.gson.JsonPrimitive +import net.minecraft.advancements.Criterion import net.minecraft.advancements.critereon.* import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.android.AndroidResearchType -import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.set +import java.util.Optional import java.util.function.Predicate object AndroidResearchTrigger : SimpleCriterionTrigger() { - val ID = ResourceLocation(OverdriveThatMatters.MOD_ID, "android_research") - - override fun getId(): ResourceLocation { - return ID - } + val id = ResourceLocation(OverdriveThatMatters.MOD_ID, "android_research") override fun createInstance( p_66248_: JsonObject, - p_286603_: ContextAwarePredicate, + p_286603_: Optional, p_66250_: DeserializationContext ): Instance { return Instance( @@ -34,18 +31,20 @@ object AndroidResearchTrigger : SimpleCriterionTrigger { + class Instance(val research: ResourceLocation?) : AbstractCriterionTriggerInstance(Optional.empty()), Predicate { constructor(research: AndroidResearchType) : this(research.id) override fun test(t: AndroidResearchType): Boolean { return research == null || t.id == research } - override fun serializeToJson(p_16979_: SerializationContext): JsonObject { - return super.serializeToJson(p_16979_).also { + override fun serializeToJson(): JsonObject { + return super.serializeToJson().also { if (research != null) it["research"] = JsonPrimitive(research.toString()) } } + + fun criterion() = Criterion(AndroidResearchTrigger, this) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidTravelUnderwater.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidTravelUnderwater.kt index 85fbc79e1..e6dd07ac4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidTravelUnderwater.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidTravelUnderwater.kt @@ -3,21 +3,24 @@ package ru.dbotthepony.mc.otm.triggers import com.google.gson.JsonObject import com.google.gson.JsonParseException import com.google.gson.JsonPrimitive +import com.mojang.serialization.Codec +import com.mojang.serialization.codecs.RecordCodecBuilder +import net.minecraft.advancements.Criterion import net.minecraft.advancements.critereon.* import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.toJsonStrict +import ru.dbotthepony.mc.otm.data.Codec2TriggerSerializer +import ru.dbotthepony.mc.otm.data.minRange +import java.util.Optional object AndroidTravelUnderwater : SimpleCriterionTrigger() { - val ID = ResourceLocation(OverdriveThatMatters.MOD_ID, "android_walk_underwater") + val id = ResourceLocation(OverdriveThatMatters.MOD_ID, "android_walk_underwater") - override fun getId(): ResourceLocation { - return ID - } - - override fun createInstance(pJson: JsonObject, pPlayer: ContextAwarePredicate, pContext: DeserializationContext): Instance { - return Instance((pJson["distance_to_travel"] as? JsonPrimitive)?.asDouble ?: throw JsonParseException("Invalid 'distance_to_travel' value")) + override fun createInstance(pJson: JsonObject, pPlayer: Optional, pContext: DeserializationContext): Instance { + return codec.fromJson(pJson, pPlayer, pContext) } fun trigger(player: ServerPlayer, travelled: Double) { @@ -26,11 +29,20 @@ object AndroidTravelUnderwater : SimpleCriterionTrigger { p -> + RecordCodecBuilder.create { + it.group( + Codec.DOUBLE.minRange(0.0).fieldOf("distanceToTravel").forGetter(Instance::distanceToTravel), + p.playerPredicate.forGetter { it.playerPredicate() } + ).apply(it, ::Instance) } } + + class Instance(val distanceToTravel: Double, playerPredicate: Optional = Optional.empty()) : AbstractCriterionTriggerInstance(playerPredicate) { + override fun serializeToJson(): JsonObject { + return codec.toJson(this) + } + + fun criterion() = Criterion(AndroidTravelUnderwater, this) + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ExopackTriggers.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ExopackTriggers.kt index ec3e399de..cd174710e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ExopackTriggers.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ExopackTriggers.kt @@ -3,16 +3,17 @@ package ru.dbotthepony.mc.otm.triggers import com.google.gson.JsonObject import com.mojang.serialization.Codec import com.mojang.serialization.codecs.RecordCodecBuilder +import net.minecraft.advancements.Criterion import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance import net.minecraft.advancements.critereon.ContextAwarePredicate import net.minecraft.advancements.critereon.DeserializationContext -import net.minecraft.advancements.critereon.SerializationContext import net.minecraft.advancements.critereon.SimpleCriterionTrigger import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.core.fromJsonStrict import ru.dbotthepony.mc.otm.core.toJsonStrict +import java.util.Optional val ExopackObtainedTrigger = SingletonTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "exopack_obtained")) val ExopackGainedCraftingTrigger = SingletonTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "exopack_gained_crafting")) @@ -22,11 +23,7 @@ val ExopackGainedEnderAccessTrigger = SingletonTrigger(ResourceLocation(Overdriv val ExopackBatterySlotTrigger = ItemTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "exopack_battery_slot")) object ExopackSlotsExpandedTrigger : SimpleCriterionTrigger() { - val ID = ResourceLocation(OverdriveThatMatters.MOD_ID, "exopack_expanded") - - override fun getId(): ResourceLocation { - return ID - } + val id = ResourceLocation(OverdriveThatMatters.MOD_ID, "exopack_expanded") val codec: Codec = RecordCodecBuilder.create { it.group( @@ -39,18 +36,20 @@ object ExopackSlotsExpandedTrigger : SimpleCriterionTrigger, p_66250_: DeserializationContext): Instance { return codec.fromJsonStrict(p_66248_) } - data class Instance(val minGained: Int = 0, val minTotal: Int = 0) : AbstractCriterionTriggerInstance(ID, ContextAwarePredicate.ANY) { + data class Instance(val minGained: Int = 0, val minTotal: Int = 0) : AbstractCriterionTriggerInstance(Optional.empty()) { init { require(minGained >= 0) { "Invalid minGained $minGained" } require(minTotal >= 0) { "Invalid minTotal $minTotal" } } - override fun serializeToJson(p_16979_: SerializationContext): JsonObject { + override fun serializeToJson(): JsonObject { return codec.toJsonStrict(this) as JsonObject } + + fun criterion() = Criterion(ExopackSlotsExpandedTrigger, this) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/HurtTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/HurtTrigger.kt index e3b797aaa..c07e5d7e5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/HurtTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/HurtTrigger.kt @@ -1,54 +1,62 @@ package ru.dbotthepony.mc.otm.triggers import com.google.gson.JsonObject +import com.mojang.serialization.codecs.RecordCodecBuilder +import net.minecraft.advancements.Criterion import net.minecraft.advancements.critereon.* import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import net.minecraft.world.damagesource.DamageSource import net.minecraft.world.entity.LivingEntity import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.data.Codec2TriggerSerializer +import ru.dbotthepony.mc.otm.data.DamagePredicateCodec +import java.util.Optional abstract class HurtTrigger : SimpleCriterionTrigger() { - abstract val ID: ResourceLocation + abstract val id: ResourceLocation - override fun getId(): ResourceLocation { - return ID - } - - override fun createInstance( + final override fun createInstance( p_66248_: JsonObject, - p_286603_: ContextAwarePredicate, + p_286603_: Optional, p_66250_: DeserializationContext ): Instance { - return Instance( - EntityPredicate.fromJson(p_66248_, "entity_predicate", p_66250_), - (p_66248_["damage"] as? JsonObject)?.let(DamagePredicate::fromJson) ?: DamagePredicate.ANY - ) + return codec.fromJson(p_66248_, p_286603_, p_66250_) } fun trigger(player: ServerPlayer, entity: LivingEntity, damage: Float, damageSource: DamageSource) { val context = EntityPredicate.createContext(player, entity) trigger(player) { - it.predicate.matches(context) && it.damagePredicate.matches(player, damageSource, damage, damage, false) + it.predicate.map { it.matches(context) }.orElse(true) && it.damagePredicate.map { it.matches(player, damageSource, damage, damage, false) }.orElse(true) + } + } + + val codec = Codec2TriggerSerializer { p -> + RecordCodecBuilder.create { + it.group( + p.awareContextCodec.optionalFieldOf("predicate").forGetter(Instance::predicate), + DamagePredicateCodec.optionalFieldOf("damagePredicate").forGetter(Instance::damagePredicate), + p.playerPredicate.forGetter { it.playerPredicate() } + ).apply(it, ::Instance) } } inner class Instance( - val predicate: ContextAwarePredicate = ContextAwarePredicate.ANY, - val damagePredicate: DamagePredicate = DamagePredicate( + val predicate: Optional = Optional.empty(), + val damagePredicate: Optional = Optional.of(DamagePredicate( MinMaxBounds.Doubles.atLeast(1.0), MinMaxBounds.Doubles.atLeast(1.0), - EntityPredicate.ANY, - null, - DamageSourcePredicate.ANY - ) - ) : AbstractCriterionTriggerInstance(ID, ContextAwarePredicate.ANY) { - override fun serializeToJson(pConditions: SerializationContext): JsonObject { - return super.serializeToJson(pConditions).also { - it["entity_predicate"] = predicate.toJson(pConditions) - it["damage"] = damagePredicate.serializeToJson() - } + Optional.empty(), + Optional.empty(), + Optional.empty() + )), + player: Optional = Optional.empty() + ) : AbstractCriterionTriggerInstance(player) { + override fun serializeToJson(): JsonObject { + return codec.toJson(this) } + + fun criterion() = Criterion(this@HurtTrigger, this) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ItemTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ItemTrigger.kt index 1b43b2356..f319bb05d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ItemTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ItemTrigger.kt @@ -3,42 +3,42 @@ package ru.dbotthepony.mc.otm.triggers import com.google.gson.JsonObject import com.mojang.serialization.Codec import com.mojang.serialization.codecs.RecordCodecBuilder +import net.minecraft.advancements.Criterion import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance import net.minecraft.advancements.critereon.ContextAwarePredicate import net.minecraft.advancements.critereon.DeserializationContext import net.minecraft.advancements.critereon.ItemPredicate -import net.minecraft.advancements.critereon.SerializationContext import net.minecraft.advancements.critereon.SimpleCriterionTrigger import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import net.minecraft.world.item.ItemStack -import ru.dbotthepony.mc.otm.core.fromJsonStrict -import ru.dbotthepony.mc.otm.core.toJsonStrict -import ru.dbotthepony.mc.otm.data.ItemPredicateCodec - -class ItemTrigger(val ID: ResourceLocation) : SimpleCriterionTrigger() { - override fun getId(): ResourceLocation { - return ID - } +import ru.dbotthepony.mc.otm.data.Codec2TriggerSerializer +import java.util.Optional +class ItemTrigger(val id: ResourceLocation) : SimpleCriterionTrigger() { fun trigger(player: ServerPlayer, item: ItemStack) { trigger(player) { if (it.invert) !it.predicate.matches(item) else it.predicate.matches(item) } } - val codec: Codec = RecordCodecBuilder.create { - it.group( - ItemPredicateCodec.fieldOf("predicate").forGetter(Instance::predicate), - Codec.BOOL.optionalFieldOf("invert", false).forGetter(Instance::invert), - ).apply(it, ::Instance) - } - - override fun createInstance(p_66248_: JsonObject, p_286603_: ContextAwarePredicate, p_66250_: DeserializationContext): Instance { - return codec.fromJsonStrict(p_66248_) - } - - inner class Instance(val predicate: ItemPredicate, val invert: Boolean = false) : AbstractCriterionTriggerInstance(ID, ContextAwarePredicate.ANY) { - override fun serializeToJson(p_16979_: SerializationContext): JsonObject { - return codec.toJsonStrict(this) as JsonObject + val codec = Codec2TriggerSerializer { p -> + RecordCodecBuilder.create { + it.group( + ItemPredicate.CODEC.fieldOf("predicate").forGetter(Instance::predicate), + Codec.BOOL.optionalFieldOf("invert", false).forGetter(Instance::invert), + p.playerPredicate.forGetter { it.playerPredicate() } + ).apply(it, ::Instance) } } + + override fun createInstance(p_66248_: JsonObject, p_286603_: Optional, p_66250_: DeserializationContext): Instance { + return codec.fromJson(p_66248_, p_286603_, p_66250_) + } + + inner class Instance(val predicate: ItemPredicate, val invert: Boolean = false, player: Optional = Optional.empty()) : AbstractCriterionTriggerInstance(player) { + override fun serializeToJson(): JsonObject { + return codec.toJson(this) + } + + fun criterion() = Criterion(this@ItemTrigger, this) + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/KillAsAndroidTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/KillAsAndroidTrigger.kt index a2041e68a..c78c2c040 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/KillAsAndroidTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/KillAsAndroidTrigger.kt @@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableList import com.google.gson.JsonArray import com.google.gson.JsonObject import com.google.gson.JsonSyntaxException +import net.minecraft.advancements.Criterion import net.minecraft.advancements.critereon.* import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer @@ -16,16 +17,13 @@ import ru.dbotthepony.mc.otm.core.asIterable import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.core.stream import ru.dbotthepony.mc.otm.registry.MRegistry +import java.util.Optional import java.util.function.Predicate object KillAsAndroidTrigger : SimpleCriterionTrigger() { - val ID = ResourceLocation(OverdriveThatMatters.MOD_ID, "kill_as_android") + val id = ResourceLocation(OverdriveThatMatters.MOD_ID, "kill_as_android") - override fun getId(): ResourceLocation { - return ID - } - - override fun createInstance(pJson: JsonObject, pPlayer: ContextAwarePredicate, pContext: DeserializationContext): Instance { + override fun createInstance(pJson: JsonObject, pPlayer: Optional, pContext: DeserializationContext): Instance { return Instance( predicate = EntityPredicate.fromJson(pJson, "predicate", pContext), playerPredicate = pPlayer, @@ -164,16 +162,18 @@ object KillAsAndroidTrigger : SimpleCriterionTrigger = Optional.empty(), val featurePredicate: FeaturePredicate = Always, - playerPredicate: ContextAwarePredicate = ContextAwarePredicate.ANY, - ) : AbstractCriterionTriggerInstance(ID, playerPredicate) { - override fun serializeToJson(pConditions: SerializationContext): JsonObject { - return super.serializeToJson(pConditions).also { - it["predicate"] = predicate.toJson(pConditions) + playerPredicate: Optional = Optional.empty(), + ) : AbstractCriterionTriggerInstance(playerPredicate) { + override fun serializeToJson(): JsonObject { + return super.serializeToJson().also { + predicate.ifPresent { p -> it["predicate"] = p.toJson() } it["feature_predicate"] = featurePredicate.toJson() } } + + fun criterion() = Criterion(KillAsAndroidTrigger, this) } fun onKill(event: LivingDeathEvent) { @@ -187,7 +187,7 @@ object KillAsAndroidTrigger : SimpleCriterionTrigger v == null || item.item == v }, { inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> mutableListOf(item.item) })) nodes.add(Node( DefaultStrategy, - { predicates.map { it.tag } }, - { v, inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> v == null || item.`is`(v) }, + { predicates.map { it.tag as Optional> } }, + { v, inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> v.isEmpty || item.`is`(v.get()) }, { inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> item.tags.collect(Collectors.toCollection(::ArrayList)) })) nodes.add(Node(BoundsStrategy, { predicates.map { it.count } }, { v, inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> v.matches(item.count) })) @@ -136,13 +140,13 @@ object MatteryInventoryChangeTrigger : CriterionTrigger) { if (set.add(listener)) { - search(listener.triggerInstance, tree, 0).forEach { it.add(listener) } + search(listener.trigger, tree, 0).forEach { it.add(listener) } } } fun remove(listener: CriterionTrigger.Listener) { if (set.remove(listener)) { - search(listener.triggerInstance, tree, 0).forEach { it.remove(listener) } + search(listener.trigger, tree, 0).forEach { it.remove(listener) } } } @@ -168,7 +172,7 @@ object MatteryInventoryChangeTrigger : CriterionTrigger>) { // переделываем matches у InventoryTriggerInstance - with (l.triggerInstance) { + with (l.trigger) { if ( this.slotsFull.matches(slotsFull) && this.slotsEmpty.matches(slotsEmpty) && @@ -212,10 +216,6 @@ object MatteryInventoryChangeTrigger : CriterionTrigger() - override fun getId(): ResourceLocation { - return CriteriaTriggers.INVENTORY_CHANGED.id - } - override fun addPlayerListener(advancements: PlayerAdvancements, instance: CriterionTrigger.Listener) { listeners.computeIfAbsent(advancements, Reference2ObjectFunction { ListenerTree(it as PlayerAdvancements) }).add(instance) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NailedEntityTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NailedEntityTrigger.kt index dfe36bca3..6414c8a1b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NailedEntityTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NailedEntityTrigger.kt @@ -4,5 +4,5 @@ import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.OverdriveThatMatters object NailedEntityTrigger : HurtTrigger() { - override val ID = ResourceLocation(OverdriveThatMatters.MOD_ID, "hammer_nail_damage") + override val id = ResourceLocation(OverdriveThatMatters.MOD_ID, "hammer_nail_damage") } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NanobotsArmorTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NanobotsArmorTrigger.kt index e60aa149f..e5ef672e2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NanobotsArmorTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NanobotsArmorTrigger.kt @@ -1,40 +1,45 @@ package ru.dbotthepony.mc.otm.triggers import com.google.gson.JsonObject +import com.mojang.serialization.codecs.RecordCodecBuilder +import net.minecraft.advancements.Criterion import net.minecraft.advancements.critereon.* import net.minecraft.advancements.critereon.MinMaxBounds.Doubles import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.data.Codec2TriggerSerializer +import java.util.Optional object NanobotsArmorTrigger : SimpleCriterionTrigger() { - val ID = ResourceLocation(OverdriveThatMatters.MOD_ID, "nanobots_armor") - - override fun getId(): ResourceLocation { - return ID - } + val id = ResourceLocation(OverdriveThatMatters.MOD_ID, "nanobots_armor") override fun createInstance( p_66248_: JsonObject, - p_286603_: ContextAwarePredicate, + p_286603_: Optional, p_66250_: DeserializationContext ): Instance { - return Instance( - Doubles.fromJson(p_66248_["predicate"]) - ) + return codec.fromJson(p_66248_, p_286603_, p_66250_) + } + + val codec = Codec2TriggerSerializer { p -> + RecordCodecBuilder.create { + it.group( + Doubles.CODEC.fieldOf("predicate").forGetter(Instance::predicate), + p.playerPredicate.forGetter { it.playerPredicate() }, + ).apply(it, ::Instance) + } } fun trigger(player: ServerPlayer, damageAbsorbed: Double) { trigger(player) { it.predicate.matches(damageAbsorbed) } } - class Instance(val predicate: Doubles) : AbstractCriterionTriggerInstance(ID, ContextAwarePredicate.ANY) { - override fun serializeToJson(p_16979_: SerializationContext): JsonObject { - return super.serializeToJson(p_16979_).also { - it["predicate"] = predicate.serializeToJson() - } + class Instance(val predicate: Doubles, player: Optional = Optional.empty()) : AbstractCriterionTriggerInstance(player) { + override fun serializeToJson(): JsonObject { + return codec.toJson((this)) } + + fun criterion() = Criterion(NanobotsArmorTrigger, this) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ShockwaveDamageMobTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ShockwaveDamageMobTrigger.kt index 55808cc84..7f8727b2e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ShockwaveDamageMobTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ShockwaveDamageMobTrigger.kt @@ -4,5 +4,5 @@ import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.OverdriveThatMatters object ShockwaveDamageMobTrigger : HurtTrigger() { - override val ID = ResourceLocation(OverdriveThatMatters.MOD_ID, "shockwave_damage_mob") + override val id = ResourceLocation(OverdriveThatMatters.MOD_ID, "shockwave_damage_mob") } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/SingletonTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/SingletonTrigger.kt index c555138d1..04f447a65 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/SingletonTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/SingletonTrigger.kt @@ -1,25 +1,42 @@ package ru.dbotthepony.mc.otm.triggers import com.google.gson.JsonObject +import com.mojang.serialization.codecs.RecordCodecBuilder +import net.minecraft.advancements.Criterion import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance import net.minecraft.advancements.critereon.ContextAwarePredicate import net.minecraft.advancements.critereon.DeserializationContext import net.minecraft.advancements.critereon.SimpleCriterionTrigger import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer +import ru.dbotthepony.mc.otm.data.Codec2TriggerSerializer +import java.util.Optional -class SingletonTrigger(val ID: ResourceLocation) : SimpleCriterionTrigger() { - override fun getId(): ResourceLocation { - return ID - } - - override fun createInstance(p_66248_: JsonObject, p_286603_: ContextAwarePredicate, p_66250_: DeserializationContext): AbstractCriterionTriggerInstance { - return instance +class SingletonTrigger(val id: ResourceLocation) : SimpleCriterionTrigger() { + override fun createInstance(p_66248_: JsonObject, p_286603_: Optional, p_66250_: DeserializationContext): AbstractCriterionTriggerInstance { + return codec.fromJson(p_66248_, p_286603_, p_66250_) } fun trigger(player: ServerPlayer) { trigger(player) { true } } - val instance = object : AbstractCriterionTriggerInstance(ID, ContextAwarePredicate.ANY) {} + val codec = Codec2TriggerSerializer { p -> + RecordCodecBuilder.create { + it.group( + p.playerPredicate.forGetter { it.playerPredicate() } + ).apply(it, ::Instance) + } + } + + val empty = Instance() + val criterion = Criterion(this@SingletonTrigger, empty) + + inner class Instance(player: Optional = Optional.empty()) : AbstractCriterionTriggerInstance(player) { + override fun serializeToJson(): JsonObject { + return codec.toJson(this) + } + + fun criterion() = Criterion(this@SingletonTrigger, this) + } } diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index c7b31cf87..b97fad5c6 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -52,33 +52,6 @@ protected net.minecraft.client.resources.TextureAtlasHolder f_118884_ # textureA public net.minecraft.client.renderer.RenderStateShard f_110133_ # name -public com.mojang.math.Matrix4f f_27603_ # m00 -public com.mojang.math.Matrix4f f_27604_ # m01 -public com.mojang.math.Matrix4f f_27605_ # m02 -public com.mojang.math.Matrix4f f_27606_ # m03 -public com.mojang.math.Matrix4f f_27607_ # m10 -public com.mojang.math.Matrix4f f_27608_ # m11 -public com.mojang.math.Matrix4f f_27609_ # m12 -public com.mojang.math.Matrix4f f_27610_ # m13 -public com.mojang.math.Matrix4f f_27611_ # m20 -public com.mojang.math.Matrix4f f_27612_ # m21 -public com.mojang.math.Matrix4f f_27613_ # m22 -public com.mojang.math.Matrix4f f_27614_ # m23 -public com.mojang.math.Matrix4f f_27615_ # m30 -public com.mojang.math.Matrix4f f_27616_ # m31 -public com.mojang.math.Matrix4f f_27617_ # m32 -public com.mojang.math.Matrix4f f_27618_ # m33 - -public com.mojang.math.Matrix3f f_8134_ # m00 -public com.mojang.math.Matrix3f f_8135_ # m01 -public com.mojang.math.Matrix3f f_8136_ # m02 -public com.mojang.math.Matrix3f f_8137_ # m10 -public com.mojang.math.Matrix3f f_8138_ # m11 -public com.mojang.math.Matrix3f f_8139_ # m12 -public com.mojang.math.Matrix3f f_8140_ # m20 -public com.mojang.math.Matrix3f f_8141_ # m21 -public com.mojang.math.Matrix3f f_8142_ # m22 - public-f net.minecraft.world.inventory.Slot f_40220_ # x public-f net.minecraft.world.inventory.Slot f_40221_ # y @@ -194,12 +167,3 @@ public net.minecraft.advancements.critereon.InventoryChangeTrigger$TriggerInstan #public-f net.minecraft.advancements.critereon.SimpleCriterionTrigger m_6467_(Lnet/minecraft/server/PlayerAdvancements;Lnet/minecraft/advancements/CriterionTrigger$Listener;)V # addPlayerListener #public-f net.minecraft.advancements.critereon.SimpleCriterionTrigger m_6468_(Lnet/minecraft/server/PlayerAdvancements;Lnet/minecraft/advancements/CriterionTrigger$Listener;)V # removePlayerListener #public-f net.minecraft.advancements.critereon.SimpleCriterionTrigger m_5656_(Lnet/minecraft/server/PlayerAdvancements;)V # removePlayerListeners - -public net.minecraft.advancements.critereon.ItemPredicate f_45031_ -public net.minecraft.advancements.critereon.ItemPredicate f_45032_ -public net.minecraft.advancements.critereon.ItemPredicate f_45033_ -public net.minecraft.advancements.critereon.ItemPredicate f_151427_ -public net.minecraft.advancements.critereon.ItemPredicate f_45036_ -public net.minecraft.advancements.critereon.ItemPredicate f_45035_ -public net.minecraft.advancements.critereon.ItemPredicate f_45034_ -public net.minecraft.advancements.critereon.ItemPredicate f_45029_ diff --git a/src/main/resources/overdrive_that_matters.mixins.json b/src/main/resources/overdrive_that_matters.mixins.json index b812f9335..aa7271058 100644 --- a/src/main/resources/overdrive_that_matters.mixins.json +++ b/src/main/resources/overdrive_that_matters.mixins.json @@ -17,7 +17,8 @@ "InventoryChangeTriggerMixin", "MixinPlayer", "HopperBlockEntityMixin", - "DispenserBlockEntityMixin" + "DispenserBlockEntityMixin", + "GuiGraphicsMixin" ], "client": [ "MixinGameRenderer", From 187038c5e3da044f758c0767da587fbaa0d04596 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 8 Oct 2023 09:53:47 +0700 Subject: [PATCH 1049/1199] Bump forge to 48.0.19, remove fakeplayer references --- gradle.properties | 2 +- src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt | 2 +- .../mc/otm/data/condition/KilledByRealPlayer.kt | 3 +-- .../otm/data/condition/KilledByRealPlayerOrIndirectly.kt | 7 +++---- src/main/kotlin/ru/dbotthepony/mc/otm/item/PillItem.kt | 8 -------- 5 files changed, 6 insertions(+), 16 deletions(-) diff --git a/gradle.properties b/gradle.properties index e1d06d4ee..8bdeaf483 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,7 +15,7 @@ jei_mc_version=1.20.2 curios_mc_version=1.20 forge_gradle_version=[6.0,6.2) -forge_version=48.0.13 +forge_version=48.0.19 mixingradle_version=0.7.33 mixin_version=0.8.5 diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt index 34bf066b0..7ad4a8c11 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -545,7 +545,7 @@ object DataGen { trapdoor(MBlocks.TRITANIUM_TRAPDOOR[null]!!, modLocation("block/decorative/tritanium_trapdoor")) - for (color in DyeColor.values()) + for (color in DyeColor.entries) trapdoor(MBlocks.TRITANIUM_TRAPDOOR[color]!!, modLocation("block/decorative/tritanium_trapdoor_${color.name.lowercase()}")) addBlockModels(blockModelProvider) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/KilledByRealPlayer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/KilledByRealPlayer.kt index 281edcf4a..ad0cc9dfc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/KilledByRealPlayer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/KilledByRealPlayer.kt @@ -5,13 +5,12 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParams import net.minecraft.world.level.storage.loot.predicates.InvertedLootItemCondition import net.minecraft.world.level.storage.loot.predicates.LootItemCondition import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType -import net.minecraftforge.common.util.FakePlayer import ru.dbotthepony.mc.otm.data.get import ru.dbotthepony.mc.otm.registry.MLootItemConditions object KilledByRealPlayer : LootItemCondition, LootItemCondition.Builder { override fun test(t: LootContext): Boolean { - return t.hasParam(LootContextParams.LAST_DAMAGE_PLAYER) && t[LootContextParams.LAST_DAMAGE_PLAYER] !is FakePlayer + return t.hasParam(LootContextParams.LAST_DAMAGE_PLAYER) //&& t[LootContextParams.LAST_DAMAGE_PLAYER] !is FakePlayer } override fun getType(): LootItemConditionType { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/KilledByRealPlayerOrIndirectly.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/KilledByRealPlayerOrIndirectly.kt index 7fe2d7340..b181ada7a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/KilledByRealPlayerOrIndirectly.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/condition/KilledByRealPlayerOrIndirectly.kt @@ -6,14 +6,13 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParams import net.minecraft.world.level.storage.loot.predicates.InvertedLootItemCondition import net.minecraft.world.level.storage.loot.predicates.LootItemCondition import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType -import net.minecraftforge.common.util.FakePlayer import ru.dbotthepony.mc.otm.NULLABLE_MINECRAFT_SERVER import ru.dbotthepony.mc.otm.data.get import ru.dbotthepony.mc.otm.registry.MLootItemConditions object KilledByRealPlayerOrIndirectly : LootItemCondition, LootItemCondition.Builder { override fun test(t: LootContext): Boolean { - if (t.hasParam(LootContextParams.LAST_DAMAGE_PLAYER) && t[LootContextParams.LAST_DAMAGE_PLAYER] !is FakePlayer) { + if (t.hasParam(LootContextParams.LAST_DAMAGE_PLAYER) /*&& t[LootContextParams.LAST_DAMAGE_PLAYER] !is FakePlayer*/) { return true } @@ -23,12 +22,12 @@ object KilledByRealPlayerOrIndirectly : LootItemCondition, LootItemCondition.Bui if (killer != null) { val owner = killer.owner - if (owner != null && owner !is FakePlayer) { + if (owner != null /*&& owner !is FakePlayer*/) { return true } val ply = NULLABLE_MINECRAFT_SERVER?.playerList?.getPlayer(killer.ownerUUID ?: return false) - return ply != null && ply !is FakePlayer + return ply != null //&& ply !is FakePlayer } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PillItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PillItem.kt index 9c50f7654..3fc956300 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/PillItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/PillItem.kt @@ -11,8 +11,6 @@ import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.player.Player import net.minecraft.world.item.* import net.minecraft.world.level.Level -import net.minecraftforge.common.util.FakePlayer -import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.capability.MatteryCapability @@ -92,9 +90,6 @@ class PillItem(val pillType: PillType) : } override fun use(level: Level, ply: Player, hand: InteractionHand): InteractionResultHolder { - if (ply is FakePlayer) - return super.use(level, ply, hand) - val resolver = ply.getCapability(MatteryCapability.MATTERY_PLAYER).resolve() if (resolver.isEmpty) @@ -115,9 +110,6 @@ class PillItem(val pillType: PillType) : } override fun finishUsingItem(stack: ItemStack, level: Level, ent: LivingEntity): ItemStack { - if (ent is FakePlayer) - super.finishUsingItem(stack, level, ent) - if (ent is Player) { val resolver = ent.getCapability(MatteryCapability.MATTERY_PLAYER).resolve() From 5b46fb96214c767691aa529b115b71057605c596 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 8 Oct 2023 10:00:33 +0700 Subject: [PATCH 1050/1199] Bump FG to 6.0.14 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 8bdeaf483..11260753e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,7 +14,7 @@ mc_version=1.20.2 jei_mc_version=1.20.2 curios_mc_version=1.20 -forge_gradle_version=[6.0,6.2) +forge_gradle_version=6.0.14 forge_version=48.0.19 mixingradle_version=0.7.33 mixin_version=0.8.5 From 363dc37cbd502986be87340b6d89010f7c1a27fd Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 9 Oct 2023 18:59:35 +0700 Subject: [PATCH 1051/1199] Bump forge to 48.0.20 --- build.gradle.kts | 2 +- gradle.properties | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 5c8c9131f..82603e92c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -160,7 +160,7 @@ dependencies { compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge-api:${jei_version}")) runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}")) - runtimeOnly(fg.deobf("ru.dbotthepony:particle-collider:0.4.5")) + // runtimeOnly(fg.deobf("ru.dbotthepony:particle-collider:0.4.5")) compileOnly(fg.deobf("curse.maven:jade-324717:${jade_id}")) //runtimeOnly(fg.deobf("curse.maven:configured-457570:${configured_id}")) diff --git a/gradle.properties b/gradle.properties index 11260753e..9d3da881b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,8 +14,8 @@ mc_version=1.20.2 jei_mc_version=1.20.2 curios_mc_version=1.20 -forge_gradle_version=6.0.14 -forge_version=48.0.19 +forge_gradle_version=[6.0.14,6.2) +forge_version=48.0.20 mixingradle_version=0.7.33 mixin_version=0.8.5 From d841a5fe1a68c04513103ebcef0d63aa36295e57 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 11 Oct 2023 16:20:57 +0700 Subject: [PATCH 1052/1199] Statically initialize criteria triggers --- .../dbotthepony/mc/otm/registry/MRegistry.kt | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) 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 c99cc71ab..2457b71f8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -286,33 +286,33 @@ object MRegistry { // call static constructors NanobotsArmorFeature.Companion EnderTeleporterFeature.Companion + + CriteriaTriggers.register(BlackHoleTrigger.id.toString(), BlackHoleTrigger) + CriteriaTriggers.register(BecomeAndroidTrigger.id.toString(), BecomeAndroidTrigger) + CriteriaTriggers.register(BecomeAndroidDeathTrigger.id.toString(), BecomeAndroidDeathTrigger) + CriteriaTriggers.register(BecomeAndroidSleepTrigger.id.toString(), BecomeAndroidSleepTrigger) + CriteriaTriggers.register(BecomeHumaneTrigger.id.toString(), BecomeHumaneTrigger) + CriteriaTriggers.register(AndroidResearchTrigger.id.toString(), AndroidResearchTrigger) + CriteriaTriggers.register(ShockwaveDamageMobTrigger.id.toString(), ShockwaveDamageMobTrigger) + CriteriaTriggers.register(ShockwaveTrigger.id.toString(), ShockwaveTrigger) + CriteriaTriggers.register(AndroidBatteryTrigger.id.toString(), AndroidBatteryTrigger) + CriteriaTriggers.register(NanobotsArmorTrigger.id.toString(), NanobotsArmorTrigger) + CriteriaTriggers.register(FallDampenersSaveTrigger.id.toString(), FallDampenersSaveTrigger) + CriteriaTriggers.register(EnderTeleporterFallDeathTrigger.id.toString(), EnderTeleporterFallDeathTrigger) + CriteriaTriggers.register(KillAsAndroidTrigger.id.toString(), KillAsAndroidTrigger) + CriteriaTriggers.register(AndroidTravelUnderwater.id.toString(), AndroidTravelUnderwater) + CriteriaTriggers.register(NailedEntityTrigger.id.toString(), NailedEntityTrigger) + CriteriaTriggers.register(ExopackObtainedTrigger.id.toString(), ExopackObtainedTrigger) + CriteriaTriggers.register(ExopackGainedSmeltingTrigger.id.toString(), ExopackGainedSmeltingTrigger) + CriteriaTriggers.register(ExopackGainedCraftingTrigger.id.toString(), ExopackGainedCraftingTrigger) + CriteriaTriggers.register(ExopackGainedEnderAccessTrigger.id.toString(), ExopackGainedEnderAccessTrigger) + CriteriaTriggers.register(ExopackSlotsExpandedTrigger.id.toString(), ExopackSlotsExpandedTrigger) + CriteriaTriggers.register(ExopackBatterySlotTrigger.id.toString(), ExopackBatterySlotTrigger) + CriteriaTriggers.register(TakeItemOutOfReplicatorTrigger.id.toString(), TakeItemOutOfReplicatorTrigger) } private fun initializeCommon(event: FMLCommonSetupEvent) { - event.enqueueWork { - CriteriaTriggers.register(BlackHoleTrigger.id.toString(), BlackHoleTrigger) - CriteriaTriggers.register(BecomeAndroidTrigger.id.toString(), BecomeAndroidTrigger) - CriteriaTriggers.register(BecomeAndroidDeathTrigger.id.toString(), BecomeAndroidDeathTrigger) - CriteriaTriggers.register(BecomeAndroidSleepTrigger.id.toString(), BecomeAndroidSleepTrigger) - CriteriaTriggers.register(BecomeHumaneTrigger.id.toString(), BecomeHumaneTrigger) - CriteriaTriggers.register(AndroidResearchTrigger.id.toString(), AndroidResearchTrigger) - CriteriaTriggers.register(ShockwaveDamageMobTrigger.id.toString(), ShockwaveDamageMobTrigger) - CriteriaTriggers.register(ShockwaveTrigger.id.toString(), ShockwaveTrigger) - CriteriaTriggers.register(AndroidBatteryTrigger.id.toString(), AndroidBatteryTrigger) - CriteriaTriggers.register(NanobotsArmorTrigger.id.toString(), NanobotsArmorTrigger) - CriteriaTriggers.register(FallDampenersSaveTrigger.id.toString(), FallDampenersSaveTrigger) - CriteriaTriggers.register(EnderTeleporterFallDeathTrigger.id.toString(), EnderTeleporterFallDeathTrigger) - CriteriaTriggers.register(KillAsAndroidTrigger.id.toString(), KillAsAndroidTrigger) - CriteriaTriggers.register(AndroidTravelUnderwater.id.toString(), AndroidTravelUnderwater) - CriteriaTriggers.register(NailedEntityTrigger.id.toString(), NailedEntityTrigger) - CriteriaTriggers.register(ExopackObtainedTrigger.id.toString(), ExopackObtainedTrigger) - CriteriaTriggers.register(ExopackGainedSmeltingTrigger.id.toString(), ExopackGainedSmeltingTrigger) - CriteriaTriggers.register(ExopackGainedCraftingTrigger.id.toString(), ExopackGainedCraftingTrigger) - CriteriaTriggers.register(ExopackGainedEnderAccessTrigger.id.toString(), ExopackGainedEnderAccessTrigger) - CriteriaTriggers.register(ExopackSlotsExpandedTrigger.id.toString(), ExopackSlotsExpandedTrigger) - CriteriaTriggers.register(ExopackBatterySlotTrigger.id.toString(), ExopackBatterySlotTrigger) - CriteriaTriggers.register(TakeItemOutOfReplicatorTrigger.id.toString(), TakeItemOutOfReplicatorTrigger) - } + } private fun initializeClient(event: FMLClientSetupEvent) { From aa513343a5e01da80a137a4040e16effce0a664d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 11 Oct 2023 17:40:21 +0700 Subject: [PATCH 1053/1199] Initial fixes for 1.20.2 --- .../dbotthepony/mc/otm/mixin/GuiGraphicsMixin.java | 4 +++- .../mc/otm/block/entity/blackhole/Explosions.kt | 3 ++- .../dbotthepony/mc/otm/client/render/RenderHelper.kt | 12 +++++++++--- .../mc/otm/client/screen/panels/EditablePanel.kt | 2 ++ .../otm/client/screen/panels/EntityRendererPanel.kt | 11 ++++------- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/GuiGraphicsMixin.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/GuiGraphicsMixin.java index 92ab70446..21986c504 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/GuiGraphicsMixin.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/GuiGraphicsMixin.java @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.mixin; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; @@ -13,7 +14,8 @@ import static ru.dbotthepony.mc.otm.client.render.RenderHelperKt.pushScissorRect public abstract class GuiGraphicsMixin { @Overwrite public void enableScissor(int x0, int y0, int x1, int y1) { - pushScissorRect(x0, y0, x1 - x0, y1 - y0); + double scale = Minecraft.getInstance().getWindow().getGuiScale(); + pushScissorRect((int) (scale * x0), (int) (scale * y0), (int) (scale * (x1 - x0)), (int) (scale * (y1 - y0))); } @Overwrite 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 44d9aa00e..ed6136dd2 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 @@ -6,6 +6,7 @@ import net.minecraft.nbt.DoubleTag import net.minecraft.nbt.ListTag import net.minecraft.nbt.Tag import net.minecraft.server.level.ServerLevel +import net.minecraft.util.datafix.DataFixTypes import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Explosion import net.minecraft.world.level.ExplosionDamageCalculator @@ -671,7 +672,7 @@ class ExplosionQueue(private val level: ServerLevel) : SavedData() { val factory = ExplosionQueue(level) factory.load(it) factory - }, TODO()), + }, DataFixTypes.LEVEL), "otm_blackhole_explosion_queue" ) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt index b64a244e0..e693e19cf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt @@ -290,7 +290,7 @@ fun GuiGraphics.drawLine( drawLine(pose().last().pose(), startX, startY, endX, endY, width, z, color) } -data class ScissorRect(val x: Int, val y: Int, val width: Int, val height: Int) { +data class ScissorRect(val x: Int, val y: Int, val width: Int, val height: Int, val lock: Boolean = false) { fun withinBounds(x: Int, y: Int): Boolean { return (x in this.x .. this.x + width) && (y in this.y .. this.y + height) } @@ -330,7 +330,8 @@ data class ScissorRect(val x: Int, val y: Int, val width: Int, val height: Int) private val scissorStack = ArrayDeque() @Suppress("NAME_SHADOWING") -fun pushScissorRect(x: Int, y: Int, width: Int, height: Int) { +@JvmOverloads +fun pushScissorRect(x: Int, y: Int, width: Int, height: Int, lock: Boolean = false) { var x = x var y = y var width = width @@ -339,6 +340,11 @@ fun pushScissorRect(x: Int, y: Int, width: Int, height: Int) { val peek = scissorStack.lastOrNull() if (peek != null) { + if (peek.lock) { + scissorStack.add(peek) + return + } + x = x.coerceAtLeast(peek.x) y = y.coerceAtLeast(peek.y) width = width.coerceAtMost(peek.width) @@ -350,7 +356,7 @@ fun pushScissorRect(x: Int, y: Int, width: Int, height: Int) { } } - scissorStack.add(ScissorRect(x, y, width, height)) + scissorStack.add(ScissorRect(x, y, width, height, lock)) y = minecraft.window.height - y - height RenderSystem.enableScissor(x, y, width, height) } 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 ca4f83484..f47b2a27c 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 @@ -319,6 +319,7 @@ open class EditablePanel @JvmOverloads constructor( // Обрезать отрисовку потомков? var scissor = false + var scissorLock = false var scissorPadding = DockProperty.EMPTY var dock = Dock.NONE set(value) { @@ -868,6 +869,7 @@ open class EditablePanel @JvmOverloads constructor( ((absoluteY + top) * scale).toInt(), ((width - right - left) * scale).toInt() + 1, ((height - bottom - top) * scale).toInt() + 1, + scissorLock ) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt index a5da55b6c..10f1dd8e8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt @@ -132,6 +132,7 @@ class EntityRendererPanel @JvmOverloads constructor( init { dock = Dock.FILL scissor = true + scissorLock = true } private val cosButton: EditablePanel? @@ -169,18 +170,14 @@ class EntityRendererPanel @JvmOverloads constructor( return } - val renderX = this.width.toInt() / 2 - val renderY = (this.height * 0.9f).toInt() - InventoryScreen.renderEntityInInventoryFollowsMouse( graphics, - renderX, - renderY, + 0, 0, this.width.toInt(), this.height.toInt(), renderScale, 0f, - absoluteX.toInt() + renderX - mouseX, - absoluteY + height * 0.15f - mouseY, + mouseX - absoluteX.toInt(), + mouseY - absoluteY + height * 0.15f, entity ) } From ed5a549b9626e4df1cee60362cd4d77d684be0c5 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 18 Oct 2023 08:04:46 +0700 Subject: [PATCH 1054/1199] java.lang.RuntimeException: This piece should be unreachable at TRANSFORMER/overdrive_that_matters@1.4-SNAPSHOT-aa513343/ru.dbotthepony.mc.otm.matter.MatterManager$Resolver.doDetermineValue(MatterManager.kt:935) --- src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index dd5d25f12..7d63a45e6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -930,7 +930,8 @@ object MatterManager { } if (accumulatedMatter == null || accumulatedComplexity == null) { - throw RuntimeException("This piece should be unreachable") + comment(item, TextComponent("${recipe.formattedName} ended up with undefined matter value and/or complexity (all inputs skipped)")) + return Result.MISSING } if (!accumulatedMatter.isPositive || accumulatedComplexity <= 0.0) { From 5be91b2f1abc90bfb14b2464ebdac1360e66510d Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sat, 21 Oct 2023 14:52:58 +0300 Subject: [PATCH 1055/1199] toast symbols for machine recipes --- .../ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt | 5 +++++ .../kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt | 5 +++++ .../kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt | 5 +++++ 3 files changed, 15 insertions(+) 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 c038932a2..6a3dbe4ee 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt @@ -26,6 +26,7 @@ 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.minRange +import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRecipes import java.util.Optional import java.util.UUID @@ -92,6 +93,10 @@ open class MatterEntanglerRecipe( return true } + override fun getToastSymbol(): ItemStack { + return ItemStack(MItems.MATTER_ENTANGLER) + } + fun toFinished(id: ResourceLocation): FinishedRecipe { return SERIALIZER.toFinished(this, id) } 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 8adc962ed..1f3210b9e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt @@ -22,6 +22,7 @@ import ru.dbotthepony.mc.otm.core.tagNotNull import ru.dbotthepony.mc.otm.data.Codec2RecipeSerializer import ru.dbotthepony.mc.otm.data.PredicatedCodecList import ru.dbotthepony.mc.otm.data.minRange +import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRecipes import java.util.EnumMap import java.util.function.Predicate @@ -100,6 +101,10 @@ class PainterRecipe( return MRecipes.PAINTER } + override fun getToastSymbol(): ItemStack { + return ItemStack(MItems.PAINTER) + } + fun toFinished(id: ResourceLocation): FinishedRecipe { return SERIALIZER.toFinished(this, id) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt index 5bf5eca8b..aca5daf14 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt @@ -21,6 +21,7 @@ import ru.dbotthepony.mc.otm.registry.MRecipes import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.data.Codec2RecipeSerializer import ru.dbotthepony.mc.otm.data.minRange +import ru.dbotthepony.mc.otm.registry.MItems class PlatePressRecipe( val input: Ingredient, @@ -74,6 +75,10 @@ class PlatePressRecipe( override fun getType(): RecipeType = MRecipes.PLATE_PRESS + override fun getToastSymbol(): ItemStack { + return ItemStack(MItems.PLATE_PRESS) + } + fun toFinished(id: ResourceLocation) = SERIALIZER.toFinished(this, id) companion object { From 91c8100729be120ea06a0fd7a7e28e327ed5a6ed Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sat, 21 Oct 2023 15:32:25 +0300 Subject: [PATCH 1056/1199] =?UTF-8?q?DBot=20=E2=80=94=20=D0=A1=D0=B5=D0=B3?= =?UTF-8?q?=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=2014:51=20=D0=A1=D1=87=D0=B8?= =?UTF-8?q?=D1=82=D0=B0=D0=B5=D1=82=D1=81=D1=8F=20=D1=87=D1=82=D0=BE=20?= =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=B8=D0=BB=D1=8C=D0=BD=D0=BE=20=D0=9F=D0=BE=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=BD=D0=B5=20=D0=B4=D0=BE=D0=BA=D0=B0=D0=B7=D0=B0?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=BE=D0=B1=D1=80=D0=B0=D1=82=D0=BD=D0=BE=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/matter/MatterManager.kt | 51 +++++++++++++++++++ .../resources/META-INF/accesstransformer.cfg | 3 ++ .../otm_recipe_finder/smithing.json | 2 +- 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 7d63a45e6..1c55d6324 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -42,8 +42,10 @@ import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.inventory.TransientCraftingContainer import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.item.crafting.Recipe import net.minecraft.world.item.crafting.RecipeType +import net.minecraft.world.item.crafting.SmithingTransformRecipe import net.minecraft.world.level.ItemLike import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.crafting.IShapedRecipe @@ -585,6 +587,55 @@ object MatterManager { } } } + + registrar.register("smithing") { + Finder { server, data -> + val location = (data["recipe_type"] ?: throw JsonSyntaxException("Missing recipe type")).let { ResourceLocation.tryParse(it.asString) } ?: throw JsonSyntaxException("Invalid recipe type: ${data["recipe_type"]}") + + if (!ForgeRegistries.RECIPE_TYPES.containsKey(location)) { + LOGGER.error("Invalid or missing recipe category: $location!") + return@Finder Stream.empty() + } + + val findRecipeType = ForgeRegistries.RECIPE_TYPES.getValue(location) as RecipeType>? ?: throw ConcurrentModificationException() + + val isCritical = data["is_critical"]?.asBoolean ?: true + val allowBacktrack = data["allow_backtrack"]?.asBoolean ?: true + + var stream = server.recipeManager.byType(findRecipeType).values.stream().filter { !it.value.isIncomplete } + stream = stream.filter { it.value is SmithingTransformRecipe } + + stream.filter { it.value.getResultItem(server.registryAccess()).isNotEmpty }.map { + try { + val ingredients = ArrayList() + + val recipe = it.value as SmithingTransformRecipe + + ingredients.add(recipe.base) + ingredients.add(recipe.addition) + + ResolvedRecipe( + ingredients.stream() + .filter { !it.isActuallyEmpty } + .map { it.items.stream().filter { it.isNotEmpty }.map(::RecipeEntry) }, + ImmutableStack(it.value.getResultItem(server.registryAccess())), + isCritical = isCritical, + name = it.id, + allowBacktrack = allowBacktrack + ) + } catch(err: Throwable) { + throw RuntimeException("Processing smithing recipe ${it.id}", err) + } + }.filterNotNull().filter { + if (it.inputs.isEmpty()) { + LOGGER.warn("${it.formattedName} with output '${it.output.item.registryName}' ended up with no inputs!") + false + } else { + true + } + } + } + } } private var foundResolvers: Map> = ImmutableMap.of() diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index b97fad5c6..b77390770 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -156,6 +156,9 @@ public net.minecraft.client.renderer.FogRenderer f_109010_ # fogRed public net.minecraft.world.item.crafting.RecipeManager m_44054_(Lnet/minecraft/world/item/crafting/RecipeType;)Ljava/util/Map; # byType +public net.minecraft.world.item.crafting.SmithingTransformRecipe f_265888_ # base +public net.minecraft.world.item.crafting.SmithingTransformRecipe f_265907_ # addition + public net.minecraft.world.entity.boss.wither.WitherBoss f_31432_ # TARGETING_CONDITIONS public-f net.minecraft.world.entity.boss.wither.WitherBoss f_31431_ # LIVING_ENTITY_SELECTOR public net.minecraft.world.entity.ai.targeting.TargetingConditions f_26879_ # selector diff --git a/src/main/resources/data/overdrive_that_matters/otm_recipe_finder/smithing.json b/src/main/resources/data/overdrive_that_matters/otm_recipe_finder/smithing.json index f5aebe2b2..59297e8b1 100644 --- a/src/main/resources/data/overdrive_that_matters/otm_recipe_finder/smithing.json +++ b/src/main/resources/data/overdrive_that_matters/otm_recipe_finder/smithing.json @@ -1,5 +1,5 @@ { "recipe_type": "minecraft:smithing", - "type": "overdrive_that_matters:simple", + "type": "overdrive_that_matters:smithing", "is_critical": false } \ No newline at end of file From 092b2f0a44568efbfb651f467a090beabb9e4557 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 21 Oct 2023 20:04:47 +0700 Subject: [PATCH 1057/1199] Reverse order of codecs when deserializing --- src/main/kotlin/ru/dbotthepony/mc/otm/data/CodecList.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/CodecList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/CodecList.kt index 0466a82da..572fa629c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/CodecList.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/CodecList.kt @@ -95,7 +95,7 @@ class PredicatedCodecList(codecs: Stream, Predicat override fun decode(ops: DynamicOps, input: T): DataResult> { val results = ArrayList>>(codecs.size) - for ((codec) in codecs) { + for ((codec) in codecs.asReversed()) { val result = codec.decode(ops, input) if (result.result().isPresent) { From 9b2566e08d55ca28052d14da3538d31f2557b0b4 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sun, 22 Oct 2023 03:47:13 +0300 Subject: [PATCH 1058/1199] i need more buckets i need more buckets i need more buckets i need more buckets --- .../ru/dbotthepony/mc/otm/datagen/MatterData.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt index 0781b1800..a46c6be0c 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/MatterData.kt @@ -21,6 +21,21 @@ fun addMatterData(provider: MatterDataProvider) { provider.inherit(MItems.TRITANIUM_ANVIL[i], MItems.TRITANIUM_ANVIL[i - 1], 0.85) } + provider.inherit(Items.WATER_BUCKET, Items.BUCKET) { + plus(Decimal(1), 20.0) + } + + provider.inherit(Items.LAVA_BUCKET, Items.MAGMA_BLOCK) { + plus(Decimal(0), 666.0) + plus(Items.BUCKET) + } + + provider.inherit(Items.POWDER_SNOW_BUCKET, Items.SNOW_BLOCK) { + multiply(Decimal(0.75), 1.0) + plus(Decimal(0), 200.0) + plus(Items.BUCKET) + } + provider.inherit(Items.MILK_BUCKET, Items.BUCKET) { plus(Decimal(7), 480.0) } From 54cfd841038b8115432a9f19d85e51e7304ac7fe Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sun, 22 Oct 2023 06:28:04 +0300 Subject: [PATCH 1059/1199] =?UTF-8?q?=D1=81=D0=B5=D0=B9=D1=87=D0=B0=D1=81?= =?UTF-8?q?=20=D0=BC=D1=8B=20=D0=B1=D1=83=D0=B4=D0=B5=D0=BC=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BA=D0=B0=D0=B7=D1=8B=D0=B2=D0=B0=D1=82=D1=8C=20=D0=B6=D0=B8?= =?UTF-8?q?=D0=B4=D0=BA=D0=BE=D1=81=D1=82=D1=8C=20closes=20#258?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt | 1 - .../kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt | 7 +++++++ .../models/item/fluid_capsule.json | 9 +++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/models/item/fluid_capsule.json diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index 8de978077..d54669d2f 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -31,7 +31,6 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.block(MItems.ITEM_MONITOR) provider.block(MItems.PHANTOM_ATTRACTOR) provider.block(MItems.HOLO_SIGN) - provider.generated(MItems.FLUID_CAPSULE) MRegistry.VENT.allItems.values.forEach(provider::block) MRegistry.VENT_ALTERNATIVE.allItems.values.forEach(provider::block) 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 2457b71f8..130956113 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -18,6 +18,8 @@ import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.properties.NoteBlockInstrument import net.minecraft.world.level.material.MapColor import net.minecraftforge.api.distmarker.Dist +import net.minecraftforge.client.event.RegisterColorHandlersEvent +import net.minecraftforge.client.model.DynamicFluidContainerModel import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent @@ -253,6 +255,7 @@ object MRegistry { bus.addListener(this::initializeCommon) bus.addListener(MStats::registerVanilla) bus.addListener(this::registerEvent) + bus.addListener(this::registerItemColorHandlers) MCreativeTabs.initialize(bus) @@ -338,4 +341,8 @@ object MRegistry { } } } + + private fun registerItemColorHandlers(event: RegisterColorHandlersEvent.Item) { + event.register(DynamicFluidContainerModel.Colors(), MItems.FLUID_CAPSULE) + } } diff --git a/src/main/resources/assets/overdrive_that_matters/models/item/fluid_capsule.json b/src/main/resources/assets/overdrive_that_matters/models/item/fluid_capsule.json new file mode 100644 index 000000000..312408e50 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/item/fluid_capsule.json @@ -0,0 +1,9 @@ +{ + "parent": "forge:item/default", + "loader": "forge:fluid_container", + "fluid": "minecraft:empty", + "textures": { + "base": "overdrive_that_matters:item/fluid_capsule", + "fluid": "overdrive_that_matters:item/fluid_capsule_liquid_mask" + } +} \ No newline at end of file From 5e91da68cf5ce438d5bf5016e1bc806a0fd998e9 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sun, 22 Oct 2023 07:48:03 +0300 Subject: [PATCH 1060/1199] separate parent recipe in upgrade recipe output --- .../ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt index 679c92fb2..7e2e75f89 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt @@ -185,8 +185,7 @@ class MatteryRecipe(val result: ItemLike, val count: Int = 1, val category: Reci return { object : FinishedRecipe by it { override fun serializeRecipeData(pJson: JsonObject) { - it.serializeRecipeData(pJson) - + pJson["parent"] = it.serializeRecipe() pJson["copyPaths"] = UpgradeRecipe.COPY_PATHS_CODEC.toJsonStrict(copyPaths) pJson["source"] = upgradeSource!!.toString() } From b9dba513e46758ec7d430b8d20029374f154fb22 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 22 Oct 2023 12:19:15 +0700 Subject: [PATCH 1061/1199] =?UTF-8?q?YuRaNnNzZZ=20=E2=80=94=20=D0=A1=D0=B5?= =?UTF-8?q?=D0=B3=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=2010:56=20=D0=BE=D0=BF?= =?UTF-8?q?=D1=8F=D1=82=D1=8C=20=D0=B2=D1=81=D1=91=20=D0=BF=D0=BE=D0=B4?= =?UTF-8?q?=D0=B1=D0=B8=D1=80=D0=B0=D0=B5=D1=82=D1=81=D1=8F=20=D0=B2=20?= =?UTF-8?q?=D0=BB=D0=B5=D0=B2=D1=83=D1=8E=20=D1=80=D1=83=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index fd72e1114..3b9a19e89 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -1382,7 +1382,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial inventoryAndExopack.consumeItem(stack, false, onlyIntoExisting = false, popTime = 5) } else { wrappedInventory.consumeItem(stack, false, slots = IntSet.of(ply.inventory.selected), onlyIntoExisting = false, popTime = 5) - wrappedInventory.consumeItem(stack, false, slots = offhandSlotRange, onlyIntoExisting = false, popTime = 5) + wrappedInventory.consumeItem(stack, false, slots = offhandSlotRange, onlyIntoExisting = true, popTime = 5) wrappedItemInventory.consumeItem(stack, false, onlyIntoExisting = false, popTime = 5) } From 964a6e17b1a958fd1d1401ec489b06a7821478ae Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sun, 22 Oct 2023 10:12:16 +0300 Subject: [PATCH 1062/1199] =?UTF-8?q?DBot=20=E2=80=94=20=D0=A1=D0=B5=D0=B3?= =?UTF-8?q?=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=2010:09=20=D0=B0=20=D0=BF?= =?UTF-8?q?=D0=BE=D1=87=D0=B5=D0=BC=D1=83=20=D1=82=D0=BE=D0=B3=D0=B4=D0=B0?= =?UTF-8?q?=20=D0=BD=D0=B5=20=D0=BA=D0=BE=D0=BF=D0=B8=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D1=82=D1=8C=20=D0=B2=D0=B5=D1=81=D1=8C=20BlockEntityTag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index f5d871ded..ab9c82344 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -73,6 +73,8 @@ fun addCraftingTableRecipes(consumer: RecipeOutput) { .build(consumer, "advanced") MatteryRecipe(MBlocks.TWIN_PLATE_PRESS, category = machinesCategory) + .setUpgradeSource(MItems.PLATE_PRESS) + .addUpgradeOps(UpgradeRecipe.Direct("BlockEntityTag")) .rowB(MItemTags.PISTONS) .rowB(MItems.PLATE_PRESS) .rowB(MItemTags.TRITANIUM_PLATES) From a70e1f30bdc1e0fee3396edb08afb4ffb2078c70 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 23 Oct 2023 00:51:55 +0700 Subject: [PATCH 1063/1199] Fix furnaces not dropping their containers in block break --- .../mc/otm/block/entity/tech/PoweredFurnaceBlockEntity.kt | 5 +++++ 1 file changed, 5 insertions(+) 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 faded59a3..b853d37be 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 @@ -42,6 +42,11 @@ class PoweredFurnaceBlockEntity( val inputs = immutableList(2) { MatteryContainer(this::itemContainerUpdated, 1) } val outputs = immutableList(2) { MatteryContainer(this::itemContainerUpdated, 1) } + init { + inputs.forEach { addDroppableContainer(it) } + outputs.forEach { addDroppableContainer(it) } + } + val energyConfig = ConfigurableEnergy(energy) val itemConfig = ConfigurableItemHandler( input = CombinedItemHandler(inputs.map { it.handler(HandlerFilter.OnlyIn) }), From 294a402447391db183cc3960ec96a20bcec6597c Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Mon, 23 Oct 2023 00:13:26 +0300 Subject: [PATCH 1064/1199] mod/toml version != jar version --- build.gradle.kts | 25 ++++++++++++++++++------- src/main/resources/META-INF/mods.toml | 10 ++++------ src/main/resources/pack.mcmeta | 5 ++--- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 82603e92c..1b3d60f66 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -48,14 +48,12 @@ data class GitInfo(val version: String, val tag: String, val buildNumber: String } val modVersion: String get() { - if (tag != "") - return mod_version + val version = if (buildNumber != "") "$mod_version.$buildNumber" else mod_version - if (version != "") { - return "$mod_version-SNAPSHOT-$version" - } else { - return "$mod_version-SNAPSHOT" - } + if (tag != "") + return version + + return "$version-SNAPSHOT" } } @@ -341,6 +339,19 @@ tasks.jar.configure { archiveVersion.set(gitVersion.jarName) } +tasks.withType(ProcessResources::class.java) { + val replaceProperties = mapOf( + "mc_version" to mc_version, + "mod_id" to mod_id, + "mod_version" to gitVersion.modVersion + ) + inputs.properties(replaceProperties) + + filesMatching(arrayListOf("META-INF/mods.toml", "pack.mcmeta")) { + expand(replaceProperties) + } +} + tasks { create("sourceJar", org.gradle.jvm.tasks.Jar::class.java) { archiveClassifier.set("sources") diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 841489a93..018965bee 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -15,11 +15,9 @@ license="2 Clause BSD" # A list of mods - how many allowed here is determined by the individual mod loader [[mods]] #mandatory # The modid of the mod -modId="overdrive_that_matters" #mandatory +modId="${mod_id}" #mandatory # The version number of the mod - there's a few well known ${} variables useable here or just hardcode it -# ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata -# see the associated build.gradle script for how to populate this completely automatically during a build -version="${file.jarVersion}" #mandatory +version="${mod_version}" #mandatory # A display name for the mod displayName="Overdrive That Matters" #mandatory # A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/ @@ -37,7 +35,7 @@ description=''' Matter. Energy. Combined. ''' # A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional. -[[dependencies.overdrive_that_matters]] #optional +[[dependencies.${mod_id}]] #optional # the modid of the dependency modId="forge" #mandatory # Does this dependency have to exist - if not, ordering below must be specified @@ -49,7 +47,7 @@ Matter. Energy. Combined. # Side this dependency is applied on - BOTH, CLIENT or SERVER side="BOTH" # Here's another dependency -[[dependencies.overdrive_that_matters]] +[[dependencies.${mod_id}]] modId="minecraft" mandatory=true # This version range declares a minimum of the current minecraft version up to but not including the next major version diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta index cb47551b4..07bda9007 100644 --- a/src/main/resources/pack.mcmeta +++ b/src/main/resources/pack.mcmeta @@ -1,7 +1,6 @@ { "pack": { - "description": "Overdrive That Matters Resources", - "pack_format": 6, - "_comment": "A pack_format of 6 requires json lang files and some texture changes from 1.16.2. Note: we require v6 pack meta for all mods." + "description": "${mod_id} resources", + "pack_format": 18 } } From 74f8e316b770810378dd2a364d2fdc7c66a1fc63 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Mon, 23 Oct 2023 05:51:07 +0300 Subject: [PATCH 1065/1199] =?UTF-8?q?DBot=20=E2=80=94=2030.05.2023=209:49?= =?UTF-8?q?=20=D0=94=D0=B0=20=D0=9D=D0=BE=20=D0=B2=D1=81=D1=91=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BD=D0=BE=20=D0=9D=D1=80=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=81=D1=8F=20=D0=BB=D0=B8=20=D1=82=D0=B5=D0=B1=D0=B5=20=D0=BA?= =?UTF-8?q?=D0=B0=D0=BF=D1=81=D1=83=D0=BB=D0=B0=20=D0=BE=D0=BF=D1=8B=D1=82?= =?UTF-8?q?=D0=B0=20=D0=9A=D0=B0=D0=BA=20=D0=BA=D0=BE=D0=BD=D1=86=D0=B5?= =?UTF-8?q?=D0=BF=D1=82=20YuRaNnNzZZ=20=E2=80=94=2030.05.2023=209:50=20?= =?UTF-8?q?=D0=B4=D0=B0=20=D1=82=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20one=20sma?= =?UTF-8?q?ll=20issue=20DBot=20=E2=80=94=2030.05.2023=209:50=20=D0=AF=20?= =?UTF-8?q?=D0=BD=D0=B5=20=D0=BF=D1=80=D0=BE=20=D0=B2=D0=B5=D1=80=D1=81?= =?UTF-8?q?=D0=B8=D1=8E=20=D0=B8=D0=B3=D1=80=D1=8B=20YuRaNnNzZZ=20?= =?UTF-8?q?=E2=80=94=2030.05.2023=209:50=20=D0=BE=D0=BD=D0=B0=20=D0=B3?= =?UTF-8?q?=D0=B5=D0=B9=D1=82=D0=B8=D1=82=20=D0=B2=D0=BE=D0=B7=D0=B2=D1=80?= =?UTF-8?q?=D0=B0=D1=82=20=D0=BE=D0=BF=D1=8B=D1=82=D0=B0=20=D0=B7=D0=B0=20?= =?UTF-8?q?=D1=82=D0=B0=D0=BD=D0=BA=D0=BE=D0=BC=20=D0=BE=D0=BF=D1=8B=D1=82?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/datagen/lang/English.kt | 2 + .../mc/otm/datagen/lang/Russian.kt | 2 + .../mc/otm/item/EssenceCapsuleItem.kt | 66 +++++++++++++++++-- .../ru/dbotthepony/mc/otm/registry/MItems.kt | 4 +- 4 files changed, 67 insertions(+), 7 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index c7cdbd1d1..224dae1f0 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -857,6 +857,8 @@ private fun gui(provider: MatteryLanguageProvider) { gui("essence_capsule", "(Almost) Everything you ever knew is within") gui("essence_capsule2", "This item can be recycled at Essence Servo") + gui("essence_capsule3", "Use to break free most of stored knowledge") + gui("essence_capsule.digital", "Use to scan memories stored within") gui("slot_filter.filtered", "This slot is filtered for automation") gui("slot_filter.forbidden", "This slot is forbidden for automation mechanisms") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 228ad6d08..4eb78a3d1 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -856,6 +856,8 @@ private fun gui(provider: MatteryLanguageProvider) { gui("essence_capsule", "(Почти) Всё, что вы знали, хранится внутри") gui("essence_capsule2", "Данный предмет может быть переработан внутри хранилища эссенции") + gui("essence_capsule3", "Используйте, чтобы высвободить большую часть хранящихся внутри знаний") + gui("essence_capsule.digital", "Используйте, чтобы вернуть ваши воспоминания") gui("slot_filter.filtered", "Данный слот отфильтрован для автоматизации") gui("slot_filter.forbidden", "Данный слот запрещён для взаимодействия средствами автоматизации") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EssenceCapsuleItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EssenceCapsuleItem.kt index 8ba7a3c00..d7b6076db 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EssenceCapsuleItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EssenceCapsuleItem.kt @@ -2,11 +2,18 @@ package ru.dbotthepony.mc.otm.item import net.minecraft.ChatFormatting import net.minecraft.network.chat.Component -import net.minecraft.world.item.Item -import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.Rarity -import net.minecraft.world.item.TooltipFlag +import net.minecraft.server.level.ServerLevel +import net.minecraft.server.level.ServerPlayer +import net.minecraft.world.InteractionHand +import net.minecraft.world.InteractionResultHolder +import net.minecraft.world.entity.ExperienceOrb +import net.minecraft.world.entity.LivingEntity +import net.minecraft.world.entity.player.Player +import net.minecraft.world.item.* +import net.minecraft.world.item.alchemy.PotionUtils +import net.minecraft.world.item.alchemy.Potions import net.minecraft.world.level.Level +import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.TranslatableComponent @@ -15,12 +22,18 @@ import ru.dbotthepony.mc.otm.core.tagNotNull import ru.dbotthepony.mc.otm.core.util.getLevelFromXp import ru.dbotthepony.mc.otm.runIfClient -class EssenceCapsuleItem : Item(Properties().stacksTo(1).rarity(Rarity.UNCOMMON)) { +class EssenceCapsuleItem(private val digital: Boolean) : Item(Properties().stacksTo(1).rarity(Rarity.UNCOMMON)) { override fun appendHoverText(pStack: ItemStack, pLevel: Level?, pTooltipComponents: MutableList, pIsAdvanced: TooltipFlag) { super.appendHoverText(pStack, pLevel, pTooltipComponents, pIsAdvanced) pTooltipComponents.add(TranslatableComponent("otm.gui.essence_capsule").withStyle(ChatFormatting.DARK_GRAY)) pTooltipComponents.add(TranslatableComponent("otm.gui.essence_capsule2").withStyle(ChatFormatting.DARK_GRAY)) + if (!digital) { + pTooltipComponents.add(TranslatableComponent("otm.gui.essence_capsule3").withStyle(ChatFormatting.DARK_GRAY)) + } else if (runIfClient(false) { minecraft.player?.matteryPlayer?.isAndroid ?: false }) { + pTooltipComponents.add(TranslatableComponent("otm.gui.essence_capsule.digital").withStyle(ChatFormatting.DARK_GRAY)) + } + if (runIfClient(false) { minecraft.window.isShiftDown }) { pTooltipComponents.add(TranslatableComponent("otm.gui.experience", experienceStored(pStack)).withStyle(ChatFormatting.GRAY)) } else { @@ -28,6 +41,49 @@ class EssenceCapsuleItem : Item(Properties().stacksTo(1).rarity(Rarity.UNCOMMON) } } + override fun getUseAnimation(itemStack: ItemStack): UseAnim { + return if (digital) UseAnim.BOW else UseAnim.BRUSH + } + + override fun getUseDuration(itemStack: ItemStack): Int { + return if (digital) 20 else 30 + } + + override fun use(level: Level, player: Player, hand: InteractionHand): InteractionResultHolder { + if (!digital || player.matteryPlayer?.isAndroid == true) { + player.startUsingItem(hand) + + return InteractionResultHolder.consume(player.getItemInHand(hand)) + } + + return super.use(level, player, hand) + } + + override fun finishUsingItem(itemStack: ItemStack, level: Level, player: LivingEntity): ItemStack { + if (player !is Player) return super.finishUsingItem(itemStack, level, player) + + val exp = experienceStored(itemStack) / itemStack.count + if (digital) { + val mattery = player.matteryPlayer ?: return super.finishUsingItem(itemStack, level, player) + if (!mattery.isAndroid) return super.finishUsingItem(itemStack, level, player) + + if (player is ServerPlayer) { + player.giveExperiencePoints(exp.toInt()) + } + } else { + if (level is ServerLevel) { + level.levelEvent(2002, player.blockPosition(), PotionUtils.getColor(Potions.WATER)) + ExperienceOrb.award(level, player.position(), (exp * (.5 + level.random.nextFloat() * .25)).toInt()) + } + } + + if (!level.isClientSide && !player.abilities.instabuild) { + itemStack.shrink(1) + } + + return itemStack + } + fun make(experience: Long): ItemStack { return ItemStack(this, 1).also { setExperience(it, experience) 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 29da8121d..39e6f0dd3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -230,8 +230,8 @@ object MItems { val TRITANIUM_BARS: BlockItem by registry.register(MNames.TRITANIUM_BARS) { BlockItem(MBlocks.TRITANIUM_BARS, DEFAULT_PROPERTIES) } val ESSENCE_SERVO: EssenceServoItem by registry.register("essence_servo") { EssenceServoItem() } - val ESSENCE_CAPSULE: EssenceCapsuleItem by registry.register("essence_capsule") { EssenceCapsuleItem() } - val ESSENCE_DRIVE: EssenceCapsuleItem by registry.register("essence_drive") { EssenceCapsuleItem() } + val ESSENCE_CAPSULE: EssenceCapsuleItem by registry.register("essence_capsule") { EssenceCapsuleItem(false) } + val ESSENCE_DRIVE: EssenceCapsuleItem by registry.register("essence_drive") { EssenceCapsuleItem(true) } val FLUID_CAPSULE: FluidCapsuleItem by registry.register("fluid_capsule") { FluidCapsuleItem(ItemsConfig::FLUID_CAPSULE_CAPACITY) } val FLUID_TANK: FluidTankItem by registry.register(MNames.FLUID_TANK) { FluidTankItem(MBlocks.FLUID_TANK, Item.Properties().stacksTo(1), ItemsConfig::FLUID_TANK_CAPACITY) } From a04643e90516b061da29b2c6e6caceeae8ea62a9 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 23 Oct 2023 18:41:38 +0700 Subject: [PATCH 1066/1199] Fix inventory change trigger search tree NPE --- .../triggers/MatteryInventoryChangeTrigger.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MatteryInventoryChangeTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MatteryInventoryChangeTrigger.kt index 61b093e08..5cf93fd64 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MatteryInventoryChangeTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MatteryInventoryChangeTrigger.kt @@ -71,7 +71,7 @@ object MatteryInventoryChangeTrigger : CriterionTrigger( val strategy: Strategy, private val getter: InventoryChangeTrigger.TriggerInstance.() -> Collection, - val test: Tester, + val test: Tester, // if hint is present, tester is always going to be called with `null` value once val hint: Hint? = null ) { fun getValues(instance: InventoryChangeTrigger.TriggerInstance): Set { @@ -84,9 +84,9 @@ object MatteryInventoryChangeTrigger : CriterionTrigger>() init { - nodes.add(Node(BoundsStrategy, { listOf(slotsOccupied) }, { v, inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> v.matches(slotsOccupied) })) - nodes.add(Node(BoundsStrategy, { listOf(slotsFull) }, { v, inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> v.matches(slotsFull) })) - nodes.add(Node(BoundsStrategy, { listOf(slotsEmpty) }, { v, inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> v.matches(slotsEmpty) })) + nodes.add(Node(BoundsStrategy, { listOf(slotsOccupied) }, { v, inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> v!!.matches(slotsOccupied) })) + nodes.add(Node(BoundsStrategy, { listOf(slotsFull) }, { v, inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> v!!.matches(slotsFull) })) + nodes.add(Node(BoundsStrategy, { listOf(slotsEmpty) }, { v, inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> v!!.matches(slotsEmpty) })) nodes.add(Node( DefaultStrategy, @@ -96,16 +96,16 @@ object MatteryInventoryChangeTrigger : CriterionTrigger> } }, - { v, inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> v.isEmpty || item.`is`(v.get()) }, + { predicates.map { it.tag.orElse(null) } }, + { v, inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> v == null || item.`is`(v) }, { inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> item.tags.collect(Collectors.toCollection(::ArrayList)) })) - nodes.add(Node(BoundsStrategy, { predicates.map { it.count } }, { v, inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> v.matches(item.count) })) + nodes.add(Node(BoundsStrategy, { predicates.map { it.count } }, { v, inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> v!!.matches(item.count) })) nodes.add(Node( BoundsStrategy, { predicates.map { it.durability } }, - { v, inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> v.isAny || item.isDamageableItem && v.matches(item.maxDamage - item.damageValue) })) + { v, inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> v!!.isAny || item.isDamageableItem && v.matches(item.maxDamage - item.damageValue) })) } private class ListenerTree(private val advancements: PlayerAdvancements) { From c4dbc797070961ad4ff35ea684e16251fd68206f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 23 Oct 2023 19:11:24 +0700 Subject: [PATCH 1067/1199] Update effect list panel sprite locations --- .../mc/otm/client/screen/panels/EffectListPanel.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt index 816505845..eba7920cf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt @@ -6,6 +6,7 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectFunction import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen +import net.minecraft.resources.ResourceLocation import net.minecraft.world.effect.MobEffect import net.minecraft.world.effect.MobEffectInstance import net.minecraft.world.entity.LivingEntity @@ -266,9 +267,7 @@ open class EffectListPanel @JvmOverloads constructor( } companion object { - val BAR = AbstractContainerScreen.INVENTORY_LOCATION.sprite(0f, 166f, 120f, 32f) - val SQUARE = AbstractContainerScreen.INVENTORY_LOCATION.sprite(0f, 198f, 32f, 32f) - val SQUARE_THIN = AbstractContainerScreen.INVENTORY_LOCATION.sprite(141f, 166f, 24f, 24f) - val SQUARE_THIN_HIGHLIGHT = AbstractContainerScreen.INVENTORY_LOCATION.sprite(165f, 166f, 24f, 24f) + val BAR = ResourceLocation("textures/gui/sprites/container/inventory/effect_background_large.png").sprite(0f, 0f, 120f, 32f, 120f, 32f) + val SQUARE_THIN = ResourceLocation("textures/gui/sprites/hud/effect_background.png").sprite(0f, 0f, 24f, 24f, 24f, 24f) } } From ff547f9a5ed0104d26a830046216f9b12c1ac2fc Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Tue, 24 Oct 2023 08:01:34 +0300 Subject: [PATCH 1068/1199] optional item/block tags display in tooltips --- .../mc/otm/datagen/lang/English.kt | 5 ++ .../mc/otm/datagen/lang/Russian.kt | 4 ++ .../mc/otm/OverdriveThatMatters.java | 1 + .../mc/otm/client/ClientEventHandler.kt | 46 +++++++++++++++++++ .../dbotthepony/mc/otm/config/ClientConfig.kt | 4 ++ 5 files changed, 60 insertions(+) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 224dae1f0..74fe3e236 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -865,6 +865,11 @@ private fun gui(provider: MatteryLanguageProvider) { gui("slot_filter.hint", "To remove slot filter press Ctrl + LMB") gui("tooltip.enum.active", "> %s") + + gui("debug.tags.help", "Hold Shift to display tags") + gui("debug.tags.item.title", "Item tags:") + gui("debug.tags.block.title", "Block tags:") + gui("debug.tags.tag.entry", " - %s") } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 4eb78a3d1..e5b1e6621 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -862,6 +862,10 @@ private fun gui(provider: MatteryLanguageProvider) { gui("slot_filter.filtered", "Данный слот отфильтрован для автоматизации") gui("slot_filter.forbidden", "Данный слот запрещён для взаимодействия средствами автоматизации") gui("slot_filter.hint", "Для удаления фильтра нажмите Ctrl + ЛКМ") + + gui("debug.tags.help", "Удерживайте Shift для отображения тегов") + gui("debug.tags.item.title", "Теги предмета:") + gui("debug.tags.block.title", "Теги блока:") } } diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 350d59128..0e62d7403 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -242,6 +242,7 @@ public final class OverdriveThatMatters { EVENT_BUS.addListener(EventPriority.LOWEST, ClientTickHandlerKt::onClientTick); EVENT_BUS.addListener(EventPriority.HIGHEST, ClientTickHandlerKt::onClientConnected); EVENT_BUS.addListener(EventPriority.HIGHEST, ClientTickHandlerKt::onClientDisconnected); + EVENT_BUS.addListener(EventPriority.NORMAL, ClientEventHandlerKt::tooltipEvent); EVENT_BUS.addListener(EventPriority.NORMAL, QuantumBatteryItem.Companion::clientDisconnect); diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt index 9f9b08fb0..b6d324cfa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt @@ -2,16 +2,22 @@ package ru.dbotthepony.mc.otm.client import com.mojang.blaze3d.platform.InputConstants import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap +import net.minecraft.ChatFormatting import net.minecraft.client.gui.components.events.GuiEventListener import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen import net.minecraft.client.gui.screens.inventory.InventoryScreen +import net.minecraft.tags.TagKey import net.minecraft.world.inventory.InventoryMenu import net.minecraft.world.inventory.Slot +import net.minecraft.world.item.BlockItem +import net.minecraft.world.item.Item +import net.minecraft.world.level.block.Block import net.minecraftforge.client.event.MovementInputUpdateEvent import net.minecraftforge.client.event.ScreenEvent import net.minecraftforge.client.event.ScreenEvent.MouseDragged import net.minecraftforge.client.event.ScreenEvent.MouseScrolled +import net.minecraftforge.event.entity.player.ItemTooltipEvent import ru.dbotthepony.mc.otm.config.ClientConfig import ru.dbotthepony.mc.otm.android.feature.JumpBoostFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability @@ -27,6 +33,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.Panel2Widget import ru.dbotthepony.mc.otm.compat.vanilla.InventoryScrollPacket import ru.dbotthepony.mc.otm.compat.cos.isCosmeticArmorScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.addAll import ru.dbotthepony.mc.otm.core.math.integerDivisionUp import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.network.MenuNetworkChannel @@ -253,3 +260,42 @@ fun onScreenOpen(event: ScreenEvent.Opening) { event.newScreen = ExopackInventoryScreen(player.exoPackMenu) } } + +private val TOOLTIP_TAG_DISPLAY_HELP = TranslatableComponent("otm.gui.debug.tags.help").withStyle(ChatFormatting.GRAY) +private val TOOLTIP_TAG_DISPLAY_ITEM_TITLE = TranslatableComponent("otm.gui.debug.tags.item.title").withStyle(ChatFormatting.DARK_GRAY) +private val TOOLTIP_TAG_DISPLAY_BLOCK_TITLE = TranslatableComponent("otm.gui.debug.tags.block.title").withStyle(ChatFormatting.DARK_GRAY) + +fun tooltipEvent(event: ItemTooltipEvent) { + if (event.flags.isAdvanced && ClientConfig.TOOLTIP_DISPLAY_TAGS && !event.itemStack.isEmpty) { + val itemTags = ArrayList>() + if (event.itemStack.tags.count() > 0) { + itemTags.addAll(event.itemStack.tags) + } + + val blockTags = ArrayList>() + if (event.itemStack.item is BlockItem) { + blockTags.addAll((event.itemStack.item as BlockItem).block.defaultBlockState().tags) + } + + if (itemTags.isNotEmpty() || blockTags.isNotEmpty()) { + if (!minecraft.window.isShiftDown) { + event.toolTip.add(TOOLTIP_TAG_DISPLAY_HELP) + return + } + } + + if (itemTags.isNotEmpty()) { + event.toolTip.add(TOOLTIP_TAG_DISPLAY_ITEM_TITLE) + for (tag in itemTags) { + event.toolTip.add(TranslatableComponent("otm.gui.debug.tags.tag.entry", tag.location).withStyle(ChatFormatting.DARK_GRAY)) + } + } + + if (blockTags.isNotEmpty()) { + event.toolTip.add(TOOLTIP_TAG_DISPLAY_BLOCK_TITLE) + for (tag in blockTags) { + event.toolTip.add(TranslatableComponent("otm.gui.debug.tags.tag.entry", tag.location).withStyle(ChatFormatting.DARK_GRAY)) + } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ClientConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ClientConfig.kt index 1c4a80cac..64b1f5e91 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ClientConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ClientConfig.kt @@ -28,4 +28,8 @@ object ClientConfig : AbstractConfig("client", ModConfig.Type.CLIENT) { .comment("Display redstone control button using items instead of custom sprites") .comment("For those who want it.") .define("REDSTONE_CONTROLS_ITEM_ICONS", false) + + var TOOLTIP_DISPLAY_TAGS: Boolean by builder + .comment("Display block/item tags in advanced item tooltips") + .define("TOOLTIP_DISPLAY_TAGS", false) } From 831e49c796ac0adf17e5427a9734041a355e608e Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Tue, 24 Oct 2023 12:13:52 +0300 Subject: [PATCH 1069/1199] chest upgrader test (#281) + multiingredient for datagen + crate recipe accepts barrels --- .../datagen/recipes/CraftingTableRecipes.kt | 2 +- .../datagen/recipes/MatteryRecipeProvider.kt | 15 ++++ .../mc/otm/item/ChestUpgraderItem.kt | 88 +++++++++++++++++++ .../mc/otm/registry/MCreativeTabs.kt | 2 + .../ru/dbotthepony/mc/otm/registry/MItems.kt | 2 + .../ru/dbotthepony/mc/otm/registry/MNames.kt | 2 + 6 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index ab9c82344..4d8bd96b8 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -24,7 +24,7 @@ fun addCraftingTableRecipes(consumer: RecipeOutput) { val machinesCategory = RecipeCategory.DECORATIONS MatteryRecipe(MRegistry.CARGO_CRATES.item, category = RecipeCategory.DECORATIONS) - .row(MItemTags.TRITANIUM_PLATES, Tags.Items.CHESTS, MItemTags.TRITANIUM_PLATES) + .row(MItemTags.TRITANIUM_PLATES, multiIngredient(Tags.Items.CHESTS_WOODEN, Tags.Items.BARRELS_WOODEN), MItemTags.TRITANIUM_PLATES) .unlockedBy(MItemTags.TRITANIUM_PLATES) .unlockedBy(Tags.Items.CHESTS) .build(consumer) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt index 60ca7a37a..7110f8f93 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt @@ -19,6 +19,7 @@ import net.minecraft.tags.TagKey import net.minecraft.util.valueproviders.ConstantFloat import net.minecraft.util.valueproviders.FloatProvider import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.level.ItemLike import ru.dbotthepony.mc.otm.core.registryName @@ -52,6 +53,20 @@ fun inventoryTrigger(vararg p_126012_: ItemPredicate): Criterion() + + for (item in items) { + if (item is ItemStack) { + values.add(Ingredient.ItemValue(item)) + } else if (item is TagKey<*>) { + values.add(Ingredient.TagValue(item as TagKey)) + } + } + + return Ingredient.fromValues(values.stream()) +} + fun T.unlockedBy(item: ItemLike): T { val location = item.asItem().registryName!! unlockedBy("has_${location.namespace}_${location.path}", has(item)) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt new file mode 100644 index 000000000..6c07356ab --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt @@ -0,0 +1,88 @@ +package ru.dbotthepony.mc.otm.item + +import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap +import net.minecraft.server.level.ServerLevel +import net.minecraft.world.Container +import net.minecraft.world.InteractionHand +import net.minecraft.world.InteractionResult +import net.minecraft.world.item.BlockItem +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.context.BlockPlaceContext +import net.minecraft.world.item.context.UseOnContext +import net.minecraft.world.level.block.Block +import net.minecraft.world.level.block.entity.BarrelBlockEntity +import net.minecraft.world.level.block.entity.ChestBlockEntity +import net.minecraft.world.level.storage.loot.LootParams +import net.minecraft.world.level.storage.loot.parameters.LootContextParams +import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock +import ru.dbotthepony.mc.otm.block.entity.decorative.CargoCrateBlockEntity +import ru.dbotthepony.mc.otm.core.math.Vector + +class ChestUpgraderItem : Item(Properties().stacksTo(1)) { + override fun onItemUseFirst(stack: ItemStack, context: UseOnContext): InteractionResult { + val player = context.player ?: return super.onItemUseFirst(stack, context) + + val otherHand = if (context.hand == InteractionHand.MAIN_HAND) InteractionHand.OFF_HAND else InteractionHand.MAIN_HAND + val crateStack = player.getItemInHand(otherHand) ?: return super.onItemUseFirst(stack, context) + + val block : Block + if (!crateStack.isEmpty && crateStack.item is BlockItem && (crateStack.item as BlockItem).block is CargoCrateBlock) { + block = (crateStack.item as BlockItem).block + } else { + return super.onItemUseFirst(stack, context) + } + + val pos = context.clickedPos + val hitBlockEntity = context.level.getBlockEntity(pos) + + if (hitBlockEntity is ChestBlockEntity || hitBlockEntity is BarrelBlockEntity) { + val container = hitBlockEntity as Container + + if (container.containerSize >= 54) return super.onItemUseFirst(stack, context) + + if (context.level is ServerLevel) { + val newState = block.getStateForPlacement(BlockPlaceContext(context)) ?: return InteractionResult.FAIL + + val contents = Int2ObjectArrayMap(container.containerSize) + for (i in 0 until container.containerSize) { + contents.put(i, container.getItem(i)) + } + container.clearContent() + + val level = context.level as ServerLevel + + val blockState = level.getBlockState(pos) + val lootparams = LootParams.Builder(level) + .withParameter(LootContextParams.ORIGIN, Vector.atCenterOf(context.clickedPos)) + .withParameter(LootContextParams.TOOL, stack) + .withOptionalParameter(LootContextParams.BLOCK_ENTITY, hitBlockEntity) + .withOptionalParameter(LootContextParams.BLOCK_STATE, blockState) + .withOptionalParameter(LootContextParams.THIS_ENTITY, context.player) + + blockState.spawnAfterBreak(level, pos, stack, true) + blockState.getDrops(lootparams).forEach { Block.popResource(level, pos, it) } + + if (!player.isCreative) + player.getItemInHand(otherHand).shrink(1) + + level.setBlockAndUpdate(pos, newState) + + val newBlockEntity = level.getBlockEntity(pos) + if (newBlockEntity is CargoCrateBlockEntity) { + for (i in 0 until contents.size) { + newBlockEntity.container[i] = contents.get(i) + } + } else { + for (i in 0 until contents.size) { + Block.popResource(level, pos, contents.get(i)) + } + } + } + + return InteractionResult.SUCCESS + } + + return super.onItemUseFirst(stack, context) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt index 6f10f057f..e0d083627 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt @@ -169,6 +169,8 @@ private fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { accept(MItems.BLACK_HOLE) accept(MItems.GRAVITATIONAL_DISRUPTOR) + accept(MItems.CHEST_UPGRADER) + accept(MItems.ESSENCE_SERVO) energized(MItems.ALL_BATTERIES) 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 39e6f0dd3..100f61660 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -566,6 +566,8 @@ object MItems { val METAL_JUNK: Item by registry.register(MNames.METAL_JUNK) { BlockItem(MBlocks.METAL_JUNK, DEFAULT_PROPERTIES) } val METAL_MESH: Item by registry.register(MNames.METAL_MESH) { BlockItem(MBlocks.METAL_MESH, DEFAULT_PROPERTIES) } + val CHEST_UPGRADER: Item by registry.register(MNames.CHEST_UPGRADER) { ChestUpgraderItem() } + init { MRegistry.INDUSTRIAL_GLASS.registerItems(registry) MRegistry.INDUSTRIAL_GLASS_PANE.registerItems(registry) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index 8fac6557d..53e56b58d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -158,6 +158,8 @@ object MNames { const val PLASMA_RIFLE = "plasma_rifle" + const val CHEST_UPGRADER = "chest_upgrader" + // items: crafting components const val TRITANIUM_DUST = "tritanium_dust" const val TRITANIUM_NUGGET = "tritanium_nugget" From 40f001fb586c9d09458d7ce909d40c341f8480dc Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 24 Oct 2023 17:39:38 +0700 Subject: [PATCH 1070/1199] Check for visibility of children panel in calculateAbsoluteObstructingRectangles --- .../ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 f47b2a27c..981705c2f 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 @@ -646,7 +646,7 @@ open class EditablePanel @JvmOverloads constructor( } for (children in visibleChildrenInternal) { - if (children.isOutsideOfParent || !isObstructing) { + if ((children.isOutsideOfParent || !isObstructing) && children.isVisible()) { result.addAll(children.calculateAbsoluteObstructingRectangles()) } } From 8d575c34a86b4df33a475be669aa09b8f5a1370b Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Thu, 26 Oct 2023 07:43:00 +0300 Subject: [PATCH 1071/1199] :WiseTree: --- gradle.properties | 6 +++--- .../ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index 9d3da881b..a6d094fe2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,16 +12,16 @@ use_commit_hash_in_version=true mc_version=1.20.2 jei_mc_version=1.20.2 -curios_mc_version=1.20 +curios_mc_version=1.20.2 forge_gradle_version=[6.0.14,6.2) -forge_version=48.0.20 +forge_version=48.0.33 mixingradle_version=0.7.33 mixin_version=0.8.5 jei_version=16.0.0.28 jupiter_version=5.9.2 -curios_version=5.2.0-beta.2 +curios_version=6.0.2 cosmetic_armor_reworked_id=4575609 ad_astra_id=4594155 botarium_id=4594094 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt index b91549300..ef035a966 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt @@ -36,8 +36,7 @@ fun onCuriosSlotModifiersUpdated(event: SlotModifiersUpdatedEvent) { } fun openCuriosScreen(carriedStack: ItemStack = ItemStack.EMPTY) { - TODO() - // if (FMLEnvironment.dist.isClient) NetworkHandler.INSTANCE.send(PacketDistributor.SERVER.noArg(), CPacketOpenCurios(carriedStack)) + if (FMLEnvironment.dist.isClient) NetworkHandler.INSTANCE.send(CPacketOpenCurios(carriedStack), PacketDistributor.SERVER.noArg()) } private fun Player.getCuriosSlotsImpl(): List> { From db4f24e85ef005b31698e272fbd1eeeb52d212b5 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Thu, 26 Oct 2023 08:22:49 +0300 Subject: [PATCH 1072/1199] =?UTF-8?q?DBot=20=E2=80=94=20=D0=A1=D0=B5=D0=B3?= =?UTF-8?q?=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=208:11=20=D0=AF=D1=89=D0=B8?= =?UTF-8?q?=D0=BA=D0=B0=D1=82=D0=BE=D1=80=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/datagen/items/ItemModels.kt | 2 ++ .../mc/otm/datagen/lang/English.kt | 4 ++++ .../mc/otm/datagen/lang/Russian.kt | 4 ++++ .../mc/otm/item/ChestUpgraderItem.kt | 18 ++++++++++++++++++ .../textures/item/chest_upgrader.png | Bin 0 -> 2437 bytes 5 files changed, 28 insertions(+) create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/chest_upgrader.png diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index d54669d2f..c85458ea1 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -89,6 +89,8 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.generated(MItems.TRITANIUM_ARMOR) provider.armorWithTrims(MItems.SIMPLE_TRITANIUM_ARMOR) + provider.handheld(MItems.CHEST_UPGRADER) + provider.generatedTiered(MItems.BATTERIES, "battery_tier") provider.generated(MItems.BATTERY_CREATIVE) provider.generated(MItems.PROCEDURAL_BATTERY, modLocation("item/battery_procedural")) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index 74fe3e236..b30813a5d 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -672,6 +672,10 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.CreativeUpgrades.FAILSAFE, "Creative Failsafe Upgrade") add(MItems.CreativeUpgrades.FAILURE, "Creative Failure Upgrade") add(MItems.CreativeUpgrades.PROCESSING_ITEMS, "Creative Item Processing Upgrade") + + add(MItems.CHEST_UPGRADER, "Crate-r") + add(MItems.CHEST_UPGRADER, "desc", "Replaces placed chests and barrels with cargo crates while keeping storage contents") + add(MItems.CHEST_UPGRADER, "desc2", "Hold desired crates in the opposite hand") } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index e5b1e6621..ebb2bd9c3 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -674,6 +674,10 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.CreativeUpgrades.FAILSAFE, "Творческое улучшение отказоустойчивости") add(MItems.CreativeUpgrades.FAILURE, "Творческое улучшение краха") add(MItems.CreativeUpgrades.PROCESSING_ITEMS, "Творческое улучшение обработки") + + add(MItems.CHEST_UPGRADER, "Ящикатор") + add(MItems.CHEST_UPGRADER, "desc", "Заменяет установленные сундуки и бочки грузовыми ящиками с сохранением содержимого") + add(MItems.CHEST_UPGRADER, "desc2", "Удерживайте необходимые ящики в противоположной руке") } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt index 6c07356ab..f4aefddff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt @@ -1,6 +1,8 @@ package ru.dbotthepony.mc.otm.item import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap +import net.minecraft.ChatFormatting +import net.minecraft.network.chat.Component import net.minecraft.server.level.ServerLevel import net.minecraft.world.Container import net.minecraft.world.InteractionHand @@ -8,15 +10,19 @@ import net.minecraft.world.InteractionResult import net.minecraft.world.item.BlockItem import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.TooltipFlag import net.minecraft.world.item.context.BlockPlaceContext import net.minecraft.world.item.context.UseOnContext +import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.entity.BarrelBlockEntity import net.minecraft.world.level.block.entity.ChestBlockEntity import net.minecraft.world.level.storage.loot.LootParams import net.minecraft.world.level.storage.loot.parameters.LootContextParams +import ru.dbotthepony.mc.otm.OverdriveThatMatters.MOD_ID import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock import ru.dbotthepony.mc.otm.block.entity.decorative.CargoCrateBlockEntity +import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.Vector class ChestUpgraderItem : Item(Properties().stacksTo(1)) { @@ -85,4 +91,16 @@ class ChestUpgraderItem : Item(Properties().stacksTo(1)) { return super.onItemUseFirst(stack, context) } + + override fun appendHoverText(pStack: ItemStack, pLevel: Level?, pTooltip: MutableList, pFlag: TooltipFlag) { + super.appendHoverText(pStack, pLevel, pTooltip, pFlag) + + pTooltip.add(DESCRIPTION) + pTooltip.add(DESCRIPTION2) + } + + companion object { + private val DESCRIPTION = TranslatableComponent("item.${MOD_ID}.chest_upgrader.desc").withStyle(ChatFormatting.DARK_GRAY) + private val DESCRIPTION2= TranslatableComponent("item.${MOD_ID}.chest_upgrader.desc2").withStyle(ChatFormatting.DARK_GRAY) + } } diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/chest_upgrader.png b/src/main/resources/assets/overdrive_that_matters/textures/item/chest_upgrader.png new file mode 100644 index 0000000000000000000000000000000000000000..d36635b4d3d72a5dd2644f4bd55341d6da866d5b GIT binary patch literal 2437 zcmV;033~R4P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGizyJUazyWI3i3tDz2^vX6K~zXfC00vs zB-ItZ&w5u^_1o=s`!Sv|69|G4pg@8KG$8_{NP$K2WB3W#Wt~+vStU{yStQB^wh=-M z5Qc#Za?}}@2Yz%Upb|=-M)42x#xW6JKs6zYd`g%BkkQV~@VUGD8nrn9+annhN)EiW(2EG_GrV4IL;%VOge-yd}} zwG3gfM_+$F8MoJqSy@Dz&1SMQ$;)DXd3CXlV4X2m*L9xfTI;%0jFO%qkM?#rso;&@ zaP_B99&}1txdV{{Q12<@|Q^k6nph&VO-yL_tHqK;OD!6<$JynX}QA)ve z{Kie3Qs3hDUc9@yoKs5tRtsAyrE5(o8mBM@BST?Twv<+sO=GpoAcxSKM>Bn&lC_erC;cPZ1gx0$84G&PlV@rMa_I{q1Cl}|sCWdKH zgjrXDQ&)De+fcU0*AhM08RNhJ657s%p7GJ_uHSJiD}fmjbxMp?CY}C!X6r zzqo*#|NPe{i**7#di~zz^#aI%MNKvcX$QgS+1czGnG>pJwrK(%%dv|hkD`>(8UWQb z18$3D#0_J5a{A@h|6#X|?#yPhaL_Ug>)G^d9Y>?_7{C`rAq3JuaEda;MO~w?|$=+WBb4WDE;N{|45T`vs`Qq z22q-TKsVqc6Sbh^rRNSgQ?Bdlx=P}>-y0%-Ntz)aHSUrOuD~bYX-J`USr&Ok89RA) z+V2mer2OG@9_MP6Wz+z}3axU+2y8V`C=F1mWPR^wukY}_Z#ky0ZLwG^OvBW)rh+P6 zX^mK#XiBX(Qe(NLuG!(8BV;nlvX4Lh1bjDz>~#lmyn!24Rk=18Xb3_*+t?e1MxCpC zWis9C`mPNUQqDB5D^fS6!I3P>@CC#JWNBHLoG{<_vHHzdU-_QdYdN9glz^!yuU9GR zF3sZg^}>?+&i=sl`FuVbj|K-j+oH&1oj4K>Da$krA@RX}R8?Koy3|Mts??H+6e$pM9!x)eb_(b#31_Obem}Xi)-E8ohSwjn`hN^JJ?(^aAhU7hkkOKlJ_W?Ll5D z$8;15x~hf-SBt;uM( zf3S1+_U_4dPx^z7!C9Fld*kt_-w{;Dn^M)939~>MH*5h)X;_0!H}J!gr%y*)!|k@eGu$2wyOw1FY2PuC0+VY}6oJe4wnmeF&l0jG z8EV?GP2|j$@^EJ&DdBIu`dpQ4%5<%C9(aDQ9TZg!v5Z$s!Z=cVYj^A2Uq0|WGs|NX z-ST1%l--t_W(BgDmo(25RJX{IEYE;yryW{Ub6vJW4{`8=frK-b$#kU*0m~!{mxtW-vDO}Q*2gi%dotbpBDLioql_IIlWq4EtZ^==^w7O|Q88^LF@8ID1qdRv8-9ayC zyJ$zGoQy{=-+M7hV~AR&Rd2MtxLo9E5rn;(K=-Azd%fZA)zzZi^7p#I!4`nwd6cAS z8U$_A^!R%Zei62O!?HD_Uf92N=jgRpUfJE7kUV>E|BZJaybXL&{~#;k@I2@7SKm06 z`|ab$I|qkxlAs&tJYz&nM*V)<4m`^g%yYpWYTK@5+x(q3f9CprcWV%KL7Yy|>h$~F z@v!&uPhXI%MwY?=jQ4~vQK!h{_s37sBlq|APk(rFc(`3>o4}?A{a~^+2t0v`0TodT z1=_T(q@eu4&+joPiPG><8YU`ILD$O?O)*)=j_qK{5CZ=edBQ0lPbL%`w=KtDtIG@c zJ|47pCnKhE%ano>$7+hfuo~lp5oTKgWx@`gS&4lmzL8sk@IRjOOHm6BxT4q@kjB3@iKZXGhfneCd zc#y;y3e8ZN21LL8@Et_g1k-@iyoYtjA=)LX%WQdu1;&Xuf*KO!NofV%TBg%93v6Z* z4U-8e3=?OYMO}l&P%bKMX}C;PSjTWCkm{RkH;svabHMUuDDp5;+F{V^5KB;i2@R`@ zyi6)xz!eN1*wf?>)^8r1!W2Sivk2vHOx&zvFl(l0+;FplF-!)G;tRSardmH7gkFeR ztBL~Y!BKo*9o{tiDTO(-bfgW_YzFDh(03zjVSoWUun>6D)!-O~><4V*mu8 Date: Thu, 26 Oct 2023 08:53:53 +0300 Subject: [PATCH 1073/1199] emit events and particles on chest upgrade --- .../ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt index f4aefddff..efba143a0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt @@ -17,6 +17,7 @@ import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.entity.BarrelBlockEntity import net.minecraft.world.level.block.entity.ChestBlockEntity +import net.minecraft.world.level.gameevent.GameEvent import net.minecraft.world.level.storage.loot.LootParams import net.minecraft.world.level.storage.loot.parameters.LootContextParams import ru.dbotthepony.mc.otm.OverdriveThatMatters.MOD_ID @@ -47,9 +48,14 @@ class ChestUpgraderItem : Item(Properties().stacksTo(1)) { if (container.containerSize >= 54) return super.onItemUseFirst(stack, context) - if (context.level is ServerLevel) { - val newState = block.getStateForPlacement(BlockPlaceContext(context)) ?: return InteractionResult.FAIL + val blockState = context.level.getBlockState(pos) + val newState = block.getStateForPlacement(BlockPlaceContext(context)) ?: return InteractionResult.FAIL + if (!newState.canSurvive(context.level, pos)) return InteractionResult.FAIL + context.level.gameEvent(GameEvent.BLOCK_DESTROY, pos, GameEvent.Context.of(player, blockState)) + context.level.levelEvent(player, 2001, pos, Block.getId(blockState)) + + if (context.level is ServerLevel) { val contents = Int2ObjectArrayMap(container.containerSize) for (i in 0 until container.containerSize) { contents.put(i, container.getItem(i)) @@ -58,7 +64,6 @@ class ChestUpgraderItem : Item(Properties().stacksTo(1)) { val level = context.level as ServerLevel - val blockState = level.getBlockState(pos) val lootparams = LootParams.Builder(level) .withParameter(LootContextParams.ORIGIN, Vector.atCenterOf(context.clickedPos)) .withParameter(LootContextParams.TOOL, stack) @@ -86,6 +91,8 @@ class ChestUpgraderItem : Item(Properties().stacksTo(1)) { } } + context.level.gameEvent(GameEvent.BLOCK_PLACE, pos, GameEvent.Context.of(player, newState)) + return InteractionResult.SUCCESS } From cf45fe69c5c8831f1267350503f6bd545fe5b568 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Thu, 26 Oct 2023 09:10:48 +0300 Subject: [PATCH 1074/1199] =?UTF-8?q?DBot=20=E2=80=94=20=D0=A1=D0=B5=D0=B3?= =?UTF-8?q?=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=208:52=20=D0=9D=D0=B0=D0=BF?= =?UTF-8?q?=D0=BE=D0=BC=D0=BD=D0=B8=D0=BB=20=D0=A7=D1=82=D0=BE=20=D1=8F?= =?UTF-8?q?=D1=89=D0=B8=D0=BA=20=D0=B4=D0=BE=D0=BB=D0=B6=D0=B5=D0=BD=20?= =?UTF-8?q?=D0=B0=D0=B3=D1=80=D0=B8=D1=82=D1=8C=20=D0=BF=D0=B8=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D0=BD=D0=BE=D0=B2=20=D0=98=D0=B1=D0=BE=20=D0=BE=D0=BD?= =?UTF-8?q?=D0=B8=20=D0=B0=D0=B3=D1=80=D1=8F=D1=82=D1=81=D1=8F=20=D0=B4?= =?UTF-8?q?=D0=B0=D0=B6=D0=B5=20=D0=BD=D0=B0=20=D0=B5=D0=BD=D0=B4=D0=B5?= =?UTF-8?q?=D1=80=20=D1=81=D1=83=D0=BD=D0=B4=D1=83=D0=BA=20=D0=98=20=D1=8D?= =?UTF-8?q?=D1=82=D0=BE=20by=20design?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt | 4 ++++ .../ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt | 1 + .../ru/dbotthepony/mc/otm/entity/MinecartCargoCrate.kt | 9 ++++++--- .../mc/otm/menu/decorative/MinecartCargoCrateMenu.kt | 4 ++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index a75c50d42..74b3e4eeb 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -253,6 +253,10 @@ fun addTags(tagsProvider: TagsProvider) { MBlocks.BLACK_HOLE, ) + tagsProvider.guardedByPiglins.add( + MBlockTags.CARGO_CRATES, + ) + tagsProvider.androidImmuneEffects.add( MobEffects.CONDUIT_POWER, MobEffects.HEAL, diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt index a09ae7255..636f88fa5 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt @@ -182,6 +182,7 @@ class TagsProvider(private val event: GatherDataEvent) { val witherImmune = blocks.Appender(BlockTags.WITHER_IMMUNE) val dragonImmune = blocks.Appender(BlockTags.DRAGON_IMMUNE) + val guardedByPiglins = blocks.Appender(BlockTags.GUARDED_BY_PIGLINS) fun stoneOre(key: String, block: Block): TagsProvider { ore(key, block) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/MinecartCargoCrate.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/MinecartCargoCrate.kt index 4ef8947d7..8e55da5e9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/MinecartCargoCrate.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/MinecartCargoCrate.kt @@ -6,7 +6,9 @@ import net.minecraft.network.syncher.EntityDataSerializers import net.minecraft.network.syncher.SynchedEntityData import net.minecraft.sounds.SoundSource import net.minecraft.world.entity.EntityType +import net.minecraft.world.entity.monster.piglin.PiglinAi import net.minecraft.world.entity.player.Inventory +import net.minecraft.world.entity.player.Player import net.minecraft.world.entity.vehicle.AbstractMinecartContainer import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.DyeColor @@ -81,19 +83,20 @@ class MinecartCargoCrate( var interactingPlayers by entityData.delegate(INTERACTING_PLAYERS) - fun onPlayerOpen() { + fun onPlayerOpen(player: Player) { if (isRemoved) return if (interactingPlayers++ == 0) { if (!isRemoved) { level().playSound(null, this, MSoundEvents.CARGO_CRATE_OPEN, SoundSource.BLOCKS, 1f, 0.8f + level().random.nextFloat() * 0.2f) - level().gameEvent(GameEvent.CONTAINER_OPEN, position, GameEvent.Context.of(this)) + this.gameEvent(GameEvent.CONTAINER_OPEN, player) + PiglinAi.angerNearbyPiglins(player, true) } } } - fun onPlayerClose() { + fun onPlayerClose(player: Player) { if (interactingPlayers <= 0) return diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt index 7ce6c9f23..b4aa8d957 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/MinecartCargoCrateMenu.kt @@ -27,7 +27,7 @@ class MinecartCargoCrateMenu( init { if (trackedPlayerOpen) { - cart?.onPlayerOpen() + cart?.onPlayerOpen(inventory.player) } addStorageSlot(storageSlots) @@ -38,7 +38,7 @@ class MinecartCargoCrateMenu( super.removed(p_38940_) if (trackedPlayerOpen) { - cart?.onPlayerClose() + cart?.onPlayerClose(inventory.player) } } From 15023b659939c0530e11a6504470b4ecdc3cb8d6 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Thu, 26 Oct 2023 10:21:06 +0300 Subject: [PATCH 1075/1199] upgrade minecarts as well --- .../mc/otm/OverdriveThatMatters.java | 3 + .../mc/otm/item/ChestUpgraderItem.kt | 67 +++++++++++++++++-- 2 files changed, 65 insertions(+), 5 deletions(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 0e62d7403..766c5e8ae 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -48,6 +48,7 @@ import ru.dbotthepony.mc.otm.config.MachinesConfig; import ru.dbotthepony.mc.otm.config.ServerCompatConfig; import ru.dbotthepony.mc.otm.config.ServerConfig; import ru.dbotthepony.mc.otm.config.ToolsConfig; +import ru.dbotthepony.mc.otm.item.ChestUpgraderItem; import ru.dbotthepony.mc.otm.item.tool.ExplosiveHammerItem; import ru.dbotthepony.mc.otm.item.armor.TritaniumArmorItem; import ru.dbotthepony.mc.otm.item.QuantumBatteryItem; @@ -198,6 +199,8 @@ public final class OverdriveThatMatters { EVENT_BUS.addListener(EventPriority.NORMAL, ExplosiveHammerItem.Companion::onLeftClickBlock); + EVENT_BUS.addListener(EventPriority.NORMAL, ChestUpgraderItem.Companion::onEntityInteract); + EVENT_BUS.addListener(EventPriority.NORMAL, DevChestBlockEntity.Companion::mappingsChanged); MatteryPlayerNetworkChannel.INSTANCE.register(); diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt index efba143a0..9e6c05910 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt @@ -7,10 +7,9 @@ import net.minecraft.server.level.ServerLevel import net.minecraft.world.Container import net.minecraft.world.InteractionHand import net.minecraft.world.InteractionResult -import net.minecraft.world.item.BlockItem -import net.minecraft.world.item.Item -import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.TooltipFlag +import net.minecraft.world.entity.vehicle.AbstractMinecart +import net.minecraft.world.entity.vehicle.MinecartChest +import net.minecraft.world.item.* import net.minecraft.world.item.context.BlockPlaceContext import net.minecraft.world.item.context.UseOnContext import net.minecraft.world.level.Level @@ -20,11 +19,15 @@ import net.minecraft.world.level.block.entity.ChestBlockEntity import net.minecraft.world.level.gameevent.GameEvent import net.minecraft.world.level.storage.loot.LootParams import net.minecraft.world.level.storage.loot.parameters.LootContextParams +import net.minecraftforge.event.entity.player.PlayerInteractEvent import ru.dbotthepony.mc.otm.OverdriveThatMatters.MOD_ID import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock import ru.dbotthepony.mc.otm.block.entity.decorative.CargoCrateBlockEntity +import ru.dbotthepony.mc.otm.container.set import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.Vector +import ru.dbotthepony.mc.otm.entity.MinecartCargoCrate +import ru.dbotthepony.mc.otm.registry.MEntityTypes class ChestUpgraderItem : Item(Properties().stacksTo(1)) { override fun onItemUseFirst(stack: ItemStack, context: UseOnContext): InteractionResult { @@ -46,7 +49,7 @@ class ChestUpgraderItem : Item(Properties().stacksTo(1)) { if (hitBlockEntity is ChestBlockEntity || hitBlockEntity is BarrelBlockEntity) { val container = hitBlockEntity as Container - if (container.containerSize >= 54) return super.onItemUseFirst(stack, context) + if (container.containerSize > 54) return super.onItemUseFirst(stack, context) val blockState = context.level.getBlockState(pos) val newState = block.getStateForPlacement(BlockPlaceContext(context)) ?: return InteractionResult.FAIL @@ -109,5 +112,59 @@ class ChestUpgraderItem : Item(Properties().stacksTo(1)) { companion object { private val DESCRIPTION = TranslatableComponent("item.${MOD_ID}.chest_upgrader.desc").withStyle(ChatFormatting.DARK_GRAY) private val DESCRIPTION2= TranslatableComponent("item.${MOD_ID}.chest_upgrader.desc2").withStyle(ChatFormatting.DARK_GRAY) + + fun onEntityInteract(event: PlayerInteractEvent.EntityInteract) { + if (event.target !is MinecartChest) return + + val offhand = if (event.entity.getItemInHand(InteractionHand.MAIN_HAND).item is ChestUpgraderItem) { + InteractionHand.OFF_HAND + } else if (event.entity.getItemInHand(InteractionHand.OFF_HAND).item is ChestUpgraderItem) { + InteractionHand.MAIN_HAND + } else { + return + } + + val stack = event.entity.getItemInHand(offhand) + if (stack.isEmpty || stack.item !is MinecartCargoCrateItem) return + val color = (stack.item as MinecartCargoCrateItem).color + + val cart = event.target as MinecartChest + if (cart.containerSize > 54) return + + event.level.levelEvent(event.entity, 2001, event.pos, Block.getId(cart.blockStateOn)) + + if (event.level is ServerLevel) { + val level = event.level as ServerLevel + + val pos = cart.position() + val delta = cart.deltaMovement + + val type = MEntityTypes.CARGO_CRATE_MINECARTS[color] ?: return + val newCart = MinecartCargoCrate(type, color, level, pos.x, pos.y, pos.z) + newCart.xRot = cart.xRot + newCart.yRot = cart.yRot + newCart.deltaMovement = delta + newCart.customName = if (stack.hasCustomHoverName()) stack.hoverName else cart.customName + + val contents = Int2ObjectArrayMap(cart.containerSize) + for (i in 0 until cart.containerSize) { + contents.put(i, cart.getItem(i)) + } + cart.clearContent() + + (cart as AbstractMinecart).destroy(cart.damageSources().genericKill()) + level.addFreshEntity(newCart) + level.gameEvent(GameEvent.ENTITY_PLACE, event.pos, GameEvent.Context.of(event.entity, level.getBlockState(event.pos.below()))) + + if (!event.entity.isCreative) + stack.shrink(1) + + for (i in 0 until contents.size) { + newCart[i] = contents.get(i) + } + + event.cancellationResult = InteractionResult.SUCCESS + } + } } } From 171e16a7c4980b1862f0e6184173dbab6338b16b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 26 Oct 2023 18:44:03 +0700 Subject: [PATCH 1076/1199] Remove Mekanism compat since it will not be updated to newer versions --- build.gradle.kts | 2 - .../mc/otm/OverdriveThatMatters.java | 10 - .../mc/otm/capability/MatteryCapability.java | 5 - .../mc/otm/block/entity/MatteryBlockEntity.kt | 60 +--- .../entity/tech/EnergyCounterBlockEntity.kt | 6 - .../ru/dbotthepony/mc/otm/capability/Ext.kt | 73 +---- .../energy/ItemEnergyStorageImpl.kt | 5 - .../mc/otm/compat/mekanism/Conversions.kt | 32 -- .../mc/otm/compat/mekanism/MekanismHooks.kt | 49 --- .../mc/otm/compat/mekanism/Power.kt | 236 -------------- .../dbotthepony/mc/otm/compat/mekanism/QIO.kt | 301 ------------------ .../mc/otm/item/QuantumBatteryItem.kt | 5 - src/main/resources/coremods/code_injector.js | 74 ----- 13 files changed, 2 insertions(+), 856 deletions(-) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Conversions.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/MekanismHooks.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/QIO.kt diff --git a/build.gradle.kts b/build.gradle.kts index 1b3d60f66..11edbe217 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -171,8 +171,6 @@ dependencies { // runtimeOnly(fg.deobf("curse.maven:worldedit-225608:${worldedit_fileid}")) // runtimeOnly(fg.deobf("at.ridgo8.moreoverlays:MoreOverlays-updated:${more_overlays_version}")) - compileOnly(fg.deobf("mekanism:Mekanism:1.20.1-10.3.9.homebaked:all")) - // runtimeOnly(fg.deobf("curse.maven:cyclops-core-232758:4392602")) // runtimeOnly(fg.deobf("curse.maven:integrated-dynamics-236307:4391535")) // runtimeOnly(fg.deobf("curse.maven:integrated-crafting-287357:4391487")) diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 766c5e8ae..4102cf615 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -38,8 +38,6 @@ import ru.dbotthepony.mc.otm.client.render.blockentity.BatteryBankRenderer; import ru.dbotthepony.mc.otm.client.render.blockentity.MatterBatteryBankRenderer; import ru.dbotthepony.mc.otm.compat.adastra.AdAstraCompatKt; import ru.dbotthepony.mc.otm.compat.curios.CuriosCompatKt; -import ru.dbotthepony.mc.otm.compat.mekanism.MekanismHooks; -import ru.dbotthepony.mc.otm.compat.mekanism.QIOKt; import ru.dbotthepony.mc.otm.config.AndroidConfig; import ru.dbotthepony.mc.otm.config.ClientConfig; import ru.dbotthepony.mc.otm.config.ExopackConfig; @@ -208,10 +206,6 @@ public final class OverdriveThatMatters { WeaponNetworkChannel.INSTANCE.register(); GenericNetworkChannel.INSTANCE.register(); - if (ModList.get().isLoaded("mekanism")) { - EVENT_BUS.addGenericListener(BlockEntity.class, EventPriority.NORMAL, QIOKt::attachCapabilities); - } - if (ModList.get().isLoaded(CuriosApi.MODID)) { EVENT_BUS.addListener(EventPriority.NORMAL, CuriosCompatKt::onCuriosSlotModifiersUpdated); } @@ -249,10 +243,6 @@ public final class OverdriveThatMatters { EVENT_BUS.addListener(EventPriority.NORMAL, QuantumBatteryItem.Companion::clientDisconnect); - if (ModList.get().isLoaded("mekanism")) { - EVENT_BUS.addListener(EventPriority.NORMAL, MekanismHooks::tooltipEvent); - } - EVENT_BUS.addListener(EventPriority.NORMAL, AndroidMenuKeyMapping.INSTANCE::onRenderGuiEvent); EVENT_BUS.addListener(EventPriority.NORMAL, AndroidMenuKeyMapping.INSTANCE::onMouseClick); diff --git a/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java b/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java index 93c227c62..4caae5fed 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java +++ b/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.capability; -import mekanism.api.energy.IStrictEnergyHandler; import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityToken; @@ -51,10 +50,6 @@ public class MatteryCapability { @NotNull public static final Capability STORAGE_NODE = CapabilityManager.get(new CapabilityToken<>() {}); - @Nonnull - @NotNull - public static final Capability MEKANISM_ENERGY = CapabilityManager.get(new CapabilityToken<>() {}); - @Nonnull @NotNull public static final Capability CURIOS_INVENTORY = CapabilityManager.get(new CapabilityToken<>() {}); 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 3bbc3582d..9005db565 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 @@ -7,7 +7,6 @@ import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.ObjectArraySet import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap -import mekanism.api.energy.IStrictEnergyHandler import net.minecraft.core.BlockPos import net.minecraft.core.Direction import net.minecraft.core.SectionPos @@ -41,13 +40,9 @@ import ru.dbotthepony.mc.otm.SERVER_IS_LIVE import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage -import ru.dbotthepony.mc.otm.capability.isMekanismLoaded -import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper -import ru.dbotthepony.mc.otm.compat.mekanism.Mekanism2MatteryEnergyWrapper import ru.dbotthepony.mc.otm.core.ISubscriptable import ru.dbotthepony.mc.otm.core.collect.WeakHashSet import ru.dbotthepony.mc.otm.core.get -import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.RelativeSide @@ -67,7 +62,6 @@ import java.util.function.Consumer import java.util.function.Predicate import java.util.function.Supplier import java.util.stream.Stream -import kotlin.NoSuchElementException import kotlin.properties.ReadWriteProperty import kotlin.reflect.KProperty import kotlin.reflect.KProperty0 @@ -148,19 +142,11 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc protected fun exposeEnergyGlobally(value: IMatteryEnergyStorage, predicate: Predicate = Predicate { true }) { exposeGlobally(ForgeCapabilities.ENERGY, value, predicate) exposeGlobally(MatteryCapability.ENERGY, value, predicate) - - if (isMekanismLoaded) { - exposeGlobally(MatteryCapability.MEKANISM_ENERGY, Mattery2MekanismEnergyWrapper(value), predicate) - } } protected fun exposeEnergySideless(value: IMatteryEnergyStorage) { exposeSideless(ForgeCapabilities.ENERGY, value) exposeSideless(MatteryCapability.ENERGY, value) - - if (isMekanismLoaded) { - exposeSideless(MatteryCapability.MEKANISM_ENERGY, Mattery2MekanismEnergyWrapper(value)) - } } protected fun exposeEnergy(side: RelativeSide, value: IMatteryEnergyStorage): ImmutableList> { @@ -169,10 +155,6 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc accept(thisSide.Cap(ForgeCapabilities.ENERGY, value)) accept(thisSide.Cap(MatteryCapability.ENERGY, value)) - - if (isMekanismLoaded) { - accept(thisSide.Cap(MatteryCapability.MEKANISM_ENERGY, Mattery2MekanismEnergyWrapper(value))) - } } } @@ -227,47 +209,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } fun trackEnergy(): SideListener { - return object : SideListener { - private val regular = track(ForgeCapabilities.ENERGY) - private val mekanism: SubRef? - private var actualMekanism: LazyOptional? = null - - private val listeners = ISubscriptable.Impl>() - - override fun addListener(listener: Consumer>): ISubscriptable.L { - val l = listeners.addListener(listener) - listener.accept(get()) - return l - } - - init { - regular.addListener { listeners.accept(it) } - - if (isMekanismLoaded) { - mekanism = track(MatteryCapability.MEKANISM_ENERGY) as SubRef - - mekanism.addListener { - actualMekanism?.invalidate() - - if (it.isPresent) { - actualMekanism = LazyOptional.of { Mekanism2MatteryEnergyWrapper(it.orElseThrow { NoSuchElementException("No mekanism energy was present, and tracker did not call back in time") }) } - } else { - actualMekanism = null - } - - listeners.accept(get()) - } - } else { - mekanism = null - } - } - - override fun get(): LazyOptional { - val get = regular.get() - get.ifPresentK { if (it is IMatteryEnergyStorage) return get } - return actualMekanism ?: get - } - } + return track(ForgeCapabilities.ENERGY) } fun updateTracked() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt index 91b42964f..445f2ae6d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyCounterBlockEntity.kt @@ -14,7 +14,6 @@ import ru.dbotthepony.mc.otm.block.tech.EnergyCounterBlock import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.* import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage -import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.Decimal @@ -280,11 +279,6 @@ class EnergyCounterBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mat back.Cap(ForgeCapabilities.ENERGY, energyOutput) back.Cap(MatteryCapability.ENERGY, energyOutput) - - if (isMekanismLoaded) { - front.Cap(MatteryCapability.MEKANISM_ENERGY, Mattery2MekanismEnergyWrapper(energyInput)) - back.Cap(MatteryCapability.MEKANISM_ENERGY, Mattery2MekanismEnergyWrapper(energyOutput)) - } } override fun tick() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt index 55e10351a..362f454cc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt @@ -2,17 +2,14 @@ package ru.dbotthepony.mc.otm.capability import com.google.common.collect.Streams import net.minecraft.ChatFormatting -import net.minecraft.core.Direction import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Player import net.minecraft.world.item.ItemStack import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.capabilities.ICapabilityProvider -import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.energy.IEnergyStorage import net.minecraftforge.fluids.FluidStack import net.minecraftforge.fluids.capability.IFluidHandler -import net.minecraftforge.fml.ModList import net.minecraftforge.items.IItemHandler import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage @@ -23,8 +20,6 @@ import ru.dbotthepony.mc.otm.compat.cos.isCosmeticArmorLoaded import ru.dbotthepony.mc.otm.compat.curios.curiosAwareStream import ru.dbotthepony.mc.otm.compat.curios.curiosStream import ru.dbotthepony.mc.otm.compat.curios.isCuriosLoaded -import ru.dbotthepony.mc.otm.compat.mekanism.getMekanismEnergySided -import ru.dbotthepony.mc.otm.compat.mekanism.mekanismEnergy import ru.dbotthepony.mc.otm.container.util.awareStream import ru.dbotthepony.mc.otm.container.util.iterator import ru.dbotthepony.mc.otm.core.collect.AwareItemStack @@ -130,8 +125,6 @@ val IEnergyStorage.chargeRatio: Float get() { return energyStored.toFloat() / maxEnergyStored.toFloat() } -val isMekanismLoaded by lazy { ModList.get().isLoaded("mekanism") } - /** * Shortcut for getting [IEnergyStorage], including wrappers for it */ @@ -142,14 +135,6 @@ val ICapabilityProvider.energy: IEnergyStorage? get() { return mattery.orNull() } - if (isMekanismLoaded) { - val mekanismEnergy = mekanismEnergy - - if (mekanismEnergy != null) { - return mekanismEnergy - } - } - return getCapability(ForgeCapabilities.ENERGY).orNull() } @@ -157,63 +142,7 @@ val ICapabilityProvider.energy: IEnergyStorage? get() { * Shortcut for getting sideless [IMatteryEnergyStorage], including wrappers for it */ val ICapabilityProvider.matteryEnergy: IMatteryEnergyStorage? get() { - val mattery = getCapability(MatteryCapability.ENERGY) - - if (mattery.isPresent) { - return mattery.orNull() - } - - if (isMekanismLoaded) { - val mekanismEnergy = mekanismEnergy - - if (mekanismEnergy != null) { - return mekanismEnergy - } - } - - return null -} - -/** - * Shortcut for getting [LazyOptional] with [IEnergyStorage], including wrappers for it - */ -fun ICapabilityProvider.getEnergySided(side: Direction? = null): LazyOptional { - val mattery = getCapability(MatteryCapability.ENERGY, side) - - if (mattery.isPresent) { - return mattery - } - - if (isMekanismLoaded) { - val mekanismEnergy = getMekanismEnergySided(side) - - if (mekanismEnergy.isPresent) { - return mekanismEnergy - } - } - - return getCapability(ForgeCapabilities.ENERGY, side) -} - -/** - * Shortcut for getting [LazyOptional] with [IMatteryEnergyStorage], including wrappers for it - */ -fun ICapabilityProvider.getMatteryEnergySided(side: Direction? = null): LazyOptional { - val mattery = getCapability(MatteryCapability.ENERGY, side) - - if (mattery.isPresent) { - return mattery - } - - if (isMekanismLoaded) { - val mekanismEnergy = getMekanismEnergySided(side) - - if (mekanismEnergy.isPresent) { - return mekanismEnergy - } - } - - return LazyOptional.empty() + return getCapability(MatteryCapability.ENERGY).orNull() } fun Player.items(includeCosmetics: Boolean = true): Iterator { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt index 8c98543ae..ac71aa330 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt @@ -12,8 +12,6 @@ import net.minecraftforge.common.util.LazyOptional import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy -import ru.dbotthepony.mc.otm.capability.isMekanismLoaded -import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set @@ -21,13 +19,10 @@ import ru.dbotthepony.mc.otm.core.tagNotNull abstract class ItemEnergyStorageImpl(val itemStack: ItemStack) : IMatteryEnergyStorage, ICapabilityProvider, IEnergyStorageImpl { private val resolver = LazyOptional.of { this } - private val resolverMekanism = if (isMekanismLoaded) LazyOptional.of { Mattery2MekanismEnergyWrapper(this) } else null override fun getCapability(cap: Capability, side: Direction?): LazyOptional { if (cap === ForgeCapabilities.ENERGY || cap === MatteryCapability.ENERGY) { return resolver.cast() - } else if (cap === MatteryCapability.MEKANISM_ENERGY) { - return resolverMekanism?.cast() ?: LazyOptional.empty() } return LazyOptional.empty() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Conversions.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Conversions.kt deleted file mode 100644 index ac8219067..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Conversions.kt +++ /dev/null @@ -1,32 +0,0 @@ -package ru.dbotthepony.mc.otm.compat.mekanism - -import mekanism.api.math.FloatingLong -import ru.dbotthepony.mc.otm.core.math.Decimal -import java.math.BigInteger - -private val LONG_OVERFLOW = (BigInteger.valueOf(Long.MAX_VALUE) + BigInteger.valueOf(Long.MAX_VALUE) + BigInteger.TWO) * Decimal.PRECISION_POW_BI -private val LONG_OVERFLOW1 = BigInteger.valueOf(Long.MAX_VALUE) + BigInteger.valueOf(Long.MAX_VALUE) + BigInteger.ONE - -fun Decimal.toFloatingLong(): FloatingLong { - if (isNegative) { - // Floating long can't be negative - return FloatingLong.ZERO - } - - if (whole >= LONG_OVERFLOW1) { - return FloatingLong.MAX_VALUE - } - - return FloatingLong.create(whole.toLong(), (fractionalFloat * 10_000.0).toInt().toShort()) -} - -fun FloatingLong.toDecimal(): Decimal { - var conv = BigInteger.valueOf(value) * Decimal.PRECISION_POW_BI + BigInteger.valueOf((decimal.toDouble() / 10_000.0 * Decimal.PRECISION_DOUBLE).toLong()) - - // Overflow - if (value < 0L) { - conv += LONG_OVERFLOW - } - - return Decimal.raw(conv) -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/MekanismHooks.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/MekanismHooks.kt deleted file mode 100644 index be5a4d36e..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/MekanismHooks.kt +++ /dev/null @@ -1,49 +0,0 @@ -package ru.dbotthepony.mc.otm.compat.mekanism - -import mekanism.api.Action -import mekanism.api.AutomationType -import mekanism.common.capabilities.energy.MachineEnergyContainer -import mekanism.common.registries.MekanismItems -import mekanism.common.tile.TileEntityChargepad -import net.minecraft.ChatFormatting -import net.minecraft.world.entity.LivingEntity -import net.minecraft.world.entity.player.Player -import net.minecraftforge.event.entity.player.ItemTooltipEvent -import ru.dbotthepony.mc.otm.capability.isMekanismLoaded -import ru.dbotthepony.mc.otm.capability.matteryPlayer -import ru.dbotthepony.mc.otm.core.TranslatableComponent - -object MekanismHooks { - @JvmStatic - fun chargeAndroidFromPadHook(container: MachineEnergyContainer, entity: LivingEntity) { - if (entity !is Player) return - - if (entity.matteryPlayer?.isAndroid == true) { - val androidEnergy = entity.matteryPlayer!!.androidEnergy - - val expectedAmount = container.energyPerTick - val remaining = (androidEnergy.receiveEnergy(expectedAmount.toDecimal() * Mekanism2MatteryEnergyWrapper.mekanism2MtJ, true) * Mattery2MekanismEnergyWrapper.mtj2Mekanism).toFloatingLong() - - if (remaining.smallerThan(expectedAmount)) { - val extracted = container.extract(expectedAmount.subtract(remaining), Action.EXECUTE, AutomationType.INTERNAL) - - if (!extracted.isZero) { - androidEnergy.receiveEnergy(extracted.toDecimal() * Mekanism2MatteryEnergyWrapper.mekanism2MtJ, false) - } - } - } - } - - private val BLACKHOLE_IMMUNITY = TranslatableComponent("otm.item.blackhole_immunity").withStyle(ChatFormatting.DARK_GRAY) - - @JvmStatic - fun tooltipEvent(event: ItemTooltipEvent) { - if (!isMekanismLoaded) { - throw IllegalStateException("Mekanism is not loaded!") - } - - if (event.itemStack.`is`(MekanismItems.MODULE_GRAVITATIONAL_MODULATING.get())) { - event.toolTip.add(BLACKHOLE_IMMUNITY) - } - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt deleted file mode 100644 index 583df483c..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/Power.kt +++ /dev/null @@ -1,236 +0,0 @@ -package ru.dbotthepony.mc.otm.compat.mekanism - -import mekanism.api.Action -import mekanism.api.energy.IStrictEnergyHandler -import mekanism.api.math.FloatingLong -import mekanism.common.config.MekanismConfig -import net.minecraft.core.Direction -import net.minecraftforge.common.capabilities.ForgeCapabilities -import net.minecraftforge.common.capabilities.ICapabilityProvider -import net.minecraftforge.common.util.LazyOptional -import net.minecraftforge.energy.IEnergyStorage -import org.apache.logging.log4j.LogManager -import ru.dbotthepony.mc.otm.capability.FlowDirection -import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage -import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.capability.isMekanismLoaded -import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.orNull -import java.lang.ref.WeakReference -import java.util.WeakHashMap - -private val LOGGER = LogManager.getLogger() - -private class LazyCache(private val provider: () -> O, private val computer: (O) -> T) : Lazy { - private var cache: T? = null - private var observed: O? = null - - override fun isInitialized(): Boolean { - return cache != null - } - - override val value: T get() { - if (cache == null || observed == null || observed != provider.invoke()) { - observed = provider.invoke() - cache = computer.invoke(observed ?: throw ConcurrentModificationException()) - } - - return cache ?: throw ConcurrentModificationException() - } -} - -private class DoubleLazy(onion: () -> Lazy) : Lazy { - private val onion = lazy(onion) - override val value: T - get() = onion.value.value - - override fun isInitialized(): Boolean { - return onion.isInitialized() && onion.value.isInitialized() - } -} - -class Mekanism2MatteryEnergyWrapper(private val power: IStrictEnergyHandler, private val forgePower: IEnergyStorage? = null) : IMatteryEnergyStorage { - companion object { - val mekanism2MtJ by DoubleLazy lazy@{ - try { - val conf = MekanismConfig.general - return@lazy LazyCache(conf.forgeConversionRate::get) { Decimal.ONE / it.toDecimal() } - } catch(err: Throwable) { - LOGGER.error("Unable to get Forge Energy to Mekanism Joules's conversion rate! Expect issues", err) - } - - return@lazy lazyOf(Decimal.ONE) - } - } - - override fun extractEnergyChecked(howMuch: Decimal, simulate: Boolean): Decimal { - return extractEnergy(howMuch, simulate) - } - - override fun receiveEnergyChecked(howMuch: Decimal, simulate: Boolean): Decimal { - return receiveEnergy(howMuch, simulate) - } - - override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { - val action = when (simulate) { - true -> Action.SIMULATE - false -> Action.EXECUTE - } - - return power.extractEnergy((howMuch * Mattery2MekanismEnergyWrapper.mtj2Mekanism).toFloatingLong(), action).toDecimal() * mekanism2MtJ - } - - override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { - val action = when (simulate) { - true -> Action.SIMULATE - false -> Action.EXECUTE - } - - return howMuch - power.insertEnergy((howMuch * Mattery2MekanismEnergyWrapper.mtj2Mekanism).toFloatingLong(), action).toDecimal() * mekanism2MtJ - } - - override val canSetBatteryLevel: Boolean - get() = power.energyContainerCount == 1 - - override var batteryLevel: Decimal - get() { - var sum = Decimal.ZERO - - for (i in 0 until power.energyContainerCount) { - sum += power.getEnergy(i).toDecimal() - } - - return sum * mekanism2MtJ - } - set(value) { - if (power.energyContainerCount != 1) - throw UnsupportedOperationException("Can set power only when we have 1 energy container, ${power.energyContainerCount} present") - - power.setEnergy(0, (value * Mattery2MekanismEnergyWrapper.mtj2Mekanism).toFloatingLong()) - } - - override val maxBatteryLevel: Decimal - get() { - var sum = Decimal.ZERO - - for (i in 0 until power.energyContainerCount) { - sum += power.getMaxEnergy(i).toDecimal() - } - - return sum * mekanism2MtJ - } - - override val energyFlow: FlowDirection - get() = FlowDirection.of(output = forgePower?.canExtract() ?: power.extractEnergy(FloatingLong.MAX_VALUE, Action.SIMULATE).greaterThan(FloatingLong.ZERO), input = forgePower?.canReceive() ?: power.insertEnergy(FloatingLong.MAX_VALUE, Action.SIMULATE).greaterThan(FloatingLong.ZERO)) -} - -class Mattery2MekanismEnergyWrapper(private val power: IMatteryEnergyStorage) : IStrictEnergyHandler { - companion object { - val mtj2Mekanism by DoubleLazy lazy@{ - try { - val conf = MekanismConfig.general - return@lazy LazyCache(conf.forgeConversionRate::get) { it.toDecimal() } - } catch(err: Throwable) { - LOGGER.error("Unable to get Mekanism Joules's to Forge Energy conversion rate! Expect issues", err) - } - - return@lazy lazyOf(Decimal.ONE) - } - } - - override fun getEnergyContainerCount(): Int = 1 - - override fun getEnergy(container: Int): FloatingLong { - if (container != 0) { - return FloatingLong.ZERO - } - - return (power.batteryLevel * mtj2Mekanism).toFloatingLong() - } - - override fun setEnergy(container: Int, value: FloatingLong) { - // no op - } - - override fun getMaxEnergy(container: Int): FloatingLong { - if (container != 0) { - return FloatingLong.ZERO - } - - return (power.maxBatteryLevel * mtj2Mekanism).toFloatingLong() - } - - override fun getNeededEnergy(container: Int): FloatingLong { - if (container != 0) { - return FloatingLong.ZERO - } - - return (power.missingPower * mtj2Mekanism).toFloatingLong() - } - - override fun insertEnergy(container: Int, howMuch: FloatingLong, action: Action): FloatingLong { - val copy = howMuch.copy() - return copy.minusEqual((power.receiveEnergyChecked(howMuch.toDecimal() * Mekanism2MatteryEnergyWrapper.mekanism2MtJ, action.simulate()) * mtj2Mekanism).toFloatingLong()) - } - - override fun extractEnergy(container: Int, howMuch: FloatingLong, action: Action): FloatingLong { - return (power.extractEnergyChecked(howMuch.toDecimal() * Mekanism2MatteryEnergyWrapper.mekanism2MtJ, action.simulate()) * mtj2Mekanism).toFloatingLong() - } -} - -val ICapabilityProvider.mekanismEnergy: IMatteryEnergyStorage? get() { - if (!isMekanismLoaded) { - return null - } - - val capability = getCapability(MatteryCapability.MEKANISM_ENERGY) - - if (!capability.isPresent) { - return null - } - - return Mekanism2MatteryEnergyWrapper(capability.orElseThrow(::IllegalStateException), getCapability(ForgeCapabilities.ENERGY).orNull()) -} - -private val lazyCache by lazy { WeakHashMap, WeakReference>>() } -private val lazyCacheDown by lazy { WeakHashMap, WeakReference>>() } -private val lazyCacheUp by lazy { WeakHashMap, WeakReference>>() } -private val lazyCacheSouth by lazy { WeakHashMap, WeakReference>>() } -private val lazyCacheNorth by lazy { WeakHashMap, WeakReference>>() } -private val lazyCacheEast by lazy { WeakHashMap, WeakReference>>() } -private val lazyCacheWest by lazy { WeakHashMap, WeakReference>>() } - -fun ICapabilityProvider.getMekanismEnergySided(side: Direction? = null): LazyOptional { - if (!isMekanismLoaded) return LazyOptional.empty() - val lazyOptional = getCapability(MatteryCapability.MEKANISM_ENERGY, side) - if (!lazyOptional.isPresent) return LazyOptional.empty() - - val cache = when (side) { - Direction.DOWN -> lazyCacheDown - Direction.UP -> lazyCacheUp - Direction.NORTH -> lazyCacheNorth - Direction.SOUTH -> lazyCacheSouth - Direction.WEST -> lazyCacheWest - Direction.EAST -> lazyCacheEast - null -> lazyCache - } - - val cached = cache[lazyOptional]?.get() - if (cached != null) return cached.cast() - - val forgeEnergy = getCapability(ForgeCapabilities.ENERGY, side) - - val resolver = LazyOptional.of { - Mekanism2MatteryEnergyWrapper(lazyOptional.orElseThrow(::IllegalStateException), forgeEnergy.orNull()) - } - - val ref = WeakReference(resolver) - cache[lazyOptional] = ref - - lazyOptional.addListener { - ref.get()?.invalidate() - } - - return resolver.cast() -} - diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/QIO.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/QIO.kt deleted file mode 100644 index d05f2bf3a..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/mekanism/QIO.kt +++ /dev/null @@ -1,301 +0,0 @@ -package ru.dbotthepony.mc.otm.compat.mekanism - -import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap -import it.unimi.dsi.fastutil.objects.Object2ObjectFunction -import mekanism.common.content.qio.QIOFrequency -import mekanism.common.content.qio.QIOFrequency.QIOItemTypeData -import mekanism.common.lib.frequency.Frequency -import mekanism.common.lib.inventory.HashedItem -import mekanism.common.tile.qio.TileEntityQIODriveArray -import net.minecraft.core.Direction -import net.minecraft.resources.ResourceLocation -import net.minecraft.world.level.block.entity.BlockEntity -import net.minecraftforge.common.capabilities.Capability -import net.minecraftforge.common.capabilities.ICapabilityProvider -import net.minecraftforge.common.util.LazyOptional -import net.minecraftforge.event.AttachCapabilitiesEvent -import net.minecraftforge.eventbus.api.SubscribeEvent -import ru.dbotthepony.mc.otm.core.util.ITickable -import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.onceServer -import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.capability.isMekanismLoaded -import ru.dbotthepony.mc.otm.core.math.isPositive -import ru.dbotthepony.mc.otm.core.util.LOHolder -import ru.dbotthepony.mc.otm.graph.storage.StorageNode -import ru.dbotthepony.mc.otm.graph.storage.StorageGraph -import ru.dbotthepony.mc.otm.storage.* -import java.math.BigInteger -import java.util.UUID -import java.util.stream.Stream - -private val QIO_LOCATION = ResourceLocation(OverdriveThatMatters.MOD_ID, "item_storage") - -private class QIOTuple( - val mekanismItem: HashedItem, - override var stack: ItemStorageStack, - override val id: UUID, - var mark: Long -) : IStorageTuple.IMutable - -private class QIOFrequencyAccess(val parent: QIOFrequency) : IStorageComponent { - private var mark = 0L - - override val storageType: StorageStack.Type - get() = StorageStack.ITEMS - - private val index = HashMap() - private val tracked = HashMap() - private val listeners = ArrayList>() - - override fun get(id: UUID): ItemStorageStack { - return index[id]?.stack ?: ItemStorageStack.EMPTY - } - - override val stacks: Stream> get() { - return ArrayList>(index.size).also { it.addAll(index.values) }.stream() - } - - override fun insertStack(stack: ItemStorageStack, simulate: Boolean): ItemStorageStack { - // Because there is no simulate method on QIO array, we have to simulate it by ourselves. - val hash = HashedItem.create(stack.toItemStack()) - - if (!simulate) { - //val used = TransporterManager.getToUse(stack.stack, parent.addItem(stack.stack)) - val used = parent.addItem(stack.toItemStack()) - - if (used.count == stack.count.toInt()) { - return stack - } - - scan(hash) - return ItemStorageStack(used) - } - - if (parent.totalItemCount >= parent.totalItemCountCapacity) { - return stack - } - - if (!parent.itemDataMap.containsKey(hash) && parent.totalItemTypeCapacity <= parent.itemDataMap.size) { - return stack - } - - return stack.copy((parent.totalItemCountCapacity - parent.totalItemCount).toBigInteger().coerceAtMost(stack.count)) - } - - override fun extractStack(id: UUID, amount: BigInteger, simulate: Boolean): ItemStorageStack { - // Because there is no simulate method on QIO array, we have to simulate it by ourselves. - // ASSUMPTION: We can ALWAYS remove items from QIO grid. - - if (!amount.isPositive) - return ItemStorageStack.EMPTY - - var local = index[id] ?: return ItemStorageStack.EMPTY - scan(local.mekanismItem) - local = index[id] ?: return ItemStorageStack.EMPTY // unexpected... - - if (simulate) { - return local.stack.copy(local.stack.count.coerceAtMost(amount)) - } - - val removed = parent.removeByType(local.mekanismItem, amount.toInt()) - - if (removed.isEmpty) { - return ItemStorageStack.EMPTY - } - - val copy = ItemStorageStack(removed) - - if (local.stack.count > copy.count) { - // expecting stack to be still present in QIO storage grid - scan(local.mekanismItem) - } else { - // expecting stack to be removed from QIO storage grid - check(parent.itemDataMap[local.mekanismItem] == null) { - "${local.mekanismItem} is expected to be empty in $parent, got ${parent.itemDataMap[local.mekanismItem]}" - } - - for (listener in listeners) { - listener.onStackRemoved(local) - } - - index.remove(local.id) - tracked.remove(local.mekanismItem) - } - - return copy - } - - override fun addListener(listener: IStorageEventConsumer): Boolean { - if (!listeners.contains(listener)) { - listeners.add(listener) - return true - } - - return false - } - - override fun removeListener(listener: IStorageEventConsumer): Boolean { - return listeners.remove(listener) - } - - private fun scan(at: HashedItem, value: QIOItemTypeData = parent.itemDataMap[at] ?: throw IllegalArgumentException("$parent does not have item $at (${at.internalStack})")) { - val local = tracked[at] - - if (local != null) { - local.mark = mark - - if (local.stack.count.toLong() != value.count) { - local.stack = local.stack.copy(value.count.toBigInteger()) - - for (listener in listeners) { - listener.onStackChanged(local) - } - } - } else { - val tuple = QIOTuple(at, ItemStorageStack(at.internalStack, value.count.toBigInteger()), UUID.randomUUID(), mark) - index[tuple.id] = tuple - - for (listener in listeners) { - listener.onStackAdded(tuple, this) - } - - tracked[at] = tuple - } - } - - fun scan() { - mark++ - - for ((key, value) in parent.itemDataMap) { - scan(key, value) - } - - var changed: ArrayList? = null - - for ((key, value) in tracked) { - if (value.mark != mark) { - if (changed == null) { - changed = ArrayList() - } - - changed.add(key) - } - } - - // sweep - if (changed != null) { - for (key in changed) { - val tuple = tracked.remove(key)!! - - for (listener in listeners) { - listener.onStackRemoved(tuple) - } - - index.remove(tuple.id) - tracked.remove(tuple.mekanismItem) - } - } - } -} - -private class QIOStorage(private val tile: TileEntityQIODriveArray) : ICapabilityProvider { - private var lastFrequency: QIOFrequency? = null - private var frequencyAccess: QIOFrequencyAccess? = null - private var wasAttached = false - - val cell: StorageNode = object : StorageNode(), ITickable { - init { - manualAttaching = true - } - - override fun tick() { - if (tile.isRemoved) { - isValid = false - return - } - - val frequency = tile.qioFrequency - - if (frequency != lastFrequency) { - if (wasAttached) { - wasAttached = false - - val lastFrequency = lastFrequency ?: throw IllegalStateException("lastFrequency is null") - - graph.userData.remove(key(lastFrequency)) - } - - frequencyAccess?.let(this::removeStorageComponent) - lastFrequency = frequency - - if (frequency != null) { - frequencyAccess = QIOFrequencyAccess(frequency).also(this::addStorageComponent) - } - } - - val frequencyAccess = frequencyAccess ?: return - frequencyAccess.scan() - val key = key(frequencyAccess.parent) - - if (!graph.userData.containsKey(key)) { - graph.userData[key] = true - wasAttached = true - graph.add(frequencyAccess) - } - } - - override fun removeComponents(from: StorageGraph) { - super.removeComponents(from) - - if (wasAttached) { - val lastFrequency = lastFrequency ?: throw IllegalStateException("lastFrequency is null") - from.userData.remove(key(lastFrequency)) - wasAttached = false - } - } - - override fun invalidate() { - super.invalidate() - holder.invalidate() - } - - override fun revive() { - super.revive() - holder.revive() - } - } - - private val holder = LOHolder(cell) - - override fun getCapability(cap: Capability, side: Direction?): LazyOptional { - if (cap === MatteryCapability.STORAGE_NODE) - return holder.get() - - return LazyOptional.empty() - } - - companion object { - private fun key(frequency: Frequency) = keyMap.computeIfAbsent(frequency.name to frequency.owner, Object2ObjectFunction { UUID.randomUUID() }) - private val keyMap = Object2ObjectArrayMap, UUID>() - } -} - -@SubscribeEvent -@Suppress("unused") -fun attachCapabilities(event: AttachCapabilitiesEvent) { - if (!isMekanismLoaded) { - throw IllegalStateException("This event should never be called if Mekanism is not loaded.") - } - - if (event.`object` is TileEntityQIODriveArray) { - val capability = QIOStorage(event.`object` as TileEntityQIODriveArray) - event.addCapability(QIO_LOCATION, capability) - - onceServer { - if (!event.`object`.isRemoved) { - capability.cell.discover(event.`object`, MatteryCapability.STORAGE_NODE) - } - } - } -} 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 4a141d219..9c481ffa6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt @@ -29,9 +29,7 @@ import ru.dbotthepony.mc.otm.capability.trackedItems import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.getBarColor import ru.dbotthepony.mc.otm.capability.energy.getBarWidth -import ru.dbotthepony.mc.otm.capability.isMekanismLoaded import ru.dbotthepony.mc.otm.capability.matteryEnergy -import ru.dbotthepony.mc.otm.compat.mekanism.Mattery2MekanismEnergyWrapper import ru.dbotthepony.mc.otm.config.EnergyBalanceValues import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.collect.filter @@ -160,7 +158,6 @@ class QuantumBatteryItem(val savedataID: String, val balanceValues: EnergyBalanc private inner class Power(private val stack: ItemStack) : IMatteryEnergyStorage, ICapabilityProvider { private val resolver = LazyOptional.of { this } - private val resolverMekanism = if (isMekanismLoaded) LazyOptional.of { Mattery2MekanismEnergyWrapper(this) } else null override val energyFlow: FlowDirection get() = FlowDirection.BI_DIRECTIONAL @@ -181,8 +178,6 @@ class QuantumBatteryItem(val savedataID: String, val balanceValues: EnergyBalanc override fun getCapability(cap: Capability, side: Direction?): LazyOptional { if (cap == ForgeCapabilities.ENERGY || cap == MatteryCapability.ENERGY) { return resolver.cast() - } else if (cap == MatteryCapability.MEKANISM_ENERGY) { - return resolverMekanism?.cast() ?: LazyOptional.empty() } return LazyOptional.empty() diff --git a/src/main/resources/coremods/code_injector.js b/src/main/resources/coremods/code_injector.js index d556eb438..d3ab6ff84 100644 --- a/src/main/resources/coremods/code_injector.js +++ b/src/main/resources/coremods/code_injector.js @@ -728,80 +728,6 @@ function initializeCoreMod() { } } - return node - } - }, - - 'Mekanism Chargepad Android Charge': { - 'target': { - 'type': 'METHOD', - 'class': 'mekanism.common.tile.TileEntityChargepad', - 'methodName': 'onUpdateServer', - 'methodDesc': '()V' - }, - - 'transformer': function(node) { - var skipLabel = new Label() - var skipLabelNode = new LabelNode(skipLabel) - - var labelIteratorEndNode - - for (i = 0; i < node.instructions.size(); i++) { - var insn = node.instructions.get(i) - - if (insn && insn.getOpcode() == opcodesRemapped.getfield && insn.name == 'CuriosLoaded') { - var nextInsn = node.instructions.get(i + 1) // IFEQ - - labelIteratorEndNode = nextInsn.label - - break - } - } - - if (!labelIteratorEndNode) return node - - for (i = 0; i < node.instructions.size(); i++) { - var insn = node.instructions.get(i) - - if (insn && insn.getType() == AbstractInsnNode.LABEL) { - if (insn == labelIteratorEndNode) { - putInstructions(node, insn, [ - new VarInsnNode(opcodesRemapped.aload, 0), - new FieldInsnNode( - opcodesRemapped.getfield, - 'mekanism/common/tile/TileEntityChargepad', - 'energyContainer', - 'Lmekanism/common/capabilities/energy/MachineEnergyContainer;' - ), - new VarInsnNode(opcodesRemapped.aload, 4), - new MethodInsnNode( - opcodesRemapped.invokestatic, - 'ru/dbotthepony/mc/otm/compat/mekanism/MekanismHooks', - 'chargeAndroidFromPadHook', - '(Lmekanism/common/capabilities/energy/MachineEnergyContainer;Lnet/minecraft/world/entity/LivingEntity;)V' - ), - skipLabelNode - ]) - - break - } - } - } - - for (i = 0; i < node.instructions.size(); i++) { - var insn = node.instructions.get(i) - - if (insn && insn.getOpcode() == opcodesRemapped.invokevirtual && insn.name == 'chargeHandler' && insn.desc == '(Ljava/util/Optional;)Z') { - var nextInsn = node.instructions.get(i + 1) // curios call is POP, pre-curios check call is IFNE; both need to redirect to loop skip label - - if (nextInsn && (nextInsn.getOpcode() == opcodesRemapped.pop || nextInsn.getOpcode() == opcodesRemapped.ifne && nextInsn.label == labelIteratorEndNode)) { - node.instructions.set(nextInsn, new JumpInsnNode(opcodesRemapped.ifne, skipLabelNode)) - - continue - } - } - } - return node } } From 474a19a30b27a0c19c7dda3d0e526bb1a12ec7f8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 26 Oct 2023 18:52:30 +0700 Subject: [PATCH 1077/1199] Make painter table reflect reality (real life colors are mixed subtractively) --- .../entity/decorative/PainterBlockEntity.kt | 22 +------------------ 1 file changed, 1 insertion(+), 21 deletions(-) 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 c5272967c..3e7c38a25 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 @@ -187,30 +187,10 @@ class PainterBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDe } val MIXING = immutableMap { - put(Mixer(DyeColor.WHITE, immutableList(DyeColor.RED, DyeColor.GREEN, DyeColor.BLUE))) - put(Mixer(DyeColor.LIGHT_GRAY, immutableList(DyeColor.BLACK, DyeColor.WHITE, DyeColor.WHITE))) - put(Mixer(DyeColor.GRAY, immutableList(DyeColor.BLACK, DyeColor.WHITE))) - put(Mixer(DyeColor.ORANGE, immutableList(DyeColor.YELLOW, DyeColor.RED))) - put(Mixer(DyeColor.LIME, immutableList(DyeColor.GREEN, DyeColor.WHITE))) - put(Mixer(DyeColor.LIGHT_BLUE, immutableList(DyeColor.BLUE, DyeColor.WHITE))) - put(Mixer(DyeColor.CYAN, immutableList(DyeColor.BLUE, DyeColor.GREEN))) - put(Mixer(DyeColor.PURPLE, immutableList(DyeColor.BLUE, DyeColor.RED))) - - put(Mixer( - DyeColor.MAGENTA, - immutableList(DyeColor.PURPLE, DyeColor.PINK), - immutableList(DyeColor.RED, DyeColor.RED, DyeColor.BLUE, DyeColor.WHITE), - immutableList(DyeColor.PINK, DyeColor.RED, DyeColor.BLUE) - )) - - put(Mixer(DyeColor.PINK, immutableList(DyeColor.RED, DyeColor.WHITE))) - + put(Mixer(DyeColor.BLACK, immutableList(DyeColor.CYAN, DyeColor.MAGENTA, DyeColor.YELLOW))) put(Mixer(DyeColor.RED, immutableList(DyeColor.MAGENTA, DyeColor.YELLOW))) put(Mixer(DyeColor.GREEN, immutableList(DyeColor.CYAN, DyeColor.YELLOW))) put(Mixer(DyeColor.BLUE, immutableList(DyeColor.CYAN, DyeColor.MAGENTA))) - put(Mixer(DyeColor.BLACK, immutableList(DyeColor.CYAN, DyeColor.MAGENTA, DyeColor.YELLOW))) - put(Mixer(DyeColor.YELLOW, immutableList(DyeColor.RED, DyeColor.GREEN))) - put(Mixer(DyeColor.BROWN, immutableList(DyeColor.MAGENTA, DyeColor.YELLOW, DyeColor.BLACK))) } const val MAX_STORAGE = 256 From 636afe639ebba98a406ee2a70cef6279848fd36f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 26 Oct 2023 20:51:26 +0700 Subject: [PATCH 1078/1199] Painter table water ingredient, semi-realistic color mixing --- .../datagen/recipes/CraftingTableRecipes.kt | 2 +- .../mc/otm/datagen/recipes/PainterRecipes.kt | 2 +- .../entity/decorative/PainterBlockEntity.kt | 164 +++++++++++++----- .../client/screen/decorative/PainterScreen.kt | 32 +++- .../otm/compat/jei/PainterRecipeCategory.kt | 3 +- .../mc/otm/menu/decorative/PainterMenu.kt | 13 +- .../mc/otm/recipe/PainterRecipe.kt | 61 +++++-- 7 files changed, 211 insertions(+), 66 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index 4d8bd96b8..509e9e9f6 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -445,7 +445,7 @@ fun addCraftingTableRecipes(consumer: RecipeOutput) { .build(consumer) MatteryRecipe(MItems.PAINTER, category = machinesCategory) - .row(Items.BRUSH, Items.BUCKET, Items.WATER_BUCKET) + .row(Items.BRUSH, Items.BUCKET, Items.BUCKET) .row(MItemTags.IRON_PLATES, Items.BUCKET, MItemTags.IRON_PLATES) .row(MItemTags.IRON_PLATES, MItemTags.CRAFTING_TABLES, MItemTags.IRON_PLATES) .unlockedBy(Tags.Items.DYES) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt index 7891470df..3a283b803 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt @@ -50,7 +50,7 @@ private fun cleaning(consumer: RecipeOutput, to: Item, from: Map(DyeColor::class.java) - val dyeStoredView: Map = Collections.unmodifiableMap(dyeStored) + // null - water + val dyeStored = Object2IntArrayMap() var isBulk = false set(value) { @@ -36,19 +46,63 @@ class PainterBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDe markDirtyFast() } + override fun getTanks(): Int { + return 1 + } + + override fun getFluidInTank(tank: Int): FluidStack { + if (tank != 1) return FluidStack.EMPTY + if (waterStored() == 0) return FluidStack.EMPTY + return FluidStack(Fluids.WATER, waterStored()) + } + + override fun getTankCapacity(tank: Int): Int { + if (tank == 1) return MAX_WATER_STORAGE + return 0 + } + + override fun isFluidValid(tank: Int, stack: FluidStack): Boolean { + return tank == 0 && stack.fluid == Fluids.WATER + } + + override fun fill(resource: FluidStack, action: IFluidHandler.FluidAction): Int { + if (resource.isEmpty || resource.fluid != Fluids.WATER || waterStored() >= MAX_WATER_STORAGE) return 0 + val diff = (waterStored() + resource.amount).coerceAtMost(MAX_WATER_STORAGE) - waterStored() + if (action.simulate() || diff == 0) return diff + dyeStored[null] = waterStored() + diff + return diff + } + + override fun drain(resource: FluidStack, action: IFluidHandler.FluidAction): FluidStack { + return FluidStack.EMPTY + } + + override fun drain(maxDrain: Int, action: IFluidHandler.FluidAction): FluidStack { + return FluidStack.EMPTY + } + init { addDroppableContainer(dyeInput) savetables.stateful(dyeInput, INVENTORY_KEY) savetables.bool(::isBulk) + exposeGlobally(ForgeCapabilities.FLUID_HANDLER, this) } - fun takeDyes(dyes: Map) { + fun takeDyes(dyes: Map) { for ((dye, amount) in dyes) { - for (i in 0 until amount) { - mixer(dye).mix(dyeStored) + if (dye == null) { + for (i in 0 until amount) { + if (waterStored() >= 1) { + dyeStored[dye] = waterStored() - 1 + } + } + } else { + for (i in 0 until amount) { + mixer(dye)?.mix(dyeStored) - if (dyeStored(dye) > 0) { - dyeStored[dye] = dyeStored(dye) - 1 + if (dyeStored(dye) > 0) { + dyeStored[dye] = dyeStored(dye) - 1 + } } } } @@ -58,6 +112,16 @@ class PainterBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDe val config = ConfigurableItemHandler(input = dyeInput.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { + if (waterStored() < MAX_WATER_STORAGE) { + stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK { + val drain = it.drain(FluidStack(Fluids.WATER, MAX_WATER_STORAGE - waterStored()), IFluidHandler.FluidAction.SIMULATE) + + if (drain.isNotEmpty) { + return true + } + } + } + val dye = DyeColor.entries.firstOrNull { stack.`is`(it.tag) } ?: return false return dyeStored(dye) + HUE_PER_ITEM <= MAX_STORAGE } @@ -75,14 +139,12 @@ class PainterBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDe } })) - fun dyeStored(dye: DyeColor): Int { - return dyeStored[dye]!! + fun waterStored(): Int { + return dyeStored.getInt(null) } - init { - for (dye in DyeColor.entries) { - dyeStored[dye] = 0 - } + fun dyeStored(dye: DyeColor?): Int { + return dyeStored.getInt(dye) } override fun saveShared(nbt: CompoundTag) { @@ -90,7 +152,7 @@ class PainterBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDe nbt["dyes"] = CompoundTag().also { for ((k, v) in dyeStored) { - it[k.getName()] = v + it[k?.getName() ?: "water"] = v } } } @@ -98,13 +160,14 @@ class PainterBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDe override fun load(nbt: CompoundTag) { super.load(nbt) - for (dye in DyeColor.entries) { - dyeStored[dye] = 0 - } + dyeStored.clear() nbt.mapPresent("dyes") { it: CompoundTag -> for (k in it.allKeys) { - dyeStored[DyeColor.entries.firstOrNull { it.getName() == k } ?: continue] = it.getInt(k) + if (k == "water") + dyeStored[null] = it.getInt("water") + else + dyeStored[DyeColor.entries.firstOrNull { it.getName() == k } ?: continue] = it.getInt(k) } } } @@ -113,6 +176,17 @@ class PainterBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDe super.tick() for (slot in dyeInput.slotIterator()) { + if (waterStored() < MAX_WATER_STORAGE) { + slot.item.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK { + val drain = it.drain(FluidStack(Fluids.WATER, MAX_WATER_STORAGE - waterStored()), IFluidHandler.FluidAction.EXECUTE) + + if (drain.isNotEmpty) { + dyeStored[null] = waterStored() + drain.amount + slot.item = it.container + } + } + } + val dye = DyeColor.entries.firstOrNull { slot.item.`is`(it.tag) } ?: continue val stored = dyeStored(dye) @@ -124,20 +198,20 @@ class PainterBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDe } } - class Mixer(val color: DyeColor, vararg mixing: ImmutableList) : Map.Entry { - val mixing: ImmutableList> = ImmutableList.copyOf(mixing) + class Mixer(val color: DyeColor, vararg mixing: ImmutableList>) : Map.Entry { + val mixing: ImmutableList>> = ImmutableList.copyOf(mixing) override val key: DyeColor get() = color override val value: Mixer get() = this - private fun mix(input: MutableMap, seen: MutableSet, stack: MutableSet) { - if (input[color]!! > 0 || color in seen || color in stack) return + private fun mix(input: Object2IntMap, seen: MutableSet, stack: MutableSet) { + if (input.getInt(color) > 0 || color in seen || color in stack) return stack.add(color) for (ingredients in mixing) { - val copy = EnumMap(input) + val copy = Object2IntArrayMap(input) var i = 0 val volumes = Int2IntArrayMap() @@ -146,8 +220,11 @@ class PainterBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDe for (i2 in ingredients.indices) volumes[i2] = 1 - while (!ingredients.all { copy[it]!! > 0 } && i++ < 20) { - ingredients.withIndex().forEach { for (t in 0 until volumes[it.index]) mixer(it.value).mix(copy, seen, stack) } + while (!ingredients.all { copy.getInt(it.orElse(null)) > 0 } && i++ < 20) { + ingredients.withIndex().forEach { + for (t in 0 until volumes[it.index]) + it.value.ifPresent { mixer(it)?.mix(copy, seen, stack) } + } var increase = i val iter = ingredients.indices.iterator() @@ -157,8 +234,8 @@ class PainterBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDe } } - if (ingredients.all { copy[it]!! > 0 }) { - ingredients.forEach { copy[it] = copy[it]!! - 1 } + if (ingredients.all { copy.getInt(it.orElse(null)) > 0 }) { + ingredients.forEach { copy[it.orElse(null)] = copy.getInt(it.orElse(null)) - 1 } copy[color] = ingredients.size input.putAll(copy) @@ -171,29 +248,38 @@ class PainterBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDe seen.add(color) } - fun mix(input: MutableMap) { + fun mix(input: Object2IntMap) { mix(input, EnumSet.noneOf(DyeColor::class.java), EnumSet.noneOf(DyeColor::class.java)) } - fun isAvailable(input: Map): Boolean { - if (input[color]!! > 0) return true - return EnumMap(input).also(::mix)[color]!! > 0 + fun isAvailable(input: Object2IntMap): Boolean { + if (input.getInt(color) > 0) return true + return Object2IntArrayMap(input).also(::mix).getInt(color) > 0 } } companion object { - fun mixer(color: DyeColor): Mixer { - return MIXING[color]!! + fun mixer(color: DyeColor): Mixer? { + return MIXING[color] } - val MIXING = immutableMap { - put(Mixer(DyeColor.BLACK, immutableList(DyeColor.CYAN, DyeColor.MAGENTA, DyeColor.YELLOW))) - put(Mixer(DyeColor.RED, immutableList(DyeColor.MAGENTA, DyeColor.YELLOW))) - put(Mixer(DyeColor.GREEN, immutableList(DyeColor.CYAN, DyeColor.YELLOW))) - put(Mixer(DyeColor.BLUE, immutableList(DyeColor.CYAN, DyeColor.MAGENTA))) + val MIXING = immutableMap { + put(Mixer(DyeColor.BLACK, immutableList(Optional.of(DyeColor.CYAN), Optional.of(DyeColor.MAGENTA), Optional.of(DyeColor.YELLOW)))) + put(Mixer(DyeColor.RED, immutableList(Optional.of(DyeColor.MAGENTA), Optional.of(DyeColor.YELLOW)))) + put(Mixer(DyeColor.GREEN, immutableList(Optional.of(DyeColor.CYAN), Optional.of(DyeColor.YELLOW)))) + put(Mixer(DyeColor.BLUE, immutableList(Optional.of(DyeColor.CYAN), Optional.of(DyeColor.MAGENTA)))) + put(Mixer(DyeColor.LIGHT_BLUE, immutableList(Optional.of(DyeColor.WHITE), Optional.of(DyeColor.BLUE)))) + put(Mixer(DyeColor.LIME, immutableList(Optional.of(DyeColor.WHITE), Optional.of(DyeColor.GREEN)))) + put(Mixer(DyeColor.ORANGE, immutableList(Optional.of(DyeColor.WHITE), Optional.of(DyeColor.RED), Optional.empty()))) + put(Mixer(DyeColor.PURPLE, immutableList(Optional.of(DyeColor.CYAN), Optional.of(DyeColor.MAGENTA), Optional.empty()))) + put(Mixer(DyeColor.BROWN, immutableList(Optional.of(DyeColor.YELLOW), Optional.of(DyeColor.MAGENTA), Optional.of(DyeColor.BLACK), Optional.empty()))) + put(Mixer(DyeColor.PINK, immutableList(Optional.of(DyeColor.YELLOW), Optional.of(DyeColor.MAGENTA), Optional.of(DyeColor.WHITE), Optional.empty()))) + put(Mixer(DyeColor.GRAY, immutableList(Optional.of(DyeColor.WHITE), Optional.of(DyeColor.BLACK), Optional.empty()))) + put(Mixer(DyeColor.LIGHT_GRAY, immutableList(Optional.of(DyeColor.WHITE), Optional.of(DyeColor.WHITE), Optional.of(DyeColor.BLACK), Optional.empty()))) } const val MAX_STORAGE = 256 const val HUE_PER_ITEM = 32 + const val MAX_WATER_STORAGE = 4_000 } } 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 792b6cfde..30bd9e6b2 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 @@ -34,11 +34,16 @@ import ru.dbotthepony.mc.otm.core.util.CreativeMenuItemComparator import ru.dbotthepony.mc.otm.menu.decorative.PainterMenu class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { - private inner class Bar(parent: EditablePanel<*>, val dye: DyeColor) : EditablePanel(this@PainterScreen, parent, width = 5f) { + private inner class Bar(parent: EditablePanel<*>, val dye: DyeColor?) : EditablePanel(this@PainterScreen, parent, width = 5f) { init { dock = Dock.RIGHT dockLeft = 1f - tooltips.add(TranslatableComponent("item.minecraft.${dye.getName()}_dye")) + + if (dye == null) + tooltips.add(TranslatableComponent("block.minecraft.water")) + else + tooltips.add(TranslatableComponent("item.minecraft.${dye.getName() ?: "water"}_dye")) + tooltips.add(TextComponent("")) tooltips.add(TextComponent("")) } @@ -46,10 +51,10 @@ class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { graphics.renderRect(0f, 0f, width, height, color = RGBAColor.DARK_GRAY) - val color = RGBAColor.rgb(dye.textColor) + val color = RGBAColor.rgb(dye?.textColor ?: DyeColor.LIGHT_BLUE.textColor) graphics.renderRect(0f, 0f, width, height, color = color.copy(alpha = 0.4f)) - val multiplier = menu.dyeStoredDirect[dye]!!.toFloat() / PainterBlockEntity.MAX_STORAGE.toFloat() + val multiplier = menu.dyeStoredDirect[dye]!!.toFloat() / (if (dye == null) PainterBlockEntity.MAX_WATER_STORAGE.toFloat() else PainterBlockEntity.MAX_STORAGE.toFloat()) graphics.renderRect(0f, height * (1f - multiplier), width, height * multiplier, color = color) tooltips[tooltips.size - 1] = TextComponent("${menu.dyeStoredDirect[dye]} (${(multiplier * 100f).toInt()}%)") @@ -68,10 +73,12 @@ class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : it.dockTop = 4f } - EditablePanel(this, frame, width = 6f * DyeColor.entries.size / 2f).also { + EditablePanel(this, frame, width = 6f * (DyeColor.entries.size / 2f + 1f)).also { it.dock = Dock.RIGHT it.dockLeft = 4f + Bar(it, null).childrenOrder = -1000 + EditablePanel(this, it, height = 46f).also { it.dock = Dock.TOP @@ -141,10 +148,17 @@ class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : recipe.value.dyes.forEach { val (dye, amount) = it - if (amount == 1) - list.add(TranslatableComponent("otm.gui.needs", TranslatableComponent("item.minecraft.${dye.getName()}_dye"))) - else if (amount > 1) - list.add(TranslatableComponent("otm.gui.needs_x", TranslatableComponent("item.minecraft.${dye.getName()}_dye"), amount)) + if (dye == null) { + if (amount == 1) + list.add(TranslatableComponent("otm.gui.needs", TranslatableComponent("block.minecraft.water"))) + else if (amount > 1) + list.add(TranslatableComponent("otm.gui.needs_x", TranslatableComponent("block.minecraft.water"), amount)) + } else { + if (amount == 1) + list.add(TranslatableComponent("otm.gui.needs", TranslatableComponent("item.minecraft.${dye.getName() ?: "water"}_dye"))) + else if (amount > 1) + list.add(TranslatableComponent("otm.gui.needs_x", TranslatableComponent("item.minecraft.${dye.getName() ?: "water"}_dye"), amount)) + } } graphics.renderComponentTooltip(font, list, mouseX.toInt(), mouseY.toInt()) 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 a948eae2f..d6dfafbe4 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 @@ -11,6 +11,7 @@ import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.Items import net.minecraft.world.item.crafting.Ingredient import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.client.render.ItemStackIcon @@ -55,7 +56,7 @@ object PainterRecipeCategory : IRecipeCategory, IDrawable { for ((dye, count) in recipe.dyes) { builder.addSlot(RecipeIngredientRole.CATALYST, 1 + x * 18, 1 + y * 18) - .addIngredients(VanillaTypes.ITEM_STACK, Ingredient.of(dye.tag).items.map { it.copyWithCount(count) }) + .addIngredients(VanillaTypes.ITEM_STACK, dye?.let { Ingredient.of(it.tag).items.map { it.copyWithCount(count) } } ?: listOf(ItemStack(Items.WATER_BUCKET, count))) y++ 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 2a7966860..94298f266 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 @@ -6,6 +6,10 @@ import net.minecraft.world.entity.player.Player import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.RecipeHolder +import net.minecraft.world.level.material.Fluids +import net.minecraftforge.common.capabilities.ForgeCapabilities +import net.minecraftforge.fluids.FluidStack +import net.minecraftforge.fluids.capability.IFluidHandler import ru.dbotthepony.mc.otm.block.entity.decorative.PainterBlockEntity import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.container.MatteryContainer @@ -15,6 +19,7 @@ import ru.dbotthepony.mc.otm.core.collect.SupplierMap import ru.dbotthepony.mc.otm.core.collect.filter import ru.dbotthepony.mc.otm.core.collect.find import ru.dbotthepony.mc.otm.core.collect.maybe +import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.core.map import ru.dbotthepony.mc.otm.core.util.CreativeMenuItemComparator @@ -34,7 +39,7 @@ import kotlin.collections.ArrayList class PainterMenu( containerId: Int, inventory: Inventory, tile: PainterBlockEntity? = null ) : MatteryMenu(MMenus.PAINTER, containerId, inventory, tile) { - val dyeStored = DyeColor.entries.associateWith { dye -> + val dyeStored = (DyeColor.entries.toMutableList().also { it.add(0, null) }).associateWith { dye -> mSynchronizer.ComputedIntField({ tile?.dyeStored(dye) ?: 0 }).also { it.addListener(IntConsumer { rescan() }) } } @@ -95,7 +100,11 @@ class PainterMenu( val dyeSlot = object : MatterySlot(tile?.dyeInput ?: SimpleContainer(1), 0) { override fun mayPlace(itemStack: ItemStack): Boolean { - return super.mayPlace(itemStack) && (DyeColor.getColor(itemStack)?.let { dyeStoredDirect[it]!! + PainterBlockEntity.HUE_PER_ITEM <= PainterBlockEntity.MAX_STORAGE } ?: false) + return super.mayPlace(itemStack) && (( + itemStack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).resolve().map { + dyeStoredDirect[null]!! < PainterBlockEntity.MAX_WATER_STORAGE && it.drain(FluidStack(Fluids.WATER, PainterBlockEntity.MAX_WATER_STORAGE - dyeStoredDirect[null]!!), IFluidHandler.FluidAction.SIMULATE).isNotEmpty + }.orElse(false) + ) || (DyeColor.getColor(itemStack)?.let { dyeStoredDirect[it]!! + PainterBlockEntity.HUE_PER_ITEM <= PainterBlockEntity.MAX_STORAGE } ?: false)) } } 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 1f3210b9e..e72cc284e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt @@ -1,11 +1,16 @@ package ru.dbotthepony.mc.otm.recipe +import com.google.common.collect.ImmutableMap import com.mojang.serialization.Codec import com.mojang.serialization.codecs.RecordCodecBuilder +import it.unimi.dsi.fastutil.objects.Object2IntArrayMap +import it.unimi.dsi.fastutil.objects.Object2IntMap +import it.unimi.dsi.fastutil.objects.Object2IntMaps import net.minecraft.core.NonNullList import net.minecraft.core.RegistryAccess import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.resources.ResourceLocation +import net.minecraft.util.StringRepresentable import net.minecraft.world.Container import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack @@ -26,28 +31,32 @@ import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRecipes import java.util.EnumMap import java.util.function.Predicate +import java.util.stream.Collector +import java.util.stream.Collectors class PainterRecipe( val input: Ingredient, val output: ItemStack, - val dyes: Map + dyes: Map ) : Recipe { constructor( input: Ingredient, output: ItemStack, - dyes: Set - ) : this(input, output, dyes.associateWith { 1 }) + dyes: Set + ) : this(input, output, Object2IntArrayMap().also { map -> dyes.forEach { map[it] = 1 } }) - fun canCraft(storedDyes: Map): Boolean { + val dyes: Object2IntMap = Object2IntMaps.unmodifiable(Object2IntArrayMap(dyes)) + + fun canCraft(storedDyes: Map): Boolean { if (isIncomplete) return false if (dyes.isEmpty() || dyes.values.none { it > 0 }) return true - val copy = EnumMap(storedDyes) + val copy = Object2IntArrayMap(storedDyes) for ((dye, amount) in dyes) { for (i in 0 until amount) { - PainterBlockEntity.mixer(dye).mix(copy) - if (copy[dye]!! <= 0) return false - copy[dye] = copy[dye]!! - 1 + if (dye != null) PainterBlockEntity.mixer(dye)?.mix(copy) + if (copy.getInt(dye) <= 0) return false + copy[dye] = copy.getInt(dye) - 1 } } @@ -109,17 +118,43 @@ class PainterRecipe( return SERIALIZER.toFinished(this, id) } + private enum class DyeColorWrapper(val refName: String, val key: DyeColor?) : StringRepresentable { + WHITE("white", DyeColor.WHITE), + ORANGE("orange", DyeColor.ORANGE), + MAGENTA("magenta", DyeColor.MAGENTA), + LIGHT_BLUE("light_blue", DyeColor.LIGHT_BLUE), + YELLOW("yellow", DyeColor.YELLOW), + LIME("lime", DyeColor.LIME), + PINK("pink", DyeColor.PINK), + GRAY("gray", DyeColor.GRAY), + LIGHT_GRAY("light_gray", DyeColor.LIGHT_GRAY), + CYAN("cyan", DyeColor.CYAN), + PURPLE("purple", DyeColor.PURPLE), + BLUE("blue", DyeColor.BLUE), + BROWN("brown", DyeColor.BROWN), + GREEN("green", DyeColor.GREEN), + RED("red", DyeColor.RED), + BLACK("black", DyeColor.BLACK), + WATER("water", null); + + override fun getSerializedName(): String { + return refName + } + } + companion object { + private val wrapperCodec = StringRepresentable.fromEnum(DyeColorWrapper::values) + val SERIALIZER = Codec2RecipeSerializer { context -> RecordCodecBuilder.create { it.group( context.ingredients.fieldOf("input").forGetter(PainterRecipe::input), ItemStack.CODEC.fieldOf("output").forGetter(PainterRecipe::output), - PredicatedCodecList>( - DyeColor.CODEC.xmap({ mapOf(it to 1) }, { it.keys.first() }) to Predicate { it.keys.size == 1 && it.values.first() == 1 }, - Codec.list(DyeColor.CODEC).xmap({ it.associateWith { 1 } }, { ArrayList(it.keys) }) to Predicate { it.values.all { it == 1 } }, - Codec.unboundedMap(DyeColor.CODEC, Codec.INT.minRange(1)) to Predicate { true } - ).fieldOf("dyes").forGetter(PainterRecipe::dyes), + PredicatedCodecList>( + 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 } } }).forGetter(PainterRecipe::dyes), ).apply(it, ::PainterRecipe) } } From 0e83e08ec638107f605fde4d6cebd5fadfef99a6 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Thu, 26 Oct 2023 17:01:36 +0300 Subject: [PATCH 1079/1199] manual hammer priming --- .../mc/otm/item/tool/ExplosiveHammerItem.kt | 69 ++++++++++++++----- .../dbotthepony/mc/otm/registry/MRegistry.kt | 12 +++- .../models/item/explosive_hammer.json | 1 + .../item/explosive_hammer_charging.json | 37 ++++++++++ 4 files changed, 98 insertions(+), 21 deletions(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_charging.json 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 1d1950099..1c7b01120 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 @@ -9,7 +9,10 @@ import net.minecraft.network.chat.Component import net.minecraft.network.protocol.game.ClientboundExplodePacket import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerPlayer +import net.minecraft.sounds.SoundEvents +import net.minecraft.sounds.SoundSource import net.minecraft.world.InteractionHand +import net.minecraft.world.InteractionResultHolder import net.minecraft.world.damagesource.DamageSource import net.minecraft.world.entity.EquipmentSlot import net.minecraft.world.entity.LivingEntity @@ -21,38 +24,24 @@ import net.minecraft.world.entity.player.Player import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag +import net.minecraft.world.item.UseAnim import net.minecraft.world.level.Explosion import net.minecraft.world.level.Level import net.minecraft.world.phys.AABB import net.minecraft.world.phys.Vec3 import net.minecraftforge.common.MinecraftForge +import net.minecraftforge.common.Tags import net.minecraftforge.event.entity.player.PlayerInteractEvent import net.minecraftforge.event.level.BlockEvent import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity -import ru.dbotthepony.mc.otm.capability.matteryEnergy -import ru.dbotthepony.mc.otm.config.ItemsConfig import ru.dbotthepony.mc.otm.config.ToolsConfig -import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.core.damageType -import ru.dbotthepony.mc.otm.core.getExplosionResistance -import ru.dbotthepony.mc.otm.core.gracefulBlockBreak -import ru.dbotthepony.mc.otm.core.immutableMap -import ru.dbotthepony.mc.otm.core.immutableMultimap -import ru.dbotthepony.mc.otm.core.isExplosion -import ru.dbotthepony.mc.otm.core.math.component1 -import ru.dbotthepony.mc.otm.core.math.component2 -import ru.dbotthepony.mc.otm.core.math.component3 -import ru.dbotthepony.mc.otm.core.math.plus -import ru.dbotthepony.mc.otm.core.math.times -import ru.dbotthepony.mc.otm.core.math.toDoubleVector +import ru.dbotthepony.mc.otm.core.* +import ru.dbotthepony.mc.otm.core.math.* import ru.dbotthepony.mc.otm.core.nbt.set -import ru.dbotthepony.mc.otm.core.position -import ru.dbotthepony.mc.otm.core.tagNotNull -import ru.dbotthepony.mc.otm.item.weapon.EnergySwordItem import ru.dbotthepony.mc.otm.registry.MDamageTypes -import ru.dbotthepony.mc.otm.registry.MRegistry import ru.dbotthepony.mc.otm.registry.MatteryDamageSource import ru.dbotthepony.mc.otm.triggers.NailedEntityTrigger +import java.util.function.Predicate class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1).fireResistant().durability(durability)) { override fun canBeHurtBy(pDamageSource: DamageSource): Boolean { @@ -72,6 +61,11 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1) itemStack.tagNotNull["primed"] = false } + fun canPrime(player: Player): Boolean { + return player.inventory.clearOrCountMatchingItems(GUNPOWDER_PREDICATE, 0, player.inventoryMenu.craftSlots) > 0 && + player.inventory.clearOrCountMatchingItems(IRON_NUGGET_PREDICATE, 0, player.inventoryMenu.craftSlots) > 0 + } + private val aabb = AABB(-0.1, -0.1, -0.1, 0.1, 0.1, 0.1) val attributes = immutableMultimap { @@ -228,7 +222,44 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1) } } + override fun getUseAnimation(stack: ItemStack): UseAnim { + return if (isPrimed(stack)) super.getUseAnimation(stack) else UseAnim.CROSSBOW + } + + override fun getUseDuration(stack: ItemStack): Int { + return if (isPrimed(stack)) super.getUseDuration(stack) else 20 + } + + override fun use(level: Level, player: Player, hand: InteractionHand): InteractionResultHolder { + val stack = player.getItemInHand(hand) + + if (stack.isEmpty || isPrimed(stack) || !canPrime(player)) + return super.use(level, player, hand) + + player.startUsingItem(hand) + return InteractionResultHolder.consume(stack) + } + + override fun finishUsingItem(stack: ItemStack, level: Level, entity: LivingEntity): ItemStack { + + if (entity is Player && canPrime(entity)) { + if (level is ServerLevel) { + entity.inventory.clearOrCountMatchingItems(GUNPOWDER_PREDICATE, 1, entity.inventoryMenu.craftSlots) + entity.inventory.clearOrCountMatchingItems(IRON_NUGGET_PREDICATE, 1, entity.inventoryMenu.craftSlots) + + prime(stack) + } + + level.playSound(entity, entity.blockPosition(), SoundEvents.CROSSBOW_LOADING_END, SoundSource.PLAYERS, 1.0F, 1.0F) + } + + return super.finishUsingItem(stack, level, entity) + } + companion object { + val GUNPOWDER_PREDICATE = Predicate { stack: ItemStack -> stack.`is`(Tags.Items.GUNPOWDER) } + val IRON_NUGGET_PREDICATE = Predicate { stack: ItemStack -> stack.`is`(Tags.Items.NUGGETS_IRON) } + fun onLeftClickBlock(event: PlayerInteractEvent.LeftClickBlock) { val item = event.itemStack.item 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 130956113..10b28e3d4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -336,8 +336,16 @@ object MRegistry { } } - ItemProperties.register(MItems.EXPLOSIVE_HAMMER, ResourceLocation(OverdriveThatMatters.MOD_ID, "is_primed")) { stack, _, _, _ -> - if (MItems.EXPLOSIVE_HAMMER.isPrimed(stack)) 1f else 0f + ItemProperties.register(MItems.EXPLOSIVE_HAMMER, ResourceLocation(OverdriveThatMatters.MOD_ID, "is_primed")) { stack, level, entity, _ -> + if (MItems.EXPLOSIVE_HAMMER.isPrimed(stack)) { + 1f + } else { + if ((entity?.useItemRemainingTicks ?: 0) <= 0) { + 0f + } else { + (stack.useDuration - (entity?.useItemRemainingTicks ?: stack.useDuration)).toFloat() / stack.useDuration + } + } } } } diff --git a/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer.json b/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer.json index 07d693f16..87f5ba7c0 100644 --- a/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer.json +++ b/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer.json @@ -17,6 +17,7 @@ } }, "overrides": [ + { "predicate": { "overdrive_that_matters:is_primed": 0.01 }, "model": "overdrive_that_matters:item/explosive_hammer_charging" }, { "predicate": { "overdrive_that_matters:is_primed": 1.0 }, "model": "overdrive_that_matters:item/explosive_hammer_primed" } ] } \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_charging.json b/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_charging.json new file mode 100644 index 000000000..f1ab82056 --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/item/explosive_hammer_charging.json @@ -0,0 +1,37 @@ +{ + "loader": "forge:separate_transforms", + "gui_light": "front", + "base": + { + "parent": "overdrive_that_matters:item/explosive_hammer_unprimed", + "display": { + "thirdperson_righthand": { + "rotation": [0, 45, 0], + "translation": [0, -10, 5] + }, + "thirdperson_lefthand": { + "rotation": [0, 45, 0], + "translation": [0, -10, 5] + }, + "firstperson_righthand": { + "rotation": [-65, 0, 75], + "translation": [5, -7.5, -10] + }, + "firstperson_lefthand": { + "rotation": [-65, 0, 75], + "translation": [5, -7.5, -10] + } + } + }, + "perspectives": { + "gui": { + "parent": "overdrive_that_matters:item/explosive_hammer_inventory" + }, + "fixed": { + "parent": "overdrive_that_matters:item/explosive_hammer_inventory" + }, + "ground": { + "parent": "overdrive_that_matters:item/explosive_hammer_inventory" + } + } +} \ No newline at end of file From 87d9df1ce1d1af1a3ed45d960ea7dc65f5a61683 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Thu, 26 Oct 2023 22:21:11 +0300 Subject: [PATCH 1080/1199] equipment slots emit eqiup sound --- .../kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index ca497bbfe..37d98e6fe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -25,7 +25,6 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.enchantment.EnchantmentHelper.hasBindingCurse import net.minecraft.world.level.block.entity.BlockEntity import net.minecraftforge.event.network.CustomPayloadEvent -import net.minecraftforge.network.PacketDistributor import ru.dbotthepony.mc.otm.capability.IMatteryUpgrade import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.UpgradeType @@ -298,6 +297,11 @@ abstract class MatteryMenu( open inner class EquipmentSlot(container: Container, index: Int, val type: net.minecraft.world.entity.EquipmentSlot) : InventorySlot(container, index) { constructor(type: net.minecraft.world.entity.EquipmentSlot) : this(inventory, 34 + type.ordinal, type) + override fun setByPlayer(newItem: ItemStack, oldItem: ItemStack) { + inventory.player.onEquipItem(type, oldItem, newItem) + super.setByPlayer(newItem, oldItem) + } + override fun mayPlace(itemStack: ItemStack): Boolean { return super.mayPlace(itemStack) && itemStack.canEquip(type, inventory.player) } @@ -322,6 +326,11 @@ abstract class MatteryMenu( autoCreateInventoryFrame = autoFrame offhandSlot = object : InventorySlot(inventory, 40) { + override fun setByPlayer(newItem: ItemStack, oldItem: ItemStack) { + inventory.player.onEquipItem(net.minecraft.world.entity.EquipmentSlot.OFFHAND, oldItem, newItem) + super.setByPlayer(newItem, oldItem) + } + override fun getNoItemIcon(): Pair { return Pair.of(InventoryMenu.BLOCK_ATLAS, InventoryMenu.EMPTY_ARMOR_SLOT_SHIELD) } From c79f686e41b36560cf2f51d5d33c379939ce4992 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Fri, 27 Oct 2023 00:57:10 +0300 Subject: [PATCH 1081/1199] organize tags --- .../dbotthepony/mc/otm/datagen/tags/Tags.kt | 46 ++++++++++++------- .../mc/otm/datagen/tags/TagsProvider.kt | 28 +++++------ 2 files changed, 44 insertions(+), 30 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index 74b3e4eeb..3218e8555 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -7,6 +7,7 @@ import net.minecraft.world.effect.MobEffects import net.minecraft.world.item.Items import net.minecraft.world.item.Tiers import net.minecraft.world.level.block.Blocks +import net.minecraftforge.common.Tags import ru.dbotthepony.mc.otm.registry.MBlockTags import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MItemTags @@ -20,6 +21,7 @@ fun addTags(tagsProvider: TagsProvider) { tagsProvider.dusts.add("tritanium", MItems.TRITANIUM_DUST) tagsProvider.ingots.add("tritanium", MItems.TRITANIUM_INGOT) + tagsProvider.items.Appender(ItemTags.BEACON_PAYMENT_ITEMS).add(MItems.TRITANIUM_INGOT) tagsProvider.plates.add("tritanium", MItems.TRITANIUM_PLATE) tagsProvider.plates.add("iron", MItems.IRON_PLATE) @@ -30,6 +32,7 @@ fun addTags(tagsProvider: TagsProvider) { tagsProvider.storageBlocksAsItem.add("tritanium", MItems.TRITANIUM_INGOT_BLOCK) tagsProvider.storageBlocksAsBlock.add("tritanium", MBlocks.TRITANIUM_INGOT_BLOCK) + tagsProvider.blocks.Appender(BlockTags.BEACON_BASE_BLOCKS).add(MBlocks.TRITANIUM_INGOT_BLOCK) tagsProvider.stoneOre("tritanium", MBlocks.TRITANIUM_ORE) tagsProvider.deepslateOre("tritanium", MBlocks.DEEPSLATE_TRITANIUM_ORE) @@ -91,29 +94,30 @@ fun addTags(tagsProvider: TagsProvider) { tagsProvider.blocks.Appender(MBlockTags.MACHINES).add(MItems.MACHINES.stream().map { it!!.block }) tagsProvider.blocks.Appender(BlockTags.ANVIL).add(MBlocks.TRITANIUM_ANVIL) + tagsProvider.items.Appender(ItemTags.ANVIL).add(MItems.TRITANIUM_ANVIL) tagsProvider.items.Appender(MItemTags.TRITANIUM_NUGGETS).add(MItems.TRITANIUM_NUGGET) tagsProvider.items.Appender(MItemTags.NUGGETS).add(MItems.TRITANIUM_NUGGET) - tagsProvider.items.forge("armors") - .add("helmets", MItems.TRITANIUM_HELMET) - .add("chestplates", MItems.TRITANIUM_CHESTPLATE) - .add("leggings", MItems.TRITANIUM_PANTS) - .add("boots", MItems.TRITANIUM_BOOTS) - .add("helmets", MItems.SIMPLE_TRITANIUM_HELMET) - .add("chestplates", MItems.SIMPLE_TRITANIUM_CHESTPLATE) - .add("leggings", MItems.SIMPLE_TRITANIUM_PANTS) - .add("boots", MItems.SIMPLE_TRITANIUM_BOOTS) + tagsProvider.items.Appender(Tags.Items.ARMORS_HELMETS) + .add(MItems.TRITANIUM_HELMET, MItems.SIMPLE_TRITANIUM_HELMET) + tagsProvider.items.Appender(Tags.Items.ARMORS_CHESTPLATES) + .add(MItems.TRITANIUM_CHESTPLATE, MItems.SIMPLE_TRITANIUM_CHESTPLATE) + tagsProvider.items.Appender(Tags.Items.ARMORS_LEGGINGS) + .add(MItems.TRITANIUM_PANTS, MItems.SIMPLE_TRITANIUM_PANTS) + tagsProvider.items.Appender(Tags.Items.ARMORS_BOOTS) + .add(MItems.TRITANIUM_BOOTS, MItems.SIMPLE_TRITANIUM_BOOTS) - tagsProvider.items.minecraft("trimmable_armor").add(MItems.SIMPLE_TRITANIUM_ARMOR) + tagsProvider.items.Appender(ItemTags.TRIMMABLE_ARMOR).add(MItems.SIMPLE_TRITANIUM_ARMOR) + tagsProvider.items.Appender(ItemTags.FREEZE_IMMUNE_WEARABLES).add(MItems.TRITANIUM_ARMOR) - tagsProvider.items.minecraft("swords").add(MItems.TRITANIUM_SWORD) - tagsProvider.items.minecraft("axes").add(MItems.TRITANIUM_AXE) - tagsProvider.items.minecraft("pickaxes").add(MItems.TRITANIUM_PICKAXE) - tagsProvider.items.minecraft("shovels").add(MItems.TRITANIUM_SHOVEL) - tagsProvider.items.minecraft("hoes").add(MItems.TRITANIUM_HOE) - tagsProvider.items.forge("shears").add(MItems.TRITANIUM_SHEARS) - tagsProvider.items.forge("shields").add(MItems.TRITANIUM_SHIELD) + tagsProvider.items.Appender(ItemTags.SWORDS).add(MItems.TRITANIUM_SWORD).add(MItems.ENERGY_SWORD) + tagsProvider.items.Appender(ItemTags.AXES).add(MItems.TRITANIUM_AXE) + tagsProvider.items.Appender(ItemTags.PICKAXES).add(MItems.TRITANIUM_PICKAXE) + tagsProvider.items.Appender(ItemTags.SHOVELS).add(MItems.TRITANIUM_SHOVEL) + tagsProvider.items.Appender(ItemTags.SHOVELS).add(MItems.TRITANIUM_HOE) + tagsProvider.items.Appender(Tags.Items.SHEARS).add(MItems.TRITANIUM_SHEARS) + tagsProvider.items.Appender(Tags.Items.TOOLS_SHIELDS).add(MItems.TRITANIUM_SHIELD) tagsProvider.items.Appender(MItemTags.UPGRADES).add(MItems.CreativeUpgrades.LIST) @@ -134,6 +138,12 @@ fun addTags(tagsProvider: TagsProvider) { .add(MRegistry.TRITANIUM_STRIPED_WALL.flatBlocks) .add(MBlocks.TRITANIUM_STRIPED_WALL) + tagsProvider.items.Appender(ItemTags.STAIRS) + .add(MRegistry.FLOOR_TILES_STAIRS.items.values) + .add(MRegistry.TRITANIUM_STAIRS.allItems.values) + .add(MRegistry.TRITANIUM_STRIPED_STAIRS.flatItems) + .add(MItems.TRITANIUM_STRIPED_STAIRS) + tagsProvider.items.Appender(ItemTags.SLABS) .add(MRegistry.TRITANIUM_SLAB.allItems.values) .add(MRegistry.TRITANIUM_STRIPED_SLAB.flatItems) @@ -257,6 +267,8 @@ fun addTags(tagsProvider: TagsProvider) { MBlockTags.CARGO_CRATES, ) + tagsProvider.impermeable.add(MRegistry.INDUSTRIAL_GLASS.allBlocks.values) + tagsProvider.androidImmuneEffects.add( MobEffects.CONDUIT_POWER, MobEffects.HEAL, diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt index 636f88fa5..b40a2b563 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt @@ -14,6 +14,7 @@ import net.minecraft.world.item.Item import net.minecraft.world.item.Tier import net.minecraft.world.item.Tiers import net.minecraft.world.level.block.Block +import net.minecraftforge.common.Tags import net.minecraftforge.data.event.GatherDataEvent import net.minecraftforge.registries.ForgeRegistries import net.minecraftforge.registries.IForgeRegistry @@ -183,6 +184,7 @@ class TagsProvider(private val event: GatherDataEvent) { val witherImmune = blocks.Appender(BlockTags.WITHER_IMMUNE) val dragonImmune = blocks.Appender(BlockTags.DRAGON_IMMUNE) val guardedByPiglins = blocks.Appender(BlockTags.GUARDED_BY_PIGLINS) + val impermeable = blocks.Appender(BlockTags.IMPERMEABLE) fun stoneOre(key: String, block: Block): TagsProvider { ore(key, block) @@ -244,28 +246,28 @@ class TagsProvider(private val event: GatherDataEvent) { } val circuits = items.forge("circuits") - val dusts = items.forge("dusts") - val ingots = items.forge("ingots") - val itemOres = items.forge("ores") - val blockOres = blocks.forge("ores") + val dusts = items.Appender(Tags.Items.DUSTS) + val ingots = items.Appender(Tags.Items.INGOTS) + val itemOres = items.Appender(Tags.Items.ORES) + val blockOres = blocks.Appender(Tags.Blocks.ORES) val plates = items.forge("plates") - val storageBlocksAsItem = items.forge("storage_blocks") - val storageBlocksAsBlock = blocks.forge("storage_blocks") - val rawMaterials = items.forge("raw_materials") + val storageBlocksAsItem = items.Appender(Tags.Items.STORAGE_BLOCKS) + val storageBlocksAsBlock = blocks.Appender(Tags.Blocks.STORAGE_BLOCKS) + val rawMaterials = items.Appender(Tags.Items.RAW_MATERIALS) val wires = items.forge("wires") - val blockGroundOresStone = blocks.forge("ores_in_ground/stone") - val blockGroundOresDeepslate = blocks.forge("ores_in_ground/deepslate") + val blockGroundOresStone = blocks.Appender(Tags.Blocks.ORES_IN_GROUND_STONE) + val blockGroundOresDeepslate = blocks.Appender(Tags.Blocks.ORES_IN_GROUND_DEEPSLATE) // val blockGroundOresNetherrack = blocks.forge("ores_in_ground/netherrack") - val itemGroundOresStone = items.forge("ores_in_ground/stone") - val itemGroundOresDeepslate = items.forge("ores_in_ground/deepslate") + val itemGroundOresStone = items.Appender(Tags.Items.ORES_IN_GROUND_STONE) + val itemGroundOresDeepslate = items.Appender(Tags.Items.ORES_IN_GROUND_DEEPSLATE) // val itemGroundOresNetherrack = items.forge("ores_in_ground/netherrack") // val blockOreRatesSparse = blocks.forge("ore_rates/sparse") - val blockOreRatesSingular = blocks.forge("ore_rates/singular") + val blockOreRatesSingular = blocks.Appender(Tags.Blocks.ORE_RATES_SINGULAR) // val blockOreRatesDense = blocks.forge("ore_rates/dense") // val itemOreRatesSparse = items.forge("ore_rates/sparse") - val itemOreRatesSingular = items.forge("ore_rates/singular") + val itemOreRatesSingular = items.Appender(Tags.Items.ORE_RATES_SINGULAR) // val itemOreRatesDense = items.forge("ore_rates/dense") val gameEvents = Delegate(Registries.GAME_EVENT) From 44bf3cca437116b55ef0d57b776be87cdd09ca93 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Fri, 27 Oct 2023 00:57:58 +0300 Subject: [PATCH 1082/1199] remove freeze protection mixin in favor of minecraft tag --- .../mc/otm/mixin/MixinLivingEntity.java | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java index 0ea0fe3f3..3cb4441d6 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinLivingEntity.java @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.mixin; -import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraftforge.event.ForgeEventFactory; @@ -9,7 +8,6 @@ import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import ru.dbotthepony.mc.otm.capability.MatteryCapability; import ru.dbotthepony.mc.otm.config.ServerConfig; import ru.dbotthepony.mc.otm.core.util.ExperienceUtilsKt; @@ -18,24 +16,6 @@ import ru.dbotthepony.mc.otm.registry.MItems; @SuppressWarnings("ConstantConditions") @Mixin(LivingEntity.class) public class MixinLivingEntity { - @Inject( - method = "canFreeze()Z", - at = @At("HEAD"), - cancellable = true) - public void canFreeze(CallbackInfoReturnable hook) { - if (((Object) this) instanceof LivingEntity entity) { - boolean flag = - entity.getItemBySlot(EquipmentSlot.HEAD).is(MItems.INSTANCE.getTRITANIUM_HELMET()) && - entity.getItemBySlot(EquipmentSlot.CHEST).is(MItems.INSTANCE.getTRITANIUM_CHESTPLATE()) && - entity.getItemBySlot(EquipmentSlot.LEGS).is(MItems.INSTANCE.getTRITANIUM_PANTS()) && - entity.getItemBySlot(EquipmentSlot.FEET).is(MItems.INSTANCE.getTRITANIUM_BOOTS()) - ; - - if (flag) - hook.setReturnValue(false); - } - } - @Shadow protected Player lastHurtByPlayer; From e6b2dec32d317253ad1386b9a8fbd8d11794f292 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Fri, 27 Oct 2023 01:11:00 +0300 Subject: [PATCH 1083/1199] do not add "-SNAPSHOT" to toml mod version --- build.gradle.kts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 11edbe217..4d2028a73 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -48,12 +48,7 @@ data class GitInfo(val version: String, val tag: String, val buildNumber: String } val modVersion: String get() { - val version = if (buildNumber != "") "$mod_version.$buildNumber" else mod_version - - if (tag != "") - return version - - return "$version-SNAPSHOT" + return if (buildNumber != "") "$mod_version.$buildNumber" else mod_version } } From bc8a52acd47d4cedaa850563650fc6d725d6f9f2 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Fri, 27 Oct 2023 01:11:37 +0300 Subject: [PATCH 1084/1199] add portable gravitation stabilizer to chestplates tag --- src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index 3218e8555..6675a714e 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -102,7 +102,7 @@ fun addTags(tagsProvider: TagsProvider) { tagsProvider.items.Appender(Tags.Items.ARMORS_HELMETS) .add(MItems.TRITANIUM_HELMET, MItems.SIMPLE_TRITANIUM_HELMET) tagsProvider.items.Appender(Tags.Items.ARMORS_CHESTPLATES) - .add(MItems.TRITANIUM_CHESTPLATE, MItems.SIMPLE_TRITANIUM_CHESTPLATE) + .add(MItems.TRITANIUM_CHESTPLATE, MItems.SIMPLE_TRITANIUM_CHESTPLATE, MItems.PORTABLE_GRAVITATION_STABILIZER) tagsProvider.items.Appender(Tags.Items.ARMORS_LEGGINGS) .add(MItems.TRITANIUM_PANTS, MItems.SIMPLE_TRITANIUM_PANTS) tagsProvider.items.Appender(Tags.Items.ARMORS_BOOTS) From 83502eb240844fd2fe3a0bc1a145f3063757e22d Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Fri, 27 Oct 2023 02:57:01 +0300 Subject: [PATCH 1085/1199] we do a little trolling --- .../otm/datagen/recipes/ShapelessRecipes.kt | 28 +++++++- .../dbotthepony/mc/otm/datagen/tags/Tags.kt | 3 + .../mc/otm/item/tool/ExplosiveHammerItem.kt | 68 ++++++++++++++++++- .../ru/dbotthepony/mc/otm/registry/Tags.kt | 2 + 4 files changed, 97 insertions(+), 4 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/ShapelessRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/ShapelessRecipes.kt index 62347854a..4926b477a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/ShapelessRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/ShapelessRecipes.kt @@ -1,19 +1,39 @@ package ru.dbotthepony.mc.otm.datagen.recipes -import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.data.recipes.RecipeCategory import net.minecraft.data.recipes.RecipeOutput import net.minecraft.data.recipes.ShapelessRecipeBuilder +import net.minecraft.tags.TagKey import net.minecraft.world.item.DyeColor +import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.item.crafting.Ingredient +import net.minecraft.world.level.ItemLike +import net.minecraftforge.common.Tags import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.datagen.modLocation import ru.dbotthepony.mc.otm.registry.MItemTags import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRegistry -import java.util.function.Consumer + +fun hammerRecipe(output: ItemLike, input: ItemLike, consumer: RecipeOutput) { + ShapelessRecipeBuilder(RecipeCategory.MISC, output, 1) + .requires(MItemTags.TOOLS_HAMMERS) + .requires(input) + .unlockedBy(MItemTags.TOOLS_HAMMERS) + .unlockedBy(input) + .save(consumer) +} + +fun hammerRecipe(output: ItemLike, input: TagKey, consumer: RecipeOutput) { + ShapelessRecipeBuilder(RecipeCategory.MISC, output, 1) + .requires(MItemTags.TOOLS_HAMMERS) + .requires(input) + .unlockedBy(MItemTags.TOOLS_HAMMERS) + .unlockedBy(input) + .save(consumer) +} fun addShapelessRecipes(consumer: RecipeOutput) { for (color in DyeColor.entries) { @@ -37,4 +57,8 @@ fun addShapelessRecipes(consumer: RecipeOutput) { .unlockedBy(Items.MINECART) .unlockedBy(MRegistry.CARGO_CRATES.item) .save(consumer) + + hammerRecipe(MItems.TRITANIUM_PLATE, MItemTags.TRITANIUM_INGOTS, consumer) + hammerRecipe(MItems.IRON_PLATE, Tags.Items.INGOTS_IRON, consumer) + hammerRecipe(MItems.GOLD_PLATE, Tags.Items.INGOTS_GOLD, consumer) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index 6675a714e..1c1011e0f 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -119,6 +119,9 @@ fun addTags(tagsProvider: TagsProvider) { tagsProvider.items.Appender(Tags.Items.SHEARS).add(MItems.TRITANIUM_SHEARS) tagsProvider.items.Appender(Tags.Items.TOOLS_SHIELDS).add(MItems.TRITANIUM_SHIELD) + tagsProvider.items.Appender(MItemTags.TOOLS_HAMMERS).add(MItems.EXPLOSIVE_HAMMER) + tagsProvider.items.forge("tools").add(MItemTags.TOOLS_HAMMERS) + tagsProvider.items.Appender(MItemTags.UPGRADES).add(MItems.CreativeUpgrades.LIST) tagsProvider.blocks.Appender(BlockTags.STAIRS) 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 1c7b01120..7537b407d 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 @@ -29,6 +29,7 @@ import net.minecraft.world.level.Explosion import net.minecraft.world.level.Level import net.minecraft.world.phys.AABB import net.minecraft.world.phys.Vec3 +import net.minecraftforge.common.ForgeHooks import net.minecraftforge.common.MinecraftForge import net.minecraftforge.common.Tags import net.minecraftforge.event.entity.player.PlayerInteractEvent @@ -73,6 +74,70 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1) put(Attributes.ATTACK_SPEED, AttributeModifier(BASE_ATTACK_SPEED_UUID, "Weapon modifier", -3.4, AttributeModifier.Operation.ADDITION)) } + override fun hasCraftingRemainingItem(itemStack: ItemStack): Boolean = true + + override fun getCraftingRemainingItem(itemStack: ItemStack): ItemStack { + val player = ForgeHooks.getCraftingPlayer() ?: return itemStack.copy() + if (player.level().isClientSide) return itemStack.copy() + + if (!isPrimed(itemStack)) { + itemStack.hurtAndBreak(1, player) {} + } else { + val level = player.level() as ServerLevel + + itemStack.hurtAndBreak(level.random.nextInt(1, 20), player) {} + unprime(itemStack) + + val (ex, ey, ez) = Vector.atCenterOf(player.blockPosition()) + + val exp = Explosion(player.level(), player, ex, ey, ez, 1f, false, if (ToolsConfig.ExplosiveHammer.EXPLOSION_DAMAGE_BLOCKS) Explosion.BlockInteraction.DESTROY_WITH_DECAY else Explosion.BlockInteraction.KEEP) + exp.explode() + exp.finalizeExplosion(true) + + if (!ToolsConfig.ExplosiveHammer.EXPLOSION_DAMAGE_BLOCKS) + exp.clearToBlow() + + MatteryBlockEntity.watchingPlayers(player.position(), level) + .filter { it.position.distanceTo(player.position()) <= 64.0 } + .forEach { + it.connection.send(ClientboundExplodePacket(ex, ey, ez, 1f, exp.toBlow, exp.hitPlayers[it])) + } + + if (!player.isCreative) { + val copy = itemStack.copy() + + if (!itemStack.isEmpty && player.random.nextDouble() <= ToolsConfig.ExplosiveHammer.FLY_OFF_CHANCE) { + val (x, y, z) = player.position + val entity = ItemEntity(level, x, y, z, copy) + + val (xv, yv, zv) = player.getViewVector(0f) + + entity.deltaMovement = Vec3( + player.random.nextDouble() * xv * -0.5, + player.random.nextDouble() * yv * -0.5, + (player.random.nextDouble() + 0.65) * zv * -2.0, + ) + + level.addFreshEntity(entity) + + if (player.random.nextDouble() <= ToolsConfig.ExplosiveHammer.FLY_OFF_DAMAGE_CHANCE) { + player.invulnerableTime = 0 + val dmg = ToolsConfig.ExplosiveHammer.FLY_OFF_MIN_DAMAGE + player.random.nextDouble() * (ToolsConfig.ExplosiveHammer.FLY_OFF_MAX_DAMAGE - ToolsConfig.ExplosiveHammer.FLY_OFF_MIN_DAMAGE) + player.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EXPLOSIVE_HAMMER), inflictor = copy), dmg.toFloat()) + } + + itemStack.shrink(itemStack.count) + } else if (player.random.nextDouble() <= ToolsConfig.ExplosiveHammer.SELF_HARM_CHANCE) { + player.invulnerableTime = 0 + val dmg = ToolsConfig.ExplosiveHammer.SELF_HARM_MIN_DAMAGE + player.random.nextDouble() * (ToolsConfig.ExplosiveHammer.SELF_HARM_MAX_DAMAGE - ToolsConfig.ExplosiveHammer.SELF_HARM_MIN_DAMAGE) + player.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EXPLOSIVE_HAMMER), inflictor = copy), dmg.toFloat()) + } + } + } + + return itemStack.copy() + } + override fun getAttributeModifiers( slot: EquipmentSlot, itemStack: ItemStack @@ -264,8 +329,7 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1) val item = event.itemStack.item if (item is ExplosiveHammerItem) { - val (x, y, z) = event.pos - item.attackAt(event.itemStack, event.entity, Vec3(x + 0.5, y + 0.5, z + 0.5), event.face?.opposite?.normal?.toDoubleVector() ?: event.entity.getViewVector(0f), event.hand) + item.attackAt(event.itemStack, event.entity, Vector.atCenterOf(event.pos), event.face?.opposite?.normal?.toDoubleVector() ?: event.entity.getViewVector(0f), event.hand) event.isCanceled = true } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt index ae77498d5..e138f4b19 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt @@ -37,6 +37,8 @@ object MItemTags { val PISTONS: TagKey = ItemTags.create(ResourceLocation("forge", "pistons")) + val TOOLS_HAMMERS: TagKey = ItemTags.create(ResourceLocation("forge", "tools/hammers")) + val HARDENED_GLASS_PANES: TagKey = ItemTags.create(ResourceLocation("forge", "hardened_glass_panes")) val HARDENED_GLASS_PANES_BLACK: TagKey = ItemTags.create(ResourceLocation("forge", "hardened_glass_panes/black")) val HARDENED_GLASS_PANES_BLUE: TagKey = ItemTags.create(ResourceLocation("forge", "hardened_glass_panes/blue")) From e116f0cd6e43ae9a201f3aeba5997e54965af737 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Fri, 27 Oct 2023 13:48:02 +0300 Subject: [PATCH 1086/1199] change crafting table tag to a widely used one --- .../mc/otm/datagen/recipes/CraftingTableRecipes.kt | 4 ++-- src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt | 4 ++-- src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index 509e9e9f6..2fdb8f2f2 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -323,7 +323,7 @@ fun addCraftingTableRecipes(consumer: RecipeOutput) { // апгрейд на сетку крафта MatteryRecipe(MItems.ExopackUpgrades.CRAFTING_UPGRADE, category = RecipeCategory.TOOLS) .row(MItemTags.ADVANCED_CIRCUIT, MItemTags.ADVANCED_CIRCUIT, MItemTags.ADVANCED_CIRCUIT) - .row(MItemTags.CRAFTING_TABLES, MItems.QUANTUM_TRANSCEIVER, MItemTags.CRAFTING_TABLES) + .row(MItemTags.WORKBENCHES, MItems.QUANTUM_TRANSCEIVER, MItemTags.WORKBENCHES) .row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) .build(consumer) @@ -447,7 +447,7 @@ fun addCraftingTableRecipes(consumer: RecipeOutput) { MatteryRecipe(MItems.PAINTER, category = machinesCategory) .row(Items.BRUSH, Items.BUCKET, Items.BUCKET) .row(MItemTags.IRON_PLATES, Items.BUCKET, MItemTags.IRON_PLATES) - .row(MItemTags.IRON_PLATES, MItemTags.CRAFTING_TABLES, MItemTags.IRON_PLATES) + .row(MItemTags.IRON_PLATES, MItemTags.WORKBENCHES, MItemTags.IRON_PLATES) .unlockedBy(Tags.Items.DYES) .build(consumer) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index 1c1011e0f..9adeb0a23 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -51,8 +51,8 @@ fun addTags(tagsProvider: TagsProvider) { MBlocks.STORAGE_CABLE ) - tagsProvider.items.Appender(MItemTags.CRAFTING_TABLES).add(Items.CRAFTING_TABLE) - tagsProvider.blocks.Appender(MBlockTags.CRAFTING_TABLES).add(Blocks.CRAFTING_TABLE) + tagsProvider.items.Appender(MItemTags.WORKBENCHES).add(Items.CRAFTING_TABLE) + tagsProvider.blocks.Appender(MBlockTags.WORKBENCHES).add(Blocks.CRAFTING_TABLE) tagsProvider.items.Appender(MItemTags.MINECART_CARGO_CRATES).add(MItems.CARGO_CRATE_MINECARTS.values) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt index e138f4b19..fa873f3e5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt @@ -27,7 +27,7 @@ object MItemTags { val INDUSTRIAL_GLASS: TagKey = ItemTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "industrial_glass")) val UPGRADES: TagKey = ItemTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "upgrades")) - val CRAFTING_TABLES: TagKey = ItemTags.create(ResourceLocation("forge", "crafting_tables")) + val WORKBENCHES: TagKey = ItemTags.create(ResourceLocation("forge", "workbenches")) val BASIC_CIRCUIT: TagKey = ItemTags.create(ResourceLocation("forge", "circuits/basic")) val ADVANCED_CIRCUIT: TagKey = ItemTags.create(ResourceLocation("forge", "circuits/advanced")) @@ -85,7 +85,7 @@ object MBlockTags { val CARGO_CRATES: TagKey = BlockTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "cargo_crates")) val INDUSTRIAL_GLASS: TagKey = BlockTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "industrial_glass")) - val CRAFTING_TABLES: TagKey = BlockTags.create(ResourceLocation("forge", "crafting_tables")) + val WORKBENCHES: TagKey = BlockTags.create(ResourceLocation("forge", "workbenches")) val REQUIRES_TRITANIUM_TOOL: TagKey = BlockTags.create(ResourceLocation("minecraft", "requires_tritanium_tool")) From d7794320fa5ac5f9e83d8cafc567595f2673ff57 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Fri, 27 Oct 2023 16:39:34 +0300 Subject: [PATCH 1087/1199] jade update --- gradle.properties | 4 ++-- .../jade/providers/MatterBottlerProvider.kt | 12 +++++------- .../providers/MatterReconstructorProvider.kt | 9 ++++++--- .../jade/providers/MatterStorageProvider.kt | 16 +++++++--------- .../jade/providers/MatteryEnergyProvider.kt | 17 +++++++---------- .../jade/providers/MatteryWorkerProvider.kt | 5 +++-- 6 files changed, 30 insertions(+), 33 deletions(-) diff --git a/gradle.properties b/gradle.properties index a6d094fe2..dc2d2cd2d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -22,12 +22,12 @@ mixin_version=0.8.5 jei_version=16.0.0.28 jupiter_version=5.9.2 curios_version=6.0.2 -cosmetic_armor_reworked_id=4575609 +cosmetic_armor_reworked_id=4764779 ad_astra_id=4594155 botarium_id=4594094 resourceful_lib_id=4598948 resourceful_config_id=4576455 -jade_id=4614153 +jade_id=4818518 configured_id=4462894 kotlin_for_forge_version=4.4.0 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterBottlerProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterBottlerProvider.kt index e2314a0ca..c44d42c25 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterBottlerProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterBottlerProvider.kt @@ -14,6 +14,7 @@ import snownee.jade.api.IServerDataProvider import snownee.jade.api.ITooltip import snownee.jade.api.config.IPluginConfig import snownee.jade.api.ui.BoxStyle +import snownee.jade.api.ui.IElementHelper object MatterBottlerProvider : IBlockComponentProvider, IServerDataProvider { override fun getUid(): ResourceLocation = JadeUids.MATTER_BOTTLER @@ -36,7 +37,7 @@ object MatterBottlerProvider : IBlockComponentProvider, IServerDataProvider { override fun getUid(): ResourceLocation = JadeUids.MATTER_RECONSTRUCTOR @@ -45,16 +46,18 @@ object MatterReconstructorProvider : IBlockComponentProvider, IServerDataProvide val ratio = damage.toFloat() / maxDamage.toFloat() + val elementHelper = IElementHelper.get() + tooltip.add( - tooltip.elementHelper.progress( + elementHelper.progress( ratio, TranslatableComponent( "item.durability", damage, maxDamage ), - tooltip.elementHelper.progressStyle().color(RGBAColor.DARK_GREEN.toARGB()).textColor(RGBAColor.WHITE.toARGB()), - BoxStyle.DEFAULT, + elementHelper.progressStyle().color(RGBAColor.DARK_GREEN.toARGB()).textColor(RGBAColor.WHITE.toARGB()), + BoxStyle.getNestedBox(), true ) ) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterStorageProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterStorageProvider.kt index 8e2d45201..3a150f84b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterStorageProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterStorageProvider.kt @@ -22,6 +22,7 @@ import snownee.jade.api.IServerDataProvider import snownee.jade.api.ITooltip import snownee.jade.api.config.IPluginConfig import snownee.jade.api.ui.BoxStyle +import snownee.jade.api.ui.IElementHelper object MatterStorageProvider : IBlockComponentProvider, IServerDataProvider { override fun getUid(): ResourceLocation = JadeUids.MATTER_STORAGE @@ -57,21 +58,18 @@ object MatterStorageProvider : IBlockComponentProvider, IServerDataProvider { override fun getUid(): ResourceLocation = JadeUids.MATTERY_ENERGY @@ -56,21 +56,18 @@ object MatteryEnergyProvider : IBlockComponentProvider, IServerDataProvider { override fun getUid(): ResourceLocation = JadeUids.MATTERY_WORKER @@ -53,7 +54,7 @@ object MatteryWorkerProvider : IBlockComponentProvider, IServerDataProvider Date: Sat, 28 Oct 2023 06:43:25 +0300 Subject: [PATCH 1088/1199] =?UTF-8?q?=E2=9C=85=20=D0=9F=D0=BE=D0=B9=D1=82?= =?UTF-8?q?=D0=B8=20=D0=BD=D0=B0=D1=85=D1=83=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/datagen/recipes/CraftingTableRecipes.kt | 4 ++-- .../kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt | 11 +++++++++++ .../kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt | 4 ++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index 2fdb8f2f2..509e9e9f6 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -323,7 +323,7 @@ fun addCraftingTableRecipes(consumer: RecipeOutput) { // апгрейд на сетку крафта MatteryRecipe(MItems.ExopackUpgrades.CRAFTING_UPGRADE, category = RecipeCategory.TOOLS) .row(MItemTags.ADVANCED_CIRCUIT, MItemTags.ADVANCED_CIRCUIT, MItemTags.ADVANCED_CIRCUIT) - .row(MItemTags.WORKBENCHES, MItems.QUANTUM_TRANSCEIVER, MItemTags.WORKBENCHES) + .row(MItemTags.CRAFTING_TABLES, MItems.QUANTUM_TRANSCEIVER, MItemTags.CRAFTING_TABLES) .row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES) .build(consumer) @@ -447,7 +447,7 @@ fun addCraftingTableRecipes(consumer: RecipeOutput) { MatteryRecipe(MItems.PAINTER, category = machinesCategory) .row(Items.BRUSH, Items.BUCKET, Items.BUCKET) .row(MItemTags.IRON_PLATES, Items.BUCKET, MItemTags.IRON_PLATES) - .row(MItemTags.IRON_PLATES, MItemTags.WORKBENCHES, MItemTags.IRON_PLATES) + .row(MItemTags.IRON_PLATES, MItemTags.CRAFTING_TABLES, MItemTags.IRON_PLATES) .unlockedBy(Tags.Items.DYES) .build(consumer) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index 9adeb0a23..dd78fad3a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -51,8 +51,19 @@ fun addTags(tagsProvider: TagsProvider) { MBlocks.STORAGE_CABLE ) + tagsProvider.items.Appender(MItemTags.CRAFTING_TABLES).add(Items.CRAFTING_TABLE) tagsProvider.items.Appender(MItemTags.WORKBENCHES).add(Items.CRAFTING_TABLE) + tagsProvider.items.Appender(MItemTags.WORKBENCH).add(Items.CRAFTING_TABLE) + tagsProvider.blocks.Appender(MBlockTags.CRAFTING_TABLES).add(Blocks.CRAFTING_TABLE) tagsProvider.blocks.Appender(MBlockTags.WORKBENCHES).add(Blocks.CRAFTING_TABLE) + tagsProvider.blocks.Appender(MBlockTags.WORKBENCH).add(Blocks.CRAFTING_TABLE) + + tagsProvider.items.Appender(MItemTags.CRAFTING_TABLES) + .add(MItemTags.WORKBENCHES) + .add(MItemTags.WORKBENCH) + tagsProvider.blocks.Appender(MBlockTags.CRAFTING_TABLES) + .add(MBlockTags.WORKBENCHES) + .add(MBlockTags.WORKBENCH) tagsProvider.items.Appender(MItemTags.MINECART_CARGO_CRATES).add(MItems.CARGO_CRATE_MINECARTS.values) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt index fa873f3e5..86a49364c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/Tags.kt @@ -27,7 +27,9 @@ object MItemTags { val INDUSTRIAL_GLASS: TagKey = ItemTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "industrial_glass")) val UPGRADES: TagKey = ItemTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "upgrades")) + val CRAFTING_TABLES: TagKey = ItemTags.create(ResourceLocation("forge", "crafting_tables")) val WORKBENCHES: TagKey = ItemTags.create(ResourceLocation("forge", "workbenches")) + val WORKBENCH: TagKey = ItemTags.create(ResourceLocation("forge", "workbench")) val BASIC_CIRCUIT: TagKey = ItemTags.create(ResourceLocation("forge", "circuits/basic")) val ADVANCED_CIRCUIT: TagKey = ItemTags.create(ResourceLocation("forge", "circuits/advanced")) @@ -85,7 +87,9 @@ object MBlockTags { val CARGO_CRATES: TagKey = BlockTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "cargo_crates")) val INDUSTRIAL_GLASS: TagKey = BlockTags.create(ResourceLocation(OverdriveThatMatters.MOD_ID, "industrial_glass")) + val CRAFTING_TABLES: TagKey = BlockTags.create(ResourceLocation("forge", "crafting_tables")) val WORKBENCHES: TagKey = BlockTags.create(ResourceLocation("forge", "workbenches")) + val WORKBENCH: TagKey = BlockTags.create(ResourceLocation("forge", "workbench")) val REQUIRES_TRITANIUM_TOOL: TagKey = BlockTags.create(ResourceLocation("minecraft", "requires_tritanium_tool")) From 814328630cc74ea03858d8ee6819185f17cc197f Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sun, 29 Oct 2023 00:42:48 +0300 Subject: [PATCH 1089/1199] fix upgrades not saving in matter decomposer and scanner; added upgrades to bottler and recycler --- .../entity/matter/MatterBottlerBlockEntity.kt | 10 +++++++--- .../entity/matter/MatterDecomposerBlockEntity.kt | 1 + .../entity/matter/MatterRecyclerBlockEntity.kt | 14 +++++++++----- .../entity/matter/MatterScannerBlockEntity.kt | 1 + 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index 5b29c2dca..f01765e4a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -15,6 +15,7 @@ import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.ProxiedItemHandler +import ru.dbotthepony.mc.otm.capability.UpgradeType import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl @@ -22,6 +23,7 @@ import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage 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.container.UpgradeContainer import ru.dbotthepony.mc.otm.menu.matter.MatterBottlerMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.core.* @@ -31,7 +33,8 @@ import ru.dbotthepony.mc.otm.graph.matter.SimpleMatterNode class MatterBottlerBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryPoweredBlockEntity(MBlockEntities.MATTER_BOTTLER, blockPos, blockState) { - override val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::markDirtyFast, MachinesConfig.MatterBottler.VALUES)) + val upgrades = UpgradeContainer(::markDirtyFast, 3, UpgradeType.BASIC_MATTER) + override val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::markDirtyFast, upgrades.transform(MachinesConfig.MatterBottler.VALUES))) val energyConfig = ConfigurableEnergy(energy) private inner class Container : MatteryContainer(3) { @@ -97,7 +100,7 @@ class MatterBottlerBlockEntity(blockPos: BlockPos, blockState: BlockState) : battery = batteryItemHandler ) - val matter: ProfiledMatterStorage = ProfiledMatterStorage(object : MatterStorageImpl(this::markDirtyFast, FlowDirection.BI_DIRECTIONAL, MachinesConfig.MatterBottler.VALUES::matterCapacity) { + val matter: ProfiledMatterStorage = ProfiledMatterStorage(object : MatterStorageImpl(this::markDirtyFast, FlowDirection.BI_DIRECTIONAL, upgrades.matterCapacity(MachinesConfig.MatterBottler.VALUES::matterCapacity)) { override val matterFlow: FlowDirection get() { return if (this@MatterBottlerBlockEntity.isBottling) FlowDirection.INPUT else FlowDirection.OUTPUT } @@ -115,6 +118,7 @@ class MatterBottlerBlockEntity(blockPos: BlockPos, blockState: BlockState) : savetable(::matter, MATTER_STORAGE_KEY) savetable(::bottling) savetable(::unbottling) + savetable(::upgrades) } var workProgress: Float = 0f @@ -193,7 +197,7 @@ class MatterBottlerBlockEntity(blockPos: BlockPos, blockState: BlockState) : } else { any = true initialCapacity = initialCapacity ?: it.storedMatter - val rate = MachinesConfig.MatterBottler.RATE + val rate = MachinesConfig.MatterBottler.RATE * (1.0 + upgrades.speedBonus) if (matter.storedMatter < rate) { matter.receiveMatter(matterNode.graph.extractMatter(matter.missingMatter diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt index 4e93fe6be..d454e94b3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterDecomposerBlockEntity.kt @@ -60,6 +60,7 @@ class MatterDecomposerBlockEntity(pos: BlockPos, state: BlockState) init { savetables.stateful(::energy, ENERGY_KEY) + savetables.stateful(::upgrades) } val matter = ProfiledMatterStorage(MatterStorageImpl(::markDirtyFast, FlowDirection.OUTPUT, upgrades.matterCapacity(MachinesConfig.MATTER_DECOMPOSER::matterCapacity))) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt index 7bf692a9d..1602236fb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterRecyclerBlockEntity.kt @@ -15,6 +15,7 @@ import ru.dbotthepony.mc.otm.block.entity.Job import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.UpgradeType import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage import ru.dbotthepony.mc.otm.capability.matter.MatterStorageImpl @@ -22,6 +23,7 @@ import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage 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.container.UpgradeContainer import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.graph.matter.MatterGraph import ru.dbotthepony.mc.otm.item.matter.MatterDustItem @@ -44,11 +46,12 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) } } - val matter = ProfiledMatterStorage(MatterStorageImpl(::matterLevelUpdated, FlowDirection.OUTPUT, MachinesConfig.MatterRecycler.VALUES::matterCapacity)) + override val upgrades = UpgradeContainer(this::markDirtyFast, 3, UpgradeType.BASIC_MATTER) + val matter = ProfiledMatterStorage(MatterStorageImpl(::matterLevelUpdated, FlowDirection.OUTPUT, upgrades.matterCapacity(MachinesConfig.MatterRecycler.VALUES::matterCapacity))) val container = MatteryContainer(::itemContainerUpdated, 1).also(::addDroppableContainer) val matterNode = SimpleMatterNode(matter = matter) - override val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::energyLevelUpdated, MachinesConfig.MatterRecycler.VALUES)) + override val energy = ProfiledEnergyStorage(WorkerEnergyStorage(::energyLevelUpdated, upgrades.transform(MachinesConfig.MatterRecycler.VALUES))) val itemConfig = ConfigurableItemHandler(input = container.handler(object : HandlerFilter { override fun canInsert(slot: Int, stack: ItemStack): Boolean { @@ -69,6 +72,7 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) savetables.stateful(::energy, ENERGY_KEY) savetables.stateful(::container, INVENTORY_KEY) savetables.stateful(::matter, MATTER_STORAGE_KEY) + savetables.stateful(::upgrades) } override fun setRemoved() { @@ -117,8 +121,8 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) return JobContainer.success( RecyclerJob( - (actualMatter / MachinesConfig.MatterRecycler.MATTER_PER_TICK).toDouble(), - MachinesConfig.MatterRecycler.VALUES.energyConsumption, + (actualMatter / (MachinesConfig.MatterRecycler.MATTER_PER_TICK * (1.0 + upgrades.speedBonus))).toDouble(), + MachinesConfig.MatterRecycler.VALUES.energyConsumption * (1.0 + upgrades.speedBonus), actualMatter ) ) @@ -126,7 +130,7 @@ class MatterRecyclerBlockEntity(blockPos: BlockPos, blockState: BlockState) override fun onJobTick(status: JobStatus, id: Int) { val job = status.job - val toReceive = job.totalMatter.coerceAtMost(MachinesConfig.MatterRecycler.MATTER_PER_TICK * status.ticksAdvanced) + val toReceive = job.totalMatter.coerceAtMost(MachinesConfig.MatterRecycler.MATTER_PER_TICK * status.ticksAdvanced * (1.0 + upgrades.speedBonus)) if (toReceive.isZero) return status.success() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt index bd758bf51..dc22e5692 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterScannerBlockEntity.kt @@ -66,6 +66,7 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : savetables.stateful(::container, INVENTORY_KEY) savetables.stateful(::energy, ENERGY_KEY) + savetables.stateful(::upgrades) } override fun invalidateCaps() { From f3da82beaf40c2d62ddef8004cfbee0fbb3907f5 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sun, 29 Oct 2023 01:25:54 +0300 Subject: [PATCH 1090/1199] furnaces and plate presses now store experience into essence storage on job finish and neighbour block update --- .../entity/tech/PlatePressBlockEntity.kt | 23 +++++++++++++++++++ .../entity/tech/PoweredFurnaceBlockEntity.kt | 23 +++++++++++++++++++ .../mc/otm/block/tech/PlatePressBlock.kt | 21 +++++++++++++++++ .../mc/otm/block/tech/PoweredFurnaceBlock.kt | 21 +++++++++++++++++ 4 files changed, 88 insertions(+) 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 27823bfcf..a570ee003 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 @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.block.entity.tech import it.unimi.dsi.fastutil.ints.IntArrayList import net.minecraft.core.BlockPos +import net.minecraft.core.Direction import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.ExperienceOrb @@ -50,6 +51,27 @@ class PlatePressBlockEntity( } } + fun tryStoreExperience(essenceStorage: EssenceStorageBlockEntity?) { + if (experience <= 0.0) return + + if (essenceStorage != null) { + essenceStorage.experienceStored += experience.toLong() + experience = 0.0 + + return + } + + for (dir in Direction.entries) { + val tile = level?.getBlockEntity(blockPos.relative(dir)) ?: continue + + if (tile is EssenceStorageBlockEntity) { + tryStoreExperience(tile) + + break + } + } + } + val energyConfig = ConfigurableEnergy(energy) val itemConfig = ConfigurableItemHandler( input = inputContainer.handler(HandlerFilter.OnlyIn), @@ -79,6 +101,7 @@ class PlatePressBlockEntity( return status.noItem() experience = (experience + status.experience).coerceAtMost(100.0) + tryStoreExperience(null) } override fun computeNextJob(id: Int): JobContainer { 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 b853d37be..c5c59bc98 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 @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.block.entity.tech import net.minecraft.core.BlockPos +import net.minecraft.core.Direction import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.ExperienceOrb @@ -66,6 +67,27 @@ class PoweredFurnaceBlockEntity( } } + fun tryStoreExperience(essenceStorage: EssenceStorageBlockEntity?) { + if (experience <= 0.0) return + + if (essenceStorage != null) { + essenceStorage.experienceStored += experience.toLong() + experience = 0.0 + + return + } + + for (dir in Direction.entries) { + val tile = level?.getBlockEntity(blockPos.relative(dir)) ?: continue + + if (tile is EssenceStorageBlockEntity) { + tryStoreExperience(tile) + + break + } + } + } + init { savetables.stateful(::upgrades) savetables.stateful(::energy) @@ -98,6 +120,7 @@ class PoweredFurnaceBlockEntity( override fun onJobFinish(status: JobStatus, id: Int) { if (outputs[id].fullyAddItem(status.job.itemStack)) { experience += status.experience + tryStoreExperience(null) } else { status.noItem() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt index 22c3aeca4..83428bc32 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt @@ -19,6 +19,7 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.block.entity.tech.EssenceStorageBlockEntity import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.shapes.BlockShapes @@ -65,4 +66,24 @@ class PlatePressBlock(properties: Properties = DEFAULT_PROPERTIES, val isTwin: B ): VoxelShape { return shapes[state]!! } + + @Suppress("OVERRIDE_DEPRECATION") + override fun neighborChanged( + state: BlockState, + level: Level, + pos: BlockPos, + neighbour: Block, + neighbourPos: BlockPos, + movedByPiston: Boolean + ) { + super.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston) + + val tile = level.getBlockEntity(pos) ?: return + val neighbourTile = level.getBlockEntity(neighbourPos) ?: return + + if (tile.isRemoved || neighbourTile.isRemoved) return + if (tile is PlatePressBlockEntity && neighbourTile is EssenceStorageBlockEntity) { + tile.tryStoreExperience(neighbourTile) + } + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt index 747014792..c20ef5be8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt @@ -17,6 +17,7 @@ import net.minecraft.world.phys.shapes.Shapes import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.WorkerState +import ru.dbotthepony.mc.otm.block.entity.tech.EssenceStorageBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.PoweredFurnaceBlockEntity import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.config.WorkerBalanceValues @@ -58,4 +59,24 @@ class PoweredFurnaceBlock( return BlockEntityTicker { _, _, _, tile -> if (tile is PoweredFurnaceBlockEntity) tile.tick() } } + + @Suppress("OVERRIDE_DEPRECATION") + override fun neighborChanged( + state: BlockState, + level: Level, + pos: BlockPos, + neighbour: Block, + neighbourPos: BlockPos, + movedByPiston: Boolean + ) { + super.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston) + + val tile = level.getBlockEntity(pos) ?: return + val neighbourTile = level.getBlockEntity(neighbourPos) ?: return + + if (tile.isRemoved || neighbourTile.isRemoved) return + if (tile is PoweredFurnaceBlockEntity && neighbourTile is EssenceStorageBlockEntity) { + tile.tryStoreExperience(neighbourTile) + } + } } From c4a5653330ba3ccac32edce83095f0667697418b Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sun, 29 Oct 2023 01:51:31 +0300 Subject: [PATCH 1091/1199] =?UTF-8?q?actually=20add=20upgrade=20slots=20?= =?UTF-8?q?=F0=9F=92=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/client/screen/matter/MatterBottlerScreen.kt | 2 +- .../mc/otm/client/screen/matter/MatterRecyclerScreen.kt | 2 +- .../ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt | 1 + .../ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt index f18d7725c..3813f8290 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterBottlerScreen.kt @@ -43,7 +43,7 @@ class MatterBottlerScreen(menu: MatterBottlerMenu, inventory: Inventory, title: ButtonPanel(this, frame, 46f, 69f, 100f, 20f, TranslatableComponent("otm.matter_bottler.switch_mode"), onPress = menu.workFlow::switchValue) } - makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, upgrades = menu.upgrades) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt index a48875e3a..89a7d6c71 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterRecyclerScreen.kt @@ -26,7 +26,7 @@ class MatterRecyclerScreen(menu: MatterRecyclerMenu, inventory: Inventory, title ProgressGaugePanel(this, frame, menu.progress, 63f, PROGRESS_ARROW_TOP).flop = true SlotPanel(this, frame, menu.input, 93f, PROGRESS_SLOT_TOP) - makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig) + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, itemConfig = menu.itemConfig, energyConfig = menu.energyConfig, upgrades = menu.upgrades) return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt index 636b17f03..0e0ad51f7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterBottlerMenu.kt @@ -45,6 +45,7 @@ class MatterBottlerMenu @JvmOverloads constructor( } val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) + val upgrades = makeUpgradeSlots(3, tile?.upgrades) init { if (tile != null) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt index 0441c860d..c374abe83 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterRecyclerMenu.kt @@ -30,6 +30,7 @@ class MatterRecyclerMenu @JvmOverloads constructor( val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig) val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig) val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget) + val upgrades = makeUpgradeSlots(3, tile?.upgrades) init { addStorageSlot(input) From 55363f5f6ab5ae955c0fb071bb17e99050530bb0 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sun, 29 Oct 2023 18:41:20 +0300 Subject: [PATCH 1092/1199] secondary recipes for powered furnaces + microwaving pattern drives to erase them --- .../ru/dbotthepony/mc/otm/datagen/DataGen.kt | 2 + .../mc/otm/datagen/recipes/BlastingRecipes.kt | 40 ------ .../mc/otm/datagen/recipes/CookingRecipes.kt | 57 +++++++++ .../datagen/recipes/MatteryRecipeProvider.kt | 7 ++ .../mc/otm/datagen/recipes/OreRecipes.kt | 22 ---- .../entity/tech/PoweredFurnaceBlockEntity.kt | 28 +++++ .../mc/otm/block/tech/PoweredFurnaceBlock.kt | 4 +- .../screen/tech/PoweredFurnaceScreen.kt | 6 +- .../mc/otm/compat/jei/JEIPlugin.kt | 5 + .../otm/compat/jei/MicrowaveRecipeCategory.kt | 115 ++++++++++++++++++ .../mc/otm/recipe/MatteryCookingRecipe.kt | 100 +++++++++++++++ .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 6 +- .../dbotthepony/mc/otm/registry/MRecipes.kt | 10 +- 13 files changed, 326 insertions(+), 76 deletions(-) delete mode 100644 src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt create mode 100644 src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CookingRecipes.kt delete mode 100644 src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/OreRecipes.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatteryCookingRecipe.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt index 7ad4a8c11..f8715acf2 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -49,6 +49,7 @@ import ru.dbotthepony.mc.otm.datagen.recipes.addBlastingRecipes import ru.dbotthepony.mc.otm.datagen.recipes.addCraftingTableRecipes import ru.dbotthepony.mc.otm.datagen.recipes.addDecorativesRecipes import ru.dbotthepony.mc.otm.datagen.recipes.addMatterEntanglerRecipes +import ru.dbotthepony.mc.otm.datagen.recipes.addMicrowaveRecipes import ru.dbotthepony.mc.otm.datagen.recipes.addPlatePressRecipes import ru.dbotthepony.mc.otm.datagen.recipes.addShapelessRecipes import ru.dbotthepony.mc.otm.datagen.recipes.addOreSmeltingRecipes @@ -569,6 +570,7 @@ object DataGen { } addPlatePressRecipes(recipeProvider) + addMicrowaveRecipes(recipeProvider) lootModifier.lambda { addLootModifiers(it) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt deleted file mode 100644 index 09e92456c..000000000 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/BlastingRecipes.kt +++ /dev/null @@ -1,40 +0,0 @@ -package ru.dbotthepony.mc.otm.datagen.recipes - -import com.google.common.collect.Lists -import net.minecraft.data.recipes.FinishedRecipe -import net.minecraft.data.recipes.RecipeCategory -import net.minecraft.data.recipes.RecipeOutput -import net.minecraft.data.recipes.SimpleCookingRecipeBuilder -import net.minecraft.world.item.Item -import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.crafting.Ingredient -import net.minecraft.world.level.ItemLike -import ru.dbotthepony.mc.otm.datagen.modLocation -import ru.dbotthepony.mc.otm.registry.MItemTags -import ru.dbotthepony.mc.otm.registry.MItems -import java.util.* -import java.util.function.Consumer - -private fun RecipeOutput.addRecyclingRecipe(inputs: Collection, result: Item, name: String) { - val inputStacks = inputs.map(::ItemStack) - - SimpleCookingRecipeBuilder.smelting( - Ingredient.of(inputStacks.stream()), - RecipeCategory.MISC, result, 0f, 200 - ).also { r -> inputs.forEach { r.unlockedBy(it) } }.save(this, modLocation("smelting/${name}")) - - SimpleCookingRecipeBuilder.blasting( - Ingredient.of(inputStacks.stream()), - RecipeCategory.MISC, result, 0f, 100 - ).also { r -> inputs.forEach { r.unlockedBy(it) } }.save(this, modLocation("blasting/${name}")) -} - -fun addBlastingRecipes(consumer: RecipeOutput) { - SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItems.MIRROR_COMPOUND), RecipeCategory.MISC, MItems.MIRROR, 0.1f, 100).unlockedBy(MItems.MIRROR_COMPOUND).save(consumer) - - SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_PLATES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 100).unlockedBy(MItemTags.TRITANIUM_PLATES).save(consumer, modLocation("tritanium_ingot_from_plates")) - SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_PLATES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 50).unlockedBy(MItemTags.TRITANIUM_PLATES).save(consumer, modLocation("tritanium_ingot_from_plates_blasting")) - - consumer.addRecyclingRecipe(MItems.TRITANIUM_TOOLS, MItems.TRITANIUM_NUGGET, "tritanium_nugget_from_tools") - consumer.addRecyclingRecipe(MItems.SIMPLE_TRITANIUM_ARMOR, MItems.TRITANIUM_NUGGET, "tritanium_nugger_from_armor") -} diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CookingRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CookingRecipes.kt new file mode 100644 index 000000000..c9e0e69b1 --- /dev/null +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CookingRecipes.kt @@ -0,0 +1,57 @@ +package ru.dbotthepony.mc.otm.datagen.recipes + +import net.minecraft.data.recipes.RecipeCategory +import net.minecraft.data.recipes.RecipeOutput +import net.minecraft.data.recipes.SimpleCookingRecipeBuilder +import net.minecraft.util.valueproviders.ConstantFloat +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.crafting.Ingredient +import net.minecraft.world.level.ItemLike +import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.datagen.modLocation +import ru.dbotthepony.mc.otm.registry.MItemTags +import ru.dbotthepony.mc.otm.registry.MItems + +private fun RecipeOutput.addRecyclingRecipe(inputs: Collection, result: Item, name: String) { + val inputStacks = inputs.map(::ItemStack) + + SimpleCookingRecipeBuilder.smelting( + Ingredient.of(inputStacks.stream()), + RecipeCategory.MISC, result, 0f, 200 + ).also { r -> inputs.forEach { r.unlockedBy(it) } }.save(this, modLocation("smelting/${name}")) + + SimpleCookingRecipeBuilder.blasting( + Ingredient.of(inputStacks.stream()), + RecipeCategory.MISC, result, 0f, 100 + ).also { r -> inputs.forEach { r.unlockedBy(it) } }.save(this, modLocation("blasting/${name}")) +} + +fun addBlastingRecipes(consumer: RecipeOutput) { + SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItems.MIRROR_COMPOUND), RecipeCategory.MISC, MItems.MIRROR, 0.1f, 100).unlockedBy( + MItems.MIRROR_COMPOUND).save(consumer) + + SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_PLATES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 100).unlockedBy( + MItemTags.TRITANIUM_PLATES).save(consumer, modLocation("tritanium_ingot_from_plates")) + SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_PLATES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 50).unlockedBy( + MItemTags.TRITANIUM_PLATES).save(consumer, modLocation("tritanium_ingot_from_plates_blasting")) + + consumer.addRecyclingRecipe(MItems.TRITANIUM_TOOLS, MItems.TRITANIUM_NUGGET, "tritanium_nugget_from_tools") + consumer.addRecyclingRecipe(MItems.SIMPLE_TRITANIUM_ARMOR, MItems.TRITANIUM_NUGGET, "tritanium_nugger_from_armor") +} + +fun addOreSmeltingRecipes(consumer: RecipeOutput) { + SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_ORES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 200).unlockedBy(MItemTags.TRITANIUM_ORES).save(consumer, modLocation("smelting/tritanium_ingot_from_ore_block")) + SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_ORES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 100).unlockedBy(MItemTags.TRITANIUM_ORES).save(consumer, modLocation("blasting/tritanium_ingot_from_ore_block")) + + SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_ORE_CLUMPS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 200).unlockedBy(MItemTags.TRITANIUM_ORE_CLUMPS).save(consumer, modLocation("smelting/tritanium_ingot_from_raw_ore")) + SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_ORE_CLUMPS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 100).unlockedBy(MItemTags.TRITANIUM_ORE_CLUMPS).save(consumer, modLocation("blasting/tritanium_ingot_from_raw_ore")) + + SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_DUSTS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 200).unlockedBy(MItemTags.TRITANIUM_DUSTS).save(consumer, modLocation("smelting/tritanium_ingot_from_dust")) + SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_DUSTS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 100).unlockedBy(MItemTags.TRITANIUM_DUSTS).save(consumer, modLocation("blasting/tritanium_ingot_from_dust")) +} + +fun addMicrowaveRecipes(provider: MatteryRecipeProvider) { + provider.microwave("pattern_drive_normal_erase", Ingredient.of(MItems.PATTERN_DRIVE_NORMAL), Ingredient.of(MItems.PATTERN_DRIVE_NORMAL), workTicks = 30 * 20, experience = ConstantFloat.of(0f)) +} + diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt index 7110f8f93..6e36513b1 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt @@ -24,6 +24,7 @@ import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.level.ItemLike import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.datagen.modLocation +import ru.dbotthepony.mc.otm.recipe.MicrowaveRecipe import ru.dbotthepony.mc.otm.recipe.PlatePressRecipe import java.util.* import java.util.function.Consumer @@ -117,4 +118,10 @@ class MatteryRecipeProvider(generatorIn: DataGenerator) : RecipeProvider(generat callback.accept(PlatePressRecipe(ingredient, result, count, workTicks, experience = experience).toFinished(modLocation("plate_$id"))) } } + + fun microwave(id: String, ingredient: Ingredient, result: Ingredient, count: Int = 1, workTicks: Int = 200, experience: FloatProvider = ConstantFloat.ZERO) { + exec { it, callback -> + callback.accept(MicrowaveRecipe(ingredient, result, count, workTicks, experience = experience).toFinished(modLocation("microwave/$id"))) + } + } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/OreRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/OreRecipes.kt deleted file mode 100644 index b2afd6a0f..000000000 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/OreRecipes.kt +++ /dev/null @@ -1,22 +0,0 @@ -package ru.dbotthepony.mc.otm.datagen.recipes - -import net.minecraft.data.recipes.FinishedRecipe -import net.minecraft.data.recipes.RecipeCategory -import net.minecraft.data.recipes.RecipeOutput -import net.minecraft.data.recipes.SimpleCookingRecipeBuilder -import net.minecraft.world.item.crafting.Ingredient -import ru.dbotthepony.mc.otm.datagen.modLocation -import ru.dbotthepony.mc.otm.registry.MItemTags -import ru.dbotthepony.mc.otm.registry.MItems -import java.util.function.Consumer - -fun addOreSmeltingRecipes(consumer: RecipeOutput) { - SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_ORES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 200).unlockedBy(MItemTags.TRITANIUM_ORES).save(consumer, modLocation("smelting/tritanium_ingot_from_ore_block")) - SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_ORES), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 100).unlockedBy(MItemTags.TRITANIUM_ORES).save(consumer, modLocation("blasting/tritanium_ingot_from_ore_block")) - - SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_ORE_CLUMPS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 200).unlockedBy(MItemTags.TRITANIUM_ORE_CLUMPS).save(consumer, modLocation("smelting/tritanium_ingot_from_raw_ore")) - SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_ORE_CLUMPS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 1f, 100).unlockedBy(MItemTags.TRITANIUM_ORE_CLUMPS).save(consumer, modLocation("blasting/tritanium_ingot_from_raw_ore")) - - SimpleCookingRecipeBuilder.smelting(Ingredient.of(MItemTags.TRITANIUM_DUSTS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 200).unlockedBy(MItemTags.TRITANIUM_DUSTS).save(consumer, modLocation("smelting/tritanium_ingot_from_dust")) - SimpleCookingRecipeBuilder.blasting(Ingredient.of(MItemTags.TRITANIUM_DUSTS), RecipeCategory.MISC, MItems.TRITANIUM_INGOT, 0f, 100).unlockedBy(MItemTags.TRITANIUM_DUSTS).save(consumer, modLocation("blasting/tritanium_ingot_from_dust")) -} 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 c5c59bc98..c8a7c9716 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 @@ -20,14 +20,18 @@ import ru.dbotthepony.mc.otm.capability.CombinedItemHandler import ru.dbotthepony.mc.otm.capability.UpgradeType import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.config.WorkerBalanceValues import ru.dbotthepony.mc.otm.container.CombinedContainer import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer 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.immutableList import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu +import ru.dbotthepony.mc.otm.recipe.MatteryCookingRecipe import ru.dbotthepony.mc.otm.registry.MBlockEntities class PoweredFurnaceBlockEntity( @@ -35,6 +39,7 @@ class PoweredFurnaceBlockEntity( blockPos: BlockPos, blockState: BlockState, val recipeType: RecipeType, + val secondaryRecipeType: (() -> RecipeType)?, val config: WorkerBalanceValues ) : MatteryWorkerBlockEntity(type, blockPos, blockState, ItemJob.CODEC, 2) { override val upgrades = UpgradeContainer(this::markDirtyFast, 2, UpgradeType.BASIC_PROCESSING) @@ -135,6 +140,29 @@ class PoweredFurnaceBlockEntity( val level = level as? ServerLevel ?: return JobContainer.failure() + if (secondaryRecipeType != null) { + val recipe = level.recipeManager + .byType(secondaryRecipeType.invoke() as RecipeType) + .values + .iterator() + .filter { it.value.matches(inputs[id], 0) } + .maybe()?.value + + if (recipe != null) { + val toProcess = inputs[id][0].count.coerceAtMost(1 + upgrades.processingItems) + + inputs[id][0].shrink(toProcess) + inputs[id].setChanged(id) + + return JobContainer.success( + ItemJob( + recipe.getResultItem(level.registryAccess()).copyWithCount(toProcess), + recipe.workTime * MachinesConfig.PLATE_PRESS.workTimeMultiplier, + MachinesConfig.PLATE_PRESS.energyConsumption * toProcess, + experience = recipe.experience.sample(level.random) * toProcess)) + } + } + return level.recipeManager.getRecipeFor(recipeType as RecipeType, inputs[id], level).map { val output = it.value.assemble(inputs[id], level.registryAccess()) val toProcess = inputs[id][0].count.coerceAtMost(upgrades.processingItems + 1) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt index c20ef5be8..556a230ae 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt @@ -22,16 +22,18 @@ import ru.dbotthepony.mc.otm.block.entity.tech.PoweredFurnaceBlockEntity import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.config.WorkerBalanceValues import ru.dbotthepony.mc.otm.core.get +import ru.dbotthepony.mc.otm.recipe.MatteryCookingRecipe import ru.dbotthepony.mc.otm.shapes.BlockShape class PoweredFurnaceBlock( val type: () -> BlockEntityType, val recipeType: RecipeType, + val secondaryRecipeType: (() -> RecipeType)?, val config: WorkerBalanceValues, shape: BlockShape? ) : RotatableMatteryBlock(), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): PoweredFurnaceBlockEntity { - return PoweredFurnaceBlockEntity(type.invoke(), p_153215_, p_153216_, recipeType, config) + return PoweredFurnaceBlockEntity(type.invoke(), p_153215_, p_153216_, recipeType, secondaryRecipeType, config) } override fun createBlockStateDefinition(builder: StateDefinition.Builder) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PoweredFurnaceScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PoweredFurnaceScreen.kt index 35f43914b..11892fdd2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PoweredFurnaceScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/PoweredFurnaceScreen.kt @@ -10,8 +10,8 @@ import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel +import ru.dbotthepony.mc.otm.compat.jei.MicrowaveRecipeCategory import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu -import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu import ru.dbotthepony.mc.otm.registry.MMenus class PoweredFurnaceScreen(menu: PoweredFurnaceMenu, inventory: Inventory, title: Component) : @@ -44,8 +44,8 @@ class PoweredFurnaceScreen(menu: PoweredFurnaceMenu, inventory: Inventory, title } MMenus.POWERED_SMOKER -> { - a.setRecipeType { listOf(RecipeTypes.SMOKING) } - b.setRecipeType { listOf(RecipeTypes.SMOKING) } + a.setRecipeType { listOf(MicrowaveRecipeCategory.recipeType, RecipeTypes.SMOKING) } + b.setRecipeType { listOf(MicrowaveRecipeCategory.recipeType, RecipeTypes.SMOKING) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt index 93edbbafd..b4a834410 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt @@ -23,6 +23,7 @@ import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.menu.decorative.PainterMenu import ru.dbotthepony.mc.otm.menu.matter.MatterEntanglerMenu import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu +import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRecipes @@ -62,6 +63,7 @@ class JEIPlugin : IModPlugin { registration.addRecipeCatalyst(ItemStack(MItems.ExopackUpgrades.SMELTING_UPGRADE), RecipeTypes.SMELTING) registration.addRecipeCatalyst(ItemStack(MItems.POWERED_BLAST_FURNACE), RecipeTypes.BLASTING) registration.addRecipeCatalyst(ItemStack(MItems.POWERED_SMOKER), RecipeTypes.SMOKING) + registration.addRecipeCatalyst(ItemStack(MItems.POWERED_SMOKER), MicrowaveRecipeCategory.recipeType) registration.addRecipeCatalyst(ItemStack(MItems.ExopackUpgrades.CRAFTING_UPGRADE), RecipeTypes.CRAFTING) registration.addRecipeCatalyst(ItemStack(MItems.ITEM_MONITOR), RecipeTypes.CRAFTING) registration.addRecipeCatalyst(ItemStack(MItems.PLATE_PRESS), PlatePressRecipeCategory.recipeType) @@ -82,6 +84,7 @@ class JEIPlugin : IModPlugin { registration.addRecipeCategories(PlatePressRecipeCategory) registration.addRecipeCategories(PainterRecipeCategory) registration.addRecipeCategories(MatterEntanglerRecipeCategory) + registration.addRecipeCategories(MicrowaveRecipeCategory) } override fun registerRecipes(registration: IRecipeRegistration) { @@ -90,6 +93,7 @@ class JEIPlugin : IModPlugin { registration.addRecipes(PlatePressRecipeCategory.recipeType, level.recipeManager.getAllRecipesFor(MRecipes.PLATE_PRESS).filter { !it.value.isIncomplete }.map { it.value }) registration.addRecipes(PainterRecipeCategory.recipeType, level.recipeManager.getAllRecipesFor(MRecipes.PAINTER).filter { !it.value.isIncomplete }.map { it.value }) registration.addRecipes(MatterEntanglerRecipeCategory.recipeType, level.recipeManager.getAllRecipesFor(MRecipes.MATTER_ENTANGLER).filter { !it.value.isIncomplete }.map { it.value }) + registration.addRecipes(MicrowaveRecipeCategory.recipeType, level.recipeManager.getAllRecipesFor(MRecipes.MICROWAVE).filter { !it.value.isIncomplete }.map { it.value }) } override fun registerRecipeTransferHandlers(registration: IRecipeTransferRegistration) { @@ -100,6 +104,7 @@ class JEIPlugin : IModPlugin { registration.addRecipeTransferHandler(simpleTransferInfo0(PainterRecipeCategory.recipeType, PainterMenu::inputSlot)) registration.addRecipeTransferHandler(simpleTransferInfo0(PlatePressRecipeCategory.recipeType, PlatePressMenu::inputSlot)) registration.addRecipeTransferHandler(simpleTransferInfo(PlatePressRecipeCategory.recipeType, TwinPlatePressMenu::inputSlots)) + registration.addRecipeTransferHandler(simpleTransferInfo(MicrowaveRecipeCategory.recipeType, PoweredFurnaceMenu::inputSlots)) } override fun registerGuiHandlers(registration: IGuiHandlerRegistration) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt new file mode 100644 index 000000000..aa44b00ca --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt @@ -0,0 +1,115 @@ +package ru.dbotthepony.mc.otm.compat.jei + +import mezz.jei.api.gui.builder.IRecipeLayoutBuilder +import mezz.jei.api.gui.drawable.IDrawable +import mezz.jei.api.gui.ingredient.IRecipeSlotsView +import mezz.jei.api.recipe.IFocusGroup +import mezz.jei.api.recipe.RecipeIngredientRole +import mezz.jei.api.recipe.RecipeType +import mezz.jei.api.recipe.category.IRecipeCategory +import net.minecraft.client.gui.GuiGraphics +import net.minecraft.network.chat.Component +import net.minecraft.resources.ResourceLocation +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.crafting.Ingredient +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.client.render.RenderGravity +import ru.dbotthepony.mc.otm.client.render.draw +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.math.RGBAColor +import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.recipe.MicrowaveRecipe +import ru.dbotthepony.mc.otm.registry.MItems +import kotlin.math.roundToInt + +object MicrowaveRecipeCategory : IRecipeCategory, IDrawable { + const val X_INPUT = 6f + const val Y_INPUT = 11f + + const val X_OUTPUT = 56f + const val Y_OUTPUT = 11f + + const val X_ARROW = 29f + const val Y_ARROW = 12f + + private val type = RecipeType(ResourceLocation(OverdriveThatMatters.MOD_ID, "microwave"), MicrowaveRecipe::class.java) + + override fun getRecipeType(): RecipeType { + return type + } + + override fun getTitle(): Component { + return MItems.POWERED_SMOKER.description + } + + override fun draw(graphics: GuiGraphics, xOffset: Int, yOffset: Int) { + @Suppress("name_shadowing") + val xOffset = xOffset.toFloat() + + @Suppress("name_shadowing") + val yOffset = yOffset.toFloat() + + AbstractSlotPanel.SLOT_BACKGROUND.render(graphics, X_INPUT + xOffset, Y_INPUT + yOffset) + AbstractSlotPanel.SLOT_BACKGROUND.render(graphics, X_OUTPUT + xOffset, Y_OUTPUT + yOffset) + ProgressGaugePanel.GAUGE_BACKGROUND.render(graphics, X_ARROW + xOffset, Y_ARROW + yOffset) + + ProgressGaugePanel.GAUGE_FOREGROUND.renderPartial( + graphics, + X_ARROW + xOffset, + Y_ARROW + yOffset, + width = (((System.currentTimeMillis() % 4000L) / 4000f) * ProgressGaugePanel.GAUGE_FOREGROUND.width).roundToInt().toFloat()) + } + + override fun draw( + recipe: MicrowaveRecipe, + recipeSlotsView: IRecipeSlotsView, + graphics: GuiGraphics, + mouseX: Double, + mouseY: Double + ) { + graphics.draw(minecraft.font, TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), 40f, 30f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK) + + val average = recipe.experience.toString() + + if (average != "0.0") { + graphics.draw(minecraft.font, TranslatableComponent("gui.jei.category.smelting.experience", average), 40f, 1f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK) + } + } + + override fun getWidth(): Int { + return 80 + } + + override fun getHeight(): Int { + return 40 + } + + override fun getBackground(): IDrawable { + return this + } + + private val iconField by lazy { + JEIPlugin.helpers.guiHelper.createDrawableItemStack(ItemStack(MItems.POWERED_SMOKER)) + } + + override fun getIcon(): IDrawable { + return iconField + } + + override fun setRecipe(builder: IRecipeLayoutBuilder, recipe: MicrowaveRecipe, focuses: IFocusGroup) { + builder.addSlot(RecipeIngredientRole.INPUT, X_INPUT.toInt() + 1, Y_INPUT.toInt() + 1) + .addIngredients(recipe.input) + + val first = recipe.output.items.firstOrNull { it.item.registryName?.namespace == OverdriveThatMatters.MOD_ID } + + if (first == null) + builder.addSlot(RecipeIngredientRole.OUTPUT, X_OUTPUT.toInt() + 1, Y_OUTPUT.toInt() + 1) + .addIngredients(recipe.output) + else + builder.addSlot(RecipeIngredientRole.OUTPUT, X_OUTPUT.toInt() + 1, Y_OUTPUT.toInt() + 1) + .addIngredients(Ingredient.of(first)) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatteryCookingRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatteryCookingRecipe.kt new file mode 100644 index 000000000..57d4646de --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatteryCookingRecipe.kt @@ -0,0 +1,100 @@ +package ru.dbotthepony.mc.otm.recipe + +import com.mojang.serialization.Codec +import com.mojang.serialization.codecs.RecordCodecBuilder +import net.minecraft.core.NonNullList +import net.minecraft.core.RegistryAccess +import net.minecraft.data.recipes.FinishedRecipe +import net.minecraft.network.FriendlyByteBuf +import net.minecraft.resources.ResourceLocation +import net.minecraft.util.valueproviders.ConstantFloat +import net.minecraft.util.valueproviders.FloatProvider +import net.minecraft.world.Container +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.Items +import net.minecraft.world.item.crafting.* +import net.minecraft.world.level.Level +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.container.get +import ru.dbotthepony.mc.otm.core.isActuallyEmpty +import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.data.Codec2RecipeSerializer +import ru.dbotthepony.mc.otm.data.minRange +import ru.dbotthepony.mc.otm.registry.MItems +import ru.dbotthepony.mc.otm.registry.MRecipes + +abstract class MatteryCookingRecipe( + val input: Ingredient, + val output: Ingredient, + val count: Int = 1, + val workTime: Int = 200, + val experience: FloatProvider = ConstantFloat.ZERO +) : Recipe { + override fun matches(container: Container, level: Level): Boolean { + if (isIncomplete) + return false + + return input.test(container[0]) + } + + fun matches(container: Container, slot: Int): Boolean { + if (isIncomplete) + return false + + return input.test(container[slot]) + } + + private val outputStack: ItemStack by lazy { + if (isIncomplete) { + ItemStack.EMPTY + } else { + val items = output.items + val bestMatch = items.firstOrNull { it.item.registryName?.namespace == OverdriveThatMatters.MOD_ID } ?: items[0] + bestMatch.copy().also { it.count = this.count } + } + } + + override fun getIngredients(): NonNullList { + if (isIncomplete) + return super.getIngredients() + + return NonNullList.of(Ingredient.EMPTY, input) + } + + override fun isIncomplete(): Boolean = input.isActuallyEmpty || output.isActuallyEmpty + + override fun assemble(container: Container, registry: RegistryAccess): ItemStack = outputStack.copy() + + override fun canCraftInDimensions(width: Int, height: Int): Boolean = true + + override fun getResultItem(registry: RegistryAccess): ItemStack = outputStack + + abstract fun toFinished(id: ResourceLocation): FinishedRecipe +} + +class MicrowaveRecipe( + input: Ingredient, + output: Ingredient, + count: Int = 1, + workTime: Int = 200, + experience: FloatProvider = ConstantFloat.ZERO +) : MatteryCookingRecipe(input, output, count, workTime, experience) { + override fun getType(): RecipeType<*> = MRecipes.MICROWAVE + override fun getToastSymbol(): ItemStack = ItemStack(MItems.POWERED_SMOKER) + override fun getSerializer(): RecipeSerializer<*> = SERIALIZER + override fun toFinished(id: ResourceLocation): FinishedRecipe = SERIALIZER.toFinished(this, id) + + companion object { + val SERIALIZER = Codec2RecipeSerializer { context -> + RecordCodecBuilder.create { + it.group( + context.ingredients.fieldOf("input").forGetter(MicrowaveRecipe::input), + context.ingredients.fieldOf("output").forGetter(MicrowaveRecipe::output), + Codec.INT.minRange(1).optionalFieldOf("count", 1).forGetter(MicrowaveRecipe::count), + Codec.INT.minRange(0).optionalFieldOf("workTime", 200).forGetter(MicrowaveRecipe::workTime), + FloatProvider.CODEC.optionalFieldOf("experience", ConstantFloat.ZERO).forGetter(MicrowaveRecipe::experience) + ).apply(it, ::MicrowaveRecipe) + } + } + } +} 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 c4218f292..98380836b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -93,9 +93,9 @@ object MBlocks { val CHEMICAL_GENERATOR: Block by registry.register(MNames.CHEMICAL_GENERATOR) { ChemicalGeneratorBlock() } val PLATE_PRESS: Block by registry.register(MNames.PLATE_PRESS) { PlatePressBlock() } val TWIN_PLATE_PRESS: Block by registry.register(MNames.TWIN_PLATE_PRESS) { PlatePressBlock(isTwin = true) } - val POWERED_FURNACE: PoweredFurnaceBlock by registry.register(MNames.POWERED_FURNACE) { PoweredFurnaceBlock(MBlockEntities::POWERED_FURNACE, RecipeType.SMELTING, MachinesConfig.POWERED_FURNACE, BlockShapes.POWERED_FURNACE) } - val POWERED_BLAST_FURNACE: PoweredFurnaceBlock by registry.register(MNames.POWERED_BLAST_FURNACE) { PoweredFurnaceBlock(MBlockEntities::POWERED_BLAST_FURNACE, RecipeType.BLASTING, MachinesConfig.POWERED_BLAST_FURNACE, BlockShapes.POWERED_BLAST_FURNACE) } - val POWERED_SMOKER: PoweredFurnaceBlock by registry.register(MNames.POWERED_SMOKER) { PoweredFurnaceBlock(MBlockEntities::POWERED_SMOKER, RecipeType.SMOKING, MachinesConfig.POWERED_SMOKER, null) } + val POWERED_FURNACE: PoweredFurnaceBlock by registry.register(MNames.POWERED_FURNACE) { PoweredFurnaceBlock(MBlockEntities::POWERED_FURNACE, RecipeType.SMELTING, null, MachinesConfig.POWERED_FURNACE, BlockShapes.POWERED_FURNACE) } + val POWERED_BLAST_FURNACE: PoweredFurnaceBlock by registry.register(MNames.POWERED_BLAST_FURNACE) { PoweredFurnaceBlock(MBlockEntities::POWERED_BLAST_FURNACE, RecipeType.BLASTING, null, MachinesConfig.POWERED_BLAST_FURNACE, BlockShapes.POWERED_BLAST_FURNACE) } + val POWERED_SMOKER: PoweredFurnaceBlock by registry.register(MNames.POWERED_SMOKER) { PoweredFurnaceBlock(MBlockEntities::POWERED_SMOKER, RecipeType.SMOKING, MRecipes::MICROWAVE, MachinesConfig.POWERED_SMOKER, null) } val MATTER_RECYCLER: Block by registry.register(MNames.MATTER_RECYCLER) { MatterRecyclerBlock() } val ENERGY_SERVO: Block by registry.register(MNames.ENERGY_SERVO) { EnergyServoBlock() } val COBBLESTONE_GENERATOR: Block by registry.register(MNames.COBBLESTONE_GENERATOR) { CobblerBlock() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt index a9aae3183..84c436e65 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt @@ -8,13 +8,7 @@ import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.ForgeRegistries import net.minecraftforge.registries.RegistryObject import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.recipe.EnergyContainerRecipe -import ru.dbotthepony.mc.otm.recipe.ExplosiveHammerPrimingRecipe -import ru.dbotthepony.mc.otm.recipe.IMatterEntanglerRecipe -import ru.dbotthepony.mc.otm.recipe.MatterEntanglerRecipe -import ru.dbotthepony.mc.otm.recipe.PainterRecipe -import ru.dbotthepony.mc.otm.recipe.PlatePressRecipe -import ru.dbotthepony.mc.otm.recipe.UpgradeRecipe +import ru.dbotthepony.mc.otm.recipe.* @Suppress("SameParameterValue") object MRecipes { @@ -41,6 +35,7 @@ object MRecipes { val PLATE_PRESS by register("plate_press") val PAINTER by register("painter") val MATTER_ENTANGLER by register("matter_entangler") + val MICROWAVE by register("microwave") init { serializers.register("plate_press") { PlatePressRecipe.SERIALIZER } @@ -51,5 +46,6 @@ object MRecipes { serializers.register("matter_entangler") { MatterEntanglerRecipe.SERIALIZER } serializers.register("matter_entangler_energetic") { MatterEntanglerRecipe.ENERGY_SERIALIZER } serializers.register("matter_entangler_matter") { MatterEntanglerRecipe.MATTER_SERIALIZER } + serializers.register("microwave") { MicrowaveRecipe.SERIALIZER } } } From 9d882d2351a20f5fbf3feae210062375031560fd Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Mon, 30 Oct 2023 08:30:30 +0300 Subject: [PATCH 1093/1199] draw shields cooldown --- .../dbotthepony/mc/otm/client/MatteryGUI.kt | 24 +++++++++++++++++++ .../dbotthepony/mc/otm/registry/MRegistry.kt | 10 +++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index 36533e2f4..fae1fea3f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -1,6 +1,8 @@ package ru.dbotthepony.mc.otm.client import com.mojang.blaze3d.systems.RenderSystem +import net.minecraft.client.gui.Font +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.components.Button import net.minecraft.client.gui.screens.DeathScreen import net.minecraft.client.gui.screens.InBedChatScreen @@ -10,11 +12,14 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.world.effect.MobEffects import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.player.Player +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.ShieldItem import net.minecraftforge.client.event.RenderGuiEvent import net.minecraftforge.client.event.RenderGuiOverlayEvent import net.minecraftforge.client.event.ScreenEvent import net.minecraftforge.client.gui.overlay.ForgeGui import net.minecraftforge.client.gui.overlay.GuiOverlayManager +import net.minecraftforge.common.ToolActions import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.android.feature.NanobotsArmorFeature import ru.dbotthepony.mc.otm.core.TranslatableComponent @@ -31,6 +36,7 @@ import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.registry.AndroidFeatures import java.util.* +import kotlin.math.PI import kotlin.math.ceil object MatteryGUI { @@ -346,4 +352,22 @@ object MatteryGUI { renderPlayerHealth(event, gui) } } + + fun renderShieldCooldownOverlay(graphics: GuiGraphics, font: Font, stack: ItemStack, x: Int, y: Int): Boolean { + if (!stack.isEmpty && stack.item is ShieldItem) { + if (!stack.canPerformAction(ToolActions.SHIELD_BLOCK)) return false + + val ply = minecraft.player ?: return false + if (!ply.isUsingItem || stack != ply.useItem || ply.isBlocking) return false + + val percent = ((stack.item.getUseDuration(stack) - ply.useItemRemainingTicks) / 5f).coerceIn(0f, 1f) + RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f) + drawArc(graphics, x + 8f, y + 8f, 8f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * percent, alignAtCenter = true) + RenderSystem.setShaderColor(1f, 1f, 1f, 1f) + + return true + } + + return false + } } 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 10b28e3d4..30e37ea11 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -5,12 +5,12 @@ import com.google.common.collect.Streams import net.minecraft.advancements.CriteriaTriggers import net.minecraft.client.renderer.item.ItemProperties import net.minecraft.core.BlockPos -import net.minecraft.core.Registry 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 import net.minecraft.world.entity.ai.village.poi.PoiTypes +import net.minecraft.world.item.Items import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.block.* import net.minecraft.world.level.block.state.BlockBehaviour @@ -19,6 +19,7 @@ import net.minecraft.world.level.block.state.properties.NoteBlockInstrument import net.minecraft.world.level.material.MapColor import net.minecraftforge.api.distmarker.Dist import net.minecraftforge.client.event.RegisterColorHandlersEvent +import net.minecraftforge.client.event.RegisterItemDecorationsEvent import net.minecraftforge.client.model.DynamicFluidContainerModel import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent @@ -37,6 +38,7 @@ import ru.dbotthepony.mc.otm.android.feature.NanobotsArmorFeature import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock import ru.dbotthepony.mc.otm.block.decorative.TritaniumPressurePlate import ru.dbotthepony.mc.otm.capability.matteryEnergy +import ru.dbotthepony.mc.otm.client.MatteryGUI import ru.dbotthepony.mc.otm.compat.vanilla.MatteryChestMenu import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.data.DecimalProvider @@ -256,6 +258,7 @@ object MRegistry { bus.addListener(MStats::registerVanilla) bus.addListener(this::registerEvent) bus.addListener(this::registerItemColorHandlers) + bus.addListener(this::registerItemDecorators) MCreativeTabs.initialize(bus) @@ -353,4 +356,9 @@ object MRegistry { private fun registerItemColorHandlers(event: RegisterColorHandlersEvent.Item) { event.register(DynamicFluidContainerModel.Colors(), MItems.FLUID_CAPSULE) } + + private fun registerItemDecorators(event: RegisterItemDecorationsEvent) { + event.register(Items.SHIELD, MatteryGUI::renderShieldCooldownOverlay) + event.register(MItems.TRITANIUM_SHIELD, MatteryGUI::renderShieldCooldownOverlay) + } } From 6aaad2fe88d540d811a866cd77fdf35f1934687b Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Mon, 30 Oct 2023 12:41:25 +0300 Subject: [PATCH 1094/1199] =?UTF-8?q?=D0=BF=D0=BE=D0=BA=D1=80=D0=B0=D1=81?= =?UTF-8?q?=D0=BA=D0=B0=20=D1=82=D1=80=D0=B8=D1=82=D0=B0=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=BE=D0=B9=20=D0=B1=D1=80=D0=BE=D0=BD=D0=B8=20#178=20:WiseTre?= =?UTF-8?q?e:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/datagen/items/ItemModels.kt | 2 +- .../datagen/items/MatteryItemModelProvider.kt | 8 ++++++ .../datagen/recipes/CraftingTableRecipes.kt | 20 ++++++++++++++ .../mc/otm/item/armor/TritaniumArmorItem.kt | 25 +++++++++++------- .../dbotthepony/mc/otm/registry/MRegistry.kt | 11 +++++++- .../textures/item/tritanium_boots_base.png | Bin 0 -> 246 bytes .../textures/item/tritanium_boots_overlay.png | Bin 0 -> 205 bytes .../item/tritanium_chestplate_base.png | Bin 0 -> 268 bytes .../item/tritanium_chestplate_overlay.png | Bin 0 -> 217 bytes .../textures/item/tritanium_helmet_base.png | Bin 0 -> 250 bytes .../item/tritanium_helmet_overlay.png | Bin 0 -> 217 bytes .../textures/item/tritanium_pants_base.png | Bin 0 -> 240 bytes .../textures/item/tritanium_pants_overlay.png | Bin 0 -> 201 bytes .../models/armor/tritanium_armor_base.png | Bin 0 -> 2358 bytes .../models/armor/tritanium_armor_overlay.png | Bin 0 -> 1861 bytes 15 files changed, 55 insertions(+), 11 deletions(-) create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_boots_base.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_boots_overlay.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_chestplate_base.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_chestplate_overlay.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_helmet_base.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_helmet_overlay.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_pants_base.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_pants_overlay.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/models/armor/tritanium_armor_base.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/models/armor/tritanium_armor_overlay.png diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index c85458ea1..ec6a56c07 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -86,7 +86,7 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.generated(MItems.EXOPACK_PROBE) provider.handheld(MItems.TRITANIUM_TOOLS) - provider.generated(MItems.TRITANIUM_ARMOR) + provider.armorColored(MItems.TRITANIUM_ARMOR) provider.armorWithTrims(MItems.SIMPLE_TRITANIUM_ARMOR) provider.handheld(MItems.CHEST_UPGRADER) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt index f06049371..649117b21 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt @@ -105,6 +105,14 @@ class MatteryItemModelProvider(event: GatherDataEvent) : ItemModelProvider(event fun armorWithTrims(vararg items: Item) = items.forEach { armorWithTrims(it, modLocation("item/${it.registryName!!.path}")) } fun armorWithTrims(items: Collection) = items.forEach { armorWithTrims(it, modLocation("item/${it.registryName!!.path}")) } + fun armorColored(item: Item) = exec { + withExistingParent(item.registryName!!.path, GENERATED) + .texture("layer0", modLocation("item/${item.registryName!!.path}_base")) + .texture("layer1", modLocation("item/${item.registryName!!.path}_overlay")) + } + fun armorColored(vararg items: Item) = items.forEach { armorColored(it) } + fun armorColored(items: Collection) = items.forEach { armorColored(it) } + companion object { val ARMOR_TRIM_MATERIALS = listOf("quartz", "iron", "netherite", "redstone", "copper", "gold", "emerald", "diamond", "lapis", "amethyst") val GENERATED = ResourceLocation("minecraft", "item/generated") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index 509e9e9f6..a7db8cd40 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -208,12 +208,22 @@ fun addCraftingTableRecipes(consumer: RecipeOutput) { // броня MatteryRecipe(MItems.TRITANIUM_HELMET, category = RecipeCategory.COMBAT) + .setUpgradeSource(Items.LEATHER_HELMET) + .addUpgradeOps( + UpgradeRecipe.Direct("display"), + UpgradeRecipe.Direct("Enchantments"), + ) .row(MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES) .row(MItemTags.REINFORCED_TRITANIUM_PLATES, Items.LEATHER_HELMET, MItemTags.REINFORCED_TRITANIUM_PLATES) .unlockedBy(MItemTags.REINFORCED_TRITANIUM_PLATES) .build(consumer) MatteryRecipe(MItems.TRITANIUM_PANTS, category = RecipeCategory.COMBAT) + .setUpgradeSource(Items.LEATHER_LEGGINGS) + .addUpgradeOps( + UpgradeRecipe.Direct("display"), + UpgradeRecipe.Direct("Enchantments"), + ) .row(MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES) .row(MItemTags.REINFORCED_TRITANIUM_PLATES, Items.LEATHER_LEGGINGS, MItemTags.REINFORCED_TRITANIUM_PLATES) .rowAC(MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES) @@ -221,6 +231,11 @@ fun addCraftingTableRecipes(consumer: RecipeOutput) { .build(consumer) MatteryRecipe(MItems.TRITANIUM_CHESTPLATE, category = RecipeCategory.COMBAT) + .setUpgradeSource(Items.LEATHER_CHESTPLATE) + .addUpgradeOps( + UpgradeRecipe.Direct("display"), + UpgradeRecipe.Direct("Enchantments"), + ) .row(MItemTags.REINFORCED_TRITANIUM_PLATES, Items.LEATHER_CHESTPLATE, MItemTags.REINFORCED_TRITANIUM_PLATES) .row(MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES) .row(MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES) @@ -228,6 +243,11 @@ fun addCraftingTableRecipes(consumer: RecipeOutput) { .build(consumer) MatteryRecipe(MItems.TRITANIUM_BOOTS, category = RecipeCategory.COMBAT) + .setUpgradeSource(Items.LEATHER_BOOTS) + .addUpgradeOps( + UpgradeRecipe.Direct("display"), + UpgradeRecipe.Direct("Enchantments"), + ) .row(MItemTags.REINFORCED_TRITANIUM_PLATES, Items.LEATHER_BOOTS, MItemTags.REINFORCED_TRITANIUM_PLATES) .rowAC(MItemTags.REINFORCED_TRITANIUM_PLATES, MItemTags.REINFORCED_TRITANIUM_PLATES) .unlockedBy(MItemTags.REINFORCED_TRITANIUM_PLATES) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/TritaniumArmorItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/TritaniumArmorItem.kt index a90d73674..2a1f8a588 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/TritaniumArmorItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/TritaniumArmorItem.kt @@ -3,20 +3,17 @@ package ru.dbotthepony.mc.otm.item.armor import net.minecraft.client.model.HumanoidModel import net.minecraft.sounds.SoundEvent import net.minecraft.sounds.SoundEvents -import net.minecraft.world.damagesource.DamageSource import net.minecraft.world.damagesource.DamageTypes import net.minecraft.world.entity.Entity import net.minecraft.world.entity.EquipmentSlot import net.minecraft.world.entity.LivingEntity -import net.minecraft.world.item.ArmorItem -import net.minecraft.world.item.ArmorMaterial -import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.Rarity +import net.minecraft.world.item.* import net.minecraft.world.item.crafting.Ingredient import net.minecraftforge.client.extensions.common.IClientItemExtensions import net.minecraftforge.event.entity.living.LivingAttackEvent import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.client.model.TritaniumArmorModel +import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.registry.MItemTags import ru.dbotthepony.mc.otm.registry.MItems import java.util.function.Consumer @@ -66,18 +63,28 @@ private object TritaniumArmorRenderProperties : IClientItemExtensions { } } -class TritaniumArmorItem(slot: Type) : ArmorItem(TritaniumArmorMaterial, slot, Properties().stacksTo(1).rarity(Rarity.RARE)) { +class TritaniumArmorItem(slot: Type) : DyeableArmorItem(TritaniumArmorMaterial, slot, Properties().stacksTo(1).rarity(Rarity.RARE)) { override fun initializeClient(consumer: Consumer) { super.initializeClient(consumer) consumer.accept(TritaniumArmorRenderProperties) } - override fun getArmorTexture(stack: ItemStack?, entity: Entity?, slot: EquipmentSlot?, type: String?): String { - return TEXTURE_LOCATION + override fun getArmorTexture(stack: ItemStack, entity: Entity, slot: EquipmentSlot, type: String?): String = + if (type.equals("overlay")) TEXTURE_LOCATION_OVERLAY else TEXTURE_LOCATION_BASE + + override fun getColor(stack: ItemStack): Int { + val tag = stack.getTagElement("display")?: return TRITANIUM_COLOR + if (tag.contains("color", 99)) { + return tag.getInt("color") + } + + return TRITANIUM_COLOR } companion object { - const val TEXTURE_LOCATION = "${OverdriveThatMatters.MOD_ID}:textures/models/armor/tritanium_armor.png" + val TRITANIUM_COLOR = RGBAColor(157, 187, 204).toARGB() + const val TEXTURE_LOCATION_BASE = "${OverdriveThatMatters.MOD_ID}:textures/models/armor/tritanium_armor_base.png" + const val TEXTURE_LOCATION_OVERLAY = "${OverdriveThatMatters.MOD_ID}:textures/models/armor/tritanium_armor_overlay.png" fun onHurt(event: LivingAttackEvent) { if (event.source.typeHolder().`is`(DamageTypes.SWEET_BERRY_BUSH) || event.source.msgId == "sweetBerryBush") { 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 30e37ea11..aac52447c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -5,11 +5,13 @@ import com.google.common.collect.Streams import net.minecraft.advancements.CriteriaTriggers import net.minecraft.client.renderer.item.ItemProperties import net.minecraft.core.BlockPos +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 import net.minecraft.world.entity.ai.village.poi.PoiTypes +import net.minecraft.world.item.DyeableArmorItem import net.minecraft.world.item.Items import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.block.* @@ -318,7 +320,7 @@ object MRegistry { } private fun initializeCommon(event: FMLCommonSetupEvent) { - + registerCauldronHandlers() } private fun initializeClient(event: FMLClientSetupEvent) { @@ -353,8 +355,15 @@ object MRegistry { } } + private fun registerCauldronHandlers() { + MItems.TRITANIUM_ARMOR.forEach { CauldronInteraction.WATER[it] = CauldronInteraction.DYED_ITEM } + } + private fun registerItemColorHandlers(event: RegisterColorHandlersEvent.Item) { event.register(DynamicFluidContainerModel.Colors(), MItems.FLUID_CAPSULE) + event.register({ stack, layer -> if (layer == 0) (stack.item as DyeableArmorItem).getColor(stack) else -1 }, + *MItems.TRITANIUM_ARMOR.toTypedArray() + ) } private fun registerItemDecorators(event: RegisterItemDecorationsEvent) { diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_boots_base.png b/src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_boots_base.png new file mode 100644 index 0000000000000000000000000000000000000000..e0d0581604afe758b5c91e9fb772d5e7b4ded4a1 GIT binary patch literal 246 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}H0G|-o^78U$&z{YlJ6Bs<``EE#>({S0H8m9z6H`-D11dRrI)DR6ag_x5 z1^*~g5I7kjv*Ssy=Sb24k&Q21SE+Z`l~$41GdvE*FfB{uoKoKK%ztl5dTG5T=ae%{AsYp{)Y)4% doaNkAfA}oB5zm9n_dsJAJYD@<);T3K0RR?cR!sl^ literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_boots_overlay.png b/src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_boots_overlay.png new file mode 100644 index 0000000000000000000000000000000000000000..5da3bfded50ee7eae8dbc202bce50d2d9dd7c3fe GIT binary patch literal 205 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G~10G|+7ZEbB+Q&TZ9F*P+cpxFBH2?+8JY5_^G=kT57z!~c@Eqd$^xvGj?DeC$>1~sinN;xG?!523jCYEd ppC-2hyV0Zrdk#)A*uk2~{P`F2jQ%fct$`*mc)I$ztaD0e0ssmYIlTY? literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_chestplate_base.png b/src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_chestplate_base.png new file mode 100644 index 0000000000000000000000000000000000000000..c031ca6ddc9da61bb319178d411053401cc70cb5 GIT binary patch literal 268 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}%0G|-o^78U$&z>DSc5MCn_1fCnH*emYJ9qAi6)S-9jnQVafD~s*kYDhB zC}0TouMh$W7I;J!GcfQS0Aa?gYn_}x!BkHd#}JL+(sS&52NZai5AdY_`G2(3L3UM? zvg3{hhhJ0qC!Ev@Ke#YU`iczmF}7U?Q=7Zn7=+qlCL}F9^pd5)RG5?J!?vkAt2gfd z&&dC7uKK@)Y;xh7Chc6<$Y@u{l)C8@Z}=|$O%1H63%$;R{LSF$>gTe~DWM4f3ddj4 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_chestplate_overlay.png b/src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_chestplate_overlay.png new file mode 100644 index 0000000000000000000000000000000000000000..533643b6554222d3b4a2c86ce22b24f86b6a3f75 GIT binary patch literal 217 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G|>0G|+7ZEfwFH*c<3u>vUYMnOmuq^=~$FZloe{|pXVE588woCO|{#S9F5 zhd`K7RKu$QDCp+t;uxY4JheBFk3oUMN%LL(bC=6eYy0o0)I4M8|HbB!(7&6dw;_eu zk@<&FL*!qE-464cclphGU}f1*G|g+ua*yrnLZ2`s2r|{}v+M{1n#kbk>gTe~DWM4f DpCUp3 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_helmet_base.png b/src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_helmet_base.png new file mode 100644 index 0000000000000000000000000000000000000000..bfa5490ba5cd4578b8e071f2156a150e615e4e2f GIT binary patch literal 250 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}H0G|-oz`(%r^73cTo*g@OOj}!9PEKz9`t@RBVsq!t1uAK%xH}0*ag_x5 z1^?c+ZES{-ZeqTlF(X1tm61#!i=zij+vjn5%gY3XEslwruYYT=zYB%65Z=6NF__ gC+>E7uD!$lv^=}E+}D$KK%*HvUHx3vIVCg!0AeImE&u=k literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_helmet_overlay.png b/src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_helmet_overlay.png new file mode 100644 index 0000000000000000000000000000000000000000..37f74f685b0bcbb22f7deaa690fb6ae4ecdafc71 GIT binary patch literal 217 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G~10G|-oz`#IlZEZO@IWaLYpqNC2YYUKKEeY}q{tpBUzqj#$4B{;Ch%9Dc z;5!V$jK}j=qyPn-JY5_^G=h8281gYFa5x7ZxcC2zn8C7L8SIDao7=MY2dtmNT{FL- z+8|i!hM;q!rC)+}NV~(TT literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_pants_base.png b/src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_pants_base.png new file mode 100644 index 0000000000000000000000000000000000000000..7f2b2f48221b26c3d71124d6891ca7ee1b48a1c1 GIT binary patch literal 240 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}%0G|-o^73+RZS7;njy-$!Z2kK6bLY;zdGqFq6)S-9cT2TJfD~s*kYDhB zC}0TouMh$W7I;J!GcfQS1YyP<6SLm}1wB1o978mMTTcb@9Z=w44(M8N=l>CHDPh&q z*ZSM`DFlAv+tkFnXzj{bm8Y2Wo-y$4Uts-U4ezzeM=cW#?Ckc`{b8P9PX(D>8XNLm50>{an^LB{Ts5N@!F@ literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_pants_overlay.png b/src/main/resources/assets/overdrive_that_matters/textures/item/tritanium_pants_overlay.png new file mode 100644 index 0000000000000000000000000000000000000000..b0a799933267ef4de06167aa0d38e0fbe2d747a4 GIT binary patch literal 201 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G|>0G|+7ZEfwFH*c<3u>vUYMnOmuq^=~$FZloe{|pXVE588woCO|{#S9F5 zhd`K7RKu$QC}`&C;uxY4oSfjsT)}!EM?_SCZzEIB86F-5CPjuN5))WwI57FBtW?lA mz_3NcFeto7#LVzUq62Qc&(vfqlrnKkx_%Ov8=3Ye}Dh-^77c&*s){BHa0d`EEa`A zp;D=0Vq!WvI(m9~+S=L-2183r3yntW>gvYF$FtdN91e#arLxF z^#I{Y>P53EE(<0+Xh|Vn_Z(IDR3jdm7n*-L;-g*N}&#NkBzG56{E-`4sh`Z>U# z8u%ht*Z-@qPd?8HWX}9tvdkLzB26i6&m{gOa_v!9q*Tjj2P9PsX=kTG&FZ^0E+WYl1L_NQCr{_kcLJe;sC^WZcM`{WnWYj>vg?+aD3^}9JM>^1VsEAHQdK-r8x zolH=3>2h`Q;^CYX?Ju**&e*yM_sX8RDo^)r^56g$Q5*9rFcj@yU~_$I#-R=t8pesn z?fLG&OUxsBt2AM$amPDMuU?enp101u>*j9tmDl8T1`!|T+rB@a=wC+e(eqb1b9 zz*^k7X_Ty1yWpmOyA{>BDu~I|Ecx+8q^SkEr2+BgrgT&)_Y|w73{}7jmopi&vz{&b ziFN_Ur$|><@@sM&a(e5_kQaKkR_q0CzV>MS$29l)`G)FxFDXag(4C<-eqHA@8xJFx zfr8C?LvoEvwm6&t1a{WX#x73dKiAk=bz}Hgz^yP5Jeu`xs=L`bO9xQjBrd{sII)BaVv#Rpjo~ zfl8%)z-2*^Hhsy4&4ex;gTcb;;qiB|`ki2ru2ru3iGoqD{x>xbw$M9$+wI{%hI;mM zqu8Q?SRsY)yR_RCt)++6cRJmixNJBz(wf1VMaV?eIk~n0x*q>j3Q7FfLc^&}{ZixL ze#sle)ot^W7~M6m4@Ci{eu7~u;a9ssdY>pG4$O_eeV2tn8^i5z@LcL*8%wi>@15%B ziQR6opG=AY500y0+;d}kVjMC;+t6HaZGnK=L?gs*?#xBbrv%(}bL$QHaDOf9)_HBG z8@@>c-ti1l1l<$Q$Ai!6St%&OwF2Xmoo~u#QKKK%#;FhQs?^5KpCkk9Du7rg|@_e1D zFpxUc{wS?Ous-NatGSxc`4pl*$oGjqCdq@KK;1l(IoWEj#S+%^b7qCq3pWM1+%;e1 zfvX)s&Qqu$kNf_WRcR;ZZlb2sp2{L31M6hp6uXDIHCwk&Qh)cdkhu zp(}C547FY17iH?@^Z6<*E;5{vN3db7+oHib9f?(Zof8O;rDL7E!UVp1PbzuH5|qv} zbWdsk4kQMxSE)Upl$J?MfMzqEGthmT&es|y;Js%7E?#{bgtDKq$%}0n&v^$k*&j#Y z5%20dpY_NVXEsA_7%Hii)B~QBC;!V0aXauor zN4Ofsyf^F2=3*rTBQ@^1vw`Yf`(63!5GPe=o~g($>UM2}#7KmraY~m(PY@22KVXkO zLM9-(D-1F#-1ja6Jx#nzUr=)0;l!RmiE13kG#WDkoJ>^;rxHR`7AB!s&eI1AQPS%= zX2hbo!nnV5E9g+bJqSF?u>p3EO~1T*6bt5V?O-cKONF~?fuH1lMbFZ_zfRYUzU{)) z=qmBH3lAzP#MLf4fP8#NGnIVB;14t9p5AXZ!Ra(La-O*btt`1XO4KmSkJPtsXz;Af z3oYkIe<$^}@r`zO@FLO#O3|>ACH=}ZZ$KokCxwX^hfKWpw&>PMasME5=k`~vO>6p; zEDF1|6n04Vlf>hG9EQ>OvOFU~_%|j-y3fb9K%1!K*dwGpbYf*XQ<}jSg{NT#8<|g| z$gk|ge_t6clS+LB86M&6qDG++uG8$U&k1GaC0YF;hFAZ%B=9X^i!-1jLG|iSXf%Ta zWN#iealvCSV$t{YZg>EgEA(01GjGYq2q*SuUK{flVejwf0#!TIwbO;IPEU_%4r9#P;k`va0W-03 zBbyUdIIf`e3y03sowHh?J~UkY&S&&JGI533Oz3{ByehdEo$0y|=-@Q~c(XpV$XkB& zxf#zg+0(h4yrUl2SrK0+C3ZpPy$kndi@+7Z(?Q`0yc#M3Rt@kd%}}p->763i0vr!otD@1qGs_ zqGDoVa&mGaA|mIbE_jUAFzXXnnGPEi5cNt0F%|%07cxl(U1&>Hm8G3sJ$dFaS8h+JgW92)z3x zw)gm&U;u!#!^Q%GbI0bo@x~VG2v_B0f2L%0yW^UB>%Rnf6h(V<+})y{o<58IW(l`0 zsWe=JnUz0{tvZg>7_u&-?o;7gbGW~nu#OYKOrJoTZI)qJ%Lt*=WmGtCOQwKWERqKt zJ?L?Aai$f9$zxn?n#`XqY>n6BdwJ#Q`t0^piCMEhaD}#hcYp9Pyss{s-4t-$PM*S3 z5-iA*a41f%rwILFlJ{Tqt)QYnk_RjkxQz9Y2?o`oPUl*zYOJVE(UtJG3c+I3n6klIDR$-4PKI|D!h+cgbdRVj}) z)J)eZHDkPenYpmG7bDK5WG8V9Om&08IboS6Ft&+LnFBEoh^X4>2YlK7)S{5KSC)4E zJGsW|U@I?1T@R1ybB{0o0!USpd#uLZ&^2ahL>X}<)dy}4#2bSi!K}zv9v@mQjYlzh zRwI_r4$+t((F+9N)NA+q;%y^P-0^=|08 z?gkP7n8NT>K!wM10vv2S3UtWVuRuGdKK(E?BGD{5xc#Qzx^dfZePd0UVjvzXCt0%5 zXJu{jB7!U1zX?R0q$W*s3(ihD=%Q+l(A>reACW!3U*S^nb%|r_VciTi^{+nWfH7H7 zv4dBL*a2PvB&y_ID_h}9pmbR^^Q2ApFr^ft}S<>Uk%*}mrYXde2JbbC^_t&YV&9I#u9PiJ?DY20*Q*D z**`DB;S*2qB!ORhgk-~n_hcrK6b{8!rcl|jqIT1z_QX2+!+v9_#5%uxx(3_mYMCKD zCL>7iT5v=bGVQG*q-a)hGpAX6(zp_jBc`1@Y2$8*}{5d z2@*V=ThOPoE9CL;;y~oVn0TVn4*JclWly{Aks)Y~!97tk|N0H)ldQ%DB`3$%uNC18 z{f6(UYFj-LdO7KPo{2&<$KBq5Jc58pHZfqbI;AnpN%2Opxxj#6vZR#UBm(4Wnukz= zNY%NHV;WltPz>tA6DVDQhA)Q0N<1uHMcs|-hd;J|5)n=u0z|WsI@cdqFVKVO!OArGhUv#yrbbRrHp-c@ODs zzSZGY?P{r8=1D%}wA~^9qsfe(InvrP&0g~fXk;0m*vf#zjJ>&JQ-(R||2_qJU@ynodA2cA>KdsFX|@{)Lx3qbm--T?W#_slf{gwcPi>kJ5fVN2R|f zp_{BVDZpI_XCQD;FOvNdc&eakd1kz~6FNP1^ysfAr!63FSq;yKTw9G%khOzd64D+IAaD2a5(XfAW8 Date: Mon, 30 Oct 2023 12:54:53 +0300 Subject: [PATCH 1095/1199] darken base tritanium armor color --- .../models/armor/tritanium_armor_base.png | Bin 2358 -> 2537 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/main/resources/assets/overdrive_that_matters/textures/models/armor/tritanium_armor_base.png b/src/main/resources/assets/overdrive_that_matters/textures/models/armor/tritanium_armor_base.png index 172d9e2b4eefc5f0edb18b827b7f7f4bfa483737..429e5e5a470860e82ce54cf148307640e4309ad7 100644 GIT binary patch delta 2347 zcmV+`3Dows66q6=Kvw|;P)t-sot>SGjEvjc+uGXNpP!$Li;Inojd*x?DJdx{D=T(( zc8ZFMl$4Z}m6a?kEPsE0fPjFTo15L;-Q3*VoSd8<9v&PV9DaU&fq{V?9UYpQnvsYe z1D>9qk)|Ynj*gBZA|kduJ-R_bw?00(KtLNC8+Uhid3kxx&d!O6iFI{#At51;kB^X$ zkj%`?(9qDJpr8^G5;itAI5;>pH8qHch%_`bGcz+cH#dTUg4x;GnVFe;dwVZ0FM4`< z|KLgg;Y$ABNd4YN0000GW*({l0038XQchF<|NsA!MFB*UPyr4F0KQ{2x} zNklFy!H8E}Ua91KWy@qg%yT}a>1)kNTsWcjfNc^(B*oXqC);h-pkr%_NH z8DQ4JfMvd-E6o?<_*tC9!{@bo+_p5L<2w)hMHXjC z64%4Id)$Sev_(|~%cxfttE#T+`TEX-3wwDrvQ{_`(q>Q(7eipM_aKXUL4T07vvm~( zc~lm&Dw)^uodKoQ W|Olf0MoxS?g>sPN||M~UnSKSL49pZLY7V3>saHN>Vaa zNIv3a*S=b_jr)fZbAtJ{G+Xz*Q1vxYZY5r3A&8;r(BPu}nb zp8FtGrTUzM5!2*^0`YX3-MPfL;M{N0N)_wbs?e#v5khdE3xA`lzR%kP9-nxS#Ypk) zoDAG@xQj3|1j8wNG1h(iQGPCnR6m51Ccj?JZ$ol7FfQ0-{_{Bj(wWWgeYN zCOwah7^8W`$7?rOVE>Jpq)<;F4^~>;7_(F=*vYe$%*v6JbdK?Mbvud?Q@Rc#^pch1iW+MsRU~B}ffFUM7xgUgpxW)A)rr*K=!BweLso^#R zLg|@NB@E7@tqrXA$A3wki5PaWVu}mS9q}e?IEE5?LD(^0T6J$W1S$O>fSxq0v;2wp$!wz;t)b^6>V@;7#RiHFsV$A88xu+*R6HS4 z5HDREx}2?0=PdiZ9q7Vk88>W#V@_+=D^8sBaW3Vi3BX-Cco-FMP-k*i2fu z%L9Uy*{R+`RyBGhrBnC;A9i<}Yhv{^91#BPE!DHV0nW##6$f2Fl4O`3PG}vwVgSj! zgzAWo9L4Y)olSq!><#$-w^I+mX|TY+1ApqN0+-IH`j;dum)npxAvlH`2M@$QPuh?+ zBSZknLy)_Ni2srzzorN_o6XyI{qWAfQPV(3#&J9*J^ghFeT$rX{C#tUX28E9`J^Jy zG`n2@n7p?JU?D~$T`_+UEIURHvf-kxP1X8>P4NP4Q3bQjhDpZSfb2^$gl3*15g_G^Dl;ux;zbB6(hu|AXhlF@jlSH6sZWB14aKi(hEU1NDPEKi!?tywB^! zARg59Fdhu+`LuQtgTDH||ARW?7k?f2?&aS>wpa}3akhxZ^={V~#*fjGkEuVy&onvR z&3lL`@_L+M`uXr1-C^kY@XcTZ+B}9l|Ik2^3>UxDm~xm+2hLa4{@RQ12V(ZHA^Kxr zQ7;0=Q3fA&g}(u5{d+}@1(4Sniuw8vxgbaUzJWHUe=4Zr-HjiES-(rFJ%1Sb9};4S zWq0QQFbUsXl?Jl|BpLEl-1k6FbWu_}^k5CpLs_}OpC5=P6k1YGb|H5Ldct-o&(PpH8t$)>@+kq zGcz+cH#dTUg8lvddwY8?FE4s}djH@_|KUph-$?!5N12(K0002uk&(&(002&OQchF< z|NsC0|NsC0|NsC0lWqY&fByiiP5aIO000SaNLh0L01m$Z01m$aI0aKA000MjNklfxz}UqYe~mOIO-(A$mCbD0 z4-&ip-<;q`z~v}lmrOW%n@coFmLF@7=doJgVYymG)1p*wVpW}L00E2%LvNPXGyPU4 zI(pam;jW{(-h?YPS?5);{^`9cejtGN8i+d6S(4}`TKVC@{G=(QH zDl$b);tEO=QoPuzEVkuUIds7<#_$V2nJ}Z~$Pc{08TKw1e_sU5#jz>MqAH5gupprA zl&j&51p|fX6mG(V(={+O2;%f5s3G$M6EU+@083&Z)JC_A~g+ z_r!1jlP#B@K7XN|e+(tx`O|c;!KDZ-_{LRH0!#n37cgirp(cha;~c}!*Ek8@ik1^0 z<+(D(Ii)~o&J}Tt@b^YBKR5AOv!P`|VheBXaBIl{IKIr)Pw(^m&14M$^VGy35aW&N z!}KtEM9h1wtpW0%g95Rh-Z050w?E)Zva;vS;_ z#(((?H4p%NG_pP>D=fYwelYegZthIsXs_j%f0Vz+1b808?NJKJLX3R<>(djui|M*6{h?U6!wr~Wx zoGq%CUO9kuRqrEvs2Gdm=-1eVT)kiC`NY}DagI9$n`PPJ`+*-4-S5oWUj%+H(2RdK zf2{qP9s_#?hZ9f8l+cP*+KD_=AUH~OkhAe_p zp;h}40A8Z8A8L37*50r@7Ba+-j>QYOXFI`0EDT$UjAH>|l4C!ISAZqZ^*fZ^!A>;v z4KQL-^lG>byk}E+M(PD1EDk2*%+LW>e}!YQvW_w1axdVHnj0i|X18;sX$oFHfIYAv zYAyQ!ip9J_c)H5Ub!-(5*C_wlJvCGyT^hI^oCmQ-UF=dO4q0!(_Yr6|#fGv6#@r-V z>mkMl4S)xPlCcG<6wJmu*I3YHdjS#|xGJ_=hmMqtgBh3XpX@Wu^-^rP+#t(Ce*gjo zIZGrdVktqS_ZnE_PedE$9UynDxW=B!8={oCNu7lfAoYjTp^&g{K1V^}Jf#VN4wK?S z^oN)U0`RKcQ*#D~a?w5*NW>&mJ$o$gjW3kw98KU9<*vvD;b+Y59rYM zws#cOcThlz$4AO%djXu!PBRXwe}E*(usoEoR{LZC%De{a$S)kpaE!`k6tsH*LVQ2f z05OdyaL|BiD&^f7S^t`d<$4$LHbjh}Jf6c^GaO>qtrn}gsWr)H>Lx)M%q~eAmgt#Axg?45 zhi?x+YTU11N69pbRQ6X|KxtQL)@7}VAO`7hWRcU0j0$G?ND zuA`OCYCUWEQ-cTVS)!8})n~XZlGD>XgC@(HS%&3T(Rb=$sQGYZ5CU$Vfu3I#kR(z4 zzXnT2*<$K-W!*267=Iv^FAJhS1{P0Z#5mI6%c}4P0MVZ%Ii^6be@i6u?H^JBBzG>L z%jusAviQ*PI-tQ(njtXMKSabJ%c180L=vt(OCz#-0%!7E13R}xN#)RsJ@DTLKHqqT z?(e;T$&e}V73zGHROMz*TF(Gq^s~SoNV{Nig7iWAHe{FnqmGpi#S;2&h>1^OVj1#J z0tqvI_!;yZf=&hBJ^9nuhaAjMOl^^lj63?H-owQvCrVOAnU5fQN+c6_8jUSx+MCjK Z{|7|noqV+H73%;1002ovPDHLkV1j@TKSBTi From 94e1ce6d8e05a86f6284cac39679012d29717136 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Mon, 30 Oct 2023 15:57:39 +0300 Subject: [PATCH 1096/1199] paint and remove armor dye in painting table --- .../mc/otm/datagen/recipes/PainterRecipes.kt | 6 + .../client/screen/decorative/PainterScreen.kt | 18 +- .../mc/otm/menu/decorative/PainterMenu.kt | 26 +-- .../mc/otm/recipe/PainterRecipe.kt | 173 +++++++++++++----- .../dbotthepony/mc/otm/registry/MRecipes.kt | 2 + 5 files changed, 162 insertions(+), 63 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt index 3a283b803..f43737eca 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt @@ -10,6 +10,7 @@ import net.minecraft.world.item.crafting.Ingredient import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.core.stream import ru.dbotthepony.mc.otm.datagen.modLocation +import ru.dbotthepony.mc.otm.recipe.PainterArmorDyeRecipe import ru.dbotthepony.mc.otm.recipe.PainterRecipe import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRegistry @@ -283,4 +284,9 @@ fun addPainterRecipes(consumer: RecipeOutput) { striped(consumer, "stairs", MRegistry.TRITANIUM_STRIPED_STAIRS.itemsWithColor, MRegistry.TRITANIUM_STAIRS.items) striped(consumer, "walls", MRegistry.TRITANIUM_STRIPED_WALL.itemsWithColor, MRegistry.TRITANIUM_WALL.items) striped(consumer, "slabs", MRegistry.TRITANIUM_STRIPED_SLAB.itemsWithColor, MRegistry.TRITANIUM_SLAB.items) + + for (color in DyeColor.entries) { + consumer.accept(PainterArmorDyeRecipe(mapOf(color to 1)).toFinished(modLocation("painter/armor_dye_" + color.getName().lowercase()))) + } + consumer.accept(PainterArmorDyeRecipe(mapOf(null to 15)).toFinished(modLocation("painter/armor_clear_dye"))) } 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 30bd9e6b2..e77d5bd07 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 @@ -32,6 +32,7 @@ import ru.dbotthepony.mc.otm.core.map import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.util.CreativeMenuItemComparator import ru.dbotthepony.mc.otm.menu.decorative.PainterMenu +import ru.dbotthepony.mc.otm.recipe.PainterRecipe class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { private inner class Bar(parent: EditablePanel<*>, val dye: DyeColor?) : EditablePanel(this@PainterScreen, parent, width = 5f) { @@ -130,8 +131,19 @@ class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : buttons.forEach { it.remove() } buttons.clear() - for (recipe in menu.possibleRecipes.sortedWith(CreativeMenuItemComparator.map { it.value.output.item })) { - object : LargeRectangleButtonPanel(this@PainterScreen, canvas.canvas, icon = ItemStackIcon(recipe.value.output, 14f, 14f).fixed()) { + val recipes = menu.possibleRecipes + .filter { !it.value.ingredients.isEmpty() } + .sortedWith(CreativeMenuItemComparator.map { it.value.getOutput(menu.inputContainer).item }) + .plus( + menu.possibleRecipes + .filter { it.value.ingredients.isEmpty() } + .sortedBy { it.id } + ) + + for (recipe in recipes) { + val recipeOutput = recipe.value.getOutput(menu.inputContainer) + + object : LargeRectangleButtonPanel(this@PainterScreen, canvas.canvas, icon = ItemStackIcon(recipeOutput, 14f, 14f).fixed()) { init { buttons.add(this) dockRight = 1f @@ -143,7 +155,7 @@ class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : set(value) {} override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { - val list = getTooltipFromItem(minecraft!!, recipe.value.output) + val list = getTooltipFromItem(minecraft!!, recipeOutput) recipe.value.dyes.forEach { val (dye, amount) = it 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 94298f266..697bf2071 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 @@ -3,8 +3,7 @@ package ru.dbotthepony.mc.otm.menu.decorative import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player -import net.minecraft.world.item.DyeColor -import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.* import net.minecraft.world.item.crafting.RecipeHolder import net.minecraft.world.level.material.Fluids import net.minecraftforge.common.capabilities.ForgeCapabilities @@ -17,19 +16,14 @@ import ru.dbotthepony.mc.otm.core.ISubscriptable import ru.dbotthepony.mc.otm.core.addAll import ru.dbotthepony.mc.otm.core.collect.SupplierMap import ru.dbotthepony.mc.otm.core.collect.filter -import ru.dbotthepony.mc.otm.core.collect.find import ru.dbotthepony.mc.otm.core.collect.maybe -import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.isNotEmpty -import ru.dbotthepony.mc.otm.core.map -import ru.dbotthepony.mc.otm.core.util.CreativeMenuItemComparator import ru.dbotthepony.mc.otm.core.util.ResourceLocationValueCodec -import ru.dbotthepony.mc.otm.isClientThread import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback import ru.dbotthepony.mc.otm.menu.input.ItemConfigPlayerInput -import ru.dbotthepony.mc.otm.recipe.PainterRecipe +import ru.dbotthepony.mc.otm.recipe.AbstractPainterRecipe import ru.dbotthepony.mc.otm.registry.MMenus import ru.dbotthepony.mc.otm.registry.MRecipes import java.util.* @@ -48,7 +42,7 @@ class PainterMenu( val inputContainer = MatteryContainer(::rescan, 1) val outputContainer = MatteryContainer(1) - private var lastRecipe: RecipeHolder? = null + private var lastRecipe: RecipeHolder? = null var selectedRecipe by mSynchronizer.Field(null, ResourceLocationValueCodec.nullable).also { it.addListener { rescan() } } val isBulk = BooleanInputWithFeedback(this, tile?.let { it::isBulk }) @@ -59,6 +53,10 @@ class PainterMenu( val inputSlot = object : MatterySlot(inputContainer, 0) { override fun mayPlace(itemStack: ItemStack): Boolean { + if (!itemStack.isEmpty && itemStack.item is DyeableArmorItem) { + return super.mayPlace(itemStack) + } + return super.mayPlace(itemStack) && inventory.player.level().recipeManager.byType(MRecipes.PAINTER).values.any { it.value.input.test(itemStack) } } } @@ -126,18 +124,24 @@ class PainterMenu( } val listeners = ISubscriptable.Impl() - val possibleRecipes = ArrayList>() + val possibleRecipes = ArrayList>() private fun rescan() { possibleRecipes.clear() possibleRecipes.addAll(inventory.player.level().recipeManager.byType(MRecipes.PAINTER).values.iterator().filter { it.value.input.test(inputContainer[0]) }) + + if (!inputContainer[0].isEmpty && inputContainer[0].item is DyeableArmorItem) { + possibleRecipes.addAll(inventory.player.level().recipeManager.byType(MRecipes.PAINTER_ARMOR_DYE).values) + } + listeners.accept(Unit) if (tile !is PainterBlockEntity) return if (inputContainer.isEmpty || selectedRecipe == null) { outputContainer.clearContent() } else { - val recipe = inventory.player.level().recipeManager.byType(MRecipes.PAINTER)[selectedRecipe] +// val recipe = inventory.player.level().recipeManager.byType(MRecipes.PAINTER)[selectedRecipe] + val recipe = inventory.player.level().recipeManager.byKey(selectedRecipe).get() as RecipeHolder? if (recipe == null || !recipe.value.canCraft(dyeStoredDirect) || !recipe.value.matches(inputContainer, inventory.player.level())) { outputContainer.clearContent() 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 e72cc284e..a93aa55e3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.recipe -import com.google.common.collect.ImmutableMap import com.mojang.serialization.Codec import com.mojang.serialization.codecs.RecordCodecBuilder import it.unimi.dsi.fastutil.objects.Object2IntArrayMap @@ -12,8 +11,7 @@ import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.resources.ResourceLocation import net.minecraft.util.StringRepresentable import net.minecraft.world.Container -import net.minecraft.world.item.DyeColor -import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.* import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.item.crafting.Recipe import net.minecraft.world.item.crafting.RecipeSerializer @@ -29,24 +27,15 @@ import ru.dbotthepony.mc.otm.data.PredicatedCodecList import ru.dbotthepony.mc.otm.data.minRange import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRecipes -import java.util.EnumMap import java.util.function.Predicate -import java.util.stream.Collector -import java.util.stream.Collectors -class PainterRecipe( - val input: Ingredient, - val output: ItemStack, +abstract class AbstractPainterRecipe( dyes: Map ) : Recipe { - constructor( - input: Ingredient, - output: ItemStack, - dyes: Set - ) : this(input, output, Object2IntArrayMap().also { map -> dyes.forEach { map[it] = 1 } }) - val dyes: Object2IntMap = Object2IntMaps.unmodifiable(Object2IntArrayMap(dyes)) + override fun getToastSymbol(): ItemStack = ItemStack(MItems.PAINTER) + fun canCraft(storedDyes: Map): Boolean { if (isIncomplete) return false if (dyes.isEmpty() || dyes.values.none { it > 0 }) return true @@ -63,6 +52,52 @@ class PainterRecipe( return true } + override fun canCraftInDimensions(p_43999_: Int, p_44000_: Int): Boolean = true + + override fun isSpecial(): Boolean = true + + open fun getOutput(container: Container): ItemStack { + if (container.isEmpty) return ItemStack.EMPTY + + return container[0].copy() + } + + enum class DyeColorWrapper(private val refName: String, val key: DyeColor?) : StringRepresentable { + WHITE("white", DyeColor.WHITE), + ORANGE("orange", DyeColor.ORANGE), + MAGENTA("magenta", DyeColor.MAGENTA), + LIGHT_BLUE("light_blue", DyeColor.LIGHT_BLUE), + YELLOW("yellow", DyeColor.YELLOW), + LIME("lime", DyeColor.LIME), + PINK("pink", DyeColor.PINK), + GRAY("gray", DyeColor.GRAY), + LIGHT_GRAY("light_gray", DyeColor.LIGHT_GRAY), + CYAN("cyan", DyeColor.CYAN), + PURPLE("purple", DyeColor.PURPLE), + BLUE("blue", DyeColor.BLUE), + BROWN("brown", DyeColor.BROWN), + GREEN("green", DyeColor.GREEN), + RED("red", DyeColor.RED), + BLACK("black", DyeColor.BLACK), + WATER("water", null); + + override fun getSerializedName(): String { + return refName + } + } +} + +class PainterRecipe( + val input: Ingredient, + val output: ItemStack, + dyes: Map +) : AbstractPainterRecipe(dyes) { + constructor( + input: Ingredient, + output: ItemStack, + dyes: Set + ) : this(input, output, Object2IntArrayMap().also { map -> dyes.forEach { map[it] = 1 } }) + override fun matches(p_44002_: Container, p_44003_: Level): Boolean { if (isIncomplete) return false return input.test(p_44002_[0]) @@ -90,14 +125,6 @@ class PainterRecipe( } } - override fun canCraftInDimensions(p_43999_: Int, p_44000_: Int): Boolean { - return true - } - - override fun isSpecial(): Boolean { - return true - } - override fun getResultItem(p_267052_: RegistryAccess): ItemStack { return output } @@ -110,36 +137,12 @@ class PainterRecipe( return MRecipes.PAINTER } - override fun getToastSymbol(): ItemStack { - return ItemStack(MItems.PAINTER) - } - fun toFinished(id: ResourceLocation): FinishedRecipe { return SERIALIZER.toFinished(this, id) } - private enum class DyeColorWrapper(val refName: String, val key: DyeColor?) : StringRepresentable { - WHITE("white", DyeColor.WHITE), - ORANGE("orange", DyeColor.ORANGE), - MAGENTA("magenta", DyeColor.MAGENTA), - LIGHT_BLUE("light_blue", DyeColor.LIGHT_BLUE), - YELLOW("yellow", DyeColor.YELLOW), - LIME("lime", DyeColor.LIME), - PINK("pink", DyeColor.PINK), - GRAY("gray", DyeColor.GRAY), - LIGHT_GRAY("light_gray", DyeColor.LIGHT_GRAY), - CYAN("cyan", DyeColor.CYAN), - PURPLE("purple", DyeColor.PURPLE), - BLUE("blue", DyeColor.BLUE), - BROWN("brown", DyeColor.BROWN), - GREEN("green", DyeColor.GREEN), - RED("red", DyeColor.RED), - BLACK("black", DyeColor.BLACK), - WATER("water", null); - - override fun getSerializedName(): String { - return refName - } + override fun getOutput(container: Container): ItemStack { + return this.output } companion object { @@ -160,3 +163,75 @@ class PainterRecipe( } } } +class PainterArmorDyeRecipe( + dyes: Map +) : AbstractPainterRecipe(dyes) { + constructor( + dyes: Set + ) : this(Object2IntArrayMap().also { map -> dyes.forEach { map[it] = 1 } }) + + override fun matches(contaier: Container, level: Level): Boolean { + if (this.isIncomplete) return false + val stack = contaier[0] + + return (!stack.isEmpty && stack.item is DyeableArmorItem) + } + + override fun assemble(container: Container, registry: RegistryAccess): ItemStack { + var output = container[0].copy() + + dyes.forEach { entry -> + if (entry.key == null) { + (output.item as DyeableLeatherItem).clearColor(output) + } else { + output = DyeableLeatherItem.dyeArmor(output.copy(), listOf(DyeItem.byColor(entry.key!!))) + } + } + + return output + } + + override fun getResultItem(registry: RegistryAccess): ItemStack = ItemStack.EMPTY + + override fun getSerializer(): RecipeSerializer<*> = SERIALIZER + + override fun getType(): RecipeType<*> = MRecipes.PAINTER_ARMOR_DYE + + override fun isIncomplete(): Boolean = dyes.isEmpty() + + fun toFinished(id: ResourceLocation): FinishedRecipe { + return SERIALIZER.toFinished(this, id) + } + + override fun getOutput(container: Container): ItemStack { + if (container.isEmpty) return ItemStack.EMPTY + + var output = container[0].copy() + + dyes.forEach { entry -> + if (entry.key == null) { + (output.item as DyeableLeatherItem).clearColor(output) + } else { + output = DyeableLeatherItem.dyeArmor(output.copy(), listOf(DyeItem.byColor(entry.key!!))) + } + } + + return output + } + + companion object { + private val wrapperCodec = StringRepresentable.fromEnum(DyeColorWrapper::values) + + val SERIALIZER = Codec2RecipeSerializer { _ -> + RecordCodecBuilder.create { + it.group( + PredicatedCodecList>( + 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 } } }).forGetter(PainterArmorDyeRecipe::dyes), + ).apply(it, ::PainterArmorDyeRecipe) + } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt index 84c436e65..d3cc8c922 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt @@ -34,6 +34,7 @@ object MRecipes { val PLATE_PRESS by register("plate_press") val PAINTER by register("painter") + val PAINTER_ARMOR_DYE by register("painter_armor_dye") val MATTER_ENTANGLER by register("matter_entangler") val MICROWAVE by register("microwave") @@ -43,6 +44,7 @@ object MRecipes { serializers.register("upgrade") { UpgradeRecipe.CODEC } serializers.register("hammer_priming") { ExplosiveHammerPrimingRecipe.CODEC } serializers.register("painter") { PainterRecipe.SERIALIZER } + serializers.register("painter_armor_dye") { PainterArmorDyeRecipe.SERIALIZER } serializers.register("matter_entangler") { MatterEntanglerRecipe.SERIALIZER } serializers.register("matter_entangler_energetic") { MatterEntanglerRecipe.ENERGY_SERIALIZER } serializers.register("matter_entangler_matter") { MatterEntanglerRecipe.MATTER_SERIALIZER } From 608771f4412322137c2052199c9b2c26b225921e Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Mon, 30 Oct 2023 16:53:21 +0300 Subject: [PATCH 1097/1199] =?UTF-8?q?DBot=20=E2=80=94=20=D0=A1=D0=B5=D0=B3?= =?UTF-8?q?=D0=BE=D0=B4=D0=BD=D1=8F,=20=D0=B2=2016:11=20=D0=B4=D0=BE=D0=B1?= =?UTF-8?q?=D0=B0=D0=B2=D1=8C=20margin=20=D1=81=D0=B2=D0=B5=D1=80=D1=85?= =?UTF-8?q?=D1=83=20=D1=83=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D0=B8=20=D0=BC?= =?UTF-8?q?=D0=B0=D1=81=D1=81=D0=BE=D0=B2=D0=BE=D0=B9=20=D0=BF=D0=BE=D0=BA?= =?UTF-8?q?=D1=80=D0=B0=D1=81=D0=BA=D0=B8=20=D0=B8=D0=BB=D0=B8=20=D1=83=20?= =?UTF-8?q?=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B0=20=D1=81=D0=BD=D0=B8=D0=B7?= =?UTF-8?q?=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dbotthepony/mc/otm/client/screen/decorative/PainterScreen.kt | 1 + .../kotlin/ru/dbotthepony/mc/otm/menu/decorative/PainterMenu.kt | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) 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 e77d5bd07..555b059a7 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 @@ -123,6 +123,7 @@ class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : val canvas = ScrollableCanvasPanel(this, column) canvas.dock = Dock.FILL + canvas.dockPaddingBottom = 4f val buttons = ArrayList>() 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 697bf2071..02ce925e5 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 @@ -140,7 +140,6 @@ class PainterMenu( if (inputContainer.isEmpty || selectedRecipe == null) { outputContainer.clearContent() } else { -// val recipe = inventory.player.level().recipeManager.byType(MRecipes.PAINTER)[selectedRecipe] val recipe = inventory.player.level().recipeManager.byKey(selectedRecipe).get() as RecipeHolder? if (recipe == null || !recipe.value.canCraft(dyeStoredDirect) || !recipe.value.matches(inputContainer, inventory.player.level())) { From 92a9fa39dfc40cf116dc5128473df66f2203ff6a Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Mon, 30 Oct 2023 22:38:18 +0300 Subject: [PATCH 1098/1199] darken icons in disabled/pressed buttons --- .../screen/panels/button/LargeRectangleButtonPanel.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt index 5c1e22d90..5515b17af 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt @@ -7,6 +7,7 @@ import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.menu.MatteryMenu open class LargeRectangleButtonPanel( @@ -28,10 +29,11 @@ open class LargeRectangleButtonPanel( override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { super.innerRender(graphics, mouseX, mouseY, partialTick) + val color = if (isDisabled || isPressed) RGBAColor.DARK_GRAY else RGBAColor.WHITE if (iconWinding != null) { - icon?.render(graphics, width = width, height = height, winding = iconWinding!!) + icon?.render(graphics, width = width, height = height, winding = iconWinding!!, color = color) } else { - icon?.render(graphics, width = width, height = height) + icon?.render(graphics, width = width, height = height, color = color) } } From 0d474e1991fa5736e7bd907e33481368332b2b09 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Mon, 30 Oct 2023 22:38:48 +0300 Subject: [PATCH 1099/1199] handle icon color in itemstack icon buttons --- .../kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt index eb41d2bac..f4ffa2179 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt @@ -131,6 +131,7 @@ data class ItemStackIcon(private val itemStack: ItemStack, override val width: F pose.scale(width / 16f, height / 16f, 1f) + guiGraphics.setColor(color.red, color.green, color.blue, color.alpha) guiGraphics.renderFakeItem(itemStack, 0, 0) pose.popPose() From 8e3c95159aa65f53658c5eea14b2f2f8b578d803 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Mon, 30 Oct 2023 22:40:07 +0300 Subject: [PATCH 1100/1199] display painter recipe name in advanced tooltips --- .../mc/otm/client/screen/decorative/PainterScreen.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 555b059a7..9decd3d15 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 @@ -32,7 +32,6 @@ import ru.dbotthepony.mc.otm.core.map import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.util.CreativeMenuItemComparator import ru.dbotthepony.mc.otm.menu.decorative.PainterMenu -import ru.dbotthepony.mc.otm.recipe.PainterRecipe class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { private inner class Bar(parent: EditablePanel<*>, val dye: DyeColor?) : EditablePanel(this@PainterScreen, parent, width = 5f) { @@ -174,6 +173,10 @@ class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : } } + if (minecraft?.options?.advancedItemTooltips == true) { + list.add(TextComponent(recipe.id.toString()).withStyle(ChatFormatting.DARK_GRAY)) + } + graphics.renderComponentTooltip(font, list, mouseX.toInt(), mouseY.toInt()) return true } From b130d69da141e3f229eeaab29ae4e17a081f8b89 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Tue, 31 Oct 2023 22:09:46 +0300 Subject: [PATCH 1101/1199] better paint bars background --- .../mc/otm/client/screen/decorative/PainterScreen.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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 9decd3d15..f738f1c56 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 @@ -49,10 +49,17 @@ class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : } override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { - graphics.renderRect(0f, 0f, width, height, color = RGBAColor.DARK_GRAY) + graphics.renderRect(0f, 0f, width, height, color = RGBAColor.LIGHT_GRAY) val color = RGBAColor.rgb(dye?.textColor ?: DyeColor.LIGHT_BLUE.textColor) - graphics.renderRect(0f, 0f, width, height, color = color.copy(alpha = 0.4f)) + + val bgColor = color.copy(alpha = 0.25f) + for (x in 0 ..< width.toInt()) { + for (y in 0 ..< height.toInt()) { + if ((x + y) % 2 == 0) + graphics.renderRect(x.toFloat(), y.toFloat(), 1f, 1f, color = bgColor) + } + } val multiplier = menu.dyeStoredDirect[dye]!!.toFloat() / (if (dye == null) PainterBlockEntity.MAX_WATER_STORAGE.toFloat() else PainterBlockEntity.MAX_STORAGE.toFloat()) graphics.renderRect(0f, height * (1f - multiplier), width, height * multiplier, color = color) From ee700c442e2c9abc056b09a546ed70fd8565e4c3 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Tue, 31 Oct 2023 22:36:59 +0300 Subject: [PATCH 1102/1199] undo dye bar static non-dye background color --- .../mc/otm/client/screen/decorative/PainterScreen.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 f738f1c56..45ff52d34 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 @@ -49,7 +49,7 @@ class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : } override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { - graphics.renderRect(0f, 0f, width, height, color = RGBAColor.LIGHT_GRAY) + graphics.renderRect(0f, 0f, width, height, color = RGBAColor.DARK_GRAY) val color = RGBAColor.rgb(dye?.textColor ?: DyeColor.LIGHT_BLUE.textColor) From 122ebb9688e83dae749b2d556d4de0e1e27c5760 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Thu, 2 Nov 2023 02:22:25 +0300 Subject: [PATCH 1103/1199] cheaper/more proper checkerboard background render (still bad) :trolley: --- .../mc/otm/client/render/RenderHelper.kt | 52 +++++++++++++++++++ .../client/screen/decorative/PainterScreen.kt | 9 +--- 2 files changed, 54 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt index e693e19cf..177c28726 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt @@ -105,6 +105,58 @@ fun GuiGraphics.renderRect( renderRect(pose().last().pose(), x, y, width, height, z, color) } +@Suppress("NAME_SHADOWING") +fun renderCheckerboard( + matrix: Matrix4f, + x: Float, + y: Float, + width: Float, + height: Float, + z: Float = 0f, + color: RGBAColor = RGBAColor.WHITE +) { + RenderSystem.setShader(GameRenderer::getPositionColorShader) + + RenderSystem.enableBlend() + RenderSystem.defaultBlendFunc() + + if (!is3DContext) + RenderSystem.depthFunc(GL_ALWAYS) + + val tess = tesselator + val builder = tess.builder + + builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR) + + for (i in 0 ..< width.toInt()) { + val x = x + i.toFloat() + + for (j in 0 ..< height.toInt()) { + val y = y + j.toFloat() + + if ((i + j) % 2 == 0) { + builder.vertex(matrix, x, y + 1f, z).color(color).endVertex() + builder.vertex(matrix, x + 1f, y + 1f, z).color(color).endVertex() + builder.vertex(matrix, x + 1f, y, z).color(color).endVertex() + builder.vertex(matrix, x, y, z).color(color).endVertex() + } + } + } + + tess.end() +} + +fun GuiGraphics.renderCheckerboard( + x: Float, + y: Float, + width: Float, + height: Float, + z: Float = 0f, + color: RGBAColor = RGBAColor.WHITE +) { + renderCheckerboard(pose().last().pose(), x, y, width, height, z, color) +} + fun renderTexturedRect( matrix: Matrix4f, x: Float, 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 45ff52d34..fd52916fd 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 @@ -13,6 +13,7 @@ import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.block.entity.decorative.PainterBlockEntity import ru.dbotthepony.mc.otm.client.render.FlatRectangleIcon import ru.dbotthepony.mc.otm.client.render.ItemStackIcon +import ru.dbotthepony.mc.otm.client.render.renderCheckerboard import ru.dbotthepony.mc.otm.client.render.renderRect import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.Dock @@ -53,13 +54,7 @@ class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : val color = RGBAColor.rgb(dye?.textColor ?: DyeColor.LIGHT_BLUE.textColor) - val bgColor = color.copy(alpha = 0.25f) - for (x in 0 ..< width.toInt()) { - for (y in 0 ..< height.toInt()) { - if ((x + y) % 2 == 0) - graphics.renderRect(x.toFloat(), y.toFloat(), 1f, 1f, color = bgColor) - } - } + graphics.renderCheckerboard(0f, 0f, width, height, color = color.copy(alpha = 0.25f)) val multiplier = menu.dyeStoredDirect[dye]!!.toFloat() / (if (dye == null) PainterBlockEntity.MAX_WATER_STORAGE.toFloat() else PainterBlockEntity.MAX_STORAGE.toFloat()) graphics.renderRect(0f, height * (1f - multiplier), width, height * multiplier, color = color) From 586c43fd6c0f785fbeb41439f5b20682f06b0779 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Sat, 4 Nov 2023 13:39:08 +0300 Subject: [PATCH 1104/1199] hud text scale + reorganize client config --- .../mc/otm/client/ClientEventHandler.kt | 4 +- .../dbotthepony/mc/otm/client/MatteryGUI.kt | 8 +- .../mc/otm/client/screen/MatteryScreen.kt | 2 +- .../client/screen/panels/button/Buttons.kt | 6 +- .../dbotthepony/mc/otm/config/ClientConfig.kt | 81 ++++++++++++++----- .../mc/otm/matter/MatterManager.kt | 4 +- 6 files changed, 73 insertions(+), 32 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt index b6d324cfa..66b76fa4a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt @@ -229,7 +229,7 @@ fun onMouseScrolled(event: MouseScrolled.Pre) { return } - if (ClientConfig.EXOPACK_FREE_SCROLL && widget.panel is InventoryScrollbarPanel) { + if (ClientConfig.GUI.EXOPACK_FREE_SCROLL && widget.panel is InventoryScrollbarPanel) { val slot = screen.slotUnderMouse if (slot != null && (slot.container == minecraft.player?.inventory && slot.containerSlot in 9 .. 35 || slot.container == minecraft.player?.matteryPlayer?.exopackContainer)) { @@ -266,7 +266,7 @@ private val TOOLTIP_TAG_DISPLAY_ITEM_TITLE = TranslatableComponent("otm.gui.debu private val TOOLTIP_TAG_DISPLAY_BLOCK_TITLE = TranslatableComponent("otm.gui.debug.tags.block.title").withStyle(ChatFormatting.DARK_GRAY) fun tooltipEvent(event: ItemTooltipEvent) { - if (event.flags.isAdvanced && ClientConfig.TOOLTIP_DISPLAY_TAGS && !event.itemStack.isEmpty) { + if (event.flags.isAdvanced && ClientConfig.Tooltip.DISPLAY_TAGS && !event.itemStack.isEmpty) { val itemTags = ArrayList>() if (event.itemStack.tags.count() > 0) { itemTags.addAll(event.itemStack.tags) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index fae1fea3f..16d14743d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -262,7 +262,8 @@ object MatteryGUI { val formattedPower = mattery.androidEnergy.batteryLevel.formatPower() - event.guiGraphics.draw(gui.font, formattedPower, left + CHARGE_BG.width + 1f, top + CHARGE_BG.height / 2f, scale = 0.5f, gravity = RenderGravity.CENTER_LEFT, color = RGBAColor.YELLOW, drawOutline = true) + val scale = ClientConfig.HUD.BAR_TEXT_SCALE.toFloat() + event.guiGraphics.draw(gui.font, formattedPower, left + CHARGE_BG.width + 2f + scale, top + CHARGE_BG.height / 2f + scale, scale = scale, gravity = RenderGravity.CENTER_LEFT, color = RGBAColor.YELLOW, drawOutline = true) } } @@ -291,7 +292,7 @@ object MatteryGUI { } // можно вынести в конфиг, но для этого нужен селектор цвета private fun renderPlayerHealth(event: RenderGuiOverlayEvent.Pre, gui: ForgeGui) { - if (!ClientConfig.ANDROID_HEALTH_HUD) return + if (!ClientConfig.HUD.ANDROID_HEALTH_BAR) return val ply: LocalPlayer = minecraft.player ?: return var mattery = ply.matteryPlayer @@ -338,7 +339,8 @@ object MatteryGUI { if (ply.absorptionAmount > 0) formattedHealth = TextComponent("%d+%d/%d".format(ply.health.toInt(), ply.absorptionAmount.toInt(), ply.maxHealth.toInt())) - event.guiGraphics.draw(minecraft.font, formattedHealth, left - 2f, top + HEALTH_BG.height / 2f, scale = 0.5f, gravity = RenderGravity.CENTER_RIGHT, color = getHealthColorForPlayer(ply), drawOutline = true) + val scale = ClientConfig.HUD.BAR_TEXT_SCALE.toFloat() + event.guiGraphics.draw(minecraft.font, formattedHealth, left - 2f, top + HEALTH_BG.height / 2f + 1f * scale, scale = scale, gravity = RenderGravity.CENTER_RIGHT, color = getHealthColorForPlayer(ply), drawOutline = true) } } 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 3105d5426..67f24f1b2 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 @@ -747,6 +747,6 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit const val MAX_ROWS = 6 var lastScroll = 0 - var lastRows by ClientConfig::EXOPACK_INVENTORY_ROWS + var lastRows by ClientConfig.GUI::EXOPACK_INVENTORY_ROWS } } 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 298603b00..69b871904 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 @@ -65,9 +65,9 @@ private fun > makeRedstoneSettingButton( set(value) {} init { - add(RedstoneSetting.IGNORED, tooltip = RedstoneSetting.IGNORED.description, skinElement = if (ClientConfig.REDSTONE_CONTROLS_ITEM_ICONS) gunpowder else Widgets18.REDSTONE_IGNORED) - add(RedstoneSetting.LOW, tooltip = RedstoneSetting.LOW.description, skinElement = if (ClientConfig.REDSTONE_CONTROLS_ITEM_ICONS) redstoneUnderBarrier else Widgets18.REDSTONE_LOW) - add(RedstoneSetting.HIGH, tooltip = RedstoneSetting.HIGH.description, skinElement = if (ClientConfig.REDSTONE_CONTROLS_ITEM_ICONS) redstone else Widgets18.REDSTONE_HIGH) + add(RedstoneSetting.IGNORED, tooltip = RedstoneSetting.IGNORED.description, skinElement = if (ClientConfig.GUI.REDSTONE_CONTROLS_ITEM_ICONS) gunpowder else Widgets18.REDSTONE_IGNORED) + add(RedstoneSetting.LOW, tooltip = RedstoneSetting.LOW.description, skinElement = if (ClientConfig.GUI.REDSTONE_CONTROLS_ITEM_ICONS) redstoneUnderBarrier else Widgets18.REDSTONE_LOW) + add(RedstoneSetting.HIGH, tooltip = RedstoneSetting.HIGH.description, skinElement = if (ClientConfig.GUI.REDSTONE_CONTROLS_ITEM_ICONS) redstone else Widgets18.REDSTONE_HIGH) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ClientConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ClientConfig.kt index 64b1f5e91..d4ce32b41 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/ClientConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/ClientConfig.kt @@ -1,35 +1,74 @@ package ru.dbotthepony.mc.otm.config -import net.minecraftforge.common.ForgeConfigSpec -import net.minecraftforge.fml.ModLoadingContext import net.minecraftforge.fml.config.ModConfig object ClientConfig : AbstractConfig("client", ModConfig.Type.CLIENT) { - var ALWAYS_DISPLAY_MATTER_VALUE: Boolean by builder - .define("ALWAYS_DISPLAY_MATTER_VALUE", false) - - var EXOPACK_INVENTORY_ROWS: Int by builder - .comment("Amount of inventory rows to show when wearing Exosuit") - .defineInRange("EXOPACK_INVENTORY_ROWS", 3, 3, 6) var JUMP_BOOST_LOOK_ANGLE: Double by builder .comment("If looking below this angle (actually, looking 'above' as you see in game, but not as you expect it, check with debug screen), Crouch + Jump will trigger jump boost android ability") .defineInRange("JUMP_BOOST_LOOK_ANGLE", 30.0, -180.0, 180.0) - var EXOPACK_FREE_SCROLL: Boolean by builder - .comment("Allow to scroll Exopack inventory in non OTM inventories when hovering just over inventory slots, not only scrollbar") - .define("EXOPACK_FREE_SCROLL", true) + object Tooltip { + init { + builder.push("Tooltip") + } - var ANDROID_HEALTH_HUD: Boolean by builder - .comment("Replace hearts with health bar on HUD when you are an android") - .define("ANDROID_HEALTH_HUD", true) + var ALWAYS_DISPLAY_MATTER_VALUE: Boolean by builder + .comment("Always display matter value in tooltips without requiring holding Shift key") + .define("ALWAYS_DISPLAY_MATTER_VALUE", false) - var REDSTONE_CONTROLS_ITEM_ICONS: Boolean by builder - .comment("Display redstone control button using items instead of custom sprites") - .comment("For those who want it.") - .define("REDSTONE_CONTROLS_ITEM_ICONS", false) + var DISPLAY_TAGS: Boolean by builder + .comment("Display block/item tags in advanced item tooltips") + .define("DISPLAY_TAGS", false) - var TOOLTIP_DISPLAY_TAGS: Boolean by builder - .comment("Display block/item tags in advanced item tooltips") - .define("TOOLTIP_DISPLAY_TAGS", false) + init { + builder.pop() + } + } + + object GUI { + init { + builder.comment("Inventory/GUI options").push("Gui") + } + + var EXOPACK_INVENTORY_ROWS: Int by builder + .comment("Amount of inventory rows to show when wearing Exosuit") + .defineInRange("EXOPACK_INVENTORY_ROWS", 3, 3, 6) + + var EXOPACK_FREE_SCROLL: Boolean by builder + .comment("Allow to scroll Exopack inventory in non OTM inventories when hovering just over inventory slots, not only scrollbar") + .define("EXOPACK_FREE_SCROLL", true) + + var REDSTONE_CONTROLS_ITEM_ICONS: Boolean by builder + .comment("Display redstone control button using items instead of custom sprites") + .comment("For those who want it.") + .define("REDSTONE_CONTROLS_ITEM_ICONS", false) + + init { + builder.pop() + } + } + + object HUD { + init { + builder.push("HUD") + } + + var ANDROID_HEALTH_BAR: Boolean by builder + .comment("Replace hearts with health bar on HUD when you are an android") + .define("ANDROID_HEALTH_BAR", true) + + var BAR_TEXT_SCALE: Double by builder + .defineInRange("BAR_TEXT_SCALE", 0.5, 0.5, 1.0) + + init { + builder.pop() + } + } + + init { + Tooltip + GUI + HUD + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 1c55d6324..097f8d008 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -1345,10 +1345,10 @@ object MatterManager { return getResearchAdvance(this@MatterManager.get(stack.asItem()).complexity) } - private val formatMatterAsReadable = BooleanSupplier { if (ClientConfig.ALWAYS_DISPLAY_MATTER_VALUE) minecraft.window.isShiftDown else minecraft.window.isShiftDown && milliTime % 2_000L > 1_000L } + private val formatMatterAsReadable = BooleanSupplier { if (ClientConfig.Tooltip.ALWAYS_DISPLAY_MATTER_VALUE) minecraft.window.isShiftDown else minecraft.window.isShiftDown && milliTime % 2_000L > 1_000L } fun tooltipEvent(event: ItemTooltipEvent) { - if (ClientConfig.ALWAYS_DISPLAY_MATTER_VALUE || minecraft.window.isShiftDown) { + if (ClientConfig.Tooltip.ALWAYS_DISPLAY_MATTER_VALUE || minecraft.window.isShiftDown) { val matter = get(event.itemStack, accountForStackSize = false) if (matter.hasMatterValue) { From 8a6e8afa6132eb51dbe15b8cdb56df8c4bb3df03 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Mon, 13 Nov 2023 21:54:10 +0300 Subject: [PATCH 1105/1199] machine upgrades --- .../ru/dbotthepony/mc/otm/datagen/DataGen.kt | 12 +- .../mc/otm/datagen/items/ItemModels.kt | 52 +++++-- .../datagen/items/MatteryItemModelProvider.kt | 6 + .../mc/otm/datagen/lang/English.kt | 52 +++++-- .../mc/otm/datagen/lang/Russian.kt | 52 +++++-- .../datagen/recipes/MachineUpgradeRecipes.kt | 83 +++++++++++ .../dbotthepony/mc/otm/datagen/tags/Tags.kt | 6 +- .../dbotthepony/mc/otm/capability/Upgrades.kt | 25 ++++ .../dbotthepony/mc/otm/core/math/Decimal.kt | 6 + .../mc/otm/registry/MCreativeTabs.kt | 5 +- .../ru/dbotthepony/mc/otm/registry/MItems.kt | 131 +++++++++++++----- .../ru/dbotthepony/mc/otm/registry/MNames.kt | 7 + .../dbotthepony/mc/otm/registry/MRegistry.kt | 3 + .../item/machine_upgrade_creative.png | Bin 0 -> 249 bytes .../item/machine_upgrade_icon_capacity.png | Bin 0 -> 158 bytes .../item/machine_upgrade_icon_energy.png | Bin 0 -> 176 bytes .../item/machine_upgrade_icon_failure.png | Bin 0 -> 183 bytes .../item/machine_upgrade_icon_matter.png | Bin 0 -> 195 bytes .../item/machine_upgrade_icon_processing.png | Bin 0 -> 192 bytes .../item/machine_upgrade_icon_speed.png | Bin 0 -> 169 bytes .../textures/item/machine_upgrade_tier0.png | Bin 0 -> 239 bytes .../textures/item/machine_upgrade_tier1.png | Bin 0 -> 248 bytes .../textures/item/machine_upgrade_tier2.png | Bin 0 -> 248 bytes .../textures/item/machine_upgrade_tier3.png | Bin 0 -> 248 bytes .../textures/item/machine_upgrade_tier4.png | Bin 0 -> 248 bytes .../textures/item/upgrade_capacity.png | Bin 251 -> 0 bytes .../textures/item/upgrade_energy.png | Bin 257 -> 0 bytes .../textures/item/upgrade_failure.png | Bin 260 -> 0 bytes .../textures/item/upgrade_matter.png | Bin 263 -> 0 bytes .../textures/item/upgrade_processing.png | Bin 266 -> 0 bytes .../textures/item/upgrade_speed.png | Bin 257 -> 0 bytes 31 files changed, 350 insertions(+), 90 deletions(-) create mode 100644 src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MachineUpgradeRecipes.kt create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_creative.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_icon_capacity.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_icon_energy.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_icon_failure.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_icon_matter.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_icon_processing.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_icon_speed.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_tier0.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_tier1.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_tier2.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_tier3.png create mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_tier4.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_capacity.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_energy.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_failure.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_matter.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_processing.png delete mode 100644 src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_speed.png diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt index f8715acf2..29d749ca5 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -31,7 +31,6 @@ import ru.dbotthepony.mc.otm.datagen.blocks.MatteryBlockStateProvider import ru.dbotthepony.mc.otm.datagen.items.MatteryItemModelProvider import ru.dbotthepony.mc.otm.datagen.lang.AddEnglishLanguage import ru.dbotthepony.mc.otm.datagen.models.MatteryBlockModelProvider -import ru.dbotthepony.mc.otm.datagen.recipes.MatteryRecipeProvider import ru.dbotthepony.mc.otm.registry.* import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.datagen.advancements.addAdvancements @@ -45,15 +44,7 @@ import ru.dbotthepony.mc.otm.datagen.lang.MatteryLanguageProvider import ru.dbotthepony.mc.otm.datagen.loot.* import ru.dbotthepony.mc.otm.datagen.loot.LootModifiers import ru.dbotthepony.mc.otm.datagen.models.addBlockModels -import ru.dbotthepony.mc.otm.datagen.recipes.addBlastingRecipes -import ru.dbotthepony.mc.otm.datagen.recipes.addCraftingTableRecipes -import ru.dbotthepony.mc.otm.datagen.recipes.addDecorativesRecipes -import ru.dbotthepony.mc.otm.datagen.recipes.addMatterEntanglerRecipes -import ru.dbotthepony.mc.otm.datagen.recipes.addMicrowaveRecipes -import ru.dbotthepony.mc.otm.datagen.recipes.addPlatePressRecipes -import ru.dbotthepony.mc.otm.datagen.recipes.addShapelessRecipes -import ru.dbotthepony.mc.otm.datagen.recipes.addOreSmeltingRecipes -import ru.dbotthepony.mc.otm.datagen.recipes.addPainterRecipes +import ru.dbotthepony.mc.otm.datagen.recipes.* import ru.dbotthepony.mc.otm.datagen.tags.TagsProvider import ru.dbotthepony.mc.otm.datagen.tags.addTags import ru.dbotthepony.mc.otm.matter.MatterDataProvider @@ -563,6 +554,7 @@ object DataGen { addCraftingTableRecipes(consumer) addBlastingRecipes(consumer) addDecorativesRecipes(recipeProvider, consumer) + addMachineUpgradeRecipes(consumer) addShapelessRecipes(consumer) addOreSmeltingRecipes(consumer) addPainterRecipes(consumer) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index ec6a56c07..e29bed539 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -100,25 +100,49 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.generated(MItems.MATTER_CAPACITOR_DENSE, modLocation("item/matter_capacitor_tier3")) provider.generated(MItems.MATTER_CAPACITOR_CREATIVE) - provider.generated(MItems.CreativeUpgrades.SPEED, modLocation("item/upgrade_speed")) + provider.generated(MItems.MachineUpgrades.Basic.BLANK, modLocation("item/machine_upgrade_tier1")) + provider.upgrade(MItems.MachineUpgrades.Basic.SPEED, "speed", "tier1") + provider.upgrade(MItems.MachineUpgrades.Basic.ENERGY_CONSUMPTION, "energy", "tier1") + provider.upgrade(MItems.MachineUpgrades.Basic.FAILSAFE, "failure", "tier1") + provider.upgrade(MItems.MachineUpgrades.Basic.ENERGY_STORAGE, "capacity", "tier1") + provider.upgrade(MItems.MachineUpgrades.Basic.MATTER_STORAGE, "matter", "tier1") + provider.upgrade(MItems.MachineUpgrades.Basic.PROCESSING_ITEMS, "processing", "tier1") - provider.generated(MItems.CreativeUpgrades.ENERGY_CONSUMPTION, modLocation("item/upgrade_energy")) - provider.generated(MItems.CreativeUpgrades.ENERGY_THROUGHPUT, modLocation("item/upgrade_energy")) - provider.generated(MItems.CreativeUpgrades.ENERGY_THROUGHPUT_FLAT, modLocation("item/upgrade_energy")) - provider.generated(MItems.CreativeUpgrades.ENERGY_THROUGHPUT_FLAT_SMALL, modLocation("item/upgrade_energy")) + provider.generated(MItems.MachineUpgrades.Normal.BLANK, modLocation("item/machine_upgrade_tier2")) + provider.upgrade(MItems.MachineUpgrades.Normal.SPEED, "speed", "tier2") + provider.upgrade(MItems.MachineUpgrades.Normal.ENERGY_CONSUMPTION, "energy", "tier2") + provider.upgrade(MItems.MachineUpgrades.Normal.FAILSAFE, "failure", "tier2") + provider.upgrade(MItems.MachineUpgrades.Normal.ENERGY_STORAGE, "capacity", "tier2") + provider.upgrade(MItems.MachineUpgrades.Normal.MATTER_STORAGE, "matter", "tier2") + provider.upgrade(MItems.MachineUpgrades.Normal.PROCESSING_ITEMS, "processing", "tier2") - provider.generated(MItems.CreativeUpgrades.ENERGY_STORAGE, modLocation("item/upgrade_capacity")) - provider.generated(MItems.CreativeUpgrades.ENERGY_STORAGE_FLAT, modLocation("item/upgrade_capacity")) - provider.generated(MItems.CreativeUpgrades.ENERGY_STORAGE_FLAT_SMALL, modLocation("item/upgrade_capacity")) + provider.generated(MItems.MachineUpgrades.Advanced.BLANK, modLocation("item/machine_upgrade_tier3")) + provider.upgrade(MItems.MachineUpgrades.Advanced.SPEED, "speed", "tier3") + provider.upgrade(MItems.MachineUpgrades.Advanced.ENERGY_CONSUMPTION, "energy", "tier3") + provider.upgrade(MItems.MachineUpgrades.Advanced.FAILSAFE, "failure", "tier3") + provider.upgrade(MItems.MachineUpgrades.Advanced.ENERGY_STORAGE, "capacity", "tier3") + provider.upgrade(MItems.MachineUpgrades.Advanced.MATTER_STORAGE, "matter", "tier3") + provider.upgrade(MItems.MachineUpgrades.Advanced.PROCESSING_ITEMS, "processing", "tier3") - provider.generated(MItems.CreativeUpgrades.FAILSAFE, modLocation("item/upgrade_failure")) - provider.generated(MItems.CreativeUpgrades.FAILURE, modLocation("item/upgrade_failure")) + provider.upgrade(MItems.MachineUpgrades.Creative.SPEED, "speed", "creative") - provider.generated(MItems.CreativeUpgrades.PROCESSING_ITEMS, modLocation("item/upgrade_processing")) + provider.upgrade(MItems.MachineUpgrades.Creative.ENERGY_CONSUMPTION, "energy", "creative") + provider.upgrade(MItems.MachineUpgrades.Creative.ENERGY_THROUGHPUT, "energy", "creative") + provider.upgrade(MItems.MachineUpgrades.Creative.ENERGY_THROUGHPUT_FLAT, "energy", "creative") + provider.upgrade(MItems.MachineUpgrades.Creative.ENERGY_THROUGHPUT_FLAT_SMALL, "energy", "creative") - provider.generated(MItems.CreativeUpgrades.MATTER_STORAGE, modLocation("item/upgrade_matter")) - provider.generated(MItems.CreativeUpgrades.MATTER_STORAGE_FLAT, modLocation("item/upgrade_matter")) - provider.generated(MItems.CreativeUpgrades.MATTER_STORAGE_FLAT_SMALL, modLocation("item/upgrade_matter")) + provider.upgrade(MItems.MachineUpgrades.Creative.ENERGY_STORAGE, "capacity", "creative") + provider.upgrade(MItems.MachineUpgrades.Creative.ENERGY_STORAGE_FLAT, "capacity", "creative") + provider.upgrade(MItems.MachineUpgrades.Creative.ENERGY_STORAGE_FLAT_SMALL, "capacity", "creative") + + provider.upgrade(MItems.MachineUpgrades.Creative.FAILSAFE, "failure", "creative") + provider.upgrade(MItems.MachineUpgrades.Creative.FAILURE, "failure", "creative") + + provider.upgrade(MItems.MachineUpgrades.Creative.PROCESSING_ITEMS, "processing", "creative") + + provider.upgrade(MItems.MachineUpgrades.Creative.MATTER_STORAGE, "matter", "creative") + provider.upgrade(MItems.MachineUpgrades.Creative.MATTER_STORAGE_FLAT, "matter", "creative") + provider.upgrade(MItems.MachineUpgrades.Creative.MATTER_STORAGE_FLAT_SMALL, "matter", "creative") provider.generated(MItems.QUANTUM_BATTERY) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt index 649117b21..ceeb59adf 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt @@ -113,6 +113,12 @@ class MatteryItemModelProvider(event: GatherDataEvent) : ItemModelProvider(event fun armorColored(vararg items: Item) = items.forEach { armorColored(it) } fun armorColored(items: Collection) = items.forEach { armorColored(it) } + fun upgrade(item: Item, upgradeType: String, tier: String = "tier0") = exec { + withExistingParent(item.registryName!!.path, GENERATED) + .texture("layer0", modLocation("item/machine_upgrade_$tier")) + .texture("layer1", modLocation("item/machine_upgrade_icon_$upgradeType")) + } + companion object { val ARMOR_TRIM_MATERIALS = listOf("quartz", "iron", "netherite", "redstone", "copper", "gold", "emerald", "diamond", "lapis", "amethyst") val GENERATED = ResourceLocation("minecraft", "item/generated") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index b30813a5d..e8e558903 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -658,20 +658,44 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.ZPM_BATTERY, "Zero Point Module") add(MItems.ZPM_BATTERY, "description", "Can be found in hands of those who travel between dimensions, if they ever reached different reality of origin of these constructs...") - add(MItems.CreativeUpgrades.SPEED, "Creative Speed Upgrade") - add(MItems.CreativeUpgrades.ENERGY_CONSUMPTION, "Creative Energy Consumption Upgrade") - add(MItems.CreativeUpgrades.ENERGY_STORAGE, "Creative Energy Storage Upgrade") - add(MItems.CreativeUpgrades.ENERGY_STORAGE_FLAT, "Creative Energy Storage Upgrade (Flat)") - add(MItems.CreativeUpgrades.ENERGY_STORAGE_FLAT_SMALL, "Creative Energy Storage Upgrade (Flat Small)") - add(MItems.CreativeUpgrades.MATTER_STORAGE, "Creative Matter Storage Upgrade") - add(MItems.CreativeUpgrades.MATTER_STORAGE_FLAT, "Creative Matter Storage Upgrade (Flat)") - add(MItems.CreativeUpgrades.MATTER_STORAGE_FLAT_SMALL, "Creative Matter Storage Upgrade (Flat Small)") - add(MItems.CreativeUpgrades.ENERGY_THROUGHPUT, "Creative Energy Throughput Upgrade") - add(MItems.CreativeUpgrades.ENERGY_THROUGHPUT_FLAT, "Creative Energy Throughput Upgrade (Flat)") - add(MItems.CreativeUpgrades.ENERGY_THROUGHPUT_FLAT_SMALL, "Creative Energy Throughput Upgrade (Flat Small)") - add(MItems.CreativeUpgrades.FAILSAFE, "Creative Failsafe Upgrade") - add(MItems.CreativeUpgrades.FAILURE, "Creative Failure Upgrade") - add(MItems.CreativeUpgrades.PROCESSING_ITEMS, "Creative Item Processing Upgrade") + add(MItems.MachineUpgrades.Basic.BLANK, "Basic Upgrade Template") + add(MItems.MachineUpgrades.Basic.SPEED, "Basic Speed Upgrade") + add(MItems.MachineUpgrades.Basic.ENERGY_CONSUMPTION, "Basic Energy Consumption Upgrade") + add(MItems.MachineUpgrades.Basic.FAILSAFE, "Basic Failsafe Upgrade") + add(MItems.MachineUpgrades.Basic.ENERGY_STORAGE, "Basic Energy Storage Upgrade") + add(MItems.MachineUpgrades.Basic.MATTER_STORAGE, "Basic Matter Storage Upgrade") + add(MItems.MachineUpgrades.Basic.PROCESSING_ITEMS, "Basic Item Processing Upgrade") + + add(MItems.MachineUpgrades.Normal.BLANK, "Upgrade Template") + add(MItems.MachineUpgrades.Normal.SPEED, "Speed Upgrade") + add(MItems.MachineUpgrades.Normal.ENERGY_CONSUMPTION, "Energy Consumption Upgrade") + add(MItems.MachineUpgrades.Normal.FAILSAFE, "Failsafe Upgrade") + add(MItems.MachineUpgrades.Normal.ENERGY_STORAGE, "Energy Storage Upgrade") + add(MItems.MachineUpgrades.Normal.MATTER_STORAGE, "Matter Storage Upgrade") + add(MItems.MachineUpgrades.Normal.PROCESSING_ITEMS, "Item Processing Upgrade") + + add(MItems.MachineUpgrades.Advanced.BLANK, "Advanced Upgrade Template") + add(MItems.MachineUpgrades.Advanced.SPEED, "Advanced Speed Upgrade") + add(MItems.MachineUpgrades.Advanced.ENERGY_CONSUMPTION, "Advanced Energy Consumption Upgrade") + add(MItems.MachineUpgrades.Advanced.FAILSAFE, "Advanced Failsafe Upgrade") + add(MItems.MachineUpgrades.Advanced.ENERGY_STORAGE, "Advanced Energy Storage Upgrade") + add(MItems.MachineUpgrades.Advanced.MATTER_STORAGE, "Advanced Matter Storage Upgrade") + add(MItems.MachineUpgrades.Advanced.PROCESSING_ITEMS, "Advanced Item Processing Upgrade") + + add(MItems.MachineUpgrades.Creative.SPEED, "Creative Speed Upgrade") + add(MItems.MachineUpgrades.Creative.ENERGY_CONSUMPTION, "Creative Energy Consumption Upgrade") + add(MItems.MachineUpgrades.Creative.ENERGY_STORAGE, "Creative Energy Storage Upgrade") + add(MItems.MachineUpgrades.Creative.ENERGY_STORAGE_FLAT, "Creative Energy Storage Upgrade (Flat)") + add(MItems.MachineUpgrades.Creative.ENERGY_STORAGE_FLAT_SMALL, "Creative Energy Storage Upgrade (Flat Small)") + add(MItems.MachineUpgrades.Creative.MATTER_STORAGE, "Creative Matter Storage Upgrade") + add(MItems.MachineUpgrades.Creative.MATTER_STORAGE_FLAT, "Creative Matter Storage Upgrade (Flat)") + add(MItems.MachineUpgrades.Creative.MATTER_STORAGE_FLAT_SMALL, "Creative Matter Storage Upgrade (Flat Small)") + add(MItems.MachineUpgrades.Creative.ENERGY_THROUGHPUT, "Creative Energy Throughput Upgrade") + add(MItems.MachineUpgrades.Creative.ENERGY_THROUGHPUT_FLAT, "Creative Energy Throughput Upgrade (Flat)") + add(MItems.MachineUpgrades.Creative.ENERGY_THROUGHPUT_FLAT_SMALL, "Creative Energy Throughput Upgrade (Flat Small)") + add(MItems.MachineUpgrades.Creative.FAILSAFE, "Creative Failsafe Upgrade") + add(MItems.MachineUpgrades.Creative.FAILURE, "Creative Failure Upgrade") + add(MItems.MachineUpgrades.Creative.PROCESSING_ITEMS, "Creative Item Processing Upgrade") add(MItems.CHEST_UPGRADER, "Crate-r") add(MItems.CHEST_UPGRADER, "desc", "Replaces placed chests and barrels with cargo crates while keeping storage contents") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index ebb2bd9c3..f29ed4aaf 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -660,20 +660,44 @@ private fun items(provider: MatteryLanguageProvider) { add(MItems.ZPM_BATTERY, "Модуль нулевой точки") add(MItems.ZPM_BATTERY, "description", "Может быть найден у тех, кто путешествует между измерениями, если, конечно, они смогли достигнуть вселенной, где данные устройства были созиданы...") - add(MItems.CreativeUpgrades.SPEED, "Творческое улучшение скорости") - add(MItems.CreativeUpgrades.ENERGY_CONSUMPTION, "Творческое улучшение энергоэффективности") - add(MItems.CreativeUpgrades.ENERGY_STORAGE, "Творческое улучшение энергохраналища") - add(MItems.CreativeUpgrades.ENERGY_STORAGE_FLAT, "Творческое улучшение энергохраналища (простое)") - add(MItems.CreativeUpgrades.ENERGY_STORAGE_FLAT_SMALL, "Творческое улучшение энергохраналища (малое простое)") - add(MItems.CreativeUpgrades.MATTER_STORAGE, "Творческое улучшение хранилища материи") - add(MItems.CreativeUpgrades.MATTER_STORAGE_FLAT, "Творческое улучшение хранилища материи (простое)") - add(MItems.CreativeUpgrades.MATTER_STORAGE_FLAT_SMALL, "Творческое улучшение хранилища материи (малое простое)") - add(MItems.CreativeUpgrades.ENERGY_THROUGHPUT, "Творческое улучшение энергоканала") - add(MItems.CreativeUpgrades.ENERGY_THROUGHPUT_FLAT, "Творческое улучшение энергоканала (простое)") - add(MItems.CreativeUpgrades.ENERGY_THROUGHPUT_FLAT_SMALL, "Творческое улучшение энергоканала (малое простое)") - add(MItems.CreativeUpgrades.FAILSAFE, "Творческое улучшение отказоустойчивости") - add(MItems.CreativeUpgrades.FAILURE, "Творческое улучшение краха") - add(MItems.CreativeUpgrades.PROCESSING_ITEMS, "Творческое улучшение обработки") + add(MItems.MachineUpgrades.Basic.BLANK, "Шаблон простого улучшения") + add(MItems.MachineUpgrades.Basic.SPEED, "Простое улучшение скорости") + add(MItems.MachineUpgrades.Basic.ENERGY_CONSUMPTION, "Простое улучшение энергоэффективности") + add(MItems.MachineUpgrades.Basic.FAILSAFE, "Простое улучшение отказоустойчивости") + add(MItems.MachineUpgrades.Basic.ENERGY_STORAGE, "Простое улучшение энергохранилища") + add(MItems.MachineUpgrades.Basic.MATTER_STORAGE, "Простое улучшение хранилища материи") + add(MItems.MachineUpgrades.Basic.PROCESSING_ITEMS, "Простое улучшение обработки") + + add(MItems.MachineUpgrades.Normal.BLANK, "Шаблон улучшения") + add(MItems.MachineUpgrades.Normal.SPEED, "Улучшение скорости") + add(MItems.MachineUpgrades.Normal.ENERGY_CONSUMPTION, "Улучшение энергоэффективности") + add(MItems.MachineUpgrades.Normal.FAILSAFE, "Улучшение отказоустойчивости") + add(MItems.MachineUpgrades.Normal.ENERGY_STORAGE, "Улучшение энергохранилища") + add(MItems.MachineUpgrades.Normal.MATTER_STORAGE, "Улучшение хранилища материи") + add(MItems.MachineUpgrades.Normal.PROCESSING_ITEMS, "Улучшение обработки") + + add(MItems.MachineUpgrades.Advanced.BLANK, "Шаблон продвинутого улучшения") + add(MItems.MachineUpgrades.Advanced.SPEED, "Продвинутое улучшение скорости") + add(MItems.MachineUpgrades.Advanced.ENERGY_CONSUMPTION, "Продвинутое улучшение энергоэффективности") + add(MItems.MachineUpgrades.Advanced.FAILSAFE, "Продвинутое улучшение отказоустойчивости") + add(MItems.MachineUpgrades.Advanced.ENERGY_STORAGE, "Продвинутое улучшение энергохранилища") + add(MItems.MachineUpgrades.Advanced.MATTER_STORAGE, "Продвинутое улучшение хранилища материи") + add(MItems.MachineUpgrades.Advanced.PROCESSING_ITEMS, "Продвинутое улучшение обработки") + + add(MItems.MachineUpgrades.Creative.SPEED, "Творческое улучшение скорости") + add(MItems.MachineUpgrades.Creative.ENERGY_CONSUMPTION, "Творческое улучшение энергоэффективности") + add(MItems.MachineUpgrades.Creative.ENERGY_STORAGE, "Творческое улучшение энергохранилища") + add(MItems.MachineUpgrades.Creative.ENERGY_STORAGE_FLAT, "Творческое улучшение энергохранилища (простое)") + add(MItems.MachineUpgrades.Creative.ENERGY_STORAGE_FLAT_SMALL, "Творческое улучшение энергохранилища (малое простое)") + add(MItems.MachineUpgrades.Creative.MATTER_STORAGE, "Творческое улучшение хранилища материи") + add(MItems.MachineUpgrades.Creative.MATTER_STORAGE_FLAT, "Творческое улучшение хранилища материи (простое)") + add(MItems.MachineUpgrades.Creative.MATTER_STORAGE_FLAT_SMALL, "Творческое улучшение хранилища материи (малое простое)") + add(MItems.MachineUpgrades.Creative.ENERGY_THROUGHPUT, "Творческое улучшение энергоканала") + add(MItems.MachineUpgrades.Creative.ENERGY_THROUGHPUT_FLAT, "Творческое улучшение энергоканала (простое)") + add(MItems.MachineUpgrades.Creative.ENERGY_THROUGHPUT_FLAT_SMALL, "Творческое улучшение энергоканала (малое простое)") + add(MItems.MachineUpgrades.Creative.FAILSAFE, "Творческое улучшение отказоустойчивости") + add(MItems.MachineUpgrades.Creative.FAILURE, "Творческое улучшение краха") + add(MItems.MachineUpgrades.Creative.PROCESSING_ITEMS, "Творческое улучшение обработки") add(MItems.CHEST_UPGRADER, "Ящикатор") add(MItems.CHEST_UPGRADER, "desc", "Заменяет установленные сундуки и бочки грузовыми ящиками с сохранением содержимого") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MachineUpgradeRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MachineUpgradeRecipes.kt new file mode 100644 index 000000000..f11d03911 --- /dev/null +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MachineUpgradeRecipes.kt @@ -0,0 +1,83 @@ +package ru.dbotthepony.mc.otm.datagen.recipes + +import net.minecraft.data.recipes.RecipeOutput +import net.minecraft.world.item.Items +import net.minecraftforge.common.Tags +import ru.dbotthepony.mc.otm.registry.MItemTags +import ru.dbotthepony.mc.otm.registry.MItems + +fun addMachineUpgradeRecipes(consumer: RecipeOutput) { + MatteryRecipe(MItems.MachineUpgrades.Basic.BLANK, 4) + .rowB(Items.REDSTONE) + .rowAC(MItemTags.IRON_PLATES, MItemTags.IRON_PLATES) + .rowB(MItems.ELECTRIC_PARTS) + .unlockedBy(MItemTags.IRON_PLATES) + .unlockedBy(MItems.ELECTRIC_PARTS) + .build(consumer) + + MatteryRecipe(MItems.MachineUpgrades.Normal.BLANK, 4) + .row(MItemTags.COPPER_WIRES, Items.REDSTONE, MItemTags.COPPER_WIRES) + .row(MItemTags.IRON_PLATES, Items.REDSTONE, MItemTags.IRON_PLATES) + .rowB(MItems.ELECTRIC_PARTS) + .unlockedBy(MItemTags.IRON_PLATES) + .unlockedBy(MItems.ELECTRIC_PARTS) + .build(consumer) + + MatteryRecipe(MItems.MachineUpgrades.Advanced.BLANK, 4) + .row(MItemTags.GOLD_WIRES, Items.REDSTONE, MItemTags.GOLD_WIRES) + .row(MItemTags.TRITANIUM_PLATES, MItemTags.COPPER_WIRES, MItemTags.TRITANIUM_PLATES) + .row(MItems.ELECTRIC_PARTS, Items.REDSTONE, MItems.ELECTRIC_PARTS) + .unlockedBy(MItemTags.TRITANIUM_PLATES) + .unlockedBy(MItems.ELECTRIC_PARTS) + .build(consumer) + + for (tier in MItems.MachineUpgrades.CRAFTABLE_TIERS) { + MatteryRecipe(tier.SPEED, 1) + .rowB(Items.REDSTONE) + .row(Items.SUGAR, MItemTags.COPPER_WIRES, Items.SUGAR) + .rowB(tier.BLANK) + .unlockedBy(tier.BLANK) + .unlockedBy(MItemTags.COPPER_WIRES) + .build(consumer) + + MatteryRecipe(tier.ENERGY_CONSUMPTION, 1) + .rowB(Items.REDSTONE) + .row(MItemTags.COPPER_WIRES, MItemTags.GOLD_WIRES, MItemTags.COPPER_WIRES) + .rowB(tier.BLANK) + .unlockedBy(tier.BLANK) + .unlockedBy(MItemTags.GOLD_WIRES) + .build(consumer) + + MatteryRecipe(tier.FAILSAFE, 1) + .rowB(MItems.ELECTRIC_PARTS) + .row(MItemTags.COPPER_WIRES, MItems.QUANTUM_TRANSCEIVER, MItemTags.COPPER_WIRES) + .rowB(tier.BLANK) + .unlockedBy(tier.BLANK) + .unlockedBy(MItems.QUANTUM_TRANSCEIVER) + .build(consumer) + + MatteryRecipe(tier.ENERGY_STORAGE, 1) + .rowB(Items.REDSTONE) + .row(Items.REDSTONE, MItems.ENERGY_BUS, Items.REDSTONE) + .rowB(tier.BLANK) + .unlockedBy(tier.BLANK) + .unlockedBy(MItems.ENERGY_BUS) + .build(consumer) + + MatteryRecipe(tier.MATTER_STORAGE, 1) + .rowB(Tags.Items.GLASS) + .row(Tags.Items.GLASS, MItems.MATTER_CAPACITOR_PARTS, Tags.Items.GLASS) + .rowB(tier.BLANK) + .unlockedBy(tier.BLANK) + .unlockedBy(MItems.MATTER_CAPACITOR_PARTS) + .build(consumer) + + MatteryRecipe(tier.PROCESSING_ITEMS, 1) + .rowB(MItems.ELECTRIC_PARTS) + .row(MItems.ELECTROMAGNET, MItemTags.TRITANIUM_PLATES, MItems.ELECTROMAGNET) + .rowB(tier.BLANK) + .unlockedBy(tier.BLANK) + .unlockedBy(MItems.ELECTROMAGNET) + .build(consumer) + } +} diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index dd78fad3a..ad9a24614 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -133,7 +133,11 @@ fun addTags(tagsProvider: TagsProvider) { tagsProvider.items.Appender(MItemTags.TOOLS_HAMMERS).add(MItems.EXPLOSIVE_HAMMER) tagsProvider.items.forge("tools").add(MItemTags.TOOLS_HAMMERS) - tagsProvider.items.Appender(MItemTags.UPGRADES).add(MItems.CreativeUpgrades.LIST) + tagsProvider.items.Appender(MItemTags.UPGRADES) + .add(MItems.MachineUpgrades.Basic.LIST) + .add(MItems.MachineUpgrades.Normal.LIST) + .add(MItems.MachineUpgrades.Advanced.LIST) + .add(MItems.MachineUpgrades.Creative.LIST) tagsProvider.blocks.Appender(BlockTags.STAIRS) .add(MRegistry.FLOOR_TILES_STAIRS.blocks.values) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt index 9ae1d54fe..2669485f4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Upgrades.kt @@ -2,10 +2,12 @@ package ru.dbotthepony.mc.otm.capability import net.minecraft.ChatFormatting import net.minecraft.network.chat.Component +import net.minecraft.world.item.Item import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.collect.SupplierList import ru.dbotthepony.mc.otm.core.immutableSet import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.util.formatMatter @@ -153,6 +155,29 @@ fun IMatteryUpgrade.getUpgradeTooltipLines(): MutableList { return ArrayList().also { addUpgradeTooltipLines(it) } } +interface ITieredUpgradeSet { + val BLANK: Item + + val SPEED: Item + val ENERGY_CONSUMPTION: Item + val FAILSAFE: Item + + val ENERGY_STORAGE: Item + val MATTER_STORAGE: Item + + val PROCESSING_ITEMS: Item + + val LIST: SupplierList + get() = SupplierList( + ::SPEED, + ::ENERGY_CONSUMPTION, + ::FAILSAFE, + ::ENERGY_STORAGE, + ::MATTER_STORAGE, + ::PROCESSING_ITEMS, + ) +} + enum class UpgradeType { SPEED, PROCESSING, 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 2794c2565..3c1c12f09 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 @@ -682,7 +682,13 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe @JvmField val MINUS_TWO = valueOf(-2) @JvmField val MINUS_TEN = valueOf(-10) @JvmField val ONE_TENTH = valueOf("0.1") + @JvmField val ONE_QUARTER = valueOf("0.25") + @JvmField val ONE_EIGHTH = valueOf("0.125") + @JvmField val ONE_HALF = valueOf("0.5") @JvmField val MINUS_ONE_TENTH = valueOf("-0.1") + @JvmField val MINUS_ONE_EIGHTH = valueOf("-0.125") + @JvmField val MINUS_ONE_QUARTER = valueOf("-0.25") + @JvmField val MINUS_ONE_HALF = valueOf("-0.5") @JvmField val INT_MAX_VALUE = Decimal(BI_INT_MAX) @JvmField val INT_MIN_VALUE = Decimal(BI_INT_MIN) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt index e0d083627..ef32d75bc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt @@ -130,7 +130,10 @@ private fun CreativeModeTab.Output.fluids(value: Item) { private fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { with(consumer) { accept(MItems.MACHINES) - accept(MItems.CreativeUpgrades.LIST) + accept(MItems.MachineUpgrades.Basic.LIST) + accept(MItems.MachineUpgrades.Normal.LIST) + accept(MItems.MachineUpgrades.Advanced.LIST) + accept(MItems.MachineUpgrades.Creative.LIST) accept(MRegistry.CARGO_CRATES.item) accept(MItems.DEV_CHEST) 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 100f61660..c914e5f4a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -14,6 +14,7 @@ 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.capability.ITieredUpgradeSet import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.UpgradeType import ru.dbotthepony.mc.otm.config.ItemsConfig @@ -181,43 +182,97 @@ object MItems { TRITANIUM_ANVIL = SupplierList(props) } - object CreativeUpgrades { - val SPEED: SimpleUpgrade by registry.register("creative_speed_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.SPEED.set(), speedBonus = 1.0) } - val ENERGY_CONSUMPTION: SimpleUpgrade by registry.register("creative_energy_consumption_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_CONSUMPTION.set(), energyConsumed = Decimal.MINUS_ONE) } - val ENERGY_STORAGE: SimpleUpgrade by registry.register("creative_energy_storage_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_STORAGE.set(), energyStorage = Decimal.ONE) } - val ENERGY_STORAGE_FLAT: SimpleUpgrade by registry.register("creative_energy_storage_flat_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_STORAGE.set(), energyStorageFlat = Decimal.LONG_MAX_VALUE) } - val ENERGY_STORAGE_FLAT_SMALL: SimpleUpgrade by registry.register("creative_energy_storage_flat2_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_STORAGE.set(), energyStorageFlat = Decimal.INT_MAX_VALUE) } - val ENERGY_THROUGHPUT: SimpleUpgrade by registry.register("creative_energy_throughput_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_THROUGHPUT.set(), energyThroughput = Decimal.ONE) } - val ENERGY_THROUGHPUT_FLAT: SimpleUpgrade by registry.register("creative_energy_throughput_flat_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_THROUGHPUT.set(), energyThroughputFlat = Decimal.LONG_MAX_VALUE) } - val ENERGY_THROUGHPUT_FLAT_SMALL: SimpleUpgrade by registry.register("creative_energy_throughput_flat2_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_THROUGHPUT.set(), energyThroughputFlat = Decimal.INT_MAX_VALUE) } - val FAILSAFE: SimpleUpgrade by registry.register("creative_failsafe_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.FAILSAFE.set(), failureMultiplier = 0.0) } - val FAILURE: SimpleUpgrade by registry.register("creative_failure_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.FAILSAFE.set(), failureMultiplier = 2.0) } - val PROCESSING_ITEMS: SimpleUpgrade by registry.register("creative_processing_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.PROCESSING.set(), processingItems = 1) } + object MachineUpgrades { + object Basic : ITieredUpgradeSet { + override val BLANK: Item by registry.register("blank_machine_upgrade_basic") { Item(DEFAULT_PROPERTIES) } - val MATTER_STORAGE: SimpleUpgrade by registry.register("creative_matter_storage_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.MATTER_STORAGE.set(), matterStorage = Decimal.ONE) } - val MATTER_STORAGE_FLAT: SimpleUpgrade by registry.register("creative_matter_storage_flat_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.MATTER_STORAGE.set(), matterStorageFlat = Decimal.LONG_MAX_VALUE) } - val MATTER_STORAGE_FLAT_SMALL: SimpleUpgrade by registry.register("creative_matter_storage_flat2_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.MATTER_STORAGE.set(), matterStorageFlat = Decimal.INT_MAX_VALUE) } + override val SPEED: SimpleUpgrade by registry.register("speed_upgrade_basic") { SimpleUpgrade(Item.Properties(), UpgradeType.SPEED.set(), speedBonus = 0.125, failureMultiplier = 1.125, energyConsumed = Decimal.ONE_EIGHTH) } + override val ENERGY_CONSUMPTION: SimpleUpgrade by registry.register("energy_consumption_upgrade_basic") { SimpleUpgrade(Item.Properties(), UpgradeType.ENERGY_CONSUMPTION.set(), speedBonus = -0.25, failureMultiplier = 1.125, energyConsumed = Decimal.MINUS_ONE_EIGHTH) } + override val FAILSAFE: SimpleUpgrade by registry.register("failsafe_upgrade_basic") { SimpleUpgrade(Item.Properties(), UpgradeType.FAILSAFE.set(), speedBonus = -0.125, failureMultiplier = 0.75, energyConsumed = Decimal.ONE_EIGHTH) } - val LIST = SupplierList( - ::SPEED, - ::ENERGY_CONSUMPTION, - ::ENERGY_STORAGE, - ::ENERGY_STORAGE_FLAT, - ::ENERGY_STORAGE_FLAT_SMALL, - ::ENERGY_THROUGHPUT, - ::ENERGY_THROUGHPUT_FLAT, - ::ENERGY_THROUGHPUT_FLAT_SMALL, - ::FAILSAFE, - ::FAILURE, - ::PROCESSING_ITEMS, - ::MATTER_STORAGE, - ::MATTER_STORAGE_FLAT, - ::MATTER_STORAGE_FLAT_SMALL, + override val ENERGY_STORAGE: SimpleUpgrade by registry.register("energy_storage_upgrade_basic") { SimpleUpgrade(Item.Properties(), UpgradeType.ENERGY_STORAGE.set(), energyStorage = Decimal.ONE_HALF) } + override val MATTER_STORAGE: SimpleUpgrade by registry.register("matter_storage_upgrade_basic") { SimpleUpgrade(Item.Properties(), UpgradeType.MATTER_STORAGE.set(), matterStorage = Decimal.ONE_HALF) } + + override val PROCESSING_ITEMS: SimpleUpgrade by registry.register("processing_upgrade_basic") { SimpleUpgrade(Item.Properties(), UpgradeType.PROCESSING.set(), processingItems = 1, speedBonus = -0.25, failureMultiplier = 1.25, energyConsumed = Decimal.ONE_QUARTER) } + } + + object Normal : ITieredUpgradeSet { + override val BLANK: Item by registry.register("blank_machine_upgrade_normal") { Item(DEFAULT_PROPERTIES) } + + override val SPEED: SimpleUpgrade by registry.register("speed_upgrade_normal") { SimpleUpgrade(Item.Properties(), UpgradeType.SPEED.set(), speedBonus = 0.25, failureMultiplier = 1.25, energyConsumed = Decimal.ONE_QUARTER) } + override val ENERGY_CONSUMPTION: SimpleUpgrade by registry.register("energy_consumption_upgrade_normal") { SimpleUpgrade(Item.Properties(), UpgradeType.ENERGY_CONSUMPTION.set(), speedBonus = -0.5, failureMultiplier = 1.25, energyConsumed = Decimal.MINUS_ONE_QUARTER) } + override val FAILSAFE: SimpleUpgrade by registry.register("failsafe_upgrade_normal") { SimpleUpgrade(Item.Properties(), UpgradeType.FAILSAFE.set(), speedBonus = -0.25, failureMultiplier = 0.5, energyConsumed = Decimal.ONE_QUARTER) } + + override val ENERGY_STORAGE: SimpleUpgrade by registry.register("energy_storage_upgrade_normal") { SimpleUpgrade(Item.Properties(), UpgradeType.ENERGY_STORAGE.set(), energyStorage = Decimal.ONE) } + override val MATTER_STORAGE: SimpleUpgrade by registry.register("matter_storage_upgrade_normal") { SimpleUpgrade(Item.Properties(), UpgradeType.MATTER_STORAGE.set(), matterStorage = Decimal.ONE) } + + override val PROCESSING_ITEMS: SimpleUpgrade by registry.register("processing_upgrade_normal") { SimpleUpgrade(Item.Properties(), UpgradeType.PROCESSING.set(), processingItems = 1, speedBonus = -0.125, failureMultiplier = 1.125, energyConsumed = Decimal.ONE_EIGHTH) } + } + + object Advanced : ITieredUpgradeSet { + override val BLANK: Item by registry.register("blank_machine_upgrade_advanced") { Item(DEFAULT_PROPERTIES) } + + override val SPEED: SimpleUpgrade by registry.register("speed_upgrade_advanced") { SimpleUpgrade(Item.Properties().rarity(Rarity.UNCOMMON), UpgradeType.SPEED.set(), speedBonus = 0.25, failureMultiplier = 1.125, energyConsumed = Decimal.ONE_EIGHTH) } + override val ENERGY_CONSUMPTION: SimpleUpgrade by registry.register("energy_consumption_upgrade_advanced") { SimpleUpgrade(Item.Properties().rarity(Rarity.UNCOMMON), UpgradeType.ENERGY_CONSUMPTION.set(), speedBonus = -0.25, failureMultiplier = 1.125, energyConsumed = Decimal.MINUS_ONE_QUARTER) } + override val FAILSAFE: SimpleUpgrade by registry.register("failsafe_upgrade_advanced") { SimpleUpgrade(Item.Properties().rarity(Rarity.UNCOMMON), UpgradeType.FAILSAFE.set(), speedBonus = -0.125, failureMultiplier = 0.5, energyConsumed = Decimal.ONE_EIGHTH) } + + override val ENERGY_STORAGE: SimpleUpgrade by registry.register("energy_storage_upgrade_advanced") { SimpleUpgrade(Item.Properties(), UpgradeType.ENERGY_STORAGE.set(), energyStorage = Decimal.TWO) } + override val MATTER_STORAGE: SimpleUpgrade by registry.register("matter_storage_upgrade_advanced") { SimpleUpgrade(Item.Properties(), UpgradeType.MATTER_STORAGE.set(), matterStorage = Decimal.TWO) } + + override val PROCESSING_ITEMS: SimpleUpgrade by registry.register("processing_upgrade_advanced") { SimpleUpgrade(Item.Properties().rarity(Rarity.UNCOMMON), UpgradeType.PROCESSING.set(), processingItems = 2, speedBonus = -0.125, failureMultiplier = 1.125, energyConsumed = Decimal.ONE_EIGHTH) } + } + + object Creative { + val SPEED: SimpleUpgrade by registry.register("creative_speed_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.SPEED.set(), speedBonus = 1.0) } + val ENERGY_CONSUMPTION: SimpleUpgrade by registry.register("creative_energy_consumption_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_CONSUMPTION.set(), energyConsumed = Decimal.MINUS_ONE) } + val ENERGY_STORAGE: SimpleUpgrade by registry.register("creative_energy_storage_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_STORAGE.set(), energyStorage = Decimal.ONE) } + val ENERGY_STORAGE_FLAT: SimpleUpgrade by registry.register("creative_energy_storage_flat_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_STORAGE.set(), energyStorageFlat = Decimal.LONG_MAX_VALUE) } + val ENERGY_STORAGE_FLAT_SMALL: SimpleUpgrade by registry.register("creative_energy_storage_flat2_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_STORAGE.set(), energyStorageFlat = Decimal.INT_MAX_VALUE) } + val ENERGY_THROUGHPUT: SimpleUpgrade by registry.register("creative_energy_throughput_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_THROUGHPUT.set(), energyThroughput = Decimal.ONE) } + val ENERGY_THROUGHPUT_FLAT: SimpleUpgrade by registry.register("creative_energy_throughput_flat_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_THROUGHPUT.set(), energyThroughputFlat = Decimal.LONG_MAX_VALUE) } + val ENERGY_THROUGHPUT_FLAT_SMALL: SimpleUpgrade by registry.register("creative_energy_throughput_flat2_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.ENERGY_THROUGHPUT.set(), energyThroughputFlat = Decimal.INT_MAX_VALUE) } + val FAILSAFE: SimpleUpgrade by registry.register("creative_failsafe_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.FAILSAFE.set(), failureMultiplier = 0.0) } + val FAILURE: SimpleUpgrade by registry.register("creative_failure_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.FAILSAFE.set(), failureMultiplier = 2.0) } + val PROCESSING_ITEMS: SimpleUpgrade by registry.register("creative_processing_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.PROCESSING.set(), processingItems = 1) } + + val MATTER_STORAGE: SimpleUpgrade by registry.register("creative_matter_storage_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.MATTER_STORAGE.set(), matterStorage = Decimal.ONE) } + val MATTER_STORAGE_FLAT: SimpleUpgrade by registry.register("creative_matter_storage_flat_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.MATTER_STORAGE.set(), matterStorageFlat = Decimal.LONG_MAX_VALUE) } + val MATTER_STORAGE_FLAT_SMALL: SimpleUpgrade by registry.register("creative_matter_storage_flat2_upgrade") { SimpleUpgrade(Item.Properties().rarity(Rarity.EPIC), UpgradeType.MATTER_STORAGE.set(), matterStorageFlat = Decimal.INT_MAX_VALUE) } + + val LIST = SupplierList( + ::SPEED, + ::ENERGY_CONSUMPTION, + ::ENERGY_STORAGE, + ::ENERGY_STORAGE_FLAT, + ::ENERGY_STORAGE_FLAT_SMALL, + ::ENERGY_THROUGHPUT, + ::ENERGY_THROUGHPUT_FLAT, + ::ENERGY_THROUGHPUT_FLAT_SMALL, + ::FAILSAFE, + ::FAILURE, + ::PROCESSING_ITEMS, + ::MATTER_STORAGE, + ::MATTER_STORAGE_FLAT, + ::MATTER_STORAGE_FLAT_SMALL, + ) + } + + init { + Basic + Normal + Advanced + Creative + } + + val CRAFTABLE_TIERS = listOf( + Basic, + Normal, + Advanced, ) } init { - CreativeUpgrades + MachineUpgrades } val MATTER_DUST: MatterDustItem by registry.register(MNames.MATTER_DUST) { MatterDustItem() } @@ -450,11 +505,11 @@ object MItems { } } } - val QUANTUM_TRANSCEIVER: Item by registry.register("quantum_transceiver") { Item(DEFAULT_PROPERTIES) } - val ELECTROMAGNET: Item by registry.register("electromagnet") { Item(DEFAULT_PROPERTIES) } - val ELECTROMOTOR: Item by registry.register("electromotor") { Item(DEFAULT_PROPERTIES) } - val MIRROR_COMPOUND: Item by registry.register("mirror_compound") { Item(DEFAULT_PROPERTIES) } - val MIRROR: Item by registry.register("mirror") { object : Item(DEFAULT_PROPERTIES) { + val QUANTUM_TRANSCEIVER: Item by registry.register(MNames.QUANTUM_TRANSCEIVER) { Item(DEFAULT_PROPERTIES) } + val ELECTROMAGNET: Item by registry.register(MNames.ELECTROMAGNET) { Item(DEFAULT_PROPERTIES) } + val ELECTROMOTOR: Item by registry.register(MNames.ELECTROMOTOR) { Item(DEFAULT_PROPERTIES) } + val MIRROR_COMPOUND: Item by registry.register(MNames.MIRROR_COMPOUND) { Item(DEFAULT_PROPERTIES) } + val MIRROR: Item by registry.register(MNames.MIRROR) { object : Item(DEFAULT_PROPERTIES) { override fun appendHoverText( p_41421_: ItemStack, p_41422_: Level?, @@ -495,6 +550,10 @@ object MItems { ::CARBON_MESH, ::REINFORCED_TRITANIUM_PLATE, + + MachineUpgrades.Basic::BLANK, + MachineUpgrades.Normal::BLANK, + MachineUpgrades.Advanced::BLANK, ) /** diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index 53e56b58d..258cc69c5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -173,6 +173,13 @@ object MNames { const val CARBON_MESH = "carbon_mesh" const val REINFORCED_TRITANIUM_PLATE = "reinforced_tritanium_plate" + const val QUANTUM_TRANSCEIVER = "quantum_transceiver" + const val ELECTROMAGNET = "electromagnet" + const val ELECTROMOTOR = "electromotor" + const val MIRROR_COMPOUND = "mirror_compound" + const val MIRROR = "mirror" + const val BLANK_MACHINE_UPGRADE = "blank_machine_upgrade" + const val ENERGY_BUS = "energy_bus" const val ELECTRIC_PARTS = "electric_parts" 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 aac52447c..c54781d2f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -43,6 +43,7 @@ import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.client.MatteryGUI import ru.dbotthepony.mc.otm.compat.vanilla.MatteryChestMenu import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.data.DecimalProvider import ru.dbotthepony.mc.otm.item.weapon.EnergySwordItem import ru.dbotthepony.mc.otm.matter.AbstractRegistryAction @@ -364,6 +365,8 @@ object MRegistry { event.register({ stack, layer -> if (layer == 0) (stack.item as DyeableArmorItem).getColor(stack) else -1 }, *MItems.TRITANIUM_ARMOR.toTypedArray() ) + event.register({ _, layer -> if (layer == 1) RGBAColor.AQUA.toARGB() else -1 }, + *MItems.MachineUpgrades.Creative.LIST.toTypedArray()) } private fun registerItemDecorators(event: RegisterItemDecorationsEvent) { diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_creative.png b/src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_creative.png new file mode 100644 index 0000000000000000000000000000000000000000..56a36411a8632970f2489866ae92dbb8c1319afc GIT binary patch literal 249 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}H0G|-o4XMKa|30`iUHI?U_!12kQ&Uqu3n9q_`TsY7Dj1^X$%0JdDhcun z{tp8To6hK*2a0kQctjR6F!1dMVMYtqU=^UCpQnpsh(>Vkd2g`>1rCS6I?p%thZ&1{ ztZdYaQk8D#8~hMyXgP60Zexyx=#gYo=ewILo3lP-IA^o$jNIBbfjI literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_icon_energy.png b/src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_icon_energy.png new file mode 100644 index 0000000000000000000000000000000000000000..461d774e84b1bcb6d65aacacd52a1ddd93c80528 GIT binary patch literal 176 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sEXgD|57Yp@DX(ACq$F~q_@S%P&6vztaQ<3DD`DV%IQ4h*S_ z7}PX;%?@N~ZQRz(5Xg3b!K}Gp77x=2wueQmfr$;?#*PiAwHGr;8W=DzEL9ZYocAnZ Q0nk7OPgg&ebxsLQ0FTEkdjJ3c literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_icon_failure.png b/src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_icon_failure.png new file mode 100644 index 0000000000000000000000000000000000000000..6591efe7ffc74f0a9d15f71f45de5b082e8967aa GIT binary patch literal 183 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sEXgD|57Yp@DX(8troF~q_@S%TGs?f*iCQ%AXGEHJs*An29M zP%>Mxk>QjIpMrElo`lhXSFAZw1(HoyBP~ReKeDwkY)YHKmXl=AaGfEC;ckN>zk~#X Y7N_>dwN2jFf#x!Jy85}Sb4q9e0Hjti^#A|> literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_icon_matter.png b/src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_icon_matter.png new file mode 100644 index 0000000000000000000000000000000000000000..6f0d1d42739a0cdda4dfaf2c5cf9fca10c4237af GIT binary patch literal 195 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}E0G|-o|Ns93nW2X+*8wS}k|4j}{|ryJ8+ZYEoCO|{#S9F5`$3q|f;CtL zC}`p7;uxY4oSfjoEW%~bV3EM6zP?C4yTuVtUk$j>y75#J4}nc&9k3=bBHeaJa_Yrw$Kx?(h6J)x7?3sJ9DRBj`7{b j9lMk2Rzzj&SAE2y*y4WCgzda1&;kZeS3j3^P6B! z-R-kET%zaGV!OAj*1qg<8!neTV7h>>_#ouV#erbyJQ({|w-GB3S_beTtNerH@ KelF{r5}E)S4>St^ literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_tier0.png b/src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_tier0.png new file mode 100644 index 0000000000000000000000000000000000000000..c9cf18e417237063bf037f86c1739b2c0fb5b488 GIT binary patch literal 239 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}%0G|-oz`(%z`uc)`0x>Z$Q&Uqu3n9q_`TsY7(hUDzzT5z$I7@>3g8xGS zL$H5^5J<4VBeIx*fp0$uGg`0)s{jQ(JY5_^G=k@zcjRMG8bz#ZoC1wexja99sOXf;C#2z%d+IWPi;^?ED+df@qJbHKk45kH4Q+%1j Uxh5I=1I=XcboFyt=akR{08A!KPyhe` literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_tier1.png b/src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_tier1.png new file mode 100644 index 0000000000000000000000000000000000000000..2922b8866dd04b9c077c618ca9954f61464340f7 GIT binary patch literal 248 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}T0G|-oz`(%z`g*@<1~Ka`#Kgo33JOe3P5CT@BopNS-vBCN@SnW<2$13~ z3Gxg64+jih{*0f1!kh&jk;M!QeEUI|(SkKt1t{q0>Ealo5j^+2q0j*Z4wpca6)ErQ z6I^GeOy2k@_+uN}LH)*>B9EV4MVDCp8LwzgiEvA0+{(K43X4$b1L3dFkDa{DVq(0z cR;qzd>Ke-=qjMkPfrc`8y85}Sb4q9e0BxdBjsO4v literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_tier2.png b/src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_tier2.png new file mode 100644 index 0000000000000000000000000000000000000000..760cf737e2fea500a9b3a4587420a873403b570d GIT binary patch literal 248 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}T0G|-oz`(%z`ueqVeU5Dj7ZVdJC@3&BHRZDql1z~Qe*>t9pEalo5j^+2q0j*Z4wpca6)ErQ z6I^GeOy2k@_+uN}LH)*>B9EV4MVDCp8LwzgiEvA0+{(K43X4$b1L3dFkDa{DVq(0z cR;qzd>Ke-=qjMkPfrc`8y85}Sb4q9e0QzuIRsaA1 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_tier3.png b/src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_tier3.png new file mode 100644 index 0000000000000000000000000000000000000000..ffef41a20c4cc460ba12954b52acf4765f5f29a8 GIT binary patch literal 248 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}T0G|-oz`(%z`ucgMrrYi8#Kgo33JOe3P5CT@BopNS-vBCNSaAG^Jdolp z3Gxg64+jih{*0f1!kh&jk;M!QeEUI|(SkKt1t{q0>Ealo5j^+2q0j*Z4wpca6)ErQ z6I^GeOy2k@_+uN}LH)*>B9EV4MVDCp8LwzgiEvA0+{(K43X4$b1L3dFkDa{DVq(0z cR;qzd>Ke-=qjMkPfrc`8y85}Sb4q9e08n61TL1t6 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_tier4.png b/src/main/resources/assets/overdrive_that_matters/textures/item/machine_upgrade_tier4.png new file mode 100644 index 0000000000000000000000000000000000000000..de42fdf3800b878872fdd49075bce40d0c302e10 GIT binary patch literal 248 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}T0G|-oz`(%z`ueHf+c!kq5EBzCC@3&BHRZDql1z~Qe*>t9;V}EUjX;XK zB*-uLKO8W4`7?e33Ud~CL>4nJ@a+d-Mhn(p6`-J}r;B5VM)2J8hC&AvI9vivR;0YI zPjH=?GI`^t;E!!=2lX3kiadUH6 cTB!y;scS5gjLvFVdQ&MBb@01VYpb^rhX literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_capacity.png b/src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_capacity.png deleted file mode 100644 index 6eb8335b6e43196a7de21a039279c9cce8bb4cb9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 251 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}H0G|-oz`(%z`uc)`0x>bM|NsA+nws)i2uUW$|GxoL!7#VK@;i{?Dhcun z2FgMJ!=^Jj=YgV}1s;*b3=DkxL735kHCP2G7~tvR7@`qedOnh`!GOc{B2!e&@B15k z1Wi7EDrd^v^&vBHZ;`^XE>EF(TyFIRDa=JaOgkEdclf=T*>ukFT;KtL!Wr6+=5L;= h#}FN=KcDvj+x;%)ADb1{9|xMv;OXk;vd$@?2>{W`REhuq diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_energy.png b/src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_energy.png deleted file mode 100644 index 6403f04c2d03bb2e05444c51e85266a0bd6d8320..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 257 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}H0G|-oz`(%z`uc)`0x>bM|NsA+nws)i2uUW$|GxoL!7#VK@;i{?Dhcun z2FgMJ!=^Jj=YgV}1s;*b3=DkxL735kHCP2G80P8X7@`qed;THU0R;}Xz_X`*{?oUy z-+Jv^vbl#9i{MRlqbk-1$3l}mZ-~m|zPP8qrnt$TiD4_tlk^_pB!-j)a=$q|I#~k3 nl@31tb1JyOH+1iYWi#*I-^={1@}_n;&;|xiS3j3^P6f diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_failure.png b/src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_failure.png deleted file mode 100644 index c9dca5ab939f9ff2a67ec1f27a04188559a97937..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 260 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}H0G|-oz`(%z`uc)`0x>bM|NsA+nws)i2uUW$|GxoL!7#VK@;i{?Dhcun z2FgMJ!=^Jj=YgV}1s;*b3=DkxL735kHCP2G80qQa7@`qedcK#hL4m_9@QM55zws7! zDqFYZUH;Uw*7INIoH$0Q?On5dB1C0!1I}Kz&)C9X-znUnZm{}XDT9{4W{WG+6n>oZ qVUVa4iqUf`NS%G}H0G|-oz`(%z`uc)`0x>bM|NsA+nws)i2uUW$|GxoL!7#VK@;i{?Dhcun z2FgMJ!=^Jj=YgV}1s;*b3=DkxL735kHCP2G7~|>U7@`pzd)}MxfC2|gz|YK`|6946 zFWuPa_MBB*_TT9bg{qA+%4RHCu=%0OSBE=~b}!KSD(quoVAaAMVX4^1e3vmPZPixZ u2|-s?7?rIj*^4X3GuT~^@?ZDzo&MV$EIiEJ7taFiVeoYIb6Mw<&;$T;5?T2G diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_processing.png b/src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_processing.png deleted file mode 100644 index 39bfd8aa673b539123df87f13e46be4a626b904a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 266 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}H0G|-oz`(%z`uc)`0x>bM|NsA+nws)i2uUW$|GxoL!7#VK@;i{?Dhcun z2FgMJ!=^Jj=YgV}1s;*b3=DkxL735kHCP2G81L!g7@`pzd!Cc;fC2}L!_x_${_{^~ zjmo_)km_W@_doT=4;F*WvW%jGv)h#UJ6v)FzNp#;GI%bq_{t$V;Q{NxGA2*v)vH`G x@2ut2y{N@pwB+!Qn4UK(Ka4hWXYc&Yd+i|e6Bu diff --git a/src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_speed.png b/src/main/resources/assets/overdrive_that_matters/textures/item/upgrade_speed.png deleted file mode 100644 index 0a1af7fd93baeb6c179a4a0dccad0070070b3f0d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 257 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}H0G|-oz`(%z`uc)`0x>bM|NsA+nws)i2uUW$|GxoL!7#VK@;i{?Dhcun z2FgMJ!=^Jj=YgV}1s;*b3=DkxL735kHCP2G80P8X7@`qedOn)#fC7(8;92Lh|IF|B zm}GJ9{ruEXpu1KpERIp@s%YrE4bcT(*_%$Xx-)$^AvEg&r`i_9^Nee>W~>l@Fv*Z1 o-00ZzKc_SgM7^&~ID1C!>U!qq%h!F`0 Date: Tue, 14 Nov 2023 13:19:36 +0300 Subject: [PATCH 1106/1199] =?UTF-8?q?YuRaNnNzZZ=20=E2=80=94=20=D0=92=D1=87?= =?UTF-8?q?=D0=B5=D1=80=D0=B0,=20=D0=B2=2018:38=20=D0=BC=D0=BE=D0=B6=D0=BD?= =?UTF-8?q?=D0=BE=20=D0=B7=D0=B0=D1=80=D1=8F=D0=B4=D0=BD=D0=B8=D0=BA=20?= =?UTF-8?q?=D0=B5=D1=89=D1=91=20=D0=B8=20=D0=BD=D0=B0=20=D1=8D=D0=BA=D0=B7?= =?UTF-8?q?=D0=BE=D0=BF=D0=B0=D0=BA=20=D1=80=D0=B0=D1=81=D1=88=D0=B8=D1=80?= =?UTF-8?q?=D0=B8=D1=82=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt index 88f41a6f2..feb2972cd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt @@ -51,6 +51,13 @@ class AndroidChargerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Ma energyConfig.energy.extractEnergy(received, false) if (!available.isPositive) return } + + if (ply.hasExopack) { + val received = ply.exopackEnergy.receiveEnergyChecked(available, false) + available -= received + energyConfig.energy.extractEnergy(received, false) + if (!available.isPositive) return + } } } } From a618436ddd35ca2cbc343b0d4c48435bc7d55f53 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Tue, 14 Nov 2023 13:29:59 +0300 Subject: [PATCH 1107/1199] fix android charger not using battery from its own slot --- .../mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt index feb2972cd..83946a3ab 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/AndroidChargerBlockEntity.kt @@ -25,7 +25,8 @@ class AndroidChargerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Ma return AndroidChargerMenu(containerID, inventory, this) } - val energyConfig = ConfigurableEnergy(ProfiledEnergyStorage(WorkerEnergyStorage(this::markDirtyFast, MachinesConfig.ANDROID_CHARGER)), modesTop = FlowDirection.NONE) + override val energy = ProfiledEnergyStorage(WorkerEnergyStorage(this::markDirtyFast, MachinesConfig.ANDROID_CHARGER)) + val energyConfig = ConfigurableEnergy(energy, modesTop = FlowDirection.NONE) init { savetables.stateful(energyConfig::energy, ENERGY_KEY) From 993b1ac0fc159ff76e7f1d97b16ee80d422deabb Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Wed, 15 Nov 2023 02:13:30 +0300 Subject: [PATCH 1108/1199] extremely fast archaeology --- .../mc/otm/datagen/ResearchData.kt | 7 +- .../feature/LimbOverclockingFeature.kt | 32 ++++++++ src/main/resources/META-INF/coremods.json | 3 +- .../coremods/limb_brush_overclock.js | 76 +++++++++++++++++++ 4 files changed, 114 insertions(+), 4 deletions(-) create mode 100644 src/main/resources/coremods/limb_brush_overclock.js diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt index 6dfc9f6ef..c2e1a2448 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/ResearchData.kt @@ -163,7 +163,8 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang TranslatableComponent( "android_research.overdrive_that_matters.limb_overclocking.description", (i + 1) * 8, - (i + 1) * 6 + (i + 1) * 6, + (i + 1) * 20 ) ) .addItem(MItemTags.COPPER_WIRES, 4 + i * 2) @@ -426,8 +427,8 @@ fun addResearchData(serializer: Consumer, lang: MatteryLang russian("Разгон конечностей %s") } - add(limbList[0], "description", "Boosts mobility by %s%% and attack speed by %s%%") { - russian("Увеличивает мобильность на %s%% и скорость атак на %s%%") + add(limbList[0], "description", "Boosts mobility by %s%%, attack speed by %s%% and brushing speed by %s%%") { + russian("Увеличивает мобильность на %s%%, скорость атак на %s%% и скорость чистки блоков на %s%%") } add(AIR_BAGS, "Air Bags") { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/LimbOverclockingFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/LimbOverclockingFeature.kt index a8653abf3..8cc4a134a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/LimbOverclockingFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/LimbOverclockingFeature.kt @@ -1,9 +1,12 @@ package ru.dbotthepony.mc.otm.android.feature +import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.ai.attributes.AttributeModifier import net.minecraft.world.entity.ai.attributes.Attributes +import net.minecraft.world.entity.player.Player import ru.dbotthepony.mc.otm.android.AndroidFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability +import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.registry.AndroidFeatures import java.util.* @@ -31,5 +34,34 @@ class LimbOverclockingFeature(android: MatteryPlayerCapability) : AndroidFeature companion object { private val MODIFIER_ID = UUID.fromString("4a3fae46-e57b-4e20-857d-f5c2b2c8f2f2") + + @JvmStatic + fun getBrushCooldown(entity: LivingEntity): Int { + if (entity !is Player) return 10 + val matteryPlayer = entity.matteryPlayer ?: return 10 + if (!matteryPlayer.isAndroid || !matteryPlayer.hasFeature(AndroidFeatures.LIMB_OVERCLOCKING)) return 10 + + val level = matteryPlayer.getFeature(AndroidFeatures.LIMB_OVERCLOCKING)!!.level + 1 + return (10 - level * 2).coerceAtLeast(2) + } + + @JvmStatic + fun getBrushTick(entity: LivingEntity): Int { + if (entity !is Player) return 5 + val matteryPlayer = entity.matteryPlayer ?: return 5 + if (!matteryPlayer.isAndroid || !matteryPlayer.hasFeature(AndroidFeatures.LIMB_OVERCLOCKING)) return 5 + + val level = matteryPlayer.getFeature(AndroidFeatures.LIMB_OVERCLOCKING)!!.level + 1 + return (5 - level).coerceAtLeast(1) + } + + @JvmStatic + fun getBrushableBlockCooldown(player: Player): Long { + val matteryPlayer = player.matteryPlayer ?: return 10L + if (!matteryPlayer.isAndroid || !matteryPlayer.hasFeature(AndroidFeatures.LIMB_OVERCLOCKING)) return 10L + + val level = matteryPlayer.getFeature(AndroidFeatures.LIMB_OVERCLOCKING)!!.level + 1 + return (10L - level * 2L).coerceAtLeast(2L) + } } } diff --git a/src/main/resources/META-INF/coremods.json b/src/main/resources/META-INF/coremods.json index 5ce1ea71b..677dde2cf 100644 --- a/src/main/resources/META-INF/coremods.json +++ b/src/main/resources/META-INF/coremods.json @@ -1,4 +1,5 @@ { "code_injector": "coremods/code_injector.js", - "chest_menus": "coremods/chest_menus.js" + "chest_menus": "coremods/chest_menus.js", + "limb_brush_overclock": "coremods/limb_brush_overclock.js" } \ No newline at end of file diff --git a/src/main/resources/coremods/limb_brush_overclock.js b/src/main/resources/coremods/limb_brush_overclock.js new file mode 100644 index 000000000..344fa1a7d --- /dev/null +++ b/src/main/resources/coremods/limb_brush_overclock.js @@ -0,0 +1,76 @@ +var Opcodes = Java.type('org.objectweb.asm.Opcodes') +var VarInsnNode = Java.type('org.objectweb.asm.tree.VarInsnNode') +var MethodInsnNode = Java.type('org.objectweb.asm.tree.MethodInsnNode') + +function initializeCoreMod() { + return { + 'Patch brush item': { + 'target': { + "type":"METHOD", + "class":"net.minecraft.world.item.BrushItem", + "methodName":"m_5929_", + "methodDesc":"(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/item/ItemStack;I)V" + }, + 'transformer': function(node) { + for (i = 0; i < node.instructions.size(); i++) { + var insn = node.instructions.get(i) + + if (insn.getOpcode() == Opcodes.BIPUSH) { + node.instructions.insert(insn, new MethodInsnNode( + Opcodes.INVOKESTATIC, + 'ru/dbotthepony/mc/otm/android/feature/LimbOverclockingFeature', + 'getBrushCooldown', + '(Lnet/minecraft/world/entity/LivingEntity;)I' + )) + node.instructions.set(insn, new VarInsnNode(Opcodes.ALOAD, 2)) + + i += 1 + continue + } + + if (insn.getOpcode() == Opcodes.ICONST_5) { + node.instructions.insert(insn, new MethodInsnNode( + Opcodes.INVOKESTATIC, + 'ru/dbotthepony/mc/otm/android/feature/LimbOverclockingFeature', + 'getBrushTick', + '(Lnet/minecraft/world/entity/LivingEntity;)I' + )) + node.instructions.set(insn, new VarInsnNode(Opcodes.ALOAD, 2)) + + i += 1 + continue + } + } + + return node + } + }, + 'Patch brushable block': { + 'target': { + "type":"METHOD", + "class":"net.minecraft.world.level.block.entity.BrushableBlockEntity", + "methodName":"m_276923_", + "methodDesc":"(JLnet/minecraft/world/entity/player/Player;Lnet/minecraft/core/Direction;)Z" + }, + 'transformer': function(node) { + for (i = 0; i < node.instructions.size(); i++) { + var insn = node.instructions.get(i) + + if (insn.getOpcode() == Opcodes.LDC && insn.cst == 10) { + node.instructions.insert(insn, new MethodInsnNode( + Opcodes.INVOKESTATIC, + 'ru/dbotthepony/mc/otm/android/feature/LimbOverclockingFeature', + 'getBrushableBlockCooldown', + '(Lnet/minecraft/world/entity/player/Player;)J' + )) + node.instructions.set(insn, new VarInsnNode(Opcodes.ALOAD, 3)) + + break + } + } + + return node + } + }, + } +} \ No newline at end of file From 41fa744d4aa4d4ba4d07eb9f7b40972df0e83ec4 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Wed, 15 Nov 2023 02:25:15 +0300 Subject: [PATCH 1109/1199] universal wireless charger --- src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt | 3 ++- src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt | 3 ++- .../ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index e8e558903..ab1f5619f 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -411,7 +411,8 @@ private fun death(provider: MatteryLanguageProvider) { private fun blocks(provider: MatteryLanguageProvider) { with(provider.english) { add(MBlocks.ANDROID_STATION, "Android Station") - add(MBlocks.ANDROID_CHARGER, "Wireless Android Charger") + add(MBlocks.ANDROID_CHARGER, "Wireless Charger") + add(MBlocks.ANDROID_CHARGER, "desc", "Charges nearby androids and exopacks") add(MBlocks.BATTERY_BANK, "Battery Bank") add(MBlocks.MATTER_DECOMPOSER, "Matter Decomposer") add(MBlocks.MATTER_CAPACITOR_BANK, "Matter Capacitor Bank") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index f29ed4aaf..9fbc08869 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -413,7 +413,8 @@ private fun death(provider: MatteryLanguageProvider) { private fun blocks(provider: MatteryLanguageProvider) { with(provider.russian) { add(MBlocks.ANDROID_STATION, "Станция андроидов") - add(MBlocks.ANDROID_CHARGER, "Беспроводной зарядник андроидов") + add(MBlocks.ANDROID_CHARGER, "Беспроводной зарядник") + add(MBlocks.ANDROID_CHARGER, "desc", "Заряжает ближайших андроидов и экзопаки") add(MBlocks.BATTERY_BANK, "Банк аккумуляторов") add(MBlocks.MATTER_DECOMPOSER, "Декомпозитор материи") add(MBlocks.MATTER_CAPACITOR_BANK, "Банк накопителей материи") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt index 2ffc08985..5b3afa5ef 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.block.tech +import net.minecraft.ChatFormatting import net.minecraft.core.BlockPos import net.minecraft.network.chat.Component import net.minecraft.util.StringRepresentable @@ -29,6 +30,7 @@ import ru.dbotthepony.mc.otm.block.entity.tech.AndroidChargerMiddleBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.AndroidChargerTopBlockEntity import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage +import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.gracefulBlockBreak import ru.dbotthepony.mc.otm.core.math.plus @@ -139,6 +141,8 @@ class AndroidChargerBlock : RotatableMatteryBlock(Properties.of().destroyTime(2. override fun appendHoverText(p_49816_: ItemStack, p_49817_: BlockGetter?, p_49818_: MutableList, p_49819_: TooltipFlag) { super.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) + + p_49818_.add(TranslatableComponent("$descriptionId.desc").withStyle(ChatFormatting.GRAY)) WorkerEnergyStorage.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) MatteryPoweredBlockEntity.appendHoverText(p_49816_, p_49817_, p_49818_, p_49819_) } From f13f9481ea412d89b5c42966cb085b8876c6bbec Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Thu, 16 Nov 2023 13:10:16 +0300 Subject: [PATCH 1110/1199] smoother shield cooldown display --- src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index 16d14743d..8886d1969 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -362,7 +362,7 @@ object MatteryGUI { val ply = minecraft.player ?: return false if (!ply.isUsingItem || stack != ply.useItem || ply.isBlocking) return false - val percent = ((stack.item.getUseDuration(stack) - ply.useItemRemainingTicks) / 5f).coerceIn(0f, 1f) + val percent = ((stack.item.getUseDuration(stack) - ply.useItemRemainingTicks + minecraft.partialTick) / 5f).coerceIn(0f, 1f) RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f) drawArc(graphics, x + 8f, y + 8f, 8f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * percent, alignAtCenter = true) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) From 8dcf4843621db96190c501ac426682c91d962422 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Thu, 16 Nov 2023 13:28:15 +0300 Subject: [PATCH 1111/1199] smoother ability cooldown display (rubberbanding due to late sync) --- .../dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt index a17deba7c..eb4bbe251 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt @@ -1,8 +1,10 @@ package ru.dbotthepony.mc.otm.android import net.minecraft.client.gui.GuiGraphics +import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.nbt.CompoundTag import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability +import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.nbt.set @@ -31,6 +33,11 @@ abstract class AndroidSwitchableFeature(type: AndroidFeatureType<*>, android: Ma val cooldownPercent: Float get() { if (maxCooldown <= 0) return 0.0f + + if (ply.level() is ClientLevel) { + return ((cooldown.toFloat() - minecraft.partialTick) / maxCooldown.toFloat()).coerceIn(0.0f, 1.0f) + } + return (cooldown.toFloat() / maxCooldown.toFloat()).coerceIn(0.0f, 1.0f) } From 6d2176062154c321ba426d54377d53ebd25942fd Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Thu, 16 Nov 2023 16:36:41 +0300 Subject: [PATCH 1112/1199] essence storage mending repair (with automation) --- .../entity/tech/EssenceStorageBlockEntity.kt | 42 ++++++++++++++++--- .../screen/tech/EssenceStorageScreen.kt | 6 +++ .../mc/otm/menu/tech/EssenceStorageMenu.kt | 8 ++++ 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt index 5862e0000..a7f83fccd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt @@ -5,8 +5,10 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.enchantment.Enchantments import net.minecraft.world.level.block.state.BlockState import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity +import ru.dbotthepony.mc.otm.capability.CombinedItemHandler import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.item.EssenceCapsuleItem @@ -23,11 +25,13 @@ class EssenceStorageBlockEntity(blockPos: BlockPos, blockState: BlockState) : Ma val capsuleContainer = MatteryContainer(::markDirtyFast, 1) val servoContainer = MatteryContainer(::markDirtyFast, 1) + val mendingContainer = MatteryContainer(::markDirtyFast, 1).also(::addDroppableContainer) init { savetables.long(::experienceStored) savetables.stateful(::capsuleContainer) savetables.stateful(::servoContainer) + savetables.stateful(::mendingContainer) } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { @@ -35,11 +39,22 @@ class EssenceStorageBlockEntity(blockPos: BlockPos, blockState: BlockState) : Ma } val itemConfig = ConfigurableItemHandler( - input = capsuleContainer.handler(HandlerFilter.OnlyIn.and(object : HandlerFilter { - override fun canInsert(slot: Int, stack: ItemStack): Boolean { - return stack.item is EssenceCapsuleItem - } - })) + inputOutput = CombinedItemHandler( + capsuleContainer.handler(HandlerFilter.OnlyIn.and(object : HandlerFilter { + override fun canInsert(slot: Int, stack: ItemStack): Boolean { + return stack.item is EssenceCapsuleItem + } + })), + mendingContainer.handler(object : HandlerFilter { + override fun canInsert(slot: Int, stack: ItemStack): Boolean { + return stack.isDamaged && stack.getEnchantmentLevel(Enchantments.MENDING) > 0 + } + + override fun canExtract(slot: Int, amount: Int, stack: ItemStack): Boolean { + return !stack.isDamaged || experienceStored <= 0 + } + }) + ) ) override fun tick() { @@ -52,6 +67,23 @@ class EssenceStorageBlockEntity(blockPos: BlockPos, blockState: BlockState) : Ma experienceStored += EssenceCapsuleItem.experienceStored(capsule) capsuleContainer.clearContent() } + + val repairStack = mendingContainer[0] + + if (!repairStack.isEmpty && repairStack.isDamaged) { + if (experienceStored > 0) { + val dmgPerExp = repairStack.xpRepairRatio + var repairPoints = dmgPerExp.toInt() + + val diff = dmgPerExp - repairPoints.toFloat() + if (diff > 0f) { + repairPoints += if ((level?.random?.nextFloat() ?: 1f) <= diff) 1 else 0 + } + + experienceStored -= 1 + repairStack.damageValue -= repairPoints + } + } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt index 1fe7a1f46..9d8a4d725 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt @@ -5,6 +5,7 @@ import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.player.Inventory +import net.minecraft.world.item.enchantment.Enchantments import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.playGuiClickSound @@ -267,6 +268,11 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title set(value) {} } + SlotPanel(this, inputs, menu.mendingSlot).also { + it.dock = Dock.LEFT + it.tooltips.add(Enchantments.MENDING.getFullname(1).copy().withStyle(ChatFormatting.GRAY)) + } + makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, itemConfig = menu.itemConfig) return frame diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt index 128d4f6d7..e4acd946a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EssenceStorageMenu.kt @@ -4,6 +4,7 @@ import net.minecraft.server.level.ServerPlayer import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.enchantment.Enchantments import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.block.entity.tech.EssenceStorageBlockEntity import ru.dbotthepony.mc.otm.capability.matteryPlayer @@ -38,6 +39,12 @@ class EssenceStorageMenu @JvmOverloads constructor( } } + val mendingSlot = object : MatterySlot(tile?.mendingContainer ?: SimpleContainer(1), 0) { + override fun mayPlace(itemStack: ItemStack): Boolean { + return itemStack.isDamaged && itemStack.getEnchantmentLevel(Enchantments.MENDING) > 0 + } + } + val storeLevels = intInput { if (it > 0) { val ply = player as ServerPlayer @@ -99,6 +106,7 @@ class EssenceStorageMenu @JvmOverloads constructor( addStorageSlot(capsuleSlot) addStorageSlot(servoSlot) + addStorageSlot(mendingSlot) addInventorySlots() } } From b26f109f56aa1fbcc26f7607ee0e1050b6df7510 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 16 Nov 2023 21:02:19 +0700 Subject: [PATCH 1113/1199] Painter Recipes updates --- .../mc/otm/recipe/PainterRecipe.kt | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) 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 a93aa55e3..f8deb91d0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.recipe import com.mojang.serialization.Codec +import com.mojang.serialization.MapCodec import com.mojang.serialization.codecs.RecordCodecBuilder import it.unimi.dsi.fastutil.objects.Object2IntArrayMap import it.unimi.dsi.fastutil.objects.Object2IntMap @@ -31,7 +32,7 @@ import java.util.function.Predicate abstract class AbstractPainterRecipe( dyes: Map -) : Recipe { +) : IMatteryRecipe { val dyes: Object2IntMap = Object2IntMaps.unmodifiable(Object2IntArrayMap(dyes)) override fun getToastSymbol(): ItemStack = ItemStack(MItems.PAINTER) @@ -85,6 +86,17 @@ abstract class AbstractPainterRecipe( return refName } } + + companion object { + private val wrapperCodec: Codec = StringRepresentable.fromEnum(DyeColorWrapper::values) + + @JvmStatic + protected val dyesFieldCodec: MapCodec> = PredicatedCodecList>( + 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 } } }) + } } class PainterRecipe( @@ -142,22 +154,16 @@ class PainterRecipe( } override fun getOutput(container: Container): ItemStack { - return this.output + return output.copy() } companion object { - private val wrapperCodec = StringRepresentable.fromEnum(DyeColorWrapper::values) - val SERIALIZER = Codec2RecipeSerializer { context -> RecordCodecBuilder.create { it.group( context.ingredients.fieldOf("input").forGetter(PainterRecipe::input), ItemStack.CODEC.fieldOf("output").forGetter(PainterRecipe::output), - PredicatedCodecList>( - 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 } } }).forGetter(PainterRecipe::dyes), + dyesFieldCodec.forGetter(AbstractPainterRecipe::dyes), ).apply(it, ::PainterRecipe) } } @@ -212,7 +218,7 @@ class PainterArmorDyeRecipe( if (entry.key == null) { (output.item as DyeableLeatherItem).clearColor(output) } else { - output = DyeableLeatherItem.dyeArmor(output.copy(), listOf(DyeItem.byColor(entry.key!!))) + output = DyeableLeatherItem.dyeArmor(output, listOf(DyeItem.byColor(entry.key!!))) } } @@ -220,16 +226,10 @@ class PainterArmorDyeRecipe( } companion object { - private val wrapperCodec = StringRepresentable.fromEnum(DyeColorWrapper::values) - val SERIALIZER = Codec2RecipeSerializer { _ -> RecordCodecBuilder.create { it.group( - PredicatedCodecList>( - 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 } } }).forGetter(PainterArmorDyeRecipe::dyes), + dyesFieldCodec.forGetter(AbstractPainterRecipe::dyes), ).apply(it, ::PainterArmorDyeRecipe) } } From 280a8f343169f4d3336ead8d5ea1d4d0eceba670 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 16 Nov 2023 21:29:19 +0700 Subject: [PATCH 1114/1199] Merge painter recipe types --- .../mc/otm/compat/jei/JEIPlugin.kt | 8 +++++++- .../mc/otm/core/collect/StreamyIterators.kt | 2 ++ .../mc/otm/menu/decorative/PainterMenu.kt | 10 +++------- .../mc/otm/recipe/PainterRecipe.kt | 20 ++++++++++--------- .../dbotthepony/mc/otm/registry/MRecipes.kt | 3 +-- 5 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt index b4a834410..354c4346f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt @@ -20,11 +20,17 @@ import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.core.collect.filter +import ru.dbotthepony.mc.otm.core.collect.filterIsInstance +import ru.dbotthepony.mc.otm.core.collect.filterNotNull +import ru.dbotthepony.mc.otm.core.collect.map +import ru.dbotthepony.mc.otm.core.collect.toList import ru.dbotthepony.mc.otm.menu.decorative.PainterMenu import ru.dbotthepony.mc.otm.menu.matter.MatterEntanglerMenu import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu +import ru.dbotthepony.mc.otm.recipe.PainterRecipe import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRecipes import java.util.* @@ -91,7 +97,7 @@ class JEIPlugin : IModPlugin { val level = minecraft.level ?: throw NullPointerException("No ClientLevel. OLOLOLOLOLOLO") registration.addRecipes(PlatePressRecipeCategory.recipeType, level.recipeManager.getAllRecipesFor(MRecipes.PLATE_PRESS).filter { !it.value.isIncomplete }.map { it.value }) - registration.addRecipes(PainterRecipeCategory.recipeType, level.recipeManager.getAllRecipesFor(MRecipes.PAINTER).filter { !it.value.isIncomplete }.map { it.value }) + registration.addRecipes(PainterRecipeCategory.recipeType, level.recipeManager.getAllRecipesFor(MRecipes.PAINTER).iterator().filter { !it.value.isIncomplete }.map { it.value }.filterIsInstance().toList()) registration.addRecipes(MatterEntanglerRecipeCategory.recipeType, level.recipeManager.getAllRecipesFor(MRecipes.MATTER_ENTANGLER).filter { !it.value.isIncomplete }.map { it.value }) registration.addRecipes(MicrowaveRecipeCategory.recipeType, level.recipeManager.getAllRecipesFor(MRecipes.MICROWAVE).filter { !it.value.isIncomplete }.map { it.value }) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt index 572e0cb10..5d9d0e85c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt @@ -230,6 +230,8 @@ inline fun Iterator.reduce(identity: T, reducer: (T, T) -> T): T { fun Iterator.filterNotNull(): MutableIterator = filter { it != null } as MutableIterator +inline fun Iterator<*>.filterIsInstance(): MutableIterator = filter { it is T } as MutableIterator + fun Iterator.any(predicate: Predicate): Boolean { while (hasNext()) if (predicate.test(next())) 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 02ce925e5..6e4f94e7c 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 @@ -57,7 +57,7 @@ class PainterMenu( return super.mayPlace(itemStack) } - return super.mayPlace(itemStack) && inventory.player.level().recipeManager.byType(MRecipes.PAINTER).values.any { it.value.input.test(itemStack) } + return super.mayPlace(itemStack) && inventory.player.level().recipeManager.byType(MRecipes.PAINTER).values.any { it.value.matches(itemStack) } } } @@ -128,11 +128,7 @@ class PainterMenu( private fun rescan() { possibleRecipes.clear() - possibleRecipes.addAll(inventory.player.level().recipeManager.byType(MRecipes.PAINTER).values.iterator().filter { it.value.input.test(inputContainer[0]) }) - - if (!inputContainer[0].isEmpty && inputContainer[0].item is DyeableArmorItem) { - possibleRecipes.addAll(inventory.player.level().recipeManager.byType(MRecipes.PAINTER_ARMOR_DYE).values) - } + possibleRecipes.addAll(inventory.player.level().recipeManager.byType(MRecipes.PAINTER).values.iterator().filter { it.value.matches(inputContainer[0]) }) listeners.accept(Unit) if (tile !is PainterBlockEntity) return @@ -140,7 +136,7 @@ class PainterMenu( if (inputContainer.isEmpty || selectedRecipe == null) { outputContainer.clearContent() } else { - val recipe = inventory.player.level().recipeManager.byKey(selectedRecipe).get() as RecipeHolder? + val recipe = inventory.player.level().recipeManager.byKey(selectedRecipe!!).get() as RecipeHolder? if (recipe == null || !recipe.value.canCraft(dyeStoredDirect) || !recipe.value.matches(inputContainer, inventory.player.level())) { outputContainer.clearContent() 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 f8deb91d0..bc89e7f34 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt @@ -35,6 +35,12 @@ abstract class AbstractPainterRecipe( ) : IMatteryRecipe { val dyes: Object2IntMap = Object2IntMaps.unmodifiable(Object2IntArrayMap(dyes)) + abstract fun matches(value: ItemStack): Boolean + + override fun matches(contaier: Container, level: Level): Boolean { + return !isIncomplete && matches(contaier[0]) + } + override fun getToastSymbol(): ItemStack = ItemStack(MItems.PAINTER) fun canCraft(storedDyes: Map): Boolean { @@ -110,9 +116,8 @@ class PainterRecipe( dyes: Set ) : this(input, output, Object2IntArrayMap().also { map -> dyes.forEach { map[it] = 1 } }) - override fun matches(p_44002_: Container, p_44003_: Level): Boolean { - if (isIncomplete) return false - return input.test(p_44002_[0]) + override fun matches(value: ItemStack): Boolean { + return !isIncomplete && input.test(value) } override fun isIncomplete(): Boolean { @@ -176,11 +181,8 @@ class PainterArmorDyeRecipe( dyes: Set ) : this(Object2IntArrayMap().also { map -> dyes.forEach { map[it] = 1 } }) - override fun matches(contaier: Container, level: Level): Boolean { - if (this.isIncomplete) return false - val stack = contaier[0] - - return (!stack.isEmpty && stack.item is DyeableArmorItem) + override fun matches(value: ItemStack): Boolean { + return !isIncomplete && value.item is DyeableArmorItem } override fun assemble(container: Container, registry: RegistryAccess): ItemStack { @@ -201,7 +203,7 @@ class PainterArmorDyeRecipe( override fun getSerializer(): RecipeSerializer<*> = SERIALIZER - override fun getType(): RecipeType<*> = MRecipes.PAINTER_ARMOR_DYE + override fun getType(): RecipeType<*> = MRecipes.PAINTER override fun isIncomplete(): Boolean = dyes.isEmpty() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt index d3cc8c922..db9109e31 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRecipes.kt @@ -33,8 +33,7 @@ object MRecipes { } val PLATE_PRESS by register("plate_press") - val PAINTER by register("painter") - val PAINTER_ARMOR_DYE by register("painter_armor_dye") + val PAINTER by register("painter") val MATTER_ENTANGLER by register("matter_entangler") val MICROWAVE by register("microwave") From 940d8333de5d67cb26c7a04d478b646ec00163ac Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 16 Nov 2023 21:44:20 +0700 Subject: [PATCH 1115/1199] Handle vanilla-like trim cloning recipes --- .../mc/otm/matter/MatterManager.kt | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 097f8d008..39e139b7a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -731,7 +731,7 @@ object MatterManager { private fun doTryToBacktrack(item: Item, makeCommentary: Boolean): Result { val recipes = input2Recipes[item] - if (recipes == null || recipes.isEmpty() || !recipes.all { it.allowBacktrack } || !recipes.all { it.inputs.all { it.all { it.input.item == item } } }) { + if (recipes.isNullOrEmpty() || !recipes.all { it.allowBacktrack } || !recipes.all { it.inputs.all { it.all { it.input.item == item } } }) { if (makeCommentary) comment(item, TextComponent("Item '${item.registryName}' has no recipes")) @@ -859,14 +859,20 @@ object MatterManager { } } } else if (ivalue.isSkipped) { - comment(item, TextComponent("Input $entry at input slot $i in ${recipe.formattedName} is recursive")) - recursiveSkips.add(entry) - - if (inputs.size == 1) { - hadSkips = true - continue@recipesLoop - } else { + if (recipes.size == 1 && entry.input.item == recipe.output.item) { + // assume cloning and/or catalyst? + comment(item, TextComponent("Input $entry at input slot $i is assumed to be cloning/catalyst")) continue@innerInputsLoop + } else { + comment(item, TextComponent("Input $entry at input slot $i in ${recipe.formattedName} is recursive")) + recursiveSkips.add(entry) + + if (inputs.size == 1) { + hadSkips = true + continue@recipesLoop + } else { + continue@innerInputsLoop + } } } From 6737d52c10b51db0c2e1cc73ea6e818ee8ce3613 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 17 Nov 2023 10:18:41 +0700 Subject: [PATCH 1116/1199] Update previous commit --- .../kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 39e139b7a..8aa89b1a0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -862,7 +862,12 @@ object MatterManager { if (recipes.size == 1 && entry.input.item == recipe.output.item) { // assume cloning and/or catalyst? comment(item, TextComponent("Input $entry at input slot $i is assumed to be cloning/catalyst")) - continue@innerInputsLoop + + if (inputs.size == 1) { + continue@inputsLoop + } else { + continue@innerInputsLoop + } } else { comment(item, TextComponent("Input $entry at input slot $i in ${recipe.formattedName} is recursive")) recursiveSkips.add(entry) From db6b5e7efc11c10882c7b2a2233fb2b100f26c70 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 17 Nov 2023 12:29:32 +0700 Subject: [PATCH 1117/1199] Get rid of savetable() --- .../mc/otm/block/entity/MatteryBlockEntity.kt | 4 ---- .../block/entity/matter/MatterBottlerBlockEntity.kt | 10 +++++----- .../otm/block/entity/storage/DriveRackBlockEntity.kt | 4 ++-- .../otm/block/entity/storage/DriveViewerBlockEntity.kt | 4 ++-- .../otm/block/entity/storage/ItemMonitorBlockEntity.kt | 2 +- .../otm/block/entity/storage/StorageBusBlockEntity.kt | 4 ++-- .../mc/otm/block/entity/storage/StorageInterfaces.kt | 4 ++-- .../entity/storage/StoragePowerSupplierBlockEntity.kt | 2 +- .../block/entity/tech/ChemicalGeneratorBlockEntity.kt | 8 ++++---- .../mc/otm/block/entity/tech/CobblerBlockEntity.kt | 2 +- .../mc/otm/block/entity/tech/PlatePressBlockEntity.kt | 6 +++--- 11 files changed, 23 insertions(+), 27 deletions(-) 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 9005db565..cd9d6707b 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 @@ -394,10 +394,6 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc side.revive() } - protected inline fun > savetable(property: KProperty0, name: String = property.name) { - savetables.stateful(property, name, T::class.java) - } - final override fun saveAdditional(nbt: CompoundTag) { super.saveAdditional(nbt) saveShared(nbt) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index f01765e4a..a929d2892 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -114,11 +114,11 @@ class MatterBottlerBlockEntity(blockPos: BlockPos, blockState: BlockState) : savetables.bool(::isBottling) savetables.bool(::spitItemsWhenCantWork) - savetable(::energy, ENERGY_KEY) - savetable(::matter, MATTER_STORAGE_KEY) - savetable(::bottling) - savetable(::unbottling) - savetable(::upgrades) + savetables.stateful(::energy, ENERGY_KEY) + savetables.stateful(::matter, MATTER_STORAGE_KEY) + savetables.stateful(::bottling) + savetables.stateful(::unbottling) + savetables.stateful(::upgrades) } var workProgress: Float = 0f diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt index 90ce6f6d1..ca660924f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveRackBlockEntity.kt @@ -60,8 +60,8 @@ class DriveRackBlockEntity(blockPos: BlockPos, blockState: BlockState) : Mattery }.also(::addDroppableContainer) init { - savetable(::energy, ENERGY_KEY) - savetable(::container, INVENTORY_KEY) + savetables.stateful(::energy, ENERGY_KEY) + savetables.stateful(::container, INVENTORY_KEY) exposeGlobally(MatteryCapability.STORAGE_NODE, cell) savetables.int(::insertPriority) savetables.int(::extractPriority) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt index 87da29344..d6dee99b5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/DriveViewerBlockEntity.kt @@ -90,8 +90,8 @@ class DriveViewerBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte } init { - savetable(::energy, ENERGY_KEY) - savetable(::container, INVENTORY_KEY) + savetables.stateful(::energy, ENERGY_KEY) + savetables.stateful(::container, INVENTORY_KEY) } override fun createMenu(containerID: Int, inventory: Inventory, ply: Player): AbstractContainerMenu { 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 2a63e5a86..970a12ba2 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 @@ -178,7 +178,7 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte val energyConfig = ConfigurableEnergy(energy) init { - savetable(::energy, ENERGY_KEY) + savetables.stateful(::energy, ENERGY_KEY) } var poweredView: PoweredVirtualComponent? = null diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt index d15bcee90..b3a21ef86 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt @@ -96,7 +96,7 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter } init { - savetable(::energy, ENERGY_KEY) + savetables.stateful(::energy, ENERGY_KEY) savetables.int(::insertPriority) savetables.int(::extractPriority) exposeGlobally(MatteryCapability.STORAGE_NODE, cell) { it != RelativeSide.FRONT } @@ -127,7 +127,7 @@ class StorageBusBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matter } init { - savetable(::filter, FILTER_KEY) + savetables.stateful(::filter, FILTER_KEY) } override fun setLevel(level: Level) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt index 39907eb94..e03e29597 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageInterfaces.kt @@ -83,7 +83,7 @@ abstract class AbstractStorageImportExport( } init { - savetable(::energy, ENERGY_KEY) + savetables.stateful(::energy, ENERGY_KEY) exposeGlobally(MatteryCapability.STORAGE_NODE, cell) { it != RelativeSide.FRONT } } @@ -102,7 +102,7 @@ abstract class AbstractStorageImportExport( abstract val filter: ItemFilter init { - savetable(::filter, FILTER_KEY) + savetables.stateful(::filter, FILTER_KEY) } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt index a2a7214ef..b10d647ae 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StoragePowerSupplierBlockEntity.kt @@ -25,7 +25,7 @@ class StoragePowerSupplierBlockEntity(blockPos: BlockPos, blockState: BlockState override val energy = WorkerEnergyStorage(this::markDirtyFast, MachinesConfig.STORAGE_POWER_SUPPLIER) init { - savetable(::energy, ENERGY_KEY) + savetables.stateful(::energy, ENERGY_KEY) exposeEnergyGlobally(energy) exposeGlobally(MatteryCapability.STORAGE_NODE, cell) 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 0ef5e8939..38597c699 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 @@ -46,10 +46,10 @@ class ChemicalGeneratorBlockEntity(pos: BlockPos, state: BlockState) : MatteryDe for (piece in energyConfig.pieces.values) piece.automatePush = true - savetable(::energy, ENERGY_KEY) - savetable(::batteryContainer) - savetable(::residueContainer) - savetable(::fuelContainer) + savetables.stateful(::energy, ENERGY_KEY) + savetables.stateful(::batteryContainer) + savetables.stateful(::residueContainer) + savetables.stateful(::fuelContainer) savetables.int(::workTicks) savetables.int(::workTicksTotal) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt index 92fc99454..23adfcb8e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/CobblerBlockEntity.kt @@ -26,7 +26,7 @@ class CobblerBlockEntity(blockPos: BlockPos, blockState: BlockState) val itemConfig = ConfigurableItemHandler(output = container.handler(HandlerFilter.OnlyOut)) init { - savetable(::container, INVENTORY_KEY) + savetables.stateful(::container, INVENTORY_KEY) } override fun onJobFinish(status: JobStatus, id: Int) { 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 a570ee003..081471a0b 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 @@ -79,9 +79,9 @@ class PlatePressBlockEntity( ) init { - savetable(::energy, ENERGY_KEY) - savetable(::inputContainer) - savetable(::outputContainer) + savetables.stateful(::energy, ENERGY_KEY) + savetables.stateful(::inputContainer) + savetables.stateful(::outputContainer) savetables.double(::experience) savetables.stateful(::upgrades) } From 6fb6687cd09a2fbbbb6574ae90fd5789c0af80b9 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 17 Nov 2023 13:19:17 +0700 Subject: [PATCH 1118/1199] Update block entity synchronization to match 1.20.2 chunk queue changes --- .../dbotthepony/mc/otm/GlobalEventHandler.kt | 13 ++++++++++ .../mc/otm/block/entity/MatteryBlockEntity.kt | 26 +++++++++++++------ .../dbotthepony/mc/otm/core/util/TickList.kt | 13 ++++++++++ 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt index 8f63cf0ec..7e8d4de0f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt @@ -67,6 +67,19 @@ fun onceServer(inTicks: Int, callback: Runnable): TickList.Timer? { return postServerTick.Timer(inTicks, callback) } +/** + * schedules execution of Runnable somewhere in the future, + * at discretion of tick list + */ +fun sometimeServer(callback: Runnable): TickList.Timer? { + if (!SERVER_IS_LIVE) { + LOGGER.error("Refusing to add ticker $callback while server is dying", IllegalStateException("Server is stopping")) + return null + } + + return postServerTick.sometime(callback) +} + private val isPausedImpl: Boolean get() { val server = _server 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 cd9d6707b..c63c5b0cf 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 @@ -56,6 +56,7 @@ import ru.dbotthepony.mc.otm.network.GenericNetworkChannel import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer import ru.dbotthepony.mc.otm.once import ru.dbotthepony.mc.otm.onceServer +import ru.dbotthepony.mc.otm.sometimeServer import java.lang.ref.WeakReference import java.util.* import java.util.function.Consumer @@ -612,23 +613,32 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc return blockEntities.any { it.synchronizer.hasObservers } } - fun subscribe(player: ServerPlayer) { - if (players.add(player)) { - veto.add(player) + private fun recheckPlayer(player: ServerPlayer) { + sometimeServer { + if (player in players && !player.hasDisconnected()) { + if (player.connection.chunkSender.isPending(chunkPos)) { + recheckPlayer(player) + } else { + veto.remove(player) - onceServer(10) { - veto.remove(player) - blockEntities.forEach { it.playerListUpdated = true } - - if (!player.hasDisconnected() && player in players) { blockEntities.forEach { + it.playerListUpdated = true it.synchronizeToPlayers(false) } } + } else if (player in players && player.hasDisconnected()) { + unsubscribe(player) } } } + fun subscribe(player: ServerPlayer) { + if (players.add(player)) { + veto.add(player) + recheckPlayer(player) + } + } + fun unsubscribe(player: ServerPlayer): Boolean { if (players.remove(player)) { veto.remove(player) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt index 62cfb08f1..a02a49ca8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt @@ -24,6 +24,7 @@ class TickList : ITickable { private set var ticks = 0 private set + private var nextSometime = 0 inner class Timer(val timerTicks: Int, val runnable: Runnable) : Comparable { val ringAt = ticks + timerTicks @@ -147,6 +148,18 @@ class TickList : ITickable { return Timer(timerTicks, action) } + /** + * Schedules execution of Runnable somewhere in the future, + * at discretion of this tick list + */ + fun sometime(action: Runnable): Timer { + if (nextSometime < ticks || nextSometime - ticks >= 40) { + nextSometime = ticks + } + + return Timer((++nextSometime) - ticks, action) + } + override fun tick() { if (inTicker) { throw ConcurrentModificationException("Already ticking") From 19bb6600dd705562230516582f903ce4ef00e55b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 22 Dec 2023 14:27:41 +0700 Subject: [PATCH 1119/1199] Bump KFF and Forge --- gradle.properties | 4 ++-- src/main/resources/META-INF/mods.toml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index dc2d2cd2d..09768289d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,7 +15,7 @@ jei_mc_version=1.20.2 curios_mc_version=1.20.2 forge_gradle_version=[6.0.14,6.2) -forge_version=48.0.33 +forge_version=48.1.0 mixingradle_version=0.7.33 mixin_version=0.8.5 @@ -30,7 +30,7 @@ resourceful_config_id=4576455 jade_id=4818518 configured_id=4462894 -kotlin_for_forge_version=4.4.0 +kotlin_for_forge_version=4.7.0 kotlin_version=1.9.0 handle_deps=true diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 018965bee..877a59311 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -41,7 +41,7 @@ Matter. Energy. Combined. # Does this dependency have to exist - if not, ordering below must be specified mandatory=true #mandatory # The version range of the dependency - versionRange="[47.1.0,)" #mandatory + versionRange="[48.0.0,)" #mandatory # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory ordering="NONE" # Side this dependency is applied on - BOTH, CLIENT or SERVER @@ -51,6 +51,6 @@ Matter. Energy. Combined. modId="minecraft" mandatory=true # This version range declares a minimum of the current minecraft version up to but not including the next major version - versionRange="[1.20.1,1.21)" + versionRange="[1.20.2,1.21)" ordering="NONE" side="BOTH" From 29cb78bbd5671dea4d37731386350df14ff44cb7 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 22 Dec 2023 14:42:58 +0700 Subject: [PATCH 1120/1199] Remove frame title from exopack inventory screen --- .../dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt | 2 +- .../ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt index ca3de74ea..a51f8b21b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt @@ -54,7 +54,7 @@ class ExopackInventoryScreen(menu: ExopackInventoryMenu) : MatteryScreen> { - val frame = FramePanel(this, width = 200f, height = FRAME_BASE_HEIGHT + inventoryRows * AbstractSlotPanel.SIZE, title = this.title) + val frame = FramePanel(this, width = 200f, height = FRAME_BASE_HEIGHT + inventoryRows * AbstractSlotPanel.SIZE) frame.makeCloseButton() frame.onClose { onClose() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index 79ae5fc49..7f74a2bd6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -25,7 +25,7 @@ open class FramePanel( var title: Component? = null, var titleColor: RGBAColor = RGBAColor.HEADING_TEXT ) : EditablePanel(screen, parent, x, y, width, height), NarratableEntry { - constructor(screen: S, width: Float, height: Float, title: Component?) : this(screen, null, 0f, 0f, width, height, title) + constructor(screen: S, width: Float, height: Float, title: Component? = null) : this(screen, null, 0f, 0f, width, height, title) open inner class Tab( var onOpen: Runnable? = null, From 9eeb4c21908f70393cc72d765e857346924b2983 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 22 Dec 2023 14:51:05 +0700 Subject: [PATCH 1121/1199] Use global constant instead of handwritten number --- .../ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt index 9e6c05910..3df88999a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt @@ -14,6 +14,7 @@ import net.minecraft.world.item.context.BlockPlaceContext import net.minecraft.world.item.context.UseOnContext import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block +import net.minecraft.world.level.block.LevelEvent import net.minecraft.world.level.block.entity.BarrelBlockEntity import net.minecraft.world.level.block.entity.ChestBlockEntity import net.minecraft.world.level.gameevent.GameEvent @@ -23,6 +24,7 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent import ru.dbotthepony.mc.otm.OverdriveThatMatters.MOD_ID import ru.dbotthepony.mc.otm.block.decorative.CargoCrateBlock import ru.dbotthepony.mc.otm.block.entity.decorative.CargoCrateBlockEntity +import ru.dbotthepony.mc.otm.container.get import ru.dbotthepony.mc.otm.container.set import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.Vector @@ -56,13 +58,14 @@ class ChestUpgraderItem : Item(Properties().stacksTo(1)) { if (!newState.canSurvive(context.level, pos)) return InteractionResult.FAIL context.level.gameEvent(GameEvent.BLOCK_DESTROY, pos, GameEvent.Context.of(player, blockState)) - context.level.levelEvent(player, 2001, pos, Block.getId(blockState)) + context.level.levelEvent(player, LevelEvent.PARTICLES_DESTROY_BLOCK, pos, Block.getId(blockState)) if (context.level is ServerLevel) { val contents = Int2ObjectArrayMap(container.containerSize) - for (i in 0 until container.containerSize) { - contents.put(i, container.getItem(i)) - } + + for (i in 0 until container.containerSize) + contents.put(i, container[i]) + container.clearContent() val level = context.level as ServerLevel From 8fece2a51720c4ed1d6636ec51ae9e33391e855f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 22 Dec 2023 14:53:25 +0700 Subject: [PATCH 1122/1199] Move capabilities impls to subpackages --- .../mc/otm/block/entity/MatteryDeviceBlockEntity.kt | 6 +++--- .../mc/otm/block/entity/decorative/FluidTankBlockEntity.kt | 2 +- .../mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt | 2 +- .../otm/block/entity/matter/MatterReplicatorBlockEntity.kt | 2 +- .../mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt | 2 +- .../mc/otm/block/entity/tech/PoweredFurnaceBlockEntity.kt | 2 +- src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt | 2 ++ .../mc/otm/capability/{ => fluid}/FluidHandlerIterator.kt | 2 +- .../otm/capability/{ => fluid}/FluidHandlerSpliterator.kt | 2 +- .../mc/otm/capability/{ => item}/CombinedItemHandler.kt | 2 +- .../mc/otm/capability/{ => item}/EmptyItemHandler.kt | 2 +- .../mc/otm/capability/{ => item}/ProxiedItemHandler.kt | 2 +- .../otm/capability/{ => item}/UnmodifiableItemHandler.kt | 2 +- .../dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt | 1 - .../ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt | 1 - .../ru/dbotthepony/mc/otm/container/HandlerFilter.kt | 2 +- .../kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt | 3 +-- .../ru/dbotthepony/mc/otm/recipe/EnergyContainerRecipe.kt | 5 ----- .../ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt | 1 - .../mc/otm/triggers/MatteryInventoryChangeTrigger.kt | 7 ------- 20 files changed, 18 insertions(+), 32 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/capability/{ => fluid}/FluidHandlerIterator.kt (94%) rename src/main/kotlin/ru/dbotthepony/mc/otm/capability/{ => fluid}/FluidHandlerSpliterator.kt (96%) rename src/main/kotlin/ru/dbotthepony/mc/otm/capability/{ => item}/CombinedItemHandler.kt (98%) rename src/main/kotlin/ru/dbotthepony/mc/otm/capability/{ => item}/EmptyItemHandler.kt (93%) rename src/main/kotlin/ru/dbotthepony/mc/otm/capability/{ => item}/ProxiedItemHandler.kt (94%) rename src/main/kotlin/ru/dbotthepony/mc/otm/capability/{ => item}/UnmodifiableItemHandler.kt (89%) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index d728a45ce..744da7694 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -16,10 +16,10 @@ import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.fluids.FluidStack import net.minecraftforge.fluids.capability.IFluidHandler import net.minecraftforge.items.IItemHandler -import ru.dbotthepony.mc.otm.capability.CombinedItemHandler -import ru.dbotthepony.mc.otm.capability.EmptyItemHandler +import ru.dbotthepony.mc.otm.capability.item.CombinedItemHandler +import ru.dbotthepony.mc.otm.capability.item.EmptyItemHandler import ru.dbotthepony.mc.otm.capability.FlowDirection -import ru.dbotthepony.mc.otm.capability.UnmodifiableItemHandler +import ru.dbotthepony.mc.otm.capability.item.UnmodifiableItemHandler import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage import ru.dbotthepony.mc.otm.capability.moveBetweenSlots import ru.dbotthepony.mc.otm.capability.moveEnergy 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 7eadaf2e3..c3e321746 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 @@ -13,7 +13,7 @@ import net.minecraftforge.fluids.FluidStack import net.minecraftforge.fluids.capability.IFluidHandler import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity -import ru.dbotthepony.mc.otm.capability.CombinedItemHandler +import ru.dbotthepony.mc.otm.capability.item.CombinedItemHandler import ru.dbotthepony.mc.otm.capability.fluid.BlockMatteryFluidHandler import ru.dbotthepony.mc.otm.capability.moveFluid import ru.dbotthepony.mc.otm.config.ItemsConfig diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt index a929d2892..412486113 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterBottlerBlockEntity.kt @@ -14,7 +14,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryPoweredBlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.capability.ProxiedItemHandler +import ru.dbotthepony.mc.otm.capability.item.ProxiedItemHandler import ru.dbotthepony.mc.otm.capability.UpgradeType import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt index 76688494d..e95210e30 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterReplicatorBlockEntity.kt @@ -14,7 +14,7 @@ import ru.dbotthepony.mc.otm.block.entity.JobStatus import ru.dbotthepony.mc.otm.block.entity.ItemJob import ru.dbotthepony.mc.otm.block.entity.MachineJobEventLoop import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity -import ru.dbotthepony.mc.otm.capability.CombinedItemHandler +import ru.dbotthepony.mc.otm.capability.item.CombinedItemHandler import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.UpgradeType diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt index a7f83fccd..a591f74d8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt @@ -8,7 +8,7 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.enchantment.Enchantments import net.minecraft.world.level.block.state.BlockState import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity -import ru.dbotthepony.mc.otm.capability.CombinedItemHandler +import ru.dbotthepony.mc.otm.capability.item.CombinedItemHandler import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.item.EssenceCapsuleItem 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 c8a7c9716..2226d0829 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 @@ -16,7 +16,7 @@ import ru.dbotthepony.mc.otm.block.entity.JobContainer import ru.dbotthepony.mc.otm.block.entity.JobStatus import ru.dbotthepony.mc.otm.block.entity.ItemJob import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity -import ru.dbotthepony.mc.otm.capability.CombinedItemHandler +import ru.dbotthepony.mc.otm.capability.item.CombinedItemHandler import ru.dbotthepony.mc.otm.capability.UpgradeType import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt index 362f454cc..f7e7c73a4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt @@ -13,6 +13,8 @@ import net.minecraftforge.fluids.capability.IFluidHandler import net.minecraftforge.items.IItemHandler import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage +import ru.dbotthepony.mc.otm.capability.fluid.iterator +import ru.dbotthepony.mc.otm.capability.fluid.stream import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.compat.cos.cosmeticArmorAwareStream import ru.dbotthepony.mc.otm.compat.cos.cosmeticArmorStream diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FluidHandlerIterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/FluidHandlerIterator.kt similarity index 94% rename from src/main/kotlin/ru/dbotthepony/mc/otm/capability/FluidHandlerIterator.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/FluidHandlerIterator.kt index 77984c858..6e81f7cfb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FluidHandlerIterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/FluidHandlerIterator.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.capability +package ru.dbotthepony.mc.otm.capability.fluid import it.unimi.dsi.fastutil.objects.ObjectIterators.AbstractIndexBasedIterator import net.minecraftforge.fluids.FluidStack diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FluidHandlerSpliterator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/FluidHandlerSpliterator.kt similarity index 96% rename from src/main/kotlin/ru/dbotthepony/mc/otm/capability/FluidHandlerSpliterator.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/FluidHandlerSpliterator.kt index 1cf554f60..4d7f874d8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/FluidHandlerSpliterator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/fluid/FluidHandlerSpliterator.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.capability +package ru.dbotthepony.mc.otm.capability.fluid import it.unimi.dsi.fastutil.objects.ObjectSpliterator import it.unimi.dsi.fastutil.objects.ObjectSpliterators.AbstractIndexBasedSpliterator diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/CombinedItemHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/item/CombinedItemHandler.kt similarity index 98% rename from src/main/kotlin/ru/dbotthepony/mc/otm/capability/CombinedItemHandler.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/capability/item/CombinedItemHandler.kt index 450e614cd..518d43e3e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/CombinedItemHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/item/CombinedItemHandler.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.capability +package ru.dbotthepony.mc.otm.capability.item import com.google.common.collect.ImmutableList import net.minecraft.world.item.ItemStack diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/EmptyItemHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/item/EmptyItemHandler.kt similarity index 93% rename from src/main/kotlin/ru/dbotthepony/mc/otm/capability/EmptyItemHandler.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/capability/item/EmptyItemHandler.kt index 0cf000529..5fb9e1ff3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/EmptyItemHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/item/EmptyItemHandler.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.capability +package ru.dbotthepony.mc.otm.capability.item import net.minecraft.world.item.ItemStack import net.minecraftforge.items.IItemHandler diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/ProxiedItemHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/item/ProxiedItemHandler.kt similarity index 94% rename from src/main/kotlin/ru/dbotthepony/mc/otm/capability/ProxiedItemHandler.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/capability/item/ProxiedItemHandler.kt index 82393a0a9..81533ebd0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/ProxiedItemHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/item/ProxiedItemHandler.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.capability +package ru.dbotthepony.mc.otm.capability.item import net.minecraft.world.item.ItemStack import net.minecraftforge.items.IItemHandler diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/UnmodifiableItemHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/item/UnmodifiableItemHandler.kt similarity index 89% rename from src/main/kotlin/ru/dbotthepony/mc/otm/capability/UnmodifiableItemHandler.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/capability/item/UnmodifiableItemHandler.kt index 3546158a6..7895a417b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/UnmodifiableItemHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/item/UnmodifiableItemHandler.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.capability +package ru.dbotthepony.mc.otm.capability.item import net.minecraft.world.item.ItemStack import net.minecraftforge.items.IItemHandler diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt index 845392761..8a3c76fa4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt @@ -24,7 +24,6 @@ import ru.dbotthepony.mc.otm.client.screen.panels.button.RectangleButtonPanel import ru.dbotthepony.mc.otm.compat.cos.CosmeticToggleButton.Companion.BUTTON_ACTIVE import ru.dbotthepony.mc.otm.compat.cos.CosmeticToggleButton.Companion.BUTTON_INACTIVE import ru.dbotthepony.mc.otm.container.util.awareStream -import ru.dbotthepony.mc.otm.capability.iterator import ru.dbotthepony.mc.otm.container.util.iterator import ru.dbotthepony.mc.otm.core.collect.AwareItemStack import ru.dbotthepony.mc.otm.core.collect.emptyIterator diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt index ef035a966..82164c0f2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt @@ -10,7 +10,6 @@ import net.minecraftforge.network.PacketDistributor import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.container.util.awareStream -import ru.dbotthepony.mc.otm.capability.iterator import ru.dbotthepony.mc.otm.container.util.iterator import ru.dbotthepony.mc.otm.core.collect.AwareItemStack import ru.dbotthepony.mc.otm.core.collect.concatIterators diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt index 1d2ca7c8e..12647683a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/HandlerFilter.kt @@ -4,7 +4,7 @@ import net.minecraft.world.item.ItemStack import net.minecraftforge.common.ForgeHooks import net.minecraftforge.common.capabilities.ForgeCapabilities import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.capability.stream +import ru.dbotthepony.mc.otm.capability.fluid.stream import ru.dbotthepony.mc.otm.core.isNotEmpty interface HandlerFilter { 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 7875dbb13..782884378 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt @@ -34,10 +34,9 @@ import net.minecraftforge.fluids.FluidUtil import net.minecraftforge.fluids.capability.IFluidHandler import ru.dbotthepony.mc.otm.capability.fluid.ItemMatteryFluidHandler import ru.dbotthepony.mc.otm.capability.fluidLevel -import ru.dbotthepony.mc.otm.capability.iterator +import ru.dbotthepony.mc.otm.capability.fluid.iterator import ru.dbotthepony.mc.otm.capability.moveFluid import ru.dbotthepony.mc.otm.container.get -import ru.dbotthepony.mc.otm.container.util.stream import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.collect.any import ru.dbotthepony.mc.otm.core.ifPresentK 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 5884c0dc7..9f3667807 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/EnergyContainerRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/EnergyContainerRecipe.kt @@ -1,11 +1,9 @@ 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 @@ -17,12 +15,9 @@ import net.minecraft.world.item.crafting.ShapedRecipe import net.minecraft.world.level.Level import net.minecraftforge.common.crafting.IShapedRecipe import ru.dbotthepony.mc.otm.capability.matteryEnergy -import ru.dbotthepony.mc.otm.capability.iterator import ru.dbotthepony.mc.otm.container.util.iterator import ru.dbotthepony.mc.otm.container.util.stream import ru.dbotthepony.mc.otm.core.filterNotNull -import ru.dbotthepony.mc.otm.core.fromJson -import ru.dbotthepony.mc.otm.core.fromJsonStrict class EnergyContainerRecipe(val parent: ShapedRecipe) : CraftingRecipe, IShapedRecipe by parent { override fun canCraftInDimensions(p_43999_: Int, p_44000_: Int): Boolean { 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 6a3dbe4ee..b9daa6882 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt @@ -15,7 +15,6 @@ import net.minecraft.world.item.crafting.RecipeType import net.minecraft.world.level.Level import ru.dbotthepony.mc.otm.capability.matter.matter import ru.dbotthepony.mc.otm.capability.matteryEnergy -import ru.dbotthepony.mc.otm.capability.iterator import ru.dbotthepony.mc.otm.container.util.iterator import ru.dbotthepony.mc.otm.core.collect.filterNotNull import ru.dbotthepony.mc.otm.core.collect.map diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MatteryInventoryChangeTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MatteryInventoryChangeTrigger.kt index 5cf93fd64..c3064c2fa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MatteryInventoryChangeTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MatteryInventoryChangeTrigger.kt @@ -14,25 +14,18 @@ import net.minecraft.advancements.CriterionTrigger import net.minecraft.advancements.critereon.DeserializationContext import net.minecraft.advancements.critereon.InventoryChangeTrigger import net.minecraft.advancements.critereon.MinMaxBounds -import net.minecraft.resources.ResourceLocation import net.minecraft.server.PlayerAdvancements import net.minecraft.server.level.ServerPlayer -import net.minecraft.tags.TagKey import net.minecraft.world.Container import net.minecraft.world.entity.player.Inventory -import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.capability.matteryPlayer -import ru.dbotthepony.mc.otm.container.CombinedContainer import ru.dbotthepony.mc.otm.container.get -import ru.dbotthepony.mc.otm.capability.iterator import ru.dbotthepony.mc.otm.container.util.iterator import ru.dbotthepony.mc.otm.core.collect.flatMap import ru.dbotthepony.mc.otm.core.collect.toList import ru.dbotthepony.mc.otm.core.isNotEmpty -import java.util.Optional import java.util.stream.Collectors -import kotlin.jvm.optionals.getOrNull /** * This object detours all necessary InventoryChangeTrigger methods From 1e2c505fbdb420d87b24bdf20b05b7ae7cd3fc32 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 22 Dec 2023 20:08:12 +0700 Subject: [PATCH 1123/1199] Unify experience storage in machines, Liquid XP --- .../datagen/recipes/MatterEntanglerRecipes.kt | 6 +- .../dbotthepony/mc/otm/block/MatteryBlock.kt | 19 ++- .../mc/otm/block/entity/ExperienceStorage.kt | 154 ++++++++++++++++++ .../mc/otm/block/entity/MatteryBlockEntity.kt | 18 +- .../matter/MatterEntanglerBlockEntity.kt | 14 +- .../entity/tech/EssenceStorageBlockEntity.kt | 62 ++++++- .../entity/tech/PlatePressBlockEntity.kt | 47 +----- .../entity/tech/PoweredFurnaceBlockEntity.kt | 43 +---- .../mc/otm/block/tech/PlatePressBlock.kt | 20 --- .../mc/otm/block/tech/PoweredFurnaceBlock.kt | 20 --- .../mc/otm/config/AbstractConfig.kt | 2 + .../mc/otm/config/BalanceValues.kt | 1 + .../mc/otm/config/MachinesConfig.kt | 13 +- .../mc/otm/menu/matter/MatterEntanglerMenu.kt | 2 +- .../mc/otm/menu/tech/PlatePressMenu.kt | 4 +- .../mc/otm/menu/tech/PoweredFurnaceMenu.kt | 2 +- .../mc/otm/menu/tech/TwinPlatePressMenu.kt | 4 +- .../mc/otm/recipe/MatterEntanglerRecipe.kt | 3 + .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 42 +++-- .../ru/dbotthepony/mc/otm/registry/MFluids.kt | 66 ++++++++ .../ru/dbotthepony/mc/otm/registry/MItems.kt | 1 + .../dbotthepony/mc/otm/registry/MRegistry.kt | 1 + 22 files changed, 388 insertions(+), 156 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ExperienceStorage.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/registry/MFluids.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatterEntanglerRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatterEntanglerRecipes.kt index 9dbf0ec82..19378ec84 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatterEntanglerRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatterEntanglerRecipes.kt @@ -21,7 +21,8 @@ fun addMatterEntanglerRecipes(consumer: RecipeOutput) { ), Decimal(40), 400.0, - ItemStack(MItems.QUANTUM_CAPACITOR, 2) + ItemStack(MItems.QUANTUM_CAPACITOR, 2), + experience = 15f ).energetic().toFinished(modLocation("quantum_capacitor")) ) @@ -34,7 +35,8 @@ fun addMatterEntanglerRecipes(consumer: RecipeOutput) { ), Decimal(120), 600.0, - ItemStack(MItems.QUANTUM_BATTERY, 2) + ItemStack(MItems.QUANTUM_BATTERY, 2), + experience = 20f ).energetic().toFinished(modLocation("quantum_battery")) ) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt index e234863ad..ac83b83c9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt @@ -23,7 +23,6 @@ import net.minecraft.world.level.block.state.properties.Property import net.minecraft.world.level.material.MapColor import net.minecraft.world.phys.BlockHitResult import net.minecraft.world.phys.shapes.VoxelShape -import ru.dbotthepony.mc.otm.SERVER_IS_LIVE import ru.dbotthepony.mc.otm.block.entity.IRedstoneControlled import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity @@ -60,9 +59,20 @@ fun Block.getShapeForEachState(property: Property<*>, fn: (BlockState) -> VoxelS return getShapeForEachState(listOf(property), fn) } +fun interface INeighbourChangeListener { + fun neighborChanged( + state: BlockState, + level: Level, + pos: BlockPos, + neighbour: Block, + neighbourPos: BlockPos, + movedByPiston: Boolean + ) +} + abstract class MatteryBlock @JvmOverloads constructor( properties: Properties = DEFAULT_PROPERTIES -) : Block(properties) { +) : Block(properties), INeighbourChangeListener { override fun setPlacedBy( level: Level, blockPos: BlockPos, @@ -168,7 +178,6 @@ abstract class MatteryBlock @JvmOverloads constructor( return null } - @Suppress("OVERRIDE_DEPRECATION") override fun neighborChanged( state: BlockState, level: Level, @@ -188,8 +197,8 @@ abstract class MatteryBlock @JvmOverloads constructor( if (tile is IRedstoneControlled) tile.redstoneControl.redstoneSignal = level.getBestNeighborSignal(pos) - if (tile is MatteryBlockEntity && SERVER_IS_LIVE) - tile.neighborChanged(neighbour, neighbourPos, movedByPiston) + if (tile is MatteryBlockEntity) + tile.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston) } } } 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 new file mode 100644 index 000000000..310f47590 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ExperienceStorage.kt @@ -0,0 +1,154 @@ +package ru.dbotthepony.mc.otm.block.entity + +import net.minecraft.core.BlockPos +import net.minecraft.core.Direction +import net.minecraft.nbt.DoubleTag +import net.minecraft.server.level.ServerLevel +import net.minecraft.server.level.ServerPlayer +import net.minecraft.world.entity.ExperienceOrb +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.Block +import net.minecraft.world.level.block.entity.BlockEntity +import net.minecraft.world.level.block.state.BlockState +import net.minecraftforge.common.util.INBTSerializable +import net.minecraftforge.fluids.FluidStack +import net.minecraftforge.fluids.capability.IFluidHandler +import ru.dbotthepony.mc.otm.block.INeighbourChangeListener +import ru.dbotthepony.mc.otm.block.entity.tech.EssenceStorageBlockEntity +import ru.dbotthepony.mc.otm.core.math.plus +import ru.dbotthepony.mc.otm.registry.MFluids +import java.util.function.DoubleSupplier + +class ExperienceStorage(val maxExperience: DoubleSupplier = DoubleSupplier { Double.POSITIVE_INFINITY }) : IFluidHandler, INBTSerializable, INeighbourChangeListener { + constructor(max: Double) : this({ max }) + + var experience = 0.0 + private set(value) { + require(value >= 0.0) { "Negative experience: $value" } + field = value + } + + fun popExperience(player: ServerPlayer) { + val whole = experience.toInt() + + if (whole > 0) { + experience -= whole + ExperienceOrb.award(player.level() as ServerLevel, player.position(), whole) + } + } + + fun storeExperience(experience: Double): Boolean { + check(experience >= 0.0) { "Invalid experience amount to store: $experience" } + val max = maxExperience.asDouble + val overflow = this.experience + experience > max + this.experience = if (overflow) max else this.experience + experience + return !overflow + } + + fun storeExperience(experience: Float): Boolean { + return storeExperience(experience.toDouble()) + } + + fun storeExperience(experience: Double, pointOfReference: BlockEntity): Boolean { + check(experience >= 0.0) { "Invalid experience amount to store: $experience" } + this.experience += experience + + for (dir in Direction.entries) { + val tile = pointOfReference.level?.getBlockEntity(pointOfReference.blockPos + dir) + + if (tile is EssenceStorageBlockEntity) { + tile.experienceStored += this.experience.toLong() + this.experience %= 1.0 + break + } + } + + val max = maxExperience.asDouble + val overflow = this.experience > max + if (overflow) this.experience = max + return !overflow + } + + fun storeExperience(experience: Float, pointOfReference: BlockEntity): Boolean { + return storeExperience(experience.toDouble(), pointOfReference) + } + + fun tryTransferExperience(pointOfReference: BlockEntity) { + if (experience >= 1.0) { + for (dir in Direction.entries) { + val tile = pointOfReference.level?.getBlockEntity(pointOfReference.blockPos + dir) + + if (tile is EssenceStorageBlockEntity) { + tile.experienceStored += experience.toLong() + experience %= 1.0 + break + } + } + } + } + + override fun neighborChanged(state: BlockState, level: Level, pos: BlockPos, neighbour: Block, neighbourPos: BlockPos, movedByPiston: Boolean) { + if (experience >= 1.0) { + val tile = level.getBlockEntity(neighbourPos) + + if (tile is EssenceStorageBlockEntity) { + tile.experienceStored += experience.toLong() + experience %= 1.0 + } + } + } + + override fun serializeNBT(): DoubleTag { + return DoubleTag.valueOf(experience) + } + + override fun deserializeNBT(nbt: DoubleTag?) { + experience = (nbt?.asDouble ?: 0.0).coerceAtLeast(0.0) + } + + override fun getTanks(): Int { + return 1 + } + + override fun getFluidInTank(tank: Int): FluidStack { + if (tank != 0) + return FluidStack.EMPTY + + return FluidStack(MFluids.LIQUID_XP, (experience * XP_TO_LIQUID_RATIO).toInt()) + } + + override fun getTankCapacity(tank: Int): Int { + return if (tank == 0) (maxExperience.asDouble * XP_TO_LIQUID_RATIO).toInt() else 0 + } + + override fun isFluidValid(tank: Int, stack: FluidStack): Boolean { + return tank == 0 && stack.fluid.fluidType == MFluids.LIQUID_XP_TYPE + } + + override fun fill(resource: FluidStack, action: IFluidHandler.FluidAction): Int { + return 0 + } + + override fun drain(resource: FluidStack, action: IFluidHandler.FluidAction): FluidStack { + if (resource.fluid.fluidType != MFluids.LIQUID_XP_TYPE) + return FluidStack.EMPTY + + return drain(resource.amount, action) + } + + override fun drain(maxDrain: Int, action: IFluidHandler.FluidAction): FluidStack { + val actualDrain = maxDrain.coerceAtMost((experience * XP_TO_LIQUID_RATIO).toInt()).let { it / XP_TO_LIQUID_RATIO * XP_TO_LIQUID_RATIO } + + if (actualDrain <= 0) + return FluidStack.EMPTY + + if (action.execute()) + experience -= actualDrain / XP_TO_LIQUID_RATIO + + return FluidStack(MFluids.LIQUID_XP, actualDrain) + } + + companion object { + const val XP_TO_LIQUID_RATIO = 10 + } +} 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 c63c5b0cf..27718dd70 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 @@ -12,7 +12,6 @@ import net.minecraft.core.Direction import net.minecraft.core.SectionPos import net.minecraft.core.Vec3i import net.minecraft.nbt.CompoundTag -import net.minecraft.nbt.Tag import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerPlayer import net.minecraft.world.Container @@ -28,7 +27,6 @@ import net.minecraft.world.level.chunk.LevelChunk import net.minecraft.world.phys.Vec3 import net.minecraftforge.common.capabilities.Capability import net.minecraftforge.common.capabilities.ForgeCapabilities -import net.minecraftforge.common.util.INBTSerializable import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.energy.IEnergyStorage import net.minecraftforge.event.TickEvent.LevelTickEvent @@ -37,6 +35,7 @@ import net.minecraftforge.event.level.ChunkWatchEvent import net.minecraftforge.event.level.LevelEvent import net.minecraftforge.event.server.ServerStoppingEvent import ru.dbotthepony.mc.otm.SERVER_IS_LIVE +import ru.dbotthepony.mc.otm.block.INeighbourChangeListener import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage @@ -65,12 +64,11 @@ import java.util.function.Supplier import java.util.stream.Stream import kotlin.properties.ReadWriteProperty import kotlin.reflect.KProperty -import kotlin.reflect.KProperty0 /** * Absolute barebone (lol) block entity class in Overdrive that Matters, providing bare minimum (lulmao, minecraft engine) functionality */ -abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: BlockPos, p_155230_: BlockState) : BlockEntity(p_155228_, p_155229_, p_155230_) { +abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: BlockPos, p_155230_: BlockState) : BlockEntity(p_155228_, p_155229_, p_155230_), INeighbourChangeListener { private var isSynchronizing = false /** @@ -83,12 +81,21 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } private val _droppableContainers = ObjectArraySet() + private val _neighbourChangeListeners = ObjectArraySet() val droppableContainers: Set = Collections.unmodifiableSet(_droppableContainers) + val neighbourChangeListeners: Set = Collections.unmodifiableSet(_neighbourChangeListeners) protected fun addDroppableContainer(container: Container) { _droppableContainers.add(container) } + protected fun addNeighbourListener(listener: INeighbourChangeListener) { + if (listener === this) + throw IllegalArgumentException("are you drunk") + + _neighbourChangeListeners.add(listener) + } + open fun beforeDroppingItems(oldBlockState: BlockState, level: Level, blockPos: BlockPos, newBlockState: BlockState, movedByPiston: Boolean) {} open fun beforeDestroyedByPlayer(level: Level, blockPos: BlockPos, blockState: BlockState, player: Player) {} @@ -441,7 +448,8 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } } - fun neighborChanged(neighbour: Block, neighbourPos: BlockPos, movedByPiston: Boolean) { + override fun neighborChanged(state: BlockState, level: Level, pos: BlockPos, neighbour: Block, neighbourPos: BlockPos, movedByPiston: Boolean) { + _neighbourChangeListeners.forEach { it.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston) } val dir = vec2Dir[vecKey(neighbourPos - blockPos)] ?: return _sides[blockRotation.dir2Side(dir)]!!.updateTracked() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterEntanglerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterEntanglerBlockEntity.kt index bcd29a5e4..40c2212b5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterEntanglerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterEntanglerBlockEntity.kt @@ -9,6 +9,8 @@ import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level import net.minecraft.world.level.block.state.BlockState +import net.minecraftforge.common.capabilities.ForgeCapabilities +import ru.dbotthepony.mc.otm.block.entity.ExperienceStorage import ru.dbotthepony.mc.otm.block.entity.ItemJob import ru.dbotthepony.mc.otm.block.entity.JobContainer import ru.dbotthepony.mc.otm.block.entity.JobStatus @@ -35,7 +37,7 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MRecipes class MatterEntanglerBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryWorkerBlockEntity(MBlockEntities.MATTER_ENTANGLER, blockPos, blockState, Job.CODEC) { - class Job(itemStack: ItemStack, val matter: Decimal, ticks: Double) : ItemJob(itemStack, ticks, MachinesConfig.MATTER_ENTANGLER.energyConsumption) { + class Job(itemStack: ItemStack, val matter: Decimal, ticks: Double, experience: Float) : ItemJob(itemStack, ticks, MachinesConfig.MATTER_ENTANGLER.energyConsumption, experience = experience) { val matterPerTick = matter / ticks companion object { @@ -44,6 +46,7 @@ class MatterEntanglerBlockEntity(blockPos: BlockPos, blockState: BlockState) : M ItemStack.CODEC.fieldOf("itemStack").forGetter(ItemJob::itemStack), DecimalCodec.minRange(Decimal.ZERO).fieldOf("matter").forGetter(Job::matter), Codec.DOUBLE.minRange(0.0).fieldOf("ticks").forGetter(ItemJob::ticks), + Codec.FLOAT.minRange(0f).optionalFieldOf("experience", 0f).forGetter(Job::experience) ).apply(it, ::Job) } } @@ -54,6 +57,7 @@ class MatterEntanglerBlockEntity(blockPos: BlockPos, blockState: BlockState) : M val matter = ProfiledMatterStorage(MatterStorageImpl(::markDirtyFast, FlowDirection.INPUT, upgrades.matterCapacity(MachinesConfig.MATTER_ENTANGLER::matterCapacity))) val node = MatterNode() + val experience = ExperienceStorage(MachinesConfig.MATTER_ENTANGLER::maxExperienceStored).also(::addNeighbourListener) val energyConfig = ConfigurableEnergy(energy) val inputs = object : MatteryCraftingContainer(::itemContainerUpdated, 3, 3) { @@ -88,11 +92,14 @@ class MatterEntanglerBlockEntity(blockPos: BlockPos, blockState: BlockState) : M ) init { + exposeGlobally(ForgeCapabilities.FLUID_HANDLER, experience) + savetables.stateful(::energy, ENERGY_KEY) savetables.stateful(::matter, MATTER_STORAGE_KEY) savetables.stateful(::upgrades) savetables.stateful(::inputs) savetables.stateful(::output) + savetables.stateful(::experience) exposeGlobally(MatteryCapability.MATTER_NODE, node) exposeGlobally(MatteryCapability.MATTER, matter) @@ -128,6 +135,8 @@ class MatterEntanglerBlockEntity(blockPos: BlockPos, blockState: BlockState) : M override fun onJobFinish(status: JobStatus, id: Int) { if (!output.fullyAddItem(status.job.itemStack)) { status.noItem() + } else { + experience.storeExperience(status.job.experience, this) } } @@ -150,7 +159,8 @@ class MatterEntanglerBlockEntity(blockPos: BlockPos, blockState: BlockState) : M Job( result, recipe.value.matter, - recipe.value.ticks * MachinesConfig.MATTER_ENTANGLER.workTimeMultiplier + recipe.value.ticks * MachinesConfig.MATTER_ENTANGLER.workTimeMultiplier, + recipe.value.experience ) ) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt index a591f74d8..5acf1f262 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EssenceStorageBlockEntity.kt @@ -7,6 +7,9 @@ import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.item.ItemStack import net.minecraft.world.item.enchantment.Enchantments import net.minecraft.world.level.block.state.BlockState +import net.minecraftforge.fluids.FluidStack +import net.minecraftforge.fluids.capability.IFluidHandler +import ru.dbotthepony.mc.otm.block.entity.ExperienceStorage.Companion.XP_TO_LIQUID_RATIO import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.capability.item.CombinedItemHandler import ru.dbotthepony.mc.otm.container.HandlerFilter @@ -14,8 +17,9 @@ import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.item.EssenceCapsuleItem import ru.dbotthepony.mc.otm.menu.tech.EssenceStorageMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities +import ru.dbotthepony.mc.otm.registry.MFluids -class EssenceStorageBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.ESSENCE_STORAGE, blockPos, blockState) { +class EssenceStorageBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDeviceBlockEntity(MBlockEntities.ESSENCE_STORAGE, blockPos, blockState), IFluidHandler { var experienceStored = 0L set(value) { require(value >= 0L) { "Negative experience: $value" } @@ -57,6 +61,62 @@ class EssenceStorageBlockEntity(blockPos: BlockPos, blockState: BlockState) : Ma ) ) + override fun getTanks(): Int { + return 1 + } + + override fun getFluidInTank(tank: Int): FluidStack { + if (tank != 0) + return FluidStack.EMPTY + + if (experienceStored >= 2_000_000_000L) + return FluidStack(MFluids.LIQUID_XP, 2_000_000_000) + + return FluidStack(MFluids.LIQUID_XP, experienceStored.toInt()) + } + + override fun getTankCapacity(tank: Int): Int { + if (tank != 0) return 0 + return Int.MAX_VALUE + } + + override fun isFluidValid(tank: Int, stack: FluidStack): Boolean { + return tank == 0 && stack.fluid.fluidType == MFluids.LIQUID_XP_TYPE + } + + override fun fill(resource: FluidStack, action: IFluidHandler.FluidAction): Int { + if (resource.fluid.fluidType != MFluids.LIQUID_XP_TYPE || resource.amount <= 0) + return 0 + + val actualFill = resource.amount / XP_TO_LIQUID_RATIO * XP_TO_LIQUID_RATIO + + if (action.execute()) + experienceStored += actualFill / XP_TO_LIQUID_RATIO + + return actualFill + } + + override fun drain(resource: FluidStack, action: IFluidHandler.FluidAction): FluidStack { + if (resource.fluid.fluidType != MFluids.LIQUID_XP_TYPE) + return FluidStack.EMPTY + + return drain(resource.amount, action) + } + + override fun drain(maxDrain: Int, action: IFluidHandler.FluidAction): FluidStack { + val stored = experienceStored * XP_TO_LIQUID_RATIO + val actualStored = if (stored >= Int.MAX_VALUE) Int.MAX_VALUE else stored.toInt() + val actualDrain = maxDrain.coerceAtMost(actualStored).let { it / XP_TO_LIQUID_RATIO * XP_TO_LIQUID_RATIO } + + if (actualDrain <= 0) + return FluidStack.EMPTY + + if (action.execute()) + experienceStored -= actualDrain / XP_TO_LIQUID_RATIO + + return FluidStack(MFluids.LIQUID_XP, actualDrain) + } + override fun tick() { super.tick() 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 081471a0b..5cfc76190 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 @@ -2,14 +2,12 @@ package ru.dbotthepony.mc.otm.block.entity.tech import it.unimi.dsi.fastutil.ints.IntArrayList import net.minecraft.core.BlockPos -import net.minecraft.core.Direction -import net.minecraft.server.level.ServerLevel -import net.minecraft.server.level.ServerPlayer -import net.minecraft.world.entity.ExperienceOrb import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.level.block.state.BlockState +import net.minecraftforge.common.capabilities.ForgeCapabilities +import ru.dbotthepony.mc.otm.block.entity.ExperienceStorage import ru.dbotthepony.mc.otm.block.entity.JobContainer import ru.dbotthepony.mc.otm.block.entity.JobStatus import ru.dbotthepony.mc.otm.block.entity.ItemJob @@ -39,39 +37,7 @@ class PlatePressBlockEntity( val inputContainer = MatteryContainer(this::itemContainerUpdated, if (isTwin) 2 else 1).also(::addDroppableContainer) val outputContainer = MatteryContainer(this::itemContainerUpdated, if (isTwin) 2 else 1).also(::addDroppableContainer) - var experience = 0.0 - private set - - fun popExperience(player: ServerPlayer) { - val whole = experience.toInt() - - if (whole > 0) { - experience -= whole - ExperienceOrb.award(player.level() as ServerLevel, player.position(), whole) - } - } - - fun tryStoreExperience(essenceStorage: EssenceStorageBlockEntity?) { - if (experience <= 0.0) return - - if (essenceStorage != null) { - essenceStorage.experienceStored += experience.toLong() - experience = 0.0 - - return - } - - for (dir in Direction.entries) { - val tile = level?.getBlockEntity(blockPos.relative(dir)) ?: continue - - if (tile is EssenceStorageBlockEntity) { - tryStoreExperience(tile) - - break - } - } - } - + val experience = ExperienceStorage(MachinesConfig.PLATE_PRESS::maxExperienceStored).also(::addNeighbourListener) val energyConfig = ConfigurableEnergy(energy) val itemConfig = ConfigurableItemHandler( input = inputContainer.handler(HandlerFilter.OnlyIn), @@ -79,10 +45,12 @@ class PlatePressBlockEntity( ) init { + exposeGlobally(ForgeCapabilities.FLUID_HANDLER, experience) + savetables.stateful(::energy, ENERGY_KEY) savetables.stateful(::inputContainer) savetables.stateful(::outputContainer) - savetables.double(::experience) + savetables.stateful(::experience) savetables.stateful(::upgrades) } @@ -100,8 +68,7 @@ class PlatePressBlockEntity( if (!outputContainer.fullyAddItem(status.job.itemStack, slots = IntArrayList.of(id)) && !outputContainer.fullyAddItem(status.job.itemStack)) return status.noItem() - experience = (experience + status.experience).coerceAtMost(100.0) - tryStoreExperience(null) + experience.storeExperience(status.experience, this) } override fun computeNextJob(id: Int): JobContainer { 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 2226d0829..b1c6c4abe 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 @@ -12,6 +12,8 @@ import net.minecraft.world.item.crafting.AbstractCookingRecipe import net.minecraft.world.item.crafting.RecipeType import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState +import net.minecraftforge.common.capabilities.ForgeCapabilities +import ru.dbotthepony.mc.otm.block.entity.ExperienceStorage import ru.dbotthepony.mc.otm.block.entity.JobContainer import ru.dbotthepony.mc.otm.block.entity.JobStatus import ru.dbotthepony.mc.otm.block.entity.ItemJob @@ -53,6 +55,7 @@ class PoweredFurnaceBlockEntity( outputs.forEach { addDroppableContainer(it) } } + val experience = ExperienceStorage(config::maxExperienceStored).also(::addNeighbourListener) val energyConfig = ConfigurableEnergy(energy) val itemConfig = ConfigurableItemHandler( input = CombinedItemHandler(inputs.map { it.handler(HandlerFilter.OnlyIn) }), @@ -60,44 +63,13 @@ class PoweredFurnaceBlockEntity( battery = batteryItemHandler ) - var experience = 0.0 - private set - - fun popExperience(player: ServerPlayer) { - val whole = experience.toInt() - - if (whole > 0) { - experience -= whole - ExperienceOrb.award(player.level() as ServerLevel, player.position(), whole) - } - } - - fun tryStoreExperience(essenceStorage: EssenceStorageBlockEntity?) { - if (experience <= 0.0) return - - if (essenceStorage != null) { - essenceStorage.experienceStored += experience.toLong() - experience = 0.0 - - return - } - - for (dir in Direction.entries) { - val tile = level?.getBlockEntity(blockPos.relative(dir)) ?: continue - - if (tile is EssenceStorageBlockEntity) { - tryStoreExperience(tile) - - break - } - } - } - init { + exposeGlobally(ForgeCapabilities.FLUID_HANDLER, experience) + savetables.stateful(::upgrades) savetables.stateful(::energy) - savetables.double(::experience) + savetables.stateful(::experience) savetables.stateful(inputs, "input") savetables.stateful(outputs, "output") @@ -124,8 +96,7 @@ class PoweredFurnaceBlockEntity( override fun onJobFinish(status: JobStatus, id: Int) { if (outputs[id].fullyAddItem(status.job.itemStack)) { - experience += status.experience - tryStoreExperience(null) + experience.storeExperience(status.experience, this) } else { status.noItem() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt index 83428bc32..740271336 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt @@ -66,24 +66,4 @@ class PlatePressBlock(properties: Properties = DEFAULT_PROPERTIES, val isTwin: B ): VoxelShape { return shapes[state]!! } - - @Suppress("OVERRIDE_DEPRECATION") - override fun neighborChanged( - state: BlockState, - level: Level, - pos: BlockPos, - neighbour: Block, - neighbourPos: BlockPos, - movedByPiston: Boolean - ) { - super.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston) - - val tile = level.getBlockEntity(pos) ?: return - val neighbourTile = level.getBlockEntity(neighbourPos) ?: return - - if (tile.isRemoved || neighbourTile.isRemoved) return - if (tile is PlatePressBlockEntity && neighbourTile is EssenceStorageBlockEntity) { - tile.tryStoreExperience(neighbourTile) - } - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt index 556a230ae..1f1be51a0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt @@ -61,24 +61,4 @@ class PoweredFurnaceBlock( return BlockEntityTicker { _, _, _, tile -> if (tile is PoweredFurnaceBlockEntity) tile.tick() } } - - @Suppress("OVERRIDE_DEPRECATION") - override fun neighborChanged( - state: BlockState, - level: Level, - pos: BlockPos, - neighbour: Block, - neighbourPos: BlockPos, - movedByPiston: Boolean - ) { - super.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston) - - val tile = level.getBlockEntity(pos) ?: return - val neighbourTile = level.getBlockEntity(neighbourPos) ?: return - - if (tile.isRemoved || neighbourTile.isRemoved) return - if (tile is PoweredFurnaceBlockEntity && neighbourTile is EssenceStorageBlockEntity) { - tile.tryStoreExperience(neighbourTile) - } - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt index 7cf624353..24b64492f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/AbstractConfig.kt @@ -51,6 +51,7 @@ abstract class AbstractConfig(private val configName: String, private val type: workTimeMultiplier: Double? = 1.0, energyConsumption: Decimal?, matterCapacity: Decimal? = null, + maxExperience: Double? = null, configurator: ForgeConfigSpec.Builder.() -> Unit = {} ): WorkerBalanceValues { builder.push(name) @@ -61,6 +62,7 @@ abstract class AbstractConfig(private val configName: String, private val type: override val energyConsumption: Decimal by (if (energyConsumption == null) GetterSetter.box(Decimal.ZERO) else builder.defineDecimal("ENERGY_CONSUMPTION", energyConsumption, minimum = Decimal.ONE)) override val matterCapacity: Decimal by (if (matterCapacity == null) GetterSetter.box(Decimal.ZERO) else builder.defineDecimal("MATTER_CAPACITY", matterCapacity, minimum = Decimal.ONE)) override val workTimeMultiplier: Double by (if (workTimeMultiplier == null) GetterSetter.box(1.0) else builder.defineInRange("WORK_TIME_MULTIPLIER", workTimeMultiplier, 0.0)) + override val maxExperienceStored: Double by (if (maxExperience == null) GetterSetter.box(Double.POSITIVE_INFINITY) else builder.defineInRange("MAX_EXPERIENCE_STORED", maxExperience, 0.0)) } configurator.invoke(builder) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/BalanceValues.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/BalanceValues.kt index 1a0a59e3e..ea3cbac7d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/BalanceValues.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/BalanceValues.kt @@ -11,6 +11,7 @@ interface WorkerBalanceValues : EnergyBalanceValues { val workTimeMultiplier: Double val energyConsumption: Decimal val matterCapacity: Decimal + val maxExperienceStored: Double } interface VerboseEnergyBalanceValues { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt index d0bc04a44..3fc705cbd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/config/MachinesConfig.kt @@ -10,7 +10,8 @@ object MachinesConfig : AbstractConfig("machines") { MNames.PLATE_PRESS, energyStorage = Decimal(40_000), energyThroughput = Decimal(200), - energyConsumption = Decimal(15) + energyConsumption = Decimal(15), + maxExperience = 200.0, ) val MATTER_ENTANGLER = workerValues( @@ -19,6 +20,7 @@ object MachinesConfig : AbstractConfig("machines") { energyThroughput = Decimal(400), energyConsumption = Decimal(120), matterCapacity = Decimal(60), + maxExperience = 400.0, ) val MATTER_DECOMPOSER = workerValues( @@ -169,7 +171,8 @@ object MachinesConfig : AbstractConfig("machines") { energyStorage = Decimal(40_000), energyThroughput = Decimal(200), energyConsumption = Decimal(20), - workTimeMultiplier = 0.75 + workTimeMultiplier = 0.75, + maxExperience = 200.0 ) val POWERED_BLAST_FURNACE = workerValues( @@ -177,7 +180,8 @@ object MachinesConfig : AbstractConfig("machines") { energyStorage = Decimal(40_000), energyThroughput = Decimal(200), energyConsumption = Decimal(20), - workTimeMultiplier = 0.75 + workTimeMultiplier = 0.75, + maxExperience = 200.0 ) val POWERED_SMOKER = workerValues( @@ -185,7 +189,8 @@ object MachinesConfig : AbstractConfig("machines") { energyStorage = Decimal(40_000), energyThroughput = Decimal(200), energyConsumption = Decimal(10), - workTimeMultiplier = 0.75 + workTimeMultiplier = 0.75, + maxExperience = 200.0 ) object Upgrades { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterEntanglerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterEntanglerMenu.kt index 2c452c85f..7b3884ee5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterEntanglerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterEntanglerMenu.kt @@ -57,7 +57,7 @@ class MatterEntanglerMenu( } } - val outputs = makeSlots(tile?.output ?: SimpleContainer(1), ::OutputSlot) + val outputs = makeSlots(tile?.output ?: SimpleContainer(1)) { a, b -> OutputSlot(a, b) { tile?.experience?.popExperience(player as ServerPlayer) } } val upgrades = makeUpgradeSlots(3, tile?.upgrades) private val entangling: Container = if (tile == null) object : SimpleContainer(2) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt index 2d3bc8512..35269557b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PlatePressMenu.kt @@ -13,13 +13,13 @@ import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus -class PlatePressMenu @JvmOverloads constructor( +class PlatePressMenu( containerID: Int, inventory: Inventory, tile: PlatePressBlockEntity? = null ) : MatteryPoweredMenu(MMenus.PLATE_PRESS, containerID, inventory, tile) { val inputSlot = MatterySlot(tile?.inputContainer ?: SimpleContainer(1), 0) - val outputSlot = OutputSlot(tile?.outputContainer ?: SimpleContainer(1), 0) { tile?.popExperience(player as ServerPlayer) } + val outputSlot = OutputSlot(tile?.outputContainer ?: SimpleContainer(1), 0) { tile?.experience?.popExperience(player as ServerPlayer) } val progressGauge = ProgressGaugeWidget(this, tile) val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig, allowPush = true) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PoweredFurnaceMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PoweredFurnaceMenu.kt index a39411c6c..e547464ab 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PoweredFurnaceMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/PoweredFurnaceMenu.kt @@ -23,7 +23,7 @@ class PoweredFurnaceMenu( tile: PoweredFurnaceBlockEntity? = null ) : MatteryPoweredMenu(type, containerID, inventory, tile) { val inputSlots = makeSlots(tile?.inputs, 2, ::MatterySlot) - val outputSlots = makeSlots(tile?.outputs, 2) { c, s -> OutputSlot(c, s) { tile?.popExperience(player as ServerPlayer) } } + val outputSlots = makeSlots(tile?.outputs, 2) { c, s -> OutputSlot(c, s) { tile?.experience?.popExperience(player as ServerPlayer) } } val progressGauge = immutableList(2) { ProgressGaugeWidget(this, tile?.jobEventLoops?.get(it)) } val itemConfig = ItemConfigPlayerInput(this, tile?.itemConfig, allowPush = true) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/TwinPlatePressMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/TwinPlatePressMenu.kt index 8533dd864..244b9bc13 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/TwinPlatePressMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/TwinPlatePressMenu.kt @@ -15,13 +15,13 @@ import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget import ru.dbotthepony.mc.otm.registry.MMenus -class TwinPlatePressMenu @JvmOverloads constructor( +class TwinPlatePressMenu( containerID: Int, inventory: Inventory, tile: PlatePressBlockEntity? = null ) : MatteryPoweredMenu(MMenus.TWIN_PLATE_PRESS, containerID, inventory, tile) { val inputSlots = makeSlots(tile?.inputContainer ?: SimpleContainer(2), ::MatterySlot) - val outputSlots = makeSlots(tile?.outputContainer ?: SimpleContainer(2)) { a, b -> OutputSlot(a, b) { tile?.popExperience(player as ServerPlayer) } } + val outputSlots = makeSlots(tile?.outputContainer ?: SimpleContainer(2)) { a, b -> OutputSlot(a, b) { tile?.experience?.popExperience(player as ServerPlayer) } } val progressGauge0 = ProgressGaugeWidget(this, tile?.jobEventLoops?.get(0)) val progressGauge1 = ProgressGaugeWidget(this, tile?.jobEventLoops?.get(1)) 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 b9daa6882..a8dc68f98 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt @@ -36,6 +36,7 @@ interface IMatterEntanglerRecipe : IMatteryRecipe { val ticks: Double val ingredients: IIngredientMatrix val result: ItemStack + val experience: Float fun preemptivelyMatches(container: CraftingContainer, level: Level): Boolean } @@ -45,6 +46,7 @@ open class MatterEntanglerRecipe( override val matter: Decimal, override val ticks: Double, override val result: ItemStack, + override val experience: Float = 0f, val uuidKey: String = "uuid", val fixedUuid: Optional = Optional.empty() ) : IMatterEntanglerRecipe { @@ -147,6 +149,7 @@ open class MatterEntanglerRecipe( DecimalCodec.minRange(Decimal.ZERO).fieldOf("matter").forGetter(MatterEntanglerRecipe::matter), Codec.DOUBLE.minRange(0.0).fieldOf("ticks").forGetter(MatterEntanglerRecipe::ticks), 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) ).apply(it, ::MatterEntanglerRecipe) 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 98380836b..8e64746f7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -12,7 +12,17 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag import net.minecraft.world.item.crafting.RecipeType import net.minecraft.world.level.BlockGetter -import net.minecraft.world.level.block.* +import net.minecraft.world.level.block.AnvilBlock +import net.minecraft.world.level.block.Block +import net.minecraft.world.level.block.DoorBlock +import net.minecraft.world.level.block.DropExperienceBlock +import net.minecraft.world.level.block.IronBarsBlock +import net.minecraft.world.level.block.LiquidBlock +import net.minecraft.world.level.block.SlabBlock +import net.minecraft.world.level.block.SoundType +import net.minecraft.world.level.block.StairBlock +import net.minecraft.world.level.block.TrapDoorBlock +import net.minecraft.world.level.block.WallBlock import net.minecraft.world.level.block.state.BlockBehaviour import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.properties.BlockSetType @@ -23,32 +33,25 @@ 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.block.tech.AndroidStationBlock -import ru.dbotthepony.mc.otm.block.tech.BatteryBankBlock import ru.dbotthepony.mc.otm.block.BlackHoleBlock import ru.dbotthepony.mc.otm.block.BlockExplosionDebugger -import ru.dbotthepony.mc.otm.block.tech.BlockGravitationStabilizer -import ru.dbotthepony.mc.otm.block.tech.BlockGravitationStabilizerLens import ru.dbotthepony.mc.otm.block.BlockSphereDebugger -import ru.dbotthepony.mc.otm.block.tech.ChemicalGeneratorBlock -import ru.dbotthepony.mc.otm.block.tech.EnergyCounterBlock -import ru.dbotthepony.mc.otm.block.tech.EnergyServoBlock -import ru.dbotthepony.mc.otm.block.decorative.LaboratoryLamp -import ru.dbotthepony.mc.otm.block.decorative.LaboratoryLampLight import ru.dbotthepony.mc.otm.block.MatterCableBlock -import ru.dbotthepony.mc.otm.block.tech.PhantomAttractorBlock -import ru.dbotthepony.mc.otm.block.tech.PlatePressBlock import ru.dbotthepony.mc.otm.block.StorageCableBlock import ru.dbotthepony.mc.otm.block.decorative.DevChestBlock import ru.dbotthepony.mc.otm.block.decorative.EngineBlock import ru.dbotthepony.mc.otm.block.decorative.FluidTankBlock import ru.dbotthepony.mc.otm.block.decorative.HoloSignBlock import ru.dbotthepony.mc.otm.block.decorative.InfiniteWaterSourceBlock -import ru.dbotthepony.mc.otm.block.matter.MatterReconstructorBlock +import ru.dbotthepony.mc.otm.block.decorative.LaboratoryLamp +import ru.dbotthepony.mc.otm.block.decorative.LaboratoryLampLight +import ru.dbotthepony.mc.otm.block.decorative.PainterBlock import ru.dbotthepony.mc.otm.block.matter.MatterBottlerBlock import ru.dbotthepony.mc.otm.block.matter.MatterCapacitorBankBlock import ru.dbotthepony.mc.otm.block.matter.MatterDecomposerBlock +import ru.dbotthepony.mc.otm.block.matter.MatterEntanglerBlock import ru.dbotthepony.mc.otm.block.matter.MatterPanelBlock +import ru.dbotthepony.mc.otm.block.matter.MatterReconstructorBlock import ru.dbotthepony.mc.otm.block.matter.MatterRecyclerBlock import ru.dbotthepony.mc.otm.block.matter.MatterReplicatorBlock import ru.dbotthepony.mc.otm.block.matter.MatterScannerBlock @@ -61,10 +64,17 @@ import ru.dbotthepony.mc.otm.block.storage.StorageExporterBlock import ru.dbotthepony.mc.otm.block.storage.StorageImporterBlock import ru.dbotthepony.mc.otm.block.storage.StoragePowerSupplierBlock import ru.dbotthepony.mc.otm.block.tech.AndroidChargerBlock +import ru.dbotthepony.mc.otm.block.tech.AndroidStationBlock +import ru.dbotthepony.mc.otm.block.tech.BatteryBankBlock +import ru.dbotthepony.mc.otm.block.tech.BlockGravitationStabilizer +import ru.dbotthepony.mc.otm.block.tech.BlockGravitationStabilizerLens +import ru.dbotthepony.mc.otm.block.tech.ChemicalGeneratorBlock import ru.dbotthepony.mc.otm.block.tech.CobblerBlock +import ru.dbotthepony.mc.otm.block.tech.EnergyCounterBlock +import ru.dbotthepony.mc.otm.block.tech.EnergyServoBlock import ru.dbotthepony.mc.otm.block.tech.EssenceStorageBlock -import ru.dbotthepony.mc.otm.block.decorative.PainterBlock -import ru.dbotthepony.mc.otm.block.matter.MatterEntanglerBlock +import ru.dbotthepony.mc.otm.block.tech.PhantomAttractorBlock +import ru.dbotthepony.mc.otm.block.tech.PlatePressBlock import ru.dbotthepony.mc.otm.block.tech.PoweredFurnaceBlock import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.core.TranslatableComponent @@ -126,6 +136,8 @@ object MBlocks { val FLUID_TANK: FluidTankBlock by registry.register(MNames.FLUID_TANK) { FluidTankBlock() } val DEV_CHEST: DevChestBlock by registry.register(MNames.DEV_CHEST) { DevChestBlock() } + val LIQUID_XP: LiquidBlock by registry.register("liquid_xp") { LiquidBlock(MFluids::LIQUID_XP, BlockBehaviour.Properties.of().mapColor(MapColor.EMERALD).replaceable().noCollission().strength(100.0f).pushReaction(PushReaction.DESTROY).noLootTable().liquid().sound(SoundType.EMPTY)) } + val TRITANIUM_ORE: Block by registry.register(MNames.TRITANIUM_ORE) { DropExperienceBlock( BlockBehaviour.Properties.of() .mapColor(MapColor.STONE) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MFluids.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MFluids.kt new file mode 100644 index 000000000..d42923a95 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MFluids.kt @@ -0,0 +1,66 @@ +package ru.dbotthepony.mc.otm.registry + +import net.minecraft.resources.ResourceLocation +import net.minecraft.sounds.SoundEvents +import net.minecraft.world.item.Rarity +import net.minecraft.world.level.material.Fluid +import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions +import net.minecraftforge.common.SoundActions +import net.minecraftforge.eventbus.api.IEventBus +import net.minecraftforge.fluids.FluidType +import net.minecraftforge.fluids.ForgeFlowingFluid +import net.minecraftforge.registries.DeferredRegister +import net.minecraftforge.registries.ForgeRegistries +import ru.dbotthepony.mc.otm.OverdriveThatMatters +import java.util.function.Consumer + +object MFluids { + private val types: DeferredRegister = DeferredRegister.create(ForgeRegistries.FLUID_TYPES, OverdriveThatMatters.MOD_ID) + private val fluids: DeferredRegister = DeferredRegister.create(ForgeRegistries.FLUIDS, OverdriveThatMatters.MOD_ID) + + internal fun register(bus: IEventBus) { + types.register(bus) + fluids.register(bus) + } + + private fun makeXpProps(): ForgeFlowingFluid.Properties { + return ForgeFlowingFluid.Properties(::LIQUID_XP_TYPE, ::LIQUID_XP, ::LIQUID_XP_FLOWING).bucket(MItems::LIQUID_XP_BUCKET).block(MBlocks::LIQUID_XP) + } + + private val xpProps = makeXpProps() + + val LIQUID_XP_TYPE: FluidType by types.register("liquid_xp") { + object : FluidType( + Properties.create() + .rarity(Rarity.UNCOMMON) + .canDrown(true) + .canExtinguish(false) + .canSwim(true) + .canHydrate(false) + .canPushEntity(true) + .canConvertToSource(false) + .fallDistanceModifier(0f) + .sound(SoundActions.BUCKET_FILL, SoundEvents.BUCKET_FILL) + .sound(SoundActions.BUCKET_EMPTY, SoundEvents.BUCKET_EMPTY) + .sound(SoundActions.FLUID_VAPORIZE, SoundEvents.FIRE_EXTINGUISH) + .descriptionId("block.overdrive_that_matters.liquid_xp") + ) { + override fun initializeClient(consumer: Consumer) { + val path = ResourceLocation(OverdriveThatMatters.MOD_ID, "block/ph_kitty") + + consumer.accept(object : IClientFluidTypeExtensions { + override fun getStillTexture(): ResourceLocation { + return path + } + + override fun getFlowingTexture(): ResourceLocation { + return path + } + }) + } + } + } + + val LIQUID_XP: ForgeFlowingFluid.Source by fluids.register("liquid_xp") { ForgeFlowingFluid.Source(xpProps) } + val LIQUID_XP_FLOWING: ForgeFlowingFluid.Flowing by fluids.register("liquid_xp_flowing") { ForgeFlowingFluid.Flowing(xpProps) } +} 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 c914e5f4a..d9cffe638 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -290,6 +290,7 @@ object MItems { val FLUID_CAPSULE: FluidCapsuleItem by registry.register("fluid_capsule") { FluidCapsuleItem(ItemsConfig::FLUID_CAPSULE_CAPACITY) } val FLUID_TANK: FluidTankItem by registry.register(MNames.FLUID_TANK) { FluidTankItem(MBlocks.FLUID_TANK, Item.Properties().stacksTo(1), ItemsConfig::FLUID_TANK_CAPACITY) } + val LIQUID_XP_BUCKET: BucketItem by registry.register("liquid_xp_bucket") { BucketItem(MFluids::LIQUID_XP, Item.Properties().stacksTo(1).rarity(Rarity.UNCOMMON)) } val TRITANIUM_COMPONENT: ForgeTier = ForgeTier( Tiers.IRON.level, 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 c54781d2f..0555c6d59 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -275,6 +275,7 @@ object MRegistry { IMatterFunction.register(bus) MBlocks.register(bus) + MFluids.register(bus) MBlockEntities.register(bus) MEntityTypes.register(bus) MMenus.register(bus) From 8b7363b130e7e815ebc42cc813c818370f146a26 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 23 Dec 2023 16:00:27 +0700 Subject: [PATCH 1124/1199] Remove parchment from buildscript --- build.gradle.kts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 4d2028a73..9426d470c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,4 @@ -import groovy.lang.Closure + import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import java.util.Date import java.text.SimpleDateFormat @@ -6,7 +6,6 @@ import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream val mod_version: String by project val mc_version: String by project -val parchment_version: String by project val forge_version: String by project val mod_id: String by project val handle_deps: String by project From a5dcf5a33186e9c973066286221f7f702c3cf6be Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 23 Dec 2023 19:42:38 +0700 Subject: [PATCH 1125/1199] Fix field synchronizer set not reacting properly to global markDirty() --- .../otm/capability/MatteryPlayerCapability.kt | 12 ++++-- .../network/synchronizer/FieldSynchronizer.kt | 37 +++++++++++++++++-- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 3b9a19e89..a279abffd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -1546,8 +1546,11 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } fun onPlayerChangeDimensionEvent(event: PlayerEvent.PlayerChangedDimensionEvent) { - event.entity.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresentK { - it.invalidateNetworkState() + onceServer { + event.entity.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresentK { + it.invalidateNetworkState() + it.recreateExoPackMenu() + } } } @@ -1604,8 +1607,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial it.invalidateNetworkState() event.original.invalidateCaps() - if (SERVER_IS_LIVE) { - it.tickList.timer(20) { + onceServer { + event.entity.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresentK { + it.invalidateNetworkState() it.recreateExoPackMenu() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt index c8140a121..c9dd51db8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/synchronizer/FieldSynchronizer.kt @@ -1700,6 +1700,36 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa super.remove() } + override fun markDirty() { + check(!isRemoved) { "Field was removed" } + + if (isRemote || endpoints.isEmpty()) + return + + isDirty = true + + val endpoints = LinkedList Unit>>>() + + forEachEndpoint { + endpoints.add(it.getSetBacklog(this)) + it.addDirtyField(this) + } + + endpoints.forEach { + it.clear() + it.add(null to ClearBacklogEntry) + } + + for (value in backingSet) { + val valueCopy = codec.copy(value) + val pair: Pair Unit> = valueCopy to { it.write(ChangesetAction.ADD.ordinal + 1); codec.write(it, valueCopy) } + + endpoints.forEach { + it.add(pair) + } + } + } + override fun markDirty(endpoint: Endpoint) { super.markDirty(endpoint) @@ -1708,7 +1738,8 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa it.add(null to ClearBacklogEntry) for (value in backingSet) { - it.add(value to { it.write(ChangesetAction.ADD.ordinal + 1); codec.write(it, value) }) + val valueCopy = codec.copy(value) + it.add(valueCopy to { it.write(ChangesetAction.ADD.ordinal + 1); codec.write(it, valueCopy) }) } } } @@ -1950,14 +1981,14 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa for ((key, value) in backingMap) { val valueCopy = valueCodec.copy(value) - val action = { it: DataOutputStream -> + val action = key to { it: DataOutputStream -> it.write(ChangesetAction.ADD.ordinal + 1) keyCodec.write(it, key) valueCodec.write(it, valueCopy) } for (backlog in backlogs) { - backlog.add(key to action) + backlog.add(action) } } } From d7c5b7609847a02a6fd6d6f0e2174c7d49cbc598 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 25 Dec 2023 11:40:15 +0700 Subject: [PATCH 1126/1199] Bump required kotlin to 1.9 --- src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index 4102cf615..cbb6c61c9 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -89,8 +89,8 @@ public final class OverdriveThatMatters { } private static void checkIfKotlinIsInstalled() { - if (!KotlinVersion.CURRENT.isAtLeast(1, 8, 0)) { - throw new UnsupportedClassVersionError("Installed kotlin version is " + KotlinVersion.CURRENT + ", when at least 1.8.0 is required."); + if (!KotlinVersion.CURRENT.isAtLeast(1, 9, 0)) { + throw new UnsupportedClassVersionError("Installed kotlin version is " + KotlinVersion.CURRENT + ", when at least 1.9.0 is required."); } } From 93942161ad8e032b4446be3233f82117e920f48a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 28 Dec 2023 15:03:13 +0700 Subject: [PATCH 1127/1199] Fold cables block code --- .../ru/dbotthepony/mc/otm/block/Cables.kt | 275 +++--------------- .../capability/drive/AbstractMatteryDrive.kt | 2 +- 2 files changed, 45 insertions(+), 232 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt index 97a7f8a71..f79fe47de 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.block +import com.google.common.collect.ImmutableMap import net.minecraft.core.BlockPos import net.minecraft.core.Direction import net.minecraft.world.level.BlockGetter @@ -20,7 +21,6 @@ import net.minecraft.world.phys.shapes.Shapes import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.entity.MatterCableBlockEntity import ru.dbotthepony.mc.otm.block.entity.StorageCableBlockEntity -import ru.dbotthepony.mc.otm.core.math.BlockRotation import java.util.Collections import java.util.EnumMap @@ -48,6 +48,39 @@ abstract class CableBlock(properties: Properties) : Block(properties) { ) } + protected fun generateShapes(halfCoreSize: Double): ImmutableMap { + val core = Shapes.box(0.5 - halfCoreSize, 0.5 - halfCoreSize, 0.5 - halfCoreSize, 0.5 + halfCoreSize, 0.5 + halfCoreSize, 0.5 + halfCoreSize) + + return getShapeForEachState { + val shapes = ArrayList() + + if (it.getValue(CONNECTION_SOUTH)) + shapes.add(Shapes.box(0.5 - halfCoreSize, 0.5 - halfCoreSize, 0.5 + halfCoreSize, 0.5 + halfCoreSize, 0.5 + halfCoreSize, 1.0)) + + if (it.getValue(CONNECTION_NORTH)) + shapes.add(Shapes.box(0.5 - halfCoreSize, 0.5 - halfCoreSize, 0.0, 0.5 + halfCoreSize, 0.5 + halfCoreSize, 0.5 - halfCoreSize)) + + if (it.getValue(CONNECTION_DOWN)) + shapes.add(Shapes.box(0.5 - halfCoreSize, 0.0, 0.5 - halfCoreSize, 0.5 + halfCoreSize, 0.5 - halfCoreSize, 0.5 + halfCoreSize)) + + if (it.getValue(CONNECTION_UP)) + shapes.add(Shapes.box(0.5 - halfCoreSize, 0.5 - halfCoreSize, 0.5 - halfCoreSize, 0.5 + halfCoreSize, 1.0, 0.5 + halfCoreSize)) + + if (it.getValue(CONNECTION_EAST)) + shapes.add(Shapes.box(0.5 + halfCoreSize, 0.5 - halfCoreSize, 0.5 - halfCoreSize, 1.0, 0.5 + halfCoreSize, 0.5 + halfCoreSize)) + + if (it.getValue(CONNECTION_WEST)) + shapes.add(Shapes.box(0.0, 0.5 - halfCoreSize, 0.5 - halfCoreSize, 0.5 - halfCoreSize, 0.5 + halfCoreSize, 0.5 + halfCoreSize)) + + var finalShape = core + + for (shape in shapes) + finalShape = Shapes.join(finalShape, shape, BooleanOp.OR) + + return@getShapeForEachState finalShape + } + } + companion object { val CONNECTION_SOUTH: BooleanProperty = BooleanProperty.create("connect_south") val CONNECTION_WEST: BooleanProperty = BooleanProperty.create("connect_west") @@ -56,7 +89,7 @@ abstract class CableBlock(properties: Properties) : Block(properties) { val CONNECTION_UP: BooleanProperty = BooleanProperty.create("connect_up") val CONNECTION_DOWN: BooleanProperty = BooleanProperty.create("connect_down") - val MAPPING_CONNECTION_PROP: Map = EnumMap(Direction::class.java) + val MAPPING_CONNECTION_PROP: Map = Collections.unmodifiableMap(EnumMap(Direction::class.java) .let { it[Direction.DOWN] = CONNECTION_DOWN it[Direction.UP] = CONNECTION_UP @@ -65,121 +98,16 @@ abstract class CableBlock(properties: Properties) : Block(properties) { it[Direction.WEST] = CONNECTION_WEST it[Direction.EAST] = CONNECTION_EAST Collections.unmodifiableMap(it) - } + }) } } -class MatterCableBlock : CableBlock( - Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), - EntityBlock { - private val CORE_SHAPE: VoxelShape = Shapes.box( - 0.5 - 0.15, - 0.5 - 0.15, - 0.5 - 0.15, - 0.5 + 0.15, - 0.5 + 0.15, - 0.5 + 0.15 - ) - - private val shapes = getShapeForEachState { - val shapes = ArrayList() - val width = 0.15 - - if (it.getValue(CONNECTION_SOUTH)) { - shapes.add( - Shapes.box( - 0.5 - width, - 0.5 - width, - 0.5 + width, - 0.5 + width, - 0.5 + width, - 1.0 - ) - ) - } - - if (it.getValue(CONNECTION_NORTH)) { - shapes.add( - Shapes.box( - 0.5 - width, - 0.5 - width, - 0.0, - 0.5 + width, - 0.5 + width, - 0.5 - width - ) - ) - } - - if (it.getValue(CONNECTION_DOWN)) { - shapes.add( - Shapes.box( - 0.5 - width, - 0.0, - 0.5 - width, - 0.5 + width, - 0.5 - width, - 0.5 + width - ) - ) - } - - if (it.getValue(CONNECTION_UP)) { - shapes.add( - Shapes.box( - 0.5 - width, - 0.5 - width, - 0.5 - width, - 0.5 + width, - 1.0, - 0.5 + width - ) - ) - } - - if (it.getValue(CONNECTION_EAST)) { - shapes.add( - Shapes.box( - 0.5 + width, - 0.5 - width, - 0.5 - width, - 1.0, - 0.5 + width, - 0.5 + width - ) - ) - } - - if (it.getValue(CONNECTION_WEST)) { - shapes.add( - Shapes.box( - 0.0, - 0.5 - width, - 0.5 - width, - 0.5 - width, - 0.5 + width, - 0.5 + width - ) - ) - } - - var finalShape = CORE_SHAPE - - for (add_shape in shapes) { - finalShape = Shapes.joinUnoptimized(finalShape, add_shape, BooleanOp.OR) - } - - return@getShapeForEachState finalShape - } +class MatterCableBlock : CableBlock(Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock { + private val shapes = generateShapes(0.15) @Suppress("OVERRIDE_DEPRECATION") - override fun getShape( - p_60555_: BlockState, - p_60556_: BlockGetter, - p_60557_: BlockPos, - p_60558_: CollisionContext - ): VoxelShape { - return shapes[p_60555_] ?: CORE_SHAPE + override fun getShape(blockState: BlockState, accessor: BlockGetter, pos: BlockPos, context: CollisionContext): VoxelShape { + return shapes[blockState] ?: Shapes.block() } override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { @@ -187,127 +115,12 @@ class MatterCableBlock : CableBlock( } } -class StorageCableBlock : CableBlock( - Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), - EntityBlock { - - companion object { - val CORE_SHAPE: VoxelShape = Shapes.box( - 0.5 - 0.185, - 0.5 - 0.185, - 0.5 - 0.185, - 0.5 + 0.185, - 0.5 + 0.185, - 0.5 + 0.185 - ) - - private const val width = 0.185 - - fun getShapeFor(it: BlockState): MutableList { - val shapes = ArrayList() - - if (it.getValue(CONNECTION_SOUTH)) { - shapes.add( - Shapes.box( - 0.5 - width, - 0.5 - width, - 0.5 + width, - 0.5 + width, - 0.5 + width, - 1.0 - ) - ) - } - - if (it.getValue(CONNECTION_NORTH)) { - shapes.add( - Shapes.box( - 0.5 - width, - 0.5 - width, - 0.0, - 0.5 + width, - 0.5 + width, - 0.5 - width - ) - ) - } - - if (it.getValue(CONNECTION_DOWN)) { - shapes.add( - Shapes.box( - 0.5 - width, - 0.0, - 0.5 - width, - 0.5 + width, - 0.5 - width, - 0.5 + width - ) - ) - } - - if (it.getValue(CONNECTION_UP)) { - shapes.add( - Shapes.box( - 0.5 - width, - 0.5 - width, - 0.5 - width, - 0.5 + width, - 1.0, - 0.5 + width - ) - ) - } - - if (it.getValue(CONNECTION_EAST)) { - shapes.add( - Shapes.box( - 0.5 + width, - 0.5 - width, - 0.5 - width, - 1.0, - 0.5 + width, - 0.5 + width - ) - ) - } - - if (it.getValue(CONNECTION_WEST)) { - shapes.add( - Shapes.box( - 0.0, - 0.5 - width, - 0.5 - width, - 0.5 - width, - 0.5 + width, - 0.5 + width - ) - ) - } - - shapes.add(CORE_SHAPE) - return shapes - } - } - - private val shapes = getShapeForEachState { - val shapes = getShapeFor(it) - var finalShape = shapes[0] - - for (i in 1 until shapes.size) { - finalShape = Shapes.joinUnoptimized(finalShape, shapes[i], BooleanOp.OR) - } - - return@getShapeForEachState finalShape - } +class StorageCableBlock : CableBlock(Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock { + private val shapes = generateShapes(0.185) @Suppress("OVERRIDE_DEPRECATION") - override fun getShape( - p_60555_: BlockState, - p_60556_: BlockGetter, - p_60557_: BlockPos, - p_60558_: CollisionContext - ): VoxelShape { - return shapes[p_60555_] ?: CORE_SHAPE + override fun getShape(blockState: BlockState, accessor: BlockGetter, pos: BlockPos, context: CollisionContext): VoxelShape { + return shapes[blockState] ?: Shapes.block() } override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/AbstractMatteryDrive.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/AbstractMatteryDrive.kt index 1bce3faba..4d506a470 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/AbstractMatteryDrive.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/drive/AbstractMatteryDrive.kt @@ -21,7 +21,7 @@ import java.math.BigInteger import java.util.ArrayList import java.util.stream.Stream -abstract class AbstractMatteryDrive> @JvmOverloads constructor( +abstract class AbstractMatteryDrive>( override var driveCapacity: BigInteger, override val uuid: UUID = UUID.randomUUID(), var maxDifferentStacks: Int = 0xFFFF From 6784271ac77b365000a6fef3bd6da728243b9bd5 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 28 Dec 2023 19:59:15 +0700 Subject: [PATCH 1128/1199] Fix shapegen for storage bus --- .../ru/dbotthepony/mc/otm/block/Cables.kt | 12 +++++----- .../mc/otm/block/storage/StorageBusBlock.kt | 11 +--------- .../mc/otm/block/storage/StorageInterfaces.kt | 22 ++----------------- 3 files changed, 9 insertions(+), 36 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt index f79fe47de..9adb59906 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt @@ -49,9 +49,11 @@ abstract class CableBlock(properties: Properties) : Block(properties) { } protected fun generateShapes(halfCoreSize: Double): ImmutableMap { - val core = Shapes.box(0.5 - halfCoreSize, 0.5 - halfCoreSize, 0.5 - halfCoreSize, 0.5 + halfCoreSize, 0.5 + halfCoreSize, 0.5 + halfCoreSize) + return getShapeForEachState { getShapeFor(it, halfCoreSize) } + } - return getShapeForEachState { + companion object { + fun getShapeFor(it: BlockState, halfCoreSize: Double): VoxelShape { val shapes = ArrayList() if (it.getValue(CONNECTION_SOUTH)) @@ -72,16 +74,14 @@ abstract class CableBlock(properties: Properties) : Block(properties) { if (it.getValue(CONNECTION_WEST)) shapes.add(Shapes.box(0.0, 0.5 - halfCoreSize, 0.5 - halfCoreSize, 0.5 - halfCoreSize, 0.5 + halfCoreSize, 0.5 + halfCoreSize)) - var finalShape = core + var finalShape = Shapes.box(0.5 - halfCoreSize, 0.5 - halfCoreSize, 0.5 - halfCoreSize, 0.5 + halfCoreSize, 0.5 + halfCoreSize, 0.5 + halfCoreSize) for (shape in shapes) finalShape = Shapes.join(finalShape, shape, BooleanOp.OR) - return@getShapeForEachState finalShape + return finalShape } - } - companion object { val CONNECTION_SOUTH: BooleanProperty = BooleanProperty.create("connect_south") val CONNECTION_WEST: BooleanProperty = BooleanProperty.create("connect_west") val CONNECTION_EAST: BooleanProperty = BooleanProperty.create("connect_east") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt index 1fb0b65d7..73e66b896 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt @@ -90,16 +90,7 @@ class StorageBusBlock : RotatableMatteryBlock(), EntityBlock { } private val shapes = getShapeForEachState { - val shapes = StorageCableBlock.getShapeFor(it) - var finalShape = shapes[0] - - for (i in 1 until shapes.size) { - finalShape = Shapes.joinUnoptimized(finalShape, shapes[i], BooleanOp.OR) - } - - finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_BUS.rotateFromNorth(it[rotationProperty]).computeShape(), BooleanOp.OR) - - return@getShapeForEachState finalShape + Shapes.joinUnoptimized(CableBlock.getShapeFor(it, 0.185), BlockShapes.STORAGE_BUS.rotateFromNorth(it[rotationProperty]).computeShape(), BooleanOp.OR) } @Suppress("OVERRIDE_DEPRECATION") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt index 54ee44c87..bf45778be 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt @@ -91,16 +91,7 @@ class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock { } private val shapes = getShapeForEachState { - val shapes = StorageCableBlock.getShapeFor(it) - var finalShape = shapes[0] - - for (i in 1 until shapes.size) { - finalShape = Shapes.joinUnoptimized(finalShape, shapes[i], BooleanOp.OR) - } - - finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_IMPORTER.rotateFromNorth(it[rotationProperty]).computeShape(), BooleanOp.OR) - - return@getShapeForEachState finalShape + Shapes.joinUnoptimized(CableBlock.getShapeFor(it, 0.185), BlockShapes.STORAGE_IMPORTER.rotateFromNorth(it[rotationProperty]).computeShape(), BooleanOp.OR) } @Suppress("OVERRIDE_DEPRECATION") @@ -173,16 +164,7 @@ class StorageExporterBlock : RotatableMatteryBlock(), EntityBlock { } private val shapes = getShapeForEachState { - val shapes = StorageCableBlock.getShapeFor(it) - var finalShape = shapes[0] - - for (i in 1 until shapes.size) { - finalShape = Shapes.joinUnoptimized(finalShape, shapes[i], BooleanOp.OR) - } - - finalShape = Shapes.joinUnoptimized(finalShape, BlockShapes.STORAGE_EXPORTER.rotateFromNorth(it[rotationProperty]).computeShape(), BooleanOp.OR) - - return@getShapeForEachState finalShape + Shapes.joinUnoptimized(CableBlock.getShapeFor(it, 0.185), BlockShapes.STORAGE_EXPORTER.rotateFromNorth(it[rotationProperty]).computeShape(), BooleanOp.OR) } @Suppress("OVERRIDE_DEPRECATION") From f13c725298ab106732e31725b12ac790660ca9fe Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 28 Dec 2023 20:13:03 +0700 Subject: [PATCH 1129/1199] Concept of infinity, for Decimals --- .../dbotthepony/mc/otm/core/math/Decimal.kt | 1792 ++++++++++++----- .../mc/otm/core/util/Formatting.kt | 2 + .../dbotthepony/mc/otm/core/util/SiPrefix.kt | 2 +- 3 files changed, 1326 insertions(+), 470 deletions(-) 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 3c1c12f09..1df81a457 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 @@ -26,44 +26,28 @@ fun Decimal(value: Byte) = Decimal.valueOf(value) fun Decimal(value: Short) = Decimal.valueOf(value) fun Decimal(value: Int) = Decimal.valueOf(value) fun Decimal(value: Long) = Decimal.valueOf(value) +fun Decimal(value: Float) = Decimal.valueOf(value) +fun Decimal(value: Double) = Decimal.valueOf(value) +fun Decimal(value: BigDecimal) = Decimal.valueOf(value) +fun Decimal(value: BigInteger) = Decimal.valueOf(value) +fun Decimal(value: String) = Decimal.valueOf(value) /** * Fixed point arbitrary precision Decimal value. Values of this class embed [BigInteger] unscaled value, scale * is defined at compile time by [PRECISION]. */ -class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Number(), Comparable { - constructor(value: BigInteger) : this(value * PRECISION_POW_BI, null) - constructor(value: BigDecimal) : this(value.setScale(PRECISION, RoundingMode.HALF_UP).unscaledValue(), null) - constructor(value: Float) : this(BigDecimal.valueOf(value.toDouble())) - constructor(value: Double) : this(BigDecimal(value)) - constructor(value: String) : this(BigDecimal(value)) - - private var _whole: BigInteger? = null - private var _fractional: BigInteger? = null - - private fun computeWholeFractional(): BigInteger { - val (a, b) = mag.divideAndRemainder(PRECISION_POW_BI) - _whole = a - _fractional = b - return a - } - +sealed class Decimal : Number(), Comparable { /** * Whole part of this Decimal */ - val whole: BigInteger get() { - return _whole ?: computeWholeFractional() - } + abstract val whole: BigInteger /** * Arbitrary fractional part of this Decimal, as [BigInteger] * * Makes sense only when utilized along [PRECISION], [PRECISION_POW], [PRECISION_POW_BI] */ - val fractional: BigInteger get() { - if (_fractional == null) computeWholeFractional() - return _fractional!! - } + abstract val fractional: BigInteger /** * *Signed* normalized (-1,1) fractional part of this Decimal, as [Float] @@ -79,349 +63,50 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe return fractional.toDouble() / PRECISION_DOUBLE } - override fun compareTo(other: Decimal): Int { - return mag.compareTo(other.mag) - } + abstract operator fun plus(other: Decimal): Decimal + abstract operator fun minus(other: Decimal): Decimal + abstract operator fun times(other: Decimal): Decimal + abstract operator fun div(other: Decimal): Decimal - override fun toByte(): Byte { - return whole.toByte() - } - - override fun toChar(): Char { - return whole.toChar() - } - - override fun toDouble(): Double { - return mag.toDouble() / PRECISION_DOUBLE - } - - override fun toFloat(): Float { - return mag.toFloat() / PRECISION_FLOAT - } - - override fun toInt(): Int { - if (whole > BI_INT_MAX) { - return Int.MAX_VALUE - } else if (whole < BI_INT_MIN) { - return Int.MIN_VALUE - } else { - return whole.toInt() - } - } - - override fun toLong(): Long { - if (whole > BI_LONG_MAX) { - return Long.MAX_VALUE - } else if (whole < BI_LONG_MIN) { - return Long.MIN_VALUE - } else { - return whole.toLong() - } - } - - override fun toShort(): Short { - return whole.toShort() - } - - operator fun plus(other: Decimal): Decimal { - if (other.mag.signum() == 0) { - return this - } - - return Decimal(mag + other.mag, null) - } - - operator fun minus(other: Decimal): Decimal { - if (other.mag.signum() == 0) { - return this - } - - return Decimal(mag - other.mag, null) - } - - operator fun times(other: Decimal): Decimal { - if (other.mag.signum() == 0) { - return ZERO - } else if (other == ONE) { - return this - } else if (other == MINUS_ONE) { - return Decimal(-mag, null) - } - - val result = mag * other.mag - val (a, b) = result.divideAndRemainder(PRECISION_POW_BI) - - if (b >= PRECISION_POW_BI_HIGH) { - return Decimal(a + BigInteger.ONE, null) - } else { - return Decimal(a, null) - } - } - - operator fun div(other: Decimal): Decimal { - if (other.mag.signum() == 0) { - throw ArithmeticException("Attempt to divide $this by zero") - } else if (other == ONE) { - return this - } else if (other == MINUS_ONE) { - return Decimal(-mag, null) - } - - return Decimal((mag * PRECISION_POW_BI) / other.mag, null) - } - - operator fun rem(other: Decimal): Decimal { - return Decimal(mag % other.mag, null) - } + abstract operator fun rem(other: Decimal): Decimal // Primitive operators - operator fun plus(other: Float): Decimal { - if (other == 0f) { - return this - } else if (other.isNaN()) { - throw ArithmeticException("Attempt to add NaN to $this") - } else if (other.isInfinite()) { - throw ArithmeticException("Attempt to add infinity to $this") - } + abstract operator fun plus(other: Float): Decimal + abstract operator fun minus(other: Float): Decimal + abstract operator fun times(other: Float): Decimal + abstract operator fun div(other: Float): Decimal - return plus(Decimal(other)) - } + abstract operator fun plus(other: Double): Decimal + abstract operator fun minus(other: Double): Decimal + abstract operator fun times(other: Double): Decimal + abstract operator fun div(other: Double): Decimal - operator fun minus(other: Float): Decimal { - if (other == 0f) { - return this - } else if (other.isNaN()) { - throw ArithmeticException("Attempt to subtract NaN from $this") - } else if (other.isInfinite()) { - throw ArithmeticException("Attempt to subtract infinity from $this") - } + abstract operator fun plus(other: Int): Decimal + abstract operator fun minus(other: Int): Decimal + abstract operator fun times(other: Int): Decimal + abstract operator fun div(other: Int): Decimal - return minus(Decimal(other)) - } + abstract operator fun plus(other: Long): Decimal + abstract operator fun minus(other: Long): Decimal + abstract operator fun times(other: Long): Decimal + abstract operator fun div(other: Long): Decimal - operator fun times(other: Float): Decimal { - if (other == 1f) { - return this - } else if (other == 0f || isZero) { - return ZERO - } else if (other == -1f) { - return -this - } else if (other.isNaN()) { - throw ArithmeticException("Attempt to multiply $this by NaN") - } else if (other.isInfinite()) { - throw ArithmeticException("Attempt to multiply $this by infinity") - } - - return times(Decimal(other)) - } - - operator fun div(other: Float): Decimal { - if (other == 0f) { - throw ArithmeticException("Attempt to divide $this by zero") - } else if (other == 1f || isZero) { - return this - } else if (other == -1f) { - return -this - } else if (other.isNaN()) { - throw ArithmeticException("Attempt to divide $this by NaN") - } else if (other.isInfinite()) { - throw ArithmeticException("Attempt to divide $this by infinity") - } - - return div(Decimal(other)) - } - - operator fun plus(other: Double): Decimal { - if (other == 0.0) { - return this - } else if (other.isNaN()) { - throw ArithmeticException("Attempt to add NaN to $this") - } else if (other.isInfinite()) { - throw ArithmeticException("Attempt to add infinity to $this") - } - - return plus(Decimal(other)) - } - - operator fun minus(other: Double): Decimal { - if (other == 0.0) { - return this - } else if (other.isNaN()) { - throw ArithmeticException("Attempt to subtract NaN from $this") - } else if (other.isInfinite()) { - throw ArithmeticException("Attempt to subtract infinity from $this") - } - - return minus(Decimal(other)) - } - - operator fun times(other: Double): Decimal { - if (other == 1.0) { - return this - } else if (other == 0.0 || isZero) { - return ZERO - } else if (other == -1.0) { - return -this - } else if (other.isNaN()) { - throw ArithmeticException("Attempt to multiply $this by NaN") - } else if (other.isInfinite()) { - throw ArithmeticException("Attempt to multiply $this by infinity") - } - - return times(Decimal(other)) - } - - operator fun div(other: Double): Decimal { - if (other == 0.0) { - throw ArithmeticException("Attempt to divide $this by zero") - } else if (other == 1.0 || isZero) { - return this - } else if (other == -1.0) { - return -this - } else if (other.isNaN()) { - throw ArithmeticException("Attempt to divide $this by NaN") - } else if (other.isInfinite()) { - throw ArithmeticException("Attempt to divide $this by infinity") - } - - return div(Decimal(other)) - } - - operator fun plus(other: Int): Decimal { - if (other == 0) { - return this - } - - return plus(valueOf(other)) - } - - operator fun minus(other: Int): Decimal { - if (other == 0) { - return this - } - - return minus(valueOf(other)) - } - - operator fun times(other: Int): Decimal { - if (other == 1 || isZero) { - return this - } else if (other == 0) { - return ZERO - } else if (other == -1) { - return -this - } - - return times(valueOf(other)) - } - - operator fun div(other: Int): Decimal { - if (other == 0) { - throw ArithmeticException("Attempt to divide $this by zero") - } else if (other == 1 || signum() == 0) { - return this - } else if (other == -1) { - return -this - } - - return div(valueOf(other)) - } - - operator fun plus(other: Long): Decimal { - if (other == 0L) { - return this - } - - return plus(valueOf(other)) - } - - operator fun minus(other: Long): Decimal { - if (other == 0L) { - return this - } - - return minus(valueOf(other)) - } - - operator fun times(other: Long): Decimal { - if (other == 1L || isZero) { - return this - } else if (other == 0L) { - return ZERO - } else if (other == -1L) { - return -this - } - - return times(valueOf(other)) - } - - operator fun div(other: Long): Decimal { - if (other == 0L) { - throw ArithmeticException("Attempt to divide $this by zero") - } else if (other == 1L || isZero) { - return this - } else if (other == -1L) { - return -this - } - - return div(valueOf(other)) - } - - operator fun plus(other: BigInteger): Decimal { - if (other == BigInteger.ZERO) { - return this - } - - return plus(Decimal(other)) - } - - operator fun minus(other: BigInteger): Decimal { - if (other == BigInteger.ZERO) { - return this - } - - return minus(Decimal(other)) - } - - operator fun times(other: BigInteger): Decimal { - if (other == BigInteger.ONE) { - return this - } else if (other.signum() == 0 || isZero) { - return ZERO - } else if (other == BI_MINUS_ONE) { - return -this - } - - return times(Decimal(other)) - } - - operator fun div(other: BigInteger): Decimal { - if (other == BigInteger.ZERO) { - throw ArithmeticException("Attempt to divide $this by zero") - } else if (other == BigInteger.ONE || isZero) { - return this - } else if (other == BI_MINUS_ONE) { - return -this - } - - return div(Decimal(other)) - } + abstract operator fun plus(other: BigInteger): Decimal + abstract operator fun minus(other: BigInteger): Decimal + abstract operator fun times(other: BigInteger): Decimal + abstract operator fun div(other: BigInteger): Decimal // /Primitive operators - operator fun unaryMinus(): Decimal { - if (mag == BigInteger.ZERO) { - return this - } - - return Decimal(-mag, null) - } + // "de-virtualize" generic method + abstract override fun compareTo(other: Decimal): Int + abstract operator fun unaryMinus(): Decimal operator fun unaryPlus() = this /** * Sign number of this Decimal, as defined by [BigInteger.signum] */ - fun signum() = mag.signum() + abstract fun signum(): Int /** * Whenever this Decimal is negative (less than zero) @@ -438,6 +123,9 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe */ inline val isZero get() = signum() == 0 + abstract val isInfinite: Boolean + abstract val isFinite: Boolean + /** * Alias for [coerceAtLeast] with [ZERO] constant, except this method might * perform faster. @@ -446,7 +134,7 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe if (signum() >= 0) return this - return ZERO + return Zero } /** @@ -457,12 +145,10 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe if (signum() <= 0) return this - return ZERO + return Zero } - fun toByteArray(): ByteArray { - return mag.toByteArray() - } + abstract fun toByteArray(): ByteArray fun serializeNBT(): Tag { return ByteArrayTag(toByteArray()) @@ -474,110 +160,1201 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe val absoluteValue: Decimal get() { - if (isNegative) { - return -this + return if (isNegative) { + -this } else { - return this + this } } /** * Truncates fractional part of this Decimal */ - fun floor(): Decimal { - return Decimal(whole) - } - - override fun equals(other: Any?): Boolean { - return this === other || other is Decimal && mag == other.mag - } - - override fun hashCode(): Int { - return mag.hashCode() - } - - fun toString(decimals: Int): String { - if (decimals == 0) { - return whole.toString() - } - - if (mag.signum() == 0) { - if (decimals < 0) { - return "0.0" - } else { - return "0." + "0".repeat(decimals) - } - } - - var original = mag.toString() - - if (mag.signum() < 0) { - // если у нас отрицательное число - убираем знак минуса - original = original.substring(1) - } - - if (original.length <= PRECISION) { - // если у нас чисто дробное число - дописываем нули в начало - original = "0".repeat(PRECISION - original.length + 1) + original - } - - // теперь у нас беззнаковая строка с нужной длиной - - if (decimals < 0) { - // нам неважно количество знаков после запятой - var result = original.substring(0, original.length - PRECISION) + "." + original.substring(original.length - PRECISION) - - if (mag.signum() < 0) { - result = "-$result" - } - - var pos = result.length - 1 - - while (result[pos] == '0') { - if (result[pos - 1] == '0' || result[pos - 1] != '.') - pos-- - else - break - } - - return result.substring(0, pos + 1) - } else { - // нужно некоторое количество знаков после запятой - val result = original.substring(0, original.length - PRECISION) + "." - var decimalPart = original.substring(original.length - PRECISION) - - if (decimalPart.length < decimals) { - decimalPart += "0".repeat(decimals - decimalPart.length) - } else if (decimalPart.length > decimals) { - decimalPart = decimalPart.substring(0, decimals) - } - - if (mag.signum() < 0) { - return "-$result$decimalPart" - } else { - return "$result$decimalPart" - } - } - } + abstract fun floor(): Decimal + abstract fun toString(decimals: Int): String override fun toString(): String = toString(-1) - fun toBigDecmial(): BigDecimal { - return BigDecimal(mag, PRECISION) - } + abstract fun toBigDecmial(): BigDecimal - fun percentage(divisor: Decimal, zeroing: Boolean = true): Float { - if ((isZero || divisor.isZero) && zeroing) return 0f + fun percentage(divisor: Decimal): Float { + if (isZero || divisor.isZero) return 0f if (this >= divisor) return 1f - - if (this <= FLOAT_MAX_VALUE && divisor <= FLOAT_MAX_VALUE) + else if (this <= FLOAT_MAX_VALUE && divisor <= FLOAT_MAX_VALUE) return (toDouble() / divisor.toDouble()).toFloat() + else if (divisor === PositiveInfinity || divisor === NegativeInfinity) + return 0f return toBigDecmial().divide(divisor.toBigDecmial(), PERCENTAGE_CONTEXT).toFloat() } + private class Regular(val mag: BigInteger, marker: Nothing?) : Decimal() { + constructor(value: BigInteger) : this(value * PRECISION_POW_BI, null) + constructor(value: BigDecimal) : this(value.setScale(PRECISION, RoundingMode.HALF_UP).unscaledValue(), null) + constructor(value: Float) : this(BigDecimal.valueOf(value.toDouble())) + constructor(value: Double) : this(BigDecimal(value)) + constructor(value: String) : this(BigDecimal(value)) + + override val isInfinite: Boolean + get() = false + override val isFinite: Boolean + get() = true + + private var _whole: BigInteger? = null + private var _fractional: BigInteger? = null + + private fun computeWholeFractional(): BigInteger { + val (a, b) = mag.divideAndRemainder(PRECISION_POW_BI) + _whole = a + _fractional = b + return a + } + + override val whole: BigInteger get() { + return _whole ?: computeWholeFractional() + } + + override val fractional: BigInteger get() { + if (_fractional == null) computeWholeFractional() + return _fractional!! + } + + override fun toDouble(): Double { + return mag.toDouble() / PRECISION_DOUBLE + } + + override fun toFloat(): Float { + return mag.toFloat() / PRECISION_FLOAT + } + + override fun toByte(): Byte { + return whole.toByte() + } + + override fun toShort(): Short { + return whole.toShort() + } + + override fun signum(): Int { + return mag.signum() + } + + override fun toInt(): Int { + return if (whole > BI_INT_MAX) { + Int.MAX_VALUE + } else if (whole < BI_INT_MIN) { + Int.MIN_VALUE + } else { + whole.toInt() + } + } + + override fun toLong(): Long { + return if (whole > BI_LONG_MAX) { + Long.MAX_VALUE + } else if (whole < BI_LONG_MIN) { + Long.MIN_VALUE + } else { + whole.toLong() + } + } + + override fun compareTo(other: Decimal): Int { + return if (other is Regular) + mag.compareTo(other.mag) + else if (other === PositiveInfinity) + -1 + else if (other === NegativeInfinity) + 1 + else if (other === Zero) + signum() + else + throw RuntimeException("unreachable code") + } + + + override fun plus(other: Decimal): Decimal { + return if (other is Regular) { + raw(mag + other.mag) + } else if (other === Zero) { + this + } else if (other === PositiveInfinity) { + PositiveInfinity + } else if (other === NegativeInfinity) { + NegativeInfinity + } else { + throw RuntimeException("Unreachable code") + } + } + + override fun minus(other: Decimal): Decimal { + return if (other is Regular) { + raw(mag - other.mag) + } else if (other === Zero) { + this + } else if (other === PositiveInfinity) { + NegativeInfinity + } else if (other === NegativeInfinity) { + PositiveInfinity + } else { + throw RuntimeException("Unreachable code") + } + } + + override fun times(other: Decimal): Decimal { + if (other is Regular) { + if (other == ONE) { + return this + } else if (other == MINUS_ONE) { + return raw(-mag) + } + + val result = mag * other.mag + val (a, b) = result.divideAndRemainder(PRECISION_POW_BI) + + return if (b >= PRECISION_POW_BI_HIGH) { + raw(a + BigInteger.ONE) + } else { + raw(a) + } + } else if (other === Zero) { + return Zero + } else if (other === PositiveInfinity) { + return PositiveInfinity + } else if (other === NegativeInfinity) { + return NegativeInfinity + } else { + throw RuntimeException("Unreachable code") + } + } + + override fun div(other: Decimal): Decimal { + if (other is Regular) { + if (other == ONE) { + return this + } else if (other == MINUS_ONE) { + return raw(-mag) + } + + return raw((mag * PRECISION_POW_BI) / other.mag) + } else if (other === Zero) { + throw ArithmeticException("$this / 0") + } else if (other === PositiveInfinity || other === NegativeInfinity) { + return Zero + } else { + throw RuntimeException("Unreachable code") + } + } + + override fun rem(other: Decimal): Decimal { + return if (other is Regular) { + raw(mag % other.mag) + } else if (other === Zero) { + throw ArithmeticException("$this % 0") + } else if (other === PositiveInfinity) { + this + } else if (other === NegativeInfinity) { + -this + } else { + throw RuntimeException("Unreachable code") + } + } + + // Primitive operators + override fun plus(other: Float): Decimal { + if (other == 0f) { + return this + } else if (other.isNaN()) { + throw ArithmeticException("$this + NaN") + } else if (other == Float.POSITIVE_INFINITY) { + return PositiveInfinity + } else if (other == Float.NEGATIVE_INFINITY) { + return NegativeInfinity + } + + return plus(valueOf(other)) + } + + override fun minus(other: Float): Decimal { + if (other == 0f) { + return this + } else if (other.isNaN()) { + throw ArithmeticException("$this - NaN") + } else if (other == Float.POSITIVE_INFINITY) { + return NegativeInfinity + } else if (other == Float.NEGATIVE_INFINITY) { + return PositiveInfinity + } + + return minus(valueOf(other)) + } + + override fun times(other: Float): Decimal { + if (other == 1f) { + return this + } else if (other == 0f) { + return Zero + } else if (other == -1f) { + return -this + } else if (other.isNaN()) { + throw ArithmeticException("$this * NaN") + } else if (other == Float.POSITIVE_INFINITY) { + return if (signum() < 0) NegativeInfinity else PositiveInfinity + } else if (other == Float.NEGATIVE_INFINITY) { + return if (signum() < 0) PositiveInfinity else NegativeInfinity + } + + return times(valueOf(other)) + } + + override fun div(other: Float): Decimal { + if (other == 0f) { + throw ArithmeticException("$this / 0") + } else if (other == 1f) { + return this + } else if (other == -1f) { + return -this + } else if (other.isNaN()) { + throw ArithmeticException("$this / NaN") + } else if (other.isInfinite()) { + return Zero + } + + return div(valueOf(other)) + } + + override fun plus(other: Double): Decimal { + if (other == 0.0) { + return this + } else if (other.isNaN()) { + throw ArithmeticException("$this + NaN") + } else if (other == Double.POSITIVE_INFINITY) { + return PositiveInfinity + } else if (other == Double.NEGATIVE_INFINITY) { + return NegativeInfinity + } + + return plus(valueOf(other)) + } + + override fun minus(other: Double): Decimal { + if (other == 0.0) { + return this + } else if (other.isNaN()) { + throw ArithmeticException("$this - NaN") + } else if (other == Double.POSITIVE_INFINITY) { + return NegativeInfinity + } else if (other == Double.NEGATIVE_INFINITY) { + return PositiveInfinity + } + + return minus(valueOf(other)) + } + + override fun times(other: Double): Decimal { + if (other == 1.0) { + return this + } else if (other == 0.0) { + return Zero + } else if (other == -1.0) { + return -this + } else if (other.isNaN()) { + throw ArithmeticException("$this * NaN") + } else if (other == Double.POSITIVE_INFINITY) { + return if (signum() < 0) NegativeInfinity else PositiveInfinity + } else if (other == Double.NEGATIVE_INFINITY) { + return if (signum() < 0) PositiveInfinity else NegativeInfinity + } + + return times(valueOf(other)) + } + + override fun div(other: Double): Decimal { + if (other == 0.0) { + throw ArithmeticException("$this / zero") + } else if (other == 1.0) { + return this + } else if (other == -1.0) { + return -this + } else if (other.isNaN()) { + throw ArithmeticException("$this / NaN") + } else if (other.isInfinite()) { + return Zero + } + + return div(valueOf(other)) + } + + override fun plus(other: Int): Decimal { + if (other == 0) + return this + + return plus(valueOf(other)) + } + + override fun minus(other: Int): Decimal { + if (other == 0) + return this + + return minus(valueOf(other)) + } + + override fun times(other: Int): Decimal { + if (other == 1) { + return this + } else if (other == 0) { + return Zero + } else if (other == -1) { + return -this + } + + return times(valueOf(other)) + } + + override fun div(other: Int): Decimal { + if (other == 0) { + throw ArithmeticException("$this / 0") + } else if (other == 1) { + return this + } else if (other == -1) { + return -this + } + + return div(valueOf(other)) + } + + override fun plus(other: Long): Decimal { + if (other == 0L) + return this + + return plus(valueOf(other)) + } + + override fun minus(other: Long): Decimal { + if (other == 0L) + return this + + return minus(valueOf(other)) + } + + override fun times(other: Long): Decimal { + if (other == 1L) { + return this + } else if (other == 0L) { + return Zero + } else if (other == -1L) { + return -this + } + + return times(valueOf(other)) + } + + override fun div(other: Long): Decimal { + if (other == 0L) { + throw ArithmeticException("$this / 0") + } else if (other == 1L || isZero) { + return this + } else if (other == -1L) { + return -this + } + + return div(valueOf(other)) + } + + override fun plus(other: BigInteger): Decimal { + if (other == BigInteger.ZERO) + return this + + return plus(valueOf(other)) + } + + override fun minus(other: BigInteger): Decimal { + if (other == BigInteger.ZERO) + return this + + return minus(valueOf(other)) + } + + override fun times(other: BigInteger): Decimal { + if (other == BigInteger.ONE) { + return this + } else if (other.signum() == 0) { + return Zero + } else if (other == BI_MINUS_ONE) { + return -this + } + + return times(valueOf(other)) + } + + override fun div(other: BigInteger): Decimal { + if (other == BigInteger.ZERO) { + throw ArithmeticException("$this / 0") + } else if (other == BigInteger.ONE) { + return this + } else if (other == BI_MINUS_ONE) { + return -this + } + + return div(valueOf(other)) + } + // /Primitive operators + + override fun unaryMinus(): Decimal { + return Regular(-mag, null) + } + + override fun toByteArray(): ByteArray { + val result = mag.toByteArray() + val copy = ByteArray(result.size + 1) + copy[0] = TYPE_NORMAL + result.copyInto(copy, 1) + return copy + } + + override fun floor(): Decimal { + return Regular(whole) + } + + override fun toString(decimals: Int): String { + if (decimals == 0) { + return whole.toString() + } + + if (mag.signum() == 0) { + return if (decimals < 0) { + "0.0" + } else { + "0." + "0".repeat(decimals) + } + } + + var original = mag.toString() + + if (mag.signum() < 0) { + // если у нас отрицательное число - убираем знак минуса + original = original.substring(1) + } + + if (original.length <= PRECISION) { + // если у нас чисто дробное число - дописываем нули в начало + original = "0".repeat(PRECISION - original.length + 1) + original + } + + // теперь у нас беззнаковая строка с нужной длиной + + if (decimals < 0) { + // нам неважно количество знаков после запятой + var result = original.substring(0, original.length - PRECISION) + "." + original.substring(original.length - PRECISION) + + if (mag.signum() < 0) { + result = "-$result" + } + + var pos = result.length - 1 + + while (result[pos] == '0') { + if (result[pos - 1] == '0' || result[pos - 1] != '.') + pos-- + else + break + } + + return result.substring(0, pos + 1) + } else { + // нужно некоторое количество знаков после запятой + val result = original.substring(0, original.length - PRECISION) + "." + var decimalPart = original.substring(original.length - PRECISION) + + if (decimalPart.length < decimals) { + decimalPart += "0".repeat(decimals - decimalPart.length) + } else if (decimalPart.length > decimals) { + decimalPart = decimalPart.substring(0, decimals) + } + + return if (mag.signum() < 0) { + "-$result$decimalPart" + } else { + "$result$decimalPart" + } + } + } + + override fun toBigDecmial(): BigDecimal { + return BigDecimal(mag, PRECISION) + } + + override fun equals(other: Any?): Boolean { + return this === other || other is Regular && mag == other.mag + } + + override fun hashCode(): Int { + return mag.hashCode() + } + } + + private object PositiveInfinity : Decimal() { + private fun readResolve(): Any = PositiveInfinity + + override val isInfinite: Boolean + get() = true + override val isFinite: Boolean + get() = false + + override fun compareTo(other: Decimal): Int { + return if (other === this) 0 else 1 + } + + override fun toByte(): Byte { + return Byte.MAX_VALUE + } + + override fun toDouble(): Double { + return Double.POSITIVE_INFINITY + } + + override fun toFloat(): Float { + return Float.POSITIVE_INFINITY + } + + override fun toInt(): Int { + return Int.MAX_VALUE + } + + override fun toLong(): Long { + return Long.MAX_VALUE + } + + override fun toShort(): Short { + return Short.MAX_VALUE + } + + override val whole: BigInteger + get() = throw UnsupportedOperationException("Attempt to get whole part of positive infinity") + override val fractional: BigInteger + get() = throw UnsupportedOperationException("Attempt to get fractional part of positive infinity") + + override fun plus(other: Decimal): Decimal { + return this + } + + override fun minus(other: Decimal): Decimal { + return this + } + + override fun times(other: Decimal): Decimal { + return if (other.signum() == 0) + Zero + else if (other.signum() < 0) + NegativeInfinity + else + this + } + + override fun div(other: Decimal): Decimal { + return if (other.signum() == 0) + throw ArithmeticException("Attempt to divide positive infinity by zero") + else if (other === this) + throw ArithmeticException("Dividing positive infinity by itself is undefined") + else if (other === NegativeInfinity) + throw ArithmeticException("Dividing positive infinity by negative infinity is undefined") + else if (other.signum() < 0) + NegativeInfinity + else + this + } + + override fun rem(other: Decimal): Decimal { + return if (other.signum() == 0) + throw ArithmeticException("Attempt to remainder divide positive infinity by zero") + else if (other.signum() < 0) + NegativeInfinity + else + this + } + + override fun plus(other: Float): Decimal { + return this + } + + override fun minus(other: Float): Decimal { + return this + } + + override fun times(other: Float): Decimal { + return if (other == 0f) + Zero + else if (other < 0f) + NegativeInfinity + else + PositiveInfinity + } + + override fun div(other: Float): Decimal { + return if (other == 0f) + throw ArithmeticException("Attempt to divide positive infinity by zero") + else if (other < 0f) + NegativeInfinity + else + PositiveInfinity + } + + override fun plus(other: Double): Decimal { + return this + } + + override fun minus(other: Double): Decimal { + return this + } + + override fun times(other: Double): Decimal { + return if (other == 0.0) + Zero + else if (other < 0.0) + NegativeInfinity + else + PositiveInfinity + } + + override fun div(other: Double): Decimal { + return if (other == 0.0) + throw ArithmeticException("Attempt to divide positive infinity by zero") + else if (other < 0.0) + NegativeInfinity + else + PositiveInfinity + } + + override fun plus(other: Int): Decimal { + return this + } + + override fun minus(other: Int): Decimal { + return this + } + + override fun times(other: Int): Decimal { + return if (other == 0) + Zero + else if (other < 0) + NegativeInfinity + else + PositiveInfinity + } + + override fun div(other: Int): Decimal { + return if (other == 0) + throw ArithmeticException("Attempt to divide positive infinity by zero") + else if (other < 0) + NegativeInfinity + else + PositiveInfinity + } + + override fun plus(other: Long): Decimal { + return this + } + + override fun minus(other: Long): Decimal { + return this + } + + override fun times(other: Long): Decimal { + return if (other == 0L) + Zero + else if (other < 0L) + NegativeInfinity + else + PositiveInfinity + } + + override fun div(other: Long): Decimal { + return if (other == 0L) + throw ArithmeticException("Attempt to divide positive infinity by zero") + else if (other < 0L) + NegativeInfinity + else + PositiveInfinity + } + + override fun plus(other: BigInteger): Decimal { + return this + } + + override fun minus(other: BigInteger): Decimal { + return this + } + + override fun times(other: BigInteger): Decimal { + return if (other.signum() == 0) + Zero + else if (other.signum() < 0) + NegativeInfinity + else + PositiveInfinity + } + + override fun div(other: BigInteger): Decimal { + return if (other.signum() == 0) + throw ArithmeticException("Attempt to divide positive infinity by zero") + else if (other.signum() < 0) + NegativeInfinity + else + PositiveInfinity + } + + override fun unaryMinus(): Decimal { + return NegativeInfinity + } + + override fun signum(): Int { + return 1 + } + + override fun toByteArray(): ByteArray { + return byteArrayOf(TYPE_POSITIVE_INFINITY) + } + + override fun floor(): Decimal { + return this + } + + override fun toString(decimals: Int): String { + return "+Infinity" + } + + override fun toBigDecmial(): BigDecimal { + throw UnsupportedOperationException("Unable to construct BigDecimal of positive infinity") + } + } + + private object NegativeInfinity : Decimal() { + private fun readResolve(): Any = NegativeInfinity + + override val isInfinite: Boolean + get() = true + override val isFinite: Boolean + get() = false + + override fun compareTo(other: Decimal): Int { + return if (other === this) 0 else -1 + } + + override fun toByte(): Byte { + return Byte.MIN_VALUE + } + + override fun toDouble(): Double { + return Double.NEGATIVE_INFINITY + } + + override fun toFloat(): Float { + return Float.NEGATIVE_INFINITY + } + + override fun toInt(): Int { + return Int.MIN_VALUE + } + + override fun toLong(): Long { + return Long.MIN_VALUE + } + + override fun toShort(): Short { + return Short.MIN_VALUE + } + + override val whole: BigInteger + get() = throw UnsupportedOperationException("Attempt to get whole part of negative infinity") + override val fractional: BigInteger + get() = throw UnsupportedOperationException("Attempt to get fractional part of negative infinity") + + override fun plus(other: Decimal): Decimal { + return this + } + + override fun minus(other: Decimal): Decimal { + return this + } + + override fun times(other: Decimal): Decimal { + return if (other.signum() == 0) + Zero + else if (other.signum() < 0) + PositiveInfinity + else + this + } + + override fun div(other: Decimal): Decimal { + return if (other.signum() == 0) + throw ArithmeticException("Attempt to divide negative infinity by zero") + else if (other === this) + throw ArithmeticException("Dividing negative infinity by itself is undefined") + else if (other === PositiveInfinity) + throw ArithmeticException("Dividing negative infinity by positive infinity is undefined") + else if (other.signum() < 0) + PositiveInfinity + else + this + } + + override fun rem(other: Decimal): Decimal { + return if (other.signum() == 0) + throw ArithmeticException("Attempt to remainder divide negative infinity by zero") + else if (other.signum() < 0) + PositiveInfinity + else + this + } + + override fun plus(other: Float): Decimal { + return this + } + + override fun minus(other: Float): Decimal { + return this + } + + override fun times(other: Float): Decimal { + return if (other == 0f) + Zero + else if (other < 0f) + PositiveInfinity + else + this + } + + override fun div(other: Float): Decimal { + return if (other == 0f) + throw ArithmeticException("Attempt to divide negative negative by zero") + else if (other < 0f) + PositiveInfinity + else + this + } + + override fun plus(other: Double): Decimal { + return this + } + + override fun minus(other: Double): Decimal { + return this + } + + override fun times(other: Double): Decimal { + return if (other == 0.0) + Zero + else if (other < 0.0) + PositiveInfinity + else + this + } + + override fun div(other: Double): Decimal { + return if (other == 0.0) + throw ArithmeticException("Attempt to divide negative infinity by zero") + else if (other < 0.0) + PositiveInfinity + else + this + } + + override fun plus(other: Int): Decimal { + return this + } + + override fun minus(other: Int): Decimal { + return this + } + + override fun times(other: Int): Decimal { + return if (other == 0) + Zero + else if (other < 0) + PositiveInfinity + else + this + } + + override fun div(other: Int): Decimal { + return if (other == 0) + throw ArithmeticException("Attempt to divide negative infinity by zero") + else if (other < 0) + PositiveInfinity + else + this + } + + override fun plus(other: Long): Decimal { + return this + } + + override fun minus(other: Long): Decimal { + return this + } + + override fun times(other: Long): Decimal { + return if (other == 0L) + Zero + else if (other < 0L) + PositiveInfinity + else + this + } + + override fun div(other: Long): Decimal { + return if (other == 0L) + throw ArithmeticException("Attempt to divide negative infinity by zero") + else if (other < 0L) + PositiveInfinity + else + this + } + + override fun plus(other: BigInteger): Decimal { + return this + } + + override fun minus(other: BigInteger): Decimal { + return this + } + + override fun times(other: BigInteger): Decimal { + return if (other.signum() == 0) + Zero + else if (other.signum() < 0) + PositiveInfinity + else + this + } + + override fun div(other: BigInteger): Decimal { + return if (other.signum() == 0) + throw ArithmeticException("Attempt to divide negative infinity by zero") + else if (other.signum() < 0) + PositiveInfinity + else + this + } + + override fun unaryMinus(): Decimal { + return PositiveInfinity + } + + override fun signum(): Int { + return -1 + } + + override fun toByteArray(): ByteArray { + return byteArrayOf(TYPE_NEGATIVE_INFINITY) + } + + override fun floor(): Decimal { + return this + } + + override fun toString(decimals: Int): String { + return "-Infinity" + } + + override fun toBigDecmial(): BigDecimal { + throw UnsupportedOperationException("Unable to construct BigDecimal of negative infinity") + } + } + + private object Zero : Decimal() { + private fun readResolve(): Any = Zero + + override val isInfinite: Boolean + get() = false + override val isFinite: Boolean + get() = true + + override fun compareTo(other: Decimal): Int { + return -other.signum() + } + + override fun toByte(): Byte { + return 0 + } + + override fun toDouble(): Double { + return 0.0 + } + + override fun toFloat(): Float { + return 0f + } + + override fun toInt(): Int { + return 0 + } + + override fun toLong(): Long { + return 0L + } + + override fun toShort(): Short { + return 0 + } + + override val whole: BigInteger + get() = BigInteger.ZERO + override val fractional: BigInteger + get() = BigInteger.ZERO + + override fun plus(other: Decimal): Decimal { + return other + } + + override fun minus(other: Decimal): Decimal { + return -other + } + + override fun times(other: Decimal): Decimal { + return this + } + + override fun div(other: Decimal): Decimal { + if (other === this) + throw ArithmeticException("0 / 0") + else + return this + } + + override fun rem(other: Decimal): Decimal { + if (other === this) + throw ArithmeticException("0 % 0") + else + return this + } + + override fun plus(other: Float): Decimal { + return valueOf(other) + } + + override fun minus(other: Float): Decimal { + return valueOf(-other) + } + + override fun times(other: Float): Decimal { + return this + } + + override fun div(other: Float): Decimal { + if (other == 0f) + throw ArithmeticException("0 / 0") + + return this + } + + override fun plus(other: Double): Decimal { + return valueOf(other) + } + + override fun minus(other: Double): Decimal { + return valueOf(-other) + } + + override fun times(other: Double): Decimal { + return this + } + + override fun div(other: Double): Decimal { + if (other == 0.0) + throw ArithmeticException("0 / 0") + + return this + } + + override fun plus(other: Int): Decimal { + return valueOf(other) + } + + override fun minus(other: Int): Decimal { + return valueOf(-other) + } + + override fun times(other: Int): Decimal { + return this + } + + override fun div(other: Int): Decimal { + if (other == 0) + throw ArithmeticException("0 / 0") + + return this + } + + override fun plus(other: Long): Decimal { + return valueOf(other) + } + + override fun minus(other: Long): Decimal { + return valueOf(-other) + } + + override fun times(other: Long): Decimal { + return this + } + + override fun div(other: Long): Decimal { + if (other == 0L) + throw ArithmeticException("0 / 0") + + return this + } + + override fun plus(other: BigInteger): Decimal { + return valueOf(other) + } + + override fun minus(other: BigInteger): Decimal { + return valueOf(-other) + } + + override fun times(other: BigInteger): Decimal { + return this + } + + override fun div(other: BigInteger): Decimal { + if (other == BigInteger.ZERO) + throw ArithmeticException("0 / 0") + + return this + } + + override fun unaryMinus(): Decimal { + return this + } + + override fun signum(): Int { + return 0 + } + + override fun toByteArray(): ByteArray { + return byteArrayOf(TYPE_ZERO) + } + + override fun floor(): Decimal { + return this + } + + override fun toString(decimals: Int): String { + if (decimals <= 0) + return "0" + else + return "0." + "0".repeat(decimals) + } + + override fun toBigDecmial(): BigDecimal { + return BigDecimal.ZERO + } + } + @Suppress("unused") companion object { /** @@ -585,6 +1362,11 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe */ const val PRECISION = 11 + const val TYPE_ZERO: Byte = 0 + const val TYPE_NORMAL: Byte = 1 + const val TYPE_POSITIVE_INFINITY: Byte = 2 + const val TYPE_NEGATIVE_INFINITY: Byte = 3 + @JvmField val PRECISION_POW_BI: BigInteger = BigInteger("1" + "0".repeat(PRECISION)) @JvmField @@ -599,7 +1381,12 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe private const val cacheSize = 16384 private const val cacheSizeL = cacheSize.toLong() - private val cache = Array(cacheSize) { Decimal(BigInteger.valueOf(it.toLong() - cacheSize / 2)) } + private val cache = Array(cacheSize) { Regular(BigInteger.valueOf(it.toLong() - cacheSize / 2)) } + + init { + check(cache[cacheSize / 2].signum() == 0) + cache[cacheSize / 2] = Zero + } /** * Returns pooled value if present, otherwise constructs new object @@ -610,7 +1397,7 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe return cache[value + cacheSize / 2] } - return Decimal(BigInteger.valueOf(value.toLong())) + return Regular(BigInteger.valueOf(value.toLong())) } /** @@ -622,7 +1409,7 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe return cache[value.toInt() + cacheSize / 2] } - return Decimal(BigInteger.valueOf(value)) + return Regular(BigInteger.valueOf(value)) } /** @@ -637,18 +1424,77 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe @JvmStatic fun valueOf(value: Byte) = valueOf(value.toInt()) - @JvmStatic fun valueOf(value: BigInteger) = Decimal(value) - @JvmStatic fun valueOf(value: BigDecimal) = Decimal(value) - @JvmStatic fun valueOf(value: String) = Decimal(value) - @JvmStatic fun valueOf(value: Float) = Decimal(value) - @JvmStatic fun valueOf(value: Double) = Decimal(value) + @JvmStatic fun valueOf(value: BigInteger): Decimal { + return if (value.signum() == 0) { + Zero + } else { + Regular(value) + } + } + + @JvmStatic fun valueOf(value: BigDecimal): Decimal { + return if (value.signum() == 0) { + Zero + } else { + Regular(value) + } + } + + @JvmStatic fun valueOf(value: String): Decimal { + if (value == "0") { + return Zero + } else { + val lower = value.lowercase() + + // why not + if (lower.startsWith("+inf") || lower.startsWith("inf") || lower == "∞" || lower == "+∞") { + return PositiveInfinity + } else if (lower.startsWith("-inf") || lower == "-∞") { + return NegativeInfinity + } else { + val result = Regular(value) + if (result.signum() == 0) return Zero + return result + } + } + } + + @JvmStatic fun valueOf(value: Float): Decimal { + return if (value == 0f) { + Zero + } else if (value == Float.POSITIVE_INFINITY) { + PositiveInfinity + } else if (value == Float.NEGATIVE_INFINITY) { + NegativeInfinity + } else { + Regular(value) + } + } + + @JvmStatic fun valueOf(value: Double): Decimal { + return if (value == 0.0) { + Zero + } else if (value == Double.POSITIVE_INFINITY) { + PositiveInfinity + } else if (value == Double.NEGATIVE_INFINITY) { + NegativeInfinity + } else { + Regular(value) + } + } @JvmStatic fun fromByteArray(input: ByteArray): Decimal { - if (input.isEmpty()) { - return ZERO + return if (input.isEmpty()) { + Zero } else { - return Decimal(BigInteger(input), null) + return when (input[0]) { + TYPE_NORMAL -> raw(BigInteger(input.copyOfRange(1, input.size))) + TYPE_NEGATIVE_INFINITY -> NegativeInfinity + TYPE_POSITIVE_INFINITY -> PositiveInfinity + // TYPE_ZERO -> Zero + else -> Zero + } } } @@ -657,24 +1503,32 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe if (input is ByteArrayTag) { return fromByteArray(input.asByteArray) } else if (input is StringTag) { - return Decimal(input.asString) + return valueOf(input.asString) } - return ZERO + return Zero } @JvmStatic fun read(buff: FriendlyByteBuf): Decimal { - return Decimal(BigInteger(buff.readByteArray()), null) + return fromByteArray(buff.readByteArray()) } /** * Takes in [value] as-is and constructs [Decimal] out of it ([value] is treated as already scaled by [PRECISION]) */ @JvmStatic - fun raw(value: BigInteger): Decimal = Decimal(value, null) + fun raw(value: BigInteger): Decimal { + return if (value.signum() == 0) { + Zero + } else { + Regular(value, null) + } + } - @JvmField val ZERO = valueOf(0) + @JvmField val POSITIVE_INFINITY: Decimal = PositiveInfinity + @JvmField val NEGATIVE_INFINITY: Decimal = NegativeInfinity + @JvmField val ZERO: Decimal = Zero @JvmField val ONE = valueOf(1) @JvmField val TWO = valueOf(2) @JvmField val TEN = valueOf(10) @@ -690,15 +1544,15 @@ class Decimal private constructor(val mag: BigInteger, marker: Nothing?) : Numbe @JvmField val MINUS_ONE_QUARTER = valueOf("-0.25") @JvmField val MINUS_ONE_HALF = valueOf("-0.5") - @JvmField val INT_MAX_VALUE = Decimal(BI_INT_MAX) - @JvmField val INT_MIN_VALUE = Decimal(BI_INT_MIN) - @JvmField val LONG_MAX_VALUE = Decimal(BI_LONG_MAX) - @JvmField val LONG_MIN_VALUE = Decimal(BI_LONG_MIN) + @JvmField val INT_MAX_VALUE: Decimal = Regular(BI_INT_MAX) + @JvmField val INT_MIN_VALUE: Decimal = Regular(BI_INT_MIN) + @JvmField val LONG_MAX_VALUE: Decimal = Regular(BI_LONG_MAX) + @JvmField val LONG_MIN_VALUE: Decimal = Regular(BI_LONG_MIN) - @JvmField val FLOAT_MAX_VALUE = Decimal(BI_FLOAT_MAX) - @JvmField val FLOAT_MIN_VALUE = Decimal(BI_FLOAT_MIN) - @JvmField val DOUBLE_MAX_VALUE = Decimal(BI_DOUBLE_MAX) - @JvmField val DOUBLE_MIN_VALUE = Decimal(BI_DOUBLE_MIN) + @JvmField val FLOAT_MAX_VALUE: Decimal = Regular(BI_FLOAT_MAX) + @JvmField val FLOAT_MIN_VALUE: Decimal = Regular(BI_FLOAT_MIN) + @JvmField val DOUBLE_MAX_VALUE: Decimal = Regular(BI_DOUBLE_MAX) + @JvmField val DOUBLE_MIN_VALUE: Decimal = Regular(BI_DOUBLE_MIN) } } @@ -789,10 +1643,10 @@ fun ForgeConfigSpec.Builder.defineDecimal(path: List, defaultValue: Deci fun RandomSource.nextDecimal(min: Decimal, max: Decimal, round: Boolean = false): Decimal { val value = nextDouble() - if (round) { - return Decimal((min + (max - min) * value).whole) + return if (round) { + Decimal((min + (max - min) * value).whole) } else { - return min + (max - min) * value + min + (max - min) * value } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt index a773fb4d1..56339f947 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Formatting.kt @@ -167,6 +167,8 @@ fun Double.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 3, formatAsR fun Decimal.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 3, formatAsReadable: BooleanSupplier = never, bias: Int = 0): Component { require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" } + if (this == Decimal.POSITIVE_INFINITY) return concat("∞", suffix) + if (this == Decimal.NEGATIVE_INFINITY) return concat("-∞", suffix) if (formatAsReadable.asBoolean && this.absoluteValue >= Decimal.ONE) return concat(reformat(toString(decimalPlaces)), suffix) val prefix = SiPrefix.determine(this) return TranslatableComponent(prefix.neighbour(bias).formatLocaleKey, (this / prefix.decimal).toString(decimalPlaces), suffix) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/SiPrefix.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/SiPrefix.kt index 2789e4ebf..4255840f6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/SiPrefix.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/SiPrefix.kt @@ -121,7 +121,7 @@ enum class SiPrefix(val power: Int, val symbol: String) { } fun determine(value: Decimal, bias: Int = 0): SiPrefix { - if (value.isZero) { + if (value.isZero || value.isInfinite) { return NONE } From a1515d54c4fdd1aa015596b788d1abe29f54c3ef Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 28 Dec 2023 20:37:18 +0700 Subject: [PATCH 1130/1199] Introduce infinity to energy impl, move creative battery to plain infinite values instead of special logic --- .../energy/BlockEnergyStorageImpl.kt | 2 +- .../energy/ItemEnergyStorageImpl.kt | 2 +- .../dbotthepony/mc/otm/core/math/Decimal.kt | 6 ++ .../ru/dbotthepony/mc/otm/item/BatteryItem.kt | 60 +++---------------- 4 files changed, 17 insertions(+), 53 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt index 150977628..fe1dccd81 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt @@ -105,7 +105,7 @@ sealed class BlockEnergyStorageImpl( howMuch = howMuch.coerceAtMost(maxInput) } - if (batteryLevel >= maxBatteryLevel) + if (batteryLevel >= maxBatteryLevel && !maxBatteryLevel.isInfinite) return Decimal.ZERO val newLevel = (batteryLevel + howMuch).coerceAtMost(maxBatteryLevel) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt index ac71aa330..b3f29cb4a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt @@ -75,7 +75,7 @@ abstract class ItemEnergyStorageImpl(val itemStack: ItemStack) : IMatteryEnergyS val batteryLevel = batteryLevel - if (batteryLevel >= maxBatteryLevel) + if (batteryLevel >= maxBatteryLevel && !maxBatteryLevel.isInfinite) return Decimal.ZERO val newLevel = (batteryLevel + howMuch).coerceAtMost(maxBatteryLevel) 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 1df81a457..2147a53ab 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 @@ -737,10 +737,16 @@ sealed class Decimal : Number(), Comparable { get() = throw UnsupportedOperationException("Attempt to get fractional part of positive infinity") override fun plus(other: Decimal): Decimal { + // not very mathematically correct, since + // case "infinity + infinity" with either sign on either side + // is undefined return this } override fun minus(other: Decimal): Decimal { + // not very mathematically correct, since + // case "infinity - infinity" with either sign on either side + // is undefined return this } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt index c557d3daa..4115d724e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt @@ -30,33 +30,6 @@ import ru.dbotthepony.mc.otm.runIfClient import kotlin.math.roundToInt open class BatteryItem : Item { - private inner class Power(stack: ItemStack) : EnergyCapacitorItem(stack, this@BatteryItem.capacity, this@BatteryItem.receive, this@BatteryItem.extract, initialBatteryLevel = this@BatteryItem.initialBatteryLevel) { - override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { - if (isCreative) return howMuch - return super.extractEnergy(howMuch, simulate) - } - - override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { - if (isCreative) return howMuch - return super.receiveEnergy(howMuch, simulate) - } - - override val missingPower: Decimal - get() { - return if (isCreative) Decimal.LONG_MAX_VALUE else super.missingPower - } - - fun maxPower() { - batteryLevel = maxBatteryLevel - } - - override var batteryLevel: Decimal - get() { return if (isCreative) Decimal.LONG_MAX_VALUE else super.batteryLevel } - set(value) { super.batteryLevel = value } - } - - private val isCreative: Boolean - val _capacity: () -> Decimal val _receive: () -> Decimal val _extract: () -> Decimal @@ -77,7 +50,6 @@ open class BatteryItem : Item { extract: Decimal = receive, initialBatteryLevel: Decimal = Decimal.ZERO ) : super(Properties().stacksTo(1)) { - isCreative = false this._capacity = { storage } this._receive = { receive } this._extract = { extract } @@ -90,7 +62,6 @@ open class BatteryItem : Item { extract: () -> Decimal = receive, initialBatteryLevel: () -> Decimal = { Decimal.ZERO } ) : super(Properties().stacksTo(1)) { - isCreative = false this._capacity = storage this._receive = receive this._extract = extract @@ -98,7 +69,6 @@ open class BatteryItem : Item { } constructor(values: BatteryBalanceValues) : super(Properties().stacksTo(1)) { - isCreative = false this._capacity = values::energyCapacity this._receive = values::maxEnergyReceive this._extract = values::maxEnergyExtract @@ -106,29 +76,28 @@ open class BatteryItem : Item { } constructor() : super(Properties().stacksTo(1).rarity(Rarity.EPIC)) { - isCreative = true - _capacity = { Decimal.LONG_MAX_VALUE } - _receive = { Decimal.LONG_MAX_VALUE } - _extract = { Decimal.LONG_MAX_VALUE } - _initialBatteryLevel = { Decimal.LONG_MAX_VALUE } + _capacity = { Decimal.POSITIVE_INFINITY } + _receive = { Decimal.POSITIVE_INFINITY } + _extract = { Decimal.POSITIVE_INFINITY } + _initialBatteryLevel = { Decimal.POSITIVE_INFINITY } } override fun isBarVisible(p_150899_: ItemStack): Boolean { - if (isCreative) + if (_capacity.invoke().isInfinite) return false return p_150899_.matteryEnergy != null } override fun getBarWidth(p_150900_: ItemStack): Int { - if (isCreative) + if (_capacity.invoke().isInfinite) return 13 return p_150900_.matteryEnergy?.getBarWidth() ?: super.getBarWidth(p_150900_) } override fun getBarColor(p_150901_: ItemStack): Int { - if (isCreative) + if (_capacity.invoke().isInfinite) return 0 return p_150901_.matteryEnergy?.getBarColor() ?: super.getBarColor(p_150901_) @@ -141,22 +110,11 @@ open class BatteryItem : Item { p_41424_: TooltipFlag ) { super.appendHoverText(stack, p_41422_, p_41423_, p_41424_) - - if (isCreative) { - p_41423_.add(INFINITE_STORAGE) - p_41423_.add(TranslatableComponent("otm.item.power.infinite.throughput").withStyle(ChatFormatting.GRAY)) - } else { - ItemEnergyStorageImpl.appendHoverText(stack, p_41423_) - } + ItemEnergyStorageImpl.appendHoverText(stack, p_41423_) } override fun initCapabilities(stack: ItemStack, nbt: CompoundTag?): ICapabilityProvider { - return Power(stack) - } - - companion object { - private val INFINITE_STORAGE: Component = - TranslatableComponent("otm.item.power.infinite.storage").withStyle(ChatFormatting.GRAY) + return EnergyCapacitorItem(stack, this@BatteryItem.capacity, this@BatteryItem.receive, this@BatteryItem.extract, initialBatteryLevel = this@BatteryItem.initialBatteryLevel) } } From 2276f0ef458475a541fa31df52dfef012af2c260 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 29 Dec 2023 10:51:13 +0700 Subject: [PATCH 1131/1199] Fix zero decimal formatting --- src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Decimal.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 2147a53ab..7ca9fdc8f 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 @@ -1350,8 +1350,10 @@ sealed class Decimal : Number(), Comparable { } override fun toString(decimals: Int): String { - if (decimals <= 0) + if (decimals == 0) return "0" + else if (decimals < 0) + return "0.0" else return "0." + "0".repeat(decimals) } From 6de2f14fcd45a0c52aa8e16b971e084954126fe8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 29 Dec 2023 10:52:01 +0700 Subject: [PATCH 1132/1199] Update energy impls to make more use of infinity --- .../energy/BlockEnergyStorageImpl.kt | 20 ++----------------- .../energy/ItemEnergyStorageImpl.kt | 11 +--------- 2 files changed, 3 insertions(+), 28 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt index fe1dccd81..cc7a7ed7e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt @@ -72,18 +72,10 @@ sealed class BlockEnergyStorageImpl( if (!howMuch.isPositive) return Decimal.ZERO - @Suppress("NAME_SHADOWING") - var howMuch = howMuch - val maxOutput = maxOutput - - if (maxOutput != null) { - howMuch = howMuch.coerceAtMost(maxOutput) - } - if (!batteryLevel.isPositive) return Decimal.ZERO - val newLevel = (batteryLevel - howMuch).moreThanZero() + val newLevel = (batteryLevel - howMuch.coerceAtMost(maxOutput ?: Decimal.POSITIVE_INFINITY)).moreThanZero() val diff = (batteryLevel - newLevel) if (!simulate && batteryLevel != newLevel) { @@ -97,18 +89,10 @@ sealed class BlockEnergyStorageImpl( if (!howMuch.isPositive) return Decimal.ZERO - @Suppress("NAME_SHADOWING") - var howMuch = howMuch - val maxInput = maxInput - - if (maxInput != null) { - howMuch = howMuch.coerceAtMost(maxInput) - } - if (batteryLevel >= maxBatteryLevel && !maxBatteryLevel.isInfinite) return Decimal.ZERO - val newLevel = (batteryLevel + howMuch).coerceAtMost(maxBatteryLevel) + val newLevel = (batteryLevel + howMuch.coerceAtMost(maxInput ?: Decimal.POSITIVE_INFINITY)).coerceAtMost(maxBatteryLevel) val diff = (newLevel - batteryLevel) if (!simulate && batteryLevel != newLevel) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt index b3f29cb4a..2867fabd4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt @@ -65,20 +65,11 @@ abstract class ItemEnergyStorageImpl(val itemStack: ItemStack) : IMatteryEnergyS if (!howMuch.isPositive || itemStack.count != 1) return Decimal.ZERO - @Suppress("NAME_SHADOWING") - var howMuch = howMuch - val maxInput = maxInput - - if (maxInput != null) { - howMuch = howMuch.coerceAtMost(maxInput) - } - val batteryLevel = batteryLevel - if (batteryLevel >= maxBatteryLevel && !maxBatteryLevel.isInfinite) return Decimal.ZERO - val newLevel = (batteryLevel + howMuch).coerceAtMost(maxBatteryLevel) + val newLevel = (batteryLevel + howMuch.coerceAtMost(maxInput ?: Decimal.POSITIVE_INFINITY)).coerceAtMost(maxBatteryLevel) val diff = (newLevel - batteryLevel) if (!simulate && batteryLevel != newLevel) { From 79aeca57209628097a3b9e5fbeab7e32f92b6a84 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 29 Dec 2023 16:35:32 +0700 Subject: [PATCH 1133/1199] Energy cables test --- .../mc/otm/capability/MatteryCapability.java | 5 + .../ru/dbotthepony/mc/otm/block/Cables.kt | 16 ++- .../dbotthepony/mc/otm/block/MatteryBlock.kt | 4 +- .../entity/cable/EnergyCableBlockEntity.kt | 133 ++++++++++++++++++ .../block/entity/cable/EnergyCableGraph.kt | 51 +++++++ .../ru/dbotthepony/mc/otm/graph/GraphNode.kt | 7 + .../dbotthepony/mc/otm/graph/GraphNodeList.kt | 24 +++- .../mc/otm/registry/MBlockEntities.kt | 2 + .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 2 + .../mc/otm/registry/MCreativeTabs.kt | 1 + .../ru/dbotthepony/mc/otm/registry/MItems.kt | 2 + .../ru/dbotthepony/mc/otm/registry/MNames.kt | 1 + 12 files changed, 241 insertions(+), 7 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableGraph.kt diff --git a/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java b/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java index 4caae5fed..90c7f3aa5 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java +++ b/src/main/java/ru/dbotthepony/mc/otm/capability/MatteryCapability.java @@ -5,6 +5,7 @@ import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityToken; import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent; import org.jetbrains.annotations.NotNull; +import ru.dbotthepony.mc.otm.block.entity.cable.EnergyCableBlockEntity; import ru.dbotthepony.mc.otm.capability.drive.IMatteryDrive; import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage; import ru.dbotthepony.mc.otm.capability.matter.IMatterStorage; @@ -50,6 +51,10 @@ public class MatteryCapability { @NotNull public static final Capability STORAGE_NODE = CapabilityManager.get(new CapabilityToken<>() {}); + @Nonnull + @NotNull + public static final Capability ENERGY_CABLE_NODE = CapabilityManager.get(new CapabilityToken<>() {}); + @Nonnull @NotNull public static final Capability CURIOS_INVENTORY = CapabilityManager.get(new CapabilityToken<>() {}); diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt index 9adb59906..e17fe4714 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt @@ -21,10 +21,11 @@ import net.minecraft.world.phys.shapes.Shapes import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.entity.MatterCableBlockEntity import ru.dbotthepony.mc.otm.block.entity.StorageCableBlockEntity +import ru.dbotthepony.mc.otm.block.entity.cable.EnergyCableBlockEntity import java.util.Collections import java.util.EnumMap -abstract class CableBlock(properties: Properties) : Block(properties) { +abstract class CableBlock(properties: Properties) : MatteryBlock(properties) { init { registerDefaultState(defaultBlockState() .setValue(CONNECTION_SOUTH, false) @@ -127,3 +128,16 @@ class StorageCableBlock : CableBlock(Properties.of().mapColor(MapColor.METAL).re return StorageCableBlockEntity(blockPos, blockState) } } + +class EnergyCableBlock : CableBlock(Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock { + private val shapes = generateShapes(0.125) + + @Suppress("OVERRIDE_DEPRECATION") + override fun getShape(blockState: BlockState, accessor: BlockGetter, pos: BlockPos, context: CollisionContext): VoxelShape { + return shapes[blockState] ?: Shapes.block() + } + + override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { + return EnergyCableBlockEntity(blockPos, blockState) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt index ac83b83c9..c7806370f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt @@ -70,9 +70,7 @@ fun interface INeighbourChangeListener { ) } -abstract class MatteryBlock @JvmOverloads constructor( - properties: Properties = DEFAULT_PROPERTIES -) : Block(properties), INeighbourChangeListener { +abstract class MatteryBlock(properties: Properties = DEFAULT_PROPERTIES) : Block(properties), INeighbourChangeListener { override fun setPlacedBy( level: Level, blockPos: BlockPos, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt new file mode 100644 index 000000000..20772b3cf --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt @@ -0,0 +1,133 @@ +package ru.dbotthepony.mc.otm.block.entity.cable + +import net.minecraft.core.BlockPos +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.Block +import net.minecraft.world.level.block.state.BlockState +import net.minecraftforge.common.capabilities.ForgeCapabilities +import ru.dbotthepony.mc.otm.SERVER_IS_LIVE +import ru.dbotthepony.mc.otm.block.CableBlock +import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity +import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage +import ru.dbotthepony.mc.otm.core.ifPresentK +import ru.dbotthepony.mc.otm.core.math.BlockRotation +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.RelativeSide +import ru.dbotthepony.mc.otm.graph.GraphNode +import ru.dbotthepony.mc.otm.registry.MBlockEntities +import java.util.Collections +import java.util.EnumMap + +// after some thinking, team decided to settle with IC2's side (techreborn, gregtech, integrated dynamics*, pipez*, p2p tunnels, ...) of implementation, +// where cables have no residue capacitance, and never pull/push energy by themselves + +// this allows simpler implementation and faster code, while also reducing possibility of duplication exploits + +class EnergyCableBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryBlockEntity(MBlockEntities.ENERGY_CABLE, blockPos, blockState) { + inner class CableSide(val side: RelativeSide) : IMatteryEnergyStorage { + var isEnabled = true + set(value) { + field = value + + if (value) { + node.graph.livelyNodes.add(node) + } + } + + init { + check(side !in energySidesInternal) + energySidesInternal[side] = this + sides[side]!!.Cap(ForgeCapabilities.ENERGY, this) + } + + val neighbour = sides[side]!!.trackEnergy() + + init { + neighbour.addListener { + if (isEnabled) { + if (it.isPresent) { + if (it.resolve().get() !is CableSide) { + node.graph.livelyNodes.add(node) + } + + ru.dbotthepony.mc.otm.onceServer { + val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[blockRotation.side2Dir(side)]!!, true) + + if (newState !== blockState) + level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + } + } else { + ru.dbotthepony.mc.otm.onceServer { + val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[blockRotation.side2Dir(side)]!!, false) + + if (newState !== blockState) + level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + } + } + } + } + } + + override fun extractEnergy(howMuch: Decimal, simulate: Boolean): Decimal { + return Decimal.ZERO + } + + override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { + return node.graph.receiveEnergy(howMuch, simulate) + } + + override var batteryLevel: Decimal + get() = Decimal.ZERO + set(value) {} + + override val maxBatteryLevel: Decimal get() = Decimal.ZERO + override var energyFlow: FlowDirection = FlowDirection.BI_DIRECTIONAL + private set + } + + inner class Node : GraphNode(::EnergyCableGraph) { + val sides get() = energySides + + override fun onNeighbour(link: Link) { + if (link is DirectionLink) { + val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[link.direction]!!, true) + + if (newState !== blockState && SERVER_IS_LIVE) + level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + } + } + + override fun onUnNeighbour(link: Link) { + if (link is DirectionLink) { + val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[link.direction]!!, false) + + if (newState !== blockState && SERVER_IS_LIVE) + level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + } + } + } + + override val blockRotation: BlockRotation + get() = BlockRotation.NORTH + + private val energySidesInternal = EnumMap(RelativeSide::class.java) + val energySides: Map = Collections.unmodifiableMap(energySidesInternal) + val node = Node() + + override fun setLevel(level: Level) { + super.setLevel(level) + node.discover(this, MatteryCapability.ENERGY_CABLE_NODE) + } + + override fun setRemoved() { + super.setRemoved() + node.isValid = false + } + + init { + sides.keys.forEach { CableSide(it) } + exposeGlobally(MatteryCapability.ENERGY_CABLE_NODE, node) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableGraph.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableGraph.kt new file mode 100644 index 000000000..c5e25be5b --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableGraph.kt @@ -0,0 +1,51 @@ +package ru.dbotthepony.mc.otm.block.entity.cable + +import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet +import ru.dbotthepony.mc.otm.capability.receiveEnergy +import ru.dbotthepony.mc.otm.core.ifPresentK +import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.graph.GraphNodeList + +class EnergyCableGraph : GraphNodeList() { + val livelyNodes = ObjectOpenHashSet() + + override fun onNodeRemoved(node: EnergyCableBlockEntity.Node) { + livelyNodes.remove(node) + } + + override fun onNodeAdded(node: EnergyCableBlockEntity.Node) { + livelyNodes.add(node) + } + + fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { + val itr = livelyNodes.iterator() + var received = Decimal.ZERO + var residue = howMuch + + for (node in itr) { + var hit = false + + for (side in node.sides.values) { + if (side.isEnabled) { + side.neighbour.get().ifPresentK { + if (it !is EnergyCableBlockEntity.CableSide) { + hit = true + + val thisReceived = it.receiveEnergy(residue, simulate) + received += thisReceived + residue -= thisReceived + + if (!residue.isPositive) return received + } + } + } + } + + if (!hit) { + itr.remove() + } + } + + return received + } +} 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 64d45298b..05899b77f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/GraphNode.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/GraphNode.kt @@ -11,6 +11,8 @@ import net.minecraftforge.common.capabilities.Capability import ru.dbotthepony.mc.otm.addTicker import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.core.orNull +import ru.dbotthepony.mc.otm.core.util.IConditionalTickable +import ru.dbotthepony.mc.otm.core.util.ITickable open class GraphNode, G : GraphNodeList>(val graphFactory: () -> G) { interface Link { @@ -38,6 +40,11 @@ open class GraphNode, G : GraphNodeList>(val graphFact private var seen: Int = 0 + fun beginTicking() { + require(this is IConditionalTickable || this is ITickable) { "Node must implement either ITickable or IConditionalTickable to tick" } + graph.beginTicking(this as N) + } + operator fun get(key: Link): N? = neighbours[key] operator fun set(key: Link, node: N?) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/GraphNodeList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/GraphNodeList.kt index 763b7beeb..de223337d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/GraphNodeList.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/GraphNodeList.kt @@ -35,14 +35,32 @@ open class GraphNodeList, G : GraphNodeList> : ICondit return false } + fun beginTicking(node: N) { + require(node in nodesInternal || node in queuedAdd) { "Node $node does not belong to $this" } + if (node in queuedRemove) return + + if (node is IConditionalTickable) { + conditional.add(node) + beginTicking() + } else if (node is ITickable) { + always.add(node) + beginTicking() + } else { + throw ClassCastException("$node does not implement ITickable nor IConditionalTickable") + } + } + private fun addNow(node: N) { node.graph = this as G nodesInternal.add(node) - if (node is IConditionalTickable) + if (node is IConditionalTickable) { conditional.add(node) - else if (node is ITickable) + beginTicking() + } else if (node is ITickable) { always.add(node) + beginTicking() + } onNodeAdded(node) } @@ -178,7 +196,7 @@ open class GraphNodeList, G : GraphNodeList> : ICondit private val graphs = ArrayList>>() private val queue = ArrayList>>() - fun tick() { + internal fun tick() { if (queue.isNotEmpty()) { graphs.addAll(queue) queue.clear() 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 8172c022a..a0697f9c7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt @@ -15,6 +15,7 @@ import ru.dbotthepony.mc.otm.block.entity.tech.* import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity import ru.dbotthepony.mc.otm.block.entity.blackhole.BlockEntityExplosionDebugger import ru.dbotthepony.mc.otm.block.entity.blackhole.BlockEntitySphereDebugger +import ru.dbotthepony.mc.otm.block.entity.cable.EnergyCableBlockEntity import ru.dbotthepony.mc.otm.block.entity.decorative.CargoCrateBlockEntity import ru.dbotthepony.mc.otm.block.entity.decorative.DevChestBlockEntity import ru.dbotthepony.mc.otm.block.entity.decorative.FluidTankBlockEntity @@ -73,6 +74,7 @@ object MBlockEntities { val DEV_CHEST by register(MNames.DEV_CHEST, ::DevChestBlockEntity, MBlocks::DEV_CHEST) val PAINTER by register(MNames.PAINTER, ::PainterBlockEntity, MBlocks::PAINTER) val MATTER_ENTANGLER by register(MNames.MATTER_ENTANGLER, ::MatterEntanglerBlockEntity, MBlocks::MATTER_ENTANGLER) + val ENERGY_CABLE by register(MNames.ENERGY_CABLE, ::EnergyCableBlockEntity, MBlocks::ENERGY_CABLE) val POWERED_FURNACE: BlockEntityType by registry.register(MNames.POWERED_FURNACE) { BlockEntityType.Builder.of({ a, b -> MBlocks.POWERED_FURNACE.newBlockEntity(a, b) }, MBlocks.POWERED_FURNACE).build(null) } val POWERED_BLAST_FURNACE: BlockEntityType by registry.register(MNames.POWERED_BLAST_FURNACE) { BlockEntityType.Builder.of({ a, b -> MBlocks.POWERED_BLAST_FURNACE.newBlockEntity(a, b) }, MBlocks.POWERED_BLAST_FURNACE).build(null) } 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 8e64746f7..266a98416 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -36,6 +36,7 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.block.BlackHoleBlock import ru.dbotthepony.mc.otm.block.BlockExplosionDebugger import ru.dbotthepony.mc.otm.block.BlockSphereDebugger +import ru.dbotthepony.mc.otm.block.EnergyCableBlock import ru.dbotthepony.mc.otm.block.MatterCableBlock import ru.dbotthepony.mc.otm.block.StorageCableBlock import ru.dbotthepony.mc.otm.block.decorative.DevChestBlock @@ -114,6 +115,7 @@ object MBlocks { val MATTER_RECONSTRUCTOR: MatterReconstructorBlock by registry.register(MNames.MATTER_RECONSTRUCTOR) { MatterReconstructorBlock() } val PAINTER: PainterBlock by registry.register(MNames.PAINTER) { PainterBlock() } val MATTER_ENTANGLER: MatterEntanglerBlock by registry.register(MNames.MATTER_ENTANGLER) { MatterEntanglerBlock() } + val ENERGY_CABLE: EnergyCableBlock by registry.register(MNames.ENERGY_CABLE) { EnergyCableBlock() } val STORAGE_BUS: Block by registry.register(MNames.STORAGE_BUS) { StorageBusBlock() } val STORAGE_IMPORTER: Block by registry.register(MNames.STORAGE_IMPORTER) { StorageImporterBlock() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt index ef32d75bc..66ef9f405 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt @@ -129,6 +129,7 @@ private fun CreativeModeTab.Output.fluids(value: Item) { private fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { with(consumer) { + accept(MItems.ENERGY_CABLE) accept(MItems.MACHINES) accept(MItems.MachineUpgrades.Basic.LIST) accept(MItems.MachineUpgrades.Normal.LIST) 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 d9cffe638..4c50272dc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -46,6 +46,8 @@ object MItems { registry.register(bus) } + val ENERGY_CABLE: BlockItem by registry.register(MNames.ENERGY_CABLE) { BlockItem(MBlocks.ENERGY_CABLE, DEFAULT_PROPERTIES) } + val ANDROID_STATION: BlockItem by registry.register(MNames.ANDROID_STATION) { BlockItem(MBlocks.ANDROID_STATION, DEFAULT_PROPERTIES) } val ANDROID_CHARGER: BlockItem by registry.register(MNames.ANDROID_CHARGER) { BlockItem(MBlocks.ANDROID_CHARGER, DEFAULT_PROPERTIES) } val BATTERY_BANK: BlockItem by registry.register(MNames.BATTERY_BANK) { BlockItem(MBlocks.BATTERY_BANK, DEFAULT_PROPERTIES) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index 258cc69c5..43316e325 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -17,6 +17,7 @@ object MNames { const val DEV_CHEST = "dev_chest" const val PAINTER = "painter" const val MATTER_ENTANGLER = "matter_entangler" + const val ENERGY_CABLE = "energy_cable" // blocks const val ANDROID_STATION = "android_station" From 35e0bc65da3f5e64c4db47a68c3fcb68dec24f13 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 29 Dec 2023 16:39:19 +0700 Subject: [PATCH 1134/1199] Add more specifics to cable energy cap --- .../mc/otm/block/entity/cable/EnergyCableBlockEntity.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt index 20772b3cf..32e30d3ef 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt @@ -85,6 +85,12 @@ class EnergyCableBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte override val maxBatteryLevel: Decimal get() = Decimal.ZERO override var energyFlow: FlowDirection = FlowDirection.BI_DIRECTIONAL private set + + override val canSetBatteryLevel: Boolean + get() = false + + override val missingPower: Decimal + get() = Decimal.POSITIVE_INFINITY } inner class Node : GraphNode(::EnergyCableGraph) { From d5f1d3cde089c4475a08642cea5cf4dc49733a25 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 29 Dec 2023 16:41:56 +0700 Subject: [PATCH 1135/1199] e --- .../entity/cable/EnergyCableBlockEntity.kt | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt index 32e30d3ef..d7c3b5018 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.block.entity.cable import net.minecraft.core.BlockPos +import net.minecraft.core.Direction import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState @@ -53,17 +54,11 @@ class EnergyCableBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte } ru.dbotthepony.mc.otm.onceServer { - val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[blockRotation.side2Dir(side)]!!, true) - - if (newState !== blockState) - level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + updateBlockState(blockRotation.side2Dir(side), true) } } else { ru.dbotthepony.mc.otm.onceServer { - val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[blockRotation.side2Dir(side)]!!, false) - - if (newState !== blockState) - level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + updateBlockState(blockRotation.side2Dir(side), false) } } } @@ -98,23 +93,24 @@ class EnergyCableBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte override fun onNeighbour(link: Link) { if (link is DirectionLink) { - val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[link.direction]!!, true) - - if (newState !== blockState && SERVER_IS_LIVE) - level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + updateBlockState(link.direction, true) } } override fun onUnNeighbour(link: Link) { if (link is DirectionLink) { - val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[link.direction]!!, false) - - if (newState !== blockState && SERVER_IS_LIVE) - level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + updateBlockState(link.direction, false) } } } + private fun updateBlockState(side: Direction, status: Boolean) { + val newState = blockState.setValue(CableBlock.MAPPING_CONNECTION_PROP[side]!!, status) + + if (newState !== blockState && SERVER_IS_LIVE) + level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) + } + override val blockRotation: BlockRotation get() = BlockRotation.NORTH From 7c9657c6d2b3f9977e38f3a23a137a10c1419e2c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 29 Dec 2023 16:43:28 +0700 Subject: [PATCH 1136/1199] Get rid of block entity specific onceLevel --- .../dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt | 7 ------- .../mc/otm/block/entity/cable/EnergyCableBlockEntity.kt | 5 +++-- 2 files changed, 3 insertions(+), 9 deletions(-) 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 27718dd70..fd6ae1e0f 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 @@ -454,13 +454,6 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc _sides[blockRotation.dir2Side(dir)]!!.updateTracked() } - protected fun onceServer(action: (ServerLevel) -> Unit) { - val level = level - if (level is ServerLevel) { - tickList.once { action.invoke(level) } - } - } - override fun setChanged() { super.setChanged() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt index d7c3b5018..aeeb47cf8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt @@ -17,6 +17,7 @@ import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.graph.GraphNode +import ru.dbotthepony.mc.otm.onceServer import ru.dbotthepony.mc.otm.registry.MBlockEntities import java.util.Collections import java.util.EnumMap @@ -53,11 +54,11 @@ class EnergyCableBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte node.graph.livelyNodes.add(node) } - ru.dbotthepony.mc.otm.onceServer { + onceServer { updateBlockState(blockRotation.side2Dir(side), true) } } else { - ru.dbotthepony.mc.otm.onceServer { + onceServer { updateBlockState(blockRotation.side2Dir(side), false) } } From 023081eaaaa9ba15c3f202bcf385aa31f467eed3 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 30 Dec 2023 19:57:21 +0700 Subject: [PATCH 1137/1199] Fix accidental LIFO order on tick list when queueing ticks (when it always should be FIFO) --- .../dbotthepony/mc/otm/core/util/TickList.kt | 43 ++++++++----------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt index a02a49ca8..d3d006ba2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/TickList.kt @@ -1,21 +1,24 @@ package ru.dbotthepony.mc.otm.core.util import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap +import it.unimi.dsi.fastutil.objects.ObjectAVLTreeSet import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.core.addSorted +import java.util.concurrent.atomic.AtomicInteger class TickList : ITickable { - private val conditional = ArrayDeque() + private val conditional = ArrayList() private val conditionalQueued = ArrayList() - private val once = ArrayDeque() + private val once = ArrayList() private val onceQueued = ArrayList() private val always = ArrayList() private val alwaysQueued = ArrayList() private val toRemoveFromAlways = ArrayList() - private val timers = ArrayDeque() + private val timers = ObjectAVLTreeSet() + private val nextTimerID = AtomicInteger() private val namedTimers = Object2ObjectOpenHashMap(0) private var shouldTick = false @@ -24,21 +27,26 @@ class TickList : ITickable { private set var ticks = 0 private set + private var nextSometime = 0 inner class Timer(val timerTicks: Int, val runnable: Runnable) : Comparable { val ringAt = ticks + timerTicks + val timerID = nextTimerID.incrementAndGet() var finished = false private set init { shouldTick = true - timers.addSorted(this) + timers.add(this) } override fun compareTo(other: Timer): Int { - return ringAt.compareTo(other.ringAt) + var c = ringAt.compareTo(other.ringAt) + if (c != 0) return c + c = timerID.compareTo(other.timerID) + return c } fun execute() { @@ -174,22 +182,13 @@ class TickList : ITickable { try { if (conditional.isNotEmpty()) { shouldTick = true - val iterator = conditional.iterator() - - for (ticker in iterator) { - if (!ticker.tick()) { - iterator.remove() - } - } + conditional.removeIf { !it.tick() } } if (once.isNotEmpty()) { shouldTick = true - for (ticker in once) { - ticker.tick() - } - + for (ticker in once) ticker.tick() once.clear() } @@ -219,20 +218,14 @@ class TickList : ITickable { if (conditionalQueued.isNotEmpty()) { shouldTick = true - for (ticker in conditionalQueued) { - conditional.addFirst(ticker) - } - + for (ticker in conditionalQueued) conditional.add(ticker) conditionalQueued.clear() } if (onceQueued.isNotEmpty()) { shouldTick = true - for (ticker in onceQueued) { - once.addFirst(ticker) - } - + for (ticker in onceQueued) once.add(ticker) onceQueued.clear() } @@ -241,7 +234,7 @@ class TickList : ITickable { if (head.ringAt <= ticks) { head.execute() - timers.removeFirst() + timers.remove(head) } else { break } From 1c0cdb8b5bd427c9f953716c7d0d02cb9c8fdf44 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 30 Dec 2023 20:26:31 +0700 Subject: [PATCH 1138/1199] Energy cable tiers, fix some Client -> Server logic leaks in singleplayer --- .../mc/otm/datagen/loot/LootTablesData.kt | 1 + .../dbotthepony/mc/otm/datagen/tags/Tags.kt | 1 + .../mc/otm/OverdriveThatMatters.java | 2 + .../dbotthepony/mc/otm/GlobalEventHandler.kt | 3 + .../ru/dbotthepony/mc/otm/block/Cables.kt | 6 +- .../mc/otm/block/entity/MatteryBlockEntity.kt | 16 +++- .../block/entity/MatteryDeviceBlockEntity.kt | 6 +- .../entity/cable/EnergyCableBlockEntity.kt | 42 +++++---- .../block/entity/cable/EnergyCableGraph.kt | 86 +++++++++++++++++-- .../dbotthepony/mc/otm/config/CablesConfig.kt | 28 ++++++ .../dbotthepony/mc/otm/core/math/Decimal.kt | 6 +- .../ru/dbotthepony/mc/otm/graph/GraphNode.kt | 3 + .../mc/otm/registry/MBlockEntities.kt | 12 ++- .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 7 +- .../mc/otm/registry/MCreativeTabs.kt | 2 +- .../ru/dbotthepony/mc/otm/registry/MItems.kt | 6 +- .../ru/dbotthepony/mc/otm/registry/MNames.kt | 1 - .../blockstates/advanced_energy_cable.json | 74 ++++++++++++++++ .../blockstates/crude_energy_cable.json | 74 ++++++++++++++++ .../blockstates/regular_energy_cable.json | 74 ++++++++++++++++ .../superconductor_energy_cable.json | 74 ++++++++++++++++ 21 files changed, 487 insertions(+), 37 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/config/CablesConfig.kt create mode 100644 src/main/resources/assets/overdrive_that_matters/blockstates/advanced_energy_cable.json create mode 100644 src/main/resources/assets/overdrive_that_matters/blockstates/crude_energy_cable.json create mode 100644 src/main/resources/assets/overdrive_that_matters/blockstates/regular_energy_cable.json create mode 100644 src/main/resources/assets/overdrive_that_matters/blockstates/superconductor_energy_cable.json diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt index f3a46e108..afea9c71a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/loot/LootTablesData.kt @@ -50,6 +50,7 @@ fun addLootTables(lootTables: LootTables) { lootTables.dropsSelf(MBlocks.METAL_BEAM) { condition(ExplosionCondition.survivesExplosion()) } lootTables.dropsSelf(MBlocks.TRITANIUM_INGOT_BLOCK) { condition(ExplosionCondition.survivesExplosion()) } lootTables.dropsSelf(MBlocks.TRITANIUM_BARS) { condition(ExplosionCondition.survivesExplosion()) } + lootTables.dropsSelf(MBlocks.ENERGY_CABLES.values) { condition(ExplosionCondition.survivesExplosion()) } lootTables.dropsSelf(MBlocks.INFINITE_WATER_SOURCE) { condition(ExplosionCondition.survivesExplosion()) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index ad9a24614..e70e7c839 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -176,6 +176,7 @@ fun addTags(tagsProvider: TagsProvider) { tagsProvider.requiresPickaxe(MBlocks.TRITANIUM_DOOR.values, Tiers.IRON) tagsProvider.requiresPickaxe(MBlocks.TRITANIUM_TRAPDOOR.values, Tiers.IRON) tagsProvider.requiresPickaxe(MBlocks.PAINTER, Tiers.STONE) + tagsProvider.requiresPickaxe(MBlocks.ENERGY_CABLES.values, Tiers.STONE) tagsProvider.requiresPickaxe(listOf( MBlocks.ANDROID_STATION, diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index cbb6c61c9..424e15699 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -39,6 +39,7 @@ import ru.dbotthepony.mc.otm.client.render.blockentity.MatterBatteryBankRenderer import ru.dbotthepony.mc.otm.compat.adastra.AdAstraCompatKt; import ru.dbotthepony.mc.otm.compat.curios.CuriosCompatKt; import ru.dbotthepony.mc.otm.config.AndroidConfig; +import ru.dbotthepony.mc.otm.config.CablesConfig; import ru.dbotthepony.mc.otm.config.ClientConfig; import ru.dbotthepony.mc.otm.config.ExopackConfig; import ru.dbotthepony.mc.otm.config.ItemsConfig; @@ -142,6 +143,7 @@ public final class OverdriveThatMatters { ClientConfig.INSTANCE.register(); ServerConfig.INSTANCE.register(); + CablesConfig.INSTANCE.register(); ServerCompatConfig.INSTANCE.register(); AndroidConfig.INSTANCE.register(); ExopackConfig.INSTANCE.register(); diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt index 7e8d4de0f..a8f8c9096 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/GlobalEventHandler.kt @@ -40,6 +40,9 @@ private val serverCounter = AtomicInteger() private var _server: MinecraftServer? = null val isClient: Boolean by lazy { FMLLoader.getDist() == Dist.CLIENT } +val UNIVERSE_TICKS get() = postServerTick.ticks +val Level.ticksPassed get() = postWorldTick.computeIfAbsent(this) { TickList() }.ticks + fun lazyPerServer(fn: (MinecraftServer) -> V): Lazy { return AtomicallyInvalidatedLazy(serverCounter) { if (!SERVER_IS_LIVE) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt index e17fe4714..d0405c814 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt @@ -129,8 +129,8 @@ class StorageCableBlock : CableBlock(Properties.of().mapColor(MapColor.METAL).re } } -class EnergyCableBlock : CableBlock(Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock { - private val shapes = generateShapes(0.125) +class EnergyCableBlock(val factory: (blockPos: BlockPos, blockState: BlockState) -> BlockEntity) : CableBlock(Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock { + private val shapes = generateShapes(0.185) @Suppress("OVERRIDE_DEPRECATION") override fun getShape(blockState: BlockState, accessor: BlockGetter, pos: BlockPos, context: CollisionContext): VoxelShape { @@ -138,6 +138,6 @@ class EnergyCableBlock : CableBlock(Properties.of().mapColor(MapColor.METAL).req } override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { - return EnergyCableBlockEntity(blockPos, blockState) + return factory(blockPos, blockState) } } 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 fd6ae1e0f..bfbb8955c 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 @@ -62,6 +62,7 @@ import java.util.function.Consumer import java.util.function.Predicate import java.util.function.Supplier import java.util.stream.Stream +import kotlin.collections.ArrayList import kotlin.properties.ReadWriteProperty import kotlin.reflect.KProperty @@ -109,6 +110,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc protected val tickList = TickList() protected val blockStateChangesCounter = IntCounter() protected val dirtyListeners = ISubscriptable.Impl() + private val waitForServerLevel = ArrayList<() -> Unit>() /** * Shared savetables, written both to level storage and to item tag @@ -166,6 +168,14 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } } + protected fun waitForServerLevel(lambda: () -> Unit) { + if (level is ServerLevel) { + lambda.invoke() + } else if (level == null) { + waitForServerLevel.add(lambda) + } + } + interface SideListener : Supplier>, ISubscriptable> inner class Side(val side: RelativeSide) { @@ -191,7 +201,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc override fun addListener(listener: Consumer>): ISubscriptable.L { val l = listeners.addListener(listener) - listener.accept(value) + if (level is ServerLevel) listener.accept(value) return l } @@ -521,6 +531,10 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc } } } + + waitForServerLevel.forEach { it.invoke() } + } else { + waitForServerLevel.clear() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt index 744da7694..9eeab72a6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryDeviceBlockEntity.kt @@ -179,7 +179,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo } init { - tickList.once { + waitForServerLevel { redstoneControl.addListener { updateTickerState() } @@ -388,7 +388,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo updateTickerState() } - tickList.once { + waitForServerLevel { redstoneControl.addListener { updateTickerState() } @@ -670,7 +670,7 @@ abstract class MatteryDeviceBlockEntity(blockEntityType: BlockEntityType<*>, blo savetables.bool(::automatePush, "itemhandler_${side}_automatePush") savetables.enum(::mode, "itemhandler_${side}_mode", ItemHandlerMode::valueOf) - tickList.once { + waitForServerLevel { redstoneControl.addListener { updateTickerState() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt index aeeb47cf8..23b852c37 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt @@ -2,8 +2,10 @@ package ru.dbotthepony.mc.otm.block.entity.cable import net.minecraft.core.BlockPos import net.minecraft.core.Direction +import net.minecraft.server.level.ServerLevel import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block +import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState import net.minecraftforge.common.capabilities.ForgeCapabilities import ru.dbotthepony.mc.otm.SERVER_IS_LIVE @@ -12,13 +14,12 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage -import ru.dbotthepony.mc.otm.core.ifPresentK +import ru.dbotthepony.mc.otm.config.CablesConfig import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.graph.GraphNode import ru.dbotthepony.mc.otm.onceServer -import ru.dbotthepony.mc.otm.registry.MBlockEntities import java.util.Collections import java.util.EnumMap @@ -27,7 +28,7 @@ import java.util.EnumMap // this allows simpler implementation and faster code, while also reducing possibility of duplication exploits -class EnergyCableBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryBlockEntity(MBlockEntities.ENERGY_CABLE, blockPos, blockState) { +abstract class EnergyCableBlockEntity(type: BlockEntityType<*>, blockPos: BlockPos, blockState: BlockState) : MatteryBlockEntity(type, blockPos, blockState) { inner class CableSide(val side: RelativeSide) : IMatteryEnergyStorage { var isEnabled = true set(value) { @@ -47,19 +48,17 @@ class EnergyCableBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte val neighbour = sides[side]!!.trackEnergy() init { - neighbour.addListener { - if (isEnabled) { - if (it.isPresent) { - if (it.resolve().get() !is CableSide) { - node.graph.livelyNodes.add(node) + waitForServerLevel { + neighbour.addListener { + if (isEnabled) { + if (it.isPresent) { + if (it.resolve().get() !is CableSide) { + node.graph.livelyNodes.add(node) + } } onceServer { - updateBlockState(blockRotation.side2Dir(side), true) - } - } else { - onceServer { - updateBlockState(blockRotation.side2Dir(side), false) + updateBlockState(blockRotation.side2Dir(side), it.isPresent || node.neighboursView[GraphNode.link(blockRotation.side2Dir(side))] != null) } } } @@ -71,7 +70,7 @@ class EnergyCableBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte } override fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { - return node.graph.receiveEnergy(howMuch, simulate) + return node.graph.receiveEnergy(howMuch, simulate, node, side) } override var batteryLevel: Decimal @@ -103,6 +102,11 @@ class EnergyCableBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte updateBlockState(link.direction, false) } } + + val blockEntity get() = this@EnergyCableBlockEntity + val canTraverse get() = energyThroughput > Decimal.ZERO + val energyThroughput get() = this@EnergyCableBlockEntity.energyThroughput + val position: BlockPos get() = this@EnergyCableBlockEntity.blockPos } private fun updateBlockState(side: Direction, status: Boolean) { @@ -112,7 +116,10 @@ class EnergyCableBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte level?.setBlock(blockPos, newState, Block.UPDATE_CLIENTS) } - override val blockRotation: BlockRotation + // whenever this changes, graph#invalidatePathCache() MUST be called + abstract val energyThroughput: Decimal + + final override val blockRotation: BlockRotation get() = BlockRotation.NORTH private val energySidesInternal = EnumMap(RelativeSide::class.java) @@ -134,3 +141,8 @@ class EnergyCableBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte exposeGlobally(MatteryCapability.ENERGY_CABLE_NODE, node) } } + +class SimpleEnergyCableBlockEntity(type: BlockEntityType<*>, blockPos: BlockPos, blockState: BlockState, val config: CablesConfig.E) : EnergyCableBlockEntity(type, blockPos, blockState) { + override val energyThroughput: Decimal + get() = config.throughput +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableGraph.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableGraph.kt index c5e25be5b..db8a71f7a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableGraph.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableGraph.kt @@ -1,23 +1,92 @@ package ru.dbotthepony.mc.otm.block.entity.cable +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap +import it.unimi.dsi.fastutil.objects.ObjectAVLTreeSet import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet import ru.dbotthepony.mc.otm.capability.receiveEnergy import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.graph.GraphNodeList +import kotlin.math.ln class EnergyCableGraph : GraphNodeList() { val livelyNodes = ObjectOpenHashSet() + private val pathCache = Object2ObjectOpenHashMap, Decimal?>() + + private class SearchNode(val node: EnergyCableBlockEntity.Node, target: EnergyCableBlockEntity.Node, var parent: SearchNode? = null) : Comparable { + var heuristics: Double = node.position.distSqr(target.position) * 0.0001 - ln(node.energyThroughput.coerceAtMost(Decimal.LONG_MAX_VALUE).toDouble()) + + override fun compareTo(other: SearchNode): Int { + return heuristics.compareTo(other.heuristics) + } + } + + fun invalidatePathCache() { + pathCache.clear() + } + + private fun getPath(a: EnergyCableBlockEntity.Node, b: EnergyCableBlockEntity.Node): Decimal? { + if (!a.canTraverse || !b.canTraverse) + return null + + val key = a to b + + if (key in pathCache) + return pathCache[key] + + // no free paths available, try to find extra one + // while this use A* algorithm, this is done purely for biasing search towards end point (to speed up search), + // on small cable networks simple flooding will do just fine, if we consider overloaded cables as closed flood gates + val openNodes = ArrayList() + val seenNodes = ObjectOpenHashSet() + + openNodes.add(SearchNode(a, b)) + + while (openNodes.isNotEmpty()) { + val first = openNodes.min() + openNodes.remove(first) + + if (first.node === b) { + // solution found + val solution = ArrayList() + + var last = first.parent + solution.add(first.node) + + while (last != null) { + solution.add(last.node) + last = last.parent + } + + val calc = solution.minOf { it.energyThroughput } + pathCache[key] = calc + return calc + } else { + for (neighbour in first.node.neighboursView.values) { + if (!seenNodes.add(neighbour) || !neighbour.canTraverse) continue + openNodes.add(SearchNode(neighbour, b, first)) + } + } + } + + // solution does not exist + pathCache[key] = null + return null + } + override fun onNodeRemoved(node: EnergyCableBlockEntity.Node) { livelyNodes.remove(node) + invalidatePathCache() } override fun onNodeAdded(node: EnergyCableBlockEntity.Node) { livelyNodes.add(node) + invalidatePathCache() } - fun receiveEnergy(howMuch: Decimal, simulate: Boolean): Decimal { + fun receiveEnergy(howMuch: Decimal, simulate: Boolean, fromNode: EnergyCableBlockEntity.Node, fromSide: RelativeSide): Decimal { val itr = livelyNodes.iterator() var received = Decimal.ZERO var residue = howMuch @@ -27,15 +96,20 @@ class EnergyCableGraph : GraphNodeList { } override fun compareTo(other: Decimal): Int { - return if (other is Regular) + return if (other === Zero) + signum() + else if (other is Regular) mag.compareTo(other.mag) else if (other === PositiveInfinity) -1 else if (other === NegativeInfinity) 1 - else if (other === Zero) - signum() else throw RuntimeException("unreachable code") } 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 05899b77f..e6b2b754e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/GraphNode.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/GraphNode.kt @@ -13,6 +13,8 @@ import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.core.util.IConditionalTickable import ru.dbotthepony.mc.otm.core.util.ITickable +import java.util.* +import kotlin.collections.ArrayList open class GraphNode, G : GraphNodeList>(val graphFactory: () -> G) { interface Link { @@ -30,6 +32,7 @@ open class GraphNode, G : GraphNodeList>(val graphFact } private val neighbours = Object2ObjectOpenHashMap() + val neighboursView: Map = Collections.unmodifiableMap(neighbours) var graph: G = graphFactory.invoke() internal set 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 a0697f9c7..9036fc742 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt @@ -15,7 +15,7 @@ import ru.dbotthepony.mc.otm.block.entity.tech.* import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity import ru.dbotthepony.mc.otm.block.entity.blackhole.BlockEntityExplosionDebugger import ru.dbotthepony.mc.otm.block.entity.blackhole.BlockEntitySphereDebugger -import ru.dbotthepony.mc.otm.block.entity.cable.EnergyCableBlockEntity +import ru.dbotthepony.mc.otm.block.entity.cable.SimpleEnergyCableBlockEntity import ru.dbotthepony.mc.otm.block.entity.decorative.CargoCrateBlockEntity import ru.dbotthepony.mc.otm.block.entity.decorative.DevChestBlockEntity import ru.dbotthepony.mc.otm.block.entity.decorative.FluidTankBlockEntity @@ -30,6 +30,9 @@ import ru.dbotthepony.mc.otm.block.entity.tech.EnergyServoBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.GravitationStabilizerBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.PlatePressBlockEntity import ru.dbotthepony.mc.otm.client.render.blockentity.* +import ru.dbotthepony.mc.otm.config.CablesConfig +import ru.dbotthepony.mc.otm.core.collect.SupplierMap +import ru.dbotthepony.mc.otm.core.getValue import java.util.function.Supplier @Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") // Type<*> is unused in BlockEntityType.Builder @@ -74,7 +77,12 @@ object MBlockEntities { val DEV_CHEST by register(MNames.DEV_CHEST, ::DevChestBlockEntity, MBlocks::DEV_CHEST) val PAINTER by register(MNames.PAINTER, ::PainterBlockEntity, MBlocks::PAINTER) val MATTER_ENTANGLER by register(MNames.MATTER_ENTANGLER, ::MatterEntanglerBlockEntity, MBlocks::MATTER_ENTANGLER) - val ENERGY_CABLE by register(MNames.ENERGY_CABLE, ::EnergyCableBlockEntity, MBlocks::ENERGY_CABLE) + + val ENERGY_CABLES: Map> = SupplierMap(CablesConfig.E.entries.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 + }) val POWERED_FURNACE: BlockEntityType by registry.register(MNames.POWERED_FURNACE) { BlockEntityType.Builder.of({ a, b -> MBlocks.POWERED_FURNACE.newBlockEntity(a, b) }, MBlocks.POWERED_FURNACE).build(null) } val POWERED_BLAST_FURNACE: BlockEntityType by registry.register(MNames.POWERED_BLAST_FURNACE) { BlockEntityType.Builder.of({ a, b -> MBlocks.POWERED_BLAST_FURNACE.newBlockEntity(a, b) }, MBlocks.POWERED_BLAST_FURNACE).build(null) } 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 266a98416..bb75430c5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -77,9 +77,11 @@ import ru.dbotthepony.mc.otm.block.tech.EssenceStorageBlock import ru.dbotthepony.mc.otm.block.tech.PhantomAttractorBlock import ru.dbotthepony.mc.otm.block.tech.PlatePressBlock import ru.dbotthepony.mc.otm.block.tech.PoweredFurnaceBlock +import ru.dbotthepony.mc.otm.config.CablesConfig import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.collect.SupplierList +import ru.dbotthepony.mc.otm.core.collect.SupplierMap import ru.dbotthepony.mc.otm.shapes.BlockShapes object MBlocks { @@ -115,7 +117,10 @@ object MBlocks { val MATTER_RECONSTRUCTOR: MatterReconstructorBlock by registry.register(MNames.MATTER_RECONSTRUCTOR) { MatterReconstructorBlock() } val PAINTER: PainterBlock by registry.register(MNames.PAINTER) { PainterBlock() } val MATTER_ENTANGLER: MatterEntanglerBlock by registry.register(MNames.MATTER_ENTANGLER) { MatterEntanglerBlock() } - val ENERGY_CABLE: EnergyCableBlock by registry.register(MNames.ENERGY_CABLE) { EnergyCableBlock() } + + val ENERGY_CABLES: Map = SupplierMap(CablesConfig.E.entries.map { conf -> + conf to registry.register("${conf.name.lowercase()}_energy_cable") { EnergyCableBlock { a, b -> MBlockEntities.ENERGY_CABLES[conf]!!.create(a, b)!! } }::get + }) val STORAGE_BUS: Block by registry.register(MNames.STORAGE_BUS) { StorageBusBlock() } val STORAGE_IMPORTER: Block by registry.register(MNames.STORAGE_IMPORTER) { StorageImporterBlock() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt index 66ef9f405..258ca4ed1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt @@ -129,7 +129,7 @@ private fun CreativeModeTab.Output.fluids(value: Item) { private fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) { with(consumer) { - accept(MItems.ENERGY_CABLE) + accept(MItems.ENERGY_CABLES.values) accept(MItems.MACHINES) accept(MItems.MachineUpgrades.Basic.LIST) accept(MItems.MachineUpgrades.Normal.LIST) 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 4c50272dc..0d3611aaa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -17,9 +17,11 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.capability.ITieredUpgradeSet import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.UpgradeType +import ru.dbotthepony.mc.otm.config.CablesConfig import ru.dbotthepony.mc.otm.config.ItemsConfig import ru.dbotthepony.mc.otm.core.collect.SupplierList import ru.dbotthepony.mc.otm.core.TranslatableComponent +import ru.dbotthepony.mc.otm.core.collect.SupplierMap import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.item.* import ru.dbotthepony.mc.otm.item.exopack.ExopackProbeItem @@ -46,7 +48,9 @@ object MItems { registry.register(bus) } - val ENERGY_CABLE: BlockItem by registry.register(MNames.ENERGY_CABLE) { BlockItem(MBlocks.ENERGY_CABLE, DEFAULT_PROPERTIES) } + val ENERGY_CABLES: Map = SupplierMap(CablesConfig.E.entries.map { conf -> + conf to registry.register("${conf.name.lowercase()}_energy_cable") { BlockItem(MBlocks.ENERGY_CABLES[conf]!!, DEFAULT_PROPERTIES) }::get + }) val ANDROID_STATION: BlockItem by registry.register(MNames.ANDROID_STATION) { BlockItem(MBlocks.ANDROID_STATION, DEFAULT_PROPERTIES) } val ANDROID_CHARGER: BlockItem by registry.register(MNames.ANDROID_CHARGER) { BlockItem(MBlocks.ANDROID_CHARGER, DEFAULT_PROPERTIES) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt index 43316e325..258cc69c5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MNames.kt @@ -17,7 +17,6 @@ object MNames { const val DEV_CHEST = "dev_chest" const val PAINTER = "painter" const val MATTER_ENTANGLER = "matter_entangler" - const val ENERGY_CABLE = "energy_cable" // blocks const val ANDROID_STATION = "android_station" diff --git a/src/main/resources/assets/overdrive_that_matters/blockstates/advanced_energy_cable.json b/src/main/resources/assets/overdrive_that_matters/blockstates/advanced_energy_cable.json new file mode 100644 index 000000000..ae8a815be --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/blockstates/advanced_energy_cable.json @@ -0,0 +1,74 @@ +{ + "multipart": [ + { + "apply": { + "model": "overdrive_that_matters:block/storage_cable_core" + } + }, + + { + "when": { + "connect_south": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection" + } + }, + + { + "when": { + "connect_west": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection", + "y": 90 + } + }, + + { + "when": { + "connect_north": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection", + "y": 180 + } + }, + + { + "when": { + "connect_east": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection", + "y": 270 + } + }, + + { + "when": { + "connect_up": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection", + "x": 90 + } + }, + + { + "when": { + "connect_down": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection", + "x": 270 + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/blockstates/crude_energy_cable.json b/src/main/resources/assets/overdrive_that_matters/blockstates/crude_energy_cable.json new file mode 100644 index 000000000..ae8a815be --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/blockstates/crude_energy_cable.json @@ -0,0 +1,74 @@ +{ + "multipart": [ + { + "apply": { + "model": "overdrive_that_matters:block/storage_cable_core" + } + }, + + { + "when": { + "connect_south": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection" + } + }, + + { + "when": { + "connect_west": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection", + "y": 90 + } + }, + + { + "when": { + "connect_north": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection", + "y": 180 + } + }, + + { + "when": { + "connect_east": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection", + "y": 270 + } + }, + + { + "when": { + "connect_up": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection", + "x": 90 + } + }, + + { + "when": { + "connect_down": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection", + "x": 270 + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/blockstates/regular_energy_cable.json b/src/main/resources/assets/overdrive_that_matters/blockstates/regular_energy_cable.json new file mode 100644 index 000000000..ae8a815be --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/blockstates/regular_energy_cable.json @@ -0,0 +1,74 @@ +{ + "multipart": [ + { + "apply": { + "model": "overdrive_that_matters:block/storage_cable_core" + } + }, + + { + "when": { + "connect_south": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection" + } + }, + + { + "when": { + "connect_west": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection", + "y": 90 + } + }, + + { + "when": { + "connect_north": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection", + "y": 180 + } + }, + + { + "when": { + "connect_east": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection", + "y": 270 + } + }, + + { + "when": { + "connect_up": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection", + "x": 90 + } + }, + + { + "when": { + "connect_down": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection", + "x": 270 + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/blockstates/superconductor_energy_cable.json b/src/main/resources/assets/overdrive_that_matters/blockstates/superconductor_energy_cable.json new file mode 100644 index 000000000..ae8a815be --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/blockstates/superconductor_energy_cable.json @@ -0,0 +1,74 @@ +{ + "multipart": [ + { + "apply": { + "model": "overdrive_that_matters:block/storage_cable_core" + } + }, + + { + "when": { + "connect_south": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection" + } + }, + + { + "when": { + "connect_west": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection", + "y": 90 + } + }, + + { + "when": { + "connect_north": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection", + "y": 180 + } + }, + + { + "when": { + "connect_east": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection", + "y": 270 + } + }, + + { + "when": { + "connect_up": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection", + "x": 90 + } + }, + + { + "when": { + "connect_down": true + }, + + "apply": { + "model": "overdrive_that_matters:block/storage_cable_connection", + "x": 270 + } + } + ] +} \ No newline at end of file From 8d222125b5145222ae88ca47b34d2e0652d8eafd Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 31 Dec 2023 09:41:03 +0700 Subject: [PATCH 1139/1199] Specify max battery of cables as positive infinity --- .../mc/otm/block/entity/cable/EnergyCableBlockEntity.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt index 23b852c37..e9ce7b301 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt @@ -77,8 +77,8 @@ abstract class EnergyCableBlockEntity(type: BlockEntityType<*>, blockPos: BlockP get() = Decimal.ZERO set(value) {} - override val maxBatteryLevel: Decimal get() = Decimal.ZERO - override var energyFlow: FlowDirection = FlowDirection.BI_DIRECTIONAL + override val maxBatteryLevel: Decimal get() = Decimal.POSITIVE_INFINITY + override var energyFlow: FlowDirection = FlowDirection.INPUT private set override val canSetBatteryLevel: Boolean From a162caefb685343191c214cbd99e0d2ddc1dc205 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 31 Dec 2023 10:07:44 +0700 Subject: [PATCH 1140/1199] Use pecrentage function --- .../mc/otm/compat/jade/providers/MatterStorageProvider.kt | 2 +- .../mc/otm/compat/jade/providers/MatteryEnergyProvider.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterStorageProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterStorageProvider.kt index 3a150f84b..e6f7ddd03 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterStorageProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterStorageProvider.kt @@ -62,7 +62,7 @@ object MatterStorageProvider : IBlockComponentProvider, IServerDataProvider Date: Sun, 31 Dec 2023 10:29:27 +0700 Subject: [PATCH 1141/1199] Don't remove self from lively nodes when all we can do is self-feed --- .../dbotthepony/mc/otm/block/entity/cable/EnergyCableGraph.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableGraph.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableGraph.kt index db8a71f7a..b5df5d5de 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableGraph.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableGraph.kt @@ -96,8 +96,10 @@ class EnergyCableGraph : GraphNodeList Date: Sun, 31 Dec 2023 10:53:55 +0700 Subject: [PATCH 1142/1199] Fix not accounting initial cable node limit when transfering energy --- .../dbotthepony/mc/otm/block/entity/cable/EnergyCableGraph.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableGraph.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableGraph.kt index b5df5d5de..8e61e22ce 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableGraph.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableGraph.kt @@ -89,7 +89,7 @@ class EnergyCableGraph : GraphNodeList Date: Sun, 31 Dec 2023 12:54:59 +0700 Subject: [PATCH 1143/1199] Downgrade dependencies --- gradle.properties | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gradle.properties b/gradle.properties index 09768289d..74f9e8fe7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,24 +10,24 @@ mod_version=1.4 use_commit_hash_in_version=true -mc_version=1.20.2 -jei_mc_version=1.20.2 -curios_mc_version=1.20.2 +mc_version=1.20.1 +jei_mc_version=1.20.1 +curios_mc_version=1.20.1 forge_gradle_version=[6.0.14,6.2) -forge_version=48.1.0 +forge_version=47.2.19 mixingradle_version=0.7.33 mixin_version=0.8.5 -jei_version=16.0.0.28 +jei_version=15.2.0.27 jupiter_version=5.9.2 -curios_version=6.0.2 +curios_version=5.4.7 cosmetic_armor_reworked_id=4764779 ad_astra_id=4594155 botarium_id=4594094 resourceful_lib_id=4598948 resourceful_config_id=4576455 -jade_id=4818518 +jade_id=4986594 configured_id=4462894 kotlin_for_forge_version=4.7.0 From b2d7f6c00235d1cf68ec61a47738ffb62c0d3e14 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 31 Dec 2023 16:52:17 +0700 Subject: [PATCH 1144/1199] Set copyIdeResources to true --- build.gradle.kts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index 9426d470c..4c71e581e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -181,6 +181,8 @@ configurations { minecraft { mappings("official", mc_version) + copyIdeResources.set(true) + accessTransformer(file("src/main/resources/META-INF/accesstransformer.cfg")) runs { From 242876d533c4bac4e60aa2c5b000eb80bed8f090 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 31 Dec 2023 17:01:57 +0700 Subject: [PATCH 1145/1199] Migrate to custom network context --- .../mc/otm/android/AndroidResearchManager.kt | 7 ++- .../otm/android/feature/ItemMagnetFeature.kt | 4 +- .../otm/android/feature/JumpBoostFeature.kt | 19 ++++---- .../otm/android/feature/ShockwaveFeature.kt | 4 +- .../vanilla/ExtendedInventoryHandler.kt | 5 +-- .../mc/otm/item/QuantumBatteryItem.kt | 4 +- .../mc/otm/item/weapon/AbstractWeaponItem.kt | 10 ++--- .../mc/otm/matter/MatterManager.kt | 3 +- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 6 +-- .../mc/otm/menu/data/NetworkedItemView.kt | 5 +-- .../mc/otm/menu/matter/MatterPanelMenu.kt | 11 ++--- .../mc/otm/network/GenericNetworkChannel.kt | 5 +-- .../mc/otm/network/MatteryNetworkChannel.kt | 19 ++++++-- .../network/MatteryPlayerNetworkChannel.kt | 45 +++++++++---------- .../mc/otm/network/MenuNetworkChannel.kt | 5 +-- 15 files changed, 76 insertions(+), 76 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchManager.kt index a7713349c..86eaa2846 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchManager.kt @@ -13,7 +13,6 @@ import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener import net.minecraft.util.profiling.ProfilerFiller import net.minecraftforge.event.AddReloadListenerEvent import net.minecraftforge.event.OnDatapackSyncEvent -import net.minecraftforge.event.network.CustomPayloadEvent import net.minecraftforge.network.PacketDistributor import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.MINECRAFT_SERVER @@ -26,6 +25,7 @@ import ru.dbotthepony.mc.otm.core.fromNetwork import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.core.toNetwork import ru.dbotthepony.mc.otm.network.GenericNetworkChannel +import ru.dbotthepony.mc.otm.network.MNetworkContext import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.onceServer import java.util.LinkedList @@ -111,12 +111,11 @@ object AndroidResearchManager : SimpleJsonResourceReloadListener(GsonBuilder().s LOGGER.debug("Constructed android research registry packet, ${buff.writerIndex()} bytes in size") } - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { context.packetHandled = true - if (NULLABLE_MINECRAFT_SERVER is IntegratedServer) { + if (NULLABLE_MINECRAFT_SERVER is IntegratedServer) return - } val builder = ImmutableMap.builder() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt index 77741942c..1112beb02 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt @@ -5,7 +5,6 @@ import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.network.FriendlyByteBuf import net.minecraft.world.entity.Entity import net.minecraft.world.entity.item.ItemEntity -import net.minecraftforge.event.network.CustomPayloadEvent import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability @@ -20,6 +19,7 @@ import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.core.position import ru.dbotthepony.mc.otm.core.math.times import ru.dbotthepony.mc.otm.network.GenericNetworkChannel +import ru.dbotthepony.mc.otm.network.MNetworkContext import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.registry.AndroidFeatures import java.util.UUID @@ -44,7 +44,7 @@ class ItemEntityDataPacket(val itemUUID: Int, val owner: UUID? = null, val age: buff.writeBoolean(hasPickupDelay) } - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { val level = minecraft.player?.level() as ClientLevel? ?: return val entity = level.getEntity(itemUUID) as ItemEntity? ?: return datatable[entity] = SharedItemEntityData(owner, age, lifespan, hasPickupDelay) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt index 1c38e41ca..904efea81 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt @@ -4,7 +4,6 @@ import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.FriendlyByteBuf import net.minecraft.server.level.ServerPlayer import net.minecraft.sounds.SoundSource -import net.minecraftforge.event.network.CustomPayloadEvent import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact @@ -16,19 +15,19 @@ import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.network.GenericNetworkChannel +import ru.dbotthepony.mc.otm.network.MNetworkContext import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel import ru.dbotthepony.mc.otm.network.SmokeParticlesPacket import ru.dbotthepony.mc.otm.registry.AndroidFeatures import ru.dbotthepony.mc.otm.registry.MSoundEvents -import java.util.function.Supplier object TriggerJumpBoostPacket : MatteryPacket { override fun write(buff: FriendlyByteBuf) { // no op } - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { val mattery = context.sender?.matteryPlayer ?: return if (!mattery.isAndroid) @@ -39,15 +38,13 @@ object TriggerJumpBoostPacket : MatteryPacket { if (feature.isActive && feature.cooldown <= 4 && mattery.androidEnergy.extractEnergyExact(AndroidConfig.JumpBoost.ENERGY_COST, false)) { feature.putOnCooldown() - context.sender?.let { - it.level().playSound( - it, it, - MSoundEvents.ANDROID_JUMP_BOOST, SoundSource.PLAYERS, - 1f, 1f - ) + context.sender.level().playSound( + context.sender, context.sender, + MSoundEvents.ANDROID_JUMP_BOOST, SoundSource.PLAYERS, + 1f, 1f + ) - GenericNetworkChannel.makeSmoke(it, it.x, it.y, it.z) - } + GenericNetworkChannel.makeSmoke(context.sender, context.sender.x, context.sender.y, context.sender.z) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt index 02289c405..a1bbe002f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt @@ -8,7 +8,6 @@ import net.minecraft.sounds.SoundSource import net.minecraft.world.entity.Entity import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.monster.warden.Warden -import net.minecraftforge.event.network.CustomPayloadEvent import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact @@ -26,6 +25,7 @@ import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.core.math.roundToIntVector import ru.dbotthepony.mc.otm.core.math.times import ru.dbotthepony.mc.otm.core.position +import ru.dbotthepony.mc.otm.network.MNetworkContext import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel import ru.dbotthepony.mc.otm.network.ShockwaveEffectPacket @@ -44,7 +44,7 @@ object TriggerShockwavePacket : MatteryPacket { // no op } - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { val shockwave = context.sender?.matteryPlayer?.getFeature(AndroidFeatures.SHOCKWAVE) ?: return if (!shockwave.isOnCooldown && shockwave.isActive && shockwave.airTicks > 0) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/ExtendedInventoryHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/ExtendedInventoryHandler.kt index a950b227e..910a6933f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/ExtendedInventoryHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/ExtendedInventoryHandler.kt @@ -13,15 +13,14 @@ import net.minecraft.world.inventory.InventoryMenu import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items -import net.minecraftforge.event.network.CustomPayloadEvent import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatterySlot +import ru.dbotthepony.mc.otm.network.MNetworkContext import ru.dbotthepony.mc.otm.network.MatteryPacket import java.util.* -import java.util.function.Supplier private val menuConfigurations = WeakHashMap() @@ -224,7 +223,7 @@ class InventoryScrollPacket(val scroll: Int) : MatteryPacket { }.scroll = scroll } - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { play(context.sender ?: throw IllegalStateException("Illegal side")) } 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 9c481ffa6..9abcfed1b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt @@ -21,7 +21,6 @@ import net.minecraftforge.common.capabilities.ICapabilityProvider import net.minecraftforge.common.util.LazyOptional import net.minecraftforge.event.TickEvent import net.minecraftforge.event.TickEvent.ServerTickEvent -import net.minecraftforge.event.network.CustomPayloadEvent import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.MatteryCapability @@ -50,6 +49,7 @@ import ru.dbotthepony.mc.otm.isClientThread import ru.dbotthepony.mc.otm.isServerThread import ru.dbotthepony.mc.otm.lazyPerServer import ru.dbotthepony.mc.otm.network.GenericNetworkChannel +import ru.dbotthepony.mc.otm.network.MNetworkContext import ru.dbotthepony.mc.otm.network.MatteryPacket import java.util.* import java.util.function.Function @@ -372,7 +372,7 @@ class QuantumBatteryItem(val savedataID: String, val balanceValues: EnergyBalanc buff.writeDecimal(received) } - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { val data = type.clientData.computeIfAbsent(uuid, Function { UnboundValues(it) }) data.energy = energy data.passed = passed diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt index 31cf99e7e..5c8a81d7d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt @@ -18,7 +18,6 @@ import net.minecraftforge.client.event.RenderHandEvent import net.minecraftforge.client.event.RenderPlayerEvent import net.minecraftforge.client.event.ViewportEvent import net.minecraftforge.event.TickEvent -import net.minecraftforge.event.network.CustomPayloadEvent import net.minecraftforge.fml.LogicalSide import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.client.font @@ -41,6 +40,7 @@ import ru.dbotthepony.mc.otm.core.nbt.ints import ru.dbotthepony.mc.otm.core.nbt.uuids import ru.dbotthepony.mc.otm.core.tagNotNull import ru.dbotthepony.mc.otm.core.util.formatPower +import ru.dbotthepony.mc.otm.network.MNetworkContext import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.WeaponNetworkChannel import java.util.* @@ -60,7 +60,7 @@ enum class WeaponScopePacket(val scope: Boolean) : MatteryPacket { buff.writeBoolean(scope) } - override fun play(context: CustomPayloadEvent.Context){ + override fun play(context: MNetworkContext) { // TODO: Manual synchronization val stack = context.sender!!.mainHandItem val item = stack.item as? AbstractWeaponItem<*> ?: return @@ -80,7 +80,7 @@ enum class WeaponFireInputPacket(val primary: Boolean) : MatteryPacket { buff.writeBoolean(primary) } - override fun play(context: CustomPayloadEvent.Context){ + override fun play(context: MNetworkContext) { // TODO: Manual synchronization val stack = context.sender!!.mainHandItem val item = stack.item as? AbstractWeaponItem<*> ?: return @@ -91,9 +91,9 @@ enum class WeaponFireInputPacket(val primary: Boolean) : MatteryPacket { item.dataTable = null if (primary) - item.tryPrimaryFire(stack, context.sender!!) + item.tryPrimaryFire(stack, context.sender) else - item.trySecondaryFire(stack, context.sender!!) + item.trySecondaryFire(stack, context.sender) (item as AbstractWeaponItem).dataTable = predictedData } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 8aa89b1a0..18f0572ff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -97,6 +97,7 @@ import ru.dbotthepony.mc.otm.core.util.writeCollection import ru.dbotthepony.mc.otm.core.writeItemType import ru.dbotthepony.mc.otm.milliTime import ru.dbotthepony.mc.otm.network.GenericNetworkChannel +import ru.dbotthepony.mc.otm.network.MNetworkContext import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.registry.RegistryDelegate import ru.dbotthepony.mc.otm.secondTime @@ -1888,7 +1889,7 @@ object MatterManager { buff.writeBytes(payload, 0, length) } - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { if (SERVER_IS_LIVE) return // singleplayer or LAN host diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 37d98e6fe..387ace84b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -24,7 +24,6 @@ import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.enchantment.EnchantmentHelper.hasBindingCurse import net.minecraft.world.level.block.entity.BlockEntity -import net.minecraftforge.event.network.CustomPayloadEvent import ru.dbotthepony.mc.otm.capability.IMatteryUpgrade import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.capability.UpgradeType @@ -55,6 +54,7 @@ import ru.dbotthepony.mc.otm.core.util.NullValueCodec import ru.dbotthepony.mc.otm.core.util.VarIntValueCodec import ru.dbotthepony.mc.otm.menu.input.InstantBooleanInput import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget +import ru.dbotthepony.mc.otm.network.MNetworkContext import ru.dbotthepony.mc.otm.network.MatteryPacket import ru.dbotthepony.mc.otm.network.MenuFieldPacket import ru.dbotthepony.mc.otm.network.MenuNetworkChannel @@ -118,9 +118,9 @@ abstract class MatteryMenu( buff.writeBytes(payload) } - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { val menu = context.sender?.containerMenu as? MatteryMenu ?: return - if (menu.containerId != containerId || !menu.stillValid(context.sender!!)) return + if (menu.containerId != containerId || !menu.stillValid(context.sender)) return val input = menu.playerInputs.getOrNull(inputId) ?: return if (!input.test(context.sender)) return input.invoke(input.codec.read(DataInputStream(FastByteArrayInputStream(payload)))) 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 12dda814a..f79daf008 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 @@ -11,7 +11,6 @@ import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.ClickAction import net.minecraft.world.inventory.ClickType import net.minecraft.world.item.ItemStack -import net.minecraftforge.event.network.CustomPayloadEvent import net.minecraftforge.network.PacketDistributor import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.addSorted @@ -42,7 +41,7 @@ data class ItemViewInteractPacket(val stackID: Int, val type: ClickType, val act buff.writeEnum(action) } - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { val sender = context.sender ?: return if (!sender.isSpectator) { @@ -59,7 +58,7 @@ data class ItemViewInteractPacket(val stackID: Int, val type: ClickType, val act } abstract class NetworkedItemViewPacket : MatteryPacket { - final override fun play(context: CustomPayloadEvent.Context) { + final override fun play(context: MNetworkContext) { val get = Minecraft.getInstance().player?.containerMenu ?: return val view = (get as? INetworkedItemViewProvider)?.networkedItemView ?: throw IllegalStateException("No NetworkedItemView is present in currently open menu") action(view) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt index 8a08a7dfa..1827a4877 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt @@ -5,8 +5,6 @@ import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.item.Item -import net.minecraftforge.event.network.CustomPayloadEvent -import net.minecraftforge.network.PacketDistributor import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.block.entity.matter.MatterPanelBlockEntity import ru.dbotthepony.mc.otm.capability.matter.* @@ -26,14 +24,13 @@ import ru.dbotthepony.mc.otm.network.* import ru.dbotthepony.mc.otm.registry.MMenus import java.util.* import java.util.function.Predicate -import java.util.function.Supplier class CancelTaskPacket(val id: UUID) : MatteryPacket { override fun write(buff: FriendlyByteBuf) { buff.writeUUID(id) } - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { val sender = context.sender!! (sender.containerMenu as? MatterPanelMenu)?.receiveTaskCancel(sender, id) } @@ -51,7 +48,7 @@ class PatternsChangePacket(val isUpdate: Boolean, val patterns: Collection, private val enqueuer: (Runnable) -> CompletableFuture<*>) { + var packetHandled by packetHandled + + fun enqueueWork(callback: Runnable): CompletableFuture<*> { + return enqueuer(callback) + } +} + interface MatteryPacket { fun write(buff: FriendlyByteBuf) - fun play(context: CustomPayloadEvent.Context) + fun play(context: MNetworkContext) } abstract class MatteryNetworkChannel(val version: Int, val name: String) { @@ -76,7 +86,7 @@ abstract class MatteryNetworkChannel(val version: Int, val name: String) { packetClass: Class, writer: BiConsumer, reader: Function, - handler: BiConsumer, + handler: (T, MNetworkContext) -> Unit, direction: NetworkDirection? = null, handleOnMainThread: Boolean = true, ) { @@ -85,11 +95,12 @@ abstract class MatteryNetworkChannel(val version: Int, val name: String) { } val builder = channel.messageBuilder(packetClass, direction) + val bridgeHandler = BiConsumer { a, b -> handler(a, MNetworkContext(b.sender, GetterSetter.of({ b.packetHandled }, { b.packetHandled = it }), b::enqueueWork)) } if (handleOnMainThread) { - builder.consumerMainThread(handler) + builder.consumerMainThread(bridgeHandler) } else { - builder.consumerNetworkThread(handler) + builder.consumerNetworkThread(bridgeHandler) } builder.encoder(writer) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt index e07e301c1..de0d36f7c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt @@ -8,7 +8,6 @@ import net.minecraft.network.protocol.game.ClientboundSetCarriedItemPacket import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack -import net.minecraftforge.event.network.CustomPayloadEvent import net.minecraftforge.network.NetworkDirection.PLAY_TO_CLIENT import net.minecraftforge.network.NetworkDirection.PLAY_TO_SERVER import org.apache.logging.log4j.LogManager @@ -54,7 +53,7 @@ class MatteryPlayerFieldPacket(val bytes: ByteArray, val length: Int, val isPubl buff.writeBytes(bytes, 0, length) } - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { val player: MatteryPlayerCapability if (target != null) { @@ -89,7 +88,7 @@ class AndroidResearchRequestPacket(val type: AndroidResearchType) : MatteryPacke buff.writeUtf(type.id.toString()) } - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { val ply = context.sender ?: return if (ply.isSpectator) return val android = ply.matteryPlayer ?: return @@ -114,7 +113,7 @@ class AndroidResearchSyncPacket(val type: AndroidResearchType, val dataList: Fas buff.writeBytes(dataList.array, 0, dataList.length) } - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { dataBytes ?: throw NullPointerException("No data bytes array is present") val android = minecraft.player?.matteryPlayer ?: return android.getResearch(type).applyNetworkPayload(ByteArrayInputStream(dataBytes)) @@ -137,7 +136,7 @@ class AndroidFeatureSyncPacket(val type: AndroidFeatureType<*>, val dataList: Fa buff.writeBytes(dataList.array, 0, dataList.length) } - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { dataBytes ?: throw NullPointerException("No data bytes array is present") val android = minecraft.player?.matteryPlayer ?: return android.computeIfAbsent(type).applyNetworkPayload(ByteArrayInputStream(dataBytes)) @@ -158,7 +157,7 @@ class AndroidFeatureRemovePacket(val type: AndroidFeatureType<*>) : MatteryPacke buff.writeInt(MRegistry.ANDROID_FEATURES.getID(type)) } - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { val android = minecraft.player?.matteryPlayer ?: return android.removeFeature(type) } @@ -181,7 +180,7 @@ class PlayerIterationPacket(val iteration: Int, val deathLog: List, val carried: ItemStack, buff.writeInt(containerState) } - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { val mattery = minecraft.player?.matteryPlayer ?: return if (mattery.hasExopack) { @@ -309,7 +308,7 @@ class ExopackMenuInitPacket(val slots: List, val carried: ItemStack, object ExopackMenuOpen : MatteryPacket { override fun write(buff: FriendlyByteBuf) {} - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { val player = context.sender ?: return val mattery = player.matteryPlayer ?: return @@ -325,7 +324,7 @@ class SwitchAndroidFeaturePacket(val type: AndroidFeatureType<*>, val newState: buff.writeBoolean(newState) } - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { val matteryPlayer = context.sender?.matteryPlayer ?: return if (!matteryPlayer.isAndroid) { @@ -358,7 +357,7 @@ class ActivateAndroidFeaturePacket(val type: AndroidFeatureType<*>) : MatteryPac buff.writeInt(MRegistry.ANDROID_FEATURES.getID(type)) } - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { val matteryPlayer = context.sender?.matteryPlayer ?: return if (!matteryPlayer.isAndroid || matteryPlayer.ply.isSpectator) { @@ -388,7 +387,7 @@ class PickItemFromInventoryPacket( buff.writeVarInt(sourceExosuitSlot) } - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { val player = context.sender ?: return val mattery = player.matteryPlayer ?: return @@ -422,7 +421,7 @@ class GlitchPacket(val millis: Long) : MatteryPacket { buff.writeVarLong(millis) } - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { context.packetHandled = true GlitchRenderer.glitchFor(millis) } @@ -441,7 +440,7 @@ class ShockwaveEffectPacket(val pos: Vector) : MatteryPacket { buff.writeDouble(pos.z) } - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { context.packetHandled = true ShockwaveRenderer.handle(this) } @@ -456,7 +455,7 @@ class ShockwaveEffectPacket(val pos: Vector) : MatteryPacket { object DisplayExopackPacket : MatteryPacket { override fun write(buff: FriendlyByteBuf) {} - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { context.packetHandled = true context.sender?.matteryPlayer?.isExopackVisible = true } @@ -465,7 +464,7 @@ object DisplayExopackPacket : MatteryPacket { object HideExopackPacket : MatteryPacket { override fun write(buff: FriendlyByteBuf) {} - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { context.packetHandled = true context.sender?.matteryPlayer?.isExopackVisible = false } @@ -474,7 +473,7 @@ object HideExopackPacket : MatteryPacket { object EnableExopackGlowPacket : MatteryPacket { override fun write(buff: FriendlyByteBuf) {} - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { context.packetHandled = true context.sender?.matteryPlayer?.exopackGlows = true } @@ -483,7 +482,7 @@ object EnableExopackGlowPacket : MatteryPacket { object DisableExopackGlowPacket : MatteryPacket { override fun write(buff: FriendlyByteBuf) {} - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { context.packetHandled = true context.sender?.matteryPlayer?.exopackGlows = false } @@ -492,7 +491,7 @@ object DisableExopackGlowPacket : MatteryPacket { object ResetExopackColorPacket : MatteryPacket { override fun write(buff: FriendlyByteBuf) {} - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { context.packetHandled = true context.sender?.matteryPlayer?.exopackColor = null } @@ -505,7 +504,7 @@ data class SetExopackColorPacket(val color: RGBAColor) : MatteryPacket { buff.writeFloat(color.blue) } - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { context.packetHandled = true context.sender?.matteryPlayer?.exopackColor = color } @@ -522,7 +521,7 @@ data class ExopackSmokePacket(val player: UUID) : MatteryPacket { buff.writeUUID(player) } - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { context.packetHandled = true // minecraft.player?.level()?.getPlayerByUUID(player)?.matteryPlayer?.spawnExopackSmoke = true diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt index d85d4defe..dacc8ad7f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MenuNetworkChannel.kt @@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.network import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream import net.minecraft.network.FriendlyByteBuf import net.minecraft.world.item.ItemStack -import net.minecraftforge.event.network.CustomPayloadEvent import net.minecraftforge.network.NetworkDirection import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft @@ -29,7 +28,7 @@ class MenuFieldPacket(val containerId: Int, val bytes: ByteArray, val length: In buff.writeBytes(bytes, 0, length) } - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { if (containerId == ExopackInventoryMenu.CONTAINER_ID) { minecraft.player?.matteryPlayer?.exoPackMenu?.mSynchronizer?.read(ByteArrayInputStream(bytes, 0, length)) } else { @@ -54,7 +53,7 @@ class SetCarriedPacket(val item: ItemStack) : MatteryPacket { buff.writeItem(item) } - override fun play(context: CustomPayloadEvent.Context) { + override fun play(context: MNetworkContext) { minecraft.player?.containerMenu?.carried = item } From 8072a7b13595885951b7a244bdb76874041283fc Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 31 Dec 2023 17:08:45 +0700 Subject: [PATCH 1146/1199] Don't check for "chunk send" status because it is already sent during event fire --- .../mc/otm/block/entity/MatteryBlockEntity.kt | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) 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 bfbb8955c..06a2416f5 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 @@ -631,15 +631,11 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc private fun recheckPlayer(player: ServerPlayer) { sometimeServer { if (player in players && !player.hasDisconnected()) { - if (player.connection.chunkSender.isPending(chunkPos)) { - recheckPlayer(player) - } else { - veto.remove(player) + veto.remove(player) - blockEntities.forEach { - it.playerListUpdated = true - it.synchronizeToPlayers(false) - } + blockEntities.forEach { + it.playerListUpdated = true + it.synchronizeToPlayers(false) } } else if (player in players && player.hasDisconnected()) { unsubscribe(player) From f16483d7c084a044ca2fe720396f2ad9f59c55f4 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 31 Dec 2023 17:46:56 +0700 Subject: [PATCH 1147/1199] Some recipe backporting --- .../otm/block/entity/matter/MatterEntanglerBlockEntity.kt | 1 + .../mc/otm/block/entity/storage/ItemMonitorBlockEntity.kt | 1 + .../mc/otm/block/entity/tech/PlatePressBlockEntity.kt | 1 + .../mc/otm/block/entity/tech/PoweredFurnaceBlockEntity.kt | 1 + src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 4 ++++ .../ru/dbotthepony/mc/otm/menu/decorative/PainterMenu.kt | 8 ++++---- 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterEntanglerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterEntanglerBlockEntity.kt index 40c2212b5..18b389486 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterEntanglerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterEntanglerBlockEntity.kt @@ -29,6 +29,7 @@ import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.container.ShadowCraftingContainer import ru.dbotthepony.mc.otm.container.UpgradeContainer import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.value import ru.dbotthepony.mc.otm.data.DecimalCodec import ru.dbotthepony.mc.otm.data.minRange import ru.dbotthepony.mc.otm.graph.matter.MatterNode 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 970a12ba2..96f016300 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 @@ -49,6 +49,7 @@ import ru.dbotthepony.mc.otm.core.collect.map import ru.dbotthepony.mc.otm.core.collect.toList import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.core.util.ItemStorageStackSorter +import ru.dbotthepony.mc.otm.core.value interface IItemMonitorPlayerSettings { var ingredientPriority: ItemMonitorPlayerSettings.IngredientPriority 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 5cfc76190..2789cdf25 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.value import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu import ru.dbotthepony.mc.otm.registry.MBlockEntities 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 b1c6c4abe..f9975f87d 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 @@ -32,6 +32,7 @@ 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.immutableList +import ru.dbotthepony.mc.otm.core.value import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu import ru.dbotthepony.mc.otm.recipe.MatteryCookingRecipe import ru.dbotthepony.mc.otm.registry.MBlockEntities 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 bc23bfbce..5ac378185 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -18,11 +18,13 @@ import net.minecraft.network.FriendlyByteBuf import net.minecraft.network.chat.ComponentContents import net.minecraft.network.chat.contents.TranslatableContents import net.minecraft.resources.ResourceLocation +import net.minecraft.world.Container import net.minecraft.world.entity.Entity import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.item.crafting.Ingredient +import net.minecraft.world.item.crafting.Recipe import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block @@ -467,3 +469,5 @@ fun lazy2(a: () -> A, b: A.() -> B): Supplier { val first = lazy(a) return Supplier { b.invoke(first.value) } } + +inline val , T : Container> R.value get() = this 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 6e4f94e7c..dcc5bb2f2 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 @@ -4,7 +4,6 @@ import net.minecraft.world.SimpleContainer import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.item.* -import net.minecraft.world.item.crafting.RecipeHolder import net.minecraft.world.level.material.Fluids import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.fluids.FluidStack @@ -19,6 +18,7 @@ import ru.dbotthepony.mc.otm.core.collect.filter import ru.dbotthepony.mc.otm.core.collect.maybe import ru.dbotthepony.mc.otm.core.isNotEmpty import ru.dbotthepony.mc.otm.core.util.ResourceLocationValueCodec +import ru.dbotthepony.mc.otm.core.value import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback @@ -42,7 +42,7 @@ class PainterMenu( val inputContainer = MatteryContainer(::rescan, 1) val outputContainer = MatteryContainer(1) - private var lastRecipe: RecipeHolder? = null + private var lastRecipe: AbstractPainterRecipe? = null var selectedRecipe by mSynchronizer.Field(null, ResourceLocationValueCodec.nullable).also { it.addListener { rescan() } } val isBulk = BooleanInputWithFeedback(this, tile?.let { it::isBulk }) @@ -124,7 +124,7 @@ class PainterMenu( } val listeners = ISubscriptable.Impl() - val possibleRecipes = ArrayList>() + val possibleRecipes = ArrayList() private fun rescan() { possibleRecipes.clear() @@ -136,7 +136,7 @@ class PainterMenu( if (inputContainer.isEmpty || selectedRecipe == null) { outputContainer.clearContent() } else { - val recipe = inventory.player.level().recipeManager.byKey(selectedRecipe!!).get() as RecipeHolder? + val recipe = inventory.player.level().recipeManager.byKey(selectedRecipe!!).get() as AbstractPainterRecipe? if (recipe == null || !recipe.value.canCraft(dyeStoredDirect) || !recipe.value.matches(inputContainer, inventory.player.level())) { outputContainer.clearContent() From 3c5ea937a5d768d5e6cb0f996027fa12dd9f32fd Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 31 Dec 2023 18:23:07 +0700 Subject: [PATCH 1148/1199] More backporting --- .../otm/capability/MatteryPlayerCapability.kt | 2 +- .../mc/otm/client/screen/MatteryScreen.kt | 4 +- .../client/screen/decorative/PainterScreen.kt | 1 + .../otm/client/screen/panels/EditablePanel.kt | 2 +- .../mc/otm/data/Codec2RecipeSerializer.kt | 102 +++++++----------- .../mc/otm/data/IngredientCodec.kt | 23 ++++ .../mc/otm/network/MatteryNetworkChannel.kt | 33 +++--- .../recipe/ExplosiveHammerPrimingRecipe.kt | 15 ++- 8 files changed, 87 insertions(+), 95 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientCodec.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index a279abffd..c477a6a75 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -531,7 +531,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial super.onJobTick(status) if (isExopackVisible && ply.level().random.nextFloat() <= 0.05f) { - MatteryPlayerNetworkChannel.send(PacketDistributor.TRACKING_ENTITY_AND_SELF.with(ply as ServerPlayer), ExopackSmokePacket(ply.uuid)) + MatteryPlayerNetworkChannel.send(PacketDistributor.TRACKING_ENTITY_AND_SELF.with { ply as ServerPlayer }, ExopackSmokePacket(ply.uuid)) } } 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 67f24f1b2..0385b5fc0 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 @@ -564,7 +564,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit return super.mouseReleased(p_97812_, p_97813_, p_97814_) } - override fun mouseScrolled(mouseX: Double, mouseY: Double, scrollX: Double, scrollY: Double): Boolean { + override fun mouseScrolled(mouseX: Double, mouseY: Double, scrollY: Double): Boolean { for (panel in panels) { if (panel.mouseScrolledChecked(mouseX, mouseY, scrollY)) { return true @@ -647,7 +647,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit val mouseYf = mouseY.toFloat() // dark background - this.renderBackground(graphics, mouseX, mouseY, partialTick) + this.renderBackground(graphics) super.hoveredSlot = null var hovered = false 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 fd52916fd..59d5c98d5 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 @@ -32,6 +32,7 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.map import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.util.CreativeMenuItemComparator +import ru.dbotthepony.mc.otm.core.value import ru.dbotthepony.mc.otm.menu.decorative.PainterMenu class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, 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 981705c2f..ed660ee97 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 @@ -108,7 +108,7 @@ open class EditablePanel @JvmOverloads constructor( return this@EditablePanel.mouseDragged(p_94740_, p_94741_, p_94742_, p_94743_, p_94744_) } - override fun mouseScrolled(mouseX: Double, mouseY: Double, scrollX: Double, scrollY: Double): Boolean { + override fun mouseScrolled(mouseX: Double, mouseY: Double, scrollY: Double): Boolean { return this@EditablePanel.mouseScrolled(mouseX, mouseY, scrollY) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt index b32702611..3ddf52bd2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt @@ -8,9 +8,6 @@ import com.mojang.serialization.Codec import com.mojang.serialization.DataResult import com.mojang.serialization.DynamicOps import com.mojang.serialization.JsonOps -import io.netty.buffer.ByteBuf -import io.netty.buffer.Unpooled -import net.minecraft.advancements.AdvancementHolder import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation @@ -24,15 +21,7 @@ import ru.dbotthepony.mc.otm.core.util.readBinaryJsonWithCodecIndirect import ru.dbotthepony.mc.otm.core.util.writeBinaryJsonWithCodec import kotlin.collections.ArrayDeque import kotlin.concurrent.getOrSet -import kotlin.reflect.KProperty -/** - * 1.20.2: Mojang FINALLY moved json IO of recipes to codecs - * - * ...but they forgot to do the same for Networking them, Ingredient does not have codec for network. - * - * Mojang.... Mojang never changes. - */ class Codec2RecipeSerializer>( val empty: S?, codec: (Codec2RecipeSerializer.Context) -> Codec, @@ -40,45 +29,15 @@ class Codec2RecipeSerializer>( constructor(supplier: (Codec2RecipeSerializer.Context) -> Codec) : this(null, supplier) private class CurrentContext { + val idStack = ArrayDeque() var isNetwork = 0 } inner class Context { + val id: ResourceLocation + get() = checkNotNull(context.idStack.lastOrNull()) { "Not currently deserializing recipe" } + val ingredients: Codec get() = ActualIngredientCodec - - fun

> wrap(serializer: RecipeSerializer

): Codec

{ - return object : Codec

{ - override fun encode(input: P, ops: DynamicOps, prefix: T): DataResult { - if (context.isNetwork > 0) { - val parent = Unpooled.buffer() - val buff = FriendlyByteBuf(parent) - serializer.toNetwork(buff, input) - return DataResult.success(ops.createByteList(parent.nioBuffer())) - } else { - return serializer.codec().encode(input, ops, prefix) - } - } - - override fun decode(ops: DynamicOps, input: T): DataResult> { - if (context.isNetwork > 0) { - return ops.getByteBuffer(input).flatMap { - val parent = Unpooled.buffer() - val buff = FriendlyByteBuf(parent) - parent.writeBytes(it) - parent.setIndex(0, 0) - val read = serializer.fromNetwork(buff) - - if (read == null) - DataResult.error { "Unable to read parent recipe from network" } - else - DataResult.success(Pair(read, ops.empty())) - } - } else { - return serializer.codec().decode(ops, input) - } - } - } - } } private val codec = codec.invoke(Context()) @@ -97,30 +56,45 @@ class Codec2RecipeSerializer>( } } - override fun codec(): Codec { - return this + override fun fromJson(id: ResourceLocation, data: JsonObject): S { + try { + context.idStack.addLast(id) + + return decode(JsonOps.INSTANCE, data).get().map( + { it.first }, + { empty ?: throw JsonSyntaxException("Failed to deserialize recipe from JSON: ${it.message()}") } + ) + } finally { + context.idStack.removeLast() + } } - override fun fromNetwork(data: FriendlyByteBuf): S? { + override fun fromNetwork(id: ResourceLocation, data: FriendlyByteBuf): S? { try { + context.idStack.addLast(id) context.isNetwork++ + return data.readBinaryJsonWithCodecIndirect(this) - .resultOrPartial { LOGGER.error("Failed to read recipe from network: $it") }.orElse(null) + .resultOrPartial { LOGGER.error("Failed to read recipe $id from network: $it") }.orElse(null) } finally { context.isNetwork-- + context.idStack.removeLast() } } override fun toNetwork(data: FriendlyByteBuf, recipe: S) { try { + context.idStack.addLast(recipe.id) context.isNetwork++ + data.writeBinaryJsonWithCodec(this, recipe) } finally { context.isNetwork-- + context.idStack.removeLast() } } - fun toFinished(recipe: S, id: ResourceLocation): FinishedRecipe { + fun toFinished(recipe: S): FinishedRecipe { return object : FinishedRecipe { override fun serializeRecipeData(p_125967_: JsonObject) { encode(recipe, JsonOps.INSTANCE, p_125967_).get().map( @@ -137,15 +111,19 @@ class Codec2RecipeSerializer>( ) } - override fun id(): ResourceLocation { - return id + override fun getId(): ResourceLocation { + return recipe.id } - override fun type(): RecipeSerializer<*> { + override fun getType(): RecipeSerializer<*> { return this@Codec2RecipeSerializer } - override fun advancement(): AdvancementHolder? { + override fun serializeAdvancement(): JsonObject? { + return null + } + + override fun getAdvancementId(): ResourceLocation? { return null } } @@ -156,7 +134,7 @@ class Codec2RecipeSerializer>( return if (context.isNetwork > 0) { networkIngredientCodec.encode(input, ops, prefix) } else { - Ingredient.CODEC.encode(input, ops, prefix) + IngredientCodec.encode(input, ops, prefix) } } @@ -164,7 +142,7 @@ class Codec2RecipeSerializer>( return if (context.isNetwork > 0) { networkIngredientCodec.decode(ops, input) } else { - Ingredient.CODEC.decode(ops, input) + IngredientCodec.decode(ops, input) } } } @@ -178,14 +156,8 @@ class Codec2RecipeSerializer>( * since RecipeSerializers are expected to be stateless. [Codec2RecipeSerializer], however, is stateful (threading PoV). * To make it stateless, [ThreadLocal] is used. */ - private val context by object : ThreadLocal() { - override fun initialValue(): CurrentContext { - return CurrentContext() - } - } + private val contextHolder = ThreadLocal() + private val context: CurrentContext + get() = contextHolder.getOrSet { CurrentContext() } } } - -private operator fun ThreadLocal.getValue(companion: Codec2RecipeSerializer.Companion, property: KProperty<*>): T { - return get() -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientCodec.kt new file mode 100644 index 000000000..27c18ade8 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientCodec.kt @@ -0,0 +1,23 @@ +package ru.dbotthepony.mc.otm.data + +import com.google.gson.JsonSyntaxException +import com.mojang.datafixers.util.Pair +import com.mojang.serialization.Codec +import com.mojang.serialization.DataResult +import com.mojang.serialization.DynamicOps +import com.mojang.serialization.JsonOps +import net.minecraft.world.item.crafting.Ingredient + +object IngredientCodec : Codec { + override fun encode(input: Ingredient, ops: DynamicOps, prefix: T): DataResult { + return DataResult.success(JsonOps.INSTANCE.convertTo(ops, input.toJson())) + } + + override fun decode(ops: DynamicOps, input: T): DataResult> { + try { + return DataResult.success(Pair(Ingredient.fromJson(ops.convertTo(JsonOps.INSTANCE, input)), ops.empty())) + } catch (err: JsonSyntaxException) { + return DataResult.error { "Error decoding Ingredient: ${err.message}" } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt index 7b69da821..72d34340a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt @@ -5,12 +5,11 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.Entity import net.minecraft.world.entity.player.Player -import net.minecraftforge.event.network.CustomPayloadEvent -import net.minecraftforge.network.Channel -import net.minecraftforge.network.ChannelBuilder import net.minecraftforge.network.NetworkDirection +import net.minecraftforge.network.NetworkEvent +import net.minecraftforge.network.NetworkRegistry import net.minecraftforge.network.PacketDistributor -import net.minecraftforge.network.SimpleChannel +import net.minecraftforge.network.simple.SimpleChannel import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.NULLABLE_MINECRAFT_SERVER import ru.dbotthepony.mc.otm.OverdriveThatMatters @@ -20,6 +19,7 @@ import java.util.concurrent.ConcurrentLinkedQueue import java.util.concurrent.locks.LockSupport import java.util.function.BiConsumer import java.util.function.Function +import java.util.function.Supplier import kotlin.reflect.KClass class MNetworkContext(val sender: ServerPlayer?, packetHandled: GetterSetter, private val enqueuer: (Runnable) -> CompletableFuture<*>) { @@ -36,23 +36,20 @@ interface MatteryPacket { } abstract class MatteryNetworkChannel(val version: Int, val name: String) { - val channel: SimpleChannel = ChannelBuilder - .named(ResourceLocation(OverdriveThatMatters.MOD_ID, name)) - .acceptedVersions(Channel.VersionTest.exact(version)) - .networkProtocolVersion(version) - .simpleChannel() + val channel: SimpleChannel = NetworkRegistry + .newSimpleChannel(ResourceLocation(OverdriveThatMatters.MOD_ID, name), version::toString, String::equals, String::equals) - fun sendToServer(packet: Any) = channel.send(packet, PacketDistributor.SERVER.noArg()) + fun sendToServer(packet: Any) = channel.send(PacketDistributor.SERVER.noArg(), packet) fun send(ply: Player, packet: Any) { if (ply is ServerPlayer) { - queue.add(Task(channel, PacketDistributor.PLAYER.with(ply), packet)) + queue.add(Task(channel, PacketDistributor.PLAYER.with { ply }, packet)) } } fun sendNow(ply: Player, packet: Any) { if (ply is ServerPlayer) { - channel.send(packet, PacketDistributor.PLAYER.with(ply)) + channel.send(PacketDistributor.PLAYER.with { ply }, packet) } } @@ -61,7 +58,7 @@ abstract class MatteryNetworkChannel(val version: Int, val name: String) { return } - queue.add(Task(channel, PacketDistributor.TRACKING_ENTITY.with(entity), packet)) + queue.add(Task(channel, PacketDistributor.TRACKING_ENTITY.with { entity }, packet)) } fun sendTrackingAndSelf(entity: Entity, packet: Any) { @@ -69,7 +66,7 @@ abstract class MatteryNetworkChannel(val version: Int, val name: String) { return } - queue.add(Task(channel, PacketDistributor.TRACKING_ENTITY_AND_SELF.with(entity), packet)) + queue.add(Task(channel, PacketDistributor.TRACKING_ENTITY_AND_SELF.with { entity }, packet)) } fun send(distributor: PacketDistributor.PacketTarget, packet: Any) { @@ -77,7 +74,7 @@ abstract class MatteryNetworkChannel(val version: Int, val name: String) { } fun sendNow(distributor: PacketDistributor.PacketTarget, packet: Any) { - channel.send(packet, distributor) + channel.send(distributor, packet) } private var nextNetworkPacketID = 0 @@ -94,8 +91,8 @@ abstract class MatteryNetworkChannel(val version: Int, val name: String) { throw IndexOutOfBoundsException("Network message ID overflow!") } - val builder = channel.messageBuilder(packetClass, direction) - val bridgeHandler = BiConsumer { a, b -> handler(a, MNetworkContext(b.sender, GetterSetter.of({ b.packetHandled }, { b.packetHandled = it }), b::enqueueWork)) } + val builder = channel.messageBuilder(packetClass, nextNetworkPacketID++) + val bridgeHandler = BiConsumer> { a, b -> handler(a, MNetworkContext(b.get().sender, GetterSetter.of({ b.get().packetHandled }, { b.get().packetHandled = it }), b.get()::enqueueWork)) } if (handleOnMainThread) { builder.consumerMainThread(bridgeHandler) @@ -154,7 +151,7 @@ abstract class MatteryNetworkChannel(val version: Int, val name: String) { LockSupport.park() } else { try { - task.channel.send(task.packet, task.target) + task.channel.send(task.target, task.packet) } catch(err: Throwable) { logger.error("Error executing network dispatcher task", err) } 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 884138e00..5349dc5f7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/ExplosiveHammerPrimingRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/ExplosiveHammerPrimingRecipe.kt @@ -1,12 +1,8 @@ package ru.dbotthepony.mc.otm.recipe -import com.google.gson.JsonObject -import com.google.gson.JsonSyntaxException import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.core.NonNullList import net.minecraft.core.RegistryAccess -import net.minecraft.data.recipes.FinishedRecipe -import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation import net.minecraft.world.inventory.CraftingContainer import net.minecraft.world.item.ItemStack @@ -19,12 +15,15 @@ import net.minecraftforge.common.Tags import ru.dbotthepony.mc.otm.container.util.stream import ru.dbotthepony.mc.otm.core.isActuallyEmpty import ru.dbotthepony.mc.otm.core.isNotEmpty -import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.data.Codec2RecipeSerializer import ru.dbotthepony.mc.otm.item.tool.ExplosiveHammerItem import ru.dbotthepony.mc.otm.registry.MItems -class ExplosiveHammerPrimingRecipe(val payload: Ingredient) : CraftingRecipe { +class ExplosiveHammerPrimingRecipe(val payload: Ingredient, val id: ResourceLocation) : CraftingRecipe { + override fun getId(): ResourceLocation { + return id + } + override fun isIncomplete(): Boolean { return payload.isActuallyEmpty } @@ -70,14 +69,14 @@ class ExplosiveHammerPrimingRecipe(val payload: Ingredient) : CraftingRecipe { return NonNullList.of(Ingredient.of(), Ingredient.of(MItems.EXPLOSIVE_HAMMER), Ingredient.of(Tags.Items.GUNPOWDER), payload) } - fun toFinished(id: ResourceLocation) = CODEC.toFinished(this, id) + fun toFinished() = CODEC.toFinished(this) companion object { val CODEC = Codec2RecipeSerializer { p -> RecordCodecBuilder.create { it.group( p.ingredients.fieldOf("payload").forGetter(ExplosiveHammerPrimingRecipe::payload) - ).apply(it, ::ExplosiveHammerPrimingRecipe) + ).apply(it) { a -> ExplosiveHammerPrimingRecipe(a, p.id) } } } } From 1681a7bf4aac8dcc392886ebc499ca3472ee335b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 31 Dec 2023 20:23:45 +0700 Subject: [PATCH 1149/1199] Streamline trigger instances into single, more portable class --- .../datagen/advancements/AdvancementData.kt | 3 - .../advancements/AndroidAdvancementsData.kt | 4 +- .../mc/otm/core/collect/StreamyIterators.kt | 7 + .../mc/otm/data/Codec2TriggerSerializer.kt | 100 ------------- .../mc/otm/triggers/AndroidResearchTrigger.kt | 51 +++---- .../otm/triggers/AndroidTravelUnderwater.kt | 43 ++---- .../mc/otm/triggers/ExopackTriggers.kt | 28 +--- .../mc/otm/triggers/HurtTrigger.kt | 46 ++---- .../mc/otm/triggers/ItemTrigger.kt | 36 ++--- .../mc/otm/triggers/KillAsAndroidTrigger.kt | 139 ++++++------------ .../mc/otm/triggers/MCriterionTrigger.kt | 105 +++++++++++++ .../mc/otm/triggers/NailedEntityTrigger.kt | 8 - .../mc/otm/triggers/NanobotsArmorTrigger.kt | 40 ++--- .../otm/triggers/ShockwaveDamageMobTrigger.kt | 8 - .../mc/otm/triggers/SimpleTriggers.kt | 3 + .../mc/otm/triggers/SingletonTrigger.kt | 35 +---- 16 files changed, 229 insertions(+), 427 deletions(-) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2TriggerSerializer.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NailedEntityTrigger.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ShockwaveDamageMobTrigger.kt diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt index a220c1843..0cd43924e 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt @@ -1,15 +1,12 @@ package ru.dbotthepony.mc.otm.datagen.advancements -import net.minecraft.advancements.Advancement import net.minecraft.advancements.AdvancementHolder -import net.minecraft.advancements.AdvancementRequirements import net.minecraft.advancements.AdvancementRewards import net.minecraft.advancements.FrameType import net.minecraft.advancements.AdvancementRequirements.Strategy import net.minecraft.advancements.critereon.InventoryChangeTrigger import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack -import net.minecraftforge.common.data.ExistingFileHelper import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.datagen.lang.MatteryLanguageProvider import ru.dbotthepony.mc.otm.datagen.modLocation diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt index 83b58e530..2a9ed3bdf 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.datagen.advancements -import net.minecraft.advancements.Advancement import net.minecraft.advancements.AdvancementHolder import net.minecraft.advancements.AdvancementRequirements.Strategy import net.minecraft.advancements.AdvancementRewards @@ -11,7 +10,6 @@ import net.minecraft.advancements.critereon.MinMaxBounds.Doubles import net.minecraft.world.entity.EntityType import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items -import net.minecraftforge.common.data.ExistingFileHelper import ru.dbotthepony.mc.otm.datagen.DataGen import ru.dbotthepony.mc.otm.datagen.lang.MatteryLanguageProvider import ru.dbotthepony.mc.otm.datagen.modLocation @@ -158,7 +156,7 @@ fun addAndroidAdvancements(serializer: Consumer, lang: Matter russian("Исследуйте что либо за андроида") }, ) - .addCriterion("research_anything", AndroidResearchTrigger.Instance(null).criterion()) + .addCriterion("research_anything", AndroidResearchTrigger.Instance(Optional.empty(), Optional.empty()).criterion()) .save(serializer, modLocation("android/research_anything")) AdvancementBuilder() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt index 5d9d0e85c..cc7aa3289 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/collect/StreamyIterators.kt @@ -297,6 +297,13 @@ fun Iterator.toList(expectedSize: Int = 16): MutableList { return result } +fun Iterator.toImmutableList(expectedSize: Int = 16): List { + if (!hasNext()) + return emptyList() + + return toList(expectedSize) +} + fun Iterator.find(): Optional { if (hasNext()) { return Optional.of(next()) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2TriggerSerializer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2TriggerSerializer.kt deleted file mode 100644 index 9f4319439..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2TriggerSerializer.kt +++ /dev/null @@ -1,100 +0,0 @@ -package ru.dbotthepony.mc.otm.data - -import com.google.gson.JsonObject -import com.mojang.datafixers.util.Pair -import com.mojang.serialization.Codec -import com.mojang.serialization.DataResult -import com.mojang.serialization.DynamicOps -import com.mojang.serialization.JsonOps -import com.mojang.serialization.MapCodec -import com.mojang.serialization.MapLike -import com.mojang.serialization.RecordBuilder -import net.minecraft.advancements.critereon.ContextAwarePredicate -import net.minecraft.advancements.critereon.DeserializationContext -import net.minecraft.advancements.critereon.EntityPredicate -import ru.dbotthepony.mc.otm.core.fromJsonStrict -import ru.dbotthepony.mc.otm.core.set -import ru.dbotthepony.mc.otm.core.toJsonStrict -import java.util.Optional -import java.util.stream.Stream - -class Codec2TriggerSerializer(supplier: (Codec2TriggerSerializer.Context) -> Codec) : Codec { - private val codec = supplier.invoke(Context()) - - override fun encode(input: S, ops: DynamicOps, prefix: T): DataResult { - return codec.encode(input, ops, prefix) - } - - override fun decode(ops: DynamicOps, input: T): DataResult> { - return codec.decode(ops, input) - } - - fun fromJson(element: JsonObject, player: Optional, context: DeserializationContext): S { - try { - Companion.context.get().addLast(ThreadContext(player, context)) - return codec.fromJsonStrict(element) - } finally { - Companion.context.get().removeLast() - } - } - - fun toJson(value: S): JsonObject { - return codec.toJsonStrict(value) as JsonObject - } - - inner class Context { - val playerPredicate: MapCodec> - get() = CAPPredicate - - val awareContextCodec: Codec - get() = ActualCAPPredicate - } - - private data class ThreadContext(val player: Optional, val context: DeserializationContext) - - private object ActualCAPPredicate : Codec { - override fun encode(input: ContextAwarePredicate, ops: DynamicOps, prefix: T): DataResult { - return try { - DataResult.success(JsonOps.INSTANCE.convertTo(ops, input.toJson())) - } catch (err: Exception) { - DataResult.error { "Failed to serialize ContextAwarePredicate: " + err.message } - } - } - - override fun decode(ops: DynamicOps, input: T): DataResult> { - val context = context.get().lastOrNull() ?: return DataResult.error { "Not current deserializing trigger instance" } - - return try { - DataResult.success(Pair(EntityPredicate.fromJson(JsonObject().also { it["a"] = ops.convertTo(JsonOps.INSTANCE, input) }, "a", context.context).get(), ops.empty())) - } catch (err: Exception) { - DataResult.error { "Failed to deserialize ContextAwarePredicate: " + err.message } - } - } - } - - private object CAPPredicate : MapCodec>() { - override fun keys(ops: DynamicOps): Stream { - return Stream.of(ops.createString("player")) - } - - override fun decode(ops: DynamicOps, input: MapLike): DataResult> { - return DataResult.success(context.get().lastOrNull()?.player ?: return DataResult.error { "Not currently deserializing trigger instance" }) - } - - override fun encode(input: Optional, ops: DynamicOps, prefix: RecordBuilder): RecordBuilder { - if (input.isPresent) { - return prefix.add("player", JsonOps.INSTANCE.convertTo(ops, input.get().toJson())) - } else { - return prefix - } - } - } - - companion object { - private val context = object : ThreadLocal>() { - override fun initialValue(): ArrayDeque { - return ArrayDeque() - } - } - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidResearchTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidResearchTrigger.kt index 33b43ba4c..800d22894 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidResearchTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidResearchTrigger.kt @@ -1,50 +1,33 @@ package ru.dbotthepony.mc.otm.triggers -import com.google.gson.JsonObject -import com.google.gson.JsonPrimitive -import net.minecraft.advancements.Criterion -import net.minecraft.advancements.critereon.* +import com.mojang.serialization.Codec +import com.mojang.serialization.codecs.RecordCodecBuilder +import net.minecraft.advancements.critereon.ContextAwarePredicate import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.android.AndroidResearchType -import ru.dbotthepony.mc.otm.core.set -import java.util.Optional +import java.util.* import java.util.function.Predicate -object AndroidResearchTrigger : SimpleCriterionTrigger() { - val id = ResourceLocation(OverdriveThatMatters.MOD_ID, "android_research") - - override fun createInstance( - p_66248_: JsonObject, - p_286603_: Optional, - p_66250_: DeserializationContext - ): Instance { - return Instance( - p_66248_["research"]?.asString?.let(::ResourceLocation) - ) - } - +object AndroidResearchTrigger : MCriterionTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "android_research")) { fun trigger(player: ServerPlayer, research: AndroidResearchType) { - trigger(player) { - it.test(research) - } + trigger(player) { it.test(research) } } - class Instance(val research: ResourceLocation?) : AbstractCriterionTriggerInstance(Optional.empty()), Predicate { - constructor(research: AndroidResearchType) : this(research.id) + override val codec: Codec = RecordCodecBuilder.create { + it.group( + ResourceLocation.CODEC.optionalFieldOf("research").forGetter(Instance::research), + playerPredicateCodec.forGetter(Instance::playerPredicate) + ).apply(it, ::Instance) + } + + class Instance(val research: Optional, player: Optional = Optional.empty()) : AbstractInstance(player), Predicate { + constructor(research: ResourceLocation) : this(Optional.of(research)) + constructor(research: AndroidResearchType) : this(Optional.of(research.id)) override fun test(t: AndroidResearchType): Boolean { - return research == null || t.id == research + return research.map { it == t.id }.orElse(true) } - - override fun serializeToJson(): JsonObject { - return super.serializeToJson().also { - if (research != null) - it["research"] = JsonPrimitive(research.toString()) - } - } - - fun criterion() = Criterion(AndroidResearchTrigger, this) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidTravelUnderwater.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidTravelUnderwater.kt index e6dd07ac4..94d02e89d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidTravelUnderwater.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidTravelUnderwater.kt @@ -1,48 +1,25 @@ package ru.dbotthepony.mc.otm.triggers -import com.google.gson.JsonObject -import com.google.gson.JsonParseException -import com.google.gson.JsonPrimitive import com.mojang.serialization.Codec import com.mojang.serialization.codecs.RecordCodecBuilder -import net.minecraft.advancements.Criterion -import net.minecraft.advancements.critereon.* +import net.minecraft.advancements.critereon.ContextAwarePredicate import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.core.set -import ru.dbotthepony.mc.otm.core.toJsonStrict -import ru.dbotthepony.mc.otm.data.Codec2TriggerSerializer import ru.dbotthepony.mc.otm.data.minRange -import java.util.Optional - -object AndroidTravelUnderwater : SimpleCriterionTrigger() { - val id = ResourceLocation(OverdriveThatMatters.MOD_ID, "android_walk_underwater") - - override fun createInstance(pJson: JsonObject, pPlayer: Optional, pContext: DeserializationContext): Instance { - return codec.fromJson(pJson, pPlayer, pContext) - } +import java.util.* +object AndroidTravelUnderwater : MCriterionTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "android_walk_underwater")) { fun trigger(player: ServerPlayer, travelled: Double) { - trigger(player) { - it.distanceToTravel <= travelled - } + trigger(player) { it.distanceToTravel <= travelled } } - val codec = Codec2TriggerSerializer { p -> - RecordCodecBuilder.create { - it.group( - Codec.DOUBLE.minRange(0.0).fieldOf("distanceToTravel").forGetter(Instance::distanceToTravel), - p.playerPredicate.forGetter { it.playerPredicate() } - ).apply(it, ::Instance) - } + override val codec: Codec = RecordCodecBuilder.create { + it.group( + Codec.DOUBLE.minRange(0.0).fieldOf("distanceToTravel").forGetter(Instance::distanceToTravel), + playerPredicateCodec.forGetter(Instance::playerPredicate) + ).apply(it, ::Instance) } - class Instance(val distanceToTravel: Double, playerPredicate: Optional = Optional.empty()) : AbstractCriterionTriggerInstance(playerPredicate) { - override fun serializeToJson(): JsonObject { - return codec.toJson(this) - } - - fun criterion() = Criterion(AndroidTravelUnderwater, this) - } + class Instance(val distanceToTravel: Double, playerPredicate: Optional = Optional.empty()) : AbstractInstance(playerPredicate) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ExopackTriggers.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ExopackTriggers.kt index cd174710e..1f8523669 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ExopackTriggers.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ExopackTriggers.kt @@ -1,19 +1,12 @@ package ru.dbotthepony.mc.otm.triggers -import com.google.gson.JsonObject import com.mojang.serialization.Codec import com.mojang.serialization.codecs.RecordCodecBuilder -import net.minecraft.advancements.Criterion -import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance import net.minecraft.advancements.critereon.ContextAwarePredicate -import net.minecraft.advancements.critereon.DeserializationContext -import net.minecraft.advancements.critereon.SimpleCriterionTrigger import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.core.fromJsonStrict -import ru.dbotthepony.mc.otm.core.toJsonStrict -import java.util.Optional +import java.util.* val ExopackObtainedTrigger = SingletonTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "exopack_obtained")) val ExopackGainedCraftingTrigger = SingletonTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "exopack_gained_crafting")) @@ -22,13 +15,12 @@ val ExopackGainedEnderAccessTrigger = SingletonTrigger(ResourceLocation(Overdriv val ExopackBatterySlotTrigger = ItemTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "exopack_battery_slot")) -object ExopackSlotsExpandedTrigger : SimpleCriterionTrigger() { - val id = ResourceLocation(OverdriveThatMatters.MOD_ID, "exopack_expanded") - - val codec: Codec = RecordCodecBuilder.create { +object ExopackSlotsExpandedTrigger : MCriterionTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "exopack_expanded")) { + override val codec: Codec = RecordCodecBuilder.create { it.group( Codec.intRange(0, Int.MAX_VALUE).optionalFieldOf("minGained", 0).forGetter(Instance::minGained), Codec.intRange(0, Int.MAX_VALUE).optionalFieldOf("minTotal", 0).forGetter(Instance::minTotal), + playerPredicateCodec.forGetter(Instance::playerPredicate) ).apply(it, ::Instance) } @@ -36,20 +28,10 @@ object ExopackSlotsExpandedTrigger : SimpleCriterionTrigger, p_66250_: DeserializationContext): Instance { - return codec.fromJsonStrict(p_66248_) - } - - data class Instance(val minGained: Int = 0, val minTotal: Int = 0) : AbstractCriterionTriggerInstance(Optional.empty()) { + class Instance(val minGained: Int = 0, val minTotal: Int = 0, player: Optional = Optional.empty()) : AbstractInstance(player) { init { require(minGained >= 0) { "Invalid minGained $minGained" } require(minTotal >= 0) { "Invalid minTotal $minTotal" } } - - override fun serializeToJson(): JsonObject { - return codec.toJsonStrict(this) as JsonObject - } - - fun criterion() = Criterion(ExopackSlotsExpandedTrigger, this) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/HurtTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/HurtTrigger.kt index c07e5d7e5..c5be0e2e5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/HurtTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/HurtTrigger.kt @@ -1,29 +1,19 @@ package ru.dbotthepony.mc.otm.triggers -import com.google.gson.JsonObject +import com.mojang.serialization.Codec import com.mojang.serialization.codecs.RecordCodecBuilder -import net.minecraft.advancements.Criterion -import net.minecraft.advancements.critereon.* +import net.minecraft.advancements.critereon.ContextAwarePredicate +import net.minecraft.advancements.critereon.DamagePredicate +import net.minecraft.advancements.critereon.EntityPredicate +import net.minecraft.advancements.critereon.MinMaxBounds import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import net.minecraft.world.damagesource.DamageSource import net.minecraft.world.entity.LivingEntity -import ru.dbotthepony.mc.otm.core.set -import ru.dbotthepony.mc.otm.data.Codec2TriggerSerializer import ru.dbotthepony.mc.otm.data.DamagePredicateCodec -import java.util.Optional - -abstract class HurtTrigger : SimpleCriterionTrigger() { - abstract val id: ResourceLocation - - final override fun createInstance( - p_66248_: JsonObject, - p_286603_: Optional, - p_66250_: DeserializationContext - ): Instance { - return codec.fromJson(p_66248_, p_286603_, p_66250_) - } +import java.util.* +class HurtTrigger(id: ResourceLocation) : MCriterionTrigger(id) { fun trigger(player: ServerPlayer, entity: LivingEntity, damage: Float, damageSource: DamageSource) { val context = EntityPredicate.createContext(player, entity) @@ -32,14 +22,12 @@ abstract class HurtTrigger : SimpleCriterionTrigger() { } } - val codec = Codec2TriggerSerializer { p -> - RecordCodecBuilder.create { - it.group( - p.awareContextCodec.optionalFieldOf("predicate").forGetter(Instance::predicate), - DamagePredicateCodec.optionalFieldOf("damagePredicate").forGetter(Instance::damagePredicate), - p.playerPredicate.forGetter { it.playerPredicate() } - ).apply(it, ::Instance) - } + override val codec: Codec = RecordCodecBuilder.create { + it.group( + predicateCodec.optionalFieldOf("predicate").forGetter(Instance::predicate), + DamagePredicateCodec.optionalFieldOf("damagePredicate").forGetter(Instance::damagePredicate), + playerPredicateCodec.forGetter(Instance::playerPredicate) + ).apply(it, ::Instance) } inner class Instance( @@ -52,11 +40,5 @@ abstract class HurtTrigger : SimpleCriterionTrigger() { Optional.empty() )), player: Optional = Optional.empty() - ) : AbstractCriterionTriggerInstance(player) { - override fun serializeToJson(): JsonObject { - return codec.toJson(this) - } - - fun criterion() = Criterion(this@HurtTrigger, this) - } + ) : AbstractInstance(player) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ItemTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ItemTrigger.kt index f319bb05d..a7cd9c923 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ItemTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ItemTrigger.kt @@ -1,44 +1,26 @@ package ru.dbotthepony.mc.otm.triggers -import com.google.gson.JsonObject import com.mojang.serialization.Codec import com.mojang.serialization.codecs.RecordCodecBuilder -import net.minecraft.advancements.Criterion -import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance import net.minecraft.advancements.critereon.ContextAwarePredicate -import net.minecraft.advancements.critereon.DeserializationContext import net.minecraft.advancements.critereon.ItemPredicate -import net.minecraft.advancements.critereon.SimpleCriterionTrigger import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import net.minecraft.world.item.ItemStack -import ru.dbotthepony.mc.otm.data.Codec2TriggerSerializer -import java.util.Optional +import java.util.* -class ItemTrigger(val id: ResourceLocation) : SimpleCriterionTrigger() { +class ItemTrigger(id: ResourceLocation) : MCriterionTrigger(id) { fun trigger(player: ServerPlayer, item: ItemStack) { trigger(player) { if (it.invert) !it.predicate.matches(item) else it.predicate.matches(item) } } - val codec = Codec2TriggerSerializer { p -> - RecordCodecBuilder.create { - it.group( - ItemPredicate.CODEC.fieldOf("predicate").forGetter(Instance::predicate), - Codec.BOOL.optionalFieldOf("invert", false).forGetter(Instance::invert), - p.playerPredicate.forGetter { it.playerPredicate() } - ).apply(it, ::Instance) - } + override val codec: Codec = RecordCodecBuilder.create { + it.group( + ItemPredicate.CODEC.fieldOf("predicate").forGetter(Instance::predicate), + Codec.BOOL.optionalFieldOf("invert", false).forGetter(Instance::invert), + playerPredicateCodec.forGetter(Instance::playerPredicate) + ).apply(it, ::Instance) } - override fun createInstance(p_66248_: JsonObject, p_286603_: Optional, p_66250_: DeserializationContext): Instance { - return codec.fromJson(p_66248_, p_286603_, p_66250_) - } - - inner class Instance(val predicate: ItemPredicate, val invert: Boolean = false, player: Optional = Optional.empty()) : AbstractCriterionTriggerInstance(player) { - override fun serializeToJson(): JsonObject { - return codec.toJson(this) - } - - fun criterion() = Criterion(this@ItemTrigger, this) - } + inner class Instance(val predicate: ItemPredicate, val invert: Boolean = false, player: Optional = Optional.empty()) : AbstractInstance(player) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/KillAsAndroidTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/KillAsAndroidTrigger.kt index c78c2c040..432303360 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/KillAsAndroidTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/KillAsAndroidTrigger.kt @@ -1,66 +1,67 @@ package ru.dbotthepony.mc.otm.triggers import com.google.common.collect.ImmutableList -import com.google.gson.JsonArray -import com.google.gson.JsonObject -import com.google.gson.JsonSyntaxException -import net.minecraft.advancements.Criterion +import com.mojang.serialization.Codec +import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.advancements.critereon.* import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer +import net.minecraft.util.StringRepresentable import net.minecraft.world.entity.monster.ElderGuardian import net.minecraftforge.event.entity.living.LivingDeathEvent import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer -import ru.dbotthepony.mc.otm.core.asIterable -import ru.dbotthepony.mc.otm.core.set -import ru.dbotthepony.mc.otm.core.stream +import ru.dbotthepony.mc.otm.data.SingletonCodec import ru.dbotthepony.mc.otm.registry.MRegistry import java.util.Optional import java.util.function.Predicate -object KillAsAndroidTrigger : SimpleCriterionTrigger() { - val id = ResourceLocation(OverdriveThatMatters.MOD_ID, "kill_as_android") +object KillAsAndroidTrigger : MCriterionTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "kill_as_android")) { + val FEATURE_CODEC: Codec = StringRepresentable.fromEnum(PredicateType::values).dispatch({ it.type }, { it.codec }) - override fun createInstance(pJson: JsonObject, pPlayer: Optional, pContext: DeserializationContext): Instance { - return Instance( - predicate = EntityPredicate.fromJson(pJson, "predicate", pContext), - playerPredicate = pPlayer, - featurePredicate = (pJson["feature_predicate"] as? JsonObject)?.let(PredicateType::from) ?: throw JsonSyntaxException("Invalid 'feature_predicate': ${pJson["feature_predicate"]}") - ) + override val codec: Codec = RecordCodecBuilder.create { + it.group( + predicateCodec.optionalFieldOf("entityPredicate").forGetter(Instance::predicate), + FEATURE_CODEC.fieldOf("featurePredicate").forGetter(Instance::featurePredicate), + playerPredicateCodec.forGetter(Instance::playerPredicate) + ).apply(it, ::Instance) } - enum class PredicateType(val factory: (JsonObject) -> FeaturePredicate) { - ALWAYS({ Always }), - HAS(::Has), - NOT(::Not), - AND(::And), - OR(::OrPredicate); - - companion object { - fun from(json: JsonObject): FeaturePredicate { - return when (val type = json["type"]?.asString?.lowercase()) { - null -> throw JsonSyntaxException("Missing feature predicate 'type'") - "has" -> HAS.factory(json) - "and" -> AND.factory(json) - "not" -> NOT.factory(json) - "or" -> OR.factory(json) - "always" -> ALWAYS.factory(json) - else -> throw JsonSyntaxException("Unknown feature predicate $type") - } + enum class PredicateType(codec: Lazy>) : StringRepresentable { + ALWAYS(lazy { + SingletonCodec(Always) + }), + HAS(lazy { + RecordCodecBuilder.create { + it.group(ResourceLocation.CODEC.fieldOf("name").forGetter(Has::name)).apply(it, ::Has) } + }), + NOT(lazy { + RecordCodecBuilder.create { + it.group(FEATURE_CODEC.fieldOf("parent").forGetter(Not::parent)).apply(it, ::Not) + } + }), + AND(lazy { + RecordCodecBuilder.create { + it.group(FEATURE_CODEC.listOf().fieldOf("children").forGetter(And::children)).apply(it, ::And) + } + }), + OR(lazy { + RecordCodecBuilder.create { + it.group(FEATURE_CODEC.listOf().fieldOf("children").forGetter(OrPredicate::children)).apply(it, ::OrPredicate) + } + }); + + val codec by codec + + override fun getSerializedName(): String { + return name.lowercase() } } abstract class FeaturePredicate : Predicate { abstract val type: PredicateType - - open fun toJson(): JsonObject { - return JsonObject().also { - it["type"] = type.name.lowercase() - } - } } object Always : FeaturePredicate() { @@ -72,17 +73,8 @@ object KillAsAndroidTrigger : SimpleCriterionTrigger) : FeaturePredicate() { - constructor(input: JsonObject) : this((input["children"] as? JsonArray)?.stream()?.map { PredicateType.from(it as? JsonObject ?: throw JsonSyntaxException("Invalid element in children list: $it")) }?.asIterable() ?: throw JsonSyntaxException("Invalid children list")) - val children: ImmutableList = ImmutableList.copyOf(children) override val type: PredicateType @@ -126,21 +102,9 @@ object KillAsAndroidTrigger : SimpleCriterionTrigger) : FeaturePredicate() { - constructor(input: JsonObject) : this((input["children"] as? JsonArray)?.stream()?.map { PredicateType.from(it as? JsonObject ?: throw JsonSyntaxException("Invalid element in children list: $it")) }?.asIterable() ?: throw JsonSyntaxException("Invalid children list")) - val children: ImmutableList = ImmutableList.copyOf(children) override val type: PredicateType @@ -149,32 +113,13 @@ object KillAsAndroidTrigger : SimpleCriterionTrigger = Optional.empty(), val featurePredicate: FeaturePredicate = Always, playerPredicate: Optional = Optional.empty(), - ) : AbstractCriterionTriggerInstance(playerPredicate) { - override fun serializeToJson(): JsonObject { - return super.serializeToJson().also { - predicate.ifPresent { p -> it["predicate"] = p.toJson() } - it["feature_predicate"] = featurePredicate.toJson() - } - } - - fun criterion() = Criterion(KillAsAndroidTrigger, this) - } + ) : AbstractInstance(playerPredicate) fun onKill(event: LivingDeathEvent) { if (event.entity is ElderGuardian) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt new file mode 100644 index 000000000..d1c9b2370 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt @@ -0,0 +1,105 @@ +package ru.dbotthepony.mc.otm.triggers + +import com.google.gson.JsonObject +import com.google.gson.JsonParseException +import com.mojang.datafixers.util.Pair +import com.mojang.serialization.Codec +import com.mojang.serialization.DataResult +import com.mojang.serialization.DynamicOps +import com.mojang.serialization.JsonOps +import com.mojang.serialization.MapCodec +import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet +import it.unimi.dsi.fastutil.objects.Reference2ObjectFunction +import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap +import net.minecraft.advancements.Criterion +import net.minecraft.advancements.CriterionTrigger +import net.minecraft.advancements.CriterionTriggerInstance +import net.minecraft.advancements.critereon.ContextAwarePredicate +import net.minecraft.advancements.critereon.DeserializationContext +import net.minecraft.advancements.critereon.EntityPredicate +import net.minecraft.resources.ResourceLocation +import net.minecraft.server.PlayerAdvancements +import net.minecraft.server.level.ServerPlayer +import ru.dbotthepony.mc.otm.core.collect.filter +import ru.dbotthepony.mc.otm.core.collect.toImmutableList +import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.toJsonStrict +import java.util.Optional +import java.util.function.Predicate + +// allows to support both 1.20.1 and 1.20.2 with ease +// and has slightly less memory footprint than vanilla SimpleCriterionTrigger +abstract class MCriterionTrigger.AbstractInstance>(val id: ResourceLocation) : CriterionTrigger { + private val listeners = Reference2ObjectOpenHashMap>>() + + override fun addPlayerListener(advancements: PlayerAdvancements, listener: CriterionTrigger.Listener) { + listeners.computeIfAbsent(advancements, Reference2ObjectFunction { ObjectOpenHashSet() }).add(listener) + } + + override fun removePlayerListener(advancements: PlayerAdvancements, listener: CriterionTrigger.Listener) { + listeners[advancements]?.remove(listener) + } + + override fun removePlayerListeners(advancements: PlayerAdvancements) { + listeners.remove(advancements) + } + + protected abstract val codec: Codec + + override fun createInstance(data: JsonObject, context: DeserializationContext): T { + return try { + deserializationContext.get().addLast(context) + codec.decode(JsonOps.INSTANCE, data).getOrThrow(false) { throw JsonParseException("Failed to decode data: $it") }.first + } finally { + deserializationContext.get().removeLast() + } + } + + fun trigger(player: ServerPlayer, predicate: Predicate = Predicate { true }) { + val advancements = player.advancements + val listeners = listeners[advancements] ?: return + + val context = EntityPredicate.createContext(player, player) + + listeners.iterator() + .filter { predicate.test(it.trigger) && it.trigger.playerPredicate.map { it.matches(context) }.orElse(true) } + .toImmutableList() + .forEach { it.run(advancements) } + } + + abstract inner class AbstractInstance(val playerPredicate: Optional) : CriterionTriggerInstance { + fun criterion() = Criterion(this@MCriterionTrigger, this as T) + + final override fun serializeToJson(): JsonObject { + return codec.toJsonStrict(this as T) as JsonObject + } + } + + companion object { + protected val deserializationContext = object : ThreadLocal>() { + override fun initialValue(): ArrayDeque { + return ArrayDeque() + } + } + + @JvmStatic + protected val predicateCodec: Codec = object : Codec { + override fun encode(input: ContextAwarePredicate, ops: DynamicOps, prefix: T): DataResult { + return DataResult.success(JsonOps.INSTANCE.convertTo(ops, input.toJson())) + } + + override fun decode(ops: DynamicOps, input: T): DataResult> { + val context = deserializationContext.get().lastOrNull() ?: return DataResult.error { "Not current deserializing trigger instance" } + + return try { + DataResult.success(Pair.of(EntityPredicate.fromJson(JsonObject().also { it["a"] = ops.convertTo(JsonOps.INSTANCE, input) }, "a", context).get(), ops.empty())) + } catch (err: Exception) { + DataResult.error { "Failed to deserialize ContextAwarePredicate: " + err.message } + } + } + } + + @JvmStatic + protected val playerPredicateCodec: MapCodec> = predicateCodec.optionalFieldOf("player") + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NailedEntityTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NailedEntityTrigger.kt deleted file mode 100644 index 6414c8a1b..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NailedEntityTrigger.kt +++ /dev/null @@ -1,8 +0,0 @@ -package ru.dbotthepony.mc.otm.triggers - -import net.minecraft.resources.ResourceLocation -import ru.dbotthepony.mc.otm.OverdriveThatMatters - -object NailedEntityTrigger : HurtTrigger() { - override val id = ResourceLocation(OverdriveThatMatters.MOD_ID, "hammer_nail_damage") -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NanobotsArmorTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NanobotsArmorTrigger.kt index e5ef672e2..9c290969e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NanobotsArmorTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NanobotsArmorTrigger.kt @@ -1,45 +1,25 @@ package ru.dbotthepony.mc.otm.triggers -import com.google.gson.JsonObject +import com.mojang.serialization.Codec import com.mojang.serialization.codecs.RecordCodecBuilder -import net.minecraft.advancements.Criterion -import net.minecraft.advancements.critereon.* +import net.minecraft.advancements.critereon.ContextAwarePredicate import net.minecraft.advancements.critereon.MinMaxBounds.Doubles import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.data.Codec2TriggerSerializer -import java.util.Optional +import java.util.* -object NanobotsArmorTrigger : SimpleCriterionTrigger() { - val id = ResourceLocation(OverdriveThatMatters.MOD_ID, "nanobots_armor") - - override fun createInstance( - p_66248_: JsonObject, - p_286603_: Optional, - p_66250_: DeserializationContext - ): Instance { - return codec.fromJson(p_66248_, p_286603_, p_66250_) - } - - val codec = Codec2TriggerSerializer { p -> - RecordCodecBuilder.create { - it.group( - Doubles.CODEC.fieldOf("predicate").forGetter(Instance::predicate), - p.playerPredicate.forGetter { it.playerPredicate() }, - ).apply(it, ::Instance) - } +object NanobotsArmorTrigger : MCriterionTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "nanobots_armor")) { + override val codec: Codec = RecordCodecBuilder.create { + it.group( + Doubles.CODEC.fieldOf("predicate").forGetter(Instance::predicate), + playerPredicateCodec.forGetter(Instance::playerPredicate), + ).apply(it, ::Instance) } fun trigger(player: ServerPlayer, damageAbsorbed: Double) { trigger(player) { it.predicate.matches(damageAbsorbed) } } - class Instance(val predicate: Doubles, player: Optional = Optional.empty()) : AbstractCriterionTriggerInstance(player) { - override fun serializeToJson(): JsonObject { - return codec.toJson((this)) - } - - fun criterion() = Criterion(NanobotsArmorTrigger, this) - } + class Instance(val predicate: Doubles, player: Optional = Optional.empty()) : AbstractInstance(player) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ShockwaveDamageMobTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ShockwaveDamageMobTrigger.kt deleted file mode 100644 index 7f8727b2e..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ShockwaveDamageMobTrigger.kt +++ /dev/null @@ -1,8 +0,0 @@ -package ru.dbotthepony.mc.otm.triggers - -import net.minecraft.resources.ResourceLocation -import ru.dbotthepony.mc.otm.OverdriveThatMatters - -object ShockwaveDamageMobTrigger : HurtTrigger() { - override val id = ResourceLocation(OverdriveThatMatters.MOD_ID, "shockwave_damage_mob") -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/SimpleTriggers.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/SimpleTriggers.kt index 174884c99..18adae924 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/SimpleTriggers.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/SimpleTriggers.kt @@ -15,3 +15,6 @@ val BecomeHumaneTrigger = SingletonTrigger(ResourceLocation(OverdriveThatMatters val AndroidBatteryTrigger = ItemTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "android_battery")) val TakeItemOutOfReplicatorTrigger = ItemTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "take_item_out_of_replicator")) + +val NailedEntityTrigger = HurtTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "hammer_nail_damage")) +val ShockwaveDamageMobTrigger = HurtTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "shockwave_damage_mob")) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/SingletonTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/SingletonTrigger.kt index 04f447a65..6ad9afd6d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/SingletonTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/SingletonTrigger.kt @@ -1,42 +1,19 @@ package ru.dbotthepony.mc.otm.triggers -import com.google.gson.JsonObject +import com.mojang.serialization.Codec import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.advancements.Criterion -import net.minecraft.advancements.critereon.AbstractCriterionTriggerInstance import net.minecraft.advancements.critereon.ContextAwarePredicate -import net.minecraft.advancements.critereon.DeserializationContext -import net.minecraft.advancements.critereon.SimpleCriterionTrigger import net.minecraft.resources.ResourceLocation -import net.minecraft.server.level.ServerPlayer -import ru.dbotthepony.mc.otm.data.Codec2TriggerSerializer -import java.util.Optional +import java.util.* -class SingletonTrigger(val id: ResourceLocation) : SimpleCriterionTrigger() { - override fun createInstance(p_66248_: JsonObject, p_286603_: Optional, p_66250_: DeserializationContext): AbstractCriterionTriggerInstance { - return codec.fromJson(p_66248_, p_286603_, p_66250_) - } - - fun trigger(player: ServerPlayer) { - trigger(player) { true } - } - - val codec = Codec2TriggerSerializer { p -> - RecordCodecBuilder.create { - it.group( - p.playerPredicate.forGetter { it.playerPredicate() } - ).apply(it, ::Instance) - } +class SingletonTrigger(id: ResourceLocation) : MCriterionTrigger(id) { + override val codec: Codec = RecordCodecBuilder.create { + it.group(playerPredicateCodec.forGetter(Instance::playerPredicate)).apply(it, ::Instance) } val empty = Instance() val criterion = Criterion(this@SingletonTrigger, empty) - inner class Instance(player: Optional = Optional.empty()) : AbstractCriterionTriggerInstance(player) { - override fun serializeToJson(): JsonObject { - return codec.toJson(this) - } - - fun criterion() = Criterion(this@SingletonTrigger, this) - } + inner class Instance(player: Optional = Optional.empty()) : AbstractInstance(player) } From 520112df77a9873933a5ff423d031d137a39af29 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 31 Dec 2023 20:29:57 +0700 Subject: [PATCH 1150/1199] Backport MCriterionTrigger to 1.20.1 --- .../mc/otm/triggers/MCriterionTrigger.kt | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt index d1c9b2370..7274941f9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt @@ -17,6 +17,7 @@ import net.minecraft.advancements.CriterionTriggerInstance import net.minecraft.advancements.critereon.ContextAwarePredicate import net.minecraft.advancements.critereon.DeserializationContext import net.minecraft.advancements.critereon.EntityPredicate +import net.minecraft.advancements.critereon.SerializationContext import net.minecraft.resources.ResourceLocation import net.minecraft.server.PlayerAdvancements import net.minecraft.server.level.ServerPlayer @@ -30,6 +31,10 @@ import java.util.function.Predicate // allows to support both 1.20.1 and 1.20.2 with ease // and has slightly less memory footprint than vanilla SimpleCriterionTrigger abstract class MCriterionTrigger.AbstractInstance>(val id: ResourceLocation) : CriterionTrigger { + override fun getId(): ResourceLocation { + return id + } + private val listeners = Reference2ObjectOpenHashMap>>() override fun addPlayerListener(advancements: PlayerAdvancements, listener: CriterionTrigger.Listener) { @@ -62,16 +67,25 @@ abstract class MCriterionTrigger.AbstractInstance>(val val context = EntityPredicate.createContext(player, player) listeners.iterator() - .filter { predicate.test(it.trigger) && it.trigger.playerPredicate.map { it.matches(context) }.orElse(true) } + .filter { predicate.test(it.triggerInstance) && it.triggerInstance.playerPredicate.map { it.matches(context) }.orElse(true) } .toImmutableList() .forEach { it.run(advancements) } } abstract inner class AbstractInstance(val playerPredicate: Optional) : CriterionTriggerInstance { - fun criterion() = Criterion(this@MCriterionTrigger, this as T) + fun criterion() = this as T - final override fun serializeToJson(): JsonObject { - return codec.toJsonStrict(this as T) as JsonObject + override fun getCriterion(): ResourceLocation { + return id + } + + final override fun serializeToJson(context: SerializationContext): JsonObject { + return try { + serializationContext.get().addLast(context) + codec.toJsonStrict(this as T) as JsonObject + } finally { + serializationContext.get().removeLast() + } } } @@ -82,17 +96,23 @@ abstract class MCriterionTrigger.AbstractInstance>(val } } + protected val serializationContext = object : ThreadLocal>() { + override fun initialValue(): ArrayDeque { + return ArrayDeque() + } + } + @JvmStatic protected val predicateCodec: Codec = object : Codec { override fun encode(input: ContextAwarePredicate, ops: DynamicOps, prefix: T): DataResult { - return DataResult.success(JsonOps.INSTANCE.convertTo(ops, input.toJson())) + return DataResult.success(JsonOps.INSTANCE.convertTo(ops, input.toJson(serializationContext.get().lastOrNull() ?: return DataResult.error { "Not serializing trigger instance" }))) } override fun decode(ops: DynamicOps, input: T): DataResult> { val context = deserializationContext.get().lastOrNull() ?: return DataResult.error { "Not current deserializing trigger instance" } return try { - DataResult.success(Pair.of(EntityPredicate.fromJson(JsonObject().also { it["a"] = ops.convertTo(JsonOps.INSTANCE, input) }, "a", context).get(), ops.empty())) + DataResult.success(Pair.of(EntityPredicate.fromJson(JsonObject().also { it["a"] = ops.convertTo(JsonOps.INSTANCE, input) }, "a", context), ops.empty())) } catch (err: Exception) { DataResult.error { "Failed to deserialize ContextAwarePredicate: " + err.message } } From 7683cacc29ed244fcb6241db45bf3c9277a4e884 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 31 Dec 2023 20:42:20 +0700 Subject: [PATCH 1151/1199] More backporting --- .../mc/otm/android/AndroidResearchType.kt | 3 +- .../mc/otm/client/ClientEventHandler.kt | 4 +- .../mc/otm/data/ItemPredicateCodec.kt | 27 ++++++++++ .../mc/otm/data/loot/LootPoolAppender.kt | 50 ++++++++++++++++++- .../mc/otm/item/MinecartCargoCrateItem.kt | 7 +-- .../mc/otm/matter/MatterManager.kt | 4 +- .../mc/otm/triggers/HurtTrigger.kt | 7 +-- .../mc/otm/triggers/ItemTrigger.kt | 3 +- .../mc/otm/triggers/MCriterionTrigger.kt | 2 +- .../mc/otm/triggers/SingletonTrigger.kt | 2 +- 10 files changed, 92 insertions(+), 17 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/ItemPredicateCodec.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt index ad2610563..f4eb7a76a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt @@ -25,6 +25,7 @@ import ru.dbotthepony.mc.otm.core.collect.ListSet import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.isActuallyEmpty import ru.dbotthepony.mc.otm.data.ComponentCodec +import ru.dbotthepony.mc.otm.data.IngredientCodec import ru.dbotthepony.mc.otm.data.JsonElementCodec import ru.dbotthepony.mc.otm.isClient import java.util.Optional @@ -392,7 +393,7 @@ class AndroidResearchType( ListCodec( RecordCodecBuilder.create> { it.group( - Ingredient.CODEC.fieldOf("item").forGetter { it.first }, + IngredientCodec.fieldOf("item").forGetter { it.first }, Codec.intRange(1, Int.MAX_VALUE).optionalFieldOf("count", 1).forGetter { it.second } ).apply(it, ::Pair) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt index 66b76fa4a..510f353c8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt @@ -224,7 +224,7 @@ fun onMouseScrolled(event: MouseScrolled.Pre) { for (widget in screen.renderables) { if (widget is Panel2Widget<*, *>) { - if (widget.panel.mouseScrolledChecked(event.mouseX, event.mouseY, event.deltaX)) { + if (widget.panel.mouseScrolledChecked(event.mouseX, event.mouseY, event.scrollDelta)) { event.isCanceled = true return } @@ -233,7 +233,7 @@ fun onMouseScrolled(event: MouseScrolled.Pre) { val slot = screen.slotUnderMouse if (slot != null && (slot.container == minecraft.player?.inventory && slot.containerSlot in 9 .. 35 || slot.container == minecraft.player?.matteryPlayer?.exopackContainer)) { - widget.panel.mouseScrolledInner(event.mouseX, event.mouseY, event.deltaX) + widget.panel.mouseScrolledInner(event.mouseX, event.mouseY, event.scrollDelta) event.isCanceled = true return } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/ItemPredicateCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/ItemPredicateCodec.kt new file mode 100644 index 000000000..b37fb23a9 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/ItemPredicateCodec.kt @@ -0,0 +1,27 @@ +package ru.dbotthepony.mc.otm.data + +import com.google.gson.JsonObject +import com.google.gson.JsonParseException +import com.google.gson.JsonSyntaxException +import com.mojang.datafixers.util.Pair +import com.mojang.serialization.Codec +import com.mojang.serialization.DataResult +import com.mojang.serialization.DynamicOps +import com.mojang.serialization.JsonOps +import net.minecraft.advancements.critereon.ItemPredicate + +object ItemPredicateCodec : Codec { + override fun encode(input: ItemPredicate, ops: DynamicOps, prefix: T): DataResult { + return DataResult.success(JsonOps.INSTANCE.convertTo(ops, input.serializeToJson().let { if (it is JsonObject) it.getRidOfNulls() else it })) + } + + override fun decode(ops: DynamicOps, input: T): DataResult> { + return try { + DataResult.success(Pair(ItemPredicate.fromJson(ops.convertTo(JsonOps.INSTANCE, input)), ops.empty())) + } catch (err: JsonSyntaxException) { + DataResult.error { "Failed to deserialize ItemPredicate: ${err.message}" } + } catch (err: JsonParseException) { + DataResult.error { "Failed to deserialize ItemPredicate: ${err.message}" } + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt index 99556a944..4154609d1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt @@ -1,13 +1,20 @@ package ru.dbotthepony.mc.otm.data.loot import com.google.common.collect.ImmutableList +import com.google.gson.JsonSyntaxException import com.mojang.serialization.Codec +import com.mojang.serialization.DataResult +import com.mojang.serialization.Dynamic +import com.mojang.serialization.JsonOps import com.mojang.serialization.codecs.RecordCodecBuilder import it.unimi.dsi.fastutil.objects.ObjectArrayList +import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.ItemStack +import net.minecraft.world.level.storage.loot.Deserializers import net.minecraft.world.level.storage.loot.LootContext import net.minecraft.world.level.storage.loot.LootPool import net.minecraft.world.level.storage.loot.predicates.LootItemCondition +import net.minecraftforge.common.ForgeHooks import net.minecraftforge.common.loot.IGlobalLootModifier import net.minecraftforge.common.loot.LootModifier import java.util.* @@ -32,10 +39,51 @@ class LootPoolAppender(conditions: Array, pools: Stream> + + private val forgeHooksLootContext by lazy { + val field = ForgeHooks::class.java.getDeclaredField("lootContext") + field.isAccessible = true + field + } + + private val lootTableContextConstructor by lazy { + val clazz = ForgeHooks::class.java.declaredClasses.firstOrNull { it.name.contains("LootTableContext") } ?: throw NoSuchElementException("Unable to find ForgeHooks\$LootTableContext!") + val constructor = clazz.getDeclaredConstructor(ResourceLocation::class.java, Boolean::class.java) + constructor.isAccessible = true + constructor + } + + init { + val serializer = Deserializers.createLootTableSerializer().create() + val notExistingLocation = ResourceLocation("null", "null") + + lootPoolCodec = Codec.list(Codec.PASSTHROUGH.flatXmap({ + val dequeueHolder = forgeHooksLootContext.get(null) as ThreadLocal> + val deque = dequeueHolder.get() ?: java.util.ArrayDeque() + dequeueHolder.set(deque) + + try { + deque.push(lootTableContextConstructor.newInstance(notExistingLocation, true)) + DataResult.success(serializer.fromJson(it.convert(JsonOps.INSTANCE).value, LootPool::class.java)) + } catch(err: JsonSyntaxException) { + DataResult.error { err.message } + } finally { + deque.pop() + } + }, { + try { + DataResult.success(Dynamic(JsonOps.INSTANCE, serializer.toJsonTree(it))) + } catch(err: JsonSyntaxException) { + DataResult.error { err.message } + } + })) + } + val CODEC: Codec = RecordCodecBuilder.create { codecStart(it).and( - LootPool.CODEC.listOf().fieldOf("pools").forGetter(LootPoolAppender::pools) + lootPoolCodec.fieldOf("pools").forGetter(LootPoolAppender::pools) ).apply(it, ::LootPoolAppender) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MinecartCargoCrateItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MinecartCargoCrateItem.kt index 9df929a39..25b520997 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/MinecartCargoCrateItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/MinecartCargoCrateItem.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.mc.otm.item +import net.minecraft.core.BlockSource import net.minecraft.core.Direction -import net.minecraft.core.dispenser.BlockSource import net.minecraft.core.dispenser.DefaultDispenseItemBehavior import net.minecraft.core.dispenser.DispenseItemBehavior import net.minecraft.tags.BlockTags @@ -9,17 +9,14 @@ import net.minecraft.world.InteractionResult import net.minecraft.world.item.DyeColor import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.MinecartItem import net.minecraft.world.item.context.UseOnContext import net.minecraft.world.level.Level import net.minecraft.world.level.block.BaseRailBlock import net.minecraft.world.level.block.DispenserBlock import net.minecraft.world.level.block.state.properties.RailShape import net.minecraft.world.level.gameevent.GameEvent -import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.entity.MinecartCargoCrate import ru.dbotthepony.mc.otm.registry.MEntityTypes -import kotlin.math.floor class MinecartCargoCrateItem(val color: DyeColor?) : Item(Properties().stacksTo(16)) { init { @@ -67,7 +64,7 @@ class MinecartCargoCrateItem(val color: DyeColor?) : Item(Properties().stacksTo( private val default = DefaultDispenseItemBehavior() override fun dispense(blockSource: BlockSource, itemStack: ItemStack): ItemStack { - val direction = blockSource.state.getValue(DispenserBlock.FACING) + val direction = blockSource.blockState.getValue(DispenserBlock.FACING) val level: Level = blockSource.level val x = blockSource.pos.x + direction.stepX.toDouble() * 1.125 val y = blockSource.pos.y + direction.stepY.toDouble() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 18f0572ff..b8467b1db 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -53,7 +53,6 @@ import net.minecraftforge.event.AddReloadListenerEvent import net.minecraftforge.event.OnDatapackSyncEvent import net.minecraftforge.event.RegisterCommandsEvent import net.minecraftforge.event.entity.player.ItemTooltipEvent -import net.minecraftforge.event.network.CustomPayloadEvent import net.minecraftforge.event.server.ServerStartedEvent import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.fml.ModList @@ -94,6 +93,7 @@ import ru.dbotthepony.mc.otm.core.util.readBinaryComponent import ru.dbotthepony.mc.otm.core.util.readCollection import ru.dbotthepony.mc.otm.core.util.writeBinaryComponent import ru.dbotthepony.mc.otm.core.util.writeCollection +import ru.dbotthepony.mc.otm.core.value import ru.dbotthepony.mc.otm.core.writeItemType import ru.dbotthepony.mc.otm.milliTime import ru.dbotthepony.mc.otm.network.GenericNetworkChannel @@ -1703,7 +1703,7 @@ object MatterManager { if (event.player == null) { syncRegistry(PacketDistributor.ALL.noArg()) } else { - syncRegistry(PacketDistributor.PLAYER.with(event.player!!)) + syncRegistry(PacketDistributor.PLAYER.with { event.player!! }) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/HurtTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/HurtTrigger.kt index c5be0e2e5..a175050d3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/HurtTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/HurtTrigger.kt @@ -4,6 +4,7 @@ import com.mojang.serialization.Codec import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.advancements.critereon.ContextAwarePredicate import net.minecraft.advancements.critereon.DamagePredicate +import net.minecraft.advancements.critereon.DamageSourcePredicate import net.minecraft.advancements.critereon.EntityPredicate import net.minecraft.advancements.critereon.MinMaxBounds import net.minecraft.resources.ResourceLocation @@ -35,9 +36,9 @@ class HurtTrigger(id: ResourceLocation) : MCriterionTrigger = Optional.of(DamagePredicate( MinMaxBounds.Doubles.atLeast(1.0), MinMaxBounds.Doubles.atLeast(1.0), - Optional.empty(), - Optional.empty(), - Optional.empty() + EntityPredicate.ANY, + null, + DamageSourcePredicate.ANY )), player: Optional = Optional.empty() ) : AbstractInstance(player) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ItemTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ItemTrigger.kt index a7cd9c923..c4acc7ccc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ItemTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ItemTrigger.kt @@ -7,6 +7,7 @@ import net.minecraft.advancements.critereon.ItemPredicate import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.data.ItemPredicateCodec import java.util.* class ItemTrigger(id: ResourceLocation) : MCriterionTrigger(id) { @@ -16,7 +17,7 @@ class ItemTrigger(id: ResourceLocation) : MCriterionTrigger = RecordCodecBuilder.create { it.group( - ItemPredicate.CODEC.fieldOf("predicate").forGetter(Instance::predicate), + ItemPredicateCodec.fieldOf("predicate").forGetter(Instance::predicate), Codec.BOOL.optionalFieldOf("invert", false).forGetter(Instance::invert), playerPredicateCodec.forGetter(Instance::playerPredicate) ).apply(it, ::Instance) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt index 7274941f9..f422251f6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt @@ -73,7 +73,7 @@ abstract class MCriterionTrigger.AbstractInstance>(val } abstract inner class AbstractInstance(val playerPredicate: Optional) : CriterionTriggerInstance { - fun criterion() = this as T + fun criterion() = Criterion(this as T) override fun getCriterion(): ResourceLocation { return id diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/SingletonTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/SingletonTrigger.kt index 6ad9afd6d..8a7536d80 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/SingletonTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/SingletonTrigger.kt @@ -13,7 +13,7 @@ class SingletonTrigger(id: ResourceLocation) : MCriterionTrigger = Optional.empty()) : AbstractInstance(player) } From 422ae92303d5bd014ea3c81e51712c9ee0aa6ec0 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 31 Dec 2023 21:02:52 +0700 Subject: [PATCH 1152/1199] More backporting --- .../otm/block/entity/blackhole/Explosions.kt | 4 +- .../otm/client/screen/panels/Panel2Widget.kt | 2 +- .../mc/otm/compat/curios/CuriosCompat.kt | 2 +- .../jade/providers/MatterBottlerProvider.kt | 2 +- .../providers/MatterReconstructorProvider.kt | 2 +- .../jade/providers/MatterStorageProvider.kt | 2 +- .../jade/providers/MatteryEnergyProvider.kt | 2 +- .../jade/providers/MatteryWorkerProvider.kt | 2 +- .../jei/ExopackInventoryTransferHandler.kt | 17 ++++--- .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 3 ++ .../mc/otm/core/nbt/CompoundTagExt.kt | 2 +- .../mc/otm/data/Codec2RecipeSerializer.kt | 1 + .../mc/otm/data/Codec2Serializer.kt | 37 ++++++++++++++++ .../mc/otm/data/loot/CopyTileNbtFunction.kt | 21 +++++---- .../mc/otm/item/ProceduralBatteryItem.kt | 21 +++++---- .../mc/otm/item/QuantumBatteryItem.kt | 4 +- .../ProceduralExopackSlotUpgradeItem.kt | 15 ++++--- .../mc/otm/menu/data/NetworkedItemView.kt | 2 +- .../mc/otm/menu/matter/MatterEntanglerMenu.kt | 1 + .../mc/otm/network/GenericNetworkChannel.kt | 4 +- .../mc/otm/recipe/MatterEntanglerRecipe.kt | 19 +++++--- .../mc/otm/recipe/MatteryCookingRecipe.kt | 14 ++++-- .../ru/dbotthepony/mc/otm/registry/MFluids.kt | 2 +- .../mc/otm/registry/MLootItemConditions.kt | 13 +++--- .../dbotthepony/mc/otm/registry/MRegistry.kt | 44 +++++++++---------- 25 files changed, 152 insertions(+), 86 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt 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 ed6136dd2..945de031e 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 @@ -668,11 +668,11 @@ class ExplosionQueue(private val level: ServerLevel) : SavedData() { @JvmStatic fun queueForLevel(level: ServerLevel): ExplosionQueue { return level.dataStorage.computeIfAbsent( - Factory({ ExplosionQueue(level) }, { + { val factory = ExplosionQueue(level) factory.load(it) factory - }, DataFixTypes.LEVEL), + }, { ExplosionQueue(level) }, "otm_blackhole_explosion_queue" ) } 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 7fb05715d..2fd87c09d 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 @@ -46,7 +46,7 @@ class Panel2Widget>( return panel.mouseDraggedChecked(p_94740_, p_94741_, p_94742_, p_94743_, p_94744_) } - override fun mouseScrolled(mouseX: Double, mouseY: Double, scrollX: Double, scrollY: Double): Boolean { + override fun mouseScrolled(mouseX: Double, mouseY: Double, scrollY: Double): Boolean { return panel.mouseScrolledChecked(mouseX, mouseY, scrollY) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt index 82164c0f2..60b1fca84 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt @@ -35,7 +35,7 @@ fun onCuriosSlotModifiersUpdated(event: SlotModifiersUpdatedEvent) { } fun openCuriosScreen(carriedStack: ItemStack = ItemStack.EMPTY) { - if (FMLEnvironment.dist.isClient) NetworkHandler.INSTANCE.send(CPacketOpenCurios(carriedStack), PacketDistributor.SERVER.noArg()) + if (FMLEnvironment.dist.isClient) NetworkHandler.INSTANCE.send(PacketDistributor.SERVER.noArg(), CPacketOpenCurios(carriedStack)) } private fun Player.getCuriosSlotsImpl(): List> { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterBottlerProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterBottlerProvider.kt index c44d42c25..30e0e4c77 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterBottlerProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterBottlerProvider.kt @@ -56,7 +56,7 @@ object MatterBottlerProvider : IBlockComponentProvider, IServerDataProvider> { - private val transfer = helper.createUnregisteredRecipeTransferHandler(object : IRecipeTransferInfo> { +class ExopackInventoryTransferHandler(private val helper: IRecipeTransferHandlerHelper) : IRecipeTransferHandler { + private val transfer = helper.createUnregisteredRecipeTransferHandler(object : IRecipeTransferInfo { override fun getContainerClass(): Class { return ExopackInventoryMenu::class.java } @@ -31,24 +30,24 @@ class ExopackInventoryTransferHandler(private val helper: IRecipeTransferHandler return Optional.empty() } - override fun getRecipeType(): mezz.jei.api.recipe.RecipeType> { + override fun getRecipeType(): mezz.jei.api.recipe.RecipeType { return RecipeTypes.CRAFTING } - override fun canHandle(container: ExopackInventoryMenu, recipe: RecipeHolder): Boolean { + override fun canHandle(container: ExopackInventoryMenu, recipe: CraftingRecipe): Boolean { return true } override fun getRecipeSlots( container: ExopackInventoryMenu, - recipe: RecipeHolder + recipe: CraftingRecipe ): List { return container.craftingSlots } override fun getInventorySlots( container: ExopackInventoryMenu, - recipe: RecipeHolder + recipe: CraftingRecipe ): List { return container.playerInventorySlots } @@ -62,7 +61,7 @@ class ExopackInventoryTransferHandler(private val helper: IRecipeTransferHandler return Optional.empty() } - override fun getRecipeType(): mezz.jei.api.recipe.RecipeType> { + override fun getRecipeType(): mezz.jei.api.recipe.RecipeType { return RecipeTypes.CRAFTING } @@ -89,7 +88,7 @@ class ExopackInventoryTransferHandler(private val helper: IRecipeTransferHandler override fun transferRecipe( container: ExopackInventoryMenu, - recipe: RecipeHolder, + recipe: CraftingRecipe, recipeSlots: IRecipeSlotsView, player: Player, maxTransfer: Boolean, 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 5ac378185..173689550 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -32,6 +32,8 @@ import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateHolder import net.minecraft.world.level.block.state.properties.Property +import net.minecraft.world.level.saveddata.SavedData +import net.minecraft.world.level.storage.DimensionDataStorage import net.minecraft.world.phys.Vec3 import net.minecraftforge.common.ForgeHooks import net.minecraftforge.common.util.LazyOptional @@ -55,6 +57,7 @@ import java.util.Arrays import java.util.Spliterators import java.util.UUID import java.util.function.Consumer +import java.util.function.Function import java.util.function.Supplier import java.util.stream.Stream import java.util.stream.StreamSupport diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt index f3ff05318..5adc25187 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/nbt/CompoundTagExt.kt @@ -117,7 +117,7 @@ fun CompoundTag.putJson(key: String, json: JsonElement) { putByteArray(key, bytes.array.copyOfRange(0, bytes.length)) } -fun CompoundTag.getJson(key: String, sizeLimit: NbtAccounter = NbtAccounter(1 shl 18, 512)): JsonElement? { +fun CompoundTag.getJson(key: String, sizeLimit: NbtAccounter = NbtAccounter(1 shl 18)): JsonElement? { val bytes = getByteArray(key) if (bytes.isEmpty()) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt index 3ddf52bd2..d2e04238e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt @@ -8,6 +8,7 @@ import com.mojang.serialization.Codec import com.mojang.serialization.DataResult import com.mojang.serialization.DynamicOps import com.mojang.serialization.JsonOps +import io.netty.buffer.Unpooled import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt new file mode 100644 index 000000000..10d9550bd --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt @@ -0,0 +1,37 @@ +package ru.dbotthepony.mc.otm.data + +import com.google.gson.JsonDeserializationContext +import com.google.gson.JsonObject +import com.google.gson.JsonSerializationContext +import com.google.gson.JsonSyntaxException +import com.mojang.serialization.Codec +import net.minecraft.world.level.storage.loot.Serializer +import ru.dbotthepony.mc.otm.core.fromJsonStrict +import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.toJsonStrict + +class Codec2Serializer(val codec: Codec, val embed: Boolean = true) : Serializer { + override fun serialize(data: JsonObject, value: T, context: JsonSerializationContext) { + if (embed) { + val result = codec.toJsonStrict(value, data) + + if (result !is JsonObject) { + throw RuntimeException("Expected JsonObject from codec, got ${result::class.qualifiedName}") + } + + val keys = ArrayList(data.keySet()) + for (k in keys) data.remove(k) + for ((k, v) in result.entrySet()) data[k] = v + } else { + data["value"] = codec.toJsonStrict(value) + } + } + + override fun deserialize(data: JsonObject, context: JsonDeserializationContext): T { + if (embed) { + return codec.fromJsonStrict(data) + } else { + return codec.fromJsonStrict(data["value"] ?: throw JsonSyntaxException("Missing 'value' element")) + } + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt index 5cd4f3c64..9d4a4f1be 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/CopyTileNbtFunction.kt @@ -16,6 +16,7 @@ import ru.dbotthepony.mc.otm.core.nbt.getJson import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.stream import ru.dbotthepony.mc.otm.core.tagNotNull +import ru.dbotthepony.mc.otm.data.Codec2Serializer import ru.dbotthepony.mc.otm.registry.MItemFunctionTypes import java.util.Optional import java.util.stream.Stream @@ -73,15 +74,17 @@ class CopyTileNbtFunction(filter: Stream = Stream.empty()) : LootIte } companion object { - val CODEC: Codec by lazy { - RecordCodecBuilder.create { - it.group( - Codec.STRING.listOf() - .optionalFieldOf("filter") - .xmap({ it.orElseGet { listOf() } }, { if (it.isEmpty()) Optional.empty() else Optional.of(it) }) - .forGetter(CopyTileNbtFunction::filter), - ).apply(it, ::CopyTileNbtFunction) - } + val CODEC by lazy { + Codec2Serializer( + RecordCodecBuilder.create { + it.group( + Codec.STRING.listOf() + .optionalFieldOf("filter") + .xmap({ it.orElseGet { listOf() } }, { if (it.isEmpty()) Optional.empty() else Optional.of(it) }) + .forGetter(CopyTileNbtFunction::filter), + ).apply(it, ::CopyTileNbtFunction) + } + ) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralBatteryItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralBatteryItem.kt index 1eb81c524..0932bc8d4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ProceduralBatteryItem.kt @@ -24,6 +24,7 @@ import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.set import ru.dbotthepony.mc.otm.core.nbt.mapPresent import ru.dbotthepony.mc.otm.core.tagNotNull +import ru.dbotthepony.mc.otm.data.Codec2Serializer import ru.dbotthepony.mc.otm.data.DecimalProvider import ru.dbotthepony.mc.otm.registry.MItemFunctionTypes import java.util.Optional @@ -119,15 +120,17 @@ class ProceduralBatteryItem : Item(Properties().stacksTo(1)) { } companion object { - val CODEC: Codec by lazy { - RecordCodecBuilder.create { - it.group( - DecimalProvider.CODEC.fieldOf("maxBatteryLevel").forGetter(Randomizer::maxBatteryLevel), - DecimalProvider.CODEC.optionalFieldOf("batteryLevel").forGetter(Randomizer::batteryLevel), - DecimalProvider.CODEC.fieldOf("maxInput").forGetter(Randomizer::maxInput), - DecimalProvider.CODEC.optionalFieldOf("maxOutput").forGetter(Randomizer::maxOutput), - ).apply(it, ::Randomizer) - } + val CODEC by lazy { + Codec2Serializer( + RecordCodecBuilder.create { + it.group( + DecimalProvider.CODEC.fieldOf("maxBatteryLevel").forGetter(Randomizer::maxBatteryLevel), + DecimalProvider.CODEC.optionalFieldOf("batteryLevel").forGetter(Randomizer::batteryLevel), + DecimalProvider.CODEC.fieldOf("maxInput").forGetter(Randomizer::maxInput), + DecimalProvider.CODEC.optionalFieldOf("maxOutput").forGetter(Randomizer::maxOutput), + ).apply(it, ::Randomizer) + } + ) } } } 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 9abcfed1b..ee6762534 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt @@ -30,8 +30,10 @@ import ru.dbotthepony.mc.otm.capability.energy.getBarColor import ru.dbotthepony.mc.otm.capability.energy.getBarWidth import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.config.EnergyBalanceValues +import ru.dbotthepony.mc.otm.core.Factory import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.collect.filter +import ru.dbotthepony.mc.otm.core.computeIfAbsent import ru.dbotthepony.mc.otm.core.getID import ru.dbotthepony.mc.otm.core.getValue import ru.dbotthepony.mc.otm.core.isNotEmpty @@ -153,7 +155,7 @@ class QuantumBatteryItem(val savedataID: String, val balanceValues: EnergyBalanc val clientData = Object2ObjectOpenHashMap() val serverData: Data by lazyPerServer { - it.overworld().dataStorage.computeIfAbsent(SavedData.Factory(::Data, ::Data, DataFixTypes.SAVED_DATA_MAP_DATA), "otm_$savedataID") + it.overworld().dataStorage.computeIfAbsent(::Data, ::Data, "otm_$savedataID") } private inner class Power(private val stack: ItemStack) : IMatteryEnergyStorage, ICapabilityProvider { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ProceduralExopackSlotUpgradeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ProceduralExopackSlotUpgradeItem.kt index 1a0188d3d..579148473 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ProceduralExopackSlotUpgradeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ProceduralExopackSlotUpgradeItem.kt @@ -15,6 +15,7 @@ import net.minecraft.world.level.storage.loot.functions.LootItemFunctionType import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.tagNotNull +import ru.dbotthepony.mc.otm.data.Codec2Serializer import ru.dbotthepony.mc.otm.registry.MItemFunctionTypes import java.util.* @@ -34,11 +35,15 @@ class ProceduralExopackSlotUpgradeItem : AbstractExopackSlotUpgradeItem(defaultP } companion object { - val CODEC: Codec = RecordCodecBuilder.create { - it.group( - IntProvider.CODEC.fieldOf("slots").forGetter(Randomizer::slots), - IntProvider.CODEC.optionalFieldOf("luck_bias", ConstantInt.ZERO).forGetter(Randomizer::luckBias), - ).apply(it, ::Randomizer) + val CODEC by lazy { + Codec2Serializer( + RecordCodecBuilder.create { + it.group( + IntProvider.CODEC.fieldOf("slots").forGetter(Randomizer::slots), + IntProvider.CODEC.optionalFieldOf("luck_bias", ConstantInt.ZERO).forGetter(Randomizer::luckBias), + ).apply(it, ::Randomizer) + } + ) } } } 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 f79daf008..8ded60070 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 @@ -242,7 +242,7 @@ class NetworkedItemView(val ply: Player, val menu: MatteryMenu, val isRemote: Bo fun network() { check(!isRemote) { "Not a server" } - val consumer = PacketDistributor.PLAYER.with(ply as ServerPlayer) + val consumer = PacketDistributor.PLAYER.with { ply as ServerPlayer } for (packet in networkBacklog) { MenuNetworkChannel.send(consumer, packet) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterEntanglerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterEntanglerMenu.kt index 7b3884ee5..3c672c57d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterEntanglerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterEntanglerMenu.kt @@ -13,6 +13,7 @@ import ru.dbotthepony.mc.otm.container.ShadowCraftingContainer import ru.dbotthepony.mc.otm.container.get import ru.dbotthepony.mc.otm.container.set import ru.dbotthepony.mc.otm.core.isNotEmpty +import ru.dbotthepony.mc.otm.core.value import ru.dbotthepony.mc.otm.item.IQuantumLinked import ru.dbotthepony.mc.otm.menu.OutputSlot import ru.dbotthepony.mc.otm.menu.MatteryMenu diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt index ab054cf1d..c51eba132 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt @@ -123,11 +123,11 @@ object GenericNetworkChannel : MatteryNetworkChannel( name = "generic" ) { fun makeSmoke(x: Double, y: Double, z: Double, level: Level) { - send(PacketDistributor.NEAR.with(PacketDistributor.TargetPoint(x, y, z, 64.0, level.dimension())), SmokeParticlesPacket(x, y, z)) + send(PacketDistributor.NEAR.with { PacketDistributor.TargetPoint(x, y, z, 64.0, level.dimension()) }, SmokeParticlesPacket(x, y, z)) } fun makeSmoke(excluded: ServerPlayer, x: Double, y: Double, z: Double) { - send(PacketDistributor.NEAR.with(PacketDistributor.TargetPoint(excluded, x, y, z, 64.0, excluded.level().dimension())), SmokeParticlesPacket(x, y, z)) + send(PacketDistributor.NEAR.with { PacketDistributor.TargetPoint(excluded, x, y, z, 64.0, excluded.level().dimension()) }, SmokeParticlesPacket(x, y, z)) } fun register() { 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 a8dc68f98..4f512b37a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt @@ -42,6 +42,7 @@ interface IMatterEntanglerRecipe : IMatteryRecipe { } open class MatterEntanglerRecipe( + val id: ResourceLocation, override val ingredients: IIngredientMatrix, override val matter: Decimal, override val ticks: Double, @@ -50,6 +51,10 @@ open class MatterEntanglerRecipe( val uuidKey: String = "uuid", val fixedUuid: Optional = Optional.empty() ) : IMatterEntanglerRecipe { + override fun getId(): ResourceLocation { + return id + } + override fun matches(container: CraftingContainer, level: Level): Boolean { if (isIncomplete) return false return ingredients.test(container) @@ -98,8 +103,8 @@ open class MatterEntanglerRecipe( return ItemStack(MItems.MATTER_ENTANGLER) } - fun toFinished(id: ResourceLocation): FinishedRecipe { - return SERIALIZER.toFinished(this, id) + fun toFinished(): FinishedRecipe { + return SERIALIZER.toFinished(this) } fun energetic() = Energy(this) @@ -114,8 +119,8 @@ open class MatterEntanglerRecipe( } } - fun toFinished(id: ResourceLocation): FinishedRecipe { - return ENERGY_SERIALIZER.toFinished(this, id) + fun toFinished(): FinishedRecipe { + return ENERGY_SERIALIZER.toFinished(this) } override fun getSerializer(): RecipeSerializer<*> { @@ -132,8 +137,8 @@ open class MatterEntanglerRecipe( } } - fun toFinished(id: ResourceLocation): FinishedRecipe { - return MATTER_SERIALIZER.toFinished(this, id) + fun toFinished(): FinishedRecipe { + return MATTER_SERIALIZER.toFinished(this) } override fun getSerializer(): RecipeSerializer<*> { @@ -152,7 +157,7 @@ open class MatterEntanglerRecipe( 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) - ).apply(it, ::MatterEntanglerRecipe) + ).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/MatteryCookingRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatteryCookingRecipe.kt index 57d4646de..ca1a3cea3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatteryCookingRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatteryCookingRecipe.kt @@ -24,12 +24,17 @@ import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRecipes abstract class MatteryCookingRecipe( + val id: ResourceLocation, val input: Ingredient, val output: Ingredient, val count: Int = 1, val workTime: Int = 200, val experience: FloatProvider = ConstantFloat.ZERO ) : Recipe { + override fun getId(): ResourceLocation { + return id + } + override fun matches(container: Container, level: Level): Boolean { if (isIncomplete) return false @@ -69,20 +74,21 @@ abstract class MatteryCookingRecipe( override fun getResultItem(registry: RegistryAccess): ItemStack = outputStack - abstract fun toFinished(id: ResourceLocation): FinishedRecipe + abstract fun toFinished(): FinishedRecipe } class MicrowaveRecipe( + id: ResourceLocation, input: Ingredient, output: Ingredient, count: Int = 1, workTime: Int = 200, experience: FloatProvider = ConstantFloat.ZERO -) : MatteryCookingRecipe(input, output, count, workTime, experience) { +) : MatteryCookingRecipe(id, input, output, count, workTime, experience) { override fun getType(): RecipeType<*> = MRecipes.MICROWAVE override fun getToastSymbol(): ItemStack = ItemStack(MItems.POWERED_SMOKER) override fun getSerializer(): RecipeSerializer<*> = SERIALIZER - override fun toFinished(id: ResourceLocation): FinishedRecipe = SERIALIZER.toFinished(this, id) + override fun toFinished(): FinishedRecipe = SERIALIZER.toFinished(this) companion object { val SERIALIZER = Codec2RecipeSerializer { context -> @@ -93,7 +99,7 @@ class MicrowaveRecipe( Codec.INT.minRange(1).optionalFieldOf("count", 1).forGetter(MicrowaveRecipe::count), Codec.INT.minRange(0).optionalFieldOf("workTime", 200).forGetter(MicrowaveRecipe::workTime), FloatProvider.CODEC.optionalFieldOf("experience", ConstantFloat.ZERO).forGetter(MicrowaveRecipe::experience) - ).apply(it, ::MicrowaveRecipe) + ).apply(it) { a, b, c, d, e -> MicrowaveRecipe(context.id, a, b, c, d, e) } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MFluids.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MFluids.kt index d42923a95..d6e2bfe01 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MFluids.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MFluids.kt @@ -15,7 +15,7 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters import java.util.function.Consumer object MFluids { - private val types: DeferredRegister = DeferredRegister.create(ForgeRegistries.FLUID_TYPES, OverdriveThatMatters.MOD_ID) + private val types: DeferredRegister = DeferredRegister.create(ForgeRegistries.Keys.FLUID_TYPES, OverdriveThatMatters.MOD_ID) private val fluids: DeferredRegister = DeferredRegister.create(ForgeRegistries.FLUIDS, OverdriveThatMatters.MOD_ID) internal fun register(bus: IEventBus) { 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 0081a28ac..ad46b96a6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MLootItemConditions.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MLootItemConditions.kt @@ -6,6 +6,7 @@ import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.registries.DeferredRegister import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.data.Codec2Serializer import ru.dbotthepony.mc.otm.data.SingletonCodec import ru.dbotthepony.mc.otm.data.condition.ChanceWithPlaytimeCondition import ru.dbotthepony.mc.otm.data.condition.HasExoPackCondition @@ -17,12 +18,12 @@ import ru.dbotthepony.mc.otm.data.condition.ChanceCondition object MLootItemConditions { private val registry = DeferredRegister.create(Registries.LOOT_CONDITION_TYPE, OverdriveThatMatters.MOD_ID) - val HAS_EXOPACK: LootItemConditionType by registry.register("has_exopack") { LootItemConditionType(SingletonCodec(HasExoPackCondition)) } - val CHANCE_WITH_PLAYTIME: LootItemConditionType by registry.register("chance_with_playtime") { LootItemConditionType(ChanceWithPlaytimeCondition.CODEC) } - val ITEM_IN_INVENTORY: LootItemConditionType by registry.register("item_in_inventory") { LootItemConditionType(ItemInInventoryCondition.CODEC) } - val KILLED_BY_REAL_PLAYER: LootItemConditionType by registry.register("killed_by_real_player") { LootItemConditionType(SingletonCodec(KilledByRealPlayer)) } - val KILLED_BY_REAL_PLAYER_OR_INDIRECTLY: LootItemConditionType by registry.register("killed_by_real_player_or_indirectly") { LootItemConditionType(SingletonCodec(KilledByRealPlayerOrIndirectly)) } - val CHANCE: LootItemConditionType by registry.register("chance") { LootItemConditionType(ChanceCondition.CODEC) } + 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)) } + val ITEM_IN_INVENTORY: LootItemConditionType by registry.register("item_in_inventory") { LootItemConditionType(Codec2Serializer(ItemInInventoryCondition.CODEC)) } + val KILLED_BY_REAL_PLAYER: LootItemConditionType by registry.register("killed_by_real_player") { LootItemConditionType(Codec2Serializer(SingletonCodec(KilledByRealPlayer))) } + val KILLED_BY_REAL_PLAYER_OR_INDIRECTLY: LootItemConditionType by registry.register("killed_by_real_player_or_indirectly") { LootItemConditionType(Codec2Serializer(SingletonCodec(KilledByRealPlayerOrIndirectly))) } + val CHANCE: LootItemConditionType by registry.register("chance") { LootItemConditionType(Codec2Serializer(ChanceCondition.CODEC)) } internal fun register(bus: IEventBus) { registry.register(bus) 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 0555c6d59..715970109 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -297,28 +297,28 @@ object MRegistry { NanobotsArmorFeature.Companion EnderTeleporterFeature.Companion - CriteriaTriggers.register(BlackHoleTrigger.id.toString(), BlackHoleTrigger) - CriteriaTriggers.register(BecomeAndroidTrigger.id.toString(), BecomeAndroidTrigger) - CriteriaTriggers.register(BecomeAndroidDeathTrigger.id.toString(), BecomeAndroidDeathTrigger) - CriteriaTriggers.register(BecomeAndroidSleepTrigger.id.toString(), BecomeAndroidSleepTrigger) - CriteriaTriggers.register(BecomeHumaneTrigger.id.toString(), BecomeHumaneTrigger) - CriteriaTriggers.register(AndroidResearchTrigger.id.toString(), AndroidResearchTrigger) - CriteriaTriggers.register(ShockwaveDamageMobTrigger.id.toString(), ShockwaveDamageMobTrigger) - CriteriaTriggers.register(ShockwaveTrigger.id.toString(), ShockwaveTrigger) - CriteriaTriggers.register(AndroidBatteryTrigger.id.toString(), AndroidBatteryTrigger) - CriteriaTriggers.register(NanobotsArmorTrigger.id.toString(), NanobotsArmorTrigger) - CriteriaTriggers.register(FallDampenersSaveTrigger.id.toString(), FallDampenersSaveTrigger) - CriteriaTriggers.register(EnderTeleporterFallDeathTrigger.id.toString(), EnderTeleporterFallDeathTrigger) - CriteriaTriggers.register(KillAsAndroidTrigger.id.toString(), KillAsAndroidTrigger) - CriteriaTriggers.register(AndroidTravelUnderwater.id.toString(), AndroidTravelUnderwater) - CriteriaTriggers.register(NailedEntityTrigger.id.toString(), NailedEntityTrigger) - CriteriaTriggers.register(ExopackObtainedTrigger.id.toString(), ExopackObtainedTrigger) - CriteriaTriggers.register(ExopackGainedSmeltingTrigger.id.toString(), ExopackGainedSmeltingTrigger) - CriteriaTriggers.register(ExopackGainedCraftingTrigger.id.toString(), ExopackGainedCraftingTrigger) - CriteriaTriggers.register(ExopackGainedEnderAccessTrigger.id.toString(), ExopackGainedEnderAccessTrigger) - CriteriaTriggers.register(ExopackSlotsExpandedTrigger.id.toString(), ExopackSlotsExpandedTrigger) - CriteriaTriggers.register(ExopackBatterySlotTrigger.id.toString(), ExopackBatterySlotTrigger) - CriteriaTriggers.register(TakeItemOutOfReplicatorTrigger.id.toString(), TakeItemOutOfReplicatorTrigger) + CriteriaTriggers.register(BlackHoleTrigger) + CriteriaTriggers.register(BecomeAndroidTrigger) + CriteriaTriggers.register(BecomeAndroidDeathTrigger) + CriteriaTriggers.register(BecomeAndroidSleepTrigger) + CriteriaTriggers.register(BecomeHumaneTrigger) + CriteriaTriggers.register(AndroidResearchTrigger) + CriteriaTriggers.register(ShockwaveDamageMobTrigger) + CriteriaTriggers.register(ShockwaveTrigger) + CriteriaTriggers.register(AndroidBatteryTrigger) + CriteriaTriggers.register(NanobotsArmorTrigger) + CriteriaTriggers.register(FallDampenersSaveTrigger) + CriteriaTriggers.register(EnderTeleporterFallDeathTrigger) + CriteriaTriggers.register(KillAsAndroidTrigger) + CriteriaTriggers.register(AndroidTravelUnderwater) + CriteriaTriggers.register(NailedEntityTrigger) + CriteriaTriggers.register(ExopackObtainedTrigger) + CriteriaTriggers.register(ExopackGainedSmeltingTrigger) + CriteriaTriggers.register(ExopackGainedCraftingTrigger) + CriteriaTriggers.register(ExopackGainedEnderAccessTrigger) + CriteriaTriggers.register(ExopackSlotsExpandedTrigger) + CriteriaTriggers.register(ExopackBatterySlotTrigger) + CriteriaTriggers.register(TakeItemOutOfReplicatorTrigger) } private fun initializeCommon(event: FMLCommonSetupEvent) { From 98fcacc9a8126e5db6cb89d7489b2dca683ac387 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 31 Dec 2023 21:14:32 +0700 Subject: [PATCH 1153/1199] More backporting --- .../mc/otm/compat/jei/JEIPlugin.kt | 1 + .../mc/otm/item/QuantumBatteryItem.kt | 2 -- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 10 +++--- .../mc/otm/recipe/PainterRecipe.kt | 31 ++++++++++++------- .../mc/otm/recipe/PlatePressRecipe.kt | 9 ++++-- .../triggers/MatteryInventoryChangeTrigger.kt | 15 ++++++--- .../resources/META-INF/accesstransformer.cfg | 9 ++++++ 7 files changed, 53 insertions(+), 24 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt index 354c4346f..1a654f7c7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt @@ -25,6 +25,7 @@ import ru.dbotthepony.mc.otm.core.collect.filterIsInstance import ru.dbotthepony.mc.otm.core.collect.filterNotNull import ru.dbotthepony.mc.otm.core.collect.map import ru.dbotthepony.mc.otm.core.collect.toList +import ru.dbotthepony.mc.otm.core.value import ru.dbotthepony.mc.otm.menu.decorative.PainterMenu import ru.dbotthepony.mc.otm.menu.matter.MatterEntanglerMenu import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu 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 ee6762534..ab27241bd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt @@ -30,10 +30,8 @@ import ru.dbotthepony.mc.otm.capability.energy.getBarColor import ru.dbotthepony.mc.otm.capability.energy.getBarWidth import ru.dbotthepony.mc.otm.capability.matteryEnergy import ru.dbotthepony.mc.otm.config.EnergyBalanceValues -import ru.dbotthepony.mc.otm.core.Factory import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.collect.filter -import ru.dbotthepony.mc.otm.core.computeIfAbsent 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/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 387ace84b..b2fcf7d17 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -297,9 +297,10 @@ abstract class MatteryMenu( open inner class EquipmentSlot(container: Container, index: Int, val type: net.minecraft.world.entity.EquipmentSlot) : InventorySlot(container, index) { constructor(type: net.minecraft.world.entity.EquipmentSlot) : this(inventory, 34 + type.ordinal, type) - override fun setByPlayer(newItem: ItemStack, oldItem: ItemStack) { + override fun setByPlayer(newItem: ItemStack) { + val oldItem = item inventory.player.onEquipItem(type, oldItem, newItem) - super.setByPlayer(newItem, oldItem) + super.setByPlayer(newItem) } override fun mayPlace(itemStack: ItemStack): Boolean { @@ -326,9 +327,10 @@ abstract class MatteryMenu( autoCreateInventoryFrame = autoFrame offhandSlot = object : InventorySlot(inventory, 40) { - override fun setByPlayer(newItem: ItemStack, oldItem: ItemStack) { + override fun setByPlayer(newItem: ItemStack) { + val oldItem = this.item inventory.player.onEquipItem(net.minecraft.world.entity.EquipmentSlot.OFFHAND, oldItem, newItem) - super.setByPlayer(newItem, oldItem) + super.setByPlayer(newItem) } override fun getNoItemIcon(): Pair { 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 bc89e7f34..a9a5cbcee 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt @@ -31,8 +31,13 @@ import ru.dbotthepony.mc.otm.registry.MRecipes import java.util.function.Predicate abstract class AbstractPainterRecipe( + val id: ResourceLocation, dyes: Map ) : IMatteryRecipe { + override fun getId(): ResourceLocation { + return id + } + val dyes: Object2IntMap = Object2IntMaps.unmodifiable(Object2IntArrayMap(dyes)) abstract fun matches(value: ItemStack): Boolean @@ -106,15 +111,17 @@ abstract class AbstractPainterRecipe( } class PainterRecipe( + id: ResourceLocation, val input: Ingredient, val output: ItemStack, dyes: Map -) : AbstractPainterRecipe(dyes) { +) : AbstractPainterRecipe(id, dyes) { constructor( + id: ResourceLocation, input: Ingredient, output: ItemStack, dyes: Set - ) : this(input, output, Object2IntArrayMap().also { map -> dyes.forEach { map[it] = 1 } }) + ) : this(id, input, output, Object2IntArrayMap().also { map -> dyes.forEach { map[it] = 1 } }) override fun matches(value: ItemStack): Boolean { return !isIncomplete && input.test(value) @@ -154,8 +161,8 @@ class PainterRecipe( return MRecipes.PAINTER } - fun toFinished(id: ResourceLocation): FinishedRecipe { - return SERIALIZER.toFinished(this, id) + fun toFinished(): FinishedRecipe { + return SERIALIZER.toFinished(this) } override fun getOutput(container: Container): ItemStack { @@ -169,17 +176,19 @@ class PainterRecipe( context.ingredients.fieldOf("input").forGetter(PainterRecipe::input), ItemStack.CODEC.fieldOf("output").forGetter(PainterRecipe::output), dyesFieldCodec.forGetter(AbstractPainterRecipe::dyes), - ).apply(it, ::PainterRecipe) + ).apply(it) { a, b, c -> PainterRecipe(context.id, a, b, c) } } } } } class PainterArmorDyeRecipe( + id: ResourceLocation, dyes: Map -) : AbstractPainterRecipe(dyes) { +) : AbstractPainterRecipe(id, dyes) { constructor( + id: ResourceLocation, dyes: Set - ) : this(Object2IntArrayMap().also { map -> dyes.forEach { map[it] = 1 } }) + ) : this(id, Object2IntArrayMap().also { map -> dyes.forEach { map[it] = 1 } }) override fun matches(value: ItemStack): Boolean { return !isIncomplete && value.item is DyeableArmorItem @@ -207,8 +216,8 @@ class PainterArmorDyeRecipe( override fun isIncomplete(): Boolean = dyes.isEmpty() - fun toFinished(id: ResourceLocation): FinishedRecipe { - return SERIALIZER.toFinished(this, id) + fun toFinished(): FinishedRecipe { + return SERIALIZER.toFinished(this) } override fun getOutput(container: Container): ItemStack { @@ -228,11 +237,11 @@ class PainterArmorDyeRecipe( } companion object { - val SERIALIZER = Codec2RecipeSerializer { _ -> + val SERIALIZER = Codec2RecipeSerializer { context -> RecordCodecBuilder.create { it.group( dyesFieldCodec.forGetter(AbstractPainterRecipe::dyes), - ).apply(it, ::PainterArmorDyeRecipe) + ).apply(it) { a -> PainterArmorDyeRecipe(context.id, a) } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt index aca5daf14..a5dd1c85e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt @@ -24,12 +24,17 @@ import ru.dbotthepony.mc.otm.data.minRange import ru.dbotthepony.mc.otm.registry.MItems class PlatePressRecipe( + val id: ResourceLocation, val input: Ingredient, val output: Ingredient, val count: Int = 1, val workTime: Int = 200, val experience: FloatProvider = ConstantFloat.ZERO ) : Recipe { + override fun getId(): ResourceLocation { + return id + } + override fun matches(container: Container, p_44003_: Level): Boolean { if (isIncomplete) return false @@ -79,7 +84,7 @@ class PlatePressRecipe( return ItemStack(MItems.PLATE_PRESS) } - fun toFinished(id: ResourceLocation) = SERIALIZER.toFinished(this, id) + fun toFinished() = SERIALIZER.toFinished(this) companion object { val SERIALIZER = Codec2RecipeSerializer { context -> @@ -90,7 +95,7 @@ class PlatePressRecipe( Codec.INT.minRange(1).optionalFieldOf("count", 1).forGetter(PlatePressRecipe::count), Codec.INT.minRange(0).optionalFieldOf("workTime", 200).forGetter(PlatePressRecipe::workTime), FloatProvider.CODEC.optionalFieldOf("experience", ConstantFloat.ZERO).forGetter(PlatePressRecipe::experience) - ).apply(it, ::PlatePressRecipe) + ).apply(it) { a, b, c, d, e -> PlatePressRecipe(context.id, a, b, c, d, e) } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MatteryInventoryChangeTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MatteryInventoryChangeTrigger.kt index c3064c2fa..4b7f4564e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MatteryInventoryChangeTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MatteryInventoryChangeTrigger.kt @@ -14,6 +14,7 @@ import net.minecraft.advancements.CriterionTrigger import net.minecraft.advancements.critereon.DeserializationContext import net.minecraft.advancements.critereon.InventoryChangeTrigger import net.minecraft.advancements.critereon.MinMaxBounds +import net.minecraft.resources.ResourceLocation import net.minecraft.server.PlayerAdvancements import net.minecraft.server.level.ServerPlayer import net.minecraft.world.Container @@ -83,13 +84,13 @@ object MatteryInventoryChangeTrigger : CriterionTrigger v == null || item.item == v }, { inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> mutableListOf(item.item) })) nodes.add(Node( DefaultStrategy, - { predicates.map { it.tag.orElse(null) } }, + { predicates.map { it.tag } }, { v, inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> v == null || item.`is`(v) }, { inventory: Container, item: ItemStack, slotsFull: Int, slotsEmpty: Int, slotsOccupied: Int -> item.tags.collect(Collectors.toCollection(::ArrayList)) })) @@ -133,13 +134,13 @@ object MatteryInventoryChangeTrigger : CriterionTrigger) { if (set.add(listener)) { - search(listener.trigger, tree, 0).forEach { it.add(listener) } + search(listener.triggerInstance, tree, 0).forEach { it.add(listener) } } } fun remove(listener: CriterionTrigger.Listener) { if (set.remove(listener)) { - search(listener.trigger, tree, 0).forEach { it.remove(listener) } + search(listener.triggerInstance, tree, 0).forEach { it.remove(listener) } } } @@ -165,7 +166,7 @@ object MatteryInventoryChangeTrigger : CriterionTrigger>) { // переделываем matches у InventoryTriggerInstance - with (l.trigger) { + with (l.triggerInstance) { if ( this.slotsFull.matches(slotsFull) && this.slotsEmpty.matches(slotsEmpty) && @@ -217,6 +218,10 @@ object MatteryInventoryChangeTrigger : CriterionTrigger Date: Sun, 31 Dec 2023 21:40:54 +0700 Subject: [PATCH 1154/1199] More backporting --- .../screen/panels/EntityRendererPanel.kt | 12 +++++----- .../ru/dbotthepony/mc/otm/data/Codecs.kt | 22 ++++++++++++++----- .../mc/otm/triggers/NanobotsArmorTrigger.kt | 3 ++- .../resources/META-INF/accesstransformer.cfg | 6 +++++ 4 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt index 10f1dd8e8..c8dc31551 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt @@ -170,14 +170,16 @@ class EntityRendererPanel @JvmOverloads constructor( return } + val renderX = width.toInt() / 2 + val renderY = (height * 0.9f).toInt() + InventoryScreen.renderEntityInInventoryFollowsMouse( graphics, - 0, 0, - this.width.toInt(), this.height.toInt(), + renderX, + renderY, renderScale, - 0f, - mouseX - absoluteX.toInt(), - mouseY - absoluteY + height * 0.15f, + absoluteX.toInt() + renderX - mouseX, + absoluteY + height * 0.15f - mouseY, entity ) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codecs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codecs.kt index 6b4f17f3b..d7e90cc59 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codecs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codecs.kt @@ -1,29 +1,39 @@ package ru.dbotthepony.mc.otm.data import com.mojang.serialization.Codec +import com.mojang.serialization.DataResult import com.mojang.serialization.Dynamic +import com.mojang.serialization.DynamicOps import com.mojang.serialization.JsonOps import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.advancements.critereon.DamagePredicate import net.minecraft.advancements.critereon.DamageSourcePredicate import net.minecraft.advancements.critereon.EntityPredicate import net.minecraft.advancements.critereon.MinMaxBounds +import java.util.Optional import kotlin.reflect.KProperty1 +val DoublesCodec: Codec = RecordCodecBuilder.create { + it.group( + Codec.DOUBLE.optionalFieldOf("min").forGetter { Optional.ofNullable(it.min) }, + Codec.DOUBLE.optionalFieldOf("max").forGetter { Optional.ofNullable(it.max) }, + ).apply(it) { a, b -> MinMaxBounds.Doubles.between(a.orElse(null), b.orElse(null)) } +} + private val dealtReceived: Codec> = RecordCodecBuilder.create { it.group( - MinMaxBounds.Doubles.CODEC.fieldOf("dealt").forGetter { it.first }, - MinMaxBounds.Doubles.CODEC.fieldOf("taken").forGetter { it.second }, + DoublesCodec.fieldOf("dealt").forGetter { it.first }, + DoublesCodec.fieldOf("taken").forGetter { it.second }, ).apply(it, ::Pair) } val DamagePredicateCodec: Codec = RecordCodecBuilder.create { it.group( dealtReceived.fieldOf("damage").forGetter { it.dealtDamage to it.takenDamage }, - Codec.BOOL.optionalFieldOf("blocked").forGetter { it.blocked }, - EntityPredicate.CODEC.optionalFieldOf("source_entity").forGetter { it.sourceEntity }, - DamageSourcePredicate.CODEC.optionalFieldOf("type").forGetter { it.type }, - ).apply(it) { damage, blocked, source, type -> DamagePredicate(damage.first, damage.second, source, blocked, type) } + Codec.BOOL.optionalFieldOf("blocked").forGetter { Optional.ofNullable(it.blocked) }, + Codec.PASSTHROUGH.xmap({ EntityPredicate.fromJson(it.cast(JsonOps.INSTANCE)) }, { Dynamic(JsonOps.INSTANCE, it.serializeToJson()) }).fieldOf("source_entity").forGetter { it.sourceEntity }, + Codec.PASSTHROUGH.xmap({ DamageSourcePredicate.fromJson(it.cast(JsonOps.INSTANCE)) }, { Dynamic(JsonOps.INSTANCE, it.serializeToJson()) }).fieldOf("type").forGetter { it.type }, + ).apply(it) { damage, blocked, source, type -> DamagePredicate(damage.first, damage.second, source, blocked.orElse(null), type) } } fun simpleCodec(factory: (T1) -> V, field1: KProperty1, codec1: Codec): Codec { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NanobotsArmorTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NanobotsArmorTrigger.kt index 9c290969e..6ad2e65c6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NanobotsArmorTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NanobotsArmorTrigger.kt @@ -7,12 +7,13 @@ import net.minecraft.advancements.critereon.MinMaxBounds.Doubles import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.data.DoublesCodec import java.util.* object NanobotsArmorTrigger : MCriterionTrigger(ResourceLocation(OverdriveThatMatters.MOD_ID, "nanobots_armor")) { override val codec: Codec = RecordCodecBuilder.create { it.group( - Doubles.CODEC.fieldOf("predicate").forGetter(Instance::predicate), + DoublesCodec.fieldOf("predicate").forGetter(Instance::predicate), playerPredicateCodec.forGetter(Instance::playerPredicate), ).apply(it, ::Instance) } diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index f500880b3..86504a276 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -179,3 +179,9 @@ public net.minecraft.advancements.critereon.ItemPredicate f_45036_ public net.minecraft.advancements.critereon.ItemPredicate f_45035_ public net.minecraft.advancements.critereon.ItemPredicate f_45034_ public net.minecraft.advancements.critereon.ItemPredicate f_45029_ + +public net.minecraft.advancements.critereon.DamagePredicate f_24906_ # blocked +public net.minecraft.advancements.critereon.DamagePredicate f_24903_ # dealtDamage +public net.minecraft.advancements.critereon.DamagePredicate f_24905_ # sourceEntity +public net.minecraft.advancements.critereon.DamagePredicate f_24904_ # takenDamage +public net.minecraft.advancements.critereon.DamagePredicate f_24907_ # type From 347be35184470dd8aca15dbe97acd06ccafb88a8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 31 Dec 2023 22:07:28 +0700 Subject: [PATCH 1155/1199] Make main source set compile --- .../mc/otm/data/Codec2RecipeSerializer.kt | 3 ++ .../mc/otm/data/RecipeWrapperCodec.kt | 54 +++++++++++++++++++ .../mc/otm/item/FluidCapsuleItem.kt | 2 +- .../mc/otm/recipe/EnergyContainerRecipe.kt | 14 +++-- .../recipe/ExplosiveHammerPrimingRecipe.kt | 2 +- .../mc/otm/recipe/MatterEntanglerRecipe.kt | 2 +- .../mc/otm/recipe/MatteryCookingRecipe.kt | 2 +- .../mc/otm/recipe/PainterRecipe.kt | 2 +- .../mc/otm/recipe/PlatePressRecipe.kt | 2 +- .../mc/otm/recipe/UpgradeRecipe.kt | 44 +++++++-------- .../mc/otm/triggers/MCriterionTrigger.kt | 2 +- 11 files changed, 89 insertions(+), 40 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/data/RecipeWrapperCodec.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt index d2e04238e..c577e9eb8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt @@ -39,6 +39,9 @@ class Codec2RecipeSerializer>( get() = checkNotNull(context.idStack.lastOrNull()) { "Not currently deserializing recipe" } val ingredients: Codec get() = ActualIngredientCodec + + val isNetwork: Boolean + get() = context.isNetwork > 0 } private val codec = codec.invoke(Context()) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/RecipeWrapperCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/RecipeWrapperCodec.kt new file mode 100644 index 000000000..7374cd200 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/RecipeWrapperCodec.kt @@ -0,0 +1,54 @@ +package ru.dbotthepony.mc.otm.data + +import com.google.gson.JsonNull +import com.google.gson.JsonObject +import com.mojang.datafixers.util.Pair +import com.mojang.serialization.Codec +import com.mojang.serialization.DataResult +import com.mojang.serialization.DynamicOps +import com.mojang.serialization.JsonOps +import io.netty.buffer.UnpooledByteBufAllocator +import net.minecraft.network.FriendlyByteBuf +import net.minecraft.resources.ResourceLocation +import net.minecraft.world.item.crafting.Recipe +import net.minecraft.world.item.crafting.RecipeSerializer +import ru.dbotthepony.mc.otm.core.set +import java.nio.ByteBuffer + +data class RecipePair>(val recipe: R, val data: JsonObject) + +fun > RecipeSerializer.codec(context: Codec2RecipeSerializer<*>.Context): Codec> { + return object : Codec> { + override fun encode(input: RecipePair, ops: DynamicOps, prefix: T): DataResult { + if (context.isNetwork) { + val buffer = FriendlyByteBuf(UnpooledByteBufAllocator.DEFAULT.heapBuffer()) + buffer.writeResourceLocation(input.recipe.id) + toNetwork(buffer, input.recipe) + buffer.writerIndex(0) + buffer.readerIndex(0) + val array = ByteBuffer.allocate(buffer.readableBytes()) + buffer.readBytes(array) + array.position(0) + return DataResult.success(ops.createByteList(array)) + } else { + return DataResult.success(JsonOps.INSTANCE.convertTo(ops, JsonObject().also { it["id"] = input.recipe.id.toString(); it["recipe"] = input.data })) + } + } + + override fun decode(ops: DynamicOps, input: T): DataResult, T>> { + if (context.isNetwork) { + return ops.getByteBuffer(input).map { + it.position(0) + val buffer = FriendlyByteBuf(UnpooledByteBufAllocator.DEFAULT.heapBuffer()) + buffer.writeBytes(it) + buffer.writerIndex(0) + buffer.readerIndex(0) + Pair(RecipePair(fromNetwork(buffer.readResourceLocation(), buffer)!!, JsonObject()), ops.empty()) + } + } else { + val getJson = ops.convertTo(JsonOps.INSTANCE, input) as JsonObject + return DataResult.success(Pair(RecipePair(fromJson(ResourceLocation(getJson["id"].asString), getJson["recipe"] as JsonObject), getJson["recipe"] as JsonObject), ops.empty())) + } + } + } +} 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 782884378..d41260d93 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt @@ -106,7 +106,7 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6 actionResult.result } else { val state = level.getBlockState(hitPos) - val placePos = if (state.block is LiquidBlockContainer && (state.block as LiquidBlockContainer).canPlaceLiquid(player, level, hitPos, state, fluid.fluid)) hitPos else nextPos + val placePos = if (state.block is LiquidBlockContainer && (state.block as LiquidBlockContainer).canPlaceLiquid(level, hitPos, state, fluid.fluid)) hitPos else nextPos val actionResult = FluidUtil.tryPlaceFluid(player, level, hand, placePos, targetItem, fluid) if (!actionResult.isSuccess) return InteractionResultHolder.pass(item) 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 9f3667807..6541d8ab9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/EnergyContainerRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/EnergyContainerRecipe.kt @@ -1,9 +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 @@ -99,16 +101,12 @@ class EnergyContainerRecipe(val parent: ShapedRecipe) : CraftingRecipe, IShapedR } companion object : RecipeSerializer { - private val codec by lazy { - RecipeSerializer.SHAPED_RECIPE.codec().xmap(::EnergyContainerRecipe, EnergyContainerRecipe::parent) + override fun fromNetwork(id: ResourceLocation, data: FriendlyByteBuf): EnergyContainerRecipe? { + return ShapedRecipe.Serializer.SHAPED_RECIPE.fromNetwork(id, data)?.let(::EnergyContainerRecipe) } - override fun codec(): Codec { - return codec - } - - override fun fromNetwork(data: FriendlyByteBuf): EnergyContainerRecipe? { - return ShapedRecipe.Serializer.SHAPED_RECIPE.fromNetwork(data)?.let(::EnergyContainerRecipe) + override fun fromJson(p_44103_: ResourceLocation, p_44104_: JsonObject): EnergyContainerRecipe { + return EnergyContainerRecipe(ShapedRecipe.Serializer.SHAPED_RECIPE.fromJson(p_44103_, p_44104_)) } override fun toNetwork(buff: FriendlyByteBuf, value: EnergyContainerRecipe) { 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 5349dc5f7..b713fb6b0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/ExplosiveHammerPrimingRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/ExplosiveHammerPrimingRecipe.kt @@ -19,7 +19,7 @@ import ru.dbotthepony.mc.otm.data.Codec2RecipeSerializer import ru.dbotthepony.mc.otm.item.tool.ExplosiveHammerItem import ru.dbotthepony.mc.otm.registry.MItems -class ExplosiveHammerPrimingRecipe(val payload: Ingredient, val id: ResourceLocation) : CraftingRecipe { +class ExplosiveHammerPrimingRecipe(val payload: Ingredient, private val id: ResourceLocation) : CraftingRecipe { override fun getId(): ResourceLocation { return id } 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 4f512b37a..aa0633bbd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt @@ -42,7 +42,7 @@ interface IMatterEntanglerRecipe : IMatteryRecipe { } open class MatterEntanglerRecipe( - val id: ResourceLocation, + private val id: ResourceLocation, override val ingredients: IIngredientMatrix, override val matter: Decimal, override val ticks: Double, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatteryCookingRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatteryCookingRecipe.kt index ca1a3cea3..22aeea670 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatteryCookingRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatteryCookingRecipe.kt @@ -24,7 +24,7 @@ import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRecipes abstract class MatteryCookingRecipe( - val id: ResourceLocation, + private val id: ResourceLocation, val input: Ingredient, val output: Ingredient, val count: Int = 1, 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 a9a5cbcee..8fff7cc78 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt @@ -31,7 +31,7 @@ import ru.dbotthepony.mc.otm.registry.MRecipes import java.util.function.Predicate abstract class AbstractPainterRecipe( - val id: ResourceLocation, + private val id: ResourceLocation, dyes: Map ) : IMatteryRecipe { override fun getId(): ResourceLocation { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt index a5dd1c85e..143d7cd1d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt @@ -24,7 +24,7 @@ import ru.dbotthepony.mc.otm.data.minRange import ru.dbotthepony.mc.otm.registry.MItems class PlatePressRecipe( - val id: ResourceLocation, + private val id: ResourceLocation, val input: Ingredient, val output: Ingredient, val count: Int = 1, 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 c5f969c7a..a946509eb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt @@ -1,16 +1,12 @@ package ru.dbotthepony.mc.otm.recipe import com.google.common.collect.ImmutableList -import com.google.gson.JsonObject -import com.google.gson.JsonPrimitive 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.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation -import net.minecraft.util.GsonHelper import net.minecraft.util.StringRepresentable import net.minecraft.world.inventory.CraftingContainer import net.minecraft.world.item.ItemStack @@ -25,67 +21,65 @@ import net.minecraftforge.common.crafting.IShapedRecipe import ru.dbotthepony.mc.otm.container.util.stream import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.core.registryName -import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.core.tagNotNull -import ru.dbotthepony.mc.otm.core.util.readBinaryJson -import ru.dbotthepony.mc.otm.core.util.writeBinaryJson -import ru.dbotthepony.mc.otm.core.collect.stream import ru.dbotthepony.mc.otm.data.Codec2RecipeSerializer +import ru.dbotthepony.mc.otm.data.RecipePair +import ru.dbotthepony.mc.otm.data.codec import java.util.stream.Stream class UpgradeRecipe( - val parent: ShapedRecipe, + val parent: RecipePair, copyPaths: Stream, val source: ResourceLocation, -) : CraftingRecipe, IShapedRecipe by parent { - constructor(parent: ShapedRecipe, copyPaths: Collection, source: ResourceLocation) : this(parent, copyPaths.stream(), source) +) : CraftingRecipe, IShapedRecipe by parent.recipe { + constructor(parent: RecipePair, copyPaths: Collection, source: ResourceLocation) : this(parent, copyPaths.stream(), source) override fun matches(p_44002_: CraftingContainer, p_44003_: Level): Boolean { - return parent.matches(p_44002_, p_44003_) + return parent.recipe.matches(p_44002_, p_44003_) } override fun canCraftInDimensions(p_43999_: Int, p_44000_: Int): Boolean { - return parent.canCraftInDimensions(p_43999_, p_44000_) + return parent.recipe.canCraftInDimensions(p_43999_, p_44000_) } override fun getResultItem(p_267052_: RegistryAccess): ItemStack { - return parent.getResultItem(p_267052_) + return parent.recipe.getResultItem(p_267052_) } override fun getRemainingItems(p_44004_: CraftingContainer): NonNullList { - return parent.getRemainingItems(p_44004_) + return parent.recipe.getRemainingItems(p_44004_) } override fun getIngredients(): NonNullList { - return parent.ingredients + return parent.recipe.ingredients } override fun isSpecial(): Boolean { - return parent.isSpecial + return parent.recipe.isSpecial } override fun showNotification(): Boolean { - return parent.showNotification() + return parent.recipe.showNotification() } override fun getGroup(): String { - return parent.group + return parent.recipe.group } override fun getToastSymbol(): ItemStack { - return parent.toastSymbol + return parent.recipe.toastSymbol } override fun isIncomplete(): Boolean { - return parent.isIncomplete + return parent.recipe.isIncomplete } override fun getType(): RecipeType<*> { - return parent.type + return parent.recipe.type } override fun category(): CraftingBookCategory { - return parent.category() + return parent.recipe.category() } enum class OpType : StringRepresentable { @@ -191,7 +185,7 @@ class UpgradeRecipe( val copyPaths: ImmutableList = copyPaths.collect(ImmutableList.toImmutableList()) override fun assemble(pInv: CraftingContainer, registryAccess: RegistryAccess): ItemStack { - val result = parent.assemble(pInv, registryAccess) + val result = parent.recipe.assemble(pInv, registryAccess) if (result.isEmpty) { return result @@ -225,7 +219,7 @@ class UpgradeRecipe( val CODEC = Codec2RecipeSerializer { p -> RecordCodecBuilder.create { it.group( - p.wrap(ShapedRecipe.Serializer.SHAPED_RECIPE).fieldOf("parent").forGetter(UpgradeRecipe::parent), + ShapedRecipe.Serializer.SHAPED_RECIPE.codec(p).fieldOf("parent").forGetter(UpgradeRecipe::parent), COPY_PATHS_CODEC.fieldOf("copyPaths").forGetter(UpgradeRecipe::copyPaths), ResourceLocation.CODEC.fieldOf("source").forGetter(UpgradeRecipe::source) ).apply(it, ::UpgradeRecipe) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt index f422251f6..7a6eb77ef 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt @@ -30,7 +30,7 @@ import java.util.function.Predicate // allows to support both 1.20.1 and 1.20.2 with ease // and has slightly less memory footprint than vanilla SimpleCriterionTrigger -abstract class MCriterionTrigger.AbstractInstance>(val id: ResourceLocation) : CriterionTrigger { +abstract class MCriterionTrigger.AbstractInstance>(private val id: ResourceLocation) : CriterionTrigger { override fun getId(): ResourceLocation { return id } From 1803d687ab8941e9adcddadc54bc43f2b4655b62 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 31 Dec 2023 22:18:43 +0700 Subject: [PATCH 1156/1199] Make mod compile against 1.20.1 --- .../datagen/advancements/AdvancementData.kt | 5 ++-- .../advancements/AndroidAdvancementsData.kt | 2 -- .../advancements/ExopackAdvancementsData.kt | 3 -- .../mc/otm/datagen/advancements/Helpers.kt | 7 +++-- .../advancements/MachineAdvancementsData.kt | 4 ++- .../mc/otm/datagen/recipes/CookingRecipes.kt | 2 -- .../datagen/recipes/CraftingTableRecipes.kt | 5 +--- .../datagen/recipes/MachineUpgradeRecipes.kt | 1 - .../datagen/recipes/MatterEntanglerRecipes.kt | 7 +++-- .../mc/otm/datagen/recipes/MatteryRecipe.kt | 13 +++----- .../datagen/recipes/MatteryRecipeProvider.kt | 30 ++++++++----------- .../mc/otm/datagen/recipes/PainterRecipes.kt | 20 ++++++------- .../otm/datagen/recipes/ShapelessRecipes.kt | 5 +++- 13 files changed, 47 insertions(+), 57 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt index 0cd43924e..4513da0a9 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AdvancementData.kt @@ -1,9 +1,8 @@ package ru.dbotthepony.mc.otm.datagen.advancements -import net.minecraft.advancements.AdvancementHolder import net.minecraft.advancements.AdvancementRewards import net.minecraft.advancements.FrameType -import net.minecraft.advancements.AdvancementRequirements.Strategy +import net.minecraft.advancements.RequirementsStrategy import net.minecraft.advancements.critereon.InventoryChangeTrigger import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack @@ -17,6 +16,8 @@ import ru.dbotthepony.mc.otm.triggers.BlackHoleTrigger import ru.dbotthepony.mc.otm.triggers.NailedEntityTrigger import java.util.function.Consumer +typealias Strategy = RequirementsStrategy + fun addAdvancements(serializer: Consumer, lang: MatteryLanguageProvider) { val translation = lang.MultiBuilder("otm.advancements.regular") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt index 2a9ed3bdf..591f3a24e 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/AndroidAdvancementsData.kt @@ -1,7 +1,5 @@ package ru.dbotthepony.mc.otm.datagen.advancements -import net.minecraft.advancements.AdvancementHolder -import net.minecraft.advancements.AdvancementRequirements.Strategy import net.minecraft.advancements.AdvancementRewards import net.minecraft.advancements.FrameType import net.minecraft.advancements.critereon.EntityPredicate diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/ExopackAdvancementsData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/ExopackAdvancementsData.kt index 5e15965ce..8f228548e 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/ExopackAdvancementsData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/ExopackAdvancementsData.kt @@ -1,12 +1,9 @@ package ru.dbotthepony.mc.otm.datagen.advancements -import net.minecraft.advancements.Advancement -import net.minecraft.advancements.AdvancementHolder import net.minecraft.advancements.FrameType import net.minecraft.advancements.critereon.ItemPredicate import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items -import net.minecraftforge.common.data.ExistingFileHelper import ru.dbotthepony.mc.otm.datagen.lang.MatteryLanguageProvider import ru.dbotthepony.mc.otm.datagen.modLocation import ru.dbotthepony.mc.otm.registry.MItems diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/Helpers.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/Helpers.kt index 83a4eef59..0e999e52a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/Helpers.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/Helpers.kt @@ -16,6 +16,7 @@ import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.level.ItemLike import ru.dbotthepony.mc.otm.core.TextComponent +import java.util.function.Consumer fun AdvancementBuilder(): Advancement.Builder = Advancement.Builder.advancement() @@ -58,7 +59,7 @@ fun predicate(tag: TagKey): ItemPredicate { return ItemPredicate.Builder.item().of(tag).build() } -fun criterion(tag: TagKey): Criterion<*> { +fun criterion(tag: TagKey): CriterionTriggerInstance { return InventoryChangeTrigger.TriggerInstance.hasItems(predicate(tag)) } @@ -66,8 +67,10 @@ fun predicate(item: ItemLike): ItemPredicate { return ItemPredicate.Builder.item().of(item).build() } -fun criterion(item: ItemLike): Criterion<*> { +fun criterion(item: ItemLike): CriterionTriggerInstance { return InventoryChangeTrigger.TriggerInstance.hasItems(predicate(item)) } fun EntityPredicate.wrap(): ContextAwarePredicate = EntityPredicate.wrap(this) + +fun Advancement.Builder.save(advancement: Consumer, name: ResourceLocation) = save(advancement, name.toString()) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt index 36cdb7ff2..0181180fd 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/MachineAdvancementsData.kt @@ -1,6 +1,6 @@ package ru.dbotthepony.mc.otm.datagen.advancements -import net.minecraft.advancements.AdvancementHolder +import net.minecraft.advancements.Advancement import net.minecraft.advancements.FrameType import net.minecraft.advancements.critereon.ItemPredicate import net.minecraft.world.item.Item @@ -15,6 +15,8 @@ import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.triggers.TakeItemOutOfReplicatorTrigger import java.util.function.Consumer +typealias AdvancementHolder = Advancement + private data class CraftEntry( val item: Item, val englishName: String, diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CookingRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CookingRecipes.kt index c9e0e69b1..b1a73ef25 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CookingRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CookingRecipes.kt @@ -1,14 +1,12 @@ package ru.dbotthepony.mc.otm.datagen.recipes import net.minecraft.data.recipes.RecipeCategory -import net.minecraft.data.recipes.RecipeOutput import net.minecraft.data.recipes.SimpleCookingRecipeBuilder import net.minecraft.util.valueproviders.ConstantFloat import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.level.ItemLike -import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.datagen.modLocation import ru.dbotthepony.mc.otm.registry.MItemTags import ru.dbotthepony.mc.otm.registry.MItems diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index a7db8cd40..db790ea62 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -1,8 +1,6 @@ package ru.dbotthepony.mc.otm.datagen.recipes -import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.data.recipes.RecipeCategory -import net.minecraft.data.recipes.RecipeOutput import net.minecraft.data.recipes.ShapelessRecipeBuilder import net.minecraft.tags.ItemTags import net.minecraft.world.item.ItemStack @@ -18,7 +16,6 @@ import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.datagen.modLocation import ru.dbotthepony.mc.otm.recipe.ExplosiveHammerPrimingRecipe import ru.dbotthepony.mc.otm.recipe.UpgradeRecipe -import java.util.function.Consumer fun addCraftingTableRecipes(consumer: RecipeOutput) { val machinesCategory = RecipeCategory.DECORATIONS @@ -430,7 +427,7 @@ fun addCraftingTableRecipes(consumer: RecipeOutput) { .unlockedBy(MItemTags.TRITANIUM_INGOTS) .build(consumer) - consumer.accept(ExplosiveHammerPrimingRecipe(Ingredient.of(Tags.Items.NUGGETS_IRON)).toFinished(modLocation("hammer_priming"))) + consumer.accept(ExplosiveHammerPrimingRecipe(Ingredient.of(Tags.Items.NUGGETS_IRON), modLocation("hammer_priming")).toFinished()) MatteryRecipe(MItems.EXPLOSIVE_HAMMER, category = RecipeCategory.COMBAT) .rowB(Tags.Items.INGOTS_IRON) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MachineUpgradeRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MachineUpgradeRecipes.kt index f11d03911..5b9ace528 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MachineUpgradeRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MachineUpgradeRecipes.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.datagen.recipes -import net.minecraft.data.recipes.RecipeOutput import net.minecraft.world.item.Items import net.minecraftforge.common.Tags import ru.dbotthepony.mc.otm.registry.MItemTags diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatterEntanglerRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatterEntanglerRecipes.kt index 19378ec84..55c3f636e 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatterEntanglerRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatterEntanglerRecipes.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.datagen.recipes -import net.minecraft.data.recipes.RecipeOutput import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Ingredient import net.minecraftforge.common.Tags @@ -14,6 +13,7 @@ import ru.dbotthepony.mc.otm.registry.MItems fun addMatterEntanglerRecipes(consumer: RecipeOutput) { consumer.accept( MatterEntanglerRecipe( + modLocation("quantum_capacitor"), IngredientMatrix.of( listOf(Ingredient.of(MItems.ELECTRIC_PARTS), Ingredient.of(MItemTags.GOLD_WIRES), Ingredient.of(MItems.ELECTRIC_PARTS)), listOf(Ingredient.of(MItems.BATTERY_CAPACITOR), Ingredient.of(MItems.QUANTUM_TRANSCEIVER), Ingredient.of(MItems.BATTERY_CAPACITOR)), @@ -23,11 +23,12 @@ fun addMatterEntanglerRecipes(consumer: RecipeOutput) { 400.0, ItemStack(MItems.QUANTUM_CAPACITOR, 2), experience = 15f - ).energetic().toFinished(modLocation("quantum_capacitor")) + ).energetic().toFinished() ) consumer.accept( MatterEntanglerRecipe( + modLocation("quantum_battery"), IngredientMatrix.of( listOf(Ingredient.of(Tags.Items.STORAGE_BLOCKS_REDSTONE), Ingredient.of(MItemTags.GOLD_WIRES), Ingredient.of(Tags.Items.STORAGE_BLOCKS_REDSTONE)), listOf(Ingredient.of(MItems.BATTERY_DENSE), Ingredient.of(MItems.QUANTUM_TRANSCEIVER), Ingredient.of(MItems.BATTERY_DENSE)), @@ -37,6 +38,6 @@ fun addMatterEntanglerRecipes(consumer: RecipeOutput) { 600.0, ItemStack(MItems.QUANTUM_BATTERY, 2), experience = 20f - ).energetic().toFinished(modLocation("quantum_battery")) + ).energetic().toFinished() ) } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt index 7e2e75f89..2d02a538e 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipe.kt @@ -7,7 +7,6 @@ import net.minecraft.advancements.Criterion import net.minecraft.advancements.CriterionTriggerInstance import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.data.recipes.RecipeCategory -import net.minecraft.data.recipes.RecipeOutput import net.minecraft.data.recipes.ShapedRecipeBuilder import net.minecraft.resources.ResourceLocation import net.minecraft.tags.TagKey @@ -62,10 +61,6 @@ private fun RecipeOutput.map(mapper: (FinishedRecipe) -> FinishedRecipe): Recipe override fun accept(recipe: FinishedRecipe) { this@map.accept(mapper(recipe)) } - - override fun advancement(): Advancement.Builder { - return this@map.advancement() - } } } @@ -77,11 +72,11 @@ class MatteryRecipe(val result: ItemLike, val count: Int = 1, val category: Reci private val rows = arrayOfNulls(3) private var index = 0 - private val unlockedBy = ArrayList>>().also { + private val unlockedBy = ArrayList>().also { it.add("has_result" to has(result)) } - fun unlockedBy(name: String, trigger: Criterion<*>): MatteryRecipe { + fun unlockedBy(name: String, trigger: CriterionTriggerInstance): MatteryRecipe { unlockedBy.add(name to trigger) return this } @@ -190,7 +185,7 @@ class MatteryRecipe(val result: ItemLike, val count: Int = 1, val category: Reci pJson["source"] = upgradeSource!!.toString() } - override fun type(): RecipeSerializer<*> { + override fun getType(): RecipeSerializer<*> { return UpgradeRecipe.CODEC } } @@ -222,7 +217,7 @@ class MatteryRecipe(val result: ItemLike, val count: Int = 1, val category: Reci fun buildEnergetic(consumer: RecipeOutput, name: String? = null) { build(consumer.map { object : FinishedRecipe by it { - override fun type(): RecipeSerializer<*> { + override fun getType(): RecipeSerializer<*> { return EnergyContainerRecipe.Companion } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt index 6e36513b1..bb937d3ed 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt @@ -1,17 +1,13 @@ package ru.dbotthepony.mc.otm.datagen.recipes -import com.google.common.collect.ImmutableList -import net.minecraft.advancements.CriteriaTriggers import net.minecraft.advancements.Criterion +import net.minecraft.advancements.CriterionTriggerInstance import net.minecraft.advancements.critereon.ContextAwarePredicate -import net.minecraft.advancements.critereon.EntityPredicate import net.minecraft.advancements.critereon.InventoryChangeTrigger import net.minecraft.advancements.critereon.ItemPredicate import net.minecraft.advancements.critereon.MinMaxBounds import net.minecraft.data.DataGenerator -import net.minecraft.data.recipes.FinishedRecipe import net.minecraft.data.recipes.RecipeBuilder -import net.minecraft.data.recipes.RecipeOutput import net.minecraft.data.recipes.RecipeProvider import net.minecraft.resources.ResourceLocation import net.minecraft.tags.ItemTags @@ -27,31 +23,30 @@ import ru.dbotthepony.mc.otm.datagen.modLocation import ru.dbotthepony.mc.otm.recipe.MicrowaveRecipe import ru.dbotthepony.mc.otm.recipe.PlatePressRecipe import java.util.* -import java.util.function.Consumer import java.util.stream.Stream private typealias RecipeBuilderCallback = (MatteryRecipeProvider, consumer: RecipeOutput) -> Unit -fun has(p_176521_: MinMaxBounds.Ints, p_176522_: ItemLike): Criterion { +fun has(p_176521_: MinMaxBounds.Ints, p_176522_: ItemLike): CriterionTriggerInstance { return inventoryTrigger(ItemPredicate.Builder.item().of(p_176522_).withCount(p_176521_).build()) } -fun has(p_125978_: ItemLike): Criterion { +fun has(p_125978_: ItemLike): CriterionTriggerInstance { return inventoryTrigger(ItemPredicate.Builder.item().of(p_125978_).build()) } -fun has(p_125976_: TagKey): Criterion { +fun has(p_125976_: TagKey): CriterionTriggerInstance { return inventoryTrigger(ItemPredicate.Builder.item().of(p_125976_).build()) } -fun inventoryTrigger(vararg p_126012_: ItemPredicate): Criterion { - return CriteriaTriggers.INVENTORY_CHANGED.createCriterion(InventoryChangeTrigger.TriggerInstance( - Optional.empty(), +fun inventoryTrigger(vararg p_126012_: ItemPredicate): CriterionTriggerInstance { + return InventoryChangeTrigger.TriggerInstance( + ContextAwarePredicate.ANY, MinMaxBounds.Ints.ANY, MinMaxBounds.Ints.ANY, MinMaxBounds.Ints.ANY, - ImmutableList.copyOf(p_126012_) - )) + p_126012_ + ) } fun multiIngredient(vararg items: Any) : Ingredient { @@ -104,24 +99,25 @@ class MatteryRecipeProvider(generatorIn: DataGenerator) : RecipeProvider(generat fun plate(id: String, count: Int = 1, workTicks: Int = 200, experience: FloatProvider = ConstantFloat.ZERO) { exec { _, consumer -> consumer.accept(PlatePressRecipe( + modLocation("plates/$id"), Ingredient.of(ItemTags.create(ResourceLocation("forge", "ingots/$id"))), Ingredient.of(ItemTags.create(ResourceLocation("forge", "plates/$id"))), count, workTicks, experience = experience - ).toFinished(modLocation("plates/$id"))) + ).toFinished()) } } fun plate(id: String, ingredient: Ingredient, result: Ingredient, count: Int = 1, workTicks: Int = 200, experience: FloatProvider = ConstantFloat.ZERO) { exec { it, callback -> - callback.accept(PlatePressRecipe(ingredient, result, count, workTicks, experience = experience).toFinished(modLocation("plate_$id"))) + callback.accept(PlatePressRecipe(modLocation("plates/$id"), ingredient, result, count, workTicks, experience = experience).toFinished()) } } fun microwave(id: String, ingredient: Ingredient, result: Ingredient, count: Int = 1, workTicks: Int = 200, experience: FloatProvider = ConstantFloat.ZERO) { exec { it, callback -> - callback.accept(MicrowaveRecipe(ingredient, result, count, workTicks, experience = experience).toFinished(modLocation("microwave/$id"))) + callback.accept(MicrowaveRecipe(modLocation("microwave/$id"), ingredient, result, count, workTicks, experience = experience).toFinished()) } } } diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt index f43737eca..ca1dbba7d 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/PainterRecipes.kt @@ -1,20 +1,16 @@ package ru.dbotthepony.mc.otm.datagen.recipes -import net.minecraft.data.recipes.FinishedRecipe -import net.minecraft.data.recipes.RecipeOutput import net.minecraft.world.item.DyeColor import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.item.crafting.Ingredient import ru.dbotthepony.mc.otm.core.registryName -import ru.dbotthepony.mc.otm.core.stream import ru.dbotthepony.mc.otm.datagen.modLocation import ru.dbotthepony.mc.otm.recipe.PainterArmorDyeRecipe import ru.dbotthepony.mc.otm.recipe.PainterRecipe import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRegistry -import java.util.function.Consumer private val Item.recipeName get() = registryName!!.namespace + "/" + registryName!!.path @@ -23,10 +19,11 @@ private fun generate(consumer: RecipeOutput, items: Map, am if (targetColor == null) continue consumer.accept(PainterRecipe( + modLocation("painter/" + targetItem.recipeName), Ingredient.of(items.entries.stream().filter { it.key != null && it.key != targetColor }.map { ItemStack(it.value) }), ItemStack(targetItem), mapOf(targetColor to amount) - ).toFinished(modLocation("painter/" + targetItem.recipeName))) + ).toFinished()) } } @@ -40,19 +37,21 @@ private fun generate(consumer: RecipeOutput, default: Item, items: Map) { consumer.accept(PainterRecipe( + modLocation("painter/cleaning/" + to.recipeName), Ingredient.of(from.entries.stream().filter { it.key != null }.map { ItemStack(it.value) }), ItemStack(to), mapOf(null to 15) - ).toFinished(modLocation("painter/cleaning/" + to.recipeName))) + ).toFinished()) } private fun striped(consumer: RecipeOutput, name: String, items: List>>, base: Map) { @@ -60,10 +59,11 @@ private fun striped(consumer: RecipeOutput, name: String, items: List fun hammerRecipe(output: ItemLike, input: ItemLike, consumer: RecipeOutput) { ShapelessRecipeBuilder(RecipeCategory.MISC, output, 1) From 5d15611f84877969a5dc65e12a8b089a937492dc Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 31 Dec 2023 22:20:48 +0700 Subject: [PATCH 1157/1199] Update mods.toml --- src/main/resources/META-INF/mods.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 877a59311..f658fa297 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -41,7 +41,7 @@ Matter. Energy. Combined. # Does this dependency have to exist - if not, ordering below must be specified mandatory=true #mandatory # The version range of the dependency - versionRange="[48.0.0,)" #mandatory + versionRange="[47.0.0,)" #mandatory # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory ordering="NONE" # Side this dependency is applied on - BOTH, CLIENT or SERVER @@ -51,6 +51,6 @@ Matter. Energy. Combined. modId="minecraft" mandatory=true # This version range declares a minimum of the current minecraft version up to but not including the next major version - versionRange="[1.20.2,1.21)" + versionRange="[1.20.1,1.20.2)" ordering="NONE" side="BOTH" From f942093e4f8d778d3192c27096fc5ecf53b9ab95 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 31 Dec 2023 22:23:16 +0700 Subject: [PATCH 1158/1199] Don't embed condition json by default --- src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt index 10d9550bd..df3588fb5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt @@ -10,7 +10,7 @@ import ru.dbotthepony.mc.otm.core.fromJsonStrict import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.core.toJsonStrict -class Codec2Serializer(val codec: Codec, val embed: Boolean = true) : Serializer { +class Codec2Serializer(val codec: Codec, val embed: Boolean = false) : Serializer { override fun serialize(data: JsonObject, value: T, context: JsonSerializationContext) { if (embed) { val result = codec.toJsonStrict(value, data) From e5a982ae1388dfd2b2e1733da63b0f90cf85269c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 31 Dec 2023 22:25:55 +0700 Subject: [PATCH 1159/1199] Caused by: java.lang.invoke.LambdaConversionException: Invalid receiver type int; not a subtype of implementation type class java.lang.Integer --- .../ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt index 72d34340a..04f40943c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt @@ -37,7 +37,7 @@ interface MatteryPacket { abstract class MatteryNetworkChannel(val version: Int, val name: String) { val channel: SimpleChannel = NetworkRegistry - .newSimpleChannel(ResourceLocation(OverdriveThatMatters.MOD_ID, name), version::toString, String::equals, String::equals) + .newSimpleChannel(ResourceLocation(OverdriveThatMatters.MOD_ID, name), { version.toString() }, String::equals, String::equals) fun sendToServer(packet: Any) = channel.send(PacketDistributor.SERVER.noArg(), packet) From 65cf8bf9dfc94f57428ecfb7d269fe74327eda37 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 31 Dec 2023 22:43:02 +0700 Subject: [PATCH 1160/1199] Fixes to data loading --- .../ru/dbotthepony/mc/otm/data/Codec2Serializer.kt | 3 ++- src/main/kotlin/ru/dbotthepony/mc/otm/data/Codecs.kt | 11 ++++++++++- .../ru/dbotthepony/mc/otm/data/RecipeWrapperCodec.kt | 7 ++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt index df3588fb5..5d43cd04e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2Serializer.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.data import com.google.gson.JsonDeserializationContext +import com.google.gson.JsonNull import com.google.gson.JsonObject import com.google.gson.JsonSerializationContext import com.google.gson.JsonSyntaxException @@ -31,7 +32,7 @@ class Codec2Serializer(val codec: Codec, val embed: Boolean = false) if (embed) { return codec.fromJsonStrict(data) } else { - return codec.fromJsonStrict(data["value"] ?: throw JsonSyntaxException("Missing 'value' element")) + return codec.fromJsonStrict(data["value"] ?: JsonNull.INSTANCE) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codecs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codecs.kt index d7e90cc59..b85df203a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codecs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codecs.kt @@ -17,7 +17,16 @@ val DoublesCodec: Codec = RecordCodecBuilder.create { it.group( Codec.DOUBLE.optionalFieldOf("min").forGetter { Optional.ofNullable(it.min) }, Codec.DOUBLE.optionalFieldOf("max").forGetter { Optional.ofNullable(it.max) }, - ).apply(it) { a, b -> MinMaxBounds.Doubles.between(a.orElse(null), b.orElse(null)) } + ).apply(it) { min, max -> + if (min.isEmpty && max.isEmpty) + MinMaxBounds.Doubles.ANY + else if (min.isEmpty) + MinMaxBounds.Doubles.atMost(max.get()) + else if (max.isEmpty) + MinMaxBounds.Doubles.atLeast(min.get()) + else + MinMaxBounds.Doubles.between(min.get(), max.get()) + } } private val dealtReceived: Codec> = RecordCodecBuilder.create { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/RecipeWrapperCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/RecipeWrapperCodec.kt index 7374cd200..e9f950796 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/RecipeWrapperCodec.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/RecipeWrapperCodec.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.data -import com.google.gson.JsonNull import com.google.gson.JsonObject import com.mojang.datafixers.util.Pair import com.mojang.serialization.Codec @@ -9,10 +8,8 @@ import com.mojang.serialization.DynamicOps import com.mojang.serialization.JsonOps import io.netty.buffer.UnpooledByteBufAllocator import net.minecraft.network.FriendlyByteBuf -import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.crafting.Recipe import net.minecraft.world.item.crafting.RecipeSerializer -import ru.dbotthepony.mc.otm.core.set import java.nio.ByteBuffer data class RecipePair>(val recipe: R, val data: JsonObject) @@ -31,7 +28,7 @@ fun > RecipeSerializer.codec(context: Codec2RecipeSerializer<*> array.position(0) return DataResult.success(ops.createByteList(array)) } else { - return DataResult.success(JsonOps.INSTANCE.convertTo(ops, JsonObject().also { it["id"] = input.recipe.id.toString(); it["recipe"] = input.data })) + return DataResult.success(JsonOps.INSTANCE.convertTo(ops, input.data)) } } @@ -47,7 +44,7 @@ fun > RecipeSerializer.codec(context: Codec2RecipeSerializer<*> } } else { val getJson = ops.convertTo(JsonOps.INSTANCE, input) as JsonObject - return DataResult.success(Pair(RecipePair(fromJson(ResourceLocation(getJson["id"].asString), getJson["recipe"] as JsonObject), getJson["recipe"] as JsonObject), ops.empty())) + return DataResult.success(Pair(RecipePair(fromJson(context.id, getJson), getJson), ops.empty())) } } } From 477e782c7c2f5acc41c4791505de3d71143968f8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 31 Dec 2023 22:44:28 +0700 Subject: [PATCH 1161/1199] *french disappointment* --- .../ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt index 04f40943c..71358da52 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryNetworkChannel.kt @@ -19,6 +19,7 @@ import java.util.concurrent.ConcurrentLinkedQueue import java.util.concurrent.locks.LockSupport import java.util.function.BiConsumer import java.util.function.Function +import java.util.function.Predicate import java.util.function.Supplier import kotlin.reflect.KClass @@ -37,7 +38,7 @@ interface MatteryPacket { abstract class MatteryNetworkChannel(val version: Int, val name: String) { val channel: SimpleChannel = NetworkRegistry - .newSimpleChannel(ResourceLocation(OverdriveThatMatters.MOD_ID, name), { version.toString() }, String::equals, String::equals) + .newSimpleChannel(ResourceLocation(OverdriveThatMatters.MOD_ID, name), { version.toString() }, { it == version.toString() }, { it == version.toString() }) fun sendToServer(packet: Any) = channel.send(PacketDistributor.SERVER.noArg(), packet) From 023ad54b330935991fb114ea12fd59c75bf0cf4f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 31 Dec 2023 23:18:23 +0700 Subject: [PATCH 1162/1199] Various fixes related to number handling --- .../energy/BatteryBackedEnergyStorage.kt | 2 +- .../capability/energy/BlockEnergyStorageImpl.kt | 4 ++-- .../otm/capability/energy/ItemEnergyStorageImpl.kt | 14 +++----------- .../ru/dbotthepony/mc/otm/client/MatteryGUI.kt | 8 ++++---- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BatteryBackedEnergyStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BatteryBackedEnergyStorage.kt index 3edbd1170..a39770a12 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BatteryBackedEnergyStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BatteryBackedEnergyStorage.kt @@ -39,7 +39,7 @@ class BatteryBackedEnergyStorage( if (ply is ServerPlayer && isAndroid) { AndroidBatteryTrigger.trigger(ply, value) - } else if (ply is ServerPlayer && !isAndroid) { + } else if (ply is ServerPlayer) { ExopackBatterySlotTrigger.trigger(ply, value) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt index cc7a7ed7e..0c9dd586a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BlockEnergyStorageImpl.kt @@ -76,7 +76,7 @@ sealed class BlockEnergyStorageImpl( return Decimal.ZERO val newLevel = (batteryLevel - howMuch.coerceAtMost(maxOutput ?: Decimal.POSITIVE_INFINITY)).moreThanZero() - val diff = (batteryLevel - newLevel) + val diff = (batteryLevel - newLevel).coerceIn(Decimal.ZERO, howMuch) if (!simulate && batteryLevel != newLevel) { batteryLevel = newLevel @@ -93,7 +93,7 @@ sealed class BlockEnergyStorageImpl( return Decimal.ZERO val newLevel = (batteryLevel + howMuch.coerceAtMost(maxInput ?: Decimal.POSITIVE_INFINITY)).coerceAtMost(maxBatteryLevel) - val diff = (newLevel - batteryLevel) + val diff = (newLevel - batteryLevel).coerceIn(Decimal.ZERO, howMuch) if (!simulate && batteryLevel != newLevel) { batteryLevel = newLevel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt index 2867fabd4..86b0916eb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/ItemEnergyStorageImpl.kt @@ -38,21 +38,13 @@ abstract class ItemEnergyStorageImpl(val itemStack: ItemStack) : IMatteryEnergyS if (!howMuch.isPositive || itemStack.count != 1) return Decimal.ZERO - @Suppress("NAME_SHADOWING") - var howMuch = howMuch - val maxOutput = maxOutput - - if (maxOutput != null) { - howMuch = howMuch.coerceAtMost(maxOutput) - } - val batteryLevel = batteryLevel if (!batteryLevel.isPositive) return Decimal.ZERO - val newLevel = (batteryLevel - howMuch).moreThanZero() - val diff = (batteryLevel - newLevel) + val newLevel = (batteryLevel - howMuch.coerceAtMost(maxOutput ?: Decimal.POSITIVE_INFINITY)).moreThanZero() + val diff = (batteryLevel - newLevel).coerceIn(Decimal.ZERO, howMuch) if (!simulate && batteryLevel != newLevel) { this.batteryLevel = newLevel @@ -70,7 +62,7 @@ abstract class ItemEnergyStorageImpl(val itemStack: ItemStack) : IMatteryEnergyS return Decimal.ZERO val newLevel = (batteryLevel + howMuch.coerceAtMost(maxInput ?: Decimal.POSITIVE_INFINITY)).coerceAtMost(maxBatteryLevel) - val diff = (newLevel - batteryLevel) + val diff = (newLevel - batteryLevel).coerceIn(Decimal.ZERO, howMuch) if (!simulate && batteryLevel != newLevel) { this.batteryLevel = newLevel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index 8886d1969..84912739a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -235,7 +235,7 @@ object MatteryGUI { if (mattery.androidEnergy.maxBatteryLevel.isZero) { level = 0f } else { - level = mattery.androidEnergy.batteryLevel.div(mattery.androidEnergy.maxBatteryLevel).toFloat() + level = mattery.androidEnergy.batteryLevel.percentage(mattery.androidEnergy.maxBatteryLevel) if (level >= 0.98f) level = 1f @@ -308,8 +308,8 @@ object MatteryGUI { if (!gui.shouldDrawSurvivalElements()) return - val level: Float = (ply.health / ply.maxHealth).coerceIn(0.0f .. 1.0f) - val levelAbsorb: Float = (ply.absorptionAmount / ply.maxHealth).coerceIn(0.0f .. 1.0f) + val level: Float = (ply.health / ply.maxHealth).coerceIn(0.0f, 1.0f) + val levelAbsorb: Float = (ply.absorptionAmount / ply.maxHealth).coerceIn(0.0f, 1.0f) gui.setupOverlayRenderState(true, false) RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f) @@ -324,7 +324,7 @@ object MatteryGUI { if (mattery.hasFeature(AndroidFeatures.NANOBOTS_ARMOR)) { val featArmor = mattery.getFeature(AndroidFeatures.NANOBOTS_ARMOR) as NanobotsArmorFeature - val levelArmor: Float = (featArmor.layers.toFloat() / (featArmor.strength + 1).toFloat()).coerceIn(0.0f .. 1.0f) + val levelArmor: Float = (featArmor.layers.toFloat() / (featArmor.strength + 1).toFloat()).coerceIn(0.0f, 1.0f) HEALTH_BG_NANOBOTS.renderPartial(event.guiGraphics, left.toFloat(), top.toFloat(), width = ceil(levelArmor * 81f)) } From 75681fb4c49906e47363822378c9f3c5fdbf1c7c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 00:13:15 +0700 Subject: [PATCH 1163/1199] Specify isCancelable directly --- .../mc/otm/capability/MatteryPlayerCapability.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index a279abffd..0f3d0349c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -150,6 +150,10 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial data class PreTick(val capability: MatteryPlayerCapability) : Event() { val player get() = capability.ply val level: Level get() = capability.ply.level() + + override fun isCancelable(): Boolean { + return true + } } /** @@ -158,6 +162,10 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial data class PostTick(val capability: MatteryPlayerCapability) : Event() { val player get() = capability.ply val level: Level get() = capability.ply.level() + + override fun isCancelable(): Boolean { + return false + } } /** From 2e23ce1a045a2fb94dedbdf2da75314ef0ab905e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 00:58:17 +0700 Subject: [PATCH 1164/1199] One more isCancelable --- .../dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 0f3d0349c..612fc76d2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -175,6 +175,10 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial data class ItemStackLeftoverEvent(val stack: ItemStack, val capability: MatteryPlayerCapability) : Event() { val player get() = capability.ply val level: Level get() = capability.ply.level() + + override fun isCancelable(): Boolean { + return false + } } private inner class PlayerMatteryContainer(size: Int) : MatteryContainer(size) { From bf46ac064728bcbc2e78af55fa606ffe1035c3ad Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 01:54:17 +0700 Subject: [PATCH 1165/1199] Downgrade dependencies --- gradle.properties | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gradle.properties b/gradle.properties index 74f9e8fe7..3ba996cf4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,24 +10,24 @@ mod_version=1.4 use_commit_hash_in_version=true -mc_version=1.20.1 -jei_mc_version=1.20.1 -curios_mc_version=1.20.1 +mc_version=1.19.4 +jei_mc_version=1.19.4 +curios_mc_version=1.19.4 forge_gradle_version=[6.0.14,6.2) -forge_version=47.2.19 +forge_version=45.2.8 mixingradle_version=0.7.33 mixin_version=0.8.5 -jei_version=15.2.0.27 +jei_version=13.1.0.16 jupiter_version=5.9.2 -curios_version=5.4.7 -cosmetic_armor_reworked_id=4764779 +curios_version=5.1.5.4 +cosmetic_armor_reworked_id=4439659 ad_astra_id=4594155 botarium_id=4594094 resourceful_lib_id=4598948 resourceful_config_id=4576455 -jade_id=4986594 +jade_id=4573063 configured_id=4462894 kotlin_for_forge_version=4.7.0 From 1a5a9a630387d8fcde033970122c54dc4cd1cd4f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 01:59:34 +0700 Subject: [PATCH 1166/1199] Use curseforge curios version --- build.gradle.kts | 3 +-- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 4c71e581e..68bcfe841 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -139,13 +139,12 @@ dependencies { val configured_id: String by project val curios_version: String by project val jei_mc_version: String by project - val curios_mc_version: String by project val resourceful_lib_id: String by project val resourceful_config_id: String by project val botarium_id: String by project val ad_astra_id: String by project - compileOnly(fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}+${curios_mc_version}")) + compileOnly(fg.deobf("curse.maven:curios-309927:${curios_version}")) compileOnly(fg.deobf("curse.maven:cosmetic-armor-reworked-237307:$cosmetic_armor_reworked_id")) compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-common-api:${jei_version}")) diff --git a/gradle.properties b/gradle.properties index 3ba996cf4..e494df7cf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,7 +21,7 @@ mixin_version=0.8.5 jei_version=13.1.0.16 jupiter_version=5.9.2 -curios_version=5.1.5.4 +curios_version=4834414 cosmetic_armor_reworked_id=4439659 ad_astra_id=4594155 botarium_id=4594094 From 311de079fa7a42dce152953dfc868f1862eea4cb Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 02:39:58 +0700 Subject: [PATCH 1167/1199] Add polyfill guigraphics --- .../otm/android/AndroidSwitchableFeature.kt | 3 +- .../android/feature/EnderTeleporterFeature.kt | 3 +- .../otm/android/feature/ItemMagnetFeature.kt | 3 +- .../otm/android/feature/JumpBoostFeature.kt | 3 +- .../otm/android/feature/NightVisionFeature.kt | 3 +- .../otm/android/feature/ShockwaveFeature.kt | 3 +- .../otm/android/feature/StepAssistFeature.kt | 3 +- .../android/feature/SwimBoostersFeature.kt | 3 +- .../mc/otm/client/AndroidAbilityKeyMapping.kt | 7 +- .../mc/otm/client/AndroidMenuKeyMapping.kt | 14 +- .../dbotthepony/mc/otm/client/MGUIGraphics.kt | 259 ++++++++++++++++++ .../dbotthepony/mc/otm/client/MatteryGUI.kt | 37 +-- .../mc/otm/client/render/FontRenderer.kt | 70 +---- .../mc/otm/client/render/IGUIRenderable.kt | 17 +- .../mc/otm/client/render/RenderHelper.kt | 55 +--- .../render/sprites/AbstractMatterySprite.kt | 9 +- .../sprites/StretchingRectangleElement.kt | 5 +- .../mc/otm/client/screen/MatteryScreen.kt | 14 +- .../client/screen/decorative/PainterScreen.kt | 8 +- .../client/screen/matter/MatterPanelScreen.kt | 4 +- .../otm/client/screen/panels/ColorPicker.kt | 16 +- .../otm/client/screen/panels/EditablePanel.kt | 21 +- .../client/screen/panels/EffectListPanel.kt | 9 +- .../screen/panels/EntityRendererPanel.kt | 8 +- .../mc/otm/client/screen/panels/FramePanel.kt | 10 +- .../mc/otm/client/screen/panels/Label.kt | 4 +- .../screen/panels/NetworkedItemGridPanel.kt | 6 +- .../otm/client/screen/panels/Panel2Widget.kt | 7 +- .../otm/client/screen/panels/SpritePanel.kt | 4 +- .../otm/client/screen/panels/Widget2Panel.kt | 7 +- .../panels/button/AbstractButtonPanel.kt | 4 +- .../button/BooleanRectangleButtonPanel.kt | 6 +- .../screen/panels/button/ButtonPanel.kt | 5 +- .../client/screen/panels/button/Buttons.kt | 8 +- .../screen/panels/button/CheckBoxPanel.kt | 5 +- .../panels/button/EnumRectangleButtonPanel.kt | 6 +- .../button/LargeRectangleButtonPanel.kt | 4 +- .../panels/button/RectangleButtonPanel.kt | 5 +- .../button/SmallRectangleButtonPanel.kt | 4 +- .../screen/panels/input/TextInputPanel.kt | 7 +- .../screen/panels/slot/AbstractSlotPanel.kt | 10 +- .../screen/panels/slot/InventorySlotPanel.kt | 3 +- .../client/screen/panels/slot/SlotPanel.kt | 9 +- .../panels/slot/UserFilteredSlotPanel.kt | 8 +- .../panels/util/AnalogScrollBarPanel.kt | 7 +- .../screen/panels/util/BackgroundPanel.kt | 4 +- .../panels/util/DiscreteScrollBarPanel.kt | 7 +- .../screen/storage/ItemMonitorScreen.kt | 8 +- .../screen/tech/AndroidStationScreen.kt | 17 +- .../client/screen/tech/EnergyServoScreen.kt | 4 +- .../screen/tech/EssenceStorageScreen.kt | 4 +- .../client/screen/widget/FluidGaugePanel.kt | 8 +- .../widget/HorizontalPowerGaugePanel.kt | 7 +- .../client/screen/widget/MatterGaugePanel.kt | 18 +- .../client/screen/widget/PatternGaugePanel.kt | 7 +- .../client/screen/widget/PowerGaugePanel.kt | 8 +- .../screen/widget/ProgressGaugePanel.kt | 7 +- .../mc/otm/compat/cos/CosmeticArmorCompat.kt | 6 +- .../dbotthepony/mc/otm/compat/jei/Gauges.kt | 5 +- .../compat/jei/IGUIRenderable2IDrawable.kt | 3 +- .../jei/MatterEntanglerRecipeCategory.kt | 17 +- .../otm/compat/jei/MicrowaveRecipeCategory.kt | 16 +- .../otm/compat/jei/PainterRecipeCategory.kt | 11 +- .../compat/jei/PlatePressRecipeCategory.kt | 17 +- 64 files changed, 532 insertions(+), 348 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/MGUIGraphics.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt index eb4bbe251..180729b85 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt @@ -4,6 +4,7 @@ import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.nbt.CompoundTag import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.nbt.set @@ -47,7 +48,7 @@ abstract class AndroidSwitchableFeature(type: AndroidFeatureType<*>, android: Ma // TODO: GuiGraphics is stripped from server dist // but it doesn't seem to cause issues? - abstract fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor = RGBAColor.WHITE) + abstract fun renderIcon(graphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor = RGBAColor.WHITE) override fun serializeNBT(): CompoundTag { return super.serializeNBT().also { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt index 30d4268dc..fc5610e7f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt @@ -30,6 +30,7 @@ import ru.dbotthepony.mc.otm.android.AndroidActiveFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.client.render.linesIgnoreZRenderType @@ -373,7 +374,7 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv } } - override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { + override fun renderIcon(graphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { if (cooldown > 0) { RenderSystem.setShaderColor(1f, 0.4f, 0.4f, 1f) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt index 1112beb02..68f0eed77 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt @@ -9,6 +9,7 @@ import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.core.math.Vector @@ -119,7 +120,7 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable } } - override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { + override fun renderIcon(graphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { ResearchIcons.ICON_ITEM_MAGNET.render(graphics, x, y, width, height, color = color) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt index 904efea81..910214ce3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt @@ -8,6 +8,7 @@ import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.config.ClientConfig @@ -96,7 +97,7 @@ class JumpBoostFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF } } - override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { + override fun renderIcon(graphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { ResearchIcons.ICON_JUMP_BOOST.render(graphics, x, y, width, height, color = if (cooldown > 0) color * RGBAColor.REDDISH else color) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt index c7241d161..9c124ea68 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt @@ -6,6 +6,7 @@ import net.minecraft.world.effect.MobEffects import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.core.math.RGBAColor @@ -33,7 +34,7 @@ class NightVisionFeature(android: MatteryPlayerCapability) : AndroidSwitchableFe } } - override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { + override fun renderIcon(graphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { ResearchIcons.ICON_NIGHT_VISION.render(graphics, x, y, width, height, color = color) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt index a1bbe002f..b987457e8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt @@ -12,6 +12,7 @@ import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.core.damageType @@ -225,7 +226,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF ticker(false) } - override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { + override fun renderIcon(graphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { ResearchIcons.ICON_SHOCKWAVE.render(graphics, x, y, width, height, color = if (isOnCooldown) color * RGBAColor.REDDISH else color) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/StepAssistFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/StepAssistFeature.kt index a26e62bd8..ead87ccd9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/StepAssistFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/StepAssistFeature.kt @@ -6,6 +6,7 @@ import net.minecraft.world.entity.ai.attributes.AttributeModifier import net.minecraftforge.common.ForgeMod import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.registry.AndroidFeatures @@ -55,7 +56,7 @@ class StepAssistFeature(android: MatteryPlayerCapability) : AndroidSwitchableFea sharedTick() } - override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { + override fun renderIcon(graphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { ResearchIcons.ICON_STEP_ASSIST.render(graphics, x, y, width, height, color = color) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/SwimBoostersFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/SwimBoostersFeature.kt index 24aaebbce..8938b8a23 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/SwimBoostersFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/SwimBoostersFeature.kt @@ -5,6 +5,7 @@ import net.minecraft.world.entity.ai.attributes.AttributeModifier import net.minecraftforge.common.ForgeMod import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.core.math.RGBAColor @@ -29,7 +30,7 @@ class SwimBoostersFeature(android: MatteryPlayerCapability) : AndroidSwitchableF ply.getAttribute(ForgeMod.SWIM_SPEED.get())?.removeModifier(MODIFIER_ID) } - override fun renderIcon(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { + override fun renderIcon(graphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, color: RGBAColor) { ResearchIcons.ICON_LIMB_OVERCLOCKING.render(graphics, x, y, width, height, color = color) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt index fae782495..d6882919d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt @@ -57,18 +57,19 @@ object AndroidAbilityKeyMapping : KeyMapping("key.otm.android_ability", KeyConfl val x = minecraft.window.guiScaledWidth.toFloat() * .5f + iconSize / 2f val y = minecraft.window.guiScaledHeight.toFloat() * .5f - iconSize / 2f + val wrap = MGUIGraphics(event.guiGraphics) - feature.renderIcon(event.guiGraphics, x, y, iconSize, iconSize) + feature.renderIcon(wrap, x, y, iconSize, iconSize) if (feature.isOnCooldown) { val cooldownPct = feature.cooldownPercent if (cooldownPct > 0.0f) { val nodrawpixels = (iconSize * (1 - cooldownPct)).roundToInt().toFloat() - event.guiGraphics.renderRect(x, y + nodrawpixels, iconSize, iconSize - nodrawpixels, color = RGBAColor.HALF_TRANSPARENT) + wrap.renderRect(x, y + nodrawpixels, iconSize, iconSize - nodrawpixels, color = RGBAColor.HALF_TRANSPARENT) } - Widgets18.COOLDOWN.render(event.guiGraphics, x, y + iconSize, iconSize, iconSize) + Widgets18.COOLDOWN.render(wrap, x, y + iconSize, iconSize, iconSize) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt index 6dd666d48..086aaf640 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt @@ -246,6 +246,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon val poseStack = event.guiGraphics.pose() poseStack.pushPose() poseStack.translate(minecraft.window.guiScaledWidth.toDouble() / 2f, minecraft.window.guiScaledHeight.toDouble() / 2f, 0.0) + val wrap = MGUIGraphics(event.guiGraphics) for ((index, feature) in features.withIndex()) { var sin = sin((index + 0.5) * degreePerSlice).toFloat() @@ -257,17 +258,17 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon } val shift = size * 0.6f - feature.renderIcon(event.guiGraphics, -iconSize / 2f + shift * cos, -shift * sin - iconSize / 2f, iconSize, iconSize) + feature.renderIcon(wrap, -iconSize / 2f + shift * cos, -shift * sin - iconSize / 2f, iconSize, iconSize) - event.guiGraphics.draw(minecraft.font, feature.type.displayName, shift * cos + 1f, -shift * sin - iconSize / 1.5f + 1f, color = RGBAColor.BLACK, gravity = RenderGravity.CENTER_CENTER) - event.guiGraphics.draw(minecraft.font, feature.type.displayName, shift * cos, -shift * sin - iconSize / 1.5f, color = if (feature.isActive) RGBAColor.DARK_GREEN else RGBAColor.DARK_RED, gravity = RenderGravity.CENTER_CENTER) + wrap.draw(minecraft.font, feature.type.displayName, shift * cos + 1f, -shift * sin - iconSize / 1.5f + 1f, color = RGBAColor.BLACK, gravity = RenderGravity.CENTER_CENTER) + wrap.draw(minecraft.font, feature.type.displayName, shift * cos, -shift * sin - iconSize / 1.5f, color = if (feature.isActive) RGBAColor.DARK_GREEN else RGBAColor.DARK_RED, gravity = RenderGravity.CENTER_CENTER) if (feature.isOnCooldown && feature.cooldownPercent > 0.0f) { RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f) drawArc(event.guiGraphics, shift * cos, -shift * sin, iconSize / 2f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * feature.cooldownPercent.toDouble()) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) - event.guiGraphics.draw(minecraft.font, formatTickDuration(feature.cooldown), shift * cos, -shift * sin + iconSize / 1.5f, color = RGBAColor.WHITE, gravity = RenderGravity.CENTER_CENTER) + wrap.draw(minecraft.font, formatTickDuration(feature.cooldown), shift * cos, -shift * sin + iconSize / 1.5f, color = RGBAColor.WHITE, gravity = RenderGravity.CENTER_CENTER) } } @@ -296,15 +297,16 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon val y = minecraft.window.guiScaledHeight * 0.2f var x = minecraft.window.guiScaledWidth * 0.5f - (features.size.toFloat() * COOLDOWN_ICON_SIZE / 2f + (features.size - 1).toFloat() * (COOLDOWN_ICON_MARGIN / 2f)) + val wrap = MGUIGraphics(event.guiGraphics) for (feature in features) { - feature.renderIcon(event.guiGraphics, x, y, COOLDOWN_ICON_SIZE, COOLDOWN_ICON_SIZE) + feature.renderIcon(wrap, x, y, COOLDOWN_ICON_SIZE, COOLDOWN_ICON_SIZE) RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f) drawArc(event.guiGraphics, x, y, COOLDOWN_ICON_SIZE / 2f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * feature.cooldownPercent, alignAtCenter = false) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) - event.guiGraphics.draw(font, formatTickDuration(feature.cooldown), x + COOLDOWN_ICON_SIZE / 2f, y + COOLDOWN_ICON_SIZE + 1f, color = RGBAColor.WHITE, gravity = RenderGravity.TOP_CENTER) + wrap.draw(font, formatTickDuration(feature.cooldown), x + COOLDOWN_ICON_SIZE / 2f, y + COOLDOWN_ICON_SIZE + 1f, color = RGBAColor.WHITE, gravity = RenderGravity.TOP_CENTER) x += COOLDOWN_ICON_SIZE + COOLDOWN_ICON_MARGIN } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MGUIGraphics.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MGUIGraphics.kt new file mode 100644 index 000000000..868fb7354 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MGUIGraphics.kt @@ -0,0 +1,259 @@ +package ru.dbotthepony.mc.otm.client + +import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.gui.Font +import net.minecraft.client.gui.GuiGraphics +import net.minecraft.client.renderer.MultiBufferSource +import net.minecraft.client.renderer.texture.TextureAtlasSprite +import net.minecraft.network.chat.Component +import net.minecraft.resources.ResourceLocation +import net.minecraft.util.FormattedCharSequence +import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.client.render.GravityRounding +import ru.dbotthepony.mc.otm.client.render.IUVCoords +import ru.dbotthepony.mc.otm.client.render.RenderGravity +import ru.dbotthepony.mc.otm.client.render.UVCoords +import ru.dbotthepony.mc.otm.client.render.UVWindingOrder +import ru.dbotthepony.mc.otm.client.render.draw +import ru.dbotthepony.mc.otm.core.math.RGBAColor + +// polyfill class for 1.19.4 and older +class MGUIGraphics(val parent: GuiGraphics) { + val pose: PoseStack get() = parent.pose() + val bufferSource: MultiBufferSource.BufferSource get() = parent.bufferSource() + val width get() = parent.guiWidth() + val height get() = parent.guiHeight() + val font: Font get() = minecraft.font + + fun setColor(red: Float, green: Float, blue: Float, alpha: Float) { + parent.setColor(red, green, blue, alpha) + } + + fun renderFakeItem(itemStack: ItemStack, x: Int, y: Int) { + parent.renderFakeItem(itemStack, x, y) + } + + fun drawLine( + startX: Float, + startY: Float, + endX: Float, + endY: Float, + width: Float, + z: Float = 0f, + color: RGBAColor = RGBAColor.WHITE + ) { + ru.dbotthepony.mc.otm.client.render.drawLine(pose.last().pose(), startX, startY, endX, endY, width, z, color) + } + + fun renderRect( + x: Float, + y: Float, + width: Float, + height: Float, + z: Float = 0f, + color: RGBAColor = RGBAColor.WHITE + ) { + ru.dbotthepony.mc.otm.client.render.renderRect(pose.last().pose(), x, y, width, height, z, color) + } + + fun renderTexturedRect( + x: Float, + y: Float, + width: Float, + height: Float, + z: Float = 0f, + uv: IUVCoords = defaultUV, + uvWinding: UVWindingOrder = UVWindingOrder.NORMAL, + color: RGBAColor = RGBAColor.WHITE, + texture: ResourceLocation? = null + ) { + ru.dbotthepony.mc.otm.client.render.renderTexturedRect(pose.last().pose(), x, y, width, height, z, uv, uvWinding, color, texture) + } + + fun renderCheckerboard( + x: Float, + y: Float, + width: Float, + height: Float, + z: Float = 0f, + color: RGBAColor = RGBAColor.WHITE + ) { + ru.dbotthepony.mc.otm.client.render.renderCheckerboard(pose.last().pose(), x, y, width, height, z, color) + } + + fun renderComponentTooltip(font: Font, lines: MutableList, x: Int, y: Int, itemStack: ItemStack = ItemStack.EMPTY) { + parent.renderComponentTooltip(font, lines, x, y, itemStack) + } + + fun flush() { + parent.flush() + } + + fun draw( + font: Font, + text: String, + x: Float = 0f, + y: Float = 0f, + gravity: RenderGravity = RenderGravity.TOP_LEFT, + scale: Float = 1f, + color: RGBAColor = RGBAColor.WHITE, + drawShadow: Boolean = false, + displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, + packedLightCoords: Int = 15728880, + effectColor: Int = 0, + shadowColor: RGBAColor = RGBAColor.BLACK, + shadowX: Float = 1f, + shadowY: Float = 1f, + shadowZ: Float = -0.1f, + customShadow: Boolean = false, + rounding: GravityRounding = if (scale == 1f) GravityRounding.DEFAULT else GravityRounding.NO, + drawOutline: Boolean = false, + outlineColor: RGBAColor = RGBAColor.BLACK, + outlineZ: Float = -0.1f, + ): Float { + val width = font.draw( + poseStack = pose, + text = text, + x = x, + y = y, + buffer = bufferSource, + gravity = gravity, + scale = scale, + color = color, + drawShadow = drawShadow, + displayMode = displayMode, + packedLightCoords = packedLightCoords, + effectColor = effectColor, + shadowColor = shadowColor, + shadowX = shadowX, + shadowY = shadowY, + shadowZ = shadowZ, + customShadow = customShadow, + rounding = rounding, + drawOutline = drawOutline, + outlineColor = outlineColor, + outlineZ = outlineZ, + ) + + flush() + return width + } + + fun draw( + font: Font, + text: Component, + x: Float = 0f, + y: Float = 0f, + gravity: RenderGravity = RenderGravity.TOP_LEFT, + scale: Float = 1f, + color: RGBAColor = RGBAColor.WHITE, + drawShadow: Boolean = false, + displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, + packedLightCoords: Int = 15728880, + effectColor: Int = 0, + shadowColor: RGBAColor = RGBAColor.BLACK, + shadowX: Float = 1f, + shadowY: Float = 1f, + shadowZ: Float = -0.1f, + customShadow: Boolean = false, + rounding: GravityRounding = if (scale == 1f) GravityRounding.DEFAULT else GravityRounding.NO, + drawOutline: Boolean = false, + outlineColor: RGBAColor = RGBAColor.BLACK, + outlineZ: Float = -0.1f, + ): Float { + val width = font.draw( + poseStack = pose, + text = text, + x = x, + y = y, + buffer = bufferSource, + gravity = gravity, + scale = scale, + color = color, + drawShadow = drawShadow, + displayMode = displayMode, + packedLightCoords = packedLightCoords, + effectColor = effectColor, + shadowColor = shadowColor, + shadowX = shadowX, + shadowY = shadowY, + shadowZ = shadowZ, + customShadow = customShadow, + rounding = rounding, + drawOutline = drawOutline, + outlineColor = outlineColor, + outlineZ = outlineZ, + ) + + flush() + return width + } + + fun draw( + font: Font, + text: FormattedCharSequence, + x: Float = 0f, + y: Float = 0f, + gravity: RenderGravity = RenderGravity.TOP_LEFT, + scale: Float = 1f, + color: RGBAColor = RGBAColor.WHITE, + drawShadow: Boolean = false, + displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, + packedLightCoords: Int = 15728880, + effectColor: Int = 0, + shadowColor: RGBAColor = RGBAColor.BLACK, + shadowX: Float = 1f, + shadowY: Float = 1f, + shadowZ: Float = -0.1f, + customShadow: Boolean = false, + rounding: GravityRounding = if (scale == 1f) GravityRounding.DEFAULT else GravityRounding.NO, + drawOutline: Boolean = false, + outlineColor: RGBAColor = RGBAColor.BLACK, + outlineZ: Float = -0.1f, + ): Float { + val width = font.draw( + poseStack = pose, + text = text, + x = x, + y = y, + buffer = bufferSource, + gravity = gravity, + scale = scale, + color = color, + drawShadow = drawShadow, + displayMode = displayMode, + packedLightCoords = packedLightCoords, + effectColor = effectColor, + shadowColor = shadowColor, + shadowX = shadowX, + shadowY = shadowY, + shadowZ = shadowZ, + customShadow = customShadow, + rounding = rounding, + drawOutline = drawOutline, + outlineColor = outlineColor, + outlineZ = outlineZ, + ) + + flush() + return width + } + + fun renderSprite( + sprite: TextureAtlasSprite, x: Float, y: Float, + width: Float = sprite.contents().width().toFloat(), + height: Float = sprite.contents().height().toFloat(), + color: RGBAColor = RGBAColor.WHITE + ) { + renderTexturedRect( + x, y, width, height, + uv = UVCoords(sprite.u0, sprite.v0, sprite.u1, sprite.v1), + texture = sprite.atlasLocation(), + color = color + ) + } + + companion object { + private val defaultUV = UVCoords(0f, 0f, 1f, 1f) + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index 84912739a..737b26927 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -141,7 +141,8 @@ object MatteryGUI { return } - val stack = event.guiGraphics.pose() + val guiGraphics = MGUIGraphics(event.guiGraphics) + val stack = guiGraphics.pose val window = event.window stack.pushPose() @@ -164,7 +165,7 @@ object MatteryGUI { pushScissorRect(0, (scissorBase + scissorHeight * (1f - progress)).toInt(), window.width, (scissorHeight * progress * 2f).toInt()) - event.guiGraphics.renderRect( + guiGraphics.renderRect( 0f, y - 12f, window.guiScaledWidth.toFloat(), @@ -173,8 +174,8 @@ object MatteryGUI { val text = TranslatableComponent("otm.iteration", iteration) - event.guiGraphics.draw(minecraft.font, text, x + 1f, y + 1f, color = RGBAColor.BLACK, gravity = RenderGravity.CENTER_CENTER) - event.guiGraphics.draw(minecraft.font, text, x, y, color = RGBAColor.WHITE, gravity = RenderGravity.CENTER_CENTER) + guiGraphics.draw(minecraft.font, text, x + 1f, y + 1f, color = RGBAColor.BLACK, gravity = RenderGravity.CENTER_CENTER) + guiGraphics.draw(minecraft.font, text, x, y, color = RGBAColor.WHITE, gravity = RenderGravity.CENTER_CENTER) stack.scale(0.35f, 0.35f, 0.35f) @@ -190,8 +191,8 @@ object MatteryGUI { for (i in deathLog.indices.reversed()) { val component = deathLog[i] - event.guiGraphics.draw(minecraft.font, component.second, x + 1f, y + 1f, color = RGBAColor.BLACK, gravity = RenderGravity.CENTER_CENTER) - event.guiGraphics.draw(minecraft.font, component.second, x, y, color = RGBAColor(color, color, color), gravity = RenderGravity.CENTER_CENTER) + guiGraphics.draw(minecraft.font, component.second, x + 1f, y + 1f, color = RGBAColor.BLACK, gravity = RenderGravity.CENTER_CENTER) + guiGraphics.draw(minecraft.font, component.second, x, y, color = RGBAColor(color, color, color), gravity = RenderGravity.CENTER_CENTER) y += minecraft.font.lineHeight color = (color - 0x20).coerceAtLeast(0x0) @@ -252,18 +253,20 @@ object MatteryGUI { val leftPadding = ceil(level * 80f - 0.5f) + val guiGraphics = MGUIGraphics(event.guiGraphics) + if (ply.hasEffect(MobEffects.HUNGER)) { - CHARGE_HUNGER_BG.render(event.guiGraphics, left.toFloat(), top.toFloat()) - CHARGE_HUNGER.renderPartial(event.guiGraphics, left.toFloat() - leftPadding + 80f, top.toFloat(), width = leftPadding) + CHARGE_HUNGER_BG.render(guiGraphics, left.toFloat(), top.toFloat()) + CHARGE_HUNGER.renderPartial(guiGraphics, left.toFloat() - leftPadding + 80f, top.toFloat(), width = leftPadding) } else { - CHARGE_BG.render(event.guiGraphics, left.toFloat(), top.toFloat()) - CHARGE.renderPartial(event.guiGraphics, left.toFloat() - leftPadding + 80f, top.toFloat(), width = leftPadding) + CHARGE_BG.render(guiGraphics, left.toFloat(), top.toFloat()) + CHARGE.renderPartial(guiGraphics, left.toFloat() - leftPadding + 80f, top.toFloat(), width = leftPadding) } val formattedPower = mattery.androidEnergy.batteryLevel.formatPower() val scale = ClientConfig.HUD.BAR_TEXT_SCALE.toFloat() - event.guiGraphics.draw(gui.font, formattedPower, left + CHARGE_BG.width + 2f + scale, top + CHARGE_BG.height / 2f + scale, scale = scale, gravity = RenderGravity.CENTER_LEFT, color = RGBAColor.YELLOW, drawOutline = true) + guiGraphics.draw(gui.font, formattedPower, left + CHARGE_BG.width + 2f + scale, top + CHARGE_BG.height / 2f + scale, scale = scale, gravity = RenderGravity.CENTER_LEFT, color = RGBAColor.YELLOW, drawOutline = true) } } @@ -320,18 +323,20 @@ object MatteryGUI { val top: Int = height - gui.leftHeight gui.leftHeight += 10 - HEALTH_BG.render(event.guiGraphics, left.toFloat(), top.toFloat()) + val guiGraphics = MGUIGraphics(event.guiGraphics) + + HEALTH_BG.render(guiGraphics, left.toFloat(), top.toFloat()) if (mattery.hasFeature(AndroidFeatures.NANOBOTS_ARMOR)) { val featArmor = mattery.getFeature(AndroidFeatures.NANOBOTS_ARMOR) as NanobotsArmorFeature val levelArmor: Float = (featArmor.layers.toFloat() / (featArmor.strength + 1).toFloat()).coerceIn(0.0f, 1.0f) - HEALTH_BG_NANOBOTS.renderPartial(event.guiGraphics, left.toFloat(), top.toFloat(), width = ceil(levelArmor * 81f)) + HEALTH_BG_NANOBOTS.renderPartial(guiGraphics, left.toFloat(), top.toFloat(), width = ceil(levelArmor * 81f)) } - getSpriteForPlayer(ply).renderPartial(event.guiGraphics, left.toFloat(), top.toFloat(), width = ceil(level * 80f - 0.5f)) + getSpriteForPlayer(ply).renderPartial(guiGraphics, left.toFloat(), top.toFloat(), width = ceil(level * 80f - 0.5f)) if (levelAbsorb > 0) { - HEALTH_ABSORB.renderPartial(event.guiGraphics, left.toFloat(), top.toFloat(), width = ceil(levelAbsorb * 80f - 0.5f)) + HEALTH_ABSORB.renderPartial(guiGraphics, left.toFloat(), top.toFloat(), width = ceil(levelAbsorb * 80f - 0.5f)) } var formattedHealth = TextComponent("%d/%d".format(ply.health.toInt(), ply.maxHealth.toInt())) @@ -340,7 +345,7 @@ object MatteryGUI { formattedHealth = TextComponent("%d+%d/%d".format(ply.health.toInt(), ply.absorptionAmount.toInt(), ply.maxHealth.toInt())) val scale = ClientConfig.HUD.BAR_TEXT_SCALE.toFloat() - event.guiGraphics.draw(minecraft.font, formattedHealth, left - 2f, top + HEALTH_BG.height / 2f + 1f * scale, scale = scale, gravity = RenderGravity.CENTER_RIGHT, color = getHealthColorForPlayer(ply), drawOutline = true) + guiGraphics.draw(minecraft.font, formattedHealth, left - 2f, top + HEALTH_BG.height / 2f + 1f * scale, scale = scale, gravity = RenderGravity.CENTER_RIGHT, color = getHealthColorForPlayer(ply), drawOutline = true) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt index 4e43bc1bb..e5b7d8a1d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt @@ -327,11 +327,12 @@ fun Font.draw( ) } -fun GuiGraphics.draw( - font: Font, - text: Component, +fun Font.draw( + poseStack: PoseStack, + text: FormattedCharSequence, x: Float = 0f, y: Float = 0f, + buffer: MultiBufferSource = buffer(), gravity: RenderGravity = RenderGravity.TOP_LEFT, scale: Float = 1f, color: RGBAColor = RGBAColor.WHITE, @@ -342,19 +343,19 @@ fun GuiGraphics.draw( shadowColor: RGBAColor = RGBAColor.BLACK, shadowX: Float = 1f, shadowY: Float = 1f, - shadowZ: Float = -0.1f, + shadowZ: Float = 0.1f, customShadow: Boolean = false, rounding: GravityRounding = if (scale == 1f) GravityRounding.DEFAULT else GravityRounding.NO, drawOutline: Boolean = false, outlineColor: RGBAColor = RGBAColor.BLACK, - outlineZ: Float = -0.1f, + outlineZ: Float = 0.1f, ): Float { - val width = font.draw( - poseStack = pose(), + return drawInternal( + poseStack = poseStack, text = text, x = x, y = y, - buffer = bufferSource(), + buffer = buffer, gravity = gravity, scale = scale, color = color, @@ -372,57 +373,4 @@ fun GuiGraphics.draw( outlineColor = outlineColor, outlineZ = outlineZ, ) - - flush() - return width -} - -fun GuiGraphics.draw( - font: Font, - text: String, - x: Float = 0f, - y: Float = 0f, - gravity: RenderGravity = RenderGravity.TOP_LEFT, - scale: Float = 1f, - color: RGBAColor = RGBAColor.WHITE, - drawShadow: Boolean = false, - displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, - packedLightCoords: Int = 15728880, - effectColor: Int = 0, - shadowColor: RGBAColor = RGBAColor.BLACK, - shadowX: Float = 1f, - shadowY: Float = 1f, - shadowZ: Float = -0.1f, - customShadow: Boolean = false, - rounding: GravityRounding = if (scale == 1f) GravityRounding.DEFAULT else GravityRounding.NO, - drawOutline: Boolean = false, - outlineColor: RGBAColor = RGBAColor.BLACK, - outlineZ: Float = -0.1f, -): Float { - val width = font.draw( - poseStack = pose(), - text = text, - x = x, - y = y, - buffer = bufferSource(), - gravity = gravity, - scale = scale, - color = color, - drawShadow = drawShadow, - displayMode = displayMode, - packedLightCoords = packedLightCoords, - effectColor = effectColor, - shadowColor = shadowColor, - shadowX = shadowX, - shadowY = shadowY, - shadowZ = shadowZ, - customShadow = customShadow, - rounding = rounding, - drawOutline = drawOutline, - outlineColor = outlineColor, - outlineZ = outlineZ, - ) - - flush() - return width } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt index f4ffa2179..acb2bc00d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.client.render import net.minecraft.client.gui.GuiGraphics import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.systemTime import kotlin.math.sin @@ -23,7 +24,7 @@ interface IGUIRenderable { val winding: UVWindingOrder get() = UVWindingOrder.NORMAL fun render( - guiGraphics: GuiGraphics, + guiGraphics: MGUIGraphics, x: Float = 0f, y: Float = 0f, gravity: RenderGravity = RenderGravity.TOP_LEFT, @@ -37,7 +38,7 @@ interface IGUIRenderable { * Render at specified position [x], [y] with size of [width] x [height], optionally with UV [winding], if we are rendering flat texture/sprite */ fun render( - guiGraphics: GuiGraphics, + guiGraphics: MGUIGraphics, x: Float = 0f, y: Float = 0f, width: Float = this.width, @@ -53,7 +54,7 @@ interface IGUIRenderable { override val height: Float get() = this@IGUIRenderable.height.coerceAtLeast(other.height) - override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder, color: RGBAColor) { + override fun render(guiGraphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder, color: RGBAColor) { this@IGUIRenderable.render(guiGraphics, x, y, width, height, winding, color) other.render(guiGraphics, x, y, width, height, winding, color) } @@ -71,7 +72,7 @@ interface IGUIRenderable { override val height: Float get() = this@IGUIRenderable.height - override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder, color: RGBAColor) { + override fun render(guiGraphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder, color: RGBAColor) { this@IGUIRenderable.render(guiGraphics, x + left, y + top, width + right + left, height + bottom + top, winding, color) } } @@ -94,7 +95,7 @@ interface IGUIRenderable { override val height: Float get() = this@IGUIRenderable.height - override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder, color: RGBAColor) { + override fun render(guiGraphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder, color: RGBAColor) { var realX = x var realY = y @@ -123,8 +124,8 @@ interface IGUIRenderable { } data class ItemStackIcon(private val itemStack: ItemStack, override val width: Float = 16f, override val height: Float = 16f) : IGUIRenderable { - override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder, color: RGBAColor) { - val pose = guiGraphics.pose() + override fun render(guiGraphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder, color: RGBAColor) { + val pose = guiGraphics.pose pose.pushPose() pose.translate(x, y, 0f) @@ -140,7 +141,7 @@ data class ItemStackIcon(private val itemStack: ItemStack, override val width: F } data class FlatRectangleIcon(override val width: Float = 1f, override val height: Float = 1f, val color: RGBAColor) : IGUIRenderable { - override fun render(guiGraphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder, color: RGBAColor) { + override fun render(guiGraphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, winding: UVWindingOrder, color: RGBAColor) { guiGraphics.renderRect(x, y, width, height, color = this.color) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt index 177c28726..4e5d00d33 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt @@ -17,6 +17,7 @@ import org.joml.Matrix4f import org.lwjgl.opengl.GL11.GL_ALWAYS import org.lwjgl.opengl.GL11.GL_LESS import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.math.RGBAColor import java.util.* @@ -94,17 +95,6 @@ fun renderRect( tess.end() } -fun GuiGraphics.renderRect( - x: Float, - y: Float, - width: Float, - height: Float, - z: Float = 0f, - color: RGBAColor = RGBAColor.WHITE -) { - renderRect(pose().last().pose(), x, y, width, height, z, color) -} - @Suppress("NAME_SHADOWING") fun renderCheckerboard( matrix: Matrix4f, @@ -146,17 +136,6 @@ fun renderCheckerboard( tess.end() } -fun GuiGraphics.renderCheckerboard( - x: Float, - y: Float, - width: Float, - height: Float, - z: Float = 0f, - color: RGBAColor = RGBAColor.WHITE -) { - renderCheckerboard(pose().last().pose(), x, y, width, height, z, color) -} - fun renderTexturedRect( matrix: Matrix4f, x: Float, @@ -209,20 +188,6 @@ fun renderTexturedRect( BufferUploader.drawWithShader(builder.end()) } -fun GuiGraphics.renderTexturedRect( - x: Float, - y: Float, - width: Float, - height: Float, - z: Float = 0f, - uv: IUVCoords = defaultUV, - uvWinding: UVWindingOrder = UVWindingOrder.NORMAL, - color: RGBAColor = RGBAColor.WHITE, - texture: ResourceLocation? = null -) { - renderTexturedRect(pose().last().pose(), x, y, width, height, z, uv, uvWinding, color, texture) -} - fun renderColoredSphere(pose: PoseStack, radius: Float, color: RGBAColor = RGBAColor.WHITE) { val fragments = 32 RenderSystem.enableBlend() @@ -330,18 +295,6 @@ fun drawLine( tess.end() } -fun GuiGraphics.drawLine( - startX: Float, - startY: Float, - endX: Float, - endY: Float, - width: Float, - z: Float = 0f, - color: RGBAColor = RGBAColor.WHITE -) { - drawLine(pose().last().pose(), startX, startY, endX, endY, width, z, color) -} - data class ScissorRect(val x: Int, val y: Int, val width: Int, val height: Int, val lock: Boolean = false) { fun withinBounds(x: Int, y: Int): Boolean { return (x in this.x .. this.x + width) && (y in this.y .. this.y + height) @@ -447,13 +400,13 @@ fun TextureAtlasSprite.render( } fun TextureAtlasSprite.render( - graphics: GuiGraphics, + graphics: MGUIGraphics, x: Float = 0f, y: Float = 0f, width: Float, height: Float, winding: UVWindingOrder = UVWindingOrder.NORMAL -) = render(graphics.pose(), x, y, width, height, winding) +) = render(graphics.pose, x, y, width, height, winding) fun determineTooltipPosition(x: Float, y: Float, width: Float, height: Float): Pair { val windowWidth = minecraft.window.guiScaledWidth.toFloat() @@ -513,7 +466,7 @@ fun clearDepth(stack: PoseStack, x: Float, y: Float, width: Float, height: Float } @JvmOverloads -fun clearDepth(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, depth: Float = -500f) = ru.dbotthepony.mc.otm.client.render.clearDepth(graphics.pose(), x, y, width, height, depth) +fun clearDepth(graphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, depth: Float = -500f) = clearDepth(graphics.pose, x, y, width, height, depth) fun drawArc( stack: PoseStack, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/AbstractMatterySprite.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/AbstractMatterySprite.kt index 90de4157e..aced04306 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/AbstractMatterySprite.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/AbstractMatterySprite.kt @@ -13,6 +13,7 @@ import net.minecraft.client.renderer.RenderType import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation import org.lwjgl.opengl.GL11.GL_ALWAYS +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.render.IUVCoords import ru.dbotthepony.mc.otm.client.render.UVWindingOrder @@ -51,7 +52,7 @@ sealed class AbstractMatterySprite : IGUIRenderable, IUVCoords { * See [ru.dbotthepony.mc.otm.client.render.clearDepth] */ fun clearDepth( - graphics: GuiGraphics, + graphics: MGUIGraphics, x: Float = 0f, y: Float = 0f, width: Float = this.width, @@ -70,7 +71,7 @@ sealed class AbstractMatterySprite : IGUIRenderable, IUVCoords { } override fun render( - guiGraphics: GuiGraphics, + guiGraphics: MGUIGraphics, x: Float, y: Float, width: Float, @@ -105,14 +106,14 @@ sealed class AbstractMatterySprite : IGUIRenderable, IUVCoords { } fun renderPartial( - graphics: GuiGraphics, + graphics: MGUIGraphics, x: Float = 0f, y: Float = 0f, width: Float = this.width, height: Float = this.height, winding: UVWindingOrder = this.winding, color: RGBAColor = RGBAColor.WHITE - ) = renderPartial(graphics.pose(), x, y, width, height, winding, color) + ) = renderPartial(graphics.pose, x, y, width, height, winding, color) protected fun uploadOnto( pose: PoseStack, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/StretchingRectangleElement.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/StretchingRectangleElement.kt index f777b9f3f..9a37f6359 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/StretchingRectangleElement.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/StretchingRectangleElement.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.client.render.sprites import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.GuiGraphics import net.minecraft.resources.ResourceLocation +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty data class StretchingRectangleElement( @@ -46,12 +47,12 @@ data class StretchingRectangleElement( @JvmOverloads fun render( - graphics: GuiGraphics, + graphics: MGUIGraphics, x: Float = 0f, y: Float = 0f, width: Float, height: Float, - ) = render(graphics.pose(), x, y, width, height) + ) = render(graphics.pose, x, y, width, height) companion object { fun square( 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 67f24f1b2..7f4165f5a 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 @@ -17,6 +17,7 @@ import net.minecraftforge.client.event.ContainerScreenEvent.Render.Foreground import net.minecraftforge.common.MinecraftForge import org.lwjgl.opengl.GL11 import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.moveMousePosScaled import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.render.Widgets18 @@ -86,13 +87,13 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit val quickCraftingType: Int get() = super.quickCraftingType val isQuickCrafting: Boolean get() = super.isQuickCrafting - fun renderItemStack(graphics: GuiGraphics, itemstack: ItemStack, countOverride: String? = null) { + fun renderItemStack(graphics: MGUIGraphics, itemstack: ItemStack, countOverride: String? = null) { if (!itemstack.isEmpty) { RenderSystem.enableDepthTest() - val (x, y) = graphics.pose().translation() + val (x, y) = graphics.pose.translation() - graphics.renderItem( + graphics.parent.renderItem( requireNotNull(ru.dbotthepony.mc.otm.client.minecraft.player) { "yo, dude, what the fuck" }, itemstack, 1, @@ -101,7 +102,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit ) RenderSystem.depthFunc(GL11.GL_ALWAYS) - graphics.renderItemDecorations( + graphics.parent.renderItemDecorations( super.font, itemstack, 1, @@ -643,6 +644,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } override fun render(graphics: GuiGraphics, mouseX: Int, mouseY: Int, partialTick: Float) { + val wrap = MGUIGraphics(graphics) val mouseXf = mouseX.toFloat() val mouseYf = mouseY.toFloat() @@ -667,7 +669,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit for (panel in panels.asReversed()) { RenderSystem.depthFunc(GL11.GL_ALWAYS) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) - panel.render(graphics, mouseXf, mouseYf, partialTick) + panel.render(wrap, mouseXf, mouseYf, partialTick) } RenderSystem.depthFunc(GL11.GL_LESS) @@ -711,7 +713,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit for (panel in panels) { RenderSystem.disableDepthTest() - if (panel.renderTooltips(graphics, mouseXf, mouseYf, partialTick)) { + if (panel.renderTooltips(wrap, mouseXf, mouseYf, partialTick)) { break } } 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 fd52916fd..8ea0afa09 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 @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.client.screen.decorative import net.minecraft.ChatFormatting -import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component import net.minecraft.util.RandomSource import net.minecraft.world.entity.player.Inventory @@ -11,10 +10,9 @@ import net.minecraft.world.item.Items import net.minecraftforge.common.Tags import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.block.entity.decorative.PainterBlockEntity +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.FlatRectangleIcon import ru.dbotthepony.mc.otm.client.render.ItemStackIcon -import ru.dbotthepony.mc.otm.client.render.renderCheckerboard -import ru.dbotthepony.mc.otm.client.render.renderRect import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode @@ -49,7 +47,7 @@ class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : tooltips.add(TextComponent("")) } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { graphics.renderRect(0f, 0f, width, height, color = RGBAColor.DARK_GRAY) val color = RGBAColor.rgb(dye?.textColor ?: DyeColor.LIGHT_BLUE.textColor) @@ -156,7 +154,7 @@ class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : get() = !recipe.value.canCraft(menu.dyeStoredDirect) set(value) {} - override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { val list = getTooltipFromItem(minecraft!!, recipeOutput) recipe.value.dyes.forEach { 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 ee098227c..fe58af574 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 @@ -1,12 +1,12 @@ package ru.dbotthepony.mc.otm.client.screen.matter import net.minecraft.ChatFormatting -import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.capability.matter.PatternState import ru.dbotthepony.mc.otm.capability.matter.ReplicationTask +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.client.screen.MatteryScreen @@ -205,7 +205,7 @@ class MatterPanelScreen( return list } - override fun renderRegular(graphics: GuiGraphics, itemstack: ItemStack, countOverride: String?) { + override fun renderRegular(graphics: MGUIGraphics, itemstack: ItemStack, countOverride: String?) { if (isPatternView) { super.renderRegular(graphics, itemstack, "") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt index 5bc85ec98..e37365d4b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt @@ -8,12 +8,12 @@ import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.WidgetLocation -import ru.dbotthepony.mc.otm.client.render.renderRect import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.button.AbstractButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.input.TextInputPanel @@ -47,7 +47,7 @@ open class ColorBoxPanel( var isPressed = false private set - override fun shouldRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun shouldRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { return super.shouldRenderTooltips(graphics, mouseX, mouseY, partialTick) || isPressed } @@ -103,7 +103,7 @@ open class ColorBoxPanel( return super.mouseReleasedInner(x, y, button) } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { graphics.renderRect(0f, 0f, width, height, color = RGBAColor.WHITE) GRADIENT_LEFT.render(graphics, 0f, 0f, width, height, color = backgroundColor) GRADIENT_DOWN.render(graphics, 0f, 0f, width, height, color = RGBAColor.BLACK) @@ -192,18 +192,18 @@ abstract class AbstractColorWangPanel( return super.mouseReleasedInner(x, y, button) } - protected fun renderGradients(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + protected fun renderGradients(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { ColorBoxPanel.GRADIENT_RIGHT.render(graphics, 0f, 0f, width, height, color = rightColor) ColorBoxPanel.GRADIENT_LEFT.render(graphics, 0f, 0f, width, height, color = leftColor) } - protected fun renderWang(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + protected fun renderWang(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (wangPosition in 0f .. 1f) { ColorBoxPanel.LINE_VERTICAL.render(graphics, x = wangPosition * width - 1f, height = height) } } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { renderGradients(graphics, mouseX, mouseY, partialTick) renderWang(graphics, mouseX, mouseY, partialTick) } @@ -334,7 +334,7 @@ open class HueWangPanel( hueCallback?.accept(newPosition * 360f) } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { HSV_BAR.render(graphics, 0f, 0f, width, height) renderWang(graphics, mouseX, mouseY, partialTick) } @@ -457,7 +457,7 @@ open class ColorPalettePanel( onColorChoose(color) } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { graphics.renderRect(0f, 0f, width, height, color = RGBAColor.BLACK) graphics.renderRect(1f, 1f, width - 2f, height - 2f, color = color) } 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 981705c2f..f4c776c13 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 @@ -7,7 +7,6 @@ import it.unimi.dsi.fastutil.ints.IntAVLTreeSet import it.unimi.dsi.fastutil.objects.ReferenceArraySet import net.minecraft.client.gui.ComponentPath import net.minecraft.client.gui.Font -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.components.events.GuiEventListener import net.minecraft.client.gui.navigation.FocusNavigationEvent import net.minecraft.client.gui.navigation.ScreenRectangle @@ -18,6 +17,7 @@ import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.SystemTime +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.moveMousePosScaled import ru.dbotthepony.mc.otm.client.render.currentScissorRect @@ -25,7 +25,6 @@ import ru.dbotthepony.mc.otm.client.render.popScissorRect import ru.dbotthepony.mc.otm.client.render.pushScissorRect import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.input.QueryUserPanel -import ru.dbotthepony.mc.otm.core.collect.any import ru.dbotthepony.mc.otm.core.collect.concatIterators import ru.dbotthepony.mc.otm.core.collect.flatMap import java.util.* @@ -786,14 +785,14 @@ open class EditablePanel @JvmOverloads constructor( } } - protected open fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {} - protected open fun preRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {} - protected open fun innerRenderPost(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {} - protected open fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + protected open fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {} + protected open fun preRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {} + protected open fun innerRenderPost(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {} + protected open fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { return false } - protected open fun shouldRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + protected open fun shouldRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { return isEverHovered || isGrabbingMouseInput() } @@ -840,14 +839,14 @@ open class EditablePanel @JvmOverloads constructor( } } - fun render(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + fun render(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { once = true if (!isVisible()) { return } - val poseStack = graphics.pose() + val poseStack = graphics.pose performLayoutIfNeeded() @@ -1041,7 +1040,7 @@ open class EditablePanel @JvmOverloads constructor( return null to ItemStack.EMPTY } - fun renderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + fun renderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { if (!isVisible()) { return false } @@ -1829,7 +1828,7 @@ open class EditablePanel @JvmOverloads constructor( /** * See [ru.dbotthepony.mc.otm.client.render.clearDepth] */ - fun clearDepth(graphics: GuiGraphics, x: Float = 0f, y: Float = 0f, width: Float = this.width, height: Float = this.height) = ru.dbotthepony.mc.otm.client.render.clearDepth(graphics, x, y, width, height) + fun clearDepth(graphics: MGUIGraphics, x: Float = 0f, y: Float = 0f, width: Float = this.width, height: Float = this.height) = ru.dbotthepony.mc.otm.client.render.clearDepth(graphics, x, y, width, height) fun queryUser(title: Component, text: Component, onConfirm: Runnable, onCancel: Runnable? = null): QueryUserPanel { return QueryUserPanel(screen, title, listOf(text), onConfirm, onCancel).also { blockingWindow = it } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt index eba7920cf..faea0c2f1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt @@ -3,13 +3,12 @@ package ru.dbotthepony.mc.otm.client.screen.panels import com.mojang.blaze3d.systems.RenderSystem import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap import it.unimi.dsi.fastutil.objects.Object2ObjectFunction -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen -import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen import net.minecraft.resources.ResourceLocation import net.minecraft.world.effect.MobEffect import net.minecraft.world.effect.MobEffectInstance import net.minecraft.world.entity.LivingEntity +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.determineTooltipPosition @@ -109,7 +108,7 @@ open class EffectListPanel @JvmOverloads constructor( } } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { clearDepth(graphics) SQUARE_THIN.render(graphics, width = width, height = height) @@ -120,7 +119,7 @@ open class EffectListPanel @JvmOverloads constructor( graphics.draw(font, formatTickDuration(effect.duration), width / 2f, height / 2f, scale = 0.75f, gravity = RenderGravity.CENTER_CENTER, color = RGBAColor.WHITE) } - override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { if (isHovered) { val (x, y) = determineTooltipPosition(mouseX + 4f, mouseY - 12f, BAR.width, BAR.height) @@ -131,7 +130,7 @@ open class EffectListPanel @JvmOverloads constructor( val renderHeight = 18f minecraft.mobEffectTextures.get(effect.effect).render( - graphics.pose(), + graphics.pose, x = x + 8f, y = y + BAR.height / 2f - renderHeight / 2f, width = renderWidth, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt index 10f1dd8e8..59cc05a94 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.client.screen.panels -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen import net.minecraft.client.gui.screens.inventory.InventoryScreen @@ -8,6 +7,7 @@ import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.player.Player import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.Widgets8 import ru.dbotthepony.mc.otm.client.render.sprites.sprite import ru.dbotthepony.mc.otm.client.screen.ExopackInventoryScreen @@ -165,13 +165,13 @@ class EntityRendererPanel @JvmOverloads constructor( } } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (entity.isDeadOrDying) { return } InventoryScreen.renderEntityInInventoryFollowsMouse( - graphics, + graphics.parent, 0, 0, this.width.toInt(), this.height.toInt(), renderScale, @@ -197,7 +197,7 @@ class EntityRendererPanel @JvmOverloads constructor( } } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { ExopackInventoryScreen.ENTITY_RECTANGLE.render(graphics) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index 7f74a2bd6..adcb9d5b0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -2,13 +2,13 @@ package ru.dbotthepony.mc.otm.client.screen.panels import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.systems.RenderSystem -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.narration.NarratableEntry import net.minecraft.client.gui.narration.NarratableEntry.NarrationPriority import net.minecraft.client.gui.narration.NarrationElementOutput import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import org.lwjgl.opengl.GL30 +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.client.render.sprites.StretchingRectangleElement import ru.dbotthepony.mc.otm.client.screen.panels.button.AbstractButtonPanel @@ -76,7 +76,7 @@ open class FramePanel( return tabs.indexOf(this) } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (isActive) { if (tabIndex() == 0) { if (isDisabled) { @@ -167,7 +167,7 @@ open class FramePanel( close() } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (isPressed) { CLOSE_BUTTON_PRESSED.render(graphics, 0f, 0f, width, height) } else if (isHovered) { @@ -193,7 +193,7 @@ open class FramePanel( isActive = !isActive }*/ - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { /*if (isPressed) { HELP_BUTTON_PRESSED.render(graphics, 0f, 0f, width, height) } else*/ if (isHovered /*|| isActive */) { @@ -364,7 +364,7 @@ open class FramePanel( return super.keyPressedInternal(key, scancode, mods) } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { RECTANGLE.render(graphics, width = width, height = height) // title diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt index aa1cba389..413eb8510 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt @@ -1,8 +1,8 @@ package ru.dbotthepony.mc.otm.client.screen.panels -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.draw import ru.dbotthepony.mc.otm.core.TextComponent @@ -31,7 +31,7 @@ open class Label @JvmOverloads constructor( var color = RGBAColor.SLATE_GRAY var gravity = RenderGravity.TOP_LEFT - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { clearDepth(graphics) if (shadow) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/NetworkedItemGridPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/NetworkedItemGridPanel.kt index d394b347d..4c6463c0c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/NetworkedItemGridPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/NetworkedItemGridPanel.kt @@ -1,17 +1,15 @@ package ru.dbotthepony.mc.otm.client.screen.panels import net.minecraft.ChatFormatting -import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.RenderGravity -import ru.dbotthepony.mc.otm.client.render.draw import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.ScrollBarConstants -import ru.dbotthepony.mc.otm.client.screen.storage.ItemMonitorScreen import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.integerDivisionDown import ru.dbotthepony.mc.otm.core.util.formatReadableNumber @@ -79,7 +77,7 @@ open class NetworkedItemGridPanel>( return true } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { renderSlotBackground(graphics, mouseX, mouseY, partialTick) val itemStack = view.sortedView.getOrNull(index)?.stack ?: StorageStack.ITEMS.empty renderRegular(graphics, itemStack.toItemStack(), "") 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 7fb05715d..722af0a2b 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 @@ -4,6 +4,7 @@ import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.components.Renderable import net.minecraft.client.gui.components.events.GuiEventListener import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.MGUIGraphics // before 1.19.3 Renderable was Widget class Panel2Widget>( @@ -19,9 +20,11 @@ class Panel2Widget>( val xFloat = mouseX.toFloat() val yFloat = mouseY.toFloat() + val wrap = MGUIGraphics(graphics) + panel.tickHover(xFloat, yFloat) - panel.render(graphics, xFloat, yFloat, partialTick) - panel.renderTooltips(graphics, xFloat, yFloat, partialTick) + panel.render(wrap, xFloat, yFloat, partialTick) + panel.renderTooltips(wrap, xFloat, yFloat, partialTick) } override fun mouseMoved(mouseX: Double, mouseY: Double) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SpritePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SpritePanel.kt index c0c45b58a..14a17b776 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SpritePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SpritePanel.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.sprites.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.UVWindingOrder @@ -16,7 +16,7 @@ class SpritePanel( var winding: UVWindingOrder = sprite.winding, var centerSprite: Boolean = false ) : EditablePanel(screen, parent, x, y, width, height) { - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (centerSprite) { sprite.render(graphics, width / 2f - sprite.width / 2f, height / 2f - sprite.height / 2f, sprite.width, sprite.height, winding) } else { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Widget2Panel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Widget2Panel.kt index 0b25469ee..4b6a35793 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Widget2Panel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Widget2Panel.kt @@ -1,11 +1,10 @@ package ru.dbotthepony.mc.otm.client.screen.panels import com.mojang.blaze3d.systems.RenderSystem -import com.mojang.blaze3d.vertex.PoseStack -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.components.AbstractWidget import net.minecraft.client.gui.screens.Screen import org.lwjgl.opengl.GL11 +import ru.dbotthepony.mc.otm.client.MGUIGraphics abstract class Widget2Panel( screen: S, @@ -90,9 +89,9 @@ abstract class Widget2Panel( return instance } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { RenderSystem.depthFunc(GL11.GL_ALWAYS) - getOrCreateWidget().render(graphics, mouseX.toInt(), mouseY.toInt(), partialTick) + getOrCreateWidget().render(graphics.parent, mouseX.toInt(), mouseY.toInt(), partialTick) RenderSystem.depthFunc(GL11.GL_ALWAYS) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractButtonPanel.kt index 41baa457c..f2ebc5a4c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractButtonPanel.kt @@ -1,8 +1,8 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import com.mojang.blaze3d.platform.InputConstants -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import java.util.function.IntPredicate @@ -65,7 +65,7 @@ abstract class AbstractButtonPanel( return true } - override fun shouldRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun shouldRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { return super.shouldRenderTooltips(graphics, mouseX, mouseY, partialTick) || isPressed } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt index 52e2c716d..4a8469438 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt @@ -1,9 +1,9 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import net.minecraft.ChatFormatting -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel @@ -33,7 +33,7 @@ abstract class BooleanRectangleButtonPanel( onChange?.invoke(newValue) } - override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { if (isHovered) { val tooltipActive = tooltipActive val tooltipInactive = tooltipInactive @@ -79,7 +79,7 @@ abstract class BooleanRectangleButtonPanel( } set(value) { super.isDisabled = value } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { super.innerRender(graphics, mouseX, mouseY, partialTick) if (prop.value) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt index 67a0c546f..ea5b0185b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.render.draw @@ -39,7 +40,7 @@ open class ButtonPanel( onPress?.accept(mouseButton) } - protected fun renderStretchableBackground(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + protected fun renderStretchableBackground(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (isDisabled) { Widgets18.BUTTON_DISABLED_STRETCHABLE.render(graphics, width = width, height = height) } else if (isPressed) { @@ -51,7 +52,7 @@ open class ButtonPanel( } } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { renderStretchableBackground(graphics, mouseX, mouseY, partialTick) graphics.draw(font, label, width / 2f, height / 2f, color = textColor, gravity = RenderGravity.CENTER_CENTER) } 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 69b871904..a1c78aebe 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 @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import com.mojang.blaze3d.platform.InputConstants import net.minecraft.ChatFormatting -import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items @@ -10,6 +9,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.addUpgradeTooltipLines +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.isCtrlDown import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.minecraft @@ -100,7 +100,7 @@ private class PullPushButton, T : Enum>( sprites[State(pull, push, value)] = sprite } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { super.innerRender(graphics, mouseX, mouseY, partialTick) sprites[State(pullProp.value, pushProp.value, prop.get())]?.render(graphics, 0f, 0f, width, height) } @@ -486,7 +486,7 @@ class DeviceControls>( tooltips.add(TranslatableComponent("otm.gui.upgrades")) } - override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { graphics.renderComponentTooltip(font, ArrayList().also { it.add(TranslatableComponent("otm.gui.upgrades")) it.add(TextComponent("")) @@ -624,7 +624,7 @@ class DeviceControls>( } } - override fun preRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun preRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (parent is FramePanel<*>) { x = parent!!.width + 3f y = dockTop diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt index 5c5693ae0..e92a13106 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.sprites.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel @@ -25,7 +26,7 @@ open class CheckBoxPanel( open val DISABLED_UNCHECKED: AbstractMatterySprite = Companion.DISABLED_UNCHECKED open val DISABLED_CHECKED: AbstractMatterySprite = Companion.DISABLED_CHECKED - protected fun renderCheckboxBackground(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + protected fun renderCheckboxBackground(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (isDisabled) { if (isChecked.get()) { DISABLED_CHECKED.render(graphics, width = width, height = height) @@ -55,7 +56,7 @@ open class CheckBoxPanel( } } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { renderCheckboxBackground(graphics, mouseX, mouseY, partialTick) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt index 9e6ee6522..d2af01f0d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt @@ -2,9 +2,9 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import com.mojang.blaze3d.platform.InputConstants import net.minecraft.ChatFormatting -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.render.UVWindingOrder @@ -70,7 +70,7 @@ abstract class EnumRectangleButtonPanel>( return this } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { check(!isBuilding) { "Still building this button!" } super.innerRender(graphics, mouseX, mouseY, partialTick) val entry = enumMapping[prop.get()] ?: return @@ -144,7 +144,7 @@ abstract class EnumRectangleButtonPanel>( } } - override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { if (tooltips.isEmpty() && enumMapping.entries.none { predicate.test(it.key) && it.value.tooltip != null }) { return super.innerRenderTooltips(graphics, mouseX, mouseY, partialTick) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt index 5515b17af..718230f23 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.render.UVWindingOrder @@ -26,7 +26,7 @@ open class LargeRectangleButtonPanel( final override val PRESSED = Widgets18.BUTTON_PRESSED final override val DISABLED = Widgets18.BUTTON_DISABLED - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { super.innerRender(graphics, mouseX, mouseY, partialTick) val color = if (isDisabled || isPressed) RGBAColor.DARK_GRAY else RGBAColor.WHITE diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/RectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/RectangleButtonPanel.kt index a89d1436b..16afdc8c9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/RectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/RectangleButtonPanel.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import java.util.function.IntConsumer @@ -25,7 +26,7 @@ abstract class RectangleButtonPanel( onPress?.accept(mouseButton) } - protected fun renderSquareButton(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + protected fun renderSquareButton(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (isDisabled) { DISABLED.render(graphics, 0f, 0f, width, height) } else if (isPressed) { @@ -37,7 +38,7 @@ abstract class RectangleButtonPanel( } } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { renderSquareButton(graphics, mouseX, mouseY, partialTick) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallRectangleButtonPanel.kt index 3b2cab6a9..a6bf44fb3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallRectangleButtonPanel.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.Widgets8 @@ -23,7 +23,7 @@ open class SmallRectangleButtonPanel( final override val PRESSED = Widgets8.BUTTON_PRESSED final override val DISABLED = Widgets8.BUTTON_DISABLED - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { super.innerRender(graphics, mouseX, mouseY, partialTick) if (skinElementWinding != null) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt index 328a0d943..b1a63bc0a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt @@ -9,11 +9,11 @@ import it.unimi.dsi.fastutil.chars.Char2IntOpenHashMap import it.unimi.dsi.fastutil.chars.CharOpenHashSet import it.unimi.dsi.fastutil.ints.Int2ObjectAVLTreeMap import it.unimi.dsi.fastutil.ints.Int2ObjectMap -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.client.renderer.GameRenderer import net.minecraft.network.chat.Component import org.joml.Vector2i +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.isCtrlDown import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.minecraft @@ -21,7 +21,6 @@ import ru.dbotthepony.mc.otm.client.playGuiClickSound 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.renderRect import ru.dbotthepony.mc.otm.client.render.tesselator import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel @@ -1117,7 +1116,7 @@ open class TextInputPanel( return accumulate } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (!backgroundColor.isFullyTransparent) graphics.renderRect(0f, 0f, width, height, color = backgroundColor) @@ -1153,7 +1152,7 @@ open class TextInputPanel( scrollPixels = 0f } - val stack = graphics.pose() + val stack = graphics.pose stack.pushPose() stack.translate(-scrollPixels, 0f, 0f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt index f98bbd7fe..6d4f7bbb6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt @@ -1,12 +1,12 @@ package ru.dbotthepony.mc.otm.client.screen.panels.slot import com.mojang.blaze3d.systems.RenderSystem -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen.getTooltipFromItem import net.minecraft.client.renderer.GameRenderer import net.minecraft.network.chat.Component import net.minecraft.world.item.ItemStack import net.minecraftforge.client.extensions.common.IClientItemExtensions +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel @@ -24,12 +24,12 @@ abstract class AbstractSlotPanel> @JvmOverloads constru open var slotBackground: IGUIRenderable? = null open var slotBackgroundEmpty: IGUIRenderable? = null - protected open fun renderSlotBackground(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + protected open fun renderSlotBackground(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { SLOT_BACKGROUND.render(graphics, width = width, height = height) slotBackground?.render(graphics, 0f, 0f, width, height) } - protected open fun renderRegular(graphics: GuiGraphics, itemstack: ItemStack, countOverride: String? = null) { + protected open fun renderRegular(graphics: MGUIGraphics, itemstack: ItemStack, countOverride: String? = null) { RenderSystem.setShader(GameRenderer::getPositionTexShader) if (!itemstack.isEmpty) { @@ -46,7 +46,7 @@ abstract class AbstractSlotPanel> @JvmOverloads constru return getTooltipFromItem(ru.dbotthepony.mc.otm.client.minecraft, stack) } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { renderSlotBackground(graphics, mouseX, mouseY, partialTick) val itemStack = itemStack renderRegular(graphics, itemStack) @@ -56,7 +56,7 @@ abstract class AbstractSlotPanel> @JvmOverloads constru } } - override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { if (isHovered) { val itemstack = itemStack diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt index 405909afb..5e044dc99 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.slot import com.mojang.blaze3d.platform.InputConstants import net.minecraft.client.gui.GuiGraphics import net.minecraft.world.item.Item +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.isAltDown import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.playGuiClickSound @@ -22,7 +23,7 @@ open class InventorySlotPanel, out T : MatteryMenu.Inve get() = slot.filter?.get() set(value) { slot.filter?.accept(value) } - override fun renderBackgroundBeforeFilter(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun renderBackgroundBeforeFilter(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (slot.chargeFlag?.get() == true) { Widgets18.CHARGE_SLOT_BACKGROUND.render(graphics, 0f, 0f, width, height) } 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 a1361b096..4d8ab5c90 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 @@ -4,14 +4,13 @@ package ru.dbotthepony.mc.otm.client.screen.panels.slot import com.mojang.blaze3d.systems.RenderSystem import net.minecraft.ChatFormatting -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.renderer.GameRenderer import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.Widgets18 -import ru.dbotthepony.mc.otm.client.render.renderRect import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.ISlotPanel @@ -52,7 +51,7 @@ open class SlotPanel, out T : Slot> @JvmOverloads const } } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { slot.x = absoluteX.roundToInt() - screen.guiLeft slot.y = absoluteY.roundToInt() - screen.guiTop renderSlotBackground(graphics, mouseX, mouseY, partialTick) @@ -99,7 +98,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()) - graphics.blit(1, 1, 0, 16, 16, texture) + graphics.renderSprite(texture, 1f, 1f, 16f, 16f) } else { slotBackgroundEmpty?.render(graphics, 0f, 0f, width = width, height = height) } @@ -112,7 +111,7 @@ open class SlotPanel, out T : Slot> @JvmOverloads const } } - override fun innerRenderTooltips(@Nonnull graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun innerRenderTooltips(@Nonnull graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { // no op, screen does it for us (completely) return false } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt index 7c9ce2e35..bede6f80d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt @@ -9,10 +9,10 @@ import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraftforge.client.extensions.common.IClientItemExtensions +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.isCtrlDown import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.playGuiClickSound -import ru.dbotthepony.mc.otm.client.render.renderRect import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.GetterSetter @@ -32,9 +32,9 @@ abstract class UserFilteredSlotPanel, out T : Slot>( ) : SlotPanel(screen, parent, slot, x, y, width, height) { abstract var slotFilter: Item? - protected open fun renderBackgroundBeforeFilter(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {} + protected open fun renderBackgroundBeforeFilter(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {} - override fun renderSlotBackground(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun renderSlotBackground(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { super.renderSlotBackground(graphics, mouseX, mouseY, partialTick) renderBackgroundBeforeFilter(graphics, mouseX, mouseY, partialTick) @@ -53,7 +53,7 @@ abstract class UserFilteredSlotPanel, out T : Slot>( } } - override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { if (isHovered && slotFilter != null && slotFilter !== Items.AIR && itemStack.isEmpty) { val itemstack = ItemStack(slotFilter!!, 1) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/AnalogScrollBarPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/AnalogScrollBarPanel.kt index 3338d0506..6b494bae7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/AnalogScrollBarPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/AnalogScrollBarPanel.kt @@ -1,9 +1,8 @@ package ru.dbotthepony.mc.otm.client.screen.panels.util import com.mojang.blaze3d.platform.InputConstants -import com.mojang.blaze3d.vertex.PoseStack -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.core.math.linearInterpolation @@ -27,7 +26,7 @@ open class AnalogScrollBarPanel( var isScrolling = false private set - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (this@AnalogScrollBarPanel.width == ScrollBarConstants.SLIM_WIDTH) { if (isScrolling) { ScrollBarConstants.SLIM_BUTTON_PRESS.render(graphics, width = width, height = height) @@ -99,7 +98,7 @@ open class AnalogScrollBarPanel( private var lastRender = milliTimeD - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (width == ScrollBarConstants.SLIM_WIDTH) { ScrollBarConstants.SLIM_BODY.render(graphics, y = 2f, height = height - 4f) ScrollBarConstants.SLIM_TOP.render(graphics) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/BackgroundPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/BackgroundPanel.kt index 62ec2595b..12db90e3f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/BackgroundPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/BackgroundPanel.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.util -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.sprites.StretchingRectangleElement import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty @@ -19,7 +19,7 @@ open class BackgroundPanel( dockPadding = DockProperty(3f, 3f, 3f, 3f) } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { RECTANGLE.render(graphics, width = width, height = height) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/DiscreteScrollBarPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/DiscreteScrollBarPanel.kt index c5944e053..317b65d2c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/DiscreteScrollBarPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/DiscreteScrollBarPanel.kt @@ -1,9 +1,8 @@ package ru.dbotthepony.mc.otm.client.screen.panels.util import com.mojang.blaze3d.platform.InputConstants -import com.mojang.blaze3d.vertex.PoseStack -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import kotlin.math.roundToInt @@ -21,7 +20,7 @@ open class DiscreteScrollBarPanel( var isScrolling = false private set - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (this@DiscreteScrollBarPanel.width == ScrollBarConstants.SLIM_WIDTH) { if (isScrolling) { ScrollBarConstants.SLIM_BUTTON_PRESS.render(graphics, width = width, height = height) @@ -91,7 +90,7 @@ open class DiscreteScrollBarPanel( val scrollButton = Button() - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (width == ScrollBarConstants.SLIM_WIDTH) { ScrollBarConstants.SLIM_BODY.render(graphics, y = 2f, height = height - 4f) ScrollBarConstants.SLIM_TOP.render(graphics) 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 028c70702..d1541921a 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 @@ -1,12 +1,11 @@ package ru.dbotthepony.mc.otm.client.screen.storage -import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorPlayerSettings -import ru.dbotthepony.mc.otm.client.render.Widgets18 +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode @@ -14,8 +13,6 @@ import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.NetworkedItemGridPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.DeviceControls -import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeBooleanRectangleButtonPanel -import ru.dbotthepony.mc.otm.client.screen.panels.button.LargeEnumRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.SmallEnumRectangleButtonPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel @@ -24,7 +21,6 @@ import ru.dbotthepony.mc.otm.client.screen.panels.util.BackgroundPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel -import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.asGetterSetter @@ -73,7 +69,7 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp } val arrowAndButtons = object : EditablePanel(this@ItemMonitorScreen, bottomPanel, width = ProgressGaugePanel.GAUGE_BACKGROUND.width) { - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { ProgressGaugePanel.GAUGE_BACKGROUND.render(graphics, y = height / 2f - ProgressGaugePanel.GAUGE_BACKGROUND.height / 2f) } } 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 e1894af55..afdfb4583 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 @@ -6,7 +6,6 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectFunction import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import net.minecraft.ChatFormatting import net.minecraft.client.Minecraft -import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack @@ -14,15 +13,13 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.android.AndroidResearch import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidResearchType -import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.MatteryCapability +import ru.dbotthepony.mc.otm.client.MGUIGraphics 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.drawLine -import ru.dbotthepony.mc.otm.client.render.renderRect 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 @@ -287,7 +284,7 @@ private class AndroidResearchButton( } } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { val hovered = screen.hoveredResearch val isBlockedByHovered = hovered != null && node.type in hovered.type.allBlocking @@ -314,7 +311,7 @@ private class AndroidResearchButton( } else if (itemIcon != null) { val itemstack = ItemStack(itemIcon, 1) - val stack = graphics.pose() + val stack = graphics.pose stack.pushPose() stack.translate(1f, 1f, 0f) screen.renderItemStack(graphics, itemstack) @@ -334,7 +331,7 @@ private class AndroidResearchButton( val text = node.type.iconText if (text != null) { - graphics.drawString(font, text.visualOrderText, width - font.width(text), height - font.lineHeight, -0x1, true) + graphics.draw(font, text.visualOrderText, width - font.width(text), height - font.lineHeight, color = RGBAColor.WHITE, drawShadow = true) } for (line in lines) { @@ -408,7 +405,7 @@ private class AndroidResearchButton( return true } - override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { if (isHovered) { val list = ArrayList().also { it.addAll(node.screenTooltipLines) } @@ -501,7 +498,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I private var scroller: PreviewScrollers = PreviewScrollers.values().let { it[random.nextInt(it.size)] } private var firstTick = false - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { graphics.renderRect(0f, 0f, width, height, color = RGBAColor.BLACK) } @@ -648,7 +645,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I gravity = RenderGravity.TOP_RIGHT } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (menu.energyWidget.level >= MachinesConfig.AndroidStation.ENERGY_PER_RESEARCH) { text = POWER_OK color = RGBAColor.LIGHT_GREEN diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt index e6a65370d..9d88499be 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt @@ -1,8 +1,8 @@ package ru.dbotthepony.mc.otm.client.screen.tech -import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel @@ -61,7 +61,7 @@ class EnergyServoScreen(menu: EnergyServoMenu, inventory: Inventory, title: Comp width = ProgressGaugePanel.GAUGE_BACKGROUND.width } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { ProgressGaugePanel.GAUGE_BACKGROUND.render(graphics) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt index 9d8a4d725..c3cec2b2d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt @@ -1,12 +1,12 @@ package ru.dbotthepony.mc.otm.client.screen.tech import net.minecraft.ChatFormatting -import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.enchantment.Enchantments import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.render.sprites.MatteryAtlas @@ -57,7 +57,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title dockMargin = DockProperty(bottom = 3f) } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { BAR_BACKGROUND.render(graphics, width = width, height = height) val level = getLevelFromXp(menu.experienceStored) val progress = (menu.experienceStored - getTotalXpRequiredForLevel(level)).toDouble() / getXpRequiredForLevelUp(level).toDouble() 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 12dee13b7..2a7eb8e2e 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 @@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.client.screen.widget import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.DefaultVertexFormat import com.mojang.blaze3d.vertex.VertexFormat -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.client.renderer.GameRenderer import net.minecraft.network.chat.Component @@ -12,6 +11,7 @@ import net.minecraft.world.inventory.InventoryMenu import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions import org.lwjgl.opengl.GL11 import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite @@ -43,7 +43,7 @@ open class FluidGaugePanel( ) } - override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { if (isHovered) { graphics.renderComponentTooltip(font, makeTooltip(), mouseX.toInt(), mouseY.toInt()) return true @@ -52,7 +52,7 @@ open class FluidGaugePanel( return false } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (widget.percentage > 0.01f && widget.fluid.isNotEmpty) { val data = IClientFluidTypeExtensions.of(widget.fluid.fluid) val texture = data.stillTexture!! @@ -61,7 +61,7 @@ open class FluidGaugePanel( var height = (height * widget.percentage) / 16f var bottom = this.height - val matrix = graphics.pose().last().pose() + val matrix = graphics.pose.last().pose() val builder = tesselator.builder builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt index 6664b16c3..ba802387e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt @@ -2,13 +2,14 @@ package ru.dbotthepony.mc.otm.client.screen.widget import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget -private fun PowerGaugePanel<*>.doRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float, flop: Boolean) { +private fun PowerGaugePanel<*>.doRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float, flop: Boolean) { if (height >= 18f) { if (flop) { HorizontalPowerGaugePanel.GAUGE_BACKGROUND_TALL.render(graphics, height = height, width = this.width, winding = UVWindingOrder.U1_V0_U0_V1) @@ -43,7 +44,7 @@ open class HorizontalPowerGaugePanel( ) : PowerGaugePanel(screen, parent, widget, x, y, width, height) { var flop = false - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { doRender(graphics, mouseX, mouseY, partialTick, flop) } @@ -81,7 +82,7 @@ open class HorizontalProfiledPowerGaugePanel( ) : ProfiledPowerGaugePanel(screen, parent, widget, x, y, width, height) { var flop = false - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { doRender(graphics, mouseX, mouseY, partialTick, flop) } } 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 4a94e9d9c..6a4e7a8e6 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 @@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.client.screen.widget import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.BufferUploader import com.mojang.blaze3d.vertex.DefaultVertexFormat -import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.VertexFormat import it.unimi.dsi.fastutil.ints.IntArrayList import net.minecraft.ChatFormatting @@ -13,7 +12,7 @@ import net.minecraft.client.renderer.GameRenderer import net.minecraft.network.chat.Component import org.lwjgl.opengl.GL11 import ru.dbotthepony.mc.otm.capability.AbstractProfiledStorage -import ru.dbotthepony.mc.otm.capability.matter.ProfiledMatterStorage +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.minecraft @@ -25,7 +24,6 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.util.formatMatter import ru.dbotthepony.mc.otm.core.util.formatMatterLevel -import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.nanoTime @@ -61,7 +59,7 @@ open class MatterGaugePanel @JvmOverloads constructor( ) } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (lastAbsoluteX == 0f && lastAbsoluteY == 0f) { lastAbsoluteX = absoluteX lastAbsoluteY = absoluteY @@ -85,7 +83,7 @@ open class MatterGaugePanel @JvmOverloads constructor( } } - override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { if (isHovered) { graphics.renderComponentTooltip(font, makeTooltip(), mouseX.toInt(), mouseY.toInt()) return true @@ -98,9 +96,9 @@ open class MatterGaugePanel @JvmOverloads constructor( val GAUGE_BACKGROUND = WidgetLocation.VERTICAL_GAUGES.sprite(x = 18f, width = 9f) val GAUGE_FOREGROUND = WidgetLocation.VERTICAL_GAUGES.sprite(x = 27f, width = 9f) - fun renderLevel(graphics: GuiGraphics, x: Float, y: Float, width: Float, height: Float, percentage: Float, wavesStrength: Float = 0.5f) { - graphics.pose().pushPose() - graphics.pose().translate(x, y, 0f) + fun renderLevel(graphics: MGUIGraphics, x: Float, y: Float, width: Float, height: Float, percentage: Float, wavesStrength: Float = 0.5f) { + graphics.pose.pushPose() + graphics.pose.translate(x, y, 0f) RenderSystem.setShader(GameRenderer::getPositionTexShader) RenderSystem.enableBlend() RenderSystem.defaultBlendFunc() @@ -112,7 +110,7 @@ open class MatterGaugePanel @JvmOverloads constructor( val u1 = GAUGE_FOREGROUND.u1 val v1 = GAUGE_FOREGROUND.v1 - val matrix = graphics.pose().last().pose() + val matrix = graphics.pose.last().pose() val builder = tesselator.builder builder.begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_TEX) @@ -134,7 +132,7 @@ open class MatterGaugePanel @JvmOverloads constructor( } BufferUploader.drawWithShader(builder.end()) - graphics.pose().popPose() + graphics.pose.popPose() } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PatternGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PatternGaugePanel.kt index de68b55bf..445f1dd77 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PatternGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PatternGaugePanel.kt @@ -1,9 +1,8 @@ package ru.dbotthepony.mc.otm.client.screen.widget -import com.mojang.blaze3d.vertex.PoseStack -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.TranslatableComponent @@ -30,13 +29,13 @@ open class PatternGaugePanel @JvmOverloads constructor( ) } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { GAUGE_BACKGROUND.render(graphics) val height = this.height * widget.percentage GAUGE_FOREGROUND.renderPartial(graphics, y = this.height - height, height = height) } - override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { if (isHovered) { graphics.renderComponentTooltip(font, makeTooltip(), mouseX.toInt(), mouseY.toInt()) return true diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt index 4af6f338f..a5c9018d9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt @@ -2,11 +2,10 @@ package ru.dbotthepony.mc.otm.client.screen.widget import it.unimi.dsi.fastutil.ints.IntArrayList import net.minecraft.ChatFormatting -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.capability.AbstractProfiledStorage -import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.minecraft @@ -15,7 +14,6 @@ import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.stream import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.core.util.formatPowerLevel import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget @@ -41,7 +39,7 @@ open class PowerGaugePanel( ) } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { val height = this.height * widget.percentage if (width >= 18f) { @@ -63,7 +61,7 @@ open class PowerGaugePanel( } } - override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { if (isHovered) { graphics.renderComponentTooltip(font, makeTooltip(), mouseX.toInt(), mouseY.toInt()) return true diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt index 790691806..77627dafa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt @@ -2,12 +2,11 @@ package ru.dbotthepony.mc.otm.client.screen.widget import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.systems.RenderSystem -import com.mojang.blaze3d.vertex.PoseStack import mezz.jei.api.recipe.RecipeType import net.minecraft.ChatFormatting -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel @@ -62,7 +61,7 @@ open class ProgressGaugePanel( return tooltip } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (widget.isStuck && tickCount % 40 <= 20) { RenderSystem.setShaderColor(0.75f, 0.4f, 0.4f, 1f) } @@ -82,7 +81,7 @@ open class ProgressGaugePanel( } } - override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { if (shouldRenderTooltips(graphics, mouseX, mouseY, partialTick)) { graphics.renderComponentTooltip(font, makeTooltip(), mouseX.toInt(), mouseY.toInt()) return true diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt index 8a3c76fa4..4be4d81a8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt @@ -5,7 +5,6 @@ import lain.mods.cos.impl.ModObjects import lain.mods.cos.impl.client.PlayerRenderHandler import lain.mods.cos.impl.client.gui.GuiCosArmorInventory import lain.mods.cos.impl.network.packet.PacketSetSkinArmor -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer @@ -16,6 +15,7 @@ import net.minecraft.world.inventory.InventoryMenu import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack import net.minecraftforge.fml.ModList +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite import ru.dbotthepony.mc.otm.client.render.sprites.sprite @@ -175,7 +175,7 @@ class CosmeticToggleButton( } } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { val inv = ModObjects.invMan.getCosArmorInventoryClient(minecraft.player?.uuid ?: throw ConcurrentModificationException()) if (inv.isSkinArmor(index)) { @@ -214,7 +214,7 @@ class CosmeticToggleRenderButton( } } - override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { if (PlayerRenderHandler.Disabled) { BUTTON_ACTIVE.render(graphics, width = width, height = height) } else { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/Gauges.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/Gauges.kt index 47c690e47..0f95d5934 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/Gauges.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/Gauges.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.compat.jei import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel @@ -12,7 +13,7 @@ import ru.dbotthepony.mc.otm.core.util.formatPower import ru.dbotthepony.mc.otm.systemTime fun renderMatterGauge( - guiGraphics: GuiGraphics, + guiGraphics: MGUIGraphics, x: Float, y: Float, width: Float = MatterGaugePanel.GAUGE_BACKGROUND.width, @@ -25,7 +26,7 @@ fun renderMatterGauge( } fun renderEnergyGauge( - guiGraphics: GuiGraphics, + guiGraphics: MGUIGraphics, x: Float, y: Float, width: Float = PowerGaugePanel.GAUGE_BACKGROUND.width, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/IGUIRenderable2IDrawable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/IGUIRenderable2IDrawable.kt index 7b168ca96..78cf691fc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/IGUIRenderable2IDrawable.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/IGUIRenderable2IDrawable.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.compat.jei import mezz.jei.api.gui.drawable.IDrawable import net.minecraft.client.gui.GuiGraphics +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.IGUIRenderable class IGUIRenderable2IDrawable(val parent: IGUIRenderable) : IDrawable { @@ -14,6 +15,6 @@ class IGUIRenderable2IDrawable(val parent: IGUIRenderable) : IDrawable { } override fun draw(guiGraphics: GuiGraphics, xOffset: Int, yOffset: Int) { - parent.render(guiGraphics, xOffset.toFloat(), yOffset.toFloat()) + parent.render(MGUIGraphics(guiGraphics), xOffset.toFloat(), yOffset.toFloat()) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt index c01c26672..babfab971 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt @@ -11,6 +11,7 @@ import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.ItemStackIcon import ru.dbotthepony.mc.otm.client.render.draw @@ -63,21 +64,25 @@ object MatterEntanglerRecipeCategory : IRecipeCategory, } override fun draw(guiGraphics: GuiGraphics, xOffset: Int, yOffset: Int) { + val wrap = MGUIGraphics(guiGraphics) + for (x in 0 until 3) { for (y in 0 until 3) { - AbstractSlotPanel.SLOT_BACKGROUND.render(guiGraphics, xOffset + x * 18f + 29f, yOffset + y * 18f + 3f) + AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, xOffset + x * 18f + 29f, yOffset + y * 18f + 3f) } } - AbstractSlotPanel.SLOT_BACKGROUND.render(guiGraphics, xOffset + 115f, yOffset + 18f + 3f) - ProgressGaugePanel.GAUGE_BACKGROUND.render(guiGraphics, xOffset + 89f, yOffset + 18f + 4f) + AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, xOffset + 115f, yOffset + 18f + 3f) + ProgressGaugePanel.GAUGE_BACKGROUND.render(wrap, xOffset + 89f, yOffset + 18f + 4f) } override fun draw(recipe: IMatterEntanglerRecipe, recipeSlotsView: IRecipeSlotsView, guiGraphics: GuiGraphics, mouseX: Double, mouseY: Double) { - renderMatterGauge(guiGraphics, 13f, 6f, drainSpeed = (recipe.matter / Decimal(300)).toFloat()) - renderEnergyGauge(guiGraphics, 4f, 6f, drainSpeed = (recipe.ticks / 2000.0).toFloat()) + val wrap = MGUIGraphics(guiGraphics) - guiGraphics.draw(minecraft.font, x = 85f, y = 45f, text = TranslatableComponent("otm.gui.recipe.ticks", recipe.ticks), drawShadow = true) + renderMatterGauge(wrap, 13f, 6f, drainSpeed = (recipe.matter / Decimal(300)).toFloat()) + renderEnergyGauge(wrap, 4f, 6f, drainSpeed = (recipe.ticks / 2000.0).toFloat()) + + wrap.draw(wrap.font, x = 85f, y = 45f, text = TranslatableComponent("otm.gui.recipe.ticks", recipe.ticks), drawShadow = true) } override fun getTooltipStrings(recipe: IMatterEntanglerRecipe, recipeSlotsView: IRecipeSlotsView, mouseX: Double, mouseY: Double): MutableList { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt index aa44b00ca..b175faa32 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt @@ -13,6 +13,7 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Ingredient import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.draw @@ -52,12 +53,14 @@ object MicrowaveRecipeCategory : IRecipeCategory, IDrawable { @Suppress("name_shadowing") val yOffset = yOffset.toFloat() - AbstractSlotPanel.SLOT_BACKGROUND.render(graphics, X_INPUT + xOffset, Y_INPUT + yOffset) - AbstractSlotPanel.SLOT_BACKGROUND.render(graphics, X_OUTPUT + xOffset, Y_OUTPUT + yOffset) - ProgressGaugePanel.GAUGE_BACKGROUND.render(graphics, X_ARROW + xOffset, Y_ARROW + yOffset) + val wrap = MGUIGraphics(graphics) + + AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, X_INPUT + xOffset, Y_INPUT + yOffset) + AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, X_OUTPUT + xOffset, Y_OUTPUT + yOffset) + ProgressGaugePanel.GAUGE_BACKGROUND.render(wrap, X_ARROW + xOffset, Y_ARROW + yOffset) ProgressGaugePanel.GAUGE_FOREGROUND.renderPartial( - graphics, + wrap, X_ARROW + xOffset, Y_ARROW + yOffset, width = (((System.currentTimeMillis() % 4000L) / 4000f) * ProgressGaugePanel.GAUGE_FOREGROUND.width).roundToInt().toFloat()) @@ -70,12 +73,13 @@ object MicrowaveRecipeCategory : IRecipeCategory, IDrawable { mouseX: Double, mouseY: Double ) { - graphics.draw(minecraft.font, TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), 40f, 30f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK) + val wrap = MGUIGraphics(graphics) + wrap.draw(minecraft.font, TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), 40f, 30f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK) val average = recipe.experience.toString() if (average != "0.0") { - graphics.draw(minecraft.font, TranslatableComponent("gui.jei.category.smelting.experience", average), 40f, 1f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK) + wrap.draw(minecraft.font, TranslatableComponent("gui.jei.category.smelting.experience", average), 40f, 1f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK) } } 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 d6dfafbe4..8318337ea 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 @@ -14,6 +14,7 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.item.crafting.Ingredient import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.client.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 @@ -71,15 +72,17 @@ object PainterRecipeCategory : IRecipeCategory, IDrawable { } override fun draw(guiGraphics: GuiGraphics, xOffset: Int, yOffset: Int) { + val wrap = MGUIGraphics(guiGraphics) + for (x in 0 .. 1) { for (y in 0 .. 2) { - AbstractSlotPanel.SLOT_BACKGROUND.render(guiGraphics, xOffset.toFloat() + x * 18f, yOffset.toFloat() + y * 18f) + AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, xOffset.toFloat() + x * 18f, yOffset.toFloat() + y * 18f) } } - AbstractSlotPanel.SLOT_BACKGROUND.render(guiGraphics, xOffset.toFloat() + 49f, yOffset.toFloat() + 21f) - AbstractSlotPanel.SLOT_BACKGROUND.render(guiGraphics, xOffset.toFloat() + 99f, yOffset.toFloat() + 21f) + AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, xOffset.toFloat() + 49f, yOffset.toFloat() + 21f) + AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, xOffset.toFloat() + 99f, yOffset.toFloat() + 21f) - ProgressGaugePanel.GAUGE_BACKGROUND.render(guiGraphics, xOffset.toFloat() + 73f, yOffset.toFloat() + 22f) + ProgressGaugePanel.GAUGE_BACKGROUND.render(wrap, xOffset.toFloat() + 73f, yOffset.toFloat() + 22f) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt index b3955b5e1..4d2c5f4c2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt @@ -13,6 +13,7 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Ingredient import ru.dbotthepony.mc.otm.OverdriveThatMatters +import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.draw @@ -52,12 +53,14 @@ object PlatePressRecipeCategory : IRecipeCategory, IDrawable { @Suppress("name_shadowing") val yOffset = yOffset.toFloat() - AbstractSlotPanel.SLOT_BACKGROUND.render(graphics, X_INPUT + xOffset, Y_INPUT + yOffset) - AbstractSlotPanel.SLOT_BACKGROUND.render(graphics, X_OUTPUT + xOffset, Y_OUTPUT + yOffset) - ProgressGaugePanel.GAUGE_BACKGROUND.render(graphics, X_ARROW + xOffset, Y_ARROW + yOffset) + val wrap = MGUIGraphics(graphics) + + AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, X_INPUT + xOffset, Y_INPUT + yOffset) + AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, X_OUTPUT + xOffset, Y_OUTPUT + yOffset) + ProgressGaugePanel.GAUGE_BACKGROUND.render(wrap, X_ARROW + xOffset, Y_ARROW + yOffset) ProgressGaugePanel.GAUGE_FOREGROUND.renderPartial( - graphics, + wrap, X_ARROW + xOffset, Y_ARROW + yOffset, width = (((System.currentTimeMillis() % 4000L) / 4000f) * ProgressGaugePanel.GAUGE_FOREGROUND.width).roundToInt().toFloat()) @@ -70,12 +73,14 @@ object PlatePressRecipeCategory : IRecipeCategory, IDrawable { mouseX: Double, mouseY: Double ) { - graphics.draw(minecraft.font, TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), 40f, 30f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK) + val wrap = MGUIGraphics(graphics) + + wrap.draw(minecraft.font, TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), 40f, 30f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK) val average = recipe.experience.toString() if (average != "0.0") { - graphics.draw(minecraft.font, TranslatableComponent("gui.jei.category.smelting.experience", average), 40f, 1f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK) + wrap.draw(minecraft.font, TranslatableComponent("gui.jei.category.smelting.experience", average), 40f, 1f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK) } } From d81d7885c0018db2a580b0f378c7a97a866dcea2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 02:40:58 +0700 Subject: [PATCH 1168/1199] And move it to render subpackage --- .../mc/otm/android/AndroidSwitchableFeature.kt | 3 +-- .../android/feature/EnderTeleporterFeature.kt | 3 +-- .../mc/otm/android/feature/ItemMagnetFeature.kt | 3 +-- .../mc/otm/android/feature/JumpBoostFeature.kt | 3 +-- .../otm/android/feature/NightVisionFeature.kt | 3 +-- .../mc/otm/android/feature/ShockwaveFeature.kt | 3 +-- .../mc/otm/android/feature/StepAssistFeature.kt | 4 +--- .../otm/android/feature/SwimBoostersFeature.kt | 3 +-- .../mc/otm/client/AndroidAbilityKeyMapping.kt | 3 +-- .../mc/otm/client/AndroidMenuKeyMapping.kt | 3 +-- .../mc/otm/client/render/IGUIRenderable.kt | 4 ---- .../mc/otm/client/{ => render}/MGUIGraphics.kt | 17 ++++++----------- .../mc/otm/client/render/RenderHelper.kt | 1 - .../render/sprites/AbstractMatterySprite.kt | 3 +-- .../sprites/StretchingRectangleElement.kt | 3 +-- .../mc/otm/client/screen/MatteryScreen.kt | 2 +- .../client/screen/decorative/PainterScreen.kt | 2 +- .../client/screen/matter/MatterPanelScreen.kt | 2 +- .../mc/otm/client/screen/panels/ColorPicker.kt | 3 +-- .../otm/client/screen/panels/EditablePanel.kt | 2 +- .../otm/client/screen/panels/EffectListPanel.kt | 3 +-- .../client/screen/panels/EntityRendererPanel.kt | 2 +- .../mc/otm/client/screen/panels/FramePanel.kt | 2 +- .../mc/otm/client/screen/panels/Label.kt | 3 +-- .../screen/panels/NetworkedItemGridPanel.kt | 2 +- .../mc/otm/client/screen/panels/Panel2Widget.kt | 2 +- .../mc/otm/client/screen/panels/SpritePanel.kt | 2 +- .../mc/otm/client/screen/panels/Widget2Panel.kt | 2 +- .../screen/panels/button/AbstractButtonPanel.kt | 2 +- .../button/BooleanRectangleButtonPanel.kt | 2 +- .../client/screen/panels/button/ButtonPanel.kt | 4 +--- .../otm/client/screen/panels/button/Buttons.kt | 2 +- .../screen/panels/button/CheckBoxPanel.kt | 3 +-- .../panels/button/EnumRectangleButtonPanel.kt | 2 +- .../panels/button/LargeRectangleButtonPanel.kt | 2 +- .../panels/button/RectangleButtonPanel.kt | 3 +-- .../panels/button/SmallRectangleButtonPanel.kt | 2 +- .../screen/panels/input/TextInputPanel.kt | 3 +-- .../screen/panels/slot/AbstractSlotPanel.kt | 2 +- .../screen/panels/slot/InventorySlotPanel.kt | 3 +-- .../otm/client/screen/panels/slot/SlotPanel.kt | 2 +- .../screen/panels/slot/UserFilteredSlotPanel.kt | 3 +-- .../screen/panels/util/AnalogScrollBarPanel.kt | 2 +- .../screen/panels/util/BackgroundPanel.kt | 2 +- .../panels/util/DiscreteScrollBarPanel.kt | 2 +- .../client/screen/storage/ItemMonitorScreen.kt | 2 +- .../client/screen/tech/AndroidStationScreen.kt | 2 +- .../otm/client/screen/tech/EnergyServoScreen.kt | 2 +- .../client/screen/tech/EssenceStorageScreen.kt | 2 +- .../otm/client/screen/widget/FluidGaugePanel.kt | 2 +- .../screen/widget/HorizontalPowerGaugePanel.kt | 3 +-- .../client/screen/widget/MatterGaugePanel.kt | 3 +-- .../client/screen/widget/PatternGaugePanel.kt | 2 +- .../otm/client/screen/widget/PowerGaugePanel.kt | 2 +- .../client/screen/widget/ProgressGaugePanel.kt | 2 +- .../mc/otm/compat/cos/CosmeticArmorCompat.kt | 2 +- .../ru/dbotthepony/mc/otm/compat/jei/Gauges.kt | 3 +-- .../otm/compat/jei/IGUIRenderable2IDrawable.kt | 2 +- .../compat/jei/MatterEntanglerRecipeCategory.kt | 4 +--- .../otm/compat/jei/MicrowaveRecipeCategory.kt | 3 +-- .../mc/otm/compat/jei/PainterRecipeCategory.kt | 2 +- .../otm/compat/jei/PlatePressRecipeCategory.kt | 3 +-- 62 files changed, 65 insertions(+), 105 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/{ => render}/MGUIGraphics.kt (88%) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt index 180729b85..13ab36b84 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt @@ -1,10 +1,9 @@ package ru.dbotthepony.mc.otm.android -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.nbt.CompoundTag import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.nbt.set diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt index fc5610e7f..a8b1dd50d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt @@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.android.feature import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.Camera -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.renderer.LevelRenderer import net.minecraft.core.BlockPos import net.minecraft.core.Direction @@ -30,7 +29,7 @@ import ru.dbotthepony.mc.otm.android.AndroidActiveFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.capability.matteryPlayer -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.client.render.linesIgnoreZRenderType diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt index 68f0eed77..1ddcd7f3b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.android.feature -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.network.FriendlyByteBuf import net.minecraft.world.entity.Entity @@ -9,7 +8,7 @@ import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.core.math.Vector diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt index 910214ce3..d92f68fbe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt @@ -1,6 +1,5 @@ package ru.dbotthepony.mc.otm.android.feature -import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.FriendlyByteBuf import net.minecraft.server.level.ServerPlayer import net.minecraft.sounds.SoundSource @@ -8,7 +7,7 @@ import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.capability.matteryPlayer -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.config.ClientConfig diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt index 9c124ea68..ad3ead63a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NightVisionFeature.kt @@ -1,12 +1,11 @@ package ru.dbotthepony.mc.otm.android.feature -import net.minecraft.client.gui.GuiGraphics import net.minecraft.world.effect.MobEffectInstance import net.minecraft.world.effect.MobEffects import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.core.math.RGBAColor diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt index b987457e8..fe37b9113 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.android.feature import it.unimi.dsi.fastutil.objects.ReferenceArraySet -import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.FriendlyByteBuf import net.minecraft.server.level.ServerPlayer import net.minecraft.sounds.SoundSource @@ -12,7 +11,7 @@ import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact import ru.dbotthepony.mc.otm.capability.matteryPlayer -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.core.damageType diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/StepAssistFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/StepAssistFeature.kt index ead87ccd9..74a4f7a3b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/StepAssistFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/StepAssistFeature.kt @@ -1,12 +1,10 @@ package ru.dbotthepony.mc.otm.android.feature -import com.mojang.blaze3d.vertex.PoseStack -import net.minecraft.client.gui.GuiGraphics import net.minecraft.world.entity.ai.attributes.AttributeModifier import net.minecraftforge.common.ForgeMod import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.registry.AndroidFeatures diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/SwimBoostersFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/SwimBoostersFeature.kt index 8938b8a23..3129d4a24 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/SwimBoostersFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/SwimBoostersFeature.kt @@ -1,11 +1,10 @@ package ru.dbotthepony.mc.otm.android.feature -import net.minecraft.client.gui.GuiGraphics import net.minecraft.world.entity.ai.attributes.AttributeModifier import net.minecraftforge.common.ForgeMod import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.core.math.RGBAColor diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt index d6882919d..d3301a692 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.client import com.mojang.blaze3d.platform.InputConstants -import com.mojang.blaze3d.systems.RenderSystem import net.minecraft.client.KeyMapping import net.minecraftforge.client.event.RegisterKeyMappingsEvent import net.minecraftforge.client.event.RenderGuiEvent @@ -10,8 +9,8 @@ import net.minecraftforge.client.settings.KeyConflictContext import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.android.AndroidActiveFeature import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.Widgets18 -import ru.dbotthepony.mc.otm.client.render.renderRect import ru.dbotthepony.mc.otm.client.render.is3DContext import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.network.ActivateAndroidFeaturePacket diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt index 086aaf640..4e1ffa3f3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt @@ -13,10 +13,9 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.android.AndroidFeature import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.RenderGravity -import ru.dbotthepony.mc.otm.client.render.draw import ru.dbotthepony.mc.otm.client.render.drawArc -import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.angleDifference import ru.dbotthepony.mc.otm.core.math.normalizeAngle diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt index acb2bc00d..e73213175 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/IGUIRenderable.kt @@ -1,11 +1,7 @@ package ru.dbotthepony.mc.otm.client.render -import net.minecraft.client.gui.GuiGraphics import net.minecraft.world.item.ItemStack -import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.core.math.RGBAColor -import ru.dbotthepony.mc.otm.systemTime -import kotlin.math.sin interface IGUIRenderable { /** diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MGUIGraphics.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt similarity index 88% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/MGUIGraphics.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt index 868fb7354..398106369 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MGUIGraphics.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.mc.otm.client +package ru.dbotthepony.mc.otm.client.render import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.Font @@ -9,12 +9,7 @@ import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation import net.minecraft.util.FormattedCharSequence import net.minecraft.world.item.ItemStack -import ru.dbotthepony.mc.otm.client.render.GravityRounding -import ru.dbotthepony.mc.otm.client.render.IUVCoords -import ru.dbotthepony.mc.otm.client.render.RenderGravity -import ru.dbotthepony.mc.otm.client.render.UVCoords -import ru.dbotthepony.mc.otm.client.render.UVWindingOrder -import ru.dbotthepony.mc.otm.client.render.draw +import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.math.RGBAColor // polyfill class for 1.19.4 and older @@ -42,7 +37,7 @@ class MGUIGraphics(val parent: GuiGraphics) { z: Float = 0f, color: RGBAColor = RGBAColor.WHITE ) { - ru.dbotthepony.mc.otm.client.render.drawLine(pose.last().pose(), startX, startY, endX, endY, width, z, color) + drawLine(pose.last().pose(), startX, startY, endX, endY, width, z, color) } fun renderRect( @@ -53,7 +48,7 @@ class MGUIGraphics(val parent: GuiGraphics) { z: Float = 0f, color: RGBAColor = RGBAColor.WHITE ) { - ru.dbotthepony.mc.otm.client.render.renderRect(pose.last().pose(), x, y, width, height, z, color) + renderRect(pose.last().pose(), x, y, width, height, z, color) } fun renderTexturedRect( @@ -67,7 +62,7 @@ class MGUIGraphics(val parent: GuiGraphics) { color: RGBAColor = RGBAColor.WHITE, texture: ResourceLocation? = null ) { - ru.dbotthepony.mc.otm.client.render.renderTexturedRect(pose.last().pose(), x, y, width, height, z, uv, uvWinding, color, texture) + renderTexturedRect(pose.last().pose(), x, y, width, height, z, uv, uvWinding, color, texture) } fun renderCheckerboard( @@ -78,7 +73,7 @@ class MGUIGraphics(val parent: GuiGraphics) { z: Float = 0f, color: RGBAColor = RGBAColor.WHITE ) { - ru.dbotthepony.mc.otm.client.render.renderCheckerboard(pose.last().pose(), x, y, width, height, z, color) + renderCheckerboard(pose.last().pose(), x, y, width, height, z, color) } fun renderComponentTooltip(font: Font, lines: MutableList, x: Int, y: Int, itemStack: ItemStack = ItemStack.EMPTY) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt index 4e5d00d33..26738c334 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt @@ -17,7 +17,6 @@ import org.joml.Matrix4f import org.lwjgl.opengl.GL11.GL_ALWAYS import org.lwjgl.opengl.GL11.GL_LESS import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.client.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.math.RGBAColor import java.util.* diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/AbstractMatterySprite.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/AbstractMatterySprite.kt index aced04306..09013d598 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/AbstractMatterySprite.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/AbstractMatterySprite.kt @@ -6,14 +6,13 @@ import com.mojang.blaze3d.vertex.DefaultVertexFormat import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.VertexConsumer import com.mojang.blaze3d.vertex.VertexFormat -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.renderer.GameRenderer import net.minecraft.client.renderer.RenderStateShard import net.minecraft.client.renderer.RenderType import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation import org.lwjgl.opengl.GL11.GL_ALWAYS -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.render.IUVCoords import ru.dbotthepony.mc.otm.client.render.UVWindingOrder diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/StretchingRectangleElement.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/StretchingRectangleElement.kt index 9a37f6359..bc68a78e1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/StretchingRectangleElement.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/StretchingRectangleElement.kt @@ -1,9 +1,8 @@ package ru.dbotthepony.mc.otm.client.render.sprites import com.mojang.blaze3d.vertex.PoseStack -import net.minecraft.client.gui.GuiGraphics import net.minecraft.resources.ResourceLocation -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty data class StretchingRectangleElement( 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 7f4165f5a..1121a8146 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 @@ -17,7 +17,7 @@ import net.minecraftforge.client.event.ContainerScreenEvent.Render.Foreground import net.minecraftforge.common.MinecraftForge import org.lwjgl.opengl.GL11 import ru.dbotthepony.mc.otm.capability.matteryPlayer -import ru.dbotthepony.mc.otm.client.MGUIGraphics +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 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 8ea0afa09..1d278384c 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 @@ -10,7 +10,7 @@ import net.minecraft.world.item.Items import net.minecraftforge.common.Tags import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.block.entity.decorative.PainterBlockEntity -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.FlatRectangleIcon import ru.dbotthepony.mc.otm.client.render.ItemStackIcon import ru.dbotthepony.mc.otm.client.screen.MatteryScreen 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 fe58af574..0bf986089 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 @@ -6,7 +6,7 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.capability.matter.PatternState import ru.dbotthepony.mc.otm.capability.matter.ReplicationTask -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.client.screen.MatteryScreen diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt index e37365d4b..bd2fa0f0c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ColorPicker.kt @@ -3,12 +3,11 @@ package ru.dbotthepony.mc.otm.client.screen.panels import com.mojang.blaze3d.platform.InputConstants import com.mojang.datafixers.util.Either import it.unimi.dsi.fastutil.floats.FloatConsumer -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite import ru.dbotthepony.mc.otm.client.render.RenderGravity 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 f4c776c13..bde047208 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 @@ -17,7 +17,7 @@ import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.SystemTime -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.moveMousePosScaled import ru.dbotthepony.mc.otm.client.render.currentScissorRect diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt index faea0c2f1..dbd05d60d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt @@ -8,11 +8,10 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.world.effect.MobEffect import net.minecraft.world.effect.MobEffectInstance import net.minecraft.world.entity.LivingEntity -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.determineTooltipPosition -import ru.dbotthepony.mc.otm.client.render.draw import ru.dbotthepony.mc.otm.client.render.sprites.sprite import ru.dbotthepony.mc.otm.client.render.render import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt index 59cc05a94..002ba34d3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt @@ -7,7 +7,7 @@ import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.player.Player import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.Widgets8 import ru.dbotthepony.mc.otm.client.render.sprites.sprite import ru.dbotthepony.mc.otm.client.screen.ExopackInventoryScreen diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index adcb9d5b0..dfd6eb4fe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -8,7 +8,7 @@ import net.minecraft.client.gui.narration.NarrationElementOutput import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import org.lwjgl.opengl.GL30 -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.client.render.sprites.StretchingRectangleElement import ru.dbotthepony.mc.otm.client.screen.panels.button.AbstractButtonPanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt index 413eb8510..d1559d418 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt @@ -2,9 +2,8 @@ package ru.dbotthepony.mc.otm.client.screen.panels import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.RenderGravity -import ru.dbotthepony.mc.otm.client.render.draw import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.math.RGBAColor diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/NetworkedItemGridPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/NetworkedItemGridPanel.kt index 4c6463c0c..31c78b628 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/NetworkedItemGridPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/NetworkedItemGridPanel.kt @@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels import net.minecraft.ChatFormatting import net.minecraft.network.chat.Component import net.minecraft.world.item.ItemStack -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel 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 722af0a2b..e4664f2bd 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 @@ -4,7 +4,7 @@ import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.components.Renderable import net.minecraft.client.gui.components.events.GuiEventListener import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics // before 1.19.3 Renderable was Widget class Panel2Widget>( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SpritePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SpritePanel.kt index 14a17b776..2e2b610e3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SpritePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SpritePanel.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.sprites.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.UVWindingOrder diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Widget2Panel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Widget2Panel.kt index 4b6a35793..ca49c74fb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Widget2Panel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Widget2Panel.kt @@ -4,7 +4,7 @@ import com.mojang.blaze3d.systems.RenderSystem import net.minecraft.client.gui.components.AbstractWidget import net.minecraft.client.gui.screens.Screen import org.lwjgl.opengl.GL11 -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics abstract class Widget2Panel( screen: S, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractButtonPanel.kt index f2ebc5a4c..e1da380a4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractButtonPanel.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import com.mojang.blaze3d.platform.InputConstants import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import java.util.function.IntPredicate diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt index 4a8469438..2ca9ba092 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt @@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import net.minecraft.ChatFormatting import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt index ea5b0185b..266022db8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt @@ -1,12 +1,10 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.Widgets18 -import ru.dbotthepony.mc.otm.client.render.draw import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.math.RGBAColor import java.util.function.IntConsumer 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 a1c78aebe..9d6c1ded8 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 @@ -9,7 +9,7 @@ import ru.dbotthepony.mc.otm.block.entity.MatteryDeviceBlockEntity import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.addUpgradeTooltipLines -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.isCtrlDown import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.minecraft diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt index e92a13106..7e7fa776f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/CheckBoxPanel.kt @@ -1,8 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.sprites.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt index d2af01f0d..ede8a66dd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt @@ -4,7 +4,7 @@ import com.mojang.blaze3d.platform.InputConstants import net.minecraft.ChatFormatting import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.render.UVWindingOrder diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt index 718230f23..be7a3cc60 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/LargeRectangleButtonPanel.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.render.UVWindingOrder diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/RectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/RectangleButtonPanel.kt index 16afdc8c9..3f862a190 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/RectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/RectangleButtonPanel.kt @@ -1,8 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import java.util.function.IntConsumer diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallRectangleButtonPanel.kt index a6bf44fb3..b7b5a1cf6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/SmallRectangleButtonPanel.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.button import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.Widgets8 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt index b1a63bc0a..fe39fa45c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt @@ -13,14 +13,13 @@ import net.minecraft.client.gui.screens.Screen import net.minecraft.client.renderer.GameRenderer import net.minecraft.network.chat.Component import org.joml.Vector2i -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.isCtrlDown import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.playGuiClickSound 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.tesselator import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt index 6d4f7bbb6..1ce1d3d89 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt @@ -6,7 +6,7 @@ import net.minecraft.client.renderer.GameRenderer import net.minecraft.network.chat.Component import net.minecraft.world.item.ItemStack import net.minecraftforge.client.extensions.common.IClientItemExtensions -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt index 5e044dc99..caa01f6aa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt @@ -1,9 +1,8 @@ package ru.dbotthepony.mc.otm.client.screen.panels.slot import com.mojang.blaze3d.platform.InputConstants -import net.minecraft.client.gui.GuiGraphics import net.minecraft.world.item.Item -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.isAltDown import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.playGuiClickSound 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 4d8ab5c90..41da7dc50 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 @@ -8,7 +8,7 @@ import net.minecraft.client.renderer.GameRenderer import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.MatteryScreen diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt index bede6f80d..a1a1989f5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt @@ -2,14 +2,13 @@ package ru.dbotthepony.mc.otm.client.screen.panels.slot import com.mojang.blaze3d.platform.InputConstants import net.minecraft.ChatFormatting -import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component import net.minecraft.world.inventory.Slot import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraftforge.client.extensions.common.IClientItemExtensions -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.isCtrlDown import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.playGuiClickSound diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/AnalogScrollBarPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/AnalogScrollBarPanel.kt index 6b494bae7..83a7f8f7d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/AnalogScrollBarPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/AnalogScrollBarPanel.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.util import com.mojang.blaze3d.platform.InputConstants import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.core.math.linearInterpolation diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/BackgroundPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/BackgroundPanel.kt index 12db90e3f..c2f416be8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/BackgroundPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/BackgroundPanel.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.util import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.sprites.StretchingRectangleElement import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/DiscreteScrollBarPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/DiscreteScrollBarPanel.kt index 317b65d2c..e5f9a23f2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/DiscreteScrollBarPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/util/DiscreteScrollBarPanel.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.util import com.mojang.blaze3d.platform.InputConstants import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import kotlin.math.roundToInt 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 d1541921a..03ea70ec7 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 @@ -5,7 +5,7 @@ import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import ru.dbotthepony.mc.otm.block.entity.storage.ItemMonitorPlayerSettings -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode 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 afdfb4583..1b83c199e 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 @@ -15,7 +15,7 @@ import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.android.AndroidResearchType import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.MatteryCapability -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.render.RenderGravity diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt index 9d88499be..658283ef4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.tech import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt index c3cec2b2d..ae05cd7f8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt @@ -6,7 +6,7 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.player.Inventory import net.minecraft.world.item.enchantment.Enchantments import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.playGuiClickSound import ru.dbotthepony.mc.otm.client.render.sprites.MatteryAtlas 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 2a7eb8e2e..670246d22 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 @@ -11,7 +11,7 @@ import net.minecraft.world.inventory.InventoryMenu import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions import org.lwjgl.opengl.GL11 import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt index ba802387e..60cbc2ed8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt @@ -1,8 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.widget -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel 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 6a4e7a8e6..c31f5db8a 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 @@ -6,13 +6,12 @@ import com.mojang.blaze3d.vertex.DefaultVertexFormat import com.mojang.blaze3d.vertex.VertexFormat import it.unimi.dsi.fastutil.ints.IntArrayList import net.minecraft.ChatFormatting -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.screens.Screen import net.minecraft.client.renderer.GameRenderer import net.minecraft.network.chat.Component import org.lwjgl.opengl.GL11 import ru.dbotthepony.mc.otm.capability.AbstractProfiledStorage -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.minecraft diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PatternGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PatternGaugePanel.kt index 445f1dd77..669a3d969 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PatternGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PatternGaugePanel.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.widget import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.TranslatableComponent diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt index a5c9018d9..51bc1a6c4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt @@ -5,7 +5,7 @@ import net.minecraft.ChatFormatting import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.capability.AbstractProfiledStorage -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.minecraft diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt index 77627dafa..97f7e4205 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/ProgressGaugePanel.kt @@ -6,7 +6,7 @@ import mezz.jei.api.recipe.RecipeType import net.minecraft.ChatFormatting import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt index 4be4d81a8..9ad73c8cd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt @@ -15,7 +15,7 @@ import net.minecraft.world.inventory.InventoryMenu import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack import net.minecraftforge.fml.ModList -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite import ru.dbotthepony.mc.otm.client.render.sprites.sprite diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/Gauges.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/Gauges.kt index 0f95d5934..e6751c646 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/Gauges.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/Gauges.kt @@ -1,8 +1,7 @@ package ru.dbotthepony.mc.otm.compat.jei -import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/IGUIRenderable2IDrawable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/IGUIRenderable2IDrawable.kt index 78cf691fc..540c861cb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/IGUIRenderable2IDrawable.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/IGUIRenderable2IDrawable.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.compat.jei import mezz.jei.api.gui.drawable.IDrawable import net.minecraft.client.gui.GuiGraphics -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.IGUIRenderable class IGUIRenderable2IDrawable(val parent: IGUIRenderable) : IDrawable { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt index babfab971..bb65b63b0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt @@ -11,10 +11,8 @@ import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.client.MGUIGraphics -import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.ItemStackIcon -import ru.dbotthepony.mc.otm.client.render.draw import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.config.MachinesConfig diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt index b175faa32..bd723a9a9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt @@ -13,10 +13,9 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Ingredient import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.RenderGravity -import ru.dbotthepony.mc.otm.client.render.draw 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.math.RGBAColor 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 8318337ea..50bb55cea 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 @@ -14,7 +14,7 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.item.crafting.Ingredient import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.client.MGUIGraphics +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 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt index 4d2c5f4c2..cda8914e9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt @@ -13,10 +13,9 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Ingredient import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.client.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.RenderGravity -import ru.dbotthepony.mc.otm.client.render.draw 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.math.RGBAColor From 1dab485d29e61e2755f0c3a01f12ad37d73b26e0 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 02:46:00 +0700 Subject: [PATCH 1169/1199] Specify font implicitly --- .../mc/otm/client/AndroidMenuKeyMapping.kt | 8 ++--- .../dbotthepony/mc/otm/client/MatteryGUI.kt | 12 +++---- .../mc/otm/client/render/MGUIGraphics.kt | 6 ++-- .../client/screen/matter/MatterPanelScreen.kt | 1 - .../client/screen/panels/EffectListPanel.kt | 6 ++-- .../mc/otm/client/screen/panels/FramePanel.kt | 2 +- .../mc/otm/client/screen/panels/Label.kt | 36 +++++++++---------- .../screen/panels/NetworkedItemGridPanel.kt | 2 +- .../screen/panels/button/ButtonPanel.kt | 2 +- .../screen/panels/input/TextInputPanel.kt | 6 ---- .../screen/tech/AndroidStationScreen.kt | 2 +- .../jei/MatterEntanglerRecipeCategory.kt | 2 +- .../otm/compat/jei/MicrowaveRecipeCategory.kt | 4 +-- .../compat/jei/PlatePressRecipeCategory.kt | 4 +-- 14 files changed, 43 insertions(+), 50 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt index 4e1ffa3f3..cfbb165af 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt @@ -259,15 +259,15 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon val shift = size * 0.6f feature.renderIcon(wrap, -iconSize / 2f + shift * cos, -shift * sin - iconSize / 2f, iconSize, iconSize) - wrap.draw(minecraft.font, feature.type.displayName, shift * cos + 1f, -shift * sin - iconSize / 1.5f + 1f, color = RGBAColor.BLACK, gravity = RenderGravity.CENTER_CENTER) - wrap.draw(minecraft.font, feature.type.displayName, shift * cos, -shift * sin - iconSize / 1.5f, color = if (feature.isActive) RGBAColor.DARK_GREEN else RGBAColor.DARK_RED, gravity = RenderGravity.CENTER_CENTER) + wrap.draw(feature.type.displayName, shift * cos + 1f, -shift * sin - iconSize / 1.5f + 1f, color = RGBAColor.BLACK, gravity = RenderGravity.CENTER_CENTER) + wrap.draw(feature.type.displayName, shift * cos, -shift * sin - iconSize / 1.5f, color = if (feature.isActive) RGBAColor.DARK_GREEN else RGBAColor.DARK_RED, gravity = RenderGravity.CENTER_CENTER) if (feature.isOnCooldown && feature.cooldownPercent > 0.0f) { RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f) drawArc(event.guiGraphics, shift * cos, -shift * sin, iconSize / 2f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * feature.cooldownPercent.toDouble()) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) - wrap.draw(minecraft.font, formatTickDuration(feature.cooldown), shift * cos, -shift * sin + iconSize / 1.5f, color = RGBAColor.WHITE, gravity = RenderGravity.CENTER_CENTER) + wrap.draw(formatTickDuration(feature.cooldown), shift * cos, -shift * sin + iconSize / 1.5f, color = RGBAColor.WHITE, gravity = RenderGravity.CENTER_CENTER) } } @@ -305,7 +305,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon drawArc(event.guiGraphics, x, y, COOLDOWN_ICON_SIZE / 2f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * feature.cooldownPercent, alignAtCenter = false) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) - wrap.draw(font, formatTickDuration(feature.cooldown), x + COOLDOWN_ICON_SIZE / 2f, y + COOLDOWN_ICON_SIZE + 1f, color = RGBAColor.WHITE, gravity = RenderGravity.TOP_CENTER) + wrap.draw(formatTickDuration(feature.cooldown), x + COOLDOWN_ICON_SIZE / 2f, y + COOLDOWN_ICON_SIZE + 1f, color = RGBAColor.WHITE, gravity = RenderGravity.TOP_CENTER) x += COOLDOWN_ICON_SIZE + COOLDOWN_ICON_MARGIN } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index 737b26927..d92fe7610 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -174,8 +174,8 @@ object MatteryGUI { val text = TranslatableComponent("otm.iteration", iteration) - guiGraphics.draw(minecraft.font, text, x + 1f, y + 1f, color = RGBAColor.BLACK, gravity = RenderGravity.CENTER_CENTER) - guiGraphics.draw(minecraft.font, text, x, y, color = RGBAColor.WHITE, gravity = RenderGravity.CENTER_CENTER) + guiGraphics.draw(text, x + 1f, y + 1f, color = RGBAColor.BLACK, gravity = RenderGravity.CENTER_CENTER) + guiGraphics.draw(text, x, y, color = RGBAColor.WHITE, gravity = RenderGravity.CENTER_CENTER) stack.scale(0.35f, 0.35f, 0.35f) @@ -191,8 +191,8 @@ object MatteryGUI { for (i in deathLog.indices.reversed()) { val component = deathLog[i] - guiGraphics.draw(minecraft.font, component.second, x + 1f, y + 1f, color = RGBAColor.BLACK, gravity = RenderGravity.CENTER_CENTER) - guiGraphics.draw(minecraft.font, component.second, x, y, color = RGBAColor(color, color, color), gravity = RenderGravity.CENTER_CENTER) + guiGraphics.draw(component.second, x + 1f, y + 1f, color = RGBAColor.BLACK, gravity = RenderGravity.CENTER_CENTER) + guiGraphics.draw(component.second, x, y, color = RGBAColor(color, color, color), gravity = RenderGravity.CENTER_CENTER) y += minecraft.font.lineHeight color = (color - 0x20).coerceAtLeast(0x0) @@ -266,7 +266,7 @@ object MatteryGUI { val formattedPower = mattery.androidEnergy.batteryLevel.formatPower() val scale = ClientConfig.HUD.BAR_TEXT_SCALE.toFloat() - guiGraphics.draw(gui.font, formattedPower, left + CHARGE_BG.width + 2f + scale, top + CHARGE_BG.height / 2f + scale, scale = scale, gravity = RenderGravity.CENTER_LEFT, color = RGBAColor.YELLOW, drawOutline = true) + guiGraphics.draw(formattedPower, left + CHARGE_BG.width + 2f + scale, top + CHARGE_BG.height / 2f + scale, font = gui.font, scale = scale, gravity = RenderGravity.CENTER_LEFT, color = RGBAColor.YELLOW, drawOutline = true) } } @@ -345,7 +345,7 @@ object MatteryGUI { formattedHealth = TextComponent("%d+%d/%d".format(ply.health.toInt(), ply.absorptionAmount.toInt(), ply.maxHealth.toInt())) val scale = ClientConfig.HUD.BAR_TEXT_SCALE.toFloat() - guiGraphics.draw(minecraft.font, formattedHealth, left - 2f, top + HEALTH_BG.height / 2f + 1f * scale, scale = scale, gravity = RenderGravity.CENTER_RIGHT, color = getHealthColorForPlayer(ply), drawOutline = true) + guiGraphics.draw(formattedHealth, left - 2f, top + HEALTH_BG.height / 2f + 1f * scale, scale = scale, gravity = RenderGravity.CENTER_RIGHT, color = getHealthColorForPlayer(ply), drawOutline = true) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt index 398106369..198ca4cd9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt @@ -85,7 +85,6 @@ class MGUIGraphics(val parent: GuiGraphics) { } fun draw( - font: Font, text: String, x: Float = 0f, y: Float = 0f, @@ -105,6 +104,7 @@ class MGUIGraphics(val parent: GuiGraphics) { drawOutline: Boolean = false, outlineColor: RGBAColor = RGBAColor.BLACK, outlineZ: Float = -0.1f, + font: Font = this.font, ): Float { val width = font.draw( poseStack = pose, @@ -135,7 +135,6 @@ class MGUIGraphics(val parent: GuiGraphics) { } fun draw( - font: Font, text: Component, x: Float = 0f, y: Float = 0f, @@ -155,6 +154,7 @@ class MGUIGraphics(val parent: GuiGraphics) { drawOutline: Boolean = false, outlineColor: RGBAColor = RGBAColor.BLACK, outlineZ: Float = -0.1f, + font: Font = this.font, ): Float { val width = font.draw( poseStack = pose, @@ -185,7 +185,6 @@ class MGUIGraphics(val parent: GuiGraphics) { } fun draw( - font: Font, text: FormattedCharSequence, x: Float = 0f, y: Float = 0f, @@ -205,6 +204,7 @@ class MGUIGraphics(val parent: GuiGraphics) { drawOutline: Boolean = false, outlineColor: RGBAColor = RGBAColor.BLACK, outlineZ: Float = -0.1f, + font: Font = this.font, ): Float { val width = font.draw( poseStack = pose, 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 0bf986089..b1d960325 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 @@ -212,7 +212,6 @@ class MatterPanelScreen( menu.patternsFiltered.getOrNull(index)?.let { if (it.researchPercent < 1f) { graphics.draw( - font, TextComponent((it.researchPercent * 100.0).toInt().toString() + "%"), width - 1f, height - 1f, scale = 0.5f, gravity = RenderGravity.BOTTOM_RIGHT, drawShadow = true, color = RGBAColor.WHITE) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt index dbd05d60d..70155b260 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt @@ -115,7 +115,7 @@ open class EffectListPanel @JvmOverloads constructor( minecraft.mobEffectTextures.get(effect.effect).render(graphics, x = 3f, y = 3f, width = width - 6f, height = height - 6f) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) - graphics.draw(font, formatTickDuration(effect.duration), width / 2f, height / 2f, scale = 0.75f, gravity = RenderGravity.CENTER_CENTER, color = RGBAColor.WHITE) + graphics.draw(formatTickDuration(effect.duration), width / 2f, height / 2f, scale = 0.75f, gravity = RenderGravity.CENTER_CENTER, color = RGBAColor.WHITE) } override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { @@ -143,8 +143,8 @@ open class EffectListPanel @JvmOverloads constructor( name.append(" ${effect.amplifier + 1}") } - graphics.draw(font, name, x + renderWidth + 12f, y + 7f, gravity = RenderGravity.TOP_LEFT, color = RGBAColor.WHITE) - graphics.draw(font, formatTickDuration(effect.duration, true), x + renderWidth + 12f, y + 7f + font.lineHeight + 2f, gravity = RenderGravity.TOP_LEFT, color = RGBAColor.LIGHT_GRAY) + graphics.draw(name, x + renderWidth + 12f, y + 7f, gravity = RenderGravity.TOP_LEFT, color = RGBAColor.WHITE) + graphics.draw(formatTickDuration(effect.duration, true), x + renderWidth + 12f, y + 7f + font.lineHeight + 2f, gravity = RenderGravity.TOP_LEFT, color = RGBAColor.LIGHT_GRAY) } return isHovered diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index dfd6eb4fe..a2b34e409 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -370,7 +370,7 @@ open class FramePanel( // title val title = title ?: return RenderSystem.depthFunc(GL30.GL_ALWAYS) - graphics.draw(font, title, 8f, 5f, color = titleColor) + graphics.draw(title, 8f, 5f, color = titleColor) RenderSystem.depthFunc(GL30.GL_ALWAYS) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt index d1559d418..39dfe7e35 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt @@ -35,28 +35,28 @@ open class Label @JvmOverloads constructor( if (shadow) { when (gravity) { - RenderGravity.TOP_LEFT -> graphics.draw(font, text, shadowX, shadowY, color = shadowColor, gravity = gravity) - RenderGravity.TOP_CENTER -> graphics.draw(font, text, shadowX + width / 2f, shadowY, color = shadowColor, gravity = gravity) - RenderGravity.TOP_RIGHT -> graphics.draw(font, text, shadowX + width, shadowY, color = shadowColor, gravity = gravity) - RenderGravity.CENTER_LEFT -> graphics.draw(font, text, shadowX, height / 2f + shadowY, color = shadowColor, gravity = gravity) - RenderGravity.CENTER_CENTER -> graphics.draw(font, text, shadowX + width / 2f, height / 2f + shadowY, color = shadowColor, gravity = gravity) - RenderGravity.CENTER_RIGHT -> graphics.draw(font, text, shadowX + width, height / 2f + shadowY, color = shadowColor, gravity = gravity) - RenderGravity.BOTTOM_LEFT -> graphics.draw(font, text, shadowX, height + shadowY, color = shadowColor, gravity = gravity) - RenderGravity.BOTTOM_CENTER -> graphics.draw(font, text, shadowX + width / 2f, height + shadowY, color = shadowColor, gravity = gravity) - RenderGravity.BOTTOM_RIGHT -> graphics.draw(font, text, shadowX + width, height + shadowY, color = shadowColor, gravity = gravity) + RenderGravity.TOP_LEFT -> graphics.draw(text, shadowX, shadowY, color = shadowColor, gravity = gravity) + RenderGravity.TOP_CENTER -> graphics.draw(text, shadowX + width / 2f, shadowY, color = shadowColor, gravity = gravity) + RenderGravity.TOP_RIGHT -> graphics.draw(text, shadowX + width, shadowY, color = shadowColor, gravity = gravity) + RenderGravity.CENTER_LEFT -> graphics.draw(text, shadowX, height / 2f + shadowY, color = shadowColor, gravity = gravity) + RenderGravity.CENTER_CENTER -> graphics.draw(text, shadowX + width / 2f, height / 2f + shadowY, color = shadowColor, gravity = gravity) + RenderGravity.CENTER_RIGHT -> graphics.draw(text, shadowX + width, height / 2f + shadowY, color = shadowColor, gravity = gravity) + RenderGravity.BOTTOM_LEFT -> graphics.draw(text, shadowX, height + shadowY, color = shadowColor, gravity = gravity) + RenderGravity.BOTTOM_CENTER -> graphics.draw(text, shadowX + width / 2f, height + shadowY, color = shadowColor, gravity = gravity) + RenderGravity.BOTTOM_RIGHT -> graphics.draw(text, shadowX + width, height + shadowY, color = shadowColor, gravity = gravity) } } when (gravity) { - RenderGravity.TOP_LEFT -> graphics.draw(font, text, 0f, 0f, color = color, gravity = gravity) - RenderGravity.TOP_CENTER -> graphics.draw(font, text, width / 2f, 0f, color = color, gravity = gravity) - RenderGravity.TOP_RIGHT -> graphics.draw(font, text, width - (if (shadow) shadowX else 0f), 0f, color = color, gravity = gravity) - RenderGravity.CENTER_LEFT -> graphics.draw(font, text, 0f, height / 2f, color = color, gravity = gravity) - RenderGravity.CENTER_CENTER -> graphics.draw(font, text, width / 2f, height / 2f, color = color, gravity = gravity) - RenderGravity.CENTER_RIGHT -> graphics.draw(font, text, width - (if (shadow) shadowX else 0f), height / 2f, color = color, gravity = gravity) - RenderGravity.BOTTOM_LEFT -> graphics.draw(font, text, 0f, height, color = color, gravity = gravity) - RenderGravity.BOTTOM_CENTER -> graphics.draw(font, text, width / 2f, height, color = color, gravity = gravity) - RenderGravity.BOTTOM_RIGHT -> graphics.draw(font, text, width - (if (shadow) shadowX else 0f), height, color = color, gravity = gravity) + RenderGravity.TOP_LEFT -> graphics.draw(text, 0f, 0f, color = color, gravity = gravity) + RenderGravity.TOP_CENTER -> graphics.draw(text, width / 2f, 0f, color = color, gravity = gravity) + RenderGravity.TOP_RIGHT -> graphics.draw(text, width - (if (shadow) shadowX else 0f), 0f, color = color, gravity = gravity) + RenderGravity.CENTER_LEFT -> graphics.draw(text, 0f, height / 2f, color = color, gravity = gravity) + RenderGravity.CENTER_CENTER -> graphics.draw(text, width / 2f, height / 2f, color = color, gravity = gravity) + RenderGravity.CENTER_RIGHT -> graphics.draw(text, width - (if (shadow) shadowX else 0f), height / 2f, color = color, gravity = gravity) + RenderGravity.BOTTOM_LEFT -> graphics.draw(text, 0f, height, color = color, gravity = gravity) + RenderGravity.BOTTOM_CENTER -> graphics.draw(text, width / 2f, height, color = color, gravity = gravity) + RenderGravity.BOTTOM_RIGHT -> graphics.draw(text, width - (if (shadow) shadowX else 0f), height, color = color, gravity = gravity) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/NetworkedItemGridPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/NetworkedItemGridPanel.kt index 31c78b628..24bb4c00a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/NetworkedItemGridPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/NetworkedItemGridPanel.kt @@ -83,7 +83,7 @@ open class NetworkedItemGridPanel>( renderRegular(graphics, itemStack.toItemStack(), "") if (!itemStack.isEmpty) { - graphics.draw(font, itemStack.count.formatSiComponent(decimalPlaces = 1), x = width - 1f, y = height - 1f, gravity = RenderGravity.BOTTOM_RIGHT, scale = 0.75f, drawShadow = true) + graphics.draw(itemStack.count.formatSiComponent(decimalPlaces = 1), x = width - 1f, y = height - 1f, gravity = RenderGravity.BOTTOM_RIGHT, scale = 0.75f, drawShadow = true) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt index 266022db8..ec7906a9d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/ButtonPanel.kt @@ -52,7 +52,7 @@ open class ButtonPanel( override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { renderStretchableBackground(graphics, mouseX, mouseY, partialTick) - graphics.draw(font, label, width / 2f, height / 2f, color = textColor, gravity = RenderGravity.CENTER_CENTER) + graphics.draw(label, width / 2f, height / 2f, color = textColor, gravity = RenderGravity.CENTER_CENTER) } override fun sizeToContents(performLayout: Boolean) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt index fe39fa45c..a18bfcdf9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/TextInputPanel.kt @@ -1174,7 +1174,6 @@ open class TextInputPanel( val selection = selections[i] graphics.draw( - font = font, text = line, gravity = RenderGravity.TOP_LEFT, x = dockPadding.left, @@ -1228,7 +1227,6 @@ open class TextInputPanel( if (activeLine == null || cursorRow >= activeLine.length) { graphics.draw( - font = font, text = "_", gravity = RenderGravity.TOP_LEFT, x = dockPadding.left + (if (activeLine == null) 0f else font.width(activeLine).toFloat()), @@ -1237,7 +1235,6 @@ open class TextInputPanel( ) } else { graphics.draw( - font = font, text = "|", gravity = RenderGravity.TOP_LEFT, x = dockPadding.left + font.width(activeLine.substring(0, cursorRow)).toFloat() - 1f, @@ -1251,7 +1248,6 @@ open class TextInputPanel( if (debugDraw) { graphics.draw( - font = font, text = cursorLine.toString(), gravity = RenderGravity.TOP_RIGHT, x = width, @@ -1260,7 +1256,6 @@ open class TextInputPanel( ) graphics.draw( - font = font, text = cursorRow.toString(), gravity = RenderGravity.TOP_RIGHT, x = width - dockPadding.right, @@ -1269,7 +1264,6 @@ open class TextInputPanel( ) graphics.draw( - font = font, text = lines.size.toString(), gravity = RenderGravity.TOP_RIGHT, x = width - dockPadding.right, 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 1b83c199e..989e501af 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 @@ -331,7 +331,7 @@ private class AndroidResearchButton( val text = node.type.iconText if (text != null) { - graphics.draw(font, text.visualOrderText, width - font.width(text), height - font.lineHeight, color = RGBAColor.WHITE, drawShadow = true) + graphics.draw(text.visualOrderText, width - font.width(text), height - font.lineHeight, color = RGBAColor.WHITE, drawShadow = true) } for (line in lines) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt index bb65b63b0..a079ac8f7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt @@ -80,7 +80,7 @@ object MatterEntanglerRecipeCategory : IRecipeCategory, renderMatterGauge(wrap, 13f, 6f, drainSpeed = (recipe.matter / Decimal(300)).toFloat()) renderEnergyGauge(wrap, 4f, 6f, drainSpeed = (recipe.ticks / 2000.0).toFloat()) - wrap.draw(wrap.font, x = 85f, y = 45f, text = TranslatableComponent("otm.gui.recipe.ticks", recipe.ticks), drawShadow = true) + wrap.draw(x = 85f, y = 45f, text = TranslatableComponent("otm.gui.recipe.ticks", recipe.ticks), drawShadow = true) } override fun getTooltipStrings(recipe: IMatterEntanglerRecipe, recipeSlotsView: IRecipeSlotsView, mouseX: Double, mouseY: Double): MutableList { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt index bd723a9a9..622c59349 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt @@ -73,12 +73,12 @@ object MicrowaveRecipeCategory : IRecipeCategory, IDrawable { mouseY: Double ) { val wrap = MGUIGraphics(graphics) - wrap.draw(minecraft.font, TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), 40f, 30f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK) + wrap.draw(TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), 40f, 30f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK) val average = recipe.experience.toString() if (average != "0.0") { - wrap.draw(minecraft.font, TranslatableComponent("gui.jei.category.smelting.experience", average), 40f, 1f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK) + wrap.draw(TranslatableComponent("gui.jei.category.smelting.experience", average), 40f, 1f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt index cda8914e9..506fd5382 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt @@ -74,12 +74,12 @@ object PlatePressRecipeCategory : IRecipeCategory, IDrawable { ) { val wrap = MGUIGraphics(graphics) - wrap.draw(minecraft.font, TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), 40f, 30f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK) + wrap.draw(TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), 40f, 30f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK) val average = recipe.experience.toString() if (average != "0.0") { - wrap.draw(minecraft.font, TranslatableComponent("gui.jei.category.smelting.experience", average), 40f, 1f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK) + wrap.draw(TranslatableComponent("gui.jei.category.smelting.experience", average), 40f, 1f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK) } } From 716d251ca09a4f0cd883413cd0ac524d9dd7d1ed Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 02:51:17 +0700 Subject: [PATCH 1170/1199] More MGUIGraphics moves --- .../mc/otm/client/AndroidMenuKeyMapping.kt | 12 +++--- .../dbotthepony/mc/otm/client/MatteryGUI.kt | 2 +- .../mc/otm/client/render/MGUIGraphics.kt | 13 +++++++ .../mc/otm/client/render/RenderHelper.kt | 38 ------------------- .../client/screen/panels/EffectListPanel.kt | 7 ++-- 5 files changed, 22 insertions(+), 50 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt index cfbb165af..f81bd9c01 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt @@ -155,9 +155,9 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon RenderSystem.setShaderColor(0f, 0f, 0f, 0.6f) val size = minecraft.window.guiScaledHeight.coerceAtMost(minecraft.window.guiScaledWidth).toFloat() * 0.35f + val wrap = MGUIGraphics(event.guiGraphics) - drawArc( - event.guiGraphics, + wrap.drawArc( minecraft.window.guiScaledWidth / 2f, minecraft.window.guiScaledHeight / 2f, size, @@ -226,8 +226,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon if (lastSelectedDegree != null && lastSelectedFeature != null) { RenderSystem.setShaderColor(85 / 255f, 197 / 255f, 255 / 255f, 0.3f * lastSelectProgressGlobal) - drawArc( - event.guiGraphics, + wrap.drawArc( minecraft.window.guiScaledWidth / 2f, minecraft.window.guiScaledHeight / 2f, ru.dbotthepony.mc.otm.core.math.linearInterpolation(lastSelectProgressGlobal, size, size * 1.2f), @@ -245,7 +244,6 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon val poseStack = event.guiGraphics.pose() poseStack.pushPose() poseStack.translate(minecraft.window.guiScaledWidth.toDouble() / 2f, minecraft.window.guiScaledHeight.toDouble() / 2f, 0.0) - val wrap = MGUIGraphics(event.guiGraphics) for ((index, feature) in features.withIndex()) { var sin = sin((index + 0.5) * degreePerSlice).toFloat() @@ -264,7 +262,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon if (feature.isOnCooldown && feature.cooldownPercent > 0.0f) { RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f) - drawArc(event.guiGraphics, shift * cos, -shift * sin, iconSize / 2f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * feature.cooldownPercent.toDouble()) + wrap.drawArc(shift * cos, -shift * sin, iconSize / 2f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * feature.cooldownPercent.toDouble()) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) wrap.draw(formatTickDuration(feature.cooldown), shift * cos, -shift * sin + iconSize / 1.5f, color = RGBAColor.WHITE, gravity = RenderGravity.CENTER_CENTER) @@ -302,7 +300,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon feature.renderIcon(wrap, x, y, COOLDOWN_ICON_SIZE, COOLDOWN_ICON_SIZE) RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f) - drawArc(event.guiGraphics, x, y, COOLDOWN_ICON_SIZE / 2f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * feature.cooldownPercent, alignAtCenter = false) + wrap.drawArc(x, y, COOLDOWN_ICON_SIZE / 2f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * feature.cooldownPercent, alignAtCenter = false) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) wrap.draw(formatTickDuration(feature.cooldown), x + COOLDOWN_ICON_SIZE / 2f, y + COOLDOWN_ICON_SIZE + 1f, color = RGBAColor.WHITE, gravity = RenderGravity.TOP_CENTER) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index d92fe7610..4588b2b7c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -369,7 +369,7 @@ object MatteryGUI { val percent = ((stack.item.getUseDuration(stack) - ply.useItemRemainingTicks + minecraft.partialTick) / 5f).coerceIn(0f, 1f) RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f) - drawArc(graphics, x + 8f, y + 8f, 8f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * percent, alignAtCenter = true) + drawArc(graphics.pose(), x + 8f, y + 8f, 8f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * percent, alignAtCenter = true) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) return true diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt index 198ca4cd9..3c2dcc7a9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt @@ -11,6 +11,8 @@ import net.minecraft.util.FormattedCharSequence import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.math.RGBAColor +import kotlin.math.PI +import kotlin.math.roundToInt // polyfill class for 1.19.4 and older class MGUIGraphics(val parent: GuiGraphics) { @@ -248,6 +250,17 @@ class MGUIGraphics(val parent: GuiGraphics) { ) } + fun drawArc( + x: Float, + y: Float, + outerRadius: Float, + innerRadius: Float = 0f, + startDegree: Double = 0.0, + endDegree: Double = PI * 2.0, + steps: Int = (outerRadius * (endDegree - startDegree) * 4.0).roundToInt().coerceAtLeast(12), + alignAtCenter: Boolean = true + ) = drawArc(pose, x, y, outerRadius, innerRadius, startDegree, endDegree, steps, alignAtCenter) + companion object { private val defaultUV = UVCoords(0f, 0f, 1f, 1f) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt index 26738c334..84d7d1da4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt @@ -381,32 +381,6 @@ fun popScissorRect() { val currentScissorRect get() = scissorStack.lastOrNull() -fun TextureAtlasSprite.render( - stack: PoseStack, - x: Float = 0f, - y: Float = 0f, - width: Float, - height: Float, - winding: UVWindingOrder = UVWindingOrder.NORMAL -) { - RenderSystem.setShaderTexture(0, atlasLocation()) - - if (winding.isIdentity) { - renderTexturedRect(stack.last().pose(), x, y, width, height, uv = UVCoords(u0, v0, u1, v1)) - } else { - renderTexturedRect(stack.last().pose(), x, y, width, height, uv = winding.translate(u0, v0, u1, v1)) - } -} - -fun TextureAtlasSprite.render( - graphics: MGUIGraphics, - x: Float = 0f, - y: Float = 0f, - width: Float, - height: Float, - winding: UVWindingOrder = UVWindingOrder.NORMAL -) = render(graphics.pose, x, y, width, height, winding) - fun determineTooltipPosition(x: Float, y: Float, width: Float, height: Float): Pair { val windowWidth = minecraft.window.guiScaledWidth.toFloat() val windowHeight = minecraft.window.guiScaledHeight.toFloat() @@ -479,18 +453,6 @@ fun drawArc( alignAtCenter: Boolean = true ) = drawArc(stack.last().pose(), x, y, outerRadius, innerRadius, startDegree, endDegree, steps, alignAtCenter) -fun drawArc( - graphics: GuiGraphics, - x: Float, - y: Float, - outerRadius: Float, - innerRadius: Float = 0f, - startDegree: Double = 0.0, - endDegree: Double = PI * 2.0, - steps: Int = (outerRadius * (endDegree - startDegree) * 4.0).roundToInt().coerceAtLeast(12), - alignAtCenter: Boolean = true -) = drawArc(graphics.pose(), x, y, outerRadius, innerRadius, startDegree, endDegree, steps, alignAtCenter) - fun uploadArc( matrix: Matrix4f, builder: VertexConsumer, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt index 70155b260..d682f52f7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt @@ -13,7 +13,6 @@ import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.determineTooltipPosition import ru.dbotthepony.mc.otm.client.render.sprites.sprite -import ru.dbotthepony.mc.otm.client.render.render import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.TranslatableComponent @@ -112,7 +111,7 @@ open class EffectListPanel @JvmOverloads constructor( SQUARE_THIN.render(graphics, width = width, height = height) RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f) - minecraft.mobEffectTextures.get(effect.effect).render(graphics, x = 3f, y = 3f, width = width - 6f, height = height - 6f) + graphics.renderSprite(minecraft.mobEffectTextures.get(effect.effect), x = 3f, y = 3f, width = width - 6f, height = height - 6f) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) graphics.draw(formatTickDuration(effect.duration), width / 2f, height / 2f, scale = 0.75f, gravity = RenderGravity.CENTER_CENTER, color = RGBAColor.WHITE) @@ -128,8 +127,8 @@ open class EffectListPanel @JvmOverloads constructor( val renderWidth = 18f val renderHeight = 18f - minecraft.mobEffectTextures.get(effect.effect).render( - graphics.pose, + graphics.renderSprite( + minecraft.mobEffectTextures.get(effect.effect), x = x + 8f, y = y + BAR.height / 2f - renderHeight / 2f, width = renderWidth, From cc82146f0ad6fc679060b3e414e23e19ab2348b0 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 03:00:09 +0700 Subject: [PATCH 1171/1199] Remove import --- src/main/java/ru/dbotthepony/mc/otm/mixin/GuiGraphicsMixin.java | 2 +- src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt | 2 +- .../kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt | 2 +- .../kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt | 2 +- .../kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt | 2 -- .../kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt | 2 +- .../ru/dbotthepony/mc/otm/client/screen/panels/Panel2Widget.kt | 2 +- .../dbotthepony/mc/otm/compat/jei/IGUIRenderable2IDrawable.kt | 2 +- .../mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt | 2 +- .../ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt | 2 +- .../ru/dbotthepony/mc/otm/compat/jei/PainterRecipeCategory.kt | 2 +- .../dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt | 2 +- 12 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/GuiGraphicsMixin.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/GuiGraphicsMixin.java index 21986c504..523933da9 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/GuiGraphicsMixin.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/GuiGraphicsMixin.java @@ -1,7 +1,7 @@ package ru.dbotthepony.mc.otm.mixin; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; +; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index 4588b2b7c..9bf4d1867 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.client import com.mojang.blaze3d.systems.RenderSystem import net.minecraft.client.gui.Font -import net.minecraft.client.gui.GuiGraphics + import net.minecraft.client.gui.components.Button import net.minecraft.client.gui.screens.DeathScreen import net.minecraft.client.gui.screens.InBedChatScreen diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt index e5b7d8a1d..818e3dc95 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt @@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.client.render import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.VertexSorting import net.minecraft.client.gui.Font -import net.minecraft.client.gui.GuiGraphics + import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.network.chat.Component import net.minecraft.util.FormattedCharSequence diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt index 3c2dcc7a9..b225fdbf0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.client.render import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.Font -import net.minecraft.client.gui.GuiGraphics + import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.client.renderer.texture.TextureAtlasSprite import net.minecraft.network.chat.Component diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt index 84d7d1da4..74e51efc4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderHelper.kt @@ -3,13 +3,11 @@ package ru.dbotthepony.mc.otm.client.render import com.mojang.blaze3d.platform.GlStateManager import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.* -import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.renderer.GameRenderer import net.minecraft.client.renderer.RenderStateShard import net.minecraft.client.renderer.RenderStateShard.LineStateShard import net.minecraft.client.renderer.RenderType import net.minecraft.client.renderer.ShaderInstance -import net.minecraft.client.renderer.texture.TextureAtlasSprite import net.minecraft.resources.ResourceLocation import net.minecraft.server.packs.resources.ResourceProvider import org.apache.logging.log4j.LogManager 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 8a64de579..b3899f777 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 @@ -5,7 +5,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectFunction import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import net.minecraft.ChatFormatting import net.minecraft.client.gui.Font -import net.minecraft.client.gui.GuiGraphics + import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory 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 e58f5e00f..863e375ec 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 @@ -1,6 +1,6 @@ package ru.dbotthepony.mc.otm.client.screen.panels -import net.minecraft.client.gui.GuiGraphics + import net.minecraft.client.gui.components.Renderable import net.minecraft.client.gui.components.events.GuiEventListener import net.minecraft.client.gui.screens.Screen diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/IGUIRenderable2IDrawable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/IGUIRenderable2IDrawable.kt index 540c861cb..d13f05d00 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/IGUIRenderable2IDrawable.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/IGUIRenderable2IDrawable.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.mc.otm.compat.jei import mezz.jei.api.gui.drawable.IDrawable -import net.minecraft.client.gui.GuiGraphics + import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.IGUIRenderable diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt index a079ac8f7..ec0c51558 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt @@ -7,7 +7,7 @@ import mezz.jei.api.recipe.IFocusGroup import mezz.jei.api.recipe.RecipeIngredientRole import mezz.jei.api.recipe.RecipeType import mezz.jei.api.recipe.category.IRecipeCategory -import net.minecraft.client.gui.GuiGraphics + import net.minecraft.network.chat.Component import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.OverdriveThatMatters diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt index 622c59349..eda80470c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt @@ -7,7 +7,7 @@ import mezz.jei.api.recipe.IFocusGroup import mezz.jei.api.recipe.RecipeIngredientRole import mezz.jei.api.recipe.RecipeType import mezz.jei.api.recipe.category.IRecipeCategory -import net.minecraft.client.gui.GuiGraphics + import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.ItemStack 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 50bb55cea..f375ebfb3 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 @@ -7,7 +7,7 @@ import mezz.jei.api.recipe.IFocusGroup import mezz.jei.api.recipe.RecipeIngredientRole import mezz.jei.api.recipe.RecipeType import mezz.jei.api.recipe.category.IRecipeCategory -import net.minecraft.client.gui.GuiGraphics + import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.ItemStack diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt index 506fd5382..2aa8885a3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt @@ -7,7 +7,7 @@ import mezz.jei.api.recipe.IFocusGroup import mezz.jei.api.recipe.RecipeIngredientRole import mezz.jei.api.recipe.RecipeType import mezz.jei.api.recipe.category.IRecipeCategory -import net.minecraft.client.gui.GuiGraphics + import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.ItemStack From e563b85946eacd056f59fe796496bb1eadc3c206 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 03:22:05 +0700 Subject: [PATCH 1172/1199] Some backporting --- .../mc/otm/mixin/FoodDataMixin.java | 2 +- .../mixin/MixinAbstractHurtingProjectile.java | 2 +- .../otm/android/AndroidSwitchableFeature.kt | 2 +- .../android/feature/EnderTeleporterFeature.kt | 32 ++++++------- .../otm/android/feature/ItemMagnetFeature.kt | 4 +- .../otm/android/feature/JumpBoostFeature.kt | 8 ++-- .../feature/NanobotsRegenerationFeature.kt | 2 +- .../otm/android/feature/ShockwaveFeature.kt | 26 +++++------ .../mc/otm/block/BlackHoleBlock.kt | 5 +- .../mc/otm/block/entity/ExperienceStorage.kt | 2 +- .../otm/capability/MatteryPlayerCapability.kt | 46 +++++++++---------- .../mc/otm/client/AndroidAbilityKeyMapping.kt | 2 +- .../mc/otm/client/AndroidMenuKeyMapping.kt | 6 +-- .../mc/otm/client/ClientEventHandler.kt | 2 +- .../dbotthepony/mc/otm/client/MatteryGUI.kt | 11 +++-- .../mc/otm/client/render/MGUIGraphics.kt | 15 +++--- .../mc/otm/client/screen/MatteryScreen.kt | 19 ++++---- .../client/screen/decorative/PainterScreen.kt | 2 +- .../otm/client/screen/panels/Panel2Widget.kt | 5 +- .../jade/providers/MatterBottlerProvider.kt | 13 +++--- .../providers/MatterReconstructorProvider.kt | 11 +++-- .../jade/providers/MatterStorageProvider.kt | 9 ++-- .../jade/providers/MatteryEnergyProvider.kt | 9 ++-- .../jade/providers/MatteryWorkerProvider.kt | 11 +++-- .../compat/jei/IGUIRenderable2IDrawable.kt | 5 +- .../jei/MatterEntanglerRecipeCategory.kt | 5 +- .../otm/compat/jei/MicrowaveRecipeCategory.kt | 6 +-- .../otm/compat/jei/PainterRecipeCategory.kt | 5 +- .../compat/jei/PlatePressRecipeCategory.kt | 10 ++-- .../mc/otm/core/util/ItemSorter.kt | 2 +- .../mc/otm/entity/MinecartCargoCrate.kt | 4 +- .../mc/otm/entity/PlasmaProjectile.kt | 18 ++++---- .../mc/otm/item/EssenceServoItem.kt | 4 +- .../mc/otm/item/FluidCapsuleItem.kt | 44 +++++++++--------- .../mc/otm/item/matter/MatterDustItem.kt | 6 +-- .../mc/otm/item/tool/ExplosiveHammerItem.kt | 12 ++--- .../mc/otm/item/weapon/EnergySwordItem.kt | 12 ++--- .../mc/otm/item/weapon/PlasmaRifleItem.kt | 8 ++-- .../mc/otm/item/weapon/PlasmaWeaponItem.kt | 2 +- .../mc/otm/item/weapon/VelocityCalculation.kt | 2 +- .../mc/otm/menu/ExopackInventoryMenu.kt | 8 ++-- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 2 +- .../mc/otm/menu/decorative/PainterMenu.kt | 10 ++-- .../mc/otm/menu/matter/MatterEntanglerMenu.kt | 2 +- .../mc/otm/menu/matter/MatterPanelMenu.kt | 2 +- .../mc/otm/network/GenericNetworkChannel.kt | 6 +-- .../network/MatteryPlayerNetworkChannel.kt | 6 +-- .../mc/otm/triggers/AndroidResearchTrigger.kt | 1 - .../otm/triggers/AndroidTravelUnderwater.kt | 1 - .../mc/otm/triggers/ExopackTriggers.kt | 1 - .../mc/otm/triggers/HurtTrigger.kt | 1 - .../mc/otm/triggers/ItemTrigger.kt | 1 - .../mc/otm/triggers/MCriterionTrigger.kt | 5 +- .../mc/otm/triggers/NanobotsArmorTrigger.kt | 1 - .../mc/otm/triggers/SingletonTrigger.kt | 1 - 55 files changed, 225 insertions(+), 214 deletions(-) diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/FoodDataMixin.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/FoodDataMixin.java index bcccde05d..95b445540 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/FoodDataMixin.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/FoodDataMixin.java @@ -34,7 +34,7 @@ public class FoodDataMixin { // полностью подменяем логику если андроид lastFoodLevel = foodLevel; - if (player.level().getDifficulty() == Difficulty.PEACEFUL) { + if (player.level.getDifficulty() == Difficulty.PEACEFUL) { exhaustionLevel = 0f; } else { tickTimer = 0; diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinAbstractHurtingProjectile.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinAbstractHurtingProjectile.java index 561b2a736..aa61faf9a 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinAbstractHurtingProjectile.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/MixinAbstractHurtingProjectile.java @@ -29,7 +29,7 @@ public class MixinAbstractHurtingProjectile { AbstractHurtingProjectile proj = (AbstractHurtingProjectile)(Object)this; if (cap.isAndroid() && proj.getOwner() != entity) { - entity.level().playSound(entity, proj.blockPosition(), MSoundEvents.INSTANCE.getANDROID_PROJ_PARRY(), SoundSource.PLAYERS, 1.0f, 0.95f + entity.level().random.nextFloat() * 0.1f); + entity.level.playSound(entity, proj.blockPosition(), MSoundEvents.INSTANCE.getANDROID_PROJ_PARRY(), SoundSource.PLAYERS, 1.0f, 0.95f + entity.level.random.nextFloat() * 0.1f); } }); } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt index 13ab36b84..82238ae29 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidSwitchableFeature.kt @@ -34,7 +34,7 @@ abstract class AndroidSwitchableFeature(type: AndroidFeatureType<*>, android: Ma val cooldownPercent: Float get() { if (maxCooldown <= 0) return 0.0f - if (ply.level() is ClientLevel) { + if (ply.level is ClientLevel) { return ((cooldown.toFloat() - minecraft.partialTick) / maxCooldown.toFloat()).coerceIn(0.0f, 1.0f) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt index a8b1dd50d..624247c79 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt @@ -71,29 +71,29 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv } private fun canSupportPlayer(blockPos: BlockPos): Boolean { - val state = ply.level().getBlockState(blockPos) + val state = ply.level.getBlockState(blockPos) if (state.`is`(BlockTags.CLIMBABLE)) { return true // ladders can always support player } - val shape = state.getCollisionShape(ply.level(), blockPos, CollisionContext.of(ply)) + val shape = state.getCollisionShape(ply.level, blockPos, CollisionContext.of(ply)) return Shapes.joinIsNotEmpty(shape, SHAPE_CHECK_SUPPORT_PLAYER, BooleanOp.AND) } private fun isWall(blockPos: BlockPos): Boolean { - val shape = ply.level().getBlockState(blockPos).getCollisionShape(ply.level(), blockPos, CollisionContext.of(ply)) + val shape = ply.level.getBlockState(blockPos).getCollisionShape(ply.level, blockPos, CollisionContext.of(ply)) return Shapes.joinIsNotEmpty(shape, SHAPE_CHECK_NOT_FENCE, BooleanOp.AND) } private fun isAirGap(blockPos: BlockPos): Boolean { - val state = ply.level().getBlockState(blockPos) + val state = ply.level.getBlockState(blockPos) if (state.isAir) { return true } - val shape = state.getCollisionShape(ply.level(), blockPos, CollisionContext.of(ply)) + val shape = state.getCollisionShape(ply.level, blockPos, CollisionContext.of(ply)) return shape.isEmpty || !Shapes.joinIsNotEmpty(shape, SHAPE_CHECK_SUPPORT_PLAYER, BooleanOp.AND) } @@ -140,7 +140,7 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv val headPosition = ply.eyePosition val aimVector = ply.getViewVector(1f) - val result = ply.level().clip(ClipContext( + val result = ply.level.clip(ClipContext( headPosition, headPosition + aimVector * (AndroidConfig.EnderTeleporter.MAX_DISTANCE * 2.0), ClipContext.Block.COLLIDER, @@ -199,14 +199,14 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv val searchDirection: IntProgression if (ply.isShiftKeyDown) { - searchDirection = -1 downTo ply.level().minBuildHeight - ply.level().maxBuildHeight + searchDirection = -1 downTo ply.level.minBuildHeight - ply.level.maxBuildHeight } else { - searchDirection = (if (ply.level().getBlockState(result.blockPos).`is`(BlockTags.CLIMBABLE)) -1 else 0) .. ply.level().maxBuildHeight - ply.level().minBuildHeight + searchDirection = (if (ply.level.getBlockState(result.blockPos).`is`(BlockTags.CLIMBABLE)) -1 else 0) .. ply.level.maxBuildHeight - ply.level.minBuildHeight } for (y in searchDirection) { val pos = BlockPos(result.blockPos.x, result.blockPos.y + y + 1, result.blockPos.z) - val state = ply.level().getBlockState(pos) + val state = ply.level.getBlockState(pos) if (state.`is`(Blocks.BEDROCK)) { // Can't phase through bedrock @@ -258,9 +258,9 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv phasedBlocks = 0 phasedBlocksList.clear() - for (y in 0 downTo ply.level().maxBuildHeight - ply.level().minBuildHeight) { + for (y in 0 downTo ply.level.maxBuildHeight - ply.level.minBuildHeight) { val pos = BlockPos(result.blockPos.x, result.blockPos.y + y, result.blockPos.z) - val state = ply.level().getBlockState(pos) + val state = ply.level.getBlockState(pos) if (state.`is`(Blocks.BEDROCK)) { // Can't phase through bedrock @@ -302,7 +302,7 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv val event = ForgeEventFactory.onEnderTeleport(ply, blockPos.x + 0.5, blockPos.y.toDouble(), blockPos.z + 0.5) if (event.isCanceled) { - (ply as ServerPlayer).connection.send(ClientboundSoundEntityPacket(SoundEvents.ITEM_BREAK.holder, SoundSource.PLAYERS, ply, 0.3f, 0.5f, ply.level().random.nextLong())) + (ply as ServerPlayer).connection.send(ClientboundSoundEntityPacket(SoundEvents.ITEM_BREAK.holder, SoundSource.PLAYERS, ply, 0.3f, 0.5f, ply.level.random.nextLong())) return false } @@ -310,9 +310,9 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv lastTeleport = ply.server!!.tickCount android.androidEnergy.extractEnergy(AndroidConfig.EnderTeleporter.ENERGY_COST, false) - ply.level().playSound(null, ply, SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 0.3f, 0.8f + ply.level().random.nextFloat() * 0.4f) + ply.level.playSound(null, ply, SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 0.3f, 0.8f + ply.level.random.nextFloat() * 0.4f) ply.teleportTo(event.targetX, event.targetY, event.targetZ) - ply.level().playSound(null, ply, SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 1f, 0.8f + ply.level().random.nextFloat() * 0.4f) + ply.level.playSound(null, ply, SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 1f, 0.8f + ply.level.random.nextFloat() * 0.4f) ply.deltaMovement = Vector(0.0, 0.0, 0.0) ply.resetFallDistance() @@ -352,8 +352,8 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv val builder = source.getBuffer(linesIgnoreZRenderType) for (blockPos in phasedBlocks) { - val blockState = ply.level().getBlockState(blockPos) - val shape = blockState.getShape(ply.level(), blockPos, collisionContext) + val blockState = ply.level.getBlockState(blockPos) + val shape = blockState.getShape(ply.level, blockPos, collisionContext) LevelRenderer.renderShape( poseStack, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt index 1ddcd7f3b..7b6e93493 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt @@ -45,7 +45,7 @@ class ItemEntityDataPacket(val itemUUID: Int, val owner: UUID? = null, val age: } override fun play(context: MNetworkContext) { - val level = minecraft.player?.level() as ClientLevel? ?: return + val level = minecraft.player?.level as ClientLevel? ?: return val entity = level.getEntity(itemUUID) as ItemEntity? ?: return datatable[entity] = SharedItemEntityData(owner, age, lifespan, hasPickupDelay) } @@ -69,7 +69,7 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable return } - val entities = ply.level().getEntitiesInEllipsoid( + val entities = ply.level.getEntitiesInEllipsoid( ply.position, Vector(AndroidConfig.Magnet.RADIUS_HORIZONTAL, AndroidConfig.Magnet.RADIUS_VERTICAL, AndroidConfig.Magnet.RADIUS_HORIZONTAL), if (server) Predicate { it is ItemEntity } else clientPredicate diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt index d92f68fbe..9d800d816 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/JumpBoostFeature.kt @@ -38,7 +38,7 @@ object TriggerJumpBoostPacket : MatteryPacket { if (feature.isActive && feature.cooldown <= 4 && mattery.androidEnergy.extractEnergyExact(AndroidConfig.JumpBoost.ENERGY_COST, false)) { feature.putOnCooldown() - context.sender.level().playSound( + context.sender.level.playSound( context.sender, context.sender, MSoundEvents.ANDROID_JUMP_BOOST, SoundSource.PLAYERS, 1f, 1f @@ -73,20 +73,20 @@ class JumpBoostFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF } val old = lastGround - lastGround = ply.onGround() + lastGround = ply.isOnGround if (isActive && cooldown <= 0 && old != lastGround && !lastGround && isJumping && isShifting && ply.xRot <= ClientConfig.JUMP_BOOST_LOOK_ANGLE && android.androidEnergy.extractEnergyExact(AndroidConfig.JumpBoost.ENERGY_COST, true)) { ply.deltaMovement += Vector(0.0, AndroidConfig.JumpBoost.POWER * (level + 1) / 20.0, 0.0) putOnCooldown() MatteryPlayerNetworkChannel.sendToServer(TriggerJumpBoostPacket) - ply.level().playSound( + ply.level.playSound( ply, ply, MSoundEvents.ANDROID_JUMP_BOOST, SoundSource.PLAYERS, 1f, 1f ) - SmokeParticlesPacket.makeSmoke(ply.x, ply.y, ply.z, ply.random, ply.level()) + SmokeParticlesPacket.makeSmoke(ply.x, ply.y, ply.z, ply.random, ply.level) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsRegenerationFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsRegenerationFeature.kt index b5cd2d73c..ab19f08ee 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsRegenerationFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsRegenerationFeature.kt @@ -17,7 +17,7 @@ class NanobotsRegenerationFeature(android: MatteryPlayerCapability) : AndroidFea private var healTicks = 0 override fun tickServer() { - if (ply.isHurt && ply.level().gameRules.getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { + if (ply.isHurt && ply.level.gameRules.getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { ticksPassed++ val waitTime = AndroidConfig.NanobotsRegeneration.COOLDOWN.getOrElse(healTicks) { AndroidConfig.NanobotsRegeneration.COOLDOWN.last() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt index fe37b9113..26979d8e9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt @@ -93,7 +93,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF ShockwaveTrigger.trigger(ply as ServerPlayer) MatteryPlayerNetworkChannel.sendTrackingAndSelf(ply, ShockwaveEffectPacket(ply.position)) - ply.level().playSound( + ply.level.playSound( null, ply, MSoundEvents.ANDROID_SHOCKWAVE, @@ -104,13 +104,13 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF } // TODO: raycasting - val entities = ply.level().getEntitiesInEllipsoid( + val entities = ply.level.getEntitiesInEllipsoid( ply.position, Vector(AndroidConfig.Shockwave.RADIUS_HORIZONTAL, AndroidConfig.Shockwave.RADIUS_VERTICAL, AndroidConfig.Shockwave.RADIUS_HORIZONTAL), except = ply, ) { (it !is LivingEntity || !it.isSpectator && it.isAlive) } - val wardens = ply.level().getEntitiesInEllipsoid( + val wardens = ply.level.getEntitiesInEllipsoid( Warden::class.java, ply.position, Vector(AndroidConfig.Shockwave.RADIUS_HORIZONTAL_WARDEN, AndroidConfig.Shockwave.RADIUS_VERTICAL_WARDEN, AndroidConfig.Shockwave.RADIUS_HORIZONTAL_WARDEN), @@ -122,7 +122,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF seen.add(entity) val multiplier = (1.0 - distanceMultiplier).pow(0.5) - val source = MatteryDamageSource(ply.level().registryAccess().damageType(MDamageTypes.SHOCKWAVE), ply) + val source = MatteryDamageSource(ply.level.registryAccess().damageType(MDamageTypes.SHOCKWAVE), ply) val damage = multiplier.toFloat() * AndroidConfig.Shockwave.DAMAGE.toFloat() * AndroidConfig.Shockwave.WARDEN_DAMAGE_MULT.toFloat() entity.hurt(source, damage) entity.deltaMovement += (entity.position - ply.position).normalize() * (multiplier * 3.0) @@ -138,7 +138,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF // don't hurt items, arrows, etc etc if (entity is LivingEntity) { - val source = MatteryDamageSource(ply.level().registryAccess().damageType(MDamageTypes.SHOCKWAVE), ply) + val source = MatteryDamageSource(ply.level.registryAccess().damageType(MDamageTypes.SHOCKWAVE), ply) val damage = multiplier.toFloat() * AndroidConfig.Shockwave.DAMAGE.toFloat() entity.hurt(source, damage) entity.deltaMovement += (entity.position - ply.position).normalize() * (multiplier * 3.0) @@ -158,21 +158,21 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF for (blockPos in getEllipsoidBlockPositions(AndroidConfig.Shockwave.RADIUS_HORIZONTAL.roundToInt(), AndroidConfig.Shockwave.RADIUS_VERTICAL.roundToInt(), AndroidConfig.Shockwave.RADIUS_HORIZONTAL.roundToInt())) { val newBlockPos = blockPos + rounded - val blockState = ply.level().getBlockState(newBlockPos) + val blockState = ply.level.getBlockState(newBlockPos) - if (!blockState.isAir && blockState.getExplosionResistance(ply.level(), newBlockPos) <= 0f && ply.level().getBlockEntity(newBlockPos) == null && blockState.block.defaultDestroyTime() >= 0f) { - // Block.dropResources(blockState, ply.level(), newBlockPos) - // blockState.block.destroy(ply.level(), newBlockPos, blockState) - // ply.level().setBlock(newBlockPos, blockState.fluidState.createLegacyBlock(), Block.UPDATE_ALL) + if (!blockState.isAir && blockState.getExplosionResistance(ply.level, newBlockPos) <= 0f && ply.level.getBlockEntity(newBlockPos) == null && blockState.block.defaultDestroyTime() >= 0f) { + // Block.dropResources(blockState, ply.level, newBlockPos) + // blockState.block.destroy(ply.level, newBlockPos, blockState) + // ply.level.setBlock(newBlockPos, blockState.fluidState.createLegacyBlock(), Block.UPDATE_ALL) - ply.level().destroyBlock(newBlockPos, true) + ply.level.destroyBlock(newBlockPos, true) } } } } private fun ticker(isClient: Boolean) { - if (!ply.onGround() || ply.isSpectator) { + if (!ply.isOnGround || ply.isSpectator) { airTicks = (airTicks + 1).coerceAtMost(3) } else { airTicks = (airTicks - 1).coerceAtLeast(0) @@ -192,7 +192,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF creativeFlightTicks == 0 ) { val old = wasMidair - wasMidair = !ply.onGround() + wasMidair = !ply.isOnGround if (wasMidair) { highestSpeed = (-ply.deltaMovement.y).coerceAtLeast(highestSpeed) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/BlackHoleBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/BlackHoleBlock.kt index 99916f8f4..d57c6f303 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/BlackHoleBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/BlackHoleBlock.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.block import net.minecraft.core.BlockPos +import net.minecraft.world.item.DyeColor import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block @@ -10,7 +11,7 @@ import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.entity.BlockEntityTicker import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState -import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.Material import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape @@ -19,7 +20,7 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes class BlackHoleBlock : - Block(Properties.of().mapColor(MapColor.COLOR_BLACK).noCollission().pushReaction(PushReaction.BLOCK).sound(SoundType.STONE).strength(-1f, 7200000.0f)), EntityBlock { + Block(Properties.of(Material.AIR, DyeColor.BLACK).noCollission().pushReaction(PushReaction.BLOCK).sound(SoundType.STONE).strength(-1f, 7200000.0f)), EntityBlock { override fun getShape( p_60555_: BlockState, p_60556_: BlockGetter, 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 310f47590..6b4c4db49 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 @@ -33,7 +33,7 @@ class ExperienceStorage(val maxExperience: DoubleSupplier = DoubleSupplier { Dou if (whole > 0) { experience -= whole - ExperienceOrb.award(player.level() as ServerLevel, player.position(), whole) + ExperienceOrb.award(player.level as ServerLevel, player.position(), whole) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 5bdca1010..185e44947 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -149,7 +149,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial @Cancelable data class PreTick(val capability: MatteryPlayerCapability) : Event() { val player get() = capability.ply - val level: Level get() = capability.ply.level() + val level: Level get() = capability.ply.level override fun isCancelable(): Boolean { return true @@ -161,7 +161,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial */ data class PostTick(val capability: MatteryPlayerCapability) : Event() { val player get() = capability.ply - val level: Level get() = capability.ply.level() + val level: Level get() = capability.ply.level override fun isCancelable(): Boolean { return false @@ -174,7 +174,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial */ data class ItemStackLeftoverEvent(val stack: ItemStack, val capability: MatteryPlayerCapability) : Event() { val player get() = capability.ply - val level: Level get() = capability.ply.level() + val level: Level get() = capability.ply.level override fun isCancelable(): Boolean { return false @@ -525,7 +525,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial override fun computeNextJob(): JobContainer { if (!exopackEnergy.batteryLevel.isPositive) return JobContainer.noEnergy() - val level = ply.level() as? ServerLevel ?: return JobContainer.failure() + val level = ply.level as? ServerLevel ?: return JobContainer.failure() val recipe = cache.getRecipeFor(input, level) if (recipe.isEmpty) { @@ -542,7 +542,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial override fun onJobTick(status: JobStatus) { super.onJobTick(status) - if (isExopackVisible && ply.level().random.nextFloat() <= 0.05f) { + if (isExopackVisible && ply.level.random.nextFloat() <= 0.05f) { MatteryPlayerNetworkChannel.send(PacketDistributor.TRACKING_ENTITY_AND_SELF.with { ply as ServerPlayer }, ExopackSmokePacket(ply.uuid)) } } @@ -685,7 +685,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial becomeAndroid() if (!ply.abilities.invulnerable) - ply.hurt(MatteryDamageSource(ply.level().registryAccess().damageType(MDamageTypes.BECOME_ANDROID)), ply.maxHealth * 2) + ply.hurt(MatteryDamageSource(ply.level.registryAccess().damageType(MDamageTypes.BECOME_ANDROID)), ply.maxHealth * 2) } /** @@ -747,7 +747,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial becomeHumane() if (!ply.abilities.invulnerable) - ply.hurt(MatteryDamageSource(ply.level().registryAccess().damageType(MDamageTypes.BECOME_HUMANE)), ply.maxHealth * 2) + ply.hurt(MatteryDamageSource(ply.level.registryAccess().damageType(MDamageTypes.BECOME_HUMANE)), ply.maxHealth * 2) } /** @@ -808,7 +808,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial if (featureMap.containsKey(feature.type)) return false featureMap[feature.type] = feature - if (!ply.level().isClientSide) { + if (!ply.level.isClientSide) { queuedTicks.add(feature::applyModifiers) } @@ -836,7 +836,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial featureMap[feature] = factory - if (!ply.level().isClientSide && isAndroid) { + if (!ply.level.isClientSide && isAndroid) { queuedTicks.add(factory::applyModifiers) } @@ -861,7 +861,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial val removed = featureMap.remove(feature) if (removed != null) { - if (!ply.level().isClientSide && isAndroid) { + if (!ply.level.isClientSide && isAndroid) { queuedTicks.add(removed::removeModifiers) } @@ -1034,7 +1034,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial instance.deserializeNBT(featureTag) addFeature(instance) - if (!ply.level().isClientSide) { + if (!ply.level.isClientSide) { queuedTicks.add(instance::applyModifiers) } } @@ -1088,7 +1088,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial if (hasExopack) { for ((i, stack) in exopackContainer.withIndex()) { if (!stack.isEmpty) { - stack.inventoryTick(ply.level(), ply, i + 41, false) + stack.inventoryTick(ply.level, ply, i + 41, false) } } } @@ -1197,8 +1197,8 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial ply.isSwimming = false if (ply is ServerPlayer) { - if (ply.level().dimension().location() != lastDimension) { - lastDimension = ply.level().dimension().location() + if (ply.level.dimension().location() != lastDimension) { + lastDimension = ply.level.dimension().location() wasInLiquid = false lastOutsideLiquid = ply.position } @@ -1243,7 +1243,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial while (stats.foodLevel > 18 && androidEnergy.receiveEnergyExact(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT / 2, false)) { stats.foodLevel-- } - } else if (ply.level().difficulty != Difficulty.PEACEFUL) { + } else if (ply.level.difficulty != Difficulty.PEACEFUL) { stats.foodLevel = stats.foodLevel.coerceAtMost(18) } @@ -1255,7 +1255,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial stats.setSaturation(stats.saturationLevel + (extracted / AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT).toFloat()) } - if (androidEnergy.batteryLevel <= Decimal.TEN && !ply.isCreative && ply.level().difficulty != Difficulty.PEACEFUL) { + if (androidEnergy.batteryLevel <= Decimal.TEN && !ply.isCreative && ply.level.difficulty != Difficulty.PEACEFUL) { if (stats.saturationLevel > 1f) { if (androidEnergy.receiveEnergyExact(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false)) { stats.setSaturation(stats.saturationLevel - 1f) @@ -1272,7 +1272,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } if (androidEnergy.batteryLevel <= Decimal.TEN) { - if (--nextDischargeHurt <= 0 && ply.hurt(DamageSource(ply.level().registryAccess().damageType(MDamageTypes.ANDROID_DISCHARGE)), 1f)) { + if (--nextDischargeHurt <= 0 && ply.hurt(DamageSource(ply.level.registryAccess().damageType(MDamageTypes.ANDROID_DISCHARGE)), 1f)) { nextDischargeHurt = 20 } @@ -1285,13 +1285,13 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } else { nextDischargeHurt = 20 - if (ply.isHurt && ply.level().gameRules.getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { + if (ply.isHurt && ply.level.gameRules.getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { if (--nextHealTick <= 0) { - nextHealTick = if (ply.level().difficulty == Difficulty.PEACEFUL) 10 else AndroidConfig.TIME_BETWEEN_NATURAL_REGENERATION + nextHealTick = if (ply.level.difficulty == Difficulty.PEACEFUL) 10 else AndroidConfig.TIME_BETWEEN_NATURAL_REGENERATION ply.heal(1f) } } else { - nextHealTick = if (ply.level().difficulty == Difficulty.PEACEFUL) 10 else AndroidConfig.TIME_BETWEEN_NATURAL_REGENERATION + nextHealTick = if (ply.level.difficulty == Difficulty.PEACEFUL) 10 else AndroidConfig.TIME_BETWEEN_NATURAL_REGENERATION } } } @@ -1418,7 +1418,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial pos.mul(RenderSystem.getProjectionMatrix()) pos.mul(poseStack.last().pose()) - makeSmoke(cam.x + pos.x, cam.y + pos.y, cam.z + pos.z, ply.level().random, ply.level()) + makeSmoke(cam.x + pos.x, cam.y + pos.y, cam.z + pos.z, ply.level.random, ply.level) } } @@ -1513,13 +1513,13 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial val ent = event.player if (event.phase == TickEvent.Phase.START) { - if (!ent.level().isClientSide) { + if (!ent.level.isClientSide) { ent.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresentK { it.preTick() } } } else { - if (ent.level().isClientSide) { + if (ent.level.isClientSide) { ent.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresentK { it.tickClient() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt index d3301a692..bbaa708ee 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidAbilityKeyMapping.kt @@ -56,7 +56,7 @@ object AndroidAbilityKeyMapping : KeyMapping("key.otm.android_ability", KeyConfl val x = minecraft.window.guiScaledWidth.toFloat() * .5f + iconSize / 2f val y = minecraft.window.guiScaledHeight.toFloat() * .5f - iconSize / 2f - val wrap = MGUIGraphics(event.guiGraphics) + val wrap = MGUIGraphics(event.poseStack) feature.renderIcon(wrap, x, y, iconSize, iconSize) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt index f81bd9c01..8c59ac6b3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt @@ -155,7 +155,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon RenderSystem.setShaderColor(0f, 0f, 0f, 0.6f) val size = minecraft.window.guiScaledHeight.coerceAtMost(minecraft.window.guiScaledWidth).toFloat() * 0.35f - val wrap = MGUIGraphics(event.guiGraphics) + val wrap = MGUIGraphics(event.poseStack) wrap.drawArc( minecraft.window.guiScaledWidth / 2f, @@ -241,7 +241,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon val iconSize = size * 0.25f - val poseStack = event.guiGraphics.pose() + val poseStack = event.poseStack poseStack.pushPose() poseStack.translate(minecraft.window.guiScaledWidth.toDouble() / 2f, minecraft.window.guiScaledHeight.toDouble() / 2f, 0.0) @@ -294,7 +294,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon val y = minecraft.window.guiScaledHeight * 0.2f var x = minecraft.window.guiScaledWidth * 0.5f - (features.size.toFloat() * COOLDOWN_ICON_SIZE / 2f + (features.size - 1).toFloat() * (COOLDOWN_ICON_MARGIN / 2f)) - val wrap = MGUIGraphics(event.guiGraphics) + val wrap = MGUIGraphics(event.poseStack) for (feature in features) { feature.renderIcon(wrap, x, y, COOLDOWN_ICON_SIZE, COOLDOWN_ICON_SIZE) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt index 510f353c8..d85321aa3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt @@ -60,7 +60,7 @@ fun onMovementInputUpdate(event: MovementInputUpdateEvent) { cap.lastJumpTicks = 14 } else { if (ply.isInWater) { - if (ply.onGround()) { + if (ply.isOnGround) { cap.lastJumpTicks = 14 } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index 9bf4d1867..f4569b45d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.client import com.mojang.blaze3d.systems.RenderSystem +import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.Font import net.minecraft.client.gui.components.Button @@ -141,7 +142,7 @@ object MatteryGUI { return } - val guiGraphics = MGUIGraphics(event.guiGraphics) + val guiGraphics = MGUIGraphics(event.poseStack) val stack = guiGraphics.pose val window = event.window @@ -253,7 +254,7 @@ object MatteryGUI { val leftPadding = ceil(level * 80f - 0.5f) - val guiGraphics = MGUIGraphics(event.guiGraphics) + val guiGraphics = MGUIGraphics(event.poseStack) if (ply.hasEffect(MobEffects.HUNGER)) { CHARGE_HUNGER_BG.render(guiGraphics, left.toFloat(), top.toFloat()) @@ -323,7 +324,7 @@ object MatteryGUI { val top: Int = height - gui.leftHeight gui.leftHeight += 10 - val guiGraphics = MGUIGraphics(event.guiGraphics) + val guiGraphics = MGUIGraphics(event.poseStack) HEALTH_BG.render(guiGraphics, left.toFloat(), top.toFloat()) @@ -360,7 +361,7 @@ object MatteryGUI { } } - fun renderShieldCooldownOverlay(graphics: GuiGraphics, font: Font, stack: ItemStack, x: Int, y: Int): Boolean { + fun renderShieldCooldownOverlay(pose: PoseStack, font: Font, stack: ItemStack, x: Int, y: Int): Boolean { if (!stack.isEmpty && stack.item is ShieldItem) { if (!stack.canPerformAction(ToolActions.SHIELD_BLOCK)) return false @@ -369,7 +370,7 @@ object MatteryGUI { val percent = ((stack.item.getUseDuration(stack) - ply.useItemRemainingTicks + minecraft.partialTick) / 5f).coerceIn(0f, 1f) RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f) - drawArc(graphics.pose(), x + 8f, y + 8f, 8f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * percent, alignAtCenter = true) + drawArc(pose, x + 8f, y + 8f, 8f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * percent, alignAtCenter = true) RenderSystem.setShaderColor(1f, 1f, 1f, 1f) return true diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt index b225fdbf0..e72eb091d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt @@ -1,9 +1,12 @@ package ru.dbotthepony.mc.otm.client.render +import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack +import com.mojang.blaze3d.vertex.Tesselator import net.minecraft.client.gui.Font import net.minecraft.client.renderer.MultiBufferSource +import net.minecraft.client.renderer.RenderBuffers import net.minecraft.client.renderer.texture.TextureAtlasSprite import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation @@ -15,15 +18,14 @@ import kotlin.math.PI import kotlin.math.roundToInt // polyfill class for 1.19.4 and older -class MGUIGraphics(val parent: GuiGraphics) { - val pose: PoseStack get() = parent.pose() - val bufferSource: MultiBufferSource.BufferSource get() = parent.bufferSource() - val width get() = parent.guiWidth() - val height get() = parent.guiHeight() +class MGUIGraphics(val pose: PoseStack) { + val bufferSource: MultiBufferSource.BufferSource get() = minecraft.renderBuffers().crumblingBufferSource() + val width get() = minecraft.window.guiScaledWidth + val height get() = minecraft.window.guiScaledHeight val font: Font get() = minecraft.font fun setColor(red: Float, green: Float, blue: Float, alpha: Float) { - parent.setColor(red, green, blue, alpha) + RenderSystem.setShaderColor(red, green, blue, alpha) } fun renderFakeItem(itemStack: ItemStack, x: Int, y: Int) { @@ -83,7 +85,6 @@ class MGUIGraphics(val parent: GuiGraphics) { } fun flush() { - parent.flush() } fun draw( 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 b3899f777..5c43c66de 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 @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen import com.mojang.blaze3d.systems.RenderSystem +import com.mojang.blaze3d.vertex.PoseStack import it.unimi.dsi.fastutil.ints.Int2ObjectFunction import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import net.minecraft.ChatFormatting @@ -610,7 +611,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit return super.keyPressed(key, scancode, mods) } - override fun renderBg(p_283065_: GuiGraphics, p_97788_: Float, p_97789_: Int, p_97790_: Int) {} + override fun renderBg(p_283065_: PoseStack, p_97788_: Float, p_97789_: Int, p_97790_: Int) {} var returnSlot: Slot? = null @@ -643,13 +644,13 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit return false } - override fun render(graphics: GuiGraphics, mouseX: Int, mouseY: Int, partialTick: Float) { - val wrap = MGUIGraphics(graphics) + override fun render(poseStack: PoseStack, mouseX: Int, mouseY: Int, partialTick: Float) { + val wrap = MGUIGraphics(poseStack) val mouseXf = mouseX.toFloat() val mouseYf = mouseY.toFloat() // dark background - this.renderBackground(graphics) + this.renderBackground(poseStack) super.hoveredSlot = null var hovered = false @@ -673,17 +674,17 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } RenderSystem.depthFunc(GL11.GL_LESS) - MinecraftForge.EVENT_BUS.post(Background(this, graphics, mouseX, mouseY)) + MinecraftForge.EVENT_BUS.post(Background(this, poseStack, mouseX, mouseY)) RenderSystem.disableDepthTest() // Screen.super.render for (widget in renderables) { - widget.render(graphics, mouseX, mouseY, partialTick) + widget.render(poseStack, mouseX, mouseY, partialTick) } // /Screen.super.render RenderSystem.disableDepthTest() - MinecraftForge.EVENT_BUS.post(Foreground(this, graphics, mouseX, mouseY)) + MinecraftForge.EVENT_BUS.post(Foreground(this, poseStack, mouseX, mouseY)) var itemstack = if (draggingItem.isEmpty) menu.carried else draggingItem @@ -701,14 +702,14 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } @Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") - renderFloatingItem(graphics, itemstack, mouseX - 8, mouseY - i2, overrideCount) + renderFloatingItem(poseStack, itemstack, mouseX - 8, mouseY - i2, overrideCount) } if (menu.carried.isEmpty) { val hoveredSlot = super.hoveredSlot if (hoveredSlot != null && hoveredSlot.hasItem()) { - this.renderTooltip(graphics, mouseX, mouseY) + this.renderTooltip(poseStack, mouseX, mouseY) } else { for (panel in panels) { RenderSystem.disableDepthTest() 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 6f67ee83a..3f2c4d177 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 @@ -156,7 +156,7 @@ class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) : set(value) {} override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { - val list = getTooltipFromItem(minecraft!!, recipeOutput) + val list = getTooltipFromItem(recipeOutput) recipe.value.dyes.forEach { val (dye, amount) = it 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 863e375ec..c286191cc 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 @@ -1,6 +1,7 @@ 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.events.GuiEventListener import net.minecraft.client.gui.screens.Screen @@ -14,13 +15,13 @@ class Panel2Widget>( require(panel.parent == null) { "Widget wrapped panels can't have a parent ($panel has parent ${panel.parent})" } } - override fun render(graphics: GuiGraphics, mouseX: Int, mouseY: Int, partialTick: Float) { + override fun render(stack: PoseStack, mouseX: Int, mouseY: Int, partialTick: Float) { panel.tick() val xFloat = mouseX.toFloat() val yFloat = mouseY.toFloat() - val wrap = MGUIGraphics(graphics) + val wrap = MGUIGraphics(stack) panel.tickHover(xFloat, yFloat) panel.render(wrap, xFloat, yFloat, partialTick) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterBottlerProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterBottlerProvider.kt index 30e0e4c77..47d5048a6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterBottlerProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterBottlerProvider.kt @@ -2,6 +2,9 @@ package ru.dbotthepony.mc.otm.compat.jade.providers import net.minecraft.nbt.CompoundTag import net.minecraft.resources.ResourceLocation +import net.minecraft.server.level.ServerPlayer +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.entity.BlockEntity import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity import ru.dbotthepony.mc.otm.compat.jade.JadeTagKeys @@ -16,16 +19,14 @@ import snownee.jade.api.config.IPluginConfig import snownee.jade.api.ui.BoxStyle import snownee.jade.api.ui.IElementHelper -object MatterBottlerProvider : IBlockComponentProvider, IServerDataProvider { +object MatterBottlerProvider : IBlockComponentProvider, IServerDataProvider { override fun getUid(): ResourceLocation = JadeUids.MATTER_BOTTLER - override fun appendServerData(data: CompoundTag, accessor: BlockAccessor) { - if (accessor.blockEntity is MatterBottlerBlockEntity) { - val bottler = accessor.blockEntity as MatterBottlerBlockEntity - + override fun appendServerData(data: CompoundTag, player: ServerPlayer, level: Level, bottler: BlockEntity?, state: Boolean) { + if (bottler is MatterBottlerBlockEntity) { val bottlerData = CompoundTag() bottlerData.putBoolean("isBottling", bottler.isBottling) - bottlerData.putBoolean("isIdling", accessor.blockState.getValue(WorkerState.SEMI_WORKER_STATE) !== WorkerState.WORKING) + bottlerData.putBoolean("isIdling", bottler.blockState.getValue(WorkerState.SEMI_WORKER_STATE) !== WorkerState.WORKING) bottlerData.putFloat("workProgress", bottler.workProgress) data.put(JadeTagKeys.MATTER_BOTTLER_DATA, bottlerData) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterReconstructorProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterReconstructorProvider.kt index 176012c2e..215f4e589 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterReconstructorProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterReconstructorProvider.kt @@ -2,6 +2,9 @@ package ru.dbotthepony.mc.otm.compat.jade.providers import net.minecraft.nbt.CompoundTag import net.minecraft.resources.ResourceLocation +import net.minecraft.server.level.ServerPlayer +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.entity.BlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterReconstructorBlockEntity import ru.dbotthepony.mc.otm.compat.jade.JadeTagKeys import ru.dbotthepony.mc.otm.compat.jade.JadeUids @@ -15,13 +18,11 @@ import snownee.jade.api.config.IPluginConfig import snownee.jade.api.ui.BoxStyle import snownee.jade.api.ui.IElementHelper -object MatterReconstructorProvider : IBlockComponentProvider, IServerDataProvider { +object MatterReconstructorProvider : IBlockComponentProvider, IServerDataProvider { override fun getUid(): ResourceLocation = JadeUids.MATTER_RECONSTRUCTOR - override fun appendServerData(data: CompoundTag, accessor: BlockAccessor) { - if (accessor.blockEntity is MatterReconstructorBlockEntity) { - val reconstructor = accessor.blockEntity as MatterReconstructorBlockEntity - + override fun appendServerData(data: CompoundTag, player: ServerPlayer, level: Level, reconstructor: BlockEntity?, state: Boolean) { + if (reconstructor is MatterReconstructorBlockEntity) { val item = reconstructor.repairContainer.get(0) if (!item.isEmpty && item.isDamageableItem && item.maxDamage != 0) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterStorageProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterStorageProvider.kt index 235be5a01..90cba644c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterStorageProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatterStorageProvider.kt @@ -4,6 +4,9 @@ import net.minecraft.ChatFormatting import net.minecraft.nbt.CompoundTag import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation +import net.minecraft.server.level.ServerPlayer +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.entity.BlockEntity import ru.dbotthepony.mc.otm.capability.AbstractProfiledStorage import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.compat.jade.JadeColors @@ -24,11 +27,11 @@ import snownee.jade.api.config.IPluginConfig import snownee.jade.api.ui.BoxStyle import snownee.jade.api.ui.IElementHelper -object MatterStorageProvider : IBlockComponentProvider, IServerDataProvider { +object MatterStorageProvider : IBlockComponentProvider, IServerDataProvider { override fun getUid(): ResourceLocation = JadeUids.MATTER_STORAGE - override fun appendServerData(data: CompoundTag, accessor: BlockAccessor) { - accessor.blockEntity?.getCapability(MatteryCapability.MATTER)?.ifPresentK { + override fun appendServerData(data: CompoundTag, player: ServerPlayer, level: Level, blockEntity: BlockEntity?, state: Boolean) { + blockEntity?.getCapability(MatteryCapability.MATTER)?.ifPresentK { val matterData = CompoundTag() matterData.putDecimal("storedMatter", it.storedMatter) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatteryEnergyProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatteryEnergyProvider.kt index b33bb10c0..4ba4a6b93 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatteryEnergyProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatteryEnergyProvider.kt @@ -4,6 +4,9 @@ import net.minecraft.ChatFormatting import net.minecraft.nbt.CompoundTag import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation +import net.minecraft.server.level.ServerPlayer +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.entity.BlockEntity import ru.dbotthepony.mc.otm.capability.AbstractProfiledStorage import ru.dbotthepony.mc.otm.capability.MatteryCapability import ru.dbotthepony.mc.otm.compat.jade.JadeColors @@ -21,11 +24,11 @@ import snownee.jade.api.config.IPluginConfig import snownee.jade.api.ui.BoxStyle import snownee.jade.api.ui.IElementHelper -object MatteryEnergyProvider : IBlockComponentProvider, IServerDataProvider { +object MatteryEnergyProvider : IBlockComponentProvider, IServerDataProvider { override fun getUid(): ResourceLocation = JadeUids.MATTERY_ENERGY - override fun appendServerData(data: CompoundTag, accessor: BlockAccessor) { - accessor.blockEntity?.getCapability(MatteryCapability.ENERGY)?.ifPresentK { + override fun appendServerData(data: CompoundTag, player: ServerPlayer, level: Level, blockEntity: BlockEntity?, state: Boolean) { + blockEntity?.getCapability(MatteryCapability.ENERGY)?.ifPresentK { val energyData = CompoundTag() energyData.putDecimal("batteryLevel", it.batteryLevel) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatteryWorkerProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatteryWorkerProvider.kt index 2b3365c9e..c6ccd4173 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatteryWorkerProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jade/providers/MatteryWorkerProvider.kt @@ -3,6 +3,9 @@ package ru.dbotthepony.mc.otm.compat.jade.providers import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.ListTag import net.minecraft.resources.ResourceLocation +import net.minecraft.server.level.ServerPlayer +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.entity.BlockEntity import ru.dbotthepony.mc.otm.block.entity.ItemJob import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity import ru.dbotthepony.mc.otm.compat.jade.JadeTagKeys @@ -19,13 +22,11 @@ import snownee.jade.api.config.IPluginConfig import snownee.jade.api.ui.BoxStyle import snownee.jade.api.ui.IElementHelper -object MatteryWorkerProvider : IBlockComponentProvider, IServerDataProvider { +object MatteryWorkerProvider : IBlockComponentProvider, IServerDataProvider { override fun getUid(): ResourceLocation = JadeUids.MATTERY_WORKER - override fun appendServerData(data: CompoundTag, accessor: BlockAccessor) { - if (accessor.blockEntity is MatteryWorkerBlockEntity<*>) { - val worker = accessor.blockEntity as MatteryWorkerBlockEntity<*> - + override fun appendServerData(data: CompoundTag, player: ServerPlayer, level: Level, worker: BlockEntity?, state: Boolean) { + if (worker is MatteryWorkerBlockEntity<*>) { val workerData = CompoundTag() workerData["jobs"] = ListTag().also { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/IGUIRenderable2IDrawable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/IGUIRenderable2IDrawable.kt index d13f05d00..56ee12f89 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/IGUIRenderable2IDrawable.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/IGUIRenderable2IDrawable.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.compat.jei +import com.mojang.blaze3d.vertex.PoseStack import mezz.jei.api.gui.drawable.IDrawable import ru.dbotthepony.mc.otm.client.render.MGUIGraphics @@ -14,7 +15,7 @@ class IGUIRenderable2IDrawable(val parent: IGUIRenderable) : IDrawable { return parent.height.toInt() } - override fun draw(guiGraphics: GuiGraphics, xOffset: Int, yOffset: Int) { - parent.render(MGUIGraphics(guiGraphics), xOffset.toFloat(), yOffset.toFloat()) + override fun draw(stack: PoseStack, xOffset: Int, yOffset: Int) { + parent.render(MGUIGraphics(stack), xOffset.toFloat(), yOffset.toFloat()) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt index ec0c51558..a3ce8ca09 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.compat.jei +import com.mojang.blaze3d.vertex.PoseStack import mezz.jei.api.gui.builder.IRecipeLayoutBuilder import mezz.jei.api.gui.drawable.IDrawable import mezz.jei.api.gui.ingredient.IRecipeSlotsView @@ -61,8 +62,8 @@ object MatterEntanglerRecipeCategory : IRecipeCategory, builder.addSlot(RecipeIngredientRole.OUTPUT, 116, 18 + 4).addItemStack(recipe.result) } - override fun draw(guiGraphics: GuiGraphics, xOffset: Int, yOffset: Int) { - val wrap = MGUIGraphics(guiGraphics) + override fun draw(stack: PoseStack, xOffset: Int, yOffset: Int) { + val wrap = MGUIGraphics(stack) for (x in 0 until 3) { for (y in 0 until 3) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt index eda80470c..7ac0538f4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.compat.jei +import com.mojang.blaze3d.vertex.PoseStack import mezz.jei.api.gui.builder.IRecipeLayoutBuilder import mezz.jei.api.gui.drawable.IDrawable import mezz.jei.api.gui.ingredient.IRecipeSlotsView @@ -14,7 +15,6 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Ingredient import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.client.render.MGUIGraphics -import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel @@ -45,14 +45,14 @@ object MicrowaveRecipeCategory : IRecipeCategory, IDrawable { return MItems.POWERED_SMOKER.description } - override fun draw(graphics: GuiGraphics, xOffset: Int, yOffset: Int) { + override fun draw(stack: PoseStack, xOffset: Int, yOffset: Int) { @Suppress("name_shadowing") val xOffset = xOffset.toFloat() @Suppress("name_shadowing") val yOffset = yOffset.toFloat() - val wrap = MGUIGraphics(graphics) + val wrap = MGUIGraphics(stack) AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, X_INPUT + xOffset, Y_INPUT + yOffset) AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, X_OUTPUT + xOffset, Y_OUTPUT + yOffset) 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 f375ebfb3..440806e40 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 @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.compat.jei +import com.mojang.blaze3d.vertex.PoseStack import mezz.jei.api.constants.VanillaTypes import mezz.jei.api.gui.builder.IRecipeLayoutBuilder import mezz.jei.api.gui.drawable.IDrawable @@ -71,8 +72,8 @@ object PainterRecipeCategory : IRecipeCategory, IDrawable { builder.addSlot(RecipeIngredientRole.OUTPUT, 100, 22).addIngredients(VanillaTypes.ITEM_STACK, listOf(recipe.output)) } - override fun draw(guiGraphics: GuiGraphics, xOffset: Int, yOffset: Int) { - val wrap = MGUIGraphics(guiGraphics) + override fun draw(stack: PoseStack, xOffset: Int, yOffset: Int) { + val wrap = MGUIGraphics(stack) for (x in 0 .. 1) { for (y in 0 .. 2) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt index 2aa8885a3..452f2c025 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.compat.jei +import com.mojang.blaze3d.vertex.PoseStack import mezz.jei.api.gui.builder.IRecipeLayoutBuilder import mezz.jei.api.gui.drawable.IDrawable import mezz.jei.api.gui.ingredient.IRecipeSlotsView @@ -14,7 +15,6 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Ingredient import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.client.render.MGUIGraphics -import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel @@ -45,14 +45,14 @@ object PlatePressRecipeCategory : IRecipeCategory, IDrawable { return MItems.PLATE_PRESS.description } - override fun draw(graphics: GuiGraphics, xOffset: Int, yOffset: Int) { + override fun draw(stack: PoseStack, xOffset: Int, yOffset: Int) { @Suppress("name_shadowing") val xOffset = xOffset.toFloat() @Suppress("name_shadowing") val yOffset = yOffset.toFloat() - val wrap = MGUIGraphics(graphics) + val wrap = MGUIGraphics(stack) AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, X_INPUT + xOffset, Y_INPUT + yOffset) AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, X_OUTPUT + xOffset, Y_OUTPUT + yOffset) @@ -68,11 +68,11 @@ object PlatePressRecipeCategory : IRecipeCategory, IDrawable { override fun draw( recipe: PlatePressRecipe, recipeSlotsView: IRecipeSlotsView, - graphics: GuiGraphics, + stack: PoseStack, mouseX: Double, mouseY: Double ) { - val wrap = MGUIGraphics(graphics) + val wrap = MGUIGraphics(stack) wrap.draw(TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), 40f, 30f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt index 6319572f0..7e11694ea 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt @@ -56,7 +56,7 @@ object CreativeMenuItemComparator : Comparator { if (item2index.isEmpty()) { val player = minecraft.player ?: return // creative tabs were not populated yet - CreativeModeTabs.tryRebuildTabContents(player.connection.enabledFeatures(), false /* operator tabs */, player.level().registryAccess()) + CreativeModeTabs.tryRebuildTabContents(player.connection.enabledFeatures(), false /* operator tabs */, player.level.registryAccess()) doRebuild() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/MinecartCargoCrate.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/MinecartCargoCrate.kt index 8e55da5e9..9308aee87 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/MinecartCargoCrate.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/MinecartCargoCrate.kt @@ -89,7 +89,7 @@ class MinecartCargoCrate( if (interactingPlayers++ == 0) { if (!isRemoved) { - level().playSound(null, this, MSoundEvents.CARGO_CRATE_OPEN, SoundSource.BLOCKS, 1f, 0.8f + level().random.nextFloat() * 0.2f) + level.playSound(null, this, MSoundEvents.CARGO_CRATE_OPEN, SoundSource.BLOCKS, 1f, 0.8f + level.random.nextFloat() * 0.2f) this.gameEvent(GameEvent.CONTAINER_OPEN, player) PiglinAi.angerNearbyPiglins(player, true) } @@ -102,7 +102,7 @@ class MinecartCargoCrate( if (--interactingPlayers == 0) { if (!isRemoved) { - level().gameEvent(GameEvent.CONTAINER_CLOSE, position, GameEvent.Context.of(this)) + level.gameEvent(GameEvent.CONTAINER_CLOSE, position, GameEvent.Context.of(this)) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/PlasmaProjectile.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/PlasmaProjectile.kt index 405a5f41f..0e3179247 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/PlasmaProjectile.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/PlasmaProjectile.kt @@ -29,7 +29,7 @@ class PlasmaProjectile(level: Level) : Projectile(MEntityTypes.PLASMA as EntityT override fun onHit(p_37260_: HitResult) { super.onHit(p_37260_) - if (!level().isClientSide) { + if (!level.isClientSide) { discard() } } @@ -37,8 +37,8 @@ class PlasmaProjectile(level: Level) : Projectile(MEntityTypes.PLASMA as EntityT override fun onHitEntity(p_37259_: EntityHitResult) { super.onHitEntity(p_37259_) - if (!level().isClientSide) { - p_37259_.entity.hurt(MatteryDamageSource(level().registryAccess().damageType(MDamageTypes.PLASMA), owner, inflictor), damage) + if (!level.isClientSide) { + p_37259_.entity.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.PLASMA), owner, inflictor), damage) } } @@ -54,17 +54,17 @@ class PlasmaProjectile(level: Level) : Projectile(MEntityTypes.PLASMA as EntityT super.tick() - val trace = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity) + val trace = ProjectileUtil.getHitResult(this, this::canHitEntity) if (trace.type == HitResult.Type.BLOCK) { val pos = (trace as BlockHitResult).blockPos - val state = level().getBlockState(pos) + val state = level.getBlockState(pos) if (state.`is`(Blocks.NETHER_PORTAL) || state.`is`(Blocks.END_GATEWAY)) { onHitBlock(trace) // don't teleport plasma projectile - if (!level().isClientSide) + if (!level.isClientSide) discard() return @@ -85,7 +85,7 @@ class PlasmaProjectile(level: Level) : Projectile(MEntityTypes.PLASMA as EntityT // extinguish for (i in 0 .. 4) { - level().addParticle( + level.addParticle( ParticleTypes.BUBBLE, x - deltaMovement.x * 0.25, y - deltaMovement.y * 0.25, @@ -96,9 +96,9 @@ class PlasmaProjectile(level: Level) : Projectile(MEntityTypes.PLASMA as EntityT ) } - if (!level().isClientSide) { + if (!level.isClientSide) { discard() - level().levelEvent(LevelEvent.LAVA_FIZZ, blockPosition(), 0) + level.levelEvent(LevelEvent.LAVA_FIZZ, blockPosition(), 0) } return diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EssenceServoItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EssenceServoItem.kt index 320bcfbcd..f6417fdc8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/EssenceServoItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/EssenceServoItem.kt @@ -22,11 +22,11 @@ class EssenceServoItem : Item(Properties().stacksTo(64)) { } fun useServo(player: Player, pos: BlockPos): InteractionResult { - val block = player.level().getBlockEntity(pos) ?: return InteractionResult.FAIL + val block = player.level.getBlockEntity(pos) ?: return InteractionResult.FAIL // TODO: опыт как жидкость if (block is EssenceStorageBlockEntity) { - if (player.level().isClientSide) return InteractionResult.SUCCESS + if (player.level.isClientSide) return InteractionResult.SUCCESS if (player !is ServerPlayer) return InteractionResult.FAIL if (player.isCrouching) { // выгружаем в блок 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 d41260d93..1494165ae 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt @@ -114,16 +114,16 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6 actionResult.result } - if (!player.abilities.instabuild && !player.level().isClientSide) { + if (!player.abilities.instabuild && !player.level.isClientSide) { item.shrink(1) - if (item.isEmpty) return InteractionResultHolder.sidedSuccess(targetItem, player.level().isClientSide) + if (item.isEmpty) return InteractionResultHolder.sidedSuccess(targetItem, player.level.isClientSide) if (!player.inventory.add(targetItem)) { player.spawnAtLocation(targetItem) } } - return InteractionResultHolder.sidedSuccess(item, player.level().isClientSide) + return InteractionResultHolder.sidedSuccess(item, player.level.isClientSide) } return InteractionResultHolder.pass(item) @@ -143,7 +143,7 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6 } override fun canInteract(item: ItemStack, player: Player, context: Context): Boolean { - return player.level().getBlockState(context.blockPos).`is`(Blocks.CAULDRON) + return player.level.getBlockState(context.blockPos).`is`(Blocks.CAULDRON) } override fun interact(item: ItemStack, player: Player, context: Context): InteractionResult { @@ -158,12 +158,12 @@ 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) - val level = player.level() as? ServerLevel ?: return InteractionResult.SUCCESS + player.level.playSound(player, context.blockPos, soundEvent, SoundSource.BLOCKS) + val level = player.level as? ServerLevel ?: return InteractionResult.SUCCESS level.setBlock(context.blockPos, newState, Block.UPDATE_ALL) cap.drain(toDrain, IFluidHandler.FluidAction.EXECUTE) - if (item.count != 1 && !player.level().isClientSide) { + if (item.count != 1 && !player.level.isClientSide) { item.count-- if (!player.inventory.add(targetItem)) { @@ -186,7 +186,7 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6 } override fun canInteract(item: ItemStack, player: Player, context: Context): Boolean { - return player.level().getBlockState(context.blockPos) in mapping + return player.level.getBlockState(context.blockPos) in mapping } override fun interact(item: ItemStack, player: Player, context: Context): InteractionResult { @@ -202,13 +202,13 @@ 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) - val level = player.level() as? ServerLevel ?: return InteractionResult.SUCCESS + val level = player.level as? ServerLevel ?: return InteractionResult.SUCCESS level.setBlock(context.blockPos, Blocks.CAULDRON.defaultBlockState(), Block.UPDATE_ALL) cap.fill(toFill, IFluidHandler.FluidAction.EXECUTE) - if (item.count != 1 && !player.level().isClientSide) { + if (item.count != 1 && !player.level.isClientSide) { item.count-- if (!player.inventory.add(targetItem)) { @@ -216,13 +216,13 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6 } } - return InteractionResult.sidedSuccess(player.level().isClientSide) + return InteractionResult.sidedSuccess(player.level.isClientSide) } } private object FillEmptyCapability : Interaction { override fun canInteract(item: ItemStack, player: Player, context: Context): Boolean { - val target = player.level().getBlockEntity(context.blockPos)?.getCapability(ForgeCapabilities.FLUID_HANDLER, context.side)?.orNull() ?: return false + val target = player.level.getBlockEntity(context.blockPos)?.getCapability(ForgeCapabilities.FLUID_HANDLER, context.side)?.orNull() ?: return false val cap = item.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).orNull() ?: return false return target.iterator().any { !it.isEmpty } || cap.iterator().any { !it.isEmpty } } @@ -233,21 +233,21 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6 val targetItem = if (item.count == 1) item else item.copyWithCount(1) val itemCap = targetItem.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).orNull() ?: return InteractionResult.FAIL - val blockCap = player.level().getBlockEntity(context.blockPos)?.getCapability(ForgeCapabilities.FLUID_HANDLER, context.side)?.orNull() ?: return InteractionResult.FAIL + val blockCap = player.level.getBlockEntity(context.blockPos)?.getCapability(ForgeCapabilities.FLUID_HANDLER, context.side)?.orNull() ?: return InteractionResult.FAIL val fluid = itemCap[0] if (fluid.isEmpty) { // заполняем из блока - val moveResult = moveFluid(source = blockCap, destination = itemCap, actuallyDrain = !player.level().isClientSide, actuallyFill = !player.level().isClientSide) + val moveResult = moveFluid(source = blockCap, destination = itemCap, actuallyDrain = !player.level.isClientSide, actuallyFill = !player.level.isClientSide) if (!moveResult.isEmpty) { 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) } - if (item.count != 1 && !player.level().isClientSide) { + if (item.count != 1 && !player.level.isClientSide) { item.count-- if (!player.inventory.add(targetItem)) { @@ -255,21 +255,21 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6 } } - return InteractionResult.sidedSuccess(player.level().isClientSide) + return InteractionResult.sidedSuccess(player.level.isClientSide) } else { return InteractionResult.FAIL } } else { - val moveResult = moveFluid(source = itemCap, destination = blockCap, actuallyDrain = !player.level().isClientSide, actuallyFill = !player.level().isClientSide) + val moveResult = moveFluid(source = itemCap, destination = blockCap, actuallyDrain = !player.level.isClientSide, actuallyFill = !player.level.isClientSide) if (!moveResult.isEmpty) { 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) } - if (item.count != 1 && !player.level().isClientSide) { + if (item.count != 1 && !player.level.isClientSide) { item.count-- if (!player.inventory.add(targetItem)) { @@ -277,7 +277,7 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6 } } - return InteractionResult.sidedSuccess(player.level().isClientSide) + return InteractionResult.sidedSuccess(player.level.isClientSide) } else { return InteractionResult.FAIL } 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 8447d888a..5f02f26c9 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 @@ -145,7 +145,7 @@ class MatterDustItem : Item(Properties().stacksTo(64)), IMatterItem { val matterHalf = getMatterValue(pStack)?.matter?.div(2) ?: return true val halfStack = pStack.copyWithCount(1) - matter(halfStack, -addMatterValue(pStack, -matterHalf, pPlayer.level().isClientSide())) + matter(halfStack, -addMatterValue(pStack, -matterHalf, pPlayer.level.isClientSide())) pSlot.set(halfStack) if (getMatterValue(pStack)?.matter!! <= Decimal.ZERO) { @@ -175,13 +175,13 @@ class MatterDustItem : Item(Properties().stacksTo(64)), IMatterItem { val matterHalf = getMatterValue(pStack)?.matter?.div(2) ?: return true val halfStack = pStack.copyWithCount(1) - matter(halfStack, -addMatterValue(pStack, -matterHalf, pPlayer.level().isClientSide())) + matter(halfStack, -addMatterValue(pStack, -matterHalf, pPlayer.level.isClientSide())) pAccess.set(halfStack) return true } else if (pOther.item is MatterDustItem && pOther.count == 1) { val matterOther = getMatterValue(pOther)?.matter ?: return true - val diff = addMatterValue(pStack, matterOther, pPlayer.level().isClientSide()) + val diff = addMatterValue(pStack, matterOther, pPlayer.level.isClientSide()) if (matterOther - diff <= Decimal.ZERO) { pOther.shrink(1) 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 7537b407d..667e35616 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 @@ -78,19 +78,19 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1) override fun getCraftingRemainingItem(itemStack: ItemStack): ItemStack { val player = ForgeHooks.getCraftingPlayer() ?: return itemStack.copy() - if (player.level().isClientSide) return itemStack.copy() + if (player.level.isClientSide) return itemStack.copy() if (!isPrimed(itemStack)) { itemStack.hurtAndBreak(1, player) {} } else { - val level = player.level() as ServerLevel + val level = player.level as ServerLevel itemStack.hurtAndBreak(level.random.nextInt(1, 20), player) {} unprime(itemStack) val (ex, ey, ez) = Vector.atCenterOf(player.blockPosition()) - val exp = Explosion(player.level(), player, ex, ey, ez, 1f, false, if (ToolsConfig.ExplosiveHammer.EXPLOSION_DAMAGE_BLOCKS) Explosion.BlockInteraction.DESTROY_WITH_DECAY else Explosion.BlockInteraction.KEEP) + val exp = Explosion(player.level, player, ex, ey, ez, 1f, false, if (ToolsConfig.ExplosiveHammer.EXPLOSION_DAMAGE_BLOCKS) Explosion.BlockInteraction.DESTROY_WITH_DECAY else Explosion.BlockInteraction.KEEP) exp.explode() exp.finalizeExplosion(true) @@ -150,20 +150,20 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1) } fun attackAt(itemStack: ItemStack, attacker: LivingEntity, pos: Vec3, aim: Vec3, hand: InteractionHand) { - if (!isPrimed(itemStack) || attacker.level().isClientSide || attacker is Player && attacker.getAttackStrengthScale(0.4f) < 0.98f) + if (!isPrimed(itemStack) || attacker.level.isClientSide || attacker is Player && attacker.getAttackStrengthScale(0.4f) < 0.98f) return 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_WITH_DECAY else Explosion.BlockInteraction.KEEP) exp.explode() exp.finalizeExplosion(true) if (!ToolsConfig.ExplosiveHammer.EXPLOSION_DAMAGE_BLOCKS) exp.clearToBlow() - val level = attacker.level() as ServerLevel + val level = attacker.level as ServerLevel val hitEntities = ObjectArraySet() hitEntities.add(attacker) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt index b36d1bc2e..f73d1e979 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt @@ -101,7 +101,7 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani victim.matteryPlayer?.let { if (it.isAndroid) { victim.invulnerableTime = 0 - victim.hurt(MatteryDamageSource(attacker.level().registryAccess().damageType(MDamageTypes.EMP), attacker, itemStack), 8f) + victim.hurt(MatteryDamageSource(attacker.level.registryAccess().damageType(MDamageTypes.EMP), attacker, itemStack), 8f) } } @@ -110,11 +110,11 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani itemStack.getCapability(MatteryCapability.ENERGY).ifPresentK { if (it.extractEnergyExact(ENERGY_PER_SWING, false)) { - it.extractEnergy(attacker.level().random.nextVariance(ENERGY_PER_SWING_VARIANCE), false) + it.extractEnergy(attacker.level.random.nextVariance(ENERGY_PER_SWING_VARIANCE), false) victim.matteryPlayer?.let { if (it.isAndroid && it.androidEnergy.extractEnergyExact(ENERGY_ZAP, false)) { - it.androidEnergy.extractEnergy(attacker.level().random.nextVariance(ENERGY_ZAP_VARIANCE), false) - victim.hurt(MatteryDamageSource(attacker.level().registryAccess().damageType(MDamageTypes.EMP), attacker, itemStack), 8f) + it.androidEnergy.extractEnergy(attacker.level.random.nextVariance(ENERGY_ZAP_VARIANCE), false) + victim.hurt(MatteryDamageSource(attacker.level.registryAccess().damageType(MDamageTypes.EMP), attacker, itemStack), 8f) } } } @@ -163,12 +163,12 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani if (blockState.`is`(BlockTags.SWORD_EFFICIENT)) { if (energy?.extractEnergyExact(PLANT_POWER_COST, false) == true) - energy.extractEnergyExact(user.level().random.nextVariance(PLANT_POWER_COST_VARIANCE), false) + energy.extractEnergyExact(user.level.random.nextVariance(PLANT_POWER_COST_VARIANCE), false) } if (blockState.`is`(Blocks.COBWEB)) { if (energy?.extractEnergyExact(COBWEB_POWER_COST, false) == true) - energy.extractEnergyExact(user.level().random.nextVariance(COBWEB_POWER_COST_VARIANCE), false) + energy.extractEnergyExact(user.level.random.nextVariance(COBWEB_POWER_COST_VARIANCE), false) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaRifleItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaRifleItem.kt index afdbc7a1d..053b96d5e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaRifleItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaRifleItem.kt @@ -25,8 +25,8 @@ class PlasmaRifleItem : PlasmaWeaponItem(PlasmaWeaponData get() = Angle(-0.02, 0.0, 0.0) override fun primaryFire(itemStack: ItemStack, player: Player, dt: PlasmaWeaponDataTable): Boolean { - if (!player.level().isClientSide) { - val arrow = PlasmaProjectile(player.level()) + if (!player.level.isClientSide) { + val arrow = PlasmaProjectile(player.level) arrow.position = player.eyePosition val calc = VelocityCalculation(player, force = 4.0, deviation = 0.3) @@ -34,14 +34,14 @@ class PlasmaRifleItem : PlasmaWeaponItem(PlasmaWeaponData arrow.owner = player - player.level().addFreshEntity(arrow) + player.level.addFreshEntity(arrow) } else { dt.doFireAnim(deviation = rotFireAnimDeviation) } receiveHeat(itemStack, player, 10.0, dt) - player.level().playSound( + player.level.playSound( player, player, MSoundEvents.RIFLE_SHOT, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt index 54e499f64..71eccdb0e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/PlasmaWeaponItem.kt @@ -280,7 +280,7 @@ abstract class PlasmaWeaponItem(tables: KClass, pr dt.heatCooldown = overheatCooldown if (!before) { - player.level().playSound(player, player, MSoundEvents.PLASMA_WEAPON_OVERHEAT, SoundSource.PLAYERS, 1f, 1f) + player.level.playSound(player, player, MSoundEvents.PLASMA_WEAPON_OVERHEAT, SoundSource.PLAYERS, 1f, 1f) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/VelocityCalculation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/VelocityCalculation.kt index a63d7e5be..a3d95a956 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/VelocityCalculation.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/VelocityCalculation.kt @@ -90,7 +90,7 @@ class VelocityCalculation( if (owner != null) { val ownerVel = owner.deltaMovement - if (owner.onGround()) { + if (owner.isOnGround) { velocity += ownerVel } else { velocity += Vec3(ownerVel.x, 0.0, ownerVel.z) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt index d93732cb3..487affde0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt @@ -84,10 +84,10 @@ class ExopackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen } private fun popFurnaceExp() { - if (capability.isExopackSmeltingInstalled && capability.exopackSmelterExperience >= 1f && !player.level().isClientSide) { + if (capability.isExopackSmeltingInstalled && capability.exopackSmelterExperience >= 1f && !player.level.isClientSide) { val whole = capability.exopackSmelterExperience.toInt() capability.exopackSmelterExperience -= whole - ExperienceOrb.award(player.level() as ServerLevel, player.position(), whole) + ExperienceOrb.award(player.level as ServerLevel, player.position(), whole) } } @@ -144,7 +144,7 @@ class ExopackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen super.slotsChanged(container) if (container == craftingGrid) { - CraftingMenu.slotChangedCraftingGrid(this, capability.ply.level(), capability.ply, craftingGrid, craftingResultContainer) + CraftingMenu.slotChangedCraftingGrid(this, capability.ply.level, capability.ply, craftingGrid, craftingResultContainer) } } @@ -168,7 +168,7 @@ class ExopackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen craftingResultContainer.clearContent() - if (!player.level().isClientSide) { + if (!player.level.isClientSide) { for (slot in craftingGrid.slotIterator()) { val leftover = moveItemStackToSlots(slot.item, playerInventorySlots) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index b2fcf7d17..73709213c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -406,7 +406,7 @@ abstract class MatteryMenu( override fun stillValid(player: Player): Boolean { if (tile == null) return true - if (player.level().getBlockEntity(tile.blockPos) !== tile) { + if (player.level.getBlockEntity(tile.blockPos) !== tile) { return false } 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 dcc5bb2f2..6aeed61ad 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 @@ -57,7 +57,7 @@ class PainterMenu( return super.mayPlace(itemStack) } - return super.mayPlace(itemStack) && inventory.player.level().recipeManager.byType(MRecipes.PAINTER).values.any { it.value.matches(itemStack) } + return super.mayPlace(itemStack) && inventory.player.level.recipeManager.byType(MRecipes.PAINTER).values.any { it.value.matches(itemStack) } } } @@ -128,7 +128,7 @@ class PainterMenu( private fun rescan() { possibleRecipes.clear() - possibleRecipes.addAll(inventory.player.level().recipeManager.byType(MRecipes.PAINTER).values.iterator().filter { it.value.matches(inputContainer[0]) }) + possibleRecipes.addAll(inventory.player.level.recipeManager.byType(MRecipes.PAINTER).values.iterator().filter { it.value.matches(inputContainer[0]) }) listeners.accept(Unit) if (tile !is PainterBlockEntity) return @@ -136,12 +136,12 @@ class PainterMenu( if (inputContainer.isEmpty || selectedRecipe == null) { outputContainer.clearContent() } else { - val recipe = inventory.player.level().recipeManager.byKey(selectedRecipe!!).get() as AbstractPainterRecipe? + val recipe = inventory.player.level.recipeManager.byKey(selectedRecipe!!).get() as AbstractPainterRecipe? - if (recipe == null || !recipe.value.canCraft(dyeStoredDirect) || !recipe.value.matches(inputContainer, inventory.player.level())) { + if (recipe == null || !recipe.value.canCraft(dyeStoredDirect) || !recipe.value.matches(inputContainer, inventory.player.level)) { outputContainer.clearContent() } else { - outputContainer[0] = recipe.value.assemble(inputContainer, inventory.player.level().registryAccess()) + outputContainer[0] = recipe.value.assemble(inputContainer, inventory.player.level.registryAccess()) lastRecipe = recipe } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterEntanglerMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterEntanglerMenu.kt index 3c672c57d..582044b64 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterEntanglerMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterEntanglerMenu.kt @@ -47,7 +47,7 @@ class MatterEntanglerMenu( object : MatterySlot(it, i) { override fun mayPlace(itemStack: ItemStack): Boolean { val shadow = ShadowCraftingContainer.shadow(it, i, itemStack) - val level = player.level() + val level = player.level return super.mayPlace(itemStack) && (level ?: return false) .recipeManager diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt index 1827a4877..0def6a9c5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt @@ -324,7 +324,7 @@ class MatterPanelMenu( } fun fullPatternBroadcast() { - if (inventory.player.level().isClientSide) { + if (inventory.player.level.isClientSide) { initialSend = true return } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt index c51eba132..9b9197192 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt @@ -30,7 +30,7 @@ class SmokeParticlesPacket(val x: Double, val y: Double, val z: Double) : Matter } override fun play(context: MNetworkContext) { - minecraft.player?.level()?.let { + minecraft.player?.level?.let { makeSmoke(x, y, z, it.random, it) } } @@ -54,7 +54,7 @@ class BlockEntitySyncPacket(val position: BlockPos, val buffer: ByteArray, val v } private fun execute() { - val level = minecraft.player?.level() + val level = minecraft.player?.level if (level == null) { LOGGER.error("Received BlockEntitySyncPacket before we are in valid level.") @@ -127,7 +127,7 @@ object GenericNetworkChannel : MatteryNetworkChannel( } fun makeSmoke(excluded: ServerPlayer, x: Double, y: Double, z: Double) { - send(PacketDistributor.NEAR.with { PacketDistributor.TargetPoint(excluded, x, y, z, 64.0, excluded.level().dimension()) }, SmokeParticlesPacket(x, y, z)) + send(PacketDistributor.NEAR.with { PacketDistributor.TargetPoint(excluded, x, y, z, 64.0, excluded.level.dimension()) }, SmokeParticlesPacket(x, y, z)) } fun register() { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt index de0d36f7c..c79c1c8fe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/MatteryPlayerNetworkChannel.kt @@ -523,9 +523,9 @@ data class ExopackSmokePacket(val player: UUID) : MatteryPacket { override fun play(context: MNetworkContext) { context.packetHandled = true - // minecraft.player?.level()?.getPlayerByUUID(player)?.matteryPlayer?.spawnExopackSmoke = true + // minecraft.player?.level?.getPlayerByUUID(player)?.matteryPlayer?.spawnExopackSmoke = true - minecraft.player?.level()?.getPlayerByUUID(player)?.let { ply -> + minecraft.player?.level?.getPlayerByUUID(player)?.let { ply -> if (ply != minecraft.player || minecraft.gameRenderer.mainCamera.isDetached) { var (x, y, z) = ply.position @@ -535,7 +535,7 @@ data class ExopackSmokePacket(val player: UUID) : MatteryPacket { x += kotlin.math.cos(deg) * -0.4 z += kotlin.math.sin(deg) * -0.4 - val level = ply.level() + val level = ply.level val random = level.random for (i in 0 .. random.nextInt(2, 4)) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidResearchTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidResearchTrigger.kt index 800d22894..45f48abee 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidResearchTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidResearchTrigger.kt @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.triggers import com.mojang.serialization.Codec import com.mojang.serialization.codecs.RecordCodecBuilder -import net.minecraft.advancements.critereon.ContextAwarePredicate import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import ru.dbotthepony.mc.otm.OverdriveThatMatters diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidTravelUnderwater.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidTravelUnderwater.kt index 94d02e89d..07fc6cdc8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidTravelUnderwater.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/AndroidTravelUnderwater.kt @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.triggers import com.mojang.serialization.Codec import com.mojang.serialization.codecs.RecordCodecBuilder -import net.minecraft.advancements.critereon.ContextAwarePredicate import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import ru.dbotthepony.mc.otm.OverdriveThatMatters diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ExopackTriggers.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ExopackTriggers.kt index 1f8523669..31b52ddd7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ExopackTriggers.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ExopackTriggers.kt @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.triggers import com.mojang.serialization.Codec import com.mojang.serialization.codecs.RecordCodecBuilder -import net.minecraft.advancements.critereon.ContextAwarePredicate import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import ru.dbotthepony.mc.otm.OverdriveThatMatters diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/HurtTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/HurtTrigger.kt index a175050d3..899cce78a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/HurtTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/HurtTrigger.kt @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.triggers import com.mojang.serialization.Codec import com.mojang.serialization.codecs.RecordCodecBuilder -import net.minecraft.advancements.critereon.ContextAwarePredicate import net.minecraft.advancements.critereon.DamagePredicate import net.minecraft.advancements.critereon.DamageSourcePredicate import net.minecraft.advancements.critereon.EntityPredicate diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ItemTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ItemTrigger.kt index c4acc7ccc..d14c49011 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ItemTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/ItemTrigger.kt @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.triggers import com.mojang.serialization.Codec import com.mojang.serialization.codecs.RecordCodecBuilder -import net.minecraft.advancements.critereon.ContextAwarePredicate import net.minecraft.advancements.critereon.ItemPredicate import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt index 7a6eb77ef..dbbc1bb97 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt @@ -14,7 +14,6 @@ import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import net.minecraft.advancements.Criterion import net.minecraft.advancements.CriterionTrigger import net.minecraft.advancements.CriterionTriggerInstance -import net.minecraft.advancements.critereon.ContextAwarePredicate import net.minecraft.advancements.critereon.DeserializationContext import net.minecraft.advancements.critereon.EntityPredicate import net.minecraft.advancements.critereon.SerializationContext @@ -28,6 +27,8 @@ import ru.dbotthepony.mc.otm.core.toJsonStrict import java.util.Optional import java.util.function.Predicate +typealias ContextAwarePredicate = EntityPredicate.Composite + // allows to support both 1.20.1 and 1.20.2 with ease // and has slightly less memory footprint than vanilla SimpleCriterionTrigger abstract class MCriterionTrigger.AbstractInstance>(private val id: ResourceLocation) : CriterionTrigger { @@ -112,7 +113,7 @@ abstract class MCriterionTrigger.AbstractInstance>(priv val context = deserializationContext.get().lastOrNull() ?: return DataResult.error { "Not current deserializing trigger instance" } return try { - DataResult.success(Pair.of(EntityPredicate.fromJson(JsonObject().also { it["a"] = ops.convertTo(JsonOps.INSTANCE, input) }, "a", context), ops.empty())) + DataResult.success(Pair.of(EntityPredicate.Composite.fromJson(JsonObject().also { it["a"] = ops.convertTo(JsonOps.INSTANCE, input) }, "a", context), ops.empty())) } catch (err: Exception) { DataResult.error { "Failed to deserialize ContextAwarePredicate: " + err.message } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NanobotsArmorTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NanobotsArmorTrigger.kt index 6ad2e65c6..e6266921f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NanobotsArmorTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/NanobotsArmorTrigger.kt @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.triggers import com.mojang.serialization.Codec import com.mojang.serialization.codecs.RecordCodecBuilder -import net.minecraft.advancements.critereon.ContextAwarePredicate import net.minecraft.advancements.critereon.MinMaxBounds.Doubles import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/SingletonTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/SingletonTrigger.kt index 8a7536d80..c21893896 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/SingletonTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/SingletonTrigger.kt @@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.triggers import com.mojang.serialization.Codec import com.mojang.serialization.codecs.RecordCodecBuilder import net.minecraft.advancements.Criterion -import net.minecraft.advancements.critereon.ContextAwarePredicate import net.minecraft.resources.ResourceLocation import java.util.* From e3e02dbad2d46c4cb813dafddae379e6ddd61c32 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 03:28:59 +0700 Subject: [PATCH 1173/1199] More backporting --- .../mc/otm/client/render/FontRenderer.kt | 2 -- .../mc/otm/client/render/GlitchRenderer.kt | 4 ++-- .../mc/otm/client/screen/MatteryScreen.kt | 17 +++++------------ .../client/screen/panels/EntityRendererPanel.kt | 2 +- .../mc/otm/client/screen/panels/Widget2Panel.kt | 2 +- 5 files changed, 9 insertions(+), 18 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt index 818e3dc95..891815dad 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt @@ -1,9 +1,7 @@ package ru.dbotthepony.mc.otm.client.render import com.mojang.blaze3d.vertex.PoseStack -import com.mojang.blaze3d.vertex.VertexSorting import net.minecraft.client.gui.Font - import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.network.chat.Component import net.minecraft.util.FormattedCharSequence diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GlitchRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GlitchRenderer.kt index 9a3fcf2cb..34c5747a1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GlitchRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/GlitchRenderer.kt @@ -148,7 +148,7 @@ object GlitchRenderer { val glitchBuffer = glitchBuffer val projection = RenderSystem.getProjectionMatrix() - RenderSystem.setProjectionMatrix(Matrix4f(), VertexSorting.ORTHOGRAPHIC_Z) + RenderSystem.setProjectionMatrix(Matrix4f()) RenderSystem.getModelViewStack().also { it.pushPose() @@ -244,7 +244,7 @@ object GlitchRenderer { RenderSystem.setShaderTexture(0, glitchBuffer.colorTextureId) draw(0.0, 0.0) - RenderSystem.setProjectionMatrix(projection, VertexSorting.DISTANCE_TO_ORIGIN) + RenderSystem.setProjectionMatrix(projection) RenderSystem.getModelViewStack().popPose() RenderSystem.applyModelViewMatrix() } 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 5c43c66de..d3fbe4daa 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 @@ -12,6 +12,7 @@ import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import net.minecraft.world.inventory.Slot import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemDisplayContext import net.minecraft.world.item.ItemStack import net.minecraftforge.client.event.ContainerScreenEvent.Render.Background import net.minecraftforge.client.event.ContainerScreenEvent.Render.Foreground @@ -91,19 +92,11 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit fun renderItemStack(graphics: MGUIGraphics, itemstack: ItemStack, countOverride: String? = null) { if (!itemstack.isEmpty) { RenderSystem.enableDepthTest() - - val (x, y) = graphics.pose.translation() - - graphics.parent.renderItem( - requireNotNull(ru.dbotthepony.mc.otm.client.minecraft.player) { "yo, dude, what the fuck" }, - itemstack, - 1, - 1, - (x + y * ru.dbotthepony.mc.otm.client.minecraft.window.guiScaledWidth).toInt() - ) - + itemRenderer.renderGuiItem(graphics.pose, itemstack, 1, 1) RenderSystem.depthFunc(GL11.GL_ALWAYS) - graphics.parent.renderItemDecorations( + + itemRenderer.renderGuiItemDecorations( + graphics.pose, super.font, itemstack, 1, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt index f5fbc7871..3dc6017e0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt @@ -174,7 +174,7 @@ class EntityRendererPanel @JvmOverloads constructor( val renderY = (height * 0.9f).toInt() InventoryScreen.renderEntityInInventoryFollowsMouse( - graphics.parent, + graphics.pose, renderX, renderY, renderScale, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Widget2Panel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Widget2Panel.kt index ca49c74fb..d904817e7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Widget2Panel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Widget2Panel.kt @@ -91,7 +91,7 @@ abstract class Widget2Panel( override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { RenderSystem.depthFunc(GL11.GL_ALWAYS) - getOrCreateWidget().render(graphics.parent, mouseX.toInt(), mouseY.toInt(), partialTick) + getOrCreateWidget().render(graphics.pose, mouseX.toInt(), mouseY.toInt(), partialTick) RenderSystem.depthFunc(GL11.GL_ALWAYS) } From 0bcc078fe900af926e83f98583153338618dff2c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 11:19:20 +0700 Subject: [PATCH 1174/1199] More backporting --- .../mc/otm/block/BlackHoleBlock.kt | 6 +- .../ru/dbotthepony/mc/otm/block/Cables.kt | 14 +++-- .../mc/otm/block/ExplosionDebuggerBlock.kt | 10 ++- .../dbotthepony/mc/otm/block/MatteryBlock.kt | 4 +- .../otm/block/decorative/CargoCrateBlock.kt | 9 ++- .../mc/otm/block/decorative/DevChestBlock.kt | 8 ++- .../mc/otm/block/decorative/EngineBlock.kt | 10 ++- .../decorative/InfiniteWaterSourceBlock.kt | 10 ++- .../mc/otm/block/decorative/LaboratoryLamp.kt | 16 ++++- .../decorative/TritaniumPressurePlate.kt | 4 +- .../decorative/CargoCrateBlockEntity.kt | 9 +-- .../mc/otm/block/tech/AndroidChargerBlock.kt | 7 ++- .../mc/otm/block/tech/EnergyServoBlock.kt | 10 ++- .../block/tech/GravitationStabilizerBlock.kt | 9 ++- .../otm/block/tech/PhantomAttractorBlock.kt | 10 ++- .../otm/client/render/DynamicBufferSource.kt | 16 ++--- .../mc/otm/client/render/FontRenderer.kt | 2 +- .../mc/otm/client/render/MGUIGraphics.kt | 63 +++++++++++++++++-- .../screen/panels/slot/AbstractSlotPanel.kt | 3 +- .../client/screen/panels/slot/SlotPanel.kt | 9 ++- .../mc/otm/compat/curios/CuriosCompat.kt | 2 +- .../jei/MatterEntanglerRecipeCategory.kt | 4 +- .../otm/compat/jei/MicrowaveRecipeCategory.kt | 4 +- .../mc/otm/item/ChestUpgraderItem.kt | 6 +- .../mc/otm/item/weapon/EnergySwordItem.kt | 24 ++++--- .../mc/otm/matter/MatterManager.kt | 4 +- .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 43 +++++-------- .../mc/otm/registry/MCreativeTabs.kt | 55 +++++++--------- .../dbotthepony/mc/otm/registry/MRegistry.kt | 52 ++++++++------- .../resources/META-INF/accesstransformer.cfg | 43 +++++++------ 30 files changed, 299 insertions(+), 167 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/BlackHoleBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/BlackHoleBlock.kt index d57c6f303..9b7e6ab92 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/BlackHoleBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/BlackHoleBlock.kt @@ -20,7 +20,7 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes class BlackHoleBlock : - Block(Properties.of(Material.AIR, DyeColor.BLACK).noCollission().pushReaction(PushReaction.BLOCK).sound(SoundType.STONE).strength(-1f, 7200000.0f)), EntityBlock { + Block(Properties.of(Material.AIR, DyeColor.BLACK).noCollission().sound(SoundType.STONE).strength(-1f, 7200000.0f)), EntityBlock { override fun getShape( p_60555_: BlockState, p_60556_: BlockGetter, @@ -30,6 +30,10 @@ class BlackHoleBlock : return SHAPE } + override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { + return PushReaction.BLOCK + } + override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return BlackHoleBlockEntity(blockPos, blockState) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt index d0405c814..04301faa0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt @@ -14,14 +14,14 @@ import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.level.block.state.properties.BooleanProperty -import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.shapes.BooleanOp import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.Shapes import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.entity.MatterCableBlockEntity import ru.dbotthepony.mc.otm.block.entity.StorageCableBlockEntity -import ru.dbotthepony.mc.otm.block.entity.cable.EnergyCableBlockEntity import java.util.Collections import java.util.EnumMap @@ -38,6 +38,10 @@ abstract class CableBlock(properties: Properties) : MatteryBlock(properties) { override fun hasDynamicShape() = true + override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { + return PushReaction.BLOCK + } + override fun createBlockStateDefinition(builder: StateDefinition.Builder) { builder.add( CONNECTION_SOUTH, @@ -103,7 +107,7 @@ abstract class CableBlock(properties: Properties) : MatteryBlock(properties) { } } -class MatterCableBlock : CableBlock(Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock { +class MatterCableBlock : CableBlock(Properties.of(Material.METAL).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock { private val shapes = generateShapes(0.15) @Suppress("OVERRIDE_DEPRECATION") @@ -116,7 +120,7 @@ class MatterCableBlock : CableBlock(Properties.of().mapColor(MapColor.METAL).req } } -class StorageCableBlock : CableBlock(Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock { +class StorageCableBlock : CableBlock(Properties.of(Material.METAL).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock { private val shapes = generateShapes(0.185) @Suppress("OVERRIDE_DEPRECATION") @@ -129,7 +133,7 @@ class StorageCableBlock : CableBlock(Properties.of().mapColor(MapColor.METAL).re } } -class EnergyCableBlock(val factory: (blockPos: BlockPos, blockState: BlockState) -> BlockEntity) : CableBlock(Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock { +class EnergyCableBlock(val factory: (blockPos: BlockPos, blockState: BlockState) -> BlockEntity) : CableBlock(Properties.of(Material.METAL).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock { private val shapes = generateShapes(0.185) @Suppress("OVERRIDE_DEPRECATION") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/ExplosionDebuggerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/ExplosionDebuggerBlock.kt index 2643ffc89..c2709a0dd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/ExplosionDebuggerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/ExplosionDebuggerBlock.kt @@ -9,15 +9,21 @@ import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.entity.BlockEntityTicker import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.PushReaction import ru.dbotthepony.mc.otm.block.entity.blackhole.BlockEntityExplosionDebugger import ru.dbotthepony.mc.otm.block.entity.blackhole.BlockEntitySphereDebugger import ru.dbotthepony.mc.otm.registry.MBlockEntities -class BlockExplosionDebugger : Block(Properties.of().sound(SoundType.STONE)), EntityBlock { +class BlockExplosionDebugger : Block(Properties.of(Material.METAL).sound(SoundType.STONE)), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return BlockEntityExplosionDebugger(p_153215_, p_153216_) } + override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { + return PushReaction.BLOCK + } + override fun getTicker( p_153212_: Level, p_153213_: BlockState, @@ -31,7 +37,7 @@ class BlockExplosionDebugger : Block(Properties.of().sound(SoundType.STONE)), En } } -class BlockSphereDebugger : Block(Properties.of()), EntityBlock { +class BlockSphereDebugger : Block(Properties.of(Material.STONE)), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return BlockEntitySphereDebugger(p_153215_, p_153216_) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt index c7806370f..666dbf084 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt @@ -20,7 +20,7 @@ import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.EntityBlock import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.properties.Property -import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.Material import net.minecraft.world.phys.BlockHitResult import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.entity.IRedstoneControlled @@ -238,7 +238,7 @@ abstract class MatteryBlock(properties: Properties = DEFAULT_PROPERTIES) : Block } companion object { - val DEFAULT_PROPERTIES: Properties = Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().destroyTime(1.5f).explosionResistance(25.0f) + val DEFAULT_PROPERTIES: Properties = Properties.of(Material.METAL).requiresCorrectToolForDrops().destroyTime(1.5f).explosionResistance(25.0f) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/CargoCrateBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/CargoCrateBlock.kt index 09826b342..3074a4033 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/CargoCrateBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/CargoCrateBlock.kt @@ -13,7 +13,8 @@ import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.level.block.state.properties.BooleanProperty -import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.Shapes import net.minecraft.world.phys.shapes.VoxelShape @@ -23,7 +24,7 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.shapes.BlockShapes class CargoCrateBlock(val color: DyeColor?) : RotatableMatteryBlock( - Properties.of().mapColor(color?.mapColor ?: MapColor.COLOR_BLUE).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.5f, 30.0f) + Properties.of(Material.METAL, color ?: DyeColor.BLUE).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.5f, 30.0f) ), EntityBlock { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return CargoCrateBlockEntity(blockPos, blockState) @@ -34,6 +35,10 @@ class CargoCrateBlock(val color: DyeColor?) : RotatableMatteryBlock( builder.add(IS_OPEN) } + override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { + return PushReaction.BLOCK + } + override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { return super.getStateForPlacement(context)?.setValue(IS_OPEN, false) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/DevChestBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/DevChestBlock.kt index 9e2a1fbd5..af30a777e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/DevChestBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/DevChestBlock.kt @@ -4,11 +4,17 @@ import net.minecraft.core.BlockPos import net.minecraft.world.level.block.EntityBlock import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.PushReaction import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.decorative.DevChestBlockEntity -class DevChestBlock : RotatableMatteryBlock(Properties.of().destroyTime(-1f).explosionResistance(360000f)), EntityBlock { +class DevChestBlock : RotatableMatteryBlock(Properties.of(Material.METAL).destroyTime(-1f).explosionResistance(360000f)), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return DevChestBlockEntity(p_153215_, p_153216_) } + + override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { + return PushReaction.NORMAL + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt index d879d13a3..3c26d807c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt @@ -3,12 +3,14 @@ package ru.dbotthepony.mc.otm.block.decorative import net.minecraft.ChatFormatting import net.minecraft.core.BlockPos import net.minecraft.network.chat.Component +import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.block.SoundType import net.minecraft.world.level.block.state.BlockState -import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock @@ -17,7 +19,7 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.shapes.BlockShapes -class EngineBlock : RotatableMatteryBlock(Properties.of().mapColor(MapColor.COLOR_ORANGE).sound(SoundType.METAL).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) { +class EngineBlock : RotatableMatteryBlock(Properties.of(Material.METAL, DyeColor.ORANGE).sound(SoundType.METAL).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) { override fun appendHoverText( p_49816_: ItemStack, p_49817_: BlockGetter?, @@ -28,6 +30,10 @@ class EngineBlock : RotatableMatteryBlock(Properties.of().mapColor(MapColor.COLO p_49818_.add(TranslatableComponent("$descriptionId.desc").withStyle(ChatFormatting.DARK_GRAY)) } + override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { + return PushReaction.NORMAL + } + override fun rotationFreedom(): BlockRotationFreedom { return BlockRotationFreedom.DIRECTIONAL } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/InfiniteWaterSourceBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/InfiniteWaterSourceBlock.kt index faab35e82..8713d0210 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/InfiniteWaterSourceBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/InfiniteWaterSourceBlock.kt @@ -7,15 +7,21 @@ import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.entity.BlockEntityTicker import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState -import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.MaterialColor +import net.minecraft.world.level.material.PushReaction import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.decorative.InfiniteWaterSourceBlockEntity -class InfiniteWaterSourceBlock : RotatableMatteryBlock(Properties.of().destroyTime(1.5f).explosionResistance(10f).requiresCorrectToolForDrops().mapColor(MapColor.WATER)), EntityBlock { +class InfiniteWaterSourceBlock : RotatableMatteryBlock(Properties.of(Material.METAL, MaterialColor.WATER).destroyTime(1.5f).explosionResistance(10f).requiresCorrectToolForDrops()), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return InfiniteWaterSourceBlockEntity(p_153215_, p_153216_) } + override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { + return PushReaction.BLOCK + } + override fun getTicker(p_153212_: Level, p_153213_: BlockState, p_153214_: BlockEntityType): BlockEntityTicker? { if (p_153212_.isClientSide) return null diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt index 3dc4aa81c..090ee9ef2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.block.decorative import net.minecraft.ChatFormatting import net.minecraft.core.BlockPos import net.minecraft.network.chat.Component +import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.item.TooltipFlag @@ -13,7 +14,8 @@ import net.minecraft.world.level.block.* import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.level.block.state.properties.BlockStateProperties -import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.Shapes import net.minecraft.world.phys.shapes.VoxelShape @@ -28,12 +30,16 @@ import ru.dbotthepony.mc.otm.registry.MBlocks private val FACING_FULL = BlockRotationFreedom.DIRECTIONAL.property -class LaboratoryLampLight : Block(Properties.of().strength(-1.0F, 3600000.8F).noCollission().noLootTable().replaceable().lightLevel { 15 }) { +class LaboratoryLampLight : Block(Properties.of(Material.AIR).strength(-1.0F, 3600000.8F).noCollission().noLootTable().lightLevel { 15 }) { override fun createBlockStateDefinition(builder: StateDefinition.Builder) { super.createBlockStateDefinition(builder) builder.add(FACING_FULL) } + override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { + return PushReaction.DESTROY + } + override fun hasDynamicShape(): Boolean { return true } @@ -102,11 +108,15 @@ class LaboratoryLampLight : Block(Properties.of().strength(-1.0F, 3600000.8F).no } } -class LaboratoryLamp(val invertRedstone: Boolean) : Block(Properties.of().mapColor(MapColor.METAL).sound(SoundType.METAL).explosionResistance(12f).destroyTime(2f).requiresCorrectToolForDrops()) { +class LaboratoryLamp(val invertRedstone: Boolean) : Block(Properties.of(Material.METAL, DyeColor.WHITE).sound(SoundType.METAL).explosionResistance(12f).destroyTime(2f).requiresCorrectToolForDrops()) { init { registerDefaultState(stateDefinition.any().setValue(BlockStateProperties.LIT, !invertRedstone)) } + override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { + return PushReaction.NORMAL + } + override fun createBlockStateDefinition(builder: StateDefinition.Builder) { super.createBlockStateDefinition(builder) builder.add(FACING_FULL) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt index 2f02e1a24..1a37c06e3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt @@ -19,10 +19,12 @@ import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.level.block.state.properties.BlockSetType import net.minecraft.world.level.block.state.properties.BlockStateProperties +import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.PushReaction import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.get -class TritaniumPressurePlate(color: DyeColor?) : BasePressurePlateBlock(Properties.of().mapColor(color ?: DyeColor.LIGHT_BLUE).sound(SoundType.METAL).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), BlockSetType.IRON) { +class TritaniumPressurePlate(color: DyeColor?) : BasePressurePlateBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).sound(SoundType.METAL).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), BlockSetType.IRON) { override fun appendHoverText( p_49816_: ItemStack, p_49817_: BlockGetter?, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt index 285a6c7ca..921d991b8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt @@ -19,7 +19,7 @@ import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.gameevent.GameEvent -import net.minecraft.world.level.storage.loot.LootParams +import net.minecraft.world.level.storage.loot.LootContext import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets import net.minecraft.world.level.storage.loot.parameters.LootContextParams import net.minecraft.world.phys.Vec3 @@ -105,7 +105,7 @@ class CargoCrateBlockEntity( val lootTableSeed = lootTableSeed ?: 0L val server = level?.server ?: return - val loot = server.lootData.getLootTable(lootTable) + val loot = server.lootTables.get(lootTable) if (ply is ServerPlayer) { CriteriaTriggers.GENERATE_LOOT.trigger(ply, lootTable) @@ -114,15 +114,16 @@ class CargoCrateBlockEntity( this.lootTable = null this.lootTableSeed = null - val params = LootParams.Builder(level as ServerLevel) + val params = LootContext.Builder(level as ServerLevel) .withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(this.worldPosition)) if (ply != null) { params.withLuck(ply.luck).withParameter(LootContextParams.THIS_ENTITY, ply) } + params.withOptionalRandomSeed(lootTableSeed) Containers.dropContents(level as ServerLevel, blockPos, container) - loot.fill(container, params.create(LootContextParamSets.CHEST), lootTableSeed) + loot.fill(container, params.create(LootContextParamSets.CHEST)) } override val defaultDisplayName: Component diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt index 5b3afa5ef..94845f127 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt @@ -20,6 +20,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.level.block.state.properties.EnumProperty +import net.minecraft.world.level.material.Material import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape @@ -37,7 +38,7 @@ import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.oncePre import ru.dbotthepony.mc.otm.shapes.BlockShapes -class AndroidChargerBlock : RotatableMatteryBlock(Properties.of().destroyTime(2.5f).explosionResistance(40f).pushReaction(PushReaction.BLOCK).requiresCorrectToolForDrops()), EntityBlock { +class AndroidChargerBlock : RotatableMatteryBlock(Properties.of(Material.METAL).destroyTime(2.5f).explosionResistance(40f).requiresCorrectToolForDrops()), EntityBlock { enum class Type : StringRepresentable { BASE, MIDDLE, @@ -48,6 +49,10 @@ class AndroidChargerBlock : RotatableMatteryBlock(Properties.of().destroyTime(2. } } + override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { + return PushReaction.BLOCK + } + override fun createBlockStateDefinition(builder: StateDefinition.Builder) { super.createBlockStateDefinition(builder) builder.add(PART) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt index b6a0aaa1a..6a132d543 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.block.tech import net.minecraft.core.BlockPos +import net.minecraft.world.item.DyeColor import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraft.world.level.block.EntityBlock @@ -9,7 +10,8 @@ import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.entity.BlockEntityTicker import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState -import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock @@ -19,11 +21,15 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes -class EnergyServoBlock : RotatableMatteryBlock(Properties.of().mapColor(MapColor.COLOR_BLUE).sound(SoundType.METAL).explosionResistance(12f).destroyTime(2f).requiresCorrectToolForDrops()), EntityBlock { +class EnergyServoBlock : RotatableMatteryBlock(Properties.of(Material.METAL, DyeColor.BLUE).sound(SoundType.METAL).explosionResistance(12f).destroyTime(2f).requiresCorrectToolForDrops()), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return EnergyServoBlockEntity(p_153215_, p_153216_) } + override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { + return PushReaction.BLOCK + } + override fun getTicker( p_153212_: Level, p_153213_: BlockState, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt index e2f33127e..71ebb5841 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt @@ -4,6 +4,7 @@ import net.minecraft.core.BlockPos import net.minecraft.core.Direction import net.minecraft.core.SectionPos import net.minecraft.world.entity.LivingEntity +import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack import net.minecraft.world.item.context.BlockPlaceContext import net.minecraft.world.level.BlockGetter @@ -18,7 +19,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockBehaviour import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition -import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.Material import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape @@ -36,13 +37,17 @@ import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.shapes.BlockShapes import kotlin.math.PI -private val props = BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BLUE).sound(SoundType.METAL).pushReaction(PushReaction.BLOCK).requiresCorrectToolForDrops().strength(3f, 600.0f) +private val props = BlockBehaviour.Properties.of(Material.METAL, DyeColor.BLUE).sound(SoundType.METAL).requiresCorrectToolForDrops().strength(3f, 600.0f) class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return GravitationStabilizerBlockEntity(p_153215_, p_153216_) } + override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { + return PushReaction.BLOCK + } + override fun getTicker( p_153212_: Level, p_153213_: BlockState, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt index 9e0ff3fe7..b654f1e0a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt @@ -8,6 +8,7 @@ import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.MobSpawnType import net.minecraft.world.entity.SpawnGroupData import net.minecraft.world.entity.monster.Phantom +import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack import net.minecraft.world.item.context.BlockPlaceContext import net.minecraft.world.level.BlockGetter @@ -20,7 +21,8 @@ import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.level.block.state.properties.BlockStateProperties import net.minecraft.world.level.block.state.properties.DoubleBlockHalf -import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.AABB import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape @@ -34,7 +36,7 @@ import ru.dbotthepony.mc.otm.once import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.shapes.BlockShapes -class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of().mapColor(MapColor.COLOR_BLUE).sound(SoundType.METAL).destroyTime(3f).explosionResistance(12f).randomTicks()) { +class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of(Material.METAL, DyeColor.BLUE).sound(SoundType.METAL).destroyTime(3f).explosionResistance(12f).randomTicks()) { @Suppress("OVERRIDE_DEPRECATION") override fun randomTick( blockState: BlockState, @@ -68,6 +70,10 @@ class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of().mapColor(Map } } + override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { + return PushReaction.BLOCK + } + override fun createBlockStateDefinition(builder: StateDefinition.Builder) { super.createBlockStateDefinition(builder) builder.add(BlockStateProperties.DOUBLE_BLOCK_HALF) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt index d8b1c49c4..53c1f89e7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt @@ -3,12 +3,13 @@ package ru.dbotthepony.mc.otm.client.render import com.google.common.collect.ImmutableList import com.mojang.blaze3d.vertex.BufferBuilder import com.mojang.blaze3d.vertex.VertexConsumer -import com.mojang.blaze3d.vertex.VertexSorting +import it.unimi.dsi.fastutil.ints.IntArrays import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.ReferenceArraySet import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.client.renderer.RenderType import net.minecraft.client.renderer.Sheets +import org.joml.Vector3f private fun equals(existing: ImmutableList?, types: Array): Boolean { if (types.isEmpty()) { @@ -63,7 +64,8 @@ private fun equals(existing: ImmutableList?, types: ImmutableList= 0) { "Invalid minimal buffer size $minimalInitialBufferSize" } require(maximalInitialBufferSize >= minimalInitialBufferSize) { "Maximal buffer size $maximalInitialBufferSize must be greater or equal to minimal buffer size $minimalInitialBufferSize" } @@ -350,7 +352,7 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit for (state in bufferList) { if (state.dirty) { state.dirty = false - state.type.end(state.builder, vertexSorting) + state.type.end(state.builder, sortX, sortY, sortZ) } } } @@ -360,7 +362,7 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit if (state.dirty) { state.dirty = false - type.end(state.builder, vertexSorting) + type.end(state.builder, sortX, sortY, sortZ) } } @@ -369,7 +371,7 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit if (state.dirty) { state.dirty = false - type.end(state.builder, vertexSorting) + type.end(state.builder, sortX, sortY, sortZ) } for (ustate in state.dependants) { @@ -380,7 +382,7 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit private fun endBatchChain(state: State) { if (state.dirty) { state.dirty = false - state.type.end(state.builder, vertexSorting) + state.type.end(state.builder, sortX, sortY, sortZ) } for (ustate in state.dependants) { @@ -390,7 +392,7 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit companion object { @JvmField - val GUI = DynamicBufferSource(maximalInitialBufferSize = 2 shl 8, vertexSorting = VertexSorting.ORTHOGRAPHIC_Z) + val GUI = DynamicBufferSource(maximalInitialBufferSize = 2 shl 8) @JvmField val WORLD = DynamicBufferSource(minimalInitialBufferSize = 2 shl 12) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt index 891815dad..cf9383d38 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt @@ -12,7 +12,7 @@ import ru.dbotthepony.mc.otm.core.math.component1 import ru.dbotthepony.mc.otm.core.math.component2 import ru.dbotthepony.mc.otm.core.math.component3 -private val buffer = DynamicBufferSource(vertexSorting = VertexSorting.ORTHOGRAPHIC_Z) +private val buffer = DynamicBufferSource() private fun buffer() = buffer private fun Font.drawInBatch( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt index e72eb091d..dfa97516c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt @@ -1,17 +1,23 @@ package ru.dbotthepony.mc.otm.client.render import com.mojang.blaze3d.systems.RenderSystem +import com.mojang.blaze3d.vertex.BufferUploader +import com.mojang.blaze3d.vertex.DefaultVertexFormat import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.Tesselator +import com.mojang.blaze3d.vertex.VertexFormat import net.minecraft.client.gui.Font - +import net.minecraft.client.gui.GuiComponent +import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent +import net.minecraft.client.gui.screens.inventory.tooltip.TooltipRenderUtil +import net.minecraft.client.renderer.GameRenderer import net.minecraft.client.renderer.MultiBufferSource -import net.minecraft.client.renderer.RenderBuffers import net.minecraft.client.renderer.texture.TextureAtlasSprite import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation import net.minecraft.util.FormattedCharSequence import net.minecraft.world.item.ItemStack +import net.minecraftforge.client.ForgeHooksClient import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.math.RGBAColor import kotlin.math.PI @@ -29,7 +35,7 @@ class MGUIGraphics(val pose: PoseStack) { } fun renderFakeItem(itemStack: ItemStack, x: Int, y: Int) { - parent.renderFakeItem(itemStack, x, y) + minecraft.itemRenderer.renderGuiItem(pose, itemStack, x, y) } fun drawLine( @@ -81,10 +87,59 @@ class MGUIGraphics(val pose: PoseStack) { } fun renderComponentTooltip(font: Font, lines: MutableList, x: Int, y: Int, itemStack: ItemStack = ItemStack.EMPTY) { - parent.renderComponentTooltip(font, lines, x, y, itemStack) + if (lines.isNotEmpty()) { + val mapped = lines.map { ClientTooltipComponent.create(it.visualOrderText) } + val preEvent = ForgeHooksClient.onRenderTooltipPre(itemStack, pose, x, y, width, height, mapped, font, font) + + if (preEvent.isCanceled) return + var i = 0 + var j = if (lines.size == 1) -2 else 0 + + for (line in mapped) { + val k = line.getWidth(preEvent.font) + if (k > i) i = k + j += line.height + } + + pose.pushPose() + val tesselator = Tesselator.getInstance() + val bufferbuilder = tesselator.builder + RenderSystem.setShader { GameRenderer.getPositionColorShader() } + bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR) + val matrix4f = pose.last().pose() + val colorEvent = ForgeHooksClient.onRenderTooltipColor(itemStack, pose, x, y, preEvent.font, mapped) + + TooltipRenderUtil.renderTooltipBackground(GuiComponent::fillGradient, matrix4f, bufferbuilder, x, y, i, j, 400, colorEvent.backgroundStart, colorEvent.backgroundEnd, colorEvent.borderStart, colorEvent.borderEnd) + RenderSystem.enableDepthTest() + RenderSystem.enableBlend() + RenderSystem.defaultBlendFunc() + BufferUploader.drawWithShader(bufferbuilder.end()) + + pose.translate(0.0f, 0.0f, 400.0f) + var yCurrent = y + + for (i in mapped.indices) { + val line = mapped[i] + line.renderText(preEvent.font, x, yCurrent, matrix4f, bufferSource) + yCurrent += line.height + if (i == 0) 2 else 0 + } + + bufferSource.endBatch() + + yCurrent = y + + for (i in mapped.indices) { + val line = mapped[i] + line.renderImage(preEvent.font, x, yCurrent, pose, minecraft.itemRenderer) + yCurrent += line.height + if (i == 0) 2 else 0 + } + + pose.popPose() + } } fun flush() { + bufferSource.endBatch() } fun draw( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt index 1ce1d3d89..390f880b2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.client.screen.panels.slot import com.mojang.blaze3d.systems.RenderSystem -import net.minecraft.client.gui.screens.Screen.getTooltipFromItem import net.minecraft.client.renderer.GameRenderer import net.minecraft.network.chat.Component import net.minecraft.world.item.ItemStack @@ -43,7 +42,7 @@ abstract class AbstractSlotPanel> @JvmOverloads constru } protected open fun getItemStackTooltip(stack: ItemStack): MutableList { - return getTooltipFromItem(ru.dbotthepony.mc.otm.client.minecraft, stack) + return screen.getTooltipFromItem(stack) } override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { 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 41da7dc50..3abd71787 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 @@ -70,11 +70,14 @@ open class SlotPanel, out T : Slot> @JvmOverloads const itemstack = carried.copy() dragHit = true - val k = Math.min(AbstractContainerMenu.getQuickCraftPlaceCount( + AbstractContainerMenu.getQuickCraftSlotCount( screen.quickCraftSlots, screen.quickCraftingType, - itemstack - ) + slot.item.count, slot.getMaxStackSize(itemstack)) + itemstack, + slot.item.count + ) + + val k = Math.min(slot.item.count, slot.getMaxStackSize(itemstack)) if (itemstack.count > k) { countOverride = ChatFormatting.YELLOW.toString() + k diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt index 60b1fca84..0966efef3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt @@ -57,7 +57,7 @@ private fun Player.getCuriosSlotsImpl(): List> { val stacks = curio.stacks for (slot in 0 until stacks.slots) { - val regular = CurioSlot(this, stacks, slot, identifier, 0, 0, curio.renders, curio.canToggleRendering()) + val regular = CurioSlot(this, stacks, slot, identifier, 0, 0, curio.renders) if (curio.hasCosmetic()) { val cosmetic = CosmeticCurioSlot(this, curio.cosmeticStacks, slot, identifier, 0, 0) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt index a3ce8ca09..ca75aeba9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt @@ -75,8 +75,8 @@ object MatterEntanglerRecipeCategory : IRecipeCategory, ProgressGaugePanel.GAUGE_BACKGROUND.render(wrap, xOffset + 89f, yOffset + 18f + 4f) } - override fun draw(recipe: IMatterEntanglerRecipe, recipeSlotsView: IRecipeSlotsView, guiGraphics: GuiGraphics, mouseX: Double, mouseY: Double) { - val wrap = MGUIGraphics(guiGraphics) + override fun draw(recipe: IMatterEntanglerRecipe, recipeSlotsView: IRecipeSlotsView, poseStack: PoseStack, mouseX: Double, mouseY: Double) { + val wrap = MGUIGraphics(poseStack) renderMatterGauge(wrap, 13f, 6f, drainSpeed = (recipe.matter / Decimal(300)).toFloat()) renderEnergyGauge(wrap, 4f, 6f, drainSpeed = (recipe.ticks / 2000.0).toFloat()) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt index 7ac0538f4..4e94fa4b5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt @@ -68,11 +68,11 @@ object MicrowaveRecipeCategory : IRecipeCategory, IDrawable { override fun draw( recipe: MicrowaveRecipe, recipeSlotsView: IRecipeSlotsView, - graphics: GuiGraphics, + poseStack: PoseStack, mouseX: Double, mouseY: Double ) { - val wrap = MGUIGraphics(graphics) + val wrap = MGUIGraphics(poseStack) wrap.draw(TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), 40f, 30f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK) val average = recipe.experience.toString() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt index 3df88999a..9ecf82023 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt @@ -18,7 +18,7 @@ import net.minecraft.world.level.block.LevelEvent import net.minecraft.world.level.block.entity.BarrelBlockEntity import net.minecraft.world.level.block.entity.ChestBlockEntity import net.minecraft.world.level.gameevent.GameEvent -import net.minecraft.world.level.storage.loot.LootParams +import net.minecraft.world.level.storage.loot.LootContext import net.minecraft.world.level.storage.loot.parameters.LootContextParams import net.minecraftforge.event.entity.player.PlayerInteractEvent import ru.dbotthepony.mc.otm.OverdriveThatMatters.MOD_ID @@ -70,7 +70,7 @@ class ChestUpgraderItem : Item(Properties().stacksTo(1)) { val level = context.level as ServerLevel - val lootparams = LootParams.Builder(level) + val lootparams = LootContext.Builder(level) .withParameter(LootContextParams.ORIGIN, Vector.atCenterOf(context.clickedPos)) .withParameter(LootContextParams.TOOL, stack) .withOptionalParameter(LootContextParams.BLOCK_ENTITY, hitBlockEntity) @@ -155,7 +155,7 @@ class ChestUpgraderItem : Item(Properties().stacksTo(1)) { } cart.clearContent() - (cart as AbstractMinecart).destroy(cart.damageSources().genericKill()) + (cart as AbstractMinecart).destroy(cart.damageSources().generic()) level.addFreshEntity(newCart) level.gameEvent(GameEvent.ENTITY_PLACE, event.pos, GameEvent.Context.of(event.entity, level.getBlockState(event.pos.below()))) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt index f73d1e979..9c1cc83f7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt @@ -24,6 +24,7 @@ import net.minecraft.world.item.enchantment.Enchantments import net.minecraft.world.level.Level import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.level.material.Material import net.minecraftforge.common.ForgeConfigSpec import net.minecraftforge.common.ToolAction import net.minecraftforge.common.ToolActions @@ -84,11 +85,17 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani val energy = itemStack.getCapability(MatteryCapability.ENERGY).orNull() ?: return 1f if (blockState.`is`(Blocks.COBWEB)) { - return if (energy.batteryLevel < COBWEB_POWER_COST) 2f else 25f - } else if (blockState.`is`(BlockTags.SWORD_EFFICIENT)) { - return if (energy.batteryLevel < PLANT_POWER_COST) 1.5f else 8f - } else { - return 1f + if (energy.batteryLevel < COBWEB_POWER_COST) { + return 2f + } else { + return 25f + } + } + + return when (blockState.material) { + Material.PLANT, Material.REPLACEABLE_PLANT, Material.VEGETABLE -> if (energy.batteryLevel < PLANT_POWER_COST) 1.5f else 4f + Material.LEAVES -> if (energy.batteryLevel < PLANT_POWER_COST) 1.5f else 8f + else -> 1f } } @@ -161,9 +168,10 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani if (blockState.getDestroySpeed(p_41417_, p_41419_) != 0f && (user !is Player || !user.isCreative)) { val energy = itemStack.matteryEnergy - if (blockState.`is`(BlockTags.SWORD_EFFICIENT)) { - if (energy?.extractEnergyExact(PLANT_POWER_COST, false) == true) - energy.extractEnergyExact(user.level.random.nextVariance(PLANT_POWER_COST_VARIANCE), false) + when (blockState.material) { + Material.PLANT, Material.REPLACEABLE_PLANT, Material.VEGETABLE, Material.LEAVES -> + if (energy?.extractEnergyExact(PLANT_POWER_COST, false) == true) + energy.extractEnergyExact(user.level.random.nextVariance(PLANT_POWER_COST_VARIANCE), false) } if (blockState.`is`(Blocks.COBWEB)) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index b8467b1db..b9a735e3e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -1592,7 +1592,7 @@ object MatterManager { val targetFile = File(MINECRAFT_SERVER.serverDirectory, "otm/registry_dumps/${filter.name.lowercase()}_${System.currentTimeMillis() / 1_000L}.csv") File(MINECRAFT_SERVER.serverDirectory, "otm/registry_dumps").mkdirs() - stack.source.sendSuccess({ TranslatableComponent("otm.dumping_matter_registry", targetFile.absolutePath) }, false) + stack.source.sendSuccess(TranslatableComponent("otm.dumping_matter_registry", targetFile.absolutePath), false) val writer = targetFile.bufferedWriter(Charsets.UTF_8) @@ -1638,7 +1638,7 @@ object MatterManager { writer.close() - stack.source.sendSuccess({ TranslatableComponent("otm.dumped_matter_registry", targetFile.absolutePath) }, true) + stack.source.sendSuccess(TranslatableComponent("otm.dumped_matter_registry", targetFile.absolutePath), true) return 0 } 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 bb75430c5..4fe772498 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -27,7 +27,8 @@ import net.minecraft.world.level.block.state.BlockBehaviour import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.properties.BlockSetType import net.minecraft.world.level.block.state.properties.NoteBlockInstrument -import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.MaterialColor import net.minecraft.world.level.material.PushReaction import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.registries.DeferredRegister @@ -143,22 +144,21 @@ object MBlocks { val FLUID_TANK: FluidTankBlock by registry.register(MNames.FLUID_TANK) { FluidTankBlock() } val DEV_CHEST: DevChestBlock by registry.register(MNames.DEV_CHEST) { DevChestBlock() } - val LIQUID_XP: LiquidBlock by registry.register("liquid_xp") { LiquidBlock(MFluids::LIQUID_XP, BlockBehaviour.Properties.of().mapColor(MapColor.EMERALD).replaceable().noCollission().strength(100.0f).pushReaction(PushReaction.DESTROY).noLootTable().liquid().sound(SoundType.EMPTY)) } + val LIQUID_XP: LiquidBlock by registry.register("liquid_xp") { LiquidBlock(MFluids::LIQUID_XP, BlockBehaviour.Properties.of(Material.WATER, MaterialColor.EMERALD).noCollission().strength(100.0f).noLootTable().sound(SoundType.POWDER_SNOW)) } val TRITANIUM_ORE: Block by registry.register(MNames.TRITANIUM_ORE) { DropExperienceBlock( - BlockBehaviour.Properties.of() - .mapColor(MapColor.STONE) + BlockBehaviour.Properties.of(Material.STONE) .strength(3.25f, 6.0f) .requiresCorrectToolForDrops(), UniformInt.of(0, 3) ) } val TRITANIUM_INGOT_BLOCK: Block by registry.register(MNames.TRITANIUM_INGOT_BLOCK) { - Block(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BLUE).sound(SoundType.METAL).explosionResistance(400f).destroyTime(3f).requiresCorrectToolForDrops()) + Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.BLUE).sound(SoundType.METAL).explosionResistance(400f).destroyTime(3f).requiresCorrectToolForDrops()) } val METAL_JUNK: Block by registry.register(MNames.METAL_JUNK) { - object : Block(BlockBehaviour.Properties.of().sound(SoundType.NETHERITE_BLOCK).mapColor(MapColor.COLOR_GRAY).explosionResistance(45f).destroyTime(3f).requiresCorrectToolForDrops()) { + object : Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.GRAY).sound(SoundType.NETHERITE_BLOCK).explosionResistance(45f).destroyTime(3f).requiresCorrectToolForDrops()) { override fun appendHoverText( p_49816_: ItemStack, p_49817_: BlockGetter?, @@ -172,20 +172,18 @@ object MBlocks { } val METAL_MESH: Block by registry.register(MNames.METAL_MESH) { - Block(BlockBehaviour.Properties.of() - .mapColor(MapColor.COLOR_GRAY) + Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.GRAY) .noOcclusion() .sound(SoundType.COPPER).explosionResistance(30f) .destroyTime(2f).requiresCorrectToolForDrops()) } val TRITANIUM_BARS: IronBarsBlock by registry.register(MNames.TRITANIUM_BARS) { - IronBarsBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_LIGHT_BLUE).sound(SoundType.METAL).explosionResistance(45f).destroyTime(2.5f).requiresCorrectToolForDrops()) + IronBarsBlock(BlockBehaviour.Properties.of(Material.METAL, DyeColor.LIGHT_BLUE).sound(SoundType.METAL).explosionResistance(45f).destroyTime(2.5f).requiresCorrectToolForDrops()) } val DEEPSLATE_TRITANIUM_ORE: Block by registry.register(MNames.DEEPSLATE_TRITANIUM_ORE) { DropExperienceBlock( - BlockBehaviour.Properties.of() - .mapColor(MapColor.DEEPSLATE) + BlockBehaviour.Properties.of(Material.STONE, MaterialColor.DEEPSLATE) .sound(SoundType.DEEPSLATE) .strength(4.75f, 6.5f) .requiresCorrectToolForDrops().sound(SoundType.DEEPSLATE), @@ -193,14 +191,14 @@ object MBlocks { ) } val TRITANIUM_RAW_BLOCK: Block by registry.register(MNames.TRITANIUM_RAW_BLOCK) { Block( - BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_LIGHT_BLUE).instrument(NoteBlockInstrument.BASEDRUM).strength(8.0f, 10f).requiresCorrectToolForDrops() + BlockBehaviour.Properties.of(Material.STONE, DyeColor.LIGHT_BLUE).strength(8.0f, 10f).requiresCorrectToolForDrops() ) } val LABORATORY_LAMP: Block by registry.register(MNames.LABORATORY_LAMP) { LaboratoryLamp(false) } val LABORATORY_LAMP_INVERTED: Block by registry.register(MNames.LABORATORY_LAMP_INVERTED) { LaboratoryLamp(true) } val LABORATORY_LAMP_LIGHT: Block by registry.register(MNames.LABORATORY_LAMP_LIGHT) { LaboratoryLampLight() } - val DANGER_STRIPE_BLOCK: Block by registry.register(MNames.DANGER_STRIPE_BLOCK) { Block(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_GRAY).explosionResistance(6f).destroyTime(1.5f).requiresCorrectToolForDrops()) } - val METAL_BEAM: Block by registry.register(MNames.METAL_BEAM) { Block(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_GRAY).sound(SoundType.METAL).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) } + val DANGER_STRIPE_BLOCK: Block by registry.register(MNames.DANGER_STRIPE_BLOCK) { Block(BlockBehaviour.Properties.of(Material.STONE, DyeColor.GRAY).explosionResistance(6f).destroyTime(1.5f).requiresCorrectToolForDrops()) } + val METAL_BEAM: Block by registry.register(MNames.METAL_BEAM) { Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.GRAY).sound(SoundType.METAL).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) } val ENGINE: Block by registry.register(MNames.ENGINE) { EngineBlock() } val HOLO_SIGN: Block by registry.register(MNames.HOLO_SIGN) { HoloSignBlock() } @@ -212,12 +210,10 @@ object MBlocks { val anvils = ArrayList<() -> Block>() for (i in 0 until TRITANIUM_ANVIL_VARIANTS) { - val props = BlockBehaviour.Properties.of() - .mapColor(MapColor.COLOR_LIGHT_BLUE) + val props = BlockBehaviour.Properties.of(Material.HEAVY_METAL, DyeColor.LIGHT_BLUE) .sound(SoundType.ANVIL) .destroyTime(2.5f - i * 0.15f) .explosionResistance(1200f - i * 80f) - .pushReaction(PushReaction.BLOCK) .requiresCorrectToolForDrops() anvils.add(registry.register(MNames.TRITANIUM_ANVIL + i) { AnvilBlock(props) }::get) @@ -228,12 +224,10 @@ object MBlocks { val TRITANIUM_DOOR = registry.allColored(MNames.TRITANIUM_DOOR) { color, _ -> object : DoorBlock( - Properties.of() - .mapColor(color ?: DyeColor.LIGHT_BLUE) + Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE) .explosionResistance(80f) .noOcclusion() .destroyTime(3f) - .pushReaction(PushReaction.DESTROY) .requiresCorrectToolForDrops(), BlockSetType.IRON ) { @@ -265,8 +259,7 @@ object MBlocks { val TRITANIUM_TRAPDOOR = registry.allColored(MNames.TRITANIUM_TRAPDOOR) { color, _ -> object : TrapDoorBlock( - Properties.of() - .mapColor(color ?: DyeColor.LIGHT_BLUE) + Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE) .explosionResistance(80f) .noOcclusion().destroyTime(3f) .requiresCorrectToolForDrops() @@ -309,8 +302,7 @@ object MBlocks { } val TRITANIUM_STRIPED_BLOCK: Block by registry.register(MNames.TRITANIUM_STRIPED_BLOCK) { Block( - BlockBehaviour.Properties.of() - .mapColor(MapColor.COLOR_LIGHT_BLUE) + BlockBehaviour.Properties.of(Material.METAL, DyeColor.LIGHT_BLUE) .sound(SoundType.BASALT) .requiresCorrectToolForDrops() .explosionResistance(80f) @@ -331,8 +323,7 @@ object MBlocks { } val CARBON_FIBRE_BLOCK: Block by registry.register(MNames.CARBON_FIBRE_BLOCK) { Block( - BlockBehaviour.Properties.of() - .mapColor(MapColor.COLOR_GRAY) + BlockBehaviour.Properties.of(Material.METAL, DyeColor.BLACK) .sound(SoundType.BASALT) .requiresCorrectToolForDrops() .explosionResistance(40f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt index 258ca4ed1..118ae68ca 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt @@ -1,27 +1,24 @@ package ru.dbotthepony.mc.otm.registry -import net.minecraft.core.registries.Registries import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.CreativeModeTab -import net.minecraft.world.item.CreativeModeTabs import net.minecraft.world.item.DyeColor import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.level.material.Fluids import net.minecraftforge.common.capabilities.ForgeCapabilities -import net.minecraftforge.event.BuildCreativeModeTabContentsEvent -import net.minecraftforge.eventbus.api.IEventBus +import net.minecraftforge.event.CreativeModeTabEvent import net.minecraftforge.fluids.FluidStack import net.minecraftforge.fluids.capability.IFluidHandler -import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.capability.matter.matter import ru.dbotthepony.mc.otm.capability.matteryEnergy -import ru.dbotthepony.mc.otm.core.util.CreativeMenuItemComparator import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.core.util.CreativeMenuItemComparator +import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.registry.MItems.BATTERY_CREATIVE private fun CreativeModeTab.Output.accept(values: Collection) { @@ -271,34 +268,30 @@ private fun addDecorativeTabItems(consumer: CreativeModeTab.Output) { } object MCreativeTabs { - private val registry = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, OverdriveThatMatters.MOD_ID) + var MAIN by WriteOnce() + private set + var DECORATIVE by WriteOnce() + private set - val MAIN: CreativeModeTab by registry.register("main") { - CreativeModeTab.builder() - .title(TranslatableComponent("itemGroup.otm")) - .icon { ItemStack(BATTERY_CREATIVE, 1) } - .withTabsBefore(CreativeModeTabs.SPAWN_EGGS) - .build() - } - - val DECORATIVE: CreativeModeTab by registry.register("decorative") { - CreativeModeTab.builder() - .title(TranslatableComponent("itemGroup.otm_decorative")) - .icon { ItemStack(MRegistry.VENT.item, 1) } - .withTabsBefore(ResourceLocation(OverdriveThatMatters.MOD_ID, "main")) - .build() - } - - internal fun initialize(bus: IEventBus) { - registry.register(bus) - } - - fun register(event: BuildCreativeModeTabContentsEvent) { + fun register(event: CreativeModeTabEvent.Register) { CreativeMenuItemComparator.invalidate() - when (event.tab) { - MAIN -> addMainCreativeTabItems(event) - DECORATIVE -> addDecorativeTabItems(event) + MAIN = event.registerCreativeModeTab(ResourceLocation(OverdriveThatMatters.MOD_ID, "main")) { + it.icon { ItemStack(BATTERY_CREATIVE, 1) } + it.title(TranslatableComponent("itemGroup.otm")) + + it.displayItems { _, consumer -> + addMainCreativeTabItems(consumer) + } + } + + DECORATIVE = event.registerCreativeModeTab(ResourceLocation(OverdriveThatMatters.MOD_ID, "decorative")) { + it.icon { ItemStack(MRegistry.VENT.item, 1) } + it.title(TranslatableComponent("itemGroup.otm_decorative")) + + it.displayItems { _, consumer -> + addDecorativeTabItems(consumer) + } } } } 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 715970109..90b228bb3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -2,7 +2,9 @@ package ru.dbotthepony.mc.otm.registry import com.google.common.collect.ImmutableSet import com.google.common.collect.Streams +import com.mojang.blaze3d.vertex.PoseStack 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.cauldron.CauldronInteraction @@ -11,15 +13,19 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.EntityType import net.minecraft.world.entity.ai.village.poi.PoiType import net.minecraft.world.entity.ai.village.poi.PoiTypes +import net.minecraft.world.item.DyeColor import net.minecraft.world.item.DyeableArmorItem +import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.block.* import net.minecraft.world.level.block.state.BlockBehaviour import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.properties.NoteBlockInstrument -import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.MaterialColor import net.minecraftforge.api.distmarker.Dist +import net.minecraftforge.client.IItemDecorator import net.minecraftforge.client.event.RegisterColorHandlersEvent import net.minecraftforge.client.event.RegisterItemDecorationsEvent import net.minecraftforge.client.model.DynamicFluidContainerModel @@ -88,8 +94,7 @@ object MRegistry { val CARGO_CRATES = DecorativeBlock(MNames.CARGO_CRATE, ::CargoCrateBlock) val DECORATIVE_CRATE = DecorativeBlock.simple(MNames.DECORATIVE_CRATE) { - BlockBehaviour.Properties.of() - .mapColor(it?.mapColor ?: MapColor.SNOW) + BlockBehaviour.Properties.of(Material.METAL, MaterialColor.SNOW) .sound(SoundType.METAL) .requiresCorrectToolForDrops() .explosionResistance(10f) @@ -97,8 +102,7 @@ object MRegistry { } val TRITANIUM_BLOCK = DecorativeBlock.simple(MNames.TRITANIUM_BLOCK) { - BlockBehaviour.Properties.of() - .mapColor(it?.mapColor ?: MapColor.COLOR_LIGHT_BLUE) + BlockBehaviour.Properties.of(Material.METAL, DyeColor.LIGHT_BLUE) .sound(SoundType.BASALT) .requiresCorrectToolForDrops() .explosionResistance(80f) @@ -123,8 +127,7 @@ object MRegistry { val TRITANIUM_PRESSURE_PLATE = DecorativeBlock(MNames.TRITANIUM_PRESSURE_PLATE, ::TritaniumPressurePlate) val VENT = DecorativeBlock.simple(MNames.VENT) { - BlockBehaviour.Properties.of() - .mapColor(it?.mapColor ?: MapColor.COLOR_LIGHT_BLUE) + BlockBehaviour.Properties.of(Material.METAL, DyeColor.LIGHT_BLUE) .sound(SoundType.BASALT) .requiresCorrectToolForDrops() .explosionResistance(20f) @@ -132,8 +135,7 @@ object MRegistry { } val VENT_ALTERNATIVE = DecorativeBlock.simple(MNames.VENT_ALTERNATIVE) { - BlockBehaviour.Properties.of() - .mapColor(it?.mapColor ?: MapColor.COLOR_LIGHT_BLUE) + BlockBehaviour.Properties.of(Material.METAL, DyeColor.LIGHT_BLUE) .sound(SoundType.BASALT) .requiresCorrectToolForDrops() .explosionResistance(20f) @@ -141,8 +143,7 @@ object MRegistry { } val FLOOR_TILES = ColoredDecorativeBlock.simple(MNames.FLOOR_TILES) { - BlockBehaviour.Properties.of() - .mapColor(it.mapColor) + BlockBehaviour.Properties.of(Material.STONE, it) .sound(SoundType.STONE) .requiresCorrectToolForDrops() .strength(1.5f, 6f) @@ -160,17 +161,14 @@ object MRegistry { } val UNREFINED_FLOOR_TILES = ColoredDecorativeBlock.simple(MNames.UNREFINED_FLOOR_TILES) { - BlockBehaviour.Properties.of() - .mapColor(it.mapColor) + BlockBehaviour.Properties.of(Material.CLAY, it) .sound(SoundType.GRAVEL) .strength(1f, 2f) } val INDUSTRIAL_GLASS = DecorativeBlock(MNames.INDUSTRIAL_GLASS) { color -> val properties = - BlockBehaviour.Properties.of() - .mapColor(if (color != null) color.mapColor else MapColor.NONE) - .instrument(NoteBlockInstrument.HAT) + BlockBehaviour.Properties.of(Material.GLASS, color?.materialColor ?: MaterialColor.NONE) .destroyTime(1.5f) .explosionResistance(40f) .requiresCorrectToolForDrops() @@ -190,9 +188,7 @@ object MRegistry { val INDUSTRIAL_GLASS_PANE = DecorativeBlock(MNames.INDUSTRIAL_GLASS_PANE) { color -> val properties = - BlockBehaviour.Properties.of() - .mapColor(if (color != null) color.mapColor else MapColor.NONE) - .instrument(NoteBlockInstrument.HAT) + BlockBehaviour.Properties.of(Material.GLASS, color?.materialColor ?: MaterialColor.NONE) .strength(1.25f, 5.0f) .requiresCorrectToolForDrops() .sound(SoundType.GLASS) @@ -206,8 +202,7 @@ object MRegistry { } val TRITANIUM_STRIPED_BLOCK = StripedColoredDecorativeBlock(MNames.TRITANIUM_STRIPED_BLOCK, { colorA, _ -> - Block(BlockBehaviour.Properties.of() - .mapColor(colorA.mapColor) + Block(BlockBehaviour.Properties.of(Material.METAL, colorA) .sound(SoundType.BASALT) .requiresCorrectToolForDrops() .explosionResistance(80f) @@ -263,7 +258,7 @@ object MRegistry { bus.addListener(this::registerItemColorHandlers) bus.addListener(this::registerItemDecorators) - MCreativeTabs.initialize(bus) + bus.addListener(MCreativeTabs::register) DecimalProvider.register(bus) AndroidResearchDescription.register(bus) @@ -371,7 +366,16 @@ object MRegistry { } private fun registerItemDecorators(event: RegisterItemDecorationsEvent) { - event.register(Items.SHIELD, MatteryGUI::renderShieldCooldownOverlay) - event.register(MItems.TRITANIUM_SHIELD, MatteryGUI::renderShieldCooldownOverlay) + event.register(Items.SHIELD, object : IItemDecorator { + override fun render(poseStack: PoseStack, font: Font, stack: ItemStack, xOffset: Int, yOffset: Int): Boolean { + return MatteryGUI.renderShieldCooldownOverlay(poseStack, font, stack, xOffset, yOffset) + } + }) + + event.register(MItems.TRITANIUM_SHIELD, object : IItemDecorator { + override fun render(poseStack: PoseStack, font: Font, stack: ItemStack, xOffset: Int, yOffset: Int): Boolean { + return MatteryGUI.renderShieldCooldownOverlay(poseStack, font, stack, xOffset, yOffset) + } + }) } } diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 86504a276..d00eefc3f 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -12,25 +12,30 @@ public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_1696 public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97732_ # menu public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_169604_ # playerInventoryTitle -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97706_ # clickedSlot -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97707_ # snapbackEnd -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97708_ # quickdropSlot -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97709_ # lastClickSlot -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97710_ # isSplittingStack -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97711_ # draggingItem -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97712_ # snapbackStartX -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97713_ # snapbackStartY -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97714_ # snapbackTime -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97715_ # snapbackItem -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97716_ # quickdropTime -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97717_ # quickCraftingType -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97718_ # quickCraftingButton -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97719_ # skipNextRelease -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97720_ # quickCraftingRemainder -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97721_ # lastClickTime -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97722_ # lastClickButton -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97723_ # doubleclick -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97724_ # lastQuickMoved +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97706_ # clickedSlot +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97707_ # snapbackEnd +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97708_ # quickdropSlot +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97709_ # lastClickSlot +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97710_ # isSplittingStack +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97711_ # draggingItem +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97712_ # snapbackStartX +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97713_ # snapbackStartY +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97714_ # snapbackTime +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97715_ # snapbackItem +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97716_ # quickdropTime +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97717_ # quickCraftingType +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97718_ # quickCraftingButton +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97719_ # skipNextRelease +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97720_ # quickCraftingRemainder +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97721_ # lastClickTime +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97722_ # lastClickButton +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97723_ # doubleclick +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97724_ # lastQuickMoved +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_274323_(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/world/item/ItemStack;IILjava/lang/String;)V # renderFloatingItem + +public net.minecraft.client.gui.GuiComponent m_168740_(Lcom/mojang/blaze3d/vertex/PoseStack;IIIIIII)V # fillGradient +public net.minecraft.client.gui.GuiComponent m_93123_(Lorg/joml/Matrix4f;Lcom/mojang/blaze3d/vertex/BufferBuilder;IIIIIII)V # fillGradient +public net.minecraft.client.gui.GuiComponent m_93179_(Lcom/mojang/blaze3d/vertex/PoseStack;IIIIII)V # fillGradient public net.minecraft.world.item.BlockItem f_150696_ # BLOCK_ENTITY_TAG From afe7d698c87ec8593028262976fbc5ce088234b4 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 11:39:30 +0700 Subject: [PATCH 1175/1199] More backporting --- .../entity/storage/ItemMonitorBlockEntity.kt | 5 +- .../otm/container/MatteryCraftingContainer.kt | 117 ++++++++++++++++-- .../otm/container/ShadowCraftingContainer.kt | 41 +++++- .../mc/otm/matter/MatterManager.kt | 4 +- .../mc/otm/menu/ExopackInventoryMenu.kt | 4 +- 5 files changed, 148 insertions(+), 23 deletions(-) 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 96f016300..02b993dd4 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 @@ -11,7 +11,6 @@ import net.minecraft.world.Container import net.minecraft.world.entity.player.Inventory import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu -import net.minecraft.world.inventory.TransientCraftingContainer import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.CraftingRecipe import net.minecraft.world.item.crafting.RecipeType @@ -28,11 +27,9 @@ import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.render.IGUIRenderable import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.config.MachinesConfig -import ru.dbotthepony.mc.otm.container.MatteryContainer import ru.dbotthepony.mc.otm.graph.storage.StorageNode import ru.dbotthepony.mc.otm.graph.storage.StorageGraph import ru.dbotthepony.mc.otm.registry.MBlockEntities -import ru.dbotthepony.mc.otm.container.set import ru.dbotthepony.mc.otm.core.nbt.mapString import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.menu.storage.ItemMonitorMenu @@ -44,6 +41,8 @@ import kotlin.collections.HashMap import ru.dbotthepony.mc.otm.client.render.Widgets8 import ru.dbotthepony.mc.otm.container.CombinedContainer import ru.dbotthepony.mc.otm.container.MatteryCraftingContainer +import ru.dbotthepony.mc.otm.container.get +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 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryCraftingContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryCraftingContainer.kt index b6904f670..3da9b65a8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryCraftingContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryCraftingContainer.kt @@ -1,22 +1,113 @@ package ru.dbotthepony.mc.otm.container +import net.minecraft.nbt.CompoundTag +import net.minecraft.nbt.Tag +import net.minecraft.world.Container +import net.minecraft.world.entity.player.Player +import net.minecraft.world.entity.player.StackedContents +import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.inventory.CraftingContainer +import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack +import net.minecraftforge.common.util.INBTSerializable +import java.util.function.Predicate -open class MatteryCraftingContainer(watcher: Runnable, private val width: Int, private val height: Int) : MatteryContainer(watcher, width * height), CraftingContainer { - constructor(width: Int, height: Int) : this({}, width, height) - final override fun getWidth(): Int { - return width +object DummyMenu : AbstractContainerMenu(null, 0) { + override fun quickMoveStack(pPlayer: Player, pIndex: Int): ItemStack { + return ItemStack.EMPTY } - final override fun getHeight(): Int { - return height - } - - final override fun getItems(): MutableList { - val i = spliterator() - val result = ArrayList(i.estimateSize().toInt()) - i.forEachRemaining { result.add(it) } - return result + override fun stillValid(pPlayer: Player): Boolean { + return false + } +} + +// урод +open class MatteryCraftingContainer private constructor(watcher: Runnable, width: Int, height: Int, private val parent: MatteryContainer) : CraftingContainer(DummyMenu, width, height), IMatteryContainer by parent, INBTSerializable { + constructor(width: Int, height: Int) : this({}, width, height) + constructor(watcher: Runnable, width: Int, height: Int) : this(watcher, width, height, MatteryContainer(watcher, width * height)) + + override fun serializeNBT(): CompoundTag { + return parent.serializeNBT() + } + + override fun deserializeNBT(nbt: CompoundTag?) { + parent.deserializeNBT(nbt) + } + + fun deserializeNBT(nbt: Tag?) { + parent.deserializeNBT(nbt as? CompoundTag) + } + + override fun clearContent() { + parent.clearContent() + } + + override fun getContainerSize(): Int { + return parent.getContainerSize() + } + + override fun isEmpty(): Boolean { + return parent.isEmpty() + } + + override fun getItem(p_39332_: Int): ItemStack { + return parent.getItem(p_39332_) + } + + override fun removeItem(p_39334_: Int, p_39335_: Int): ItemStack { + return parent.removeItem(p_39334_, p_39335_) + } + + override fun removeItemNoUpdate(p_39344_: Int): ItemStack { + return parent.removeItemNoUpdate(p_39344_) + } + + override fun setItem(p_39337_: Int, p_39338_: ItemStack) { + parent.setItem(p_39337_, p_39338_) + } + + override fun setChanged() { + parent.setChanged() + } + + override fun stillValid(p_39340_: Player): Boolean { + return parent.stillValid(p_39340_) + } + + override fun fillStackedContents(p_39342_: StackedContents) { + parent.fillStackedContents(p_39342_) + } + + override fun getMaxStackSize(): Int { + return parent.getMaxStackSize() + } + + override fun startOpen(p_18955_: Player) { + parent.startOpen(p_18955_) + } + + override fun stopOpen(p_18954_: Player) { + parent.stopOpen(p_18954_) + } + + override fun canPlaceItem(p_18952_: Int, p_18953_: ItemStack): Boolean { + return parent.canPlaceItem(p_18952_, p_18953_) + } + + override fun canTakeItem(p_273520_: Container, p_272681_: Int, p_273702_: ItemStack): Boolean { + return parent.canTakeItem(p_273520_, p_272681_, p_273702_) + } + + override fun countItem(p_18948_: Item): Int { + return parent.countItem(p_18948_) + } + + override fun hasAnyOf(p_18950_: MutableSet): Boolean { + return parent.hasAnyOf(p_18950_) + } + + override fun hasAnyMatching(p_216875_: Predicate): Boolean { + return parent.hasAnyMatching(p_216875_) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowCraftingContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowCraftingContainer.kt index 95123a710..cd8c011c6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowCraftingContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowCraftingContainer.kt @@ -1,12 +1,15 @@ package ru.dbotthepony.mc.otm.container +import net.minecraft.world.entity.player.Player import net.minecraft.world.entity.player.StackedContents import net.minecraft.world.inventory.CraftingContainer import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.container.util.iterator import ru.dbotthepony.mc.otm.core.collect.toList -class ShadowCraftingContainer(private val parent: CraftingContainer) : IContainer by ShadowContainer(parent), CraftingContainer { +class ShadowCraftingContainer private constructor(private val parent: CraftingContainer, private val shadow: ShadowContainer) : CraftingContainer(DummyMenu, parent.width, parent.height), IContainer by shadow { + constructor(parent: CraftingContainer) : this(parent, ShadowContainer(parent)) + override fun fillStackedContents(contents: StackedContents) { for (item in iterator()) { contents.accountStack(item) @@ -21,8 +24,40 @@ class ShadowCraftingContainer(private val parent: CraftingContainer) : IContaine return parent.height } - override fun getItems(): MutableList { - return iterator().toList() + override fun clearContent() { + shadow.clearContent() + } + + override fun getContainerSize(): Int { + return shadow.getContainerSize() + } + + override fun isEmpty(): Boolean { + return shadow.isEmpty() + } + + override fun getItem(p_39332_: Int): ItemStack { + return shadow.getItem(p_39332_) + } + + override fun removeItem(p_39334_: Int, p_39335_: Int): ItemStack { + return shadow.removeItem(p_39334_, p_39335_) + } + + override fun removeItemNoUpdate(p_39344_: Int): ItemStack { + return shadow.removeItemNoUpdate(p_39344_) + } + + override fun setItem(p_39337_: Int, p_39338_: ItemStack) { + shadow.setItem(p_39337_, p_39338_) + } + + override fun setChanged() { + shadow.setChanged() + } + + override fun stillValid(p_39340_: Player): Boolean { + return shadow.stillValid(p_39340_) } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index b9a735e3e..0ebac3639 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -39,7 +39,7 @@ import net.minecraft.util.profiling.ProfilerFiller import net.minecraft.world.Container import net.minecraft.world.entity.player.Player import net.minecraft.world.inventory.AbstractContainerMenu -import net.minecraft.world.inventory.TransientCraftingContainer +import net.minecraft.world.inventory.CraftingContainer import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Ingredient @@ -521,7 +521,7 @@ object MatterManager { height = it.value.ingredients.size.coerceAtLeast(height) } - val container = TransientCraftingContainer(object : AbstractContainerMenu(null, 0) { + val container = CraftingContainer(object : AbstractContainerMenu(null, 0) { override fun quickMoveStack(pPlayer: Player, pIndex: Int): ItemStack { return ItemStack.EMPTY } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt index 487affde0..49c95010e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExopackInventoryMenu.kt @@ -25,9 +25,9 @@ class ExopackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen init { if (capability.isExopackCraftingUpgraded) { - craftingGrid = TransientCraftingContainer(this, 3, 3) + craftingGrid = CraftingContainer(this, 3, 3) } else { - craftingGrid = TransientCraftingContainer(this, 2, 2) + craftingGrid = CraftingContainer(this, 2, 2) } val builder = ImmutableList.builder() From 3db63aa5890a416fa1fb831a6e775628f5b82840 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 11:45:06 +0700 Subject: [PATCH 1176/1199] Add MatteryContainer.ContainerListener --- .../mc/otm/container/MatteryContainer.kt | 15 ++++++++++++--- .../mc/otm/container/MatteryCraftingContainer.kt | 6 ++++-- .../mc/otm/container/UpgradeContainer.kt | 4 ++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt index 9061de489..688d803cd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryContainer.kt @@ -44,8 +44,17 @@ import java.util.stream.StreamSupport import kotlin.collections.ArrayList @Suppress("UNUSED") -open class MatteryContainer(protected val watcher: Runnable, private val size: Int) : IMatteryContainer, INBTSerializable, StackedContentsCompatible { - constructor(size: Int) : this({}, size) +open class MatteryContainer(var listener: ContainerListener, private val size: Int) : IMatteryContainer, INBTSerializable, StackedContentsCompatible { + constructor(watcher: () -> Unit, size: Int) : this({ _, _, _ -> watcher.invoke() }, size) + constructor(size: Int) : this(EmptyListener, size) + + fun interface ContainerListener { + fun setChanged(slot: Int, new: ItemStack, old: ItemStack) + } + + object EmptyListener : ContainerListener { + override fun setChanged(slot: Int, new: ItemStack, old: ItemStack) {} + } init { require(size >= 0) { "Invalid container size $size" } @@ -254,7 +263,7 @@ open class MatteryContainer(protected val watcher: Runnable, private val size: I } protected open fun setChanged(slot: Int, new: ItemStack, old: ItemStack) { - watcher.run() + listener.setChanged(slot, new, old) } override fun serializeNBT(): CompoundTag { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryCraftingContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryCraftingContainer.kt index b6904f670..65831e744 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryCraftingContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryCraftingContainer.kt @@ -3,8 +3,10 @@ package ru.dbotthepony.mc.otm.container import net.minecraft.world.inventory.CraftingContainer import net.minecraft.world.item.ItemStack -open class MatteryCraftingContainer(watcher: Runnable, private val width: Int, private val height: Int) : MatteryContainer(watcher, width * height), CraftingContainer { - constructor(width: Int, height: Int) : this({}, width, height) +open class MatteryCraftingContainer(listener: ContainerListener, private val width: Int, private val height: Int) : MatteryContainer(listener, width * height), CraftingContainer { + constructor(listener: () -> Unit, width: Int, height: Int) : this({ _, _, _ -> listener.invoke() }, width, height) + constructor(width: Int, height: Int) : this(EmptyListener, width, height) + final override fun getWidth(): Int { return width } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt index a8fa5095e..35abc5839 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/UpgradeContainer.kt @@ -10,8 +10,8 @@ import ru.dbotthepony.mc.otm.core.collect.reduce import ru.dbotthepony.mc.otm.core.math.Decimal import kotlin.math.pow -open class UpgradeContainer(slotCount: Int, open val allowedUpgrades: Set = UpgradeType.ALL, watcher: Runnable = Runnable {}) : MatteryContainer(watcher, slotCount), IMatteryUpgrade { - constructor(watcher: Runnable, slotCount: Int, allowedUpgrades: Set) : this(slotCount, allowedUpgrades, watcher) +open class UpgradeContainer(slotCount: Int, open val allowedUpgrades: Set = UpgradeType.ALL, listener: ContainerListener = EmptyListener) : MatteryContainer(listener, slotCount), IMatteryUpgrade { + constructor(listener: () -> Unit, slotCount: Int, allowedUpgrades: Set) : this(slotCount, allowedUpgrades, { _, _, _ -> listener.invoke() }) final override val upgradeTypes: Set get() = setOf() From b6643a6dd3be8cda88988fdcf45b541c771f3809 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 12:10:02 +0700 Subject: [PATCH 1177/1199] Make main source set compile against 1.19.4 --- .../mc/otm/mixin/GuiGraphicsMixin.java | 25 ------------------- .../entity/storage/ItemMonitorBlockEntity.kt | 2 +- .../otm/container/MatteryCraftingContainer.kt | 6 +---- .../overdrive_that_matters.mixins.json | 3 +-- 4 files changed, 3 insertions(+), 33 deletions(-) delete mode 100644 src/main/java/ru/dbotthepony/mc/otm/mixin/GuiGraphicsMixin.java diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/GuiGraphicsMixin.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/GuiGraphicsMixin.java deleted file mode 100644 index 523933da9..000000000 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/GuiGraphicsMixin.java +++ /dev/null @@ -1,25 +0,0 @@ -package ru.dbotthepony.mc.otm.mixin; - -import net.minecraft.client.Minecraft; -; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; - -import static ru.dbotthepony.mc.otm.client.render.RenderHelperKt.popScissorRect; -import static ru.dbotthepony.mc.otm.client.render.RenderHelperKt.pushScissorRect; - -// because scissor stack fucking sucks. -// mostly because it is not a stack at all. -@Mixin(GuiGraphics.class) -public abstract class GuiGraphicsMixin { - @Overwrite - public void enableScissor(int x0, int y0, int x1, int y1) { - double scale = Minecraft.getInstance().getWindow().getGuiScale(); - pushScissorRect((int) (scale * x0), (int) (scale * y0), (int) (scale * (x1 - x0)), (int) (scale * (y1 - y0))); - } - - @Overwrite - public void disableScissor() { - popScissorRect(); - } -} 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 02b993dd4..d42d9f0fe 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 @@ -430,7 +430,7 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte check(this.settings.put(UUID.fromString(key), ItemMonitorPlayerSettings().also { it.deserializeNBT(settings.getCompound(key)) }) == null) } - craftingGrid.deserializeNBT(nbt["crafting_grid"]) + craftingGrid.deserializeNBT(nbt["crafting_grid"] as? CompoundTag) } fun getSettings(ply: ServerPlayer): ItemMonitorPlayerSettings { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryCraftingContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryCraftingContainer.kt index 27f03529e..1639388a5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryCraftingContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryCraftingContainer.kt @@ -44,10 +44,6 @@ open class MatteryCraftingContainer private constructor(private val listener: Ma parent.deserializeNBT(nbt) } - fun deserializeNBT(nbt: Tag?) { - parent.deserializeNBT(nbt as? CompoundTag) - } - override fun clearContent() { parent.clearContent() } @@ -112,7 +108,7 @@ open class MatteryCraftingContainer private constructor(private val listener: Ma return parent.countItem(p_18948_) } - override fun hasAnyOf(p_18950_: MutableSet): Boolean { + override fun hasAnyOf(p_18950_: Set): Boolean { return parent.hasAnyOf(p_18950_) } diff --git a/src/main/resources/overdrive_that_matters.mixins.json b/src/main/resources/overdrive_that_matters.mixins.json index aa7271058..b812f9335 100644 --- a/src/main/resources/overdrive_that_matters.mixins.json +++ b/src/main/resources/overdrive_that_matters.mixins.json @@ -17,8 +17,7 @@ "InventoryChangeTriggerMixin", "MixinPlayer", "HopperBlockEntityMixin", - "DispenserBlockEntityMixin", - "GuiGraphicsMixin" + "DispenserBlockEntityMixin" ], "client": [ "MixinGameRenderer", From f3bf84a7a251ade652843538cbbba252095623d5 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 12:19:07 +0700 Subject: [PATCH 1178/1199] Make mod compile against 1.19.4 --- .../ru/dbotthepony/mc/otm/datagen/advancements/Helpers.kt | 4 +--- .../mc/otm/datagen/recipes/MatteryRecipeProvider.kt | 5 ++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/Helpers.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/Helpers.kt index 0e999e52a..bfb78c050 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/Helpers.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/advancements/Helpers.kt @@ -1,11 +1,9 @@ package ru.dbotthepony.mc.otm.datagen.advancements import net.minecraft.advancements.Advancement -import net.minecraft.advancements.Criterion import net.minecraft.advancements.CriterionTriggerInstance import net.minecraft.advancements.DisplayInfo import net.minecraft.advancements.FrameType -import net.minecraft.advancements.critereon.ContextAwarePredicate import net.minecraft.advancements.critereon.EntityPredicate import net.minecraft.advancements.critereon.InventoryChangeTrigger import net.minecraft.advancements.critereon.ItemPredicate @@ -71,6 +69,6 @@ fun criterion(item: ItemLike): CriterionTriggerInstance { return InventoryChangeTrigger.TriggerInstance.hasItems(predicate(item)) } -fun EntityPredicate.wrap(): ContextAwarePredicate = EntityPredicate.wrap(this) +fun EntityPredicate.wrap(): EntityPredicate.Composite = EntityPredicate.Composite.wrap(this) fun Advancement.Builder.save(advancement: Consumer, name: ResourceLocation) = save(advancement, name.toString()) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt index bb937d3ed..510ce2bd2 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/MatteryRecipeProvider.kt @@ -1,8 +1,7 @@ package ru.dbotthepony.mc.otm.datagen.recipes -import net.minecraft.advancements.Criterion import net.minecraft.advancements.CriterionTriggerInstance -import net.minecraft.advancements.critereon.ContextAwarePredicate +import net.minecraft.advancements.critereon.EntityPredicate import net.minecraft.advancements.critereon.InventoryChangeTrigger import net.minecraft.advancements.critereon.ItemPredicate import net.minecraft.advancements.critereon.MinMaxBounds @@ -41,7 +40,7 @@ fun has(p_125976_: TagKey): CriterionTriggerInstance { fun inventoryTrigger(vararg p_126012_: ItemPredicate): CriterionTriggerInstance { return InventoryChangeTrigger.TriggerInstance( - ContextAwarePredicate.ANY, + EntityPredicate.Composite.ANY, MinMaxBounds.Ints.ANY, MinMaxBounds.Ints.ANY, MinMaxBounds.Ints.ANY, From 8e469c309d72450ab60d6ecad51afa0866808297 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 14:23:28 +0700 Subject: [PATCH 1179/1199] Make datagen run? --- src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt | 2 -- src/main/resources/META-INF/mods.toml | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) 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 90b228bb3..d164e3bd2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -258,8 +258,6 @@ object MRegistry { bus.addListener(this::registerItemColorHandlers) bus.addListener(this::registerItemDecorators) - bus.addListener(MCreativeTabs::register) - DecimalProvider.register(bus) AndroidResearchDescription.register(bus) AndroidResearchDescriptions.register(bus) diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index f658fa297..59d818de6 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -6,7 +6,7 @@ # The name of the mod loader type to load - for regular FML @Mod mods it should be javafml modLoader="javafml" #mandatory # A version range to match for said mod loader - for regular FML @Mod it will be the forge version -loaderVersion="[47,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. +loaderVersion="[45,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. # The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties. # Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here. license="2 Clause BSD" @@ -41,7 +41,7 @@ Matter. Energy. Combined. # Does this dependency have to exist - if not, ordering below must be specified mandatory=true #mandatory # The version range of the dependency - versionRange="[47.0.0,)" #mandatory + versionRange="[45.0.0,)" #mandatory # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory ordering="NONE" # Side this dependency is applied on - BOTH, CLIENT or SERVER @@ -51,6 +51,6 @@ Matter. Energy. Combined. modId="minecraft" mandatory=true # This version range declares a minimum of the current minecraft version up to but not including the next major version - versionRange="[1.20.1,1.20.2)" + versionRange="[1.19.4,1.20)" ordering="NONE" side="BOTH" From da4c1108c25f91466bb6354be4e60078268cd94b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 14:45:37 +0700 Subject: [PATCH 1180/1199] Fix slot panel quick move display --- .../dbotthepony/mc/otm/client/screen/panels/slot/SlotPanel.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 3abd71787..5ec271a7d 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 @@ -74,10 +74,10 @@ open class SlotPanel, out T : Slot> @JvmOverloads const screen.quickCraftSlots, screen.quickCraftingType, itemstack, - slot.item.count + if (slot.item.isEmpty) 0 else slot.item.count ) - val k = Math.min(slot.item.count, slot.getMaxStackSize(itemstack)) + val k = itemstack.maxStackSize.coerceAtMost(slot.getMaxStackSize(itemstack)) if (itemstack.count > k) { countOverride = ChatFormatting.YELLOW.toString() + k From 50112bfbafc6f51a150ac76e2050cf2333e9f1a8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 15:00:50 +0700 Subject: [PATCH 1181/1199] Don't make cables seem to be interactable --- src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt index d0405c814..50b6a759a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt @@ -6,7 +6,11 @@ package ru.dbotthepony.mc.otm.block import com.google.common.collect.ImmutableMap import net.minecraft.core.BlockPos import net.minecraft.core.Direction +import net.minecraft.world.InteractionHand +import net.minecraft.world.InteractionResult +import net.minecraft.world.entity.player.Player import net.minecraft.world.level.BlockGetter +import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.EntityBlock import net.minecraft.world.level.block.SoundType @@ -15,6 +19,7 @@ import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.level.block.state.properties.BooleanProperty import net.minecraft.world.level.material.MapColor +import net.minecraft.world.phys.BlockHitResult import net.minecraft.world.phys.shapes.BooleanOp import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.Shapes @@ -53,6 +58,11 @@ abstract class CableBlock(properties: Properties) : MatteryBlock(properties) { return getShapeForEachState { getShapeFor(it, halfCoreSize) } } + @Suppress("OVERRIDE_DEPRECATION") + override fun use(blockState: BlockState, level: Level, blockPos: BlockPos, ply: Player, hand: InteractionHand, blockHitResult: BlockHitResult): InteractionResult { + return InteractionResult.PASS + } + companion object { fun getShapeFor(it: BlockState, halfCoreSize: Double): VoxelShape { val shapes = ArrayList() From 64b8346424c219249d7445aba97b0613b8f6245c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 16:37:42 +0700 Subject: [PATCH 1182/1199] Specify proper piston push behavior for most blocks --- src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt | 7 ++++--- .../ru/dbotthepony/mc/otm/block/ExplosionDebuggerBlock.kt | 3 ++- .../kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt | 2 ++ .../dbotthepony/mc/otm/block/decorative/DevChestBlock.kt | 3 ++- .../ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt | 3 ++- .../dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt | 2 +- .../dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt | 2 +- .../mc/otm/block/decorative/InfiniteWaterSourceBlock.kt | 3 ++- .../dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt | 5 +++-- .../dbotthepony/mc/otm/block/decorative/PainterBlock.kt | 2 +- .../dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt | 4 ++-- .../mc/otm/block/matter/MatterCapacitorBankBlock.kt | 2 +- .../mc/otm/block/matter/MatterDecomposerBlock.kt | 4 +--- .../mc/otm/block/matter/MatterEntanglerBlock.kt | 2 +- .../dbotthepony/mc/otm/block/matter/MatterPanelBlock.kt | 2 +- .../mc/otm/block/matter/MatterReconstructorBlock.kt | 2 +- .../mc/otm/block/matter/MatterRecyclerBlock.kt | 2 +- .../mc/otm/block/matter/MatterReplicatorBlock.kt | 2 +- .../dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt | 2 +- .../mc/otm/block/matter/PatternStorageBlock.kt | 4 ++-- .../ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt | 2 +- .../dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt | 2 +- .../dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt | 2 +- .../dbotthepony/mc/otm/block/storage/StorageBusBlock.kt | 2 +- .../dbotthepony/mc/otm/block/storage/StorageInterfaces.kt | 4 ++-- .../mc/otm/block/storage/StoragePowerSupplierBlock.kt | 2 +- .../dbotthepony/mc/otm/block/tech/AndroidStationBlock.kt | 2 +- .../ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt | 2 +- .../mc/otm/block/tech/ChemicalGeneratorBlock.kt | 2 +- .../ru/dbotthepony/mc/otm/block/tech/CobblerBlock.kt | 2 +- .../dbotthepony/mc/otm/block/tech/EnergyCounterBlock.kt | 2 +- .../ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt | 2 +- .../dbotthepony/mc/otm/block/tech/EssenceStorageBlock.kt | 2 +- .../mc/otm/block/tech/PhantomAttractorBlock.kt | 3 ++- .../ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt | 2 +- .../dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt | 2 +- src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt | 8 +++++++- 37 files changed, 57 insertions(+), 44 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt index 50b6a759a..e5bbdacc5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt @@ -19,6 +19,7 @@ import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.level.block.state.properties.BooleanProperty import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.BlockHitResult import net.minecraft.world.phys.shapes.BooleanOp import net.minecraft.world.phys.shapes.CollisionContext @@ -113,7 +114,7 @@ abstract class CableBlock(properties: Properties) : MatteryBlock(properties) { } } -class MatterCableBlock : CableBlock(Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock { +class MatterCableBlock : CableBlock(Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().pushReaction(PushReaction.DESTROY).sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock { private val shapes = generateShapes(0.15) @Suppress("OVERRIDE_DEPRECATION") @@ -126,7 +127,7 @@ class MatterCableBlock : CableBlock(Properties.of().mapColor(MapColor.METAL).req } } -class StorageCableBlock : CableBlock(Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock { +class StorageCableBlock : CableBlock(Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().pushReaction(PushReaction.DESTROY).sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock { private val shapes = generateShapes(0.185) @Suppress("OVERRIDE_DEPRECATION") @@ -139,7 +140,7 @@ class StorageCableBlock : CableBlock(Properties.of().mapColor(MapColor.METAL).re } } -class EnergyCableBlock(val factory: (blockPos: BlockPos, blockState: BlockState) -> BlockEntity) : CableBlock(Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock { +class EnergyCableBlock(val factory: (blockPos: BlockPos, blockState: BlockState) -> BlockEntity) : CableBlock(Properties.of().mapColor(MapColor.METAL).pushReaction(PushReaction.DESTROY).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock { private val shapes = generateShapes(0.185) @Suppress("OVERRIDE_DEPRECATION") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/ExplosionDebuggerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/ExplosionDebuggerBlock.kt index 2643ffc89..fb0640659 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/ExplosionDebuggerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/ExplosionDebuggerBlock.kt @@ -9,11 +9,12 @@ import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.entity.BlockEntityTicker import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.level.material.PushReaction import ru.dbotthepony.mc.otm.block.entity.blackhole.BlockEntityExplosionDebugger import ru.dbotthepony.mc.otm.block.entity.blackhole.BlockEntitySphereDebugger import ru.dbotthepony.mc.otm.registry.MBlockEntities -class BlockExplosionDebugger : Block(Properties.of().sound(SoundType.STONE)), EntityBlock { +class BlockExplosionDebugger : Block(Properties.of().sound(SoundType.STONE).pushReaction(PushReaction.BLOCK)), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return BlockEntityExplosionDebugger(p_153215_, p_153216_) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt index c7806370f..f6d4459d7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt @@ -21,6 +21,7 @@ import net.minecraft.world.level.block.EntityBlock import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.properties.Property import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.BlockHitResult import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.entity.IRedstoneControlled @@ -239,6 +240,7 @@ abstract class MatteryBlock(properties: Properties = DEFAULT_PROPERTIES) : Block companion object { val DEFAULT_PROPERTIES: Properties = Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().destroyTime(1.5f).explosionResistance(25.0f) + val DEFAULT_MACHINE_PROPERTIES: Properties = Properties.of().mapColor(MapColor.METAL).pushReaction(PushReaction.BLOCK).requiresCorrectToolForDrops().destroyTime(1.5f).explosionResistance(25.0f) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/DevChestBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/DevChestBlock.kt index 9e2a1fbd5..3e6c21913 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/DevChestBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/DevChestBlock.kt @@ -4,10 +4,11 @@ import net.minecraft.core.BlockPos import net.minecraft.world.level.block.EntityBlock import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.level.material.PushReaction import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.decorative.DevChestBlockEntity -class DevChestBlock : RotatableMatteryBlock(Properties.of().destroyTime(-1f).explosionResistance(360000f)), EntityBlock { +class DevChestBlock : RotatableMatteryBlock(Properties.of().destroyTime(-1f).explosionResistance(360000f).pushReaction(PushReaction.BLOCK)), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return DevChestBlockEntity(p_153215_, p_153216_) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt index d879d13a3..3ff655cdc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt @@ -9,6 +9,7 @@ import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.block.SoundType import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock @@ -17,7 +18,7 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.shapes.BlockShapes -class EngineBlock : RotatableMatteryBlock(Properties.of().mapColor(MapColor.COLOR_ORANGE).sound(SoundType.METAL).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) { +class EngineBlock : RotatableMatteryBlock(Properties.of().mapColor(MapColor.COLOR_ORANGE).sound(SoundType.METAL).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops().pushReaction(PushReaction.NORMAL)) { override fun appendHoverText( p_49816_: ItemStack, p_49817_: BlockGetter?, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt index 6764fc0b4..ea0b5a975 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/FluidTankBlock.kt @@ -21,7 +21,7 @@ import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.shapes.BlockShapes -class FluidTankBlock : RotatableMatteryBlock(), EntityBlock { +class FluidTankBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { override fun newBlockEntity(pPos: BlockPos, pState: BlockState): BlockEntity { return FluidTankBlockEntity(pPos, pState) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt index b784c2f1d..d54faef8e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/HoloSignBlock.kt @@ -13,7 +13,7 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.shapes.BlockShapes -class HoloSignBlock : RotatableMatteryBlock(), EntityBlock { +class HoloSignBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { override fun rotationFreedom(): BlockRotationFreedom { return BlockRotationFreedom.DIRECTIONAL_WITH_ROTATION } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/InfiniteWaterSourceBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/InfiniteWaterSourceBlock.kt index faab35e82..294a0353a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/InfiniteWaterSourceBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/InfiniteWaterSourceBlock.kt @@ -8,10 +8,11 @@ import net.minecraft.world.level.block.entity.BlockEntityTicker import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.PushReaction import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.decorative.InfiniteWaterSourceBlockEntity -class InfiniteWaterSourceBlock : RotatableMatteryBlock(Properties.of().destroyTime(1.5f).explosionResistance(10f).requiresCorrectToolForDrops().mapColor(MapColor.WATER)), EntityBlock { +class InfiniteWaterSourceBlock : RotatableMatteryBlock(Properties.of().destroyTime(1.5f).explosionResistance(10f).pushReaction(PushReaction.NORMAL).requiresCorrectToolForDrops().mapColor(MapColor.WATER)), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return InfiniteWaterSourceBlockEntity(p_153215_, p_153216_) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt index 3dc4aa81c..c8d8d6afe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt @@ -14,6 +14,7 @@ import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.level.block.state.properties.BlockStateProperties import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.Shapes import net.minecraft.world.phys.shapes.VoxelShape @@ -28,7 +29,7 @@ import ru.dbotthepony.mc.otm.registry.MBlocks private val FACING_FULL = BlockRotationFreedom.DIRECTIONAL.property -class LaboratoryLampLight : Block(Properties.of().strength(-1.0F, 3600000.8F).noCollission().noLootTable().replaceable().lightLevel { 15 }) { +class LaboratoryLampLight : Block(Properties.of().strength(-1.0F, 3600000.8F).noCollission().noLootTable().replaceable().pushReaction(PushReaction.DESTROY).lightLevel { 15 }) { override fun createBlockStateDefinition(builder: StateDefinition.Builder) { super.createBlockStateDefinition(builder) builder.add(FACING_FULL) @@ -102,7 +103,7 @@ class LaboratoryLampLight : Block(Properties.of().strength(-1.0F, 3600000.8F).no } } -class LaboratoryLamp(val invertRedstone: Boolean) : Block(Properties.of().mapColor(MapColor.METAL).sound(SoundType.METAL).explosionResistance(12f).destroyTime(2f).requiresCorrectToolForDrops()) { +class LaboratoryLamp(val invertRedstone: Boolean) : Block(Properties.of().mapColor(MapColor.METAL).sound(SoundType.METAL).explosionResistance(12f).destroyTime(2f).requiresCorrectToolForDrops().pushReaction(PushReaction.BLOCK)) { init { registerDefaultState(stateDefinition.any().setValue(BlockStateProperties.LIT, !invertRedstone)) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/PainterBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/PainterBlock.kt index 0e8ffdaa6..c13cce68a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/PainterBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/PainterBlock.kt @@ -10,7 +10,7 @@ import net.minecraft.world.level.block.state.BlockState import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.decorative.PainterBlockEntity -class PainterBlock : RotatableMatteryBlock(), EntityBlock { +class PainterBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return PainterBlockEntity(p_153215_, p_153216_) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt index ad79208e4..7dd4a1876 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterBottlerBlock.kt @@ -22,8 +22,8 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes -class MatterBottlerBlock : RotatableMatteryBlock(), EntityBlock { - override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity? { +class MatterBottlerBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { + override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return MatterBottlerBlockEntity(blockPos, blockState) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt index 99ff2d94a..8dd5f1d73 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterCapacitorBankBlock.kt @@ -18,7 +18,7 @@ import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.shapes.BlockShapes -class MatterCapacitorBankBlock : RotatableMatteryBlock(), EntityBlock { +class MatterCapacitorBankBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return MatterCapacitorBankBlockEntity(blockPos, blockState) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt index 1393720be..8a3034140 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterDecomposerBlock.kt @@ -22,9 +22,7 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes -@MethodsReturnNonnullByDefault -@ParametersAreNonnullByDefault -class MatterDecomposerBlock : RotatableMatteryBlock(), EntityBlock { +class MatterDecomposerBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return MatterDecomposerBlockEntity(blockPos, blockState) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterEntanglerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterEntanglerBlock.kt index 23427703f..96bcf3b1a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterEntanglerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterEntanglerBlock.kt @@ -10,7 +10,7 @@ import net.minecraft.world.level.block.state.BlockState import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.matter.MatterEntanglerBlockEntity -class MatterEntanglerBlock : RotatableMatteryBlock(), EntityBlock { +class MatterEntanglerBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return MatterEntanglerBlockEntity(blockPos, blockState) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterPanelBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterPanelBlock.kt index 00cc3a746..fbabb31e2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterPanelBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterPanelBlock.kt @@ -17,7 +17,7 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom -class MatterPanelBlock : RotatableMatteryBlock(), EntityBlock { +class MatterPanelBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return MatterPanelBlockEntity(blockPos, blockState) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReconstructorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReconstructorBlock.kt index d46b0e414..3452c1ff2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReconstructorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReconstructorBlock.kt @@ -16,7 +16,7 @@ import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.shapes.BlockShapes -class MatterReconstructorBlock : RotatableMatteryBlock(), EntityBlock { +class MatterReconstructorBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { override fun newBlockEntity(pPos: BlockPos, pState: BlockState): BlockEntity { return MatterReconstructorBlockEntity(pPos, pState) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt index 1f5078266..13d2bcd0f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterRecyclerBlock.kt @@ -20,7 +20,7 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes -class MatterRecyclerBlock : RotatableMatteryBlock(), EntityBlock { +class MatterRecyclerBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return MatterRecyclerBlockEntity(p_153215_, p_153216_) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt index 1609c8740..a51b83ae5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterReplicatorBlock.kt @@ -20,7 +20,7 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes -class MatterReplicatorBlock : RotatableMatteryBlock(), EntityBlock { +class MatterReplicatorBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return MatterReplicatorBlockEntity(blockPos, blockState) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt index 157a81bef..53cc306ca 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/MatterScannerBlock.kt @@ -20,7 +20,7 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes -class MatterScannerBlock : RotatableMatteryBlock(), EntityBlock { +class MatterScannerBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return MatterScannerBlockEntity(blockPos, blockState) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt index fc2a84286..d5f36e76a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/matter/PatternStorageBlock.kt @@ -19,8 +19,8 @@ import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.shapes.BlockShapes -class PatternStorageBlock : RotatableMatteryBlock(), EntityBlock { - override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity? { +class PatternStorageBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { + override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return PatternStorageBlockEntity(blockPos, blockState) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt index cd4862293..8f4ecc071 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveRackBlock.kt @@ -22,7 +22,7 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes -class DriveRackBlock : RotatableMatteryBlock(), EntityBlock { +class DriveRackBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return DriveRackBlockEntity(blockPos, blockState) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt index ab4b10c66..03a0bb47c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/DriveViewerBlock.kt @@ -27,7 +27,7 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes -class DriveViewerBlock : RotatableMatteryBlock(), EntityBlock { +class DriveViewerBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return DriveViewerBlockEntity(blockPos, blockState) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt index 95bdd4d32..32dd33264 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/ItemMonitorBlock.kt @@ -22,7 +22,7 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes -class ItemMonitorBlock : RotatableMatteryBlock(), EntityBlock { +class ItemMonitorBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return ItemMonitorBlockEntity(blockPos, blockState) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt index 73e66b896..568ec92e9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageBusBlock.kt @@ -31,7 +31,7 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes import ru.dbotthepony.mc.otm.core.math.unaryMinus -class StorageBusBlock : RotatableMatteryBlock(), EntityBlock { +class StorageBusBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { override fun rotationFreedom(): BlockRotationFreedom { return BlockRotationFreedom.DIRECTIONAL } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt index bf45778be..aaef6b7f4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StorageInterfaces.kt @@ -32,7 +32,7 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes import ru.dbotthepony.mc.otm.core.math.unaryMinus -class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock { +class StorageImporterBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { override fun rotationFreedom(): BlockRotationFreedom { return BlockRotationFreedom.DIRECTIONAL } @@ -105,7 +105,7 @@ class StorageImporterBlock : RotatableMatteryBlock(), EntityBlock { } } -class StorageExporterBlock : RotatableMatteryBlock(), EntityBlock { +class StorageExporterBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { override fun rotationFreedom(): BlockRotationFreedom { return BlockRotationFreedom.DIRECTIONAL } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt index dcef7302a..0f756e32e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/storage/StoragePowerSupplierBlock.kt @@ -22,7 +22,7 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes -class StoragePowerSupplierBlock : RotatableMatteryBlock(), EntityBlock { +class StoragePowerSupplierBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return StoragePowerSupplierBlockEntity(p_153215_, p_153216_) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidStationBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidStationBlock.kt index 722b13328..962af67b5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidStationBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidStationBlock.kt @@ -29,7 +29,7 @@ import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes -class AndroidStationBlock : MatteryBlock(), EntityBlock { +class AndroidStationBlock : MatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { override fun use( blockState: BlockState, level: Level, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt index 75a288228..c5f7f9c87 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/BatteryBankBlock.kt @@ -27,7 +27,7 @@ import ru.dbotthepony.mc.otm.shapes.BlockShapes @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault -class BatteryBankBlock : RotatableMatteryBlock(), EntityBlock { +class BatteryBankBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { override fun getTicker( level: Level, p_153213_: BlockState, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt index 3dd554dbb..3ba037ad4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/ChemicalGeneratorBlock.kt @@ -34,7 +34,7 @@ import ru.dbotthepony.mc.otm.oncePre import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes -class ChemicalGeneratorBlock : RotatableMatteryBlock(), EntityBlock { +class ChemicalGeneratorBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return ChemicalGeneratorBlockEntity(p_153215_, p_153216_) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/CobblerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/CobblerBlock.kt index 8be327fc1..5da695907 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/CobblerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/CobblerBlock.kt @@ -16,7 +16,7 @@ import ru.dbotthepony.mc.otm.block.entity.tech.CobblerBlockEntity import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.shapes.BlockShapes -class CobblerBlock : RotatableMatteryBlock(), EntityBlock { +class CobblerBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { override fun newBlockEntity(pPos: BlockPos, pState: BlockState): BlockEntity { return CobblerBlockEntity(pPos, pState) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyCounterBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyCounterBlock.kt index b6c4a565a..6e0e61f94 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyCounterBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyCounterBlock.kt @@ -22,7 +22,7 @@ import ru.dbotthepony.mc.otm.once import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes -class EnergyCounterBlock : MatteryBlock(), EntityBlock { +class EnergyCounterBlock : MatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return EnergyCounterBlockEntity(blockPos, blockState) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt index b6a0aaa1a..4dff8b68c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt @@ -19,7 +19,7 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes -class EnergyServoBlock : RotatableMatteryBlock(Properties.of().mapColor(MapColor.COLOR_BLUE).sound(SoundType.METAL).explosionResistance(12f).destroyTime(2f).requiresCorrectToolForDrops()), EntityBlock { +class EnergyServoBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return EnergyServoBlockEntity(p_153215_, p_153216_) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EssenceStorageBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EssenceStorageBlock.kt index 85b813e2f..41eb4826a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EssenceStorageBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EssenceStorageBlock.kt @@ -21,7 +21,7 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.shapes.BlockShapes -class EssenceStorageBlock : RotatableMatteryBlock(), EntityBlock { +class EssenceStorageBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { override fun newBlockEntity(pPos: BlockPos, pState: BlockState): BlockEntity { return EssenceStorageBlockEntity(pPos, pState) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt index 9e0ff3fe7..ef92bc7f5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt @@ -21,6 +21,7 @@ import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.level.block.state.properties.BlockStateProperties import net.minecraft.world.level.block.state.properties.DoubleBlockHalf import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.AABB import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape @@ -34,7 +35,7 @@ import ru.dbotthepony.mc.otm.once import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.shapes.BlockShapes -class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of().mapColor(MapColor.COLOR_BLUE).sound(SoundType.METAL).destroyTime(3f).explosionResistance(12f).randomTicks()) { +class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of().mapColor(MapColor.COLOR_BLUE).sound(SoundType.METAL).pushReaction(PushReaction.BLOCK).destroyTime(3f).explosionResistance(12f).randomTicks()) { @Suppress("OVERRIDE_DEPRECATION") override fun randomTick( blockState: BlockState, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt index 740271336..8aed09a9a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PlatePressBlock.kt @@ -24,7 +24,7 @@ import ru.dbotthepony.mc.otm.block.getShapeForEachState import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.shapes.BlockShapes -class PlatePressBlock(properties: Properties = DEFAULT_PROPERTIES, val isTwin: Boolean = false) : RotatableMatteryBlock(properties), EntityBlock { +class PlatePressBlock(properties: Properties = DEFAULT_MACHINE_PROPERTIES, val isTwin: Boolean = false) : RotatableMatteryBlock(properties), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return PlatePressBlockEntity(p_153215_, p_153216_, isTwin) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt index 1f1be51a0..54eda35b1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PoweredFurnaceBlock.kt @@ -31,7 +31,7 @@ class PoweredFurnaceBlock( val secondaryRecipeType: (() -> RecipeType)?, val config: WorkerBalanceValues, shape: BlockShape? -) : RotatableMatteryBlock(), EntityBlock { +) : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): PoweredFurnaceBlockEntity { return PoweredFurnaceBlockEntity(type.invoke(), p_153215_, p_153216_, recipeType, secondaryRecipeType, config) } 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 bb75430c5..a5ea5b8ff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -180,7 +180,13 @@ object MBlocks { } val TRITANIUM_BARS: IronBarsBlock by registry.register(MNames.TRITANIUM_BARS) { - IronBarsBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_LIGHT_BLUE).sound(SoundType.METAL).explosionResistance(45f).destroyTime(2.5f).requiresCorrectToolForDrops()) + IronBarsBlock(BlockBehaviour.Properties.of() + .mapColor(MapColor.COLOR_LIGHT_BLUE) + .sound(SoundType.METAL) + .explosionResistance(45f) + .noOcclusion() + .destroyTime(2.5f) + .requiresCorrectToolForDrops()) } val DEEPSLATE_TRITANIUM_ORE: Block by registry.register(MNames.DEEPSLATE_TRITANIUM_ORE) { DropExperienceBlock( From 4e3ca82fc76533372fdc39b56eb706e2bc0cd43c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 16:43:11 +0700 Subject: [PATCH 1183/1199] Destroy cables on piston push instead of block --- src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt index 0b442eadc..02ba02eed 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt @@ -44,7 +44,7 @@ abstract class CableBlock(properties: Properties) : MatteryBlock(properties) { override fun hasDynamicShape() = true override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { - return PushReaction.BLOCK + return PushReaction.DESTROY } override fun createBlockStateDefinition(builder: StateDefinition.Builder) { From 18965ccfc79cdb38a2d38a260ac45b5eae100cc0 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 16:50:37 +0700 Subject: [PATCH 1184/1199] god damn it --- .../ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 612fc76d2..cddfee6e0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -1393,7 +1393,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial combinedInventory.consumeItem(stack, false, slots = offhandSlotRange, onlyIntoExisting = true, popTime = 5) inventoryAndExopack.consumeItem(stack, false, onlyIntoExisting = false, popTime = 5) } else { - wrappedInventory.consumeItem(stack, false, slots = IntSet.of(ply.inventory.selected), onlyIntoExisting = false, popTime = 5) + wrappedInventory.consumeItem(stack, false, slots = IntSet.of(ply.inventory.selected), onlyIntoExisting = true, popTime = 5) wrappedInventory.consumeItem(stack, false, slots = offhandSlotRange, onlyIntoExisting = true, popTime = 5) wrappedItemInventory.consumeItem(stack, false, onlyIntoExisting = false, popTime = 5) } From 45dd3e5c4bf278991691b694cbadb5e5a0b0e225 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 17:02:19 +0700 Subject: [PATCH 1185/1199] Downgrade dependencies --- gradle.properties | 14 +++++++------- src/main/resources/META-INF/mods.toml | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gradle.properties b/gradle.properties index e494df7cf..26f8720c1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,24 +10,24 @@ mod_version=1.4 use_commit_hash_in_version=true -mc_version=1.19.4 -jei_mc_version=1.19.4 -curios_mc_version=1.19.4 +mc_version=1.19.3 +jei_mc_version=1.19.3 +curios_mc_version=1.19.3 forge_gradle_version=[6.0.14,6.2) -forge_version=45.2.8 +forge_version=44.1.23 mixingradle_version=0.7.33 mixin_version=0.8.5 -jei_version=13.1.0.16 +jei_version=12.4.0.22 jupiter_version=5.9.2 -curios_version=4834414 +curios_version=4440173 cosmetic_armor_reworked_id=4439659 ad_astra_id=4594155 botarium_id=4594094 resourceful_lib_id=4598948 resourceful_config_id=4576455 -jade_id=4573063 +jade_id=4434045 configured_id=4462894 kotlin_for_forge_version=4.7.0 diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 59d818de6..eb74bb55e 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -6,7 +6,7 @@ # The name of the mod loader type to load - for regular FML @Mod mods it should be javafml modLoader="javafml" #mandatory # A version range to match for said mod loader - for regular FML @Mod it will be the forge version -loaderVersion="[45,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. +loaderVersion="[44,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. # The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties. # Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here. license="2 Clause BSD" @@ -41,7 +41,7 @@ Matter. Energy. Combined. # Does this dependency have to exist - if not, ordering below must be specified mandatory=true #mandatory # The version range of the dependency - versionRange="[45.0.0,)" #mandatory + versionRange="[44.0.0,)" #mandatory # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory ordering="NONE" # Side this dependency is applied on - BOTH, CLIENT or SERVER @@ -51,6 +51,6 @@ Matter. Energy. Combined. modId="minecraft" mandatory=true # This version range declares a minimum of the current minecraft version up to but not including the next major version - versionRange="[1.19.4,1.20)" + versionRange="[1.19.3,1.19.4)" ordering="NONE" side="BOTH" From 0a5ae5461440177fb787aea1025ebf5836753602 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 17:18:57 +0700 Subject: [PATCH 1186/1199] Some backporting --- .../client/render/blockentity/FluidTankRenderer.kt | 6 +++--- .../mc/otm/container/DynamicallyProxiedContainer.kt | 4 ---- .../ru/dbotthepony/mc/otm/container/IContainer.kt | 8 -------- src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 1 + .../mc/otm/recipe/EnergyContainerRecipe.kt | 12 ++++-------- .../ru/dbotthepony/mc/otm/recipe/IMatteryRecipe.kt | 4 ---- .../ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt | 8 ++++---- .../ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt | 4 ++-- 8 files changed, 14 insertions(+), 33 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/FluidTankRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/FluidTankRenderer.kt index 4d9fd6fc4..3159ae3ca 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/FluidTankRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/FluidTankRenderer.kt @@ -3,12 +3,12 @@ package ru.dbotthepony.mc.otm.client.render.blockentity import com.mojang.blaze3d.vertex.* import com.mojang.math.Axis import net.minecraft.client.renderer.* +import net.minecraft.client.renderer.block.model.ItemTransforms import net.minecraft.client.renderer.blockentity.BlockEntityRenderer import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider import net.minecraft.client.renderer.entity.ItemRenderer import net.minecraft.world.inventory.InventoryMenu import net.minecraft.world.item.BlockItem -import net.minecraft.world.item.ItemDisplayContext import net.minecraft.world.item.ItemStack import net.minecraft.world.level.block.HalfTransparentBlock import net.minecraft.world.level.block.StainedGlassPaneBlock @@ -38,7 +38,7 @@ class FluidTankRenderer(private val context: BlockEntityRendererProvider.Context object FluidTankItemRenderer : BlockEntityWithoutLevelRenderer(minecraft.blockEntityRenderDispatcher, minecraft.entityModels) { override fun renderByItem( stack: ItemStack, - displayContext: ItemDisplayContext, + displayContext: ItemTransforms.TransformType, poseStack: PoseStack, bufferSource: MultiBufferSource, packedLight: Int, @@ -51,7 +51,7 @@ class FluidTankRenderer(private val context: BlockEntityRendererProvider.Context } val hasFoil = stack.hasFoil() - val fabulous = displayContext == ItemDisplayContext.GUI + val fabulous = displayContext == ItemTransforms.TransformType.GUI || displayContext.firstPerson() || (stack.item is BlockItem && ((stack.item as BlockItem).block is HalfTransparentBlock || (stack.item as BlockItem).block is StainedGlassPaneBlock)) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/DynamicallyProxiedContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/DynamicallyProxiedContainer.kt index b2e400392..26b258970 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/DynamicallyProxiedContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/DynamicallyProxiedContainer.kt @@ -63,10 +63,6 @@ class DynamicallyProxiedContainer(private val toProxy: Supplier) : IC return toProxy.get().canPlaceItem(slot, itemStack) } - override fun canTakeItem(container: Container, slot: Int, itemStack: ItemStack): Boolean { - return toProxy.get().canTakeItem(container, slot, itemStack) - } - override fun countItem(item: Item): Int { return toProxy.get().countItem(item) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/IContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/IContainer.kt index 3afa4ab72..152b969e5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/IContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/IContainer.kt @@ -26,10 +26,6 @@ interface IContainer : Container { return super.canPlaceItem(slot, itemStack) } - override fun canTakeItem(container: Container, slot: Int, itemStack: ItemStack): Boolean { - return super.canTakeItem(container, slot, itemStack) - } - override fun countItem(item: Item): Int { return super.countItem(item) } @@ -74,10 +70,6 @@ interface IContainer : Container { return container.canPlaceItem(slot, itemStack) } - override fun canTakeItem(container: Container, slot: Int, itemStack: ItemStack): Boolean { - return container.canTakeItem(container, slot, itemStack) - } - override fun countItem(item: Item): Int { return container.countItem(item) } 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 173689550..1a3e5ce02 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -10,6 +10,7 @@ import com.google.common.collect.ImmutableSet import com.google.gson.JsonElement import com.google.gson.JsonObject import com.google.gson.JsonPrimitive +import com.mojang.serialization.DataResult import it.unimi.dsi.fastutil.objects.ObjectComparators import net.minecraft.core.BlockPos import net.minecraft.nbt.CompoundTag 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 6541d8ab9..8990a7ca2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/EnergyContainerRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/EnergyContainerRecipe.kt @@ -26,8 +26,8 @@ class EnergyContainerRecipe(val parent: ShapedRecipe) : CraftingRecipe, IShapedR return parent.canCraftInDimensions(p_43999_, p_44000_) } - override fun getResultItem(p_267052_: RegistryAccess): ItemStack { - return parent.getResultItem(p_267052_) + override fun getResultItem(): ItemStack { + return parent.getResultItem() } override fun category(): CraftingBookCategory { @@ -46,10 +46,6 @@ class EnergyContainerRecipe(val parent: ShapedRecipe) : CraftingRecipe, IShapedR return parent.isSpecial } - override fun showNotification(): Boolean { - return parent.showNotification() - } - override fun getGroup(): String { return parent.group } @@ -66,8 +62,8 @@ class EnergyContainerRecipe(val parent: ShapedRecipe) : CraftingRecipe, IShapedR return parent.type } - override fun assemble(container: CraftingContainer, registryAccess: RegistryAccess): ItemStack { - val itemStack = parent.assemble(container, registryAccess) + override fun assemble(container: CraftingContainer): ItemStack { + val itemStack = parent.assemble(container) val battery = container.stream() .filter { !it.isEmpty } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/IMatteryRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/IMatteryRecipe.kt index 3e5ac763e..a8045539c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/IMatteryRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/IMatteryRecipe.kt @@ -23,10 +23,6 @@ interface IMatteryRecipe : Recipe { return super.isSpecial() } - override fun showNotification(): Boolean { - return super.showNotification() - } - override fun getGroup(): String { return super.getGroup() } 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 8fff7cc78..b726497b5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt @@ -135,7 +135,7 @@ class PainterRecipe( return NonNullList.of(Ingredient.EMPTY, input) } - override fun assemble(p_44001_: Container, p_267165_: RegistryAccess): ItemStack { + override fun assemble(p_44001_: Container): ItemStack { return output.copy().also { o -> p_44001_[0].tag?.let { if (o.tag == null) { @@ -149,7 +149,7 @@ class PainterRecipe( } } - override fun getResultItem(p_267052_: RegistryAccess): ItemStack { + override fun getResultItem(): ItemStack { return output } @@ -194,7 +194,7 @@ class PainterArmorDyeRecipe( return !isIncomplete && value.item is DyeableArmorItem } - override fun assemble(container: Container, registry: RegistryAccess): ItemStack { + override fun assemble(container: Container): ItemStack { var output = container[0].copy() dyes.forEach { entry -> @@ -208,7 +208,7 @@ class PainterArmorDyeRecipe( return output } - override fun getResultItem(registry: RegistryAccess): ItemStack = ItemStack.EMPTY + override fun getResultItem(): ItemStack = ItemStack.EMPTY override fun getSerializer(): RecipeSerializer<*> = SERIALIZER diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt index 143d7cd1d..a55184efd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PlatePressRecipe.kt @@ -70,9 +70,9 @@ class PlatePressRecipe( return input.isActuallyEmpty || output.isActuallyEmpty } - override fun assemble(p_44001_: Container, registry: RegistryAccess): ItemStack = outputStack.copy() + override fun assemble(p_44001_: Container): ItemStack = outputStack.copy() override fun canCraftInDimensions(p_43999_: Int, p_44000_: Int) = true - override fun getResultItem(registry: RegistryAccess): ItemStack = outputStack + override fun getResultItem(): ItemStack = outputStack override fun getSerializer(): RecipeSerializer<*> { return SERIALIZER From e3df0d82e0d2f4416c05efa0a61680105f216417 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 17:28:46 +0700 Subject: [PATCH 1187/1199] Polyfill dataresult --- .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 18 ++++++++++--- .../mc/otm/core/util/StreamCodecs.kt | 6 +++-- .../mc/otm/data/Codec2RecipeSerializer.kt | 6 +++-- .../ru/dbotthepony/mc/otm/data/CodecList.kt | 11 ++++---- .../mc/otm/data/ComparableCodec.kt | 9 ++++--- .../dbotthepony/mc/otm/data/ComponentCodec.kt | 6 +++-- .../dbotthepony/mc/otm/data/DecimalCodec.kt | 24 +++++++++-------- .../mc/otm/data/IngredientMatrixCodec.kt | 26 ++++++++++--------- .../ru/dbotthepony/mc/otm/data/UUIDCodec.kt | 18 +++++++------ .../mc/otm/matter/ComputeAction.kt | 20 +++++++------- .../mc/otm/triggers/MCriterionTrigger.kt | 10 ++++--- 11 files changed, 91 insertions(+), 63 deletions(-) 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 bc23bfbce..60b55c578 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -10,10 +10,10 @@ import com.google.common.collect.ImmutableSet import com.google.gson.JsonElement import com.google.gson.JsonObject import com.google.gson.JsonPrimitive +import com.mojang.serialization.DataResult import it.unimi.dsi.fastutil.objects.ObjectComparators import net.minecraft.core.BlockPos import net.minecraft.nbt.CompoundTag -import net.minecraft.nbt.NbtAccounter import net.minecraft.network.FriendlyByteBuf import net.minecraft.network.chat.ComponentContents import net.minecraft.network.chat.contents.TranslatableContents @@ -26,7 +26,6 @@ import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block -import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateHolder import net.minecraft.world.level.block.state.properties.Property @@ -41,9 +40,7 @@ import net.minecraftforge.registries.IForgeRegistry import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.math.Vector -import ru.dbotthepony.mc.otm.core.util.readInt import ru.dbotthepony.mc.otm.core.util.readVarIntLE -import ru.dbotthepony.mc.otm.core.util.writeInt import ru.dbotthepony.mc.otm.core.util.writeVarIntLE import java.io.InputStream import java.io.OutputStream @@ -467,3 +464,16 @@ fun lazy2(a: () -> A, b: A.() -> B): Supplier { val first = lazy(a) return Supplier { b.invoke(first.value) } } + +// 1.19.3 and earlier polyfill +fun failure(message: String): DataResult { + return DataResult.error { message } +} + +fun failure(message: Supplier): DataResult { + return DataResult.error(message) +} + +fun success(result: R): DataResult { + return DataResult.success(result) +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt index 961847d1e..191ff8fb4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt @@ -8,11 +8,13 @@ import com.mojang.serialization.DynamicOps import net.minecraft.nbt.NbtAccounter import net.minecraft.world.item.ItemStack import net.minecraftforge.fluids.FluidStack +import ru.dbotthepony.mc.otm.core.failure import ru.dbotthepony.mc.otm.core.immutableMap import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.readDecimal import ru.dbotthepony.mc.otm.core.math.writeDecimal import ru.dbotthepony.mc.otm.core.readItemType +import ru.dbotthepony.mc.otm.core.success import ru.dbotthepony.mc.otm.core.writeItemType import java.io.DataInput import java.io.DataInputStream @@ -195,11 +197,11 @@ class EnumValueCodec>(clazz: Class) : IStreamCodec, Codec< override fun decode(ops: DynamicOps, input: T): DataResult> { if (ops.compressMaps()) { return ops.getNumberValue(input) - .flatMap { values.getOrNull(it.toInt())?.let { DataResult.success(Pair(it, ops.empty())) } ?: DataResult.error { "No such enum with ordinal index $it" } } + .flatMap { values.getOrNull(it.toInt())?.let { success(Pair(it, ops.empty())) } ?: failure { "No such enum with ordinal index $it" } } } return ops.getStringValue(input) - .flatMap { valuesMap[it]?.let { DataResult.success(Pair(it, ops.empty())) } ?: DataResult.error { "No such enum value $it" } } + .flatMap { valuesMap[it]?.let { success(Pair(it, ops.empty())) } ?: failure { "No such enum value $it" } } } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt index b32702611..f09e62ffe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt @@ -19,7 +19,9 @@ import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.item.crafting.Recipe import net.minecraft.world.item.crafting.RecipeSerializer import org.apache.logging.log4j.LogManager +import ru.dbotthepony.mc.otm.core.failure import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.success import ru.dbotthepony.mc.otm.core.util.readBinaryJsonWithCodecIndirect import ru.dbotthepony.mc.otm.core.util.writeBinaryJsonWithCodec import kotlin.collections.ArrayDeque @@ -69,9 +71,9 @@ class Codec2RecipeSerializer>( val read = serializer.fromNetwork(buff) if (read == null) - DataResult.error { "Unable to read parent recipe from network" } + failure { "Unable to read parent recipe from network" } else - DataResult.success(Pair(read, ops.empty())) + success(Pair(read, ops.empty())) } } else { return serializer.codec().decode(ops, input) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/CodecList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/CodecList.kt index 572fa629c..00b73e8ec 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/CodecList.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/CodecList.kt @@ -5,6 +5,7 @@ import com.mojang.datafixers.util.Pair import com.mojang.serialization.Codec import com.mojang.serialization.DataResult import com.mojang.serialization.DynamicOps +import ru.dbotthepony.mc.otm.core.failure import ru.dbotthepony.mc.otm.core.stream import java.util.function.Predicate import java.util.stream.Stream @@ -32,7 +33,7 @@ class CodecList(codecs: Stream>) : Codec { } } - return DataResult.error { + return failure { "None of codecs encoded the input:\n " + results.joinToString(";\n ") { it.error().get().message() } } } @@ -50,7 +51,7 @@ class CodecList(codecs: Stream>) : Codec { } } - return DataResult.error { + return failure { "None of codecs decoded the input:\n " + results.joinToString(";\n ") { it.error().get().message() } } } @@ -83,11 +84,11 @@ class PredicatedCodecList(codecs: Stream, Predicat } } else { val i2 = i - results.add(DataResult.error { "Codec #$i2 predicate tested false" }) + results.add(failure { "Codec #$i2 predicate tested false" }) } } - return DataResult.error { + return failure { "None of codecs encoded the input:\n " + results.joinToString(";\n ") { it.error().get().message() } } } @@ -105,7 +106,7 @@ class PredicatedCodecList(codecs: Stream, Predicat } } - return DataResult.error { + return failure { "None of codecs decoded the input:\n " + results.joinToString(";\n ") { it.error().get().message() } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComparableCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComparableCodec.kt index 3a49fcf06..40e4e8545 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComparableCodec.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComparableCodec.kt @@ -4,17 +4,18 @@ import com.mojang.datafixers.util.Pair import com.mojang.serialization.Codec import com.mojang.serialization.DataResult import com.mojang.serialization.DynamicOps +import ru.dbotthepony.mc.otm.core.failure class ComparableCodec>(val parent: Codec, val min: S? = null, val max: S? = null, val minExclusive: Boolean = false, val maxExclusive: Boolean = false) : Codec { private fun check(input: S): DataResult? { if (min != null) { if (minExclusive) { if (input <= min) { - return DataResult.error { "Value $input is smaller or equal to minimal $min" } + return failure { "Value $input is smaller or equal to minimal $min" } } } else { if (input < min) { - return DataResult.error { "Value $input is smaller than minimal $min" } + return failure { "Value $input is smaller than minimal $min" } } } } @@ -22,11 +23,11 @@ class ComparableCodec>(val parent: Codec, val min: S? = nul if (max != null) { if (maxExclusive) { if (input >= max) { - return DataResult.error { "Value $input is bigger or equal to maximal $max" } + return failure { "Value $input is bigger or equal to maximal $max" } } } else { if (input > max) { - return DataResult.error { "Value $input is bigger than maximal $max" } + return failure { "Value $input is bigger than maximal $max" } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComponentCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComponentCodec.kt index ec65bb31a..2a007ea95 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComponentCodec.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComponentCodec.kt @@ -7,6 +7,8 @@ import com.mojang.serialization.DataResult import com.mojang.serialization.DynamicOps import com.mojang.serialization.JsonOps import net.minecraft.network.chat.Component +import ru.dbotthepony.mc.otm.core.failure +import ru.dbotthepony.mc.otm.core.success object ComponentCodec : Codec { override fun encode(input: Component, ops: DynamicOps, prefix: T): DataResult { @@ -17,9 +19,9 @@ object ComponentCodec : Codec { val value = ops.convertTo(JsonOps.INSTANCE, input) try { - return DataResult.success(Pair(Component.Serializer.fromJson(value), ops.empty())) + return success(Pair(Component.Serializer.fromJson(value), ops.empty())) } catch (err: JsonSyntaxException) { - return DataResult.error { "Error decoding component: ${err.message}" } + return failure { "Error decoding component: ${err.message}" } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt index 062564586..7ec7322cd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt @@ -6,7 +6,9 @@ import com.mojang.serialization.DataResult import com.mojang.serialization.DynamicOps import it.unimi.dsi.fastutil.bytes.ByteArrayList import net.minecraft.nbt.NbtOps +import ru.dbotthepony.mc.otm.core.failure import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.success import java.nio.ByteBuffer import java.util.stream.Collector import java.util.stream.Stream @@ -14,47 +16,47 @@ import java.util.stream.Stream object DecimalCodec : Codec { override fun encode(input: Decimal, ops: DynamicOps, prefix: T): DataResult { if (ops === NbtOps.INSTANCE) { - return DataResult.success((ops as DynamicOps).createByteList(ByteBuffer.wrap(input.toByteArray()))) + return success((ops as DynamicOps).createByteList(ByteBuffer.wrap(input.toByteArray()))) } - return DataResult.success(ops.createString(input.toString())) + return success(ops.createString(input.toString())) } override fun decode(ops: DynamicOps, input: T): DataResult> { return ops.getStringValue(input).flatMap { try { - DataResult.success(Pair(Decimal(it), ops.empty())) + success(Pair(Decimal(it), ops.empty())) } catch (err: NumberFormatException) { - DataResult.error { "Not a valid number for converting into Decimal: $it" } + failure { "Not a valid number for converting into Decimal: $it" } } }.get().map( { - DataResult.success(it) + success(it) }, { e0 -> ops.getIntStream(input).flatMap { try { - DataResult.success(Pair(Decimal.fromByteArray( + success(Pair(Decimal.fromByteArray( it .collect(::ByteArrayList, { v, a -> v.add(a.toByte()) }, ByteArrayList::addAll) .toByteArray() ), ops.empty())) } catch (err: NumberFormatException) { - DataResult.error { "Failed to convert array of bytes into Decimal: $it" } + failure { "Failed to convert array of bytes into Decimal: $it" } } }.get().map( { - DataResult.success(it) + success(it) }, { e1 -> ops.getNumberValue(input).flatMap { - DataResult.success(Pair(Decimal(it.toString()), ops.empty())) + success(Pair(Decimal(it.toString()), ops.empty())) }.get().map( { - DataResult.success(it) + success(it) }, { e2 -> - DataResult.error { "None of attempts at decoding Decimal were successful: ${e0.message()}; ${e1.message()}; ${e2.message()}" } + failure { "None of attempts at decoding Decimal were successful: ${e0.message()}; ${e1.message()}; ${e2.message()}" } } ) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientMatrixCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientMatrixCodec.kt index 12d7117cd..731ae577b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientMatrixCodec.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientMatrixCodec.kt @@ -11,7 +11,9 @@ import ru.dbotthepony.mc.otm.core.collect.allEqual import ru.dbotthepony.mc.otm.core.collect.map import ru.dbotthepony.mc.otm.core.collect.toList import ru.dbotthepony.mc.otm.core.collect.toStream +import ru.dbotthepony.mc.otm.core.failure import ru.dbotthepony.mc.otm.core.stream +import ru.dbotthepony.mc.otm.core.success import ru.dbotthepony.mc.otm.recipe.IIngredientMatrix import ru.dbotthepony.mc.otm.recipe.IngredientMatrix import java.util.function.Supplier @@ -38,15 +40,15 @@ class IngredientMatrixCodec(ingredientCodec: Codec) : Codec) : Codec) : Codec handwrittenCodec.decode(ops, input).get().map( { - DataResult.success(it) + success(it) }, { - DataResult.error { "Failed to decode ingredients as list: ${err1.message()} and as pattern/dictionary: ${it.message()}" } + failure { "Failed to decode ingredients as list: ${err1.message()} and as pattern/dictionary: ${it.message()}" } } ).flatMap { val handwritten = it.first @@ -100,12 +102,12 @@ class IngredientMatrixCodec(ingredientCodec: Codec) : Codec { override fun encode(input: UUID, ops: DynamicOps, prefix: T): DataResult { if (ops === NbtOps.INSTANCE) { - return DataResult.success((ops as DynamicOps).createLongList(LongStream.of(input.mostSignificantBits, input.leastSignificantBits))) + return success((ops as DynamicOps).createLongList(LongStream.of(input.mostSignificantBits, input.leastSignificantBits))) } - return DataResult.success(ops.createString(input.toString())) + return success(ops.createString(input.toString())) } override fun decode(ops: DynamicOps, input: T): DataResult> { @@ -25,25 +27,25 @@ object UUIDCodec : Codec { if (l.size == 4) { // 4 int - DataResult.success(Pair(UUID((l[0] shl 32) or l[1], (l[2] shl 32) or l[3]), ops.empty())) + success(Pair(UUID((l[0] shl 32) or l[1], (l[2] shl 32) or l[3]), ops.empty())) } else if (l.size == 2) { - DataResult.success(Pair(UUID(l[0], l[1]), ops.empty())) + success(Pair(UUID(l[0], l[1]), ops.empty())) } else { - DataResult.error { "Can't construct UUID from ${l.size} elements" } + failure { "Can't construct UUID from ${l.size} elements" } } }.get().map( { - DataResult.success(it) + success(it) }, { e0 -> ops.getStringValue(input).map { Pair(UUID.fromString(it), ops.empty()) }.get().map( { - DataResult.success(it) + success(it) }, { - DataResult.error { "Unable to deserialize UUID: ${e0.message()}; ${it.message()}" } + failure { "Unable to deserialize UUID: ${e0.message()}; ${it.message()}" } } ) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt index 50449c5dd..886a961a1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt @@ -11,7 +11,9 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.tags.TagKey import net.minecraft.world.item.Item import net.minecraftforge.registries.ForgeRegistries +import ru.dbotthepony.mc.otm.core.failure import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.core.success import ru.dbotthepony.mc.otm.data.DecimalCodec import ru.dbotthepony.mc.otm.data.PredicatedCodecList import java.util.Optional @@ -103,19 +105,19 @@ class ComputeAction( val pair = this to this override fun encode(input: Constant, ops: DynamicOps, prefix: T): DataResult { - return DataResult.success(ops.createString(symbol + input.matter.toString())) + return success(ops.createString(symbol + input.matter.toString())) } override fun decode(ops: DynamicOps, input: T): DataResult> { return ops.getStringValue(input).flatMap { if (it[0] == symbol) { try { - DataResult.success(Pair(Constant(Decimal(it.substring(1).trim()), it.substring(1).trim().toDouble(), fn, fn), ops.empty())) + success(Pair(Constant(Decimal(it.substring(1).trim()), it.substring(1).trim().toDouble(), fn, fn), ops.empty())) } catch (err: NumberFormatException) { - DataResult.error { "Not a number: ${it.substring(1).trim()} (input string: $it)" } + failure { "Not a number: ${it.substring(1).trim()} (input string: $it)" } } } else { - DataResult.error { "Input string does not match expected operand: expected $symbol, got ${it[0]} (for input $it)" } + failure { "Input string does not match expected operand: expected $symbol, got ${it[0]} (for input $it)" } } } } @@ -127,15 +129,15 @@ class ComputeAction( private object PlainStringConstantCodec : Codec, Predicate { override fun encode(input: Constant, ops: DynamicOps, prefix: T): DataResult { - return DataResult.success(ops.createString(input.matter.toString())) + return success(ops.createString(input.matter.toString())) } override fun decode(ops: DynamicOps, input: T): DataResult> { val result = ops.getNumberValue(input).flatMap { try { - DataResult.success(Pair(Constant(Decimal(it.toString()), it.toDouble(), IMatterFunction.PLUS, IMatterFunction.PLUS), ops.empty())) + success(Pair(Constant(Decimal(it.toString()), it.toDouble(), IMatterFunction.PLUS, IMatterFunction.PLUS), ops.empty())) } catch (err: NumberFormatException) { - DataResult.error { "Not a number: $it" } + failure { "Not a number: $it" } } } @@ -144,9 +146,9 @@ class ComputeAction( return ops.getStringValue(input).flatMap { try { - DataResult.success(Pair(Constant(Decimal(it), it.toDouble(), IMatterFunction.PLUS, IMatterFunction.PLUS), ops.empty())) + success(Pair(Constant(Decimal(it), it.toDouble(), IMatterFunction.PLUS, IMatterFunction.PLUS), ops.empty())) } catch (err: NumberFormatException) { - DataResult.error { "Not a number: $it" } + failure { "Not a number: $it" } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt index d1c9b2370..971cfe407 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt @@ -22,7 +22,9 @@ import net.minecraft.server.PlayerAdvancements import net.minecraft.server.level.ServerPlayer import ru.dbotthepony.mc.otm.core.collect.filter import ru.dbotthepony.mc.otm.core.collect.toImmutableList +import ru.dbotthepony.mc.otm.core.failure import ru.dbotthepony.mc.otm.core.set +import ru.dbotthepony.mc.otm.core.success import ru.dbotthepony.mc.otm.core.toJsonStrict import java.util.Optional import java.util.function.Predicate @@ -85,16 +87,16 @@ abstract class MCriterionTrigger.AbstractInstance>(val @JvmStatic protected val predicateCodec: Codec = object : Codec { override fun encode(input: ContextAwarePredicate, ops: DynamicOps, prefix: T): DataResult { - return DataResult.success(JsonOps.INSTANCE.convertTo(ops, input.toJson())) + return success(JsonOps.INSTANCE.convertTo(ops, input.toJson())) } override fun decode(ops: DynamicOps, input: T): DataResult> { - val context = deserializationContext.get().lastOrNull() ?: return DataResult.error { "Not current deserializing trigger instance" } + val context = deserializationContext.get().lastOrNull() ?: return failure { "Not current deserializing trigger instance" } return try { - DataResult.success(Pair.of(EntityPredicate.fromJson(JsonObject().also { it["a"] = ops.convertTo(JsonOps.INSTANCE, input) }, "a", context).get(), ops.empty())) + success(Pair.of(EntityPredicate.fromJson(JsonObject().also { it["a"] = ops.convertTo(JsonOps.INSTANCE, input) }, "a", context).get(), ops.empty())) } catch (err: Exception) { - DataResult.error { "Failed to deserialize ContextAwarePredicate: " + err.message } + failure { "Failed to deserialize ContextAwarePredicate: " + err.message } } } } From 2cc8215cb0026f484a88d48168cba6d24758aacc Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 17:30:48 +0700 Subject: [PATCH 1188/1199] Revert "Polyfill dataresult" This reverts commit e3df0d82e0d2f4416c05efa0a61680105f216417. --- .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 18 +++---------- .../mc/otm/core/util/StreamCodecs.kt | 6 ++--- .../mc/otm/data/Codec2RecipeSerializer.kt | 6 ++--- .../ru/dbotthepony/mc/otm/data/CodecList.kt | 11 ++++---- .../mc/otm/data/ComparableCodec.kt | 9 +++---- .../dbotthepony/mc/otm/data/ComponentCodec.kt | 6 ++--- .../dbotthepony/mc/otm/data/DecimalCodec.kt | 24 ++++++++--------- .../mc/otm/data/IngredientMatrixCodec.kt | 26 +++++++++---------- .../ru/dbotthepony/mc/otm/data/UUIDCodec.kt | 18 ++++++------- .../mc/otm/matter/ComputeAction.kt | 20 +++++++------- .../mc/otm/triggers/MCriterionTrigger.kt | 10 +++---- 11 files changed, 63 insertions(+), 91 deletions(-) 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 60b55c578..bc23bfbce 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -10,10 +10,10 @@ import com.google.common.collect.ImmutableSet import com.google.gson.JsonElement import com.google.gson.JsonObject import com.google.gson.JsonPrimitive -import com.mojang.serialization.DataResult import it.unimi.dsi.fastutil.objects.ObjectComparators import net.minecraft.core.BlockPos import net.minecraft.nbt.CompoundTag +import net.minecraft.nbt.NbtAccounter import net.minecraft.network.FriendlyByteBuf import net.minecraft.network.chat.ComponentContents import net.minecraft.network.chat.contents.TranslatableContents @@ -26,6 +26,7 @@ import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block +import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateHolder import net.minecraft.world.level.block.state.properties.Property @@ -40,7 +41,9 @@ import net.minecraftforge.registries.IForgeRegistry import ru.dbotthepony.mc.otm.core.math.BlockRotation import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.math.Vector +import ru.dbotthepony.mc.otm.core.util.readInt import ru.dbotthepony.mc.otm.core.util.readVarIntLE +import ru.dbotthepony.mc.otm.core.util.writeInt import ru.dbotthepony.mc.otm.core.util.writeVarIntLE import java.io.InputStream import java.io.OutputStream @@ -464,16 +467,3 @@ fun lazy2(a: () -> A, b: A.() -> B): Supplier { val first = lazy(a) return Supplier { b.invoke(first.value) } } - -// 1.19.3 and earlier polyfill -fun failure(message: String): DataResult { - return DataResult.error { message } -} - -fun failure(message: Supplier): DataResult { - return DataResult.error(message) -} - -fun success(result: R): DataResult { - return DataResult.success(result) -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt index 191ff8fb4..961847d1e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt @@ -8,13 +8,11 @@ import com.mojang.serialization.DynamicOps import net.minecraft.nbt.NbtAccounter import net.minecraft.world.item.ItemStack import net.minecraftforge.fluids.FluidStack -import ru.dbotthepony.mc.otm.core.failure import ru.dbotthepony.mc.otm.core.immutableMap import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.readDecimal import ru.dbotthepony.mc.otm.core.math.writeDecimal import ru.dbotthepony.mc.otm.core.readItemType -import ru.dbotthepony.mc.otm.core.success import ru.dbotthepony.mc.otm.core.writeItemType import java.io.DataInput import java.io.DataInputStream @@ -197,11 +195,11 @@ class EnumValueCodec>(clazz: Class) : IStreamCodec, Codec< override fun decode(ops: DynamicOps, input: T): DataResult> { if (ops.compressMaps()) { return ops.getNumberValue(input) - .flatMap { values.getOrNull(it.toInt())?.let { success(Pair(it, ops.empty())) } ?: failure { "No such enum with ordinal index $it" } } + .flatMap { values.getOrNull(it.toInt())?.let { DataResult.success(Pair(it, ops.empty())) } ?: DataResult.error { "No such enum with ordinal index $it" } } } return ops.getStringValue(input) - .flatMap { valuesMap[it]?.let { success(Pair(it, ops.empty())) } ?: failure { "No such enum value $it" } } + .flatMap { valuesMap[it]?.let { DataResult.success(Pair(it, ops.empty())) } ?: DataResult.error { "No such enum value $it" } } } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt index f09e62ffe..b32702611 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/Codec2RecipeSerializer.kt @@ -19,9 +19,7 @@ import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.item.crafting.Recipe import net.minecraft.world.item.crafting.RecipeSerializer import org.apache.logging.log4j.LogManager -import ru.dbotthepony.mc.otm.core.failure import ru.dbotthepony.mc.otm.core.set -import ru.dbotthepony.mc.otm.core.success import ru.dbotthepony.mc.otm.core.util.readBinaryJsonWithCodecIndirect import ru.dbotthepony.mc.otm.core.util.writeBinaryJsonWithCodec import kotlin.collections.ArrayDeque @@ -71,9 +69,9 @@ class Codec2RecipeSerializer>( val read = serializer.fromNetwork(buff) if (read == null) - failure { "Unable to read parent recipe from network" } + DataResult.error { "Unable to read parent recipe from network" } else - success(Pair(read, ops.empty())) + DataResult.success(Pair(read, ops.empty())) } } else { return serializer.codec().decode(ops, input) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/CodecList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/CodecList.kt index 00b73e8ec..572fa629c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/CodecList.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/CodecList.kt @@ -5,7 +5,6 @@ import com.mojang.datafixers.util.Pair import com.mojang.serialization.Codec import com.mojang.serialization.DataResult import com.mojang.serialization.DynamicOps -import ru.dbotthepony.mc.otm.core.failure import ru.dbotthepony.mc.otm.core.stream import java.util.function.Predicate import java.util.stream.Stream @@ -33,7 +32,7 @@ class CodecList(codecs: Stream>) : Codec { } } - return failure { + return DataResult.error { "None of codecs encoded the input:\n " + results.joinToString(";\n ") { it.error().get().message() } } } @@ -51,7 +50,7 @@ class CodecList(codecs: Stream>) : Codec { } } - return failure { + return DataResult.error { "None of codecs decoded the input:\n " + results.joinToString(";\n ") { it.error().get().message() } } } @@ -84,11 +83,11 @@ class PredicatedCodecList(codecs: Stream, Predicat } } else { val i2 = i - results.add(failure { "Codec #$i2 predicate tested false" }) + results.add(DataResult.error { "Codec #$i2 predicate tested false" }) } } - return failure { + return DataResult.error { "None of codecs encoded the input:\n " + results.joinToString(";\n ") { it.error().get().message() } } } @@ -106,7 +105,7 @@ class PredicatedCodecList(codecs: Stream, Predicat } } - return failure { + return DataResult.error { "None of codecs decoded the input:\n " + results.joinToString(";\n ") { it.error().get().message() } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComparableCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComparableCodec.kt index 40e4e8545..3a49fcf06 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComparableCodec.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComparableCodec.kt @@ -4,18 +4,17 @@ import com.mojang.datafixers.util.Pair import com.mojang.serialization.Codec import com.mojang.serialization.DataResult import com.mojang.serialization.DynamicOps -import ru.dbotthepony.mc.otm.core.failure class ComparableCodec>(val parent: Codec, val min: S? = null, val max: S? = null, val minExclusive: Boolean = false, val maxExclusive: Boolean = false) : Codec { private fun check(input: S): DataResult? { if (min != null) { if (minExclusive) { if (input <= min) { - return failure { "Value $input is smaller or equal to minimal $min" } + return DataResult.error { "Value $input is smaller or equal to minimal $min" } } } else { if (input < min) { - return failure { "Value $input is smaller than minimal $min" } + return DataResult.error { "Value $input is smaller than minimal $min" } } } } @@ -23,11 +22,11 @@ class ComparableCodec>(val parent: Codec, val min: S? = nul if (max != null) { if (maxExclusive) { if (input >= max) { - return failure { "Value $input is bigger or equal to maximal $max" } + return DataResult.error { "Value $input is bigger or equal to maximal $max" } } } else { if (input > max) { - return failure { "Value $input is bigger than maximal $max" } + return DataResult.error { "Value $input is bigger than maximal $max" } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComponentCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComponentCodec.kt index 2a007ea95..ec65bb31a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComponentCodec.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComponentCodec.kt @@ -7,8 +7,6 @@ import com.mojang.serialization.DataResult import com.mojang.serialization.DynamicOps import com.mojang.serialization.JsonOps import net.minecraft.network.chat.Component -import ru.dbotthepony.mc.otm.core.failure -import ru.dbotthepony.mc.otm.core.success object ComponentCodec : Codec { override fun encode(input: Component, ops: DynamicOps, prefix: T): DataResult { @@ -19,9 +17,9 @@ object ComponentCodec : Codec { val value = ops.convertTo(JsonOps.INSTANCE, input) try { - return success(Pair(Component.Serializer.fromJson(value), ops.empty())) + return DataResult.success(Pair(Component.Serializer.fromJson(value), ops.empty())) } catch (err: JsonSyntaxException) { - return failure { "Error decoding component: ${err.message}" } + return DataResult.error { "Error decoding component: ${err.message}" } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt index 7ec7322cd..062564586 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt @@ -6,9 +6,7 @@ import com.mojang.serialization.DataResult import com.mojang.serialization.DynamicOps import it.unimi.dsi.fastutil.bytes.ByteArrayList import net.minecraft.nbt.NbtOps -import ru.dbotthepony.mc.otm.core.failure import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.success import java.nio.ByteBuffer import java.util.stream.Collector import java.util.stream.Stream @@ -16,47 +14,47 @@ import java.util.stream.Stream object DecimalCodec : Codec { override fun encode(input: Decimal, ops: DynamicOps, prefix: T): DataResult { if (ops === NbtOps.INSTANCE) { - return success((ops as DynamicOps).createByteList(ByteBuffer.wrap(input.toByteArray()))) + return DataResult.success((ops as DynamicOps).createByteList(ByteBuffer.wrap(input.toByteArray()))) } - return success(ops.createString(input.toString())) + return DataResult.success(ops.createString(input.toString())) } override fun decode(ops: DynamicOps, input: T): DataResult> { return ops.getStringValue(input).flatMap { try { - success(Pair(Decimal(it), ops.empty())) + DataResult.success(Pair(Decimal(it), ops.empty())) } catch (err: NumberFormatException) { - failure { "Not a valid number for converting into Decimal: $it" } + DataResult.error { "Not a valid number for converting into Decimal: $it" } } }.get().map( { - success(it) + DataResult.success(it) }, { e0 -> ops.getIntStream(input).flatMap { try { - success(Pair(Decimal.fromByteArray( + DataResult.success(Pair(Decimal.fromByteArray( it .collect(::ByteArrayList, { v, a -> v.add(a.toByte()) }, ByteArrayList::addAll) .toByteArray() ), ops.empty())) } catch (err: NumberFormatException) { - failure { "Failed to convert array of bytes into Decimal: $it" } + DataResult.error { "Failed to convert array of bytes into Decimal: $it" } } }.get().map( { - success(it) + DataResult.success(it) }, { e1 -> ops.getNumberValue(input).flatMap { - success(Pair(Decimal(it.toString()), ops.empty())) + DataResult.success(Pair(Decimal(it.toString()), ops.empty())) }.get().map( { - success(it) + DataResult.success(it) }, { e2 -> - failure { "None of attempts at decoding Decimal were successful: ${e0.message()}; ${e1.message()}; ${e2.message()}" } + DataResult.error { "None of attempts at decoding Decimal were successful: ${e0.message()}; ${e1.message()}; ${e2.message()}" } } ) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientMatrixCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientMatrixCodec.kt index 731ae577b..12d7117cd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientMatrixCodec.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientMatrixCodec.kt @@ -11,9 +11,7 @@ import ru.dbotthepony.mc.otm.core.collect.allEqual import ru.dbotthepony.mc.otm.core.collect.map import ru.dbotthepony.mc.otm.core.collect.toList import ru.dbotthepony.mc.otm.core.collect.toStream -import ru.dbotthepony.mc.otm.core.failure import ru.dbotthepony.mc.otm.core.stream -import ru.dbotthepony.mc.otm.core.success import ru.dbotthepony.mc.otm.recipe.IIngredientMatrix import ru.dbotthepony.mc.otm.recipe.IngredientMatrix import java.util.function.Supplier @@ -40,15 +38,15 @@ class IngredientMatrixCodec(ingredientCodec: Codec) : Codec) : Codec) : Codec handwrittenCodec.decode(ops, input).get().map( { - success(it) + DataResult.success(it) }, { - failure { "Failed to decode ingredients as list: ${err1.message()} and as pattern/dictionary: ${it.message()}" } + DataResult.error { "Failed to decode ingredients as list: ${err1.message()} and as pattern/dictionary: ${it.message()}" } } ).flatMap { val handwritten = it.first @@ -102,12 +100,12 @@ class IngredientMatrixCodec(ingredientCodec: Codec) : Codec { override fun encode(input: UUID, ops: DynamicOps, prefix: T): DataResult { if (ops === NbtOps.INSTANCE) { - return success((ops as DynamicOps).createLongList(LongStream.of(input.mostSignificantBits, input.leastSignificantBits))) + return DataResult.success((ops as DynamicOps).createLongList(LongStream.of(input.mostSignificantBits, input.leastSignificantBits))) } - return success(ops.createString(input.toString())) + return DataResult.success(ops.createString(input.toString())) } override fun decode(ops: DynamicOps, input: T): DataResult> { @@ -27,25 +25,25 @@ object UUIDCodec : Codec { if (l.size == 4) { // 4 int - success(Pair(UUID((l[0] shl 32) or l[1], (l[2] shl 32) or l[3]), ops.empty())) + DataResult.success(Pair(UUID((l[0] shl 32) or l[1], (l[2] shl 32) or l[3]), ops.empty())) } else if (l.size == 2) { - success(Pair(UUID(l[0], l[1]), ops.empty())) + DataResult.success(Pair(UUID(l[0], l[1]), ops.empty())) } else { - failure { "Can't construct UUID from ${l.size} elements" } + DataResult.error { "Can't construct UUID from ${l.size} elements" } } }.get().map( { - success(it) + DataResult.success(it) }, { e0 -> ops.getStringValue(input).map { Pair(UUID.fromString(it), ops.empty()) }.get().map( { - success(it) + DataResult.success(it) }, { - failure { "Unable to deserialize UUID: ${e0.message()}; ${it.message()}" } + DataResult.error { "Unable to deserialize UUID: ${e0.message()}; ${it.message()}" } } ) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt index 886a961a1..50449c5dd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt @@ -11,9 +11,7 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.tags.TagKey import net.minecraft.world.item.Item import net.minecraftforge.registries.ForgeRegistries -import ru.dbotthepony.mc.otm.core.failure import ru.dbotthepony.mc.otm.core.math.Decimal -import ru.dbotthepony.mc.otm.core.success import ru.dbotthepony.mc.otm.data.DecimalCodec import ru.dbotthepony.mc.otm.data.PredicatedCodecList import java.util.Optional @@ -105,19 +103,19 @@ class ComputeAction( val pair = this to this override fun encode(input: Constant, ops: DynamicOps, prefix: T): DataResult { - return success(ops.createString(symbol + input.matter.toString())) + return DataResult.success(ops.createString(symbol + input.matter.toString())) } override fun decode(ops: DynamicOps, input: T): DataResult> { return ops.getStringValue(input).flatMap { if (it[0] == symbol) { try { - success(Pair(Constant(Decimal(it.substring(1).trim()), it.substring(1).trim().toDouble(), fn, fn), ops.empty())) + DataResult.success(Pair(Constant(Decimal(it.substring(1).trim()), it.substring(1).trim().toDouble(), fn, fn), ops.empty())) } catch (err: NumberFormatException) { - failure { "Not a number: ${it.substring(1).trim()} (input string: $it)" } + DataResult.error { "Not a number: ${it.substring(1).trim()} (input string: $it)" } } } else { - failure { "Input string does not match expected operand: expected $symbol, got ${it[0]} (for input $it)" } + DataResult.error { "Input string does not match expected operand: expected $symbol, got ${it[0]} (for input $it)" } } } } @@ -129,15 +127,15 @@ class ComputeAction( private object PlainStringConstantCodec : Codec, Predicate { override fun encode(input: Constant, ops: DynamicOps, prefix: T): DataResult { - return success(ops.createString(input.matter.toString())) + return DataResult.success(ops.createString(input.matter.toString())) } override fun decode(ops: DynamicOps, input: T): DataResult> { val result = ops.getNumberValue(input).flatMap { try { - success(Pair(Constant(Decimal(it.toString()), it.toDouble(), IMatterFunction.PLUS, IMatterFunction.PLUS), ops.empty())) + DataResult.success(Pair(Constant(Decimal(it.toString()), it.toDouble(), IMatterFunction.PLUS, IMatterFunction.PLUS), ops.empty())) } catch (err: NumberFormatException) { - failure { "Not a number: $it" } + DataResult.error { "Not a number: $it" } } } @@ -146,9 +144,9 @@ class ComputeAction( return ops.getStringValue(input).flatMap { try { - success(Pair(Constant(Decimal(it), it.toDouble(), IMatterFunction.PLUS, IMatterFunction.PLUS), ops.empty())) + DataResult.success(Pair(Constant(Decimal(it), it.toDouble(), IMatterFunction.PLUS, IMatterFunction.PLUS), ops.empty())) } catch (err: NumberFormatException) { - failure { "Not a number: $it" } + DataResult.error { "Not a number: $it" } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt index 971cfe407..d1c9b2370 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt @@ -22,9 +22,7 @@ import net.minecraft.server.PlayerAdvancements import net.minecraft.server.level.ServerPlayer import ru.dbotthepony.mc.otm.core.collect.filter import ru.dbotthepony.mc.otm.core.collect.toImmutableList -import ru.dbotthepony.mc.otm.core.failure import ru.dbotthepony.mc.otm.core.set -import ru.dbotthepony.mc.otm.core.success import ru.dbotthepony.mc.otm.core.toJsonStrict import java.util.Optional import java.util.function.Predicate @@ -87,16 +85,16 @@ abstract class MCriterionTrigger.AbstractInstance>(val @JvmStatic protected val predicateCodec: Codec = object : Codec { override fun encode(input: ContextAwarePredicate, ops: DynamicOps, prefix: T): DataResult { - return success(JsonOps.INSTANCE.convertTo(ops, input.toJson())) + return DataResult.success(JsonOps.INSTANCE.convertTo(ops, input.toJson())) } override fun decode(ops: DynamicOps, input: T): DataResult> { - val context = deserializationContext.get().lastOrNull() ?: return failure { "Not current deserializing trigger instance" } + val context = deserializationContext.get().lastOrNull() ?: return DataResult.error { "Not current deserializing trigger instance" } return try { - success(Pair.of(EntityPredicate.fromJson(JsonObject().also { it["a"] = ops.convertTo(JsonOps.INSTANCE, input) }, "a", context).get(), ops.empty())) + DataResult.success(Pair.of(EntityPredicate.fromJson(JsonObject().also { it["a"] = ops.convertTo(JsonOps.INSTANCE, input) }, "a", context).get(), ops.empty())) } catch (err: Exception) { - failure { "Failed to deserialize ContextAwarePredicate: " + err.message } + DataResult.error { "Failed to deserialize ContextAwarePredicate: " + err.message } } } } From df15bd2f6909b0d77cfc2cb8da41b4f64f6eb13f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 17:55:27 +0700 Subject: [PATCH 1189/1199] More backporting --- .../android/feature/ExtendedReachFeature.kt | 8 ++++---- .../otm/android/feature/ItemMagnetFeature.kt | 4 ++-- .../block/decorative/TritaniumPressurePlate.kt | 3 --- .../otm/client/screen/panels/Panel2Widget.kt | 6 +----- .../mc/otm/compat/vanilla/MatteryChestMenu.kt | 16 ++++++++-------- .../otm/container/MatteryCraftingContainer.kt | 4 ---- .../mc/otm/core/UnOverengineering.kt | 17 ----------------- .../dbotthepony/mc/otm/core/util/ItemSorter.kt | 2 +- .../mc/otm/core/util/StreamCodecs.kt | 4 ++-- .../ru/dbotthepony/mc/otm/data/CodecList.kt | 18 +++++++++--------- .../dbotthepony/mc/otm/data/ComparableCodec.kt | 8 ++++---- .../dbotthepony/mc/otm/data/ComponentCodec.kt | 2 +- .../ru/dbotthepony/mc/otm/data/DecimalCodec.kt | 6 +++--- .../dbotthepony/mc/otm/data/IngredientCodec.kt | 2 +- .../mc/otm/data/IngredientMatrixCodec.kt | 14 +++++++------- .../mc/otm/data/ItemPredicateCodec.kt | 4 ++-- .../ru/dbotthepony/mc/otm/data/UUIDCodec.kt | 4 ++-- .../mc/otm/data/loot/LootPoolAppender.kt | 4 ++-- .../mc/otm/item/EssenceCapsuleItem.kt | 2 +- .../otm/item/PortableCondensationDriveItem.kt | 2 +- .../armor/PortableGravitationStabilizerItem.kt | 6 +++--- 21 files changed, 54 insertions(+), 82 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ExtendedReachFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ExtendedReachFeature.kt index 270e08963..7a7b62b84 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ExtendedReachFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ExtendedReachFeature.kt @@ -9,20 +9,20 @@ import java.util.* class ExtendedReachFeature(android: MatteryPlayerCapability) : AndroidFeature(AndroidFeatures.EXTENDED_REACH, android) { override fun applyModifiers() { - if (!ForgeMod.BLOCK_REACH.isPresent) + if (!ForgeMod.REACH_DISTANCE.isPresent) return - val reach = ply.getAttribute(ForgeMod.BLOCK_REACH.get()) ?: return + val reach = ply.getAttribute(ForgeMod.REACH_DISTANCE.get()) ?: return reach.removePermanentModifier(MODIFIER_ID) reach.addPermanentModifier(AttributeModifier(MODIFIER_ID, type.displayName.toString(), level + 1.0, AttributeModifier.Operation.ADDITION)) } override fun removeModifiers() { - if (!ForgeMod.BLOCK_REACH.isPresent) + if (!ForgeMod.REACH_DISTANCE.isPresent) return - ply.getAttribute(ForgeMod.BLOCK_REACH.get())?.removePermanentModifier(MODIFIER_ID) + ply.getAttribute(ForgeMod.REACH_DISTANCE.get())?.removePermanentModifier(MODIFIER_ID) } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt index 7b6e93493..ad4d00cc5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ItemMagnetFeature.kt @@ -61,7 +61,7 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable private data class ItemPos(var position: Vector, var ticksSinceActivity: Int) private val rememberPositions = WeakHashMap() - private val serverPredicate = Predicate { it is ItemEntity && !it.hasPickUpDelay() && (it.owner == null || it.owner != ply || it.lifespan - it.age <= 200) } + private val serverPredicate = Predicate { it is ItemEntity && !it.hasPickUpDelay() && (it.owner == null || it.owner != ply.uuid || it.lifespan - it.age <= 200) } private val clientPredicate = Predicate { it is ItemEntity && (datatable[it] ?: SharedItemEntityData.EMPTY).let { !it.hasPickupDelay && (it.owner == null || it.owner != ply.uuid || it.lifespan - it.age <= 200) } } private fun doTick(server: Boolean) { @@ -79,7 +79,7 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable ent as ItemEntity if (server) { - GenericNetworkChannel.send(ply, ItemEntityDataPacket(ent.id, ent.owner?.uuid, ent.age, ent.lifespan, ent.hasPickUpDelay())) + GenericNetworkChannel.send(ply, ItemEntityDataPacket(ent.id, ent.owner, ent.age, ent.lifespan, ent.hasPickUpDelay())) if (!serverPredicate.test(ent)) { continue diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt index 1a37c06e3..75fbde496 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt @@ -11,16 +11,13 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level -import net.minecraft.world.level.LevelAccessor import net.minecraft.world.level.block.BasePressurePlateBlock import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.SoundType import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition -import net.minecraft.world.level.block.state.properties.BlockSetType import net.minecraft.world.level.block.state.properties.BlockStateProperties import net.minecraft.world.level.material.Material -import net.minecraft.world.level.material.PushReaction import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.get 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 c286191cc..6cff8a82f 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 @@ -70,12 +70,8 @@ class Panel2Widget>( return panel.isMouseOver(p_94748_, p_94749_) } - override fun setFocused(p_265728_: Boolean) { + override fun changeFocus(p_265728_: Boolean): Boolean { // no op - } - - override fun isFocused(): Boolean { - // ага, щас return false } } 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 6ed91b59f..c726ff6d3 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 @@ -44,14 +44,14 @@ class MatteryChestMenu( companion object { private val registrar = DeferredRegister.create(Registries.MENU, OverdriveThatMatters.MOD_ID) - private val GENERIC_9x1 by registrar.register("generic_9x1") { MenuType(::c9x1, FeatureFlags.VANILLA_SET) } - private val GENERIC_9x2 by registrar.register("generic_9x2") { MenuType(::c9x2, FeatureFlags.VANILLA_SET) } - private val GENERIC_9x3 by registrar.register("generic_9x3") { MenuType(::c9x3, FeatureFlags.VANILLA_SET) } - private val GENERIC_9x4 by registrar.register("generic_9x4") { MenuType(::c9x4, FeatureFlags.VANILLA_SET) } - private val GENERIC_9x5 by registrar.register("generic_9x5") { MenuType(::c9x5, FeatureFlags.VANILLA_SET) } - private val GENERIC_9x6 by registrar.register("generic_9x6") { MenuType(::c9x6, FeatureFlags.VANILLA_SET) } - private val GENERIC_3x3 by registrar.register("generic_3x3") { MenuType(::c3x3, FeatureFlags.VANILLA_SET) } - private val HOPPER by registrar.register("hopper") { MenuType(::hopper, FeatureFlags.VANILLA_SET) } + private val GENERIC_9x1 by registrar.register("generic_9x1") { MenuType(::c9x1) } + private val GENERIC_9x2 by registrar.register("generic_9x2") { MenuType(::c9x2) } + private val GENERIC_9x3 by registrar.register("generic_9x3") { MenuType(::c9x3) } + private val GENERIC_9x4 by registrar.register("generic_9x4") { MenuType(::c9x4) } + private val GENERIC_9x5 by registrar.register("generic_9x5") { MenuType(::c9x5) } + private val GENERIC_9x6 by registrar.register("generic_9x6") { MenuType(::c9x6) } + private val GENERIC_3x3 by registrar.register("generic_3x3") { MenuType(::c3x3) } + private val HOPPER by registrar.register("hopper") { MenuType(::hopper) } @JvmStatic @JvmOverloads diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryCraftingContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryCraftingContainer.kt index 1639388a5..27baab0d0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryCraftingContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/MatteryCraftingContainer.kt @@ -100,10 +100,6 @@ open class MatteryCraftingContainer private constructor(private val listener: Ma return parent.canPlaceItem(p_18952_, p_18953_) } - override fun canTakeItem(p_273520_: Container, p_272681_: Int, p_273702_: ItemStack): Boolean { - return parent.canTakeItem(p_273520_, p_272681_, p_273702_) - } - override fun countItem(p_18948_: Item): Int { return parent.countItem(p_18948_) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt index 3cc18df17..2fbe1ff64 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt @@ -4,21 +4,14 @@ import com.google.gson.JsonElement import com.google.gson.JsonSyntaxException import com.mojang.serialization.Codec import com.mojang.serialization.JsonOps -import net.minecraft.core.Holder -import net.minecraft.core.RegistryAccess -import net.minecraft.core.registries.Registries import net.minecraft.nbt.NbtOps import net.minecraft.nbt.Tag import net.minecraft.network.FriendlyByteBuf import net.minecraft.network.chat.MutableComponent import net.minecraft.network.chat.contents.LiteralContents import net.minecraft.network.chat.contents.TranslatableContents -import net.minecraft.resources.ResourceKey import net.minecraft.resources.ResourceLocation import net.minecraft.sounds.SoundEvent -import net.minecraft.tags.DamageTypeTags -import net.minecraft.world.damagesource.DamageSource -import net.minecraft.world.damagesource.DamageType import net.minecraft.world.item.Item import net.minecraft.world.level.block.Block import net.minecraft.world.level.material.Fluid @@ -90,13 +83,3 @@ fun FriendlyByteBuf.writeRegistryId(value: Item) = writeRegistryId(ForgeRegistri // 1.19.3 lol inline val SoundEvent.holder get() = ForgeRegistries.SOUND_EVENTS.getHolder(this).orElse(null) ?: throw NoSuchElementException("$this is missing from ${ForgeRegistries.SOUND_EVENTS}") - -// 1.19.4 :thonkang: -inline val DamageSource.isFall get() = `is`(DamageTypeTags.IS_FALL) -inline val DamageSource.isBypassArmor get() = `is`(DamageTypeTags.BYPASSES_ARMOR) -inline val DamageSource.isExplosion get() = `is`(DamageTypeTags.IS_EXPLOSION) -inline val DamageSource.isFire get() = `is`(DamageTypeTags.IS_FIRE) - -fun RegistryAccess.damageType(key: ResourceKey): Holder { - return registryOrThrow(Registries.DAMAGE_TYPE).getHolderOrThrow(key) -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt index 7e11694ea..0b4a15aff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/ItemSorter.kt @@ -56,7 +56,7 @@ object CreativeMenuItemComparator : Comparator { if (item2index.isEmpty()) { val player = minecraft.player ?: return // creative tabs were not populated yet - CreativeModeTabs.tryRebuildTabContents(player.connection.enabledFeatures(), false /* operator tabs */, player.level.registryAccess()) + CreativeModeTabs.tryRebuildTabContents(player.connection.enabledFeatures(), false /* operator tabs */) doRebuild() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt index 961847d1e..81968cf67 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/StreamCodecs.kt @@ -195,11 +195,11 @@ class EnumValueCodec>(clazz: Class) : IStreamCodec, Codec< override fun decode(ops: DynamicOps, input: T): DataResult> { if (ops.compressMaps()) { return ops.getNumberValue(input) - .flatMap { values.getOrNull(it.toInt())?.let { DataResult.success(Pair(it, ops.empty())) } ?: DataResult.error { "No such enum with ordinal index $it" } } + .flatMap { values.getOrNull(it.toInt())?.let { DataResult.success(Pair(it, ops.empty())) } ?: DataResult.error("No such enum with ordinal index $it") } } return ops.getStringValue(input) - .flatMap { valuesMap[it]?.let { DataResult.success(Pair(it, ops.empty())) } ?: DataResult.error { "No such enum value $it" } } + .flatMap { valuesMap[it]?.let { DataResult.success(Pair(it, ops.empty())) } ?: DataResult.error("No such enum value $it") } } companion object { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/CodecList.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/CodecList.kt index 572fa629c..1636d73a3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/CodecList.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/CodecList.kt @@ -32,9 +32,9 @@ class CodecList(codecs: Stream>) : Codec { } } - return DataResult.error { + return DataResult.error ( "None of codecs encoded the input:\n " + results.joinToString(";\n ") { it.error().get().message() } - } + ) } override fun decode(ops: DynamicOps, input: T): DataResult> { @@ -50,9 +50,9 @@ class CodecList(codecs: Stream>) : Codec { } } - return DataResult.error { + return DataResult.error ( "None of codecs decoded the input:\n " + results.joinToString(";\n ") { it.error().get().message() } - } + ) } } @@ -83,13 +83,13 @@ class PredicatedCodecList(codecs: Stream, Predicat } } else { val i2 = i - results.add(DataResult.error { "Codec #$i2 predicate tested false" }) + results.add(DataResult.error("Codec #$i2 predicate tested false")) } } - return DataResult.error { + return DataResult.error ( "None of codecs encoded the input:\n " + results.joinToString(";\n ") { it.error().get().message() } - } + ) } override fun decode(ops: DynamicOps, input: T): DataResult> { @@ -105,8 +105,8 @@ class PredicatedCodecList(codecs: Stream, Predicat } } - return DataResult.error { + return DataResult.error ( "None of codecs decoded the input:\n " + results.joinToString(";\n ") { it.error().get().message() } - } + ) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComparableCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComparableCodec.kt index 3a49fcf06..83c457723 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComparableCodec.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComparableCodec.kt @@ -10,11 +10,11 @@ class ComparableCodec>(val parent: Codec, val min: S? = nul if (min != null) { if (minExclusive) { if (input <= min) { - return DataResult.error { "Value $input is smaller or equal to minimal $min" } + return DataResult.error("Value $input is smaller or equal to minimal $min") } } else { if (input < min) { - return DataResult.error { "Value $input is smaller than minimal $min" } + return DataResult.error("Value $input is smaller than minimal $min") } } } @@ -22,11 +22,11 @@ class ComparableCodec>(val parent: Codec, val min: S? = nul if (max != null) { if (maxExclusive) { if (input >= max) { - return DataResult.error { "Value $input is bigger or equal to maximal $max" } + return DataResult.error("Value $input is bigger or equal to maximal $max") } } else { if (input > max) { - return DataResult.error { "Value $input is bigger than maximal $max" } + return DataResult.error("Value $input is bigger than maximal $max") } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComponentCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComponentCodec.kt index ec65bb31a..82ff139e2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComponentCodec.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/ComponentCodec.kt @@ -19,7 +19,7 @@ object ComponentCodec : Codec { try { return DataResult.success(Pair(Component.Serializer.fromJson(value), ops.empty())) } catch (err: JsonSyntaxException) { - return DataResult.error { "Error decoding component: ${err.message}" } + return DataResult.error("Error decoding component: ${err.message}") } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt index 062564586..445fb51eb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/DecimalCodec.kt @@ -25,7 +25,7 @@ object DecimalCodec : Codec { try { DataResult.success(Pair(Decimal(it), ops.empty())) } catch (err: NumberFormatException) { - DataResult.error { "Not a valid number for converting into Decimal: $it" } + DataResult.error("Not a valid number for converting into Decimal: $it") } }.get().map( { @@ -40,7 +40,7 @@ object DecimalCodec : Codec { .toByteArray() ), ops.empty())) } catch (err: NumberFormatException) { - DataResult.error { "Failed to convert array of bytes into Decimal: $it" } + DataResult.error("Failed to convert array of bytes into Decimal: $it") } }.get().map( { @@ -54,7 +54,7 @@ object DecimalCodec : Codec { DataResult.success(it) }, { e2 -> - DataResult.error { "None of attempts at decoding Decimal were successful: ${e0.message()}; ${e1.message()}; ${e2.message()}" } + DataResult.error("None of attempts at decoding Decimal were successful: ${e0.message()}; ${e1.message()}; ${e2.message()}") } ) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientCodec.kt index 27c18ade8..aa6b50077 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientCodec.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientCodec.kt @@ -17,7 +17,7 @@ object IngredientCodec : Codec { try { return DataResult.success(Pair(Ingredient.fromJson(ops.convertTo(JsonOps.INSTANCE, input)), ops.empty())) } catch (err: JsonSyntaxException) { - return DataResult.error { "Error decoding Ingredient: ${err.message}" } + return DataResult.error("Error decoding Ingredient: ${err.message}") } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientMatrixCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientMatrixCodec.kt index 12d7117cd..d13d41320 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientMatrixCodec.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/IngredientMatrixCodec.kt @@ -39,13 +39,13 @@ class IngredientMatrixCodec(ingredientCodec: Codec) : Codec) : Codec) : Codec) : Codec { return try { DataResult.success(Pair(ItemPredicate.fromJson(ops.convertTo(JsonOps.INSTANCE, input)), ops.empty())) } catch (err: JsonSyntaxException) { - DataResult.error { "Failed to deserialize ItemPredicate: ${err.message}" } + DataResult.error("Failed to deserialize ItemPredicate: ${err.message}") } catch (err: JsonParseException) { - DataResult.error { "Failed to deserialize ItemPredicate: ${err.message}" } + DataResult.error("Failed to deserialize ItemPredicate: ${err.message}") } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/UUIDCodec.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/UUIDCodec.kt index a6fead1fb..9334b20d4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/UUIDCodec.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/UUIDCodec.kt @@ -29,7 +29,7 @@ object UUIDCodec : Codec { } else if (l.size == 2) { DataResult.success(Pair(UUID(l[0], l[1]), ops.empty())) } else { - DataResult.error { "Can't construct UUID from ${l.size} elements" } + DataResult.error("Can't construct UUID from ${l.size} elements") } }.get().map( { @@ -43,7 +43,7 @@ object UUIDCodec : Codec { DataResult.success(it) }, { - DataResult.error { "Unable to deserialize UUID: ${e0.message()}; ${it.message()}" } + DataResult.error("Unable to deserialize UUID: ${e0.message()}; ${it.message()}") } ) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt index 4154609d1..0f0224793 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/data/loot/LootPoolAppender.kt @@ -67,7 +67,7 @@ class LootPoolAppender(conditions: Array, pools: Stream, pools: Stream) { super.initializeClient(consumer) consumer.accept(GravitationStabilizerArmorRenderProperties) From 2a117a540e3d528e265f7f52eb97b667d2d391e9 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 21:07:43 +0700 Subject: [PATCH 1190/1199] More backporting --- .../android/feature/EnderTeleporterFeature.kt | 1 - .../android/feature/FallDampenersFeature.kt | 8 --- .../android/feature/NanobotsArmorFeature.kt | 3 - .../otm/android/feature/ShockwaveFeature.kt | 1 - .../matter/MatterEntanglerBlockEntity.kt | 2 +- .../entity/storage/ItemMonitorBlockEntity.kt | 8 +-- .../entity/tech/PlatePressBlockEntity.kt | 2 +- .../entity/tech/PoweredFurnaceBlockEntity.kt | 2 +- .../energy/BatteryBackedEnergyStorage.kt | 20 +++++- .../mc/otm/client/render/FontRenderer.kt | 10 +-- .../mc/otm/client/render/MGUIGraphics.kt | 6 +- .../MatterReconstructorRenderer.kt | 4 +- .../blockentity/MatterReplicatorRenderer.kt | 3 +- .../blockentity/MatterScannerRenderer.kt | 5 +- .../mc/otm/client/screen/MatteryScreen.kt | 41 +++++++---- .../otm/client/screen/panels/EditablePanel.kt | 22 +----- .../screen/panels/EntityRendererPanel.kt | 9 ++- .../item/armor/SimpleTritaniumArmorItem.kt | 22 +++--- .../mc/otm/item/armor/TritaniumArmorItem.kt | 28 ++++---- .../exopack/AbstractExopackSlotUpgradeItem.kt | 2 - .../mc/otm/item/weapon/AbstractWeaponItem.kt | 4 +- .../mc/otm/matter/ComputeAction.kt | 8 +-- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 16 +---- .../mc/otm/menu/decorative/PainterMenu.kt | 2 +- .../recipe/ExplosiveHammerPrimingRecipe.kt | 4 +- .../mc/otm/recipe/MatterEntanglerRecipe.kt | 12 ++-- .../mc/otm/recipe/UpgradeRecipe.kt | 12 ++-- .../mc/otm/registry/MCreativeTabs.kt | 4 +- .../mc/otm/registry/MDamageTypes.kt | 32 ++++----- .../ru/dbotthepony/mc/otm/registry/MItems.kt | 17 ++--- .../ru/dbotthepony/mc/otm/registry/MMenus.kt | 68 +++++++++---------- .../dbotthepony/mc/otm/registry/MRegistry.kt | 12 +--- .../mc/otm/triggers/MCriterionTrigger.kt | 6 +- .../resources/META-INF/accesstransformer.cfg | 2 +- 34 files changed, 183 insertions(+), 215 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt index 624247c79..6fb7cd0b6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/EnderTeleporterFeature.kt @@ -37,7 +37,6 @@ import ru.dbotthepony.mc.otm.client.render.sprites.sprite import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.core.genericPositions import ru.dbotthepony.mc.otm.core.holder -import ru.dbotthepony.mc.otm.core.isFall import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.math.asVector diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt index 4b1b75900..ea63587bb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/FallDampenersFeature.kt @@ -1,20 +1,12 @@ package ru.dbotthepony.mc.otm.android.feature -import net.minecraft.ChatFormatting -import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import net.minecraftforge.event.entity.living.LivingAttackEvent import net.minecraftforge.event.entity.living.LivingHurtEvent -import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.android.AndroidFeature -import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.config.AndroidConfig -import ru.dbotthepony.mc.otm.core.TextComponent -import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.core.isFall import ru.dbotthepony.mc.otm.registry.AndroidFeatures -import ru.dbotthepony.mc.otm.registry.MNames import ru.dbotthepony.mc.otm.triggers.FallDampenersSaveTrigger class FallDampenersFeature(capability: MatteryPlayerCapability) : AndroidFeature(AndroidFeatures.FALL_DAMPENERS, capability) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt index 8dc1f81db..66a16c3ce 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/NanobotsArmorFeature.kt @@ -4,12 +4,9 @@ import net.minecraft.nbt.CompoundTag import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import net.minecraftforge.event.entity.living.LivingHurtEvent -import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.android.AndroidFeature -import ru.dbotthepony.mc.otm.android.AndroidResearchManager import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact -import ru.dbotthepony.mc.otm.core.isBypassArmor import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.registry.AndroidFeatures import ru.dbotthepony.mc.otm.registry.StatNames diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt index 26979d8e9..a95c85975 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt @@ -14,7 +14,6 @@ import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.ResearchIcons import ru.dbotthepony.mc.otm.config.AndroidConfig -import ru.dbotthepony.mc.otm.core.damageType import ru.dbotthepony.mc.otm.core.getEntitiesInEllipsoid import ru.dbotthepony.mc.otm.core.getExplosionResistance import ru.dbotthepony.mc.otm.core.math.RGBAColor diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterEntanglerBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterEntanglerBlockEntity.kt index 18b389486..59130c1e3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterEntanglerBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterEntanglerBlockEntity.kt @@ -151,7 +151,7 @@ class MatterEntanglerBlockEntity(blockPos: BlockPos, blockState: BlockState) : M .values .firstOrNull { it.value.matches(inputs, level!!) } ?: return JobContainer.noItem() - val result = recipe.value.assemble(inputs, level!!.registryAccess()) + val result = recipe.value.assemble(inputs) inputs.forEach { it.shrink(1) } inputs.setChanged() 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 d42d9f0fe..062e42e86 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 @@ -292,7 +292,7 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte override fun getItem(slot: Int): ItemStack { require(slot == 0) { "Invalid slot: $slot" } - return craftingRecipe?.getResultItem(level?.registryAccess() ?: return ItemStack.EMPTY)?.copy() ?: ItemStack.EMPTY + return craftingRecipe?.resultItem?.copy() ?: ItemStack.EMPTY } override fun removeItem(index: Int, amount: Int): ItemStack { @@ -305,7 +305,7 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte try { ForgeHooks.setCraftingPlayer(craftingPlayer) - if (craftingRecipe.getResultItem(level.registryAccess()).count != amount) { + if (craftingRecipe.resultItem.count != amount) { return ItemStack.EMPTY } } finally { @@ -331,7 +331,7 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte try { residue = craftingRecipe.getRemainingItems(craftingGrid) - result = craftingRecipe.getResultItem(level.registryAccess()) + result = craftingRecipe.resultItem } finally { ForgeHooks.setCraftingPlayer(null) } @@ -398,7 +398,7 @@ class ItemMonitorBlockEntity(blockPos: BlockPos, blockState: BlockState) : Matte } override fun setItem(p_18944_: Int, p_18945_: ItemStack) { - if ((craftingRecipe != null && !craftingRecipe!!.let { it.getResultItem(level?.registryAccess() ?: return@let ItemStack.EMPTY) }.isEmpty) || !p_18945_.isEmpty) { + if ((craftingRecipe != null && !craftingRecipe!!.resultItem.isEmpty) || !p_18945_.isEmpty) { throw RuntimeException("BUG-DETECT: Tried to set crafting result slot item to something, and either we have crafting recipe which have valid result, or we are trying to set slot to non empty item: $p_18945_") } } 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 2789cdf25..2ba1f2a45 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 @@ -93,7 +93,7 @@ class PlatePressBlockEntity( return JobContainer.success( ItemJob( - recipe.getResultItem(level.registryAccess()).copyWithCount(toProcess), + recipe.getResultItem().copyWithCount(toProcess), recipe.workTime * MachinesConfig.PLATE_PRESS.workTimeMultiplier, MachinesConfig.PLATE_PRESS.energyConsumption * toProcess, experience = recipe.experience.sample(level.random) * toProcess)) 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 f9975f87d..f24900862 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 @@ -136,7 +136,7 @@ class PoweredFurnaceBlockEntity( } return level.recipeManager.getRecipeFor(recipeType as RecipeType, inputs[id], level).map { - val output = it.value.assemble(inputs[id], level.registryAccess()) + val output = it.value.assemble(inputs[id]) val toProcess = inputs[id][0].count.coerceAtMost(upgrades.processingItems + 1) inputs[id][0].shrink(toProcess) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BatteryBackedEnergyStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BatteryBackedEnergyStorage.kt index a39770a12..38281241a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BatteryBackedEnergyStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/BatteryBackedEnergyStorage.kt @@ -4,12 +4,12 @@ import net.minecraft.nbt.CompoundTag import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.player.Player import net.minecraft.world.item.ItemStack -import net.minecraft.world.ticks.ContainerSingleItem import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.util.INBTSerializable import ru.dbotthepony.mc.otm.capability.FlowDirection import ru.dbotthepony.mc.otm.capability.extractEnergy import ru.dbotthepony.mc.otm.capability.receiveEnergy +import ru.dbotthepony.mc.otm.container.IContainer import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.getDecimal import ru.dbotthepony.mc.otm.core.nbt.getItemStack @@ -27,7 +27,7 @@ class BatteryBackedEnergyStorage( maxCharge: Decimal, val isAndroid: Boolean, val onChange: Runnable? = null -) : IMatteryEnergyStorage, INBTSerializable, ContainerSingleItem { +) : IMatteryEnergyStorage, INBTSerializable, IContainer { override val energyFlow: FlowDirection get() = FlowDirection.INPUT @@ -61,6 +61,22 @@ class BatteryBackedEnergyStorage( item = stack } + override fun clearContent() { + item = ItemStack.EMPTY + } + + override fun getContainerSize(): Int { + return 1 + } + + override fun isEmpty(): Boolean { + return item.isEmpty + } + + override fun removeItemNoUpdate(slot: Int): ItemStack { + TODO("Not yet implemented") + } + override fun setChanged() { } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt index cf9383d38..edcd8de6f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt @@ -17,7 +17,7 @@ private fun buffer() = buffer private fun Font.drawInBatch( text: Any, x: Float, y: Float, color: Int, drawShadow: Boolean, - matrix4f: Matrix4f, buffer: MultiBufferSource, displayMode: Font.DisplayMode, + matrix4f: Matrix4f, buffer: MultiBufferSource, displayMode: Boolean, effectColor: Int, packedLightCoords: Int, gravity: RenderGravity, rounding: GravityRounding, width: FloatSupplier ): Int { @@ -120,7 +120,7 @@ private fun Font.drawInternal( scale: Float, color: RGBAColor, drawShadow: Boolean, - displayMode: Font.DisplayMode, + displayMode: Boolean, packedLightCoords: Int, effectColor: Int, shadowColor: RGBAColor, @@ -239,7 +239,7 @@ fun Font.draw( scale: Float = 1f, color: RGBAColor = RGBAColor.WHITE, drawShadow: Boolean = false, - displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, + displayMode: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0, shadowColor: RGBAColor = RGBAColor.BLACK, @@ -287,7 +287,7 @@ fun Font.draw( scale: Float = 1f, color: RGBAColor = RGBAColor.WHITE, drawShadow: Boolean = false, - displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, + displayMode: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0, shadowColor: RGBAColor = RGBAColor.BLACK, @@ -335,7 +335,7 @@ fun Font.draw( scale: Float = 1f, color: RGBAColor = RGBAColor.WHITE, drawShadow: Boolean = false, - displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, + displayMode: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0, shadowColor: RGBAColor = RGBAColor.BLACK, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt index dfa97516c..d92ec4d20 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt @@ -35,7 +35,7 @@ class MGUIGraphics(val pose: PoseStack) { } fun renderFakeItem(itemStack: ItemStack, x: Int, y: Int) { - minecraft.itemRenderer.renderGuiItem(pose, itemStack, x, y) + minecraft.itemRenderer.renderGuiItem(itemStack, x, y) } fun drawLine( @@ -130,7 +130,9 @@ class MGUIGraphics(val pose: PoseStack) { for (i in mapped.indices) { val line = mapped[i] - line.renderImage(preEvent.font, x, yCurrent, pose, minecraft.itemRenderer) + line.renderImage(preEvent.font, x, yCurrent, pose, minecraft.itemRenderer, 0 /* blit offset, i love you, go commit self-murder */) + /* because your existence servers ZERO FUCKING PURPOSE */ + /* Z-BUFFER IN MY GUI PIECE OF SHIT */ yCurrent += line.height + if (i == 0) 2 else 0 } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReconstructorRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReconstructorRenderer.kt index 1d252f645..df2c300b3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReconstructorRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReconstructorRenderer.kt @@ -3,9 +3,9 @@ package ru.dbotthepony.mc.otm.client.render.blockentity import com.mojang.blaze3d.vertex.PoseStack import com.mojang.math.Axis import net.minecraft.client.renderer.MultiBufferSource +import net.minecraft.client.renderer.block.model.ItemTransforms import net.minecraft.client.renderer.blockentity.BlockEntityRenderer import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider -import net.minecraft.world.item.ItemDisplayContext import ru.dbotthepony.mc.otm.block.entity.matter.MatterReconstructorBlockEntity import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource @@ -32,7 +32,7 @@ class MatterReconstructorRenderer(private val context: BlockEntityRendererProvid pose.mulPose(Axis.XP.rotationDegrees(90f)) pose.mulPose(Axis.ZP.rotationDegrees(tile.blockRotation.back.toYRot())) - context.itemRenderer.renderStatic(item, ItemDisplayContext.FIXED, packedLight, packedOverlay, pose, DynamicBufferSource.WORLD, tile.level, tile.blockPos.asLong().toInt()) + context.itemRenderer.renderStatic(item, ItemTransforms.TransformType.FIXED, packedLight, packedOverlay, pose, DynamicBufferSource.WORLD, tile.blockPos.asLong().toInt()) pose.popPose() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReplicatorRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReplicatorRenderer.kt index 2f4a080ce..73bc49d0d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReplicatorRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterReplicatorRenderer.kt @@ -9,7 +9,6 @@ import net.minecraft.client.renderer.block.model.ItemTransforms import net.minecraft.client.renderer.blockentity.BlockEntityRenderer import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider import net.minecraft.core.particles.DustParticleOptions -import net.minecraft.world.item.ItemDisplayContext import net.minecraft.world.level.levelgen.XoroshiroRandomSource import org.joml.Vector3f import org.lwjgl.opengl.GL14.glBlendColor @@ -80,7 +79,7 @@ class MatterReplicatorRenderer(private val context: BlockEntityRendererProvider. context.itemRenderer.render( item, - ItemDisplayContext.NONE, + ItemTransforms.TransformType.NONE, false, pose, source, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterScannerRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterScannerRenderer.kt index adf55b8b1..f61b83232 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterScannerRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/MatterScannerRenderer.kt @@ -5,9 +5,9 @@ import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack import com.mojang.math.Axis import net.minecraft.client.renderer.MultiBufferSource +import net.minecraft.client.renderer.block.model.ItemTransforms import net.minecraft.client.renderer.blockentity.BlockEntityRenderer import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider -import net.minecraft.world.item.ItemDisplayContext import ru.dbotthepony.mc.otm.block.entity.matter.MatterScannerBlockEntity import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.render.lockBlendFunc @@ -41,12 +41,11 @@ class MatterScannerRenderer(private val context: BlockEntityRendererProvider.Con context.itemRenderer.renderStatic( item, - ItemDisplayContext.FIXED, + ItemTransforms.TransformType.FIXED, packedLight, packedOverlay, pose, source, - tile.level, tile.blockPos.asLong().toInt() ) 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 d3fbe4daa..252a9a062 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 @@ -12,7 +12,6 @@ import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory import net.minecraft.world.inventory.Slot import net.minecraft.world.item.Item -import net.minecraft.world.item.ItemDisplayContext import net.minecraft.world.item.ItemStack import net.minecraftforge.client.event.ContainerScreenEvent.Render.Background import net.minecraftforge.client.event.ContainerScreenEvent.Render.Foreground @@ -23,7 +22,6 @@ 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.translation 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 @@ -46,8 +44,6 @@ import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.config.ClientConfig import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.core.math.component1 -import ru.dbotthepony.mc.otm.core.math.component2 import ru.dbotthepony.mc.otm.core.math.integerDivisionDown import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.MatterySlot @@ -89,20 +85,37 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit val quickCraftingType: Int get() = super.quickCraftingType val isQuickCrafting: Boolean get() = super.isQuickCrafting - fun renderItemStack(graphics: MGUIGraphics, itemstack: ItemStack, countOverride: String? = null) { + fun renderItemStack(absoluteX: Float, absoluteY: Float, itemstack: ItemStack, countOverride: String? = null) { if (!itemstack.isEmpty) { RenderSystem.enableDepthTest() - itemRenderer.renderGuiItem(graphics.pose, itemstack, 1, 1) - RenderSystem.depthFunc(GL11.GL_ALWAYS) - itemRenderer.renderGuiItemDecorations( - graphics.pose, - super.font, + val systemPoseStack = RenderSystem.getModelViewStack() + + systemPoseStack.pushPose() + systemPoseStack.translate(absoluteX + 1f, absoluteY + 1f, 0f) + RenderSystem.applyModelViewMatrix() + RenderSystem.depthFunc(GL11.GL_LESS) + + // Thanks Mojang + // Very cool + // (for int x, int y, which are then cast into doubles anyway) + itemRenderer.blitOffset = 1f // Z pos + + itemRenderer.renderAndDecorateItem( + requireNotNull(ru.dbotthepony.mc.otm.client.minecraft.player) { "yo, dude, what the fuck" }, itemstack, - 1, - 1, - countOverride + 0, + 0, + (absoluteX + absoluteY * 1000f).toInt() ) + + RenderSystem.depthFunc(GL11.GL_ALWAYS) + itemRenderer.renderGuiItemDecorations(super.font, itemstack, 0, 0, countOverride) + itemRenderer.blitOffset = 0f + + // too big accumulations can lead to Z near clipping issues + systemPoseStack.popPose() + RenderSystem.applyModelViewMatrix() } } @@ -695,7 +708,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } @Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") - renderFloatingItem(poseStack, itemstack, mouseX - 8, mouseY - i2, overrideCount) + renderFloatingItem(itemstack, mouseX - 8, mouseY - i2, overrideCount) } if (menu.carried.isEmpty) { 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 0746b9b0e..96719477e 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 @@ -5,11 +5,8 @@ import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.systems.RenderSystem import it.unimi.dsi.fastutil.ints.IntAVLTreeSet import it.unimi.dsi.fastutil.objects.ReferenceArraySet -import net.minecraft.client.gui.ComponentPath import net.minecraft.client.gui.Font import net.minecraft.client.gui.components.events.GuiEventListener -import net.minecraft.client.gui.navigation.FocusNavigationEvent -import net.minecraft.client.gui.navigation.ScreenRectangle import net.minecraft.client.gui.screens.Screen import net.minecraft.client.renderer.Rect2i import net.minecraft.network.chat.Component @@ -78,17 +75,15 @@ open class EditablePanel @JvmOverloads constructor( ) : Comparable> { // layout engine does not support navigation using keyboard val listener: GuiEventListener = object : GuiEventListener { - override fun setFocused(p_265728_: Boolean) { + override fun changeFocus(p_265728_: Boolean): Boolean { if (p_265728_) { if (isVisible()) requestFocus() } else { killFocus() } - } - override fun isFocused(): Boolean { - return isEverFocused() + return true } override fun mouseMoved(p_94758_: Double, p_94759_: Double) { @@ -123,22 +118,9 @@ open class EditablePanel @JvmOverloads constructor( return this@EditablePanel.charTyped(p_94732_, p_94733_) } - override fun nextFocusPath(p_265234_: FocusNavigationEvent): ComponentPath? { - return null - } - override fun isMouseOver(p_94748_: Double, p_94749_: Double): Boolean { return this@EditablePanel.isMouseOver(p_94748_, p_94749_) } - - override fun getCurrentFocusPath(): ComponentPath? { - return null - } - - override fun getRectangle(): ScreenRectangle { - val rect = calculateAbsoluteRectangle() - return ScreenRectangle(rect.x.toInt(), rect.y.toInt(), rect.width.toInt(), rect.height.toInt()) - } } /** diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt index 3dc6017e0..f8d193e91 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt @@ -170,15 +170,14 @@ class EntityRendererPanel @JvmOverloads constructor( return } - val renderX = width.toInt() / 2 - val renderY = (height * 0.9f).toInt() + val renderX = absoluteX.toInt() + width.toInt() / 2 + val renderY = absoluteY.toInt() + (height * 0.9f).toInt() - InventoryScreen.renderEntityInInventoryFollowsMouse( - graphics.pose, + InventoryScreen.renderEntityInInventory( renderX, renderY, renderScale, - absoluteX.toInt() + renderX - mouseX, + renderX - mouseX, absoluteY + height * 0.15f - mouseY, entity ) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/SimpleTritaniumArmorItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/SimpleTritaniumArmorItem.kt index 4441e7237..892d74340 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/SimpleTritaniumArmorItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/SimpleTritaniumArmorItem.kt @@ -12,22 +12,22 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.registry.MItemTags private object SimpleTritaniumArmorMaterial : ArmorMaterial { - override fun getDurabilityForType(p_40410_: ArmorItem.Type): Int { + override fun getDurabilityForSlot(p_40410_: EquipmentSlot): Int { return when (p_40410_) { - ArmorItem.Type.HELMET -> 380 - ArmorItem.Type.CHESTPLATE -> 590 - ArmorItem.Type.LEGGINGS -> 500 - ArmorItem.Type.BOOTS -> 420 + EquipmentSlot.HEAD -> 380 + EquipmentSlot.CHEST -> 590 + EquipmentSlot.LEGS -> 500 + EquipmentSlot.FEET -> 420 else -> throw IllegalArgumentException("yo dude what the fuck $p_40410_") } } - override fun getDefenseForType(p_40411_: ArmorItem.Type): Int { + override fun getDefenseForSlot(p_40411_: EquipmentSlot): Int { return when (p_40411_) { - ArmorItem.Type.HELMET -> 2 - ArmorItem.Type.CHESTPLATE -> 6 - ArmorItem.Type.LEGGINGS -> 7 - ArmorItem.Type.BOOTS -> 2 + EquipmentSlot.HEAD -> 2 + EquipmentSlot.CHEST -> 6 + EquipmentSlot.LEGS -> 7 + EquipmentSlot.FEET -> 2 else -> throw IllegalArgumentException("yo dude what the fuck $p_40411_") } } @@ -43,7 +43,7 @@ private object SimpleTritaniumArmorMaterial : ArmorMaterial { override fun getKnockbackResistance() = 0f } -class SimpleTritaniumArmorItem(slot: Type) : ArmorItem(SimpleTritaniumArmorMaterial, slot, Properties().stacksTo(1)) { +class SimpleTritaniumArmorItem(slot: EquipmentSlot) : ArmorItem(SimpleTritaniumArmorMaterial, slot, Properties().stacksTo(1)) { override fun getArmorTexture(stack: ItemStack, entity: Entity?, slot: EquipmentSlot, type: String?): String? { if (type != "overlay" || slot == EquipmentSlot.FEET) return when (slot) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/TritaniumArmorItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/TritaniumArmorItem.kt index 2a1f8a588..0abbd1be4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/TritaniumArmorItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/armor/TritaniumArmorItem.kt @@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.item.armor import net.minecraft.client.model.HumanoidModel import net.minecraft.sounds.SoundEvent import net.minecraft.sounds.SoundEvents -import net.minecraft.world.damagesource.DamageTypes +import net.minecraft.world.damagesource.DamageSource import net.minecraft.world.entity.Entity import net.minecraft.world.entity.EquipmentSlot import net.minecraft.world.entity.LivingEntity @@ -19,21 +19,23 @@ import ru.dbotthepony.mc.otm.registry.MItems import java.util.function.Consumer private object TritaniumArmorMaterial : ArmorMaterial { - override fun getDurabilityForType(p_40410_: ArmorItem.Type): Int { + override fun getDurabilityForSlot(p_40410_: EquipmentSlot): Int { return when (p_40410_) { - ArmorItem.Type.HELMET -> 520 - ArmorItem.Type.CHESTPLATE -> 920 - ArmorItem.Type.LEGGINGS -> 650 - ArmorItem.Type.BOOTS -> 540 + EquipmentSlot.HEAD -> 520 + EquipmentSlot.CHEST -> 920 + EquipmentSlot.LEGS -> 650 + EquipmentSlot.FEET -> 540 + else -> throw IllegalArgumentException(p_40410_.toString()) } } - override fun getDefenseForType(p_40411_: ArmorItem.Type): Int { + override fun getDefenseForSlot(p_40411_: EquipmentSlot): Int { return when (p_40411_) { - ArmorItem.Type.HELMET -> 4 - ArmorItem.Type.CHESTPLATE -> 9 - ArmorItem.Type.LEGGINGS -> 7 - ArmorItem.Type.BOOTS -> 3 + EquipmentSlot.HEAD -> 4 + EquipmentSlot.CHEST -> 9 + EquipmentSlot.LEGS -> 7 + EquipmentSlot.FEET -> 3 + else -> throw IllegalArgumentException(p_40411_.toString()) } } @@ -63,7 +65,7 @@ private object TritaniumArmorRenderProperties : IClientItemExtensions { } } -class TritaniumArmorItem(slot: Type) : DyeableArmorItem(TritaniumArmorMaterial, slot, Properties().stacksTo(1).rarity(Rarity.RARE)) { +class TritaniumArmorItem(slot: EquipmentSlot) : DyeableArmorItem(TritaniumArmorMaterial, slot, Properties().stacksTo(1).rarity(Rarity.RARE)) { override fun initializeClient(consumer: Consumer) { super.initializeClient(consumer) consumer.accept(TritaniumArmorRenderProperties) @@ -87,7 +89,7 @@ class TritaniumArmorItem(slot: Type) : DyeableArmorItem(TritaniumArmorMaterial, const val TEXTURE_LOCATION_OVERLAY = "${OverdriveThatMatters.MOD_ID}:textures/models/armor/tritanium_armor_overlay.png" fun onHurt(event: LivingAttackEvent) { - if (event.source.typeHolder().`is`(DamageTypes.SWEET_BERRY_BUSH) || event.source.msgId == "sweetBerryBush") { + if (event.source == DamageSource.SWEET_BERRY_BUSH || event.source.msgId == "sweetBerryBush") { if ( event.entity.getItemBySlot(EquipmentSlot.FEET).let { !it.isEmpty && it.item == MItems.TRITANIUM_BOOTS } && event.entity.getItemBySlot(EquipmentSlot.LEGS).let { !it.isEmpty && it.item == MItems.TRITANIUM_PANTS } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/AbstractExopackSlotUpgradeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/AbstractExopackSlotUpgradeItem.kt index d99790504..ba3213c5c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/AbstractExopackSlotUpgradeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/AbstractExopackSlotUpgradeItem.kt @@ -18,8 +18,6 @@ import ru.dbotthepony.mc.otm.config.ServerConfig import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.core.isExplosion -import ru.dbotthepony.mc.otm.core.isFire import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.runIfClient import ru.dbotthepony.mc.otm.triggers.ExopackSlotsExpandedTrigger diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt index 5c8a81d7d..964402223 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/AbstractWeaponItem.kt @@ -3,13 +3,13 @@ package ru.dbotthepony.mc.otm.item.weapon import com.mojang.blaze3d.systems.RenderSystem import net.minecraft.client.Minecraft import net.minecraft.client.model.HumanoidModel +import net.minecraft.client.renderer.block.model.ItemTransforms import net.minecraft.nbt.CompoundTag import net.minecraft.network.FriendlyByteBuf import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.Entity import net.minecraft.world.entity.player.Player import net.minecraft.world.item.Item -import net.minecraft.world.item.ItemDisplayContext import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Rarity import net.minecraft.world.level.block.state.BlockState @@ -429,7 +429,7 @@ abstract class AbstractWeaponItem(val tables: KClass, pr itemInHandRenderer.renderItem( player, stack, - ItemDisplayContext.FIRST_PERSON_RIGHT_HAND, + ItemTransforms.TransformType.FIRST_PERSON_RIGHT_HAND, false, pose, event.multiBufferSource, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt index 50449c5dd..5de261641 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/ComputeAction.kt @@ -112,10 +112,10 @@ class ComputeAction( try { DataResult.success(Pair(Constant(Decimal(it.substring(1).trim()), it.substring(1).trim().toDouble(), fn, fn), ops.empty())) } catch (err: NumberFormatException) { - DataResult.error { "Not a number: ${it.substring(1).trim()} (input string: $it)" } + DataResult.error("Not a number: ${it.substring(1).trim()} (input string: $it)") } } else { - DataResult.error { "Input string does not match expected operand: expected $symbol, got ${it[0]} (for input $it)" } + DataResult.error("Input string does not match expected operand: expected $symbol, got ${it[0]} (for input $it)") } } } @@ -135,7 +135,7 @@ class ComputeAction( try { DataResult.success(Pair(Constant(Decimal(it.toString()), it.toDouble(), IMatterFunction.PLUS, IMatterFunction.PLUS), ops.empty())) } catch (err: NumberFormatException) { - DataResult.error { "Not a number: $it" } + DataResult.error("Not a number: $it") } } @@ -146,7 +146,7 @@ class ComputeAction( try { DataResult.success(Pair(Constant(Decimal(it), it.toDouble(), IMatterFunction.PLUS, IMatterFunction.PLUS), ops.empty())) } catch (err: NumberFormatException) { - DataResult.error { "Not a number: $it" } + DataResult.error("Not a number: $it") } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index 73709213c..ac48cb38a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -297,12 +297,6 @@ abstract class MatteryMenu( open inner class EquipmentSlot(container: Container, index: Int, val type: net.minecraft.world.entity.EquipmentSlot) : InventorySlot(container, index) { constructor(type: net.minecraft.world.entity.EquipmentSlot) : this(inventory, 34 + type.ordinal, type) - override fun setByPlayer(newItem: ItemStack) { - val oldItem = item - inventory.player.onEquipItem(type, oldItem, newItem) - super.setByPlayer(newItem) - } - override fun mayPlace(itemStack: ItemStack): Boolean { return super.mayPlace(itemStack) && itemStack.canEquip(type, inventory.player) } @@ -327,12 +321,6 @@ abstract class MatteryMenu( autoCreateInventoryFrame = autoFrame offhandSlot = object : InventorySlot(inventory, 40) { - override fun setByPlayer(newItem: ItemStack) { - val oldItem = this.item - inventory.player.onEquipItem(net.minecraft.world.entity.EquipmentSlot.OFFHAND, oldItem, newItem) - super.setByPlayer(newItem) - } - override fun getNoItemIcon(): Pair { return Pair.of(InventoryMenu.BLOCK_ATLAS, InventoryMenu.EMPTY_ARMOR_SLOT_SHIELD) } @@ -602,7 +590,7 @@ abstract class MatteryMenu( val copy = source.item.copy() if (remainder.isEmpty) { - source.setByPlayer(ItemStack.EMPTY) + source.set(ItemStack.EMPTY) source.onTake(player, copy) } else { copy.count = source.item.count - remainder.count @@ -662,7 +650,7 @@ abstract class MatteryMenu( val newCount = copy.count.coerceAtMost(limit) if (!simulate) { - slot.setByPlayer(copy.copy().also { it.count = newCount }) + slot.set(copy.copy().also { it.count = newCount }) slot.setChanged() } 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 6aeed61ad..d61b81d0b 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 @@ -141,7 +141,7 @@ class PainterMenu( if (recipe == null || !recipe.value.canCraft(dyeStoredDirect) || !recipe.value.matches(inputContainer, inventory.player.level)) { outputContainer.clearContent() } else { - outputContainer[0] = recipe.value.assemble(inputContainer, inventory.player.level.registryAccess()) + outputContainer[0] = recipe.value.assemble(inputContainer) lastRecipe = recipe } } 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 b713fb6b0..dbd47c23e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/ExplosiveHammerPrimingRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/ExplosiveHammerPrimingRecipe.kt @@ -40,7 +40,7 @@ class ExplosiveHammerPrimingRecipe(val payload: Ingredient, private val id: Reso result.any { payload.test(it) } } - override fun assemble(pContainer: CraftingContainer, registry: RegistryAccess): ItemStack { + override fun assemble(pContainer: CraftingContainer): ItemStack { val hammer = pContainer.stream().filter { it.isNotEmpty && it.item is ExplosiveHammerItem }.findAny() if (hammer.isEmpty) return ItemStack.EMPTY @@ -53,7 +53,7 @@ class ExplosiveHammerPrimingRecipe(val payload: Ingredient, private val id: Reso return pWidth * pHeight >= 3 } - override fun getResultItem(registry: RegistryAccess): ItemStack { + override fun getResultItem(): ItemStack { return ItemStack.EMPTY } 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 aa0633bbd..1bd928749 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt @@ -65,7 +65,7 @@ open class MatterEntanglerRecipe( return ingredients.preemptiveTest(container) } - override fun assemble(container: CraftingContainer, registry: RegistryAccess): ItemStack { + override fun assemble(container: CraftingContainer): ItemStack { return result.copy().also { it.tagNotNull[uuidKey] = fixedUuid.getOrElse { UUID.randomUUID() } } @@ -75,7 +75,7 @@ open class MatterEntanglerRecipe( return width >= ingredients.width && height >= ingredients.height } - override fun getResultItem(registry: RegistryAccess): ItemStack { + override fun getResultItem(): ItemStack { return result } @@ -111,8 +111,8 @@ open class MatterEntanglerRecipe( fun matter() = Matter(this) open class Energy(val parent: MatterEntanglerRecipe) : IMatterEntanglerRecipe by parent { - override fun assemble(container: CraftingContainer, registry: RegistryAccess): ItemStack { - return parent.assemble(container, registry).also { result -> + override fun assemble(container: CraftingContainer): ItemStack { + return parent.assemble(container).also { result -> container.iterator().map { it.matteryEnergy }.filterNotNull().forEach { result.matteryEnergy!!.batteryLevel += it.batteryLevel } @@ -129,8 +129,8 @@ open class MatterEntanglerRecipe( } open class Matter(val parent: MatterEntanglerRecipe) : IMatterEntanglerRecipe by parent { - override fun assemble(container: CraftingContainer, registry: RegistryAccess): ItemStack { - return parent.assemble(container, registry).also { result -> + override fun assemble(container: CraftingContainer): ItemStack { + return parent.assemble(container).also { result -> container.iterator().map { it.matter }.filterNotNull().forEach { result.matter!!.storedMatter += it.storedMatter } 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 a946509eb..01eb1200a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt @@ -42,8 +42,8 @@ class UpgradeRecipe( return parent.recipe.canCraftInDimensions(p_43999_, p_44000_) } - override fun getResultItem(p_267052_: RegistryAccess): ItemStack { - return parent.recipe.getResultItem(p_267052_) + override fun getResultItem(): ItemStack { + return parent.recipe.resultItem } override fun getRemainingItems(p_44004_: CraftingContainer): NonNullList { @@ -58,10 +58,6 @@ class UpgradeRecipe( return parent.recipe.isSpecial } - override fun showNotification(): Boolean { - return parent.recipe.showNotification() - } - override fun getGroup(): String { return parent.recipe.group } @@ -184,8 +180,8 @@ class UpgradeRecipe( val copyPaths: ImmutableList = copyPaths.collect(ImmutableList.toImmutableList()) - override fun assemble(pInv: CraftingContainer, registryAccess: RegistryAccess): ItemStack { - val result = parent.recipe.assemble(pInv, registryAccess) + override fun assemble(pInv: CraftingContainer): ItemStack { + val result = parent.recipe.assemble(pInv) if (result.isEmpty) { return result diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt index 118ae68ca..e73002ea4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt @@ -280,7 +280,7 @@ object MCreativeTabs { it.icon { ItemStack(BATTERY_CREATIVE, 1) } it.title(TranslatableComponent("itemGroup.otm")) - it.displayItems { _, consumer -> + it.displayItems { _, consumer, hasPerms -> addMainCreativeTabItems(consumer) } } @@ -289,7 +289,7 @@ object MCreativeTabs { it.icon { ItemStack(MRegistry.VENT.item, 1) } it.title(TranslatableComponent("itemGroup.otm_decorative")) - it.displayItems { _, consumer -> + it.displayItems { _, consumer, hasPerms -> addDecorativeTabItems(consumer) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MDamageTypes.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MDamageTypes.kt index a1af1bade..65a92be76 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MDamageTypes.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MDamageTypes.kt @@ -1,24 +1,18 @@ package ru.dbotthepony.mc.otm.registry -import net.minecraft.core.registries.Registries -import net.minecraft.resources.ResourceKey -import net.minecraft.resources.ResourceLocation -import net.minecraft.world.damagesource.DamageType -import ru.dbotthepony.mc.otm.OverdriveThatMatters +import net.minecraft.world.damagesource.DamageSource object MDamageTypes { - private fun register(name: String): ResourceKey = ResourceKey.create(Registries.DAMAGE_TYPE, ResourceLocation(OverdriveThatMatters.MOD_ID, name)) - - val BECOME_ANDROID = register("become_android") - val BECOME_HUMANE = register("become_humane") - val EVENT_HORIZON = register("event_horizon") - val HAWKING_RADIATION = register("hawking_radiation") - val EXOPACK_PROBE = register("exopack_probe") - val EMP = register("emp") - val SHOCKWAVE = register("shockwave") - val PLASMA = register("plasma") - val COSMIC_RAYS = register("cosmic_rays") - val EXPLOSIVE_HAMMER = register("explosive_hammer") - val HAMMER_NAIL = register("hammer_nail") - val ANDROID_DISCHARGE = register("android_discharge") + val BECOME_ANDROID = DamageSource("become_android") + val BECOME_HUMANE = DamageSource("become_humane") + val EVENT_HORIZON = DamageSource("event_horizon") + val HAWKING_RADIATION = DamageSource("hawking_radiation") + val EXOPACK_PROBE = DamageSource("exopack_probe") + val EMP = DamageSource("emp") + val SHOCKWAVE = DamageSource("shockwave") + val PLASMA = DamageSource("plasma") + val COSMIC_RAYS = DamageSource("cosmic_rays") + val EXPLOSIVE_HAMMER = DamageSource("explosive_hammer") + val HAMMER_NAIL = DamageSource("hammer_nail") + val ANDROID_DISCHARGE = DamageSource("android_discharge") } 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 0d3611aaa..bc94ff668 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -4,6 +4,7 @@ package ru.dbotthepony.mc.otm.registry import net.minecraft.ChatFormatting import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation +import net.minecraft.world.entity.EquipmentSlot import net.minecraft.world.food.FoodProperties import net.minecraft.world.item.* import net.minecraft.world.item.crafting.Ingredient @@ -341,15 +342,15 @@ object MItems { ::TRITANIUM_SHEARS, ) - val TRITANIUM_HELMET: TritaniumArmorItem by registry.register(MNames.TRITANIUM_HELMET) { TritaniumArmorItem(ArmorItem.Type.HELMET) } - val TRITANIUM_CHESTPLATE: TritaniumArmorItem by registry.register(MNames.TRITANIUM_CHESTPLATE) { TritaniumArmorItem(ArmorItem.Type.CHESTPLATE) } - val TRITANIUM_PANTS: TritaniumArmorItem by registry.register(MNames.TRITANIUM_PANTS) { TritaniumArmorItem(ArmorItem.Type.LEGGINGS) } - val TRITANIUM_BOOTS: TritaniumArmorItem by registry.register(MNames.TRITANIUM_BOOTS) { TritaniumArmorItem(ArmorItem.Type.BOOTS) } + val TRITANIUM_HELMET: TritaniumArmorItem by registry.register(MNames.TRITANIUM_HELMET) { TritaniumArmorItem(EquipmentSlot.HEAD) } + val TRITANIUM_CHESTPLATE: TritaniumArmorItem by registry.register(MNames.TRITANIUM_CHESTPLATE) { TritaniumArmorItem(EquipmentSlot.CHEST) } + val TRITANIUM_PANTS: TritaniumArmorItem by registry.register(MNames.TRITANIUM_PANTS) { TritaniumArmorItem(EquipmentSlot.LEGS) } + val TRITANIUM_BOOTS: TritaniumArmorItem by registry.register(MNames.TRITANIUM_BOOTS) { TritaniumArmorItem(EquipmentSlot.FEET) } - val SIMPLE_TRITANIUM_HELMET: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_HELMET) { SimpleTritaniumArmorItem(ArmorItem.Type.HELMET) } - val SIMPLE_TRITANIUM_CHESTPLATE: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_CHESTPLATE) { SimpleTritaniumArmorItem(ArmorItem.Type.CHESTPLATE) } - val SIMPLE_TRITANIUM_PANTS: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_PANTS) { SimpleTritaniumArmorItem(ArmorItem.Type.LEGGINGS) } - val SIMPLE_TRITANIUM_BOOTS: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_BOOTS) { SimpleTritaniumArmorItem(ArmorItem.Type.BOOTS) } + val SIMPLE_TRITANIUM_HELMET: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_HELMET) { SimpleTritaniumArmorItem(EquipmentSlot.HEAD) } + val SIMPLE_TRITANIUM_CHESTPLATE: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_CHESTPLATE) { SimpleTritaniumArmorItem(EquipmentSlot.CHEST) } + val SIMPLE_TRITANIUM_PANTS: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_PANTS) { SimpleTritaniumArmorItem(EquipmentSlot.LEGS) } + val SIMPLE_TRITANIUM_BOOTS: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_BOOTS) { SimpleTritaniumArmorItem(EquipmentSlot.FEET) } val TRITANIUM_ARMOR = SupplierList( ::TRITANIUM_HELMET, 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 25f1c43ab..e308ef926 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt @@ -77,41 +77,41 @@ import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu object MMenus { private val registry = DeferredRegister.create(ForgeRegistries.MENU_TYPES, OverdriveThatMatters.MOD_ID) - val ANDROID_STATION: MenuType by registry.register(MNames.ANDROID_STATION) { MenuType(::AndroidStationMenu, FeatureFlags.VANILLA_SET) } - val ANDROID_CHARGER: MenuType by registry.register(MNames.ANDROID_CHARGER) { MenuType({ a, b -> AndroidChargerMenu(a, b, null as AndroidChargerBlockEntity?) }, FeatureFlags.VANILLA_SET) } - val BATTERY_BANK: MenuType by registry.register(MNames.BATTERY_BANK) { MenuType(::BatteryBankMenu, FeatureFlags.VANILLA_SET) } - val MATTER_DECOMPOSER: MenuType by registry.register(MNames.MATTER_DECOMPOSER) { MenuType(::MatterDecomposerMenu, FeatureFlags.VANILLA_SET) } - val MATTER_CAPACITOR_BANK: MenuType by registry.register(MNames.MATTER_CAPACITOR_BANK) { MenuType(::MatterCapacitorBankMenu, FeatureFlags.VANILLA_SET) } - val PATTERN_STORAGE: MenuType by registry.register(MNames.PATTERN_STORAGE) { MenuType(::PatternStorageMenu, FeatureFlags.VANILLA_SET) } - val MATTER_SCANNER: MenuType by registry.register(MNames.MATTER_SCANNER) { MenuType(::MatterScannerMenu, FeatureFlags.VANILLA_SET) } - val MATTER_PANEL: MenuType by registry.register(MNames.MATTER_PANEL) { MenuType(::MatterPanelMenu, FeatureFlags.VANILLA_SET) } - val MATTER_REPLICATOR: MenuType by registry.register(MNames.MATTER_REPLICATOR) { MenuType(::MatterReplicatorMenu, FeatureFlags.VANILLA_SET) } - val MATTER_BOTTLER: MenuType by registry.register(MNames.MATTER_BOTTLER) { MenuType(::MatterBottlerMenu, FeatureFlags.VANILLA_SET) } - val DRIVE_VIEWER: MenuType by registry.register(MNames.DRIVE_VIEWER) { MenuType(::DriveViewerMenu, FeatureFlags.VANILLA_SET) } - val CARGO_CRATE: MenuType by registry.register(MNames.CARGO_CRATE) { MenuType(::CargoCrateMenu, FeatureFlags.VANILLA_SET) } - val MINECART_CARGO_CRATE: MenuType by registry.register(MNames.MINECART_CARGO_CRATE) { MenuType(::MinecartCargoCrateMenu, FeatureFlags.VANILLA_SET) } - val DRIVE_RACK: MenuType by registry.register(MNames.DRIVE_RACK) { MenuType(::DriveRackMenu, FeatureFlags.VANILLA_SET) } - val ITEM_MONITOR: MenuType by registry.register(MNames.ITEM_MONITOR) { MenuType(::ItemMonitorMenu, FeatureFlags.VANILLA_SET) } - val ENERGY_COUNTER: MenuType by registry.register(MNames.ENERGY_COUNTER) { MenuType(::EnergyCounterMenu, FeatureFlags.VANILLA_SET) } - val CHEMICAL_GENERATOR: MenuType by registry.register(MNames.CHEMICAL_GENERATOR) { MenuType(::ChemicalGeneratorMenu, FeatureFlags.VANILLA_SET) } - val PLATE_PRESS: MenuType by registry.register(MNames.PLATE_PRESS) { MenuType(::PlatePressMenu, FeatureFlags.VANILLA_SET) } - val POWERED_FURNACE: MenuType by registry.register(MNames.POWERED_FURNACE) { MenuType(PoweredFurnaceMenu::furnace, FeatureFlags.VANILLA_SET) } - val POWERED_BLAST_FURNACE: MenuType by registry.register(MNames.POWERED_BLAST_FURNACE) { MenuType(PoweredFurnaceMenu::blasting, FeatureFlags.VANILLA_SET) } - val POWERED_SMOKER: MenuType by registry.register(MNames.POWERED_SMOKER) { MenuType(PoweredFurnaceMenu::smoking, FeatureFlags.VANILLA_SET) } - val TWIN_PLATE_PRESS: MenuType by registry.register(MNames.TWIN_PLATE_PRESS) { MenuType(::TwinPlatePressMenu, FeatureFlags.VANILLA_SET) } - val MATTER_RECYCLER: MenuType by registry.register(MNames.MATTER_RECYCLER) { MenuType(::MatterRecyclerMenu, FeatureFlags.VANILLA_SET) } - val ENERGY_SERVO: MenuType by registry.register(MNames.ENERGY_SERVO) { MenuType(::EnergyServoMenu, FeatureFlags.VANILLA_SET) } - val HOLO_SIGN: MenuType by registry.register(MNames.HOLO_SIGN) { MenuType(::HoloSignMenu, FeatureFlags.VANILLA_SET) } - val COBBLESTONE_GENERATOR: MenuType by registry.register(MNames.COBBLESTONE_GENERATOR) { MenuType(::CobblerMenu, FeatureFlags.VANILLA_SET) } - val ESSENCE_STORAGE: MenuType by registry.register(MNames.ESSENCE_STORAGE) { MenuType(::EssenceStorageMenu, FeatureFlags.VANILLA_SET) } - val ITEM_REPAIER: MenuType by registry.register(MNames.MATTER_RECONSTRUCTOR) { MenuType(::MatterReconstructorMenu, FeatureFlags.VANILLA_SET) } - val FLUID_TANK: MenuType by registry.register(MNames.FLUID_TANK) { MenuType(::FluidTankMenu, FeatureFlags.VANILLA_SET) } - val PAINTER: MenuType by registry.register(MNames.PAINTER) { MenuType(::PainterMenu, FeatureFlags.VANILLA_SET) } - val MATTER_ENTANGLER: MenuType by registry.register(MNames.MATTER_ENTANGLER) { MenuType(::MatterEntanglerMenu, FeatureFlags.VANILLA_SET) } + val ANDROID_STATION: MenuType by registry.register(MNames.ANDROID_STATION) { MenuType(::AndroidStationMenu) } + val ANDROID_CHARGER: MenuType by registry.register(MNames.ANDROID_CHARGER) { MenuType({ a, b -> AndroidChargerMenu(a, b, null as AndroidChargerBlockEntity?) }) } + val BATTERY_BANK: MenuType by registry.register(MNames.BATTERY_BANK) { MenuType(::BatteryBankMenu) } + val MATTER_DECOMPOSER: MenuType by registry.register(MNames.MATTER_DECOMPOSER) { MenuType(::MatterDecomposerMenu) } + val MATTER_CAPACITOR_BANK: MenuType by registry.register(MNames.MATTER_CAPACITOR_BANK) { MenuType(::MatterCapacitorBankMenu) } + val PATTERN_STORAGE: MenuType by registry.register(MNames.PATTERN_STORAGE) { MenuType(::PatternStorageMenu) } + val MATTER_SCANNER: MenuType by registry.register(MNames.MATTER_SCANNER) { MenuType(::MatterScannerMenu) } + val MATTER_PANEL: MenuType by registry.register(MNames.MATTER_PANEL) { MenuType(::MatterPanelMenu) } + val MATTER_REPLICATOR: MenuType by registry.register(MNames.MATTER_REPLICATOR) { MenuType(::MatterReplicatorMenu) } + val MATTER_BOTTLER: MenuType by registry.register(MNames.MATTER_BOTTLER) { MenuType(::MatterBottlerMenu) } + val DRIVE_VIEWER: MenuType by registry.register(MNames.DRIVE_VIEWER) { MenuType(::DriveViewerMenu) } + val CARGO_CRATE: MenuType by registry.register(MNames.CARGO_CRATE) { MenuType(::CargoCrateMenu) } + val MINECART_CARGO_CRATE: MenuType by registry.register(MNames.MINECART_CARGO_CRATE) { MenuType(::MinecartCargoCrateMenu) } + val DRIVE_RACK: MenuType by registry.register(MNames.DRIVE_RACK) { MenuType(::DriveRackMenu) } + val ITEM_MONITOR: MenuType by registry.register(MNames.ITEM_MONITOR) { MenuType(::ItemMonitorMenu) } + val ENERGY_COUNTER: MenuType by registry.register(MNames.ENERGY_COUNTER) { MenuType(::EnergyCounterMenu) } + val CHEMICAL_GENERATOR: MenuType by registry.register(MNames.CHEMICAL_GENERATOR) { MenuType(::ChemicalGeneratorMenu) } + val PLATE_PRESS: MenuType by registry.register(MNames.PLATE_PRESS) { MenuType(::PlatePressMenu) } + val POWERED_FURNACE: MenuType by registry.register(MNames.POWERED_FURNACE) { MenuType(PoweredFurnaceMenu::furnace) } + val POWERED_BLAST_FURNACE: MenuType by registry.register(MNames.POWERED_BLAST_FURNACE) { MenuType(PoweredFurnaceMenu::blasting) } + val POWERED_SMOKER: MenuType by registry.register(MNames.POWERED_SMOKER) { MenuType(PoweredFurnaceMenu::smoking) } + val TWIN_PLATE_PRESS: MenuType by registry.register(MNames.TWIN_PLATE_PRESS) { MenuType(::TwinPlatePressMenu) } + val MATTER_RECYCLER: MenuType by registry.register(MNames.MATTER_RECYCLER) { MenuType(::MatterRecyclerMenu) } + val ENERGY_SERVO: MenuType by registry.register(MNames.ENERGY_SERVO) { MenuType(::EnergyServoMenu) } + val HOLO_SIGN: MenuType by registry.register(MNames.HOLO_SIGN) { MenuType(::HoloSignMenu) } + val COBBLESTONE_GENERATOR: MenuType by registry.register(MNames.COBBLESTONE_GENERATOR) { MenuType(::CobblerMenu) } + val ESSENCE_STORAGE: MenuType by registry.register(MNames.ESSENCE_STORAGE) { MenuType(::EssenceStorageMenu) } + val ITEM_REPAIER: MenuType by registry.register(MNames.MATTER_RECONSTRUCTOR) { MenuType(::MatterReconstructorMenu) } + val FLUID_TANK: MenuType by registry.register(MNames.FLUID_TANK) { MenuType(::FluidTankMenu) } + val PAINTER: MenuType by registry.register(MNames.PAINTER) { MenuType(::PainterMenu) } + val MATTER_ENTANGLER: MenuType by registry.register(MNames.MATTER_ENTANGLER) { MenuType(::MatterEntanglerMenu) } - val STORAGE_BUS: MenuType by registry.register(MNames.STORAGE_BUS) { MenuType(::StorageBusMenu, FeatureFlags.VANILLA_SET) } - val STORAGE_IMPORTER_EXPORTER: MenuType by registry.register(MNames.STORAGE_IMPORTER) { MenuType(::StorageImporterExporterMenu, FeatureFlags.VANILLA_SET) } - val STORAGE_POWER_SUPPLIER: MenuType by registry.register(MNames.STORAGE_POWER_SUPPLIER) { MenuType(::StoragePowerSupplierMenu, FeatureFlags.VANILLA_SET) } + val STORAGE_BUS: MenuType by registry.register(MNames.STORAGE_BUS) { MenuType(::StorageBusMenu) } + val STORAGE_IMPORTER_EXPORTER: MenuType by registry.register(MNames.STORAGE_IMPORTER) { MenuType(::StorageImporterExporterMenu) } + val STORAGE_POWER_SUPPLIER: MenuType by registry.register(MNames.STORAGE_POWER_SUPPLIER) { MenuType(::StoragePowerSupplierMenu) } internal fun register(bus: IEventBus) { registry.register(bus) 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 d164e3bd2..931960ee0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -364,16 +364,8 @@ object MRegistry { } private fun registerItemDecorators(event: RegisterItemDecorationsEvent) { - event.register(Items.SHIELD, object : IItemDecorator { - override fun render(poseStack: PoseStack, font: Font, stack: ItemStack, xOffset: Int, yOffset: Int): Boolean { - return MatteryGUI.renderShieldCooldownOverlay(poseStack, font, stack, xOffset, yOffset) - } - }) + event.register(Items.SHIELD) { font, stack, xOffset, yOffset, blitOffset -> MatteryGUI.renderShieldCooldownOverlay(PoseStack(), font, stack, xOffset, yOffset) } - event.register(MItems.TRITANIUM_SHIELD, object : IItemDecorator { - override fun render(poseStack: PoseStack, font: Font, stack: ItemStack, xOffset: Int, yOffset: Int): Boolean { - return MatteryGUI.renderShieldCooldownOverlay(poseStack, font, stack, xOffset, yOffset) - } - }) + event.register(MItems.TRITANIUM_SHIELD) { font, stack, xOffset, yOffset, blitOffset -> MatteryGUI.renderShieldCooldownOverlay(PoseStack(), font, stack, xOffset, yOffset) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt index dbbc1bb97..2d5bdee45 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/triggers/MCriterionTrigger.kt @@ -106,16 +106,16 @@ abstract class MCriterionTrigger.AbstractInstance>(priv @JvmStatic protected val predicateCodec: Codec = object : Codec { override fun encode(input: ContextAwarePredicate, ops: DynamicOps, prefix: T): DataResult { - return DataResult.success(JsonOps.INSTANCE.convertTo(ops, input.toJson(serializationContext.get().lastOrNull() ?: return DataResult.error { "Not serializing trigger instance" }))) + return DataResult.success(JsonOps.INSTANCE.convertTo(ops, input.toJson(serializationContext.get().lastOrNull() ?: return DataResult.error("Not serializing trigger instance")))) } override fun decode(ops: DynamicOps, input: T): DataResult> { - val context = deserializationContext.get().lastOrNull() ?: return DataResult.error { "Not current deserializing trigger instance" } + val context = deserializationContext.get().lastOrNull() ?: return DataResult.error("Not current deserializing trigger instance") return try { DataResult.success(Pair.of(EntityPredicate.Composite.fromJson(JsonObject().also { it["a"] = ops.convertTo(JsonOps.INSTANCE, input) }, "a", context), ops.empty())) } catch (err: Exception) { - DataResult.error { "Failed to deserialize ContextAwarePredicate: " + err.message } + DataResult.error("Failed to deserialize ContextAwarePredicate: " + err.message) } } } diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index d00eefc3f..bea3566fc 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -31,7 +31,7 @@ public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_9772 public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97722_ # lastClickButton public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97723_ # doubleclick public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97724_ # lastQuickMoved -public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_274323_(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/world/item/ItemStack;IILjava/lang/String;)V # renderFloatingItem +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_97782_(Lnet/minecraft/world/item/ItemStack;IILjava/lang/String;)V # renderFloatingItem public net.minecraft.client.gui.GuiComponent m_168740_(Lcom/mojang/blaze3d/vertex/PoseStack;IIIIIII)V # fillGradient public net.minecraft.client.gui.GuiComponent m_93123_(Lorg/joml/Matrix4f;Lcom/mojang/blaze3d/vertex/BufferBuilder;IIIIIII)V # fillGradient From 7b415fbce32ae3034b91df9c1a0c684b4ec95736 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 22:01:57 +0700 Subject: [PATCH 1191/1199] More backporting --- gradle.properties | 8 +- .../dbotthepony/mc/otm/datagen/DamageTypes.kt | 55 ----- .../ru/dbotthepony/mc/otm/datagen/DataGen.kt | 3 - .../mc/otm/android/AndroidFeatureType.kt | 2 +- .../otm/android/feature/ShockwaveFeature.kt | 6 +- .../decorative/TritaniumPressurePlate.kt | 11 +- .../entity/blackhole/BlackHoleBlockEntity.kt | 10 +- .../otm/block/entity/blackhole/Explosions.kt | 5 +- .../entity/tech/PoweredFurnaceBlockEntity.kt | 2 +- .../otm/capability/MatteryPlayerCapability.kt | 9 +- .../mc/otm/client/render/MGUIGraphics.kt | 13 +- .../screen/panels/input/EditBoxPanel.kt | 6 +- .../screen/panels/slot/AbstractSlotPanel.kt | 2 +- .../panels/slot/UserFilteredSlotPanel.kt | 2 +- .../screen/tech/AndroidStationScreen.kt | 2 +- .../mc/otm/compat/adastra/AdAstraCompat.kt | 10 +- .../mc/otm/core/UnOverengineering.kt | 2 +- .../mc/otm/entity/PlasmaProjectile.kt | 5 +- .../ru/dbotthepony/mc/otm/item/BatteryItem.kt | 4 +- .../mc/otm/item/ChestUpgraderItem.kt | 3 +- .../mc/otm/item/exopack/ExopackProbeItem.kt | 5 +- .../mc/otm/item/tool/ExplosiveHammerItem.kt | 13 +- .../mc/otm/item/weapon/EnergySwordItem.kt | 7 +- .../mc/otm/matter/MatterManager.kt | 18 +- .../mc/otm/recipe/MatteryCookingRecipe.kt | 4 +- .../mc/otm/registry/DamageSources.kt | 222 ++++++++++++++++++ .../ru/dbotthepony/mc/otm/registry/MBlocks.kt | 8 +- .../mc/otm/registry/MDamageTypes.kt | 24 +- .../dbotthepony/mc/otm/registry/MRegistry.kt | 12 + .../mc/otm/registry/MatteryDamageSource.kt | 35 --- .../resources/META-INF/accesstransformer.cfg | 7 + 31 files changed, 330 insertions(+), 185 deletions(-) delete mode 100644 src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DamageTypes.kt create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/registry/DamageSources.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/registry/MatteryDamageSource.kt diff --git a/gradle.properties b/gradle.properties index 26f8720c1..d287adf01 100644 --- a/gradle.properties +++ b/gradle.properties @@ -23,10 +23,10 @@ jei_version=12.4.0.22 jupiter_version=5.9.2 curios_version=4440173 cosmetic_armor_reworked_id=4439659 -ad_astra_id=4594155 -botarium_id=4594094 -resourceful_lib_id=4598948 -resourceful_config_id=4576455 +ad_astra_id=4452072 +botarium_id=4416456 +resourceful_lib_id=4378849 +resourceful_config_id=4441381 jade_id=4434045 configured_id=4462894 diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DamageTypes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DamageTypes.kt deleted file mode 100644 index 525fbf309..000000000 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DamageTypes.kt +++ /dev/null @@ -1,55 +0,0 @@ -package ru.dbotthepony.mc.otm.datagen - -import net.minecraft.core.RegistrySetBuilder -import net.minecraft.core.registries.Registries -import net.minecraft.data.worldgen.BootstapContext -import net.minecraft.tags.DamageTypeTags -import net.minecraft.world.damagesource.DamageScaling -import net.minecraft.world.damagesource.DamageType -import net.minecraftforge.common.data.DatapackBuiltinEntriesProvider -import net.minecraftforge.data.event.GatherDataEvent -import ru.dbotthepony.mc.otm.datagen.tags.TagsProvider -import ru.dbotthepony.mc.otm.registry.MDamageTypes - -fun registerDamageTypes(context: BootstapContext) { - context.register(MDamageTypes.EXOPACK_PROBE, DamageType("otm_exopack_probe", DamageScaling.NEVER, 4.0f)) - context.register(MDamageTypes.BECOME_ANDROID, DamageType("otm_become_android", DamageScaling.NEVER, 0f)) - context.register(MDamageTypes.BECOME_HUMANE, DamageType("otm_become_humane", DamageScaling.NEVER, 0f)) - context.register(MDamageTypes.EVENT_HORIZON, DamageType("otm_event_horizon", DamageScaling.NEVER, 0f)) - context.register(MDamageTypes.HAWKING_RADIATION, DamageType("otm_hawking_radiation", DamageScaling.NEVER, 0f)) - context.register(MDamageTypes.EMP, DamageType("otm_emp", DamageScaling.NEVER, 0f)) - context.register(MDamageTypes.SHOCKWAVE, DamageType("otm_shockwave", DamageScaling.NEVER, 0f)) - context.register(MDamageTypes.PLASMA, DamageType("otm_plasma", DamageScaling.NEVER, 0f)) - context.register(MDamageTypes.COSMIC_RAYS, DamageType("otm_cosmic_rays", DamageScaling.NEVER, 0f)) - context.register(MDamageTypes.EXPLOSIVE_HAMMER, DamageType("otm_explosive_hammer", DamageScaling.NEVER, 0.1f)) - context.register(MDamageTypes.HAMMER_NAIL, DamageType("otm_hammer_nail", DamageScaling.NEVER, 0.1f)) - context.register(MDamageTypes.ANDROID_DISCHARGE, DamageType("otm_android_discharge", DamageScaling.NEVER, 4.0f)) -} - -fun registerDamageTypeTags(provider: TagsProvider.Delegate) { - val ignoreArmor = provider.Appender(DamageTypeTags.BYPASSES_ARMOR) - val ignoreMagic = provider.Appender(DamageTypeTags.BYPASSES_ENCHANTMENTS) - val ignoreInvl = provider.Appender(DamageTypeTags.BYPASSES_INVULNERABILITY) - - ignoreArmor - .add(MDamageTypes.EXOPACK_PROBE) - .add(MDamageTypes.BECOME_ANDROID) - .add(MDamageTypes.BECOME_HUMANE) - .add(MDamageTypes.EVENT_HORIZON) - .add(MDamageTypes.EMP) - .add(MDamageTypes.SHOCKWAVE) - .add(MDamageTypes.COSMIC_RAYS) - .add(MDamageTypes.ANDROID_DISCHARGE) - - ignoreMagic - .add(MDamageTypes.EXOPACK_PROBE) - .add(MDamageTypes.BECOME_ANDROID) - .add(MDamageTypes.BECOME_HUMANE) - .add(MDamageTypes.COSMIC_RAYS) - .add(MDamageTypes.ANDROID_DISCHARGE) - - ignoreInvl - .add(MDamageTypes.BECOME_HUMANE) - .add(MDamageTypes.BECOME_ANDROID) - .add(MDamageTypes.ANDROID_DISCHARGE) -} diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt index 29d749ca5..04d2f80eb 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -521,14 +521,11 @@ object DataGen { event.generator.addProvider(event.includeServer(), matterData) val registrySetBuilder = RegistrySetBuilder() - .add(Registries.DAMAGE_TYPE, ::registerDamageTypes) .add(Registries.CONFIGURED_FEATURE, ::registerConfiguredFeatures) .add(Registries.PLACED_FEATURE, ::registerPlacedFeatures) event.generator.addProvider(event.includeServer(), DatapackBuiltinEntriesProvider(event.generator.packOutput, event.lookupProvider, registrySetBuilder, setOf(MOD_ID))) - registerDamageTypeTags(tagsProvider.damageTypes) - AddEnglishLanguage(languageProvider) AddRussianLanguage(languageProvider) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeatureType.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeatureType.kt index 4a3da406a..1203326ed 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeatureType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeatureType.kt @@ -30,7 +30,7 @@ open class AndroidFeatureType { } open val displayContents: ComponentContents by lazy { - TranslatableContents(displayId, null, arrayOf()) + TranslatableContents(displayId) } open val displayName: Component by lazy { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt index a95c85975..a6c8437a2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/feature/ShockwaveFeature.kt @@ -32,7 +32,7 @@ import ru.dbotthepony.mc.otm.onceServer import ru.dbotthepony.mc.otm.registry.AndroidFeatures import ru.dbotthepony.mc.otm.registry.MDamageTypes import ru.dbotthepony.mc.otm.registry.MSoundEvents -import ru.dbotthepony.mc.otm.registry.MatteryDamageSource +import ru.dbotthepony.mc.otm.registry.ShockwaveDamageSource import ru.dbotthepony.mc.otm.triggers.ShockwaveDamageMobTrigger import ru.dbotthepony.mc.otm.triggers.ShockwaveTrigger import kotlin.math.pow @@ -121,7 +121,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF seen.add(entity) val multiplier = (1.0 - distanceMultiplier).pow(0.5) - val source = MatteryDamageSource(ply.level.registryAccess().damageType(MDamageTypes.SHOCKWAVE), ply) + val source = ShockwaveDamageSource(ply) val damage = multiplier.toFloat() * AndroidConfig.Shockwave.DAMAGE.toFloat() * AndroidConfig.Shockwave.WARDEN_DAMAGE_MULT.toFloat() entity.hurt(source, damage) entity.deltaMovement += (entity.position - ply.position).normalize() * (multiplier * 3.0) @@ -137,7 +137,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF // don't hurt items, arrows, etc etc if (entity is LivingEntity) { - val source = MatteryDamageSource(ply.level.registryAccess().damageType(MDamageTypes.SHOCKWAVE), ply) + val source = ShockwaveDamageSource(ply) val damage = multiplier.toFloat() * AndroidConfig.Shockwave.DAMAGE.toFloat() entity.hurt(source, damage) entity.deltaMovement += (entity.position - ply.position).normalize() * (multiplier * 3.0) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt index 75fbde496..2fecb3d4c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt @@ -11,6 +11,7 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level +import net.minecraft.world.level.LevelAccessor import net.minecraft.world.level.block.BasePressurePlateBlock import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.SoundType @@ -21,7 +22,7 @@ import net.minecraft.world.level.material.Material import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.get -class TritaniumPressurePlate(color: DyeColor?) : BasePressurePlateBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).sound(SoundType.METAL).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), BlockSetType.IRON) { +class TritaniumPressurePlate(color: DyeColor?) : BasePressurePlateBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).sound(SoundType.METAL).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops()) { override fun appendHoverText( p_49816_: ItemStack, p_49817_: BlockGetter?, @@ -42,6 +43,14 @@ class TritaniumPressurePlate(color: DyeColor?) : BasePressurePlateBlock(Properti p_49915_.add(BlockStateProperties.POWERED) } + override fun playOnSound(level: LevelAccessor, pos: BlockPos) { + level.playSound(null, pos, SoundEvents.METAL_PRESSURE_PLATE_CLICK_ON, SoundSource.BLOCKS, 0.3f, 0.9f) + } + + override fun playOffSound(level: LevelAccessor, pos: BlockPos) { + level.playSound(null, pos, SoundEvents.METAL_PRESSURE_PLATE_CLICK_OFF, SoundSource.BLOCKS, 0.3f, 0.9f) + } + override fun getSignalStrength(level: Level, pos: BlockPos): Int { if (level.getEntitiesOfClass(ServerPlayer::class.java, TOUCH_AABB.move(pos)).isNotEmpty()) { return 15 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 a1e304372..b20cbcc60 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 @@ -9,7 +9,6 @@ import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.Entity import net.minecraft.world.entity.EquipmentSlot import net.minecraft.world.entity.LivingEntity -import net.minecraft.world.entity.boss.wither.WitherBoss import net.minecraft.world.entity.item.ItemEntity import net.minecraft.world.entity.player.Player import net.minecraft.world.level.Level @@ -20,13 +19,11 @@ import net.minecraft.world.level.levelgen.structure.BoundingBox import net.minecraft.world.phys.AABB import net.minecraft.world.phys.Vec3 import net.minecraftforge.common.Tags -import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.block.BlackHoleBlock import ru.dbotthepony.mc.otm.block.entity.tech.GravitationStabilizerBlockEntity import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.block.entity.blackhole.ExplosionQueue.Companion.queueForLevel import ru.dbotthepony.mc.otm.config.ServerConfig -import ru.dbotthepony.mc.otm.core.damageType import ru.dbotthepony.mc.otm.core.getExplosionResistance import ru.dbotthepony.mc.otm.core.gracefulBlockBreak import ru.dbotthepony.mc.otm.core.math.Decimal @@ -39,7 +36,6 @@ import ru.dbotthepony.mc.otm.core.nbt.map import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.matter.MatterManager import ru.dbotthepony.mc.otm.registry.MDamageTypes -import ru.dbotthepony.mc.otm.registry.MatteryDamageSource import ru.dbotthepony.mc.otm.triggers.BlackHoleTrigger import kotlin.math.pow import kotlin.math.roundToInt @@ -121,7 +117,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery } else { level.explode( null, - MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.HAWKING_RADIATION)), + MDamageTypes.HAWKING_RADIATION, null, blockPos.x + 0.5, blockPos.y + 0.5, @@ -240,7 +236,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery } if (distance < gravitationStrength + 1.0) { - val source = MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EVENT_HORIZON)) + val source = MDamageTypes.EVENT_HORIZON val damage = (gravitationStrength / distance).toFloat() if (living is Player) { @@ -258,7 +254,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery setDeltaMovement(item, center, distance) if (distance < gravitationStrength + 1) { - if (item.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EVENT_HORIZON)), (gravitationStrength / distance).toFloat()) && item.isRemoved) { + if (item.hurt(MDamageTypes.EVENT_HORIZON, (gravitationStrength / distance).toFloat()) && item.isRemoved) { if (item.item.item === MItems.GRAVITATIONAL_DISRUPTOR) { collapse() } else { 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 945de031e..3f3b8ba2b 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 @@ -6,7 +6,6 @@ import net.minecraft.nbt.DoubleTag import net.minecraft.nbt.ListTag import net.minecraft.nbt.Tag import net.minecraft.server.level.ServerLevel -import net.minecraft.util.datafix.DataFixTypes import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Explosion import net.minecraft.world.level.ExplosionDamageCalculator @@ -32,8 +31,6 @@ import ru.dbotthepony.mc.otm.core.math.rotateAroundAxis import ru.dbotthepony.mc.otm.core.math.up import ru.dbotthepony.mc.otm.core.nbt.set import ru.dbotthepony.mc.otm.registry.MDamageTypes -import ru.dbotthepony.mc.otm.registry.MRegistry -import ru.dbotthepony.mc.otm.registry.MatteryDamageSource import java.util.* import kotlin.collections.ArrayList import kotlin.collections.HashMap @@ -539,7 +536,7 @@ private data class QueuedExplosion(val x: Double, val y: Double, val z: Double, fun explode(level: Level) { level.explode( null, - MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.HAWKING_RADIATION)), + MDamageTypes.HAWKING_RADIATION, BlackHoleExplosionDamageCalculator, x, y, 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 f24900862..f88b67c25 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 @@ -128,7 +128,7 @@ class PoweredFurnaceBlockEntity( return JobContainer.success( ItemJob( - recipe.getResultItem(level.registryAccess()).copyWithCount(toProcess), + recipe.getResultItem().copyWithCount(toProcess), recipe.workTime * MachinesConfig.PLATE_PRESS.workTimeMultiplier, MachinesConfig.PLATE_PRESS.energyConsumption * toProcess, experience = recipe.experience.sample(level.random) * toProcess)) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt index 120b04377..ba7ca02f3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/MatteryPlayerCapability.kt @@ -114,7 +114,6 @@ import ru.dbotthepony.mc.otm.registry.AndroidFeatures import ru.dbotthepony.mc.otm.registry.MDamageTypes import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRegistry -import ru.dbotthepony.mc.otm.registry.MatteryDamageSource import ru.dbotthepony.mc.otm.triggers.AndroidResearchTrigger import ru.dbotthepony.mc.otm.triggers.AndroidTravelUnderwater import ru.dbotthepony.mc.otm.triggers.BecomeAndroidDeathTrigger @@ -532,7 +531,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial return JobContainer.noItem() } else { val actual = recipe.get() - val item = actual.value.assemble(input, level.registryAccess()) + val item = actual.value.assemble(input) input[0].shrink(1) input.setChanged(0) return JobContainer.success(ItemJob(item, actual.value.cookingTime.toDouble(), ExopackConfig.FURNACE_POWER_CONSUMPTION, actual.value.experience)) @@ -685,7 +684,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial becomeAndroid() if (!ply.abilities.invulnerable) - ply.hurt(MatteryDamageSource(ply.level.registryAccess().damageType(MDamageTypes.BECOME_ANDROID)), ply.maxHealth * 2) + ply.hurt(MDamageTypes.BECOME_ANDROID, ply.maxHealth * 2) } /** @@ -747,7 +746,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial becomeHumane() if (!ply.abilities.invulnerable) - ply.hurt(MatteryDamageSource(ply.level.registryAccess().damageType(MDamageTypes.BECOME_HUMANE)), ply.maxHealth * 2) + ply.hurt(MDamageTypes.BECOME_HUMANE, ply.maxHealth * 2) } /** @@ -1272,7 +1271,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial } if (androidEnergy.batteryLevel <= Decimal.TEN) { - if (--nextDischargeHurt <= 0 && ply.hurt(DamageSource(ply.level.registryAccess().damageType(MDamageTypes.ANDROID_DISCHARGE)), 1f)) { + if (--nextDischargeHurt <= 0 && ply.hurt(MDamageTypes.ANDROID_DISCHARGE, 1f)) { nextDischargeHurt = 20 } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt index d92ec4d20..e0646fce8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt @@ -107,13 +107,14 @@ class MGUIGraphics(val pose: PoseStack) { RenderSystem.setShader { GameRenderer.getPositionColorShader() } bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR) val matrix4f = pose.last().pose() - val colorEvent = ForgeHooksClient.onRenderTooltipColor(itemStack, pose, x, y, preEvent.font, mapped) - - TooltipRenderUtil.renderTooltipBackground(GuiComponent::fillGradient, matrix4f, bufferbuilder, x, y, i, j, 400, colorEvent.backgroundStart, colorEvent.backgroundEnd, colorEvent.borderStart, colorEvent.borderEnd) + TooltipRenderUtil.renderTooltipBackground(GuiComponent::fillGradient, matrix4f, bufferbuilder, x, y, i, j, 400) RenderSystem.enableDepthTest() + RenderSystem.disableTexture() RenderSystem.enableBlend() RenderSystem.defaultBlendFunc() BufferUploader.drawWithShader(bufferbuilder.end()) + RenderSystem.disableBlend() + RenderSystem.enableTexture() pose.translate(0.0f, 0.0f, 400.0f) var yCurrent = y @@ -152,7 +153,7 @@ class MGUIGraphics(val pose: PoseStack) { scale: Float = 1f, color: RGBAColor = RGBAColor.WHITE, drawShadow: Boolean = false, - displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, + displayMode: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0, shadowColor: RGBAColor = RGBAColor.BLACK, @@ -202,7 +203,7 @@ class MGUIGraphics(val pose: PoseStack) { scale: Float = 1f, color: RGBAColor = RGBAColor.WHITE, drawShadow: Boolean = false, - displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, + displayMode: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0, shadowColor: RGBAColor = RGBAColor.BLACK, @@ -252,7 +253,7 @@ class MGUIGraphics(val pose: PoseStack) { scale: Float = 1f, color: RGBAColor = RGBAColor.WHITE, drawShadow: Boolean = false, - displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, + displayMode: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0, shadowColor: RGBAColor = RGBAColor.BLACK, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/EditBoxPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/EditBoxPanel.kt index 5ddbc95f2..c2f003189 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/EditBoxPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/input/EditBoxPanel.kt @@ -34,11 +34,11 @@ open class EditBoxPanel( } override fun configureNew(widget: EditBox, recreation: Boolean) { - widget.isFocused = isFocusedThis + widget.changeFocus(isFocusedThis) } override fun onFocusChanged() { - widget?.isFocused = isFocusedThis + widget?.changeFocus(isFocusedThis) } override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { @@ -49,7 +49,7 @@ open class EditBoxPanel( override fun keyPressedInternal(key: Int, scancode: Int, mods: Int): Boolean { if (key == InputConstants.KEY_ESCAPE && widget?.isActive == true) { - widget?.isFocused = false + widget?.changeFocus(false) return true } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt index 390f880b2..10635cdcc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt @@ -32,7 +32,7 @@ abstract class AbstractSlotPanel> @JvmOverloads constru RenderSystem.setShader(GameRenderer::getPositionTexShader) if (!itemstack.isEmpty) { - screen.renderItemStack(graphics, itemstack, countOverride) + screen.renderItemStack(absoluteX + 1, absoluteY + 1, itemstack, countOverride) clearDepth(graphics) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt index a1a1989f5..820ce2a0a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt @@ -42,7 +42,7 @@ abstract class UserFilteredSlotPanel, out T : Slot>( if (slotFilter !== Items.AIR) { val itemStack = ItemStack(slotFilter!!, 1) - screen.renderItemStack(graphics, itemStack, null) + screen.renderItemStack(absoluteX + 1, absoluteY + 1, itemStack, null) clearDepth(graphics) graphics.renderRect(0f, 0f, width, height, color = SLOT_FILTER_COLOR) 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 989e501af..97e36e7eb 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 @@ -314,7 +314,7 @@ private class AndroidResearchButton( val stack = graphics.pose stack.pushPose() stack.translate(1f, 1f, 0f) - screen.renderItemStack(graphics, itemstack) + screen.renderItemStack(absoluteX + 1, absoluteY + 1, itemstack) stack.popPose() clearDepth(graphics) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt index b29c3359e..29c3c79fa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/adastra/AdAstraCompat.kt @@ -4,17 +4,15 @@ import earth.terrarium.ad_astra.AdAstra import earth.terrarium.ad_astra.common.data.Planet import earth.terrarium.ad_astra.common.data.PlanetData import earth.terrarium.ad_astra.common.item.armor.SpaceSuit -import earth.terrarium.ad_astra.common.registry.ModDamageSources +import earth.terrarium.ad_astra.common.registry.ModDamageSource import net.minecraft.world.entity.player.Player import net.minecraftforge.event.entity.living.LivingHurtEvent import net.minecraftforge.fml.ModList import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.config.ServerCompatConfig -import ru.dbotthepony.mc.otm.core.damageType -import ru.dbotthepony.mc.otm.registry.MDamageTypes +import ru.dbotthepony.mc.otm.registry.CosmicRaysDamageSource import ru.dbotthepony.mc.otm.registry.MItems -import ru.dbotthepony.mc.otm.registry.MatteryDamageSource val isAdAstraLoaded by lazy { ModList.get().isLoaded(AdAstra.MOD_ID) @@ -28,7 +26,7 @@ fun onDamageEvent(event: LivingHurtEvent) { if (ServerCompatConfig.AdAstra.ANDROIDS_DO_NOT_NEED_OXYGEN) { if (ply.matteryPlayer?.isAndroid != true) return - if (event.source.`is`(ModDamageSources.OXYGEN)) { + if (event.source == ModDamageSource.OXYGEN) { event.amount = 0f event.isCanceled = true } @@ -52,7 +50,7 @@ fun onMatteryTick(event: MatteryPlayerCapability.PostTick) { val yesTritanium = yesTritanium0 + yesTritanium1 if (rand.nextDouble() <= (noSpacesuits - yesTritanium) * ServerCompatConfig.AdAstra.ANDROID_COSMIC_RAYS_CHANCE) { - event.player.hurt(MatteryDamageSource(event.level.registryAccess().damageType(MDamageTypes.COSMIC_RAYS)), 1f) + event.player.hurt(CosmicRaysDamageSource(), 1f) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt index 2fbe1ff64..83122b2c1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/UnOverengineering.kt @@ -62,7 +62,7 @@ fun Codec.fromNetwork(buff: FriendlyByteBuf): V { } // 1.19 being 1.19 -fun TranslatableComponent(key: String, vararg values: Any): MutableComponent = MutableComponent.create(TranslatableContents(key, null, values)) +fun TranslatableComponent(key: String, vararg values: Any): MutableComponent = MutableComponent.create(TranslatableContents(key, *values)) fun TextComponent(value: String): MutableComponent = MutableComponent.create(LiteralContents(value)) fun IForgeRegistry.getKeyNullable(value: T): ResourceLocation? { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/PlasmaProjectile.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/PlasmaProjectile.kt index 0e3179247..719b67ca5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/entity/PlasmaProjectile.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/entity/PlasmaProjectile.kt @@ -12,10 +12,9 @@ import net.minecraft.world.phys.BlockHitResult import net.minecraft.world.phys.EntityHitResult import net.minecraft.world.phys.HitResult import net.minecraftforge.event.ForgeEventFactory -import ru.dbotthepony.mc.otm.core.damageType import ru.dbotthepony.mc.otm.registry.MDamageTypes import ru.dbotthepony.mc.otm.registry.MEntityTypes -import ru.dbotthepony.mc.otm.registry.MatteryDamageSource +import ru.dbotthepony.mc.otm.registry.PlasmaDamageSource class PlasmaProjectile(level: Level) : Projectile(MEntityTypes.PLASMA as EntityType, level) { var inflictor: ItemStack? = null @@ -38,7 +37,7 @@ class PlasmaProjectile(level: Level) : Projectile(MEntityTypes.PLASMA as EntityT super.onHitEntity(p_37259_) if (!level.isClientSide) { - p_37259_.entity.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.PLASMA), owner, inflictor), damage) + p_37259_.entity.hurt(PlasmaDamageSource(owner, inflictor), damage) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt index 4115d724e..bcbeae5b9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/BatteryItem.kt @@ -24,8 +24,8 @@ import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.config.ItemsConfig import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.math.Decimal +import ru.dbotthepony.mc.otm.registry.EMPDamageSource import ru.dbotthepony.mc.otm.registry.MDamageTypes -import ru.dbotthepony.mc.otm.registry.MatteryDamageSource import ru.dbotthepony.mc.otm.runIfClient import kotlin.math.roundToInt @@ -171,7 +171,7 @@ class CrudeBatteryItem : BatteryItem(ItemsConfig.Batteries.CRUDE) { mattery.androidEnergy.item = copyStack val extraDamageMult = level.random.nextFloat() - player.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EMP), inflictor = itemStack), 1.5f + extraDamageMult * 3.5f) + player.hurt(EMPDamageSource(inflictor = itemStack), 1.5f + extraDamageMult * 3.5f) val debuffDuration = 100 + (100 * (1f - extraDamageMult)).roundToInt() player.addEffect(MobEffectInstance(MobEffects.BLINDNESS, debuffDuration), player) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt index 9ecf82023..641910205 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt @@ -7,6 +7,7 @@ import net.minecraft.server.level.ServerLevel import net.minecraft.world.Container import net.minecraft.world.InteractionHand import net.minecraft.world.InteractionResult +import net.minecraft.world.damagesource.DamageSource import net.minecraft.world.entity.vehicle.AbstractMinecart import net.minecraft.world.entity.vehicle.MinecartChest import net.minecraft.world.item.* @@ -155,7 +156,7 @@ class ChestUpgraderItem : Item(Properties().stacksTo(1)) { } cart.clearContent() - (cart as AbstractMinecart).destroy(cart.damageSources().generic()) + (cart as AbstractMinecart).destroy(DamageSource.GENERIC) level.addFreshEntity(newCart) level.gameEvent(GameEvent.ENTITY_PLACE, event.pos, GameEvent.Context.of(event.entity, level.getBlockState(event.pos.below()))) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExopackProbeItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExopackProbeItem.kt index fd4a6c8a4..899549add 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExopackProbeItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/exopack/ExopackProbeItem.kt @@ -13,9 +13,8 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.onceServer import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.core.damageType +import ru.dbotthepony.mc.otm.registry.ExopackDamageSource import ru.dbotthepony.mc.otm.registry.MDamageTypes -import ru.dbotthepony.mc.otm.registry.MatteryDamageSource import ru.dbotthepony.mc.otm.runIfClient class ExopackProbeItem : Item(Properties().stacksTo(1).rarity(Rarity.EPIC)) { @@ -66,7 +65,7 @@ class ExopackProbeItem : Item(Properties().stacksTo(1).rarity(Rarity.EPIC)) { player.displayClientMessage(TranslatableComponent("otm.exopack.granted1").withStyle(ChatFormatting.GRAY), false) player.displayClientMessage(TranslatableComponent("otm.exopack.granted2").withStyle(ChatFormatting.GRAY), false) - player.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EXOPACK_PROBE), inflictor = copy), 10f) + player.hurt(ExopackDamageSource(inflictor = copy), 10f) for (i in 3 .. 7) { onceServer((i - 1) * 100) { 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 667e35616..017f0ae5a 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 @@ -39,8 +39,9 @@ import ru.dbotthepony.mc.otm.config.ToolsConfig import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.math.* import ru.dbotthepony.mc.otm.core.nbt.set +import ru.dbotthepony.mc.otm.registry.ExplosiveHammerDamageSource +import ru.dbotthepony.mc.otm.registry.HammerNailDamageSource import ru.dbotthepony.mc.otm.registry.MDamageTypes -import ru.dbotthepony.mc.otm.registry.MatteryDamageSource import ru.dbotthepony.mc.otm.triggers.NailedEntityTrigger import java.util.function.Predicate @@ -123,14 +124,14 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1) if (player.random.nextDouble() <= ToolsConfig.ExplosiveHammer.FLY_OFF_DAMAGE_CHANCE) { player.invulnerableTime = 0 val dmg = ToolsConfig.ExplosiveHammer.FLY_OFF_MIN_DAMAGE + player.random.nextDouble() * (ToolsConfig.ExplosiveHammer.FLY_OFF_MAX_DAMAGE - ToolsConfig.ExplosiveHammer.FLY_OFF_MIN_DAMAGE) - player.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EXPLOSIVE_HAMMER), inflictor = copy), dmg.toFloat()) + player.hurt(ExplosiveHammerDamageSource(inflictor = copy), dmg.toFloat()) } itemStack.shrink(itemStack.count) } else if (player.random.nextDouble() <= ToolsConfig.ExplosiveHammer.SELF_HARM_CHANCE) { player.invulnerableTime = 0 val dmg = ToolsConfig.ExplosiveHammer.SELF_HARM_MIN_DAMAGE + player.random.nextDouble() * (ToolsConfig.ExplosiveHammer.SELF_HARM_MAX_DAMAGE - ToolsConfig.ExplosiveHammer.SELF_HARM_MIN_DAMAGE) - player.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EXPLOSIVE_HAMMER), inflictor = copy), dmg.toFloat()) + player.hurt(ExplosiveHammerDamageSource(inflictor = copy), dmg.toFloat()) } } } @@ -205,7 +206,7 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1) val rayBox = aabb.move(rayPos) val entities = level.getEntities(null, rayBox) { it is LivingEntity && it.isAlive && !it.isSpectator && hitEntities.add(it) } as List - val damageSource = MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.HAMMER_NAIL), attacker, itemStack) + val damageSource = HammerNailDamageSource(attacker, itemStack) for (it in entities) { val damage = canTravel * ToolsConfig.ExplosiveHammer.TRAVEL_DAMAGE_MULT @@ -257,12 +258,12 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1) if (attacker.random.nextDouble() <= ToolsConfig.ExplosiveHammer.FLY_OFF_DAMAGE_CHANCE) { attacker.invulnerableTime = 0 val dmg = ToolsConfig.ExplosiveHammer.FLY_OFF_MIN_DAMAGE + attacker.random.nextDouble() * (ToolsConfig.ExplosiveHammer.FLY_OFF_MAX_DAMAGE - ToolsConfig.ExplosiveHammer.FLY_OFF_MIN_DAMAGE) - attacker.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EXPLOSIVE_HAMMER), inflictor = copy), dmg.toFloat()) + attacker.hurt(ExplosiveHammerDamageSource(inflictor = copy), dmg.toFloat()) } } else if (attacker.random.nextDouble() <= ToolsConfig.ExplosiveHammer.SELF_HARM_CHANCE) { attacker.invulnerableTime = 0 val dmg = ToolsConfig.ExplosiveHammer.SELF_HARM_MIN_DAMAGE + attacker.random.nextDouble() * (ToolsConfig.ExplosiveHammer.SELF_HARM_MAX_DAMAGE - ToolsConfig.ExplosiveHammer.SELF_HARM_MIN_DAMAGE) - attacker.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EXPLOSIVE_HAMMER), inflictor = copy), dmg.toFloat()) + attacker.hurt(ExplosiveHammerDamageSource(inflictor = copy), dmg.toFloat()) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt index 9c1cc83f7..177169b3a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt @@ -6,7 +6,6 @@ import net.minecraft.ChatFormatting import net.minecraft.core.BlockPos import net.minecraft.nbt.CompoundTag import net.minecraft.network.chat.Component -import net.minecraft.tags.BlockTags import net.minecraft.world.entity.EquipmentSlot import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.ai.attributes.Attribute @@ -40,12 +39,12 @@ import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.core.math.Decimal import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue import ru.dbotthepony.mc.otm.core.TranslatableComponent -import ru.dbotthepony.mc.otm.core.damageType import ru.dbotthepony.mc.otm.core.math.defineDecimal import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.math.nextVariance import ru.dbotthepony.mc.otm.core.orNull import ru.dbotthepony.mc.otm.core.util.WriteOnce +import ru.dbotthepony.mc.otm.registry.EMPDamageSource import ru.dbotthepony.mc.otm.registry.MDamageTypes import ru.dbotthepony.mc.otm.registry.MatteryDamageSource @@ -108,7 +107,7 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani victim.matteryPlayer?.let { if (it.isAndroid) { victim.invulnerableTime = 0 - victim.hurt(MatteryDamageSource(attacker.level.registryAccess().damageType(MDamageTypes.EMP), attacker, itemStack), 8f) + victim.hurt(EMPDamageSource(attacker, itemStack), 8f) } } @@ -121,7 +120,7 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani victim.matteryPlayer?.let { if (it.isAndroid && it.androidEnergy.extractEnergyExact(ENERGY_ZAP, false)) { it.androidEnergy.extractEnergy(attacker.level.random.nextVariance(ENERGY_ZAP_VARIANCE), false) - victim.hurt(MatteryDamageSource(attacker.level.registryAccess().damageType(MDamageTypes.EMP), attacker, itemStack), 8f) + victim.hurt(EMPDamageSource(attacker, itemStack), 8f) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 0ebac3639..40480d309 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -45,7 +45,7 @@ import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.item.crafting.Recipe import net.minecraft.world.item.crafting.RecipeType -import net.minecraft.world.item.crafting.SmithingTransformRecipe +import net.minecraft.world.item.crafting.UpgradeRecipe import net.minecraft.world.level.ItemLike import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.crafting.IShapedRecipe @@ -451,13 +451,13 @@ object MatterManager { stream = stream.filter { it.value.ingredients.stream().flatMap { it.items.stream() }.noneMatch { it.isDamageableItem } } } - stream.filter { it.value.getResultItem(server.registryAccess()).isNotEmpty }.map { + stream.filter { it.value.getResultItem().isNotEmpty }.map { try { ResolvedRecipe( it.value.ingredients.stream() .filter { !it.isActuallyEmpty } .map { it.items.stream().filter { it.isNotEmpty }.map(::RecipeEntry) }, - ImmutableStack(it.value.getResultItem(server.registryAccess())), + ImmutableStack(it.value.getResultItem()), isCritical = isCritical, name = it.id, allowBacktrack = allowBacktrack @@ -500,7 +500,7 @@ object MatterManager { stream.map { try { // avoid reality snap when recipe has no output - val resultItem = it.value.getResultItem(server.registryAccess()) + val resultItem = it.value.getResultItem() if (resultItem.isEmpty) { null @@ -549,7 +549,7 @@ object MatterManager { for (item in it.value.ingredients[c].items) { container[c] = item - if (!it.value.assemble(container, server.registryAccess()).isEmpty) { + if (!it.value.assemble(container).isEmpty) { val residue = it.value.getRemainingItems(container) val thisResidue = residue[c] @@ -604,13 +604,13 @@ object MatterManager { val allowBacktrack = data["allow_backtrack"]?.asBoolean ?: true var stream = server.recipeManager.byType(findRecipeType).values.stream().filter { !it.value.isIncomplete } - stream = stream.filter { it.value is SmithingTransformRecipe } + stream = stream.filter { it.value is UpgradeRecipe } - stream.filter { it.value.getResultItem(server.registryAccess()).isNotEmpty }.map { + stream.filter { it.value.getResultItem().isNotEmpty }.map { try { val ingredients = ArrayList() - val recipe = it.value as SmithingTransformRecipe + val recipe = it.value as UpgradeRecipe ingredients.add(recipe.base) ingredients.add(recipe.addition) @@ -619,7 +619,7 @@ object MatterManager { ingredients.stream() .filter { !it.isActuallyEmpty } .map { it.items.stream().filter { it.isNotEmpty }.map(::RecipeEntry) }, - ImmutableStack(it.value.getResultItem(server.registryAccess())), + ImmutableStack(it.value.resultItem), isCritical = isCritical, name = it.id, allowBacktrack = allowBacktrack diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatteryCookingRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatteryCookingRecipe.kt index 22aeea670..198701d4c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatteryCookingRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatteryCookingRecipe.kt @@ -68,11 +68,11 @@ abstract class MatteryCookingRecipe( override fun isIncomplete(): Boolean = input.isActuallyEmpty || output.isActuallyEmpty - override fun assemble(container: Container, registry: RegistryAccess): ItemStack = outputStack.copy() + override fun assemble(container: Container): ItemStack = outputStack.copy() override fun canCraftInDimensions(width: Int, height: Int): Boolean = true - override fun getResultItem(registry: RegistryAccess): ItemStack = outputStack + override fun getResultItem(): ItemStack = outputStack abstract fun toFinished(): FinishedRecipe } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/DamageSources.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/DamageSources.kt new file mode 100644 index 000000000..84fd8fc17 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/DamageSources.kt @@ -0,0 +1,222 @@ +package ru.dbotthepony.mc.otm.registry + +import net.minecraft.network.chat.Component +import net.minecraft.world.damagesource.DamageSource +import net.minecraft.world.entity.Entity +import net.minecraft.world.entity.LivingEntity +import net.minecraft.world.item.ItemStack +import net.minecraft.world.phys.Vec3 +import ru.dbotthepony.mc.otm.core.TranslatableComponent + +class ImmutableDamageSource(private val parent: DamageSource) : DamageSource(parent.msgId) { + override fun equals(other: Any?): Boolean { + return parent == other + } + + override fun hashCode(): Int { + return parent.hashCode() + } + + override fun toString(): String { + return parent.toString() + } + + override fun isProjectile(): Boolean { + return parent.isProjectile + } + + override fun setProjectile(): DamageSource { + throw UnsupportedOperationException() + } + + override fun isExplosion(): Boolean { + return parent.isExplosion + } + + override fun setExplosion(): DamageSource { + throw UnsupportedOperationException() + } + + override fun isBypassArmor(): Boolean { + return parent.isBypassArmor + } + + override fun isDamageHelmet(): Boolean { + return parent.isDamageHelmet + } + + override fun getFoodExhaustion(): Float { + return parent.foodExhaustion + } + + override fun isBypassInvul(): Boolean { + return parent.isBypassInvul + } + + override fun isBypassMagic(): Boolean { + return parent.isBypassMagic + } + + override fun getDirectEntity(): Entity? { + return parent.directEntity + } + + override fun getEntity(): Entity? { + return parent.entity + } + + override fun bypassArmor(): DamageSource { + throw UnsupportedOperationException() + } + + override fun damageHelmet(): DamageSource { + throw UnsupportedOperationException() + } + + override fun bypassInvul(): DamageSource { + throw UnsupportedOperationException() + } + + override fun bypassMagic(): DamageSource { + throw UnsupportedOperationException() + } + + override fun setIsFire(): DamageSource { + throw UnsupportedOperationException() + } + + override fun setNoAggro(): DamageSource { + throw UnsupportedOperationException() + } + + override fun getLocalizedDeathMessage(p_19343_: LivingEntity): Component { + return super.getLocalizedDeathMessage(p_19343_) + } + + override fun isFire(): Boolean { + return parent.isFire + } + + override fun isNoAggro(): Boolean { + return parent.isNoAggro + } + + override fun getMsgId(): String { + return parent.getMsgId() + } + + override fun setScalesWithDifficulty(): DamageSource { + throw UnsupportedOperationException() + } + + override fun scalesWithDifficulty(): Boolean { + return parent.scalesWithDifficulty() + } + + override fun isMagic(): Boolean { + return parent.isMagic + } + + override fun setMagic(): DamageSource { + throw UnsupportedOperationException() + } + + override fun isFall(): Boolean { + return parent.isFall + } + + override fun setIsFall(): DamageSource { + throw UnsupportedOperationException() + } + + override fun isCreativePlayer(): Boolean { + return parent.isCreativePlayer + } + + override fun getSourcePosition(): Vec3? { + return parent.sourcePosition + } +} + +abstract class MatteryDamageSource(name: String, private val entity: Entity? = null, val inflictor: ItemStack? = null) : DamageSource(name) { + override fun getLocalizedDeathMessage(victim: LivingEntity): Component { + val itemStack = inflictor ?: (entity as LivingEntity?)?.mainHandItem ?: ItemStack.EMPTY + + if (!itemStack.isEmpty && itemStack.hasCustomHoverName()) { + return TranslatableComponent("death.attack.$msgId.player.item", victim.displayName, entity!!.displayName, itemStack.displayName) + } + + if (entity != null) { + return TranslatableComponent("death.attack.$msgId.player", victim.displayName, entity.displayName) + } + + return TranslatableComponent("death.attack.$msgId", victim.displayName) + } + + final override fun getEntity(): Entity? { + return entity + } +} + +class EMPDamageSource(entity: Entity? = null, inflictor: ItemStack? = null) : MatteryDamageSource(MRegistry.DAMAGE_EMP_NAME, entity, inflictor) { + init { + bypassArmor() + bypassMagic() + } + + override fun scalesWithDifficulty(): Boolean { + return false + } +} + +class ExopackDamageSource(entity: Entity? = null, inflictor: ItemStack? = null) : MatteryDamageSource(MRegistry.DAMAGE_EXOPACK_PROBE_ID, entity, inflictor) { + init { + bypassArmor() + bypassMagic() + bypassEnchantments() + } + + override fun scalesWithDifficulty(): Boolean { + return false + } +} + +class CosmicRaysDamageSource(entity: Entity? = null, inflictor: ItemStack? = null) : MatteryDamageSource(MRegistry.DAMAGE_COSMIC_RAYS_NAME, entity, inflictor) { + init { + bypassArmor() + bypassMagic() + bypassEnchantments() + } + + override fun scalesWithDifficulty(): Boolean { + return false + } +} + +class ExplosiveHammerDamageSource(entity: Entity? = null, inflictor: ItemStack? = null) : MatteryDamageSource(MRegistry.DAMAGE_EXPLOSIVE_HAMMER_NAME, entity, inflictor) { + override fun scalesWithDifficulty(): Boolean { + return false + } +} + +class ShockwaveDamageSource(entity: Entity? = null, inflictor: ItemStack? = null) : MatteryDamageSource(MRegistry.DAMAGE_SHOCKWAVE_NAME, entity, inflictor) { + init { + bypassArmor() + } + + override fun scalesWithDifficulty(): Boolean { + return false + } +} + +class PlasmaDamageSource(entity: Entity? = null, inflictor: ItemStack? = null) : MatteryDamageSource(MRegistry.DAMAGE_PLASMA_NAME, entity, inflictor) { + override fun scalesWithDifficulty(): Boolean { + return false + } +} + +class HammerNailDamageSource(entity: Entity? = null, inflictor: ItemStack? = null) : MatteryDamageSource(MRegistry.DAMAGE_HAMMER_NAIL_NAME, entity, inflictor) { + override fun scalesWithDifficulty(): Boolean { + return false + } +} 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 4fe772498..ef5561e86 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.registry import net.minecraft.ChatFormatting import net.minecraft.core.BlockPos import net.minecraft.network.chat.Component +import net.minecraft.sounds.SoundEvents import net.minecraft.util.valueproviders.UniformInt import net.minecraft.world.entity.Entity import net.minecraft.world.entity.EntityType @@ -25,11 +26,8 @@ import net.minecraft.world.level.block.TrapDoorBlock import net.minecraft.world.level.block.WallBlock import net.minecraft.world.level.block.state.BlockBehaviour import net.minecraft.world.level.block.state.BlockState -import net.minecraft.world.level.block.state.properties.BlockSetType -import net.minecraft.world.level.block.state.properties.NoteBlockInstrument import net.minecraft.world.level.material.Material import net.minecraft.world.level.material.MaterialColor -import net.minecraft.world.level.material.PushReaction import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.ForgeRegistries @@ -229,7 +227,7 @@ object MBlocks { .noOcclusion() .destroyTime(3f) .requiresCorrectToolForDrops(), - BlockSetType.IRON + SoundEvents.IRON_DOOR_CLOSE, SoundEvents.IRON_DOOR_OPEN ) { override fun appendHoverText( p_49816_: ItemStack, @@ -264,7 +262,7 @@ object MBlocks { .noOcclusion().destroyTime(3f) .requiresCorrectToolForDrops() .isValidSpawn { _: BlockState, _: BlockGetter, _: BlockPos, _: EntityType<*>? -> false }, - BlockSetType.IRON + SoundEvents.IRON_DOOR_CLOSE, SoundEvents.IRON_DOOR_OPEN ) { override fun appendHoverText( p_49816_: ItemStack, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MDamageTypes.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MDamageTypes.kt index 65a92be76..680e58bfa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MDamageTypes.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MDamageTypes.kt @@ -3,16 +3,16 @@ package ru.dbotthepony.mc.otm.registry import net.minecraft.world.damagesource.DamageSource object MDamageTypes { - val BECOME_ANDROID = DamageSource("become_android") - val BECOME_HUMANE = DamageSource("become_humane") - val EVENT_HORIZON = DamageSource("event_horizon") - val HAWKING_RADIATION = DamageSource("hawking_radiation") - val EXOPACK_PROBE = DamageSource("exopack_probe") - val EMP = DamageSource("emp") - val SHOCKWAVE = DamageSource("shockwave") - val PLASMA = DamageSource("plasma") - val COSMIC_RAYS = DamageSource("cosmic_rays") - val EXPLOSIVE_HAMMER = DamageSource("explosive_hammer") - val HAMMER_NAIL = DamageSource("hammer_nail") - val ANDROID_DISCHARGE = DamageSource("android_discharge") + val BECOME_ANDROID = ImmutableDamageSource(DamageSource("become_android").bypassArmor().bypassInvul().bypassMagic().bypassEnchantments()) + val BECOME_HUMANE = ImmutableDamageSource(DamageSource("become_humane").bypassArmor().bypassInvul().bypassMagic().bypassEnchantments()) + val EVENT_HORIZON = ImmutableDamageSource(DamageSource("event_horizon").bypassArmor()) + val HAWKING_RADIATION = ImmutableDamageSource(DamageSource("hawking_radiation").bypassArmor()) + val EXOPACK_PROBE = ImmutableDamageSource(DamageSource("exopack_probe").bypassArmor().bypassMagic().bypassEnchantments()) + val EMP = ImmutableDamageSource(DamageSource("emp").bypassArmor()) + val SHOCKWAVE = ImmutableDamageSource(DamageSource("shockwave").bypassArmor()) + val PLASMA = ImmutableDamageSource(DamageSource("plasma")) + val COSMIC_RAYS = ImmutableDamageSource(DamageSource("cosmic_rays").bypassArmor().bypassMagic().bypassEnchantments()) + val EXPLOSIVE_HAMMER = ImmutableDamageSource(DamageSource("explosive_hammer")) + val HAMMER_NAIL = ImmutableDamageSource(DamageSource("hammer_nail")) + val ANDROID_DISCHARGE = ImmutableDamageSource(DamageSource("android_discharge").bypassArmor().bypassInvul().bypassMagic().bypassEnchantments()) } 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 931960ee0..211e305d3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -221,6 +221,18 @@ object MRegistry { WallBlock(BlockBehaviour.Properties.copy(TRITANIUM_STRIPED_BLOCK.getBlock(colorA, colorB))) }) + const val DAMAGE_BECOME_ANDROID_ID = "otm_become_android" + const val DAMAGE_BECOME_HUMANE_ID = "otm_become_humane" + const val DAMAGE_EVENT_HORIZON_ID = "otm_event_horizon" + const val DAMAGE_HAWKING_RADIATION_ID = "otm_hawking_radiation" + const val DAMAGE_EXOPACK_PROBE_ID = "otm_exopack_probe" + const val DAMAGE_EMP_NAME = "otm_emp" + const val DAMAGE_SHOCKWAVE_NAME = "otm_shockwave" + const val DAMAGE_PLASMA_NAME = "otm_plasma" + const val DAMAGE_COSMIC_RAYS_NAME = "otm_cosmic_rays" + const val DAMAGE_EXPLOSIVE_HAMMER_NAME = "otm_explosive_hammer" + const val DAMAGE_HAMMER_NAIL_NAME = "otm_hammer_nail" + private fun registerEvent(event: RegisterEvent) { // mojang moment diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MatteryDamageSource.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MatteryDamageSource.kt deleted file mode 100644 index 697463316..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MatteryDamageSource.kt +++ /dev/null @@ -1,35 +0,0 @@ -package ru.dbotthepony.mc.otm.registry - -import net.minecraft.core.Holder -import net.minecraft.network.chat.Component -import net.minecraft.world.damagesource.DamageSource -import net.minecraft.world.damagesource.DamageType -import net.minecraft.world.entity.Entity -import net.minecraft.world.entity.LivingEntity -import net.minecraft.world.item.ItemStack -import net.minecraft.world.phys.Vec3 -import ru.dbotthepony.mc.otm.core.TranslatableComponent - -class MatteryDamageSource( - type: Holder, - entity: Entity? = null, - inflictor: ItemStack? = null, - entityInflictor: Entity? = null, - pos: Vec3? = null -) : DamageSource(type, entity, entityInflictor, pos) { - val inflictor = inflictor?.copy() - - override fun getLocalizedDeathMessage(victim: LivingEntity): Component { - val itemStack = inflictor ?: (entity as? LivingEntity)?.mainHandItem ?: ItemStack.EMPTY - - if (!itemStack.isEmpty && itemStack.hasCustomHoverName()) { - return TranslatableComponent("death.attack.$msgId.player.item", victim.displayName, entity!!.displayName, itemStack.displayName) - } - - if (entity != null) { - return TranslatableComponent("death.attack.$msgId.player", victim.displayName, entity!!.displayName) - } - - return TranslatableComponent("death.attack.$msgId", victim.displayName) - } -} diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index bea3566fc..cdac62ced 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -190,3 +190,10 @@ public net.minecraft.advancements.critereon.DamagePredicate f_24903_ # dealtDama public net.minecraft.advancements.critereon.DamagePredicate f_24905_ # sourceEntity public net.minecraft.advancements.critereon.DamagePredicate f_24904_ # takenDamage public net.minecraft.advancements.critereon.DamagePredicate f_24907_ # type + +public net.minecraft.world.item.crafting.UpgradeRecipe f_44519_ # addition +public net.minecraft.world.item.crafting.UpgradeRecipe f_44518_ # base +public net.minecraft.world.item.crafting.UpgradeRecipe f_44521_ # id +public net.minecraft.world.item.crafting.UpgradeRecipe f_44520_ # result + +public net.minecraft.client.gui.components.AbstractWidget m_93696_()Z # isFocused From a5ba27cf6386c2e779db7e01e706838455abbc3d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 22:04:26 +0700 Subject: [PATCH 1192/1199] More backporting --- .../mc/otm/block/tech/PhantomAttractorBlock.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt index b654f1e0a..189be0d22 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt @@ -26,6 +26,7 @@ import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.AABB import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape +import net.minecraftforge.common.ForgeHooks import net.minecraftforge.event.ForgeEventFactory import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.getShapeForEachState @@ -63,7 +64,12 @@ class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of(Material.METAL ) { val phantom = EntityType.PHANTOM.create(level) ?: continue phantom.moveTo(spawnPos, 0.0f, 0.0f) - groupData = ForgeEventFactory.onFinalizeSpawn(phantom, level, level.getCurrentDifficultyAt(spawnPos), MobSpawnType.SPAWNER, groupData, null) + + if (ForgeHooks.canEntitySpawn(phantom, level, spawnPos.x.toDouble(), spawnPos.y.toDouble(), spawnPos.z.toDouble(), null, MobSpawnType.SPAWNER) == -1) { + continue + } + + groupData = phantom.finalizeSpawn(level, level.getCurrentDifficultyAt(spawnPos), MobSpawnType.SPAWNER, groupData, null) level.addFreshEntityWithPassengers(phantom) } } From 41ce2841b19ba8b6d30a1bc626db5c9e32b2762f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 22:04:53 +0700 Subject: [PATCH 1193/1199] More backporting --- .../ru/dbotthepony/mc/otm/item/tool/ExplosiveHammerItem.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 017f0ae5a..da381bb92 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 @@ -176,7 +176,7 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1) // так как у меня алгоритм "своеобразный", я изобрету велосипед ибо я такой нехороший и непослушный // Трассировка луча используя наивный метод while (canTravel > 0.0) { - val blockPos = BlockPos.containing(rayPos) + val blockPos = BlockPos(rayPos) if (blockPos != lastBlockPos) { if (!level.hasChunkAt(blockPos)) break From b9f6b659003250170a13fdb1780630291f1d0208 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 22:12:39 +0700 Subject: [PATCH 1194/1199] Make main source set compile against 1.19.3 --- .../dbotthepony/mc/otm/client/render/RenderExtensions.kt | 7 +++++++ .../mc/otm/client/render/blockentity/FluidTankRenderer.kt | 1 + 2 files changed, 8 insertions(+) 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 1d08afc62..432d88021 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 @@ -5,6 +5,7 @@ import com.mojang.blaze3d.vertex.Tesselator import com.mojang.blaze3d.vertex.VertexConsumer import net.minecraft.core.Vec3i import org.joml.Matrix4f +import org.joml.Quaternionf import org.joml.Vector3f import ru.dbotthepony.mc.otm.core.math.IAngle import ru.dbotthepony.mc.otm.core.math.RGBAColor @@ -52,6 +53,12 @@ fun PoseStack.rotateAroundPoint(point: Vector3f, rotation: IAngle) { // last.normal().mul(rotation.forward().rotateAroundThis(rotation)) } +fun PoseStack.rotateAround(rotationMatrix: Quaternionf, x: Float, y: Float, z: Float) { + val pose = last + pose.pose.rotateAround(rotationMatrix, x, y, z) + pose.normal().rotate(rotationMatrix) +} + fun PoseStack.translation(): Vector3f { return last().pose().translation } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/FluidTankRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/FluidTankRenderer.kt index 3159ae3ca..c36fb08dd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/FluidTankRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/FluidTankRenderer.kt @@ -18,6 +18,7 @@ import net.minecraftforge.fluids.FluidStack import net.minecraftforge.fluids.capability.IFluidHandler import ru.dbotthepony.mc.otm.block.entity.decorative.FluidTankBlockEntity import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.client.render.rotateAround import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.linearInterpolation From 2aa084290b7b587244c707e33b9f227a59d91a45 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 22:15:32 +0700 Subject: [PATCH 1195/1199] Make mod compile against 1.19.3 --- .../mc/otm/datagen/items/ItemModels.kt | 2 +- .../datagen/items/MatteryItemModelProvider.kt | 23 ------------------- .../datagen/recipes/CraftingTableRecipes.kt | 2 +- .../dbotthepony/mc/otm/datagen/tags/Tags.kt | 6 ----- .../mc/otm/datagen/tags/TagsProvider.kt | 1 - 5 files changed, 2 insertions(+), 32 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt index e29bed539..8ef92f7c8 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/ItemModels.kt @@ -87,7 +87,7 @@ fun addItemModels(provider: MatteryItemModelProvider) { provider.handheld(MItems.TRITANIUM_TOOLS) provider.armorColored(MItems.TRITANIUM_ARMOR) - provider.armorWithTrims(MItems.SIMPLE_TRITANIUM_ARMOR) + provider.generated(MItems.SIMPLE_TRITANIUM_ARMOR) provider.handheld(MItems.CHEST_UPGRADER) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt index ceeb59adf..7c5a3f187 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/items/MatteryItemModelProvider.kt @@ -82,29 +82,6 @@ class MatteryItemModelProvider(event: GatherDataEvent) : ItemModelProvider(event } } - fun armorWithTrims(item: Item, texture: ResourceLocation) = exec { - val mainModel = withExistingParent(item.registryName!!.path, GENERATED).texture("layer0", texture) - - if (item is ArmorItem) { - for ((i, material) in ARMOR_TRIM_MATERIALS.withIndex()) { - val trimLocation = ResourceLocation("trims/items/${item.type.getName()}_trim_${material}") - existingFileHelper.trackGenerated(trimLocation, PackType.CLIENT_RESOURCES, ".png", "textures") - - val overrideModel = withExistingParent("${item.registryName!!.path}_${material}_trim", GENERATED) - .texture("layer0", texture) - .texture("layer1", trimLocation) - - mainModel.override() - .predicate(ItemModelGenerators.TRIM_TYPE_PREDICATE_ID, (i + 1).toFloat() / ARMOR_TRIM_MATERIALS.size.toFloat()) - .model(overrideModel) - .end() - } - } - } - - fun armorWithTrims(vararg items: Item) = items.forEach { armorWithTrims(it, modLocation("item/${it.registryName!!.path}")) } - fun armorWithTrims(items: Collection) = items.forEach { armorWithTrims(it, modLocation("item/${it.registryName!!.path}")) } - fun armorColored(item: Item) = exec { withExistingParent(item.registryName!!.path, GENERATED) .texture("layer0", modLocation("item/${item.registryName!!.path}_base")) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt index db790ea62..b2561618f 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/recipes/CraftingTableRecipes.kt @@ -462,7 +462,7 @@ fun addCraftingTableRecipes(consumer: RecipeOutput) { .build(consumer) MatteryRecipe(MItems.PAINTER, category = machinesCategory) - .row(Items.BRUSH, Items.BUCKET, Items.BUCKET) + .row(Tags.Items.RODS_WOODEN, Items.BUCKET, Items.BUCKET) .row(MItemTags.IRON_PLATES, Items.BUCKET, MItemTags.IRON_PLATES) .row(MItemTags.IRON_PLATES, MItemTags.CRAFTING_TABLES, MItemTags.IRON_PLATES) .unlockedBy(Tags.Items.DYES) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt index e70e7c839..61702d244 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/Tags.kt @@ -119,14 +119,8 @@ fun addTags(tagsProvider: TagsProvider) { tagsProvider.items.Appender(Tags.Items.ARMORS_BOOTS) .add(MItems.TRITANIUM_BOOTS, MItems.SIMPLE_TRITANIUM_BOOTS) - tagsProvider.items.Appender(ItemTags.TRIMMABLE_ARMOR).add(MItems.SIMPLE_TRITANIUM_ARMOR) tagsProvider.items.Appender(ItemTags.FREEZE_IMMUNE_WEARABLES).add(MItems.TRITANIUM_ARMOR) - tagsProvider.items.Appender(ItemTags.SWORDS).add(MItems.TRITANIUM_SWORD).add(MItems.ENERGY_SWORD) - tagsProvider.items.Appender(ItemTags.AXES).add(MItems.TRITANIUM_AXE) - tagsProvider.items.Appender(ItemTags.PICKAXES).add(MItems.TRITANIUM_PICKAXE) - tagsProvider.items.Appender(ItemTags.SHOVELS).add(MItems.TRITANIUM_SHOVEL) - tagsProvider.items.Appender(ItemTags.SHOVELS).add(MItems.TRITANIUM_HOE) tagsProvider.items.Appender(Tags.Items.SHEARS).add(MItems.TRITANIUM_SHEARS) tagsProvider.items.Appender(Tags.Items.TOOLS_SHIELDS).add(MItems.TRITANIUM_SHIELD) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt index b40a2b563..295439ac2 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/tags/TagsProvider.kt @@ -168,7 +168,6 @@ class TagsProvider(private val event: GatherDataEvent) { val blocks = Delegate(ForgeRegistries.BLOCKS) val items = Delegate(ForgeRegistries.ITEMS) val mobEffects = Delegate(ForgeRegistries.MOB_EFFECTS) - val damageTypes = Delegate(Registries.DAMAGE_TYPE) val androidImmuneEffects = mobEffects.Appender(MatteryPlayerCapability.ANDROID_IMMUNE_EFFECTS) From 2506f0fe0e9f9139d3e43ef542cd9a3920d71d5d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 22:17:23 +0700 Subject: [PATCH 1196/1199] Fix missed translatable contents --- .../kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt index f4eb7a76a..931d545c0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt @@ -371,7 +371,7 @@ class AndroidResearchType( } val displayContents: ComponentContents by lazy { - TranslatableContents(displayId, null, arrayOf()) + TranslatableContents(displayId) } val displayName: Component get() { From 9cf66e443ea21a44fc12d81b4b5dbd9e7452d8ea Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 22:24:15 +0700 Subject: [PATCH 1197/1199] Fix items being rendered with 1 pixel offset --- .../mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt | 2 +- .../mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt | 2 +- .../mc/otm/client/screen/tech/AndroidStationScreen.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt index 10635cdcc..ea53cd915 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt @@ -32,7 +32,7 @@ abstract class AbstractSlotPanel> @JvmOverloads constru RenderSystem.setShader(GameRenderer::getPositionTexShader) if (!itemstack.isEmpty) { - screen.renderItemStack(absoluteX + 1, absoluteY + 1, itemstack, countOverride) + screen.renderItemStack(absoluteX, absoluteY, itemstack, countOverride) clearDepth(graphics) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt index 820ce2a0a..e8dcf674c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt @@ -42,7 +42,7 @@ abstract class UserFilteredSlotPanel, out T : Slot>( if (slotFilter !== Items.AIR) { val itemStack = ItemStack(slotFilter!!, 1) - screen.renderItemStack(absoluteX + 1, absoluteY + 1, itemStack, null) + screen.renderItemStack(absoluteX, absoluteY, itemStack, null) clearDepth(graphics) graphics.renderRect(0f, 0f, width, height, color = SLOT_FILTER_COLOR) 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 97e36e7eb..f4067d725 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 @@ -314,7 +314,7 @@ private class AndroidResearchButton( val stack = graphics.pose stack.pushPose() stack.translate(1f, 1f, 0f) - screen.renderItemStack(absoluteX + 1, absoluteY + 1, itemstack) + screen.renderItemStack(absoluteX, absoluteY, itemstack) stack.popPose() clearDepth(graphics) From ad76b4cabcb65ba35a53fddd427ca7a3c7cf69f2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 22:41:58 +0700 Subject: [PATCH 1198/1199] Fix tooltips being wrongly positioned --- .../mc/otm/client/render/MGUIGraphics.kt | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt index dfa97516c..43a8d851e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt @@ -92,15 +92,26 @@ class MGUIGraphics(val pose: PoseStack) { val preEvent = ForgeHooksClient.onRenderTooltipPre(itemStack, pose, x, y, width, height, mapped, font, font) if (preEvent.isCanceled) return - var i = 0 - var j = if (lines.size == 1) -2 else 0 + var totalWidth = 0 + var totalHeight = if (lines.size == 1) -2 else 0 for (line in mapped) { val k = line.getWidth(preEvent.font) - if (k > i) i = k - j += line.height + if (k > totalWidth) totalWidth = k + totalHeight += line.height } + @Suppress("NAME_SHADOWING") + var x = x + 12 + @Suppress("NAME_SHADOWING") + var y = y - 12 + + if (x + totalWidth >= minecraft.window.guiScaledWidth) + x = (x - 24 - totalWidth).coerceAtLeast(4) + + if (y + totalHeight + 3 >= minecraft.window.guiScaledHeight) + y = minecraft.window.guiScaledHeight - totalHeight - 3 + pose.pushPose() val tesselator = Tesselator.getInstance() val bufferbuilder = tesselator.builder @@ -109,7 +120,7 @@ class MGUIGraphics(val pose: PoseStack) { val matrix4f = pose.last().pose() val colorEvent = ForgeHooksClient.onRenderTooltipColor(itemStack, pose, x, y, preEvent.font, mapped) - TooltipRenderUtil.renderTooltipBackground(GuiComponent::fillGradient, matrix4f, bufferbuilder, x, y, i, j, 400, colorEvent.backgroundStart, colorEvent.backgroundEnd, colorEvent.borderStart, colorEvent.borderEnd) + TooltipRenderUtil.renderTooltipBackground(GuiComponent::fillGradient, matrix4f, bufferbuilder, x, y, totalWidth, totalHeight, 400, colorEvent.backgroundStart, colorEvent.backgroundEnd, colorEvent.borderStart, colorEvent.borderEnd) RenderSystem.enableDepthTest() RenderSystem.enableBlend() RenderSystem.defaultBlendFunc() From 20469a14dd89e2ac51b0a366c4a5ce9e2f578104 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 22:53:51 +0700 Subject: [PATCH 1199/1199] :wine: --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 68bcfe841..9ad1213ff 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -149,7 +149,7 @@ dependencies { compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-common-api:${jei_version}")) compileOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge-api:${jei_version}")) - runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}")) + // runtimeOnly(fg.deobf("mezz.jei:jei-${jei_mc_version}-forge:${jei_version}")) // runtimeOnly(fg.deobf("ru.dbotthepony:particle-collider:0.4.5"))